{"bookId": "hands_on_machine_learning_aurelien_geron", "title": "Hands-On Machine Learning with Scikit-Learn and TensorFlow", "author": "Aurélien Géron", "totalPages": 510, "engine": "pymupdf", "pages": [{"page": 1, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": []}, {"page": 2, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": []}, {"page": 3, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Aurélien Géron", "words": [{"w": "Aurélien", "b": [0.6601, 0.6756, 0.7705, 0.709]}, {"w": "Géron", "b": [0.7776, 0.6756, 0.8571, 0.709]}]}, {"id": "b_1", "type": "equation", "text": "Hands-on Machine Learning with", "words": [{"w": "Hands-on", "b": [0.1771, 0.2183, 0.375, 0.2754]}, {"w": "Machine", "b": [0.3849, 0.2183, 0.5597, 0.2754]}, {"w": "Learning", "b": [0.5695, 0.2183, 0.7523, 0.2754]}, {"w": "with", "b": [0.7622, 0.2183, 0.8572, 0.2754]}]}, {"id": "b_2", "type": "equation", "text": "Scikit-Learn, Keras, and", "words": [{"w": "Scikit-Learn,", "b": [0.3752, 0.2636, 0.6327, 0.3206]}, {"w": "Keras,", "b": [0.6425, 0.2636, 0.7688, 0.3206]}, {"w": "and", "b": [0.7787, 0.2636, 0.8572, 0.3206]}]}, {"id": "b_3", "type": "paragraph", "text": "TensorFlow Concepts, Tools, and Techniques to", "words": [{"w": "TensorFlow", "b": [0.6209, 0.3088, 0.8572, 0.3659]}, {"w": "Concepts,", "b": [0.3607, 0.3594, 0.4993, 0.397]}, {"w": "Tools,", "b": [0.5073, 0.3594, 0.5913, 0.397]}, {"w": "and", "b": [0.5993, 0.3594, 0.655, 0.397]}, {"w": "Techniques", "b": [0.6629, 0.3594, 0.8209, 0.397]}, {"w": "to", "b": [0.8289, 0.3594, 0.8572, 0.397]}]}, {"id": "b_4", "type": "paragraph", "text": "Build Intelligent Systems", "words": [{"w": "Build", "b": [0.5062, 0.392, 0.5848, 0.4296]}, {"w": "Intelligent", "b": [0.5927, 0.392, 0.7372, 0.4296]}, {"w": "Systems", "b": [0.7451, 0.392, 0.8572, 0.4296]}]}, {"id": "b_5", "type": "paragraph", "text": "SECOND EDITION", "words": [{"w": "SECOND", "b": [0.7349, 0.1857, 0.7935, 0.2066]}, {"w": "EDITION", "b": [0.7971, 0.1857, 0.8571, 0.2066]}]}, {"id": "b_6", "type": "paragraph", "text": "Boston Farnham Sebastopol Tokyo Beijing Boston Farnham Sebastopol Tokyo Beijing", "words": [{"w": "Boston", "b": [0.3636, 0.8952, 0.4154, 0.9172]}, {"w": "Farnham", "b": [0.4387, 0.8952, 0.5055, 0.9172]}, {"w": "Sebastopol", "b": [0.5293, 0.8952, 0.6116, 0.9172]}, {"w": "Tokyo", "b": [0.6365, 0.8952, 0.6808, 0.9172]}, {"w": "Beijing", "b": [0.2857, 0.8952, 0.3377, 0.9172]}, {"w": "Boston", "b": [0.3636, 0.8952, 0.4154, 0.9172]}, {"w": "Farnham", "b": [0.4387, 0.8952, 0.5055, 0.9172]}, {"w": "Sebastopol", "b": [0.5293, 0.8952, 0.6116, 0.9172]}, {"w": "Tokyo", "b": [0.6365, 0.8952, 0.6808, 0.9172]}, {"w": "Beijing", "b": [0.2857, 0.8952, 0.3377, 0.9172]}]}]}, {"page": 4, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "978-1-492-03264-9", "words": [{"w": "978-1-492-03264-9", "b": [0.1429, 0.841, 0.2721, 0.8583]}]}, {"id": "b_1", "type": "paragraph", "text": "[LSI]", "words": [{"w": "[LSI]", "b": [0.1429, 0.8655, 0.1773, 0.8828]}]}, {"id": "b_2", "type": "paragraph", "text": "Hands-on Machine Learning with Scikit-Learn, Keras, and TensorFlow by Aurélien Géron", "words": [{"w": "Hands-on", "b": [0.1428, 0.0884, 0.2057, 0.1065]}, {"w": "Machine", "b": [0.2088, 0.0884, 0.2643, 0.1065]}, {"w": "Learning", "b": [0.2674, 0.0884, 0.3255, 0.1065]}, {"w": "with", "b": [0.3286, 0.0884, 0.3587, 0.1065]}, {"w": "Scikit-Learn,", "b": [0.3619, 0.0884, 0.4436, 0.1065]}, {"w": "Keras,", "b": [0.4467, 0.0884, 0.4868, 0.1065]}, {"w": "and", "b": [0.49, 0.0884, 0.5149, 0.1065]}, {"w": "TensorFlow", "b": [0.518, 0.0884, 0.593, 0.1065]}, {"w": "by", "b": [0.1429, 0.1071, 0.1592, 0.1244]}, {"w": "Aurélien", "b": [0.163, 0.1071, 0.2215, 0.1244]}, {"w": "Géron", "b": [0.2253, 0.1071, 0.2687, 0.1244]}]}, {"id": "b_3", "type": "paragraph", "text": "Copyright © 2019 Aurélien Géron. All rights reserved.", "words": [{"w": "Copyright", "b": [0.1429, 0.1316, 0.2118, 0.1489]}, {"w": "©", "b": [0.2156, 0.1316, 0.2274, 0.1489]}, {"w": "2019", "b": [0.2313, 0.1316, 0.2636, 0.1489]}, {"w": "Aurélien", "b": [0.2675, 0.1316, 0.326, 0.1489]}, {"w": "Géron.", "b": [0.3298, 0.1316, 0.377, 0.1489]}, {"w": "All", "b": [0.3808, 0.1316, 0.401, 0.1489]}, {"w": "rights", "b": [0.4048, 0.1316, 0.4435, 0.1489]}, {"w": "reserved.", "b": [0.4473, 0.1316, 0.5086, 0.1489]}]}, {"id": "b_4", "type": "paragraph", "text": "Printed in the United States of America.", "words": [{"w": "Printed", "b": [0.1429, 0.156, 0.1933, 0.1734]}, {"w": "in", "b": [0.1971, 0.156, 0.2108, 0.1734]}, {"w": "the", "b": [0.2147, 0.156, 0.236, 0.1734]}, {"w": "United", "b": [0.2398, 0.156, 0.2865, 0.1734]}, {"w": "States", "b": [0.2903, 0.156, 0.329, 0.1734]}, {"w": "of", "b": [0.3328, 0.156, 0.3464, 0.1734]}, {"w": "America.", "b": [0.3503, 0.156, 0.412, 0.1734]}]}, {"id": "b_5", "type": "paragraph", "text": "Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.", "words": [{"w": "Published", "b": [0.1429, 0.1805, 0.2099, 0.1979]}, {"w": "by", "b": [0.2138, 0.1805, 0.2301, 0.1979]}, {"w": "O’Reilly", "b": [0.2339, 0.1805, 0.2881, 0.1979]}, {"w": "Media,", "b": [0.2919, 0.1805, 0.3383, 0.1979]}, {"w": "Inc.,", "b": [0.3422, 0.1805, 0.372, 0.1979]}, {"w": "1005", "b": [0.3758, 0.1805, 0.4082, 0.1979]}, {"w": "Gravenstein", "b": [0.412, 0.1805, 0.4939, 0.1979]}, {"w": "Highway", "b": [0.4977, 0.1805, 0.558, 0.1979]}, {"w": "North,", "b": [0.5619, 0.1805, 0.6068, 0.1979]}, {"w": "Sebastopol,", "b": [0.6107, 0.1805, 0.6873, 0.1979]}, {"w": "CA", "b": [0.6911, 0.1805, 0.714, 0.1979]}, {"w": "95472.", "b": [0.7178, 0.1805, 0.7621, 0.1979]}]}, {"id": "b_6", "type": "paragraph", "text": "O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com.", "words": [{"w": "O’Reilly", "b": [0.1429, 0.205, 0.197, 0.2224]}, {"w": "books", "b": [0.2015, 0.205, 0.2419, 0.2224]}, {"w": "may", "b": [0.2464, 0.205, 0.275, 0.2224]}, {"w": "be", "b": [0.2795, 0.205, 0.2953, 0.2224]}, {"w": "purchased", "b": [0.2998, 0.205, 0.3696, 0.2224]}, {"w": "for", "b": [0.3741, 0.205, 0.394, 0.2224]}, {"w": "educational,", "b": [0.3985, 0.205, 0.4807, 0.2224]}, {"w": "business,", "b": [0.4852, 0.205, 0.5461, 0.2224]}, {"w": "or", "b": [0.5506, 0.205, 0.5654, 0.2224]}, {"w": "sales", "b": [0.5699, 0.205, 0.6011, 0.2224]}, {"w": "promotional", "b": [0.6056, 0.205, 0.6909, 0.2224]}, {"w": "use.", "b": [0.6954, 0.205, 0.7215, 0.2224]}, {"w": "Online", "b": [0.726, 0.205, 0.7731, 0.2224]}, {"w": "editions", "b": [0.7775, 0.205, 0.8318, 0.2224]}, {"w": "are", "b": [0.8363, 0.205, 0.8571, 0.2224]}, {"w": "also", "b": [0.1429, 0.2204, 0.1693, 0.2378]}, {"w": "available", "b": [0.1733, 0.2204, 0.2318, 0.2378]}, {"w": "for", "b": [0.2357, 0.2204, 0.2556, 0.2378]}, {"w": "most", "b": [0.2596, 0.2204, 0.2933, 0.2378]}, {"w": "titles", "b": [0.2973, 0.2204, 0.3297, 0.2378]}, {"w": "(http://oreilly.com).", "b": [0.3337, 0.2203, 0.4615, 0.2378]}, {"w": "For", "b": [0.4654, 0.2204, 0.4889, 0.2378]}, {"w": "more", "b": [0.4928, 0.2204, 0.5287, 0.2378]}, {"w": "information,", "b": [0.5326, 0.2204, 0.6185, 0.2378]}, {"w": "contact", "b": [0.6224, 0.2204, 0.6719, 0.2378]}, {"w": "our", "b": [0.6758, 0.2204, 0.6997, 0.2378]}, {"w": "corporate/institutional", "b": [0.7036, 0.2204, 0.8571, 0.2378]}, {"w": "sales", "b": [0.1429, 0.2359, 0.1741, 0.2532]}, {"w": "department:", "b": [0.1779, 0.2359, 0.2605, 0.2532]}, {"w": "800-998-9938", "b": [0.2643, 0.2359, 0.3573, 0.2532]}, {"w": "or", "b": [0.3611, 0.2359, 0.376, 0.2532]}, {"w": "corporate@oreilly.com.", "b": [0.3798, 0.2357, 0.5287, 0.2532]}]}, {"id": "b_7", "type": "paragraph", "text": "Editor: Nicole Tache Interior Designer: David Futato", "words": [{"w": "Editor:", "b": [0.1429, 0.2626, 0.182, 0.2789]}, {"w": "Nicole", "b": [0.1858, 0.2628, 0.2297, 0.2801]}, {"w": "Tache", "b": [0.2335, 0.2628, 0.2731, 0.2801]}, {"w": "Interior", "b": [0.1429, 0.279, 0.1875, 0.2953]}, {"w": "Designer:", "b": [0.1903, 0.279, 0.246, 0.2953]}, {"w": "David", "b": [0.2499, 0.2792, 0.2906, 0.2965]}, {"w": "Futato", "b": [0.2944, 0.2792, 0.3379, 0.2965]}]}, {"id": "b_8", "type": "paragraph", "text": "Cover Designer: Karen Montgomery Illustrator: Rebecca Demarest", "words": [{"w": "Cover", "b": [0.5149, 0.2626, 0.5477, 0.2789]}, {"w": "Designer:", "b": [0.5505, 0.2626, 0.6062, 0.2789]}, {"w": "Karen", "b": [0.61, 0.2628, 0.6514, 0.2801]}, {"w": "Montgomery", "b": [0.6552, 0.2628, 0.7444, 0.2801]}, {"w": "Illustrator:", "b": [0.5149, 0.279, 0.5778, 0.2953]}, {"w": "Rebecca", "b": [0.5816, 0.2792, 0.6366, 0.2965]}, {"w": "Demarest", "b": [0.6405, 0.2792, 0.706, 0.2965]}]}, {"id": "b_9", "type": "paragraph", "text": "June 2019: Second Edition", "words": [{"w": "June", "b": [0.1429, 0.3142, 0.1732, 0.3316]}, {"w": "2019:", "b": [0.177, 0.3142, 0.2133, 0.3316]}, {"w": "Second", "b": [0.2895, 0.3142, 0.3386, 0.3316]}, {"w": "Edition", "b": [0.3424, 0.3142, 0.3929, 0.3316]}]}, {"id": "b_10", "type": "paragraph", "text": "Revision History for the Early Release 2018-11-05: First Release 2019-01-24: Second Release 2019-03-07: Third Release 2019-03-29: Fourth Release 2019-04-22: Fifth Release", "words": [{"w": "Revision", "b": [0.1429, 0.3484, 0.1924, 0.3647]}, {"w": "History", "b": [0.1952, 0.3484, 0.2371, 0.3647]}, {"w": "for", "b": [0.2399, 0.3484, 0.2567, 0.3647]}, {"w": "the", "b": [0.2595, 0.3484, 0.2794, 0.3647]}, {"w": "Early", "b": [0.2823, 0.3484, 0.3113, 0.3647]}, {"w": "Release", "b": [0.3141, 0.3484, 0.3594, 0.3647]}, {"w": "2018-11-05:", "b": [0.1429, 0.3668, 0.2235, 0.3841]}, {"w": "First", "b": [0.2403, 0.3668, 0.2714, 0.3841]}, {"w": "Release", "b": [0.2752, 0.3668, 0.325, 0.3841]}, {"w": "2019-01-24:", "b": [0.1429, 0.3822, 0.2235, 0.3995]}, {"w": "Second", "b": [0.2403, 0.3822, 0.2894, 0.3995]}, {"w": "Release", "b": [0.2932, 0.3822, 0.343, 0.3995]}, {"w": "2019-03-07:", "b": [0.1429, 0.3976, 0.2235, 0.4149]}, {"w": "Third", "b": [0.2403, 0.3976, 0.2794, 0.4149]}, {"w": "Release", "b": [0.2833, 0.3976, 0.3331, 0.4149]}, {"w": "2019-03-29:", "b": [0.1429, 0.413, 0.2235, 0.4304]}, {"w": "Fourth", "b": [0.2403, 0.413, 0.2869, 0.4304]}, {"w": "Release", "b": [0.2907, 0.413, 0.3406, 0.4304]}, {"w": "2019-04-22:", "b": [0.1429, 0.4284, 0.2235, 0.4458]}, {"w": "Fifth", "b": [0.2403, 0.4284, 0.2729, 0.4458]}, {"w": "Release", "b": [0.2767, 0.4284, 0.3266, 0.4458]}]}, {"id": "b_11", "type": "paragraph", "text": "See http://oreilly.com/catalog/errata.csp?isbn=9781492032649 for release details.", "words": [{"w": "See", "b": [0.1429, 0.4635, 0.1652, 0.4808]}, {"w": "http://oreilly.com/catalog/errata.csp?isbn=9781492032649", "b": [0.169, 0.4633, 0.5508, 0.4808]}, {"w": "for", "b": [0.5546, 0.4635, 0.5745, 0.4808]}, {"w": "release", "b": [0.5783, 0.4635, 0.6239, 0.4808]}, {"w": "details.", "b": [0.6277, 0.4635, 0.6752, 0.4808]}]}, {"id": "b_12", "type": "paragraph", "text": "The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Hands-on Machine Learning with Scikit-Learn, Keras, and TensorFlow, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc.", "words": [{"w": "The", "b": [0.1429, 0.4986, 0.1694, 0.5159]}, {"w": "O’Reilly", "b": [0.1764, 0.4986, 0.2306, 0.5159]}, {"w": "logo", "b": [0.2375, 0.4986, 0.2669, 0.5159]}, {"w": "is", "b": [0.2739, 0.4986, 0.2846, 0.5159]}, {"w": "a", "b": [0.2915, 0.4986, 0.2989, 0.5159]}, {"w": "registered", "b": [0.3059, 0.4986, 0.3726, 0.5159]}, {"w": "trademark", "b": [0.3795, 0.4986, 0.4503, 0.5159]}, {"w": "of", "b": [0.4572, 0.4986, 0.4708, 0.5159]}, {"w": "O’Reilly", "b": [0.4778, 0.4986, 0.532, 0.5159]}, {"w": "Media,", "b": [0.5389, 0.4986, 0.5854, 0.5159]}, {"w": "Inc.", "b": [0.5923, 0.4986, 0.6183, 0.5159]}, {"w": "Hands-on", "b": [0.6252, 0.4984, 0.6908, 0.5159]}, {"w": "Machine", "b": [0.6978, 0.4984, 0.7547, 0.5159]}, {"w": "Learning", "b": [0.7617, 0.4984, 0.8206, 0.5159]}, {"w": "with", "b": [0.8276, 0.4984, 0.8571, 0.5159]}, {"w": "Scikit-Learn,", "b": [0.1429, 0.5138, 0.2275, 0.5313]}, {"w": "Keras,", "b": [0.2328, 0.5138, 0.2739, 0.5313]}, {"w": "and", "b": [0.2792, 0.5138, 0.3046, 0.5313]}, {"w": "TensorFlow,", "b": [0.3099, 0.5138, 0.3897, 0.5313]}, {"w": "the", "b": [0.3949, 0.514, 0.4163, 0.5313]}, {"w": "cover", "b": [0.4215, 0.514, 0.4585, 0.5313]}, {"w": "image,", "b": [0.4638, 0.514, 0.5084, 0.5313]}, {"w": "and", "b": [0.5137, 0.514, 0.5392, 0.5313]}, {"w": "related", "b": [0.5445, 0.514, 0.5905, 0.5313]}, {"w": "trade", "b": [0.5957, 0.514, 0.6306, 0.5313]}, {"w": "dress", "b": [0.6359, 0.514, 0.6706, 0.5313]}, {"w": "are", "b": [0.6758, 0.514, 0.6967, 0.5313]}, {"w": "trademarks", "b": [0.7019, 0.514, 0.7788, 0.5313]}, {"w": "of", "b": [0.7841, 0.514, 0.7977, 0.5313]}, {"w": "O’Reilly", "b": [0.8029, 0.514, 0.8571, 0.5313]}, {"w": "Media,", "b": [0.1428, 0.5294, 0.1893, 0.5468]}, {"w": "Inc.", "b": [0.1931, 0.5294, 0.2191, 0.5468]}]}, {"id": "b_13", "type": "paragraph", "text": "While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.", "words": [{"w": "While", "b": [0.1428, 0.5539, 0.1842, 0.5712]}, {"w": "the", "b": [0.1911, 0.5539, 0.2125, 0.5712]}, {"w": "publisher", "b": [0.2194, 0.5539, 0.2832, 0.5712]}, {"w": "and", "b": [0.2901, 0.5539, 0.3157, 0.5712]}, {"w": "the", "b": [0.3226, 0.5539, 0.344, 0.5712]}, {"w": "author", "b": [0.3509, 0.5539, 0.396, 0.5712]}, {"w": "have", "b": [0.4029, 0.5539, 0.434, 0.5712]}, {"w": "used", "b": [0.441, 0.5539, 0.4722, 0.5712]}, {"w": "good", "b": [0.4791, 0.5539, 0.5131, 0.5712]}, {"w": "faith", "b": [0.5201, 0.5539, 0.5512, 0.5712]}, {"w": "efforts", "b": [0.5581, 0.5539, 0.6015, 0.5712]}, {"w": "to", "b": [0.6084, 0.5539, 0.6222, 0.5712]}, {"w": "ensure", "b": [0.6291, 0.5539, 0.6741, 0.5712]}, {"w": "that", "b": [0.681, 0.5539, 0.7074, 0.5712]}, {"w": "the", "b": [0.7144, 0.5539, 0.7357, 0.5712]}, {"w": "information", "b": [0.7427, 0.5539, 0.8246, 0.5712]}, {"w": "and", "b": [0.8316, 0.5539, 0.8571, 0.5712]}, {"w": "instructions", "b": [0.1429, 0.5693, 0.224, 0.5867]}, {"w": "contained", "b": [0.229, 0.5693, 0.296, 0.5867]}, {"w": "in", "b": [0.301, 0.5693, 0.3148, 0.5867]}, {"w": "this", "b": [0.3198, 0.5693, 0.3447, 0.5867]}, {"w": "work", "b": [0.3497, 0.5693, 0.3845, 0.5867]}, {"w": "are", "b": [0.3895, 0.5693, 0.4103, 0.5867]}, {"w": "accurate,", "b": [0.4154, 0.5693, 0.4755, 0.5867]}, {"w": "the", "b": [0.4805, 0.5693, 0.5018, 0.5867]}, {"w": "publisher", "b": [0.5069, 0.5693, 0.5706, 0.5867]}, {"w": "and", "b": [0.5757, 0.5693, 0.6012, 0.5867]}, {"w": "the", "b": [0.6062, 0.5693, 0.6275, 0.5867]}, {"w": "author", "b": [0.6326, 0.5693, 0.6776, 0.5867]}, {"w": "disclaim", "b": [0.6827, 0.5693, 0.7394, 0.5867]}, {"w": "all", "b": [0.7444, 0.5693, 0.7604, 0.5867]}, {"w": "responsibility", "b": [0.7654, 0.5693, 0.8572, 0.5867]}, {"w": "for", "b": [0.1429, 0.5848, 0.1627, 0.6021]}, {"w": "errors", "b": [0.1671, 0.5848, 0.2079, 0.6021]}, {"w": "or", "b": [0.2123, 0.5848, 0.2271, 0.6021]}, {"w": "omissions,", "b": [0.2316, 0.5848, 0.3033, 0.6021]}, {"w": "including", "b": [0.3077, 0.5848, 0.3723, 0.6021]}, {"w": "without", "b": [0.3767, 0.5848, 0.4297, 0.6021]}, {"w": "limitation", "b": [0.4341, 0.5848, 0.5009, 0.6021]}, {"w": "responsibility", "b": [0.5053, 0.5848, 0.5971, 0.6021]}, {"w": "for", "b": [0.6015, 0.5848, 0.6214, 0.6021]}, {"w": "damages", "b": [0.6258, 0.5848, 0.6845, 0.6021]}, {"w": "resulting", "b": [0.689, 0.5848, 0.7486, 0.6021]}, {"w": "from", "b": [0.753, 0.5848, 0.7867, 0.6021]}, {"w": "the", "b": [0.7911, 0.5848, 0.8124, 0.6021]}, {"w": "use", "b": [0.8168, 0.5848, 0.8391, 0.6021]}, {"w": "of", "b": [0.8436, 0.5848, 0.8571, 0.6021]}, {"w": "or", "b": [0.1429, 0.6002, 0.1577, 0.6175]}, {"w": "reliance", "b": [0.1628, 0.6002, 0.216, 0.6175]}, {"w": "on", "b": [0.2211, 0.6002, 0.2389, 0.6175]}, {"w": "this", "b": [0.2441, 0.6002, 0.2689, 0.6175]}, {"w": "work.", "b": [0.2741, 0.6002, 0.3127, 0.6175]}, {"w": "Use", "b": [0.3178, 0.6002, 0.3427, 0.6175]}, {"w": "of", "b": [0.3478, 0.6002, 0.3614, 0.6175]}, {"w": "the", "b": [0.3665, 0.6002, 0.3879, 0.6175]}, {"w": "information", "b": [0.393, 0.6002, 0.475, 0.6175]}, {"w": "and", "b": [0.4801, 0.6002, 0.5056, 0.6175]}, {"w": "instructions", "b": [0.5108, 0.6002, 0.5919, 0.6175]}, {"w": "contained", "b": [0.597, 0.6002, 0.664, 0.6175]}, {"w": "in", "b": [0.6691, 0.6002, 0.6829, 0.6175]}, {"w": "this", "b": [0.688, 0.6002, 0.7129, 0.6175]}, {"w": "work", "b": [0.718, 0.6002, 0.7528, 0.6175]}, {"w": "is", "b": [0.7579, 0.6002, 0.7686, 0.6175]}, {"w": "at", "b": [0.7737, 0.6002, 0.786, 0.6175]}, {"w": "your", "b": [0.7911, 0.6002, 0.8226, 0.6175]}, {"w": "own", "b": [0.8278, 0.6002, 0.8571, 0.6175]}, {"w": "risk.", "b": [0.1429, 0.6156, 0.172, 0.6329]}, {"w": "If", "b": [0.1776, 0.6156, 0.1884, 0.6329]}, {"w": "any", "b": [0.194, 0.6156, 0.2179, 0.6329]}, {"w": "code", "b": [0.2235, 0.6156, 0.2553, 0.6329]}, {"w": "samples", "b": [0.2609, 0.6156, 0.3145, 0.6329]}, {"w": "or", "b": [0.3201, 0.6156, 0.3349, 0.6329]}, {"w": "other", "b": [0.3405, 0.6156, 0.3767, 0.6329]}, {"w": "technology", "b": [0.3823, 0.6156, 0.4575, 0.6329]}, {"w": "this", "b": [0.4631, 0.6156, 0.4879, 0.6329]}, {"w": "work", "b": [0.4935, 0.6156, 0.5283, 0.6329]}, {"w": "contains", "b": [0.5339, 0.6156, 0.591, 0.6329]}, {"w": "or", "b": [0.5966, 0.6156, 0.6114, 0.6329]}, {"w": "describes", "b": [0.617, 0.6156, 0.6791, 0.6329]}, {"w": "is", "b": [0.6847, 0.6156, 0.6954, 0.6329]}, {"w": "subject", "b": [0.701, 0.6156, 0.7485, 0.6329]}, {"w": "to", "b": [0.7541, 0.6156, 0.7678, 0.6329]}, {"w": "open", "b": [0.7734, 0.6156, 0.8073, 0.6329]}, {"w": "source", "b": [0.8128, 0.6156, 0.8571, 0.6329]}, {"w": "licenses", "b": [0.1429, 0.631, 0.1947, 0.6483]}, {"w": "or", "b": [0.2017, 0.631, 0.2166, 0.6483]}, {"w": "the", "b": [0.2236, 0.631, 0.2449, 0.6483]}, {"w": "intellectual", "b": [0.2519, 0.631, 0.3262, 0.6483]}, {"w": "property", "b": [0.3332, 0.631, 0.3921, 0.6483]}, {"w": "rights", "b": [0.3991, 0.631, 0.4378, 0.6483]}, {"w": "of", "b": [0.4447, 0.631, 0.4583, 0.6483]}, {"w": "others,", "b": [0.4653, 0.631, 0.5115, 0.6483]}, {"w": "it", "b": [0.5185, 0.631, 0.5282, 0.6483]}, {"w": "is", "b": [0.5352, 0.631, 0.5459, 0.6483]}, {"w": "your", "b": [0.5529, 0.631, 0.5845, 0.6483]}, {"w": "responsibility", "b": [0.5915, 0.631, 0.6832, 0.6483]}, {"w": "to", "b": [0.6902, 0.631, 0.704, 0.6483]}, {"w": "ensure", "b": [0.7109, 0.631, 0.7559, 0.6483]}, {"w": "that", "b": [0.7629, 0.631, 0.7893, 0.6483]}, {"w": "your", "b": [0.7963, 0.631, 0.8278, 0.6483]}, {"w": "use", "b": [0.8348, 0.631, 0.8571, 0.6483]}, {"w": "thereof", "b": [0.1429, 0.6464, 0.1912, 0.6638]}, {"w": "complies", "b": [0.195, 0.6464, 0.2552, 0.6638]}, {"w": "with", "b": [0.2591, 0.6464, 0.2893, 0.6638]}, {"w": "such", "b": [0.2931, 0.6464, 0.3244, 0.6638]}, {"w": "licenses", "b": [0.3282, 0.6464, 0.3801, 0.6638]}, {"w": "and/or", "b": [0.3839, 0.6464, 0.4299, 0.6638]}, {"w": "rights.", "b": [0.4337, 0.6464, 0.4762, 0.6638]}]}]}, {"page": 5, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Table of Contents", "words": [{"w": "Table", "b": [0.5707, 0.1062, 0.6608, 0.1518]}, {"w": "of", "b": [0.6687, 0.1062, 0.7023, 0.1518]}, {"w": "Contents", "b": [0.7102, 0.1062, 0.8571, 0.1518]}]}, {"id": "b_1", "type": "paragraph", "text": "Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi", "words": [{"w": "Preface.", "b": [0.1429, 0.3456, 0.2066, 0.3674]}, {"w": ".", "b": [0.2104, 0.3456, 0.2155, 0.3674]}, {"w": ".", "b": [0.2193, 0.3456, 0.2244, 0.3674]}, {"w": ".", "b": [0.2282, 0.3456, 0.2333, 0.3674]}, {"w": ".", "b": [0.2371, 0.3456, 0.2422, 0.3674]}, {"w": ".", "b": [0.246, 0.3456, 0.2511, 0.3674]}, {"w": ".", "b": [0.2549, 0.3456, 0.26, 0.3674]}, {"w": ".", "b": [0.2638, 0.3456, 0.2689, 0.3674]}, {"w": ".", "b": [0.2727, 0.3456, 0.2778, 0.3674]}, {"w": ".", "b": [0.2816, 0.3456, 0.2867, 0.3674]}, {"w": ".", "b": [0.2905, 0.3456, 0.2956, 0.3674]}, {"w": ".", "b": [0.2994, 0.3456, 0.3045, 0.3674]}, {"w": ".", "b": [0.3083, 0.3456, 0.3135, 0.3674]}, {"w": ".", "b": [0.3172, 0.3456, 0.3224, 0.3674]}, {"w": ".", "b": [0.3261, 0.3456, 0.3313, 0.3674]}, {"w": ".", "b": [0.335, 0.3456, 0.3402, 0.3674]}, {"w": ".", "b": [0.3439, 0.3456, 0.3491, 0.3674]}, {"w": ".", "b": [0.3528, 0.3456, 0.358, 0.3674]}, {"w": ".", "b": [0.3617, 0.3456, 0.3669, 0.3674]}, {"w": ".", "b": [0.3706, 0.3456, 0.3758, 0.3674]}, {"w": ".", "b": [0.3795, 0.3456, 0.3847, 0.3674]}, {"w": ".", "b": [0.3885, 0.3456, 0.3936, 0.3674]}, {"w": ".", "b": [0.3974, 0.3456, 0.4025, 0.3674]}, {"w": ".", "b": [0.4063, 0.3456, 0.4114, 0.3674]}, {"w": ".", "b": [0.4152, 0.3456, 0.4203, 0.3674]}, {"w": ".", "b": [0.4241, 0.3456, 0.4292, 0.3674]}, {"w": ".", "b": [0.433, 0.3456, 0.4381, 0.3674]}, {"w": ".", "b": [0.4419, 0.3456, 0.447, 0.3674]}, {"w": ".", "b": [0.4508, 0.3456, 0.4559, 0.3674]}, {"w": ".", "b": [0.4597, 0.3456, 0.4648, 0.3674]}, {"w": ".", "b": [0.4686, 0.3456, 0.4737, 0.3674]}, {"w": ".", "b": [0.4775, 0.3456, 0.4826, 0.3674]}, {"w": ".", "b": [0.4864, 0.3456, 0.4915, 0.3674]}, {"w": ".", "b": [0.4953, 0.3456, 0.5005, 0.3674]}, {"w": ".", "b": [0.5042, 0.3456, 0.5094, 0.3674]}, {"w": ".", "b": [0.5131, 0.3456, 0.5183, 0.3674]}, {"w": ".", "b": [0.522, 0.3456, 0.5272, 0.3674]}, {"w": ".", "b": [0.5309, 0.3456, 0.5361, 0.3674]}, {"w": ".", "b": [0.5398, 0.3456, 0.545, 0.3674]}, {"w": ".", "b": [0.5487, 0.3456, 0.5539, 0.3674]}, {"w": ".", "b": [0.5576, 0.3456, 0.5628, 0.3674]}, {"w": ".", "b": [0.5665, 0.3456, 0.5717, 0.3674]}, {"w": ".", "b": [0.5755, 0.3456, 0.5806, 0.3674]}, {"w": ".", "b": [0.5844, 0.3456, 0.5895, 0.3674]}, {"w": ".", "b": [0.5933, 0.3456, 0.5984, 0.3674]}, {"w": ".", "b": [0.6022, 0.3456, 0.6073, 0.3674]}, {"w": ".", "b": [0.6111, 0.3456, 0.6162, 0.3674]}, {"w": ".", "b": [0.62, 0.3456, 0.6251, 0.3674]}, {"w": ".", "b": [0.6289, 0.3456, 0.634, 0.3674]}, {"w": ".", "b": [0.6378, 0.3456, 0.6429, 0.3674]}, {"w": ".", "b": [0.6467, 0.3456, 0.6518, 0.3674]}, {"w": ".", "b": [0.6556, 0.3456, 0.6607, 0.3674]}, {"w": ".", "b": [0.6645, 0.3456, 0.6696, 0.3674]}, {"w": ".", "b": [0.6734, 0.3456, 0.6785, 0.3674]}, {"w": ".", "b": [0.6823, 0.3456, 0.6875, 0.3674]}, {"w": ".", "b": [0.6912, 0.3456, 0.6964, 0.3674]}, {"w": ".", "b": [0.7001, 0.3456, 0.7053, 0.3674]}, {"w": ".", "b": [0.709, 0.3456, 0.7142, 0.3674]}, {"w": ".", "b": [0.7179, 0.3456, 0.7231, 0.3674]}, {"w": ".", "b": [0.7268, 0.3456, 0.732, 0.3674]}, {"w": ".", "b": [0.7357, 0.3456, 0.7409, 0.3674]}, {"w": ".", "b": [0.7446, 0.3456, 0.7498, 0.3674]}, {"w": ".", "b": [0.7535, 0.3456, 0.7587, 0.3674]}, {"w": ".", "b": [0.7625, 0.3456, 0.7676, 0.3674]}, {"w": ".", "b": [0.7714, 0.3456, 0.7765, 0.3674]}, {"w": ".", "b": [0.7803, 0.3456, 0.7854, 0.3674]}, {"w": ".", "b": [0.7892, 0.3456, 0.7943, 0.3674]}, {"w": ".", "b": [0.7981, 0.3456, 0.8032, 0.3674]}, {"w": ".", "b": [0.807, 0.3456, 0.8121, 0.3674]}, {"w": ".", "b": [0.8159, 0.3456, 0.821, 0.3674]}, {"w": ".", "b": [0.8248, 0.3456, 0.8299, 0.3674]}, {"w": "xi", "b": [0.8435, 0.3456, 0.8571, 0.3674]}]}, {"id": "b_2", "type": "paragraph", "text": "Part I. The Fundamentals of Machine Learning", "words": [{"w": "Part", "b": [0.1429, 0.4001, 0.1814, 0.4255]}, {"w": "I.", "b": [0.1858, 0.4001, 0.198, 0.4255]}, {"w": "The", "b": [0.2258, 0.4001, 0.2593, 0.4255]}, {"w": "Fundamentals", "b": [0.2636, 0.4001, 0.3952, 0.4255]}, {"w": "of", "b": [0.3996, 0.4001, 0.4182, 0.4255]}, {"w": "Machine", "b": [0.4226, 0.4001, 0.5002, 0.4255]}, {"w": "Learning", "b": [0.5046, 0.4001, 0.5859, 0.4255]}]}, {"id": "b_3", "type": "paragraph", "text": "1. The Machine Learning Landscape. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 What Is Machine Learning? 4 Why Use Machine Learning? 4 Types of Machine Learning Systems 8", "words": [{"w": "1.", "b": [0.1547, 0.4422, 0.1695, 0.4639]}, {"w": "The", "b": [0.1814, 0.4422, 0.2101, 0.4639]}, {"w": "Machine", "b": [0.2139, 0.4422, 0.2804, 0.4639]}, {"w": "Learning", "b": [0.2842, 0.4422, 0.3538, 0.4639]}, {"w": "Landscape.", "b": [0.3576, 0.4422, 0.445, 0.4639]}, {"w": ".", "b": [0.4488, 0.4422, 0.4539, 0.4639]}, {"w": ".", "b": [0.4577, 0.4422, 0.4628, 0.4639]}, {"w": ".", "b": [0.4666, 0.4422, 0.4717, 0.4639]}, {"w": ".", "b": [0.4755, 0.4422, 0.4806, 0.4639]}, {"w": ".", "b": [0.4844, 0.4422, 0.4895, 0.4639]}, {"w": ".", "b": [0.4933, 0.4422, 0.4984, 0.4639]}, {"w": ".", "b": [0.5022, 0.4422, 0.5073, 0.4639]}, {"w": ".", "b": [0.5111, 0.4422, 0.5162, 0.4639]}, {"w": ".", "b": [0.52, 0.4422, 0.5252, 0.4639]}, {"w": ".", "b": [0.5289, 0.4422, 0.5341, 0.4639]}, {"w": ".", "b": [0.5378, 0.4422, 0.543, 0.4639]}, {"w": ".", "b": [0.5467, 0.4422, 0.5519, 0.4639]}, {"w": ".", "b": [0.5556, 0.4422, 0.5608, 0.4639]}, {"w": ".", "b": [0.5645, 0.4422, 0.5697, 0.4639]}, {"w": ".", "b": [0.5734, 0.4422, 0.5786, 0.4639]}, {"w": ".", "b": [0.5823, 0.4422, 0.5875, 0.4639]}, {"w": ".", "b": [0.5912, 0.4422, 0.5964, 0.4639]}, {"w": ".", "b": [0.6002, 0.4422, 0.6053, 0.4639]}, {"w": ".", "b": [0.6091, 0.4422, 0.6142, 0.4639]}, {"w": ".", "b": [0.618, 0.4422, 0.6231, 0.4639]}, {"w": ".", "b": [0.6269, 0.4422, 0.632, 0.4639]}, {"w": ".", "b": [0.6358, 0.4422, 0.6409, 0.4639]}, {"w": ".", "b": [0.6447, 0.4422, 0.6498, 0.4639]}, {"w": ".", "b": [0.6536, 0.4422, 0.6587, 0.4639]}, {"w": ".", "b": [0.6625, 0.4422, 0.6676, 0.4639]}, {"w": ".", "b": [0.6714, 0.4422, 0.6765, 0.4639]}, {"w": ".", "b": [0.6803, 0.4422, 0.6854, 0.4639]}, {"w": ".", "b": [0.6892, 0.4422, 0.6943, 0.4639]}, {"w": ".", "b": [0.6981, 0.4422, 0.7032, 0.4639]}, {"w": ".", "b": [0.707, 0.4422, 0.7122, 0.4639]}, {"w": ".", "b": [0.7159, 0.4422, 0.7211, 0.4639]}, {"w": ".", "b": [0.7248, 0.4422, 0.73, 0.4639]}, {"w": ".", "b": [0.7337, 0.4422, 0.7389, 0.4639]}, {"w": ".", "b": [0.7426, 0.4422, 0.7478, 0.4639]}, {"w": ".", "b": [0.7515, 0.4422, 0.7567, 0.4639]}, {"w": ".", "b": [0.7604, 0.4422, 0.7656, 0.4639]}, {"w": ".", "b": [0.7693, 0.4422, 0.7745, 0.4639]}, {"w": ".", "b": [0.7782, 0.4422, 0.7834, 0.4639]}, {"w": ".", "b": [0.7872, 0.4422, 0.7923, 0.4639]}, {"w": ".", "b": [0.7961, 0.4422, 0.8012, 0.4639]}, {"w": ".", "b": [0.805, 0.4422, 0.8101, 0.4639]}, {"w": ".", "b": [0.8139, 0.4422, 0.819, 0.4639]}, {"w": ".", "b": [0.8228, 0.4422, 0.8279, 0.4639]}, {"w": ".", "b": [0.8317, 0.4422, 0.8368, 0.4639]}, {"w": "3", "b": [0.8474, 0.4422, 0.8572, 0.4639]}, {"w": "What", "b": [0.1814, 0.4631, 0.2279, 0.4845]}, {"w": "Is", "b": [0.2326, 0.4631, 0.2469, 0.4845]}, {"w": "Machine", "b": [0.2516, 0.4631, 0.3248, 0.4845]}, {"w": "Learning?", "b": [0.3295, 0.4631, 0.4124, 0.4845]}, {"w": "4", "b": [0.8472, 0.4631, 0.8572, 0.4845]}, {"w": "Why", "b": [0.1814, 0.4822, 0.2219, 0.5036]}, {"w": "Use", "b": [0.2266, 0.4822, 0.2573, 0.5036]}, {"w": "Machine", "b": [0.262, 0.4822, 0.3352, 0.5036]}, {"w": "Learning?", "b": [0.3399, 0.4822, 0.4229, 0.5036]}, {"w": "4", "b": [0.8472, 0.4822, 0.8572, 0.5036]}, {"w": "Types", "b": [0.1814, 0.5012, 0.2297, 0.5226]}, {"w": "of", "b": [0.2345, 0.5012, 0.2513, 0.5226]}, {"w": "Machine", "b": [0.256, 0.5012, 0.3291, 0.5226]}, {"w": "Learning", "b": [0.3338, 0.5012, 0.4089, 0.5226]}, {"w": "Systems", "b": [0.4136, 0.5012, 0.4806, 0.5226]}, {"w": "8", "b": [0.8472, 0.5012, 0.8572, 0.5226]}]}, {"id": "b_4", "type": "paragraph", "text": "Supervised/Unsupervised Learning 8 Batch and Online Learning 15 Instance-Based Versus Model-Based Learning 18 Main Challenges of Machine Learning 24", "words": [{"w": "Supervised/Unsupervised", "b": [0.1986, 0.5203, 0.4126, 0.5417]}, {"w": "Learning", "b": [0.4173, 0.5203, 0.4924, 0.5417]}, {"w": "8", "b": [0.8472, 0.5203, 0.8572, 0.5417]}, {"w": "Batch", "b": [0.1986, 0.5393, 0.2459, 0.5607]}, {"w": "and", "b": [0.2506, 0.5393, 0.2821, 0.5607]}, {"w": "Online", "b": [0.2869, 0.5393, 0.3449, 0.5607]}, {"w": "Learning", "b": [0.3497, 0.5393, 0.4247, 0.5607]}, {"w": "15", "b": [0.8372, 0.5393, 0.8572, 0.5607]}, {"w": "Instance-Based", "b": [0.1986, 0.5584, 0.3256, 0.5798]}, {"w": "Versus", "b": [0.3303, 0.5584, 0.3859, 0.5798]}, {"w": "Model-Based", "b": [0.3906, 0.5584, 0.5007, 0.5798]}, {"w": "Learning", "b": [0.5054, 0.5584, 0.5805, 0.5798]}, {"w": "18", "b": [0.8372, 0.5584, 0.8572, 0.5798]}, {"w": "Main", "b": [0.1814, 0.5774, 0.2258, 0.5988]}, {"w": "Challenges", "b": [0.2305, 0.5774, 0.3217, 0.5988]}, {"w": "of", "b": [0.3264, 0.5774, 0.3432, 0.5988]}, {"w": "Machine", "b": [0.3479, 0.5774, 0.421, 0.5988]}, {"w": "Learning", "b": [0.4258, 0.5774, 0.5008, 0.5988]}, {"w": "24", "b": [0.8372, 0.5774, 0.8572, 0.5988]}]}, {"id": "b_5", "type": "paragraph", "text": "Insufficient Quantity of Training Data 24 Nonrepresentative Training Data 26 Poor-Quality Data 27 Irrelevant Features 27 Overfitting the Training Data 28 Underfitting the Training Data 30 Stepping Back 30 Testing and Validating 31", "words": [{"w": "Insufficient", "b": [0.1986, 0.5965, 0.2943, 0.6179]}, {"w": "Quantity", "b": [0.299, 0.5965, 0.3736, 0.6179]}, {"w": "of", "b": [0.3783, 0.5965, 0.3951, 0.6179]}, {"w": "Training", "b": [0.3999, 0.5965, 0.4716, 0.6179]}, {"w": "Data", "b": [0.4763, 0.5965, 0.5159, 0.6179]}, {"w": "24", "b": [0.8372, 0.5965, 0.8572, 0.6179]}, {"w": "Nonrepresentative", "b": [0.1986, 0.6155, 0.3527, 0.6369]}, {"w": "Training", "b": [0.3574, 0.6155, 0.4291, 0.6369]}, {"w": "Data", "b": [0.4338, 0.6155, 0.4734, 0.6369]}, {"w": "26", "b": [0.8372, 0.6155, 0.8572, 0.6369]}, {"w": "Poor-Quality", "b": [0.1986, 0.6346, 0.308, 0.656]}, {"w": "Data", "b": [0.3128, 0.6346, 0.3523, 0.656]}, {"w": "27", "b": [0.8372, 0.6346, 0.8572, 0.656]}, {"w": "Irrelevant", "b": [0.1986, 0.6536, 0.2803, 0.675]}, {"w": "Features", "b": [0.285, 0.6536, 0.3549, 0.675]}, {"w": "27", "b": [0.8372, 0.6536, 0.8572, 0.675]}, {"w": "Overfitting", "b": [0.1986, 0.6727, 0.2919, 0.6941]}, {"w": "the", "b": [0.2966, 0.6727, 0.323, 0.6941]}, {"w": "Training", "b": [0.3277, 0.6727, 0.3994, 0.6941]}, {"w": "Data", "b": [0.4041, 0.6727, 0.4437, 0.6941]}, {"w": "28", "b": [0.8372, 0.6727, 0.8572, 0.6941]}, {"w": "Underfitting", "b": [0.1986, 0.6917, 0.3032, 0.7131]}, {"w": "the", "b": [0.3079, 0.6917, 0.3342, 0.7131]}, {"w": "Training", "b": [0.339, 0.6917, 0.4107, 0.7131]}, {"w": "Data", "b": [0.4154, 0.6917, 0.455, 0.7131]}, {"w": "30", "b": [0.8372, 0.6917, 0.8572, 0.7131]}, {"w": "Stepping", "b": [0.1986, 0.7107, 0.2722, 0.7322]}, {"w": "Back", "b": [0.2769, 0.7107, 0.3175, 0.7322]}, {"w": "30", "b": [0.8372, 0.7107, 0.8572, 0.7322]}, {"w": "Testing", "b": [0.1814, 0.7298, 0.2418, 0.7512]}, {"w": "and", "b": [0.2465, 0.7298, 0.2781, 0.7512]}, {"w": "Validating", "b": [0.2828, 0.7298, 0.3682, 0.7512]}, {"w": "31", "b": [0.8372, 0.7298, 0.8572, 0.7512]}]}, {"id": "b_6", "type": "paragraph", "text": "Hyperparameter Tuning and Model Selection 32 Data Mismatch 33 Exercises 34", "words": [{"w": "Hyperparameter", "b": [0.1986, 0.7488, 0.3367, 0.7703]}, {"w": "Tuning", "b": [0.3414, 0.7488, 0.4014, 0.7703]}, {"w": "and", "b": [0.4062, 0.7488, 0.4377, 0.7703]}, {"w": "Model", "b": [0.4424, 0.7488, 0.4962, 0.7703]}, {"w": "Selection", "b": [0.5009, 0.7488, 0.5766, 0.7703]}, {"w": "32", "b": [0.8372, 0.7488, 0.8572, 0.7703]}, {"w": "Data", "b": [0.1986, 0.7679, 0.2381, 0.7893]}, {"w": "Mismatch", "b": [0.2429, 0.7679, 0.3268, 0.7893]}, {"w": "33", "b": [0.8372, 0.7679, 0.8572, 0.7893]}, {"w": "Exercises", "b": [0.1814, 0.7869, 0.2582, 0.8083]}, {"w": "34", "b": [0.8372, 0.7869, 0.8572, 0.8083]}]}, {"id": "b_7", "type": "paragraph", "text": "2. End-to-End Machine Learning Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Working with Real Data 38 Look at the Big Picture 39", "words": [{"w": "2.", "b": [0.1547, 0.8231, 0.1695, 0.8448]}, {"w": "End-to-End", "b": [0.1814, 0.8231, 0.2696, 0.8448]}, {"w": "Machine", "b": [0.2733, 0.8231, 0.3399, 0.8448]}, {"w": "Learning", "b": [0.3437, 0.8231, 0.4133, 0.8448]}, {"w": "Project.", "b": [0.4171, 0.8231, 0.4773, 0.8448]}, {"w": ".", "b": [0.4811, 0.8231, 0.4862, 0.8448]}, {"w": ".", "b": [0.49, 0.8231, 0.4952, 0.8448]}, {"w": ".", "b": [0.4989, 0.8231, 0.5041, 0.8448]}, {"w": ".", "b": [0.5078, 0.8231, 0.513, 0.8448]}, {"w": ".", "b": [0.5167, 0.8231, 0.5219, 0.8448]}, {"w": ".", "b": [0.5256, 0.8231, 0.5308, 0.8448]}, {"w": ".", "b": [0.5345, 0.8231, 0.5397, 0.8448]}, {"w": ".", "b": [0.5434, 0.8231, 0.5486, 0.8448]}, {"w": ".", "b": [0.5523, 0.8231, 0.5575, 0.8448]}, {"w": ".", "b": [0.5612, 0.8231, 0.5664, 0.8448]}, {"w": ".", "b": [0.5702, 0.8231, 0.5753, 0.8448]}, {"w": ".", "b": [0.5791, 0.8231, 0.5842, 0.8448]}, {"w": ".", "b": [0.588, 0.8231, 0.5931, 0.8448]}, {"w": ".", "b": [0.5969, 0.8231, 0.602, 0.8448]}, {"w": ".", "b": [0.6058, 0.8231, 0.6109, 0.8448]}, {"w": ".", "b": [0.6147, 0.8231, 0.6198, 0.8448]}, {"w": ".", "b": [0.6236, 0.8231, 0.6287, 0.8448]}, {"w": ".", "b": [0.6325, 0.8231, 0.6376, 0.8448]}, {"w": ".", "b": [0.6414, 0.8231, 0.6465, 0.8448]}, {"w": ".", "b": [0.6503, 0.8231, 0.6554, 0.8448]}, {"w": ".", "b": [0.6592, 0.8231, 0.6643, 0.8448]}, {"w": ".", "b": [0.6681, 0.8231, 0.6732, 0.8448]}, {"w": ".", "b": [0.677, 0.8231, 0.6822, 0.8448]}, {"w": ".", "b": [0.6859, 0.8231, 0.6911, 0.8448]}, {"w": ".", "b": [0.6948, 0.8231, 0.7, 0.8448]}, {"w": ".", "b": [0.7037, 0.8231, 0.7089, 0.8448]}, {"w": ".", "b": [0.7126, 0.8231, 0.7178, 0.8448]}, {"w": ".", "b": [0.7215, 0.8231, 0.7267, 0.8448]}, {"w": ".", "b": [0.7304, 0.8231, 0.7356, 0.8448]}, {"w": ".", "b": [0.7393, 0.8231, 0.7445, 0.8448]}, {"w": ".", "b": [0.7482, 0.8231, 0.7534, 0.8448]}, {"w": ".", "b": [0.7572, 0.8231, 0.7623, 0.8448]}, {"w": ".", "b": [0.7661, 0.8231, 0.7712, 0.8448]}, {"w": ".", "b": [0.775, 0.8231, 0.7801, 0.8448]}, {"w": ".", "b": [0.7839, 0.8231, 0.789, 0.8448]}, {"w": ".", "b": [0.7928, 0.8231, 0.7979, 0.8448]}, {"w": ".", "b": [0.8017, 0.8231, 0.8068, 0.8448]}, {"w": ".", "b": [0.8106, 0.8231, 0.8157, 0.8448]}, {"w": ".", "b": [0.8195, 0.8231, 0.8246, 0.8448]}, {"w": "37", "b": [0.8377, 0.8231, 0.8572, 0.8448]}, {"w": "Working", "b": [0.1814, 0.8441, 0.255, 0.8655]}, {"w": "with", "b": [0.2598, 0.8441, 0.2971, 0.8655]}, {"w": "Real", "b": [0.3018, 0.8441, 0.338, 0.8655]}, {"w": "Data", "b": [0.3428, 0.8441, 0.3823, 0.8655]}, {"w": "38", "b": [0.8372, 0.8441, 0.8572, 0.8655]}, {"w": "Look", "b": [0.1814, 0.8631, 0.2242, 0.8845]}, {"w": "at", "b": [0.2289, 0.8631, 0.244, 0.8845]}, {"w": "the", "b": [0.2488, 0.8631, 0.2751, 0.8845]}, {"w": "Big", "b": [0.2798, 0.8631, 0.3074, 0.8845]}, {"w": "Picture", "b": [0.3122, 0.8631, 0.3723, 0.8845]}, {"w": "39", "b": [0.8372, 0.8631, 0.8572, 0.8845]}]}, {"id": "b_8", "type": "paragraph", "text": "iii", "words": [{"w": "iii", "b": [0.8462, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 6, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Frame the Problem 39 Select a Performance Measure 42 Check the Assumptions 45 Get the Data 45", "words": [{"w": "Frame", "b": [0.1986, 0.0791, 0.2524, 0.1005]}, {"w": "the", "b": [0.2571, 0.0791, 0.2834, 0.1005]}, {"w": "Problem", "b": [0.2882, 0.0791, 0.36, 0.1005]}, {"w": "39", "b": [0.8371, 0.0791, 0.8571, 0.1005]}, {"w": "Select", "b": [0.1986, 0.0981, 0.2466, 0.1195]}, {"w": "a", "b": [0.2513, 0.0981, 0.2605, 0.1195]}, {"w": "Performance", "b": [0.2652, 0.0981, 0.3726, 0.1195]}, {"w": "Measure", "b": [0.3774, 0.0981, 0.4487, 0.1195]}, {"w": "42", "b": [0.8371, 0.0981, 0.8571, 0.1195]}, {"w": "Check", "b": [0.1986, 0.1172, 0.2515, 0.1386]}, {"w": "the", "b": [0.2563, 0.1172, 0.2826, 0.1386]}, {"w": "Assumptions", "b": [0.2873, 0.1172, 0.3973, 0.1386]}, {"w": "45", "b": [0.8371, 0.1172, 0.8571, 0.1386]}, {"w": "Get", "b": [0.1814, 0.1362, 0.2115, 0.1576]}, {"w": "the", "b": [0.2163, 0.1362, 0.2426, 0.1576]}, {"w": "Data", "b": [0.2473, 0.1362, 0.2869, 0.1576]}, {"w": "45", "b": [0.8371, 0.1362, 0.8571, 0.1576]}]}, {"id": "b_1", "type": "paragraph", "text": "Create the Workspace 45 Download the Data 49 Take a Quick Look at the Data Structure 50 Create a Test Set 54 Discover and Visualize the Data to Gain Insights 58", "words": [{"w": "Create", "b": [0.1986, 0.1553, 0.253, 0.1767]}, {"w": "the", "b": [0.2577, 0.1553, 0.284, 0.1767]}, {"w": "Workspace", "b": [0.2888, 0.1553, 0.381, 0.1767]}, {"w": "45", "b": [0.8371, 0.1553, 0.8571, 0.1767]}, {"w": "Download", "b": [0.1986, 0.1743, 0.2862, 0.1957]}, {"w": "the", "b": [0.2909, 0.1743, 0.3173, 0.1957]}, {"w": "Data", "b": [0.322, 0.1743, 0.3616, 0.1957]}, {"w": "49", "b": [0.8371, 0.1743, 0.8571, 0.1957]}, {"w": "Take", "b": [0.1986, 0.1933, 0.2378, 0.2148]}, {"w": "a", "b": [0.2426, 0.1933, 0.2517, 0.2148]}, {"w": "Quick", "b": [0.2564, 0.1933, 0.3078, 0.2148]}, {"w": "Look", "b": [0.3125, 0.1933, 0.3553, 0.2148]}, {"w": "at", "b": [0.36, 0.1933, 0.3751, 0.2148]}, {"w": "the", "b": [0.3798, 0.1933, 0.4062, 0.2148]}, {"w": "Data", "b": [0.4109, 0.1933, 0.4505, 0.2148]}, {"w": "Structure", "b": [0.4552, 0.1933, 0.533, 0.2148]}, {"w": "50", "b": [0.8371, 0.1933, 0.8571, 0.2148]}, {"w": "Create", "b": [0.1986, 0.2124, 0.253, 0.2338]}, {"w": "a", "b": [0.2577, 0.2124, 0.2668, 0.2338]}, {"w": "Test", "b": [0.2716, 0.2124, 0.3052, 0.2338]}, {"w": "Set", "b": [0.31, 0.2124, 0.335, 0.2338]}, {"w": "54", "b": [0.8371, 0.2124, 0.8571, 0.2338]}, {"w": "Discover", "b": [0.1814, 0.2314, 0.2556, 0.2529]}, {"w": "and", "b": [0.2604, 0.2314, 0.2919, 0.2529]}, {"w": "Visualize", "b": [0.2966, 0.2314, 0.3723, 0.2529]}, {"w": "the", "b": [0.377, 0.2314, 0.4034, 0.2529]}, {"w": "Data", "b": [0.4081, 0.2314, 0.4477, 0.2529]}, {"w": "to", "b": [0.4524, 0.2314, 0.4694, 0.2529]}, {"w": "Gain", "b": [0.4741, 0.2314, 0.5151, 0.2529]}, {"w": "Insights", "b": [0.5199, 0.2314, 0.5861, 0.2529]}, {"w": "58", "b": [0.8371, 0.2314, 0.8571, 0.2529]}]}, {"id": "b_2", "type": "paragraph", "text": "Visualizing Geographical Data 59 Looking for Correlations 62 Experimenting with Attribute Combinations 65 Prepare the Data for Machine Learning Algorithms 66", "words": [{"w": "Visualizing", "b": [0.1986, 0.2505, 0.2921, 0.2719]}, {"w": "Geographical", "b": [0.2969, 0.2505, 0.4083, 0.2719]}, {"w": "Data", "b": [0.413, 0.2505, 0.4526, 0.2719]}, {"w": "59", "b": [0.8371, 0.2505, 0.8571, 0.2719]}, {"w": "Looking", "b": [0.1986, 0.2695, 0.2681, 0.291]}, {"w": "for", "b": [0.2728, 0.2695, 0.2973, 0.291]}, {"w": "Correlations", "b": [0.3021, 0.2695, 0.4065, 0.291]}, {"w": "62", "b": [0.8371, 0.2695, 0.8571, 0.291]}, {"w": "Experimenting", "b": [0.1986, 0.2886, 0.3233, 0.31]}, {"w": "with", "b": [0.328, 0.2886, 0.3654, 0.31]}, {"w": "Attribute", "b": [0.3701, 0.2886, 0.4465, 0.31]}, {"w": "Combinations", "b": [0.4513, 0.2886, 0.5707, 0.31]}, {"w": "65", "b": [0.8371, 0.2886, 0.8571, 0.31]}, {"w": "Prepare", "b": [0.1814, 0.3076, 0.2464, 0.329]}, {"w": "the", "b": [0.2511, 0.3076, 0.2774, 0.329]}, {"w": "Data", "b": [0.2822, 0.3076, 0.3217, 0.329]}, {"w": "for", "b": [0.3265, 0.3076, 0.351, 0.329]}, {"w": "Machine", "b": [0.3557, 0.3076, 0.4288, 0.329]}, {"w": "Learning", "b": [0.4336, 0.3076, 0.5086, 0.329]}, {"w": "Algorithms", "b": [0.5134, 0.3076, 0.6089, 0.329]}, {"w": "66", "b": [0.8371, 0.3076, 0.8571, 0.329]}]}, {"id": "b_3", "type": "paragraph", "text": "Data Cleaning 67 Handling Text and Categorical Attributes 69 Custom Transformers 71 Feature Scaling 72 Transformation Pipelines 73 Select and Train a Model 75", "words": [{"w": "Data", "b": [0.1986, 0.3267, 0.2381, 0.3481]}, {"w": "Cleaning", "b": [0.2429, 0.3267, 0.3181, 0.3481]}, {"w": "67", "b": [0.8371, 0.3267, 0.8571, 0.3481]}, {"w": "Handling", "b": [0.1986, 0.3457, 0.2776, 0.3671]}, {"w": "Text", "b": [0.2823, 0.3457, 0.3181, 0.3671]}, {"w": "and", "b": [0.3229, 0.3457, 0.3544, 0.3671]}, {"w": "Categorical", "b": [0.3591, 0.3457, 0.4539, 0.3671]}, {"w": "Attributes", "b": [0.4586, 0.3457, 0.5427, 0.3671]}, {"w": "69", "b": [0.8371, 0.3457, 0.8571, 0.3671]}, {"w": "Custom", "b": [0.1986, 0.3648, 0.2652, 0.3862]}, {"w": "Transformers", "b": [0.2699, 0.3648, 0.3828, 0.3862]}, {"w": "71", "b": [0.8371, 0.3648, 0.8571, 0.3862]}, {"w": "Feature", "b": [0.1986, 0.3838, 0.2608, 0.4052]}, {"w": "Scaling", "b": [0.2655, 0.3838, 0.3254, 0.4052]}, {"w": "72", "b": [0.8371, 0.3838, 0.8571, 0.4052]}, {"w": "Transformation", "b": [0.1986, 0.4029, 0.3299, 0.4243]}, {"w": "Pipelines", "b": [0.3346, 0.4029, 0.4105, 0.4243]}, {"w": "73", "b": [0.8371, 0.4029, 0.8571, 0.4243]}, {"w": "Select", "b": [0.1814, 0.4219, 0.2294, 0.4433]}, {"w": "and", "b": [0.2342, 0.4219, 0.2657, 0.4433]}, {"w": "Train", "b": [0.2704, 0.4219, 0.3154, 0.4433]}, {"w": "a", "b": [0.3201, 0.4219, 0.3293, 0.4433]}, {"w": "Model", "b": [0.334, 0.4219, 0.3878, 0.4433]}, {"w": "75", "b": [0.8371, 0.4219, 0.8571, 0.4433]}]}, {"id": "b_4", "type": "paragraph", "text": "Training and Evaluating on the Training Set 75 Better Evaluation Using Cross-Validation 76 Fine-Tune Your Model 79", "words": [{"w": "Training", "b": [0.1986, 0.441, 0.2703, 0.4624]}, {"w": "and", "b": [0.275, 0.441, 0.3065, 0.4624]}, {"w": "Evaluating", "b": [0.3113, 0.441, 0.3996, 0.4624]}, {"w": "on", "b": [0.4044, 0.441, 0.4264, 0.4624]}, {"w": "the", "b": [0.4311, 0.441, 0.4575, 0.4624]}, {"w": "Training", "b": [0.4622, 0.441, 0.5339, 0.4624]}, {"w": "Set", "b": [0.5386, 0.441, 0.5637, 0.4624]}, {"w": "75", "b": [0.8371, 0.441, 0.8571, 0.4624]}, {"w": "Better", "b": [0.1986, 0.46, 0.2494, 0.4814]}, {"w": "Evaluation", "b": [0.2541, 0.46, 0.3434, 0.4814]}, {"w": "Using", "b": [0.3481, 0.46, 0.3967, 0.4814]}, {"w": "Cross-Validation", "b": [0.4014, 0.46, 0.5426, 0.4814]}, {"w": "76", "b": [0.8371, 0.46, 0.8571, 0.4814]}, {"w": "Fine-Tune", "b": [0.1814, 0.4791, 0.2678, 0.5005]}, {"w": "Your", "b": [0.2726, 0.4791, 0.3126, 0.5005]}, {"w": "Model", "b": [0.3174, 0.4791, 0.3711, 0.5005]}, {"w": "79", "b": [0.8371, 0.4791, 0.8571, 0.5005]}]}, {"id": "b_5", "type": "paragraph", "text": "Grid Search 79 Randomized Search 81 Ensemble Methods 82 Analyze the Best Models and Their Errors 82 Evaluate Your System on the Test Set 83 Launch, Monitor, and Maintain Your System 84 Try It Out! 85 Exercises 85", "words": [{"w": "Grid", "b": [0.1986, 0.4981, 0.2378, 0.5195]}, {"w": "Search", "b": [0.2425, 0.4981, 0.298, 0.5195]}, {"w": "79", "b": [0.8371, 0.4981, 0.8571, 0.5195]}, {"w": "Randomized", "b": [0.1986, 0.5172, 0.3053, 0.5386]}, {"w": "Search", "b": [0.31, 0.5172, 0.3656, 0.5386]}, {"w": "81", "b": [0.8371, 0.5172, 0.8571, 0.5386]}, {"w": "Ensemble", "b": [0.1986, 0.5362, 0.2801, 0.5576]}, {"w": "Methods", "b": [0.2848, 0.5362, 0.3584, 0.5576]}, {"w": "82", "b": [0.8371, 0.5362, 0.8571, 0.5576]}, {"w": "Analyze", "b": [0.1986, 0.5553, 0.2659, 0.5767]}, {"w": "the", "b": [0.2707, 0.5553, 0.297, 0.5767]}, {"w": "Best", "b": [0.3017, 0.5553, 0.3373, 0.5767]}, {"w": "Models", "b": [0.342, 0.5553, 0.4034, 0.5767]}, {"w": "and", "b": [0.4081, 0.5553, 0.4397, 0.5767]}, {"w": "Their", "b": [0.4444, 0.5553, 0.4905, 0.5767]}, {"w": "Errors", "b": [0.4953, 0.5553, 0.5486, 0.5767]}, {"w": "82", "b": [0.8371, 0.5553, 0.8571, 0.5767]}, {"w": "Evaluate", "b": [0.1986, 0.5743, 0.2691, 0.5957]}, {"w": "Your", "b": [0.2738, 0.5743, 0.3139, 0.5957]}, {"w": "System", "b": [0.3186, 0.5743, 0.378, 0.5957]}, {"w": "on", "b": [0.3827, 0.5743, 0.4047, 0.5957]}, {"w": "the", "b": [0.4094, 0.5743, 0.4358, 0.5957]}, {"w": "Test", "b": [0.4405, 0.5743, 0.4742, 0.5957]}, {"w": "Set", "b": [0.4789, 0.5743, 0.504, 0.5957]}, {"w": "83", "b": [0.8371, 0.5743, 0.8571, 0.5957]}, {"w": "Launch,", "b": [0.1814, 0.5933, 0.2485, 0.6148]}, {"w": "Monitor,", "b": [0.2533, 0.5933, 0.327, 0.6148]}, {"w": "and", "b": [0.3318, 0.5933, 0.3633, 0.6148]}, {"w": "Maintain", "b": [0.368, 0.5933, 0.4444, 0.6148]}, {"w": "Your", "b": [0.4492, 0.5933, 0.4893, 0.6148]}, {"w": "System", "b": [0.494, 0.5933, 0.5533, 0.6148]}, {"w": "84", "b": [0.8371, 0.5933, 0.8571, 0.6148]}, {"w": "Try", "b": [0.1814, 0.6124, 0.2104, 0.6338]}, {"w": "It", "b": [0.2152, 0.6124, 0.2278, 0.6338]}, {"w": "Out!", "b": [0.2325, 0.6124, 0.2713, 0.6338]}, {"w": "85", "b": [0.8371, 0.6124, 0.8571, 0.6338]}, {"w": "Exercises", "b": [0.1814, 0.6314, 0.2582, 0.6529]}, {"w": "85", "b": [0.8371, 0.6314, 0.8571, 0.6529]}]}, {"id": "b_6", "type": "paragraph", "text": "3. Classification. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 MNIST 87 Training a Binary Classifier 90 Performance Measures 90", "words": [{"w": "3.", "b": [0.1547, 0.6676, 0.1695, 0.6893]}, {"w": "Classification.", "b": [0.1814, 0.6676, 0.2893, 0.6893]}, {"w": ".", "b": [0.293, 0.6676, 0.2982, 0.6893]}, {"w": ".", "b": [0.3019, 0.6676, 0.3071, 0.6893]}, {"w": ".", "b": [0.3108, 0.6676, 0.316, 0.6893]}, {"w": ".", "b": [0.3197, 0.6676, 0.3249, 0.6893]}, {"w": ".", "b": [0.3286, 0.6676, 0.3338, 0.6893]}, {"w": ".", "b": [0.3376, 0.6676, 0.3427, 0.6893]}, {"w": ".", "b": [0.3465, 0.6676, 0.3516, 0.6893]}, {"w": ".", "b": [0.3554, 0.6676, 0.3605, 0.6893]}, {"w": ".", "b": [0.3643, 0.6676, 0.3694, 0.6893]}, {"w": ".", "b": [0.3732, 0.6676, 0.3783, 0.6893]}, {"w": ".", "b": [0.3821, 0.6676, 0.3872, 0.6893]}, {"w": ".", "b": [0.391, 0.6676, 0.3961, 0.6893]}, {"w": ".", "b": [0.3999, 0.6676, 0.405, 0.6893]}, {"w": ".", "b": [0.4088, 0.6676, 0.4139, 0.6893]}, {"w": ".", "b": [0.4177, 0.6676, 0.4228, 0.6893]}, {"w": ".", "b": [0.4266, 0.6676, 0.4317, 0.6893]}, {"w": ".", "b": [0.4355, 0.6676, 0.4406, 0.6893]}, {"w": ".", "b": [0.4444, 0.6676, 0.4496, 0.6893]}, {"w": ".", "b": [0.4533, 0.6676, 0.4585, 0.6893]}, {"w": ".", "b": [0.4622, 0.6676, 0.4674, 0.6893]}, {"w": ".", "b": [0.4711, 0.6676, 0.4763, 0.6893]}, {"w": ".", "b": [0.48, 0.6676, 0.4852, 0.6893]}, {"w": ".", "b": [0.4889, 0.6676, 0.4941, 0.6893]}, {"w": ".", "b": [0.4978, 0.6676, 0.503, 0.6893]}, {"w": ".", "b": [0.5067, 0.6676, 0.5119, 0.6893]}, {"w": ".", "b": [0.5156, 0.6676, 0.5208, 0.6893]}, {"w": ".", "b": [0.5246, 0.6676, 0.5297, 0.6893]}, {"w": ".", "b": [0.5335, 0.6676, 0.5386, 0.6893]}, {"w": ".", "b": [0.5424, 0.6676, 0.5475, 0.6893]}, {"w": ".", "b": [0.5513, 0.6676, 0.5564, 0.6893]}, {"w": ".", "b": [0.5602, 0.6676, 0.5653, 0.6893]}, {"w": ".", "b": [0.5691, 0.6676, 0.5742, 0.6893]}, {"w": ".", "b": [0.578, 0.6676, 0.5831, 0.6893]}, {"w": ".", "b": [0.5869, 0.6676, 0.592, 0.6893]}, {"w": ".", "b": [0.5958, 0.6676, 0.6009, 0.6893]}, {"w": ".", "b": [0.6047, 0.6676, 0.6098, 0.6893]}, {"w": ".", "b": [0.6136, 0.6676, 0.6187, 0.6893]}, {"w": ".", "b": [0.6225, 0.6676, 0.6276, 0.6893]}, {"w": ".", "b": [0.6314, 0.6676, 0.6366, 0.6893]}, {"w": ".", "b": [0.6403, 0.6676, 0.6455, 0.6893]}, {"w": ".", "b": [0.6492, 0.6676, 0.6544, 0.6893]}, {"w": ".", "b": [0.6581, 0.6676, 0.6633, 0.6893]}, {"w": ".", "b": [0.667, 0.6676, 0.6722, 0.6893]}, {"w": ".", "b": [0.6759, 0.6676, 0.6811, 0.6893]}, {"w": ".", "b": [0.6848, 0.6676, 0.69, 0.6893]}, {"w": ".", "b": [0.6937, 0.6676, 0.6989, 0.6893]}, {"w": ".", "b": [0.7026, 0.6676, 0.7078, 0.6893]}, {"w": ".", "b": [0.7116, 0.6676, 0.7167, 0.6893]}, {"w": ".", "b": [0.7205, 0.6676, 0.7256, 0.6893]}, {"w": ".", "b": [0.7294, 0.6676, 0.7345, 0.6893]}, {"w": ".", "b": [0.7383, 0.6676, 0.7434, 0.6893]}, {"w": ".", "b": [0.7472, 0.6676, 0.7523, 0.6893]}, {"w": ".", "b": [0.7561, 0.6676, 0.7612, 0.6893]}, {"w": ".", "b": [0.765, 0.6676, 0.7701, 0.6893]}, {"w": ".", "b": [0.7739, 0.6676, 0.779, 0.6893]}, {"w": ".", "b": [0.7828, 0.6676, 0.7879, 0.6893]}, {"w": ".", "b": [0.7917, 0.6676, 0.7968, 0.6893]}, {"w": ".", "b": [0.8006, 0.6676, 0.8057, 0.6893]}, {"w": ".", "b": [0.8095, 0.6676, 0.8146, 0.6893]}, {"w": ".", "b": [0.8184, 0.6676, 0.8236, 0.6893]}, {"w": "87", "b": [0.8377, 0.6676, 0.8571, 0.6893]}, {"w": "MNIST", "b": [0.1814, 0.6886, 0.2453, 0.71]}, {"w": "87", "b": [0.8371, 0.6886, 0.8571, 0.71]}, {"w": "Training", "b": [0.1814, 0.7076, 0.2531, 0.729]}, {"w": "a", "b": [0.2579, 0.7076, 0.267, 0.729]}, {"w": "Binary", "b": [0.2717, 0.7076, 0.328, 0.729]}, {"w": "Classifier", "b": [0.3327, 0.7076, 0.4102, 0.729]}, {"w": "90", "b": [0.8371, 0.7076, 0.8571, 0.729]}, {"w": "Performance", "b": [0.1814, 0.7267, 0.2889, 0.7481]}, {"w": "Measures", "b": [0.2936, 0.7267, 0.3725, 0.7481]}, {"w": "90", "b": [0.8371, 0.7267, 0.8571, 0.7481]}]}, {"id": "b_7", "type": "paragraph", "text": "Measuring Accuracy Using Cross-Validation 91 Confusion Matrix 92 Precision and Recall 94 Precision/Recall Tradeoff 95 The ROC Curve 99 Multiclass Classification 102 Error Analysis 104", "words": [{"w": "Measuring", "b": [0.1986, 0.7457, 0.2878, 0.7671]}, {"w": "Accuracy", "b": [0.2925, 0.7457, 0.3703, 0.7671]}, {"w": "Using", "b": [0.375, 0.7457, 0.4236, 0.7671]}, {"w": "Cross-Validation", "b": [0.4283, 0.7457, 0.5695, 0.7671]}, {"w": "91", "b": [0.8371, 0.7457, 0.8571, 0.7671]}, {"w": "Confusion", "b": [0.1986, 0.7648, 0.2869, 0.7862]}, {"w": "Matrix", "b": [0.2916, 0.7648, 0.3481, 0.7862]}, {"w": "92", "b": [0.8371, 0.7648, 0.8571, 0.7862]}, {"w": "Precision", "b": [0.1986, 0.7838, 0.2765, 0.8052]}, {"w": "and", "b": [0.2813, 0.7838, 0.3128, 0.8052]}, {"w": "Recall", "b": [0.3175, 0.7838, 0.3678, 0.8052]}, {"w": "94", "b": [0.8371, 0.7838, 0.8571, 0.8052]}, {"w": "Precision/Recall", "b": [0.1986, 0.8029, 0.3337, 0.8243]}, {"w": "Tradeoff", "b": [0.3384, 0.8029, 0.4093, 0.8243]}, {"w": "95", "b": [0.8371, 0.8029, 0.8571, 0.8243]}, {"w": "The", "b": [0.1986, 0.8219, 0.2314, 0.8433]}, {"w": "ROC", "b": [0.2361, 0.8219, 0.2789, 0.8433]}, {"w": "Curve", "b": [0.2836, 0.8219, 0.3353, 0.8433]}, {"w": "99", "b": [0.8371, 0.8219, 0.8571, 0.8433]}, {"w": "Multiclass", "b": [0.1814, 0.841, 0.2661, 0.8624]}, {"w": "Classification", "b": [0.2708, 0.841, 0.3832, 0.8624]}, {"w": "102", "b": [0.8271, 0.841, 0.8571, 0.8624]}, {"w": "Error", "b": [0.1814, 0.86, 0.2271, 0.8814]}, {"w": "Analysis", "b": [0.2318, 0.86, 0.3024, 0.8814]}, {"w": "104", "b": [0.8271, 0.86, 0.8571, 0.8814]}]}, {"id": "b_8", "type": "paragraph", "text": "iv | Table of Contents", "words": [{"w": "iv", "b": [0.1429, 0.9225, 0.1532, 0.9388]}, {"w": "|", "b": [0.1711, 0.9225, 0.1748, 0.9388]}, {"w": "Table", "b": [0.1927, 0.9225, 0.2248, 0.9388]}, {"w": "of", "b": [0.2276, 0.9225, 0.2396, 0.9388]}, {"w": "Contents", "b": [0.2424, 0.9225, 0.2949, 0.9388]}]}]}, {"page": 7, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Multilabel Classification 108 Multioutput Classification 109 Exercises 110", "words": [{"w": "Multilabel", "b": [0.1814, 0.0791, 0.2667, 0.1005]}, {"w": "Classification", "b": [0.2714, 0.0791, 0.3838, 0.1005]}, {"w": "108", "b": [0.8271, 0.0791, 0.8571, 0.1005]}, {"w": "Multioutput", "b": [0.1814, 0.0981, 0.2839, 0.1195]}, {"w": "Classification", "b": [0.2887, 0.0981, 0.4011, 0.1195]}, {"w": "109", "b": [0.8271, 0.0981, 0.8571, 0.1195]}, {"w": "Exercises", "b": [0.1814, 0.1172, 0.2582, 0.1386]}, {"w": "110", "b": [0.8271, 0.1172, 0.8571, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "4. Training Models. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Linear Regression 114", "words": [{"w": "4.", "b": [0.1547, 0.1533, 0.1695, 0.1751]}, {"w": "Training", "b": [0.1814, 0.1533, 0.2469, 0.1751]}, {"w": "Models.", "b": [0.2506, 0.1533, 0.3121, 0.1751]}, {"w": ".", "b": [0.3159, 0.1533, 0.321, 0.1751]}, {"w": ".", "b": [0.3248, 0.1533, 0.3299, 0.1751]}, {"w": ".", "b": [0.3337, 0.1533, 0.3388, 0.1751]}, {"w": ".", "b": [0.3426, 0.1533, 0.3477, 0.1751]}, {"w": ".", "b": [0.3515, 0.1533, 0.3566, 0.1751]}, {"w": ".", "b": [0.3604, 0.1533, 0.3656, 0.1751]}, {"w": ".", "b": [0.3693, 0.1533, 0.3745, 0.1751]}, {"w": ".", "b": [0.3782, 0.1533, 0.3834, 0.1751]}, {"w": ".", "b": [0.3871, 0.1533, 0.3923, 0.1751]}, {"w": ".", "b": [0.396, 0.1533, 0.4012, 0.1751]}, {"w": ".", "b": [0.4049, 0.1533, 0.4101, 0.1751]}, {"w": ".", "b": [0.4138, 0.1533, 0.419, 0.1751]}, {"w": ".", "b": [0.4227, 0.1533, 0.4279, 0.1751]}, {"w": ".", "b": [0.4316, 0.1533, 0.4368, 0.1751]}, {"w": ".", "b": [0.4406, 0.1533, 0.4457, 0.1751]}, {"w": ".", "b": [0.4495, 0.1533, 0.4546, 0.1751]}, {"w": ".", "b": [0.4584, 0.1533, 0.4635, 0.1751]}, {"w": ".", "b": [0.4673, 0.1533, 0.4724, 0.1751]}, {"w": ".", "b": [0.4762, 0.1533, 0.4813, 0.1751]}, {"w": ".", "b": [0.4851, 0.1533, 0.4902, 0.1751]}, {"w": ".", "b": [0.494, 0.1533, 0.4991, 0.1751]}, {"w": ".", "b": [0.5029, 0.1533, 0.508, 0.1751]}, {"w": ".", "b": [0.5118, 0.1533, 0.5169, 0.1751]}, {"w": ".", "b": [0.5207, 0.1533, 0.5258, 0.1751]}, {"w": ".", "b": [0.5296, 0.1533, 0.5347, 0.1751]}, {"w": ".", "b": [0.5385, 0.1533, 0.5436, 0.1751]}, {"w": ".", "b": [0.5474, 0.1533, 0.5526, 0.1751]}, {"w": ".", "b": [0.5563, 0.1533, 0.5615, 0.1751]}, {"w": ".", "b": [0.5652, 0.1533, 0.5704, 0.1751]}, {"w": ".", "b": [0.5741, 0.1533, 0.5793, 0.1751]}, {"w": ".", "b": [0.583, 0.1533, 0.5882, 0.1751]}, {"w": ".", "b": [0.5919, 0.1533, 0.5971, 0.1751]}, {"w": ".", "b": [0.6008, 0.1533, 0.606, 0.1751]}, {"w": ".", "b": [0.6097, 0.1533, 0.6149, 0.1751]}, {"w": ".", "b": [0.6186, 0.1533, 0.6238, 0.1751]}, {"w": ".", "b": [0.6276, 0.1533, 0.6327, 0.1751]}, {"w": ".", "b": [0.6365, 0.1533, 0.6416, 0.1751]}, {"w": ".", "b": [0.6454, 0.1533, 0.6505, 0.1751]}, {"w": ".", "b": [0.6543, 0.1533, 0.6594, 0.1751]}, {"w": ".", "b": [0.6632, 0.1533, 0.6683, 0.1751]}, {"w": ".", "b": [0.6721, 0.1533, 0.6772, 0.1751]}, {"w": ".", "b": [0.681, 0.1533, 0.6861, 0.1751]}, {"w": ".", "b": [0.6899, 0.1533, 0.695, 0.1751]}, {"w": ".", "b": [0.6988, 0.1533, 0.7039, 0.1751]}, {"w": ".", "b": [0.7077, 0.1533, 0.7128, 0.1751]}, {"w": ".", "b": [0.7166, 0.1533, 0.7217, 0.1751]}, {"w": ".", "b": [0.7255, 0.1533, 0.7306, 0.1751]}, {"w": ".", "b": [0.7344, 0.1533, 0.7396, 0.1751]}, {"w": ".", "b": [0.7433, 0.1533, 0.7485, 0.1751]}, {"w": ".", "b": [0.7522, 0.1533, 0.7574, 0.1751]}, {"w": ".", "b": [0.7611, 0.1533, 0.7663, 0.1751]}, {"w": ".", "b": [0.77, 0.1533, 0.7752, 0.1751]}, {"w": ".", "b": [0.7789, 0.1533, 0.7841, 0.1751]}, {"w": ".", "b": [0.7878, 0.1533, 0.793, 0.1751]}, {"w": ".", "b": [0.7967, 0.1533, 0.8019, 0.1751]}, {"w": ".", "b": [0.8056, 0.1533, 0.8108, 0.1751]}, {"w": ".", "b": [0.8146, 0.1533, 0.8197, 0.1751]}, {"w": "113", "b": [0.828, 0.1533, 0.8571, 0.1751]}, {"w": "Linear", "b": [0.1814, 0.1743, 0.2353, 0.1957]}, {"w": "Regression", "b": [0.2401, 0.1743, 0.3311, 0.1957]}, {"w": "114", "b": [0.8271, 0.1743, 0.8571, 0.1957]}]}, {"id": "b_2", "type": "paragraph", "text": "The Normal Equation 116 Computational Complexity 119 Gradient Descent 119", "words": [{"w": "The", "b": [0.1986, 0.1933, 0.2314, 0.2148]}, {"w": "Normal", "b": [0.2361, 0.1933, 0.3009, 0.2148]}, {"w": "Equation", "b": [0.3056, 0.1933, 0.3819, 0.2148]}, {"w": "116", "b": [0.8271, 0.1933, 0.8571, 0.2148]}, {"w": "Computational", "b": [0.1986, 0.2124, 0.3252, 0.2338]}, {"w": "Complexity", "b": [0.3299, 0.2124, 0.4274, 0.2338]}, {"w": "119", "b": [0.8271, 0.2124, 0.8571, 0.2338]}, {"w": "Gradient", "b": [0.1814, 0.2314, 0.256, 0.2529]}, {"w": "Descent", "b": [0.2607, 0.2314, 0.3275, 0.2529]}, {"w": "119", "b": [0.8271, 0.2314, 0.8571, 0.2529]}]}, {"id": "b_3", "type": "paragraph", "text": "Batch Gradient Descent 123 Stochastic Gradient Descent 126 Mini-batch Gradient Descent 129 Polynomial Regression 130 Learning Curves 132 Regularized Linear Models 136", "words": [{"w": "Batch", "b": [0.1986, 0.2505, 0.2459, 0.2719]}, {"w": "Gradient", "b": [0.2506, 0.2505, 0.3251, 0.2719]}, {"w": "Descent", "b": [0.3299, 0.2505, 0.3967, 0.2719]}, {"w": "123", "b": [0.8271, 0.2505, 0.8571, 0.2719]}, {"w": "Stochastic", "b": [0.1986, 0.2695, 0.2829, 0.291]}, {"w": "Gradient", "b": [0.2876, 0.2695, 0.3622, 0.291]}, {"w": "Descent", "b": [0.3669, 0.2695, 0.4338, 0.291]}, {"w": "126", "b": [0.8271, 0.2695, 0.8571, 0.291]}, {"w": "Mini-batch", "b": [0.1986, 0.2886, 0.2927, 0.31]}, {"w": "Gradient", "b": [0.2975, 0.2886, 0.372, 0.31]}, {"w": "Descent", "b": [0.3768, 0.2886, 0.4436, 0.31]}, {"w": "129", "b": [0.8271, 0.2886, 0.8571, 0.31]}, {"w": "Polynomial", "b": [0.1814, 0.3076, 0.277, 0.329]}, {"w": "Regression", "b": [0.2818, 0.3076, 0.3728, 0.329]}, {"w": "130", "b": [0.8271, 0.3076, 0.8572, 0.329]}, {"w": "Learning", "b": [0.1814, 0.3267, 0.2565, 0.3481]}, {"w": "Curves", "b": [0.2612, 0.3267, 0.3206, 0.3481]}, {"w": "132", "b": [0.8271, 0.3267, 0.8572, 0.3481]}, {"w": "Regularized", "b": [0.1814, 0.3457, 0.2804, 0.3671]}, {"w": "Linear", "b": [0.2851, 0.3457, 0.339, 0.3671]}, {"w": "Models", "b": [0.3437, 0.3457, 0.4051, 0.3671]}, {"w": "136", "b": [0.8271, 0.3457, 0.8571, 0.3671]}]}, {"id": "b_4", "type": "paragraph", "text": "Ridge Regression 137 Lasso Regression 139 Elastic Net 142 Early Stopping 142 Logistic Regression 144", "words": [{"w": "Ridge", "b": [0.1986, 0.3648, 0.2467, 0.3862]}, {"w": "Regression", "b": [0.2514, 0.3648, 0.3424, 0.3862]}, {"w": "137", "b": [0.8271, 0.3648, 0.8572, 0.3862]}, {"w": "Lasso", "b": [0.1986, 0.3838, 0.2448, 0.4052]}, {"w": "Regression", "b": [0.2496, 0.3838, 0.3406, 0.4052]}, {"w": "139", "b": [0.8271, 0.3838, 0.8572, 0.4052]}, {"w": "Elastic", "b": [0.1986, 0.4029, 0.2532, 0.4243]}, {"w": "Net", "b": [0.2579, 0.4029, 0.2881, 0.4243]}, {"w": "142", "b": [0.8271, 0.4029, 0.8571, 0.4243]}, {"w": "Early", "b": [0.1986, 0.4219, 0.2421, 0.4433]}, {"w": "Stopping", "b": [0.2468, 0.4219, 0.3223, 0.4433]}, {"w": "142", "b": [0.8271, 0.4219, 0.8572, 0.4433]}, {"w": "Logistic", "b": [0.1814, 0.441, 0.247, 0.4624]}, {"w": "Regression", "b": [0.2517, 0.441, 0.3427, 0.4624]}, {"w": "144", "b": [0.8271, 0.441, 0.8572, 0.4624]}]}, {"id": "b_5", "type": "paragraph", "text": "Estimating Probabilities 144 Training and Cost Function 145 Decision Boundaries 146 Softmax Regression 149 Exercises 153", "words": [{"w": "Estimating", "b": [0.1986, 0.46, 0.2889, 0.4814]}, {"w": "Probabilities", "b": [0.2936, 0.46, 0.3989, 0.4814]}, {"w": "144", "b": [0.8272, 0.46, 0.8572, 0.4814]}, {"w": "Training", "b": [0.1986, 0.4791, 0.2703, 0.5005]}, {"w": "and", "b": [0.275, 0.4791, 0.3065, 0.5005]}, {"w": "Cost", "b": [0.3113, 0.4791, 0.3498, 0.5005]}, {"w": "Function", "b": [0.3545, 0.4791, 0.4303, 0.5005]}, {"w": "145", "b": [0.8272, 0.4791, 0.8572, 0.5005]}, {"w": "Decision", "b": [0.1986, 0.4981, 0.2724, 0.5195]}, {"w": "Boundaries", "b": [0.2771, 0.4981, 0.3728, 0.5195]}, {"w": "146", "b": [0.8272, 0.4981, 0.8572, 0.5195]}, {"w": "Softmax", "b": [0.1986, 0.5172, 0.2676, 0.5386]}, {"w": "Regression", "b": [0.2724, 0.5172, 0.3634, 0.5386]}, {"w": "149", "b": [0.8272, 0.5172, 0.8572, 0.5386]}, {"w": "Exercises", "b": [0.1814, 0.5362, 0.2582, 0.5576]}, {"w": "153", "b": [0.8271, 0.5362, 0.8572, 0.5576]}]}, {"id": "b_6", "type": "paragraph", "text": "5. Support Vector Machines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 Linear SVM Classification 155", "words": [{"w": "5.", "b": [0.1547, 0.5724, 0.1695, 0.5941]}, {"w": "Support", "b": [0.1814, 0.5724, 0.244, 0.5941]}, {"w": "Vector", "b": [0.2477, 0.5724, 0.2981, 0.5941]}, {"w": "Machines.", "b": [0.3018, 0.5724, 0.3809, 0.5941]}, {"w": ".", "b": [0.3846, 0.5724, 0.3898, 0.5941]}, {"w": ".", "b": [0.3935, 0.5724, 0.3987, 0.5941]}, {"w": ".", "b": [0.4024, 0.5724, 0.4076, 0.5941]}, {"w": ".", "b": [0.4113, 0.5724, 0.4165, 0.5941]}, {"w": ".", "b": [0.4202, 0.5724, 0.4254, 0.5941]}, {"w": ".", "b": [0.4291, 0.5724, 0.4343, 0.5941]}, {"w": ".", "b": [0.4381, 0.5724, 0.4432, 0.5941]}, {"w": ".", "b": [0.447, 0.5724, 0.4521, 0.5941]}, {"w": ".", "b": [0.4559, 0.5724, 0.461, 0.5941]}, {"w": ".", "b": [0.4648, 0.5724, 0.4699, 0.5941]}, {"w": ".", "b": [0.4737, 0.5724, 0.4788, 0.5941]}, {"w": ".", "b": [0.4826, 0.5724, 0.4877, 0.5941]}, {"w": ".", "b": [0.4915, 0.5724, 0.4966, 0.5941]}, {"w": ".", "b": [0.5004, 0.5724, 0.5055, 0.5941]}, {"w": ".", "b": [0.5093, 0.5724, 0.5144, 0.5941]}, {"w": ".", "b": [0.5182, 0.5724, 0.5233, 0.5941]}, {"w": ".", "b": [0.5271, 0.5724, 0.5322, 0.5941]}, {"w": ".", "b": [0.536, 0.5724, 0.5411, 0.5941]}, {"w": ".", "b": [0.5449, 0.5724, 0.5501, 0.5941]}, {"w": ".", "b": [0.5538, 0.5724, 0.559, 0.5941]}, {"w": ".", "b": [0.5627, 0.5724, 0.5679, 0.5941]}, {"w": ".", "b": [0.5716, 0.5724, 0.5768, 0.5941]}, {"w": ".", "b": [0.5805, 0.5724, 0.5857, 0.5941]}, {"w": ".", "b": [0.5894, 0.5724, 0.5946, 0.5941]}, {"w": ".", "b": [0.5983, 0.5724, 0.6035, 0.5941]}, {"w": ".", "b": [0.6072, 0.5724, 0.6124, 0.5941]}, {"w": ".", "b": [0.6161, 0.5724, 0.6213, 0.5941]}, {"w": ".", "b": [0.6251, 0.5724, 0.6302, 0.5941]}, {"w": ".", "b": [0.634, 0.5724, 0.6391, 0.5941]}, {"w": ".", "b": [0.6429, 0.5724, 0.648, 0.5941]}, {"w": ".", "b": [0.6518, 0.5724, 0.6569, 0.5941]}, {"w": ".", "b": [0.6607, 0.5724, 0.6658, 0.5941]}, {"w": ".", "b": [0.6696, 0.5724, 0.6747, 0.5941]}, {"w": ".", "b": [0.6785, 0.5724, 0.6836, 0.5941]}, {"w": ".", "b": [0.6874, 0.5724, 0.6925, 0.5941]}, {"w": ".", "b": [0.6963, 0.5724, 0.7014, 0.5941]}, {"w": ".", "b": [0.7052, 0.5724, 0.7103, 0.5941]}, {"w": ".", "b": [0.7141, 0.5724, 0.7192, 0.5941]}, {"w": ".", "b": [0.723, 0.5724, 0.7281, 0.5941]}, {"w": ".", "b": [0.7319, 0.5724, 0.7371, 0.5941]}, {"w": ".", "b": [0.7408, 0.5724, 0.746, 0.5941]}, {"w": ".", "b": [0.7497, 0.5724, 0.7549, 0.5941]}, {"w": ".", "b": [0.7586, 0.5724, 0.7638, 0.5941]}, {"w": ".", "b": [0.7675, 0.5724, 0.7727, 0.5941]}, {"w": ".", "b": [0.7764, 0.5724, 0.7816, 0.5941]}, {"w": ".", "b": [0.7853, 0.5724, 0.7905, 0.5941]}, {"w": ".", "b": [0.7942, 0.5724, 0.7994, 0.5941]}, {"w": ".", "b": [0.8031, 0.5724, 0.8083, 0.5941]}, {"w": ".", "b": [0.8121, 0.5724, 0.8172, 0.5941]}, {"w": "155", "b": [0.828, 0.5724, 0.8571, 0.5941]}, {"w": "Linear", "b": [0.1814, 0.5933, 0.2353, 0.6148]}, {"w": "SVM", "b": [0.2401, 0.5933, 0.2831, 0.6148]}, {"w": "Classification", "b": [0.2879, 0.5933, 0.4003, 0.6148]}, {"w": "155", "b": [0.8272, 0.5933, 0.8572, 0.6148]}]}, {"id": "b_7", "type": "paragraph", "text": "Soft Margin Classification 156 Nonlinear SVM Classification 159", "words": [{"w": "Soft", "b": [0.1986, 0.6124, 0.2316, 0.6338]}, {"w": "Margin", "b": [0.2363, 0.6124, 0.2981, 0.6338]}, {"w": "Classification", "b": [0.3029, 0.6124, 0.4153, 0.6338]}, {"w": "156", "b": [0.8272, 0.6124, 0.8572, 0.6338]}, {"w": "Nonlinear", "b": [0.1814, 0.6314, 0.2664, 0.6529]}, {"w": "SVM", "b": [0.2711, 0.6314, 0.3142, 0.6529]}, {"w": "Classification", "b": [0.3189, 0.6314, 0.4313, 0.6529]}, {"w": "159", "b": [0.8272, 0.6314, 0.8572, 0.6529]}]}, {"id": "b_8", "type": "paragraph", "text": "Polynomial Kernel 160 Adding Similarity Features 161 Gaussian RBF Kernel 162 Computational Complexity 163 SVM Regression 164 Under the Hood 166", "words": [{"w": "Polynomial", "b": [0.1986, 0.6505, 0.2942, 0.6719]}, {"w": "Kernel", "b": [0.2989, 0.6505, 0.3545, 0.6719]}, {"w": "160", "b": [0.8272, 0.6505, 0.8572, 0.6719]}, {"w": "Adding", "b": [0.1986, 0.6695, 0.2611, 0.691]}, {"w": "Similarity", "b": [0.2659, 0.6695, 0.3476, 0.691]}, {"w": "Features", "b": [0.3524, 0.6695, 0.4222, 0.691]}, {"w": "161", "b": [0.8272, 0.6695, 0.8572, 0.691]}, {"w": "Gaussian", "b": [0.1986, 0.6886, 0.2747, 0.71]}, {"w": "RBF", "b": [0.2794, 0.6886, 0.3156, 0.71]}, {"w": "Kernel", "b": [0.3204, 0.6886, 0.376, 0.71]}, {"w": "162", "b": [0.8272, 0.6886, 0.8572, 0.71]}, {"w": "Computational", "b": [0.1986, 0.7076, 0.3252, 0.729]}, {"w": "Complexity", "b": [0.3299, 0.7076, 0.4274, 0.729]}, {"w": "163", "b": [0.8272, 0.7076, 0.8572, 0.729]}, {"w": "SVM", "b": [0.1814, 0.7267, 0.2245, 0.7481]}, {"w": "Regression", "b": [0.2292, 0.7267, 0.3203, 0.7481]}, {"w": "164", "b": [0.8272, 0.7267, 0.8572, 0.7481]}, {"w": "Under", "b": [0.1814, 0.7457, 0.2348, 0.7671]}, {"w": "the", "b": [0.2396, 0.7457, 0.2659, 0.7671]}, {"w": "Hood", "b": [0.2706, 0.7457, 0.3183, 0.7671]}, {"w": "166", "b": [0.8272, 0.7457, 0.8572, 0.7671]}]}, {"id": "b_9", "type": "paragraph", "text": "Decision Function and Predictions 166 Training Objective 167 Quadratic Programming 169 The Dual Problem 170 Kernelized SVM 171 Online SVMs 174", "words": [{"w": "Decision", "b": [0.1986, 0.7648, 0.2724, 0.7862]}, {"w": "Function", "b": [0.2771, 0.7648, 0.3529, 0.7862]}, {"w": "and", "b": [0.3577, 0.7648, 0.3892, 0.7862]}, {"w": "Predictions", "b": [0.3939, 0.7648, 0.4893, 0.7862]}, {"w": "166", "b": [0.8272, 0.7648, 0.8572, 0.7862]}, {"w": "Training", "b": [0.1986, 0.7838, 0.2703, 0.8052]}, {"w": "Objective", "b": [0.275, 0.7838, 0.3546, 0.8052]}, {"w": "167", "b": [0.8272, 0.7838, 0.8572, 0.8052]}, {"w": "Quadratic", "b": [0.1986, 0.8029, 0.2825, 0.8243]}, {"w": "Programming", "b": [0.2873, 0.8029, 0.4048, 0.8243]}, {"w": "169", "b": [0.8272, 0.8029, 0.8572, 0.8243]}, {"w": "The", "b": [0.1986, 0.8219, 0.2314, 0.8433]}, {"w": "Dual", "b": [0.2361, 0.8219, 0.2769, 0.8433]}, {"w": "Problem", "b": [0.2816, 0.8219, 0.3535, 0.8433]}, {"w": "170", "b": [0.8272, 0.8219, 0.8572, 0.8433]}, {"w": "Kernelized", "b": [0.1986, 0.841, 0.2884, 0.8624]}, {"w": "SVM", "b": [0.2931, 0.841, 0.3362, 0.8624]}, {"w": "171", "b": [0.8272, 0.841, 0.8572, 0.8624]}, {"w": "Online", "b": [0.1986, 0.86, 0.2566, 0.8814]}, {"w": "SVMs", "b": [0.2614, 0.86, 0.3121, 0.8814]}, {"w": "174", "b": [0.8272, 0.86, 0.8572, 0.8814]}]}, {"id": "b_10", "type": "paragraph", "text": "Table of Contents | v", "words": [{"w": "Table", "b": [0.7088, 0.9225, 0.741, 0.9388]}, {"w": "of", "b": [0.7438, 0.9225, 0.7557, 0.9388]}, {"w": "Contents", "b": [0.7586, 0.9225, 0.811, 0.9388]}, {"w": "|", "b": [0.8289, 0.9225, 0.8326, 0.9388]}, {"w": "v", "b": [0.8505, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 8, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Exercises 175", "words": [{"w": "Exercises", "b": [0.1814, 0.0791, 0.2582, 0.1005]}, {"w": "175", "b": [0.8271, 0.0791, 0.8571, 0.1005]}]}, {"id": "b_1", "type": "paragraph", "text": "6. Decision Trees. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 Training and Visualizing a Decision Tree 177 Making Predictions 179 Estimating Class Probabilities 181 The CART Training Algorithm 182 Computational Complexity 183 Gini Impurity or Entropy? 183 Regularization Hyperparameters 184 Regression 185 Instability 188 Exercises 189", "words": [{"w": "6.", "b": [0.1547, 0.1152, 0.1695, 0.137]}, {"w": "Decision", "b": [0.1814, 0.1152, 0.2466, 0.137]}, {"w": "Trees.", "b": [0.2504, 0.1152, 0.2971, 0.137]}, {"w": ".", "b": [0.3009, 0.1152, 0.306, 0.137]}, {"w": ".", "b": [0.3098, 0.1152, 0.3149, 0.137]}, {"w": ".", "b": [0.3187, 0.1152, 0.3238, 0.137]}, {"w": ".", "b": [0.3276, 0.1152, 0.3327, 0.137]}, {"w": ".", "b": [0.3365, 0.1152, 0.3416, 0.137]}, {"w": ".", "b": [0.3454, 0.1152, 0.3505, 0.137]}, {"w": ".", "b": [0.3543, 0.1152, 0.3594, 0.137]}, {"w": ".", "b": [0.3632, 0.1152, 0.3683, 0.137]}, {"w": ".", "b": [0.3721, 0.1152, 0.3772, 0.137]}, {"w": ".", "b": [0.381, 0.1152, 0.3861, 0.137]}, {"w": ".", "b": [0.3899, 0.1152, 0.3951, 0.137]}, {"w": ".", "b": [0.3988, 0.1152, 0.404, 0.137]}, {"w": ".", "b": [0.4077, 0.1152, 0.4129, 0.137]}, {"w": ".", "b": [0.4166, 0.1152, 0.4218, 0.137]}, {"w": ".", "b": [0.4255, 0.1152, 0.4307, 0.137]}, {"w": ".", "b": [0.4344, 0.1152, 0.4396, 0.137]}, {"w": ".", "b": [0.4433, 0.1152, 0.4485, 0.137]}, {"w": ".", "b": [0.4522, 0.1152, 0.4574, 0.137]}, {"w": ".", "b": [0.4611, 0.1152, 0.4663, 0.137]}, {"w": ".", "b": [0.4701, 0.1152, 0.4752, 0.137]}, {"w": ".", "b": [0.479, 0.1152, 0.4841, 0.137]}, {"w": ".", "b": [0.4879, 0.1152, 0.493, 0.137]}, {"w": ".", "b": [0.4968, 0.1152, 0.5019, 0.137]}, {"w": ".", "b": [0.5057, 0.1152, 0.5108, 0.137]}, {"w": ".", "b": [0.5146, 0.1152, 0.5197, 0.137]}, {"w": ".", "b": [0.5235, 0.1152, 0.5286, 0.137]}, {"w": ".", "b": [0.5324, 0.1152, 0.5375, 0.137]}, {"w": ".", "b": [0.5413, 0.1152, 0.5464, 0.137]}, {"w": ".", "b": [0.5502, 0.1152, 0.5553, 0.137]}, {"w": ".", "b": [0.5591, 0.1152, 0.5642, 0.137]}, {"w": ".", "b": [0.568, 0.1152, 0.5731, 0.137]}, {"w": ".", "b": [0.5769, 0.1152, 0.5821, 0.137]}, {"w": ".", "b": [0.5858, 0.1152, 0.591, 0.137]}, {"w": ".", "b": [0.5947, 0.1152, 0.5999, 0.137]}, {"w": ".", "b": [0.6036, 0.1152, 0.6088, 0.137]}, {"w": ".", "b": [0.6125, 0.1152, 0.6177, 0.137]}, {"w": ".", "b": [0.6214, 0.1152, 0.6266, 0.137]}, {"w": ".", "b": [0.6303, 0.1152, 0.6355, 0.137]}, {"w": ".", "b": [0.6392, 0.1152, 0.6444, 0.137]}, {"w": ".", "b": [0.6481, 0.1152, 0.6533, 0.137]}, {"w": ".", "b": [0.6571, 0.1152, 0.6622, 0.137]}, {"w": ".", "b": [0.666, 0.1152, 0.6711, 0.137]}, {"w": ".", "b": [0.6749, 0.1152, 0.68, 0.137]}, {"w": ".", "b": [0.6838, 0.1152, 0.6889, 0.137]}, {"w": ".", "b": [0.6927, 0.1152, 0.6978, 0.137]}, {"w": ".", "b": [0.7016, 0.1152, 0.7067, 0.137]}, {"w": ".", "b": [0.7105, 0.1152, 0.7156, 0.137]}, {"w": ".", "b": [0.7194, 0.1152, 0.7245, 0.137]}, {"w": ".", "b": [0.7283, 0.1152, 0.7334, 0.137]}, {"w": ".", "b": [0.7372, 0.1152, 0.7423, 0.137]}, {"w": ".", "b": [0.7461, 0.1152, 0.7512, 0.137]}, {"w": ".", "b": [0.755, 0.1152, 0.7601, 0.137]}, {"w": ".", "b": [0.7639, 0.1152, 0.7691, 0.137]}, {"w": ".", "b": [0.7728, 0.1152, 0.778, 0.137]}, {"w": ".", "b": [0.7817, 0.1152, 0.7869, 0.137]}, {"w": ".", "b": [0.7906, 0.1152, 0.7958, 0.137]}, {"w": ".", "b": [0.7995, 0.1152, 0.8047, 0.137]}, {"w": ".", "b": [0.8084, 0.1152, 0.8136, 0.137]}, {"w": "177", "b": [0.828, 0.1152, 0.8571, 0.137]}, {"w": "Training", "b": [0.1814, 0.1362, 0.2531, 0.1576]}, {"w": "and", "b": [0.2579, 0.1362, 0.2894, 0.1576]}, {"w": "Visualizing", "b": [0.2941, 0.1362, 0.3877, 0.1576]}, {"w": "a", "b": [0.3924, 0.1362, 0.4016, 0.1576]}, {"w": "Decision", "b": [0.4063, 0.1362, 0.4801, 0.1576]}, {"w": "Tree", "b": [0.4848, 0.1362, 0.5214, 0.1576]}, {"w": "177", "b": [0.8271, 0.1362, 0.8571, 0.1576]}, {"w": "Making", "b": [0.1814, 0.1553, 0.2458, 0.1767]}, {"w": "Predictions", "b": [0.2506, 0.1553, 0.3459, 0.1767]}, {"w": "179", "b": [0.8271, 0.1553, 0.8571, 0.1767]}, {"w": "Estimating", "b": [0.1814, 0.1743, 0.2717, 0.1957]}, {"w": "Class", "b": [0.2765, 0.1743, 0.32, 0.1957]}, {"w": "Probabilities", "b": [0.3248, 0.1743, 0.43, 0.1957]}, {"w": "181", "b": [0.8271, 0.1743, 0.8571, 0.1957]}, {"w": "The", "b": [0.1814, 0.1933, 0.2143, 0.2148]}, {"w": "CART", "b": [0.219, 0.1933, 0.2724, 0.2148]}, {"w": "Training", "b": [0.2771, 0.1933, 0.3488, 0.2148]}, {"w": "Algorithm", "b": [0.3535, 0.1933, 0.4414, 0.2148]}, {"w": "182", "b": [0.8271, 0.1933, 0.8571, 0.2148]}, {"w": "Computational", "b": [0.1814, 0.2124, 0.308, 0.2338]}, {"w": "Complexity", "b": [0.3128, 0.2124, 0.4103, 0.2338]}, {"w": "183", "b": [0.8271, 0.2124, 0.8571, 0.2338]}, {"w": "Gini", "b": [0.1814, 0.2314, 0.2189, 0.2529]}, {"w": "Impurity", "b": [0.2236, 0.2314, 0.2986, 0.2529]}, {"w": "or", "b": [0.3033, 0.2314, 0.3217, 0.2529]}, {"w": "Entropy?", "b": [0.3264, 0.2314, 0.4023, 0.2529]}, {"w": "183", "b": [0.8271, 0.2314, 0.8571, 0.2529]}, {"w": "Regularization", "b": [0.1814, 0.2505, 0.3032, 0.2719]}, {"w": "Hyperparameters", "b": [0.3079, 0.2505, 0.4537, 0.2719]}, {"w": "184", "b": [0.8271, 0.2505, 0.8571, 0.2719]}, {"w": "Regression", "b": [0.1814, 0.2695, 0.2724, 0.291]}, {"w": "185", "b": [0.8271, 0.2695, 0.8571, 0.291]}, {"w": "Instability", "b": [0.1814, 0.2886, 0.266, 0.31]}, {"w": "188", "b": [0.8271, 0.2886, 0.8571, 0.31]}, {"w": "Exercises", "b": [0.1814, 0.3076, 0.2582, 0.329]}, {"w": "189", "b": [0.8271, 0.3076, 0.8571, 0.329]}]}, {"id": "b_2", "type": "paragraph", "text": "7. Ensemble Learning and Random Forests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 Voting Classifiers 192 Bagging and Pasting 195", "words": [{"w": "7.", "b": [0.1547, 0.3438, 0.1695, 0.3655]}, {"w": "Ensemble", "b": [0.1814, 0.3438, 0.2575, 0.3655]}, {"w": "Learning", "b": [0.2612, 0.3438, 0.3309, 0.3655]}, {"w": "and", "b": [0.3346, 0.3438, 0.3645, 0.3655]}, {"w": "Random", "b": [0.3683, 0.3438, 0.434, 0.3655]}, {"w": "Forests.", "b": [0.4378, 0.3438, 0.4989, 0.3655]}, {"w": ".", "b": [0.5026, 0.3438, 0.5078, 0.3655]}, {"w": ".", "b": [0.5116, 0.3438, 0.5167, 0.3655]}, {"w": ".", "b": [0.5205, 0.3438, 0.5256, 0.3655]}, {"w": ".", "b": [0.5294, 0.3438, 0.5345, 0.3655]}, {"w": ".", "b": [0.5383, 0.3438, 0.5434, 0.3655]}, {"w": ".", "b": [0.5472, 0.3438, 0.5523, 0.3655]}, {"w": ".", "b": [0.5561, 0.3438, 0.5612, 0.3655]}, {"w": ".", "b": [0.565, 0.3438, 0.5701, 0.3655]}, {"w": ".", "b": [0.5739, 0.3438, 0.579, 0.3655]}, {"w": ".", "b": [0.5828, 0.3438, 0.5879, 0.3655]}, {"w": ".", "b": [0.5917, 0.3438, 0.5968, 0.3655]}, {"w": ".", "b": [0.6006, 0.3438, 0.6057, 0.3655]}, {"w": ".", "b": [0.6095, 0.3438, 0.6146, 0.3655]}, {"w": ".", "b": [0.6184, 0.3438, 0.6236, 0.3655]}, {"w": ".", "b": [0.6273, 0.3438, 0.6325, 0.3655]}, {"w": ".", "b": [0.6362, 0.3438, 0.6414, 0.3655]}, {"w": ".", "b": [0.6451, 0.3438, 0.6503, 0.3655]}, {"w": ".", "b": [0.654, 0.3438, 0.6592, 0.3655]}, {"w": ".", "b": [0.6629, 0.3438, 0.6681, 0.3655]}, {"w": ".", "b": [0.6718, 0.3438, 0.677, 0.3655]}, {"w": ".", "b": [0.6807, 0.3438, 0.6859, 0.3655]}, {"w": ".", "b": [0.6896, 0.3438, 0.6948, 0.3655]}, {"w": ".", "b": [0.6986, 0.3438, 0.7037, 0.3655]}, {"w": ".", "b": [0.7075, 0.3438, 0.7126, 0.3655]}, {"w": ".", "b": [0.7164, 0.3438, 0.7215, 0.3655]}, {"w": ".", "b": [0.7253, 0.3438, 0.7304, 0.3655]}, {"w": ".", "b": [0.7342, 0.3438, 0.7393, 0.3655]}, {"w": ".", "b": [0.7431, 0.3438, 0.7482, 0.3655]}, {"w": ".", "b": [0.752, 0.3438, 0.7571, 0.3655]}, {"w": ".", "b": [0.7609, 0.3438, 0.766, 0.3655]}, {"w": ".", "b": [0.7698, 0.3438, 0.7749, 0.3655]}, {"w": ".", "b": [0.7787, 0.3438, 0.7838, 0.3655]}, {"w": ".", "b": [0.7876, 0.3438, 0.7927, 0.3655]}, {"w": ".", "b": [0.7965, 0.3438, 0.8016, 0.3655]}, {"w": ".", "b": [0.8054, 0.3438, 0.8106, 0.3655]}, {"w": ".", "b": [0.8143, 0.3438, 0.8195, 0.3655]}, {"w": "191", "b": [0.828, 0.3438, 0.8571, 0.3655]}, {"w": "Voting", "b": [0.1814, 0.3648, 0.2378, 0.3862]}, {"w": "Classifiers", "b": [0.2425, 0.3648, 0.3276, 0.3862]}, {"w": "192", "b": [0.8271, 0.3648, 0.8571, 0.3862]}, {"w": "Bagging", "b": [0.1814, 0.3838, 0.249, 0.4052]}, {"w": "and", "b": [0.2538, 0.3838, 0.2853, 0.4052]}, {"w": "Pasting", "b": [0.29, 0.3838, 0.3512, 0.4052]}, {"w": "195", "b": [0.8271, 0.3838, 0.8571, 0.4052]}]}, {"id": "b_3", "type": "paragraph", "text": "Bagging and Pasting in Scikit-Learn 196 Out-of-Bag Evaluation 197 Random Patches and Random Subspaces 198 Random Forests 199", "words": [{"w": "Bagging", "b": [0.1986, 0.4029, 0.2662, 0.4243]}, {"w": "and", "b": [0.2709, 0.4029, 0.3025, 0.4243]}, {"w": "Pasting", "b": [0.3072, 0.4029, 0.3683, 0.4243]}, {"w": "in", "b": [0.3731, 0.4029, 0.39, 0.4243]}, {"w": "Scikit-Learn", "b": [0.3948, 0.4029, 0.4971, 0.4243]}, {"w": "196", "b": [0.8271, 0.4029, 0.8571, 0.4243]}, {"w": "Out-of-Bag", "b": [0.1986, 0.4219, 0.2943, 0.4433]}, {"w": "Evaluation", "b": [0.299, 0.4219, 0.3883, 0.4433]}, {"w": "197", "b": [0.8271, 0.4219, 0.8571, 0.4433]}, {"w": "Random", "b": [0.1814, 0.441, 0.254, 0.4624]}, {"w": "Patches", "b": [0.2587, 0.441, 0.3215, 0.4624]}, {"w": "and", "b": [0.3262, 0.441, 0.3578, 0.4624]}, {"w": "Random", "b": [0.3625, 0.441, 0.435, 0.4624]}, {"w": "Subspaces", "b": [0.4398, 0.441, 0.5243, 0.4624]}, {"w": "198", "b": [0.8271, 0.441, 0.8571, 0.4624]}, {"w": "Random", "b": [0.1814, 0.46, 0.254, 0.4814]}, {"w": "Forests", "b": [0.2587, 0.46, 0.3182, 0.4814]}, {"w": "199", "b": [0.8271, 0.46, 0.8571, 0.4814]}]}, {"id": "b_4", "type": "equation", "text": "Extra-Trees 200 Feature Importance 200 Boosting 201", "words": [{"w": "Extra-Trees", "b": [0.1986, 0.4791, 0.2951, 0.5005]}, {"w": "200", "b": [0.8271, 0.4791, 0.8571, 0.5005]}, {"w": "Feature", "b": [0.1986, 0.4981, 0.2608, 0.5195]}, {"w": "Importance", "b": [0.2655, 0.4981, 0.3631, 0.5195]}, {"w": "200", "b": [0.8271, 0.4981, 0.8572, 0.5195]}, {"w": "Boosting", "b": [0.1814, 0.5172, 0.2561, 0.5386]}, {"w": "201", "b": [0.8271, 0.5172, 0.8571, 0.5386]}]}, {"id": "b_5", "type": "paragraph", "text": "AdaBoost 202 Gradient Boosting 205 Stacking 210 Exercises 213", "words": [{"w": "AdaBoost", "b": [0.1986, 0.5362, 0.2805, 0.5576]}, {"w": "202", "b": [0.8271, 0.5362, 0.8571, 0.5576]}, {"w": "Gradient", "b": [0.1986, 0.5553, 0.2731, 0.5767]}, {"w": "Boosting", "b": [0.2779, 0.5553, 0.3525, 0.5767]}, {"w": "205", "b": [0.8271, 0.5553, 0.8571, 0.5767]}, {"w": "Stacking", "b": [0.1814, 0.5743, 0.2527, 0.5957]}, {"w": "210", "b": [0.8271, 0.5743, 0.8571, 0.5957]}, {"w": "Exercises", "b": [0.1814, 0.5933, 0.2582, 0.6148]}, {"w": "213", "b": [0.8271, 0.5933, 0.8571, 0.6148]}]}, {"id": "b_6", "type": "paragraph", "text": "8. Dimensionality Reduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 The Curse of Dimensionality 216 Main Approaches for Dimensionality Reduction 218", "words": [{"w": "8.", "b": [0.1547, 0.6295, 0.1695, 0.6512]}, {"w": "Dimensionality", "b": [0.1814, 0.6295, 0.3, 0.6512]}, {"w": "Reduction.", "b": [0.3038, 0.6295, 0.3884, 0.6512]}, {"w": ".", "b": [0.3921, 0.6295, 0.3973, 0.6512]}, {"w": ".", "b": [0.4011, 0.6295, 0.4062, 0.6512]}, {"w": ".", "b": [0.41, 0.6295, 0.4151, 0.6512]}, {"w": ".", "b": [0.4189, 0.6295, 0.424, 0.6512]}, {"w": ".", "b": [0.4278, 0.6295, 0.4329, 0.6512]}, {"w": ".", "b": [0.4367, 0.6295, 0.4418, 0.6512]}, {"w": ".", "b": [0.4456, 0.6295, 0.4507, 0.6512]}, {"w": ".", "b": [0.4545, 0.6295, 0.4596, 0.6512]}, {"w": ".", "b": [0.4634, 0.6295, 0.4685, 0.6512]}, {"w": ".", "b": [0.4723, 0.6295, 0.4774, 0.6512]}, {"w": ".", "b": [0.4812, 0.6295, 0.4863, 0.6512]}, {"w": ".", "b": [0.4901, 0.6295, 0.4952, 0.6512]}, {"w": ".", "b": [0.499, 0.6295, 0.5041, 0.6512]}, {"w": ".", "b": [0.5079, 0.6295, 0.5131, 0.6512]}, {"w": ".", "b": [0.5168, 0.6295, 0.522, 0.6512]}, {"w": ".", "b": [0.5257, 0.6295, 0.5309, 0.6512]}, {"w": ".", "b": [0.5346, 0.6295, 0.5398, 0.6512]}, {"w": ".", "b": [0.5435, 0.6295, 0.5487, 0.6512]}, {"w": ".", "b": [0.5524, 0.6295, 0.5576, 0.6512]}, {"w": ".", "b": [0.5613, 0.6295, 0.5665, 0.6512]}, {"w": ".", "b": [0.5702, 0.6295, 0.5754, 0.6512]}, {"w": ".", "b": [0.5791, 0.6295, 0.5843, 0.6512]}, {"w": ".", "b": [0.5881, 0.6295, 0.5932, 0.6512]}, {"w": ".", "b": [0.597, 0.6295, 0.6021, 0.6512]}, {"w": ".", "b": [0.6059, 0.6295, 0.611, 0.6512]}, {"w": ".", "b": [0.6148, 0.6295, 0.6199, 0.6512]}, {"w": ".", "b": [0.6237, 0.6295, 0.6288, 0.6512]}, {"w": ".", "b": [0.6326, 0.6295, 0.6377, 0.6512]}, {"w": ".", "b": [0.6415, 0.6295, 0.6466, 0.6512]}, {"w": ".", "b": [0.6504, 0.6295, 0.6555, 0.6512]}, {"w": ".", "b": [0.6593, 0.6295, 0.6644, 0.6512]}, {"w": ".", "b": [0.6682, 0.6295, 0.6733, 0.6512]}, {"w": ".", "b": [0.6771, 0.6295, 0.6822, 0.6512]}, {"w": ".", "b": [0.686, 0.6295, 0.6911, 0.6512]}, {"w": ".", "b": [0.6949, 0.6295, 0.7001, 0.6512]}, {"w": ".", "b": [0.7038, 0.6295, 0.709, 0.6512]}, {"w": ".", "b": [0.7127, 0.6295, 0.7179, 0.6512]}, {"w": ".", "b": [0.7216, 0.6295, 0.7268, 0.6512]}, {"w": ".", "b": [0.7305, 0.6295, 0.7357, 0.6512]}, {"w": ".", "b": [0.7394, 0.6295, 0.7446, 0.6512]}, {"w": ".", "b": [0.7483, 0.6295, 0.7535, 0.6512]}, {"w": ".", "b": [0.7572, 0.6295, 0.7624, 0.6512]}, {"w": ".", "b": [0.7661, 0.6295, 0.7713, 0.6512]}, {"w": ".", "b": [0.7751, 0.6295, 0.7802, 0.6512]}, {"w": ".", "b": [0.784, 0.6295, 0.7891, 0.6512]}, {"w": ".", "b": [0.7929, 0.6295, 0.798, 0.6512]}, {"w": ".", "b": [0.8018, 0.6295, 0.8069, 0.6512]}, {"w": ".", "b": [0.8107, 0.6295, 0.8158, 0.6512]}, {"w": "215", "b": [0.828, 0.6295, 0.8571, 0.6512]}, {"w": "The", "b": [0.1814, 0.6505, 0.2143, 0.6719]}, {"w": "Curse", "b": [0.219, 0.6505, 0.2681, 0.6719]}, {"w": "of", "b": [0.2729, 0.6505, 0.2896, 0.6719]}, {"w": "Dimensionality", "b": [0.2944, 0.6505, 0.4238, 0.6719]}, {"w": "216", "b": [0.8271, 0.6505, 0.8571, 0.6719]}, {"w": "Main", "b": [0.1814, 0.6695, 0.2258, 0.691]}, {"w": "Approaches", "b": [0.2305, 0.6695, 0.3298, 0.691]}, {"w": "for", "b": [0.3345, 0.6695, 0.359, 0.691]}, {"w": "Dimensionality", "b": [0.3638, 0.6695, 0.4931, 0.691]}, {"w": "Reduction", "b": [0.4979, 0.6695, 0.5845, 0.691]}, {"w": "218", "b": [0.8271, 0.6695, 0.8571, 0.691]}]}, {"id": "b_7", "type": "paragraph", "text": "Projection 218 Manifold Learning 220 PCA 222", "words": [{"w": "Projection", "b": [0.1986, 0.6886, 0.2856, 0.71]}, {"w": "218", "b": [0.8271, 0.6886, 0.8571, 0.71]}, {"w": "Manifold", "b": [0.1986, 0.7076, 0.276, 0.729]}, {"w": "Learning", "b": [0.2807, 0.7076, 0.3558, 0.729]}, {"w": "220", "b": [0.8271, 0.7076, 0.8571, 0.729]}, {"w": "PCA", "b": [0.1814, 0.7267, 0.2214, 0.7481]}, {"w": "222", "b": [0.8271, 0.7267, 0.8571, 0.7481]}]}, {"id": "b_8", "type": "paragraph", "text": "Preserving the Variance 222 Principal Components 223 Projecting Down to d Dimensions 224 Using Scikit-Learn 224 Explained Variance Ratio 225 Choosing the Right Number of Dimensions 225 PCA for Compression 226", "words": [{"w": "Preserving", "b": [0.1986, 0.7457, 0.2881, 0.7671]}, {"w": "the", "b": [0.2928, 0.7457, 0.3191, 0.7671]}, {"w": "Variance", "b": [0.3239, 0.7457, 0.3971, 0.7671]}, {"w": "222", "b": [0.8271, 0.7457, 0.8572, 0.7671]}, {"w": "Principal", "b": [0.1986, 0.7648, 0.2747, 0.7862]}, {"w": "Components", "b": [0.2795, 0.7648, 0.3874, 0.7862]}, {"w": "223", "b": [0.8271, 0.7648, 0.8572, 0.7862]}, {"w": "Projecting", "b": [0.1986, 0.7838, 0.2847, 0.8052]}, {"w": "Down", "b": [0.2895, 0.7838, 0.3411, 0.8052]}, {"w": "to", "b": [0.3458, 0.7838, 0.3628, 0.8052]}, {"w": "d", "b": [0.3675, 0.7836, 0.3781, 0.8052]}, {"w": "Dimensions", "b": [0.3828, 0.7838, 0.4839, 0.8052]}, {"w": "224", "b": [0.8271, 0.7838, 0.8571, 0.8052]}, {"w": "Using", "b": [0.1986, 0.8029, 0.2472, 0.8243]}, {"w": "Scikit-Learn", "b": [0.2519, 0.8029, 0.3542, 0.8243]}, {"w": "224", "b": [0.8271, 0.8029, 0.8572, 0.8243]}, {"w": "Explained", "b": [0.1986, 0.8219, 0.2824, 0.8433]}, {"w": "Variance", "b": [0.2871, 0.8219, 0.3604, 0.8433]}, {"w": "Ratio", "b": [0.3651, 0.8219, 0.4097, 0.8433]}, {"w": "225", "b": [0.8271, 0.8219, 0.8572, 0.8433]}, {"w": "Choosing", "b": [0.1986, 0.841, 0.2792, 0.8624]}, {"w": "the", "b": [0.2839, 0.841, 0.3102, 0.8624]}, {"w": "Right", "b": [0.315, 0.841, 0.3603, 0.8624]}, {"w": "Number", "b": [0.365, 0.841, 0.4351, 0.8624]}, {"w": "of", "b": [0.4398, 0.841, 0.4566, 0.8624]}, {"w": "Dimensions", "b": [0.4613, 0.841, 0.5624, 0.8624]}, {"w": "225", "b": [0.8271, 0.841, 0.8571, 0.8624]}, {"w": "PCA", "b": [0.1986, 0.86, 0.2385, 0.8814]}, {"w": "for", "b": [0.2433, 0.86, 0.2678, 0.8814]}, {"w": "Compression", "b": [0.2725, 0.86, 0.3841, 0.8814]}, {"w": "226", "b": [0.8271, 0.86, 0.8572, 0.8814]}]}, {"id": "b_9", "type": "paragraph", "text": "vi | Table of Contents", "words": [{"w": "vi", "b": [0.1429, 0.9225, 0.1532, 0.9388]}, {"w": "|", "b": [0.1711, 0.9225, 0.1748, 0.9388]}, {"w": "Table", "b": [0.1927, 0.9225, 0.2248, 0.9388]}, {"w": "of", "b": [0.2276, 0.9225, 0.2396, 0.9388]}, {"w": "Contents", "b": [0.2424, 0.9225, 0.2949, 0.9388]}]}]}, {"page": 9, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Randomized PCA 227 Incremental PCA 227 Kernel PCA 228", "words": [{"w": "Randomized", "b": [0.1986, 0.0791, 0.3053, 0.1005]}, {"w": "PCA", "b": [0.31, 0.0791, 0.35, 0.1005]}, {"w": "227", "b": [0.8271, 0.0791, 0.8571, 0.1005]}, {"w": "Incremental", "b": [0.1986, 0.0981, 0.3001, 0.1195]}, {"w": "PCA", "b": [0.3049, 0.0981, 0.3449, 0.1195]}, {"w": "227", "b": [0.8271, 0.0981, 0.8571, 0.1195]}, {"w": "Kernel", "b": [0.1814, 0.1172, 0.237, 0.1386]}, {"w": "PCA", "b": [0.2418, 0.1172, 0.2818, 0.1386]}, {"w": "228", "b": [0.8271, 0.1172, 0.8571, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "Selecting a Kernel and Tuning Hyperparameters 229 LLE 232 Other Dimensionality Reduction Techniques 234 Exercises 235", "words": [{"w": "Selecting", "b": [0.1986, 0.1362, 0.2733, 0.1576]}, {"w": "a", "b": [0.278, 0.1362, 0.2872, 0.1576]}, {"w": "Kernel", "b": [0.2919, 0.1362, 0.3475, 0.1576]}, {"w": "and", "b": [0.3523, 0.1362, 0.3838, 0.1576]}, {"w": "Tuning", "b": [0.3885, 0.1362, 0.4486, 0.1576]}, {"w": "Hyperparameters", "b": [0.4533, 0.1362, 0.5991, 0.1576]}, {"w": "229", "b": [0.8271, 0.1362, 0.8571, 0.1576]}, {"w": "LLE", "b": [0.1814, 0.1553, 0.2157, 0.1767]}, {"w": "232", "b": [0.8271, 0.1553, 0.8571, 0.1767]}, {"w": "Other", "b": [0.1814, 0.1743, 0.231, 0.1957]}, {"w": "Dimensionality", "b": [0.2358, 0.1743, 0.3651, 0.1957]}, {"w": "Reduction", "b": [0.3699, 0.1743, 0.4565, 0.1957]}, {"w": "Techniques", "b": [0.4612, 0.1743, 0.556, 0.1957]}, {"w": "234", "b": [0.8271, 0.1743, 0.8571, 0.1957]}, {"w": "Exercises", "b": [0.1814, 0.1933, 0.2582, 0.2148]}, {"w": "235", "b": [0.8271, 0.1933, 0.8571, 0.2148]}]}, {"id": "b_2", "type": "paragraph", "text": "9. Unsupervised Learning Techniques. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 Clustering 238", "words": [{"w": "9.", "b": [0.1547, 0.2295, 0.1695, 0.2512]}, {"w": "Unsupervised", "b": [0.1814, 0.2295, 0.2874, 0.2512]}, {"w": "Learning", "b": [0.2911, 0.2295, 0.3608, 0.2512]}, {"w": "Techniques.", "b": [0.3645, 0.2295, 0.458, 0.2512]}, {"w": ".", "b": [0.4618, 0.2295, 0.4669, 0.2512]}, {"w": ".", "b": [0.4707, 0.2295, 0.4758, 0.2512]}, {"w": ".", "b": [0.4796, 0.2295, 0.4847, 0.2512]}, {"w": ".", "b": [0.4885, 0.2295, 0.4936, 0.2512]}, {"w": ".", "b": [0.4974, 0.2295, 0.5026, 0.2512]}, {"w": ".", "b": [0.5063, 0.2295, 0.5115, 0.2512]}, {"w": ".", "b": [0.5152, 0.2295, 0.5204, 0.2512]}, {"w": ".", "b": [0.5241, 0.2295, 0.5293, 0.2512]}, {"w": ".", "b": [0.533, 0.2295, 0.5382, 0.2512]}, {"w": ".", "b": [0.5419, 0.2295, 0.5471, 0.2512]}, {"w": ".", "b": [0.5508, 0.2295, 0.556, 0.2512]}, {"w": ".", "b": [0.5597, 0.2295, 0.5649, 0.2512]}, {"w": ".", "b": [0.5686, 0.2295, 0.5738, 0.2512]}, {"w": ".", "b": [0.5776, 0.2295, 0.5827, 0.2512]}, {"w": ".", "b": [0.5865, 0.2295, 0.5916, 0.2512]}, {"w": ".", "b": [0.5954, 0.2295, 0.6005, 0.2512]}, {"w": ".", "b": [0.6043, 0.2295, 0.6094, 0.2512]}, {"w": ".", "b": [0.6132, 0.2295, 0.6183, 0.2512]}, {"w": ".", "b": [0.6221, 0.2295, 0.6272, 0.2512]}, {"w": ".", "b": [0.631, 0.2295, 0.6361, 0.2512]}, {"w": ".", "b": [0.6399, 0.2295, 0.645, 0.2512]}, {"w": ".", "b": [0.6488, 0.2295, 0.6539, 0.2512]}, {"w": ".", "b": [0.6577, 0.2295, 0.6628, 0.2512]}, {"w": ".", "b": [0.6666, 0.2295, 0.6717, 0.2512]}, {"w": ".", "b": [0.6755, 0.2295, 0.6806, 0.2512]}, {"w": ".", "b": [0.6844, 0.2295, 0.6896, 0.2512]}, {"w": ".", "b": [0.6933, 0.2295, 0.6985, 0.2512]}, {"w": ".", "b": [0.7022, 0.2295, 0.7074, 0.2512]}, {"w": ".", "b": [0.7111, 0.2295, 0.7163, 0.2512]}, {"w": ".", "b": [0.72, 0.2295, 0.7252, 0.2512]}, {"w": ".", "b": [0.7289, 0.2295, 0.7341, 0.2512]}, {"w": ".", "b": [0.7378, 0.2295, 0.743, 0.2512]}, {"w": ".", "b": [0.7467, 0.2295, 0.7519, 0.2512]}, {"w": ".", "b": [0.7556, 0.2295, 0.7608, 0.2512]}, {"w": ".", "b": [0.7646, 0.2295, 0.7697, 0.2512]}, {"w": ".", "b": [0.7735, 0.2295, 0.7786, 0.2512]}, {"w": ".", "b": [0.7824, 0.2295, 0.7875, 0.2512]}, {"w": ".", "b": [0.7913, 0.2295, 0.7964, 0.2512]}, {"w": ".", "b": [0.8002, 0.2295, 0.8053, 0.2512]}, {"w": ".", "b": [0.8091, 0.2295, 0.8142, 0.2512]}, {"w": "237", "b": [0.828, 0.2295, 0.8571, 0.2512]}, {"w": "Clustering", "b": [0.1814, 0.2505, 0.2689, 0.2719]}, {"w": "238", "b": [0.8271, 0.2505, 0.8571, 0.2719]}]}, {"id": "b_3", "type": "paragraph", "text": "K-Means 240 Limits of K-Means 250 Using clustering for image segmentation 251 Using Clustering for Preprocessing 252 Using Clustering for Semi-Supervised Learning 254 DBSCAN 256 Other Clustering Algorithms 259 Gaussian Mixtures 260", "words": [{"w": "K-Means", "b": [0.1986, 0.2695, 0.2751, 0.291]}, {"w": "240", "b": [0.8271, 0.2695, 0.8571, 0.291]}, {"w": "Limits", "b": [0.1986, 0.2886, 0.252, 0.31]}, {"w": "of", "b": [0.2567, 0.2886, 0.2735, 0.31]}, {"w": "K-Means", "b": [0.2783, 0.2886, 0.3548, 0.31]}, {"w": "250", "b": [0.8271, 0.2886, 0.8571, 0.31]}, {"w": "Using", "b": [0.1986, 0.3076, 0.2472, 0.329]}, {"w": "clustering", "b": [0.2519, 0.3076, 0.3344, 0.329]}, {"w": "for", "b": [0.3391, 0.3076, 0.3636, 0.329]}, {"w": "image", "b": [0.3683, 0.3076, 0.4187, 0.329]}, {"w": "segmentation", "b": [0.4235, 0.3076, 0.5357, 0.329]}, {"w": "251", "b": [0.8271, 0.3076, 0.8571, 0.329]}, {"w": "Using", "b": [0.1986, 0.3267, 0.2472, 0.3481]}, {"w": "Clustering", "b": [0.2519, 0.3267, 0.3394, 0.3481]}, {"w": "for", "b": [0.3441, 0.3267, 0.3686, 0.3481]}, {"w": "Preprocessing", "b": [0.3734, 0.3267, 0.4906, 0.3481]}, {"w": "252", "b": [0.8271, 0.3267, 0.8571, 0.3481]}, {"w": "Using", "b": [0.1986, 0.3457, 0.2472, 0.3671]}, {"w": "Clustering", "b": [0.2519, 0.3457, 0.3394, 0.3671]}, {"w": "for", "b": [0.3441, 0.3457, 0.3686, 0.3671]}, {"w": "Semi-Supervised", "b": [0.3734, 0.3457, 0.5139, 0.3671]}, {"w": "Learning", "b": [0.5187, 0.3457, 0.5937, 0.3671]}, {"w": "254", "b": [0.8271, 0.3457, 0.8571, 0.3671]}, {"w": "DBSCAN", "b": [0.1986, 0.3648, 0.2797, 0.3862]}, {"w": "256", "b": [0.8271, 0.3648, 0.8571, 0.3862]}, {"w": "Other", "b": [0.1986, 0.3838, 0.2482, 0.4052]}, {"w": "Clustering", "b": [0.2529, 0.3838, 0.3404, 0.4052]}, {"w": "Algorithms", "b": [0.3451, 0.3838, 0.4407, 0.4052]}, {"w": "259", "b": [0.8271, 0.3838, 0.8571, 0.4052]}, {"w": "Gaussian", "b": [0.1814, 0.4029, 0.2575, 0.4243]}, {"w": "Mixtures", "b": [0.2623, 0.4029, 0.3379, 0.4243]}, {"w": "260", "b": [0.8271, 0.4029, 0.8571, 0.4243]}]}, {"id": "b_4", "type": "paragraph", "text": "Anomaly Detection using Gaussian Mixtures 266 Selecting the Number of Clusters 267 Bayesian Gaussian Mixture Models 270 Other Anomaly Detection and Novelty Detection Algorithms 274", "words": [{"w": "Anomaly", "b": [0.1986, 0.4219, 0.276, 0.4433]}, {"w": "Detection", "b": [0.2808, 0.4219, 0.3629, 0.4433]}, {"w": "using", "b": [0.3676, 0.4219, 0.4131, 0.4433]}, {"w": "Gaussian", "b": [0.4178, 0.4219, 0.4939, 0.4433]}, {"w": "Mixtures", "b": [0.4986, 0.4219, 0.5743, 0.4433]}, {"w": "266", "b": [0.8271, 0.4219, 0.8571, 0.4433]}, {"w": "Selecting", "b": [0.1986, 0.441, 0.2733, 0.4624]}, {"w": "the", "b": [0.278, 0.441, 0.3044, 0.4624]}, {"w": "Number", "b": [0.3091, 0.441, 0.3791, 0.4624]}, {"w": "of", "b": [0.3839, 0.441, 0.4007, 0.4624]}, {"w": "Clusters", "b": [0.4054, 0.441, 0.4738, 0.4624]}, {"w": "267", "b": [0.8271, 0.441, 0.8571, 0.4624]}, {"w": "Bayesian", "b": [0.1986, 0.46, 0.2718, 0.4814]}, {"w": "Gaussian", "b": [0.2765, 0.46, 0.3526, 0.4814]}, {"w": "Mixture", "b": [0.3574, 0.46, 0.4253, 0.4814]}, {"w": "Models", "b": [0.4301, 0.46, 0.4915, 0.4814]}, {"w": "270", "b": [0.8271, 0.46, 0.8571, 0.4814]}, {"w": "Other", "b": [0.1986, 0.4791, 0.2482, 0.5005]}, {"w": "Anomaly", "b": [0.2529, 0.4791, 0.3304, 0.5005]}, {"w": "Detection", "b": [0.3351, 0.4791, 0.4173, 0.5005]}, {"w": "and", "b": [0.422, 0.4791, 0.4535, 0.5005]}, {"w": "Novelty", "b": [0.4583, 0.4791, 0.5235, 0.5005]}, {"w": "Detection", "b": [0.5283, 0.4791, 0.6104, 0.5005]}, {"w": "Algorithms", "b": [0.6151, 0.4791, 0.7107, 0.5005]}, {"w": "274", "b": [0.8271, 0.4791, 0.8571, 0.5005]}]}, {"id": "b_5", "type": "paragraph", "text": "Part II. Neural Networks and Deep Learning", "words": [{"w": "Part", "b": [0.1428, 0.5316, 0.1813, 0.557]}, {"w": "II.", "b": [0.1857, 0.5316, 0.2043, 0.557]}, {"w": "Neural", "b": [0.2321, 0.5316, 0.293, 0.557]}, {"w": "Networks", "b": [0.2974, 0.5316, 0.3847, 0.557]}, {"w": "and", "b": [0.3891, 0.5316, 0.424, 0.557]}, {"w": "Deep", "b": [0.4284, 0.5316, 0.4751, 0.557]}, {"w": "Learning", "b": [0.4795, 0.5316, 0.5608, 0.557]}]}, {"id": "b_6", "type": "paragraph", "text": "10. Introduction to Artificial Neural Networks with Keras. . . . . . . . . . . . . . . . . . . . . . . . . . 277 From Biological to Artificial Neurons 278", "words": [{"w": "10.", "b": [0.145, 0.5737, 0.1695, 0.5954]}, {"w": "Introduction", "b": [0.1814, 0.5737, 0.2798, 0.5954]}, {"w": "to", "b": [0.2835, 0.5737, 0.3001, 0.5954]}, {"w": "Artificial", "b": [0.3039, 0.5737, 0.3704, 0.5954]}, {"w": "Neural", "b": [0.3741, 0.5737, 0.4264, 0.5954]}, {"w": "Networks", "b": [0.4301, 0.5737, 0.505, 0.5954]}, {"w": "with", "b": [0.5087, 0.5737, 0.5449, 0.5954]}, {"w": "Keras.", "b": [0.5487, 0.5737, 0.5968, 0.5954]}, {"w": ".", "b": [0.6005, 0.5737, 0.6057, 0.5954]}, {"w": ".", "b": [0.6095, 0.5737, 0.6146, 0.5954]}, {"w": ".", "b": [0.6184, 0.5737, 0.6235, 0.5954]}, {"w": ".", "b": [0.6273, 0.5737, 0.6324, 0.5954]}, {"w": ".", "b": [0.6362, 0.5737, 0.6413, 0.5954]}, {"w": ".", "b": [0.6451, 0.5737, 0.6502, 0.5954]}, {"w": ".", "b": [0.654, 0.5737, 0.6591, 0.5954]}, {"w": ".", "b": [0.6629, 0.5737, 0.668, 0.5954]}, {"w": ".", "b": [0.6718, 0.5737, 0.6769, 0.5954]}, {"w": ".", "b": [0.6807, 0.5737, 0.6858, 0.5954]}, {"w": ".", "b": [0.6896, 0.5737, 0.6947, 0.5954]}, {"w": ".", "b": [0.6985, 0.5737, 0.7036, 0.5954]}, {"w": ".", "b": [0.7074, 0.5737, 0.7125, 0.5954]}, {"w": ".", "b": [0.7163, 0.5737, 0.7215, 0.5954]}, {"w": ".", "b": [0.7252, 0.5737, 0.7304, 0.5954]}, {"w": ".", "b": [0.7341, 0.5737, 0.7393, 0.5954]}, {"w": ".", "b": [0.743, 0.5737, 0.7482, 0.5954]}, {"w": ".", "b": [0.7519, 0.5737, 0.7571, 0.5954]}, {"w": ".", "b": [0.7608, 0.5737, 0.766, 0.5954]}, {"w": ".", "b": [0.7697, 0.5737, 0.7749, 0.5954]}, {"w": ".", "b": [0.7786, 0.5737, 0.7838, 0.5954]}, {"w": ".", "b": [0.7875, 0.5737, 0.7927, 0.5954]}, {"w": ".", "b": [0.7965, 0.5737, 0.8016, 0.5954]}, {"w": ".", "b": [0.8054, 0.5737, 0.8105, 0.5954]}, {"w": ".", "b": [0.8143, 0.5737, 0.8194, 0.5954]}, {"w": "277", "b": [0.828, 0.5737, 0.8571, 0.5954]}, {"w": "From", "b": [0.1814, 0.5946, 0.2279, 0.616]}, {"w": "Biological", "b": [0.2326, 0.5946, 0.3155, 0.616]}, {"w": "to", "b": [0.3202, 0.5946, 0.3372, 0.616]}, {"w": "Artificial", "b": [0.342, 0.5946, 0.4166, 0.616]}, {"w": "Neurons", "b": [0.4213, 0.5946, 0.4936, 0.616]}, {"w": "278", "b": [0.8271, 0.5946, 0.8571, 0.616]}]}, {"id": "b_7", "type": "paragraph", "text": "Biological Neurons 279 Logical Computations with Neurons 281 The Perceptron 281 Multi-Layer Perceptron and Backpropagation 286 Regression MLPs 289 Classification MLPs 290 Implementing MLPs with Keras 292", "words": [{"w": "Biological", "b": [0.1986, 0.6137, 0.2815, 0.6351]}, {"w": "Neurons", "b": [0.2862, 0.6137, 0.3585, 0.6351]}, {"w": "279", "b": [0.8271, 0.6137, 0.8571, 0.6351]}, {"w": "Logical", "b": [0.1986, 0.6327, 0.259, 0.6541]}, {"w": "Computations", "b": [0.2637, 0.6327, 0.3835, 0.6541]}, {"w": "with", "b": [0.3883, 0.6327, 0.4256, 0.6541]}, {"w": "Neurons", "b": [0.4303, 0.6327, 0.5026, 0.6541]}, {"w": "281", "b": [0.8271, 0.6327, 0.8571, 0.6541]}, {"w": "The", "b": [0.1986, 0.6518, 0.2314, 0.6732]}, {"w": "Perceptron", "b": [0.2361, 0.6518, 0.3285, 0.6732]}, {"w": "281", "b": [0.8271, 0.6518, 0.8571, 0.6732]}, {"w": "Multi-Layer", "b": [0.1986, 0.6708, 0.2983, 0.6922]}, {"w": "Perceptron", "b": [0.303, 0.6708, 0.3953, 0.6922]}, {"w": "and", "b": [0.4001, 0.6708, 0.4316, 0.6922]}, {"w": "Backpropagation", "b": [0.4363, 0.6708, 0.5787, 0.6922]}, {"w": "286", "b": [0.8271, 0.6708, 0.8571, 0.6922]}, {"w": "Regression", "b": [0.1986, 0.6899, 0.2896, 0.7113]}, {"w": "MLPs", "b": [0.2943, 0.6899, 0.3429, 0.7113]}, {"w": "289", "b": [0.8271, 0.6899, 0.8571, 0.7113]}, {"w": "Classification", "b": [0.1986, 0.7089, 0.311, 0.7303]}, {"w": "MLPs", "b": [0.3157, 0.7089, 0.3643, 0.7303]}, {"w": "290", "b": [0.8271, 0.7089, 0.8571, 0.7303]}, {"w": "Implementing", "b": [0.1814, 0.728, 0.3002, 0.7494]}, {"w": "MLPs", "b": [0.305, 0.728, 0.3535, 0.7494]}, {"w": "with", "b": [0.3583, 0.728, 0.3956, 0.7494]}, {"w": "Keras", "b": [0.4003, 0.728, 0.4472, 0.7494]}, {"w": "292", "b": [0.8271, 0.728, 0.8571, 0.7494]}]}, {"id": "b_8", "type": "paragraph", "text": "Installing TensorFlow 2 293 Building an Image Classifier Using the Sequential API 294 Building a Regression MLP Using the Sequential API 303 Building Complex Models Using the Functional API 304 Building Dynamic Models Using the Subclassing API 309 Saving and Restoring a Model 311 Using Callbacks 311", "words": [{"w": "Installing", "b": [0.1986, 0.747, 0.2775, 0.7684]}, {"w": "TensorFlow", "b": [0.2822, 0.747, 0.3805, 0.7684]}, {"w": "2", "b": [0.3852, 0.747, 0.3952, 0.7684]}, {"w": "293", "b": [0.8271, 0.747, 0.8571, 0.7684]}, {"w": "Building", "b": [0.1986, 0.7661, 0.2705, 0.7875]}, {"w": "an", "b": [0.2752, 0.7661, 0.2957, 0.7875]}, {"w": "Image", "b": [0.3005, 0.7661, 0.3524, 0.7875]}, {"w": "Classifier", "b": [0.3571, 0.7661, 0.4346, 0.7875]}, {"w": "Using", "b": [0.4393, 0.7661, 0.4879, 0.7875]}, {"w": "the", "b": [0.4927, 0.7661, 0.519, 0.7875]}, {"w": "Sequential", "b": [0.5237, 0.7661, 0.6104, 0.7875]}, {"w": "API", "b": [0.6151, 0.7661, 0.6483, 0.7875]}, {"w": "294", "b": [0.8271, 0.7661, 0.8571, 0.7875]}, {"w": "Building", "b": [0.1986, 0.7851, 0.2705, 0.8065]}, {"w": "a", "b": [0.2752, 0.7851, 0.2843, 0.8065]}, {"w": "Regression", "b": [0.2891, 0.7851, 0.3801, 0.8065]}, {"w": "MLP", "b": [0.3848, 0.7851, 0.4263, 0.8065]}, {"w": "Using", "b": [0.4311, 0.7851, 0.4797, 0.8065]}, {"w": "the", "b": [0.4844, 0.7851, 0.5107, 0.8065]}, {"w": "Sequential", "b": [0.5155, 0.7851, 0.6021, 0.8065]}, {"w": "API", "b": [0.6068, 0.7851, 0.6401, 0.8065]}, {"w": "303", "b": [0.8271, 0.7851, 0.8571, 0.8065]}, {"w": "Building", "b": [0.1986, 0.8042, 0.2705, 0.8256]}, {"w": "Complex", "b": [0.2752, 0.8042, 0.3512, 0.8256]}, {"w": "Models", "b": [0.356, 0.8042, 0.4174, 0.8256]}, {"w": "Using", "b": [0.4221, 0.8042, 0.4707, 0.8256]}, {"w": "the", "b": [0.4754, 0.8042, 0.5018, 0.8256]}, {"w": "Functional", "b": [0.5065, 0.8042, 0.5967, 0.8256]}, {"w": "API", "b": [0.6015, 0.8042, 0.6347, 0.8256]}, {"w": "304", "b": [0.8271, 0.8042, 0.8571, 0.8256]}, {"w": "Building", "b": [0.1986, 0.8232, 0.2705, 0.8446]}, {"w": "Dynamic", "b": [0.2752, 0.8232, 0.3524, 0.8446]}, {"w": "Models", "b": [0.3572, 0.8232, 0.4186, 0.8446]}, {"w": "Using", "b": [0.4233, 0.8232, 0.4719, 0.8446]}, {"w": "the", "b": [0.4766, 0.8232, 0.503, 0.8446]}, {"w": "Subclassing", "b": [0.5077, 0.8232, 0.6045, 0.8446]}, {"w": "API", "b": [0.6092, 0.8232, 0.6424, 0.8446]}, {"w": "309", "b": [0.8271, 0.8232, 0.8571, 0.8446]}, {"w": "Saving", "b": [0.1986, 0.8423, 0.2536, 0.8637]}, {"w": "and", "b": [0.2583, 0.8423, 0.2899, 0.8637]}, {"w": "Restoring", "b": [0.2946, 0.8423, 0.3755, 0.8637]}, {"w": "a", "b": [0.3802, 0.8423, 0.3893, 0.8637]}, {"w": "Model", "b": [0.3941, 0.8423, 0.4478, 0.8637]}, {"w": "311", "b": [0.8271, 0.8423, 0.8571, 0.8637]}, {"w": "Using", "b": [0.1986, 0.8613, 0.2472, 0.8827]}, {"w": "Callbacks", "b": [0.2519, 0.8613, 0.332, 0.8827]}, {"w": "311", "b": [0.8271, 0.8613, 0.8571, 0.8827]}]}, {"id": "b_9", "type": "paragraph", "text": "Table of Contents | vii", "words": [{"w": "Table", "b": [0.7015, 0.9225, 0.7336, 0.9388]}, {"w": "of", "b": [0.7364, 0.9225, 0.7484, 0.9388]}, {"w": "Contents", "b": [0.7512, 0.9225, 0.8037, 0.9388]}, {"w": "|", "b": [0.8215, 0.9225, 0.8253, 0.9388]}, {"w": "vii", "b": [0.8431, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 10, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Visualization Using TensorBoard 313 Fine-Tuning Neural Network Hyperparameters 315", "words": [{"w": "Visualization", "b": [0.1986, 0.0791, 0.3081, 0.1005]}, {"w": "Using", "b": [0.3128, 0.0791, 0.3614, 0.1005]}, {"w": "TensorBoard", "b": [0.3662, 0.0791, 0.4744, 0.1005]}, {"w": "313", "b": [0.8271, 0.0791, 0.8571, 0.1005]}, {"w": "Fine-Tuning", "b": [0.1814, 0.0981, 0.2857, 0.1195]}, {"w": "Neural", "b": [0.2904, 0.0981, 0.3475, 0.1195]}, {"w": "Network", "b": [0.3522, 0.0981, 0.4253, 0.1195]}, {"w": "Hyperparameters", "b": [0.43, 0.0981, 0.5758, 0.1195]}, {"w": "315", "b": [0.8271, 0.0981, 0.8571, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "Number of Hidden Layers 319 Number of Neurons per Hidden Layer 320 Learning Rate, Batch Size and Other Hyperparameters 320 Exercises 322", "words": [{"w": "Number", "b": [0.1986, 0.1172, 0.2686, 0.1386]}, {"w": "of", "b": [0.2733, 0.1172, 0.2901, 0.1386]}, {"w": "Hidden", "b": [0.2949, 0.1172, 0.3586, 0.1386]}, {"w": "Layers", "b": [0.3634, 0.1172, 0.4171, 0.1386]}, {"w": "319", "b": [0.8271, 0.1172, 0.8572, 0.1386]}, {"w": "Number", "b": [0.1986, 0.1362, 0.2686, 0.1576]}, {"w": "of", "b": [0.2733, 0.1362, 0.2901, 0.1576]}, {"w": "Neurons", "b": [0.2949, 0.1362, 0.3671, 0.1576]}, {"w": "per", "b": [0.3719, 0.1362, 0.3994, 0.1576]}, {"w": "Hidden", "b": [0.4041, 0.1362, 0.4679, 0.1576]}, {"w": "Layer", "b": [0.4726, 0.1362, 0.5187, 0.1576]}, {"w": "320", "b": [0.8272, 0.1362, 0.8572, 0.1576]}, {"w": "Learning", "b": [0.1986, 0.1553, 0.2736, 0.1767]}, {"w": "Rate,", "b": [0.2784, 0.1553, 0.3204, 0.1767]}, {"w": "Batch", "b": [0.3251, 0.1553, 0.3724, 0.1767]}, {"w": "Size", "b": [0.3771, 0.1553, 0.4102, 0.1767]}, {"w": "and", "b": [0.4149, 0.1553, 0.4465, 0.1767]}, {"w": "Other", "b": [0.4512, 0.1553, 0.5008, 0.1767]}, {"w": "Hyperparameters", "b": [0.5055, 0.1553, 0.6513, 0.1767]}, {"w": "320", "b": [0.8271, 0.1553, 0.8571, 0.1767]}, {"w": "Exercises", "b": [0.1814, 0.1743, 0.2582, 0.1957]}, {"w": "322", "b": [0.8271, 0.1743, 0.8572, 0.1957]}]}, {"id": "b_2", "type": "paragraph", "text": "11. Training Deep Neural Networks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 Vanishing/Exploding Gradients Problems 326", "words": [{"w": "11.", "b": [0.145, 0.2105, 0.1695, 0.2322]}, {"w": "Training", "b": [0.1814, 0.2105, 0.2469, 0.2322]}, {"w": "Deep", "b": [0.2506, 0.2105, 0.2907, 0.2322]}, {"w": "Neural", "b": [0.2945, 0.2105, 0.3467, 0.2322]}, {"w": "Networks.", "b": [0.3505, 0.2105, 0.4305, 0.2322]}, {"w": ".", "b": [0.4342, 0.2105, 0.4394, 0.2322]}, {"w": ".", "b": [0.4431, 0.2105, 0.4483, 0.2322]}, {"w": ".", "b": [0.452, 0.2105, 0.4572, 0.2322]}, {"w": ".", "b": [0.4609, 0.2105, 0.4661, 0.2322]}, {"w": ".", "b": [0.4698, 0.2105, 0.475, 0.2322]}, {"w": ".", "b": [0.4787, 0.2105, 0.4839, 0.2322]}, {"w": ".", "b": [0.4876, 0.2105, 0.4928, 0.2322]}, {"w": ".", "b": [0.4966, 0.2105, 0.5017, 0.2322]}, {"w": ".", "b": [0.5055, 0.2105, 0.5106, 0.2322]}, {"w": ".", "b": [0.5144, 0.2105, 0.5195, 0.2322]}, {"w": ".", "b": [0.5233, 0.2105, 0.5284, 0.2322]}, {"w": ".", "b": [0.5322, 0.2105, 0.5373, 0.2322]}, {"w": ".", "b": [0.5411, 0.2105, 0.5462, 0.2322]}, {"w": ".", "b": [0.55, 0.2105, 0.5551, 0.2322]}, {"w": ".", "b": [0.5589, 0.2105, 0.564, 0.2322]}, {"w": ".", "b": [0.5678, 0.2105, 0.5729, 0.2322]}, {"w": ".", "b": [0.5767, 0.2105, 0.5818, 0.2322]}, {"w": ".", "b": [0.5856, 0.2105, 0.5907, 0.2322]}, {"w": ".", "b": [0.5945, 0.2105, 0.5996, 0.2322]}, {"w": ".", "b": [0.6034, 0.2105, 0.6086, 0.2322]}, {"w": ".", "b": [0.6123, 0.2105, 0.6175, 0.2322]}, {"w": ".", "b": [0.6212, 0.2105, 0.6264, 0.2322]}, {"w": ".", "b": [0.6301, 0.2105, 0.6353, 0.2322]}, {"w": ".", "b": [0.639, 0.2105, 0.6442, 0.2322]}, {"w": ".", "b": [0.6479, 0.2105, 0.6531, 0.2322]}, {"w": ".", "b": [0.6568, 0.2105, 0.662, 0.2322]}, {"w": ".", "b": [0.6657, 0.2105, 0.6709, 0.2322]}, {"w": ".", "b": [0.6746, 0.2105, 0.6798, 0.2322]}, {"w": ".", "b": [0.6836, 0.2105, 0.6887, 0.2322]}, {"w": ".", "b": [0.6925, 0.2105, 0.6976, 0.2322]}, {"w": ".", "b": [0.7014, 0.2105, 0.7065, 0.2322]}, {"w": ".", "b": [0.7103, 0.2105, 0.7154, 0.2322]}, {"w": ".", "b": [0.7192, 0.2105, 0.7243, 0.2322]}, {"w": ".", "b": [0.7281, 0.2105, 0.7332, 0.2322]}, {"w": ".", "b": [0.737, 0.2105, 0.7421, 0.2322]}, {"w": ".", "b": [0.7459, 0.2105, 0.751, 0.2322]}, {"w": ".", "b": [0.7548, 0.2105, 0.7599, 0.2322]}, {"w": ".", "b": [0.7637, 0.2105, 0.7688, 0.2322]}, {"w": ".", "b": [0.7726, 0.2105, 0.7777, 0.2322]}, {"w": ".", "b": [0.7815, 0.2105, 0.7866, 0.2322]}, {"w": ".", "b": [0.7904, 0.2105, 0.7956, 0.2322]}, {"w": ".", "b": [0.7993, 0.2105, 0.8045, 0.2322]}, {"w": ".", "b": [0.8082, 0.2105, 0.8134, 0.2322]}, {"w": "325", "b": [0.828, 0.2105, 0.8571, 0.2322]}, {"w": "Vanishing/Exploding", "b": [0.1814, 0.2314, 0.3587, 0.2529]}, {"w": "Gradients", "b": [0.3635, 0.2314, 0.4457, 0.2529]}, {"w": "Problems", "b": [0.4504, 0.2314, 0.5299, 0.2529]}, {"w": "326", "b": [0.8272, 0.2314, 0.8572, 0.2529]}]}, {"id": "b_3", "type": "paragraph", "text": "Glorot and He Initialization 327 Nonsaturating Activation Functions 329 Batch Normalization 333 Gradient Clipping 338 Reusing Pretrained Layers 339", "words": [{"w": "Glorot", "b": [0.1986, 0.2505, 0.2541, 0.2719]}, {"w": "and", "b": [0.2588, 0.2505, 0.2903, 0.2719]}, {"w": "He", "b": [0.2951, 0.2505, 0.3194, 0.2719]}, {"w": "Initialization", "b": [0.3241, 0.2505, 0.4316, 0.2719]}, {"w": "327", "b": [0.8272, 0.2505, 0.8572, 0.2719]}, {"w": "Nonsaturating", "b": [0.1986, 0.2695, 0.3189, 0.291]}, {"w": "Activation", "b": [0.3236, 0.2695, 0.4106, 0.291]}, {"w": "Functions", "b": [0.4153, 0.2695, 0.4988, 0.291]}, {"w": "329", "b": [0.8272, 0.2695, 0.8572, 0.291]}, {"w": "Batch", "b": [0.1986, 0.2886, 0.2459, 0.31]}, {"w": "Normalization", "b": [0.2506, 0.2886, 0.3724, 0.31]}, {"w": "333", "b": [0.8272, 0.2886, 0.8572, 0.31]}, {"w": "Gradient", "b": [0.1986, 0.3076, 0.2731, 0.329]}, {"w": "Clipping", "b": [0.2779, 0.3076, 0.3511, 0.329]}, {"w": "338", "b": [0.8272, 0.3076, 0.8572, 0.329]}, {"w": "Reusing", "b": [0.1814, 0.3267, 0.2486, 0.3481]}, {"w": "Pretrained", "b": [0.2534, 0.3267, 0.3418, 0.3481]}, {"w": "Layers", "b": [0.3465, 0.3267, 0.4003, 0.3481]}, {"w": "339", "b": [0.8272, 0.3267, 0.8572, 0.3481]}]}, {"id": "b_4", "type": "paragraph", "text": "Transfer Learning With Keras 341 Unsupervised Pretraining 343 Pretraining on an Auxiliary Task 344 Faster Optimizers 344", "words": [{"w": "Transfer", "b": [0.1986, 0.3457, 0.2684, 0.3671]}, {"w": "Learning", "b": [0.2731, 0.3457, 0.3481, 0.3671]}, {"w": "With", "b": [0.3529, 0.3457, 0.3953, 0.3671]}, {"w": "Keras", "b": [0.4, 0.3457, 0.4469, 0.3671]}, {"w": "341", "b": [0.8272, 0.3457, 0.8572, 0.3671]}, {"w": "Unsupervised", "b": [0.1986, 0.3648, 0.3139, 0.3862]}, {"w": "Pretraining", "b": [0.3187, 0.3648, 0.4139, 0.3862]}, {"w": "343", "b": [0.8272, 0.3648, 0.8572, 0.3862]}, {"w": "Pretraining", "b": [0.1986, 0.3838, 0.2938, 0.4052]}, {"w": "on", "b": [0.2985, 0.3838, 0.3206, 0.4052]}, {"w": "an", "b": [0.3253, 0.3838, 0.3458, 0.4052]}, {"w": "Auxiliary", "b": [0.3506, 0.3838, 0.4285, 0.4052]}, {"w": "Task", "b": [0.4332, 0.3838, 0.4713, 0.4052]}, {"w": "344", "b": [0.8272, 0.3838, 0.8572, 0.4052]}, {"w": "Faster", "b": [0.1814, 0.4029, 0.2318, 0.4243]}, {"w": "Optimizers", "b": [0.2365, 0.4029, 0.3305, 0.4243]}, {"w": "344", "b": [0.8272, 0.4029, 0.8572, 0.4243]}]}, {"id": "b_5", "type": "paragraph", "text": "Momentum Optimization 345 Nesterov Accelerated Gradient 346 AdaGrad 347 RMSProp 349 Adam and Nadam Optimization 349 Learning Rate Scheduling 352 Avoiding Overfitting Through Regularization 356", "words": [{"w": "Momentum", "b": [0.1986, 0.4219, 0.2986, 0.4433]}, {"w": "Optimization", "b": [0.3033, 0.4219, 0.4159, 0.4433]}, {"w": "345", "b": [0.8272, 0.4219, 0.8572, 0.4433]}, {"w": "Nesterov", "b": [0.1986, 0.441, 0.2732, 0.4624]}, {"w": "Accelerated", "b": [0.278, 0.441, 0.3751, 0.4624]}, {"w": "Gradient", "b": [0.3798, 0.441, 0.4544, 0.4624]}, {"w": "346", "b": [0.8272, 0.441, 0.8572, 0.4624]}, {"w": "AdaGrad", "b": [0.1986, 0.46, 0.2753, 0.4814]}, {"w": "347", "b": [0.8272, 0.46, 0.8572, 0.4814]}, {"w": "RMSProp", "b": [0.1986, 0.4791, 0.2809, 0.5005]}, {"w": "349", "b": [0.8272, 0.4791, 0.8572, 0.5005]}, {"w": "Adam", "b": [0.1986, 0.4981, 0.2496, 0.5195]}, {"w": "and", "b": [0.2544, 0.4981, 0.2859, 0.5195]}, {"w": "Nadam", "b": [0.2906, 0.4981, 0.3519, 0.5195]}, {"w": "Optimization", "b": [0.3566, 0.4981, 0.4692, 0.5195]}, {"w": "349", "b": [0.8272, 0.4981, 0.8572, 0.5195]}, {"w": "Learning", "b": [0.1986, 0.5172, 0.2736, 0.5386]}, {"w": "Rate", "b": [0.2784, 0.5172, 0.3156, 0.5386]}, {"w": "Scheduling", "b": [0.3204, 0.5172, 0.4131, 0.5386]}, {"w": "352", "b": [0.8272, 0.5172, 0.8572, 0.5386]}, {"w": "Avoiding", "b": [0.1814, 0.5362, 0.258, 0.5576]}, {"w": "Overfitting", "b": [0.2628, 0.5362, 0.3561, 0.5576]}, {"w": "Through", "b": [0.3608, 0.5362, 0.4351, 0.5576]}, {"w": "Regularization", "b": [0.4398, 0.5362, 0.5616, 0.5576]}, {"w": "356", "b": [0.8272, 0.5362, 0.8572, 0.5576]}]}, {"id": "b_6", "type": "paragraph", "text": "ℓ1 and ℓ2 Regularization 356 Dropout 357 Monte-Carlo (MC) Dropout 360 Max-Norm Regularization 362 Summary and Practical Guidelines 363 Exercises 364", "words": [{"w": "ℓ1", "b": [0.1986, 0.5553, 0.2131, 0.5776]}, {"w": "and", "b": [0.2179, 0.5553, 0.2494, 0.5767]}, {"w": "ℓ2", "b": [0.2541, 0.5553, 0.2687, 0.5776]}, {"w": "Regularization", "b": [0.2734, 0.5553, 0.3952, 0.5767]}, {"w": "356", "b": [0.8272, 0.5553, 0.8572, 0.5767]}, {"w": "Dropout", "b": [0.1986, 0.5743, 0.2712, 0.5957]}, {"w": "357", "b": [0.8272, 0.5743, 0.8572, 0.5957]}, {"w": "Monte-Carlo", "b": [0.1986, 0.5933, 0.3075, 0.6148]}, {"w": "(MC)", "b": [0.3122, 0.5933, 0.359, 0.6148]}, {"w": "Dropout", "b": [0.3638, 0.5933, 0.4364, 0.6148]}, {"w": "360", "b": [0.8272, 0.5933, 0.8572, 0.6148]}, {"w": "Max-Norm", "b": [0.1986, 0.6124, 0.2935, 0.6338]}, {"w": "Regularization", "b": [0.2983, 0.6124, 0.4201, 0.6338]}, {"w": "362", "b": [0.8272, 0.6124, 0.8572, 0.6338]}, {"w": "Summary", "b": [0.1814, 0.6314, 0.2635, 0.6529]}, {"w": "and", "b": [0.2683, 0.6314, 0.2998, 0.6529]}, {"w": "Practical", "b": [0.3045, 0.6314, 0.3771, 0.6529]}, {"w": "Guidelines", "b": [0.3818, 0.6314, 0.472, 0.6529]}, {"w": "363", "b": [0.8272, 0.6314, 0.8572, 0.6529]}, {"w": "Exercises", "b": [0.1814, 0.6505, 0.2582, 0.6719]}, {"w": "364", "b": [0.8272, 0.6505, 0.8572, 0.6719]}]}, {"id": "b_7", "type": "paragraph", "text": "12. Custom Models and Training with TensorFlow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 A Quick Tour of TensorFlow 368 Using TensorFlow like NumPy 371", "words": [{"w": "12.", "b": [0.145, 0.6867, 0.1695, 0.7084]}, {"w": "Custom", "b": [0.1814, 0.6867, 0.2402, 0.7084]}, {"w": "Models", "b": [0.244, 0.6867, 0.3004, 0.7084]}, {"w": "and", "b": [0.3041, 0.6867, 0.334, 0.7084]}, {"w": "Training", "b": [0.3378, 0.6867, 0.4032, 0.7084]}, {"w": "with", "b": [0.407, 0.6867, 0.4431, 0.7084]}, {"w": "TensorFlow.", "b": [0.4469, 0.6867, 0.542, 0.7084]}, {"w": ".", "b": [0.5458, 0.6867, 0.5509, 0.7084]}, {"w": ".", "b": [0.5547, 0.6867, 0.5598, 0.7084]}, {"w": ".", "b": [0.5636, 0.6867, 0.5687, 0.7084]}, {"w": ".", "b": [0.5725, 0.6867, 0.5776, 0.7084]}, {"w": ".", "b": [0.5814, 0.6867, 0.5866, 0.7084]}, {"w": ".", "b": [0.5903, 0.6867, 0.5955, 0.7084]}, {"w": ".", "b": [0.5992, 0.6867, 0.6044, 0.7084]}, {"w": ".", "b": [0.6081, 0.6867, 0.6133, 0.7084]}, {"w": ".", "b": [0.617, 0.6867, 0.6222, 0.7084]}, {"w": ".", "b": [0.6259, 0.6867, 0.6311, 0.7084]}, {"w": ".", "b": [0.6348, 0.6867, 0.64, 0.7084]}, {"w": ".", "b": [0.6437, 0.6867, 0.6489, 0.7084]}, {"w": ".", "b": [0.6526, 0.6867, 0.6578, 0.7084]}, {"w": ".", "b": [0.6616, 0.6867, 0.6667, 0.7084]}, {"w": ".", "b": [0.6705, 0.6867, 0.6756, 0.7084]}, {"w": ".", "b": [0.6794, 0.6867, 0.6845, 0.7084]}, {"w": ".", "b": [0.6883, 0.6867, 0.6934, 0.7084]}, {"w": ".", "b": [0.6972, 0.6867, 0.7023, 0.7084]}, {"w": ".", "b": [0.7061, 0.6867, 0.7112, 0.7084]}, {"w": ".", "b": [0.715, 0.6867, 0.7201, 0.7084]}, {"w": ".", "b": [0.7239, 0.6867, 0.729, 0.7084]}, {"w": ".", "b": [0.7328, 0.6867, 0.7379, 0.7084]}, {"w": ".", "b": [0.7417, 0.6867, 0.7468, 0.7084]}, {"w": ".", "b": [0.7506, 0.6867, 0.7557, 0.7084]}, {"w": ".", "b": [0.7595, 0.6867, 0.7646, 0.7084]}, {"w": ".", "b": [0.7684, 0.6867, 0.7736, 0.7084]}, {"w": ".", "b": [0.7773, 0.6867, 0.7825, 0.7084]}, {"w": ".", "b": [0.7862, 0.6867, 0.7914, 0.7084]}, {"w": ".", "b": [0.7951, 0.6867, 0.8003, 0.7084]}, {"w": ".", "b": [0.804, 0.6867, 0.8092, 0.7084]}, {"w": ".", "b": [0.8129, 0.6867, 0.8181, 0.7084]}, {"w": "367", "b": [0.828, 0.6867, 0.8571, 0.7084]}, {"w": "A", "b": [0.1814, 0.7076, 0.1958, 0.729]}, {"w": "Quick", "b": [0.2005, 0.7076, 0.2519, 0.729]}, {"w": "Tour", "b": [0.2566, 0.7076, 0.2968, 0.729]}, {"w": "of", "b": [0.3015, 0.7076, 0.3183, 0.729]}, {"w": "TensorFlow", "b": [0.3231, 0.7076, 0.4213, 0.729]}, {"w": "368", "b": [0.8272, 0.7076, 0.8572, 0.729]}, {"w": "Using", "b": [0.1814, 0.7267, 0.23, 0.7481]}, {"w": "TensorFlow", "b": [0.2348, 0.7267, 0.333, 0.7481]}, {"w": "like", "b": [0.3377, 0.7267, 0.3678, 0.7481]}, {"w": "NumPy", "b": [0.3725, 0.7267, 0.4367, 0.7481]}, {"w": "371", "b": [0.8272, 0.7267, 0.8572, 0.7481]}]}, {"id": "b_8", "type": "paragraph", "text": "Tensors and Operations 371 Tensors and NumPy 373 Type Conversions 374 Variables 374 Other Data Structures 375 Customizing Models and Training Algorithms 376", "words": [{"w": "Tensors", "b": [0.1986, 0.7457, 0.2633, 0.7671]}, {"w": "and", "b": [0.268, 0.7457, 0.2995, 0.7671]}, {"w": "Operations", "b": [0.3043, 0.7457, 0.3977, 0.7671]}, {"w": "371", "b": [0.8272, 0.7457, 0.8572, 0.7671]}, {"w": "Tensors", "b": [0.1986, 0.7648, 0.2633, 0.7862]}, {"w": "and", "b": [0.268, 0.7648, 0.2995, 0.7862]}, {"w": "NumPy", "b": [0.3043, 0.7648, 0.3684, 0.7862]}, {"w": "373", "b": [0.8272, 0.7648, 0.8572, 0.7862]}, {"w": "Type", "b": [0.1986, 0.7838, 0.2392, 0.8052]}, {"w": "Conversions", "b": [0.244, 0.7838, 0.3485, 0.8052]}, {"w": "374", "b": [0.8272, 0.7838, 0.8572, 0.8052]}, {"w": "Variables", "b": [0.1986, 0.8029, 0.2751, 0.8243]}, {"w": "374", "b": [0.8272, 0.8029, 0.8572, 0.8243]}, {"w": "Other", "b": [0.1986, 0.8219, 0.2482, 0.8433]}, {"w": "Data", "b": [0.2529, 0.8219, 0.2925, 0.8433]}, {"w": "Structures", "b": [0.2972, 0.8219, 0.3827, 0.8433]}, {"w": "375", "b": [0.8272, 0.8219, 0.8572, 0.8433]}, {"w": "Customizing", "b": [0.1814, 0.841, 0.2891, 0.8624]}, {"w": "Models", "b": [0.2938, 0.841, 0.3552, 0.8624]}, {"w": "and", "b": [0.36, 0.841, 0.3915, 0.8624]}, {"w": "Training", "b": [0.3962, 0.841, 0.4679, 0.8624]}, {"w": "Algorithms", "b": [0.4727, 0.841, 0.5682, 0.8624]}, {"w": "376", "b": [0.8272, 0.841, 0.8572, 0.8624]}]}, {"id": "b_9", "type": "paragraph", "text": "Custom Loss Functions 376", "words": [{"w": "Custom", "b": [0.1986, 0.86, 0.2652, 0.8814]}, {"w": "Loss", "b": [0.2699, 0.86, 0.307, 0.8814]}, {"w": "Functions", "b": [0.3118, 0.86, 0.3952, 0.8814]}, {"w": "376", "b": [0.8272, 0.86, 0.8572, 0.8814]}]}, {"id": "b_10", "type": "paragraph", "text": "viii | Table of Contents", "words": [{"w": "viii", "b": [0.1429, 0.9225, 0.1605, 0.9388]}, {"w": "|", "b": [0.1784, 0.9225, 0.1821, 0.9388]}, {"w": "Table", "b": [0.2, 0.9225, 0.2321, 0.9388]}, {"w": "of", "b": [0.235, 0.9225, 0.2469, 0.9388]}, {"w": "Contents", "b": [0.2498, 0.9225, 0.3022, 0.9388]}]}]}, {"page": 11, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Saving and Loading Models That Contain Custom Components 377 Custom Activation Functions, Initializers, Regularizers, and Constraints 379 Custom Metrics 380 Custom Layers 383 Custom Models 386 Losses and Metrics Based on Model Internals 388 Computing Gradients Using Autodiff 389 Custom Training Loops 393 TensorFlow Functions and Graphs 396", "words": [{"w": "Saving", "b": [0.1986, 0.0791, 0.2536, 0.1005]}, {"w": "and", "b": [0.2583, 0.0791, 0.2899, 0.1005]}, {"w": "Loading", "b": [0.2946, 0.0791, 0.3633, 0.1005]}, {"w": "Models", "b": [0.368, 0.0791, 0.4294, 0.1005]}, {"w": "That", "b": [0.4342, 0.0791, 0.4733, 0.1005]}, {"w": "Contain", "b": [0.478, 0.0791, 0.5459, 0.1005]}, {"w": "Custom", "b": [0.5507, 0.0791, 0.6173, 0.1005]}, {"w": "Components", "b": [0.622, 0.0791, 0.7299, 0.1005]}, {"w": "377", "b": [0.8271, 0.0791, 0.8571, 0.1005]}, {"w": "Custom", "b": [0.1986, 0.0981, 0.2652, 0.1195]}, {"w": "Activation", "b": [0.2699, 0.0981, 0.3569, 0.1195]}, {"w": "Functions,", "b": [0.3616, 0.0981, 0.4498, 0.1195]}, {"w": "Initializers,", "b": [0.4545, 0.0981, 0.5483, 0.1195]}, {"w": "Regularizers,", "b": [0.553, 0.0981, 0.6611, 0.1195]}, {"w": "and", "b": [0.6658, 0.0981, 0.6974, 0.1195]}, {"w": "Constraints", "b": [0.7021, 0.0981, 0.7994, 0.1195]}, {"w": "379", "b": [0.8271, 0.0981, 0.8571, 0.1195]}, {"w": "Custom", "b": [0.1986, 0.1172, 0.2652, 0.1386]}, {"w": "Metrics", "b": [0.2699, 0.1172, 0.3329, 0.1386]}, {"w": "380", "b": [0.8271, 0.1172, 0.8571, 0.1386]}, {"w": "Custom", "b": [0.1986, 0.1362, 0.2652, 0.1576]}, {"w": "Layers", "b": [0.2699, 0.1362, 0.3237, 0.1576]}, {"w": "383", "b": [0.8271, 0.1362, 0.8571, 0.1576]}, {"w": "Custom", "b": [0.1986, 0.1553, 0.2652, 0.1767]}, {"w": "Models", "b": [0.2699, 0.1553, 0.3313, 0.1767]}, {"w": "386", "b": [0.8271, 0.1553, 0.8571, 0.1767]}, {"w": "Losses", "b": [0.1986, 0.1743, 0.2522, 0.1957]}, {"w": "and", "b": [0.2569, 0.1743, 0.2885, 0.1957]}, {"w": "Metrics", "b": [0.2932, 0.1743, 0.3562, 0.1957]}, {"w": "Based", "b": [0.3609, 0.1743, 0.4098, 0.1957]}, {"w": "on", "b": [0.4145, 0.1743, 0.4366, 0.1957]}, {"w": "Model", "b": [0.4413, 0.1743, 0.4951, 0.1957]}, {"w": "Internals", "b": [0.4998, 0.1743, 0.5743, 0.1957]}, {"w": "388", "b": [0.8271, 0.1743, 0.8571, 0.1957]}, {"w": "Computing", "b": [0.1986, 0.1933, 0.2948, 0.2148]}, {"w": "Gradients", "b": [0.2995, 0.1933, 0.3817, 0.2148]}, {"w": "Using", "b": [0.3864, 0.1933, 0.435, 0.2148]}, {"w": "Autodiff", "b": [0.4398, 0.1933, 0.5103, 0.2148]}, {"w": "389", "b": [0.8271, 0.1933, 0.8571, 0.2148]}, {"w": "Custom", "b": [0.1986, 0.2124, 0.2652, 0.2338]}, {"w": "Training", "b": [0.2699, 0.2124, 0.3416, 0.2338]}, {"w": "Loops", "b": [0.3463, 0.2124, 0.3974, 0.2338]}, {"w": "393", "b": [0.8271, 0.2124, 0.8571, 0.2338]}, {"w": "TensorFlow", "b": [0.1814, 0.2314, 0.2797, 0.2529]}, {"w": "Functions", "b": [0.2844, 0.2314, 0.3679, 0.2529]}, {"w": "and", "b": [0.3726, 0.2314, 0.4041, 0.2529]}, {"w": "Graphs", "b": [0.4089, 0.2314, 0.4699, 0.2529]}, {"w": "396", "b": [0.8271, 0.2314, 0.8571, 0.2529]}]}, {"id": "b_1", "type": "paragraph", "text": "Autograph and Tracing 398 TF Function Rules 400", "words": [{"w": "Autograph", "b": [0.1986, 0.2505, 0.2884, 0.2719]}, {"w": "and", "b": [0.2931, 0.2505, 0.3247, 0.2719]}, {"w": "Tracing", "b": [0.3294, 0.2505, 0.393, 0.2719]}, {"w": "398", "b": [0.8271, 0.2505, 0.8571, 0.2719]}, {"w": "TF", "b": [0.1986, 0.2695, 0.2224, 0.291]}, {"w": "Function", "b": [0.2272, 0.2695, 0.303, 0.291]}, {"w": "Rules", "b": [0.3077, 0.2695, 0.3531, 0.291]}, {"w": "400", "b": [0.8271, 0.2695, 0.8572, 0.291]}]}, {"id": "b_2", "type": "paragraph", "text": "13. Loading and Preprocessing Data with TensorFlow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 The Data API 404", "words": [{"w": "13.", "b": [0.145, 0.3057, 0.1695, 0.3274]}, {"w": "Loading", "b": [0.1814, 0.3057, 0.2447, 0.3274]}, {"w": "and", "b": [0.2485, 0.3057, 0.2784, 0.3274]}, {"w": "Preprocessing", "b": [0.2821, 0.3057, 0.3915, 0.3274]}, {"w": "Data", "b": [0.3953, 0.3057, 0.4321, 0.3274]}, {"w": "with", "b": [0.4359, 0.3057, 0.4721, 0.3274]}, {"w": "TensorFlow.", "b": [0.4758, 0.3057, 0.571, 0.3274]}, {"w": ".", "b": [0.5747, 0.3057, 0.5799, 0.3274]}, {"w": ".", "b": [0.5836, 0.3057, 0.5888, 0.3274]}, {"w": ".", "b": [0.5925, 0.3057, 0.5977, 0.3274]}, {"w": ".", "b": [0.6014, 0.3057, 0.6066, 0.3274]}, {"w": ".", "b": [0.6103, 0.3057, 0.6155, 0.3274]}, {"w": ".", "b": [0.6192, 0.3057, 0.6244, 0.3274]}, {"w": ".", "b": [0.6281, 0.3057, 0.6333, 0.3274]}, {"w": ".", "b": [0.6371, 0.3057, 0.6422, 0.3274]}, {"w": ".", "b": [0.646, 0.3057, 0.6511, 0.3274]}, {"w": ".", "b": [0.6549, 0.3057, 0.66, 0.3274]}, {"w": ".", "b": [0.6638, 0.3057, 0.6689, 0.3274]}, {"w": ".", "b": [0.6727, 0.3057, 0.6778, 0.3274]}, {"w": ".", "b": [0.6816, 0.3057, 0.6867, 0.3274]}, {"w": ".", "b": [0.6905, 0.3057, 0.6956, 0.3274]}, {"w": ".", "b": [0.6994, 0.3057, 0.7045, 0.3274]}, {"w": ".", "b": [0.7083, 0.3057, 0.7134, 0.3274]}, {"w": ".", "b": [0.7172, 0.3057, 0.7223, 0.3274]}, {"w": ".", "b": [0.7261, 0.3057, 0.7312, 0.3274]}, {"w": ".", "b": [0.735, 0.3057, 0.7401, 0.3274]}, {"w": ".", "b": [0.7439, 0.3057, 0.7491, 0.3274]}, {"w": ".", "b": [0.7528, 0.3057, 0.758, 0.3274]}, {"w": ".", "b": [0.7617, 0.3057, 0.7669, 0.3274]}, {"w": ".", "b": [0.7706, 0.3057, 0.7758, 0.3274]}, {"w": ".", "b": [0.7795, 0.3057, 0.7847, 0.3274]}, {"w": ".", "b": [0.7884, 0.3057, 0.7936, 0.3274]}, {"w": ".", "b": [0.7973, 0.3057, 0.8025, 0.3274]}, {"w": ".", "b": [0.8062, 0.3057, 0.8114, 0.3274]}, {"w": ".", "b": [0.8151, 0.3057, 0.8203, 0.3274]}, {"w": "403", "b": [0.828, 0.3057, 0.8571, 0.3274]}, {"w": "The", "b": [0.1814, 0.3267, 0.2143, 0.3481]}, {"w": "Data", "b": [0.219, 0.3267, 0.2585, 0.3481]}, {"w": "API", "b": [0.2633, 0.3267, 0.2965, 0.3481]}, {"w": "404", "b": [0.8272, 0.3267, 0.8572, 0.3481]}]}, {"id": "b_3", "type": "paragraph", "text": "Chaining Transformations 405 Shuffling the Data 406 Preprocessing the Data 409 Putting Everything Together 410 Prefetching 411 Using the Dataset With tf.keras 413 The TFRecord Format 414", "words": [{"w": "Chaining", "b": [0.1986, 0.3457, 0.2764, 0.3671]}, {"w": "Transformations", "b": [0.2811, 0.3457, 0.4201, 0.3671]}, {"w": "405", "b": [0.8272, 0.3457, 0.8572, 0.3671]}, {"w": "Shuffling", "b": [0.1986, 0.3648, 0.2746, 0.3862]}, {"w": "the", "b": [0.2793, 0.3648, 0.3056, 0.3862]}, {"w": "Data", "b": [0.3104, 0.3648, 0.3499, 0.3862]}, {"w": "406", "b": [0.8272, 0.3648, 0.8572, 0.3862]}, {"w": "Preprocessing", "b": [0.1986, 0.3838, 0.3158, 0.4052]}, {"w": "the", "b": [0.3206, 0.3838, 0.3469, 0.4052]}, {"w": "Data", "b": [0.3516, 0.3838, 0.3912, 0.4052]}, {"w": "409", "b": [0.8272, 0.3838, 0.8572, 0.4052]}, {"w": "Putting", "b": [0.1986, 0.4029, 0.2608, 0.4243]}, {"w": "Everything", "b": [0.2655, 0.4029, 0.3575, 0.4243]}, {"w": "Together", "b": [0.3623, 0.4029, 0.4364, 0.4243]}, {"w": "410", "b": [0.8272, 0.4029, 0.8572, 0.4243]}, {"w": "Prefetching", "b": [0.1986, 0.4219, 0.2949, 0.4433]}, {"w": "411", "b": [0.8272, 0.4219, 0.8572, 0.4433]}, {"w": "Using", "b": [0.1986, 0.441, 0.2472, 0.4624]}, {"w": "the", "b": [0.2519, 0.441, 0.2782, 0.4624]}, {"w": "Dataset", "b": [0.283, 0.441, 0.3454, 0.4624]}, {"w": "With", "b": [0.3501, 0.441, 0.3925, 0.4624]}, {"w": "tf.keras", "b": [0.3973, 0.441, 0.4583, 0.4624]}, {"w": "413", "b": [0.8272, 0.441, 0.8572, 0.4624]}, {"w": "The", "b": [0.1814, 0.46, 0.2143, 0.4814]}, {"w": "TFRecord", "b": [0.219, 0.46, 0.3028, 0.4814]}, {"w": "Format", "b": [0.3075, 0.46, 0.3687, 0.4814]}, {"w": "414", "b": [0.8272, 0.46, 0.8572, 0.4814]}]}, {"id": "b_4", "type": "paragraph", "text": "Compressed TFRecord Files 415 A Brief Introduction to Protocol Buffers 415 TensorFlow Protobufs 416 Loading and Parsing Examples 418 Handling Lists of Lists Using the SequenceExample Protobuf 419 The Features API 420", "words": [{"w": "Compressed", "b": [0.1986, 0.4791, 0.3024, 0.5005]}, {"w": "TFRecord", "b": [0.3071, 0.4791, 0.3909, 0.5005]}, {"w": "Files", "b": [0.3956, 0.4791, 0.434, 0.5005]}, {"w": "415", "b": [0.8272, 0.4791, 0.8572, 0.5005]}, {"w": "A", "b": [0.1986, 0.4981, 0.213, 0.5195]}, {"w": "Brief", "b": [0.2177, 0.4981, 0.2583, 0.5195]}, {"w": "Introduction", "b": [0.263, 0.4981, 0.3706, 0.5195]}, {"w": "to", "b": [0.3754, 0.4981, 0.3924, 0.5195]}, {"w": "Protocol", "b": [0.3971, 0.4981, 0.4689, 0.5195]}, {"w": "Buffers", "b": [0.4736, 0.4981, 0.5335, 0.5195]}, {"w": "415", "b": [0.8272, 0.4981, 0.8572, 0.5195]}, {"w": "TensorFlow", "b": [0.1986, 0.5172, 0.2968, 0.5386]}, {"w": "Protobufs", "b": [0.3015, 0.5172, 0.3841, 0.5386]}, {"w": "416", "b": [0.8272, 0.5172, 0.8572, 0.5386]}, {"w": "Loading", "b": [0.1986, 0.5362, 0.2673, 0.5576]}, {"w": "and", "b": [0.272, 0.5362, 0.3035, 0.5576]}, {"w": "Parsing", "b": [0.3083, 0.5362, 0.3708, 0.5576]}, {"w": "Examples", "b": [0.3755, 0.5362, 0.4557, 0.5576]}, {"w": "418", "b": [0.8272, 0.5362, 0.8572, 0.5576]}, {"w": "Handling", "b": [0.1986, 0.5561, 0.2776, 0.5776]}, {"w": "Lists", "b": [0.2823, 0.5561, 0.3207, 0.5776]}, {"w": "of", "b": [0.3255, 0.5561, 0.3423, 0.5776]}, {"w": "Lists", "b": [0.347, 0.5561, 0.3854, 0.5776]}, {"w": "Using", "b": [0.3901, 0.5561, 0.4388, 0.5776]}, {"w": "the", "b": [0.4435, 0.5561, 0.4698, 0.5776]}, {"w": "SequenceExample", "b": [0.4745, 0.5593, 0.623, 0.5744]}, {"w": "Protobuf", "b": [0.6277, 0.5561, 0.7026, 0.5776]}, {"w": "419", "b": [0.8271, 0.5561, 0.8571, 0.5776]}, {"w": "The", "b": [0.1814, 0.5752, 0.2143, 0.5966]}, {"w": "Features", "b": [0.219, 0.5752, 0.2889, 0.5966]}, {"w": "API", "b": [0.2936, 0.5752, 0.3268, 0.5966]}, {"w": "420", "b": [0.8272, 0.5752, 0.8572, 0.5966]}]}, {"id": "b_5", "type": "paragraph", "text": "Categorical Features 421 Crossed Categorical Features 421 Encoding Categorical Features Using One-Hot Vectors 422 Encoding Categorical Features Using Embeddings 423 Using Feature Columns for Parsing 426 Using Feature Columns in Your Models 426 TF Transform 428 The TensorFlow Datasets (TFDS) Project 429", "words": [{"w": "Categorical", "b": [0.1986, 0.5942, 0.2933, 0.6157]}, {"w": "Features", "b": [0.298, 0.5942, 0.3679, 0.6157]}, {"w": "421", "b": [0.8272, 0.5942, 0.8572, 0.6157]}, {"w": "Crossed", "b": [0.1986, 0.6133, 0.2659, 0.6347]}, {"w": "Categorical", "b": [0.2706, 0.6133, 0.3654, 0.6347]}, {"w": "Features", "b": [0.3701, 0.6133, 0.44, 0.6347]}, {"w": "421", "b": [0.8272, 0.6133, 0.8572, 0.6347]}, {"w": "Encoding", "b": [0.1986, 0.6323, 0.279, 0.6538]}, {"w": "Categorical", "b": [0.2837, 0.6323, 0.3784, 0.6538]}, {"w": "Features", "b": [0.3831, 0.6323, 0.453, 0.6538]}, {"w": "Using", "b": [0.4578, 0.6323, 0.5064, 0.6538]}, {"w": "One-Hot", "b": [0.5111, 0.6323, 0.5867, 0.6538]}, {"w": "Vectors", "b": [0.5915, 0.6323, 0.6541, 0.6538]}, {"w": "422", "b": [0.8272, 0.6323, 0.8572, 0.6538]}, {"w": "Encoding", "b": [0.1986, 0.6514, 0.279, 0.6728]}, {"w": "Categorical", "b": [0.2837, 0.6514, 0.3784, 0.6728]}, {"w": "Features", "b": [0.3831, 0.6514, 0.453, 0.6728]}, {"w": "Using", "b": [0.4578, 0.6514, 0.5064, 0.6728]}, {"w": "Embeddings", "b": [0.5111, 0.6514, 0.6158, 0.6728]}, {"w": "423", "b": [0.8272, 0.6514, 0.8572, 0.6728]}, {"w": "Using", "b": [0.1986, 0.6704, 0.2472, 0.6918]}, {"w": "Feature", "b": [0.2519, 0.6704, 0.3141, 0.6918]}, {"w": "Columns", "b": [0.3189, 0.6704, 0.3958, 0.6918]}, {"w": "for", "b": [0.4005, 0.6704, 0.425, 0.6918]}, {"w": "Parsing", "b": [0.4298, 0.6704, 0.4923, 0.6918]}, {"w": "426", "b": [0.8272, 0.6704, 0.8572, 0.6918]}, {"w": "Using", "b": [0.1986, 0.6895, 0.2472, 0.7109]}, {"w": "Feature", "b": [0.2519, 0.6895, 0.3141, 0.7109]}, {"w": "Columns", "b": [0.3189, 0.6895, 0.3958, 0.7109]}, {"w": "in", "b": [0.4005, 0.6895, 0.4175, 0.7109]}, {"w": "Your", "b": [0.4222, 0.6895, 0.4623, 0.7109]}, {"w": "Models", "b": [0.467, 0.6895, 0.5284, 0.7109]}, {"w": "426", "b": [0.8272, 0.6895, 0.8572, 0.7109]}, {"w": "TF", "b": [0.1814, 0.7085, 0.2053, 0.7299]}, {"w": "Transform", "b": [0.21, 0.7085, 0.2986, 0.7299]}, {"w": "428", "b": [0.8272, 0.7085, 0.8572, 0.7299]}, {"w": "The", "b": [0.1814, 0.7276, 0.2143, 0.749]}, {"w": "TensorFlow", "b": [0.219, 0.7276, 0.3172, 0.749]}, {"w": "Datasets", "b": [0.322, 0.7276, 0.392, 0.749]}, {"w": "(TFDS)", "b": [0.3968, 0.7276, 0.4602, 0.749]}, {"w": "Project", "b": [0.465, 0.7276, 0.5244, 0.749]}, {"w": "429", "b": [0.8272, 0.7276, 0.8572, 0.749]}]}, {"id": "b_6", "type": "paragraph", "text": "14. Deep Computer Vision Using Convolutional Neural Networks. . . . . . . . . . . . . . . . . . . 431 The Architecture of the Visual Cortex 432 Convolutional Layer 434", "words": [{"w": "14.", "b": [0.145, 0.7637, 0.1695, 0.7855]}, {"w": "Deep", "b": [0.1814, 0.7637, 0.2215, 0.7855]}, {"w": "Computer", "b": [0.2253, 0.7637, 0.3027, 0.7855]}, {"w": "Vision", "b": [0.3065, 0.7637, 0.3541, 0.7855]}, {"w": "Using", "b": [0.3579, 0.7637, 0.402, 0.7855]}, {"w": "Convolutional", "b": [0.4058, 0.7637, 0.5151, 0.7855]}, {"w": "Neural", "b": [0.5189, 0.7637, 0.5711, 0.7855]}, {"w": "Networks.", "b": [0.5749, 0.7637, 0.6549, 0.7855]}, {"w": ".", "b": [0.6586, 0.7637, 0.6638, 0.7855]}, {"w": ".", "b": [0.6675, 0.7637, 0.6727, 0.7855]}, {"w": ".", "b": [0.6764, 0.7637, 0.6816, 0.7855]}, {"w": ".", "b": [0.6853, 0.7637, 0.6905, 0.7855]}, {"w": ".", "b": [0.6942, 0.7637, 0.6994, 0.7855]}, {"w": ".", "b": [0.7032, 0.7637, 0.7083, 0.7855]}, {"w": ".", "b": [0.7121, 0.7637, 0.7172, 0.7855]}, {"w": ".", "b": [0.721, 0.7637, 0.7261, 0.7855]}, {"w": ".", "b": [0.7299, 0.7637, 0.735, 0.7855]}, {"w": ".", "b": [0.7388, 0.7637, 0.7439, 0.7855]}, {"w": ".", "b": [0.7477, 0.7637, 0.7528, 0.7855]}, {"w": ".", "b": [0.7566, 0.7637, 0.7617, 0.7855]}, {"w": ".", "b": [0.7655, 0.7637, 0.7706, 0.7855]}, {"w": ".", "b": [0.7744, 0.7637, 0.7795, 0.7855]}, {"w": ".", "b": [0.7833, 0.7637, 0.7884, 0.7855]}, {"w": ".", "b": [0.7922, 0.7637, 0.7973, 0.7855]}, {"w": ".", "b": [0.8011, 0.7637, 0.8062, 0.7855]}, {"w": ".", "b": [0.81, 0.7637, 0.8152, 0.7855]}, {"w": "431", "b": [0.828, 0.7637, 0.8572, 0.7855]}, {"w": "The", "b": [0.1814, 0.7847, 0.2143, 0.8061]}, {"w": "Architecture", "b": [0.219, 0.7847, 0.3246, 0.8061]}, {"w": "of", "b": [0.3294, 0.7847, 0.3462, 0.8061]}, {"w": "the", "b": [0.3509, 0.7847, 0.3772, 0.8061]}, {"w": "Visual", "b": [0.382, 0.7847, 0.4345, 0.8061]}, {"w": "Cortex", "b": [0.4392, 0.7847, 0.4964, 0.8061]}, {"w": "432", "b": [0.8272, 0.7847, 0.8572, 0.8061]}, {"w": "Convolutional", "b": [0.1814, 0.8038, 0.3018, 0.8252]}, {"w": "Layer", "b": [0.3065, 0.8038, 0.3526, 0.8252]}, {"w": "434", "b": [0.8272, 0.8038, 0.8572, 0.8252]}]}, {"id": "b_7", "type": "paragraph", "text": "Filters 436 Stacking Multiple Feature Maps 437 TensorFlow Implementation 439", "words": [{"w": "Filters", "b": [0.1986, 0.8228, 0.251, 0.8442]}, {"w": "436", "b": [0.8272, 0.8228, 0.8572, 0.8442]}, {"w": "Stacking", "b": [0.1986, 0.8419, 0.2698, 0.8633]}, {"w": "Multiple", "b": [0.2745, 0.8419, 0.3457, 0.8633]}, {"w": "Feature", "b": [0.3505, 0.8419, 0.4127, 0.8633]}, {"w": "Maps", "b": [0.4174, 0.8419, 0.4629, 0.8633]}, {"w": "437", "b": [0.8272, 0.8419, 0.8572, 0.8633]}, {"w": "TensorFlow", "b": [0.1986, 0.8609, 0.2968, 0.8823]}, {"w": "Implementation", "b": [0.3015, 0.8609, 0.4363, 0.8823]}, {"w": "439", "b": [0.8272, 0.8609, 0.8572, 0.8823]}]}, {"id": "b_8", "type": "paragraph", "text": "Table of Contents | ix", "words": [{"w": "Table", "b": [0.7052, 0.9225, 0.7374, 0.9388]}, {"w": "of", "b": [0.7402, 0.9225, 0.7522, 0.9388]}, {"w": "Contents", "b": [0.755, 0.9225, 0.8074, 0.9388]}, {"w": "|", "b": [0.8253, 0.9225, 0.829, 0.9388]}, {"w": "ix", "b": [0.8469, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 12, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Memory Requirements 441 Pooling Layer 442", "words": [{"w": "Memory", "b": [0.1986, 0.0791, 0.271, 0.1005]}, {"w": "Requirements", "b": [0.2758, 0.0791, 0.3923, 0.1005]}, {"w": "441", "b": [0.8271, 0.0791, 0.8571, 0.1005]}, {"w": "Pooling", "b": [0.1814, 0.0981, 0.2457, 0.1195]}, {"w": "Layer", "b": [0.2505, 0.0981, 0.2966, 0.1195]}, {"w": "442", "b": [0.8271, 0.0981, 0.8571, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "TensorFlow Implementation 444 CNN Architectures 446", "words": [{"w": "TensorFlow", "b": [0.1986, 0.1172, 0.2968, 0.1386]}, {"w": "Implementation", "b": [0.3015, 0.1172, 0.4363, 0.1386]}, {"w": "444", "b": [0.8271, 0.1172, 0.8571, 0.1386]}, {"w": "CNN", "b": [0.1814, 0.1362, 0.2262, 0.1576]}, {"w": "Architectures", "b": [0.231, 0.1362, 0.3443, 0.1576]}, {"w": "446", "b": [0.8271, 0.1362, 0.8571, 0.1576]}]}, {"id": "b_2", "type": "paragraph", "text": "LeNet-5 449 AlexNet 450 GoogLeNet 452 VGGNet 456 ResNet 457 Xception 459 SENet 461 Implementing a ResNet-34 CNN Using Keras 464 Using Pretrained Models From Keras 465 Pretrained Models for Transfer Learning 467 Classification and Localization 469 Object Detection 471", "words": [{"w": "LeNet-5", "b": [0.1986, 0.1553, 0.2662, 0.1767]}, {"w": "449", "b": [0.8271, 0.1553, 0.8571, 0.1767]}, {"w": "AlexNet", "b": [0.1986, 0.1743, 0.2671, 0.1957]}, {"w": "450", "b": [0.8271, 0.1743, 0.8571, 0.1957]}, {"w": "GoogLeNet", "b": [0.1986, 0.1933, 0.2947, 0.2148]}, {"w": "452", "b": [0.8271, 0.1933, 0.8571, 0.2148]}, {"w": "VGGNet", "b": [0.1986, 0.2124, 0.2724, 0.2338]}, {"w": "456", "b": [0.8271, 0.2124, 0.8571, 0.2338]}, {"w": "ResNet", "b": [0.1986, 0.2314, 0.2582, 0.2529]}, {"w": "457", "b": [0.8271, 0.2314, 0.8571, 0.2529]}, {"w": "Xception", "b": [0.1986, 0.2505, 0.2747, 0.2719]}, {"w": "459", "b": [0.8271, 0.2505, 0.8571, 0.2719]}, {"w": "SENet", "b": [0.1986, 0.2695, 0.2504, 0.291]}, {"w": "461", "b": [0.8271, 0.2695, 0.8571, 0.291]}, {"w": "Implementing", "b": [0.1814, 0.2886, 0.3002, 0.31]}, {"w": "a", "b": [0.305, 0.2886, 0.3141, 0.31]}, {"w": "ResNet-34", "b": [0.3188, 0.2886, 0.4059, 0.31]}, {"w": "CNN", "b": [0.4106, 0.2886, 0.4554, 0.31]}, {"w": "Using", "b": [0.4601, 0.2886, 0.5087, 0.31]}, {"w": "Keras", "b": [0.5135, 0.2886, 0.5604, 0.31]}, {"w": "464", "b": [0.8271, 0.2886, 0.8572, 0.31]}, {"w": "Using", "b": [0.1814, 0.3076, 0.23, 0.329]}, {"w": "Pretrained", "b": [0.2348, 0.3076, 0.3231, 0.329]}, {"w": "Models", "b": [0.3279, 0.3076, 0.3893, 0.329]}, {"w": "From", "b": [0.394, 0.3076, 0.4404, 0.329]}, {"w": "Keras", "b": [0.4452, 0.3076, 0.4921, 0.329]}, {"w": "465", "b": [0.8271, 0.3076, 0.8572, 0.329]}, {"w": "Pretrained", "b": [0.1814, 0.3267, 0.2698, 0.3481]}, {"w": "Models", "b": [0.2745, 0.3267, 0.3359, 0.3481]}, {"w": "for", "b": [0.3407, 0.3267, 0.3652, 0.3481]}, {"w": "Transfer", "b": [0.3699, 0.3267, 0.4397, 0.3481]}, {"w": "Learning", "b": [0.4444, 0.3267, 0.5195, 0.3481]}, {"w": "467", "b": [0.8272, 0.3267, 0.8572, 0.3481]}, {"w": "Classification", "b": [0.1814, 0.3457, 0.2938, 0.3671]}, {"w": "and", "b": [0.2986, 0.3457, 0.3301, 0.3671]}, {"w": "Localization", "b": [0.3348, 0.3457, 0.4369, 0.3671]}, {"w": "469", "b": [0.8271, 0.3457, 0.8572, 0.3671]}, {"w": "Object", "b": [0.1814, 0.3648, 0.2369, 0.3862]}, {"w": "Detection", "b": [0.2416, 0.3648, 0.3238, 0.3862]}, {"w": "471", "b": [0.8271, 0.3648, 0.8571, 0.3862]}]}, {"id": "b_3", "type": "paragraph", "text": "Fully Convolutional Networks (FCNs) 473 You Only Look Once (YOLO) 475 Semantic Segmentation 478 Exercises 482", "words": [{"w": "Fully", "b": [0.1986, 0.3838, 0.2403, 0.4052]}, {"w": "Convolutional", "b": [0.2451, 0.3838, 0.3654, 0.4052]}, {"w": "Networks", "b": [0.3702, 0.3838, 0.4509, 0.4052]}, {"w": "(FCNs)", "b": [0.4557, 0.3838, 0.5175, 0.4052]}, {"w": "473", "b": [0.8272, 0.3838, 0.8572, 0.4052]}, {"w": "You", "b": [0.1986, 0.4029, 0.2309, 0.4243]}, {"w": "Only", "b": [0.2356, 0.4029, 0.2774, 0.4243]}, {"w": "Look", "b": [0.2822, 0.4029, 0.325, 0.4243]}, {"w": "Once", "b": [0.3297, 0.4029, 0.3743, 0.4243]}, {"w": "(YOLO)", "b": [0.379, 0.4029, 0.4481, 0.4243]}, {"w": "475", "b": [0.8272, 0.4029, 0.8572, 0.4243]}, {"w": "Semantic", "b": [0.1814, 0.4219, 0.2581, 0.4433]}, {"w": "Segmentation", "b": [0.2628, 0.4219, 0.3773, 0.4433]}, {"w": "478", "b": [0.8272, 0.4219, 0.8572, 0.4433]}, {"w": "Exercises", "b": [0.1814, 0.441, 0.2582, 0.4624]}, {"w": "482", "b": [0.8271, 0.441, 0.8571, 0.4624]}]}, {"id": "b_4", "type": "paragraph", "text": "x | Table of Contents", "words": [{"w": "x", "b": [0.1429, 0.9225, 0.1495, 0.9388]}, {"w": "|", "b": [0.1673, 0.9225, 0.1711, 0.9388]}, {"w": "Table", "b": [0.1889, 0.9225, 0.2211, 0.9388]}, {"w": "of", "b": [0.2239, 0.9225, 0.2359, 0.9388]}, {"w": "Contents", "b": [0.2387, 0.9225, 0.2911, 0.9388]}]}]}, {"page": 13, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "1 Available on Hinton’s home page at http://www.cs.toronto.edu/~hinton/.", "words": [{"w": "1", "b": [0.1451, 0.8416, 0.1518, 0.8559]}, {"w": "Available", "b": [0.1587, 0.8401, 0.217, 0.8565]}, {"w": "on", "b": [0.2206, 0.8401, 0.2374, 0.8565]}, {"w": "Hinton’s", "b": [0.241, 0.8401, 0.294, 0.8565]}, {"w": "home", "b": [0.2976, 0.8401, 0.3339, 0.8565]}, {"w": "page", "b": [0.3375, 0.8401, 0.367, 0.8565]}, {"w": "at", "b": [0.3706, 0.8401, 0.3821, 0.8565]}, {"w": "http://www.cs.toronto.edu/~hinton/.", "b": [0.3857, 0.84, 0.609, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "2 Despite the fact that Yann Lecun’s deep convolutional neural networks had worked well for image recognition since the 1990s, although they were not as general purpose.", "words": [{"w": "2", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Despite", "b": [0.1587, 0.8598, 0.2071, 0.8761]}, {"w": "the", "b": [0.2107, 0.8598, 0.2308, 0.8761]}, {"w": "fact", "b": [0.2344, 0.8598, 0.2576, 0.8761]}, {"w": "that", "b": [0.2612, 0.8598, 0.286, 0.8761]}, {"w": "Yann", "b": [0.2897, 0.8598, 0.3222, 0.8761]}, {"w": "Lecun’s", "b": [0.3258, 0.8598, 0.3715, 0.8761]}, {"w": "deep", "b": [0.3751, 0.8598, 0.4053, 0.8761]}, {"w": "convolutional", "b": [0.4089, 0.8598, 0.4968, 0.8761]}, {"w": "neural", "b": [0.5004, 0.8598, 0.5411, 0.8761]}, {"w": "networks", "b": [0.5447, 0.8598, 0.6035, 0.8761]}, {"w": "had", "b": [0.6071, 0.8598, 0.631, 0.8761]}, {"w": "worked", "b": [0.6346, 0.8598, 0.6824, 0.8761]}, {"w": "well", "b": [0.686, 0.8598, 0.7117, 0.8761]}, {"w": "for", "b": [0.7153, 0.8598, 0.734, 0.8761]}, {"w": "image", "b": [0.7376, 0.8598, 0.776, 0.8761]}, {"w": "recognition", "b": [0.7796, 0.8598, 0.8532, 0.8761]}, {"w": "since", "b": [0.1587, 0.8749, 0.191, 0.8912]}, {"w": "the", "b": [0.1946, 0.8749, 0.2146, 0.8912]}, {"w": "1990s,", "b": [0.2182, 0.8749, 0.2581, 0.8912]}, {"w": "although", "b": [0.2617, 0.8749, 0.3185, 0.8912]}, {"w": "they", "b": [0.3221, 0.8749, 0.3494, 0.8912]}, {"w": "were", "b": [0.353, 0.8749, 0.3833, 0.8912]}, {"w": "not", "b": [0.3869, 0.8749, 0.4085, 0.8912]}, {"w": "as", "b": [0.4121, 0.8749, 0.4249, 0.8912]}, {"w": "general", "b": [0.4285, 0.8749, 0.475, 0.8912]}, {"w": "purpose.", "b": [0.4786, 0.8749, 0.5338, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "Preface", "words": [{"w": "Preface", "b": [0.734, 0.1062, 0.8571, 0.1518]}]}, {"id": "b_3", "type": "paragraph", "text": "The Machine Learning Tsunami", "words": [{"w": "The", "b": [0.1429, 0.3187, 0.1881, 0.3529]}, {"w": "Machine", "b": [0.194, 0.3187, 0.299, 0.3529]}, {"w": "Learning", "b": [0.3049, 0.3187, 0.4147, 0.3529]}, {"w": "Tsunami", "b": [0.4206, 0.3187, 0.5257, 0.3529]}]}, {"id": "b_4", "type": "paragraph", "text": "In 2006, Geoffrey Hinton et al. published a paper1 showing how to train a deep neural network capable of recognizing handwritten digits with state-of-the-art precision (>98%). They branded this technique “Deep Learning.” Training a deep neural net was widely considered impossible at the time,2 and most researchers had abandoned the idea since the 1990s. This paper revived the interest of the scientific community and before long many new papers demonstrated that Deep Learning was not only possible, but capable of mind-blowing achievements that no other Machine Learning (ML) technique could hope to match (with the help of tremendous computing power and great amounts of data). This enthusiasm soon extended to many other areas of Machine Learning.", "words": [{"w": "In", "b": [0.1429, 0.3598, 0.1614, 0.3812]}, {"w": "2006,", "b": [0.1662, 0.3598, 0.211, 0.3812]}, {"w": "Geoffrey", "b": [0.2158, 0.3598, 0.2887, 0.3812]}, {"w": "Hinton", "b": [0.2936, 0.3598, 0.3545, 0.3812]}, {"w": "et", "b": [0.3593, 0.3598, 0.3746, 0.3812]}, {"w": "al.", "b": [0.3794, 0.3598, 0.3986, 0.3812]}, {"w": "published", "b": [0.4034, 0.3598, 0.4855, 0.3812]}, {"w": "a", "b": [0.4904, 0.3598, 0.4995, 0.3812]}, {"w": "paper1", "b": [0.5044, 0.3598, 0.5572, 0.3812]}, {"w": "showing", "b": [0.5621, 0.3598, 0.6325, 0.3812]}, {"w": "how", "b": [0.6374, 0.3598, 0.6734, 0.3812]}, {"w": "to", "b": [0.6783, 0.3598, 0.6953, 0.3812]}, {"w": "train", "b": [0.7001, 0.3598, 0.7403, 0.3812]}, {"w": "a", "b": [0.7452, 0.3598, 0.7543, 0.3812]}, {"w": "deep", "b": [0.7592, 0.3598, 0.7988, 0.3812]}, {"w": "neural", "b": [0.8037, 0.3598, 0.8572, 0.3812]}, {"w": "network", "b": [0.1429, 0.3789, 0.2124, 0.4003]}, {"w": "capable", "b": [0.2221, 0.3789, 0.2844, 0.4003]}, {"w": "of", "b": [0.2941, 0.3789, 0.3108, 0.4003]}, {"w": "recognizing", "b": [0.3205, 0.3789, 0.4187, 0.4003]}, {"w": "handwritten", "b": [0.4284, 0.3789, 0.5316, 0.4003]}, {"w": "digits", "b": [0.5412, 0.3789, 0.5872, 0.4003]}, {"w": "with", "b": [0.5968, 0.3789, 0.6341, 0.4003]}, {"w": "state-of-the-art", "b": [0.6438, 0.3789, 0.7703, 0.4003]}, {"w": "precision", "b": [0.78, 0.3789, 0.8571, 0.4003]}, {"w": "(>98%).", "b": [0.1429, 0.3979, 0.2093, 0.4193]}, {"w": "They", "b": [0.2169, 0.3979, 0.2593, 0.4193]}, {"w": "branded", "b": [0.267, 0.3979, 0.3367, 0.4193]}, {"w": "this", "b": [0.3444, 0.3979, 0.3751, 0.4193]}, {"w": "technique", "b": [0.3827, 0.3979, 0.4654, 0.4193]}, {"w": "“Deep", "b": [0.4731, 0.3979, 0.5253, 0.4193]}, {"w": "Learning.”", "b": [0.533, 0.3979, 0.6183, 0.4193]}, {"w": "Training", "b": [0.6259, 0.3979, 0.6976, 0.4193]}, {"w": "a", "b": [0.7053, 0.3979, 0.7145, 0.4193]}, {"w": "deep", "b": [0.7221, 0.3979, 0.7617, 0.4193]}, {"w": "neural", "b": [0.7694, 0.3979, 0.8229, 0.4193]}, {"w": "net", "b": [0.8305, 0.3979, 0.8571, 0.4193]}, {"w": "was", "b": [0.1428, 0.417, 0.1739, 0.4384]}, {"w": "widely", "b": [0.1799, 0.417, 0.2345, 0.4384]}, {"w": "considered", "b": [0.2405, 0.417, 0.332, 0.4384]}, {"w": "impossible", "b": [0.338, 0.417, 0.4274, 0.4384]}, {"w": "at", "b": [0.4334, 0.417, 0.4485, 0.4384]}, {"w": "the", "b": [0.4546, 0.417, 0.4809, 0.4384]}, {"w": "time,2", "b": [0.4869, 0.417, 0.5352, 0.4384]}, {"w": "and", "b": [0.5413, 0.417, 0.5728, 0.4384]}, {"w": "most", "b": [0.5788, 0.417, 0.6205, 0.4384]}, {"w": "researchers", "b": [0.6266, 0.417, 0.7207, 0.4384]}, {"w": "had", "b": [0.7267, 0.417, 0.758, 0.4384]}, {"w": "abandoned", "b": [0.764, 0.417, 0.8571, 0.4384]}, {"w": "the", "b": [0.1429, 0.436, 0.1692, 0.4574]}, {"w": "idea", "b": [0.1756, 0.436, 0.2102, 0.4574]}, {"w": "since", "b": [0.2166, 0.436, 0.2589, 0.4574]}, {"w": "the", "b": [0.2653, 0.436, 0.2916, 0.4574]}, {"w": "1990s.", "b": [0.298, 0.436, 0.3504, 0.4574]}, {"w": "This", "b": [0.3568, 0.436, 0.394, 0.4574]}, {"w": "paper", "b": [0.4004, 0.436, 0.4476, 0.4574]}, {"w": "revived", "b": [0.454, 0.436, 0.5153, 0.4574]}, {"w": "the", "b": [0.5217, 0.436, 0.5481, 0.4574]}, {"w": "interest", "b": [0.5545, 0.436, 0.6169, 0.4574]}, {"w": "of", "b": [0.6233, 0.436, 0.6401, 0.4574]}, {"w": "the", "b": [0.6465, 0.436, 0.6728, 0.4574]}, {"w": "scientific", "b": [0.6792, 0.436, 0.7536, 0.4574]}, {"w": "community", "b": [0.76, 0.436, 0.8571, 0.4574]}, {"w": "and", "b": [0.1428, 0.4551, 0.1744, 0.4765]}, {"w": "before", "b": [0.1822, 0.4551, 0.235, 0.4765]}, {"w": "long", "b": [0.2428, 0.4551, 0.2798, 0.4765]}, {"w": "many", "b": [0.2876, 0.4551, 0.3343, 0.4765]}, {"w": "new", "b": [0.3421, 0.4551, 0.3766, 0.4765]}, {"w": "papers", "b": [0.3844, 0.4551, 0.4392, 0.4765]}, {"w": "demonstrated", "b": [0.4469, 0.4551, 0.5626, 0.4765]}, {"w": "that", "b": [0.5704, 0.4551, 0.6029, 0.4765]}, {"w": "Deep", "b": [0.6107, 0.4551, 0.6547, 0.4765]}, {"w": "Learning", "b": [0.6624, 0.4551, 0.7375, 0.4765]}, {"w": "was", "b": [0.7453, 0.4551, 0.7763, 0.4765]}, {"w": "not", "b": [0.7841, 0.4551, 0.8125, 0.4765]}, {"w": "only", "b": [0.8203, 0.4551, 0.8571, 0.4765]}, {"w": "possible,", "b": [0.1429, 0.4741, 0.2147, 0.4955]}, {"w": "but", "b": [0.2202, 0.4741, 0.2482, 0.4955]}, {"w": "capable", "b": [0.2537, 0.4741, 0.3161, 0.4955]}, {"w": "of", "b": [0.3216, 0.4741, 0.3383, 0.4955]}, {"w": "mind-blowing", "b": [0.3438, 0.4741, 0.4638, 0.4955]}, {"w": "achievements", "b": [0.4693, 0.4741, 0.5822, 0.4955]}, {"w": "that", "b": [0.5877, 0.4741, 0.6203, 0.4955]}, {"w": "no", "b": [0.6258, 0.4741, 0.6478, 0.4955]}, {"w": "other", "b": [0.6533, 0.4741, 0.698, 0.4955]}, {"w": "Machine", "b": [0.7035, 0.4741, 0.7766, 0.4955]}, {"w": "Learning", "b": [0.7821, 0.4741, 0.8571, 0.4955]}, {"w": "(ML)", "b": [0.1429, 0.4932, 0.187, 0.5146]}, {"w": "technique", "b": [0.1922, 0.4932, 0.2749, 0.5146]}, {"w": "could", "b": [0.2801, 0.4932, 0.3268, 0.5146]}, {"w": "hope", "b": [0.332, 0.4932, 0.3735, 0.5146]}, {"w": "to", "b": [0.3787, 0.4932, 0.3957, 0.5146]}, {"w": "match", "b": [0.4009, 0.4932, 0.453, 0.5146]}, {"w": "(with", "b": [0.4581, 0.4932, 0.5027, 0.5146]}, {"w": "the", "b": [0.5078, 0.4932, 0.5342, 0.5146]}, {"w": "help", "b": [0.5394, 0.4932, 0.5755, 0.5146]}, {"w": "of", "b": [0.5807, 0.4932, 0.5975, 0.5146]}, {"w": "tremendous", "b": [0.6027, 0.4932, 0.7032, 0.5146]}, {"w": "computing", "b": [0.7084, 0.4932, 0.7996, 0.5146]}, {"w": "power", "b": [0.8047, 0.4932, 0.8571, 0.5146]}, {"w": "and", "b": [0.1429, 0.5122, 0.1744, 0.5336]}, {"w": "great", "b": [0.1812, 0.5122, 0.2226, 0.5336]}, {"w": "amounts", "b": [0.2294, 0.5122, 0.3023, 0.5336]}, {"w": "of", "b": [0.309, 0.5122, 0.3258, 0.5336]}, {"w": "data).", "b": [0.3326, 0.5122, 0.3798, 0.5336]}, {"w": "This", "b": [0.3866, 0.5122, 0.4238, 0.5336]}, {"w": "enthusiasm", "b": [0.4306, 0.5122, 0.5256, 0.5336]}, {"w": "soon", "b": [0.5324, 0.5122, 0.5727, 0.5336]}, {"w": "extended", "b": [0.5795, 0.5122, 0.6556, 0.5336]}, {"w": "to", "b": [0.6624, 0.5122, 0.6794, 0.5336]}, {"w": "many", "b": [0.6861, 0.5122, 0.7328, 0.5336]}, {"w": "other", "b": [0.7396, 0.5122, 0.7843, 0.5336]}, {"w": "areas", "b": [0.7911, 0.5122, 0.8336, 0.5336]}, {"w": "of", "b": [0.8403, 0.5122, 0.8571, 0.5336]}, {"w": "Machine", "b": [0.1429, 0.5313, 0.216, 0.5527]}, {"w": "Learning.", "b": [0.2207, 0.5313, 0.3005, 0.5527]}]}, {"id": "b_5", "type": "paragraph", "text": "Fast-forward 10 years and Machine Learning has conquered the industry: it is now at the heart of much of the magic in today’s high-tech products, ranking your web search results, powering your smartphone’s speech recognition, recommending vid‐ eos, and beating the world champion at the game of Go. Before you know it, it will be driving your car.", "words": [{"w": "Fast-forward", "b": [0.1429, 0.5594, 0.2513, 0.5808]}, {"w": "10", "b": [0.2565, 0.5594, 0.2765, 0.5808]}, {"w": "years", "b": [0.2816, 0.5594, 0.3246, 0.5808]}, {"w": "and", "b": [0.3297, 0.5594, 0.3613, 0.5808]}, {"w": "Machine", "b": [0.3664, 0.5594, 0.4395, 0.5808]}, {"w": "Learning", "b": [0.4447, 0.5594, 0.5198, 0.5808]}, {"w": "has", "b": [0.5249, 0.5594, 0.5528, 0.5808]}, {"w": "conquered", "b": [0.558, 0.5594, 0.647, 0.5808]}, {"w": "the", "b": [0.6521, 0.5594, 0.6785, 0.5808]}, {"w": "industry:", "b": [0.6836, 0.5594, 0.76, 0.5808]}, {"w": "it", "b": [0.7651, 0.5594, 0.7771, 0.5808]}, {"w": "is", "b": [0.7822, 0.5594, 0.7954, 0.5808]}, {"w": "now", "b": [0.8006, 0.5594, 0.8369, 0.5808]}, {"w": "at", "b": [0.842, 0.5594, 0.8572, 0.5808]}, {"w": "the", "b": [0.1429, 0.5784, 0.1692, 0.5998]}, {"w": "heart", "b": [0.1781, 0.5784, 0.2213, 0.5998]}, {"w": "of", "b": [0.2303, 0.5784, 0.2471, 0.5998]}, {"w": "much", "b": [0.256, 0.5784, 0.3037, 0.5998]}, {"w": "of", "b": [0.3126, 0.5784, 0.3294, 0.5998]}, {"w": "the", "b": [0.3383, 0.5784, 0.3647, 0.5998]}, {"w": "magic", "b": [0.3736, 0.5784, 0.4239, 0.5998]}, {"w": "in", "b": [0.4329, 0.5784, 0.4499, 0.5998]}, {"w": "today’s", "b": [0.4588, 0.5784, 0.5154, 0.5998]}, {"w": "high-tech", "b": [0.5243, 0.5784, 0.6045, 0.5998]}, {"w": "products,", "b": [0.6134, 0.5784, 0.6923, 0.5998]}, {"w": "ranking", "b": [0.7013, 0.5784, 0.7666, 0.5998]}, {"w": "your", "b": [0.7755, 0.5784, 0.8145, 0.5998]}, {"w": "web", "b": [0.8234, 0.5784, 0.8571, 0.5998]}, {"w": "search", "b": [0.1429, 0.5975, 0.1962, 0.6189]}, {"w": "results,", "b": [0.2029, 0.5975, 0.2622, 0.6189]}, {"w": "powering", "b": [0.269, 0.5975, 0.3481, 0.6189]}, {"w": "your", "b": [0.3549, 0.5975, 0.3939, 0.6189]}, {"w": "smartphone’s", "b": [0.4007, 0.5975, 0.5106, 0.6189]}, {"w": "speech", "b": [0.5174, 0.5975, 0.5736, 0.6189]}, {"w": "recognition,", "b": [0.5804, 0.5975, 0.6818, 0.6189]}, {"w": "recommending", "b": [0.6886, 0.5975, 0.8167, 0.6189]}, {"w": "vid‐", "b": [0.8235, 0.5975, 0.8571, 0.6189]}, {"w": "eos,", "b": [0.1428, 0.6165, 0.1747, 0.6379]}, {"w": "and", "b": [0.1798, 0.6165, 0.2113, 0.6379]}, {"w": "beating", "b": [0.2164, 0.6165, 0.2777, 0.6379]}, {"w": "the", "b": [0.2827, 0.6165, 0.3091, 0.6379]}, {"w": "world", "b": [0.3141, 0.6165, 0.363, 0.6379]}, {"w": "champion", "b": [0.3681, 0.6165, 0.4524, 0.6379]}, {"w": "at", "b": [0.4574, 0.6165, 0.4725, 0.6379]}, {"w": "the", "b": [0.4776, 0.6165, 0.504, 0.6379]}, {"w": "game", "b": [0.509, 0.6165, 0.5538, 0.6379]}, {"w": "of", "b": [0.5589, 0.6165, 0.5757, 0.6379]}, {"w": "Go.", "b": [0.5808, 0.6165, 0.6104, 0.6379]}, {"w": "Before", "b": [0.6155, 0.6165, 0.6704, 0.6379]}, {"w": "you", "b": [0.6755, 0.6165, 0.7067, 0.6379]}, {"w": "know", "b": [0.7118, 0.6165, 0.7584, 0.6379]}, {"w": "it,", "b": [0.7635, 0.6165, 0.7802, 0.6379]}, {"w": "it", "b": [0.7852, 0.6165, 0.7972, 0.6379]}, {"w": "will", "b": [0.8022, 0.6165, 0.8326, 0.6379]}, {"w": "be", "b": [0.8377, 0.6165, 0.8571, 0.6379]}, {"w": "driving", "b": [0.1429, 0.6356, 0.2036, 0.657]}, {"w": "your", "b": [0.2083, 0.6356, 0.2473, 0.657]}, {"w": "car.", "b": [0.252, 0.6356, 0.2811, 0.657]}]}, {"id": "b_6", "type": "paragraph", "text": "Machine Learning in Your Projects", "words": [{"w": "Machine", "b": [0.1429, 0.67, 0.2478, 0.7042]}, {"w": "Learning", "b": [0.2537, 0.67, 0.3635, 0.7042]}, {"w": "in", "b": [0.3695, 0.67, 0.3935, 0.7042]}, {"w": "Your", "b": [0.3994, 0.67, 0.456, 0.7042]}, {"w": "Projects", "b": [0.462, 0.67, 0.5604, 0.7042]}]}, {"id": "b_7", "type": "paragraph", "text": "So naturally you are excited about Machine Learning and you would love to join the party!", "words": [{"w": "So", "b": [0.1429, 0.7112, 0.1634, 0.7326]}, {"w": "naturally", "b": [0.1692, 0.7112, 0.2437, 0.7326]}, {"w": "you", "b": [0.2495, 0.7112, 0.2808, 0.7326]}, {"w": "are", "b": [0.2866, 0.7112, 0.3123, 0.7326]}, {"w": "excited", "b": [0.3181, 0.7112, 0.3774, 0.7326]}, {"w": "about", "b": [0.3832, 0.7112, 0.431, 0.7326]}, {"w": "Machine", "b": [0.4368, 0.7112, 0.5099, 0.7326]}, {"w": "Learning", "b": [0.5157, 0.7112, 0.5908, 0.7326]}, {"w": "and", "b": [0.5966, 0.7112, 0.6282, 0.7326]}, {"w": "you", "b": [0.634, 0.7112, 0.6652, 0.7326]}, {"w": "would", "b": [0.671, 0.7112, 0.7233, 0.7326]}, {"w": "love", "b": [0.7291, 0.7112, 0.7635, 0.7326]}, {"w": "to", "b": [0.7693, 0.7112, 0.7863, 0.7326]}, {"w": "join", "b": [0.7921, 0.7112, 0.825, 0.7326]}, {"w": "the", "b": [0.8308, 0.7112, 0.8571, 0.7326]}, {"w": "party!", "b": [0.1429, 0.7302, 0.1923, 0.7516]}]}, {"id": "b_8", "type": "paragraph", "text": "Perhaps you would like to give your homemade robot a brain of its own? Make it rec‐ ognize faces? Or learn to walk around?", "words": [{"w": "Perhaps", "b": [0.1429, 0.7583, 0.2089, 0.7797]}, {"w": "you", "b": [0.2139, 0.7583, 0.2452, 0.7797]}, {"w": "would", "b": [0.2502, 0.7583, 0.3024, 0.7797]}, {"w": "like", "b": [0.3074, 0.7583, 0.3374, 0.7797]}, {"w": "to", "b": [0.3424, 0.7583, 0.3594, 0.7797]}, {"w": "give", "b": [0.3644, 0.7583, 0.3982, 0.7797]}, {"w": "your", "b": [0.4032, 0.7583, 0.4422, 0.7797]}, {"w": "homemade", "b": [0.4472, 0.7583, 0.5409, 0.7797]}, {"w": "robot", "b": [0.5459, 0.7583, 0.5918, 0.7797]}, {"w": "a", "b": [0.5968, 0.7583, 0.6059, 0.7797]}, {"w": "brain", "b": [0.6109, 0.7583, 0.6554, 0.7797]}, {"w": "of", "b": [0.6603, 0.7583, 0.6771, 0.7797]}, {"w": "its", "b": [0.6821, 0.7583, 0.7017, 0.7797]}, {"w": "own?", "b": [0.7067, 0.7583, 0.7509, 0.7797]}, {"w": "Make", "b": [0.7559, 0.7583, 0.8024, 0.7797]}, {"w": "it", "b": [0.8074, 0.7583, 0.8193, 0.7797]}, {"w": "rec‐", "b": [0.8243, 0.7583, 0.8571, 0.7797]}, {"w": "ognize", "b": [0.1429, 0.7774, 0.1978, 0.7988]}, {"w": "faces?", "b": [0.2025, 0.7774, 0.2511, 0.7988]}, {"w": "Or", "b": [0.2558, 0.7774, 0.2791, 0.7988]}, {"w": "learn", "b": [0.2838, 0.7774, 0.3262, 0.7988]}, {"w": "to", "b": [0.3309, 0.7774, 0.3479, 0.7988]}, {"w": "walk", "b": [0.3526, 0.7774, 0.3917, 0.7988]}, {"w": "around?", "b": [0.3964, 0.7774, 0.4652, 0.7988]}]}]}, {"page": 14, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Or maybe your company has tons of data (user logs, financial data, production data, machine sensor data, hotline stats, HR reports, etc.), and more than likely you could unearth some hidden gems if you just knew where to look; for example:", "words": [{"w": "Or", "b": [0.1429, 0.0791, 0.1661, 0.1005]}, {"w": "maybe", "b": [0.1721, 0.0791, 0.2269, 0.1005]}, {"w": "your", "b": [0.2329, 0.0791, 0.2719, 0.1005]}, {"w": "company", "b": [0.2778, 0.0791, 0.3545, 0.1005]}, {"w": "has", "b": [0.3604, 0.0791, 0.3883, 0.1005]}, {"w": "tons", "b": [0.3943, 0.0791, 0.4303, 0.1005]}, {"w": "of", "b": [0.4363, 0.0791, 0.4531, 0.1005]}, {"w": "data", "b": [0.459, 0.0791, 0.4943, 0.1005]}, {"w": "(user", "b": [0.5002, 0.0791, 0.5427, 0.1005]}, {"w": "logs,", "b": [0.5487, 0.0791, 0.5867, 0.1005]}, {"w": "financial", "b": [0.5927, 0.0791, 0.6652, 0.1005]}, {"w": "data,", "b": [0.6711, 0.0791, 0.7111, 0.1005]}, {"w": "production", "b": [0.7171, 0.0791, 0.8112, 0.1005]}, {"w": "data,", "b": [0.8171, 0.0791, 0.8571, 0.1005]}, {"w": "machine", "b": [0.1429, 0.0981, 0.2148, 0.1195]}, {"w": "sensor", "b": [0.2207, 0.0981, 0.2746, 0.1195]}, {"w": "data,", "b": [0.2805, 0.0981, 0.3205, 0.1195]}, {"w": "hotline", "b": [0.3264, 0.0981, 0.3856, 0.1195]}, {"w": "stats,", "b": [0.3915, 0.0981, 0.433, 0.1195]}, {"w": "HR", "b": [0.439, 0.0981, 0.4678, 0.1195]}, {"w": "reports,", "b": [0.4738, 0.0981, 0.5384, 0.1195]}, {"w": "etc.),", "b": [0.5443, 0.0981, 0.585, 0.1195]}, {"w": "and", "b": [0.5909, 0.0981, 0.6224, 0.1195]}, {"w": "more", "b": [0.6283, 0.0981, 0.6726, 0.1195]}, {"w": "than", "b": [0.6785, 0.0981, 0.7165, 0.1195]}, {"w": "likely", "b": [0.7224, 0.0981, 0.7673, 0.1195]}, {"w": "you", "b": [0.7732, 0.0981, 0.8045, 0.1195]}, {"w": "could", "b": [0.8104, 0.0981, 0.8571, 0.1195]}, {"w": "unearth", "b": [0.1429, 0.1172, 0.2085, 0.1386]}, {"w": "some", "b": [0.2133, 0.1172, 0.2574, 0.1386]}, {"w": "hidden", "b": [0.2622, 0.1172, 0.3211, 0.1386]}, {"w": "gems", "b": [0.3259, 0.1172, 0.3692, 0.1386]}, {"w": "if", "b": [0.3739, 0.1172, 0.3857, 0.1386]}, {"w": "you", "b": [0.3904, 0.1172, 0.4216, 0.1386]}, {"w": "just", "b": [0.4264, 0.1172, 0.4568, 0.1386]}, {"w": "knew", "b": [0.4615, 0.1172, 0.5063, 0.1386]}, {"w": "where", "b": [0.5111, 0.1172, 0.5619, 0.1386]}, {"w": "to", "b": [0.5666, 0.1172, 0.5836, 0.1386]}, {"w": "look;", "b": [0.5883, 0.1172, 0.6299, 0.1386]}, {"w": "for", "b": [0.6347, 0.1172, 0.6592, 0.1386]}, {"w": "example:", "b": [0.6639, 0.1172, 0.7382, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "• Segment customers and find the best marketing strategy for each group", "words": [{"w": "•", "b": [0.16, 0.1513, 0.1682, 0.1727]}, {"w": "Segment", "b": [0.1786, 0.1513, 0.2503, 0.1727]}, {"w": "customers", "b": [0.255, 0.1513, 0.3408, 0.1727]}, {"w": "and", "b": [0.3456, 0.1513, 0.3771, 0.1727]}, {"w": "find", "b": [0.3818, 0.1513, 0.416, 0.1727]}, {"w": "the", "b": [0.4207, 0.1513, 0.447, 0.1727]}, {"w": "best", "b": [0.4518, 0.1513, 0.4852, 0.1727]}, {"w": "marketing", "b": [0.4899, 0.1513, 0.5761, 0.1727]}, {"w": "strategy", "b": [0.5809, 0.1513, 0.6464, 0.1727]}, {"w": "for", "b": [0.6511, 0.1513, 0.6756, 0.1727]}, {"w": "each", "b": [0.6804, 0.1513, 0.7183, 0.1727]}, {"w": "group", "b": [0.723, 0.1513, 0.7731, 0.1727]}]}, {"id": "b_2", "type": "paragraph", "text": "• Recommend products for each client based on what similar clients bought", "words": [{"w": "•", "b": [0.16, 0.1764, 0.1682, 0.1978]}, {"w": "Recommend", "b": [0.1786, 0.1764, 0.2852, 0.1978]}, {"w": "products", "b": [0.2899, 0.1764, 0.364, 0.1978]}, {"w": "for", "b": [0.3688, 0.1764, 0.3933, 0.1978]}, {"w": "each", "b": [0.398, 0.1764, 0.436, 0.1978]}, {"w": "client", "b": [0.4407, 0.1764, 0.4866, 0.1978]}, {"w": "based", "b": [0.4913, 0.1764, 0.5385, 0.1978]}, {"w": "on", "b": [0.5433, 0.1764, 0.5653, 0.1978]}, {"w": "what", "b": [0.57, 0.1764, 0.6105, 0.1978]}, {"w": "similar", "b": [0.6152, 0.1764, 0.6733, 0.1978]}, {"w": "clients", "b": [0.678, 0.1764, 0.7315, 0.1978]}, {"w": "bought", "b": [0.7362, 0.1764, 0.7953, 0.1978]}]}, {"id": "b_3", "type": "paragraph", "text": "• Detect which transactions are likely to be fraudulent", "words": [{"w": "•", "b": [0.16, 0.2015, 0.1682, 0.2229]}, {"w": "Detect", "b": [0.1786, 0.2015, 0.2331, 0.2229]}, {"w": "which", "b": [0.2378, 0.2015, 0.2888, 0.2229]}, {"w": "transactions", "b": [0.2935, 0.2015, 0.3953, 0.2229]}, {"w": "are", "b": [0.4, 0.2015, 0.4258, 0.2229]}, {"w": "likely", "b": [0.4305, 0.2015, 0.4754, 0.2229]}, {"w": "to", "b": [0.4801, 0.2015, 0.4971, 0.2229]}, {"w": "be", "b": [0.5018, 0.2015, 0.5213, 0.2229]}, {"w": "fraudulent", "b": [0.526, 0.2015, 0.6132, 0.2229]}]}, {"id": "b_4", "type": "paragraph", "text": "• Forecast next year’s revenue", "words": [{"w": "•", "b": [0.16, 0.2266, 0.1682, 0.248]}, {"w": "Forecast", "b": [0.1786, 0.2266, 0.2484, 0.248]}, {"w": "next", "b": [0.2531, 0.2266, 0.2895, 0.248]}, {"w": "year’s", "b": [0.2943, 0.2266, 0.3399, 0.248]}, {"w": "revenue", "b": [0.3446, 0.2266, 0.4106, 0.248]}]}, {"id": "b_5", "type": "paragraph", "text": "• And more", "words": [{"w": "•", "b": [0.16, 0.2517, 0.1682, 0.2731]}, {"w": "And", "b": [0.1786, 0.2517, 0.2154, 0.2731]}, {"w": "more", "b": [0.2201, 0.2517, 0.2644, 0.2731]}]}, {"id": "b_6", "type": "paragraph", "text": "Whatever the reason, you have decided to learn Machine Learning and implement it in your projects. Great idea!", "words": [{"w": "Whatever", "b": [0.1429, 0.2859, 0.2244, 0.3073]}, {"w": "the", "b": [0.2302, 0.2859, 0.2566, 0.3073]}, {"w": "reason,", "b": [0.2624, 0.2859, 0.3225, 0.3073]}, {"w": "you", "b": [0.3284, 0.2859, 0.3596, 0.3073]}, {"w": "have", "b": [0.3654, 0.2859, 0.4038, 0.3073]}, {"w": "decided", "b": [0.4097, 0.2859, 0.4748, 0.3073]}, {"w": "to", "b": [0.4806, 0.2859, 0.4976, 0.3073]}, {"w": "learn", "b": [0.5034, 0.2859, 0.5458, 0.3073]}, {"w": "Machine", "b": [0.5516, 0.2859, 0.6247, 0.3073]}, {"w": "Learning", "b": [0.6306, 0.2859, 0.7056, 0.3073]}, {"w": "and", "b": [0.7114, 0.2859, 0.743, 0.3073]}, {"w": "implement", "b": [0.7488, 0.2859, 0.8394, 0.3073]}, {"w": "it", "b": [0.8452, 0.2859, 0.8571, 0.3073]}, {"w": "in", "b": [0.1429, 0.3049, 0.1598, 0.3263]}, {"w": "your", "b": [0.1646, 0.3049, 0.2035, 0.3263]}, {"w": "projects.", "b": [0.2083, 0.3049, 0.2793, 0.3263]}, {"w": "Great", "b": [0.284, 0.3049, 0.3306, 0.3263]}, {"w": "idea!", "b": [0.3353, 0.3049, 0.3757, 0.3263]}]}, {"id": "b_7", "type": "paragraph", "text": "Objective and Approach", "words": [{"w": "Objective", "b": [0.1428, 0.3393, 0.2579, 0.3736]}, {"w": "and", "b": [0.2638, 0.3393, 0.3109, 0.3736]}, {"w": "Approach", "b": [0.3168, 0.3393, 0.4341, 0.3736]}]}, {"id": "b_8", "type": "paragraph", "text": "This book assumes that you know close to nothing about Machine Learning. Its goal is to give you the concepts, the intuitions, and the tools you need to actually imple‐ ment programs capable of learning from data.", "words": [{"w": "This", "b": [0.1429, 0.3805, 0.1801, 0.4019]}, {"w": "book", "b": [0.1859, 0.3805, 0.228, 0.4019]}, {"w": "assumes", "b": [0.2338, 0.3805, 0.3029, 0.4019]}, {"w": "that", "b": [0.3087, 0.3805, 0.3412, 0.4019]}, {"w": "you", "b": [0.347, 0.3805, 0.3783, 0.4019]}, {"w": "know", "b": [0.384, 0.3805, 0.4307, 0.4019]}, {"w": "close", "b": [0.4365, 0.3805, 0.4777, 0.4019]}, {"w": "to", "b": [0.4834, 0.3805, 0.5004, 0.4019]}, {"w": "nothing", "b": [0.5062, 0.3805, 0.5724, 0.4019]}, {"w": "about", "b": [0.5782, 0.3805, 0.626, 0.4019]}, {"w": "Machine", "b": [0.6318, 0.3805, 0.7049, 0.4019]}, {"w": "Learning.", "b": [0.7107, 0.3805, 0.7905, 0.4019]}, {"w": "Its", "b": [0.7963, 0.3805, 0.8166, 0.4019]}, {"w": "goal", "b": [0.8224, 0.3805, 0.8571, 0.4019]}, {"w": "is", "b": [0.1429, 0.3995, 0.1561, 0.421]}, {"w": "to", "b": [0.1625, 0.3995, 0.1795, 0.421]}, {"w": "give", "b": [0.1859, 0.3995, 0.2197, 0.421]}, {"w": "you", "b": [0.2261, 0.3995, 0.2574, 0.421]}, {"w": "the", "b": [0.2638, 0.3995, 0.2901, 0.421]}, {"w": "concepts,", "b": [0.2965, 0.3995, 0.3747, 0.421]}, {"w": "the", "b": [0.3811, 0.3995, 0.4074, 0.421]}, {"w": "intuitions,", "b": [0.4139, 0.3995, 0.4998, 0.421]}, {"w": "and", "b": [0.5062, 0.3995, 0.5377, 0.421]}, {"w": "the", "b": [0.5442, 0.3995, 0.5705, 0.421]}, {"w": "tools", "b": [0.5769, 0.3995, 0.6174, 0.421]}, {"w": "you", "b": [0.6238, 0.3995, 0.6551, 0.421]}, {"w": "need", "b": [0.6615, 0.3995, 0.7016, 0.421]}, {"w": "to", "b": [0.708, 0.3995, 0.725, 0.421]}, {"w": "actually", "b": [0.7314, 0.3995, 0.796, 0.421]}, {"w": "imple‐", "b": [0.8024, 0.3995, 0.8571, 0.421]}, {"w": "ment", "b": [0.1429, 0.4186, 0.1861, 0.44]}, {"w": "programs", "b": [0.1909, 0.4186, 0.2715, 0.44]}, {"w": "capable", "b": [0.2762, 0.4186, 0.3385, 0.44]}, {"w": "of", "b": [0.3432, 0.4186, 0.36, 0.44]}, {"w": "learning", "b": [0.3648, 0.4184, 0.4315, 0.44]}, {"w": "from", "b": [0.4362, 0.4184, 0.4753, 0.44]}, {"w": "data.", "b": [0.48, 0.4184, 0.5214, 0.44]}]}, {"id": "b_9", "type": "paragraph", "text": "We will cover a large number of techniques, from the simplest and most commonly used (such as linear regression) to some of the Deep Learning techniques that regu‐ larly win competitions.", "words": [{"w": "We", "b": [0.1429, 0.4467, 0.1699, 0.4681]}, {"w": "will", "b": [0.1763, 0.4467, 0.2067, 0.4681]}, {"w": "cover", "b": [0.213, 0.4467, 0.2587, 0.4681]}, {"w": "a", "b": [0.265, 0.4467, 0.2742, 0.4681]}, {"w": "large", "b": [0.2805, 0.4467, 0.3213, 0.4681]}, {"w": "number", "b": [0.3276, 0.4467, 0.3939, 0.4681]}, {"w": "of", "b": [0.4003, 0.4467, 0.4171, 0.4681]}, {"w": "techniques,", "b": [0.4234, 0.4467, 0.5185, 0.4681]}, {"w": "from", "b": [0.5249, 0.4467, 0.5665, 0.4681]}, {"w": "the", "b": [0.5728, 0.4467, 0.5991, 0.4681]}, {"w": "simplest", "b": [0.6055, 0.4467, 0.6744, 0.4681]}, {"w": "and", "b": [0.6808, 0.4467, 0.7123, 0.4681]}, {"w": "most", "b": [0.7187, 0.4467, 0.7604, 0.4681]}, {"w": "commonly", "b": [0.7667, 0.4467, 0.8571, 0.4681]}, {"w": "used", "b": [0.1429, 0.4658, 0.1814, 0.4872]}, {"w": "(such", "b": [0.1877, 0.4658, 0.2335, 0.4872]}, {"w": "as", "b": [0.2398, 0.4658, 0.2565, 0.4872]}, {"w": "linear", "b": [0.2628, 0.4658, 0.3108, 0.4872]}, {"w": "regression)", "b": [0.317, 0.4658, 0.41, 0.4872]}, {"w": "to", "b": [0.4163, 0.4658, 0.4332, 0.4872]}, {"w": "some", "b": [0.4395, 0.4658, 0.4837, 0.4872]}, {"w": "of", "b": [0.4899, 0.4658, 0.5067, 0.4872]}, {"w": "the", "b": [0.5129, 0.4658, 0.5392, 0.4872]}, {"w": "Deep", "b": [0.5455, 0.4658, 0.5894, 0.4872]}, {"w": "Learning", "b": [0.5957, 0.4658, 0.6707, 0.4872]}, {"w": "techniques", "b": [0.677, 0.4658, 0.7673, 0.4872]}, {"w": "that", "b": [0.7735, 0.4658, 0.8061, 0.4872]}, {"w": "regu‐", "b": [0.8123, 0.4658, 0.8572, 0.4872]}, {"w": "larly", "b": [0.1429, 0.4848, 0.1798, 0.5062]}, {"w": "win", "b": [0.1846, 0.4848, 0.2158, 0.5062]}, {"w": "competitions.", "b": [0.2205, 0.4848, 0.3347, 0.5062]}]}, {"id": "b_10", "type": "paragraph", "text": "Rather than implementing our own toy versions of each algorithm, we will be using actual production-ready Python frameworks:", "words": [{"w": "Rather", "b": [0.1429, 0.5129, 0.199, 0.5343]}, {"w": "than", "b": [0.2052, 0.5129, 0.2432, 0.5343]}, {"w": "implementing", "b": [0.2495, 0.5129, 0.3668, 0.5343]}, {"w": "our", "b": [0.373, 0.5129, 0.4024, 0.5343]}, {"w": "own", "b": [0.4086, 0.5129, 0.4449, 0.5343]}, {"w": "toy", "b": [0.4511, 0.5129, 0.4777, 0.5343]}, {"w": "versions", "b": [0.4839, 0.5129, 0.553, 0.5343]}, {"w": "of", "b": [0.5593, 0.5129, 0.5761, 0.5343]}, {"w": "each", "b": [0.5823, 0.5129, 0.6202, 0.5343]}, {"w": "algorithm,", "b": [0.6264, 0.5129, 0.7138, 0.5343]}, {"w": "we", "b": [0.7201, 0.5129, 0.7432, 0.5343]}, {"w": "will", "b": [0.7494, 0.5129, 0.7798, 0.5343]}, {"w": "be", "b": [0.786, 0.5129, 0.8055, 0.5343]}, {"w": "using", "b": [0.8117, 0.5129, 0.8571, 0.5343]}, {"w": "actual", "b": [0.1429, 0.532, 0.1926, 0.5534]}, {"w": "production-ready", "b": [0.1974, 0.532, 0.3452, 0.5534]}, {"w": "Python", "b": [0.3499, 0.532, 0.4107, 0.5534]}, {"w": "frameworks:", "b": [0.4154, 0.532, 0.5198, 0.5534]}]}, {"id": "b_11", "type": "paragraph", "text": "• Scikit-Learn is very easy to use, yet it implements many Machine Learning algo‐ rithms efficiently, so it makes for a great entry point to learn Machine Learning.", "words": [{"w": "•", "b": [0.16, 0.5661, 0.1682, 0.5875]}, {"w": "Scikit-Learn", "b": [0.1786, 0.5661, 0.2809, 0.5875]}, {"w": "is", "b": [0.2867, 0.5661, 0.2999, 0.5875]}, {"w": "very", "b": [0.3058, 0.5661, 0.3422, 0.5875]}, {"w": "easy", "b": [0.348, 0.5661, 0.3832, 0.5875]}, {"w": "to", "b": [0.3891, 0.5661, 0.4061, 0.5875]}, {"w": "use,", "b": [0.4119, 0.5661, 0.4442, 0.5875]}, {"w": "yet", "b": [0.4501, 0.5661, 0.4748, 0.5875]}, {"w": "it", "b": [0.4807, 0.5661, 0.4926, 0.5875]}, {"w": "implements", "b": [0.4985, 0.5661, 0.5967, 0.5875]}, {"w": "many", "b": [0.6025, 0.5661, 0.6492, 0.5875]}, {"w": "Machine", "b": [0.655, 0.5661, 0.7282, 0.5875]}, {"w": "Learning", "b": [0.734, 0.5661, 0.8091, 0.5875]}, {"w": "algo‐", "b": [0.8149, 0.5661, 0.8571, 0.5875]}, {"w": "rithms", "b": [0.1786, 0.5852, 0.2341, 0.6066]}, {"w": "efficiently,", "b": [0.2388, 0.5852, 0.3242, 0.6066]}, {"w": "so", "b": [0.329, 0.5852, 0.3472, 0.6066]}, {"w": "it", "b": [0.352, 0.5852, 0.3639, 0.6066]}, {"w": "makes", "b": [0.3686, 0.5852, 0.4217, 0.6066]}, {"w": "for", "b": [0.4264, 0.5852, 0.4509, 0.6066]}, {"w": "a", "b": [0.4557, 0.5852, 0.4648, 0.6066]}, {"w": "great", "b": [0.4695, 0.5852, 0.511, 0.6066]}, {"w": "entry", "b": [0.5157, 0.5852, 0.5598, 0.6066]}, {"w": "point", "b": [0.5645, 0.5852, 0.609, 0.6066]}, {"w": "to", "b": [0.6137, 0.5852, 0.6307, 0.6066]}, {"w": "learn", "b": [0.6354, 0.5852, 0.6778, 0.6066]}, {"w": "Machine", "b": [0.6826, 0.5852, 0.7557, 0.6066]}, {"w": "Learning.", "b": [0.7604, 0.5852, 0.8402, 0.6066]}]}, {"id": "b_12", "type": "paragraph", "text": "• TensorFlow is a more complex library for distributed numerical computation. It makes it possible to train and run very large neural networks efficiently by dis‐ tributing the computations across potentially hundreds of multi-GPU servers. TensorFlow was created at Google and supports many of their large-scale Machine Learning applications. It was open sourced in November 2015.", "words": [{"w": "•", "b": [0.16, 0.6103, 0.1682, 0.6317]}, {"w": "TensorFlow", "b": [0.1786, 0.6103, 0.2768, 0.6317]}, {"w": "is", "b": [0.2829, 0.6103, 0.2962, 0.6317]}, {"w": "a", "b": [0.3023, 0.6103, 0.3114, 0.6317]}, {"w": "more", "b": [0.3175, 0.6103, 0.3618, 0.6317]}, {"w": "complex", "b": [0.3679, 0.6103, 0.4389, 0.6317]}, {"w": "library", "b": [0.445, 0.6103, 0.5012, 0.6317]}, {"w": "for", "b": [0.5073, 0.6103, 0.5319, 0.6317]}, {"w": "distributed", "b": [0.538, 0.6103, 0.6297, 0.6317]}, {"w": "numerical", "b": [0.6358, 0.6103, 0.7204, 0.6317]}, {"w": "computation.", "b": [0.7265, 0.6103, 0.8384, 0.6317]}, {"w": "It", "b": [0.8445, 0.6103, 0.8571, 0.6317]}, {"w": "makes", "b": [0.1786, 0.6293, 0.2316, 0.6507]}, {"w": "it", "b": [0.2382, 0.6293, 0.2501, 0.6507]}, {"w": "possible", "b": [0.2567, 0.6293, 0.3239, 0.6507]}, {"w": "to", "b": [0.3305, 0.6293, 0.3474, 0.6507]}, {"w": "train", "b": [0.354, 0.6293, 0.3942, 0.6507]}, {"w": "and", "b": [0.4008, 0.6293, 0.4324, 0.6507]}, {"w": "run", "b": [0.439, 0.6293, 0.4692, 0.6507]}, {"w": "very", "b": [0.4758, 0.6293, 0.5122, 0.6507]}, {"w": "large", "b": [0.5188, 0.6293, 0.5595, 0.6507]}, {"w": "neural", "b": [0.5661, 0.6293, 0.6196, 0.6507]}, {"w": "networks", "b": [0.6262, 0.6293, 0.7034, 0.6507]}, {"w": "efficiently", "b": [0.71, 0.6293, 0.7922, 0.6507]}, {"w": "by", "b": [0.7988, 0.6293, 0.8189, 0.6507]}, {"w": "dis‐", "b": [0.8255, 0.6293, 0.8571, 0.6507]}, {"w": "tributing", "b": [0.1786, 0.6484, 0.253, 0.6698]}, {"w": "the", "b": [0.2615, 0.6484, 0.2879, 0.6698]}, {"w": "computations", "b": [0.2964, 0.6484, 0.4112, 0.6698]}, {"w": "across", "b": [0.4198, 0.6484, 0.4714, 0.6698]}, {"w": "potentially", "b": [0.48, 0.6484, 0.5689, 0.6698]}, {"w": "hundreds", "b": [0.5775, 0.6484, 0.6569, 0.6698]}, {"w": "of", "b": [0.6654, 0.6484, 0.6822, 0.6698]}, {"w": "multi-GPU", "b": [0.6908, 0.6484, 0.7851, 0.6698]}, {"w": "servers.", "b": [0.7937, 0.6484, 0.8571, 0.6698]}, {"w": "TensorFlow", "b": [0.1786, 0.6674, 0.2768, 0.6888]}, {"w": "was", "b": [0.2887, 0.6674, 0.3197, 0.6888]}, {"w": "created", "b": [0.3315, 0.6674, 0.3919, 0.6888]}, {"w": "at", "b": [0.4037, 0.6674, 0.4188, 0.6888]}, {"w": "Google", "b": [0.4307, 0.6674, 0.4907, 0.6888]}, {"w": "and", "b": [0.5025, 0.6674, 0.5341, 0.6888]}, {"w": "supports", "b": [0.5459, 0.6674, 0.6188, 0.6888]}, {"w": "many", "b": [0.6306, 0.6674, 0.6773, 0.6888]}, {"w": "of", "b": [0.6891, 0.6674, 0.7059, 0.6888]}, {"w": "their", "b": [0.7178, 0.6674, 0.7574, 0.6888]}, {"w": "large-scale", "b": [0.7692, 0.6674, 0.8571, 0.6888]}, {"w": "Machine", "b": [0.1786, 0.6865, 0.2517, 0.7079]}, {"w": "Learning", "b": [0.2564, 0.6865, 0.3315, 0.7079]}, {"w": "applications.", "b": [0.3362, 0.6865, 0.4416, 0.7079]}, {"w": "It", "b": [0.4463, 0.6865, 0.459, 0.7079]}, {"w": "was", "b": [0.4637, 0.6865, 0.4947, 0.7079]}, {"w": "open", "b": [0.4995, 0.6865, 0.5413, 0.7079]}, {"w": "sourced", "b": [0.546, 0.6865, 0.6117, 0.7079]}, {"w": "in", "b": [0.6165, 0.6865, 0.6334, 0.7079]}, {"w": "November", "b": [0.6382, 0.6865, 0.7265, 0.7079]}, {"w": "2015.", "b": [0.7312, 0.6865, 0.776, 0.7079]}]}, {"id": "b_13", "type": "paragraph", "text": "• Keras is a high level Deep Learning API that makes it very simple to train and run neural networks. It can run on top of either TensorFlow, Theano or Micro‐ soft Cognitive Toolkit (formerly known as CNTK). TensorFlow comes with its own implementation of this API, called tf.keras, which provides support for some advanced TensorFlow features (e.g., to efficiently load data).", "words": [{"w": "•", "b": [0.16, 0.7116, 0.1681, 0.733]}, {"w": "Keras", "b": [0.1786, 0.7116, 0.2255, 0.733]}, {"w": "is", "b": [0.2324, 0.7116, 0.2456, 0.733]}, {"w": "a", "b": [0.2526, 0.7116, 0.2617, 0.733]}, {"w": "high", "b": [0.2686, 0.7116, 0.3062, 0.733]}, {"w": "level", "b": [0.3131, 0.7116, 0.351, 0.733]}, {"w": "Deep", "b": [0.358, 0.7116, 0.4019, 0.733]}, {"w": "Learning", "b": [0.4088, 0.7116, 0.4839, 0.733]}, {"w": "API", "b": [0.4908, 0.7116, 0.5241, 0.733]}, {"w": "that", "b": [0.531, 0.7116, 0.5636, 0.733]}, {"w": "makes", "b": [0.5705, 0.7116, 0.6235, 0.733]}, {"w": "it", "b": [0.6305, 0.7116, 0.6424, 0.733]}, {"w": "very", "b": [0.6493, 0.7116, 0.6857, 0.733]}, {"w": "simple", "b": [0.6927, 0.7116, 0.7476, 0.733]}, {"w": "to", "b": [0.7545, 0.7116, 0.7715, 0.733]}, {"w": "train", "b": [0.7785, 0.7116, 0.8187, 0.733]}, {"w": "and", "b": [0.8256, 0.7116, 0.8571, 0.733]}, {"w": "run", "b": [0.1786, 0.7306, 0.2088, 0.752]}, {"w": "neural", "b": [0.2151, 0.7306, 0.2686, 0.752]}, {"w": "networks.", "b": [0.275, 0.7306, 0.3569, 0.752]}, {"w": "It", "b": [0.3633, 0.7306, 0.376, 0.752]}, {"w": "can", "b": [0.3824, 0.7306, 0.4117, 0.752]}, {"w": "run", "b": [0.4181, 0.7306, 0.4483, 0.752]}, {"w": "on", "b": [0.4547, 0.7306, 0.4767, 0.752]}, {"w": "top", "b": [0.4831, 0.7306, 0.511, 0.752]}, {"w": "of", "b": [0.5174, 0.7306, 0.5342, 0.752]}, {"w": "either", "b": [0.5405, 0.7306, 0.589, 0.752]}, {"w": "TensorFlow,", "b": [0.5954, 0.7306, 0.6969, 0.752]}, {"w": "Theano", "b": [0.7033, 0.7306, 0.7673, 0.752]}, {"w": "or", "b": [0.7737, 0.7306, 0.792, 0.752]}, {"w": "Micro‐", "b": [0.7984, 0.7306, 0.8571, 0.752]}, {"w": "soft", "b": [0.1786, 0.7497, 0.2094, 0.7711]}, {"w": "Cognitive", "b": [0.2169, 0.7497, 0.2985, 0.7711]}, {"w": "Toolkit", "b": [0.306, 0.7497, 0.3656, 0.7711]}, {"w": "(formerly", "b": [0.3732, 0.7497, 0.4534, 0.7711]}, {"w": "known", "b": [0.4609, 0.7497, 0.5189, 0.7711]}, {"w": "as", "b": [0.5264, 0.7497, 0.5432, 0.7711]}, {"w": "CNTK).", "b": [0.5507, 0.7497, 0.6189, 0.7711]}, {"w": "TensorFlow", "b": [0.6264, 0.7497, 0.7247, 0.7711]}, {"w": "comes", "b": [0.7322, 0.7497, 0.7852, 0.7711]}, {"w": "with", "b": [0.7927, 0.7497, 0.83, 0.7711]}, {"w": "its", "b": [0.8376, 0.7497, 0.8571, 0.7711]}, {"w": "own", "b": [0.1786, 0.7687, 0.2149, 0.7901]}, {"w": "implementation", "b": [0.2198, 0.7687, 0.3531, 0.7901]}, {"w": "of", "b": [0.3581, 0.7687, 0.3749, 0.7901]}, {"w": "this", "b": [0.3798, 0.7687, 0.4105, 0.7901]}, {"w": "API,", "b": [0.4155, 0.7687, 0.4535, 0.7901]}, {"w": "called", "b": [0.4584, 0.7687, 0.5068, 0.7901]}, {"w": "tf.keras,", "b": [0.5118, 0.7685, 0.5754, 0.7901]}, {"w": "which", "b": [0.5804, 0.7687, 0.6313, 0.7901]}, {"w": "provides", "b": [0.6363, 0.7687, 0.7083, 0.7901]}, {"w": "support", "b": [0.7133, 0.7687, 0.7785, 0.7901]}, {"w": "for", "b": [0.7835, 0.7687, 0.808, 0.7901]}, {"w": "some", "b": [0.813, 0.7687, 0.8571, 0.7901]}, {"w": "advanced", "b": [0.1786, 0.7878, 0.2576, 0.8092]}, {"w": "TensorFlow", "b": [0.2623, 0.7878, 0.3606, 0.8092]}, {"w": "features", "b": [0.3653, 0.7878, 0.4307, 0.8092]}, {"w": "(e.g.,", "b": [0.4354, 0.7878, 0.4755, 0.8092]}, {"w": "to", "b": [0.4802, 0.7878, 0.4972, 0.8092]}, {"w": "efficiently", "b": [0.5019, 0.7878, 0.5841, 0.8092]}, {"w": "load", "b": [0.5889, 0.7878, 0.6249, 0.8092]}, {"w": "data).", "b": [0.6296, 0.7878, 0.6769, 0.8092]}]}, {"id": "b_14", "type": "paragraph", "text": "The book favors a hands-on approach, growing an intuitive understanding of Machine Learning through concrete working examples and just a little bit of theory. While you can read this book without picking up your laptop, we highly recommend", "words": [{"w": "The", "b": [0.1429, 0.8219, 0.1757, 0.8433]}, {"w": "book", "b": [0.1875, 0.8219, 0.2297, 0.8433]}, {"w": "favors", "b": [0.2415, 0.8219, 0.2921, 0.8433]}, {"w": "a", "b": [0.3039, 0.8219, 0.3131, 0.8433]}, {"w": "hands-on", "b": [0.3249, 0.8219, 0.4046, 0.8433]}, {"w": "approach,", "b": [0.4165, 0.8219, 0.4992, 0.8433]}, {"w": "growing", "b": [0.5111, 0.8219, 0.5802, 0.8433]}, {"w": "an", "b": [0.592, 0.8219, 0.6125, 0.8433]}, {"w": "intuitive", "b": [0.6244, 0.8219, 0.6944, 0.8433]}, {"w": "understanding", "b": [0.7062, 0.8219, 0.8285, 0.8433]}, {"w": "of", "b": [0.8403, 0.8219, 0.8571, 0.8433]}, {"w": "Machine", "b": [0.1429, 0.841, 0.216, 0.8624]}, {"w": "Learning", "b": [0.2221, 0.841, 0.2972, 0.8624]}, {"w": "through", "b": [0.3034, 0.841, 0.3711, 0.8624]}, {"w": "concrete", "b": [0.3773, 0.841, 0.4487, 0.8624]}, {"w": "working", "b": [0.4549, 0.841, 0.5246, 0.8624]}, {"w": "examples", "b": [0.5307, 0.841, 0.6079, 0.8624]}, {"w": "and", "b": [0.6141, 0.841, 0.6456, 0.8624]}, {"w": "just", "b": [0.6518, 0.841, 0.6822, 0.8624]}, {"w": "a", "b": [0.6883, 0.841, 0.6975, 0.8624]}, {"w": "little", "b": [0.7036, 0.841, 0.7413, 0.8624]}, {"w": "bit", "b": [0.7474, 0.841, 0.77, 0.8624]}, {"w": "of", "b": [0.7761, 0.841, 0.7929, 0.8624]}, {"w": "theory.", "b": [0.7991, 0.841, 0.8572, 0.8624]}, {"w": "While", "b": [0.1429, 0.86, 0.1939, 0.8814]}, {"w": "you", "b": [0.1993, 0.86, 0.2306, 0.8814]}, {"w": "can", "b": [0.236, 0.86, 0.2654, 0.8814]}, {"w": "read", "b": [0.2708, 0.86, 0.3075, 0.8814]}, {"w": "this", "b": [0.3129, 0.86, 0.3436, 0.8814]}, {"w": "book", "b": [0.349, 0.86, 0.3912, 0.8814]}, {"w": "without", "b": [0.3966, 0.86, 0.462, 0.8814]}, {"w": "picking", "b": [0.4674, 0.86, 0.5298, 0.8814]}, {"w": "up", "b": [0.5352, 0.86, 0.5572, 0.8814]}, {"w": "your", "b": [0.5626, 0.86, 0.6016, 0.8814]}, {"w": "laptop,", "b": [0.607, 0.86, 0.664, 0.8814]}, {"w": "we", "b": [0.6694, 0.86, 0.6925, 0.8814]}, {"w": "highly", "b": [0.6979, 0.86, 0.7503, 0.8814]}, {"w": "recommend", "b": [0.7558, 0.86, 0.8571, 0.8814]}]}, {"id": "b_15", "type": "paragraph", "text": "xii | Preface", "words": [{"w": "xii", "b": [0.1429, 0.9225, 0.1568, 0.9388]}, {"w": "|", "b": [0.1746, 0.9225, 0.1784, 0.9388]}, {"w": "Preface", "b": [0.1963, 0.9225, 0.2402, 0.9388]}]}]}, {"page": 15, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "you experiment with the code examples available online as Jupyter notebooks at https://github.com/ageron/handson-ml2.", "words": [{"w": "you", "b": [0.1429, 0.0791, 0.1741, 0.1005]}, {"w": "experiment", "b": [0.1835, 0.0791, 0.2785, 0.1005]}, {"w": "with", "b": [0.2878, 0.0791, 0.3252, 0.1005]}, {"w": "the", "b": [0.3345, 0.0791, 0.3609, 0.1005]}, {"w": "code", "b": [0.3702, 0.0791, 0.4095, 0.1005]}, {"w": "examples", "b": [0.4189, 0.0791, 0.496, 0.1005]}, {"w": "available", "b": [0.5054, 0.0791, 0.5777, 0.1005]}, {"w": "online", "b": [0.587, 0.0791, 0.6401, 0.1005]}, {"w": "as", "b": [0.6495, 0.0791, 0.6663, 0.1005]}, {"w": "Jupyter", "b": [0.6756, 0.0791, 0.7363, 0.1005]}, {"w": "notebooks", "b": [0.7456, 0.0791, 0.8327, 0.1005]}, {"w": "at", "b": [0.842, 0.0791, 0.8571, 0.1005]}, {"w": "https://github.com/ageron/handson-ml2.", "b": [0.1429, 0.0979, 0.4718, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "Prerequisites", "words": [{"w": "Prerequisites", "b": [0.1429, 0.1325, 0.3052, 0.1668]}]}, {"id": "b_2", "type": "paragraph", "text": "This book assumes that you have some Python programming experience and that you are familiar with Python’s main scientific libraries, in particular NumPy, Pandas, and Matplotlib.", "words": [{"w": "This", "b": [0.1429, 0.1737, 0.1801, 0.1951]}, {"w": "book", "b": [0.1848, 0.1737, 0.227, 0.1951]}, {"w": "assumes", "b": [0.2317, 0.1737, 0.3008, 0.1951]}, {"w": "that", "b": [0.3055, 0.1737, 0.3381, 0.1951]}, {"w": "you", "b": [0.3428, 0.1737, 0.374, 0.1951]}, {"w": "have", "b": [0.3788, 0.1737, 0.4172, 0.1951]}, {"w": "some", "b": [0.4219, 0.1737, 0.4661, 0.1951]}, {"w": "Python", "b": [0.4708, 0.1737, 0.5316, 0.1951]}, {"w": "programming", "b": [0.5363, 0.1737, 0.6531, 0.1951]}, {"w": "experience", "b": [0.6578, 0.1737, 0.7475, 0.1951]}, {"w": "and", "b": [0.7522, 0.1737, 0.7838, 0.1951]}, {"w": "that", "b": [0.7885, 0.1737, 0.8211, 0.1951]}, {"w": "you", "b": [0.8258, 0.1737, 0.8571, 0.1951]}, {"w": "are", "b": [0.1429, 0.1927, 0.1686, 0.2142]}, {"w": "familiar", "b": [0.1742, 0.1927, 0.2399, 0.2142]}, {"w": "with", "b": [0.2456, 0.1927, 0.2829, 0.2142]}, {"w": "Python’s", "b": [0.2886, 0.1927, 0.3579, 0.2142]}, {"w": "main", "b": [0.3636, 0.1927, 0.4068, 0.2142]}, {"w": "scientific", "b": [0.4124, 0.1927, 0.4868, 0.2142]}, {"w": "libraries,", "b": [0.4925, 0.1927, 0.5654, 0.2142]}, {"w": "in", "b": [0.571, 0.1927, 0.588, 0.2142]}, {"w": "particular", "b": [0.5936, 0.1927, 0.6754, 0.2142]}, {"w": "NumPy,", "b": [0.681, 0.1927, 0.7499, 0.2142]}, {"w": "Pandas,", "b": [0.7556, 0.1927, 0.82, 0.2142]}, {"w": "and", "b": [0.8256, 0.1927, 0.8571, 0.2142]}, {"w": "Matplotlib.", "b": [0.1428, 0.2118, 0.2355, 0.2332]}]}, {"id": "b_3", "type": "paragraph", "text": "Also, if you care about what’s under the hood you should have a reasonable under‐ standing of college-level math as well (calculus, linear algebra, probabilities, and sta‐ tistics).", "words": [{"w": "Also,", "b": [0.1428, 0.2399, 0.1849, 0.2613]}, {"w": "if", "b": [0.1917, 0.2399, 0.2034, 0.2613]}, {"w": "you", "b": [0.2102, 0.2399, 0.2415, 0.2613]}, {"w": "care", "b": [0.2482, 0.2399, 0.2828, 0.2613]}, {"w": "about", "b": [0.2895, 0.2399, 0.3373, 0.2613]}, {"w": "what’s", "b": [0.3441, 0.2399, 0.3943, 0.2613]}, {"w": "under", "b": [0.4011, 0.2399, 0.4511, 0.2613]}, {"w": "the", "b": [0.4579, 0.2399, 0.4842, 0.2613]}, {"w": "hood", "b": [0.491, 0.2399, 0.5343, 0.2613]}, {"w": "you", "b": [0.5411, 0.2399, 0.5723, 0.2613]}, {"w": "should", "b": [0.5791, 0.2399, 0.6358, 0.2613]}, {"w": "have", "b": [0.6426, 0.2399, 0.681, 0.2613]}, {"w": "a", "b": [0.6878, 0.2399, 0.6969, 0.2613]}, {"w": "reasonable", "b": [0.7037, 0.2399, 0.7929, 0.2613]}, {"w": "under‐", "b": [0.7997, 0.2399, 0.8571, 0.2613]}, {"w": "standing", "b": [0.1429, 0.259, 0.2151, 0.2804]}, {"w": "of", "b": [0.2211, 0.259, 0.2378, 0.2804]}, {"w": "college-level", "b": [0.2438, 0.259, 0.3465, 0.2804]}, {"w": "math", "b": [0.3524, 0.259, 0.3957, 0.2804]}, {"w": "as", "b": [0.4017, 0.259, 0.4185, 0.2804]}, {"w": "well", "b": [0.4244, 0.259, 0.458, 0.2804]}, {"w": "(calculus,", "b": [0.464, 0.259, 0.543, 0.2804]}, {"w": "linear", "b": [0.5489, 0.259, 0.5969, 0.2804]}, {"w": "algebra,", "b": [0.6028, 0.259, 0.6681, 0.2804]}, {"w": "probabilities,", "b": [0.674, 0.259, 0.7832, 0.2804]}, {"w": "and", "b": [0.7891, 0.259, 0.8207, 0.2804]}, {"w": "sta‐", "b": [0.8266, 0.259, 0.8571, 0.2804]}, {"w": "tistics).", "b": [0.1429, 0.278, 0.2028, 0.2994]}]}, {"id": "b_4", "type": "paragraph", "text": "If you don’t know Python yet, http://learnpython.org/ is a great place to start. The offi‐ cial tutorial on python.org is also quite good.", "words": [{"w": "If", "b": [0.1429, 0.3061, 0.1561, 0.3275]}, {"w": "you", "b": [0.1611, 0.3061, 0.1923, 0.3275]}, {"w": "don’t", "b": [0.1973, 0.3061, 0.2389, 0.3275]}, {"w": "know", "b": [0.2438, 0.3061, 0.2905, 0.3275]}, {"w": "Python", "b": [0.2954, 0.3061, 0.3562, 0.3275]}, {"w": "yet,", "b": [0.3612, 0.3061, 0.3907, 0.3275]}, {"w": "http://learnpython.org/", "b": [0.3956, 0.3059, 0.583, 0.3275]}, {"w": "is", "b": [0.5879, 0.3061, 0.6012, 0.3275]}, {"w": "a", "b": [0.6061, 0.3061, 0.6153, 0.3275]}, {"w": "great", "b": [0.6202, 0.3061, 0.6616, 0.3275]}, {"w": "place", "b": [0.6666, 0.3061, 0.7096, 0.3275]}, {"w": "to", "b": [0.7145, 0.3061, 0.7315, 0.3275]}, {"w": "start.", "b": [0.7365, 0.3061, 0.7785, 0.3275]}, {"w": "The", "b": [0.7834, 0.3061, 0.8162, 0.3275]}, {"w": "offi‐", "b": [0.8212, 0.3061, 0.8571, 0.3275]}, {"w": "cial", "b": [0.1429, 0.3252, 0.1717, 0.3466]}, {"w": "tutorial", "b": [0.1764, 0.3252, 0.2385, 0.3466]}, {"w": "on", "b": [0.2433, 0.3252, 0.2653, 0.3466]}, {"w": "python.org", "b": [0.27, 0.3252, 0.3628, 0.3466]}, {"w": "is", "b": [0.3676, 0.3252, 0.3808, 0.3466]}, {"w": "also", "b": [0.3855, 0.3252, 0.4182, 0.3466]}, {"w": "quite", "b": [0.4229, 0.3252, 0.4654, 0.3466]}, {"w": "good.", "b": [0.4702, 0.3252, 0.5169, 0.3466]}]}, {"id": "b_5", "type": "paragraph", "text": "If you have never used Jupyter, Chapter 2 will guide you through installation and the basics: it is a great tool to have in your toolbox.", "words": [{"w": "If", "b": [0.1429, 0.3533, 0.1561, 0.3747]}, {"w": "you", "b": [0.1617, 0.3533, 0.1929, 0.3747]}, {"w": "have", "b": [0.1985, 0.3533, 0.2369, 0.3747]}, {"w": "never", "b": [0.2424, 0.3533, 0.2889, 0.3747]}, {"w": "used", "b": [0.2945, 0.3533, 0.333, 0.3747]}, {"w": "Jupyter,", "b": [0.3386, 0.3533, 0.4027, 0.3747]}, {"w": "Chapter", "b": [0.4082, 0.3533, 0.4758, 0.3747]}, {"w": "2", "b": [0.4814, 0.3533, 0.4914, 0.3747]}, {"w": "will", "b": [0.4969, 0.3533, 0.5273, 0.3747]}, {"w": "guide", "b": [0.5329, 0.3533, 0.5791, 0.3747]}, {"w": "you", "b": [0.5847, 0.3533, 0.6159, 0.3747]}, {"w": "through", "b": [0.6215, 0.3533, 0.6892, 0.3747]}, {"w": "installation", "b": [0.6948, 0.3533, 0.7882, 0.3747]}, {"w": "and", "b": [0.7937, 0.3533, 0.8253, 0.3747]}, {"w": "the", "b": [0.8308, 0.3533, 0.8571, 0.3747]}, {"w": "basics:", "b": [0.1429, 0.3723, 0.197, 0.3937]}, {"w": "it", "b": [0.2017, 0.3723, 0.2137, 0.3937]}, {"w": "is", "b": [0.2184, 0.3723, 0.2316, 0.3937]}, {"w": "a", "b": [0.2364, 0.3723, 0.2455, 0.3937]}, {"w": "great", "b": [0.2502, 0.3723, 0.2917, 0.3937]}, {"w": "tool", "b": [0.2964, 0.3723, 0.3293, 0.3937]}, {"w": "to", "b": [0.334, 0.3723, 0.351, 0.3937]}, {"w": "have", "b": [0.3557, 0.3723, 0.3941, 0.3937]}, {"w": "in", "b": [0.3989, 0.3723, 0.4158, 0.3937]}, {"w": "your", "b": [0.4206, 0.3723, 0.4595, 0.3937]}, {"w": "toolbox.", "b": [0.4643, 0.3723, 0.5329, 0.3937]}]}, {"id": "b_6", "type": "paragraph", "text": "If you are not familiar with Python’s scientific libraries, the provided Jupyter note‐ books include a few tutorials. There is also a quick math tutorial for linear algebra.", "words": [{"w": "If", "b": [0.1429, 0.4005, 0.1561, 0.4219]}, {"w": "you", "b": [0.1635, 0.4005, 0.1948, 0.4219]}, {"w": "are", "b": [0.2022, 0.4005, 0.2279, 0.4219]}, {"w": "not", "b": [0.2353, 0.4005, 0.2637, 0.4219]}, {"w": "familiar", "b": [0.2711, 0.4005, 0.3368, 0.4219]}, {"w": "with", "b": [0.3442, 0.4005, 0.3816, 0.4219]}, {"w": "Python’s", "b": [0.389, 0.4005, 0.4584, 0.4219]}, {"w": "scientific", "b": [0.4658, 0.4005, 0.5402, 0.4219]}, {"w": "libraries,", "b": [0.5476, 0.4005, 0.6205, 0.4219]}, {"w": "the", "b": [0.6279, 0.4005, 0.6542, 0.4219]}, {"w": "provided", "b": [0.6616, 0.4005, 0.737, 0.4219]}, {"w": "Jupyter", "b": [0.7444, 0.4005, 0.8051, 0.4219]}, {"w": "note‐", "b": [0.8125, 0.4005, 0.8571, 0.4219]}, {"w": "books", "b": [0.1429, 0.4195, 0.1927, 0.4409]}, {"w": "include", "b": [0.1974, 0.4195, 0.2594, 0.4409]}, {"w": "a", "b": [0.2641, 0.4195, 0.2733, 0.4409]}, {"w": "few", "b": [0.278, 0.4195, 0.3073, 0.4409]}, {"w": "tutorials.", "b": [0.312, 0.4195, 0.3865, 0.4409]}, {"w": "There", "b": [0.3913, 0.4195, 0.4407, 0.4409]}, {"w": "is", "b": [0.4454, 0.4195, 0.4586, 0.4409]}, {"w": "also", "b": [0.4634, 0.4195, 0.4961, 0.4409]}, {"w": "a", "b": [0.5008, 0.4195, 0.5099, 0.4409]}, {"w": "quick", "b": [0.5147, 0.4195, 0.5611, 0.4409]}, {"w": "math", "b": [0.5658, 0.4195, 0.6091, 0.4409]}, {"w": "tutorial", "b": [0.6138, 0.4195, 0.676, 0.4409]}, {"w": "for", "b": [0.6807, 0.4195, 0.7052, 0.4409]}, {"w": "linear", "b": [0.7099, 0.4195, 0.7579, 0.4409]}, {"w": "algebra.", "b": [0.7627, 0.4195, 0.8279, 0.4409]}]}, {"id": "b_7", "type": "paragraph", "text": "Roadmap", "words": [{"w": "Roadmap", "b": [0.1429, 0.4539, 0.261, 0.4882]}]}, {"id": "b_8", "type": "paragraph", "text": "This book is organized in two parts. Part I, The Fundamentals of Machine Learning, covers the following topics:", "words": [{"w": "This", "b": [0.1428, 0.4951, 0.1801, 0.5165]}, {"w": "book", "b": [0.1869, 0.4951, 0.229, 0.5165]}, {"w": "is", "b": [0.2358, 0.4951, 0.249, 0.5165]}, {"w": "organized", "b": [0.2558, 0.4951, 0.3387, 0.5165]}, {"w": "in", "b": [0.3455, 0.4951, 0.3624, 0.5165]}, {"w": "two", "b": [0.3692, 0.4951, 0.4005, 0.5165]}, {"w": "parts.", "b": [0.4073, 0.4951, 0.4538, 0.5165]}, {"w": "Part", "b": [0.4606, 0.4951, 0.4951, 0.5165]}, {"w": "I,", "b": [0.5019, 0.4951, 0.5138, 0.5165]}, {"w": "The", "b": [0.5206, 0.4949, 0.5504, 0.5165]}, {"w": "Fundamentals", "b": [0.5573, 0.4949, 0.6735, 0.5165]}, {"w": "of", "b": [0.6804, 0.4949, 0.6956, 0.5165]}, {"w": "Machine", "b": [0.7024, 0.4949, 0.7728, 0.5165]}, {"w": "Learning,", "b": [0.7796, 0.4949, 0.8571, 0.5165]}, {"w": "covers", "b": [0.1429, 0.5141, 0.1962, 0.5355]}, {"w": "the", "b": [0.2009, 0.5141, 0.2272, 0.5355]}, {"w": "following", "b": [0.232, 0.5141, 0.3109, 0.5355]}, {"w": "topics:", "b": [0.3157, 0.5141, 0.3703, 0.5355]}]}, {"id": "b_9", "type": "paragraph", "text": "• What is Machine Learning? What problems does it try to solve? What are the main categories and fundamental concepts of Machine Learning systems?", "words": [{"w": "•", "b": [0.16, 0.5483, 0.1682, 0.5697]}, {"w": "What", "b": [0.1786, 0.5483, 0.225, 0.5697]}, {"w": "is", "b": [0.2326, 0.5483, 0.2458, 0.5697]}, {"w": "Machine", "b": [0.2533, 0.5483, 0.3264, 0.5697]}, {"w": "Learning?", "b": [0.334, 0.5483, 0.4169, 0.5697]}, {"w": "What", "b": [0.4245, 0.5483, 0.4709, 0.5697]}, {"w": "problems", "b": [0.4785, 0.5483, 0.5571, 0.5697]}, {"w": "does", "b": [0.5647, 0.5483, 0.6028, 0.5697]}, {"w": "it", "b": [0.6103, 0.5483, 0.6223, 0.5697]}, {"w": "try", "b": [0.6298, 0.5483, 0.654, 0.5697]}, {"w": "to", "b": [0.6616, 0.5483, 0.6786, 0.5697]}, {"w": "solve?", "b": [0.6861, 0.5483, 0.736, 0.5697]}, {"w": "What", "b": [0.7436, 0.5483, 0.79, 0.5697]}, {"w": "are", "b": [0.7975, 0.5483, 0.8233, 0.5697]}, {"w": "the", "b": [0.8308, 0.5483, 0.8571, 0.5697]}, {"w": "main", "b": [0.1786, 0.5673, 0.2218, 0.5888]}, {"w": "categories", "b": [0.2265, 0.5673, 0.3094, 0.5888]}, {"w": "and", "b": [0.3142, 0.5673, 0.3457, 0.5888]}, {"w": "fundamental", "b": [0.3504, 0.5673, 0.4569, 0.5888]}, {"w": "concepts", "b": [0.4616, 0.5673, 0.5351, 0.5888]}, {"w": "of", "b": [0.5398, 0.5673, 0.5566, 0.5888]}, {"w": "Machine", "b": [0.5613, 0.5673, 0.6344, 0.5888]}, {"w": "Learning", "b": [0.6392, 0.5673, 0.7142, 0.5888]}, {"w": "systems?", "b": [0.7189, 0.5673, 0.7916, 0.5888]}]}, {"id": "b_10", "type": "paragraph", "text": "• The main steps in a typical Machine Learning project.", "words": [{"w": "•", "b": [0.16, 0.5924, 0.1682, 0.6139]}, {"w": "The", "b": [0.1786, 0.5924, 0.2114, 0.6139]}, {"w": "main", "b": [0.2161, 0.5924, 0.2593, 0.6139]}, {"w": "steps", "b": [0.264, 0.5924, 0.3055, 0.6139]}, {"w": "in", "b": [0.3102, 0.5924, 0.3272, 0.6139]}, {"w": "a", "b": [0.3319, 0.5924, 0.341, 0.6139]}, {"w": "typical", "b": [0.3458, 0.5924, 0.4014, 0.6139]}, {"w": "Machine", "b": [0.4061, 0.5924, 0.4793, 0.6139]}, {"w": "Learning", "b": [0.484, 0.5924, 0.5591, 0.6139]}, {"w": "project.", "b": [0.5638, 0.5924, 0.6272, 0.6139]}]}, {"id": "b_11", "type": "paragraph", "text": "• Learning by fitting a model to data.", "words": [{"w": "•", "b": [0.16, 0.6175, 0.1682, 0.6389]}, {"w": "Learning", "b": [0.1786, 0.6175, 0.2536, 0.6389]}, {"w": "by", "b": [0.2584, 0.6175, 0.2785, 0.6389]}, {"w": "fitting", "b": [0.2832, 0.6175, 0.3344, 0.6389]}, {"w": "a", "b": [0.3391, 0.6175, 0.3483, 0.6389]}, {"w": "model", "b": [0.353, 0.6175, 0.4058, 0.6389]}, {"w": "to", "b": [0.4106, 0.6175, 0.4275, 0.6389]}, {"w": "data.", "b": [0.4323, 0.6175, 0.4723, 0.6389]}]}, {"id": "b_12", "type": "paragraph", "text": "• Optimizing a cost function.", "words": [{"w": "•", "b": [0.16, 0.6426, 0.1682, 0.664]}, {"w": "Optimizing", "b": [0.1786, 0.6426, 0.2751, 0.664]}, {"w": "a", "b": [0.2798, 0.6426, 0.289, 0.664]}, {"w": "cost", "b": [0.2937, 0.6426, 0.3271, 0.664]}, {"w": "function.", "b": [0.3319, 0.6426, 0.408, 0.664]}]}, {"id": "b_13", "type": "paragraph", "text": "• Handling, cleaning, and preparing data.", "words": [{"w": "•", "b": [0.16, 0.6677, 0.1682, 0.6891]}, {"w": "Handling,", "b": [0.1786, 0.6677, 0.2623, 0.6891]}, {"w": "cleaning,", "b": [0.267, 0.6677, 0.342, 0.6891]}, {"w": "and", "b": [0.3467, 0.6677, 0.3783, 0.6891]}, {"w": "preparing", "b": [0.383, 0.6677, 0.465, 0.6891]}, {"w": "data.", "b": [0.4698, 0.6677, 0.5098, 0.6891]}]}, {"id": "b_14", "type": "paragraph", "text": "• Selecting and engineering features.", "words": [{"w": "•", "b": [0.16, 0.6928, 0.1682, 0.7142]}, {"w": "Selecting", "b": [0.1786, 0.6928, 0.2533, 0.7142]}, {"w": "and", "b": [0.258, 0.6928, 0.2896, 0.7142]}, {"w": "engineering", "b": [0.2943, 0.6928, 0.3935, 0.7142]}, {"w": "features.", "b": [0.3982, 0.6928, 0.4684, 0.7142]}]}, {"id": "b_15", "type": "equation", "text": "• Selecting a model and tuning hyperparameters using cross-validation.", "words": [{"w": "•", "b": [0.16, 0.7179, 0.1682, 0.7393]}, {"w": "Selecting", "b": [0.1786, 0.7179, 0.2533, 0.7393]}, {"w": "a", "b": [0.258, 0.7179, 0.2672, 0.7393]}, {"w": "model", "b": [0.2719, 0.7179, 0.3247, 0.7393]}, {"w": "and", "b": [0.3295, 0.7179, 0.361, 0.7393]}, {"w": "tuning", "b": [0.3657, 0.7179, 0.4213, 0.7393]}, {"w": "hyperparameters", "b": [0.426, 0.7179, 0.5671, 0.7393]}, {"w": "using", "b": [0.5719, 0.7179, 0.6173, 0.7393]}, {"w": "cross-validation.", "b": [0.622, 0.7179, 0.76, 0.7393]}]}, {"id": "b_16", "type": "paragraph", "text": "• The main challenges of Machine Learning, in particular underfitting and overfit‐ ting (the bias/variance tradeoff).", "words": [{"w": "•", "b": [0.16, 0.743, 0.1682, 0.7644]}, {"w": "The", "b": [0.1786, 0.743, 0.2114, 0.7644]}, {"w": "main", "b": [0.2167, 0.743, 0.2599, 0.7644]}, {"w": "challenges", "b": [0.2652, 0.743, 0.3513, 0.7644]}, {"w": "of", "b": [0.3566, 0.743, 0.3733, 0.7644]}, {"w": "Machine", "b": [0.3786, 0.743, 0.4518, 0.7644]}, {"w": "Learning,", "b": [0.457, 0.743, 0.5369, 0.7644]}, {"w": "in", "b": [0.5421, 0.743, 0.5591, 0.7644]}, {"w": "particular", "b": [0.5644, 0.743, 0.6461, 0.7644]}, {"w": "underfitting", "b": [0.6514, 0.743, 0.7527, 0.7644]}, {"w": "and", "b": [0.7579, 0.743, 0.7895, 0.7644]}, {"w": "overfit‐", "b": [0.7948, 0.743, 0.8571, 0.7644]}, {"w": "ting", "b": [0.1786, 0.7621, 0.2117, 0.7835]}, {"w": "(the", "b": [0.2164, 0.7621, 0.2499, 0.7835]}, {"w": "bias/variance", "b": [0.2547, 0.7621, 0.3648, 0.7835]}, {"w": "tradeoff).", "b": [0.3696, 0.7621, 0.4492, 0.7835]}]}, {"id": "b_17", "type": "paragraph", "text": "• Reducing the dimensionality of the training data to fight the curse of dimension‐ ality.", "words": [{"w": "•", "b": [0.16, 0.7872, 0.1682, 0.8086]}, {"w": "Reducing", "b": [0.1786, 0.7871, 0.258, 0.8086]}, {"w": "the", "b": [0.2632, 0.7871, 0.2896, 0.8086]}, {"w": "dimensionality", "b": [0.2948, 0.7871, 0.4199, 0.8086]}, {"w": "of", "b": [0.4251, 0.7871, 0.4419, 0.8086]}, {"w": "the", "b": [0.4472, 0.7871, 0.4735, 0.8086]}, {"w": "training", "b": [0.4788, 0.7871, 0.5457, 0.8086]}, {"w": "data", "b": [0.551, 0.7871, 0.5862, 0.8086]}, {"w": "to", "b": [0.5915, 0.7871, 0.6085, 0.8086]}, {"w": "fight", "b": [0.6137, 0.7871, 0.6523, 0.8086]}, {"w": "the", "b": [0.6576, 0.7871, 0.6839, 0.8086]}, {"w": "curse", "b": [0.6892, 0.7871, 0.7333, 0.8086]}, {"w": "of", "b": [0.7385, 0.7871, 0.7553, 0.8086]}, {"w": "dimension‐", "b": [0.7606, 0.7871, 0.8571, 0.8086]}, {"w": "ality.", "b": [0.1786, 0.8062, 0.2177, 0.8276]}]}, {"id": "b_18", "type": "paragraph", "text": "• Other unsupervised learning techniques, including clustering, density estimation and anomaly detection.", "words": [{"w": "•", "b": [0.16, 0.8313, 0.1682, 0.8527]}, {"w": "Other", "b": [0.1786, 0.8313, 0.2282, 0.8527]}, {"w": "unsupervised", "b": [0.2335, 0.8313, 0.3455, 0.8527]}, {"w": "learning", "b": [0.3508, 0.8313, 0.4199, 0.8527]}, {"w": "techniques,", "b": [0.4252, 0.8313, 0.5203, 0.8527]}, {"w": "including", "b": [0.5256, 0.8313, 0.6054, 0.8527]}, {"w": "clustering,", "b": [0.6107, 0.8313, 0.6979, 0.8527]}, {"w": "density", "b": [0.7032, 0.8313, 0.7636, 0.8527]}, {"w": "estimation", "b": [0.7689, 0.8313, 0.8571, 0.8527]}, {"w": "and", "b": [0.1786, 0.8503, 0.2101, 0.8718]}, {"w": "anomaly", "b": [0.2148, 0.8503, 0.2871, 0.8718]}, {"w": "detection.", "b": [0.2918, 0.8503, 0.3744, 0.8718]}]}, {"id": "b_19", "type": "paragraph", "text": "Preface | xiii", "words": [{"w": "Preface", "b": [0.7561, 0.9225, 0.8001, 0.9388]}, {"w": "|", "b": [0.8179, 0.9225, 0.8217, 0.9388]}, {"w": "xiii", "b": [0.8395, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 16, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• The most common learning algorithms: Linear and Polynomial Regression, Logistic Regression, k-Nearest Neighbors, Support Vector Machines, Decision Trees, Random Forests, and Ensemble methods.", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "The", "b": [0.1786, 0.0791, 0.2114, 0.1005]}, {"w": "most", "b": [0.2223, 0.0791, 0.264, 0.1005]}, {"w": "common", "b": [0.275, 0.0791, 0.3505, 0.1005]}, {"w": "learning", "b": [0.3615, 0.0791, 0.4306, 0.1005]}, {"w": "algorithms:", "b": [0.4415, 0.0791, 0.5366, 0.1005]}, {"w": "Linear", "b": [0.5475, 0.0791, 0.6014, 0.1005]}, {"w": "and", "b": [0.6124, 0.0791, 0.6439, 0.1005]}, {"w": "Polynomial", "b": [0.6548, 0.0791, 0.7504, 0.1005]}, {"w": "Regression,", "b": [0.7614, 0.0791, 0.8571, 0.1005]}, {"w": "Logistic", "b": [0.1786, 0.0981, 0.2441, 0.1195]}, {"w": "Regression,", "b": [0.2531, 0.0981, 0.3488, 0.1195]}, {"w": "k-Nearest", "b": [0.3578, 0.0981, 0.4391, 0.1195]}, {"w": "Neighbors,", "b": [0.448, 0.0981, 0.5396, 0.1195]}, {"w": "Support", "b": [0.5485, 0.0981, 0.616, 0.1195]}, {"w": "Vector", "b": [0.6249, 0.0981, 0.6799, 0.1195]}, {"w": "Machines,", "b": [0.6889, 0.0981, 0.7744, 0.1195]}, {"w": "Decision", "b": [0.7833, 0.0981, 0.8571, 0.1195]}, {"w": "Trees,", "b": [0.1786, 0.1172, 0.2275, 0.1386]}, {"w": "Random", "b": [0.2323, 0.1172, 0.3048, 0.1386]}, {"w": "Forests,", "b": [0.3095, 0.1172, 0.3738, 0.1386]}, {"w": "and", "b": [0.3785, 0.1172, 0.41, 0.1386]}, {"w": "Ensemble", "b": [0.4148, 0.1172, 0.4963, 0.1386]}, {"w": "methods.", "b": [0.501, 0.1172, 0.5784, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "xiv | Preface", "words": [{"w": "xiv", "b": [0.1429, 0.9225, 0.1598, 0.9388]}, {"w": "|", "b": [0.1777, 0.9225, 0.1814, 0.9388]}, {"w": "Preface", "b": [0.1993, 0.9225, 0.2432, 0.9388]}]}]}, {"page": 17, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Part II, Neural Networks and Deep Learning, covers the following topics:", "words": [{"w": "Part", "b": [0.1429, 0.0791, 0.1774, 0.1005]}, {"w": "II,", "b": [0.1821, 0.0791, 0.201, 0.1005]}, {"w": "Neural", "b": [0.2058, 0.0789, 0.2614, 0.1005]}, {"w": "Networks", "b": [0.2662, 0.0789, 0.3426, 0.1005]}, {"w": "and", "b": [0.3474, 0.0789, 0.3788, 0.1005]}, {"w": "Deep", "b": [0.3835, 0.0789, 0.425, 0.1005]}, {"w": "Learning,", "b": [0.4298, 0.0789, 0.5073, 0.1005]}, {"w": "covers", "b": [0.512, 0.0791, 0.5653, 0.1005]}, {"w": "the", "b": [0.57, 0.0791, 0.5964, 0.1005]}, {"w": "following", "b": [0.6011, 0.0791, 0.6801, 0.1005]}, {"w": "topics:", "b": [0.6848, 0.0791, 0.7395, 0.1005]}]}, {"id": "b_1", "type": "paragraph", "text": "• What are neural nets? What are they good for?", "words": [{"w": "•", "b": [0.16, 0.1132, 0.1682, 0.1346]}, {"w": "What", "b": [0.1786, 0.1132, 0.225, 0.1346]}, {"w": "are", "b": [0.2298, 0.1132, 0.2555, 0.1346]}, {"w": "neural", "b": [0.2602, 0.1132, 0.3137, 0.1346]}, {"w": "nets?", "b": [0.3184, 0.1132, 0.3605, 0.1346]}, {"w": "What", "b": [0.3653, 0.1132, 0.4117, 0.1346]}, {"w": "are", "b": [0.4165, 0.1132, 0.4422, 0.1346]}, {"w": "they", "b": [0.4469, 0.1132, 0.4828, 0.1346]}, {"w": "good", "b": [0.4875, 0.1132, 0.5295, 0.1346]}, {"w": "for?", "b": [0.5343, 0.1132, 0.5667, 0.1346]}]}, {"id": "b_2", "type": "paragraph", "text": "• Building and training neural nets using TensorFlow and Keras.", "words": [{"w": "•", "b": [0.16, 0.1383, 0.1682, 0.1597]}, {"w": "Building", "b": [0.1786, 0.1383, 0.2505, 0.1597]}, {"w": "and", "b": [0.2552, 0.1383, 0.2867, 0.1597]}, {"w": "training", "b": [0.2915, 0.1383, 0.3584, 0.1597]}, {"w": "neural", "b": [0.3631, 0.1383, 0.4166, 0.1597]}, {"w": "nets", "b": [0.4213, 0.1383, 0.4556, 0.1597]}, {"w": "using", "b": [0.4603, 0.1383, 0.5057, 0.1597]}, {"w": "TensorFlow", "b": [0.5105, 0.1383, 0.6087, 0.1597]}, {"w": "and", "b": [0.6134, 0.1383, 0.645, 0.1597]}, {"w": "Keras.", "b": [0.6497, 0.1383, 0.7014, 0.1597]}]}, {"id": "b_3", "type": "paragraph", "text": "• The most important neural net architectures: feedforward neural nets, convolu‐ tional nets, recurrent nets, long short-term memory (LSTM) nets, autoencoders and generative adversarial networks (GANs).", "words": [{"w": "•", "b": [0.16, 0.1634, 0.1682, 0.1848]}, {"w": "The", "b": [0.1786, 0.1634, 0.2114, 0.1848]}, {"w": "most", "b": [0.2178, 0.1634, 0.2595, 0.1848]}, {"w": "important", "b": [0.2659, 0.1634, 0.3503, 0.1848]}, {"w": "neural", "b": [0.3567, 0.1634, 0.4102, 0.1848]}, {"w": "net", "b": [0.4166, 0.1634, 0.4432, 0.1848]}, {"w": "architectures:", "b": [0.4496, 0.1634, 0.5625, 0.1848]}, {"w": "feedforward", "b": [0.5689, 0.1634, 0.671, 0.1848]}, {"w": "neural", "b": [0.6775, 0.1634, 0.7309, 0.1848]}, {"w": "nets,", "b": [0.7373, 0.1634, 0.7763, 0.1848]}, {"w": "convolu‐", "b": [0.7828, 0.1634, 0.8571, 0.1848]}, {"w": "tional", "b": [0.1786, 0.1825, 0.2269, 0.2039]}, {"w": "nets,", "b": [0.2333, 0.1825, 0.2723, 0.2039]}, {"w": "recurrent", "b": [0.2786, 0.1825, 0.3567, 0.2039]}, {"w": "nets,", "b": [0.3631, 0.1825, 0.4021, 0.2039]}, {"w": "long", "b": [0.4084, 0.1825, 0.4455, 0.2039]}, {"w": "short-term", "b": [0.4518, 0.1825, 0.5427, 0.2039]}, {"w": "memory", "b": [0.549, 0.1825, 0.6205, 0.2039]}, {"w": "(LSTM)", "b": [0.6269, 0.1825, 0.6938, 0.2039]}, {"w": "nets,", "b": [0.7001, 0.1825, 0.7391, 0.2039]}, {"w": "autoencoders", "b": [0.7454, 0.1825, 0.8571, 0.2039]}, {"w": "and", "b": [0.1786, 0.2015, 0.2101, 0.2229]}, {"w": "generative", "b": [0.2148, 0.2015, 0.3006, 0.2229]}, {"w": "adversarial", "b": [0.3053, 0.2015, 0.3962, 0.2229]}, {"w": "networks", "b": [0.401, 0.2015, 0.4782, 0.2229]}, {"w": "(GANs).", "b": [0.4829, 0.2015, 0.5539, 0.2229]}]}, {"id": "b_4", "type": "paragraph", "text": "• Techniques for training deep neural nets.", "words": [{"w": "•", "b": [0.16, 0.2266, 0.1682, 0.248]}, {"w": "Techniques", "b": [0.1786, 0.2266, 0.2734, 0.248]}, {"w": "for", "b": [0.2781, 0.2266, 0.3026, 0.248]}, {"w": "training", "b": [0.3073, 0.2266, 0.3743, 0.248]}, {"w": "deep", "b": [0.379, 0.2266, 0.4186, 0.248]}, {"w": "neural", "b": [0.4234, 0.2266, 0.4768, 0.248]}, {"w": "nets.", "b": [0.4815, 0.2266, 0.5205, 0.248]}]}, {"id": "b_5", "type": "paragraph", "text": "• Scaling neural networks for large datasets.", "words": [{"w": "•", "b": [0.16, 0.2517, 0.1682, 0.2731]}, {"w": "Scaling", "b": [0.1786, 0.2517, 0.2384, 0.2731]}, {"w": "neural", "b": [0.2431, 0.2517, 0.2966, 0.2731]}, {"w": "networks", "b": [0.3013, 0.2517, 0.3785, 0.2731]}, {"w": "for", "b": [0.3833, 0.2517, 0.4078, 0.2731]}, {"w": "large", "b": [0.4125, 0.2517, 0.4533, 0.2731]}, {"w": "datasets.", "b": [0.458, 0.2517, 0.5285, 0.2731]}]}, {"id": "b_6", "type": "paragraph", "text": "• Learning strategies with Reinforcement Learning.", "words": [{"w": "•", "b": [0.16, 0.2768, 0.1682, 0.2982]}, {"w": "Learning", "b": [0.1786, 0.2768, 0.2536, 0.2982]}, {"w": "strategies", "b": [0.2584, 0.2768, 0.3359, 0.2982]}, {"w": "with", "b": [0.3406, 0.2768, 0.3779, 0.2982]}, {"w": "Reinforcement", "b": [0.3827, 0.2768, 0.5069, 0.2982]}, {"w": "Learning.", "b": [0.5116, 0.2768, 0.5914, 0.2982]}]}, {"id": "b_7", "type": "paragraph", "text": "• Handling uncertainty with Bayesian Deep Learning.", "words": [{"w": "•", "b": [0.16, 0.3019, 0.1682, 0.3233]}, {"w": "Handling", "b": [0.1786, 0.3019, 0.2576, 0.3233]}, {"w": "uncertainty", "b": [0.2623, 0.3019, 0.3581, 0.3233]}, {"w": "with", "b": [0.3629, 0.3019, 0.4002, 0.3233]}, {"w": "Bayesian", "b": [0.4049, 0.3019, 0.4781, 0.3233]}, {"w": "Deep", "b": [0.4829, 0.3019, 0.5268, 0.3233]}, {"w": "Learning.", "b": [0.5315, 0.3019, 0.6114, 0.3233]}]}, {"id": "b_8", "type": "paragraph", "text": "The first part is based mostly on Scikit-Learn while the second part uses TensorFlow and Keras.", "words": [{"w": "The", "b": [0.1429, 0.3361, 0.1757, 0.3575]}, {"w": "first", "b": [0.1815, 0.3361, 0.215, 0.3575]}, {"w": "part", "b": [0.2207, 0.3361, 0.2549, 0.3575]}, {"w": "is", "b": [0.2607, 0.3361, 0.2739, 0.3575]}, {"w": "based", "b": [0.2797, 0.3361, 0.3269, 0.3575]}, {"w": "mostly", "b": [0.3327, 0.3361, 0.3892, 0.3575]}, {"w": "on", "b": [0.395, 0.3361, 0.417, 0.3575]}, {"w": "Scikit-Learn", "b": [0.4228, 0.3361, 0.5251, 0.3575]}, {"w": "while", "b": [0.5309, 0.3361, 0.576, 0.3575]}, {"w": "the", "b": [0.5817, 0.3361, 0.6081, 0.3575]}, {"w": "second", "b": [0.6139, 0.3361, 0.6722, 0.3575]}, {"w": "part", "b": [0.678, 0.3361, 0.7121, 0.3575]}, {"w": "uses", "b": [0.7179, 0.3361, 0.7531, 0.3575]}, {"w": "TensorFlow", "b": [0.7589, 0.3361, 0.8571, 0.3575]}, {"w": "and", "b": [0.1429, 0.3551, 0.1744, 0.3765]}, {"w": "Keras.", "b": [0.1791, 0.3551, 0.2308, 0.3765]}]}, {"id": "b_9", "type": "paragraph", "text": "Don’t jump into deep waters too hastily: while Deep Learning is no doubt one of the most exciting areas in Machine Learning, you should master the fundamentals first. Moreover, most problems can be solved quite well using simpler techniques such as Random Forests and Ensemble methods (discussed in Part I). Deep Learn‐ ing is best suited for complex problems such as image recognition, speech recognition, or natural language processing, provided you have enough data, computing power, and patience.", "words": [{"w": "Don’t", "b": [0.2714, 0.397, 0.3134, 0.4166]}, {"w": "jump", "b": [0.3183, 0.397, 0.3585, 0.4166]}, {"w": "into", "b": [0.3634, 0.397, 0.3941, 0.4166]}, {"w": "deep", "b": [0.3989, 0.397, 0.4352, 0.4166]}, {"w": "waters", "b": [0.4401, 0.397, 0.4891, 0.4166]}, {"w": "too", "b": [0.494, 0.397, 0.5192, 0.4166]}, {"w": "hastily:", "b": [0.5241, 0.397, 0.579, 0.4166]}, {"w": "while", "b": [0.5839, 0.397, 0.6251, 0.4166]}, {"w": "Deep", "b": [0.63, 0.397, 0.6702, 0.4166]}, {"w": "Learning", "b": [0.6751, 0.397, 0.7437, 0.4166]}, {"w": "is", "b": [0.7486, 0.397, 0.7607, 0.4166]}, {"w": "no", "b": [0.7656, 0.397, 0.7857, 0.4166]}, {"w": "doubt", "b": [0.2714, 0.4145, 0.3168, 0.434]}, {"w": "one", "b": [0.3248, 0.4145, 0.353, 0.434]}, {"w": "of", "b": [0.361, 0.4145, 0.3763, 0.434]}, {"w": "the", "b": [0.3843, 0.4145, 0.4084, 0.434]}, {"w": "most", "b": [0.4164, 0.4145, 0.4545, 0.434]}, {"w": "exciting", "b": [0.4625, 0.4145, 0.523, 0.434]}, {"w": "areas", "b": [0.531, 0.4145, 0.5698, 0.434]}, {"w": "in", "b": [0.5778, 0.4145, 0.5934, 0.434]}, {"w": "Machine", "b": [0.6013, 0.4145, 0.6682, 0.434]}, {"w": "Learning,", "b": [0.6762, 0.4145, 0.7492, 0.434]}, {"w": "you", "b": [0.7571, 0.4145, 0.7857, 0.434]}, {"w": "should", "b": [0.2714, 0.4319, 0.3233, 0.4515]}, {"w": "master", "b": [0.3317, 0.4319, 0.3836, 0.4515]}, {"w": "the", "b": [0.392, 0.4319, 0.4161, 0.4515]}, {"w": "fundamentals", "b": [0.4245, 0.4319, 0.5288, 0.4515]}, {"w": "first.", "b": [0.5373, 0.4319, 0.5722, 0.4515]}, {"w": "Moreover,", "b": [0.5806, 0.4319, 0.6588, 0.4515]}, {"w": "most", "b": [0.6672, 0.4319, 0.7054, 0.4515]}, {"w": "problems", "b": [0.7138, 0.4319, 0.7857, 0.4515]}, {"w": "can", "b": [0.2714, 0.4493, 0.2982, 0.4689]}, {"w": "be", "b": [0.3036, 0.4493, 0.3213, 0.4689]}, {"w": "solved", "b": [0.3266, 0.4493, 0.3751, 0.4689]}, {"w": "quite", "b": [0.3804, 0.4493, 0.4193, 0.4689]}, {"w": "well", "b": [0.4246, 0.4493, 0.4554, 0.4689]}, {"w": "using", "b": [0.4607, 0.4493, 0.5023, 0.4689]}, {"w": "simpler", "b": [0.5076, 0.4493, 0.5649, 0.4689]}, {"w": "techniques", "b": [0.5702, 0.4493, 0.6528, 0.4689]}, {"w": "such", "b": [0.6581, 0.4493, 0.6934, 0.4689]}, {"w": "as", "b": [0.6987, 0.4493, 0.7141, 0.4689]}, {"w": "Random", "b": [0.7194, 0.4493, 0.7857, 0.4689]}, {"w": "Forests", "b": [0.2714, 0.4667, 0.3258, 0.4863]}, {"w": "and", "b": [0.3319, 0.4667, 0.3608, 0.4863]}, {"w": "Ensemble", "b": [0.3669, 0.4667, 0.4415, 0.4863]}, {"w": "methods", "b": [0.4476, 0.4667, 0.5141, 0.4863]}, {"w": "(discussed", "b": [0.5202, 0.4667, 0.5993, 0.4863]}, {"w": "in", "b": [0.6054, 0.4667, 0.621, 0.4863]}, {"w": "Part", "b": [0.6271, 0.4667, 0.6587, 0.4863]}, {"w": "I).", "b": [0.6648, 0.4667, 0.6822, 0.4863]}, {"w": "Deep", "b": [0.6884, 0.4667, 0.7286, 0.4863]}, {"w": "Learn‐", "b": [0.7347, 0.4667, 0.7857, 0.4863]}, {"w": "ing", "b": [0.2714, 0.4841, 0.2958, 0.5037]}, {"w": "is", "b": [0.3011, 0.4841, 0.3132, 0.5037]}, {"w": "best", "b": [0.3184, 0.4841, 0.349, 0.5037]}, {"w": "suited", "b": [0.3542, 0.4841, 0.4004, 0.5037]}, {"w": "for", "b": [0.4056, 0.4841, 0.428, 0.5037]}, {"w": "complex", "b": [0.4332, 0.4841, 0.4981, 0.5037]}, {"w": "problems", "b": [0.5033, 0.4841, 0.5753, 0.5037]}, {"w": "such", "b": [0.5805, 0.4841, 0.6158, 0.5037]}, {"w": "as", "b": [0.6211, 0.4841, 0.6364, 0.5037]}, {"w": "image", "b": [0.6417, 0.4841, 0.6877, 0.5037]}, {"w": "recognition,", "b": [0.693, 0.4841, 0.7857, 0.5037]}, {"w": "speech", "b": [0.2714, 0.5015, 0.3228, 0.5211]}, {"w": "recognition,", "b": [0.3296, 0.5015, 0.4224, 0.5211]}, {"w": "or", "b": [0.4292, 0.5015, 0.446, 0.5211]}, {"w": "natural", "b": [0.4528, 0.5015, 0.5073, 0.5211]}, {"w": "language", "b": [0.5142, 0.5015, 0.5822, 0.5211]}, {"w": "processing,", "b": [0.589, 0.5015, 0.6746, 0.5211]}, {"w": "provided", "b": [0.6814, 0.5015, 0.7503, 0.5211]}, {"w": "you", "b": [0.7571, 0.5015, 0.7857, 0.5211]}, {"w": "have", "b": [0.2714, 0.5189, 0.3065, 0.5385]}, {"w": "enough", "b": [0.3108, 0.5189, 0.3683, 0.5385]}, {"w": "data,", "b": [0.3726, 0.5189, 0.4092, 0.5385]}, {"w": "computing", "b": [0.4135, 0.5189, 0.4968, 0.5385]}, {"w": "power,", "b": [0.5012, 0.5189, 0.5522, 0.5385]}, {"w": "and", "b": [0.5565, 0.5189, 0.5854, 0.5385]}, {"w": "patience.", "b": [0.5897, 0.5189, 0.6576, 0.5385]}]}, {"id": "b_10", "type": "paragraph", "text": "Other Resources", "words": [{"w": "Other", "b": [0.1429, 0.555, 0.2124, 0.5893]}, {"w": "Resources", "b": [0.2183, 0.555, 0.3411, 0.5893]}]}, {"id": "b_11", "type": "paragraph", "text": "Many resources are available to learn about Machine Learning. Andrew Ng’s ML course on Coursera and Geoffrey Hinton’s course on neural networks and Deep Learning are amazing, although they both require a significant time investment (think months).", "words": [{"w": "Many", "b": [0.1429, 0.5962, 0.1907, 0.6176]}, {"w": "resources", "b": [0.1995, 0.5962, 0.2785, 0.6176]}, {"w": "are", "b": [0.2874, 0.5962, 0.3131, 0.6176]}, {"w": "available", "b": [0.322, 0.5962, 0.3942, 0.6176]}, {"w": "to", "b": [0.4031, 0.5962, 0.4201, 0.6176]}, {"w": "learn", "b": [0.4289, 0.5962, 0.4713, 0.6176]}, {"w": "about", "b": [0.4802, 0.5962, 0.5279, 0.6176]}, {"w": "Machine", "b": [0.5368, 0.5962, 0.6099, 0.6176]}, {"w": "Learning.", "b": [0.6188, 0.5962, 0.6986, 0.6176]}, {"w": "Andrew", "b": [0.7075, 0.5962, 0.7751, 0.6176]}, {"w": "Ng’s", "b": [0.784, 0.5962, 0.8185, 0.6176]}, {"w": "ML", "b": [0.8274, 0.5962, 0.8571, 0.6176]}, {"w": "course", "b": [0.1428, 0.6152, 0.1976, 0.6367]}, {"w": "on", "b": [0.207, 0.6152, 0.2291, 0.6367]}, {"w": "Coursera", "b": [0.2385, 0.6152, 0.3152, 0.6367]}, {"w": "and", "b": [0.3246, 0.6152, 0.3562, 0.6367]}, {"w": "Geoffrey", "b": [0.3656, 0.6152, 0.4385, 0.6367]}, {"w": "Hinton’s", "b": [0.4479, 0.6152, 0.5175, 0.6367]}, {"w": "course", "b": [0.5269, 0.6152, 0.5817, 0.6367]}, {"w": "on", "b": [0.5911, 0.6152, 0.6131, 0.6367]}, {"w": "neural", "b": [0.6226, 0.6152, 0.6761, 0.6367]}, {"w": "networks", "b": [0.6855, 0.6152, 0.7627, 0.6367]}, {"w": "and", "b": [0.7722, 0.6152, 0.8037, 0.6367]}, {"w": "Deep", "b": [0.8132, 0.6152, 0.8571, 0.6367]}, {"w": "Learning", "b": [0.1429, 0.6343, 0.2179, 0.6557]}, {"w": "are", "b": [0.2281, 0.6343, 0.2539, 0.6557]}, {"w": "amazing,", "b": [0.2641, 0.6343, 0.3397, 0.6557]}, {"w": "although", "b": [0.3499, 0.6343, 0.4243, 0.6557]}, {"w": "they", "b": [0.4345, 0.6343, 0.4704, 0.6557]}, {"w": "both", "b": [0.4807, 0.6343, 0.5193, 0.6557]}, {"w": "require", "b": [0.5296, 0.6343, 0.59, 0.6557]}, {"w": "a", "b": [0.6002, 0.6343, 0.6094, 0.6557]}, {"w": "significant", "b": [0.6196, 0.6343, 0.7066, 0.6557]}, {"w": "time", "b": [0.7168, 0.6343, 0.7547, 0.6557]}, {"w": "investment", "b": [0.7649, 0.6343, 0.8572, 0.6557]}, {"w": "(think", "b": [0.1429, 0.6533, 0.1949, 0.6747]}, {"w": "months).", "b": [0.1996, 0.6533, 0.2754, 0.6747]}]}, {"id": "b_12", "type": "paragraph", "text": "There are also many interesting websites about Machine Learning, including of course Scikit-Learn’s exceptional User Guide. You may also enjoy Dataquest, which provides very nice interactive tutorials, and ML blogs such as those listed on Quora. Finally, the Deep Learning website has a good list of resources to learn more.", "words": [{"w": "There", "b": [0.1429, 0.6815, 0.1923, 0.7029]}, {"w": "are", "b": [0.2026, 0.6815, 0.2284, 0.7029]}, {"w": "also", "b": [0.2387, 0.6815, 0.2714, 0.7029]}, {"w": "many", "b": [0.2817, 0.6815, 0.3284, 0.7029]}, {"w": "interesting", "b": [0.3388, 0.6815, 0.4279, 0.7029]}, {"w": "websites", "b": [0.4382, 0.6815, 0.508, 0.7029]}, {"w": "about", "b": [0.5184, 0.6815, 0.5662, 0.7029]}, {"w": "Machine", "b": [0.5765, 0.6815, 0.6496, 0.7029]}, {"w": "Learning,", "b": [0.66, 0.6815, 0.7398, 0.7029]}, {"w": "including", "b": [0.7501, 0.6815, 0.83, 0.7029]}, {"w": "of", "b": [0.8404, 0.6815, 0.8571, 0.7029]}, {"w": "course", "b": [0.1429, 0.7005, 0.1976, 0.7219]}, {"w": "Scikit-Learn’s", "b": [0.2049, 0.7005, 0.3158, 0.7219]}, {"w": "exceptional", "b": [0.323, 0.7005, 0.4187, 0.7219]}, {"w": "User", "b": [0.426, 0.7005, 0.4644, 0.7219]}, {"w": "Guide.", "b": [0.4717, 0.7005, 0.5279, 0.7219]}, {"w": "You", "b": [0.5351, 0.7005, 0.5675, 0.7219]}, {"w": "may", "b": [0.5748, 0.7005, 0.6102, 0.7219]}, {"w": "also", "b": [0.6174, 0.7005, 0.6501, 0.7219]}, {"w": "enjoy", "b": [0.6574, 0.7005, 0.7028, 0.7219]}, {"w": "Dataquest,", "b": [0.7101, 0.7005, 0.7989, 0.7219]}, {"w": "which", "b": [0.8062, 0.7005, 0.8571, 0.7219]}, {"w": "provides", "b": [0.1429, 0.7196, 0.2149, 0.741]}, {"w": "very", "b": [0.2209, 0.7196, 0.2573, 0.741]}, {"w": "nice", "b": [0.2633, 0.7196, 0.2979, 0.741]}, {"w": "interactive", "b": [0.3039, 0.7196, 0.3918, 0.741]}, {"w": "tutorials,", "b": [0.3978, 0.7196, 0.4724, 0.741]}, {"w": "and", "b": [0.4784, 0.7196, 0.5099, 0.741]}, {"w": "ML", "b": [0.5159, 0.7196, 0.5457, 0.741]}, {"w": "blogs", "b": [0.5517, 0.7196, 0.5955, 0.741]}, {"w": "such", "b": [0.6015, 0.7196, 0.6402, 0.741]}, {"w": "as", "b": [0.6462, 0.7196, 0.663, 0.741]}, {"w": "those", "b": [0.669, 0.7196, 0.7136, 0.741]}, {"w": "listed", "b": [0.7196, 0.7196, 0.7643, 0.741]}, {"w": "on", "b": [0.7703, 0.7196, 0.7923, 0.741]}, {"w": "Quora.", "b": [0.7983, 0.7196, 0.8572, 0.741]}, {"w": "Finally,", "b": [0.1429, 0.7386, 0.2033, 0.76]}, {"w": "the", "b": [0.2081, 0.7386, 0.2344, 0.76]}, {"w": "Deep", "b": [0.2391, 0.7386, 0.2831, 0.76]}, {"w": "Learning", "b": [0.2878, 0.7386, 0.3629, 0.76]}, {"w": "website", "b": [0.3676, 0.7386, 0.4297, 0.76]}, {"w": "has", "b": [0.4345, 0.7386, 0.4624, 0.76]}, {"w": "a", "b": [0.4671, 0.7386, 0.4763, 0.76]}, {"w": "good", "b": [0.481, 0.7386, 0.523, 0.76]}, {"w": "list", "b": [0.5277, 0.7386, 0.5526, 0.76]}, {"w": "of", "b": [0.5573, 0.7386, 0.5741, 0.76]}, {"w": "resources", "b": [0.5788, 0.7386, 0.6578, 0.76]}, {"w": "to", "b": [0.6625, 0.7386, 0.6795, 0.76]}, {"w": "learn", "b": [0.6842, 0.7386, 0.7266, 0.76]}, {"w": "more.", "b": [0.7313, 0.7386, 0.7804, 0.76]}]}, {"id": "b_13", "type": "paragraph", "text": "Of course there are also many other introductory books about Machine Learning, in particular:", "words": [{"w": "Of", "b": [0.1429, 0.7667, 0.1646, 0.7881]}, {"w": "course", "b": [0.1705, 0.7667, 0.2252, 0.7881]}, {"w": "there", "b": [0.2311, 0.7667, 0.274, 0.7881]}, {"w": "are", "b": [0.2799, 0.7667, 0.3056, 0.7881]}, {"w": "also", "b": [0.3115, 0.7667, 0.3442, 0.7881]}, {"w": "many", "b": [0.3501, 0.7667, 0.3967, 0.7881]}, {"w": "other", "b": [0.4026, 0.7667, 0.4473, 0.7881]}, {"w": "introductory", "b": [0.4532, 0.7667, 0.5602, 0.7881]}, {"w": "books", "b": [0.5661, 0.7667, 0.6159, 0.7881]}, {"w": "about", "b": [0.6218, 0.7667, 0.6696, 0.7881]}, {"w": "Machine", "b": [0.6755, 0.7667, 0.7486, 0.7881]}, {"w": "Learning,", "b": [0.7545, 0.7667, 0.8343, 0.7881]}, {"w": "in", "b": [0.8402, 0.7667, 0.8571, 0.7881]}, {"w": "particular:", "b": [0.1429, 0.7858, 0.2299, 0.8072]}]}, {"id": "b_14", "type": "paragraph", "text": "• Joel Grus, Data Science from Scratch (O’Reilly). This book presents the funda‐ mentals of Machine Learning, and implements some of the main algorithms in pure Python (from scratch, as the name suggests).", "words": [{"w": "•", "b": [0.16, 0.8199, 0.1682, 0.8413]}, {"w": "Joel", "b": [0.1786, 0.8199, 0.2097, 0.8413]}, {"w": "Grus,", "b": [0.2175, 0.8199, 0.2636, 0.8413]}, {"w": "Data", "b": [0.2714, 0.8197, 0.3125, 0.8413]}, {"w": "Science", "b": [0.3203, 0.8197, 0.3792, 0.8413]}, {"w": "from", "b": [0.387, 0.8197, 0.4261, 0.8413]}, {"w": "Scratch", "b": [0.4339, 0.8197, 0.4933, 0.8413]}, {"w": "(O’Reilly).", "b": [0.5011, 0.8199, 0.5872, 0.8413]}, {"w": "This", "b": [0.595, 0.8199, 0.6322, 0.8413]}, {"w": "book", "b": [0.64, 0.8199, 0.6822, 0.8413]}, {"w": "presents", "b": [0.69, 0.8199, 0.759, 0.8413]}, {"w": "the", "b": [0.7668, 0.8199, 0.7931, 0.8413]}, {"w": "funda‐", "b": [0.8009, 0.8199, 0.8571, 0.8413]}, {"w": "mentals", "b": [0.1786, 0.839, 0.2439, 0.8604]}, {"w": "of", "b": [0.2508, 0.839, 0.2676, 0.8604]}, {"w": "Machine", "b": [0.2745, 0.839, 0.3476, 0.8604]}, {"w": "Learning,", "b": [0.3545, 0.839, 0.4344, 0.8604]}, {"w": "and", "b": [0.4413, 0.839, 0.4728, 0.8604]}, {"w": "implements", "b": [0.4797, 0.839, 0.5779, 0.8604]}, {"w": "some", "b": [0.5848, 0.839, 0.629, 0.8604]}, {"w": "of", "b": [0.6359, 0.839, 0.6527, 0.8604]}, {"w": "the", "b": [0.6596, 0.839, 0.686, 0.8604]}, {"w": "main", "b": [0.6929, 0.839, 0.7361, 0.8604]}, {"w": "algorithms", "b": [0.743, 0.839, 0.8333, 0.8604]}, {"w": "in", "b": [0.8402, 0.839, 0.8571, 0.8604]}, {"w": "pure", "b": [0.1786, 0.858, 0.2171, 0.8794]}, {"w": "Python", "b": [0.2219, 0.858, 0.2826, 0.8794]}, {"w": "(from", "b": [0.2874, 0.858, 0.3362, 0.8794]}, {"w": "scratch,", "b": [0.3409, 0.858, 0.4049, 0.8794]}, {"w": "as", "b": [0.4096, 0.858, 0.4264, 0.8794]}, {"w": "the", "b": [0.4311, 0.858, 0.4575, 0.8794]}, {"w": "name", "b": [0.4622, 0.858, 0.5086, 0.8794]}, {"w": "suggests).", "b": [0.5134, 0.858, 0.594, 0.8794]}]}, {"id": "b_15", "type": "paragraph", "text": "Preface | xv", "words": [{"w": "Preface", "b": [0.7605, 0.9225, 0.8044, 0.9388]}, {"w": "|", "b": [0.8223, 0.9225, 0.826, 0.9388]}, {"w": "xv", "b": [0.8439, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 18, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• Stephen Marsland, Machine Learning: An Algorithmic Perspective (Chapman and Hall). This book is a great introduction to Machine Learning, covering a wide range of topics in depth, with code examples in Python (also from scratch, but using NumPy).", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "Stephen", "b": [0.1786, 0.0791, 0.2459, 0.1005]}, {"w": "Marsland,", "b": [0.2518, 0.0791, 0.3361, 0.1005]}, {"w": "Machine", "b": [0.342, 0.0789, 0.4124, 0.1005]}, {"w": "Learning:", "b": [0.4183, 0.0789, 0.496, 0.1005]}, {"w": "An", "b": [0.5019, 0.0789, 0.5268, 0.1005]}, {"w": "Algorithmic", "b": [0.5328, 0.0789, 0.6292, 0.1005]}, {"w": "Perspective", "b": [0.6351, 0.0789, 0.7244, 0.1005]}, {"w": "(Chapman", "b": [0.7302, 0.0791, 0.8197, 0.1005]}, {"w": "and", "b": [0.8256, 0.0791, 0.8571, 0.1005]}, {"w": "Hall).", "b": [0.1786, 0.0981, 0.2257, 0.1195]}, {"w": "This", "b": [0.2333, 0.0981, 0.2705, 0.1195]}, {"w": "book", "b": [0.2781, 0.0981, 0.3202, 0.1195]}, {"w": "is", "b": [0.3278, 0.0981, 0.341, 0.1195]}, {"w": "a", "b": [0.3486, 0.0981, 0.3578, 0.1195]}, {"w": "great", "b": [0.3653, 0.0981, 0.4068, 0.1195]}, {"w": "introduction", "b": [0.4144, 0.0981, 0.5205, 0.1195]}, {"w": "to", "b": [0.5281, 0.0981, 0.545, 0.1195]}, {"w": "Machine", "b": [0.5526, 0.0981, 0.6258, 0.1195]}, {"w": "Learning,", "b": [0.6333, 0.0981, 0.7131, 0.1195]}, {"w": "covering", "b": [0.7207, 0.0981, 0.7931, 0.1195]}, {"w": "a", "b": [0.8007, 0.0981, 0.8099, 0.1195]}, {"w": "wide", "b": [0.8174, 0.0981, 0.8571, 0.1195]}, {"w": "range", "b": [0.1786, 0.1172, 0.2254, 0.1386]}, {"w": "of", "b": [0.2324, 0.1172, 0.2491, 0.1386]}, {"w": "topics", "b": [0.2561, 0.1172, 0.306, 0.1386]}, {"w": "in", "b": [0.3129, 0.1172, 0.3299, 0.1386]}, {"w": "depth,", "b": [0.3368, 0.1172, 0.3898, 0.1386]}, {"w": "with", "b": [0.3967, 0.1172, 0.4341, 0.1386]}, {"w": "code", "b": [0.441, 0.1172, 0.4803, 0.1386]}, {"w": "examples", "b": [0.4872, 0.1172, 0.5644, 0.1386]}, {"w": "in", "b": [0.5713, 0.1172, 0.5883, 0.1386]}, {"w": "Python", "b": [0.5952, 0.1172, 0.656, 0.1386]}, {"w": "(also", "b": [0.6629, 0.1172, 0.7028, 0.1386]}, {"w": "from", "b": [0.7097, 0.1172, 0.7513, 0.1386]}, {"w": "scratch,", "b": [0.7582, 0.1172, 0.8222, 0.1386]}, {"w": "but", "b": [0.8291, 0.1172, 0.8571, 0.1386]}, {"w": "using", "b": [0.1786, 0.1362, 0.224, 0.1576]}, {"w": "NumPy).", "b": [0.2287, 0.1362, 0.3049, 0.1576]}]}, {"id": "b_1", "type": "paragraph", "text": "• Sebastian Raschka, Python Machine Learning (Packt Publishing). Also a great introduction to Machine Learning, this book leverages Python open source libra‐ ries (Pylearn 2 and Theano).", "words": [{"w": "•", "b": [0.16, 0.1613, 0.1682, 0.1827]}, {"w": "Sebastian", "b": [0.1786, 0.1613, 0.2571, 0.1827]}, {"w": "Raschka,", "b": [0.2661, 0.1613, 0.3404, 0.1827]}, {"w": "Python", "b": [0.3493, 0.1611, 0.408, 0.1827]}, {"w": "Machine", "b": [0.417, 0.1611, 0.4874, 0.1827]}, {"w": "Learning", "b": [0.4963, 0.1611, 0.5691, 0.1827]}, {"w": "(Packt", "b": [0.578, 0.1613, 0.6312, 0.1827]}, {"w": "Publishing).", "b": [0.6401, 0.1613, 0.7418, 0.1827]}, {"w": "Also", "b": [0.7507, 0.1613, 0.7887, 0.1827]}, {"w": "a", "b": [0.7976, 0.1613, 0.8068, 0.1827]}, {"w": "great", "b": [0.8157, 0.1613, 0.8571, 0.1827]}, {"w": "introduction", "b": [0.1786, 0.1803, 0.2847, 0.2018]}, {"w": "to", "b": [0.2898, 0.1803, 0.3068, 0.2018]}, {"w": "Machine", "b": [0.3119, 0.1803, 0.385, 0.2018]}, {"w": "Learning,", "b": [0.3901, 0.1803, 0.4699, 0.2018]}, {"w": "this", "b": [0.475, 0.1803, 0.5057, 0.2018]}, {"w": "book", "b": [0.5108, 0.1803, 0.5529, 0.2018]}, {"w": "leverages", "b": [0.558, 0.1803, 0.6338, 0.2018]}, {"w": "Python", "b": [0.6388, 0.1803, 0.6996, 0.2018]}, {"w": "open", "b": [0.7047, 0.1803, 0.7465, 0.2018]}, {"w": "source", "b": [0.7516, 0.1803, 0.8063, 0.2018]}, {"w": "libra‐", "b": [0.8114, 0.1803, 0.8571, 0.2018]}, {"w": "ries", "b": [0.1786, 0.1994, 0.2084, 0.2208]}, {"w": "(Pylearn", "b": [0.2131, 0.1994, 0.284, 0.2208]}, {"w": "2", "b": [0.2887, 0.1994, 0.2987, 0.2208]}, {"w": "and", "b": [0.3035, 0.1994, 0.335, 0.2208]}, {"w": "Theano).", "b": [0.3397, 0.1994, 0.4157, 0.2208]}]}, {"id": "b_2", "type": "paragraph", "text": "• François Chollet, Deep Learning with Python (Manning). A very practical book that covers a large range of topics in a clear and concise way, as you might expect from the author of the excellent Keras library. It favors code examples over math‐ ematical theory.", "words": [{"w": "•", "b": [0.16, 0.2245, 0.1682, 0.2459]}, {"w": "François", "b": [0.1786, 0.2245, 0.2505, 0.2459]}, {"w": "Chollet,", "b": [0.2575, 0.2245, 0.3236, 0.2459]}, {"w": "Deep", "b": [0.3306, 0.2243, 0.3721, 0.2459]}, {"w": "Learning", "b": [0.3792, 0.2243, 0.4519, 0.2459]}, {"w": "with", "b": [0.459, 0.2243, 0.4955, 0.2459]}, {"w": "Python", "b": [0.5025, 0.2243, 0.5612, 0.2459]}, {"w": "(Manning).", "b": [0.5683, 0.2245, 0.6643, 0.2459]}, {"w": "A", "b": [0.6713, 0.2245, 0.6857, 0.2459]}, {"w": "very", "b": [0.6928, 0.2245, 0.7291, 0.2459]}, {"w": "practical", "b": [0.7362, 0.2245, 0.8079, 0.2459]}, {"w": "book", "b": [0.815, 0.2245, 0.8571, 0.2459]}, {"w": "that", "b": [0.1786, 0.2435, 0.2112, 0.2649]}, {"w": "covers", "b": [0.2163, 0.2435, 0.2697, 0.2649]}, {"w": "a", "b": [0.2748, 0.2435, 0.284, 0.2649]}, {"w": "large", "b": [0.2892, 0.2435, 0.3299, 0.2649]}, {"w": "range", "b": [0.3351, 0.2435, 0.382, 0.2649]}, {"w": "of", "b": [0.3872, 0.2435, 0.404, 0.2649]}, {"w": "topics", "b": [0.4092, 0.2435, 0.4591, 0.2649]}, {"w": "in", "b": [0.4643, 0.2435, 0.4813, 0.2649]}, {"w": "a", "b": [0.4864, 0.2435, 0.4956, 0.2649]}, {"w": "clear", "b": [0.5008, 0.2435, 0.5406, 0.2649]}, {"w": "and", "b": [0.5458, 0.2435, 0.5773, 0.2649]}, {"w": "concise", "b": [0.5825, 0.2435, 0.6442, 0.2649]}, {"w": "way,", "b": [0.6494, 0.2435, 0.6853, 0.2649]}, {"w": "as", "b": [0.6904, 0.2435, 0.7072, 0.2649]}, {"w": "you", "b": [0.7124, 0.2435, 0.7437, 0.2649]}, {"w": "might", "b": [0.7489, 0.2435, 0.7983, 0.2649]}, {"w": "expect", "b": [0.8035, 0.2435, 0.8571, 0.2649]}, {"w": "from", "b": [0.1786, 0.2626, 0.2201, 0.284]}, {"w": "the", "b": [0.2252, 0.2626, 0.2515, 0.284]}, {"w": "author", "b": [0.2565, 0.2626, 0.3122, 0.284]}, {"w": "of", "b": [0.3172, 0.2626, 0.334, 0.284]}, {"w": "the", "b": [0.339, 0.2626, 0.3653, 0.284]}, {"w": "excellent", "b": [0.3703, 0.2626, 0.4434, 0.284]}, {"w": "Keras", "b": [0.4484, 0.2626, 0.4953, 0.284]}, {"w": "library.", "b": [0.5003, 0.2626, 0.5598, 0.284]}, {"w": "It", "b": [0.5648, 0.2626, 0.5774, 0.284]}, {"w": "favors", "b": [0.5825, 0.2626, 0.633, 0.284]}, {"w": "code", "b": [0.6381, 0.2626, 0.6773, 0.284]}, {"w": "examples", "b": [0.6824, 0.2626, 0.7595, 0.284]}, {"w": "over", "b": [0.7646, 0.2626, 0.8014, 0.284]}, {"w": "math‐", "b": [0.8064, 0.2626, 0.8571, 0.284]}, {"w": "ematical", "b": [0.1786, 0.2816, 0.2484, 0.303]}, {"w": "theory.", "b": [0.2531, 0.2816, 0.3112, 0.303]}]}, {"id": "b_3", "type": "paragraph", "text": "• Yaser S. Abu-Mostafa, Malik Magdon-Ismail, and Hsuan-Tien Lin, Learning from Data (AMLBook). A rather theoretical approach to ML, this book provides deep insights, in particular on the bias/variance tradeoff (see Chapter 4).", "words": [{"w": "•", "b": [0.16, 0.3067, 0.1682, 0.3281]}, {"w": "Yaser", "b": [0.1786, 0.3067, 0.2228, 0.3281]}, {"w": "S.", "b": [0.2279, 0.3067, 0.2426, 0.3281]}, {"w": "Abu-Mostafa,", "b": [0.2477, 0.3067, 0.3624, 0.3281]}, {"w": "Malik", "b": [0.3676, 0.3067, 0.4161, 0.3281]}, {"w": "Magdon-Ismail,", "b": [0.4213, 0.3067, 0.555, 0.3281]}, {"w": "and", "b": [0.5601, 0.3067, 0.5917, 0.3281]}, {"w": "Hsuan-Tien", "b": [0.5969, 0.3067, 0.6968, 0.3281]}, {"w": "Lin,", "b": [0.702, 0.3067, 0.735, 0.3281]}, {"w": "Learning", "b": [0.7401, 0.3065, 0.8129, 0.3281]}, {"w": "from", "b": [0.8177, 0.3065, 0.8567, 0.3281]}, {"w": "Data", "b": [0.1786, 0.3256, 0.2196, 0.3472]}, {"w": "(AMLBook).", "b": [0.2253, 0.3258, 0.3328, 0.3472]}, {"w": "A", "b": [0.3385, 0.3258, 0.3529, 0.3472]}, {"w": "rather", "b": [0.3586, 0.3258, 0.4091, 0.3472]}, {"w": "theoretical", "b": [0.4148, 0.3258, 0.5035, 0.3472]}, {"w": "approach", "b": [0.5091, 0.3258, 0.5872, 0.3472]}, {"w": "to", "b": [0.5928, 0.3258, 0.6098, 0.3472]}, {"w": "ML,", "b": [0.6155, 0.3258, 0.65, 0.3472]}, {"w": "this", "b": [0.6556, 0.3258, 0.6864, 0.3472]}, {"w": "book", "b": [0.692, 0.3258, 0.7342, 0.3472]}, {"w": "provides", "b": [0.7398, 0.3258, 0.8118, 0.3472]}, {"w": "deep", "b": [0.8175, 0.3258, 0.8571, 0.3472]}, {"w": "insights,", "b": [0.1786, 0.3448, 0.248, 0.3662]}, {"w": "in", "b": [0.2527, 0.3448, 0.2697, 0.3662]}, {"w": "particular", "b": [0.2744, 0.3448, 0.3562, 0.3662]}, {"w": "on", "b": [0.3609, 0.3448, 0.3829, 0.3662]}, {"w": "the", "b": [0.3877, 0.3448, 0.414, 0.3662]}, {"w": "bias/variance", "b": [0.4187, 0.3448, 0.5289, 0.3662]}, {"w": "tradeoff", "b": [0.5336, 0.3448, 0.5997, 0.3662]}, {"w": "(see", "b": [0.6044, 0.3448, 0.637, 0.3662]}, {"w": "Chapter", "b": [0.6417, 0.3448, 0.7093, 0.3662]}, {"w": "4).", "b": [0.714, 0.3448, 0.736, 0.3662]}]}, {"id": "b_4", "type": "paragraph", "text": "• Stuart Russell and Peter Norvig, Artificial Intelligence: A Modern Approach, 3rd Edition (Pearson). This is a great (and huge) book covering an incredible amount of topics, including Machine Learning. It helps put ML into perspective.", "words": [{"w": "•", "b": [0.16, 0.3699, 0.1682, 0.3913]}, {"w": "Stuart", "b": [0.1786, 0.3699, 0.2291, 0.3913]}, {"w": "Russell", "b": [0.2363, 0.3699, 0.2945, 0.3913]}, {"w": "and", "b": [0.3017, 0.3699, 0.3332, 0.3913]}, {"w": "Peter", "b": [0.3404, 0.3699, 0.3833, 0.3913]}, {"w": "Norvig,", "b": [0.3905, 0.3699, 0.4541, 0.3913]}, {"w": "Artificial", "b": [0.4613, 0.3697, 0.5349, 0.3913]}, {"w": "Intelligence:", "b": [0.5421, 0.3697, 0.6377, 0.3913]}, {"w": "A", "b": [0.6449, 0.3697, 0.6587, 0.3913]}, {"w": "Modern", "b": [0.6659, 0.3697, 0.731, 0.3913]}, {"w": "Approach,", "b": [0.7382, 0.3697, 0.8222, 0.3913]}, {"w": "3rd", "b": [0.8294, 0.3697, 0.8571, 0.3913]}, {"w": "Edition", "b": [0.1786, 0.3888, 0.2384, 0.4104]}, {"w": "(Pearson).", "b": [0.2436, 0.389, 0.3292, 0.4104]}, {"w": "This", "b": [0.3343, 0.389, 0.3715, 0.4104]}, {"w": "is", "b": [0.3767, 0.389, 0.3899, 0.4104]}, {"w": "a", "b": [0.395, 0.389, 0.4042, 0.4104]}, {"w": "great", "b": [0.4093, 0.389, 0.4508, 0.4104]}, {"w": "(and", "b": [0.4559, 0.389, 0.4947, 0.4104]}, {"w": "huge)", "b": [0.4998, 0.389, 0.5474, 0.4104]}, {"w": "book", "b": [0.5526, 0.389, 0.5947, 0.4104]}, {"w": "covering", "b": [0.5999, 0.389, 0.6723, 0.4104]}, {"w": "an", "b": [0.6774, 0.389, 0.6979, 0.4104]}, {"w": "incredible", "b": [0.7031, 0.389, 0.7868, 0.4104]}, {"w": "amount", "b": [0.7919, 0.389, 0.8571, 0.4104]}, {"w": "of", "b": [0.1786, 0.408, 0.1954, 0.4294]}, {"w": "topics,", "b": [0.2001, 0.408, 0.2548, 0.4294]}, {"w": "including", "b": [0.2595, 0.408, 0.3394, 0.4294]}, {"w": "Machine", "b": [0.3441, 0.408, 0.4172, 0.4294]}, {"w": "Learning.", "b": [0.4219, 0.408, 0.5018, 0.4294]}, {"w": "It", "b": [0.5065, 0.408, 0.5191, 0.4294]}, {"w": "helps", "b": [0.5239, 0.408, 0.5677, 0.4294]}, {"w": "put", "b": [0.5724, 0.408, 0.6007, 0.4294]}, {"w": "ML", "b": [0.6055, 0.408, 0.6352, 0.4294]}, {"w": "into", "b": [0.64, 0.408, 0.6735, 0.4294]}, {"w": "perspective.", "b": [0.6783, 0.408, 0.7772, 0.4294]}]}, {"id": "b_5", "type": "paragraph", "text": "Finally, a great way to learn is to join ML competition websites such as Kaggle.com this will allow you to practice your skills on real-world problems, with help and insights from some of the best ML professionals out there.", "words": [{"w": "Finally,", "b": [0.1429, 0.4422, 0.2033, 0.4636]}, {"w": "a", "b": [0.21, 0.4422, 0.2191, 0.4636]}, {"w": "great", "b": [0.2258, 0.4422, 0.2672, 0.4636]}, {"w": "way", "b": [0.2739, 0.4422, 0.3065, 0.4636]}, {"w": "to", "b": [0.3132, 0.4422, 0.3302, 0.4636]}, {"w": "learn", "b": [0.3368, 0.4422, 0.3792, 0.4636]}, {"w": "is", "b": [0.3859, 0.4422, 0.3991, 0.4636]}, {"w": "to", "b": [0.4058, 0.4422, 0.4228, 0.4636]}, {"w": "join", "b": [0.4294, 0.4422, 0.4624, 0.4636]}, {"w": "ML", "b": [0.469, 0.4422, 0.4988, 0.4636]}, {"w": "competition", "b": [0.5054, 0.4422, 0.6072, 0.4636]}, {"w": "websites", "b": [0.6139, 0.4422, 0.6837, 0.4636]}, {"w": "such", "b": [0.6903, 0.4422, 0.729, 0.4636]}, {"w": "as", "b": [0.7356, 0.4422, 0.7524, 0.4636]}, {"w": "Kaggle.com", "b": [0.7591, 0.4422, 0.8571, 0.4636]}, {"w": "this", "b": [0.1429, 0.4612, 0.1736, 0.4826]}, {"w": "will", "b": [0.1825, 0.4612, 0.2128, 0.4826]}, {"w": "allow", "b": [0.2217, 0.4612, 0.2663, 0.4826]}, {"w": "you", "b": [0.2752, 0.4612, 0.3065, 0.4826]}, {"w": "to", "b": [0.3154, 0.4612, 0.3323, 0.4826]}, {"w": "practice", "b": [0.3412, 0.4612, 0.4074, 0.4826]}, {"w": "your", "b": [0.4163, 0.4612, 0.4553, 0.4826]}, {"w": "skills", "b": [0.4642, 0.4612, 0.506, 0.4826]}, {"w": "on", "b": [0.5149, 0.4612, 0.5369, 0.4826]}, {"w": "real-world", "b": [0.5458, 0.4612, 0.6331, 0.4826]}, {"w": "problems,", "b": [0.642, 0.4612, 0.7254, 0.4826]}, {"w": "with", "b": [0.7343, 0.4612, 0.7716, 0.4826]}, {"w": "help", "b": [0.7805, 0.4612, 0.8167, 0.4826]}, {"w": "and", "b": [0.8256, 0.4612, 0.8571, 0.4826]}, {"w": "insights", "b": [0.1429, 0.4803, 0.2076, 0.5017]}, {"w": "from", "b": [0.2123, 0.4803, 0.2539, 0.5017]}, {"w": "some", "b": [0.2586, 0.4803, 0.3028, 0.5017]}, {"w": "of", "b": [0.3075, 0.4803, 0.3243, 0.5017]}, {"w": "the", "b": [0.329, 0.4803, 0.3554, 0.5017]}, {"w": "best", "b": [0.3601, 0.4803, 0.3935, 0.5017]}, {"w": "ML", "b": [0.3983, 0.4803, 0.428, 0.5017]}, {"w": "professionals", "b": [0.4328, 0.4803, 0.542, 0.5017]}, {"w": "out", "b": [0.5467, 0.4803, 0.5748, 0.5017]}, {"w": "there.", "b": [0.5795, 0.4803, 0.6272, 0.5017]}]}, {"id": "b_6", "type": "paragraph", "text": "Conventions Used in This Book", "words": [{"w": "Conventions", "b": [0.1428, 0.5147, 0.2958, 0.5489]}, {"w": "Used", "b": [0.3017, 0.5147, 0.3621, 0.5489]}, {"w": "in", "b": [0.368, 0.5147, 0.392, 0.5489]}, {"w": "This", "b": [0.3979, 0.5147, 0.4476, 0.5489]}, {"w": "Book", "b": [0.4535, 0.5147, 0.5158, 0.5489]}]}, {"id": "b_7", "type": "paragraph", "text": "The following typographical conventions are used in this book:", "words": [{"w": "The", "b": [0.1429, 0.5559, 0.1757, 0.5773]}, {"w": "following", "b": [0.1804, 0.5559, 0.2594, 0.5773]}, {"w": "typographical", "b": [0.2641, 0.5559, 0.3787, 0.5773]}, {"w": "conventions", "b": [0.3834, 0.5559, 0.4848, 0.5773]}, {"w": "are", "b": [0.4896, 0.5559, 0.5153, 0.5773]}, {"w": "used", "b": [0.52, 0.5559, 0.5586, 0.5773]}, {"w": "in", "b": [0.5633, 0.5559, 0.5803, 0.5773]}, {"w": "this", "b": [0.585, 0.5559, 0.6157, 0.5773]}, {"w": "book:", "b": [0.6205, 0.5559, 0.6674, 0.5773]}]}, {"id": "b_8", "type": "paragraph", "text": "Italic", "words": [{"w": "Italic", "b": [0.1429, 0.5853, 0.1838, 0.6069]}]}, {"id": "b_9", "type": "paragraph", "text": "Indicates new terms, URLs, email addresses, filenames, and file extensions.", "words": [{"w": "Indicates", "b": [0.1786, 0.6045, 0.2541, 0.6259]}, {"w": "new", "b": [0.2588, 0.6045, 0.2933, 0.6259]}, {"w": "terms,", "b": [0.298, 0.6045, 0.3504, 0.6259]}, {"w": "URLs,", "b": [0.3552, 0.6045, 0.407, 0.6259]}, {"w": "email", "b": [0.4118, 0.6045, 0.4577, 0.6259]}, {"w": "addresses,", "b": [0.4624, 0.6045, 0.5467, 0.6259]}, {"w": "filenames,", "b": [0.5514, 0.6045, 0.6362, 0.6259]}, {"w": "and", "b": [0.6409, 0.6045, 0.6724, 0.6259]}, {"w": "file", "b": [0.6772, 0.6045, 0.703, 0.6259]}, {"w": "extensions.", "b": [0.7078, 0.6045, 0.8007, 0.6259]}]}, {"id": "b_10", "type": "paragraph", "text": "Constant width", "words": [{"w": "Constant", "b": [0.1429, 0.6382, 0.222, 0.6533]}, {"w": "width", "b": [0.2319, 0.6382, 0.2814, 0.6533]}]}, {"id": "b_11", "type": "paragraph", "text": "Used for program listings, as well as within paragraphs to refer to program ele‐ ments such as variable or function names, databases, data types, environment variables, statements and keywords.", "words": [{"w": "Used", "b": [0.1786, 0.6541, 0.2203, 0.6755]}, {"w": "for", "b": [0.2268, 0.6541, 0.2513, 0.6755]}, {"w": "program", "b": [0.2578, 0.6541, 0.3307, 0.6755]}, {"w": "listings,", "b": [0.3372, 0.6541, 0.4012, 0.6755]}, {"w": "as", "b": [0.4077, 0.6541, 0.4245, 0.6755]}, {"w": "well", "b": [0.431, 0.6541, 0.4646, 0.6755]}, {"w": "as", "b": [0.4711, 0.6541, 0.4879, 0.6755]}, {"w": "within", "b": [0.4944, 0.6541, 0.5487, 0.6755]}, {"w": "paragraphs", "b": [0.5552, 0.6541, 0.6481, 0.6755]}, {"w": "to", "b": [0.6545, 0.6541, 0.6715, 0.6755]}, {"w": "refer", "b": [0.678, 0.6541, 0.7173, 0.6755]}, {"w": "to", "b": [0.7238, 0.6541, 0.7408, 0.6755]}, {"w": "program", "b": [0.7473, 0.6541, 0.8203, 0.6755]}, {"w": "ele‐", "b": [0.8267, 0.6541, 0.8571, 0.6755]}, {"w": "ments", "b": [0.1786, 0.6732, 0.2295, 0.6946]}, {"w": "such", "b": [0.2377, 0.6732, 0.2764, 0.6946]}, {"w": "as", "b": [0.2846, 0.6732, 0.3014, 0.6946]}, {"w": "variable", "b": [0.3097, 0.6732, 0.3756, 0.6946]}, {"w": "or", "b": [0.3839, 0.6732, 0.4022, 0.6946]}, {"w": "function", "b": [0.4105, 0.6732, 0.4819, 0.6946]}, {"w": "names,", "b": [0.4901, 0.6732, 0.5489, 0.6946]}, {"w": "databases,", "b": [0.5572, 0.6732, 0.6411, 0.6946]}, {"w": "data", "b": [0.6493, 0.6732, 0.6846, 0.6946]}, {"w": "types,", "b": [0.6928, 0.6732, 0.7409, 0.6946]}, {"w": "environment", "b": [0.7491, 0.6732, 0.8571, 0.6946]}, {"w": "variables,", "b": [0.1786, 0.6922, 0.2569, 0.7136]}, {"w": "statements", "b": [0.2616, 0.6922, 0.3505, 0.7136]}, {"w": "and", "b": [0.3553, 0.6922, 0.3868, 0.7136]}, {"w": "keywords.", "b": [0.3915, 0.6922, 0.4763, 0.7136]}]}, {"id": "b_12", "type": "paragraph", "text": "Constant width bold", "words": [{"w": "Constant", "b": [0.1429, 0.7259, 0.222, 0.741]}, {"w": "width", "b": [0.2319, 0.7259, 0.2814, 0.741]}, {"w": "bold", "b": [0.2913, 0.7259, 0.3309, 0.741]}]}, {"id": "b_13", "type": "paragraph", "text": "Shows commands or other text that should be typed literally by the user.", "words": [{"w": "Shows", "b": [0.1786, 0.7418, 0.2321, 0.7632]}, {"w": "commands", "b": [0.2368, 0.7418, 0.3296, 0.7632]}, {"w": "or", "b": [0.3343, 0.7418, 0.3527, 0.7632]}, {"w": "other", "b": [0.3574, 0.7418, 0.4021, 0.7632]}, {"w": "text", "b": [0.4068, 0.7418, 0.4382, 0.7632]}, {"w": "that", "b": [0.4429, 0.7418, 0.4755, 0.7632]}, {"w": "should", "b": [0.4803, 0.7418, 0.537, 0.7632]}, {"w": "be", "b": [0.5417, 0.7418, 0.5612, 0.7632]}, {"w": "typed", "b": [0.5659, 0.7418, 0.6126, 0.7632]}, {"w": "literally", "b": [0.6173, 0.7418, 0.6803, 0.7632]}, {"w": "by", "b": [0.6851, 0.7418, 0.7052, 0.7632]}, {"w": "the", "b": [0.7099, 0.7418, 0.7363, 0.7632]}, {"w": "user.", "b": [0.741, 0.7418, 0.7797, 0.7632]}]}, {"id": "b_14", "type": "paragraph", "text": "Constant width italic", "words": [{"w": "Constant", "b": [0.1429, 0.7755, 0.222, 0.7906]}, {"w": "width", "b": [0.2319, 0.7755, 0.2814, 0.7906]}, {"w": "italic", "b": [0.2913, 0.7755, 0.3507, 0.7906]}]}, {"id": "b_15", "type": "paragraph", "text": "Shows text that should be replaced with user-supplied values or by values deter‐ mined by context.", "words": [{"w": "Shows", "b": [0.1786, 0.7914, 0.2321, 0.8128]}, {"w": "text", "b": [0.2381, 0.7914, 0.2695, 0.8128]}, {"w": "that", "b": [0.2754, 0.7914, 0.308, 0.8128]}, {"w": "should", "b": [0.314, 0.7914, 0.3707, 0.8128]}, {"w": "be", "b": [0.3767, 0.7914, 0.3961, 0.8128]}, {"w": "replaced", "b": [0.4021, 0.7914, 0.4727, 0.8128]}, {"w": "with", "b": [0.4786, 0.7914, 0.516, 0.8128]}, {"w": "user-supplied", "b": [0.5219, 0.7914, 0.6354, 0.8128]}, {"w": "values", "b": [0.6413, 0.7914, 0.693, 0.8128]}, {"w": "or", "b": [0.6989, 0.7914, 0.7173, 0.8128]}, {"w": "by", "b": [0.7232, 0.7914, 0.7434, 0.8128]}, {"w": "values", "b": [0.7493, 0.7914, 0.801, 0.8128]}, {"w": "deter‐", "b": [0.8069, 0.7914, 0.8571, 0.8128]}, {"w": "mined", "b": [0.1786, 0.8104, 0.2325, 0.8318]}, {"w": "by", "b": [0.2372, 0.8104, 0.2574, 0.8318]}, {"w": "context.", "b": [0.2621, 0.8104, 0.3287, 0.8318]}]}, {"id": "b_16", "type": "paragraph", "text": "xvi | Preface", "words": [{"w": "xvi", "b": [0.1429, 0.9225, 0.1598, 0.9388]}, {"w": "|", "b": [0.1777, 0.9225, 0.1814, 0.9388]}, {"w": "Preface", "b": [0.1993, 0.9225, 0.2432, 0.9388]}]}]}, {"page": 19, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "This element signifies a tip or suggestion.", "words": [{"w": "This", "b": [0.2714, 0.0793, 0.3054, 0.0989]}, {"w": "element", "b": [0.3098, 0.0793, 0.3703, 0.0989]}, {"w": "signifies", "b": [0.3746, 0.0793, 0.437, 0.0989]}, {"w": "a", "b": [0.4413, 0.0793, 0.4497, 0.0989]}, {"w": "tip", "b": [0.454, 0.0793, 0.4749, 0.0989]}, {"w": "or", "b": [0.4792, 0.0793, 0.496, 0.0989]}, {"w": "suggestion.", "b": [0.5003, 0.0793, 0.5858, 0.0989]}]}, {"id": "b_1", "type": "paragraph", "text": "This element signifies a general note.", "words": [{"w": "This", "b": [0.2714, 0.1781, 0.3054, 0.1977]}, {"w": "element", "b": [0.3098, 0.1781, 0.3703, 0.1977]}, {"w": "signifies", "b": [0.3746, 0.1781, 0.437, 0.1977]}, {"w": "a", "b": [0.4413, 0.1781, 0.4497, 0.1977]}, {"w": "general", "b": [0.454, 0.1781, 0.5098, 0.1977]}, {"w": "note.", "b": [0.5141, 0.1781, 0.5525, 0.1977]}]}, {"id": "b_2", "type": "paragraph", "text": "This element indicates a warning or caution.", "words": [{"w": "This", "b": [0.2714, 0.277, 0.3054, 0.2966]}, {"w": "element", "b": [0.3098, 0.277, 0.3703, 0.2966]}, {"w": "indicates", "b": [0.3746, 0.277, 0.4423, 0.2966]}, {"w": "a", "b": [0.4466, 0.277, 0.455, 0.2966]}, {"w": "warning", "b": [0.4593, 0.277, 0.5226, 0.2966]}, {"w": "or", "b": [0.527, 0.277, 0.5437, 0.2966]}, {"w": "caution.", "b": [0.5481, 0.277, 0.6096, 0.2966]}]}, {"id": "b_3", "type": "paragraph", "text": "Code Examples", "words": [{"w": "Code", "b": [0.1429, 0.3719, 0.2034, 0.4061]}, {"w": "Examples", "b": [0.2094, 0.3719, 0.3269, 0.4061]}]}, {"id": "b_4", "type": "paragraph", "text": "Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/ageron/handson-ml2. It is mostly composed of Jupyter notebooks.", "words": [{"w": "Supplemental", "b": [0.1429, 0.413, 0.2574, 0.4344]}, {"w": "material", "b": [0.2654, 0.413, 0.3341, 0.4344]}, {"w": "(code", "b": [0.3421, 0.413, 0.3886, 0.4344]}, {"w": "examples,", "b": [0.3965, 0.413, 0.4785, 0.4344]}, {"w": "exercises,", "b": [0.4864, 0.413, 0.565, 0.4344]}, {"w": "etc.)", "b": [0.573, 0.413, 0.6089, 0.4344]}, {"w": "is", "b": [0.6169, 0.413, 0.6301, 0.4344]}, {"w": "available", "b": [0.6381, 0.413, 0.7103, 0.4344]}, {"w": "for", "b": [0.7183, 0.413, 0.7428, 0.4344]}, {"w": "download", "b": [0.7508, 0.413, 0.8341, 0.4344]}, {"w": "at", "b": [0.842, 0.413, 0.8571, 0.4344]}, {"w": "https://github.com/ageron/handson-ml2.", "b": [0.1429, 0.4319, 0.4718, 0.4535]}, {"w": "It", "b": [0.4765, 0.4321, 0.4892, 0.4535]}, {"w": "is", "b": [0.4939, 0.4321, 0.5071, 0.4535]}, {"w": "mostly", "b": [0.5119, 0.4321, 0.5684, 0.4535]}, {"w": "composed", "b": [0.5731, 0.4321, 0.6583, 0.4535]}, {"w": "of", "b": [0.663, 0.4321, 0.6798, 0.4535]}, {"w": "Jupyter", "b": [0.6845, 0.4321, 0.7452, 0.4535]}, {"w": "notebooks.", "b": [0.7499, 0.4321, 0.8417, 0.4535]}]}, {"id": "b_5", "type": "paragraph", "text": "Some of the code examples in the book leave out some repetitive sections, or details that are obvious or unrelated to Machine Learning. This keeps the focus on the important parts of the code, and it saves space to cover more topics. However, if you want the full code examples, they are all available in the Jupyter notebooks.", "words": [{"w": "Some", "b": [0.1429, 0.4602, 0.1893, 0.4816]}, {"w": "of", "b": [0.1955, 0.4602, 0.2122, 0.4816]}, {"w": "the", "b": [0.2184, 0.4602, 0.2448, 0.4816]}, {"w": "code", "b": [0.2509, 0.4602, 0.2902, 0.4816]}, {"w": "examples", "b": [0.2964, 0.4602, 0.3736, 0.4816]}, {"w": "in", "b": [0.3798, 0.4602, 0.3968, 0.4816]}, {"w": "the", "b": [0.403, 0.4602, 0.4293, 0.4816]}, {"w": "book", "b": [0.4355, 0.4602, 0.4776, 0.4816]}, {"w": "leave", "b": [0.4838, 0.4602, 0.5252, 0.4816]}, {"w": "out", "b": [0.5314, 0.4602, 0.5594, 0.4816]}, {"w": "some", "b": [0.5656, 0.4602, 0.6098, 0.4816]}, {"w": "repetitive", "b": [0.616, 0.4602, 0.6947, 0.4816]}, {"w": "sections,", "b": [0.7009, 0.4602, 0.7726, 0.4816]}, {"w": "or", "b": [0.7788, 0.4602, 0.7971, 0.4816]}, {"w": "details", "b": [0.8033, 0.4602, 0.8571, 0.4816]}, {"w": "that", "b": [0.1429, 0.4792, 0.1754, 0.5007]}, {"w": "are", "b": [0.1847, 0.4792, 0.2104, 0.5007]}, {"w": "obvious", "b": [0.2196, 0.4792, 0.2854, 0.5007]}, {"w": "or", "b": [0.2946, 0.4792, 0.3129, 0.5007]}, {"w": "unrelated", "b": [0.3222, 0.4792, 0.4014, 0.5007]}, {"w": "to", "b": [0.4107, 0.4792, 0.4276, 0.5007]}, {"w": "Machine", "b": [0.4369, 0.4792, 0.51, 0.5007]}, {"w": "Learning.", "b": [0.5192, 0.4792, 0.599, 0.5007]}, {"w": "This", "b": [0.6082, 0.4792, 0.6454, 0.5007]}, {"w": "keeps", "b": [0.6547, 0.4792, 0.7013, 0.5007]}, {"w": "the", "b": [0.7105, 0.4792, 0.7368, 0.5007]}, {"w": "focus", "b": [0.746, 0.4792, 0.7903, 0.5007]}, {"w": "on", "b": [0.7996, 0.4792, 0.8216, 0.5007]}, {"w": "the", "b": [0.8308, 0.4792, 0.8571, 0.5007]}, {"w": "important", "b": [0.1429, 0.4983, 0.2272, 0.5197]}, {"w": "parts", "b": [0.233, 0.4983, 0.2748, 0.5197]}, {"w": "of", "b": [0.2805, 0.4983, 0.2973, 0.5197]}, {"w": "the", "b": [0.303, 0.4983, 0.3294, 0.5197]}, {"w": "code,", "b": [0.3351, 0.4983, 0.3792, 0.5197]}, {"w": "and", "b": [0.3849, 0.4983, 0.4164, 0.5197]}, {"w": "it", "b": [0.4222, 0.4983, 0.4341, 0.5197]}, {"w": "saves", "b": [0.4398, 0.4983, 0.4824, 0.5197]}, {"w": "space", "b": [0.4881, 0.4983, 0.5335, 0.5197]}, {"w": "to", "b": [0.5393, 0.4983, 0.5562, 0.5197]}, {"w": "cover", "b": [0.562, 0.4983, 0.6076, 0.5197]}, {"w": "more", "b": [0.6134, 0.4983, 0.6577, 0.5197]}, {"w": "topics.", "b": [0.6634, 0.4983, 0.7181, 0.5197]}, {"w": "However,", "b": [0.7238, 0.4983, 0.8027, 0.5197]}, {"w": "if", "b": [0.8084, 0.4983, 0.8202, 0.5197]}, {"w": "you", "b": [0.8259, 0.4983, 0.8572, 0.5197]}, {"w": "want", "b": [0.1429, 0.5173, 0.1836, 0.5388]}, {"w": "the", "b": [0.1884, 0.5173, 0.2147, 0.5388]}, {"w": "full", "b": [0.2194, 0.5173, 0.2472, 0.5388]}, {"w": "code", "b": [0.2519, 0.5173, 0.2912, 0.5388]}, {"w": "examples,", "b": [0.2959, 0.5173, 0.3779, 0.5388]}, {"w": "they", "b": [0.3826, 0.5173, 0.4185, 0.5388]}, {"w": "are", "b": [0.4232, 0.5173, 0.449, 0.5388]}, {"w": "all", "b": [0.4537, 0.5173, 0.4734, 0.5388]}, {"w": "available", "b": [0.4781, 0.5173, 0.5504, 0.5388]}, {"w": "in", "b": [0.5551, 0.5173, 0.5721, 0.5388]}, {"w": "the", "b": [0.5768, 0.5173, 0.6032, 0.5388]}, {"w": "Jupyter", "b": [0.6079, 0.5173, 0.6685, 0.5388]}, {"w": "notebooks.", "b": [0.6733, 0.5173, 0.7651, 0.5388]}]}, {"id": "b_6", "type": "paragraph", "text": "Note that when the code examples display some outputs, then these code examples are shown with Python prompts (>>> and ...), as in a Python shell, to clearly distin‐ guish the code from the outputs. For example, this code defines the square() func‐ tion then it computes and displays the square of 3:", "words": [{"w": "Note", "b": [0.1429, 0.5455, 0.1837, 0.5669]}, {"w": "that", "b": [0.1906, 0.5455, 0.2232, 0.5669]}, {"w": "when", "b": [0.2302, 0.5455, 0.2758, 0.5669]}, {"w": "the", "b": [0.2828, 0.5455, 0.3091, 0.5669]}, {"w": "code", "b": [0.3161, 0.5455, 0.3554, 0.5669]}, {"w": "examples", "b": [0.3624, 0.5455, 0.4396, 0.5669]}, {"w": "display", "b": [0.4465, 0.5455, 0.5053, 0.5669]}, {"w": "some", "b": [0.5123, 0.5455, 0.5565, 0.5669]}, {"w": "outputs,", "b": [0.5634, 0.5455, 0.6322, 0.5669]}, {"w": "then", "b": [0.6392, 0.5455, 0.6769, 0.5669]}, {"w": "these", "b": [0.6839, 0.5455, 0.7267, 0.5669]}, {"w": "code", "b": [0.7337, 0.5455, 0.773, 0.5669]}, {"w": "examples", "b": [0.78, 0.5455, 0.8571, 0.5669]}, {"w": "are", "b": [0.1429, 0.5654, 0.1686, 0.5868]}, {"w": "shown", "b": [0.174, 0.5654, 0.2291, 0.5868]}, {"w": "with", "b": [0.2345, 0.5654, 0.2718, 0.5868]}, {"w": "Python", "b": [0.2772, 0.5654, 0.338, 0.5868]}, {"w": "prompts", "b": [0.3434, 0.5654, 0.4143, 0.5868]}, {"w": "(>>>", "b": [0.4197, 0.5654, 0.4566, 0.5868]}, {"w": "and", "b": [0.462, 0.5654, 0.4935, 0.5868]}, {"w": "...),", "b": [0.499, 0.5654, 0.5406, 0.5868]}, {"w": "as", "b": [0.546, 0.5654, 0.5628, 0.5868]}, {"w": "in", "b": [0.5682, 0.5654, 0.5852, 0.5868]}, {"w": "a", "b": [0.5906, 0.5654, 0.5998, 0.5868]}, {"w": "Python", "b": [0.6052, 0.5654, 0.666, 0.5868]}, {"w": "shell,", "b": [0.6714, 0.5654, 0.7143, 0.5868]}, {"w": "to", "b": [0.7197, 0.5654, 0.7367, 0.5868]}, {"w": "clearly", "b": [0.7421, 0.5654, 0.7968, 0.5868]}, {"w": "distin‐", "b": [0.8022, 0.5654, 0.8572, 0.5868]}, {"w": "guish", "b": [0.1429, 0.5854, 0.188, 0.6068]}, {"w": "the", "b": [0.1945, 0.5854, 0.2208, 0.6068]}, {"w": "code", "b": [0.2272, 0.5854, 0.2665, 0.6068]}, {"w": "from", "b": [0.273, 0.5854, 0.3145, 0.6068]}, {"w": "the", "b": [0.321, 0.5854, 0.3473, 0.6068]}, {"w": "outputs.", "b": [0.3538, 0.5854, 0.4225, 0.6068]}, {"w": "For", "b": [0.429, 0.5854, 0.4579, 0.6068]}, {"w": "example,", "b": [0.4644, 0.5854, 0.5387, 0.6068]}, {"w": "this", "b": [0.5451, 0.5854, 0.5758, 0.6068]}, {"w": "code", "b": [0.5823, 0.5854, 0.6215, 0.6068]}, {"w": "defines", "b": [0.628, 0.5854, 0.6875, 0.6068]}, {"w": "the", "b": [0.6939, 0.5854, 0.7203, 0.6068]}, {"w": "square()", "b": [0.7267, 0.5885, 0.8059, 0.6036]}, {"w": "func‐", "b": [0.8123, 0.5854, 0.8571, 0.6068]}, {"w": "tion", "b": [0.1429, 0.6044, 0.1768, 0.6258]}, {"w": "then", "b": [0.1815, 0.6044, 0.2193, 0.6258]}, {"w": "it", "b": [0.224, 0.6044, 0.2359, 0.6258]}, {"w": "computes", "b": [0.2407, 0.6044, 0.3216, 0.6258]}, {"w": "and", "b": [0.3263, 0.6044, 0.3579, 0.6258]}, {"w": "displays", "b": [0.3626, 0.6044, 0.429, 0.6258]}, {"w": "the", "b": [0.4337, 0.6044, 0.4601, 0.6258]}, {"w": "square", "b": [0.4648, 0.6044, 0.5199, 0.6258]}, {"w": "of", "b": [0.5246, 0.6044, 0.5414, 0.6258]}, {"w": "3:", "b": [0.5461, 0.6044, 0.5609, 0.6258]}]}, {"id": "b_7", "type": "equation", "text": ">>> def square(x): ... return x ** 2 ... >>> result = square(3) >>> result 9", "words": [{"w": ">>>", "b": [0.1766, 0.6364, 0.2019, 0.6492]}, {"w": "def", "b": [0.2103, 0.6364, 0.2356, 0.6492]}, {"w": "square(x):", "b": [0.244, 0.6364, 0.3284, 0.6492]}, {"w": "...", "b": [0.1766, 0.6518, 0.2019, 0.6646]}, {"w": "return", "b": [0.244, 0.6518, 0.2946, 0.6646]}, {"w": "x", "b": [0.3031, 0.6518, 0.3115, 0.6646]}, {"w": "**", "b": [0.3199, 0.6518, 0.3368, 0.6646]}, {"w": "2", "b": [0.3452, 0.6518, 0.3537, 0.6646]}, {"w": "...", "b": [0.1766, 0.6672, 0.2019, 0.6801]}, {"w": ">>>", "b": [0.1766, 0.6826, 0.2019, 0.6955]}, {"w": "result", "b": [0.2103, 0.6826, 0.2609, 0.6955]}, {"w": "=", "b": [0.2693, 0.6826, 0.2778, 0.6955]}, {"w": "square(3)", "b": [0.2862, 0.6826, 0.3621, 0.6955]}, {"w": ">>>", "b": [0.1766, 0.6981, 0.2019, 0.7109]}, {"w": "result", "b": [0.2103, 0.6981, 0.2609, 0.7109]}, {"w": "9", "b": [0.1766, 0.7135, 0.185, 0.7263]}]}, {"id": "b_8", "type": "paragraph", "text": "When code does not display anything, prompts are not used. However, the result may sometimes be shown as a comment like this:", "words": [{"w": "When", "b": [0.1429, 0.7341, 0.1945, 0.7555]}, {"w": "code", "b": [0.1994, 0.7341, 0.2387, 0.7555]}, {"w": "does", "b": [0.2436, 0.7341, 0.2817, 0.7555]}, {"w": "not", "b": [0.2866, 0.7341, 0.315, 0.7555]}, {"w": "display", "b": [0.3199, 0.7341, 0.3786, 0.7555]}, {"w": "anything,", "b": [0.3835, 0.7341, 0.4621, 0.7555]}, {"w": "prompts", "b": [0.467, 0.7341, 0.5379, 0.7555]}, {"w": "are", "b": [0.5428, 0.7341, 0.5685, 0.7555]}, {"w": "not", "b": [0.5734, 0.7341, 0.6018, 0.7555]}, {"w": "used.", "b": [0.6067, 0.7341, 0.65, 0.7555]}, {"w": "However,", "b": [0.6549, 0.7341, 0.7338, 0.7555]}, {"w": "the", "b": [0.7387, 0.7341, 0.765, 0.7555]}, {"w": "result", "b": [0.7699, 0.7341, 0.8168, 0.7555]}, {"w": "may", "b": [0.8217, 0.7341, 0.8571, 0.7555]}, {"w": "sometimes", "b": [0.1429, 0.7532, 0.2326, 0.7746]}, {"w": "be", "b": [0.2373, 0.7532, 0.2567, 0.7746]}, {"w": "shown", "b": [0.2615, 0.7532, 0.3165, 0.7746]}, {"w": "as", "b": [0.3212, 0.7532, 0.338, 0.7746]}, {"w": "a", "b": [0.3428, 0.7532, 0.3519, 0.7746]}, {"w": "comment", "b": [0.3566, 0.7532, 0.4364, 0.7746]}, {"w": "like", "b": [0.4411, 0.7532, 0.4712, 0.7746]}, {"w": "this:", "b": [0.4759, 0.7532, 0.5114, 0.7746]}]}, {"id": "b_9", "type": "equation", "text": "def square(x): return x ** 2", "words": [{"w": "def", "b": [0.1766, 0.7851, 0.2019, 0.798]}, {"w": "square(x):", "b": [0.2103, 0.7851, 0.2947, 0.798]}, {"w": "return", "b": [0.2103, 0.8005, 0.2609, 0.8134]}, {"w": "x", "b": [0.2694, 0.8005, 0.2778, 0.8134]}, {"w": "**", "b": [0.2862, 0.8005, 0.3031, 0.8134]}, {"w": "2", "b": [0.3115, 0.8005, 0.32, 0.8134]}]}, {"id": "b_10", "type": "equation", "text": "result = square(3) # result is 9", "words": [{"w": "result", "b": [0.1766, 0.8314, 0.2272, 0.8442]}, {"w": "=", "b": [0.2356, 0.8314, 0.2441, 0.8442]}, {"w": "square(3)", "b": [0.2525, 0.8314, 0.3284, 0.8442]}, {"w": "#", "b": [0.3452, 0.8314, 0.3537, 0.8442]}, {"w": "result", "b": [0.3621, 0.8314, 0.4127, 0.8442]}, {"w": "is", "b": [0.4211, 0.8314, 0.438, 0.8442]}, {"w": "9", "b": [0.4464, 0.8314, 0.4549, 0.8442]}]}, {"id": "b_11", "type": "paragraph", "text": "Preface | xvii", "words": [{"w": "Preface", "b": [0.7531, 0.9225, 0.7971, 0.9388]}, {"w": "|", "b": [0.8149, 0.9225, 0.8187, 0.9388]}, {"w": "xvii", "b": [0.8365, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 20, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Using Code Examples", "words": [{"w": "Using", "b": [0.1429, 0.0753, 0.2124, 0.1095]}, {"w": "Code", "b": [0.2183, 0.0753, 0.2789, 0.1095]}, {"w": "Examples", "b": [0.2849, 0.0753, 0.4024, 0.1095]}]}, {"id": "b_1", "type": "paragraph", "text": "This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a signifi‐ cant amount of example code from this book into your product’s documentation does require permission.", "words": [{"w": "This", "b": [0.1429, 0.1164, 0.1801, 0.1378]}, {"w": "book", "b": [0.1851, 0.1164, 0.2273, 0.1378]}, {"w": "is", "b": [0.2324, 0.1164, 0.2456, 0.1378]}, {"w": "here", "b": [0.2507, 0.1164, 0.2872, 0.1378]}, {"w": "to", "b": [0.2923, 0.1164, 0.3093, 0.1378]}, {"w": "help", "b": [0.3143, 0.1164, 0.3505, 0.1378]}, {"w": "you", "b": [0.3556, 0.1164, 0.3868, 0.1378]}, {"w": "get", "b": [0.3919, 0.1164, 0.4169, 0.1378]}, {"w": "your", "b": [0.4219, 0.1164, 0.4609, 0.1378]}, {"w": "job", "b": [0.466, 0.1164, 0.4925, 0.1378]}, {"w": "done.", "b": [0.4976, 0.1164, 0.5442, 0.1378]}, {"w": "In", "b": [0.5493, 0.1164, 0.5678, 0.1378]}, {"w": "general,", "b": [0.5728, 0.1164, 0.6386, 0.1378]}, {"w": "if", "b": [0.6437, 0.1164, 0.6554, 0.1378]}, {"w": "example", "b": [0.6605, 0.1164, 0.73, 0.1378]}, {"w": "code", "b": [0.7351, 0.1164, 0.7744, 0.1378]}, {"w": "is", "b": [0.7795, 0.1164, 0.7927, 0.1378]}, {"w": "offered", "b": [0.7978, 0.1164, 0.8571, 0.1378]}, {"w": "with", "b": [0.1429, 0.1355, 0.1802, 0.1569]}, {"w": "this", "b": [0.1881, 0.1355, 0.2188, 0.1569]}, {"w": "book,", "b": [0.2267, 0.1355, 0.2736, 0.1569]}, {"w": "you", "b": [0.2815, 0.1355, 0.3127, 0.1569]}, {"w": "may", "b": [0.3206, 0.1355, 0.356, 0.1569]}, {"w": "use", "b": [0.3639, 0.1355, 0.3915, 0.1569]}, {"w": "it", "b": [0.3994, 0.1355, 0.4113, 0.1569]}, {"w": "in", "b": [0.4192, 0.1355, 0.4362, 0.1569]}, {"w": "your", "b": [0.4441, 0.1355, 0.4831, 0.1569]}, {"w": "programs", "b": [0.4909, 0.1355, 0.5716, 0.1569]}, {"w": "and", "b": [0.5794, 0.1355, 0.611, 0.1569]}, {"w": "documentation.", "b": [0.6189, 0.1355, 0.7511, 0.1569]}, {"w": "You", "b": [0.759, 0.1355, 0.7914, 0.1569]}, {"w": "do", "b": [0.7992, 0.1355, 0.8209, 0.1569]}, {"w": "not", "b": [0.8288, 0.1355, 0.8571, 0.1569]}, {"w": "need", "b": [0.1428, 0.1545, 0.183, 0.1759]}, {"w": "to", "b": [0.1894, 0.1545, 0.2064, 0.1759]}, {"w": "contact", "b": [0.2128, 0.1545, 0.2739, 0.1759]}, {"w": "us", "b": [0.2804, 0.1545, 0.2991, 0.1759]}, {"w": "for", "b": [0.3056, 0.1545, 0.3301, 0.1759]}, {"w": "permission", "b": [0.3365, 0.1545, 0.4296, 0.1759]}, {"w": "unless", "b": [0.436, 0.1545, 0.4879, 0.1759]}, {"w": "you’re", "b": [0.4944, 0.1545, 0.5452, 0.1759]}, {"w": "reproducing", "b": [0.5517, 0.1545, 0.6551, 0.1759]}, {"w": "a", "b": [0.6616, 0.1545, 0.6707, 0.1759]}, {"w": "significant", "b": [0.6772, 0.1545, 0.7642, 0.1759]}, {"w": "portion", "b": [0.7707, 0.1545, 0.8339, 0.1759]}, {"w": "of", "b": [0.8403, 0.1545, 0.8571, 0.1759]}, {"w": "the", "b": [0.1429, 0.1736, 0.1692, 0.195]}, {"w": "code.", "b": [0.1752, 0.1736, 0.2193, 0.195]}, {"w": "For", "b": [0.2253, 0.1736, 0.2543, 0.195]}, {"w": "example,", "b": [0.2603, 0.1736, 0.3346, 0.195]}, {"w": "writing", "b": [0.3407, 0.1736, 0.4013, 0.195]}, {"w": "a", "b": [0.4074, 0.1736, 0.4165, 0.195]}, {"w": "program", "b": [0.4226, 0.1736, 0.4955, 0.195]}, {"w": "that", "b": [0.5016, 0.1736, 0.5342, 0.195]}, {"w": "uses", "b": [0.5402, 0.1736, 0.5754, 0.195]}, {"w": "several", "b": [0.5814, 0.1736, 0.6386, 0.195]}, {"w": "chunks", "b": [0.6446, 0.1736, 0.7046, 0.195]}, {"w": "of", "b": [0.7107, 0.1736, 0.7274, 0.195]}, {"w": "code", "b": [0.7335, 0.1736, 0.7728, 0.195]}, {"w": "from", "b": [0.7788, 0.1736, 0.8204, 0.195]}, {"w": "this", "b": [0.8264, 0.1736, 0.8571, 0.195]}, {"w": "book", "b": [0.1429, 0.1926, 0.185, 0.214]}, {"w": "does", "b": [0.193, 0.1926, 0.2311, 0.214]}, {"w": "not", "b": [0.2391, 0.1926, 0.2675, 0.214]}, {"w": "require", "b": [0.2754, 0.1926, 0.3359, 0.214]}, {"w": "permission.", "b": [0.3438, 0.1926, 0.4416, 0.214]}, {"w": "Selling", "b": [0.4496, 0.1926, 0.5056, 0.214]}, {"w": "or", "b": [0.5136, 0.1926, 0.5319, 0.214]}, {"w": "distributing", "b": [0.5399, 0.1926, 0.6385, 0.214]}, {"w": "a", "b": [0.6465, 0.1926, 0.6556, 0.214]}, {"w": "CD-ROM", "b": [0.6636, 0.1926, 0.7472, 0.214]}, {"w": "of", "b": [0.7552, 0.1926, 0.772, 0.214]}, {"w": "examples", "b": [0.78, 0.1926, 0.8571, 0.214]}, {"w": "from", "b": [0.1429, 0.2117, 0.1844, 0.2331]}, {"w": "O’Reilly", "b": [0.1925, 0.2117, 0.2595, 0.2331]}, {"w": "books", "b": [0.2675, 0.2117, 0.3174, 0.2331]}, {"w": "does", "b": [0.3254, 0.2117, 0.3636, 0.2331]}, {"w": "require", "b": [0.3716, 0.2117, 0.4321, 0.2331]}, {"w": "permission.", "b": [0.4402, 0.2117, 0.538, 0.2331]}, {"w": "Answering", "b": [0.5461, 0.2117, 0.6371, 0.2331]}, {"w": "a", "b": [0.6452, 0.2117, 0.6543, 0.2331]}, {"w": "question", "b": [0.6624, 0.2117, 0.7346, 0.2331]}, {"w": "by", "b": [0.7426, 0.2117, 0.7628, 0.2331]}, {"w": "citing", "b": [0.7709, 0.2117, 0.8183, 0.2331]}, {"w": "this", "b": [0.8264, 0.2117, 0.8571, 0.2331]}, {"w": "book", "b": [0.1429, 0.2307, 0.185, 0.2521]}, {"w": "and", "b": [0.1902, 0.2307, 0.2217, 0.2521]}, {"w": "quoting", "b": [0.2269, 0.2307, 0.2923, 0.2521]}, {"w": "example", "b": [0.2974, 0.2307, 0.367, 0.2521]}, {"w": "code", "b": [0.3721, 0.2307, 0.4114, 0.2521]}, {"w": "does", "b": [0.4165, 0.2307, 0.4546, 0.2521]}, {"w": "not", "b": [0.4598, 0.2307, 0.4882, 0.2521]}, {"w": "require", "b": [0.4933, 0.2307, 0.5538, 0.2521]}, {"w": "permission.", "b": [0.5589, 0.2307, 0.6567, 0.2521]}, {"w": "Incorporating", "b": [0.6618, 0.2307, 0.7786, 0.2521]}, {"w": "a", "b": [0.7837, 0.2307, 0.7929, 0.2521]}, {"w": "signifi‐", "b": [0.798, 0.2307, 0.8572, 0.2521]}, {"w": "cant", "b": [0.1429, 0.2498, 0.1782, 0.2712]}, {"w": "amount", "b": [0.1831, 0.2498, 0.2484, 0.2712]}, {"w": "of", "b": [0.2533, 0.2498, 0.2701, 0.2712]}, {"w": "example", "b": [0.275, 0.2498, 0.3446, 0.2712]}, {"w": "code", "b": [0.3495, 0.2498, 0.3888, 0.2712]}, {"w": "from", "b": [0.3937, 0.2498, 0.4353, 0.2712]}, {"w": "this", "b": [0.4403, 0.2498, 0.471, 0.2712]}, {"w": "book", "b": [0.4759, 0.2498, 0.5181, 0.2712]}, {"w": "into", "b": [0.523, 0.2498, 0.5566, 0.2712]}, {"w": "your", "b": [0.5615, 0.2498, 0.6005, 0.2712]}, {"w": "product’s", "b": [0.6054, 0.2498, 0.6817, 0.2712]}, {"w": "documentation", "b": [0.6866, 0.2498, 0.8141, 0.2712]}, {"w": "does", "b": [0.819, 0.2498, 0.8571, 0.2712]}, {"w": "require", "b": [0.1429, 0.2688, 0.2033, 0.2902]}, {"w": "permission.", "b": [0.208, 0.2688, 0.3058, 0.2902]}]}, {"id": "b_2", "type": "paragraph", "text": "We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Hands-On Machine Learning with Scikit-Learn, Keras and TensorFlow by Aurélien Géron (O’Reilly). Copyright 2019 Aurélien Géron, 978-1-492-03264-9.” If you feel your use of code examples falls out‐ side fair use or the permission given above, feel free to contact us at permis‐ sions@oreilly.com.", "words": [{"w": "We", "b": [0.1429, 0.2969, 0.1699, 0.3183]}, {"w": "appreciate,", "b": [0.1779, 0.2969, 0.2681, 0.3183]}, {"w": "but", "b": [0.2761, 0.2969, 0.3041, 0.3183]}, {"w": "do", "b": [0.312, 0.2969, 0.3337, 0.3183]}, {"w": "not", "b": [0.3416, 0.2969, 0.37, 0.3183]}, {"w": "require,", "b": [0.3779, 0.2969, 0.4432, 0.3183]}, {"w": "attribution.", "b": [0.4511, 0.2969, 0.5462, 0.3183]}, {"w": "An", "b": [0.5542, 0.2969, 0.58, 0.3183]}, {"w": "attribution", "b": [0.5879, 0.2969, 0.6783, 0.3183]}, {"w": "usually", "b": [0.6863, 0.2969, 0.7453, 0.3183]}, {"w": "includes", "b": [0.7532, 0.2969, 0.8229, 0.3183]}, {"w": "the", "b": [0.8308, 0.2969, 0.8571, 0.3183]}, {"w": "title,", "b": [0.1428, 0.316, 0.18, 0.3374]}, {"w": "author,", "b": [0.1878, 0.316, 0.2468, 0.3374]}, {"w": "publisher,", "b": [0.2546, 0.316, 0.3368, 0.3374]}, {"w": "and", "b": [0.3445, 0.316, 0.3761, 0.3374]}, {"w": "ISBN.", "b": [0.3838, 0.316, 0.4332, 0.3374]}, {"w": "For", "b": [0.441, 0.316, 0.47, 0.3374]}, {"w": "example:", "b": [0.4777, 0.316, 0.552, 0.3374]}, {"w": "“Hands-On", "b": [0.5597, 0.3158, 0.6542, 0.3374]}, {"w": "Machine", "b": [0.662, 0.3158, 0.7324, 0.3374]}, {"w": "Learning", "b": [0.7401, 0.3158, 0.8129, 0.3374]}, {"w": "with", "b": [0.8207, 0.3158, 0.8571, 0.3374]}, {"w": "Scikit-Learn,", "b": [0.1429, 0.3348, 0.2475, 0.3564]}, {"w": "Keras", "b": [0.2566, 0.3348, 0.3024, 0.3564]}, {"w": "and", "b": [0.3115, 0.3348, 0.3429, 0.3564]}, {"w": "TensorFlow", "b": [0.352, 0.3348, 0.4457, 0.3564]}, {"w": "by", "b": [0.4548, 0.335, 0.4749, 0.3564]}, {"w": "Aurélien", "b": [0.484, 0.335, 0.5563, 0.3564]}, {"w": "Géron", "b": [0.5653, 0.335, 0.6188, 0.3564]}, {"w": "(O’Reilly).", "b": [0.6279, 0.335, 0.714, 0.3564]}, {"w": "Copyright", "b": [0.723, 0.335, 0.8081, 0.3564]}, {"w": "2019", "b": [0.8171, 0.335, 0.8571, 0.3564]}, {"w": "Aurélien", "b": [0.1429, 0.3541, 0.2152, 0.3755]}, {"w": "Géron,", "b": [0.2211, 0.3541, 0.2794, 0.3755]}, {"w": "978-1-492-03264-9.”", "b": [0.2853, 0.3541, 0.4552, 0.3755]}, {"w": "If", "b": [0.4611, 0.3541, 0.4744, 0.3755]}, {"w": "you", "b": [0.4804, 0.3541, 0.5116, 0.3755]}, {"w": "feel", "b": [0.5176, 0.3541, 0.5467, 0.3755]}, {"w": "your", "b": [0.5527, 0.3541, 0.5916, 0.3755]}, {"w": "use", "b": [0.5976, 0.3541, 0.6252, 0.3755]}, {"w": "of", "b": [0.6311, 0.3541, 0.6479, 0.3755]}, {"w": "code", "b": [0.6539, 0.3541, 0.6931, 0.3755]}, {"w": "examples", "b": [0.6991, 0.3541, 0.7763, 0.3755]}, {"w": "falls", "b": [0.7822, 0.3541, 0.8157, 0.3755]}, {"w": "out‐", "b": [0.8217, 0.3541, 0.8571, 0.3755]}, {"w": "side", "b": [0.1429, 0.3731, 0.1759, 0.3945]}, {"w": "fair", "b": [0.1869, 0.3731, 0.2155, 0.3945]}, {"w": "use", "b": [0.2265, 0.3731, 0.2541, 0.3945]}, {"w": "or", "b": [0.2651, 0.3731, 0.2834, 0.3945]}, {"w": "the", "b": [0.2944, 0.3731, 0.3208, 0.3945]}, {"w": "permission", "b": [0.3317, 0.3731, 0.4248, 0.3945]}, {"w": "given", "b": [0.4358, 0.3731, 0.481, 0.3945]}, {"w": "above,", "b": [0.492, 0.3731, 0.5456, 0.3945]}, {"w": "feel", "b": [0.5566, 0.3731, 0.5857, 0.3945]}, {"w": "free", "b": [0.5967, 0.3731, 0.6283, 0.3945]}, {"w": "to", "b": [0.6393, 0.3731, 0.6563, 0.3945]}, {"w": "contact", "b": [0.6673, 0.3731, 0.7284, 0.3945]}, {"w": "us", "b": [0.7394, 0.3731, 0.7581, 0.3945]}, {"w": "at", "b": [0.7691, 0.3731, 0.7842, 0.3945]}, {"w": "permis‐", "b": [0.7952, 0.3729, 0.8571, 0.3945]}, {"w": "sions@oreilly.com.", "b": [0.1429, 0.392, 0.2904, 0.4136]}]}, {"id": "b_3", "type": "paragraph", "text": "O’Reilly Safari", "words": [{"w": "O’Reilly", "b": [0.1429, 0.4266, 0.236, 0.4608]}, {"w": "Safari", "b": [0.2419, 0.4266, 0.3136, 0.4608]}]}, {"id": "b_4", "type": "paragraph", "text": "Safari (formerly Safari Books Online) is a membership-based training and reference platform for enterprise, government, educators, and individuals.", "words": [{"w": "Safari", "b": [0.3353, 0.48, 0.3839, 0.5016]}, {"w": "(formerly", "b": [0.3905, 0.4802, 0.4707, 0.5016]}, {"w": "Safari", "b": [0.4772, 0.4802, 0.5249, 0.5016]}, {"w": "Books", "b": [0.5314, 0.4802, 0.5833, 0.5016]}, {"w": "Online)", "b": [0.5898, 0.4802, 0.6551, 0.5016]}, {"w": "is", "b": [0.6616, 0.4802, 0.6749, 0.5016]}, {"w": "a", "b": [0.6814, 0.4802, 0.6905, 0.5016]}, {"w": "membership-based", "b": [0.6971, 0.4802, 0.8571, 0.5016]}, {"w": "training", "b": [0.3353, 0.4993, 0.4022, 0.5207]}, {"w": "and", "b": [0.4113, 0.4993, 0.4429, 0.5207]}, {"w": "reference", "b": [0.4519, 0.4993, 0.5292, 0.5207]}, {"w": "platform", "b": [0.5382, 0.4993, 0.6111, 0.5207]}, {"w": "for", "b": [0.6202, 0.4993, 0.6447, 0.5207]}, {"w": "enterprise,", "b": [0.6538, 0.4993, 0.742, 0.5207]}, {"w": "government,", "b": [0.7511, 0.4993, 0.8571, 0.5207]}, {"w": "educators,", "b": [0.3353, 0.5183, 0.4209, 0.5397]}, {"w": "and", "b": [0.4256, 0.5183, 0.4572, 0.5397]}, {"w": "individuals.", "b": [0.4619, 0.5183, 0.5596, 0.5397]}]}, {"id": "b_5", "type": "paragraph", "text": "Members have access to thousands of books, training videos, Learning Paths, interac‐ tive tutorials, and curated playlists from over 250 publishers, including O’Reilly Media, Harvard Business Review, Prentice Hall Professional, Addison-Wesley Profes‐ sional, Microsoft Press, Sams, Que, Peachpit Press, Adobe, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, and Course Technology, among others.", "words": [{"w": "Members", "b": [0.1429, 0.5601, 0.2216, 0.5815]}, {"w": "have", "b": [0.2268, 0.5601, 0.2652, 0.5815]}, {"w": "access", "b": [0.2704, 0.5601, 0.3213, 0.5815]}, {"w": "to", "b": [0.3265, 0.5601, 0.3435, 0.5815]}, {"w": "thousands", "b": [0.3486, 0.5601, 0.4346, 0.5815]}, {"w": "of", "b": [0.4398, 0.5601, 0.4566, 0.5815]}, {"w": "books,", "b": [0.4618, 0.5601, 0.5163, 0.5815]}, {"w": "training", "b": [0.5215, 0.5601, 0.5885, 0.5815]}, {"w": "videos,", "b": [0.5936, 0.5601, 0.6518, 0.5815]}, {"w": "Learning", "b": [0.6569, 0.5601, 0.732, 0.5815]}, {"w": "Paths,", "b": [0.7372, 0.5601, 0.7871, 0.5815]}, {"w": "interac‐", "b": [0.7923, 0.5601, 0.8572, 0.5815]}, {"w": "tive", "b": [0.1429, 0.5791, 0.1733, 0.6005]}, {"w": "tutorials,", "b": [0.1835, 0.5791, 0.258, 0.6005]}, {"w": "and", "b": [0.2682, 0.5791, 0.2997, 0.6005]}, {"w": "curated", "b": [0.3099, 0.5791, 0.3725, 0.6005]}, {"w": "playlists", "b": [0.3826, 0.5791, 0.4497, 0.6005]}, {"w": "from", "b": [0.4598, 0.5791, 0.5014, 0.6005]}, {"w": "over", "b": [0.5116, 0.5791, 0.5485, 0.6005]}, {"w": "250", "b": [0.5586, 0.5791, 0.5886, 0.6005]}, {"w": "publishers,", "b": [0.5988, 0.5791, 0.69, 0.6005]}, {"w": "including", "b": [0.7002, 0.5791, 0.78, 0.6005]}, {"w": "O’Reilly", "b": [0.7902, 0.5791, 0.8571, 0.6005]}, {"w": "Media,", "b": [0.1429, 0.5981, 0.2002, 0.6196]}, {"w": "Harvard", "b": [0.2055, 0.5981, 0.276, 0.6196]}, {"w": "Business", "b": [0.2813, 0.5981, 0.3534, 0.6196]}, {"w": "Review,", "b": [0.3588, 0.5981, 0.4221, 0.6196]}, {"w": "Prentice", "b": [0.4275, 0.5981, 0.4964, 0.6196]}, {"w": "Hall", "b": [0.5017, 0.5981, 0.5369, 0.6196]}, {"w": "Professional,", "b": [0.5422, 0.5981, 0.6494, 0.6196]}, {"w": "Addison-Wesley", "b": [0.6547, 0.5981, 0.7916, 0.6196]}, {"w": "Profes‐", "b": [0.797, 0.5981, 0.8571, 0.6196]}, {"w": "sional,", "b": [0.1429, 0.6172, 0.1973, 0.6386]}, {"w": "Microsoft", "b": [0.204, 0.6172, 0.2861, 0.6386]}, {"w": "Press,", "b": [0.2928, 0.6172, 0.3411, 0.6386]}, {"w": "Sams,", "b": [0.3478, 0.6172, 0.3963, 0.6386]}, {"w": "Que,", "b": [0.403, 0.6172, 0.4432, 0.6386]}, {"w": "Peachpit", "b": [0.4498, 0.6172, 0.5213, 0.6386]}, {"w": "Press,", "b": [0.528, 0.6172, 0.5763, 0.6386]}, {"w": "Adobe,", "b": [0.583, 0.6172, 0.6427, 0.6386]}, {"w": "Focal", "b": [0.6494, 0.6172, 0.6939, 0.6386]}, {"w": "Press,", "b": [0.7006, 0.6172, 0.7489, 0.6386]}, {"w": "Cisco", "b": [0.7556, 0.6172, 0.8021, 0.6386]}, {"w": "Press,", "b": [0.8088, 0.6172, 0.8572, 0.6386]}, {"w": "John", "b": [0.1429, 0.6362, 0.1824, 0.6577]}, {"w": "Wiley", "b": [0.1923, 0.6362, 0.2409, 0.6577]}, {"w": "&", "b": [0.2508, 0.6362, 0.2656, 0.6577]}, {"w": "Sons,", "b": [0.2754, 0.6362, 0.3197, 0.6577]}, {"w": "Syngress,", "b": [0.3296, 0.6362, 0.4068, 0.6577]}, {"w": "Morgan", "b": [0.4166, 0.6362, 0.4833, 0.6577]}, {"w": "Kaufmann,", "b": [0.4931, 0.6362, 0.5869, 0.6577]}, {"w": "IBM", "b": [0.5967, 0.6362, 0.6347, 0.6577]}, {"w": "Redbooks,", "b": [0.6445, 0.6362, 0.7319, 0.6577]}, {"w": "Packt,", "b": [0.7417, 0.6362, 0.7924, 0.6577]}, {"w": "Adobe", "b": [0.8022, 0.6362, 0.8571, 0.6577]}, {"w": "Press,", "b": [0.1429, 0.6553, 0.1912, 0.6767]}, {"w": "FT", "b": [0.1984, 0.6553, 0.2223, 0.6767]}, {"w": "Press,", "b": [0.2295, 0.6553, 0.2779, 0.6767]}, {"w": "Apress,", "b": [0.2851, 0.6553, 0.3462, 0.6767]}, {"w": "Manning,", "b": [0.3534, 0.6553, 0.435, 0.6767]}, {"w": "New", "b": [0.4422, 0.6553, 0.4803, 0.6767]}, {"w": "Riders,", "b": [0.4875, 0.6553, 0.546, 0.6767]}, {"w": "McGraw-Hill,", "b": [0.5532, 0.6553, 0.6699, 0.6767]}, {"w": "Jones", "b": [0.6772, 0.6553, 0.7221, 0.6767]}, {"w": "&", "b": [0.7293, 0.6553, 0.7441, 0.6767]}, {"w": "Bartlett,", "b": [0.7513, 0.6553, 0.8184, 0.6767]}, {"w": "and", "b": [0.8256, 0.6553, 0.8571, 0.6767]}, {"w": "Course", "b": [0.1429, 0.6743, 0.2026, 0.6957]}, {"w": "Technology,", "b": [0.2074, 0.6743, 0.3079, 0.6957]}, {"w": "among", "b": [0.3126, 0.6743, 0.3706, 0.6957]}, {"w": "others.", "b": [0.3754, 0.6743, 0.4324, 0.6957]}]}, {"id": "b_6", "type": "equation", "text": "For more information, please visit http://oreilly.com/safari.", "words": [{"w": "For", "b": [0.1429, 0.7025, 0.1718, 0.7239]}, {"w": "more", "b": [0.1766, 0.7025, 0.2208, 0.7239]}, {"w": "information,", "b": [0.2256, 0.7025, 0.3316, 0.7239]}, {"w": "please", "b": [0.3363, 0.7025, 0.387, 0.7239]}, {"w": "visit", "b": [0.3917, 0.7025, 0.4265, 0.7239]}, {"w": "http://oreilly.com/safari.", "b": [0.4313, 0.7022, 0.6273, 0.7239]}]}, {"id": "b_7", "type": "paragraph", "text": "How to Contact Us", "words": [{"w": "How", "b": [0.1429, 0.7369, 0.199, 0.7711]}, {"w": "to", "b": [0.2049, 0.7369, 0.2311, 0.7711]}, {"w": "Contact", "b": [0.237, 0.7369, 0.3312, 0.7711]}, {"w": "Us", "b": [0.3372, 0.7369, 0.3668, 0.7711]}]}, {"id": "b_8", "type": "paragraph", "text": "Please address comments and questions concerning this book to the publisher:", "words": [{"w": "Please", "b": [0.1429, 0.778, 0.1944, 0.7995]}, {"w": "address", "b": [0.1991, 0.778, 0.2621, 0.7995]}, {"w": "comments", "b": [0.2668, 0.778, 0.3543, 0.7995]}, {"w": "and", "b": [0.359, 0.778, 0.3905, 0.7995]}, {"w": "questions", "b": [0.3953, 0.778, 0.4751, 0.7995]}, {"w": "concerning", "b": [0.4798, 0.778, 0.5742, 0.7995]}, {"w": "this", "b": [0.5789, 0.778, 0.6096, 0.7995]}, {"w": "book", "b": [0.6143, 0.778, 0.6565, 0.7995]}, {"w": "to", "b": [0.6612, 0.778, 0.6782, 0.7995]}, {"w": "the", "b": [0.6829, 0.778, 0.7093, 0.7995]}, {"w": "publisher:", "b": [0.714, 0.778, 0.798, 0.7995]}]}, {"id": "b_9", "type": "paragraph", "text": "O’Reilly Media, Inc. 1005 Gravenstein Highway North Sebastopol, CA 95472 800-998-9938 (in the United States or Canada)", "words": [{"w": "O’Reilly", "b": [0.1786, 0.8122, 0.2455, 0.8336]}, {"w": "Media,", "b": [0.2502, 0.8122, 0.3076, 0.8336]}, {"w": "Inc.", "b": [0.3123, 0.8122, 0.3444, 0.8336]}, {"w": "1005", "b": [0.1786, 0.8313, 0.2186, 0.8527]}, {"w": "Gravenstein", "b": [0.2233, 0.8313, 0.3244, 0.8527]}, {"w": "Highway", "b": [0.3292, 0.8313, 0.4037, 0.8527]}, {"w": "North", "b": [0.4084, 0.8313, 0.4592, 0.8527]}, {"w": "Sebastopol,", "b": [0.1786, 0.8503, 0.2732, 0.8717]}, {"w": "CA", "b": [0.2779, 0.8503, 0.3062, 0.8717]}, {"w": "95472", "b": [0.3109, 0.8503, 0.3609, 0.8717]}, {"w": "800-998-9938", "b": [0.1786, 0.8693, 0.2934, 0.8908]}, {"w": "(in", "b": [0.2981, 0.8693, 0.3223, 0.8908]}, {"w": "the", "b": [0.327, 0.8693, 0.3534, 0.8908]}, {"w": "United", "b": [0.3581, 0.8693, 0.4157, 0.8908]}, {"w": "States", "b": [0.4205, 0.8693, 0.4683, 0.8908]}, {"w": "or", "b": [0.473, 0.8693, 0.4914, 0.8908]}, {"w": "Canada)", "b": [0.4961, 0.8693, 0.567, 0.8908]}]}, {"id": "b_10", "type": "paragraph", "text": "xviii | Preface", "words": [{"w": "xviii", "b": [0.1429, 0.9225, 0.1671, 0.9388]}, {"w": "|", "b": [0.185, 0.9225, 0.1887, 0.9388]}, {"w": "Preface", "b": [0.2066, 0.9225, 0.2505, 0.9388]}]}]}, {"page": 21, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "707-829-0515 (international or local) 707-829-0104 (fax)", "words": [{"w": "707-829-0515", "b": [0.1786, 0.0791, 0.2934, 0.1005]}, {"w": "(international", "b": [0.2981, 0.0791, 0.4134, 0.1005]}, {"w": "or", "b": [0.4181, 0.0791, 0.4365, 0.1005]}, {"w": "local)", "b": [0.4412, 0.0791, 0.4875, 0.1005]}, {"w": "707-829-0104", "b": [0.1786, 0.0981, 0.2934, 0.1195]}, {"w": "(fax)", "b": [0.2981, 0.0981, 0.3377, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://bit.ly/hands-on-machine-learning- with-scikit-learn-and-tensorflow or https://homl.info/oreilly.", "words": [{"w": "We", "b": [0.1429, 0.1323, 0.1699, 0.1537]}, {"w": "have", "b": [0.1756, 0.1323, 0.214, 0.1537]}, {"w": "a", "b": [0.2196, 0.1323, 0.2288, 0.1537]}, {"w": "web", "b": [0.2344, 0.1323, 0.2681, 0.1537]}, {"w": "page", "b": [0.2738, 0.1323, 0.3125, 0.1537]}, {"w": "for", "b": [0.3181, 0.1323, 0.3426, 0.1537]}, {"w": "this", "b": [0.3483, 0.1323, 0.379, 0.1537]}, {"w": "book,", "b": [0.3847, 0.1323, 0.4316, 0.1537]}, {"w": "where", "b": [0.4372, 0.1323, 0.4881, 0.1537]}, {"w": "we", "b": [0.4937, 0.1323, 0.5168, 0.1537]}, {"w": "list", "b": [0.5225, 0.1323, 0.5473, 0.1537]}, {"w": "errata,", "b": [0.553, 0.1323, 0.6063, 0.1537]}, {"w": "examples,", "b": [0.612, 0.1323, 0.6939, 0.1537]}, {"w": "and", "b": [0.6996, 0.1323, 0.7311, 0.1537]}, {"w": "any", "b": [0.7368, 0.1323, 0.7664, 0.1537]}, {"w": "additional", "b": [0.772, 0.1323, 0.8571, 0.1537]}, {"w": "information.", "b": [0.1429, 0.1513, 0.2489, 0.1727]}, {"w": "You", "b": [0.2595, 0.1513, 0.2919, 0.1727]}, {"w": "can", "b": [0.3025, 0.1513, 0.3319, 0.1727]}, {"w": "access", "b": [0.3425, 0.1513, 0.3934, 0.1727]}, {"w": "this", "b": [0.4041, 0.1513, 0.4348, 0.1727]}, {"w": "page", "b": [0.4455, 0.1513, 0.4841, 0.1727]}, {"w": "at", "b": [0.4948, 0.1513, 0.5099, 0.1727]}, {"w": "http://bit.ly/hands-on-machine-learning-", "b": [0.5205, 0.1511, 0.8571, 0.1727]}, {"w": "with-scikit-learn-and-tensorflow", "b": [0.1429, 0.1702, 0.4092, 0.1918]}, {"w": "or", "b": [0.4139, 0.1704, 0.4323, 0.1918]}, {"w": "https://homl.info/oreilly.", "b": [0.437, 0.1702, 0.6346, 0.1918]}]}, {"id": "b_2", "type": "paragraph", "text": "To comment or ask technical questions about this book, send email to bookques‐ tions@oreilly.com.", "words": [{"w": "To", "b": [0.1429, 0.1985, 0.1643, 0.2199]}, {"w": "comment", "b": [0.1729, 0.1985, 0.2527, 0.2199]}, {"w": "or", "b": [0.2613, 0.1985, 0.2797, 0.2199]}, {"w": "ask", "b": [0.2883, 0.1985, 0.3154, 0.2199]}, {"w": "technical", "b": [0.324, 0.1985, 0.3994, 0.2199]}, {"w": "questions", "b": [0.408, 0.1985, 0.4878, 0.2199]}, {"w": "about", "b": [0.4964, 0.1985, 0.5442, 0.2199]}, {"w": "this", "b": [0.5528, 0.1985, 0.5835, 0.2199]}, {"w": "book,", "b": [0.5921, 0.1985, 0.639, 0.2199]}, {"w": "send", "b": [0.6476, 0.1985, 0.6865, 0.2199]}, {"w": "email", "b": [0.6951, 0.1985, 0.741, 0.2199]}, {"w": "to", "b": [0.7496, 0.1985, 0.7666, 0.2199]}, {"w": "bookques‐", "b": [0.7752, 0.1983, 0.8572, 0.2199]}, {"w": "tions@oreilly.com.", "b": [0.1429, 0.2173, 0.2898, 0.2389]}]}, {"id": "b_3", "type": "paragraph", "text": "For more information about our books, courses, conferences, and news, see our web‐ site at http://www.oreilly.com.", "words": [{"w": "For", "b": [0.1429, 0.2457, 0.1718, 0.2671]}, {"w": "more", "b": [0.1771, 0.2457, 0.2213, 0.2671]}, {"w": "information", "b": [0.2266, 0.2457, 0.3278, 0.2671]}, {"w": "about", "b": [0.333, 0.2457, 0.3808, 0.2671]}, {"w": "our", "b": [0.386, 0.2457, 0.4154, 0.2671]}, {"w": "books,", "b": [0.4207, 0.2457, 0.4752, 0.2671]}, {"w": "courses,", "b": [0.4805, 0.2457, 0.5476, 0.2671]}, {"w": "conferences,", "b": [0.5528, 0.2457, 0.6567, 0.2671]}, {"w": "and", "b": [0.6619, 0.2457, 0.6935, 0.2671]}, {"w": "news,", "b": [0.6987, 0.2457, 0.7456, 0.2671]}, {"w": "see", "b": [0.7508, 0.2457, 0.7762, 0.2671]}, {"w": "our", "b": [0.7814, 0.2457, 0.8108, 0.2671]}, {"w": "web‐", "b": [0.816, 0.2457, 0.8571, 0.2671]}, {"w": "site", "b": [0.1429, 0.2647, 0.1713, 0.2861]}, {"w": "at", "b": [0.176, 0.2647, 0.1911, 0.2861]}, {"w": "http://www.oreilly.com.", "b": [0.1959, 0.2645, 0.3852, 0.2861]}]}, {"id": "b_4", "type": "equation", "text": "Find us on Facebook: http://facebook.com/oreilly", "words": [{"w": "Find", "b": [0.1429, 0.2928, 0.1819, 0.3142]}, {"w": "us", "b": [0.1866, 0.2928, 0.2053, 0.3142]}, {"w": "on", "b": [0.21, 0.2928, 0.232, 0.3142]}, {"w": "Facebook:", "b": [0.2368, 0.2928, 0.3211, 0.3142]}, {"w": "http://facebook.com/oreilly", "b": [0.3258, 0.2926, 0.5429, 0.3142]}]}, {"id": "b_5", "type": "equation", "text": "Follow us on Twitter: http://twitter.com/oreillymedia", "words": [{"w": "Follow", "b": [0.1429, 0.3209, 0.1995, 0.3423]}, {"w": "us", "b": [0.2043, 0.3209, 0.223, 0.3423]}, {"w": "on", "b": [0.2277, 0.3209, 0.2497, 0.3423]}, {"w": "Twitter:", "b": [0.2545, 0.3209, 0.3202, 0.3423]}, {"w": "http://twitter.com/oreillymedia", "b": [0.3249, 0.3207, 0.5756, 0.3423]}]}, {"id": "b_6", "type": "equation", "text": "Watch us on YouTube: http://www.youtube.com/oreillymedia", "words": [{"w": "Watch", "b": [0.1429, 0.3491, 0.1961, 0.3705]}, {"w": "us", "b": [0.2008, 0.3491, 0.2195, 0.3705]}, {"w": "on", "b": [0.2242, 0.3491, 0.2462, 0.3705]}, {"w": "YouTube:", "b": [0.251, 0.3491, 0.3294, 0.3705]}, {"w": "http://www.youtube.com/oreillymedia", "b": [0.3341, 0.3488, 0.6425, 0.3705]}]}, {"id": "b_7", "type": "paragraph", "text": "Changes in the Second Edition", "words": [{"w": "Changes", "b": [0.1429, 0.3835, 0.2471, 0.4177]}, {"w": "in", "b": [0.253, 0.3835, 0.277, 0.4177]}, {"w": "the", "b": [0.2829, 0.3835, 0.3247, 0.4177]}, {"w": "Second", "b": [0.3307, 0.3835, 0.4191, 0.4177]}, {"w": "Edition", "b": [0.425, 0.3835, 0.5129, 0.4177]}]}, {"id": "b_8", "type": "paragraph", "text": "This second edition has five main objectives:", "words": [{"w": "This", "b": [0.1429, 0.4246, 0.1801, 0.4461]}, {"w": "second", "b": [0.1848, 0.4246, 0.2431, 0.4461]}, {"w": "edition", "b": [0.2479, 0.4246, 0.3072, 0.4461]}, {"w": "has", "b": [0.312, 0.4246, 0.3399, 0.4461]}, {"w": "five", "b": [0.3446, 0.4246, 0.3749, 0.4461]}, {"w": "main", "b": [0.3796, 0.4246, 0.4228, 0.4461]}, {"w": "objectives:", "b": [0.4275, 0.4246, 0.5146, 0.4461]}]}, {"id": "b_9", "type": "paragraph", "text": "1. Cover additional topics: additional unsupervised learning techniques (including clustering, anomaly detection, density estimation and mixture models), addi‐ tional techniques for training deep nets (including self-normalized networks), additional computer vision techniques (including the Xception, SENet, object detection with YOLO, and semantic segmentation using R-CNN), handling sequences using CNNs (including WaveNet), natural language processing using RNNs, CNNs and Transformers, generative adversarial networks, deploying Ten‐ sorFlow models, and more.", "words": [{"w": "1.", "b": [0.1534, 0.4588, 0.1681, 0.4802]}, {"w": "Cover", "b": [0.1786, 0.4588, 0.2293, 0.4802]}, {"w": "additional", "b": [0.2356, 0.4588, 0.3207, 0.4802]}, {"w": "topics:", "b": [0.3271, 0.4588, 0.3818, 0.4802]}, {"w": "additional", "b": [0.3881, 0.4588, 0.4732, 0.4802]}, {"w": "unsupervised", "b": [0.4796, 0.4588, 0.5916, 0.4802]}, {"w": "learning", "b": [0.5979, 0.4588, 0.667, 0.4802]}, {"w": "techniques", "b": [0.6734, 0.4588, 0.7637, 0.4802]}, {"w": "(including", "b": [0.7701, 0.4588, 0.8571, 0.4802]}, {"w": "clustering,", "b": [0.1786, 0.4779, 0.2658, 0.4993]}, {"w": "anomaly", "b": [0.275, 0.4779, 0.3472, 0.4993]}, {"w": "detection,", "b": [0.3563, 0.4779, 0.4389, 0.4993]}, {"w": "density", "b": [0.4481, 0.4779, 0.5085, 0.4993]}, {"w": "estimation", "b": [0.5177, 0.4779, 0.6059, 0.4993]}, {"w": "and", "b": [0.615, 0.4779, 0.6466, 0.4993]}, {"w": "mixture", "b": [0.6558, 0.4779, 0.7222, 0.4993]}, {"w": "models),", "b": [0.7314, 0.4779, 0.8038, 0.4993]}, {"w": "addi‐", "b": [0.813, 0.4779, 0.8571, 0.4993]}, {"w": "tional", "b": [0.1786, 0.4969, 0.2269, 0.5183]}, {"w": "techniques", "b": [0.2354, 0.4969, 0.3257, 0.5183]}, {"w": "for", "b": [0.3342, 0.4969, 0.3587, 0.5183]}, {"w": "training", "b": [0.3671, 0.4969, 0.4341, 0.5183]}, {"w": "deep", "b": [0.4425, 0.4969, 0.4821, 0.5183]}, {"w": "nets", "b": [0.4906, 0.4969, 0.5248, 0.5183]}, {"w": "(including", "b": [0.5333, 0.4969, 0.6203, 0.5183]}, {"w": "self-normalized", "b": [0.6288, 0.4969, 0.7595, 0.5183]}, {"w": "networks),", "b": [0.768, 0.4969, 0.8571, 0.5183]}, {"w": "additional", "b": [0.1786, 0.5159, 0.2637, 0.5374]}, {"w": "computer", "b": [0.2724, 0.5159, 0.3535, 0.5374]}, {"w": "vision", "b": [0.3622, 0.5159, 0.4127, 0.5374]}, {"w": "techniques", "b": [0.4215, 0.5159, 0.5118, 0.5374]}, {"w": "(including", "b": [0.5206, 0.5159, 0.6076, 0.5374]}, {"w": "the", "b": [0.6164, 0.5159, 0.6427, 0.5374]}, {"w": "Xception,", "b": [0.6515, 0.5159, 0.7324, 0.5374]}, {"w": "SENet,", "b": [0.7412, 0.5159, 0.7978, 0.5374]}, {"w": "object", "b": [0.8066, 0.5159, 0.8571, 0.5374]}, {"w": "detection", "b": [0.1786, 0.535, 0.2564, 0.5564]}, {"w": "with", "b": [0.2677, 0.535, 0.305, 0.5564]}, {"w": "YOLO,", "b": [0.3163, 0.535, 0.3749, 0.5564]}, {"w": "and", "b": [0.3862, 0.535, 0.4177, 0.5564]}, {"w": "semantic", "b": [0.429, 0.535, 0.5034, 0.5564]}, {"w": "segmentation", "b": [0.5147, 0.535, 0.627, 0.5564]}, {"w": "using", "b": [0.6382, 0.535, 0.6837, 0.5564]}, {"w": "R-CNN),", "b": [0.695, 0.535, 0.7712, 0.5564]}, {"w": "handling", "b": [0.7825, 0.535, 0.8572, 0.5564]}, {"w": "sequences", "b": [0.1786, 0.554, 0.2623, 0.5755]}, {"w": "using", "b": [0.2691, 0.554, 0.3146, 0.5755]}, {"w": "CNNs", "b": [0.3214, 0.554, 0.3733, 0.5755]}, {"w": "(including", "b": [0.3801, 0.554, 0.4671, 0.5755]}, {"w": "WaveNet),", "b": [0.4739, 0.554, 0.5615, 0.5755]}, {"w": "natural", "b": [0.5683, 0.554, 0.628, 0.5755]}, {"w": "language", "b": [0.6348, 0.554, 0.7092, 0.5755]}, {"w": "processing", "b": [0.7159, 0.554, 0.8049, 0.5755]}, {"w": "using", "b": [0.8117, 0.554, 0.8571, 0.5755]}, {"w": "RNNs,", "b": [0.1786, 0.5731, 0.2343, 0.5945]}, {"w": "CNNs", "b": [0.2395, 0.5731, 0.2914, 0.5945]}, {"w": "and", "b": [0.2966, 0.5731, 0.3282, 0.5945]}, {"w": "Transformers,", "b": [0.3334, 0.5731, 0.451, 0.5945]}, {"w": "generative", "b": [0.4562, 0.5731, 0.542, 0.5945]}, {"w": "adversarial", "b": [0.5472, 0.5731, 0.6381, 0.5945]}, {"w": "networks,", "b": [0.6433, 0.5731, 0.7253, 0.5945]}, {"w": "deploying", "b": [0.7305, 0.5731, 0.8135, 0.5945]}, {"w": "Ten‐", "b": [0.8187, 0.5731, 0.8571, 0.5945]}, {"w": "sorFlow", "b": [0.1786, 0.5921, 0.2458, 0.6136]}, {"w": "models,", "b": [0.2505, 0.5921, 0.3157, 0.6136]}, {"w": "and", "b": [0.3204, 0.5921, 0.352, 0.6136]}, {"w": "more.", "b": [0.3567, 0.5921, 0.4057, 0.6136]}]}, {"id": "b_10", "type": "paragraph", "text": "2. Update the book to mention some of the latest results from Deep Learning research.", "words": [{"w": "2.", "b": [0.1534, 0.6172, 0.1682, 0.6386]}, {"w": "Update", "b": [0.1786, 0.6172, 0.239, 0.6386]}, {"w": "the", "b": [0.2486, 0.6172, 0.275, 0.6386]}, {"w": "book", "b": [0.2847, 0.6172, 0.3268, 0.6386]}, {"w": "to", "b": [0.3365, 0.6172, 0.3535, 0.6386]}, {"w": "mention", "b": [0.3632, 0.6172, 0.434, 0.6386]}, {"w": "some", "b": [0.4437, 0.6172, 0.4879, 0.6386]}, {"w": "of", "b": [0.4976, 0.6172, 0.5144, 0.6386]}, {"w": "the", "b": [0.524, 0.6172, 0.5504, 0.6386]}, {"w": "latest", "b": [0.5601, 0.6172, 0.6033, 0.6386]}, {"w": "results", "b": [0.613, 0.6172, 0.6675, 0.6386]}, {"w": "from", "b": [0.6772, 0.6172, 0.7188, 0.6386]}, {"w": "Deep", "b": [0.7285, 0.6172, 0.7724, 0.6386]}, {"w": "Learning", "b": [0.7821, 0.6172, 0.8571, 0.6386]}, {"w": "research.", "b": [0.1786, 0.6363, 0.2532, 0.6577]}]}, {"id": "b_11", "type": "paragraph", "text": "3. Migrate all TensorFlow chapters to TensorFlow 2, and use TensorFlow’s imple‐ mentation of the Keras API (called tf.keras) whenever possible, to simplify the code examples.", "words": [{"w": "3.", "b": [0.1534, 0.6614, 0.1682, 0.6828]}, {"w": "Migrate", "b": [0.1786, 0.6614, 0.2441, 0.6828]}, {"w": "all", "b": [0.2514, 0.6614, 0.2711, 0.6828]}, {"w": "TensorFlow", "b": [0.2783, 0.6614, 0.3766, 0.6828]}, {"w": "chapters", "b": [0.3838, 0.6614, 0.454, 0.6828]}, {"w": "to", "b": [0.4613, 0.6614, 0.4783, 0.6828]}, {"w": "TensorFlow", "b": [0.4855, 0.6614, 0.5838, 0.6828]}, {"w": "2,", "b": [0.591, 0.6614, 0.6058, 0.6828]}, {"w": "and", "b": [0.613, 0.6614, 0.6446, 0.6828]}, {"w": "use", "b": [0.6518, 0.6614, 0.6794, 0.6828]}, {"w": "TensorFlow’s", "b": [0.6866, 0.6614, 0.7952, 0.6828]}, {"w": "imple‐", "b": [0.8024, 0.6614, 0.8571, 0.6828]}, {"w": "mentation", "b": [0.1786, 0.6804, 0.2646, 0.7018]}, {"w": "of", "b": [0.272, 0.6804, 0.2888, 0.7018]}, {"w": "the", "b": [0.2962, 0.6804, 0.3226, 0.7018]}, {"w": "Keras", "b": [0.33, 0.6804, 0.3769, 0.7018]}, {"w": "API", "b": [0.3844, 0.6804, 0.4176, 0.7018]}, {"w": "(called", "b": [0.425, 0.6804, 0.4806, 0.7018]}, {"w": "tf.keras)", "b": [0.4881, 0.6804, 0.5562, 0.7018]}, {"w": "whenever", "b": [0.5637, 0.6804, 0.6444, 0.7018]}, {"w": "possible,", "b": [0.6519, 0.6804, 0.7237, 0.7018]}, {"w": "to", "b": [0.7312, 0.6804, 0.7482, 0.7018]}, {"w": "simplify", "b": [0.7556, 0.6804, 0.8234, 0.7018]}, {"w": "the", "b": [0.8308, 0.6804, 0.8571, 0.7018]}, {"w": "code", "b": [0.1786, 0.6995, 0.2179, 0.7209]}, {"w": "examples.", "b": [0.2226, 0.6995, 0.3045, 0.7209]}]}, {"id": "b_12", "type": "paragraph", "text": "4. Update the code examples to use the latest version of Scikit-Learn, NumPy, Pan‐ das, Matplotlib and other libraries.", "words": [{"w": "4.", "b": [0.1534, 0.7246, 0.1682, 0.746]}, {"w": "Update", "b": [0.1786, 0.7246, 0.239, 0.746]}, {"w": "the", "b": [0.2447, 0.7246, 0.2711, 0.746]}, {"w": "code", "b": [0.2768, 0.7246, 0.3161, 0.746]}, {"w": "examples", "b": [0.3219, 0.7246, 0.3991, 0.746]}, {"w": "to", "b": [0.4049, 0.7246, 0.4219, 0.746]}, {"w": "use", "b": [0.4276, 0.7246, 0.4552, 0.746]}, {"w": "the", "b": [0.461, 0.7246, 0.4873, 0.746]}, {"w": "latest", "b": [0.4931, 0.7246, 0.5363, 0.746]}, {"w": "version", "b": [0.5421, 0.7246, 0.6036, 0.746]}, {"w": "of", "b": [0.6093, 0.7246, 0.6261, 0.746]}, {"w": "Scikit-Learn,", "b": [0.6319, 0.7246, 0.739, 0.746]}, {"w": "NumPy,", "b": [0.7447, 0.7246, 0.8121, 0.746]}, {"w": "Pan‐", "b": [0.8179, 0.7246, 0.8571, 0.746]}, {"w": "das,", "b": [0.1786, 0.7436, 0.2111, 0.765]}, {"w": "Matplotlib", "b": [0.2158, 0.7436, 0.3038, 0.765]}, {"w": "and", "b": [0.3085, 0.7436, 0.34, 0.765]}, {"w": "other", "b": [0.3448, 0.7436, 0.3894, 0.765]}, {"w": "libraries.", "b": [0.3942, 0.7436, 0.4671, 0.765]}]}, {"id": "b_13", "type": "paragraph", "text": "5. Clarify some sections and fix some errors, thanks to plenty of great feedback from readers.", "words": [{"w": "5.", "b": [0.1534, 0.7687, 0.1682, 0.7901]}, {"w": "Clarify", "b": [0.1786, 0.7687, 0.2362, 0.7901]}, {"w": "some", "b": [0.2446, 0.7687, 0.2888, 0.7901]}, {"w": "sections", "b": [0.2972, 0.7687, 0.3641, 0.7901]}, {"w": "and", "b": [0.3725, 0.7687, 0.404, 0.7901]}, {"w": "fix", "b": [0.4124, 0.7687, 0.434, 0.7901]}, {"w": "some", "b": [0.4423, 0.7687, 0.4865, 0.7901]}, {"w": "errors,", "b": [0.4949, 0.7687, 0.55, 0.7901]}, {"w": "thanks", "b": [0.5583, 0.7687, 0.6143, 0.7901]}, {"w": "to", "b": [0.6227, 0.7687, 0.6397, 0.7901]}, {"w": "plenty", "b": [0.6481, 0.7687, 0.7, 0.7901]}, {"w": "of", "b": [0.7084, 0.7687, 0.7252, 0.7901]}, {"w": "great", "b": [0.7336, 0.7687, 0.775, 0.7901]}, {"w": "feedback", "b": [0.7834, 0.7687, 0.8571, 0.7901]}, {"w": "from", "b": [0.1786, 0.7878, 0.2202, 0.8092]}, {"w": "readers.", "b": [0.2249, 0.7878, 0.2906, 0.8092]}]}, {"id": "b_14", "type": "paragraph", "text": "Some chapters were added, others were rewritten and a few were reordered. Table P-1 shows the mapping between the 1st edition chapters and the 2nd edition chapters:", "words": [{"w": "Some", "b": [0.1429, 0.8219, 0.1893, 0.8433]}, {"w": "chapters", "b": [0.1942, 0.8219, 0.2643, 0.8433]}, {"w": "were", "b": [0.2692, 0.8219, 0.3089, 0.8433]}, {"w": "added,", "b": [0.3138, 0.8219, 0.3695, 0.8433]}, {"w": "others", "b": [0.3744, 0.8219, 0.4267, 0.8433]}, {"w": "were", "b": [0.4316, 0.8219, 0.4713, 0.8433]}, {"w": "rewritten", "b": [0.4762, 0.8219, 0.5533, 0.8433]}, {"w": "and", "b": [0.5582, 0.8219, 0.5897, 0.8433]}, {"w": "a", "b": [0.5946, 0.8219, 0.6038, 0.8433]}, {"w": "few", "b": [0.6086, 0.8219, 0.6379, 0.8433]}, {"w": "were", "b": [0.6428, 0.8219, 0.6825, 0.8433]}, {"w": "reordered.", "b": [0.6874, 0.8219, 0.7745, 0.8433]}, {"w": "Table", "b": [0.7794, 0.8219, 0.8242, 0.8433]}, {"w": "P-1", "b": [0.8289, 0.8219, 0.857, 0.8433]}, {"w": "shows", "b": [0.1429, 0.841, 0.1942, 0.8624]}, {"w": "the", "b": [0.1989, 0.841, 0.2252, 0.8624]}, {"w": "mapping", "b": [0.23, 0.841, 0.3043, 0.8624]}, {"w": "between", "b": [0.3091, 0.841, 0.3782, 0.8624]}, {"w": "the", "b": [0.383, 0.841, 0.4093, 0.8624]}, {"w": "1st", "b": [0.414, 0.841, 0.4324, 0.8624]}, {"w": "edition", "b": [0.4371, 0.841, 0.4965, 0.8624]}, {"w": "chapters", "b": [0.5013, 0.841, 0.5715, 0.8624]}, {"w": "and", "b": [0.5762, 0.841, 0.6077, 0.8624]}, {"w": "the", "b": [0.6125, 0.841, 0.6388, 0.8624]}, {"w": "2nd", "b": [0.6435, 0.841, 0.667, 0.8624]}, {"w": "edition", "b": [0.6717, 0.841, 0.7311, 0.8624]}, {"w": "chapters:", "b": [0.7358, 0.841, 0.8108, 0.8624]}]}, {"id": "b_15", "type": "paragraph", "text": "Preface | xix", "words": [{"w": "Preface", "b": [0.7569, 0.9225, 0.8008, 0.9388]}, {"w": "|", "b": [0.8187, 0.9225, 0.8224, 0.9388]}, {"w": "xix", "b": [0.8403, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 22, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Table P-1. Chapter mapping between 1st and 2nd edition", "words": [{"w": "Table", "b": [0.1429, 0.079, 0.1844, 0.0996]}, {"w": "P-1.", "b": [0.189, 0.079, 0.2203, 0.0996]}, {"w": "Chapter", "b": [0.2248, 0.079, 0.2874, 0.0996]}, {"w": "mapping", "b": [0.292, 0.079, 0.3597, 0.0996]}, {"w": "between", "b": [0.3642, 0.079, 0.4272, 0.0996]}, {"w": "1st", "b": [0.4317, 0.079, 0.4491, 0.0996]}, {"w": "and", "b": [0.4537, 0.079, 0.4836, 0.0996]}, {"w": "2nd", "b": [0.4881, 0.079, 0.5105, 0.0996]}, {"w": "edition", "b": [0.515, 0.079, 0.5687, 0.0996]}]}, {"id": "b_1", "type": "paragraph", "text": "1st Ed. chapter 2nd Ed. Chapter % Changes 2nd Ed. Title 1 1 <10% The Machine Learning Landscape", "words": [{"w": "1st", "b": [0.15, 0.1068, 0.1647, 0.1238]}, {"w": "Ed.", "b": [0.1681, 0.1075, 0.1863, 0.1238]}, {"w": "chapter", "b": [0.1897, 0.1075, 0.2347, 0.1238]}, {"w": "2nd", "b": [0.249, 0.1068, 0.267, 0.1238]}, {"w": "Ed.", "b": [0.2704, 0.1075, 0.2886, 0.1238]}, {"w": "Chapter", "b": [0.292, 0.1075, 0.3383, 0.1238]}, {"w": "%", "b": [0.3526, 0.1075, 0.3643, 0.1238]}, {"w": "Changes", "b": [0.3677, 0.1075, 0.4172, 0.1238]}, {"w": "2nd", "b": [0.454, 0.1068, 0.472, 0.1238]}, {"w": "Ed.", "b": [0.4754, 0.1075, 0.4936, 0.1238]}, {"w": "Title", "b": [0.497, 0.1075, 0.5232, 0.1238]}, {"w": "1", "b": [0.15, 0.1279, 0.1569, 0.144]}, {"w": "1", "b": [0.249, 0.1279, 0.2559, 0.144]}, {"w": "<10%", "b": [0.3526, 0.1279, 0.3885, 0.144]}, {"w": "The", "b": [0.454, 0.1279, 0.474, 0.144]}, {"w": "Machine", "b": [0.4774, 0.1279, 0.5242, 0.144]}, {"w": "Learning", "b": [0.5277, 0.1279, 0.5761, 0.144]}, {"w": "Landscape", "b": [0.5795, 0.1279, 0.6371, 0.144]}]}, {"id": "b_2", "type": "equation", "text": "2 2 <10% End-to-End Machine Learning Project", "words": [{"w": "2", "b": [0.15, 0.1489, 0.1569, 0.165]}, {"w": "2", "b": [0.249, 0.1489, 0.2559, 0.165]}, {"w": "<10%", "b": [0.3526, 0.1489, 0.3885, 0.165]}, {"w": "End-to-End", "b": [0.454, 0.1489, 0.5167, 0.165]}, {"w": "Machine", "b": [0.5201, 0.1489, 0.5669, 0.165]}, {"w": "Learning", "b": [0.5703, 0.1489, 0.6188, 0.165]}, {"w": "Project", "b": [0.6222, 0.1489, 0.6603, 0.165]}]}, {"id": "b_3", "type": "paragraph", "text": "3 3 <10% Classification", "words": [{"w": "3", "b": [0.15, 0.1699, 0.1569, 0.186]}, {"w": "3", "b": [0.249, 0.1699, 0.2559, 0.186]}, {"w": "<10%", "b": [0.3526, 0.1699, 0.3885, 0.186]}, {"w": "Classification", "b": [0.454, 0.1699, 0.5254, 0.186]}]}, {"id": "b_4", "type": "paragraph", "text": "4 4 <10% Training Models", "words": [{"w": "4", "b": [0.15, 0.1909, 0.1569, 0.207]}, {"w": "4", "b": [0.249, 0.1909, 0.2559, 0.207]}, {"w": "<10%", "b": [0.3526, 0.1909, 0.3885, 0.207]}, {"w": "Training", "b": [0.454, 0.1909, 0.4994, 0.207]}, {"w": "Models", "b": [0.5028, 0.1909, 0.5425, 0.207]}]}, {"id": "b_5", "type": "paragraph", "text": "5 5 <10% Support Vector Machines", "words": [{"w": "5", "b": [0.15, 0.2119, 0.1569, 0.228]}, {"w": "5", "b": [0.249, 0.2119, 0.2559, 0.228]}, {"w": "<10%", "b": [0.3526, 0.2119, 0.3885, 0.228]}, {"w": "Support", "b": [0.454, 0.2119, 0.4976, 0.228]}, {"w": "Vector", "b": [0.501, 0.2119, 0.5362, 0.228]}, {"w": "Machines", "b": [0.5396, 0.2119, 0.5916, 0.228]}]}, {"id": "b_6", "type": "paragraph", "text": "6 6 <10% Decision Trees", "words": [{"w": "6", "b": [0.15, 0.2329, 0.1569, 0.2491]}, {"w": "6", "b": [0.249, 0.2329, 0.2559, 0.2491]}, {"w": "<10%", "b": [0.3526, 0.2329, 0.3885, 0.2491]}, {"w": "Decision", "b": [0.454, 0.2329, 0.4996, 0.2491]}, {"w": "Trees", "b": [0.503, 0.2329, 0.5319, 0.2491]}]}, {"id": "b_7", "type": "paragraph", "text": "7 7 <10% Ensemble Learning and Random Forests", "words": [{"w": "7", "b": [0.15, 0.2539, 0.1569, 0.2701]}, {"w": "7", "b": [0.249, 0.2539, 0.2559, 0.2701]}, {"w": "<10%", "b": [0.3526, 0.2539, 0.3885, 0.2701]}, {"w": "Ensemble", "b": [0.454, 0.2539, 0.5073, 0.2701]}, {"w": "Learning", "b": [0.5107, 0.2539, 0.5591, 0.2701]}, {"w": "and", "b": [0.5625, 0.2539, 0.5834, 0.2701]}, {"w": "Random", "b": [0.5868, 0.2539, 0.6328, 0.2701]}, {"w": "Forests", "b": [0.6362, 0.2539, 0.675, 0.2701]}]}, {"id": "b_8", "type": "paragraph", "text": "8 8 <10% Dimensionality Reduction", "words": [{"w": "8", "b": [0.15, 0.275, 0.1569, 0.2911]}, {"w": "8", "b": [0.249, 0.275, 0.2559, 0.2911]}, {"w": "<10%", "b": [0.3526, 0.275, 0.3885, 0.2911]}, {"w": "Dimensionality", "b": [0.454, 0.275, 0.5365, 0.2911]}, {"w": "Reduction", "b": [0.5399, 0.275, 0.5952, 0.2911]}]}, {"id": "b_9", "type": "equation", "text": "N/A 9 100% new Unsupervised Learning Techniques", "words": [{"w": "N/A", "b": [0.15, 0.296, 0.1711, 0.3121]}, {"w": "9", "b": [0.249, 0.296, 0.2559, 0.3121]}, {"w": "100%", "b": [0.3526, 0.296, 0.3848, 0.3121]}, {"w": "new", "b": [0.3882, 0.296, 0.412, 0.3121]}, {"w": "Unsupervised", "b": [0.454, 0.296, 0.5279, 0.3121]}, {"w": "Learning", "b": [0.5313, 0.296, 0.5798, 0.3121]}, {"w": "Techniques", "b": [0.5832, 0.296, 0.645, 0.3121]}]}, {"id": "b_10", "type": "paragraph", "text": "10 10 ~75% Introduction to Artificial Neural Networks with Keras", "words": [{"w": "10", "b": [0.15, 0.317, 0.1638, 0.3331]}, {"w": "10", "b": [0.249, 0.317, 0.2628, 0.3331]}, {"w": "~75%", "b": [0.3526, 0.317, 0.3885, 0.3331]}, {"w": "Introduction", "b": [0.454, 0.317, 0.5221, 0.3331]}, {"w": "to", "b": [0.5255, 0.317, 0.5369, 0.3331]}, {"w": "Artificial", "b": [0.5403, 0.317, 0.5864, 0.3331]}, {"w": "Neural", "b": [0.5898, 0.317, 0.626, 0.3331]}, {"w": "Networks", "b": [0.6294, 0.317, 0.6816, 0.3331]}, {"w": "with", "b": [0.685, 0.317, 0.7102, 0.3331]}, {"w": "Keras", "b": [0.7136, 0.317, 0.7434, 0.3331]}]}, {"id": "b_11", "type": "paragraph", "text": "11 11 ~50% Training Deep Neural Networks", "words": [{"w": "11", "b": [0.15, 0.338, 0.1637, 0.3541]}, {"w": "11", "b": [0.249, 0.338, 0.2628, 0.3541]}, {"w": "~50%", "b": [0.3526, 0.338, 0.3885, 0.3541]}, {"w": "Training", "b": [0.454, 0.338, 0.4994, 0.3541]}, {"w": "Deep", "b": [0.5028, 0.338, 0.5308, 0.3541]}, {"w": "Neural", "b": [0.5342, 0.338, 0.5705, 0.3541]}, {"w": "Networks", "b": [0.5739, 0.338, 0.6261, 0.3541]}]}, {"id": "b_12", "type": "paragraph", "text": "9 12 100% rewritten Custom Models and Training with TensorFlow", "words": [{"w": "9", "b": [0.15, 0.359, 0.1569, 0.3751]}, {"w": "12", "b": [0.249, 0.359, 0.2628, 0.3751]}, {"w": "100%", "b": [0.3526, 0.359, 0.3848, 0.3751]}, {"w": "rewritten", "b": [0.3882, 0.359, 0.4397, 0.3751]}, {"w": "Custom", "b": [0.454, 0.359, 0.4954, 0.3751]}, {"w": "Models", "b": [0.4988, 0.359, 0.5385, 0.3751]}, {"w": "and", "b": [0.5419, 0.359, 0.5628, 0.3751]}, {"w": "Training", "b": [0.5662, 0.359, 0.6116, 0.3751]}, {"w": "with", "b": [0.615, 0.359, 0.6401, 0.3751]}, {"w": "TensorFlow", "b": [0.6435, 0.359, 0.7065, 0.3751]}]}, {"id": "b_13", "type": "paragraph", "text": "Part of 12 13 100% rewritten Loading and Preprocessing Data with TensorFlow", "words": [{"w": "Part", "b": [0.15, 0.38, 0.1726, 0.3961]}, {"w": "of", "b": [0.176, 0.38, 0.1869, 0.3961]}, {"w": "12", "b": [0.1903, 0.38, 0.2041, 0.3961]}, {"w": "13", "b": [0.249, 0.38, 0.2628, 0.3961]}, {"w": "100%", "b": [0.3526, 0.38, 0.3848, 0.3961]}, {"w": "rewritten", "b": [0.3882, 0.38, 0.4397, 0.3961]}, {"w": "Loading", "b": [0.454, 0.38, 0.4982, 0.3961]}, {"w": "and", "b": [0.5016, 0.38, 0.5225, 0.3961]}, {"w": "Preprocessing", "b": [0.5259, 0.38, 0.6022, 0.3961]}, {"w": "Data", "b": [0.6056, 0.38, 0.6311, 0.3961]}, {"w": "with", "b": [0.6345, 0.38, 0.6596, 0.3961]}, {"w": "TensorFlow", "b": [0.663, 0.38, 0.726, 0.3961]}]}, {"id": "b_14", "type": "paragraph", "text": "13 14 ~50% Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "13", "b": [0.15, 0.401, 0.1638, 0.4172]}, {"w": "14", "b": [0.249, 0.401, 0.2628, 0.4172]}, {"w": "~50%", "b": [0.3526, 0.401, 0.3885, 0.4172]}, {"w": "Deep", "b": [0.454, 0.401, 0.482, 0.4172]}, {"w": "Computer", "b": [0.4854, 0.401, 0.5397, 0.4172]}, {"w": "Vision", "b": [0.5431, 0.401, 0.5764, 0.4172]}, {"w": "Using", "b": [0.5798, 0.401, 0.6108, 0.4172]}, {"w": "Convolutional", "b": [0.6142, 0.401, 0.6903, 0.4172]}, {"w": "Neural", "b": [0.6937, 0.401, 0.7299, 0.4172]}, {"w": "Networks", "b": [0.7333, 0.401, 0.7855, 0.4172]}]}, {"id": "b_15", "type": "paragraph", "text": "Part of 14 15 ~75% Processing Sequences Using RNNs and CNNs", "words": [{"w": "Part", "b": [0.15, 0.422, 0.1726, 0.4382]}, {"w": "of", "b": [0.176, 0.422, 0.1869, 0.4382]}, {"w": "14", "b": [0.1903, 0.422, 0.2041, 0.4382]}, {"w": "15", "b": [0.249, 0.422, 0.2628, 0.4382]}, {"w": "~75%", "b": [0.3526, 0.422, 0.3885, 0.4382]}, {"w": "Processing", "b": [0.454, 0.422, 0.5122, 0.4382]}, {"w": "Sequences", "b": [0.5156, 0.422, 0.5735, 0.4382]}, {"w": "Using", "b": [0.5769, 0.422, 0.6079, 0.4382]}, {"w": "RNNs", "b": [0.6113, 0.422, 0.6404, 0.4382]}, {"w": "and", "b": [0.6438, 0.422, 0.6646, 0.4382]}, {"w": "CNNs", "b": [0.668, 0.422, 0.6965, 0.4382]}]}, {"id": "b_16", "type": "paragraph", "text": "Part of 14 16 ~90% Natural Language Processing with RNNs and Attention", "words": [{"w": "Part", "b": [0.15, 0.4431, 0.1726, 0.4592]}, {"w": "of", "b": [0.176, 0.4431, 0.1869, 0.4592]}, {"w": "14", "b": [0.1903, 0.4431, 0.2041, 0.4592]}, {"w": "16", "b": [0.249, 0.4431, 0.2628, 0.4592]}, {"w": "~90%", "b": [0.3526, 0.4431, 0.3885, 0.4592]}, {"w": "Natural", "b": [0.454, 0.4431, 0.4948, 0.4592]}, {"w": "Language", "b": [0.4982, 0.4431, 0.5524, 0.4592]}, {"w": "Processing", "b": [0.5558, 0.4431, 0.614, 0.4592]}, {"w": "with", "b": [0.6174, 0.4431, 0.6426, 0.4592]}, {"w": "RNNs", "b": [0.646, 0.4431, 0.6751, 0.4592]}, {"w": "and", "b": [0.6785, 0.4431, 0.6994, 0.4592]}, {"w": "Attention", "b": [0.7027, 0.4431, 0.7552, 0.4592]}]}, {"id": "b_17", "type": "paragraph", "text": "15 17 ~75% Autoencoders and GANs", "words": [{"w": "15", "b": [0.15, 0.4641, 0.1637, 0.4802]}, {"w": "17", "b": [0.249, 0.4641, 0.2628, 0.4802]}, {"w": "~75%", "b": [0.3526, 0.4641, 0.3885, 0.4802]}, {"w": "Autoencoders", "b": [0.454, 0.4641, 0.5294, 0.4802]}, {"w": "and", "b": [0.5328, 0.4641, 0.5537, 0.4802]}, {"w": "GANs", "b": [0.5571, 0.4641, 0.5861, 0.4802]}]}, {"id": "b_18", "type": "paragraph", "text": "16 18 ~75% Reinforcement Learning", "words": [{"w": "16", "b": [0.15, 0.4851, 0.1637, 0.5012]}, {"w": "18", "b": [0.249, 0.4851, 0.2628, 0.5012]}, {"w": "~75%", "b": [0.3526, 0.4851, 0.3885, 0.5012]}, {"w": "Reinforcement", "b": [0.454, 0.4851, 0.5349, 0.5012]}, {"w": "Learning", "b": [0.5382, 0.4851, 0.5867, 0.5012]}]}, {"id": "b_19", "type": "paragraph", "text": "Part of 12 19 100% rewritten Deploying your TensorFlow Models", "words": [{"w": "Part", "b": [0.15, 0.5061, 0.1726, 0.5222]}, {"w": "of", "b": [0.176, 0.5061, 0.1869, 0.5222]}, {"w": "12", "b": [0.1903, 0.5061, 0.2041, 0.5222]}, {"w": "19", "b": [0.249, 0.5061, 0.2628, 0.5222]}, {"w": "100%", "b": [0.3526, 0.5061, 0.3848, 0.5222]}, {"w": "rewritten", "b": [0.3882, 0.5061, 0.4397, 0.5222]}, {"w": "Deploying", "b": [0.454, 0.5061, 0.5096, 0.5222]}, {"w": "your", "b": [0.513, 0.5061, 0.5376, 0.5222]}, {"w": "TensorFlow", "b": [0.541, 0.5061, 0.604, 0.5222]}, {"w": "Models", "b": [0.6074, 0.5061, 0.6471, 0.5222]}]}, {"id": "b_20", "type": "paragraph", "text": "More specifically, here are the main changes for each 2nd edition chapter (other than clarifications, corrections and code updates):", "words": [{"w": "More", "b": [0.1429, 0.5426, 0.1881, 0.564]}, {"w": "specifically,", "b": [0.1941, 0.5426, 0.2889, 0.564]}, {"w": "here", "b": [0.2949, 0.5426, 0.3315, 0.564]}, {"w": "are", "b": [0.3375, 0.5426, 0.3632, 0.564]}, {"w": "the", "b": [0.3692, 0.5426, 0.3955, 0.564]}, {"w": "main", "b": [0.4015, 0.5426, 0.4447, 0.564]}, {"w": "changes", "b": [0.4507, 0.5426, 0.5174, 0.564]}, {"w": "for", "b": [0.5234, 0.5426, 0.548, 0.564]}, {"w": "each", "b": [0.554, 0.5426, 0.5919, 0.564]}, {"w": "2nd", "b": [0.5979, 0.5426, 0.6213, 0.564]}, {"w": "edition", "b": [0.6273, 0.5426, 0.6867, 0.564]}, {"w": "chapter", "b": [0.6927, 0.5426, 0.7552, 0.564]}, {"w": "(other", "b": [0.7612, 0.5426, 0.8131, 0.564]}, {"w": "than", "b": [0.8191, 0.5426, 0.8571, 0.564]}, {"w": "clarifications,", "b": [0.1428, 0.5617, 0.2551, 0.5831]}, {"w": "corrections", "b": [0.2598, 0.5617, 0.354, 0.5831]}, {"w": "and", "b": [0.3587, 0.5617, 0.3902, 0.5831]}, {"w": "code", "b": [0.395, 0.5617, 0.4342, 0.5831]}, {"w": "updates):", "b": [0.439, 0.5617, 0.5155, 0.5831]}]}, {"id": "b_21", "type": "paragraph", "text": "• Chapter 1", "words": [{"w": "•", "b": [0.16, 0.5958, 0.1681, 0.6173]}, {"w": "Chapter", "b": [0.1786, 0.5958, 0.2461, 0.6173]}, {"w": "1", "b": [0.2509, 0.5958, 0.2609, 0.6173]}]}, {"id": "b_22", "type": "paragraph", "text": "— Added a section on handling mismatch between the training set and the vali‐", "words": [{"w": "—", "b": [0.1807, 0.6209, 0.1999, 0.6423]}, {"w": "Added", "b": [0.2044, 0.6209, 0.2601, 0.6423]}, {"w": "a", "b": [0.2658, 0.6209, 0.275, 0.6423]}, {"w": "section", "b": [0.2808, 0.6209, 0.34, 0.6423]}, {"w": "on", "b": [0.3458, 0.6209, 0.3678, 0.6423]}, {"w": "handling", "b": [0.3736, 0.6209, 0.4483, 0.6423]}, {"w": "mismatch", "b": [0.4541, 0.6209, 0.5365, 0.6423]}, {"w": "between", "b": [0.5422, 0.6209, 0.6114, 0.6423]}, {"w": "the", "b": [0.6172, 0.6209, 0.6435, 0.6423]}, {"w": "training", "b": [0.6493, 0.6209, 0.7162, 0.6423]}, {"w": "set", "b": [0.722, 0.6209, 0.7449, 0.6423]}, {"w": "and", "b": [0.7506, 0.6209, 0.7822, 0.6423]}, {"w": "the", "b": [0.788, 0.6209, 0.8143, 0.6423]}, {"w": "vali‐", "b": [0.8201, 0.6209, 0.8571, 0.6423]}]}, {"id": "b_23", "type": "paragraph", "text": "dation & test sets.", "words": [{"w": "dation", "b": [0.2044, 0.64, 0.2581, 0.6614]}, {"w": "&", "b": [0.2628, 0.64, 0.2776, 0.6614]}, {"w": "test", "b": [0.2823, 0.64, 0.3116, 0.6614]}, {"w": "sets.", "b": [0.3163, 0.64, 0.3515, 0.6614]}]}, {"id": "b_24", "type": "paragraph", "text": "• Chapter 2", "words": [{"w": "•", "b": [0.16, 0.6651, 0.1682, 0.6865]}, {"w": "Chapter", "b": [0.1786, 0.6651, 0.2461, 0.6865]}, {"w": "2", "b": [0.2509, 0.6651, 0.2609, 0.6865]}]}, {"id": "b_25", "type": "paragraph", "text": "— Added how to compute a confidence interval.", "words": [{"w": "—", "b": [0.1807, 0.6902, 0.1999, 0.7116]}, {"w": "Added", "b": [0.2044, 0.6902, 0.2601, 0.7116]}, {"w": "how", "b": [0.2648, 0.6902, 0.3008, 0.7116]}, {"w": "to", "b": [0.3055, 0.6902, 0.3225, 0.7116]}, {"w": "compute", "b": [0.3273, 0.6902, 0.4005, 0.7116]}, {"w": "a", "b": [0.4053, 0.6902, 0.4144, 0.7116]}, {"w": "confidence", "b": [0.4191, 0.6902, 0.5106, 0.7116]}, {"w": "interval.", "b": [0.5154, 0.6902, 0.5843, 0.7116]}]}, {"id": "b_26", "type": "paragraph", "text": "— Improved the installation instructions (e.g., for Windows).", "words": [{"w": "—", "b": [0.1807, 0.7153, 0.1999, 0.7367]}, {"w": "Improved", "b": [0.2044, 0.7153, 0.2869, 0.7367]}, {"w": "the", "b": [0.2916, 0.7153, 0.318, 0.7367]}, {"w": "installation", "b": [0.3227, 0.7153, 0.4161, 0.7367]}, {"w": "instructions", "b": [0.4208, 0.7153, 0.521, 0.7367]}, {"w": "(e.g.,", "b": [0.5257, 0.7153, 0.5658, 0.7367]}, {"w": "for", "b": [0.5705, 0.7153, 0.595, 0.7367]}, {"w": "Windows).", "b": [0.5998, 0.7153, 0.6916, 0.7367]}]}, {"id": "b_27", "type": "paragraph", "text": "— Introduced the upgraded OneHotEncoder and the new ColumnTransformer.", "words": [{"w": "—", "b": [0.1807, 0.7413, 0.1999, 0.7627]}, {"w": "Introduced", "b": [0.2044, 0.7413, 0.2979, 0.7627]}, {"w": "the", "b": [0.3026, 0.7413, 0.329, 0.7627]}, {"w": "upgraded", "b": [0.3337, 0.7413, 0.4131, 0.7627]}, {"w": "OneHotEncoder", "b": [0.4179, 0.7444, 0.5465, 0.7595]}, {"w": "and", "b": [0.5513, 0.7413, 0.5828, 0.7627]}, {"w": "the", "b": [0.5875, 0.7413, 0.6139, 0.7627]}, {"w": "new", "b": [0.6186, 0.7413, 0.6531, 0.7627]}, {"w": "ColumnTransformer.", "b": [0.6578, 0.7413, 0.8308, 0.7627]}]}, {"id": "b_28", "type": "paragraph", "text": "• Chapter 4", "words": [{"w": "•", "b": [0.16, 0.7664, 0.1682, 0.7878]}, {"w": "Chapter", "b": [0.1786, 0.7664, 0.2461, 0.7878]}, {"w": "4", "b": [0.2509, 0.7664, 0.2609, 0.7878]}]}, {"id": "b_29", "type": "paragraph", "text": "— Explained the need for training instances to be Independent and Identically", "words": [{"w": "—", "b": [0.1807, 0.7914, 0.1999, 0.8129]}, {"w": "Explained", "b": [0.2044, 0.7914, 0.2882, 0.8129]}, {"w": "the", "b": [0.2954, 0.7914, 0.3217, 0.8129]}, {"w": "need", "b": [0.3289, 0.7914, 0.369, 0.8129]}, {"w": "for", "b": [0.3763, 0.7914, 0.4008, 0.8129]}, {"w": "training", "b": [0.408, 0.7914, 0.4749, 0.8129]}, {"w": "instances", "b": [0.4821, 0.7914, 0.559, 0.8129]}, {"w": "to", "b": [0.5662, 0.7914, 0.5832, 0.8129]}, {"w": "be", "b": [0.5904, 0.7914, 0.6098, 0.8129]}, {"w": "Independent", "b": [0.617, 0.7914, 0.7237, 0.8129]}, {"w": "and", "b": [0.7309, 0.7914, 0.7625, 0.8129]}, {"w": "Identically", "b": [0.7697, 0.7914, 0.8571, 0.8129]}]}, {"id": "b_30", "type": "paragraph", "text": "Distributed (IID).", "words": [{"w": "Distributed", "b": [0.2044, 0.8105, 0.3004, 0.8319]}, {"w": "(IID).", "b": [0.3052, 0.8105, 0.3538, 0.8319]}]}, {"id": "b_31", "type": "paragraph", "text": "• Chapter 7", "words": [{"w": "•", "b": [0.16, 0.8356, 0.1682, 0.857]}, {"w": "Chapter", "b": [0.1786, 0.8356, 0.2461, 0.857]}, {"w": "7", "b": [0.2509, 0.8356, 0.2609, 0.857]}]}, {"id": "b_32", "type": "paragraph", "text": "— Added a short section about XGBoost.", "words": [{"w": "—", "b": [0.1807, 0.8607, 0.1999, 0.8821]}, {"w": "Added", "b": [0.2044, 0.8607, 0.2601, 0.8821]}, {"w": "a", "b": [0.2648, 0.8607, 0.2739, 0.8821]}, {"w": "short", "b": [0.2787, 0.8607, 0.3221, 0.8821]}, {"w": "section", "b": [0.3269, 0.8607, 0.3861, 0.8821]}, {"w": "about", "b": [0.3909, 0.8607, 0.4386, 0.8821]}, {"w": "XGBoost.", "b": [0.4434, 0.8607, 0.5239, 0.8821]}]}, {"id": "b_33", "type": "paragraph", "text": "xx | Preface", "words": [{"w": "xx", "b": [0.1428, 0.9225, 0.1561, 0.9388]}, {"w": "|", "b": [0.1739, 0.9225, 0.1777, 0.9388]}, {"w": "Preface", "b": [0.1955, 0.9225, 0.2395, 0.9388]}]}]}, {"page": 23, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• Chapter 9 – new chapter including:", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "Chapter", "b": [0.1786, 0.0791, 0.2461, 0.1005]}, {"w": "9", "b": [0.2509, 0.0791, 0.2609, 0.1005]}, {"w": "–", "b": [0.2656, 0.0791, 0.2764, 0.1005]}, {"w": "new", "b": [0.2812, 0.0791, 0.3157, 0.1005]}, {"w": "chapter", "b": [0.3204, 0.0791, 0.383, 0.1005]}, {"w": "including:", "b": [0.3877, 0.0791, 0.4723, 0.1005]}]}, {"id": "b_1", "type": "equation", "text": "— Clustering with K-Means, how to choose the number of clusters, how to use it", "words": [{"w": "—", "b": [0.1807, 0.1042, 0.1999, 0.1256]}, {"w": "Clustering", "b": [0.2044, 0.1042, 0.2919, 0.1256]}, {"w": "with", "b": [0.2969, 0.1042, 0.3343, 0.1256]}, {"w": "K-Means,", "b": [0.3393, 0.1042, 0.4206, 0.1256]}, {"w": "how", "b": [0.4257, 0.1042, 0.4617, 0.1256]}, {"w": "to", "b": [0.4668, 0.1042, 0.4837, 0.1256]}, {"w": "choose", "b": [0.4888, 0.1042, 0.5465, 0.1256]}, {"w": "the", "b": [0.5516, 0.1042, 0.5779, 0.1256]}, {"w": "number", "b": [0.583, 0.1042, 0.6493, 0.1256]}, {"w": "of", "b": [0.6543, 0.1042, 0.6711, 0.1256]}, {"w": "clusters,", "b": [0.6762, 0.1042, 0.7443, 0.1256]}, {"w": "how", "b": [0.7494, 0.1042, 0.7854, 0.1256]}, {"w": "to", "b": [0.7905, 0.1042, 0.8075, 0.1256]}, {"w": "use", "b": [0.8126, 0.1042, 0.8401, 0.1256]}, {"w": "it", "b": [0.8452, 0.1042, 0.8571, 0.1256]}]}, {"id": "b_2", "type": "paragraph", "text": "for dimensionality reduction, semi-supervised learning, image segmentation, and more.", "words": [{"w": "for", "b": [0.2044, 0.1232, 0.2289, 0.1446]}, {"w": "dimensionality", "b": [0.2355, 0.1232, 0.3606, 0.1446]}, {"w": "reduction,", "b": [0.3672, 0.1232, 0.4533, 0.1446]}, {"w": "semi-supervised", "b": [0.46, 0.1232, 0.5961, 0.1446]}, {"w": "learning,", "b": [0.6027, 0.1232, 0.6765, 0.1446]}, {"w": "image", "b": [0.6832, 0.1232, 0.7336, 0.1446]}, {"w": "segmentation,", "b": [0.7402, 0.1232, 0.8571, 0.1446]}, {"w": "and", "b": [0.2044, 0.1423, 0.2359, 0.1637]}, {"w": "more.", "b": [0.2406, 0.1423, 0.2897, 0.1637]}]}, {"id": "b_3", "type": "paragraph", "text": "— The DBSCAN clustering algorithm and an overview of other clustering algo‐", "words": [{"w": "—", "b": [0.1807, 0.1673, 0.1999, 0.1888]}, {"w": "The", "b": [0.2044, 0.1673, 0.2372, 0.1888]}, {"w": "DBSCAN", "b": [0.2432, 0.1673, 0.3243, 0.1888]}, {"w": "clustering", "b": [0.3303, 0.1673, 0.4127, 0.1888]}, {"w": "algorithm", "b": [0.4187, 0.1673, 0.5014, 0.1888]}, {"w": "and", "b": [0.5073, 0.1673, 0.5389, 0.1888]}, {"w": "an", "b": [0.5448, 0.1673, 0.5654, 0.1888]}, {"w": "overview", "b": [0.5713, 0.1673, 0.6471, 0.1888]}, {"w": "of", "b": [0.6531, 0.1673, 0.6699, 0.1888]}, {"w": "other", "b": [0.6759, 0.1673, 0.7205, 0.1888]}, {"w": "clustering", "b": [0.7265, 0.1673, 0.809, 0.1888]}, {"w": "algo‐", "b": [0.8149, 0.1673, 0.8571, 0.1888]}]}, {"id": "b_4", "type": "equation", "text": "rithms available in Scikit-Learn.", "words": [{"w": "rithms", "b": [0.2044, 0.1864, 0.2599, 0.2078]}, {"w": "available", "b": [0.2646, 0.1864, 0.3369, 0.2078]}, {"w": "in", "b": [0.3416, 0.1864, 0.3586, 0.2078]}, {"w": "Scikit-Learn.", "b": [0.3633, 0.1864, 0.4703, 0.2078]}]}, {"id": "b_5", "type": "equation", "text": "— Gaussian mixture models, the Expectation-Maximization (EM) algorithm,", "words": [{"w": "—", "b": [0.1807, 0.2115, 0.1999, 0.2329]}, {"w": "Gaussian", "b": [0.2044, 0.2115, 0.2805, 0.2329]}, {"w": "mixture", "b": [0.291, 0.2115, 0.3574, 0.2329]}, {"w": "models,", "b": [0.3679, 0.2115, 0.4331, 0.2329]}, {"w": "the", "b": [0.4436, 0.2115, 0.4699, 0.2329]}, {"w": "Expectation-Maximization", "b": [0.4804, 0.2115, 0.704, 0.2329]}, {"w": "(EM)", "b": [0.7145, 0.2115, 0.7593, 0.2329]}, {"w": "algorithm,", "b": [0.7697, 0.2115, 0.8571, 0.2329]}]}, {"id": "b_6", "type": "paragraph", "text": "Bayesian variational inference, and how mixture models can be used for clus‐ tering, density estimation, anomaly detection and novelty detection.", "words": [{"w": "Bayesian", "b": [0.2044, 0.2305, 0.2776, 0.2519]}, {"w": "variational", "b": [0.2832, 0.2305, 0.3724, 0.2519]}, {"w": "inference,", "b": [0.378, 0.2305, 0.4604, 0.2519]}, {"w": "and", "b": [0.4659, 0.2305, 0.4975, 0.2519]}, {"w": "how", "b": [0.5031, 0.2305, 0.5391, 0.2519]}, {"w": "mixture", "b": [0.5447, 0.2305, 0.6111, 0.2519]}, {"w": "models", "b": [0.6167, 0.2305, 0.6772, 0.2519]}, {"w": "can", "b": [0.6827, 0.2305, 0.7121, 0.2519]}, {"w": "be", "b": [0.7177, 0.2305, 0.7371, 0.2519]}, {"w": "used", "b": [0.7427, 0.2305, 0.7813, 0.2519]}, {"w": "for", "b": [0.7868, 0.2305, 0.8114, 0.2519]}, {"w": "clus‐", "b": [0.8169, 0.2305, 0.8571, 0.2519]}, {"w": "tering,", "b": [0.2044, 0.2496, 0.2588, 0.271]}, {"w": "density", "b": [0.2635, 0.2496, 0.3239, 0.271]}, {"w": "estimation,", "b": [0.3286, 0.2496, 0.4216, 0.271]}, {"w": "anomaly", "b": [0.4263, 0.2496, 0.4985, 0.271]}, {"w": "detection", "b": [0.5033, 0.2496, 0.5811, 0.271]}, {"w": "and", "b": [0.5858, 0.2496, 0.6174, 0.271]}, {"w": "novelty", "b": [0.6221, 0.2496, 0.6838, 0.271]}, {"w": "detection.", "b": [0.6885, 0.2496, 0.7711, 0.271]}]}, {"id": "b_7", "type": "paragraph", "text": "— Overview of other anomaly detection and novelty detection algorithms.", "words": [{"w": "—", "b": [0.1807, 0.2747, 0.1999, 0.2961]}, {"w": "Overview", "b": [0.2044, 0.2747, 0.2855, 0.2961]}, {"w": "of", "b": [0.2902, 0.2747, 0.307, 0.2961]}, {"w": "other", "b": [0.3117, 0.2747, 0.3564, 0.2961]}, {"w": "anomaly", "b": [0.3611, 0.2747, 0.4333, 0.2961]}, {"w": "detection", "b": [0.4381, 0.2747, 0.5159, 0.2961]}, {"w": "and", "b": [0.5206, 0.2747, 0.5522, 0.2961]}, {"w": "novelty", "b": [0.5569, 0.2747, 0.6186, 0.2961]}, {"w": "detection", "b": [0.6233, 0.2747, 0.7012, 0.2961]}, {"w": "algorithms.", "b": [0.7059, 0.2747, 0.8009, 0.2961]}]}, {"id": "b_8", "type": "paragraph", "text": "• Chapter 10 (mostly new)", "words": [{"w": "•", "b": [0.16, 0.2998, 0.1682, 0.3212]}, {"w": "Chapter", "b": [0.1786, 0.2998, 0.2461, 0.3212]}, {"w": "10", "b": [0.2509, 0.2998, 0.2709, 0.3212]}, {"w": "(mostly", "b": [0.2756, 0.2998, 0.3393, 0.3212]}, {"w": "new)", "b": [0.3441, 0.2998, 0.3858, 0.3212]}]}, {"id": "b_9", "type": "paragraph", "text": "— Added an introduction to the Keras API, including all its APIs (Sequential,", "words": [{"w": "—", "b": [0.1807, 0.3249, 0.1999, 0.3463]}, {"w": "Added", "b": [0.2044, 0.3249, 0.2601, 0.3463]}, {"w": "an", "b": [0.2677, 0.3249, 0.2882, 0.3463]}, {"w": "introduction", "b": [0.2959, 0.3249, 0.402, 0.3463]}, {"w": "to", "b": [0.4097, 0.3249, 0.4266, 0.3463]}, {"w": "the", "b": [0.4343, 0.3249, 0.4606, 0.3463]}, {"w": "Keras", "b": [0.4683, 0.3249, 0.5152, 0.3463]}, {"w": "API,", "b": [0.5228, 0.3249, 0.5608, 0.3463]}, {"w": "including", "b": [0.5684, 0.3249, 0.6483, 0.3463]}, {"w": "all", "b": [0.6559, 0.3249, 0.6756, 0.3463]}, {"w": "its", "b": [0.6832, 0.3249, 0.7028, 0.3463]}, {"w": "APIs", "b": [0.7105, 0.3249, 0.7509, 0.3463]}, {"w": "(Sequential,", "b": [0.7585, 0.3249, 0.8571, 0.3463]}]}, {"id": "b_10", "type": "paragraph", "text": "Functional and Subclassing), persistence and callbacks (including the Tensor Board callback).", "words": [{"w": "Functional", "b": [0.2044, 0.3448, 0.2946, 0.3662]}, {"w": "and", "b": [0.3007, 0.3448, 0.3323, 0.3662]}, {"w": "Subclassing),", "b": [0.3384, 0.3448, 0.4471, 0.3662]}, {"w": "persistence", "b": [0.4532, 0.3448, 0.5459, 0.3662]}, {"w": "and", "b": [0.552, 0.3448, 0.5836, 0.3662]}, {"w": "callbacks", "b": [0.5897, 0.3448, 0.6647, 0.3662]}, {"w": "(including", "b": [0.6708, 0.3448, 0.7579, 0.3662]}, {"w": "the", "b": [0.764, 0.3448, 0.7903, 0.3662]}, {"w": "Tensor", "b": [0.7964, 0.348, 0.8558, 0.3631]}, {"w": "Board", "b": [0.2044, 0.3679, 0.2538, 0.383]}, {"w": "callback).", "b": [0.2586, 0.3648, 0.3379, 0.3862]}]}, {"id": "b_11", "type": "paragraph", "text": "• Chapter 11 (many changes)", "words": [{"w": "•", "b": [0.16, 0.3899, 0.1682, 0.4113]}, {"w": "Chapter", "b": [0.1786, 0.3898, 0.2461, 0.4113]}, {"w": "11", "b": [0.2509, 0.3898, 0.2709, 0.4113]}, {"w": "(many", "b": [0.2756, 0.3898, 0.3295, 0.4113]}, {"w": "changes)", "b": [0.3342, 0.3898, 0.4082, 0.4113]}]}, {"id": "b_12", "type": "equation", "text": "— Introduced self-normalizing nets, the SELU activation function and Alpha", "words": [{"w": "—", "b": [0.1807, 0.4149, 0.1999, 0.4364]}, {"w": "Introduced", "b": [0.2044, 0.4149, 0.2979, 0.4364]}, {"w": "self-normalizing", "b": [0.307, 0.4149, 0.4446, 0.4364]}, {"w": "nets,", "b": [0.4537, 0.4149, 0.4927, 0.4364]}, {"w": "the", "b": [0.5018, 0.4149, 0.5282, 0.4364]}, {"w": "SELU", "b": [0.5373, 0.4149, 0.5847, 0.4364]}, {"w": "activation", "b": [0.5938, 0.4149, 0.676, 0.4364]}, {"w": "function", "b": [0.6851, 0.4149, 0.7565, 0.4364]}, {"w": "and", "b": [0.7656, 0.4149, 0.7972, 0.4364]}, {"w": "Alpha", "b": [0.8063, 0.4149, 0.8571, 0.4364]}]}, {"id": "b_13", "type": "paragraph", "text": "Dropout.", "words": [{"w": "Dropout.", "b": [0.2044, 0.434, 0.2817, 0.4554]}]}, {"id": "b_14", "type": "equation", "text": "— Introduced self-supervised learning.", "words": [{"w": "—", "b": [0.1807, 0.4591, 0.1999, 0.4805]}, {"w": "Introduced", "b": [0.2044, 0.4591, 0.2979, 0.4805]}, {"w": "self-supervised", "b": [0.3026, 0.4591, 0.4275, 0.4805]}, {"w": "learning.", "b": [0.4323, 0.4591, 0.5061, 0.4805]}]}, {"id": "b_15", "type": "paragraph", "text": "— Added Nadam optimization.", "words": [{"w": "—", "b": [0.1807, 0.4842, 0.1999, 0.5056]}, {"w": "Added", "b": [0.2044, 0.4842, 0.2601, 0.5056]}, {"w": "Nadam", "b": [0.2648, 0.4842, 0.3261, 0.5056]}, {"w": "optimization.", "b": [0.3308, 0.4842, 0.4431, 0.5056]}]}, {"id": "b_16", "type": "equation", "text": "— Added Monte-Carlo Dropout.", "words": [{"w": "—", "b": [0.1807, 0.5093, 0.1999, 0.5307]}, {"w": "Added", "b": [0.2044, 0.5093, 0.2601, 0.5307]}, {"w": "Monte-Carlo", "b": [0.2648, 0.5093, 0.3737, 0.5307]}, {"w": "Dropout.", "b": [0.3784, 0.5093, 0.4558, 0.5307]}]}, {"id": "b_17", "type": "paragraph", "text": "— Added a note about the risks of adaptive optimization methods.", "words": [{"w": "—", "b": [0.1807, 0.5344, 0.1999, 0.5558]}, {"w": "Added", "b": [0.2044, 0.5344, 0.2601, 0.5558]}, {"w": "a", "b": [0.2648, 0.5344, 0.2739, 0.5558]}, {"w": "note", "b": [0.2787, 0.5344, 0.3159, 0.5558]}, {"w": "about", "b": [0.3206, 0.5344, 0.3684, 0.5558]}, {"w": "the", "b": [0.3731, 0.5344, 0.3995, 0.5558]}, {"w": "risks", "b": [0.4042, 0.5344, 0.4431, 0.5558]}, {"w": "of", "b": [0.4479, 0.5344, 0.4646, 0.5558]}, {"w": "adaptive", "b": [0.4694, 0.5344, 0.5396, 0.5558]}, {"w": "optimization", "b": [0.5444, 0.5344, 0.6519, 0.5558]}, {"w": "methods.", "b": [0.6567, 0.5344, 0.7341, 0.5558]}]}, {"id": "b_18", "type": "paragraph", "text": "— Updated the practical guidelines.", "words": [{"w": "—", "b": [0.1807, 0.5595, 0.1999, 0.5809]}, {"w": "Updated", "b": [0.2044, 0.5595, 0.2758, 0.5809]}, {"w": "the", "b": [0.2805, 0.5595, 0.3068, 0.5809]}, {"w": "practical", "b": [0.3115, 0.5595, 0.3833, 0.5809]}, {"w": "guidelines.", "b": [0.388, 0.5595, 0.4778, 0.5809]}]}, {"id": "b_19", "type": "paragraph", "text": "• Chapter 12 – completely rewritten chapter, including:", "words": [{"w": "•", "b": [0.16, 0.5846, 0.1682, 0.606]}, {"w": "Chapter", "b": [0.1786, 0.5846, 0.2461, 0.606]}, {"w": "12", "b": [0.2509, 0.5846, 0.2709, 0.606]}, {"w": "–", "b": [0.2756, 0.5846, 0.2864, 0.606]}, {"w": "completely", "b": [0.2912, 0.5846, 0.3824, 0.606]}, {"w": "rewritten", "b": [0.3871, 0.5846, 0.4642, 0.606]}, {"w": "chapter,", "b": [0.4689, 0.5846, 0.5349, 0.606]}, {"w": "including:", "b": [0.5396, 0.5846, 0.6243, 0.606]}]}, {"id": "b_20", "type": "paragraph", "text": "— A tour of TensorFlow 2", "words": [{"w": "—", "b": [0.1807, 0.6097, 0.1999, 0.6311]}, {"w": "A", "b": [0.2044, 0.6097, 0.2188, 0.6311]}, {"w": "tour", "b": [0.2235, 0.6097, 0.2593, 0.6311]}, {"w": "of", "b": [0.264, 0.6097, 0.2808, 0.6311]}, {"w": "TensorFlow", "b": [0.2855, 0.6097, 0.3838, 0.6311]}, {"w": "2", "b": [0.3885, 0.6097, 0.3985, 0.6311]}]}, {"id": "b_21", "type": "equation", "text": "— TensorFlow’s lower-level Python API", "words": [{"w": "—", "b": [0.1807, 0.6347, 0.1999, 0.6562]}, {"w": "TensorFlow’s", "b": [0.2044, 0.6347, 0.3129, 0.6562]}, {"w": "lower-level", "b": [0.3176, 0.6347, 0.4092, 0.6562]}, {"w": "Python", "b": [0.4139, 0.6347, 0.4747, 0.6562]}, {"w": "API", "b": [0.4795, 0.6347, 0.5127, 0.6562]}]}, {"id": "b_22", "type": "paragraph", "text": "— Writing custom loss functions, metrics, layers, models", "words": [{"w": "—", "b": [0.1807, 0.6598, 0.1999, 0.6813]}, {"w": "Writing", "b": [0.2044, 0.6598, 0.2692, 0.6813]}, {"w": "custom", "b": [0.2739, 0.6598, 0.3355, 0.6813]}, {"w": "loss", "b": [0.3402, 0.6598, 0.3714, 0.6813]}, {"w": "functions,", "b": [0.3761, 0.6598, 0.4599, 0.6813]}, {"w": "metrics,", "b": [0.4646, 0.6598, 0.5314, 0.6813]}, {"w": "layers,", "b": [0.5362, 0.6598, 0.5888, 0.6813]}, {"w": "models", "b": [0.5935, 0.6598, 0.6539, 0.6813]}]}, {"id": "b_23", "type": "equation", "text": "— Using auto-differentiation and creating custom training algorithms.", "words": [{"w": "—", "b": [0.1807, 0.6849, 0.1999, 0.7063]}, {"w": "Using", "b": [0.2044, 0.6849, 0.253, 0.7063]}, {"w": "auto-differentiation", "b": [0.2577, 0.6849, 0.4219, 0.7063]}, {"w": "and", "b": [0.4266, 0.6849, 0.4582, 0.7063]}, {"w": "creating", "b": [0.4629, 0.6849, 0.5301, 0.7063]}, {"w": "custom", "b": [0.5349, 0.6849, 0.5964, 0.7063]}, {"w": "training", "b": [0.6011, 0.6849, 0.6681, 0.7063]}, {"w": "algorithms.", "b": [0.6728, 0.6849, 0.7679, 0.7063]}]}, {"id": "b_24", "type": "paragraph", "text": "— TensorFlow Functions and graphs (including tracing and autograph).", "words": [{"w": "—", "b": [0.1807, 0.71, 0.1999, 0.7314]}, {"w": "TensorFlow", "b": [0.2044, 0.71, 0.3026, 0.7314]}, {"w": "Functions", "b": [0.3073, 0.71, 0.3908, 0.7314]}, {"w": "and", "b": [0.3955, 0.71, 0.4271, 0.7314]}, {"w": "graphs", "b": [0.4318, 0.71, 0.4877, 0.7314]}, {"w": "(including", "b": [0.4925, 0.71, 0.5795, 0.7314]}, {"w": "tracing", "b": [0.5843, 0.71, 0.643, 0.7314]}, {"w": "and", "b": [0.6478, 0.71, 0.6793, 0.7314]}, {"w": "autograph).", "b": [0.684, 0.71, 0.781, 0.7314]}]}, {"id": "b_25", "type": "paragraph", "text": "• Chapter 13 – new chapter, including:", "words": [{"w": "•", "b": [0.16, 0.7351, 0.1682, 0.7565]}, {"w": "Chapter", "b": [0.1786, 0.7351, 0.2461, 0.7565]}, {"w": "13", "b": [0.2509, 0.7351, 0.2709, 0.7565]}, {"w": "–", "b": [0.2756, 0.7351, 0.2864, 0.7565]}, {"w": "new", "b": [0.2912, 0.7351, 0.3257, 0.7565]}, {"w": "chapter,", "b": [0.3304, 0.7351, 0.3964, 0.7565]}, {"w": "including:", "b": [0.4011, 0.7351, 0.4857, 0.7565]}]}, {"id": "b_26", "type": "paragraph", "text": "— The Data API", "words": [{"w": "—", "b": [0.1807, 0.7602, 0.1999, 0.7816]}, {"w": "The", "b": [0.2044, 0.7602, 0.2372, 0.7816]}, {"w": "Data", "b": [0.2419, 0.7602, 0.2815, 0.7816]}, {"w": "API", "b": [0.2862, 0.7602, 0.3194, 0.7816]}]}, {"id": "b_27", "type": "equation", "text": "— Loading/Storing data efficiently using TFRecords", "words": [{"w": "—", "b": [0.1807, 0.7853, 0.1999, 0.8067]}, {"w": "Loading/Storing", "b": [0.2044, 0.7853, 0.3413, 0.8067]}, {"w": "data", "b": [0.346, 0.7853, 0.3813, 0.8067]}, {"w": "efficiently", "b": [0.386, 0.7853, 0.4682, 0.8067]}, {"w": "using", "b": [0.4729, 0.7853, 0.5184, 0.8067]}, {"w": "TFRecords", "b": [0.5231, 0.7853, 0.6146, 0.8067]}]}, {"id": "b_28", "type": "paragraph", "text": "— The Features API (including an introduction to embeddings).", "words": [{"w": "—", "b": [0.1807, 0.8104, 0.1999, 0.8318]}, {"w": "The", "b": [0.2044, 0.8104, 0.2372, 0.8318]}, {"w": "Features", "b": [0.2419, 0.8104, 0.3118, 0.8318]}, {"w": "API", "b": [0.3165, 0.8104, 0.3498, 0.8318]}, {"w": "(including", "b": [0.3545, 0.8104, 0.4415, 0.8318]}, {"w": "an", "b": [0.4463, 0.8104, 0.4668, 0.8318]}, {"w": "introduction", "b": [0.4715, 0.8104, 0.5777, 0.8318]}, {"w": "to", "b": [0.5824, 0.8104, 0.5994, 0.8318]}, {"w": "embeddings).", "b": [0.6041, 0.8104, 0.7178, 0.8318]}]}, {"id": "b_29", "type": "paragraph", "text": "— An overview of TF Transform and TF Datasets", "words": [{"w": "—", "b": [0.1807, 0.8355, 0.1999, 0.8569]}, {"w": "An", "b": [0.2044, 0.8355, 0.2301, 0.8569]}, {"w": "overview", "b": [0.2349, 0.8355, 0.3107, 0.8569]}, {"w": "of", "b": [0.3154, 0.8355, 0.3322, 0.8569]}, {"w": "TF", "b": [0.3369, 0.8355, 0.3608, 0.8569]}, {"w": "Transform", "b": [0.3655, 0.8355, 0.4542, 0.8569]}, {"w": "and", "b": [0.4589, 0.8355, 0.4904, 0.8569]}, {"w": "TF", "b": [0.4952, 0.8355, 0.519, 0.8569]}, {"w": "Datasets", "b": [0.5238, 0.8355, 0.5938, 0.8569]}]}, {"id": "b_30", "type": "equation", "text": "— Moved the low-level implementation of the neural network to the exercises.", "words": [{"w": "—", "b": [0.1807, 0.8606, 0.1999, 0.882]}, {"w": "Moved", "b": [0.2044, 0.8606, 0.2625, 0.882]}, {"w": "the", "b": [0.2672, 0.8606, 0.2936, 0.882]}, {"w": "low-level", "b": [0.2983, 0.8606, 0.3738, 0.882]}, {"w": "implementation", "b": [0.3785, 0.8606, 0.5118, 0.882]}, {"w": "of", "b": [0.5165, 0.8606, 0.5333, 0.882]}, {"w": "the", "b": [0.538, 0.8606, 0.5644, 0.882]}, {"w": "neural", "b": [0.5691, 0.8606, 0.6225, 0.882]}, {"w": "network", "b": [0.6273, 0.8606, 0.6968, 0.882]}, {"w": "to", "b": [0.7016, 0.8606, 0.7185, 0.882]}, {"w": "the", "b": [0.7233, 0.8606, 0.7496, 0.882]}, {"w": "exercises.", "b": [0.7543, 0.8606, 0.8329, 0.882]}]}, {"id": "b_31", "type": "paragraph", "text": "Preface | xxi", "words": [{"w": "Preface", "b": [0.7569, 0.9225, 0.8008, 0.9388]}, {"w": "|", "b": [0.8187, 0.9225, 0.8224, 0.9388]}, {"w": "xxi", "b": [0.8403, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 24, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "— Removed details about queues and readers that are now superseded by the", "words": [{"w": "—", "b": [0.1807, 0.0791, 0.1999, 0.1005]}, {"w": "Removed", "b": [0.2044, 0.0791, 0.2833, 0.1005]}, {"w": "details", "b": [0.2912, 0.0791, 0.3451, 0.1005]}, {"w": "about", "b": [0.353, 0.0791, 0.4008, 0.1005]}, {"w": "queues", "b": [0.4087, 0.0791, 0.4668, 0.1005]}, {"w": "and", "b": [0.4747, 0.0791, 0.5062, 0.1005]}, {"w": "readers", "b": [0.5141, 0.0791, 0.5751, 0.1005]}, {"w": "that", "b": [0.583, 0.0791, 0.6156, 0.1005]}, {"w": "are", "b": [0.6235, 0.0791, 0.6492, 0.1005]}, {"w": "now", "b": [0.6571, 0.0791, 0.6934, 0.1005]}, {"w": "superseded", "b": [0.7013, 0.0791, 0.7949, 0.1005]}, {"w": "by", "b": [0.8028, 0.0791, 0.8229, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}]}, {"id": "b_1", "type": "paragraph", "text": "Data API.", "words": [{"w": "Data", "b": [0.2044, 0.0981, 0.2439, 0.1195]}, {"w": "API.", "b": [0.2487, 0.0981, 0.2866, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "• Chapter 14", "words": [{"w": "•", "b": [0.16, 0.1232, 0.1682, 0.1446]}, {"w": "Chapter", "b": [0.1786, 0.1232, 0.2461, 0.1446]}, {"w": "14", "b": [0.2509, 0.1232, 0.2709, 0.1446]}]}, {"id": "b_3", "type": "paragraph", "text": "— Added Xception and SENet architectures.", "words": [{"w": "—", "b": [0.1807, 0.1483, 0.1999, 0.1697]}, {"w": "Added", "b": [0.2044, 0.1483, 0.2601, 0.1697]}, {"w": "Xception", "b": [0.2648, 0.1483, 0.341, 0.1697]}, {"w": "and", "b": [0.3457, 0.1483, 0.3772, 0.1697]}, {"w": "SENet", "b": [0.382, 0.1483, 0.4338, 0.1697]}, {"w": "architectures.", "b": [0.4386, 0.1483, 0.5514, 0.1697]}]}, {"id": "b_4", "type": "equation", "text": "— Added a Keras implementation of ResNet-34.", "words": [{"w": "—", "b": [0.1807, 0.1734, 0.1999, 0.1948]}, {"w": "Added", "b": [0.2044, 0.1734, 0.2601, 0.1948]}, {"w": "a", "b": [0.2648, 0.1734, 0.2739, 0.1948]}, {"w": "Keras", "b": [0.2787, 0.1734, 0.3256, 0.1948]}, {"w": "implementation", "b": [0.3303, 0.1734, 0.4636, 0.1948]}, {"w": "of", "b": [0.4683, 0.1734, 0.4851, 0.1948]}, {"w": "ResNet-34.", "b": [0.4898, 0.1734, 0.5816, 0.1948]}]}, {"id": "b_5", "type": "paragraph", "text": "— Showed how to use pretrained models using Keras.", "words": [{"w": "—", "b": [0.1807, 0.1985, 0.1999, 0.2199]}, {"w": "Showed", "b": [0.2044, 0.1985, 0.2701, 0.2199]}, {"w": "how", "b": [0.2748, 0.1985, 0.3109, 0.2199]}, {"w": "to", "b": [0.3156, 0.1985, 0.3326, 0.2199]}, {"w": "use", "b": [0.3373, 0.1985, 0.3649, 0.2199]}, {"w": "pretrained", "b": [0.3696, 0.1985, 0.4571, 0.2199]}, {"w": "models", "b": [0.4619, 0.1985, 0.5223, 0.2199]}, {"w": "using", "b": [0.5271, 0.1985, 0.5725, 0.2199]}, {"w": "Keras.", "b": [0.5772, 0.1985, 0.6289, 0.2199]}]}, {"id": "b_6", "type": "equation", "text": "— Added an end-to-end transfer learning example.", "words": [{"w": "—", "b": [0.1807, 0.2236, 0.1999, 0.245]}, {"w": "Added", "b": [0.2044, 0.2236, 0.2601, 0.245]}, {"w": "an", "b": [0.2648, 0.2236, 0.2853, 0.245]}, {"w": "end-to-end", "b": [0.2901, 0.2236, 0.3844, 0.245]}, {"w": "transfer", "b": [0.3891, 0.2236, 0.4541, 0.245]}, {"w": "learning", "b": [0.4589, 0.2236, 0.528, 0.245]}, {"w": "example.", "b": [0.5327, 0.2236, 0.607, 0.245]}]}, {"id": "b_7", "type": "paragraph", "text": "— Added classification and localization.", "words": [{"w": "—", "b": [0.1807, 0.2487, 0.1999, 0.2701]}, {"w": "Added", "b": [0.2044, 0.2487, 0.2601, 0.2701]}, {"w": "classification", "b": [0.2648, 0.2487, 0.3722, 0.2701]}, {"w": "and", "b": [0.3769, 0.2487, 0.4084, 0.2701]}, {"w": "localization.", "b": [0.4132, 0.2487, 0.5141, 0.2701]}]}, {"id": "b_8", "type": "paragraph", "text": "— Introduced Fully Convolutional Networks (FCNs).", "words": [{"w": "—", "b": [0.1807, 0.2738, 0.1999, 0.2952]}, {"w": "Introduced", "b": [0.2044, 0.2738, 0.2979, 0.2952]}, {"w": "Fully", "b": [0.3026, 0.2738, 0.3444, 0.2952]}, {"w": "Convolutional", "b": [0.3491, 0.2738, 0.4695, 0.2952]}, {"w": "Networks", "b": [0.4742, 0.2738, 0.555, 0.2952]}, {"w": "(FCNs).", "b": [0.5597, 0.2738, 0.6263, 0.2952]}]}, {"id": "b_9", "type": "paragraph", "text": "— Introduced object detection using the YOLO architecture.", "words": [{"w": "—", "b": [0.1807, 0.2989, 0.1999, 0.3203]}, {"w": "Introduced", "b": [0.2044, 0.2989, 0.2979, 0.3203]}, {"w": "object", "b": [0.3026, 0.2989, 0.3532, 0.3203]}, {"w": "detection", "b": [0.3579, 0.2989, 0.4358, 0.3203]}, {"w": "using", "b": [0.4405, 0.2989, 0.4859, 0.3203]}, {"w": "the", "b": [0.4906, 0.2989, 0.517, 0.3203]}, {"w": "YOLO", "b": [0.5217, 0.2989, 0.5763, 0.3203]}, {"w": "architecture.", "b": [0.5811, 0.2989, 0.6862, 0.3203]}]}, {"id": "b_10", "type": "equation", "text": "— Introduced semantic segmentation using R-CNN.", "words": [{"w": "—", "b": [0.1807, 0.324, 0.1999, 0.3454]}, {"w": "Introduced", "b": [0.2044, 0.324, 0.2979, 0.3454]}, {"w": "semantic", "b": [0.3026, 0.324, 0.3771, 0.3454]}, {"w": "segmentation", "b": [0.3818, 0.324, 0.494, 0.3454]}, {"w": "using", "b": [0.4988, 0.324, 0.5442, 0.3454]}, {"w": "R-CNN.", "b": [0.5489, 0.324, 0.618, 0.3454]}]}, {"id": "b_11", "type": "paragraph", "text": "• Chapter 15", "words": [{"w": "•", "b": [0.16, 0.3491, 0.1682, 0.3705]}, {"w": "Chapter", "b": [0.1786, 0.3491, 0.2461, 0.3705]}, {"w": "15", "b": [0.2509, 0.3491, 0.2709, 0.3705]}]}, {"id": "b_12", "type": "paragraph", "text": "— Added an introduction to Wavenet.", "words": [{"w": "—", "b": [0.1807, 0.3741, 0.1999, 0.3956]}, {"w": "Added", "b": [0.2044, 0.3741, 0.2601, 0.3956]}, {"w": "an", "b": [0.2648, 0.3741, 0.2853, 0.3956]}, {"w": "introduction", "b": [0.2901, 0.3741, 0.3962, 0.3956]}, {"w": "to", "b": [0.4009, 0.3741, 0.4179, 0.3956]}, {"w": "Wavenet.", "b": [0.4226, 0.3741, 0.4994, 0.3956]}]}, {"id": "b_13", "type": "paragraph", "text": "— Moved the Encoder–Decoder architecture and Bidirectional RNNs to Chapter", "words": [{"w": "—", "b": [0.1807, 0.3992, 0.1999, 0.4207]}, {"w": "Moved", "b": [0.2044, 0.3992, 0.2625, 0.4207]}, {"w": "the", "b": [0.2676, 0.3992, 0.2939, 0.4207]}, {"w": "Encoder–Decoder", "b": [0.299, 0.3992, 0.4508, 0.4207]}, {"w": "architecture", "b": [0.4559, 0.3992, 0.5563, 0.4207]}, {"w": "and", "b": [0.5614, 0.3992, 0.593, 0.4207]}, {"w": "Bidirectional", "b": [0.5981, 0.3992, 0.7063, 0.4207]}, {"w": "RNNs", "b": [0.7114, 0.3992, 0.7624, 0.4207]}, {"w": "to", "b": [0.7675, 0.3992, 0.7844, 0.4207]}, {"w": "Chapter", "b": [0.7896, 0.3992, 0.8571, 0.4207]}]}, {"id": "b_14", "type": "paragraph", "text": "16.", "words": [{"w": "16.", "b": [0.2044, 0.4183, 0.2291, 0.4397]}]}, {"id": "b_15", "type": "paragraph", "text": "• Chapter 16", "words": [{"w": "•", "b": [0.16, 0.4434, 0.1682, 0.4648]}, {"w": "Chapter", "b": [0.1786, 0.4434, 0.2461, 0.4648]}, {"w": "16", "b": [0.2509, 0.4434, 0.2709, 0.4648]}]}, {"id": "b_16", "type": "paragraph", "text": "— Explained how to use the Data API to handle sequential data.", "words": [{"w": "—", "b": [0.1807, 0.4685, 0.1999, 0.4899]}, {"w": "Explained", "b": [0.2044, 0.4685, 0.2882, 0.4899]}, {"w": "how", "b": [0.2929, 0.4685, 0.3289, 0.4899]}, {"w": "to", "b": [0.3337, 0.4685, 0.3506, 0.4899]}, {"w": "use", "b": [0.3554, 0.4685, 0.3829, 0.4899]}, {"w": "the", "b": [0.3877, 0.4685, 0.414, 0.4899]}, {"w": "Data", "b": [0.4187, 0.4685, 0.4583, 0.4899]}, {"w": "API", "b": [0.463, 0.4685, 0.4963, 0.4899]}, {"w": "to", "b": [0.501, 0.4685, 0.518, 0.4899]}, {"w": "handle", "b": [0.5227, 0.4685, 0.5795, 0.4899]}, {"w": "sequential", "b": [0.5842, 0.4685, 0.6686, 0.4899]}, {"w": "data.", "b": [0.6734, 0.4685, 0.7134, 0.4899]}]}, {"id": "b_17", "type": "equation", "text": "— Showed an end-to-end example of text generation using a Character RNN,", "words": [{"w": "—", "b": [0.1807, 0.4936, 0.1999, 0.515]}, {"w": "Showed", "b": [0.2044, 0.4936, 0.2701, 0.515]}, {"w": "an", "b": [0.278, 0.4936, 0.2986, 0.515]}, {"w": "end-to-end", "b": [0.3065, 0.4936, 0.4008, 0.515]}, {"w": "example", "b": [0.4087, 0.4936, 0.4783, 0.515]}, {"w": "of", "b": [0.4862, 0.4936, 0.503, 0.515]}, {"w": "text", "b": [0.5109, 0.4936, 0.5423, 0.515]}, {"w": "generation", "b": [0.5502, 0.4936, 0.6395, 0.515]}, {"w": "using", "b": [0.6474, 0.4936, 0.6928, 0.515]}, {"w": "a", "b": [0.7008, 0.4936, 0.7099, 0.515]}, {"w": "Character", "b": [0.7178, 0.4936, 0.8006, 0.515]}, {"w": "RNN,", "b": [0.8085, 0.4936, 0.8571, 0.515]}]}, {"id": "b_18", "type": "paragraph", "text": "using both a stateless and a stateful RNN.", "words": [{"w": "using", "b": [0.2044, 0.5126, 0.2498, 0.534]}, {"w": "both", "b": [0.2545, 0.5126, 0.2932, 0.534]}, {"w": "a", "b": [0.2979, 0.5126, 0.3071, 0.534]}, {"w": "stateless", "b": [0.3118, 0.5126, 0.3792, 0.534]}, {"w": "and", "b": [0.3839, 0.5126, 0.4155, 0.534]}, {"w": "a", "b": [0.4202, 0.5126, 0.4293, 0.534]}, {"w": "stateful", "b": [0.4341, 0.5126, 0.4945, 0.534]}, {"w": "RNN.", "b": [0.4993, 0.5126, 0.5479, 0.534]}]}, {"id": "b_19", "type": "equation", "text": "— Showed an end-to-end example of sentiment analysis using an LSTM.", "words": [{"w": "—", "b": [0.1807, 0.5377, 0.1999, 0.5591]}, {"w": "Showed", "b": [0.2044, 0.5377, 0.2701, 0.5591]}, {"w": "an", "b": [0.2748, 0.5377, 0.2954, 0.5591]}, {"w": "end-to-end", "b": [0.3001, 0.5377, 0.3944, 0.5591]}, {"w": "example", "b": [0.3991, 0.5377, 0.4687, 0.5591]}, {"w": "of", "b": [0.4734, 0.5377, 0.4902, 0.5591]}, {"w": "sentiment", "b": [0.4949, 0.5377, 0.5776, 0.5591]}, {"w": "analysis", "b": [0.5824, 0.5377, 0.6478, 0.5591]}, {"w": "using", "b": [0.6525, 0.5377, 0.6979, 0.5591]}, {"w": "an", "b": [0.7027, 0.5377, 0.7232, 0.5591]}, {"w": "LSTM.", "b": [0.7279, 0.5377, 0.7852, 0.5591]}]}, {"id": "b_20", "type": "paragraph", "text": "— Explained masking in Keras.", "words": [{"w": "—", "b": [0.1807, 0.5628, 0.1999, 0.5842]}, {"w": "Explained", "b": [0.2044, 0.5628, 0.2882, 0.5842]}, {"w": "masking", "b": [0.2929, 0.5628, 0.3638, 0.5842]}, {"w": "in", "b": [0.3686, 0.5628, 0.3855, 0.5842]}, {"w": "Keras.", "b": [0.3903, 0.5628, 0.4419, 0.5842]}]}, {"id": "b_21", "type": "paragraph", "text": "— Showed how to reuse pretrained embeddings using TF Hub.", "words": [{"w": "—", "b": [0.1807, 0.5879, 0.1999, 0.6093]}, {"w": "Showed", "b": [0.2044, 0.5879, 0.2701, 0.6093]}, {"w": "how", "b": [0.2748, 0.5879, 0.3109, 0.6093]}, {"w": "to", "b": [0.3156, 0.5879, 0.3326, 0.6093]}, {"w": "reuse", "b": [0.3373, 0.5879, 0.3814, 0.6093]}, {"w": "pretrained", "b": [0.3862, 0.5879, 0.4737, 0.6093]}, {"w": "embeddings", "b": [0.4785, 0.5879, 0.5802, 0.6093]}, {"w": "using", "b": [0.5849, 0.5879, 0.6304, 0.6093]}, {"w": "TF", "b": [0.6351, 0.5879, 0.659, 0.6093]}, {"w": "Hub.", "b": [0.6637, 0.5879, 0.7046, 0.6093]}]}, {"id": "b_22", "type": "paragraph", "text": "— Showed how to build an Encoder–Decoder for Neural Machine Translation", "words": [{"w": "—", "b": [0.1807, 0.613, 0.1999, 0.6344]}, {"w": "Showed", "b": [0.2044, 0.613, 0.2701, 0.6344]}, {"w": "how", "b": [0.2777, 0.613, 0.3137, 0.6344]}, {"w": "to", "b": [0.3214, 0.613, 0.3383, 0.6344]}, {"w": "build", "b": [0.3459, 0.613, 0.3894, 0.6344]}, {"w": "an", "b": [0.3971, 0.613, 0.4176, 0.6344]}, {"w": "Encoder–Decoder", "b": [0.4252, 0.613, 0.577, 0.6344]}, {"w": "for", "b": [0.5846, 0.613, 0.6091, 0.6344]}, {"w": "Neural", "b": [0.6167, 0.613, 0.6738, 0.6344]}, {"w": "Machine", "b": [0.6814, 0.613, 0.7545, 0.6344]}, {"w": "Translation", "b": [0.7621, 0.613, 0.8571, 0.6344]}]}, {"id": "b_23", "type": "equation", "text": "using TensorFlow Addons/seq2seq.", "words": [{"w": "using", "b": [0.2044, 0.632, 0.2498, 0.6535]}, {"w": "TensorFlow", "b": [0.2545, 0.632, 0.3528, 0.6535]}, {"w": "Addons/seq2seq.", "b": [0.3575, 0.632, 0.499, 0.6535]}]}, {"id": "b_24", "type": "paragraph", "text": "— Introduced beam search.", "words": [{"w": "—", "b": [0.1807, 0.6571, 0.1999, 0.6786]}, {"w": "Introduced", "b": [0.2044, 0.6571, 0.2979, 0.6786]}, {"w": "beam", "b": [0.3026, 0.6571, 0.3483, 0.6786]}, {"w": "search.", "b": [0.353, 0.6571, 0.4111, 0.6786]}]}, {"id": "b_25", "type": "paragraph", "text": "— Explained attention mechanisms.", "words": [{"w": "—", "b": [0.1807, 0.6822, 0.1999, 0.7036]}, {"w": "Explained", "b": [0.2044, 0.6822, 0.2882, 0.7036]}, {"w": "attention", "b": [0.2929, 0.6822, 0.3682, 0.7036]}, {"w": "mechanisms.", "b": [0.3729, 0.6822, 0.482, 0.7036]}]}, {"id": "b_26", "type": "paragraph", "text": "— Added a short overview of visual attention and a note on explainability.", "words": [{"w": "—", "b": [0.1807, 0.7073, 0.1999, 0.7287]}, {"w": "Added", "b": [0.2044, 0.7073, 0.2601, 0.7287]}, {"w": "a", "b": [0.2648, 0.7073, 0.2739, 0.7287]}, {"w": "short", "b": [0.2787, 0.7073, 0.3221, 0.7287]}, {"w": "overview", "b": [0.3269, 0.7073, 0.4027, 0.7287]}, {"w": "of", "b": [0.4074, 0.7073, 0.4242, 0.7287]}, {"w": "visual", "b": [0.4289, 0.7073, 0.4773, 0.7287]}, {"w": "attention", "b": [0.482, 0.7073, 0.5573, 0.7287]}, {"w": "and", "b": [0.562, 0.7073, 0.5936, 0.7287]}, {"w": "a", "b": [0.5983, 0.7073, 0.6074, 0.7287]}, {"w": "note", "b": [0.6122, 0.7073, 0.6494, 0.7287]}, {"w": "on", "b": [0.6541, 0.7073, 0.6761, 0.7287]}, {"w": "explainability.", "b": [0.6809, 0.7073, 0.7972, 0.7287]}]}, {"id": "b_27", "type": "paragraph", "text": "— Introduced the fully attention-based Transformer architecture, including posi‐", "words": [{"w": "—", "b": [0.1807, 0.7324, 0.1999, 0.7538]}, {"w": "Introduced", "b": [0.2044, 0.7324, 0.2979, 0.7538]}, {"w": "the", "b": [0.3026, 0.7324, 0.329, 0.7538]}, {"w": "fully", "b": [0.3337, 0.7324, 0.371, 0.7538]}, {"w": "attention-based", "b": [0.3758, 0.7324, 0.5057, 0.7538]}, {"w": "Transformer", "b": [0.5104, 0.7324, 0.6156, 0.7538]}, {"w": "architecture,", "b": [0.6203, 0.7324, 0.7255, 0.7538]}, {"w": "including", "b": [0.7302, 0.7324, 0.8101, 0.7538]}, {"w": "posi‐", "b": [0.8148, 0.7324, 0.857, 0.7538]}]}, {"id": "b_28", "type": "equation", "text": "tional embeddings and multi-head attention.", "words": [{"w": "tional", "b": [0.2044, 0.7515, 0.2527, 0.7729]}, {"w": "embeddings", "b": [0.2575, 0.7515, 0.3592, 0.7729]}, {"w": "and", "b": [0.3639, 0.7515, 0.3955, 0.7729]}, {"w": "multi-head", "b": [0.4002, 0.7515, 0.4927, 0.7729]}, {"w": "attention.", "b": [0.4974, 0.7515, 0.5774, 0.7729]}]}, {"id": "b_29", "type": "paragraph", "text": "— Added an overview of recent language models (2018).", "words": [{"w": "—", "b": [0.1807, 0.7766, 0.1999, 0.798]}, {"w": "Added", "b": [0.2044, 0.7766, 0.2601, 0.798]}, {"w": "an", "b": [0.2648, 0.7766, 0.2853, 0.798]}, {"w": "overview", "b": [0.2901, 0.7766, 0.3659, 0.798]}, {"w": "of", "b": [0.3706, 0.7766, 0.3874, 0.798]}, {"w": "recent", "b": [0.3921, 0.7766, 0.4437, 0.798]}, {"w": "language", "b": [0.4485, 0.7766, 0.5228, 0.798]}, {"w": "models", "b": [0.5276, 0.7766, 0.588, 0.798]}, {"w": "(2018).", "b": [0.5928, 0.7766, 0.6519, 0.798]}]}, {"id": "b_30", "type": "paragraph", "text": "• Chapters 17, 18 and 19: coming soon.", "words": [{"w": "•", "b": [0.16, 0.8017, 0.1682, 0.8231]}, {"w": "Chapters", "b": [0.1786, 0.8017, 0.2538, 0.8231]}, {"w": "17,", "b": [0.2585, 0.8017, 0.2833, 0.8231]}, {"w": "18", "b": [0.288, 0.8017, 0.308, 0.8231]}, {"w": "and", "b": [0.3127, 0.8017, 0.3443, 0.8231]}, {"w": "19:", "b": [0.349, 0.8017, 0.3738, 0.8231]}, {"w": "coming", "b": [0.3785, 0.8017, 0.4417, 0.8231]}, {"w": "soon.", "b": [0.4464, 0.8017, 0.4915, 0.8231]}]}, {"id": "b_31", "type": "paragraph", "text": "xxii | Preface", "words": [{"w": "xxii", "b": [0.1429, 0.9225, 0.1634, 0.9388]}, {"w": "|", "b": [0.1812, 0.9225, 0.185, 0.9388]}, {"w": "Preface", "b": [0.2029, 0.9225, 0.2468, 0.9388]}]}]}, {"page": 25, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "3 “Deep Learning with Python,” François Chollet (2017).", "words": [{"w": "3", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Deep", "b": [0.1587, 0.8749, 0.1985, 0.8912]}, {"w": "Learning", "b": [0.2021, 0.8749, 0.2593, 0.8912]}, {"w": "with", "b": [0.2629, 0.8749, 0.2914, 0.8912]}, {"w": "Python,”", "b": [0.295, 0.8749, 0.3491, 0.8912]}, {"w": "François", "b": [0.3527, 0.8749, 0.4075, 0.8912]}, {"w": "Chollet", "b": [0.4111, 0.8749, 0.4578, 0.8912]}, {"w": "(2017).", "b": [0.4614, 0.8749, 0.5065, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Acknowledgments", "words": [{"w": "Acknowledgments", "b": [0.1429, 0.0753, 0.3724, 0.1095]}]}, {"id": "b_2", "type": "paragraph", "text": "Never in my wildest dreams did I imagine that the first edition of this book would get such a large audience. I received so many messages from readers, many asking ques‐ tions, some kindly pointing out errata, and most sending me encouraging words. I cannot express how grateful I am to all these readers for their tremendous support. Thank you all so very much! Please do not hesitate to file issues on github if you find errors in the code examples (or just to ask questions), or to submit errata if you find errors in the text. Some readers also shared how this book helped them get their first job, or how it helped them solve a concrete problem they were working on: I find such feedback incredibly motivating. If you find this book helpful, I would love it if you could share your story with me, either privately (e.g., via LinkedIn) or publicly (e.g., in an Amazon review).", "words": [{"w": "Never", "b": [0.1429, 0.1164, 0.1929, 0.1378]}, {"w": "in", "b": [0.1979, 0.1164, 0.2149, 0.1378]}, {"w": "my", "b": [0.2199, 0.1164, 0.246, 0.1378]}, {"w": "wildest", "b": [0.251, 0.1164, 0.31, 0.1378]}, {"w": "dreams", "b": [0.315, 0.1164, 0.3764, 0.1378]}, {"w": "did", "b": [0.3814, 0.1164, 0.409, 0.1378]}, {"w": "I", "b": [0.414, 0.1164, 0.4211, 0.1378]}, {"w": "imagine", "b": [0.4261, 0.1164, 0.4935, 0.1378]}, {"w": "that", "b": [0.4985, 0.1164, 0.5311, 0.1378]}, {"w": "the", "b": [0.5361, 0.1164, 0.5624, 0.1378]}, {"w": "first", "b": [0.5674, 0.1164, 0.6009, 0.1378]}, {"w": "edition", "b": [0.6059, 0.1164, 0.6653, 0.1378]}, {"w": "of", "b": [0.6703, 0.1164, 0.6871, 0.1378]}, {"w": "this", "b": [0.6921, 0.1164, 0.7228, 0.1378]}, {"w": "book", "b": [0.7278, 0.1164, 0.77, 0.1378]}, {"w": "would", "b": [0.775, 0.1164, 0.8272, 0.1378]}, {"w": "get", "b": [0.8322, 0.1164, 0.8571, 0.1378]}, {"w": "such", "b": [0.1429, 0.1355, 0.1815, 0.1569]}, {"w": "a", "b": [0.1873, 0.1355, 0.1964, 0.1569]}, {"w": "large", "b": [0.2022, 0.1355, 0.243, 0.1569]}, {"w": "audience.", "b": [0.2488, 0.1355, 0.3278, 0.1569]}, {"w": "I", "b": [0.3336, 0.1355, 0.3407, 0.1569]}, {"w": "received", "b": [0.3465, 0.1355, 0.4158, 0.1569]}, {"w": "so", "b": [0.4216, 0.1355, 0.4399, 0.1569]}, {"w": "many", "b": [0.4457, 0.1355, 0.4924, 0.1569]}, {"w": "messages", "b": [0.4981, 0.1355, 0.5747, 0.1569]}, {"w": "from", "b": [0.5805, 0.1355, 0.6221, 0.1569]}, {"w": "readers,", "b": [0.6279, 0.1355, 0.6936, 0.1569]}, {"w": "many", "b": [0.6994, 0.1355, 0.7461, 0.1569]}, {"w": "asking", "b": [0.7519, 0.1355, 0.8057, 0.1569]}, {"w": "ques‐", "b": [0.8115, 0.1355, 0.8571, 0.1569]}, {"w": "tions,", "b": [0.1429, 0.1545, 0.1892, 0.1759]}, {"w": "some", "b": [0.1964, 0.1545, 0.2406, 0.1759]}, {"w": "kindly", "b": [0.2477, 0.1545, 0.3009, 0.1759]}, {"w": "pointing", "b": [0.3081, 0.1545, 0.3793, 0.1759]}, {"w": "out", "b": [0.3864, 0.1545, 0.4145, 0.1759]}, {"w": "errata,", "b": [0.4217, 0.1545, 0.475, 0.1759]}, {"w": "and", "b": [0.4821, 0.1545, 0.5137, 0.1759]}, {"w": "most", "b": [0.5208, 0.1545, 0.5625, 0.1759]}, {"w": "sending", "b": [0.5697, 0.1545, 0.6353, 0.1759]}, {"w": "me", "b": [0.6425, 0.1545, 0.6684, 0.1759]}, {"w": "encouraging", "b": [0.6756, 0.1545, 0.7797, 0.1759]}, {"w": "words.", "b": [0.7869, 0.1545, 0.8429, 0.1759]}, {"w": "I", "b": [0.85, 0.1545, 0.8572, 0.1759]}, {"w": "cannot", "b": [0.1429, 0.1736, 0.2006, 0.195]}, {"w": "express", "b": [0.2073, 0.1736, 0.2687, 0.195]}, {"w": "how", "b": [0.2754, 0.1736, 0.3114, 0.195]}, {"w": "grateful", "b": [0.3181, 0.1736, 0.382, 0.195]}, {"w": "I", "b": [0.3887, 0.1736, 0.3958, 0.195]}, {"w": "am", "b": [0.4024, 0.1736, 0.4286, 0.195]}, {"w": "to", "b": [0.4353, 0.1736, 0.4523, 0.195]}, {"w": "all", "b": [0.4589, 0.1736, 0.4786, 0.195]}, {"w": "these", "b": [0.4853, 0.1736, 0.5281, 0.195]}, {"w": "readers", "b": [0.5348, 0.1736, 0.5958, 0.195]}, {"w": "for", "b": [0.6024, 0.1736, 0.6269, 0.195]}, {"w": "their", "b": [0.6336, 0.1736, 0.6732, 0.195]}, {"w": "tremendous", "b": [0.6799, 0.1736, 0.7805, 0.195]}, {"w": "support.", "b": [0.7871, 0.1736, 0.8571, 0.195]}, {"w": "Thank", "b": [0.1429, 0.1926, 0.1977, 0.214]}, {"w": "you", "b": [0.2031, 0.1926, 0.2343, 0.214]}, {"w": "all", "b": [0.2396, 0.1926, 0.2593, 0.214]}, {"w": "so", "b": [0.2647, 0.1926, 0.283, 0.214]}, {"w": "very", "b": [0.2883, 0.1926, 0.3247, 0.214]}, {"w": "much!", "b": [0.33, 0.1926, 0.3835, 0.214]}, {"w": "Please", "b": [0.3888, 0.1926, 0.4403, 0.214]}, {"w": "do", "b": [0.4456, 0.1926, 0.4673, 0.214]}, {"w": "not", "b": [0.4726, 0.1926, 0.501, 0.214]}, {"w": "hesitate", "b": [0.5063, 0.1926, 0.5699, 0.214]}, {"w": "to", "b": [0.5752, 0.1926, 0.5922, 0.214]}, {"w": "file", "b": [0.5975, 0.1926, 0.6234, 0.214]}, {"w": "issues", "b": [0.6287, 0.1926, 0.6772, 0.214]}, {"w": "on", "b": [0.6825, 0.1926, 0.7046, 0.214]}, {"w": "github", "b": [0.7099, 0.1926, 0.764, 0.214]}, {"w": "if", "b": [0.7693, 0.1926, 0.7811, 0.214]}, {"w": "you", "b": [0.7864, 0.1926, 0.8177, 0.214]}, {"w": "find", "b": [0.823, 0.1926, 0.8571, 0.214]}, {"w": "errors", "b": [0.1429, 0.2117, 0.1932, 0.2331]}, {"w": "in", "b": [0.199, 0.2117, 0.216, 0.2331]}, {"w": "the", "b": [0.2218, 0.2117, 0.2481, 0.2331]}, {"w": "code", "b": [0.2539, 0.2117, 0.2932, 0.2331]}, {"w": "examples", "b": [0.299, 0.2117, 0.3762, 0.2331]}, {"w": "(or", "b": [0.382, 0.2117, 0.4076, 0.2331]}, {"w": "just", "b": [0.4134, 0.2117, 0.4438, 0.2331]}, {"w": "to", "b": [0.4496, 0.2117, 0.4666, 0.2331]}, {"w": "ask", "b": [0.4724, 0.2117, 0.4995, 0.2331]}, {"w": "questions),", "b": [0.5053, 0.2117, 0.5971, 0.2331]}, {"w": "or", "b": [0.6029, 0.2117, 0.6213, 0.2331]}, {"w": "to", "b": [0.6271, 0.2117, 0.6441, 0.2331]}, {"w": "submit", "b": [0.6499, 0.2117, 0.7082, 0.2331]}, {"w": "errata", "b": [0.714, 0.2117, 0.7626, 0.2331]}, {"w": "if", "b": [0.7684, 0.2117, 0.7801, 0.2331]}, {"w": "you", "b": [0.7859, 0.2117, 0.8172, 0.2331]}, {"w": "find", "b": [0.823, 0.2117, 0.8571, 0.2331]}, {"w": "errors", "b": [0.1429, 0.2307, 0.1932, 0.2521]}, {"w": "in", "b": [0.1987, 0.2307, 0.2156, 0.2521]}, {"w": "the", "b": [0.2212, 0.2307, 0.2475, 0.2521]}, {"w": "text.", "b": [0.253, 0.2307, 0.2891, 0.2521]}, {"w": "Some", "b": [0.2946, 0.2307, 0.3411, 0.2521]}, {"w": "readers", "b": [0.3466, 0.2307, 0.4075, 0.2521]}, {"w": "also", "b": [0.413, 0.2307, 0.4457, 0.2521]}, {"w": "shared", "b": [0.4512, 0.2307, 0.5067, 0.2521]}, {"w": "how", "b": [0.5122, 0.2307, 0.5482, 0.2521]}, {"w": "this", "b": [0.5537, 0.2307, 0.5844, 0.2521]}, {"w": "book", "b": [0.59, 0.2307, 0.6321, 0.2521]}, {"w": "helped", "b": [0.6376, 0.2307, 0.6936, 0.2521]}, {"w": "them", "b": [0.6991, 0.2307, 0.7425, 0.2521]}, {"w": "get", "b": [0.748, 0.2307, 0.773, 0.2521]}, {"w": "their", "b": [0.7785, 0.2307, 0.8182, 0.2521]}, {"w": "first", "b": [0.8237, 0.2307, 0.8571, 0.2521]}, {"w": "job,", "b": [0.1429, 0.2498, 0.1736, 0.2712]}, {"w": "or", "b": [0.1809, 0.2498, 0.1993, 0.2712]}, {"w": "how", "b": [0.2067, 0.2498, 0.2427, 0.2712]}, {"w": "it", "b": [0.2501, 0.2498, 0.262, 0.2712]}, {"w": "helped", "b": [0.2694, 0.2498, 0.3255, 0.2712]}, {"w": "them", "b": [0.3329, 0.2498, 0.3762, 0.2712]}, {"w": "solve", "b": [0.3836, 0.2498, 0.4257, 0.2712]}, {"w": "a", "b": [0.4331, 0.2498, 0.4422, 0.2712]}, {"w": "concrete", "b": [0.4496, 0.2498, 0.521, 0.2712]}, {"w": "problem", "b": [0.5284, 0.2498, 0.5995, 0.2712]}, {"w": "they", "b": [0.6069, 0.2498, 0.6428, 0.2712]}, {"w": "were", "b": [0.6502, 0.2498, 0.6899, 0.2712]}, {"w": "working", "b": [0.6973, 0.2498, 0.767, 0.2712]}, {"w": "on:", "b": [0.7743, 0.2498, 0.8011, 0.2712]}, {"w": "I", "b": [0.8085, 0.2498, 0.8156, 0.2712]}, {"w": "find", "b": [0.823, 0.2498, 0.8572, 0.2712]}, {"w": "such", "b": [0.1429, 0.2688, 0.1815, 0.2902]}, {"w": "feedback", "b": [0.1879, 0.2688, 0.2616, 0.2902]}, {"w": "incredibly", "b": [0.268, 0.2688, 0.3524, 0.2902]}, {"w": "motivating.", "b": [0.3588, 0.2688, 0.4546, 0.2902]}, {"w": "If", "b": [0.461, 0.2688, 0.4743, 0.2902]}, {"w": "you", "b": [0.4806, 0.2688, 0.5119, 0.2902]}, {"w": "find", "b": [0.5183, 0.2688, 0.5524, 0.2902]}, {"w": "this", "b": [0.5588, 0.2688, 0.5895, 0.2902]}, {"w": "book", "b": [0.5959, 0.2688, 0.638, 0.2902]}, {"w": "helpful,", "b": [0.6444, 0.2688, 0.7078, 0.2902]}, {"w": "I", "b": [0.7142, 0.2688, 0.7213, 0.2902]}, {"w": "would", "b": [0.7277, 0.2688, 0.7799, 0.2902]}, {"w": "love", "b": [0.7863, 0.2688, 0.8207, 0.2902]}, {"w": "it", "b": [0.8271, 0.2688, 0.839, 0.2902]}, {"w": "if", "b": [0.8454, 0.2688, 0.8571, 0.2902]}, {"w": "you", "b": [0.1429, 0.2879, 0.1741, 0.3093]}, {"w": "could", "b": [0.1808, 0.2879, 0.2276, 0.3093]}, {"w": "share", "b": [0.2343, 0.2879, 0.2788, 0.3093]}, {"w": "your", "b": [0.2855, 0.2879, 0.3245, 0.3093]}, {"w": "story", "b": [0.3312, 0.2879, 0.3737, 0.3093]}, {"w": "with", "b": [0.3804, 0.2879, 0.4177, 0.3093]}, {"w": "me,", "b": [0.4244, 0.2879, 0.4551, 0.3093]}, {"w": "either", "b": [0.4618, 0.2879, 0.5103, 0.3093]}, {"w": "privately", "b": [0.517, 0.2879, 0.5897, 0.3093]}, {"w": "(e.g.,", "b": [0.5964, 0.2879, 0.6364, 0.3093]}, {"w": "via", "b": [0.6432, 0.2879, 0.6675, 0.3093]}, {"w": "LinkedIn)", "b": [0.6742, 0.2879, 0.7583, 0.3093]}, {"w": "or", "b": [0.765, 0.2879, 0.7834, 0.3093]}, {"w": "publicly", "b": [0.7901, 0.2879, 0.8571, 0.3093]}, {"w": "(e.g.,", "b": [0.1428, 0.3069, 0.1829, 0.3283]}, {"w": "in", "b": [0.1876, 0.3069, 0.2046, 0.3283]}, {"w": "an", "b": [0.2093, 0.3069, 0.2299, 0.3283]}, {"w": "Amazon", "b": [0.2346, 0.3069, 0.306, 0.3283]}, {"w": "review).", "b": [0.3107, 0.3069, 0.3776, 0.3283]}]}, {"id": "b_3", "type": "paragraph", "text": "I am also incredibly thankful to all the amazing people who took time out of their busy lives to review my book with such care. In particular, I would like to thank Fran‐ çois Chollet for reviewing all the chapters based on Keras & TensorFlow, and giving me some great, in-depth feedback. Since Keras is one of the main additions to this 2nd", "words": [{"w": "I", "b": [0.1429, 0.335, 0.15, 0.3564]}, {"w": "am", "b": [0.1571, 0.335, 0.1833, 0.3564]}, {"w": "also", "b": [0.1905, 0.335, 0.2232, 0.3564]}, {"w": "incredibly", "b": [0.2303, 0.335, 0.3147, 0.3564]}, {"w": "thankful", "b": [0.3219, 0.335, 0.3927, 0.3564]}, {"w": "to", "b": [0.3999, 0.335, 0.4169, 0.3564]}, {"w": "all", "b": [0.4241, 0.335, 0.4437, 0.3564]}, {"w": "the", "b": [0.4509, 0.335, 0.4772, 0.3564]}, {"w": "amazing", "b": [0.4844, 0.335, 0.5552, 0.3564]}, {"w": "people", "b": [0.5624, 0.335, 0.6178, 0.3564]}, {"w": "who", "b": [0.625, 0.335, 0.661, 0.3564]}, {"w": "took", "b": [0.6682, 0.335, 0.7061, 0.3564]}, {"w": "time", "b": [0.7133, 0.335, 0.7512, 0.3564]}, {"w": "out", "b": [0.7583, 0.335, 0.7864, 0.3564]}, {"w": "of", "b": [0.7935, 0.335, 0.8103, 0.3564]}, {"w": "their", "b": [0.8175, 0.335, 0.8571, 0.3564]}, {"w": "busy", "b": [0.1429, 0.3541, 0.1817, 0.3755]}, {"w": "lives", "b": [0.1866, 0.3541, 0.2236, 0.3755]}, {"w": "to", "b": [0.2284, 0.3541, 0.2454, 0.3755]}, {"w": "review", "b": [0.2503, 0.3541, 0.3052, 0.3755]}, {"w": "my", "b": [0.3101, 0.3541, 0.3362, 0.3755]}, {"w": "book", "b": [0.3411, 0.3541, 0.3833, 0.3755]}, {"w": "with", "b": [0.3881, 0.3541, 0.4255, 0.3755]}, {"w": "such", "b": [0.4303, 0.3541, 0.469, 0.3755]}, {"w": "care.", "b": [0.4738, 0.3541, 0.5131, 0.3755]}, {"w": "In", "b": [0.518, 0.3541, 0.5365, 0.3755]}, {"w": "particular,", "b": [0.5414, 0.3541, 0.6265, 0.3755]}, {"w": "I", "b": [0.6314, 0.3541, 0.6385, 0.3755]}, {"w": "would", "b": [0.6434, 0.3541, 0.6956, 0.3755]}, {"w": "like", "b": [0.7005, 0.3541, 0.7305, 0.3755]}, {"w": "to", "b": [0.7354, 0.3541, 0.7524, 0.3755]}, {"w": "thank", "b": [0.7572, 0.3541, 0.8056, 0.3755]}, {"w": "Fran‐", "b": [0.8104, 0.3541, 0.8572, 0.3755]}, {"w": "çois", "b": [0.1429, 0.3731, 0.1755, 0.3945]}, {"w": "Chollet", "b": [0.1818, 0.3731, 0.2432, 0.3945]}, {"w": "for", "b": [0.2495, 0.3731, 0.274, 0.3945]}, {"w": "reviewing", "b": [0.2803, 0.3731, 0.362, 0.3945]}, {"w": "all", "b": [0.3683, 0.3731, 0.388, 0.3945]}, {"w": "the", "b": [0.3943, 0.3731, 0.4207, 0.3945]}, {"w": "chapters", "b": [0.427, 0.3731, 0.4972, 0.3945]}, {"w": "based", "b": [0.5035, 0.3731, 0.5507, 0.3945]}, {"w": "on", "b": [0.5571, 0.3731, 0.5791, 0.3945]}, {"w": "Keras", "b": [0.5854, 0.3731, 0.6323, 0.3945]}, {"w": "&", "b": [0.6386, 0.3731, 0.6534, 0.3945]}, {"w": "TensorFlow,", "b": [0.6598, 0.3731, 0.7612, 0.3945]}, {"w": "and", "b": [0.7676, 0.3731, 0.7991, 0.3945]}, {"w": "giving", "b": [0.8054, 0.3731, 0.8571, 0.3945]}, {"w": "me", "b": [0.1429, 0.3922, 0.1688, 0.4136]}, {"w": "some", "b": [0.1738, 0.3922, 0.218, 0.4136]}, {"w": "great,", "b": [0.223, 0.3922, 0.2692, 0.4136]}, {"w": "in-depth", "b": [0.2743, 0.3922, 0.3469, 0.4136]}, {"w": "feedback.", "b": [0.3519, 0.3922, 0.4304, 0.4136]}, {"w": "Since", "b": [0.4355, 0.3922, 0.48, 0.4136]}, {"w": "Keras", "b": [0.485, 0.3922, 0.5319, 0.4136]}, {"w": "is", "b": [0.537, 0.3922, 0.5502, 0.4136]}, {"w": "one", "b": [0.5552, 0.3922, 0.5861, 0.4136]}, {"w": "of", "b": [0.5911, 0.3922, 0.6079, 0.4136]}, {"w": "the", "b": [0.613, 0.3922, 0.6393, 0.4136]}, {"w": "main", "b": [0.6443, 0.3922, 0.6875, 0.4136]}, {"w": "additions", "b": [0.6926, 0.3922, 0.7709, 0.4136]}, {"w": "to", "b": [0.7759, 0.3922, 0.7929, 0.4136]}, {"w": "this", "b": [0.798, 0.3922, 0.8287, 0.4136]}, {"w": "2nd", "b": [0.8337, 0.3922, 0.8571, 0.4136]}]}, {"id": "b_4", "type": "paragraph", "text": "edition, having its author review the book was invaluable. I highly recommend Fran‐ çois’s excellent book Deep Learning with Python3: it has the conciseness, clarity and depth of the Keras library itself. Big thanks as well to Ankur Patel, who reviewed every chapter of this 2nd edition and gave me excellent feedback.", "words": [{"w": "edition,", "b": [0.1429, 0.4112, 0.207, 0.4326]}, {"w": "having", "b": [0.2125, 0.4112, 0.2688, 0.4326]}, {"w": "its", "b": [0.2743, 0.4112, 0.2939, 0.4326]}, {"w": "author", "b": [0.2994, 0.4112, 0.3551, 0.4326]}, {"w": "review", "b": [0.3606, 0.4112, 0.4155, 0.4326]}, {"w": "the", "b": [0.4211, 0.4112, 0.4474, 0.4326]}, {"w": "book", "b": [0.4529, 0.4112, 0.4951, 0.4326]}, {"w": "was", "b": [0.5006, 0.4112, 0.5317, 0.4326]}, {"w": "invaluable.", "b": [0.5372, 0.4112, 0.6274, 0.4326]}, {"w": "I", "b": [0.633, 0.4112, 0.6401, 0.4326]}, {"w": "highly", "b": [0.6456, 0.4112, 0.698, 0.4326]}, {"w": "recommend", "b": [0.7035, 0.4112, 0.8049, 0.4326]}, {"w": "Fran‐", "b": [0.8104, 0.4112, 0.8572, 0.4326]}, {"w": "çois’s", "b": [0.1429, 0.4303, 0.1849, 0.4517]}, {"w": "excellent", "b": [0.1914, 0.4303, 0.2645, 0.4517]}, {"w": "book", "b": [0.2709, 0.4303, 0.3131, 0.4517]}, {"w": "Deep", "b": [0.3195, 0.4303, 0.3634, 0.4517]}, {"w": "Learning", "b": [0.3699, 0.4303, 0.4449, 0.4517]}, {"w": "with", "b": [0.4514, 0.4303, 0.4887, 0.4517]}, {"w": "Python3:", "b": [0.4951, 0.4303, 0.5664, 0.4517]}, {"w": "it", "b": [0.5728, 0.4303, 0.5847, 0.4517]}, {"w": "has", "b": [0.5912, 0.4303, 0.6191, 0.4517]}, {"w": "the", "b": [0.6255, 0.4303, 0.6518, 0.4517]}, {"w": "conciseness,", "b": [0.6583, 0.4303, 0.7603, 0.4517]}, {"w": "clarity", "b": [0.7667, 0.4303, 0.8192, 0.4517]}, {"w": "and", "b": [0.8256, 0.4303, 0.8571, 0.4517]}, {"w": "depth", "b": [0.1429, 0.4493, 0.1911, 0.4707]}, {"w": "of", "b": [0.1992, 0.4493, 0.216, 0.4707]}, {"w": "the", "b": [0.2241, 0.4493, 0.2504, 0.4707]}, {"w": "Keras", "b": [0.2585, 0.4493, 0.3054, 0.4707]}, {"w": "library", "b": [0.3135, 0.4493, 0.3697, 0.4707]}, {"w": "itself.", "b": [0.3778, 0.4493, 0.4224, 0.4707]}, {"w": "Big", "b": [0.4305, 0.4493, 0.4581, 0.4707]}, {"w": "thanks", "b": [0.4661, 0.4493, 0.5221, 0.4707]}, {"w": "as", "b": [0.5302, 0.4493, 0.547, 0.4707]}, {"w": "well", "b": [0.5551, 0.4493, 0.5888, 0.4707]}, {"w": "to", "b": [0.5968, 0.4493, 0.6138, 0.4707]}, {"w": "Ankur", "b": [0.6219, 0.4493, 0.6768, 0.4707]}, {"w": "Patel,", "b": [0.6849, 0.4493, 0.7302, 0.4707]}, {"w": "who", "b": [0.7382, 0.4493, 0.7743, 0.4707]}, {"w": "reviewed", "b": [0.7824, 0.4493, 0.8571, 0.4707]}, {"w": "every", "b": [0.1429, 0.4684, 0.1881, 0.4898]}, {"w": "chapter", "b": [0.1928, 0.4684, 0.2554, 0.4898]}, {"w": "of", "b": [0.2601, 0.4684, 0.2769, 0.4898]}, {"w": "this", "b": [0.2816, 0.4684, 0.3123, 0.4898]}, {"w": "2nd", "b": [0.3171, 0.4684, 0.3405, 0.4898]}, {"w": "edition", "b": [0.3452, 0.4684, 0.4046, 0.4898]}, {"w": "and", "b": [0.4094, 0.4684, 0.4409, 0.4898]}, {"w": "gave", "b": [0.4456, 0.4684, 0.4827, 0.4898]}, {"w": "me", "b": [0.4874, 0.4684, 0.5133, 0.4898]}, {"w": "excellent", "b": [0.518, 0.4684, 0.5911, 0.4898]}, {"w": "feedback.", "b": [0.5959, 0.4684, 0.6744, 0.4898]}]}, {"id": "b_5", "type": "paragraph", "text": "This book also benefited from plenty of help from members of the TensorFlow team, in particular Martin Wicke, who tirelessly answered dozens of my questions and dis‐ patched the rest to the right people, including Alexandre Passos, Allen Lavoie, André Susano Pinto, Anna Revinskaya, Anthony Platanios, Clemens Mewald, Dan Moldo‐ van, Daniel Dobson, Dustin Tran, Edd Wilder-James, Goldie Gadde, Jiri Simsa, Kar‐ mel Allison, Nick Felt, Paige Bailey, Pete Warden (who also reviewed the 1st edition), Ryan Sepassi, Sandeep Gupta, Sean Morgan, Todd Wang, Tom O’Malley, William Chargin, and Yuefeng Zhou, all of whom were tremendously helpful. A huge thank you to all of you, and to all other members of the TensorFlow team. Not just for your help, but also for making such a great library.", "words": [{"w": "This", "b": [0.1429, 0.4965, 0.1801, 0.5179]}, {"w": "book", "b": [0.1855, 0.4965, 0.2277, 0.5179]}, {"w": "also", "b": [0.2332, 0.4965, 0.2659, 0.5179]}, {"w": "benefited", "b": [0.2713, 0.4965, 0.349, 0.5179]}, {"w": "from", "b": [0.3545, 0.4965, 0.3961, 0.5179]}, {"w": "plenty", "b": [0.4015, 0.4965, 0.4535, 0.5179]}, {"w": "of", "b": [0.459, 0.4965, 0.4757, 0.5179]}, {"w": "help", "b": [0.4812, 0.4965, 0.5174, 0.5179]}, {"w": "from", "b": [0.5229, 0.4965, 0.5644, 0.5179]}, {"w": "members", "b": [0.5699, 0.4965, 0.6477, 0.5179]}, {"w": "of", "b": [0.6532, 0.4965, 0.67, 0.5179]}, {"w": "the", "b": [0.6755, 0.4965, 0.7018, 0.5179]}, {"w": "TensorFlow", "b": [0.7073, 0.4965, 0.8055, 0.5179]}, {"w": "team,", "b": [0.811, 0.4965, 0.8572, 0.5179]}, {"w": "in", "b": [0.1429, 0.5155, 0.1598, 0.5369]}, {"w": "particular", "b": [0.1655, 0.5155, 0.2472, 0.5369]}, {"w": "Martin", "b": [0.2528, 0.5155, 0.3113, 0.5369]}, {"w": "Wicke,", "b": [0.3169, 0.5155, 0.3746, 0.5369]}, {"w": "who", "b": [0.3802, 0.5155, 0.4162, 0.5369]}, {"w": "tirelessly", "b": [0.4219, 0.5155, 0.4946, 0.5369]}, {"w": "answered", "b": [0.5003, 0.5155, 0.5792, 0.5369]}, {"w": "dozens", "b": [0.5848, 0.5155, 0.6431, 0.5369]}, {"w": "of", "b": [0.6487, 0.5155, 0.6655, 0.5369]}, {"w": "my", "b": [0.6711, 0.5155, 0.6973, 0.5369]}, {"w": "questions", "b": [0.7029, 0.5155, 0.7827, 0.5369]}, {"w": "and", "b": [0.7883, 0.5155, 0.8199, 0.5369]}, {"w": "dis‐", "b": [0.8255, 0.5155, 0.8571, 0.5369]}, {"w": "patched", "b": [0.1429, 0.5346, 0.2087, 0.556]}, {"w": "the", "b": [0.2141, 0.5346, 0.2404, 0.556]}, {"w": "rest", "b": [0.2458, 0.5346, 0.2764, 0.556]}, {"w": "to", "b": [0.2818, 0.5346, 0.2988, 0.556]}, {"w": "the", "b": [0.3042, 0.5346, 0.3305, 0.556]}, {"w": "right", "b": [0.3359, 0.5346, 0.3761, 0.556]}, {"w": "people,", "b": [0.3815, 0.5346, 0.4417, 0.556]}, {"w": "including", "b": [0.4471, 0.5346, 0.5269, 0.556]}, {"w": "Alexandre", "b": [0.5323, 0.5346, 0.6188, 0.556]}, {"w": "Passos,", "b": [0.6242, 0.5346, 0.6829, 0.556]}, {"w": "Allen", "b": [0.6883, 0.5346, 0.7335, 0.556]}, {"w": "Lavoie,", "b": [0.7389, 0.5346, 0.7984, 0.556]}, {"w": "André", "b": [0.8038, 0.5346, 0.8571, 0.556]}, {"w": "Susano", "b": [0.1429, 0.5536, 0.2026, 0.575]}, {"w": "Pinto,", "b": [0.2095, 0.5536, 0.2589, 0.575]}, {"w": "Anna", "b": [0.2658, 0.5536, 0.3121, 0.575]}, {"w": "Revinskaya,", "b": [0.319, 0.5536, 0.4176, 0.575]}, {"w": "Anthony", "b": [0.4245, 0.5536, 0.4985, 0.575]}, {"w": "Platanios,", "b": [0.5054, 0.5536, 0.5866, 0.575]}, {"w": "Clemens", "b": [0.5935, 0.5536, 0.6664, 0.575]}, {"w": "Mewald,", "b": [0.6733, 0.5536, 0.7446, 0.575]}, {"w": "Dan", "b": [0.7515, 0.5536, 0.7873, 0.575]}, {"w": "Moldo‐", "b": [0.7942, 0.5536, 0.8572, 0.575]}, {"w": "van,", "b": [0.1429, 0.5727, 0.1778, 0.5941]}, {"w": "Daniel", "b": [0.1838, 0.5727, 0.2393, 0.5941]}, {"w": "Dobson,", "b": [0.2453, 0.5727, 0.3162, 0.5941]}, {"w": "Dustin", "b": [0.3222, 0.5727, 0.3796, 0.5941]}, {"w": "Tran,", "b": [0.3856, 0.5727, 0.4297, 0.5941]}, {"w": "Edd", "b": [0.4357, 0.5727, 0.4695, 0.5941]}, {"w": "Wilder-James,", "b": [0.4755, 0.5727, 0.5939, 0.5941]}, {"w": "Goldie", "b": [0.5999, 0.5727, 0.6561, 0.5941]}, {"w": "Gadde,", "b": [0.6621, 0.5727, 0.7218, 0.5941]}, {"w": "Jiri", "b": [0.7277, 0.5727, 0.7528, 0.5941]}, {"w": "Simsa,", "b": [0.7588, 0.5727, 0.8129, 0.5941]}, {"w": "Kar‐", "b": [0.8188, 0.5727, 0.8571, 0.5941]}, {"w": "mel", "b": [0.1429, 0.5917, 0.174, 0.6131]}, {"w": "Allison,", "b": [0.1799, 0.5917, 0.2448, 0.6131]}, {"w": "Nick", "b": [0.2506, 0.5917, 0.2904, 0.6131]}, {"w": "Felt,", "b": [0.2962, 0.5917, 0.3321, 0.6131]}, {"w": "Paige", "b": [0.3379, 0.5917, 0.3825, 0.6131]}, {"w": "Bailey,", "b": [0.3884, 0.5917, 0.4423, 0.6131]}, {"w": "Pete", "b": [0.4481, 0.5917, 0.4832, 0.6131]}, {"w": "Warden", "b": [0.4891, 0.5917, 0.5554, 0.6131]}, {"w": "(who", "b": [0.5612, 0.5917, 0.6044, 0.6131]}, {"w": "also", "b": [0.6102, 0.5917, 0.6429, 0.6131]}, {"w": "reviewed", "b": [0.6488, 0.5917, 0.7236, 0.6131]}, {"w": "the", "b": [0.7294, 0.5917, 0.7557, 0.6131]}, {"w": "1st", "b": [0.7616, 0.5917, 0.78, 0.6131]}, {"w": "edition),", "b": [0.7858, 0.5917, 0.8571, 0.6131]}, {"w": "Ryan", "b": [0.1429, 0.6108, 0.1852, 0.6322]}, {"w": "Sepassi,", "b": [0.194, 0.6108, 0.2584, 0.6322]}, {"w": "Sandeep", "b": [0.2673, 0.6108, 0.3373, 0.6322]}, {"w": "Gupta,", "b": [0.3461, 0.6108, 0.4033, 0.6322]}, {"w": "Sean", "b": [0.4121, 0.6108, 0.4513, 0.6322]}, {"w": "Morgan,", "b": [0.4602, 0.6108, 0.5316, 0.6322]}, {"w": "Todd", "b": [0.5404, 0.6108, 0.5838, 0.6322]}, {"w": "Wang,", "b": [0.5927, 0.6108, 0.6459, 0.6322]}, {"w": "Tom", "b": [0.6547, 0.6108, 0.6932, 0.6322]}, {"w": "O’Malley,", "b": [0.702, 0.6108, 0.781, 0.6322]}, {"w": "William", "b": [0.7898, 0.6108, 0.8571, 0.6322]}, {"w": "Chargin,", "b": [0.1429, 0.6298, 0.2162, 0.6512]}, {"w": "and", "b": [0.2229, 0.6298, 0.2545, 0.6512]}, {"w": "Yuefeng", "b": [0.2612, 0.6298, 0.3284, 0.6512]}, {"w": "Zhou,", "b": [0.3352, 0.6298, 0.3853, 0.6512]}, {"w": "all", "b": [0.392, 0.6298, 0.4117, 0.6512]}, {"w": "of", "b": [0.4185, 0.6298, 0.4352, 0.6512]}, {"w": "whom", "b": [0.442, 0.6298, 0.4951, 0.6512]}, {"w": "were", "b": [0.5018, 0.6298, 0.5415, 0.6512]}, {"w": "tremendously", "b": [0.5482, 0.6298, 0.6637, 0.6512]}, {"w": "helpful.", "b": [0.6704, 0.6298, 0.7338, 0.6512]}, {"w": "A", "b": [0.7405, 0.6298, 0.7549, 0.6512]}, {"w": "huge", "b": [0.7617, 0.6298, 0.8021, 0.6512]}, {"w": "thank", "b": [0.8088, 0.6298, 0.8572, 0.6512]}, {"w": "you", "b": [0.1429, 0.6489, 0.1741, 0.6703]}, {"w": "to", "b": [0.1794, 0.6489, 0.1964, 0.6703]}, {"w": "all", "b": [0.2016, 0.6489, 0.2213, 0.6703]}, {"w": "of", "b": [0.2266, 0.6489, 0.2434, 0.6703]}, {"w": "you,", "b": [0.2486, 0.6489, 0.2846, 0.6703]}, {"w": "and", "b": [0.2899, 0.6489, 0.3214, 0.6703]}, {"w": "to", "b": [0.3267, 0.6489, 0.3437, 0.6703]}, {"w": "all", "b": [0.3489, 0.6489, 0.3686, 0.6703]}, {"w": "other", "b": [0.3739, 0.6489, 0.4186, 0.6703]}, {"w": "members", "b": [0.4239, 0.6489, 0.5016, 0.6703]}, {"w": "of", "b": [0.5069, 0.6489, 0.5237, 0.6703]}, {"w": "the", "b": [0.529, 0.6489, 0.5553, 0.6703]}, {"w": "TensorFlow", "b": [0.5606, 0.6489, 0.6588, 0.6703]}, {"w": "team.", "b": [0.6641, 0.6489, 0.7102, 0.6703]}, {"w": "Not", "b": [0.7155, 0.6489, 0.7475, 0.6703]}, {"w": "just", "b": [0.7527, 0.6489, 0.7831, 0.6703]}, {"w": "for", "b": [0.7884, 0.6489, 0.8129, 0.6703]}, {"w": "your", "b": [0.8182, 0.6489, 0.8571, 0.6703]}, {"w": "help,", "b": [0.1429, 0.6679, 0.1832, 0.6893]}, {"w": "but", "b": [0.1879, 0.6679, 0.2159, 0.6893]}, {"w": "also", "b": [0.2206, 0.6679, 0.2533, 0.6893]}, {"w": "for", "b": [0.258, 0.6679, 0.2826, 0.6893]}, {"w": "making", "b": [0.2873, 0.6679, 0.3506, 0.6893]}, {"w": "such", "b": [0.3553, 0.6679, 0.3939, 0.6893]}, {"w": "a", "b": [0.3987, 0.6679, 0.4078, 0.6893]}, {"w": "great", "b": [0.4125, 0.6679, 0.454, 0.6893]}, {"w": "library.", "b": [0.4587, 0.6679, 0.5181, 0.6893]}]}, {"id": "b_6", "type": "paragraph", "text": "Big thanks to Haesun Park, who gave me plenty of excellent feedback and caught sev‐ eral errors while he was writing the Korean translation of the 1st edition of this book. He also translated the Jupyter notebooks to Korean, not to mention TensorFlow’s documentation. I do not speak Korean, but judging by the quality of his feedback, all his translations must be truly excellent! Moreover, he kindly contributed some of the solutions to the exercises in this book.", "words": [{"w": "Big", "b": [0.1429, 0.696, 0.1704, 0.7174]}, {"w": "thanks", "b": [0.1756, 0.696, 0.2316, 0.7174]}, {"w": "to", "b": [0.2367, 0.696, 0.2537, 0.7174]}, {"w": "Haesun", "b": [0.2588, 0.696, 0.3224, 0.7174]}, {"w": "Park,", "b": [0.3275, 0.696, 0.3707, 0.7174]}, {"w": "who", "b": [0.3759, 0.696, 0.4119, 0.7174]}, {"w": "gave", "b": [0.417, 0.696, 0.454, 0.7174]}, {"w": "me", "b": [0.4592, 0.696, 0.4851, 0.7174]}, {"w": "plenty", "b": [0.4902, 0.696, 0.5422, 0.7174]}, {"w": "of", "b": [0.5473, 0.696, 0.5641, 0.7174]}, {"w": "excellent", "b": [0.5692, 0.696, 0.6423, 0.7174]}, {"w": "feedback", "b": [0.6474, 0.696, 0.7212, 0.7174]}, {"w": "and", "b": [0.7263, 0.696, 0.7579, 0.7174]}, {"w": "caught", "b": [0.763, 0.696, 0.8184, 0.7174]}, {"w": "sev‐", "b": [0.8236, 0.696, 0.8571, 0.7174]}, {"w": "eral", "b": [0.1429, 0.7151, 0.1739, 0.7365]}, {"w": "errors", "b": [0.1794, 0.7151, 0.2297, 0.7365]}, {"w": "while", "b": [0.2352, 0.7151, 0.2803, 0.7365]}, {"w": "he", "b": [0.2859, 0.7151, 0.3059, 0.7365]}, {"w": "was", "b": [0.3114, 0.7151, 0.3425, 0.7365]}, {"w": "writing", "b": [0.348, 0.7151, 0.4086, 0.7365]}, {"w": "the", "b": [0.4142, 0.7151, 0.4405, 0.7365]}, {"w": "Korean", "b": [0.446, 0.7151, 0.5073, 0.7365]}, {"w": "translation", "b": [0.5128, 0.7151, 0.6031, 0.7365]}, {"w": "of", "b": [0.6086, 0.7151, 0.6254, 0.7365]}, {"w": "the", "b": [0.631, 0.7151, 0.6573, 0.7365]}, {"w": "1st", "b": [0.6628, 0.7151, 0.6812, 0.7365]}, {"w": "edition", "b": [0.6867, 0.7151, 0.7461, 0.7365]}, {"w": "of", "b": [0.7517, 0.7151, 0.7685, 0.7365]}, {"w": "this", "b": [0.774, 0.7151, 0.8047, 0.7365]}, {"w": "book.", "b": [0.8102, 0.7151, 0.8571, 0.7365]}, {"w": "He", "b": [0.1429, 0.7341, 0.1671, 0.7555]}, {"w": "also", "b": [0.1756, 0.7341, 0.2083, 0.7555]}, {"w": "translated", "b": [0.2167, 0.7341, 0.2992, 0.7555]}, {"w": "the", "b": [0.3077, 0.7341, 0.334, 0.7555]}, {"w": "Jupyter", "b": [0.3425, 0.7341, 0.4031, 0.7555]}, {"w": "notebooks", "b": [0.4116, 0.7341, 0.4986, 0.7555]}, {"w": "to", "b": [0.5071, 0.7341, 0.5241, 0.7555]}, {"w": "Korean,", "b": [0.5325, 0.7341, 0.5985, 0.7555]}, {"w": "not", "b": [0.607, 0.7341, 0.6354, 0.7555]}, {"w": "to", "b": [0.6438, 0.7341, 0.6608, 0.7555]}, {"w": "mention", "b": [0.6692, 0.7341, 0.7401, 0.7555]}, {"w": "TensorFlow’s", "b": [0.7486, 0.7341, 0.8571, 0.7555]}, {"w": "documentation.", "b": [0.1429, 0.7532, 0.2751, 0.7746]}, {"w": "I", "b": [0.2806, 0.7532, 0.2877, 0.7746]}, {"w": "do", "b": [0.2932, 0.7532, 0.3148, 0.7746]}, {"w": "not", "b": [0.3203, 0.7532, 0.3486, 0.7746]}, {"w": "speak", "b": [0.3541, 0.7532, 0.401, 0.7746]}, {"w": "Korean,", "b": [0.4065, 0.7532, 0.4725, 0.7746]}, {"w": "but", "b": [0.478, 0.7532, 0.506, 0.7746]}, {"w": "judging", "b": [0.5115, 0.7532, 0.5754, 0.7746]}, {"w": "by", "b": [0.5808, 0.7532, 0.601, 0.7746]}, {"w": "the", "b": [0.6065, 0.7532, 0.6328, 0.7746]}, {"w": "quality", "b": [0.6383, 0.7532, 0.6959, 0.7746]}, {"w": "of", "b": [0.7014, 0.7532, 0.7182, 0.7746]}, {"w": "his", "b": [0.7236, 0.7532, 0.748, 0.7746]}, {"w": "feedback,", "b": [0.7535, 0.7532, 0.832, 0.7746]}, {"w": "all", "b": [0.8375, 0.7532, 0.8572, 0.7746]}, {"w": "his", "b": [0.1429, 0.7722, 0.1672, 0.7936]}, {"w": "translations", "b": [0.1729, 0.7722, 0.2708, 0.7936]}, {"w": "must", "b": [0.2765, 0.7722, 0.3182, 0.7936]}, {"w": "be", "b": [0.3239, 0.7722, 0.3433, 0.7936]}, {"w": "truly", "b": [0.349, 0.7722, 0.389, 0.7936]}, {"w": "excellent!", "b": [0.3946, 0.7722, 0.4735, 0.7936]}, {"w": "Moreover,", "b": [0.4792, 0.7722, 0.5647, 0.7936]}, {"w": "he", "b": [0.5704, 0.7722, 0.5903, 0.7936]}, {"w": "kindly", "b": [0.596, 0.7722, 0.6492, 0.7936]}, {"w": "contributed", "b": [0.6548, 0.7722, 0.7528, 0.7936]}, {"w": "some", "b": [0.7585, 0.7722, 0.8027, 0.7936]}, {"w": "of", "b": [0.8083, 0.7722, 0.8251, 0.7936]}, {"w": "the", "b": [0.8308, 0.7722, 0.8571, 0.7936]}, {"w": "solutions", "b": [0.1429, 0.7913, 0.2191, 0.8127]}, {"w": "to", "b": [0.2238, 0.7913, 0.2408, 0.8127]}, {"w": "the", "b": [0.2455, 0.7913, 0.2718, 0.8127]}, {"w": "exercises", "b": [0.2766, 0.7913, 0.3504, 0.8127]}, {"w": "in", "b": [0.3551, 0.7913, 0.3721, 0.8127]}, {"w": "this", "b": [0.3768, 0.7913, 0.4075, 0.8127]}, {"w": "book.", "b": [0.4123, 0.7913, 0.4592, 0.8127]}]}, {"id": "b_7", "type": "paragraph", "text": "Preface | xxiii", "words": [{"w": "Preface", "b": [0.7495, 0.9225, 0.7935, 0.9388]}, {"w": "|", "b": [0.8113, 0.9225, 0.8151, 0.9388]}, {"w": "xxiii", "b": [0.8329, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 26, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Many thanks as well to O’Reilly’s fantastic staff, in particular Nicole Tache, who gave me insightful feedback, always cheerful, encouraging, and helpful: I could not dream of a better editor. Big thanks to Michele Cronin as well, who was very helpful (and patient) at the start of this 2nd edition. Thanks to Marie Beaugureau, Ben Lorica, Mike Loukides, and Laurel Ruma for believing in this project and helping me define its scope. Thanks to Matt Hacker and all of the Atlas team for answering all my technical questions regarding formatting, asciidoc, and LaTeX, and thanks to Rachel Mona‐ ghan, Nick Adams, and all of the production team for their final review and their hundreds of corrections.", "words": [{"w": "Many", "b": [0.1429, 0.0791, 0.1907, 0.1005]}, {"w": "thanks", "b": [0.1965, 0.0791, 0.2525, 0.1005]}, {"w": "as", "b": [0.2583, 0.0791, 0.2751, 0.1005]}, {"w": "well", "b": [0.281, 0.0791, 0.3146, 0.1005]}, {"w": "to", "b": [0.3205, 0.0791, 0.3374, 0.1005]}, {"w": "O’Reilly’s", "b": [0.3433, 0.0791, 0.4205, 0.1005]}, {"w": "fantastic", "b": [0.4263, 0.0791, 0.4965, 0.1005]}, {"w": "staff,", "b": [0.5024, 0.0791, 0.5426, 0.1005]}, {"w": "in", "b": [0.5484, 0.0791, 0.5654, 0.1005]}, {"w": "particular", "b": [0.5712, 0.0791, 0.653, 0.1005]}, {"w": "Nicole", "b": [0.6588, 0.0791, 0.713, 0.1005]}, {"w": "Tache,", "b": [0.7188, 0.0791, 0.7724, 0.1005]}, {"w": "who", "b": [0.7783, 0.0791, 0.8143, 0.1005]}, {"w": "gave", "b": [0.8201, 0.0791, 0.8571, 0.1005]}, {"w": "me", "b": [0.1429, 0.0981, 0.1688, 0.1195]}, {"w": "insightful", "b": [0.1745, 0.0981, 0.2541, 0.1195]}, {"w": "feedback,", "b": [0.2598, 0.0981, 0.3383, 0.1195]}, {"w": "always", "b": [0.344, 0.0981, 0.3987, 0.1195]}, {"w": "cheerful,", "b": [0.4045, 0.0981, 0.4771, 0.1195]}, {"w": "encouraging,", "b": [0.4828, 0.0981, 0.5917, 0.1195]}, {"w": "and", "b": [0.5974, 0.0981, 0.629, 0.1195]}, {"w": "helpful:", "b": [0.6347, 0.0981, 0.6981, 0.1195]}, {"w": "I", "b": [0.7039, 0.0981, 0.711, 0.1195]}, {"w": "could", "b": [0.7167, 0.0981, 0.7635, 0.1195]}, {"w": "not", "b": [0.7692, 0.0981, 0.7976, 0.1195]}, {"w": "dream", "b": [0.8033, 0.0981, 0.8571, 0.1195]}, {"w": "of", "b": [0.1429, 0.1172, 0.1597, 0.1386]}, {"w": "a", "b": [0.1664, 0.1172, 0.1756, 0.1386]}, {"w": "better", "b": [0.1824, 0.1172, 0.2311, 0.1386]}, {"w": "editor.", "b": [0.2379, 0.1172, 0.2915, 0.1386]}, {"w": "Big", "b": [0.2982, 0.1172, 0.3258, 0.1386]}, {"w": "thanks", "b": [0.3326, 0.1172, 0.3886, 0.1386]}, {"w": "to", "b": [0.3954, 0.1172, 0.4124, 0.1386]}, {"w": "Michele", "b": [0.4191, 0.1172, 0.4862, 0.1386]}, {"w": "Cronin", "b": [0.493, 0.1172, 0.5536, 0.1386]}, {"w": "as", "b": [0.5604, 0.1172, 0.5771, 0.1386]}, {"w": "well,", "b": [0.5839, 0.1172, 0.6223, 0.1386]}, {"w": "who", "b": [0.6291, 0.1172, 0.6652, 0.1386]}, {"w": "was", "b": [0.6719, 0.1172, 0.703, 0.1386]}, {"w": "very", "b": [0.7098, 0.1172, 0.7462, 0.1386]}, {"w": "helpful", "b": [0.753, 0.1172, 0.8116, 0.1386]}, {"w": "(and", "b": [0.8184, 0.1172, 0.8572, 0.1386]}, {"w": "patient)", "b": [0.1429, 0.1362, 0.2079, 0.1576]}, {"w": "at", "b": [0.2128, 0.1362, 0.2279, 0.1576]}, {"w": "the", "b": [0.2329, 0.1362, 0.2592, 0.1576]}, {"w": "start", "b": [0.2641, 0.1362, 0.3014, 0.1576]}, {"w": "of", "b": [0.3063, 0.1362, 0.3231, 0.1576]}, {"w": "this", "b": [0.328, 0.1362, 0.3587, 0.1576]}, {"w": "2nd", "b": [0.3637, 0.1362, 0.3871, 0.1576]}, {"w": "edition.", "b": [0.392, 0.1362, 0.4562, 0.1576]}, {"w": "Thanks", "b": [0.4611, 0.1362, 0.5236, 0.1576]}, {"w": "to", "b": [0.5286, 0.1362, 0.5455, 0.1576]}, {"w": "Marie", "b": [0.5505, 0.1362, 0.6, 0.1576]}, {"w": "Beaugureau,", "b": [0.6049, 0.1362, 0.7082, 0.1576]}, {"w": "Ben", "b": [0.7132, 0.1362, 0.7461, 0.1576]}, {"w": "Lorica,", "b": [0.751, 0.1362, 0.8089, 0.1576]}, {"w": "Mike", "b": [0.8138, 0.1362, 0.8571, 0.1576]}, {"w": "Loukides,", "b": [0.1429, 0.1553, 0.2239, 0.1767]}, {"w": "and", "b": [0.2317, 0.1553, 0.2632, 0.1767]}, {"w": "Laurel", "b": [0.271, 0.1553, 0.3239, 0.1767]}, {"w": "Ruma", "b": [0.3316, 0.1553, 0.3814, 0.1767]}, {"w": "for", "b": [0.3891, 0.1553, 0.4137, 0.1767]}, {"w": "believing", "b": [0.4214, 0.1553, 0.4969, 0.1767]}, {"w": "in", "b": [0.5047, 0.1553, 0.5217, 0.1767]}, {"w": "this", "b": [0.5295, 0.1553, 0.5602, 0.1767]}, {"w": "project", "b": [0.5679, 0.1553, 0.6265, 0.1767]}, {"w": "and", "b": [0.6343, 0.1553, 0.6658, 0.1767]}, {"w": "helping", "b": [0.6736, 0.1553, 0.7365, 0.1767]}, {"w": "me", "b": [0.7443, 0.1553, 0.7702, 0.1767]}, {"w": "define", "b": [0.7779, 0.1553, 0.8298, 0.1767]}, {"w": "its", "b": [0.8376, 0.1553, 0.8571, 0.1767]}, {"w": "scope.", "b": [0.1428, 0.1743, 0.1945, 0.1957]}, {"w": "Thanks", "b": [0.1994, 0.1743, 0.2619, 0.1957]}, {"w": "to", "b": [0.2668, 0.1743, 0.2838, 0.1957]}, {"w": "Matt", "b": [0.2887, 0.1743, 0.3284, 0.1957]}, {"w": "Hacker", "b": [0.3333, 0.1743, 0.3937, 0.1957]}, {"w": "and", "b": [0.3986, 0.1743, 0.4301, 0.1957]}, {"w": "all", "b": [0.4351, 0.1743, 0.4548, 0.1957]}, {"w": "of", "b": [0.4597, 0.1743, 0.4765, 0.1957]}, {"w": "the", "b": [0.4814, 0.1743, 0.5077, 0.1957]}, {"w": "Atlas", "b": [0.5127, 0.1743, 0.5546, 0.1957]}, {"w": "team", "b": [0.5596, 0.1743, 0.601, 0.1957]}, {"w": "for", "b": [0.6059, 0.1743, 0.6304, 0.1957]}, {"w": "answering", "b": [0.6354, 0.1743, 0.7211, 0.1957]}, {"w": "all", "b": [0.7261, 0.1743, 0.7458, 0.1957]}, {"w": "my", "b": [0.7507, 0.1743, 0.7768, 0.1957]}, {"w": "technical", "b": [0.7818, 0.1743, 0.8571, 0.1957]}, {"w": "questions", "b": [0.1429, 0.1933, 0.2227, 0.2148]}, {"w": "regarding", "b": [0.2306, 0.1933, 0.3116, 0.2148]}, {"w": "formatting,", "b": [0.3195, 0.1933, 0.414, 0.2148]}, {"w": "asciidoc,", "b": [0.422, 0.1933, 0.4939, 0.2148]}, {"w": "and", "b": [0.5019, 0.1933, 0.5334, 0.2148]}, {"w": "LaTeX,", "b": [0.5414, 0.1933, 0.5998, 0.2148]}, {"w": "and", "b": [0.6077, 0.1933, 0.6393, 0.2148]}, {"w": "thanks", "b": [0.6472, 0.1933, 0.7032, 0.2148]}, {"w": "to", "b": [0.7112, 0.1933, 0.7281, 0.2148]}, {"w": "Rachel", "b": [0.7361, 0.1933, 0.7926, 0.2148]}, {"w": "Mona‐", "b": [0.8005, 0.1933, 0.8571, 0.2148]}, {"w": "ghan,", "b": [0.1429, 0.2124, 0.189, 0.2338]}, {"w": "Nick", "b": [0.1967, 0.2124, 0.2364, 0.2338]}, {"w": "Adams,", "b": [0.2441, 0.2124, 0.3076, 0.2338]}, {"w": "and", "b": [0.3152, 0.2124, 0.3468, 0.2338]}, {"w": "all", "b": [0.3544, 0.2124, 0.3741, 0.2338]}, {"w": "of", "b": [0.3818, 0.2124, 0.3985, 0.2338]}, {"w": "the", "b": [0.4062, 0.2124, 0.4325, 0.2338]}, {"w": "production", "b": [0.4402, 0.2124, 0.5343, 0.2338]}, {"w": "team", "b": [0.5419, 0.2124, 0.5834, 0.2338]}, {"w": "for", "b": [0.591, 0.2124, 0.6155, 0.2338]}, {"w": "their", "b": [0.6232, 0.2124, 0.6628, 0.2338]}, {"w": "final", "b": [0.6705, 0.2124, 0.7081, 0.2338]}, {"w": "review", "b": [0.7157, 0.2124, 0.7706, 0.2338]}, {"w": "and", "b": [0.7783, 0.2124, 0.8098, 0.2338]}, {"w": "their", "b": [0.8175, 0.2124, 0.8571, 0.2338]}, {"w": "hundreds", "b": [0.1429, 0.2314, 0.2223, 0.2529]}, {"w": "of", "b": [0.227, 0.2314, 0.2438, 0.2529]}, {"w": "corrections.", "b": [0.2485, 0.2314, 0.3474, 0.2529]}]}, {"id": "b_1", "type": "paragraph", "text": "I would also like to thank my former Google colleagues, in particular the YouTube video classification team, for teaching me so much about Machine Learning. I could never have started the first edition without them. Special thanks to my personal ML gurus: Clément Courbet, Julien Dubois, Mathias Kende, Daniel Kitachewsky, James Pack, Alexander Pak, Anosh Raj, Vitor Sessak, Wiktor Tomczak, Ingrid von Glehn, Rich Washington, and everyone I worked with at YouTube and in the amazing Goo‐ gle research teams in Mountain View. All these people are just as nice and helpful as they are bright, and that’s saying a lot.", "words": [{"w": "I", "b": [0.1429, 0.2596, 0.15, 0.281]}, {"w": "would", "b": [0.1572, 0.2596, 0.2094, 0.281]}, {"w": "also", "b": [0.2166, 0.2596, 0.2493, 0.281]}, {"w": "like", "b": [0.2565, 0.2596, 0.2866, 0.281]}, {"w": "to", "b": [0.2938, 0.2596, 0.3107, 0.281]}, {"w": "thank", "b": [0.318, 0.2596, 0.3663, 0.281]}, {"w": "my", "b": [0.3735, 0.2596, 0.3997, 0.281]}, {"w": "former", "b": [0.4069, 0.2596, 0.465, 0.281]}, {"w": "Google", "b": [0.4723, 0.2596, 0.5323, 0.281]}, {"w": "colleagues,", "b": [0.5395, 0.2596, 0.6295, 0.281]}, {"w": "in", "b": [0.6367, 0.2596, 0.6537, 0.281]}, {"w": "particular", "b": [0.6609, 0.2596, 0.7427, 0.281]}, {"w": "the", "b": [0.7499, 0.2596, 0.7762, 0.281]}, {"w": "YouTube", "b": [0.7834, 0.2596, 0.8571, 0.281]}, {"w": "video", "b": [0.1429, 0.2786, 0.1886, 0.3]}, {"w": "classification", "b": [0.1947, 0.2786, 0.302, 0.3]}, {"w": "team,", "b": [0.3081, 0.2786, 0.3543, 0.3]}, {"w": "for", "b": [0.3604, 0.2786, 0.3849, 0.3]}, {"w": "teaching", "b": [0.391, 0.2786, 0.462, 0.3]}, {"w": "me", "b": [0.4681, 0.2786, 0.494, 0.3]}, {"w": "so", "b": [0.5001, 0.2786, 0.5184, 0.3]}, {"w": "much", "b": [0.5245, 0.2786, 0.5721, 0.3]}, {"w": "about", "b": [0.5782, 0.2786, 0.626, 0.3]}, {"w": "Machine", "b": [0.6321, 0.2786, 0.7052, 0.3]}, {"w": "Learning.", "b": [0.7113, 0.2786, 0.7911, 0.3]}, {"w": "I", "b": [0.7972, 0.2786, 0.8043, 0.3]}, {"w": "could", "b": [0.8104, 0.2786, 0.8572, 0.3]}, {"w": "never", "b": [0.1429, 0.2977, 0.1893, 0.3191]}, {"w": "have", "b": [0.1955, 0.2977, 0.2339, 0.3191]}, {"w": "started", "b": [0.2401, 0.2977, 0.2972, 0.3191]}, {"w": "the", "b": [0.3034, 0.2977, 0.3298, 0.3191]}, {"w": "first", "b": [0.336, 0.2977, 0.3695, 0.3191]}, {"w": "edition", "b": [0.3757, 0.2977, 0.4351, 0.3191]}, {"w": "without", "b": [0.4413, 0.2977, 0.5066, 0.3191]}, {"w": "them.", "b": [0.5128, 0.2977, 0.561, 0.3191]}, {"w": "Special", "b": [0.5672, 0.2977, 0.6256, 0.3191]}, {"w": "thanks", "b": [0.6318, 0.2977, 0.6878, 0.3191]}, {"w": "to", "b": [0.6941, 0.2977, 0.711, 0.3191]}, {"w": "my", "b": [0.7172, 0.2977, 0.7434, 0.3191]}, {"w": "personal", "b": [0.7496, 0.2977, 0.8212, 0.3191]}, {"w": "ML", "b": [0.8274, 0.2977, 0.8571, 0.3191]}, {"w": "gurus:", "b": [0.1429, 0.3167, 0.1949, 0.3381]}, {"w": "Clément", "b": [0.202, 0.3167, 0.2733, 0.3381]}, {"w": "Courbet,", "b": [0.2805, 0.3167, 0.3543, 0.3381]}, {"w": "Julien", "b": [0.3615, 0.3167, 0.4098, 0.3381]}, {"w": "Dubois,", "b": [0.417, 0.3167, 0.4826, 0.3381]}, {"w": "Mathias", "b": [0.4897, 0.3167, 0.5566, 0.3381]}, {"w": "Kende,", "b": [0.5637, 0.3167, 0.6221, 0.3381]}, {"w": "Daniel", "b": [0.6293, 0.3167, 0.6849, 0.3381]}, {"w": "Kitachewsky,", "b": [0.692, 0.3167, 0.801, 0.3381]}, {"w": "James", "b": [0.8082, 0.3167, 0.8571, 0.3381]}, {"w": "Pack,", "b": [0.1428, 0.3358, 0.1872, 0.3572]}, {"w": "Alexander", "b": [0.1942, 0.3358, 0.2807, 0.3572]}, {"w": "Pak,", "b": [0.2877, 0.3358, 0.3232, 0.3572]}, {"w": "Anosh", "b": [0.3303, 0.3358, 0.3855, 0.3572]}, {"w": "Raj,", "b": [0.3925, 0.3358, 0.4247, 0.3572]}, {"w": "Vitor", "b": [0.4317, 0.3358, 0.4758, 0.3572]}, {"w": "Sessak,", "b": [0.4828, 0.3358, 0.5411, 0.3572]}, {"w": "Wiktor", "b": [0.5481, 0.3358, 0.6081, 0.3572]}, {"w": "Tomczak,", "b": [0.6152, 0.3358, 0.6955, 0.3572]}, {"w": "Ingrid", "b": [0.7025, 0.3358, 0.7551, 0.3572]}, {"w": "von", "b": [0.7621, 0.3358, 0.7938, 0.3572]}, {"w": "Glehn,", "b": [0.8008, 0.3358, 0.8571, 0.3572]}, {"w": "Rich", "b": [0.1429, 0.3548, 0.1813, 0.3762]}, {"w": "Washington,", "b": [0.1872, 0.3548, 0.2932, 0.3762]}, {"w": "and", "b": [0.2991, 0.3548, 0.3306, 0.3762]}, {"w": "everyone", "b": [0.3366, 0.3548, 0.4127, 0.3762]}, {"w": "I", "b": [0.4186, 0.3548, 0.4257, 0.3762]}, {"w": "worked", "b": [0.4316, 0.3548, 0.4944, 0.3762]}, {"w": "with", "b": [0.5003, 0.3548, 0.5377, 0.3762]}, {"w": "at", "b": [0.5436, 0.3548, 0.5587, 0.3762]}, {"w": "YouTube", "b": [0.5646, 0.3548, 0.6383, 0.3762]}, {"w": "and", "b": [0.6442, 0.3548, 0.6758, 0.3762]}, {"w": "in", "b": [0.6817, 0.3548, 0.6987, 0.3762]}, {"w": "the", "b": [0.7046, 0.3548, 0.7309, 0.3762]}, {"w": "amazing", "b": [0.7368, 0.3548, 0.8077, 0.3762]}, {"w": "Goo‐", "b": [0.8136, 0.3548, 0.8571, 0.3762]}, {"w": "gle", "b": [0.1429, 0.3738, 0.1667, 0.3953]}, {"w": "research", "b": [0.1726, 0.3738, 0.2425, 0.3953]}, {"w": "teams", "b": [0.2483, 0.3738, 0.2974, 0.3953]}, {"w": "in", "b": [0.3032, 0.3738, 0.3202, 0.3953]}, {"w": "Mountain", "b": [0.3261, 0.3738, 0.4093, 0.3953]}, {"w": "View.", "b": [0.4151, 0.3738, 0.4608, 0.3953]}, {"w": "All", "b": [0.4667, 0.3738, 0.4916, 0.3953]}, {"w": "these", "b": [0.4975, 0.3738, 0.5403, 0.3953]}, {"w": "people", "b": [0.5462, 0.3738, 0.6016, 0.3953]}, {"w": "are", "b": [0.6075, 0.3738, 0.6332, 0.3953]}, {"w": "just", "b": [0.639, 0.3738, 0.6694, 0.3953]}, {"w": "as", "b": [0.6753, 0.3738, 0.6921, 0.3953]}, {"w": "nice", "b": [0.6979, 0.3738, 0.7326, 0.3953]}, {"w": "and", "b": [0.7384, 0.3738, 0.77, 0.3953]}, {"w": "helpful", "b": [0.7758, 0.3738, 0.8345, 0.3953]}, {"w": "as", "b": [0.8404, 0.3738, 0.8571, 0.3953]}, {"w": "they", "b": [0.1429, 0.3929, 0.1787, 0.4143]}, {"w": "are", "b": [0.1835, 0.3929, 0.2092, 0.4143]}, {"w": "bright,", "b": [0.2139, 0.3929, 0.2694, 0.4143]}, {"w": "and", "b": [0.2741, 0.3929, 0.3057, 0.4143]}, {"w": "that’s", "b": [0.3104, 0.3929, 0.3527, 0.4143]}, {"w": "saying", "b": [0.3575, 0.3929, 0.4102, 0.4143]}, {"w": "a", "b": [0.4149, 0.3929, 0.4241, 0.4143]}, {"w": "lot.", "b": [0.4288, 0.3929, 0.4558, 0.4143]}]}, {"id": "b_2", "type": "paragraph", "text": "I will never forget the kind people who reviewed the 1st edition of this book, including David Andrzejewski, Eddy Hung, Grégoire Mesnil, Iain Smears, Ingrid von Glehn, Justin Francis, Karim Matrah, Lukas Biewald, Michel Tessier, Salim Sémaoune, Vin‐ cent Guilbeau and of course my dear brother Sylvain.", "words": [{"w": "I", "b": [0.1429, 0.421, 0.15, 0.4424]}, {"w": "will", "b": [0.1547, 0.421, 0.1851, 0.4424]}, {"w": "never", "b": [0.1898, 0.421, 0.2363, 0.4424]}, {"w": "forget", "b": [0.241, 0.421, 0.2905, 0.4424]}, {"w": "the", "b": [0.2952, 0.421, 0.3216, 0.4424]}, {"w": "kind", "b": [0.3263, 0.421, 0.3646, 0.4424]}, {"w": "people", "b": [0.3693, 0.421, 0.4248, 0.4424]}, {"w": "who", "b": [0.4295, 0.421, 0.4655, 0.4424]}, {"w": "reviewed", "b": [0.4702, 0.421, 0.545, 0.4424]}, {"w": "the", "b": [0.5498, 0.421, 0.5761, 0.4424]}, {"w": "1st", "b": [0.5808, 0.421, 0.5996, 0.4424]}, {"w": "edition", "b": [0.6044, 0.421, 0.6638, 0.4424]}, {"w": "of", "b": [0.6685, 0.421, 0.6853, 0.4424]}, {"w": "this", "b": [0.69, 0.421, 0.7208, 0.4424]}, {"w": "book,", "b": [0.7255, 0.421, 0.7724, 0.4424]}, {"w": "including", "b": [0.7771, 0.421, 0.857, 0.4424]}, {"w": "David", "b": [0.1429, 0.4401, 0.1932, 0.4615]}, {"w": "Andrzejewski,", "b": [0.2007, 0.4401, 0.3196, 0.4615]}, {"w": "Eddy", "b": [0.3272, 0.4401, 0.3706, 0.4615]}, {"w": "Hung,", "b": [0.3782, 0.4401, 0.4303, 0.4615]}, {"w": "Grégoire", "b": [0.4379, 0.4401, 0.5119, 0.4615]}, {"w": "Mesnil,", "b": [0.5195, 0.4401, 0.581, 0.4615]}, {"w": "Iain", "b": [0.5885, 0.4401, 0.6213, 0.4615]}, {"w": "Smears,", "b": [0.6288, 0.4401, 0.6939, 0.4615]}, {"w": "Ingrid", "b": [0.7015, 0.4401, 0.754, 0.4615]}, {"w": "von", "b": [0.7616, 0.4401, 0.7933, 0.4615]}, {"w": "Glehn,", "b": [0.8009, 0.4401, 0.8571, 0.4615]}, {"w": "Justin", "b": [0.1429, 0.4591, 0.1911, 0.4805]}, {"w": "Francis,", "b": [0.1976, 0.4591, 0.2636, 0.4805]}, {"w": "Karim", "b": [0.2701, 0.4591, 0.3237, 0.4805]}, {"w": "Matrah,", "b": [0.3301, 0.4591, 0.3962, 0.4805]}, {"w": "Lukas", "b": [0.4027, 0.4591, 0.4516, 0.4805]}, {"w": "Biewald,", "b": [0.4581, 0.4591, 0.5292, 0.4805]}, {"w": "Michel", "b": [0.5357, 0.4591, 0.5939, 0.4805]}, {"w": "Tessier,", "b": [0.6004, 0.4591, 0.661, 0.4805]}, {"w": "Salim", "b": [0.6674, 0.4591, 0.7144, 0.4805]}, {"w": "Sémaoune,", "b": [0.7209, 0.4591, 0.8125, 0.4805]}, {"w": "Vin‐", "b": [0.819, 0.4591, 0.8571, 0.4805]}, {"w": "cent", "b": [0.1428, 0.4782, 0.1779, 0.4996]}, {"w": "Guilbeau", "b": [0.1826, 0.4782, 0.2587, 0.4996]}, {"w": "and", "b": [0.2634, 0.4782, 0.2949, 0.4996]}, {"w": "of", "b": [0.2997, 0.4782, 0.3165, 0.4996]}, {"w": "course", "b": [0.3212, 0.4782, 0.3759, 0.4996]}, {"w": "my", "b": [0.3806, 0.4782, 0.4068, 0.4996]}, {"w": "dear", "b": [0.4115, 0.4782, 0.4482, 0.4996]}, {"w": "brother", "b": [0.453, 0.4782, 0.516, 0.4996]}, {"w": "Sylvain.", "b": [0.5207, 0.4782, 0.5859, 0.4996]}]}, {"id": "b_3", "type": "paragraph", "text": "Last but not least, I am infinitely grateful to my beloved wife, Emmanuelle, and to our three wonderful children, Alexandre, Rémi, and Gabrielle, for encouraging me to work hard on this book, as well as for their insatiable curiosity: explaining some of the most difficult concepts in this book to my wife and children helped me clarify my thoughts and directly improved many parts of this book. Plus, they keep bringing me cookies and coffee! What more can one dream of?", "words": [{"w": "Last", "b": [0.1428, 0.5063, 0.1772, 0.5277]}, {"w": "but", "b": [0.1821, 0.5063, 0.2101, 0.5277]}, {"w": "not", "b": [0.2149, 0.5063, 0.2433, 0.5277]}, {"w": "least,", "b": [0.2481, 0.5063, 0.2902, 0.5277]}, {"w": "I", "b": [0.295, 0.5063, 0.3021, 0.5277]}, {"w": "am", "b": [0.307, 0.5063, 0.3332, 0.5277]}, {"w": "infinitely", "b": [0.3381, 0.5063, 0.4138, 0.5277]}, {"w": "grateful", "b": [0.4187, 0.5063, 0.4826, 0.5277]}, {"w": "to", "b": [0.4875, 0.5063, 0.5044, 0.5277]}, {"w": "my", "b": [0.5093, 0.5063, 0.5354, 0.5277]}, {"w": "beloved", "b": [0.5403, 0.5063, 0.6051, 0.5277]}, {"w": "wife,", "b": [0.61, 0.5063, 0.6496, 0.5277]}, {"w": "Emmanuelle,", "b": [0.6545, 0.5063, 0.7646, 0.5277]}, {"w": "and", "b": [0.7695, 0.5063, 0.801, 0.5277]}, {"w": "to", "b": [0.8059, 0.5063, 0.8229, 0.5277]}, {"w": "our", "b": [0.8277, 0.5063, 0.8571, 0.5277]}, {"w": "three", "b": [0.1429, 0.5253, 0.1858, 0.5467]}, {"w": "wonderful", "b": [0.1944, 0.5253, 0.2808, 0.5467]}, {"w": "children,", "b": [0.2894, 0.5253, 0.3639, 0.5467]}, {"w": "Alexandre,", "b": [0.3725, 0.5253, 0.4637, 0.5467]}, {"w": "Rémi,", "b": [0.4723, 0.5253, 0.5215, 0.5467]}, {"w": "and", "b": [0.5301, 0.5253, 0.5617, 0.5467]}, {"w": "Gabrielle,", "b": [0.5703, 0.5253, 0.6512, 0.5467]}, {"w": "for", "b": [0.6598, 0.5253, 0.6843, 0.5467]}, {"w": "encouraging", "b": [0.6929, 0.5253, 0.797, 0.5467]}, {"w": "me", "b": [0.8056, 0.5253, 0.8316, 0.5467]}, {"w": "to", "b": [0.8402, 0.5253, 0.8572, 0.5467]}, {"w": "work", "b": [0.1429, 0.5444, 0.1858, 0.5658]}, {"w": "hard", "b": [0.1926, 0.5444, 0.2316, 0.5658]}, {"w": "on", "b": [0.2384, 0.5444, 0.2604, 0.5658]}, {"w": "this", "b": [0.2672, 0.5444, 0.2979, 0.5658]}, {"w": "book,", "b": [0.3047, 0.5444, 0.3516, 0.5658]}, {"w": "as", "b": [0.3584, 0.5444, 0.3752, 0.5658]}, {"w": "well", "b": [0.382, 0.5444, 0.4157, 0.5658]}, {"w": "as", "b": [0.4224, 0.5444, 0.4392, 0.5658]}, {"w": "for", "b": [0.446, 0.5444, 0.4705, 0.5658]}, {"w": "their", "b": [0.4773, 0.5444, 0.517, 0.5658]}, {"w": "insatiable", "b": [0.5238, 0.5444, 0.6029, 0.5658]}, {"w": "curiosity:", "b": [0.6097, 0.5444, 0.6881, 0.5658]}, {"w": "explaining", "b": [0.6949, 0.5444, 0.7826, 0.5658]}, {"w": "some", "b": [0.7894, 0.5444, 0.8336, 0.5658]}, {"w": "of", "b": [0.8404, 0.5444, 0.8571, 0.5658]}, {"w": "the", "b": [0.1429, 0.5634, 0.1692, 0.5848]}, {"w": "most", "b": [0.1743, 0.5634, 0.216, 0.5848]}, {"w": "difficult", "b": [0.2211, 0.5634, 0.2871, 0.5848]}, {"w": "concepts", "b": [0.2923, 0.5634, 0.3657, 0.5848]}, {"w": "in", "b": [0.3708, 0.5634, 0.3878, 0.5848]}, {"w": "this", "b": [0.3929, 0.5634, 0.4236, 0.5848]}, {"w": "book", "b": [0.4288, 0.5634, 0.4709, 0.5848]}, {"w": "to", "b": [0.4761, 0.5634, 0.493, 0.5848]}, {"w": "my", "b": [0.4982, 0.5634, 0.5243, 0.5848]}, {"w": "wife", "b": [0.5295, 0.5634, 0.5643, 0.5848]}, {"w": "and", "b": [0.5695, 0.5634, 0.601, 0.5848]}, {"w": "children", "b": [0.6061, 0.5634, 0.6759, 0.5848]}, {"w": "helped", "b": [0.681, 0.5634, 0.7371, 0.5848]}, {"w": "me", "b": [0.7422, 0.5634, 0.7681, 0.5848]}, {"w": "clarify", "b": [0.7732, 0.5634, 0.8259, 0.5848]}, {"w": "my", "b": [0.831, 0.5634, 0.8571, 0.5848]}, {"w": "thoughts", "b": [0.1429, 0.5825, 0.2165, 0.6039]}, {"w": "and", "b": [0.2218, 0.5825, 0.2534, 0.6039]}, {"w": "directly", "b": [0.2587, 0.5825, 0.3218, 0.6039]}, {"w": "improved", "b": [0.3271, 0.5825, 0.4082, 0.6039]}, {"w": "many", "b": [0.4135, 0.5825, 0.4602, 0.6039]}, {"w": "parts", "b": [0.4655, 0.5825, 0.5073, 0.6039]}, {"w": "of", "b": [0.5126, 0.5825, 0.5294, 0.6039]}, {"w": "this", "b": [0.5347, 0.5825, 0.5654, 0.6039]}, {"w": "book.", "b": [0.5707, 0.5825, 0.6176, 0.6039]}, {"w": "Plus,", "b": [0.6229, 0.5825, 0.6634, 0.6039]}, {"w": "they", "b": [0.6687, 0.5825, 0.7046, 0.6039]}, {"w": "keep", "b": [0.7099, 0.5825, 0.7488, 0.6039]}, {"w": "bringing", "b": [0.7542, 0.5825, 0.8259, 0.6039]}, {"w": "me", "b": [0.8312, 0.5825, 0.8572, 0.6039]}, {"w": "cookies", "b": [0.1429, 0.6015, 0.2053, 0.6229]}, {"w": "and", "b": [0.2101, 0.6015, 0.2416, 0.6229]}, {"w": "coffee!", "b": [0.2463, 0.6015, 0.3016, 0.6229]}, {"w": "What", "b": [0.3063, 0.6015, 0.3528, 0.6229]}, {"w": "more", "b": [0.3575, 0.6015, 0.4018, 0.6229]}, {"w": "can", "b": [0.4065, 0.6015, 0.4358, 0.6229]}, {"w": "one", "b": [0.4406, 0.6015, 0.4714, 0.6229]}, {"w": "dream", "b": [0.4762, 0.6015, 0.53, 0.6229]}, {"w": "of?", "b": [0.5347, 0.6015, 0.561, 0.6229]}]}, {"id": "b_4", "type": "paragraph", "text": "xxiv | Preface", "words": [{"w": "xxiv", "b": [0.1429, 0.9225, 0.1664, 0.9388]}, {"w": "|", "b": [0.1843, 0.9225, 0.188, 0.9388]}, {"w": "Preface", "b": [0.2059, 0.9225, 0.2498, 0.9388]}]}]}, {"page": 27, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "PART I The Fundamentals of", "words": [{"w": "PART", "b": [0.779, 0.1147, 0.8427, 0.149]}, {"w": "I", "b": [0.8486, 0.1147, 0.8571, 0.149]}, {"w": "The", "b": [0.4672, 0.1513, 0.535, 0.2027]}, {"w": "Fundamentals", "b": [0.5439, 0.1513, 0.8105, 0.2027]}, {"w": "of", "b": [0.8194, 0.1513, 0.8571, 0.2027]}]}, {"id": "b_1", "type": "paragraph", "text": "Machine Learning", "words": [{"w": "Machine", "b": [0.5261, 0.1921, 0.6835, 0.2435]}, {"w": "Learning", "b": [0.6924, 0.1921, 0.8571, 0.2435]}]}]}, {"page": 28, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": []}, {"page": 29, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "CHAPTER 1 The Machine Learning Landscape", "words": [{"w": "CHAPTER", "b": [0.7398, 0.1146, 0.8383, 0.1451]}, {"w": "1", "b": [0.8435, 0.1146, 0.8571, 0.1451]}, {"w": "The", "b": [0.314, 0.1478, 0.3743, 0.1935]}, {"w": "Machine", "b": [0.3822, 0.1478, 0.5221, 0.1935]}, {"w": "Learning", "b": [0.53, 0.1478, 0.6763, 0.1935]}, {"w": "Landscape", "b": [0.6843, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_1", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 1 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.3643, 0.3102, 0.3839]}, {"w": "Early", "b": [0.3165, 0.3643, 0.3563, 0.3839]}, {"w": "Release", "b": [0.3626, 0.3643, 0.4189, 0.3839]}, {"w": "ebooks,", "b": [0.4251, 0.3643, 0.4831, 0.3839]}, {"w": "you", "b": [0.4894, 0.3643, 0.518, 0.3839]}, {"w": "get", "b": [0.5243, 0.3643, 0.5471, 0.3839]}, {"w": "books", "b": [0.5534, 0.3643, 0.5989, 0.3839]}, {"w": "in", "b": [0.6052, 0.3643, 0.6207, 0.3839]}, {"w": "their", "b": [0.627, 0.3643, 0.6632, 0.3839]}, {"w": "earliest", "b": [0.6695, 0.3643, 0.7239, 0.3839]}, {"w": "form—", "b": [0.7301, 0.3643, 0.7857, 0.3839]}, {"w": "the", "b": [0.2714, 0.3818, 0.2955, 0.4013]}, {"w": "author’s", "b": [0.3012, 0.3818, 0.3615, 0.4013]}, {"w": "raw", "b": [0.3672, 0.3818, 0.3954, 0.4013]}, {"w": "and", "b": [0.4011, 0.3818, 0.4299, 0.4013]}, {"w": "unedited", "b": [0.4357, 0.3818, 0.5034, 0.4013]}, {"w": "content", "b": [0.5091, 0.3818, 0.5667, 0.4013]}, {"w": "as", "b": [0.5725, 0.3818, 0.5878, 0.4013]}, {"w": "he", "b": [0.5936, 0.3818, 0.6118, 0.4013]}, {"w": "or", "b": [0.6175, 0.3818, 0.6343, 0.4013]}, {"w": "she", "b": [0.6401, 0.3818, 0.6653, 0.4013]}, {"w": "writes—so", "b": [0.671, 0.3818, 0.7514, 0.4013]}, {"w": "you", "b": [0.7571, 0.3818, 0.7857, 0.4013]}, {"w": "can", "b": [0.2714, 0.3992, 0.2982, 0.4188]}, {"w": "take", "b": [0.306, 0.3992, 0.3377, 0.4188]}, {"w": "advantage", "b": [0.3455, 0.3992, 0.4223, 0.4188]}, {"w": "of", "b": [0.4301, 0.3992, 0.4454, 0.4188]}, {"w": "these", "b": [0.4532, 0.3992, 0.4923, 0.4188]}, {"w": "technologies", "b": [0.5001, 0.3992, 0.596, 0.4188]}, {"w": "long", "b": [0.6038, 0.3992, 0.6376, 0.4188]}, {"w": "before", "b": [0.6454, 0.3992, 0.6937, 0.4188]}, {"w": "the", "b": [0.7014, 0.3992, 0.7255, 0.4188]}, {"w": "official", "b": [0.7333, 0.3992, 0.7857, 0.4188]}, {"w": "release", "b": [0.2714, 0.4166, 0.3229, 0.4362]}, {"w": "of", "b": [0.3292, 0.4166, 0.3445, 0.4362]}, {"w": "these", "b": [0.3507, 0.4166, 0.3899, 0.4362]}, {"w": "titles.", "b": [0.3961, 0.4166, 0.4371, 0.4362]}, {"w": "The", "b": [0.4433, 0.4166, 0.4733, 0.4362]}, {"w": "following", "b": [0.4795, 0.4166, 0.5517, 0.4362]}, {"w": "will", "b": [0.558, 0.4166, 0.5857, 0.4362]}, {"w": "be", "b": [0.592, 0.4166, 0.6097, 0.4362]}, {"w": "Chapter", "b": [0.616, 0.4166, 0.6777, 0.4362]}, {"w": "1", "b": [0.684, 0.4166, 0.6931, 0.4362]}, {"w": "in", "b": [0.6993, 0.4166, 0.7149, 0.4362]}, {"w": "the", "b": [0.7211, 0.4166, 0.7452, 0.4362]}, {"w": "final", "b": [0.7514, 0.4166, 0.7857, 0.4362]}, {"w": "release", "b": [0.2714, 0.434, 0.3229, 0.4536]}, {"w": "of", "b": [0.3273, 0.434, 0.3426, 0.4536]}, {"w": "the", "b": [0.3469, 0.434, 0.371, 0.4536]}, {"w": "book.", "b": [0.3753, 0.434, 0.4182, 0.4536]}]}, {"id": "b_2", "type": "paragraph", "text": "When most people hear “Machine Learning,” they picture a robot: a dependable but‐ ler or a deadly Terminator depending on who you ask. But Machine Learning is not just a futuristic fantasy, it’s already here. In fact, it has been around for decades in some specialized applications, such as Optical Character Recognition (OCR). But the first ML application that really became mainstream, improving the lives of hundreds of millions of people, took over the world back in the 1990s: it was the spam filter. Not exactly a self-aware Skynet, but it does technically qualify as Machine Learning (it has actually learned so well that you seldom need to flag an email as spam any‐ more). It was followed by hundreds of ML applications that now quietly power hun‐ dreds of products and features that you use regularly, from better recommendations to voice search.", "words": [{"w": "When", "b": [0.1429, 0.4739, 0.1945, 0.4953]}, {"w": "most", "b": [0.2, 0.4739, 0.2417, 0.4953]}, {"w": "people", "b": [0.2473, 0.4739, 0.3028, 0.4953]}, {"w": "hear", "b": [0.3083, 0.4739, 0.3452, 0.4953]}, {"w": "“Machine", "b": [0.3508, 0.4739, 0.4317, 0.4953]}, {"w": "Learning,”", "b": [0.4373, 0.4739, 0.5226, 0.4953]}, {"w": "they", "b": [0.5282, 0.4739, 0.564, 0.4953]}, {"w": "picture", "b": [0.5696, 0.4739, 0.6289, 0.4953]}, {"w": "a", "b": [0.6345, 0.4739, 0.6437, 0.4953]}, {"w": "robot:", "b": [0.6493, 0.4739, 0.6999, 0.4953]}, {"w": "a", "b": [0.7055, 0.4739, 0.7147, 0.4953]}, {"w": "dependable", "b": [0.7203, 0.4739, 0.8161, 0.4953]}, {"w": "but‐", "b": [0.8217, 0.4739, 0.8571, 0.4953]}, {"w": "ler", "b": [0.1428, 0.4929, 0.1647, 0.5143]}, {"w": "or", "b": [0.1708, 0.4929, 0.1892, 0.5143]}, {"w": "a", "b": [0.1953, 0.4929, 0.2045, 0.5143]}, {"w": "deadly", "b": [0.2106, 0.4929, 0.2654, 0.5143]}, {"w": "Terminator", "b": [0.2716, 0.4929, 0.3665, 0.5143]}, {"w": "depending", "b": [0.3726, 0.4929, 0.4613, 0.5143]}, {"w": "on", "b": [0.4675, 0.4929, 0.4895, 0.5143]}, {"w": "who", "b": [0.4956, 0.4929, 0.5316, 0.5143]}, {"w": "you", "b": [0.5378, 0.4929, 0.569, 0.5143]}, {"w": "ask.", "b": [0.5751, 0.4929, 0.607, 0.5143]}, {"w": "But", "b": [0.6132, 0.4929, 0.6428, 0.5143]}, {"w": "Machine", "b": [0.649, 0.4929, 0.7221, 0.5143]}, {"w": "Learning", "b": [0.7282, 0.4929, 0.8033, 0.5143]}, {"w": "is", "b": [0.8094, 0.4929, 0.8226, 0.5143]}, {"w": "not", "b": [0.8288, 0.4929, 0.8571, 0.5143]}, {"w": "just", "b": [0.1429, 0.512, 0.1733, 0.5334]}, {"w": "a", "b": [0.1807, 0.512, 0.1898, 0.5334]}, {"w": "futuristic", "b": [0.1973, 0.512, 0.2736, 0.5334]}, {"w": "fantasy,", "b": [0.281, 0.512, 0.3433, 0.5334]}, {"w": "it’s", "b": [0.3507, 0.512, 0.3724, 0.5334]}, {"w": "already", "b": [0.3798, 0.512, 0.4405, 0.5334]}, {"w": "here.", "b": [0.448, 0.512, 0.4893, 0.5334]}, {"w": "In", "b": [0.4967, 0.512, 0.5152, 0.5334]}, {"w": "fact,", "b": [0.5226, 0.512, 0.5579, 0.5334]}, {"w": "it", "b": [0.5653, 0.512, 0.5772, 0.5334]}, {"w": "has", "b": [0.5846, 0.512, 0.6126, 0.5334]}, {"w": "been", "b": [0.62, 0.512, 0.6597, 0.5334]}, {"w": "around", "b": [0.6671, 0.512, 0.7281, 0.5334]}, {"w": "for", "b": [0.7355, 0.512, 0.76, 0.5334]}, {"w": "decades", "b": [0.7674, 0.512, 0.8327, 0.5334]}, {"w": "in", "b": [0.8402, 0.512, 0.8571, 0.5334]}, {"w": "some", "b": [0.1429, 0.531, 0.187, 0.5524]}, {"w": "specialized", "b": [0.1935, 0.531, 0.2839, 0.5524]}, {"w": "applications,", "b": [0.2904, 0.531, 0.3957, 0.5524]}, {"w": "such", "b": [0.4022, 0.531, 0.4408, 0.5524]}, {"w": "as", "b": [0.4473, 0.531, 0.4641, 0.5524]}, {"w": "Optical", "b": [0.4705, 0.5308, 0.5301, 0.5524]}, {"w": "Character", "b": [0.5366, 0.5308, 0.6177, 0.5524]}, {"w": "Recognition", "b": [0.6242, 0.5308, 0.7199, 0.5524]}, {"w": "(OCR).", "b": [0.7263, 0.531, 0.7882, 0.5524]}, {"w": "But", "b": [0.7947, 0.531, 0.8244, 0.5524]}, {"w": "the", "b": [0.8308, 0.531, 0.8571, 0.5524]}, {"w": "first", "b": [0.1429, 0.5501, 0.1763, 0.5715]}, {"w": "ML", "b": [0.1822, 0.5501, 0.2119, 0.5715]}, {"w": "application", "b": [0.2178, 0.5501, 0.3107, 0.5715]}, {"w": "that", "b": [0.3166, 0.5501, 0.3491, 0.5715]}, {"w": "really", "b": [0.355, 0.5501, 0.4008, 0.5715]}, {"w": "became", "b": [0.4067, 0.5501, 0.47, 0.5715]}, {"w": "mainstream,", "b": [0.4758, 0.5501, 0.5805, 0.5715]}, {"w": "improving", "b": [0.5864, 0.5501, 0.6743, 0.5715]}, {"w": "the", "b": [0.6801, 0.5501, 0.7064, 0.5715]}, {"w": "lives", "b": [0.7123, 0.5501, 0.7493, 0.5715]}, {"w": "of", "b": [0.7551, 0.5501, 0.7719, 0.5715]}, {"w": "hundreds", "b": [0.7777, 0.5501, 0.8571, 0.5715]}, {"w": "of", "b": [0.1429, 0.5691, 0.1597, 0.5905]}, {"w": "millions", "b": [0.1666, 0.5691, 0.2351, 0.5905]}, {"w": "of", "b": [0.242, 0.5691, 0.2588, 0.5905]}, {"w": "people,", "b": [0.2658, 0.5691, 0.326, 0.5905]}, {"w": "took", "b": [0.333, 0.5691, 0.3709, 0.5905]}, {"w": "over", "b": [0.3779, 0.5691, 0.4147, 0.5905]}, {"w": "the", "b": [0.4217, 0.5691, 0.4481, 0.5905]}, {"w": "world", "b": [0.455, 0.5691, 0.5039, 0.5905]}, {"w": "back", "b": [0.5109, 0.5691, 0.5498, 0.5905]}, {"w": "in", "b": [0.5567, 0.5691, 0.5737, 0.5905]}, {"w": "the", "b": [0.5807, 0.5691, 0.607, 0.5905]}, {"w": "1990s:", "b": [0.614, 0.5691, 0.6664, 0.5905]}, {"w": "it", "b": [0.6734, 0.5691, 0.6853, 0.5905]}, {"w": "was", "b": [0.6923, 0.5691, 0.7234, 0.5905]}, {"w": "the", "b": [0.7303, 0.5691, 0.7567, 0.5905]}, {"w": "spam", "b": [0.7636, 0.5689, 0.8068, 0.5905]}, {"w": "filter.", "b": [0.8138, 0.5689, 0.8572, 0.5905]}, {"w": "Not", "b": [0.1429, 0.5882, 0.1748, 0.6096]}, {"w": "exactly", "b": [0.1814, 0.5882, 0.2392, 0.6096]}, {"w": "a", "b": [0.2458, 0.5882, 0.255, 0.6096]}, {"w": "self-aware", "b": [0.2616, 0.5882, 0.3457, 0.6096]}, {"w": "Skynet,", "b": [0.3523, 0.5882, 0.4134, 0.6096]}, {"w": "but", "b": [0.42, 0.5882, 0.448, 0.6096]}, {"w": "it", "b": [0.4546, 0.5882, 0.4665, 0.6096]}, {"w": "does", "b": [0.4731, 0.5882, 0.5112, 0.6096]}, {"w": "technically", "b": [0.5178, 0.5882, 0.608, 0.6096]}, {"w": "qualify", "b": [0.6146, 0.5882, 0.6724, 0.6096]}, {"w": "as", "b": [0.679, 0.5882, 0.6958, 0.6096]}, {"w": "Machine", "b": [0.7024, 0.5882, 0.7755, 0.6096]}, {"w": "Learning", "b": [0.7821, 0.5882, 0.8571, 0.6096]}, {"w": "(it", "b": [0.1429, 0.6072, 0.162, 0.6286]}, {"w": "has", "b": [0.169, 0.6072, 0.1969, 0.6286]}, {"w": "actually", "b": [0.2039, 0.6072, 0.2685, 0.6286]}, {"w": "learned", "b": [0.2755, 0.6072, 0.3377, 0.6286]}, {"w": "so", "b": [0.3447, 0.6072, 0.363, 0.6286]}, {"w": "well", "b": [0.3699, 0.6072, 0.4036, 0.6286]}, {"w": "that", "b": [0.4106, 0.6072, 0.4432, 0.6286]}, {"w": "you", "b": [0.4502, 0.6072, 0.4814, 0.6286]}, {"w": "seldom", "b": [0.4884, 0.6072, 0.5488, 0.6286]}, {"w": "need", "b": [0.5558, 0.6072, 0.5959, 0.6286]}, {"w": "to", "b": [0.6029, 0.6072, 0.6199, 0.6286]}, {"w": "flag", "b": [0.6269, 0.6072, 0.6572, 0.6286]}, {"w": "an", "b": [0.6642, 0.6072, 0.6847, 0.6286]}, {"w": "email", "b": [0.6917, 0.6072, 0.7376, 0.6286]}, {"w": "as", "b": [0.7446, 0.6072, 0.7614, 0.6286]}, {"w": "spam", "b": [0.7683, 0.6072, 0.8131, 0.6286]}, {"w": "any‐", "b": [0.8201, 0.6072, 0.8571, 0.6286]}, {"w": "more).", "b": [0.1428, 0.6263, 0.1991, 0.6477]}, {"w": "It", "b": [0.2049, 0.6263, 0.2176, 0.6477]}, {"w": "was", "b": [0.2235, 0.6263, 0.2545, 0.6477]}, {"w": "followed", "b": [0.2604, 0.6263, 0.3325, 0.6477]}, {"w": "by", "b": [0.3384, 0.6263, 0.3585, 0.6477]}, {"w": "hundreds", "b": [0.3644, 0.6263, 0.4438, 0.6477]}, {"w": "of", "b": [0.4497, 0.6263, 0.4665, 0.6477]}, {"w": "ML", "b": [0.4723, 0.6263, 0.5021, 0.6477]}, {"w": "applications", "b": [0.508, 0.6263, 0.6086, 0.6477]}, {"w": "that", "b": [0.6144, 0.6263, 0.647, 0.6477]}, {"w": "now", "b": [0.6529, 0.6263, 0.6892, 0.6477]}, {"w": "quietly", "b": [0.6951, 0.6263, 0.7524, 0.6477]}, {"w": "power", "b": [0.7583, 0.6263, 0.8107, 0.6477]}, {"w": "hun‐", "b": [0.8165, 0.6263, 0.8571, 0.6477]}, {"w": "dreds", "b": [0.1429, 0.6453, 0.1891, 0.6667]}, {"w": "of", "b": [0.1954, 0.6453, 0.2122, 0.6667]}, {"w": "products", "b": [0.2184, 0.6453, 0.2926, 0.6667]}, {"w": "and", "b": [0.2989, 0.6453, 0.3304, 0.6667]}, {"w": "features", "b": [0.3367, 0.6453, 0.4021, 0.6667]}, {"w": "that", "b": [0.4084, 0.6453, 0.441, 0.6667]}, {"w": "you", "b": [0.4473, 0.6453, 0.4785, 0.6667]}, {"w": "use", "b": [0.4848, 0.6453, 0.5124, 0.6667]}, {"w": "regularly,", "b": [0.5186, 0.6453, 0.5962, 0.6667]}, {"w": "from", "b": [0.6025, 0.6453, 0.6441, 0.6667]}, {"w": "better", "b": [0.6504, 0.6453, 0.6991, 0.6667]}, {"w": "recommendations", "b": [0.7054, 0.6453, 0.8571, 0.6667]}, {"w": "to", "b": [0.1429, 0.6644, 0.1598, 0.6858]}, {"w": "voice", "b": [0.1646, 0.6644, 0.2081, 0.6858]}, {"w": "search.", "b": [0.2128, 0.6644, 0.2709, 0.6858]}]}, {"id": "b_3", "type": "paragraph", "text": "Where does Machine Learning start and where does it end? What exactly does it mean for a machine to learn something? If I download a copy of Wikipedia, has my computer really “learned” something? Is it suddenly smarter? In this chapter we will start by clarifying what Machine Learning is and why you may want to use it.", "words": [{"w": "Where", "b": [0.1429, 0.6925, 0.1996, 0.7139]}, {"w": "does", "b": [0.208, 0.6925, 0.2461, 0.7139]}, {"w": "Machine", "b": [0.2544, 0.6925, 0.3275, 0.7139]}, {"w": "Learning", "b": [0.3358, 0.6925, 0.4109, 0.7139]}, {"w": "start", "b": [0.4192, 0.6925, 0.4564, 0.7139]}, {"w": "and", "b": [0.4647, 0.6925, 0.4963, 0.7139]}, {"w": "where", "b": [0.5046, 0.6925, 0.5554, 0.7139]}, {"w": "does", "b": [0.5637, 0.6925, 0.6019, 0.7139]}, {"w": "it", "b": [0.6102, 0.6925, 0.6221, 0.7139]}, {"w": "end?", "b": [0.6304, 0.6925, 0.6696, 0.7139]}, {"w": "What", "b": [0.6779, 0.6925, 0.7243, 0.7139]}, {"w": "exactly", "b": [0.7326, 0.6925, 0.7905, 0.7139]}, {"w": "does", "b": [0.7988, 0.6925, 0.8369, 0.7139]}, {"w": "it", "b": [0.8452, 0.6925, 0.8571, 0.7139]}, {"w": "mean", "b": [0.1429, 0.7115, 0.1893, 0.7329]}, {"w": "for", "b": [0.1954, 0.7115, 0.22, 0.7329]}, {"w": "a", "b": [0.2261, 0.7115, 0.2353, 0.7329]}, {"w": "machine", "b": [0.2414, 0.7115, 0.3134, 0.7329]}, {"w": "to", "b": [0.3195, 0.7115, 0.3365, 0.7329]}, {"w": "learn", "b": [0.3426, 0.7113, 0.3847, 0.7329]}, {"w": "something?", "b": [0.3908, 0.7115, 0.4871, 0.7329]}, {"w": "If", "b": [0.4933, 0.7115, 0.5065, 0.7329]}, {"w": "I", "b": [0.5127, 0.7115, 0.5198, 0.7329]}, {"w": "download", "b": [0.5259, 0.7115, 0.6093, 0.7329]}, {"w": "a", "b": [0.6154, 0.7115, 0.6245, 0.7329]}, {"w": "copy", "b": [0.6307, 0.7115, 0.6706, 0.7329]}, {"w": "of", "b": [0.6767, 0.7115, 0.6935, 0.7329]}, {"w": "Wikipedia,", "b": [0.6997, 0.7115, 0.7908, 0.7329]}, {"w": "has", "b": [0.7969, 0.7115, 0.8249, 0.7329]}, {"w": "my", "b": [0.831, 0.7115, 0.8571, 0.7329]}, {"w": "computer", "b": [0.1429, 0.7306, 0.2239, 0.752]}, {"w": "really", "b": [0.23, 0.7306, 0.2758, 0.752]}, {"w": "“learned”", "b": [0.2819, 0.7306, 0.3603, 0.752]}, {"w": "something?", "b": [0.3663, 0.7306, 0.4626, 0.752]}, {"w": "Is", "b": [0.4687, 0.7306, 0.483, 0.752]}, {"w": "it", "b": [0.4891, 0.7306, 0.501, 0.752]}, {"w": "suddenly", "b": [0.5071, 0.7306, 0.5829, 0.752]}, {"w": "smarter?", "b": [0.589, 0.7306, 0.6614, 0.752]}, {"w": "In", "b": [0.6675, 0.7306, 0.686, 0.752]}, {"w": "this", "b": [0.6921, 0.7306, 0.7228, 0.752]}, {"w": "chapter", "b": [0.7289, 0.7306, 0.7914, 0.752]}, {"w": "we", "b": [0.7975, 0.7306, 0.8207, 0.752]}, {"w": "will", "b": [0.8268, 0.7306, 0.8571, 0.752]}, {"w": "start", "b": [0.1429, 0.7496, 0.1801, 0.771]}, {"w": "by", "b": [0.1848, 0.7496, 0.205, 0.771]}, {"w": "clarifying", "b": [0.2097, 0.7496, 0.289, 0.771]}, {"w": "what", "b": [0.2938, 0.7496, 0.3343, 0.771]}, {"w": "Machine", "b": [0.339, 0.7496, 0.4121, 0.771]}, {"w": "Learning", "b": [0.4169, 0.7496, 0.4919, 0.771]}, {"w": "is", "b": [0.4966, 0.7496, 0.5099, 0.771]}, {"w": "and", "b": [0.5146, 0.7496, 0.5461, 0.771]}, {"w": "why", "b": [0.5509, 0.7496, 0.5854, 0.771]}, {"w": "you", "b": [0.5901, 0.7496, 0.6213, 0.771]}, {"w": "may", "b": [0.6261, 0.7496, 0.6615, 0.771]}, {"w": "want", "b": [0.6662, 0.7496, 0.707, 0.771]}, {"w": "to", "b": [0.7117, 0.7496, 0.7287, 0.771]}, {"w": "use", "b": [0.7334, 0.7496, 0.761, 0.771]}, {"w": "it.", "b": [0.7657, 0.7496, 0.7824, 0.771]}]}, {"id": "b_4", "type": "paragraph", "text": "Then, before we set out to explore the Machine Learning continent, we will take a look at the map and learn about the main regions and the most notable landmarks: supervised versus unsupervised learning, online versus batch learning, instance- based versus model-based learning. Then we will look at the workflow of a typical ML project, discuss the main challenges you may face, and cover how to evaluate and fine-tune a Machine Learning system.", "words": [{"w": "Then,", "b": [0.1429, 0.7777, 0.1918, 0.7991]}, {"w": "before", "b": [0.1992, 0.7777, 0.252, 0.7991]}, {"w": "we", "b": [0.2593, 0.7777, 0.2825, 0.7991]}, {"w": "set", "b": [0.2898, 0.7777, 0.3127, 0.7991]}, {"w": "out", "b": [0.32, 0.7777, 0.348, 0.7991]}, {"w": "to", "b": [0.3554, 0.7777, 0.3724, 0.7991]}, {"w": "explore", "b": [0.3797, 0.7777, 0.4418, 0.7991]}, {"w": "the", "b": [0.4491, 0.7777, 0.4755, 0.7991]}, {"w": "Machine", "b": [0.4828, 0.7777, 0.5559, 0.7991]}, {"w": "Learning", "b": [0.5633, 0.7777, 0.6383, 0.7991]}, {"w": "continent,", "b": [0.6457, 0.7777, 0.7304, 0.7991]}, {"w": "we", "b": [0.7378, 0.7777, 0.7609, 0.7991]}, {"w": "will", "b": [0.7682, 0.7777, 0.7986, 0.7991]}, {"w": "take", "b": [0.806, 0.7777, 0.8407, 0.7991]}, {"w": "a", "b": [0.848, 0.7777, 0.8571, 0.7991]}, {"w": "look", "b": [0.1429, 0.7968, 0.1797, 0.8182]}, {"w": "at", "b": [0.1862, 0.7968, 0.2013, 0.8182]}, {"w": "the", "b": [0.2078, 0.7968, 0.2342, 0.8182]}, {"w": "map", "b": [0.2407, 0.7968, 0.2774, 0.8182]}, {"w": "and", "b": [0.2839, 0.7968, 0.3155, 0.8182]}, {"w": "learn", "b": [0.322, 0.7968, 0.3644, 0.8182]}, {"w": "about", "b": [0.3709, 0.7968, 0.4187, 0.8182]}, {"w": "the", "b": [0.4252, 0.7968, 0.4515, 0.8182]}, {"w": "main", "b": [0.458, 0.7968, 0.5012, 0.8182]}, {"w": "regions", "b": [0.5077, 0.7968, 0.5693, 0.8182]}, {"w": "and", "b": [0.5758, 0.7968, 0.6074, 0.8182]}, {"w": "the", "b": [0.6139, 0.7968, 0.6402, 0.8182]}, {"w": "most", "b": [0.6467, 0.7968, 0.6884, 0.8182]}, {"w": "notable", "b": [0.6949, 0.7968, 0.7571, 0.8182]}, {"w": "landmarks:", "b": [0.7637, 0.7968, 0.8571, 0.8182]}, {"w": "supervised", "b": [0.1428, 0.8158, 0.2324, 0.8372]}, {"w": "versus", "b": [0.2429, 0.8158, 0.2955, 0.8372]}, {"w": "unsupervised", "b": [0.3061, 0.8158, 0.4181, 0.8372]}, {"w": "learning,", "b": [0.4286, 0.8158, 0.5025, 0.8372]}, {"w": "online", "b": [0.5131, 0.8158, 0.5662, 0.8372]}, {"w": "versus", "b": [0.5768, 0.8158, 0.6294, 0.8372]}, {"w": "batch", "b": [0.6399, 0.8158, 0.6855, 0.8372]}, {"w": "learning,", "b": [0.6961, 0.8158, 0.77, 0.8372]}, {"w": "instance-", "b": [0.7805, 0.8158, 0.8571, 0.8372]}, {"w": "based", "b": [0.1429, 0.8349, 0.1901, 0.8563]}, {"w": "versus", "b": [0.1948, 0.8349, 0.2474, 0.8563]}, {"w": "model-based", "b": [0.2521, 0.8349, 0.3596, 0.8563]}, {"w": "learning.", "b": [0.3643, 0.8349, 0.4382, 0.8563]}, {"w": "Then", "b": [0.4429, 0.8349, 0.4872, 0.8563]}, {"w": "we", "b": [0.4919, 0.8349, 0.515, 0.8563]}, {"w": "will", "b": [0.5197, 0.8349, 0.5501, 0.8563]}, {"w": "look", "b": [0.5549, 0.8349, 0.5917, 0.8563]}, {"w": "at", "b": [0.5964, 0.8349, 0.6115, 0.8563]}, {"w": "the", "b": [0.6163, 0.8349, 0.6426, 0.8563]}, {"w": "workflow", "b": [0.6473, 0.8349, 0.7266, 0.8563]}, {"w": "of", "b": [0.7314, 0.8349, 0.7482, 0.8563]}, {"w": "a", "b": [0.7529, 0.8349, 0.762, 0.8563]}, {"w": "typical", "b": [0.7668, 0.8349, 0.8224, 0.8563]}, {"w": "ML", "b": [0.8271, 0.8349, 0.8569, 0.8563]}, {"w": "project,", "b": [0.1429, 0.8539, 0.2062, 0.8753]}, {"w": "discuss", "b": [0.2141, 0.8539, 0.2735, 0.8753]}, {"w": "the", "b": [0.2813, 0.8539, 0.3076, 0.8753]}, {"w": "main", "b": [0.3155, 0.8539, 0.3586, 0.8753]}, {"w": "challenges", "b": [0.3665, 0.8539, 0.4526, 0.8753]}, {"w": "you", "b": [0.4604, 0.8539, 0.4917, 0.8753]}, {"w": "may", "b": [0.4995, 0.8539, 0.5349, 0.8753]}, {"w": "face,", "b": [0.5427, 0.8539, 0.5805, 0.8753]}, {"w": "and", "b": [0.5883, 0.8539, 0.6198, 0.8753]}, {"w": "cover", "b": [0.6277, 0.8539, 0.6733, 0.8753]}, {"w": "how", "b": [0.6812, 0.8539, 0.7172, 0.8753]}, {"w": "to", "b": [0.725, 0.8539, 0.742, 0.8753]}, {"w": "evaluate", "b": [0.7498, 0.8539, 0.8178, 0.8753]}, {"w": "and", "b": [0.8256, 0.8539, 0.8571, 0.8753]}, {"w": "fine-tune", "b": [0.1429, 0.873, 0.2199, 0.8944]}, {"w": "a", "b": [0.2247, 0.873, 0.2338, 0.8944]}, {"w": "Machine", "b": [0.2385, 0.873, 0.3117, 0.8944]}, {"w": "Learning", "b": [0.3164, 0.873, 0.3915, 0.8944]}, {"w": "system.", "b": [0.3962, 0.873, 0.4581, 0.8944]}]}]}, {"page": 30, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "This chapter introduces a lot of fundamental concepts (and jargon) that every data scientist should know by heart. It will be a high-level overview (the only chapter without much code), all rather simple, but you should make sure everything is crystal-clear to you before continuing to the rest of the book. So grab a coffee and let’s get started!", "words": [{"w": "This", "b": [0.1429, 0.0791, 0.1801, 0.1005]}, {"w": "chapter", "b": [0.1871, 0.0791, 0.2497, 0.1005]}, {"w": "introduces", "b": [0.2567, 0.0791, 0.3454, 0.1005]}, {"w": "a", "b": [0.3525, 0.0791, 0.3616, 0.1005]}, {"w": "lot", "b": [0.3687, 0.0791, 0.3909, 0.1005]}, {"w": "of", "b": [0.398, 0.0791, 0.4148, 0.1005]}, {"w": "fundamental", "b": [0.4219, 0.0791, 0.5283, 0.1005]}, {"w": "concepts", "b": [0.5354, 0.0791, 0.6088, 0.1005]}, {"w": "(and", "b": [0.6159, 0.0791, 0.6546, 0.1005]}, {"w": "jargon)", "b": [0.6617, 0.0791, 0.7229, 0.1005]}, {"w": "that", "b": [0.7299, 0.0791, 0.7625, 0.1005]}, {"w": "every", "b": [0.7696, 0.0791, 0.8148, 0.1005]}, {"w": "data", "b": [0.8219, 0.0791, 0.8571, 0.1005]}, {"w": "scientist", "b": [0.1429, 0.0981, 0.2107, 0.1195]}, {"w": "should", "b": [0.2193, 0.0981, 0.276, 0.1195]}, {"w": "know", "b": [0.2846, 0.0981, 0.3312, 0.1195]}, {"w": "by", "b": [0.3398, 0.0981, 0.36, 0.1195]}, {"w": "heart.", "b": [0.3686, 0.0981, 0.4165, 0.1195]}, {"w": "It", "b": [0.4251, 0.0981, 0.4378, 0.1195]}, {"w": "will", "b": [0.4464, 0.0981, 0.4767, 0.1195]}, {"w": "be", "b": [0.4853, 0.0981, 0.5048, 0.1195]}, {"w": "a", "b": [0.5134, 0.0981, 0.5225, 0.1195]}, {"w": "high-level", "b": [0.5311, 0.0981, 0.614, 0.1195]}, {"w": "overview", "b": [0.6226, 0.0981, 0.6984, 0.1195]}, {"w": "(the", "b": [0.707, 0.0981, 0.7406, 0.1195]}, {"w": "only", "b": [0.7491, 0.0981, 0.786, 0.1195]}, {"w": "chapter", "b": [0.7946, 0.0981, 0.8571, 0.1195]}, {"w": "without", "b": [0.1429, 0.1172, 0.2082, 0.1386]}, {"w": "much", "b": [0.2183, 0.1172, 0.266, 0.1386]}, {"w": "code),", "b": [0.276, 0.1172, 0.3273, 0.1386]}, {"w": "all", "b": [0.3373, 0.1172, 0.357, 0.1386]}, {"w": "rather", "b": [0.3671, 0.1172, 0.4176, 0.1386]}, {"w": "simple,", "b": [0.4277, 0.1172, 0.4874, 0.1386]}, {"w": "but", "b": [0.4974, 0.1172, 0.5254, 0.1386]}, {"w": "you", "b": [0.5355, 0.1172, 0.5667, 0.1386]}, {"w": "should", "b": [0.5768, 0.1172, 0.6335, 0.1386]}, {"w": "make", "b": [0.6436, 0.1172, 0.689, 0.1386]}, {"w": "sure", "b": [0.6991, 0.1172, 0.7343, 0.1386]}, {"w": "everything", "b": [0.7444, 0.1172, 0.8339, 0.1386]}, {"w": "is", "b": [0.8439, 0.1172, 0.8572, 0.1386]}, {"w": "crystal-clear", "b": [0.1429, 0.1362, 0.2452, 0.1576]}, {"w": "to", "b": [0.2501, 0.1362, 0.267, 0.1576]}, {"w": "you", "b": [0.2719, 0.1362, 0.3032, 0.1576]}, {"w": "before", "b": [0.308, 0.1362, 0.3608, 0.1576]}, {"w": "continuing", "b": [0.3657, 0.1362, 0.4568, 0.1576]}, {"w": "to", "b": [0.4617, 0.1362, 0.4787, 0.1576]}, {"w": "the", "b": [0.4835, 0.1362, 0.5099, 0.1576]}, {"w": "rest", "b": [0.5147, 0.1362, 0.5453, 0.1576]}, {"w": "of", "b": [0.5502, 0.1362, 0.567, 0.1576]}, {"w": "the", "b": [0.5718, 0.1362, 0.5981, 0.1576]}, {"w": "book.", "b": [0.603, 0.1362, 0.6499, 0.1576]}, {"w": "So", "b": [0.6548, 0.1362, 0.6753, 0.1576]}, {"w": "grab", "b": [0.6801, 0.1362, 0.7173, 0.1576]}, {"w": "a", "b": [0.7222, 0.1362, 0.7313, 0.1576]}, {"w": "coffee", "b": [0.7362, 0.1362, 0.7857, 0.1576]}, {"w": "and", "b": [0.7905, 0.1362, 0.8221, 0.1576]}, {"w": "let’s", "b": [0.8269, 0.1362, 0.8571, 0.1576]}, {"w": "get", "b": [0.1429, 0.1553, 0.1678, 0.1767]}, {"w": "started!", "b": [0.1725, 0.1553, 0.2354, 0.1767]}]}, {"id": "b_1", "type": "paragraph", "text": "If you already know all the Machine Learning basics, you may want to skip directly to Chapter 2. If you are not sure, try to answer all the questions listed at the end of the chapter before moving on.", "words": [{"w": "If", "b": [0.2714, 0.1972, 0.2835, 0.2168]}, {"w": "you", "b": [0.2881, 0.1972, 0.3167, 0.2168]}, {"w": "already", "b": [0.3212, 0.1972, 0.3767, 0.2168]}, {"w": "know", "b": [0.3813, 0.1972, 0.4239, 0.2168]}, {"w": "all", "b": [0.4285, 0.1972, 0.4465, 0.2168]}, {"w": "the", "b": [0.4511, 0.1972, 0.4751, 0.2168]}, {"w": "Machine", "b": [0.4797, 0.1972, 0.5466, 0.2168]}, {"w": "Learning", "b": [0.5511, 0.1972, 0.6197, 0.2168]}, {"w": "basics,", "b": [0.6243, 0.1972, 0.6738, 0.2168]}, {"w": "you", "b": [0.6784, 0.1972, 0.707, 0.2168]}, {"w": "may", "b": [0.7115, 0.1972, 0.7439, 0.2168]}, {"w": "want", "b": [0.7484, 0.1972, 0.7857, 0.2168]}, {"w": "to", "b": [0.2714, 0.2146, 0.2869, 0.2342]}, {"w": "skip", "b": [0.2928, 0.2146, 0.3243, 0.2342]}, {"w": "directly", "b": [0.3302, 0.2146, 0.388, 0.2342]}, {"w": "to", "b": [0.3938, 0.2146, 0.4094, 0.2342]}, {"w": "Chapter", "b": [0.4152, 0.2146, 0.477, 0.2342]}, {"w": "2.", "b": [0.4829, 0.2146, 0.4964, 0.2342]}, {"w": "If", "b": [0.5023, 0.2146, 0.5144, 0.2342]}, {"w": "you", "b": [0.5203, 0.2146, 0.5488, 0.2342]}, {"w": "are", "b": [0.5547, 0.2146, 0.5782, 0.2342]}, {"w": "not", "b": [0.5841, 0.2146, 0.6101, 0.2342]}, {"w": "sure,", "b": [0.6159, 0.2146, 0.6525, 0.2342]}, {"w": "try", "b": [0.6584, 0.2146, 0.6806, 0.2342]}, {"w": "to", "b": [0.6865, 0.2146, 0.702, 0.2342]}, {"w": "answer", "b": [0.7079, 0.2146, 0.7618, 0.2342]}, {"w": "all", "b": [0.7677, 0.2146, 0.7857, 0.2342]}, {"w": "the", "b": [0.2714, 0.232, 0.2955, 0.2516]}, {"w": "questions", "b": [0.2998, 0.232, 0.3728, 0.2516]}, {"w": "listed", "b": [0.3771, 0.232, 0.418, 0.2516]}, {"w": "at", "b": [0.4223, 0.232, 0.4361, 0.2516]}, {"w": "the", "b": [0.4404, 0.232, 0.4645, 0.2516]}, {"w": "end", "b": [0.4688, 0.232, 0.4974, 0.2516]}, {"w": "of", "b": [0.5017, 0.232, 0.5171, 0.2516]}, {"w": "the", "b": [0.5214, 0.232, 0.5455, 0.2516]}, {"w": "chapter", "b": [0.5498, 0.232, 0.607, 0.2516]}, {"w": "before", "b": [0.6113, 0.232, 0.6596, 0.2516]}, {"w": "moving", "b": [0.6639, 0.232, 0.7225, 0.2516]}, {"w": "on.", "b": [0.7268, 0.232, 0.7513, 0.2516]}]}, {"id": "b_2", "type": "paragraph", "text": "What Is Machine Learning?", "words": [{"w": "What", "b": [0.1429, 0.292, 0.2098, 0.3263]}, {"w": "Is", "b": [0.2158, 0.292, 0.2358, 0.3263]}, {"w": "Machine", "b": [0.2417, 0.292, 0.3467, 0.3263]}, {"w": "Learning?", "b": [0.3526, 0.292, 0.4746, 0.3263]}]}, {"id": "b_3", "type": "paragraph", "text": "Machine Learning is the science (and art) of programming computers so they can learn from data.", "words": [{"w": "Machine", "b": [0.1428, 0.3332, 0.216, 0.3546]}, {"w": "Learning", "b": [0.2236, 0.3332, 0.2987, 0.3546]}, {"w": "is", "b": [0.3063, 0.3332, 0.3195, 0.3546]}, {"w": "the", "b": [0.3272, 0.3332, 0.3535, 0.3546]}, {"w": "science", "b": [0.3612, 0.3332, 0.4211, 0.3546]}, {"w": "(and", "b": [0.4287, 0.3332, 0.4675, 0.3546]}, {"w": "art)", "b": [0.4751, 0.3332, 0.5056, 0.3546]}, {"w": "of", "b": [0.5132, 0.3332, 0.53, 0.3546]}, {"w": "programming", "b": [0.5376, 0.3332, 0.6544, 0.3546]}, {"w": "computers", "b": [0.662, 0.3332, 0.7507, 0.3546]}, {"w": "so", "b": [0.7583, 0.3332, 0.7766, 0.3546]}, {"w": "they", "b": [0.7842, 0.3332, 0.8201, 0.3546]}, {"w": "can", "b": [0.8278, 0.3332, 0.8571, 0.3546]}, {"w": "learn", "b": [0.1429, 0.3521, 0.1849, 0.3737]}, {"w": "from", "b": [0.1897, 0.3521, 0.2287, 0.3737]}, {"w": "data.", "b": [0.2335, 0.3521, 0.2749, 0.3737]}]}, {"id": "b_4", "type": "paragraph", "text": "Here is a slightly more general definition:", "words": [{"w": "Here", "b": [0.1429, 0.3804, 0.1837, 0.4018]}, {"w": "is", "b": [0.1885, 0.3804, 0.2017, 0.4018]}, {"w": "a", "b": [0.2064, 0.3804, 0.2156, 0.4018]}, {"w": "slightly", "b": [0.2203, 0.3804, 0.2805, 0.4018]}, {"w": "more", "b": [0.2852, 0.3804, 0.3295, 0.4018]}, {"w": "general", "b": [0.3342, 0.3804, 0.3952, 0.4018]}, {"w": "definition:", "b": [0.3999, 0.3804, 0.4872, 0.4018]}]}, {"id": "b_5", "type": "paragraph", "text": "[Machine Learning is the] field of study that gives computers the ability to learn without being explicitly programmed.", "words": [{"w": "[Machine", "b": [0.1786, 0.4088, 0.2497, 0.4278]}, {"w": "Learning", "b": [0.2581, 0.4088, 0.3246, 0.4278]}, {"w": "is", "b": [0.3331, 0.4088, 0.3448, 0.4278]}, {"w": "the]", "b": [0.3532, 0.4088, 0.3829, 0.4278]}, {"w": "field", "b": [0.3913, 0.4088, 0.424, 0.4278]}, {"w": "of", "b": [0.4324, 0.4088, 0.4473, 0.4278]}, {"w": "study", "b": [0.4558, 0.4088, 0.4962, 0.4278]}, {"w": "that", "b": [0.5046, 0.4088, 0.5335, 0.4278]}, {"w": "gives", "b": [0.5419, 0.4088, 0.5786, 0.4278]}, {"w": "computers", "b": [0.5871, 0.4088, 0.6656, 0.4278]}, {"w": "the", "b": [0.6741, 0.4088, 0.6974, 0.4278]}, {"w": "ability", "b": [0.7058, 0.4088, 0.752, 0.4278]}, {"w": "to", "b": [0.7604, 0.4088, 0.7754, 0.4278]}, {"w": "learn", "b": [0.7839, 0.4088, 0.8214, 0.4278]}, {"w": "without", "b": [0.1786, 0.4257, 0.2365, 0.4446]}, {"w": "being", "b": [0.2407, 0.4257, 0.2816, 0.4446]}, {"w": "explicitly", "b": [0.2858, 0.4257, 0.3531, 0.4446]}, {"w": "programmed.", "b": [0.3573, 0.4257, 0.4588, 0.4446]}]}, {"id": "b_6", "type": "paragraph", "text": "—Arthur Samuel, 1959", "words": [{"w": "—Arthur", "b": [0.2063, 0.4486, 0.2746, 0.4675]}, {"w": "Samuel,", "b": [0.2788, 0.4486, 0.337, 0.4675]}, {"w": "1959", "b": [0.3411, 0.4484, 0.3764, 0.4675]}]}, {"id": "b_7", "type": "equation", "text": "And a more engineering-oriented one:", "words": [{"w": "And", "b": [0.1429, 0.4773, 0.1796, 0.4987]}, {"w": "a", "b": [0.1844, 0.4773, 0.1935, 0.4987]}, {"w": "more", "b": [0.1982, 0.4773, 0.2425, 0.4987]}, {"w": "engineering-oriented", "b": [0.2472, 0.4773, 0.4238, 0.4987]}, {"w": "one:", "b": [0.4285, 0.4773, 0.4642, 0.4987]}]}, {"id": "b_8", "type": "paragraph", "text": "A computer program is said to learn from experience E with respect to some task T and some performance measure P, if its performance on T, as measured by P, improves with experience E.", "words": [{"w": "A", "b": [0.1786, 0.5057, 0.1913, 0.5246]}, {"w": "computer", "b": [0.1975, 0.5057, 0.2692, 0.5246]}, {"w": "program", "b": [0.2754, 0.5057, 0.34, 0.5246]}, {"w": "is", "b": [0.3462, 0.5057, 0.3579, 0.5246]}, {"w": "said", "b": [0.3641, 0.5057, 0.3936, 0.5246]}, {"w": "to", "b": [0.3998, 0.5057, 0.4148, 0.5246]}, {"w": "learn", "b": [0.421, 0.5057, 0.4585, 0.5246]}, {"w": "from", "b": [0.4647, 0.5057, 0.5015, 0.5246]}, {"w": "experience", "b": [0.5077, 0.5057, 0.5871, 0.5246]}, {"w": "E", "b": [0.5933, 0.5057, 0.6038, 0.5246]}, {"w": "with", "b": [0.6099, 0.5057, 0.643, 0.5246]}, {"w": "respect", "b": [0.6492, 0.5057, 0.7016, 0.5246]}, {"w": "to", "b": [0.7077, 0.5057, 0.7228, 0.5246]}, {"w": "some", "b": [0.7289, 0.5057, 0.7681, 0.5246]}, {"w": "task", "b": [0.7742, 0.5057, 0.8039, 0.5246]}, {"w": "T", "b": [0.81, 0.5057, 0.8214, 0.5246]}, {"w": "and", "b": [0.1786, 0.5225, 0.2065, 0.5415]}, {"w": "some", "b": [0.2111, 0.5225, 0.2503, 0.5415]}, {"w": "performance", "b": [0.2549, 0.5225, 0.3499, 0.5415]}, {"w": "measure", "b": [0.3546, 0.5225, 0.4169, 0.5415]}, {"w": "P,", "b": [0.4215, 0.5225, 0.4335, 0.5415]}, {"w": "if", "b": [0.4381, 0.5225, 0.4486, 0.5415]}, {"w": "its", "b": [0.4532, 0.5225, 0.4705, 0.5415]}, {"w": "performance", "b": [0.4752, 0.5225, 0.5702, 0.5415]}, {"w": "on", "b": [0.5748, 0.5225, 0.5943, 0.5415]}, {"w": "T,", "b": [0.5989, 0.5225, 0.6127, 0.5415]}, {"w": "as", "b": [0.6173, 0.5225, 0.6322, 0.5415]}, {"w": "measured", "b": [0.6368, 0.5225, 0.7089, 0.5415]}, {"w": "by", "b": [0.7135, 0.5225, 0.7314, 0.5415]}, {"w": "P,", "b": [0.736, 0.5225, 0.748, 0.5415]}, {"w": "improves", "b": [0.7526, 0.5225, 0.8214, 0.5415]}, {"w": "with", "b": [0.1786, 0.5394, 0.2116, 0.5584]}, {"w": "experience", "b": [0.2158, 0.5394, 0.2953, 0.5584]}, {"w": "E.", "b": [0.2994, 0.5394, 0.3141, 0.5584]}]}, {"id": "b_9", "type": "paragraph", "text": "—Tom Mitchell, 1997", "words": [{"w": "—Tom", "b": [0.2062, 0.5623, 0.2574, 0.5813]}, {"w": "Mitchell,", "b": [0.2615, 0.5623, 0.3276, 0.5813]}, {"w": "1997", "b": [0.3318, 0.5621, 0.367, 0.5813]}]}, {"id": "b_10", "type": "paragraph", "text": "For example, your spam filter is a Machine Learning program that can learn to flag spam given examples of spam emails (e.g., flagged by users) and examples of regular (nonspam, also called “ham”) emails. The examples that the system uses to learn are called the training set. Each training example is called a training instance (or sample). In this case, the task T is to flag spam for new emails, the experience E is the training data, and the performance measure P needs to be defined; for example, you can use the ratio of correctly classified emails. This particular performance measure is called accuracy and it is often used in classification tasks.", "words": [{"w": "For", "b": [0.1429, 0.591, 0.1718, 0.6124]}, {"w": "example,", "b": [0.1784, 0.591, 0.2527, 0.6124]}, {"w": "your", "b": [0.2593, 0.591, 0.2983, 0.6124]}, {"w": "spam", "b": [0.3048, 0.591, 0.3496, 0.6124]}, {"w": "filter", "b": [0.3562, 0.591, 0.3962, 0.6124]}, {"w": "is", "b": [0.4027, 0.591, 0.416, 0.6124]}, {"w": "a", "b": [0.4226, 0.591, 0.4317, 0.6124]}, {"w": "Machine", "b": [0.4383, 0.591, 0.5114, 0.6124]}, {"w": "Learning", "b": [0.518, 0.591, 0.593, 0.6124]}, {"w": "program", "b": [0.5996, 0.591, 0.6726, 0.6124]}, {"w": "that", "b": [0.6792, 0.591, 0.7118, 0.6124]}, {"w": "can", "b": [0.7183, 0.591, 0.7477, 0.6124]}, {"w": "learn", "b": [0.7543, 0.591, 0.7967, 0.6124]}, {"w": "to", "b": [0.8032, 0.591, 0.8202, 0.6124]}, {"w": "flag", "b": [0.8268, 0.591, 0.8571, 0.6124]}, {"w": "spam", "b": [0.1428, 0.61, 0.1876, 0.6315]}, {"w": "given", "b": [0.1935, 0.61, 0.2387, 0.6315]}, {"w": "examples", "b": [0.2446, 0.61, 0.3218, 0.6315]}, {"w": "of", "b": [0.3277, 0.61, 0.3445, 0.6315]}, {"w": "spam", "b": [0.3504, 0.61, 0.3952, 0.6315]}, {"w": "emails", "b": [0.4011, 0.61, 0.4546, 0.6315]}, {"w": "(e.g.,", "b": [0.4605, 0.61, 0.5006, 0.6315]}, {"w": "flagged", "b": [0.5065, 0.61, 0.5664, 0.6315]}, {"w": "by", "b": [0.5723, 0.61, 0.5925, 0.6315]}, {"w": "users)", "b": [0.5984, 0.61, 0.6485, 0.6315]}, {"w": "and", "b": [0.6544, 0.61, 0.6859, 0.6315]}, {"w": "examples", "b": [0.6918, 0.61, 0.769, 0.6315]}, {"w": "of", "b": [0.7749, 0.61, 0.7917, 0.6315]}, {"w": "regular", "b": [0.7976, 0.61, 0.8571, 0.6315]}, {"w": "(nonspam,", "b": [0.1429, 0.6291, 0.233, 0.6505]}, {"w": "also", "b": [0.2391, 0.6291, 0.2718, 0.6505]}, {"w": "called", "b": [0.2778, 0.6291, 0.3262, 0.6505]}, {"w": "“ham”)", "b": [0.3323, 0.6291, 0.3917, 0.6505]}, {"w": "emails.", "b": [0.3978, 0.6291, 0.4561, 0.6505]}, {"w": "The", "b": [0.4622, 0.6291, 0.495, 0.6505]}, {"w": "examples", "b": [0.5011, 0.6291, 0.5783, 0.6505]}, {"w": "that", "b": [0.5844, 0.6291, 0.6169, 0.6505]}, {"w": "the", "b": [0.623, 0.6291, 0.6494, 0.6505]}, {"w": "system", "b": [0.6554, 0.6291, 0.7126, 0.6505]}, {"w": "uses", "b": [0.7186, 0.6291, 0.7538, 0.6505]}, {"w": "to", "b": [0.7599, 0.6291, 0.7769, 0.6505]}, {"w": "learn", "b": [0.783, 0.6291, 0.8253, 0.6505]}, {"w": "are", "b": [0.8314, 0.6291, 0.8572, 0.6505]}, {"w": "called", "b": [0.1429, 0.6481, 0.1912, 0.6696]}, {"w": "the", "b": [0.197, 0.6481, 0.2234, 0.6696]}, {"w": "training", "b": [0.2292, 0.6479, 0.2936, 0.6696]}, {"w": "set.", "b": [0.2995, 0.6479, 0.3259, 0.6696]}, {"w": "Each", "b": [0.3317, 0.6481, 0.3727, 0.6696]}, {"w": "training", "b": [0.3785, 0.6481, 0.4454, 0.6696]}, {"w": "example", "b": [0.4513, 0.6481, 0.5208, 0.6696]}, {"w": "is", "b": [0.5266, 0.6481, 0.5399, 0.6696]}, {"w": "called", "b": [0.5457, 0.6481, 0.594, 0.6696]}, {"w": "a", "b": [0.5999, 0.6481, 0.609, 0.6696]}, {"w": "training", "b": [0.6148, 0.6479, 0.6793, 0.6696]}, {"w": "instance", "b": [0.6851, 0.6479, 0.7516, 0.6696]}, {"w": "(or", "b": [0.7574, 0.6481, 0.783, 0.6696]}, {"w": "sample).", "b": [0.7888, 0.6479, 0.8571, 0.6696]}, {"w": "In", "b": [0.1429, 0.6672, 0.1614, 0.6886]}, {"w": "this", "b": [0.1668, 0.6672, 0.1975, 0.6886]}, {"w": "case,", "b": [0.203, 0.6672, 0.2422, 0.6886]}, {"w": "the", "b": [0.2477, 0.6672, 0.2741, 0.6886]}, {"w": "task", "b": [0.2795, 0.6672, 0.313, 0.6886]}, {"w": "T", "b": [0.3185, 0.6672, 0.3313, 0.6886]}, {"w": "is", "b": [0.3368, 0.6672, 0.3501, 0.6886]}, {"w": "to", "b": [0.3555, 0.6672, 0.3725, 0.6886]}, {"w": "flag", "b": [0.378, 0.6672, 0.4083, 0.6886]}, {"w": "spam", "b": [0.4138, 0.6672, 0.4586, 0.6886]}, {"w": "for", "b": [0.4641, 0.6672, 0.4886, 0.6886]}, {"w": "new", "b": [0.4941, 0.6672, 0.5286, 0.6886]}, {"w": "emails,", "b": [0.5341, 0.6672, 0.5924, 0.6886]}, {"w": "the", "b": [0.5979, 0.6672, 0.6242, 0.6886]}, {"w": "experience", "b": [0.6297, 0.6672, 0.7194, 0.6886]}, {"w": "E", "b": [0.7249, 0.6672, 0.7367, 0.6886]}, {"w": "is", "b": [0.7422, 0.6672, 0.7554, 0.6886]}, {"w": "the", "b": [0.7609, 0.6672, 0.7872, 0.6886]}, {"w": "training", "b": [0.7927, 0.667, 0.8571, 0.6886]}, {"w": "data,", "b": [0.1428, 0.686, 0.1842, 0.7076]}, {"w": "and", "b": [0.1904, 0.6862, 0.222, 0.7076]}, {"w": "the", "b": [0.2282, 0.6862, 0.2545, 0.7076]}, {"w": "performance", "b": [0.2607, 0.6862, 0.368, 0.7076]}, {"w": "measure", "b": [0.3742, 0.6862, 0.4446, 0.7076]}, {"w": "P", "b": [0.4508, 0.6862, 0.4625, 0.7076]}, {"w": "needs", "b": [0.4687, 0.6862, 0.5165, 0.7076]}, {"w": "to", "b": [0.5227, 0.6862, 0.5397, 0.7076]}, {"w": "be", "b": [0.5459, 0.6862, 0.5653, 0.7076]}, {"w": "defined;", "b": [0.5715, 0.6862, 0.6391, 0.7076]}, {"w": "for", "b": [0.6453, 0.6862, 0.6698, 0.7076]}, {"w": "example,", "b": [0.6761, 0.6862, 0.7503, 0.7076]}, {"w": "you", "b": [0.7566, 0.6862, 0.7878, 0.7076]}, {"w": "can", "b": [0.794, 0.6862, 0.8234, 0.7076]}, {"w": "use", "b": [0.8296, 0.6862, 0.8571, 0.7076]}, {"w": "the", "b": [0.1429, 0.7053, 0.1692, 0.7267]}, {"w": "ratio", "b": [0.1752, 0.7053, 0.2142, 0.7267]}, {"w": "of", "b": [0.2203, 0.7053, 0.2371, 0.7267]}, {"w": "correctly", "b": [0.2431, 0.7053, 0.3168, 0.7267]}, {"w": "classified", "b": [0.3228, 0.7053, 0.3985, 0.7267]}, {"w": "emails.", "b": [0.4046, 0.7053, 0.4629, 0.7267]}, {"w": "This", "b": [0.4689, 0.7053, 0.5061, 0.7267]}, {"w": "particular", "b": [0.5121, 0.7053, 0.5939, 0.7267]}, {"w": "performance", "b": [0.5999, 0.7053, 0.7072, 0.7267]}, {"w": "measure", "b": [0.7132, 0.7053, 0.7835, 0.7267]}, {"w": "is", "b": [0.7895, 0.7053, 0.8028, 0.7267]}, {"w": "called", "b": [0.8088, 0.7053, 0.8571, 0.7267]}, {"w": "accuracy", "b": [0.1429, 0.7241, 0.2142, 0.7457]}, {"w": "and", "b": [0.2189, 0.7243, 0.2505, 0.7457]}, {"w": "it", "b": [0.2552, 0.7243, 0.2671, 0.7457]}, {"w": "is", "b": [0.2719, 0.7243, 0.2851, 0.7457]}, {"w": "often", "b": [0.2898, 0.7243, 0.3332, 0.7457]}, {"w": "used", "b": [0.3379, 0.7243, 0.3765, 0.7457]}, {"w": "in", "b": [0.3812, 0.7243, 0.3982, 0.7457]}, {"w": "classification", "b": [0.4029, 0.7243, 0.5103, 0.7457]}, {"w": "tasks.", "b": [0.515, 0.7243, 0.5609, 0.7457]}]}, {"id": "b_11", "type": "paragraph", "text": "If you just download a copy of Wikipedia, your computer has a lot more data, but it is not suddenly better at any task. Thus, it is not Machine Learning.", "words": [{"w": "If", "b": [0.1429, 0.7524, 0.1561, 0.7739]}, {"w": "you", "b": [0.161, 0.7524, 0.1922, 0.7739]}, {"w": "just", "b": [0.1971, 0.7524, 0.2275, 0.7739]}, {"w": "download", "b": [0.2323, 0.7524, 0.3156, 0.7739]}, {"w": "a", "b": [0.3205, 0.7524, 0.3296, 0.7739]}, {"w": "copy", "b": [0.3345, 0.7524, 0.3744, 0.7739]}, {"w": "of", "b": [0.3792, 0.7524, 0.396, 0.7739]}, {"w": "Wikipedia,", "b": [0.4008, 0.7524, 0.492, 0.7739]}, {"w": "your", "b": [0.4968, 0.7524, 0.5358, 0.7739]}, {"w": "computer", "b": [0.5406, 0.7524, 0.6217, 0.7739]}, {"w": "has", "b": [0.6265, 0.7524, 0.6544, 0.7739]}, {"w": "a", "b": [0.6593, 0.7524, 0.6684, 0.7739]}, {"w": "lot", "b": [0.6732, 0.7524, 0.6955, 0.7739]}, {"w": "more", "b": [0.7003, 0.7524, 0.7446, 0.7739]}, {"w": "data,", "b": [0.7494, 0.7524, 0.7894, 0.7739]}, {"w": "but", "b": [0.7943, 0.7524, 0.8223, 0.7739]}, {"w": "it", "b": [0.8271, 0.7524, 0.8391, 0.7739]}, {"w": "is", "b": [0.8439, 0.7524, 0.8571, 0.7739]}, {"w": "not", "b": [0.1428, 0.7715, 0.1712, 0.7929]}, {"w": "suddenly", "b": [0.176, 0.7715, 0.2517, 0.7929]}, {"w": "better", "b": [0.2565, 0.7715, 0.3052, 0.7929]}, {"w": "at", "b": [0.3099, 0.7715, 0.325, 0.7929]}, {"w": "any", "b": [0.3298, 0.7715, 0.3594, 0.7929]}, {"w": "task.", "b": [0.3641, 0.7715, 0.4023, 0.7929]}, {"w": "Thus,", "b": [0.4071, 0.7715, 0.4541, 0.7929]}, {"w": "it", "b": [0.4588, 0.7715, 0.4708, 0.7929]}, {"w": "is", "b": [0.4755, 0.7715, 0.4887, 0.7929]}, {"w": "not", "b": [0.4935, 0.7715, 0.5218, 0.7929]}, {"w": "Machine", "b": [0.5266, 0.7715, 0.5997, 0.7929]}, {"w": "Learning.", "b": [0.6044, 0.7715, 0.6842, 0.7929]}]}, {"id": "b_12", "type": "paragraph", "text": "Why Use Machine Learning?", "words": [{"w": "Why", "b": [0.1428, 0.8059, 0.1981, 0.8402]}, {"w": "Use", "b": [0.204, 0.8059, 0.2484, 0.8402]}, {"w": "Machine", "b": [0.2544, 0.8059, 0.3593, 0.8402]}, {"w": "Learning?", "b": [0.3653, 0.8059, 0.4872, 0.8402]}]}, {"id": "b_13", "type": "paragraph", "text": "Consider how you would write a spam filter using traditional programming techni‐ ques (Figure 1-1):", "words": [{"w": "Consider", "b": [0.1429, 0.8471, 0.2196, 0.8685]}, {"w": "how", "b": [0.2261, 0.8471, 0.2621, 0.8685]}, {"w": "you", "b": [0.2686, 0.8471, 0.2998, 0.8685]}, {"w": "would", "b": [0.3063, 0.8471, 0.3586, 0.8685]}, {"w": "write", "b": [0.3651, 0.8471, 0.4078, 0.8685]}, {"w": "a", "b": [0.4144, 0.8471, 0.4235, 0.8685]}, {"w": "spam", "b": [0.43, 0.8471, 0.4748, 0.8685]}, {"w": "filter", "b": [0.4813, 0.8471, 0.5212, 0.8685]}, {"w": "using", "b": [0.5277, 0.8471, 0.5732, 0.8685]}, {"w": "traditional", "b": [0.5797, 0.8471, 0.6679, 0.8685]}, {"w": "programming", "b": [0.6744, 0.8471, 0.7911, 0.8685]}, {"w": "techni‐", "b": [0.7976, 0.8471, 0.8572, 0.8685]}, {"w": "ques", "b": [0.1429, 0.8661, 0.1811, 0.8875]}, {"w": "(Figure", "b": [0.1858, 0.8661, 0.247, 0.8875]}, {"w": "1-1):", "b": [0.2517, 0.8661, 0.2911, 0.8875]}]}, {"id": "b_14", "type": "paragraph", "text": "4 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "4", "b": [0.1429, 0.9225, 0.1501, 0.9388]}, {"w": "|", "b": [0.168, 0.9225, 0.1718, 0.9388]}, {"w": "Chapter", "b": [0.1896, 0.9225, 0.2359, 0.9388]}, {"w": "1:", "b": [0.2387, 0.9225, 0.2499, 0.9388]}, {"w": "The", "b": [0.2527, 0.9225, 0.2742, 0.9388]}, {"w": "Machine", "b": [0.277, 0.9225, 0.327, 0.9388]}, {"w": "Learning", "b": [0.3298, 0.9225, 0.382, 0.9388]}, {"w": "Landscape", "b": [0.3848, 0.9225, 0.4465, 0.9388]}]}]}, {"page": 31, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1. First you would look at what spam typically looks like. You might notice that some words or phrases (such as “4U,” “credit card,” “free,” and “amazing”) tend to come up a lot in the subject. Perhaps you would also notice a few other patterns in the sender’s name, the email’s body, and so on.", "words": [{"w": "1.", "b": [0.1534, 0.0851, 0.1682, 0.1065]}, {"w": "First", "b": [0.1786, 0.0851, 0.2169, 0.1065]}, {"w": "you", "b": [0.2249, 0.0851, 0.2561, 0.1065]}, {"w": "would", "b": [0.2641, 0.0851, 0.3163, 0.1065]}, {"w": "look", "b": [0.3243, 0.0851, 0.3612, 0.1065]}, {"w": "at", "b": [0.3691, 0.0851, 0.3842, 0.1065]}, {"w": "what", "b": [0.3922, 0.0851, 0.4327, 0.1065]}, {"w": "spam", "b": [0.4407, 0.0851, 0.4855, 0.1065]}, {"w": "typically", "b": [0.4935, 0.0851, 0.5639, 0.1065]}, {"w": "looks", "b": [0.5719, 0.0851, 0.6164, 0.1065]}, {"w": "like.", "b": [0.6244, 0.0851, 0.6592, 0.1065]}, {"w": "You", "b": [0.6672, 0.0851, 0.6995, 0.1065]}, {"w": "might", "b": [0.7075, 0.0851, 0.757, 0.1065]}, {"w": "notice", "b": [0.765, 0.0851, 0.8166, 0.1065]}, {"w": "that", "b": [0.8246, 0.0851, 0.8571, 0.1065]}, {"w": "some", "b": [0.1786, 0.1042, 0.2228, 0.1256]}, {"w": "words", "b": [0.2279, 0.1042, 0.2791, 0.1256]}, {"w": "or", "b": [0.2842, 0.1042, 0.3026, 0.1256]}, {"w": "phrases", "b": [0.3077, 0.1042, 0.3708, 0.1256]}, {"w": "(such", "b": [0.3759, 0.1042, 0.4217, 0.1256]}, {"w": "as", "b": [0.4268, 0.1042, 0.4436, 0.1256]}, {"w": "“4U,”", "b": [0.4487, 0.1042, 0.491, 0.1256]}, {"w": "“credit", "b": [0.4961, 0.1042, 0.551, 0.1256]}, {"w": "card,”", "b": [0.5561, 0.1042, 0.6031, 0.1256]}, {"w": "“free,”", "b": [0.6082, 0.1042, 0.6577, 0.1256]}, {"w": "and", "b": [0.6628, 0.1042, 0.6943, 0.1256]}, {"w": "“amazing”)", "b": [0.6994, 0.1042, 0.7923, 0.1256]}, {"w": "tend", "b": [0.7975, 0.1042, 0.8351, 0.1256]}, {"w": "to", "b": [0.8402, 0.1042, 0.8571, 0.1256]}, {"w": "come", "b": [0.1786, 0.1232, 0.2239, 0.1446]}, {"w": "up", "b": [0.2298, 0.1232, 0.2518, 0.1446]}, {"w": "a", "b": [0.2576, 0.1232, 0.2668, 0.1446]}, {"w": "lot", "b": [0.2727, 0.1232, 0.2949, 0.1446]}, {"w": "in", "b": [0.3008, 0.1232, 0.3178, 0.1446]}, {"w": "the", "b": [0.3236, 0.1232, 0.35, 0.1446]}, {"w": "subject.", "b": [0.3559, 0.1232, 0.4193, 0.1446]}, {"w": "Perhaps", "b": [0.4251, 0.1232, 0.4912, 0.1446]}, {"w": "you", "b": [0.4971, 0.1232, 0.5283, 0.1446]}, {"w": "would", "b": [0.5342, 0.1232, 0.5864, 0.1446]}, {"w": "also", "b": [0.5923, 0.1232, 0.625, 0.1446]}, {"w": "notice", "b": [0.6309, 0.1232, 0.6825, 0.1446]}, {"w": "a", "b": [0.6884, 0.1232, 0.6975, 0.1446]}, {"w": "few", "b": [0.7034, 0.1232, 0.7327, 0.1446]}, {"w": "other", "b": [0.7386, 0.1232, 0.7833, 0.1446]}, {"w": "patterns", "b": [0.7891, 0.1232, 0.8571, 0.1446]}, {"w": "in", "b": [0.1786, 0.1423, 0.1956, 0.1637]}, {"w": "the", "b": [0.2003, 0.1423, 0.2266, 0.1637]}, {"w": "sender’s", "b": [0.2313, 0.1423, 0.2971, 0.1637]}, {"w": "name,", "b": [0.3019, 0.1423, 0.3531, 0.1637]}, {"w": "the", "b": [0.3578, 0.1423, 0.3841, 0.1637]}, {"w": "email’s", "b": [0.3889, 0.1423, 0.4446, 0.1637]}, {"w": "body,", "b": [0.4493, 0.1423, 0.4943, 0.1637]}, {"w": "and", "b": [0.499, 0.1423, 0.5306, 0.1637]}, {"w": "so", "b": [0.5353, 0.1423, 0.5536, 0.1637]}, {"w": "on.", "b": [0.5583, 0.1423, 0.5851, 0.1637]}]}, {"id": "b_1", "type": "paragraph", "text": "2. You would write a detection algorithm for each of the patterns that you noticed, and your program would flag emails as spam if a number of these patterns are detected.", "words": [{"w": "2.", "b": [0.1534, 0.1673, 0.1682, 0.1888]}, {"w": "You", "b": [0.1786, 0.1673, 0.2109, 0.1888]}, {"w": "would", "b": [0.2168, 0.1673, 0.2691, 0.1888]}, {"w": "write", "b": [0.275, 0.1673, 0.3178, 0.1888]}, {"w": "a", "b": [0.3237, 0.1673, 0.3328, 0.1888]}, {"w": "detection", "b": [0.3387, 0.1673, 0.4165, 0.1888]}, {"w": "algorithm", "b": [0.4225, 0.1673, 0.5051, 0.1888]}, {"w": "for", "b": [0.511, 0.1673, 0.5355, 0.1888]}, {"w": "each", "b": [0.5414, 0.1673, 0.5794, 0.1888]}, {"w": "of", "b": [0.5853, 0.1673, 0.6021, 0.1888]}, {"w": "the", "b": [0.608, 0.1673, 0.6343, 0.1888]}, {"w": "patterns", "b": [0.6402, 0.1673, 0.7082, 0.1888]}, {"w": "that", "b": [0.7141, 0.1673, 0.7467, 0.1888]}, {"w": "you", "b": [0.7526, 0.1673, 0.7839, 0.1888]}, {"w": "noticed,", "b": [0.7898, 0.1673, 0.8571, 0.1888]}, {"w": "and", "b": [0.1786, 0.1864, 0.2101, 0.2078]}, {"w": "your", "b": [0.217, 0.1864, 0.256, 0.2078]}, {"w": "program", "b": [0.2629, 0.1864, 0.3359, 0.2078]}, {"w": "would", "b": [0.3428, 0.1864, 0.395, 0.2078]}, {"w": "flag", "b": [0.402, 0.1864, 0.4323, 0.2078]}, {"w": "emails", "b": [0.4392, 0.1864, 0.4928, 0.2078]}, {"w": "as", "b": [0.4997, 0.1864, 0.5165, 0.2078]}, {"w": "spam", "b": [0.5234, 0.1864, 0.5682, 0.2078]}, {"w": "if", "b": [0.5751, 0.1864, 0.5868, 0.2078]}, {"w": "a", "b": [0.5938, 0.1864, 0.6029, 0.2078]}, {"w": "number", "b": [0.6098, 0.1864, 0.6761, 0.2078]}, {"w": "of", "b": [0.683, 0.1864, 0.6998, 0.2078]}, {"w": "these", "b": [0.7067, 0.1864, 0.7496, 0.2078]}, {"w": "patterns", "b": [0.7565, 0.1864, 0.8245, 0.2078]}, {"w": "are", "b": [0.8314, 0.1864, 0.8571, 0.2078]}, {"w": "detected.", "b": [0.1786, 0.2054, 0.2534, 0.2269]}]}, {"id": "b_2", "type": "paragraph", "text": "3. You would test your program, and repeat steps 1 and 2 until it is good enough.", "words": [{"w": "3.", "b": [0.1534, 0.2305, 0.1682, 0.2519]}, {"w": "You", "b": [0.1786, 0.2305, 0.2109, 0.2519]}, {"w": "would", "b": [0.2156, 0.2305, 0.2679, 0.2519]}, {"w": "test", "b": [0.2726, 0.2305, 0.3018, 0.2519]}, {"w": "your", "b": [0.3065, 0.2305, 0.3455, 0.2519]}, {"w": "program,", "b": [0.3503, 0.2305, 0.428, 0.2519]}, {"w": "and", "b": [0.4327, 0.2305, 0.4642, 0.2519]}, {"w": "repeat", "b": [0.469, 0.2305, 0.5204, 0.2519]}, {"w": "steps", "b": [0.5251, 0.2305, 0.5666, 0.2519]}, {"w": "1", "b": [0.5713, 0.2305, 0.5813, 0.2519]}, {"w": "and", "b": [0.586, 0.2305, 0.6176, 0.2519]}, {"w": "2", "b": [0.6223, 0.2305, 0.6323, 0.2519]}, {"w": "until", "b": [0.637, 0.2305, 0.6763, 0.2519]}, {"w": "it", "b": [0.681, 0.2305, 0.693, 0.2519]}, {"w": "is", "b": [0.6977, 0.2305, 0.7109, 0.2519]}, {"w": "good", "b": [0.7156, 0.2305, 0.7576, 0.2519]}, {"w": "enough.", "b": [0.7624, 0.2305, 0.8299, 0.2519]}]}, {"id": "b_3", "type": "equation", "text": "Figure 1-1. The traditional approach", "words": [{"w": "Figure", "b": [0.1429, 0.5062, 0.1943, 0.5278]}, {"w": "1-1.", "b": [0.1991, 0.5062, 0.2308, 0.5278]}, {"w": "The", "b": [0.2356, 0.5062, 0.2654, 0.5278]}, {"w": "traditional", "b": [0.2702, 0.5062, 0.3569, 0.5278]}, {"w": "approach", "b": [0.3617, 0.5062, 0.4369, 0.5278]}]}, {"id": "b_4", "type": "paragraph", "text": "Since the problem is not trivial, your program will likely become a long list of com‐ plex rules—pretty hard to maintain.", "words": [{"w": "Since", "b": [0.1429, 0.5436, 0.1874, 0.565]}, {"w": "the", "b": [0.1936, 0.5436, 0.2199, 0.565]}, {"w": "problem", "b": [0.2261, 0.5436, 0.2971, 0.565]}, {"w": "is", "b": [0.3033, 0.5436, 0.3166, 0.565]}, {"w": "not", "b": [0.3228, 0.5436, 0.3512, 0.565]}, {"w": "trivial,", "b": [0.3573, 0.5436, 0.4114, 0.565]}, {"w": "your", "b": [0.4176, 0.5436, 0.4566, 0.565]}, {"w": "program", "b": [0.4628, 0.5436, 0.5357, 0.565]}, {"w": "will", "b": [0.5419, 0.5436, 0.5723, 0.565]}, {"w": "likely", "b": [0.5785, 0.5436, 0.6234, 0.565]}, {"w": "become", "b": [0.6296, 0.5436, 0.6944, 0.565]}, {"w": "a", "b": [0.7006, 0.5436, 0.7097, 0.565]}, {"w": "long", "b": [0.7159, 0.5436, 0.753, 0.565]}, {"w": "list", "b": [0.7592, 0.5436, 0.784, 0.565]}, {"w": "of", "b": [0.7902, 0.5436, 0.807, 0.565]}, {"w": "com‐", "b": [0.8132, 0.5436, 0.8571, 0.565]}, {"w": "plex", "b": [0.1429, 0.5627, 0.1777, 0.5841]}, {"w": "rules—pretty", "b": [0.1825, 0.5627, 0.292, 0.5841]}, {"w": "hard", "b": [0.2967, 0.5627, 0.3357, 0.5841]}, {"w": "to", "b": [0.3405, 0.5627, 0.3574, 0.5841]}, {"w": "maintain.", "b": [0.3622, 0.5627, 0.4422, 0.5841]}]}, {"id": "b_5", "type": "paragraph", "text": "In contrast, a spam filter based on Machine Learning techniques automatically learns which words and phrases are good predictors of spam by detecting unusually fre‐ quent patterns of words in the spam examples compared to the ham examples (Figure 1-2). The program is much shorter, easier to maintain, and most likely more accurate.", "words": [{"w": "In", "b": [0.1429, 0.5908, 0.1614, 0.6122]}, {"w": "contrast,", "b": [0.1667, 0.5908, 0.2391, 0.6122]}, {"w": "a", "b": [0.2445, 0.5908, 0.2537, 0.6122]}, {"w": "spam", "b": [0.259, 0.5908, 0.3038, 0.6122]}, {"w": "filter", "b": [0.3092, 0.5908, 0.3491, 0.6122]}, {"w": "based", "b": [0.3545, 0.5908, 0.4017, 0.6122]}, {"w": "on", "b": [0.4071, 0.5908, 0.4291, 0.6122]}, {"w": "Machine", "b": [0.4345, 0.5908, 0.5076, 0.6122]}, {"w": "Learning", "b": [0.513, 0.5908, 0.588, 0.6122]}, {"w": "techniques", "b": [0.5934, 0.5908, 0.6837, 0.6122]}, {"w": "automatically", "b": [0.6891, 0.5908, 0.8017, 0.6122]}, {"w": "learns", "b": [0.8071, 0.5908, 0.8571, 0.6122]}, {"w": "which", "b": [0.1429, 0.6098, 0.1938, 0.6312]}, {"w": "words", "b": [0.2017, 0.6098, 0.2529, 0.6312]}, {"w": "and", "b": [0.2608, 0.6098, 0.2924, 0.6312]}, {"w": "phrases", "b": [0.3002, 0.6098, 0.3633, 0.6312]}, {"w": "are", "b": [0.3712, 0.6098, 0.3969, 0.6312]}, {"w": "good", "b": [0.4048, 0.6098, 0.4468, 0.6312]}, {"w": "predictors", "b": [0.4547, 0.6098, 0.5399, 0.6312]}, {"w": "of", "b": [0.5478, 0.6098, 0.5646, 0.6312]}, {"w": "spam", "b": [0.5725, 0.6098, 0.6173, 0.6312]}, {"w": "by", "b": [0.6251, 0.6098, 0.6453, 0.6312]}, {"w": "detecting", "b": [0.6532, 0.6098, 0.7301, 0.6312]}, {"w": "unusually", "b": [0.738, 0.6098, 0.8191, 0.6312]}, {"w": "fre‐", "b": [0.827, 0.6098, 0.8572, 0.6312]}, {"w": "quent", "b": [0.1429, 0.6289, 0.1908, 0.6503]}, {"w": "patterns", "b": [0.2011, 0.6289, 0.2691, 0.6503]}, {"w": "of", "b": [0.2794, 0.6289, 0.2961, 0.6503]}, {"w": "words", "b": [0.3064, 0.6289, 0.3577, 0.6503]}, {"w": "in", "b": [0.368, 0.6289, 0.385, 0.6503]}, {"w": "the", "b": [0.3953, 0.6289, 0.4216, 0.6503]}, {"w": "spam", "b": [0.4319, 0.6289, 0.4766, 0.6503]}, {"w": "examples", "b": [0.4869, 0.6289, 0.5641, 0.6503]}, {"w": "compared", "b": [0.5744, 0.6289, 0.6582, 0.6503]}, {"w": "to", "b": [0.6684, 0.6289, 0.6854, 0.6503]}, {"w": "the", "b": [0.6957, 0.6289, 0.722, 0.6503]}, {"w": "ham", "b": [0.7323, 0.6289, 0.7697, 0.6503]}, {"w": "examples", "b": [0.78, 0.6289, 0.8571, 0.6503]}, {"w": "(Figure", "b": [0.1429, 0.6479, 0.2041, 0.6693]}, {"w": "1-2).", "b": [0.2099, 0.6479, 0.2493, 0.6693]}, {"w": "The", "b": [0.2552, 0.6479, 0.288, 0.6693]}, {"w": "program", "b": [0.2939, 0.6479, 0.3668, 0.6693]}, {"w": "is", "b": [0.3727, 0.6479, 0.3859, 0.6693]}, {"w": "much", "b": [0.3918, 0.6479, 0.4395, 0.6693]}, {"w": "shorter,", "b": [0.4454, 0.6479, 0.5089, 0.6693]}, {"w": "easier", "b": [0.5147, 0.6479, 0.5625, 0.6693]}, {"w": "to", "b": [0.5684, 0.6479, 0.5854, 0.6693]}, {"w": "maintain,", "b": [0.5913, 0.6479, 0.6713, 0.6693]}, {"w": "and", "b": [0.6772, 0.6479, 0.7087, 0.6693]}, {"w": "most", "b": [0.7146, 0.6479, 0.7563, 0.6693]}, {"w": "likely", "b": [0.7621, 0.6479, 0.807, 0.6693]}, {"w": "more", "b": [0.8129, 0.6479, 0.8571, 0.6693]}, {"w": "accurate.", "b": [0.1428, 0.667, 0.2171, 0.6884]}]}, {"id": "b_6", "type": "paragraph", "text": "Why Use Machine Learning? | 5", "words": [{"w": "Why", "b": [0.6466, 0.9225, 0.6729, 0.9388]}, {"w": "Use", "b": [0.6757, 0.9225, 0.6968, 0.9388]}, {"w": "Machine", "b": [0.6996, 0.9225, 0.7496, 0.9388]}, {"w": "Learning?", "b": [0.7524, 0.9225, 0.8104, 0.9388]}, {"w": "|", "b": [0.8282, 0.9225, 0.832, 0.9388]}, {"w": "5", "b": [0.8499, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 32, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 1-2. Machine Learning approach", "words": [{"w": "Figure", "b": [0.1429, 0.3336, 0.1943, 0.3552]}, {"w": "1-2.", "b": [0.1991, 0.3336, 0.2308, 0.3552]}, {"w": "Machine", "b": [0.2356, 0.3336, 0.3059, 0.3552]}, {"w": "Learning", "b": [0.3107, 0.3336, 0.3835, 0.3552]}, {"w": "approach", "b": [0.3882, 0.3336, 0.4634, 0.3552]}]}, {"id": "b_1", "type": "paragraph", "text": "Moreover, if spammers notice that all their emails containing “4U” are blocked, they might start writing “For U” instead. A spam filter using traditional programming techniques would need to be updated to flag “For U” emails. If spammers keep work‐ ing around your spam filter, you will need to keep writing new rules forever.", "words": [{"w": "Moreover,", "b": [0.1429, 0.371, 0.2284, 0.3924]}, {"w": "if", "b": [0.2342, 0.371, 0.246, 0.3924]}, {"w": "spammers", "b": [0.2519, 0.371, 0.3379, 0.3924]}, {"w": "notice", "b": [0.3438, 0.371, 0.3954, 0.3924]}, {"w": "that", "b": [0.4013, 0.371, 0.4339, 0.3924]}, {"w": "all", "b": [0.4397, 0.371, 0.4594, 0.3924]}, {"w": "their", "b": [0.4653, 0.371, 0.5049, 0.3924]}, {"w": "emails", "b": [0.5108, 0.371, 0.5643, 0.3924]}, {"w": "containing", "b": [0.5702, 0.371, 0.6599, 0.3924]}, {"w": "“4U”", "b": [0.6657, 0.371, 0.7077, 0.3924]}, {"w": "are", "b": [0.7136, 0.371, 0.7393, 0.3924]}, {"w": "blocked,", "b": [0.7452, 0.371, 0.8154, 0.3924]}, {"w": "they", "b": [0.8212, 0.371, 0.8571, 0.3924]}, {"w": "might", "b": [0.1429, 0.39, 0.1923, 0.4114]}, {"w": "start", "b": [0.2007, 0.39, 0.2379, 0.4114]}, {"w": "writing", "b": [0.2462, 0.39, 0.3069, 0.4114]}, {"w": "“For", "b": [0.3152, 0.39, 0.3525, 0.4114]}, {"w": "U”", "b": [0.3609, 0.39, 0.3845, 0.4114]}, {"w": "instead.", "b": [0.3929, 0.39, 0.4576, 0.4114]}, {"w": "A", "b": [0.4659, 0.39, 0.4803, 0.4114]}, {"w": "spam", "b": [0.4887, 0.39, 0.5334, 0.4114]}, {"w": "filter", "b": [0.5418, 0.39, 0.5817, 0.4114]}, {"w": "using", "b": [0.5901, 0.39, 0.6355, 0.4114]}, {"w": "traditional", "b": [0.6439, 0.39, 0.732, 0.4114]}, {"w": "programming", "b": [0.7404, 0.39, 0.8571, 0.4114]}, {"w": "techniques", "b": [0.1429, 0.4091, 0.2332, 0.4305]}, {"w": "would", "b": [0.2383, 0.4091, 0.2906, 0.4305]}, {"w": "need", "b": [0.2957, 0.4091, 0.3358, 0.4305]}, {"w": "to", "b": [0.341, 0.4091, 0.3579, 0.4305]}, {"w": "be", "b": [0.3631, 0.4091, 0.3825, 0.4305]}, {"w": "updated", "b": [0.3877, 0.4091, 0.4556, 0.4305]}, {"w": "to", "b": [0.4608, 0.4091, 0.4777, 0.4305]}, {"w": "flag", "b": [0.4829, 0.4091, 0.5132, 0.4305]}, {"w": "“For", "b": [0.5184, 0.4091, 0.5556, 0.4305]}, {"w": "U”", "b": [0.5608, 0.4091, 0.5845, 0.4305]}, {"w": "emails.", "b": [0.5896, 0.4091, 0.6479, 0.4305]}, {"w": "If", "b": [0.6531, 0.4091, 0.6663, 0.4305]}, {"w": "spammers", "b": [0.6715, 0.4091, 0.7575, 0.4305]}, {"w": "keep", "b": [0.7627, 0.4091, 0.8016, 0.4305]}, {"w": "work‐", "b": [0.8068, 0.4091, 0.8572, 0.4305]}, {"w": "ing", "b": [0.1429, 0.4281, 0.1696, 0.4495]}, {"w": "around", "b": [0.1743, 0.4281, 0.2353, 0.4495]}, {"w": "your", "b": [0.24, 0.4281, 0.279, 0.4495]}, {"w": "spam", "b": [0.2837, 0.4281, 0.3285, 0.4495]}, {"w": "filter,", "b": [0.3332, 0.4281, 0.3766, 0.4495]}, {"w": "you", "b": [0.3813, 0.4281, 0.4126, 0.4495]}, {"w": "will", "b": [0.4173, 0.4281, 0.4477, 0.4495]}, {"w": "need", "b": [0.4524, 0.4281, 0.4925, 0.4495]}, {"w": "to", "b": [0.4973, 0.4281, 0.5143, 0.4495]}, {"w": "keep", "b": [0.519, 0.4281, 0.5579, 0.4495]}, {"w": "writing", "b": [0.5627, 0.4281, 0.6233, 0.4495]}, {"w": "new", "b": [0.6281, 0.4281, 0.6626, 0.4495]}, {"w": "rules", "b": [0.6673, 0.4281, 0.7079, 0.4495]}, {"w": "forever.", "b": [0.7126, 0.4281, 0.7757, 0.4495]}]}, {"id": "b_2", "type": "paragraph", "text": "In contrast, a spam filter based on Machine Learning techniques automatically noti‐ ces that “For U” has become unusually frequent in spam flagged by users, and it starts flagging them without your intervention (Figure 1-3).", "words": [{"w": "In", "b": [0.1429, 0.4562, 0.1614, 0.4776]}, {"w": "contrast,", "b": [0.1675, 0.4562, 0.2399, 0.4776]}, {"w": "a", "b": [0.2461, 0.4562, 0.2552, 0.4776]}, {"w": "spam", "b": [0.2614, 0.4562, 0.3062, 0.4776]}, {"w": "filter", "b": [0.3123, 0.4562, 0.3523, 0.4776]}, {"w": "based", "b": [0.3584, 0.4562, 0.4057, 0.4776]}, {"w": "on", "b": [0.4118, 0.4562, 0.4339, 0.4776]}, {"w": "Machine", "b": [0.44, 0.4562, 0.5131, 0.4776]}, {"w": "Learning", "b": [0.5193, 0.4562, 0.5944, 0.4776]}, {"w": "techniques", "b": [0.6005, 0.4562, 0.6908, 0.4776]}, {"w": "automatically", "b": [0.697, 0.4562, 0.8096, 0.4776]}, {"w": "noti‐", "b": [0.8158, 0.4562, 0.8571, 0.4776]}, {"w": "ces", "b": [0.1429, 0.4753, 0.1682, 0.4967]}, {"w": "that", "b": [0.173, 0.4753, 0.2056, 0.4967]}, {"w": "“For", "b": [0.2105, 0.4753, 0.2478, 0.4967]}, {"w": "U”", "b": [0.2526, 0.4753, 0.2763, 0.4967]}, {"w": "has", "b": [0.2812, 0.4753, 0.3091, 0.4967]}, {"w": "become", "b": [0.314, 0.4753, 0.3788, 0.4967]}, {"w": "unusually", "b": [0.3837, 0.4753, 0.4647, 0.4967]}, {"w": "frequent", "b": [0.4696, 0.4753, 0.5403, 0.4967]}, {"w": "in", "b": [0.5452, 0.4753, 0.5621, 0.4967]}, {"w": "spam", "b": [0.567, 0.4753, 0.6118, 0.4967]}, {"w": "flagged", "b": [0.6166, 0.4753, 0.6766, 0.4967]}, {"w": "by", "b": [0.6815, 0.4753, 0.7016, 0.4967]}, {"w": "users,", "b": [0.7065, 0.4753, 0.7542, 0.4967]}, {"w": "and", "b": [0.759, 0.4753, 0.7906, 0.4967]}, {"w": "it", "b": [0.7955, 0.4753, 0.8074, 0.4967]}, {"w": "starts", "b": [0.8123, 0.4753, 0.8571, 0.4967]}, {"w": "flagging", "b": [0.1428, 0.4943, 0.2097, 0.5157]}, {"w": "them", "b": [0.2144, 0.4943, 0.2578, 0.5157]}, {"w": "without", "b": [0.2625, 0.4943, 0.3279, 0.5157]}, {"w": "your", "b": [0.3326, 0.4943, 0.3716, 0.5157]}, {"w": "intervention", "b": [0.3763, 0.4943, 0.4799, 0.5157]}, {"w": "(Figure", "b": [0.4846, 0.4943, 0.5458, 0.5157]}, {"w": "1-3).", "b": [0.5506, 0.4943, 0.59, 0.5157]}]}, {"id": "b_3", "type": "equation", "text": "Figure 1-3. Automatically adapting to change", "words": [{"w": "Figure", "b": [0.1428, 0.7127, 0.1943, 0.7344]}, {"w": "1-3.", "b": [0.1991, 0.7127, 0.2308, 0.7344]}, {"w": "Automatically", "b": [0.2356, 0.7127, 0.3507, 0.7344]}, {"w": "adapting", "b": [0.3555, 0.7127, 0.4271, 0.7344]}, {"w": "to", "b": [0.4319, 0.7127, 0.4479, 0.7344]}, {"w": "change", "b": [0.4526, 0.7127, 0.5086, 0.7344]}]}, {"id": "b_4", "type": "paragraph", "text": "Another area where Machine Learning shines is for problems that either are too com‐ plex for traditional approaches or have no known algorithm. For example, consider speech recognition: say you want to start simple and write a program capable of dis‐ tinguishing the words “one” and “two.” You might notice that the word “two” starts with a high-pitch sound (“T”), so you could hardcode an algorithm that measures high-pitch sound intensity and use that to distinguish ones and twos. Obviously this technique will not scale to thousands of words spoken by millions of very different", "words": [{"w": "Another", "b": [0.1428, 0.7501, 0.2133, 0.7715]}, {"w": "area", "b": [0.2182, 0.7501, 0.2531, 0.7715]}, {"w": "where", "b": [0.2579, 0.7501, 0.3087, 0.7715]}, {"w": "Machine", "b": [0.3136, 0.7501, 0.3867, 0.7715]}, {"w": "Learning", "b": [0.3915, 0.7501, 0.4666, 0.7715]}, {"w": "shines", "b": [0.4714, 0.7501, 0.5237, 0.7715]}, {"w": "is", "b": [0.5285, 0.7501, 0.5417, 0.7715]}, {"w": "for", "b": [0.5466, 0.7501, 0.5711, 0.7715]}, {"w": "problems", "b": [0.5759, 0.7501, 0.6546, 0.7715]}, {"w": "that", "b": [0.6595, 0.7501, 0.692, 0.7715]}, {"w": "either", "b": [0.6969, 0.7501, 0.7454, 0.7715]}, {"w": "are", "b": [0.7502, 0.7501, 0.776, 0.7715]}, {"w": "too", "b": [0.7808, 0.7501, 0.8084, 0.7715]}, {"w": "com‐", "b": [0.8132, 0.7501, 0.8572, 0.7715]}, {"w": "plex", "b": [0.1429, 0.7692, 0.1777, 0.7906]}, {"w": "for", "b": [0.1838, 0.7692, 0.2083, 0.7906]}, {"w": "traditional", "b": [0.2144, 0.7692, 0.3026, 0.7906]}, {"w": "approaches", "b": [0.3087, 0.7692, 0.4032, 0.7906]}, {"w": "or", "b": [0.4093, 0.7692, 0.4277, 0.7906]}, {"w": "have", "b": [0.4338, 0.7692, 0.4722, 0.7906]}, {"w": "no", "b": [0.4783, 0.7692, 0.5003, 0.7906]}, {"w": "known", "b": [0.5064, 0.7692, 0.5644, 0.7906]}, {"w": "algorithm.", "b": [0.5705, 0.7692, 0.6579, 0.7906]}, {"w": "For", "b": [0.664, 0.7692, 0.6929, 0.7906]}, {"w": "example,", "b": [0.699, 0.7692, 0.7733, 0.7906]}, {"w": "consider", "b": [0.7794, 0.7692, 0.8511, 0.7906]}, {"w": "speech", "b": [0.1429, 0.7882, 0.1991, 0.8096]}, {"w": "recognition:", "b": [0.2049, 0.7882, 0.3064, 0.8096]}, {"w": "say", "b": [0.3123, 0.7882, 0.3383, 0.8096]}, {"w": "you", "b": [0.3441, 0.7882, 0.3754, 0.8096]}, {"w": "want", "b": [0.3813, 0.7882, 0.422, 0.8096]}, {"w": "to", "b": [0.4279, 0.7882, 0.4449, 0.8096]}, {"w": "start", "b": [0.4508, 0.7882, 0.488, 0.8096]}, {"w": "simple", "b": [0.4939, 0.7882, 0.5488, 0.8096]}, {"w": "and", "b": [0.5547, 0.7882, 0.5862, 0.8096]}, {"w": "write", "b": [0.5921, 0.7882, 0.6349, 0.8096]}, {"w": "a", "b": [0.6408, 0.7882, 0.6499, 0.8096]}, {"w": "program", "b": [0.6558, 0.7882, 0.7287, 0.8096]}, {"w": "capable", "b": [0.7346, 0.7882, 0.7969, 0.8096]}, {"w": "of", "b": [0.8028, 0.7882, 0.8196, 0.8096]}, {"w": "dis‐", "b": [0.8255, 0.7882, 0.8571, 0.8096]}, {"w": "tinguishing", "b": [0.1428, 0.8073, 0.2381, 0.8287]}, {"w": "the", "b": [0.245, 0.8073, 0.2714, 0.8287]}, {"w": "words", "b": [0.2783, 0.8073, 0.3296, 0.8287]}, {"w": "“one”", "b": [0.3365, 0.8073, 0.3811, 0.8287]}, {"w": "and", "b": [0.3881, 0.8073, 0.4196, 0.8287]}, {"w": "“two.”", "b": [0.4266, 0.8073, 0.475, 0.8287]}, {"w": "You", "b": [0.482, 0.8073, 0.5143, 0.8287]}, {"w": "might", "b": [0.5213, 0.8073, 0.5707, 0.8287]}, {"w": "notice", "b": [0.5777, 0.8073, 0.6293, 0.8287]}, {"w": "that", "b": [0.6363, 0.8073, 0.6689, 0.8287]}, {"w": "the", "b": [0.6758, 0.8073, 0.7021, 0.8287]}, {"w": "word", "b": [0.7091, 0.8073, 0.7527, 0.8287]}, {"w": "“two”", "b": [0.7597, 0.8073, 0.8053, 0.8287]}, {"w": "starts", "b": [0.8123, 0.8073, 0.8571, 0.8287]}, {"w": "with", "b": [0.1429, 0.8263, 0.1802, 0.8477]}, {"w": "a", "b": [0.1877, 0.8263, 0.1969, 0.8477]}, {"w": "high-pitch", "b": [0.2044, 0.8263, 0.2922, 0.8477]}, {"w": "sound", "b": [0.2997, 0.8263, 0.3514, 0.8477]}, {"w": "(“T”),", "b": [0.359, 0.8263, 0.4086, 0.8477]}, {"w": "so", "b": [0.4161, 0.8263, 0.4344, 0.8477]}, {"w": "you", "b": [0.4419, 0.8263, 0.4732, 0.8477]}, {"w": "could", "b": [0.4807, 0.8263, 0.5275, 0.8477]}, {"w": "hardcode", "b": [0.535, 0.8263, 0.6133, 0.8477]}, {"w": "an", "b": [0.6208, 0.8263, 0.6413, 0.8477]}, {"w": "algorithm", "b": [0.6489, 0.8263, 0.7315, 0.8477]}, {"w": "that", "b": [0.739, 0.8263, 0.7716, 0.8477]}, {"w": "measures", "b": [0.7791, 0.8263, 0.8571, 0.8477]}, {"w": "high-pitch", "b": [0.1429, 0.8454, 0.2306, 0.8668]}, {"w": "sound", "b": [0.2366, 0.8454, 0.2883, 0.8668]}, {"w": "intensity", "b": [0.2942, 0.8454, 0.3666, 0.8668]}, {"w": "and", "b": [0.3725, 0.8454, 0.404, 0.8668]}, {"w": "use", "b": [0.4099, 0.8454, 0.4375, 0.8668]}, {"w": "that", "b": [0.4434, 0.8454, 0.476, 0.8668]}, {"w": "to", "b": [0.4819, 0.8454, 0.4989, 0.8668]}, {"w": "distinguish", "b": [0.5048, 0.8454, 0.5976, 0.8668]}, {"w": "ones", "b": [0.6035, 0.8454, 0.642, 0.8668]}, {"w": "and", "b": [0.6479, 0.8454, 0.6795, 0.8668]}, {"w": "twos.", "b": [0.6854, 0.8454, 0.729, 0.8668]}, {"w": "Obviously", "b": [0.735, 0.8454, 0.8205, 0.8668]}, {"w": "this", "b": [0.8264, 0.8454, 0.8571, 0.8668]}, {"w": "technique", "b": [0.1429, 0.8644, 0.2255, 0.8858]}, {"w": "will", "b": [0.2324, 0.8644, 0.2628, 0.8858]}, {"w": "not", "b": [0.2696, 0.8644, 0.298, 0.8858]}, {"w": "scale", "b": [0.3048, 0.8644, 0.3445, 0.8858]}, {"w": "to", "b": [0.3514, 0.8644, 0.3683, 0.8858]}, {"w": "thousands", "b": [0.3752, 0.8644, 0.4612, 0.8858]}, {"w": "of", "b": [0.468, 0.8644, 0.4848, 0.8858]}, {"w": "words", "b": [0.4916, 0.8644, 0.5429, 0.8858]}, {"w": "spoken", "b": [0.5497, 0.8644, 0.6095, 0.8858]}, {"w": "by", "b": [0.6163, 0.8644, 0.6365, 0.8858]}, {"w": "millions", "b": [0.6433, 0.8644, 0.7117, 0.8858]}, {"w": "of", "b": [0.7186, 0.8644, 0.7354, 0.8858]}, {"w": "very", "b": [0.7422, 0.8644, 0.7786, 0.8858]}, {"w": "different", "b": [0.7854, 0.8644, 0.8571, 0.8858]}]}, {"id": "b_5", "type": "paragraph", "text": "6 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "6", "b": [0.1429, 0.9225, 0.1501, 0.9388]}, {"w": "|", "b": [0.168, 0.9225, 0.1717, 0.9388]}, {"w": "Chapter", "b": [0.1896, 0.9225, 0.2359, 0.9388]}, {"w": "1:", "b": [0.2387, 0.9225, 0.2499, 0.9388]}, {"w": "The", "b": [0.2527, 0.9225, 0.2742, 0.9388]}, {"w": "Machine", "b": [0.277, 0.9225, 0.3269, 0.9388]}, {"w": "Learning", "b": [0.3298, 0.9225, 0.382, 0.9388]}, {"w": "Landscape", "b": [0.3848, 0.9225, 0.4465, 0.9388]}]}]}, {"page": 33, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "people in noisy environments and in dozens of languages. The best solution (at least today) is to write an algorithm that learns by itself, given many example recordings for each word.", "words": [{"w": "people", "b": [0.1429, 0.0791, 0.1983, 0.1005]}, {"w": "in", "b": [0.2042, 0.0791, 0.2212, 0.1005]}, {"w": "noisy", "b": [0.2271, 0.0791, 0.2719, 0.1005]}, {"w": "environments", "b": [0.2778, 0.0791, 0.3934, 0.1005]}, {"w": "and", "b": [0.3993, 0.0791, 0.4309, 0.1005]}, {"w": "in", "b": [0.4368, 0.0791, 0.4537, 0.1005]}, {"w": "dozens", "b": [0.4596, 0.0791, 0.5179, 0.1005]}, {"w": "of", "b": [0.5238, 0.0791, 0.5406, 0.1005]}, {"w": "languages.", "b": [0.5465, 0.0791, 0.6333, 0.1005]}, {"w": "The", "b": [0.6392, 0.0791, 0.672, 0.1005]}, {"w": "best", "b": [0.6779, 0.0791, 0.7113, 0.1005]}, {"w": "solution", "b": [0.7172, 0.0791, 0.7858, 0.1005]}, {"w": "(at", "b": [0.7917, 0.0791, 0.814, 0.1005]}, {"w": "least", "b": [0.8199, 0.0791, 0.8571, 0.1005]}, {"w": "today)", "b": [0.1429, 0.0981, 0.1964, 0.1195]}, {"w": "is", "b": [0.203, 0.0981, 0.2163, 0.1195]}, {"w": "to", "b": [0.2229, 0.0981, 0.2399, 0.1195]}, {"w": "write", "b": [0.2466, 0.0981, 0.2894, 0.1195]}, {"w": "an", "b": [0.296, 0.0981, 0.3166, 0.1195]}, {"w": "algorithm", "b": [0.3232, 0.0981, 0.4059, 0.1195]}, {"w": "that", "b": [0.4125, 0.0981, 0.4451, 0.1195]}, {"w": "learns", "b": [0.4518, 0.0981, 0.5018, 0.1195]}, {"w": "by", "b": [0.5085, 0.0981, 0.5286, 0.1195]}, {"w": "itself,", "b": [0.5353, 0.0981, 0.5799, 0.1195]}, {"w": "given", "b": [0.5866, 0.0981, 0.6318, 0.1195]}, {"w": "many", "b": [0.6385, 0.0981, 0.6851, 0.1195]}, {"w": "example", "b": [0.6918, 0.0981, 0.7614, 0.1195]}, {"w": "recordings", "b": [0.768, 0.0981, 0.8571, 0.1195]}, {"w": "for", "b": [0.1429, 0.1172, 0.1674, 0.1386]}, {"w": "each", "b": [0.1721, 0.1172, 0.2101, 0.1386]}, {"w": "word.", "b": [0.2148, 0.1172, 0.2632, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "Finally, Machine Learning can help humans learn (Figure 1-4): ML algorithms can be inspected to see what they have learned (although for some algorithms this can be tricky). For instance, once the spam filter has been trained on enough spam, it can easily be inspected to reveal the list of words and combinations of words that it believes are the best predictors of spam. Sometimes this will reveal unsuspected cor‐ relations or new trends, and thereby lead to a better understanding of the problem.", "words": [{"w": "Finally,", "b": [0.1429, 0.1453, 0.2033, 0.1667]}, {"w": "Machine", "b": [0.2084, 0.1453, 0.2816, 0.1667]}, {"w": "Learning", "b": [0.2867, 0.1453, 0.3617, 0.1667]}, {"w": "can", "b": [0.3668, 0.1453, 0.3962, 0.1667]}, {"w": "help", "b": [0.4013, 0.1453, 0.4375, 0.1667]}, {"w": "humans", "b": [0.4426, 0.1453, 0.5096, 0.1667]}, {"w": "learn", "b": [0.5147, 0.1453, 0.5571, 0.1667]}, {"w": "(Figure", "b": [0.5622, 0.1453, 0.6234, 0.1667]}, {"w": "1-4):", "b": [0.6281, 0.1453, 0.6679, 0.1667]}, {"w": "ML", "b": [0.673, 0.1453, 0.7027, 0.1667]}, {"w": "algorithms", "b": [0.7078, 0.1453, 0.7981, 0.1667]}, {"w": "can", "b": [0.8032, 0.1453, 0.8326, 0.1667]}, {"w": "be", "b": [0.8377, 0.1453, 0.8571, 0.1667]}, {"w": "inspected", "b": [0.1429, 0.1643, 0.2223, 0.1857]}, {"w": "to", "b": [0.2296, 0.1643, 0.2466, 0.1857]}, {"w": "see", "b": [0.2539, 0.1643, 0.2793, 0.1857]}, {"w": "what", "b": [0.2866, 0.1643, 0.3271, 0.1857]}, {"w": "they", "b": [0.3344, 0.1643, 0.3703, 0.1857]}, {"w": "have", "b": [0.3777, 0.1643, 0.4161, 0.1857]}, {"w": "learned", "b": [0.4234, 0.1643, 0.4857, 0.1857]}, {"w": "(although", "b": [0.493, 0.1643, 0.5747, 0.1857]}, {"w": "for", "b": [0.582, 0.1643, 0.6065, 0.1857]}, {"w": "some", "b": [0.6138, 0.1643, 0.658, 0.1857]}, {"w": "algorithms", "b": [0.6654, 0.1643, 0.7557, 0.1857]}, {"w": "this", "b": [0.763, 0.1643, 0.7937, 0.1857]}, {"w": "can", "b": [0.801, 0.1643, 0.8304, 0.1857]}, {"w": "be", "b": [0.8377, 0.1643, 0.8571, 0.1857]}, {"w": "tricky).", "b": [0.1429, 0.1834, 0.2032, 0.2048]}, {"w": "For", "b": [0.2101, 0.1834, 0.2391, 0.2048]}, {"w": "instance,", "b": [0.246, 0.1834, 0.32, 0.2048]}, {"w": "once", "b": [0.3269, 0.1834, 0.3666, 0.2048]}, {"w": "the", "b": [0.3735, 0.1834, 0.3998, 0.2048]}, {"w": "spam", "b": [0.4068, 0.1834, 0.4515, 0.2048]}, {"w": "filter", "b": [0.4585, 0.1834, 0.4984, 0.2048]}, {"w": "has", "b": [0.5053, 0.1834, 0.5333, 0.2048]}, {"w": "been", "b": [0.5402, 0.1834, 0.5799, 0.2048]}, {"w": "trained", "b": [0.5868, 0.1834, 0.6469, 0.2048]}, {"w": "on", "b": [0.6538, 0.1834, 0.6758, 0.2048]}, {"w": "enough", "b": [0.6827, 0.1834, 0.7456, 0.2048]}, {"w": "spam,", "b": [0.7525, 0.1834, 0.802, 0.2048]}, {"w": "it", "b": [0.8089, 0.1834, 0.8209, 0.2048]}, {"w": "can", "b": [0.8278, 0.1834, 0.8571, 0.2048]}, {"w": "easily", "b": [0.1429, 0.2024, 0.1889, 0.2238]}, {"w": "be", "b": [0.1979, 0.2024, 0.2173, 0.2238]}, {"w": "inspected", "b": [0.2262, 0.2024, 0.3056, 0.2238]}, {"w": "to", "b": [0.3146, 0.2024, 0.3316, 0.2238]}, {"w": "reveal", "b": [0.3405, 0.2024, 0.39, 0.2238]}, {"w": "the", "b": [0.3989, 0.2024, 0.4253, 0.2238]}, {"w": "list", "b": [0.4342, 0.2024, 0.459, 0.2238]}, {"w": "of", "b": [0.468, 0.2024, 0.4848, 0.2238]}, {"w": "words", "b": [0.4937, 0.2024, 0.545, 0.2238]}, {"w": "and", "b": [0.5539, 0.2024, 0.5855, 0.2238]}, {"w": "combinations", "b": [0.5944, 0.2024, 0.7088, 0.2238]}, {"w": "of", "b": [0.7177, 0.2024, 0.7345, 0.2238]}, {"w": "words", "b": [0.7435, 0.2024, 0.7947, 0.2238]}, {"w": "that", "b": [0.8037, 0.2024, 0.8363, 0.2238]}, {"w": "it", "b": [0.8452, 0.2024, 0.8571, 0.2238]}, {"w": "believes", "b": [0.1429, 0.2215, 0.2082, 0.2429]}, {"w": "are", "b": [0.2141, 0.2215, 0.2398, 0.2429]}, {"w": "the", "b": [0.2458, 0.2215, 0.2721, 0.2429]}, {"w": "best", "b": [0.278, 0.2215, 0.3115, 0.2429]}, {"w": "predictors", "b": [0.3174, 0.2215, 0.4026, 0.2429]}, {"w": "of", "b": [0.4086, 0.2215, 0.4254, 0.2429]}, {"w": "spam.", "b": [0.4313, 0.2215, 0.4808, 0.2429]}, {"w": "Sometimes", "b": [0.4868, 0.2215, 0.5787, 0.2429]}, {"w": "this", "b": [0.5846, 0.2215, 0.6153, 0.2429]}, {"w": "will", "b": [0.6213, 0.2215, 0.6517, 0.2429]}, {"w": "reveal", "b": [0.6576, 0.2215, 0.7071, 0.2429]}, {"w": "unsuspected", "b": [0.713, 0.2215, 0.8166, 0.2429]}, {"w": "cor‐", "b": [0.8226, 0.2215, 0.8572, 0.2429]}, {"w": "relations", "b": [0.1429, 0.2405, 0.2151, 0.2619]}, {"w": "or", "b": [0.2198, 0.2405, 0.2382, 0.2619]}, {"w": "new", "b": [0.2429, 0.2405, 0.2774, 0.2619]}, {"w": "trends,", "b": [0.2821, 0.2405, 0.3399, 0.2619]}, {"w": "and", "b": [0.3446, 0.2405, 0.3761, 0.2619]}, {"w": "thereby", "b": [0.3809, 0.2405, 0.4439, 0.2619]}, {"w": "lead", "b": [0.4487, 0.2405, 0.4829, 0.2619]}, {"w": "to", "b": [0.4877, 0.2405, 0.5046, 0.2619]}, {"w": "a", "b": [0.5094, 0.2405, 0.5185, 0.2619]}, {"w": "better", "b": [0.5232, 0.2405, 0.572, 0.2619]}, {"w": "understanding", "b": [0.5767, 0.2405, 0.699, 0.2619]}, {"w": "of", "b": [0.7037, 0.2405, 0.7205, 0.2619]}, {"w": "the", "b": [0.7253, 0.2405, 0.7516, 0.2619]}, {"w": "problem.", "b": [0.7563, 0.2405, 0.8321, 0.2619]}]}, {"id": "b_2", "type": "paragraph", "text": "Applying ML techniques to dig into large amounts of data can help discover patterns that were not immediately apparent. This is called data mining.", "words": [{"w": "Applying", "b": [0.1429, 0.2686, 0.2198, 0.29]}, {"w": "ML", "b": [0.2253, 0.2686, 0.2551, 0.29]}, {"w": "techniques", "b": [0.2605, 0.2686, 0.3509, 0.29]}, {"w": "to", "b": [0.3563, 0.2686, 0.3733, 0.29]}, {"w": "dig", "b": [0.3788, 0.2686, 0.4051, 0.29]}, {"w": "into", "b": [0.4106, 0.2686, 0.4442, 0.29]}, {"w": "large", "b": [0.4497, 0.2686, 0.4904, 0.29]}, {"w": "amounts", "b": [0.4959, 0.2686, 0.5688, 0.29]}, {"w": "of", "b": [0.5743, 0.2686, 0.5911, 0.29]}, {"w": "data", "b": [0.5966, 0.2686, 0.6318, 0.29]}, {"w": "can", "b": [0.6373, 0.2686, 0.6666, 0.29]}, {"w": "help", "b": [0.6721, 0.2686, 0.7083, 0.29]}, {"w": "discover", "b": [0.7138, 0.2686, 0.7837, 0.29]}, {"w": "patterns", "b": [0.7891, 0.2686, 0.8571, 0.29]}, {"w": "that", "b": [0.1429, 0.2877, 0.1754, 0.3091]}, {"w": "were", "b": [0.1802, 0.2877, 0.2199, 0.3091]}, {"w": "not", "b": [0.2246, 0.2877, 0.253, 0.3091]}, {"w": "immediately", "b": [0.2577, 0.2877, 0.3616, 0.3091]}, {"w": "apparent.", "b": [0.3664, 0.2877, 0.4448, 0.3091]}, {"w": "This", "b": [0.4495, 0.2877, 0.4867, 0.3091]}, {"w": "is", "b": [0.4915, 0.2877, 0.5047, 0.3091]}, {"w": "called", "b": [0.5094, 0.2877, 0.5578, 0.3091]}, {"w": "data", "b": [0.5625, 0.2875, 0.5991, 0.3091]}, {"w": "mining.", "b": [0.6039, 0.2875, 0.6658, 0.3091]}]}, {"id": "b_3", "type": "equation", "text": "Figure 1-4. Machine Learning can help humans learn", "words": [{"w": "Figure", "b": [0.1429, 0.5622, 0.1943, 0.5838]}, {"w": "1-4.", "b": [0.1991, 0.5622, 0.2308, 0.5838]}, {"w": "Machine", "b": [0.2356, 0.5622, 0.3059, 0.5838]}, {"w": "Learning", "b": [0.3107, 0.5622, 0.3835, 0.5838]}, {"w": "can", "b": [0.3882, 0.5622, 0.417, 0.5838]}, {"w": "help", "b": [0.4218, 0.5622, 0.4554, 0.5838]}, {"w": "humans", "b": [0.4601, 0.5622, 0.5255, 0.5838]}, {"w": "learn", "b": [0.5303, 0.5622, 0.5724, 0.5838]}]}, {"id": "b_4", "type": "paragraph", "text": "To summarize, Machine Learning is great for:", "words": [{"w": "To", "b": [0.1429, 0.5996, 0.1643, 0.621]}, {"w": "summarize,", "b": [0.169, 0.5996, 0.2667, 0.621]}, {"w": "Machine", "b": [0.2714, 0.5996, 0.3445, 0.621]}, {"w": "Learning", "b": [0.3492, 0.5996, 0.4243, 0.621]}, {"w": "is", "b": [0.429, 0.5996, 0.4423, 0.621]}, {"w": "great", "b": [0.447, 0.5996, 0.4884, 0.621]}, {"w": "for:", "b": [0.4932, 0.5996, 0.5229, 0.621]}]}, {"id": "b_5", "type": "paragraph", "text": "• Problems for which existing solutions require a lot of hand-tuning or long lists of rules: one Machine Learning algorithm can often simplify code and perform bet‐ ter.", "words": [{"w": "•", "b": [0.16, 0.6337, 0.1682, 0.6551]}, {"w": "Problems", "b": [0.1786, 0.6337, 0.2581, 0.6551]}, {"w": "for", "b": [0.2629, 0.6337, 0.2875, 0.6551]}, {"w": "which", "b": [0.2924, 0.6337, 0.3433, 0.6551]}, {"w": "existing", "b": [0.3481, 0.6337, 0.4131, 0.6551]}, {"w": "solutions", "b": [0.418, 0.6337, 0.4942, 0.6551]}, {"w": "require", "b": [0.4991, 0.6337, 0.5596, 0.6551]}, {"w": "a", "b": [0.5645, 0.6337, 0.5736, 0.6551]}, {"w": "lot", "b": [0.5785, 0.6337, 0.6007, 0.6551]}, {"w": "of", "b": [0.6056, 0.6337, 0.6224, 0.6551]}, {"w": "hand-tuning", "b": [0.6273, 0.6337, 0.7329, 0.6551]}, {"w": "or", "b": [0.7378, 0.6337, 0.7562, 0.6551]}, {"w": "long", "b": [0.761, 0.6337, 0.7981, 0.6551]}, {"w": "lists", "b": [0.803, 0.6337, 0.8355, 0.6551]}, {"w": "of", "b": [0.8403, 0.6337, 0.8571, 0.6551]}, {"w": "rules:", "b": [0.1786, 0.6528, 0.2239, 0.6742]}, {"w": "one", "b": [0.2292, 0.6528, 0.26, 0.6742]}, {"w": "Machine", "b": [0.2653, 0.6528, 0.3384, 0.6742]}, {"w": "Learning", "b": [0.3437, 0.6528, 0.4187, 0.6742]}, {"w": "algorithm", "b": [0.424, 0.6528, 0.5067, 0.6742]}, {"w": "can", "b": [0.5119, 0.6528, 0.5413, 0.6742]}, {"w": "often", "b": [0.5465, 0.6528, 0.5899, 0.6742]}, {"w": "simplify", "b": [0.5952, 0.6528, 0.663, 0.6742]}, {"w": "code", "b": [0.6682, 0.6528, 0.7075, 0.6742]}, {"w": "and", "b": [0.7128, 0.6528, 0.7443, 0.6742]}, {"w": "perform", "b": [0.7496, 0.6528, 0.8187, 0.6742]}, {"w": "bet‐", "b": [0.8239, 0.6528, 0.8571, 0.6742]}, {"w": "ter.", "b": [0.1786, 0.6718, 0.2049, 0.6932]}]}, {"id": "b_6", "type": "paragraph", "text": "• Complex problems for which there is no good solution at all using a traditional approach: the best Machine Learning techniques can find a solution.", "words": [{"w": "•", "b": [0.16, 0.6969, 0.1682, 0.7183]}, {"w": "Complex", "b": [0.1786, 0.6969, 0.2546, 0.7183]}, {"w": "problems", "b": [0.2609, 0.6969, 0.3396, 0.7183]}, {"w": "for", "b": [0.3459, 0.6969, 0.3704, 0.7183]}, {"w": "which", "b": [0.3767, 0.6969, 0.4277, 0.7183]}, {"w": "there", "b": [0.434, 0.6969, 0.4769, 0.7183]}, {"w": "is", "b": [0.4832, 0.6969, 0.4964, 0.7183]}, {"w": "no", "b": [0.5028, 0.6969, 0.5248, 0.7183]}, {"w": "good", "b": [0.5311, 0.6969, 0.5731, 0.7183]}, {"w": "solution", "b": [0.5794, 0.6969, 0.648, 0.7183]}, {"w": "at", "b": [0.6543, 0.6969, 0.6694, 0.7183]}, {"w": "all", "b": [0.6757, 0.6969, 0.6954, 0.7183]}, {"w": "using", "b": [0.7017, 0.6969, 0.7472, 0.7183]}, {"w": "a", "b": [0.7535, 0.6969, 0.7626, 0.7183]}, {"w": "traditional", "b": [0.7689, 0.6969, 0.8571, 0.7183]}, {"w": "approach:", "b": [0.1786, 0.716, 0.2613, 0.7374]}, {"w": "the", "b": [0.2661, 0.716, 0.2924, 0.7374]}, {"w": "best", "b": [0.2971, 0.716, 0.3306, 0.7374]}, {"w": "Machine", "b": [0.3353, 0.716, 0.4084, 0.7374]}, {"w": "Learning", "b": [0.4132, 0.716, 0.4882, 0.7374]}, {"w": "techniques", "b": [0.4929, 0.716, 0.5833, 0.7374]}, {"w": "can", "b": [0.588, 0.716, 0.6174, 0.7374]}, {"w": "find", "b": [0.6221, 0.716, 0.6562, 0.7374]}, {"w": "a", "b": [0.661, 0.716, 0.6701, 0.7374]}, {"w": "solution.", "b": [0.6748, 0.716, 0.7482, 0.7374]}]}, {"id": "b_7", "type": "paragraph", "text": "• Fluctuating environments: a Machine Learning system can adapt to new data.", "words": [{"w": "•", "b": [0.16, 0.7411, 0.1682, 0.7625]}, {"w": "Fluctuating", "b": [0.1786, 0.7411, 0.274, 0.7625]}, {"w": "environments:", "b": [0.2787, 0.7411, 0.3991, 0.7625]}, {"w": "a", "b": [0.4039, 0.7411, 0.413, 0.7625]}, {"w": "Machine", "b": [0.4177, 0.7411, 0.4909, 0.7625]}, {"w": "Learning", "b": [0.4956, 0.7411, 0.5706, 0.7625]}, {"w": "system", "b": [0.5754, 0.7411, 0.6325, 0.7625]}, {"w": "can", "b": [0.6372, 0.7411, 0.6666, 0.7625]}, {"w": "adapt", "b": [0.6713, 0.7411, 0.7175, 0.7625]}, {"w": "to", "b": [0.7222, 0.7411, 0.7392, 0.7625]}, {"w": "new", "b": [0.7439, 0.7411, 0.7784, 0.7625]}, {"w": "data.", "b": [0.7832, 0.7411, 0.8232, 0.7625]}]}, {"id": "b_8", "type": "paragraph", "text": "• Getting insights about complex problems and large amounts of data.", "words": [{"w": "•", "b": [0.16, 0.7661, 0.1682, 0.7876]}, {"w": "Getting", "b": [0.1786, 0.7661, 0.2418, 0.7876]}, {"w": "insights", "b": [0.2465, 0.7661, 0.3112, 0.7876]}, {"w": "about", "b": [0.3159, 0.7661, 0.3637, 0.7876]}, {"w": "complex", "b": [0.3684, 0.7661, 0.4394, 0.7876]}, {"w": "problems", "b": [0.4441, 0.7661, 0.5228, 0.7876]}, {"w": "and", "b": [0.5275, 0.7661, 0.5591, 0.7876]}, {"w": "large", "b": [0.5638, 0.7661, 0.6045, 0.7876]}, {"w": "amounts", "b": [0.6093, 0.7661, 0.6822, 0.7876]}, {"w": "of", "b": [0.6869, 0.7661, 0.7037, 0.7876]}, {"w": "data.", "b": [0.7084, 0.7661, 0.7484, 0.7876]}]}, {"id": "b_9", "type": "paragraph", "text": "Why Use Machine Learning? | 7", "words": [{"w": "Why", "b": [0.6466, 0.9225, 0.6729, 0.9388]}, {"w": "Use", "b": [0.6757, 0.9225, 0.6968, 0.9388]}, {"w": "Machine", "b": [0.6996, 0.9225, 0.7496, 0.9388]}, {"w": "Learning?", "b": [0.7524, 0.9225, 0.8104, 0.9388]}, {"w": "|", "b": [0.8282, 0.9225, 0.832, 0.9388]}, {"w": "7", "b": [0.8498, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 34, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Types of Machine Learning Systems", "words": [{"w": "Types", "b": [0.1429, 0.0753, 0.2132, 0.1095]}, {"w": "of", "b": [0.2191, 0.0753, 0.2443, 0.1095]}, {"w": "Machine", "b": [0.2502, 0.0753, 0.3551, 0.1095]}, {"w": "Learning", "b": [0.3611, 0.0753, 0.4709, 0.1095]}, {"w": "Systems", "b": [0.4768, 0.0753, 0.5781, 0.1095]}]}, {"id": "b_1", "type": "paragraph", "text": "There are so many different types of Machine Learning systems that it is useful to classify them in broad categories based on:", "words": [{"w": "There", "b": [0.1429, 0.1164, 0.1923, 0.1378]}, {"w": "are", "b": [0.1998, 0.1164, 0.2255, 0.1378]}, {"w": "so", "b": [0.233, 0.1164, 0.2512, 0.1378]}, {"w": "many", "b": [0.2587, 0.1164, 0.3054, 0.1378]}, {"w": "different", "b": [0.3129, 0.1164, 0.3846, 0.1378]}, {"w": "types", "b": [0.392, 0.1164, 0.4354, 0.1378]}, {"w": "of", "b": [0.4428, 0.1164, 0.4596, 0.1378]}, {"w": "Machine", "b": [0.4671, 0.1164, 0.5402, 0.1378]}, {"w": "Learning", "b": [0.5477, 0.1164, 0.6228, 0.1378]}, {"w": "systems", "b": [0.6302, 0.1164, 0.695, 0.1378]}, {"w": "that", "b": [0.7025, 0.1164, 0.7351, 0.1378]}, {"w": "it", "b": [0.7425, 0.1164, 0.7545, 0.1378]}, {"w": "is", "b": [0.7619, 0.1164, 0.7752, 0.1378]}, {"w": "useful", "b": [0.7826, 0.1164, 0.8327, 0.1378]}, {"w": "to", "b": [0.8402, 0.1164, 0.8571, 0.1378]}, {"w": "classify", "b": [0.1429, 0.1355, 0.203, 0.1569]}, {"w": "them", "b": [0.2078, 0.1355, 0.2512, 0.1569]}, {"w": "in", "b": [0.2559, 0.1355, 0.2729, 0.1569]}, {"w": "broad", "b": [0.2776, 0.1355, 0.3267, 0.1569]}, {"w": "categories", "b": [0.3314, 0.1355, 0.4144, 0.1569]}, {"w": "based", "b": [0.4191, 0.1355, 0.4663, 0.1569]}, {"w": "on:", "b": [0.4711, 0.1355, 0.4978, 0.1569]}]}, {"id": "b_2", "type": "paragraph", "text": "• Whether or not they are trained with human supervision (supervised, unsuper‐ vised, semisupervised, and Reinforcement Learning)", "words": [{"w": "•", "b": [0.16, 0.1696, 0.1682, 0.1911]}, {"w": "Whether", "b": [0.1786, 0.1696, 0.2528, 0.1911]}, {"w": "or", "b": [0.2593, 0.1696, 0.2776, 0.1911]}, {"w": "not", "b": [0.284, 0.1696, 0.3124, 0.1911]}, {"w": "they", "b": [0.3188, 0.1696, 0.3547, 0.1911]}, {"w": "are", "b": [0.3612, 0.1696, 0.3869, 0.1911]}, {"w": "trained", "b": [0.3933, 0.1696, 0.4534, 0.1911]}, {"w": "with", "b": [0.4598, 0.1696, 0.4972, 0.1911]}, {"w": "human", "b": [0.5036, 0.1696, 0.563, 0.1911]}, {"w": "supervision", "b": [0.5694, 0.1696, 0.6667, 0.1911]}, {"w": "(supervised,", "b": [0.6731, 0.1696, 0.7746, 0.1911]}, {"w": "unsuper‐", "b": [0.7811, 0.1696, 0.8571, 0.1911]}, {"w": "vised,", "b": [0.1786, 0.1887, 0.2261, 0.2101]}, {"w": "semisupervised,", "b": [0.2308, 0.1887, 0.3642, 0.2101]}, {"w": "and", "b": [0.3689, 0.1887, 0.4005, 0.2101]}, {"w": "Reinforcement", "b": [0.4052, 0.1887, 0.5294, 0.2101]}, {"w": "Learning)", "b": [0.5342, 0.1887, 0.6164, 0.2101]}]}, {"id": "b_3", "type": "paragraph", "text": "• Whether or not they can learn incrementally on the fly (online versus batch learning)", "words": [{"w": "•", "b": [0.16, 0.2138, 0.1682, 0.2352]}, {"w": "Whether", "b": [0.1786, 0.2138, 0.2528, 0.2352]}, {"w": "or", "b": [0.2618, 0.2138, 0.2801, 0.2352]}, {"w": "not", "b": [0.289, 0.2138, 0.3174, 0.2352]}, {"w": "they", "b": [0.3263, 0.2138, 0.3622, 0.2352]}, {"w": "can", "b": [0.3712, 0.2138, 0.4005, 0.2352]}, {"w": "learn", "b": [0.4095, 0.2138, 0.4519, 0.2352]}, {"w": "incrementally", "b": [0.4608, 0.2138, 0.5757, 0.2352]}, {"w": "on", "b": [0.5846, 0.2138, 0.6066, 0.2352]}, {"w": "the", "b": [0.6156, 0.2138, 0.6419, 0.2352]}, {"w": "fly", "b": [0.6508, 0.2138, 0.6718, 0.2352]}, {"w": "(online", "b": [0.6807, 0.2138, 0.7411, 0.2352]}, {"w": "versus", "b": [0.75, 0.2138, 0.8026, 0.2352]}, {"w": "batch", "b": [0.8115, 0.2138, 0.8571, 0.2352]}, {"w": "learning)", "b": [0.1786, 0.2328, 0.2549, 0.2543]}]}, {"id": "b_4", "type": "paragraph", "text": "• Whether they work by simply comparing new data points to known data points, or instead detect patterns in the training data and build a predictive model, much like scientists do (instance-based versus model-based learning)", "words": [{"w": "•", "b": [0.16, 0.2579, 0.1682, 0.2793]}, {"w": "Whether", "b": [0.1786, 0.2579, 0.2528, 0.2793]}, {"w": "they", "b": [0.2587, 0.2579, 0.2946, 0.2793]}, {"w": "work", "b": [0.3004, 0.2579, 0.3434, 0.2793]}, {"w": "by", "b": [0.3492, 0.2579, 0.3693, 0.2793]}, {"w": "simply", "b": [0.3752, 0.2579, 0.4308, 0.2793]}, {"w": "comparing", "b": [0.4367, 0.2579, 0.5273, 0.2793]}, {"w": "new", "b": [0.5331, 0.2579, 0.5676, 0.2793]}, {"w": "data", "b": [0.5735, 0.2579, 0.6087, 0.2793]}, {"w": "points", "b": [0.6146, 0.2579, 0.6667, 0.2793]}, {"w": "to", "b": [0.6725, 0.2579, 0.6895, 0.2793]}, {"w": "known", "b": [0.6953, 0.2579, 0.7533, 0.2793]}, {"w": "data", "b": [0.7592, 0.2579, 0.7944, 0.2793]}, {"w": "points,", "b": [0.8003, 0.2579, 0.8571, 0.2793]}, {"w": "or", "b": [0.1786, 0.277, 0.1969, 0.2984]}, {"w": "instead", "b": [0.2018, 0.277, 0.2618, 0.2984]}, {"w": "detect", "b": [0.2667, 0.277, 0.3169, 0.2984]}, {"w": "patterns", "b": [0.3219, 0.277, 0.3899, 0.2984]}, {"w": "in", "b": [0.3948, 0.277, 0.4117, 0.2984]}, {"w": "the", "b": [0.4166, 0.277, 0.443, 0.2984]}, {"w": "training", "b": [0.4479, 0.277, 0.5148, 0.2984]}, {"w": "data", "b": [0.5197, 0.277, 0.555, 0.2984]}, {"w": "and", "b": [0.5599, 0.277, 0.5914, 0.2984]}, {"w": "build", "b": [0.5963, 0.277, 0.6398, 0.2984]}, {"w": "a", "b": [0.6447, 0.277, 0.6539, 0.2984]}, {"w": "predictive", "b": [0.6588, 0.277, 0.7421, 0.2984]}, {"w": "model,", "b": [0.747, 0.277, 0.8046, 0.2984]}, {"w": "much", "b": [0.8095, 0.277, 0.8571, 0.2984]}, {"w": "like", "b": [0.1786, 0.296, 0.2086, 0.3174]}, {"w": "scientists", "b": [0.2133, 0.296, 0.2888, 0.3174]}, {"w": "do", "b": [0.2935, 0.296, 0.3152, 0.3174]}, {"w": "(instance-based", "b": [0.3199, 0.296, 0.4509, 0.3174]}, {"w": "versus", "b": [0.4557, 0.296, 0.5083, 0.3174]}, {"w": "model-based", "b": [0.513, 0.296, 0.6204, 0.3174]}, {"w": "learning)", "b": [0.6252, 0.296, 0.7015, 0.3174]}]}, {"id": "b_5", "type": "paragraph", "text": "These criteria are not exclusive; you can combine them in any way you like. For example, a state-of-the-art spam filter may learn on the fly using a deep neural net‐ work model trained using examples of spam and ham; this makes it an online, model- based, supervised learning system.", "words": [{"w": "These", "b": [0.1429, 0.3302, 0.1922, 0.3516]}, {"w": "criteria", "b": [0.2007, 0.3302, 0.2605, 0.3516]}, {"w": "are", "b": [0.2691, 0.3302, 0.2948, 0.3516]}, {"w": "not", "b": [0.3033, 0.3302, 0.3317, 0.3516]}, {"w": "exclusive;", "b": [0.3403, 0.3302, 0.4206, 0.3516]}, {"w": "you", "b": [0.4291, 0.3302, 0.4604, 0.3516]}, {"w": "can", "b": [0.4689, 0.3302, 0.4983, 0.3516]}, {"w": "combine", "b": [0.5068, 0.3302, 0.5797, 0.3516]}, {"w": "them", "b": [0.5883, 0.3302, 0.6317, 0.3516]}, {"w": "in", "b": [0.6402, 0.3302, 0.6572, 0.3516]}, {"w": "any", "b": [0.6657, 0.3302, 0.6953, 0.3516]}, {"w": "way", "b": [0.7039, 0.3302, 0.7365, 0.3516]}, {"w": "you", "b": [0.745, 0.3302, 0.7763, 0.3516]}, {"w": "like.", "b": [0.7848, 0.3302, 0.8196, 0.3516]}, {"w": "For", "b": [0.8282, 0.3302, 0.8571, 0.3516]}, {"w": "example,", "b": [0.1428, 0.3492, 0.2171, 0.3707]}, {"w": "a", "b": [0.2236, 0.3492, 0.2328, 0.3707]}, {"w": "state-of-the-art", "b": [0.2392, 0.3492, 0.3658, 0.3707]}, {"w": "spam", "b": [0.3723, 0.3492, 0.4171, 0.3707]}, {"w": "filter", "b": [0.4235, 0.3492, 0.4635, 0.3707]}, {"w": "may", "b": [0.47, 0.3492, 0.5054, 0.3707]}, {"w": "learn", "b": [0.5119, 0.3492, 0.5543, 0.3707]}, {"w": "on", "b": [0.5607, 0.3492, 0.5828, 0.3707]}, {"w": "the", "b": [0.5892, 0.3492, 0.6156, 0.3707]}, {"w": "fly", "b": [0.622, 0.3492, 0.643, 0.3707]}, {"w": "using", "b": [0.6495, 0.3492, 0.695, 0.3707]}, {"w": "a", "b": [0.7014, 0.3492, 0.7106, 0.3707]}, {"w": "deep", "b": [0.7171, 0.3492, 0.7567, 0.3707]}, {"w": "neural", "b": [0.7632, 0.3492, 0.8166, 0.3707]}, {"w": "net‐", "b": [0.8231, 0.3492, 0.8571, 0.3707]}, {"w": "work", "b": [0.1429, 0.3683, 0.1858, 0.3897]}, {"w": "model", "b": [0.1906, 0.3683, 0.2434, 0.3897]}, {"w": "trained", "b": [0.2481, 0.3683, 0.3082, 0.3897]}, {"w": "using", "b": [0.3129, 0.3683, 0.3583, 0.3897]}, {"w": "examples", "b": [0.3631, 0.3683, 0.4402, 0.3897]}, {"w": "of", "b": [0.445, 0.3683, 0.4618, 0.3897]}, {"w": "spam", "b": [0.4665, 0.3683, 0.5113, 0.3897]}, {"w": "and", "b": [0.516, 0.3683, 0.5475, 0.3897]}, {"w": "ham;", "b": [0.5523, 0.3683, 0.5943, 0.3897]}, {"w": "this", "b": [0.5991, 0.3683, 0.6298, 0.3897]}, {"w": "makes", "b": [0.6345, 0.3683, 0.6876, 0.3897]}, {"w": "it", "b": [0.6923, 0.3683, 0.7042, 0.3897]}, {"w": "an", "b": [0.7089, 0.3683, 0.7295, 0.3897]}, {"w": "online,", "b": [0.7342, 0.3683, 0.7921, 0.3897]}, {"w": "model-", "b": [0.7968, 0.3683, 0.8571, 0.3897]}, {"w": "based,", "b": [0.1429, 0.3873, 0.1948, 0.4087]}, {"w": "supervised", "b": [0.1996, 0.3873, 0.2891, 0.4087]}, {"w": "learning", "b": [0.2938, 0.3873, 0.363, 0.4087]}, {"w": "system.", "b": [0.3677, 0.3873, 0.4296, 0.4087]}]}, {"id": "b_6", "type": "paragraph", "text": "Let’s look at each of these criteria a bit more closely.", "words": [{"w": "Let’s", "b": [0.1429, 0.4155, 0.179, 0.4369]}, {"w": "look", "b": [0.1838, 0.4155, 0.2206, 0.4369]}, {"w": "at", "b": [0.2253, 0.4155, 0.2404, 0.4369]}, {"w": "each", "b": [0.2452, 0.4155, 0.2831, 0.4369]}, {"w": "of", "b": [0.2878, 0.4155, 0.3046, 0.4369]}, {"w": "these", "b": [0.3094, 0.4155, 0.3522, 0.4369]}, {"w": "criteria", "b": [0.3569, 0.4155, 0.4167, 0.4369]}, {"w": "a", "b": [0.4214, 0.4155, 0.4306, 0.4369]}, {"w": "bit", "b": [0.4353, 0.4155, 0.4578, 0.4369]}, {"w": "more", "b": [0.4626, 0.4155, 0.5068, 0.4369]}, {"w": "closely.", "b": [0.5116, 0.4155, 0.5708, 0.4369]}]}, {"id": "b_7", "type": "equation", "text": "Supervised/Unsupervised Learning", "words": [{"w": "Supervised/Unsupervised", "b": [0.1429, 0.4496, 0.4036, 0.4782]}, {"w": "Learning", "b": [0.4086, 0.4496, 0.5001, 0.4782]}]}, {"id": "b_8", "type": "paragraph", "text": "Machine Learning systems can be classified according to the amount and type of supervision they get during training. There are four major categories: supervised learning, unsupervised learning, semisupervised learning, and Reinforcement Learn‐ ing.", "words": [{"w": "Machine", "b": [0.1429, 0.4841, 0.216, 0.5055]}, {"w": "Learning", "b": [0.2244, 0.4841, 0.2995, 0.5055]}, {"w": "systems", "b": [0.308, 0.4841, 0.3727, 0.5055]}, {"w": "can", "b": [0.3812, 0.4841, 0.4105, 0.5055]}, {"w": "be", "b": [0.419, 0.4841, 0.4384, 0.5055]}, {"w": "classified", "b": [0.4469, 0.4841, 0.5226, 0.5055]}, {"w": "according", "b": [0.531, 0.4841, 0.6139, 0.5055]}, {"w": "to", "b": [0.6223, 0.4841, 0.6393, 0.5055]}, {"w": "the", "b": [0.6478, 0.4841, 0.6741, 0.5055]}, {"w": "amount", "b": [0.6825, 0.4841, 0.7478, 0.5055]}, {"w": "and", "b": [0.7562, 0.4841, 0.7878, 0.5055]}, {"w": "type", "b": [0.7962, 0.4841, 0.8319, 0.5055]}, {"w": "of", "b": [0.8404, 0.4841, 0.8572, 0.5055]}, {"w": "supervision", "b": [0.1429, 0.5031, 0.2402, 0.5246]}, {"w": "they", "b": [0.2492, 0.5031, 0.2851, 0.5246]}, {"w": "get", "b": [0.2941, 0.5031, 0.3191, 0.5246]}, {"w": "during", "b": [0.3281, 0.5031, 0.3847, 0.5246]}, {"w": "training.", "b": [0.3937, 0.5031, 0.4654, 0.5246]}, {"w": "There", "b": [0.4744, 0.5031, 0.5239, 0.5246]}, {"w": "are", "b": [0.5329, 0.5031, 0.5586, 0.5246]}, {"w": "four", "b": [0.5677, 0.5031, 0.6033, 0.5246]}, {"w": "major", "b": [0.6123, 0.5031, 0.6618, 0.5246]}, {"w": "categories:", "b": [0.6709, 0.5031, 0.7586, 0.5246]}, {"w": "supervised", "b": [0.7676, 0.5031, 0.8571, 0.5246]}, {"w": "learning,", "b": [0.1429, 0.5222, 0.2167, 0.5436]}, {"w": "unsupervised", "b": [0.2225, 0.5222, 0.3345, 0.5436]}, {"w": "learning,", "b": [0.3403, 0.5222, 0.4142, 0.5436]}, {"w": "semisupervised", "b": [0.4199, 0.5222, 0.5486, 0.5436]}, {"w": "learning,", "b": [0.5544, 0.5222, 0.6283, 0.5436]}, {"w": "and", "b": [0.6341, 0.5222, 0.6656, 0.5436]}, {"w": "Reinforcement", "b": [0.6714, 0.5222, 0.7956, 0.5436]}, {"w": "Learn‐", "b": [0.8014, 0.5222, 0.8571, 0.5436]}, {"w": "ing.", "b": [0.1428, 0.5412, 0.1743, 0.5627]}]}, {"id": "b_9", "type": "paragraph", "text": "Supervised learning", "words": [{"w": "Supervised", "b": [0.1429, 0.5786, 0.2255, 0.5995]}, {"w": "learning", "b": [0.2292, 0.5786, 0.2927, 0.5995]}]}, {"id": "b_10", "type": "paragraph", "text": "In supervised learning, the training data you feed to the algorithm includes the desired solutions, called labels (Figure 1-5).", "words": [{"w": "In", "b": [0.1429, 0.6052, 0.1614, 0.6266]}, {"w": "supervised", "b": [0.1661, 0.605, 0.2515, 0.6266]}, {"w": "learning,", "b": [0.2562, 0.605, 0.3277, 0.6266]}, {"w": "the", "b": [0.3324, 0.6052, 0.3588, 0.6266]}, {"w": "training", "b": [0.3635, 0.6052, 0.4304, 0.6266]}, {"w": "data", "b": [0.4352, 0.6052, 0.4704, 0.6266]}, {"w": "you", "b": [0.4751, 0.6052, 0.5064, 0.6266]}, {"w": "feed", "b": [0.5111, 0.6052, 0.546, 0.6266]}, {"w": "to", "b": [0.5507, 0.6052, 0.5677, 0.6266]}, {"w": "the", "b": [0.5724, 0.6052, 0.5988, 0.6266]}, {"w": "algorithm", "b": [0.6035, 0.6052, 0.6861, 0.6266]}, {"w": "includes", "b": [0.6909, 0.6052, 0.7605, 0.6266]}, {"w": "the", "b": [0.7652, 0.6052, 0.7916, 0.6266]}, {"w": "desired", "b": [0.7963, 0.6052, 0.857, 0.6266]}, {"w": "solutions,", "b": [0.1429, 0.6242, 0.2238, 0.6456]}, {"w": "called", "b": [0.2285, 0.6242, 0.2769, 0.6456]}, {"w": "labels", "b": [0.2816, 0.624, 0.3268, 0.6456]}, {"w": "(Figure", "b": [0.3315, 0.6242, 0.3927, 0.6456]}, {"w": "1-5).", "b": [0.3975, 0.6242, 0.4369, 0.6456]}]}, {"id": "b_11", "type": "paragraph", "text": "Figure 1-5. A labeled training set for supervised learning (e.g., spam classification)", "words": [{"w": "Figure", "b": [0.1429, 0.842, 0.1943, 0.8636]}, {"w": "1-5.", "b": [0.1991, 0.842, 0.2308, 0.8636]}, {"w": "A", "b": [0.2356, 0.842, 0.2494, 0.8636]}, {"w": "labeled", "b": [0.2542, 0.842, 0.311, 0.8636]}, {"w": "training", "b": [0.3157, 0.842, 0.3802, 0.8636]}, {"w": "set", "b": [0.3849, 0.842, 0.4066, 0.8636]}, {"w": "for", "b": [0.4114, 0.842, 0.434, 0.8636]}, {"w": "supervised", "b": [0.4388, 0.842, 0.5241, 0.8636]}, {"w": "learning", "b": [0.5289, 0.842, 0.5956, 0.8636]}, {"w": "(e.g.,", "b": [0.6004, 0.842, 0.639, 0.8636]}, {"w": "spam", "b": [0.6438, 0.842, 0.687, 0.8636]}, {"w": "classification)", "b": [0.6917, 0.842, 0.8039, 0.8636]}]}, {"id": "b_12", "type": "paragraph", "text": "8 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "8", "b": [0.1429, 0.9225, 0.1501, 0.9388]}, {"w": "|", "b": [0.168, 0.9225, 0.1717, 0.9388]}, {"w": "Chapter", "b": [0.1896, 0.9225, 0.2359, 0.9388]}, {"w": "1:", "b": [0.2387, 0.9225, 0.2499, 0.9388]}, {"w": "The", "b": [0.2527, 0.9225, 0.2742, 0.9388]}, {"w": "Machine", "b": [0.277, 0.9225, 0.3269, 0.9388]}, {"w": "Learning", "b": [0.3298, 0.9225, 0.382, 0.9388]}, {"w": "Landscape", "b": [0.3848, 0.9225, 0.4465, 0.9388]}]}]}, {"page": 35, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 Fun fact: this odd-sounding name is a statistics term introduced by Francis Galton while he was studying the fact that the children of tall people tend to be shorter than their parents. Since children were shorter, he called this regression to the mean. This name was then applied to the methods he used to analyze correlations between variables.", "words": [{"w": "1", "b": [0.1451, 0.8311, 0.1518, 0.8453]}, {"w": "Fun", "b": [0.1587, 0.8296, 0.1839, 0.8459]}, {"w": "fact:", "b": [0.1875, 0.8296, 0.2144, 0.8459]}, {"w": "this", "b": [0.218, 0.8296, 0.2414, 0.8459]}, {"w": "odd-sounding", "b": [0.245, 0.8296, 0.3353, 0.8459]}, {"w": "name", "b": [0.3389, 0.8296, 0.3743, 0.8459]}, {"w": "is", "b": [0.3779, 0.8296, 0.3879, 0.8459]}, {"w": "a", "b": [0.3915, 0.8296, 0.3985, 0.8459]}, {"w": "statistics", "b": [0.4021, 0.8296, 0.456, 0.8459]}, {"w": "term", "b": [0.4596, 0.8296, 0.4901, 0.8459]}, {"w": "introduced", "b": [0.4937, 0.8296, 0.5638, 0.8459]}, {"w": "by", "b": [0.5674, 0.8296, 0.5827, 0.8459]}, {"w": "Francis", "b": [0.5863, 0.8296, 0.6331, 0.8459]}, {"w": "Galton", "b": [0.6367, 0.8296, 0.6806, 0.8459]}, {"w": "while", "b": [0.6842, 0.8296, 0.7186, 0.8459]}, {"w": "he", "b": [0.7222, 0.8296, 0.7374, 0.8459]}, {"w": "was", "b": [0.741, 0.8296, 0.7647, 0.8459]}, {"w": "studying", "b": [0.7683, 0.8296, 0.8234, 0.8459]}, {"w": "the", "b": [0.827, 0.8296, 0.8471, 0.8459]}, {"w": "fact", "b": [0.1587, 0.8447, 0.182, 0.861]}, {"w": "that", "b": [0.1856, 0.8447, 0.2104, 0.861]}, {"w": "the", "b": [0.214, 0.8447, 0.234, 0.861]}, {"w": "children", "b": [0.2377, 0.8447, 0.2908, 0.861]}, {"w": "of", "b": [0.2944, 0.8447, 0.3072, 0.861]}, {"w": "tall", "b": [0.3108, 0.8447, 0.3307, 0.861]}, {"w": "people", "b": [0.3343, 0.8447, 0.3765, 0.861]}, {"w": "tend", "b": [0.3801, 0.8447, 0.4087, 0.861]}, {"w": "to", "b": [0.4123, 0.8447, 0.4253, 0.861]}, {"w": "be", "b": [0.4289, 0.8447, 0.4437, 0.861]}, {"w": "shorter", "b": [0.4473, 0.8447, 0.4931, 0.861]}, {"w": "than", "b": [0.4967, 0.8447, 0.5256, 0.861]}, {"w": "their", "b": [0.5292, 0.8447, 0.5594, 0.861]}, {"w": "parents.", "b": [0.563, 0.8447, 0.6136, 0.861]}, {"w": "Since", "b": [0.6172, 0.8447, 0.6512, 0.861]}, {"w": "children", "b": [0.6548, 0.8447, 0.7079, 0.861]}, {"w": "were", "b": [0.7115, 0.8447, 0.7418, 0.861]}, {"w": "shorter,", "b": [0.7454, 0.8447, 0.7938, 0.861]}, {"w": "he", "b": [0.7974, 0.8447, 0.8126, 0.861]}, {"w": "called", "b": [0.8162, 0.8447, 0.853, 0.861]}, {"w": "this", "b": [0.1587, 0.8598, 0.1821, 0.8761]}, {"w": "regression", "b": [0.1857, 0.8596, 0.2463, 0.8761]}, {"w": "to", "b": [0.25, 0.8596, 0.2621, 0.8761]}, {"w": "the", "b": [0.2658, 0.8596, 0.2849, 0.8761]}, {"w": "mean.", "b": [0.2885, 0.8596, 0.3267, 0.8761]}, {"w": "This", "b": [0.3303, 0.8598, 0.3587, 0.8761]}, {"w": "name", "b": [0.3623, 0.8598, 0.3977, 0.8761]}, {"w": "was", "b": [0.4013, 0.8598, 0.4249, 0.8761]}, {"w": "then", "b": [0.4285, 0.8598, 0.4573, 0.8761]}, {"w": "applied", "b": [0.4609, 0.8598, 0.5076, 0.8761]}, {"w": "to", "b": [0.5112, 0.8598, 0.5241, 0.8761]}, {"w": "the", "b": [0.5277, 0.8598, 0.5478, 0.8761]}, {"w": "methods", "b": [0.5514, 0.8598, 0.6068, 0.8761]}, {"w": "he", "b": [0.6104, 0.8598, 0.6256, 0.8761]}, {"w": "used", "b": [0.6292, 0.8598, 0.6586, 0.8761]}, {"w": "to", "b": [0.6622, 0.8598, 0.6751, 0.8761]}, {"w": "analyze", "b": [0.6787, 0.8598, 0.726, 0.8761]}, {"w": "correlations", "b": [0.7297, 0.8598, 0.8054, 0.8761]}, {"w": "between", "b": [0.1587, 0.8749, 0.2114, 0.8912]}, {"w": "variables.", "b": [0.215, 0.8749, 0.2747, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "A typical supervised learning task is classification. The spam filter is a good example of this: it is trained with many example emails along with their class (spam or ham), and it must learn how to classify new emails.", "words": [{"w": "A", "b": [0.1429, 0.0791, 0.1573, 0.1005]}, {"w": "typical", "b": [0.1632, 0.0791, 0.2188, 0.1005]}, {"w": "supervised", "b": [0.2248, 0.0791, 0.3143, 0.1005]}, {"w": "learning", "b": [0.3203, 0.0791, 0.3894, 0.1005]}, {"w": "task", "b": [0.3954, 0.0791, 0.4288, 0.1005]}, {"w": "is", "b": [0.4348, 0.0791, 0.448, 0.1005]}, {"w": "classification.", "b": [0.454, 0.0789, 0.564, 0.1005]}, {"w": "The", "b": [0.57, 0.0791, 0.6028, 0.1005]}, {"w": "spam", "b": [0.6087, 0.0791, 0.6535, 0.1005]}, {"w": "filter", "b": [0.6595, 0.0791, 0.6994, 0.1005]}, {"w": "is", "b": [0.7054, 0.0791, 0.7186, 0.1005]}, {"w": "a", "b": [0.7246, 0.0791, 0.7337, 0.1005]}, {"w": "good", "b": [0.7396, 0.0791, 0.7816, 0.1005]}, {"w": "example", "b": [0.7876, 0.0791, 0.8571, 0.1005]}, {"w": "of", "b": [0.1428, 0.0981, 0.1596, 0.1195]}, {"w": "this:", "b": [0.1656, 0.0981, 0.2011, 0.1195]}, {"w": "it", "b": [0.2071, 0.0981, 0.219, 0.1195]}, {"w": "is", "b": [0.225, 0.0981, 0.2383, 0.1195]}, {"w": "trained", "b": [0.2443, 0.0981, 0.3043, 0.1195]}, {"w": "with", "b": [0.3103, 0.0981, 0.3477, 0.1195]}, {"w": "many", "b": [0.3537, 0.0981, 0.4004, 0.1195]}, {"w": "example", "b": [0.4064, 0.0981, 0.4759, 0.1195]}, {"w": "emails", "b": [0.4819, 0.0981, 0.5355, 0.1195]}, {"w": "along", "b": [0.5415, 0.0981, 0.5877, 0.1195]}, {"w": "with", "b": [0.5937, 0.0981, 0.631, 0.1195]}, {"w": "their", "b": [0.637, 0.0981, 0.6766, 0.1195]}, {"w": "class", "b": [0.6826, 0.0979, 0.7195, 0.1195]}, {"w": "(spam", "b": [0.7255, 0.0981, 0.7775, 0.1195]}, {"w": "or", "b": [0.7835, 0.0981, 0.8018, 0.1195]}, {"w": "ham),", "b": [0.8078, 0.0981, 0.8571, 0.1195]}, {"w": "and", "b": [0.1429, 0.1172, 0.1744, 0.1386]}, {"w": "it", "b": [0.1791, 0.1172, 0.1911, 0.1386]}, {"w": "must", "b": [0.1958, 0.1172, 0.2375, 0.1386]}, {"w": "learn", "b": [0.2423, 0.1172, 0.2847, 0.1386]}, {"w": "how", "b": [0.2894, 0.1172, 0.3254, 0.1386]}, {"w": "to", "b": [0.3301, 0.1172, 0.3471, 0.1386]}, {"w": "classify", "b": [0.3518, 0.1172, 0.412, 0.1386]}, {"w": "new", "b": [0.4168, 0.1172, 0.4513, 0.1386]}, {"w": "emails.", "b": [0.456, 0.1172, 0.5143, 0.1386]}]}, {"id": "b_2", "type": "paragraph", "text": "Another typical task is to predict a target numeric value, such as the price of a car, given a set of features (mileage, age, brand, etc.) called predictors. This sort of task is called regression (Figure 1-6).1 To train the system, you need to give it many examples of cars, including both their predictors and their labels (i.e., their prices).", "words": [{"w": "Another", "b": [0.1429, 0.1453, 0.2133, 0.1667]}, {"w": "typical", "b": [0.2203, 0.1453, 0.276, 0.1667]}, {"w": "task", "b": [0.2829, 0.1453, 0.3164, 0.1667]}, {"w": "is", "b": [0.3234, 0.1453, 0.3366, 0.1667]}, {"w": "to", "b": [0.3436, 0.1453, 0.3606, 0.1667]}, {"w": "predict", "b": [0.3676, 0.1453, 0.4268, 0.1667]}, {"w": "a", "b": [0.4338, 0.1453, 0.4429, 0.1667]}, {"w": "target", "b": [0.4499, 0.1451, 0.4968, 0.1667]}, {"w": "numeric", "b": [0.5038, 0.1453, 0.5739, 0.1667]}, {"w": "value,", "b": [0.5808, 0.1453, 0.6296, 0.1667]}, {"w": "such", "b": [0.6366, 0.1453, 0.6752, 0.1667]}, {"w": "as", "b": [0.6822, 0.1453, 0.699, 0.1667]}, {"w": "the", "b": [0.7059, 0.1453, 0.7323, 0.1667]}, {"w": "price", "b": [0.7393, 0.1453, 0.7812, 0.1667]}, {"w": "of", "b": [0.7881, 0.1453, 0.8049, 0.1667]}, {"w": "a", "b": [0.8119, 0.1453, 0.821, 0.1667]}, {"w": "car,", "b": [0.828, 0.1453, 0.8572, 0.1667]}, {"w": "given", "b": [0.1429, 0.1643, 0.1881, 0.1857]}, {"w": "a", "b": [0.1938, 0.1643, 0.203, 0.1857]}, {"w": "set", "b": [0.2087, 0.1643, 0.2316, 0.1857]}, {"w": "of", "b": [0.2373, 0.1643, 0.2541, 0.1857]}, {"w": "features", "b": [0.2599, 0.1641, 0.3227, 0.1857]}, {"w": "(mileage,", "b": [0.3285, 0.1643, 0.405, 0.1857]}, {"w": "age,", "b": [0.4107, 0.1643, 0.4432, 0.1857]}, {"w": "brand,", "b": [0.449, 0.1643, 0.5036, 0.1857]}, {"w": "etc.)", "b": [0.5093, 0.1643, 0.5453, 0.1857]}, {"w": "called", "b": [0.5511, 0.1643, 0.5994, 0.1857]}, {"w": "predictors.", "b": [0.6052, 0.1641, 0.6896, 0.1857]}, {"w": "This", "b": [0.6953, 0.1643, 0.7325, 0.1857]}, {"w": "sort", "b": [0.7383, 0.1643, 0.7706, 0.1857]}, {"w": "of", "b": [0.7764, 0.1643, 0.7932, 0.1857]}, {"w": "task", "b": [0.7989, 0.1643, 0.8324, 0.1857]}, {"w": "is", "b": [0.8382, 0.1643, 0.8514, 0.1857]}, {"w": "called", "b": [0.1429, 0.1834, 0.1912, 0.2048]}, {"w": "regression", "b": [0.1964, 0.1832, 0.2759, 0.2048]}, {"w": "(Figure", "b": [0.2811, 0.1834, 0.3423, 0.2048]}, {"w": "1-6).1", "b": [0.347, 0.1834, 0.3925, 0.2048]}, {"w": "To", "b": [0.3977, 0.1834, 0.4191, 0.2048]}, {"w": "train", "b": [0.4243, 0.1834, 0.4645, 0.2048]}, {"w": "the", "b": [0.4697, 0.1834, 0.496, 0.2048]}, {"w": "system,", "b": [0.5012, 0.1834, 0.563, 0.2048]}, {"w": "you", "b": [0.5682, 0.1834, 0.5995, 0.2048]}, {"w": "need", "b": [0.6046, 0.1834, 0.6447, 0.2048]}, {"w": "to", "b": [0.6499, 0.1834, 0.6669, 0.2048]}, {"w": "give", "b": [0.672, 0.1834, 0.7059, 0.2048]}, {"w": "it", "b": [0.711, 0.1834, 0.723, 0.2048]}, {"w": "many", "b": [0.7281, 0.1834, 0.7748, 0.2048]}, {"w": "examples", "b": [0.78, 0.1834, 0.8572, 0.2048]}, {"w": "of", "b": [0.1429, 0.2024, 0.1596, 0.2238]}, {"w": "cars,", "b": [0.1644, 0.2024, 0.2025, 0.2238]}, {"w": "including", "b": [0.2072, 0.2024, 0.287, 0.2238]}, {"w": "both", "b": [0.2918, 0.2024, 0.3305, 0.2238]}, {"w": "their", "b": [0.3352, 0.2024, 0.3748, 0.2238]}, {"w": "predictors", "b": [0.3796, 0.2024, 0.4648, 0.2238]}, {"w": "and", "b": [0.4695, 0.2024, 0.5011, 0.2238]}, {"w": "their", "b": [0.5058, 0.2024, 0.5455, 0.2238]}, {"w": "labels", "b": [0.5502, 0.2024, 0.597, 0.2238]}, {"w": "(i.e.,", "b": [0.6017, 0.2024, 0.6376, 0.2238]}, {"w": "their", "b": [0.6423, 0.2024, 0.682, 0.2238]}, {"w": "prices).", "b": [0.6867, 0.2024, 0.7482, 0.2238]}]}, {"id": "b_3", "type": "paragraph", "text": "In Machine Learning an attribute is a data type (e.g., “Mileage”), while a feature has several meanings depending on the context, but generally means an attribute plus its value (e.g., “Mileage = 15,000”). Many people use the words attribute and feature inter‐ changeably, though.", "words": [{"w": "In", "b": [0.2714, 0.2444, 0.2883, 0.2639]}, {"w": "Machine", "b": [0.2955, 0.2444, 0.3623, 0.2639]}, {"w": "Learning", "b": [0.3695, 0.2444, 0.4381, 0.2639]}, {"w": "an", "b": [0.4453, 0.2444, 0.464, 0.2639]}, {"w": "attribute", "b": [0.4712, 0.2442, 0.5359, 0.2639]}, {"w": "is", "b": [0.5431, 0.2444, 0.5552, 0.2639]}, {"w": "a", "b": [0.5623, 0.2444, 0.5707, 0.2639]}, {"w": "data", "b": [0.5778, 0.2444, 0.6101, 0.2639]}, {"w": "type", "b": [0.6172, 0.2444, 0.6499, 0.2639]}, {"w": "(e.g.,", "b": [0.657, 0.2444, 0.6936, 0.2639]}, {"w": "“Mileage”),", "b": [0.7008, 0.2444, 0.7857, 0.2639]}, {"w": "while", "b": [0.2714, 0.2618, 0.3126, 0.2814]}, {"w": "a", "b": [0.3176, 0.2618, 0.326, 0.2814]}, {"w": "feature", "b": [0.331, 0.2616, 0.3822, 0.2814]}, {"w": "has", "b": [0.3872, 0.2618, 0.4127, 0.2814]}, {"w": "several", "b": [0.4177, 0.2618, 0.47, 0.2814]}, {"w": "meanings", "b": [0.475, 0.2618, 0.5489, 0.2814]}, {"w": "depending", "b": [0.5539, 0.2618, 0.635, 0.2814]}, {"w": "on", "b": [0.64, 0.2618, 0.6602, 0.2814]}, {"w": "the", "b": [0.6652, 0.2618, 0.6892, 0.2814]}, {"w": "context,", "b": [0.6942, 0.2618, 0.7551, 0.2814]}, {"w": "but", "b": [0.7601, 0.2618, 0.7857, 0.2814]}, {"w": "generally", "b": [0.2714, 0.2792, 0.3407, 0.2988]}, {"w": "means", "b": [0.3525, 0.2792, 0.402, 0.2988]}, {"w": "an", "b": [0.4138, 0.2792, 0.4326, 0.2988]}, {"w": "attribute", "b": [0.4444, 0.2792, 0.5098, 0.2988]}, {"w": "plus", "b": [0.5216, 0.2792, 0.5535, 0.2988]}, {"w": "its", "b": [0.5653, 0.2792, 0.5832, 0.2988]}, {"w": "value", "b": [0.595, 0.2792, 0.6352, 0.2988]}, {"w": "(e.g.,", "b": [0.647, 0.2792, 0.6836, 0.2988]}, {"w": "“Mileage", "b": [0.6954, 0.2792, 0.7629, 0.2988]}, {"w": "=", "b": [0.7747, 0.2792, 0.7857, 0.2988]}, {"w": "15,000”).", "b": [0.2714, 0.2966, 0.34, 0.3162]}, {"w": "Many", "b": [0.3475, 0.2966, 0.3913, 0.3162]}, {"w": "people", "b": [0.3988, 0.2966, 0.4494, 0.3162]}, {"w": "use", "b": [0.4569, 0.2966, 0.4821, 0.3162]}, {"w": "the", "b": [0.4896, 0.2966, 0.5137, 0.3162]}, {"w": "words", "b": [0.5212, 0.2966, 0.5681, 0.3162]}, {"w": "attribute", "b": [0.5756, 0.2964, 0.6403, 0.3162]}, {"w": "and", "b": [0.6478, 0.2966, 0.6766, 0.3162]}, {"w": "feature", "b": [0.6841, 0.2964, 0.7353, 0.3162]}, {"w": "inter‐", "b": [0.7428, 0.2966, 0.7857, 0.3162]}, {"w": "changeably,", "b": [0.2714, 0.314, 0.36, 0.3336]}, {"w": "though.", "b": [0.3643, 0.314, 0.4235, 0.3336]}]}, {"id": "b_4", "type": "equation", "text": "Figure 1-6. Regression", "words": [{"w": "Figure", "b": [0.1429, 0.6418, 0.1943, 0.6634]}, {"w": "1-6.", "b": [0.1991, 0.6418, 0.2308, 0.6634]}, {"w": "Regression", "b": [0.2356, 0.6418, 0.3203, 0.6634]}]}, {"id": "b_5", "type": "paragraph", "text": "Note that some regression algorithms can be used for classification as well, and vice versa. For example, Logistic Regression is commonly used for classification, as it can output a value that corresponds to the probability of belonging to a given class (e.g., 20% chance of being spam).", "words": [{"w": "Note", "b": [0.1429, 0.6791, 0.1837, 0.7006]}, {"w": "that", "b": [0.1899, 0.6791, 0.2225, 0.7006]}, {"w": "some", "b": [0.2288, 0.6791, 0.273, 0.7006]}, {"w": "regression", "b": [0.2793, 0.6791, 0.3651, 0.7006]}, {"w": "algorithms", "b": [0.3714, 0.6791, 0.4617, 0.7006]}, {"w": "can", "b": [0.468, 0.6791, 0.4973, 0.7006]}, {"w": "be", "b": [0.5036, 0.6791, 0.523, 0.7006]}, {"w": "used", "b": [0.5293, 0.6791, 0.5679, 0.7006]}, {"w": "for", "b": [0.5742, 0.6791, 0.5987, 0.7006]}, {"w": "classification", "b": [0.605, 0.6791, 0.7124, 0.7006]}, {"w": "as", "b": [0.7186, 0.6791, 0.7354, 0.7006]}, {"w": "well,", "b": [0.7417, 0.6791, 0.7801, 0.7006]}, {"w": "and", "b": [0.7864, 0.6791, 0.818, 0.7006]}, {"w": "vice", "b": [0.8242, 0.6791, 0.8571, 0.7006]}, {"w": "versa.", "b": [0.1429, 0.6982, 0.1906, 0.7196]}, {"w": "For", "b": [0.1972, 0.6982, 0.2262, 0.7196]}, {"w": "example,", "b": [0.2328, 0.6982, 0.3071, 0.7196]}, {"w": "Logistic", "b": [0.3137, 0.698, 0.3759, 0.7196]}, {"w": "Regression", "b": [0.3826, 0.698, 0.4673, 0.7196]}, {"w": "is", "b": [0.4739, 0.6982, 0.4871, 0.7196]}, {"w": "commonly", "b": [0.4937, 0.6982, 0.5842, 0.7196]}, {"w": "used", "b": [0.5908, 0.6982, 0.6293, 0.7196]}, {"w": "for", "b": [0.636, 0.6982, 0.6605, 0.7196]}, {"w": "classification,", "b": [0.6671, 0.6982, 0.7792, 0.7196]}, {"w": "as", "b": [0.7858, 0.6982, 0.8026, 0.7196]}, {"w": "it", "b": [0.8092, 0.6982, 0.8212, 0.7196]}, {"w": "can", "b": [0.8278, 0.6982, 0.8571, 0.7196]}, {"w": "output", "b": [0.1428, 0.7172, 0.1992, 0.7387]}, {"w": "a", "b": [0.2052, 0.7172, 0.2144, 0.7387]}, {"w": "value", "b": [0.2204, 0.7172, 0.2644, 0.7387]}, {"w": "that", "b": [0.2704, 0.7172, 0.3029, 0.7387]}, {"w": "corresponds", "b": [0.3089, 0.7172, 0.4119, 0.7387]}, {"w": "to", "b": [0.4179, 0.7172, 0.4349, 0.7387]}, {"w": "the", "b": [0.4409, 0.7172, 0.4672, 0.7387]}, {"w": "probability", "b": [0.4732, 0.7172, 0.5652, 0.7387]}, {"w": "of", "b": [0.5712, 0.7172, 0.588, 0.7387]}, {"w": "belonging", "b": [0.594, 0.7172, 0.6772, 0.7387]}, {"w": "to", "b": [0.6832, 0.7172, 0.7002, 0.7387]}, {"w": "a", "b": [0.7062, 0.7172, 0.7153, 0.7387]}, {"w": "given", "b": [0.7213, 0.7172, 0.7665, 0.7387]}, {"w": "class", "b": [0.7725, 0.7172, 0.8111, 0.7387]}, {"w": "(e.g.,", "b": [0.8171, 0.7172, 0.8571, 0.7387]}, {"w": "20%", "b": [0.1429, 0.7363, 0.1786, 0.7577]}, {"w": "chance", "b": [0.1833, 0.7363, 0.2415, 0.7577]}, {"w": "of", "b": [0.2462, 0.7363, 0.263, 0.7577]}, {"w": "being", "b": [0.2677, 0.7363, 0.3139, 0.7577]}, {"w": "spam).", "b": [0.3186, 0.7363, 0.3754, 0.7577]}]}, {"id": "b_6", "type": "paragraph", "text": "Types of Machine Learning Systems | 9", "words": [{"w": "Types", "b": [0.6034, 0.9225, 0.6368, 0.9388]}, {"w": "of", "b": [0.6396, 0.9225, 0.6516, 0.9388]}, {"w": "Machine", "b": [0.6544, 0.9225, 0.7043, 0.9388]}, {"w": "Learning", "b": [0.7072, 0.9225, 0.7594, 0.9388]}, {"w": "Systems", "b": [0.7622, 0.9225, 0.8104, 0.9388]}, {"w": "|", "b": [0.8283, 0.9225, 0.832, 0.9388]}, {"w": "9", "b": [0.8499, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 36, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "2 Some neural network architectures can be unsupervised, such as autoencoders and restricted Boltzmann machines. They can also be semisupervised, such as in deep belief networks and unsupervised pretraining.", "words": [{"w": "2", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Some", "b": [0.1587, 0.8598, 0.1941, 0.8761]}, {"w": "neural", "b": [0.1977, 0.8598, 0.2384, 0.8761]}, {"w": "network", "b": [0.242, 0.8598, 0.295, 0.8761]}, {"w": "architectures", "b": [0.2986, 0.8598, 0.381, 0.8761]}, {"w": "can", "b": [0.3846, 0.8598, 0.4069, 0.8761]}, {"w": "be", "b": [0.4105, 0.8598, 0.4253, 0.8761]}, {"w": "unsupervised,", "b": [0.429, 0.8598, 0.5179, 0.8761]}, {"w": "such", "b": [0.5215, 0.8598, 0.551, 0.8761]}, {"w": "as", "b": [0.5546, 0.8598, 0.5673, 0.8761]}, {"w": "autoencoders", "b": [0.571, 0.8598, 0.6561, 0.8761]}, {"w": "and", "b": [0.6597, 0.8598, 0.6837, 0.8761]}, {"w": "restricted", "b": [0.6873, 0.8598, 0.7474, 0.8761]}, {"w": "Boltzmann", "b": [0.751, 0.8598, 0.8216, 0.8761]}, {"w": "machines.", "b": [0.1587, 0.8749, 0.223, 0.8912]}, {"w": "They", "b": [0.2266, 0.8749, 0.2589, 0.8912]}, {"w": "can", "b": [0.2625, 0.8749, 0.2849, 0.8912]}, {"w": "also", "b": [0.2885, 0.8749, 0.3134, 0.8912]}, {"w": "be", "b": [0.317, 0.8749, 0.3318, 0.8912]}, {"w": "semisupervised,", "b": [0.3354, 0.8749, 0.4371, 0.8912]}, {"w": "such", "b": [0.4407, 0.8749, 0.4701, 0.8912]}, {"w": "as", "b": [0.4737, 0.8749, 0.4865, 0.8912]}, {"w": "in", "b": [0.4901, 0.8749, 0.5031, 0.8912]}, {"w": "deep", "b": [0.5067, 0.8749, 0.5369, 0.8912]}, {"w": "belief", "b": [0.5405, 0.8749, 0.575, 0.8912]}, {"w": "networks", "b": [0.5786, 0.8749, 0.6374, 0.8912]}, {"w": "and", "b": [0.641, 0.8749, 0.665, 0.8912]}, {"w": "unsupervised", "b": [0.6687, 0.8749, 0.754, 0.8912]}, {"w": "pretraining.", "b": [0.7576, 0.8749, 0.8332, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Here are some of the most important supervised learning algorithms (covered in this book):", "words": [{"w": "Here", "b": [0.1429, 0.0791, 0.1837, 0.1005]}, {"w": "are", "b": [0.1892, 0.0791, 0.2149, 0.1005]}, {"w": "some", "b": [0.2203, 0.0791, 0.2645, 0.1005]}, {"w": "of", "b": [0.2699, 0.0791, 0.2867, 0.1005]}, {"w": "the", "b": [0.2921, 0.0791, 0.3184, 0.1005]}, {"w": "most", "b": [0.3238, 0.0791, 0.3655, 0.1005]}, {"w": "important", "b": [0.3709, 0.0791, 0.4553, 0.1005]}, {"w": "supervised", "b": [0.4607, 0.0791, 0.5503, 0.1005]}, {"w": "learning", "b": [0.5557, 0.0791, 0.6248, 0.1005]}, {"w": "algorithms", "b": [0.6302, 0.0791, 0.7205, 0.1005]}, {"w": "(covered", "b": [0.7259, 0.0791, 0.7986, 0.1005]}, {"w": "in", "b": [0.8041, 0.0791, 0.821, 0.1005]}, {"w": "this", "b": [0.8264, 0.0791, 0.8572, 0.1005]}, {"w": "book):", "b": [0.1429, 0.0981, 0.197, 0.1195]}]}, {"id": "b_2", "type": "equation", "text": "• k-Nearest Neighbors", "words": [{"w": "•", "b": [0.16, 0.1323, 0.1682, 0.1537]}, {"w": "k-Nearest", "b": [0.1786, 0.1323, 0.2599, 0.1537]}, {"w": "Neighbors", "b": [0.2646, 0.1323, 0.3514, 0.1537]}]}, {"id": "b_3", "type": "paragraph", "text": "• Linear Regression", "words": [{"w": "•", "b": [0.16, 0.1574, 0.1682, 0.1788]}, {"w": "Linear", "b": [0.1786, 0.1574, 0.2325, 0.1788]}, {"w": "Regression", "b": [0.2372, 0.1574, 0.3282, 0.1788]}]}, {"id": "b_4", "type": "paragraph", "text": "• Logistic Regression", "words": [{"w": "•", "b": [0.16, 0.1825, 0.1682, 0.2039]}, {"w": "Logistic", "b": [0.1786, 0.1825, 0.2441, 0.2039]}, {"w": "Regression", "b": [0.2489, 0.1825, 0.3399, 0.2039]}]}, {"id": "b_5", "type": "paragraph", "text": "• Support Vector Machines (SVMs)", "words": [{"w": "•", "b": [0.16, 0.2076, 0.1682, 0.229]}, {"w": "Support", "b": [0.1786, 0.2076, 0.246, 0.229]}, {"w": "Vector", "b": [0.2508, 0.2076, 0.3058, 0.229]}, {"w": "Machines", "b": [0.3105, 0.2076, 0.3913, 0.229]}, {"w": "(SVMs)", "b": [0.396, 0.2076, 0.4611, 0.229]}]}, {"id": "b_6", "type": "paragraph", "text": "• Decision Trees and Random Forests", "words": [{"w": "•", "b": [0.16, 0.2327, 0.1682, 0.2541]}, {"w": "Decision", "b": [0.1786, 0.2327, 0.2524, 0.2541]}, {"w": "Trees", "b": [0.2571, 0.2327, 0.3013, 0.2541]}, {"w": "and", "b": [0.306, 0.2327, 0.3376, 0.2541]}, {"w": "Random", "b": [0.3423, 0.2327, 0.4149, 0.2541]}, {"w": "Forests", "b": [0.4196, 0.2327, 0.4791, 0.2541]}]}, {"id": "b_7", "type": "paragraph", "text": "• Neural networks2", "words": [{"w": "•", "b": [0.16, 0.2577, 0.1682, 0.2792]}, {"w": "Neural", "b": [0.1786, 0.2577, 0.2356, 0.2792]}, {"w": "networks2", "b": [0.2403, 0.2577, 0.3232, 0.2792]}]}, {"id": "b_8", "type": "paragraph", "text": "Unsupervised learning", "words": [{"w": "Unsupervised", "b": [0.1429, 0.3102, 0.2449, 0.3311]}, {"w": "learning", "b": [0.2485, 0.3102, 0.3121, 0.3311]}]}, {"id": "b_9", "type": "paragraph", "text": "In unsupervised learning, as you might guess, the training data is unlabeled (Figure 1-7). The system tries to learn without a teacher.", "words": [{"w": "In", "b": [0.1429, 0.3368, 0.1614, 0.3582]}, {"w": "unsupervised", "b": [0.1747, 0.3366, 0.2819, 0.3582]}, {"w": "learning,", "b": [0.2953, 0.3366, 0.3668, 0.3582]}, {"w": "as", "b": [0.3801, 0.3368, 0.3969, 0.3582]}, {"w": "you", "b": [0.4102, 0.3368, 0.4415, 0.3582]}, {"w": "might", "b": [0.4548, 0.3368, 0.5043, 0.3582]}, {"w": "guess,", "b": [0.5176, 0.3368, 0.5673, 0.3582]}, {"w": "the", "b": [0.5806, 0.3368, 0.607, 0.3582]}, {"w": "training", "b": [0.6203, 0.3368, 0.6872, 0.3582]}, {"w": "data", "b": [0.7006, 0.3368, 0.7358, 0.3582]}, {"w": "is", "b": [0.7491, 0.3368, 0.7624, 0.3582]}, {"w": "unlabeled", "b": [0.7757, 0.3368, 0.8571, 0.3582]}, {"w": "(Figure", "b": [0.1429, 0.3558, 0.2041, 0.3773]}, {"w": "1-7).", "b": [0.2088, 0.3558, 0.2482, 0.3773]}, {"w": "The", "b": [0.2529, 0.3558, 0.2857, 0.3773]}, {"w": "system", "b": [0.2905, 0.3558, 0.3476, 0.3773]}, {"w": "tries", "b": [0.3523, 0.3558, 0.3885, 0.3773]}, {"w": "to", "b": [0.3932, 0.3558, 0.4102, 0.3773]}, {"w": "learn", "b": [0.4149, 0.3558, 0.4573, 0.3773]}, {"w": "without", "b": [0.4621, 0.3558, 0.5274, 0.3773]}, {"w": "a", "b": [0.5322, 0.3558, 0.5413, 0.3773]}, {"w": "teacher.", "b": [0.546, 0.3558, 0.6103, 0.3773]}]}, {"id": "b_10", "type": "equation", "text": "Figure 1-7. An unlabeled training set for unsupervised learning", "words": [{"w": "Figure", "b": [0.1429, 0.5614, 0.1943, 0.583]}, {"w": "1-7.", "b": [0.1991, 0.5614, 0.2308, 0.583]}, {"w": "An", "b": [0.2356, 0.5614, 0.2605, 0.583]}, {"w": "unlabeled", "b": [0.2653, 0.5614, 0.3438, 0.583]}, {"w": "training", "b": [0.3486, 0.5614, 0.413, 0.583]}, {"w": "set", "b": [0.4178, 0.5614, 0.4394, 0.583]}, {"w": "for", "b": [0.4442, 0.5614, 0.4668, 0.583]}, {"w": "unsupervised", "b": [0.4716, 0.5614, 0.5789, 0.583]}, {"w": "learning", "b": [0.5837, 0.5614, 0.6504, 0.583]}]}, {"id": "b_11", "type": "paragraph", "text": "Here are some of the most important unsupervised learning algorithms (most of these are covered in Chapter 8 and Chapter 9):", "words": [{"w": "Here", "b": [0.1429, 0.5988, 0.1837, 0.6202]}, {"w": "are", "b": [0.1926, 0.5988, 0.2183, 0.6202]}, {"w": "some", "b": [0.2271, 0.5988, 0.2713, 0.6202]}, {"w": "of", "b": [0.2802, 0.5988, 0.297, 0.6202]}, {"w": "the", "b": [0.3058, 0.5988, 0.3321, 0.6202]}, {"w": "most", "b": [0.341, 0.5988, 0.3827, 0.6202]}, {"w": "important", "b": [0.3915, 0.5988, 0.4759, 0.6202]}, {"w": "unsupervised", "b": [0.4847, 0.5988, 0.5967, 0.6202]}, {"w": "learning", "b": [0.6055, 0.5988, 0.6747, 0.6202]}, {"w": "algorithms", "b": [0.6835, 0.5988, 0.7738, 0.6202]}, {"w": "(most", "b": [0.7826, 0.5988, 0.8315, 0.6202]}, {"w": "of", "b": [0.8404, 0.5988, 0.8572, 0.6202]}, {"w": "these", "b": [0.1429, 0.6179, 0.1857, 0.6393]}, {"w": "are", "b": [0.1904, 0.6179, 0.2162, 0.6393]}, {"w": "covered", "b": [0.2209, 0.6179, 0.2864, 0.6393]}, {"w": "in", "b": [0.2911, 0.6179, 0.3081, 0.6393]}, {"w": "Chapter", "b": [0.3128, 0.6179, 0.3804, 0.6393]}, {"w": "8", "b": [0.3852, 0.6179, 0.3952, 0.6393]}, {"w": "and", "b": [0.3999, 0.6179, 0.4314, 0.6393]}, {"w": "Chapter", "b": [0.4362, 0.6179, 0.5037, 0.6393]}, {"w": "9):", "b": [0.5085, 0.6179, 0.5304, 0.6393]}]}, {"id": "b_12", "type": "paragraph", "text": "• Clustering", "words": [{"w": "•", "b": [0.16, 0.652, 0.1682, 0.6734]}, {"w": "Clustering", "b": [0.1786, 0.652, 0.2661, 0.6734]}]}, {"id": "b_13", "type": "equation", "text": "— K-Means", "words": [{"w": "—", "b": [0.1807, 0.6771, 0.1999, 0.6985]}, {"w": "K-Means", "b": [0.2044, 0.6771, 0.2809, 0.6985]}]}, {"id": "b_14", "type": "paragraph", "text": "— DBSCAN", "words": [{"w": "—", "b": [0.1807, 0.7022, 0.1999, 0.7236]}, {"w": "DBSCAN", "b": [0.2044, 0.7022, 0.2855, 0.7236]}]}, {"id": "b_15", "type": "paragraph", "text": "— Hierarchical Cluster Analysis (HCA)", "words": [{"w": "—", "b": [0.1807, 0.7273, 0.1999, 0.7487]}, {"w": "Hierarchical", "b": [0.2044, 0.7273, 0.3081, 0.7487]}, {"w": "Cluster", "b": [0.3128, 0.7273, 0.3736, 0.7487]}, {"w": "Analysis", "b": [0.3783, 0.7273, 0.449, 0.7487]}, {"w": "(HCA)", "b": [0.4537, 0.7273, 0.5123, 0.7487]}]}, {"id": "b_16", "type": "paragraph", "text": "• Anomaly detection and novelty detection", "words": [{"w": "•", "b": [0.16, 0.7524, 0.1682, 0.7738]}, {"w": "Anomaly", "b": [0.1786, 0.7524, 0.256, 0.7738]}, {"w": "detection", "b": [0.2608, 0.7524, 0.3386, 0.7738]}, {"w": "and", "b": [0.3433, 0.7524, 0.3749, 0.7738]}, {"w": "novelty", "b": [0.3796, 0.7524, 0.4413, 0.7738]}, {"w": "detection", "b": [0.446, 0.7524, 0.5239, 0.7738]}]}, {"id": "b_17", "type": "equation", "text": "— One-class SVM", "words": [{"w": "—", "b": [0.1807, 0.7775, 0.1999, 0.7989]}, {"w": "One-class", "b": [0.2044, 0.7775, 0.2861, 0.7989]}, {"w": "SVM", "b": [0.2908, 0.7775, 0.3339, 0.7989]}]}, {"id": "b_18", "type": "paragraph", "text": "— Isolation Forest", "words": [{"w": "—", "b": [0.1807, 0.8026, 0.1999, 0.824]}, {"w": "Isolation", "b": [0.2044, 0.8026, 0.2773, 0.824]}, {"w": "Forest", "b": [0.282, 0.8026, 0.3338, 0.824]}]}, {"id": "b_19", "type": "paragraph", "text": "10 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "10", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.337, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 37, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• Visualization and dimensionality reduction", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "Visualization", "b": [0.1786, 0.0791, 0.2881, 0.1005]}, {"w": "and", "b": [0.2928, 0.0791, 0.3244, 0.1005]}, {"w": "dimensionality", "b": [0.3291, 0.0791, 0.4542, 0.1005]}, {"w": "reduction", "b": [0.4589, 0.0791, 0.5403, 0.1005]}]}, {"id": "b_1", "type": "paragraph", "text": "— Principal Component Analysis (PCA)", "words": [{"w": "—", "b": [0.1807, 0.1042, 0.1999, 0.1256]}, {"w": "Principal", "b": [0.2044, 0.1042, 0.2805, 0.1256]}, {"w": "Component", "b": [0.2853, 0.1042, 0.3855, 0.1256]}, {"w": "Analysis", "b": [0.3903, 0.1042, 0.4609, 0.1256]}, {"w": "(PCA)", "b": [0.4656, 0.1042, 0.52, 0.1256]}]}, {"id": "b_2", "type": "paragraph", "text": "— Kernel PCA", "words": [{"w": "—", "b": [0.1807, 0.1293, 0.1999, 0.1507]}, {"w": "Kernel", "b": [0.2044, 0.1293, 0.26, 0.1507]}, {"w": "PCA", "b": [0.2647, 0.1293, 0.3047, 0.1507]}]}, {"id": "b_3", "type": "equation", "text": "— Locally-Linear Embedding (LLE)", "words": [{"w": "—", "b": [0.1807, 0.1543, 0.1999, 0.1758]}, {"w": "Locally-Linear", "b": [0.2044, 0.1543, 0.3256, 0.1758]}, {"w": "Embedding", "b": [0.3303, 0.1543, 0.4274, 0.1758]}, {"w": "(LLE)", "b": [0.4321, 0.1543, 0.4808, 0.1758]}]}, {"id": "b_4", "type": "equation", "text": "— t-distributed Stochastic Neighbor Embedding (t-SNE)", "words": [{"w": "—", "b": [0.1807, 0.1794, 0.1999, 0.2009]}, {"w": "t-distributed", "b": [0.2044, 0.1794, 0.3099, 0.2009]}, {"w": "Stochastic", "b": [0.3146, 0.1794, 0.3989, 0.2009]}, {"w": "Neighbor", "b": [0.4037, 0.1794, 0.4829, 0.2009]}, {"w": "Embedding", "b": [0.4876, 0.1794, 0.5847, 0.2009]}, {"w": "(t-SNE)", "b": [0.5894, 0.1794, 0.6548, 0.2009]}]}, {"id": "b_5", "type": "paragraph", "text": "• Association rule learning", "words": [{"w": "•", "b": [0.16, 0.2045, 0.1682, 0.2259]}, {"w": "Association", "b": [0.1786, 0.2045, 0.276, 0.2259]}, {"w": "rule", "b": [0.2807, 0.2045, 0.3136, 0.2259]}, {"w": "learning", "b": [0.3184, 0.2045, 0.3875, 0.2259]}]}, {"id": "b_6", "type": "paragraph", "text": "— Apriori", "words": [{"w": "—", "b": [0.1807, 0.2296, 0.1999, 0.251]}, {"w": "Apriori", "b": [0.2044, 0.2296, 0.2661, 0.251]}]}, {"id": "b_7", "type": "paragraph", "text": "— Eclat", "words": [{"w": "—", "b": [0.1807, 0.2547, 0.1999, 0.2761]}, {"w": "Eclat", "b": [0.2044, 0.2547, 0.2454, 0.2761]}]}, {"id": "b_8", "type": "paragraph", "text": "For example, say you have a lot of data about your blog’s visitors. You may want to run a clustering algorithm to try to detect groups of similar visitors (Figure 1-8). At no point do you tell the algorithm which group a visitor belongs to: it finds those connections without your help. For example, it might notice that 40% of your visitors are males who love comic books and generally read your blog in the evening, while 20% are young sci-fi lovers who visit during the weekends, and so on. If you use a hierarchical clustering algorithm, it may also subdivide each group into smaller groups. This may help you target your posts for each group.", "words": [{"w": "For", "b": [0.1429, 0.2889, 0.1718, 0.3103]}, {"w": "example,", "b": [0.1786, 0.2889, 0.2529, 0.3103]}, {"w": "say", "b": [0.2596, 0.2889, 0.2856, 0.3103]}, {"w": "you", "b": [0.2924, 0.2889, 0.3236, 0.3103]}, {"w": "have", "b": [0.3304, 0.2889, 0.3688, 0.3103]}, {"w": "a", "b": [0.3755, 0.2889, 0.3846, 0.3103]}, {"w": "lot", "b": [0.3914, 0.2889, 0.4136, 0.3103]}, {"w": "of", "b": [0.4204, 0.2889, 0.4372, 0.3103]}, {"w": "data", "b": [0.4439, 0.2889, 0.4792, 0.3103]}, {"w": "about", "b": [0.4859, 0.2889, 0.5337, 0.3103]}, {"w": "your", "b": [0.5405, 0.2889, 0.5794, 0.3103]}, {"w": "blog’s", "b": [0.5862, 0.2889, 0.6323, 0.3103]}, {"w": "visitors.", "b": [0.6391, 0.2889, 0.7046, 0.3103]}, {"w": "You", "b": [0.7114, 0.2889, 0.7437, 0.3103]}, {"w": "may", "b": [0.7505, 0.2889, 0.7859, 0.3103]}, {"w": "want", "b": [0.7926, 0.2889, 0.8334, 0.3103]}, {"w": "to", "b": [0.8402, 0.2889, 0.8571, 0.3103]}, {"w": "run", "b": [0.1429, 0.3079, 0.173, 0.3293]}, {"w": "a", "b": [0.1796, 0.3079, 0.1888, 0.3293]}, {"w": "clustering", "b": [0.1953, 0.3077, 0.2733, 0.3293]}, {"w": "algorithm", "b": [0.2799, 0.3079, 0.3625, 0.3293]}, {"w": "to", "b": [0.3691, 0.3079, 0.3861, 0.3293]}, {"w": "try", "b": [0.3926, 0.3079, 0.4169, 0.3293]}, {"w": "to", "b": [0.4235, 0.3079, 0.4404, 0.3293]}, {"w": "detect", "b": [0.447, 0.3079, 0.4973, 0.3293]}, {"w": "groups", "b": [0.5038, 0.3079, 0.5616, 0.3293]}, {"w": "of", "b": [0.5681, 0.3079, 0.5849, 0.3293]}, {"w": "similar", "b": [0.5915, 0.3079, 0.6495, 0.3293]}, {"w": "visitors", "b": [0.6561, 0.3079, 0.7169, 0.3293]}, {"w": "(Figure", "b": [0.7235, 0.3079, 0.7847, 0.3293]}, {"w": "1-8).", "b": [0.7913, 0.3079, 0.8307, 0.3293]}, {"w": "At", "b": [0.8372, 0.3079, 0.8571, 0.3293]}, {"w": "no", "b": [0.1429, 0.327, 0.1649, 0.3484]}, {"w": "point", "b": [0.1724, 0.327, 0.2169, 0.3484]}, {"w": "do", "b": [0.2244, 0.327, 0.246, 0.3484]}, {"w": "you", "b": [0.2535, 0.327, 0.2848, 0.3484]}, {"w": "tell", "b": [0.2923, 0.327, 0.318, 0.3484]}, {"w": "the", "b": [0.3256, 0.327, 0.3519, 0.3484]}, {"w": "algorithm", "b": [0.3594, 0.327, 0.442, 0.3484]}, {"w": "which", "b": [0.4496, 0.327, 0.5005, 0.3484]}, {"w": "group", "b": [0.508, 0.327, 0.5581, 0.3484]}, {"w": "a", "b": [0.5656, 0.327, 0.5747, 0.3484]}, {"w": "visitor", "b": [0.5822, 0.327, 0.6354, 0.3484]}, {"w": "belongs", "b": [0.6429, 0.327, 0.707, 0.3484]}, {"w": "to:", "b": [0.7146, 0.327, 0.7363, 0.3484]}, {"w": "it", "b": [0.7438, 0.327, 0.7557, 0.3484]}, {"w": "finds", "b": [0.7632, 0.327, 0.805, 0.3484]}, {"w": "those", "b": [0.8125, 0.327, 0.8572, 0.3484]}, {"w": "connections", "b": [0.1429, 0.346, 0.2444, 0.3674]}, {"w": "without", "b": [0.2495, 0.346, 0.3149, 0.3674]}, {"w": "your", "b": [0.32, 0.346, 0.359, 0.3674]}, {"w": "help.", "b": [0.3642, 0.346, 0.4045, 0.3674]}, {"w": "For", "b": [0.4096, 0.346, 0.4386, 0.3674]}, {"w": "example,", "b": [0.4437, 0.346, 0.518, 0.3674]}, {"w": "it", "b": [0.5232, 0.346, 0.5351, 0.3674]}, {"w": "might", "b": [0.5403, 0.346, 0.5897, 0.3674]}, {"w": "notice", "b": [0.5949, 0.346, 0.6465, 0.3674]}, {"w": "that", "b": [0.6516, 0.346, 0.6842, 0.3674]}, {"w": "40%", "b": [0.6894, 0.346, 0.7251, 0.3674]}, {"w": "of", "b": [0.7303, 0.346, 0.7471, 0.3674]}, {"w": "your", "b": [0.7522, 0.346, 0.7912, 0.3674]}, {"w": "visitors", "b": [0.7963, 0.346, 0.8571, 0.3674]}, {"w": "are", "b": [0.1429, 0.3651, 0.1686, 0.3865]}, {"w": "males", "b": [0.1751, 0.3651, 0.2231, 0.3865]}, {"w": "who", "b": [0.2296, 0.3651, 0.2657, 0.3865]}, {"w": "love", "b": [0.2722, 0.3651, 0.3066, 0.3865]}, {"w": "comic", "b": [0.3131, 0.3651, 0.364, 0.3865]}, {"w": "books", "b": [0.3706, 0.3651, 0.4204, 0.3865]}, {"w": "and", "b": [0.4269, 0.3651, 0.4584, 0.3865]}, {"w": "generally", "b": [0.465, 0.3651, 0.5408, 0.3865]}, {"w": "read", "b": [0.5473, 0.3651, 0.5841, 0.3865]}, {"w": "your", "b": [0.5906, 0.3651, 0.6296, 0.3865]}, {"w": "blog", "b": [0.6361, 0.3651, 0.6724, 0.3865]}, {"w": "in", "b": [0.6789, 0.3651, 0.6959, 0.3865]}, {"w": "the", "b": [0.7024, 0.3651, 0.7287, 0.3865]}, {"w": "evening,", "b": [0.7353, 0.3651, 0.8055, 0.3865]}, {"w": "while", "b": [0.812, 0.3651, 0.8571, 0.3865]}, {"w": "20%", "b": [0.1428, 0.3841, 0.1786, 0.4055]}, {"w": "are", "b": [0.1856, 0.3841, 0.2113, 0.4055]}, {"w": "young", "b": [0.2183, 0.3841, 0.2707, 0.4055]}, {"w": "sci-fi", "b": [0.2777, 0.3841, 0.3189, 0.4055]}, {"w": "lovers", "b": [0.3259, 0.3841, 0.3757, 0.4055]}, {"w": "who", "b": [0.3827, 0.3841, 0.4187, 0.4055]}, {"w": "visit", "b": [0.4257, 0.3841, 0.4605, 0.4055]}, {"w": "during", "b": [0.4675, 0.3841, 0.524, 0.4055]}, {"w": "the", "b": [0.531, 0.3841, 0.5574, 0.4055]}, {"w": "weekends,", "b": [0.5644, 0.3841, 0.6503, 0.4055]}, {"w": "and", "b": [0.6573, 0.3841, 0.6889, 0.4055]}, {"w": "so", "b": [0.6959, 0.3841, 0.7141, 0.4055]}, {"w": "on.", "b": [0.7211, 0.3841, 0.7479, 0.4055]}, {"w": "If", "b": [0.7549, 0.3841, 0.7682, 0.4055]}, {"w": "you", "b": [0.7752, 0.3841, 0.8064, 0.4055]}, {"w": "use", "b": [0.8134, 0.3841, 0.841, 0.4055]}, {"w": "a", "b": [0.848, 0.3841, 0.8571, 0.4055]}, {"w": "hierarchical", "b": [0.1429, 0.403, 0.238, 0.4246]}, {"w": "clustering", "b": [0.2491, 0.403, 0.327, 0.4246]}, {"w": "algorithm,", "b": [0.338, 0.4032, 0.4254, 0.4246]}, {"w": "it", "b": [0.4365, 0.4032, 0.4484, 0.4246]}, {"w": "may", "b": [0.4594, 0.4032, 0.4948, 0.4246]}, {"w": "also", "b": [0.5058, 0.4032, 0.5385, 0.4246]}, {"w": "subdivide", "b": [0.5495, 0.4032, 0.6305, 0.4246]}, {"w": "each", "b": [0.6415, 0.4032, 0.6795, 0.4246]}, {"w": "group", "b": [0.6905, 0.4032, 0.7406, 0.4246]}, {"w": "into", "b": [0.7516, 0.4032, 0.7851, 0.4246]}, {"w": "smaller", "b": [0.7962, 0.4032, 0.8571, 0.4246]}, {"w": "groups.", "b": [0.1429, 0.4222, 0.2053, 0.4436]}, {"w": "This", "b": [0.2101, 0.4222, 0.2473, 0.4436]}, {"w": "may", "b": [0.252, 0.4222, 0.2874, 0.4436]}, {"w": "help", "b": [0.2921, 0.4222, 0.3283, 0.4436]}, {"w": "you", "b": [0.333, 0.4222, 0.3643, 0.4436]}, {"w": "target", "b": [0.369, 0.4222, 0.4172, 0.4436]}, {"w": "your", "b": [0.4219, 0.4222, 0.4609, 0.4436]}, {"w": "posts", "b": [0.4656, 0.4222, 0.5088, 0.4436]}, {"w": "for", "b": [0.5135, 0.4222, 0.5381, 0.4436]}, {"w": "each", "b": [0.5428, 0.4222, 0.5807, 0.4436]}, {"w": "group.", "b": [0.5855, 0.4222, 0.6397, 0.4436]}]}, {"id": "b_9", "type": "equation", "text": "Figure 1-8. Clustering", "words": [{"w": "Figure", "b": [0.1429, 0.6304, 0.1943, 0.652]}, {"w": "1-8.", "b": [0.1991, 0.6304, 0.2308, 0.652]}, {"w": "Clustering", "b": [0.2356, 0.6304, 0.319, 0.652]}]}, {"id": "b_10", "type": "paragraph", "text": "Visualization algorithms are also good examples of unsupervised learning algorithms: you feed them a lot of complex and unlabeled data, and they output a 2D or 3D rep‐ resentation of your data that can easily be plotted (Figure 1-9). These algorithms try to preserve as much structure as they can (e.g., trying to keep separate clusters in the input space from overlapping in the visualization), so you can understand how the data is organized and perhaps identify unsuspected patterns.", "words": [{"w": "Visualization", "b": [0.1429, 0.6676, 0.251, 0.6892]}, {"w": "algorithms", "b": [0.256, 0.6678, 0.3463, 0.6892]}, {"w": "are", "b": [0.3514, 0.6678, 0.3771, 0.6892]}, {"w": "also", "b": [0.3821, 0.6678, 0.4148, 0.6892]}, {"w": "good", "b": [0.4198, 0.6678, 0.4618, 0.6892]}, {"w": "examples", "b": [0.4669, 0.6678, 0.5441, 0.6892]}, {"w": "of", "b": [0.5491, 0.6678, 0.5659, 0.6892]}, {"w": "unsupervised", "b": [0.5709, 0.6678, 0.6829, 0.6892]}, {"w": "learning", "b": [0.6879, 0.6678, 0.7571, 0.6892]}, {"w": "algorithms:", "b": [0.7621, 0.6678, 0.8571, 0.6892]}, {"w": "you", "b": [0.1428, 0.6869, 0.1741, 0.7083]}, {"w": "feed", "b": [0.1797, 0.6869, 0.2146, 0.7083]}, {"w": "them", "b": [0.2202, 0.6869, 0.2636, 0.7083]}, {"w": "a", "b": [0.2693, 0.6869, 0.2784, 0.7083]}, {"w": "lot", "b": [0.284, 0.6869, 0.3063, 0.7083]}, {"w": "of", "b": [0.3119, 0.6869, 0.3287, 0.7083]}, {"w": "complex", "b": [0.3344, 0.6869, 0.4053, 0.7083]}, {"w": "and", "b": [0.411, 0.6869, 0.4425, 0.7083]}, {"w": "unlabeled", "b": [0.4481, 0.6869, 0.5296, 0.7083]}, {"w": "data,", "b": [0.5352, 0.6869, 0.5752, 0.7083]}, {"w": "and", "b": [0.5808, 0.6869, 0.6124, 0.7083]}, {"w": "they", "b": [0.618, 0.6869, 0.6539, 0.7083]}, {"w": "output", "b": [0.6596, 0.6869, 0.7159, 0.7083]}, {"w": "a", "b": [0.7216, 0.6869, 0.7307, 0.7083]}, {"w": "2D", "b": [0.7363, 0.6869, 0.7617, 0.7083]}, {"w": "or", "b": [0.7673, 0.6869, 0.7856, 0.7083]}, {"w": "3D", "b": [0.7913, 0.6869, 0.8166, 0.7083]}, {"w": "rep‐", "b": [0.8222, 0.6869, 0.8571, 0.7083]}, {"w": "resentation", "b": [0.1429, 0.7059, 0.236, 0.7273]}, {"w": "of", "b": [0.2421, 0.7059, 0.2589, 0.7273]}, {"w": "your", "b": [0.2649, 0.7059, 0.3039, 0.7273]}, {"w": "data", "b": [0.31, 0.7059, 0.3452, 0.7273]}, {"w": "that", "b": [0.3513, 0.7059, 0.3839, 0.7273]}, {"w": "can", "b": [0.3899, 0.7059, 0.4193, 0.7273]}, {"w": "easily", "b": [0.4254, 0.7059, 0.4714, 0.7273]}, {"w": "be", "b": [0.4775, 0.7059, 0.4969, 0.7273]}, {"w": "plotted", "b": [0.503, 0.7059, 0.5624, 0.7273]}, {"w": "(Figure", "b": [0.5684, 0.7059, 0.6296, 0.7273]}, {"w": "1-9).", "b": [0.6357, 0.7059, 0.6751, 0.7273]}, {"w": "These", "b": [0.6811, 0.7059, 0.7305, 0.7273]}, {"w": "algorithms", "b": [0.7365, 0.7059, 0.8268, 0.7273]}, {"w": "try", "b": [0.8329, 0.7059, 0.8571, 0.7273]}, {"w": "to", "b": [0.1429, 0.725, 0.1598, 0.7464]}, {"w": "preserve", "b": [0.1653, 0.725, 0.2362, 0.7464]}, {"w": "as", "b": [0.2417, 0.725, 0.2585, 0.7464]}, {"w": "much", "b": [0.264, 0.725, 0.3116, 0.7464]}, {"w": "structure", "b": [0.3171, 0.725, 0.3927, 0.7464]}, {"w": "as", "b": [0.3982, 0.725, 0.415, 0.7464]}, {"w": "they", "b": [0.4205, 0.725, 0.4564, 0.7464]}, {"w": "can", "b": [0.4619, 0.725, 0.4913, 0.7464]}, {"w": "(e.g.,", "b": [0.4967, 0.725, 0.5368, 0.7464]}, {"w": "trying", "b": [0.5423, 0.725, 0.5933, 0.7464]}, {"w": "to", "b": [0.5988, 0.725, 0.6158, 0.7464]}, {"w": "keep", "b": [0.6213, 0.725, 0.6602, 0.7464]}, {"w": "separate", "b": [0.6657, 0.725, 0.734, 0.7464]}, {"w": "clusters", "b": [0.7395, 0.725, 0.8028, 0.7464]}, {"w": "in", "b": [0.8083, 0.725, 0.8253, 0.7464]}, {"w": "the", "b": [0.8308, 0.725, 0.8571, 0.7464]}, {"w": "input", "b": [0.1429, 0.744, 0.1878, 0.7654]}, {"w": "space", "b": [0.1949, 0.744, 0.2403, 0.7654]}, {"w": "from", "b": [0.2474, 0.744, 0.289, 0.7654]}, {"w": "overlapping", "b": [0.2961, 0.744, 0.3955, 0.7654]}, {"w": "in", "b": [0.4027, 0.744, 0.4196, 0.7654]}, {"w": "the", "b": [0.4268, 0.744, 0.4531, 0.7654]}, {"w": "visualization),", "b": [0.4602, 0.744, 0.5776, 0.7654]}, {"w": "so", "b": [0.5847, 0.744, 0.603, 0.7654]}, {"w": "you", "b": [0.6101, 0.744, 0.6413, 0.7654]}, {"w": "can", "b": [0.6485, 0.744, 0.6778, 0.7654]}, {"w": "understand", "b": [0.685, 0.744, 0.7805, 0.7654]}, {"w": "how", "b": [0.7877, 0.744, 0.8237, 0.7654]}, {"w": "the", "b": [0.8308, 0.744, 0.8571, 0.7654]}, {"w": "data", "b": [0.1428, 0.7631, 0.1781, 0.7845]}, {"w": "is", "b": [0.1828, 0.7631, 0.1961, 0.7845]}, {"w": "organized", "b": [0.2008, 0.7631, 0.2836, 0.7845]}, {"w": "and", "b": [0.2883, 0.7631, 0.3199, 0.7845]}, {"w": "perhaps", "b": [0.3246, 0.7631, 0.3906, 0.7845]}, {"w": "identify", "b": [0.3953, 0.7631, 0.4597, 0.7845]}, {"w": "unsuspected", "b": [0.4645, 0.7631, 0.5681, 0.7845]}, {"w": "patterns.", "b": [0.5728, 0.7631, 0.6456, 0.7845]}]}, {"id": "b_11", "type": "paragraph", "text": "Types of Machine Learning Systems | 11", "words": [{"w": "Types", "b": [0.5961, 0.9225, 0.6295, 0.9388]}, {"w": "of", "b": [0.6323, 0.9225, 0.6443, 0.9388]}, {"w": "Machine", "b": [0.6471, 0.9225, 0.6971, 0.9388]}, {"w": "Learning", "b": [0.6999, 0.9225, 0.7521, 0.9388]}, {"w": "Systems", "b": [0.7549, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "11", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 38, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "3 Notice how animals are rather well separated from vehicles, how horses are close to deer but far from birds, and so on. Figure reproduced with permission from Socher, Ganjoo, Manning, and Ng (2013), “T-SNE visual‐ ization of the semantic word space.”", "words": [{"w": "3", "b": [0.1451, 0.8462, 0.1518, 0.8604]}, {"w": "Notice", "b": [0.1587, 0.8447, 0.2008, 0.861]}, {"w": "how", "b": [0.2044, 0.8447, 0.2318, 0.861]}, {"w": "animals", "b": [0.2354, 0.8447, 0.2851, 0.861]}, {"w": "are", "b": [0.2887, 0.8447, 0.3083, 0.861]}, {"w": "rather", "b": [0.312, 0.8447, 0.3505, 0.861]}, {"w": "well", "b": [0.3541, 0.8447, 0.3797, 0.861]}, {"w": "separated", "b": [0.3833, 0.8447, 0.4437, 0.861]}, {"w": "from", "b": [0.4473, 0.8447, 0.479, 0.861]}, {"w": "vehicles,", "b": [0.4826, 0.8447, 0.5363, 0.861]}, {"w": "how", "b": [0.5399, 0.8447, 0.5674, 0.861]}, {"w": "horses", "b": [0.571, 0.8447, 0.6118, 0.861]}, {"w": "are", "b": [0.6154, 0.8447, 0.635, 0.861]}, {"w": "close", "b": [0.6387, 0.8447, 0.67, 0.861]}, {"w": "to", "b": [0.6737, 0.8447, 0.6866, 0.861]}, {"w": "deer", "b": [0.6902, 0.8447, 0.718, 0.861]}, {"w": "but", "b": [0.7216, 0.8447, 0.7429, 0.861]}, {"w": "far", "b": [0.7465, 0.8447, 0.764, 0.861]}, {"w": "from", "b": [0.7677, 0.8447, 0.7993, 0.861]}, {"w": "birds,", "b": [0.8029, 0.8447, 0.839, 0.861]}, {"w": "and", "b": [0.1587, 0.8598, 0.1828, 0.8761]}, {"w": "so", "b": [0.1864, 0.8598, 0.2003, 0.8761]}, {"w": "on.", "b": [0.2039, 0.8598, 0.2243, 0.8761]}, {"w": "Figure", "b": [0.2279, 0.8598, 0.269, 0.8761]}, {"w": "reproduced", "b": [0.2726, 0.8598, 0.3462, 0.8761]}, {"w": "with", "b": [0.3498, 0.8598, 0.3783, 0.8761]}, {"w": "permission", "b": [0.3819, 0.8598, 0.4528, 0.8761]}, {"w": "from", "b": [0.4564, 0.8598, 0.488, 0.8761]}, {"w": "Socher,", "b": [0.4917, 0.8598, 0.5377, 0.8761]}, {"w": "Ganjoo,", "b": [0.5413, 0.8598, 0.5914, 0.8761]}, {"w": "Manning,", "b": [0.595, 0.8598, 0.6572, 0.8761]}, {"w": "and", "b": [0.6608, 0.8598, 0.6849, 0.8761]}, {"w": "Ng", "b": [0.6885, 0.8598, 0.7072, 0.8761]}, {"w": "(2013),", "b": [0.7108, 0.8598, 0.7559, 0.8761]}, {"w": "“T-SNE", "b": [0.7595, 0.8598, 0.8091, 0.8761]}, {"w": "visual‐", "b": [0.8127, 0.8598, 0.8552, 0.8761]}, {"w": "ization", "b": [0.1587, 0.8749, 0.2022, 0.8912]}, {"w": "of", "b": [0.2058, 0.8749, 0.2186, 0.8912]}, {"w": "the", "b": [0.2222, 0.8749, 0.2423, 0.8912]}, {"w": "semantic", "b": [0.2459, 0.8749, 0.3026, 0.8912]}, {"w": "word", "b": [0.3062, 0.8749, 0.3394, 0.8912]}, {"w": "space.”", "b": [0.343, 0.8749, 0.3854, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 1-9. Example of a t-SNE visualization highlighting semantic clusters3", "words": [{"w": "Figure", "b": [0.1429, 0.424, 0.1943, 0.4456]}, {"w": "1-9.", "b": [0.1991, 0.424, 0.2308, 0.4456]}, {"w": "Example", "b": [0.2356, 0.424, 0.3068, 0.4456]}, {"w": "of", "b": [0.3116, 0.424, 0.3268, 0.4456]}, {"w": "a", "b": [0.3315, 0.424, 0.3418, 0.4456]}, {"w": "t-SNE", "b": [0.3465, 0.424, 0.3958, 0.4456]}, {"w": "visualization", "b": [0.4006, 0.424, 0.5053, 0.4456]}, {"w": "highlighting", "b": [0.5101, 0.424, 0.6056, 0.4456]}, {"w": "semantic", "b": [0.6104, 0.424, 0.6823, 0.4456]}, {"w": "clusters3", "b": [0.6871, 0.424, 0.7525, 0.4456]}]}, {"id": "b_2", "type": "paragraph", "text": "A related task is dimensionality reduction, in which the goal is to simplify the data without losing too much information. One way to do this is to merge several correla‐ ted features into one. For example, a car’s mileage may be very correlated with its age, so the dimensionality reduction algorithm will merge them into one feature that rep‐ resents the car’s wear and tear. This is called feature extraction.", "words": [{"w": "A", "b": [0.1429, 0.4614, 0.1573, 0.4828]}, {"w": "related", "b": [0.1648, 0.4614, 0.2216, 0.4828]}, {"w": "task", "b": [0.2291, 0.4614, 0.2626, 0.4828]}, {"w": "is", "b": [0.2702, 0.4614, 0.2834, 0.4828]}, {"w": "dimensionality", "b": [0.2909, 0.4612, 0.4112, 0.4828]}, {"w": "reduction,", "b": [0.4187, 0.4612, 0.5008, 0.4828]}, {"w": "in", "b": [0.5083, 0.4614, 0.5253, 0.4828]}, {"w": "which", "b": [0.5328, 0.4614, 0.5837, 0.4828]}, {"w": "the", "b": [0.5913, 0.4614, 0.6176, 0.4828]}, {"w": "goal", "b": [0.6251, 0.4614, 0.6599, 0.4828]}, {"w": "is", "b": [0.6675, 0.4614, 0.6807, 0.4828]}, {"w": "to", "b": [0.6882, 0.4614, 0.7052, 0.4828]}, {"w": "simplify", "b": [0.7127, 0.4614, 0.7805, 0.4828]}, {"w": "the", "b": [0.788, 0.4614, 0.8144, 0.4828]}, {"w": "data", "b": [0.8219, 0.4614, 0.8572, 0.4828]}, {"w": "without", "b": [0.1429, 0.4804, 0.2082, 0.5018]}, {"w": "losing", "b": [0.2136, 0.4804, 0.2638, 0.5018]}, {"w": "too", "b": [0.2691, 0.4804, 0.2967, 0.5018]}, {"w": "much", "b": [0.3021, 0.4804, 0.3497, 0.5018]}, {"w": "information.", "b": [0.355, 0.4804, 0.4611, 0.5018]}, {"w": "One", "b": [0.4664, 0.4804, 0.5022, 0.5018]}, {"w": "way", "b": [0.5075, 0.4804, 0.5401, 0.5018]}, {"w": "to", "b": [0.5454, 0.4804, 0.5624, 0.5018]}, {"w": "do", "b": [0.5677, 0.4804, 0.5894, 0.5018]}, {"w": "this", "b": [0.5947, 0.4804, 0.6254, 0.5018]}, {"w": "is", "b": [0.6307, 0.4804, 0.6439, 0.5018]}, {"w": "to", "b": [0.6492, 0.4804, 0.6662, 0.5018]}, {"w": "merge", "b": [0.6715, 0.4804, 0.7238, 0.5018]}, {"w": "several", "b": [0.7291, 0.4804, 0.7862, 0.5018]}, {"w": "correla‐", "b": [0.7916, 0.4804, 0.8571, 0.5018]}, {"w": "ted", "b": [0.1429, 0.4995, 0.1691, 0.5209]}, {"w": "features", "b": [0.1741, 0.4995, 0.2395, 0.5209]}, {"w": "into", "b": [0.2446, 0.4995, 0.2782, 0.5209]}, {"w": "one.", "b": [0.2832, 0.4995, 0.3189, 0.5209]}, {"w": "For", "b": [0.3239, 0.4995, 0.3529, 0.5209]}, {"w": "example,", "b": [0.358, 0.4995, 0.4322, 0.5209]}, {"w": "a", "b": [0.4373, 0.4995, 0.4464, 0.5209]}, {"w": "car’s", "b": [0.4515, 0.4995, 0.4875, 0.5209]}, {"w": "mileage", "b": [0.4926, 0.4995, 0.5571, 0.5209]}, {"w": "may", "b": [0.5622, 0.4995, 0.5975, 0.5209]}, {"w": "be", "b": [0.6026, 0.4995, 0.622, 0.5209]}, {"w": "very", "b": [0.6271, 0.4995, 0.6635, 0.5209]}, {"w": "correlated", "b": [0.6686, 0.4995, 0.7525, 0.5209]}, {"w": "with", "b": [0.7576, 0.4995, 0.7949, 0.5209]}, {"w": "its", "b": [0.8, 0.4995, 0.8196, 0.5209]}, {"w": "age,", "b": [0.8246, 0.4995, 0.8571, 0.5209]}, {"w": "so", "b": [0.1428, 0.5185, 0.1611, 0.5399]}, {"w": "the", "b": [0.1665, 0.5185, 0.1929, 0.5399]}, {"w": "dimensionality", "b": [0.1983, 0.5185, 0.3233, 0.5399]}, {"w": "reduction", "b": [0.3287, 0.5185, 0.4101, 0.5399]}, {"w": "algorithm", "b": [0.4155, 0.5185, 0.4982, 0.5399]}, {"w": "will", "b": [0.5036, 0.5185, 0.534, 0.5399]}, {"w": "merge", "b": [0.5394, 0.5185, 0.5916, 0.5399]}, {"w": "them", "b": [0.597, 0.5185, 0.6404, 0.5399]}, {"w": "into", "b": [0.6458, 0.5185, 0.6794, 0.5399]}, {"w": "one", "b": [0.6848, 0.5185, 0.7157, 0.5399]}, {"w": "feature", "b": [0.7211, 0.5185, 0.7788, 0.5399]}, {"w": "that", "b": [0.7842, 0.5185, 0.8168, 0.5399]}, {"w": "rep‐", "b": [0.8222, 0.5185, 0.8571, 0.5399]}, {"w": "resents", "b": [0.1429, 0.5376, 0.2009, 0.559]}, {"w": "the", "b": [0.2057, 0.5376, 0.232, 0.559]}, {"w": "car’s", "b": [0.2367, 0.5376, 0.2727, 0.559]}, {"w": "wear", "b": [0.2775, 0.5376, 0.3175, 0.559]}, {"w": "and", "b": [0.3222, 0.5376, 0.3537, 0.559]}, {"w": "tear.", "b": [0.3585, 0.5376, 0.394, 0.559]}, {"w": "This", "b": [0.3987, 0.5376, 0.4359, 0.559]}, {"w": "is", "b": [0.4407, 0.5376, 0.4539, 0.559]}, {"w": "called", "b": [0.4586, 0.5376, 0.507, 0.559]}, {"w": "feature", "b": [0.5117, 0.5373, 0.5677, 0.559]}, {"w": "extraction.", "b": [0.5725, 0.5373, 0.6594, 0.559]}]}, {"id": "b_3", "type": "paragraph", "text": "It is often a good idea to try to reduce the dimension of your train‐ ing data using a dimensionality reduction algorithm before you feed it to another Machine Learning algorithm (such as a super‐ vised learning algorithm). It will run much faster, the data will take up less disk and memory space, and in some cases it may also per‐ form better.", "words": [{"w": "It", "b": [0.2714, 0.5795, 0.283, 0.5991]}, {"w": "is", "b": [0.2878, 0.5795, 0.2999, 0.5991]}, {"w": "often", "b": [0.3047, 0.5795, 0.3444, 0.5991]}, {"w": "a", "b": [0.3493, 0.5795, 0.3576, 0.5991]}, {"w": "good", "b": [0.3625, 0.5795, 0.4009, 0.5991]}, {"w": "idea", "b": [0.4057, 0.5795, 0.4373, 0.5991]}, {"w": "to", "b": [0.4422, 0.5795, 0.4577, 0.5991]}, {"w": "try", "b": [0.4625, 0.5795, 0.4847, 0.5991]}, {"w": "to", "b": [0.4895, 0.5795, 0.5051, 0.5991]}, {"w": "reduce", "b": [0.5099, 0.5795, 0.5614, 0.5991]}, {"w": "the", "b": [0.5662, 0.5795, 0.5903, 0.5991]}, {"w": "dimension", "b": [0.5952, 0.5795, 0.6767, 0.5991]}, {"w": "of", "b": [0.6815, 0.5795, 0.6969, 0.5991]}, {"w": "your", "b": [0.7017, 0.5795, 0.7373, 0.5991]}, {"w": "train‐", "b": [0.7422, 0.5795, 0.7857, 0.5991]}, {"w": "ing", "b": [0.2714, 0.5969, 0.2958, 0.6165]}, {"w": "data", "b": [0.3042, 0.5969, 0.3364, 0.6165]}, {"w": "using", "b": [0.3447, 0.5969, 0.3863, 0.6165]}, {"w": "a", "b": [0.3946, 0.5969, 0.4029, 0.6165]}, {"w": "dimensionality", "b": [0.4112, 0.5969, 0.5256, 0.6165]}, {"w": "reduction", "b": [0.5339, 0.5969, 0.6083, 0.6165]}, {"w": "algorithm", "b": [0.6167, 0.5969, 0.6922, 0.6165]}, {"w": "before", "b": [0.7005, 0.5969, 0.7488, 0.6165]}, {"w": "you", "b": [0.7571, 0.5969, 0.7857, 0.6165]}, {"w": "feed", "b": [0.2714, 0.6143, 0.3033, 0.6339]}, {"w": "it", "b": [0.3104, 0.6143, 0.3213, 0.6339]}, {"w": "to", "b": [0.3283, 0.6143, 0.3439, 0.6339]}, {"w": "another", "b": [0.3509, 0.6143, 0.4106, 0.6339]}, {"w": "Machine", "b": [0.4176, 0.6143, 0.4845, 0.6339]}, {"w": "Learning", "b": [0.4915, 0.6143, 0.5602, 0.6339]}, {"w": "algorithm", "b": [0.5672, 0.6143, 0.6428, 0.6339]}, {"w": "(such", "b": [0.6499, 0.6143, 0.6918, 0.6339]}, {"w": "as", "b": [0.6988, 0.6143, 0.7142, 0.6339]}, {"w": "a", "b": [0.7213, 0.6143, 0.7296, 0.6339]}, {"w": "super‐", "b": [0.7367, 0.6143, 0.7857, 0.6339]}, {"w": "vised", "b": [0.2714, 0.6317, 0.3105, 0.6513]}, {"w": "learning", "b": [0.3154, 0.6317, 0.3786, 0.6513]}, {"w": "algorithm).", "b": [0.3835, 0.6317, 0.47, 0.6513]}, {"w": "It", "b": [0.4749, 0.6317, 0.4865, 0.6513]}, {"w": "will", "b": [0.4914, 0.6317, 0.5192, 0.6513]}, {"w": "run", "b": [0.5241, 0.6317, 0.5517, 0.6513]}, {"w": "much", "b": [0.5566, 0.6317, 0.6002, 0.6513]}, {"w": "faster,", "b": [0.6051, 0.6317, 0.6502, 0.6513]}, {"w": "the", "b": [0.6552, 0.6317, 0.6792, 0.6513]}, {"w": "data", "b": [0.6841, 0.6317, 0.7164, 0.6513]}, {"w": "will", "b": [0.7213, 0.6317, 0.7491, 0.6513]}, {"w": "take", "b": [0.754, 0.6317, 0.7857, 0.6513]}, {"w": "up", "b": [0.2714, 0.6492, 0.2915, 0.6687]}, {"w": "less", "b": [0.2967, 0.6492, 0.3236, 0.6687]}, {"w": "disk", "b": [0.3288, 0.6492, 0.3604, 0.6687]}, {"w": "and", "b": [0.3655, 0.6492, 0.3944, 0.6687]}, {"w": "memory", "b": [0.3996, 0.6492, 0.4649, 0.6687]}, {"w": "space,", "b": [0.4701, 0.6492, 0.5159, 0.6687]}, {"w": "and", "b": [0.5211, 0.6492, 0.55, 0.6687]}, {"w": "in", "b": [0.5551, 0.6492, 0.5707, 0.6687]}, {"w": "some", "b": [0.5758, 0.6492, 0.6162, 0.6687]}, {"w": "cases", "b": [0.6214, 0.6492, 0.6599, 0.6687]}, {"w": "it", "b": [0.6651, 0.6492, 0.676, 0.6687]}, {"w": "may", "b": [0.6812, 0.6492, 0.7135, 0.6687]}, {"w": "also", "b": [0.7187, 0.6492, 0.7486, 0.6687]}, {"w": "per‐", "b": [0.7538, 0.6492, 0.7857, 0.6687]}, {"w": "form", "b": [0.2714, 0.6666, 0.3094, 0.6861]}, {"w": "better.", "b": [0.3138, 0.6666, 0.3614, 0.6861]}]}, {"id": "b_4", "type": "paragraph", "text": "Yet another important unsupervised task is anomaly detection—for example, detect‐ ing unusual credit card transactions to prevent fraud, catching manufacturing defects, or automatically removing outliers from a dataset before feeding it to another learn‐ ing algorithm. The system is shown mostly normal instances during training, so it learns to recognize them and when it sees a new instance it can tell whether it looks", "words": [{"w": "Yet", "b": [0.1429, 0.7064, 0.1687, 0.7279]}, {"w": "another", "b": [0.1754, 0.7064, 0.2406, 0.7279]}, {"w": "important", "b": [0.2473, 0.7064, 0.3317, 0.7279]}, {"w": "unsupervised", "b": [0.3384, 0.7064, 0.4504, 0.7279]}, {"w": "task", "b": [0.457, 0.7064, 0.4905, 0.7279]}, {"w": "is", "b": [0.4972, 0.7064, 0.5104, 0.7279]}, {"w": "anomaly", "b": [0.5171, 0.7062, 0.5878, 0.7279]}, {"w": "detection—for", "b": [0.5945, 0.7062, 0.7119, 0.7279]}, {"w": "example,", "b": [0.7185, 0.7064, 0.7928, 0.7279]}, {"w": "detect‐", "b": [0.7995, 0.7064, 0.8572, 0.7279]}, {"w": "ing", "b": [0.1429, 0.7255, 0.1696, 0.7469]}, {"w": "unusual", "b": [0.1743, 0.7255, 0.2406, 0.7469]}, {"w": "credit", "b": [0.2453, 0.7255, 0.2936, 0.7469]}, {"w": "card", "b": [0.2984, 0.7255, 0.335, 0.7469]}, {"w": "transactions", "b": [0.3398, 0.7255, 0.4416, 0.7469]}, {"w": "to", "b": [0.4463, 0.7255, 0.4633, 0.7469]}, {"w": "prevent", "b": [0.468, 0.7255, 0.5314, 0.7469]}, {"w": "fraud,", "b": [0.5361, 0.7255, 0.5856, 0.7469]}, {"w": "catching", "b": [0.5903, 0.7255, 0.6609, 0.7469]}, {"w": "manufacturing", "b": [0.6656, 0.7255, 0.7899, 0.7469]}, {"w": "defects,", "b": [0.7946, 0.7255, 0.8571, 0.7469]}, {"w": "or", "b": [0.1429, 0.7445, 0.1612, 0.766]}, {"w": "automatically", "b": [0.1672, 0.7445, 0.2798, 0.766]}, {"w": "removing", "b": [0.2859, 0.7445, 0.3665, 0.766]}, {"w": "outliers", "b": [0.3726, 0.7445, 0.4357, 0.766]}, {"w": "from", "b": [0.4417, 0.7445, 0.4833, 0.766]}, {"w": "a", "b": [0.4893, 0.7445, 0.4985, 0.766]}, {"w": "dataset", "b": [0.5045, 0.7445, 0.5626, 0.766]}, {"w": "before", "b": [0.5686, 0.7445, 0.6214, 0.766]}, {"w": "feeding", "b": [0.6275, 0.7445, 0.6891, 0.766]}, {"w": "it", "b": [0.6951, 0.7445, 0.707, 0.766]}, {"w": "to", "b": [0.7131, 0.7445, 0.73, 0.766]}, {"w": "another", "b": [0.7361, 0.7445, 0.8013, 0.766]}, {"w": "learn‐", "b": [0.8073, 0.7445, 0.8571, 0.766]}, {"w": "ing", "b": [0.1429, 0.7636, 0.1696, 0.785]}, {"w": "algorithm.", "b": [0.177, 0.7636, 0.2644, 0.785]}, {"w": "The", "b": [0.2718, 0.7636, 0.3046, 0.785]}, {"w": "system", "b": [0.312, 0.7636, 0.3692, 0.785]}, {"w": "is", "b": [0.3766, 0.7636, 0.3898, 0.785]}, {"w": "shown", "b": [0.3972, 0.7636, 0.4523, 0.785]}, {"w": "mostly", "b": [0.4597, 0.7636, 0.5162, 0.785]}, {"w": "normal", "b": [0.5236, 0.7636, 0.5848, 0.785]}, {"w": "instances", "b": [0.5923, 0.7636, 0.6691, 0.785]}, {"w": "during", "b": [0.6765, 0.7636, 0.733, 0.785]}, {"w": "training,", "b": [0.7404, 0.7636, 0.8121, 0.785]}, {"w": "so", "b": [0.8195, 0.7636, 0.8378, 0.785]}, {"w": "it", "b": [0.8452, 0.7636, 0.8571, 0.785]}, {"w": "learns", "b": [0.1428, 0.7826, 0.1929, 0.804]}, {"w": "to", "b": [0.1989, 0.7826, 0.2159, 0.804]}, {"w": "recognize", "b": [0.222, 0.7826, 0.3023, 0.804]}, {"w": "them", "b": [0.3084, 0.7826, 0.3518, 0.804]}, {"w": "and", "b": [0.3578, 0.7826, 0.3893, 0.804]}, {"w": "when", "b": [0.3954, 0.7826, 0.441, 0.804]}, {"w": "it", "b": [0.4471, 0.7826, 0.459, 0.804]}, {"w": "sees", "b": [0.4651, 0.7826, 0.4981, 0.804]}, {"w": "a", "b": [0.5041, 0.7826, 0.5133, 0.804]}, {"w": "new", "b": [0.5193, 0.7826, 0.5538, 0.804]}, {"w": "instance", "b": [0.5599, 0.7826, 0.6291, 0.804]}, {"w": "it", "b": [0.6351, 0.7826, 0.647, 0.804]}, {"w": "can", "b": [0.6531, 0.7826, 0.6824, 0.804]}, {"w": "tell", "b": [0.6885, 0.7826, 0.7142, 0.804]}, {"w": "whether", "b": [0.7203, 0.7826, 0.7886, 0.804]}, {"w": "it", "b": [0.7947, 0.7826, 0.8066, 0.804]}, {"w": "looks", "b": [0.8126, 0.7826, 0.8571, 0.804]}]}, {"id": "b_5", "type": "paragraph", "text": "12 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "12", "b": [0.1428, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.337, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 39, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "4 That’s when the system works perfectly. In practice it often creates a few clusters per person, and sometimes mixes up two people who look alike, so you need to provide a few labels per person and manually clean up some clusters.", "words": [{"w": "4", "b": [0.1451, 0.8462, 0.1518, 0.8604]}, {"w": "That’s", "b": [0.1587, 0.8447, 0.1959, 0.861]}, {"w": "when", "b": [0.1995, 0.8447, 0.2343, 0.861]}, {"w": "the", "b": [0.2379, 0.8447, 0.258, 0.861]}, {"w": "system", "b": [0.2616, 0.8447, 0.3051, 0.861]}, {"w": "works", "b": [0.3087, 0.8447, 0.3473, 0.861]}, {"w": "perfectly.", "b": [0.3509, 0.8447, 0.4086, 0.861]}, {"w": "In", "b": [0.4122, 0.8447, 0.4263, 0.861]}, {"w": "practice", "b": [0.4299, 0.8447, 0.4803, 0.861]}, {"w": "it", "b": [0.4839, 0.8447, 0.493, 0.861]}, {"w": "often", "b": [0.4966, 0.8447, 0.5297, 0.861]}, {"w": "creates", "b": [0.5333, 0.8447, 0.5767, 0.861]}, {"w": "a", "b": [0.5803, 0.8447, 0.5873, 0.861]}, {"w": "few", "b": [0.5909, 0.8447, 0.6132, 0.861]}, {"w": "clusters", "b": [0.6168, 0.8447, 0.6651, 0.861]}, {"w": "per", "b": [0.6687, 0.8447, 0.6897, 0.861]}, {"w": "person,", "b": [0.6933, 0.8447, 0.7404, 0.861]}, {"w": "and", "b": [0.744, 0.8447, 0.7681, 0.861]}, {"w": "sometimes", "b": [0.7717, 0.8447, 0.84, 0.861]}, {"w": "mixes", "b": [0.1587, 0.8598, 0.196, 0.8761]}, {"w": "up", "b": [0.1997, 0.8598, 0.2164, 0.8761]}, {"w": "two", "b": [0.22, 0.8598, 0.2438, 0.8761]}, {"w": "people", "b": [0.2474, 0.8598, 0.2897, 0.8761]}, {"w": "who", "b": [0.2933, 0.8598, 0.3207, 0.8761]}, {"w": "look", "b": [0.3243, 0.8598, 0.3524, 0.8761]}, {"w": "alike,", "b": [0.356, 0.8598, 0.3895, 0.8761]}, {"w": "so", "b": [0.3931, 0.8598, 0.407, 0.8761]}, {"w": "you", "b": [0.4106, 0.8598, 0.4344, 0.8761]}, {"w": "need", "b": [0.438, 0.8598, 0.4686, 0.8761]}, {"w": "to", "b": [0.4722, 0.8598, 0.4851, 0.8761]}, {"w": "provide", "b": [0.4887, 0.8598, 0.5377, 0.8761]}, {"w": "a", "b": [0.5413, 0.8598, 0.5483, 0.8761]}, {"w": "few", "b": [0.5519, 0.8598, 0.5742, 0.8761]}, {"w": "labels", "b": [0.5778, 0.8598, 0.6135, 0.8761]}, {"w": "per", "b": [0.6171, 0.8598, 0.638, 0.8761]}, {"w": "person", "b": [0.6416, 0.8598, 0.6852, 0.8761]}, {"w": "and", "b": [0.6888, 0.8598, 0.7128, 0.8761]}, {"w": "manually", "b": [0.7164, 0.8598, 0.7755, 0.8761]}, {"w": "clean", "b": [0.7791, 0.8598, 0.8122, 0.8761]}, {"w": "up", "b": [0.8158, 0.8598, 0.8326, 0.8761]}, {"w": "some", "b": [0.1587, 0.8749, 0.1924, 0.8912]}, {"w": "clusters.", "b": [0.196, 0.8749, 0.2479, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "like a normal one or whether it is likely an anomaly (see Figure 1-10). A very similar task is novelty detection: the difference is that novelty detection algorithms expect to see only normal data during training, while anomaly detection algorithms are usually more tolerant, they can often perform well even with a small percentage of outliers in the training set.", "words": [{"w": "like", "b": [0.1429, 0.0791, 0.1729, 0.1005]}, {"w": "a", "b": [0.1785, 0.0791, 0.1876, 0.1005]}, {"w": "normal", "b": [0.1931, 0.0791, 0.2544, 0.1005]}, {"w": "one", "b": [0.2599, 0.0791, 0.2908, 0.1005]}, {"w": "or", "b": [0.2964, 0.0791, 0.3147, 0.1005]}, {"w": "whether", "b": [0.3203, 0.0791, 0.3886, 0.1005]}, {"w": "it", "b": [0.3941, 0.0791, 0.4061, 0.1005]}, {"w": "is", "b": [0.4116, 0.0791, 0.4248, 0.1005]}, {"w": "likely", "b": [0.4304, 0.0791, 0.4753, 0.1005]}, {"w": "an", "b": [0.4808, 0.0791, 0.5013, 0.1005]}, {"w": "anomaly", "b": [0.5069, 0.0791, 0.5791, 0.1005]}, {"w": "(see", "b": [0.5847, 0.0791, 0.6172, 0.1005]}, {"w": "Figure", "b": [0.6228, 0.0791, 0.6768, 0.1005]}, {"w": "1-10).", "b": [0.6823, 0.0791, 0.7317, 0.1005]}, {"w": "A", "b": [0.7372, 0.0791, 0.7516, 0.1005]}, {"w": "very", "b": [0.7572, 0.0791, 0.7936, 0.1005]}, {"w": "similar", "b": [0.7991, 0.0791, 0.8571, 0.1005]}, {"w": "task", "b": [0.1429, 0.0981, 0.1763, 0.1195]}, {"w": "is", "b": [0.1826, 0.0981, 0.1958, 0.1195]}, {"w": "novelty", "b": [0.2021, 0.0979, 0.2603, 0.1195]}, {"w": "detection:", "b": [0.2666, 0.0979, 0.3449, 0.1195]}, {"w": "the", "b": [0.3512, 0.0981, 0.3775, 0.1195]}, {"w": "difference", "b": [0.3837, 0.0981, 0.4672, 0.1195]}, {"w": "is", "b": [0.4734, 0.0981, 0.4866, 0.1195]}, {"w": "that", "b": [0.4929, 0.0981, 0.5255, 0.1195]}, {"w": "novelty", "b": [0.5317, 0.0981, 0.5934, 0.1195]}, {"w": "detection", "b": [0.5997, 0.0981, 0.6775, 0.1195]}, {"w": "algorithms", "b": [0.6838, 0.0981, 0.774, 0.1195]}, {"w": "expect", "b": [0.7803, 0.0981, 0.8339, 0.1195]}, {"w": "to", "b": [0.8402, 0.0981, 0.8572, 0.1195]}, {"w": "see", "b": [0.1429, 0.1172, 0.1682, 0.1386]}, {"w": "only", "b": [0.1734, 0.1172, 0.2103, 0.1386]}, {"w": "normal", "b": [0.2155, 0.1172, 0.2767, 0.1386]}, {"w": "data", "b": [0.2819, 0.1172, 0.3171, 0.1386]}, {"w": "during", "b": [0.3223, 0.1172, 0.3789, 0.1386]}, {"w": "training,", "b": [0.3841, 0.1172, 0.4558, 0.1386]}, {"w": "while", "b": [0.461, 0.1172, 0.5061, 0.1386]}, {"w": "anomaly", "b": [0.5113, 0.1172, 0.5835, 0.1386]}, {"w": "detection", "b": [0.5887, 0.1172, 0.6665, 0.1386]}, {"w": "algorithms", "b": [0.6717, 0.1172, 0.762, 0.1386]}, {"w": "are", "b": [0.7672, 0.1172, 0.7929, 0.1386]}, {"w": "usually", "b": [0.7981, 0.1172, 0.8571, 0.1386]}, {"w": "more", "b": [0.1429, 0.1362, 0.1871, 0.1576]}, {"w": "tolerant,", "b": [0.1922, 0.1362, 0.2623, 0.1576]}, {"w": "they", "b": [0.2675, 0.1362, 0.3034, 0.1576]}, {"w": "can", "b": [0.3085, 0.1362, 0.3378, 0.1576]}, {"w": "often", "b": [0.343, 0.1362, 0.3864, 0.1576]}, {"w": "perform", "b": [0.3915, 0.1362, 0.4606, 0.1576]}, {"w": "well", "b": [0.4657, 0.1362, 0.4994, 0.1576]}, {"w": "even", "b": [0.5045, 0.1362, 0.5432, 0.1576]}, {"w": "with", "b": [0.5484, 0.1362, 0.5857, 0.1576]}, {"w": "a", "b": [0.5908, 0.1362, 0.6, 0.1576]}, {"w": "small", "b": [0.6051, 0.1362, 0.6495, 0.1576]}, {"w": "percentage", "b": [0.6546, 0.1362, 0.7449, 0.1576]}, {"w": "of", "b": [0.75, 0.1362, 0.7668, 0.1576]}, {"w": "outliers", "b": [0.7719, 0.1362, 0.835, 0.1576]}, {"w": "in", "b": [0.8402, 0.1362, 0.8571, 0.1576]}, {"w": "the", "b": [0.1428, 0.1553, 0.1692, 0.1767]}, {"w": "training", "b": [0.1739, 0.1553, 0.2408, 0.1767]}, {"w": "set.", "b": [0.2456, 0.1553, 0.2732, 0.1767]}]}, {"id": "b_2", "type": "equation", "text": "Figure 1-10. Anomaly detection", "words": [{"w": "Figure", "b": [0.1428, 0.3898, 0.1943, 0.4114]}, {"w": "1-10.", "b": [0.1991, 0.3898, 0.2407, 0.4114]}, {"w": "Anomaly", "b": [0.2455, 0.3898, 0.3202, 0.4114]}, {"w": "detection", "b": [0.3249, 0.3898, 0.3985, 0.4114]}]}, {"id": "b_3", "type": "paragraph", "text": "Finally, another common unsupervised task is association rule learning, in which the goal is to dig into large amounts of data and discover interesting relations between attributes. For example, suppose you own a supermarket. Running an association rule on your sales logs may reveal that people who purchase barbecue sauce and potato chips also tend to buy steak. Thus, you may want to place these items close to each other.", "words": [{"w": "Finally,", "b": [0.1428, 0.4272, 0.2033, 0.4486]}, {"w": "another", "b": [0.2094, 0.4272, 0.2746, 0.4486]}, {"w": "common", "b": [0.2807, 0.4272, 0.3563, 0.4486]}, {"w": "unsupervised", "b": [0.3623, 0.4272, 0.4743, 0.4486]}, {"w": "task", "b": [0.4804, 0.4272, 0.5139, 0.4486]}, {"w": "is", "b": [0.5199, 0.4272, 0.5331, 0.4486]}, {"w": "association", "b": [0.5392, 0.427, 0.6288, 0.4486]}, {"w": "rule", "b": [0.6349, 0.427, 0.6672, 0.4486]}, {"w": "learning,", "b": [0.6733, 0.427, 0.7447, 0.4486]}, {"w": "in", "b": [0.7508, 0.4272, 0.7678, 0.4486]}, {"w": "which", "b": [0.7738, 0.4272, 0.8247, 0.4486]}, {"w": "the", "b": [0.8308, 0.4272, 0.8571, 0.4486]}, {"w": "goal", "b": [0.1429, 0.4462, 0.1777, 0.4676]}, {"w": "is", "b": [0.1847, 0.4462, 0.1979, 0.4676]}, {"w": "to", "b": [0.205, 0.4462, 0.222, 0.4676]}, {"w": "dig", "b": [0.229, 0.4462, 0.2554, 0.4676]}, {"w": "into", "b": [0.2624, 0.4462, 0.296, 0.4676]}, {"w": "large", "b": [0.3031, 0.4462, 0.3438, 0.4676]}, {"w": "amounts", "b": [0.3509, 0.4462, 0.4238, 0.4676]}, {"w": "of", "b": [0.4308, 0.4462, 0.4476, 0.4676]}, {"w": "data", "b": [0.4547, 0.4462, 0.4899, 0.4676]}, {"w": "and", "b": [0.497, 0.4462, 0.5285, 0.4676]}, {"w": "discover", "b": [0.5356, 0.4462, 0.6055, 0.4676]}, {"w": "interesting", "b": [0.6125, 0.4462, 0.7017, 0.4676]}, {"w": "relations", "b": [0.7087, 0.4462, 0.7809, 0.4676]}, {"w": "between", "b": [0.788, 0.4462, 0.8571, 0.4676]}, {"w": "attributes.", "b": [0.1429, 0.4653, 0.2269, 0.4867]}, {"w": "For", "b": [0.2317, 0.4653, 0.2607, 0.4867]}, {"w": "example,", "b": [0.2656, 0.4653, 0.3399, 0.4867]}, {"w": "suppose", "b": [0.3447, 0.4653, 0.4124, 0.4867]}, {"w": "you", "b": [0.4173, 0.4653, 0.4485, 0.4867]}, {"w": "own", "b": [0.4534, 0.4653, 0.4897, 0.4867]}, {"w": "a", "b": [0.4945, 0.4653, 0.5037, 0.4867]}, {"w": "supermarket.", "b": [0.5085, 0.4653, 0.619, 0.4867]}, {"w": "Running", "b": [0.6238, 0.4653, 0.6969, 0.4867]}, {"w": "an", "b": [0.7018, 0.4653, 0.7223, 0.4867]}, {"w": "association", "b": [0.7272, 0.4653, 0.8194, 0.4867]}, {"w": "rule", "b": [0.8242, 0.4653, 0.8571, 0.4867]}, {"w": "on", "b": [0.1429, 0.4843, 0.1649, 0.5057]}, {"w": "your", "b": [0.1719, 0.4843, 0.2109, 0.5057]}, {"w": "sales", "b": [0.2179, 0.4843, 0.2565, 0.5057]}, {"w": "logs", "b": [0.2635, 0.4843, 0.2968, 0.5057]}, {"w": "may", "b": [0.3038, 0.4843, 0.3392, 0.5057]}, {"w": "reveal", "b": [0.3462, 0.4843, 0.3957, 0.5057]}, {"w": "that", "b": [0.4027, 0.4843, 0.4353, 0.5057]}, {"w": "people", "b": [0.4423, 0.4843, 0.4978, 0.5057]}, {"w": "who", "b": [0.5048, 0.4843, 0.5408, 0.5057]}, {"w": "purchase", "b": [0.5478, 0.4843, 0.6231, 0.5057]}, {"w": "barbecue", "b": [0.6302, 0.4843, 0.7058, 0.5057]}, {"w": "sauce", "b": [0.7128, 0.4843, 0.7579, 0.5057]}, {"w": "and", "b": [0.7649, 0.4843, 0.7965, 0.5057]}, {"w": "potato", "b": [0.8035, 0.4843, 0.8571, 0.5057]}, {"w": "chips", "b": [0.1429, 0.5034, 0.187, 0.5248]}, {"w": "also", "b": [0.1932, 0.5034, 0.2259, 0.5248]}, {"w": "tend", "b": [0.2321, 0.5034, 0.2697, 0.5248]}, {"w": "to", "b": [0.2759, 0.5034, 0.2929, 0.5248]}, {"w": "buy", "b": [0.2991, 0.5034, 0.3303, 0.5248]}, {"w": "steak.", "b": [0.3365, 0.5034, 0.3836, 0.5248]}, {"w": "Thus,", "b": [0.3898, 0.5034, 0.4369, 0.5248]}, {"w": "you", "b": [0.4431, 0.5034, 0.4743, 0.5248]}, {"w": "may", "b": [0.4806, 0.5034, 0.516, 0.5248]}, {"w": "want", "b": [0.5222, 0.5034, 0.563, 0.5248]}, {"w": "to", "b": [0.5692, 0.5034, 0.5862, 0.5248]}, {"w": "place", "b": [0.5924, 0.5034, 0.6354, 0.5248]}, {"w": "these", "b": [0.6416, 0.5034, 0.6844, 0.5248]}, {"w": "items", "b": [0.6906, 0.5034, 0.7361, 0.5248]}, {"w": "close", "b": [0.7424, 0.5034, 0.7836, 0.5248]}, {"w": "to", "b": [0.7898, 0.5034, 0.8068, 0.5248]}, {"w": "each", "b": [0.813, 0.5034, 0.8509, 0.5248]}, {"w": "other.", "b": [0.1429, 0.5224, 0.191, 0.5438]}]}, {"id": "b_4", "type": "paragraph", "text": "Semisupervised learning", "words": [{"w": "Semisupervised", "b": [0.1429, 0.5597, 0.2613, 0.5807]}, {"w": "learning", "b": [0.265, 0.5597, 0.3285, 0.5807]}]}, {"id": "b_5", "type": "paragraph", "text": "Some algorithms can deal with partially labeled training data, usually a lot of unla‐ beled data and a little bit of labeled data. This is called semisupervised learning (Figure 1-11).", "words": [{"w": "Some", "b": [0.1429, 0.5863, 0.1893, 0.6077]}, {"w": "algorithms", "b": [0.1962, 0.5863, 0.2865, 0.6077]}, {"w": "can", "b": [0.2935, 0.5863, 0.3228, 0.6077]}, {"w": "deal", "b": [0.3298, 0.5863, 0.364, 0.6077]}, {"w": "with", "b": [0.371, 0.5863, 0.4083, 0.6077]}, {"w": "partially", "b": [0.4152, 0.5863, 0.4842, 0.6077]}, {"w": "labeled", "b": [0.4912, 0.5863, 0.5501, 0.6077]}, {"w": "training", "b": [0.5571, 0.5863, 0.624, 0.6077]}, {"w": "data,", "b": [0.631, 0.5863, 0.671, 0.6077]}, {"w": "usually", "b": [0.6779, 0.5863, 0.7369, 0.6077]}, {"w": "a", "b": [0.7439, 0.5863, 0.753, 0.6077]}, {"w": "lot", "b": [0.7599, 0.5863, 0.7822, 0.6077]}, {"w": "of", "b": [0.7891, 0.5863, 0.8059, 0.6077]}, {"w": "unla‐", "b": [0.8129, 0.5863, 0.8572, 0.6077]}, {"w": "beled", "b": [0.1429, 0.6054, 0.1874, 0.6268]}, {"w": "data", "b": [0.1974, 0.6054, 0.2326, 0.6268]}, {"w": "and", "b": [0.2426, 0.6054, 0.2742, 0.6268]}, {"w": "a", "b": [0.2841, 0.6054, 0.2933, 0.6268]}, {"w": "little", "b": [0.3033, 0.6054, 0.341, 0.6268]}, {"w": "bit", "b": [0.3509, 0.6054, 0.3734, 0.6268]}, {"w": "of", "b": [0.3834, 0.6054, 0.4002, 0.6268]}, {"w": "labeled", "b": [0.4102, 0.6054, 0.4692, 0.6268]}, {"w": "data.", "b": [0.4791, 0.6054, 0.5191, 0.6268]}, {"w": "This", "b": [0.5291, 0.6054, 0.5663, 0.6268]}, {"w": "is", "b": [0.5763, 0.6054, 0.5895, 0.6268]}, {"w": "called", "b": [0.5995, 0.6054, 0.6479, 0.6268]}, {"w": "semisupervised", "b": [0.6578, 0.6052, 0.7804, 0.6268]}, {"w": "learning", "b": [0.7904, 0.6052, 0.8571, 0.6268]}, {"w": "(Figure", "b": [0.1429, 0.6244, 0.2041, 0.6458]}, {"w": "1-11).", "b": [0.2088, 0.6244, 0.2582, 0.6458]}]}, {"id": "b_6", "type": "paragraph", "text": "Some photo-hosting services, such as Google Photos, are good examples of this. Once you upload all your family photos to the service, it automatically recognizes that the same person A shows up in photos 1, 5, and 11, while another person B shows up in photos 2, 5, and 7. This is the unsupervised part of the algorithm (clustering). Now all the system needs is for you to tell it who these people are. Just one label per person,4", "words": [{"w": "Some", "b": [0.1429, 0.6525, 0.1893, 0.674]}, {"w": "photo-hosting", "b": [0.1941, 0.6525, 0.3136, 0.674]}, {"w": "services,", "b": [0.3184, 0.6525, 0.3885, 0.674]}, {"w": "such", "b": [0.3932, 0.6525, 0.4319, 0.674]}, {"w": "as", "b": [0.4366, 0.6525, 0.4534, 0.674]}, {"w": "Google", "b": [0.4586, 0.6525, 0.5186, 0.674]}, {"w": "Photos,", "b": [0.5234, 0.6525, 0.5863, 0.674]}, {"w": "are", "b": [0.5911, 0.6525, 0.6169, 0.674]}, {"w": "good", "b": [0.6217, 0.6525, 0.6637, 0.674]}, {"w": "examples", "b": [0.6686, 0.6525, 0.7457, 0.674]}, {"w": "of", "b": [0.7506, 0.6525, 0.7674, 0.674]}, {"w": "this.", "b": [0.7722, 0.6525, 0.8077, 0.674]}, {"w": "Once", "b": [0.8125, 0.6525, 0.8571, 0.674]}, {"w": "you", "b": [0.1429, 0.6716, 0.1741, 0.693]}, {"w": "upload", "b": [0.1802, 0.6716, 0.2382, 0.693]}, {"w": "all", "b": [0.2443, 0.6716, 0.264, 0.693]}, {"w": "your", "b": [0.27, 0.6716, 0.309, 0.693]}, {"w": "family", "b": [0.3151, 0.6716, 0.3679, 0.693]}, {"w": "photos", "b": [0.374, 0.6716, 0.4313, 0.693]}, {"w": "to", "b": [0.4373, 0.6716, 0.4543, 0.693]}, {"w": "the", "b": [0.4604, 0.6716, 0.4867, 0.693]}, {"w": "service,", "b": [0.4928, 0.6716, 0.5553, 0.693]}, {"w": "it", "b": [0.5614, 0.6716, 0.5733, 0.693]}, {"w": "automatically", "b": [0.5794, 0.6716, 0.692, 0.693]}, {"w": "recognizes", "b": [0.6981, 0.6716, 0.7861, 0.693]}, {"w": "that", "b": [0.7921, 0.6716, 0.8247, 0.693]}, {"w": "the", "b": [0.8308, 0.6716, 0.8571, 0.693]}, {"w": "same", "b": [0.1429, 0.6906, 0.1856, 0.7121]}, {"w": "person", "b": [0.1913, 0.6906, 0.2484, 0.7121]}, {"w": "A", "b": [0.2541, 0.6906, 0.2685, 0.7121]}, {"w": "shows", "b": [0.2742, 0.6906, 0.3255, 0.7121]}, {"w": "up", "b": [0.3312, 0.6906, 0.3532, 0.7121]}, {"w": "in", "b": [0.3589, 0.6906, 0.3758, 0.7121]}, {"w": "photos", "b": [0.3815, 0.6906, 0.4388, 0.7121]}, {"w": "1,", "b": [0.4445, 0.6906, 0.4592, 0.7121]}, {"w": "5,", "b": [0.4649, 0.6906, 0.4797, 0.7121]}, {"w": "and", "b": [0.4854, 0.6906, 0.5169, 0.7121]}, {"w": "11,", "b": [0.5226, 0.6906, 0.5473, 0.7121]}, {"w": "while", "b": [0.553, 0.6906, 0.5981, 0.7121]}, {"w": "another", "b": [0.6038, 0.6906, 0.669, 0.7121]}, {"w": "person", "b": [0.6747, 0.6906, 0.7319, 0.7121]}, {"w": "B", "b": [0.7376, 0.6906, 0.7498, 0.7121]}, {"w": "shows", "b": [0.7555, 0.6906, 0.8068, 0.7121]}, {"w": "up", "b": [0.8125, 0.6906, 0.8345, 0.7121]}, {"w": "in", "b": [0.8402, 0.6906, 0.8572, 0.7121]}, {"w": "photos", "b": [0.1429, 0.7097, 0.2002, 0.7311]}, {"w": "2,", "b": [0.2049, 0.7097, 0.2196, 0.7311]}, {"w": "5,", "b": [0.2244, 0.7097, 0.2391, 0.7311]}, {"w": "and", "b": [0.2438, 0.7097, 0.2754, 0.7311]}, {"w": "7.", "b": [0.2801, 0.7097, 0.2949, 0.7311]}, {"w": "This", "b": [0.2996, 0.7097, 0.3368, 0.7311]}, {"w": "is", "b": [0.3415, 0.7097, 0.3548, 0.7311]}, {"w": "the", "b": [0.3595, 0.7097, 0.3858, 0.7311]}, {"w": "unsupervised", "b": [0.3905, 0.7097, 0.5025, 0.7311]}, {"w": "part", "b": [0.5073, 0.7097, 0.5414, 0.7311]}, {"w": "of", "b": [0.5462, 0.7097, 0.5629, 0.7311]}, {"w": "the", "b": [0.5677, 0.7097, 0.594, 0.7311]}, {"w": "algorithm", "b": [0.5987, 0.7097, 0.6814, 0.7311]}, {"w": "(clustering).", "b": [0.6861, 0.7097, 0.7877, 0.7311]}, {"w": "Now", "b": [0.7925, 0.7097, 0.8323, 0.7311]}, {"w": "all", "b": [0.837, 0.7097, 0.8567, 0.7311]}, {"w": "the", "b": [0.1429, 0.7287, 0.1692, 0.7502]}, {"w": "system", "b": [0.175, 0.7287, 0.2321, 0.7502]}, {"w": "needs", "b": [0.2379, 0.7287, 0.2856, 0.7502]}, {"w": "is", "b": [0.2914, 0.7287, 0.3046, 0.7502]}, {"w": "for", "b": [0.3104, 0.7287, 0.3349, 0.7502]}, {"w": "you", "b": [0.3407, 0.7287, 0.372, 0.7502]}, {"w": "to", "b": [0.3777, 0.7287, 0.3947, 0.7502]}, {"w": "tell", "b": [0.4005, 0.7287, 0.4263, 0.7502]}, {"w": "it", "b": [0.432, 0.7287, 0.444, 0.7502]}, {"w": "who", "b": [0.4498, 0.7287, 0.4858, 0.7502]}, {"w": "these", "b": [0.4916, 0.7287, 0.5344, 0.7502]}, {"w": "people", "b": [0.5402, 0.7287, 0.5956, 0.7502]}, {"w": "are.", "b": [0.6014, 0.7287, 0.6319, 0.7502]}, {"w": "Just", "b": [0.6376, 0.7287, 0.6689, 0.7502]}, {"w": "one", "b": [0.6747, 0.7287, 0.7056, 0.7502]}, {"w": "label", "b": [0.7113, 0.7287, 0.7505, 0.7502]}, {"w": "per", "b": [0.7562, 0.7287, 0.7837, 0.7502]}, {"w": "person,4", "b": [0.7895, 0.7287, 0.8571, 0.7502]}]}, {"id": "b_7", "type": "paragraph", "text": "and it is able to name everyone in every photo, which is useful for searching photos.", "words": [{"w": "and", "b": [0.1429, 0.7478, 0.1744, 0.7692]}, {"w": "it", "b": [0.1791, 0.7478, 0.1911, 0.7692]}, {"w": "is", "b": [0.1958, 0.7478, 0.209, 0.7692]}, {"w": "able", "b": [0.2138, 0.7478, 0.2476, 0.7692]}, {"w": "to", "b": [0.2523, 0.7478, 0.2693, 0.7692]}, {"w": "name", "b": [0.274, 0.7478, 0.3205, 0.7692]}, {"w": "everyone", "b": [0.3252, 0.7478, 0.4014, 0.7692]}, {"w": "in", "b": [0.4061, 0.7478, 0.4231, 0.7692]}, {"w": "every", "b": [0.4278, 0.7478, 0.473, 0.7692]}, {"w": "photo,", "b": [0.4778, 0.7478, 0.5316, 0.7692]}, {"w": "which", "b": [0.5363, 0.7478, 0.5872, 0.7692]}, {"w": "is", "b": [0.5919, 0.7478, 0.6052, 0.7692]}, {"w": "useful", "b": [0.6099, 0.7478, 0.66, 0.7692]}, {"w": "for", "b": [0.6647, 0.7478, 0.6892, 0.7692]}, {"w": "searching", "b": [0.6939, 0.7478, 0.774, 0.7692]}, {"w": "photos.", "b": [0.7787, 0.7478, 0.8408, 0.7692]}]}, {"id": "b_8", "type": "paragraph", "text": "Types of Machine Learning Systems | 13", "words": [{"w": "Types", "b": [0.5961, 0.9225, 0.6295, 0.9388]}, {"w": "of", "b": [0.6323, 0.9225, 0.6443, 0.9388]}, {"w": "Machine", "b": [0.6471, 0.9225, 0.6971, 0.9388]}, {"w": "Learning", "b": [0.6999, 0.9225, 0.7521, 0.9388]}, {"w": "Systems", "b": [0.7549, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "13", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 40, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 1-11. Semisupervised learning", "words": [{"w": "Figure", "b": [0.1429, 0.2855, 0.1943, 0.3071]}, {"w": "1-11.", "b": [0.1991, 0.2855, 0.2407, 0.3071]}, {"w": "Semisupervised", "b": [0.2455, 0.2855, 0.3709, 0.3071]}, {"w": "learning", "b": [0.3756, 0.2855, 0.4424, 0.3071]}]}, {"id": "b_1", "type": "paragraph", "text": "Most semisupervised learning algorithms are combinations of unsupervised and supervised algorithms. For example, deep belief networks (DBNs) are based on unsu‐ pervised components called restricted Boltzmann machines (RBMs) stacked on top of one another. RBMs are trained sequentially in an unsupervised manner, and then the whole system is fine-tuned using supervised learning techniques.", "words": [{"w": "Most", "b": [0.1429, 0.3229, 0.1855, 0.3443]}, {"w": "semisupervised", "b": [0.1959, 0.3229, 0.3246, 0.3443]}, {"w": "learning", "b": [0.335, 0.3229, 0.4041, 0.3443]}, {"w": "algorithms", "b": [0.4145, 0.3229, 0.5048, 0.3443]}, {"w": "are", "b": [0.5151, 0.3229, 0.5409, 0.3443]}, {"w": "combinations", "b": [0.5512, 0.3229, 0.6657, 0.3443]}, {"w": "of", "b": [0.676, 0.3229, 0.6928, 0.3443]}, {"w": "unsupervised", "b": [0.7032, 0.3229, 0.8152, 0.3443]}, {"w": "and", "b": [0.8256, 0.3229, 0.8571, 0.3443]}, {"w": "supervised", "b": [0.1429, 0.3419, 0.2324, 0.3633]}, {"w": "algorithms.", "b": [0.2383, 0.3419, 0.3334, 0.3633]}, {"w": "For", "b": [0.3393, 0.3419, 0.3683, 0.3633]}, {"w": "example,", "b": [0.3742, 0.3419, 0.4485, 0.3633]}, {"w": "deep", "b": [0.4545, 0.3417, 0.4916, 0.3633]}, {"w": "belief", "b": [0.4975, 0.3417, 0.5401, 0.3633]}, {"w": "networks", "b": [0.5461, 0.3417, 0.6193, 0.3633]}, {"w": "(DBNs)", "b": [0.6253, 0.3419, 0.6898, 0.3633]}, {"w": "are", "b": [0.6957, 0.3419, 0.7215, 0.3633]}, {"w": "based", "b": [0.7274, 0.3419, 0.7746, 0.3633]}, {"w": "on", "b": [0.7806, 0.3419, 0.8026, 0.3633]}, {"w": "unsu‐", "b": [0.8086, 0.3419, 0.8571, 0.3633]}, {"w": "pervised", "b": [0.1429, 0.361, 0.2137, 0.3824]}, {"w": "components", "b": [0.2194, 0.361, 0.3223, 0.3824]}, {"w": "called", "b": [0.328, 0.361, 0.3764, 0.3824]}, {"w": "restricted", "b": [0.3821, 0.3607, 0.4569, 0.3824]}, {"w": "Boltzmann", "b": [0.4627, 0.3607, 0.5523, 0.3824]}, {"w": "machines", "b": [0.5581, 0.3607, 0.6339, 0.3824]}, {"w": "(RBMs)", "b": [0.6396, 0.361, 0.7055, 0.3824]}, {"w": "stacked", "b": [0.7112, 0.361, 0.7733, 0.3824]}, {"w": "on", "b": [0.779, 0.361, 0.801, 0.3824]}, {"w": "top", "b": [0.8068, 0.361, 0.8346, 0.3824]}, {"w": "of", "b": [0.8404, 0.361, 0.8572, 0.3824]}, {"w": "one", "b": [0.1429, 0.38, 0.1737, 0.4014]}, {"w": "another.", "b": [0.1791, 0.38, 0.2477, 0.4014]}, {"w": "RBMs", "b": [0.2531, 0.38, 0.3045, 0.4014]}, {"w": "are", "b": [0.3098, 0.38, 0.3356, 0.4014]}, {"w": "trained", "b": [0.3409, 0.38, 0.401, 0.4014]}, {"w": "sequentially", "b": [0.4063, 0.38, 0.5056, 0.4014]}, {"w": "in", "b": [0.5109, 0.38, 0.5279, 0.4014]}, {"w": "an", "b": [0.5332, 0.38, 0.5538, 0.4014]}, {"w": "unsupervised", "b": [0.5591, 0.38, 0.6711, 0.4014]}, {"w": "manner,", "b": [0.6765, 0.38, 0.7455, 0.4014]}, {"w": "and", "b": [0.7508, 0.38, 0.7824, 0.4014]}, {"w": "then", "b": [0.7877, 0.38, 0.8255, 0.4014]}, {"w": "the", "b": [0.8308, 0.38, 0.8571, 0.4014]}, {"w": "whole", "b": [0.1429, 0.399, 0.193, 0.4205]}, {"w": "system", "b": [0.1977, 0.399, 0.2549, 0.4205]}, {"w": "is", "b": [0.2596, 0.399, 0.2728, 0.4205]}, {"w": "fine-tuned", "b": [0.2775, 0.399, 0.3656, 0.4205]}, {"w": "using", "b": [0.3704, 0.399, 0.4158, 0.4205]}, {"w": "supervised", "b": [0.4205, 0.399, 0.5101, 0.4205]}, {"w": "learning", "b": [0.5148, 0.399, 0.5839, 0.4205]}, {"w": "techniques.", "b": [0.5886, 0.399, 0.6837, 0.4205]}]}, {"id": "b_2", "type": "paragraph", "text": "Reinforcement Learning", "words": [{"w": "Reinforcement", "b": [0.1429, 0.4364, 0.2551, 0.4573]}, {"w": "Learning", "b": [0.2587, 0.4364, 0.3258, 0.4573]}]}, {"id": "b_3", "type": "paragraph", "text": "Reinforcement Learning is a very different beast. The learning system, called an agent in this context, can observe the environment, select and perform actions, and get rewards in return (or penalties in the form of negative rewards, as in Figure 1-12). It must then learn by itself what is the best strategy, called a policy, to get the most reward over time. A policy defines what action the agent should choose when it is in a given situation.", "words": [{"w": "Reinforcement", "b": [0.1429, 0.4628, 0.2599, 0.4844]}, {"w": "Learning", "b": [0.2658, 0.4628, 0.3385, 0.4844]}, {"w": "is", "b": [0.3444, 0.463, 0.3576, 0.4844]}, {"w": "a", "b": [0.3634, 0.463, 0.3726, 0.4844]}, {"w": "very", "b": [0.3784, 0.463, 0.4148, 0.4844]}, {"w": "different", "b": [0.4206, 0.463, 0.4923, 0.4844]}, {"w": "beast.", "b": [0.4981, 0.463, 0.5455, 0.4844]}, {"w": "The", "b": [0.5513, 0.463, 0.5841, 0.4844]}, {"w": "learning", "b": [0.59, 0.463, 0.6591, 0.4844]}, {"w": "system,", "b": [0.6649, 0.463, 0.7268, 0.4844]}, {"w": "called", "b": [0.7326, 0.463, 0.781, 0.4844]}, {"w": "an", "b": [0.7868, 0.463, 0.8073, 0.4844]}, {"w": "agent", "b": [0.8132, 0.4628, 0.8572, 0.4844]}, {"w": "in", "b": [0.1429, 0.482, 0.1598, 0.5034]}, {"w": "this", "b": [0.1682, 0.482, 0.1989, 0.5034]}, {"w": "context,", "b": [0.2072, 0.482, 0.2738, 0.5034]}, {"w": "can", "b": [0.2821, 0.482, 0.3114, 0.5034]}, {"w": "observe", "b": [0.3197, 0.482, 0.3843, 0.5034]}, {"w": "the", "b": [0.3926, 0.482, 0.4189, 0.5034]}, {"w": "environment,", "b": [0.4273, 0.482, 0.54, 0.5034]}, {"w": "select", "b": [0.5483, 0.482, 0.5941, 0.5034]}, {"w": "and", "b": [0.6024, 0.482, 0.634, 0.5034]}, {"w": "perform", "b": [0.6423, 0.482, 0.7114, 0.5034]}, {"w": "actions,", "b": [0.7197, 0.482, 0.784, 0.5034]}, {"w": "and", "b": [0.7923, 0.482, 0.8239, 0.5034]}, {"w": "get", "b": [0.8322, 0.482, 0.8571, 0.5034]}, {"w": "rewards", "b": [0.1429, 0.5009, 0.2072, 0.5225]}, {"w": "in", "b": [0.2133, 0.5011, 0.2302, 0.5225]}, {"w": "return", "b": [0.2363, 0.5011, 0.2894, 0.5225]}, {"w": "(or", "b": [0.2955, 0.5011, 0.3211, 0.5225]}, {"w": "penalties", "b": [0.3272, 0.5009, 0.3984, 0.5225]}, {"w": "in", "b": [0.4045, 0.5011, 0.4214, 0.5225]}, {"w": "the", "b": [0.4275, 0.5011, 0.4539, 0.5225]}, {"w": "form", "b": [0.46, 0.5011, 0.5015, 0.5225]}, {"w": "of", "b": [0.5076, 0.5011, 0.5244, 0.5225]}, {"w": "negative", "b": [0.5305, 0.5011, 0.5997, 0.5225]}, {"w": "rewards,", "b": [0.6058, 0.5011, 0.6769, 0.5225]}, {"w": "as", "b": [0.683, 0.5011, 0.6998, 0.5225]}, {"w": "in", "b": [0.7059, 0.5011, 0.7229, 0.5225]}, {"w": "Figure", "b": [0.7289, 0.5011, 0.7829, 0.5225]}, {"w": "1-12).", "b": [0.789, 0.5011, 0.8384, 0.5225]}, {"w": "It", "b": [0.8445, 0.5011, 0.8571, 0.5225]}, {"w": "must", "b": [0.1428, 0.5201, 0.1846, 0.5415]}, {"w": "then", "b": [0.1927, 0.5201, 0.2305, 0.5415]}, {"w": "learn", "b": [0.2386, 0.5201, 0.281, 0.5415]}, {"w": "by", "b": [0.2892, 0.5201, 0.3093, 0.5415]}, {"w": "itself", "b": [0.3175, 0.5201, 0.3573, 0.5415]}, {"w": "what", "b": [0.3655, 0.5201, 0.406, 0.5415]}, {"w": "is", "b": [0.4141, 0.5201, 0.4274, 0.5415]}, {"w": "the", "b": [0.4355, 0.5201, 0.4619, 0.5415]}, {"w": "best", "b": [0.47, 0.5201, 0.5035, 0.5415]}, {"w": "strategy,", "b": [0.5116, 0.5201, 0.5803, 0.5415]}, {"w": "called", "b": [0.5885, 0.5201, 0.6368, 0.5415]}, {"w": "a", "b": [0.645, 0.5201, 0.6541, 0.5415]}, {"w": "policy,", "b": [0.6623, 0.5199, 0.7146, 0.5415]}, {"w": "to", "b": [0.7227, 0.5201, 0.7397, 0.5415]}, {"w": "get", "b": [0.7479, 0.5201, 0.7728, 0.5415]}, {"w": "the", "b": [0.781, 0.5201, 0.8073, 0.5415]}, {"w": "most", "b": [0.8154, 0.5201, 0.8571, 0.5415]}, {"w": "reward", "b": [0.1429, 0.5392, 0.2016, 0.5606]}, {"w": "over", "b": [0.2063, 0.5392, 0.2432, 0.5606]}, {"w": "time.", "b": [0.2479, 0.5392, 0.2905, 0.5606]}, {"w": "A", "b": [0.2952, 0.5392, 0.3096, 0.5606]}, {"w": "policy", "b": [0.3144, 0.5392, 0.3651, 0.5606]}, {"w": "defines", "b": [0.3699, 0.5392, 0.4294, 0.5606]}, {"w": "what", "b": [0.4341, 0.5392, 0.4746, 0.5606]}, {"w": "action", "b": [0.4793, 0.5392, 0.5312, 0.5606]}, {"w": "the", "b": [0.536, 0.5392, 0.5623, 0.5606]}, {"w": "agent", "b": [0.567, 0.5392, 0.6121, 0.5606]}, {"w": "should", "b": [0.6169, 0.5392, 0.6736, 0.5606]}, {"w": "choose", "b": [0.6783, 0.5392, 0.736, 0.5606]}, {"w": "when", "b": [0.7407, 0.5392, 0.7864, 0.5606]}, {"w": "it", "b": [0.7911, 0.5392, 0.8031, 0.5606]}, {"w": "is", "b": [0.8078, 0.5392, 0.821, 0.5606]}, {"w": "in", "b": [0.8257, 0.5392, 0.8427, 0.5606]}, {"w": "a", "b": [0.8474, 0.5392, 0.8566, 0.5606]}, {"w": "given", "b": [0.1429, 0.5582, 0.1881, 0.5796]}, {"w": "situation.", "b": [0.1928, 0.5582, 0.2709, 0.5796]}]}, {"id": "b_4", "type": "paragraph", "text": "14 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "14", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.3371, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 41, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 1-12. Reinforcement Learning", "words": [{"w": "Figure", "b": [0.1429, 0.3737, 0.1943, 0.3954]}, {"w": "1-12.", "b": [0.1991, 0.3737, 0.2407, 0.3954]}, {"w": "Reinforcement", "b": [0.2455, 0.3737, 0.3625, 0.3954]}, {"w": "Learning", "b": [0.3673, 0.3737, 0.4401, 0.3954]}]}, {"id": "b_1", "type": "paragraph", "text": "For example, many robots implement Reinforcement Learning algorithms to learn how to walk. DeepMind’s AlphaGo program is also a good example of Reinforcement Learning: it made the headlines in May 2017 when it beat the world champion Ke Jie at the game of Go. It learned its winning policy by analyzing millions of games, and then playing many games against itself. Note that learning was turned off during the games against the champion; AlphaGo was just applying the policy it had learned.", "words": [{"w": "For", "b": [0.1429, 0.4111, 0.1718, 0.4325]}, {"w": "example,", "b": [0.1798, 0.4111, 0.254, 0.4325]}, {"w": "many", "b": [0.262, 0.4111, 0.3086, 0.4325]}, {"w": "robots", "b": [0.3166, 0.4111, 0.3701, 0.4325]}, {"w": "implement", "b": [0.378, 0.4111, 0.4686, 0.4325]}, {"w": "Reinforcement", "b": [0.4765, 0.4111, 0.6007, 0.4325]}, {"w": "Learning", "b": [0.6087, 0.4111, 0.6837, 0.4325]}, {"w": "algorithms", "b": [0.6916, 0.4111, 0.7819, 0.4325]}, {"w": "to", "b": [0.7899, 0.4111, 0.8068, 0.4325]}, {"w": "learn", "b": [0.8147, 0.4111, 0.8571, 0.4325]}, {"w": "how", "b": [0.1429, 0.4302, 0.1789, 0.4516]}, {"w": "to", "b": [0.1839, 0.4302, 0.2009, 0.4516]}, {"w": "walk.", "b": [0.2059, 0.4302, 0.2497, 0.4516]}, {"w": "DeepMind’s", "b": [0.2547, 0.4302, 0.3549, 0.4516]}, {"w": "AlphaGo", "b": [0.36, 0.4302, 0.4363, 0.4516]}, {"w": "program", "b": [0.4414, 0.4302, 0.5143, 0.4516]}, {"w": "is", "b": [0.5194, 0.4302, 0.5326, 0.4516]}, {"w": "also", "b": [0.5376, 0.4302, 0.5703, 0.4516]}, {"w": "a", "b": [0.5753, 0.4302, 0.5845, 0.4516]}, {"w": "good", "b": [0.5895, 0.4302, 0.6315, 0.4516]}, {"w": "example", "b": [0.6365, 0.4302, 0.7061, 0.4516]}, {"w": "of", "b": [0.7111, 0.4302, 0.7279, 0.4516]}, {"w": "Reinforcement", "b": [0.7329, 0.4302, 0.8571, 0.4516]}, {"w": "Learning:", "b": [0.1429, 0.4492, 0.2227, 0.4706]}, {"w": "it", "b": [0.2282, 0.4492, 0.2402, 0.4706]}, {"w": "made", "b": [0.2457, 0.4492, 0.2918, 0.4706]}, {"w": "the", "b": [0.2973, 0.4492, 0.3236, 0.4706]}, {"w": "headlines", "b": [0.3292, 0.4492, 0.4081, 0.4706]}, {"w": "in", "b": [0.4136, 0.4492, 0.4306, 0.4706]}, {"w": "May", "b": [0.4361, 0.4492, 0.4727, 0.4706]}, {"w": "2017", "b": [0.4782, 0.4492, 0.5182, 0.4706]}, {"w": "when", "b": [0.5237, 0.4492, 0.5694, 0.4706]}, {"w": "it", "b": [0.5749, 0.4492, 0.5869, 0.4706]}, {"w": "beat", "b": [0.5924, 0.4492, 0.6269, 0.4706]}, {"w": "the", "b": [0.6325, 0.4492, 0.6588, 0.4706]}, {"w": "world", "b": [0.6644, 0.4492, 0.7133, 0.4706]}, {"w": "champion", "b": [0.7188, 0.4492, 0.8031, 0.4706]}, {"w": "Ke", "b": [0.8086, 0.4492, 0.831, 0.4706]}, {"w": "Jie", "b": [0.8365, 0.4492, 0.8572, 0.4706]}, {"w": "at", "b": [0.1429, 0.4683, 0.158, 0.4897]}, {"w": "the", "b": [0.1642, 0.4683, 0.1905, 0.4897]}, {"w": "game", "b": [0.1968, 0.4683, 0.2416, 0.4897]}, {"w": "of", "b": [0.2478, 0.4683, 0.2646, 0.4897]}, {"w": "Go.", "b": [0.2709, 0.4681, 0.2997, 0.4897]}, {"w": "It", "b": [0.3059, 0.4683, 0.3186, 0.4897]}, {"w": "learned", "b": [0.3248, 0.4683, 0.3871, 0.4897]}, {"w": "its", "b": [0.3933, 0.4683, 0.4129, 0.4897]}, {"w": "winning", "b": [0.4192, 0.4683, 0.4885, 0.4897]}, {"w": "policy", "b": [0.4948, 0.4683, 0.5455, 0.4897]}, {"w": "by", "b": [0.5518, 0.4683, 0.5719, 0.4897]}, {"w": "analyzing", "b": [0.5782, 0.4683, 0.6582, 0.4897]}, {"w": "millions", "b": [0.6644, 0.4683, 0.7329, 0.4897]}, {"w": "of", "b": [0.7391, 0.4683, 0.7559, 0.4897]}, {"w": "games,", "b": [0.7622, 0.4683, 0.8194, 0.4897]}, {"w": "and", "b": [0.8256, 0.4683, 0.8571, 0.4897]}, {"w": "then", "b": [0.1429, 0.4873, 0.1806, 0.5087]}, {"w": "playing", "b": [0.1865, 0.4873, 0.2477, 0.5087]}, {"w": "many", "b": [0.2536, 0.4873, 0.3003, 0.5087]}, {"w": "games", "b": [0.3062, 0.4873, 0.3587, 0.5087]}, {"w": "against", "b": [0.3646, 0.4873, 0.4236, 0.5087]}, {"w": "itself.", "b": [0.4295, 0.4873, 0.4741, 0.5087]}, {"w": "Note", "b": [0.48, 0.4873, 0.5208, 0.5087]}, {"w": "that", "b": [0.5267, 0.4873, 0.5593, 0.5087]}, {"w": "learning", "b": [0.5652, 0.4873, 0.6344, 0.5087]}, {"w": "was", "b": [0.6403, 0.4873, 0.6713, 0.5087]}, {"w": "turned", "b": [0.6772, 0.4873, 0.7336, 0.5087]}, {"w": "off", "b": [0.7395, 0.4873, 0.7625, 0.5087]}, {"w": "during", "b": [0.7684, 0.4873, 0.8249, 0.5087]}, {"w": "the", "b": [0.8308, 0.4873, 0.8571, 0.5087]}, {"w": "games", "b": [0.1428, 0.5064, 0.1953, 0.5278]}, {"w": "against", "b": [0.2, 0.5064, 0.2591, 0.5278]}, {"w": "the", "b": [0.2638, 0.5064, 0.2901, 0.5278]}, {"w": "champion;", "b": [0.2948, 0.5064, 0.3839, 0.5278]}, {"w": "AlphaGo", "b": [0.3886, 0.5064, 0.465, 0.5278]}, {"w": "was", "b": [0.4697, 0.5064, 0.5008, 0.5278]}, {"w": "just", "b": [0.5055, 0.5064, 0.5359, 0.5278]}, {"w": "applying", "b": [0.5406, 0.5064, 0.6128, 0.5278]}, {"w": "the", "b": [0.6175, 0.5064, 0.6438, 0.5278]}, {"w": "policy", "b": [0.6486, 0.5064, 0.6993, 0.5278]}, {"w": "it", "b": [0.7041, 0.5064, 0.716, 0.5278]}, {"w": "had", "b": [0.7207, 0.5064, 0.752, 0.5278]}, {"w": "learned.", "b": [0.7567, 0.5064, 0.8237, 0.5278]}]}, {"id": "b_2", "type": "paragraph", "text": "Batch and Online Learning", "words": [{"w": "Batch", "b": [0.1429, 0.5406, 0.2017, 0.5691]}, {"w": "and", "b": [0.2067, 0.5406, 0.246, 0.5691]}, {"w": "Online", "b": [0.2509, 0.5406, 0.3179, 0.5691]}, {"w": "Learning", "b": [0.3229, 0.5406, 0.4144, 0.5691]}]}, {"id": "b_3", "type": "paragraph", "text": "Another criterion used to classify Machine Learning systems is whether or not the system can learn incrementally from a stream of incoming data.", "words": [{"w": "Another", "b": [0.1428, 0.575, 0.2133, 0.5964]}, {"w": "criterion", "b": [0.2206, 0.575, 0.2933, 0.5964]}, {"w": "used", "b": [0.3006, 0.575, 0.3392, 0.5964]}, {"w": "to", "b": [0.3465, 0.575, 0.3635, 0.5964]}, {"w": "classify", "b": [0.3708, 0.575, 0.431, 0.5964]}, {"w": "Machine", "b": [0.4383, 0.575, 0.5115, 0.5964]}, {"w": "Learning", "b": [0.5188, 0.575, 0.5938, 0.5964]}, {"w": "systems", "b": [0.6012, 0.575, 0.6659, 0.5964]}, {"w": "is", "b": [0.6732, 0.575, 0.6865, 0.5964]}, {"w": "whether", "b": [0.6938, 0.575, 0.7621, 0.5964]}, {"w": "or", "b": [0.7694, 0.575, 0.7878, 0.5964]}, {"w": "not", "b": [0.7951, 0.575, 0.8235, 0.5964]}, {"w": "the", "b": [0.8308, 0.575, 0.8571, 0.5964]}, {"w": "system", "b": [0.1429, 0.5941, 0.2, 0.6155]}, {"w": "can", "b": [0.2047, 0.5941, 0.2341, 0.6155]}, {"w": "learn", "b": [0.2388, 0.5941, 0.2812, 0.6155]}, {"w": "incrementally", "b": [0.2859, 0.5941, 0.4008, 0.6155]}, {"w": "from", "b": [0.4056, 0.5941, 0.4471, 0.6155]}, {"w": "a", "b": [0.4519, 0.5941, 0.461, 0.6155]}, {"w": "stream", "b": [0.4657, 0.5941, 0.5225, 0.6155]}, {"w": "of", "b": [0.5273, 0.5941, 0.5441, 0.6155]}, {"w": "incoming", "b": [0.5488, 0.5941, 0.629, 0.6155]}, {"w": "data.", "b": [0.6337, 0.5941, 0.6737, 0.6155]}]}, {"id": "b_4", "type": "paragraph", "text": "Batch learning", "words": [{"w": "Batch", "b": [0.1429, 0.6314, 0.186, 0.6523]}, {"w": "learning", "b": [0.1896, 0.6314, 0.2532, 0.6523]}]}, {"id": "b_5", "type": "paragraph", "text": "In batch learning, the system is incapable of learning incrementally: it must be trained using all the available data. This will generally take a lot of time and computing resources, so it is typically done offline. First the system is trained, and then it is launched into production and runs without learning anymore; it just applies what it has learned. This is called offline learning.", "words": [{"w": "In", "b": [0.1429, 0.658, 0.1614, 0.6794]}, {"w": "batch", "b": [0.1663, 0.6578, 0.2107, 0.6794]}, {"w": "learning,", "b": [0.2154, 0.6578, 0.2871, 0.6794]}, {"w": "the", "b": [0.2921, 0.658, 0.3184, 0.6794]}, {"w": "system", "b": [0.3234, 0.658, 0.3805, 0.6794]}, {"w": "is", "b": [0.3855, 0.658, 0.3987, 0.6794]}, {"w": "incapable", "b": [0.4037, 0.658, 0.483, 0.6794]}, {"w": "of", "b": [0.488, 0.658, 0.5047, 0.6794]}, {"w": "learning", "b": [0.5097, 0.658, 0.5788, 0.6794]}, {"w": "incrementally:", "b": [0.5838, 0.658, 0.7041, 0.6794]}, {"w": "it", "b": [0.7091, 0.658, 0.721, 0.6794]}, {"w": "must", "b": [0.726, 0.658, 0.7677, 0.6794]}, {"w": "be", "b": [0.7727, 0.658, 0.7921, 0.6794]}, {"w": "trained", "b": [0.7971, 0.658, 0.8571, 0.6794]}, {"w": "using", "b": [0.1429, 0.677, 0.1883, 0.6985]}, {"w": "all", "b": [0.1971, 0.677, 0.2168, 0.6985]}, {"w": "the", "b": [0.2257, 0.677, 0.252, 0.6985]}, {"w": "available", "b": [0.2608, 0.677, 0.3331, 0.6985]}, {"w": "data.", "b": [0.3419, 0.677, 0.3819, 0.6985]}, {"w": "This", "b": [0.3908, 0.677, 0.428, 0.6985]}, {"w": "will", "b": [0.4368, 0.677, 0.4672, 0.6985]}, {"w": "generally", "b": [0.476, 0.677, 0.5519, 0.6985]}, {"w": "take", "b": [0.5607, 0.677, 0.5954, 0.6985]}, {"w": "a", "b": [0.6042, 0.677, 0.6134, 0.6985]}, {"w": "lot", "b": [0.6222, 0.677, 0.6445, 0.6985]}, {"w": "of", "b": [0.6533, 0.677, 0.6701, 0.6985]}, {"w": "time", "b": [0.6789, 0.677, 0.7168, 0.6985]}, {"w": "and", "b": [0.7256, 0.677, 0.7571, 0.6985]}, {"w": "computing", "b": [0.766, 0.677, 0.8572, 0.6985]}, {"w": "resources,", "b": [0.1429, 0.6961, 0.2266, 0.7175]}, {"w": "so", "b": [0.2347, 0.6961, 0.253, 0.7175]}, {"w": "it", "b": [0.2611, 0.6961, 0.273, 0.7175]}, {"w": "is", "b": [0.2811, 0.6961, 0.2943, 0.7175]}, {"w": "typically", "b": [0.3025, 0.6961, 0.3729, 0.7175]}, {"w": "done", "b": [0.3811, 0.6961, 0.4229, 0.7175]}, {"w": "offline.", "b": [0.431, 0.6961, 0.4899, 0.7175]}, {"w": "First", "b": [0.498, 0.6961, 0.5363, 0.7175]}, {"w": "the", "b": [0.5444, 0.6961, 0.5707, 0.7175]}, {"w": "system", "b": [0.5789, 0.6961, 0.636, 0.7175]}, {"w": "is", "b": [0.6441, 0.6961, 0.6573, 0.7175]}, {"w": "trained,", "b": [0.6654, 0.6961, 0.7303, 0.7175]}, {"w": "and", "b": [0.7384, 0.6961, 0.7699, 0.7175]}, {"w": "then", "b": [0.778, 0.6961, 0.8158, 0.7175]}, {"w": "it", "b": [0.8239, 0.6961, 0.8358, 0.7175]}, {"w": "is", "b": [0.8439, 0.6961, 0.8571, 0.7175]}, {"w": "launched", "b": [0.1429, 0.7151, 0.2191, 0.7366]}, {"w": "into", "b": [0.2254, 0.7151, 0.2589, 0.7366]}, {"w": "production", "b": [0.2652, 0.7151, 0.3593, 0.7366]}, {"w": "and", "b": [0.3656, 0.7151, 0.3971, 0.7366]}, {"w": "runs", "b": [0.4034, 0.7151, 0.4412, 0.7366]}, {"w": "without", "b": [0.4475, 0.7151, 0.5128, 0.7366]}, {"w": "learning", "b": [0.5191, 0.7151, 0.5882, 0.7366]}, {"w": "anymore;", "b": [0.5945, 0.7151, 0.6731, 0.7366]}, {"w": "it", "b": [0.6794, 0.7151, 0.6913, 0.7366]}, {"w": "just", "b": [0.6976, 0.7151, 0.728, 0.7366]}, {"w": "applies", "b": [0.7342, 0.7151, 0.7922, 0.7366]}, {"w": "what", "b": [0.7984, 0.7151, 0.8389, 0.7366]}, {"w": "it", "b": [0.8452, 0.7151, 0.8571, 0.7366]}, {"w": "has", "b": [0.1429, 0.7342, 0.1708, 0.7556]}, {"w": "learned.", "b": [0.1755, 0.7342, 0.2425, 0.7556]}, {"w": "This", "b": [0.2472, 0.7342, 0.2845, 0.7556]}, {"w": "is", "b": [0.2892, 0.7342, 0.3024, 0.7556]}, {"w": "called", "b": [0.3071, 0.7342, 0.3555, 0.7556]}, {"w": "offline", "b": [0.3602, 0.734, 0.4116, 0.7556]}, {"w": "learning.", "b": [0.4164, 0.734, 0.4879, 0.7556]}]}, {"id": "b_6", "type": "paragraph", "text": "If you want a batch learning system to know about new data (such as a new type of spam), you need to train a new version of the system from scratch on the full dataset (not just the new data, but also the old data), then stop the old system and replace it with the new one.", "words": [{"w": "If", "b": [0.1429, 0.7623, 0.1561, 0.7837]}, {"w": "you", "b": [0.1625, 0.7623, 0.1937, 0.7837]}, {"w": "want", "b": [0.2001, 0.7623, 0.2409, 0.7837]}, {"w": "a", "b": [0.2472, 0.7623, 0.2564, 0.7837]}, {"w": "batch", "b": [0.2627, 0.7623, 0.3084, 0.7837]}, {"w": "learning", "b": [0.3147, 0.7623, 0.3838, 0.7837]}, {"w": "system", "b": [0.3902, 0.7623, 0.4473, 0.7837]}, {"w": "to", "b": [0.4537, 0.7623, 0.4706, 0.7837]}, {"w": "know", "b": [0.477, 0.7623, 0.5236, 0.7837]}, {"w": "about", "b": [0.53, 0.7623, 0.5778, 0.7837]}, {"w": "new", "b": [0.5841, 0.7623, 0.6186, 0.7837]}, {"w": "data", "b": [0.625, 0.7623, 0.6602, 0.7837]}, {"w": "(such", "b": [0.6666, 0.7623, 0.7124, 0.7837]}, {"w": "as", "b": [0.7188, 0.7623, 0.7356, 0.7837]}, {"w": "a", "b": [0.7419, 0.7623, 0.7511, 0.7837]}, {"w": "new", "b": [0.7574, 0.7623, 0.792, 0.7837]}, {"w": "type", "b": [0.7983, 0.7623, 0.834, 0.7837]}, {"w": "of", "b": [0.8404, 0.7623, 0.8572, 0.7837]}, {"w": "spam),", "b": [0.1429, 0.7814, 0.1996, 0.8028]}, {"w": "you", "b": [0.2051, 0.7814, 0.2364, 0.8028]}, {"w": "need", "b": [0.2419, 0.7814, 0.282, 0.8028]}, {"w": "to", "b": [0.2876, 0.7814, 0.3045, 0.8028]}, {"w": "train", "b": [0.3101, 0.7814, 0.3503, 0.8028]}, {"w": "a", "b": [0.3558, 0.7814, 0.365, 0.8028]}, {"w": "new", "b": [0.3705, 0.7814, 0.405, 0.8028]}, {"w": "version", "b": [0.4106, 0.7814, 0.472, 0.8028]}, {"w": "of", "b": [0.4776, 0.7814, 0.4944, 0.8028]}, {"w": "the", "b": [0.4999, 0.7814, 0.5262, 0.8028]}, {"w": "system", "b": [0.5318, 0.7814, 0.5889, 0.8028]}, {"w": "from", "b": [0.5944, 0.7814, 0.636, 0.8028]}, {"w": "scratch", "b": [0.6415, 0.7814, 0.7008, 0.8028]}, {"w": "on", "b": [0.7063, 0.7814, 0.7283, 0.8028]}, {"w": "the", "b": [0.7339, 0.7814, 0.7602, 0.8028]}, {"w": "full", "b": [0.7657, 0.7814, 0.7935, 0.8028]}, {"w": "dataset", "b": [0.799, 0.7814, 0.8571, 0.8028]}, {"w": "(not", "b": [0.1429, 0.8004, 0.1784, 0.8218]}, {"w": "just", "b": [0.1843, 0.8004, 0.2147, 0.8218]}, {"w": "the", "b": [0.2206, 0.8004, 0.2469, 0.8218]}, {"w": "new", "b": [0.2528, 0.8004, 0.2873, 0.8218]}, {"w": "data,", "b": [0.2931, 0.8004, 0.3331, 0.8218]}, {"w": "but", "b": [0.339, 0.8004, 0.367, 0.8218]}, {"w": "also", "b": [0.3729, 0.8004, 0.4055, 0.8218]}, {"w": "the", "b": [0.4114, 0.8004, 0.4377, 0.8218]}, {"w": "old", "b": [0.4436, 0.8004, 0.4705, 0.8218]}, {"w": "data),", "b": [0.4764, 0.8004, 0.5236, 0.8218]}, {"w": "then", "b": [0.5294, 0.8004, 0.5672, 0.8218]}, {"w": "stop", "b": [0.573, 0.8004, 0.6086, 0.8218]}, {"w": "the", "b": [0.6144, 0.8004, 0.6408, 0.8218]}, {"w": "old", "b": [0.6466, 0.8004, 0.6735, 0.8218]}, {"w": "system", "b": [0.6794, 0.8004, 0.7365, 0.8218]}, {"w": "and", "b": [0.7424, 0.8004, 0.7739, 0.8218]}, {"w": "replace", "b": [0.7798, 0.8004, 0.8393, 0.8218]}, {"w": "it", "b": [0.8452, 0.8004, 0.8571, 0.8218]}, {"w": "with", "b": [0.1429, 0.8194, 0.1802, 0.8409]}, {"w": "the", "b": [0.1849, 0.8194, 0.2112, 0.8409]}, {"w": "new", "b": [0.216, 0.8194, 0.2505, 0.8409]}, {"w": "one.", "b": [0.2552, 0.8194, 0.2909, 0.8409]}]}, {"id": "b_7", "type": "paragraph", "text": "Fortunately, the whole process of training, evaluating, and launching a Machine Learning system can be automated fairly easily (as shown in Figure 1-3), so even a", "words": [{"w": "Fortunately,", "b": [0.1429, 0.8476, 0.2427, 0.869]}, {"w": "the", "b": [0.2526, 0.8476, 0.279, 0.869]}, {"w": "whole", "b": [0.2889, 0.8476, 0.3391, 0.869]}, {"w": "process", "b": [0.3491, 0.8476, 0.4113, 0.869]}, {"w": "of", "b": [0.4213, 0.8476, 0.4381, 0.869]}, {"w": "training,", "b": [0.448, 0.8476, 0.5197, 0.869]}, {"w": "evaluating,", "b": [0.5297, 0.8476, 0.6203, 0.869]}, {"w": "and", "b": [0.6302, 0.8476, 0.6618, 0.869]}, {"w": "launching", "b": [0.6718, 0.8476, 0.7549, 0.869]}, {"w": "a", "b": [0.7649, 0.8476, 0.774, 0.869]}, {"w": "Machine", "b": [0.784, 0.8476, 0.8571, 0.869]}, {"w": "Learning", "b": [0.1429, 0.8666, 0.2179, 0.888]}, {"w": "system", "b": [0.225, 0.8666, 0.2822, 0.888]}, {"w": "can", "b": [0.2893, 0.8666, 0.3186, 0.888]}, {"w": "be", "b": [0.3257, 0.8666, 0.3451, 0.888]}, {"w": "automated", "b": [0.3522, 0.8666, 0.4411, 0.888]}, {"w": "fairly", "b": [0.4482, 0.8666, 0.4916, 0.888]}, {"w": "easily", "b": [0.4987, 0.8666, 0.5448, 0.888]}, {"w": "(as", "b": [0.5519, 0.8666, 0.5759, 0.888]}, {"w": "shown", "b": [0.583, 0.8666, 0.638, 0.888]}, {"w": "in", "b": [0.6451, 0.8666, 0.6621, 0.888]}, {"w": "Figure", "b": [0.6692, 0.8666, 0.7232, 0.888]}, {"w": "1-3),", "b": [0.7303, 0.8666, 0.7697, 0.888]}, {"w": "so", "b": [0.7768, 0.8666, 0.7951, 0.888]}, {"w": "even", "b": [0.8022, 0.8666, 0.8409, 0.888]}, {"w": "a", "b": [0.848, 0.8666, 0.8572, 0.888]}]}, {"id": "b_8", "type": "paragraph", "text": "Types of Machine Learning Systems | 15", "words": [{"w": "Types", "b": [0.5961, 0.9225, 0.6295, 0.9388]}, {"w": "of", "b": [0.6323, 0.9225, 0.6443, 0.9388]}, {"w": "Machine", "b": [0.6471, 0.9225, 0.6971, 0.9388]}, {"w": "Learning", "b": [0.6999, 0.9225, 0.7521, 0.9388]}, {"w": "Systems", "b": [0.7549, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "15", "b": [0.8426, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 42, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "batch learning system can adapt to change. Simply update the data and train a new version of the system from scratch as often as needed.", "words": [{"w": "batch", "b": [0.1429, 0.0791, 0.1885, 0.1005]}, {"w": "learning", "b": [0.1952, 0.0791, 0.2643, 0.1005]}, {"w": "system", "b": [0.2711, 0.0791, 0.3282, 0.1005]}, {"w": "can", "b": [0.3349, 0.0791, 0.3643, 0.1005]}, {"w": "adapt", "b": [0.371, 0.0791, 0.4172, 0.1005]}, {"w": "to", "b": [0.4239, 0.0791, 0.4409, 0.1005]}, {"w": "change.", "b": [0.4476, 0.0791, 0.5115, 0.1005]}, {"w": "Simply", "b": [0.5182, 0.0791, 0.5761, 0.1005]}, {"w": "update", "b": [0.5828, 0.0791, 0.6397, 0.1005]}, {"w": "the", "b": [0.6465, 0.0791, 0.6728, 0.1005]}, {"w": "data", "b": [0.6795, 0.0791, 0.7148, 0.1005]}, {"w": "and", "b": [0.7215, 0.0791, 0.7531, 0.1005]}, {"w": "train", "b": [0.7598, 0.0791, 0.8, 0.1005]}, {"w": "a", "b": [0.8067, 0.0791, 0.8159, 0.1005]}, {"w": "new", "b": [0.8226, 0.0791, 0.8571, 0.1005]}, {"w": "version", "b": [0.1429, 0.0981, 0.2043, 0.1195]}, {"w": "of", "b": [0.2091, 0.0981, 0.2259, 0.1195]}, {"w": "the", "b": [0.2306, 0.0981, 0.2569, 0.1195]}, {"w": "system", "b": [0.2616, 0.0981, 0.3188, 0.1195]}, {"w": "from", "b": [0.3235, 0.0981, 0.3651, 0.1195]}, {"w": "scratch", "b": [0.3698, 0.0981, 0.429, 0.1195]}, {"w": "as", "b": [0.4338, 0.0981, 0.4506, 0.1195]}, {"w": "often", "b": [0.4553, 0.0981, 0.4987, 0.1195]}, {"w": "as", "b": [0.5034, 0.0981, 0.5202, 0.1195]}, {"w": "needed.", "b": [0.5249, 0.0981, 0.5896, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "This solution is simple and often works fine, but training using the full set of data can take many hours, so you would typically train a new system only every 24 hours or even just weekly. If your system needs to adapt to rapidly changing data (e.g., to pre‐ dict stock prices), then you need a more reactive solution.", "words": [{"w": "This", "b": [0.1429, 0.1262, 0.1801, 0.1476]}, {"w": "solution", "b": [0.185, 0.1262, 0.2536, 0.1476]}, {"w": "is", "b": [0.2585, 0.1262, 0.2718, 0.1476]}, {"w": "simple", "b": [0.2767, 0.1262, 0.3317, 0.1476]}, {"w": "and", "b": [0.3366, 0.1262, 0.3682, 0.1476]}, {"w": "often", "b": [0.3731, 0.1262, 0.4165, 0.1476]}, {"w": "works", "b": [0.4215, 0.1262, 0.4721, 0.1476]}, {"w": "fine,", "b": [0.477, 0.1262, 0.5138, 0.1476]}, {"w": "but", "b": [0.5187, 0.1262, 0.5467, 0.1476]}, {"w": "training", "b": [0.5517, 0.1262, 0.6186, 0.1476]}, {"w": "using", "b": [0.6236, 0.1262, 0.669, 0.1476]}, {"w": "the", "b": [0.674, 0.1262, 0.7003, 0.1476]}, {"w": "full", "b": [0.7053, 0.1262, 0.7331, 0.1476]}, {"w": "set", "b": [0.738, 0.1262, 0.7609, 0.1476]}, {"w": "of", "b": [0.7658, 0.1262, 0.7826, 0.1476]}, {"w": "data", "b": [0.7876, 0.1262, 0.8228, 0.1476]}, {"w": "can", "b": [0.8278, 0.1262, 0.8571, 0.1476]}, {"w": "take", "b": [0.1429, 0.1453, 0.1776, 0.1667]}, {"w": "many", "b": [0.1841, 0.1453, 0.2308, 0.1667]}, {"w": "hours,", "b": [0.2373, 0.1453, 0.2903, 0.1667]}, {"w": "so", "b": [0.2968, 0.1453, 0.3151, 0.1667]}, {"w": "you", "b": [0.3216, 0.1453, 0.3529, 0.1667]}, {"w": "would", "b": [0.3594, 0.1453, 0.4116, 0.1667]}, {"w": "typically", "b": [0.4182, 0.1453, 0.4886, 0.1667]}, {"w": "train", "b": [0.4952, 0.1453, 0.5354, 0.1667]}, {"w": "a", "b": [0.5419, 0.1453, 0.5511, 0.1667]}, {"w": "new", "b": [0.5576, 0.1453, 0.5921, 0.1667]}, {"w": "system", "b": [0.5987, 0.1453, 0.6558, 0.1667]}, {"w": "only", "b": [0.6623, 0.1453, 0.6992, 0.1667]}, {"w": "every", "b": [0.7057, 0.1453, 0.751, 0.1667]}, {"w": "24", "b": [0.7575, 0.1453, 0.7775, 0.1667]}, {"w": "hours", "b": [0.7841, 0.1453, 0.8323, 0.1667]}, {"w": "or", "b": [0.8388, 0.1453, 0.8572, 0.1667]}, {"w": "even", "b": [0.1429, 0.1643, 0.1816, 0.1857]}, {"w": "just", "b": [0.1872, 0.1643, 0.2176, 0.1857]}, {"w": "weekly.", "b": [0.2233, 0.1643, 0.2837, 0.1857]}, {"w": "If", "b": [0.2893, 0.1643, 0.3026, 0.1857]}, {"w": "your", "b": [0.3082, 0.1643, 0.3472, 0.1857]}, {"w": "system", "b": [0.3528, 0.1643, 0.4099, 0.1857]}, {"w": "needs", "b": [0.4156, 0.1643, 0.4633, 0.1857]}, {"w": "to", "b": [0.469, 0.1643, 0.4859, 0.1857]}, {"w": "adapt", "b": [0.4916, 0.1643, 0.5377, 0.1857]}, {"w": "to", "b": [0.5434, 0.1643, 0.5604, 0.1857]}, {"w": "rapidly", "b": [0.566, 0.1643, 0.6248, 0.1857]}, {"w": "changing", "b": [0.6304, 0.1643, 0.7074, 0.1857]}, {"w": "data", "b": [0.713, 0.1643, 0.7483, 0.1857]}, {"w": "(e.g.,", "b": [0.7539, 0.1643, 0.794, 0.1857]}, {"w": "to", "b": [0.7996, 0.1643, 0.8166, 0.1857]}, {"w": "pre‐", "b": [0.8222, 0.1643, 0.8571, 0.1857]}, {"w": "dict", "b": [0.1429, 0.1834, 0.1746, 0.2048]}, {"w": "stock", "b": [0.1793, 0.1834, 0.2231, 0.2048]}, {"w": "prices),", "b": [0.2278, 0.1834, 0.2893, 0.2048]}, {"w": "then", "b": [0.2941, 0.1834, 0.3318, 0.2048]}, {"w": "you", "b": [0.3365, 0.1834, 0.3678, 0.2048]}, {"w": "need", "b": [0.3725, 0.1834, 0.4126, 0.2048]}, {"w": "a", "b": [0.4173, 0.1834, 0.4265, 0.2048]}, {"w": "more", "b": [0.4312, 0.1834, 0.4755, 0.2048]}, {"w": "reactive", "b": [0.4802, 0.1834, 0.5452, 0.2048]}, {"w": "solution.", "b": [0.5499, 0.1834, 0.6232, 0.2048]}]}, {"id": "b_2", "type": "paragraph", "text": "Also, training on the full set of data requires a lot of computing resources (CPU, memory space, disk space, disk I/O, network I/O, etc.). If you have a lot of data and you automate your system to train from scratch every day, it will end up costing you a lot of money. If the amount of data is huge, it may even be impossible to use a batch learning algorithm.", "words": [{"w": "Also,", "b": [0.1429, 0.2115, 0.1849, 0.2329]}, {"w": "training", "b": [0.1933, 0.2115, 0.2602, 0.2329]}, {"w": "on", "b": [0.2685, 0.2115, 0.2905, 0.2329]}, {"w": "the", "b": [0.2989, 0.2115, 0.3252, 0.2329]}, {"w": "full", "b": [0.3335, 0.2115, 0.3613, 0.2329]}, {"w": "set", "b": [0.3696, 0.2115, 0.3925, 0.2329]}, {"w": "of", "b": [0.4008, 0.2115, 0.4176, 0.2329]}, {"w": "data", "b": [0.4259, 0.2115, 0.4612, 0.2329]}, {"w": "requires", "b": [0.4695, 0.2115, 0.5376, 0.2329]}, {"w": "a", "b": [0.5459, 0.2115, 0.555, 0.2329]}, {"w": "lot", "b": [0.5634, 0.2115, 0.5856, 0.2329]}, {"w": "of", "b": [0.5939, 0.2115, 0.6107, 0.2329]}, {"w": "computing", "b": [0.6191, 0.2115, 0.7102, 0.2329]}, {"w": "resources", "b": [0.7185, 0.2115, 0.7975, 0.2329]}, {"w": "(CPU,", "b": [0.8058, 0.2115, 0.8571, 0.2329]}, {"w": "memory", "b": [0.1428, 0.2305, 0.2143, 0.2519]}, {"w": "space,", "b": [0.2205, 0.2305, 0.2706, 0.2519]}, {"w": "disk", "b": [0.2768, 0.2305, 0.3113, 0.2519]}, {"w": "space,", "b": [0.3175, 0.2305, 0.3676, 0.2519]}, {"w": "disk", "b": [0.3737, 0.2305, 0.4083, 0.2519]}, {"w": "I/O,", "b": [0.4144, 0.2305, 0.4479, 0.2519]}, {"w": "network", "b": [0.4541, 0.2305, 0.5236, 0.2519]}, {"w": "I/O,", "b": [0.5298, 0.2305, 0.5632, 0.2519]}, {"w": "etc.).", "b": [0.5694, 0.2305, 0.6101, 0.2519]}, {"w": "If", "b": [0.6162, 0.2305, 0.6295, 0.2519]}, {"w": "you", "b": [0.6357, 0.2305, 0.6669, 0.2519]}, {"w": "have", "b": [0.6731, 0.2305, 0.7114, 0.2519]}, {"w": "a", "b": [0.7176, 0.2305, 0.7267, 0.2519]}, {"w": "lot", "b": [0.7329, 0.2305, 0.7551, 0.2519]}, {"w": "of", "b": [0.7613, 0.2305, 0.7781, 0.2519]}, {"w": "data", "b": [0.7842, 0.2305, 0.8195, 0.2519]}, {"w": "and", "b": [0.8256, 0.2305, 0.8571, 0.2519]}, {"w": "you", "b": [0.1429, 0.2496, 0.1741, 0.271]}, {"w": "automate", "b": [0.1789, 0.2496, 0.2567, 0.271]}, {"w": "your", "b": [0.2616, 0.2496, 0.3006, 0.271]}, {"w": "system", "b": [0.3054, 0.2496, 0.3625, 0.271]}, {"w": "to", "b": [0.3673, 0.2496, 0.3843, 0.271]}, {"w": "train", "b": [0.3891, 0.2496, 0.4293, 0.271]}, {"w": "from", "b": [0.4342, 0.2496, 0.4757, 0.271]}, {"w": "scratch", "b": [0.4806, 0.2496, 0.5398, 0.271]}, {"w": "every", "b": [0.5446, 0.2496, 0.5899, 0.271]}, {"w": "day,", "b": [0.5947, 0.2496, 0.6273, 0.271]}, {"w": "it", "b": [0.6321, 0.2496, 0.644, 0.271]}, {"w": "will", "b": [0.6488, 0.2496, 0.6792, 0.271]}, {"w": "end", "b": [0.6841, 0.2496, 0.7153, 0.271]}, {"w": "up", "b": [0.7201, 0.2496, 0.7421, 0.271]}, {"w": "costing", "b": [0.7469, 0.2496, 0.8071, 0.271]}, {"w": "you", "b": [0.8119, 0.2496, 0.8432, 0.271]}, {"w": "a", "b": [0.848, 0.2496, 0.8571, 0.271]}, {"w": "lot", "b": [0.1429, 0.2686, 0.1651, 0.29]}, {"w": "of", "b": [0.1709, 0.2686, 0.1877, 0.29]}, {"w": "money.", "b": [0.1936, 0.2686, 0.2543, 0.29]}, {"w": "If", "b": [0.2601, 0.2686, 0.2734, 0.29]}, {"w": "the", "b": [0.2792, 0.2686, 0.3056, 0.29]}, {"w": "amount", "b": [0.3114, 0.2686, 0.3767, 0.29]}, {"w": "of", "b": [0.3825, 0.2686, 0.3993, 0.29]}, {"w": "data", "b": [0.4051, 0.2686, 0.4404, 0.29]}, {"w": "is", "b": [0.4462, 0.2686, 0.4594, 0.29]}, {"w": "huge,", "b": [0.4653, 0.2686, 0.5104, 0.29]}, {"w": "it", "b": [0.5163, 0.2686, 0.5282, 0.29]}, {"w": "may", "b": [0.534, 0.2686, 0.5694, 0.29]}, {"w": "even", "b": [0.5753, 0.2686, 0.614, 0.29]}, {"w": "be", "b": [0.6198, 0.2686, 0.6393, 0.29]}, {"w": "impossible", "b": [0.6451, 0.2686, 0.7345, 0.29]}, {"w": "to", "b": [0.7403, 0.2686, 0.7573, 0.29]}, {"w": "use", "b": [0.7631, 0.2686, 0.7907, 0.29]}, {"w": "a", "b": [0.7965, 0.2686, 0.8057, 0.29]}, {"w": "batch", "b": [0.8115, 0.2686, 0.8571, 0.29]}, {"w": "learning", "b": [0.1429, 0.2877, 0.212, 0.3091]}, {"w": "algorithm.", "b": [0.2167, 0.2877, 0.3041, 0.3091]}]}, {"id": "b_3", "type": "paragraph", "text": "Finally, if your system needs to be able to learn autonomously and it has limited resources (e.g., a smartphone application or a rover on Mars), then carrying around large amounts of training data and taking up a lot of resources to train for hours every day is a showstopper.", "words": [{"w": "Finally,", "b": [0.1429, 0.3158, 0.2033, 0.3372]}, {"w": "if", "b": [0.2117, 0.3158, 0.2235, 0.3372]}, {"w": "your", "b": [0.2319, 0.3158, 0.2708, 0.3372]}, {"w": "system", "b": [0.2792, 0.3158, 0.3363, 0.3372]}, {"w": "needs", "b": [0.3447, 0.3158, 0.3925, 0.3372]}, {"w": "to", "b": [0.4009, 0.3158, 0.4178, 0.3372]}, {"w": "be", "b": [0.4262, 0.3158, 0.4457, 0.3372]}, {"w": "able", "b": [0.4541, 0.3158, 0.4879, 0.3372]}, {"w": "to", "b": [0.4963, 0.3158, 0.5133, 0.3372]}, {"w": "learn", "b": [0.5217, 0.3158, 0.5641, 0.3372]}, {"w": "autonomously", "b": [0.5724, 0.3158, 0.6925, 0.3372]}, {"w": "and", "b": [0.7009, 0.3158, 0.7324, 0.3372]}, {"w": "it", "b": [0.7408, 0.3158, 0.7527, 0.3372]}, {"w": "has", "b": [0.7611, 0.3158, 0.789, 0.3372]}, {"w": "limited", "b": [0.7974, 0.3158, 0.8571, 0.3372]}, {"w": "resources", "b": [0.1429, 0.3348, 0.2218, 0.3563]}, {"w": "(e.g.,", "b": [0.228, 0.3348, 0.2681, 0.3563]}, {"w": "a", "b": [0.2743, 0.3348, 0.2835, 0.3563]}, {"w": "smartphone", "b": [0.2897, 0.3348, 0.3905, 0.3563]}, {"w": "application", "b": [0.3967, 0.3348, 0.4897, 0.3563]}, {"w": "or", "b": [0.4959, 0.3348, 0.5142, 0.3563]}, {"w": "a", "b": [0.5205, 0.3348, 0.5296, 0.3563]}, {"w": "rover", "b": [0.5358, 0.3348, 0.5804, 0.3563]}, {"w": "on", "b": [0.5866, 0.3348, 0.6086, 0.3563]}, {"w": "Mars),", "b": [0.6148, 0.3348, 0.6695, 0.3563]}, {"w": "then", "b": [0.6757, 0.3348, 0.7135, 0.3563]}, {"w": "carrying", "b": [0.7197, 0.3348, 0.79, 0.3563]}, {"w": "around", "b": [0.7962, 0.3348, 0.8572, 0.3563]}, {"w": "large", "b": [0.1429, 0.3539, 0.1836, 0.3753]}, {"w": "amounts", "b": [0.1915, 0.3539, 0.2644, 0.3753]}, {"w": "of", "b": [0.2723, 0.3539, 0.2891, 0.3753]}, {"w": "training", "b": [0.297, 0.3539, 0.3639, 0.3753]}, {"w": "data", "b": [0.3718, 0.3539, 0.4071, 0.3753]}, {"w": "and", "b": [0.415, 0.3539, 0.4465, 0.3753]}, {"w": "taking", "b": [0.4544, 0.3539, 0.507, 0.3753]}, {"w": "up", "b": [0.5149, 0.3539, 0.5369, 0.3753]}, {"w": "a", "b": [0.5448, 0.3539, 0.5539, 0.3753]}, {"w": "lot", "b": [0.5618, 0.3539, 0.5841, 0.3753]}, {"w": "of", "b": [0.592, 0.3539, 0.6088, 0.3753]}, {"w": "resources", "b": [0.6167, 0.3539, 0.6956, 0.3753]}, {"w": "to", "b": [0.7035, 0.3539, 0.7205, 0.3753]}, {"w": "train", "b": [0.7284, 0.3539, 0.7686, 0.3753]}, {"w": "for", "b": [0.7765, 0.3539, 0.8011, 0.3753]}, {"w": "hours", "b": [0.809, 0.3539, 0.8571, 0.3753]}, {"w": "every", "b": [0.1429, 0.3729, 0.1881, 0.3944]}, {"w": "day", "b": [0.1928, 0.3729, 0.2222, 0.3944]}, {"w": "is", "b": [0.2269, 0.3729, 0.2401, 0.3944]}, {"w": "a", "b": [0.2449, 0.3729, 0.254, 0.3944]}, {"w": "showstopper.", "b": [0.2587, 0.3729, 0.3689, 0.3944]}]}, {"id": "b_4", "type": "paragraph", "text": "Fortunately, a better option in all these cases is to use algorithms that are capable of learning incrementally.", "words": [{"w": "Fortunately,", "b": [0.1429, 0.4011, 0.2427, 0.4225]}, {"w": "a", "b": [0.2489, 0.4011, 0.2581, 0.4225]}, {"w": "better", "b": [0.2643, 0.4011, 0.3131, 0.4225]}, {"w": "option", "b": [0.3193, 0.4011, 0.3748, 0.4225]}, {"w": "in", "b": [0.3811, 0.4011, 0.3981, 0.4225]}, {"w": "all", "b": [0.4044, 0.4011, 0.424, 0.4225]}, {"w": "these", "b": [0.4303, 0.4011, 0.4731, 0.4225]}, {"w": "cases", "b": [0.4794, 0.4011, 0.5215, 0.4225]}, {"w": "is", "b": [0.5278, 0.4011, 0.541, 0.4225]}, {"w": "to", "b": [0.5473, 0.4011, 0.5643, 0.4225]}, {"w": "use", "b": [0.5705, 0.4011, 0.5981, 0.4225]}, {"w": "algorithms", "b": [0.6043, 0.4011, 0.6946, 0.4225]}, {"w": "that", "b": [0.7009, 0.4011, 0.7335, 0.4225]}, {"w": "are", "b": [0.7398, 0.4011, 0.7655, 0.4225]}, {"w": "capable", "b": [0.7717, 0.4011, 0.8341, 0.4225]}, {"w": "of", "b": [0.8403, 0.4011, 0.8571, 0.4225]}, {"w": "learning", "b": [0.1428, 0.4201, 0.212, 0.4415]}, {"w": "incrementally.", "b": [0.2167, 0.4201, 0.3348, 0.4415]}]}, {"id": "b_5", "type": "paragraph", "text": "Online learning", "words": [{"w": "Online", "b": [0.1428, 0.4574, 0.192, 0.4784]}, {"w": "learning", "b": [0.1956, 0.4574, 0.2592, 0.4784]}]}, {"id": "b_6", "type": "paragraph", "text": "In online learning, you train the system incrementally by feeding it data instances sequentially, either individually or by small groups called mini-batches. Each learning step is fast and cheap, so the system can learn about new data on the fly, as it arrives (see Figure 1-13).", "words": [{"w": "In", "b": [0.1428, 0.484, 0.1613, 0.5055]}, {"w": "online", "b": [0.1696, 0.4838, 0.2196, 0.5055]}, {"w": "learning,", "b": [0.2279, 0.4838, 0.2994, 0.5055]}, {"w": "you", "b": [0.3076, 0.484, 0.3388, 0.5055]}, {"w": "train", "b": [0.3471, 0.484, 0.3873, 0.5055]}, {"w": "the", "b": [0.3955, 0.484, 0.4218, 0.5055]}, {"w": "system", "b": [0.43, 0.484, 0.4872, 0.5055]}, {"w": "incrementally", "b": [0.4954, 0.484, 0.6103, 0.5055]}, {"w": "by", "b": [0.6185, 0.484, 0.6386, 0.5055]}, {"w": "feeding", "b": [0.6469, 0.484, 0.7085, 0.5055]}, {"w": "it", "b": [0.7167, 0.484, 0.7286, 0.5055]}, {"w": "data", "b": [0.7368, 0.484, 0.7721, 0.5055]}, {"w": "instances", "b": [0.7803, 0.484, 0.8571, 0.5055]}, {"w": "sequentially,", "b": [0.1429, 0.5031, 0.2453, 0.5245]}, {"w": "either", "b": [0.2509, 0.5031, 0.2994, 0.5245]}, {"w": "individually", "b": [0.3049, 0.5031, 0.405, 0.5245]}, {"w": "or", "b": [0.4105, 0.5031, 0.4289, 0.5245]}, {"w": "by", "b": [0.4344, 0.5031, 0.4545, 0.5245]}, {"w": "small", "b": [0.4601, 0.5031, 0.5045, 0.5245]}, {"w": "groups", "b": [0.51, 0.5031, 0.5677, 0.5245]}, {"w": "called", "b": [0.5732, 0.5031, 0.6216, 0.5245]}, {"w": "mini-batches.", "b": [0.6271, 0.5029, 0.7361, 0.5245]}, {"w": "Each", "b": [0.7416, 0.5031, 0.7825, 0.5245]}, {"w": "learning", "b": [0.788, 0.5031, 0.8571, 0.5245]}, {"w": "step", "b": [0.1429, 0.5221, 0.1766, 0.5435]}, {"w": "is", "b": [0.1825, 0.5221, 0.1957, 0.5435]}, {"w": "fast", "b": [0.2015, 0.5221, 0.2309, 0.5435]}, {"w": "and", "b": [0.2367, 0.5221, 0.2682, 0.5435]}, {"w": "cheap,", "b": [0.2741, 0.5221, 0.3267, 0.5435]}, {"w": "so", "b": [0.3325, 0.5221, 0.3508, 0.5435]}, {"w": "the", "b": [0.3566, 0.5221, 0.383, 0.5435]}, {"w": "system", "b": [0.3888, 0.5221, 0.4459, 0.5435]}, {"w": "can", "b": [0.4518, 0.5221, 0.4811, 0.5435]}, {"w": "learn", "b": [0.487, 0.5221, 0.5294, 0.5435]}, {"w": "about", "b": [0.5352, 0.5221, 0.583, 0.5435]}, {"w": "new", "b": [0.5888, 0.5221, 0.6234, 0.5435]}, {"w": "data", "b": [0.6292, 0.5221, 0.6644, 0.5435]}, {"w": "on", "b": [0.6703, 0.5221, 0.6923, 0.5435]}, {"w": "the", "b": [0.6981, 0.5221, 0.7245, 0.5435]}, {"w": "fly,", "b": [0.7303, 0.5221, 0.7546, 0.5435]}, {"w": "as", "b": [0.7604, 0.5221, 0.7772, 0.5435]}, {"w": "it", "b": [0.783, 0.5221, 0.795, 0.5435]}, {"w": "arrives", "b": [0.8008, 0.5221, 0.8571, 0.5435]}, {"w": "(see", "b": [0.1429, 0.5412, 0.1754, 0.5626]}, {"w": "Figure", "b": [0.1801, 0.5412, 0.2341, 0.5626]}, {"w": "1-13).", "b": [0.2389, 0.5412, 0.2882, 0.5626]}]}, {"id": "b_7", "type": "equation", "text": "Figure 1-13. Online learning", "words": [{"w": "Figure", "b": [0.1429, 0.8056, 0.1943, 0.8273]}, {"w": "1-13.", "b": [0.1991, 0.8056, 0.2407, 0.8273]}, {"w": "Online", "b": [0.2455, 0.8056, 0.3008, 0.8273]}, {"w": "learning", "b": [0.3056, 0.8056, 0.3723, 0.8273]}]}, {"id": "b_8", "type": "paragraph", "text": "Online learning is great for systems that receive data as a continuous flow (e.g., stock prices) and need to adapt to change rapidly or autonomously. It is also a good option", "words": [{"w": "Online", "b": [0.1429, 0.843, 0.2009, 0.8644]}, {"w": "learning", "b": [0.2064, 0.843, 0.2755, 0.8644]}, {"w": "is", "b": [0.2811, 0.843, 0.2943, 0.8644]}, {"w": "great", "b": [0.2998, 0.843, 0.3412, 0.8644]}, {"w": "for", "b": [0.3467, 0.843, 0.3713, 0.8644]}, {"w": "systems", "b": [0.3768, 0.843, 0.4415, 0.8644]}, {"w": "that", "b": [0.447, 0.843, 0.4796, 0.8644]}, {"w": "receive", "b": [0.4851, 0.843, 0.5435, 0.8644]}, {"w": "data", "b": [0.549, 0.843, 0.5842, 0.8644]}, {"w": "as", "b": [0.5897, 0.843, 0.6065, 0.8644]}, {"w": "a", "b": [0.612, 0.843, 0.6212, 0.8644]}, {"w": "continuous", "b": [0.6267, 0.843, 0.7204, 0.8644]}, {"w": "flow", "b": [0.726, 0.843, 0.7623, 0.8644]}, {"w": "(e.g.,", "b": [0.7678, 0.843, 0.8079, 0.8644]}, {"w": "stock", "b": [0.8134, 0.843, 0.8571, 0.8644]}, {"w": "prices)", "b": [0.1429, 0.8621, 0.1996, 0.8835]}, {"w": "and", "b": [0.205, 0.8621, 0.2366, 0.8835]}, {"w": "need", "b": [0.242, 0.8621, 0.2821, 0.8835]}, {"w": "to", "b": [0.2875, 0.8621, 0.3044, 0.8835]}, {"w": "adapt", "b": [0.3099, 0.8621, 0.356, 0.8835]}, {"w": "to", "b": [0.3614, 0.8621, 0.3784, 0.8835]}, {"w": "change", "b": [0.3838, 0.8621, 0.4429, 0.8835]}, {"w": "rapidly", "b": [0.4483, 0.8621, 0.5071, 0.8835]}, {"w": "or", "b": [0.5125, 0.8621, 0.5309, 0.8835]}, {"w": "autonomously.", "b": [0.5363, 0.8621, 0.6595, 0.8835]}, {"w": "It", "b": [0.6649, 0.8621, 0.6776, 0.8835]}, {"w": "is", "b": [0.683, 0.8621, 0.6962, 0.8835]}, {"w": "also", "b": [0.7016, 0.8621, 0.7343, 0.8835]}, {"w": "a", "b": [0.7397, 0.8621, 0.7488, 0.8835]}, {"w": "good", "b": [0.7542, 0.8621, 0.7962, 0.8835]}, {"w": "option", "b": [0.8017, 0.8621, 0.8572, 0.8835]}]}, {"id": "b_9", "type": "paragraph", "text": "16 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "16", "b": [0.1428, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.337, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 43, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "if you have limited computing resources: once an online learning system has learned about new data instances, it does not need them anymore, so you can discard them (unless you want to be able to roll back to a previous state and “replay” the data). This can save a huge amount of space.", "words": [{"w": "if", "b": [0.1429, 0.0791, 0.1546, 0.1005]}, {"w": "you", "b": [0.1603, 0.0791, 0.1916, 0.1005]}, {"w": "have", "b": [0.1973, 0.0791, 0.2357, 0.1005]}, {"w": "limited", "b": [0.2414, 0.0791, 0.3011, 0.1005]}, {"w": "computing", "b": [0.3068, 0.0791, 0.398, 0.1005]}, {"w": "resources:", "b": [0.4037, 0.0791, 0.4874, 0.1005]}, {"w": "once", "b": [0.4931, 0.0791, 0.5328, 0.1005]}, {"w": "an", "b": [0.5385, 0.0791, 0.559, 0.1005]}, {"w": "online", "b": [0.5648, 0.0791, 0.6179, 0.1005]}, {"w": "learning", "b": [0.6236, 0.0791, 0.6927, 0.1005]}, {"w": "system", "b": [0.6984, 0.0791, 0.7556, 0.1005]}, {"w": "has", "b": [0.7613, 0.0791, 0.7892, 0.1005]}, {"w": "learned", "b": [0.7949, 0.0791, 0.8571, 0.1005]}, {"w": "about", "b": [0.1429, 0.0981, 0.1906, 0.1195]}, {"w": "new", "b": [0.1971, 0.0981, 0.2317, 0.1195]}, {"w": "data", "b": [0.2382, 0.0981, 0.2734, 0.1195]}, {"w": "instances,", "b": [0.28, 0.0981, 0.3616, 0.1195]}, {"w": "it", "b": [0.3681, 0.0981, 0.38, 0.1195]}, {"w": "does", "b": [0.3866, 0.0981, 0.4247, 0.1195]}, {"w": "not", "b": [0.4312, 0.0981, 0.4596, 0.1195]}, {"w": "need", "b": [0.4661, 0.0981, 0.5062, 0.1195]}, {"w": "them", "b": [0.5127, 0.0981, 0.5561, 0.1195]}, {"w": "anymore,", "b": [0.5627, 0.0981, 0.6413, 0.1195]}, {"w": "so", "b": [0.6478, 0.0981, 0.6661, 0.1195]}, {"w": "you", "b": [0.6726, 0.0981, 0.7039, 0.1195]}, {"w": "can", "b": [0.7104, 0.0981, 0.7398, 0.1195]}, {"w": "discard", "b": [0.7463, 0.0981, 0.8072, 0.1195]}, {"w": "them", "b": [0.8137, 0.0981, 0.8571, 0.1195]}, {"w": "(unless", "b": [0.1429, 0.1172, 0.2019, 0.1386]}, {"w": "you", "b": [0.2068, 0.1172, 0.2381, 0.1386]}, {"w": "want", "b": [0.2429, 0.1172, 0.2837, 0.1386]}, {"w": "to", "b": [0.2886, 0.1172, 0.3055, 0.1386]}, {"w": "be", "b": [0.3104, 0.1172, 0.3298, 0.1386]}, {"w": "able", "b": [0.3347, 0.1172, 0.3685, 0.1386]}, {"w": "to", "b": [0.3734, 0.1172, 0.3904, 0.1386]}, {"w": "roll", "b": [0.3952, 0.1172, 0.4241, 0.1386]}, {"w": "back", "b": [0.429, 0.1172, 0.4679, 0.1386]}, {"w": "to", "b": [0.4727, 0.1172, 0.4897, 0.1386]}, {"w": "a", "b": [0.4946, 0.1172, 0.5037, 0.1386]}, {"w": "previous", "b": [0.5086, 0.1172, 0.5806, 0.1386]}, {"w": "state", "b": [0.5855, 0.1172, 0.6235, 0.1386]}, {"w": "and", "b": [0.6283, 0.1172, 0.6599, 0.1386]}, {"w": "“replay”", "b": [0.6647, 0.1172, 0.7318, 0.1386]}, {"w": "the", "b": [0.7367, 0.1172, 0.763, 0.1386]}, {"w": "data).", "b": [0.7679, 0.1172, 0.8151, 0.1386]}, {"w": "This", "b": [0.8199, 0.1172, 0.8572, 0.1386]}, {"w": "can", "b": [0.1429, 0.1362, 0.1722, 0.1576]}, {"w": "save", "b": [0.1769, 0.1362, 0.2119, 0.1576]}, {"w": "a", "b": [0.2166, 0.1362, 0.2257, 0.1576]}, {"w": "huge", "b": [0.2305, 0.1362, 0.2709, 0.1576]}, {"w": "amount", "b": [0.2756, 0.1362, 0.3408, 0.1576]}, {"w": "of", "b": [0.3456, 0.1362, 0.3624, 0.1576]}, {"w": "space.", "b": [0.3671, 0.1362, 0.4172, 0.1576]}]}, {"id": "b_1", "type": "paragraph", "text": "Online learning algorithms can also be used to train systems on huge datasets that cannot fit in one machine’s main memory (this is called out-of-core learning). The algorithm loads part of the data, runs a training step on that data, and repeats the process until it has run on all of the data (see Figure 1-14).", "words": [{"w": "Online", "b": [0.1429, 0.1643, 0.2009, 0.1857]}, {"w": "learning", "b": [0.2082, 0.1643, 0.2773, 0.1857]}, {"w": "algorithms", "b": [0.2845, 0.1643, 0.3748, 0.1857]}, {"w": "can", "b": [0.382, 0.1643, 0.4114, 0.1857]}, {"w": "also", "b": [0.4186, 0.1643, 0.4513, 0.1857]}, {"w": "be", "b": [0.4586, 0.1643, 0.478, 0.1857]}, {"w": "used", "b": [0.4852, 0.1643, 0.5238, 0.1857]}, {"w": "to", "b": [0.531, 0.1643, 0.548, 0.1857]}, {"w": "train", "b": [0.5552, 0.1643, 0.5954, 0.1857]}, {"w": "systems", "b": [0.6027, 0.1643, 0.6675, 0.1857]}, {"w": "on", "b": [0.6747, 0.1643, 0.6967, 0.1857]}, {"w": "huge", "b": [0.7039, 0.1643, 0.7443, 0.1857]}, {"w": "datasets", "b": [0.7516, 0.1643, 0.8173, 0.1857]}, {"w": "that", "b": [0.8246, 0.1643, 0.8571, 0.1857]}, {"w": "cannot", "b": [0.1429, 0.1834, 0.2006, 0.2048]}, {"w": "fit", "b": [0.2083, 0.1834, 0.2264, 0.2048]}, {"w": "in", "b": [0.2341, 0.1834, 0.2511, 0.2048]}, {"w": "one", "b": [0.2588, 0.1834, 0.2897, 0.2048]}, {"w": "machine’s", "b": [0.2974, 0.1834, 0.3785, 0.2048]}, {"w": "main", "b": [0.3862, 0.1834, 0.4294, 0.2048]}, {"w": "memory", "b": [0.4371, 0.1834, 0.5086, 0.2048]}, {"w": "(this", "b": [0.5163, 0.1834, 0.5542, 0.2048]}, {"w": "is", "b": [0.5619, 0.1834, 0.5751, 0.2048]}, {"w": "called", "b": [0.5829, 0.1834, 0.6312, 0.2048]}, {"w": "out-of-core", "b": [0.6389, 0.1832, 0.7278, 0.2048]}, {"w": "learning).", "b": [0.7355, 0.1834, 0.8166, 0.2048]}, {"w": "The", "b": [0.8243, 0.1834, 0.8571, 0.2048]}, {"w": "algorithm", "b": [0.1428, 0.2024, 0.2255, 0.2238]}, {"w": "loads", "b": [0.2329, 0.2024, 0.2766, 0.2238]}, {"w": "part", "b": [0.284, 0.2024, 0.3182, 0.2238]}, {"w": "of", "b": [0.3256, 0.2024, 0.3424, 0.2238]}, {"w": "the", "b": [0.3498, 0.2024, 0.3762, 0.2238]}, {"w": "data,", "b": [0.3836, 0.2024, 0.4236, 0.2238]}, {"w": "runs", "b": [0.431, 0.2024, 0.4689, 0.2238]}, {"w": "a", "b": [0.4763, 0.2024, 0.4854, 0.2238]}, {"w": "training", "b": [0.4929, 0.2024, 0.5598, 0.2238]}, {"w": "step", "b": [0.5672, 0.2024, 0.601, 0.2238]}, {"w": "on", "b": [0.6084, 0.2024, 0.6304, 0.2238]}, {"w": "that", "b": [0.6379, 0.2024, 0.6704, 0.2238]}, {"w": "data,", "b": [0.6779, 0.2024, 0.7179, 0.2238]}, {"w": "and", "b": [0.7253, 0.2024, 0.7568, 0.2238]}, {"w": "repeats", "b": [0.7643, 0.2024, 0.8234, 0.2238]}, {"w": "the", "b": [0.8308, 0.2024, 0.8571, 0.2238]}, {"w": "process", "b": [0.1429, 0.2215, 0.2051, 0.2429]}, {"w": "until", "b": [0.2098, 0.2215, 0.2491, 0.2429]}, {"w": "it", "b": [0.2538, 0.2215, 0.2658, 0.2429]}, {"w": "has", "b": [0.2705, 0.2215, 0.2984, 0.2429]}, {"w": "run", "b": [0.3031, 0.2215, 0.3333, 0.2429]}, {"w": "on", "b": [0.3381, 0.2215, 0.3601, 0.2429]}, {"w": "all", "b": [0.3648, 0.2215, 0.3845, 0.2429]}, {"w": "of", "b": [0.3892, 0.2215, 0.406, 0.2429]}, {"w": "the", "b": [0.4107, 0.2215, 0.4371, 0.2429]}, {"w": "data", "b": [0.4418, 0.2215, 0.4771, 0.2429]}, {"w": "(see", "b": [0.4818, 0.2215, 0.5143, 0.2429]}, {"w": "Figure", "b": [0.5191, 0.2215, 0.5731, 0.2429]}, {"w": "1-14).", "b": [0.5778, 0.2215, 0.6272, 0.2429]}]}, {"id": "b_2", "type": "paragraph", "text": "Out-of-core learning is usually done offline (i.e., not on the live system), so online learning can be a confusing name. Think of it as incremental learning.", "words": [{"w": "Out-of-core", "b": [0.2714, 0.2634, 0.3634, 0.283]}, {"w": "learning", "b": [0.371, 0.2634, 0.4342, 0.283]}, {"w": "is", "b": [0.4417, 0.2634, 0.4538, 0.283]}, {"w": "usually", "b": [0.4614, 0.2634, 0.5153, 0.283]}, {"w": "done", "b": [0.5229, 0.2634, 0.5612, 0.283]}, {"w": "offline", "b": [0.5687, 0.2634, 0.6181, 0.283]}, {"w": "(i.e.,", "b": [0.6257, 0.2634, 0.6585, 0.283]}, {"w": "not", "b": [0.6661, 0.2634, 0.692, 0.283]}, {"w": "on", "b": [0.6996, 0.2634, 0.7197, 0.283]}, {"w": "the", "b": [0.7272, 0.2634, 0.7513, 0.283]}, {"w": "live", "b": [0.7589, 0.2634, 0.7857, 0.283]}, {"w": "system),", "b": [0.2714, 0.2808, 0.3346, 0.3004]}, {"w": "so", "b": [0.3399, 0.2808, 0.3566, 0.3004]}, {"w": "online", "b": [0.3619, 0.2806, 0.4077, 0.3004]}, {"w": "learning", "b": [0.4131, 0.2806, 0.4741, 0.3004]}, {"w": "can", "b": [0.4794, 0.2808, 0.5062, 0.3004]}, {"w": "be", "b": [0.5116, 0.2808, 0.5293, 0.3004]}, {"w": "a", "b": [0.5347, 0.2808, 0.543, 0.3004]}, {"w": "confusing", "b": [0.5484, 0.2808, 0.6237, 0.3004]}, {"w": "name.", "b": [0.6291, 0.2808, 0.6759, 0.3004]}, {"w": "Think", "b": [0.6812, 0.2808, 0.7281, 0.3004]}, {"w": "of", "b": [0.7334, 0.2808, 0.7488, 0.3004]}, {"w": "it", "b": [0.7541, 0.2808, 0.765, 0.3004]}, {"w": "as", "b": [0.7704, 0.2808, 0.7857, 0.3004]}, {"w": "incremental", "b": [0.2714, 0.298, 0.3596, 0.3178]}, {"w": "learning.", "b": [0.3639, 0.298, 0.4293, 0.3178]}]}, {"id": "b_3", "type": "equation", "text": "Figure 1-14. Using online learning to handle huge datasets", "words": [{"w": "Figure", "b": [0.1429, 0.6244, 0.1943, 0.6461]}, {"w": "1-14.", "b": [0.1991, 0.6244, 0.2407, 0.6461]}, {"w": "Using", "b": [0.2455, 0.6244, 0.2912, 0.6461]}, {"w": "online", "b": [0.296, 0.6244, 0.3461, 0.6461]}, {"w": "learning", "b": [0.3508, 0.6244, 0.4175, 0.6461]}, {"w": "to", "b": [0.4223, 0.6244, 0.4383, 0.6461]}, {"w": "handle", "b": [0.4431, 0.6244, 0.4983, 0.6461]}, {"w": "huge", "b": [0.5031, 0.6244, 0.5413, 0.6461]}, {"w": "datasets", "b": [0.5461, 0.6244, 0.6114, 0.6461]}]}, {"id": "b_4", "type": "paragraph", "text": "One important parameter of online learning systems is how fast they should adapt to changing data: this is called the learning rate. If you set a high learning rate, then your system will rapidly adapt to new data, but it will also tend to quickly forget the old data (you don’t want a spam filter to flag only the latest kinds of spam it was shown). Conversely, if you set a low learning rate, the system will have more inertia; that is, it will learn more slowly, but it will also be less sensitive to noise in the new data or to sequences of nonrepresentative data points (outliers).", "words": [{"w": "One", "b": [0.1429, 0.6618, 0.1787, 0.6833]}, {"w": "important", "b": [0.1841, 0.6618, 0.2684, 0.6833]}, {"w": "parameter", "b": [0.2738, 0.6618, 0.3596, 0.6833]}, {"w": "of", "b": [0.365, 0.6618, 0.3818, 0.6833]}, {"w": "online", "b": [0.3872, 0.6618, 0.4403, 0.6833]}, {"w": "learning", "b": [0.4457, 0.6618, 0.5149, 0.6833]}, {"w": "systems", "b": [0.5203, 0.6618, 0.585, 0.6833]}, {"w": "is", "b": [0.5904, 0.6618, 0.6037, 0.6833]}, {"w": "how", "b": [0.6091, 0.6618, 0.6451, 0.6833]}, {"w": "fast", "b": [0.6505, 0.6618, 0.6798, 0.6833]}, {"w": "they", "b": [0.6852, 0.6618, 0.7211, 0.6833]}, {"w": "should", "b": [0.7265, 0.6618, 0.7832, 0.6833]}, {"w": "adapt", "b": [0.7886, 0.6618, 0.8348, 0.6833]}, {"w": "to", "b": [0.8402, 0.6618, 0.8571, 0.6833]}, {"w": "changing", "b": [0.1429, 0.6809, 0.2198, 0.7023]}, {"w": "data:", "b": [0.2248, 0.6809, 0.2648, 0.7023]}, {"w": "this", "b": [0.2697, 0.6809, 0.3004, 0.7023]}, {"w": "is", "b": [0.3054, 0.6809, 0.3186, 0.7023]}, {"w": "called", "b": [0.3236, 0.6809, 0.3719, 0.7023]}, {"w": "the", "b": [0.3769, 0.6809, 0.4032, 0.7023]}, {"w": "learning", "b": [0.4082, 0.6807, 0.4749, 0.7023]}, {"w": "rate.", "b": [0.4797, 0.6807, 0.5161, 0.7023]}, {"w": "If", "b": [0.5211, 0.6809, 0.5344, 0.7023]}, {"w": "you", "b": [0.5393, 0.6809, 0.5706, 0.7023]}, {"w": "set", "b": [0.5755, 0.6809, 0.5984, 0.7023]}, {"w": "a", "b": [0.6033, 0.6809, 0.6125, 0.7023]}, {"w": "high", "b": [0.6175, 0.6809, 0.655, 0.7023]}, {"w": "learning", "b": [0.66, 0.6809, 0.7291, 0.7023]}, {"w": "rate,", "b": [0.7341, 0.6809, 0.7705, 0.7023]}, {"w": "then", "b": [0.7755, 0.6809, 0.8132, 0.7023]}, {"w": "your", "b": [0.8182, 0.6809, 0.8571, 0.7023]}, {"w": "system", "b": [0.1429, 0.6999, 0.2, 0.7213]}, {"w": "will", "b": [0.2068, 0.6999, 0.2372, 0.7213]}, {"w": "rapidly", "b": [0.244, 0.6999, 0.3028, 0.7213]}, {"w": "adapt", "b": [0.3096, 0.6999, 0.3557, 0.7213]}, {"w": "to", "b": [0.3625, 0.6999, 0.3795, 0.7213]}, {"w": "new", "b": [0.3863, 0.6999, 0.4208, 0.7213]}, {"w": "data,", "b": [0.4276, 0.6999, 0.4676, 0.7213]}, {"w": "but", "b": [0.4744, 0.6999, 0.5024, 0.7213]}, {"w": "it", "b": [0.5092, 0.6999, 0.5212, 0.7213]}, {"w": "will", "b": [0.5279, 0.6999, 0.5583, 0.7213]}, {"w": "also", "b": [0.5651, 0.6999, 0.5978, 0.7213]}, {"w": "tend", "b": [0.6046, 0.6999, 0.6422, 0.7213]}, {"w": "to", "b": [0.649, 0.6999, 0.666, 0.7213]}, {"w": "quickly", "b": [0.6728, 0.6999, 0.7341, 0.7213]}, {"w": "forget", "b": [0.7409, 0.6999, 0.7903, 0.7213]}, {"w": "the", "b": [0.7971, 0.6999, 0.8235, 0.7213]}, {"w": "old", "b": [0.8303, 0.6999, 0.8572, 0.7213]}, {"w": "data", "b": [0.1429, 0.719, 0.1781, 0.7404]}, {"w": "(you", "b": [0.1836, 0.719, 0.222, 0.7404]}, {"w": "don’t", "b": [0.2275, 0.719, 0.2691, 0.7404]}, {"w": "want", "b": [0.2746, 0.719, 0.3154, 0.7404]}, {"w": "a", "b": [0.3208, 0.719, 0.33, 0.7404]}, {"w": "spam", "b": [0.3355, 0.719, 0.3802, 0.7404]}, {"w": "filter", "b": [0.3857, 0.719, 0.4257, 0.7404]}, {"w": "to", "b": [0.4311, 0.719, 0.4481, 0.7404]}, {"w": "flag", "b": [0.4536, 0.719, 0.4839, 0.7404]}, {"w": "only", "b": [0.4894, 0.719, 0.5263, 0.7404]}, {"w": "the", "b": [0.5317, 0.719, 0.5581, 0.7404]}, {"w": "latest", "b": [0.5635, 0.719, 0.6068, 0.7404]}, {"w": "kinds", "b": [0.6122, 0.719, 0.6582, 0.7404]}, {"w": "of", "b": [0.6637, 0.719, 0.6805, 0.7404]}, {"w": "spam", "b": [0.6859, 0.719, 0.7307, 0.7404]}, {"w": "it", "b": [0.7362, 0.719, 0.7481, 0.7404]}, {"w": "was", "b": [0.7536, 0.719, 0.7847, 0.7404]}, {"w": "shown).", "b": [0.7901, 0.719, 0.8571, 0.7404]}, {"w": "Conversely,", "b": [0.1429, 0.738, 0.239, 0.7594]}, {"w": "if", "b": [0.2446, 0.738, 0.2564, 0.7594]}, {"w": "you", "b": [0.2619, 0.738, 0.2932, 0.7594]}, {"w": "set", "b": [0.2987, 0.738, 0.3216, 0.7594]}, {"w": "a", "b": [0.3271, 0.738, 0.3363, 0.7594]}, {"w": "low", "b": [0.3418, 0.738, 0.372, 0.7594]}, {"w": "learning", "b": [0.3776, 0.738, 0.4467, 0.7594]}, {"w": "rate,", "b": [0.4523, 0.738, 0.4887, 0.7594]}, {"w": "the", "b": [0.4942, 0.738, 0.5206, 0.7594]}, {"w": "system", "b": [0.5261, 0.738, 0.5833, 0.7594]}, {"w": "will", "b": [0.5888, 0.738, 0.6192, 0.7594]}, {"w": "have", "b": [0.6248, 0.738, 0.6632, 0.7594]}, {"w": "more", "b": [0.6687, 0.738, 0.713, 0.7594]}, {"w": "inertia;", "b": [0.7186, 0.738, 0.778, 0.7594]}, {"w": "that", "b": [0.7835, 0.738, 0.8161, 0.7594]}, {"w": "is,", "b": [0.8217, 0.738, 0.8396, 0.7594]}, {"w": "it", "b": [0.8452, 0.738, 0.8571, 0.7594]}, {"w": "will", "b": [0.1428, 0.7571, 0.1732, 0.7785]}, {"w": "learn", "b": [0.1793, 0.7571, 0.2217, 0.7785]}, {"w": "more", "b": [0.2277, 0.7571, 0.272, 0.7785]}, {"w": "slowly,", "b": [0.278, 0.7571, 0.3339, 0.7785]}, {"w": "but", "b": [0.3399, 0.7571, 0.3679, 0.7785]}, {"w": "it", "b": [0.3739, 0.7571, 0.3858, 0.7785]}, {"w": "will", "b": [0.3919, 0.7571, 0.4223, 0.7785]}, {"w": "also", "b": [0.4283, 0.7571, 0.461, 0.7785]}, {"w": "be", "b": [0.467, 0.7571, 0.4864, 0.7785]}, {"w": "less", "b": [0.4924, 0.7571, 0.5219, 0.7785]}, {"w": "sensitive", "b": [0.5279, 0.7571, 0.5995, 0.7785]}, {"w": "to", "b": [0.6055, 0.7571, 0.6225, 0.7785]}, {"w": "noise", "b": [0.6285, 0.7571, 0.6726, 0.7785]}, {"w": "in", "b": [0.6786, 0.7571, 0.6956, 0.7785]}, {"w": "the", "b": [0.7016, 0.7571, 0.7279, 0.7785]}, {"w": "new", "b": [0.734, 0.7571, 0.7685, 0.7785]}, {"w": "data", "b": [0.7745, 0.7571, 0.8098, 0.7785]}, {"w": "or", "b": [0.8158, 0.7571, 0.8341, 0.7785]}, {"w": "to", "b": [0.8402, 0.7571, 0.8571, 0.7785]}, {"w": "sequences", "b": [0.1429, 0.7761, 0.2266, 0.7975]}, {"w": "of", "b": [0.2314, 0.7761, 0.2482, 0.7975]}, {"w": "nonrepresentative", "b": [0.2529, 0.7761, 0.4034, 0.7975]}, {"w": "data", "b": [0.4082, 0.7761, 0.4434, 0.7975]}, {"w": "points", "b": [0.4481, 0.7761, 0.5003, 0.7975]}, {"w": "(outliers).", "b": [0.505, 0.7761, 0.5873, 0.7975]}]}, {"id": "b_5", "type": "paragraph", "text": "A big challenge with online learning is that if bad data is fed to the system, the sys‐ tem’s performance will gradually decline. If we are talking about a live system, your clients will notice. For example, bad data could come from a malfunctioning sensor on a robot, or from someone spamming a search engine to try to rank high in search", "words": [{"w": "A", "b": [0.1429, 0.8042, 0.1573, 0.8257]}, {"w": "big", "b": [0.1637, 0.8042, 0.1896, 0.8257]}, {"w": "challenge", "b": [0.196, 0.8042, 0.2745, 0.8257]}, {"w": "with", "b": [0.2809, 0.8042, 0.3183, 0.8257]}, {"w": "online", "b": [0.3247, 0.8042, 0.3778, 0.8257]}, {"w": "learning", "b": [0.3843, 0.8042, 0.4534, 0.8257]}, {"w": "is", "b": [0.4598, 0.8042, 0.4731, 0.8257]}, {"w": "that", "b": [0.4795, 0.8042, 0.5121, 0.8257]}, {"w": "if", "b": [0.5185, 0.8042, 0.5302, 0.8257]}, {"w": "bad", "b": [0.5367, 0.8042, 0.5674, 0.8257]}, {"w": "data", "b": [0.5738, 0.8042, 0.6091, 0.8257]}, {"w": "is", "b": [0.6155, 0.8042, 0.6288, 0.8257]}, {"w": "fed", "b": [0.6352, 0.8042, 0.6612, 0.8257]}, {"w": "to", "b": [0.6676, 0.8042, 0.6846, 0.8257]}, {"w": "the", "b": [0.691, 0.8042, 0.7174, 0.8257]}, {"w": "system,", "b": [0.7238, 0.8042, 0.7857, 0.8257]}, {"w": "the", "b": [0.7921, 0.8042, 0.8184, 0.8257]}, {"w": "sys‐", "b": [0.8249, 0.8042, 0.8571, 0.8257]}, {"w": "tem’s", "b": [0.1429, 0.8233, 0.1837, 0.8447]}, {"w": "performance", "b": [0.1904, 0.8233, 0.2977, 0.8447]}, {"w": "will", "b": [0.3043, 0.8233, 0.3347, 0.8447]}, {"w": "gradually", "b": [0.3413, 0.8233, 0.4192, 0.8447]}, {"w": "decline.", "b": [0.4259, 0.8233, 0.4904, 0.8447]}, {"w": "If", "b": [0.497, 0.8233, 0.5103, 0.8447]}, {"w": "we", "b": [0.5169, 0.8233, 0.5401, 0.8447]}, {"w": "are", "b": [0.5467, 0.8233, 0.5724, 0.8447]}, {"w": "talking", "b": [0.579, 0.8233, 0.6369, 0.8447]}, {"w": "about", "b": [0.6435, 0.8233, 0.6913, 0.8447]}, {"w": "a", "b": [0.6979, 0.8233, 0.707, 0.8447]}, {"w": "live", "b": [0.7137, 0.8233, 0.743, 0.8447]}, {"w": "system,", "b": [0.7497, 0.8233, 0.8115, 0.8447]}, {"w": "your", "b": [0.8182, 0.8233, 0.8571, 0.8447]}, {"w": "clients", "b": [0.1429, 0.8423, 0.1964, 0.8638]}, {"w": "will", "b": [0.2029, 0.8423, 0.2333, 0.8638]}, {"w": "notice.", "b": [0.2398, 0.8423, 0.2962, 0.8638]}, {"w": "For", "b": [0.3027, 0.8423, 0.3317, 0.8638]}, {"w": "example,", "b": [0.3383, 0.8423, 0.4125, 0.8638]}, {"w": "bad", "b": [0.4191, 0.8423, 0.4498, 0.8638]}, {"w": "data", "b": [0.4563, 0.8423, 0.4916, 0.8638]}, {"w": "could", "b": [0.4981, 0.8423, 0.5449, 0.8638]}, {"w": "come", "b": [0.5514, 0.8423, 0.5968, 0.8638]}, {"w": "from", "b": [0.6033, 0.8423, 0.6449, 0.8638]}, {"w": "a", "b": [0.6514, 0.8423, 0.6606, 0.8638]}, {"w": "malfunctioning", "b": [0.6671, 0.8423, 0.7967, 0.8638]}, {"w": "sensor", "b": [0.8032, 0.8423, 0.8571, 0.8638]}, {"w": "on", "b": [0.1429, 0.8614, 0.1649, 0.8828]}, {"w": "a", "b": [0.1703, 0.8614, 0.1794, 0.8828]}, {"w": "robot,", "b": [0.1848, 0.8614, 0.2354, 0.8828]}, {"w": "or", "b": [0.2408, 0.8614, 0.2592, 0.8828]}, {"w": "from", "b": [0.2645, 0.8614, 0.3061, 0.8828]}, {"w": "someone", "b": [0.3115, 0.8614, 0.3865, 0.8828]}, {"w": "spamming", "b": [0.3919, 0.8614, 0.4805, 0.8828]}, {"w": "a", "b": [0.4858, 0.8614, 0.495, 0.8828]}, {"w": "search", "b": [0.5004, 0.8614, 0.5537, 0.8828]}, {"w": "engine", "b": [0.559, 0.8614, 0.6149, 0.8828]}, {"w": "to", "b": [0.6202, 0.8614, 0.6372, 0.8828]}, {"w": "try", "b": [0.6426, 0.8614, 0.6668, 0.8828]}, {"w": "to", "b": [0.6722, 0.8614, 0.6892, 0.8828]}, {"w": "rank", "b": [0.6946, 0.8614, 0.7332, 0.8828]}, {"w": "high", "b": [0.7385, 0.8614, 0.7761, 0.8828]}, {"w": "in", "b": [0.7815, 0.8614, 0.7985, 0.8828]}, {"w": "search", "b": [0.8038, 0.8614, 0.8572, 0.8828]}]}, {"id": "b_6", "type": "paragraph", "text": "Types of Machine Learning Systems | 17", "words": [{"w": "Types", "b": [0.5961, 0.9225, 0.6295, 0.9388]}, {"w": "of", "b": [0.6323, 0.9225, 0.6443, 0.9388]}, {"w": "Machine", "b": [0.6471, 0.9225, 0.6971, 0.9388]}, {"w": "Learning", "b": [0.6999, 0.9225, 0.7521, 0.9388]}, {"w": "Systems", "b": [0.7549, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "17", "b": [0.8426, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 44, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "results. To reduce this risk, you need to monitor your system closely and promptly switch learning off (and possibly revert to a previously working state) if you detect a drop in performance. You may also want to monitor the input data and react to abnormal data (e.g., using an anomaly detection algorithm).", "words": [{"w": "results.", "b": [0.1429, 0.0791, 0.2022, 0.1005]}, {"w": "To", "b": [0.2092, 0.0791, 0.2306, 0.1005]}, {"w": "reduce", "b": [0.2376, 0.0791, 0.2939, 0.1005]}, {"w": "this", "b": [0.3009, 0.0791, 0.3316, 0.1005]}, {"w": "risk,", "b": [0.3386, 0.0791, 0.3747, 0.1005]}, {"w": "you", "b": [0.3817, 0.0791, 0.4129, 0.1005]}, {"w": "need", "b": [0.4199, 0.0791, 0.46, 0.1005]}, {"w": "to", "b": [0.467, 0.0791, 0.484, 0.1005]}, {"w": "monitor", "b": [0.491, 0.0791, 0.5604, 0.1005]}, {"w": "your", "b": [0.5674, 0.0791, 0.6064, 0.1005]}, {"w": "system", "b": [0.6134, 0.0791, 0.6705, 0.1005]}, {"w": "closely", "b": [0.6775, 0.0791, 0.7336, 0.1005]}, {"w": "and", "b": [0.7406, 0.0791, 0.7721, 0.1005]}, {"w": "promptly", "b": [0.7791, 0.0791, 0.8571, 0.1005]}, {"w": "switch", "b": [0.1429, 0.0981, 0.1966, 0.1195]}, {"w": "learning", "b": [0.2025, 0.0981, 0.2717, 0.1195]}, {"w": "off", "b": [0.2775, 0.0981, 0.3005, 0.1195]}, {"w": "(and", "b": [0.3064, 0.0981, 0.3451, 0.1195]}, {"w": "possibly", "b": [0.351, 0.0981, 0.4189, 0.1195]}, {"w": "revert", "b": [0.4247, 0.0981, 0.4739, 0.1195]}, {"w": "to", "b": [0.4798, 0.0981, 0.4968, 0.1195]}, {"w": "a", "b": [0.5027, 0.0981, 0.5118, 0.1195]}, {"w": "previously", "b": [0.5177, 0.0981, 0.6046, 0.1195]}, {"w": "working", "b": [0.6105, 0.0981, 0.6802, 0.1195]}, {"w": "state)", "b": [0.686, 0.0981, 0.7312, 0.1195]}, {"w": "if", "b": [0.7371, 0.0981, 0.7489, 0.1195]}, {"w": "you", "b": [0.7547, 0.0981, 0.786, 0.1195]}, {"w": "detect", "b": [0.7919, 0.0981, 0.8421, 0.1195]}, {"w": "a", "b": [0.848, 0.0981, 0.8571, 0.1195]}, {"w": "drop", "b": [0.1429, 0.1172, 0.1831, 0.1386]}, {"w": "in", "b": [0.1918, 0.1172, 0.2088, 0.1386]}, {"w": "performance.", "b": [0.2175, 0.1172, 0.3295, 0.1386]}, {"w": "You", "b": [0.3382, 0.1172, 0.3706, 0.1386]}, {"w": "may", "b": [0.3792, 0.1172, 0.4146, 0.1386]}, {"w": "also", "b": [0.4233, 0.1172, 0.456, 0.1386]}, {"w": "want", "b": [0.4647, 0.1172, 0.5054, 0.1386]}, {"w": "to", "b": [0.5141, 0.1172, 0.5311, 0.1386]}, {"w": "monitor", "b": [0.5398, 0.1172, 0.6092, 0.1386]}, {"w": "the", "b": [0.6178, 0.1172, 0.6442, 0.1386]}, {"w": "input", "b": [0.6529, 0.1172, 0.6978, 0.1386]}, {"w": "data", "b": [0.7064, 0.1172, 0.7417, 0.1386]}, {"w": "and", "b": [0.7504, 0.1172, 0.7819, 0.1386]}, {"w": "react", "b": [0.7906, 0.1172, 0.8315, 0.1386]}, {"w": "to", "b": [0.8402, 0.1172, 0.8572, 0.1386]}, {"w": "abnormal", "b": [0.1429, 0.1362, 0.2238, 0.1576]}, {"w": "data", "b": [0.2285, 0.1362, 0.2638, 0.1576]}, {"w": "(e.g.,", "b": [0.2685, 0.1362, 0.3086, 0.1576]}, {"w": "using", "b": [0.3133, 0.1362, 0.3588, 0.1576]}, {"w": "an", "b": [0.3635, 0.1362, 0.384, 0.1576]}, {"w": "anomaly", "b": [0.3888, 0.1362, 0.461, 0.1576]}, {"w": "detection", "b": [0.4657, 0.1362, 0.5435, 0.1576]}, {"w": "algorithm).", "b": [0.5483, 0.1362, 0.6429, 0.1576]}]}, {"id": "b_1", "type": "equation", "text": "Instance-Based Versus Model-Based Learning", "words": [{"w": "Instance-Based", "b": [0.1429, 0.1704, 0.3004, 0.1989]}, {"w": "Versus", "b": [0.3053, 0.1704, 0.3726, 0.1989]}, {"w": "Model-Based", "b": [0.3775, 0.1704, 0.5122, 0.1989]}, {"w": "Learning", "b": [0.5171, 0.1704, 0.6086, 0.1989]}]}, {"id": "b_2", "type": "paragraph", "text": "One more way to categorize Machine Learning systems is by how they generalize. Most Machine Learning tasks are about making predictions. This means that given a number of training examples, the system needs to be able to generalize to examples it has never seen before. Having a good performance measure on the training data is good, but insufficient; the true goal is to perform well on new instances.", "words": [{"w": "One", "b": [0.1429, 0.2048, 0.1787, 0.2263]}, {"w": "more", "b": [0.1867, 0.2048, 0.231, 0.2263]}, {"w": "way", "b": [0.239, 0.2048, 0.2716, 0.2263]}, {"w": "to", "b": [0.2796, 0.2048, 0.2966, 0.2263]}, {"w": "categorize", "b": [0.3046, 0.2048, 0.3887, 0.2263]}, {"w": "Machine", "b": [0.3967, 0.2048, 0.4698, 0.2263]}, {"w": "Learning", "b": [0.4779, 0.2048, 0.5529, 0.2263]}, {"w": "systems", "b": [0.5609, 0.2048, 0.6257, 0.2263]}, {"w": "is", "b": [0.6337, 0.2048, 0.647, 0.2263]}, {"w": "by", "b": [0.655, 0.2048, 0.6751, 0.2263]}, {"w": "how", "b": [0.6832, 0.2048, 0.7192, 0.2263]}, {"w": "they", "b": [0.7272, 0.2048, 0.7631, 0.2263]}, {"w": "generalize.", "b": [0.7711, 0.2046, 0.8571, 0.2263]}, {"w": "Most", "b": [0.1429, 0.2239, 0.1855, 0.2453]}, {"w": "Machine", "b": [0.1912, 0.2239, 0.2643, 0.2453]}, {"w": "Learning", "b": [0.27, 0.2239, 0.345, 0.2453]}, {"w": "tasks", "b": [0.3507, 0.2239, 0.3918, 0.2453]}, {"w": "are", "b": [0.3975, 0.2239, 0.4232, 0.2453]}, {"w": "about", "b": [0.4289, 0.2239, 0.4767, 0.2453]}, {"w": "making", "b": [0.4823, 0.2239, 0.5456, 0.2453]}, {"w": "predictions.", "b": [0.5513, 0.2239, 0.6505, 0.2453]}, {"w": "This", "b": [0.6562, 0.2239, 0.6934, 0.2453]}, {"w": "means", "b": [0.6991, 0.2239, 0.7532, 0.2453]}, {"w": "that", "b": [0.7588, 0.2239, 0.7914, 0.2453]}, {"w": "given", "b": [0.7971, 0.2239, 0.8423, 0.2453]}, {"w": "a", "b": [0.848, 0.2239, 0.8571, 0.2453]}, {"w": "number", "b": [0.1429, 0.2429, 0.2092, 0.2644]}, {"w": "of", "b": [0.2144, 0.2429, 0.2312, 0.2644]}, {"w": "training", "b": [0.2365, 0.2429, 0.3034, 0.2644]}, {"w": "examples,", "b": [0.3087, 0.2429, 0.3906, 0.2644]}, {"w": "the", "b": [0.3958, 0.2429, 0.4222, 0.2644]}, {"w": "system", "b": [0.4274, 0.2429, 0.4846, 0.2644]}, {"w": "needs", "b": [0.4898, 0.2429, 0.5376, 0.2644]}, {"w": "to", "b": [0.5428, 0.2429, 0.5598, 0.2644]}, {"w": "be", "b": [0.5651, 0.2429, 0.5845, 0.2644]}, {"w": "able", "b": [0.5897, 0.2429, 0.6236, 0.2644]}, {"w": "to", "b": [0.6289, 0.2429, 0.6458, 0.2644]}, {"w": "generalize", "b": [0.6511, 0.2429, 0.7353, 0.2644]}, {"w": "to", "b": [0.7405, 0.2429, 0.7575, 0.2644]}, {"w": "examples", "b": [0.7628, 0.2429, 0.84, 0.2644]}, {"w": "it", "b": [0.8452, 0.2429, 0.8572, 0.2644]}, {"w": "has", "b": [0.1429, 0.262, 0.1708, 0.2834]}, {"w": "never", "b": [0.1779, 0.262, 0.2244, 0.2834]}, {"w": "seen", "b": [0.2315, 0.262, 0.2682, 0.2834]}, {"w": "before.", "b": [0.2753, 0.262, 0.3329, 0.2834]}, {"w": "Having", "b": [0.34, 0.262, 0.4006, 0.2834]}, {"w": "a", "b": [0.4077, 0.262, 0.4169, 0.2834]}, {"w": "good", "b": [0.424, 0.262, 0.466, 0.2834]}, {"w": "performance", "b": [0.4731, 0.262, 0.5804, 0.2834]}, {"w": "measure", "b": [0.5875, 0.262, 0.6578, 0.2834]}, {"w": "on", "b": [0.6649, 0.262, 0.687, 0.2834]}, {"w": "the", "b": [0.6941, 0.262, 0.7204, 0.2834]}, {"w": "training", "b": [0.7275, 0.262, 0.7945, 0.2834]}, {"w": "data", "b": [0.8016, 0.262, 0.8368, 0.2834]}, {"w": "is", "b": [0.8439, 0.262, 0.8571, 0.2834]}, {"w": "good,", "b": [0.1429, 0.281, 0.1896, 0.3025]}, {"w": "but", "b": [0.1943, 0.281, 0.2223, 0.3025]}, {"w": "insufficient;", "b": [0.2271, 0.281, 0.326, 0.3025]}, {"w": "the", "b": [0.3308, 0.281, 0.3571, 0.3025]}, {"w": "true", "b": [0.3618, 0.281, 0.3958, 0.3025]}, {"w": "goal", "b": [0.4005, 0.281, 0.4353, 0.3025]}, {"w": "is", "b": [0.4401, 0.281, 0.4533, 0.3025]}, {"w": "to", "b": [0.458, 0.281, 0.475, 0.3025]}, {"w": "perform", "b": [0.4797, 0.281, 0.5488, 0.3025]}, {"w": "well", "b": [0.5535, 0.281, 0.5872, 0.3025]}, {"w": "on", "b": [0.5919, 0.281, 0.614, 0.3025]}, {"w": "new", "b": [0.6187, 0.281, 0.6532, 0.3025]}, {"w": "instances.", "b": [0.6579, 0.281, 0.7395, 0.3025]}]}, {"id": "b_3", "type": "paragraph", "text": "There are two main approaches to generalization: instance-based learning and model-based learning.", "words": [{"w": "There", "b": [0.1429, 0.3092, 0.1923, 0.3306]}, {"w": "are", "b": [0.204, 0.3092, 0.2298, 0.3306]}, {"w": "two", "b": [0.2415, 0.3092, 0.2728, 0.3306]}, {"w": "main", "b": [0.2846, 0.3092, 0.3277, 0.3306]}, {"w": "approaches", "b": [0.3395, 0.3092, 0.434, 0.3306]}, {"w": "to", "b": [0.4458, 0.3092, 0.4628, 0.3306]}, {"w": "generalization:", "b": [0.4745, 0.3092, 0.5973, 0.3306]}, {"w": "instance-based", "b": [0.6091, 0.3092, 0.7329, 0.3306]}, {"w": "learning", "b": [0.7447, 0.3092, 0.8138, 0.3306]}, {"w": "and", "b": [0.8256, 0.3092, 0.8571, 0.3306]}, {"w": "model-based", "b": [0.1428, 0.3282, 0.2503, 0.3496]}, {"w": "learning.", "b": [0.255, 0.3282, 0.3289, 0.3496]}]}, {"id": "b_4", "type": "equation", "text": "Instance-based learning", "words": [{"w": "Instance-based", "b": [0.1429, 0.3655, 0.2577, 0.3865]}, {"w": "learning", "b": [0.2613, 0.3655, 0.3249, 0.3865]}]}, {"id": "b_5", "type": "paragraph", "text": "Possibly the most trivial form of learning is simply to learn by heart. If you were to create a spam filter this way, it would just flag all emails that are identical to emails that have already been flagged by users—not the worst solution, but certainly not the best.", "words": [{"w": "Possibly", "b": [0.1429, 0.3921, 0.2108, 0.4136]}, {"w": "the", "b": [0.2173, 0.3921, 0.2437, 0.4136]}, {"w": "most", "b": [0.2502, 0.3921, 0.2918, 0.4136]}, {"w": "trivial", "b": [0.2983, 0.3921, 0.3476, 0.4136]}, {"w": "form", "b": [0.3541, 0.3921, 0.3957, 0.4136]}, {"w": "of", "b": [0.4022, 0.3921, 0.419, 0.4136]}, {"w": "learning", "b": [0.4255, 0.3921, 0.4946, 0.4136]}, {"w": "is", "b": [0.5011, 0.3921, 0.5144, 0.4136]}, {"w": "simply", "b": [0.5209, 0.3921, 0.5765, 0.4136]}, {"w": "to", "b": [0.583, 0.3921, 0.6, 0.4136]}, {"w": "learn", "b": [0.6065, 0.3921, 0.6489, 0.4136]}, {"w": "by", "b": [0.6554, 0.3921, 0.6755, 0.4136]}, {"w": "heart.", "b": [0.682, 0.3921, 0.73, 0.4136]}, {"w": "If", "b": [0.7364, 0.3921, 0.7497, 0.4136]}, {"w": "you", "b": [0.7562, 0.3921, 0.7875, 0.4136]}, {"w": "were", "b": [0.794, 0.3921, 0.8337, 0.4136]}, {"w": "to", "b": [0.8402, 0.3921, 0.8571, 0.4136]}, {"w": "create", "b": [0.1428, 0.4112, 0.1922, 0.4326]}, {"w": "a", "b": [0.1988, 0.4112, 0.208, 0.4326]}, {"w": "spam", "b": [0.2146, 0.4112, 0.2594, 0.4326]}, {"w": "filter", "b": [0.266, 0.4112, 0.3059, 0.4326]}, {"w": "this", "b": [0.3126, 0.4112, 0.3433, 0.4326]}, {"w": "way,", "b": [0.3499, 0.4112, 0.3857, 0.4326]}, {"w": "it", "b": [0.3923, 0.4112, 0.4043, 0.4326]}, {"w": "would", "b": [0.4109, 0.4112, 0.4631, 0.4326]}, {"w": "just", "b": [0.4697, 0.4112, 0.5001, 0.4326]}, {"w": "flag", "b": [0.5068, 0.4112, 0.5371, 0.4326]}, {"w": "all", "b": [0.5437, 0.4112, 0.5634, 0.4326]}, {"w": "emails", "b": [0.57, 0.4112, 0.6236, 0.4326]}, {"w": "that", "b": [0.6302, 0.4112, 0.6628, 0.4326]}, {"w": "are", "b": [0.6694, 0.4112, 0.6951, 0.4326]}, {"w": "identical", "b": [0.7017, 0.4112, 0.7734, 0.4326]}, {"w": "to", "b": [0.78, 0.4112, 0.797, 0.4326]}, {"w": "emails", "b": [0.8036, 0.4112, 0.8571, 0.4326]}, {"w": "that", "b": [0.1429, 0.4302, 0.1754, 0.4516]}, {"w": "have", "b": [0.1809, 0.4302, 0.2193, 0.4516]}, {"w": "already", "b": [0.2247, 0.4302, 0.2854, 0.4516]}, {"w": "been", "b": [0.2908, 0.4302, 0.3305, 0.4516]}, {"w": "flagged", "b": [0.336, 0.4302, 0.3959, 0.4516]}, {"w": "by", "b": [0.4013, 0.4302, 0.4215, 0.4516]}, {"w": "users—not", "b": [0.4269, 0.4302, 0.5174, 0.4516]}, {"w": "the", "b": [0.5229, 0.4302, 0.5492, 0.4516]}, {"w": "worst", "b": [0.5546, 0.4302, 0.6013, 0.4516]}, {"w": "solution,", "b": [0.6067, 0.4302, 0.68, 0.4516]}, {"w": "but", "b": [0.6854, 0.4302, 0.7134, 0.4516]}, {"w": "certainly", "b": [0.7189, 0.4302, 0.7916, 0.4516]}, {"w": "not", "b": [0.797, 0.4302, 0.8254, 0.4516]}, {"w": "the", "b": [0.8308, 0.4302, 0.8571, 0.4516]}, {"w": "best.", "b": [0.1429, 0.4493, 0.181, 0.4707]}]}, {"id": "b_6", "type": "paragraph", "text": "Instead of just flagging emails that are identical to known spam emails, your spam filter could be programmed to also flag emails that are very similar to known spam emails. This requires a measure of similarity between two emails. A (very basic) simi‐ larity measure between two emails could be to count the number of words they have in common. The system would flag an email as spam if it has many words in com‐ mon with a known spam email.", "words": [{"w": "Instead", "b": [0.1429, 0.4774, 0.2044, 0.4988]}, {"w": "of", "b": [0.2115, 0.4774, 0.2283, 0.4988]}, {"w": "just", "b": [0.2355, 0.4774, 0.2659, 0.4988]}, {"w": "flagging", "b": [0.2731, 0.4774, 0.3399, 0.4988]}, {"w": "emails", "b": [0.3471, 0.4774, 0.4007, 0.4988]}, {"w": "that", "b": [0.4079, 0.4774, 0.4405, 0.4988]}, {"w": "are", "b": [0.4476, 0.4774, 0.4734, 0.4988]}, {"w": "identical", "b": [0.4806, 0.4774, 0.5522, 0.4988]}, {"w": "to", "b": [0.5594, 0.4774, 0.5763, 0.4988]}, {"w": "known", "b": [0.5835, 0.4774, 0.6415, 0.4988]}, {"w": "spam", "b": [0.6487, 0.4774, 0.6935, 0.4988]}, {"w": "emails,", "b": [0.7007, 0.4774, 0.759, 0.4988]}, {"w": "your", "b": [0.7662, 0.4774, 0.8052, 0.4988]}, {"w": "spam", "b": [0.8124, 0.4774, 0.8571, 0.4988]}, {"w": "filter", "b": [0.1429, 0.4964, 0.1828, 0.5179]}, {"w": "could", "b": [0.1894, 0.4964, 0.2362, 0.5179]}, {"w": "be", "b": [0.2427, 0.4964, 0.2622, 0.5179]}, {"w": "programmed", "b": [0.2688, 0.4964, 0.3786, 0.5179]}, {"w": "to", "b": [0.3852, 0.4964, 0.4022, 0.5179]}, {"w": "also", "b": [0.4088, 0.4964, 0.4415, 0.5179]}, {"w": "flag", "b": [0.4481, 0.4964, 0.4784, 0.5179]}, {"w": "emails", "b": [0.485, 0.4964, 0.5385, 0.5179]}, {"w": "that", "b": [0.5451, 0.4964, 0.5777, 0.5179]}, {"w": "are", "b": [0.5843, 0.4964, 0.61, 0.5179]}, {"w": "very", "b": [0.6166, 0.4964, 0.653, 0.5179]}, {"w": "similar", "b": [0.6596, 0.4964, 0.7176, 0.5179]}, {"w": "to", "b": [0.7242, 0.4964, 0.7412, 0.5179]}, {"w": "known", "b": [0.7478, 0.4964, 0.8058, 0.5179]}, {"w": "spam", "b": [0.8124, 0.4964, 0.8571, 0.5179]}, {"w": "emails.", "b": [0.1429, 0.5155, 0.2012, 0.5369]}, {"w": "This", "b": [0.2067, 0.5155, 0.2439, 0.5369]}, {"w": "requires", "b": [0.2494, 0.5155, 0.3175, 0.5369]}, {"w": "a", "b": [0.323, 0.5155, 0.3322, 0.5369]}, {"w": "measure", "b": [0.3377, 0.5153, 0.4056, 0.5369]}, {"w": "of", "b": [0.4111, 0.5153, 0.4263, 0.5369]}, {"w": "similarity", "b": [0.4319, 0.5153, 0.5095, 0.5369]}, {"w": "between", "b": [0.5151, 0.5155, 0.5842, 0.5369]}, {"w": "two", "b": [0.5897, 0.5155, 0.621, 0.5369]}, {"w": "emails.", "b": [0.6265, 0.5155, 0.6848, 0.5369]}, {"w": "A", "b": [0.6903, 0.5155, 0.7047, 0.5369]}, {"w": "(very", "b": [0.7102, 0.5155, 0.7538, 0.5369]}, {"w": "basic)", "b": [0.7594, 0.5155, 0.8083, 0.5369]}, {"w": "simi‐", "b": [0.8139, 0.5155, 0.8572, 0.5369]}, {"w": "larity", "b": [0.1429, 0.5345, 0.1865, 0.556]}, {"w": "measure", "b": [0.1922, 0.5345, 0.2626, 0.556]}, {"w": "between", "b": [0.2683, 0.5345, 0.3375, 0.556]}, {"w": "two", "b": [0.3432, 0.5345, 0.3745, 0.556]}, {"w": "emails", "b": [0.3802, 0.5345, 0.4338, 0.556]}, {"w": "could", "b": [0.4395, 0.5345, 0.4863, 0.556]}, {"w": "be", "b": [0.492, 0.5345, 0.5115, 0.556]}, {"w": "to", "b": [0.5172, 0.5345, 0.5342, 0.556]}, {"w": "count", "b": [0.5399, 0.5345, 0.5878, 0.556]}, {"w": "the", "b": [0.5935, 0.5345, 0.6198, 0.556]}, {"w": "number", "b": [0.6256, 0.5345, 0.6919, 0.556]}, {"w": "of", "b": [0.6976, 0.5345, 0.7144, 0.556]}, {"w": "words", "b": [0.7201, 0.5345, 0.7714, 0.556]}, {"w": "they", "b": [0.7771, 0.5345, 0.813, 0.556]}, {"w": "have", "b": [0.8188, 0.5345, 0.8571, 0.556]}, {"w": "in", "b": [0.1429, 0.5536, 0.1598, 0.575]}, {"w": "common.", "b": [0.1665, 0.5536, 0.2468, 0.575]}, {"w": "The", "b": [0.2534, 0.5536, 0.2862, 0.575]}, {"w": "system", "b": [0.2929, 0.5536, 0.35, 0.575]}, {"w": "would", "b": [0.3566, 0.5536, 0.4088, 0.575]}, {"w": "flag", "b": [0.4155, 0.5536, 0.4458, 0.575]}, {"w": "an", "b": [0.4524, 0.5536, 0.473, 0.575]}, {"w": "email", "b": [0.4796, 0.5536, 0.5255, 0.575]}, {"w": "as", "b": [0.5321, 0.5536, 0.5489, 0.575]}, {"w": "spam", "b": [0.5555, 0.5536, 0.6003, 0.575]}, {"w": "if", "b": [0.6069, 0.5536, 0.6187, 0.575]}, {"w": "it", "b": [0.6253, 0.5536, 0.6373, 0.575]}, {"w": "has", "b": [0.6439, 0.5536, 0.6718, 0.575]}, {"w": "many", "b": [0.6784, 0.5536, 0.7251, 0.575]}, {"w": "words", "b": [0.7317, 0.5536, 0.783, 0.575]}, {"w": "in", "b": [0.7896, 0.5536, 0.8066, 0.575]}, {"w": "com‐", "b": [0.8132, 0.5536, 0.8571, 0.575]}, {"w": "mon", "b": [0.1428, 0.5726, 0.1819, 0.5941]}, {"w": "with", "b": [0.1867, 0.5726, 0.224, 0.5941]}, {"w": "a", "b": [0.2287, 0.5726, 0.2379, 0.5941]}, {"w": "known", "b": [0.2426, 0.5726, 0.3006, 0.5941]}, {"w": "spam", "b": [0.3053, 0.5726, 0.3501, 0.5941]}, {"w": "email.", "b": [0.3548, 0.5726, 0.4055, 0.5941]}]}, {"id": "b_7", "type": "paragraph", "text": "This is called instance-based learning: the system learns the examples by heart, then generalizes to new cases by comparing them to the learned examples (or a subset of them), using a similarity measure. For example, in Figure 1-15 the new instance would be classified as a triangle because the majority of the most similar instances belong to that class.", "words": [{"w": "This", "b": [0.1428, 0.6008, 0.1801, 0.6222]}, {"w": "is", "b": [0.1869, 0.6008, 0.2001, 0.6222]}, {"w": "called", "b": [0.2069, 0.6008, 0.2552, 0.6222]}, {"w": "instance-based", "b": [0.262, 0.6005, 0.3816, 0.6222]}, {"w": "learning:", "b": [0.3884, 0.6005, 0.4599, 0.6222]}, {"w": "the", "b": [0.4667, 0.6008, 0.493, 0.6222]}, {"w": "system", "b": [0.4998, 0.6008, 0.5569, 0.6222]}, {"w": "learns", "b": [0.5637, 0.6008, 0.6138, 0.6222]}, {"w": "the", "b": [0.6206, 0.6008, 0.6469, 0.6222]}, {"w": "examples", "b": [0.6537, 0.6008, 0.7309, 0.6222]}, {"w": "by", "b": [0.7377, 0.6008, 0.7578, 0.6222]}, {"w": "heart,", "b": [0.7646, 0.6008, 0.8126, 0.6222]}, {"w": "then", "b": [0.8194, 0.6008, 0.8571, 0.6222]}, {"w": "generalizes", "b": [0.1429, 0.6198, 0.2347, 0.6412]}, {"w": "to", "b": [0.241, 0.6198, 0.258, 0.6412]}, {"w": "new", "b": [0.2643, 0.6198, 0.2988, 0.6412]}, {"w": "cases", "b": [0.3051, 0.6198, 0.3472, 0.6412]}, {"w": "by", "b": [0.3535, 0.6198, 0.3737, 0.6412]}, {"w": "comparing", "b": [0.38, 0.6198, 0.4706, 0.6412]}, {"w": "them", "b": [0.4769, 0.6198, 0.5203, 0.6412]}, {"w": "to", "b": [0.5266, 0.6198, 0.5436, 0.6412]}, {"w": "the", "b": [0.5499, 0.6198, 0.5762, 0.6412]}, {"w": "learned", "b": [0.5825, 0.6198, 0.6448, 0.6412]}, {"w": "examples", "b": [0.6511, 0.6198, 0.7283, 0.6412]}, {"w": "(or", "b": [0.7346, 0.6198, 0.7601, 0.6412]}, {"w": "a", "b": [0.7665, 0.6198, 0.7756, 0.6412]}, {"w": "subset", "b": [0.7819, 0.6198, 0.8341, 0.6412]}, {"w": "of", "b": [0.8404, 0.6198, 0.8571, 0.6412]}, {"w": "them),", "b": [0.1429, 0.6389, 0.1982, 0.6603]}, {"w": "using", "b": [0.2072, 0.6389, 0.2527, 0.6603]}, {"w": "a", "b": [0.2617, 0.6389, 0.2708, 0.6603]}, {"w": "similarity", "b": [0.2798, 0.6389, 0.3593, 0.6603]}, {"w": "measure.", "b": [0.3683, 0.6389, 0.4434, 0.6603]}, {"w": "For", "b": [0.4524, 0.6389, 0.4814, 0.6603]}, {"w": "example,", "b": [0.4904, 0.6389, 0.5647, 0.6603]}, {"w": "in", "b": [0.5737, 0.6389, 0.5907, 0.6603]}, {"w": "Figure", "b": [0.5997, 0.6389, 0.6537, 0.6603]}, {"w": "1-15", "b": [0.6627, 0.6389, 0.7001, 0.6603]}, {"w": "the", "b": [0.7091, 0.6389, 0.7354, 0.6603]}, {"w": "new", "b": [0.7444, 0.6389, 0.779, 0.6603]}, {"w": "instance", "b": [0.788, 0.6389, 0.8571, 0.6603]}, {"w": "would", "b": [0.1429, 0.6579, 0.1951, 0.6793]}, {"w": "be", "b": [0.2024, 0.6579, 0.2219, 0.6793]}, {"w": "classified", "b": [0.2292, 0.6579, 0.3049, 0.6793]}, {"w": "as", "b": [0.3122, 0.6579, 0.329, 0.6793]}, {"w": "a", "b": [0.3363, 0.6579, 0.3455, 0.6793]}, {"w": "triangle", "b": [0.3528, 0.6579, 0.4169, 0.6793]}, {"w": "because", "b": [0.4242, 0.6579, 0.4888, 0.6793]}, {"w": "the", "b": [0.4961, 0.6579, 0.5225, 0.6793]}, {"w": "majority", "b": [0.5298, 0.6579, 0.6008, 0.6793]}, {"w": "of", "b": [0.6081, 0.6579, 0.6249, 0.6793]}, {"w": "the", "b": [0.6323, 0.6579, 0.6586, 0.6793]}, {"w": "most", "b": [0.6659, 0.6579, 0.7076, 0.6793]}, {"w": "similar", "b": [0.7149, 0.6579, 0.773, 0.6793]}, {"w": "instances", "b": [0.7803, 0.6579, 0.8571, 0.6793]}, {"w": "belong", "b": [0.1429, 0.6769, 0.1993, 0.6984]}, {"w": "to", "b": [0.2041, 0.6769, 0.2211, 0.6984]}, {"w": "that", "b": [0.2258, 0.6769, 0.2584, 0.6984]}, {"w": "class.", "b": [0.2631, 0.6769, 0.3064, 0.6984]}]}, {"id": "b_8", "type": "paragraph", "text": "18 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "18", "b": [0.1428, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.337, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 45, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 1-15. Instance-based learning", "words": [{"w": "Figure", "b": [0.1429, 0.2855, 0.1943, 0.3071]}, {"w": "1-15.", "b": [0.1991, 0.2855, 0.2407, 0.3071]}, {"w": "Instance-based", "b": [0.2455, 0.2855, 0.3658, 0.3071]}, {"w": "learning", "b": [0.3706, 0.2855, 0.4373, 0.3071]}]}, {"id": "b_1", "type": "equation", "text": "Model-based learning", "words": [{"w": "Model-based", "b": [0.1429, 0.323, 0.2409, 0.3439]}, {"w": "learning", "b": [0.2445, 0.323, 0.3081, 0.3439]}]}, {"id": "b_2", "type": "paragraph", "text": "Another way to generalize from a set of examples is to build a model of these exam‐ ples, then use that model to make predictions. This is called model-based learning (Figure 1-16).", "words": [{"w": "Another", "b": [0.1429, 0.3496, 0.2133, 0.371]}, {"w": "way", "b": [0.2193, 0.3496, 0.2519, 0.371]}, {"w": "to", "b": [0.2578, 0.3496, 0.2748, 0.371]}, {"w": "generalize", "b": [0.2807, 0.3496, 0.3649, 0.371]}, {"w": "from", "b": [0.3708, 0.3496, 0.4124, 0.371]}, {"w": "a", "b": [0.4183, 0.3496, 0.4275, 0.371]}, {"w": "set", "b": [0.4334, 0.3496, 0.4563, 0.371]}, {"w": "of", "b": [0.4622, 0.3496, 0.479, 0.371]}, {"w": "examples", "b": [0.4849, 0.3496, 0.5621, 0.371]}, {"w": "is", "b": [0.568, 0.3496, 0.5813, 0.371]}, {"w": "to", "b": [0.5872, 0.3496, 0.6042, 0.371]}, {"w": "build", "b": [0.6101, 0.3496, 0.6536, 0.371]}, {"w": "a", "b": [0.6595, 0.3496, 0.6687, 0.371]}, {"w": "model", "b": [0.6746, 0.3496, 0.7274, 0.371]}, {"w": "of", "b": [0.7334, 0.3496, 0.7501, 0.371]}, {"w": "these", "b": [0.7561, 0.3496, 0.7989, 0.371]}, {"w": "exam‐", "b": [0.8048, 0.3496, 0.8572, 0.371]}, {"w": "ples,", "b": [0.1429, 0.3686, 0.1803, 0.3901]}, {"w": "then", "b": [0.1888, 0.3686, 0.2265, 0.3901]}, {"w": "use", "b": [0.235, 0.3686, 0.2626, 0.3901]}, {"w": "that", "b": [0.2711, 0.3686, 0.3037, 0.3901]}, {"w": "model", "b": [0.3122, 0.3686, 0.365, 0.3901]}, {"w": "to", "b": [0.3735, 0.3686, 0.3904, 0.3901]}, {"w": "make", "b": [0.3989, 0.3686, 0.4443, 0.3901]}, {"w": "predictions.", "b": [0.4528, 0.3684, 0.5464, 0.3901]}, {"w": "This", "b": [0.5549, 0.3686, 0.5921, 0.3901]}, {"w": "is", "b": [0.6006, 0.3686, 0.6138, 0.3901]}, {"w": "called", "b": [0.6223, 0.3686, 0.6707, 0.3901]}, {"w": "model-based", "b": [0.6792, 0.3684, 0.7819, 0.3901]}, {"w": "learning", "b": [0.7904, 0.3684, 0.8571, 0.3901]}, {"w": "(Figure", "b": [0.1429, 0.3877, 0.2041, 0.4091]}, {"w": "1-16).", "b": [0.2088, 0.3877, 0.2582, 0.4091]}]}, {"id": "b_3", "type": "equation", "text": "Figure 1-16. Model-based learning", "words": [{"w": "Figure", "b": [0.1429, 0.7022, 0.1943, 0.7238]}, {"w": "1-16.", "b": [0.1991, 0.7022, 0.2407, 0.7238]}, {"w": "Model-based", "b": [0.2455, 0.7022, 0.3496, 0.7238]}, {"w": "learning", "b": [0.3544, 0.7022, 0.4211, 0.7238]}]}, {"id": "b_4", "type": "paragraph", "text": "For example, suppose you want to know if money makes people happy, so you down‐ load the Better Life Index data from the OECD’s website as well as stats about GDP per capita from the IMF’s website. Then you join the tables and sort by GDP per cap‐ ita. Table 1-1 shows an excerpt of what you get.", "words": [{"w": "For", "b": [0.1429, 0.7396, 0.1718, 0.761]}, {"w": "example,", "b": [0.1769, 0.7396, 0.2512, 0.761]}, {"w": "suppose", "b": [0.2563, 0.7396, 0.324, 0.761]}, {"w": "you", "b": [0.3291, 0.7396, 0.3603, 0.761]}, {"w": "want", "b": [0.3654, 0.7396, 0.4062, 0.761]}, {"w": "to", "b": [0.4113, 0.7396, 0.4282, 0.761]}, {"w": "know", "b": [0.4333, 0.7396, 0.48, 0.761]}, {"w": "if", "b": [0.485, 0.7396, 0.4968, 0.761]}, {"w": "money", "b": [0.5019, 0.7396, 0.5594, 0.761]}, {"w": "makes", "b": [0.5645, 0.7396, 0.6175, 0.761]}, {"w": "people", "b": [0.6226, 0.7396, 0.678, 0.761]}, {"w": "happy,", "b": [0.6831, 0.7396, 0.7376, 0.761]}, {"w": "so", "b": [0.7427, 0.7396, 0.761, 0.761]}, {"w": "you", "b": [0.7661, 0.7396, 0.7973, 0.761]}, {"w": "down‐", "b": [0.8024, 0.7396, 0.8571, 0.761]}, {"w": "load", "b": [0.1428, 0.7587, 0.1789, 0.7801]}, {"w": "the", "b": [0.1857, 0.7587, 0.212, 0.7801]}, {"w": "Better", "b": [0.2189, 0.7585, 0.2677, 0.7801]}, {"w": "Life", "b": [0.2746, 0.7585, 0.3044, 0.7801]}, {"w": "Index", "b": [0.3112, 0.7585, 0.357, 0.7801]}, {"w": "data", "b": [0.3639, 0.7587, 0.3991, 0.7801]}, {"w": "from", "b": [0.4059, 0.7587, 0.4475, 0.7801]}, {"w": "the", "b": [0.4543, 0.7587, 0.4806, 0.7801]}, {"w": "OECD’s", "b": [0.4875, 0.7587, 0.5536, 0.7801]}, {"w": "website", "b": [0.5604, 0.7587, 0.6225, 0.7801]}, {"w": "as", "b": [0.6294, 0.7587, 0.6461, 0.7801]}, {"w": "well", "b": [0.653, 0.7587, 0.6866, 0.7801]}, {"w": "as", "b": [0.6934, 0.7587, 0.7102, 0.7801]}, {"w": "stats", "b": [0.717, 0.7587, 0.7538, 0.7801]}, {"w": "about", "b": [0.7606, 0.7587, 0.8084, 0.7801]}, {"w": "GDP", "b": [0.8152, 0.7587, 0.8571, 0.7801]}, {"w": "per", "b": [0.1429, 0.7777, 0.1704, 0.7991]}, {"w": "capita", "b": [0.1756, 0.7777, 0.2251, 0.7991]}, {"w": "from", "b": [0.2304, 0.7777, 0.2719, 0.7991]}, {"w": "the", "b": [0.2772, 0.7777, 0.3035, 0.7991]}, {"w": "IMF’s", "b": [0.3087, 0.7777, 0.3557, 0.7991]}, {"w": "website.", "b": [0.3604, 0.7777, 0.4278, 0.7991]}, {"w": "Then", "b": [0.433, 0.7777, 0.4772, 0.7991]}, {"w": "you", "b": [0.4825, 0.7777, 0.5137, 0.7991]}, {"w": "join", "b": [0.5189, 0.7777, 0.5519, 0.7991]}, {"w": "the", "b": [0.5571, 0.7777, 0.5834, 0.7991]}, {"w": "tables", "b": [0.5886, 0.7777, 0.6365, 0.7991]}, {"w": "and", "b": [0.6417, 0.7777, 0.6732, 0.7991]}, {"w": "sort", "b": [0.6785, 0.7777, 0.7108, 0.7991]}, {"w": "by", "b": [0.716, 0.7777, 0.7362, 0.7991]}, {"w": "GDP", "b": [0.7414, 0.7777, 0.7833, 0.7991]}, {"w": "per", "b": [0.7885, 0.7777, 0.816, 0.7991]}, {"w": "cap‐", "b": [0.8212, 0.7777, 0.8571, 0.7991]}, {"w": "ita.", "b": [0.1429, 0.7968, 0.1687, 0.8182]}, {"w": "Table", "b": [0.1734, 0.7968, 0.2182, 0.8182]}, {"w": "1-1", "b": [0.2229, 0.7968, 0.2504, 0.8182]}, {"w": "shows", "b": [0.2551, 0.7968, 0.3064, 0.8182]}, {"w": "an", "b": [0.3111, 0.7968, 0.3317, 0.8182]}, {"w": "excerpt", "b": [0.3364, 0.7968, 0.3977, 0.8182]}, {"w": "of", "b": [0.4025, 0.7968, 0.4193, 0.8182]}, {"w": "what", "b": [0.424, 0.7968, 0.4645, 0.8182]}, {"w": "you", "b": [0.4692, 0.7968, 0.5005, 0.8182]}, {"w": "get.", "b": [0.5052, 0.7968, 0.5349, 0.8182]}]}, {"id": "b_5", "type": "paragraph", "text": "Types of Machine Learning Systems | 19", "words": [{"w": "Types", "b": [0.5961, 0.9225, 0.6295, 0.9388]}, {"w": "of", "b": [0.6323, 0.9225, 0.6443, 0.9388]}, {"w": "Machine", "b": [0.6471, 0.9225, 0.6971, 0.9388]}, {"w": "Learning", "b": [0.6999, 0.9225, 0.7521, 0.9388]}, {"w": "Systems", "b": [0.7549, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "19", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 46, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "5 By convention, the Greek letter θ (theta) is frequently used to represent model parameters.", "words": [{"w": "5", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "By", "b": [0.1587, 0.8749, 0.1753, 0.8912]}, {"w": "convention,", "b": [0.179, 0.8749, 0.254, 0.8912]}, {"w": "the", "b": [0.2577, 0.8749, 0.2777, 0.8912]}, {"w": "Greek", "b": [0.2813, 0.8749, 0.3199, 0.8912]}, {"w": "letter", "b": [0.3235, 0.8749, 0.3566, 0.8912]}, {"w": "θ", "b": [0.3602, 0.8749, 0.368, 0.8912]}, {"w": "(theta)", "b": [0.3716, 0.8749, 0.4144, 0.8912]}, {"w": "is", "b": [0.418, 0.8749, 0.4281, 0.8912]}, {"w": "frequently", "b": [0.4317, 0.8749, 0.4969, 0.8912]}, {"w": "used", "b": [0.5005, 0.8749, 0.5299, 0.8912]}, {"w": "to", "b": [0.5335, 0.8749, 0.5464, 0.8912]}, {"w": "represent", "b": [0.55, 0.8749, 0.6094, 0.8912]}, {"w": "model", "b": [0.613, 0.8749, 0.6532, 0.8912]}, {"w": "parameters.", "b": [0.6568, 0.8749, 0.7316, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Table 1-1. Does money make people happier?", "words": [{"w": "Table", "b": [0.1429, 0.079, 0.1844, 0.0996]}, {"w": "1-1.", "b": [0.189, 0.079, 0.2192, 0.0996]}, {"w": "Does", "b": [0.2237, 0.079, 0.2616, 0.0996]}, {"w": "money", "b": [0.2662, 0.079, 0.318, 0.0996]}, {"w": "make", "b": [0.3225, 0.079, 0.3646, 0.0996]}, {"w": "people", "b": [0.3692, 0.079, 0.4179, 0.0996]}, {"w": "happier?", "b": [0.4225, 0.079, 0.4885, 0.0996]}]}, {"id": "b_2", "type": "paragraph", "text": "Country GDP per capita (USD) Life satisfaction Hungary 12,240 4.9", "words": [{"w": "Country", "b": [0.15, 0.1075, 0.1962, 0.1238]}, {"w": "GDP", "b": [0.2382, 0.1075, 0.2624, 0.1238]}, {"w": "per", "b": [0.2659, 0.1075, 0.2854, 0.1238]}, {"w": "capita", "b": [0.2888, 0.1075, 0.3249, 0.1238]}, {"w": "(USD)", "b": [0.3283, 0.1075, 0.3612, 0.1238]}, {"w": "Life", "b": [0.3755, 0.1075, 0.3973, 0.1238]}, {"w": "satisfaction", "b": [0.4007, 0.1075, 0.4687, 0.1238]}, {"w": "Hungary", "b": [0.15, 0.1279, 0.1968, 0.144]}, {"w": "12,240", "b": [0.2382, 0.1279, 0.2761, 0.144]}, {"w": "4.9", "b": [0.3755, 0.1279, 0.3927, 0.144]}]}, {"id": "b_3", "type": "paragraph", "text": "Korea 27,195 5.8", "words": [{"w": "Korea", "b": [0.15, 0.1489, 0.1815, 0.165]}, {"w": "27,195", "b": [0.2382, 0.1489, 0.2761, 0.165]}, {"w": "5.8", "b": [0.3755, 0.1489, 0.3927, 0.165]}]}, {"id": "b_4", "type": "paragraph", "text": "France 37,675 6.5", "words": [{"w": "France", "b": [0.15, 0.1699, 0.1862, 0.186]}, {"w": "37,675", "b": [0.2382, 0.1699, 0.2761, 0.186]}, {"w": "6.5", "b": [0.3755, 0.1699, 0.3927, 0.186]}]}, {"id": "b_5", "type": "paragraph", "text": "Australia 50,962 7.3", "words": [{"w": "Australia", "b": [0.15, 0.1909, 0.1987, 0.207]}, {"w": "50,962", "b": [0.2382, 0.1909, 0.2761, 0.207]}, {"w": "7.3", "b": [0.3755, 0.1909, 0.3927, 0.207]}]}, {"id": "b_6", "type": "paragraph", "text": "United States 55,805 7.2", "words": [{"w": "United", "b": [0.15, 0.2119, 0.1868, 0.228]}, {"w": "States", "b": [0.1902, 0.2119, 0.2239, 0.228]}, {"w": "55,805", "b": [0.2382, 0.2119, 0.2761, 0.228]}, {"w": "7.2", "b": [0.3755, 0.2119, 0.3927, 0.228]}]}, {"id": "b_7", "type": "equation", "text": "Let’s plot the data for a few random countries (Figure 1-17).", "words": [{"w": "Let’s", "b": [0.1429, 0.2484, 0.179, 0.2699]}, {"w": "plot", "b": [0.1838, 0.2484, 0.2169, 0.2699]}, {"w": "the", "b": [0.2216, 0.2484, 0.248, 0.2699]}, {"w": "data", "b": [0.2527, 0.2484, 0.288, 0.2699]}, {"w": "for", "b": [0.2927, 0.2484, 0.3172, 0.2699]}, {"w": "a", "b": [0.3219, 0.2484, 0.3311, 0.2699]}, {"w": "few", "b": [0.3358, 0.2484, 0.3651, 0.2699]}, {"w": "random", "b": [0.3698, 0.2484, 0.4368, 0.2699]}, {"w": "countries", "b": [0.4415, 0.2484, 0.5192, 0.2699]}, {"w": "(Figure", "b": [0.5239, 0.2484, 0.5851, 0.2699]}, {"w": "1-17).", "b": [0.5899, 0.2484, 0.6392, 0.2699]}]}, {"id": "b_8", "type": "equation", "text": "Figure 1-17. Do you see a trend here?", "words": [{"w": "Figure", "b": [0.1429, 0.5, 0.1943, 0.5216]}, {"w": "1-17.", "b": [0.1991, 0.5, 0.2407, 0.5216]}, {"w": "Do", "b": [0.2455, 0.5, 0.2702, 0.5216]}, {"w": "you", "b": [0.275, 0.5, 0.3048, 0.5216]}, {"w": "see", "b": [0.3095, 0.5, 0.3332, 0.5216]}, {"w": "a", "b": [0.3379, 0.5, 0.3481, 0.5216]}, {"w": "trend", "b": [0.3529, 0.5, 0.3962, 0.5216]}, {"w": "here?", "b": [0.401, 0.5, 0.4428, 0.5216]}]}, {"id": "b_9", "type": "paragraph", "text": "There does seem to be a trend here! Although the data is noisy (i.e., partly random), it looks like life satisfaction goes up more or less linearly as the country’s GDP per cap‐ ita increases. So you decide to model life satisfaction as a linear function of GDP per capita. This step is called model selection: you selected a linear model of life satisfac‐ tion with just one attribute, GDP per capita (Equation 1-1).", "words": [{"w": "There", "b": [0.1429, 0.5374, 0.1923, 0.5588]}, {"w": "does", "b": [0.1972, 0.5374, 0.2353, 0.5588]}, {"w": "seem", "b": [0.2402, 0.5374, 0.2826, 0.5588]}, {"w": "to", "b": [0.2875, 0.5374, 0.3045, 0.5588]}, {"w": "be", "b": [0.3094, 0.5374, 0.3289, 0.5588]}, {"w": "a", "b": [0.3338, 0.5374, 0.3429, 0.5588]}, {"w": "trend", "b": [0.3478, 0.5374, 0.3932, 0.5588]}, {"w": "here!", "b": [0.3981, 0.5374, 0.4404, 0.5588]}, {"w": "Although", "b": [0.4453, 0.5374, 0.525, 0.5588]}, {"w": "the", "b": [0.5299, 0.5374, 0.5562, 0.5588]}, {"w": "data", "b": [0.5611, 0.5374, 0.5964, 0.5588]}, {"w": "is", "b": [0.6013, 0.5374, 0.6145, 0.5588]}, {"w": "noisy", "b": [0.6194, 0.5372, 0.6618, 0.5588]}, {"w": "(i.e.,", "b": [0.6667, 0.5374, 0.7026, 0.5588]}, {"w": "partly", "b": [0.7073, 0.5374, 0.7563, 0.5588]}, {"w": "random),", "b": [0.761, 0.5374, 0.84, 0.5588]}, {"w": "it", "b": [0.8447, 0.5374, 0.8566, 0.5588]}, {"w": "looks", "b": [0.1428, 0.5565, 0.1873, 0.5779]}, {"w": "like", "b": [0.1928, 0.5565, 0.2228, 0.5779]}, {"w": "life", "b": [0.2283, 0.5565, 0.2541, 0.5779]}, {"w": "satisfaction", "b": [0.2596, 0.5565, 0.3536, 0.5779]}, {"w": "goes", "b": [0.3591, 0.5565, 0.396, 0.5779]}, {"w": "up", "b": [0.4014, 0.5565, 0.4234, 0.5779]}, {"w": "more", "b": [0.4288, 0.5565, 0.4731, 0.5779]}, {"w": "or", "b": [0.4785, 0.5565, 0.4969, 0.5779]}, {"w": "less", "b": [0.5023, 0.5565, 0.5317, 0.5779]}, {"w": "linearly", "b": [0.5372, 0.5565, 0.6, 0.5779]}, {"w": "as", "b": [0.6054, 0.5565, 0.6222, 0.5779]}, {"w": "the", "b": [0.6277, 0.5565, 0.654, 0.5779]}, {"w": "country’s", "b": [0.6594, 0.5565, 0.7355, 0.5779]}, {"w": "GDP", "b": [0.7409, 0.5565, 0.7829, 0.5779]}, {"w": "per", "b": [0.7883, 0.5565, 0.8158, 0.5779]}, {"w": "cap‐", "b": [0.8212, 0.5565, 0.8571, 0.5779]}, {"w": "ita", "b": [0.1429, 0.5755, 0.1639, 0.5969]}, {"w": "increases.", "b": [0.1697, 0.5755, 0.2501, 0.5969]}, {"w": "So", "b": [0.2558, 0.5755, 0.2763, 0.5969]}, {"w": "you", "b": [0.282, 0.5755, 0.3132, 0.5969]}, {"w": "decide", "b": [0.319, 0.5755, 0.3731, 0.5969]}, {"w": "to", "b": [0.3788, 0.5755, 0.3958, 0.5969]}, {"w": "model", "b": [0.4015, 0.5755, 0.4543, 0.5969]}, {"w": "life", "b": [0.46, 0.5755, 0.4859, 0.5969]}, {"w": "satisfaction", "b": [0.4916, 0.5755, 0.5856, 0.5969]}, {"w": "as", "b": [0.5913, 0.5755, 0.6081, 0.5969]}, {"w": "a", "b": [0.6138, 0.5755, 0.623, 0.5969]}, {"w": "linear", "b": [0.6287, 0.5755, 0.6767, 0.5969]}, {"w": "function", "b": [0.6824, 0.5755, 0.7538, 0.5969]}, {"w": "of", "b": [0.7595, 0.5755, 0.7763, 0.5969]}, {"w": "GDP", "b": [0.782, 0.5755, 0.8239, 0.5969]}, {"w": "per", "b": [0.8296, 0.5755, 0.8571, 0.5969]}, {"w": "capita.", "b": [0.1429, 0.5946, 0.1972, 0.616]}, {"w": "This", "b": [0.2037, 0.5946, 0.2409, 0.616]}, {"w": "step", "b": [0.2474, 0.5946, 0.2812, 0.616]}, {"w": "is", "b": [0.2877, 0.5946, 0.3009, 0.616]}, {"w": "called", "b": [0.3074, 0.5946, 0.3558, 0.616]}, {"w": "model", "b": [0.3623, 0.5944, 0.4119, 0.616]}, {"w": "selection:", "b": [0.4185, 0.5944, 0.4922, 0.616]}, {"w": "you", "b": [0.4987, 0.5946, 0.5299, 0.616]}, {"w": "selected", "b": [0.5364, 0.5946, 0.6021, 0.616]}, {"w": "a", "b": [0.6086, 0.5946, 0.6177, 0.616]}, {"w": "linear", "b": [0.6242, 0.5944, 0.6712, 0.616]}, {"w": "model", "b": [0.6778, 0.5944, 0.7274, 0.616]}, {"w": "of", "b": [0.7339, 0.5946, 0.7507, 0.616]}, {"w": "life", "b": [0.7572, 0.5946, 0.7831, 0.616]}, {"w": "satisfac‐", "b": [0.7896, 0.5946, 0.8571, 0.616]}, {"w": "tion", "b": [0.1429, 0.6136, 0.1768, 0.635]}, {"w": "with", "b": [0.1815, 0.6136, 0.2189, 0.635]}, {"w": "just", "b": [0.2236, 0.6136, 0.254, 0.635]}, {"w": "one", "b": [0.2587, 0.6136, 0.2896, 0.635]}, {"w": "attribute,", "b": [0.2943, 0.6136, 0.3707, 0.635]}, {"w": "GDP", "b": [0.3754, 0.6136, 0.4174, 0.635]}, {"w": "per", "b": [0.4221, 0.6136, 0.4496, 0.635]}, {"w": "capita", "b": [0.4543, 0.6136, 0.5039, 0.635]}, {"w": "(Equation", "b": [0.5086, 0.6136, 0.5921, 0.635]}, {"w": "1-1).", "b": [0.5968, 0.6136, 0.6362, 0.635]}]}, {"id": "b_10", "type": "equation", "text": "Equation 1-1. A simple linear model", "words": [{"w": "Equation", "b": [0.1726, 0.6531, 0.2473, 0.6748]}, {"w": "1-1.", "b": [0.2521, 0.6531, 0.2838, 0.6748]}, {"w": "A", "b": [0.2886, 0.6531, 0.3024, 0.6748]}, {"w": "simple", "b": [0.3072, 0.6531, 0.3588, 0.6748]}, {"w": "linear", "b": [0.3636, 0.6531, 0.4106, 0.6748]}, {"w": "model", "b": [0.4153, 0.6531, 0.465, 0.6748]}]}, {"id": "b_11", "type": "equation", "text": "life_satisfaction = θ0 + θ1 × GDP_per_capita", "words": [{"w": "life_satisfaction", "b": [0.1726, 0.6811, 0.2971, 0.7015]}, {"w": "=", "b": [0.3027, 0.6811, 0.3142, 0.7015]}, {"w": "θ0", "b": [0.3197, 0.6809, 0.3368, 0.7058]}, {"w": "+", "b": [0.3412, 0.6811, 0.3527, 0.7015]}, {"w": "θ1", "b": [0.3571, 0.6809, 0.3742, 0.7058]}, {"w": "×", "b": [0.3786, 0.6811, 0.3901, 0.7015]}, {"w": "GDP_per_capita", "b": [0.3945, 0.6811, 0.5281, 0.7015]}]}, {"id": "b_12", "type": "paragraph", "text": "This model has two model parameters, θ0 and θ1.5 By tweaking these parameters, you can make your model represent any linear function, as shown in Figure 1-18.", "words": [{"w": "This", "b": [0.1429, 0.7248, 0.1801, 0.7462]}, {"w": "model", "b": [0.1859, 0.7248, 0.2388, 0.7462]}, {"w": "has", "b": [0.2446, 0.7248, 0.2726, 0.7462]}, {"w": "two", "b": [0.2784, 0.7248, 0.3097, 0.7462]}, {"w": "model", "b": [0.3156, 0.7246, 0.3652, 0.7462]}, {"w": "parameters,", "b": [0.3711, 0.7246, 0.4664, 0.7462]}, {"w": "θ0", "b": [0.4723, 0.7246, 0.4882, 0.7471]}, {"w": "and", "b": [0.4941, 0.7248, 0.5257, 0.7462]}, {"w": "θ1.5", "b": [0.5316, 0.7246, 0.558, 0.7471]}, {"w": "By", "b": [0.5638, 0.7248, 0.5857, 0.7462]}, {"w": "tweaking", "b": [0.5915, 0.7248, 0.6672, 0.7462]}, {"w": "these", "b": [0.6731, 0.7248, 0.7159, 0.7462]}, {"w": "parameters,", "b": [0.7218, 0.7248, 0.82, 0.7462]}, {"w": "you", "b": [0.8259, 0.7248, 0.8571, 0.7462]}, {"w": "can", "b": [0.1429, 0.7439, 0.1722, 0.7653]}, {"w": "make", "b": [0.1769, 0.7439, 0.2223, 0.7653]}, {"w": "your", "b": [0.2271, 0.7439, 0.2661, 0.7653]}, {"w": "model", "b": [0.2708, 0.7439, 0.3236, 0.7653]}, {"w": "represent", "b": [0.3283, 0.7439, 0.4063, 0.7653]}, {"w": "any", "b": [0.411, 0.7439, 0.4406, 0.7653]}, {"w": "linear", "b": [0.4453, 0.7439, 0.4933, 0.7653]}, {"w": "function,", "b": [0.4981, 0.7439, 0.5742, 0.7653]}, {"w": "as", "b": [0.5789, 0.7439, 0.5957, 0.7653]}, {"w": "shown", "b": [0.6004, 0.7439, 0.6555, 0.7653]}, {"w": "in", "b": [0.6602, 0.7439, 0.6772, 0.7653]}, {"w": "Figure", "b": [0.6819, 0.7439, 0.7359, 0.7653]}, {"w": "1-18.", "b": [0.7407, 0.7439, 0.7828, 0.7653]}]}, {"id": "b_13", "type": "paragraph", "text": "20 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "20", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.3371, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 47, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 1-18. A few possible linear models", "words": [{"w": "Figure", "b": [0.1429, 0.3025, 0.1943, 0.3241]}, {"w": "1-18.", "b": [0.1991, 0.3025, 0.2407, 0.3241]}, {"w": "A", "b": [0.2455, 0.3025, 0.2593, 0.3241]}, {"w": "few", "b": [0.2641, 0.3025, 0.2919, 0.3241]}, {"w": "possible", "b": [0.2967, 0.3025, 0.3588, 0.3241]}, {"w": "linear", "b": [0.3635, 0.3025, 0.4105, 0.3241]}, {"w": "models", "b": [0.4153, 0.3025, 0.472, 0.3241]}]}, {"id": "b_1", "type": "paragraph", "text": "Before you can use your model, you need to define the parameter values θ0 and θ1. How can you know which values will make your model perform best? To answer this question, you need to specify a performance measure. You can either define a utility function (or fitness function) that measures how good your model is, or you can define a cost function that measures how bad it is. For linear regression problems, people typically use a cost function that measures the distance between the linear model’s predictions and the training examples; the objective is to minimize this distance.", "words": [{"w": "Before", "b": [0.1429, 0.3399, 0.1978, 0.3613]}, {"w": "you", "b": [0.2046, 0.3399, 0.2358, 0.3613]}, {"w": "can", "b": [0.2427, 0.3399, 0.272, 0.3613]}, {"w": "use", "b": [0.2789, 0.3399, 0.3064, 0.3613]}, {"w": "your", "b": [0.3133, 0.3399, 0.3523, 0.3613]}, {"w": "model,", "b": [0.3591, 0.3399, 0.4167, 0.3613]}, {"w": "you", "b": [0.4235, 0.3399, 0.4547, 0.3613]}, {"w": "need", "b": [0.4616, 0.3399, 0.5017, 0.3613]}, {"w": "to", "b": [0.5085, 0.3399, 0.5255, 0.3613]}, {"w": "define", "b": [0.5323, 0.3399, 0.5842, 0.3613]}, {"w": "the", "b": [0.591, 0.3399, 0.6174, 0.3613]}, {"w": "parameter", "b": [0.6242, 0.3399, 0.71, 0.3613]}, {"w": "values", "b": [0.7168, 0.3399, 0.7685, 0.3613]}, {"w": "θ0", "b": [0.7753, 0.3397, 0.7912, 0.3622]}, {"w": "and", "b": [0.7981, 0.3399, 0.8296, 0.3613]}, {"w": "θ1.", "b": [0.8365, 0.3397, 0.8571, 0.3622]}, {"w": "How", "b": [0.1429, 0.359, 0.1832, 0.3804]}, {"w": "can", "b": [0.1885, 0.359, 0.2179, 0.3804]}, {"w": "you", "b": [0.2233, 0.359, 0.2545, 0.3804]}, {"w": "know", "b": [0.2599, 0.359, 0.3065, 0.3804]}, {"w": "which", "b": [0.3118, 0.359, 0.3628, 0.3804]}, {"w": "values", "b": [0.3681, 0.359, 0.4197, 0.3804]}, {"w": "will", "b": [0.4251, 0.359, 0.4555, 0.3804]}, {"w": "make", "b": [0.4608, 0.359, 0.5062, 0.3804]}, {"w": "your", "b": [0.5116, 0.359, 0.5506, 0.3804]}, {"w": "model", "b": [0.5559, 0.359, 0.6087, 0.3804]}, {"w": "perform", "b": [0.6141, 0.359, 0.6832, 0.3804]}, {"w": "best?", "b": [0.6885, 0.359, 0.7299, 0.3804]}, {"w": "To", "b": [0.7352, 0.359, 0.7567, 0.3804]}, {"w": "answer", "b": [0.762, 0.359, 0.8211, 0.3804]}, {"w": "this", "b": [0.8264, 0.359, 0.8571, 0.3804]}, {"w": "question,", "b": [0.1429, 0.378, 0.2198, 0.3994]}, {"w": "you", "b": [0.2259, 0.378, 0.2572, 0.3994]}, {"w": "need", "b": [0.2633, 0.378, 0.3034, 0.3994]}, {"w": "to", "b": [0.3096, 0.378, 0.3265, 0.3994]}, {"w": "specify", "b": [0.3327, 0.378, 0.3906, 0.3994]}, {"w": "a", "b": [0.3967, 0.378, 0.4059, 0.3994]}, {"w": "performance", "b": [0.412, 0.378, 0.5193, 0.3994]}, {"w": "measure.", "b": [0.5255, 0.378, 0.6006, 0.3994]}, {"w": "You", "b": [0.6067, 0.378, 0.6391, 0.3994]}, {"w": "can", "b": [0.6452, 0.378, 0.6746, 0.3994]}, {"w": "either", "b": [0.6807, 0.378, 0.7292, 0.3994]}, {"w": "define", "b": [0.7353, 0.378, 0.7872, 0.3994]}, {"w": "a", "b": [0.7933, 0.378, 0.8025, 0.3994]}, {"w": "utility", "b": [0.8086, 0.3778, 0.8572, 0.3994]}, {"w": "function", "b": [0.1429, 0.3968, 0.211, 0.4185]}, {"w": "(or", "b": [0.2158, 0.3971, 0.2414, 0.4185]}, {"w": "fitness", "b": [0.2463, 0.3968, 0.2972, 0.4185]}, {"w": "function)", "b": [0.302, 0.3968, 0.3775, 0.4185]}, {"w": "that", "b": [0.3823, 0.3971, 0.4149, 0.4185]}, {"w": "measures", "b": [0.4198, 0.3971, 0.4978, 0.4185]}, {"w": "how", "b": [0.5025, 0.3971, 0.5386, 0.4185]}, {"w": "good", "b": [0.5436, 0.3968, 0.5824, 0.4185]}, {"w": "your", "b": [0.5872, 0.3971, 0.6262, 0.4185]}, {"w": "model", "b": [0.6311, 0.3971, 0.6839, 0.4185]}, {"w": "is,", "b": [0.6888, 0.3971, 0.7068, 0.4185]}, {"w": "or", "b": [0.7117, 0.3971, 0.73, 0.4185]}, {"w": "you", "b": [0.7349, 0.3971, 0.7662, 0.4185]}, {"w": "can", "b": [0.771, 0.3971, 0.8004, 0.4185]}, {"w": "define", "b": [0.8053, 0.3971, 0.8571, 0.4185]}, {"w": "a", "b": [0.1429, 0.4161, 0.152, 0.4375]}, {"w": "cost", "b": [0.1595, 0.4159, 0.1902, 0.4375]}, {"w": "function", "b": [0.1977, 0.4159, 0.2658, 0.4375]}, {"w": "that", "b": [0.2733, 0.4161, 0.3059, 0.4375]}, {"w": "measures", "b": [0.3134, 0.4161, 0.3914, 0.4375]}, {"w": "how", "b": [0.3989, 0.4161, 0.4349, 0.4375]}, {"w": "bad", "b": [0.4424, 0.4159, 0.4731, 0.4375]}, {"w": "it", "b": [0.4806, 0.4161, 0.4925, 0.4375]}, {"w": "is.", "b": [0.5, 0.4161, 0.518, 0.4375]}, {"w": "For", "b": [0.5255, 0.4161, 0.5545, 0.4375]}, {"w": "linear", "b": [0.562, 0.4161, 0.61, 0.4375]}, {"w": "regression", "b": [0.6175, 0.4161, 0.7033, 0.4375]}, {"w": "problems,", "b": [0.7108, 0.4161, 0.7942, 0.4375]}, {"w": "people", "b": [0.8017, 0.4161, 0.8572, 0.4375]}, {"w": "typically", "b": [0.1429, 0.4351, 0.2133, 0.4566]}, {"w": "use", "b": [0.2209, 0.4351, 0.2484, 0.4566]}, {"w": "a", "b": [0.256, 0.4351, 0.2651, 0.4566]}, {"w": "cost", "b": [0.2727, 0.4351, 0.3061, 0.4566]}, {"w": "function", "b": [0.3137, 0.4351, 0.385, 0.4566]}, {"w": "that", "b": [0.3926, 0.4351, 0.4252, 0.4566]}, {"w": "measures", "b": [0.4327, 0.4351, 0.5107, 0.4566]}, {"w": "the", "b": [0.5183, 0.4351, 0.5446, 0.4566]}, {"w": "distance", "b": [0.5521, 0.4351, 0.6209, 0.4566]}, {"w": "between", "b": [0.6285, 0.4351, 0.6976, 0.4566]}, {"w": "the", "b": [0.7052, 0.4351, 0.7315, 0.4566]}, {"w": "linear", "b": [0.739, 0.4351, 0.787, 0.4566]}, {"w": "model’s", "b": [0.7946, 0.4351, 0.8571, 0.4566]}, {"w": "predictions", "b": [0.1429, 0.4542, 0.2374, 0.4756]}, {"w": "and", "b": [0.2421, 0.4542, 0.2736, 0.4756]}, {"w": "the", "b": [0.2784, 0.4542, 0.3047, 0.4756]}, {"w": "training", "b": [0.3094, 0.4542, 0.3764, 0.4756]}, {"w": "examples;", "b": [0.3811, 0.4542, 0.463, 0.4756]}, {"w": "the", "b": [0.4678, 0.4542, 0.4941, 0.4756]}, {"w": "objective", "b": [0.4988, 0.4542, 0.5735, 0.4756]}, {"w": "is", "b": [0.5782, 0.4542, 0.5914, 0.4756]}, {"w": "to", "b": [0.5961, 0.4542, 0.6131, 0.4756]}, {"w": "minimize", "b": [0.6179, 0.4542, 0.6977, 0.4756]}, {"w": "this", "b": [0.7025, 0.4542, 0.7332, 0.4756]}, {"w": "distance.", "b": [0.7379, 0.4542, 0.8114, 0.4756]}]}, {"id": "b_2", "type": "paragraph", "text": "This is where the Linear Regression algorithm comes in: you feed it your training examples and it finds the parameters that make the linear model fit best to your data. This is called training the model. In our case the algorithm finds that the optimal parameter values are θ0 = 4.85 and θ1 = 4.91 × 10–5.", "words": [{"w": "This", "b": [0.1429, 0.4823, 0.1801, 0.5037]}, {"w": "is", "b": [0.1878, 0.4823, 0.201, 0.5037]}, {"w": "where", "b": [0.2087, 0.4823, 0.2596, 0.5037]}, {"w": "the", "b": [0.2673, 0.4823, 0.2936, 0.5037]}, {"w": "Linear", "b": [0.3013, 0.4823, 0.3553, 0.5037]}, {"w": "Regression", "b": [0.363, 0.4823, 0.454, 0.5037]}, {"w": "algorithm", "b": [0.4617, 0.4823, 0.5444, 0.5037]}, {"w": "comes", "b": [0.5521, 0.4823, 0.6051, 0.5037]}, {"w": "in:", "b": [0.6128, 0.4823, 0.6346, 0.5037]}, {"w": "you", "b": [0.6423, 0.4823, 0.6735, 0.5037]}, {"w": "feed", "b": [0.6812, 0.4823, 0.7161, 0.5037]}, {"w": "it", "b": [0.7238, 0.4823, 0.7358, 0.5037]}, {"w": "your", "b": [0.7435, 0.4823, 0.7825, 0.5037]}, {"w": "training", "b": [0.7902, 0.4823, 0.8571, 0.5037]}, {"w": "examples", "b": [0.1428, 0.5014, 0.22, 0.5228]}, {"w": "and", "b": [0.2253, 0.5014, 0.2569, 0.5228]}, {"w": "it", "b": [0.2622, 0.5014, 0.2741, 0.5228]}, {"w": "finds", "b": [0.2794, 0.5014, 0.3212, 0.5228]}, {"w": "the", "b": [0.3265, 0.5014, 0.3528, 0.5228]}, {"w": "parameters", "b": [0.3581, 0.5014, 0.4516, 0.5228]}, {"w": "that", "b": [0.4569, 0.5014, 0.4894, 0.5228]}, {"w": "make", "b": [0.4947, 0.5014, 0.5401, 0.5228]}, {"w": "the", "b": [0.5454, 0.5014, 0.5718, 0.5228]}, {"w": "linear", "b": [0.5771, 0.5014, 0.625, 0.5228]}, {"w": "model", "b": [0.6303, 0.5014, 0.6832, 0.5228]}, {"w": "fit", "b": [0.6884, 0.5014, 0.7066, 0.5228]}, {"w": "best", "b": [0.7118, 0.5014, 0.7453, 0.5228]}, {"w": "to", "b": [0.7506, 0.5014, 0.7676, 0.5228]}, {"w": "your", "b": [0.7729, 0.5014, 0.8118, 0.5228]}, {"w": "data.", "b": [0.8171, 0.5014, 0.8571, 0.5228]}, {"w": "This", "b": [0.1429, 0.5204, 0.1801, 0.5418]}, {"w": "is", "b": [0.1879, 0.5204, 0.2012, 0.5418]}, {"w": "called", "b": [0.209, 0.5204, 0.2574, 0.5418]}, {"w": "training", "b": [0.2653, 0.5202, 0.3297, 0.5418]}, {"w": "the", "b": [0.3376, 0.5204, 0.3639, 0.5418]}, {"w": "model.", "b": [0.3718, 0.5204, 0.4293, 0.5418]}, {"w": "In", "b": [0.4372, 0.5204, 0.4557, 0.5418]}, {"w": "our", "b": [0.4636, 0.5204, 0.493, 0.5418]}, {"w": "case", "b": [0.5008, 0.5204, 0.5353, 0.5418]}, {"w": "the", "b": [0.5432, 0.5204, 0.5695, 0.5418]}, {"w": "algorithm", "b": [0.5774, 0.5204, 0.66, 0.5418]}, {"w": "finds", "b": [0.6679, 0.5204, 0.7097, 0.5418]}, {"w": "that", "b": [0.7175, 0.5204, 0.7501, 0.5418]}, {"w": "the", "b": [0.758, 0.5204, 0.7843, 0.5418]}, {"w": "optimal", "b": [0.7922, 0.5204, 0.8571, 0.5418]}, {"w": "parameter", "b": [0.1429, 0.5395, 0.2287, 0.5609]}, {"w": "values", "b": [0.2334, 0.5395, 0.285, 0.5609]}, {"w": "are", "b": [0.2897, 0.5395, 0.3155, 0.5609]}, {"w": "θ0", "b": [0.3202, 0.5392, 0.3361, 0.5618]}, {"w": "=", "b": [0.3409, 0.5395, 0.3529, 0.5609]}, {"w": "4.85", "b": [0.3577, 0.5395, 0.3924, 0.5609]}, {"w": "and", "b": [0.3972, 0.5395, 0.4287, 0.5609]}, {"w": "θ1", "b": [0.4334, 0.5392, 0.4494, 0.5618]}, {"w": "=", "b": [0.4541, 0.5395, 0.4662, 0.5609]}, {"w": "4.91", "b": [0.4709, 0.5395, 0.5056, 0.5609]}, {"w": "×", "b": [0.5104, 0.5395, 0.5225, 0.5609]}, {"w": "10–5.", "b": [0.5272, 0.5395, 0.5644, 0.5609]}]}, {"id": "b_3", "type": "paragraph", "text": "Now the model fits the training data as closely as possible (for a linear model), as you can see in Figure 1-19.", "words": [{"w": "Now", "b": [0.1429, 0.5676, 0.1827, 0.589]}, {"w": "the", "b": [0.1879, 0.5676, 0.2142, 0.589]}, {"w": "model", "b": [0.2194, 0.5676, 0.2722, 0.589]}, {"w": "fits", "b": [0.2773, 0.5676, 0.3031, 0.589]}, {"w": "the", "b": [0.3083, 0.5676, 0.3346, 0.589]}, {"w": "training", "b": [0.3398, 0.5676, 0.4067, 0.589]}, {"w": "data", "b": [0.4119, 0.5676, 0.4471, 0.589]}, {"w": "as", "b": [0.4523, 0.5676, 0.4691, 0.589]}, {"w": "closely", "b": [0.4742, 0.5676, 0.5303, 0.589]}, {"w": "as", "b": [0.5354, 0.5676, 0.5522, 0.589]}, {"w": "possible", "b": [0.5574, 0.5676, 0.6245, 0.589]}, {"w": "(for", "b": [0.6297, 0.5676, 0.6614, 0.589]}, {"w": "a", "b": [0.6666, 0.5676, 0.6757, 0.589]}, {"w": "linear", "b": [0.6809, 0.5676, 0.7288, 0.589]}, {"w": "model),", "b": [0.734, 0.5676, 0.7988, 0.589]}, {"w": "as", "b": [0.8039, 0.5676, 0.8207, 0.589]}, {"w": "you", "b": [0.8259, 0.5676, 0.8571, 0.589]}, {"w": "can", "b": [0.1429, 0.5866, 0.1722, 0.608]}, {"w": "see", "b": [0.1769, 0.5866, 0.2023, 0.608]}, {"w": "in", "b": [0.207, 0.5866, 0.224, 0.608]}, {"w": "Figure", "b": [0.2287, 0.5866, 0.2827, 0.608]}, {"w": "1-19.", "b": [0.2875, 0.5866, 0.3296, 0.608]}]}, {"id": "b_4", "type": "equation", "text": "Figure 1-19. The linear model that fits the training data best", "words": [{"w": "Figure", "b": [0.1429, 0.8382, 0.1943, 0.8598]}, {"w": "1-19.", "b": [0.1991, 0.8382, 0.2407, 0.8598]}, {"w": "The", "b": [0.2455, 0.8382, 0.2754, 0.8598]}, {"w": "linear", "b": [0.2801, 0.8382, 0.3271, 0.8598]}, {"w": "model", "b": [0.3319, 0.8382, 0.3815, 0.8598]}, {"w": "that", "b": [0.3863, 0.8382, 0.4191, 0.8598]}, {"w": "fits", "b": [0.4239, 0.8382, 0.4484, 0.8598]}, {"w": "the", "b": [0.4532, 0.8382, 0.4782, 0.8598]}, {"w": "training", "b": [0.483, 0.8382, 0.5474, 0.8598]}, {"w": "data", "b": [0.5522, 0.8382, 0.5888, 0.8598]}, {"w": "best", "b": [0.5936, 0.8382, 0.625, 0.8598]}]}, {"id": "b_5", "type": "paragraph", "text": "Types of Machine Learning Systems | 21", "words": [{"w": "Types", "b": [0.5961, 0.9225, 0.6295, 0.9388]}, {"w": "of", "b": [0.6323, 0.9225, 0.6443, 0.9388]}, {"w": "Machine", "b": [0.6471, 0.9225, 0.6971, 0.9388]}, {"w": "Learning", "b": [0.6999, 0.9225, 0.7521, 0.9388]}, {"w": "Systems", "b": [0.7549, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "21", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 48, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 The prepare_country_stats() function’s definition is not shown here (see this chapter’s Jupyter notebook if you want all the gory details). It’s just boring Pandas code that joins the life satisfaction data from the OECD with the GDP per capita data from the IMF.", "words": [{"w": "6", "b": [0.1451, 0.8265, 0.1518, 0.8408]}, {"w": "The", "b": [0.1587, 0.825, 0.1837, 0.8413]}, {"w": "prepare_country_stats()", "b": [0.1873, 0.8274, 0.3608, 0.8389]}, {"w": "function’s", "b": [0.3644, 0.825, 0.4253, 0.8413]}, {"w": "definition", "b": [0.4289, 0.825, 0.4918, 0.8413]}, {"w": "is", "b": [0.4954, 0.825, 0.5055, 0.8413]}, {"w": "not", "b": [0.5091, 0.825, 0.5307, 0.8413]}, {"w": "shown", "b": [0.5343, 0.825, 0.5763, 0.8413]}, {"w": "here", "b": [0.5799, 0.825, 0.6077, 0.8413]}, {"w": "(see", "b": [0.6113, 0.825, 0.6361, 0.8413]}, {"w": "this", "b": [0.6397, 0.825, 0.6631, 0.8413]}, {"w": "chapter’s", "b": [0.6667, 0.825, 0.7223, 0.8413]}, {"w": "Jupyter", "b": [0.7259, 0.825, 0.7721, 0.8413]}, {"w": "notebook", "b": [0.7757, 0.825, 0.8362, 0.8413]}, {"w": "if", "b": [0.8398, 0.825, 0.8487, 0.8413]}, {"w": "you", "b": [0.1587, 0.8401, 0.1825, 0.8565]}, {"w": "want", "b": [0.1861, 0.8401, 0.2172, 0.8565]}, {"w": "all", "b": [0.2208, 0.8401, 0.2358, 0.8565]}, {"w": "the", "b": [0.2394, 0.8401, 0.2595, 0.8565]}, {"w": "gory", "b": [0.2631, 0.8401, 0.2922, 0.8565]}, {"w": "details).", "b": [0.2958, 0.8401, 0.346, 0.8565]}, {"w": "It’s", "b": [0.3496, 0.8401, 0.3667, 0.8565]}, {"w": "just", "b": [0.3703, 0.8401, 0.3934, 0.8565]}, {"w": "boring", "b": [0.397, 0.8401, 0.4394, 0.8565]}, {"w": "Pandas", "b": [0.443, 0.8401, 0.4884, 0.8565]}, {"w": "code", "b": [0.492, 0.8401, 0.522, 0.8565]}, {"w": "that", "b": [0.5256, 0.8401, 0.5504, 0.8565]}, {"w": "joins", "b": [0.554, 0.8401, 0.5849, 0.8565]}, {"w": "the", "b": [0.5885, 0.8401, 0.6086, 0.8565]}, {"w": "life", "b": [0.6122, 0.8401, 0.6319, 0.8565]}, {"w": "satisfaction", "b": [0.6355, 0.8401, 0.7072, 0.8565]}, {"w": "data", "b": [0.7108, 0.8401, 0.7377, 0.8565]}, {"w": "from", "b": [0.7413, 0.8401, 0.7729, 0.8565]}, {"w": "the", "b": [0.7765, 0.8401, 0.7966, 0.8565]}, {"w": "OECD", "b": [0.8002, 0.8401, 0.8433, 0.8565]}, {"w": "with", "b": [0.1587, 0.8553, 0.1872, 0.8716]}, {"w": "the", "b": [0.1908, 0.8553, 0.2108, 0.8716]}, {"w": "GDP", "b": [0.2144, 0.8553, 0.2464, 0.8716]}, {"w": "per", "b": [0.25, 0.8553, 0.271, 0.8716]}, {"w": "capita", "b": [0.2746, 0.8553, 0.3123, 0.8716]}, {"w": "data", "b": [0.3159, 0.8553, 0.3428, 0.8716]}, {"w": "from", "b": [0.3464, 0.8553, 0.3781, 0.8716]}, {"w": "the", "b": [0.3817, 0.8553, 0.4017, 0.8716]}, {"w": "IMF.", "b": [0.4053, 0.8553, 0.4352, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "7 It’s okay if you don’t understand all the code yet; we will present Scikit-Learn in the following chapters.", "words": [{"w": "7", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "It’s", "b": [0.1587, 0.8749, 0.1758, 0.8912]}, {"w": "okay", "b": [0.1794, 0.8749, 0.2093, 0.8912]}, {"w": "if", "b": [0.2129, 0.8749, 0.2219, 0.8912]}, {"w": "you", "b": [0.2255, 0.8749, 0.2493, 0.8912]}, {"w": "don’t", "b": [0.2529, 0.8749, 0.2846, 0.8912]}, {"w": "understand", "b": [0.2882, 0.8749, 0.361, 0.8912]}, {"w": "all", "b": [0.3646, 0.8749, 0.3796, 0.8912]}, {"w": "the", "b": [0.3832, 0.8749, 0.4033, 0.8912]}, {"w": "code", "b": [0.4069, 0.8749, 0.4368, 0.8912]}, {"w": "yet;", "b": [0.4404, 0.8749, 0.4629, 0.8912]}, {"w": "we", "b": [0.4665, 0.8749, 0.4842, 0.8912]}, {"w": "will", "b": [0.4878, 0.8749, 0.5109, 0.8912]}, {"w": "present", "b": [0.5145, 0.8749, 0.5613, 0.8912]}, {"w": "Scikit-Learn", "b": [0.5649, 0.8749, 0.6428, 0.8912]}, {"w": "in", "b": [0.6464, 0.8749, 0.6593, 0.8912]}, {"w": "the", "b": [0.663, 0.8749, 0.683, 0.8912]}, {"w": "following", "b": [0.6866, 0.8749, 0.7468, 0.8912]}, {"w": "chapters.", "b": [0.7504, 0.8749, 0.8075, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "You are finally ready to run the model to make predictions. For example, say you want to know how happy Cypriots are, and the OECD data does not have the answer. Fortunately, you can use your model to make a good prediction: you look up Cyprus’s GDP per capita, find $22,587, and then apply your model and find that life satisfac‐ tion is likely to be somewhere around 4.85 + 22,587 × 4.91 × 10-5 = 5.96.", "words": [{"w": "You", "b": [0.1429, 0.0791, 0.1752, 0.1005]}, {"w": "are", "b": [0.183, 0.0791, 0.2087, 0.1005]}, {"w": "finally", "b": [0.2165, 0.0791, 0.2689, 0.1005]}, {"w": "ready", "b": [0.2767, 0.0791, 0.323, 0.1005]}, {"w": "to", "b": [0.3308, 0.0791, 0.3478, 0.1005]}, {"w": "run", "b": [0.3556, 0.0791, 0.3857, 0.1005]}, {"w": "the", "b": [0.3935, 0.0791, 0.4199, 0.1005]}, {"w": "model", "b": [0.4277, 0.0791, 0.4805, 0.1005]}, {"w": "to", "b": [0.4883, 0.0791, 0.5052, 0.1005]}, {"w": "make", "b": [0.513, 0.0791, 0.5584, 0.1005]}, {"w": "predictions.", "b": [0.5662, 0.0791, 0.6655, 0.1005]}, {"w": "For", "b": [0.6733, 0.0791, 0.7022, 0.1005]}, {"w": "example,", "b": [0.71, 0.0791, 0.7843, 0.1005]}, {"w": "say", "b": [0.7921, 0.0791, 0.8181, 0.1005]}, {"w": "you", "b": [0.8259, 0.0791, 0.8571, 0.1005]}, {"w": "want", "b": [0.1429, 0.0981, 0.1836, 0.1195]}, {"w": "to", "b": [0.1887, 0.0981, 0.2057, 0.1195]}, {"w": "know", "b": [0.2108, 0.0981, 0.2574, 0.1195]}, {"w": "how", "b": [0.2625, 0.0981, 0.2986, 0.1195]}, {"w": "happy", "b": [0.3037, 0.0981, 0.3549, 0.1195]}, {"w": "Cypriots", "b": [0.36, 0.0981, 0.4323, 0.1195]}, {"w": "are,", "b": [0.4374, 0.0981, 0.4679, 0.1195]}, {"w": "and", "b": [0.473, 0.0981, 0.5045, 0.1195]}, {"w": "the", "b": [0.5096, 0.0981, 0.5359, 0.1195]}, {"w": "OECD", "b": [0.541, 0.0981, 0.5976, 0.1195]}, {"w": "data", "b": [0.6027, 0.0981, 0.638, 0.1195]}, {"w": "does", "b": [0.6431, 0.0981, 0.6812, 0.1195]}, {"w": "not", "b": [0.6863, 0.0981, 0.7146, 0.1195]}, {"w": "have", "b": [0.7197, 0.0981, 0.7581, 0.1195]}, {"w": "the", "b": [0.7632, 0.0981, 0.7896, 0.1195]}, {"w": "answer.", "b": [0.7947, 0.0981, 0.8572, 0.1195]}, {"w": "Fortunately,", "b": [0.1429, 0.1172, 0.2427, 0.1386]}, {"w": "you", "b": [0.2476, 0.1172, 0.2789, 0.1386]}, {"w": "can", "b": [0.2838, 0.1172, 0.3131, 0.1386]}, {"w": "use", "b": [0.3181, 0.1172, 0.3456, 0.1386]}, {"w": "your", "b": [0.3506, 0.1172, 0.3896, 0.1386]}, {"w": "model", "b": [0.3945, 0.1172, 0.4473, 0.1386]}, {"w": "to", "b": [0.4522, 0.1172, 0.4692, 0.1386]}, {"w": "make", "b": [0.4741, 0.1172, 0.5195, 0.1386]}, {"w": "a", "b": [0.5245, 0.1172, 0.5336, 0.1386]}, {"w": "good", "b": [0.5386, 0.1172, 0.5806, 0.1386]}, {"w": "prediction:", "b": [0.5855, 0.1172, 0.6771, 0.1386]}, {"w": "you", "b": [0.682, 0.1172, 0.7133, 0.1386]}, {"w": "look", "b": [0.7182, 0.1172, 0.7551, 0.1386]}, {"w": "up", "b": [0.76, 0.1172, 0.782, 0.1386]}, {"w": "Cyprus’s", "b": [0.7869, 0.1172, 0.8571, 0.1386]}, {"w": "GDP", "b": [0.1429, 0.1362, 0.1848, 0.1576]}, {"w": "per", "b": [0.1911, 0.1362, 0.2186, 0.1576]}, {"w": "capita,", "b": [0.225, 0.1362, 0.2793, 0.1576]}, {"w": "find", "b": [0.2856, 0.1362, 0.3198, 0.1576]}, {"w": "$22,587,", "b": [0.3261, 0.1362, 0.3956, 0.1576]}, {"w": "and", "b": [0.4019, 0.1362, 0.4335, 0.1576]}, {"w": "then", "b": [0.4398, 0.1362, 0.4776, 0.1576]}, {"w": "apply", "b": [0.4839, 0.1362, 0.5293, 0.1576]}, {"w": "your", "b": [0.5356, 0.1362, 0.5746, 0.1576]}, {"w": "model", "b": [0.581, 0.1362, 0.6338, 0.1576]}, {"w": "and", "b": [0.6401, 0.1362, 0.6717, 0.1576]}, {"w": "find", "b": [0.678, 0.1362, 0.7121, 0.1576]}, {"w": "that", "b": [0.7185, 0.1362, 0.7511, 0.1576]}, {"w": "life", "b": [0.7574, 0.1362, 0.7833, 0.1576]}, {"w": "satisfac‐", "b": [0.7896, 0.1362, 0.8571, 0.1576]}, {"w": "tion", "b": [0.1428, 0.1553, 0.1768, 0.1767]}, {"w": "is", "b": [0.1815, 0.1553, 0.1948, 0.1767]}, {"w": "likely", "b": [0.1995, 0.1553, 0.2444, 0.1767]}, {"w": "to", "b": [0.2491, 0.1553, 0.2661, 0.1767]}, {"w": "be", "b": [0.2708, 0.1553, 0.2902, 0.1767]}, {"w": "somewhere", "b": [0.295, 0.1553, 0.39, 0.1767]}, {"w": "around", "b": [0.3947, 0.1553, 0.4557, 0.1767]}, {"w": "4.85", "b": [0.4604, 0.1553, 0.4952, 0.1767]}, {"w": "+", "b": [0.4999, 0.1553, 0.512, 0.1767]}, {"w": "22,587", "b": [0.5167, 0.1553, 0.5715, 0.1767]}, {"w": "×", "b": [0.5762, 0.1553, 0.5883, 0.1767]}, {"w": "4.91", "b": [0.593, 0.1553, 0.6277, 0.1767]}, {"w": "×", "b": [0.6325, 0.1553, 0.6446, 0.1767]}, {"w": "10-5", "b": [0.6493, 0.1553, 0.6797, 0.1767]}, {"w": "=", "b": [0.6845, 0.1553, 0.6966, 0.1767]}, {"w": "5.96.", "b": [0.7013, 0.1553, 0.7408, 0.1767]}]}, {"id": "b_3", "type": "paragraph", "text": "To whet your appetite, Example 1-1 shows the Python code that loads the data, pre‐ pares it,6 creates a scatterplot for visualization, and then trains a linear model and makes a prediction.7", "words": [{"w": "To", "b": [0.1429, 0.1834, 0.1643, 0.2048]}, {"w": "whet", "b": [0.1705, 0.1834, 0.2111, 0.2048]}, {"w": "your", "b": [0.2173, 0.1834, 0.2563, 0.2048]}, {"w": "appetite,", "b": [0.2625, 0.1834, 0.3338, 0.2048]}, {"w": "Example", "b": [0.34, 0.1834, 0.4125, 0.2048]}, {"w": "1-1", "b": [0.4187, 0.1834, 0.4461, 0.2048]}, {"w": "shows", "b": [0.4523, 0.1834, 0.5036, 0.2048]}, {"w": "the", "b": [0.5098, 0.1834, 0.5362, 0.2048]}, {"w": "Python", "b": [0.5424, 0.1834, 0.6032, 0.2048]}, {"w": "code", "b": [0.6093, 0.1834, 0.6486, 0.2048]}, {"w": "that", "b": [0.6548, 0.1834, 0.6874, 0.2048]}, {"w": "loads", "b": [0.6936, 0.1834, 0.7373, 0.2048]}, {"w": "the", "b": [0.7435, 0.1834, 0.7698, 0.2048]}, {"w": "data,", "b": [0.776, 0.1834, 0.816, 0.2048]}, {"w": "pre‐", "b": [0.8222, 0.1834, 0.8571, 0.2048]}, {"w": "pares", "b": [0.1428, 0.2024, 0.1871, 0.2238]}, {"w": "it,6", "b": [0.1949, 0.2024, 0.2173, 0.2238]}, {"w": "creates", "b": [0.225, 0.2024, 0.282, 0.2238]}, {"w": "a", "b": [0.2897, 0.2024, 0.2989, 0.2238]}, {"w": "scatterplot", "b": [0.3066, 0.2024, 0.3943, 0.2238]}, {"w": "for", "b": [0.402, 0.2024, 0.4265, 0.2238]}, {"w": "visualization,", "b": [0.4343, 0.2024, 0.5444, 0.2238]}, {"w": "and", "b": [0.5522, 0.2024, 0.5837, 0.2238]}, {"w": "then", "b": [0.5914, 0.2024, 0.6292, 0.2238]}, {"w": "trains", "b": [0.6369, 0.2024, 0.6847, 0.2238]}, {"w": "a", "b": [0.6925, 0.2024, 0.7016, 0.2238]}, {"w": "linear", "b": [0.7093, 0.2024, 0.7573, 0.2238]}, {"w": "model", "b": [0.7651, 0.2024, 0.8179, 0.2238]}, {"w": "and", "b": [0.8256, 0.2024, 0.8571, 0.2238]}, {"w": "makes", "b": [0.1429, 0.2215, 0.1959, 0.2429]}, {"w": "a", "b": [0.2006, 0.2215, 0.2098, 0.2429]}, {"w": "prediction.7", "b": [0.2145, 0.2215, 0.3118, 0.2429]}]}, {"id": "b_4", "type": "equation", "text": "Example 1-1. Training and running a linear model using Scikit-Learn", "words": [{"w": "Example", "b": [0.1429, 0.2633, 0.2141, 0.2849]}, {"w": "1-1.", "b": [0.2189, 0.2633, 0.2506, 0.2849]}, {"w": "Training", "b": [0.2554, 0.2633, 0.3246, 0.2849]}, {"w": "and", "b": [0.3294, 0.2633, 0.3608, 0.2849]}, {"w": "running", "b": [0.3655, 0.2633, 0.4306, 0.2849]}, {"w": "a", "b": [0.4354, 0.2633, 0.4456, 0.2849]}, {"w": "linear", "b": [0.4504, 0.2633, 0.4973, 0.2849]}, {"w": "model", "b": [0.5021, 0.2633, 0.5518, 0.2849]}, {"w": "using", "b": [0.5565, 0.2633, 0.5995, 0.2849]}, {"w": "Scikit-Learn", "b": [0.6043, 0.2633, 0.704, 0.2849]}]}, {"id": "b_5", "type": "paragraph", "text": "import matplotlib.pyplot as plt import numpy as np import pandas as pd import sklearn.linear_model", "words": [{"w": "import", "b": [0.1429, 0.3008, 0.1934, 0.3136]}, {"w": "matplotlib.pyplot", "b": [0.2019, 0.3008, 0.3452, 0.3136]}, {"w": "as", "b": [0.3537, 0.3008, 0.3705, 0.3136]}, {"w": "plt", "b": [0.379, 0.3008, 0.4043, 0.3136]}, {"w": "import", "b": [0.1429, 0.3162, 0.1934, 0.329]}, {"w": "numpy", "b": [0.2019, 0.3162, 0.244, 0.329]}, {"w": "as", "b": [0.2525, 0.3162, 0.2693, 0.329]}, {"w": "np", "b": [0.2778, 0.3162, 0.2946, 0.329]}, {"w": "import", "b": [0.1429, 0.3316, 0.1934, 0.3444]}, {"w": "pandas", "b": [0.2019, 0.3316, 0.2525, 0.3444]}, {"w": "as", "b": [0.2609, 0.3316, 0.2778, 0.3444]}, {"w": "pd", "b": [0.2862, 0.3316, 0.3031, 0.3444]}, {"w": "import", "b": [0.1429, 0.347, 0.1934, 0.3599]}, {"w": "sklearn.linear_model", "b": [0.2019, 0.347, 0.3705, 0.3599]}]}, {"id": "b_6", "type": "paragraph", "text": "# Load the data oecd_bli = pd.read_csv(\"oecd_bli_2015.csv\", thousands=',') gdp_per_capita = pd.read_csv(\"gdp_per_capita.csv\",thousands=',',delimiter='\\t', encoding='latin1', na_values=\"n/a\")", "words": [{"w": "#", "b": [0.1429, 0.3779, 0.1513, 0.3907]}, {"w": "Load", "b": [0.1597, 0.3779, 0.1934, 0.3907]}, {"w": "the", "b": [0.2019, 0.3779, 0.2272, 0.3907]}, {"w": "data", "b": [0.2356, 0.3779, 0.2693, 0.3907]}, {"w": "oecd_bli", "b": [0.1429, 0.3933, 0.2103, 0.4061]}, {"w": "=", "b": [0.2187, 0.3933, 0.2272, 0.4061]}, {"w": "pd.read_csv(\"oecd_bli_2015.csv\",", "b": [0.2356, 0.3933, 0.5055, 0.4061]}, {"w": "thousands=',')", "b": [0.5139, 0.3933, 0.6319, 0.4061]}, {"w": "gdp_per_capita", "b": [0.1429, 0.4087, 0.2609, 0.4215]}, {"w": "=", "b": [0.2693, 0.4087, 0.2778, 0.4215]}, {"w": "pd.read_csv(\"gdp_per_capita.csv\",thousands=',',delimiter='\\t',", "b": [0.2862, 0.4087, 0.809, 0.4215]}, {"w": "encoding='latin1',", "b": [0.3874, 0.4241, 0.5392, 0.437]}, {"w": "na_values=\"n/a\")", "b": [0.5476, 0.4241, 0.6825, 0.437]}]}, {"id": "b_7", "type": "paragraph", "text": "# Prepare the data country_stats = prepare_country_stats(oecd_bli, gdp_per_capita) X = np.c_[country_stats[\"GDP per capita\"]] y = np.c_[country_stats[\"Life satisfaction\"]]", "words": [{"w": "#", "b": [0.1429, 0.455, 0.1513, 0.4678]}, {"w": "Prepare", "b": [0.1597, 0.455, 0.2187, 0.4678]}, {"w": "the", "b": [0.2272, 0.455, 0.2525, 0.4678]}, {"w": "data", "b": [0.2609, 0.455, 0.2946, 0.4678]}, {"w": "country_stats", "b": [0.1429, 0.4704, 0.2525, 0.4832]}, {"w": "=", "b": [0.2609, 0.4704, 0.2693, 0.4832]}, {"w": "prepare_country_stats(oecd_bli,", "b": [0.2778, 0.4704, 0.5392, 0.4832]}, {"w": "gdp_per_capita)", "b": [0.5476, 0.4704, 0.6741, 0.4832]}, {"w": "X", "b": [0.1429, 0.4858, 0.1513, 0.4986]}, {"w": "=", "b": [0.1597, 0.4858, 0.1682, 0.4986]}, {"w": "np.c_[country_stats[\"GDP", "b": [0.1766, 0.4858, 0.379, 0.4986]}, {"w": "per", "b": [0.3874, 0.4858, 0.4127, 0.4986]}, {"w": "capita\"]]", "b": [0.4211, 0.4858, 0.497, 0.4986]}, {"w": "y", "b": [0.1429, 0.5012, 0.1513, 0.5141]}, {"w": "=", "b": [0.1597, 0.5012, 0.1682, 0.5141]}, {"w": "np.c_[country_stats[\"Life", "b": [0.1766, 0.5012, 0.3874, 0.5141]}, {"w": "satisfaction\"]]", "b": [0.3958, 0.5012, 0.5223, 0.5141]}]}, {"id": "b_8", "type": "paragraph", "text": "# Visualize the data country_stats.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction') plt.show()", "words": [{"w": "#", "b": [0.1429, 0.532, 0.1513, 0.5449]}, {"w": "Visualize", "b": [0.1597, 0.532, 0.2356, 0.5449]}, {"w": "the", "b": [0.244, 0.532, 0.2693, 0.5449]}, {"w": "data", "b": [0.2778, 0.532, 0.3115, 0.5449]}, {"w": "country_stats.plot(kind='scatter',", "b": [0.1429, 0.5475, 0.4296, 0.5603]}, {"w": "x=\"GDP", "b": [0.438, 0.5475, 0.4886, 0.5603]}, {"w": "per", "b": [0.497, 0.5475, 0.5223, 0.5603]}, {"w": "capita\",", "b": [0.5308, 0.5475, 0.5982, 0.5603]}, {"w": "y='Life", "b": [0.6066, 0.5475, 0.6657, 0.5603]}, {"w": "satisfaction')", "b": [0.6741, 0.5475, 0.7922, 0.5603]}, {"w": "plt.show()", "b": [0.1429, 0.5629, 0.2272, 0.5757]}]}, {"id": "b_9", "type": "equation", "text": "# Select a linear model model = sklearn.linear_model.LinearRegression()", "words": [{"w": "#", "b": [0.1429, 0.5937, 0.1513, 0.6066]}, {"w": "Select", "b": [0.1597, 0.5937, 0.2103, 0.6066]}, {"w": "a", "b": [0.2187, 0.5937, 0.2272, 0.6066]}, {"w": "linear", "b": [0.2356, 0.5937, 0.2862, 0.6066]}, {"w": "model", "b": [0.2946, 0.5937, 0.3368, 0.6066]}, {"w": "model", "b": [0.1429, 0.6091, 0.185, 0.622]}, {"w": "=", "b": [0.1934, 0.6091, 0.2019, 0.622]}, {"w": "sklearn.linear_model.LinearRegression()", "b": [0.2103, 0.6091, 0.5392, 0.622]}]}, {"id": "b_10", "type": "paragraph", "text": "# Train the model model.fit(X, y)", "words": [{"w": "#", "b": [0.1429, 0.64, 0.1513, 0.6528]}, {"w": "Train", "b": [0.1597, 0.64, 0.2019, 0.6528]}, {"w": "the", "b": [0.2103, 0.64, 0.2356, 0.6528]}, {"w": "model", "b": [0.244, 0.64, 0.2862, 0.6528]}, {"w": "model.fit(X,", "b": [0.1429, 0.6554, 0.244, 0.6683]}, {"w": "y)", "b": [0.2525, 0.6554, 0.2693, 0.6683]}]}, {"id": "b_11", "type": "paragraph", "text": "# Make a prediction for Cyprus X_new = [[22587]] # Cyprus' GDP per capita print(model.predict(X_new)) # outputs [[ 5.96242338]]", "words": [{"w": "#", "b": [0.1429, 0.6862, 0.1513, 0.6991]}, {"w": "Make", "b": [0.1597, 0.6862, 0.1934, 0.6991]}, {"w": "a", "b": [0.2019, 0.6862, 0.2103, 0.6991]}, {"w": "prediction", "b": [0.2187, 0.6862, 0.3031, 0.6991]}, {"w": "for", "b": [0.3115, 0.6862, 0.3368, 0.6991]}, {"w": "Cyprus", "b": [0.3452, 0.6862, 0.3958, 0.6991]}, {"w": "X_new", "b": [0.1429, 0.7017, 0.185, 0.7145]}, {"w": "=", "b": [0.1934, 0.7017, 0.2019, 0.7145]}, {"w": "[[22587]]", "b": [0.2103, 0.7017, 0.2862, 0.7145]}, {"w": "#", "b": [0.3031, 0.7017, 0.3115, 0.7145]}, {"w": "Cyprus'", "b": [0.3199, 0.7017, 0.379, 0.7145]}, {"w": "GDP", "b": [0.3874, 0.7017, 0.4127, 0.7145]}, {"w": "per", "b": [0.4211, 0.7017, 0.4464, 0.7145]}, {"w": "capita", "b": [0.4549, 0.7017, 0.5055, 0.7145]}, {"w": "print(model.predict(X_new))", "b": [0.1429, 0.7171, 0.3705, 0.7299]}, {"w": "#", "b": [0.379, 0.7171, 0.3874, 0.7299]}, {"w": "outputs", "b": [0.3958, 0.7171, 0.4549, 0.7299]}, {"w": "[[", "b": [0.4633, 0.7171, 0.4802, 0.7299]}, {"w": "5.96242338]]", "b": [0.4886, 0.7171, 0.5898, 0.7299]}]}, {"id": "b_12", "type": "paragraph", "text": "22 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "22", "b": [0.1428, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.337, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 49, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "If you had used an instance-based learning algorithm instead, you would have found that Slovenia has the closest GDP per capita to that of Cyprus ($20,732), and since the OECD data tells us that Slovenians’ life satisfaction is 5.7, you would have predicted a life satisfaction of 5.7 for Cyprus. If you zoom out a bit and look at the two next closest countries, you will find Portugal and Spain with life satisfactions of 5.1 and 6.5, respectively. Averaging these three values, you get 5.77, which is pretty close to your model-based pre‐ diction. This simple algorithm is called k-Nearest Neighbors regres‐ sion (in this example, k = 3).", "words": [{"w": "If", "b": [0.2714, 0.0793, 0.2835, 0.0989]}, {"w": "you", "b": [0.2892, 0.0793, 0.3178, 0.0989]}, {"w": "had", "b": [0.3235, 0.0793, 0.3521, 0.0989]}, {"w": "used", "b": [0.3578, 0.0793, 0.393, 0.0989]}, {"w": "an", "b": [0.3987, 0.0793, 0.4175, 0.0989]}, {"w": "instance-based", "b": [0.4232, 0.0793, 0.5364, 0.0989]}, {"w": "learning", "b": [0.5421, 0.0793, 0.6053, 0.0989]}, {"w": "algorithm", "b": [0.611, 0.0793, 0.6866, 0.0989]}, {"w": "instead,", "b": [0.6923, 0.0793, 0.7515, 0.0989]}, {"w": "you", "b": [0.7571, 0.0793, 0.7857, 0.0989]}, {"w": "would", "b": [0.2714, 0.0967, 0.3192, 0.1163]}, {"w": "have", "b": [0.3252, 0.0967, 0.3604, 0.1163]}, {"w": "found", "b": [0.3664, 0.0967, 0.4124, 0.1163]}, {"w": "that", "b": [0.4185, 0.0967, 0.4483, 0.1163]}, {"w": "Slovenia", "b": [0.4543, 0.0967, 0.5187, 0.1163]}, {"w": "has", "b": [0.5248, 0.0967, 0.5503, 0.1163]}, {"w": "the", "b": [0.5564, 0.0967, 0.5805, 0.1163]}, {"w": "closest", "b": [0.5866, 0.0967, 0.637, 0.1163]}, {"w": "GDP", "b": [0.6431, 0.0967, 0.6815, 0.1163]}, {"w": "per", "b": [0.6876, 0.0967, 0.7127, 0.1163]}, {"w": "capita", "b": [0.7188, 0.0967, 0.7641, 0.1163]}, {"w": "to", "b": [0.7702, 0.0967, 0.7857, 0.1163]}, {"w": "that", "b": [0.2714, 0.1141, 0.3012, 0.1337]}, {"w": "of", "b": [0.3088, 0.1141, 0.3242, 0.1337]}, {"w": "Cyprus", "b": [0.3318, 0.1141, 0.3874, 0.1337]}, {"w": "($20,732),", "b": [0.395, 0.1141, 0.4717, 0.1337]}, {"w": "and", "b": [0.4794, 0.1141, 0.5082, 0.1337]}, {"w": "since", "b": [0.5158, 0.1141, 0.5545, 0.1337]}, {"w": "the", "b": [0.5621, 0.1141, 0.5862, 0.1337]}, {"w": "OECD", "b": [0.5938, 0.1141, 0.6455, 0.1337]}, {"w": "data", "b": [0.6532, 0.1141, 0.6854, 0.1337]}, {"w": "tells", "b": [0.693, 0.1141, 0.7236, 0.1337]}, {"w": "us", "b": [0.7312, 0.1141, 0.7483, 0.1337]}, {"w": "that", "b": [0.7559, 0.1141, 0.7857, 0.1337]}, {"w": "Slovenians’", "b": [0.2714, 0.1315, 0.3566, 0.1511]}, {"w": "life", "b": [0.3631, 0.1315, 0.3868, 0.1511]}, {"w": "satisfaction", "b": [0.3932, 0.1315, 0.4792, 0.1511]}, {"w": "is", "b": [0.4857, 0.1315, 0.4978, 0.1511]}, {"w": "5.7,", "b": [0.5042, 0.1315, 0.5312, 0.1511]}, {"w": "you", "b": [0.5377, 0.1315, 0.5662, 0.1511]}, {"w": "would", "b": [0.5727, 0.1315, 0.6204, 0.1511]}, {"w": "have", "b": [0.6269, 0.1315, 0.662, 0.1511]}, {"w": "predicted", "b": [0.6685, 0.1315, 0.7408, 0.1511]}, {"w": "a", "b": [0.7472, 0.1315, 0.7556, 0.1511]}, {"w": "life", "b": [0.7621, 0.1315, 0.7857, 0.1511]}, {"w": "satisfaction", "b": [0.2714, 0.1489, 0.3574, 0.1685]}, {"w": "of", "b": [0.3624, 0.1489, 0.3777, 0.1685]}, {"w": "5.7", "b": [0.3827, 0.1489, 0.4053, 0.1685]}, {"w": "for", "b": [0.4102, 0.1489, 0.4327, 0.1685]}, {"w": "Cyprus.", "b": [0.4376, 0.1489, 0.4975, 0.1685]}, {"w": "If", "b": [0.5025, 0.1489, 0.5146, 0.1685]}, {"w": "you", "b": [0.5195, 0.1489, 0.5481, 0.1685]}, {"w": "zoom", "b": [0.5531, 0.1489, 0.5961, 0.1685]}, {"w": "out", "b": [0.601, 0.1489, 0.6267, 0.1685]}, {"w": "a", "b": [0.6316, 0.1489, 0.64, 0.1685]}, {"w": "bit", "b": [0.6449, 0.1489, 0.6655, 0.1685]}, {"w": "and", "b": [0.6705, 0.1489, 0.6993, 0.1685]}, {"w": "look", "b": [0.7042, 0.1489, 0.7379, 0.1685]}, {"w": "at", "b": [0.7429, 0.1489, 0.7567, 0.1685]}, {"w": "the", "b": [0.7616, 0.1489, 0.7857, 0.1685]}, {"w": "two", "b": [0.2714, 0.1664, 0.3, 0.1859]}, {"w": "next", "b": [0.3068, 0.1664, 0.3401, 0.1859]}, {"w": "closest", "b": [0.3469, 0.1664, 0.3974, 0.1859]}, {"w": "countries,", "b": [0.4042, 0.1664, 0.4796, 0.1859]}, {"w": "you", "b": [0.4864, 0.1664, 0.515, 0.1859]}, {"w": "will", "b": [0.5218, 0.1664, 0.5496, 0.1859]}, {"w": "find", "b": [0.5564, 0.1664, 0.5876, 0.1859]}, {"w": "Portugal", "b": [0.5945, 0.1664, 0.6594, 0.1859]}, {"w": "and", "b": [0.6662, 0.1664, 0.695, 0.1859]}, {"w": "Spain", "b": [0.7019, 0.1664, 0.7448, 0.1859]}, {"w": "with", "b": [0.7516, 0.1664, 0.7857, 0.1859]}, {"w": "life", "b": [0.2714, 0.1838, 0.2951, 0.2033]}, {"w": "satisfactions", "b": [0.3012, 0.1838, 0.3942, 0.2033]}, {"w": "of", "b": [0.4003, 0.1838, 0.4157, 0.2033]}, {"w": "5.1", "b": [0.4218, 0.1838, 0.4445, 0.2033]}, {"w": "and", "b": [0.4506, 0.1838, 0.4794, 0.2033]}, {"w": "6.5,", "b": [0.4856, 0.1838, 0.5125, 0.2033]}, {"w": "respectively.", "b": [0.5187, 0.1838, 0.6113, 0.2033]}, {"w": "Averaging", "b": [0.6174, 0.1838, 0.695, 0.2033]}, {"w": "these", "b": [0.7012, 0.1838, 0.7403, 0.2033]}, {"w": "three", "b": [0.7465, 0.1838, 0.7857, 0.2033]}, {"w": "values,", "b": [0.2714, 0.2012, 0.323, 0.2208]}, {"w": "you", "b": [0.3277, 0.2012, 0.3563, 0.2208]}, {"w": "get", "b": [0.361, 0.2012, 0.3838, 0.2208]}, {"w": "5.77,", "b": [0.3886, 0.2012, 0.4247, 0.2208]}, {"w": "which", "b": [0.4294, 0.2012, 0.476, 0.2208]}, {"w": "is", "b": [0.4807, 0.2012, 0.4928, 0.2208]}, {"w": "pretty", "b": [0.4975, 0.2012, 0.543, 0.2208]}, {"w": "close", "b": [0.5478, 0.2012, 0.5854, 0.2208]}, {"w": "to", "b": [0.5902, 0.2012, 0.6057, 0.2208]}, {"w": "your", "b": [0.6104, 0.2012, 0.6461, 0.2208]}, {"w": "model-based", "b": [0.6508, 0.2012, 0.7491, 0.2208]}, {"w": "pre‐", "b": [0.7538, 0.2012, 0.7857, 0.2208]}, {"w": "diction.", "b": [0.2714, 0.2186, 0.33, 0.2382]}, {"w": "This", "b": [0.3352, 0.2186, 0.3692, 0.2382]}, {"w": "simple", "b": [0.3744, 0.2186, 0.4246, 0.2382]}, {"w": "algorithm", "b": [0.4298, 0.2186, 0.5054, 0.2382]}, {"w": "is", "b": [0.5106, 0.2186, 0.5227, 0.2382]}, {"w": "called", "b": [0.5279, 0.2186, 0.5721, 0.2382]}, {"w": "k-Nearest", "b": [0.5773, 0.2184, 0.6481, 0.2382]}, {"w": "Neighbors", "b": [0.6534, 0.2184, 0.7275, 0.2382]}, {"w": "regres‐", "b": [0.7327, 0.2186, 0.7857, 0.2382]}, {"w": "sion", "b": [0.2714, 0.236, 0.3036, 0.2556]}, {"w": "(in", "b": [0.308, 0.236, 0.3301, 0.2556]}, {"w": "this", "b": [0.3344, 0.236, 0.3625, 0.2556]}, {"w": "example,", "b": [0.3668, 0.236, 0.4347, 0.2556]}, {"w": "k", "b": [0.4391, 0.2358, 0.448, 0.2556]}, {"w": "=", "b": [0.4523, 0.236, 0.4634, 0.2556]}, {"w": "3).", "b": [0.4677, 0.236, 0.4878, 0.2556]}]}, {"id": "b_1", "type": "paragraph", "text": "Replacing the Linear Regression model with k-Nearest Neighbors regression in the previous code is as simple as replacing these two lines:", "words": [{"w": "Replacing", "b": [0.2714, 0.2595, 0.347, 0.2791]}, {"w": "the", "b": [0.3536, 0.2595, 0.3776, 0.2791]}, {"w": "Linear", "b": [0.3842, 0.2595, 0.4335, 0.2791]}, {"w": "Regression", "b": [0.4401, 0.2595, 0.5233, 0.2791]}, {"w": "model", "b": [0.5299, 0.2595, 0.5781, 0.2791]}, {"w": "with", "b": [0.5847, 0.2595, 0.6189, 0.2791]}, {"w": "k-Nearest", "b": [0.6254, 0.2595, 0.6997, 0.2791]}, {"w": "Neighbors", "b": [0.7063, 0.2595, 0.7857, 0.2791]}, {"w": "regression", "b": [0.2714, 0.2769, 0.3499, 0.2965]}, {"w": "in", "b": [0.3556, 0.2769, 0.3711, 0.2965]}, {"w": "the", "b": [0.3768, 0.2769, 0.4009, 0.2965]}, {"w": "previous", "b": [0.4066, 0.2769, 0.4725, 0.2965]}, {"w": "code", "b": [0.4782, 0.2769, 0.5141, 0.2965]}, {"w": "is", "b": [0.5199, 0.2769, 0.532, 0.2965]}, {"w": "as", "b": [0.5377, 0.2769, 0.553, 0.2965]}, {"w": "simple", "b": [0.5587, 0.2769, 0.609, 0.2965]}, {"w": "as", "b": [0.6147, 0.2769, 0.63, 0.2965]}, {"w": "replacing", "b": [0.6357, 0.2769, 0.7066, 0.2965]}, {"w": "these", "b": [0.7123, 0.2769, 0.7514, 0.2965]}, {"w": "two", "b": [0.7572, 0.2769, 0.7857, 0.2965]}, {"w": "lines:", "b": [0.2714, 0.2943, 0.3112, 0.3139]}]}, {"id": "b_2", "type": "paragraph", "text": "import sklearn.linear_model model = sklearn.linear_model.LinearRegression() with these two:", "words": [{"w": "import", "b": [0.3051, 0.3214, 0.3557, 0.3343]}, {"w": "sklearn.linear_model", "b": [0.3642, 0.3214, 0.5328, 0.3343]}, {"w": "model", "b": [0.3051, 0.3368, 0.3473, 0.3497]}, {"w": "=", "b": [0.3557, 0.3368, 0.3642, 0.3497]}, {"w": "sklearn.linear_model.LinearRegression()", "b": [0.3726, 0.3368, 0.7015, 0.3497]}, {"w": "with", "b": [0.2714, 0.3547, 0.3055, 0.3742]}, {"w": "these", "b": [0.3099, 0.3547, 0.349, 0.3742]}, {"w": "two:", "b": [0.3533, 0.3547, 0.3863, 0.3742]}]}, {"id": "b_3", "type": "paragraph", "text": "import sklearn.neighbors model = sklearn.neighbors.KNeighborsRegressor(n_neighbors=3)", "words": [{"w": "import", "b": [0.3051, 0.3818, 0.3557, 0.3946]}, {"w": "sklearn.neighbors", "b": [0.3642, 0.3818, 0.5075, 0.3946]}, {"w": "model", "b": [0.3051, 0.3972, 0.3473, 0.41]}, {"w": "=", "b": [0.3557, 0.3972, 0.3642, 0.41]}, {"w": "sklearn.neighbors.KNeighborsRegressor(n_neighbors=3)", "b": [0.3726, 0.3972, 0.8111, 0.41]}]}, {"id": "b_4", "type": "paragraph", "text": "If all went well, your model will make good predictions. If not, you may need to use more attributes (employment rate, health, air pollution, etc.), get more or better qual‐ ity training data, or perhaps select a more powerful model (e.g., a Polynomial Regres‐ sion model).", "words": [{"w": "If", "b": [0.1429, 0.4314, 0.1561, 0.4528]}, {"w": "all", "b": [0.1621, 0.4314, 0.1818, 0.4528]}, {"w": "went", "b": [0.1878, 0.4314, 0.2283, 0.4528]}, {"w": "well,", "b": [0.2343, 0.4314, 0.2727, 0.4528]}, {"w": "your", "b": [0.2787, 0.4314, 0.3177, 0.4528]}, {"w": "model", "b": [0.3237, 0.4314, 0.3765, 0.4528]}, {"w": "will", "b": [0.3825, 0.4314, 0.4129, 0.4528]}, {"w": "make", "b": [0.4189, 0.4314, 0.4643, 0.4528]}, {"w": "good", "b": [0.4703, 0.4314, 0.5123, 0.4528]}, {"w": "predictions.", "b": [0.5183, 0.4314, 0.6175, 0.4528]}, {"w": "If", "b": [0.6235, 0.4314, 0.6368, 0.4528]}, {"w": "not,", "b": [0.6428, 0.4314, 0.6759, 0.4528]}, {"w": "you", "b": [0.6819, 0.4314, 0.7131, 0.4528]}, {"w": "may", "b": [0.7191, 0.4314, 0.7545, 0.4528]}, {"w": "need", "b": [0.7605, 0.4314, 0.8006, 0.4528]}, {"w": "to", "b": [0.8066, 0.4314, 0.8236, 0.4528]}, {"w": "use", "b": [0.8296, 0.4314, 0.8572, 0.4528]}, {"w": "more", "b": [0.1429, 0.4505, 0.1871, 0.4719]}, {"w": "attributes", "b": [0.1922, 0.4505, 0.2714, 0.4719]}, {"w": "(employment", "b": [0.2765, 0.4505, 0.3888, 0.4719]}, {"w": "rate,", "b": [0.3939, 0.4505, 0.4303, 0.4719]}, {"w": "health,", "b": [0.4353, 0.4505, 0.492, 0.4719]}, {"w": "air", "b": [0.497, 0.4505, 0.5195, 0.4719]}, {"w": "pollution,", "b": [0.5245, 0.4505, 0.6064, 0.4719]}, {"w": "etc.),", "b": [0.6114, 0.4505, 0.6521, 0.4719]}, {"w": "get", "b": [0.6572, 0.4505, 0.6821, 0.4719]}, {"w": "more", "b": [0.6871, 0.4505, 0.7314, 0.4719]}, {"w": "or", "b": [0.7365, 0.4505, 0.7548, 0.4719]}, {"w": "better", "b": [0.7598, 0.4505, 0.8086, 0.4719]}, {"w": "qual‐", "b": [0.8136, 0.4505, 0.8571, 0.4719]}, {"w": "ity", "b": [0.1429, 0.4695, 0.1644, 0.4909]}, {"w": "training", "b": [0.1695, 0.4695, 0.2364, 0.4909]}, {"w": "data,", "b": [0.2415, 0.4695, 0.2815, 0.4909]}, {"w": "or", "b": [0.2867, 0.4695, 0.305, 0.4909]}, {"w": "perhaps", "b": [0.3101, 0.4695, 0.3761, 0.4909]}, {"w": "select", "b": [0.3812, 0.4695, 0.427, 0.4909]}, {"w": "a", "b": [0.4321, 0.4695, 0.4413, 0.4909]}, {"w": "more", "b": [0.4464, 0.4695, 0.4907, 0.4909]}, {"w": "powerful", "b": [0.4958, 0.4695, 0.5707, 0.4909]}, {"w": "model", "b": [0.5758, 0.4695, 0.6286, 0.4909]}, {"w": "(e.g.,", "b": [0.6338, 0.4695, 0.6738, 0.4909]}, {"w": "a", "b": [0.6789, 0.4695, 0.6881, 0.4909]}, {"w": "Polynomial", "b": [0.6932, 0.4695, 0.7888, 0.4909]}, {"w": "Regres‐", "b": [0.794, 0.4695, 0.8571, 0.4909]}, {"w": "sion", "b": [0.1428, 0.4886, 0.1781, 0.51]}, {"w": "model).", "b": [0.1828, 0.4886, 0.2476, 0.51]}]}, {"id": "b_5", "type": "paragraph", "text": "In summary:", "words": [{"w": "In", "b": [0.1428, 0.5167, 0.1613, 0.5381]}, {"w": "summary:", "b": [0.1661, 0.5167, 0.2513, 0.5381]}]}, {"id": "b_6", "type": "paragraph", "text": "• You studied the data.", "words": [{"w": "•", "b": [0.16, 0.5508, 0.1681, 0.5723]}, {"w": "You", "b": [0.1786, 0.5508, 0.2109, 0.5723]}, {"w": "studied", "b": [0.2156, 0.5508, 0.2771, 0.5723]}, {"w": "the", "b": [0.2819, 0.5508, 0.3082, 0.5723]}, {"w": "data.", "b": [0.3129, 0.5508, 0.3529, 0.5723]}]}, {"id": "b_7", "type": "paragraph", "text": "• You selected a model.", "words": [{"w": "•", "b": [0.16, 0.5759, 0.1682, 0.5973]}, {"w": "You", "b": [0.1786, 0.5759, 0.2109, 0.5973]}, {"w": "selected", "b": [0.2156, 0.5759, 0.2813, 0.5973]}, {"w": "a", "b": [0.286, 0.5759, 0.2952, 0.5973]}, {"w": "model.", "b": [0.2999, 0.5759, 0.3575, 0.5973]}]}, {"id": "b_8", "type": "paragraph", "text": "• You trained it on the training data (i.e., the learning algorithm searched for the model parameter values that minimize a cost function).", "words": [{"w": "•", "b": [0.16, 0.601, 0.1682, 0.6224]}, {"w": "You", "b": [0.1786, 0.601, 0.2109, 0.6224]}, {"w": "trained", "b": [0.2175, 0.601, 0.2776, 0.6224]}, {"w": "it", "b": [0.2842, 0.601, 0.2961, 0.6224]}, {"w": "on", "b": [0.3027, 0.601, 0.3247, 0.6224]}, {"w": "the", "b": [0.3313, 0.601, 0.3576, 0.6224]}, {"w": "training", "b": [0.3642, 0.601, 0.4312, 0.6224]}, {"w": "data", "b": [0.4377, 0.601, 0.473, 0.6224]}, {"w": "(i.e.,", "b": [0.4796, 0.601, 0.5155, 0.6224]}, {"w": "the", "b": [0.5221, 0.601, 0.5484, 0.6224]}, {"w": "learning", "b": [0.555, 0.601, 0.6241, 0.6224]}, {"w": "algorithm", "b": [0.6307, 0.601, 0.7133, 0.6224]}, {"w": "searched", "b": [0.7199, 0.601, 0.7931, 0.6224]}, {"w": "for", "b": [0.7997, 0.601, 0.8242, 0.6224]}, {"w": "the", "b": [0.8308, 0.601, 0.8571, 0.6224]}, {"w": "model", "b": [0.1786, 0.6201, 0.2314, 0.6415]}, {"w": "parameter", "b": [0.2361, 0.6201, 0.3219, 0.6415]}, {"w": "values", "b": [0.3266, 0.6201, 0.3783, 0.6415]}, {"w": "that", "b": [0.383, 0.6201, 0.4156, 0.6415]}, {"w": "minimize", "b": [0.4203, 0.6201, 0.5002, 0.6415]}, {"w": "a", "b": [0.5049, 0.6201, 0.5141, 0.6415]}, {"w": "cost", "b": [0.5188, 0.6201, 0.5522, 0.6415]}, {"w": "function).", "b": [0.5569, 0.6201, 0.6403, 0.6415]}]}, {"id": "b_9", "type": "paragraph", "text": "• Finally, you applied the model to make predictions on new cases (this is called inference), hoping that this model will generalize well.", "words": [{"w": "•", "b": [0.16, 0.6452, 0.1682, 0.6666]}, {"w": "Finally,", "b": [0.1786, 0.6452, 0.239, 0.6666]}, {"w": "you", "b": [0.2461, 0.6452, 0.2773, 0.6666]}, {"w": "applied", "b": [0.2844, 0.6452, 0.3456, 0.6666]}, {"w": "the", "b": [0.3527, 0.6452, 0.379, 0.6666]}, {"w": "model", "b": [0.386, 0.6452, 0.4389, 0.6666]}, {"w": "to", "b": [0.4459, 0.6452, 0.4629, 0.6666]}, {"w": "make", "b": [0.4699, 0.6452, 0.5153, 0.6666]}, {"w": "predictions", "b": [0.5223, 0.6452, 0.6168, 0.6666]}, {"w": "on", "b": [0.6238, 0.6452, 0.6459, 0.6666]}, {"w": "new", "b": [0.6529, 0.6452, 0.6874, 0.6666]}, {"w": "cases", "b": [0.6944, 0.6452, 0.7365, 0.6666]}, {"w": "(this", "b": [0.7436, 0.6452, 0.7815, 0.6666]}, {"w": "is", "b": [0.7885, 0.6452, 0.8018, 0.6666]}, {"w": "called", "b": [0.8088, 0.6452, 0.8571, 0.6666]}, {"w": "inference),", "b": [0.1786, 0.664, 0.2632, 0.6856]}, {"w": "hoping", "b": [0.268, 0.6642, 0.3274, 0.6856]}, {"w": "that", "b": [0.3321, 0.6642, 0.3647, 0.6856]}, {"w": "this", "b": [0.3694, 0.6642, 0.4001, 0.6856]}, {"w": "model", "b": [0.4048, 0.6642, 0.4577, 0.6856]}, {"w": "will", "b": [0.4624, 0.6642, 0.4928, 0.6856]}, {"w": "generalize", "b": [0.4975, 0.6642, 0.5817, 0.6856]}, {"w": "well.", "b": [0.5864, 0.6642, 0.6248, 0.6856]}]}, {"id": "b_10", "type": "paragraph", "text": "This is what a typical Machine Learning project looks like. In Chapter 2 you will experience this first-hand by going through an end-to-end project.", "words": [{"w": "This", "b": [0.1429, 0.6984, 0.1801, 0.7198]}, {"w": "is", "b": [0.1883, 0.6984, 0.2015, 0.7198]}, {"w": "what", "b": [0.2097, 0.6984, 0.2502, 0.7198]}, {"w": "a", "b": [0.2584, 0.6984, 0.2675, 0.7198]}, {"w": "typical", "b": [0.2757, 0.6984, 0.3314, 0.7198]}, {"w": "Machine", "b": [0.3396, 0.6984, 0.4127, 0.7198]}, {"w": "Learning", "b": [0.4209, 0.6984, 0.4959, 0.7198]}, {"w": "project", "b": [0.5041, 0.6984, 0.5628, 0.7198]}, {"w": "looks", "b": [0.571, 0.6984, 0.6155, 0.7198]}, {"w": "like.", "b": [0.6237, 0.6984, 0.6584, 0.7198]}, {"w": "In", "b": [0.6666, 0.6984, 0.6851, 0.7198]}, {"w": "Chapter", "b": [0.6933, 0.6984, 0.7609, 0.7198]}, {"w": "2", "b": [0.7691, 0.6984, 0.7791, 0.7198]}, {"w": "you", "b": [0.7873, 0.6984, 0.8186, 0.7198]}, {"w": "will", "b": [0.8268, 0.6984, 0.8572, 0.7198]}, {"w": "experience", "b": [0.1429, 0.7174, 0.2325, 0.7388]}, {"w": "this", "b": [0.2373, 0.7174, 0.268, 0.7388]}, {"w": "first-hand", "b": [0.2727, 0.7174, 0.3563, 0.7388]}, {"w": "by", "b": [0.361, 0.7174, 0.3812, 0.7388]}, {"w": "going", "b": [0.3859, 0.7174, 0.433, 0.7388]}, {"w": "through", "b": [0.4377, 0.7174, 0.5055, 0.7388]}, {"w": "an", "b": [0.5102, 0.7174, 0.5308, 0.7388]}, {"w": "end-to-end", "b": [0.5355, 0.7174, 0.6298, 0.7388]}, {"w": "project.", "b": [0.6345, 0.7174, 0.6979, 0.7388]}]}, {"id": "b_11", "type": "paragraph", "text": "We have covered a lot of ground so far: you now know what Machine Learning is really about, why it is useful, what some of the most common categories of ML sys‐ tems are, and what a typical project workflow looks like. Now let’s look at what can go wrong in learning and prevent you from making accurate predictions.", "words": [{"w": "We", "b": [0.1429, 0.7455, 0.1699, 0.767]}, {"w": "have", "b": [0.1773, 0.7455, 0.2157, 0.767]}, {"w": "covered", "b": [0.2231, 0.7455, 0.2886, 0.767]}, {"w": "a", "b": [0.296, 0.7455, 0.3052, 0.767]}, {"w": "lot", "b": [0.3126, 0.7455, 0.3348, 0.767]}, {"w": "of", "b": [0.3422, 0.7455, 0.359, 0.767]}, {"w": "ground", "b": [0.3664, 0.7455, 0.428, 0.767]}, {"w": "so", "b": [0.4353, 0.7455, 0.4536, 0.767]}, {"w": "far:", "b": [0.461, 0.7455, 0.4893, 0.767]}, {"w": "you", "b": [0.4967, 0.7455, 0.5279, 0.767]}, {"w": "now", "b": [0.5353, 0.7455, 0.5716, 0.767]}, {"w": "know", "b": [0.579, 0.7455, 0.6257, 0.767]}, {"w": "what", "b": [0.633, 0.7455, 0.6735, 0.767]}, {"w": "Machine", "b": [0.6809, 0.7455, 0.7541, 0.767]}, {"w": "Learning", "b": [0.7615, 0.7455, 0.8365, 0.767]}, {"w": "is", "b": [0.8439, 0.7455, 0.8571, 0.767]}, {"w": "really", "b": [0.1429, 0.7646, 0.1887, 0.786]}, {"w": "about,", "b": [0.195, 0.7646, 0.2475, 0.786]}, {"w": "why", "b": [0.2538, 0.7646, 0.2883, 0.786]}, {"w": "it", "b": [0.2946, 0.7646, 0.3065, 0.786]}, {"w": "is", "b": [0.3129, 0.7646, 0.3261, 0.786]}, {"w": "useful,", "b": [0.3324, 0.7646, 0.3872, 0.786]}, {"w": "what", "b": [0.3935, 0.7646, 0.434, 0.786]}, {"w": "some", "b": [0.4403, 0.7646, 0.4845, 0.786]}, {"w": "of", "b": [0.4908, 0.7646, 0.5076, 0.786]}, {"w": "the", "b": [0.5139, 0.7646, 0.5402, 0.786]}, {"w": "most", "b": [0.5465, 0.7646, 0.5882, 0.786]}, {"w": "common", "b": [0.5945, 0.7646, 0.6701, 0.786]}, {"w": "categories", "b": [0.6764, 0.7646, 0.7594, 0.786]}, {"w": "of", "b": [0.7657, 0.7646, 0.7825, 0.786]}, {"w": "ML", "b": [0.7888, 0.7646, 0.8186, 0.786]}, {"w": "sys‐", "b": [0.8249, 0.7646, 0.8571, 0.786]}, {"w": "tems", "b": [0.1428, 0.7836, 0.1828, 0.8051]}, {"w": "are,", "b": [0.1876, 0.7836, 0.2181, 0.8051]}, {"w": "and", "b": [0.2229, 0.7836, 0.2545, 0.8051]}, {"w": "what", "b": [0.2593, 0.7836, 0.2998, 0.8051]}, {"w": "a", "b": [0.3047, 0.7836, 0.3138, 0.8051]}, {"w": "typical", "b": [0.3187, 0.7836, 0.3743, 0.8051]}, {"w": "project", "b": [0.3792, 0.7836, 0.4378, 0.8051]}, {"w": "workflow", "b": [0.4426, 0.7836, 0.5219, 0.8051]}, {"w": "looks", "b": [0.5268, 0.7836, 0.5713, 0.8051]}, {"w": "like.", "b": [0.5761, 0.7836, 0.6109, 0.8051]}, {"w": "Now", "b": [0.6158, 0.7836, 0.6556, 0.8051]}, {"w": "let’s", "b": [0.6605, 0.7836, 0.6907, 0.8051]}, {"w": "look", "b": [0.6956, 0.7836, 0.7324, 0.8051]}, {"w": "at", "b": [0.7373, 0.7836, 0.7524, 0.8051]}, {"w": "what", "b": [0.7572, 0.7836, 0.7977, 0.8051]}, {"w": "can", "b": [0.8026, 0.7836, 0.8319, 0.8051]}, {"w": "go", "b": [0.8368, 0.7836, 0.8571, 0.8051]}, {"w": "wrong", "b": [0.1429, 0.8027, 0.1966, 0.8241]}, {"w": "in", "b": [0.2014, 0.8027, 0.2183, 0.8241]}, {"w": "learning", "b": [0.2231, 0.8027, 0.2922, 0.8241]}, {"w": "and", "b": [0.2969, 0.8027, 0.3285, 0.8241]}, {"w": "prevent", "b": [0.3332, 0.8027, 0.3966, 0.8241]}, {"w": "you", "b": [0.4013, 0.8027, 0.4325, 0.8241]}, {"w": "from", "b": [0.4373, 0.8027, 0.4788, 0.8241]}, {"w": "making", "b": [0.4836, 0.8027, 0.5468, 0.8241]}, {"w": "accurate", "b": [0.5516, 0.8027, 0.6211, 0.8241]}, {"w": "predictions.", "b": [0.6258, 0.8027, 0.7251, 0.8241]}]}, {"id": "b_12", "type": "paragraph", "text": "Types of Machine Learning Systems | 23", "words": [{"w": "Types", "b": [0.5961, 0.9225, 0.6295, 0.9388]}, {"w": "of", "b": [0.6323, 0.9225, 0.6443, 0.9388]}, {"w": "Machine", "b": [0.6471, 0.9225, 0.6971, 0.9388]}, {"w": "Learning", "b": [0.6999, 0.9225, 0.7521, 0.9388]}, {"w": "Systems", "b": [0.7549, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "23", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 50, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Main Challenges of Machine Learning", "words": [{"w": "Main", "b": [0.1429, 0.0753, 0.205, 0.1095]}, {"w": "Challenges", "b": [0.2109, 0.0753, 0.3457, 0.1095]}, {"w": "of", "b": [0.3516, 0.0753, 0.3768, 0.1095]}, {"w": "Machine", "b": [0.3827, 0.0753, 0.4877, 0.1095]}, {"w": "Learning", "b": [0.4936, 0.0753, 0.6034, 0.1095]}]}, {"id": "b_1", "type": "paragraph", "text": "In short, since your main task is to select a learning algorithm and train it on some data, the two things that can go wrong are “bad algorithm” and “bad data.” Let’s start with examples of bad data.", "words": [{"w": "In", "b": [0.1429, 0.1164, 0.1614, 0.1378]}, {"w": "short,", "b": [0.1678, 0.1164, 0.216, 0.1378]}, {"w": "since", "b": [0.2224, 0.1164, 0.2647, 0.1378]}, {"w": "your", "b": [0.2711, 0.1164, 0.3101, 0.1378]}, {"w": "main", "b": [0.3166, 0.1164, 0.3597, 0.1378]}, {"w": "task", "b": [0.3662, 0.1164, 0.3996, 0.1378]}, {"w": "is", "b": [0.4061, 0.1164, 0.4193, 0.1378]}, {"w": "to", "b": [0.4257, 0.1164, 0.4427, 0.1378]}, {"w": "select", "b": [0.4491, 0.1164, 0.4949, 0.1378]}, {"w": "a", "b": [0.5013, 0.1164, 0.5105, 0.1378]}, {"w": "learning", "b": [0.5169, 0.1164, 0.586, 0.1378]}, {"w": "algorithm", "b": [0.5925, 0.1164, 0.6751, 0.1378]}, {"w": "and", "b": [0.6815, 0.1164, 0.7131, 0.1378]}, {"w": "train", "b": [0.7195, 0.1164, 0.7597, 0.1378]}, {"w": "it", "b": [0.7661, 0.1164, 0.7781, 0.1378]}, {"w": "on", "b": [0.7845, 0.1164, 0.8065, 0.1378]}, {"w": "some", "b": [0.813, 0.1164, 0.8571, 0.1378]}, {"w": "data,", "b": [0.1429, 0.1355, 0.1829, 0.1569]}, {"w": "the", "b": [0.1886, 0.1355, 0.2149, 0.1569]}, {"w": "two", "b": [0.2206, 0.1355, 0.2518, 0.1569]}, {"w": "things", "b": [0.2575, 0.1355, 0.3094, 0.1569]}, {"w": "that", "b": [0.315, 0.1355, 0.3476, 0.1569]}, {"w": "can", "b": [0.3533, 0.1355, 0.3827, 0.1569]}, {"w": "go", "b": [0.3884, 0.1355, 0.4087, 0.1569]}, {"w": "wrong", "b": [0.4144, 0.1355, 0.4682, 0.1569]}, {"w": "are", "b": [0.4739, 0.1355, 0.4996, 0.1569]}, {"w": "“bad", "b": [0.5053, 0.1355, 0.5443, 0.1569]}, {"w": "algorithm”", "b": [0.55, 0.1355, 0.6393, 0.1569]}, {"w": "and", "b": [0.645, 0.1355, 0.6765, 0.1569]}, {"w": "“bad", "b": [0.6822, 0.1355, 0.7212, 0.1569]}, {"w": "data.”", "b": [0.7269, 0.1355, 0.7724, 0.1569]}, {"w": "Let’s", "b": [0.7781, 0.1355, 0.8142, 0.1569]}, {"w": "start", "b": [0.8199, 0.1355, 0.8572, 0.1569]}, {"w": "with", "b": [0.1429, 0.1545, 0.1802, 0.1759]}, {"w": "examples", "b": [0.1849, 0.1545, 0.2621, 0.1759]}, {"w": "of", "b": [0.2668, 0.1545, 0.2836, 0.1759]}, {"w": "bad", "b": [0.2884, 0.1545, 0.3191, 0.1759]}, {"w": "data.", "b": [0.3238, 0.1545, 0.3638, 0.1759]}]}, {"id": "b_2", "type": "paragraph", "text": "Insufficient Quantity of Training Data", "words": [{"w": "Insufficient", "b": [0.1429, 0.1887, 0.2595, 0.2173]}, {"w": "Quantity", "b": [0.2644, 0.1887, 0.3542, 0.2173]}, {"w": "of", "b": [0.3592, 0.1887, 0.3802, 0.2173]}, {"w": "Training", "b": [0.3851, 0.1887, 0.4711, 0.2173]}, {"w": "Data", "b": [0.476, 0.1887, 0.5245, 0.2173]}]}, {"id": "b_3", "type": "paragraph", "text": "For a toddler to learn what an apple is, all it takes is for you to point to an apple and say “apple” (possibly repeating this procedure a few times). Now the child is able to recognize apples in all sorts of colors and shapes. Genius.", "words": [{"w": "For", "b": [0.1429, 0.2232, 0.1718, 0.2446]}, {"w": "a", "b": [0.1775, 0.2232, 0.1867, 0.2446]}, {"w": "toddler", "b": [0.1924, 0.2232, 0.2532, 0.2446]}, {"w": "to", "b": [0.2589, 0.2232, 0.2759, 0.2446]}, {"w": "learn", "b": [0.2816, 0.2232, 0.324, 0.2446]}, {"w": "what", "b": [0.3297, 0.2232, 0.3702, 0.2446]}, {"w": "an", "b": [0.3759, 0.2232, 0.3964, 0.2446]}, {"w": "apple", "b": [0.4021, 0.2232, 0.4469, 0.2446]}, {"w": "is,", "b": [0.4526, 0.2232, 0.4705, 0.2446]}, {"w": "all", "b": [0.4762, 0.2232, 0.4959, 0.2446]}, {"w": "it", "b": [0.5016, 0.2232, 0.5136, 0.2446]}, {"w": "takes", "b": [0.5193, 0.2232, 0.5616, 0.2446]}, {"w": "is", "b": [0.5673, 0.2232, 0.5805, 0.2446]}, {"w": "for", "b": [0.5862, 0.2232, 0.6108, 0.2446]}, {"w": "you", "b": [0.6165, 0.2232, 0.6477, 0.2446]}, {"w": "to", "b": [0.6534, 0.2232, 0.6704, 0.2446]}, {"w": "point", "b": [0.6761, 0.2232, 0.7206, 0.2446]}, {"w": "to", "b": [0.7263, 0.2232, 0.7432, 0.2446]}, {"w": "an", "b": [0.7489, 0.2232, 0.7695, 0.2446]}, {"w": "apple", "b": [0.7752, 0.2232, 0.8199, 0.2446]}, {"w": "and", "b": [0.8256, 0.2232, 0.8571, 0.2446]}, {"w": "say", "b": [0.1429, 0.2422, 0.1688, 0.2636]}, {"w": "“apple”", "b": [0.1754, 0.2422, 0.2342, 0.2636]}, {"w": "(possibly", "b": [0.2408, 0.2422, 0.3158, 0.2636]}, {"w": "repeating", "b": [0.3224, 0.2422, 0.4006, 0.2636]}, {"w": "this", "b": [0.4072, 0.2422, 0.4379, 0.2636]}, {"w": "procedure", "b": [0.4444, 0.2422, 0.53, 0.2636]}, {"w": "a", "b": [0.5366, 0.2422, 0.5457, 0.2636]}, {"w": "few", "b": [0.5523, 0.2422, 0.5816, 0.2636]}, {"w": "times).", "b": [0.5882, 0.2422, 0.6456, 0.2636]}, {"w": "Now", "b": [0.6522, 0.2422, 0.6921, 0.2636]}, {"w": "the", "b": [0.6986, 0.2422, 0.725, 0.2636]}, {"w": "child", "b": [0.7316, 0.2422, 0.7733, 0.2636]}, {"w": "is", "b": [0.7799, 0.2422, 0.7932, 0.2636]}, {"w": "able", "b": [0.7997, 0.2422, 0.8336, 0.2636]}, {"w": "to", "b": [0.8402, 0.2422, 0.8571, 0.2636]}, {"w": "recognize", "b": [0.1429, 0.2613, 0.2232, 0.2827]}, {"w": "apples", "b": [0.2279, 0.2613, 0.2803, 0.2827]}, {"w": "in", "b": [0.285, 0.2613, 0.302, 0.2827]}, {"w": "all", "b": [0.3067, 0.2613, 0.3264, 0.2827]}, {"w": "sorts", "b": [0.3312, 0.2613, 0.3712, 0.2827]}, {"w": "of", "b": [0.3759, 0.2613, 0.3927, 0.2827]}, {"w": "colors", "b": [0.3974, 0.2613, 0.4481, 0.2827]}, {"w": "and", "b": [0.4528, 0.2613, 0.4844, 0.2827]}, {"w": "shapes.", "b": [0.4891, 0.2613, 0.5488, 0.2827]}, {"w": "Genius.", "b": [0.5535, 0.2613, 0.6177, 0.2827]}]}, {"id": "b_4", "type": "paragraph", "text": "Machine Learning is not quite there yet; it takes a lot of data for most Machine Learn‐ ing algorithms to work properly. Even for very simple problems you typically need thousands of examples, and for complex problems such as image or speech recogni‐ tion you may need millions of examples (unless you can reuse parts of an existing model).", "words": [{"w": "Machine", "b": [0.1429, 0.2894, 0.216, 0.3108]}, {"w": "Learning", "b": [0.2208, 0.2894, 0.2959, 0.3108]}, {"w": "is", "b": [0.3006, 0.2894, 0.3139, 0.3108]}, {"w": "not", "b": [0.3187, 0.2894, 0.3471, 0.3108]}, {"w": "quite", "b": [0.3518, 0.2894, 0.3943, 0.3108]}, {"w": "there", "b": [0.3991, 0.2894, 0.4421, 0.3108]}, {"w": "yet;", "b": [0.4469, 0.2894, 0.4764, 0.3108]}, {"w": "it", "b": [0.4812, 0.2894, 0.4931, 0.3108]}, {"w": "takes", "b": [0.4979, 0.2894, 0.5402, 0.3108]}, {"w": "a", "b": [0.545, 0.2894, 0.5542, 0.3108]}, {"w": "lot", "b": [0.559, 0.2894, 0.5812, 0.3108]}, {"w": "of", "b": [0.586, 0.2894, 0.6028, 0.3108]}, {"w": "data", "b": [0.6076, 0.2894, 0.6429, 0.3108]}, {"w": "for", "b": [0.6477, 0.2894, 0.6722, 0.3108]}, {"w": "most", "b": [0.677, 0.2894, 0.7187, 0.3108]}, {"w": "Machine", "b": [0.7235, 0.2894, 0.7966, 0.3108]}, {"w": "Learn‐", "b": [0.8014, 0.2894, 0.8572, 0.3108]}, {"w": "ing", "b": [0.1429, 0.3084, 0.1696, 0.3299]}, {"w": "algorithms", "b": [0.1767, 0.3084, 0.2669, 0.3299]}, {"w": "to", "b": [0.274, 0.3084, 0.291, 0.3299]}, {"w": "work", "b": [0.2981, 0.3084, 0.341, 0.3299]}, {"w": "properly.", "b": [0.3481, 0.3084, 0.4229, 0.3299]}, {"w": "Even", "b": [0.43, 0.3084, 0.4713, 0.3299]}, {"w": "for", "b": [0.4784, 0.3084, 0.5029, 0.3299]}, {"w": "very", "b": [0.51, 0.3084, 0.5464, 0.3299]}, {"w": "simple", "b": [0.5534, 0.3084, 0.6084, 0.3299]}, {"w": "problems", "b": [0.6154, 0.3084, 0.6941, 0.3299]}, {"w": "you", "b": [0.7012, 0.3084, 0.7324, 0.3299]}, {"w": "typically", "b": [0.7395, 0.3084, 0.81, 0.3299]}, {"w": "need", "b": [0.817, 0.3084, 0.8571, 0.3299]}, {"w": "thousands", "b": [0.1429, 0.3275, 0.2289, 0.3489]}, {"w": "of", "b": [0.235, 0.3275, 0.2518, 0.3489]}, {"w": "examples,", "b": [0.2579, 0.3275, 0.3398, 0.3489]}, {"w": "and", "b": [0.3459, 0.3275, 0.3774, 0.3489]}, {"w": "for", "b": [0.3835, 0.3275, 0.4081, 0.3489]}, {"w": "complex", "b": [0.4142, 0.3275, 0.4852, 0.3489]}, {"w": "problems", "b": [0.4913, 0.3275, 0.5699, 0.3489]}, {"w": "such", "b": [0.5761, 0.3275, 0.6147, 0.3489]}, {"w": "as", "b": [0.6208, 0.3275, 0.6376, 0.3489]}, {"w": "image", "b": [0.6437, 0.3275, 0.6941, 0.3489]}, {"w": "or", "b": [0.7002, 0.3275, 0.7186, 0.3489]}, {"w": "speech", "b": [0.7247, 0.3275, 0.7809, 0.3489]}, {"w": "recogni‐", "b": [0.787, 0.3275, 0.8571, 0.3489]}, {"w": "tion", "b": [0.1428, 0.3465, 0.1768, 0.3679]}, {"w": "you", "b": [0.1842, 0.3465, 0.2154, 0.3679]}, {"w": "may", "b": [0.2228, 0.3465, 0.2582, 0.3679]}, {"w": "need", "b": [0.2656, 0.3465, 0.3057, 0.3679]}, {"w": "millions", "b": [0.313, 0.3465, 0.3815, 0.3679]}, {"w": "of", "b": [0.3889, 0.3465, 0.4056, 0.3679]}, {"w": "examples", "b": [0.413, 0.3465, 0.4902, 0.3679]}, {"w": "(unless", "b": [0.4976, 0.3465, 0.5567, 0.3679]}, {"w": "you", "b": [0.564, 0.3465, 0.5953, 0.3679]}, {"w": "can", "b": [0.6027, 0.3465, 0.632, 0.3679]}, {"w": "reuse", "b": [0.6394, 0.3465, 0.6835, 0.3679]}, {"w": "parts", "b": [0.6909, 0.3465, 0.7327, 0.3679]}, {"w": "of", "b": [0.7401, 0.3465, 0.7568, 0.3679]}, {"w": "an", "b": [0.7642, 0.3465, 0.7848, 0.3679]}, {"w": "existing", "b": [0.7921, 0.3465, 0.8571, 0.3679]}, {"w": "model).", "b": [0.1429, 0.3656, 0.2076, 0.387]}]}, {"id": "b_5", "type": "paragraph", "text": "24 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "24", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.3371, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 51, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "8 For example, knowing whether to write “to,” “two,” or “too” depending on the context.", "words": [{"w": "8", "b": [0.1451, 0.822, 0.1518, 0.8363]}, {"w": "For", "b": [0.1587, 0.8205, 0.1808, 0.8368]}, {"w": "example,", "b": [0.1844, 0.8205, 0.241, 0.8368]}, {"w": "knowing", "b": [0.2446, 0.8205, 0.3005, 0.8368]}, {"w": "whether", "b": [0.3041, 0.8205, 0.3562, 0.8368]}, {"w": "to", "b": [0.3598, 0.8205, 0.3727, 0.8368]}, {"w": "write", "b": [0.3763, 0.8205, 0.4089, 0.8368]}, {"w": "“to,”", "b": [0.4125, 0.8205, 0.4385, 0.8368]}, {"w": "“two,”", "b": [0.4421, 0.8205, 0.479, 0.8368]}, {"w": "or", "b": [0.4826, 0.8205, 0.4966, 0.8368]}, {"w": "“too”", "b": [0.5002, 0.8205, 0.5322, 0.8368]}, {"w": "depending", "b": [0.5358, 0.8205, 0.6034, 0.8368]}, {"w": "on", "b": [0.607, 0.8205, 0.6238, 0.8368]}, {"w": "the", "b": [0.6274, 0.8205, 0.6475, 0.8368]}, {"w": "context.", "b": [0.6511, 0.8205, 0.7018, 0.8368]}]}, {"id": "b_1", "type": "paragraph", "text": "9 Figure reproduced with permission from Banko and Brill (2001), “Learning Curves for Confusion Set Disam‐ biguation.”", "words": [{"w": "9", "b": [0.1451, 0.8416, 0.1518, 0.8559]}, {"w": "Figure", "b": [0.1587, 0.8401, 0.1999, 0.8565]}, {"w": "reproduced", "b": [0.2035, 0.8401, 0.2771, 0.8565]}, {"w": "with", "b": [0.2807, 0.8401, 0.3091, 0.8565]}, {"w": "permission", "b": [0.3127, 0.8401, 0.3836, 0.8565]}, {"w": "from", "b": [0.3872, 0.8401, 0.4189, 0.8565]}, {"w": "Banko", "b": [0.4225, 0.8401, 0.4634, 0.8565]}, {"w": "and", "b": [0.467, 0.8401, 0.4911, 0.8565]}, {"w": "Brill", "b": [0.4947, 0.8401, 0.5222, 0.8565]}, {"w": "(2001),", "b": [0.5258, 0.8401, 0.5709, 0.8565]}, {"w": "“Learning", "b": [0.5745, 0.8401, 0.638, 0.8565]}, {"w": "Curves", "b": [0.6416, 0.8401, 0.6868, 0.8565]}, {"w": "for", "b": [0.6904, 0.8401, 0.7091, 0.8565]}, {"w": "Confusion", "b": [0.7127, 0.8401, 0.78, 0.8565]}, {"w": "Set", "b": [0.7837, 0.8401, 0.8028, 0.8565]}, {"w": "Disam‐", "b": [0.8064, 0.8401, 0.8537, 0.8565]}, {"w": "biguation.”", "b": [0.1587, 0.8553, 0.2272, 0.8716]}]}, {"id": "b_2", "type": "paragraph", "text": "10 “The Unreasonable Effectiveness of Data,” Peter Norvig et al. (2009).", "words": [{"w": "10", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“The", "b": [0.1587, 0.8749, 0.1905, 0.8912]}, {"w": "Unreasonable", "b": [0.1941, 0.8749, 0.2817, 0.8912]}, {"w": "Effectiveness", "b": [0.2853, 0.8749, 0.3675, 0.8912]}, {"w": "of", "b": [0.3711, 0.8749, 0.3839, 0.8912]}, {"w": "Data,”", "b": [0.3875, 0.8749, 0.4254, 0.8912]}, {"w": "Peter", "b": [0.429, 0.8749, 0.4617, 0.8912]}, {"w": "Norvig", "b": [0.4653, 0.8749, 0.5102, 0.8912]}, {"w": "et", "b": [0.5138, 0.8749, 0.5253, 0.8912]}, {"w": "al.", "b": [0.529, 0.8749, 0.5436, 0.8912]}, {"w": "(2009).", "b": [0.5472, 0.8749, 0.5922, 0.8912]}]}, {"id": "b_3", "type": "paragraph", "text": "The Unreasonable Effectiveness of Data", "words": [{"w": "The", "b": [0.3082, 0.0921, 0.344, 0.1192]}, {"w": "Unreasonable", "b": [0.3487, 0.0921, 0.4843, 0.1192]}, {"w": "Effectiveness", "b": [0.489, 0.0921, 0.6164, 0.1192]}, {"w": "of", "b": [0.6211, 0.0921, 0.641, 0.1192]}, {"w": "Data", "b": [0.6457, 0.0921, 0.6918, 0.1192]}]}, {"id": "b_4", "type": "paragraph", "text": "In a famous paper published in 2001, Microsoft researchers Michele Banko and Eric Brill showed that very different Machine Learning algorithms, including fairly simple ones, performed almost identically well on a complex problem of natural language disambiguation8 once they were given enough data (as you can see in Figure 1-20).", "words": [{"w": "In", "b": [0.1592, 0.1238, 0.1768, 0.1442]}, {"w": "a", "b": [0.1826, 0.1238, 0.1913, 0.1442]}, {"w": "famous", "b": [0.1971, 0.1238, 0.2559, 0.1442]}, {"w": "paper", "b": [0.2616, 0.1238, 0.3066, 0.1442]}, {"w": "published", "b": [0.3123, 0.1238, 0.3905, 0.1442]}, {"w": "in", "b": [0.3963, 0.1238, 0.4124, 0.1442]}, {"w": "2001,", "b": [0.4182, 0.1238, 0.4608, 0.1442]}, {"w": "Microsoft", "b": [0.4666, 0.1238, 0.5448, 0.1442]}, {"w": "researchers", "b": [0.5506, 0.1238, 0.6402, 0.1442]}, {"w": "Michele", "b": [0.646, 0.1238, 0.7099, 0.1442]}, {"w": "Banko", "b": [0.7156, 0.1238, 0.7668, 0.1442]}, {"w": "and", "b": [0.7726, 0.1238, 0.8026, 0.1442]}, {"w": "Eric", "b": [0.8084, 0.1238, 0.8408, 0.1442]}, {"w": "Brill", "b": [0.1592, 0.1419, 0.1936, 0.1623]}, {"w": "showed", "b": [0.1987, 0.1419, 0.2592, 0.1623]}, {"w": "that", "b": [0.2644, 0.1419, 0.2954, 0.1623]}, {"w": "very", "b": [0.3005, 0.1419, 0.3352, 0.1623]}, {"w": "different", "b": [0.3403, 0.1419, 0.4086, 0.1623]}, {"w": "Machine", "b": [0.4137, 0.1419, 0.4834, 0.1623]}, {"w": "Learning", "b": [0.4885, 0.1419, 0.56, 0.1623]}, {"w": "algorithms,", "b": [0.5651, 0.1419, 0.6556, 0.1623]}, {"w": "including", "b": [0.6607, 0.1419, 0.7368, 0.1623]}, {"w": "fairly", "b": [0.7419, 0.1419, 0.7833, 0.1623]}, {"w": "simple", "b": [0.7884, 0.1419, 0.8408, 0.1623]}, {"w": "ones,", "b": [0.1592, 0.1601, 0.2004, 0.1805]}, {"w": "performed", "b": [0.2076, 0.1601, 0.2923, 0.1805]}, {"w": "almost", "b": [0.2995, 0.1601, 0.353, 0.1805]}, {"w": "identically", "b": [0.3602, 0.1601, 0.4425, 0.1805]}, {"w": "well", "b": [0.4497, 0.1601, 0.4817, 0.1805]}, {"w": "on", "b": [0.4889, 0.1601, 0.5099, 0.1805]}, {"w": "a", "b": [0.5171, 0.1601, 0.5258, 0.1805]}, {"w": "complex", "b": [0.533, 0.1601, 0.6006, 0.1805]}, {"w": "problem", "b": [0.6078, 0.1601, 0.6755, 0.1805]}, {"w": "of", "b": [0.6827, 0.1601, 0.6987, 0.1805]}, {"w": "natural", "b": [0.7059, 0.1601, 0.7627, 0.1805]}, {"w": "language", "b": [0.7699, 0.1601, 0.8408, 0.1805]}, {"w": "disambiguation8", "b": [0.1592, 0.1782, 0.2889, 0.1986]}, {"w": "once", "b": [0.2934, 0.1782, 0.3312, 0.1986]}, {"w": "they", "b": [0.3357, 0.1782, 0.3699, 0.1986]}, {"w": "were", "b": [0.3744, 0.1782, 0.4122, 0.1986]}, {"w": "given", "b": [0.4167, 0.1782, 0.4598, 0.1986]}, {"w": "enough", "b": [0.4643, 0.1782, 0.5241, 0.1986]}, {"w": "data", "b": [0.5286, 0.1782, 0.5622, 0.1986]}, {"w": "(as", "b": [0.5667, 0.1782, 0.5895, 0.1986]}, {"w": "you", "b": [0.594, 0.1782, 0.6238, 0.1986]}, {"w": "can", "b": [0.6283, 0.1782, 0.6563, 0.1986]}, {"w": "see", "b": [0.6608, 0.1782, 0.6849, 0.1986]}, {"w": "in", "b": [0.6894, 0.1782, 0.7056, 0.1986]}, {"w": "Figure", "b": [0.7101, 0.1782, 0.7615, 0.1986]}, {"w": "1-20).", "b": [0.766, 0.1782, 0.813, 0.1986]}]}, {"id": "b_5", "type": "equation", "text": "Figure 1-20. The importance of data versus algorithms9", "words": [{"w": "Figure", "b": [0.1592, 0.525, 0.2082, 0.5456]}, {"w": "1-20.", "b": [0.2128, 0.525, 0.2524, 0.5456]}, {"w": "The", "b": [0.257, 0.525, 0.2854, 0.5456]}, {"w": "importance", "b": [0.29, 0.525, 0.3778, 0.5456]}, {"w": "of", "b": [0.3824, 0.525, 0.3969, 0.5456]}, {"w": "data", "b": [0.4014, 0.525, 0.4363, 0.5456]}, {"w": "versus", "b": [0.4409, 0.525, 0.4886, 0.5456]}, {"w": "algorithms9", "b": [0.4931, 0.525, 0.5811, 0.5456]}]}, {"id": "b_6", "type": "paragraph", "text": "As the authors put it: “these results suggest that we may want to reconsider the trade- off between spending time and money on algorithm development versus spending it on corpus development.”", "words": [{"w": "As", "b": [0.1592, 0.5615, 0.1802, 0.5819]}, {"w": "the", "b": [0.1852, 0.5615, 0.2103, 0.5819]}, {"w": "authors", "b": [0.2153, 0.5615, 0.2756, 0.5819]}, {"w": "put", "b": [0.2806, 0.5615, 0.3076, 0.5819]}, {"w": "it:", "b": [0.3126, 0.5615, 0.3285, 0.5819]}, {"w": "“these", "b": [0.3335, 0.5615, 0.3815, 0.5819]}, {"w": "results", "b": [0.3865, 0.5615, 0.4385, 0.5819]}, {"w": "suggest", "b": [0.4435, 0.5615, 0.5017, 0.5819]}, {"w": "that", "b": [0.5067, 0.5615, 0.5377, 0.5819]}, {"w": "we", "b": [0.5427, 0.5615, 0.5648, 0.5819]}, {"w": "may", "b": [0.5698, 0.5615, 0.6035, 0.5819]}, {"w": "want", "b": [0.6085, 0.5615, 0.6473, 0.5819]}, {"w": "to", "b": [0.6524, 0.5615, 0.6685, 0.5819]}, {"w": "reconsider", "b": [0.6735, 0.5615, 0.7576, 0.5819]}, {"w": "the", "b": [0.7626, 0.5615, 0.7877, 0.5819]}, {"w": "trade-", "b": [0.7927, 0.5615, 0.8408, 0.5819]}, {"w": "off", "b": [0.1592, 0.5796, 0.1811, 0.6]}, {"w": "between", "b": [0.1868, 0.5796, 0.2527, 0.6]}, {"w": "spending", "b": [0.2584, 0.5796, 0.3313, 0.6]}, {"w": "time", "b": [0.337, 0.5796, 0.373, 0.6]}, {"w": "and", "b": [0.3787, 0.5796, 0.4088, 0.6]}, {"w": "money", "b": [0.4145, 0.5796, 0.4692, 0.6]}, {"w": "on", "b": [0.475, 0.5796, 0.4959, 0.6]}, {"w": "algorithm", "b": [0.5016, 0.5796, 0.5803, 0.6]}, {"w": "development", "b": [0.586, 0.5796, 0.6893, 0.6]}, {"w": "versus", "b": [0.695, 0.5796, 0.7451, 0.6]}, {"w": "spending", "b": [0.7508, 0.5796, 0.8237, 0.6]}, {"w": "it", "b": [0.8294, 0.5796, 0.8408, 0.6]}, {"w": "on", "b": [0.1592, 0.5978, 0.1802, 0.6182]}, {"w": "corpus", "b": [0.1847, 0.5978, 0.2388, 0.6182]}, {"w": "development.”", "b": [0.2433, 0.5978, 0.3563, 0.6182]}]}, {"id": "b_7", "type": "paragraph", "text": "The idea that data matters more than algorithms for complex problems was further popularized by Peter Norvig et al. in a paper titled “The Unreasonable Effectiveness of Data” published in 2009.10 It should be noted, however, that small- and medium- sized datasets are still very common, and it is not always easy or cheap to get extra training data, so don’t abandon algorithms just yet.", "words": [{"w": "The", "b": [0.1592, 0.625, 0.1905, 0.6454]}, {"w": "idea", "b": [0.1969, 0.625, 0.2298, 0.6454]}, {"w": "that", "b": [0.2363, 0.625, 0.2673, 0.6454]}, {"w": "data", "b": [0.2737, 0.625, 0.3073, 0.6454]}, {"w": "matters", "b": [0.3137, 0.625, 0.3734, 0.6454]}, {"w": "more", "b": [0.3799, 0.625, 0.422, 0.6454]}, {"w": "than", "b": [0.4284, 0.625, 0.4646, 0.6454]}, {"w": "algorithms", "b": [0.471, 0.625, 0.557, 0.6454]}, {"w": "for", "b": [0.5635, 0.625, 0.5868, 0.6454]}, {"w": "complex", "b": [0.5932, 0.625, 0.6608, 0.6454]}, {"w": "problems", "b": [0.6672, 0.625, 0.7422, 0.6454]}, {"w": "was", "b": [0.7486, 0.625, 0.7782, 0.6454]}, {"w": "further", "b": [0.7846, 0.625, 0.8408, 0.6454]}, {"w": "popularized", "b": [0.1592, 0.6431, 0.2543, 0.6635]}, {"w": "by", "b": [0.2605, 0.6431, 0.2797, 0.6635]}, {"w": "Peter", "b": [0.2859, 0.6431, 0.3268, 0.6635]}, {"w": "Norvig", "b": [0.333, 0.6431, 0.3891, 0.6635]}, {"w": "et", "b": [0.3953, 0.6431, 0.4097, 0.6635]}, {"w": "al.", "b": [0.416, 0.6431, 0.4342, 0.6635]}, {"w": "in", "b": [0.4404, 0.6431, 0.4566, 0.6635]}, {"w": "a", "b": [0.4628, 0.6431, 0.4715, 0.6635]}, {"w": "paper", "b": [0.4777, 0.6431, 0.5226, 0.6635]}, {"w": "titled", "b": [0.5289, 0.6431, 0.5702, 0.6635]}, {"w": "“The", "b": [0.5764, 0.6431, 0.6161, 0.6635]}, {"w": "Unreasonable", "b": [0.6223, 0.6431, 0.7319, 0.6635]}, {"w": "Effectiveness", "b": [0.7381, 0.6431, 0.8408, 0.6635]}, {"w": "of", "b": [0.1592, 0.6613, 0.1752, 0.6817]}, {"w": "Data”", "b": [0.1816, 0.6613, 0.2256, 0.6817]}, {"w": "published", "b": [0.232, 0.6613, 0.3101, 0.6817]}, {"w": "in", "b": [0.3164, 0.6613, 0.3326, 0.6817]}, {"w": "2009.10", "b": [0.3389, 0.6613, 0.393, 0.6817]}, {"w": "It", "b": [0.3993, 0.6613, 0.4114, 0.6817]}, {"w": "should", "b": [0.4177, 0.6613, 0.4717, 0.6817]}, {"w": "be", "b": [0.4781, 0.6613, 0.4966, 0.6817]}, {"w": "noted,", "b": [0.5029, 0.6613, 0.5534, 0.6817]}, {"w": "however,", "b": [0.5597, 0.6613, 0.6307, 0.6817]}, {"w": "that", "b": [0.637, 0.6613, 0.6681, 0.6817]}, {"w": "small-", "b": [0.6744, 0.6613, 0.7237, 0.6817]}, {"w": "and", "b": [0.7301, 0.6613, 0.7601, 0.6817]}, {"w": "medium-", "b": [0.7664, 0.6613, 0.8408, 0.6817]}, {"w": "sized", "b": [0.1592, 0.6794, 0.1991, 0.6998]}, {"w": "datasets", "b": [0.2056, 0.6794, 0.2682, 0.6998]}, {"w": "are", "b": [0.2748, 0.6794, 0.2993, 0.6998]}, {"w": "still", "b": [0.3058, 0.6794, 0.3345, 0.6998]}, {"w": "very", "b": [0.341, 0.6794, 0.3757, 0.6998]}, {"w": "common,", "b": [0.3822, 0.6794, 0.4587, 0.6998]}, {"w": "and", "b": [0.4653, 0.6794, 0.4953, 0.6998]}, {"w": "it", "b": [0.5018, 0.6794, 0.5132, 0.6998]}, {"w": "is", "b": [0.5198, 0.6794, 0.5324, 0.6998]}, {"w": "not", "b": [0.5389, 0.6794, 0.5659, 0.6998]}, {"w": "always", "b": [0.5725, 0.6794, 0.6245, 0.6998]}, {"w": "easy", "b": [0.6311, 0.6794, 0.6646, 0.6998]}, {"w": "or", "b": [0.6711, 0.6794, 0.6886, 0.6998]}, {"w": "cheap", "b": [0.6951, 0.6794, 0.7413, 0.6998]}, {"w": "to", "b": [0.7478, 0.6794, 0.764, 0.6998]}, {"w": "get", "b": [0.7705, 0.6794, 0.7943, 0.6998]}, {"w": "extra", "b": [0.8008, 0.6794, 0.8408, 0.6998]}, {"w": "training", "b": [0.1592, 0.6976, 0.223, 0.718]}, {"w": "data,", "b": [0.2275, 0.6976, 0.2656, 0.718]}, {"w": "so", "b": [0.2701, 0.6976, 0.2875, 0.718]}, {"w": "don’t", "b": [0.292, 0.6976, 0.3316, 0.718]}, {"w": "abandon", "b": [0.3361, 0.6976, 0.4059, 0.718]}, {"w": "algorithms", "b": [0.4104, 0.6976, 0.4964, 0.718]}, {"w": "just", "b": [0.5009, 0.6976, 0.5299, 0.718]}, {"w": "yet.", "b": [0.5344, 0.6976, 0.5625, 0.718]}]}, {"id": "b_8", "type": "paragraph", "text": "Main Challenges of Machine Learning | 25", "words": [{"w": "Main", "b": [0.584, 0.9225, 0.6136, 0.9388]}, {"w": "Challenges", "b": [0.6164, 0.9225, 0.6805, 0.9388]}, {"w": "of", "b": [0.6833, 0.9225, 0.6953, 0.9388]}, {"w": "Machine", "b": [0.6981, 0.9225, 0.748, 0.9388]}, {"w": "Learning", "b": [0.7509, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "25", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 52, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Nonrepresentative Training Data", "words": [{"w": "Nonrepresentative", "b": [0.1429, 0.0763, 0.336, 0.1049]}, {"w": "Training", "b": [0.341, 0.0763, 0.4269, 0.1049]}, {"w": "Data", "b": [0.4319, 0.0763, 0.4803, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "In order to generalize well, it is crucial that your training data be representative of the new cases you want to generalize to. This is true whether you use instance-based learning or model-based learning.", "words": [{"w": "In", "b": [0.1429, 0.1108, 0.1614, 0.1322]}, {"w": "order", "b": [0.1664, 0.1108, 0.2123, 0.1322]}, {"w": "to", "b": [0.2173, 0.1108, 0.2343, 0.1322]}, {"w": "generalize", "b": [0.2393, 0.1108, 0.3235, 0.1322]}, {"w": "well,", "b": [0.3285, 0.1108, 0.3669, 0.1322]}, {"w": "it", "b": [0.372, 0.1108, 0.3839, 0.1322]}, {"w": "is", "b": [0.3889, 0.1108, 0.4021, 0.1322]}, {"w": "crucial", "b": [0.4072, 0.1108, 0.4636, 0.1322]}, {"w": "that", "b": [0.4686, 0.1108, 0.5012, 0.1322]}, {"w": "your", "b": [0.5062, 0.1108, 0.5452, 0.1322]}, {"w": "training", "b": [0.5502, 0.1108, 0.6171, 0.1322]}, {"w": "data", "b": [0.6221, 0.1108, 0.6574, 0.1322]}, {"w": "be", "b": [0.6624, 0.1108, 0.6818, 0.1322]}, {"w": "representative", "b": [0.6869, 0.1108, 0.804, 0.1322]}, {"w": "of", "b": [0.809, 0.1108, 0.8258, 0.1322]}, {"w": "the", "b": [0.8308, 0.1108, 0.8571, 0.1322]}, {"w": "new", "b": [0.1429, 0.1298, 0.1774, 0.1512]}, {"w": "cases", "b": [0.1857, 0.1298, 0.2278, 0.1512]}, {"w": "you", "b": [0.2361, 0.1298, 0.2673, 0.1512]}, {"w": "want", "b": [0.2756, 0.1298, 0.3164, 0.1512]}, {"w": "to", "b": [0.3247, 0.1298, 0.3417, 0.1512]}, {"w": "generalize", "b": [0.35, 0.1298, 0.4342, 0.1512]}, {"w": "to.", "b": [0.4425, 0.1298, 0.4636, 0.1512]}, {"w": "This", "b": [0.4719, 0.1298, 0.5091, 0.1512]}, {"w": "is", "b": [0.5174, 0.1298, 0.5307, 0.1512]}, {"w": "true", "b": [0.539, 0.1298, 0.573, 0.1512]}, {"w": "whether", "b": [0.5813, 0.1298, 0.6496, 0.1512]}, {"w": "you", "b": [0.6579, 0.1298, 0.6891, 0.1512]}, {"w": "use", "b": [0.6974, 0.1298, 0.725, 0.1512]}, {"w": "instance-based", "b": [0.7333, 0.1298, 0.8571, 0.1512]}, {"w": "learning", "b": [0.1429, 0.1489, 0.212, 0.1703]}, {"w": "or", "b": [0.2167, 0.1489, 0.2351, 0.1703]}, {"w": "model-based", "b": [0.2398, 0.1489, 0.3472, 0.1703]}, {"w": "learning.", "b": [0.352, 0.1489, 0.4259, 0.1703]}]}, {"id": "b_2", "type": "paragraph", "text": "For example, the set of countries we used earlier for training the linear model was not perfectly representative; a few countries were missing. Figure 1-21 shows what the data looks like when you add the missing countries.", "words": [{"w": "For", "b": [0.1429, 0.177, 0.1718, 0.1984]}, {"w": "example,", "b": [0.1768, 0.177, 0.2511, 0.1984]}, {"w": "the", "b": [0.2561, 0.177, 0.2824, 0.1984]}, {"w": "set", "b": [0.2874, 0.177, 0.3102, 0.1984]}, {"w": "of", "b": [0.3152, 0.177, 0.332, 0.1984]}, {"w": "countries", "b": [0.3369, 0.177, 0.4146, 0.1984]}, {"w": "we", "b": [0.4196, 0.177, 0.4427, 0.1984]}, {"w": "used", "b": [0.4477, 0.177, 0.4862, 0.1984]}, {"w": "earlier", "b": [0.4912, 0.177, 0.5444, 0.1984]}, {"w": "for", "b": [0.5493, 0.177, 0.5738, 0.1984]}, {"w": "training", "b": [0.5788, 0.177, 0.6457, 0.1984]}, {"w": "the", "b": [0.6507, 0.177, 0.677, 0.1984]}, {"w": "linear", "b": [0.682, 0.177, 0.73, 0.1984]}, {"w": "model", "b": [0.735, 0.177, 0.7878, 0.1984]}, {"w": "was", "b": [0.7927, 0.177, 0.8238, 0.1984]}, {"w": "not", "b": [0.8288, 0.177, 0.8571, 0.1984]}, {"w": "perfectly", "b": [0.1429, 0.196, 0.2154, 0.2175]}, {"w": "representative;", "b": [0.2231, 0.196, 0.345, 0.2175]}, {"w": "a", "b": [0.3527, 0.196, 0.3619, 0.2175]}, {"w": "few", "b": [0.3696, 0.196, 0.3989, 0.2175]}, {"w": "countries", "b": [0.4066, 0.196, 0.4843, 0.2175]}, {"w": "were", "b": [0.492, 0.196, 0.5318, 0.2175]}, {"w": "missing.", "b": [0.5395, 0.196, 0.6089, 0.2175]}, {"w": "Figure", "b": [0.6166, 0.196, 0.6706, 0.2175]}, {"w": "1-21", "b": [0.6784, 0.196, 0.7158, 0.2175]}, {"w": "shows", "b": [0.7235, 0.196, 0.7748, 0.2175]}, {"w": "what", "b": [0.7826, 0.196, 0.8231, 0.2175]}, {"w": "the", "b": [0.8308, 0.196, 0.8572, 0.2175]}, {"w": "data", "b": [0.1429, 0.2151, 0.1781, 0.2365]}, {"w": "looks", "b": [0.1828, 0.2151, 0.2273, 0.2365]}, {"w": "like", "b": [0.2321, 0.2151, 0.2621, 0.2365]}, {"w": "when", "b": [0.2668, 0.2151, 0.3125, 0.2365]}, {"w": "you", "b": [0.3172, 0.2151, 0.3485, 0.2365]}, {"w": "add", "b": [0.3532, 0.2151, 0.3843, 0.2365]}, {"w": "the", "b": [0.3891, 0.2151, 0.4154, 0.2365]}, {"w": "missing", "b": [0.4201, 0.2151, 0.4848, 0.2365]}, {"w": "countries.", "b": [0.4895, 0.2151, 0.5719, 0.2365]}]}, {"id": "b_3", "type": "equation", "text": "Figure 1-21. A more representative training sample", "words": [{"w": "Figure", "b": [0.1429, 0.4475, 0.1943, 0.4691]}, {"w": "1-21.", "b": [0.1991, 0.4475, 0.2407, 0.4691]}, {"w": "A", "b": [0.2455, 0.4475, 0.2593, 0.4691]}, {"w": "more", "b": [0.2641, 0.4475, 0.3055, 0.4691]}, {"w": "representative", "b": [0.3103, 0.4475, 0.4222, 0.4691]}, {"w": "training", "b": [0.427, 0.4475, 0.4914, 0.4691]}, {"w": "sample", "b": [0.4962, 0.4475, 0.5525, 0.4691]}]}, {"id": "b_4", "type": "paragraph", "text": "If you train a linear model on this data, you get the solid line, while the old model is represented by the dotted line. As you can see, not only does adding a few missing countries significantly alter the model, but it makes it clear that such a simple linear model is probably never going to work well. It seems that very rich countries are not happier than moderately rich countries (in fact they seem unhappier), and conversely some poor countries seem happier than many rich countries.", "words": [{"w": "If", "b": [0.1429, 0.4849, 0.1561, 0.5063]}, {"w": "you", "b": [0.1619, 0.4849, 0.1932, 0.5063]}, {"w": "train", "b": [0.1989, 0.4849, 0.2391, 0.5063]}, {"w": "a", "b": [0.2449, 0.4849, 0.2541, 0.5063]}, {"w": "linear", "b": [0.2598, 0.4849, 0.3078, 0.5063]}, {"w": "model", "b": [0.3136, 0.4849, 0.3664, 0.5063]}, {"w": "on", "b": [0.3722, 0.4849, 0.3942, 0.5063]}, {"w": "this", "b": [0.4, 0.4849, 0.4307, 0.5063]}, {"w": "data,", "b": [0.4365, 0.4849, 0.4765, 0.5063]}, {"w": "you", "b": [0.4823, 0.4849, 0.5135, 0.5063]}, {"w": "get", "b": [0.5193, 0.4849, 0.5442, 0.5063]}, {"w": "the", "b": [0.55, 0.4849, 0.5763, 0.5063]}, {"w": "solid", "b": [0.5821, 0.4849, 0.6223, 0.5063]}, {"w": "line,", "b": [0.628, 0.4849, 0.6639, 0.5063]}, {"w": "while", "b": [0.6697, 0.4849, 0.7148, 0.5063]}, {"w": "the", "b": [0.7205, 0.4849, 0.7469, 0.5063]}, {"w": "old", "b": [0.7527, 0.4849, 0.7795, 0.5063]}, {"w": "model", "b": [0.7853, 0.4849, 0.8381, 0.5063]}, {"w": "is", "b": [0.8439, 0.4849, 0.8571, 0.5063]}, {"w": "represented", "b": [0.1429, 0.504, 0.2406, 0.5254]}, {"w": "by", "b": [0.2475, 0.504, 0.2677, 0.5254]}, {"w": "the", "b": [0.2745, 0.504, 0.3008, 0.5254]}, {"w": "dotted", "b": [0.3077, 0.504, 0.3619, 0.5254]}, {"w": "line.", "b": [0.3687, 0.504, 0.4046, 0.5254]}, {"w": "As", "b": [0.4115, 0.504, 0.4335, 0.5254]}, {"w": "you", "b": [0.4404, 0.504, 0.4716, 0.5254]}, {"w": "can", "b": [0.4785, 0.504, 0.5078, 0.5254]}, {"w": "see,", "b": [0.5147, 0.504, 0.5448, 0.5254]}, {"w": "not", "b": [0.5517, 0.504, 0.58, 0.5254]}, {"w": "only", "b": [0.5869, 0.504, 0.6237, 0.5254]}, {"w": "does", "b": [0.6306, 0.504, 0.6687, 0.5254]}, {"w": "adding", "b": [0.6756, 0.504, 0.7335, 0.5254]}, {"w": "a", "b": [0.7403, 0.504, 0.7495, 0.5254]}, {"w": "few", "b": [0.7563, 0.504, 0.7856, 0.5254]}, {"w": "missing", "b": [0.7925, 0.504, 0.8571, 0.5254]}, {"w": "countries", "b": [0.1428, 0.523, 0.2205, 0.5444]}, {"w": "significantly", "b": [0.2266, 0.523, 0.3285, 0.5444]}, {"w": "alter", "b": [0.3346, 0.523, 0.3719, 0.5444]}, {"w": "the", "b": [0.378, 0.523, 0.4044, 0.5444]}, {"w": "model,", "b": [0.4105, 0.523, 0.468, 0.5444]}, {"w": "but", "b": [0.4742, 0.523, 0.5022, 0.5444]}, {"w": "it", "b": [0.5083, 0.523, 0.5202, 0.5444]}, {"w": "makes", "b": [0.5263, 0.523, 0.5793, 0.5444]}, {"w": "it", "b": [0.5855, 0.523, 0.5974, 0.5444]}, {"w": "clear", "b": [0.6035, 0.523, 0.6433, 0.5444]}, {"w": "that", "b": [0.6494, 0.523, 0.682, 0.5444]}, {"w": "such", "b": [0.6881, 0.523, 0.7268, 0.5444]}, {"w": "a", "b": [0.7329, 0.523, 0.742, 0.5444]}, {"w": "simple", "b": [0.7481, 0.523, 0.803, 0.5444]}, {"w": "linear", "b": [0.8092, 0.523, 0.8571, 0.5444]}, {"w": "model", "b": [0.1429, 0.5421, 0.1957, 0.5635]}, {"w": "is", "b": [0.2014, 0.5421, 0.2146, 0.5635]}, {"w": "probably", "b": [0.2203, 0.5421, 0.2947, 0.5635]}, {"w": "never", "b": [0.3004, 0.5421, 0.3468, 0.5635]}, {"w": "going", "b": [0.3525, 0.5421, 0.3996, 0.5635]}, {"w": "to", "b": [0.4053, 0.5421, 0.4223, 0.5635]}, {"w": "work", "b": [0.428, 0.5421, 0.4709, 0.5635]}, {"w": "well.", "b": [0.4766, 0.5421, 0.515, 0.5635]}, {"w": "It", "b": [0.5207, 0.5421, 0.5333, 0.5635]}, {"w": "seems", "b": [0.539, 0.5421, 0.5891, 0.5635]}, {"w": "that", "b": [0.5948, 0.5421, 0.6273, 0.5635]}, {"w": "very", "b": [0.633, 0.5421, 0.6694, 0.5635]}, {"w": "rich", "b": [0.6751, 0.5421, 0.7083, 0.5635]}, {"w": "countries", "b": [0.714, 0.5421, 0.7917, 0.5635]}, {"w": "are", "b": [0.7974, 0.5421, 0.8231, 0.5635]}, {"w": "not", "b": [0.8288, 0.5421, 0.8571, 0.5635]}, {"w": "happier", "b": [0.1429, 0.5611, 0.2067, 0.5825]}, {"w": "than", "b": [0.2119, 0.5611, 0.2499, 0.5825]}, {"w": "moderately", "b": [0.2551, 0.5611, 0.3491, 0.5825]}, {"w": "rich", "b": [0.3543, 0.5611, 0.3875, 0.5825]}, {"w": "countries", "b": [0.3927, 0.5611, 0.4703, 0.5825]}, {"w": "(in", "b": [0.4755, 0.5611, 0.4997, 0.5825]}, {"w": "fact", "b": [0.5048, 0.5611, 0.5353, 0.5825]}, {"w": "they", "b": [0.5405, 0.5611, 0.5764, 0.5825]}, {"w": "seem", "b": [0.5815, 0.5611, 0.6239, 0.5825]}, {"w": "unhappier),", "b": [0.6291, 0.5611, 0.7274, 0.5825]}, {"w": "and", "b": [0.7325, 0.5611, 0.7641, 0.5825]}, {"w": "conversely", "b": [0.7692, 0.5611, 0.8571, 0.5825]}, {"w": "some", "b": [0.1429, 0.5802, 0.187, 0.6016]}, {"w": "poor", "b": [0.1918, 0.5802, 0.2317, 0.6016]}, {"w": "countries", "b": [0.2364, 0.5802, 0.3141, 0.6016]}, {"w": "seem", "b": [0.3188, 0.5802, 0.3612, 0.6016]}, {"w": "happier", "b": [0.3659, 0.5802, 0.4298, 0.6016]}, {"w": "than", "b": [0.4345, 0.5802, 0.4726, 0.6016]}, {"w": "many", "b": [0.4773, 0.5802, 0.524, 0.6016]}, {"w": "rich", "b": [0.5287, 0.5802, 0.562, 0.6016]}, {"w": "countries.", "b": [0.5667, 0.5802, 0.6491, 0.6016]}]}, {"id": "b_5", "type": "paragraph", "text": "By using a nonrepresentative training set, we trained a model that is unlikely to make accurate predictions, especially for very poor and very rich countries.", "words": [{"w": "By", "b": [0.1429, 0.6083, 0.1647, 0.6297]}, {"w": "using", "b": [0.1698, 0.6083, 0.2153, 0.6297]}, {"w": "a", "b": [0.2204, 0.6083, 0.2296, 0.6297]}, {"w": "nonrepresentative", "b": [0.2347, 0.6083, 0.3852, 0.6297]}, {"w": "training", "b": [0.3904, 0.6083, 0.4573, 0.6297]}, {"w": "set,", "b": [0.4625, 0.6083, 0.4901, 0.6297]}, {"w": "we", "b": [0.4952, 0.6083, 0.5184, 0.6297]}, {"w": "trained", "b": [0.5235, 0.6083, 0.5836, 0.6297]}, {"w": "a", "b": [0.5887, 0.6083, 0.5979, 0.6297]}, {"w": "model", "b": [0.603, 0.6083, 0.6559, 0.6297]}, {"w": "that", "b": [0.661, 0.6083, 0.6936, 0.6297]}, {"w": "is", "b": [0.6987, 0.6083, 0.712, 0.6297]}, {"w": "unlikely", "b": [0.7171, 0.6083, 0.7845, 0.6297]}, {"w": "to", "b": [0.7896, 0.6083, 0.8066, 0.6297]}, {"w": "make", "b": [0.8117, 0.6083, 0.8571, 0.6297]}, {"w": "accurate", "b": [0.1429, 0.6273, 0.2124, 0.6487]}, {"w": "predictions,", "b": [0.2171, 0.6273, 0.3164, 0.6487]}, {"w": "especially", "b": [0.3211, 0.6273, 0.401, 0.6487]}, {"w": "for", "b": [0.4057, 0.6273, 0.4303, 0.6487]}, {"w": "very", "b": [0.435, 0.6273, 0.4714, 0.6487]}, {"w": "poor", "b": [0.4761, 0.6273, 0.516, 0.6487]}, {"w": "and", "b": [0.5207, 0.6273, 0.5523, 0.6487]}, {"w": "very", "b": [0.557, 0.6273, 0.5934, 0.6487]}, {"w": "rich", "b": [0.5981, 0.6273, 0.6314, 0.6487]}, {"w": "countries.", "b": [0.6361, 0.6273, 0.7185, 0.6487]}]}, {"id": "b_6", "type": "paragraph", "text": "It is crucial to use a training set that is representative of the cases you want to general‐ ize to. This is often harder than it sounds: if the sample is too small, you will have sampling noise (i.e., nonrepresentative data as a result of chance), but even very large samples can be nonrepresentative if the sampling method is flawed. This is called sampling bias.", "words": [{"w": "It", "b": [0.1429, 0.6554, 0.1555, 0.6769]}, {"w": "is", "b": [0.1604, 0.6554, 0.1736, 0.6769]}, {"w": "crucial", "b": [0.1785, 0.6554, 0.2349, 0.6769]}, {"w": "to", "b": [0.2398, 0.6554, 0.2568, 0.6769]}, {"w": "use", "b": [0.2617, 0.6554, 0.2892, 0.6769]}, {"w": "a", "b": [0.2941, 0.6554, 0.3032, 0.6769]}, {"w": "training", "b": [0.3081, 0.6554, 0.3751, 0.6769]}, {"w": "set", "b": [0.3799, 0.6554, 0.4028, 0.6769]}, {"w": "that", "b": [0.4077, 0.6554, 0.4402, 0.6769]}, {"w": "is", "b": [0.4451, 0.6554, 0.4584, 0.6769]}, {"w": "representative", "b": [0.4632, 0.6554, 0.5804, 0.6769]}, {"w": "of", "b": [0.5852, 0.6554, 0.602, 0.6769]}, {"w": "the", "b": [0.6069, 0.6554, 0.6332, 0.6769]}, {"w": "cases", "b": [0.6381, 0.6554, 0.6802, 0.6769]}, {"w": "you", "b": [0.6851, 0.6554, 0.7163, 0.6769]}, {"w": "want", "b": [0.7212, 0.6554, 0.762, 0.6769]}, {"w": "to", "b": [0.7669, 0.6554, 0.7839, 0.6769]}, {"w": "general‐", "b": [0.7887, 0.6554, 0.8572, 0.6769]}, {"w": "ize", "b": [0.1429, 0.6745, 0.166, 0.6959]}, {"w": "to.", "b": [0.1731, 0.6745, 0.1942, 0.6959]}, {"w": "This", "b": [0.2013, 0.6745, 0.2385, 0.6959]}, {"w": "is", "b": [0.2455, 0.6745, 0.2588, 0.6959]}, {"w": "often", "b": [0.2658, 0.6745, 0.3092, 0.6959]}, {"w": "harder", "b": [0.3163, 0.6745, 0.3718, 0.6959]}, {"w": "than", "b": [0.3789, 0.6745, 0.4169, 0.6959]}, {"w": "it", "b": [0.424, 0.6745, 0.4359, 0.6959]}, {"w": "sounds:", "b": [0.443, 0.6745, 0.5071, 0.6959]}, {"w": "if", "b": [0.5141, 0.6745, 0.5259, 0.6959]}, {"w": "the", "b": [0.5329, 0.6745, 0.5593, 0.6959]}, {"w": "sample", "b": [0.5663, 0.6745, 0.6248, 0.6959]}, {"w": "is", "b": [0.6319, 0.6745, 0.6451, 0.6959]}, {"w": "too", "b": [0.6521, 0.6745, 0.6798, 0.6959]}, {"w": "small,", "b": [0.6868, 0.6745, 0.736, 0.6959]}, {"w": "you", "b": [0.743, 0.6745, 0.7743, 0.6959]}, {"w": "will", "b": [0.7813, 0.6745, 0.8117, 0.6959]}, {"w": "have", "b": [0.8188, 0.6745, 0.8571, 0.6959]}, {"w": "sampling", "b": [0.1429, 0.6933, 0.2157, 0.7149]}, {"w": "noise", "b": [0.2215, 0.6933, 0.2632, 0.7149]}, {"w": "(i.e.,", "b": [0.2689, 0.6935, 0.3048, 0.7149]}, {"w": "nonrepresentative", "b": [0.3105, 0.6935, 0.461, 0.7149]}, {"w": "data", "b": [0.4668, 0.6935, 0.502, 0.7149]}, {"w": "as", "b": [0.5077, 0.6935, 0.5245, 0.7149]}, {"w": "a", "b": [0.5302, 0.6935, 0.5394, 0.7149]}, {"w": "result", "b": [0.5451, 0.6935, 0.592, 0.7149]}, {"w": "of", "b": [0.5977, 0.6935, 0.6145, 0.7149]}, {"w": "chance),", "b": [0.6203, 0.6935, 0.6904, 0.7149]}, {"w": "but", "b": [0.6961, 0.6935, 0.7241, 0.7149]}, {"w": "even", "b": [0.7298, 0.6935, 0.7686, 0.7149]}, {"w": "very", "b": [0.7743, 0.6935, 0.8107, 0.7149]}, {"w": "large", "b": [0.8164, 0.6935, 0.8571, 0.7149]}, {"w": "samples", "b": [0.1429, 0.7126, 0.209, 0.734]}, {"w": "can", "b": [0.2172, 0.7126, 0.2465, 0.734]}, {"w": "be", "b": [0.2547, 0.7126, 0.2742, 0.734]}, {"w": "nonrepresentative", "b": [0.2823, 0.7126, 0.4329, 0.734]}, {"w": "if", "b": [0.4411, 0.7126, 0.4528, 0.734]}, {"w": "the", "b": [0.461, 0.7126, 0.4873, 0.734]}, {"w": "sampling", "b": [0.4955, 0.7126, 0.5719, 0.734]}, {"w": "method", "b": [0.5801, 0.7126, 0.6451, 0.734]}, {"w": "is", "b": [0.6533, 0.7126, 0.6665, 0.734]}, {"w": "flawed.", "b": [0.6747, 0.7126, 0.7338, 0.734]}, {"w": "This", "b": [0.742, 0.7126, 0.7792, 0.734]}, {"w": "is", "b": [0.7874, 0.7126, 0.8006, 0.734]}, {"w": "called", "b": [0.8088, 0.7126, 0.8571, 0.734]}, {"w": "sampling", "b": [0.1429, 0.7314, 0.2157, 0.753]}, {"w": "bias.", "b": [0.2205, 0.7314, 0.258, 0.753]}]}, {"id": "b_7", "type": "paragraph", "text": "A Famous Example of Sampling Bias", "words": [{"w": "A", "b": [0.3246, 0.7788, 0.3379, 0.806]}, {"w": "Famous", "b": [0.3426, 0.7788, 0.419, 0.806]}, {"w": "Example", "b": [0.4237, 0.7788, 0.5078, 0.806]}, {"w": "of", "b": [0.5125, 0.7788, 0.5324, 0.806]}, {"w": "Sampling", "b": [0.5371, 0.7788, 0.6302, 0.806]}, {"w": "Bias", "b": [0.6349, 0.7788, 0.6754, 0.806]}]}, {"id": "b_8", "type": "paragraph", "text": "Perhaps the most famous example of sampling bias happened during the US presi‐ dential election in 1936, which pitted Landon against Roosevelt: the Literary Digest conducted a very large poll, sending mail to about 10 million people. It got 2.4 million answers, and predicted with high confidence that Landon would get 57% of the votes.", "words": [{"w": "Perhaps", "b": [0.1592, 0.8105, 0.2222, 0.8309]}, {"w": "the", "b": [0.229, 0.8105, 0.2541, 0.8309]}, {"w": "most", "b": [0.2609, 0.8105, 0.3006, 0.8309]}, {"w": "famous", "b": [0.3074, 0.8105, 0.3662, 0.8309]}, {"w": "example", "b": [0.373, 0.8105, 0.4393, 0.8309]}, {"w": "of", "b": [0.4461, 0.8105, 0.4621, 0.8309]}, {"w": "sampling", "b": [0.4689, 0.8105, 0.5417, 0.8309]}, {"w": "bias", "b": [0.5485, 0.8105, 0.5799, 0.8309]}, {"w": "happened", "b": [0.5867, 0.8105, 0.6647, 0.8309]}, {"w": "during", "b": [0.6715, 0.8105, 0.7253, 0.8309]}, {"w": "the", "b": [0.7322, 0.8105, 0.7572, 0.8309]}, {"w": "US", "b": [0.7641, 0.8105, 0.7881, 0.8309]}, {"w": "presi‐", "b": [0.7949, 0.8105, 0.8408, 0.8309]}, {"w": "dential", "b": [0.1592, 0.8287, 0.2137, 0.849]}, {"w": "election", "b": [0.2206, 0.8287, 0.2832, 0.849]}, {"w": "in", "b": [0.2902, 0.8287, 0.3063, 0.849]}, {"w": "1936,", "b": [0.3132, 0.8287, 0.3559, 0.849]}, {"w": "which", "b": [0.3628, 0.8287, 0.4113, 0.849]}, {"w": "pitted", "b": [0.4182, 0.8287, 0.4649, 0.849]}, {"w": "Landon", "b": [0.4718, 0.8287, 0.5335, 0.849]}, {"w": "against", "b": [0.5404, 0.8287, 0.5966, 0.849]}, {"w": "Roosevelt:", "b": [0.6036, 0.8287, 0.6851, 0.849]}, {"w": "the", "b": [0.692, 0.8287, 0.7171, 0.849]}, {"w": "Literary", "b": [0.724, 0.8285, 0.7858, 0.849]}, {"w": "Digest", "b": [0.7927, 0.8285, 0.8408, 0.849]}, {"w": "conducted", "b": [0.1592, 0.8468, 0.2429, 0.8672]}, {"w": "a", "b": [0.2475, 0.8468, 0.2562, 0.8672]}, {"w": "very", "b": [0.2607, 0.8468, 0.2953, 0.8672]}, {"w": "large", "b": [0.2998, 0.8468, 0.3386, 0.8672]}, {"w": "poll,", "b": [0.3431, 0.8468, 0.3782, 0.8672]}, {"w": "sending", "b": [0.3827, 0.8468, 0.4452, 0.8672]}, {"w": "mail", "b": [0.4497, 0.8468, 0.485, 0.8672]}, {"w": "to", "b": [0.4895, 0.8468, 0.5057, 0.8672]}, {"w": "about", "b": [0.5102, 0.8468, 0.5557, 0.8672]}, {"w": "10", "b": [0.5602, 0.8468, 0.5793, 0.8672]}, {"w": "million", "b": [0.5838, 0.8468, 0.6417, 0.8672]}, {"w": "people.", "b": [0.6462, 0.8468, 0.7035, 0.8672]}, {"w": "It", "b": [0.708, 0.8468, 0.72, 0.8672]}, {"w": "got", "b": [0.7245, 0.8468, 0.75, 0.8672]}, {"w": "2.4", "b": [0.7545, 0.8468, 0.7781, 0.8672]}, {"w": "million", "b": [0.7826, 0.8468, 0.8405, 0.8672]}, {"w": "answers,", "b": [0.1592, 0.8649, 0.2273, 0.8853]}, {"w": "and", "b": [0.2321, 0.8649, 0.2621, 0.8853]}, {"w": "predicted", "b": [0.2669, 0.8649, 0.3423, 0.8853]}, {"w": "with", "b": [0.3471, 0.8649, 0.3827, 0.8853]}, {"w": "high", "b": [0.3875, 0.8649, 0.4233, 0.8853]}, {"w": "confidence", "b": [0.4281, 0.8649, 0.5152, 0.8853]}, {"w": "that", "b": [0.5201, 0.8649, 0.5511, 0.8853]}, {"w": "Landon", "b": [0.5559, 0.8649, 0.6176, 0.8853]}, {"w": "would", "b": [0.6224, 0.8649, 0.6722, 0.8853]}, {"w": "get", "b": [0.677, 0.8649, 0.7008, 0.8853]}, {"w": "57%", "b": [0.7056, 0.8649, 0.7396, 0.8853]}, {"w": "of", "b": [0.7445, 0.8649, 0.7604, 0.8853]}, {"w": "the", "b": [0.7653, 0.8649, 0.7903, 0.8853]}, {"w": "votes.", "b": [0.7952, 0.8649, 0.8408, 0.8853]}]}, {"id": "b_9", "type": "paragraph", "text": "26 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "26", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.3371, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 53, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Instead, Roosevelt won with 62% of the votes. The flaw was in the Literary Digest’s sampling method:", "words": [{"w": "Instead,", "b": [0.1592, 0.0792, 0.2223, 0.0996]}, {"w": "Roosevelt", "b": [0.2292, 0.0792, 0.3061, 0.0996]}, {"w": "won", "b": [0.313, 0.0792, 0.3476, 0.0996]}, {"w": "with", "b": [0.3544, 0.0792, 0.39, 0.0996]}, {"w": "62%", "b": [0.3968, 0.0792, 0.4309, 0.0996]}, {"w": "of", "b": [0.4377, 0.0792, 0.4537, 0.0996]}, {"w": "the", "b": [0.4606, 0.0792, 0.4857, 0.0996]}, {"w": "votes.", "b": [0.4925, 0.0792, 0.5381, 0.0996]}, {"w": "The", "b": [0.545, 0.0792, 0.5763, 0.0996]}, {"w": "flaw", "b": [0.5831, 0.0792, 0.6159, 0.0996]}, {"w": "was", "b": [0.6228, 0.0792, 0.6524, 0.0996]}, {"w": "in", "b": [0.6592, 0.0792, 0.6754, 0.0996]}, {"w": "the", "b": [0.6823, 0.0792, 0.7074, 0.0996]}, {"w": "Literary", "b": [0.7142, 0.079, 0.776, 0.0996]}, {"w": "Digest’s", "b": [0.7829, 0.079, 0.8408, 0.0996]}, {"w": "sampling", "b": [0.1592, 0.0973, 0.232, 0.1177]}, {"w": "method:", "b": [0.2365, 0.0973, 0.3029, 0.1177]}]}, {"id": "b_1", "type": "paragraph", "text": "• First, to obtain the addresses to send the polls to, the Literary Digest used tele‐ phone directories, lists of magazine subscribers, club membership lists, and the like. All of these lists tend to favor wealthier people, who are more likely to vote Republican (hence Landon).", "words": [{"w": "•", "b": [0.1773, 0.1306, 0.185, 0.151]}, {"w": "First,", "b": [0.1949, 0.1306, 0.236, 0.151]}, {"w": "to", "b": [0.2427, 0.1306, 0.2588, 0.151]}, {"w": "obtain", "b": [0.2655, 0.1306, 0.3167, 0.151]}, {"w": "the", "b": [0.3234, 0.1306, 0.3484, 0.151]}, {"w": "addresses", "b": [0.3551, 0.1306, 0.4309, 0.151]}, {"w": "to", "b": [0.4376, 0.1306, 0.4537, 0.151]}, {"w": "send", "b": [0.4604, 0.1306, 0.4975, 0.151]}, {"w": "the", "b": [0.5042, 0.1306, 0.5293, 0.151]}, {"w": "polls", "b": [0.536, 0.1306, 0.5738, 0.151]}, {"w": "to,", "b": [0.5805, 0.1306, 0.6006, 0.151]}, {"w": "the", "b": [0.6073, 0.1306, 0.6324, 0.151]}, {"w": "Literary", "b": [0.6391, 0.1304, 0.7009, 0.151]}, {"w": "Digest", "b": [0.7076, 0.1304, 0.7557, 0.151]}, {"w": "used", "b": [0.7624, 0.1306, 0.7991, 0.151]}, {"w": "tele‐", "b": [0.8058, 0.1306, 0.8408, 0.151]}, {"w": "phone", "b": [0.1949, 0.1487, 0.2453, 0.1691]}, {"w": "directories,", "b": [0.2518, 0.1487, 0.3409, 0.1691]}, {"w": "lists", "b": [0.3473, 0.1487, 0.3783, 0.1691]}, {"w": "of", "b": [0.3847, 0.1487, 0.4007, 0.1691]}, {"w": "magazine", "b": [0.4072, 0.1487, 0.4831, 0.1691]}, {"w": "subscribers,", "b": [0.4895, 0.1487, 0.5835, 0.1691]}, {"w": "club", "b": [0.5899, 0.1487, 0.6239, 0.1691]}, {"w": "membership", "b": [0.6304, 0.1487, 0.7308, 0.1691]}, {"w": "lists,", "b": [0.7373, 0.1487, 0.7727, 0.1691]}, {"w": "and", "b": [0.7792, 0.1487, 0.8092, 0.1691]}, {"w": "the", "b": [0.8157, 0.1487, 0.8408, 0.1691]}, {"w": "like.", "b": [0.1949, 0.1669, 0.2281, 0.1873]}, {"w": "All", "b": [0.2337, 0.1669, 0.2574, 0.1873]}, {"w": "of", "b": [0.263, 0.1669, 0.279, 0.1873]}, {"w": "these", "b": [0.2846, 0.1669, 0.3254, 0.1873]}, {"w": "lists", "b": [0.331, 0.1669, 0.3619, 0.1873]}, {"w": "tend", "b": [0.3675, 0.1669, 0.4033, 0.1873]}, {"w": "to", "b": [0.4089, 0.1669, 0.4251, 0.1873]}, {"w": "favor", "b": [0.4307, 0.1669, 0.4716, 0.1873]}, {"w": "wealthier", "b": [0.4771, 0.1669, 0.5507, 0.1873]}, {"w": "people,", "b": [0.5563, 0.1669, 0.6136, 0.1873]}, {"w": "who", "b": [0.6192, 0.1669, 0.6535, 0.1873]}, {"w": "are", "b": [0.6591, 0.1669, 0.6836, 0.1873]}, {"w": "more", "b": [0.6891, 0.1669, 0.7313, 0.1873]}, {"w": "likely", "b": [0.7369, 0.1669, 0.7796, 0.1873]}, {"w": "to", "b": [0.7852, 0.1669, 0.8014, 0.1873]}, {"w": "vote", "b": [0.807, 0.1669, 0.8408, 0.1873]}, {"w": "Republican", "b": [0.1949, 0.185, 0.285, 0.2054]}, {"w": "(hence", "b": [0.2895, 0.185, 0.3431, 0.2054]}, {"w": "Landon).", "b": [0.3476, 0.185, 0.4207, 0.2054]}]}, {"id": "b_2", "type": "paragraph", "text": "• Second, less than 25% of the people who received the poll answered. Again, this introduces a sampling bias, by ruling out people who don’t care much about poli‐ tics, people who don’t like the Literary Digest, and other key groups. This is a spe‐ cial type of sampling bias called nonresponse bias.", "words": [{"w": "•", "b": [0.1773, 0.2092, 0.185, 0.2296]}, {"w": "Second,", "b": [0.1949, 0.2092, 0.2571, 0.2296]}, {"w": "less", "b": [0.2629, 0.2092, 0.2909, 0.2296]}, {"w": "than", "b": [0.2966, 0.2092, 0.3328, 0.2296]}, {"w": "25%", "b": [0.3385, 0.2092, 0.3725, 0.2296]}, {"w": "of", "b": [0.3782, 0.2092, 0.3942, 0.2296]}, {"w": "the", "b": [0.3999, 0.2092, 0.425, 0.2296]}, {"w": "people", "b": [0.4307, 0.2092, 0.4835, 0.2296]}, {"w": "who", "b": [0.4892, 0.2092, 0.5235, 0.2296]}, {"w": "received", "b": [0.5293, 0.2092, 0.5953, 0.2296]}, {"w": "the", "b": [0.601, 0.2092, 0.6261, 0.2296]}, {"w": "poll", "b": [0.6318, 0.2092, 0.6623, 0.2296]}, {"w": "answered.", "b": [0.668, 0.2092, 0.7477, 0.2296]}, {"w": "Again,", "b": [0.7534, 0.2092, 0.8058, 0.2296]}, {"w": "this", "b": [0.8115, 0.2092, 0.8408, 0.2296]}, {"w": "introduces", "b": [0.1949, 0.2273, 0.2794, 0.2477]}, {"w": "a", "b": [0.2841, 0.2273, 0.2928, 0.2477]}, {"w": "sampling", "b": [0.2975, 0.2273, 0.3703, 0.2477]}, {"w": "bias,", "b": [0.375, 0.2273, 0.4109, 0.2477]}, {"w": "by", "b": [0.4156, 0.2273, 0.4348, 0.2477]}, {"w": "ruling", "b": [0.4395, 0.2273, 0.4879, 0.2477]}, {"w": "out", "b": [0.4926, 0.2273, 0.5193, 0.2477]}, {"w": "people", "b": [0.524, 0.2273, 0.5768, 0.2477]}, {"w": "who", "b": [0.5816, 0.2273, 0.6159, 0.2477]}, {"w": "don’t", "b": [0.6206, 0.2273, 0.6602, 0.2477]}, {"w": "care", "b": [0.6649, 0.2273, 0.6978, 0.2477]}, {"w": "much", "b": [0.7025, 0.2273, 0.7479, 0.2477]}, {"w": "about", "b": [0.7526, 0.2273, 0.7981, 0.2477]}, {"w": "poli‐", "b": [0.8029, 0.2273, 0.8408, 0.2477]}, {"w": "tics,", "b": [0.1949, 0.2455, 0.2265, 0.2659]}, {"w": "people", "b": [0.2312, 0.2455, 0.284, 0.2659]}, {"w": "who", "b": [0.2886, 0.2455, 0.3229, 0.2659]}, {"w": "don’t", "b": [0.3276, 0.2455, 0.3672, 0.2659]}, {"w": "like", "b": [0.3719, 0.2455, 0.4005, 0.2659]}, {"w": "the", "b": [0.4052, 0.2455, 0.4303, 0.2659]}, {"w": "Literary", "b": [0.4349, 0.2453, 0.4967, 0.2659]}, {"w": "Digest,", "b": [0.5013, 0.2453, 0.554, 0.2659]}, {"w": "and", "b": [0.5587, 0.2455, 0.5887, 0.2659]}, {"w": "other", "b": [0.5934, 0.2455, 0.6359, 0.2659]}, {"w": "key", "b": [0.6406, 0.2455, 0.668, 0.2659]}, {"w": "groups.", "b": [0.6727, 0.2455, 0.7322, 0.2659]}, {"w": "This", "b": [0.7368, 0.2455, 0.7723, 0.2659]}, {"w": "is", "b": [0.7769, 0.2455, 0.7895, 0.2659]}, {"w": "a", "b": [0.7942, 0.2455, 0.8029, 0.2659]}, {"w": "spe‐", "b": [0.8076, 0.2455, 0.8408, 0.2659]}, {"w": "cial", "b": [0.1949, 0.2636, 0.2224, 0.284]}, {"w": "type", "b": [0.2269, 0.2636, 0.2609, 0.284]}, {"w": "of", "b": [0.2654, 0.2636, 0.2814, 0.284]}, {"w": "sampling", "b": [0.2859, 0.2636, 0.3586, 0.284]}, {"w": "bias", "b": [0.3631, 0.2636, 0.3945, 0.284]}, {"w": "called", "b": [0.399, 0.2636, 0.4451, 0.284]}, {"w": "nonresponse", "b": [0.4496, 0.2634, 0.5444, 0.284]}, {"w": "bias.", "b": [0.549, 0.2634, 0.5847, 0.284]}]}, {"id": "b_3", "type": "paragraph", "text": "Here is another example: say you want to build a system to recognize funk music vid‐ eos. One way to build your training set is to search “funk music” on YouTube and use the resulting videos. But this assumes that YouTube’s search engine returns a set of videos that are representative of all the funk music videos on YouTube. In reality, the search results are likely to be biased toward popular artists (and if you live in Brazil you will get a lot of “funk carioca” videos, which sound nothing like James Brown). On the other hand, how else can you get a large training set?", "words": [{"w": "Here", "b": [0.1592, 0.2969, 0.1981, 0.3173]}, {"w": "is", "b": [0.2031, 0.2969, 0.2157, 0.3173]}, {"w": "another", "b": [0.2206, 0.2969, 0.2827, 0.3173]}, {"w": "example:", "b": [0.2876, 0.2969, 0.3584, 0.3173]}, {"w": "say", "b": [0.3633, 0.2969, 0.3881, 0.3173]}, {"w": "you", "b": [0.393, 0.2969, 0.4227, 0.3173]}, {"w": "want", "b": [0.4277, 0.2969, 0.4665, 0.3173]}, {"w": "to", "b": [0.4714, 0.2969, 0.4876, 0.3173]}, {"w": "build", "b": [0.4925, 0.2969, 0.5339, 0.3173]}, {"w": "a", "b": [0.5389, 0.2969, 0.5476, 0.3173]}, {"w": "system", "b": [0.5525, 0.2969, 0.6069, 0.3173]}, {"w": "to", "b": [0.6118, 0.2969, 0.628, 0.3173]}, {"w": "recognize", "b": [0.6329, 0.2969, 0.7095, 0.3173]}, {"w": "funk", "b": [0.7144, 0.2969, 0.7515, 0.3173]}, {"w": "music", "b": [0.7564, 0.2969, 0.8038, 0.3173]}, {"w": "vid‐", "b": [0.8087, 0.2969, 0.8408, 0.3173]}, {"w": "eos.", "b": [0.1592, 0.315, 0.1896, 0.3354]}, {"w": "One", "b": [0.1946, 0.315, 0.2287, 0.3354]}, {"w": "way", "b": [0.2336, 0.315, 0.2647, 0.3354]}, {"w": "to", "b": [0.2697, 0.315, 0.2858, 0.3354]}, {"w": "build", "b": [0.2908, 0.315, 0.3322, 0.3354]}, {"w": "your", "b": [0.3372, 0.315, 0.3743, 0.3354]}, {"w": "training", "b": [0.3793, 0.315, 0.443, 0.3354]}, {"w": "set", "b": [0.448, 0.315, 0.4698, 0.3354]}, {"w": "is", "b": [0.4748, 0.315, 0.4874, 0.3354]}, {"w": "to", "b": [0.4923, 0.315, 0.5085, 0.3354]}, {"w": "search", "b": [0.5135, 0.315, 0.5642, 0.3354]}, {"w": "“funk", "b": [0.5692, 0.315, 0.6136, 0.3354]}, {"w": "music”", "b": [0.6186, 0.315, 0.6734, 0.3354]}, {"w": "on", "b": [0.6784, 0.315, 0.6994, 0.3354]}, {"w": "YouTube", "b": [0.7044, 0.315, 0.7745, 0.3354]}, {"w": "and", "b": [0.7795, 0.315, 0.8095, 0.3354]}, {"w": "use", "b": [0.8145, 0.315, 0.8408, 0.3354]}, {"w": "the", "b": [0.1592, 0.3332, 0.1843, 0.3535]}, {"w": "resulting", "b": [0.1912, 0.3332, 0.2613, 0.3535]}, {"w": "videos.", "b": [0.2682, 0.3332, 0.3236, 0.3535]}, {"w": "But", "b": [0.3304, 0.3332, 0.3587, 0.3535]}, {"w": "this", "b": [0.3656, 0.3332, 0.3948, 0.3535]}, {"w": "assumes", "b": [0.4017, 0.3332, 0.4675, 0.3535]}, {"w": "that", "b": [0.4744, 0.3332, 0.5054, 0.3535]}, {"w": "YouTube’s", "b": [0.5123, 0.3332, 0.5911, 0.3535]}, {"w": "search", "b": [0.598, 0.3332, 0.6488, 0.3535]}, {"w": "engine", "b": [0.6557, 0.3332, 0.7089, 0.3535]}, {"w": "returns", "b": [0.7158, 0.3332, 0.7736, 0.3535]}, {"w": "a", "b": [0.7805, 0.3332, 0.7892, 0.3535]}, {"w": "set", "b": [0.7961, 0.3332, 0.8179, 0.3535]}, {"w": "of", "b": [0.8248, 0.3332, 0.8408, 0.3535]}, {"w": "videos", "b": [0.1592, 0.3513, 0.21, 0.3717]}, {"w": "that", "b": [0.2155, 0.3513, 0.2466, 0.3717]}, {"w": "are", "b": [0.2521, 0.3513, 0.2766, 0.3717]}, {"w": "representative", "b": [0.2821, 0.3513, 0.3936, 0.3717]}, {"w": "of", "b": [0.3991, 0.3513, 0.4151, 0.3717]}, {"w": "all", "b": [0.4206, 0.3513, 0.4394, 0.3717]}, {"w": "the", "b": [0.4449, 0.3513, 0.47, 0.3717]}, {"w": "funk", "b": [0.4755, 0.3513, 0.5126, 0.3717]}, {"w": "music", "b": [0.5181, 0.3513, 0.5655, 0.3717]}, {"w": "videos", "b": [0.571, 0.3513, 0.6218, 0.3717]}, {"w": "on", "b": [0.6273, 0.3513, 0.6483, 0.3717]}, {"w": "YouTube.", "b": [0.6538, 0.3513, 0.7285, 0.3717]}, {"w": "In", "b": [0.734, 0.3513, 0.7516, 0.3717]}, {"w": "reality,", "b": [0.7571, 0.3513, 0.8102, 0.3717]}, {"w": "the", "b": [0.8157, 0.3513, 0.8408, 0.3717]}, {"w": "search", "b": [0.1592, 0.3694, 0.21, 0.3898]}, {"w": "results", "b": [0.2161, 0.3694, 0.268, 0.3898]}, {"w": "are", "b": [0.2741, 0.3694, 0.2986, 0.3898]}, {"w": "likely", "b": [0.3047, 0.3694, 0.3475, 0.3898]}, {"w": "to", "b": [0.3535, 0.3694, 0.3697, 0.3898]}, {"w": "be", "b": [0.3758, 0.3694, 0.3943, 0.3898]}, {"w": "biased", "b": [0.4004, 0.3694, 0.4507, 0.3898]}, {"w": "toward", "b": [0.4568, 0.3694, 0.5131, 0.3898]}, {"w": "popular", "b": [0.5192, 0.3694, 0.5817, 0.3898]}, {"w": "artists", "b": [0.5878, 0.3694, 0.6359, 0.3898]}, {"w": "(and", "b": [0.6419, 0.3694, 0.6788, 0.3898]}, {"w": "if", "b": [0.6849, 0.3694, 0.6961, 0.3898]}, {"w": "you", "b": [0.7022, 0.3694, 0.732, 0.3898]}, {"w": "live", "b": [0.7381, 0.3694, 0.766, 0.3898]}, {"w": "in", "b": [0.7721, 0.3694, 0.7883, 0.3898]}, {"w": "Brazil", "b": [0.7944, 0.3694, 0.8408, 0.3898]}, {"w": "you", "b": [0.1592, 0.3876, 0.189, 0.408]}, {"w": "will", "b": [0.1953, 0.3876, 0.2243, 0.408]}, {"w": "get", "b": [0.2306, 0.3876, 0.2544, 0.408]}, {"w": "a", "b": [0.2608, 0.3876, 0.2695, 0.408]}, {"w": "lot", "b": [0.2758, 0.3876, 0.297, 0.408]}, {"w": "of", "b": [0.3034, 0.3876, 0.3194, 0.408]}, {"w": "“funk", "b": [0.3257, 0.3876, 0.3701, 0.408]}, {"w": "carioca”", "b": [0.3765, 0.3876, 0.4399, 0.408]}, {"w": "videos,", "b": [0.4462, 0.3876, 0.5016, 0.408]}, {"w": "which", "b": [0.5079, 0.3876, 0.5564, 0.408]}, {"w": "sound", "b": [0.5628, 0.3876, 0.612, 0.408]}, {"w": "nothing", "b": [0.6184, 0.3876, 0.6815, 0.408]}, {"w": "like", "b": [0.6878, 0.3876, 0.7164, 0.408]}, {"w": "James", "b": [0.7228, 0.3876, 0.7694, 0.408]}, {"w": "Brown).", "b": [0.7758, 0.3876, 0.8408, 0.408]}, {"w": "On", "b": [0.1592, 0.4057, 0.1849, 0.4261]}, {"w": "the", "b": [0.1894, 0.4057, 0.2145, 0.4261]}, {"w": "other", "b": [0.219, 0.4057, 0.2615, 0.4261]}, {"w": "hand,", "b": [0.266, 0.4057, 0.3112, 0.4261]}, {"w": "how", "b": [0.3157, 0.4057, 0.35, 0.4261]}, {"w": "else", "b": [0.3545, 0.4057, 0.3837, 0.4261]}, {"w": "can", "b": [0.3882, 0.4057, 0.4161, 0.4261]}, {"w": "you", "b": [0.4206, 0.4057, 0.4504, 0.4261]}, {"w": "get", "b": [0.4549, 0.4057, 0.4787, 0.4261]}, {"w": "a", "b": [0.4832, 0.4057, 0.4919, 0.4261]}, {"w": "large", "b": [0.4964, 0.4057, 0.5352, 0.4261]}, {"w": "training", "b": [0.5397, 0.4057, 0.6035, 0.4261]}, {"w": "set?", "b": [0.608, 0.4057, 0.6373, 0.4261]}]}, {"id": "b_4", "type": "equation", "text": "Poor-Quality Data", "words": [{"w": "Poor-Quality", "b": [0.1428, 0.4559, 0.2728, 0.4844]}, {"w": "Data", "b": [0.2777, 0.4559, 0.3261, 0.4844]}]}, {"id": "b_5", "type": "paragraph", "text": "Obviously, if your training data is full of errors, outliers, and noise (e.g., due to poor- quality measurements), it will make it harder for the system to detect the underlying patterns, so your system is less likely to perform well. It is often well worth the effort to spend time cleaning up your training data. The truth is, most data scientists spend a significant part of their time doing just that. For example:", "words": [{"w": "Obviously,", "b": [0.1429, 0.4903, 0.2316, 0.5117]}, {"w": "if", "b": [0.2371, 0.4903, 0.2488, 0.5117]}, {"w": "your", "b": [0.2542, 0.4903, 0.2932, 0.5117]}, {"w": "training", "b": [0.2986, 0.4903, 0.3656, 0.5117]}, {"w": "data", "b": [0.371, 0.4903, 0.4063, 0.5117]}, {"w": "is", "b": [0.4117, 0.4903, 0.4249, 0.5117]}, {"w": "full", "b": [0.4303, 0.4903, 0.4581, 0.5117]}, {"w": "of", "b": [0.4635, 0.4903, 0.4803, 0.5117]}, {"w": "errors,", "b": [0.4858, 0.4903, 0.5408, 0.5117]}, {"w": "outliers,", "b": [0.5463, 0.4903, 0.6141, 0.5117]}, {"w": "and", "b": [0.6196, 0.4903, 0.6511, 0.5117]}, {"w": "noise", "b": [0.6565, 0.4903, 0.7006, 0.5117]}, {"w": "(e.g.,", "b": [0.7061, 0.4903, 0.7461, 0.5117]}, {"w": "due", "b": [0.7516, 0.4903, 0.7825, 0.5117]}, {"w": "to", "b": [0.7879, 0.4903, 0.8049, 0.5117]}, {"w": "poor-", "b": [0.8103, 0.4903, 0.8571, 0.5117]}, {"w": "quality", "b": [0.1429, 0.5094, 0.2005, 0.5308]}, {"w": "measurements),", "b": [0.2063, 0.5094, 0.3395, 0.5308]}, {"w": "it", "b": [0.3453, 0.5094, 0.3572, 0.5308]}, {"w": "will", "b": [0.363, 0.5094, 0.3934, 0.5308]}, {"w": "make", "b": [0.3991, 0.5094, 0.4445, 0.5308]}, {"w": "it", "b": [0.4503, 0.5094, 0.4623, 0.5308]}, {"w": "harder", "b": [0.468, 0.5094, 0.5236, 0.5308]}, {"w": "for", "b": [0.5294, 0.5094, 0.5539, 0.5308]}, {"w": "the", "b": [0.5597, 0.5094, 0.586, 0.5308]}, {"w": "system", "b": [0.5918, 0.5094, 0.6489, 0.5308]}, {"w": "to", "b": [0.6547, 0.5094, 0.6717, 0.5308]}, {"w": "detect", "b": [0.6774, 0.5094, 0.7277, 0.5308]}, {"w": "the", "b": [0.7334, 0.5094, 0.7598, 0.5308]}, {"w": "underlying", "b": [0.7655, 0.5094, 0.8572, 0.5308]}, {"w": "patterns,", "b": [0.1429, 0.5284, 0.2156, 0.5498]}, {"w": "so", "b": [0.2212, 0.5284, 0.2395, 0.5498]}, {"w": "your", "b": [0.2451, 0.5284, 0.2841, 0.5498]}, {"w": "system", "b": [0.2897, 0.5284, 0.3468, 0.5498]}, {"w": "is", "b": [0.3525, 0.5284, 0.3657, 0.5498]}, {"w": "less", "b": [0.3713, 0.5284, 0.4007, 0.5498]}, {"w": "likely", "b": [0.4063, 0.5284, 0.4512, 0.5498]}, {"w": "to", "b": [0.4568, 0.5284, 0.4738, 0.5498]}, {"w": "perform", "b": [0.4794, 0.5284, 0.5485, 0.5498]}, {"w": "well.", "b": [0.5541, 0.5284, 0.5925, 0.5498]}, {"w": "It", "b": [0.5982, 0.5284, 0.6108, 0.5498]}, {"w": "is", "b": [0.6164, 0.5284, 0.6297, 0.5498]}, {"w": "often", "b": [0.6353, 0.5284, 0.6787, 0.5498]}, {"w": "well", "b": [0.6843, 0.5284, 0.718, 0.5498]}, {"w": "worth", "b": [0.7236, 0.5284, 0.7737, 0.5498]}, {"w": "the", "b": [0.7793, 0.5284, 0.8056, 0.5498]}, {"w": "effort", "b": [0.8112, 0.5284, 0.8571, 0.5498]}, {"w": "to", "b": [0.1429, 0.5475, 0.1598, 0.5689]}, {"w": "spend", "b": [0.1653, 0.5475, 0.2151, 0.5689]}, {"w": "time", "b": [0.2205, 0.5475, 0.2583, 0.5689]}, {"w": "cleaning", "b": [0.2638, 0.5475, 0.334, 0.5689]}, {"w": "up", "b": [0.3394, 0.5475, 0.3614, 0.5689]}, {"w": "your", "b": [0.3668, 0.5475, 0.4058, 0.5689]}, {"w": "training", "b": [0.4112, 0.5475, 0.4781, 0.5689]}, {"w": "data.", "b": [0.4835, 0.5475, 0.5235, 0.5689]}, {"w": "The", "b": [0.529, 0.5475, 0.5618, 0.5689]}, {"w": "truth", "b": [0.5672, 0.5475, 0.6098, 0.5689]}, {"w": "is,", "b": [0.6153, 0.5475, 0.6332, 0.5689]}, {"w": "most", "b": [0.6387, 0.5475, 0.6803, 0.5689]}, {"w": "data", "b": [0.6858, 0.5475, 0.721, 0.5689]}, {"w": "scientists", "b": [0.7264, 0.5475, 0.8019, 0.5689]}, {"w": "spend", "b": [0.8073, 0.5475, 0.8571, 0.5689]}, {"w": "a", "b": [0.1428, 0.5665, 0.152, 0.5879]}, {"w": "significant", "b": [0.1567, 0.5665, 0.2437, 0.5879]}, {"w": "part", "b": [0.2485, 0.5665, 0.2826, 0.5879]}, {"w": "of", "b": [0.2873, 0.5665, 0.3041, 0.5879]}, {"w": "their", "b": [0.3089, 0.5665, 0.3485, 0.5879]}, {"w": "time", "b": [0.3532, 0.5665, 0.3911, 0.5879]}, {"w": "doing", "b": [0.3958, 0.5665, 0.4442, 0.5879]}, {"w": "just", "b": [0.4489, 0.5665, 0.4793, 0.5879]}, {"w": "that.", "b": [0.484, 0.5665, 0.5214, 0.5879]}, {"w": "For", "b": [0.5261, 0.5665, 0.5551, 0.5879]}, {"w": "example:", "b": [0.5598, 0.5665, 0.6341, 0.5879]}]}, {"id": "b_6", "type": "paragraph", "text": "• If some instances are clearly outliers, it may help to simply discard them or try to fix the errors manually.", "words": [{"w": "•", "b": [0.16, 0.6007, 0.1681, 0.6221]}, {"w": "If", "b": [0.1786, 0.6007, 0.1918, 0.6221]}, {"w": "some", "b": [0.1969, 0.6007, 0.2411, 0.6221]}, {"w": "instances", "b": [0.2462, 0.6007, 0.323, 0.6221]}, {"w": "are", "b": [0.3281, 0.6007, 0.3538, 0.6221]}, {"w": "clearly", "b": [0.3589, 0.6007, 0.4135, 0.6221]}, {"w": "outliers,", "b": [0.4186, 0.6007, 0.4864, 0.6221]}, {"w": "it", "b": [0.4915, 0.6007, 0.5034, 0.6221]}, {"w": "may", "b": [0.5085, 0.6007, 0.5439, 0.6221]}, {"w": "help", "b": [0.549, 0.6007, 0.5851, 0.6221]}, {"w": "to", "b": [0.5902, 0.6007, 0.6072, 0.6221]}, {"w": "simply", "b": [0.6123, 0.6007, 0.6679, 0.6221]}, {"w": "discard", "b": [0.673, 0.6007, 0.7339, 0.6221]}, {"w": "them", "b": [0.739, 0.6007, 0.7824, 0.6221]}, {"w": "or", "b": [0.7874, 0.6007, 0.8058, 0.6221]}, {"w": "try", "b": [0.8108, 0.6007, 0.8351, 0.6221]}, {"w": "to", "b": [0.8402, 0.6007, 0.8571, 0.6221]}, {"w": "fix", "b": [0.1786, 0.6197, 0.2002, 0.6412]}, {"w": "the", "b": [0.2049, 0.6197, 0.2312, 0.6412]}, {"w": "errors", "b": [0.2359, 0.6197, 0.2863, 0.6412]}, {"w": "manually.", "b": [0.291, 0.6197, 0.3717, 0.6412]}]}, {"id": "b_7", "type": "paragraph", "text": "• If some instances are missing a few features (e.g., 5% of your customers did not specify their age), you must decide whether you want to ignore this attribute alto‐ gether, ignore these instances, fill in the missing values (e.g., with the median age), or train one model with the feature and one model without it, and so on.", "words": [{"w": "•", "b": [0.16, 0.6448, 0.1682, 0.6662]}, {"w": "If", "b": [0.1786, 0.6448, 0.1918, 0.6662]}, {"w": "some", "b": [0.198, 0.6448, 0.2422, 0.6662]}, {"w": "instances", "b": [0.2484, 0.6448, 0.3252, 0.6662]}, {"w": "are", "b": [0.3314, 0.6448, 0.3572, 0.6662]}, {"w": "missing", "b": [0.3634, 0.6448, 0.428, 0.6662]}, {"w": "a", "b": [0.4342, 0.6448, 0.4434, 0.6662]}, {"w": "few", "b": [0.4496, 0.6448, 0.4788, 0.6662]}, {"w": "features", "b": [0.485, 0.6448, 0.5505, 0.6662]}, {"w": "(e.g.,", "b": [0.5566, 0.6448, 0.5967, 0.6662]}, {"w": "5%", "b": [0.6029, 0.6448, 0.6287, 0.6662]}, {"w": "of", "b": [0.6348, 0.6448, 0.6516, 0.6662]}, {"w": "your", "b": [0.6578, 0.6448, 0.6968, 0.6662]}, {"w": "customers", "b": [0.703, 0.6448, 0.7888, 0.6662]}, {"w": "did", "b": [0.795, 0.6448, 0.8226, 0.6662]}, {"w": "not", "b": [0.8288, 0.6448, 0.8571, 0.6662]}, {"w": "specify", "b": [0.1786, 0.6639, 0.2365, 0.6853]}, {"w": "their", "b": [0.2412, 0.6639, 0.2808, 0.6853]}, {"w": "age),", "b": [0.2856, 0.6639, 0.3253, 0.6853]}, {"w": "you", "b": [0.33, 0.6639, 0.3613, 0.6853]}, {"w": "must", "b": [0.366, 0.6639, 0.4077, 0.6853]}, {"w": "decide", "b": [0.4124, 0.6639, 0.4666, 0.6853]}, {"w": "whether", "b": [0.4713, 0.6639, 0.5396, 0.6853]}, {"w": "you", "b": [0.5443, 0.6639, 0.5756, 0.6853]}, {"w": "want", "b": [0.5803, 0.6639, 0.6211, 0.6853]}, {"w": "to", "b": [0.6258, 0.6639, 0.6428, 0.6853]}, {"w": "ignore", "b": [0.6475, 0.6639, 0.7014, 0.6853]}, {"w": "this", "b": [0.7062, 0.6639, 0.7369, 0.6853]}, {"w": "attribute", "b": [0.7416, 0.6639, 0.8132, 0.6853]}, {"w": "alto‐", "b": [0.818, 0.6639, 0.8568, 0.6853]}, {"w": "gether,", "b": [0.1786, 0.6829, 0.2347, 0.7043]}, {"w": "ignore", "b": [0.2426, 0.6829, 0.2966, 0.7043]}, {"w": "these", "b": [0.3045, 0.6829, 0.3474, 0.7043]}, {"w": "instances,", "b": [0.3553, 0.6829, 0.4369, 0.7043]}, {"w": "fill", "b": [0.4448, 0.6829, 0.4671, 0.7043]}, {"w": "in", "b": [0.4751, 0.6829, 0.4921, 0.7043]}, {"w": "the", "b": [0.5, 0.6829, 0.5264, 0.7043]}, {"w": "missing", "b": [0.5343, 0.6829, 0.599, 0.7043]}, {"w": "values", "b": [0.6069, 0.6829, 0.6586, 0.7043]}, {"w": "(e.g.,", "b": [0.6665, 0.6829, 0.7066, 0.7043]}, {"w": "with", "b": [0.7145, 0.6829, 0.7519, 0.7043]}, {"w": "the", "b": [0.7598, 0.6829, 0.7862, 0.7043]}, {"w": "median", "b": [0.7941, 0.6829, 0.8571, 0.7043]}, {"w": "age),", "b": [0.1786, 0.702, 0.2183, 0.7234]}, {"w": "or", "b": [0.223, 0.702, 0.2414, 0.7234]}, {"w": "train", "b": [0.2461, 0.702, 0.2863, 0.7234]}, {"w": "one", "b": [0.291, 0.702, 0.3219, 0.7234]}, {"w": "model", "b": [0.3266, 0.702, 0.3794, 0.7234]}, {"w": "with", "b": [0.3842, 0.702, 0.4215, 0.7234]}, {"w": "the", "b": [0.4262, 0.702, 0.4526, 0.7234]}, {"w": "feature", "b": [0.4573, 0.702, 0.5151, 0.7234]}, {"w": "and", "b": [0.5198, 0.702, 0.5513, 0.7234]}, {"w": "one", "b": [0.5561, 0.702, 0.5869, 0.7234]}, {"w": "model", "b": [0.5917, 0.702, 0.6445, 0.7234]}, {"w": "without", "b": [0.6492, 0.702, 0.7146, 0.7234]}, {"w": "it,", "b": [0.7193, 0.702, 0.736, 0.7234]}, {"w": "and", "b": [0.7407, 0.702, 0.7723, 0.7234]}, {"w": "so", "b": [0.777, 0.702, 0.7953, 0.7234]}, {"w": "on.", "b": [0.8, 0.702, 0.8268, 0.7234]}]}, {"id": "b_8", "type": "paragraph", "text": "Irrelevant Features", "words": [{"w": "Irrelevant", "b": [0.1429, 0.7513, 0.2449, 0.7798]}, {"w": "Features", "b": [0.2498, 0.7513, 0.339, 0.7798]}]}, {"id": "b_9", "type": "paragraph", "text": "As the saying goes: garbage in, garbage out. Your system will only be capable of learn‐ ing if the training data contains enough relevant features and not too many irrelevant ones. A critical part of the success of a Machine Learning project is coming up with a good set of features to train on. This process, called feature engineering, involves:", "words": [{"w": "As", "b": [0.1429, 0.7857, 0.1649, 0.8072]}, {"w": "the", "b": [0.1699, 0.7857, 0.1962, 0.8072]}, {"w": "saying", "b": [0.2011, 0.7857, 0.2538, 0.8072]}, {"w": "goes:", "b": [0.2588, 0.7857, 0.3004, 0.8072]}, {"w": "garbage", "b": [0.3054, 0.7857, 0.3703, 0.8072]}, {"w": "in,", "b": [0.3753, 0.7857, 0.397, 0.8072]}, {"w": "garbage", "b": [0.402, 0.7857, 0.4669, 0.8072]}, {"w": "out.", "b": [0.4719, 0.7857, 0.5047, 0.8072]}, {"w": "Your", "b": [0.5096, 0.7857, 0.5497, 0.8072]}, {"w": "system", "b": [0.5547, 0.7857, 0.6118, 0.8072]}, {"w": "will", "b": [0.6167, 0.7857, 0.6471, 0.8072]}, {"w": "only", "b": [0.6521, 0.7857, 0.689, 0.8072]}, {"w": "be", "b": [0.6939, 0.7857, 0.7133, 0.8072]}, {"w": "capable", "b": [0.7183, 0.7857, 0.7806, 0.8072]}, {"w": "of", "b": [0.7856, 0.7857, 0.8024, 0.8072]}, {"w": "learn‐", "b": [0.8073, 0.7857, 0.8571, 0.8072]}, {"w": "ing", "b": [0.1428, 0.8048, 0.1696, 0.8262]}, {"w": "if", "b": [0.1748, 0.8048, 0.1865, 0.8262]}, {"w": "the", "b": [0.1917, 0.8048, 0.218, 0.8262]}, {"w": "training", "b": [0.2232, 0.8048, 0.2901, 0.8262]}, {"w": "data", "b": [0.2953, 0.8048, 0.3305, 0.8262]}, {"w": "contains", "b": [0.3357, 0.8048, 0.4063, 0.8262]}, {"w": "enough", "b": [0.4115, 0.8048, 0.4743, 0.8262]}, {"w": "relevant", "b": [0.4794, 0.8048, 0.5463, 0.8262]}, {"w": "features", "b": [0.5515, 0.8048, 0.6169, 0.8262]}, {"w": "and", "b": [0.6221, 0.8048, 0.6536, 0.8262]}, {"w": "not", "b": [0.6588, 0.8048, 0.6872, 0.8262]}, {"w": "too", "b": [0.6923, 0.8048, 0.7199, 0.8262]}, {"w": "many", "b": [0.7251, 0.8048, 0.7718, 0.8262]}, {"w": "irrelevant", "b": [0.777, 0.8048, 0.8571, 0.8262]}, {"w": "ones.", "b": [0.1429, 0.8238, 0.1861, 0.8452]}, {"w": "A", "b": [0.1914, 0.8238, 0.2058, 0.8452]}, {"w": "critical", "b": [0.211, 0.8238, 0.2683, 0.8452]}, {"w": "part", "b": [0.2736, 0.8238, 0.3077, 0.8452]}, {"w": "of", "b": [0.3129, 0.8238, 0.3297, 0.8452]}, {"w": "the", "b": [0.335, 0.8238, 0.3613, 0.8452]}, {"w": "success", "b": [0.3666, 0.8238, 0.427, 0.8452]}, {"w": "of", "b": [0.4323, 0.8238, 0.4491, 0.8452]}, {"w": "a", "b": [0.4543, 0.8238, 0.4635, 0.8452]}, {"w": "Machine", "b": [0.4687, 0.8238, 0.5418, 0.8452]}, {"w": "Learning", "b": [0.5471, 0.8238, 0.6221, 0.8452]}, {"w": "project", "b": [0.6274, 0.8238, 0.686, 0.8452]}, {"w": "is", "b": [0.6913, 0.8238, 0.7045, 0.8452]}, {"w": "coming", "b": [0.7097, 0.8238, 0.773, 0.8452]}, {"w": "up", "b": [0.7782, 0.8238, 0.8002, 0.8452]}, {"w": "with", "b": [0.8054, 0.8238, 0.8428, 0.8452]}, {"w": "a", "b": [0.848, 0.8238, 0.8571, 0.8452]}, {"w": "good", "b": [0.1429, 0.8429, 0.1849, 0.8643]}, {"w": "set", "b": [0.1896, 0.8429, 0.2124, 0.8643]}, {"w": "of", "b": [0.2172, 0.8429, 0.234, 0.8643]}, {"w": "features", "b": [0.2387, 0.8429, 0.3041, 0.8643]}, {"w": "to", "b": [0.3088, 0.8429, 0.3258, 0.8643]}, {"w": "train", "b": [0.3305, 0.8429, 0.3708, 0.8643]}, {"w": "on.", "b": [0.3755, 0.8429, 0.4023, 0.8643]}, {"w": "This", "b": [0.407, 0.8429, 0.4442, 0.8643]}, {"w": "process,", "b": [0.4489, 0.8429, 0.5159, 0.8643]}, {"w": "called", "b": [0.5206, 0.8429, 0.569, 0.8643]}, {"w": "feature", "b": [0.5737, 0.8427, 0.6297, 0.8643]}, {"w": "engineering,", "b": [0.6345, 0.8427, 0.7329, 0.8643]}, {"w": "involves:", "b": [0.7377, 0.8429, 0.8106, 0.8643]}]}, {"id": "b_10", "type": "paragraph", "text": "Main Challenges of Machine Learning | 27", "words": [{"w": "Main", "b": [0.584, 0.9225, 0.6136, 0.9388]}, {"w": "Challenges", "b": [0.6164, 0.9225, 0.6805, 0.9388]}, {"w": "of", "b": [0.6833, 0.9225, 0.6953, 0.9388]}, {"w": "Machine", "b": [0.6981, 0.9225, 0.7481, 0.9388]}, {"w": "Learning", "b": [0.7509, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "27", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 54, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• Feature selection: selecting the most useful features to train on among existing features.", "words": [{"w": "•", "b": [0.16, 0.0851, 0.1682, 0.1065]}, {"w": "Feature", "b": [0.1786, 0.0849, 0.2394, 0.1065]}, {"w": "selection:", "b": [0.2473, 0.0849, 0.3209, 0.1065]}, {"w": "selecting", "b": [0.3287, 0.0851, 0.4013, 0.1065]}, {"w": "the", "b": [0.4091, 0.0851, 0.4354, 0.1065]}, {"w": "most", "b": [0.4432, 0.0851, 0.4849, 0.1065]}, {"w": "useful", "b": [0.4927, 0.0851, 0.5427, 0.1065]}, {"w": "features", "b": [0.5505, 0.0851, 0.616, 0.1065]}, {"w": "to", "b": [0.6238, 0.0851, 0.6407, 0.1065]}, {"w": "train", "b": [0.6485, 0.0851, 0.6887, 0.1065]}, {"w": "on", "b": [0.6965, 0.0851, 0.7186, 0.1065]}, {"w": "among", "b": [0.7264, 0.0851, 0.7843, 0.1065]}, {"w": "existing", "b": [0.7921, 0.0851, 0.8571, 0.1065]}, {"w": "features.", "b": [0.1786, 0.1042, 0.2487, 0.1256]}]}, {"id": "b_1", "type": "paragraph", "text": "• Feature extraction: combining existing features to produce a more useful one (as we saw earlier, dimensionality reduction algorithms can help).", "words": [{"w": "•", "b": [0.16, 0.1293, 0.1682, 0.1507]}, {"w": "Feature", "b": [0.1786, 0.129, 0.2394, 0.1507]}, {"w": "extraction:", "b": [0.2454, 0.129, 0.3324, 0.1507]}, {"w": "combining", "b": [0.3383, 0.1293, 0.4291, 0.1507]}, {"w": "existing", "b": [0.435, 0.1293, 0.5, 0.1507]}, {"w": "features", "b": [0.5059, 0.1293, 0.5713, 0.1507]}, {"w": "to", "b": [0.5773, 0.1293, 0.5942, 0.1507]}, {"w": "produce", "b": [0.6002, 0.1293, 0.6692, 0.1507]}, {"w": "a", "b": [0.6751, 0.1293, 0.6842, 0.1507]}, {"w": "more", "b": [0.6902, 0.1293, 0.7344, 0.1507]}, {"w": "useful", "b": [0.7404, 0.1293, 0.7904, 0.1507]}, {"w": "one", "b": [0.7963, 0.1293, 0.8272, 0.1507]}, {"w": "(as", "b": [0.8331, 0.1293, 0.8571, 0.1507]}, {"w": "we", "b": [0.1786, 0.1483, 0.2017, 0.1697]}, {"w": "saw", "b": [0.2064, 0.1483, 0.2371, 0.1697]}, {"w": "earlier,", "b": [0.2418, 0.1483, 0.2984, 0.1697]}, {"w": "dimensionality", "b": [0.3032, 0.1483, 0.4282, 0.1697]}, {"w": "reduction", "b": [0.433, 0.1483, 0.5144, 0.1697]}, {"w": "algorithms", "b": [0.5191, 0.1483, 0.6094, 0.1697]}, {"w": "can", "b": [0.6141, 0.1483, 0.6435, 0.1697]}, {"w": "help).", "b": [0.6482, 0.1483, 0.6963, 0.1697]}]}, {"id": "b_2", "type": "paragraph", "text": "• Creating new features by gathering new data.", "words": [{"w": "•", "b": [0.16, 0.1734, 0.1682, 0.1948]}, {"w": "Creating", "b": [0.1786, 0.1734, 0.2508, 0.1948]}, {"w": "new", "b": [0.2556, 0.1734, 0.2901, 0.1948]}, {"w": "features", "b": [0.2948, 0.1734, 0.3602, 0.1948]}, {"w": "by", "b": [0.365, 0.1734, 0.3851, 0.1948]}, {"w": "gathering", "b": [0.3898, 0.1734, 0.4691, 0.1948]}, {"w": "new", "b": [0.4739, 0.1734, 0.5084, 0.1948]}, {"w": "data.", "b": [0.5131, 0.1734, 0.5531, 0.1948]}]}, {"id": "b_3", "type": "paragraph", "text": "Now that we have looked at many examples of bad data, let’s look at a couple of exam‐ ples of bad algorithms.", "words": [{"w": "Now", "b": [0.1429, 0.2076, 0.1827, 0.229]}, {"w": "that", "b": [0.1875, 0.2076, 0.2201, 0.229]}, {"w": "we", "b": [0.2248, 0.2076, 0.248, 0.229]}, {"w": "have", "b": [0.2527, 0.2076, 0.2911, 0.229]}, {"w": "looked", "b": [0.2959, 0.2076, 0.3526, 0.229]}, {"w": "at", "b": [0.3574, 0.2076, 0.3725, 0.229]}, {"w": "many", "b": [0.3773, 0.2076, 0.424, 0.229]}, {"w": "examples", "b": [0.4287, 0.2076, 0.5059, 0.229]}, {"w": "of", "b": [0.5107, 0.2076, 0.5275, 0.229]}, {"w": "bad", "b": [0.5323, 0.2076, 0.563, 0.229]}, {"w": "data,", "b": [0.5678, 0.2076, 0.6078, 0.229]}, {"w": "let’s", "b": [0.6125, 0.2076, 0.6428, 0.229]}, {"w": "look", "b": [0.6475, 0.2076, 0.6844, 0.229]}, {"w": "at", "b": [0.6892, 0.2076, 0.7043, 0.229]}, {"w": "a", "b": [0.709, 0.2076, 0.7182, 0.229]}, {"w": "couple", "b": [0.723, 0.2076, 0.7785, 0.229]}, {"w": "of", "b": [0.7833, 0.2076, 0.8001, 0.229]}, {"w": "exam‐", "b": [0.8048, 0.2076, 0.8571, 0.229]}, {"w": "ples", "b": [0.1429, 0.2266, 0.1755, 0.248]}, {"w": "of", "b": [0.1803, 0.2266, 0.1971, 0.248]}, {"w": "bad", "b": [0.2018, 0.2266, 0.2325, 0.248]}, {"w": "algorithms.", "b": [0.2372, 0.2266, 0.3323, 0.248]}]}, {"id": "b_4", "type": "paragraph", "text": "Overfitting the Training Data", "words": [{"w": "Overfitting", "b": [0.1429, 0.2608, 0.2555, 0.2893]}, {"w": "the", "b": [0.2604, 0.2608, 0.2953, 0.2893]}, {"w": "Training", "b": [0.3002, 0.2608, 0.3862, 0.2893]}, {"w": "Data", "b": [0.3911, 0.2608, 0.4396, 0.2893]}]}, {"id": "b_5", "type": "paragraph", "text": "Say you are visiting a foreign country and the taxi driver rips you off. You might be tempted to say that all taxi drivers in that country are thieves. Overgeneralizing is something that we humans do all too often, and unfortunately machines can fall into the same trap if we are not careful. In Machine Learning this is called overfitting: it means that the model performs well on the training data, but it does not generalize well.", "words": [{"w": "Say", "b": [0.1429, 0.2953, 0.1711, 0.3167]}, {"w": "you", "b": [0.1774, 0.2953, 0.2086, 0.3167]}, {"w": "are", "b": [0.215, 0.2953, 0.2407, 0.3167]}, {"w": "visiting", "b": [0.247, 0.2953, 0.3085, 0.3167]}, {"w": "a", "b": [0.3149, 0.2953, 0.324, 0.3167]}, {"w": "foreign", "b": [0.3303, 0.2953, 0.3904, 0.3167]}, {"w": "country", "b": [0.3968, 0.2953, 0.4625, 0.3167]}, {"w": "and", "b": [0.4688, 0.2953, 0.5004, 0.3167]}, {"w": "the", "b": [0.5067, 0.2953, 0.533, 0.3167]}, {"w": "taxi", "b": [0.5393, 0.2953, 0.5703, 0.3167]}, {"w": "driver", "b": [0.5766, 0.2953, 0.6271, 0.3167]}, {"w": "rips", "b": [0.6334, 0.2953, 0.6653, 0.3167]}, {"w": "you", "b": [0.6716, 0.2953, 0.7029, 0.3167]}, {"w": "off.", "b": [0.7092, 0.2953, 0.7369, 0.3167]}, {"w": "You", "b": [0.7432, 0.2953, 0.7756, 0.3167]}, {"w": "might", "b": [0.7819, 0.2953, 0.8314, 0.3167]}, {"w": "be", "b": [0.8377, 0.2953, 0.8571, 0.3167]}, {"w": "tempted", "b": [0.1429, 0.3143, 0.2119, 0.3357]}, {"w": "to", "b": [0.2195, 0.3143, 0.2365, 0.3357]}, {"w": "say", "b": [0.2441, 0.3143, 0.2701, 0.3357]}, {"w": "that", "b": [0.2777, 0.3143, 0.3103, 0.3357]}, {"w": "all", "b": [0.3179, 0.3141, 0.3382, 0.3357]}, {"w": "taxi", "b": [0.3458, 0.3143, 0.3767, 0.3357]}, {"w": "drivers", "b": [0.3843, 0.3143, 0.4425, 0.3357]}, {"w": "in", "b": [0.4501, 0.3143, 0.4671, 0.3357]}, {"w": "that", "b": [0.4747, 0.3143, 0.5073, 0.3357]}, {"w": "country", "b": [0.5149, 0.3143, 0.5807, 0.3357]}, {"w": "are", "b": [0.5883, 0.3143, 0.614, 0.3357]}, {"w": "thieves.", "b": [0.6217, 0.3143, 0.6845, 0.3357]}, {"w": "Overgeneralizing", "b": [0.6921, 0.3143, 0.8363, 0.3357]}, {"w": "is", "b": [0.8439, 0.3143, 0.8572, 0.3357]}, {"w": "something", "b": [0.1429, 0.3333, 0.2313, 0.3548]}, {"w": "that", "b": [0.2368, 0.3333, 0.2693, 0.3548]}, {"w": "we", "b": [0.2748, 0.3333, 0.298, 0.3548]}, {"w": "humans", "b": [0.3035, 0.3333, 0.3705, 0.3548]}, {"w": "do", "b": [0.376, 0.3333, 0.3976, 0.3548]}, {"w": "all", "b": [0.4032, 0.3333, 0.4228, 0.3548]}, {"w": "too", "b": [0.4283, 0.3333, 0.4559, 0.3548]}, {"w": "often,", "b": [0.4615, 0.3333, 0.5096, 0.3548]}, {"w": "and", "b": [0.5151, 0.3333, 0.5466, 0.3548]}, {"w": "unfortunately", "b": [0.5522, 0.3333, 0.6667, 0.3548]}, {"w": "machines", "b": [0.6722, 0.3333, 0.7519, 0.3548]}, {"w": "can", "b": [0.7574, 0.3333, 0.7867, 0.3548]}, {"w": "fall", "b": [0.7922, 0.3333, 0.8181, 0.3548]}, {"w": "into", "b": [0.8236, 0.3333, 0.8571, 0.3548]}, {"w": "the", "b": [0.1429, 0.3524, 0.1692, 0.3738]}, {"w": "same", "b": [0.1759, 0.3524, 0.2186, 0.3738]}, {"w": "trap", "b": [0.2253, 0.3524, 0.2591, 0.3738]}, {"w": "if", "b": [0.2658, 0.3524, 0.2775, 0.3738]}, {"w": "we", "b": [0.2842, 0.3524, 0.3074, 0.3738]}, {"w": "are", "b": [0.3141, 0.3524, 0.3398, 0.3738]}, {"w": "not", "b": [0.3465, 0.3524, 0.3749, 0.3738]}, {"w": "careful.", "b": [0.3816, 0.3524, 0.4434, 0.3738]}, {"w": "In", "b": [0.4501, 0.3524, 0.4686, 0.3738]}, {"w": "Machine", "b": [0.4753, 0.3524, 0.5484, 0.3738]}, {"w": "Learning", "b": [0.5551, 0.3524, 0.6302, 0.3738]}, {"w": "this", "b": [0.6369, 0.3524, 0.6676, 0.3738]}, {"w": "is", "b": [0.6743, 0.3524, 0.6875, 0.3738]}, {"w": "called", "b": [0.6942, 0.3524, 0.7426, 0.3738]}, {"w": "overfitting:", "b": [0.7493, 0.3522, 0.8385, 0.3738]}, {"w": "it", "b": [0.8452, 0.3524, 0.8571, 0.3738]}, {"w": "means", "b": [0.1428, 0.3714, 0.197, 0.3929]}, {"w": "that", "b": [0.2035, 0.3714, 0.2361, 0.3929]}, {"w": "the", "b": [0.2427, 0.3714, 0.269, 0.3929]}, {"w": "model", "b": [0.2756, 0.3714, 0.3284, 0.3929]}, {"w": "performs", "b": [0.335, 0.3714, 0.4117, 0.3929]}, {"w": "well", "b": [0.4183, 0.3714, 0.452, 0.3929]}, {"w": "on", "b": [0.4586, 0.3714, 0.4806, 0.3929]}, {"w": "the", "b": [0.4872, 0.3714, 0.5135, 0.3929]}, {"w": "training", "b": [0.5201, 0.3714, 0.587, 0.3929]}, {"w": "data,", "b": [0.5936, 0.3714, 0.6336, 0.3929]}, {"w": "but", "b": [0.6402, 0.3714, 0.6682, 0.3929]}, {"w": "it", "b": [0.6748, 0.3714, 0.6867, 0.3929]}, {"w": "does", "b": [0.6933, 0.3714, 0.7314, 0.3929]}, {"w": "not", "b": [0.738, 0.3714, 0.7664, 0.3929]}, {"w": "generalize", "b": [0.7729, 0.3714, 0.8571, 0.3929]}, {"w": "well.", "b": [0.1429, 0.3905, 0.1813, 0.4119]}]}, {"id": "b_6", "type": "paragraph", "text": "Figure 1-22 shows an example of a high-degree polynomial life satisfaction model that strongly overfits the training data. Even though it performs much better on the training data than the simple linear model, would you really trust its predictions?", "words": [{"w": "Figure", "b": [0.1429, 0.4186, 0.1969, 0.44]}, {"w": "1-22", "b": [0.2048, 0.4186, 0.2422, 0.44]}, {"w": "shows", "b": [0.2502, 0.4186, 0.3015, 0.44]}, {"w": "an", "b": [0.3094, 0.4186, 0.3299, 0.44]}, {"w": "example", "b": [0.3379, 0.4186, 0.4074, 0.44]}, {"w": "of", "b": [0.4154, 0.4186, 0.4321, 0.44]}, {"w": "a", "b": [0.4401, 0.4186, 0.4492, 0.44]}, {"w": "high-degree", "b": [0.4572, 0.4186, 0.5572, 0.44]}, {"w": "polynomial", "b": [0.5651, 0.4186, 0.6606, 0.44]}, {"w": "life", "b": [0.6685, 0.4186, 0.6944, 0.44]}, {"w": "satisfaction", "b": [0.7023, 0.4186, 0.7964, 0.44]}, {"w": "model", "b": [0.8043, 0.4186, 0.8571, 0.44]}, {"w": "that", "b": [0.1429, 0.4377, 0.1754, 0.4591]}, {"w": "strongly", "b": [0.1818, 0.4377, 0.2501, 0.4591]}, {"w": "overfits", "b": [0.2565, 0.4377, 0.3191, 0.4591]}, {"w": "the", "b": [0.3255, 0.4377, 0.3518, 0.4591]}, {"w": "training", "b": [0.3582, 0.4377, 0.4251, 0.4591]}, {"w": "data.", "b": [0.4315, 0.4377, 0.4715, 0.4591]}, {"w": "Even", "b": [0.4778, 0.4377, 0.5191, 0.4591]}, {"w": "though", "b": [0.5255, 0.4377, 0.5855, 0.4591]}, {"w": "it", "b": [0.5919, 0.4377, 0.6038, 0.4591]}, {"w": "performs", "b": [0.6102, 0.4377, 0.6869, 0.4591]}, {"w": "much", "b": [0.6933, 0.4377, 0.741, 0.4591]}, {"w": "better", "b": [0.7473, 0.4377, 0.7961, 0.4591]}, {"w": "on", "b": [0.8024, 0.4377, 0.8244, 0.4591]}, {"w": "the", "b": [0.8308, 0.4377, 0.8571, 0.4591]}, {"w": "training", "b": [0.1429, 0.4567, 0.2098, 0.4781]}, {"w": "data", "b": [0.2145, 0.4567, 0.2498, 0.4781]}, {"w": "than", "b": [0.2545, 0.4567, 0.2925, 0.4781]}, {"w": "the", "b": [0.2972, 0.4567, 0.3236, 0.4781]}, {"w": "simple", "b": [0.3283, 0.4567, 0.3832, 0.4781]}, {"w": "linear", "b": [0.388, 0.4567, 0.436, 0.4781]}, {"w": "model,", "b": [0.4407, 0.4567, 0.4982, 0.4781]}, {"w": "would", "b": [0.503, 0.4567, 0.5552, 0.4781]}, {"w": "you", "b": [0.5599, 0.4567, 0.5912, 0.4781]}, {"w": "really", "b": [0.5959, 0.4567, 0.6417, 0.4781]}, {"w": "trust", "b": [0.6465, 0.4567, 0.6856, 0.4781]}, {"w": "its", "b": [0.6904, 0.4567, 0.7099, 0.4781]}, {"w": "predictions?", "b": [0.7147, 0.4567, 0.8171, 0.4781]}]}, {"id": "b_7", "type": "equation", "text": "Figure 1-22. Overfitting the training data", "words": [{"w": "Figure", "b": [0.1429, 0.6891, 0.1943, 0.7108]}, {"w": "1-22.", "b": [0.1991, 0.6891, 0.2407, 0.7108]}, {"w": "Overfitting", "b": [0.2455, 0.6891, 0.3349, 0.7108]}, {"w": "the", "b": [0.3397, 0.6891, 0.3647, 0.7108]}, {"w": "training", "b": [0.3695, 0.6891, 0.4339, 0.7108]}, {"w": "data", "b": [0.4387, 0.6891, 0.4753, 0.7108]}]}, {"id": "b_8", "type": "paragraph", "text": "Complex models such as deep neural networks can detect subtle patterns in the data, but if the training set is noisy, or if it is too small (which introduces sampling noise), then the model is likely to detect patterns in the noise itself. Obviously these patterns will not generalize to new instances. For example, say you feed your life satisfaction model many more attributes, including uninformative ones such as the country’s name. In that case, a complex model may detect patterns like the fact that all coun‐ tries in the training data with a w in their name have a life satisfaction greater than 7: New Zealand (7.3), Norway (7.4), Sweden (7.2), and Switzerland (7.5). How confident", "words": [{"w": "Complex", "b": [0.1429, 0.7265, 0.2189, 0.7479]}, {"w": "models", "b": [0.2244, 0.7265, 0.2848, 0.7479]}, {"w": "such", "b": [0.2903, 0.7265, 0.329, 0.7479]}, {"w": "as", "b": [0.3345, 0.7265, 0.3512, 0.7479]}, {"w": "deep", "b": [0.3567, 0.7265, 0.3964, 0.7479]}, {"w": "neural", "b": [0.4019, 0.7265, 0.4553, 0.7479]}, {"w": "networks", "b": [0.4608, 0.7265, 0.538, 0.7479]}, {"w": "can", "b": [0.5435, 0.7265, 0.5729, 0.7479]}, {"w": "detect", "b": [0.5784, 0.7265, 0.6286, 0.7479]}, {"w": "subtle", "b": [0.6341, 0.7265, 0.6839, 0.7479]}, {"w": "patterns", "b": [0.6893, 0.7265, 0.7573, 0.7479]}, {"w": "in", "b": [0.7628, 0.7265, 0.7798, 0.7479]}, {"w": "the", "b": [0.7853, 0.7265, 0.8116, 0.7479]}, {"w": "data,", "b": [0.8171, 0.7265, 0.8571, 0.7479]}, {"w": "but", "b": [0.1429, 0.7456, 0.1709, 0.767]}, {"w": "if", "b": [0.1765, 0.7456, 0.1883, 0.767]}, {"w": "the", "b": [0.1939, 0.7456, 0.2203, 0.767]}, {"w": "training", "b": [0.2259, 0.7456, 0.2929, 0.767]}, {"w": "set", "b": [0.2985, 0.7456, 0.3214, 0.767]}, {"w": "is", "b": [0.3271, 0.7456, 0.3403, 0.767]}, {"w": "noisy,", "b": [0.346, 0.7456, 0.394, 0.767]}, {"w": "or", "b": [0.3997, 0.7456, 0.418, 0.767]}, {"w": "if", "b": [0.4237, 0.7456, 0.4354, 0.767]}, {"w": "it", "b": [0.4411, 0.7456, 0.453, 0.767]}, {"w": "is", "b": [0.4587, 0.7456, 0.4719, 0.767]}, {"w": "too", "b": [0.4776, 0.7456, 0.5052, 0.767]}, {"w": "small", "b": [0.5109, 0.7456, 0.5553, 0.767]}, {"w": "(which", "b": [0.5609, 0.7456, 0.6191, 0.767]}, {"w": "introduces", "b": [0.6247, 0.7456, 0.7134, 0.767]}, {"w": "sampling", "b": [0.7191, 0.7456, 0.7954, 0.767]}, {"w": "noise),", "b": [0.8011, 0.7456, 0.8572, 0.767]}, {"w": "then", "b": [0.1429, 0.7646, 0.1806, 0.786]}, {"w": "the", "b": [0.186, 0.7646, 0.2123, 0.786]}, {"w": "model", "b": [0.2177, 0.7646, 0.2705, 0.786]}, {"w": "is", "b": [0.276, 0.7646, 0.2892, 0.786]}, {"w": "likely", "b": [0.2946, 0.7646, 0.3395, 0.786]}, {"w": "to", "b": [0.3449, 0.7646, 0.3618, 0.786]}, {"w": "detect", "b": [0.3673, 0.7646, 0.4175, 0.786]}, {"w": "patterns", "b": [0.4229, 0.7646, 0.4909, 0.786]}, {"w": "in", "b": [0.4963, 0.7646, 0.5133, 0.786]}, {"w": "the", "b": [0.5187, 0.7646, 0.545, 0.786]}, {"w": "noise", "b": [0.5504, 0.7646, 0.5945, 0.786]}, {"w": "itself.", "b": [0.5999, 0.7646, 0.6446, 0.786]}, {"w": "Obviously", "b": [0.65, 0.7646, 0.7355, 0.786]}, {"w": "these", "b": [0.7409, 0.7646, 0.7837, 0.786]}, {"w": "patterns", "b": [0.7891, 0.7646, 0.8571, 0.786]}, {"w": "will", "b": [0.1429, 0.7837, 0.1733, 0.8051]}, {"w": "not", "b": [0.1797, 0.7837, 0.2081, 0.8051]}, {"w": "generalize", "b": [0.2145, 0.7837, 0.2987, 0.8051]}, {"w": "to", "b": [0.3052, 0.7837, 0.3222, 0.8051]}, {"w": "new", "b": [0.3286, 0.7837, 0.3631, 0.8051]}, {"w": "instances.", "b": [0.3696, 0.7837, 0.4512, 0.8051]}, {"w": "For", "b": [0.4576, 0.7837, 0.4866, 0.8051]}, {"w": "example,", "b": [0.4931, 0.7837, 0.5674, 0.8051]}, {"w": "say", "b": [0.5738, 0.7837, 0.5998, 0.8051]}, {"w": "you", "b": [0.6063, 0.7837, 0.6375, 0.8051]}, {"w": "feed", "b": [0.644, 0.7837, 0.6789, 0.8051]}, {"w": "your", "b": [0.6853, 0.7837, 0.7243, 0.8051]}, {"w": "life", "b": [0.7307, 0.7837, 0.7566, 0.8051]}, {"w": "satisfaction", "b": [0.7631, 0.7837, 0.8571, 0.8051]}, {"w": "model", "b": [0.1428, 0.8027, 0.1957, 0.8241]}, {"w": "many", "b": [0.2047, 0.8027, 0.2514, 0.8241]}, {"w": "more", "b": [0.2604, 0.8027, 0.3046, 0.8241]}, {"w": "attributes,", "b": [0.3136, 0.8027, 0.3977, 0.8241]}, {"w": "including", "b": [0.4067, 0.8027, 0.4865, 0.8241]}, {"w": "uninformative", "b": [0.4955, 0.8027, 0.6157, 0.8241]}, {"w": "ones", "b": [0.6247, 0.8027, 0.6633, 0.8241]}, {"w": "such", "b": [0.6723, 0.8027, 0.7109, 0.8241]}, {"w": "as", "b": [0.7199, 0.8027, 0.7367, 0.8241]}, {"w": "the", "b": [0.7457, 0.8027, 0.7721, 0.8241]}, {"w": "country’s", "b": [0.7811, 0.8027, 0.8571, 0.8241]}, {"w": "name.", "b": [0.1429, 0.8218, 0.1941, 0.8432]}, {"w": "In", "b": [0.2006, 0.8218, 0.2191, 0.8432]}, {"w": "that", "b": [0.2256, 0.8218, 0.2582, 0.8432]}, {"w": "case,", "b": [0.2647, 0.8218, 0.3039, 0.8432]}, {"w": "a", "b": [0.3104, 0.8218, 0.3196, 0.8432]}, {"w": "complex", "b": [0.3261, 0.8218, 0.3971, 0.8432]}, {"w": "model", "b": [0.4036, 0.8218, 0.4564, 0.8432]}, {"w": "may", "b": [0.4629, 0.8218, 0.4983, 0.8432]}, {"w": "detect", "b": [0.5048, 0.8218, 0.5551, 0.8432]}, {"w": "patterns", "b": [0.5616, 0.8218, 0.6296, 0.8432]}, {"w": "like", "b": [0.6361, 0.8218, 0.6662, 0.8432]}, {"w": "the", "b": [0.6727, 0.8218, 0.699, 0.8432]}, {"w": "fact", "b": [0.7055, 0.8218, 0.736, 0.8432]}, {"w": "that", "b": [0.7425, 0.8218, 0.7751, 0.8432]}, {"w": "all", "b": [0.7816, 0.8218, 0.8013, 0.8432]}, {"w": "coun‐", "b": [0.8078, 0.8218, 0.8572, 0.8432]}, {"w": "tries", "b": [0.1429, 0.8408, 0.179, 0.8622]}, {"w": "in", "b": [0.1844, 0.8408, 0.2013, 0.8622]}, {"w": "the", "b": [0.2067, 0.8408, 0.233, 0.8622]}, {"w": "training", "b": [0.2384, 0.8408, 0.3053, 0.8622]}, {"w": "data", "b": [0.3106, 0.8408, 0.3459, 0.8622]}, {"w": "with", "b": [0.3512, 0.8408, 0.3886, 0.8622]}, {"w": "a", "b": [0.3939, 0.8408, 0.4031, 0.8622]}, {"w": "w", "b": [0.4084, 0.8406, 0.4224, 0.8622]}, {"w": "in", "b": [0.4277, 0.8408, 0.4447, 0.8622]}, {"w": "their", "b": [0.45, 0.8408, 0.4897, 0.8622]}, {"w": "name", "b": [0.495, 0.8408, 0.5415, 0.8622]}, {"w": "have", "b": [0.5468, 0.8408, 0.5852, 0.8622]}, {"w": "a", "b": [0.5905, 0.8408, 0.5997, 0.8622]}, {"w": "life", "b": [0.605, 0.8408, 0.6309, 0.8622]}, {"w": "satisfaction", "b": [0.6363, 0.8408, 0.7303, 0.8622]}, {"w": "greater", "b": [0.7357, 0.8408, 0.7937, 0.8622]}, {"w": "than", "b": [0.799, 0.8408, 0.837, 0.8622]}, {"w": "7:", "b": [0.8424, 0.8408, 0.8571, 0.8622]}, {"w": "New", "b": [0.1429, 0.8599, 0.1809, 0.8813]}, {"w": "Zealand", "b": [0.1857, 0.8599, 0.2531, 0.8813]}, {"w": "(7.3),", "b": [0.2578, 0.8599, 0.3017, 0.8813]}, {"w": "Norway", "b": [0.3064, 0.8599, 0.3729, 0.8813]}, {"w": "(7.4),", "b": [0.3777, 0.8599, 0.4216, 0.8813]}, {"w": "Sweden", "b": [0.4263, 0.8599, 0.4906, 0.8813]}, {"w": "(7.2),", "b": [0.4953, 0.8599, 0.5392, 0.8813]}, {"w": "and", "b": [0.5439, 0.8599, 0.5755, 0.8813]}, {"w": "Switzerland", "b": [0.5802, 0.8599, 0.6784, 0.8813]}, {"w": "(7.5).", "b": [0.6832, 0.8599, 0.7271, 0.8813]}, {"w": "How", "b": [0.7318, 0.8599, 0.7722, 0.8813]}, {"w": "confident", "b": [0.7769, 0.8599, 0.8567, 0.8813]}]}, {"id": "b_9", "type": "paragraph", "text": "28 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "28", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.3371, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 55, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "are you that the W-satisfaction rule generalizes to Rwanda or Zimbabwe? Obviously this pattern occurred in the training data by pure chance, but the model has no way to tell whether a pattern is real or simply the result of noise in the data.", "words": [{"w": "are", "b": [0.1429, 0.0791, 0.1686, 0.1005]}, {"w": "you", "b": [0.1748, 0.0791, 0.2061, 0.1005]}, {"w": "that", "b": [0.2123, 0.0791, 0.2449, 0.1005]}, {"w": "the", "b": [0.2511, 0.0791, 0.2775, 0.1005]}, {"w": "W-satisfaction", "b": [0.2837, 0.0791, 0.4041, 0.1005]}, {"w": "rule", "b": [0.4103, 0.0791, 0.4433, 0.1005]}, {"w": "generalizes", "b": [0.4495, 0.0791, 0.5413, 0.1005]}, {"w": "to", "b": [0.5476, 0.0791, 0.5645, 0.1005]}, {"w": "Rwanda", "b": [0.5708, 0.0791, 0.638, 0.1005]}, {"w": "or", "b": [0.6442, 0.0791, 0.6626, 0.1005]}, {"w": "Zimbabwe?", "b": [0.6688, 0.0791, 0.7654, 0.1005]}, {"w": "Obviously", "b": [0.7716, 0.0791, 0.8571, 0.1005]}, {"w": "this", "b": [0.1429, 0.0981, 0.1736, 0.1195]}, {"w": "pattern", "b": [0.1797, 0.0981, 0.24, 0.1195]}, {"w": "occurred", "b": [0.2462, 0.0981, 0.3208, 0.1195]}, {"w": "in", "b": [0.3269, 0.0981, 0.3439, 0.1195]}, {"w": "the", "b": [0.35, 0.0981, 0.3763, 0.1195]}, {"w": "training", "b": [0.3825, 0.0981, 0.4494, 0.1195]}, {"w": "data", "b": [0.4555, 0.0981, 0.4908, 0.1195]}, {"w": "by", "b": [0.4969, 0.0981, 0.517, 0.1195]}, {"w": "pure", "b": [0.5231, 0.0981, 0.5617, 0.1195]}, {"w": "chance,", "b": [0.5678, 0.0981, 0.6307, 0.1195]}, {"w": "but", "b": [0.6368, 0.0981, 0.6648, 0.1195]}, {"w": "the", "b": [0.671, 0.0981, 0.6973, 0.1195]}, {"w": "model", "b": [0.7034, 0.0981, 0.7562, 0.1195]}, {"w": "has", "b": [0.7624, 0.0981, 0.7903, 0.1195]}, {"w": "no", "b": [0.7964, 0.0981, 0.8184, 0.1195]}, {"w": "way", "b": [0.8245, 0.0981, 0.8571, 0.1195]}, {"w": "to", "b": [0.1429, 0.1172, 0.1598, 0.1386]}, {"w": "tell", "b": [0.1646, 0.1172, 0.1903, 0.1386]}, {"w": "whether", "b": [0.1951, 0.1172, 0.2634, 0.1386]}, {"w": "a", "b": [0.2681, 0.1172, 0.2772, 0.1386]}, {"w": "pattern", "b": [0.282, 0.1172, 0.3423, 0.1386]}, {"w": "is", "b": [0.3471, 0.1172, 0.3603, 0.1386]}, {"w": "real", "b": [0.365, 0.1172, 0.396, 0.1386]}, {"w": "or", "b": [0.4007, 0.1172, 0.4191, 0.1386]}, {"w": "simply", "b": [0.4238, 0.1172, 0.4795, 0.1386]}, {"w": "the", "b": [0.4842, 0.1172, 0.5105, 0.1386]}, {"w": "result", "b": [0.5153, 0.1172, 0.5622, 0.1386]}, {"w": "of", "b": [0.5669, 0.1172, 0.5837, 0.1386]}, {"w": "noise", "b": [0.5884, 0.1172, 0.6325, 0.1386]}, {"w": "in", "b": [0.6373, 0.1172, 0.6542, 0.1386]}, {"w": "the", "b": [0.659, 0.1172, 0.6853, 0.1386]}, {"w": "data.", "b": [0.69, 0.1172, 0.73, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "Overfitting happens when the model is too complex relative to the amount and noisiness of the training data. The possible solutions are:", "words": [{"w": "Overfitting", "b": [0.2714, 0.1591, 0.3567, 0.1787]}, {"w": "happens", "b": [0.3621, 0.1591, 0.4257, 0.1787]}, {"w": "when", "b": [0.4311, 0.1591, 0.4728, 0.1787]}, {"w": "the", "b": [0.4782, 0.1591, 0.5023, 0.1787]}, {"w": "model", "b": [0.5076, 0.1591, 0.5559, 0.1787]}, {"w": "is", "b": [0.5613, 0.1591, 0.5734, 0.1787]}, {"w": "too", "b": [0.5787, 0.1591, 0.604, 0.1787]}, {"w": "complex", "b": [0.6093, 0.1591, 0.6742, 0.1787]}, {"w": "relative", "b": [0.6796, 0.1591, 0.7354, 0.1787]}, {"w": "to", "b": [0.7407, 0.1591, 0.7563, 0.1787]}, {"w": "the", "b": [0.7616, 0.1591, 0.7857, 0.1787]}, {"w": "amount", "b": [0.2714, 0.1765, 0.3311, 0.1961]}, {"w": "and", "b": [0.3375, 0.1765, 0.3663, 0.1961]}, {"w": "noisiness", "b": [0.3727, 0.1765, 0.4426, 0.1961]}, {"w": "of", "b": [0.449, 0.1765, 0.4643, 0.1961]}, {"w": "the", "b": [0.4707, 0.1765, 0.4948, 0.1961]}, {"w": "training", "b": [0.5012, 0.1765, 0.5624, 0.1961]}, {"w": "data.", "b": [0.5688, 0.1765, 0.6054, 0.1961]}, {"w": "The", "b": [0.6118, 0.1765, 0.6418, 0.1961]}, {"w": "possible", "b": [0.6483, 0.1765, 0.7096, 0.1961]}, {"w": "solutions", "b": [0.716, 0.1765, 0.7857, 0.1961]}, {"w": "are:", "b": [0.2714, 0.1939, 0.2993, 0.2135]}]}, {"id": "b_2", "type": "paragraph", "text": "• To simplify the model by selecting one with fewer parameters (e.g., a linear model rather than a high-degree polynomial model), by reducing the number of attributes in the training data or by constraining the model", "words": [{"w": "•", "b": [0.2902, 0.2234, 0.2976, 0.243]}, {"w": "To", "b": [0.3071, 0.2234, 0.3267, 0.243]}, {"w": "simplify", "b": [0.3323, 0.2234, 0.3942, 0.243]}, {"w": "the", "b": [0.3998, 0.2234, 0.4239, 0.243]}, {"w": "model", "b": [0.4295, 0.2234, 0.4778, 0.243]}, {"w": "by", "b": [0.4834, 0.2234, 0.5018, 0.243]}, {"w": "selecting", "b": [0.5074, 0.2234, 0.5737, 0.243]}, {"w": "one", "b": [0.5792, 0.2234, 0.6075, 0.243]}, {"w": "with", "b": [0.613, 0.2234, 0.6472, 0.243]}, {"w": "fewer", "b": [0.6528, 0.2234, 0.6947, 0.243]}, {"w": "parameters", "b": [0.7003, 0.2234, 0.7857, 0.243]}, {"w": "(e.g.,", "b": [0.3071, 0.2409, 0.3438, 0.2604]}, {"w": "a", "b": [0.3529, 0.2409, 0.3613, 0.2604]}, {"w": "linear", "b": [0.3705, 0.2409, 0.4143, 0.2604]}, {"w": "model", "b": [0.4235, 0.2409, 0.4718, 0.2604]}, {"w": "rather", "b": [0.481, 0.2409, 0.5272, 0.2604]}, {"w": "than", "b": [0.5363, 0.2409, 0.5711, 0.2604]}, {"w": "a", "b": [0.5803, 0.2409, 0.5886, 0.2604]}, {"w": "high-degree", "b": [0.5978, 0.2409, 0.6893, 0.2604]}, {"w": "polynomial", "b": [0.6984, 0.2409, 0.7857, 0.2604]}, {"w": "model),", "b": [0.3071, 0.2583, 0.3663, 0.2778]}, {"w": "by", "b": [0.373, 0.2583, 0.3914, 0.2778]}, {"w": "reducing", "b": [0.3981, 0.2583, 0.4659, 0.2778]}, {"w": "the", "b": [0.4725, 0.2583, 0.4966, 0.2778]}, {"w": "number", "b": [0.5033, 0.2583, 0.5639, 0.2778]}, {"w": "of", "b": [0.5705, 0.2583, 0.5859, 0.2778]}, {"w": "attributes", "b": [0.5925, 0.2583, 0.665, 0.2778]}, {"w": "in", "b": [0.6716, 0.2583, 0.6871, 0.2778]}, {"w": "the", "b": [0.6938, 0.2583, 0.7179, 0.2778]}, {"w": "training", "b": [0.7245, 0.2583, 0.7857, 0.2778]}, {"w": "data", "b": [0.3071, 0.2757, 0.3394, 0.2953]}, {"w": "or", "b": [0.3437, 0.2757, 0.3605, 0.2953]}, {"w": "by", "b": [0.3648, 0.2757, 0.3832, 0.2953]}, {"w": "constraining", "b": [0.3875, 0.2757, 0.4839, 0.2953]}, {"w": "the", "b": [0.4882, 0.2757, 0.5123, 0.2953]}, {"w": "model", "b": [0.5166, 0.2757, 0.5649, 0.2953]}]}, {"id": "b_3", "type": "paragraph", "text": "• To gather more training data", "words": [{"w": "•", "b": [0.2902, 0.2991, 0.2976, 0.3187]}, {"w": "To", "b": [0.3071, 0.2991, 0.3267, 0.3187]}, {"w": "gather", "b": [0.331, 0.2991, 0.3791, 0.3187]}, {"w": "more", "b": [0.3834, 0.2991, 0.4239, 0.3187]}, {"w": "training", "b": [0.4282, 0.2991, 0.4894, 0.3187]}, {"w": "data", "b": [0.4938, 0.2991, 0.526, 0.3187]}]}, {"id": "b_4", "type": "paragraph", "text": "• To reduce the noise in the training data (e.g., fix data errors and remove outliers)", "words": [{"w": "•", "b": [0.2902, 0.3226, 0.2976, 0.3422]}, {"w": "To", "b": [0.3071, 0.3226, 0.3267, 0.3422]}, {"w": "reduce", "b": [0.3336, 0.3226, 0.3851, 0.3422]}, {"w": "the", "b": [0.3919, 0.3226, 0.416, 0.3422]}, {"w": "noise", "b": [0.4229, 0.3226, 0.4632, 0.3422]}, {"w": "in", "b": [0.4701, 0.3226, 0.4856, 0.3422]}, {"w": "the", "b": [0.4924, 0.3226, 0.5165, 0.3422]}, {"w": "training", "b": [0.5234, 0.3226, 0.5846, 0.3422]}, {"w": "data", "b": [0.5914, 0.3226, 0.6237, 0.3422]}, {"w": "(e.g.,", "b": [0.6305, 0.3226, 0.6672, 0.3422]}, {"w": "fix", "b": [0.674, 0.3226, 0.6938, 0.3422]}, {"w": "data", "b": [0.7006, 0.3226, 0.7329, 0.3422]}, {"w": "errors", "b": [0.7397, 0.3226, 0.7857, 0.3422]}, {"w": "and", "b": [0.3071, 0.34, 0.336, 0.3596]}, {"w": "remove", "b": [0.3403, 0.34, 0.3977, 0.3596]}, {"w": "outliers)", "b": [0.402, 0.34, 0.4663, 0.3596]}]}, {"id": "b_5", "type": "paragraph", "text": "Constraining a model to make it simpler and reduce the risk of overfitting is called regularization. For example, the linear model we defined earlier has two parameters, θ0 and θ1. This gives the learning algorithm two degrees of freedom to adapt the model to the training data: it can tweak both the height (θ0) and the slope (θ1) of the line. If we forced θ1 = 0, the algorithm would have only one degree of freedom and would have a much harder time fitting the data properly: all it could do is move the line up or down to get as close as possible to the training instances, so it would end up around the mean. A very simple model indeed! If we allow the algorithm to modify θ1 but we force it to keep it small, then the learning algorithm will effectively have some‐ where in between one and two degrees of freedom. It will produce a simpler model than with two degrees of freedom, but more complex than with just one. You want to find the right balance between fitting the training data perfectly and keeping the model simple enough to ensure that it will generalize well.", "words": [{"w": "Constraining", "b": [0.1428, 0.395, 0.2533, 0.4164]}, {"w": "a", "b": [0.2599, 0.395, 0.2691, 0.4164]}, {"w": "model", "b": [0.2757, 0.395, 0.3285, 0.4164]}, {"w": "to", "b": [0.3352, 0.395, 0.3522, 0.4164]}, {"w": "make", "b": [0.3588, 0.395, 0.4042, 0.4164]}, {"w": "it", "b": [0.4109, 0.395, 0.4228, 0.4164]}, {"w": "simpler", "b": [0.4294, 0.395, 0.4921, 0.4164]}, {"w": "and", "b": [0.4987, 0.395, 0.5303, 0.4164]}, {"w": "reduce", "b": [0.5369, 0.395, 0.5932, 0.4164]}, {"w": "the", "b": [0.5999, 0.395, 0.6262, 0.4164]}, {"w": "risk", "b": [0.6329, 0.395, 0.6641, 0.4164]}, {"w": "of", "b": [0.6708, 0.395, 0.6876, 0.4164]}, {"w": "overfitting", "b": [0.6942, 0.395, 0.7823, 0.4164]}, {"w": "is", "b": [0.7889, 0.395, 0.8021, 0.4164]}, {"w": "called", "b": [0.8088, 0.395, 0.8571, 0.4164]}, {"w": "regularization.", "b": [0.1429, 0.4139, 0.2623, 0.4355]}, {"w": "For", "b": [0.2685, 0.4141, 0.2975, 0.4355]}, {"w": "example,", "b": [0.3037, 0.4141, 0.378, 0.4355]}, {"w": "the", "b": [0.3841, 0.4141, 0.4105, 0.4355]}, {"w": "linear", "b": [0.4166, 0.4141, 0.4646, 0.4355]}, {"w": "model", "b": [0.4708, 0.4141, 0.5236, 0.4355]}, {"w": "we", "b": [0.5298, 0.4141, 0.5529, 0.4355]}, {"w": "defined", "b": [0.5591, 0.4141, 0.6219, 0.4355]}, {"w": "earlier", "b": [0.6281, 0.4141, 0.6813, 0.4355]}, {"w": "has", "b": [0.6874, 0.4141, 0.7154, 0.4355]}, {"w": "two", "b": [0.7215, 0.4141, 0.7528, 0.4355]}, {"w": "parameters,", "b": [0.759, 0.4141, 0.8571, 0.4355]}, {"w": "θ0", "b": [0.1429, 0.4329, 0.1588, 0.4554]}, {"w": "and", "b": [0.1639, 0.4331, 0.1954, 0.4545]}, {"w": "θ1.", "b": [0.2005, 0.4329, 0.2212, 0.4554]}, {"w": "This", "b": [0.2263, 0.4331, 0.2635, 0.4545]}, {"w": "gives", "b": [0.2686, 0.4331, 0.3101, 0.4545]}, {"w": "the", "b": [0.3152, 0.4331, 0.3415, 0.4545]}, {"w": "learning", "b": [0.3466, 0.4331, 0.4157, 0.4545]}, {"w": "algorithm", "b": [0.4208, 0.4331, 0.5035, 0.4545]}, {"w": "two", "b": [0.5086, 0.4331, 0.5398, 0.4545]}, {"w": "degrees", "b": [0.5449, 0.4329, 0.6031, 0.4545]}, {"w": "of", "b": [0.6082, 0.4329, 0.6234, 0.4545]}, {"w": "freedom", "b": [0.6285, 0.4329, 0.6945, 0.4545]}, {"w": "to", "b": [0.6996, 0.4331, 0.7166, 0.4545]}, {"w": "adapt", "b": [0.7216, 0.4331, 0.7678, 0.4545]}, {"w": "the", "b": [0.7729, 0.4331, 0.7992, 0.4545]}, {"w": "model", "b": [0.8043, 0.4331, 0.8571, 0.4545]}, {"w": "to", "b": [0.1428, 0.4522, 0.1598, 0.4736]}, {"w": "the", "b": [0.1655, 0.4522, 0.1918, 0.4736]}, {"w": "training", "b": [0.1975, 0.4522, 0.2645, 0.4736]}, {"w": "data:", "b": [0.2701, 0.4522, 0.3101, 0.4736]}, {"w": "it", "b": [0.3158, 0.4522, 0.3278, 0.4736]}, {"w": "can", "b": [0.3334, 0.4522, 0.3628, 0.4736]}, {"w": "tweak", "b": [0.3685, 0.4522, 0.4174, 0.4736]}, {"w": "both", "b": [0.4231, 0.4522, 0.4618, 0.4736]}, {"w": "the", "b": [0.4675, 0.4522, 0.4938, 0.4736]}, {"w": "height", "b": [0.4995, 0.4522, 0.5519, 0.4736]}, {"w": "(θ0)", "b": [0.5576, 0.4519, 0.5879, 0.4745]}, {"w": "and", "b": [0.5936, 0.4522, 0.6251, 0.4736]}, {"w": "the", "b": [0.6308, 0.4522, 0.6572, 0.4736]}, {"w": "slope", "b": [0.6628, 0.4522, 0.7061, 0.4736]}, {"w": "(θ1)", "b": [0.7118, 0.4519, 0.7422, 0.4745]}, {"w": "of", "b": [0.7479, 0.4522, 0.7646, 0.4736]}, {"w": "the", "b": [0.7703, 0.4522, 0.7967, 0.4736]}, {"w": "line.", "b": [0.8023, 0.4522, 0.8382, 0.4736]}, {"w": "If", "b": [0.8439, 0.4522, 0.8571, 0.4736]}, {"w": "we", "b": [0.1429, 0.4712, 0.166, 0.4926]}, {"w": "forced", "b": [0.1728, 0.4712, 0.226, 0.4926]}, {"w": "θ1", "b": [0.2328, 0.471, 0.2487, 0.4935]}, {"w": "=", "b": [0.2555, 0.4712, 0.2676, 0.4926]}, {"w": "0,", "b": [0.2744, 0.4712, 0.2891, 0.4926]}, {"w": "the", "b": [0.2959, 0.4712, 0.3223, 0.4926]}, {"w": "algorithm", "b": [0.3291, 0.4712, 0.4117, 0.4926]}, {"w": "would", "b": [0.4185, 0.4712, 0.4707, 0.4926]}, {"w": "have", "b": [0.4775, 0.4712, 0.5159, 0.4926]}, {"w": "only", "b": [0.5227, 0.4712, 0.5596, 0.4926]}, {"w": "one", "b": [0.5664, 0.4712, 0.5973, 0.4926]}, {"w": "degree", "b": [0.6041, 0.4712, 0.6591, 0.4926]}, {"w": "of", "b": [0.6659, 0.4712, 0.6827, 0.4926]}, {"w": "freedom", "b": [0.6895, 0.4712, 0.7598, 0.4926]}, {"w": "and", "b": [0.7666, 0.4712, 0.7981, 0.4926]}, {"w": "would", "b": [0.8049, 0.4712, 0.8571, 0.4926]}, {"w": "have", "b": [0.1428, 0.4902, 0.1812, 0.5117]}, {"w": "a", "b": [0.187, 0.4902, 0.1961, 0.5117]}, {"w": "much", "b": [0.2018, 0.4902, 0.2495, 0.5117]}, {"w": "harder", "b": [0.2552, 0.4902, 0.3108, 0.5117]}, {"w": "time", "b": [0.3165, 0.4902, 0.3543, 0.5117]}, {"w": "fitting", "b": [0.36, 0.4902, 0.4112, 0.5117]}, {"w": "the", "b": [0.4169, 0.4902, 0.4433, 0.5117]}, {"w": "data", "b": [0.449, 0.4902, 0.4842, 0.5117]}, {"w": "properly:", "b": [0.4899, 0.4902, 0.5669, 0.5117]}, {"w": "all", "b": [0.5726, 0.4902, 0.5923, 0.5117]}, {"w": "it", "b": [0.598, 0.4902, 0.61, 0.5117]}, {"w": "could", "b": [0.6157, 0.4902, 0.6624, 0.5117]}, {"w": "do", "b": [0.6681, 0.4902, 0.6898, 0.5117]}, {"w": "is", "b": [0.6955, 0.4902, 0.7087, 0.5117]}, {"w": "move", "b": [0.7144, 0.4902, 0.7606, 0.5117]}, {"w": "the", "b": [0.7663, 0.4902, 0.7926, 0.5117]}, {"w": "line", "b": [0.7983, 0.4902, 0.8294, 0.5117]}, {"w": "up", "b": [0.8352, 0.4902, 0.8571, 0.5117]}, {"w": "or", "b": [0.1429, 0.5093, 0.1612, 0.5307]}, {"w": "down", "b": [0.1698, 0.5093, 0.2171, 0.5307]}, {"w": "to", "b": [0.2257, 0.5093, 0.2426, 0.5307]}, {"w": "get", "b": [0.2512, 0.5093, 0.2762, 0.5307]}, {"w": "as", "b": [0.2848, 0.5093, 0.3016, 0.5307]}, {"w": "close", "b": [0.3101, 0.5093, 0.3513, 0.5307]}, {"w": "as", "b": [0.3599, 0.5093, 0.3767, 0.5307]}, {"w": "possible", "b": [0.3853, 0.5093, 0.4524, 0.5307]}, {"w": "to", "b": [0.461, 0.5093, 0.478, 0.5307]}, {"w": "the", "b": [0.4866, 0.5093, 0.5129, 0.5307]}, {"w": "training", "b": [0.5215, 0.5093, 0.5884, 0.5307]}, {"w": "instances,", "b": [0.597, 0.5093, 0.6786, 0.5307]}, {"w": "so", "b": [0.6872, 0.5093, 0.7054, 0.5307]}, {"w": "it", "b": [0.714, 0.5093, 0.7259, 0.5307]}, {"w": "would", "b": [0.7345, 0.5093, 0.7868, 0.5307]}, {"w": "end", "b": [0.7953, 0.5093, 0.8266, 0.5307]}, {"w": "up", "b": [0.8352, 0.5093, 0.8571, 0.5307]}, {"w": "around", "b": [0.1429, 0.5283, 0.2038, 0.5498]}, {"w": "the", "b": [0.2085, 0.5283, 0.2349, 0.5498]}, {"w": "mean.", "b": [0.2396, 0.5283, 0.2908, 0.5498]}, {"w": "A", "b": [0.2955, 0.5283, 0.3099, 0.5498]}, {"w": "very", "b": [0.3147, 0.5283, 0.3511, 0.5498]}, {"w": "simple", "b": [0.3558, 0.5283, 0.4107, 0.5498]}, {"w": "model", "b": [0.4155, 0.5283, 0.4683, 0.5498]}, {"w": "indeed!", "b": [0.473, 0.5283, 0.5354, 0.5498]}, {"w": "If", "b": [0.5402, 0.5283, 0.5534, 0.5498]}, {"w": "we", "b": [0.5582, 0.5283, 0.5813, 0.5498]}, {"w": "allow", "b": [0.586, 0.5283, 0.6306, 0.5498]}, {"w": "the", "b": [0.6353, 0.5283, 0.6617, 0.5498]}, {"w": "algorithm", "b": [0.6664, 0.5283, 0.749, 0.5498]}, {"w": "to", "b": [0.7538, 0.5283, 0.7708, 0.5498]}, {"w": "modify", "b": [0.7755, 0.5283, 0.8358, 0.5498]}, {"w": "θ1", "b": [0.8412, 0.5281, 0.8571, 0.5506]}, {"w": "but", "b": [0.1429, 0.5474, 0.1709, 0.5688]}, {"w": "we", "b": [0.1756, 0.5474, 0.1988, 0.5688]}, {"w": "force", "b": [0.2035, 0.5474, 0.2457, 0.5688]}, {"w": "it", "b": [0.2505, 0.5474, 0.2624, 0.5688]}, {"w": "to", "b": [0.2672, 0.5474, 0.2842, 0.5688]}, {"w": "keep", "b": [0.289, 0.5474, 0.3279, 0.5688]}, {"w": "it", "b": [0.3327, 0.5474, 0.3447, 0.5688]}, {"w": "small,", "b": [0.3494, 0.5474, 0.3986, 0.5688]}, {"w": "then", "b": [0.4034, 0.5474, 0.4411, 0.5688]}, {"w": "the", "b": [0.4459, 0.5474, 0.4722, 0.5688]}, {"w": "learning", "b": [0.477, 0.5474, 0.5461, 0.5688]}, {"w": "algorithm", "b": [0.5509, 0.5474, 0.6335, 0.5688]}, {"w": "will", "b": [0.6383, 0.5474, 0.6687, 0.5688]}, {"w": "effectively", "b": [0.6735, 0.5474, 0.7576, 0.5688]}, {"w": "have", "b": [0.7624, 0.5474, 0.8008, 0.5688]}, {"w": "some‐", "b": [0.8055, 0.5474, 0.8571, 0.5688]}, {"w": "where", "b": [0.1429, 0.5664, 0.1937, 0.5879]}, {"w": "in", "b": [0.2003, 0.5664, 0.2173, 0.5879]}, {"w": "between", "b": [0.2239, 0.5664, 0.293, 0.5879]}, {"w": "one", "b": [0.2996, 0.5664, 0.3305, 0.5879]}, {"w": "and", "b": [0.3371, 0.5664, 0.3687, 0.5879]}, {"w": "two", "b": [0.3753, 0.5664, 0.4065, 0.5879]}, {"w": "degrees", "b": [0.4131, 0.5664, 0.4758, 0.5879]}, {"w": "of", "b": [0.4824, 0.5664, 0.4992, 0.5879]}, {"w": "freedom.", "b": [0.5058, 0.5664, 0.5809, 0.5879]}, {"w": "It", "b": [0.5875, 0.5664, 0.6001, 0.5879]}, {"w": "will", "b": [0.6067, 0.5664, 0.6371, 0.5879]}, {"w": "produce", "b": [0.6437, 0.5664, 0.7127, 0.5879]}, {"w": "a", "b": [0.7193, 0.5664, 0.7285, 0.5879]}, {"w": "simpler", "b": [0.7351, 0.5664, 0.7977, 0.5879]}, {"w": "model", "b": [0.8043, 0.5664, 0.8571, 0.5879]}, {"w": "than", "b": [0.1429, 0.5855, 0.1809, 0.6069]}, {"w": "with", "b": [0.1861, 0.5855, 0.2234, 0.6069]}, {"w": "two", "b": [0.2287, 0.5855, 0.2599, 0.6069]}, {"w": "degrees", "b": [0.2651, 0.5855, 0.3278, 0.6069]}, {"w": "of", "b": [0.3331, 0.5855, 0.3498, 0.6069]}, {"w": "freedom,", "b": [0.3551, 0.5855, 0.4301, 0.6069]}, {"w": "but", "b": [0.4353, 0.5855, 0.4633, 0.6069]}, {"w": "more", "b": [0.4686, 0.5855, 0.5128, 0.6069]}, {"w": "complex", "b": [0.5181, 0.5855, 0.5891, 0.6069]}, {"w": "than", "b": [0.5943, 0.5855, 0.6323, 0.6069]}, {"w": "with", "b": [0.6375, 0.5855, 0.6749, 0.6069]}, {"w": "just", "b": [0.6801, 0.5855, 0.7105, 0.6069]}, {"w": "one.", "b": [0.7157, 0.5855, 0.7513, 0.6069]}, {"w": "You", "b": [0.7566, 0.5855, 0.7889, 0.6069]}, {"w": "want", "b": [0.7942, 0.5855, 0.8349, 0.6069]}, {"w": "to", "b": [0.8402, 0.5855, 0.8571, 0.6069]}, {"w": "find", "b": [0.1428, 0.6045, 0.177, 0.6259]}, {"w": "the", "b": [0.1858, 0.6045, 0.2121, 0.6259]}, {"w": "right", "b": [0.2209, 0.6045, 0.2611, 0.6259]}, {"w": "balance", "b": [0.2698, 0.6045, 0.3331, 0.6259]}, {"w": "between", "b": [0.3418, 0.6045, 0.411, 0.6259]}, {"w": "fitting", "b": [0.4198, 0.6045, 0.471, 0.6259]}, {"w": "the", "b": [0.4798, 0.6045, 0.5061, 0.6259]}, {"w": "training", "b": [0.5149, 0.6045, 0.5818, 0.6259]}, {"w": "data", "b": [0.5906, 0.6045, 0.6259, 0.6259]}, {"w": "perfectly", "b": [0.6347, 0.6045, 0.7072, 0.6259]}, {"w": "and", "b": [0.716, 0.6045, 0.7475, 0.6259]}, {"w": "keeping", "b": [0.7563, 0.6045, 0.822, 0.6259]}, {"w": "the", "b": [0.8308, 0.6045, 0.8571, 0.6259]}, {"w": "model", "b": [0.1429, 0.6236, 0.1957, 0.645]}, {"w": "simple", "b": [0.2004, 0.6236, 0.2553, 0.645]}, {"w": "enough", "b": [0.2601, 0.6236, 0.3229, 0.645]}, {"w": "to", "b": [0.3276, 0.6236, 0.3446, 0.645]}, {"w": "ensure", "b": [0.3493, 0.6236, 0.4049, 0.645]}, {"w": "that", "b": [0.4096, 0.6236, 0.4422, 0.645]}, {"w": "it", "b": [0.4469, 0.6236, 0.4588, 0.645]}, {"w": "will", "b": [0.4636, 0.6236, 0.494, 0.645]}, {"w": "generalize", "b": [0.4987, 0.6236, 0.5829, 0.645]}, {"w": "well.", "b": [0.5876, 0.6236, 0.626, 0.645]}]}, {"id": "b_6", "type": "paragraph", "text": "Figure 1-23 shows three models: the dotted line represents the original model that was trained with a few countries missing, the dashed line is our second model trained with all countries, and the solid line is a linear model trained with the same data as the first model but with a regularization constraint. You can see that regularization forced the model to have a smaller slope, which fits a bit less the training data that the model was trained on, but actually allows it to generalize better to new examples.", "words": [{"w": "Figure", "b": [0.1429, 0.6517, 0.1969, 0.6731]}, {"w": "1-23", "b": [0.2043, 0.6517, 0.2417, 0.6731]}, {"w": "shows", "b": [0.2492, 0.6517, 0.3005, 0.6731]}, {"w": "three", "b": [0.3079, 0.6517, 0.3509, 0.6731]}, {"w": "models:", "b": [0.3583, 0.6517, 0.4235, 0.6731]}, {"w": "the", "b": [0.431, 0.6517, 0.4573, 0.6731]}, {"w": "dotted", "b": [0.4648, 0.6517, 0.5189, 0.6731]}, {"w": "line", "b": [0.5264, 0.6517, 0.5575, 0.6731]}, {"w": "represents", "b": [0.5649, 0.6517, 0.6505, 0.6731]}, {"w": "the", "b": [0.658, 0.6517, 0.6843, 0.6731]}, {"w": "original", "b": [0.6918, 0.6517, 0.7568, 0.6731]}, {"w": "model", "b": [0.7643, 0.6517, 0.8171, 0.6731]}, {"w": "that", "b": [0.8246, 0.6517, 0.8571, 0.6731]}, {"w": "was", "b": [0.1429, 0.6707, 0.1739, 0.6922]}, {"w": "trained", "b": [0.1789, 0.6707, 0.239, 0.6922]}, {"w": "with", "b": [0.244, 0.6707, 0.2813, 0.6922]}, {"w": "a", "b": [0.2864, 0.6707, 0.2955, 0.6922]}, {"w": "few", "b": [0.3005, 0.6707, 0.3298, 0.6922]}, {"w": "countries", "b": [0.3348, 0.6707, 0.4125, 0.6922]}, {"w": "missing,", "b": [0.4175, 0.6707, 0.4869, 0.6922]}, {"w": "the", "b": [0.492, 0.6707, 0.5183, 0.6922]}, {"w": "dashed", "b": [0.5233, 0.6707, 0.5821, 0.6922]}, {"w": "line", "b": [0.5871, 0.6707, 0.6182, 0.6922]}, {"w": "is", "b": [0.6232, 0.6707, 0.6364, 0.6922]}, {"w": "our", "b": [0.6415, 0.6707, 0.6709, 0.6922]}, {"w": "second", "b": [0.6759, 0.6707, 0.7342, 0.6922]}, {"w": "model", "b": [0.7392, 0.6707, 0.7921, 0.6922]}, {"w": "trained", "b": [0.7971, 0.6707, 0.8571, 0.6922]}, {"w": "with", "b": [0.1428, 0.6898, 0.1802, 0.7112]}, {"w": "all", "b": [0.1867, 0.6898, 0.2064, 0.7112]}, {"w": "countries,", "b": [0.2129, 0.6898, 0.2953, 0.7112]}, {"w": "and", "b": [0.3018, 0.6898, 0.3333, 0.7112]}, {"w": "the", "b": [0.3399, 0.6898, 0.3662, 0.7112]}, {"w": "solid", "b": [0.3727, 0.6898, 0.4128, 0.7112]}, {"w": "line", "b": [0.4193, 0.6898, 0.4504, 0.7112]}, {"w": "is", "b": [0.4569, 0.6898, 0.4702, 0.7112]}, {"w": "a", "b": [0.4767, 0.6898, 0.4858, 0.7112]}, {"w": "linear", "b": [0.4923, 0.6898, 0.5403, 0.7112]}, {"w": "model", "b": [0.5468, 0.6898, 0.5996, 0.7112]}, {"w": "trained", "b": [0.6061, 0.6898, 0.6662, 0.7112]}, {"w": "with", "b": [0.6727, 0.6898, 0.71, 0.7112]}, {"w": "the", "b": [0.7165, 0.6898, 0.7429, 0.7112]}, {"w": "same", "b": [0.7494, 0.6898, 0.7921, 0.7112]}, {"w": "data", "b": [0.7986, 0.6898, 0.8338, 0.7112]}, {"w": "as", "b": [0.8403, 0.6898, 0.8571, 0.7112]}, {"w": "the", "b": [0.1429, 0.7088, 0.1692, 0.7303]}, {"w": "first", "b": [0.1763, 0.7088, 0.2098, 0.7303]}, {"w": "model", "b": [0.2168, 0.7088, 0.2697, 0.7303]}, {"w": "but", "b": [0.2767, 0.7088, 0.3047, 0.7303]}, {"w": "with", "b": [0.3118, 0.7088, 0.3491, 0.7303]}, {"w": "a", "b": [0.3562, 0.7088, 0.3654, 0.7303]}, {"w": "regularization", "b": [0.3725, 0.7088, 0.489, 0.7303]}, {"w": "constraint.", "b": [0.4961, 0.7088, 0.5855, 0.7303]}, {"w": "You", "b": [0.5926, 0.7088, 0.6249, 0.7303]}, {"w": "can", "b": [0.632, 0.7088, 0.6614, 0.7303]}, {"w": "see", "b": [0.6685, 0.7088, 0.6938, 0.7303]}, {"w": "that", "b": [0.7009, 0.7088, 0.7335, 0.7303]}, {"w": "regularization", "b": [0.7406, 0.7088, 0.8571, 0.7303]}, {"w": "forced", "b": [0.1429, 0.7279, 0.196, 0.7493]}, {"w": "the", "b": [0.2009, 0.7279, 0.2273, 0.7493]}, {"w": "model", "b": [0.2322, 0.7279, 0.285, 0.7493]}, {"w": "to", "b": [0.2899, 0.7279, 0.3069, 0.7493]}, {"w": "have", "b": [0.3117, 0.7279, 0.3501, 0.7493]}, {"w": "a", "b": [0.355, 0.7279, 0.3642, 0.7493]}, {"w": "smaller", "b": [0.3691, 0.7279, 0.4301, 0.7493]}, {"w": "slope,", "b": [0.435, 0.7279, 0.483, 0.7493]}, {"w": "which", "b": [0.4879, 0.7279, 0.5388, 0.7493]}, {"w": "fits", "b": [0.5437, 0.7279, 0.5695, 0.7493]}, {"w": "a", "b": [0.5744, 0.7279, 0.5835, 0.7493]}, {"w": "bit", "b": [0.5884, 0.7279, 0.6109, 0.7493]}, {"w": "less", "b": [0.6158, 0.7279, 0.6452, 0.7493]}, {"w": "the", "b": [0.6501, 0.7279, 0.6765, 0.7493]}, {"w": "training", "b": [0.6814, 0.7279, 0.7483, 0.7493]}, {"w": "data", "b": [0.7532, 0.7279, 0.7884, 0.7493]}, {"w": "that", "b": [0.7933, 0.7279, 0.8259, 0.7493]}, {"w": "the", "b": [0.8308, 0.7279, 0.8571, 0.7493]}, {"w": "model", "b": [0.1429, 0.7469, 0.1957, 0.7683]}, {"w": "was", "b": [0.2004, 0.7469, 0.2315, 0.7683]}, {"w": "trained", "b": [0.2362, 0.7469, 0.2962, 0.7683]}, {"w": "on,", "b": [0.301, 0.7469, 0.3277, 0.7683]}, {"w": "but", "b": [0.3325, 0.7469, 0.3605, 0.7683]}, {"w": "actually", "b": [0.3652, 0.7469, 0.4298, 0.7683]}, {"w": "allows", "b": [0.4346, 0.7469, 0.4868, 0.7683]}, {"w": "it", "b": [0.4915, 0.7469, 0.5035, 0.7683]}, {"w": "to", "b": [0.5082, 0.7469, 0.5252, 0.7683]}, {"w": "generalize", "b": [0.5299, 0.7469, 0.6141, 0.7683]}, {"w": "better", "b": [0.6188, 0.7469, 0.6675, 0.7683]}, {"w": "to", "b": [0.6723, 0.7469, 0.6892, 0.7683]}, {"w": "new", "b": [0.694, 0.7469, 0.7285, 0.7683]}, {"w": "examples.", "b": [0.7332, 0.7469, 0.8152, 0.7683]}]}, {"id": "b_7", "type": "paragraph", "text": "Main Challenges of Machine Learning | 29", "words": [{"w": "Main", "b": [0.584, 0.9225, 0.6136, 0.9388]}, {"w": "Challenges", "b": [0.6164, 0.9225, 0.6805, 0.9388]}, {"w": "of", "b": [0.6833, 0.9225, 0.6953, 0.9388]}, {"w": "Machine", "b": [0.6981, 0.9225, 0.7481, 0.9388]}, {"w": "Learning", "b": [0.7509, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "29", "b": [0.8426, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 56, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 1-23. Regularization reduces the risk of overfitting", "words": [{"w": "Figure", "b": [0.1429, 0.2834, 0.1943, 0.305]}, {"w": "1-23.", "b": [0.1991, 0.2834, 0.2407, 0.305]}, {"w": "Regularization", "b": [0.2455, 0.2834, 0.3654, 0.305]}, {"w": "reduces", "b": [0.3702, 0.2834, 0.43, 0.305]}, {"w": "the", "b": [0.4347, 0.2834, 0.4598, 0.305]}, {"w": "risk", "b": [0.4645, 0.2834, 0.4947, 0.305]}, {"w": "of", "b": [0.4994, 0.2834, 0.5146, 0.305]}, {"w": "overfitting", "b": [0.5194, 0.2834, 0.6039, 0.305]}]}, {"id": "b_1", "type": "paragraph", "text": "The amount of regularization to apply during learning can be controlled by a hyper‐ parameter. A hyperparameter is a parameter of a learning algorithm (not of the model). As such, it is not affected by the learning algorithm itself; it must be set prior to training and remains constant during training. If you set the regularization hyper‐ parameter to a very large value, you will get an almost flat model (a slope close to zero); the learning algorithm will almost certainly not overfit the training data, but it will be less likely to find a good solution. Tuning hyperparameters is an important part of building a Machine Learning system (you will see a detailed example in the next chapter).", "words": [{"w": "The", "b": [0.1429, 0.3208, 0.1757, 0.3422]}, {"w": "amount", "b": [0.1817, 0.3208, 0.247, 0.3422]}, {"w": "of", "b": [0.253, 0.3208, 0.2698, 0.3422]}, {"w": "regularization", "b": [0.2759, 0.3208, 0.3925, 0.3422]}, {"w": "to", "b": [0.3985, 0.3208, 0.4155, 0.3422]}, {"w": "apply", "b": [0.4215, 0.3208, 0.4669, 0.3422]}, {"w": "during", "b": [0.473, 0.3208, 0.5295, 0.3422]}, {"w": "learning", "b": [0.5356, 0.3208, 0.6047, 0.3422]}, {"w": "can", "b": [0.6107, 0.3208, 0.6401, 0.3422]}, {"w": "be", "b": [0.6461, 0.3208, 0.6656, 0.3422]}, {"w": "controlled", "b": [0.6716, 0.3208, 0.7572, 0.3422]}, {"w": "by", "b": [0.7632, 0.3208, 0.7833, 0.3422]}, {"w": "a", "b": [0.7894, 0.3208, 0.7985, 0.3422]}, {"w": "hyper‐", "b": [0.8046, 0.3206, 0.8571, 0.3422]}, {"w": "parameter.", "b": [0.1428, 0.3396, 0.2312, 0.3612]}, {"w": "A", "b": [0.2407, 0.3398, 0.2551, 0.3612]}, {"w": "hyperparameter", "b": [0.2645, 0.3398, 0.398, 0.3612]}, {"w": "is", "b": [0.4075, 0.3398, 0.4207, 0.3612]}, {"w": "a", "b": [0.4301, 0.3398, 0.4393, 0.3612]}, {"w": "parameter", "b": [0.4487, 0.3398, 0.5345, 0.3612]}, {"w": "of", "b": [0.544, 0.3398, 0.5608, 0.3612]}, {"w": "a", "b": [0.5702, 0.3398, 0.5794, 0.3612]}, {"w": "learning", "b": [0.5888, 0.3398, 0.658, 0.3612]}, {"w": "algorithm", "b": [0.6674, 0.3398, 0.7501, 0.3612]}, {"w": "(not", "b": [0.7595, 0.3398, 0.7951, 0.3612]}, {"w": "of", "b": [0.8046, 0.3398, 0.8213, 0.3612]}, {"w": "the", "b": [0.8308, 0.3398, 0.8571, 0.3612]}, {"w": "model).", "b": [0.1429, 0.3589, 0.2076, 0.3803]}, {"w": "As", "b": [0.2129, 0.3589, 0.2349, 0.3803]}, {"w": "such,", "b": [0.2401, 0.3589, 0.2835, 0.3803]}, {"w": "it", "b": [0.2888, 0.3589, 0.3007, 0.3803]}, {"w": "is", "b": [0.306, 0.3589, 0.3192, 0.3803]}, {"w": "not", "b": [0.3244, 0.3589, 0.3528, 0.3803]}, {"w": "affected", "b": [0.358, 0.3589, 0.4234, 0.3803]}, {"w": "by", "b": [0.4286, 0.3589, 0.4488, 0.3803]}, {"w": "the", "b": [0.454, 0.3589, 0.4803, 0.3803]}, {"w": "learning", "b": [0.4856, 0.3589, 0.5547, 0.3803]}, {"w": "algorithm", "b": [0.5599, 0.3589, 0.6426, 0.3803]}, {"w": "itself;", "b": [0.6478, 0.3589, 0.6924, 0.3803]}, {"w": "it", "b": [0.6977, 0.3589, 0.7096, 0.3803]}, {"w": "must", "b": [0.7148, 0.3589, 0.7566, 0.3803]}, {"w": "be", "b": [0.7618, 0.3589, 0.7812, 0.3803]}, {"w": "set", "b": [0.7865, 0.3589, 0.8093, 0.3803]}, {"w": "prior", "b": [0.8146, 0.3589, 0.8572, 0.3803]}, {"w": "to", "b": [0.1429, 0.3779, 0.1598, 0.3993]}, {"w": "training", "b": [0.1654, 0.3779, 0.2323, 0.3993]}, {"w": "and", "b": [0.2379, 0.3779, 0.2694, 0.3993]}, {"w": "remains", "b": [0.2749, 0.3779, 0.3423, 0.3993]}, {"w": "constant", "b": [0.3479, 0.3779, 0.4192, 0.3993]}, {"w": "during", "b": [0.4248, 0.3779, 0.4813, 0.3993]}, {"w": "training.", "b": [0.4868, 0.3779, 0.5585, 0.3993]}, {"w": "If", "b": [0.564, 0.3779, 0.5773, 0.3993]}, {"w": "you", "b": [0.5828, 0.3779, 0.6141, 0.3993]}, {"w": "set", "b": [0.6196, 0.3779, 0.6425, 0.3993]}, {"w": "the", "b": [0.648, 0.3779, 0.6744, 0.3993]}, {"w": "regularization", "b": [0.6799, 0.3779, 0.7965, 0.3993]}, {"w": "hyper‐", "b": [0.802, 0.3779, 0.8571, 0.3993]}, {"w": "parameter", "b": [0.1429, 0.397, 0.2286, 0.4184]}, {"w": "to", "b": [0.2359, 0.397, 0.2529, 0.4184]}, {"w": "a", "b": [0.2601, 0.397, 0.2693, 0.4184]}, {"w": "very", "b": [0.2765, 0.397, 0.3129, 0.4184]}, {"w": "large", "b": [0.3202, 0.397, 0.3609, 0.4184]}, {"w": "value,", "b": [0.3682, 0.397, 0.4169, 0.4184]}, {"w": "you", "b": [0.4242, 0.397, 0.4554, 0.4184]}, {"w": "will", "b": [0.4627, 0.397, 0.4931, 0.4184]}, {"w": "get", "b": [0.5003, 0.397, 0.5253, 0.4184]}, {"w": "an", "b": [0.5325, 0.397, 0.5531, 0.4184]}, {"w": "almost", "b": [0.5603, 0.397, 0.6164, 0.4184]}, {"w": "flat", "b": [0.6237, 0.397, 0.6502, 0.4184]}, {"w": "model", "b": [0.6575, 0.397, 0.7103, 0.4184]}, {"w": "(a", "b": [0.7175, 0.397, 0.7339, 0.4184]}, {"w": "slope", "b": [0.7411, 0.397, 0.7844, 0.4184]}, {"w": "close", "b": [0.7917, 0.397, 0.8329, 0.4184]}, {"w": "to", "b": [0.8402, 0.397, 0.8571, 0.4184]}, {"w": "zero);", "b": [0.1428, 0.416, 0.1908, 0.4374]}, {"w": "the", "b": [0.1963, 0.416, 0.2227, 0.4374]}, {"w": "learning", "b": [0.2283, 0.416, 0.2974, 0.4374]}, {"w": "algorithm", "b": [0.303, 0.416, 0.3856, 0.4374]}, {"w": "will", "b": [0.3912, 0.416, 0.4216, 0.4374]}, {"w": "almost", "b": [0.4272, 0.416, 0.4833, 0.4374]}, {"w": "certainly", "b": [0.4888, 0.416, 0.5615, 0.4374]}, {"w": "not", "b": [0.5671, 0.416, 0.5955, 0.4374]}, {"w": "overfit", "b": [0.6011, 0.416, 0.656, 0.4374]}, {"w": "the", "b": [0.6616, 0.416, 0.6879, 0.4374]}, {"w": "training", "b": [0.6935, 0.416, 0.7605, 0.4374]}, {"w": "data,", "b": [0.766, 0.416, 0.806, 0.4374]}, {"w": "but", "b": [0.8116, 0.416, 0.8396, 0.4374]}, {"w": "it", "b": [0.8452, 0.416, 0.8571, 0.4374]}, {"w": "will", "b": [0.1429, 0.4351, 0.1733, 0.4565]}, {"w": "be", "b": [0.1806, 0.4351, 0.2, 0.4565]}, {"w": "less", "b": [0.2074, 0.4351, 0.2368, 0.4565]}, {"w": "likely", "b": [0.2441, 0.4351, 0.289, 0.4565]}, {"w": "to", "b": [0.2963, 0.4351, 0.3133, 0.4565]}, {"w": "find", "b": [0.3206, 0.4351, 0.3548, 0.4565]}, {"w": "a", "b": [0.3621, 0.4351, 0.3712, 0.4565]}, {"w": "good", "b": [0.3786, 0.4351, 0.4206, 0.4565]}, {"w": "solution.", "b": [0.4279, 0.4351, 0.5012, 0.4565]}, {"w": "Tuning", "b": [0.5085, 0.4351, 0.5685, 0.4565]}, {"w": "hyperparameters", "b": [0.5759, 0.4351, 0.717, 0.4565]}, {"w": "is", "b": [0.7243, 0.4351, 0.7376, 0.4565]}, {"w": "an", "b": [0.7449, 0.4351, 0.7654, 0.4565]}, {"w": "important", "b": [0.7728, 0.4351, 0.8571, 0.4565]}, {"w": "part", "b": [0.1429, 0.4541, 0.177, 0.4755]}, {"w": "of", "b": [0.1839, 0.4541, 0.2007, 0.4755]}, {"w": "building", "b": [0.2076, 0.4541, 0.2778, 0.4755]}, {"w": "a", "b": [0.2847, 0.4541, 0.2938, 0.4755]}, {"w": "Machine", "b": [0.3007, 0.4541, 0.3738, 0.4755]}, {"w": "Learning", "b": [0.3807, 0.4541, 0.4558, 0.4755]}, {"w": "system", "b": [0.4627, 0.4541, 0.5198, 0.4755]}, {"w": "(you", "b": [0.5267, 0.4541, 0.5651, 0.4755]}, {"w": "will", "b": [0.572, 0.4541, 0.6024, 0.4755]}, {"w": "see", "b": [0.6093, 0.4541, 0.6347, 0.4755]}, {"w": "a", "b": [0.6415, 0.4541, 0.6507, 0.4755]}, {"w": "detailed", "b": [0.6576, 0.4541, 0.7236, 0.4755]}, {"w": "example", "b": [0.7305, 0.4541, 0.8001, 0.4755]}, {"w": "in", "b": [0.8069, 0.4541, 0.8239, 0.4755]}, {"w": "the", "b": [0.8308, 0.4541, 0.8571, 0.4755]}, {"w": "next", "b": [0.1428, 0.4732, 0.1793, 0.4946]}, {"w": "chapter).", "b": [0.184, 0.4732, 0.2585, 0.4946]}]}, {"id": "b_2", "type": "paragraph", "text": "Underfitting the Training Data", "words": [{"w": "Underfitting", "b": [0.1429, 0.5073, 0.2712, 0.5359]}, {"w": "the", "b": [0.2761, 0.5073, 0.311, 0.5359]}, {"w": "Training", "b": [0.3159, 0.5073, 0.4019, 0.5359]}, {"w": "Data", "b": [0.4068, 0.5073, 0.4553, 0.5359]}]}, {"id": "b_3", "type": "paragraph", "text": "As you might guess, underfitting is the opposite of overfitting: it occurs when your model is too simple to learn the underlying structure of the data. For example, a lin‐ ear model of life satisfaction is prone to underfit; reality is just more complex than the model, so its predictions are bound to be inaccurate, even on the training exam‐ ples.", "words": [{"w": "As", "b": [0.1429, 0.5418, 0.1649, 0.5632]}, {"w": "you", "b": [0.172, 0.5418, 0.2032, 0.5632]}, {"w": "might", "b": [0.2103, 0.5418, 0.2597, 0.5632]}, {"w": "guess,", "b": [0.2668, 0.5418, 0.3165, 0.5632]}, {"w": "underfitting", "b": [0.3236, 0.5416, 0.4217, 0.5632]}, {"w": "is", "b": [0.4287, 0.5418, 0.442, 0.5632]}, {"w": "the", "b": [0.449, 0.5418, 0.4754, 0.5632]}, {"w": "opposite", "b": [0.4824, 0.5418, 0.5539, 0.5632]}, {"w": "of", "b": [0.561, 0.5418, 0.5778, 0.5632]}, {"w": "overfitting:", "b": [0.5849, 0.5418, 0.6776, 0.5632]}, {"w": "it", "b": [0.6847, 0.5418, 0.6966, 0.5632]}, {"w": "occurs", "b": [0.7037, 0.5418, 0.7584, 0.5632]}, {"w": "when", "b": [0.7655, 0.5418, 0.8111, 0.5632]}, {"w": "your", "b": [0.8182, 0.5418, 0.8571, 0.5632]}, {"w": "model", "b": [0.1429, 0.5608, 0.1957, 0.5823]}, {"w": "is", "b": [0.2015, 0.5608, 0.2147, 0.5823]}, {"w": "too", "b": [0.2206, 0.5608, 0.2482, 0.5823]}, {"w": "simple", "b": [0.254, 0.5608, 0.309, 0.5823]}, {"w": "to", "b": [0.3148, 0.5608, 0.3318, 0.5823]}, {"w": "learn", "b": [0.3376, 0.5608, 0.38, 0.5823]}, {"w": "the", "b": [0.3859, 0.5608, 0.4122, 0.5823]}, {"w": "underlying", "b": [0.418, 0.5608, 0.5096, 0.5823]}, {"w": "structure", "b": [0.5155, 0.5608, 0.5911, 0.5823]}, {"w": "of", "b": [0.5969, 0.5608, 0.6137, 0.5823]}, {"w": "the", "b": [0.6195, 0.5608, 0.6459, 0.5823]}, {"w": "data.", "b": [0.6517, 0.5608, 0.6917, 0.5823]}, {"w": "For", "b": [0.6976, 0.5608, 0.7265, 0.5823]}, {"w": "example,", "b": [0.7324, 0.5608, 0.8067, 0.5823]}, {"w": "a", "b": [0.8125, 0.5608, 0.8216, 0.5823]}, {"w": "lin‐", "b": [0.8275, 0.5608, 0.8572, 0.5823]}, {"w": "ear", "b": [0.1429, 0.5799, 0.1686, 0.6013]}, {"w": "model", "b": [0.1755, 0.5799, 0.2283, 0.6013]}, {"w": "of", "b": [0.2353, 0.5799, 0.2521, 0.6013]}, {"w": "life", "b": [0.259, 0.5799, 0.2849, 0.6013]}, {"w": "satisfaction", "b": [0.2918, 0.5799, 0.3858, 0.6013]}, {"w": "is", "b": [0.3928, 0.5799, 0.406, 0.6013]}, {"w": "prone", "b": [0.4129, 0.5799, 0.4625, 0.6013]}, {"w": "to", "b": [0.4694, 0.5799, 0.4864, 0.6013]}, {"w": "underfit;", "b": [0.4933, 0.5799, 0.5662, 0.6013]}, {"w": "reality", "b": [0.5731, 0.5799, 0.6256, 0.6013]}, {"w": "is", "b": [0.6325, 0.5799, 0.6458, 0.6013]}, {"w": "just", "b": [0.6527, 0.5799, 0.6831, 0.6013]}, {"w": "more", "b": [0.69, 0.5799, 0.7343, 0.6013]}, {"w": "complex", "b": [0.7412, 0.5799, 0.8122, 0.6013]}, {"w": "than", "b": [0.8191, 0.5799, 0.8571, 0.6013]}, {"w": "the", "b": [0.1429, 0.5989, 0.1692, 0.6204]}, {"w": "model,", "b": [0.1752, 0.5989, 0.2327, 0.6204]}, {"w": "so", "b": [0.2387, 0.5989, 0.257, 0.6204]}, {"w": "its", "b": [0.2629, 0.5989, 0.2825, 0.6204]}, {"w": "predictions", "b": [0.2885, 0.5989, 0.383, 0.6204]}, {"w": "are", "b": [0.389, 0.5989, 0.4147, 0.6204]}, {"w": "bound", "b": [0.4207, 0.5989, 0.4753, 0.6204]}, {"w": "to", "b": [0.4813, 0.5989, 0.4983, 0.6204]}, {"w": "be", "b": [0.5043, 0.5989, 0.5237, 0.6204]}, {"w": "inaccurate,", "b": [0.5297, 0.5989, 0.6209, 0.6204]}, {"w": "even", "b": [0.6269, 0.5989, 0.6656, 0.6204]}, {"w": "on", "b": [0.6716, 0.5989, 0.6936, 0.6204]}, {"w": "the", "b": [0.6996, 0.5989, 0.7259, 0.6204]}, {"w": "training", "b": [0.7319, 0.5989, 0.7989, 0.6204]}, {"w": "exam‐", "b": [0.8048, 0.5989, 0.8571, 0.6204]}, {"w": "ples.", "b": [0.1428, 0.618, 0.1803, 0.6394]}]}, {"id": "b_4", "type": "paragraph", "text": "The main options to fix this problem are:", "words": [{"w": "The", "b": [0.1428, 0.6461, 0.1757, 0.6675]}, {"w": "main", "b": [0.1804, 0.6461, 0.2236, 0.6675]}, {"w": "options", "b": [0.2283, 0.6461, 0.2915, 0.6675]}, {"w": "to", "b": [0.2962, 0.6461, 0.3132, 0.6675]}, {"w": "fix", "b": [0.3179, 0.6461, 0.3395, 0.6675]}, {"w": "this", "b": [0.3442, 0.6461, 0.3749, 0.6675]}, {"w": "problem", "b": [0.3797, 0.6461, 0.4507, 0.6675]}, {"w": "are:", "b": [0.4554, 0.6461, 0.4859, 0.6675]}]}, {"id": "b_5", "type": "paragraph", "text": "• Selecting a more powerful model, with more parameters", "words": [{"w": "•", "b": [0.16, 0.6803, 0.1681, 0.7017]}, {"w": "Selecting", "b": [0.1786, 0.6803, 0.2533, 0.7017]}, {"w": "a", "b": [0.258, 0.6803, 0.2672, 0.7017]}, {"w": "more", "b": [0.2719, 0.6803, 0.3162, 0.7017]}, {"w": "powerful", "b": [0.3209, 0.6803, 0.3958, 0.7017]}, {"w": "model,", "b": [0.4005, 0.6803, 0.4581, 0.7017]}, {"w": "with", "b": [0.4628, 0.6803, 0.5002, 0.7017]}, {"w": "more", "b": [0.5049, 0.6803, 0.5492, 0.7017]}, {"w": "parameters", "b": [0.5539, 0.6803, 0.6473, 0.7017]}]}, {"id": "b_6", "type": "paragraph", "text": "• Feeding better features to the learning algorithm (feature engineering)", "words": [{"w": "•", "b": [0.16, 0.7054, 0.1682, 0.7268]}, {"w": "Feeding", "b": [0.1786, 0.7054, 0.2446, 0.7268]}, {"w": "better", "b": [0.2494, 0.7054, 0.2981, 0.7268]}, {"w": "features", "b": [0.3028, 0.7054, 0.3682, 0.7268]}, {"w": "to", "b": [0.373, 0.7054, 0.3899, 0.7268]}, {"w": "the", "b": [0.3947, 0.7054, 0.421, 0.7268]}, {"w": "learning", "b": [0.4257, 0.7054, 0.4949, 0.7268]}, {"w": "algorithm", "b": [0.4996, 0.7054, 0.5822, 0.7268]}, {"w": "(feature", "b": [0.587, 0.7054, 0.6519, 0.7268]}, {"w": "engineering)", "b": [0.6567, 0.7054, 0.763, 0.7268]}]}, {"id": "b_7", "type": "paragraph", "text": "• Reducing the constraints on the model (e.g., reducing the regularization hyper‐ parameter)", "words": [{"w": "•", "b": [0.16, 0.7305, 0.1682, 0.7519]}, {"w": "Reducing", "b": [0.1786, 0.7305, 0.258, 0.7519]}, {"w": "the", "b": [0.2647, 0.7305, 0.291, 0.7519]}, {"w": "constraints", "b": [0.2977, 0.7305, 0.39, 0.7519]}, {"w": "on", "b": [0.3967, 0.7305, 0.4187, 0.7519]}, {"w": "the", "b": [0.4254, 0.7305, 0.4518, 0.7519]}, {"w": "model", "b": [0.4585, 0.7305, 0.5113, 0.7519]}, {"w": "(e.g.,", "b": [0.518, 0.7305, 0.5581, 0.7519]}, {"w": "reducing", "b": [0.5648, 0.7305, 0.639, 0.7519]}, {"w": "the", "b": [0.6457, 0.7305, 0.672, 0.7519]}, {"w": "regularization", "b": [0.6787, 0.7305, 0.7953, 0.7519]}, {"w": "hyper‐", "b": [0.802, 0.7305, 0.8571, 0.7519]}, {"w": "parameter)", "b": [0.1786, 0.7495, 0.2716, 0.7709]}]}, {"id": "b_8", "type": "paragraph", "text": "Stepping Back", "words": [{"w": "Stepping", "b": [0.1428, 0.7988, 0.2359, 0.8274]}, {"w": "Back", "b": [0.2408, 0.7988, 0.2893, 0.8274]}]}, {"id": "b_9", "type": "paragraph", "text": "By now you already know a lot about Machine Learning. However, we went through so many concepts that you may be feeling a little lost, so let’s step back and look at the big picture:", "words": [{"w": "By", "b": [0.1429, 0.8333, 0.1647, 0.8547]}, {"w": "now", "b": [0.1705, 0.8333, 0.2068, 0.8547]}, {"w": "you", "b": [0.2125, 0.8333, 0.2438, 0.8547]}, {"w": "already", "b": [0.2496, 0.8333, 0.3103, 0.8547]}, {"w": "know", "b": [0.3161, 0.8333, 0.3627, 0.8547]}, {"w": "a", "b": [0.3685, 0.8333, 0.3776, 0.8547]}, {"w": "lot", "b": [0.3834, 0.8333, 0.4057, 0.8547]}, {"w": "about", "b": [0.4115, 0.8333, 0.4592, 0.8547]}, {"w": "Machine", "b": [0.465, 0.8333, 0.5382, 0.8547]}, {"w": "Learning.", "b": [0.5439, 0.8333, 0.6238, 0.8547]}, {"w": "However,", "b": [0.6295, 0.8333, 0.7084, 0.8547]}, {"w": "we", "b": [0.7142, 0.8333, 0.7373, 0.8547]}, {"w": "went", "b": [0.7431, 0.8333, 0.7836, 0.8547]}, {"w": "through", "b": [0.7894, 0.8333, 0.8571, 0.8547]}, {"w": "so", "b": [0.1429, 0.8523, 0.1611, 0.8737]}, {"w": "many", "b": [0.1661, 0.8523, 0.2127, 0.8737]}, {"w": "concepts", "b": [0.2177, 0.8523, 0.2911, 0.8737]}, {"w": "that", "b": [0.296, 0.8523, 0.3286, 0.8737]}, {"w": "you", "b": [0.3336, 0.8523, 0.3648, 0.8737]}, {"w": "may", "b": [0.3698, 0.8523, 0.4052, 0.8737]}, {"w": "be", "b": [0.4101, 0.8523, 0.4295, 0.8737]}, {"w": "feeling", "b": [0.4345, 0.8523, 0.4903, 0.8737]}, {"w": "a", "b": [0.4953, 0.8523, 0.5044, 0.8737]}, {"w": "little", "b": [0.5094, 0.8523, 0.5471, 0.8737]}, {"w": "lost,", "b": [0.552, 0.8523, 0.5866, 0.8737]}, {"w": "so", "b": [0.5916, 0.8523, 0.6099, 0.8737]}, {"w": "let’s", "b": [0.6148, 0.8523, 0.645, 0.8737]}, {"w": "step", "b": [0.65, 0.8523, 0.6837, 0.8737]}, {"w": "back", "b": [0.6887, 0.8523, 0.7275, 0.8737]}, {"w": "and", "b": [0.7325, 0.8523, 0.764, 0.8737]}, {"w": "look", "b": [0.769, 0.8523, 0.8058, 0.8737]}, {"w": "at", "b": [0.8108, 0.8523, 0.8259, 0.8737]}, {"w": "the", "b": [0.8308, 0.8523, 0.8571, 0.8737]}, {"w": "big", "b": [0.1429, 0.8714, 0.1688, 0.8928]}, {"w": "picture:", "b": [0.1735, 0.8714, 0.2376, 0.8928]}]}, {"id": "b_10", "type": "paragraph", "text": "30 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "30", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.3371, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 57, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• Machine Learning is about making machines get better at some task by learning from data, instead of having to explicitly code rules.", "words": [{"w": "•", "b": [0.16, 0.0851, 0.1682, 0.1065]}, {"w": "Machine", "b": [0.1786, 0.0851, 0.2517, 0.1065]}, {"w": "Learning", "b": [0.2576, 0.0851, 0.3326, 0.1065]}, {"w": "is", "b": [0.3385, 0.0851, 0.3518, 0.1065]}, {"w": "about", "b": [0.3577, 0.0851, 0.4054, 0.1065]}, {"w": "making", "b": [0.4113, 0.0851, 0.4746, 0.1065]}, {"w": "machines", "b": [0.4805, 0.0851, 0.5601, 0.1065]}, {"w": "get", "b": [0.566, 0.0851, 0.591, 0.1065]}, {"w": "better", "b": [0.5969, 0.0851, 0.6456, 0.1065]}, {"w": "at", "b": [0.6515, 0.0851, 0.6666, 0.1065]}, {"w": "some", "b": [0.6725, 0.0851, 0.7167, 0.1065]}, {"w": "task", "b": [0.7226, 0.0851, 0.7561, 0.1065]}, {"w": "by", "b": [0.762, 0.0851, 0.7821, 0.1065]}, {"w": "learning", "b": [0.788, 0.0851, 0.8571, 0.1065]}, {"w": "from", "b": [0.1786, 0.1042, 0.2202, 0.1256]}, {"w": "data,", "b": [0.2249, 0.1042, 0.2649, 0.1256]}, {"w": "instead", "b": [0.2696, 0.1042, 0.3296, 0.1256]}, {"w": "of", "b": [0.3343, 0.1042, 0.3511, 0.1256]}, {"w": "having", "b": [0.3558, 0.1042, 0.4121, 0.1256]}, {"w": "to", "b": [0.4168, 0.1042, 0.4338, 0.1256]}, {"w": "explicitly", "b": [0.4386, 0.1042, 0.5146, 0.1256]}, {"w": "code", "b": [0.5193, 0.1042, 0.5586, 0.1256]}, {"w": "rules.", "b": [0.5633, 0.1042, 0.6087, 0.1256]}]}, {"id": "b_1", "type": "paragraph", "text": "• There are many different types of ML systems: supervised or not, batch or online, instance-based or model-based, and so on.", "words": [{"w": "•", "b": [0.16, 0.1293, 0.1682, 0.1507]}, {"w": "There", "b": [0.1786, 0.1293, 0.228, 0.1507]}, {"w": "are", "b": [0.2328, 0.1293, 0.2585, 0.1507]}, {"w": "many", "b": [0.2634, 0.1293, 0.3101, 0.1507]}, {"w": "different", "b": [0.3149, 0.1293, 0.3866, 0.1507]}, {"w": "types", "b": [0.3914, 0.1293, 0.4347, 0.1507]}, {"w": "of", "b": [0.4396, 0.1293, 0.4564, 0.1507]}, {"w": "ML", "b": [0.4612, 0.1293, 0.491, 0.1507]}, {"w": "systems:", "b": [0.4958, 0.1293, 0.5653, 0.1507]}, {"w": "supervised", "b": [0.5701, 0.1293, 0.6597, 0.1507]}, {"w": "or", "b": [0.6645, 0.1293, 0.6829, 0.1507]}, {"w": "not,", "b": [0.6877, 0.1293, 0.7208, 0.1507]}, {"w": "batch", "b": [0.7256, 0.1293, 0.7713, 0.1507]}, {"w": "or", "b": [0.7761, 0.1293, 0.7944, 0.1507]}, {"w": "online,", "b": [0.7993, 0.1293, 0.8571, 0.1507]}, {"w": "instance-based", "b": [0.1786, 0.1483, 0.3024, 0.1697]}, {"w": "or", "b": [0.3071, 0.1483, 0.3255, 0.1697]}, {"w": "model-based,", "b": [0.3302, 0.1483, 0.4424, 0.1697]}, {"w": "and", "b": [0.4472, 0.1483, 0.4787, 0.1697]}, {"w": "so", "b": [0.4834, 0.1483, 0.5017, 0.1697]}, {"w": "on.", "b": [0.5064, 0.1483, 0.5332, 0.1697]}]}, {"id": "b_2", "type": "paragraph", "text": "• In a ML project you gather data in a training set, and you feed the training set to a learning algorithm. If the algorithm is model-based it tunes some parameters to fit the model to the training set (i.e., to make good predictions on the training set itself), and then hopefully it will be able to make good predictions on new cases as well. If the algorithm is instance-based, it just learns the examples by heart and generalizes to new instances by comparing them to the learned instances using a similarity measure.", "words": [{"w": "•", "b": [0.16, 0.1734, 0.1682, 0.1948]}, {"w": "In", "b": [0.1786, 0.1734, 0.1971, 0.1948]}, {"w": "a", "b": [0.2025, 0.1734, 0.2116, 0.1948]}, {"w": "ML", "b": [0.217, 0.1734, 0.2468, 0.1948]}, {"w": "project", "b": [0.2522, 0.1734, 0.3108, 0.1948]}, {"w": "you", "b": [0.3163, 0.1734, 0.3475, 0.1948]}, {"w": "gather", "b": [0.3529, 0.1734, 0.4055, 0.1948]}, {"w": "data", "b": [0.4109, 0.1734, 0.4462, 0.1948]}, {"w": "in", "b": [0.4516, 0.1734, 0.4685, 0.1948]}, {"w": "a", "b": [0.474, 0.1734, 0.4831, 0.1948]}, {"w": "training", "b": [0.4885, 0.1734, 0.5555, 0.1948]}, {"w": "set,", "b": [0.5609, 0.1734, 0.5885, 0.1948]}, {"w": "and", "b": [0.5939, 0.1734, 0.6254, 0.1948]}, {"w": "you", "b": [0.6308, 0.1734, 0.6621, 0.1948]}, {"w": "feed", "b": [0.6675, 0.1734, 0.7024, 0.1948]}, {"w": "the", "b": [0.7078, 0.1734, 0.7341, 0.1948]}, {"w": "training", "b": [0.7395, 0.1734, 0.8065, 0.1948]}, {"w": "set", "b": [0.8119, 0.1734, 0.8347, 0.1948]}, {"w": "to", "b": [0.8402, 0.1734, 0.8571, 0.1948]}, {"w": "a", "b": [0.1786, 0.1924, 0.1877, 0.2139]}, {"w": "learning", "b": [0.1926, 0.1924, 0.2617, 0.2139]}, {"w": "algorithm.", "b": [0.2665, 0.1924, 0.3539, 0.2139]}, {"w": "If", "b": [0.3588, 0.1924, 0.372, 0.2139]}, {"w": "the", "b": [0.3769, 0.1924, 0.4032, 0.2139]}, {"w": "algorithm", "b": [0.4081, 0.1924, 0.4907, 0.2139]}, {"w": "is", "b": [0.4955, 0.1924, 0.5088, 0.2139]}, {"w": "model-based", "b": [0.5136, 0.1924, 0.6211, 0.2139]}, {"w": "it", "b": [0.6259, 0.1924, 0.6379, 0.2139]}, {"w": "tunes", "b": [0.6427, 0.1924, 0.688, 0.2139]}, {"w": "some", "b": [0.6929, 0.1924, 0.737, 0.2139]}, {"w": "parameters", "b": [0.7419, 0.1924, 0.8353, 0.2139]}, {"w": "to", "b": [0.8402, 0.1924, 0.8571, 0.2139]}, {"w": "fit", "b": [0.1786, 0.2115, 0.1967, 0.2329]}, {"w": "the", "b": [0.2017, 0.2115, 0.228, 0.2329]}, {"w": "model", "b": [0.233, 0.2115, 0.2859, 0.2329]}, {"w": "to", "b": [0.2909, 0.2115, 0.3079, 0.2329]}, {"w": "the", "b": [0.3129, 0.2115, 0.3392, 0.2329]}, {"w": "training", "b": [0.3442, 0.2115, 0.4112, 0.2329]}, {"w": "set", "b": [0.4162, 0.2115, 0.439, 0.2329]}, {"w": "(i.e.,", "b": [0.4441, 0.2115, 0.48, 0.2329]}, {"w": "to", "b": [0.485, 0.2115, 0.502, 0.2329]}, {"w": "make", "b": [0.507, 0.2115, 0.5524, 0.2329]}, {"w": "good", "b": [0.5574, 0.2115, 0.5994, 0.2329]}, {"w": "predictions", "b": [0.6044, 0.2115, 0.6989, 0.2329]}, {"w": "on", "b": [0.7039, 0.2115, 0.7259, 0.2329]}, {"w": "the", "b": [0.731, 0.2115, 0.7573, 0.2329]}, {"w": "training", "b": [0.7623, 0.2115, 0.8293, 0.2329]}, {"w": "set", "b": [0.8343, 0.2115, 0.8571, 0.2329]}, {"w": "itself),", "b": [0.1786, 0.2305, 0.232, 0.2519]}, {"w": "and", "b": [0.238, 0.2305, 0.2696, 0.2519]}, {"w": "then", "b": [0.2755, 0.2305, 0.3133, 0.2519]}, {"w": "hopefully", "b": [0.3193, 0.2305, 0.3981, 0.2519]}, {"w": "it", "b": [0.4041, 0.2305, 0.416, 0.2519]}, {"w": "will", "b": [0.422, 0.2305, 0.4524, 0.2519]}, {"w": "be", "b": [0.4584, 0.2305, 0.4779, 0.2519]}, {"w": "able", "b": [0.4838, 0.2305, 0.5177, 0.2519]}, {"w": "to", "b": [0.5237, 0.2305, 0.5407, 0.2519]}, {"w": "make", "b": [0.5467, 0.2305, 0.5921, 0.2519]}, {"w": "good", "b": [0.598, 0.2305, 0.64, 0.2519]}, {"w": "predictions", "b": [0.646, 0.2305, 0.7405, 0.2519]}, {"w": "on", "b": [0.7465, 0.2305, 0.7685, 0.2519]}, {"w": "new", "b": [0.7745, 0.2305, 0.8091, 0.2519]}, {"w": "cases", "b": [0.815, 0.2305, 0.8571, 0.2519]}, {"w": "as", "b": [0.1786, 0.2496, 0.1954, 0.271]}, {"w": "well.", "b": [0.2003, 0.2496, 0.2387, 0.271]}, {"w": "If", "b": [0.2436, 0.2496, 0.2568, 0.271]}, {"w": "the", "b": [0.2617, 0.2496, 0.2881, 0.271]}, {"w": "algorithm", "b": [0.293, 0.2496, 0.3756, 0.271]}, {"w": "is", "b": [0.3805, 0.2496, 0.3937, 0.271]}, {"w": "instance-based,", "b": [0.3986, 0.2496, 0.5272, 0.271]}, {"w": "it", "b": [0.5321, 0.2496, 0.544, 0.271]}, {"w": "just", "b": [0.5489, 0.2496, 0.5793, 0.271]}, {"w": "learns", "b": [0.5842, 0.2496, 0.6343, 0.271]}, {"w": "the", "b": [0.6392, 0.2496, 0.6655, 0.271]}, {"w": "examples", "b": [0.6704, 0.2496, 0.7476, 0.271]}, {"w": "by", "b": [0.7525, 0.2496, 0.7726, 0.271]}, {"w": "heart", "b": [0.7775, 0.2496, 0.8207, 0.271]}, {"w": "and", "b": [0.8256, 0.2496, 0.8572, 0.271]}, {"w": "generalizes", "b": [0.1786, 0.2686, 0.2704, 0.29]}, {"w": "to", "b": [0.276, 0.2686, 0.293, 0.29]}, {"w": "new", "b": [0.2986, 0.2686, 0.3331, 0.29]}, {"w": "instances", "b": [0.3387, 0.2686, 0.4155, 0.29]}, {"w": "by", "b": [0.4212, 0.2686, 0.4413, 0.29]}, {"w": "comparing", "b": [0.4469, 0.2686, 0.5375, 0.29]}, {"w": "them", "b": [0.5431, 0.2686, 0.5865, 0.29]}, {"w": "to", "b": [0.5921, 0.2686, 0.6091, 0.29]}, {"w": "the", "b": [0.6147, 0.2686, 0.6411, 0.29]}, {"w": "learned", "b": [0.6467, 0.2686, 0.7089, 0.29]}, {"w": "instances", "b": [0.7145, 0.2686, 0.7913, 0.29]}, {"w": "using", "b": [0.797, 0.2686, 0.8424, 0.29]}, {"w": "a", "b": [0.848, 0.2686, 0.8571, 0.29]}, {"w": "similarity", "b": [0.1786, 0.2877, 0.2581, 0.3091]}, {"w": "measure.", "b": [0.2628, 0.2877, 0.3379, 0.3091]}]}, {"id": "b_3", "type": "paragraph", "text": "• The system will not perform well if your training set is too small, or if the data is not representative, noisy, or polluted with irrelevant features (garbage in, garbage out). Lastly, your model needs to be neither too simple (in which case it will underfit) nor too complex (in which case it will overfit).", "words": [{"w": "•", "b": [0.16, 0.3128, 0.1681, 0.3342]}, {"w": "The", "b": [0.1786, 0.3128, 0.2114, 0.3342]}, {"w": "system", "b": [0.2168, 0.3128, 0.2739, 0.3342]}, {"w": "will", "b": [0.2793, 0.3128, 0.3097, 0.3342]}, {"w": "not", "b": [0.3151, 0.3128, 0.3435, 0.3342]}, {"w": "perform", "b": [0.3489, 0.3128, 0.4179, 0.3342]}, {"w": "well", "b": [0.4233, 0.3128, 0.457, 0.3342]}, {"w": "if", "b": [0.4624, 0.3128, 0.4742, 0.3342]}, {"w": "your", "b": [0.4795, 0.3128, 0.5185, 0.3342]}, {"w": "training", "b": [0.5239, 0.3128, 0.5909, 0.3342]}, {"w": "set", "b": [0.5962, 0.3128, 0.6191, 0.3342]}, {"w": "is", "b": [0.6245, 0.3128, 0.6377, 0.3342]}, {"w": "too", "b": [0.6431, 0.3128, 0.6707, 0.3342]}, {"w": "small,", "b": [0.6761, 0.3128, 0.7253, 0.3342]}, {"w": "or", "b": [0.7306, 0.3128, 0.749, 0.3342]}, {"w": "if", "b": [0.7544, 0.3128, 0.7661, 0.3342]}, {"w": "the", "b": [0.7715, 0.3128, 0.7979, 0.3342]}, {"w": "data", "b": [0.8033, 0.3128, 0.8385, 0.3342]}, {"w": "is", "b": [0.8439, 0.3128, 0.8571, 0.3342]}, {"w": "not", "b": [0.1786, 0.3318, 0.2069, 0.3532]}, {"w": "representative,", "b": [0.212, 0.3318, 0.3339, 0.3532]}, {"w": "noisy,", "b": [0.339, 0.3318, 0.387, 0.3532]}, {"w": "or", "b": [0.3921, 0.3318, 0.4105, 0.3532]}, {"w": "polluted", "b": [0.4155, 0.3318, 0.4849, 0.3532]}, {"w": "with", "b": [0.49, 0.3318, 0.5273, 0.3532]}, {"w": "irrelevant", "b": [0.5324, 0.3318, 0.6126, 0.3532]}, {"w": "features", "b": [0.6176, 0.3318, 0.6831, 0.3532]}, {"w": "(garbage", "b": [0.6881, 0.3318, 0.7603, 0.3532]}, {"w": "in,", "b": [0.7654, 0.3318, 0.7871, 0.3532]}, {"w": "garbage", "b": [0.7922, 0.3318, 0.8571, 0.3532]}, {"w": "out).", "b": [0.1786, 0.3509, 0.2186, 0.3723]}, {"w": "Lastly,", "b": [0.2268, 0.3509, 0.2793, 0.3723]}, {"w": "your", "b": [0.2875, 0.3509, 0.3265, 0.3723]}, {"w": "model", "b": [0.3348, 0.3509, 0.3876, 0.3723]}, {"w": "needs", "b": [0.3959, 0.3509, 0.4436, 0.3723]}, {"w": "to", "b": [0.4519, 0.3509, 0.4689, 0.3723]}, {"w": "be", "b": [0.4772, 0.3509, 0.4966, 0.3723]}, {"w": "neither", "b": [0.5049, 0.3509, 0.5648, 0.3723]}, {"w": "too", "b": [0.573, 0.3509, 0.6006, 0.3723]}, {"w": "simple", "b": [0.6089, 0.3509, 0.6639, 0.3723]}, {"w": "(in", "b": [0.6721, 0.3509, 0.6963, 0.3723]}, {"w": "which", "b": [0.7046, 0.3509, 0.7555, 0.3723]}, {"w": "case", "b": [0.7638, 0.3509, 0.7982, 0.3723]}, {"w": "it", "b": [0.8065, 0.3509, 0.8185, 0.3723]}, {"w": "will", "b": [0.8267, 0.3509, 0.8571, 0.3723]}, {"w": "underfit)", "b": [0.1786, 0.3699, 0.2539, 0.3913]}, {"w": "nor", "b": [0.2587, 0.3699, 0.2884, 0.3913]}, {"w": "too", "b": [0.2931, 0.3699, 0.3207, 0.3913]}, {"w": "complex", "b": [0.3255, 0.3699, 0.3964, 0.3913]}, {"w": "(in", "b": [0.4012, 0.3699, 0.4254, 0.3913]}, {"w": "which", "b": [0.4301, 0.3699, 0.481, 0.3913]}, {"w": "case", "b": [0.4857, 0.3699, 0.5202, 0.3913]}, {"w": "it", "b": [0.5249, 0.3699, 0.5369, 0.3913]}, {"w": "will", "b": [0.5416, 0.3699, 0.572, 0.3913]}, {"w": "overfit).", "b": [0.5767, 0.3699, 0.6436, 0.3913]}]}, {"id": "b_4", "type": "paragraph", "text": "There’s just one last important topic to cover: once you have trained a model, you don’t want to just “hope” it generalizes to new cases. You want to evaluate it, and fine- tune it if necessary. Let’s see how.", "words": [{"w": "There’s", "b": [0.1429, 0.4041, 0.2014, 0.4255]}, {"w": "just", "b": [0.2088, 0.4041, 0.2392, 0.4255]}, {"w": "one", "b": [0.2467, 0.4041, 0.2775, 0.4255]}, {"w": "last", "b": [0.285, 0.4041, 0.3134, 0.4255]}, {"w": "important", "b": [0.3208, 0.4041, 0.4052, 0.4255]}, {"w": "topic", "b": [0.4126, 0.4041, 0.4549, 0.4255]}, {"w": "to", "b": [0.4624, 0.4041, 0.4794, 0.4255]}, {"w": "cover:", "b": [0.4868, 0.4041, 0.5377, 0.4255]}, {"w": "once", "b": [0.5452, 0.4041, 0.5848, 0.4255]}, {"w": "you", "b": [0.5923, 0.4041, 0.6235, 0.4255]}, {"w": "have", "b": [0.631, 0.4041, 0.6694, 0.4255]}, {"w": "trained", "b": [0.6768, 0.4041, 0.7369, 0.4255]}, {"w": "a", "b": [0.7443, 0.4041, 0.7535, 0.4255]}, {"w": "model,", "b": [0.7609, 0.4041, 0.8185, 0.4255]}, {"w": "you", "b": [0.8259, 0.4041, 0.8571, 0.4255]}, {"w": "don’t", "b": [0.1429, 0.4231, 0.1845, 0.4445]}, {"w": "want", "b": [0.1894, 0.4231, 0.2302, 0.4445]}, {"w": "to", "b": [0.2352, 0.4231, 0.2522, 0.4445]}, {"w": "just", "b": [0.2572, 0.4231, 0.2876, 0.4445]}, {"w": "“hope”", "b": [0.2925, 0.4231, 0.3495, 0.4445]}, {"w": "it", "b": [0.3545, 0.4231, 0.3664, 0.4445]}, {"w": "generalizes", "b": [0.3714, 0.4231, 0.4632, 0.4445]}, {"w": "to", "b": [0.4682, 0.4231, 0.4852, 0.4445]}, {"w": "new", "b": [0.4902, 0.4231, 0.5247, 0.4445]}, {"w": "cases.", "b": [0.5297, 0.4231, 0.5766, 0.4445]}, {"w": "You", "b": [0.5815, 0.4231, 0.6139, 0.4445]}, {"w": "want", "b": [0.6189, 0.4231, 0.6597, 0.4445]}, {"w": "to", "b": [0.6646, 0.4231, 0.6816, 0.4445]}, {"w": "evaluate", "b": [0.6866, 0.4231, 0.7545, 0.4445]}, {"w": "it,", "b": [0.7595, 0.4231, 0.7762, 0.4445]}, {"w": "and", "b": [0.7812, 0.4231, 0.8127, 0.4445]}, {"w": "fine-", "b": [0.8177, 0.4231, 0.8571, 0.4445]}, {"w": "tune", "b": [0.1429, 0.4422, 0.1805, 0.4636]}, {"w": "it", "b": [0.1852, 0.4422, 0.1972, 0.4636]}, {"w": "if", "b": [0.2019, 0.4422, 0.2137, 0.4636]}, {"w": "necessary.", "b": [0.2184, 0.4422, 0.3019, 0.4636]}, {"w": "Let’s", "b": [0.3066, 0.4422, 0.3428, 0.4636]}, {"w": "see", "b": [0.3475, 0.4422, 0.3729, 0.4636]}, {"w": "how.", "b": [0.3776, 0.4422, 0.4168, 0.4636]}]}, {"id": "b_5", "type": "paragraph", "text": "Testing and Validating", "words": [{"w": "Testing", "b": [0.1429, 0.4766, 0.234, 0.5108]}, {"w": "and", "b": [0.2399, 0.4766, 0.2871, 0.5108]}, {"w": "Validating", "b": [0.293, 0.4766, 0.4214, 0.5108]}]}, {"id": "b_6", "type": "paragraph", "text": "The only way to know how well a model will generalize to new cases is to actually try it out on new cases. One way to do that is to put your model in production and moni‐ tor how well it performs. This works well, but if your model is horribly bad, your users will complain—not the best idea.", "words": [{"w": "The", "b": [0.1429, 0.5178, 0.1757, 0.5392]}, {"w": "only", "b": [0.181, 0.5178, 0.2178, 0.5392]}, {"w": "way", "b": [0.2231, 0.5178, 0.2557, 0.5392]}, {"w": "to", "b": [0.2609, 0.5178, 0.2779, 0.5392]}, {"w": "know", "b": [0.2832, 0.5178, 0.3298, 0.5392]}, {"w": "how", "b": [0.3351, 0.5178, 0.3711, 0.5392]}, {"w": "well", "b": [0.3764, 0.5178, 0.41, 0.5392]}, {"w": "a", "b": [0.4153, 0.5178, 0.4244, 0.5392]}, {"w": "model", "b": [0.4297, 0.5178, 0.4825, 0.5392]}, {"w": "will", "b": [0.4878, 0.5178, 0.5182, 0.5392]}, {"w": "generalize", "b": [0.5234, 0.5178, 0.6076, 0.5392]}, {"w": "to", "b": [0.6129, 0.5178, 0.6299, 0.5392]}, {"w": "new", "b": [0.6351, 0.5178, 0.6696, 0.5392]}, {"w": "cases", "b": [0.6749, 0.5178, 0.717, 0.5392]}, {"w": "is", "b": [0.7223, 0.5178, 0.7355, 0.5392]}, {"w": "to", "b": [0.7408, 0.5178, 0.7577, 0.5392]}, {"w": "actually", "b": [0.763, 0.5178, 0.8276, 0.5392]}, {"w": "try", "b": [0.8329, 0.5178, 0.8571, 0.5392]}, {"w": "it", "b": [0.1429, 0.5368, 0.1548, 0.5582]}, {"w": "out", "b": [0.1596, 0.5368, 0.1876, 0.5582]}, {"w": "on", "b": [0.1924, 0.5368, 0.2144, 0.5582]}, {"w": "new", "b": [0.2192, 0.5368, 0.2538, 0.5582]}, {"w": "cases.", "b": [0.2585, 0.5368, 0.3054, 0.5582]}, {"w": "One", "b": [0.3102, 0.5368, 0.346, 0.5582]}, {"w": "way", "b": [0.3508, 0.5368, 0.3834, 0.5582]}, {"w": "to", "b": [0.3882, 0.5368, 0.4052, 0.5582]}, {"w": "do", "b": [0.41, 0.5368, 0.4316, 0.5582]}, {"w": "that", "b": [0.4364, 0.5368, 0.469, 0.5582]}, {"w": "is", "b": [0.4738, 0.5368, 0.487, 0.5582]}, {"w": "to", "b": [0.4918, 0.5368, 0.5088, 0.5582]}, {"w": "put", "b": [0.5136, 0.5368, 0.5419, 0.5582]}, {"w": "your", "b": [0.5467, 0.5368, 0.5857, 0.5582]}, {"w": "model", "b": [0.5904, 0.5368, 0.6433, 0.5582]}, {"w": "in", "b": [0.6481, 0.5368, 0.665, 0.5582]}, {"w": "production", "b": [0.6698, 0.5368, 0.7639, 0.5582]}, {"w": "and", "b": [0.7687, 0.5368, 0.8003, 0.5582]}, {"w": "moni‐", "b": [0.8051, 0.5368, 0.8571, 0.5582]}, {"w": "tor", "b": [0.1428, 0.5559, 0.1676, 0.5773]}, {"w": "how", "b": [0.1751, 0.5559, 0.2111, 0.5773]}, {"w": "well", "b": [0.2186, 0.5559, 0.2523, 0.5773]}, {"w": "it", "b": [0.2598, 0.5559, 0.2717, 0.5773]}, {"w": "performs.", "b": [0.2793, 0.5559, 0.3607, 0.5773]}, {"w": "This", "b": [0.3683, 0.5559, 0.4055, 0.5773]}, {"w": "works", "b": [0.413, 0.5559, 0.4636, 0.5773]}, {"w": "well,", "b": [0.4711, 0.5559, 0.5095, 0.5773]}, {"w": "but", "b": [0.5171, 0.5559, 0.5451, 0.5773]}, {"w": "if", "b": [0.5526, 0.5559, 0.5643, 0.5773]}, {"w": "your", "b": [0.5718, 0.5559, 0.6108, 0.5773]}, {"w": "model", "b": [0.6183, 0.5559, 0.6712, 0.5773]}, {"w": "is", "b": [0.6787, 0.5559, 0.6919, 0.5773]}, {"w": "horribly", "b": [0.6994, 0.5559, 0.7676, 0.5773]}, {"w": "bad,", "b": [0.7752, 0.5559, 0.8106, 0.5773]}, {"w": "your", "b": [0.8182, 0.5559, 0.8571, 0.5773]}, {"w": "users", "b": [0.1429, 0.5749, 0.1858, 0.5963]}, {"w": "will", "b": [0.1905, 0.5749, 0.2209, 0.5963]}, {"w": "complain—not", "b": [0.2257, 0.5749, 0.3517, 0.5963]}, {"w": "the", "b": [0.3564, 0.5749, 0.3827, 0.5963]}, {"w": "best", "b": [0.3874, 0.5749, 0.4209, 0.5963]}, {"w": "idea.", "b": [0.4256, 0.5749, 0.4649, 0.5963]}]}, {"id": "b_7", "type": "paragraph", "text": "A better option is to split your data into two sets: the training set and the test set. As these names imply, you train your model using the training set, and you test it using the test set. The error rate on new cases is called the generalization error (or out-of- sample error), and by evaluating your model on the test set, you get an estimate of this error. This value tells you how well your model will perform on instances it has never seen before.", "words": [{"w": "A", "b": [0.1429, 0.603, 0.1573, 0.6244]}, {"w": "better", "b": [0.1633, 0.603, 0.212, 0.6244]}, {"w": "option", "b": [0.2181, 0.603, 0.2736, 0.6244]}, {"w": "is", "b": [0.2796, 0.603, 0.2929, 0.6244]}, {"w": "to", "b": [0.2989, 0.603, 0.3159, 0.6244]}, {"w": "split", "b": [0.322, 0.603, 0.3577, 0.6244]}, {"w": "your", "b": [0.3638, 0.603, 0.4028, 0.6244]}, {"w": "data", "b": [0.4088, 0.603, 0.4441, 0.6244]}, {"w": "into", "b": [0.4501, 0.603, 0.4837, 0.6244]}, {"w": "two", "b": [0.4897, 0.603, 0.521, 0.6244]}, {"w": "sets:", "b": [0.527, 0.603, 0.5623, 0.6244]}, {"w": "the", "b": [0.5684, 0.603, 0.5947, 0.6244]}, {"w": "training", "b": [0.6007, 0.6028, 0.6652, 0.6244]}, {"w": "set", "b": [0.6713, 0.6028, 0.6929, 0.6244]}, {"w": "and", "b": [0.699, 0.603, 0.7305, 0.6244]}, {"w": "the", "b": [0.7366, 0.603, 0.7629, 0.6244]}, {"w": "test", "b": [0.769, 0.6028, 0.7965, 0.6244]}, {"w": "set.", "b": [0.8026, 0.6028, 0.8291, 0.6244]}, {"w": "As", "b": [0.8351, 0.603, 0.8571, 0.6244]}, {"w": "these", "b": [0.1429, 0.6221, 0.1857, 0.6435]}, {"w": "names", "b": [0.1915, 0.6221, 0.2456, 0.6435]}, {"w": "imply,", "b": [0.2514, 0.6221, 0.3026, 0.6435]}, {"w": "you", "b": [0.3085, 0.6221, 0.3397, 0.6435]}, {"w": "train", "b": [0.3455, 0.6221, 0.3857, 0.6435]}, {"w": "your", "b": [0.3915, 0.6221, 0.4305, 0.6435]}, {"w": "model", "b": [0.4363, 0.6221, 0.4891, 0.6435]}, {"w": "using", "b": [0.495, 0.6221, 0.5404, 0.6435]}, {"w": "the", "b": [0.5462, 0.6221, 0.5725, 0.6435]}, {"w": "training", "b": [0.5784, 0.6221, 0.6453, 0.6435]}, {"w": "set,", "b": [0.6511, 0.6221, 0.6787, 0.6435]}, {"w": "and", "b": [0.6845, 0.6221, 0.7161, 0.6435]}, {"w": "you", "b": [0.7219, 0.6221, 0.7531, 0.6435]}, {"w": "test", "b": [0.7589, 0.6221, 0.7881, 0.6435]}, {"w": "it", "b": [0.794, 0.6221, 0.8059, 0.6435]}, {"w": "using", "b": [0.8117, 0.6221, 0.8571, 0.6435]}, {"w": "the", "b": [0.1428, 0.6411, 0.1692, 0.6625]}, {"w": "test", "b": [0.1759, 0.6411, 0.2051, 0.6625]}, {"w": "set.", "b": [0.2117, 0.6411, 0.2393, 0.6625]}, {"w": "The", "b": [0.246, 0.6411, 0.2789, 0.6625]}, {"w": "error", "b": [0.2855, 0.6411, 0.3282, 0.6625]}, {"w": "rate", "b": [0.3349, 0.6411, 0.3666, 0.6625]}, {"w": "on", "b": [0.3732, 0.6411, 0.3953, 0.6625]}, {"w": "new", "b": [0.4019, 0.6411, 0.4364, 0.6625]}, {"w": "cases", "b": [0.4431, 0.6411, 0.4852, 0.6625]}, {"w": "is", "b": [0.4919, 0.6411, 0.5051, 0.6625]}, {"w": "called", "b": [0.5118, 0.6411, 0.5602, 0.6625]}, {"w": "the", "b": [0.5668, 0.6411, 0.5932, 0.6625]}, {"w": "generalization", "b": [0.5998, 0.6409, 0.715, 0.6625]}, {"w": "error", "b": [0.7217, 0.6409, 0.7623, 0.6625]}, {"w": "(or", "b": [0.769, 0.6411, 0.7945, 0.6625]}, {"w": "out-of-", "b": [0.8012, 0.6409, 0.8571, 0.6625]}, {"w": "sample", "b": [0.1429, 0.66, 0.1992, 0.6816]}, {"w": "error),", "b": [0.204, 0.66, 0.2566, 0.6816]}, {"w": "and", "b": [0.2615, 0.6602, 0.293, 0.6816]}, {"w": "by", "b": [0.2978, 0.6602, 0.318, 0.6816]}, {"w": "evaluating", "b": [0.3228, 0.6602, 0.4086, 0.6816]}, {"w": "your", "b": [0.4134, 0.6602, 0.4524, 0.6816]}, {"w": "model", "b": [0.4572, 0.6602, 0.51, 0.6816]}, {"w": "on", "b": [0.5149, 0.6602, 0.5369, 0.6816]}, {"w": "the", "b": [0.5417, 0.6602, 0.568, 0.6816]}, {"w": "test", "b": [0.5729, 0.6602, 0.6021, 0.6816]}, {"w": "set,", "b": [0.6069, 0.6602, 0.6345, 0.6816]}, {"w": "you", "b": [0.6393, 0.6602, 0.6706, 0.6816]}, {"w": "get", "b": [0.6754, 0.6602, 0.7004, 0.6816]}, {"w": "an", "b": [0.7052, 0.6602, 0.7257, 0.6816]}, {"w": "estimate", "b": [0.7305, 0.6602, 0.8, 0.6816]}, {"w": "of", "b": [0.8048, 0.6602, 0.8216, 0.6816]}, {"w": "this", "b": [0.8264, 0.6602, 0.8571, 0.6816]}, {"w": "error.", "b": [0.1429, 0.6792, 0.189, 0.7006]}, {"w": "This", "b": [0.194, 0.6792, 0.2312, 0.7006]}, {"w": "value", "b": [0.2363, 0.6792, 0.2803, 0.7006]}, {"w": "tells", "b": [0.2854, 0.6792, 0.3188, 0.7006]}, {"w": "you", "b": [0.3239, 0.6792, 0.3551, 0.7006]}, {"w": "how", "b": [0.3602, 0.6792, 0.3962, 0.7006]}, {"w": "well", "b": [0.4013, 0.6792, 0.435, 0.7006]}, {"w": "your", "b": [0.44, 0.6792, 0.479, 0.7006]}, {"w": "model", "b": [0.4841, 0.6792, 0.5369, 0.7006]}, {"w": "will", "b": [0.542, 0.6792, 0.5724, 0.7006]}, {"w": "perform", "b": [0.5775, 0.6792, 0.6466, 0.7006]}, {"w": "on", "b": [0.6516, 0.6792, 0.6737, 0.7006]}, {"w": "instances", "b": [0.6787, 0.6792, 0.7556, 0.7006]}, {"w": "it", "b": [0.7606, 0.6792, 0.7726, 0.7006]}, {"w": "has", "b": [0.7777, 0.6792, 0.8056, 0.7006]}, {"w": "never", "b": [0.8107, 0.6792, 0.8571, 0.7006]}, {"w": "seen", "b": [0.1429, 0.6983, 0.1796, 0.7197]}, {"w": "before.", "b": [0.1843, 0.6983, 0.2419, 0.7197]}]}, {"id": "b_8", "type": "paragraph", "text": "If the training error is low (i.e., your model makes few mistakes on the training set) but the generalization error is high, it means that your model is overfitting the train‐ ing data.", "words": [{"w": "If", "b": [0.1429, 0.7264, 0.1561, 0.7478]}, {"w": "the", "b": [0.1624, 0.7264, 0.1887, 0.7478]}, {"w": "training", "b": [0.1949, 0.7264, 0.2619, 0.7478]}, {"w": "error", "b": [0.2681, 0.7264, 0.3108, 0.7478]}, {"w": "is", "b": [0.317, 0.7264, 0.3303, 0.7478]}, {"w": "low", "b": [0.3365, 0.7264, 0.3667, 0.7478]}, {"w": "(i.e.,", "b": [0.3729, 0.7264, 0.4088, 0.7478]}, {"w": "your", "b": [0.4151, 0.7264, 0.454, 0.7478]}, {"w": "model", "b": [0.4603, 0.7264, 0.5131, 0.7478]}, {"w": "makes", "b": [0.5194, 0.7264, 0.5724, 0.7478]}, {"w": "few", "b": [0.5786, 0.7264, 0.6079, 0.7478]}, {"w": "mistakes", "b": [0.6142, 0.7264, 0.6868, 0.7478]}, {"w": "on", "b": [0.693, 0.7264, 0.7151, 0.7478]}, {"w": "the", "b": [0.7213, 0.7264, 0.7476, 0.7478]}, {"w": "training", "b": [0.7539, 0.7264, 0.8208, 0.7478]}, {"w": "set)", "b": [0.8271, 0.7264, 0.8571, 0.7478]}, {"w": "but", "b": [0.1428, 0.7454, 0.1708, 0.7668]}, {"w": "the", "b": [0.1764, 0.7454, 0.2028, 0.7668]}, {"w": "generalization", "b": [0.2083, 0.7454, 0.3264, 0.7668]}, {"w": "error", "b": [0.3319, 0.7454, 0.3746, 0.7668]}, {"w": "is", "b": [0.3802, 0.7454, 0.3934, 0.7668]}, {"w": "high,", "b": [0.399, 0.7454, 0.4413, 0.7668]}, {"w": "it", "b": [0.4469, 0.7454, 0.4588, 0.7668]}, {"w": "means", "b": [0.4644, 0.7454, 0.5185, 0.7668]}, {"w": "that", "b": [0.5241, 0.7454, 0.5567, 0.7668]}, {"w": "your", "b": [0.5622, 0.7454, 0.6012, 0.7668]}, {"w": "model", "b": [0.6068, 0.7454, 0.6596, 0.7668]}, {"w": "is", "b": [0.6652, 0.7454, 0.6784, 0.7668]}, {"w": "overfitting", "b": [0.684, 0.7454, 0.772, 0.7668]}, {"w": "the", "b": [0.7776, 0.7454, 0.8039, 0.7668]}, {"w": "train‐", "b": [0.8095, 0.7454, 0.8571, 0.7668]}, {"w": "ing", "b": [0.1429, 0.7645, 0.1696, 0.7859]}, {"w": "data.", "b": [0.1743, 0.7645, 0.2143, 0.7859]}]}, {"id": "b_9", "type": "paragraph", "text": "It is common to use 80% of the data for training and hold out 20% for testing. However, this depends on the size of the dataset: if it contains 10 million instances, then holding out 1% means your test set will contain 100,000 instances: that’s probably more than enough to get a good estimate of the generalization error.", "words": [{"w": "It", "b": [0.2714, 0.8064, 0.283, 0.826]}, {"w": "is", "b": [0.2883, 0.8064, 0.3004, 0.826]}, {"w": "common", "b": [0.3056, 0.8064, 0.3748, 0.826]}, {"w": "to", "b": [0.38, 0.8064, 0.3956, 0.826]}, {"w": "use", "b": [0.4009, 0.8064, 0.4261, 0.826]}, {"w": "80%", "b": [0.4314, 0.8064, 0.464, 0.826]}, {"w": "of", "b": [0.4693, 0.8064, 0.4847, 0.826]}, {"w": "the", "b": [0.49, 0.8064, 0.5141, 0.826]}, {"w": "data", "b": [0.5193, 0.8064, 0.5516, 0.826]}, {"w": "for", "b": [0.5569, 0.8064, 0.5793, 0.826]}, {"w": "training", "b": [0.5846, 0.8064, 0.6458, 0.826]}, {"w": "and", "b": [0.6511, 0.8064, 0.6799, 0.826]}, {"w": "hold", "b": [0.6852, 0.8062, 0.7179, 0.826]}, {"w": "out", "b": [0.7232, 0.8062, 0.7477, 0.826]}, {"w": "20%", "b": [0.753, 0.8064, 0.7857, 0.826]}, {"w": "for", "b": [0.2714, 0.8238, 0.2938, 0.8434]}, {"w": "testing.", "b": [0.3006, 0.8238, 0.3561, 0.8434]}, {"w": "However,", "b": [0.3629, 0.8238, 0.435, 0.8434]}, {"w": "this", "b": [0.4418, 0.8238, 0.4699, 0.8434]}, {"w": "depends", "b": [0.4767, 0.8238, 0.5404, 0.8434]}, {"w": "on", "b": [0.5472, 0.8238, 0.5673, 0.8434]}, {"w": "the", "b": [0.5741, 0.8238, 0.5982, 0.8434]}, {"w": "size", "b": [0.605, 0.8238, 0.6332, 0.8434]}, {"w": "of", "b": [0.64, 0.8238, 0.6553, 0.8434]}, {"w": "the", "b": [0.6621, 0.8238, 0.6862, 0.8434]}, {"w": "dataset:", "b": [0.693, 0.8238, 0.7505, 0.8434]}, {"w": "if", "b": [0.7573, 0.8238, 0.768, 0.8434]}, {"w": "it", "b": [0.7748, 0.8238, 0.7857, 0.8434]}, {"w": "contains", "b": [0.2714, 0.8412, 0.3359, 0.8608]}, {"w": "10", "b": [0.3406, 0.8412, 0.3589, 0.8608]}, {"w": "million", "b": [0.3635, 0.8412, 0.4191, 0.8608]}, {"w": "instances,", "b": [0.4238, 0.8412, 0.4984, 0.8608]}, {"w": "then", "b": [0.503, 0.8412, 0.5375, 0.8608]}, {"w": "holding", "b": [0.5422, 0.8412, 0.6014, 0.8608]}, {"w": "out", "b": [0.6061, 0.8412, 0.6317, 0.8608]}, {"w": "1%", "b": [0.6364, 0.8412, 0.6599, 0.8608]}, {"w": "means", "b": [0.6646, 0.8412, 0.714, 0.8608]}, {"w": "your", "b": [0.7187, 0.8412, 0.7543, 0.8608]}, {"w": "test", "b": [0.759, 0.8412, 0.7857, 0.8608]}, {"w": "set", "b": [0.2714, 0.8587, 0.2923, 0.8782]}, {"w": "will", "b": [0.3038, 0.8587, 0.3316, 0.8782]}, {"w": "contain", "b": [0.3432, 0.8587, 0.4007, 0.8782]}, {"w": "100,000", "b": [0.4122, 0.8587, 0.4714, 0.8782]}, {"w": "instances:", "b": [0.483, 0.8587, 0.5576, 0.8782]}, {"w": "that’s", "b": [0.5691, 0.8587, 0.6078, 0.8782]}, {"w": "probably", "b": [0.6194, 0.8587, 0.6874, 0.8782]}, {"w": "more", "b": [0.6989, 0.8587, 0.7394, 0.8782]}, {"w": "than", "b": [0.7509, 0.8587, 0.7857, 0.8782]}, {"w": "enough", "b": [0.2714, 0.8761, 0.3288, 0.8957]}, {"w": "to", "b": [0.3332, 0.8761, 0.3487, 0.8957]}, {"w": "get", "b": [0.353, 0.8761, 0.3758, 0.8957]}, {"w": "a", "b": [0.3801, 0.8761, 0.3885, 0.8957]}, {"w": "good", "b": [0.3928, 0.8761, 0.4312, 0.8957]}, {"w": "estimate", "b": [0.4356, 0.8761, 0.4991, 0.8957]}, {"w": "of", "b": [0.5034, 0.8761, 0.5187, 0.8957]}, {"w": "the", "b": [0.5231, 0.8761, 0.5471, 0.8957]}, {"w": "generalization", "b": [0.5515, 0.8761, 0.6594, 0.8957]}, {"w": "error.", "b": [0.6637, 0.8761, 0.7059, 0.8957]}]}, {"id": "b_10", "type": "paragraph", "text": "Testing and Validating | 31", "words": [{"w": "Testing", "b": [0.6706, 0.9225, 0.714, 0.9388]}, {"w": "and", "b": [0.7168, 0.9225, 0.7392, 0.9388]}, {"w": "Validating", "b": [0.742, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "31", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 58, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Hyperparameter Tuning and Model Selection", "words": [{"w": "Hyperparameter", "b": [0.1429, 0.0763, 0.3132, 0.1049]}, {"w": "Tuning", "b": [0.3181, 0.0763, 0.3902, 0.1049]}, {"w": "and", "b": [0.3951, 0.0763, 0.4344, 0.1049]}, {"w": "Model", "b": [0.4393, 0.0763, 0.5038, 0.1049]}, {"w": "Selection", "b": [0.5087, 0.0763, 0.6033, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "So evaluating a model is simple enough: just use a test set. Now suppose you are hesi‐ tating between two models (say a linear model and a polynomial model): how can you decide? One option is to train both and compare how well they generalize using the test set.", "words": [{"w": "So", "b": [0.1428, 0.1108, 0.1633, 0.1322]}, {"w": "evaluating", "b": [0.1684, 0.1108, 0.2542, 0.1322]}, {"w": "a", "b": [0.2593, 0.1108, 0.2685, 0.1322]}, {"w": "model", "b": [0.2735, 0.1108, 0.3264, 0.1322]}, {"w": "is", "b": [0.3314, 0.1108, 0.3447, 0.1322]}, {"w": "simple", "b": [0.3497, 0.1108, 0.4047, 0.1322]}, {"w": "enough:", "b": [0.4098, 0.1108, 0.4773, 0.1322]}, {"w": "just", "b": [0.4824, 0.1108, 0.5128, 0.1322]}, {"w": "use", "b": [0.5179, 0.1108, 0.5454, 0.1322]}, {"w": "a", "b": [0.5505, 0.1108, 0.5597, 0.1322]}, {"w": "test", "b": [0.5647, 0.1108, 0.5939, 0.1322]}, {"w": "set.", "b": [0.599, 0.1108, 0.6266, 0.1322]}, {"w": "Now", "b": [0.6317, 0.1108, 0.6716, 0.1322]}, {"w": "suppose", "b": [0.6766, 0.1108, 0.7443, 0.1322]}, {"w": "you", "b": [0.7494, 0.1108, 0.7806, 0.1322]}, {"w": "are", "b": [0.7857, 0.1108, 0.8114, 0.1322]}, {"w": "hesi‐", "b": [0.8165, 0.1108, 0.8571, 0.1322]}, {"w": "tating", "b": [0.1429, 0.1298, 0.191, 0.1512]}, {"w": "between", "b": [0.1984, 0.1298, 0.2676, 0.1512]}, {"w": "two", "b": [0.275, 0.1298, 0.3062, 0.1512]}, {"w": "models", "b": [0.3136, 0.1298, 0.374, 0.1512]}, {"w": "(say", "b": [0.3814, 0.1298, 0.4146, 0.1512]}, {"w": "a", "b": [0.422, 0.1298, 0.4311, 0.1512]}, {"w": "linear", "b": [0.4385, 0.1298, 0.4865, 0.1512]}, {"w": "model", "b": [0.4938, 0.1298, 0.5466, 0.1512]}, {"w": "and", "b": [0.554, 0.1298, 0.5855, 0.1512]}, {"w": "a", "b": [0.5929, 0.1298, 0.6021, 0.1512]}, {"w": "polynomial", "b": [0.6094, 0.1298, 0.7049, 0.1512]}, {"w": "model):", "b": [0.7123, 0.1298, 0.777, 0.1512]}, {"w": "how", "b": [0.7844, 0.1298, 0.8204, 0.1512]}, {"w": "can", "b": [0.8278, 0.1298, 0.8571, 0.1512]}, {"w": "you", "b": [0.1429, 0.1489, 0.1741, 0.1703]}, {"w": "decide?", "b": [0.1799, 0.1489, 0.2419, 0.1703]}, {"w": "One", "b": [0.2477, 0.1489, 0.2835, 0.1703]}, {"w": "option", "b": [0.2893, 0.1489, 0.3448, 0.1703]}, {"w": "is", "b": [0.3506, 0.1489, 0.3638, 0.1703]}, {"w": "to", "b": [0.3696, 0.1489, 0.3866, 0.1703]}, {"w": "train", "b": [0.3924, 0.1489, 0.4326, 0.1703]}, {"w": "both", "b": [0.4384, 0.1489, 0.4771, 0.1703]}, {"w": "and", "b": [0.4829, 0.1489, 0.5144, 0.1703]}, {"w": "compare", "b": [0.5202, 0.1489, 0.593, 0.1703]}, {"w": "how", "b": [0.5988, 0.1489, 0.6348, 0.1703]}, {"w": "well", "b": [0.6406, 0.1489, 0.6742, 0.1703]}, {"w": "they", "b": [0.68, 0.1489, 0.7159, 0.1703]}, {"w": "generalize", "b": [0.7217, 0.1489, 0.8059, 0.1703]}, {"w": "using", "b": [0.8117, 0.1489, 0.8571, 0.1703]}, {"w": "the", "b": [0.1429, 0.1679, 0.1692, 0.1893]}, {"w": "test", "b": [0.1739, 0.1679, 0.2031, 0.1893]}, {"w": "set.", "b": [0.2079, 0.1679, 0.2355, 0.1893]}]}, {"id": "b_2", "type": "paragraph", "text": "Now suppose that the linear model generalizes better, but you want to apply some regularization to avoid overfitting. The question is: how do you choose the value of the regularization hyperparameter? One option is to train 100 different models using 100 different values for this hyperparameter. Suppose you find the best hyperparame‐ ter value that produces a model with the lowest generalization error, say just 5% error.", "words": [{"w": "Now", "b": [0.1429, 0.196, 0.1827, 0.2175]}, {"w": "suppose", "b": [0.1896, 0.196, 0.2573, 0.2175]}, {"w": "that", "b": [0.2642, 0.196, 0.2967, 0.2175]}, {"w": "the", "b": [0.3036, 0.196, 0.33, 0.2175]}, {"w": "linear", "b": [0.3368, 0.196, 0.3848, 0.2175]}, {"w": "model", "b": [0.3917, 0.196, 0.4445, 0.2175]}, {"w": "generalizes", "b": [0.4514, 0.196, 0.5432, 0.2175]}, {"w": "better,", "b": [0.5501, 0.196, 0.6023, 0.2175]}, {"w": "but", "b": [0.6092, 0.196, 0.6372, 0.2175]}, {"w": "you", "b": [0.6441, 0.196, 0.6753, 0.2175]}, {"w": "want", "b": [0.6822, 0.196, 0.723, 0.2175]}, {"w": "to", "b": [0.7299, 0.196, 0.7469, 0.2175]}, {"w": "apply", "b": [0.7538, 0.196, 0.7992, 0.2175]}, {"w": "some", "b": [0.8061, 0.196, 0.8502, 0.2175]}, {"w": "regularization", "b": [0.1429, 0.2151, 0.2594, 0.2365]}, {"w": "to", "b": [0.266, 0.2151, 0.283, 0.2365]}, {"w": "avoid", "b": [0.2896, 0.2151, 0.3352, 0.2365]}, {"w": "overfitting.", "b": [0.3418, 0.2151, 0.4346, 0.2365]}, {"w": "The", "b": [0.4412, 0.2151, 0.474, 0.2365]}, {"w": "question", "b": [0.4806, 0.2151, 0.5528, 0.2365]}, {"w": "is:", "b": [0.5594, 0.2151, 0.5773, 0.2365]}, {"w": "how", "b": [0.5839, 0.2151, 0.62, 0.2365]}, {"w": "do", "b": [0.6265, 0.2151, 0.6482, 0.2365]}, {"w": "you", "b": [0.6548, 0.2151, 0.686, 0.2365]}, {"w": "choose", "b": [0.6926, 0.2151, 0.7503, 0.2365]}, {"w": "the", "b": [0.7569, 0.2151, 0.7832, 0.2365]}, {"w": "value", "b": [0.7898, 0.2151, 0.8338, 0.2365]}, {"w": "of", "b": [0.8404, 0.2151, 0.8572, 0.2365]}, {"w": "the", "b": [0.1429, 0.2341, 0.1692, 0.2555]}, {"w": "regularization", "b": [0.1747, 0.2341, 0.2913, 0.2555]}, {"w": "hyperparameter?", "b": [0.2968, 0.2341, 0.4382, 0.2555]}, {"w": "One", "b": [0.4437, 0.2341, 0.4795, 0.2555]}, {"w": "option", "b": [0.485, 0.2341, 0.5405, 0.2555]}, {"w": "is", "b": [0.546, 0.2341, 0.5593, 0.2555]}, {"w": "to", "b": [0.5648, 0.2341, 0.5818, 0.2555]}, {"w": "train", "b": [0.5873, 0.2341, 0.6275, 0.2555]}, {"w": "100", "b": [0.633, 0.2341, 0.663, 0.2555]}, {"w": "different", "b": [0.6685, 0.2341, 0.7402, 0.2555]}, {"w": "models", "b": [0.7457, 0.2341, 0.8062, 0.2555]}, {"w": "using", "b": [0.8117, 0.2341, 0.8571, 0.2555]}, {"w": "100", "b": [0.1429, 0.2532, 0.1729, 0.2746]}, {"w": "different", "b": [0.1779, 0.2532, 0.2496, 0.2746]}, {"w": "values", "b": [0.2547, 0.2532, 0.3063, 0.2746]}, {"w": "for", "b": [0.3114, 0.2532, 0.3359, 0.2746]}, {"w": "this", "b": [0.341, 0.2532, 0.3717, 0.2746]}, {"w": "hyperparameter.", "b": [0.3768, 0.2532, 0.5137, 0.2746]}, {"w": "Suppose", "b": [0.5188, 0.2532, 0.5887, 0.2746]}, {"w": "you", "b": [0.5937, 0.2532, 0.625, 0.2746]}, {"w": "find", "b": [0.63, 0.2532, 0.6642, 0.2746]}, {"w": "the", "b": [0.6693, 0.2532, 0.6956, 0.2746]}, {"w": "best", "b": [0.7007, 0.2532, 0.7341, 0.2746]}, {"w": "hyperparame‐", "b": [0.7392, 0.2532, 0.8571, 0.2746]}, {"w": "ter", "b": [0.1428, 0.2722, 0.1658, 0.2936]}, {"w": "value", "b": [0.1705, 0.2722, 0.2145, 0.2936]}, {"w": "that", "b": [0.2192, 0.2722, 0.2518, 0.2936]}, {"w": "produces", "b": [0.2565, 0.2722, 0.3332, 0.2936]}, {"w": "a", "b": [0.3379, 0.2722, 0.3471, 0.2936]}, {"w": "model", "b": [0.3518, 0.2722, 0.4046, 0.2936]}, {"w": "with", "b": [0.4093, 0.2722, 0.4467, 0.2936]}, {"w": "the", "b": [0.4514, 0.2722, 0.4777, 0.2936]}, {"w": "lowest", "b": [0.4825, 0.2722, 0.5355, 0.2936]}, {"w": "generalization", "b": [0.5402, 0.2722, 0.6582, 0.2936]}, {"w": "error,", "b": [0.663, 0.2722, 0.7091, 0.2936]}, {"w": "say", "b": [0.7138, 0.2722, 0.7398, 0.2936]}, {"w": "just", "b": [0.7445, 0.2722, 0.7749, 0.2936]}, {"w": "5%", "b": [0.7796, 0.2722, 0.8054, 0.2936]}, {"w": "error.", "b": [0.8101, 0.2722, 0.8562, 0.2936]}]}, {"id": "b_3", "type": "paragraph", "text": "So you launch this model into production, but unfortunately it does not perform as well as expected and produces 15% errors. What just happened?", "words": [{"w": "So", "b": [0.1428, 0.3003, 0.1633, 0.3218]}, {"w": "you", "b": [0.1698, 0.3003, 0.201, 0.3218]}, {"w": "launch", "b": [0.2074, 0.3003, 0.2638, 0.3218]}, {"w": "this", "b": [0.2702, 0.3003, 0.3009, 0.3218]}, {"w": "model", "b": [0.3073, 0.3003, 0.3602, 0.3218]}, {"w": "into", "b": [0.3666, 0.3003, 0.4001, 0.3218]}, {"w": "production,", "b": [0.4065, 0.3003, 0.5054, 0.3218]}, {"w": "but", "b": [0.5118, 0.3003, 0.5398, 0.3218]}, {"w": "unfortunately", "b": [0.5462, 0.3003, 0.6608, 0.3218]}, {"w": "it", "b": [0.6672, 0.3003, 0.6791, 0.3218]}, {"w": "does", "b": [0.6855, 0.3003, 0.7237, 0.3218]}, {"w": "not", "b": [0.7301, 0.3003, 0.7584, 0.3218]}, {"w": "perform", "b": [0.7649, 0.3003, 0.8339, 0.3218]}, {"w": "as", "b": [0.8403, 0.3003, 0.8571, 0.3218]}, {"w": "well", "b": [0.1429, 0.3194, 0.1765, 0.3408]}, {"w": "as", "b": [0.1813, 0.3194, 0.198, 0.3408]}, {"w": "expected", "b": [0.2028, 0.3194, 0.2763, 0.3408]}, {"w": "and", "b": [0.281, 0.3194, 0.3125, 0.3408]}, {"w": "produces", "b": [0.3173, 0.3194, 0.3939, 0.3408]}, {"w": "15%", "b": [0.3986, 0.3194, 0.4344, 0.3408]}, {"w": "errors.", "b": [0.4391, 0.3194, 0.4942, 0.3408]}, {"w": "What", "b": [0.4989, 0.3194, 0.5454, 0.3408]}, {"w": "just", "b": [0.5501, 0.3194, 0.5805, 0.3408]}, {"w": "happened?", "b": [0.5852, 0.3194, 0.6749, 0.3408]}]}, {"id": "b_4", "type": "paragraph", "text": "The problem is that you measured the generalization error multiple times on the test set, and you adapted the model and hyperparameters to produce the best model for that particular set. This means that the model is unlikely to perform as well on new data.", "words": [{"w": "The", "b": [0.1429, 0.3475, 0.1757, 0.3689]}, {"w": "problem", "b": [0.1812, 0.3475, 0.2523, 0.3689]}, {"w": "is", "b": [0.2578, 0.3475, 0.271, 0.3689]}, {"w": "that", "b": [0.2766, 0.3475, 0.3091, 0.3689]}, {"w": "you", "b": [0.3147, 0.3475, 0.3459, 0.3689]}, {"w": "measured", "b": [0.3515, 0.3475, 0.4328, 0.3689]}, {"w": "the", "b": [0.4383, 0.3475, 0.4647, 0.3689]}, {"w": "generalization", "b": [0.4702, 0.3475, 0.5883, 0.3689]}, {"w": "error", "b": [0.5938, 0.3475, 0.6364, 0.3689]}, {"w": "multiple", "b": [0.642, 0.3475, 0.712, 0.3689]}, {"w": "times", "b": [0.7175, 0.3475, 0.763, 0.3689]}, {"w": "on", "b": [0.7685, 0.3475, 0.7905, 0.3689]}, {"w": "the", "b": [0.7961, 0.3475, 0.8224, 0.3689]}, {"w": "test", "b": [0.8279, 0.3475, 0.8571, 0.3689]}, {"w": "set,", "b": [0.1429, 0.3666, 0.1705, 0.388]}, {"w": "and", "b": [0.177, 0.3666, 0.2085, 0.388]}, {"w": "you", "b": [0.2151, 0.3666, 0.2463, 0.388]}, {"w": "adapted", "b": [0.2528, 0.3666, 0.3188, 0.388]}, {"w": "the", "b": [0.3254, 0.3666, 0.3517, 0.388]}, {"w": "model", "b": [0.3582, 0.3666, 0.411, 0.388]}, {"w": "and", "b": [0.4176, 0.3666, 0.4491, 0.388]}, {"w": "hyperparameters", "b": [0.4556, 0.3666, 0.5968, 0.388]}, {"w": "to", "b": [0.6033, 0.3666, 0.6203, 0.388]}, {"w": "produce", "b": [0.6268, 0.3666, 0.6958, 0.388]}, {"w": "the", "b": [0.7023, 0.3666, 0.7287, 0.388]}, {"w": "best", "b": [0.7352, 0.3666, 0.7686, 0.388]}, {"w": "model", "b": [0.7752, 0.3666, 0.828, 0.388]}, {"w": "for", "b": [0.8345, 0.3664, 0.8571, 0.388]}, {"w": "that", "b": [0.1429, 0.3854, 0.1757, 0.407]}, {"w": "particular", "b": [0.1822, 0.3854, 0.2635, 0.407]}, {"w": "set.", "b": [0.27, 0.3854, 0.2964, 0.407]}, {"w": "This", "b": [0.3029, 0.3856, 0.3401, 0.407]}, {"w": "means", "b": [0.3466, 0.3856, 0.4007, 0.407]}, {"w": "that", "b": [0.4071, 0.3856, 0.4397, 0.407]}, {"w": "the", "b": [0.4462, 0.3856, 0.4725, 0.407]}, {"w": "model", "b": [0.479, 0.3856, 0.5318, 0.407]}, {"w": "is", "b": [0.5383, 0.3856, 0.5515, 0.407]}, {"w": "unlikely", "b": [0.558, 0.3856, 0.6253, 0.407]}, {"w": "to", "b": [0.6318, 0.3856, 0.6487, 0.407]}, {"w": "perform", "b": [0.6552, 0.3856, 0.7243, 0.407]}, {"w": "as", "b": [0.7307, 0.3856, 0.7475, 0.407]}, {"w": "well", "b": [0.754, 0.3856, 0.7877, 0.407]}, {"w": "on", "b": [0.7941, 0.3856, 0.8162, 0.407]}, {"w": "new", "b": [0.8226, 0.3856, 0.8571, 0.407]}, {"w": "data.", "b": [0.1429, 0.4047, 0.1829, 0.4261]}]}, {"id": "b_5", "type": "paragraph", "text": "A common solution to this problem is called holdout validation: you simply hold out part of the training set to evaluate several candidate models and select the best one. The new heldout set is called the validation set (or sometimes the development set, or dev set). More specifically, you train multiple models with various hyperparameters on the reduced training set (i.e., the full training set minus the validation set), and you select the model that performs best on the validation set. After this holdout vali‐ dation process, you train the best model on the full training set (including the valida‐ tion set), and this gives you the final model. Lastly, you evaluate this final model on the test set to get an estimate of the generalization error.", "words": [{"w": "A", "b": [0.1429, 0.4328, 0.1573, 0.4542]}, {"w": "common", "b": [0.1629, 0.4328, 0.2384, 0.4542]}, {"w": "solution", "b": [0.244, 0.4328, 0.3126, 0.4542]}, {"w": "to", "b": [0.3182, 0.4328, 0.3352, 0.4542]}, {"w": "this", "b": [0.3408, 0.4328, 0.3715, 0.4542]}, {"w": "problem", "b": [0.3771, 0.4328, 0.4481, 0.4542]}, {"w": "is", "b": [0.4537, 0.4328, 0.4669, 0.4542]}, {"w": "called", "b": [0.4725, 0.4328, 0.5209, 0.4542]}, {"w": "holdout", "b": [0.5265, 0.4326, 0.589, 0.4542]}, {"w": "validation:", "b": [0.5946, 0.4326, 0.6818, 0.4542]}, {"w": "you", "b": [0.6874, 0.4328, 0.7187, 0.4542]}, {"w": "simply", "b": [0.7243, 0.4328, 0.7799, 0.4542]}, {"w": "hold", "b": [0.7855, 0.4328, 0.8235, 0.4542]}, {"w": "out", "b": [0.8291, 0.4328, 0.8572, 0.4542]}, {"w": "part", "b": [0.1429, 0.4518, 0.177, 0.4732]}, {"w": "of", "b": [0.1835, 0.4518, 0.2003, 0.4732]}, {"w": "the", "b": [0.2068, 0.4518, 0.2331, 0.4732]}, {"w": "training", "b": [0.2396, 0.4518, 0.3066, 0.4732]}, {"w": "set", "b": [0.3131, 0.4518, 0.3359, 0.4732]}, {"w": "to", "b": [0.3424, 0.4518, 0.3594, 0.4732]}, {"w": "evaluate", "b": [0.3659, 0.4518, 0.4339, 0.4732]}, {"w": "several", "b": [0.4404, 0.4518, 0.4975, 0.4732]}, {"w": "candidate", "b": [0.504, 0.4518, 0.5849, 0.4732]}, {"w": "models", "b": [0.5914, 0.4518, 0.6519, 0.4732]}, {"w": "and", "b": [0.6584, 0.4518, 0.6899, 0.4732]}, {"w": "select", "b": [0.6964, 0.4518, 0.7422, 0.4732]}, {"w": "the", "b": [0.7487, 0.4518, 0.7751, 0.4732]}, {"w": "best", "b": [0.7816, 0.4518, 0.815, 0.4732]}, {"w": "one.", "b": [0.8215, 0.4518, 0.8571, 0.4732]}, {"w": "The", "b": [0.1429, 0.4709, 0.1757, 0.4923]}, {"w": "new", "b": [0.1813, 0.4709, 0.2158, 0.4923]}, {"w": "heldout", "b": [0.2215, 0.4709, 0.2858, 0.4923]}, {"w": "set", "b": [0.2914, 0.4709, 0.3143, 0.4923]}, {"w": "is", "b": [0.3199, 0.4709, 0.3331, 0.4923]}, {"w": "called", "b": [0.3388, 0.4709, 0.3871, 0.4923]}, {"w": "the", "b": [0.3928, 0.4709, 0.4191, 0.4923]}, {"w": "validation", "b": [0.4247, 0.4707, 0.5072, 0.4923]}, {"w": "set", "b": [0.5129, 0.4707, 0.5345, 0.4923]}, {"w": "(or", "b": [0.5402, 0.4709, 0.5657, 0.4923]}, {"w": "sometimes", "b": [0.5714, 0.4709, 0.6611, 0.4923]}, {"w": "the", "b": [0.6667, 0.4709, 0.693, 0.4923]}, {"w": "development", "b": [0.6987, 0.4707, 0.8011, 0.4923]}, {"w": "set,", "b": [0.8067, 0.4707, 0.8331, 0.4923]}, {"w": "or", "b": [0.8388, 0.4709, 0.8571, 0.4923]}, {"w": "dev", "b": [0.1428, 0.4897, 0.1711, 0.5113]}, {"w": "set).", "b": [0.1782, 0.4897, 0.2118, 0.5113]}, {"w": "More", "b": [0.2188, 0.4899, 0.2641, 0.5113]}, {"w": "specifically,", "b": [0.2711, 0.4899, 0.366, 0.5113]}, {"w": "you", "b": [0.373, 0.4899, 0.4043, 0.5113]}, {"w": "train", "b": [0.4113, 0.4899, 0.4515, 0.5113]}, {"w": "multiple", "b": [0.4586, 0.4899, 0.5286, 0.5113]}, {"w": "models", "b": [0.5356, 0.4899, 0.5961, 0.5113]}, {"w": "with", "b": [0.6031, 0.4899, 0.6405, 0.5113]}, {"w": "various", "b": [0.6475, 0.4899, 0.7089, 0.5113]}, {"w": "hyperparameters", "b": [0.716, 0.4899, 0.8571, 0.5113]}, {"w": "on", "b": [0.1429, 0.509, 0.1649, 0.5304]}, {"w": "the", "b": [0.1721, 0.509, 0.1984, 0.5304]}, {"w": "reduced", "b": [0.2056, 0.509, 0.2729, 0.5304]}, {"w": "training", "b": [0.2801, 0.509, 0.347, 0.5304]}, {"w": "set", "b": [0.3542, 0.509, 0.3771, 0.5304]}, {"w": "(i.e.,", "b": [0.3843, 0.509, 0.4202, 0.5304]}, {"w": "the", "b": [0.4273, 0.509, 0.4537, 0.5304]}, {"w": "full", "b": [0.4609, 0.509, 0.4886, 0.5304]}, {"w": "training", "b": [0.4958, 0.509, 0.5628, 0.5304]}, {"w": "set", "b": [0.57, 0.509, 0.5928, 0.5304]}, {"w": "minus", "b": [0.6, 0.509, 0.6524, 0.5304]}, {"w": "the", "b": [0.6595, 0.509, 0.6859, 0.5304]}, {"w": "validation", "b": [0.6931, 0.509, 0.7764, 0.5304]}, {"w": "set),", "b": [0.7836, 0.509, 0.8184, 0.5304]}, {"w": "and", "b": [0.8256, 0.509, 0.8571, 0.5304]}, {"w": "you", "b": [0.1429, 0.528, 0.1741, 0.5494]}, {"w": "select", "b": [0.1797, 0.528, 0.2255, 0.5494]}, {"w": "the", "b": [0.2311, 0.528, 0.2575, 0.5494]}, {"w": "model", "b": [0.2631, 0.528, 0.3159, 0.5494]}, {"w": "that", "b": [0.3215, 0.528, 0.3541, 0.5494]}, {"w": "performs", "b": [0.3597, 0.528, 0.4365, 0.5494]}, {"w": "best", "b": [0.4421, 0.528, 0.4755, 0.5494]}, {"w": "on", "b": [0.4811, 0.528, 0.5032, 0.5494]}, {"w": "the", "b": [0.5088, 0.528, 0.5351, 0.5494]}, {"w": "validation", "b": [0.5407, 0.528, 0.6241, 0.5494]}, {"w": "set.", "b": [0.6297, 0.528, 0.6573, 0.5494]}, {"w": "After", "b": [0.6629, 0.528, 0.7064, 0.5494]}, {"w": "this", "b": [0.7121, 0.528, 0.7428, 0.5494]}, {"w": "holdout", "b": [0.7484, 0.528, 0.8145, 0.5494]}, {"w": "vali‐", "b": [0.8201, 0.528, 0.8571, 0.5494]}, {"w": "dation", "b": [0.1429, 0.5471, 0.1966, 0.5685]}, {"w": "process,", "b": [0.2018, 0.5471, 0.2688, 0.5685]}, {"w": "you", "b": [0.274, 0.5471, 0.3052, 0.5685]}, {"w": "train", "b": [0.3104, 0.5471, 0.3506, 0.5685]}, {"w": "the", "b": [0.3559, 0.5471, 0.3822, 0.5685]}, {"w": "best", "b": [0.3874, 0.5471, 0.4209, 0.5685]}, {"w": "model", "b": [0.4261, 0.5471, 0.4789, 0.5685]}, {"w": "on", "b": [0.4841, 0.5471, 0.5061, 0.5685]}, {"w": "the", "b": [0.5113, 0.5471, 0.5377, 0.5685]}, {"w": "full", "b": [0.5429, 0.5471, 0.5707, 0.5685]}, {"w": "training", "b": [0.5759, 0.5471, 0.6428, 0.5685]}, {"w": "set", "b": [0.648, 0.5471, 0.6709, 0.5685]}, {"w": "(including", "b": [0.6761, 0.5471, 0.7632, 0.5685]}, {"w": "the", "b": [0.7684, 0.5471, 0.7947, 0.5685]}, {"w": "valida‐", "b": [0.7999, 0.5471, 0.8571, 0.5685]}, {"w": "tion", "b": [0.1429, 0.5661, 0.1768, 0.5875]}, {"w": "set),", "b": [0.1831, 0.5661, 0.2179, 0.5875]}, {"w": "and", "b": [0.2242, 0.5661, 0.2558, 0.5875]}, {"w": "this", "b": [0.2621, 0.5661, 0.2928, 0.5875]}, {"w": "gives", "b": [0.2991, 0.5661, 0.3405, 0.5875]}, {"w": "you", "b": [0.3468, 0.5661, 0.3781, 0.5875]}, {"w": "the", "b": [0.3844, 0.5661, 0.4107, 0.5875]}, {"w": "final", "b": [0.417, 0.5661, 0.4546, 0.5875]}, {"w": "model.", "b": [0.4608, 0.5661, 0.5184, 0.5875]}, {"w": "Lastly,", "b": [0.5247, 0.5661, 0.5771, 0.5875]}, {"w": "you", "b": [0.5834, 0.5661, 0.6147, 0.5875]}, {"w": "evaluate", "b": [0.6209, 0.5661, 0.6889, 0.5875]}, {"w": "this", "b": [0.6952, 0.5661, 0.7259, 0.5875]}, {"w": "final", "b": [0.7322, 0.5661, 0.7697, 0.5875]}, {"w": "model", "b": [0.776, 0.5661, 0.8288, 0.5875]}, {"w": "on", "b": [0.8351, 0.5661, 0.8572, 0.5875]}, {"w": "the", "b": [0.1429, 0.5852, 0.1692, 0.6066]}, {"w": "test", "b": [0.1739, 0.5852, 0.2031, 0.6066]}, {"w": "set", "b": [0.2079, 0.5852, 0.2307, 0.6066]}, {"w": "to", "b": [0.2354, 0.5852, 0.2524, 0.6066]}, {"w": "get", "b": [0.2572, 0.5852, 0.2821, 0.6066]}, {"w": "an", "b": [0.2868, 0.5852, 0.3074, 0.6066]}, {"w": "estimate", "b": [0.3121, 0.5852, 0.3816, 0.6066]}, {"w": "of", "b": [0.3863, 0.5852, 0.4031, 0.6066]}, {"w": "the", "b": [0.4078, 0.5852, 0.4342, 0.6066]}, {"w": "generalization", "b": [0.4389, 0.5852, 0.5569, 0.6066]}, {"w": "error.", "b": [0.5617, 0.5852, 0.6078, 0.6066]}]}, {"id": "b_6", "type": "paragraph", "text": "This solution usually works quite well. However, if the validation set is too small, then model evaluations will be imprecise: you may end up selecting a suboptimal model by mistake. Conversely, if the validation set is too large, then the remaining training set will be much smaller than the full training set. Why is this bad? Well, since the final model will be trained on the full training set, it is not ideal to compare candidate models trained on a much smaller training set. It would be like selecting the fastest sprinter to participate in a marathon. One way to solve this problem is to perform repeated cross-validation, using many small validation sets. Each model is evaluated once per validation set, after it is trained on the rest of the data. By averaging out all the evaluations of a model, we get a much more accurate measure of its performance. However, there is a drawback: the training time is multiplied by the number of valida‐ tion sets.", "words": [{"w": "This", "b": [0.1429, 0.6133, 0.1801, 0.6347]}, {"w": "solution", "b": [0.1849, 0.6133, 0.2534, 0.6347]}, {"w": "usually", "b": [0.2582, 0.6133, 0.3172, 0.6347]}, {"w": "works", "b": [0.322, 0.6133, 0.3726, 0.6347]}, {"w": "quite", "b": [0.3774, 0.6133, 0.4199, 0.6347]}, {"w": "well.", "b": [0.4247, 0.6133, 0.4631, 0.6347]}, {"w": "However,", "b": [0.4679, 0.6133, 0.5468, 0.6347]}, {"w": "if", "b": [0.5516, 0.6133, 0.5633, 0.6347]}, {"w": "the", "b": [0.5681, 0.6133, 0.5945, 0.6347]}, {"w": "validation", "b": [0.5993, 0.6133, 0.6826, 0.6347]}, {"w": "set", "b": [0.6874, 0.6133, 0.7103, 0.6347]}, {"w": "is", "b": [0.7151, 0.6133, 0.7283, 0.6347]}, {"w": "too", "b": [0.7331, 0.6133, 0.7607, 0.6347]}, {"w": "small,", "b": [0.7655, 0.6133, 0.8146, 0.6347]}, {"w": "then", "b": [0.8194, 0.6133, 0.8571, 0.6347]}, {"w": "model", "b": [0.1429, 0.6323, 0.1957, 0.6537]}, {"w": "evaluations", "b": [0.2005, 0.6323, 0.2949, 0.6537]}, {"w": "will", "b": [0.2997, 0.6323, 0.3301, 0.6537]}, {"w": "be", "b": [0.335, 0.6323, 0.3544, 0.6537]}, {"w": "imprecise:", "b": [0.3593, 0.6323, 0.4447, 0.6537]}, {"w": "you", "b": [0.4495, 0.6323, 0.4808, 0.6537]}, {"w": "may", "b": [0.4856, 0.6323, 0.521, 0.6537]}, {"w": "end", "b": [0.5259, 0.6323, 0.5571, 0.6537]}, {"w": "up", "b": [0.562, 0.6323, 0.584, 0.6537]}, {"w": "selecting", "b": [0.5888, 0.6323, 0.6614, 0.6537]}, {"w": "a", "b": [0.6662, 0.6323, 0.6754, 0.6537]}, {"w": "suboptimal", "b": [0.6802, 0.6323, 0.7745, 0.6537]}, {"w": "model", "b": [0.7793, 0.6323, 0.8321, 0.6537]}, {"w": "by", "b": [0.837, 0.6323, 0.8571, 0.6537]}, {"w": "mistake.", "b": [0.1428, 0.6514, 0.2126, 0.6728]}, {"w": "Conversely,", "b": [0.2185, 0.6514, 0.3147, 0.6728]}, {"w": "if", "b": [0.3207, 0.6514, 0.3324, 0.6728]}, {"w": "the", "b": [0.3384, 0.6514, 0.3647, 0.6728]}, {"w": "validation", "b": [0.3707, 0.6514, 0.454, 0.6728]}, {"w": "set", "b": [0.46, 0.6514, 0.4828, 0.6728]}, {"w": "is", "b": [0.4888, 0.6514, 0.502, 0.6728]}, {"w": "too", "b": [0.508, 0.6514, 0.5356, 0.6728]}, {"w": "large,", "b": [0.5415, 0.6514, 0.587, 0.6728]}, {"w": "then", "b": [0.593, 0.6514, 0.6307, 0.6728]}, {"w": "the", "b": [0.6366, 0.6514, 0.663, 0.6728]}, {"w": "remaining", "b": [0.6689, 0.6514, 0.7554, 0.6728]}, {"w": "training", "b": [0.7614, 0.6514, 0.8283, 0.6728]}, {"w": "set", "b": [0.8343, 0.6514, 0.8571, 0.6728]}, {"w": "will", "b": [0.1429, 0.6704, 0.1733, 0.6918]}, {"w": "be", "b": [0.1794, 0.6704, 0.1988, 0.6918]}, {"w": "much", "b": [0.2049, 0.6704, 0.2526, 0.6918]}, {"w": "smaller", "b": [0.2587, 0.6704, 0.3196, 0.6918]}, {"w": "than", "b": [0.3257, 0.6704, 0.3638, 0.6918]}, {"w": "the", "b": [0.3699, 0.6704, 0.3962, 0.6918]}, {"w": "full", "b": [0.4023, 0.6704, 0.4301, 0.6918]}, {"w": "training", "b": [0.4362, 0.6704, 0.5031, 0.6918]}, {"w": "set.", "b": [0.5092, 0.6704, 0.5368, 0.6918]}, {"w": "Why", "b": [0.5429, 0.6704, 0.5833, 0.6918]}, {"w": "is", "b": [0.5894, 0.6704, 0.6027, 0.6918]}, {"w": "this", "b": [0.6088, 0.6704, 0.6395, 0.6918]}, {"w": "bad?", "b": [0.6456, 0.6704, 0.6842, 0.6918]}, {"w": "Well,", "b": [0.6903, 0.6704, 0.7327, 0.6918]}, {"w": "since", "b": [0.7388, 0.6704, 0.7811, 0.6918]}, {"w": "the", "b": [0.7872, 0.6704, 0.8135, 0.6918]}, {"w": "final", "b": [0.8196, 0.6704, 0.8571, 0.6918]}, {"w": "model", "b": [0.1429, 0.6895, 0.1957, 0.7109]}, {"w": "will", "b": [0.2035, 0.6895, 0.2339, 0.7109]}, {"w": "be", "b": [0.2417, 0.6895, 0.2611, 0.7109]}, {"w": "trained", "b": [0.2689, 0.6895, 0.3289, 0.7109]}, {"w": "on", "b": [0.3367, 0.6895, 0.3588, 0.7109]}, {"w": "the", "b": [0.3665, 0.6895, 0.3929, 0.7109]}, {"w": "full", "b": [0.4007, 0.6895, 0.4284, 0.7109]}, {"w": "training", "b": [0.4362, 0.6895, 0.5032, 0.7109]}, {"w": "set,", "b": [0.511, 0.6895, 0.5386, 0.7109]}, {"w": "it", "b": [0.5464, 0.6895, 0.5583, 0.7109]}, {"w": "is", "b": [0.5661, 0.6895, 0.5793, 0.7109]}, {"w": "not", "b": [0.5871, 0.6895, 0.6155, 0.7109]}, {"w": "ideal", "b": [0.6233, 0.6895, 0.6631, 0.7109]}, {"w": "to", "b": [0.6709, 0.6895, 0.6879, 0.7109]}, {"w": "compare", "b": [0.6957, 0.6895, 0.7685, 0.7109]}, {"w": "candidate", "b": [0.7762, 0.6895, 0.8571, 0.7109]}, {"w": "models", "b": [0.1429, 0.7085, 0.2033, 0.7299]}, {"w": "trained", "b": [0.21, 0.7085, 0.2701, 0.7299]}, {"w": "on", "b": [0.2768, 0.7085, 0.2988, 0.7299]}, {"w": "a", "b": [0.3055, 0.7085, 0.3147, 0.7299]}, {"w": "much", "b": [0.3214, 0.7085, 0.3691, 0.7299]}, {"w": "smaller", "b": [0.3758, 0.7085, 0.4368, 0.7299]}, {"w": "training", "b": [0.4435, 0.7085, 0.5104, 0.7299]}, {"w": "set.", "b": [0.5171, 0.7085, 0.5447, 0.7299]}, {"w": "It", "b": [0.5515, 0.7085, 0.5641, 0.7299]}, {"w": "would", "b": [0.5708, 0.7085, 0.6231, 0.7299]}, {"w": "be", "b": [0.6298, 0.7085, 0.6492, 0.7299]}, {"w": "like", "b": [0.6559, 0.7085, 0.686, 0.7299]}, {"w": "selecting", "b": [0.6927, 0.7085, 0.7652, 0.7299]}, {"w": "the", "b": [0.7719, 0.7085, 0.7983, 0.7299]}, {"w": "fastest", "b": [0.805, 0.7085, 0.8571, 0.7299]}, {"w": "sprinter", "b": [0.1429, 0.7276, 0.2087, 0.749]}, {"w": "to", "b": [0.2159, 0.7276, 0.2329, 0.749]}, {"w": "participate", "b": [0.2401, 0.7276, 0.3291, 0.749]}, {"w": "in", "b": [0.3363, 0.7276, 0.3533, 0.749]}, {"w": "a", "b": [0.3605, 0.7276, 0.3696, 0.749]}, {"w": "marathon.", "b": [0.3768, 0.7276, 0.4638, 0.749]}, {"w": "One", "b": [0.471, 0.7276, 0.5068, 0.749]}, {"w": "way", "b": [0.514, 0.7276, 0.5466, 0.749]}, {"w": "to", "b": [0.5538, 0.7276, 0.5708, 0.749]}, {"w": "solve", "b": [0.578, 0.7276, 0.6201, 0.749]}, {"w": "this", "b": [0.6273, 0.7276, 0.658, 0.749]}, {"w": "problem", "b": [0.6652, 0.7276, 0.7362, 0.749]}, {"w": "is", "b": [0.7434, 0.7276, 0.7567, 0.749]}, {"w": "to", "b": [0.7639, 0.7276, 0.7809, 0.749]}, {"w": "perform", "b": [0.7881, 0.7276, 0.8572, 0.749]}, {"w": "repeated", "b": [0.1429, 0.7466, 0.2142, 0.768]}, {"w": "cross-validation,", "b": [0.2211, 0.7464, 0.3539, 0.768]}, {"w": "using", "b": [0.3608, 0.7466, 0.4063, 0.768]}, {"w": "many", "b": [0.4132, 0.7466, 0.4599, 0.768]}, {"w": "small", "b": [0.4668, 0.7466, 0.5112, 0.768]}, {"w": "validation", "b": [0.5181, 0.7466, 0.6015, 0.768]}, {"w": "sets.", "b": [0.6084, 0.7466, 0.6436, 0.768]}, {"w": "Each", "b": [0.6505, 0.7466, 0.6914, 0.768]}, {"w": "model", "b": [0.6983, 0.7466, 0.7512, 0.768]}, {"w": "is", "b": [0.7581, 0.7466, 0.7713, 0.768]}, {"w": "evaluated", "b": [0.7782, 0.7466, 0.8571, 0.768]}, {"w": "once", "b": [0.1429, 0.7657, 0.1825, 0.7871]}, {"w": "per", "b": [0.1884, 0.7657, 0.2159, 0.7871]}, {"w": "validation", "b": [0.2219, 0.7657, 0.3052, 0.7871]}, {"w": "set,", "b": [0.3111, 0.7657, 0.3387, 0.7871]}, {"w": "after", "b": [0.3446, 0.7657, 0.3829, 0.7871]}, {"w": "it", "b": [0.3888, 0.7657, 0.4007, 0.7871]}, {"w": "is", "b": [0.4066, 0.7657, 0.4199, 0.7871]}, {"w": "trained", "b": [0.4258, 0.7657, 0.4858, 0.7871]}, {"w": "on", "b": [0.4917, 0.7657, 0.5138, 0.7871]}, {"w": "the", "b": [0.5197, 0.7657, 0.546, 0.7871]}, {"w": "rest", "b": [0.5519, 0.7657, 0.5825, 0.7871]}, {"w": "of", "b": [0.5884, 0.7657, 0.6052, 0.7871]}, {"w": "the", "b": [0.6111, 0.7657, 0.6374, 0.7871]}, {"w": "data.", "b": [0.6433, 0.7657, 0.6833, 0.7871]}, {"w": "By", "b": [0.6892, 0.7657, 0.7111, 0.7871]}, {"w": "averaging", "b": [0.717, 0.7657, 0.7976, 0.7871]}, {"w": "out", "b": [0.8035, 0.7657, 0.8315, 0.7871]}, {"w": "all", "b": [0.8375, 0.7657, 0.8571, 0.7871]}, {"w": "the", "b": [0.1428, 0.7847, 0.1692, 0.8061]}, {"w": "evaluations", "b": [0.1744, 0.7847, 0.2687, 0.8061]}, {"w": "of", "b": [0.2739, 0.7847, 0.2907, 0.8061]}, {"w": "a", "b": [0.2959, 0.7847, 0.305, 0.8061]}, {"w": "model,", "b": [0.3102, 0.7847, 0.3678, 0.8061]}, {"w": "we", "b": [0.373, 0.7847, 0.3961, 0.8061]}, {"w": "get", "b": [0.4013, 0.7847, 0.4262, 0.8061]}, {"w": "a", "b": [0.4314, 0.7847, 0.4406, 0.8061]}, {"w": "much", "b": [0.4458, 0.7847, 0.4934, 0.8061]}, {"w": "more", "b": [0.4986, 0.7847, 0.5429, 0.8061]}, {"w": "accurate", "b": [0.5481, 0.7847, 0.6176, 0.8061]}, {"w": "measure", "b": [0.6228, 0.7847, 0.6931, 0.8061]}, {"w": "of", "b": [0.6983, 0.7847, 0.7151, 0.8061]}, {"w": "its", "b": [0.7203, 0.7847, 0.7399, 0.8061]}, {"w": "performance.", "b": [0.7451, 0.7847, 0.8571, 0.8061]}, {"w": "However,", "b": [0.1429, 0.8037, 0.2217, 0.8252]}, {"w": "there", "b": [0.2265, 0.8037, 0.2694, 0.8252]}, {"w": "is", "b": [0.2742, 0.8037, 0.2874, 0.8252]}, {"w": "a", "b": [0.2922, 0.8037, 0.3014, 0.8252]}, {"w": "drawback:", "b": [0.3062, 0.8037, 0.3916, 0.8252]}, {"w": "the", "b": [0.3964, 0.8037, 0.4227, 0.8252]}, {"w": "training", "b": [0.4275, 0.8037, 0.4944, 0.8252]}, {"w": "time", "b": [0.4992, 0.8037, 0.5371, 0.8252]}, {"w": "is", "b": [0.5418, 0.8037, 0.5551, 0.8252]}, {"w": "multiplied", "b": [0.5599, 0.8037, 0.6464, 0.8252]}, {"w": "by", "b": [0.6512, 0.8037, 0.6714, 0.8252]}, {"w": "the", "b": [0.6762, 0.8037, 0.7025, 0.8252]}, {"w": "number", "b": [0.7073, 0.8037, 0.7736, 0.8252]}, {"w": "of", "b": [0.7784, 0.8037, 0.7951, 0.8252]}, {"w": "valida‐", "b": [0.7999, 0.8037, 0.8571, 0.8252]}, {"w": "tion", "b": [0.1429, 0.8228, 0.1768, 0.8442]}, {"w": "sets.", "b": [0.1815, 0.8228, 0.2168, 0.8442]}]}, {"id": "b_7", "type": "paragraph", "text": "32 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "32", "b": [0.1428, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.337, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 59, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "11 “The Lack of A Priori Distinctions Between Learning Algorithms,” D. Wolpert (1996).", "words": [{"w": "11", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“The", "b": [0.1587, 0.8749, 0.1905, 0.8912]}, {"w": "Lack", "b": [0.1941, 0.8749, 0.2242, 0.8912]}, {"w": "of", "b": [0.2278, 0.8749, 0.2406, 0.8912]}, {"w": "A", "b": [0.2442, 0.8749, 0.2551, 0.8912]}, {"w": "Priori", "b": [0.2587, 0.8749, 0.296, 0.8912]}, {"w": "Distinctions", "b": [0.2997, 0.8749, 0.3776, 0.8912]}, {"w": "Between", "b": [0.3812, 0.8749, 0.4355, 0.8912]}, {"w": "Learning", "b": [0.4391, 0.8749, 0.4963, 0.8912]}, {"w": "Algorithms,”", "b": [0.4999, 0.8749, 0.5805, 0.8912]}, {"w": "D.", "b": [0.5841, 0.8749, 0.5987, 0.8912]}, {"w": "Wolpert", "b": [0.6023, 0.8749, 0.6541, 0.8912]}, {"w": "(1996).", "b": [0.6577, 0.8749, 0.7028, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Data Mismatch", "words": [{"w": "Data", "b": [0.1428, 0.0763, 0.1913, 0.1049]}, {"w": "Mismatch", "b": [0.1962, 0.0763, 0.2968, 0.1049]}]}, {"id": "b_2", "type": "paragraph", "text": "In some cases, it is easy to get a large amount of data for training, but it is not per‐ fectly representative of the data that will be used in production. For example, suppose you want to create a mobile app to take pictures of flowers and automatically deter‐ mine their species. You can easily download millions of pictures of flowers on the web, but they won’t be perfectly representative of the pictures that will actually be taken using the app on a mobile device. Perhaps you only have 10,000 representative pictures (i.e., actually taken with the app). In this case, the most important rule to remember is that the validation set and the test must be as representative as possible of the data you expect to use in production, so they should be composed exclusively of representative pictures: you can shuffle them and put half in the validation set, and half in the test set (making sure that no duplicates or near-duplicates end up in both sets). After training your model on the web pictures, if you observe that the perfor‐ mance of your model on the validation set is disappointing, you will not know whether this is because your model has overfit the training set, or whether this is just due to the mismatch between the web pictures and the mobile app pictures. One sol‐ ution is to hold out part of the training pictures (from the web) in yet another set that Andrew Ng calls the train-dev set. After the model is trained (on the training set, not on the train-dev set), you can evaluate it on the train-dev set: if it performs well, then the model is not overfitting the training set, so if performs poorly on the validation set, the problem must come from the data mismatch. You can try to tackle this prob‐ lem by preprocessing the web images to make them look more like the pictures that will be taken by the mobile app, and then retraining the model. Conversely, if the model performs poorly on the train-dev set, then the model must have overfit the training set, so you should try to simplify or regularize the model, get more training data and clean up the training data, as discussed earlier.", "words": [{"w": "In", "b": [0.1429, 0.1108, 0.1614, 0.1322]}, {"w": "some", "b": [0.1678, 0.1108, 0.212, 0.1322]}, {"w": "cases,", "b": [0.2185, 0.1108, 0.2653, 0.1322]}, {"w": "it", "b": [0.2718, 0.1108, 0.2837, 0.1322]}, {"w": "is", "b": [0.2902, 0.1108, 0.3034, 0.1322]}, {"w": "easy", "b": [0.3098, 0.1108, 0.345, 0.1322]}, {"w": "to", "b": [0.3515, 0.1108, 0.3685, 0.1322]}, {"w": "get", "b": [0.3749, 0.1108, 0.3999, 0.1322]}, {"w": "a", "b": [0.4063, 0.1108, 0.4155, 0.1322]}, {"w": "large", "b": [0.4219, 0.1108, 0.4627, 0.1322]}, {"w": "amount", "b": [0.4691, 0.1108, 0.5344, 0.1322]}, {"w": "of", "b": [0.5408, 0.1108, 0.5576, 0.1322]}, {"w": "data", "b": [0.5641, 0.1108, 0.5993, 0.1322]}, {"w": "for", "b": [0.6058, 0.1108, 0.6303, 0.1322]}, {"w": "training,", "b": [0.6367, 0.1108, 0.7084, 0.1322]}, {"w": "but", "b": [0.7149, 0.1108, 0.7429, 0.1322]}, {"w": "it", "b": [0.7493, 0.1108, 0.7613, 0.1322]}, {"w": "is", "b": [0.7677, 0.1108, 0.781, 0.1322]}, {"w": "not", "b": [0.7874, 0.1108, 0.8158, 0.1322]}, {"w": "per‐", "b": [0.8222, 0.1108, 0.8572, 0.1322]}, {"w": "fectly", "b": [0.1429, 0.1298, 0.1879, 0.1512]}, {"w": "representative", "b": [0.193, 0.1298, 0.3101, 0.1512]}, {"w": "of", "b": [0.3152, 0.1298, 0.332, 0.1512]}, {"w": "the", "b": [0.337, 0.1298, 0.3634, 0.1512]}, {"w": "data", "b": [0.3684, 0.1298, 0.4037, 0.1512]}, {"w": "that", "b": [0.4088, 0.1298, 0.4414, 0.1512]}, {"w": "will", "b": [0.4464, 0.1298, 0.4768, 0.1512]}, {"w": "be", "b": [0.4819, 0.1298, 0.5013, 0.1512]}, {"w": "used", "b": [0.5064, 0.1298, 0.545, 0.1512]}, {"w": "in", "b": [0.5501, 0.1298, 0.567, 0.1512]}, {"w": "production.", "b": [0.5721, 0.1298, 0.671, 0.1512]}, {"w": "For", "b": [0.6761, 0.1298, 0.705, 0.1512]}, {"w": "example,", "b": [0.7101, 0.1298, 0.7844, 0.1512]}, {"w": "suppose", "b": [0.7895, 0.1298, 0.8571, 0.1512]}, {"w": "you", "b": [0.1429, 0.1489, 0.1741, 0.1703]}, {"w": "want", "b": [0.1804, 0.1489, 0.2212, 0.1703]}, {"w": "to", "b": [0.2274, 0.1489, 0.2444, 0.1703]}, {"w": "create", "b": [0.2507, 0.1489, 0.3, 0.1703]}, {"w": "a", "b": [0.3063, 0.1489, 0.3155, 0.1703]}, {"w": "mobile", "b": [0.3217, 0.1489, 0.3797, 0.1703]}, {"w": "app", "b": [0.386, 0.1489, 0.4166, 0.1703]}, {"w": "to", "b": [0.4229, 0.1489, 0.4398, 0.1703]}, {"w": "take", "b": [0.4461, 0.1489, 0.4808, 0.1703]}, {"w": "pictures", "b": [0.4871, 0.1489, 0.554, 0.1703]}, {"w": "of", "b": [0.5603, 0.1489, 0.5771, 0.1703]}, {"w": "flowers", "b": [0.5834, 0.1489, 0.644, 0.1703]}, {"w": "and", "b": [0.6502, 0.1489, 0.6818, 0.1703]}, {"w": "automatically", "b": [0.6881, 0.1489, 0.8007, 0.1703]}, {"w": "deter‐", "b": [0.8069, 0.1489, 0.8571, 0.1703]}, {"w": "mine", "b": [0.1428, 0.1679, 0.1857, 0.1893]}, {"w": "their", "b": [0.1934, 0.1679, 0.2331, 0.1893]}, {"w": "species.", "b": [0.2407, 0.1679, 0.3038, 0.1893]}, {"w": "You", "b": [0.3115, 0.1679, 0.3438, 0.1893]}, {"w": "can", "b": [0.3515, 0.1679, 0.3808, 0.1893]}, {"w": "easily", "b": [0.3885, 0.1679, 0.4346, 0.1893]}, {"w": "download", "b": [0.4422, 0.1679, 0.5256, 0.1893]}, {"w": "millions", "b": [0.5332, 0.1679, 0.6017, 0.1893]}, {"w": "of", "b": [0.6093, 0.1679, 0.6261, 0.1893]}, {"w": "pictures", "b": [0.6338, 0.1679, 0.7008, 0.1893]}, {"w": "of", "b": [0.7084, 0.1679, 0.7252, 0.1893]}, {"w": "flowers", "b": [0.7329, 0.1679, 0.7934, 0.1893]}, {"w": "on", "b": [0.8011, 0.1679, 0.8231, 0.1893]}, {"w": "the", "b": [0.8308, 0.1679, 0.8571, 0.1893]}, {"w": "web,", "b": [0.1429, 0.187, 0.1807, 0.2084]}, {"w": "but", "b": [0.1885, 0.187, 0.2165, 0.2084]}, {"w": "they", "b": [0.2243, 0.187, 0.2602, 0.2084]}, {"w": "won’t", "b": [0.268, 0.187, 0.3129, 0.2084]}, {"w": "be", "b": [0.3207, 0.187, 0.3401, 0.2084]}, {"w": "perfectly", "b": [0.3479, 0.187, 0.4205, 0.2084]}, {"w": "representative", "b": [0.4283, 0.187, 0.5454, 0.2084]}, {"w": "of", "b": [0.5532, 0.187, 0.57, 0.2084]}, {"w": "the", "b": [0.5778, 0.187, 0.6041, 0.2084]}, {"w": "pictures", "b": [0.6119, 0.187, 0.6789, 0.2084]}, {"w": "that", "b": [0.6867, 0.187, 0.7193, 0.2084]}, {"w": "will", "b": [0.7271, 0.187, 0.7575, 0.2084]}, {"w": "actually", "b": [0.7653, 0.187, 0.8299, 0.2084]}, {"w": "be", "b": [0.8377, 0.187, 0.8572, 0.2084]}, {"w": "taken", "b": [0.1429, 0.206, 0.1889, 0.2274]}, {"w": "using", "b": [0.1947, 0.206, 0.2401, 0.2274]}, {"w": "the", "b": [0.2459, 0.206, 0.2722, 0.2274]}, {"w": "app", "b": [0.278, 0.206, 0.3085, 0.2274]}, {"w": "on", "b": [0.3143, 0.206, 0.3363, 0.2274]}, {"w": "a", "b": [0.3421, 0.206, 0.3512, 0.2274]}, {"w": "mobile", "b": [0.357, 0.206, 0.4149, 0.2274]}, {"w": "device.", "b": [0.4207, 0.206, 0.4782, 0.2274]}, {"w": "Perhaps", "b": [0.4839, 0.206, 0.55, 0.2274]}, {"w": "you", "b": [0.5558, 0.206, 0.587, 0.2274]}, {"w": "only", "b": [0.5928, 0.206, 0.6296, 0.2274]}, {"w": "have", "b": [0.6354, 0.206, 0.6738, 0.2274]}, {"w": "10,000", "b": [0.6795, 0.206, 0.7343, 0.2274]}, {"w": "representative", "b": [0.74, 0.206, 0.8571, 0.2274]}, {"w": "pictures", "b": [0.1429, 0.2251, 0.2098, 0.2465]}, {"w": "(i.e.,", "b": [0.2172, 0.2251, 0.2531, 0.2465]}, {"w": "actually", "b": [0.2605, 0.2251, 0.3252, 0.2465]}, {"w": "taken", "b": [0.3326, 0.2251, 0.3787, 0.2465]}, {"w": "with", "b": [0.3861, 0.2251, 0.4234, 0.2465]}, {"w": "the", "b": [0.4308, 0.2251, 0.4572, 0.2465]}, {"w": "app).", "b": [0.4646, 0.2251, 0.5071, 0.2465]}, {"w": "In", "b": [0.5145, 0.2251, 0.533, 0.2465]}, {"w": "this", "b": [0.5404, 0.2251, 0.5711, 0.2465]}, {"w": "case,", "b": [0.5786, 0.2251, 0.6178, 0.2465]}, {"w": "the", "b": [0.6252, 0.2251, 0.6515, 0.2465]}, {"w": "most", "b": [0.6589, 0.2251, 0.7006, 0.2465]}, {"w": "important", "b": [0.708, 0.2251, 0.7924, 0.2465]}, {"w": "rule", "b": [0.7998, 0.2251, 0.8327, 0.2465]}, {"w": "to", "b": [0.8402, 0.2251, 0.8571, 0.2465]}, {"w": "remember", "b": [0.1429, 0.2441, 0.2296, 0.2655]}, {"w": "is", "b": [0.2355, 0.2441, 0.2488, 0.2655]}, {"w": "that", "b": [0.2547, 0.2441, 0.2873, 0.2655]}, {"w": "the", "b": [0.2932, 0.2441, 0.3196, 0.2655]}, {"w": "validation", "b": [0.3255, 0.2441, 0.4088, 0.2655]}, {"w": "set", "b": [0.4148, 0.2441, 0.4376, 0.2655]}, {"w": "and", "b": [0.4436, 0.2441, 0.4751, 0.2655]}, {"w": "the", "b": [0.4811, 0.2441, 0.5074, 0.2655]}, {"w": "test", "b": [0.5133, 0.2441, 0.5425, 0.2655]}, {"w": "must", "b": [0.5485, 0.2441, 0.5902, 0.2655]}, {"w": "be", "b": [0.5961, 0.2441, 0.6156, 0.2655]}, {"w": "as", "b": [0.6215, 0.2441, 0.6383, 0.2655]}, {"w": "representative", "b": [0.6442, 0.2441, 0.7614, 0.2655]}, {"w": "as", "b": [0.7673, 0.2441, 0.7841, 0.2655]}, {"w": "possible", "b": [0.79, 0.2441, 0.8572, 0.2655]}, {"w": "of", "b": [0.1429, 0.2632, 0.1597, 0.2846]}, {"w": "the", "b": [0.1657, 0.2632, 0.192, 0.2846]}, {"w": "data", "b": [0.1981, 0.2632, 0.2333, 0.2846]}, {"w": "you", "b": [0.2394, 0.2632, 0.2707, 0.2846]}, {"w": "expect", "b": [0.2767, 0.2632, 0.3303, 0.2846]}, {"w": "to", "b": [0.3364, 0.2632, 0.3534, 0.2846]}, {"w": "use", "b": [0.3594, 0.2632, 0.387, 0.2846]}, {"w": "in", "b": [0.393, 0.2632, 0.41, 0.2846]}, {"w": "production,", "b": [0.4161, 0.2632, 0.5149, 0.2846]}, {"w": "so", "b": [0.521, 0.2632, 0.5393, 0.2846]}, {"w": "they", "b": [0.5453, 0.2632, 0.5812, 0.2846]}, {"w": "should", "b": [0.5873, 0.2632, 0.644, 0.2846]}, {"w": "be", "b": [0.6501, 0.2632, 0.6695, 0.2846]}, {"w": "composed", "b": [0.6755, 0.2632, 0.7607, 0.2846]}, {"w": "exclusively", "b": [0.7668, 0.2632, 0.8571, 0.2846]}, {"w": "of", "b": [0.1429, 0.2822, 0.1596, 0.3036]}, {"w": "representative", "b": [0.1647, 0.2822, 0.2819, 0.3036]}, {"w": "pictures:", "b": [0.287, 0.2822, 0.3587, 0.3036]}, {"w": "you", "b": [0.3638, 0.2822, 0.395, 0.3036]}, {"w": "can", "b": [0.4001, 0.2822, 0.4295, 0.3036]}, {"w": "shuffle", "b": [0.4346, 0.2822, 0.4905, 0.3036]}, {"w": "them", "b": [0.4956, 0.2822, 0.539, 0.3036]}, {"w": "and", "b": [0.5441, 0.2822, 0.5756, 0.3036]}, {"w": "put", "b": [0.5807, 0.2822, 0.609, 0.3036]}, {"w": "half", "b": [0.6141, 0.2822, 0.6458, 0.3036]}, {"w": "in", "b": [0.6509, 0.2822, 0.6679, 0.3036]}, {"w": "the", "b": [0.673, 0.2822, 0.6993, 0.3036]}, {"w": "validation", "b": [0.7044, 0.2822, 0.7878, 0.3036]}, {"w": "set,", "b": [0.7929, 0.2822, 0.8205, 0.3036]}, {"w": "and", "b": [0.8256, 0.2822, 0.8571, 0.3036]}, {"w": "half", "b": [0.1428, 0.3013, 0.1746, 0.3227]}, {"w": "in", "b": [0.1804, 0.3013, 0.1973, 0.3227]}, {"w": "the", "b": [0.2031, 0.3013, 0.2295, 0.3227]}, {"w": "test", "b": [0.2353, 0.3013, 0.2645, 0.3227]}, {"w": "set", "b": [0.2703, 0.3013, 0.2931, 0.3227]}, {"w": "(making", "b": [0.2989, 0.3013, 0.3694, 0.3227]}, {"w": "sure", "b": [0.3752, 0.3013, 0.4105, 0.3227]}, {"w": "that", "b": [0.4163, 0.3013, 0.4489, 0.3227]}, {"w": "no", "b": [0.4547, 0.3013, 0.4767, 0.3227]}, {"w": "duplicates", "b": [0.4825, 0.3013, 0.5668, 0.3227]}, {"w": "or", "b": [0.5726, 0.3013, 0.5909, 0.3227]}, {"w": "near-duplicates", "b": [0.5967, 0.3013, 0.725, 0.3227]}, {"w": "end", "b": [0.7308, 0.3013, 0.7621, 0.3227]}, {"w": "up", "b": [0.7679, 0.3013, 0.7899, 0.3227]}, {"w": "in", "b": [0.7957, 0.3013, 0.8126, 0.3227]}, {"w": "both", "b": [0.8184, 0.3013, 0.8571, 0.3227]}, {"w": "sets).", "b": [0.1429, 0.3203, 0.1853, 0.3417]}, {"w": "After", "b": [0.1917, 0.3203, 0.2352, 0.3417]}, {"w": "training", "b": [0.2417, 0.3203, 0.3086, 0.3417]}, {"w": "your", "b": [0.315, 0.3203, 0.354, 0.3417]}, {"w": "model", "b": [0.3604, 0.3203, 0.4132, 0.3417]}, {"w": "on", "b": [0.4197, 0.3203, 0.4417, 0.3417]}, {"w": "the", "b": [0.4481, 0.3203, 0.4744, 0.3417]}, {"w": "web", "b": [0.4809, 0.3203, 0.5146, 0.3417]}, {"w": "pictures,", "b": [0.521, 0.3203, 0.5927, 0.3417]}, {"w": "if", "b": [0.5991, 0.3203, 0.6109, 0.3417]}, {"w": "you", "b": [0.6173, 0.3203, 0.6486, 0.3417]}, {"w": "observe", "b": [0.655, 0.3203, 0.7195, 0.3417]}, {"w": "that", "b": [0.7259, 0.3203, 0.7585, 0.3417]}, {"w": "the", "b": [0.765, 0.3203, 0.7913, 0.3417]}, {"w": "perfor‐", "b": [0.7977, 0.3203, 0.8572, 0.3417]}, {"w": "mance", "b": [0.1429, 0.3394, 0.1981, 0.3608]}, {"w": "of", "b": [0.2078, 0.3394, 0.2246, 0.3608]}, {"w": "your", "b": [0.2343, 0.3394, 0.2733, 0.3608]}, {"w": "model", "b": [0.283, 0.3394, 0.3358, 0.3608]}, {"w": "on", "b": [0.3455, 0.3394, 0.3675, 0.3608]}, {"w": "the", "b": [0.3772, 0.3394, 0.4036, 0.3608]}, {"w": "validation", "b": [0.4133, 0.3394, 0.4966, 0.3608]}, {"w": "set", "b": [0.5063, 0.3394, 0.5292, 0.3608]}, {"w": "is", "b": [0.5389, 0.3394, 0.5521, 0.3608]}, {"w": "disappointing,", "b": [0.5618, 0.3394, 0.6817, 0.3608]}, {"w": "you", "b": [0.6914, 0.3394, 0.7226, 0.3608]}, {"w": "will", "b": [0.7323, 0.3394, 0.7627, 0.3608]}, {"w": "not", "b": [0.7724, 0.3394, 0.8008, 0.3608]}, {"w": "know", "b": [0.8105, 0.3394, 0.8571, 0.3608]}, {"w": "whether", "b": [0.1429, 0.3584, 0.2112, 0.3798]}, {"w": "this", "b": [0.2166, 0.3584, 0.2473, 0.3798]}, {"w": "is", "b": [0.2527, 0.3584, 0.2659, 0.3798]}, {"w": "because", "b": [0.2713, 0.3584, 0.3359, 0.3798]}, {"w": "your", "b": [0.3412, 0.3584, 0.3802, 0.3798]}, {"w": "model", "b": [0.3856, 0.3584, 0.4384, 0.3798]}, {"w": "has", "b": [0.4438, 0.3584, 0.4717, 0.3798]}, {"w": "overfit", "b": [0.4771, 0.3584, 0.5321, 0.3798]}, {"w": "the", "b": [0.5375, 0.3584, 0.5638, 0.3798]}, {"w": "training", "b": [0.5692, 0.3584, 0.6362, 0.3798]}, {"w": "set,", "b": [0.6416, 0.3584, 0.6692, 0.3798]}, {"w": "or", "b": [0.6746, 0.3584, 0.6929, 0.3798]}, {"w": "whether", "b": [0.6983, 0.3584, 0.7666, 0.3798]}, {"w": "this", "b": [0.772, 0.3584, 0.8027, 0.3798]}, {"w": "is", "b": [0.8081, 0.3584, 0.8213, 0.3798]}, {"w": "just", "b": [0.8267, 0.3584, 0.8571, 0.3798]}, {"w": "due", "b": [0.1428, 0.3774, 0.1738, 0.3989]}, {"w": "to", "b": [0.1792, 0.3774, 0.1962, 0.3989]}, {"w": "the", "b": [0.2017, 0.3774, 0.228, 0.3989]}, {"w": "mismatch", "b": [0.2335, 0.3774, 0.3159, 0.3989]}, {"w": "between", "b": [0.3214, 0.3774, 0.3905, 0.3989]}, {"w": "the", "b": [0.396, 0.3774, 0.4223, 0.3989]}, {"w": "web", "b": [0.4278, 0.3774, 0.4615, 0.3989]}, {"w": "pictures", "b": [0.467, 0.3774, 0.5339, 0.3989]}, {"w": "and", "b": [0.5394, 0.3774, 0.5709, 0.3989]}, {"w": "the", "b": [0.5764, 0.3774, 0.6027, 0.3989]}, {"w": "mobile", "b": [0.6082, 0.3774, 0.6662, 0.3989]}, {"w": "app", "b": [0.6717, 0.3774, 0.7022, 0.3989]}, {"w": "pictures.", "b": [0.7077, 0.3774, 0.7794, 0.3989]}, {"w": "One", "b": [0.7849, 0.3774, 0.8207, 0.3989]}, {"w": "sol‐", "b": [0.8262, 0.3774, 0.8571, 0.3989]}, {"w": "ution", "b": [0.1429, 0.3965, 0.1879, 0.4179]}, {"w": "is", "b": [0.1928, 0.3965, 0.206, 0.4179]}, {"w": "to", "b": [0.2109, 0.3965, 0.2279, 0.4179]}, {"w": "hold", "b": [0.2328, 0.3965, 0.2708, 0.4179]}, {"w": "out", "b": [0.2757, 0.3965, 0.3038, 0.4179]}, {"w": "part", "b": [0.3087, 0.3965, 0.3428, 0.4179]}, {"w": "of", "b": [0.3477, 0.3965, 0.3645, 0.4179]}, {"w": "the", "b": [0.3694, 0.3965, 0.3958, 0.4179]}, {"w": "training", "b": [0.4007, 0.3965, 0.4676, 0.4179]}, {"w": "pictures", "b": [0.4725, 0.3965, 0.5395, 0.4179]}, {"w": "(from", "b": [0.5444, 0.3965, 0.5932, 0.4179]}, {"w": "the", "b": [0.5981, 0.3965, 0.6244, 0.4179]}, {"w": "web)", "b": [0.6293, 0.3965, 0.6702, 0.4179]}, {"w": "in", "b": [0.6751, 0.3965, 0.6921, 0.4179]}, {"w": "yet", "b": [0.697, 0.3965, 0.7218, 0.4179]}, {"w": "another", "b": [0.7267, 0.3965, 0.7919, 0.4179]}, {"w": "set", "b": [0.7968, 0.3965, 0.8197, 0.4179]}, {"w": "that", "b": [0.8246, 0.3965, 0.8571, 0.4179]}, {"w": "Andrew", "b": [0.1429, 0.4155, 0.2105, 0.437]}, {"w": "Ng", "b": [0.2162, 0.4155, 0.2408, 0.437]}, {"w": "calls", "b": [0.2465, 0.4155, 0.2826, 0.437]}, {"w": "the", "b": [0.2883, 0.4155, 0.3146, 0.437]}, {"w": "train-dev", "b": [0.3203, 0.4153, 0.3953, 0.437]}, {"w": "set.", "b": [0.401, 0.4153, 0.4275, 0.437]}, {"w": "After", "b": [0.4331, 0.4155, 0.4766, 0.437]}, {"w": "the", "b": [0.4823, 0.4155, 0.5086, 0.437]}, {"w": "model", "b": [0.5143, 0.4155, 0.5671, 0.437]}, {"w": "is", "b": [0.5728, 0.4155, 0.586, 0.437]}, {"w": "trained", "b": [0.5917, 0.4155, 0.6518, 0.437]}, {"w": "(on", "b": [0.6575, 0.4155, 0.6867, 0.437]}, {"w": "the", "b": [0.6924, 0.4155, 0.7187, 0.437]}, {"w": "training", "b": [0.7244, 0.4155, 0.7913, 0.437]}, {"w": "set,", "b": [0.797, 0.4155, 0.8246, 0.437]}, {"w": "not", "b": [0.8303, 0.4153, 0.8571, 0.437]}, {"w": "on", "b": [0.1428, 0.4346, 0.1649, 0.456]}, {"w": "the", "b": [0.1701, 0.4346, 0.1964, 0.456]}, {"w": "train-dev", "b": [0.2017, 0.4346, 0.2788, 0.456]}, {"w": "set),", "b": [0.2841, 0.4346, 0.3189, 0.456]}, {"w": "you", "b": [0.3241, 0.4346, 0.3554, 0.456]}, {"w": "can", "b": [0.3606, 0.4346, 0.39, 0.456]}, {"w": "evaluate", "b": [0.3952, 0.4346, 0.4631, 0.456]}, {"w": "it", "b": [0.4684, 0.4346, 0.4803, 0.456]}, {"w": "on", "b": [0.4856, 0.4346, 0.5076, 0.456]}, {"w": "the", "b": [0.5128, 0.4346, 0.5392, 0.456]}, {"w": "train-dev", "b": [0.5444, 0.4346, 0.6215, 0.456]}, {"w": "set:", "b": [0.6268, 0.4346, 0.6544, 0.456]}, {"w": "if", "b": [0.6596, 0.4346, 0.6714, 0.456]}, {"w": "it", "b": [0.6766, 0.4346, 0.6885, 0.456]}, {"w": "performs", "b": [0.6938, 0.4346, 0.7705, 0.456]}, {"w": "well,", "b": [0.7757, 0.4346, 0.8142, 0.456]}, {"w": "then", "b": [0.8194, 0.4346, 0.8571, 0.456]}, {"w": "the", "b": [0.1429, 0.4536, 0.1692, 0.475]}, {"w": "model", "b": [0.1757, 0.4536, 0.2285, 0.475]}, {"w": "is", "b": [0.2351, 0.4536, 0.2483, 0.475]}, {"w": "not", "b": [0.2548, 0.4536, 0.2832, 0.475]}, {"w": "overfitting", "b": [0.2897, 0.4536, 0.3778, 0.475]}, {"w": "the", "b": [0.3843, 0.4536, 0.4106, 0.475]}, {"w": "training", "b": [0.4172, 0.4536, 0.4841, 0.475]}, {"w": "set,", "b": [0.4906, 0.4536, 0.5182, 0.475]}, {"w": "so", "b": [0.5248, 0.4536, 0.543, 0.475]}, {"w": "if", "b": [0.5496, 0.4536, 0.5613, 0.475]}, {"w": "performs", "b": [0.5679, 0.4536, 0.6446, 0.475]}, {"w": "poorly", "b": [0.6511, 0.4536, 0.7058, 0.475]}, {"w": "on", "b": [0.7124, 0.4536, 0.7344, 0.475]}, {"w": "the", "b": [0.7409, 0.4536, 0.7673, 0.475]}, {"w": "validation", "b": [0.7738, 0.4536, 0.8572, 0.475]}, {"w": "set,", "b": [0.1429, 0.4727, 0.1705, 0.4941]}, {"w": "the", "b": [0.1759, 0.4727, 0.2023, 0.4941]}, {"w": "problem", "b": [0.2078, 0.4727, 0.2788, 0.4941]}, {"w": "must", "b": [0.2843, 0.4727, 0.326, 0.4941]}, {"w": "come", "b": [0.3315, 0.4727, 0.3768, 0.4941]}, {"w": "from", "b": [0.3823, 0.4727, 0.4239, 0.4941]}, {"w": "the", "b": [0.4294, 0.4727, 0.4557, 0.4941]}, {"w": "data", "b": [0.4612, 0.4727, 0.4965, 0.4941]}, {"w": "mismatch.", "b": [0.5019, 0.4727, 0.5891, 0.4941]}, {"w": "You", "b": [0.5946, 0.4727, 0.6269, 0.4941]}, {"w": "can", "b": [0.6324, 0.4727, 0.6618, 0.4941]}, {"w": "try", "b": [0.6672, 0.4727, 0.6915, 0.4941]}, {"w": "to", "b": [0.697, 0.4727, 0.714, 0.4941]}, {"w": "tackle", "b": [0.7194, 0.4727, 0.7682, 0.4941]}, {"w": "this", "b": [0.7737, 0.4727, 0.8044, 0.4941]}, {"w": "prob‐", "b": [0.8099, 0.4727, 0.8571, 0.4941]}, {"w": "lem", "b": [0.1429, 0.4917, 0.174, 0.5131]}, {"w": "by", "b": [0.1802, 0.4917, 0.2003, 0.5131]}, {"w": "preprocessing", "b": [0.2064, 0.4917, 0.3229, 0.5131]}, {"w": "the", "b": [0.329, 0.4917, 0.3553, 0.5131]}, {"w": "web", "b": [0.3614, 0.4917, 0.3951, 0.5131]}, {"w": "images", "b": [0.4013, 0.4917, 0.4593, 0.5131]}, {"w": "to", "b": [0.4654, 0.4917, 0.4824, 0.5131]}, {"w": "make", "b": [0.4885, 0.4917, 0.5339, 0.5131]}, {"w": "them", "b": [0.54, 0.4917, 0.5834, 0.5131]}, {"w": "look", "b": [0.5895, 0.4917, 0.6264, 0.5131]}, {"w": "more", "b": [0.6325, 0.4917, 0.6768, 0.5131]}, {"w": "like", "b": [0.6829, 0.4917, 0.7129, 0.5131]}, {"w": "the", "b": [0.719, 0.4917, 0.7454, 0.5131]}, {"w": "pictures", "b": [0.7515, 0.4917, 0.8184, 0.5131]}, {"w": "that", "b": [0.8246, 0.4917, 0.8571, 0.5131]}, {"w": "will", "b": [0.1428, 0.5108, 0.1732, 0.5322]}, {"w": "be", "b": [0.181, 0.5108, 0.2004, 0.5322]}, {"w": "taken", "b": [0.2081, 0.5108, 0.2542, 0.5322]}, {"w": "by", "b": [0.262, 0.5108, 0.2821, 0.5322]}, {"w": "the", "b": [0.2898, 0.5108, 0.3162, 0.5322]}, {"w": "mobile", "b": [0.3239, 0.5108, 0.3819, 0.5322]}, {"w": "app,", "b": [0.3896, 0.5108, 0.4243, 0.5322]}, {"w": "and", "b": [0.4321, 0.5108, 0.4636, 0.5322]}, {"w": "then", "b": [0.4713, 0.5108, 0.5091, 0.5322]}, {"w": "retraining", "b": [0.5168, 0.5108, 0.6003, 0.5322]}, {"w": "the", "b": [0.608, 0.5108, 0.6344, 0.5322]}, {"w": "model.", "b": [0.6421, 0.5108, 0.6997, 0.5322]}, {"w": "Conversely,", "b": [0.7074, 0.5108, 0.8036, 0.5322]}, {"w": "if", "b": [0.8113, 0.5108, 0.8231, 0.5322]}, {"w": "the", "b": [0.8308, 0.5108, 0.8571, 0.5322]}, {"w": "model", "b": [0.1429, 0.5298, 0.1957, 0.5512]}, {"w": "performs", "b": [0.2033, 0.5298, 0.28, 0.5512]}, {"w": "poorly", "b": [0.2876, 0.5298, 0.3423, 0.5512]}, {"w": "on", "b": [0.3499, 0.5298, 0.3719, 0.5512]}, {"w": "the", "b": [0.3795, 0.5298, 0.4058, 0.5512]}, {"w": "train-dev", "b": [0.4134, 0.5298, 0.4906, 0.5512]}, {"w": "set,", "b": [0.4981, 0.5298, 0.5257, 0.5512]}, {"w": "then", "b": [0.5333, 0.5298, 0.5711, 0.5512]}, {"w": "the", "b": [0.5786, 0.5298, 0.605, 0.5512]}, {"w": "model", "b": [0.6126, 0.5298, 0.6654, 0.5512]}, {"w": "must", "b": [0.673, 0.5298, 0.7147, 0.5512]}, {"w": "have", "b": [0.7223, 0.5298, 0.7607, 0.5512]}, {"w": "overfit", "b": [0.7683, 0.5298, 0.8232, 0.5512]}, {"w": "the", "b": [0.8308, 0.5298, 0.8571, 0.5512]}, {"w": "training", "b": [0.1429, 0.5489, 0.2098, 0.5703]}, {"w": "set,", "b": [0.2157, 0.5489, 0.2434, 0.5703]}, {"w": "so", "b": [0.2493, 0.5489, 0.2676, 0.5703]}, {"w": "you", "b": [0.2735, 0.5489, 0.3048, 0.5703]}, {"w": "should", "b": [0.3107, 0.5489, 0.3675, 0.5703]}, {"w": "try", "b": [0.3734, 0.5489, 0.3977, 0.5703]}, {"w": "to", "b": [0.4036, 0.5489, 0.4206, 0.5703]}, {"w": "simplify", "b": [0.4266, 0.5489, 0.4943, 0.5703]}, {"w": "or", "b": [0.5003, 0.5489, 0.5186, 0.5703]}, {"w": "regularize", "b": [0.5246, 0.5489, 0.6073, 0.5703]}, {"w": "the", "b": [0.6133, 0.5489, 0.6396, 0.5703]}, {"w": "model,", "b": [0.6455, 0.5489, 0.7031, 0.5703]}, {"w": "get", "b": [0.7091, 0.5489, 0.734, 0.5703]}, {"w": "more", "b": [0.74, 0.5489, 0.7842, 0.5703]}, {"w": "training", "b": [0.7902, 0.5489, 0.8571, 0.5703]}, {"w": "data", "b": [0.1429, 0.5679, 0.1781, 0.5893]}, {"w": "and", "b": [0.1828, 0.5679, 0.2144, 0.5893]}, {"w": "clean", "b": [0.2191, 0.5679, 0.2626, 0.5893]}, {"w": "up", "b": [0.2673, 0.5679, 0.2893, 0.5893]}, {"w": "the", "b": [0.294, 0.5679, 0.3204, 0.5893]}, {"w": "training", "b": [0.3251, 0.5679, 0.392, 0.5893]}, {"w": "data,", "b": [0.3967, 0.5679, 0.4367, 0.5893]}, {"w": "as", "b": [0.4415, 0.5679, 0.4583, 0.5893]}, {"w": "discussed", "b": [0.463, 0.5679, 0.5422, 0.5893]}, {"w": "earlier.", "b": [0.547, 0.5679, 0.6036, 0.5893]}]}, {"id": "b_3", "type": "paragraph", "text": "No Free Lunch Theorem", "words": [{"w": "No", "b": [0.3852, 0.6151, 0.4121, 0.6423]}, {"w": "Free", "b": [0.4168, 0.6151, 0.4594, 0.6423]}, {"w": "Lunch", "b": [0.4641, 0.6151, 0.5228, 0.6423]}, {"w": "Theorem", "b": [0.5275, 0.6151, 0.6148, 0.6423]}]}, {"id": "b_4", "type": "paragraph", "text": "A model is a simplified version of the observations. The simplifications are meant to discard the superfluous details that are unlikely to generalize to new instances. How‐ ever, to decide what data to discard and what data to keep, you must make assump‐ tions. For example, a linear model makes the assumption that the data is fundamentally linear and that the distance between the instances and the straight line is just noise, which can safely be ignored.", "words": [{"w": "A", "b": [0.1592, 0.6468, 0.1729, 0.6672]}, {"w": "model", "b": [0.1786, 0.6468, 0.2289, 0.6672]}, {"w": "is", "b": [0.2345, 0.6468, 0.2471, 0.6672]}, {"w": "a", "b": [0.2527, 0.6468, 0.2614, 0.6672]}, {"w": "simplified", "b": [0.2671, 0.6468, 0.3464, 0.6672]}, {"w": "version", "b": [0.352, 0.6468, 0.4106, 0.6672]}, {"w": "of", "b": [0.4162, 0.6468, 0.4322, 0.6672]}, {"w": "the", "b": [0.4378, 0.6468, 0.4629, 0.6672]}, {"w": "observations.", "b": [0.4685, 0.6468, 0.574, 0.6672]}, {"w": "The", "b": [0.5797, 0.6468, 0.6109, 0.6672]}, {"w": "simplifications", "b": [0.6166, 0.6468, 0.7333, 0.6672]}, {"w": "are", "b": [0.7389, 0.6468, 0.7634, 0.6672]}, {"w": "meant", "b": [0.7691, 0.6468, 0.819, 0.6672]}, {"w": "to", "b": [0.8246, 0.6468, 0.8408, 0.6672]}, {"w": "discard", "b": [0.1592, 0.6649, 0.2173, 0.6853]}, {"w": "the", "b": [0.2227, 0.6649, 0.2478, 0.6853]}, {"w": "superfluous", "b": [0.2533, 0.6649, 0.3466, 0.6853]}, {"w": "details", "b": [0.3521, 0.6649, 0.4034, 0.6853]}, {"w": "that", "b": [0.4088, 0.6649, 0.4399, 0.6853]}, {"w": "are", "b": [0.4453, 0.6649, 0.4698, 0.6853]}, {"w": "unlikely", "b": [0.4753, 0.6649, 0.5394, 0.6853]}, {"w": "to", "b": [0.5449, 0.6649, 0.5611, 0.6853]}, {"w": "generalize", "b": [0.5665, 0.6649, 0.6467, 0.6853]}, {"w": "to", "b": [0.6522, 0.6649, 0.6683, 0.6853]}, {"w": "new", "b": [0.6738, 0.6649, 0.7067, 0.6853]}, {"w": "instances.", "b": [0.7121, 0.6649, 0.7898, 0.6853]}, {"w": "How‐", "b": [0.7953, 0.6649, 0.8408, 0.6853]}, {"w": "ever,", "b": [0.1592, 0.6831, 0.1959, 0.7035]}, {"w": "to", "b": [0.2022, 0.6831, 0.2184, 0.7035]}, {"w": "decide", "b": [0.2246, 0.6831, 0.2762, 0.7035]}, {"w": "what", "b": [0.2824, 0.6831, 0.321, 0.7035]}, {"w": "data", "b": [0.3273, 0.6831, 0.3609, 0.7035]}, {"w": "to", "b": [0.3671, 0.6831, 0.3833, 0.7035]}, {"w": "discard", "b": [0.3896, 0.6831, 0.4476, 0.7035]}, {"w": "and", "b": [0.4539, 0.6831, 0.4839, 0.7035]}, {"w": "what", "b": [0.4902, 0.6831, 0.5288, 0.7035]}, {"w": "data", "b": [0.535, 0.6831, 0.5686, 0.7035]}, {"w": "to", "b": [0.5749, 0.6831, 0.591, 0.7035]}, {"w": "keep,", "b": [0.5973, 0.6831, 0.6384, 0.7035]}, {"w": "you", "b": [0.6446, 0.6831, 0.6744, 0.7035]}, {"w": "must", "b": [0.6807, 0.6831, 0.7204, 0.7035]}, {"w": "make", "b": [0.7267, 0.6831, 0.7699, 0.7035]}, {"w": "assump‐", "b": [0.7762, 0.6829, 0.8408, 0.7035]}, {"w": "tions.", "b": [0.1592, 0.701, 0.2014, 0.7216]}, {"w": "For", "b": [0.2152, 0.7012, 0.2428, 0.7216]}, {"w": "example,", "b": [0.2567, 0.7012, 0.3274, 0.7216]}, {"w": "a", "b": [0.3412, 0.7012, 0.35, 0.7216]}, {"w": "linear", "b": [0.3638, 0.7012, 0.4095, 0.7216]}, {"w": "model", "b": [0.4233, 0.7012, 0.4736, 0.7216]}, {"w": "makes", "b": [0.4875, 0.7012, 0.538, 0.7216]}, {"w": "the", "b": [0.5518, 0.7012, 0.5769, 0.7216]}, {"w": "assumption", "b": [0.5907, 0.7012, 0.6832, 0.7216]}, {"w": "that", "b": [0.697, 0.7012, 0.728, 0.7216]}, {"w": "the", "b": [0.7419, 0.7012, 0.7669, 0.7216]}, {"w": "data", "b": [0.7808, 0.7012, 0.8143, 0.7216]}, {"w": "is", "b": [0.8282, 0.7012, 0.8408, 0.7216]}, {"w": "fundamentally", "b": [0.1592, 0.7194, 0.2748, 0.7398]}, {"w": "linear", "b": [0.2797, 0.7194, 0.3254, 0.7398]}, {"w": "and", "b": [0.3304, 0.7194, 0.3604, 0.7398]}, {"w": "that", "b": [0.3654, 0.7194, 0.3964, 0.7398]}, {"w": "the", "b": [0.4014, 0.7194, 0.4264, 0.7398]}, {"w": "distance", "b": [0.4314, 0.7194, 0.4969, 0.7398]}, {"w": "between", "b": [0.5019, 0.7194, 0.5677, 0.7398]}, {"w": "the", "b": [0.5727, 0.7194, 0.5978, 0.7398]}, {"w": "instances", "b": [0.6027, 0.7194, 0.6759, 0.7398]}, {"w": "and", "b": [0.6809, 0.7194, 0.7109, 0.7398]}, {"w": "the", "b": [0.7159, 0.7194, 0.741, 0.7398]}, {"w": "straight", "b": [0.7459, 0.7194, 0.8062, 0.7398]}, {"w": "line", "b": [0.8112, 0.7194, 0.8408, 0.7398]}, {"w": "is", "b": [0.1592, 0.7375, 0.1718, 0.7579]}, {"w": "just", "b": [0.1763, 0.7375, 0.2053, 0.7579]}, {"w": "noise,", "b": [0.2098, 0.7375, 0.2563, 0.7579]}, {"w": "which", "b": [0.2608, 0.7375, 0.3093, 0.7579]}, {"w": "can", "b": [0.3138, 0.7375, 0.3418, 0.7579]}, {"w": "safely", "b": [0.3463, 0.7375, 0.3907, 0.7579]}, {"w": "be", "b": [0.3952, 0.7375, 0.4137, 0.7579]}, {"w": "ignored.", "b": [0.4182, 0.7375, 0.4846, 0.7579]}]}, {"id": "b_5", "type": "paragraph", "text": "In a famous 1996 paper,11 David Wolpert demonstrated that if you make absolutely no assumption about the data, then there is no reason to prefer one model over any other. This is called the No Free Lunch (NFL) theorem. For some datasets the best", "words": [{"w": "In", "b": [0.1592, 0.7647, 0.1769, 0.7851]}, {"w": "a", "b": [0.1834, 0.7647, 0.1922, 0.7851]}, {"w": "famous", "b": [0.1988, 0.7647, 0.2575, 0.7851]}, {"w": "1996", "b": [0.2641, 0.7647, 0.3022, 0.7851]}, {"w": "paper,11", "b": [0.3088, 0.7647, 0.3697, 0.7851]}, {"w": "David", "b": [0.3763, 0.7647, 0.4242, 0.7851]}, {"w": "Wolpert", "b": [0.4308, 0.7647, 0.4955, 0.7851]}, {"w": "demonstrated", "b": [0.5021, 0.7647, 0.6122, 0.7851]}, {"w": "that", "b": [0.6188, 0.7647, 0.6498, 0.7851]}, {"w": "if", "b": [0.6564, 0.7647, 0.6676, 0.7851]}, {"w": "you", "b": [0.6742, 0.7647, 0.704, 0.7851]}, {"w": "make", "b": [0.7106, 0.7647, 0.7538, 0.7851]}, {"w": "absolutely", "b": [0.7604, 0.7647, 0.8408, 0.7851]}, {"w": "no", "b": [0.1592, 0.7829, 0.1802, 0.8033]}, {"w": "assumption", "b": [0.1861, 0.7829, 0.2786, 0.8033]}, {"w": "about", "b": [0.2845, 0.7829, 0.33, 0.8033]}, {"w": "the", "b": [0.336, 0.7829, 0.3611, 0.8033]}, {"w": "data,", "b": [0.367, 0.7829, 0.4051, 0.8033]}, {"w": "then", "b": [0.4111, 0.7829, 0.447, 0.8033]}, {"w": "there", "b": [0.4529, 0.7829, 0.4938, 0.8033]}, {"w": "is", "b": [0.4998, 0.7829, 0.5124, 0.8033]}, {"w": "no", "b": [0.5183, 0.7829, 0.5393, 0.8033]}, {"w": "reason", "b": [0.5452, 0.7829, 0.598, 0.8033]}, {"w": "to", "b": [0.604, 0.7829, 0.6201, 0.8033]}, {"w": "prefer", "b": [0.6261, 0.7829, 0.6739, 0.8033]}, {"w": "one", "b": [0.6799, 0.7829, 0.7093, 0.8033]}, {"w": "model", "b": [0.7153, 0.7829, 0.7655, 0.8033]}, {"w": "over", "b": [0.7715, 0.7829, 0.8066, 0.8033]}, {"w": "any", "b": [0.8126, 0.7829, 0.8408, 0.8033]}, {"w": "other.", "b": [0.1592, 0.801, 0.2051, 0.8214]}, {"w": "This", "b": [0.2124, 0.801, 0.2478, 0.8214]}, {"w": "is", "b": [0.2551, 0.801, 0.2677, 0.8214]}, {"w": "called", "b": [0.275, 0.801, 0.321, 0.8214]}, {"w": "the", "b": [0.3283, 0.801, 0.3534, 0.8214]}, {"w": "No", "b": [0.3607, 0.8008, 0.3834, 0.8214]}, {"w": "Free", "b": [0.3908, 0.8008, 0.4234, 0.8214]}, {"w": "Lunch", "b": [0.4307, 0.8008, 0.4791, 0.8214]}, {"w": "(NFL)", "b": [0.4864, 0.801, 0.536, 0.8214]}, {"w": "theorem.", "b": [0.5433, 0.801, 0.6151, 0.8214]}, {"w": "For", "b": [0.6224, 0.801, 0.65, 0.8214]}, {"w": "some", "b": [0.6573, 0.801, 0.6993, 0.8214]}, {"w": "datasets", "b": [0.7066, 0.801, 0.7693, 0.8214]}, {"w": "the", "b": [0.7766, 0.801, 0.8016, 0.8214]}, {"w": "best", "b": [0.8089, 0.801, 0.8408, 0.8214]}]}, {"id": "b_6", "type": "paragraph", "text": "Testing and Validating | 33", "words": [{"w": "Testing", "b": [0.6706, 0.9225, 0.714, 0.9388]}, {"w": "and", "b": [0.7168, 0.9225, 0.7392, 0.9388]}, {"w": "Validating", "b": [0.742, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "33", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 60, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "model is a linear model, while for other datasets it is a neural network. There is no model that is a priori guaranteed to work better (hence the name of the theorem). The only way to know for sure which model is best is to evaluate them all. Since this is not possible, in practice you make some reasonable assumptions about the data and you evaluate only a few reasonable models. For example, for simple tasks you may evalu‐ ate linear models with various levels of regularization, and for a complex problem you may evaluate various neural networks.", "words": [{"w": "model", "b": [0.1592, 0.0792, 0.2095, 0.0996]}, {"w": "is", "b": [0.216, 0.0792, 0.2286, 0.0996]}, {"w": "a", "b": [0.235, 0.0792, 0.2437, 0.0996]}, {"w": "linear", "b": [0.2501, 0.0792, 0.2958, 0.0996]}, {"w": "model,", "b": [0.3023, 0.0792, 0.3571, 0.0996]}, {"w": "while", "b": [0.3635, 0.0792, 0.4065, 0.0996]}, {"w": "for", "b": [0.4129, 0.0792, 0.4363, 0.0996]}, {"w": "other", "b": [0.4427, 0.0792, 0.4853, 0.0996]}, {"w": "datasets", "b": [0.4917, 0.0792, 0.5543, 0.0996]}, {"w": "it", "b": [0.5607, 0.0792, 0.5721, 0.0996]}, {"w": "is", "b": [0.5785, 0.0792, 0.5911, 0.0996]}, {"w": "a", "b": [0.5976, 0.0792, 0.6063, 0.0996]}, {"w": "neural", "b": [0.6127, 0.0792, 0.6636, 0.0996]}, {"w": "network.", "b": [0.6701, 0.0792, 0.7408, 0.0996]}, {"w": "There", "b": [0.7473, 0.0792, 0.7943, 0.0996]}, {"w": "is", "b": [0.8008, 0.0792, 0.8134, 0.0996]}, {"w": "no", "b": [0.8198, 0.0792, 0.8408, 0.0996]}, {"w": "model", "b": [0.1592, 0.0973, 0.2095, 0.1177]}, {"w": "that", "b": [0.214, 0.0973, 0.2451, 0.1177]}, {"w": "is", "b": [0.2496, 0.0973, 0.2622, 0.1177]}, {"w": "a", "b": [0.2667, 0.0971, 0.2764, 0.1177]}, {"w": "priori", "b": [0.281, 0.0971, 0.3252, 0.1177]}, {"w": "guaranteed", "b": [0.3297, 0.0973, 0.4182, 0.1177]}, {"w": "to", "b": [0.4227, 0.0973, 0.4389, 0.1177]}, {"w": "work", "b": [0.4434, 0.0973, 0.4843, 0.1177]}, {"w": "better", "b": [0.4888, 0.0973, 0.5352, 0.1177]}, {"w": "(hence", "b": [0.5397, 0.0973, 0.5933, 0.1177]}, {"w": "the", "b": [0.5978, 0.0973, 0.6229, 0.1177]}, {"w": "name", "b": [0.6274, 0.0973, 0.6716, 0.1177]}, {"w": "of", "b": [0.6761, 0.0973, 0.6921, 0.1177]}, {"w": "the", "b": [0.6966, 0.0973, 0.7217, 0.1177]}, {"w": "theorem).", "b": [0.7262, 0.0973, 0.8048, 0.1177]}, {"w": "The", "b": [0.8093, 0.0973, 0.8406, 0.1177]}, {"w": "only", "b": [0.1592, 0.1155, 0.1943, 0.1359]}, {"w": "way", "b": [0.1991, 0.1155, 0.2301, 0.1359]}, {"w": "to", "b": [0.2349, 0.1155, 0.251, 0.1359]}, {"w": "know", "b": [0.2558, 0.1155, 0.3002, 0.1359]}, {"w": "for", "b": [0.3049, 0.1155, 0.3283, 0.1359]}, {"w": "sure", "b": [0.333, 0.1155, 0.3666, 0.1359]}, {"w": "which", "b": [0.3713, 0.1155, 0.4198, 0.1359]}, {"w": "model", "b": [0.4246, 0.1155, 0.4749, 0.1359]}, {"w": "is", "b": [0.4796, 0.1155, 0.4922, 0.1359]}, {"w": "best", "b": [0.4969, 0.1155, 0.5288, 0.1359]}, {"w": "is", "b": [0.5335, 0.1155, 0.5461, 0.1359]}, {"w": "to", "b": [0.5509, 0.1155, 0.567, 0.1359]}, {"w": "evaluate", "b": [0.5718, 0.1155, 0.6365, 0.1359]}, {"w": "them", "b": [0.6412, 0.1155, 0.6825, 0.1359]}, {"w": "all.", "b": [0.6873, 0.1155, 0.7106, 0.1359]}, {"w": "Since", "b": [0.7153, 0.1155, 0.7577, 0.1359]}, {"w": "this", "b": [0.7624, 0.1155, 0.7917, 0.1359]}, {"w": "is", "b": [0.7964, 0.1155, 0.809, 0.1359]}, {"w": "not", "b": [0.8137, 0.1155, 0.8408, 0.1359]}, {"w": "possible,", "b": [0.1592, 0.1336, 0.2277, 0.154]}, {"w": "in", "b": [0.2335, 0.1336, 0.2497, 0.154]}, {"w": "practice", "b": [0.2555, 0.1336, 0.3186, 0.154]}, {"w": "you", "b": [0.3244, 0.1336, 0.3542, 0.154]}, {"w": "make", "b": [0.36, 0.1336, 0.4033, 0.154]}, {"w": "some", "b": [0.4091, 0.1336, 0.4512, 0.154]}, {"w": "reasonable", "b": [0.4571, 0.1336, 0.5421, 0.154]}, {"w": "assumptions", "b": [0.5479, 0.1336, 0.6476, 0.154]}, {"w": "about", "b": [0.6534, 0.1336, 0.6989, 0.154]}, {"w": "the", "b": [0.7048, 0.1336, 0.7299, 0.154]}, {"w": "data", "b": [0.7357, 0.1336, 0.7693, 0.154]}, {"w": "and", "b": [0.7751, 0.1336, 0.8052, 0.154]}, {"w": "you", "b": [0.811, 0.1336, 0.8408, 0.154]}, {"w": "evaluate", "b": [0.1592, 0.1517, 0.2239, 0.1721]}, {"w": "only", "b": [0.2295, 0.1517, 0.2646, 0.1721]}, {"w": "a", "b": [0.2702, 0.1517, 0.2789, 0.1721]}, {"w": "few", "b": [0.2845, 0.1517, 0.3123, 0.1721]}, {"w": "reasonable", "b": [0.3179, 0.1517, 0.4029, 0.1721]}, {"w": "models.", "b": [0.4085, 0.1517, 0.4706, 0.1721]}, {"w": "For", "b": [0.4762, 0.1517, 0.5038, 0.1721]}, {"w": "example,", "b": [0.5093, 0.1517, 0.5801, 0.1721]}, {"w": "for", "b": [0.5857, 0.1517, 0.609, 0.1721]}, {"w": "simple", "b": [0.6146, 0.1517, 0.6669, 0.1721]}, {"w": "tasks", "b": [0.6725, 0.1517, 0.7116, 0.1721]}, {"w": "you", "b": [0.7172, 0.1517, 0.747, 0.1721]}, {"w": "may", "b": [0.7525, 0.1517, 0.7863, 0.1721]}, {"w": "evalu‐", "b": [0.7918, 0.1517, 0.8408, 0.1721]}, {"w": "ate", "b": [0.1592, 0.1699, 0.182, 0.1903]}, {"w": "linear", "b": [0.1866, 0.1699, 0.2323, 0.1903]}, {"w": "models", "b": [0.2369, 0.1699, 0.2944, 0.1903]}, {"w": "with", "b": [0.299, 0.1699, 0.3346, 0.1903]}, {"w": "various", "b": [0.3391, 0.1699, 0.3976, 0.1903]}, {"w": "levels", "b": [0.4022, 0.1699, 0.4456, 0.1903]}, {"w": "of", "b": [0.4501, 0.1699, 0.4661, 0.1903]}, {"w": "regularization,", "b": [0.4707, 0.1699, 0.5863, 0.1903]}, {"w": "and", "b": [0.5908, 0.1699, 0.6209, 0.1903]}, {"w": "for", "b": [0.6254, 0.1699, 0.6488, 0.1903]}, {"w": "a", "b": [0.6533, 0.1699, 0.6621, 0.1903]}, {"w": "complex", "b": [0.6666, 0.1699, 0.7342, 0.1903]}, {"w": "problem", "b": [0.7388, 0.1699, 0.8064, 0.1903]}, {"w": "you", "b": [0.811, 0.1699, 0.8408, 0.1903]}, {"w": "may", "b": [0.1592, 0.188, 0.1929, 0.2084]}, {"w": "evaluate", "b": [0.1974, 0.188, 0.2621, 0.2084]}, {"w": "various", "b": [0.2666, 0.188, 0.3252, 0.2084]}, {"w": "neural", "b": [0.3297, 0.188, 0.3806, 0.2084]}, {"w": "networks.", "b": [0.3851, 0.188, 0.4631, 0.2084]}]}, {"id": "b_1", "type": "paragraph", "text": "Exercises", "words": [{"w": "Exercises", "b": [0.1428, 0.2384, 0.2533, 0.2727]}]}, {"id": "b_2", "type": "paragraph", "text": "In this chapter we have covered some of the most important concepts in Machine Learning. In the next chapters we will dive deeper and write more code, but before we do, make sure you know how to answer the following questions:", "words": [{"w": "In", "b": [0.1429, 0.2796, 0.1614, 0.301]}, {"w": "this", "b": [0.1689, 0.2796, 0.1996, 0.301]}, {"w": "chapter", "b": [0.2072, 0.2796, 0.2698, 0.301]}, {"w": "we", "b": [0.2774, 0.2796, 0.3005, 0.301]}, {"w": "have", "b": [0.3081, 0.2796, 0.3465, 0.301]}, {"w": "covered", "b": [0.354, 0.2796, 0.4196, 0.301]}, {"w": "some", "b": [0.4272, 0.2796, 0.4713, 0.301]}, {"w": "of", "b": [0.4789, 0.2796, 0.4957, 0.301]}, {"w": "the", "b": [0.5033, 0.2796, 0.5296, 0.301]}, {"w": "most", "b": [0.5372, 0.2796, 0.5789, 0.301]}, {"w": "important", "b": [0.5865, 0.2796, 0.6709, 0.301]}, {"w": "concepts", "b": [0.6785, 0.2796, 0.7519, 0.301]}, {"w": "in", "b": [0.7595, 0.2796, 0.7764, 0.301]}, {"w": "Machine", "b": [0.784, 0.2796, 0.8571, 0.301]}, {"w": "Learning.", "b": [0.1428, 0.2986, 0.2227, 0.3201]}, {"w": "In", "b": [0.2274, 0.2986, 0.2459, 0.3201]}, {"w": "the", "b": [0.2506, 0.2986, 0.277, 0.3201]}, {"w": "next", "b": [0.2817, 0.2986, 0.3181, 0.3201]}, {"w": "chapters", "b": [0.3228, 0.2986, 0.393, 0.3201]}, {"w": "we", "b": [0.3978, 0.2986, 0.4209, 0.3201]}, {"w": "will", "b": [0.4256, 0.2986, 0.456, 0.3201]}, {"w": "dive", "b": [0.4607, 0.2986, 0.4958, 0.3201]}, {"w": "deeper", "b": [0.5006, 0.2986, 0.5568, 0.3201]}, {"w": "and", "b": [0.5615, 0.2986, 0.593, 0.3201]}, {"w": "write", "b": [0.5978, 0.2986, 0.6406, 0.3201]}, {"w": "more", "b": [0.6453, 0.2986, 0.6896, 0.3201]}, {"w": "code,", "b": [0.6943, 0.2986, 0.7383, 0.3201]}, {"w": "but", "b": [0.7431, 0.2986, 0.7711, 0.3201]}, {"w": "before", "b": [0.7758, 0.2986, 0.8286, 0.3201]}, {"w": "we", "b": [0.8333, 0.2986, 0.8565, 0.3201]}, {"w": "do,", "b": [0.1428, 0.3177, 0.1686, 0.3391]}, {"w": "make", "b": [0.1733, 0.3177, 0.2187, 0.3391]}, {"w": "sure", "b": [0.2235, 0.3177, 0.2588, 0.3391]}, {"w": "you", "b": [0.2635, 0.3177, 0.2947, 0.3391]}, {"w": "know", "b": [0.2995, 0.3177, 0.3461, 0.3391]}, {"w": "how", "b": [0.3508, 0.3177, 0.3868, 0.3391]}, {"w": "to", "b": [0.3916, 0.3177, 0.4086, 0.3391]}, {"w": "answer", "b": [0.4133, 0.3177, 0.4723, 0.3391]}, {"w": "the", "b": [0.4771, 0.3177, 0.5034, 0.3391]}, {"w": "following", "b": [0.5081, 0.3177, 0.5871, 0.3391]}, {"w": "questions:", "b": [0.5918, 0.3177, 0.6764, 0.3391]}]}, {"id": "b_3", "type": "paragraph", "text": "1. How would you define Machine Learning?", "words": [{"w": "1.", "b": [0.1534, 0.3519, 0.1681, 0.3733]}, {"w": "How", "b": [0.1786, 0.3519, 0.2189, 0.3733]}, {"w": "would", "b": [0.2236, 0.3519, 0.2759, 0.3733]}, {"w": "you", "b": [0.2806, 0.3519, 0.3118, 0.3733]}, {"w": "define", "b": [0.3166, 0.3519, 0.3684, 0.3733]}, {"w": "Machine", "b": [0.3731, 0.3519, 0.4463, 0.3733]}, {"w": "Learning?", "b": [0.451, 0.3519, 0.534, 0.3733]}]}, {"id": "b_4", "type": "paragraph", "text": "2. Can you name four types of problems where it shines?", "words": [{"w": "2.", "b": [0.1534, 0.3769, 0.1682, 0.3984]}, {"w": "Can", "b": [0.1786, 0.3769, 0.213, 0.3984]}, {"w": "you", "b": [0.2177, 0.3769, 0.2489, 0.3984]}, {"w": "name", "b": [0.2537, 0.3769, 0.3001, 0.3984]}, {"w": "four", "b": [0.3049, 0.3769, 0.3404, 0.3984]}, {"w": "types", "b": [0.3452, 0.3769, 0.3885, 0.3984]}, {"w": "of", "b": [0.3932, 0.3769, 0.41, 0.3984]}, {"w": "problems", "b": [0.4148, 0.3769, 0.4934, 0.3984]}, {"w": "where", "b": [0.4982, 0.3769, 0.549, 0.3984]}, {"w": "it", "b": [0.5537, 0.3769, 0.5657, 0.3984]}, {"w": "shines?", "b": [0.5704, 0.3769, 0.6305, 0.3984]}]}, {"id": "b_5", "type": "paragraph", "text": "3. What is a labeled training set?", "words": [{"w": "3.", "b": [0.1534, 0.402, 0.1682, 0.4235]}, {"w": "What", "b": [0.1786, 0.402, 0.225, 0.4235]}, {"w": "is", "b": [0.2298, 0.402, 0.243, 0.4235]}, {"w": "a", "b": [0.2477, 0.402, 0.2569, 0.4235]}, {"w": "labeled", "b": [0.2616, 0.402, 0.3206, 0.4235]}, {"w": "training", "b": [0.3253, 0.402, 0.3922, 0.4235]}, {"w": "set?", "b": [0.397, 0.402, 0.4277, 0.4235]}]}, {"id": "b_6", "type": "paragraph", "text": "4. What are the two most common supervised tasks?", "words": [{"w": "4.", "b": [0.1534, 0.4271, 0.1682, 0.4485]}, {"w": "What", "b": [0.1786, 0.4271, 0.225, 0.4485]}, {"w": "are", "b": [0.2298, 0.4271, 0.2555, 0.4485]}, {"w": "the", "b": [0.2602, 0.4271, 0.2865, 0.4485]}, {"w": "two", "b": [0.2913, 0.4271, 0.3225, 0.4485]}, {"w": "most", "b": [0.3273, 0.4271, 0.3689, 0.4485]}, {"w": "common", "b": [0.3737, 0.4271, 0.4493, 0.4485]}, {"w": "supervised", "b": [0.454, 0.4271, 0.5435, 0.4485]}, {"w": "tasks?", "b": [0.5483, 0.4271, 0.5973, 0.4485]}]}, {"id": "b_7", "type": "paragraph", "text": "5. Can you name four common unsupervised tasks?", "words": [{"w": "5.", "b": [0.1534, 0.4522, 0.1682, 0.4736]}, {"w": "Can", "b": [0.1786, 0.4522, 0.213, 0.4736]}, {"w": "you", "b": [0.2177, 0.4522, 0.2489, 0.4736]}, {"w": "name", "b": [0.2537, 0.4522, 0.3001, 0.4736]}, {"w": "four", "b": [0.3049, 0.4522, 0.3404, 0.4736]}, {"w": "common", "b": [0.3452, 0.4522, 0.4208, 0.4736]}, {"w": "unsupervised", "b": [0.4255, 0.4522, 0.5375, 0.4736]}, {"w": "tasks?", "b": [0.5422, 0.4522, 0.5912, 0.4736]}]}, {"id": "b_8", "type": "paragraph", "text": "6. What type of Machine Learning algorithm would you use to allow a robot to walk in various unknown terrains?", "words": [{"w": "6.", "b": [0.1534, 0.4773, 0.1682, 0.4987]}, {"w": "What", "b": [0.1786, 0.4773, 0.225, 0.4987]}, {"w": "type", "b": [0.233, 0.4773, 0.2687, 0.4987]}, {"w": "of", "b": [0.2767, 0.4773, 0.2935, 0.4987]}, {"w": "Machine", "b": [0.3015, 0.4773, 0.3747, 0.4987]}, {"w": "Learning", "b": [0.3827, 0.4773, 0.4577, 0.4987]}, {"w": "algorithm", "b": [0.4658, 0.4773, 0.5484, 0.4987]}, {"w": "would", "b": [0.5564, 0.4773, 0.6086, 0.4987]}, {"w": "you", "b": [0.6166, 0.4773, 0.6479, 0.4987]}, {"w": "use", "b": [0.6559, 0.4773, 0.6835, 0.4987]}, {"w": "to", "b": [0.6915, 0.4773, 0.7085, 0.4987]}, {"w": "allow", "b": [0.7165, 0.4773, 0.7611, 0.4987]}, {"w": "a", "b": [0.7691, 0.4773, 0.7782, 0.4987]}, {"w": "robot", "b": [0.7862, 0.4773, 0.8321, 0.4987]}, {"w": "to", "b": [0.8402, 0.4773, 0.8571, 0.4987]}, {"w": "walk", "b": [0.1786, 0.4964, 0.2176, 0.5178]}, {"w": "in", "b": [0.2223, 0.4964, 0.2393, 0.5178]}, {"w": "various", "b": [0.244, 0.4964, 0.3055, 0.5178]}, {"w": "unknown", "b": [0.3102, 0.4964, 0.3907, 0.5178]}, {"w": "terrains?", "b": [0.3954, 0.4964, 0.4677, 0.5178]}]}, {"id": "b_9", "type": "paragraph", "text": "7. What type of algorithm would you use to segment your customers into multiple groups?", "words": [{"w": "7.", "b": [0.1534, 0.5215, 0.1682, 0.5429]}, {"w": "What", "b": [0.1786, 0.5215, 0.225, 0.5429]}, {"w": "type", "b": [0.231, 0.5215, 0.2666, 0.5429]}, {"w": "of", "b": [0.2726, 0.5215, 0.2894, 0.5429]}, {"w": "algorithm", "b": [0.2953, 0.5215, 0.3779, 0.5429]}, {"w": "would", "b": [0.3839, 0.5215, 0.4361, 0.5429]}, {"w": "you", "b": [0.442, 0.5215, 0.4733, 0.5429]}, {"w": "use", "b": [0.4792, 0.5215, 0.5068, 0.5429]}, {"w": "to", "b": [0.5127, 0.5215, 0.5297, 0.5429]}, {"w": "segment", "b": [0.5356, 0.5215, 0.6051, 0.5429]}, {"w": "your", "b": [0.611, 0.5215, 0.65, 0.5429]}, {"w": "customers", "b": [0.6559, 0.5215, 0.7417, 0.5429]}, {"w": "into", "b": [0.7477, 0.5215, 0.7812, 0.5429]}, {"w": "multiple", "b": [0.7872, 0.5215, 0.8571, 0.5429]}, {"w": "groups?", "b": [0.1786, 0.5405, 0.2442, 0.5619]}]}, {"id": "b_10", "type": "paragraph", "text": "8. Would you frame the problem of spam detection as a supervised learning prob‐ lem or an unsupervised learning problem?", "words": [{"w": "8.", "b": [0.1534, 0.5656, 0.1682, 0.587]}, {"w": "Would", "b": [0.1786, 0.5656, 0.2347, 0.587]}, {"w": "you", "b": [0.2409, 0.5656, 0.2721, 0.587]}, {"w": "frame", "b": [0.2782, 0.5656, 0.3272, 0.587]}, {"w": "the", "b": [0.3333, 0.5656, 0.3597, 0.587]}, {"w": "problem", "b": [0.3658, 0.5656, 0.4368, 0.587]}, {"w": "of", "b": [0.443, 0.5656, 0.4598, 0.587]}, {"w": "spam", "b": [0.4659, 0.5656, 0.5107, 0.587]}, {"w": "detection", "b": [0.5168, 0.5656, 0.5946, 0.587]}, {"w": "as", "b": [0.6007, 0.5656, 0.6175, 0.587]}, {"w": "a", "b": [0.6237, 0.5656, 0.6328, 0.587]}, {"w": "supervised", "b": [0.6389, 0.5656, 0.7285, 0.587]}, {"w": "learning", "b": [0.7346, 0.5656, 0.8037, 0.587]}, {"w": "prob‐", "b": [0.8099, 0.5656, 0.8571, 0.587]}, {"w": "lem", "b": [0.1786, 0.5847, 0.2098, 0.6061]}, {"w": "or", "b": [0.2145, 0.5847, 0.2328, 0.6061]}, {"w": "an", "b": [0.2376, 0.5847, 0.2581, 0.6061]}, {"w": "unsupervised", "b": [0.2628, 0.5847, 0.3748, 0.6061]}, {"w": "learning", "b": [0.3796, 0.5847, 0.4487, 0.6061]}, {"w": "problem?", "b": [0.4534, 0.5847, 0.5324, 0.6061]}]}, {"id": "b_11", "type": "paragraph", "text": "9. What is an online learning system?", "words": [{"w": "9.", "b": [0.1534, 0.6097, 0.1682, 0.6312]}, {"w": "What", "b": [0.1786, 0.6097, 0.225, 0.6312]}, {"w": "is", "b": [0.2298, 0.6097, 0.243, 0.6312]}, {"w": "an", "b": [0.2477, 0.6097, 0.2683, 0.6312]}, {"w": "online", "b": [0.273, 0.6097, 0.3261, 0.6312]}, {"w": "learning", "b": [0.3308, 0.6097, 0.4, 0.6312]}, {"w": "system?", "b": [0.4047, 0.6097, 0.4697, 0.6312]}]}, {"id": "b_12", "type": "equation", "text": "10. What is out-of-core learning?", "words": [{"w": "10.", "b": [0.1434, 0.6348, 0.1682, 0.6563]}, {"w": "What", "b": [0.1786, 0.6348, 0.225, 0.6563]}, {"w": "is", "b": [0.2298, 0.6348, 0.243, 0.6563]}, {"w": "out-of-core", "b": [0.2477, 0.6348, 0.3434, 0.6563]}, {"w": "learning?", "b": [0.3481, 0.6348, 0.4251, 0.6563]}]}, {"id": "b_13", "type": "paragraph", "text": "11. What type of learning algorithm relies on a similarity measure to make predic‐ tions?", "words": [{"w": "11.", "b": [0.1434, 0.6599, 0.1682, 0.6814]}, {"w": "What", "b": [0.1786, 0.6599, 0.225, 0.6814]}, {"w": "type", "b": [0.2317, 0.6599, 0.2674, 0.6814]}, {"w": "of", "b": [0.2741, 0.6599, 0.2909, 0.6814]}, {"w": "learning", "b": [0.2976, 0.6599, 0.3667, 0.6814]}, {"w": "algorithm", "b": [0.3734, 0.6599, 0.456, 0.6814]}, {"w": "relies", "b": [0.4627, 0.6599, 0.5066, 0.6814]}, {"w": "on", "b": [0.5133, 0.6599, 0.5353, 0.6814]}, {"w": "a", "b": [0.542, 0.6599, 0.5512, 0.6814]}, {"w": "similarity", "b": [0.5578, 0.6599, 0.6374, 0.6814]}, {"w": "measure", "b": [0.644, 0.6599, 0.7144, 0.6814]}, {"w": "to", "b": [0.7211, 0.6599, 0.7381, 0.6814]}, {"w": "make", "b": [0.7447, 0.6599, 0.7901, 0.6814]}, {"w": "predic‐", "b": [0.7968, 0.6599, 0.8571, 0.6814]}, {"w": "tions?", "b": [0.1786, 0.679, 0.2281, 0.7004]}]}, {"id": "b_14", "type": "paragraph", "text": "12. What is the difference between a model parameter and a learning algorithm’s hyperparameter?", "words": [{"w": "12.", "b": [0.1434, 0.7041, 0.1682, 0.7255]}, {"w": "What", "b": [0.1786, 0.7041, 0.225, 0.7255]}, {"w": "is", "b": [0.2333, 0.7041, 0.2465, 0.7255]}, {"w": "the", "b": [0.2548, 0.7041, 0.2812, 0.7255]}, {"w": "difference", "b": [0.2894, 0.7041, 0.3729, 0.7255]}, {"w": "between", "b": [0.3812, 0.7041, 0.4503, 0.7255]}, {"w": "a", "b": [0.4586, 0.7041, 0.4677, 0.7255]}, {"w": "model", "b": [0.476, 0.7041, 0.5288, 0.7255]}, {"w": "parameter", "b": [0.5371, 0.7041, 0.6229, 0.7255]}, {"w": "and", "b": [0.6312, 0.7041, 0.6628, 0.7255]}, {"w": "a", "b": [0.671, 0.7041, 0.6802, 0.7255]}, {"w": "learning", "b": [0.6885, 0.7041, 0.7576, 0.7255]}, {"w": "algorithm’s", "b": [0.7659, 0.7041, 0.8571, 0.7255]}, {"w": "hyperparameter?", "b": [0.1786, 0.7231, 0.32, 0.7445]}]}, {"id": "b_15", "type": "paragraph", "text": "13. What do model-based learning algorithms search for? What is the most common strategy they use to succeed? How do they make predictions?", "words": [{"w": "13.", "b": [0.1434, 0.7482, 0.1682, 0.7696]}, {"w": "What", "b": [0.1786, 0.7482, 0.225, 0.7696]}, {"w": "do", "b": [0.23, 0.7482, 0.2516, 0.7696]}, {"w": "model-based", "b": [0.2566, 0.7482, 0.364, 0.7696]}, {"w": "learning", "b": [0.369, 0.7482, 0.4381, 0.7696]}, {"w": "algorithms", "b": [0.4431, 0.7482, 0.5334, 0.7696]}, {"w": "search", "b": [0.5383, 0.7482, 0.5917, 0.7696]}, {"w": "for?", "b": [0.5966, 0.7482, 0.629, 0.7696]}, {"w": "What", "b": [0.634, 0.7482, 0.6805, 0.7696]}, {"w": "is", "b": [0.6854, 0.7482, 0.6986, 0.7696]}, {"w": "the", "b": [0.7036, 0.7482, 0.7299, 0.7696]}, {"w": "most", "b": [0.7349, 0.7482, 0.7766, 0.7696]}, {"w": "common", "b": [0.7816, 0.7482, 0.8571, 0.7696]}, {"w": "strategy", "b": [0.1786, 0.7673, 0.2441, 0.7887]}, {"w": "they", "b": [0.2488, 0.7673, 0.2847, 0.7887]}, {"w": "use", "b": [0.2894, 0.7673, 0.317, 0.7887]}, {"w": "to", "b": [0.3217, 0.7673, 0.3387, 0.7887]}, {"w": "succeed?", "b": [0.3434, 0.7673, 0.4164, 0.7887]}, {"w": "How", "b": [0.4211, 0.7673, 0.4614, 0.7887]}, {"w": "do", "b": [0.4662, 0.7673, 0.4878, 0.7887]}, {"w": "they", "b": [0.4925, 0.7673, 0.5284, 0.7887]}, {"w": "make", "b": [0.5331, 0.7673, 0.5785, 0.7887]}, {"w": "predictions?", "b": [0.5833, 0.7673, 0.6857, 0.7887]}]}, {"id": "b_16", "type": "paragraph", "text": "14. Can you name four of the main challenges in Machine Learning?", "words": [{"w": "14.", "b": [0.1434, 0.7924, 0.1682, 0.8138]}, {"w": "Can", "b": [0.1786, 0.7924, 0.213, 0.8138]}, {"w": "you", "b": [0.2177, 0.7924, 0.2489, 0.8138]}, {"w": "name", "b": [0.2537, 0.7924, 0.3001, 0.8138]}, {"w": "four", "b": [0.3049, 0.7924, 0.3404, 0.8138]}, {"w": "of", "b": [0.3452, 0.7924, 0.362, 0.8138]}, {"w": "the", "b": [0.3667, 0.7924, 0.393, 0.8138]}, {"w": "main", "b": [0.3978, 0.7924, 0.4409, 0.8138]}, {"w": "challenges", "b": [0.4457, 0.7924, 0.5318, 0.8138]}, {"w": "in", "b": [0.5365, 0.7924, 0.5535, 0.8138]}, {"w": "Machine", "b": [0.5582, 0.7924, 0.6314, 0.8138]}, {"w": "Learning?", "b": [0.6361, 0.7924, 0.719, 0.8138]}]}, {"id": "b_17", "type": "paragraph", "text": "15. If your model performs great on the training data but generalizes poorly to new instances, what is happening? Can you name three possible solutions?", "words": [{"w": "15.", "b": [0.1434, 0.8175, 0.1682, 0.8389]}, {"w": "If", "b": [0.1786, 0.8175, 0.1918, 0.8389]}, {"w": "your", "b": [0.1979, 0.8175, 0.2369, 0.8389]}, {"w": "model", "b": [0.2429, 0.8175, 0.2957, 0.8389]}, {"w": "performs", "b": [0.3018, 0.8175, 0.3785, 0.8389]}, {"w": "great", "b": [0.3846, 0.8175, 0.426, 0.8389]}, {"w": "on", "b": [0.4321, 0.8175, 0.4541, 0.8389]}, {"w": "the", "b": [0.4602, 0.8175, 0.4865, 0.8389]}, {"w": "training", "b": [0.4925, 0.8175, 0.5595, 0.8389]}, {"w": "data", "b": [0.5655, 0.8175, 0.6008, 0.8389]}, {"w": "but", "b": [0.6068, 0.8175, 0.6348, 0.8389]}, {"w": "generalizes", "b": [0.6409, 0.8175, 0.7327, 0.8389]}, {"w": "poorly", "b": [0.7388, 0.8175, 0.7935, 0.8389]}, {"w": "to", "b": [0.7996, 0.8175, 0.8166, 0.8389]}, {"w": "new", "b": [0.8226, 0.8175, 0.8571, 0.8389]}, {"w": "instances,", "b": [0.1786, 0.8365, 0.2602, 0.8579]}, {"w": "what", "b": [0.2649, 0.8365, 0.3054, 0.8579]}, {"w": "is", "b": [0.3101, 0.8365, 0.3233, 0.8579]}, {"w": "happening?", "b": [0.3281, 0.8365, 0.4247, 0.8579]}, {"w": "Can", "b": [0.4294, 0.8365, 0.4638, 0.8579]}, {"w": "you", "b": [0.4685, 0.8365, 0.4998, 0.8579]}, {"w": "name", "b": [0.5045, 0.8365, 0.5509, 0.8579]}, {"w": "three", "b": [0.5557, 0.8365, 0.5986, 0.8579]}, {"w": "possible", "b": [0.6033, 0.8365, 0.6704, 0.8579]}, {"w": "solutions?", "b": [0.6752, 0.8365, 0.7593, 0.8579]}]}, {"id": "b_18", "type": "paragraph", "text": "16. What is a test set and why would you want to use it?", "words": [{"w": "16.", "b": [0.1434, 0.8616, 0.1682, 0.883]}, {"w": "What", "b": [0.1786, 0.8616, 0.225, 0.883]}, {"w": "is", "b": [0.2298, 0.8616, 0.243, 0.883]}, {"w": "a", "b": [0.2477, 0.8616, 0.2569, 0.883]}, {"w": "test", "b": [0.2616, 0.8616, 0.2908, 0.883]}, {"w": "set", "b": [0.2955, 0.8616, 0.3184, 0.883]}, {"w": "and", "b": [0.3231, 0.8616, 0.3546, 0.883]}, {"w": "why", "b": [0.3594, 0.8616, 0.3939, 0.883]}, {"w": "would", "b": [0.3986, 0.8616, 0.4508, 0.883]}, {"w": "you", "b": [0.4555, 0.8616, 0.4868, 0.883]}, {"w": "want", "b": [0.4915, 0.8616, 0.5323, 0.883]}, {"w": "to", "b": [0.537, 0.8616, 0.554, 0.883]}, {"w": "use", "b": [0.5587, 0.8616, 0.5863, 0.883]}, {"w": "it?", "b": [0.591, 0.8616, 0.6109, 0.883]}]}, {"id": "b_19", "type": "paragraph", "text": "34 | Chapter 1: The Machine Learning Landscape", "words": [{"w": "34", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "1:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "The", "b": [0.26, 0.9225, 0.2815, 0.9388]}, {"w": "Machine", "b": [0.2843, 0.9225, 0.3342, 0.9388]}, {"w": "Learning", "b": [0.3371, 0.9225, 0.3893, 0.9388]}, {"w": "Landscape", "b": [0.3921, 0.9225, 0.4538, 0.9388]}]}]}, {"page": 61, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "17. What is the purpose of a validation set?", "words": [{"w": "17.", "b": [0.1434, 0.0791, 0.1682, 0.1005]}, {"w": "What", "b": [0.1786, 0.0791, 0.225, 0.1005]}, {"w": "is", "b": [0.2298, 0.0791, 0.243, 0.1005]}, {"w": "the", "b": [0.2477, 0.0791, 0.274, 0.1005]}, {"w": "purpose", "b": [0.2788, 0.0791, 0.3465, 0.1005]}, {"w": "of", "b": [0.3513, 0.0791, 0.368, 0.1005]}, {"w": "a", "b": [0.3728, 0.0791, 0.3819, 0.1005]}, {"w": "validation", "b": [0.3866, 0.0791, 0.47, 0.1005]}, {"w": "set?", "b": [0.4747, 0.0791, 0.5055, 0.1005]}]}, {"id": "b_1", "type": "paragraph", "text": "18. What can go wrong if you tune hyperparameters using the test set?", "words": [{"w": "18.", "b": [0.1434, 0.1042, 0.1682, 0.1256]}, {"w": "What", "b": [0.1786, 0.1042, 0.225, 0.1256]}, {"w": "can", "b": [0.2298, 0.1042, 0.2591, 0.1256]}, {"w": "go", "b": [0.2638, 0.1042, 0.2842, 0.1256]}, {"w": "wrong", "b": [0.2889, 0.1042, 0.3427, 0.1256]}, {"w": "if", "b": [0.3474, 0.1042, 0.3592, 0.1256]}, {"w": "you", "b": [0.3639, 0.1042, 0.3952, 0.1256]}, {"w": "tune", "b": [0.3999, 0.1042, 0.4376, 0.1256]}, {"w": "hyperparameters", "b": [0.4423, 0.1042, 0.5834, 0.1256]}, {"w": "using", "b": [0.5882, 0.1042, 0.6336, 0.1256]}, {"w": "the", "b": [0.6383, 0.1042, 0.6647, 0.1256]}, {"w": "test", "b": [0.6694, 0.1042, 0.6986, 0.1256]}, {"w": "set?", "b": [0.7033, 0.1042, 0.7341, 0.1256]}]}, {"id": "b_2", "type": "paragraph", "text": "19. What is repeated cross-validation and why would you prefer it to using a single validation set?", "words": [{"w": "19.", "b": [0.1434, 0.1293, 0.1682, 0.1507]}, {"w": "What", "b": [0.1786, 0.1293, 0.225, 0.1507]}, {"w": "is", "b": [0.2314, 0.1293, 0.2446, 0.1507]}, {"w": "repeated", "b": [0.251, 0.1293, 0.3223, 0.1507]}, {"w": "cross-validation", "b": [0.3286, 0.1293, 0.4619, 0.1507]}, {"w": "and", "b": [0.4682, 0.1293, 0.4997, 0.1507]}, {"w": "why", "b": [0.5061, 0.1293, 0.5406, 0.1507]}, {"w": "would", "b": [0.5469, 0.1293, 0.5992, 0.1507]}, {"w": "you", "b": [0.6055, 0.1293, 0.6368, 0.1507]}, {"w": "prefer", "b": [0.6431, 0.1293, 0.6934, 0.1507]}, {"w": "it", "b": [0.6997, 0.1293, 0.7117, 0.1507]}, {"w": "to", "b": [0.718, 0.1293, 0.735, 0.1507]}, {"w": "using", "b": [0.7413, 0.1293, 0.7868, 0.1507]}, {"w": "a", "b": [0.7931, 0.1293, 0.8023, 0.1507]}, {"w": "single", "b": [0.8086, 0.1293, 0.8571, 0.1507]}, {"w": "validation", "b": [0.1786, 0.1483, 0.2619, 0.1697]}, {"w": "set?", "b": [0.2667, 0.1483, 0.2974, 0.1697]}]}, {"id": "b_3", "type": "paragraph", "text": "Solutions to these exercises are available in ???.", "words": [{"w": "Solutions", "b": [0.1429, 0.1825, 0.2213, 0.2039]}, {"w": "to", "b": [0.226, 0.1825, 0.243, 0.2039]}, {"w": "these", "b": [0.2477, 0.1825, 0.2906, 0.2039]}, {"w": "exercises", "b": [0.2953, 0.1825, 0.3691, 0.2039]}, {"w": "are", "b": [0.3738, 0.1825, 0.3996, 0.2039]}, {"w": "available", "b": [0.4043, 0.1825, 0.4766, 0.2039]}, {"w": "in", "b": [0.4813, 0.1825, 0.4983, 0.2039]}, {"w": "???.", "b": [0.503, 0.1825, 0.5314, 0.2039]}]}, {"id": "b_4", "type": "paragraph", "text": "Exercises | 35", "words": [{"w": "Exercises", "b": [0.7506, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "35", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 62, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": []}, {"page": 63, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 The example project is completely fictitious; the goal is just to illustrate the main steps of a Machine Learning project, not to learn anything about the real estate business.", "words": [{"w": "1", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "The", "b": [0.1587, 0.8598, 0.1837, 0.8761]}, {"w": "example", "b": [0.1873, 0.8598, 0.2403, 0.8761]}, {"w": "project", "b": [0.2439, 0.8598, 0.2886, 0.8761]}, {"w": "is", "b": [0.2922, 0.8598, 0.3023, 0.8761]}, {"w": "completely", "b": [0.3059, 0.8598, 0.3754, 0.8761]}, {"w": "fictitious;", "b": [0.379, 0.8598, 0.4388, 0.8761]}, {"w": "the", "b": [0.4424, 0.8598, 0.4625, 0.8761]}, {"w": "goal", "b": [0.4661, 0.8598, 0.4926, 0.8761]}, {"w": "is", "b": [0.4962, 0.8598, 0.5063, 0.8761]}, {"w": "just", "b": [0.5099, 0.8598, 0.533, 0.8761]}, {"w": "to", "b": [0.5366, 0.8598, 0.5496, 0.8761]}, {"w": "illustrate", "b": [0.5532, 0.8598, 0.6087, 0.8761]}, {"w": "the", "b": [0.6123, 0.8598, 0.6323, 0.8761]}, {"w": "main", "b": [0.636, 0.8598, 0.6689, 0.8761]}, {"w": "steps", "b": [0.6725, 0.8598, 0.704, 0.8761]}, {"w": "of", "b": [0.7076, 0.8598, 0.7204, 0.8761]}, {"w": "a", "b": [0.724, 0.8598, 0.731, 0.8761]}, {"w": "Machine", "b": [0.7346, 0.8598, 0.7903, 0.8761]}, {"w": "Learning", "b": [0.7939, 0.8598, 0.8511, 0.8761]}, {"w": "project,", "b": [0.1587, 0.8749, 0.207, 0.8912]}, {"w": "not", "b": [0.2106, 0.8749, 0.2322, 0.8912]}, {"w": "to", "b": [0.2358, 0.8749, 0.2488, 0.8912]}, {"w": "learn", "b": [0.2524, 0.8749, 0.2847, 0.8912]}, {"w": "anything", "b": [0.2883, 0.8749, 0.3445, 0.8912]}, {"w": "about", "b": [0.3481, 0.8749, 0.3845, 0.8912]}, {"w": "the", "b": [0.3881, 0.8749, 0.4082, 0.8912]}, {"w": "real", "b": [0.4118, 0.8749, 0.4354, 0.8912]}, {"w": "estate", "b": [0.439, 0.8749, 0.4747, 0.8912]}, {"w": "business.", "b": [0.4783, 0.8749, 0.5356, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "CHAPTER 2 End-to-End Machine Learning Project", "words": [{"w": "CHAPTER", "b": [0.7398, 0.1146, 0.8383, 0.1451]}, {"w": "2", "b": [0.8435, 0.1146, 0.8572, 0.1451]}, {"w": "End-to-End", "b": [0.2461, 0.1478, 0.4313, 0.1935]}, {"w": "Machine", "b": [0.4392, 0.1478, 0.5791, 0.1935]}, {"w": "Learning", "b": [0.587, 0.1478, 0.7334, 0.1935]}, {"w": "Project", "b": [0.7413, 0.1478, 0.8572, 0.1935]}]}, {"id": "b_2", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 2 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.3643, 0.3102, 0.3839]}, {"w": "Early", "b": [0.3165, 0.3643, 0.3563, 0.3839]}, {"w": "Release", "b": [0.3626, 0.3643, 0.4189, 0.3839]}, {"w": "ebooks,", "b": [0.4251, 0.3643, 0.4831, 0.3839]}, {"w": "you", "b": [0.4894, 0.3643, 0.518, 0.3839]}, {"w": "get", "b": [0.5242, 0.3643, 0.5471, 0.3839]}, {"w": "books", "b": [0.5533, 0.3643, 0.5989, 0.3839]}, {"w": "in", "b": [0.6052, 0.3643, 0.6207, 0.3839]}, {"w": "their", "b": [0.627, 0.3643, 0.6632, 0.3839]}, {"w": "earliest", "b": [0.6695, 0.3643, 0.7238, 0.3839]}, {"w": "form—", "b": [0.7301, 0.3643, 0.7857, 0.3839]}, {"w": "the", "b": [0.2714, 0.3818, 0.2955, 0.4013]}, {"w": "author’s", "b": [0.3012, 0.3818, 0.3615, 0.4013]}, {"w": "raw", "b": [0.3672, 0.3818, 0.3954, 0.4013]}, {"w": "and", "b": [0.4011, 0.3818, 0.4299, 0.4013]}, {"w": "unedited", "b": [0.4357, 0.3818, 0.5034, 0.4013]}, {"w": "content", "b": [0.5091, 0.3818, 0.5667, 0.4013]}, {"w": "as", "b": [0.5725, 0.3818, 0.5878, 0.4013]}, {"w": "he", "b": [0.5935, 0.3818, 0.6118, 0.4013]}, {"w": "or", "b": [0.6175, 0.3818, 0.6343, 0.4013]}, {"w": "she", "b": [0.64, 0.3818, 0.6653, 0.4013]}, {"w": "writes—so", "b": [0.671, 0.3818, 0.7514, 0.4013]}, {"w": "you", "b": [0.7571, 0.3818, 0.7857, 0.4013]}, {"w": "can", "b": [0.2714, 0.3992, 0.2982, 0.4188]}, {"w": "take", "b": [0.306, 0.3992, 0.3377, 0.4188]}, {"w": "advantage", "b": [0.3455, 0.3992, 0.4223, 0.4188]}, {"w": "of", "b": [0.4301, 0.3992, 0.4454, 0.4188]}, {"w": "these", "b": [0.4532, 0.3992, 0.4923, 0.4188]}, {"w": "technologies", "b": [0.5001, 0.3992, 0.596, 0.4188]}, {"w": "long", "b": [0.6038, 0.3992, 0.6376, 0.4188]}, {"w": "before", "b": [0.6454, 0.3992, 0.6937, 0.4188]}, {"w": "the", "b": [0.7014, 0.3992, 0.7255, 0.4188]}, {"w": "official", "b": [0.7333, 0.3992, 0.7857, 0.4188]}, {"w": "release", "b": [0.2714, 0.4166, 0.3229, 0.4362]}, {"w": "of", "b": [0.3291, 0.4166, 0.3445, 0.4362]}, {"w": "these", "b": [0.3507, 0.4166, 0.3899, 0.4362]}, {"w": "titles.", "b": [0.3961, 0.4166, 0.4371, 0.4362]}, {"w": "The", "b": [0.4433, 0.4166, 0.4733, 0.4362]}, {"w": "following", "b": [0.4795, 0.4166, 0.5517, 0.4362]}, {"w": "will", "b": [0.5579, 0.4166, 0.5857, 0.4362]}, {"w": "be", "b": [0.592, 0.4166, 0.6097, 0.4362]}, {"w": "Chapter", "b": [0.616, 0.4166, 0.6777, 0.4362]}, {"w": "2", "b": [0.684, 0.4166, 0.6931, 0.4362]}, {"w": "in", "b": [0.6993, 0.4166, 0.7148, 0.4362]}, {"w": "the", "b": [0.7211, 0.4166, 0.7451, 0.4362]}, {"w": "final", "b": [0.7514, 0.4166, 0.7857, 0.4362]}, {"w": "release", "b": [0.2714, 0.434, 0.3229, 0.4536]}, {"w": "of", "b": [0.3273, 0.434, 0.3426, 0.4536]}, {"w": "the", "b": [0.3469, 0.434, 0.371, 0.4536]}, {"w": "book.", "b": [0.3753, 0.434, 0.4182, 0.4536]}]}, {"id": "b_3", "type": "paragraph", "text": "In this chapter, you will go through an example project end to end, pretending to be a recently hired data scientist in a real estate company.1 Here are the main steps you will go through:", "words": [{"w": "In", "b": [0.1428, 0.4739, 0.1613, 0.4953]}, {"w": "this", "b": [0.1663, 0.4739, 0.197, 0.4953]}, {"w": "chapter,", "b": [0.2019, 0.4739, 0.2679, 0.4953]}, {"w": "you", "b": [0.2728, 0.4739, 0.3041, 0.4953]}, {"w": "will", "b": [0.309, 0.4739, 0.3394, 0.4953]}, {"w": "go", "b": [0.3444, 0.4739, 0.3647, 0.4953]}, {"w": "through", "b": [0.3697, 0.4739, 0.4374, 0.4953]}, {"w": "an", "b": [0.4424, 0.4739, 0.4629, 0.4953]}, {"w": "example", "b": [0.4679, 0.4739, 0.5374, 0.4953]}, {"w": "project", "b": [0.5423, 0.4739, 0.601, 0.4953]}, {"w": "end", "b": [0.6059, 0.4739, 0.6371, 0.4953]}, {"w": "to", "b": [0.6421, 0.4739, 0.6591, 0.4953]}, {"w": "end,", "b": [0.664, 0.4739, 0.7, 0.4953]}, {"w": "pretending", "b": [0.7049, 0.4739, 0.7968, 0.4953]}, {"w": "to", "b": [0.8017, 0.4739, 0.8187, 0.4953]}, {"w": "be", "b": [0.8236, 0.4739, 0.8431, 0.4953]}, {"w": "a", "b": [0.848, 0.4739, 0.8571, 0.4953]}, {"w": "recently", "b": [0.1429, 0.4929, 0.2093, 0.5143]}, {"w": "hired", "b": [0.214, 0.4929, 0.2583, 0.5143]}, {"w": "data", "b": [0.2631, 0.4929, 0.2983, 0.5143]}, {"w": "scientist", "b": [0.303, 0.4929, 0.3709, 0.5143]}, {"w": "in", "b": [0.3756, 0.4929, 0.3926, 0.5143]}, {"w": "a", "b": [0.3973, 0.4929, 0.4064, 0.5143]}, {"w": "real", "b": [0.4112, 0.4929, 0.4422, 0.5143]}, {"w": "estate", "b": [0.4469, 0.4929, 0.4937, 0.5143]}, {"w": "company.1", "b": [0.4984, 0.4929, 0.5845, 0.5143]}, {"w": "Here", "b": [0.5893, 0.4929, 0.6301, 0.5143]}, {"w": "are", "b": [0.6349, 0.4929, 0.6606, 0.5143]}, {"w": "the", "b": [0.6653, 0.4929, 0.6917, 0.5143]}, {"w": "main", "b": [0.6964, 0.4929, 0.7396, 0.5143]}, {"w": "steps", "b": [0.7443, 0.4929, 0.7857, 0.5143]}, {"w": "you", "b": [0.7904, 0.4929, 0.8217, 0.5143]}, {"w": "will", "b": [0.8264, 0.4929, 0.8568, 0.5143]}, {"w": "go", "b": [0.1429, 0.512, 0.1632, 0.5334]}, {"w": "through:", "b": [0.168, 0.512, 0.2405, 0.5334]}]}, {"id": "b_4", "type": "paragraph", "text": "1. Look at the big picture.", "words": [{"w": "1.", "b": [0.1534, 0.5461, 0.1682, 0.5675]}, {"w": "Look", "b": [0.1786, 0.5461, 0.2214, 0.5675]}, {"w": "at", "b": [0.2261, 0.5461, 0.2412, 0.5675]}, {"w": "the", "b": [0.2459, 0.5461, 0.2723, 0.5675]}, {"w": "big", "b": [0.277, 0.5461, 0.3029, 0.5675]}, {"w": "picture.", "b": [0.3076, 0.5461, 0.3717, 0.5675]}]}, {"id": "b_5", "type": "paragraph", "text": "2. Get the data.", "words": [{"w": "2.", "b": [0.1534, 0.5712, 0.1682, 0.5926]}, {"w": "Get", "b": [0.1786, 0.5712, 0.2087, 0.5926]}, {"w": "the", "b": [0.2134, 0.5712, 0.2397, 0.5926]}, {"w": "data.", "b": [0.2445, 0.5712, 0.2845, 0.5926]}]}, {"id": "b_6", "type": "paragraph", "text": "3. Discover and visualize the data to gain insights.", "words": [{"w": "3.", "b": [0.1534, 0.5963, 0.1682, 0.6177]}, {"w": "Discover", "b": [0.1786, 0.5963, 0.2528, 0.6177]}, {"w": "and", "b": [0.2575, 0.5963, 0.289, 0.6177]}, {"w": "visualize", "b": [0.2938, 0.5963, 0.3653, 0.6177]}, {"w": "the", "b": [0.37, 0.5963, 0.3964, 0.6177]}, {"w": "data", "b": [0.4011, 0.5963, 0.4364, 0.6177]}, {"w": "to", "b": [0.4411, 0.5963, 0.4581, 0.6177]}, {"w": "gain", "b": [0.4628, 0.5963, 0.4987, 0.6177]}, {"w": "insights.", "b": [0.5034, 0.5963, 0.5728, 0.6177]}]}, {"id": "b_7", "type": "paragraph", "text": "4. Prepare the data for Machine Learning algorithms.", "words": [{"w": "4.", "b": [0.1534, 0.6214, 0.1682, 0.6428]}, {"w": "Prepare", "b": [0.1786, 0.6214, 0.2435, 0.6428]}, {"w": "the", "b": [0.2483, 0.6214, 0.2746, 0.6428]}, {"w": "data", "b": [0.2793, 0.6214, 0.3146, 0.6428]}, {"w": "for", "b": [0.3193, 0.6214, 0.3438, 0.6428]}, {"w": "Machine", "b": [0.3485, 0.6214, 0.4217, 0.6428]}, {"w": "Learning", "b": [0.4264, 0.6214, 0.5015, 0.6428]}, {"w": "algorithms.", "b": [0.5062, 0.6214, 0.6012, 0.6428]}]}, {"id": "b_8", "type": "paragraph", "text": "5. Select a model and train it.", "words": [{"w": "5.", "b": [0.1534, 0.6465, 0.1682, 0.6679]}, {"w": "Select", "b": [0.1786, 0.6465, 0.2266, 0.6679]}, {"w": "a", "b": [0.2313, 0.6465, 0.2405, 0.6679]}, {"w": "model", "b": [0.2452, 0.6465, 0.298, 0.6679]}, {"w": "and", "b": [0.3027, 0.6465, 0.3343, 0.6679]}, {"w": "train", "b": [0.339, 0.6465, 0.3792, 0.6679]}, {"w": "it.", "b": [0.3839, 0.6465, 0.4006, 0.6679]}]}, {"id": "b_9", "type": "equation", "text": "6. Fine-tune your model.", "words": [{"w": "6.", "b": [0.1534, 0.6716, 0.1682, 0.693]}, {"w": "Fine-tune", "b": [0.1786, 0.6716, 0.2605, 0.693]}, {"w": "your", "b": [0.2652, 0.6716, 0.3042, 0.693]}, {"w": "model.", "b": [0.3089, 0.6716, 0.3665, 0.693]}]}, {"id": "b_10", "type": "paragraph", "text": "7. Present your solution.", "words": [{"w": "7.", "b": [0.1534, 0.6967, 0.1682, 0.7181]}, {"w": "Present", "b": [0.1786, 0.6967, 0.2407, 0.7181]}, {"w": "your", "b": [0.2455, 0.6967, 0.2844, 0.7181]}, {"w": "solution.", "b": [0.2892, 0.6967, 0.3625, 0.7181]}]}, {"id": "b_11", "type": "paragraph", "text": "8. Launch, monitor, and maintain your system.", "words": [{"w": "8.", "b": [0.1534, 0.7218, 0.1682, 0.7432]}, {"w": "Launch,", "b": [0.1786, 0.7218, 0.2457, 0.7432]}, {"w": "monitor,", "b": [0.2504, 0.7218, 0.3232, 0.7432]}, {"w": "and", "b": [0.3279, 0.7218, 0.3595, 0.7432]}, {"w": "maintain", "b": [0.3642, 0.7218, 0.4395, 0.7432]}, {"w": "your", "b": [0.4442, 0.7218, 0.4832, 0.7432]}, {"w": "system.", "b": [0.4879, 0.7218, 0.5498, 0.7432]}]}]}, {"page": 64, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "2 The original dataset appeared in R. Kelley Pace and Ronald Barry, “Sparse Spatial Autoregressions,” Statistics & Probability Letters 33, no. 3 (1997): 291–297.", "words": [{"w": "2", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "The", "b": [0.1587, 0.8598, 0.1837, 0.8761]}, {"w": "original", "b": [0.1873, 0.8598, 0.2369, 0.8761]}, {"w": "dataset", "b": [0.2405, 0.8598, 0.2848, 0.8761]}, {"w": "appeared", "b": [0.2884, 0.8598, 0.3464, 0.8761]}, {"w": "in", "b": [0.35, 0.8598, 0.363, 0.8761]}, {"w": "R.", "b": [0.3666, 0.8598, 0.3801, 0.8761]}, {"w": "Kelley", "b": [0.3837, 0.8598, 0.4228, 0.8761]}, {"w": "Pace", "b": [0.4264, 0.8598, 0.4554, 0.8761]}, {"w": "and", "b": [0.459, 0.8598, 0.483, 0.8761]}, {"w": "Ronald", "b": [0.4866, 0.8598, 0.5326, 0.8761]}, {"w": "Barry,", "b": [0.5362, 0.8598, 0.5745, 0.8761]}, {"w": "“Sparse", "b": [0.5781, 0.8598, 0.6253, 0.8761]}, {"w": "Spatial", "b": [0.6289, 0.8598, 0.6715, 0.8761]}, {"w": "Autoregressions,”", "b": [0.6751, 0.8598, 0.7858, 0.8761]}, {"w": "Statistics", "b": [0.7894, 0.8596, 0.8435, 0.8761]}, {"w": "&", "b": [0.1587, 0.8748, 0.1708, 0.8912]}, {"w": "Probability", "b": [0.1745, 0.8748, 0.2426, 0.8912]}, {"w": "Letters", "b": [0.2462, 0.8748, 0.288, 0.8912]}, {"w": "33,", "b": [0.2916, 0.8749, 0.3105, 0.8912]}, {"w": "no.", "b": [0.3141, 0.8749, 0.334, 0.8912]}, {"w": "3", "b": [0.3376, 0.8749, 0.3452, 0.8912]}, {"w": "(1997):", "b": [0.3488, 0.8749, 0.3939, 0.8912]}, {"w": "291–297.", "b": [0.3975, 0.8749, 0.4551, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Working with Real Data", "words": [{"w": "Working", "b": [0.1428, 0.0753, 0.248, 0.1095]}, {"w": "with", "b": [0.2539, 0.0753, 0.3109, 0.1095]}, {"w": "Real", "b": [0.3169, 0.0753, 0.371, 0.1095]}, {"w": "Data", "b": [0.377, 0.0753, 0.4351, 0.1095]}]}, {"id": "b_2", "type": "paragraph", "text": "When you are learning about Machine Learning it is best to actually experiment with real-world data, not just artificial datasets. Fortunately, there are thousands of open datasets to choose from, ranging across all sorts of domains. Here are a few places you can look to get data:", "words": [{"w": "When", "b": [0.1429, 0.1164, 0.1945, 0.1378]}, {"w": "you", "b": [0.1997, 0.1164, 0.2309, 0.1378]}, {"w": "are", "b": [0.2362, 0.1164, 0.2619, 0.1378]}, {"w": "learning", "b": [0.2671, 0.1164, 0.3363, 0.1378]}, {"w": "about", "b": [0.3415, 0.1164, 0.3893, 0.1378]}, {"w": "Machine", "b": [0.3945, 0.1164, 0.4676, 0.1378]}, {"w": "Learning", "b": [0.4729, 0.1164, 0.5479, 0.1378]}, {"w": "it", "b": [0.5532, 0.1164, 0.5651, 0.1378]}, {"w": "is", "b": [0.5703, 0.1164, 0.5836, 0.1378]}, {"w": "best", "b": [0.5888, 0.1164, 0.6222, 0.1378]}, {"w": "to", "b": [0.6275, 0.1164, 0.6444, 0.1378]}, {"w": "actually", "b": [0.6497, 0.1164, 0.7143, 0.1378]}, {"w": "experiment", "b": [0.7195, 0.1164, 0.8146, 0.1378]}, {"w": "with", "b": [0.8198, 0.1164, 0.8571, 0.1378]}, {"w": "real-world", "b": [0.1428, 0.1355, 0.2302, 0.1569]}, {"w": "data,", "b": [0.237, 0.1355, 0.277, 0.1569]}, {"w": "not", "b": [0.2838, 0.1355, 0.3122, 0.1569]}, {"w": "just", "b": [0.3191, 0.1355, 0.3495, 0.1569]}, {"w": "artificial", "b": [0.3563, 0.1355, 0.4257, 0.1569]}, {"w": "datasets.", "b": [0.4325, 0.1355, 0.503, 0.1569]}, {"w": "Fortunately,", "b": [0.5099, 0.1355, 0.6097, 0.1569]}, {"w": "there", "b": [0.6165, 0.1355, 0.6594, 0.1569]}, {"w": "are", "b": [0.6663, 0.1355, 0.692, 0.1569]}, {"w": "thousands", "b": [0.6989, 0.1355, 0.7849, 0.1569]}, {"w": "of", "b": [0.7917, 0.1355, 0.8085, 0.1569]}, {"w": "open", "b": [0.8153, 0.1355, 0.8571, 0.1569]}, {"w": "datasets", "b": [0.1429, 0.1545, 0.2086, 0.1759]}, {"w": "to", "b": [0.2159, 0.1545, 0.2329, 0.1759]}, {"w": "choose", "b": [0.2401, 0.1545, 0.2978, 0.1759]}, {"w": "from,", "b": [0.3051, 0.1545, 0.3514, 0.1759]}, {"w": "ranging", "b": [0.3587, 0.1545, 0.4234, 0.1759]}, {"w": "across", "b": [0.4307, 0.1545, 0.4823, 0.1759]}, {"w": "all", "b": [0.4896, 0.1545, 0.5093, 0.1759]}, {"w": "sorts", "b": [0.5166, 0.1545, 0.5566, 0.1759]}, {"w": "of", "b": [0.5638, 0.1545, 0.5806, 0.1759]}, {"w": "domains.", "b": [0.5879, 0.1545, 0.6651, 0.1759]}, {"w": "Here", "b": [0.6724, 0.1545, 0.7132, 0.1759]}, {"w": "are", "b": [0.7205, 0.1545, 0.7462, 0.1759]}, {"w": "a", "b": [0.7535, 0.1545, 0.7627, 0.1759]}, {"w": "few", "b": [0.7699, 0.1545, 0.7992, 0.1759]}, {"w": "places", "b": [0.8065, 0.1545, 0.8571, 0.1759]}, {"w": "you", "b": [0.1429, 0.1736, 0.1741, 0.195]}, {"w": "can", "b": [0.1788, 0.1736, 0.2082, 0.195]}, {"w": "look", "b": [0.2129, 0.1736, 0.2498, 0.195]}, {"w": "to", "b": [0.2545, 0.1736, 0.2715, 0.195]}, {"w": "get", "b": [0.2762, 0.1736, 0.3012, 0.195]}, {"w": "data:", "b": [0.3059, 0.1736, 0.3459, 0.195]}]}, {"id": "b_3", "type": "paragraph", "text": "• Popular open data repositories:", "words": [{"w": "•", "b": [0.16, 0.2077, 0.1682, 0.2292]}, {"w": "Popular", "b": [0.1786, 0.2077, 0.2444, 0.2292]}, {"w": "open", "b": [0.2491, 0.2077, 0.2909, 0.2292]}, {"w": "data", "b": [0.2956, 0.2077, 0.3309, 0.2292]}, {"w": "repositories:", "b": [0.3356, 0.2077, 0.4385, 0.2292]}]}, {"id": "b_4", "type": "paragraph", "text": "— UC Irvine Machine Learning Repository", "words": [{"w": "—", "b": [0.1807, 0.2328, 0.1999, 0.2543]}, {"w": "UC", "b": [0.2044, 0.2328, 0.2335, 0.2543]}, {"w": "Irvine", "b": [0.2383, 0.2328, 0.2892, 0.2543]}, {"w": "Machine", "b": [0.2939, 0.2328, 0.367, 0.2543]}, {"w": "Learning", "b": [0.3718, 0.2328, 0.4468, 0.2543]}, {"w": "Repository", "b": [0.4516, 0.2328, 0.543, 0.2543]}]}, {"id": "b_5", "type": "paragraph", "text": "— Kaggle datasets", "words": [{"w": "—", "b": [0.1807, 0.2579, 0.1999, 0.2793]}, {"w": "Kaggle", "b": [0.2044, 0.2579, 0.2611, 0.2793]}, {"w": "datasets", "b": [0.2659, 0.2579, 0.3316, 0.2793]}]}, {"id": "b_6", "type": "paragraph", "text": "— Amazon’s AWS datasets", "words": [{"w": "—", "b": [0.1807, 0.283, 0.1999, 0.3044]}, {"w": "Amazon’s", "b": [0.2044, 0.283, 0.2843, 0.3044]}, {"w": "AWS", "b": [0.2891, 0.283, 0.3309, 0.3044]}, {"w": "datasets", "b": [0.3356, 0.283, 0.4013, 0.3044]}]}, {"id": "b_7", "type": "paragraph", "text": "• Meta portals (they list open data repositories):", "words": [{"w": "•", "b": [0.16, 0.3081, 0.1682, 0.3295]}, {"w": "Meta", "b": [0.1786, 0.3081, 0.2209, 0.3295]}, {"w": "portals", "b": [0.2257, 0.3081, 0.2834, 0.3295]}, {"w": "(they", "b": [0.2881, 0.3081, 0.3312, 0.3295]}, {"w": "list", "b": [0.3359, 0.3081, 0.3608, 0.3295]}, {"w": "open", "b": [0.3655, 0.3081, 0.4073, 0.3295]}, {"w": "data", "b": [0.412, 0.3081, 0.4473, 0.3295]}, {"w": "repositories):", "b": [0.452, 0.3081, 0.5621, 0.3295]}]}, {"id": "b_8", "type": "equation", "text": "— http://dataportals.org/", "words": [{"w": "—", "b": [0.1807, 0.3332, 0.1999, 0.3546]}, {"w": "http://dataportals.org/", "b": [0.2044, 0.333, 0.3857, 0.3546]}]}, {"id": "b_9", "type": "equation", "text": "— http://opendatamonitor.eu/", "words": [{"w": "—", "b": [0.1807, 0.3583, 0.1999, 0.3797]}, {"w": "http://opendatamonitor.eu/", "b": [0.2044, 0.3581, 0.4259, 0.3797]}]}, {"id": "b_10", "type": "equation", "text": "— http://quandl.com/", "words": [{"w": "—", "b": [0.1807, 0.3834, 0.1999, 0.4048]}, {"w": "http://quandl.com/", "b": [0.2044, 0.3832, 0.3584, 0.4048]}]}, {"id": "b_11", "type": "paragraph", "text": "• Other pages listing many popular open data repositories:", "words": [{"w": "•", "b": [0.16, 0.4085, 0.1682, 0.4299]}, {"w": "Other", "b": [0.1786, 0.4085, 0.2282, 0.4299]}, {"w": "pages", "b": [0.2329, 0.4085, 0.2792, 0.4299]}, {"w": "listing", "b": [0.284, 0.4085, 0.3355, 0.4299]}, {"w": "many", "b": [0.3403, 0.4085, 0.387, 0.4299]}, {"w": "popular", "b": [0.3917, 0.4085, 0.4574, 0.4299]}, {"w": "open", "b": [0.4621, 0.4085, 0.5039, 0.4299]}, {"w": "data", "b": [0.5086, 0.4085, 0.5439, 0.4299]}, {"w": "repositories:", "b": [0.5486, 0.4085, 0.6515, 0.4299]}]}, {"id": "b_12", "type": "paragraph", "text": "— Wikipedia’s list of Machine Learning datasets", "words": [{"w": "—", "b": [0.1807, 0.4336, 0.1999, 0.455]}, {"w": "Wikipedia’s", "b": [0.2044, 0.4336, 0.2994, 0.455]}, {"w": "list", "b": [0.3041, 0.4336, 0.329, 0.455]}, {"w": "of", "b": [0.3337, 0.4336, 0.3505, 0.455]}, {"w": "Machine", "b": [0.3552, 0.4336, 0.4284, 0.455]}, {"w": "Learning", "b": [0.4331, 0.4336, 0.5081, 0.455]}, {"w": "datasets", "b": [0.5129, 0.4336, 0.5786, 0.455]}]}, {"id": "b_13", "type": "paragraph", "text": "— Quora.com question", "words": [{"w": "—", "b": [0.1807, 0.4587, 0.1999, 0.4801]}, {"w": "Quora.com", "b": [0.2044, 0.4587, 0.2997, 0.4801]}, {"w": "question", "b": [0.3044, 0.4587, 0.3766, 0.4801]}]}, {"id": "b_14", "type": "paragraph", "text": "— Datasets subreddit", "words": [{"w": "—", "b": [0.1807, 0.4838, 0.1999, 0.5052]}, {"w": "Datasets", "b": [0.2044, 0.4838, 0.2744, 0.5052]}, {"w": "subreddit", "b": [0.2791, 0.4838, 0.359, 0.5052]}]}, {"id": "b_15", "type": "paragraph", "text": "In this chapter we chose the California Housing Prices dataset from the StatLib repos‐ itory2 (see Figure 2-1). This dataset was based on data from the 1990 California cen‐ sus. It is not exactly recent (you could still afford a nice house in the Bay Area at the time), but it has many qualities for learning, so we will pretend it is recent data. We also added a categorical attribute and removed a few features for teaching purposes.", "words": [{"w": "In", "b": [0.1429, 0.5179, 0.1614, 0.5394]}, {"w": "this", "b": [0.1661, 0.5179, 0.1968, 0.5394]}, {"w": "chapter", "b": [0.2015, 0.5179, 0.2641, 0.5394]}, {"w": "we", "b": [0.2688, 0.5179, 0.2919, 0.5394]}, {"w": "chose", "b": [0.2966, 0.5179, 0.3437, 0.5394]}, {"w": "the", "b": [0.3484, 0.5179, 0.3748, 0.5394]}, {"w": "California", "b": [0.3795, 0.5179, 0.464, 0.5394]}, {"w": "Housing", "b": [0.4687, 0.5179, 0.5402, 0.5394]}, {"w": "Prices", "b": [0.545, 0.5179, 0.5953, 0.5394]}, {"w": "dataset", "b": [0.6, 0.5179, 0.6581, 0.5394]}, {"w": "from", "b": [0.6629, 0.5179, 0.7045, 0.5394]}, {"w": "the", "b": [0.7092, 0.5179, 0.7355, 0.5394]}, {"w": "StatLib", "b": [0.7403, 0.5179, 0.799, 0.5394]}, {"w": "repos‐", "b": [0.8037, 0.5179, 0.8569, 0.5394]}, {"w": "itory2", "b": [0.1429, 0.537, 0.189, 0.5584]}, {"w": "(see", "b": [0.1949, 0.537, 0.2275, 0.5584]}, {"w": "Figure", "b": [0.2334, 0.537, 0.2874, 0.5584]}, {"w": "2-1).", "b": [0.2933, 0.537, 0.3326, 0.5584]}, {"w": "This", "b": [0.3385, 0.537, 0.3757, 0.5584]}, {"w": "dataset", "b": [0.3816, 0.537, 0.4397, 0.5584]}, {"w": "was", "b": [0.4456, 0.537, 0.4767, 0.5584]}, {"w": "based", "b": [0.4825, 0.537, 0.5298, 0.5584]}, {"w": "on", "b": [0.5357, 0.537, 0.5577, 0.5584]}, {"w": "data", "b": [0.5636, 0.537, 0.5988, 0.5584]}, {"w": "from", "b": [0.6047, 0.537, 0.6463, 0.5584]}, {"w": "the", "b": [0.6522, 0.537, 0.6785, 0.5584]}, {"w": "1990", "b": [0.6844, 0.537, 0.7244, 0.5584]}, {"w": "California", "b": [0.7303, 0.537, 0.8148, 0.5584]}, {"w": "cen‐", "b": [0.8207, 0.537, 0.8571, 0.5584]}, {"w": "sus.", "b": [0.1429, 0.556, 0.174, 0.5775]}, {"w": "It", "b": [0.1798, 0.556, 0.1924, 0.5775]}, {"w": "is", "b": [0.1982, 0.556, 0.2115, 0.5775]}, {"w": "not", "b": [0.2173, 0.556, 0.2457, 0.5775]}, {"w": "exactly", "b": [0.2515, 0.556, 0.3093, 0.5775]}, {"w": "recent", "b": [0.3151, 0.556, 0.3667, 0.5775]}, {"w": "(you", "b": [0.3726, 0.556, 0.411, 0.5775]}, {"w": "could", "b": [0.4168, 0.556, 0.4636, 0.5775]}, {"w": "still", "b": [0.4694, 0.556, 0.4995, 0.5775]}, {"w": "afford", "b": [0.5054, 0.556, 0.5562, 0.5775]}, {"w": "a", "b": [0.562, 0.556, 0.5712, 0.5775]}, {"w": "nice", "b": [0.577, 0.556, 0.6116, 0.5775]}, {"w": "house", "b": [0.6175, 0.556, 0.6668, 0.5775]}, {"w": "in", "b": [0.6726, 0.556, 0.6896, 0.5775]}, {"w": "the", "b": [0.6954, 0.556, 0.7217, 0.5775]}, {"w": "Bay", "b": [0.7275, 0.556, 0.7581, 0.5775]}, {"w": "Area", "b": [0.7639, 0.556, 0.8041, 0.5775]}, {"w": "at", "b": [0.8099, 0.556, 0.825, 0.5775]}, {"w": "the", "b": [0.8308, 0.556, 0.8571, 0.5775]}, {"w": "time),", "b": [0.1429, 0.5751, 0.1927, 0.5965]}, {"w": "but", "b": [0.199, 0.5751, 0.227, 0.5965]}, {"w": "it", "b": [0.2333, 0.5751, 0.2452, 0.5965]}, {"w": "has", "b": [0.2515, 0.5751, 0.2794, 0.5965]}, {"w": "many", "b": [0.2857, 0.5751, 0.3324, 0.5965]}, {"w": "qualities", "b": [0.3387, 0.5751, 0.4088, 0.5965]}, {"w": "for", "b": [0.4151, 0.5751, 0.4396, 0.5965]}, {"w": "learning,", "b": [0.4459, 0.5751, 0.5198, 0.5965]}, {"w": "so", "b": [0.5261, 0.5751, 0.5444, 0.5965]}, {"w": "we", "b": [0.5507, 0.5751, 0.5738, 0.5965]}, {"w": "will", "b": [0.5801, 0.5751, 0.6105, 0.5965]}, {"w": "pretend", "b": [0.6168, 0.5751, 0.6819, 0.5965]}, {"w": "it", "b": [0.6882, 0.5751, 0.7001, 0.5965]}, {"w": "is", "b": [0.7064, 0.5751, 0.7196, 0.5965]}, {"w": "recent", "b": [0.7259, 0.5751, 0.7775, 0.5965]}, {"w": "data.", "b": [0.7838, 0.5751, 0.8238, 0.5965]}, {"w": "We", "b": [0.8301, 0.5751, 0.8572, 0.5965]}, {"w": "also", "b": [0.1429, 0.5941, 0.1755, 0.6156]}, {"w": "added", "b": [0.1803, 0.5941, 0.2313, 0.6156]}, {"w": "a", "b": [0.236, 0.5941, 0.2452, 0.6156]}, {"w": "categorical", "b": [0.2499, 0.5941, 0.3396, 0.6156]}, {"w": "attribute", "b": [0.3443, 0.5941, 0.4159, 0.6156]}, {"w": "and", "b": [0.4207, 0.5941, 0.4522, 0.6156]}, {"w": "removed", "b": [0.4569, 0.5941, 0.5307, 0.6156]}, {"w": "a", "b": [0.5354, 0.5941, 0.5446, 0.6156]}, {"w": "few", "b": [0.5493, 0.5941, 0.5786, 0.6156]}, {"w": "features", "b": [0.5833, 0.5941, 0.6487, 0.6156]}, {"w": "for", "b": [0.6535, 0.5941, 0.678, 0.6156]}, {"w": "teaching", "b": [0.6827, 0.5941, 0.7537, 0.6156]}, {"w": "purposes.", "b": [0.7585, 0.5941, 0.8386, 0.6156]}]}, {"id": "b_16", "type": "equation", "text": "38 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "38", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 65, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 2-1. California housing prices", "words": [{"w": "Figure", "b": [0.1429, 0.3816, 0.1943, 0.4032]}, {"w": "2-1.", "b": [0.1991, 0.3816, 0.2308, 0.4032]}, {"w": "California", "b": [0.2356, 0.3816, 0.3186, 0.4032]}, {"w": "housing", "b": [0.3233, 0.3816, 0.3864, 0.4032]}, {"w": "prices", "b": [0.3912, 0.3816, 0.4375, 0.4032]}]}, {"id": "b_1", "type": "paragraph", "text": "Look at the Big Picture", "words": [{"w": "Look", "b": [0.1429, 0.4162, 0.2018, 0.4504]}, {"w": "at", "b": [0.2077, 0.4162, 0.2333, 0.4504]}, {"w": "the", "b": [0.2393, 0.4162, 0.2811, 0.4504]}, {"w": "Big", "b": [0.287, 0.4162, 0.3277, 0.4504]}, {"w": "Picture", "b": [0.3336, 0.4162, 0.4211, 0.4504]}]}, {"id": "b_2", "type": "paragraph", "text": "Welcome to Machine Learning Housing Corporation! The first task you are asked to perform is to build a model of housing prices in California using the California cen‐ sus data. This data has metrics such as the population, median income, median hous‐ ing price, and so on for each block group in California. Block groups are the smallest geographical unit for which the US Census Bureau publishes sample data (a block group typically has a population of 600 to 3,000 people). We will just call them “dis‐ tricts” for short.", "words": [{"w": "Welcome", "b": [0.1429, 0.4574, 0.2205, 0.4788]}, {"w": "to", "b": [0.2263, 0.4574, 0.2433, 0.4788]}, {"w": "Machine", "b": [0.2491, 0.4574, 0.3222, 0.4788]}, {"w": "Learning", "b": [0.328, 0.4574, 0.403, 0.4788]}, {"w": "Housing", "b": [0.4088, 0.4574, 0.4803, 0.4788]}, {"w": "Corporation!", "b": [0.4861, 0.4574, 0.596, 0.4788]}, {"w": "The", "b": [0.6018, 0.4574, 0.6346, 0.4788]}, {"w": "first", "b": [0.6404, 0.4574, 0.6739, 0.4788]}, {"w": "task", "b": [0.6796, 0.4574, 0.7131, 0.4788]}, {"w": "you", "b": [0.7189, 0.4574, 0.7501, 0.4788]}, {"w": "are", "b": [0.7559, 0.4574, 0.7816, 0.4788]}, {"w": "asked", "b": [0.7874, 0.4574, 0.8344, 0.4788]}, {"w": "to", "b": [0.8402, 0.4574, 0.8571, 0.4788]}, {"w": "perform", "b": [0.1429, 0.4764, 0.212, 0.4978]}, {"w": "is", "b": [0.2178, 0.4764, 0.231, 0.4978]}, {"w": "to", "b": [0.2369, 0.4764, 0.2538, 0.4978]}, {"w": "build", "b": [0.2597, 0.4764, 0.3032, 0.4978]}, {"w": "a", "b": [0.309, 0.4764, 0.3182, 0.4978]}, {"w": "model", "b": [0.324, 0.4764, 0.3768, 0.4978]}, {"w": "of", "b": [0.3827, 0.4764, 0.3995, 0.4978]}, {"w": "housing", "b": [0.4053, 0.4764, 0.4725, 0.4978]}, {"w": "prices", "b": [0.4783, 0.4764, 0.5279, 0.4978]}, {"w": "in", "b": [0.5337, 0.4764, 0.5507, 0.4978]}, {"w": "California", "b": [0.5565, 0.4764, 0.641, 0.4978]}, {"w": "using", "b": [0.6469, 0.4764, 0.6923, 0.4978]}, {"w": "the", "b": [0.6982, 0.4764, 0.7245, 0.4978]}, {"w": "California", "b": [0.7303, 0.4764, 0.8148, 0.4978]}, {"w": "cen‐", "b": [0.8207, 0.4764, 0.8572, 0.4978]}, {"w": "sus", "b": [0.1429, 0.4955, 0.1692, 0.5169]}, {"w": "data.", "b": [0.1743, 0.4955, 0.2143, 0.5169]}, {"w": "This", "b": [0.2194, 0.4955, 0.2566, 0.5169]}, {"w": "data", "b": [0.2618, 0.4955, 0.297, 0.5169]}, {"w": "has", "b": [0.3021, 0.4955, 0.33, 0.5169]}, {"w": "metrics", "b": [0.3351, 0.4955, 0.3972, 0.5169]}, {"w": "such", "b": [0.4023, 0.4955, 0.4409, 0.5169]}, {"w": "as", "b": [0.4461, 0.4955, 0.4629, 0.5169]}, {"w": "the", "b": [0.468, 0.4955, 0.4943, 0.5169]}, {"w": "population,", "b": [0.4994, 0.4955, 0.5957, 0.5169]}, {"w": "median", "b": [0.6008, 0.4955, 0.6638, 0.5169]}, {"w": "income,", "b": [0.6689, 0.4955, 0.736, 0.5169]}, {"w": "median", "b": [0.7411, 0.4955, 0.8042, 0.5169]}, {"w": "hous‐", "b": [0.8093, 0.4955, 0.8571, 0.5169]}, {"w": "ing", "b": [0.1429, 0.5145, 0.1696, 0.5359]}, {"w": "price,", "b": [0.1749, 0.5145, 0.2216, 0.5359]}, {"w": "and", "b": [0.2269, 0.5145, 0.2585, 0.5359]}, {"w": "so", "b": [0.2638, 0.5145, 0.2821, 0.5359]}, {"w": "on", "b": [0.2875, 0.5145, 0.3095, 0.5359]}, {"w": "for", "b": [0.3148, 0.5145, 0.3394, 0.5359]}, {"w": "each", "b": [0.3447, 0.5145, 0.3827, 0.5359]}, {"w": "block", "b": [0.388, 0.5145, 0.4336, 0.5359]}, {"w": "group", "b": [0.439, 0.5145, 0.4891, 0.5359]}, {"w": "in", "b": [0.4944, 0.5145, 0.5114, 0.5359]}, {"w": "California.", "b": [0.5168, 0.5145, 0.606, 0.5359]}, {"w": "Block", "b": [0.6114, 0.5145, 0.6587, 0.5359]}, {"w": "groups", "b": [0.664, 0.5145, 0.7218, 0.5359]}, {"w": "are", "b": [0.7271, 0.5145, 0.7528, 0.5359]}, {"w": "the", "b": [0.7582, 0.5145, 0.7845, 0.5359]}, {"w": "smallest", "b": [0.7899, 0.5145, 0.8571, 0.5359]}, {"w": "geographical", "b": [0.1428, 0.5335, 0.2492, 0.555]}, {"w": "unit", "b": [0.2568, 0.5335, 0.2912, 0.555]}, {"w": "for", "b": [0.2989, 0.5335, 0.3234, 0.555]}, {"w": "which", "b": [0.3311, 0.5335, 0.382, 0.555]}, {"w": "the", "b": [0.3897, 0.5335, 0.416, 0.555]}, {"w": "US", "b": [0.4237, 0.5335, 0.4489, 0.555]}, {"w": "Census", "b": [0.4565, 0.5335, 0.517, 0.555]}, {"w": "Bureau", "b": [0.5247, 0.5335, 0.5844, 0.555]}, {"w": "publishes", "b": [0.592, 0.5335, 0.6707, 0.555]}, {"w": "sample", "b": [0.6784, 0.5335, 0.7369, 0.555]}, {"w": "data", "b": [0.7446, 0.5335, 0.7798, 0.555]}, {"w": "(a", "b": [0.7875, 0.5335, 0.8038, 0.555]}, {"w": "block", "b": [0.8115, 0.5335, 0.8571, 0.555]}, {"w": "group", "b": [0.1429, 0.5526, 0.1929, 0.574]}, {"w": "typically", "b": [0.199, 0.5526, 0.2695, 0.574]}, {"w": "has", "b": [0.2756, 0.5526, 0.3035, 0.574]}, {"w": "a", "b": [0.3096, 0.5526, 0.3187, 0.574]}, {"w": "population", "b": [0.3248, 0.5526, 0.4163, 0.574]}, {"w": "of", "b": [0.4224, 0.5526, 0.4392, 0.574]}, {"w": "600", "b": [0.4453, 0.5526, 0.4753, 0.574]}, {"w": "to", "b": [0.4814, 0.5526, 0.4984, 0.574]}, {"w": "3,000", "b": [0.5044, 0.5526, 0.5492, 0.574]}, {"w": "people).", "b": [0.5553, 0.5526, 0.6227, 0.574]}, {"w": "We", "b": [0.6288, 0.5526, 0.6558, 0.574]}, {"w": "will", "b": [0.6619, 0.5526, 0.6923, 0.574]}, {"w": "just", "b": [0.6984, 0.5526, 0.7288, 0.574]}, {"w": "call", "b": [0.7349, 0.5526, 0.7634, 0.574]}, {"w": "them", "b": [0.7695, 0.5526, 0.8129, 0.574]}, {"w": "“dis‐", "b": [0.8189, 0.5526, 0.8571, 0.574]}, {"w": "tricts”", "b": [0.1429, 0.5716, 0.1928, 0.5931]}, {"w": "for", "b": [0.1976, 0.5716, 0.2221, 0.5931]}, {"w": "short.", "b": [0.2268, 0.5716, 0.275, 0.5931]}]}, {"id": "b_3", "type": "paragraph", "text": "Your model should learn from this data and be able to predict the median housing price in any district, given all the other metrics.", "words": [{"w": "Your", "b": [0.1429, 0.5998, 0.1829, 0.6212]}, {"w": "model", "b": [0.1899, 0.5998, 0.2427, 0.6212]}, {"w": "should", "b": [0.2496, 0.5998, 0.3064, 0.6212]}, {"w": "learn", "b": [0.3133, 0.5998, 0.3557, 0.6212]}, {"w": "from", "b": [0.3626, 0.5998, 0.4042, 0.6212]}, {"w": "this", "b": [0.4111, 0.5998, 0.4418, 0.6212]}, {"w": "data", "b": [0.4488, 0.5998, 0.484, 0.6212]}, {"w": "and", "b": [0.491, 0.5998, 0.5225, 0.6212]}, {"w": "be", "b": [0.5294, 0.5998, 0.5489, 0.6212]}, {"w": "able", "b": [0.5558, 0.5998, 0.5897, 0.6212]}, {"w": "to", "b": [0.5966, 0.5998, 0.6136, 0.6212]}, {"w": "predict", "b": [0.6205, 0.5998, 0.6798, 0.6212]}, {"w": "the", "b": [0.6867, 0.5998, 0.713, 0.6212]}, {"w": "median", "b": [0.72, 0.5998, 0.783, 0.6212]}, {"w": "housing", "b": [0.79, 0.5998, 0.8571, 0.6212]}, {"w": "price", "b": [0.1429, 0.6188, 0.1847, 0.6402]}, {"w": "in", "b": [0.1895, 0.6188, 0.2065, 0.6402]}, {"w": "any", "b": [0.2112, 0.6188, 0.2408, 0.6402]}, {"w": "district,", "b": [0.2455, 0.6188, 0.3094, 0.6402]}, {"w": "given", "b": [0.3141, 0.6188, 0.3593, 0.6402]}, {"w": "all", "b": [0.364, 0.6188, 0.3837, 0.6402]}, {"w": "the", "b": [0.3885, 0.6188, 0.4148, 0.6402]}, {"w": "other", "b": [0.4195, 0.6188, 0.4642, 0.6402]}, {"w": "metrics.", "b": [0.4689, 0.6188, 0.5357, 0.6402]}]}, {"id": "b_4", "type": "paragraph", "text": "Since you are a well-organized data scientist, the first thing you do is to pull out your Machine Learning project checklist. You can start with the one in ???; it should work reasonably well for most Machine Learning projects but make sure to adapt it to your needs. In this chapter we will go through many checklist items, but we will also skip a few, either because they are self-explanatory or because they will be discussed in later chapters.", "words": [{"w": "Since", "b": [0.2714, 0.6608, 0.3121, 0.6803]}, {"w": "you", "b": [0.3174, 0.6608, 0.3459, 0.6803]}, {"w": "are", "b": [0.3512, 0.6608, 0.3747, 0.6803]}, {"w": "a", "b": [0.38, 0.6608, 0.3883, 0.6803]}, {"w": "well-organized", "b": [0.3936, 0.6608, 0.5069, 0.6803]}, {"w": "data", "b": [0.5121, 0.6608, 0.5444, 0.6803]}, {"w": "scientist,", "b": [0.5496, 0.6608, 0.616, 0.6803]}, {"w": "the", "b": [0.6212, 0.6608, 0.6453, 0.6803]}, {"w": "first", "b": [0.6506, 0.6608, 0.6812, 0.6803]}, {"w": "thing", "b": [0.6864, 0.6608, 0.7269, 0.6803]}, {"w": "you", "b": [0.7321, 0.6608, 0.7607, 0.6803]}, {"w": "do", "b": [0.7659, 0.6608, 0.7857, 0.6803]}, {"w": "is", "b": [0.2714, 0.6782, 0.2835, 0.6977]}, {"w": "to", "b": [0.2914, 0.6782, 0.307, 0.6977]}, {"w": "pull", "b": [0.3149, 0.6782, 0.3446, 0.6977]}, {"w": "out", "b": [0.3525, 0.6782, 0.3782, 0.6977]}, {"w": "your", "b": [0.3861, 0.6782, 0.4217, 0.6977]}, {"w": "Machine", "b": [0.4297, 0.6782, 0.4965, 0.6977]}, {"w": "Learning", "b": [0.5045, 0.6782, 0.5731, 0.6977]}, {"w": "project", "b": [0.581, 0.6782, 0.6346, 0.6977]}, {"w": "checklist.", "b": [0.6425, 0.6782, 0.7134, 0.6977]}, {"w": "You", "b": [0.7214, 0.6782, 0.7509, 0.6977]}, {"w": "can", "b": [0.7589, 0.6782, 0.7857, 0.6977]}, {"w": "start", "b": [0.2714, 0.6956, 0.3054, 0.7152]}, {"w": "with", "b": [0.3118, 0.6956, 0.346, 0.7152]}, {"w": "the", "b": [0.3524, 0.6956, 0.3764, 0.7152]}, {"w": "one", "b": [0.3828, 0.6956, 0.4111, 0.7152]}, {"w": "in", "b": [0.4174, 0.6956, 0.433, 0.7152]}, {"w": "???;", "b": [0.4394, 0.6956, 0.4654, 0.7152]}, {"w": "it", "b": [0.4717, 0.6956, 0.4827, 0.7152]}, {"w": "should", "b": [0.4891, 0.6956, 0.5409, 0.7152]}, {"w": "work", "b": [0.5473, 0.6956, 0.5866, 0.7152]}, {"w": "reasonably", "b": [0.593, 0.6956, 0.6752, 0.7152]}, {"w": "well", "b": [0.6816, 0.6956, 0.7124, 0.7152]}, {"w": "for", "b": [0.7188, 0.6956, 0.7412, 0.7152]}, {"w": "most", "b": [0.7476, 0.6956, 0.7857, 0.7152]}, {"w": "Machine", "b": [0.2714, 0.713, 0.3383, 0.7326]}, {"w": "Learning", "b": [0.3429, 0.713, 0.4115, 0.7326]}, {"w": "projects", "b": [0.4162, 0.713, 0.4768, 0.7326]}, {"w": "but", "b": [0.4814, 0.713, 0.507, 0.7326]}, {"w": "make", "b": [0.5116, 0.713, 0.5531, 0.7326]}, {"w": "sure", "b": [0.5578, 0.713, 0.5901, 0.7326]}, {"w": "to", "b": [0.5947, 0.713, 0.6102, 0.7326]}, {"w": "adapt", "b": [0.6149, 0.713, 0.6571, 0.7326]}, {"w": "it", "b": [0.6617, 0.713, 0.6726, 0.7326]}, {"w": "to", "b": [0.6773, 0.713, 0.6928, 0.7326]}, {"w": "your", "b": [0.6974, 0.713, 0.7331, 0.7326]}, {"w": "needs.", "b": [0.7377, 0.713, 0.7857, 0.7326]}, {"w": "In", "b": [0.2714, 0.7304, 0.2883, 0.75]}, {"w": "this", "b": [0.2927, 0.7304, 0.3208, 0.75]}, {"w": "chapter", "b": [0.3252, 0.7304, 0.3824, 0.75]}, {"w": "we", "b": [0.3868, 0.7304, 0.4079, 0.75]}, {"w": "will", "b": [0.4124, 0.7304, 0.4401, 0.75]}, {"w": "go", "b": [0.4446, 0.7304, 0.4632, 0.75]}, {"w": "through", "b": [0.4676, 0.7304, 0.5295, 0.75]}, {"w": "many", "b": [0.534, 0.7304, 0.5766, 0.75]}, {"w": "checklist", "b": [0.5811, 0.7304, 0.6476, 0.75]}, {"w": "items,", "b": [0.652, 0.7304, 0.698, 0.75]}, {"w": "but", "b": [0.7024, 0.7304, 0.728, 0.75]}, {"w": "we", "b": [0.7324, 0.7304, 0.7535, 0.75]}, {"w": "will", "b": [0.7579, 0.7304, 0.7857, 0.75]}, {"w": "also", "b": [0.2714, 0.7478, 0.3013, 0.7674]}, {"w": "skip", "b": [0.3069, 0.7478, 0.3385, 0.7674]}, {"w": "a", "b": [0.3441, 0.7478, 0.3525, 0.7674]}, {"w": "few,", "b": [0.3581, 0.7478, 0.3878, 0.7674]}, {"w": "either", "b": [0.3935, 0.7478, 0.4378, 0.7674]}, {"w": "because", "b": [0.4435, 0.7478, 0.5025, 0.7674]}, {"w": "they", "b": [0.5081, 0.7478, 0.5409, 0.7674]}, {"w": "are", "b": [0.5466, 0.7478, 0.5701, 0.7674]}, {"w": "self-explanatory", "b": [0.5757, 0.7478, 0.6986, 0.7674]}, {"w": "or", "b": [0.7043, 0.7478, 0.721, 0.7674]}, {"w": "because", "b": [0.7267, 0.7478, 0.7857, 0.7674]}, {"w": "they", "b": [0.2714, 0.7652, 0.3042, 0.7848]}, {"w": "will", "b": [0.3086, 0.7652, 0.3363, 0.7848]}, {"w": "be", "b": [0.3407, 0.7652, 0.3584, 0.7848]}, {"w": "discussed", "b": [0.3628, 0.7652, 0.4352, 0.7848]}, {"w": "in", "b": [0.4395, 0.7652, 0.4551, 0.7848]}, {"w": "later", "b": [0.4594, 0.7652, 0.4932, 0.7848]}, {"w": "chapters.", "b": [0.4975, 0.7652, 0.566, 0.7848]}]}, {"id": "b_5", "type": "paragraph", "text": "Frame the Problem", "words": [{"w": "Frame", "b": [0.1429, 0.8024, 0.2082, 0.8309]}, {"w": "the", "b": [0.2131, 0.8024, 0.248, 0.8309]}, {"w": "Problem", "b": [0.2529, 0.8024, 0.3404, 0.8309]}]}, {"id": "b_6", "type": "paragraph", "text": "The first question to ask your boss is what exactly is the business objective; building a model is probably not the end goal. How does the company expect to use and benefit", "words": [{"w": "The", "b": [0.1429, 0.8368, 0.1757, 0.8582]}, {"w": "first", "b": [0.1807, 0.8368, 0.2142, 0.8582]}, {"w": "question", "b": [0.2193, 0.8368, 0.2914, 0.8582]}, {"w": "to", "b": [0.2965, 0.8368, 0.3135, 0.8582]}, {"w": "ask", "b": [0.3185, 0.8368, 0.3457, 0.8582]}, {"w": "your", "b": [0.3507, 0.8368, 0.3897, 0.8582]}, {"w": "boss", "b": [0.3948, 0.8368, 0.4313, 0.8582]}, {"w": "is", "b": [0.4363, 0.8368, 0.4496, 0.8582]}, {"w": "what", "b": [0.4546, 0.8368, 0.4951, 0.8582]}, {"w": "exactly", "b": [0.5002, 0.8368, 0.558, 0.8582]}, {"w": "is", "b": [0.5631, 0.8368, 0.5763, 0.8582]}, {"w": "the", "b": [0.5814, 0.8368, 0.6077, 0.8582]}, {"w": "business", "b": [0.6128, 0.8368, 0.6832, 0.8582]}, {"w": "objective;", "b": [0.6882, 0.8368, 0.7676, 0.8582]}, {"w": "building", "b": [0.7727, 0.8368, 0.8429, 0.8582]}, {"w": "a", "b": [0.848, 0.8368, 0.8571, 0.8582]}, {"w": "model", "b": [0.1429, 0.8559, 0.1957, 0.8773]}, {"w": "is", "b": [0.201, 0.8559, 0.2142, 0.8773]}, {"w": "probably", "b": [0.2195, 0.8559, 0.2939, 0.8773]}, {"w": "not", "b": [0.2992, 0.8559, 0.3276, 0.8773]}, {"w": "the", "b": [0.3329, 0.8559, 0.3592, 0.8773]}, {"w": "end", "b": [0.3645, 0.8559, 0.3957, 0.8773]}, {"w": "goal.", "b": [0.401, 0.8559, 0.4406, 0.8773]}, {"w": "How", "b": [0.4459, 0.8559, 0.4862, 0.8773]}, {"w": "does", "b": [0.4915, 0.8559, 0.5296, 0.8773]}, {"w": "the", "b": [0.5349, 0.8559, 0.5612, 0.8773]}, {"w": "company", "b": [0.5665, 0.8559, 0.6432, 0.8773]}, {"w": "expect", "b": [0.6485, 0.8559, 0.7021, 0.8773]}, {"w": "to", "b": [0.7074, 0.8559, 0.7244, 0.8773]}, {"w": "use", "b": [0.7297, 0.8559, 0.7572, 0.8773]}, {"w": "and", "b": [0.7625, 0.8559, 0.7941, 0.8773]}, {"w": "benefit", "b": [0.7994, 0.8559, 0.8571, 0.8773]}]}, {"id": "b_7", "type": "paragraph", "text": "Look at the Big Picture | 39", "words": [{"w": "Look", "b": [0.6708, 0.9225, 0.6988, 0.9388]}, {"w": "at", "b": [0.7016, 0.9225, 0.7138, 0.9388]}, {"w": "the", "b": [0.7166, 0.9225, 0.7365, 0.9388]}, {"w": "Big", "b": [0.7393, 0.9225, 0.7587, 0.9388]}, {"w": "Picture", "b": [0.7615, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "39", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 66, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "3 A piece of information fed to a Machine Learning system is often called a signal in reference to Shannon’s information theory: you want a high signal/noise ratio.", "words": [{"w": "3", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "A", "b": [0.1587, 0.8598, 0.1697, 0.8761]}, {"w": "piece", "b": [0.1733, 0.8598, 0.2061, 0.8761]}, {"w": "of", "b": [0.2097, 0.8598, 0.2225, 0.8761]}, {"w": "information", "b": [0.2261, 0.8598, 0.3032, 0.8761]}, {"w": "fed", "b": [0.3068, 0.8598, 0.3267, 0.8761]}, {"w": "to", "b": [0.3303, 0.8598, 0.3432, 0.8761]}, {"w": "a", "b": [0.3468, 0.8598, 0.3538, 0.8761]}, {"w": "Machine", "b": [0.3574, 0.8598, 0.4131, 0.8761]}, {"w": "Learning", "b": [0.4167, 0.8598, 0.4739, 0.8761]}, {"w": "system", "b": [0.4775, 0.8598, 0.521, 0.8761]}, {"w": "is", "b": [0.5246, 0.8598, 0.5347, 0.8761]}, {"w": "often", "b": [0.5383, 0.8598, 0.5714, 0.8761]}, {"w": "called", "b": [0.575, 0.8598, 0.6118, 0.8761]}, {"w": "a", "b": [0.6154, 0.8598, 0.6224, 0.8761]}, {"w": "signal", "b": [0.626, 0.8596, 0.662, 0.8761]}, {"w": "in", "b": [0.6656, 0.8598, 0.6785, 0.8761]}, {"w": "reference", "b": [0.6821, 0.8598, 0.741, 0.8761]}, {"w": "to", "b": [0.7446, 0.8598, 0.7575, 0.8761]}, {"w": "Shannon’s", "b": [0.7611, 0.8598, 0.8248, 0.8761]}, {"w": "information", "b": [0.1587, 0.8749, 0.2359, 0.8912]}, {"w": "theory:", "b": [0.2395, 0.8749, 0.2854, 0.8912]}, {"w": "you", "b": [0.289, 0.8749, 0.3128, 0.8912]}, {"w": "want", "b": [0.3164, 0.8749, 0.3475, 0.8912]}, {"w": "a", "b": [0.3511, 0.8749, 0.358, 0.8912]}, {"w": "high", "b": [0.3617, 0.8749, 0.3903, 0.8912]}, {"w": "signal/noise", "b": [0.3939, 0.8749, 0.4699, 0.8912]}, {"w": "ratio.", "b": [0.4735, 0.8749, 0.5064, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "from this model? This is important because it will determine how you frame the problem, what algorithms you will select, what performance measure you will use to evaluate your model, and how much effort you should spend tweaking it.", "words": [{"w": "from", "b": [0.1429, 0.0791, 0.1844, 0.1005]}, {"w": "this", "b": [0.193, 0.0791, 0.2237, 0.1005]}, {"w": "model?", "b": [0.2323, 0.0791, 0.293, 0.1005]}, {"w": "This", "b": [0.3016, 0.0791, 0.3388, 0.1005]}, {"w": "is", "b": [0.3473, 0.0791, 0.3606, 0.1005]}, {"w": "important", "b": [0.3691, 0.0791, 0.4535, 0.1005]}, {"w": "because", "b": [0.4621, 0.0791, 0.5266, 0.1005]}, {"w": "it", "b": [0.5352, 0.0791, 0.5471, 0.1005]}, {"w": "will", "b": [0.5557, 0.0791, 0.5861, 0.1005]}, {"w": "determine", "b": [0.5946, 0.0791, 0.6803, 0.1005]}, {"w": "how", "b": [0.6889, 0.0791, 0.7249, 0.1005]}, {"w": "you", "b": [0.7335, 0.0791, 0.7647, 0.1005]}, {"w": "frame", "b": [0.7733, 0.0791, 0.8223, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8572, 0.1005]}, {"w": "problem,", "b": [0.1429, 0.0981, 0.2187, 0.1195]}, {"w": "what", "b": [0.2246, 0.0981, 0.2651, 0.1195]}, {"w": "algorithms", "b": [0.271, 0.0981, 0.3613, 0.1195]}, {"w": "you", "b": [0.3672, 0.0981, 0.3985, 0.1195]}, {"w": "will", "b": [0.4044, 0.0981, 0.4348, 0.1195]}, {"w": "select,", "b": [0.4407, 0.0981, 0.4913, 0.1195]}, {"w": "what", "b": [0.4972, 0.0981, 0.5377, 0.1195]}, {"w": "performance", "b": [0.5437, 0.0981, 0.6509, 0.1195]}, {"w": "measure", "b": [0.6569, 0.0981, 0.7272, 0.1195]}, {"w": "you", "b": [0.7332, 0.0981, 0.7644, 0.1195]}, {"w": "will", "b": [0.7703, 0.0981, 0.8007, 0.1195]}, {"w": "use", "b": [0.8067, 0.0981, 0.8342, 0.1195]}, {"w": "to", "b": [0.8402, 0.0981, 0.8571, 0.1195]}, {"w": "evaluate", "b": [0.1429, 0.1172, 0.2108, 0.1386]}, {"w": "your", "b": [0.2155, 0.1172, 0.2545, 0.1386]}, {"w": "model,", "b": [0.2592, 0.1172, 0.3168, 0.1386]}, {"w": "and", "b": [0.3215, 0.1172, 0.3531, 0.1386]}, {"w": "how", "b": [0.3578, 0.1172, 0.3938, 0.1386]}, {"w": "much", "b": [0.3985, 0.1172, 0.4462, 0.1386]}, {"w": "effort", "b": [0.4509, 0.1172, 0.4968, 0.1386]}, {"w": "you", "b": [0.5016, 0.1172, 0.5328, 0.1386]}, {"w": "should", "b": [0.5375, 0.1172, 0.5943, 0.1386]}, {"w": "spend", "b": [0.599, 0.1172, 0.6488, 0.1386]}, {"w": "tweaking", "b": [0.6535, 0.1172, 0.7292, 0.1386]}, {"w": "it.", "b": [0.734, 0.1172, 0.7506, 0.1386]}]}, {"id": "b_2", "type": "paragraph", "text": "Your boss answers that your model’s output (a prediction of a district’s median hous‐ ing price) will be fed to another Machine Learning system (see Figure 2-2), along with many other signals.3 This downstream system will determine whether it is worth investing in a given area or not. Getting this right is critical, as it directly affects reve‐ nue.", "words": [{"w": "Your", "b": [0.1429, 0.1453, 0.1829, 0.1667]}, {"w": "boss", "b": [0.1884, 0.1453, 0.2249, 0.1667]}, {"w": "answers", "b": [0.2305, 0.1453, 0.2971, 0.1667]}, {"w": "that", "b": [0.3027, 0.1453, 0.3352, 0.1667]}, {"w": "your", "b": [0.3407, 0.1453, 0.3797, 0.1667]}, {"w": "model’s", "b": [0.3852, 0.1453, 0.4478, 0.1667]}, {"w": "output", "b": [0.4533, 0.1453, 0.5097, 0.1667]}, {"w": "(a", "b": [0.5152, 0.1453, 0.5316, 0.1667]}, {"w": "prediction", "b": [0.5371, 0.1453, 0.6239, 0.1667]}, {"w": "of", "b": [0.6294, 0.1453, 0.6462, 0.1667]}, {"w": "a", "b": [0.6517, 0.1453, 0.6609, 0.1667]}, {"w": "district’s", "b": [0.6664, 0.1453, 0.7352, 0.1667]}, {"w": "median", "b": [0.7407, 0.1453, 0.8038, 0.1667]}, {"w": "hous‐", "b": [0.8093, 0.1453, 0.8571, 0.1667]}, {"w": "ing", "b": [0.1428, 0.1643, 0.1696, 0.1857]}, {"w": "price)", "b": [0.1775, 0.1643, 0.2266, 0.1857]}, {"w": "will", "b": [0.2345, 0.1643, 0.2649, 0.1857]}, {"w": "be", "b": [0.2728, 0.1643, 0.2923, 0.1857]}, {"w": "fed", "b": [0.3002, 0.1643, 0.3262, 0.1857]}, {"w": "to", "b": [0.3341, 0.1643, 0.3511, 0.1857]}, {"w": "another", "b": [0.359, 0.1643, 0.4243, 0.1857]}, {"w": "Machine", "b": [0.4322, 0.1643, 0.5053, 0.1857]}, {"w": "Learning", "b": [0.5132, 0.1643, 0.5883, 0.1857]}, {"w": "system", "b": [0.5962, 0.1643, 0.6533, 0.1857]}, {"w": "(see", "b": [0.6613, 0.1643, 0.6938, 0.1857]}, {"w": "Figure", "b": [0.7017, 0.1643, 0.7557, 0.1857]}, {"w": "2-2),", "b": [0.7637, 0.1643, 0.803, 0.1857]}, {"w": "along", "b": [0.8109, 0.1643, 0.8571, 0.1857]}, {"w": "with", "b": [0.1429, 0.1834, 0.1802, 0.2048]}, {"w": "many", "b": [0.1854, 0.1834, 0.2321, 0.2048]}, {"w": "other", "b": [0.2373, 0.1834, 0.282, 0.2048]}, {"w": "signals.3", "b": [0.2872, 0.1832, 0.3521, 0.2048]}, {"w": "This", "b": [0.3573, 0.1834, 0.3945, 0.2048]}, {"w": "downstream", "b": [0.3997, 0.1834, 0.5038, 0.2048]}, {"w": "system", "b": [0.509, 0.1834, 0.5662, 0.2048]}, {"w": "will", "b": [0.5714, 0.1834, 0.6018, 0.2048]}, {"w": "determine", "b": [0.607, 0.1834, 0.6927, 0.2048]}, {"w": "whether", "b": [0.6979, 0.1834, 0.7662, 0.2048]}, {"w": "it", "b": [0.7714, 0.1834, 0.7834, 0.2048]}, {"w": "is", "b": [0.7886, 0.1834, 0.8018, 0.2048]}, {"w": "worth", "b": [0.807, 0.1834, 0.8571, 0.2048]}, {"w": "investing", "b": [0.1429, 0.2024, 0.2186, 0.2238]}, {"w": "in", "b": [0.2238, 0.2024, 0.2408, 0.2238]}, {"w": "a", "b": [0.2461, 0.2024, 0.2552, 0.2238]}, {"w": "given", "b": [0.2605, 0.2024, 0.3057, 0.2238]}, {"w": "area", "b": [0.3109, 0.2024, 0.3458, 0.2238]}, {"w": "or", "b": [0.3511, 0.2024, 0.3694, 0.2238]}, {"w": "not.", "b": [0.3747, 0.2024, 0.4078, 0.2238]}, {"w": "Getting", "b": [0.413, 0.2024, 0.4762, 0.2238]}, {"w": "this", "b": [0.4815, 0.2024, 0.5122, 0.2238]}, {"w": "right", "b": [0.5174, 0.2024, 0.5576, 0.2238]}, {"w": "is", "b": [0.5628, 0.2024, 0.5761, 0.2238]}, {"w": "critical,", "b": [0.5813, 0.2024, 0.6433, 0.2238]}, {"w": "as", "b": [0.6486, 0.2024, 0.6654, 0.2238]}, {"w": "it", "b": [0.6706, 0.2024, 0.6826, 0.2238]}, {"w": "directly", "b": [0.6878, 0.2024, 0.751, 0.2238]}, {"w": "affects", "b": [0.7562, 0.2024, 0.8094, 0.2238]}, {"w": "reve‐", "b": [0.8146, 0.2024, 0.8571, 0.2238]}, {"w": "nue.", "b": [0.1428, 0.2215, 0.1785, 0.2429]}]}, {"id": "b_3", "type": "equation", "text": "Figure 2-2. A Machine Learning pipeline for real estate investments", "words": [{"w": "Figure", "b": [0.1428, 0.4415, 0.1943, 0.4631]}, {"w": "2-2.", "b": [0.1991, 0.4415, 0.2308, 0.4631]}, {"w": "A", "b": [0.2356, 0.4415, 0.2494, 0.4631]}, {"w": "Machine", "b": [0.2542, 0.4415, 0.3245, 0.4631]}, {"w": "Learning", "b": [0.3293, 0.4415, 0.4021, 0.4631]}, {"w": "pipeline", "b": [0.4068, 0.4415, 0.4699, 0.4631]}, {"w": "for", "b": [0.4746, 0.4415, 0.4973, 0.4631]}, {"w": "real", "b": [0.5021, 0.4415, 0.5327, 0.4631]}, {"w": "estate", "b": [0.5374, 0.4415, 0.5829, 0.4631]}, {"w": "investments", "b": [0.5876, 0.4415, 0.6827, 0.4631]}]}, {"id": "b_4", "type": "paragraph", "text": "Pipelines", "words": [{"w": "Pipelines", "b": [0.4553, 0.4919, 0.5447, 0.5191]}]}, {"id": "b_5", "type": "paragraph", "text": "A sequence of data processing components is called a data pipeline. Pipelines are very common in Machine Learning systems, since there is a lot of data to manipulate and many data transformations to apply.", "words": [{"w": "A", "b": [0.1592, 0.5236, 0.1729, 0.544]}, {"w": "sequence", "b": [0.1785, 0.5236, 0.251, 0.544]}, {"w": "of", "b": [0.2566, 0.5236, 0.2726, 0.544]}, {"w": "data", "b": [0.2781, 0.5236, 0.3117, 0.544]}, {"w": "processing", "b": [0.3173, 0.5236, 0.402, 0.544]}, {"w": "components", "b": [0.4076, 0.5234, 0.4994, 0.544]}, {"w": "is", "b": [0.5049, 0.5236, 0.5175, 0.544]}, {"w": "called", "b": [0.5231, 0.5236, 0.5691, 0.544]}, {"w": "a", "b": [0.5747, 0.5236, 0.5834, 0.544]}, {"w": "data", "b": [0.589, 0.5236, 0.6226, 0.544]}, {"w": "pipeline.", "b": [0.6281, 0.5234, 0.6927, 0.544]}, {"w": "Pipelines", "b": [0.6983, 0.5236, 0.7705, 0.544]}, {"w": "are", "b": [0.776, 0.5236, 0.8005, 0.544]}, {"w": "very", "b": [0.8061, 0.5236, 0.8408, 0.544]}, {"w": "common", "b": [0.1592, 0.5418, 0.2312, 0.5622]}, {"w": "in", "b": [0.2367, 0.5418, 0.2529, 0.5622]}, {"w": "Machine", "b": [0.2583, 0.5418, 0.328, 0.5622]}, {"w": "Learning", "b": [0.3335, 0.5418, 0.405, 0.5622]}, {"w": "systems,", "b": [0.4104, 0.5418, 0.4766, 0.5622]}, {"w": "since", "b": [0.4821, 0.5418, 0.5224, 0.5622]}, {"w": "there", "b": [0.5279, 0.5418, 0.5688, 0.5622]}, {"w": "is", "b": [0.5742, 0.5418, 0.5868, 0.5622]}, {"w": "a", "b": [0.5923, 0.5418, 0.601, 0.5622]}, {"w": "lot", "b": [0.6065, 0.5418, 0.6277, 0.5622]}, {"w": "of", "b": [0.6332, 0.5418, 0.6492, 0.5622]}, {"w": "data", "b": [0.6547, 0.5418, 0.6882, 0.5622]}, {"w": "to", "b": [0.6937, 0.5418, 0.7099, 0.5622]}, {"w": "manipulate", "b": [0.7154, 0.5418, 0.8053, 0.5622]}, {"w": "and", "b": [0.8107, 0.5418, 0.8408, 0.5622]}, {"w": "many", "b": [0.1592, 0.5599, 0.2037, 0.5803]}, {"w": "data", "b": [0.2082, 0.5599, 0.2418, 0.5803]}, {"w": "transformations", "b": [0.2463, 0.5599, 0.3741, 0.5803]}, {"w": "to", "b": [0.3786, 0.5599, 0.3948, 0.5803]}, {"w": "apply.", "b": [0.3993, 0.5599, 0.4456, 0.5803]}]}, {"id": "b_6", "type": "paragraph", "text": "Components typically run asynchronously. Each component pulls in a large amount of data, processes it, and spits out the result in another data store, and then some time later the next component in the pipeline pulls this data and spits out its own output, and so on. Each component is fairly self-contained: the interface between components is simply the data store. This makes the system quite simple to grasp (with the help of a data flow graph), and different teams can focus on different components. Moreover, if a component breaks down, the downstream components can often continue to run normally (at least for a while) by just using the last output from the broken compo‐ nent. This makes the architecture quite robust.", "words": [{"w": "Components", "b": [0.1592, 0.5871, 0.262, 0.6075]}, {"w": "typically", "b": [0.2681, 0.5871, 0.3352, 0.6075]}, {"w": "run", "b": [0.3413, 0.5871, 0.37, 0.6075]}, {"w": "asynchronously.", "b": [0.3761, 0.5871, 0.5045, 0.6075]}, {"w": "Each", "b": [0.5106, 0.5871, 0.5496, 0.6075]}, {"w": "component", "b": [0.5556, 0.5871, 0.6463, 0.6075]}, {"w": "pulls", "b": [0.6524, 0.5871, 0.6907, 0.6075]}, {"w": "in", "b": [0.6967, 0.5871, 0.7129, 0.6075]}, {"w": "a", "b": [0.719, 0.5871, 0.7277, 0.6075]}, {"w": "large", "b": [0.7338, 0.5871, 0.7726, 0.6075]}, {"w": "amount", "b": [0.7786, 0.5871, 0.8408, 0.6075]}, {"w": "of", "b": [0.1592, 0.6053, 0.1752, 0.6257]}, {"w": "data,", "b": [0.1798, 0.6053, 0.2179, 0.6257]}, {"w": "processes", "b": [0.2226, 0.6053, 0.2975, 0.6257]}, {"w": "it,", "b": [0.3022, 0.6053, 0.3181, 0.6257]}, {"w": "and", "b": [0.3227, 0.6053, 0.3527, 0.6257]}, {"w": "spits", "b": [0.3574, 0.6053, 0.3937, 0.6257]}, {"w": "out", "b": [0.3983, 0.6053, 0.425, 0.6257]}, {"w": "the", "b": [0.4296, 0.6053, 0.4547, 0.6257]}, {"w": "result", "b": [0.4593, 0.6053, 0.504, 0.6257]}, {"w": "in", "b": [0.5087, 0.6053, 0.5248, 0.6257]}, {"w": "another", "b": [0.5294, 0.6053, 0.5916, 0.6257]}, {"w": "data", "b": [0.5962, 0.6053, 0.6298, 0.6257]}, {"w": "store,", "b": [0.6344, 0.6053, 0.6782, 0.6257]}, {"w": "and", "b": [0.6828, 0.6053, 0.7128, 0.6257]}, {"w": "then", "b": [0.7175, 0.6053, 0.7534, 0.6257]}, {"w": "some", "b": [0.758, 0.6053, 0.8001, 0.6257]}, {"w": "time", "b": [0.8047, 0.6053, 0.8408, 0.6257]}, {"w": "later", "b": [0.1592, 0.6234, 0.1944, 0.6438]}, {"w": "the", "b": [0.2001, 0.6234, 0.2252, 0.6438]}, {"w": "next", "b": [0.2308, 0.6234, 0.2655, 0.6438]}, {"w": "component", "b": [0.2712, 0.6234, 0.3619, 0.6438]}, {"w": "in", "b": [0.3676, 0.6234, 0.3837, 0.6438]}, {"w": "the", "b": [0.3894, 0.6234, 0.4145, 0.6438]}, {"w": "pipeline", "b": [0.4201, 0.6234, 0.4843, 0.6438]}, {"w": "pulls", "b": [0.4899, 0.6234, 0.5282, 0.6438]}, {"w": "this", "b": [0.5339, 0.6234, 0.5631, 0.6438]}, {"w": "data", "b": [0.5688, 0.6234, 0.6023, 0.6438]}, {"w": "and", "b": [0.608, 0.6234, 0.638, 0.6438]}, {"w": "spits", "b": [0.6437, 0.6234, 0.68, 0.6438]}, {"w": "out", "b": [0.6857, 0.6234, 0.7124, 0.6438]}, {"w": "its", "b": [0.718, 0.6234, 0.7367, 0.6438]}, {"w": "own", "b": [0.7423, 0.6234, 0.7769, 0.6438]}, {"w": "output,", "b": [0.7826, 0.6234, 0.8408, 0.6438]}, {"w": "and", "b": [0.1592, 0.6415, 0.1893, 0.6619]}, {"w": "so", "b": [0.1938, 0.6415, 0.2112, 0.6619]}, {"w": "on.", "b": [0.2157, 0.6415, 0.2412, 0.6619]}, {"w": "Each", "b": [0.2457, 0.6415, 0.2846, 0.6619]}, {"w": "component", "b": [0.2891, 0.6415, 0.3799, 0.6619]}, {"w": "is", "b": [0.3844, 0.6415, 0.397, 0.6619]}, {"w": "fairly", "b": [0.4015, 0.6415, 0.4429, 0.6619]}, {"w": "self-contained:", "b": [0.4474, 0.6415, 0.5644, 0.6619]}, {"w": "the", "b": [0.5689, 0.6415, 0.594, 0.6619]}, {"w": "interface", "b": [0.5985, 0.6415, 0.6675, 0.6619]}, {"w": "between", "b": [0.672, 0.6415, 0.7379, 0.6619]}, {"w": "components", "b": [0.7424, 0.6415, 0.8404, 0.6619]}, {"w": "is", "b": [0.1592, 0.6597, 0.1718, 0.6801]}, {"w": "simply", "b": [0.1767, 0.6597, 0.2297, 0.6801]}, {"w": "the", "b": [0.2346, 0.6597, 0.2597, 0.6801]}, {"w": "data", "b": [0.2646, 0.6597, 0.2981, 0.6801]}, {"w": "store.", "b": [0.303, 0.6597, 0.3468, 0.6801]}, {"w": "This", "b": [0.3517, 0.6597, 0.3871, 0.6801]}, {"w": "makes", "b": [0.392, 0.6597, 0.4425, 0.6801]}, {"w": "the", "b": [0.4474, 0.6597, 0.4725, 0.6801]}, {"w": "system", "b": [0.4774, 0.6597, 0.5318, 0.6801]}, {"w": "quite", "b": [0.5366, 0.6597, 0.5771, 0.6801]}, {"w": "simple", "b": [0.582, 0.6597, 0.6343, 0.6801]}, {"w": "to", "b": [0.6392, 0.6597, 0.6554, 0.6801]}, {"w": "grasp", "b": [0.6603, 0.6597, 0.7033, 0.6801]}, {"w": "(with", "b": [0.7082, 0.6597, 0.7506, 0.6801]}, {"w": "the", "b": [0.7555, 0.6597, 0.7806, 0.6801]}, {"w": "help", "b": [0.7855, 0.6597, 0.8199, 0.6801]}, {"w": "of", "b": [0.8248, 0.6597, 0.8408, 0.6801]}, {"w": "a", "b": [0.1592, 0.6778, 0.1679, 0.6982]}, {"w": "data", "b": [0.1728, 0.6778, 0.2064, 0.6982]}, {"w": "flow", "b": [0.2113, 0.6778, 0.2459, 0.6982]}, {"w": "graph),", "b": [0.2508, 0.6778, 0.3082, 0.6982]}, {"w": "and", "b": [0.3131, 0.6778, 0.3431, 0.6982]}, {"w": "different", "b": [0.348, 0.6778, 0.4163, 0.6982]}, {"w": "teams", "b": [0.4212, 0.6778, 0.468, 0.6982]}, {"w": "can", "b": [0.4729, 0.6778, 0.5008, 0.6982]}, {"w": "focus", "b": [0.5057, 0.6778, 0.5479, 0.6982]}, {"w": "on", "b": [0.5528, 0.6778, 0.5738, 0.6982]}, {"w": "different", "b": [0.5787, 0.6778, 0.647, 0.6982]}, {"w": "components.", "b": [0.6519, 0.6778, 0.7544, 0.6982]}, {"w": "Moreover,", "b": [0.7593, 0.6778, 0.8408, 0.6982]}, {"w": "if", "b": [0.1592, 0.696, 0.1704, 0.7164]}, {"w": "a", "b": [0.1757, 0.696, 0.1844, 0.7164]}, {"w": "component", "b": [0.1897, 0.696, 0.2804, 0.7164]}, {"w": "breaks", "b": [0.2857, 0.696, 0.3374, 0.7164]}, {"w": "down,", "b": [0.3427, 0.696, 0.3923, 0.7164]}, {"w": "the", "b": [0.3975, 0.696, 0.4226, 0.7164]}, {"w": "downstream", "b": [0.4279, 0.696, 0.527, 0.7164]}, {"w": "components", "b": [0.5323, 0.696, 0.6303, 0.7164]}, {"w": "can", "b": [0.6356, 0.696, 0.6636, 0.7164]}, {"w": "often", "b": [0.6689, 0.696, 0.7102, 0.7164]}, {"w": "continue", "b": [0.7155, 0.696, 0.7853, 0.7164]}, {"w": "to", "b": [0.7906, 0.696, 0.8067, 0.7164]}, {"w": "run", "b": [0.812, 0.696, 0.8408, 0.7164]}, {"w": "normally", "b": [0.1592, 0.7141, 0.2317, 0.7345]}, {"w": "(at", "b": [0.2377, 0.7141, 0.2589, 0.7345]}, {"w": "least", "b": [0.2649, 0.7141, 0.3004, 0.7345]}, {"w": "for", "b": [0.3064, 0.7141, 0.3297, 0.7345]}, {"w": "a", "b": [0.3357, 0.7141, 0.3444, 0.7345]}, {"w": "while)", "b": [0.3504, 0.7141, 0.4003, 0.7345]}, {"w": "by", "b": [0.4063, 0.7141, 0.4254, 0.7345]}, {"w": "just", "b": [0.4314, 0.7141, 0.4604, 0.7345]}, {"w": "using", "b": [0.4664, 0.7141, 0.5097, 0.7345]}, {"w": "the", "b": [0.5156, 0.7141, 0.5407, 0.7345]}, {"w": "last", "b": [0.5467, 0.7141, 0.5738, 0.7345]}, {"w": "output", "b": [0.5798, 0.7141, 0.6335, 0.7345]}, {"w": "from", "b": [0.6395, 0.7141, 0.6791, 0.7345]}, {"w": "the", "b": [0.6851, 0.7141, 0.7101, 0.7345]}, {"w": "broken", "b": [0.7161, 0.7141, 0.7728, 0.7345]}, {"w": "compo‐", "b": [0.7788, 0.7141, 0.8408, 0.7345]}, {"w": "nent.", "b": [0.1592, 0.7322, 0.1996, 0.7526]}, {"w": "This", "b": [0.2041, 0.7322, 0.2395, 0.7526]}, {"w": "makes", "b": [0.244, 0.7322, 0.2945, 0.7526]}, {"w": "the", "b": [0.299, 0.7322, 0.3241, 0.7526]}, {"w": "architecture", "b": [0.3286, 0.7322, 0.4242, 0.7526]}, {"w": "quite", "b": [0.4288, 0.7322, 0.4692, 0.7526]}, {"w": "robust.", "b": [0.4737, 0.7322, 0.5297, 0.7526]}]}, {"id": "b_7", "type": "equation", "text": "40 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "40", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 67, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "On the other hand, a broken component can go unnoticed for some time if proper monitoring is not implemented. The data gets stale and the overall system’s perfor‐ mance drops.", "words": [{"w": "On", "b": [0.1592, 0.0792, 0.1849, 0.0996]}, {"w": "the", "b": [0.1915, 0.0792, 0.2165, 0.0996]}, {"w": "other", "b": [0.2231, 0.0792, 0.2657, 0.0996]}, {"w": "hand,", "b": [0.2722, 0.0792, 0.3174, 0.0996]}, {"w": "a", "b": [0.3239, 0.0792, 0.3326, 0.0996]}, {"w": "broken", "b": [0.3392, 0.0792, 0.3959, 0.0996]}, {"w": "component", "b": [0.4024, 0.0792, 0.4932, 0.0996]}, {"w": "can", "b": [0.4997, 0.0792, 0.5277, 0.0996]}, {"w": "go", "b": [0.5342, 0.0792, 0.5536, 0.0996]}, {"w": "unnoticed", "b": [0.5602, 0.0792, 0.6412, 0.0996]}, {"w": "for", "b": [0.6478, 0.0792, 0.6711, 0.0996]}, {"w": "some", "b": [0.6777, 0.0792, 0.7198, 0.0996]}, {"w": "time", "b": [0.7263, 0.0792, 0.7624, 0.0996]}, {"w": "if", "b": [0.769, 0.0792, 0.7801, 0.0996]}, {"w": "proper", "b": [0.7867, 0.0792, 0.8408, 0.0996]}, {"w": "monitoring", "b": [0.1592, 0.0973, 0.2508, 0.1177]}, {"w": "is", "b": [0.2575, 0.0973, 0.2701, 0.1177]}, {"w": "not", "b": [0.2769, 0.0973, 0.3039, 0.1177]}, {"w": "implemented.", "b": [0.3107, 0.0973, 0.4203, 0.1177]}, {"w": "The", "b": [0.4271, 0.0973, 0.4584, 0.1177]}, {"w": "data", "b": [0.4651, 0.0973, 0.4987, 0.1177]}, {"w": "gets", "b": [0.5055, 0.0973, 0.5365, 0.1177]}, {"w": "stale", "b": [0.5433, 0.0973, 0.5788, 0.1177]}, {"w": "and", "b": [0.5855, 0.0973, 0.6156, 0.1177]}, {"w": "the", "b": [0.6224, 0.0973, 0.6474, 0.1177]}, {"w": "overall", "b": [0.6542, 0.0973, 0.708, 0.1177]}, {"w": "system’s", "b": [0.7148, 0.0973, 0.7774, 0.1177]}, {"w": "perfor‐", "b": [0.7842, 0.0973, 0.8408, 0.1177]}, {"w": "mance", "b": [0.1592, 0.1155, 0.2119, 0.1359]}, {"w": "drops.", "b": [0.2164, 0.1155, 0.2665, 0.1359]}]}, {"id": "b_1", "type": "paragraph", "text": "The next question to ask is what the current solution looks like (if any). It will often give you a reference performance, as well as insights on how to solve the problem. Your boss answers that the district housing prices are currently estimated manually by experts: a team gathers up-to-date information about a district, and when they cannot get the median housing price, they estimate it using complex rules.", "words": [{"w": "The", "b": [0.1429, 0.1656, 0.1757, 0.187]}, {"w": "next", "b": [0.1818, 0.1656, 0.2182, 0.187]}, {"w": "question", "b": [0.2243, 0.1656, 0.2964, 0.187]}, {"w": "to", "b": [0.3025, 0.1656, 0.3195, 0.187]}, {"w": "ask", "b": [0.3255, 0.1656, 0.3527, 0.187]}, {"w": "is", "b": [0.3587, 0.1656, 0.372, 0.187]}, {"w": "what", "b": [0.378, 0.1656, 0.4185, 0.187]}, {"w": "the", "b": [0.4246, 0.1656, 0.4509, 0.187]}, {"w": "current", "b": [0.457, 0.1656, 0.5185, 0.187]}, {"w": "solution", "b": [0.5246, 0.1656, 0.5932, 0.187]}, {"w": "looks", "b": [0.5992, 0.1656, 0.6437, 0.187]}, {"w": "like", "b": [0.6498, 0.1656, 0.6798, 0.187]}, {"w": "(if", "b": [0.6859, 0.1656, 0.7049, 0.187]}, {"w": "any).", "b": [0.7109, 0.1656, 0.7525, 0.187]}, {"w": "It", "b": [0.7586, 0.1656, 0.7712, 0.187]}, {"w": "will", "b": [0.7773, 0.1656, 0.8077, 0.187]}, {"w": "often", "b": [0.8138, 0.1656, 0.8571, 0.187]}, {"w": "give", "b": [0.1429, 0.1847, 0.1767, 0.2061]}, {"w": "you", "b": [0.1838, 0.1847, 0.2151, 0.2061]}, {"w": "a", "b": [0.2222, 0.1847, 0.2313, 0.2061]}, {"w": "reference", "b": [0.2384, 0.1847, 0.3157, 0.2061]}, {"w": "performance,", "b": [0.3228, 0.1847, 0.4348, 0.2061]}, {"w": "as", "b": [0.442, 0.1847, 0.4588, 0.2061]}, {"w": "well", "b": [0.4659, 0.1847, 0.4995, 0.2061]}, {"w": "as", "b": [0.5067, 0.1847, 0.5234, 0.2061]}, {"w": "insights", "b": [0.5306, 0.1847, 0.5953, 0.2061]}, {"w": "on", "b": [0.6024, 0.1847, 0.6244, 0.2061]}, {"w": "how", "b": [0.6315, 0.1847, 0.6675, 0.2061]}, {"w": "to", "b": [0.6746, 0.1847, 0.6916, 0.2061]}, {"w": "solve", "b": [0.6987, 0.1847, 0.7408, 0.2061]}, {"w": "the", "b": [0.7479, 0.1847, 0.7742, 0.2061]}, {"w": "problem.", "b": [0.7813, 0.1847, 0.8571, 0.2061]}, {"w": "Your", "b": [0.1428, 0.2037, 0.1829, 0.2251]}, {"w": "boss", "b": [0.1899, 0.2037, 0.2264, 0.2251]}, {"w": "answers", "b": [0.2333, 0.2037, 0.3, 0.2251]}, {"w": "that", "b": [0.3069, 0.2037, 0.3395, 0.2251]}, {"w": "the", "b": [0.3464, 0.2037, 0.3728, 0.2251]}, {"w": "district", "b": [0.3797, 0.2037, 0.4387, 0.2251]}, {"w": "housing", "b": [0.4457, 0.2037, 0.5129, 0.2251]}, {"w": "prices", "b": [0.5198, 0.2037, 0.5693, 0.2251]}, {"w": "are", "b": [0.5763, 0.2037, 0.602, 0.2251]}, {"w": "currently", "b": [0.6089, 0.2037, 0.6853, 0.2251]}, {"w": "estimated", "b": [0.6922, 0.2037, 0.7727, 0.2251]}, {"w": "manually", "b": [0.7796, 0.2037, 0.8571, 0.2251]}, {"w": "by", "b": [0.1429, 0.2227, 0.163, 0.2442]}, {"w": "experts:", "b": [0.1709, 0.2227, 0.2358, 0.2442]}, {"w": "a", "b": [0.2437, 0.2227, 0.2529, 0.2442]}, {"w": "team", "b": [0.2607, 0.2227, 0.3022, 0.2442]}, {"w": "gathers", "b": [0.31, 0.2227, 0.3703, 0.2442]}, {"w": "up-to-date", "b": [0.3781, 0.2227, 0.4669, 0.2442]}, {"w": "information", "b": [0.4748, 0.2227, 0.576, 0.2442]}, {"w": "about", "b": [0.5839, 0.2227, 0.6317, 0.2442]}, {"w": "a", "b": [0.6396, 0.2227, 0.6487, 0.2442]}, {"w": "district,", "b": [0.6566, 0.2227, 0.7204, 0.2442]}, {"w": "and", "b": [0.7283, 0.2227, 0.7598, 0.2442]}, {"w": "when", "b": [0.7677, 0.2227, 0.8134, 0.2442]}, {"w": "they", "b": [0.8213, 0.2227, 0.8572, 0.2442]}, {"w": "cannot", "b": [0.1429, 0.2418, 0.2006, 0.2632]}, {"w": "get", "b": [0.2053, 0.2418, 0.2303, 0.2632]}, {"w": "the", "b": [0.235, 0.2418, 0.2613, 0.2632]}, {"w": "median", "b": [0.2661, 0.2418, 0.3291, 0.2632]}, {"w": "housing", "b": [0.3338, 0.2418, 0.401, 0.2632]}, {"w": "price,", "b": [0.4058, 0.2418, 0.4524, 0.2632]}, {"w": "they", "b": [0.4571, 0.2418, 0.493, 0.2632]}, {"w": "estimate", "b": [0.4978, 0.2418, 0.5672, 0.2632]}, {"w": "it", "b": [0.5719, 0.2418, 0.5839, 0.2632]}, {"w": "using", "b": [0.5886, 0.2418, 0.634, 0.2632]}, {"w": "complex", "b": [0.6388, 0.2418, 0.7098, 0.2632]}, {"w": "rules.", "b": [0.7145, 0.2418, 0.7598, 0.2632]}]}, {"id": "b_2", "type": "paragraph", "text": "This is costly and time-consuming, and their estimates are not great; in cases where they manage to find out the actual median housing price, they often realize that their estimates were off by more than 20%. This is why the company thinks that it would be useful to train a model to predict a district’s median housing price given other data about that district. The census data looks like a great dataset to exploit for this pur‐ pose, since it includes the median housing prices of thousands of districts, as well as other data.", "words": [{"w": "This", "b": [0.1429, 0.2699, 0.1801, 0.2913]}, {"w": "is", "b": [0.1864, 0.2699, 0.1996, 0.2913]}, {"w": "costly", "b": [0.2059, 0.2699, 0.2542, 0.2913]}, {"w": "and", "b": [0.2605, 0.2699, 0.2921, 0.2913]}, {"w": "time-consuming,", "b": [0.2984, 0.2699, 0.4417, 0.2913]}, {"w": "and", "b": [0.4481, 0.2699, 0.4796, 0.2913]}, {"w": "their", "b": [0.4859, 0.2699, 0.5256, 0.2913]}, {"w": "estimates", "b": [0.5319, 0.2699, 0.609, 0.2913]}, {"w": "are", "b": [0.6153, 0.2699, 0.6411, 0.2913]}, {"w": "not", "b": [0.6474, 0.2699, 0.6758, 0.2913]}, {"w": "great;", "b": [0.6821, 0.2699, 0.7283, 0.2913]}, {"w": "in", "b": [0.7346, 0.2699, 0.7516, 0.2913]}, {"w": "cases", "b": [0.7579, 0.2699, 0.8, 0.2913]}, {"w": "where", "b": [0.8063, 0.2699, 0.8571, 0.2913]}, {"w": "they", "b": [0.1429, 0.289, 0.1787, 0.3104]}, {"w": "manage", "b": [0.1841, 0.289, 0.2495, 0.3104]}, {"w": "to", "b": [0.2548, 0.289, 0.2718, 0.3104]}, {"w": "find", "b": [0.2772, 0.289, 0.3113, 0.3104]}, {"w": "out", "b": [0.3167, 0.289, 0.3447, 0.3104]}, {"w": "the", "b": [0.3501, 0.289, 0.3764, 0.3104]}, {"w": "actual", "b": [0.3818, 0.289, 0.4316, 0.3104]}, {"w": "median", "b": [0.437, 0.289, 0.5, 0.3104]}, {"w": "housing", "b": [0.5054, 0.289, 0.5726, 0.3104]}, {"w": "price,", "b": [0.5779, 0.289, 0.6246, 0.3104]}, {"w": "they", "b": [0.63, 0.289, 0.6659, 0.3104]}, {"w": "often", "b": [0.6712, 0.289, 0.7146, 0.3104]}, {"w": "realize", "b": [0.72, 0.289, 0.7742, 0.3104]}, {"w": "that", "b": [0.7795, 0.289, 0.8121, 0.3104]}, {"w": "their", "b": [0.8175, 0.289, 0.8571, 0.3104]}, {"w": "estimates", "b": [0.1429, 0.308, 0.22, 0.3294]}, {"w": "were", "b": [0.2263, 0.308, 0.266, 0.3294]}, {"w": "off", "b": [0.2723, 0.308, 0.2952, 0.3294]}, {"w": "by", "b": [0.3015, 0.308, 0.3217, 0.3294]}, {"w": "more", "b": [0.328, 0.308, 0.3723, 0.3294]}, {"w": "than", "b": [0.3786, 0.308, 0.4166, 0.3294]}, {"w": "20%.", "b": [0.4229, 0.308, 0.4634, 0.3294]}, {"w": "This", "b": [0.4697, 0.308, 0.5069, 0.3294]}, {"w": "is", "b": [0.5132, 0.308, 0.5264, 0.3294]}, {"w": "why", "b": [0.5327, 0.308, 0.5672, 0.3294]}, {"w": "the", "b": [0.5735, 0.308, 0.5998, 0.3294]}, {"w": "company", "b": [0.6061, 0.308, 0.6828, 0.3294]}, {"w": "thinks", "b": [0.6891, 0.308, 0.7415, 0.3294]}, {"w": "that", "b": [0.7478, 0.308, 0.7804, 0.3294]}, {"w": "it", "b": [0.7867, 0.308, 0.7986, 0.3294]}, {"w": "would", "b": [0.8049, 0.308, 0.8572, 0.3294]}, {"w": "be", "b": [0.1429, 0.3271, 0.1623, 0.3485]}, {"w": "useful", "b": [0.1672, 0.3271, 0.2173, 0.3485]}, {"w": "to", "b": [0.2222, 0.3271, 0.2392, 0.3485]}, {"w": "train", "b": [0.2442, 0.3271, 0.2844, 0.3485]}, {"w": "a", "b": [0.2893, 0.3271, 0.2985, 0.3485]}, {"w": "model", "b": [0.3034, 0.3271, 0.3562, 0.3485]}, {"w": "to", "b": [0.3612, 0.3271, 0.3782, 0.3485]}, {"w": "predict", "b": [0.3831, 0.3271, 0.4423, 0.3485]}, {"w": "a", "b": [0.4473, 0.3271, 0.4564, 0.3485]}, {"w": "district’s", "b": [0.4614, 0.3271, 0.5302, 0.3485]}, {"w": "median", "b": [0.5351, 0.3271, 0.5982, 0.3485]}, {"w": "housing", "b": [0.6031, 0.3271, 0.6703, 0.3485]}, {"w": "price", "b": [0.6753, 0.3271, 0.7171, 0.3485]}, {"w": "given", "b": [0.7221, 0.3271, 0.7673, 0.3485]}, {"w": "other", "b": [0.7723, 0.3271, 0.817, 0.3485]}, {"w": "data", "b": [0.8219, 0.3271, 0.8571, 0.3485]}, {"w": "about", "b": [0.1429, 0.3461, 0.1906, 0.3675]}, {"w": "that", "b": [0.1971, 0.3461, 0.2297, 0.3675]}, {"w": "district.", "b": [0.2361, 0.3461, 0.2999, 0.3675]}, {"w": "The", "b": [0.3063, 0.3461, 0.3392, 0.3675]}, {"w": "census", "b": [0.3456, 0.3461, 0.401, 0.3675]}, {"w": "data", "b": [0.4075, 0.3461, 0.4427, 0.3675]}, {"w": "looks", "b": [0.4492, 0.3461, 0.4937, 0.3675]}, {"w": "like", "b": [0.5001, 0.3461, 0.5302, 0.3675]}, {"w": "a", "b": [0.5366, 0.3461, 0.5457, 0.3675]}, {"w": "great", "b": [0.5522, 0.3461, 0.5936, 0.3675]}, {"w": "dataset", "b": [0.6001, 0.3461, 0.6582, 0.3675]}, {"w": "to", "b": [0.6646, 0.3461, 0.6816, 0.3675]}, {"w": "exploit", "b": [0.688, 0.3461, 0.7455, 0.3675]}, {"w": "for", "b": [0.7519, 0.3461, 0.7764, 0.3675]}, {"w": "this", "b": [0.7829, 0.3461, 0.8136, 0.3675]}, {"w": "pur‐", "b": [0.82, 0.3461, 0.8571, 0.3675]}, {"w": "pose,", "b": [0.1428, 0.3652, 0.1856, 0.3866]}, {"w": "since", "b": [0.1916, 0.3652, 0.2339, 0.3866]}, {"w": "it", "b": [0.2398, 0.3652, 0.2518, 0.3866]}, {"w": "includes", "b": [0.2577, 0.3652, 0.3273, 0.3866]}, {"w": "the", "b": [0.3333, 0.3652, 0.3596, 0.3866]}, {"w": "median", "b": [0.3656, 0.3652, 0.4286, 0.3866]}, {"w": "housing", "b": [0.4345, 0.3652, 0.5017, 0.3866]}, {"w": "prices", "b": [0.5077, 0.3652, 0.5572, 0.3866]}, {"w": "of", "b": [0.5632, 0.3652, 0.58, 0.3866]}, {"w": "thousands", "b": [0.5859, 0.3652, 0.6719, 0.3866]}, {"w": "of", "b": [0.6779, 0.3652, 0.6946, 0.3866]}, {"w": "districts,", "b": [0.7006, 0.3652, 0.772, 0.3866]}, {"w": "as", "b": [0.778, 0.3652, 0.7948, 0.3866]}, {"w": "well", "b": [0.8007, 0.3652, 0.8344, 0.3866]}, {"w": "as", "b": [0.8403, 0.3652, 0.8571, 0.3866]}, {"w": "other", "b": [0.1429, 0.3842, 0.1876, 0.4056]}, {"w": "data.", "b": [0.1923, 0.3842, 0.2323, 0.4056]}]}, {"id": "b_3", "type": "paragraph", "text": "Okay, with all this information you are now ready to start designing your system. First, you need to frame the problem: is it supervised, unsupervised, or Reinforce‐ ment Learning? Is it a classification task, a regression task, or something else? Should you use batch learning or online learning techniques? Before you read on, pause and try to answer these questions for yourself.", "words": [{"w": "Okay,", "b": [0.1429, 0.4123, 0.1903, 0.4337]}, {"w": "with", "b": [0.1982, 0.4123, 0.2355, 0.4337]}, {"w": "all", "b": [0.2434, 0.4123, 0.2631, 0.4337]}, {"w": "this", "b": [0.2709, 0.4123, 0.3016, 0.4337]}, {"w": "information", "b": [0.3095, 0.4123, 0.4108, 0.4337]}, {"w": "you", "b": [0.4186, 0.4123, 0.4499, 0.4337]}, {"w": "are", "b": [0.4578, 0.4123, 0.4835, 0.4337]}, {"w": "now", "b": [0.4914, 0.4123, 0.5276, 0.4337]}, {"w": "ready", "b": [0.5355, 0.4123, 0.5818, 0.4337]}, {"w": "to", "b": [0.5897, 0.4123, 0.6066, 0.4337]}, {"w": "start", "b": [0.6145, 0.4123, 0.6517, 0.4337]}, {"w": "designing", "b": [0.6596, 0.4123, 0.7406, 0.4337]}, {"w": "your", "b": [0.7484, 0.4123, 0.7874, 0.4337]}, {"w": "system.", "b": [0.7953, 0.4123, 0.8572, 0.4337]}, {"w": "First,", "b": [0.1429, 0.4314, 0.1859, 0.4528]}, {"w": "you", "b": [0.1933, 0.4314, 0.2246, 0.4528]}, {"w": "need", "b": [0.232, 0.4314, 0.2721, 0.4528]}, {"w": "to", "b": [0.2795, 0.4314, 0.2965, 0.4528]}, {"w": "frame", "b": [0.3039, 0.4314, 0.3528, 0.4528]}, {"w": "the", "b": [0.3603, 0.4314, 0.3866, 0.4528]}, {"w": "problem:", "b": [0.394, 0.4314, 0.4698, 0.4528]}, {"w": "is", "b": [0.4772, 0.4314, 0.4904, 0.4528]}, {"w": "it", "b": [0.4978, 0.4314, 0.5098, 0.4528]}, {"w": "supervised,", "b": [0.5172, 0.4314, 0.6115, 0.4528]}, {"w": "unsupervised,", "b": [0.6189, 0.4314, 0.7356, 0.4528]}, {"w": "or", "b": [0.743, 0.4314, 0.7614, 0.4528]}, {"w": "Reinforce‐", "b": [0.7688, 0.4314, 0.8571, 0.4528]}, {"w": "ment", "b": [0.1429, 0.4504, 0.1861, 0.4718]}, {"w": "Learning?", "b": [0.1915, 0.4504, 0.2744, 0.4718]}, {"w": "Is", "b": [0.2798, 0.4504, 0.2941, 0.4718]}, {"w": "it", "b": [0.2994, 0.4504, 0.3114, 0.4718]}, {"w": "a", "b": [0.3167, 0.4504, 0.3259, 0.4718]}, {"w": "classification", "b": [0.3312, 0.4504, 0.4386, 0.4718]}, {"w": "task,", "b": [0.444, 0.4504, 0.4822, 0.4718]}, {"w": "a", "b": [0.4876, 0.4504, 0.4967, 0.4718]}, {"w": "regression", "b": [0.5021, 0.4504, 0.5879, 0.4718]}, {"w": "task,", "b": [0.5932, 0.4504, 0.6315, 0.4718]}, {"w": "or", "b": [0.6368, 0.4504, 0.6552, 0.4718]}, {"w": "something", "b": [0.6605, 0.4504, 0.7489, 0.4718]}, {"w": "else?", "b": [0.7543, 0.4504, 0.7928, 0.4718]}, {"w": "Should", "b": [0.7982, 0.4504, 0.8571, 0.4718]}, {"w": "you", "b": [0.1428, 0.4695, 0.1741, 0.4909]}, {"w": "use", "b": [0.1797, 0.4695, 0.2073, 0.4909]}, {"w": "batch", "b": [0.213, 0.4695, 0.2586, 0.4909]}, {"w": "learning", "b": [0.2642, 0.4695, 0.3334, 0.4909]}, {"w": "or", "b": [0.339, 0.4695, 0.3574, 0.4909]}, {"w": "online", "b": [0.363, 0.4695, 0.4161, 0.4909]}, {"w": "learning", "b": [0.4218, 0.4695, 0.4909, 0.4909]}, {"w": "techniques?", "b": [0.4966, 0.4695, 0.5948, 0.4909]}, {"w": "Before", "b": [0.6005, 0.4695, 0.6554, 0.4909]}, {"w": "you", "b": [0.661, 0.4695, 0.6923, 0.4909]}, {"w": "read", "b": [0.6979, 0.4695, 0.7346, 0.4909]}, {"w": "on,", "b": [0.7403, 0.4695, 0.7671, 0.4909]}, {"w": "pause", "b": [0.7727, 0.4695, 0.8199, 0.4909]}, {"w": "and", "b": [0.8256, 0.4695, 0.8571, 0.4909]}, {"w": "try", "b": [0.1429, 0.4885, 0.1671, 0.5099]}, {"w": "to", "b": [0.1718, 0.4885, 0.1888, 0.5099]}, {"w": "answer", "b": [0.1935, 0.4885, 0.2526, 0.5099]}, {"w": "these", "b": [0.2573, 0.4885, 0.3002, 0.5099]}, {"w": "questions", "b": [0.3049, 0.4885, 0.3847, 0.5099]}, {"w": "for", "b": [0.3894, 0.4885, 0.4139, 0.5099]}, {"w": "yourself.", "b": [0.4187, 0.4885, 0.4903, 0.5099]}]}, {"id": "b_4", "type": "paragraph", "text": "Have you found the answers? Let’s see: it is clearly a typical supervised learning task since you are given labeled training examples (each instance comes with the expected output, i.e., the district’s median housing price). Moreover, it is also a typical regres‐ sion task, since you are asked to predict a value. More specifically, this is a multiple regression problem since the system will use multiple features to make a prediction (it will use the district’s population, the median income, etc.). It is also a univariate regression problem since we are only trying to predict a single value for each district. If we were trying to predict multiple values per district, it would be a multivariate regression problem. Finally, there is no continuous flow of data coming in the system, there is no particular need to adjust to changing data rapidly, and the data is small enough to fit in memory, so plain batch learning should do just fine.", "words": [{"w": "Have", "b": [0.1429, 0.5166, 0.1856, 0.538]}, {"w": "you", "b": [0.1917, 0.5166, 0.223, 0.538]}, {"w": "found", "b": [0.2291, 0.5166, 0.2794, 0.538]}, {"w": "the", "b": [0.2855, 0.5166, 0.3119, 0.538]}, {"w": "answers?", "b": [0.318, 0.5166, 0.3926, 0.538]}, {"w": "Let’s", "b": [0.3988, 0.5166, 0.4349, 0.538]}, {"w": "see:", "b": [0.4411, 0.5166, 0.4712, 0.538]}, {"w": "it", "b": [0.4773, 0.5166, 0.4893, 0.538]}, {"w": "is", "b": [0.4954, 0.5166, 0.5087, 0.538]}, {"w": "clearly", "b": [0.5148, 0.5166, 0.5695, 0.538]}, {"w": "a", "b": [0.5756, 0.5166, 0.5848, 0.538]}, {"w": "typical", "b": [0.5909, 0.5166, 0.6465, 0.538]}, {"w": "supervised", "b": [0.6527, 0.5166, 0.7422, 0.538]}, {"w": "learning", "b": [0.7484, 0.5166, 0.8175, 0.538]}, {"w": "task", "b": [0.8237, 0.5166, 0.8571, 0.538]}, {"w": "since", "b": [0.1429, 0.5357, 0.1851, 0.5571]}, {"w": "you", "b": [0.1905, 0.5357, 0.2218, 0.5571]}, {"w": "are", "b": [0.2271, 0.5357, 0.2529, 0.5571]}, {"w": "given", "b": [0.2582, 0.5357, 0.3035, 0.5571]}, {"w": "labeled", "b": [0.3088, 0.5355, 0.3656, 0.5571]}, {"w": "training", "b": [0.371, 0.5357, 0.4379, 0.5571]}, {"w": "examples", "b": [0.4433, 0.5357, 0.5205, 0.5571]}, {"w": "(each", "b": [0.5258, 0.5357, 0.571, 0.5571]}, {"w": "instance", "b": [0.5763, 0.5357, 0.6455, 0.5571]}, {"w": "comes", "b": [0.6509, 0.5357, 0.7039, 0.5571]}, {"w": "with", "b": [0.7093, 0.5357, 0.7466, 0.5571]}, {"w": "the", "b": [0.752, 0.5357, 0.7783, 0.5571]}, {"w": "expected", "b": [0.7837, 0.5357, 0.8571, 0.5571]}, {"w": "output,", "b": [0.1428, 0.5547, 0.204, 0.5761]}, {"w": "i.e.,", "b": [0.2101, 0.5547, 0.2387, 0.5761]}, {"w": "the", "b": [0.2448, 0.5547, 0.2712, 0.5761]}, {"w": "district’s", "b": [0.2772, 0.5547, 0.3461, 0.5761]}, {"w": "median", "b": [0.3521, 0.5547, 0.4152, 0.5761]}, {"w": "housing", "b": [0.4213, 0.5547, 0.4885, 0.5761]}, {"w": "price).", "b": [0.4945, 0.5547, 0.5484, 0.5761]}, {"w": "Moreover,", "b": [0.5545, 0.5547, 0.64, 0.5761]}, {"w": "it", "b": [0.6461, 0.5547, 0.658, 0.5761]}, {"w": "is", "b": [0.6641, 0.5547, 0.6773, 0.5761]}, {"w": "also", "b": [0.6834, 0.5547, 0.7161, 0.5761]}, {"w": "a", "b": [0.7222, 0.5547, 0.7313, 0.5761]}, {"w": "typical", "b": [0.7374, 0.5547, 0.7931, 0.5761]}, {"w": "regres‐", "b": [0.7992, 0.5547, 0.8571, 0.5761]}, {"w": "sion", "b": [0.1429, 0.5738, 0.1781, 0.5952]}, {"w": "task,", "b": [0.1848, 0.5738, 0.223, 0.5952]}, {"w": "since", "b": [0.2297, 0.5738, 0.272, 0.5952]}, {"w": "you", "b": [0.2787, 0.5738, 0.3099, 0.5952]}, {"w": "are", "b": [0.3166, 0.5738, 0.3424, 0.5952]}, {"w": "asked", "b": [0.349, 0.5738, 0.396, 0.5952]}, {"w": "to", "b": [0.4027, 0.5738, 0.4197, 0.5952]}, {"w": "predict", "b": [0.4264, 0.5738, 0.4856, 0.5952]}, {"w": "a", "b": [0.4923, 0.5738, 0.5015, 0.5952]}, {"w": "value.", "b": [0.5082, 0.5738, 0.5569, 0.5952]}, {"w": "More", "b": [0.5636, 0.5738, 0.6088, 0.5952]}, {"w": "specifically,", "b": [0.6155, 0.5738, 0.7103, 0.5952]}, {"w": "this", "b": [0.717, 0.5738, 0.7477, 0.5952]}, {"w": "is", "b": [0.7544, 0.5738, 0.7676, 0.5952]}, {"w": "a", "b": [0.7743, 0.5738, 0.7835, 0.5952]}, {"w": "multiple", "b": [0.7902, 0.5736, 0.8571, 0.5952]}, {"w": "regression", "b": [0.1429, 0.5926, 0.2224, 0.6142]}, {"w": "problem", "b": [0.2276, 0.5928, 0.2986, 0.6142]}, {"w": "since", "b": [0.3038, 0.5928, 0.3461, 0.6142]}, {"w": "the", "b": [0.3512, 0.5928, 0.3775, 0.6142]}, {"w": "system", "b": [0.3827, 0.5928, 0.4398, 0.6142]}, {"w": "will", "b": [0.445, 0.5928, 0.4754, 0.6142]}, {"w": "use", "b": [0.4805, 0.5928, 0.5081, 0.6142]}, {"w": "multiple", "b": [0.5133, 0.5928, 0.5833, 0.6142]}, {"w": "features", "b": [0.5884, 0.5928, 0.6538, 0.6142]}, {"w": "to", "b": [0.659, 0.5928, 0.676, 0.6142]}, {"w": "make", "b": [0.6811, 0.5928, 0.7265, 0.6142]}, {"w": "a", "b": [0.7317, 0.5928, 0.7408, 0.6142]}, {"w": "prediction", "b": [0.746, 0.5928, 0.8328, 0.6142]}, {"w": "(it", "b": [0.838, 0.5928, 0.8571, 0.6142]}, {"w": "will", "b": [0.1429, 0.6119, 0.1733, 0.6333]}, {"w": "use", "b": [0.1822, 0.6119, 0.2098, 0.6333]}, {"w": "the", "b": [0.2187, 0.6119, 0.245, 0.6333]}, {"w": "district’s", "b": [0.254, 0.6119, 0.3228, 0.6333]}, {"w": "population,", "b": [0.3317, 0.6119, 0.428, 0.6333]}, {"w": "the", "b": [0.4369, 0.6119, 0.4633, 0.6333]}, {"w": "median", "b": [0.4722, 0.6119, 0.5353, 0.6333]}, {"w": "income,", "b": [0.5442, 0.6119, 0.6113, 0.6333]}, {"w": "etc.).", "b": [0.6202, 0.6119, 0.661, 0.6333]}, {"w": "It", "b": [0.6699, 0.6119, 0.6826, 0.6333]}, {"w": "is", "b": [0.6915, 0.6119, 0.7047, 0.6333]}, {"w": "also", "b": [0.7137, 0.6119, 0.7464, 0.6333]}, {"w": "a", "b": [0.7553, 0.6119, 0.7645, 0.6333]}, {"w": "univariate", "b": [0.7734, 0.6117, 0.8571, 0.6333]}, {"w": "regression", "b": [0.1429, 0.6307, 0.2224, 0.6523]}, {"w": "problem", "b": [0.2281, 0.6309, 0.2992, 0.6523]}, {"w": "since", "b": [0.3049, 0.6309, 0.3472, 0.6523]}, {"w": "we", "b": [0.353, 0.6309, 0.3761, 0.6523]}, {"w": "are", "b": [0.3819, 0.6309, 0.4076, 0.6523]}, {"w": "only", "b": [0.4134, 0.6309, 0.4502, 0.6523]}, {"w": "trying", "b": [0.456, 0.6309, 0.507, 0.6523]}, {"w": "to", "b": [0.5127, 0.6309, 0.5297, 0.6523]}, {"w": "predict", "b": [0.5354, 0.6309, 0.5947, 0.6523]}, {"w": "a", "b": [0.6005, 0.6309, 0.6096, 0.6523]}, {"w": "single", "b": [0.6154, 0.6309, 0.6639, 0.6523]}, {"w": "value", "b": [0.6696, 0.6309, 0.7136, 0.6523]}, {"w": "for", "b": [0.7194, 0.6309, 0.7439, 0.6523]}, {"w": "each", "b": [0.7496, 0.6309, 0.7876, 0.6523]}, {"w": "district.", "b": [0.7933, 0.6309, 0.8571, 0.6523]}, {"w": "If", "b": [0.1429, 0.65, 0.1561, 0.6714]}, {"w": "we", "b": [0.1636, 0.65, 0.1868, 0.6714]}, {"w": "were", "b": [0.1943, 0.65, 0.234, 0.6714]}, {"w": "trying", "b": [0.2415, 0.65, 0.2924, 0.6714]}, {"w": "to", "b": [0.2999, 0.65, 0.3169, 0.6714]}, {"w": "predict", "b": [0.3244, 0.65, 0.3837, 0.6714]}, {"w": "multiple", "b": [0.3912, 0.65, 0.4612, 0.6714]}, {"w": "values", "b": [0.4687, 0.65, 0.5203, 0.6714]}, {"w": "per", "b": [0.5278, 0.65, 0.5553, 0.6714]}, {"w": "district,", "b": [0.5628, 0.65, 0.6266, 0.6714]}, {"w": "it", "b": [0.6341, 0.65, 0.646, 0.6714]}, {"w": "would", "b": [0.6535, 0.65, 0.7058, 0.6714]}, {"w": "be", "b": [0.7133, 0.65, 0.7327, 0.6714]}, {"w": "a", "b": [0.7402, 0.65, 0.7493, 0.6714]}, {"w": "multivariate", "b": [0.7568, 0.6498, 0.8572, 0.6714]}, {"w": "regression", "b": [0.1429, 0.6688, 0.2224, 0.6904]}, {"w": "problem.", "b": [0.2278, 0.669, 0.3035, 0.6904]}, {"w": "Finally,", "b": [0.3089, 0.669, 0.3694, 0.6904]}, {"w": "there", "b": [0.3748, 0.669, 0.4177, 0.6904]}, {"w": "is", "b": [0.423, 0.669, 0.4363, 0.6904]}, {"w": "no", "b": [0.4416, 0.669, 0.4637, 0.6904]}, {"w": "continuous", "b": [0.469, 0.669, 0.5628, 0.6904]}, {"w": "flow", "b": [0.5682, 0.669, 0.6045, 0.6904]}, {"w": "of", "b": [0.6099, 0.669, 0.6266, 0.6904]}, {"w": "data", "b": [0.632, 0.669, 0.6673, 0.6904]}, {"w": "coming", "b": [0.6726, 0.669, 0.7359, 0.6904]}, {"w": "in", "b": [0.7412, 0.669, 0.7582, 0.6904]}, {"w": "the", "b": [0.7636, 0.669, 0.7899, 0.6904]}, {"w": "system,", "b": [0.7953, 0.669, 0.8571, 0.6904]}, {"w": "there", "b": [0.1429, 0.6881, 0.1858, 0.7095]}, {"w": "is", "b": [0.1928, 0.6881, 0.206, 0.7095]}, {"w": "no", "b": [0.213, 0.6881, 0.235, 0.7095]}, {"w": "particular", "b": [0.242, 0.6881, 0.3237, 0.7095]}, {"w": "need", "b": [0.3307, 0.6881, 0.3708, 0.7095]}, {"w": "to", "b": [0.3778, 0.6881, 0.3948, 0.7095]}, {"w": "adjust", "b": [0.4018, 0.6881, 0.4523, 0.7095]}, {"w": "to", "b": [0.4593, 0.6881, 0.4763, 0.7095]}, {"w": "changing", "b": [0.4833, 0.6881, 0.5602, 0.7095]}, {"w": "data", "b": [0.5672, 0.6881, 0.6025, 0.7095]}, {"w": "rapidly,", "b": [0.6094, 0.6881, 0.6715, 0.7095]}, {"w": "and", "b": [0.6785, 0.6881, 0.71, 0.7095]}, {"w": "the", "b": [0.717, 0.6881, 0.7433, 0.7095]}, {"w": "data", "b": [0.7503, 0.6881, 0.7856, 0.7095]}, {"w": "is", "b": [0.7925, 0.6881, 0.8058, 0.7095]}, {"w": "small", "b": [0.8128, 0.6881, 0.8571, 0.7095]}, {"w": "enough", "b": [0.1429, 0.7071, 0.2057, 0.7285]}, {"w": "to", "b": [0.2104, 0.7071, 0.2274, 0.7285]}, {"w": "fit", "b": [0.2321, 0.7071, 0.2502, 0.7285]}, {"w": "in", "b": [0.2549, 0.7071, 0.2719, 0.7285]}, {"w": "memory,", "b": [0.2766, 0.7071, 0.3514, 0.7285]}, {"w": "so", "b": [0.3561, 0.7071, 0.3744, 0.7285]}, {"w": "plain", "b": [0.3791, 0.7071, 0.4214, 0.7285]}, {"w": "batch", "b": [0.4261, 0.7071, 0.4718, 0.7285]}, {"w": "learning", "b": [0.4765, 0.7071, 0.5456, 0.7285]}, {"w": "should", "b": [0.5504, 0.7071, 0.6071, 0.7285]}, {"w": "do", "b": [0.6118, 0.7071, 0.6334, 0.7285]}, {"w": "just", "b": [0.6382, 0.7071, 0.6686, 0.7285]}, {"w": "fine.", "b": [0.6733, 0.7071, 0.71, 0.7285]}]}, {"id": "b_5", "type": "paragraph", "text": "If the data was huge, you could either split your batch learning work across multiple servers (using the MapReduce technique), or you could use an online learning technique instead.", "words": [{"w": "If", "b": [0.2714, 0.749, 0.2835, 0.7686]}, {"w": "the", "b": [0.2915, 0.749, 0.3156, 0.7686]}, {"w": "data", "b": [0.3235, 0.749, 0.3557, 0.7686]}, {"w": "was", "b": [0.3637, 0.749, 0.3921, 0.7686]}, {"w": "huge,", "b": [0.4, 0.749, 0.4413, 0.7686]}, {"w": "you", "b": [0.4492, 0.749, 0.4778, 0.7686]}, {"w": "could", "b": [0.4857, 0.749, 0.5285, 0.7686]}, {"w": "either", "b": [0.5364, 0.749, 0.5807, 0.7686]}, {"w": "split", "b": [0.5887, 0.749, 0.6214, 0.7686]}, {"w": "your", "b": [0.6293, 0.749, 0.6649, 0.7686]}, {"w": "batch", "b": [0.6729, 0.749, 0.7146, 0.7686]}, {"w": "learning", "b": [0.7225, 0.749, 0.7857, 0.7686]}, {"w": "work", "b": [0.2714, 0.7665, 0.3107, 0.786]}, {"w": "across", "b": [0.3166, 0.7665, 0.3638, 0.786]}, {"w": "multiple", "b": [0.3696, 0.7665, 0.4336, 0.786]}, {"w": "servers", "b": [0.4395, 0.7665, 0.4932, 0.786]}, {"w": "(using", "b": [0.4991, 0.7665, 0.5472, 0.786]}, {"w": "the", "b": [0.5531, 0.7665, 0.5771, 0.786]}, {"w": "MapReduce", "b": [0.583, 0.7663, 0.6706, 0.786]}, {"w": "technique),", "b": [0.6765, 0.7665, 0.7631, 0.786]}, {"w": "or", "b": [0.7689, 0.7665, 0.7857, 0.786]}, {"w": "you", "b": [0.2714, 0.7839, 0.3, 0.8035]}, {"w": "could", "b": [0.3043, 0.7839, 0.3471, 0.8035]}, {"w": "use", "b": [0.3514, 0.7839, 0.3766, 0.8035]}, {"w": "an", "b": [0.3809, 0.7839, 0.3997, 0.8035]}, {"w": "online", "b": [0.404, 0.7839, 0.4526, 0.8035]}, {"w": "learning", "b": [0.4569, 0.7839, 0.5201, 0.8035]}, {"w": "technique", "b": [0.5244, 0.7839, 0.6, 0.8035]}, {"w": "instead.", "b": [0.6044, 0.7839, 0.6635, 0.8035]}]}, {"id": "b_6", "type": "paragraph", "text": "Look at the Big Picture | 41", "words": [{"w": "Look", "b": [0.6708, 0.9225, 0.6988, 0.9388]}, {"w": "at", "b": [0.7016, 0.9225, 0.7138, 0.9388]}, {"w": "the", "b": [0.7166, 0.9225, 0.7365, 0.9388]}, {"w": "Big", "b": [0.7393, 0.9225, 0.7587, 0.9388]}, {"w": "Picture", "b": [0.7615, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "41", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 68, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Select a Performance Measure", "words": [{"w": "Select", "b": [0.1429, 0.0763, 0.2047, 0.1049]}, {"w": "a", "b": [0.2096, 0.0763, 0.222, 0.1049]}, {"w": "Performance", "b": [0.227, 0.0763, 0.3594, 0.1049]}, {"w": "Measure", "b": [0.3643, 0.0763, 0.4523, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "Your next step is to select a performance measure. A typical performance measure for regression problems is the Root Mean Square Error (RMSE). It gives an idea of how much error the system typically makes in its predictions, with a higher weight for large errors. Equation 2-1 shows the mathematical formula to compute the RMSE.", "words": [{"w": "Your", "b": [0.1429, 0.1108, 0.1829, 0.1322]}, {"w": "next", "b": [0.1879, 0.1108, 0.2243, 0.1322]}, {"w": "step", "b": [0.2293, 0.1108, 0.263, 0.1322]}, {"w": "is", "b": [0.268, 0.1108, 0.2812, 0.1322]}, {"w": "to", "b": [0.2861, 0.1108, 0.3031, 0.1322]}, {"w": "select", "b": [0.3081, 0.1108, 0.3539, 0.1322]}, {"w": "a", "b": [0.3588, 0.1108, 0.3679, 0.1322]}, {"w": "performance", "b": [0.3729, 0.1108, 0.4802, 0.1322]}, {"w": "measure.", "b": [0.4851, 0.1108, 0.5602, 0.1322]}, {"w": "A", "b": [0.5652, 0.1108, 0.5796, 0.1322]}, {"w": "typical", "b": [0.5845, 0.1108, 0.6401, 0.1322]}, {"w": "performance", "b": [0.6451, 0.1108, 0.7524, 0.1322]}, {"w": "measure", "b": [0.7573, 0.1108, 0.8277, 0.1322]}, {"w": "for", "b": [0.8326, 0.1108, 0.8571, 0.1322]}, {"w": "regression", "b": [0.1429, 0.1298, 0.2287, 0.1512]}, {"w": "problems", "b": [0.2347, 0.1298, 0.3134, 0.1512]}, {"w": "is", "b": [0.3195, 0.1298, 0.3327, 0.1512]}, {"w": "the", "b": [0.3388, 0.1298, 0.3651, 0.1512]}, {"w": "Root", "b": [0.3712, 0.1298, 0.4117, 0.1512]}, {"w": "Mean", "b": [0.4178, 0.1298, 0.4652, 0.1512]}, {"w": "Square", "b": [0.4713, 0.1298, 0.5286, 0.1512]}, {"w": "Error", "b": [0.5346, 0.1298, 0.5803, 0.1512]}, {"w": "(RMSE).", "b": [0.5863, 0.1298, 0.6587, 0.1512]}, {"w": "It", "b": [0.6648, 0.1298, 0.6774, 0.1512]}, {"w": "gives", "b": [0.6835, 0.1298, 0.725, 0.1512]}, {"w": "an", "b": [0.731, 0.1298, 0.7516, 0.1512]}, {"w": "idea", "b": [0.7576, 0.1298, 0.7922, 0.1512]}, {"w": "of", "b": [0.7983, 0.1298, 0.8151, 0.1512]}, {"w": "how", "b": [0.8211, 0.1298, 0.8572, 0.1512]}, {"w": "much", "b": [0.1429, 0.1489, 0.1905, 0.1703]}, {"w": "error", "b": [0.1983, 0.1489, 0.2409, 0.1703]}, {"w": "the", "b": [0.2486, 0.1489, 0.275, 0.1703]}, {"w": "system", "b": [0.2827, 0.1489, 0.3398, 0.1703]}, {"w": "typically", "b": [0.3476, 0.1489, 0.418, 0.1703]}, {"w": "makes", "b": [0.4258, 0.1489, 0.4788, 0.1703]}, {"w": "in", "b": [0.4865, 0.1489, 0.5035, 0.1703]}, {"w": "its", "b": [0.5112, 0.1489, 0.5308, 0.1703]}, {"w": "predictions,", "b": [0.5386, 0.1489, 0.6378, 0.1703]}, {"w": "with", "b": [0.6455, 0.1489, 0.6829, 0.1703]}, {"w": "a", "b": [0.6906, 0.1489, 0.6997, 0.1703]}, {"w": "higher", "b": [0.7075, 0.1489, 0.7616, 0.1703]}, {"w": "weight", "b": [0.7694, 0.1489, 0.8249, 0.1703]}, {"w": "for", "b": [0.8326, 0.1489, 0.8571, 0.1703]}, {"w": "large", "b": [0.1429, 0.1679, 0.1836, 0.1893]}, {"w": "errors.", "b": [0.1883, 0.1679, 0.2434, 0.1893]}, {"w": "Equation", "b": [0.2481, 0.1679, 0.3244, 0.1893]}, {"w": "2-1", "b": [0.3291, 0.1679, 0.3565, 0.1893]}, {"w": "shows", "b": [0.3612, 0.1679, 0.4126, 0.1893]}, {"w": "the", "b": [0.4173, 0.1679, 0.4436, 0.1893]}, {"w": "mathematical", "b": [0.4484, 0.1679, 0.5615, 0.1893]}, {"w": "formula", "b": [0.5662, 0.1679, 0.6329, 0.1893]}, {"w": "to", "b": [0.6376, 0.1679, 0.6546, 0.1893]}, {"w": "compute", "b": [0.6593, 0.1679, 0.7326, 0.1893]}, {"w": "the", "b": [0.7373, 0.1679, 0.7637, 0.1893]}, {"w": "RMSE.", "b": [0.7684, 0.1679, 0.8264, 0.1893]}]}, {"id": "b_2", "type": "equation", "text": "Equation 2-1. Root Mean Square Error (RMSE)", "words": [{"w": "Equation", "b": [0.1726, 0.2075, 0.2473, 0.2291]}, {"w": "2-1.", "b": [0.2521, 0.2075, 0.2838, 0.2291]}, {"w": "Root", "b": [0.2886, 0.2075, 0.3266, 0.2291]}, {"w": "Mean", "b": [0.3314, 0.2075, 0.3782, 0.2291]}, {"w": "Square", "b": [0.383, 0.2075, 0.4391, 0.2291]}, {"w": "Error", "b": [0.4438, 0.2075, 0.4874, 0.2291]}, {"w": "(RMSE)", "b": [0.4922, 0.2075, 0.5581, 0.2291]}]}, {"id": "b_3", "type": "equation", "text": "RMSE X, h = 1 m ∑", "words": [{"w": "RMSE", "b": [0.1726, 0.2517, 0.2233, 0.2721]}, {"w": "X,", "b": [0.2302, 0.2512, 0.2484, 0.2721]}, {"w": "h", "b": [0.2517, 0.2515, 0.2619, 0.2721]}, {"w": "=", "b": [0.2742, 0.2517, 0.2858, 0.2721]}, {"w": "1", "b": [0.3087, 0.2429, 0.3182, 0.2633]}, {"w": "m", "b": [0.3056, 0.2603, 0.3213, 0.2809]}, {"w": "∑", "b": [0.332, 0.2469, 0.3471, 0.2757]}]}, {"id": "b_4", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.3246, 0.2664, 0.3289, 0.2828]}, {"w": "=", "b": [0.3333, 0.2665, 0.3425, 0.2828]}, {"w": "1", "b": [0.3469, 0.2665, 0.3545, 0.2828]}]}, {"id": "b_6", "type": "paragraph", "text": "h x i −y i 2", "words": [{"w": "h", "b": [0.3636, 0.2515, 0.3737, 0.2721]}, {"w": "x", "b": [0.3806, 0.2512, 0.3902, 0.2721]}, {"w": "i", "b": [0.3958, 0.2478, 0.4001, 0.2643]}, {"w": "−y", "b": [0.4169, 0.2515, 0.4427, 0.2721]}, {"w": "i", "b": [0.4482, 0.2478, 0.4525, 0.2643]}, {"w": "2", "b": [0.4649, 0.2446, 0.4725, 0.2609]}]}, {"id": "b_7", "type": "equation", "text": "42 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "42", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 69, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "4 Recall that the transpose operator flips a column vector into a row vector (and vice versa).", "words": [{"w": "4", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "Recall", "b": [0.1587, 0.8749, 0.197, 0.8912]}, {"w": "that", "b": [0.2007, 0.8749, 0.2255, 0.8912]}, {"w": "the", "b": [0.2291, 0.8749, 0.2491, 0.8912]}, {"w": "transpose", "b": [0.2527, 0.8749, 0.3139, 0.8912]}, {"w": "operator", "b": [0.3175, 0.8749, 0.3721, 0.8912]}, {"w": "flips", "b": [0.3757, 0.8749, 0.4028, 0.8912]}, {"w": "a", "b": [0.4064, 0.8749, 0.4134, 0.8912]}, {"w": "column", "b": [0.417, 0.8749, 0.4659, 0.8912]}, {"w": "vector", "b": [0.4695, 0.8749, 0.5091, 0.8912]}, {"w": "into", "b": [0.5127, 0.8749, 0.5383, 0.8912]}, {"w": "a", "b": [0.5419, 0.8749, 0.5489, 0.8912]}, {"w": "row", "b": [0.5525, 0.8749, 0.5773, 0.8912]}, {"w": "vector", "b": [0.581, 0.8749, 0.6206, 0.8912]}, {"w": "(and", "b": [0.6242, 0.8749, 0.6537, 0.8912]}, {"w": "vice", "b": [0.6573, 0.8749, 0.6824, 0.8912]}, {"w": "versa).", "b": [0.686, 0.8749, 0.7279, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Notations", "words": [{"w": "Notations", "b": [0.452, 0.0921, 0.548, 0.1192]}]}, {"id": "b_2", "type": "paragraph", "text": "This equation introduces several very common Machine Learning notations that we will use throughout this book:", "words": [{"w": "This", "b": [0.1592, 0.1238, 0.1947, 0.1442]}, {"w": "equation", "b": [0.2008, 0.1238, 0.2706, 0.1442]}, {"w": "introduces", "b": [0.2768, 0.1238, 0.3612, 0.1442]}, {"w": "several", "b": [0.3674, 0.1238, 0.4218, 0.1442]}, {"w": "very", "b": [0.428, 0.1238, 0.4626, 0.1442]}, {"w": "common", "b": [0.4688, 0.1238, 0.5408, 0.1442]}, {"w": "Machine", "b": [0.547, 0.1238, 0.6166, 0.1442]}, {"w": "Learning", "b": [0.6228, 0.1238, 0.6943, 0.1442]}, {"w": "notations", "b": [0.7004, 0.1238, 0.7754, 0.1442]}, {"w": "that", "b": [0.7816, 0.1238, 0.8126, 0.1442]}, {"w": "we", "b": [0.8188, 0.1238, 0.8408, 0.1442]}, {"w": "will", "b": [0.1592, 0.1419, 0.1882, 0.1623]}, {"w": "use", "b": [0.1927, 0.1419, 0.2189, 0.1623]}, {"w": "throughout", "b": [0.2234, 0.1419, 0.3147, 0.1623]}, {"w": "this", "b": [0.3192, 0.1419, 0.3484, 0.1623]}, {"w": "book:", "b": [0.3529, 0.1419, 0.3976, 0.1623]}]}, {"id": "b_3", "type": "paragraph", "text": "• m is the number of instances in the dataset you are measuring the RMSE on.", "words": [{"w": "•", "b": [0.1773, 0.1752, 0.185, 0.1956]}, {"w": "m", "b": [0.1949, 0.175, 0.2106, 0.1956]}, {"w": "is", "b": [0.2151, 0.1752, 0.2277, 0.1956]}, {"w": "the", "b": [0.2322, 0.1752, 0.2572, 0.1956]}, {"w": "number", "b": [0.2617, 0.1752, 0.3249, 0.1956]}, {"w": "of", "b": [0.3294, 0.1752, 0.3454, 0.1956]}, {"w": "instances", "b": [0.3499, 0.1752, 0.4231, 0.1956]}, {"w": "in", "b": [0.4276, 0.1752, 0.4437, 0.1956]}, {"w": "the", "b": [0.4482, 0.1752, 0.4733, 0.1956]}, {"w": "dataset", "b": [0.4778, 0.1752, 0.5332, 0.1956]}, {"w": "you", "b": [0.5377, 0.1752, 0.5674, 0.1956]}, {"w": "are", "b": [0.5719, 0.1752, 0.5964, 0.1956]}, {"w": "measuring", "b": [0.6009, 0.1752, 0.685, 0.1956]}, {"w": "the", "b": [0.6895, 0.1752, 0.7145, 0.1956]}, {"w": "RMSE", "b": [0.719, 0.1752, 0.7697, 0.1956]}, {"w": "on.", "b": [0.7742, 0.1752, 0.7997, 0.1956]}]}, {"id": "b_4", "type": "paragraph", "text": "— For example, if you are evaluating the RMSE on a validation set of 2,000 dis‐", "words": [{"w": "—", "b": [0.1985, 0.1994, 0.2168, 0.2198]}, {"w": "For", "b": [0.2207, 0.1994, 0.2483, 0.2198]}, {"w": "example,", "b": [0.254, 0.1994, 0.3247, 0.2198]}, {"w": "if", "b": [0.3304, 0.1994, 0.3416, 0.2198]}, {"w": "you", "b": [0.3472, 0.1994, 0.377, 0.2198]}, {"w": "are", "b": [0.3827, 0.1994, 0.4072, 0.2198]}, {"w": "evaluating", "b": [0.4128, 0.1994, 0.4945, 0.2198]}, {"w": "the", "b": [0.5002, 0.1994, 0.5253, 0.2198]}, {"w": "RMSE", "b": [0.5309, 0.1994, 0.5816, 0.2198]}, {"w": "on", "b": [0.5873, 0.1994, 0.6082, 0.2198]}, {"w": "a", "b": [0.6139, 0.1994, 0.6226, 0.2198]}, {"w": "validation", "b": [0.6283, 0.1994, 0.7076, 0.2198]}, {"w": "set", "b": [0.7133, 0.1994, 0.7351, 0.2198]}, {"w": "of", "b": [0.7407, 0.1994, 0.7567, 0.2198]}, {"w": "2,000", "b": [0.7624, 0.1994, 0.805, 0.2198]}, {"w": "dis‐", "b": [0.8106, 0.1994, 0.8408, 0.2198]}]}, {"id": "b_5", "type": "equation", "text": "tricts, then m = 2,000.", "words": [{"w": "tricts,", "b": [0.2207, 0.2175, 0.2657, 0.2379]}, {"w": "then", "b": [0.2702, 0.2175, 0.3062, 0.2379]}, {"w": "m", "b": [0.3107, 0.2173, 0.3263, 0.2379]}, {"w": "=", "b": [0.3308, 0.2175, 0.3423, 0.2379]}, {"w": "2,000.", "b": [0.3468, 0.2175, 0.3939, 0.2379]}]}, {"id": "b_6", "type": "paragraph", "text": "• x(i) is a vector of all the feature values (excluding the label) of the ith instance in the dataset, and y(i) is its label (the desired output value for that instance).", "words": [{"w": "•", "b": [0.1773, 0.2417, 0.185, 0.2621]}, {"w": "x(i)", "b": [0.1949, 0.2412, 0.2163, 0.2621]}, {"w": "is", "b": [0.2224, 0.2417, 0.235, 0.2621]}, {"w": "a", "b": [0.2411, 0.2417, 0.2498, 0.2621]}, {"w": "vector", "b": [0.2558, 0.2417, 0.3054, 0.2621]}, {"w": "of", "b": [0.3115, 0.2417, 0.3274, 0.2621]}, {"w": "all", "b": [0.3335, 0.2417, 0.3523, 0.2621]}, {"w": "the", "b": [0.3583, 0.2417, 0.3834, 0.2621]}, {"w": "feature", "b": [0.3895, 0.2417, 0.4445, 0.2621]}, {"w": "values", "b": [0.4506, 0.2417, 0.4998, 0.2621]}, {"w": "(excluding", "b": [0.5058, 0.2417, 0.5904, 0.2621]}, {"w": "the", "b": [0.5965, 0.2417, 0.6215, 0.2621]}, {"w": "label)", "b": [0.6276, 0.2417, 0.6717, 0.2621]}, {"w": "of", "b": [0.6778, 0.2417, 0.6938, 0.2621]}, {"w": "the", "b": [0.6999, 0.2417, 0.725, 0.2621]}, {"w": "ith", "b": [0.731, 0.2415, 0.7466, 0.2621]}, {"w": "instance", "b": [0.7526, 0.2417, 0.8185, 0.2621]}, {"w": "in", "b": [0.8246, 0.2417, 0.8408, 0.2621]}, {"w": "the", "b": [0.1949, 0.2598, 0.22, 0.2802]}, {"w": "dataset,", "b": [0.2245, 0.2598, 0.2844, 0.2802]}, {"w": "and", "b": [0.2889, 0.2598, 0.3189, 0.2802]}, {"w": "y(i)", "b": [0.3234, 0.2596, 0.344, 0.2802]}, {"w": "is", "b": [0.3485, 0.2598, 0.3611, 0.2802]}, {"w": "its", "b": [0.3656, 0.2598, 0.3843, 0.2802]}, {"w": "label", "b": [0.3888, 0.2598, 0.426, 0.2802]}, {"w": "(the", "b": [0.4305, 0.2598, 0.4625, 0.2802]}, {"w": "desired", "b": [0.467, 0.2598, 0.5248, 0.2802]}, {"w": "output", "b": [0.5293, 0.2598, 0.583, 0.2802]}, {"w": "value", "b": [0.5875, 0.2598, 0.6293, 0.2802]}, {"w": "for", "b": [0.6338, 0.2598, 0.6572, 0.2802]}, {"w": "that", "b": [0.6617, 0.2598, 0.6927, 0.2802]}, {"w": "instance).", "b": [0.6972, 0.2598, 0.7745, 0.2802]}]}, {"id": "b_7", "type": "paragraph", "text": "— For example, if the first district in the dataset is located at longitude –118.29°,", "words": [{"w": "—", "b": [0.1985, 0.284, 0.2168, 0.3044]}, {"w": "For", "b": [0.2207, 0.284, 0.2483, 0.3044]}, {"w": "example,", "b": [0.2535, 0.284, 0.3242, 0.3044]}, {"w": "if", "b": [0.3294, 0.284, 0.3406, 0.3044]}, {"w": "the", "b": [0.3457, 0.284, 0.3708, 0.3044]}, {"w": "first", "b": [0.376, 0.284, 0.4079, 0.3044]}, {"w": "district", "b": [0.413, 0.284, 0.4693, 0.3044]}, {"w": "in", "b": [0.4744, 0.284, 0.4906, 0.3044]}, {"w": "the", "b": [0.4957, 0.284, 0.5208, 0.3044]}, {"w": "dataset", "b": [0.526, 0.284, 0.5813, 0.3044]}, {"w": "is", "b": [0.5865, 0.284, 0.5991, 0.3044]}, {"w": "located", "b": [0.6042, 0.284, 0.661, 0.3044]}, {"w": "at", "b": [0.6662, 0.284, 0.6806, 0.3044]}, {"w": "longitude", "b": [0.6857, 0.284, 0.7618, 0.3044]}, {"w": "–118.29°,", "b": [0.767, 0.284, 0.8408, 0.3044]}]}, {"id": "b_8", "type": "paragraph", "text": "latitude 33.91°, and it has 1,416 inhabitants with a median income of $38,372, and the median house value is $156,400 (ignoring the other features for now), then:", "words": [{"w": "latitude", "b": [0.2207, 0.3022, 0.281, 0.3226]}, {"w": "33.91°,", "b": [0.2859, 0.3022, 0.3399, 0.3226]}, {"w": "and", "b": [0.3449, 0.3022, 0.3749, 0.3226]}, {"w": "it", "b": [0.3799, 0.3022, 0.3913, 0.3226]}, {"w": "has", "b": [0.3963, 0.3022, 0.4229, 0.3226]}, {"w": "1,416", "b": [0.4279, 0.3022, 0.4705, 0.3226]}, {"w": "inhabitants", "b": [0.4755, 0.3022, 0.5649, 0.3226]}, {"w": "with", "b": [0.5699, 0.3022, 0.6055, 0.3226]}, {"w": "a", "b": [0.6105, 0.3022, 0.6192, 0.3226]}, {"w": "median", "b": [0.6242, 0.3022, 0.6842, 0.3226]}, {"w": "income", "b": [0.6892, 0.3022, 0.7486, 0.3226]}, {"w": "of", "b": [0.7536, 0.3022, 0.7696, 0.3226]}, {"w": "$38,372,", "b": [0.7746, 0.3022, 0.8408, 0.3226]}, {"w": "and", "b": [0.2207, 0.3203, 0.2508, 0.3407]}, {"w": "the", "b": [0.2556, 0.3203, 0.2807, 0.3407]}, {"w": "median", "b": [0.2855, 0.3203, 0.3455, 0.3407]}, {"w": "house", "b": [0.3503, 0.3203, 0.3973, 0.3407]}, {"w": "value", "b": [0.4021, 0.3203, 0.444, 0.3407]}, {"w": "is", "b": [0.4488, 0.3203, 0.4614, 0.3407]}, {"w": "$156,400", "b": [0.4662, 0.3203, 0.5374, 0.3407]}, {"w": "(ignoring", "b": [0.5422, 0.3203, 0.6175, 0.3407]}, {"w": "the", "b": [0.6223, 0.3203, 0.6474, 0.3407]}, {"w": "other", "b": [0.6522, 0.3203, 0.6947, 0.3407]}, {"w": "features", "b": [0.6995, 0.3203, 0.7618, 0.3407]}, {"w": "for", "b": [0.7667, 0.3203, 0.79, 0.3407]}, {"w": "now),", "b": [0.7948, 0.3203, 0.8408, 0.3407]}, {"w": "then:", "b": [0.2207, 0.3384, 0.2612, 0.3588]}]}, {"id": "b_9", "type": "equation", "text": "x 1 =", "words": [{"w": "x", "b": [0.2564, 0.4098, 0.266, 0.4307]}, {"w": "1", "b": [0.2716, 0.4066, 0.2792, 0.4229]}, {"w": "=", "b": [0.2903, 0.4104, 0.3018, 0.4307]}]}, {"id": "b_10", "type": "paragraph", "text": "−118 . 29", "words": [{"w": "−118", "b": [0.3141, 0.3777, 0.3553, 0.3981]}, {"w": ".", "b": [0.3586, 0.3777, 0.3632, 0.3981]}, {"w": "29", "b": [0.3664, 0.3777, 0.3855, 0.3981]}]}, {"id": "b_11", "type": "paragraph", "text": "33 . 91 1, 416 38, 372", "words": [{"w": "33", "b": [0.3252, 0.3995, 0.3442, 0.4199]}, {"w": ".", "b": [0.3476, 0.3995, 0.3521, 0.4199]}, {"w": "91", "b": [0.3554, 0.3995, 0.3744, 0.4199]}, {"w": "1,", "b": [0.3268, 0.4212, 0.3409, 0.4416]}, {"w": "416", "b": [0.3442, 0.4212, 0.3728, 0.4416]}, {"w": "38,", "b": [0.3221, 0.443, 0.3457, 0.4634]}, {"w": "372", "b": [0.349, 0.443, 0.3775, 0.4634]}]}, {"id": "b_12", "type": "paragraph", "text": "and:", "words": [{"w": "and:", "b": [0.2207, 0.4823, 0.2553, 0.5027]}]}, {"id": "b_13", "type": "equation", "text": "y 1 = 156, 400", "words": [{"w": "y", "b": [0.2576, 0.5259, 0.2663, 0.5465]}, {"w": "1", "b": [0.2719, 0.5224, 0.2795, 0.5387]}, {"w": "=", "b": [0.2905, 0.5261, 0.302, 0.5465]}, {"w": "156,", "b": [0.3075, 0.5261, 0.3406, 0.5465]}, {"w": "400", "b": [0.3439, 0.5261, 0.3725, 0.5465]}]}, {"id": "b_14", "type": "paragraph", "text": "• X is a matrix containing all the feature values (excluding labels) of all instances in the dataset. There is one row per instance and the ith row is equal to the transpose of x(i), noted (x(i))T.4", "words": [{"w": "•", "b": [0.1773, 0.5654, 0.185, 0.5858]}, {"w": "X", "b": [0.1949, 0.5649, 0.2087, 0.5858]}, {"w": "is", "b": [0.2133, 0.5654, 0.2259, 0.5858]}, {"w": "a", "b": [0.2305, 0.5654, 0.2392, 0.5858]}, {"w": "matrix", "b": [0.2439, 0.5654, 0.2965, 0.5858]}, {"w": "containing", "b": [0.3012, 0.5654, 0.3865, 0.5858]}, {"w": "all", "b": [0.3912, 0.5654, 0.4099, 0.5858]}, {"w": "the", "b": [0.4145, 0.5654, 0.4396, 0.5858]}, {"w": "feature", "b": [0.4442, 0.5654, 0.4992, 0.5858]}, {"w": "values", "b": [0.5039, 0.5654, 0.553, 0.5858]}, {"w": "(excluding", "b": [0.5576, 0.5654, 0.6422, 0.5858]}, {"w": "labels)", "b": [0.6468, 0.5654, 0.6982, 0.5858]}, {"w": "of", "b": [0.7028, 0.5654, 0.7188, 0.5858]}, {"w": "all", "b": [0.7234, 0.5654, 0.7422, 0.5858]}, {"w": "instances", "b": [0.7468, 0.5654, 0.82, 0.5858]}, {"w": "in", "b": [0.8246, 0.5654, 0.8408, 0.5858]}, {"w": "the", "b": [0.1949, 0.5836, 0.22, 0.6039]}, {"w": "dataset.", "b": [0.2246, 0.5836, 0.2845, 0.6039]}, {"w": "There", "b": [0.2891, 0.5836, 0.3362, 0.6039]}, {"w": "is", "b": [0.3408, 0.5836, 0.3534, 0.6039]}, {"w": "one", "b": [0.358, 0.5836, 0.3874, 0.6039]}, {"w": "row", "b": [0.392, 0.5836, 0.4231, 0.6039]}, {"w": "per", "b": [0.4277, 0.5836, 0.4539, 0.6039]}, {"w": "instance", "b": [0.4585, 0.5836, 0.5244, 0.6039]}, {"w": "and", "b": [0.529, 0.5836, 0.559, 0.6039]}, {"w": "the", "b": [0.5636, 0.5836, 0.5887, 0.6039]}, {"w": "ith", "b": [0.5933, 0.5834, 0.6089, 0.6039]}, {"w": "row", "b": [0.6135, 0.5836, 0.6445, 0.6039]}, {"w": "is", "b": [0.649, 0.5836, 0.6616, 0.6039]}, {"w": "equal", "b": [0.6661, 0.5836, 0.709, 0.6039]}, {"w": "to", "b": [0.7135, 0.5836, 0.7297, 0.6039]}, {"w": "the", "b": [0.7342, 0.5836, 0.7592, 0.6039]}, {"w": "transpose", "b": [0.7637, 0.5836, 0.8402, 0.6039]}, {"w": "of", "b": [0.1949, 0.6017, 0.2109, 0.6221]}, {"w": "x(i),", "b": [0.2154, 0.6012, 0.2413, 0.6221]}, {"w": "noted", "b": [0.2458, 0.6017, 0.2918, 0.6221]}, {"w": "(x(i))T.4", "b": [0.2963, 0.6012, 0.3491, 0.6221]}]}, {"id": "b_15", "type": "paragraph", "text": "— For example, if the first district is as just described, then the matrix X looks", "words": [{"w": "—", "b": [0.1985, 0.6259, 0.2168, 0.6463]}, {"w": "For", "b": [0.2207, 0.6259, 0.2483, 0.6463]}, {"w": "example,", "b": [0.2547, 0.6259, 0.3255, 0.6463]}, {"w": "if", "b": [0.3318, 0.6259, 0.343, 0.6463]}, {"w": "the", "b": [0.3494, 0.6259, 0.3745, 0.6463]}, {"w": "first", "b": [0.3808, 0.6259, 0.4127, 0.6463]}, {"w": "district", "b": [0.4191, 0.6259, 0.4753, 0.6463]}, {"w": "is", "b": [0.4817, 0.6259, 0.4943, 0.6463]}, {"w": "as", "b": [0.5007, 0.6259, 0.5167, 0.6463]}, {"w": "just", "b": [0.523, 0.6259, 0.552, 0.6463]}, {"w": "described,", "b": [0.5583, 0.6259, 0.6391, 0.6463]}, {"w": "then", "b": [0.6455, 0.6259, 0.6814, 0.6463]}, {"w": "the", "b": [0.6878, 0.6259, 0.7129, 0.6463]}, {"w": "matrix", "b": [0.7192, 0.6259, 0.7719, 0.6463]}, {"w": "X", "b": [0.7783, 0.6254, 0.792, 0.6463]}, {"w": "looks", "b": [0.7984, 0.6259, 0.8408, 0.6463]}]}, {"id": "b_16", "type": "paragraph", "text": "like this:", "words": [{"w": "like", "b": [0.2207, 0.644, 0.2493, 0.6644]}, {"w": "this:", "b": [0.2539, 0.644, 0.2876, 0.6644]}]}, {"id": "b_17", "type": "equation", "text": "X =", "words": [{"w": "X", "b": [0.2565, 0.7496, 0.2702, 0.7705]}, {"w": "=", "b": [0.2757, 0.7501, 0.2872, 0.7705]}]}, {"id": "b_18", "type": "paragraph", "text": "x 1 T", "words": [{"w": "x", "b": [0.3179, 0.6906, 0.3274, 0.7116]}, {"w": "1", "b": [0.3331, 0.6874, 0.3407, 0.7037]}, {"w": "T", "b": [0.353, 0.684, 0.3626, 0.7004]}]}, {"id": "b_19", "type": "paragraph", "text": "x 2 T", "words": [{"w": "x", "b": [0.3179, 0.724, 0.3274, 0.745]}, {"w": "2", "b": [0.3331, 0.7208, 0.3407, 0.7371]}, {"w": "T", "b": [0.353, 0.7174, 0.3626, 0.7338]}]}, {"id": "b_21", "type": "paragraph", "text": "x 1999 T", "words": [{"w": "x", "b": [0.3065, 0.7792, 0.316, 0.8001]}, {"w": "1999", "b": [0.3216, 0.776, 0.3521, 0.7923]}, {"w": "T", "b": [0.3645, 0.7725, 0.374, 0.789]}]}, {"id": "b_22", "type": "paragraph", "text": "x 2000 T", "words": [{"w": "x", "b": [0.3065, 0.8126, 0.316, 0.8335]}, {"w": "2000", "b": [0.3216, 0.8094, 0.3521, 0.8257]}, {"w": "T", "b": [0.3645, 0.8059, 0.374, 0.8224]}]}, {"id": "b_23", "type": "equation", "text": "= −118 . 29 33 . 91 1, 416 38, 372", "words": [{"w": "=", "b": [0.3871, 0.7501, 0.3986, 0.7705]}, {"w": "−118", "b": [0.411, 0.7393, 0.4522, 0.7597]}, {"w": ".", "b": [0.4555, 0.7393, 0.46, 0.7597]}, {"w": "29", "b": [0.4633, 0.7393, 0.4824, 0.7597]}, {"w": "33", "b": [0.4911, 0.7393, 0.5101, 0.7597]}, {"w": ".", "b": [0.5134, 0.7393, 0.5179, 0.7597]}, {"w": "91", "b": [0.5213, 0.7393, 0.5403, 0.7597]}, {"w": "1,", "b": [0.549, 0.7393, 0.563, 0.7597]}, {"w": "416", "b": [0.5664, 0.7393, 0.5949, 0.7597]}, {"w": "38,", "b": [0.6036, 0.7393, 0.6272, 0.7597]}, {"w": "372", "b": [0.6305, 0.7393, 0.6591, 0.7597]}]}, {"id": "b_24", "type": "paragraph", "text": "⋮ ⋮ ⋮ ⋮", "words": [{"w": "⋮", "b": [0.4434, 0.765, 0.45, 0.7801]}, {"w": "⋮", "b": [0.5124, 0.765, 0.519, 0.7801]}, {"w": "⋮", "b": [0.5687, 0.765, 0.5753, 0.7801]}, {"w": "⋮", "b": [0.628, 0.765, 0.6346, 0.7801]}]}, {"id": "b_25", "type": "paragraph", "text": "Look at the Big Picture | 43", "words": [{"w": "Look", "b": [0.6708, 0.9225, 0.6988, 0.9388]}, {"w": "at", "b": [0.7016, 0.9225, 0.7138, 0.9388]}, {"w": "the", "b": [0.7166, 0.9225, 0.7365, 0.9388]}, {"w": "Big", "b": [0.7393, 0.9225, 0.7587, 0.9388]}, {"w": "Picture", "b": [0.7615, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "43", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 70, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• h is your system’s prediction function, also called a hypothesis. When your system is given an instance’s feature vector x(i), it outputs a predicted value ŷ(i) = h(x(i)) for that instance (ŷ is pronounced “y-hat”).", "words": [{"w": "•", "b": [0.1773, 0.0792, 0.185, 0.0996]}, {"w": "h", "b": [0.1949, 0.079, 0.2051, 0.0996]}, {"w": "is", "b": [0.2099, 0.0792, 0.2225, 0.0996]}, {"w": "your", "b": [0.2272, 0.0792, 0.2644, 0.0996]}, {"w": "system’s", "b": [0.2691, 0.0792, 0.3317, 0.0996]}, {"w": "prediction", "b": [0.3365, 0.0792, 0.4192, 0.0996]}, {"w": "function,", "b": [0.424, 0.0792, 0.4965, 0.0996]}, {"w": "also", "b": [0.5013, 0.0792, 0.5325, 0.0996]}, {"w": "called", "b": [0.5372, 0.0792, 0.5833, 0.0996]}, {"w": "a", "b": [0.5881, 0.0792, 0.5968, 0.0996]}, {"w": "hypothesis.", "b": [0.6016, 0.079, 0.6858, 0.0996]}, {"w": "When", "b": [0.6905, 0.0792, 0.7397, 0.0996]}, {"w": "your", "b": [0.7445, 0.0792, 0.7816, 0.0996]}, {"w": "system", "b": [0.7864, 0.0792, 0.8408, 0.0996]}, {"w": "is", "b": [0.1949, 0.0973, 0.2075, 0.1177]}, {"w": "given", "b": [0.214, 0.0973, 0.257, 0.1177]}, {"w": "an", "b": [0.2635, 0.0973, 0.283, 0.1177]}, {"w": "instance’s", "b": [0.2895, 0.0973, 0.364, 0.1177]}, {"w": "feature", "b": [0.3705, 0.0973, 0.4255, 0.1177]}, {"w": "vector", "b": [0.4319, 0.0973, 0.4815, 0.1177]}, {"w": "x(i),", "b": [0.4879, 0.0968, 0.5138, 0.1177]}, {"w": "it", "b": [0.5202, 0.0973, 0.5316, 0.1177]}, {"w": "outputs", "b": [0.538, 0.0973, 0.599, 0.1177]}, {"w": "a", "b": [0.6054, 0.0973, 0.6141, 0.1177]}, {"w": "predicted", "b": [0.6205, 0.0973, 0.6959, 0.1177]}, {"w": "value", "b": [0.7023, 0.0973, 0.7442, 0.1177]}, {"w": "ŷ(i)", "b": [0.7506, 0.0971, 0.7712, 0.1177]}, {"w": "=", "b": [0.7776, 0.0973, 0.7891, 0.1177]}, {"w": "h(x(i))", "b": [0.7955, 0.0968, 0.8408, 0.1177]}, {"w": "for", "b": [0.1949, 0.1155, 0.2183, 0.1359]}, {"w": "that", "b": [0.2228, 0.1155, 0.2538, 0.1359]}, {"w": "instance", "b": [0.2583, 0.1155, 0.3242, 0.1359]}, {"w": "(ŷ", "b": [0.3287, 0.1153, 0.3444, 0.1359]}, {"w": "is", "b": [0.3489, 0.1155, 0.3615, 0.1359]}, {"w": "pronounced", "b": [0.366, 0.1155, 0.4635, 0.1359]}, {"w": "“y-hat”).", "b": [0.468, 0.1155, 0.5359, 0.1359]}]}, {"id": "b_1", "type": "paragraph", "text": "— For example, if your system predicts that the median housing price in the first", "words": [{"w": "—", "b": [0.1985, 0.1397, 0.2168, 0.16]}, {"w": "For", "b": [0.2207, 0.1397, 0.2483, 0.16]}, {"w": "example,", "b": [0.2531, 0.1397, 0.3239, 0.16]}, {"w": "if", "b": [0.3286, 0.1397, 0.3398, 0.16]}, {"w": "your", "b": [0.3446, 0.1397, 0.3817, 0.16]}, {"w": "system", "b": [0.3865, 0.1397, 0.4409, 0.16]}, {"w": "predicts", "b": [0.4457, 0.1397, 0.5094, 0.16]}, {"w": "that", "b": [0.5142, 0.1397, 0.5452, 0.16]}, {"w": "the", "b": [0.55, 0.1397, 0.5751, 0.16]}, {"w": "median", "b": [0.5798, 0.1397, 0.6399, 0.16]}, {"w": "housing", "b": [0.6446, 0.1397, 0.7086, 0.16]}, {"w": "price", "b": [0.7134, 0.1397, 0.7533, 0.16]}, {"w": "in", "b": [0.7581, 0.1397, 0.7743, 0.16]}, {"w": "the", "b": [0.779, 0.1397, 0.8041, 0.16]}, {"w": "first", "b": [0.8089, 0.1397, 0.8408, 0.16]}]}, {"id": "b_2", "type": "paragraph", "text": "district is $158,400, then ŷ(1) = h(x(1)) = 158,400. The prediction error for this district is ŷ(1) – y(1) = 2,000.", "words": [{"w": "district", "b": [0.2207, 0.1578, 0.277, 0.1782]}, {"w": "is", "b": [0.2825, 0.1578, 0.2951, 0.1782]}, {"w": "$158,400,", "b": [0.3006, 0.1578, 0.3763, 0.1782]}, {"w": "then", "b": [0.3818, 0.1578, 0.4178, 0.1782]}, {"w": "ŷ(1)", "b": [0.4233, 0.1576, 0.4467, 0.1782]}, {"w": "=", "b": [0.4522, 0.1578, 0.4637, 0.1782]}, {"w": "h(x(1))", "b": [0.4692, 0.1573, 0.5173, 0.1782]}, {"w": "=", "b": [0.5228, 0.1578, 0.5343, 0.1782]}, {"w": "158,400.", "b": [0.5398, 0.1578, 0.606, 0.1782]}, {"w": "The", "b": [0.6115, 0.1578, 0.6428, 0.1782]}, {"w": "prediction", "b": [0.6483, 0.1578, 0.731, 0.1782]}, {"w": "error", "b": [0.7365, 0.1578, 0.7772, 0.1782]}, {"w": "for", "b": [0.7827, 0.1578, 0.806, 0.1782]}, {"w": "this", "b": [0.8115, 0.1578, 0.8408, 0.1782]}, {"w": "district", "b": [0.2207, 0.1759, 0.277, 0.1963]}, {"w": "is", "b": [0.2815, 0.1759, 0.2941, 0.1963]}, {"w": "ŷ(1)", "b": [0.2986, 0.1757, 0.322, 0.1963]}, {"w": "–", "b": [0.3265, 0.1759, 0.3368, 0.1963]}, {"w": "y(1)", "b": [0.3413, 0.1757, 0.3648, 0.1963]}, {"w": "=", "b": [0.3693, 0.1759, 0.3808, 0.1963]}, {"w": "2,000.", "b": [0.3853, 0.1759, 0.4324, 0.1963]}]}, {"id": "b_3", "type": "paragraph", "text": "• RMSE(X,h) is the cost function measured on the set of examples using your hypothesis h.", "words": [{"w": "•", "b": [0.1773, 0.2001, 0.185, 0.2205]}, {"w": "RMSE(X,h)", "b": [0.1949, 0.1996, 0.2878, 0.2205]}, {"w": "is", "b": [0.2961, 0.2001, 0.3087, 0.2205]}, {"w": "the", "b": [0.3171, 0.2001, 0.3422, 0.2205]}, {"w": "cost", "b": [0.3505, 0.2001, 0.3824, 0.2205]}, {"w": "function", "b": [0.3907, 0.2001, 0.4587, 0.2205]}, {"w": "measured", "b": [0.4671, 0.2001, 0.5445, 0.2205]}, {"w": "on", "b": [0.5529, 0.2001, 0.5739, 0.2205]}, {"w": "the", "b": [0.5822, 0.2001, 0.6073, 0.2205]}, {"w": "set", "b": [0.6157, 0.2001, 0.6374, 0.2205]}, {"w": "of", "b": [0.6458, 0.2001, 0.6618, 0.2205]}, {"w": "examples", "b": [0.6701, 0.2001, 0.7437, 0.2205]}, {"w": "using", "b": [0.752, 0.2001, 0.7953, 0.2205]}, {"w": "your", "b": [0.8037, 0.2001, 0.8408, 0.2205]}, {"w": "hypothesis", "b": [0.1949, 0.2183, 0.2797, 0.2387]}, {"w": "h.", "b": [0.2842, 0.2181, 0.2988, 0.2387]}]}, {"id": "b_4", "type": "paragraph", "text": "We use lowercase italic font for scalar values (such as m or y(i)) and function names (such as h), lowercase bold font for vectors (such as x(i)), and uppercase bold font for matrices (such as X).", "words": [{"w": "We", "b": [0.1592, 0.2515, 0.185, 0.2719]}, {"w": "use", "b": [0.1912, 0.2515, 0.2175, 0.2719]}, {"w": "lowercase", "b": [0.2237, 0.2515, 0.301, 0.2719]}, {"w": "italic", "b": [0.3072, 0.2515, 0.346, 0.2719]}, {"w": "font", "b": [0.3522, 0.2515, 0.3847, 0.2719]}, {"w": "for", "b": [0.391, 0.2515, 0.4143, 0.2719]}, {"w": "scalar", "b": [0.4205, 0.2515, 0.466, 0.2719]}, {"w": "values", "b": [0.4722, 0.2515, 0.5214, 0.2719]}, {"w": "(such", "b": [0.5276, 0.2515, 0.5712, 0.2719]}, {"w": "as", "b": [0.5774, 0.2515, 0.5934, 0.2719]}, {"w": "m", "b": [0.5996, 0.2513, 0.6153, 0.2719]}, {"w": "or", "b": [0.6215, 0.2515, 0.6389, 0.2719]}, {"w": "y(i))", "b": [0.6452, 0.2513, 0.6726, 0.2719]}, {"w": "and", "b": [0.6788, 0.2515, 0.7088, 0.2719]}, {"w": "function", "b": [0.715, 0.2515, 0.783, 0.2719]}, {"w": "names", "b": [0.7892, 0.2515, 0.8408, 0.2719]}, {"w": "(such", "b": [0.1592, 0.2697, 0.2029, 0.2901]}, {"w": "as", "b": [0.2083, 0.2697, 0.2243, 0.2901]}, {"w": "h),", "b": [0.2296, 0.2695, 0.2512, 0.2901]}, {"w": "lowercase", "b": [0.2566, 0.2697, 0.3339, 0.2901]}, {"w": "bold", "b": [0.3393, 0.2697, 0.375, 0.2901]}, {"w": "font", "b": [0.3803, 0.2697, 0.4129, 0.2901]}, {"w": "for", "b": [0.4182, 0.2697, 0.4416, 0.2901]}, {"w": "vectors", "b": [0.447, 0.2697, 0.5038, 0.2901]}, {"w": "(such", "b": [0.5092, 0.2697, 0.5528, 0.2901]}, {"w": "as", "b": [0.5582, 0.2697, 0.5742, 0.2901]}, {"w": "x(i)),", "b": [0.5796, 0.2691, 0.6123, 0.2901]}, {"w": "and", "b": [0.6177, 0.2697, 0.6478, 0.2901]}, {"w": "uppercase", "b": [0.6531, 0.2697, 0.7331, 0.2901]}, {"w": "bold", "b": [0.7385, 0.2697, 0.7741, 0.2901]}, {"w": "font", "b": [0.7795, 0.2697, 0.812, 0.2901]}, {"w": "for", "b": [0.8174, 0.2697, 0.8408, 0.2901]}, {"w": "matrices", "b": [0.1592, 0.2878, 0.2266, 0.3082]}, {"w": "(such", "b": [0.2312, 0.2878, 0.2748, 0.3082]}, {"w": "as", "b": [0.2793, 0.2878, 0.2953, 0.3082]}, {"w": "X).", "b": [0.2998, 0.2873, 0.325, 0.3082]}]}, {"id": "b_5", "type": "paragraph", "text": "Even though the RMSE is generally the preferred performance measure for regression tasks, in some contexts you may prefer to use another function. For example, suppose that there are many outlier districts. In that case, you may consider using the Mean Absolute Error (also called the Average Absolute Deviation; see Equation 2-2):", "words": [{"w": "Even", "b": [0.1429, 0.3379, 0.1842, 0.3594]}, {"w": "though", "b": [0.1889, 0.3379, 0.2489, 0.3594]}, {"w": "the", "b": [0.2537, 0.3379, 0.28, 0.3594]}, {"w": "RMSE", "b": [0.2847, 0.3379, 0.3379, 0.3594]}, {"w": "is", "b": [0.3427, 0.3379, 0.3559, 0.3594]}, {"w": "generally", "b": [0.3606, 0.3379, 0.4365, 0.3594]}, {"w": "the", "b": [0.4412, 0.3379, 0.4675, 0.3594]}, {"w": "preferred", "b": [0.4723, 0.3379, 0.5501, 0.3594]}, {"w": "performance", "b": [0.5548, 0.3379, 0.6621, 0.3594]}, {"w": "measure", "b": [0.6668, 0.3379, 0.7372, 0.3594]}, {"w": "for", "b": [0.7419, 0.3379, 0.7664, 0.3594]}, {"w": "regression", "b": [0.7712, 0.3379, 0.857, 0.3594]}, {"w": "tasks,", "b": [0.1429, 0.357, 0.1887, 0.3784]}, {"w": "in", "b": [0.1937, 0.357, 0.2106, 0.3784]}, {"w": "some", "b": [0.2156, 0.357, 0.2597, 0.3784]}, {"w": "contexts", "b": [0.2647, 0.357, 0.3342, 0.3784]}, {"w": "you", "b": [0.3391, 0.357, 0.3703, 0.3784]}, {"w": "may", "b": [0.3752, 0.357, 0.4106, 0.3784]}, {"w": "prefer", "b": [0.4156, 0.357, 0.4658, 0.3784]}, {"w": "to", "b": [0.4707, 0.357, 0.4877, 0.3784]}, {"w": "use", "b": [0.4926, 0.357, 0.5202, 0.3784]}, {"w": "another", "b": [0.5251, 0.357, 0.5904, 0.3784]}, {"w": "function.", "b": [0.5953, 0.357, 0.6714, 0.3784]}, {"w": "For", "b": [0.6764, 0.357, 0.7053, 0.3784]}, {"w": "example,", "b": [0.7103, 0.357, 0.7846, 0.3784]}, {"w": "suppose", "b": [0.7895, 0.357, 0.8571, 0.3784]}, {"w": "that", "b": [0.1429, 0.376, 0.1754, 0.3975]}, {"w": "there", "b": [0.182, 0.376, 0.2249, 0.3975]}, {"w": "are", "b": [0.2315, 0.376, 0.2573, 0.3975]}, {"w": "many", "b": [0.2639, 0.376, 0.3105, 0.3975]}, {"w": "outlier", "b": [0.3171, 0.376, 0.3726, 0.3975]}, {"w": "districts.", "b": [0.3792, 0.376, 0.4507, 0.3975]}, {"w": "In", "b": [0.4573, 0.376, 0.4758, 0.3975]}, {"w": "that", "b": [0.4823, 0.376, 0.5149, 0.3975]}, {"w": "case,", "b": [0.5215, 0.376, 0.5607, 0.3975]}, {"w": "you", "b": [0.5673, 0.376, 0.5986, 0.3975]}, {"w": "may", "b": [0.6052, 0.376, 0.6406, 0.3975]}, {"w": "consider", "b": [0.6472, 0.376, 0.7188, 0.3975]}, {"w": "using", "b": [0.7254, 0.376, 0.7708, 0.3975]}, {"w": "the", "b": [0.7774, 0.376, 0.8038, 0.3975]}, {"w": "Mean", "b": [0.8103, 0.3758, 0.8571, 0.3975]}, {"w": "Absolute", "b": [0.1429, 0.3949, 0.2136, 0.4165]}, {"w": "Error", "b": [0.2184, 0.3949, 0.262, 0.4165]}, {"w": "(also", "b": [0.2667, 0.3951, 0.3066, 0.4165]}, {"w": "called", "b": [0.3113, 0.3951, 0.3597, 0.4165]}, {"w": "the", "b": [0.3644, 0.3951, 0.3907, 0.4165]}, {"w": "Average", "b": [0.3955, 0.3951, 0.4625, 0.4165]}, {"w": "Absolute", "b": [0.4672, 0.3951, 0.5413, 0.4165]}, {"w": "Deviation;", "b": [0.5461, 0.3951, 0.6329, 0.4165]}, {"w": "see", "b": [0.6377, 0.3951, 0.663, 0.4165]}, {"w": "Equation", "b": [0.6677, 0.3951, 0.744, 0.4165]}, {"w": "2-2):", "b": [0.7487, 0.3951, 0.7881, 0.4165]}]}, {"id": "b_6", "type": "equation", "text": "Equation 2-2. Mean Absolute Error", "words": [{"w": "Equation", "b": [0.1726, 0.4346, 0.2473, 0.4562]}, {"w": "2-2.", "b": [0.2521, 0.4346, 0.2838, 0.4562]}, {"w": "Mean", "b": [0.2886, 0.4346, 0.3353, 0.4562]}, {"w": "Absolute", "b": [0.3401, 0.4346, 0.4109, 0.4562]}, {"w": "Error", "b": [0.4156, 0.4346, 0.4592, 0.4562]}]}, {"id": "b_7", "type": "equation", "text": "MAE X, h = 1", "words": [{"w": "MAE", "b": [0.1726, 0.4762, 0.2153, 0.4966]}, {"w": "X,", "b": [0.2221, 0.4757, 0.2404, 0.4966]}, {"w": "h", "b": [0.2437, 0.476, 0.2539, 0.4966]}, {"w": "=", "b": [0.2662, 0.4762, 0.2777, 0.4966]}, {"w": "1", "b": [0.2885, 0.4674, 0.298, 0.4878]}]}, {"id": "b_8", "type": "paragraph", "text": "m ∑", "words": [{"w": "m", "b": [0.2855, 0.4848, 0.3011, 0.5054]}, {"w": "∑", "b": [0.3118, 0.4714, 0.3269, 0.5003]}]}, {"id": "b_9", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.3044, 0.4909, 0.3087, 0.5074]}, {"w": "=", "b": [0.3131, 0.4911, 0.3223, 0.5074]}, {"w": "1", "b": [0.3267, 0.4911, 0.3344, 0.5074]}]}, {"id": "b_11", "type": "paragraph", "text": "h x i −y i", "words": [{"w": "h", "b": [0.3418, 0.476, 0.3519, 0.4966]}, {"w": "x", "b": [0.3588, 0.4757, 0.3684, 0.4966]}, {"w": "i", "b": [0.374, 0.4723, 0.3783, 0.4888]}, {"w": "−y", "b": [0.3951, 0.476, 0.4209, 0.4966]}, {"w": "i", "b": [0.4264, 0.4723, 0.4307, 0.4888]}]}, {"id": "b_12", "type": "paragraph", "text": "Both the RMSE and the MAE are ways to measure the distance between two vectors: the vector of predictions and the vector of target values. Various distance measures, or norms, are possible:", "words": [{"w": "Both", "b": [0.1429, 0.5264, 0.1836, 0.5478]}, {"w": "the", "b": [0.1892, 0.5264, 0.2155, 0.5478]}, {"w": "RMSE", "b": [0.2211, 0.5264, 0.2743, 0.5478]}, {"w": "and", "b": [0.2799, 0.5264, 0.3114, 0.5478]}, {"w": "the", "b": [0.317, 0.5264, 0.3433, 0.5478]}, {"w": "MAE", "b": [0.3489, 0.5264, 0.3937, 0.5478]}, {"w": "are", "b": [0.3993, 0.5264, 0.425, 0.5478]}, {"w": "ways", "b": [0.4306, 0.5264, 0.4708, 0.5478]}, {"w": "to", "b": [0.4764, 0.5264, 0.4934, 0.5478]}, {"w": "measure", "b": [0.499, 0.5264, 0.5693, 0.5478]}, {"w": "the", "b": [0.5749, 0.5264, 0.6012, 0.5478]}, {"w": "distance", "b": [0.6068, 0.5264, 0.6756, 0.5478]}, {"w": "between", "b": [0.6812, 0.5264, 0.7503, 0.5478]}, {"w": "two", "b": [0.7559, 0.5264, 0.7872, 0.5478]}, {"w": "vectors:", "b": [0.7927, 0.5264, 0.8571, 0.5478]}, {"w": "the", "b": [0.1429, 0.5455, 0.1692, 0.5669]}, {"w": "vector", "b": [0.1756, 0.5455, 0.2277, 0.5669]}, {"w": "of", "b": [0.2341, 0.5455, 0.2509, 0.5669]}, {"w": "predictions", "b": [0.2574, 0.5455, 0.3519, 0.5669]}, {"w": "and", "b": [0.3583, 0.5455, 0.3899, 0.5669]}, {"w": "the", "b": [0.3963, 0.5455, 0.4227, 0.5669]}, {"w": "vector", "b": [0.4291, 0.5455, 0.4811, 0.5669]}, {"w": "of", "b": [0.4876, 0.5455, 0.5044, 0.5669]}, {"w": "target", "b": [0.5108, 0.5455, 0.559, 0.5669]}, {"w": "values.", "b": [0.5655, 0.5455, 0.6219, 0.5669]}, {"w": "Various", "b": [0.6283, 0.5455, 0.6927, 0.5669]}, {"w": "distance", "b": [0.6991, 0.5455, 0.7679, 0.5669]}, {"w": "measures,", "b": [0.7744, 0.5455, 0.8571, 0.5669]}, {"w": "or", "b": [0.1429, 0.5645, 0.1612, 0.5859]}, {"w": "norms,", "b": [0.166, 0.5643, 0.2225, 0.5859]}, {"w": "are", "b": [0.2272, 0.5645, 0.2529, 0.5859]}, {"w": "possible:", "b": [0.2576, 0.5645, 0.3295, 0.5859]}]}, {"id": "b_13", "type": "paragraph", "text": "• Computing the root of a sum of squares (RMSE) corresponds to the Euclidean norm: it is the notion of distance you are familiar with. It is also called the ℓ2 norm, noted ∥ · ∥2 (or just ∥ · ∥).", "words": [{"w": "•", "b": [0.16, 0.5987, 0.1682, 0.6201]}, {"w": "Computing", "b": [0.1786, 0.5987, 0.2748, 0.6201]}, {"w": "the", "b": [0.2819, 0.5987, 0.3082, 0.6201]}, {"w": "root", "b": [0.3153, 0.5987, 0.3507, 0.6201]}, {"w": "of", "b": [0.3578, 0.5987, 0.3746, 0.6201]}, {"w": "a", "b": [0.3817, 0.5987, 0.3908, 0.6201]}, {"w": "sum", "b": [0.3979, 0.5987, 0.4337, 0.6201]}, {"w": "of", "b": [0.4408, 0.5987, 0.4576, 0.6201]}, {"w": "squares", "b": [0.4647, 0.5987, 0.5274, 0.6201]}, {"w": "(RMSE)", "b": [0.5346, 0.5987, 0.6022, 0.6201]}, {"w": "corresponds", "b": [0.6093, 0.5987, 0.7123, 0.6201]}, {"w": "to", "b": [0.7194, 0.5987, 0.7364, 0.6201]}, {"w": "the", "b": [0.7435, 0.5987, 0.7698, 0.6201]}, {"w": "Euclidean", "b": [0.7769, 0.5985, 0.8571, 0.6201]}, {"w": "norm:", "b": [0.1786, 0.6175, 0.2281, 0.6391]}, {"w": "it", "b": [0.2358, 0.6177, 0.2477, 0.6391]}, {"w": "is", "b": [0.2554, 0.6177, 0.2687, 0.6391]}, {"w": "the", "b": [0.2764, 0.6177, 0.3027, 0.6391]}, {"w": "notion", "b": [0.3104, 0.6177, 0.3664, 0.6391]}, {"w": "of", "b": [0.3741, 0.6177, 0.3909, 0.6391]}, {"w": "distance", "b": [0.3986, 0.6177, 0.4674, 0.6391]}, {"w": "you", "b": [0.4751, 0.6177, 0.5064, 0.6391]}, {"w": "are", "b": [0.5141, 0.6177, 0.5398, 0.6391]}, {"w": "familiar", "b": [0.5475, 0.6177, 0.6132, 0.6391]}, {"w": "with.", "b": [0.6209, 0.6177, 0.663, 0.6391]}, {"w": "It", "b": [0.6707, 0.6177, 0.6834, 0.6391]}, {"w": "is", "b": [0.6911, 0.6177, 0.7043, 0.6391]}, {"w": "also", "b": [0.7121, 0.6177, 0.7447, 0.6391]}, {"w": "called", "b": [0.7525, 0.6177, 0.8008, 0.6391]}, {"w": "the", "b": [0.8085, 0.6177, 0.8349, 0.6391]}, {"w": "ℓ2", "b": [0.8426, 0.6177, 0.8571, 0.64]}, {"w": "norm,", "b": [0.1786, 0.6366, 0.228, 0.6582]}, {"w": "noted", "b": [0.2328, 0.6368, 0.281, 0.6582]}, {"w": "∥", "b": [0.2857, 0.64, 0.2961, 0.6559]}, {"w": "·", "b": [0.3009, 0.6368, 0.3056, 0.6582]}, {"w": "∥2", "b": [0.3103, 0.64, 0.3267, 0.6591]}, {"w": "(or", "b": [0.3315, 0.6368, 0.357, 0.6582]}, {"w": "just", "b": [0.3618, 0.6368, 0.3922, 0.6582]}, {"w": "∥", "b": [0.3969, 0.64, 0.4073, 0.6559]}, {"w": "·", "b": [0.412, 0.6368, 0.4167, 0.6582]}, {"w": "∥).", "b": [0.4215, 0.6368, 0.4438, 0.6582]}]}, {"id": "b_14", "type": "paragraph", "text": "• Computing the sum of absolutes (MAE) corresponds to the ℓ1 norm, noted ∥ · ∥1. It is sometimes called the Manhattan norm because it measures the distance between two points in a city if you can only travel along orthogonal city blocks.", "words": [{"w": "•", "b": [0.16, 0.6619, 0.1682, 0.6833]}, {"w": "Computing", "b": [0.1786, 0.6619, 0.2748, 0.6833]}, {"w": "the", "b": [0.2799, 0.6619, 0.3063, 0.6833]}, {"w": "sum", "b": [0.3114, 0.6619, 0.3472, 0.6833]}, {"w": "of", "b": [0.3524, 0.6619, 0.3691, 0.6833]}, {"w": "absolutes", "b": [0.3743, 0.6619, 0.4515, 0.6833]}, {"w": "(MAE)", "b": [0.4566, 0.6619, 0.5159, 0.6833]}, {"w": "corresponds", "b": [0.521, 0.6619, 0.624, 0.6833]}, {"w": "to", "b": [0.6292, 0.6619, 0.6461, 0.6833]}, {"w": "the", "b": [0.6513, 0.6619, 0.6776, 0.6833]}, {"w": "ℓ1", "b": [0.6828, 0.6619, 0.6973, 0.6842]}, {"w": "norm,", "b": [0.7025, 0.6617, 0.752, 0.6833]}, {"w": "noted", "b": [0.7571, 0.6619, 0.8054, 0.6833]}, {"w": "∥", "b": [0.8105, 0.6651, 0.8209, 0.681]}, {"w": "·", "b": [0.8261, 0.6619, 0.8308, 0.6833]}, {"w": "∥1.", "b": [0.836, 0.6619, 0.8571, 0.6842]}, {"w": "It", "b": [0.1786, 0.6809, 0.1912, 0.7023]}, {"w": "is", "b": [0.2005, 0.6809, 0.2137, 0.7023]}, {"w": "sometimes", "b": [0.223, 0.6809, 0.3126, 0.7023]}, {"w": "called", "b": [0.3219, 0.6809, 0.3702, 0.7023]}, {"w": "the", "b": [0.3795, 0.6809, 0.4058, 0.7023]}, {"w": "Manhattan", "b": [0.4151, 0.6807, 0.5073, 0.7023]}, {"w": "norm", "b": [0.5166, 0.6807, 0.5613, 0.7023]}, {"w": "because", "b": [0.5705, 0.6809, 0.6351, 0.7023]}, {"w": "it", "b": [0.6443, 0.6809, 0.6563, 0.7023]}, {"w": "measures", "b": [0.6655, 0.6809, 0.7435, 0.7023]}, {"w": "the", "b": [0.7528, 0.6809, 0.7791, 0.7023]}, {"w": "distance", "b": [0.7884, 0.6809, 0.8572, 0.7023]}, {"w": "between", "b": [0.1786, 0.7, 0.2477, 0.7214]}, {"w": "two", "b": [0.2525, 0.7, 0.2837, 0.7214]}, {"w": "points", "b": [0.2884, 0.7, 0.3406, 0.7214]}, {"w": "in", "b": [0.3453, 0.7, 0.3623, 0.7214]}, {"w": "a", "b": [0.367, 0.7, 0.3761, 0.7214]}, {"w": "city", "b": [0.3809, 0.7, 0.4112, 0.7214]}, {"w": "if", "b": [0.4159, 0.7, 0.4277, 0.7214]}, {"w": "you", "b": [0.4324, 0.7, 0.4636, 0.7214]}, {"w": "can", "b": [0.4684, 0.7, 0.4977, 0.7214]}, {"w": "only", "b": [0.5025, 0.7, 0.5393, 0.7214]}, {"w": "travel", "b": [0.544, 0.7, 0.5907, 0.7214]}, {"w": "along", "b": [0.5954, 0.7, 0.6416, 0.7214]}, {"w": "orthogonal", "b": [0.6463, 0.7, 0.739, 0.7214]}, {"w": "city", "b": [0.7437, 0.7, 0.774, 0.7214]}, {"w": "blocks.", "b": [0.7787, 0.7, 0.8368, 0.7214]}]}, {"id": "b_15", "type": "paragraph", "text": "• More generally, the ℓk norm of a vector v containing n elements is defined as", "words": [{"w": "•", "b": [0.16, 0.7251, 0.1682, 0.7465]}, {"w": "More", "b": [0.1786, 0.7251, 0.2238, 0.7465]}, {"w": "generally,", "b": [0.2319, 0.7251, 0.311, 0.7465]}, {"w": "the", "b": [0.3191, 0.7251, 0.3454, 0.7465]}, {"w": "ℓk", "b": [0.3535, 0.7251, 0.368, 0.7474]}, {"w": "norm", "b": [0.3761, 0.7249, 0.4208, 0.7465]}, {"w": "of", "b": [0.4289, 0.7251, 0.4457, 0.7465]}, {"w": "a", "b": [0.4538, 0.7251, 0.463, 0.7465]}, {"w": "vector", "b": [0.4711, 0.7251, 0.5231, 0.7465]}, {"w": "v", "b": [0.5312, 0.7245, 0.5409, 0.7465]}, {"w": "containing", "b": [0.5491, 0.7251, 0.6387, 0.7465]}, {"w": "n", "b": [0.6468, 0.7249, 0.6579, 0.7465]}, {"w": "elements", "b": [0.666, 0.7251, 0.7399, 0.7465]}, {"w": "is", "b": [0.748, 0.7251, 0.7613, 0.7465]}, {"w": "defined", "b": [0.7694, 0.7251, 0.8322, 0.7465]}, {"w": "as", "b": [0.8403, 0.7251, 0.8571, 0.7465]}]}, {"id": "b_16", "type": "equation", "text": "∥�∥k = v0", "words": [{"w": "∥�∥k", "b": [0.1786, 0.764, 0.2296, 0.7851]}, {"w": "=", "b": [0.2354, 0.7608, 0.2474, 0.7822]}, {"w": "v0", "b": [0.2659, 0.7606, 0.2828, 0.786]}]}, {"id": "b_17", "type": "equation", "text": "k + v1", "words": [{"w": "k", "b": [0.2883, 0.7573, 0.2958, 0.7738]}, {"w": "+", "b": [0.3004, 0.7608, 0.3125, 0.7822]}, {"w": "v1", "b": [0.3226, 0.7606, 0.3395, 0.786]}]}, {"id": "b_18", "type": "equation", "text": "k + ⋯+ vn", "words": [{"w": "k", "b": [0.345, 0.7575, 0.3525, 0.7739]}, {"w": "+", "b": [0.3571, 0.7608, 0.3692, 0.7822]}, {"w": "⋯+", "b": [0.3738, 0.7608, 0.4114, 0.7822]}, {"w": "vn", "b": [0.4215, 0.7606, 0.4392, 0.786]}]}, {"id": "b_20", "type": "paragraph", "text": "1 k. ℓ0 just gives the number of non-zero ele‐ ments in the vector, and ℓ∞ gives the maximum absolute value in the vector.", "words": [{"w": "1", "b": [0.4611, 0.7435, 0.4688, 0.7598]}, {"w": "k.", "b": [0.4612, 0.7575, 0.4753, 0.7822]}, {"w": "ℓ0", "b": [0.4851, 0.7608, 0.4997, 0.7831]}, {"w": "just", "b": [0.5095, 0.7608, 0.5399, 0.7822]}, {"w": "gives", "b": [0.5498, 0.7608, 0.5913, 0.7822]}, {"w": "the", "b": [0.6011, 0.7608, 0.6275, 0.7822]}, {"w": "number", "b": [0.6373, 0.7608, 0.7036, 0.7822]}, {"w": "of", "b": [0.7135, 0.7608, 0.7303, 0.7822]}, {"w": "non-zero", "b": [0.7401, 0.7608, 0.8169, 0.7822]}, {"w": "ele‐", "b": [0.8268, 0.7608, 0.8571, 0.7822]}, {"w": "ments", "b": [0.1786, 0.7824, 0.2295, 0.8038]}, {"w": "in", "b": [0.2342, 0.7824, 0.2512, 0.8038]}, {"w": "the", "b": [0.2559, 0.7824, 0.2823, 0.8038]}, {"w": "vector,", "b": [0.287, 0.7824, 0.3424, 0.8038]}, {"w": "and", "b": [0.3472, 0.7824, 0.3787, 0.8038]}, {"w": "ℓ∞", "b": [0.3834, 0.7824, 0.4015, 0.8047]}, {"w": "gives", "b": [0.4062, 0.7824, 0.4477, 0.8038]}, {"w": "the", "b": [0.4525, 0.7824, 0.4788, 0.8038]}, {"w": "maximum", "b": [0.4835, 0.7824, 0.5699, 0.8038]}, {"w": "absolute", "b": [0.5747, 0.7824, 0.6442, 0.8038]}, {"w": "value", "b": [0.6489, 0.7824, 0.6929, 0.8038]}, {"w": "in", "b": [0.6976, 0.7824, 0.7146, 0.8038]}, {"w": "the", "b": [0.7193, 0.7824, 0.7457, 0.8038]}, {"w": "vector.", "b": [0.7504, 0.7824, 0.8059, 0.8038]}]}, {"id": "b_21", "type": "paragraph", "text": "• The higher the norm index, the more it focuses on large values and neglects small ones. This is why the RMSE is more sensitive to outliers than the MAE. But when", "words": [{"w": "•", "b": [0.16, 0.8075, 0.1681, 0.8289]}, {"w": "The", "b": [0.1786, 0.8075, 0.2114, 0.8289]}, {"w": "higher", "b": [0.2161, 0.8075, 0.2703, 0.8289]}, {"w": "the", "b": [0.275, 0.8075, 0.3014, 0.8289]}, {"w": "norm", "b": [0.3061, 0.8075, 0.3529, 0.8289]}, {"w": "index,", "b": [0.3576, 0.8075, 0.409, 0.8289]}, {"w": "the", "b": [0.4138, 0.8075, 0.4401, 0.8289]}, {"w": "more", "b": [0.4448, 0.8075, 0.4891, 0.8289]}, {"w": "it", "b": [0.4938, 0.8075, 0.5058, 0.8289]}, {"w": "focuses", "b": [0.5105, 0.8075, 0.5713, 0.8289]}, {"w": "on", "b": [0.576, 0.8075, 0.5981, 0.8289]}, {"w": "large", "b": [0.6028, 0.8075, 0.6435, 0.8289]}, {"w": "values", "b": [0.6483, 0.8075, 0.6999, 0.8289]}, {"w": "and", "b": [0.7046, 0.8075, 0.7362, 0.8289]}, {"w": "neglects", "b": [0.7409, 0.8075, 0.8078, 0.8289]}, {"w": "small", "b": [0.8126, 0.8075, 0.857, 0.8289]}, {"w": "ones.", "b": [0.1786, 0.8266, 0.2218, 0.848]}, {"w": "This", "b": [0.2267, 0.8266, 0.2639, 0.848]}, {"w": "is", "b": [0.2687, 0.8266, 0.2819, 0.848]}, {"w": "why", "b": [0.2868, 0.8266, 0.3212, 0.848]}, {"w": "the", "b": [0.3261, 0.8266, 0.3524, 0.848]}, {"w": "RMSE", "b": [0.3572, 0.8266, 0.4105, 0.848]}, {"w": "is", "b": [0.4153, 0.8266, 0.4285, 0.848]}, {"w": "more", "b": [0.4333, 0.8266, 0.4776, 0.848]}, {"w": "sensitive", "b": [0.4824, 0.8266, 0.554, 0.848]}, {"w": "to", "b": [0.5588, 0.8266, 0.5758, 0.848]}, {"w": "outliers", "b": [0.5806, 0.8266, 0.6438, 0.848]}, {"w": "than", "b": [0.6486, 0.8266, 0.6866, 0.848]}, {"w": "the", "b": [0.6915, 0.8266, 0.7178, 0.848]}, {"w": "MAE.", "b": [0.7226, 0.8266, 0.7722, 0.848]}, {"w": "But", "b": [0.777, 0.8266, 0.8067, 0.848]}, {"w": "when", "b": [0.8115, 0.8266, 0.8571, 0.848]}]}, {"id": "b_22", "type": "equation", "text": "44 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "44", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.478, 0.9388]}]}]}, {"page": 71, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "5 The latest version of Python 3 is recommended. Python 2.7+ may work too, but it is now deprecated, all major scientific libraries are dropping support for it, so you should migrate to Python 3 as soon as possible.", "words": [{"w": "5", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "The", "b": [0.1587, 0.8598, 0.1837, 0.8761]}, {"w": "latest", "b": [0.1873, 0.8598, 0.2203, 0.8761]}, {"w": "version", "b": [0.2239, 0.8598, 0.2707, 0.8761]}, {"w": "of", "b": [0.2743, 0.8598, 0.2871, 0.8761]}, {"w": "Python", "b": [0.2907, 0.8598, 0.337, 0.8761]}, {"w": "3", "b": [0.3407, 0.8598, 0.3483, 0.8761]}, {"w": "is", "b": [0.3519, 0.8598, 0.362, 0.8761]}, {"w": "recommended.", "b": [0.3656, 0.8598, 0.4616, 0.8761]}, {"w": "Python", "b": [0.4652, 0.8598, 0.5115, 0.8761]}, {"w": "2.7+", "b": [0.5151, 0.8598, 0.5431, 0.8761]}, {"w": "may", "b": [0.5467, 0.8598, 0.5737, 0.8761]}, {"w": "work", "b": [0.5773, 0.8598, 0.61, 0.8761]}, {"w": "too,", "b": [0.6137, 0.8598, 0.6378, 0.8761]}, {"w": "but", "b": [0.6414, 0.8598, 0.6628, 0.8761]}, {"w": "it", "b": [0.6664, 0.8598, 0.6755, 0.8761]}, {"w": "is", "b": [0.6791, 0.8598, 0.6892, 0.8761]}, {"w": "now", "b": [0.6928, 0.8598, 0.7204, 0.8761]}, {"w": "deprecated,", "b": [0.724, 0.8598, 0.7971, 0.8761]}, {"w": "all", "b": [0.8007, 0.8598, 0.8157, 0.8761]}, {"w": "major", "b": [0.8193, 0.8598, 0.857, 0.8761]}, {"w": "scientific", "b": [0.1587, 0.8749, 0.2154, 0.8912]}, {"w": "libraries", "b": [0.219, 0.8749, 0.2709, 0.8912]}, {"w": "are", "b": [0.2745, 0.8749, 0.2941, 0.8912]}, {"w": "dropping", "b": [0.2977, 0.8749, 0.3571, 0.8912]}, {"w": "support", "b": [0.3607, 0.8749, 0.4104, 0.8912]}, {"w": "for", "b": [0.414, 0.8749, 0.4327, 0.8912]}, {"w": "it,", "b": [0.4363, 0.8749, 0.449, 0.8912]}, {"w": "so", "b": [0.4526, 0.8749, 0.4665, 0.8912]}, {"w": "you", "b": [0.4701, 0.8749, 0.494, 0.8912]}, {"w": "should", "b": [0.4976, 0.8749, 0.5408, 0.8912]}, {"w": "migrate", "b": [0.5444, 0.8749, 0.5932, 0.8912]}, {"w": "to", "b": [0.5968, 0.8749, 0.6097, 0.8912]}, {"w": "Python", "b": [0.6133, 0.8749, 0.6597, 0.8912]}, {"w": "3", "b": [0.6633, 0.8749, 0.6709, 0.8912]}, {"w": "as", "b": [0.6745, 0.8749, 0.6873, 0.8912]}, {"w": "soon", "b": [0.6909, 0.8749, 0.7216, 0.8912]}, {"w": "as", "b": [0.7252, 0.8749, 0.738, 0.8912]}, {"w": "possible.", "b": [0.7416, 0.8749, 0.7963, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "outliers are exponentially rare (like in a bell-shaped curve), the RMSE performs very well and is generally preferred.", "words": [{"w": "outliers", "b": [0.1786, 0.0791, 0.2417, 0.1005]}, {"w": "are", "b": [0.248, 0.0791, 0.2738, 0.1005]}, {"w": "exponentially", "b": [0.2801, 0.0791, 0.3928, 0.1005]}, {"w": "rare", "b": [0.3991, 0.0791, 0.4325, 0.1005]}, {"w": "(like", "b": [0.4389, 0.0791, 0.4761, 0.1005]}, {"w": "in", "b": [0.4824, 0.0791, 0.4994, 0.1005]}, {"w": "a", "b": [0.5057, 0.0791, 0.5149, 0.1005]}, {"w": "bell-shaped", "b": [0.5212, 0.0791, 0.6169, 0.1005]}, {"w": "curve),", "b": [0.6232, 0.0791, 0.6819, 0.1005]}, {"w": "the", "b": [0.6882, 0.0791, 0.7146, 0.1005]}, {"w": "RMSE", "b": [0.7209, 0.0791, 0.7741, 0.1005]}, {"w": "performs", "b": [0.7804, 0.0791, 0.8571, 0.1005]}, {"w": "very", "b": [0.1786, 0.0981, 0.215, 0.1195]}, {"w": "well", "b": [0.2197, 0.0981, 0.2534, 0.1195]}, {"w": "and", "b": [0.2581, 0.0981, 0.2896, 0.1195]}, {"w": "is", "b": [0.2944, 0.0981, 0.3076, 0.1195]}, {"w": "generally", "b": [0.3123, 0.0981, 0.3881, 0.1195]}, {"w": "preferred.", "b": [0.3929, 0.0981, 0.4755, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "Check the Assumptions", "words": [{"w": "Check", "b": [0.1429, 0.1474, 0.2027, 0.176]}, {"w": "the", "b": [0.2076, 0.1474, 0.2425, 0.176]}, {"w": "Assumptions", "b": [0.2474, 0.1474, 0.3792, 0.176]}]}, {"id": "b_3", "type": "paragraph", "text": "Lastly, it is good practice to list and verify the assumptions that were made so far (by you or others); this can catch serious issues early on. For example, the district prices that your system outputs are going to be fed into a downstream Machine Learning system, and we assume that these prices are going to be used as such. But what if the downstream system actually converts the prices into categories (e.g., “cheap,” “medium,” or “expensive”) and then uses those categories instead of the prices them‐ selves? In this case, getting the price perfectly right is not important at all; your sys‐ tem just needs to get the category right. If that’s so, then the problem should have been framed as a classification task, not a regression task. You don’t want to find this out after working on a regression system for months.", "words": [{"w": "Lastly,", "b": [0.1429, 0.1819, 0.1953, 0.2033]}, {"w": "it", "b": [0.2008, 0.1819, 0.2128, 0.2033]}, {"w": "is", "b": [0.2184, 0.1819, 0.2316, 0.2033]}, {"w": "good", "b": [0.2372, 0.1819, 0.2792, 0.2033]}, {"w": "practice", "b": [0.2847, 0.1819, 0.3509, 0.2033]}, {"w": "to", "b": [0.3565, 0.1819, 0.3735, 0.2033]}, {"w": "list", "b": [0.3791, 0.1819, 0.4039, 0.2033]}, {"w": "and", "b": [0.4095, 0.1819, 0.441, 0.2033]}, {"w": "verify", "b": [0.4466, 0.1819, 0.4945, 0.2033]}, {"w": "the", "b": [0.5001, 0.1819, 0.5264, 0.2033]}, {"w": "assumptions", "b": [0.532, 0.1819, 0.6367, 0.2033]}, {"w": "that", "b": [0.6422, 0.1819, 0.6748, 0.2033]}, {"w": "were", "b": [0.6804, 0.1819, 0.7201, 0.2033]}, {"w": "made", "b": [0.7257, 0.1819, 0.7717, 0.2033]}, {"w": "so", "b": [0.7773, 0.1819, 0.7956, 0.2033]}, {"w": "far", "b": [0.8012, 0.1819, 0.8242, 0.2033]}, {"w": "(by", "b": [0.8298, 0.1819, 0.8571, 0.2033]}, {"w": "you", "b": [0.1429, 0.2009, 0.1741, 0.2223]}, {"w": "or", "b": [0.1801, 0.2009, 0.1984, 0.2223]}, {"w": "others);", "b": [0.2044, 0.2009, 0.2687, 0.2223]}, {"w": "this", "b": [0.2746, 0.2009, 0.3053, 0.2223]}, {"w": "can", "b": [0.3113, 0.2009, 0.3406, 0.2223]}, {"w": "catch", "b": [0.3466, 0.2009, 0.3904, 0.2223]}, {"w": "serious", "b": [0.3964, 0.2009, 0.4555, 0.2223]}, {"w": "issues", "b": [0.4615, 0.2009, 0.5099, 0.2223]}, {"w": "early", "b": [0.5159, 0.2009, 0.5565, 0.2223]}, {"w": "on.", "b": [0.5624, 0.2009, 0.5892, 0.2223]}, {"w": "For", "b": [0.5951, 0.2009, 0.6241, 0.2223]}, {"w": "example,", "b": [0.6301, 0.2009, 0.7044, 0.2223]}, {"w": "the", "b": [0.7103, 0.2009, 0.7366, 0.2223]}, {"w": "district", "b": [0.7426, 0.2009, 0.8017, 0.2223]}, {"w": "prices", "b": [0.8076, 0.2009, 0.8572, 0.2223]}, {"w": "that", "b": [0.1429, 0.22, 0.1754, 0.2414]}, {"w": "your", "b": [0.1825, 0.22, 0.2214, 0.2414]}, {"w": "system", "b": [0.2285, 0.22, 0.2856, 0.2414]}, {"w": "outputs", "b": [0.2926, 0.22, 0.3566, 0.2414]}, {"w": "are", "b": [0.3637, 0.22, 0.3894, 0.2414]}, {"w": "going", "b": [0.3964, 0.22, 0.4435, 0.2414]}, {"w": "to", "b": [0.4506, 0.22, 0.4675, 0.2414]}, {"w": "be", "b": [0.4746, 0.22, 0.494, 0.2414]}, {"w": "fed", "b": [0.501, 0.22, 0.527, 0.2414]}, {"w": "into", "b": [0.5341, 0.22, 0.5676, 0.2414]}, {"w": "a", "b": [0.5747, 0.22, 0.5838, 0.2414]}, {"w": "downstream", "b": [0.5908, 0.22, 0.6949, 0.2414]}, {"w": "Machine", "b": [0.7019, 0.22, 0.7751, 0.2414]}, {"w": "Learning", "b": [0.7821, 0.22, 0.8571, 0.2414]}, {"w": "system,", "b": [0.1429, 0.239, 0.2047, 0.2604]}, {"w": "and", "b": [0.2103, 0.239, 0.2419, 0.2604]}, {"w": "we", "b": [0.2475, 0.239, 0.2706, 0.2604]}, {"w": "assume", "b": [0.2762, 0.239, 0.3376, 0.2604]}, {"w": "that", "b": [0.3432, 0.239, 0.3758, 0.2604]}, {"w": "these", "b": [0.3814, 0.239, 0.4242, 0.2604]}, {"w": "prices", "b": [0.4298, 0.239, 0.4793, 0.2604]}, {"w": "are", "b": [0.4849, 0.239, 0.5107, 0.2604]}, {"w": "going", "b": [0.5163, 0.239, 0.5634, 0.2604]}, {"w": "to", "b": [0.569, 0.239, 0.5859, 0.2604]}, {"w": "be", "b": [0.5915, 0.239, 0.611, 0.2604]}, {"w": "used", "b": [0.6166, 0.239, 0.6551, 0.2604]}, {"w": "as", "b": [0.6607, 0.239, 0.6775, 0.2604]}, {"w": "such.", "b": [0.6831, 0.239, 0.7265, 0.2604]}, {"w": "But", "b": [0.7321, 0.239, 0.7618, 0.2604]}, {"w": "what", "b": [0.7674, 0.239, 0.8079, 0.2604]}, {"w": "if", "b": [0.8135, 0.239, 0.8252, 0.2604]}, {"w": "the", "b": [0.8308, 0.239, 0.8571, 0.2604]}, {"w": "downstream", "b": [0.1428, 0.2581, 0.2469, 0.2795]}, {"w": "system", "b": [0.2603, 0.2581, 0.3175, 0.2795]}, {"w": "actually", "b": [0.3309, 0.2581, 0.3955, 0.2795]}, {"w": "converts", "b": [0.4089, 0.2581, 0.4795, 0.2795]}, {"w": "the", "b": [0.4929, 0.2581, 0.5193, 0.2795]}, {"w": "prices", "b": [0.5327, 0.2581, 0.5822, 0.2795]}, {"w": "into", "b": [0.5956, 0.2581, 0.6292, 0.2795]}, {"w": "categories", "b": [0.6426, 0.2581, 0.7256, 0.2795]}, {"w": "(e.g.,", "b": [0.739, 0.2581, 0.7791, 0.2795]}, {"w": "“cheap,”", "b": [0.7925, 0.2581, 0.8571, 0.2795]}, {"w": "“medium,”", "b": [0.1429, 0.2771, 0.2314, 0.2985]}, {"w": "or", "b": [0.2371, 0.2771, 0.2555, 0.2985]}, {"w": "“expensive”)", "b": [0.2613, 0.2771, 0.3638, 0.2985]}, {"w": "and", "b": [0.3696, 0.2771, 0.4011, 0.2985]}, {"w": "then", "b": [0.4069, 0.2771, 0.4446, 0.2985]}, {"w": "uses", "b": [0.4504, 0.2771, 0.4856, 0.2985]}, {"w": "those", "b": [0.4914, 0.2771, 0.536, 0.2985]}, {"w": "categories", "b": [0.5418, 0.2771, 0.6248, 0.2985]}, {"w": "instead", "b": [0.6305, 0.2771, 0.6905, 0.2985]}, {"w": "of", "b": [0.6963, 0.2771, 0.7131, 0.2985]}, {"w": "the", "b": [0.7189, 0.2771, 0.7452, 0.2985]}, {"w": "prices", "b": [0.751, 0.2771, 0.8006, 0.2985]}, {"w": "them‐", "b": [0.8063, 0.2771, 0.8571, 0.2985]}, {"w": "selves?", "b": [0.1429, 0.2962, 0.1987, 0.3176]}, {"w": "In", "b": [0.205, 0.2962, 0.2235, 0.3176]}, {"w": "this", "b": [0.2297, 0.2962, 0.2605, 0.3176]}, {"w": "case,", "b": [0.2667, 0.2962, 0.306, 0.3176]}, {"w": "getting", "b": [0.3122, 0.2962, 0.3703, 0.3176]}, {"w": "the", "b": [0.3766, 0.2962, 0.4029, 0.3176]}, {"w": "price", "b": [0.4092, 0.2962, 0.4511, 0.3176]}, {"w": "perfectly", "b": [0.4574, 0.2962, 0.5299, 0.3176]}, {"w": "right", "b": [0.5362, 0.2962, 0.5763, 0.3176]}, {"w": "is", "b": [0.5826, 0.2962, 0.5959, 0.3176]}, {"w": "not", "b": [0.6022, 0.2962, 0.6305, 0.3176]}, {"w": "important", "b": [0.6368, 0.2962, 0.7212, 0.3176]}, {"w": "at", "b": [0.7275, 0.2962, 0.7426, 0.3176]}, {"w": "all;", "b": [0.7489, 0.2962, 0.7733, 0.3176]}, {"w": "your", "b": [0.7796, 0.2962, 0.8186, 0.3176]}, {"w": "sys‐", "b": [0.8249, 0.2962, 0.8571, 0.3176]}, {"w": "tem", "b": [0.1429, 0.3152, 0.1751, 0.3366]}, {"w": "just", "b": [0.1825, 0.3152, 0.2129, 0.3366]}, {"w": "needs", "b": [0.2204, 0.3152, 0.2681, 0.3366]}, {"w": "to", "b": [0.2755, 0.3152, 0.2925, 0.3366]}, {"w": "get", "b": [0.3, 0.3152, 0.3249, 0.3366]}, {"w": "the", "b": [0.3323, 0.3152, 0.3587, 0.3366]}, {"w": "category", "b": [0.3661, 0.3152, 0.4371, 0.3366]}, {"w": "right.", "b": [0.4446, 0.3152, 0.4895, 0.3366]}, {"w": "If", "b": [0.4969, 0.3152, 0.5102, 0.3366]}, {"w": "that’s", "b": [0.5176, 0.3152, 0.5599, 0.3366]}, {"w": "so,", "b": [0.5674, 0.3152, 0.5898, 0.3366]}, {"w": "then", "b": [0.5972, 0.3152, 0.6349, 0.3366]}, {"w": "the", "b": [0.6424, 0.3152, 0.6687, 0.3366]}, {"w": "problem", "b": [0.6761, 0.3152, 0.7472, 0.3366]}, {"w": "should", "b": [0.7546, 0.3152, 0.8113, 0.3366]}, {"w": "have", "b": [0.8187, 0.3152, 0.8571, 0.3366]}, {"w": "been", "b": [0.1429, 0.3343, 0.1826, 0.3557]}, {"w": "framed", "b": [0.1882, 0.3343, 0.2482, 0.3557]}, {"w": "as", "b": [0.2538, 0.3343, 0.2706, 0.3557]}, {"w": "a", "b": [0.2763, 0.3343, 0.2854, 0.3557]}, {"w": "classification", "b": [0.2911, 0.3343, 0.3985, 0.3557]}, {"w": "task,", "b": [0.4041, 0.3343, 0.4424, 0.3557]}, {"w": "not", "b": [0.448, 0.3343, 0.4764, 0.3557]}, {"w": "a", "b": [0.4821, 0.3343, 0.4912, 0.3557]}, {"w": "regression", "b": [0.4969, 0.3343, 0.5827, 0.3557]}, {"w": "task.", "b": [0.5884, 0.3343, 0.6266, 0.3557]}, {"w": "You", "b": [0.6323, 0.3343, 0.6646, 0.3557]}, {"w": "don’t", "b": [0.6703, 0.3343, 0.7119, 0.3557]}, {"w": "want", "b": [0.7176, 0.3343, 0.7583, 0.3557]}, {"w": "to", "b": [0.764, 0.3343, 0.781, 0.3557]}, {"w": "find", "b": [0.7866, 0.3343, 0.8208, 0.3557]}, {"w": "this", "b": [0.8264, 0.3343, 0.8572, 0.3557]}, {"w": "out", "b": [0.1429, 0.3533, 0.1709, 0.3747]}, {"w": "after", "b": [0.1756, 0.3533, 0.2139, 0.3747]}, {"w": "working", "b": [0.2186, 0.3533, 0.2883, 0.3747]}, {"w": "on", "b": [0.293, 0.3533, 0.315, 0.3747]}, {"w": "a", "b": [0.3198, 0.3533, 0.3289, 0.3747]}, {"w": "regression", "b": [0.3337, 0.3533, 0.4195, 0.3747]}, {"w": "system", "b": [0.4242, 0.3533, 0.4813, 0.3747]}, {"w": "for", "b": [0.486, 0.3533, 0.5106, 0.3747]}, {"w": "months.", "b": [0.5153, 0.3533, 0.5839, 0.3747]}]}, {"id": "b_4", "type": "paragraph", "text": "Fortunately, after talking with the team in charge of the downstream system, you are confident that they do indeed need the actual prices, not just categories. Great! You’re all set, the lights are green, and you can start coding now!", "words": [{"w": "Fortunately,", "b": [0.1429, 0.3814, 0.2427, 0.4028]}, {"w": "after", "b": [0.2484, 0.3814, 0.2867, 0.4028]}, {"w": "talking", "b": [0.2924, 0.3814, 0.3503, 0.4028]}, {"w": "with", "b": [0.356, 0.3814, 0.3934, 0.4028]}, {"w": "the", "b": [0.3991, 0.3814, 0.4255, 0.4028]}, {"w": "team", "b": [0.4312, 0.3814, 0.4726, 0.4028]}, {"w": "in", "b": [0.4784, 0.3814, 0.4954, 0.4028]}, {"w": "charge", "b": [0.5011, 0.3814, 0.5565, 0.4028]}, {"w": "of", "b": [0.5623, 0.3814, 0.5791, 0.4028]}, {"w": "the", "b": [0.5848, 0.3814, 0.6112, 0.4028]}, {"w": "downstream", "b": [0.6169, 0.3814, 0.721, 0.4028]}, {"w": "system,", "b": [0.7268, 0.3814, 0.7887, 0.4028]}, {"w": "you", "b": [0.7944, 0.3814, 0.8257, 0.4028]}, {"w": "are", "b": [0.8314, 0.3814, 0.8571, 0.4028]}, {"w": "confident", "b": [0.1429, 0.4005, 0.2226, 0.4219]}, {"w": "that", "b": [0.2278, 0.4005, 0.2603, 0.4219]}, {"w": "they", "b": [0.2654, 0.4005, 0.3013, 0.4219]}, {"w": "do", "b": [0.3065, 0.4005, 0.3281, 0.4219]}, {"w": "indeed", "b": [0.3332, 0.4005, 0.3899, 0.4219]}, {"w": "need", "b": [0.395, 0.4005, 0.4351, 0.4219]}, {"w": "the", "b": [0.4402, 0.4005, 0.4665, 0.4219]}, {"w": "actual", "b": [0.4716, 0.4005, 0.5214, 0.4219]}, {"w": "prices,", "b": [0.5265, 0.4005, 0.5808, 0.4219]}, {"w": "not", "b": [0.5859, 0.4005, 0.6143, 0.4219]}, {"w": "just", "b": [0.6194, 0.4005, 0.6498, 0.4219]}, {"w": "categories.", "b": [0.6549, 0.4005, 0.7426, 0.4219]}, {"w": "Great!", "b": [0.7478, 0.4005, 0.8001, 0.4219]}, {"w": "You’re", "b": [0.8052, 0.4005, 0.8571, 0.4219]}, {"w": "all", "b": [0.1428, 0.4195, 0.1625, 0.4409]}, {"w": "set,", "b": [0.1673, 0.4195, 0.1949, 0.4409]}, {"w": "the", "b": [0.1996, 0.4195, 0.2259, 0.4409]}, {"w": "lights", "b": [0.2307, 0.4195, 0.276, 0.4409]}, {"w": "are", "b": [0.2807, 0.4195, 0.3065, 0.4409]}, {"w": "green,", "b": [0.3112, 0.4195, 0.3625, 0.4409]}, {"w": "and", "b": [0.3672, 0.4195, 0.3988, 0.4409]}, {"w": "you", "b": [0.4035, 0.4195, 0.4348, 0.4409]}, {"w": "can", "b": [0.4395, 0.4195, 0.4688, 0.4409]}, {"w": "start", "b": [0.4736, 0.4195, 0.5108, 0.4409]}, {"w": "coding", "b": [0.5155, 0.4195, 0.5727, 0.4409]}, {"w": "now!", "b": [0.5774, 0.4195, 0.6195, 0.4409]}]}, {"id": "b_5", "type": "paragraph", "text": "Get the Data", "words": [{"w": "Get", "b": [0.1429, 0.4539, 0.1855, 0.4882]}, {"w": "the", "b": [0.1914, 0.4539, 0.2333, 0.4882]}, {"w": "Data", "b": [0.2392, 0.4539, 0.2973, 0.4882]}]}, {"id": "b_6", "type": "paragraph", "text": "It’s time to get your hands dirty. Don’t hesitate to pick up your laptop and walk through the following code examples in a Jupyter notebook. The full Jupyter note‐ book is available at https://github.com/ageron/handson-ml2.", "words": [{"w": "It’s", "b": [0.1428, 0.4951, 0.1652, 0.5165]}, {"w": "time", "b": [0.1741, 0.4951, 0.212, 0.5165]}, {"w": "to", "b": [0.2208, 0.4951, 0.2378, 0.5165]}, {"w": "get", "b": [0.2467, 0.4951, 0.2716, 0.5165]}, {"w": "your", "b": [0.2805, 0.4951, 0.3195, 0.5165]}, {"w": "hands", "b": [0.3283, 0.4951, 0.3786, 0.5165]}, {"w": "dirty.", "b": [0.3875, 0.4951, 0.431, 0.5165]}, {"w": "Don’t", "b": [0.4398, 0.4951, 0.4857, 0.5165]}, {"w": "hesitate", "b": [0.4946, 0.4951, 0.5581, 0.5165]}, {"w": "to", "b": [0.567, 0.4951, 0.584, 0.5165]}, {"w": "pick", "b": [0.5928, 0.4951, 0.6285, 0.5165]}, {"w": "up", "b": [0.6373, 0.4951, 0.6593, 0.5165]}, {"w": "your", "b": [0.6682, 0.4951, 0.7072, 0.5165]}, {"w": "laptop", "b": [0.716, 0.4951, 0.7688, 0.5165]}, {"w": "and", "b": [0.7777, 0.4951, 0.8093, 0.5165]}, {"w": "walk", "b": [0.8181, 0.4951, 0.8571, 0.5165]}, {"w": "through", "b": [0.1429, 0.5141, 0.2106, 0.5356]}, {"w": "the", "b": [0.218, 0.5141, 0.2443, 0.5356]}, {"w": "following", "b": [0.2516, 0.5141, 0.3306, 0.5356]}, {"w": "code", "b": [0.3379, 0.5141, 0.3772, 0.5356]}, {"w": "examples", "b": [0.3845, 0.5141, 0.4617, 0.5356]}, {"w": "in", "b": [0.469, 0.5141, 0.486, 0.5356]}, {"w": "a", "b": [0.4933, 0.5141, 0.5025, 0.5356]}, {"w": "Jupyter", "b": [0.5098, 0.5141, 0.5705, 0.5356]}, {"w": "notebook.", "b": [0.5778, 0.5141, 0.6619, 0.5356]}, {"w": "The", "b": [0.6693, 0.5141, 0.7021, 0.5356]}, {"w": "full", "b": [0.7094, 0.5141, 0.7372, 0.5356]}, {"w": "Jupyter", "b": [0.7445, 0.5141, 0.8052, 0.5356]}, {"w": "note‐", "b": [0.8125, 0.5141, 0.8572, 0.5356]}, {"w": "book", "b": [0.1429, 0.5332, 0.185, 0.5546]}, {"w": "is", "b": [0.1898, 0.5332, 0.203, 0.5546]}, {"w": "available", "b": [0.2077, 0.5332, 0.28, 0.5546]}, {"w": "at", "b": [0.2847, 0.5332, 0.2998, 0.5546]}, {"w": "https://github.com/ageron/handson-ml2.", "b": [0.3045, 0.533, 0.6335, 0.5546]}]}, {"id": "b_7", "type": "paragraph", "text": "Create the Workspace", "words": [{"w": "Create", "b": [0.1429, 0.5674, 0.2094, 0.5959]}, {"w": "the", "b": [0.2144, 0.5674, 0.2492, 0.5959]}, {"w": "Workspace", "b": [0.2542, 0.5674, 0.366, 0.5959]}]}, {"id": "b_8", "type": "paragraph", "text": "First you will need to have Python installed. It is probably already installed on your system. If not, you can get it at https://www.python.org/.5", "words": [{"w": "First", "b": [0.1429, 0.6018, 0.1812, 0.6233]}, {"w": "you", "b": [0.1876, 0.6018, 0.2189, 0.6233]}, {"w": "will", "b": [0.2253, 0.6018, 0.2557, 0.6233]}, {"w": "need", "b": [0.2622, 0.6018, 0.3023, 0.6233]}, {"w": "to", "b": [0.3087, 0.6018, 0.3257, 0.6233]}, {"w": "have", "b": [0.3322, 0.6018, 0.3706, 0.6233]}, {"w": "Python", "b": [0.377, 0.6018, 0.4378, 0.6233]}, {"w": "installed.", "b": [0.4442, 0.6018, 0.5195, 0.6233]}, {"w": "It", "b": [0.526, 0.6018, 0.5386, 0.6233]}, {"w": "is", "b": [0.545, 0.6018, 0.5583, 0.6233]}, {"w": "probably", "b": [0.5647, 0.6018, 0.6391, 0.6233]}, {"w": "already", "b": [0.6456, 0.6018, 0.7063, 0.6233]}, {"w": "installed", "b": [0.7127, 0.6018, 0.7833, 0.6233]}, {"w": "on", "b": [0.7897, 0.6018, 0.8117, 0.6233]}, {"w": "your", "b": [0.8182, 0.6018, 0.8571, 0.6233]}, {"w": "system.", "b": [0.1429, 0.6209, 0.2047, 0.6423]}, {"w": "If", "b": [0.2095, 0.6209, 0.2227, 0.6423]}, {"w": "not,", "b": [0.2275, 0.6209, 0.2606, 0.6423]}, {"w": "you", "b": [0.2653, 0.6209, 0.2966, 0.6423]}, {"w": "can", "b": [0.3013, 0.6209, 0.3306, 0.6423]}, {"w": "get", "b": [0.3354, 0.6209, 0.3603, 0.6423]}, {"w": "it", "b": [0.3651, 0.6209, 0.377, 0.6423]}, {"w": "at", "b": [0.3817, 0.6209, 0.3968, 0.6423]}, {"w": "https://www.python.org/.5", "b": [0.4016, 0.6207, 0.6104, 0.6423]}]}, {"id": "b_9", "type": "paragraph", "text": "Next you need to create a workspace directory for your Machine Learning code and datasets. Open a terminal and type the following commands (after the $ prompts):", "words": [{"w": "Next", "b": [0.1429, 0.649, 0.1829, 0.6704]}, {"w": "you", "b": [0.189, 0.649, 0.2202, 0.6704]}, {"w": "need", "b": [0.2264, 0.649, 0.2665, 0.6704]}, {"w": "to", "b": [0.2726, 0.649, 0.2896, 0.6704]}, {"w": "create", "b": [0.2957, 0.649, 0.3451, 0.6704]}, {"w": "a", "b": [0.3512, 0.649, 0.3604, 0.6704]}, {"w": "workspace", "b": [0.3665, 0.649, 0.4548, 0.6704]}, {"w": "directory", "b": [0.461, 0.649, 0.5378, 0.6704]}, {"w": "for", "b": [0.544, 0.649, 0.5685, 0.6704]}, {"w": "your", "b": [0.5746, 0.649, 0.6136, 0.6704]}, {"w": "Machine", "b": [0.6197, 0.649, 0.6929, 0.6704]}, {"w": "Learning", "b": [0.699, 0.649, 0.774, 0.6704]}, {"w": "code", "b": [0.7802, 0.649, 0.8195, 0.6704]}, {"w": "and", "b": [0.8256, 0.649, 0.8571, 0.6704]}, {"w": "datasets.", "b": [0.1429, 0.669, 0.2134, 0.6904]}, {"w": "Open", "b": [0.2181, 0.669, 0.2648, 0.6904]}, {"w": "a", "b": [0.2695, 0.669, 0.2787, 0.6904]}, {"w": "terminal", "b": [0.2834, 0.669, 0.3548, 0.6904]}, {"w": "and", "b": [0.3595, 0.669, 0.3911, 0.6904]}, {"w": "type", "b": [0.3958, 0.669, 0.4315, 0.6904]}, {"w": "the", "b": [0.4362, 0.669, 0.4626, 0.6904]}, {"w": "following", "b": [0.4673, 0.669, 0.5463, 0.6904]}, {"w": "commands", "b": [0.551, 0.669, 0.6437, 0.6904]}, {"w": "(after", "b": [0.6485, 0.669, 0.6939, 0.6904]}, {"w": "the", "b": [0.6986, 0.669, 0.725, 0.6904]}, {"w": "$", "b": [0.7297, 0.6721, 0.7396, 0.6872]}, {"w": "prompts):", "b": [0.7443, 0.669, 0.8272, 0.6904]}]}, {"id": "b_10", "type": "paragraph", "text": "$ export ML_PATH=\"$HOME/ml\" # You can change the path if you prefer $ mkdir -p $ML_PATH", "words": [{"w": "$", "b": [0.1766, 0.7009, 0.185, 0.7138]}, {"w": "export", "b": [0.1935, 0.7009, 0.2441, 0.7138]}, {"w": "ML_PATH=\"$HOME/ml\"", "b": [0.2525, 0.7009, 0.4043, 0.7138]}, {"w": "#", "b": [0.4549, 0.7009, 0.4633, 0.7138]}, {"w": "You", "b": [0.4717, 0.7009, 0.497, 0.7138]}, {"w": "can", "b": [0.5055, 0.7009, 0.5308, 0.7138]}, {"w": "change", "b": [0.5392, 0.7009, 0.5898, 0.7138]}, {"w": "the", "b": [0.5982, 0.7009, 0.6235, 0.7138]}, {"w": "path", "b": [0.632, 0.7009, 0.6657, 0.7138]}, {"w": "if", "b": [0.6741, 0.7009, 0.691, 0.7138]}, {"w": "you", "b": [0.6994, 0.7009, 0.7247, 0.7138]}, {"w": "prefer", "b": [0.7331, 0.7009, 0.7837, 0.7138]}, {"w": "$", "b": [0.1766, 0.7163, 0.185, 0.7292]}, {"w": "mkdir", "b": [0.1935, 0.7163, 0.2356, 0.7292]}, {"w": "-p", "b": [0.2441, 0.7163, 0.2609, 0.7292]}, {"w": "$ML_PATH", "b": [0.2694, 0.7163, 0.3368, 0.7292]}]}, {"id": "b_11", "type": "paragraph", "text": "You will need a number of Python modules: Jupyter, NumPy, Pandas, Matplotlib, and Scikit-Learn. If you already have Jupyter running with all these modules installed, you can safely skip to “Download the Data” on page 49. If you don’t have them yet, there are many ways to install them (and their dependencies). You can use your sys‐", "words": [{"w": "You", "b": [0.1429, 0.737, 0.1752, 0.7584]}, {"w": "will", "b": [0.1804, 0.737, 0.2108, 0.7584]}, {"w": "need", "b": [0.2161, 0.737, 0.2562, 0.7584]}, {"w": "a", "b": [0.2614, 0.737, 0.2705, 0.7584]}, {"w": "number", "b": [0.2758, 0.737, 0.342, 0.7584]}, {"w": "of", "b": [0.3473, 0.737, 0.3641, 0.7584]}, {"w": "Python", "b": [0.3693, 0.737, 0.4301, 0.7584]}, {"w": "modules:", "b": [0.4353, 0.737, 0.5116, 0.7584]}, {"w": "Jupyter,", "b": [0.5168, 0.737, 0.5809, 0.7584]}, {"w": "NumPy,", "b": [0.5861, 0.737, 0.6535, 0.7584]}, {"w": "Pandas,", "b": [0.6587, 0.737, 0.7231, 0.7584]}, {"w": "Matplotlib,", "b": [0.7283, 0.737, 0.8204, 0.7584]}, {"w": "and", "b": [0.8256, 0.737, 0.8571, 0.7584]}, {"w": "Scikit-Learn.", "b": [0.1429, 0.756, 0.2499, 0.7774]}, {"w": "If", "b": [0.2579, 0.756, 0.2712, 0.7774]}, {"w": "you", "b": [0.2792, 0.756, 0.3104, 0.7774]}, {"w": "already", "b": [0.3184, 0.756, 0.3791, 0.7774]}, {"w": "have", "b": [0.3871, 0.756, 0.4255, 0.7774]}, {"w": "Jupyter", "b": [0.4335, 0.756, 0.4942, 0.7774]}, {"w": "running", "b": [0.5022, 0.756, 0.5705, 0.7774]}, {"w": "with", "b": [0.5785, 0.756, 0.6158, 0.7774]}, {"w": "all", "b": [0.6238, 0.756, 0.6435, 0.7774]}, {"w": "these", "b": [0.6515, 0.756, 0.6943, 0.7774]}, {"w": "modules", "b": [0.7023, 0.756, 0.7739, 0.7774]}, {"w": "installed,", "b": [0.7819, 0.756, 0.8571, 0.7774]}, {"w": "you", "b": [0.1429, 0.7751, 0.1741, 0.7965]}, {"w": "can", "b": [0.1806, 0.7751, 0.21, 0.7965]}, {"w": "safely", "b": [0.2165, 0.7751, 0.2631, 0.7965]}, {"w": "skip", "b": [0.2696, 0.7751, 0.3041, 0.7965]}, {"w": "to", "b": [0.3106, 0.7751, 0.3276, 0.7965]}, {"w": "“Download", "b": [0.3341, 0.7751, 0.4301, 0.7965]}, {"w": "the", "b": [0.4366, 0.7751, 0.4629, 0.7965]}, {"w": "Data”", "b": [0.4694, 0.7751, 0.5157, 0.7965]}, {"w": "on", "b": [0.5222, 0.7751, 0.5442, 0.7965]}, {"w": "page", "b": [0.5507, 0.7751, 0.5894, 0.7965]}, {"w": "49.", "b": [0.5959, 0.7751, 0.6207, 0.7965]}, {"w": "If", "b": [0.6272, 0.7751, 0.6404, 0.7965]}, {"w": "you", "b": [0.6469, 0.7751, 0.6782, 0.7965]}, {"w": "don’t", "b": [0.6847, 0.7751, 0.7263, 0.7965]}, {"w": "have", "b": [0.7328, 0.7751, 0.7712, 0.7965]}, {"w": "them", "b": [0.7777, 0.7751, 0.8211, 0.7965]}, {"w": "yet,", "b": [0.8276, 0.7751, 0.8572, 0.7965]}, {"w": "there", "b": [0.1429, 0.7941, 0.1858, 0.8155]}, {"w": "are", "b": [0.1917, 0.7941, 0.2175, 0.8155]}, {"w": "many", "b": [0.2235, 0.7941, 0.2701, 0.8155]}, {"w": "ways", "b": [0.2761, 0.7941, 0.3164, 0.8155]}, {"w": "to", "b": [0.3223, 0.7941, 0.3393, 0.8155]}, {"w": "install", "b": [0.3453, 0.7941, 0.396, 0.8155]}, {"w": "them", "b": [0.4019, 0.7941, 0.4453, 0.8155]}, {"w": "(and", "b": [0.4513, 0.7941, 0.49, 0.8155]}, {"w": "their", "b": [0.496, 0.7941, 0.5357, 0.8155]}, {"w": "dependencies).", "b": [0.5416, 0.7941, 0.6668, 0.8155]}, {"w": "You", "b": [0.6727, 0.7941, 0.7051, 0.8155]}, {"w": "can", "b": [0.7111, 0.7941, 0.7404, 0.8155]}, {"w": "use", "b": [0.7464, 0.7941, 0.774, 0.8155]}, {"w": "your", "b": [0.7799, 0.7941, 0.8189, 0.8155]}, {"w": "sys‐", "b": [0.8249, 0.7941, 0.8571, 0.8155]}]}, {"id": "b_12", "type": "paragraph", "text": "Get the Data | 45", "words": [{"w": "Get", "b": [0.7296, 0.9225, 0.7499, 0.9388]}, {"w": "the", "b": [0.7528, 0.9225, 0.7726, 0.9388]}, {"w": "Data", "b": [0.7755, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "45", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 72, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 We will show the installation steps using pip in a bash shell on a Linux or MacOS system. You may need to adapt these commands to your own system. On Windows, we recommend installing Anaconda instead.", "words": [{"w": "6", "b": [0.1451, 0.7443, 0.1518, 0.7586]}, {"w": "We", "b": [0.1587, 0.7428, 0.1793, 0.7591]}, {"w": "will", "b": [0.183, 0.7428, 0.2061, 0.7591]}, {"w": "show", "b": [0.2097, 0.7428, 0.243, 0.7591]}, {"w": "the", "b": [0.2466, 0.7428, 0.2667, 0.7591]}, {"w": "installation", "b": [0.2703, 0.7428, 0.3414, 0.7591]}, {"w": "steps", "b": [0.345, 0.7428, 0.3766, 0.7591]}, {"w": "using", "b": [0.3802, 0.7428, 0.4148, 0.7591]}, {"w": "pip", "b": [0.4184, 0.7428, 0.4393, 0.7591]}, {"w": "in", "b": [0.4429, 0.7428, 0.4558, 0.7591]}, {"w": "a", "b": [0.4594, 0.7428, 0.4664, 0.7591]}, {"w": "bash", "b": [0.47, 0.7428, 0.4993, 0.7591]}, {"w": "shell", "b": [0.5029, 0.7428, 0.532, 0.7591]}, {"w": "on", "b": [0.5356, 0.7428, 0.5524, 0.7591]}, {"w": "a", "b": [0.556, 0.7428, 0.563, 0.7591]}, {"w": "Linux", "b": [0.5666, 0.7428, 0.6037, 0.7591]}, {"w": "or", "b": [0.6073, 0.7428, 0.6212, 0.7591]}, {"w": "MacOS", "b": [0.6248, 0.7428, 0.6718, 0.7591]}, {"w": "system.", "b": [0.6754, 0.7428, 0.7225, 0.7591]}, {"w": "You", "b": [0.7261, 0.7428, 0.7508, 0.7591]}, {"w": "may", "b": [0.7544, 0.7428, 0.7813, 0.7591]}, {"w": "need", "b": [0.785, 0.7428, 0.8155, 0.7591]}, {"w": "to", "b": [0.8191, 0.7428, 0.832, 0.7591]}, {"w": "adapt", "b": [0.1587, 0.7579, 0.1939, 0.7742]}, {"w": "these", "b": [0.1975, 0.7579, 0.2301, 0.7742]}, {"w": "commands", "b": [0.2337, 0.7579, 0.3044, 0.7742]}, {"w": "to", "b": [0.308, 0.7579, 0.321, 0.7742]}, {"w": "your", "b": [0.3246, 0.7579, 0.3543, 0.7742]}, {"w": "own", "b": [0.3579, 0.7579, 0.3855, 0.7742]}, {"w": "system.", "b": [0.3891, 0.7579, 0.4363, 0.7742]}, {"w": "On", "b": [0.4399, 0.7579, 0.4604, 0.7742]}, {"w": "Windows,", "b": [0.464, 0.7579, 0.5285, 0.7742]}, {"w": "we", "b": [0.5321, 0.7579, 0.5497, 0.7742]}, {"w": "recommend", "b": [0.5533, 0.7579, 0.6306, 0.7742]}, {"w": "installing", "b": [0.6342, 0.7579, 0.6931, 0.7742]}, {"w": "Anaconda", "b": [0.6967, 0.7579, 0.7622, 0.7742]}, {"w": "instead.", "b": [0.7658, 0.7579, 0.8151, 0.7742]}]}, {"id": "b_1", "type": "paragraph", "text": "7 If you want to upgrade pip for all users on your machine rather than just your own user, you should remove the --user option and make sure you have administrator rights (e.g., by adding sudo before the whole com‐ mand on Linux or MacOSX).", "words": [{"w": "7", "b": [0.1451, 0.7791, 0.1518, 0.7934]}, {"w": "If", "b": [0.1587, 0.7776, 0.1688, 0.7939]}, {"w": "you", "b": [0.1724, 0.7776, 0.1963, 0.7939]}, {"w": "want", "b": [0.1999, 0.7776, 0.2309, 0.7939]}, {"w": "to", "b": [0.2345, 0.7776, 0.2475, 0.7939]}, {"w": "upgrade", "b": [0.2511, 0.7776, 0.3032, 0.7939]}, {"w": "pip", "b": [0.3068, 0.7776, 0.3277, 0.7939]}, {"w": "for", "b": [0.3313, 0.7776, 0.35, 0.7939]}, {"w": "all", "b": [0.3536, 0.7776, 0.3686, 0.7939]}, {"w": "users", "b": [0.3722, 0.7776, 0.4049, 0.7939]}, {"w": "on", "b": [0.4085, 0.7776, 0.4253, 0.7939]}, {"w": "your", "b": [0.4289, 0.7776, 0.4586, 0.7939]}, {"w": "machine", "b": [0.4622, 0.7776, 0.517, 0.7939]}, {"w": "rather", "b": [0.5207, 0.7776, 0.5592, 0.7939]}, {"w": "than", "b": [0.5628, 0.7776, 0.5917, 0.7939]}, {"w": "just", "b": [0.5953, 0.7776, 0.6185, 0.7939]}, {"w": "your", "b": [0.6221, 0.7776, 0.6518, 0.7939]}, {"w": "own", "b": [0.6554, 0.7776, 0.683, 0.7939]}, {"w": "user,", "b": [0.6867, 0.7776, 0.7162, 0.7939]}, {"w": "you", "b": [0.7198, 0.7776, 0.7436, 0.7939]}, {"w": "should", "b": [0.7472, 0.7776, 0.7904, 0.7939]}, {"w": "remove", "b": [0.794, 0.7776, 0.8418, 0.7939]}, {"w": "the", "b": [0.1587, 0.7937, 0.1788, 0.8101]}, {"w": "--user", "b": [0.1824, 0.7962, 0.2276, 0.8077]}, {"w": "option", "b": [0.2312, 0.7937, 0.2735, 0.8101]}, {"w": "and", "b": [0.2771, 0.7937, 0.3012, 0.8101]}, {"w": "make", "b": [0.3048, 0.7937, 0.3393, 0.8101]}, {"w": "sure", "b": [0.343, 0.7937, 0.3698, 0.8101]}, {"w": "you", "b": [0.3734, 0.7937, 0.3973, 0.8101]}, {"w": "have", "b": [0.4009, 0.7937, 0.4301, 0.8101]}, {"w": "administrator", "b": [0.4337, 0.7937, 0.5213, 0.8101]}, {"w": "rights", "b": [0.5249, 0.7937, 0.5613, 0.8101]}, {"w": "(e.g.,", "b": [0.5649, 0.7937, 0.5954, 0.8101]}, {"w": "by", "b": [0.599, 0.7937, 0.6144, 0.8101]}, {"w": "adding", "b": [0.618, 0.7937, 0.6621, 0.8101]}, {"w": "sudo", "b": [0.6657, 0.7962, 0.6959, 0.8077]}, {"w": "before", "b": [0.6995, 0.7937, 0.7397, 0.8101]}, {"w": "the", "b": [0.7433, 0.7937, 0.7634, 0.8101]}, {"w": "whole", "b": [0.767, 0.7937, 0.8052, 0.8101]}, {"w": "com‐", "b": [0.8088, 0.7937, 0.8422, 0.8101]}, {"w": "mand", "b": [0.1587, 0.8089, 0.1958, 0.8252]}, {"w": "on", "b": [0.1994, 0.8089, 0.2161, 0.8252]}, {"w": "Linux", "b": [0.2197, 0.8089, 0.2568, 0.8252]}, {"w": "or", "b": [0.2604, 0.8089, 0.2744, 0.8252]}, {"w": "MacOSX).", "b": [0.278, 0.8089, 0.3445, 0.8252]}]}, {"id": "b_2", "type": "paragraph", "text": "8 Alternative tools include venv (very similar to virtualenv and included in the standard library), virtualenv‐ wrapper (provides extra functionalities on top of virtualenv), pyenv (allows easy switching between Python versions), and pipenv (a great packaging tool by the same author as the popular requests library, built on top of pip, virtualenv and more).", "words": [{"w": "8", "b": [0.1451, 0.83, 0.1518, 0.8443]}, {"w": "Alternative", "b": [0.1587, 0.8285, 0.2297, 0.8448]}, {"w": "tools", "b": [0.2333, 0.8285, 0.2642, 0.8448]}, {"w": "include", "b": [0.2678, 0.8285, 0.315, 0.8448]}, {"w": "venv", "b": [0.3186, 0.8285, 0.3484, 0.8448]}, {"w": "(very", "b": [0.352, 0.8285, 0.3852, 0.8448]}, {"w": "similar", "b": [0.3888, 0.8285, 0.433, 0.8448]}, {"w": "to", "b": [0.4366, 0.8285, 0.4496, 0.8448]}, {"w": "virtualenv", "b": [0.4532, 0.8285, 0.5173, 0.8448]}, {"w": "and", "b": [0.5209, 0.8285, 0.545, 0.8448]}, {"w": "included", "b": [0.5486, 0.8285, 0.6042, 0.8448]}, {"w": "in", "b": [0.6078, 0.8285, 0.6207, 0.8448]}, {"w": "the", "b": [0.6243, 0.8285, 0.6444, 0.8448]}, {"w": "standard", "b": [0.648, 0.8285, 0.7039, 0.8448]}, {"w": "library),", "b": [0.7075, 0.8285, 0.7595, 0.8448]}, {"w": "virtualenv‐", "b": [0.7631, 0.8285, 0.8329, 0.8448]}, {"w": "wrapper", "b": [0.1587, 0.8436, 0.2114, 0.8599]}, {"w": "(provides", "b": [0.215, 0.8436, 0.2754, 0.8599]}, {"w": "extra", "b": [0.279, 0.8436, 0.3109, 0.8599]}, {"w": "functionalities", "b": [0.3145, 0.8436, 0.4058, 0.8599]}, {"w": "on", "b": [0.4094, 0.8436, 0.4262, 0.8599]}, {"w": "top", "b": [0.4298, 0.8436, 0.4511, 0.8599]}, {"w": "of", "b": [0.4547, 0.8436, 0.4675, 0.8599]}, {"w": "virtualenv),", "b": [0.4711, 0.8436, 0.5443, 0.8599]}, {"w": "pyenv", "b": [0.5479, 0.8436, 0.586, 0.8599]}, {"w": "(allows", "b": [0.5896, 0.8436, 0.6348, 0.8599]}, {"w": "easy", "b": [0.6384, 0.8436, 0.6653, 0.8599]}, {"w": "switching", "b": [0.6689, 0.8436, 0.7302, 0.8599]}, {"w": "between", "b": [0.7338, 0.8436, 0.7865, 0.8599]}, {"w": "Python", "b": [0.7901, 0.8436, 0.8364, 0.8599]}, {"w": "versions),", "b": [0.1587, 0.8598, 0.2205, 0.8761]}, {"w": "and", "b": [0.2241, 0.8598, 0.2481, 0.8761]}, {"w": "pipenv", "b": [0.2517, 0.8598, 0.295, 0.8761]}, {"w": "(a", "b": [0.2987, 0.8598, 0.3111, 0.8761]}, {"w": "great", "b": [0.3147, 0.8598, 0.3463, 0.8761]}, {"w": "packaging", "b": [0.3499, 0.8598, 0.4145, 0.8761]}, {"w": "tool", "b": [0.4181, 0.8598, 0.4432, 0.8761]}, {"w": "by", "b": [0.4468, 0.8598, 0.4621, 0.8761]}, {"w": "the", "b": [0.4657, 0.8598, 0.4858, 0.8761]}, {"w": "same", "b": [0.4894, 0.8598, 0.5219, 0.8761]}, {"w": "author", "b": [0.5255, 0.8598, 0.5679, 0.8761]}, {"w": "as", "b": [0.5715, 0.8598, 0.5843, 0.8761]}, {"w": "the", "b": [0.5879, 0.8598, 0.608, 0.8761]}, {"w": "popular", "b": [0.6116, 0.8598, 0.6616, 0.8761]}, {"w": "requests", "b": [0.6652, 0.8622, 0.7256, 0.8737]}, {"w": "library,", "b": [0.7292, 0.8598, 0.7744, 0.8761]}, {"w": "built", "b": [0.778, 0.8598, 0.8077, 0.8761]}, {"w": "on", "b": [0.8113, 0.8598, 0.828, 0.8761]}, {"w": "top", "b": [0.8316, 0.8598, 0.8529, 0.8761]}, {"w": "of", "b": [0.1587, 0.8749, 0.1715, 0.8912]}, {"w": "pip,", "b": [0.1751, 0.8749, 0.1992, 0.8912]}, {"w": "virtualenv", "b": [0.2028, 0.8749, 0.2669, 0.8912]}, {"w": "and", "b": [0.2705, 0.8749, 0.2946, 0.8912]}, {"w": "more).", "b": [0.2982, 0.8749, 0.341, 0.8912]}]}, {"id": "b_3", "type": "paragraph", "text": "tem’s packaging system (e.g., apt-get on Ubuntu, or MacPorts or HomeBrew on MacOS), install a Scientific Python distribution such as Anaconda and use its packag‐ ing system, or just use Python’s own packaging system, pip, which is included by default with the Python binary installers (since Python 2.7.9).6 You can check to see if pip is installed by typing the following command:", "words": [{"w": "tem’s", "b": [0.1428, 0.0791, 0.1837, 0.1005]}, {"w": "packaging", "b": [0.1935, 0.0791, 0.2783, 0.1005]}, {"w": "system", "b": [0.2881, 0.0791, 0.3452, 0.1005]}, {"w": "(e.g.,", "b": [0.355, 0.0791, 0.395, 0.1005]}, {"w": "apt-get", "b": [0.4048, 0.0791, 0.4632, 0.1005]}, {"w": "on", "b": [0.473, 0.0791, 0.495, 0.1005]}, {"w": "Ubuntu,", "b": [0.5048, 0.0791, 0.5749, 0.1005]}, {"w": "or", "b": [0.5847, 0.0791, 0.603, 0.1005]}, {"w": "MacPorts", "b": [0.6128, 0.0791, 0.6924, 0.1005]}, {"w": "or", "b": [0.7021, 0.0791, 0.7205, 0.1005]}, {"w": "HomeBrew", "b": [0.7303, 0.0791, 0.8253, 0.1005]}, {"w": "on", "b": [0.8351, 0.0791, 0.8571, 0.1005]}, {"w": "MacOS),", "b": [0.1429, 0.0981, 0.2164, 0.1195]}, {"w": "install", "b": [0.2213, 0.0981, 0.272, 0.1195]}, {"w": "a", "b": [0.2768, 0.0981, 0.286, 0.1195]}, {"w": "Scientific", "b": [0.2908, 0.0981, 0.3675, 0.1195]}, {"w": "Python", "b": [0.3723, 0.0981, 0.4331, 0.1195]}, {"w": "distribution", "b": [0.438, 0.0981, 0.5375, 0.1195]}, {"w": "such", "b": [0.5424, 0.0981, 0.581, 0.1195]}, {"w": "as", "b": [0.5859, 0.0981, 0.6027, 0.1195]}, {"w": "Anaconda", "b": [0.6075, 0.0981, 0.6935, 0.1195]}, {"w": "and", "b": [0.6983, 0.0981, 0.7299, 0.1195]}, {"w": "use", "b": [0.7346, 0.0981, 0.7622, 0.1195]}, {"w": "its", "b": [0.7669, 0.0981, 0.7865, 0.1195]}, {"w": "packag‐", "b": [0.7912, 0.0981, 0.8567, 0.1195]}, {"w": "ing", "b": [0.1429, 0.1172, 0.1696, 0.1386]}, {"w": "system,", "b": [0.1779, 0.1172, 0.2398, 0.1386]}, {"w": "or", "b": [0.2481, 0.1172, 0.2664, 0.1386]}, {"w": "just", "b": [0.2748, 0.1172, 0.3052, 0.1386]}, {"w": "use", "b": [0.3135, 0.1172, 0.341, 0.1386]}, {"w": "Python’s", "b": [0.3494, 0.1172, 0.4188, 0.1386]}, {"w": "own", "b": [0.4271, 0.1172, 0.4634, 0.1386]}, {"w": "packaging", "b": [0.4717, 0.1172, 0.5565, 0.1386]}, {"w": "system,", "b": [0.5648, 0.1172, 0.6267, 0.1386]}, {"w": "pip,", "b": [0.635, 0.1172, 0.6666, 0.1386]}, {"w": "which", "b": [0.6749, 0.1172, 0.7258, 0.1386]}, {"w": "is", "b": [0.7341, 0.1172, 0.7474, 0.1386]}, {"w": "included", "b": [0.7557, 0.1172, 0.8287, 0.1386]}, {"w": "by", "b": [0.837, 0.1172, 0.8571, 0.1386]}, {"w": "default", "b": [0.1428, 0.1362, 0.2003, 0.1576]}, {"w": "with", "b": [0.2054, 0.1362, 0.2428, 0.1576]}, {"w": "the", "b": [0.2479, 0.1362, 0.2742, 0.1576]}, {"w": "Python", "b": [0.2793, 0.1362, 0.3401, 0.1576]}, {"w": "binary", "b": [0.3452, 0.1362, 0.3998, 0.1576]}, {"w": "installers", "b": [0.405, 0.1362, 0.4799, 0.1576]}, {"w": "(since", "b": [0.485, 0.1362, 0.5345, 0.1576]}, {"w": "Python", "b": [0.5396, 0.1362, 0.6004, 0.1576]}, {"w": "2.7.9).6", "b": [0.6055, 0.1362, 0.6627, 0.1576]}, {"w": "You", "b": [0.6678, 0.1362, 0.7002, 0.1576]}, {"w": "can", "b": [0.7053, 0.1362, 0.7347, 0.1576]}, {"w": "check", "b": [0.7398, 0.1362, 0.7877, 0.1576]}, {"w": "to", "b": [0.7928, 0.1362, 0.8098, 0.1576]}, {"w": "see", "b": [0.8149, 0.1362, 0.8403, 0.1576]}, {"w": "if", "b": [0.8454, 0.1362, 0.8572, 0.1576]}, {"w": "pip", "b": [0.1429, 0.1553, 0.1703, 0.1767]}, {"w": "is", "b": [0.175, 0.1553, 0.1882, 0.1767]}, {"w": "installed", "b": [0.193, 0.1553, 0.2635, 0.1767]}, {"w": "by", "b": [0.2682, 0.1553, 0.2884, 0.1767]}, {"w": "typing", "b": [0.2931, 0.1553, 0.3467, 0.1767]}, {"w": "the", "b": [0.3514, 0.1553, 0.3777, 0.1767]}, {"w": "following", "b": [0.3824, 0.1553, 0.4614, 0.1767]}, {"w": "command:", "b": [0.4661, 0.1553, 0.556, 0.1767]}]}, {"id": "b_4", "type": "paragraph", "text": "$ python3 -m pip --version pip 19.0.2 from [...]/lib/python3.6/site-packages (python 3.6)", "words": [{"w": "$", "b": [0.1766, 0.1872, 0.185, 0.2001]}, {"w": "python3", "b": [0.1935, 0.1872, 0.2525, 0.2001]}, {"w": "-m", "b": [0.2609, 0.1872, 0.2778, 0.2001]}, {"w": "pip", "b": [0.2862, 0.1872, 0.3115, 0.2001]}, {"w": "--version", "b": [0.3199, 0.1872, 0.3958, 0.2001]}, {"w": "pip", "b": [0.1766, 0.2026, 0.2019, 0.2155]}, {"w": "19.0.2", "b": [0.2103, 0.2026, 0.2609, 0.2155]}, {"w": "from", "b": [0.2693, 0.2026, 0.3031, 0.2155]}, {"w": "[...]/lib/python3.6/site-packages", "b": [0.3115, 0.2026, 0.5898, 0.2155]}, {"w": "(python", "b": [0.5982, 0.2026, 0.6572, 0.2155]}, {"w": "3.6)", "b": [0.6657, 0.2026, 0.6994, 0.2155]}]}, {"id": "b_5", "type": "paragraph", "text": "You should make sure you have a recent version of pip installed. To upgrade the pip module, type:7", "words": [{"w": "You", "b": [0.1429, 0.2233, 0.1752, 0.2447]}, {"w": "should", "b": [0.1812, 0.2233, 0.2379, 0.2447]}, {"w": "make", "b": [0.2439, 0.2233, 0.2893, 0.2447]}, {"w": "sure", "b": [0.2952, 0.2233, 0.3305, 0.2447]}, {"w": "you", "b": [0.3365, 0.2233, 0.3678, 0.2447]}, {"w": "have", "b": [0.3737, 0.2233, 0.4121, 0.2447]}, {"w": "a", "b": [0.4181, 0.2233, 0.4272, 0.2447]}, {"w": "recent", "b": [0.4332, 0.2233, 0.4848, 0.2447]}, {"w": "version", "b": [0.4908, 0.2233, 0.5523, 0.2447]}, {"w": "of", "b": [0.5582, 0.2233, 0.575, 0.2447]}, {"w": "pip", "b": [0.581, 0.2233, 0.6084, 0.2447]}, {"w": "installed.", "b": [0.6144, 0.2233, 0.6896, 0.2447]}, {"w": "To", "b": [0.6956, 0.2233, 0.717, 0.2447]}, {"w": "upgrade", "b": [0.723, 0.2233, 0.7915, 0.2447]}, {"w": "the", "b": [0.7974, 0.2233, 0.8238, 0.2447]}, {"w": "pip", "b": [0.8297, 0.2233, 0.8572, 0.2447]}, {"w": "module,", "b": [0.1429, 0.2423, 0.2115, 0.2637]}, {"w": "type:7", "b": [0.2162, 0.2423, 0.2624, 0.2637]}]}, {"id": "b_6", "type": "paragraph", "text": "$ python3 -m pip install --user -U pip Collecting pip [...] Successfully installed pip-19.0.2", "words": [{"w": "$", "b": [0.1766, 0.2743, 0.185, 0.2872]}, {"w": "python3", "b": [0.1935, 0.2743, 0.2525, 0.2872]}, {"w": "-m", "b": [0.2609, 0.2743, 0.2778, 0.2872]}, {"w": "pip", "b": [0.2862, 0.2743, 0.3115, 0.2872]}, {"w": "install", "b": [0.3199, 0.2743, 0.379, 0.2872]}, {"w": "--user", "b": [0.3874, 0.2743, 0.438, 0.2872]}, {"w": "-U", "b": [0.4464, 0.2743, 0.4633, 0.2872]}, {"w": "pip", "b": [0.4717, 0.2743, 0.497, 0.2872]}, {"w": "Collecting", "b": [0.1766, 0.2897, 0.2609, 0.3026]}, {"w": "pip", "b": [0.2693, 0.2897, 0.2946, 0.3026]}, {"w": "[...]", "b": [0.1766, 0.3051, 0.2188, 0.318]}, {"w": "Successfully", "b": [0.1766, 0.3206, 0.2778, 0.3334]}, {"w": "installed", "b": [0.2862, 0.3206, 0.3621, 0.3334]}, {"w": "pip-19.0.2", "b": [0.3705, 0.3206, 0.4549, 0.3334]}]}, {"id": "b_7", "type": "paragraph", "text": "Creating an Isolated Environment", "words": [{"w": "Creating", "b": [0.3359, 0.3602, 0.4191, 0.3874]}, {"w": "an", "b": [0.4239, 0.3602, 0.4486, 0.3874]}, {"w": "Isolated", "b": [0.4533, 0.3602, 0.5323, 0.3874]}, {"w": "Environment", "b": [0.537, 0.3602, 0.6641, 0.3874]}]}, {"id": "b_8", "type": "paragraph", "text": "If you would like to work in an isolated environment (which is strongly recom‐ mended so you can work on different projects without having conflicting library ver‐ sions), install virtualenv8 by running the following pip command (again, if you want virtualenv to be installed for all users on your machine, remove --user and run this command with administrator rights):", "words": [{"w": "If", "b": [0.1592, 0.392, 0.1719, 0.4124]}, {"w": "you", "b": [0.1806, 0.392, 0.2104, 0.4124]}, {"w": "would", "b": [0.2191, 0.392, 0.2688, 0.4124]}, {"w": "like", "b": [0.2775, 0.392, 0.3062, 0.4124]}, {"w": "to", "b": [0.3149, 0.392, 0.331, 0.4124]}, {"w": "work", "b": [0.3398, 0.392, 0.3807, 0.4124]}, {"w": "in", "b": [0.3894, 0.392, 0.4056, 0.4124]}, {"w": "an", "b": [0.4143, 0.392, 0.4339, 0.4124]}, {"w": "isolated", "b": [0.4426, 0.392, 0.5036, 0.4124]}, {"w": "environment", "b": [0.5123, 0.392, 0.6152, 0.4124]}, {"w": "(which", "b": [0.6239, 0.392, 0.6793, 0.4124]}, {"w": "is", "b": [0.688, 0.392, 0.7006, 0.4124]}, {"w": "strongly", "b": [0.7094, 0.392, 0.7744, 0.4124]}, {"w": "recom‐", "b": [0.7832, 0.392, 0.8408, 0.4124]}, {"w": "mended", "b": [0.1592, 0.4101, 0.2241, 0.4305]}, {"w": "so", "b": [0.2293, 0.4101, 0.2467, 0.4305]}, {"w": "you", "b": [0.2518, 0.4101, 0.2815, 0.4305]}, {"w": "can", "b": [0.2866, 0.4101, 0.3146, 0.4305]}, {"w": "work", "b": [0.3197, 0.4101, 0.3606, 0.4305]}, {"w": "on", "b": [0.3657, 0.4101, 0.3867, 0.4305]}, {"w": "different", "b": [0.3918, 0.4101, 0.4601, 0.4305]}, {"w": "projects", "b": [0.4652, 0.4101, 0.5283, 0.4305]}, {"w": "without", "b": [0.5334, 0.4101, 0.5957, 0.4305]}, {"w": "having", "b": [0.6008, 0.4101, 0.6544, 0.4305]}, {"w": "conflicting", "b": [0.6595, 0.4101, 0.745, 0.4305]}, {"w": "library", "b": [0.7501, 0.4101, 0.8036, 0.4305]}, {"w": "ver‐", "b": [0.8087, 0.4101, 0.8408, 0.4305]}, {"w": "sions),", "b": [0.1592, 0.4282, 0.2115, 0.4486]}, {"w": "install", "b": [0.2173, 0.4282, 0.2655, 0.4486]}, {"w": "virtualenv8", "b": [0.2713, 0.4282, 0.3572, 0.4486]}, {"w": "by", "b": [0.363, 0.4282, 0.3822, 0.4486]}, {"w": "running", "b": [0.388, 0.4282, 0.453, 0.4486]}, {"w": "the", "b": [0.4588, 0.4282, 0.4839, 0.4486]}, {"w": "following", "b": [0.4897, 0.4282, 0.5649, 0.4486]}, {"w": "pip", "b": [0.5706, 0.4282, 0.5968, 0.4486]}, {"w": "command", "b": [0.6025, 0.4282, 0.6836, 0.4486]}, {"w": "(again,", "b": [0.6894, 0.4282, 0.7436, 0.4486]}, {"w": "if", "b": [0.7494, 0.4282, 0.7606, 0.4486]}, {"w": "you", "b": [0.7664, 0.4282, 0.7962, 0.4486]}, {"w": "want", "b": [0.8019, 0.4282, 0.8408, 0.4486]}, {"w": "virtualenv", "b": [0.1592, 0.4472, 0.2394, 0.4676]}, {"w": "to", "b": [0.2452, 0.4472, 0.2614, 0.4676]}, {"w": "be", "b": [0.2672, 0.4472, 0.2857, 0.4676]}, {"w": "installed", "b": [0.2915, 0.4472, 0.3586, 0.4676]}, {"w": "for", "b": [0.3644, 0.4472, 0.3878, 0.4676]}, {"w": "all", "b": [0.3935, 0.4472, 0.4123, 0.4676]}, {"w": "users", "b": [0.4181, 0.4472, 0.459, 0.4676]}, {"w": "on", "b": [0.4648, 0.4472, 0.4857, 0.4676]}, {"w": "your", "b": [0.4915, 0.4472, 0.5286, 0.4676]}, {"w": "machine,", "b": [0.5344, 0.4472, 0.6075, 0.4676]}, {"w": "remove", "b": [0.6133, 0.4472, 0.6731, 0.4676]}, {"w": "--user", "b": [0.6788, 0.4503, 0.7354, 0.4646]}, {"w": "and", "b": [0.7412, 0.4472, 0.7712, 0.4676]}, {"w": "run", "b": [0.777, 0.4472, 0.8057, 0.4676]}, {"w": "this", "b": [0.8115, 0.4472, 0.8408, 0.4676]}, {"w": "command", "b": [0.1592, 0.4654, 0.2403, 0.4858]}, {"w": "with", "b": [0.2448, 0.4654, 0.2803, 0.4858]}, {"w": "administrator", "b": [0.2848, 0.4654, 0.3943, 0.4858]}, {"w": "rights):", "b": [0.3988, 0.4654, 0.4557, 0.4858]}]}, {"id": "b_9", "type": "paragraph", "text": "$ python3 -m pip install --user -U virtualenv Collecting virtualenv [...] Successfully installed virtualenv", "words": [{"w": "$", "b": [0.193, 0.4963, 0.2014, 0.5092]}, {"w": "python3", "b": [0.2098, 0.4963, 0.2689, 0.5092]}, {"w": "-m", "b": [0.2773, 0.4963, 0.2942, 0.5092]}, {"w": "pip", "b": [0.3026, 0.4963, 0.3279, 0.5092]}, {"w": "install", "b": [0.3363, 0.4963, 0.3953, 0.5092]}, {"w": "--user", "b": [0.4038, 0.4963, 0.4544, 0.5092]}, {"w": "-U", "b": [0.4628, 0.4963, 0.4797, 0.5092]}, {"w": "virtualenv", "b": [0.4881, 0.4963, 0.5724, 0.5092]}, {"w": "Collecting", "b": [0.193, 0.5117, 0.2773, 0.5246]}, {"w": "virtualenv", "b": [0.2857, 0.5117, 0.37, 0.5246]}, {"w": "[...]", "b": [0.193, 0.5272, 0.2351, 0.54]}, {"w": "Successfully", "b": [0.193, 0.5426, 0.2942, 0.5554]}, {"w": "installed", "b": [0.3026, 0.5426, 0.3785, 0.5554]}, {"w": "virtualenv", "b": [0.3869, 0.5426, 0.4712, 0.5554]}]}, {"id": "b_10", "type": "paragraph", "text": "Now you can create an isolated Python environment by typing:", "words": [{"w": "Now", "b": [0.1592, 0.5633, 0.1972, 0.5837]}, {"w": "you", "b": [0.2017, 0.5633, 0.2315, 0.5837]}, {"w": "can", "b": [0.236, 0.5633, 0.2639, 0.5837]}, {"w": "create", "b": [0.2684, 0.5633, 0.3154, 0.5837]}, {"w": "an", "b": [0.3199, 0.5633, 0.3395, 0.5837]}, {"w": "isolated", "b": [0.344, 0.5633, 0.405, 0.5837]}, {"w": "Python", "b": [0.4095, 0.5633, 0.4674, 0.5837]}, {"w": "environment", "b": [0.4719, 0.5633, 0.5748, 0.5837]}, {"w": "by", "b": [0.5793, 0.5633, 0.5985, 0.5837]}, {"w": "typing:", "b": [0.603, 0.5633, 0.6585, 0.5837]}]}, {"id": "b_11", "type": "paragraph", "text": "$ cd $ML_PATH $ virtualenv env Using base prefix '[...]' New python executable in [...]/ml/env/bin/python3.6 Also creating executable in [...]/ml/env/bin/python Installing setuptools, pip, wheel...done.", "words": [{"w": "$", "b": [0.193, 0.5943, 0.2014, 0.6071]}, {"w": "cd", "b": [0.2098, 0.5943, 0.2267, 0.6071]}, {"w": "$ML_PATH", "b": [0.2351, 0.5943, 0.3026, 0.6071]}, {"w": "$", "b": [0.193, 0.6097, 0.2014, 0.6225]}, {"w": "virtualenv", "b": [0.2098, 0.6097, 0.2941, 0.6225]}, {"w": "env", "b": [0.3026, 0.6097, 0.3279, 0.6225]}, {"w": "Using", "b": [0.193, 0.6251, 0.2351, 0.638]}, {"w": "base", "b": [0.2436, 0.6251, 0.2773, 0.638]}, {"w": "prefix", "b": [0.2857, 0.6251, 0.3363, 0.638]}, {"w": "'[...]'", "b": [0.3447, 0.6251, 0.4038, 0.638]}, {"w": "New", "b": [0.193, 0.6405, 0.2183, 0.6534]}, {"w": "python", "b": [0.2267, 0.6405, 0.2773, 0.6534]}, {"w": "executable", "b": [0.2857, 0.6405, 0.37, 0.6534]}, {"w": "in", "b": [0.3785, 0.6405, 0.3953, 0.6534]}, {"w": "[...]/ml/env/bin/python3.6", "b": [0.4038, 0.6405, 0.623, 0.6534]}, {"w": "Also", "b": [0.193, 0.656, 0.2267, 0.6688]}, {"w": "creating", "b": [0.2351, 0.656, 0.3026, 0.6688]}, {"w": "executable", "b": [0.311, 0.656, 0.3953, 0.6688]}, {"w": "in", "b": [0.4038, 0.656, 0.4206, 0.6688]}, {"w": "[...]/ml/env/bin/python", "b": [0.4291, 0.656, 0.623, 0.6688]}, {"w": "Installing", "b": [0.193, 0.6714, 0.2773, 0.6842]}, {"w": "setuptools,", "b": [0.2857, 0.6714, 0.3785, 0.6842]}, {"w": "pip,", "b": [0.3869, 0.6714, 0.4206, 0.6842]}, {"w": "wheel...done.", "b": [0.4291, 0.6714, 0.5387, 0.6842]}]}, {"id": "b_12", "type": "equation", "text": "46 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "46", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.478, 0.9388]}]}]}, {"page": 73, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "9 Note that Jupyter can handle multiple versions of Python, and even many other languages such as R or Octave.", "words": [{"w": "9", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Note", "b": [0.1587, 0.8598, 0.1898, 0.8761]}, {"w": "that", "b": [0.1934, 0.8598, 0.2182, 0.8761]}, {"w": "Jupyter", "b": [0.2218, 0.8598, 0.2681, 0.8761]}, {"w": "can", "b": [0.2717, 0.8598, 0.294, 0.8761]}, {"w": "handle", "b": [0.2976, 0.8598, 0.3409, 0.8761]}, {"w": "multiple", "b": [0.3445, 0.8598, 0.3978, 0.8761]}, {"w": "versions", "b": [0.4014, 0.8598, 0.4541, 0.8761]}, {"w": "of", "b": [0.4577, 0.8598, 0.4705, 0.8761]}, {"w": "Python,", "b": [0.4741, 0.8598, 0.524, 0.8761]}, {"w": "and", "b": [0.5276, 0.8598, 0.5517, 0.8761]}, {"w": "even", "b": [0.5553, 0.8598, 0.5848, 0.8761]}, {"w": "many", "b": [0.5884, 0.8598, 0.624, 0.8761]}, {"w": "other", "b": [0.6276, 0.8598, 0.6616, 0.8761]}, {"w": "languages", "b": [0.6652, 0.8598, 0.7277, 0.8761]}, {"w": "such", "b": [0.7313, 0.8598, 0.7608, 0.8761]}, {"w": "as", "b": [0.7644, 0.8598, 0.7772, 0.8761]}, {"w": "R", "b": [0.7808, 0.8598, 0.7906, 0.8761]}, {"w": "or", "b": [0.7942, 0.8598, 0.8082, 0.8761]}, {"w": "Octave.", "b": [0.1587, 0.8749, 0.2065, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Now every time you want to activate this environment, just open a terminal and type:", "words": [{"w": "Now", "b": [0.1592, 0.0792, 0.1972, 0.0996]}, {"w": "every", "b": [0.2017, 0.0792, 0.2448, 0.0996]}, {"w": "time", "b": [0.2493, 0.0792, 0.2853, 0.0996]}, {"w": "you", "b": [0.2898, 0.0792, 0.3196, 0.0996]}, {"w": "want", "b": [0.3241, 0.0792, 0.3629, 0.0996]}, {"w": "to", "b": [0.3674, 0.0792, 0.3836, 0.0996]}, {"w": "activate", "b": [0.3881, 0.0792, 0.4486, 0.0996]}, {"w": "this", "b": [0.4531, 0.0792, 0.4823, 0.0996]}, {"w": "environment,", "b": [0.4868, 0.0792, 0.5942, 0.0996]}, {"w": "just", "b": [0.5987, 0.0792, 0.6277, 0.0996]}, {"w": "open", "b": [0.6322, 0.0792, 0.672, 0.0996]}, {"w": "a", "b": [0.6765, 0.0792, 0.6852, 0.0996]}, {"w": "terminal", "b": [0.6897, 0.0792, 0.7577, 0.0996]}, {"w": "and", "b": [0.7622, 0.0792, 0.7923, 0.0996]}, {"w": "type:", "b": [0.7968, 0.0792, 0.8353, 0.0996]}]}, {"id": "b_2", "type": "paragraph", "text": "$ cd $ML_PATH $ source env/bin/activate # on Linux or MacOSX $ .\\env\\Scripts\\activate # on Windows", "words": [{"w": "$", "b": [0.193, 0.1101, 0.2014, 0.123]}, {"w": "cd", "b": [0.2098, 0.1101, 0.2267, 0.123]}, {"w": "$ML_PATH", "b": [0.2351, 0.1101, 0.3026, 0.123]}, {"w": "$", "b": [0.193, 0.1255, 0.2014, 0.1384]}, {"w": "source", "b": [0.2098, 0.1255, 0.2604, 0.1384]}, {"w": "env/bin/activate", "b": [0.2689, 0.1255, 0.4038, 0.1384]}, {"w": "#", "b": [0.4122, 0.1255, 0.4206, 0.1384]}, {"w": "on", "b": [0.4291, 0.1255, 0.4459, 0.1384]}, {"w": "Linux", "b": [0.4544, 0.1255, 0.4965, 0.1384]}, {"w": "or", "b": [0.505, 0.1255, 0.5218, 0.1384]}, {"w": "MacOSX", "b": [0.5303, 0.1255, 0.5809, 0.1384]}, {"w": "$", "b": [0.193, 0.141, 0.2014, 0.1538]}, {"w": ".\\env\\Scripts\\activate", "b": [0.2098, 0.141, 0.3953, 0.1538]}, {"w": "#", "b": [0.4122, 0.141, 0.4206, 0.1538]}, {"w": "on", "b": [0.4291, 0.141, 0.4459, 0.1538]}, {"w": "Windows", "b": [0.4544, 0.141, 0.5134, 0.1538]}]}, {"id": "b_3", "type": "paragraph", "text": "To deactivate this environment, just type deactivate. While the environment is active, any package you install using pip will be installed in this isolated environment, and Python will only have access to these packages (if you also want access to the sys‐ tem’s packages, you should create the environment using virtualenv’s --system-site- packages option). Check out virtualenv’s documentation for more information.", "words": [{"w": "To", "b": [0.1592, 0.1626, 0.1796, 0.183]}, {"w": "deactivate", "b": [0.1891, 0.1626, 0.2685, 0.183]}, {"w": "this", "b": [0.2779, 0.1626, 0.3071, 0.183]}, {"w": "environment,", "b": [0.3165, 0.1626, 0.4239, 0.183]}, {"w": "just", "b": [0.4334, 0.1626, 0.4623, 0.183]}, {"w": "type", "b": [0.4717, 0.1626, 0.5057, 0.183]}, {"w": "deactivate.", "b": [0.5151, 0.1626, 0.6139, 0.183]}, {"w": "While", "b": [0.6233, 0.1626, 0.672, 0.183]}, {"w": "the", "b": [0.6814, 0.1626, 0.7065, 0.183]}, {"w": "environment", "b": [0.7159, 0.1626, 0.8188, 0.183]}, {"w": "is", "b": [0.8282, 0.1626, 0.8408, 0.183]}, {"w": "active,", "b": [0.1592, 0.1807, 0.2098, 0.2011]}, {"w": "any", "b": [0.2147, 0.1807, 0.2429, 0.2011]}, {"w": "package", "b": [0.2478, 0.1807, 0.3115, 0.2011]}, {"w": "you", "b": [0.3164, 0.1807, 0.3462, 0.2011]}, {"w": "install", "b": [0.351, 0.1807, 0.3993, 0.2011]}, {"w": "using", "b": [0.4041, 0.1807, 0.4474, 0.2011]}, {"w": "pip", "b": [0.4522, 0.1807, 0.4783, 0.2011]}, {"w": "will", "b": [0.4832, 0.1807, 0.5121, 0.2011]}, {"w": "be", "b": [0.517, 0.1807, 0.5355, 0.2011]}, {"w": "installed", "b": [0.5404, 0.1807, 0.6075, 0.2011]}, {"w": "in", "b": [0.6124, 0.1807, 0.6285, 0.2011]}, {"w": "this", "b": [0.6334, 0.1807, 0.6626, 0.2011]}, {"w": "isolated", "b": [0.6675, 0.1807, 0.7285, 0.2011]}, {"w": "environment,", "b": [0.7334, 0.1807, 0.8408, 0.2011]}, {"w": "and", "b": [0.1592, 0.1989, 0.1893, 0.2193]}, {"w": "Python", "b": [0.1942, 0.1989, 0.2521, 0.2193]}, {"w": "will", "b": [0.2569, 0.1989, 0.2859, 0.2193]}, {"w": "only", "b": [0.2908, 0.1989, 0.3259, 0.2193]}, {"w": "have", "b": [0.3308, 0.1989, 0.3673, 0.2193]}, {"w": "access", "b": [0.3722, 0.1989, 0.4207, 0.2193]}, {"w": "to", "b": [0.4256, 0.1989, 0.4418, 0.2193]}, {"w": "these", "b": [0.4467, 0.1989, 0.4875, 0.2193]}, {"w": "packages", "b": [0.4924, 0.1989, 0.5634, 0.2193]}, {"w": "(if", "b": [0.5683, 0.1989, 0.5864, 0.2193]}, {"w": "you", "b": [0.5912, 0.1989, 0.621, 0.2193]}, {"w": "also", "b": [0.6259, 0.1989, 0.657, 0.2193]}, {"w": "want", "b": [0.6619, 0.1989, 0.7007, 0.2193]}, {"w": "access", "b": [0.7056, 0.1989, 0.7541, 0.2193]}, {"w": "to", "b": [0.759, 0.1989, 0.7752, 0.2193]}, {"w": "the", "b": [0.7801, 0.1989, 0.8052, 0.2193]}, {"w": "sys‐", "b": [0.81, 0.1989, 0.8408, 0.2193]}, {"w": "tem’s", "b": [0.1592, 0.2179, 0.1982, 0.2382]}, {"w": "packages,", "b": [0.2029, 0.2179, 0.2785, 0.2382]}, {"w": "you", "b": [0.2833, 0.2179, 0.3131, 0.2382]}, {"w": "should", "b": [0.3179, 0.2179, 0.3719, 0.2382]}, {"w": "create", "b": [0.3767, 0.2179, 0.4237, 0.2382]}, {"w": "the", "b": [0.4285, 0.2179, 0.4535, 0.2382]}, {"w": "environment", "b": [0.4583, 0.2179, 0.5612, 0.2382]}, {"w": "using", "b": [0.566, 0.2179, 0.6092, 0.2382]}, {"w": "virtualenv’s", "b": [0.614, 0.2179, 0.7041, 0.2382]}, {"w": "--system-site-", "b": [0.7088, 0.2209, 0.8408, 0.2352]}, {"w": "packages", "b": [0.1592, 0.2399, 0.2346, 0.2542]}, {"w": "option).", "b": [0.2391, 0.2368, 0.3034, 0.2572]}, {"w": "Check", "b": [0.3079, 0.2368, 0.3583, 0.2572]}, {"w": "out", "b": [0.3628, 0.2368, 0.3895, 0.2572]}, {"w": "virtualenv’s", "b": [0.3941, 0.2368, 0.4841, 0.2572]}, {"w": "documentation", "b": [0.4886, 0.2368, 0.61, 0.2572]}, {"w": "for", "b": [0.6145, 0.2368, 0.6378, 0.2572]}, {"w": "more", "b": [0.6423, 0.2368, 0.6845, 0.2572]}, {"w": "information.", "b": [0.689, 0.2368, 0.79, 0.2572]}]}, {"id": "b_4", "type": "paragraph", "text": "Now you can install all the required modules and their dependencies using this sim‐ ple pip command (if you are not using a virtualenv, you will need the --user option or administrator rights):", "words": [{"w": "Now", "b": [0.1429, 0.287, 0.1827, 0.3084]}, {"w": "you", "b": [0.1886, 0.287, 0.2198, 0.3084]}, {"w": "can", "b": [0.2256, 0.287, 0.255, 0.3084]}, {"w": "install", "b": [0.2608, 0.287, 0.3115, 0.3084]}, {"w": "all", "b": [0.3174, 0.287, 0.337, 0.3084]}, {"w": "the", "b": [0.3429, 0.287, 0.3692, 0.3084]}, {"w": "required", "b": [0.3751, 0.287, 0.4465, 0.3084]}, {"w": "modules", "b": [0.4524, 0.287, 0.5239, 0.3084]}, {"w": "and", "b": [0.5297, 0.287, 0.5613, 0.3084]}, {"w": "their", "b": [0.5671, 0.287, 0.6068, 0.3084]}, {"w": "dependencies", "b": [0.6126, 0.287, 0.7258, 0.3084]}, {"w": "using", "b": [0.7316, 0.287, 0.777, 0.3084]}, {"w": "this", "b": [0.7829, 0.287, 0.8136, 0.3084]}, {"w": "sim‐", "b": [0.8194, 0.287, 0.8571, 0.3084]}, {"w": "ple", "b": [0.1429, 0.3069, 0.1679, 0.3283]}, {"w": "pip", "b": [0.1737, 0.3069, 0.2011, 0.3283]}, {"w": "command", "b": [0.207, 0.3069, 0.2921, 0.3283]}, {"w": "(if", "b": [0.2979, 0.3069, 0.3169, 0.3283]}, {"w": "you", "b": [0.3227, 0.3069, 0.3539, 0.3283]}, {"w": "are", "b": [0.3598, 0.3069, 0.3855, 0.3283]}, {"w": "not", "b": [0.3913, 0.3069, 0.4197, 0.3283]}, {"w": "using", "b": [0.4255, 0.3069, 0.471, 0.3283]}, {"w": "a", "b": [0.4768, 0.3069, 0.4859, 0.3283]}, {"w": "virtualenv,", "b": [0.4918, 0.3069, 0.5792, 0.3283]}, {"w": "you", "b": [0.585, 0.3069, 0.6163, 0.3283]}, {"w": "will", "b": [0.6221, 0.3069, 0.6525, 0.3283]}, {"w": "need", "b": [0.6583, 0.3069, 0.6984, 0.3283]}, {"w": "the", "b": [0.7043, 0.3069, 0.7306, 0.3283]}, {"w": "--user", "b": [0.7364, 0.3101, 0.7958, 0.3252]}, {"w": "option", "b": [0.8016, 0.3069, 0.8571, 0.3283]}, {"w": "or", "b": [0.1428, 0.326, 0.1612, 0.3474]}, {"w": "administrator", "b": [0.1659, 0.326, 0.2809, 0.3474]}, {"w": "rights):", "b": [0.2856, 0.326, 0.3454, 0.3474]}]}, {"id": "b_5", "type": "paragraph", "text": "$ python3 -m pip install -U jupyter matplotlib numpy pandas scipy scikit-learn Collecting jupyter Downloading jupyter-1.0.0-py2.py3-none-any.whl Collecting matplotlib [...]", "words": [{"w": "$", "b": [0.1766, 0.358, 0.185, 0.3708]}, {"w": "python3", "b": [0.1934, 0.358, 0.2525, 0.3708]}, {"w": "-m", "b": [0.2609, 0.358, 0.2778, 0.3708]}, {"w": "pip", "b": [0.2862, 0.358, 0.3115, 0.3708]}, {"w": "install", "b": [0.3199, 0.358, 0.379, 0.3708]}, {"w": "-U", "b": [0.3874, 0.358, 0.4043, 0.3708]}, {"w": "jupyter", "b": [0.4127, 0.358, 0.4717, 0.3708]}, {"w": "matplotlib", "b": [0.4802, 0.358, 0.5645, 0.3708]}, {"w": "numpy", "b": [0.5729, 0.358, 0.6151, 0.3708]}, {"w": "pandas", "b": [0.6235, 0.358, 0.6741, 0.3708]}, {"w": "scipy", "b": [0.6825, 0.358, 0.7247, 0.3708]}, {"w": "scikit-learn", "b": [0.7331, 0.358, 0.8343, 0.3708]}, {"w": "Collecting", "b": [0.1766, 0.3734, 0.2609, 0.3862]}, {"w": "jupyter", "b": [0.2693, 0.3734, 0.3284, 0.3862]}, {"w": "Downloading", "b": [0.1934, 0.3888, 0.2862, 0.4016]}, {"w": "jupyter-1.0.0-py2.py3-none-any.whl", "b": [0.2946, 0.3888, 0.5813, 0.4016]}, {"w": "Collecting", "b": [0.1766, 0.4042, 0.2609, 0.4171]}, {"w": "matplotlib", "b": [0.2693, 0.4042, 0.3537, 0.4171]}, {"w": "[...]", "b": [0.1934, 0.4196, 0.2356, 0.4325]}]}, {"id": "b_6", "type": "paragraph", "text": "To check your installation, try to import every module like this:", "words": [{"w": "To", "b": [0.1429, 0.4403, 0.1643, 0.4617]}, {"w": "check", "b": [0.169, 0.4403, 0.217, 0.4617]}, {"w": "your", "b": [0.2217, 0.4403, 0.2607, 0.4617]}, {"w": "installation,", "b": [0.2654, 0.4403, 0.3635, 0.4617]}, {"w": "try", "b": [0.3683, 0.4403, 0.3925, 0.4617]}, {"w": "to", "b": [0.3972, 0.4403, 0.4142, 0.4617]}, {"w": "import", "b": [0.4189, 0.4403, 0.4768, 0.4617]}, {"w": "every", "b": [0.4815, 0.4403, 0.5268, 0.4617]}, {"w": "module", "b": [0.5315, 0.4403, 0.5954, 0.4617]}, {"w": "like", "b": [0.6001, 0.4403, 0.6302, 0.4617]}, {"w": "this:", "b": [0.6349, 0.4403, 0.6704, 0.4617]}]}, {"id": "b_7", "type": "equation", "text": "$ python3 -c \"import jupyter, matplotlib, numpy, pandas, scipy, sklearn\"", "words": [{"w": "$", "b": [0.1766, 0.4722, 0.185, 0.4851]}, {"w": "python3", "b": [0.1934, 0.4722, 0.2525, 0.4851]}, {"w": "-c", "b": [0.2609, 0.4722, 0.2778, 0.4851]}, {"w": "\"import", "b": [0.2862, 0.4722, 0.3452, 0.4851]}, {"w": "jupyter,", "b": [0.3537, 0.4722, 0.4211, 0.4851]}, {"w": "matplotlib,", "b": [0.4296, 0.4722, 0.5223, 0.4851]}, {"w": "numpy,", "b": [0.5308, 0.4722, 0.5813, 0.4851]}, {"w": "pandas,", "b": [0.5898, 0.4722, 0.6488, 0.4851]}, {"w": "scipy,", "b": [0.6572, 0.4722, 0.7078, 0.4851]}, {"w": "sklearn\"", "b": [0.7163, 0.4722, 0.7837, 0.4851]}]}, {"id": "b_8", "type": "paragraph", "text": "There should be no output and no error. Now you can fire up Jupyter by typing:", "words": [{"w": "There", "b": [0.1429, 0.4929, 0.1923, 0.5143]}, {"w": "should", "b": [0.197, 0.4929, 0.2537, 0.5143]}, {"w": "be", "b": [0.2585, 0.4929, 0.2779, 0.5143]}, {"w": "no", "b": [0.2826, 0.4929, 0.3046, 0.5143]}, {"w": "output", "b": [0.3094, 0.4929, 0.3657, 0.5143]}, {"w": "and", "b": [0.3705, 0.4929, 0.402, 0.5143]}, {"w": "no", "b": [0.4067, 0.4929, 0.4288, 0.5143]}, {"w": "error.", "b": [0.4335, 0.4929, 0.4796, 0.5143]}, {"w": "Now", "b": [0.4843, 0.4929, 0.5242, 0.5143]}, {"w": "you", "b": [0.5289, 0.4929, 0.5602, 0.5143]}, {"w": "can", "b": [0.5649, 0.4929, 0.5942, 0.5143]}, {"w": "fire", "b": [0.599, 0.4929, 0.6273, 0.5143]}, {"w": "up", "b": [0.632, 0.4929, 0.654, 0.5143]}, {"w": "Jupyter", "b": [0.6587, 0.4929, 0.7194, 0.5143]}, {"w": "by", "b": [0.7241, 0.4929, 0.7443, 0.5143]}, {"w": "typing:", "b": [0.749, 0.4929, 0.8073, 0.5143]}]}, {"id": "b_9", "type": "paragraph", "text": "$ jupyter notebook [I 15:24 NotebookApp] Serving notebooks from local directory: [...]/ml [I 15:24 NotebookApp] 0 active kernels [I 15:24 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/ [I 15:24 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).", "words": [{"w": "$", "b": [0.1766, 0.5249, 0.185, 0.5377]}, {"w": "jupyter", "b": [0.1935, 0.5249, 0.2525, 0.5377]}, {"w": "notebook", "b": [0.2609, 0.5249, 0.3284, 0.5377]}, {"w": "[I", "b": [0.1766, 0.5403, 0.1935, 0.5531]}, {"w": "15:24", "b": [0.2019, 0.5403, 0.2441, 0.5531]}, {"w": "NotebookApp]", "b": [0.2525, 0.5403, 0.3537, 0.5531]}, {"w": "Serving", "b": [0.3621, 0.5403, 0.4211, 0.5531]}, {"w": "notebooks", "b": [0.4296, 0.5403, 0.5055, 0.5531]}, {"w": "from", "b": [0.5139, 0.5403, 0.5476, 0.5531]}, {"w": "local", "b": [0.5561, 0.5403, 0.5982, 0.5531]}, {"w": "directory:", "b": [0.6067, 0.5403, 0.691, 0.5531]}, {"w": "[...]/ml", "b": [0.6994, 0.5403, 0.7669, 0.5531]}, {"w": "[I", "b": [0.1766, 0.5557, 0.1935, 0.5685]}, {"w": "15:24", "b": [0.2019, 0.5557, 0.2441, 0.5685]}, {"w": "NotebookApp]", "b": [0.2525, 0.5557, 0.3537, 0.5685]}, {"w": "0", "b": [0.3621, 0.5557, 0.3705, 0.5685]}, {"w": "active", "b": [0.379, 0.5557, 0.4296, 0.5685]}, {"w": "kernels", "b": [0.438, 0.5557, 0.497, 0.5685]}, {"w": "[I", "b": [0.1766, 0.5711, 0.1935, 0.584]}, {"w": "15:24", "b": [0.2019, 0.5711, 0.2441, 0.584]}, {"w": "NotebookApp]", "b": [0.2525, 0.5711, 0.3537, 0.584]}, {"w": "The", "b": [0.3621, 0.5711, 0.3874, 0.584]}, {"w": "Jupyter", "b": [0.3958, 0.5711, 0.4549, 0.584]}, {"w": "Notebook", "b": [0.4633, 0.5711, 0.5308, 0.584]}, {"w": "is", "b": [0.5392, 0.5711, 0.5561, 0.584]}, {"w": "running", "b": [0.5645, 0.5711, 0.6235, 0.584]}, {"w": "at:", "b": [0.632, 0.5711, 0.6572, 0.584]}, {"w": "http://localhost:8888/", "b": [0.6657, 0.5711, 0.8512, 0.584]}, {"w": "[I", "b": [0.1766, 0.5865, 0.1935, 0.5994]}, {"w": "15:24", "b": [0.2019, 0.5865, 0.2441, 0.5994]}, {"w": "NotebookApp]", "b": [0.2525, 0.5865, 0.3537, 0.5994]}, {"w": "Use", "b": [0.3621, 0.5865, 0.3874, 0.5994]}, {"w": "Control-C", "b": [0.3958, 0.5865, 0.4717, 0.5994]}, {"w": "to", "b": [0.4802, 0.5865, 0.497, 0.5994]}, {"w": "stop", "b": [0.5055, 0.5865, 0.5392, 0.5994]}, {"w": "this", "b": [0.5476, 0.5865, 0.5814, 0.5994]}, {"w": "server", "b": [0.5898, 0.5865, 0.6404, 0.5994]}, {"w": "and", "b": [0.6488, 0.5865, 0.6741, 0.5994]}, {"w": "shut", "b": [0.6825, 0.5865, 0.7163, 0.5994]}, {"w": "down", "b": [0.7247, 0.5865, 0.7584, 0.5994]}, {"w": "all", "b": [0.7669, 0.5865, 0.7922, 0.5994]}, {"w": "kernels", "b": [0.1766, 0.6019, 0.2356, 0.6148]}, {"w": "(twice", "b": [0.2441, 0.6019, 0.2947, 0.6148]}, {"w": "to", "b": [0.3031, 0.6019, 0.3199, 0.6148]}, {"w": "skip", "b": [0.3284, 0.6019, 0.3621, 0.6148]}, {"w": "confirmation).", "b": [0.3705, 0.6019, 0.4886, 0.6148]}]}, {"id": "b_10", "type": "paragraph", "text": "A Jupyter server is now running in your terminal, listening to port 8888. You can visit this server by opening your web browser to http://localhost:8888/ (this usually hap‐ pens automatically when the server starts). You should see your empty workspace directory (containing only the env directory if you followed the preceding virtualenv instructions).", "words": [{"w": "A", "b": [0.1428, 0.6226, 0.1572, 0.644]}, {"w": "Jupyter", "b": [0.1621, 0.6226, 0.2227, 0.644]}, {"w": "server", "b": [0.2276, 0.6226, 0.2786, 0.644]}, {"w": "is", "b": [0.2835, 0.6226, 0.2967, 0.644]}, {"w": "now", "b": [0.3015, 0.6226, 0.3378, 0.644]}, {"w": "running", "b": [0.3427, 0.6226, 0.411, 0.644]}, {"w": "in", "b": [0.4158, 0.6226, 0.4328, 0.644]}, {"w": "your", "b": [0.4376, 0.6226, 0.4766, 0.644]}, {"w": "terminal,", "b": [0.4814, 0.6226, 0.5576, 0.644]}, {"w": "listening", "b": [0.5624, 0.6226, 0.6343, 0.644]}, {"w": "to", "b": [0.6391, 0.6226, 0.6561, 0.644]}, {"w": "port", "b": [0.6609, 0.6226, 0.6965, 0.644]}, {"w": "8888.", "b": [0.7014, 0.6226, 0.7461, 0.644]}, {"w": "You", "b": [0.7509, 0.6226, 0.7833, 0.644]}, {"w": "can", "b": [0.7881, 0.6226, 0.8175, 0.644]}, {"w": "visit", "b": [0.8223, 0.6226, 0.8571, 0.644]}, {"w": "this", "b": [0.1429, 0.6416, 0.1736, 0.663]}, {"w": "server", "b": [0.1806, 0.6416, 0.2317, 0.663]}, {"w": "by", "b": [0.2388, 0.6416, 0.2589, 0.663]}, {"w": "opening", "b": [0.266, 0.6416, 0.3345, 0.663]}, {"w": "your", "b": [0.3416, 0.6416, 0.3806, 0.663]}, {"w": "web", "b": [0.3876, 0.6416, 0.4213, 0.663]}, {"w": "browser", "b": [0.4284, 0.6416, 0.4958, 0.663]}, {"w": "to", "b": [0.5029, 0.6416, 0.5199, 0.663]}, {"w": "http://localhost:8888/", "b": [0.527, 0.6414, 0.7008, 0.663]}, {"w": "(this", "b": [0.7079, 0.6416, 0.7458, 0.663]}, {"w": "usually", "b": [0.7528, 0.6416, 0.8119, 0.663]}, {"w": "hap‐", "b": [0.8189, 0.6416, 0.8571, 0.663]}, {"w": "pens", "b": [0.1429, 0.6607, 0.1817, 0.6821]}, {"w": "automatically", "b": [0.1898, 0.6607, 0.3024, 0.6821]}, {"w": "when", "b": [0.3104, 0.6607, 0.3561, 0.6821]}, {"w": "the", "b": [0.3642, 0.6607, 0.3905, 0.6821]}, {"w": "server", "b": [0.3986, 0.6607, 0.4496, 0.6821]}, {"w": "starts).", "b": [0.4577, 0.6607, 0.5146, 0.6821]}, {"w": "You", "b": [0.5226, 0.6607, 0.555, 0.6821]}, {"w": "should", "b": [0.5631, 0.6607, 0.6198, 0.6821]}, {"w": "see", "b": [0.6279, 0.6607, 0.6532, 0.6821]}, {"w": "your", "b": [0.6613, 0.6607, 0.7003, 0.6821]}, {"w": "empty", "b": [0.7084, 0.6607, 0.7607, 0.6821]}, {"w": "workspace", "b": [0.7688, 0.6607, 0.8571, 0.6821]}, {"w": "directory", "b": [0.1429, 0.6797, 0.2197, 0.7011]}, {"w": "(containing", "b": [0.2255, 0.6797, 0.3224, 0.7011]}, {"w": "only", "b": [0.3282, 0.6797, 0.365, 0.7011]}, {"w": "the", "b": [0.3708, 0.6797, 0.3971, 0.7011]}, {"w": "env", "b": [0.403, 0.6795, 0.4312, 0.7011]}, {"w": "directory", "b": [0.437, 0.6797, 0.5138, 0.7011]}, {"w": "if", "b": [0.5196, 0.6797, 0.5314, 0.7011]}, {"w": "you", "b": [0.5372, 0.6797, 0.5684, 0.7011]}, {"w": "followed", "b": [0.5742, 0.6797, 0.6463, 0.7011]}, {"w": "the", "b": [0.6521, 0.6797, 0.6784, 0.7011]}, {"w": "preceding", "b": [0.6842, 0.6797, 0.7671, 0.7011]}, {"w": "virtualenv", "b": [0.7729, 0.6797, 0.8571, 0.7011]}, {"w": "instructions).", "b": [0.1429, 0.6988, 0.255, 0.7202]}]}, {"id": "b_11", "type": "paragraph", "text": "Now create a new Python notebook by clicking on the New button and selecting the appropriate Python version9 (see Figure 2-3).", "words": [{"w": "Now", "b": [0.1429, 0.7269, 0.1827, 0.7483]}, {"w": "create", "b": [0.1886, 0.7269, 0.238, 0.7483]}, {"w": "a", "b": [0.2438, 0.7269, 0.253, 0.7483]}, {"w": "new", "b": [0.2589, 0.7269, 0.2934, 0.7483]}, {"w": "Python", "b": [0.2993, 0.7269, 0.3601, 0.7483]}, {"w": "notebook", "b": [0.3659, 0.7269, 0.4453, 0.7483]}, {"w": "by", "b": [0.4512, 0.7269, 0.4714, 0.7483]}, {"w": "clicking", "b": [0.4772, 0.7269, 0.5428, 0.7483]}, {"w": "on", "b": [0.5487, 0.7269, 0.5707, 0.7483]}, {"w": "the", "b": [0.5766, 0.7269, 0.6029, 0.7483]}, {"w": "New", "b": [0.6088, 0.7269, 0.6469, 0.7483]}, {"w": "button", "b": [0.6527, 0.7269, 0.7091, 0.7483]}, {"w": "and", "b": [0.715, 0.7269, 0.7465, 0.7483]}, {"w": "selecting", "b": [0.7524, 0.7269, 0.8249, 0.7483]}, {"w": "the", "b": [0.8308, 0.7269, 0.8572, 0.7483]}, {"w": "appropriate", "b": [0.1429, 0.7459, 0.24, 0.7673]}, {"w": "Python", "b": [0.2447, 0.7459, 0.3055, 0.7673]}, {"w": "version9", "b": [0.3102, 0.7459, 0.3774, 0.7673]}, {"w": "(see", "b": [0.3822, 0.7459, 0.4147, 0.7673]}, {"w": "Figure", "b": [0.4194, 0.7459, 0.4734, 0.7673]}, {"w": "2-3).", "b": [0.4782, 0.7459, 0.5176, 0.7673]}]}, {"id": "b_12", "type": "paragraph", "text": "This does three things: first, it creates a new notebook file called Untitled.ipynb in your workspace; second, it starts a Jupyter Python kernel to run this notebook; and", "words": [{"w": "This", "b": [0.1428, 0.7741, 0.1801, 0.7955]}, {"w": "does", "b": [0.1878, 0.7741, 0.226, 0.7955]}, {"w": "three", "b": [0.2337, 0.7741, 0.2767, 0.7955]}, {"w": "things:", "b": [0.2844, 0.7741, 0.341, 0.7955]}, {"w": "first,", "b": [0.3488, 0.7741, 0.3871, 0.7955]}, {"w": "it", "b": [0.3948, 0.7741, 0.4068, 0.7955]}, {"w": "creates", "b": [0.4146, 0.7741, 0.4716, 0.7955]}, {"w": "a", "b": [0.4793, 0.7741, 0.4885, 0.7955]}, {"w": "new", "b": [0.4963, 0.7741, 0.5308, 0.7955]}, {"w": "notebook", "b": [0.5386, 0.7741, 0.618, 0.7955]}, {"w": "file", "b": [0.6258, 0.7741, 0.6516, 0.7955]}, {"w": "called", "b": [0.6594, 0.7741, 0.7078, 0.7955]}, {"w": "Untitled.ipynb", "b": [0.7156, 0.7738, 0.8324, 0.7955]}, {"w": "in", "b": [0.8402, 0.7741, 0.8571, 0.7955]}, {"w": "your", "b": [0.1429, 0.7931, 0.1818, 0.8145]}, {"w": "workspace;", "b": [0.1884, 0.7931, 0.2815, 0.8145]}, {"w": "second,", "b": [0.2881, 0.7931, 0.3512, 0.8145]}, {"w": "it", "b": [0.3578, 0.7931, 0.3697, 0.8145]}, {"w": "starts", "b": [0.3763, 0.7931, 0.4212, 0.8145]}, {"w": "a", "b": [0.4278, 0.7931, 0.4369, 0.8145]}, {"w": "Jupyter", "b": [0.4435, 0.7931, 0.5042, 0.8145]}, {"w": "Python", "b": [0.5108, 0.7931, 0.5716, 0.8145]}, {"w": "kernel", "b": [0.5782, 0.7931, 0.6306, 0.8145]}, {"w": "to", "b": [0.6372, 0.7931, 0.6542, 0.8145]}, {"w": "run", "b": [0.6608, 0.7931, 0.691, 0.8145]}, {"w": "this", "b": [0.6976, 0.7931, 0.7283, 0.8145]}, {"w": "notebook;", "b": [0.7349, 0.7931, 0.819, 0.8145]}, {"w": "and", "b": [0.8256, 0.7931, 0.8571, 0.8145]}]}, {"id": "b_13", "type": "paragraph", "text": "Get the Data | 47", "words": [{"w": "Get", "b": [0.7296, 0.9225, 0.7499, 0.9388]}, {"w": "the", "b": [0.7528, 0.9225, 0.7726, 0.9388]}, {"w": "Data", "b": [0.7755, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "47", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 74, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "third, it opens this notebook in a new tab. You should start by renaming this note‐ book to “Housing” (this will automatically rename the file to Housing.ipynb) by click‐ ing Untitled and typing the new name.", "words": [{"w": "third,", "b": [0.1429, 0.0791, 0.1894, 0.1005]}, {"w": "it", "b": [0.1962, 0.0791, 0.2082, 0.1005]}, {"w": "opens", "b": [0.215, 0.0791, 0.2645, 0.1005]}, {"w": "this", "b": [0.2713, 0.0791, 0.302, 0.1005]}, {"w": "notebook", "b": [0.3089, 0.0791, 0.3883, 0.1005]}, {"w": "in", "b": [0.3951, 0.0791, 0.4121, 0.1005]}, {"w": "a", "b": [0.4189, 0.0791, 0.4281, 0.1005]}, {"w": "new", "b": [0.4349, 0.0791, 0.4694, 0.1005]}, {"w": "tab.", "b": [0.4763, 0.0791, 0.5065, 0.1005]}, {"w": "You", "b": [0.5133, 0.0791, 0.5457, 0.1005]}, {"w": "should", "b": [0.5525, 0.0791, 0.6093, 0.1005]}, {"w": "start", "b": [0.6161, 0.0791, 0.6533, 0.1005]}, {"w": "by", "b": [0.6602, 0.0791, 0.6803, 0.1005]}, {"w": "renaming", "b": [0.6872, 0.0791, 0.7681, 0.1005]}, {"w": "this", "b": [0.7749, 0.0791, 0.8057, 0.1005]}, {"w": "note‐", "b": [0.8125, 0.0791, 0.8571, 0.1005]}, {"w": "book", "b": [0.1429, 0.0981, 0.185, 0.1195]}, {"w": "to", "b": [0.1903, 0.0981, 0.2072, 0.1195]}, {"w": "“Housing”", "b": [0.2125, 0.0981, 0.3002, 0.1195]}, {"w": "(this", "b": [0.3055, 0.0981, 0.3434, 0.1195]}, {"w": "will", "b": [0.3486, 0.0981, 0.379, 0.1195]}, {"w": "automatically", "b": [0.3843, 0.0981, 0.4969, 0.1195]}, {"w": "rename", "b": [0.5021, 0.0981, 0.5652, 0.1195]}, {"w": "the", "b": [0.5704, 0.0981, 0.5967, 0.1195]}, {"w": "file", "b": [0.602, 0.0981, 0.6279, 0.1195]}, {"w": "to", "b": [0.6331, 0.0981, 0.6501, 0.1195]}, {"w": "Housing.ipynb)", "b": [0.6553, 0.0979, 0.7803, 0.1195]}, {"w": "by", "b": [0.7855, 0.0981, 0.8057, 0.1195]}, {"w": "click‐", "b": [0.8109, 0.0981, 0.8571, 0.1195]}, {"w": "ing", "b": [0.1429, 0.1172, 0.1696, 0.1386]}, {"w": "Untitled", "b": [0.1743, 0.1172, 0.2432, 0.1386]}, {"w": "and", "b": [0.2479, 0.1172, 0.2795, 0.1386]}, {"w": "typing", "b": [0.2842, 0.1172, 0.3377, 0.1386]}, {"w": "the", "b": [0.3425, 0.1172, 0.3688, 0.1386]}, {"w": "new", "b": [0.3735, 0.1172, 0.4081, 0.1386]}, {"w": "name.", "b": [0.4128, 0.1172, 0.464, 0.1386]}]}, {"id": "b_1", "type": "equation", "text": "Figure 2-3. Your workspace in Jupyter", "words": [{"w": "Figure", "b": [0.1429, 0.4285, 0.1943, 0.4501]}, {"w": "2-3.", "b": [0.1991, 0.4285, 0.2308, 0.4501]}, {"w": "Your", "b": [0.2356, 0.4285, 0.2742, 0.4501]}, {"w": "workspace", "b": [0.2789, 0.4285, 0.3627, 0.4501]}, {"w": "in", "b": [0.3675, 0.4285, 0.384, 0.4501]}, {"w": "Jupyter", "b": [0.3888, 0.4285, 0.4471, 0.4501]}]}, {"id": "b_2", "type": "paragraph", "text": "A notebook contains a list of cells. Each cell can contain executable code or formatted text. Right now the notebook contains only one empty code cell, labeled “In [1]:”. Try typing print(\"Hello world!\") in the cell, and click on the play button (see Figure 2-4) or press Shift-Enter. This sends the current cell to this notebook’s Python kernel, which runs it and returns the output. The result is displayed below the cell, and since we reached the end of the notebook, a new cell is automatically created. Go through the User Interface Tour from Jupyter’s Help menu to learn the basics.", "words": [{"w": "A", "b": [0.1429, 0.4659, 0.1573, 0.4873]}, {"w": "notebook", "b": [0.1622, 0.4659, 0.2416, 0.4873]}, {"w": "contains", "b": [0.2465, 0.4659, 0.3171, 0.4873]}, {"w": "a", "b": [0.322, 0.4659, 0.3311, 0.4873]}, {"w": "list", "b": [0.3361, 0.4659, 0.3609, 0.4873]}, {"w": "of", "b": [0.3659, 0.4659, 0.3826, 0.4873]}, {"w": "cells.", "b": [0.3876, 0.4659, 0.4282, 0.4873]}, {"w": "Each", "b": [0.4331, 0.4659, 0.474, 0.4873]}, {"w": "cell", "b": [0.4789, 0.4659, 0.5072, 0.4873]}, {"w": "can", "b": [0.5121, 0.4659, 0.5414, 0.4873]}, {"w": "contain", "b": [0.5464, 0.4659, 0.6093, 0.4873]}, {"w": "executable", "b": [0.6142, 0.4659, 0.7018, 0.4873]}, {"w": "code", "b": [0.7068, 0.4659, 0.746, 0.4873]}, {"w": "or", "b": [0.751, 0.4659, 0.7693, 0.4873]}, {"w": "formatted", "b": [0.7743, 0.4659, 0.8572, 0.4873]}, {"w": "text.", "b": [0.1429, 0.485, 0.179, 0.5064]}, {"w": "Right", "b": [0.1843, 0.485, 0.2297, 0.5064]}, {"w": "now", "b": [0.235, 0.485, 0.2712, 0.5064]}, {"w": "the", "b": [0.2765, 0.485, 0.3029, 0.5064]}, {"w": "notebook", "b": [0.3082, 0.485, 0.3876, 0.5064]}, {"w": "contains", "b": [0.3929, 0.485, 0.4634, 0.5064]}, {"w": "only", "b": [0.4687, 0.485, 0.5056, 0.5064]}, {"w": "one", "b": [0.5109, 0.485, 0.5418, 0.5064]}, {"w": "empty", "b": [0.5471, 0.485, 0.5994, 0.5064]}, {"w": "code", "b": [0.6047, 0.485, 0.644, 0.5064]}, {"w": "cell,", "b": [0.6493, 0.485, 0.6823, 0.5064]}, {"w": "labeled", "b": [0.6876, 0.485, 0.7465, 0.5064]}, {"w": "“In", "b": [0.7518, 0.485, 0.7786, 0.5064]}, {"w": "[1]:”.", "b": [0.7839, 0.485, 0.8228, 0.5064]}, {"w": "Try", "b": [0.8281, 0.485, 0.8571, 0.5064]}, {"w": "typing", "b": [0.1429, 0.5049, 0.1964, 0.5263]}, {"w": "print(\"Hello", "b": [0.208, 0.5081, 0.3268, 0.5232]}, {"w": "world!\")", "b": [0.3432, 0.5081, 0.4224, 0.5232]}, {"w": "in", "b": [0.434, 0.5049, 0.451, 0.5263]}, {"w": "the", "b": [0.4626, 0.5049, 0.489, 0.5263]}, {"w": "cell,", "b": [0.5006, 0.5049, 0.5336, 0.5263]}, {"w": "and", "b": [0.5452, 0.5049, 0.5767, 0.5263]}, {"w": "click", "b": [0.5884, 0.5049, 0.6272, 0.5263]}, {"w": "on", "b": [0.6388, 0.5049, 0.6608, 0.5263]}, {"w": "the", "b": [0.6725, 0.5049, 0.6988, 0.5263]}, {"w": "play", "b": [0.7104, 0.5049, 0.7449, 0.5263]}, {"w": "button", "b": [0.7566, 0.5049, 0.8129, 0.5263]}, {"w": "(see", "b": [0.8246, 0.5049, 0.8571, 0.5263]}, {"w": "Figure", "b": [0.1428, 0.524, 0.1968, 0.5454]}, {"w": "2-4)", "b": [0.2024, 0.524, 0.237, 0.5454]}, {"w": "or", "b": [0.2425, 0.524, 0.2608, 0.5454]}, {"w": "press", "b": [0.2664, 0.524, 0.3091, 0.5454]}, {"w": "Shift-Enter.", "b": [0.3147, 0.524, 0.4104, 0.5454]}, {"w": "This", "b": [0.4159, 0.524, 0.4531, 0.5454]}, {"w": "sends", "b": [0.4586, 0.524, 0.5052, 0.5454]}, {"w": "the", "b": [0.5107, 0.524, 0.537, 0.5454]}, {"w": "current", "b": [0.5425, 0.524, 0.604, 0.5454]}, {"w": "cell", "b": [0.6096, 0.524, 0.6378, 0.5454]}, {"w": "to", "b": [0.6433, 0.524, 0.6603, 0.5454]}, {"w": "this", "b": [0.6658, 0.524, 0.6965, 0.5454]}, {"w": "notebook’s", "b": [0.702, 0.524, 0.7908, 0.5454]}, {"w": "Python", "b": [0.7963, 0.524, 0.8571, 0.5454]}, {"w": "kernel,", "b": [0.1429, 0.543, 0.2, 0.5644]}, {"w": "which", "b": [0.2069, 0.543, 0.2578, 0.5644]}, {"w": "runs", "b": [0.2647, 0.543, 0.3025, 0.5644]}, {"w": "it", "b": [0.3094, 0.543, 0.3213, 0.5644]}, {"w": "and", "b": [0.3282, 0.543, 0.3598, 0.5644]}, {"w": "returns", "b": [0.3666, 0.543, 0.4274, 0.5644]}, {"w": "the", "b": [0.4343, 0.543, 0.4606, 0.5644]}, {"w": "output.", "b": [0.4675, 0.543, 0.5286, 0.5644]}, {"w": "The", "b": [0.5355, 0.543, 0.5683, 0.5644]}, {"w": "result", "b": [0.5752, 0.543, 0.6221, 0.5644]}, {"w": "is", "b": [0.6289, 0.543, 0.6422, 0.5644]}, {"w": "displayed", "b": [0.649, 0.543, 0.7276, 0.5644]}, {"w": "below", "b": [0.7345, 0.543, 0.7841, 0.5644]}, {"w": "the", "b": [0.791, 0.543, 0.8173, 0.5644]}, {"w": "cell,", "b": [0.8242, 0.543, 0.8571, 0.5644]}, {"w": "and", "b": [0.1429, 0.5621, 0.1744, 0.5835]}, {"w": "since", "b": [0.1796, 0.5621, 0.2219, 0.5835]}, {"w": "we", "b": [0.2272, 0.5621, 0.2503, 0.5835]}, {"w": "reached", "b": [0.2555, 0.5621, 0.3211, 0.5835]}, {"w": "the", "b": [0.3263, 0.5621, 0.3526, 0.5835]}, {"w": "end", "b": [0.3579, 0.5621, 0.3891, 0.5835]}, {"w": "of", "b": [0.3944, 0.5621, 0.4112, 0.5835]}, {"w": "the", "b": [0.4164, 0.5621, 0.4427, 0.5835]}, {"w": "notebook,", "b": [0.448, 0.5621, 0.5321, 0.5835]}, {"w": "a", "b": [0.5374, 0.5621, 0.5465, 0.5835]}, {"w": "new", "b": [0.5517, 0.5621, 0.5863, 0.5835]}, {"w": "cell", "b": [0.5915, 0.5621, 0.6197, 0.5835]}, {"w": "is", "b": [0.625, 0.5621, 0.6382, 0.5835]}, {"w": "automatically", "b": [0.6434, 0.5621, 0.756, 0.5835]}, {"w": "created.", "b": [0.7613, 0.5621, 0.8264, 0.5835]}, {"w": "Go", "b": [0.8316, 0.5621, 0.8571, 0.5835]}, {"w": "through", "b": [0.1429, 0.5811, 0.2106, 0.6025]}, {"w": "the", "b": [0.2154, 0.5811, 0.2417, 0.6025]}, {"w": "User", "b": [0.2464, 0.5811, 0.2849, 0.6025]}, {"w": "Interface", "b": [0.2896, 0.5811, 0.3636, 0.6025]}, {"w": "Tour", "b": [0.3684, 0.5811, 0.4086, 0.6025]}, {"w": "from", "b": [0.4133, 0.5811, 0.4549, 0.6025]}, {"w": "Jupyter’s", "b": [0.4596, 0.5811, 0.5306, 0.6025]}, {"w": "Help", "b": [0.5353, 0.5811, 0.5758, 0.6025]}, {"w": "menu", "b": [0.5805, 0.5811, 0.6285, 0.6025]}, {"w": "to", "b": [0.6332, 0.5811, 0.6502, 0.6025]}, {"w": "learn", "b": [0.655, 0.5811, 0.6974, 0.6025]}, {"w": "the", "b": [0.7021, 0.5811, 0.7284, 0.6025]}, {"w": "basics.", "b": [0.7331, 0.5811, 0.7873, 0.6025]}]}, {"id": "b_3", "type": "equation", "text": "Figure 2-4. Hello world Python notebook", "words": [{"w": "Figure", "b": [0.1429, 0.8144, 0.1943, 0.836]}, {"w": "2-4.", "b": [0.1991, 0.8144, 0.2308, 0.836]}, {"w": "Hello", "b": [0.2356, 0.8144, 0.2784, 0.836]}, {"w": "world", "b": [0.2831, 0.8144, 0.3297, 0.836]}, {"w": "Python", "b": [0.3345, 0.8144, 0.3932, 0.836]}, {"w": "notebook", "b": [0.398, 0.8144, 0.4717, 0.836]}]}, {"id": "b_4", "type": "equation", "text": "48 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "48", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 75, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "10 You might also need to check legal constraints, such as private fields that should never be copied to unsafe datastores.", "words": [{"w": "10", "b": [0.1385, 0.8265, 0.1518, 0.8408]}, {"w": "You", "b": [0.1587, 0.825, 0.1834, 0.8413]}, {"w": "might", "b": [0.187, 0.825, 0.2247, 0.8413]}, {"w": "also", "b": [0.2283, 0.825, 0.2532, 0.8413]}, {"w": "need", "b": [0.2568, 0.825, 0.2873, 0.8413]}, {"w": "to", "b": [0.291, 0.825, 0.3039, 0.8413]}, {"w": "check", "b": [0.3075, 0.825, 0.344, 0.8413]}, {"w": "legal", "b": [0.3476, 0.825, 0.3768, 0.8413]}, {"w": "constraints,", "b": [0.3804, 0.825, 0.4543, 0.8413]}, {"w": "such", "b": [0.4579, 0.825, 0.4874, 0.8413]}, {"w": "as", "b": [0.491, 0.825, 0.5038, 0.8413]}, {"w": "private", "b": [0.5074, 0.825, 0.5514, 0.8413]}, {"w": "fields", "b": [0.555, 0.825, 0.589, 0.8413]}, {"w": "that", "b": [0.5926, 0.825, 0.6174, 0.8413]}, {"w": "should", "b": [0.621, 0.825, 0.6642, 0.8413]}, {"w": "never", "b": [0.6678, 0.825, 0.7032, 0.8413]}, {"w": "be", "b": [0.7068, 0.825, 0.7217, 0.8413]}, {"w": "copied", "b": [0.7253, 0.825, 0.7678, 0.8413]}, {"w": "to", "b": [0.7714, 0.825, 0.7843, 0.8413]}, {"w": "unsafe", "b": [0.7879, 0.825, 0.8293, 0.8413]}, {"w": "datastores.", "b": [0.1587, 0.8401, 0.2264, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "11 In a real project you would save this code in a Python file, but for now you can just write it in your Jupyter notebook.", "words": [{"w": "11", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "In", "b": [0.1587, 0.8598, 0.1728, 0.8761]}, {"w": "a", "b": [0.1764, 0.8598, 0.1834, 0.8761]}, {"w": "real", "b": [0.187, 0.8598, 0.2106, 0.8761]}, {"w": "project", "b": [0.2142, 0.8598, 0.2589, 0.8761]}, {"w": "you", "b": [0.2625, 0.8598, 0.2863, 0.8761]}, {"w": "would", "b": [0.2899, 0.8598, 0.3297, 0.8761]}, {"w": "save", "b": [0.3333, 0.8598, 0.3599, 0.8761]}, {"w": "this", "b": [0.3635, 0.8598, 0.3869, 0.8761]}, {"w": "code", "b": [0.3905, 0.8598, 0.4204, 0.8761]}, {"w": "in", "b": [0.424, 0.8598, 0.437, 0.8761]}, {"w": "a", "b": [0.4406, 0.8598, 0.4476, 0.8761]}, {"w": "Python", "b": [0.4512, 0.8598, 0.4975, 0.8761]}, {"w": "file,", "b": [0.5011, 0.8598, 0.5244, 0.8761]}, {"w": "but", "b": [0.528, 0.8598, 0.5493, 0.8761]}, {"w": "for", "b": [0.553, 0.8598, 0.5716, 0.8761]}, {"w": "now", "b": [0.5752, 0.8598, 0.6029, 0.8761]}, {"w": "you", "b": [0.6065, 0.8598, 0.6303, 0.8761]}, {"w": "can", "b": [0.6339, 0.8598, 0.6563, 0.8761]}, {"w": "just", "b": [0.6599, 0.8598, 0.683, 0.8761]}, {"w": "write", "b": [0.6866, 0.8598, 0.7192, 0.8761]}, {"w": "it", "b": [0.7228, 0.8598, 0.7319, 0.8761]}, {"w": "in", "b": [0.7355, 0.8598, 0.7485, 0.8761]}, {"w": "your", "b": [0.7521, 0.8598, 0.7818, 0.8761]}, {"w": "Jupyter", "b": [0.7854, 0.8598, 0.8316, 0.8761]}, {"w": "notebook.", "b": [0.1587, 0.8749, 0.2228, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "Download the Data", "words": [{"w": "Download", "b": [0.1429, 0.0763, 0.2477, 0.1049]}, {"w": "the", "b": [0.2526, 0.0763, 0.2875, 0.1049]}, {"w": "Data", "b": [0.2924, 0.0763, 0.3408, 0.1049]}]}, {"id": "b_3", "type": "paragraph", "text": "In typical environments your data would be available in a relational database (or some other common datastore) and spread across multiple tables/documents/files. To access it, you would first need to get your credentials and access authorizations,10 and familiarize yourself with the data schema. In this project, however, things are much simpler: you will just download a single compressed file, housing.tgz, which contains a comma-separated value (CSV) file called housing.csv with all the data.", "words": [{"w": "In", "b": [0.1429, 0.1108, 0.1614, 0.1322]}, {"w": "typical", "b": [0.17, 0.1108, 0.2257, 0.1322]}, {"w": "environments", "b": [0.2344, 0.1108, 0.35, 0.1322]}, {"w": "your", "b": [0.3587, 0.1108, 0.3977, 0.1322]}, {"w": "data", "b": [0.4064, 0.1108, 0.4416, 0.1322]}, {"w": "would", "b": [0.4503, 0.1108, 0.5025, 0.1322]}, {"w": "be", "b": [0.5112, 0.1108, 0.5306, 0.1322]}, {"w": "available", "b": [0.5393, 0.1108, 0.6116, 0.1322]}, {"w": "in", "b": [0.6203, 0.1108, 0.6373, 0.1322]}, {"w": "a", "b": [0.6459, 0.1108, 0.6551, 0.1322]}, {"w": "relational", "b": [0.6638, 0.1108, 0.7427, 0.1322]}, {"w": "database", "b": [0.7514, 0.1108, 0.8229, 0.1322]}, {"w": "(or", "b": [0.8316, 0.1108, 0.8571, 0.1322]}, {"w": "some", "b": [0.1428, 0.1298, 0.187, 0.1512]}, {"w": "other", "b": [0.1919, 0.1298, 0.2366, 0.1512]}, {"w": "common", "b": [0.2415, 0.1298, 0.3171, 0.1512]}, {"w": "datastore)", "b": [0.322, 0.1298, 0.4056, 0.1512]}, {"w": "and", "b": [0.4105, 0.1298, 0.4421, 0.1512]}, {"w": "spread", "b": [0.4469, 0.1298, 0.5022, 0.1512]}, {"w": "across", "b": [0.5071, 0.1298, 0.5587, 0.1512]}, {"w": "multiple", "b": [0.5636, 0.1298, 0.6336, 0.1512]}, {"w": "tables/documents/files.", "b": [0.6385, 0.1298, 0.8308, 0.1512]}, {"w": "To", "b": [0.8357, 0.1298, 0.8571, 0.1512]}, {"w": "access", "b": [0.1429, 0.1489, 0.1938, 0.1703]}, {"w": "it,", "b": [0.199, 0.1489, 0.2157, 0.1703]}, {"w": "you", "b": [0.2209, 0.1489, 0.2522, 0.1703]}, {"w": "would", "b": [0.2574, 0.1489, 0.3096, 0.1703]}, {"w": "first", "b": [0.3149, 0.1489, 0.3483, 0.1703]}, {"w": "need", "b": [0.3536, 0.1489, 0.3937, 0.1703]}, {"w": "to", "b": [0.3989, 0.1489, 0.4159, 0.1703]}, {"w": "get", "b": [0.4211, 0.1489, 0.4461, 0.1703]}, {"w": "your", "b": [0.4513, 0.1489, 0.4903, 0.1703]}, {"w": "credentials", "b": [0.4955, 0.1489, 0.5857, 0.1703]}, {"w": "and", "b": [0.591, 0.1489, 0.6225, 0.1703]}, {"w": "access", "b": [0.6277, 0.1489, 0.6786, 0.1703]}, {"w": "authorizations,10", "b": [0.6839, 0.1489, 0.8204, 0.1703]}, {"w": "and", "b": [0.8256, 0.1489, 0.8571, 0.1703]}, {"w": "familiarize", "b": [0.1429, 0.1679, 0.2317, 0.1893]}, {"w": "yourself", "b": [0.2384, 0.1679, 0.3053, 0.1893]}, {"w": "with", "b": [0.3119, 0.1679, 0.3493, 0.1893]}, {"w": "the", "b": [0.3559, 0.1679, 0.3823, 0.1893]}, {"w": "data", "b": [0.3889, 0.1679, 0.4242, 0.1893]}, {"w": "schema.", "b": [0.4308, 0.1679, 0.4982, 0.1893]}, {"w": "In", "b": [0.5049, 0.1679, 0.5234, 0.1893]}, {"w": "this", "b": [0.53, 0.1679, 0.5607, 0.1893]}, {"w": "project,", "b": [0.5674, 0.1679, 0.6307, 0.1893]}, {"w": "however,", "b": [0.6374, 0.1679, 0.7119, 0.1893]}, {"w": "things", "b": [0.7186, 0.1679, 0.7704, 0.1893]}, {"w": "are", "b": [0.7771, 0.1679, 0.8028, 0.1893]}, {"w": "much", "b": [0.8095, 0.1679, 0.8571, 0.1893]}, {"w": "simpler:", "b": [0.1429, 0.187, 0.2108, 0.2084]}, {"w": "you", "b": [0.2155, 0.187, 0.2468, 0.2084]}, {"w": "will", "b": [0.2515, 0.187, 0.2819, 0.2084]}, {"w": "just", "b": [0.2866, 0.187, 0.317, 0.2084]}, {"w": "download", "b": [0.3217, 0.187, 0.4051, 0.2084]}, {"w": "a", "b": [0.4098, 0.187, 0.4189, 0.2084]}, {"w": "single", "b": [0.4237, 0.187, 0.4722, 0.2084]}, {"w": "compressed", "b": [0.4769, 0.187, 0.5757, 0.2084]}, {"w": "file,", "b": [0.5804, 0.187, 0.611, 0.2084]}, {"w": "housing.tgz,", "b": [0.6162, 0.1868, 0.7122, 0.2084]}, {"w": "which", "b": [0.7169, 0.187, 0.7678, 0.2084]}, {"w": "contains", "b": [0.7726, 0.187, 0.8431, 0.2084]}, {"w": "a", "b": [0.8479, 0.187, 0.857, 0.2084]}, {"w": "comma-separated", "b": [0.1429, 0.206, 0.2922, 0.2274]}, {"w": "value", "b": [0.297, 0.206, 0.3409, 0.2274]}, {"w": "(CSV)", "b": [0.3457, 0.206, 0.3985, 0.2274]}, {"w": "file", "b": [0.4032, 0.206, 0.4291, 0.2274]}, {"w": "called", "b": [0.4338, 0.206, 0.4822, 0.2274]}, {"w": "housing.csv", "b": [0.4869, 0.2058, 0.5788, 0.2274]}, {"w": "with", "b": [0.5835, 0.206, 0.6209, 0.2274]}, {"w": "all", "b": [0.6256, 0.206, 0.6453, 0.2274]}, {"w": "the", "b": [0.65, 0.206, 0.6763, 0.2274]}, {"w": "data.", "b": [0.6811, 0.206, 0.7211, 0.2274]}]}, {"id": "b_4", "type": "paragraph", "text": "You could use your web browser to download it, and run tar xzf housing.tgz to decompress the file and extract the CSV file, but it is preferable to create a small func‐ tion to do that. It is useful in particular if data changes regularly, as it allows you to write a small script that you can run whenever you need to fetch the latest data (or you can set up a scheduled job to do that automatically at regular intervals). Auto‐ mating the process of fetching the data is also useful if you need to install the dataset on multiple machines.", "words": [{"w": "You", "b": [0.1429, 0.235, 0.1752, 0.2564]}, {"w": "could", "b": [0.1819, 0.235, 0.2287, 0.2564]}, {"w": "use", "b": [0.2353, 0.235, 0.2629, 0.2564]}, {"w": "your", "b": [0.2696, 0.235, 0.3085, 0.2564]}, {"w": "web", "b": [0.3152, 0.235, 0.3489, 0.2564]}, {"w": "browser", "b": [0.3556, 0.235, 0.423, 0.2564]}, {"w": "to", "b": [0.4297, 0.235, 0.4467, 0.2564]}, {"w": "download", "b": [0.4534, 0.235, 0.5367, 0.2564]}, {"w": "it,", "b": [0.5434, 0.235, 0.56, 0.2564]}, {"w": "and", "b": [0.5667, 0.235, 0.5983, 0.2564]}, {"w": "run", "b": [0.6049, 0.235, 0.6351, 0.2564]}, {"w": "tar", "b": [0.6418, 0.2382, 0.6715, 0.2533]}, {"w": "xzf", "b": [0.6832, 0.2382, 0.7129, 0.2533]}, {"w": "housing.tgz", "b": [0.7246, 0.2382, 0.8335, 0.2533]}, {"w": "to", "b": [0.8402, 0.235, 0.8572, 0.2564]}, {"w": "decompress", "b": [0.1429, 0.2541, 0.2416, 0.2755]}, {"w": "the", "b": [0.2464, 0.2541, 0.2728, 0.2755]}, {"w": "file", "b": [0.2776, 0.2541, 0.3035, 0.2755]}, {"w": "and", "b": [0.3083, 0.2541, 0.3399, 0.2755]}, {"w": "extract", "b": [0.3447, 0.2541, 0.4018, 0.2755]}, {"w": "the", "b": [0.4066, 0.2541, 0.433, 0.2755]}, {"w": "CSV", "b": [0.4378, 0.2541, 0.4762, 0.2755]}, {"w": "file,", "b": [0.481, 0.2541, 0.5116, 0.2755]}, {"w": "but", "b": [0.5165, 0.2541, 0.5445, 0.2755]}, {"w": "it", "b": [0.5493, 0.2541, 0.5612, 0.2755]}, {"w": "is", "b": [0.5661, 0.2541, 0.5793, 0.2755]}, {"w": "preferable", "b": [0.5841, 0.2541, 0.6682, 0.2755]}, {"w": "to", "b": [0.6731, 0.2541, 0.6901, 0.2755]}, {"w": "create", "b": [0.6949, 0.2541, 0.7442, 0.2755]}, {"w": "a", "b": [0.7491, 0.2541, 0.7582, 0.2755]}, {"w": "small", "b": [0.7631, 0.2541, 0.8075, 0.2755]}, {"w": "func‐", "b": [0.8123, 0.2541, 0.8571, 0.2755]}, {"w": "tion", "b": [0.1429, 0.2731, 0.1768, 0.2945]}, {"w": "to", "b": [0.1832, 0.2731, 0.2002, 0.2945]}, {"w": "do", "b": [0.2066, 0.2731, 0.2283, 0.2945]}, {"w": "that.", "b": [0.2347, 0.2731, 0.272, 0.2945]}, {"w": "It", "b": [0.2784, 0.2731, 0.2911, 0.2945]}, {"w": "is", "b": [0.2975, 0.2731, 0.3107, 0.2945]}, {"w": "useful", "b": [0.3172, 0.2731, 0.3672, 0.2945]}, {"w": "in", "b": [0.3737, 0.2731, 0.3906, 0.2945]}, {"w": "particular", "b": [0.3971, 0.2731, 0.4788, 0.2945]}, {"w": "if", "b": [0.4852, 0.2731, 0.497, 0.2945]}, {"w": "data", "b": [0.5034, 0.2731, 0.5387, 0.2945]}, {"w": "changes", "b": [0.5451, 0.2731, 0.6118, 0.2945]}, {"w": "regularly,", "b": [0.6182, 0.2731, 0.6958, 0.2945]}, {"w": "as", "b": [0.7023, 0.2731, 0.7191, 0.2945]}, {"w": "it", "b": [0.7255, 0.2731, 0.7374, 0.2945]}, {"w": "allows", "b": [0.7438, 0.2731, 0.7961, 0.2945]}, {"w": "you", "b": [0.8025, 0.2731, 0.8337, 0.2945]}, {"w": "to", "b": [0.8402, 0.2731, 0.8571, 0.2945]}, {"w": "write", "b": [0.1429, 0.2922, 0.1856, 0.3136]}, {"w": "a", "b": [0.1923, 0.2922, 0.2015, 0.3136]}, {"w": "small", "b": [0.2081, 0.2922, 0.2525, 0.3136]}, {"w": "script", "b": [0.2592, 0.2922, 0.3062, 0.3136]}, {"w": "that", "b": [0.3129, 0.2922, 0.3455, 0.3136]}, {"w": "you", "b": [0.3522, 0.2922, 0.3834, 0.3136]}, {"w": "can", "b": [0.3901, 0.2922, 0.4195, 0.3136]}, {"w": "run", "b": [0.4261, 0.2922, 0.4563, 0.3136]}, {"w": "whenever", "b": [0.463, 0.2922, 0.5437, 0.3136]}, {"w": "you", "b": [0.5504, 0.2922, 0.5816, 0.3136]}, {"w": "need", "b": [0.5883, 0.2922, 0.6284, 0.3136]}, {"w": "to", "b": [0.6351, 0.2922, 0.6521, 0.3136]}, {"w": "fetch", "b": [0.6588, 0.2922, 0.7001, 0.3136]}, {"w": "the", "b": [0.7067, 0.2922, 0.7331, 0.3136]}, {"w": "latest", "b": [0.7397, 0.2922, 0.783, 0.3136]}, {"w": "data", "b": [0.7897, 0.2922, 0.8249, 0.3136]}, {"w": "(or", "b": [0.8316, 0.2922, 0.8571, 0.3136]}, {"w": "you", "b": [0.1429, 0.3112, 0.1741, 0.3326]}, {"w": "can", "b": [0.1811, 0.3112, 0.2105, 0.3326]}, {"w": "set", "b": [0.2175, 0.3112, 0.2404, 0.3326]}, {"w": "up", "b": [0.2474, 0.3112, 0.2694, 0.3326]}, {"w": "a", "b": [0.2764, 0.3112, 0.2855, 0.3326]}, {"w": "scheduled", "b": [0.2926, 0.3112, 0.3762, 0.3326]}, {"w": "job", "b": [0.3832, 0.3112, 0.4097, 0.3326]}, {"w": "to", "b": [0.4168, 0.3112, 0.4337, 0.3326]}, {"w": "do", "b": [0.4408, 0.3112, 0.4624, 0.3326]}, {"w": "that", "b": [0.4694, 0.3112, 0.502, 0.3326]}, {"w": "automatically", "b": [0.509, 0.3112, 0.6216, 0.3326]}, {"w": "at", "b": [0.6286, 0.3112, 0.6438, 0.3326]}, {"w": "regular", "b": [0.6508, 0.3112, 0.7103, 0.3326]}, {"w": "intervals).", "b": [0.7173, 0.3112, 0.8011, 0.3326]}, {"w": "Auto‐", "b": [0.8082, 0.3112, 0.8572, 0.3326]}, {"w": "mating", "b": [0.1429, 0.3303, 0.2018, 0.3517]}, {"w": "the", "b": [0.2073, 0.3303, 0.2337, 0.3517]}, {"w": "process", "b": [0.2392, 0.3303, 0.3015, 0.3517]}, {"w": "of", "b": [0.3071, 0.3303, 0.3238, 0.3517]}, {"w": "fetching", "b": [0.3294, 0.3303, 0.3975, 0.3517]}, {"w": "the", "b": [0.403, 0.3303, 0.4294, 0.3517]}, {"w": "data", "b": [0.435, 0.3303, 0.4702, 0.3517]}, {"w": "is", "b": [0.4758, 0.3303, 0.489, 0.3517]}, {"w": "also", "b": [0.4946, 0.3303, 0.5273, 0.3517]}, {"w": "useful", "b": [0.5329, 0.3303, 0.5829, 0.3517]}, {"w": "if", "b": [0.5885, 0.3303, 0.6002, 0.3517]}, {"w": "you", "b": [0.6058, 0.3303, 0.6371, 0.3517]}, {"w": "need", "b": [0.6426, 0.3303, 0.6828, 0.3517]}, {"w": "to", "b": [0.6883, 0.3303, 0.7053, 0.3517]}, {"w": "install", "b": [0.7109, 0.3303, 0.7616, 0.3517]}, {"w": "the", "b": [0.7671, 0.3303, 0.7935, 0.3517]}, {"w": "dataset", "b": [0.799, 0.3303, 0.8571, 0.3517]}, {"w": "on", "b": [0.1429, 0.3493, 0.1649, 0.3707]}, {"w": "multiple", "b": [0.1696, 0.3493, 0.2396, 0.3707]}, {"w": "machines.", "b": [0.2443, 0.3493, 0.3287, 0.3707]}]}, {"id": "b_5", "type": "paragraph", "text": "Here is the function to fetch the data:11", "words": [{"w": "Here", "b": [0.1429, 0.3774, 0.1837, 0.3988]}, {"w": "is", "b": [0.1885, 0.3774, 0.2017, 0.3988]}, {"w": "the", "b": [0.2064, 0.3774, 0.2327, 0.3988]}, {"w": "function", "b": [0.2375, 0.3774, 0.3089, 0.3988]}, {"w": "to", "b": [0.3136, 0.3774, 0.3306, 0.3988]}, {"w": "fetch", "b": [0.3353, 0.3774, 0.3766, 0.3988]}, {"w": "the", "b": [0.3814, 0.3774, 0.4077, 0.3988]}, {"w": "data:11", "b": [0.4124, 0.3774, 0.4639, 0.3988]}]}, {"id": "b_6", "type": "paragraph", "text": "import os import tarfile from six.moves import urllib", "words": [{"w": "import", "b": [0.1766, 0.4094, 0.2272, 0.4223]}, {"w": "os", "b": [0.2356, 0.4094, 0.2525, 0.4223]}, {"w": "import", "b": [0.1766, 0.4248, 0.2272, 0.4377]}, {"w": "tarfile", "b": [0.2356, 0.4248, 0.2946, 0.4377]}, {"w": "from", "b": [0.1766, 0.4402, 0.2103, 0.4531]}, {"w": "six.moves", "b": [0.2188, 0.4402, 0.2946, 0.4531]}, {"w": "import", "b": [0.3031, 0.4402, 0.3537, 0.4531]}, {"w": "urllib", "b": [0.3621, 0.4402, 0.4127, 0.4531]}]}, {"id": "b_7", "type": "paragraph", "text": "DOWNLOAD_ROOT = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\" HOUSING_PATH = os.path.join(\"datasets\", \"housing\") HOUSING_URL = DOWNLOAD_ROOT + \"datasets/housing/housing.tgz\"", "words": [{"w": "DOWNLOAD_ROOT", "b": [0.1766, 0.4711, 0.2862, 0.4839]}, {"w": "=", "b": [0.2946, 0.4711, 0.3031, 0.4839]}, {"w": "\"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"", "b": [0.3115, 0.4711, 0.8343, 0.4839]}, {"w": "HOUSING_PATH", "b": [0.1766, 0.4865, 0.2778, 0.4994]}, {"w": "=", "b": [0.2862, 0.4865, 0.2946, 0.4994]}, {"w": "os.path.join(\"datasets\",", "b": [0.3031, 0.4865, 0.5055, 0.4994]}, {"w": "\"housing\")", "b": [0.5139, 0.4865, 0.5982, 0.4994]}, {"w": "HOUSING_URL", "b": [0.1766, 0.5019, 0.2694, 0.5148]}, {"w": "=", "b": [0.2778, 0.5019, 0.2862, 0.5148]}, {"w": "DOWNLOAD_ROOT", "b": [0.2946, 0.5019, 0.4043, 0.5148]}, {"w": "+", "b": [0.4127, 0.5019, 0.4211, 0.5148]}, {"w": "\"datasets/housing/housing.tgz\"", "b": [0.4296, 0.5019, 0.6825, 0.5148]}]}, {"id": "b_8", "type": "paragraph", "text": "def fetch_housing_data(housing_url=HOUSING_URL, housing_path=HOUSING_PATH): if not os.path.isdir(housing_path): os.makedirs(housing_path) tgz_path = os.path.join(housing_path, \"housing.tgz\") urllib.request.urlretrieve(housing_url, tgz_path) housing_tgz = tarfile.open(tgz_path) housing_tgz.extractall(path=housing_path) housing_tgz.close()", "words": [{"w": "def", "b": [0.1766, 0.5328, 0.2019, 0.5456]}, {"w": "fetch_housing_data(housing_url=HOUSING_URL,", "b": [0.2103, 0.5328, 0.5729, 0.5456]}, {"w": "housing_path=HOUSING_PATH):", "b": [0.5814, 0.5328, 0.809, 0.5456]}, {"w": "if", "b": [0.2103, 0.5482, 0.2272, 0.561]}, {"w": "not", "b": [0.2356, 0.5482, 0.2609, 0.561]}, {"w": "os.path.isdir(housing_path):", "b": [0.2694, 0.5482, 0.5055, 0.561]}, {"w": "os.makedirs(housing_path)", "b": [0.2441, 0.5636, 0.4549, 0.5765]}, {"w": "tgz_path", "b": [0.2103, 0.579, 0.2778, 0.5919]}, {"w": "=", "b": [0.2862, 0.579, 0.2946, 0.5919]}, {"w": "os.path.join(housing_path,", "b": [0.3031, 0.579, 0.5223, 0.5919]}, {"w": "\"housing.tgz\")", "b": [0.5308, 0.579, 0.6488, 0.5919]}, {"w": "urllib.request.urlretrieve(housing_url,", "b": [0.2103, 0.5944, 0.5392, 0.6073]}, {"w": "tgz_path)", "b": [0.5476, 0.5944, 0.6235, 0.6073]}, {"w": "housing_tgz", "b": [0.2103, 0.6099, 0.3031, 0.6227]}, {"w": "=", "b": [0.3115, 0.6099, 0.3199, 0.6227]}, {"w": "tarfile.open(tgz_path)", "b": [0.3284, 0.6099, 0.5139, 0.6227]}, {"w": "housing_tgz.extractall(path=housing_path)", "b": [0.2103, 0.6253, 0.5561, 0.6381]}, {"w": "housing_tgz.close()", "b": [0.2103, 0.6407, 0.3705, 0.6536]}]}, {"id": "b_9", "type": "paragraph", "text": "Now when you call fetch_housing_data(), it creates a datasets/housing directory in your workspace, downloads the housing.tgz file, and extracts the housing.csv from it in this directory.", "words": [{"w": "Now", "b": [0.1429, 0.6622, 0.1827, 0.6836]}, {"w": "when", "b": [0.1886, 0.6622, 0.2343, 0.6836]}, {"w": "you", "b": [0.2402, 0.6622, 0.2715, 0.6836]}, {"w": "call", "b": [0.2774, 0.6622, 0.3059, 0.6836]}, {"w": "fetch_housing_data(),", "b": [0.3118, 0.6622, 0.5145, 0.6836]}, {"w": "it", "b": [0.5204, 0.6622, 0.5324, 0.6836]}, {"w": "creates", "b": [0.5383, 0.6622, 0.5953, 0.6836]}, {"w": "a", "b": [0.6013, 0.6622, 0.6104, 0.6836]}, {"w": "datasets/housing", "b": [0.6163, 0.662, 0.7514, 0.6836]}, {"w": "directory", "b": [0.7574, 0.6622, 0.8342, 0.6836]}, {"w": "in", "b": [0.8402, 0.6622, 0.8571, 0.6836]}, {"w": "your", "b": [0.1429, 0.6813, 0.1819, 0.7027]}, {"w": "workspace,", "b": [0.1866, 0.6813, 0.2797, 0.7027]}, {"w": "downloads", "b": [0.2844, 0.6813, 0.3754, 0.7027]}, {"w": "the", "b": [0.3801, 0.6813, 0.4064, 0.7027]}, {"w": "housing.tgz", "b": [0.4116, 0.6811, 0.5029, 0.7027]}, {"w": "file,", "b": [0.5077, 0.6813, 0.5383, 0.7027]}, {"w": "and", "b": [0.543, 0.6813, 0.5746, 0.7027]}, {"w": "extracts", "b": [0.5793, 0.6813, 0.644, 0.7027]}, {"w": "the", "b": [0.6488, 0.6813, 0.6751, 0.7027]}, {"w": "housing.csv", "b": [0.6802, 0.6811, 0.7722, 0.7027]}, {"w": "from", "b": [0.777, 0.6813, 0.8186, 0.7027]}, {"w": "it", "b": [0.8233, 0.6813, 0.8352, 0.7027]}, {"w": "in", "b": [0.84, 0.6813, 0.857, 0.7027]}, {"w": "this", "b": [0.1429, 0.7003, 0.1736, 0.7217]}, {"w": "directory.", "b": [0.1783, 0.7003, 0.2584, 0.7217]}]}, {"id": "b_10", "type": "paragraph", "text": "Now let’s load the data using Pandas. Once again you should write a small function to load the data:", "words": [{"w": "Now", "b": [0.1429, 0.7284, 0.1827, 0.7499]}, {"w": "let’s", "b": [0.1877, 0.7284, 0.2179, 0.7499]}, {"w": "load", "b": [0.2229, 0.7284, 0.2589, 0.7499]}, {"w": "the", "b": [0.2639, 0.7284, 0.2902, 0.7499]}, {"w": "data", "b": [0.2952, 0.7284, 0.3304, 0.7499]}, {"w": "using", "b": [0.3354, 0.7284, 0.3808, 0.7499]}, {"w": "Pandas.", "b": [0.3858, 0.7284, 0.4502, 0.7499]}, {"w": "Once", "b": [0.4551, 0.7284, 0.4997, 0.7499]}, {"w": "again", "b": [0.5047, 0.7284, 0.5497, 0.7499]}, {"w": "you", "b": [0.5547, 0.7284, 0.5859, 0.7499]}, {"w": "should", "b": [0.5909, 0.7284, 0.6476, 0.7499]}, {"w": "write", "b": [0.6526, 0.7284, 0.6954, 0.7499]}, {"w": "a", "b": [0.7004, 0.7284, 0.7095, 0.7499]}, {"w": "small", "b": [0.7145, 0.7284, 0.7589, 0.7499]}, {"w": "function", "b": [0.7638, 0.7284, 0.8352, 0.7499]}, {"w": "to", "b": [0.8402, 0.7284, 0.8572, 0.7499]}, {"w": "load", "b": [0.1429, 0.7475, 0.1789, 0.7689]}, {"w": "the", "b": [0.1836, 0.7475, 0.21, 0.7689]}, {"w": "data:", "b": [0.2147, 0.7475, 0.2547, 0.7689]}]}, {"id": "b_11", "type": "paragraph", "text": "Get the Data | 49", "words": [{"w": "Get", "b": [0.7296, 0.9225, 0.7499, 0.9388]}, {"w": "the", "b": [0.7527, 0.9225, 0.7726, 0.9388]}, {"w": "Data", "b": [0.7755, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "49", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 76, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "import pandas as pd", "words": [{"w": "import", "b": [0.1766, 0.0829, 0.2272, 0.0958]}, {"w": "pandas", "b": [0.2356, 0.0829, 0.2862, 0.0958]}, {"w": "as", "b": [0.2946, 0.0829, 0.3115, 0.0958]}, {"w": "pd", "b": [0.3199, 0.0829, 0.3368, 0.0958]}]}, {"id": "b_1", "type": "paragraph", "text": "def load_housing_data(housing_path=HOUSING_PATH): csv_path = os.path.join(housing_path, \"housing.csv\") return pd.read_csv(csv_path)", "words": [{"w": "def", "b": [0.1766, 0.1138, 0.2019, 0.1266]}, {"w": "load_housing_data(housing_path=HOUSING_PATH):", "b": [0.2103, 0.1138, 0.5898, 0.1266]}, {"w": "csv_path", "b": [0.2103, 0.1292, 0.2778, 0.142]}, {"w": "=", "b": [0.2862, 0.1292, 0.2946, 0.142]}, {"w": "os.path.join(housing_path,", "b": [0.3031, 0.1292, 0.5223, 0.142]}, {"w": "\"housing.csv\")", "b": [0.5308, 0.1292, 0.6488, 0.142]}, {"w": "return", "b": [0.2103, 0.1446, 0.2609, 0.1574]}, {"w": "pd.read_csv(csv_path)", "b": [0.2693, 0.1446, 0.4464, 0.1574]}]}, {"id": "b_2", "type": "paragraph", "text": "This function returns a Pandas DataFrame object containing all the data.", "words": [{"w": "This", "b": [0.1429, 0.1652, 0.1801, 0.1866]}, {"w": "function", "b": [0.1848, 0.1652, 0.2562, 0.1866]}, {"w": "returns", "b": [0.2609, 0.1652, 0.3217, 0.1866]}, {"w": "a", "b": [0.3264, 0.1652, 0.3356, 0.1866]}, {"w": "Pandas", "b": [0.3403, 0.1652, 0.3999, 0.1866]}, {"w": "DataFrame", "b": [0.4046, 0.1652, 0.498, 0.1866]}, {"w": "object", "b": [0.5027, 0.1652, 0.5533, 0.1866]}, {"w": "containing", "b": [0.558, 0.1652, 0.6477, 0.1866]}, {"w": "all", "b": [0.6524, 0.1652, 0.6721, 0.1866]}, {"w": "the", "b": [0.6768, 0.1652, 0.7032, 0.1866]}, {"w": "data.", "b": [0.7079, 0.1652, 0.7479, 0.1866]}]}, {"id": "b_3", "type": "paragraph", "text": "Take a Quick Look at the Data Structure", "words": [{"w": "Take", "b": [0.1429, 0.1994, 0.1914, 0.228]}, {"w": "a", "b": [0.1964, 0.1994, 0.2088, 0.228]}, {"w": "Quick", "b": [0.2137, 0.1994, 0.2699, 0.228]}, {"w": "Look", "b": [0.2749, 0.1994, 0.324, 0.228]}, {"w": "at", "b": [0.329, 0.1994, 0.3503, 0.228]}, {"w": "the", "b": [0.3552, 0.1994, 0.3901, 0.228]}, {"w": "Data", "b": [0.395, 0.1994, 0.4435, 0.228]}, {"w": "Structure", "b": [0.4484, 0.1994, 0.5442, 0.228]}]}, {"id": "b_4", "type": "paragraph", "text": "Let’s take a look at the top five rows using the DataFrame’s head() method (see Figure 2-5).", "words": [{"w": "Let’s", "b": [0.1428, 0.2348, 0.179, 0.2562]}, {"w": "take", "b": [0.188, 0.2348, 0.2227, 0.2562]}, {"w": "a", "b": [0.2318, 0.2348, 0.2409, 0.2562]}, {"w": "look", "b": [0.2499, 0.2348, 0.2868, 0.2562]}, {"w": "at", "b": [0.2958, 0.2348, 0.3109, 0.2562]}, {"w": "the", "b": [0.3199, 0.2348, 0.3463, 0.2562]}, {"w": "top", "b": [0.3553, 0.2348, 0.3832, 0.2562]}, {"w": "five", "b": [0.3922, 0.2348, 0.4225, 0.2562]}, {"w": "rows", "b": [0.4315, 0.2348, 0.4718, 0.2562]}, {"w": "using", "b": [0.4808, 0.2348, 0.5262, 0.2562]}, {"w": "the", "b": [0.5353, 0.2348, 0.5616, 0.2562]}, {"w": "DataFrame’s", "b": [0.5706, 0.2348, 0.6731, 0.2562]}, {"w": "head()", "b": [0.6821, 0.238, 0.7415, 0.253]}, {"w": "method", "b": [0.7505, 0.2348, 0.8156, 0.2562]}, {"w": "(see", "b": [0.8246, 0.2348, 0.8572, 0.2562]}, {"w": "Figure", "b": [0.1429, 0.2538, 0.1969, 0.2752]}, {"w": "2-5).", "b": [0.2016, 0.2538, 0.241, 0.2752]}]}, {"id": "b_5", "type": "equation", "text": "Figure 2-5. Top five rows in the dataset", "words": [{"w": "Figure", "b": [0.1429, 0.4898, 0.1943, 0.5114]}, {"w": "2-5.", "b": [0.1991, 0.4898, 0.2308, 0.5114]}, {"w": "Top", "b": [0.2356, 0.4898, 0.2658, 0.5114]}, {"w": "five", "b": [0.2706, 0.4898, 0.2993, 0.5114]}, {"w": "rows", "b": [0.3041, 0.4898, 0.3418, 0.5114]}, {"w": "in", "b": [0.3466, 0.4898, 0.3631, 0.5114]}, {"w": "the", "b": [0.3679, 0.4898, 0.3929, 0.5114]}, {"w": "dataset", "b": [0.3977, 0.4898, 0.456, 0.5114]}]}, {"id": "b_6", "type": "paragraph", "text": "Each row represents one district. There are 10 attributes (you can see the first 6 in the screenshot): longitude, latitude, housing_median_age, total_rooms, total_bed rooms, population, households, median_income, median_house_value, and ocean_proximity.", "words": [{"w": "Each", "b": [0.1429, 0.5272, 0.1838, 0.5486]}, {"w": "row", "b": [0.1888, 0.5272, 0.2214, 0.5486]}, {"w": "represents", "b": [0.2264, 0.5272, 0.312, 0.5486]}, {"w": "one", "b": [0.3169, 0.5272, 0.3478, 0.5486]}, {"w": "district.", "b": [0.3528, 0.5272, 0.4166, 0.5486]}, {"w": "There", "b": [0.4216, 0.5272, 0.471, 0.5486]}, {"w": "are", "b": [0.476, 0.5272, 0.5017, 0.5486]}, {"w": "10", "b": [0.5067, 0.5272, 0.5267, 0.5486]}, {"w": "attributes", "b": [0.5317, 0.5272, 0.611, 0.5486]}, {"w": "(you", "b": [0.616, 0.5272, 0.6544, 0.5486]}, {"w": "can", "b": [0.6594, 0.5272, 0.6888, 0.5486]}, {"w": "see", "b": [0.6937, 0.5272, 0.7191, 0.5486]}, {"w": "the", "b": [0.7241, 0.5272, 0.7504, 0.5486]}, {"w": "first", "b": [0.7554, 0.5272, 0.7889, 0.5486]}, {"w": "6", "b": [0.7939, 0.5272, 0.8039, 0.5486]}, {"w": "in", "b": [0.8088, 0.5272, 0.8258, 0.5486]}, {"w": "the", "b": [0.8308, 0.5272, 0.8571, 0.5486]}, {"w": "screenshot):", "b": [0.1429, 0.5472, 0.2439, 0.5686]}, {"w": "longitude,", "b": [0.253, 0.5472, 0.3468, 0.5686]}, {"w": "latitude,", "b": [0.356, 0.5472, 0.4399, 0.5686]}, {"w": "housing_median_age,", "b": [0.4491, 0.5472, 0.6319, 0.5686]}, {"w": "total_rooms,", "b": [0.6411, 0.5472, 0.7547, 0.5686]}, {"w": "total_bed", "b": [0.7639, 0.5503, 0.8529, 0.5654]}, {"w": "rooms,", "b": [0.1429, 0.5671, 0.1971, 0.5885]}, {"w": "population,", "b": [0.2181, 0.5671, 0.3218, 0.5885]}, {"w": "households,", "b": [0.3427, 0.5671, 0.4464, 0.5885]}, {"w": "median_income,", "b": [0.4674, 0.5671, 0.6008, 0.5885]}, {"w": "median_house_value,", "b": [0.6218, 0.5671, 0.8046, 0.5885]}, {"w": "and", "b": [0.8256, 0.5671, 0.8572, 0.5885]}, {"w": "ocean_proximity.", "b": [0.1428, 0.5871, 0.296, 0.6085]}]}, {"id": "b_7", "type": "paragraph", "text": "The info() method is useful to get a quick description of the data, in particular the total number of rows, and each attribute’s type and number of non-null values (see Figure 2-6).", "words": [{"w": "The", "b": [0.1428, 0.6161, 0.1757, 0.6375]}, {"w": "info()", "b": [0.1819, 0.6192, 0.2413, 0.6343]}, {"w": "method", "b": [0.2475, 0.6161, 0.3126, 0.6375]}, {"w": "is", "b": [0.3188, 0.6161, 0.332, 0.6375]}, {"w": "useful", "b": [0.3383, 0.6161, 0.3883, 0.6375]}, {"w": "to", "b": [0.3946, 0.6161, 0.4115, 0.6375]}, {"w": "get", "b": [0.4178, 0.6161, 0.4427, 0.6375]}, {"w": "a", "b": [0.449, 0.6161, 0.4581, 0.6375]}, {"w": "quick", "b": [0.4644, 0.6161, 0.5108, 0.6375]}, {"w": "description", "b": [0.517, 0.6161, 0.6115, 0.6375]}, {"w": "of", "b": [0.6178, 0.6161, 0.6346, 0.6375]}, {"w": "the", "b": [0.6408, 0.6161, 0.6671, 0.6375]}, {"w": "data,", "b": [0.6734, 0.6161, 0.7134, 0.6375]}, {"w": "in", "b": [0.7196, 0.6161, 0.7366, 0.6375]}, {"w": "particular", "b": [0.7428, 0.6161, 0.8246, 0.6375]}, {"w": "the", "b": [0.8308, 0.6161, 0.8571, 0.6375]}, {"w": "total", "b": [0.1429, 0.6351, 0.1806, 0.6565]}, {"w": "number", "b": [0.1876, 0.6351, 0.2539, 0.6565]}, {"w": "of", "b": [0.2608, 0.6351, 0.2776, 0.6565]}, {"w": "rows,", "b": [0.2845, 0.6351, 0.3296, 0.6565]}, {"w": "and", "b": [0.3365, 0.6351, 0.368, 0.6565]}, {"w": "each", "b": [0.375, 0.6351, 0.4129, 0.6565]}, {"w": "attribute’s", "b": [0.4199, 0.6351, 0.5006, 0.6565]}, {"w": "type", "b": [0.5075, 0.6351, 0.5432, 0.6565]}, {"w": "and", "b": [0.5502, 0.6351, 0.5817, 0.6565]}, {"w": "number", "b": [0.5887, 0.6351, 0.655, 0.6565]}, {"w": "of", "b": [0.6619, 0.6351, 0.6787, 0.6565]}, {"w": "non-null", "b": [0.6856, 0.6351, 0.7591, 0.6565]}, {"w": "values", "b": [0.766, 0.6351, 0.8176, 0.6565]}, {"w": "(see", "b": [0.8246, 0.6351, 0.8572, 0.6565]}, {"w": "Figure", "b": [0.1429, 0.6542, 0.1969, 0.6756]}, {"w": "2-6).", "b": [0.2016, 0.6542, 0.241, 0.6756]}]}, {"id": "b_8", "type": "equation", "text": "50 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "50", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 77, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 2-6. Housing info", "words": [{"w": "Figure", "b": [0.1429, 0.3329, 0.1943, 0.3545]}, {"w": "2-6.", "b": [0.1991, 0.3329, 0.2308, 0.3545]}, {"w": "Housing", "b": [0.2356, 0.3329, 0.3029, 0.3545]}, {"w": "info", "b": [0.3077, 0.3329, 0.3392, 0.3545]}]}, {"id": "b_1", "type": "paragraph", "text": "There are 20,640 instances in the dataset, which means that it is fairly small by Machine Learning standards, but it’s perfect to get started. Notice that the total_bed rooms attribute has only 20,433 non-null values, meaning that 207 districts are miss‐ ing this feature. We will need to take care of this later.", "words": [{"w": "There", "b": [0.1429, 0.3703, 0.1923, 0.3917]}, {"w": "are", "b": [0.2016, 0.3703, 0.2273, 0.3917]}, {"w": "20,640", "b": [0.2367, 0.3703, 0.2914, 0.3917]}, {"w": "instances", "b": [0.3007, 0.3703, 0.3776, 0.3917]}, {"w": "in", "b": [0.3869, 0.3703, 0.4039, 0.3917]}, {"w": "the", "b": [0.4132, 0.3703, 0.4395, 0.3917]}, {"w": "dataset,", "b": [0.4489, 0.3703, 0.5117, 0.3917]}, {"w": "which", "b": [0.5211, 0.3703, 0.572, 0.3917]}, {"w": "means", "b": [0.5813, 0.3703, 0.6354, 0.3917]}, {"w": "that", "b": [0.6447, 0.3703, 0.6773, 0.3917]}, {"w": "it", "b": [0.6867, 0.3703, 0.6986, 0.3917]}, {"w": "is", "b": [0.7079, 0.3703, 0.7212, 0.3917]}, {"w": "fairly", "b": [0.7305, 0.3703, 0.7739, 0.3917]}, {"w": "small", "b": [0.7833, 0.3703, 0.8277, 0.3917]}, {"w": "by", "b": [0.837, 0.3703, 0.8571, 0.3917]}, {"w": "Machine", "b": [0.1429, 0.3902, 0.216, 0.4116]}, {"w": "Learning", "b": [0.2214, 0.3902, 0.2965, 0.4116]}, {"w": "standards,", "b": [0.3019, 0.3902, 0.3877, 0.4116]}, {"w": "but", "b": [0.3932, 0.3902, 0.4212, 0.4116]}, {"w": "it’s", "b": [0.4266, 0.3902, 0.4483, 0.4116]}, {"w": "perfect", "b": [0.4537, 0.3902, 0.5114, 0.4116]}, {"w": "to", "b": [0.5169, 0.3902, 0.5339, 0.4116]}, {"w": "get", "b": [0.5393, 0.3902, 0.5643, 0.4116]}, {"w": "started.", "b": [0.5697, 0.3902, 0.6315, 0.4116]}, {"w": "Notice", "b": [0.637, 0.3902, 0.6922, 0.4116]}, {"w": "that", "b": [0.6976, 0.3902, 0.7302, 0.4116]}, {"w": "the", "b": [0.7356, 0.3902, 0.762, 0.4116]}, {"w": "total_bed", "b": [0.7674, 0.3934, 0.8565, 0.4085]}, {"w": "rooms", "b": [0.1429, 0.4134, 0.1923, 0.4284]}, {"w": "attribute", "b": [0.1982, 0.4102, 0.2698, 0.4316]}, {"w": "has", "b": [0.2757, 0.4102, 0.3036, 0.4316]}, {"w": "only", "b": [0.3094, 0.4102, 0.3463, 0.4316]}, {"w": "20,433", "b": [0.3522, 0.4102, 0.4069, 0.4316]}, {"w": "non-null", "b": [0.4128, 0.4102, 0.4862, 0.4316]}, {"w": "values,", "b": [0.4921, 0.4102, 0.5484, 0.4316]}, {"w": "meaning", "b": [0.5543, 0.4102, 0.6275, 0.4316]}, {"w": "that", "b": [0.6333, 0.4102, 0.6659, 0.4316]}, {"w": "207", "b": [0.6718, 0.4102, 0.7018, 0.4316]}, {"w": "districts", "b": [0.7076, 0.4102, 0.7743, 0.4316]}, {"w": "are", "b": [0.7802, 0.4102, 0.8059, 0.4316]}, {"w": "miss‐", "b": [0.8118, 0.4102, 0.8571, 0.4316]}, {"w": "ing", "b": [0.1429, 0.4292, 0.1696, 0.4506]}, {"w": "this", "b": [0.1743, 0.4292, 0.205, 0.4506]}, {"w": "feature.", "b": [0.2098, 0.4292, 0.2723, 0.4506]}, {"w": "We", "b": [0.277, 0.4292, 0.3041, 0.4506]}, {"w": "will", "b": [0.3088, 0.4292, 0.3392, 0.4506]}, {"w": "need", "b": [0.3439, 0.4292, 0.384, 0.4506]}, {"w": "to", "b": [0.3888, 0.4292, 0.4057, 0.4506]}, {"w": "take", "b": [0.4105, 0.4292, 0.4452, 0.4506]}, {"w": "care", "b": [0.4499, 0.4292, 0.4844, 0.4506]}, {"w": "of", "b": [0.4892, 0.4292, 0.5059, 0.4506]}, {"w": "this", "b": [0.5107, 0.4292, 0.5414, 0.4506]}, {"w": "later.", "b": [0.5461, 0.4292, 0.5865, 0.4506]}]}, {"id": "b_2", "type": "paragraph", "text": "All attributes are numerical, except the ocean_proximity field. Its type is object, so it could hold any kind of Python object, but since you loaded this data from a CSV file you know that it must be a text attribute. When you looked at the top five rows, you probably noticed that the values in the ocean_proximity column were repetitive, which means that it is probably a categorical attribute. You can find out what cate‐ gories exist and how many districts belong to each category by using the value_counts() method:", "words": [{"w": "All", "b": [0.1429, 0.4582, 0.1678, 0.4797]}, {"w": "attributes", "b": [0.1725, 0.4582, 0.2518, 0.4797]}, {"w": "are", "b": [0.2565, 0.4582, 0.2823, 0.4797]}, {"w": "numerical,", "b": [0.287, 0.4582, 0.3763, 0.4797]}, {"w": "except", "b": [0.381, 0.4582, 0.4346, 0.4797]}, {"w": "the", "b": [0.4393, 0.4582, 0.4657, 0.4797]}, {"w": "ocean_proximity", "b": [0.4704, 0.4614, 0.6188, 0.4765]}, {"w": "field.", "b": [0.6236, 0.4582, 0.6652, 0.4797]}, {"w": "Its", "b": [0.6699, 0.4582, 0.6902, 0.4797]}, {"w": "type", "b": [0.6949, 0.4582, 0.7306, 0.4797]}, {"w": "is", "b": [0.7354, 0.4582, 0.7486, 0.4797]}, {"w": "object,", "b": [0.7533, 0.4582, 0.8175, 0.4797]}, {"w": "so", "b": [0.8222, 0.4582, 0.8405, 0.4797]}, {"w": "it", "b": [0.8452, 0.4582, 0.8571, 0.4797]}, {"w": "could", "b": [0.1429, 0.4773, 0.1896, 0.4987]}, {"w": "hold", "b": [0.1953, 0.4773, 0.2333, 0.4987]}, {"w": "any", "b": [0.2389, 0.4773, 0.2686, 0.4987]}, {"w": "kind", "b": [0.2742, 0.4773, 0.3125, 0.4987]}, {"w": "of", "b": [0.3182, 0.4773, 0.335, 0.4987]}, {"w": "Python", "b": [0.3406, 0.4773, 0.4014, 0.4987]}, {"w": "object,", "b": [0.407, 0.4773, 0.4623, 0.4987]}, {"w": "but", "b": [0.468, 0.4773, 0.496, 0.4987]}, {"w": "since", "b": [0.5016, 0.4773, 0.5439, 0.4987]}, {"w": "you", "b": [0.5496, 0.4773, 0.5808, 0.4987]}, {"w": "loaded", "b": [0.5865, 0.4773, 0.6424, 0.4987]}, {"w": "this", "b": [0.648, 0.4773, 0.6787, 0.4987]}, {"w": "data", "b": [0.6843, 0.4773, 0.7196, 0.4987]}, {"w": "from", "b": [0.7252, 0.4773, 0.7668, 0.4987]}, {"w": "a", "b": [0.7725, 0.4773, 0.7816, 0.4987]}, {"w": "CSV", "b": [0.7873, 0.4773, 0.8256, 0.4987]}, {"w": "file", "b": [0.8313, 0.4773, 0.8571, 0.4987]}, {"w": "you", "b": [0.1429, 0.4963, 0.1741, 0.5177]}, {"w": "know", "b": [0.1799, 0.4963, 0.2265, 0.5177]}, {"w": "that", "b": [0.2323, 0.4963, 0.2649, 0.5177]}, {"w": "it", "b": [0.2707, 0.4963, 0.2826, 0.5177]}, {"w": "must", "b": [0.2884, 0.4963, 0.3301, 0.5177]}, {"w": "be", "b": [0.3359, 0.4963, 0.3554, 0.5177]}, {"w": "a", "b": [0.3611, 0.4963, 0.3703, 0.5177]}, {"w": "text", "b": [0.3761, 0.4963, 0.4075, 0.5177]}, {"w": "attribute.", "b": [0.4133, 0.4963, 0.4896, 0.5177]}, {"w": "When", "b": [0.4954, 0.4963, 0.547, 0.5177]}, {"w": "you", "b": [0.5528, 0.4963, 0.5841, 0.5177]}, {"w": "looked", "b": [0.5899, 0.4963, 0.6466, 0.5177]}, {"w": "at", "b": [0.6524, 0.4963, 0.6675, 0.5177]}, {"w": "the", "b": [0.6732, 0.4963, 0.6996, 0.5177]}, {"w": "top", "b": [0.7054, 0.4963, 0.7333, 0.5177]}, {"w": "five", "b": [0.739, 0.4963, 0.7693, 0.5177]}, {"w": "rows,", "b": [0.7751, 0.4963, 0.8201, 0.5177]}, {"w": "you", "b": [0.8259, 0.4963, 0.8571, 0.5177]}, {"w": "probably", "b": [0.1429, 0.5163, 0.2173, 0.5377]}, {"w": "noticed", "b": [0.226, 0.5163, 0.2886, 0.5377]}, {"w": "that", "b": [0.2974, 0.5163, 0.33, 0.5377]}, {"w": "the", "b": [0.3387, 0.5163, 0.3651, 0.5377]}, {"w": "values", "b": [0.3738, 0.5163, 0.4254, 0.5377]}, {"w": "in", "b": [0.4342, 0.5163, 0.4512, 0.5377]}, {"w": "the", "b": [0.4599, 0.5163, 0.4863, 0.5377]}, {"w": "ocean_proximity", "b": [0.495, 0.5195, 0.6435, 0.5345]}, {"w": "column", "b": [0.6522, 0.5163, 0.7164, 0.5377]}, {"w": "were", "b": [0.7252, 0.5163, 0.7649, 0.5377]}, {"w": "repetitive,", "b": [0.7737, 0.5163, 0.8571, 0.5377]}, {"w": "which", "b": [0.1428, 0.5353, 0.1938, 0.5567]}, {"w": "means", "b": [0.2007, 0.5353, 0.2548, 0.5567]}, {"w": "that", "b": [0.2618, 0.5353, 0.2944, 0.5567]}, {"w": "it", "b": [0.3013, 0.5353, 0.3132, 0.5567]}, {"w": "is", "b": [0.3202, 0.5353, 0.3334, 0.5567]}, {"w": "probably", "b": [0.3404, 0.5353, 0.4148, 0.5567]}, {"w": "a", "b": [0.4217, 0.5353, 0.4309, 0.5567]}, {"w": "categorical", "b": [0.4378, 0.5353, 0.5275, 0.5567]}, {"w": "attribute.", "b": [0.5345, 0.5353, 0.6108, 0.5567]}, {"w": "You", "b": [0.6178, 0.5353, 0.6502, 0.5567]}, {"w": "can", "b": [0.6571, 0.5353, 0.6865, 0.5567]}, {"w": "find", "b": [0.6934, 0.5353, 0.7276, 0.5567]}, {"w": "out", "b": [0.7345, 0.5353, 0.7625, 0.5567]}, {"w": "what", "b": [0.7695, 0.5353, 0.81, 0.5567]}, {"w": "cate‐", "b": [0.8169, 0.5353, 0.8571, 0.5567]}, {"w": "gories", "b": [0.1429, 0.5544, 0.193, 0.5758]}, {"w": "exist", "b": [0.2073, 0.5544, 0.2455, 0.5758]}, {"w": "and", "b": [0.2597, 0.5544, 0.2913, 0.5758]}, {"w": "how", "b": [0.3055, 0.5544, 0.3415, 0.5758]}, {"w": "many", "b": [0.3557, 0.5544, 0.4024, 0.5758]}, {"w": "districts", "b": [0.4166, 0.5544, 0.4833, 0.5758]}, {"w": "belong", "b": [0.4975, 0.5544, 0.554, 0.5758]}, {"w": "to", "b": [0.5682, 0.5544, 0.5852, 0.5758]}, {"w": "each", "b": [0.5994, 0.5544, 0.6374, 0.5758]}, {"w": "category", "b": [0.6516, 0.5544, 0.7226, 0.5758]}, {"w": "by", "b": [0.7368, 0.5544, 0.757, 0.5758]}, {"w": "using", "b": [0.7712, 0.5544, 0.8166, 0.5758]}, {"w": "the", "b": [0.8308, 0.5544, 0.8571, 0.5758]}, {"w": "value_counts()", "b": [0.1428, 0.5775, 0.2814, 0.5926]}, {"w": "method:", "b": [0.2861, 0.5743, 0.3559, 0.5957]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> housing[\"ocean_proximity\"].value_counts() <1H OCEAN 9136 INLAND 6551 NEAR OCEAN 2658 NEAR BAY 2290 ISLAND 5 Name: ocean_proximity, dtype: int64", "words": [{"w": ">>>", "b": [0.1766, 0.6063, 0.2019, 0.6191]}, {"w": "housing[\"ocean_proximity\"].value_counts()", "b": [0.2103, 0.6063, 0.556, 0.6191]}, {"w": "<1H", "b": [0.1766, 0.6217, 0.2019, 0.6346]}, {"w": "OCEAN", "b": [0.2103, 0.6217, 0.2525, 0.6346]}, {"w": "9136", "b": [0.2946, 0.6217, 0.3284, 0.6346]}, {"w": "INLAND", "b": [0.1766, 0.6371, 0.2272, 0.65]}, {"w": "6551", "b": [0.2946, 0.6371, 0.3284, 0.65]}, {"w": "NEAR", "b": [0.1766, 0.6526, 0.2103, 0.6654]}, {"w": "OCEAN", "b": [0.2187, 0.6526, 0.2609, 0.6654]}, {"w": "2658", "b": [0.2946, 0.6526, 0.3284, 0.6654]}, {"w": "NEAR", "b": [0.1766, 0.668, 0.2103, 0.6808]}, {"w": "BAY", "b": [0.2187, 0.668, 0.244, 0.6808]}, {"w": "2290", "b": [0.2946, 0.668, 0.3284, 0.6808]}, {"w": "ISLAND", "b": [0.1766, 0.6834, 0.2272, 0.6962]}, {"w": "5", "b": [0.3199, 0.6834, 0.3284, 0.6962]}, {"w": "Name:", "b": [0.1766, 0.6988, 0.2187, 0.7117]}, {"w": "ocean_proximity,", "b": [0.2272, 0.6988, 0.3621, 0.7117]}, {"w": "dtype:", "b": [0.3705, 0.6988, 0.4211, 0.7117]}, {"w": "int64", "b": [0.4296, 0.6988, 0.4717, 0.7117]}]}, {"id": "b_4", "type": "paragraph", "text": "Let’s look at the other fields. The describe() method shows a summary of the numerical attributes (Figure 2-7).", "words": [{"w": "Let’s", "b": [0.1429, 0.7203, 0.179, 0.7418]}, {"w": "look", "b": [0.1887, 0.7203, 0.2255, 0.7418]}, {"w": "at", "b": [0.2352, 0.7203, 0.2503, 0.7418]}, {"w": "the", "b": [0.26, 0.7203, 0.2863, 0.7418]}, {"w": "other", "b": [0.296, 0.7203, 0.3407, 0.7418]}, {"w": "fields.", "b": [0.3503, 0.7203, 0.3996, 0.7418]}, {"w": "The", "b": [0.4092, 0.7203, 0.4421, 0.7418]}, {"w": "describe()", "b": [0.4517, 0.7235, 0.5507, 0.7386]}, {"w": "method", "b": [0.5604, 0.7203, 0.6254, 0.7418]}, {"w": "shows", "b": [0.635, 0.7203, 0.6864, 0.7418]}, {"w": "a", "b": [0.696, 0.7203, 0.7052, 0.7418]}, {"w": "summary", "b": [0.7148, 0.7203, 0.7947, 0.7418]}, {"w": "of", "b": [0.8044, 0.7203, 0.8212, 0.7418]}, {"w": "the", "b": [0.8308, 0.7203, 0.8571, 0.7418]}, {"w": "numerical", "b": [0.1429, 0.7394, 0.2274, 0.7608]}, {"w": "attributes", "b": [0.2321, 0.7394, 0.3114, 0.7608]}, {"w": "(Figure", "b": [0.3161, 0.7394, 0.3773, 0.7608]}, {"w": "2-7).", "b": [0.382, 0.7394, 0.4214, 0.7608]}]}, {"id": "b_5", "type": "paragraph", "text": "Get the Data | 51", "words": [{"w": "Get", "b": [0.7296, 0.9225, 0.7499, 0.9388]}, {"w": "the", "b": [0.7527, 0.9225, 0.7726, 0.9388]}, {"w": "Data", "b": [0.7755, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "51", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 78, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "12 The standard deviation is generally denoted σ (the Greek letter sigma), and it is the square root of the var‐ iance, which is the average of the squared deviation from the mean. When a feature has a bell-shaped normal distribution (also called a Gaussian distribution), which is very common, the “68-95-99.7” rule applies: about 68% of the values fall within 1σ of the mean, 95% within 2σ, and 99.7% within 3σ.", "words": [{"w": "12", "b": [0.1385, 0.8311, 0.1518, 0.8453]}, {"w": "The", "b": [0.1587, 0.8296, 0.1837, 0.8459]}, {"w": "standard", "b": [0.1873, 0.8296, 0.2433, 0.8459]}, {"w": "deviation", "b": [0.2469, 0.8296, 0.3062, 0.8459]}, {"w": "is", "b": [0.3098, 0.8296, 0.3198, 0.8459]}, {"w": "generally", "b": [0.3234, 0.8296, 0.3812, 0.8459]}, {"w": "denoted", "b": [0.3848, 0.8296, 0.4367, 0.8459]}, {"w": "σ", "b": [0.4403, 0.8296, 0.4485, 0.8459]}, {"w": "(the", "b": [0.4521, 0.8296, 0.4776, 0.8459]}, {"w": "Greek", "b": [0.4812, 0.8296, 0.5198, 0.8459]}, {"w": "letter", "b": [0.5234, 0.8296, 0.5565, 0.8459]}, {"w": "sigma),", "b": [0.5601, 0.8296, 0.6067, 0.8459]}, {"w": "and", "b": [0.6103, 0.8296, 0.6343, 0.8459]}, {"w": "it", "b": [0.638, 0.8296, 0.647, 0.8459]}, {"w": "is", "b": [0.6507, 0.8296, 0.6607, 0.8459]}, {"w": "the", "b": [0.6643, 0.8296, 0.6844, 0.8459]}, {"w": "square", "b": [0.688, 0.8296, 0.73, 0.8459]}, {"w": "root", "b": [0.7336, 0.8296, 0.7605, 0.8459]}, {"w": "of", "b": [0.7641, 0.8296, 0.7769, 0.8459]}, {"w": "the", "b": [0.7805, 0.8296, 0.8006, 0.8459]}, {"w": "var‐", "b": [0.8042, 0.8294, 0.8298, 0.8459]}, {"w": "iance,", "b": [0.1587, 0.8445, 0.1948, 0.861]}, {"w": "which", "b": [0.1984, 0.8447, 0.2372, 0.861]}, {"w": "is", "b": [0.2408, 0.8447, 0.2509, 0.861]}, {"w": "the", "b": [0.2545, 0.8447, 0.2745, 0.861]}, {"w": "average", "b": [0.2781, 0.8447, 0.3259, 0.861]}, {"w": "of", "b": [0.3295, 0.8447, 0.3423, 0.861]}, {"w": "the", "b": [0.3459, 0.8447, 0.366, 0.861]}, {"w": "squared", "b": [0.3696, 0.8447, 0.42, 0.861]}, {"w": "deviation", "b": [0.4236, 0.8447, 0.4828, 0.861]}, {"w": "from", "b": [0.4864, 0.8447, 0.5181, 0.861]}, {"w": "the", "b": [0.5217, 0.8447, 0.5418, 0.861]}, {"w": "mean.", "b": [0.5454, 0.8447, 0.5844, 0.861]}, {"w": "When", "b": [0.588, 0.8447, 0.6273, 0.861]}, {"w": "a", "b": [0.6309, 0.8447, 0.6379, 0.861]}, {"w": "feature", "b": [0.6415, 0.8447, 0.6855, 0.861]}, {"w": "has", "b": [0.6891, 0.8447, 0.7104, 0.861]}, {"w": "a", "b": [0.714, 0.8447, 0.721, 0.861]}, {"w": "bell-shaped", "b": [0.7246, 0.8447, 0.7975, 0.861]}, {"w": "normal", "b": [0.8011, 0.8445, 0.8466, 0.861]}, {"w": "distribution", "b": [0.1587, 0.8596, 0.2315, 0.8761]}, {"w": "(also", "b": [0.2351, 0.8598, 0.2655, 0.8761]}, {"w": "called", "b": [0.2691, 0.8598, 0.306, 0.8761]}, {"w": "a", "b": [0.3096, 0.8598, 0.3165, 0.8761]}, {"w": "Gaussian", "b": [0.3201, 0.8596, 0.3777, 0.8761]}, {"w": "distribution),", "b": [0.3813, 0.8596, 0.4632, 0.8761]}, {"w": "which", "b": [0.4668, 0.8598, 0.5056, 0.8761]}, {"w": "is", "b": [0.5092, 0.8598, 0.5193, 0.8761]}, {"w": "very", "b": [0.5229, 0.8598, 0.5506, 0.8761]}, {"w": "common,", "b": [0.5542, 0.8598, 0.6154, 0.8761]}, {"w": "the", "b": [0.619, 0.8598, 0.6391, 0.8761]}, {"w": "“68-95-99.7”", "b": [0.6427, 0.8598, 0.7236, 0.8761]}, {"w": "rule", "b": [0.7272, 0.8598, 0.7523, 0.8761]}, {"w": "applies:", "b": [0.7559, 0.8598, 0.8037, 0.8761]}, {"w": "about", "b": [0.8073, 0.8598, 0.8437, 0.8761]}, {"w": "68%", "b": [0.1587, 0.8749, 0.186, 0.8912]}, {"w": "of", "b": [0.1896, 0.8749, 0.2024, 0.8912]}, {"w": "the", "b": [0.206, 0.8749, 0.226, 0.8912]}, {"w": "values", "b": [0.2296, 0.8749, 0.269, 0.8912]}, {"w": "fall", "b": [0.2726, 0.8749, 0.2923, 0.8912]}, {"w": "within", "b": [0.2959, 0.8749, 0.3373, 0.8912]}, {"w": "1σ", "b": [0.3409, 0.8749, 0.3567, 0.8912]}, {"w": "of", "b": [0.3603, 0.8749, 0.373, 0.8912]}, {"w": "the", "b": [0.3767, 0.8749, 0.3967, 0.8912]}, {"w": "mean,", "b": [0.4003, 0.8749, 0.4393, 0.8912]}, {"w": "95%", "b": [0.4429, 0.8749, 0.4702, 0.8912]}, {"w": "within", "b": [0.4738, 0.8749, 0.5152, 0.8912]}, {"w": "2σ,", "b": [0.5188, 0.8749, 0.5382, 0.8912]}, {"w": "and", "b": [0.5418, 0.8749, 0.5658, 0.8912]}, {"w": "99.7%", "b": [0.5694, 0.8749, 0.6079, 0.8912]}, {"w": "within", "b": [0.6115, 0.8749, 0.6529, 0.8912]}, {"w": "3σ.", "b": [0.6565, 0.8749, 0.6759, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 2-7. Summary of each numerical attribute", "words": [{"w": "Figure", "b": [0.1428, 0.339, 0.1943, 0.3606]}, {"w": "2-7.", "b": [0.1991, 0.339, 0.2308, 0.3606]}, {"w": "Summary", "b": [0.2356, 0.339, 0.3153, 0.3606]}, {"w": "of", "b": [0.3201, 0.339, 0.3353, 0.3606]}, {"w": "each", "b": [0.34, 0.339, 0.3767, 0.3606]}, {"w": "numerical", "b": [0.3814, 0.339, 0.464, 0.3606]}, {"w": "attribute", "b": [0.4687, 0.339, 0.5396, 0.3606]}]}, {"id": "b_2", "type": "paragraph", "text": "The count, mean, min, and max rows are self-explanatory. Note that the null values are ignored (so, for example, count of total_bedrooms is 20,433, not 20,640). The std row shows the standard deviation, which measures how dispersed the values are.12", "words": [{"w": "The", "b": [0.1428, 0.3773, 0.1757, 0.3987]}, {"w": "count,", "b": [0.181, 0.3773, 0.2352, 0.3987]}, {"w": "mean,", "b": [0.2405, 0.3773, 0.2848, 0.3987]}, {"w": "min,", "b": [0.2901, 0.3773, 0.3245, 0.3987]}, {"w": "and", "b": [0.3298, 0.3773, 0.3614, 0.3987]}, {"w": "max", "b": [0.3666, 0.3804, 0.3963, 0.3955]}, {"w": "rows", "b": [0.4016, 0.3773, 0.4419, 0.3987]}, {"w": "are", "b": [0.4472, 0.3773, 0.4729, 0.3987]}, {"w": "self-explanatory.", "b": [0.4782, 0.3773, 0.6158, 0.3987]}, {"w": "Note", "b": [0.6211, 0.3773, 0.6619, 0.3987]}, {"w": "that", "b": [0.6672, 0.3773, 0.6997, 0.3987]}, {"w": "the", "b": [0.705, 0.3773, 0.7314, 0.3987]}, {"w": "null", "b": [0.7366, 0.3773, 0.7692, 0.3987]}, {"w": "values", "b": [0.7745, 0.3773, 0.8261, 0.3987]}, {"w": "are", "b": [0.8314, 0.3773, 0.8572, 0.3987]}, {"w": "ignored", "b": [0.1429, 0.3972, 0.2078, 0.4186]}, {"w": "(so,", "b": [0.2149, 0.3972, 0.2446, 0.4186]}, {"w": "for", "b": [0.2517, 0.3972, 0.2762, 0.4186]}, {"w": "example,", "b": [0.2834, 0.3972, 0.3577, 0.4186]}, {"w": "count", "b": [0.3648, 0.4004, 0.4143, 0.4155]}, {"w": "of", "b": [0.4214, 0.3972, 0.4382, 0.4186]}, {"w": "total_bedrooms", "b": [0.4454, 0.4004, 0.5839, 0.4155]}, {"w": "is", "b": [0.5911, 0.3972, 0.6043, 0.4186]}, {"w": "20,433,", "b": [0.6115, 0.3972, 0.671, 0.4186]}, {"w": "not", "b": [0.6781, 0.3972, 0.7065, 0.4186]}, {"w": "20,640).", "b": [0.7136, 0.3972, 0.7803, 0.4186]}, {"w": "The", "b": [0.7875, 0.3972, 0.8203, 0.4186]}, {"w": "std", "b": [0.8275, 0.4004, 0.8571, 0.4155]}, {"w": "row", "b": [0.1429, 0.4162, 0.1755, 0.4377]}, {"w": "shows", "b": [0.1834, 0.4162, 0.2347, 0.4377]}, {"w": "the", "b": [0.2426, 0.4162, 0.2689, 0.4377]}, {"w": "standard", "b": [0.2768, 0.416, 0.3488, 0.4377]}, {"w": "deviation,", "b": [0.3568, 0.416, 0.4378, 0.4377]}, {"w": "which", "b": [0.4457, 0.4162, 0.4966, 0.4377]}, {"w": "measures", "b": [0.5045, 0.4162, 0.5825, 0.4377]}, {"w": "how", "b": [0.5904, 0.4162, 0.6265, 0.4377]}, {"w": "dispersed", "b": [0.6344, 0.4162, 0.7136, 0.4377]}, {"w": "the", "b": [0.7215, 0.4162, 0.7478, 0.4377]}, {"w": "values", "b": [0.7557, 0.4162, 0.8073, 0.4377]}, {"w": "are.12", "b": [0.8152, 0.4162, 0.8571, 0.4377]}]}, {"id": "b_3", "type": "paragraph", "text": "The 25%, 50%, and 75% rows show the corresponding percentiles: a percentile indi‐ cates the value below which a given percentage of observations in a group of observa‐ tions falls. For example, 25% of the districts have a housing_median_age lower than 18, while 50% are lower than 29 and 75% are lower than 37. These are often called the 25th percentile (or 1st quartile), the median, and the 75th percentile (or 3rd quartile).", "words": [{"w": "The", "b": [0.1428, 0.4353, 0.1757, 0.4567]}, {"w": "25%,", "b": [0.1823, 0.4353, 0.2228, 0.4567]}, {"w": "50%,", "b": [0.2294, 0.4353, 0.2699, 0.4567]}, {"w": "and", "b": [0.2765, 0.4353, 0.308, 0.4567]}, {"w": "75%", "b": [0.3146, 0.4353, 0.3504, 0.4567]}, {"w": "rows", "b": [0.357, 0.4353, 0.3973, 0.4567]}, {"w": "show", "b": [0.4039, 0.4353, 0.4475, 0.4567]}, {"w": "the", "b": [0.4541, 0.4353, 0.4805, 0.4567]}, {"w": "corresponding", "b": [0.4871, 0.4353, 0.6091, 0.4567]}, {"w": "percentiles:", "b": [0.6158, 0.4351, 0.705, 0.4567]}, {"w": "a", "b": [0.7116, 0.4353, 0.7207, 0.4567]}, {"w": "percentile", "b": [0.7273, 0.4353, 0.8095, 0.4567]}, {"w": "indi‐", "b": [0.8162, 0.4353, 0.8571, 0.4567]}, {"w": "cates", "b": [0.1429, 0.4543, 0.1833, 0.4758]}, {"w": "the", "b": [0.1883, 0.4543, 0.2146, 0.4758]}, {"w": "value", "b": [0.2197, 0.4543, 0.2636, 0.4758]}, {"w": "below", "b": [0.2687, 0.4543, 0.3183, 0.4758]}, {"w": "which", "b": [0.3233, 0.4543, 0.3742, 0.4758]}, {"w": "a", "b": [0.3792, 0.4543, 0.3884, 0.4758]}, {"w": "given", "b": [0.3934, 0.4543, 0.4386, 0.4758]}, {"w": "percentage", "b": [0.4436, 0.4543, 0.5339, 0.4758]}, {"w": "of", "b": [0.5389, 0.4543, 0.5557, 0.4758]}, {"w": "observations", "b": [0.5607, 0.4543, 0.6668, 0.4758]}, {"w": "in", "b": [0.6718, 0.4543, 0.6888, 0.4758]}, {"w": "a", "b": [0.6938, 0.4543, 0.703, 0.4758]}, {"w": "group", "b": [0.708, 0.4543, 0.7581, 0.4758]}, {"w": "of", "b": [0.7631, 0.4543, 0.7799, 0.4758]}, {"w": "observa‐", "b": [0.7849, 0.4543, 0.8571, 0.4758]}, {"w": "tions", "b": [0.1429, 0.4743, 0.1845, 0.4957]}, {"w": "falls.", "b": [0.1907, 0.4743, 0.229, 0.4957]}, {"w": "For", "b": [0.2352, 0.4743, 0.2642, 0.4957]}, {"w": "example,", "b": [0.2705, 0.4743, 0.3448, 0.4957]}, {"w": "25%", "b": [0.351, 0.4743, 0.3868, 0.4957]}, {"w": "of", "b": [0.393, 0.4743, 0.4098, 0.4957]}, {"w": "the", "b": [0.4161, 0.4743, 0.4424, 0.4957]}, {"w": "districts", "b": [0.4487, 0.4743, 0.5154, 0.4957]}, {"w": "have", "b": [0.5217, 0.4743, 0.5601, 0.4957]}, {"w": "a", "b": [0.5663, 0.4743, 0.5755, 0.4957]}, {"w": "housing_median_age", "b": [0.5817, 0.4775, 0.7598, 0.4925]}, {"w": "lower", "b": [0.7661, 0.4743, 0.8129, 0.4957]}, {"w": "than", "b": [0.8191, 0.4743, 0.8571, 0.4957]}, {"w": "18,", "b": [0.1429, 0.4933, 0.1676, 0.5147]}, {"w": "while", "b": [0.1725, 0.4933, 0.2176, 0.5147]}, {"w": "50%", "b": [0.2224, 0.4933, 0.2582, 0.5147]}, {"w": "are", "b": [0.263, 0.4933, 0.2887, 0.5147]}, {"w": "lower", "b": [0.2936, 0.4933, 0.3403, 0.5147]}, {"w": "than", "b": [0.3452, 0.4933, 0.3832, 0.5147]}, {"w": "29", "b": [0.3881, 0.4933, 0.4081, 0.5147]}, {"w": "and", "b": [0.4129, 0.4933, 0.4445, 0.5147]}, {"w": "75%", "b": [0.4493, 0.4933, 0.4851, 0.5147]}, {"w": "are", "b": [0.4899, 0.4933, 0.5156, 0.5147]}, {"w": "lower", "b": [0.5205, 0.4933, 0.5673, 0.5147]}, {"w": "than", "b": [0.5721, 0.4933, 0.6101, 0.5147]}, {"w": "37.", "b": [0.615, 0.4933, 0.6397, 0.5147]}, {"w": "These", "b": [0.6446, 0.4933, 0.6939, 0.5147]}, {"w": "are", "b": [0.6988, 0.4933, 0.7245, 0.5147]}, {"w": "often", "b": [0.7293, 0.4933, 0.7727, 0.5147]}, {"w": "called", "b": [0.7776, 0.4933, 0.826, 0.5147]}, {"w": "the", "b": [0.8308, 0.4933, 0.8571, 0.5147]}, {"w": "25th", "b": [0.1429, 0.5124, 0.1733, 0.5338]}, {"w": "percentile", "b": [0.1781, 0.5124, 0.2603, 0.5338]}, {"w": "(or", "b": [0.265, 0.5124, 0.2906, 0.5338]}, {"w": "1st", "b": [0.2953, 0.5124, 0.3137, 0.5338]}, {"w": "quartile),", "b": [0.3184, 0.5122, 0.3943, 0.5338]}, {"w": "the", "b": [0.3991, 0.5124, 0.4254, 0.5338]}, {"w": "median,", "b": [0.4301, 0.5124, 0.4979, 0.5338]}, {"w": "and", "b": [0.5026, 0.5124, 0.5342, 0.5338]}, {"w": "the", "b": [0.5389, 0.5124, 0.5652, 0.5338]}, {"w": "75th", "b": [0.57, 0.5124, 0.6005, 0.5338]}, {"w": "percentile", "b": [0.6052, 0.5124, 0.6874, 0.5338]}, {"w": "(or", "b": [0.6921, 0.5124, 0.7177, 0.5338]}, {"w": "3rd", "b": [0.7224, 0.5124, 0.7437, 0.5338]}, {"w": "quartile).", "b": [0.7484, 0.5124, 0.825, 0.5338]}]}, {"id": "b_4", "type": "paragraph", "text": "Another quick way to get a feel of the type of data you are dealing with is to plot a histogram for each numerical attribute. A histogram shows the number of instances (on the vertical axis) that have a given value range (on the horizontal axis). You can either plot this one attribute at a time, or you can call the hist() method on the whole dataset, and it will plot a histogram for each numerical attribute (see Figure 2-8). For example, you can see that slightly over 800 districts have a median_house_value equal to about $100,000.", "words": [{"w": "Another", "b": [0.1429, 0.5405, 0.2133, 0.5619]}, {"w": "quick", "b": [0.2196, 0.5405, 0.2661, 0.5619]}, {"w": "way", "b": [0.2724, 0.5405, 0.305, 0.5619]}, {"w": "to", "b": [0.3113, 0.5405, 0.3282, 0.5619]}, {"w": "get", "b": [0.3345, 0.5405, 0.3595, 0.5619]}, {"w": "a", "b": [0.3658, 0.5405, 0.3749, 0.5619]}, {"w": "feel", "b": [0.3812, 0.5405, 0.4104, 0.5619]}, {"w": "of", "b": [0.4167, 0.5405, 0.4335, 0.5619]}, {"w": "the", "b": [0.4397, 0.5405, 0.4661, 0.5619]}, {"w": "type", "b": [0.4724, 0.5405, 0.5081, 0.5619]}, {"w": "of", "b": [0.5143, 0.5405, 0.5311, 0.5619]}, {"w": "data", "b": [0.5374, 0.5405, 0.5727, 0.5619]}, {"w": "you", "b": [0.579, 0.5405, 0.6102, 0.5619]}, {"w": "are", "b": [0.6165, 0.5405, 0.6422, 0.5619]}, {"w": "dealing", "b": [0.6485, 0.5405, 0.7095, 0.5619]}, {"w": "with", "b": [0.7158, 0.5405, 0.7532, 0.5619]}, {"w": "is", "b": [0.7595, 0.5405, 0.7727, 0.5619]}, {"w": "to", "b": [0.779, 0.5405, 0.796, 0.5619]}, {"w": "plot", "b": [0.8023, 0.5405, 0.8354, 0.5619]}, {"w": "a", "b": [0.8417, 0.5405, 0.8509, 0.5619]}, {"w": "histogram", "b": [0.1429, 0.5595, 0.2279, 0.581]}, {"w": "for", "b": [0.2341, 0.5595, 0.2587, 0.581]}, {"w": "each", "b": [0.2649, 0.5595, 0.3029, 0.581]}, {"w": "numerical", "b": [0.3091, 0.5595, 0.3937, 0.581]}, {"w": "attribute.", "b": [0.3999, 0.5595, 0.4763, 0.581]}, {"w": "A", "b": [0.4826, 0.5595, 0.497, 0.581]}, {"w": "histogram", "b": [0.5032, 0.5595, 0.5882, 0.581]}, {"w": "shows", "b": [0.5945, 0.5595, 0.6458, 0.581]}, {"w": "the", "b": [0.6521, 0.5595, 0.6784, 0.581]}, {"w": "number", "b": [0.6847, 0.5595, 0.751, 0.581]}, {"w": "of", "b": [0.7573, 0.5595, 0.774, 0.581]}, {"w": "instances", "b": [0.7803, 0.5595, 0.8571, 0.581]}, {"w": "(on", "b": [0.1429, 0.5786, 0.1721, 0.6]}, {"w": "the", "b": [0.1784, 0.5786, 0.2047, 0.6]}, {"w": "vertical", "b": [0.211, 0.5786, 0.2724, 0.6]}, {"w": "axis)", "b": [0.2786, 0.5786, 0.318, 0.6]}, {"w": "that", "b": [0.3243, 0.5786, 0.3569, 0.6]}, {"w": "have", "b": [0.3632, 0.5786, 0.4016, 0.6]}, {"w": "a", "b": [0.4078, 0.5786, 0.417, 0.6]}, {"w": "given", "b": [0.4232, 0.5786, 0.4685, 0.6]}, {"w": "value", "b": [0.4747, 0.5786, 0.5187, 0.6]}, {"w": "range", "b": [0.525, 0.5786, 0.5719, 0.6]}, {"w": "(on", "b": [0.5781, 0.5786, 0.6074, 0.6]}, {"w": "the", "b": [0.6136, 0.5786, 0.64, 0.6]}, {"w": "horizontal", "b": [0.6462, 0.5786, 0.7325, 0.6]}, {"w": "axis).", "b": [0.7387, 0.5786, 0.7829, 0.6]}, {"w": "You", "b": [0.7892, 0.5786, 0.8215, 0.6]}, {"w": "can", "b": [0.8278, 0.5786, 0.8571, 0.6]}, {"w": "either", "b": [0.1429, 0.5985, 0.1914, 0.62]}, {"w": "plot", "b": [0.1992, 0.5985, 0.2324, 0.62]}, {"w": "this", "b": [0.2403, 0.5985, 0.271, 0.62]}, {"w": "one", "b": [0.2789, 0.5985, 0.3097, 0.62]}, {"w": "attribute", "b": [0.3176, 0.5985, 0.3892, 0.62]}, {"w": "at", "b": [0.3971, 0.5985, 0.4122, 0.62]}, {"w": "a", "b": [0.4201, 0.5985, 0.4292, 0.62]}, {"w": "time,", "b": [0.4371, 0.5985, 0.4797, 0.62]}, {"w": "or", "b": [0.4876, 0.5985, 0.506, 0.62]}, {"w": "you", "b": [0.5138, 0.5985, 0.5451, 0.62]}, {"w": "can", "b": [0.553, 0.5985, 0.5823, 0.62]}, {"w": "call", "b": [0.5902, 0.5985, 0.6187, 0.62]}, {"w": "the", "b": [0.6266, 0.5985, 0.6529, 0.62]}, {"w": "hist()", "b": [0.6608, 0.6017, 0.7201, 0.6168]}, {"w": "method", "b": [0.728, 0.5985, 0.793, 0.62]}, {"w": "on", "b": [0.8009, 0.5985, 0.8229, 0.62]}, {"w": "the", "b": [0.8308, 0.5985, 0.8572, 0.62]}, {"w": "whole", "b": [0.1429, 0.6176, 0.193, 0.639]}, {"w": "dataset,", "b": [0.2054, 0.6176, 0.2683, 0.639]}, {"w": "and", "b": [0.2807, 0.6176, 0.3122, 0.639]}, {"w": "it", "b": [0.3246, 0.6176, 0.3366, 0.639]}, {"w": "will", "b": [0.349, 0.6176, 0.3794, 0.639]}, {"w": "plot", "b": [0.3918, 0.6176, 0.4249, 0.639]}, {"w": "a", "b": [0.4374, 0.6176, 0.4465, 0.639]}, {"w": "histogram", "b": [0.4589, 0.6176, 0.5439, 0.639]}, {"w": "for", "b": [0.5563, 0.6176, 0.5809, 0.639]}, {"w": "each", "b": [0.5933, 0.6176, 0.6312, 0.639]}, {"w": "numerical", "b": [0.6436, 0.6176, 0.7281, 0.639]}, {"w": "attribute", "b": [0.7406, 0.6176, 0.8122, 0.639]}, {"w": "(see", "b": [0.8246, 0.6176, 0.8571, 0.639]}, {"w": "Figure", "b": [0.1429, 0.6366, 0.1969, 0.658]}, {"w": "2-8).", "b": [0.209, 0.6366, 0.2484, 0.658]}, {"w": "For", "b": [0.2605, 0.6366, 0.2895, 0.658]}, {"w": "example,", "b": [0.3016, 0.6366, 0.3759, 0.658]}, {"w": "you", "b": [0.3881, 0.6366, 0.4193, 0.658]}, {"w": "can", "b": [0.4315, 0.6366, 0.4608, 0.658]}, {"w": "see", "b": [0.4729, 0.6366, 0.4983, 0.658]}, {"w": "that", "b": [0.5104, 0.6366, 0.543, 0.658]}, {"w": "slightly", "b": [0.5552, 0.6366, 0.6153, 0.658]}, {"w": "over", "b": [0.6275, 0.6366, 0.6643, 0.658]}, {"w": "800", "b": [0.6765, 0.6366, 0.7065, 0.658]}, {"w": "districts", "b": [0.7186, 0.6366, 0.7853, 0.658]}, {"w": "have", "b": [0.7975, 0.6366, 0.8359, 0.658]}, {"w": "a", "b": [0.848, 0.6366, 0.8571, 0.658]}, {"w": "median_house_value", "b": [0.1429, 0.6598, 0.321, 0.6748]}, {"w": "equal", "b": [0.3257, 0.6566, 0.3707, 0.678]}, {"w": "to", "b": [0.3754, 0.6566, 0.3924, 0.678]}, {"w": "about", "b": [0.3971, 0.6566, 0.4449, 0.678]}, {"w": "$100,000.", "b": [0.4496, 0.6566, 0.5291, 0.678]}]}, {"id": "b_5", "type": "paragraph", "text": "%matplotlib inline # only in a Jupyter notebook import matplotlib.pyplot as plt housing.hist(bins=50, figsize=(20,15)) plt.show()", "words": [{"w": "%matplotlib", "b": [0.1766, 0.6886, 0.2693, 0.7014]}, {"w": "inline", "b": [0.2778, 0.6886, 0.3284, 0.7014]}, {"w": "#", "b": [0.3537, 0.6886, 0.3621, 0.7014]}, {"w": "only", "b": [0.3705, 0.6886, 0.4043, 0.7014]}, {"w": "in", "b": [0.4127, 0.6886, 0.4296, 0.7014]}, {"w": "a", "b": [0.438, 0.6886, 0.4464, 0.7014]}, {"w": "Jupyter", "b": [0.4549, 0.6886, 0.5139, 0.7014]}, {"w": "notebook", "b": [0.5223, 0.6886, 0.5898, 0.7014]}, {"w": "import", "b": [0.1766, 0.704, 0.2272, 0.7168]}, {"w": "matplotlib.pyplot", "b": [0.2356, 0.704, 0.379, 0.7168]}, {"w": "as", "b": [0.3874, 0.704, 0.4043, 0.7168]}, {"w": "plt", "b": [0.4127, 0.704, 0.438, 0.7168]}, {"w": "housing.hist(bins=50,", "b": [0.1766, 0.7194, 0.3537, 0.7322]}, {"w": "figsize=(20,15))", "b": [0.3621, 0.7194, 0.497, 0.7322]}, {"w": "plt.show()", "b": [0.1766, 0.7348, 0.2609, 0.7477]}]}, {"id": "b_6", "type": "equation", "text": "52 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "52", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.478, 0.9388]}]}]}, {"page": 79, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "The hist() method relies on Matplotlib, which in turn relies on a user-specified graphical backend to draw on your screen. So before you can plot anything, you need to specify which backend Matplot‐ lib should use. The simplest option is to use Jupyter’s magic com‐ mand %matplotlib inline. This tells Jupyter to set up Matplotlib so it uses Jupyter’s own backend. Plots are then rendered within the notebook itself. Note that calling show() is optional in a Jupyter notebook, as Jupyter will automatically display plots when a cell is executed.", "words": [{"w": "The", "b": [0.2714, 0.0801, 0.3014, 0.0997]}, {"w": "hist()", "b": [0.3071, 0.083, 0.3613, 0.0968]}, {"w": "method", "b": [0.367, 0.0801, 0.4264, 0.0997]}, {"w": "relies", "b": [0.4321, 0.0801, 0.4722, 0.0997]}, {"w": "on", "b": [0.4779, 0.0801, 0.498, 0.0997]}, {"w": "Matplotlib,", "b": [0.5036, 0.0801, 0.5878, 0.0997]}, {"w": "which", "b": [0.5934, 0.0801, 0.64, 0.0997]}, {"w": "in", "b": [0.6456, 0.0801, 0.6611, 0.0997]}, {"w": "turn", "b": [0.6668, 0.0801, 0.7002, 0.0997]}, {"w": "relies", "b": [0.7058, 0.0801, 0.746, 0.0997]}, {"w": "on", "b": [0.7516, 0.0801, 0.7717, 0.0997]}, {"w": "a", "b": [0.7774, 0.0801, 0.7857, 0.0997]}, {"w": "user-specified", "b": [0.2714, 0.0975, 0.3771, 0.1171]}, {"w": "graphical", "b": [0.3821, 0.0975, 0.4525, 0.1171]}, {"w": "backend", "b": [0.4575, 0.0975, 0.5216, 0.1171]}, {"w": "to", "b": [0.5265, 0.0975, 0.542, 0.1171]}, {"w": "draw", "b": [0.547, 0.0975, 0.5852, 0.1171]}, {"w": "on", "b": [0.5901, 0.0975, 0.6102, 0.1171]}, {"w": "your", "b": [0.6152, 0.0975, 0.6508, 0.1171]}, {"w": "screen.", "b": [0.6557, 0.0975, 0.7088, 0.1171]}, {"w": "So", "b": [0.7138, 0.0975, 0.7325, 0.1171]}, {"w": "before", "b": [0.7374, 0.0975, 0.7857, 0.1171]}, {"w": "you", "b": [0.2714, 0.1149, 0.3, 0.1345]}, {"w": "can", "b": [0.3045, 0.1149, 0.3313, 0.1345]}, {"w": "plot", "b": [0.3358, 0.1149, 0.3661, 0.1345]}, {"w": "anything,", "b": [0.3706, 0.1149, 0.4424, 0.1345]}, {"w": "you", "b": [0.4469, 0.1149, 0.4755, 0.1345]}, {"w": "need", "b": [0.48, 0.1149, 0.5166, 0.1345]}, {"w": "to", "b": [0.5211, 0.1149, 0.5366, 0.1345]}, {"w": "specify", "b": [0.5411, 0.1149, 0.594, 0.1345]}, {"w": "which", "b": [0.5985, 0.1149, 0.6451, 0.1345]}, {"w": "backend", "b": [0.6496, 0.1149, 0.7137, 0.1345]}, {"w": "Matplot‐", "b": [0.7182, 0.1149, 0.7857, 0.1345]}, {"w": "lib", "b": [0.2714, 0.1323, 0.291, 0.1519]}, {"w": "should", "b": [0.297, 0.1323, 0.3488, 0.1519]}, {"w": "use.", "b": [0.3548, 0.1323, 0.3843, 0.1519]}, {"w": "The", "b": [0.3903, 0.1323, 0.4203, 0.1519]}, {"w": "simplest", "b": [0.4263, 0.1323, 0.4893, 0.1519]}, {"w": "option", "b": [0.4953, 0.1323, 0.546, 0.1519]}, {"w": "is", "b": [0.552, 0.1323, 0.5641, 0.1519]}, {"w": "to", "b": [0.5701, 0.1323, 0.5856, 0.1519]}, {"w": "use", "b": [0.5915, 0.1323, 0.6167, 0.1519]}, {"w": "Jupyter’s", "b": [0.6227, 0.1323, 0.6876, 0.1519]}, {"w": "magic", "b": [0.6936, 0.1323, 0.7396, 0.1519]}, {"w": "com‐", "b": [0.7456, 0.1323, 0.7857, 0.1519]}, {"w": "mand", "b": [0.2714, 0.1506, 0.3159, 0.1702]}, {"w": "%matplotlib", "b": [0.3214, 0.1535, 0.4209, 0.1673]}, {"w": "inline.", "b": [0.4312, 0.1506, 0.4898, 0.1702]}, {"w": "This", "b": [0.4954, 0.1506, 0.5294, 0.1702]}, {"w": "tells", "b": [0.535, 0.1506, 0.5655, 0.1702]}, {"w": "Jupyter", "b": [0.5711, 0.1506, 0.6265, 0.1702]}, {"w": "to", "b": [0.6321, 0.1506, 0.6476, 0.1702]}, {"w": "set", "b": [0.6532, 0.1506, 0.6741, 0.1702]}, {"w": "up", "b": [0.6797, 0.1506, 0.6998, 0.1702]}, {"w": "Matplotlib", "b": [0.7053, 0.1506, 0.7857, 0.1702]}, {"w": "so", "b": [0.2714, 0.168, 0.2881, 0.1876]}, {"w": "it", "b": [0.2926, 0.168, 0.3035, 0.1876]}, {"w": "uses", "b": [0.308, 0.168, 0.3402, 0.1876]}, {"w": "Jupyter’s", "b": [0.3446, 0.168, 0.4095, 0.1876]}, {"w": "own", "b": [0.414, 0.168, 0.4472, 0.1876]}, {"w": "backend.", "b": [0.4517, 0.168, 0.5201, 0.1876]}, {"w": "Plots", "b": [0.5246, 0.168, 0.5627, 0.1876]}, {"w": "are", "b": [0.5671, 0.168, 0.5906, 0.1876]}, {"w": "then", "b": [0.5951, 0.168, 0.6296, 0.1876]}, {"w": "rendered", "b": [0.6341, 0.168, 0.703, 0.1876]}, {"w": "within", "b": [0.7075, 0.168, 0.7572, 0.1876]}, {"w": "the", "b": [0.7616, 0.168, 0.7857, 0.1876]}, {"w": "notebook", "b": [0.2714, 0.1862, 0.344, 0.2058]}, {"w": "itself.", "b": [0.3514, 0.1862, 0.3922, 0.2058]}, {"w": "Note", "b": [0.3995, 0.1862, 0.4368, 0.2058]}, {"w": "that", "b": [0.4442, 0.1862, 0.474, 0.2058]}, {"w": "calling", "b": [0.4814, 0.1862, 0.5319, 0.2058]}, {"w": "show()", "b": [0.5392, 0.1891, 0.5935, 0.2029]}, {"w": "is", "b": [0.6009, 0.1862, 0.613, 0.2058]}, {"w": "optional", "b": [0.6203, 0.1862, 0.6843, 0.2058]}, {"w": "in", "b": [0.6916, 0.1862, 0.7072, 0.2058]}, {"w": "a", "b": [0.7145, 0.1862, 0.7229, 0.2058]}, {"w": "Jupyter", "b": [0.7303, 0.1862, 0.7857, 0.2058]}, {"w": "notebook,", "b": [0.2714, 0.2036, 0.3483, 0.2232]}, {"w": "as", "b": [0.354, 0.2036, 0.3694, 0.2232]}, {"w": "Jupyter", "b": [0.3751, 0.2036, 0.4305, 0.2232]}, {"w": "will", "b": [0.4362, 0.2036, 0.464, 0.2232]}, {"w": "automatically", "b": [0.4697, 0.2036, 0.5726, 0.2232]}, {"w": "display", "b": [0.5783, 0.2036, 0.632, 0.2232]}, {"w": "plots", "b": [0.6377, 0.2036, 0.675, 0.2232]}, {"w": "when", "b": [0.6807, 0.2036, 0.7224, 0.2232]}, {"w": "a", "b": [0.7281, 0.2036, 0.7365, 0.2232]}, {"w": "cell", "b": [0.7422, 0.2036, 0.7679, 0.2232]}, {"w": "is", "b": [0.7736, 0.2036, 0.7857, 0.2232]}, {"w": "executed.", "b": [0.2714, 0.2211, 0.3431, 0.2406]}]}, {"id": "b_1", "type": "equation", "text": "Figure 2-8. A histogram for each numerical attribute", "words": [{"w": "Figure", "b": [0.1429, 0.6723, 0.1943, 0.6939]}, {"w": "2-8.", "b": [0.1991, 0.6723, 0.2308, 0.6939]}, {"w": "A", "b": [0.2356, 0.6723, 0.2494, 0.6939]}, {"w": "histogram", "b": [0.2542, 0.6723, 0.3354, 0.6939]}, {"w": "for", "b": [0.3402, 0.6723, 0.3628, 0.6939]}, {"w": "each", "b": [0.3676, 0.6723, 0.4042, 0.6939]}, {"w": "numerical", "b": [0.409, 0.6723, 0.4915, 0.6939]}, {"w": "attribute", "b": [0.4963, 0.6723, 0.5671, 0.6939]}]}, {"id": "b_2", "type": "paragraph", "text": "Notice a few things in these histograms:", "words": [{"w": "Notice", "b": [0.1429, 0.7097, 0.1981, 0.7311]}, {"w": "a", "b": [0.2028, 0.7097, 0.2119, 0.7311]}, {"w": "few", "b": [0.2167, 0.7097, 0.2459, 0.7311]}, {"w": "things", "b": [0.2507, 0.7097, 0.3025, 0.7311]}, {"w": "in", "b": [0.3073, 0.7097, 0.3242, 0.7311]}, {"w": "these", "b": [0.329, 0.7097, 0.3718, 0.7311]}, {"w": "histograms:", "b": [0.3765, 0.7097, 0.4739, 0.7311]}]}, {"id": "b_3", "type": "paragraph", "text": "1. First, the median income attribute does not look like it is expressed in US dollars (USD). After checking with the team that collected the data, you are told that the data has been scaled and capped at 15 (actually 15.0001) for higher median incomes, and at 0.5 (actually 0.4999) for lower median incomes. The numbers represent roughly tens of thousands of dollars (e.g., 3 actually means about $30,000). Working with preprocessed attributes is common in Machine Learning,", "words": [{"w": "1.", "b": [0.1534, 0.7438, 0.1682, 0.7652]}, {"w": "First,", "b": [0.1786, 0.7438, 0.2216, 0.7652]}, {"w": "the", "b": [0.2269, 0.7438, 0.2532, 0.7652]}, {"w": "median", "b": [0.2585, 0.7438, 0.3215, 0.7652]}, {"w": "income", "b": [0.3267, 0.7438, 0.3891, 0.7652]}, {"w": "attribute", "b": [0.3943, 0.7438, 0.4659, 0.7652]}, {"w": "does", "b": [0.4712, 0.7438, 0.5093, 0.7652]}, {"w": "not", "b": [0.5146, 0.7438, 0.5429, 0.7652]}, {"w": "look", "b": [0.5482, 0.7438, 0.585, 0.7652]}, {"w": "like", "b": [0.5903, 0.7438, 0.6203, 0.7652]}, {"w": "it", "b": [0.6256, 0.7438, 0.6375, 0.7652]}, {"w": "is", "b": [0.6427, 0.7438, 0.656, 0.7652]}, {"w": "expressed", "b": [0.6612, 0.7438, 0.7425, 0.7652]}, {"w": "in", "b": [0.7478, 0.7438, 0.7648, 0.7652]}, {"w": "US", "b": [0.77, 0.7438, 0.7952, 0.7652]}, {"w": "dollars", "b": [0.8004, 0.7438, 0.8571, 0.7652]}, {"w": "(USD).", "b": [0.1786, 0.7629, 0.2383, 0.7843]}, {"w": "After", "b": [0.2435, 0.7629, 0.287, 0.7843]}, {"w": "checking", "b": [0.2923, 0.7629, 0.367, 0.7843]}, {"w": "with", "b": [0.3722, 0.7629, 0.4096, 0.7843]}, {"w": "the", "b": [0.4148, 0.7629, 0.4412, 0.7843]}, {"w": "team", "b": [0.4464, 0.7629, 0.4878, 0.7843]}, {"w": "that", "b": [0.4931, 0.7629, 0.5257, 0.7843]}, {"w": "collected", "b": [0.531, 0.7629, 0.6048, 0.7843]}, {"w": "the", "b": [0.6101, 0.7629, 0.6364, 0.7843]}, {"w": "data,", "b": [0.6417, 0.7629, 0.6817, 0.7843]}, {"w": "you", "b": [0.6869, 0.7629, 0.7182, 0.7843]}, {"w": "are", "b": [0.7235, 0.7629, 0.7492, 0.7843]}, {"w": "told", "b": [0.7544, 0.7629, 0.7877, 0.7843]}, {"w": "that", "b": [0.793, 0.7629, 0.8255, 0.7843]}, {"w": "the", "b": [0.8308, 0.7629, 0.8571, 0.7843]}, {"w": "data", "b": [0.1786, 0.7819, 0.2138, 0.8033]}, {"w": "has", "b": [0.2233, 0.7819, 0.2512, 0.8033]}, {"w": "been", "b": [0.2607, 0.7819, 0.3003, 0.8033]}, {"w": "scaled", "b": [0.3098, 0.7819, 0.3605, 0.8033]}, {"w": "and", "b": [0.37, 0.7819, 0.4015, 0.8033]}, {"w": "capped", "b": [0.411, 0.7819, 0.4703, 0.8033]}, {"w": "at", "b": [0.4797, 0.7819, 0.4948, 0.8033]}, {"w": "15", "b": [0.5043, 0.7819, 0.5243, 0.8033]}, {"w": "(actually", "b": [0.5338, 0.7819, 0.6056, 0.8033]}, {"w": "15.0001)", "b": [0.6151, 0.7819, 0.687, 0.8033]}, {"w": "for", "b": [0.6965, 0.7819, 0.721, 0.8033]}, {"w": "higher", "b": [0.7305, 0.7819, 0.7846, 0.8033]}, {"w": "median", "b": [0.7941, 0.7819, 0.8571, 0.8033]}, {"w": "incomes,", "b": [0.1786, 0.801, 0.2533, 0.8224]}, {"w": "and", "b": [0.2608, 0.801, 0.2924, 0.8224]}, {"w": "at", "b": [0.2999, 0.801, 0.315, 0.8224]}, {"w": "0.5", "b": [0.3225, 0.801, 0.3473, 0.8224]}, {"w": "(actually", "b": [0.3548, 0.801, 0.4267, 0.8224]}, {"w": "0.4999)", "b": [0.4342, 0.801, 0.4961, 0.8224]}, {"w": "for", "b": [0.5037, 0.801, 0.5282, 0.8224]}, {"w": "lower", "b": [0.5357, 0.801, 0.5825, 0.8224]}, {"w": "median", "b": [0.59, 0.801, 0.653, 0.8224]}, {"w": "incomes.", "b": [0.6606, 0.801, 0.7353, 0.8224]}, {"w": "The", "b": [0.7428, 0.801, 0.7757, 0.8224]}, {"w": "numbers", "b": [0.7832, 0.801, 0.8571, 0.8224]}, {"w": "represent", "b": [0.1786, 0.82, 0.2565, 0.8414]}, {"w": "roughly", "b": [0.2664, 0.82, 0.3315, 0.8414]}, {"w": "tens", "b": [0.3414, 0.82, 0.3756, 0.8414]}, {"w": "of", "b": [0.3855, 0.82, 0.4023, 0.8414]}, {"w": "thousands", "b": [0.4121, 0.82, 0.4981, 0.8414]}, {"w": "of", "b": [0.508, 0.82, 0.5248, 0.8414]}, {"w": "dollars", "b": [0.5346, 0.82, 0.5913, 0.8414]}, {"w": "(e.g.,", "b": [0.6012, 0.82, 0.6412, 0.8414]}, {"w": "3", "b": [0.6511, 0.82, 0.6611, 0.8414]}, {"w": "actually", "b": [0.6709, 0.82, 0.7356, 0.8414]}, {"w": "means", "b": [0.7454, 0.82, 0.7995, 0.8414]}, {"w": "about", "b": [0.8094, 0.82, 0.8572, 0.8414]}, {"w": "$30,000).", "b": [0.1786, 0.8391, 0.2553, 0.8605]}, {"w": "Working", "b": [0.26, 0.8391, 0.3336, 0.8605]}, {"w": "with", "b": [0.3384, 0.8391, 0.3757, 0.8605]}, {"w": "preprocessed", "b": [0.3807, 0.8391, 0.4903, 0.8605]}, {"w": "attributes", "b": [0.495, 0.8391, 0.5743, 0.8605]}, {"w": "is", "b": [0.579, 0.8391, 0.5922, 0.8605]}, {"w": "common", "b": [0.5969, 0.8391, 0.6725, 0.8605]}, {"w": "in", "b": [0.6773, 0.8391, 0.6942, 0.8605]}, {"w": "Machine", "b": [0.699, 0.8391, 0.7721, 0.8605]}, {"w": "Learning,", "b": [0.7768, 0.8391, 0.8566, 0.8605]}]}, {"id": "b_4", "type": "paragraph", "text": "Get the Data | 53", "words": [{"w": "Get", "b": [0.7296, 0.9225, 0.7499, 0.9388]}, {"w": "the", "b": [0.7528, 0.9225, 0.7726, 0.9388]}, {"w": "Data", "b": [0.7755, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "53", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 80, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "and it is not necessarily a problem, but you should try to understand how the data was computed.", "words": [{"w": "and", "b": [0.1786, 0.0791, 0.2101, 0.1005]}, {"w": "it", "b": [0.2175, 0.0791, 0.2294, 0.1005]}, {"w": "is", "b": [0.2367, 0.0791, 0.25, 0.1005]}, {"w": "not", "b": [0.2573, 0.0791, 0.2857, 0.1005]}, {"w": "necessarily", "b": [0.2931, 0.0791, 0.3836, 0.1005]}, {"w": "a", "b": [0.3909, 0.0791, 0.4, 0.1005]}, {"w": "problem,", "b": [0.4074, 0.0791, 0.4832, 0.1005]}, {"w": "but", "b": [0.4905, 0.0791, 0.5185, 0.1005]}, {"w": "you", "b": [0.5259, 0.0791, 0.5571, 0.1005]}, {"w": "should", "b": [0.5645, 0.0791, 0.6212, 0.1005]}, {"w": "try", "b": [0.6286, 0.0791, 0.6528, 0.1005]}, {"w": "to", "b": [0.6602, 0.0791, 0.6771, 0.1005]}, {"w": "understand", "b": [0.6845, 0.0791, 0.7801, 0.1005]}, {"w": "how", "b": [0.7874, 0.0791, 0.8235, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}, {"w": "data", "b": [0.1786, 0.0981, 0.2138, 0.1195]}, {"w": "was", "b": [0.2186, 0.0981, 0.2496, 0.1195]}, {"w": "computed.", "b": [0.2543, 0.0981, 0.3434, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "2. The housing median age and the median house value were also capped. The lat‐ ter may be a serious problem since it is your target attribute (your labels). Your Machine Learning algorithms may learn that prices never go beyond that limit. You need to check with your client team (the team that will use your system’s out‐ put) to see if this is a problem or not. If they tell you that they need precise pre‐ dictions even beyond $500,000, then you have mainly two options:", "words": [{"w": "2.", "b": [0.1534, 0.1232, 0.1682, 0.1446]}, {"w": "The", "b": [0.1786, 0.1232, 0.2114, 0.1446]}, {"w": "housing", "b": [0.2173, 0.1232, 0.2845, 0.1446]}, {"w": "median", "b": [0.2904, 0.1232, 0.3534, 0.1446]}, {"w": "age", "b": [0.3593, 0.1232, 0.387, 0.1446]}, {"w": "and", "b": [0.3929, 0.1232, 0.4245, 0.1446]}, {"w": "the", "b": [0.4304, 0.1232, 0.4567, 0.1446]}, {"w": "median", "b": [0.4626, 0.1232, 0.5256, 0.1446]}, {"w": "house", "b": [0.5315, 0.1232, 0.5808, 0.1446]}, {"w": "value", "b": [0.5867, 0.1232, 0.6307, 0.1446]}, {"w": "were", "b": [0.6366, 0.1232, 0.6763, 0.1446]}, {"w": "also", "b": [0.6822, 0.1232, 0.7149, 0.1446]}, {"w": "capped.", "b": [0.7207, 0.1232, 0.7847, 0.1446]}, {"w": "The", "b": [0.7906, 0.1232, 0.8235, 0.1446]}, {"w": "lat‐", "b": [0.8293, 0.1232, 0.8571, 0.1446]}, {"w": "ter", "b": [0.1786, 0.1423, 0.2015, 0.1637]}, {"w": "may", "b": [0.208, 0.1423, 0.2434, 0.1637]}, {"w": "be", "b": [0.2498, 0.1423, 0.2692, 0.1637]}, {"w": "a", "b": [0.2757, 0.1423, 0.2848, 0.1637]}, {"w": "serious", "b": [0.2913, 0.1423, 0.3504, 0.1637]}, {"w": "problem", "b": [0.3569, 0.1423, 0.4279, 0.1637]}, {"w": "since", "b": [0.4343, 0.1423, 0.4766, 0.1637]}, {"w": "it", "b": [0.4831, 0.1423, 0.495, 0.1637]}, {"w": "is", "b": [0.5015, 0.1423, 0.5147, 0.1637]}, {"w": "your", "b": [0.5211, 0.1423, 0.5601, 0.1637]}, {"w": "target", "b": [0.5666, 0.1423, 0.6147, 0.1637]}, {"w": "attribute", "b": [0.6212, 0.1423, 0.6928, 0.1637]}, {"w": "(your", "b": [0.6993, 0.1423, 0.7454, 0.1637]}, {"w": "labels).", "b": [0.7519, 0.1423, 0.8106, 0.1637]}, {"w": "Your", "b": [0.8171, 0.1423, 0.8571, 0.1637]}, {"w": "Machine", "b": [0.1786, 0.1613, 0.2517, 0.1827]}, {"w": "Learning", "b": [0.2584, 0.1613, 0.3335, 0.1827]}, {"w": "algorithms", "b": [0.3402, 0.1613, 0.4305, 0.1827]}, {"w": "may", "b": [0.4373, 0.1613, 0.4727, 0.1827]}, {"w": "learn", "b": [0.4794, 0.1613, 0.5218, 0.1827]}, {"w": "that", "b": [0.5285, 0.1613, 0.5611, 0.1827]}, {"w": "prices", "b": [0.5678, 0.1613, 0.6174, 0.1827]}, {"w": "never", "b": [0.6241, 0.1613, 0.6706, 0.1827]}, {"w": "go", "b": [0.6773, 0.1613, 0.6977, 0.1827]}, {"w": "beyond", "b": [0.7045, 0.1613, 0.7665, 0.1827]}, {"w": "that", "b": [0.7732, 0.1613, 0.8058, 0.1827]}, {"w": "limit.", "b": [0.8125, 0.1613, 0.8571, 0.1827]}, {"w": "You", "b": [0.1786, 0.1803, 0.2109, 0.2018]}, {"w": "need", "b": [0.2157, 0.1803, 0.2558, 0.2018]}, {"w": "to", "b": [0.2606, 0.1803, 0.2776, 0.2018]}, {"w": "check", "b": [0.2824, 0.1803, 0.3303, 0.2018]}, {"w": "with", "b": [0.3351, 0.1803, 0.3725, 0.2018]}, {"w": "your", "b": [0.3773, 0.1803, 0.4162, 0.2018]}, {"w": "client", "b": [0.421, 0.1803, 0.4669, 0.2018]}, {"w": "team", "b": [0.4717, 0.1803, 0.5131, 0.2018]}, {"w": "(the", "b": [0.5179, 0.1803, 0.5515, 0.2018]}, {"w": "team", "b": [0.5562, 0.1803, 0.5977, 0.2018]}, {"w": "that", "b": [0.6025, 0.1803, 0.635, 0.2018]}, {"w": "will", "b": [0.6398, 0.1803, 0.6702, 0.2018]}, {"w": "use", "b": [0.675, 0.1803, 0.7026, 0.2018]}, {"w": "your", "b": [0.7074, 0.1803, 0.7464, 0.2018]}, {"w": "system’s", "b": [0.7512, 0.1803, 0.8169, 0.2018]}, {"w": "out‐", "b": [0.8217, 0.1803, 0.8571, 0.2018]}, {"w": "put)", "b": [0.1786, 0.1994, 0.2141, 0.2208]}, {"w": "to", "b": [0.22, 0.1994, 0.237, 0.2208]}, {"w": "see", "b": [0.2428, 0.1994, 0.2682, 0.2208]}, {"w": "if", "b": [0.274, 0.1994, 0.2858, 0.2208]}, {"w": "this", "b": [0.2916, 0.1994, 0.3223, 0.2208]}, {"w": "is", "b": [0.3282, 0.1994, 0.3414, 0.2208]}, {"w": "a", "b": [0.3472, 0.1994, 0.3564, 0.2208]}, {"w": "problem", "b": [0.3622, 0.1994, 0.4333, 0.2208]}, {"w": "or", "b": [0.4391, 0.1994, 0.4575, 0.2208]}, {"w": "not.", "b": [0.4633, 0.1994, 0.4964, 0.2208]}, {"w": "If", "b": [0.5023, 0.1994, 0.5156, 0.2208]}, {"w": "they", "b": [0.5214, 0.1994, 0.5573, 0.2208]}, {"w": "tell", "b": [0.5632, 0.1994, 0.5889, 0.2208]}, {"w": "you", "b": [0.5948, 0.1994, 0.626, 0.2208]}, {"w": "that", "b": [0.6319, 0.1994, 0.6644, 0.2208]}, {"w": "they", "b": [0.6703, 0.1994, 0.7062, 0.2208]}, {"w": "need", "b": [0.712, 0.1994, 0.7521, 0.2208]}, {"w": "precise", "b": [0.758, 0.1994, 0.8164, 0.2208]}, {"w": "pre‐", "b": [0.8222, 0.1994, 0.8572, 0.2208]}, {"w": "dictions", "b": [0.1786, 0.2184, 0.2456, 0.2399]}, {"w": "even", "b": [0.2503, 0.2184, 0.289, 0.2399]}, {"w": "beyond", "b": [0.2938, 0.2184, 0.3558, 0.2399]}, {"w": "$500,000,", "b": [0.3605, 0.2184, 0.44, 0.2399]}, {"w": "then", "b": [0.4448, 0.2184, 0.4825, 0.2399]}, {"w": "you", "b": [0.4872, 0.2184, 0.5185, 0.2399]}, {"w": "have", "b": [0.5232, 0.2184, 0.5616, 0.2399]}, {"w": "mainly", "b": [0.5663, 0.2184, 0.6243, 0.2399]}, {"w": "two", "b": [0.6291, 0.2184, 0.6603, 0.2399]}, {"w": "options:", "b": [0.665, 0.2184, 0.7329, 0.2399]}]}, {"id": "b_2", "type": "paragraph", "text": "a. Collect proper labels for the districts whose labels were capped.", "words": [{"w": "a.", "b": [0.1801, 0.2435, 0.194, 0.2649]}, {"w": "Collect", "b": [0.2044, 0.2435, 0.2634, 0.2649]}, {"w": "proper", "b": [0.2681, 0.2435, 0.3249, 0.2649]}, {"w": "labels", "b": [0.3296, 0.2435, 0.3764, 0.2649]}, {"w": "for", "b": [0.3811, 0.2435, 0.4056, 0.2649]}, {"w": "the", "b": [0.4104, 0.2435, 0.4367, 0.2649]}, {"w": "districts", "b": [0.4414, 0.2435, 0.5081, 0.2649]}, {"w": "whose", "b": [0.5129, 0.2435, 0.5654, 0.2649]}, {"w": "labels", "b": [0.5701, 0.2435, 0.6169, 0.2649]}, {"w": "were", "b": [0.6216, 0.2435, 0.6613, 0.2649]}, {"w": "capped.", "b": [0.6661, 0.2435, 0.7301, 0.2649]}]}, {"id": "b_3", "type": "paragraph", "text": "b. Remove those districts from the training set (and also from the test set, since", "words": [{"w": "b.", "b": [0.1792, 0.2686, 0.1939, 0.29]}, {"w": "Remove", "b": [0.2044, 0.2686, 0.2723, 0.29]}, {"w": "those", "b": [0.2783, 0.2686, 0.3229, 0.29]}, {"w": "districts", "b": [0.3288, 0.2686, 0.3955, 0.29]}, {"w": "from", "b": [0.4015, 0.2686, 0.4431, 0.29]}, {"w": "the", "b": [0.449, 0.2686, 0.4754, 0.29]}, {"w": "training", "b": [0.4813, 0.2686, 0.5482, 0.29]}, {"w": "set", "b": [0.5542, 0.2686, 0.577, 0.29]}, {"w": "(and", "b": [0.583, 0.2686, 0.6217, 0.29]}, {"w": "also", "b": [0.6277, 0.2686, 0.6604, 0.29]}, {"w": "from", "b": [0.6663, 0.2686, 0.7079, 0.29]}, {"w": "the", "b": [0.7139, 0.2686, 0.7402, 0.29]}, {"w": "test", "b": [0.7461, 0.2686, 0.7753, 0.29]}, {"w": "set,", "b": [0.7813, 0.2686, 0.8089, 0.29]}, {"w": "since", "b": [0.8148, 0.2686, 0.8571, 0.29]}]}, {"id": "b_4", "type": "paragraph", "text": "your system should not be evaluated poorly if it predicts values beyond $500,000).", "words": [{"w": "your", "b": [0.2044, 0.2877, 0.2433, 0.3091]}, {"w": "system", "b": [0.2537, 0.2877, 0.3109, 0.3091]}, {"w": "should", "b": [0.3212, 0.2877, 0.378, 0.3091]}, {"w": "not", "b": [0.3884, 0.2877, 0.4167, 0.3091]}, {"w": "be", "b": [0.4271, 0.2877, 0.4466, 0.3091]}, {"w": "evaluated", "b": [0.4569, 0.2877, 0.5359, 0.3091]}, {"w": "poorly", "b": [0.5463, 0.2877, 0.601, 0.3091]}, {"w": "if", "b": [0.6114, 0.2877, 0.6231, 0.3091]}, {"w": "it", "b": [0.6335, 0.2877, 0.6454, 0.3091]}, {"w": "predicts", "b": [0.6558, 0.2877, 0.7227, 0.3091]}, {"w": "values", "b": [0.7331, 0.2877, 0.7847, 0.3091]}, {"w": "beyond", "b": [0.7951, 0.2877, 0.8571, 0.3091]}, {"w": "$500,000).", "b": [0.2044, 0.3067, 0.2911, 0.3281]}]}, {"id": "b_5", "type": "paragraph", "text": "3. These attributes have very different scales. We will discuss this later in this chap‐ ter when we explore feature scaling.", "words": [{"w": "3.", "b": [0.1534, 0.3318, 0.1681, 0.3532]}, {"w": "These", "b": [0.1786, 0.3318, 0.2279, 0.3532]}, {"w": "attributes", "b": [0.2334, 0.3318, 0.3127, 0.3532]}, {"w": "have", "b": [0.3183, 0.3318, 0.3567, 0.3532]}, {"w": "very", "b": [0.3622, 0.3318, 0.3986, 0.3532]}, {"w": "different", "b": [0.4041, 0.3318, 0.4759, 0.3532]}, {"w": "scales.", "b": [0.4814, 0.3318, 0.5335, 0.3532]}, {"w": "We", "b": [0.5391, 0.3318, 0.5661, 0.3532]}, {"w": "will", "b": [0.5717, 0.3318, 0.6021, 0.3532]}, {"w": "discuss", "b": [0.6076, 0.3318, 0.667, 0.3532]}, {"w": "this", "b": [0.6726, 0.3318, 0.7033, 0.3532]}, {"w": "later", "b": [0.7088, 0.3318, 0.7458, 0.3532]}, {"w": "in", "b": [0.7513, 0.3318, 0.7683, 0.3532]}, {"w": "this", "b": [0.7739, 0.3318, 0.8046, 0.3532]}, {"w": "chap‐", "b": [0.8101, 0.3318, 0.8571, 0.3532]}, {"w": "ter", "b": [0.1786, 0.3509, 0.2015, 0.3723]}, {"w": "when", "b": [0.2062, 0.3509, 0.2519, 0.3723]}, {"w": "we", "b": [0.2566, 0.3509, 0.2797, 0.3723]}, {"w": "explore", "b": [0.2845, 0.3509, 0.3466, 0.3723]}, {"w": "feature", "b": [0.3513, 0.3509, 0.4091, 0.3723]}, {"w": "scaling.", "b": [0.4138, 0.3509, 0.4761, 0.3723]}]}, {"id": "b_6", "type": "paragraph", "text": "4. Finally, many histograms are tail heavy: they extend much farther to the right of the median than to the left. This may make it a bit harder for some Machine Learning algorithms to detect patterns. We will try transforming these attributes later on to have more bell-shaped distributions.", "words": [{"w": "4.", "b": [0.1534, 0.376, 0.1682, 0.3974]}, {"w": "Finally,", "b": [0.1786, 0.376, 0.239, 0.3974]}, {"w": "many", "b": [0.245, 0.376, 0.2917, 0.3974]}, {"w": "histograms", "b": [0.2976, 0.376, 0.3902, 0.3974]}, {"w": "are", "b": [0.3962, 0.376, 0.4219, 0.3974]}, {"w": "tail", "b": [0.4278, 0.3758, 0.4547, 0.3974]}, {"w": "heavy:", "b": [0.4606, 0.3758, 0.5125, 0.3974]}, {"w": "they", "b": [0.5185, 0.376, 0.5543, 0.3974]}, {"w": "extend", "b": [0.5603, 0.376, 0.6166, 0.3974]}, {"w": "much", "b": [0.6225, 0.376, 0.6702, 0.3974]}, {"w": "farther", "b": [0.6761, 0.376, 0.7332, 0.3974]}, {"w": "to", "b": [0.7391, 0.376, 0.7561, 0.3974]}, {"w": "the", "b": [0.762, 0.376, 0.7883, 0.3974]}, {"w": "right", "b": [0.7943, 0.376, 0.8344, 0.3974]}, {"w": "of", "b": [0.8403, 0.376, 0.8571, 0.3974]}, {"w": "the", "b": [0.1786, 0.395, 0.2049, 0.4164]}, {"w": "median", "b": [0.2127, 0.395, 0.2758, 0.4164]}, {"w": "than", "b": [0.2836, 0.395, 0.3216, 0.4164]}, {"w": "to", "b": [0.3295, 0.395, 0.3464, 0.4164]}, {"w": "the", "b": [0.3543, 0.395, 0.3806, 0.4164]}, {"w": "left.", "b": [0.3884, 0.395, 0.4198, 0.4164]}, {"w": "This", "b": [0.4277, 0.395, 0.4649, 0.4164]}, {"w": "may", "b": [0.4727, 0.395, 0.5081, 0.4164]}, {"w": "make", "b": [0.5159, 0.395, 0.5613, 0.4164]}, {"w": "it", "b": [0.5691, 0.395, 0.5811, 0.4164]}, {"w": "a", "b": [0.5889, 0.395, 0.5981, 0.4164]}, {"w": "bit", "b": [0.6059, 0.395, 0.6284, 0.4164]}, {"w": "harder", "b": [0.6362, 0.395, 0.6918, 0.4164]}, {"w": "for", "b": [0.6997, 0.395, 0.7242, 0.4164]}, {"w": "some", "b": [0.732, 0.395, 0.7762, 0.4164]}, {"w": "Machine", "b": [0.784, 0.395, 0.8571, 0.4164]}, {"w": "Learning", "b": [0.1786, 0.4141, 0.2536, 0.4355]}, {"w": "algorithms", "b": [0.2595, 0.4141, 0.3498, 0.4355]}, {"w": "to", "b": [0.3557, 0.4141, 0.3727, 0.4355]}, {"w": "detect", "b": [0.3786, 0.4141, 0.4288, 0.4355]}, {"w": "patterns.", "b": [0.4347, 0.4141, 0.5074, 0.4355]}, {"w": "We", "b": [0.5133, 0.4141, 0.5404, 0.4355]}, {"w": "will", "b": [0.5463, 0.4141, 0.5767, 0.4355]}, {"w": "try", "b": [0.5825, 0.4141, 0.6068, 0.4355]}, {"w": "transforming", "b": [0.6127, 0.4141, 0.7233, 0.4355]}, {"w": "these", "b": [0.7291, 0.4141, 0.772, 0.4355]}, {"w": "attributes", "b": [0.7779, 0.4141, 0.8571, 0.4355]}, {"w": "later", "b": [0.1786, 0.4331, 0.2155, 0.4545]}, {"w": "on", "b": [0.2203, 0.4331, 0.2423, 0.4545]}, {"w": "to", "b": [0.247, 0.4331, 0.264, 0.4545]}, {"w": "have", "b": [0.2687, 0.4331, 0.3071, 0.4545]}, {"w": "more", "b": [0.3118, 0.4331, 0.3561, 0.4545]}, {"w": "bell-shaped", "b": [0.3608, 0.4331, 0.4565, 0.4545]}, {"w": "distributions.", "b": [0.4613, 0.4331, 0.5732, 0.4545]}]}, {"id": "b_7", "type": "paragraph", "text": "Hopefully you now have a better understanding of the kind of data you are dealing with.", "words": [{"w": "Hopefully", "b": [0.1429, 0.4673, 0.226, 0.4887]}, {"w": "you", "b": [0.2327, 0.4673, 0.264, 0.4887]}, {"w": "now", "b": [0.2706, 0.4673, 0.3069, 0.4887]}, {"w": "have", "b": [0.3136, 0.4673, 0.352, 0.4887]}, {"w": "a", "b": [0.3587, 0.4673, 0.3678, 0.4887]}, {"w": "better", "b": [0.3745, 0.4673, 0.4232, 0.4887]}, {"w": "understanding", "b": [0.4299, 0.4673, 0.5522, 0.4887]}, {"w": "of", "b": [0.5589, 0.4673, 0.5757, 0.4887]}, {"w": "the", "b": [0.5824, 0.4673, 0.6087, 0.4887]}, {"w": "kind", "b": [0.6154, 0.4673, 0.6537, 0.4887]}, {"w": "of", "b": [0.6604, 0.4673, 0.6772, 0.4887]}, {"w": "data", "b": [0.6839, 0.4673, 0.7191, 0.4887]}, {"w": "you", "b": [0.7258, 0.4673, 0.7571, 0.4887]}, {"w": "are", "b": [0.7637, 0.4673, 0.7895, 0.4887]}, {"w": "dealing", "b": [0.7961, 0.4673, 0.8571, 0.4887]}, {"w": "with.", "b": [0.1429, 0.4863, 0.1849, 0.5077]}]}, {"id": "b_8", "type": "paragraph", "text": "Wait! Before you look at the data any further, you need to create a test set, put it aside, and never look at it.", "words": [{"w": "Wait!", "b": [0.2714, 0.5283, 0.3126, 0.5478]}, {"w": "Before", "b": [0.3181, 0.5283, 0.3683, 0.5478]}, {"w": "you", "b": [0.3739, 0.5283, 0.4024, 0.5478]}, {"w": "look", "b": [0.408, 0.5283, 0.4417, 0.5478]}, {"w": "at", "b": [0.4472, 0.5283, 0.461, 0.5478]}, {"w": "the", "b": [0.4666, 0.5283, 0.4907, 0.5478]}, {"w": "data", "b": [0.4962, 0.5283, 0.5284, 0.5478]}, {"w": "any", "b": [0.534, 0.5283, 0.5611, 0.5478]}, {"w": "further,", "b": [0.5666, 0.5283, 0.6237, 0.5478]}, {"w": "you", "b": [0.6293, 0.5283, 0.6578, 0.5478]}, {"w": "need", "b": [0.6634, 0.5283, 0.7001, 0.5478]}, {"w": "to", "b": [0.7056, 0.5283, 0.7211, 0.5478]}, {"w": "create", "b": [0.7267, 0.5283, 0.7718, 0.5478]}, {"w": "a", "b": [0.7774, 0.5283, 0.7857, 0.5478]}, {"w": "test", "b": [0.2714, 0.5457, 0.2981, 0.5653]}, {"w": "set,", "b": [0.3024, 0.5457, 0.3277, 0.5653]}, {"w": "put", "b": [0.332, 0.5457, 0.3579, 0.5653]}, {"w": "it", "b": [0.3622, 0.5457, 0.3732, 0.5653]}, {"w": "aside,", "b": [0.3775, 0.5457, 0.4204, 0.5653]}, {"w": "and", "b": [0.4248, 0.5457, 0.4536, 0.5653]}, {"w": "never", "b": [0.4579, 0.5457, 0.5004, 0.5653]}, {"w": "look", "b": [0.5047, 0.5457, 0.5384, 0.5653]}, {"w": "at", "b": [0.5428, 0.5457, 0.5566, 0.5653]}, {"w": "it.", "b": [0.5609, 0.5457, 0.5761, 0.5653]}]}, {"id": "b_9", "type": "paragraph", "text": "Create a Test Set", "words": [{"w": "Create", "b": [0.1428, 0.6242, 0.2094, 0.6527]}, {"w": "a", "b": [0.2144, 0.6242, 0.2268, 0.6527]}, {"w": "Test", "b": [0.2317, 0.6242, 0.2744, 0.6527]}, {"w": "Set", "b": [0.2793, 0.6242, 0.3125, 0.6527]}]}, {"id": "b_10", "type": "paragraph", "text": "It may sound strange to voluntarily set aside part of the data at this stage. After all, you have only taken a quick glance at the data, and surely you should learn a whole lot more about it before you decide what algorithms to use, right? This is true, but your brain is an amazing pattern detection system, which means that it is highly prone to overfitting: if you look at the test set, you may stumble upon some seemingly interesting pattern in the test data that leads you to select a particular kind of Machine Learning model. When you estimate the generalization error using the test set, your estimate will be too optimistic and you will launch a system that will not perform as well as expected. This is called data snooping bias.", "words": [{"w": "It", "b": [0.1429, 0.6586, 0.1555, 0.68]}, {"w": "may", "b": [0.1622, 0.6586, 0.1976, 0.68]}, {"w": "sound", "b": [0.2043, 0.6586, 0.2561, 0.68]}, {"w": "strange", "b": [0.2628, 0.6586, 0.3237, 0.68]}, {"w": "to", "b": [0.3304, 0.6586, 0.3474, 0.68]}, {"w": "voluntarily", "b": [0.3541, 0.6586, 0.4453, 0.68]}, {"w": "set", "b": [0.4521, 0.6586, 0.4749, 0.68]}, {"w": "aside", "b": [0.4816, 0.6586, 0.5239, 0.68]}, {"w": "part", "b": [0.5306, 0.6586, 0.5647, 0.68]}, {"w": "of", "b": [0.5715, 0.6586, 0.5883, 0.68]}, {"w": "the", "b": [0.595, 0.6586, 0.6213, 0.68]}, {"w": "data", "b": [0.628, 0.6586, 0.6633, 0.68]}, {"w": "at", "b": [0.67, 0.6586, 0.6851, 0.68]}, {"w": "this", "b": [0.6918, 0.6586, 0.7225, 0.68]}, {"w": "stage.", "b": [0.7293, 0.6586, 0.7758, 0.68]}, {"w": "After", "b": [0.7825, 0.6586, 0.826, 0.68]}, {"w": "all,", "b": [0.8327, 0.6586, 0.8571, 0.68]}, {"w": "you", "b": [0.1429, 0.6777, 0.1741, 0.6991]}, {"w": "have", "b": [0.1804, 0.6777, 0.2188, 0.6991]}, {"w": "only", "b": [0.225, 0.6777, 0.2619, 0.6991]}, {"w": "taken", "b": [0.2681, 0.6777, 0.3142, 0.6991]}, {"w": "a", "b": [0.3205, 0.6777, 0.3296, 0.6991]}, {"w": "quick", "b": [0.3359, 0.6777, 0.3823, 0.6991]}, {"w": "glance", "b": [0.3886, 0.6777, 0.4418, 0.6991]}, {"w": "at", "b": [0.4481, 0.6777, 0.4632, 0.6991]}, {"w": "the", "b": [0.4694, 0.6777, 0.4957, 0.6991]}, {"w": "data,", "b": [0.502, 0.6777, 0.542, 0.6991]}, {"w": "and", "b": [0.5483, 0.6777, 0.5798, 0.6991]}, {"w": "surely", "b": [0.5861, 0.6777, 0.6362, 0.6991]}, {"w": "you", "b": [0.6424, 0.6777, 0.6737, 0.6991]}, {"w": "should", "b": [0.68, 0.6777, 0.7367, 0.6991]}, {"w": "learn", "b": [0.7429, 0.6777, 0.7853, 0.6991]}, {"w": "a", "b": [0.7916, 0.6777, 0.8007, 0.6991]}, {"w": "whole", "b": [0.807, 0.6777, 0.8571, 0.6991]}, {"w": "lot", "b": [0.1428, 0.6967, 0.1651, 0.7181]}, {"w": "more", "b": [0.1721, 0.6967, 0.2163, 0.7181]}, {"w": "about", "b": [0.2233, 0.6967, 0.2711, 0.7181]}, {"w": "it", "b": [0.2781, 0.6967, 0.29, 0.7181]}, {"w": "before", "b": [0.297, 0.6967, 0.3498, 0.7181]}, {"w": "you", "b": [0.3567, 0.6967, 0.388, 0.7181]}, {"w": "decide", "b": [0.395, 0.6967, 0.4491, 0.7181]}, {"w": "what", "b": [0.456, 0.6967, 0.4965, 0.7181]}, {"w": "algorithms", "b": [0.5035, 0.6967, 0.5938, 0.7181]}, {"w": "to", "b": [0.6008, 0.6967, 0.6178, 0.7181]}, {"w": "use,", "b": [0.6247, 0.6967, 0.657, 0.7181]}, {"w": "right?", "b": [0.664, 0.6967, 0.7121, 0.7181]}, {"w": "This", "b": [0.719, 0.6967, 0.7562, 0.7181]}, {"w": "is", "b": [0.7632, 0.6967, 0.7764, 0.7181]}, {"w": "true,", "b": [0.7834, 0.6967, 0.8222, 0.7181]}, {"w": "but", "b": [0.8291, 0.6967, 0.8571, 0.7181]}, {"w": "your", "b": [0.1429, 0.7158, 0.1818, 0.7372]}, {"w": "brain", "b": [0.1904, 0.7158, 0.2348, 0.7372]}, {"w": "is", "b": [0.2434, 0.7158, 0.2566, 0.7372]}, {"w": "an", "b": [0.2651, 0.7158, 0.2857, 0.7372]}, {"w": "amazing", "b": [0.2942, 0.7158, 0.365, 0.7372]}, {"w": "pattern", "b": [0.3736, 0.7158, 0.4339, 0.7372]}, {"w": "detection", "b": [0.4425, 0.7158, 0.5203, 0.7372]}, {"w": "system,", "b": [0.5288, 0.7158, 0.5907, 0.7372]}, {"w": "which", "b": [0.5993, 0.7158, 0.6502, 0.7372]}, {"w": "means", "b": [0.6587, 0.7158, 0.7128, 0.7372]}, {"w": "that", "b": [0.7214, 0.7158, 0.7539, 0.7372]}, {"w": "it", "b": [0.7625, 0.7158, 0.7744, 0.7372]}, {"w": "is", "b": [0.783, 0.7158, 0.7962, 0.7372]}, {"w": "highly", "b": [0.8047, 0.7158, 0.8571, 0.7372]}, {"w": "prone", "b": [0.1429, 0.7348, 0.1924, 0.7562]}, {"w": "to", "b": [0.1971, 0.7348, 0.2141, 0.7562]}, {"w": "overfitting:", "b": [0.2189, 0.7348, 0.3116, 0.7562]}, {"w": "if", "b": [0.3164, 0.7348, 0.3281, 0.7562]}, {"w": "you", "b": [0.3329, 0.7348, 0.3641, 0.7562]}, {"w": "look", "b": [0.3688, 0.7348, 0.4057, 0.7562]}, {"w": "at", "b": [0.4104, 0.7348, 0.4255, 0.7562]}, {"w": "the", "b": [0.4303, 0.7348, 0.4566, 0.7562]}, {"w": "test", "b": [0.4613, 0.7348, 0.4905, 0.7562]}, {"w": "set,", "b": [0.4953, 0.7348, 0.5229, 0.7562]}, {"w": "you", "b": [0.5276, 0.7348, 0.5588, 0.7562]}, {"w": "may", "b": [0.5636, 0.7348, 0.599, 0.7562]}, {"w": "stumble", "b": [0.6037, 0.7348, 0.6705, 0.7562]}, {"w": "upon", "b": [0.6753, 0.7348, 0.7193, 0.7562]}, {"w": "some", "b": [0.724, 0.7348, 0.7682, 0.7562]}, {"w": "seemingly", "b": [0.7729, 0.7348, 0.8569, 0.7562]}, {"w": "interesting", "b": [0.1429, 0.7539, 0.232, 0.7753]}, {"w": "pattern", "b": [0.2421, 0.7539, 0.3025, 0.7753]}, {"w": "in", "b": [0.3127, 0.7539, 0.3297, 0.7753]}, {"w": "the", "b": [0.3398, 0.7539, 0.3662, 0.7753]}, {"w": "test", "b": [0.3764, 0.7539, 0.4056, 0.7753]}, {"w": "data", "b": [0.4157, 0.7539, 0.451, 0.7753]}, {"w": "that", "b": [0.4612, 0.7539, 0.4938, 0.7753]}, {"w": "leads", "b": [0.5039, 0.7539, 0.5459, 0.7753]}, {"w": "you", "b": [0.556, 0.7539, 0.5873, 0.7753]}, {"w": "to", "b": [0.5975, 0.7539, 0.6144, 0.7753]}, {"w": "select", "b": [0.6246, 0.7539, 0.6704, 0.7753]}, {"w": "a", "b": [0.6806, 0.7539, 0.6897, 0.7753]}, {"w": "particular", "b": [0.6999, 0.7539, 0.7817, 0.7753]}, {"w": "kind", "b": [0.7919, 0.7539, 0.8302, 0.7753]}, {"w": "of", "b": [0.8404, 0.7539, 0.8571, 0.7753]}, {"w": "Machine", "b": [0.1429, 0.7729, 0.216, 0.7943]}, {"w": "Learning", "b": [0.2222, 0.7729, 0.2972, 0.7943]}, {"w": "model.", "b": [0.3034, 0.7729, 0.361, 0.7943]}, {"w": "When", "b": [0.3672, 0.7729, 0.4188, 0.7943]}, {"w": "you", "b": [0.425, 0.7729, 0.4563, 0.7943]}, {"w": "estimate", "b": [0.4625, 0.7729, 0.5319, 0.7943]}, {"w": "the", "b": [0.5381, 0.7729, 0.5644, 0.7943]}, {"w": "generalization", "b": [0.5706, 0.7729, 0.6887, 0.7943]}, {"w": "error", "b": [0.6949, 0.7729, 0.7376, 0.7943]}, {"w": "using", "b": [0.7438, 0.7729, 0.7892, 0.7943]}, {"w": "the", "b": [0.7954, 0.7729, 0.8217, 0.7943]}, {"w": "test", "b": [0.8279, 0.7729, 0.8571, 0.7943]}, {"w": "set,", "b": [0.1429, 0.792, 0.1705, 0.8134]}, {"w": "your", "b": [0.1777, 0.792, 0.2167, 0.8134]}, {"w": "estimate", "b": [0.224, 0.792, 0.2934, 0.8134]}, {"w": "will", "b": [0.3007, 0.792, 0.3311, 0.8134]}, {"w": "be", "b": [0.3384, 0.792, 0.3578, 0.8134]}, {"w": "too", "b": [0.3651, 0.792, 0.3927, 0.8134]}, {"w": "optimistic", "b": [0.4, 0.792, 0.4845, 0.8134]}, {"w": "and", "b": [0.4918, 0.792, 0.5233, 0.8134]}, {"w": "you", "b": [0.5306, 0.792, 0.5618, 0.8134]}, {"w": "will", "b": [0.5691, 0.792, 0.5995, 0.8134]}, {"w": "launch", "b": [0.6068, 0.792, 0.6632, 0.8134]}, {"w": "a", "b": [0.6704, 0.792, 0.6796, 0.8134]}, {"w": "system", "b": [0.6869, 0.792, 0.744, 0.8134]}, {"w": "that", "b": [0.7513, 0.792, 0.7838, 0.8134]}, {"w": "will", "b": [0.7911, 0.792, 0.8215, 0.8134]}, {"w": "not", "b": [0.8288, 0.792, 0.8572, 0.8134]}, {"w": "perform", "b": [0.1429, 0.811, 0.2119, 0.8324]}, {"w": "as", "b": [0.2167, 0.811, 0.2335, 0.8324]}, {"w": "well", "b": [0.2382, 0.811, 0.2719, 0.8324]}, {"w": "as", "b": [0.2766, 0.811, 0.2934, 0.8324]}, {"w": "expected.", "b": [0.2981, 0.811, 0.3763, 0.8324]}, {"w": "This", "b": [0.3811, 0.811, 0.4183, 0.8324]}, {"w": "is", "b": [0.423, 0.811, 0.4362, 0.8324]}, {"w": "called", "b": [0.441, 0.811, 0.4893, 0.8324]}, {"w": "data", "b": [0.494, 0.8108, 0.5307, 0.8324]}, {"w": "snooping", "b": [0.5355, 0.8108, 0.6074, 0.8324]}, {"w": "bias.", "b": [0.6122, 0.811, 0.6499, 0.8324]}]}, {"id": "b_11", "type": "paragraph", "text": "Creating a test set is theoretically quite simple: just pick some instances randomly, typically 20% of the dataset (or less if your dataset is very large), and set them aside:", "words": [{"w": "Creating", "b": [0.1429, 0.8391, 0.2151, 0.8605]}, {"w": "a", "b": [0.2226, 0.8391, 0.2318, 0.8605]}, {"w": "test", "b": [0.2392, 0.8391, 0.2684, 0.8605]}, {"w": "set", "b": [0.2759, 0.8391, 0.2988, 0.8605]}, {"w": "is", "b": [0.3063, 0.8391, 0.3195, 0.8605]}, {"w": "theoretically", "b": [0.327, 0.8391, 0.4305, 0.8605]}, {"w": "quite", "b": [0.438, 0.8391, 0.4805, 0.8605]}, {"w": "simple:", "b": [0.488, 0.8391, 0.5477, 0.8605]}, {"w": "just", "b": [0.5551, 0.8391, 0.5855, 0.8605]}, {"w": "pick", "b": [0.593, 0.8391, 0.6287, 0.8605]}, {"w": "some", "b": [0.6361, 0.8391, 0.6803, 0.8605]}, {"w": "instances", "b": [0.6878, 0.8391, 0.7646, 0.8605]}, {"w": "randomly,", "b": [0.7721, 0.8391, 0.8571, 0.8605]}, {"w": "typically", "b": [0.1429, 0.8582, 0.2133, 0.8796]}, {"w": "20%", "b": [0.2181, 0.8582, 0.2538, 0.8796]}, {"w": "of", "b": [0.2585, 0.8582, 0.2753, 0.8796]}, {"w": "the", "b": [0.2801, 0.8582, 0.3064, 0.8796]}, {"w": "dataset", "b": [0.3111, 0.8582, 0.3692, 0.8796]}, {"w": "(or", "b": [0.374, 0.8582, 0.3995, 0.8796]}, {"w": "less", "b": [0.4043, 0.8582, 0.4337, 0.8796]}, {"w": "if", "b": [0.4384, 0.8582, 0.4501, 0.8796]}, {"w": "your", "b": [0.4549, 0.8582, 0.4939, 0.8796]}, {"w": "dataset", "b": [0.4986, 0.8582, 0.5567, 0.8796]}, {"w": "is", "b": [0.5614, 0.8582, 0.5746, 0.8796]}, {"w": "very", "b": [0.5794, 0.8582, 0.6158, 0.8796]}, {"w": "large),", "b": [0.6205, 0.8582, 0.6732, 0.8796]}, {"w": "and", "b": [0.6779, 0.8582, 0.7095, 0.8796]}, {"w": "set", "b": [0.7142, 0.8582, 0.7371, 0.8796]}, {"w": "them", "b": [0.7418, 0.8582, 0.7852, 0.8796]}, {"w": "aside:", "b": [0.7899, 0.8582, 0.8369, 0.8796]}]}, {"id": "b_12", "type": "equation", "text": "54 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "54", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 81, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "13 In this book, when a code example contains a mix of code and outputs, as is the case here, it is formatted like in the Python interpreter, for better readability: the code lines are prefixed with >>> (or ... for indented blocks), and the outputs have no prefix.", "words": [{"w": "13", "b": [0.1385, 0.8104, 0.1518, 0.8246]}, {"w": "In", "b": [0.1587, 0.8089, 0.1728, 0.8252]}, {"w": "this", "b": [0.1764, 0.8089, 0.1998, 0.8252]}, {"w": "book,", "b": [0.2034, 0.8089, 0.2392, 0.8252]}, {"w": "when", "b": [0.2428, 0.8089, 0.2776, 0.8252]}, {"w": "a", "b": [0.2812, 0.8089, 0.2881, 0.8252]}, {"w": "code", "b": [0.2917, 0.8089, 0.3217, 0.8252]}, {"w": "example", "b": [0.3253, 0.8089, 0.3783, 0.8252]}, {"w": "contains", "b": [0.3819, 0.8089, 0.4356, 0.8252]}, {"w": "a", "b": [0.4392, 0.8089, 0.4462, 0.8252]}, {"w": "mix", "b": [0.4498, 0.8089, 0.4745, 0.8252]}, {"w": "of", "b": [0.4781, 0.8089, 0.4909, 0.8252]}, {"w": "code", "b": [0.4945, 0.8089, 0.5245, 0.8252]}, {"w": "and", "b": [0.5281, 0.8089, 0.5521, 0.8252]}, {"w": "outputs,", "b": [0.5557, 0.8089, 0.6081, 0.8252]}, {"w": "as", "b": [0.6117, 0.8089, 0.6245, 0.8252]}, {"w": "is", "b": [0.6281, 0.8089, 0.6382, 0.8252]}, {"w": "the", "b": [0.6418, 0.8089, 0.6619, 0.8252]}, {"w": "case", "b": [0.6655, 0.8089, 0.6917, 0.8252]}, {"w": "here,", "b": [0.6953, 0.8089, 0.7268, 0.8252]}, {"w": "it", "b": [0.7304, 0.8089, 0.7395, 0.8252]}, {"w": "is", "b": [0.7431, 0.8089, 0.7532, 0.8252]}, {"w": "formatted", "b": [0.7568, 0.8089, 0.8199, 0.8252]}, {"w": "like", "b": [0.8235, 0.8089, 0.8464, 0.8252]}, {"w": "in", "b": [0.1587, 0.825, 0.1717, 0.8413]}, {"w": "the", "b": [0.1753, 0.825, 0.1953, 0.8413]}, {"w": "Python", "b": [0.1989, 0.825, 0.2453, 0.8413]}, {"w": "interpreter,", "b": [0.2489, 0.825, 0.32, 0.8413]}, {"w": "for", "b": [0.3236, 0.825, 0.3423, 0.8413]}, {"w": "better", "b": [0.3459, 0.825, 0.383, 0.8413]}, {"w": "readability:", "b": [0.3866, 0.825, 0.4584, 0.8413]}, {"w": "the", "b": [0.462, 0.825, 0.4821, 0.8413]}, {"w": "code", "b": [0.4857, 0.825, 0.5156, 0.8413]}, {"w": "lines", "b": [0.5192, 0.825, 0.5487, 0.8413]}, {"w": "are", "b": [0.5523, 0.825, 0.572, 0.8413]}, {"w": "prefixed", "b": [0.5756, 0.825, 0.6281, 0.8413]}, {"w": "with", "b": [0.6317, 0.825, 0.6601, 0.8413]}, {"w": ">>>", "b": [0.6637, 0.8274, 0.6863, 0.8389]}, {"w": "(or", "b": [0.69, 0.825, 0.7094, 0.8413]}, {"w": "...", "b": [0.713, 0.8274, 0.7357, 0.8389]}, {"w": "for", "b": [0.7393, 0.825, 0.7579, 0.8413]}, {"w": "indented", "b": [0.7615, 0.825, 0.818, 0.8413]}, {"w": "blocks),", "b": [0.1587, 0.8401, 0.2084, 0.8565]}, {"w": "and", "b": [0.212, 0.8401, 0.2361, 0.8565]}, {"w": "the", "b": [0.2397, 0.8401, 0.2597, 0.8565]}, {"w": "outputs", "b": [0.2633, 0.8401, 0.3121, 0.8565]}, {"w": "have", "b": [0.3157, 0.8401, 0.345, 0.8565]}, {"w": "no", "b": [0.3486, 0.8401, 0.3653, 0.8565]}, {"w": "prefix.", "b": [0.369, 0.8401, 0.41, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "14 You will often see people set the random seed to 42. This number has no special property, other than to be The Answer to the Ultimate Question of Life, the Universe, and Everything.", "words": [{"w": "14", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "You", "b": [0.1587, 0.8598, 0.1834, 0.8761]}, {"w": "will", "b": [0.187, 0.8598, 0.2101, 0.8761]}, {"w": "often", "b": [0.2137, 0.8598, 0.2468, 0.8761]}, {"w": "see", "b": [0.2504, 0.8598, 0.2697, 0.8761]}, {"w": "people", "b": [0.2733, 0.8598, 0.3156, 0.8761]}, {"w": "set", "b": [0.3192, 0.8598, 0.3366, 0.8761]}, {"w": "the", "b": [0.3402, 0.8598, 0.3603, 0.8761]}, {"w": "random", "b": [0.3639, 0.8598, 0.4149, 0.8761]}, {"w": "seed", "b": [0.4185, 0.8598, 0.4462, 0.8761]}, {"w": "to", "b": [0.4498, 0.8598, 0.4627, 0.8761]}, {"w": "42.", "b": [0.4663, 0.8598, 0.4852, 0.8761]}, {"w": "This", "b": [0.4888, 0.8598, 0.5171, 0.8761]}, {"w": "number", "b": [0.5207, 0.8598, 0.5712, 0.8761]}, {"w": "has", "b": [0.5748, 0.8598, 0.5961, 0.8761]}, {"w": "no", "b": [0.5997, 0.8598, 0.6165, 0.8761]}, {"w": "special", "b": [0.6201, 0.8598, 0.6629, 0.8761]}, {"w": "property,", "b": [0.6665, 0.8598, 0.7244, 0.8761]}, {"w": "other", "b": [0.728, 0.8598, 0.762, 0.8761]}, {"w": "than", "b": [0.7656, 0.8598, 0.7946, 0.8761]}, {"w": "to", "b": [0.7982, 0.8598, 0.8111, 0.8761]}, {"w": "be", "b": [0.8147, 0.8598, 0.8296, 0.8761]}, {"w": "The", "b": [0.1587, 0.8749, 0.1837, 0.8912]}, {"w": "Answer", "b": [0.1873, 0.8749, 0.2363, 0.8912]}, {"w": "to", "b": [0.2399, 0.8749, 0.2529, 0.8912]}, {"w": "the", "b": [0.2565, 0.8749, 0.2765, 0.8912]}, {"w": "Ultimate", "b": [0.2801, 0.8749, 0.3362, 0.8912]}, {"w": "Question", "b": [0.3398, 0.8749, 0.3985, 0.8912]}, {"w": "of", "b": [0.4021, 0.8749, 0.4149, 0.8912]}, {"w": "Life,", "b": [0.4185, 0.8749, 0.4463, 0.8912]}, {"w": "the", "b": [0.45, 0.8749, 0.47, 0.8912]}, {"w": "Universe,", "b": [0.4736, 0.8749, 0.5337, 0.8912]}, {"w": "and", "b": [0.5373, 0.8749, 0.5614, 0.8912]}, {"w": "Everything.", "b": [0.565, 0.8749, 0.6387, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "import numpy as np", "words": [{"w": "import", "b": [0.1766, 0.0829, 0.2272, 0.0958]}, {"w": "numpy", "b": [0.2356, 0.0829, 0.2778, 0.0958]}, {"w": "as", "b": [0.2862, 0.0829, 0.3031, 0.0958]}, {"w": "np", "b": [0.3115, 0.0829, 0.3284, 0.0958]}]}, {"id": "b_3", "type": "paragraph", "text": "def split_train_test(data, test_ratio): shuffled_indices = np.random.permutation(len(data)) test_set_size = int(len(data) * test_ratio) test_indices = shuffled_indices[:test_set_size] train_indices = shuffled_indices[test_set_size:] return data.iloc[train_indices], data.iloc[test_indices]", "words": [{"w": "def", "b": [0.1766, 0.1138, 0.2019, 0.1266]}, {"w": "split_train_test(data,", "b": [0.2103, 0.1138, 0.3958, 0.1266]}, {"w": "test_ratio):", "b": [0.4043, 0.1138, 0.5055, 0.1266]}, {"w": "shuffled_indices", "b": [0.2103, 0.1292, 0.3452, 0.142]}, {"w": "=", "b": [0.3537, 0.1292, 0.3621, 0.142]}, {"w": "np.random.permutation(len(data))", "b": [0.3705, 0.1292, 0.6404, 0.142]}, {"w": "test_set_size", "b": [0.2103, 0.1446, 0.3199, 0.1574]}, {"w": "=", "b": [0.3284, 0.1446, 0.3368, 0.1574]}, {"w": "int(len(data)", "b": [0.3452, 0.1446, 0.4549, 0.1574]}, {"w": "*", "b": [0.4633, 0.1446, 0.4717, 0.1574]}, {"w": "test_ratio)", "b": [0.4802, 0.1446, 0.5729, 0.1574]}, {"w": "test_indices", "b": [0.2103, 0.16, 0.3115, 0.1729]}, {"w": "=", "b": [0.3199, 0.16, 0.3284, 0.1729]}, {"w": "shuffled_indices[:test_set_size]", "b": [0.3368, 0.16, 0.6067, 0.1729]}, {"w": "train_indices", "b": [0.2103, 0.1754, 0.3199, 0.1883]}, {"w": "=", "b": [0.3284, 0.1754, 0.3368, 0.1883]}, {"w": "shuffled_indices[test_set_size:]", "b": [0.3452, 0.1754, 0.6151, 0.1883]}, {"w": "return", "b": [0.2103, 0.1909, 0.2609, 0.2037]}, {"w": "data.iloc[train_indices],", "b": [0.2694, 0.1909, 0.4802, 0.2037]}, {"w": "data.iloc[test_indices]", "b": [0.4886, 0.1909, 0.6825, 0.2037]}]}, {"id": "b_4", "type": "paragraph", "text": "You can then use this function like this:13", "words": [{"w": "You", "b": [0.1429, 0.2115, 0.1752, 0.2329]}, {"w": "can", "b": [0.1799, 0.2115, 0.2093, 0.2329]}, {"w": "then", "b": [0.214, 0.2115, 0.2518, 0.2329]}, {"w": "use", "b": [0.2565, 0.2115, 0.284, 0.2329]}, {"w": "this", "b": [0.2888, 0.2115, 0.3195, 0.2329]}, {"w": "function", "b": [0.3242, 0.2115, 0.3956, 0.2329]}, {"w": "like", "b": [0.4003, 0.2115, 0.4304, 0.2329]}, {"w": "this:13", "b": [0.4351, 0.2115, 0.482, 0.2329]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> train_set, test_set = split_train_test(housing, 0.2) >>> len(train_set) 16512 >>> len(test_set) 4128", "words": [{"w": ">>>", "b": [0.1766, 0.2435, 0.2019, 0.2563]}, {"w": "train_set,", "b": [0.2103, 0.2435, 0.2946, 0.2563]}, {"w": "test_set", "b": [0.3031, 0.2435, 0.3705, 0.2563]}, {"w": "=", "b": [0.379, 0.2435, 0.3874, 0.2563]}, {"w": "split_train_test(housing,", "b": [0.3958, 0.2435, 0.6066, 0.2563]}, {"w": "0.2)", "b": [0.6151, 0.2435, 0.6488, 0.2563]}, {"w": ">>>", "b": [0.1766, 0.2589, 0.2019, 0.2717]}, {"w": "len(train_set)", "b": [0.2103, 0.2589, 0.3284, 0.2717]}, {"w": "16512", "b": [0.1766, 0.2743, 0.2188, 0.2872]}, {"w": ">>>", "b": [0.1766, 0.2897, 0.2019, 0.3026]}, {"w": "len(test_set)", "b": [0.2103, 0.2897, 0.3199, 0.3026]}, {"w": "4128", "b": [0.1766, 0.3051, 0.2103, 0.318]}]}, {"id": "b_6", "type": "paragraph", "text": "Well, this works, but it is not perfect: if you run the program again, it will generate a different test set! Over time, you (or your Machine Learning algorithms) will get to see the whole dataset, which is what you want to avoid.", "words": [{"w": "Well,", "b": [0.1429, 0.3258, 0.1852, 0.3472]}, {"w": "this", "b": [0.191, 0.3258, 0.2217, 0.3472]}, {"w": "works,", "b": [0.2274, 0.3258, 0.2828, 0.3472]}, {"w": "but", "b": [0.2885, 0.3258, 0.3165, 0.3472]}, {"w": "it", "b": [0.3222, 0.3258, 0.3342, 0.3472]}, {"w": "is", "b": [0.3399, 0.3258, 0.3532, 0.3472]}, {"w": "not", "b": [0.3589, 0.3258, 0.3873, 0.3472]}, {"w": "perfect:", "b": [0.393, 0.3258, 0.4555, 0.3472]}, {"w": "if", "b": [0.4612, 0.3258, 0.4729, 0.3472]}, {"w": "you", "b": [0.4787, 0.3258, 0.5099, 0.3472]}, {"w": "run", "b": [0.5157, 0.3258, 0.5459, 0.3472]}, {"w": "the", "b": [0.5516, 0.3258, 0.5779, 0.3472]}, {"w": "program", "b": [0.5837, 0.3258, 0.6566, 0.3472]}, {"w": "again,", "b": [0.6624, 0.3258, 0.7122, 0.3472]}, {"w": "it", "b": [0.7179, 0.3258, 0.7298, 0.3472]}, {"w": "will", "b": [0.7356, 0.3258, 0.766, 0.3472]}, {"w": "generate", "b": [0.7717, 0.3258, 0.8423, 0.3472]}, {"w": "a", "b": [0.848, 0.3258, 0.8571, 0.3472]}, {"w": "different", "b": [0.1429, 0.3448, 0.2146, 0.3662]}, {"w": "test", "b": [0.2212, 0.3448, 0.2504, 0.3662]}, {"w": "set!", "b": [0.257, 0.3448, 0.2856, 0.3662]}, {"w": "Over", "b": [0.2923, 0.3448, 0.3344, 0.3662]}, {"w": "time,", "b": [0.341, 0.3448, 0.3836, 0.3662]}, {"w": "you", "b": [0.3903, 0.3448, 0.4215, 0.3662]}, {"w": "(or", "b": [0.4282, 0.3448, 0.4537, 0.3662]}, {"w": "your", "b": [0.4604, 0.3448, 0.4993, 0.3662]}, {"w": "Machine", "b": [0.506, 0.3448, 0.5791, 0.3662]}, {"w": "Learning", "b": [0.5857, 0.3448, 0.6608, 0.3662]}, {"w": "algorithms)", "b": [0.6674, 0.3448, 0.7649, 0.3662]}, {"w": "will", "b": [0.7715, 0.3448, 0.8019, 0.3662]}, {"w": "get", "b": [0.8086, 0.3448, 0.8335, 0.3662]}, {"w": "to", "b": [0.8402, 0.3448, 0.8571, 0.3662]}, {"w": "see", "b": [0.1428, 0.3639, 0.1682, 0.3853]}, {"w": "the", "b": [0.1729, 0.3639, 0.1993, 0.3853]}, {"w": "whole", "b": [0.204, 0.3639, 0.2541, 0.3853]}, {"w": "dataset,", "b": [0.2589, 0.3639, 0.3217, 0.3853]}, {"w": "which", "b": [0.3265, 0.3639, 0.3774, 0.3853]}, {"w": "is", "b": [0.3821, 0.3639, 0.3953, 0.3853]}, {"w": "what", "b": [0.4001, 0.3639, 0.4406, 0.3853]}, {"w": "you", "b": [0.4453, 0.3639, 0.4765, 0.3853]}, {"w": "want", "b": [0.4813, 0.3639, 0.522, 0.3853]}, {"w": "to", "b": [0.5268, 0.3639, 0.5437, 0.3853]}, {"w": "avoid.", "b": [0.5485, 0.3639, 0.5988, 0.3853]}]}, {"id": "b_7", "type": "paragraph", "text": "One solution is to save the test set on the first run and then load it in subsequent runs. Another option is to set the random number generator’s seed (e.g., np.ran dom.seed(42))14 before calling np.random.permutation(), so that it always generates the same shuffled indices.", "words": [{"w": "One", "b": [0.1428, 0.392, 0.1787, 0.4134]}, {"w": "solution", "b": [0.1861, 0.392, 0.2547, 0.4134]}, {"w": "is", "b": [0.2621, 0.392, 0.2753, 0.4134]}, {"w": "to", "b": [0.2828, 0.392, 0.2997, 0.4134]}, {"w": "save", "b": [0.3072, 0.392, 0.3421, 0.4134]}, {"w": "the", "b": [0.3495, 0.392, 0.3759, 0.4134]}, {"w": "test", "b": [0.3833, 0.392, 0.4125, 0.4134]}, {"w": "set", "b": [0.42, 0.392, 0.4428, 0.4134]}, {"w": "on", "b": [0.4502, 0.392, 0.4723, 0.4134]}, {"w": "the", "b": [0.4797, 0.392, 0.506, 0.4134]}, {"w": "first", "b": [0.5135, 0.392, 0.5469, 0.4134]}, {"w": "run", "b": [0.5544, 0.392, 0.5846, 0.4134]}, {"w": "and", "b": [0.592, 0.392, 0.6236, 0.4134]}, {"w": "then", "b": [0.631, 0.392, 0.6687, 0.4134]}, {"w": "load", "b": [0.6762, 0.392, 0.7122, 0.4134]}, {"w": "it", "b": [0.7196, 0.392, 0.7316, 0.4134]}, {"w": "in", "b": [0.739, 0.392, 0.756, 0.4134]}, {"w": "subsequent", "b": [0.7634, 0.392, 0.8571, 0.4134]}, {"w": "runs.", "b": [0.1429, 0.4119, 0.1854, 0.4333]}, {"w": "Another", "b": [0.1941, 0.4119, 0.2645, 0.4333]}, {"w": "option", "b": [0.2731, 0.4119, 0.3286, 0.4333]}, {"w": "is", "b": [0.3372, 0.4119, 0.3505, 0.4333]}, {"w": "to", "b": [0.3591, 0.4119, 0.3761, 0.4333]}, {"w": "set", "b": [0.3847, 0.4119, 0.4075, 0.4333]}, {"w": "the", "b": [0.4161, 0.4119, 0.4424, 0.4333]}, {"w": "random", "b": [0.4511, 0.4119, 0.518, 0.4333]}, {"w": "number", "b": [0.5266, 0.4119, 0.5929, 0.4333]}, {"w": "generator’s", "b": [0.6015, 0.4119, 0.6919, 0.4333]}, {"w": "seed", "b": [0.7005, 0.4119, 0.7368, 0.4333]}, {"w": "(e.g.,", "b": [0.7454, 0.4119, 0.7855, 0.4333]}, {"w": "np.ran", "b": [0.7941, 0.4151, 0.8535, 0.4302]}, {"w": "dom.seed(42))14", "b": [0.1429, 0.4319, 0.2802, 0.4533]}, {"w": "before", "b": [0.2853, 0.4319, 0.3382, 0.4533]}, {"w": "calling", "b": [0.3433, 0.4319, 0.3985, 0.4533]}, {"w": "np.random.permutation(),", "b": [0.4036, 0.4319, 0.636, 0.4533]}, {"w": "so", "b": [0.6411, 0.4319, 0.6593, 0.4533]}, {"w": "that", "b": [0.6644, 0.4319, 0.697, 0.4533]}, {"w": "it", "b": [0.7021, 0.4319, 0.7141, 0.4533]}, {"w": "always", "b": [0.7192, 0.4319, 0.7738, 0.4533]}, {"w": "generates", "b": [0.779, 0.4319, 0.8571, 0.4533]}, {"w": "the", "b": [0.1429, 0.4509, 0.1692, 0.4723]}, {"w": "same", "b": [0.1739, 0.4509, 0.2166, 0.4723]}, {"w": "shuffled", "b": [0.2214, 0.4509, 0.2883, 0.4723]}, {"w": "indices.", "b": [0.293, 0.4509, 0.3566, 0.4723]}]}, {"id": "b_8", "type": "paragraph", "text": "But both these solutions will break next time you fetch an updated dataset. A com‐ mon solution is to use each instance’s identifier to decide whether or not it should go in the test set (assuming instances have a unique and immutable identifier). For example, you could compute a hash of each instance’s identifier and put that instance in the test set if the hash is lower or equal to 20% of the maximum hash value. This ensures that the test set will remain consistent across multiple runs, even if you refresh the dataset. The new test set will contain 20% of the new instances, but it will not contain any instance that was previously in the training set. Here is a possible implementation:", "words": [{"w": "But", "b": [0.1429, 0.479, 0.1725, 0.5005]}, {"w": "both", "b": [0.1792, 0.479, 0.2179, 0.5005]}, {"w": "these", "b": [0.2246, 0.479, 0.2674, 0.5005]}, {"w": "solutions", "b": [0.2741, 0.479, 0.3503, 0.5005]}, {"w": "will", "b": [0.3569, 0.479, 0.3873, 0.5005]}, {"w": "break", "b": [0.394, 0.479, 0.4406, 0.5005]}, {"w": "next", "b": [0.4473, 0.479, 0.4838, 0.5005]}, {"w": "time", "b": [0.4904, 0.479, 0.5283, 0.5005]}, {"w": "you", "b": [0.5349, 0.479, 0.5662, 0.5005]}, {"w": "fetch", "b": [0.5729, 0.479, 0.6142, 0.5005]}, {"w": "an", "b": [0.6208, 0.479, 0.6414, 0.5005]}, {"w": "updated", "b": [0.648, 0.479, 0.716, 0.5005]}, {"w": "dataset.", "b": [0.7227, 0.479, 0.7855, 0.5005]}, {"w": "A", "b": [0.7922, 0.479, 0.8066, 0.5005]}, {"w": "com‐", "b": [0.8132, 0.479, 0.8572, 0.5005]}, {"w": "mon", "b": [0.1429, 0.4981, 0.1819, 0.5195]}, {"w": "solution", "b": [0.1873, 0.4981, 0.2559, 0.5195]}, {"w": "is", "b": [0.2613, 0.4981, 0.2745, 0.5195]}, {"w": "to", "b": [0.2799, 0.4981, 0.2969, 0.5195]}, {"w": "use", "b": [0.3023, 0.4981, 0.3298, 0.5195]}, {"w": "each", "b": [0.3352, 0.4981, 0.3731, 0.5195]}, {"w": "instance’s", "b": [0.3785, 0.4981, 0.4568, 0.5195]}, {"w": "identifier", "b": [0.4622, 0.4981, 0.5389, 0.5195]}, {"w": "to", "b": [0.5443, 0.4981, 0.5613, 0.5195]}, {"w": "decide", "b": [0.5667, 0.4981, 0.6208, 0.5195]}, {"w": "whether", "b": [0.6261, 0.4981, 0.6945, 0.5195]}, {"w": "or", "b": [0.6998, 0.4981, 0.7182, 0.5195]}, {"w": "not", "b": [0.7236, 0.4981, 0.752, 0.5195]}, {"w": "it", "b": [0.7573, 0.4981, 0.7693, 0.5195]}, {"w": "should", "b": [0.7747, 0.4981, 0.8314, 0.5195]}, {"w": "go", "b": [0.8368, 0.4981, 0.8571, 0.5195]}, {"w": "in", "b": [0.1429, 0.5171, 0.1598, 0.5385]}, {"w": "the", "b": [0.169, 0.5171, 0.1953, 0.5385]}, {"w": "test", "b": [0.2044, 0.5171, 0.2337, 0.5385]}, {"w": "set", "b": [0.2428, 0.5171, 0.2656, 0.5385]}, {"w": "(assuming", "b": [0.2748, 0.5171, 0.3613, 0.5385]}, {"w": "instances", "b": [0.3704, 0.5171, 0.4473, 0.5385]}, {"w": "have", "b": [0.4564, 0.5171, 0.4948, 0.5385]}, {"w": "a", "b": [0.5039, 0.5171, 0.5131, 0.5385]}, {"w": "unique", "b": [0.5222, 0.5171, 0.5808, 0.5385]}, {"w": "and", "b": [0.59, 0.5171, 0.6215, 0.5385]}, {"w": "immutable", "b": [0.6306, 0.5171, 0.7212, 0.5385]}, {"w": "identifier).", "b": [0.7304, 0.5171, 0.819, 0.5385]}, {"w": "For", "b": [0.8282, 0.5171, 0.8571, 0.5385]}, {"w": "example,", "b": [0.1429, 0.5362, 0.2171, 0.5576]}, {"w": "you", "b": [0.2225, 0.5362, 0.2537, 0.5576]}, {"w": "could", "b": [0.259, 0.5362, 0.3058, 0.5576]}, {"w": "compute", "b": [0.3111, 0.5362, 0.3844, 0.5576]}, {"w": "a", "b": [0.3897, 0.5362, 0.3989, 0.5576]}, {"w": "hash", "b": [0.4042, 0.5362, 0.4432, 0.5576]}, {"w": "of", "b": [0.4485, 0.5362, 0.4653, 0.5576]}, {"w": "each", "b": [0.4707, 0.5362, 0.5086, 0.5576]}, {"w": "instance’s", "b": [0.5139, 0.5362, 0.5922, 0.5576]}, {"w": "identifier", "b": [0.5975, 0.5362, 0.6742, 0.5576]}, {"w": "and", "b": [0.6795, 0.5362, 0.7111, 0.5576]}, {"w": "put", "b": [0.7164, 0.5362, 0.7447, 0.5576]}, {"w": "that", "b": [0.75, 0.5362, 0.7826, 0.5576]}, {"w": "instance", "b": [0.7879, 0.5362, 0.8571, 0.5576]}, {"w": "in", "b": [0.1429, 0.5552, 0.1598, 0.5766]}, {"w": "the", "b": [0.166, 0.5552, 0.1924, 0.5766]}, {"w": "test", "b": [0.1985, 0.5552, 0.2277, 0.5766]}, {"w": "set", "b": [0.2339, 0.5552, 0.2568, 0.5766]}, {"w": "if", "b": [0.263, 0.5552, 0.2747, 0.5766]}, {"w": "the", "b": [0.2809, 0.5552, 0.3072, 0.5766]}, {"w": "hash", "b": [0.3134, 0.5552, 0.3524, 0.5766]}, {"w": "is", "b": [0.3586, 0.5552, 0.3718, 0.5766]}, {"w": "lower", "b": [0.378, 0.5552, 0.4248, 0.5766]}, {"w": "or", "b": [0.431, 0.5552, 0.4493, 0.5766]}, {"w": "equal", "b": [0.4555, 0.5552, 0.5005, 0.5766]}, {"w": "to", "b": [0.5066, 0.5552, 0.5236, 0.5766]}, {"w": "20%", "b": [0.5298, 0.5552, 0.5656, 0.5766]}, {"w": "of", "b": [0.5717, 0.5552, 0.5885, 0.5766]}, {"w": "the", "b": [0.5947, 0.5552, 0.621, 0.5766]}, {"w": "maximum", "b": [0.6272, 0.5552, 0.7136, 0.5766]}, {"w": "hash", "b": [0.7198, 0.5552, 0.7589, 0.5766]}, {"w": "value.", "b": [0.765, 0.5552, 0.8138, 0.5766]}, {"w": "This", "b": [0.8199, 0.5552, 0.8572, 0.5766]}, {"w": "ensures", "b": [0.1429, 0.5743, 0.206, 0.5957]}, {"w": "that", "b": [0.2153, 0.5743, 0.2478, 0.5957]}, {"w": "the", "b": [0.2571, 0.5743, 0.2834, 0.5957]}, {"w": "test", "b": [0.2926, 0.5743, 0.3218, 0.5957]}, {"w": "set", "b": [0.331, 0.5743, 0.3539, 0.5957]}, {"w": "will", "b": [0.3631, 0.5743, 0.3935, 0.5957]}, {"w": "remain", "b": [0.4027, 0.5743, 0.4625, 0.5957]}, {"w": "consistent", "b": [0.4717, 0.5743, 0.556, 0.5957]}, {"w": "across", "b": [0.5652, 0.5743, 0.6168, 0.5957]}, {"w": "multiple", "b": [0.626, 0.5743, 0.696, 0.5957]}, {"w": "runs,", "b": [0.7052, 0.5743, 0.7478, 0.5957]}, {"w": "even", "b": [0.757, 0.5743, 0.7957, 0.5957]}, {"w": "if", "b": [0.8049, 0.5743, 0.8167, 0.5957]}, {"w": "you", "b": [0.8259, 0.5743, 0.8571, 0.5957]}, {"w": "refresh", "b": [0.1429, 0.5933, 0.201, 0.6147]}, {"w": "the", "b": [0.2065, 0.5933, 0.2329, 0.6147]}, {"w": "dataset.", "b": [0.2384, 0.5933, 0.3013, 0.6147]}, {"w": "The", "b": [0.3068, 0.5933, 0.3397, 0.6147]}, {"w": "new", "b": [0.3452, 0.5933, 0.3797, 0.6147]}, {"w": "test", "b": [0.3853, 0.5933, 0.4145, 0.6147]}, {"w": "set", "b": [0.4201, 0.5933, 0.4429, 0.6147]}, {"w": "will", "b": [0.4485, 0.5933, 0.4789, 0.6147]}, {"w": "contain", "b": [0.4844, 0.5933, 0.5474, 0.6147]}, {"w": "20%", "b": [0.5529, 0.5933, 0.5887, 0.6147]}, {"w": "of", "b": [0.5942, 0.5933, 0.611, 0.6147]}, {"w": "the", "b": [0.6166, 0.5933, 0.6429, 0.6147]}, {"w": "new", "b": [0.6485, 0.5933, 0.683, 0.6147]}, {"w": "instances,", "b": [0.6885, 0.5933, 0.7701, 0.6147]}, {"w": "but", "b": [0.7757, 0.5933, 0.8037, 0.6147]}, {"w": "it", "b": [0.8092, 0.5933, 0.8212, 0.6147]}, {"w": "will", "b": [0.8267, 0.5933, 0.8571, 0.6147]}, {"w": "not", "b": [0.1429, 0.6124, 0.1712, 0.6338]}, {"w": "contain", "b": [0.1788, 0.6124, 0.2417, 0.6338]}, {"w": "any", "b": [0.2492, 0.6124, 0.2788, 0.6338]}, {"w": "instance", "b": [0.2864, 0.6124, 0.3556, 0.6338]}, {"w": "that", "b": [0.3631, 0.6124, 0.3957, 0.6338]}, {"w": "was", "b": [0.4032, 0.6124, 0.4343, 0.6338]}, {"w": "previously", "b": [0.4418, 0.6124, 0.5287, 0.6338]}, {"w": "in", "b": [0.5362, 0.6124, 0.5532, 0.6338]}, {"w": "the", "b": [0.5607, 0.6124, 0.5871, 0.6338]}, {"w": "training", "b": [0.5946, 0.6124, 0.6615, 0.6338]}, {"w": "set.", "b": [0.6691, 0.6124, 0.6967, 0.6338]}, {"w": "Here", "b": [0.7042, 0.6124, 0.7451, 0.6338]}, {"w": "is", "b": [0.7526, 0.6124, 0.7658, 0.6338]}, {"w": "a", "b": [0.7734, 0.6124, 0.7825, 0.6338]}, {"w": "possible", "b": [0.79, 0.6124, 0.8572, 0.6338]}, {"w": "implementation:", "b": [0.1429, 0.6314, 0.2809, 0.6528]}]}, {"id": "b_9", "type": "paragraph", "text": "from zlib import crc32", "words": [{"w": "from", "b": [0.1766, 0.6634, 0.2103, 0.6762]}, {"w": "zlib", "b": [0.2188, 0.6634, 0.2525, 0.6762]}, {"w": "import", "b": [0.2609, 0.6634, 0.3115, 0.6762]}, {"w": "crc32", "b": [0.3199, 0.6634, 0.3621, 0.6762]}]}, {"id": "b_10", "type": "paragraph", "text": "def test_set_check(identifier, test_ratio): return crc32(np.int64(identifier)) & 0xffffffff < test_ratio * 2**32", "words": [{"w": "def", "b": [0.1766, 0.6942, 0.2019, 0.7071]}, {"w": "test_set_check(identifier,", "b": [0.2103, 0.6942, 0.4296, 0.7071]}, {"w": "test_ratio):", "b": [0.438, 0.6942, 0.5392, 0.7071]}, {"w": "return", "b": [0.2103, 0.7097, 0.2609, 0.7225]}, {"w": "crc32(np.int64(identifier))", "b": [0.2693, 0.7097, 0.497, 0.7225]}, {"w": "&", "b": [0.5055, 0.7097, 0.5139, 0.7225]}, {"w": "0xffffffff", "b": [0.5223, 0.7097, 0.6067, 0.7225]}, {"w": "<", "b": [0.6151, 0.7097, 0.6235, 0.7225]}, {"w": "test_ratio", "b": [0.6319, 0.7097, 0.7163, 0.7225]}, {"w": "*", "b": [0.7247, 0.7097, 0.7331, 0.7225]}, {"w": "2**32", "b": [0.7416, 0.7097, 0.7837, 0.7225]}]}, {"id": "b_11", "type": "equation", "text": "def split_train_test_by_id(data, test_ratio, id_column): ids = data[id_column]", "words": [{"w": "def", "b": [0.1766, 0.7405, 0.2019, 0.7533]}, {"w": "split_train_test_by_id(data,", "b": [0.2103, 0.7405, 0.4464, 0.7533]}, {"w": "test_ratio,", "b": [0.4549, 0.7405, 0.5476, 0.7533]}, {"w": "id_column):", "b": [0.5561, 0.7405, 0.6488, 0.7533]}, {"w": "ids", "b": [0.2103, 0.7559, 0.2356, 0.7688]}, {"w": "=", "b": [0.2441, 0.7559, 0.2525, 0.7688]}, {"w": "data[id_column]", "b": [0.2609, 0.7559, 0.3874, 0.7688]}]}, {"id": "b_12", "type": "paragraph", "text": "Get the Data | 55", "words": [{"w": "Get", "b": [0.7297, 0.9225, 0.7499, 0.9388]}, {"w": "the", "b": [0.7528, 0.9225, 0.7727, 0.9388]}, {"w": "Data", "b": [0.7755, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "55", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 82, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "15 The location information is actually quite coarse, and as a result many districts will have the exact same ID, so they will end up in the same set (test or train). This introduces some unfortunate sampling bias.", "words": [{"w": "15", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "The", "b": [0.1587, 0.8598, 0.1837, 0.8761]}, {"w": "location", "b": [0.1873, 0.8598, 0.2387, 0.8761]}, {"w": "information", "b": [0.2423, 0.8598, 0.3195, 0.8761]}, {"w": "is", "b": [0.3231, 0.8598, 0.3332, 0.8761]}, {"w": "actually", "b": [0.3368, 0.8598, 0.386, 0.8761]}, {"w": "quite", "b": [0.3896, 0.8598, 0.422, 0.8761]}, {"w": "coarse,", "b": [0.4256, 0.8598, 0.4694, 0.8761]}, {"w": "and", "b": [0.473, 0.8598, 0.4971, 0.8761]}, {"w": "as", "b": [0.5007, 0.8598, 0.5135, 0.8761]}, {"w": "a", "b": [0.5171, 0.8598, 0.524, 0.8761]}, {"w": "result", "b": [0.5277, 0.8598, 0.5634, 0.8761]}, {"w": "many", "b": [0.567, 0.8598, 0.6026, 0.8761]}, {"w": "districts", "b": [0.6062, 0.8598, 0.657, 0.8761]}, {"w": "will", "b": [0.6606, 0.8598, 0.6838, 0.8761]}, {"w": "have", "b": [0.6874, 0.8598, 0.7166, 0.8761]}, {"w": "the", "b": [0.7202, 0.8598, 0.7403, 0.8761]}, {"w": "exact", "b": [0.7439, 0.8598, 0.7767, 0.8761]}, {"w": "same", "b": [0.7803, 0.8598, 0.8128, 0.8761]}, {"w": "ID,", "b": [0.8164, 0.8598, 0.8365, 0.8761]}, {"w": "so", "b": [0.8401, 0.8598, 0.854, 0.8761]}, {"w": "they", "b": [0.1587, 0.8749, 0.1861, 0.8912]}, {"w": "will", "b": [0.1897, 0.8749, 0.2128, 0.8912]}, {"w": "end", "b": [0.2164, 0.8749, 0.2403, 0.8912]}, {"w": "up", "b": [0.2439, 0.8749, 0.2606, 0.8912]}, {"w": "in", "b": [0.2642, 0.8749, 0.2771, 0.8912]}, {"w": "the", "b": [0.2807, 0.8749, 0.3008, 0.8912]}, {"w": "same", "b": [0.3044, 0.8749, 0.337, 0.8912]}, {"w": "set", "b": [0.3406, 0.8749, 0.358, 0.8912]}, {"w": "(test", "b": [0.3616, 0.8749, 0.3893, 0.8912]}, {"w": "or", "b": [0.3929, 0.8749, 0.4069, 0.8912]}, {"w": "train).", "b": [0.4105, 0.8749, 0.4503, 0.8912]}, {"w": "This", "b": [0.4539, 0.8749, 0.4822, 0.8912]}, {"w": "introduces", "b": [0.4858, 0.8749, 0.5534, 0.8912]}, {"w": "some", "b": [0.557, 0.8749, 0.5906, 0.8912]}, {"w": "unfortunate", "b": [0.5942, 0.8749, 0.6702, 0.8912]}, {"w": "sampling", "b": [0.6738, 0.8749, 0.732, 0.8912]}, {"w": "bias.", "b": [0.7356, 0.8749, 0.7644, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "in_test_set = ids.apply(lambda id_: test_set_check(id_, test_ratio)) return data.loc[~in_test_set], data.loc[in_test_set]", "words": [{"w": "in_test_set", "b": [0.2103, 0.0829, 0.3031, 0.0958]}, {"w": "=", "b": [0.3115, 0.0829, 0.3199, 0.0958]}, {"w": "ids.apply(lambda", "b": [0.3284, 0.0829, 0.4633, 0.0958]}, {"w": "id_:", "b": [0.4717, 0.0829, 0.5055, 0.0958]}, {"w": "test_set_check(id_,", "b": [0.5139, 0.0829, 0.6741, 0.0958]}, {"w": "test_ratio))", "b": [0.6825, 0.0829, 0.7837, 0.0958]}, {"w": "return", "b": [0.2103, 0.0983, 0.2609, 0.1112]}, {"w": "data.loc[~in_test_set],", "b": [0.2693, 0.0983, 0.4633, 0.1112]}, {"w": "data.loc[in_test_set]", "b": [0.4717, 0.0983, 0.6488, 0.1112]}]}, {"id": "b_2", "type": "paragraph", "text": "Unfortunately, the housing dataset does not have an identifier column. The simplest solution is to use the row index as the ID:", "words": [{"w": "Unfortunately,", "b": [0.1429, 0.119, 0.264, 0.1404]}, {"w": "the", "b": [0.2703, 0.119, 0.2966, 0.1404]}, {"w": "housing", "b": [0.3028, 0.119, 0.37, 0.1404]}, {"w": "dataset", "b": [0.3763, 0.119, 0.4344, 0.1404]}, {"w": "does", "b": [0.4406, 0.119, 0.4787, 0.1404]}, {"w": "not", "b": [0.485, 0.119, 0.5133, 0.1404]}, {"w": "have", "b": [0.5196, 0.119, 0.558, 0.1404]}, {"w": "an", "b": [0.5642, 0.119, 0.5847, 0.1404]}, {"w": "identifier", "b": [0.591, 0.119, 0.6677, 0.1404]}, {"w": "column.", "b": [0.6739, 0.119, 0.7429, 0.1404]}, {"w": "The", "b": [0.7491, 0.119, 0.782, 0.1404]}, {"w": "simplest", "b": [0.7882, 0.119, 0.8571, 0.1404]}, {"w": "solution", "b": [0.1429, 0.138, 0.2114, 0.1594]}, {"w": "is", "b": [0.2162, 0.138, 0.2294, 0.1594]}, {"w": "to", "b": [0.2341, 0.138, 0.2511, 0.1594]}, {"w": "use", "b": [0.2558, 0.138, 0.2834, 0.1594]}, {"w": "the", "b": [0.2881, 0.138, 0.3144, 0.1594]}, {"w": "row", "b": [0.3192, 0.138, 0.3518, 0.1594]}, {"w": "index", "b": [0.3565, 0.138, 0.4032, 0.1594]}, {"w": "as", "b": [0.4079, 0.138, 0.4247, 0.1594]}, {"w": "the", "b": [0.4294, 0.138, 0.4558, 0.1594]}, {"w": "ID:", "b": [0.4605, 0.138, 0.4877, 0.1594]}]}, {"id": "b_3", "type": "paragraph", "text": "housing_with_id = housing.reset_index() # adds an `index` column train_set, test_set = split_train_test_by_id(housing_with_id, 0.2, \"index\")", "words": [{"w": "housing_with_id", "b": [0.1766, 0.17, 0.3031, 0.1828]}, {"w": "=", "b": [0.3115, 0.17, 0.3199, 0.1828]}, {"w": "housing.reset_index()", "b": [0.3284, 0.17, 0.5055, 0.1828]}, {"w": "#", "b": [0.5308, 0.17, 0.5392, 0.1828]}, {"w": "adds", "b": [0.5476, 0.17, 0.5813, 0.1828]}, {"w": "an", "b": [0.5898, 0.17, 0.6066, 0.1828]}, {"w": "`index`", "b": [0.6151, 0.17, 0.6741, 0.1828]}, {"w": "column", "b": [0.6825, 0.17, 0.7331, 0.1828]}, {"w": "train_set,", "b": [0.1766, 0.1854, 0.2609, 0.1983]}, {"w": "test_set", "b": [0.2693, 0.1854, 0.3368, 0.1983]}, {"w": "=", "b": [0.3452, 0.1854, 0.3537, 0.1983]}, {"w": "split_train_test_by_id(housing_with_id,", "b": [0.3621, 0.1854, 0.691, 0.1983]}, {"w": "0.2,", "b": [0.6994, 0.1854, 0.7331, 0.1983]}, {"w": "\"index\")", "b": [0.7416, 0.1854, 0.809, 0.1983]}]}, {"id": "b_4", "type": "paragraph", "text": "If you use the row index as a unique identifier, you need to make sure that new data gets appended to the end of the dataset, and no row ever gets deleted. If this is not possible, then you can try to use the most stable features to build a unique identifier. For example, a district’s latitude and longitude are guaranteed to be stable for a few million years, so you could combine them into an ID like so:15", "words": [{"w": "If", "b": [0.1429, 0.206, 0.1561, 0.2275]}, {"w": "you", "b": [0.162, 0.206, 0.1933, 0.2275]}, {"w": "use", "b": [0.1992, 0.206, 0.2268, 0.2275]}, {"w": "the", "b": [0.2327, 0.206, 0.259, 0.2275]}, {"w": "row", "b": [0.2649, 0.206, 0.2976, 0.2275]}, {"w": "index", "b": [0.3035, 0.206, 0.3501, 0.2275]}, {"w": "as", "b": [0.356, 0.206, 0.3728, 0.2275]}, {"w": "a", "b": [0.3787, 0.206, 0.3879, 0.2275]}, {"w": "unique", "b": [0.3938, 0.206, 0.4524, 0.2275]}, {"w": "identifier,", "b": [0.4583, 0.206, 0.5385, 0.2275]}, {"w": "you", "b": [0.5444, 0.206, 0.5756, 0.2275]}, {"w": "need", "b": [0.5815, 0.206, 0.6216, 0.2275]}, {"w": "to", "b": [0.6276, 0.206, 0.6445, 0.2275]}, {"w": "make", "b": [0.6505, 0.206, 0.6958, 0.2275]}, {"w": "sure", "b": [0.7018, 0.206, 0.7371, 0.2275]}, {"w": "that", "b": [0.743, 0.206, 0.7755, 0.2275]}, {"w": "new", "b": [0.7815, 0.206, 0.816, 0.2275]}, {"w": "data", "b": [0.8219, 0.206, 0.8571, 0.2275]}, {"w": "gets", "b": [0.1429, 0.2251, 0.1755, 0.2465]}, {"w": "appended", "b": [0.1822, 0.2251, 0.2639, 0.2465]}, {"w": "to", "b": [0.2707, 0.2251, 0.2877, 0.2465]}, {"w": "the", "b": [0.2944, 0.2251, 0.3208, 0.2465]}, {"w": "end", "b": [0.3275, 0.2251, 0.3588, 0.2465]}, {"w": "of", "b": [0.3655, 0.2251, 0.3823, 0.2465]}, {"w": "the", "b": [0.3891, 0.2251, 0.4154, 0.2465]}, {"w": "dataset,", "b": [0.4222, 0.2251, 0.4851, 0.2465]}, {"w": "and", "b": [0.4918, 0.2251, 0.5234, 0.2465]}, {"w": "no", "b": [0.5301, 0.2251, 0.5522, 0.2465]}, {"w": "row", "b": [0.5589, 0.2251, 0.5916, 0.2465]}, {"w": "ever", "b": [0.5983, 0.2251, 0.6334, 0.2465]}, {"w": "gets", "b": [0.6402, 0.2251, 0.6728, 0.2465]}, {"w": "deleted.", "b": [0.6795, 0.2251, 0.7445, 0.2465]}, {"w": "If", "b": [0.7513, 0.2251, 0.7645, 0.2465]}, {"w": "this", "b": [0.7713, 0.2251, 0.802, 0.2465]}, {"w": "is", "b": [0.8088, 0.2251, 0.822, 0.2465]}, {"w": "not", "b": [0.8288, 0.2251, 0.8571, 0.2465]}, {"w": "possible,", "b": [0.1428, 0.2441, 0.2147, 0.2656]}, {"w": "then", "b": [0.2204, 0.2441, 0.2582, 0.2656]}, {"w": "you", "b": [0.2639, 0.2441, 0.2951, 0.2656]}, {"w": "can", "b": [0.3008, 0.2441, 0.3302, 0.2656]}, {"w": "try", "b": [0.3359, 0.2441, 0.3601, 0.2656]}, {"w": "to", "b": [0.3658, 0.2441, 0.3828, 0.2656]}, {"w": "use", "b": [0.3885, 0.2441, 0.4161, 0.2656]}, {"w": "the", "b": [0.4218, 0.2441, 0.4481, 0.2656]}, {"w": "most", "b": [0.4538, 0.2441, 0.4955, 0.2656]}, {"w": "stable", "b": [0.5012, 0.2441, 0.5491, 0.2656]}, {"w": "features", "b": [0.5548, 0.2441, 0.6202, 0.2656]}, {"w": "to", "b": [0.6259, 0.2441, 0.6429, 0.2656]}, {"w": "build", "b": [0.6486, 0.2441, 0.6921, 0.2656]}, {"w": "a", "b": [0.6978, 0.2441, 0.707, 0.2656]}, {"w": "unique", "b": [0.7127, 0.2441, 0.7713, 0.2656]}, {"w": "identifier.", "b": [0.777, 0.2441, 0.8571, 0.2656]}, {"w": "For", "b": [0.1429, 0.2632, 0.1718, 0.2846]}, {"w": "example,", "b": [0.1785, 0.2632, 0.2527, 0.2846]}, {"w": "a", "b": [0.2594, 0.2632, 0.2685, 0.2846]}, {"w": "district’s", "b": [0.2751, 0.2632, 0.3439, 0.2846]}, {"w": "latitude", "b": [0.3505, 0.2632, 0.4138, 0.2846]}, {"w": "and", "b": [0.4204, 0.2632, 0.4519, 0.2846]}, {"w": "longitude", "b": [0.4585, 0.2632, 0.5384, 0.2846]}, {"w": "are", "b": [0.545, 0.2632, 0.5708, 0.2846]}, {"w": "guaranteed", "b": [0.5774, 0.2632, 0.6703, 0.2846]}, {"w": "to", "b": [0.6769, 0.2632, 0.6938, 0.2846]}, {"w": "be", "b": [0.7005, 0.2632, 0.7199, 0.2846]}, {"w": "stable", "b": [0.7265, 0.2632, 0.7744, 0.2846]}, {"w": "for", "b": [0.781, 0.2632, 0.8055, 0.2846]}, {"w": "a", "b": [0.8121, 0.2632, 0.8212, 0.2846]}, {"w": "few", "b": [0.8279, 0.2632, 0.8571, 0.2846]}, {"w": "million", "b": [0.1429, 0.2822, 0.2036, 0.3036]}, {"w": "years,", "b": [0.2084, 0.2822, 0.2561, 0.3036]}, {"w": "so", "b": [0.2608, 0.2822, 0.2791, 0.3036]}, {"w": "you", "b": [0.2838, 0.2822, 0.315, 0.3036]}, {"w": "could", "b": [0.3198, 0.2822, 0.3665, 0.3036]}, {"w": "combine", "b": [0.3713, 0.2822, 0.4442, 0.3036]}, {"w": "them", "b": [0.4489, 0.2822, 0.4923, 0.3036]}, {"w": "into", "b": [0.497, 0.2822, 0.5306, 0.3036]}, {"w": "an", "b": [0.5353, 0.2822, 0.5559, 0.3036]}, {"w": "ID", "b": [0.5606, 0.2822, 0.583, 0.3036]}, {"w": "like", "b": [0.5878, 0.2822, 0.6178, 0.3036]}, {"w": "so:15", "b": [0.6225, 0.2822, 0.657, 0.3036]}]}, {"id": "b_5", "type": "paragraph", "text": "housing_with_id[\"id\"] = housing[\"longitude\"] * 1000 + housing[\"latitude\"] train_set, test_set = split_train_test_by_id(housing_with_id, 0.2, \"id\")", "words": [{"w": "housing_with_id[\"id\"]", "b": [0.1766, 0.3142, 0.3537, 0.3271]}, {"w": "=", "b": [0.3621, 0.3142, 0.3705, 0.3271]}, {"w": "housing[\"longitude\"]", "b": [0.379, 0.3142, 0.5476, 0.3271]}, {"w": "*", "b": [0.5561, 0.3142, 0.5645, 0.3271]}, {"w": "1000", "b": [0.5729, 0.3142, 0.6066, 0.3271]}, {"w": "+", "b": [0.6151, 0.3142, 0.6235, 0.3271]}, {"w": "housing[\"latitude\"]", "b": [0.6319, 0.3142, 0.7922, 0.3271]}, {"w": "train_set,", "b": [0.1766, 0.3296, 0.2609, 0.3425]}, {"w": "test_set", "b": [0.2693, 0.3296, 0.3368, 0.3425]}, {"w": "=", "b": [0.3452, 0.3296, 0.3537, 0.3425]}, {"w": "split_train_test_by_id(housing_with_id,", "b": [0.3621, 0.3296, 0.691, 0.3425]}, {"w": "0.2,", "b": [0.6994, 0.3296, 0.7331, 0.3425]}, {"w": "\"id\")", "b": [0.7416, 0.3296, 0.7837, 0.3425]}]}, {"id": "b_6", "type": "paragraph", "text": "Scikit-Learn provides a few functions to split datasets into multiple subsets in various ways. The simplest function is train_test_split, which does pretty much the same thing as the function split_train_test defined earlier, with a couple of additional features. First there is a random_state parameter that allows you to set the random generator seed as explained previously, and second you can pass it multiple datasets with an identical number of rows, and it will split them on the same indices (this is very useful, for example, if you have a separate DataFrame for labels):", "words": [{"w": "Scikit-Learn", "b": [0.1429, 0.3503, 0.2451, 0.3717]}, {"w": "provides", "b": [0.2503, 0.3503, 0.3223, 0.3717]}, {"w": "a", "b": [0.3275, 0.3503, 0.3367, 0.3717]}, {"w": "few", "b": [0.3419, 0.3503, 0.3711, 0.3717]}, {"w": "functions", "b": [0.3763, 0.3503, 0.4554, 0.3717]}, {"w": "to", "b": [0.4606, 0.3503, 0.4775, 0.3717]}, {"w": "split", "b": [0.4827, 0.3503, 0.5185, 0.3717]}, {"w": "datasets", "b": [0.5237, 0.3503, 0.5894, 0.3717]}, {"w": "into", "b": [0.5946, 0.3503, 0.6282, 0.3717]}, {"w": "multiple", "b": [0.6334, 0.3503, 0.7034, 0.3717]}, {"w": "subsets", "b": [0.7086, 0.3503, 0.7683, 0.3717]}, {"w": "in", "b": [0.7735, 0.3503, 0.7905, 0.3717]}, {"w": "various", "b": [0.7957, 0.3503, 0.8571, 0.3717]}, {"w": "ways.", "b": [0.1428, 0.3702, 0.1878, 0.3916]}, {"w": "The", "b": [0.1937, 0.3702, 0.2265, 0.3916]}, {"w": "simplest", "b": [0.2324, 0.3702, 0.3013, 0.3916]}, {"w": "function", "b": [0.3072, 0.3702, 0.3785, 0.3916]}, {"w": "is", "b": [0.3844, 0.3702, 0.3976, 0.3916]}, {"w": "train_test_split,", "b": [0.4035, 0.3702, 0.5665, 0.3916]}, {"w": "which", "b": [0.5724, 0.3702, 0.6233, 0.3916]}, {"w": "does", "b": [0.6292, 0.3702, 0.6673, 0.3916]}, {"w": "pretty", "b": [0.6731, 0.3702, 0.7229, 0.3916]}, {"w": "much", "b": [0.7287, 0.3702, 0.7764, 0.3916]}, {"w": "the", "b": [0.7822, 0.3702, 0.8086, 0.3916]}, {"w": "same", "b": [0.8144, 0.3702, 0.8571, 0.3916]}, {"w": "thing", "b": [0.1429, 0.3902, 0.1871, 0.4116]}, {"w": "as", "b": [0.1938, 0.3902, 0.2106, 0.4116]}, {"w": "the", "b": [0.2173, 0.3902, 0.2436, 0.4116]}, {"w": "function", "b": [0.2503, 0.3902, 0.3217, 0.4116]}, {"w": "split_train_test", "b": [0.3284, 0.3933, 0.4868, 0.4084]}, {"w": "defined", "b": [0.4935, 0.3902, 0.5563, 0.4116]}, {"w": "earlier,", "b": [0.5631, 0.3902, 0.6197, 0.4116]}, {"w": "with", "b": [0.6264, 0.3902, 0.6637, 0.4116]}, {"w": "a", "b": [0.6704, 0.3902, 0.6796, 0.4116]}, {"w": "couple", "b": [0.6863, 0.3902, 0.7418, 0.4116]}, {"w": "of", "b": [0.7485, 0.3902, 0.7653, 0.4116]}, {"w": "additional", "b": [0.772, 0.3902, 0.8572, 0.4116]}, {"w": "features.", "b": [0.1429, 0.4101, 0.213, 0.4315]}, {"w": "First", "b": [0.2197, 0.4101, 0.258, 0.4315]}, {"w": "there", "b": [0.2647, 0.4101, 0.3076, 0.4315]}, {"w": "is", "b": [0.3143, 0.4101, 0.3275, 0.4315]}, {"w": "a", "b": [0.3342, 0.4101, 0.3433, 0.4315]}, {"w": "random_state", "b": [0.35, 0.4133, 0.4688, 0.4284]}, {"w": "parameter", "b": [0.4754, 0.4101, 0.5612, 0.4315]}, {"w": "that", "b": [0.5679, 0.4101, 0.6005, 0.4315]}, {"w": "allows", "b": [0.6072, 0.4101, 0.6594, 0.4315]}, {"w": "you", "b": [0.6661, 0.4101, 0.6973, 0.4315]}, {"w": "to", "b": [0.704, 0.4101, 0.721, 0.4315]}, {"w": "set", "b": [0.7276, 0.4101, 0.7505, 0.4315]}, {"w": "the", "b": [0.7572, 0.4101, 0.7835, 0.4315]}, {"w": "random", "b": [0.7902, 0.4101, 0.8571, 0.4315]}, {"w": "generator", "b": [0.1429, 0.4291, 0.2229, 0.4506]}, {"w": "seed", "b": [0.2293, 0.4291, 0.2656, 0.4506]}, {"w": "as", "b": [0.272, 0.4291, 0.2888, 0.4506]}, {"w": "explained", "b": [0.2952, 0.4291, 0.376, 0.4506]}, {"w": "previously,", "b": [0.3824, 0.4291, 0.4726, 0.4506]}, {"w": "and", "b": [0.4789, 0.4291, 0.5105, 0.4506]}, {"w": "second", "b": [0.5169, 0.4291, 0.5752, 0.4506]}, {"w": "you", "b": [0.5816, 0.4291, 0.6128, 0.4506]}, {"w": "can", "b": [0.6192, 0.4291, 0.6486, 0.4506]}, {"w": "pass", "b": [0.655, 0.4291, 0.6903, 0.4506]}, {"w": "it", "b": [0.6967, 0.4291, 0.7086, 0.4506]}, {"w": "multiple", "b": [0.715, 0.4291, 0.785, 0.4506]}, {"w": "datasets", "b": [0.7914, 0.4291, 0.8571, 0.4506]}, {"w": "with", "b": [0.1428, 0.4482, 0.1802, 0.4696]}, {"w": "an", "b": [0.1866, 0.4482, 0.2071, 0.4696]}, {"w": "identical", "b": [0.2135, 0.4482, 0.2851, 0.4696]}, {"w": "number", "b": [0.2916, 0.4482, 0.3579, 0.4696]}, {"w": "of", "b": [0.3643, 0.4482, 0.3811, 0.4696]}, {"w": "rows,", "b": [0.3875, 0.4482, 0.4325, 0.4696]}, {"w": "and", "b": [0.4389, 0.4482, 0.4704, 0.4696]}, {"w": "it", "b": [0.4768, 0.4482, 0.4888, 0.4696]}, {"w": "will", "b": [0.4952, 0.4482, 0.5256, 0.4696]}, {"w": "split", "b": [0.532, 0.4482, 0.5678, 0.4696]}, {"w": "them", "b": [0.5742, 0.4482, 0.6176, 0.4696]}, {"w": "on", "b": [0.624, 0.4482, 0.646, 0.4696]}, {"w": "the", "b": [0.6524, 0.4482, 0.6788, 0.4696]}, {"w": "same", "b": [0.6852, 0.4482, 0.7279, 0.4696]}, {"w": "indices", "b": [0.7343, 0.4482, 0.7932, 0.4696]}, {"w": "(this", "b": [0.7996, 0.4482, 0.8375, 0.4696]}, {"w": "is", "b": [0.8439, 0.4482, 0.8571, 0.4696]}, {"w": "very", "b": [0.1429, 0.4672, 0.1793, 0.4887]}, {"w": "useful,", "b": [0.184, 0.4672, 0.2388, 0.4887]}, {"w": "for", "b": [0.2435, 0.4672, 0.268, 0.4887]}, {"w": "example,", "b": [0.2728, 0.4672, 0.3471, 0.4887]}, {"w": "if", "b": [0.3518, 0.4672, 0.3635, 0.4887]}, {"w": "you", "b": [0.3683, 0.4672, 0.3995, 0.4887]}, {"w": "have", "b": [0.4043, 0.4672, 0.4427, 0.4887]}, {"w": "a", "b": [0.4474, 0.4672, 0.4565, 0.4887]}, {"w": "separate", "b": [0.4613, 0.4672, 0.5295, 0.4887]}, {"w": "DataFrame", "b": [0.5342, 0.4672, 0.6276, 0.4887]}, {"w": "for", "b": [0.6323, 0.4672, 0.6569, 0.4887]}, {"w": "labels):", "b": [0.6616, 0.4672, 0.7203, 0.4887]}]}, {"id": "b_7", "type": "equation", "text": "from sklearn.model_selection import train_test_split", "words": [{"w": "from", "b": [0.1766, 0.4992, 0.2103, 0.5121]}, {"w": "sklearn.model_selection", "b": [0.2188, 0.4992, 0.4127, 0.5121]}, {"w": "import", "b": [0.4211, 0.4992, 0.4717, 0.5121]}, {"w": "train_test_split", "b": [0.4802, 0.4992, 0.6151, 0.5121]}]}, {"id": "b_8", "type": "equation", "text": "train_set, test_set = train_test_split(housing, test_size=0.2, random_state=42)", "words": [{"w": "train_set,", "b": [0.1766, 0.5301, 0.2609, 0.5429]}, {"w": "test_set", "b": [0.2693, 0.5301, 0.3368, 0.5429]}, {"w": "=", "b": [0.3452, 0.5301, 0.3537, 0.5429]}, {"w": "train_test_split(housing,", "b": [0.3621, 0.5301, 0.5729, 0.5429]}, {"w": "test_size=0.2,", "b": [0.5814, 0.5301, 0.6994, 0.5429]}, {"w": "random_state=42)", "b": [0.7078, 0.5301, 0.8428, 0.5429]}]}, {"id": "b_9", "type": "paragraph", "text": "So far we have considered purely random sampling methods. This is generally fine if your dataset is large enough (especially relative to the number of attributes), but if it is not, you run the risk of introducing a significant sampling bias. When a survey company decides to call 1,000 people to ask them a few questions, they don’t just pick 1,000 people randomly in a phone book. They try to ensure that these 1,000 people are representative of the whole population. For example, the US population is com‐ posed of 51.3% female and 48.7% male, so a well-conducted survey in the US would try to maintain this ratio in the sample: 513 female and 487 male. This is called strati‐ fied sampling: the population is divided into homogeneous subgroups called strata, and the right number of instances is sampled from each stratum to guarantee that the test set is representative of the overall population. If they used purely random sam‐ pling, there would be about 12% chance of sampling a skewed test set with either less than 49% female or more than 54% female. Either way, the survey results would be significantly biased.", "words": [{"w": "So", "b": [0.1429, 0.5507, 0.1634, 0.5721]}, {"w": "far", "b": [0.169, 0.5507, 0.1921, 0.5721]}, {"w": "we", "b": [0.1977, 0.5507, 0.2208, 0.5721]}, {"w": "have", "b": [0.2265, 0.5507, 0.2649, 0.5721]}, {"w": "considered", "b": [0.2706, 0.5507, 0.3621, 0.5721]}, {"w": "purely", "b": [0.3677, 0.5507, 0.4211, 0.5721]}, {"w": "random", "b": [0.4268, 0.5507, 0.4937, 0.5721]}, {"w": "sampling", "b": [0.4994, 0.5507, 0.5758, 0.5721]}, {"w": "methods.", "b": [0.5814, 0.5507, 0.6588, 0.5721]}, {"w": "This", "b": [0.6645, 0.5507, 0.7017, 0.5721]}, {"w": "is", "b": [0.7074, 0.5507, 0.7206, 0.5721]}, {"w": "generally", "b": [0.7263, 0.5507, 0.8021, 0.5721]}, {"w": "fine", "b": [0.8077, 0.5507, 0.8397, 0.5721]}, {"w": "if", "b": [0.8454, 0.5507, 0.8572, 0.5721]}, {"w": "your", "b": [0.1429, 0.5697, 0.1818, 0.5911]}, {"w": "dataset", "b": [0.1878, 0.5697, 0.2459, 0.5911]}, {"w": "is", "b": [0.2518, 0.5697, 0.265, 0.5911]}, {"w": "large", "b": [0.2709, 0.5697, 0.3117, 0.5911]}, {"w": "enough", "b": [0.3176, 0.5697, 0.3804, 0.5911]}, {"w": "(especially", "b": [0.3864, 0.5697, 0.4735, 0.5911]}, {"w": "relative", "b": [0.4794, 0.5697, 0.5404, 0.5911]}, {"w": "to", "b": [0.5464, 0.5697, 0.5633, 0.5911]}, {"w": "the", "b": [0.5693, 0.5697, 0.5956, 0.5911]}, {"w": "number", "b": [0.6015, 0.5697, 0.6678, 0.5911]}, {"w": "of", "b": [0.6737, 0.5697, 0.6905, 0.5911]}, {"w": "attributes),", "b": [0.6965, 0.5697, 0.7877, 0.5911]}, {"w": "but", "b": [0.7936, 0.5697, 0.8216, 0.5911]}, {"w": "if", "b": [0.8275, 0.5697, 0.8393, 0.5911]}, {"w": "it", "b": [0.8452, 0.5697, 0.8571, 0.5911]}, {"w": "is", "b": [0.1429, 0.5888, 0.1561, 0.6102]}, {"w": "not,", "b": [0.1637, 0.5888, 0.1969, 0.6102]}, {"w": "you", "b": [0.2045, 0.5888, 0.2358, 0.6102]}, {"w": "run", "b": [0.2434, 0.5888, 0.2736, 0.6102]}, {"w": "the", "b": [0.2812, 0.5888, 0.3076, 0.6102]}, {"w": "risk", "b": [0.3152, 0.5888, 0.3465, 0.6102]}, {"w": "of", "b": [0.3542, 0.5888, 0.371, 0.6102]}, {"w": "introducing", "b": [0.3786, 0.5888, 0.4775, 0.6102]}, {"w": "a", "b": [0.4851, 0.5888, 0.4943, 0.6102]}, {"w": "significant", "b": [0.5019, 0.5888, 0.589, 0.6102]}, {"w": "sampling", "b": [0.5966, 0.5888, 0.673, 0.6102]}, {"w": "bias.", "b": [0.6806, 0.5888, 0.7183, 0.6102]}, {"w": "When", "b": [0.726, 0.5888, 0.7776, 0.6102]}, {"w": "a", "b": [0.7852, 0.5888, 0.7944, 0.6102]}, {"w": "survey", "b": [0.802, 0.5888, 0.8571, 0.6102]}, {"w": "company", "b": [0.1428, 0.6078, 0.2195, 0.6292]}, {"w": "decides", "b": [0.2246, 0.6078, 0.2863, 0.6292]}, {"w": "to", "b": [0.2914, 0.6078, 0.3084, 0.6292]}, {"w": "call", "b": [0.3135, 0.6078, 0.342, 0.6292]}, {"w": "1,000", "b": [0.347, 0.6078, 0.3918, 0.6292]}, {"w": "people", "b": [0.3969, 0.6078, 0.4523, 0.6292]}, {"w": "to", "b": [0.4574, 0.6078, 0.4744, 0.6292]}, {"w": "ask", "b": [0.4794, 0.6078, 0.5066, 0.6292]}, {"w": "them", "b": [0.5116, 0.6078, 0.555, 0.6292]}, {"w": "a", "b": [0.5601, 0.6078, 0.5693, 0.6292]}, {"w": "few", "b": [0.5743, 0.6078, 0.6036, 0.6292]}, {"w": "questions,", "b": [0.6087, 0.6078, 0.6933, 0.6292]}, {"w": "they", "b": [0.6984, 0.6078, 0.7343, 0.6292]}, {"w": "don’t", "b": [0.7393, 0.6078, 0.7809, 0.6292]}, {"w": "just", "b": [0.786, 0.6078, 0.8164, 0.6292]}, {"w": "pick", "b": [0.8215, 0.6078, 0.8571, 0.6292]}, {"w": "1,000", "b": [0.1429, 0.6269, 0.1876, 0.6483]}, {"w": "people", "b": [0.1942, 0.6269, 0.2496, 0.6483]}, {"w": "randomly", "b": [0.2561, 0.6269, 0.3379, 0.6483]}, {"w": "in", "b": [0.3445, 0.6269, 0.3614, 0.6483]}, {"w": "a", "b": [0.368, 0.6269, 0.3771, 0.6483]}, {"w": "phone", "b": [0.3837, 0.6269, 0.4366, 0.6483]}, {"w": "book.", "b": [0.4431, 0.6269, 0.49, 0.6483]}, {"w": "They", "b": [0.4966, 0.6269, 0.539, 0.6483]}, {"w": "try", "b": [0.5455, 0.6269, 0.5698, 0.6483]}, {"w": "to", "b": [0.5763, 0.6269, 0.5933, 0.6483]}, {"w": "ensure", "b": [0.5998, 0.6269, 0.6554, 0.6483]}, {"w": "that", "b": [0.6619, 0.6269, 0.6945, 0.6483]}, {"w": "these", "b": [0.701, 0.6269, 0.7439, 0.6483]}, {"w": "1,000", "b": [0.7504, 0.6269, 0.7952, 0.6483]}, {"w": "people", "b": [0.8017, 0.6269, 0.8571, 0.6483]}, {"w": "are", "b": [0.1429, 0.6459, 0.1686, 0.6673]}, {"w": "representative", "b": [0.1751, 0.6459, 0.2922, 0.6673]}, {"w": "of", "b": [0.2988, 0.6459, 0.3156, 0.6673]}, {"w": "the", "b": [0.3221, 0.6459, 0.3484, 0.6673]}, {"w": "whole", "b": [0.355, 0.6459, 0.4051, 0.6673]}, {"w": "population.", "b": [0.4117, 0.6459, 0.5079, 0.6673]}, {"w": "For", "b": [0.5145, 0.6459, 0.5434, 0.6673]}, {"w": "example,", "b": [0.55, 0.6459, 0.6243, 0.6673]}, {"w": "the", "b": [0.6308, 0.6459, 0.6571, 0.6673]}, {"w": "US", "b": [0.6637, 0.6459, 0.6889, 0.6673]}, {"w": "population", "b": [0.6954, 0.6459, 0.7869, 0.6673]}, {"w": "is", "b": [0.7935, 0.6459, 0.8067, 0.6673]}, {"w": "com‐", "b": [0.8132, 0.6459, 0.8571, 0.6673]}, {"w": "posed", "b": [0.1429, 0.665, 0.1919, 0.6864]}, {"w": "of", "b": [0.1978, 0.665, 0.2146, 0.6864]}, {"w": "51.3%", "b": [0.2206, 0.665, 0.2711, 0.6864]}, {"w": "female", "b": [0.277, 0.665, 0.3324, 0.6864]}, {"w": "and", "b": [0.3383, 0.665, 0.3699, 0.6864]}, {"w": "48.7%", "b": [0.3758, 0.665, 0.4263, 0.6864]}, {"w": "male,", "b": [0.4322, 0.665, 0.4773, 0.6864]}, {"w": "so", "b": [0.4833, 0.665, 0.5015, 0.6864]}, {"w": "a", "b": [0.5075, 0.665, 0.5166, 0.6864]}, {"w": "well-conducted", "b": [0.5226, 0.665, 0.6516, 0.6864]}, {"w": "survey", "b": [0.6575, 0.665, 0.7126, 0.6864]}, {"w": "in", "b": [0.7186, 0.665, 0.7355, 0.6864]}, {"w": "the", "b": [0.7415, 0.665, 0.7678, 0.6864]}, {"w": "US", "b": [0.7738, 0.665, 0.799, 0.6864]}, {"w": "would", "b": [0.8049, 0.665, 0.8571, 0.6864]}, {"w": "try", "b": [0.1429, 0.684, 0.1671, 0.7054]}, {"w": "to", "b": [0.1722, 0.684, 0.1892, 0.7054]}, {"w": "maintain", "b": [0.1943, 0.684, 0.2696, 0.7054]}, {"w": "this", "b": [0.2747, 0.684, 0.3054, 0.7054]}, {"w": "ratio", "b": [0.3105, 0.684, 0.3496, 0.7054]}, {"w": "in", "b": [0.3547, 0.684, 0.3717, 0.7054]}, {"w": "the", "b": [0.3768, 0.684, 0.4031, 0.7054]}, {"w": "sample:", "b": [0.4082, 0.684, 0.4715, 0.7054]}, {"w": "513", "b": [0.4766, 0.684, 0.5066, 0.7054]}, {"w": "female", "b": [0.5117, 0.684, 0.5671, 0.7054]}, {"w": "and", "b": [0.5722, 0.684, 0.6037, 0.7054]}, {"w": "487", "b": [0.6088, 0.684, 0.6388, 0.7054]}, {"w": "male.", "b": [0.644, 0.684, 0.689, 0.7054]}, {"w": "This", "b": [0.6942, 0.684, 0.7314, 0.7054]}, {"w": "is", "b": [0.7365, 0.684, 0.7497, 0.7054]}, {"w": "called", "b": [0.7548, 0.684, 0.8032, 0.7054]}, {"w": "strati‐", "b": [0.8083, 0.6838, 0.8572, 0.7054]}, {"w": "fied", "b": [0.1429, 0.7029, 0.1728, 0.7245]}, {"w": "sampling:", "b": [0.1804, 0.7029, 0.258, 0.7245]}, {"w": "the", "b": [0.2655, 0.7031, 0.2918, 0.7245]}, {"w": "population", "b": [0.2994, 0.7031, 0.3909, 0.7245]}, {"w": "is", "b": [0.3984, 0.7031, 0.4116, 0.7245]}, {"w": "divided", "b": [0.4191, 0.7031, 0.4818, 0.7245]}, {"w": "into", "b": [0.4893, 0.7031, 0.5229, 0.7245]}, {"w": "homogeneous", "b": [0.5304, 0.7031, 0.6481, 0.7245]}, {"w": "subgroups", "b": [0.6556, 0.7031, 0.7426, 0.7245]}, {"w": "called", "b": [0.7501, 0.7031, 0.7985, 0.7245]}, {"w": "strata,", "b": [0.806, 0.7029, 0.8571, 0.7245]}, {"w": "and", "b": [0.1429, 0.7221, 0.1744, 0.7435]}, {"w": "the", "b": [0.1795, 0.7221, 0.2058, 0.7435]}, {"w": "right", "b": [0.2109, 0.7221, 0.2511, 0.7435]}, {"w": "number", "b": [0.2562, 0.7221, 0.3225, 0.7435]}, {"w": "of", "b": [0.3276, 0.7221, 0.3443, 0.7435]}, {"w": "instances", "b": [0.3494, 0.7221, 0.4263, 0.7435]}, {"w": "is", "b": [0.4314, 0.7221, 0.4446, 0.7435]}, {"w": "sampled", "b": [0.4497, 0.7221, 0.5192, 0.7435]}, {"w": "from", "b": [0.5243, 0.7221, 0.5659, 0.7435]}, {"w": "each", "b": [0.571, 0.7221, 0.6089, 0.7435]}, {"w": "stratum", "b": [0.614, 0.7221, 0.679, 0.7435]}, {"w": "to", "b": [0.6841, 0.7221, 0.701, 0.7435]}, {"w": "guarantee", "b": [0.7061, 0.7221, 0.788, 0.7435]}, {"w": "that", "b": [0.7931, 0.7221, 0.8257, 0.7435]}, {"w": "the", "b": [0.8308, 0.7221, 0.8571, 0.7435]}, {"w": "test", "b": [0.1428, 0.7412, 0.1721, 0.7626]}, {"w": "set", "b": [0.1787, 0.7412, 0.2016, 0.7626]}, {"w": "is", "b": [0.2082, 0.7412, 0.2215, 0.7626]}, {"w": "representative", "b": [0.2281, 0.7412, 0.3452, 0.7626]}, {"w": "of", "b": [0.3519, 0.7412, 0.3687, 0.7626]}, {"w": "the", "b": [0.3754, 0.7412, 0.4017, 0.7626]}, {"w": "overall", "b": [0.4084, 0.7412, 0.4649, 0.7626]}, {"w": "population.", "b": [0.4716, 0.7412, 0.5678, 0.7626]}, {"w": "If", "b": [0.5745, 0.7412, 0.5877, 0.7626]}, {"w": "they", "b": [0.5944, 0.7412, 0.6303, 0.7626]}, {"w": "used", "b": [0.637, 0.7412, 0.6755, 0.7626]}, {"w": "purely", "b": [0.6822, 0.7412, 0.7356, 0.7626]}, {"w": "random", "b": [0.7422, 0.7412, 0.8092, 0.7626]}, {"w": "sam‐", "b": [0.8159, 0.7412, 0.8571, 0.7626]}, {"w": "pling,", "b": [0.1429, 0.7602, 0.1905, 0.7816]}, {"w": "there", "b": [0.1958, 0.7602, 0.2388, 0.7816]}, {"w": "would", "b": [0.2441, 0.7602, 0.2963, 0.7816]}, {"w": "be", "b": [0.3016, 0.7602, 0.3211, 0.7816]}, {"w": "about", "b": [0.3264, 0.7602, 0.3742, 0.7816]}, {"w": "12%", "b": [0.3795, 0.7602, 0.4152, 0.7816]}, {"w": "chance", "b": [0.4205, 0.7602, 0.4787, 0.7816]}, {"w": "of", "b": [0.484, 0.7602, 0.5008, 0.7816]}, {"w": "sampling", "b": [0.5061, 0.7602, 0.5825, 0.7816]}, {"w": "a", "b": [0.5878, 0.7602, 0.597, 0.7816]}, {"w": "skewed", "b": [0.6023, 0.7602, 0.6632, 0.7816]}, {"w": "test", "b": [0.6686, 0.7602, 0.6978, 0.7816]}, {"w": "set", "b": [0.7031, 0.7602, 0.7259, 0.7816]}, {"w": "with", "b": [0.7313, 0.7602, 0.7686, 0.7816]}, {"w": "either", "b": [0.7739, 0.7602, 0.8224, 0.7816]}, {"w": "less", "b": [0.8277, 0.7602, 0.8571, 0.7816]}, {"w": "than", "b": [0.1429, 0.7793, 0.1809, 0.8007]}, {"w": "49%", "b": [0.1876, 0.7793, 0.2233, 0.8007]}, {"w": "female", "b": [0.23, 0.7793, 0.2854, 0.8007]}, {"w": "or", "b": [0.2921, 0.7793, 0.3104, 0.8007]}, {"w": "more", "b": [0.3171, 0.7793, 0.3614, 0.8007]}, {"w": "than", "b": [0.3681, 0.7793, 0.4061, 0.8007]}, {"w": "54%", "b": [0.4128, 0.7793, 0.4485, 0.8007]}, {"w": "female.", "b": [0.4552, 0.7793, 0.5153, 0.8007]}, {"w": "Either", "b": [0.522, 0.7793, 0.5735, 0.8007]}, {"w": "way,", "b": [0.5802, 0.7793, 0.616, 0.8007]}, {"w": "the", "b": [0.6227, 0.7793, 0.649, 0.8007]}, {"w": "survey", "b": [0.6557, 0.7793, 0.7108, 0.8007]}, {"w": "results", "b": [0.7175, 0.7793, 0.7721, 0.8007]}, {"w": "would", "b": [0.7788, 0.7793, 0.831, 0.8007]}, {"w": "be", "b": [0.8377, 0.7793, 0.8571, 0.8007]}, {"w": "significantly", "b": [0.1429, 0.7983, 0.2447, 0.8197]}, {"w": "biased.", "b": [0.2494, 0.7983, 0.307, 0.8197]}]}, {"id": "b_10", "type": "equation", "text": "56 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "56", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.478, 0.9388]}]}]}, {"page": 83, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Suppose you chatted with experts who told you that the median income is a very important attribute to predict median housing prices. You may want to ensure that the test set is representative of the various categories of incomes in the whole dataset. Since the median income is a continuous numerical attribute, you first need to create an income category attribute. Let’s look at the median income histogram more closely (back in Figure 2-8): most median income values are clustered around 1.5 to 6 (i.e., $15,000–$60,000), but some median incomes go far beyond 6. It is important to have a sufficient number of instances in your dataset for each stratum, or else the estimate of the stratum’s importance may be biased. This means that you should not have too many strata, and each stratum should be large enough. The following code uses the pd.cut() function to create an income category attribute with 5 categories (labeled from 1 to 5): category 1 ranges from 0 to 1.5 (i.e., less than $15,000), category 2 from 1.5 to 3, and so on:", "words": [{"w": "Suppose", "b": [0.1429, 0.0791, 0.2128, 0.1005]}, {"w": "you", "b": [0.2207, 0.0791, 0.2519, 0.1005]}, {"w": "chatted", "b": [0.2598, 0.0791, 0.3211, 0.1005]}, {"w": "with", "b": [0.329, 0.0791, 0.3663, 0.1005]}, {"w": "experts", "b": [0.3742, 0.0791, 0.4344, 0.1005]}, {"w": "who", "b": [0.4423, 0.0791, 0.4784, 0.1005]}, {"w": "told", "b": [0.4863, 0.0791, 0.5195, 0.1005]}, {"w": "you", "b": [0.5274, 0.0791, 0.5587, 0.1005]}, {"w": "that", "b": [0.5666, 0.0791, 0.5992, 0.1005]}, {"w": "the", "b": [0.6071, 0.0791, 0.6334, 0.1005]}, {"w": "median", "b": [0.6413, 0.0791, 0.7044, 0.1005]}, {"w": "income", "b": [0.7123, 0.0791, 0.7746, 0.1005]}, {"w": "is", "b": [0.7825, 0.0791, 0.7958, 0.1005]}, {"w": "a", "b": [0.8037, 0.0791, 0.8128, 0.1005]}, {"w": "very", "b": [0.8207, 0.0791, 0.8571, 0.1005]}, {"w": "important", "b": [0.1429, 0.0981, 0.2272, 0.1195]}, {"w": "attribute", "b": [0.2342, 0.0981, 0.3058, 0.1195]}, {"w": "to", "b": [0.3128, 0.0981, 0.3298, 0.1195]}, {"w": "predict", "b": [0.3368, 0.0981, 0.3961, 0.1195]}, {"w": "median", "b": [0.4031, 0.0981, 0.4661, 0.1195]}, {"w": "housing", "b": [0.4731, 0.0981, 0.5403, 0.1195]}, {"w": "prices.", "b": [0.5473, 0.0981, 0.6016, 0.1195]}, {"w": "You", "b": [0.6085, 0.0981, 0.6409, 0.1195]}, {"w": "may", "b": [0.6479, 0.0981, 0.6833, 0.1195]}, {"w": "want", "b": [0.6903, 0.0981, 0.7311, 0.1195]}, {"w": "to", "b": [0.738, 0.0981, 0.755, 0.1195]}, {"w": "ensure", "b": [0.762, 0.0981, 0.8176, 0.1195]}, {"w": "that", "b": [0.8246, 0.0981, 0.8571, 0.1195]}, {"w": "the", "b": [0.1429, 0.1172, 0.1692, 0.1386]}, {"w": "test", "b": [0.1746, 0.1172, 0.2038, 0.1386]}, {"w": "set", "b": [0.2091, 0.1172, 0.232, 0.1386]}, {"w": "is", "b": [0.2373, 0.1172, 0.2505, 0.1386]}, {"w": "representative", "b": [0.2559, 0.1172, 0.373, 0.1386]}, {"w": "of", "b": [0.3784, 0.1172, 0.3952, 0.1386]}, {"w": "the", "b": [0.4005, 0.1172, 0.4269, 0.1386]}, {"w": "various", "b": [0.4322, 0.1172, 0.4936, 0.1386]}, {"w": "categories", "b": [0.499, 0.1172, 0.582, 0.1386]}, {"w": "of", "b": [0.5873, 0.1172, 0.6041, 0.1386]}, {"w": "incomes", "b": [0.6095, 0.1172, 0.6794, 0.1386]}, {"w": "in", "b": [0.6848, 0.1172, 0.7018, 0.1386]}, {"w": "the", "b": [0.7071, 0.1172, 0.7334, 0.1386]}, {"w": "whole", "b": [0.7388, 0.1172, 0.7889, 0.1386]}, {"w": "dataset.", "b": [0.7943, 0.1172, 0.8572, 0.1386]}, {"w": "Since", "b": [0.1429, 0.1362, 0.1874, 0.1576]}, {"w": "the", "b": [0.1928, 0.1362, 0.2191, 0.1576]}, {"w": "median", "b": [0.2245, 0.1362, 0.2875, 0.1576]}, {"w": "income", "b": [0.2929, 0.1362, 0.3552, 0.1576]}, {"w": "is", "b": [0.3606, 0.1362, 0.3738, 0.1576]}, {"w": "a", "b": [0.3792, 0.1362, 0.3883, 0.1576]}, {"w": "continuous", "b": [0.3937, 0.1362, 0.4875, 0.1576]}, {"w": "numerical", "b": [0.4928, 0.1362, 0.5774, 0.1576]}, {"w": "attribute,", "b": [0.5827, 0.1362, 0.6591, 0.1576]}, {"w": "you", "b": [0.6645, 0.1362, 0.6957, 0.1576]}, {"w": "first", "b": [0.7011, 0.1362, 0.7346, 0.1576]}, {"w": "need", "b": [0.74, 0.1362, 0.7801, 0.1576]}, {"w": "to", "b": [0.7854, 0.1362, 0.8024, 0.1576]}, {"w": "create", "b": [0.8078, 0.1362, 0.8571, 0.1576]}, {"w": "an", "b": [0.1429, 0.1553, 0.1634, 0.1767]}, {"w": "income", "b": [0.1683, 0.1553, 0.2306, 0.1767]}, {"w": "category", "b": [0.2355, 0.1553, 0.3066, 0.1767]}, {"w": "attribute.", "b": [0.3115, 0.1553, 0.3879, 0.1767]}, {"w": "Let’s", "b": [0.3928, 0.1553, 0.4289, 0.1767]}, {"w": "look", "b": [0.4338, 0.1553, 0.4707, 0.1767]}, {"w": "at", "b": [0.4756, 0.1553, 0.4907, 0.1767]}, {"w": "the", "b": [0.4956, 0.1553, 0.5219, 0.1767]}, {"w": "median", "b": [0.5268, 0.1553, 0.5899, 0.1767]}, {"w": "income", "b": [0.5948, 0.1553, 0.6571, 0.1767]}, {"w": "histogram", "b": [0.662, 0.1553, 0.747, 0.1767]}, {"w": "more", "b": [0.7519, 0.1553, 0.7962, 0.1767]}, {"w": "closely", "b": [0.8011, 0.1553, 0.8571, 0.1767]}, {"w": "(back", "b": [0.1428, 0.1743, 0.1889, 0.1957]}, {"w": "in", "b": [0.1953, 0.1743, 0.2123, 0.1957]}, {"w": "Figure", "b": [0.2187, 0.1743, 0.2727, 0.1957]}, {"w": "2-8):", "b": [0.279, 0.1743, 0.3184, 0.1957]}, {"w": "most", "b": [0.3248, 0.1743, 0.3665, 0.1957]}, {"w": "median", "b": [0.3729, 0.1743, 0.4359, 0.1957]}, {"w": "income", "b": [0.4423, 0.1743, 0.5046, 0.1957]}, {"w": "values", "b": [0.511, 0.1743, 0.5626, 0.1957]}, {"w": "are", "b": [0.569, 0.1743, 0.5947, 0.1957]}, {"w": "clustered", "b": [0.6011, 0.1743, 0.6767, 0.1957]}, {"w": "around", "b": [0.683, 0.1743, 0.744, 0.1957]}, {"w": "1.5", "b": [0.7504, 0.1743, 0.7751, 0.1957]}, {"w": "to", "b": [0.7815, 0.1743, 0.7985, 0.1957]}, {"w": "6", "b": [0.8049, 0.1743, 0.8149, 0.1957]}, {"w": "(i.e.,", "b": [0.8212, 0.1743, 0.8571, 0.1957]}, {"w": "$15,000–$60,000),", "b": [0.1429, 0.1933, 0.2952, 0.2148]}, {"w": "but", "b": [0.3006, 0.1933, 0.3286, 0.2148]}, {"w": "some", "b": [0.3341, 0.1933, 0.3783, 0.2148]}, {"w": "median", "b": [0.3837, 0.1933, 0.4468, 0.2148]}, {"w": "incomes", "b": [0.4522, 0.1933, 0.5222, 0.2148]}, {"w": "go", "b": [0.5277, 0.1933, 0.548, 0.2148]}, {"w": "far", "b": [0.5535, 0.1933, 0.5765, 0.2148]}, {"w": "beyond", "b": [0.582, 0.1933, 0.644, 0.2148]}, {"w": "6.", "b": [0.6495, 0.1933, 0.6642, 0.2148]}, {"w": "It", "b": [0.6697, 0.1933, 0.6823, 0.2148]}, {"w": "is", "b": [0.6878, 0.1933, 0.701, 0.2148]}, {"w": "important", "b": [0.7065, 0.1933, 0.7909, 0.2148]}, {"w": "to", "b": [0.7963, 0.1933, 0.8133, 0.2148]}, {"w": "have", "b": [0.8188, 0.1933, 0.8571, 0.2148]}, {"w": "a", "b": [0.1429, 0.2124, 0.152, 0.2338]}, {"w": "sufficient", "b": [0.1575, 0.2124, 0.2347, 0.2338]}, {"w": "number", "b": [0.2402, 0.2124, 0.3065, 0.2338]}, {"w": "of", "b": [0.312, 0.2124, 0.3288, 0.2338]}, {"w": "instances", "b": [0.3343, 0.2124, 0.4111, 0.2338]}, {"w": "in", "b": [0.4166, 0.2124, 0.4336, 0.2338]}, {"w": "your", "b": [0.4391, 0.2124, 0.4781, 0.2338]}, {"w": "dataset", "b": [0.4836, 0.2124, 0.5417, 0.2338]}, {"w": "for", "b": [0.5472, 0.2124, 0.5717, 0.2338]}, {"w": "each", "b": [0.5772, 0.2124, 0.6152, 0.2338]}, {"w": "stratum,", "b": [0.6207, 0.2124, 0.6904, 0.2338]}, {"w": "or", "b": [0.6959, 0.2124, 0.7142, 0.2338]}, {"w": "else", "b": [0.7197, 0.2124, 0.7504, 0.2338]}, {"w": "the", "b": [0.7559, 0.2124, 0.7822, 0.2338]}, {"w": "estimate", "b": [0.7877, 0.2124, 0.8571, 0.2338]}, {"w": "of", "b": [0.1429, 0.2314, 0.1596, 0.2529]}, {"w": "the", "b": [0.1656, 0.2314, 0.1919, 0.2529]}, {"w": "stratum’s", "b": [0.1978, 0.2314, 0.2714, 0.2529]}, {"w": "importance", "b": [0.2773, 0.2314, 0.3734, 0.2529]}, {"w": "may", "b": [0.3793, 0.2314, 0.4147, 0.2529]}, {"w": "be", "b": [0.4206, 0.2314, 0.4401, 0.2529]}, {"w": "biased.", "b": [0.446, 0.2314, 0.5035, 0.2529]}, {"w": "This", "b": [0.5095, 0.2314, 0.5467, 0.2529]}, {"w": "means", "b": [0.5526, 0.2314, 0.6067, 0.2529]}, {"w": "that", "b": [0.6126, 0.2314, 0.6452, 0.2529]}, {"w": "you", "b": [0.6511, 0.2314, 0.6824, 0.2529]}, {"w": "should", "b": [0.6883, 0.2314, 0.745, 0.2529]}, {"w": "not", "b": [0.7509, 0.2314, 0.7793, 0.2529]}, {"w": "have", "b": [0.7852, 0.2314, 0.8236, 0.2529]}, {"w": "too", "b": [0.8295, 0.2314, 0.8571, 0.2529]}, {"w": "many", "b": [0.1429, 0.2505, 0.1896, 0.2719]}, {"w": "strata,", "b": [0.1961, 0.2505, 0.2468, 0.2719]}, {"w": "and", "b": [0.2534, 0.2505, 0.285, 0.2719]}, {"w": "each", "b": [0.2915, 0.2505, 0.3295, 0.2719]}, {"w": "stratum", "b": [0.336, 0.2505, 0.401, 0.2719]}, {"w": "should", "b": [0.4075, 0.2505, 0.4643, 0.2719]}, {"w": "be", "b": [0.4708, 0.2505, 0.4903, 0.2719]}, {"w": "large", "b": [0.4968, 0.2505, 0.5376, 0.2719]}, {"w": "enough.", "b": [0.5441, 0.2505, 0.6117, 0.2719]}, {"w": "The", "b": [0.6183, 0.2505, 0.6511, 0.2719]}, {"w": "following", "b": [0.6577, 0.2505, 0.7366, 0.2719]}, {"w": "code", "b": [0.7432, 0.2505, 0.7825, 0.2719]}, {"w": "uses", "b": [0.789, 0.2505, 0.8243, 0.2719]}, {"w": "the", "b": [0.8308, 0.2505, 0.8572, 0.2719]}, {"w": "pd.cut()", "b": [0.1429, 0.2736, 0.222, 0.2887]}, {"w": "function", "b": [0.2289, 0.2704, 0.3003, 0.2918]}, {"w": "to", "b": [0.3071, 0.2704, 0.3241, 0.2918]}, {"w": "create", "b": [0.3309, 0.2704, 0.3803, 0.2918]}, {"w": "an", "b": [0.3872, 0.2704, 0.4077, 0.2918]}, {"w": "income", "b": [0.4145, 0.2704, 0.4769, 0.2918]}, {"w": "category", "b": [0.4837, 0.2704, 0.5548, 0.2918]}, {"w": "attribute", "b": [0.5616, 0.2704, 0.6333, 0.2918]}, {"w": "with", "b": [0.6401, 0.2704, 0.6774, 0.2918]}, {"w": "5", "b": [0.6843, 0.2704, 0.6943, 0.2918]}, {"w": "categories", "b": [0.7011, 0.2704, 0.7841, 0.2918]}, {"w": "(labeled", "b": [0.7909, 0.2704, 0.8571, 0.2918]}, {"w": "from", "b": [0.1429, 0.2895, 0.1844, 0.3109]}, {"w": "1", "b": [0.1899, 0.2895, 0.1999, 0.3109]}, {"w": "to", "b": [0.2053, 0.2895, 0.2223, 0.3109]}, {"w": "5):", "b": [0.2277, 0.2895, 0.2497, 0.3109]}, {"w": "category", "b": [0.2551, 0.2895, 0.3261, 0.3109]}, {"w": "1", "b": [0.3316, 0.2895, 0.3416, 0.3109]}, {"w": "ranges", "b": [0.347, 0.2895, 0.4015, 0.3109]}, {"w": "from", "b": [0.4069, 0.2895, 0.4485, 0.3109]}, {"w": "0", "b": [0.4539, 0.2895, 0.4639, 0.3109]}, {"w": "to", "b": [0.4694, 0.2895, 0.4863, 0.3109]}, {"w": "1.5", "b": [0.4918, 0.2895, 0.5165, 0.3109]}, {"w": "(i.e.,", "b": [0.5219, 0.2895, 0.5578, 0.3109]}, {"w": "less", "b": [0.5633, 0.2895, 0.5927, 0.3109]}, {"w": "than", "b": [0.5981, 0.2895, 0.6361, 0.3109]}, {"w": "$15,000),", "b": [0.6415, 0.2895, 0.7183, 0.3109]}, {"w": "category", "b": [0.7237, 0.2895, 0.7947, 0.3109]}, {"w": "2", "b": [0.8001, 0.2895, 0.8101, 0.3109]}, {"w": "from", "b": [0.8156, 0.2895, 0.8572, 0.3109]}, {"w": "1.5", "b": [0.1429, 0.3085, 0.1676, 0.3299]}, {"w": "to", "b": [0.1723, 0.3085, 0.1893, 0.3299]}, {"w": "3,", "b": [0.194, 0.3085, 0.2088, 0.3299]}, {"w": "and", "b": [0.2135, 0.3085, 0.2451, 0.3299]}, {"w": "so", "b": [0.2498, 0.3085, 0.2681, 0.3299]}, {"w": "on:", "b": [0.2728, 0.3085, 0.2996, 0.3299]}]}, {"id": "b_1", "type": "paragraph", "text": "housing[\"income_cat\"] = pd.cut(housing[\"median_income\"], bins=[0., 1.5, 3.0, 4.5, 6., np.inf], labels=[1, 2, 3, 4, 5])", "words": [{"w": "housing[\"income_cat\"]", "b": [0.1766, 0.3405, 0.3537, 0.3534]}, {"w": "=", "b": [0.3621, 0.3405, 0.3705, 0.3534]}, {"w": "pd.cut(housing[\"median_income\"],", "b": [0.379, 0.3405, 0.6488, 0.3534]}, {"w": "bins=[0.,", "b": [0.438, 0.3559, 0.5139, 0.3688]}, {"w": "1.5,", "b": [0.5223, 0.3559, 0.5561, 0.3688]}, {"w": "3.0,", "b": [0.5645, 0.3559, 0.5982, 0.3688]}, {"w": "4.5,", "b": [0.6066, 0.3559, 0.6404, 0.3688]}, {"w": "6.,", "b": [0.6488, 0.3559, 0.6741, 0.3688]}, {"w": "np.inf],", "b": [0.6825, 0.3559, 0.75, 0.3688]}, {"w": "labels=[1,", "b": [0.438, 0.3713, 0.5223, 0.3842]}, {"w": "2,", "b": [0.5308, 0.3713, 0.5476, 0.3842]}, {"w": "3,", "b": [0.5561, 0.3713, 0.5729, 0.3842]}, {"w": "4,", "b": [0.5814, 0.3713, 0.5982, 0.3842]}, {"w": "5])", "b": [0.6066, 0.3713, 0.6319, 0.3842]}]}, {"id": "b_2", "type": "equation", "text": "These income categories are represented in Figure 2-9:", "words": [{"w": "These", "b": [0.1429, 0.392, 0.1922, 0.4134]}, {"w": "income", "b": [0.1969, 0.392, 0.2593, 0.4134]}, {"w": "categories", "b": [0.264, 0.392, 0.3469, 0.4134]}, {"w": "are", "b": [0.3517, 0.392, 0.3774, 0.4134]}, {"w": "represented", "b": [0.3821, 0.392, 0.4799, 0.4134]}, {"w": "in", "b": [0.4847, 0.392, 0.5016, 0.4134]}, {"w": "Figure", "b": [0.5064, 0.392, 0.5604, 0.4134]}, {"w": "2-9:", "b": [0.5651, 0.392, 0.5973, 0.4134]}]}, {"id": "b_3", "type": "equation", "text": "housing[\"income_cat\"].hist()", "words": [{"w": "housing[\"income_cat\"].hist()", "b": [0.1766, 0.424, 0.4127, 0.4368]}]}, {"id": "b_4", "type": "equation", "text": "Figure 2-9. Histogram of income categories", "words": [{"w": "Figure", "b": [0.1428, 0.7136, 0.1943, 0.7352]}, {"w": "2-9.", "b": [0.1991, 0.7136, 0.2308, 0.7352]}, {"w": "Histogram", "b": [0.2356, 0.7136, 0.3211, 0.7352]}, {"w": "of", "b": [0.3259, 0.7136, 0.3411, 0.7352]}, {"w": "income", "b": [0.3459, 0.7136, 0.4042, 0.7352]}, {"w": "categories", "b": [0.409, 0.7136, 0.4878, 0.7352]}]}, {"id": "b_5", "type": "paragraph", "text": "Now you are ready to do stratified sampling based on the income category. For this you can use Scikit-Learn’s StratifiedShuffleSplit class:", "words": [{"w": "Now", "b": [0.1428, 0.751, 0.1827, 0.7724]}, {"w": "you", "b": [0.1892, 0.751, 0.2204, 0.7724]}, {"w": "are", "b": [0.2269, 0.751, 0.2526, 0.7724]}, {"w": "ready", "b": [0.259, 0.751, 0.3053, 0.7724]}, {"w": "to", "b": [0.3118, 0.751, 0.3287, 0.7724]}, {"w": "do", "b": [0.3352, 0.751, 0.3568, 0.7724]}, {"w": "stratified", "b": [0.3633, 0.751, 0.4373, 0.7724]}, {"w": "sampling", "b": [0.4437, 0.751, 0.5201, 0.7724]}, {"w": "based", "b": [0.5266, 0.751, 0.5738, 0.7724]}, {"w": "on", "b": [0.5802, 0.751, 0.6023, 0.7724]}, {"w": "the", "b": [0.6087, 0.751, 0.635, 0.7724]}, {"w": "income", "b": [0.6415, 0.751, 0.7038, 0.7724]}, {"w": "category.", "b": [0.7103, 0.751, 0.7845, 0.7724]}, {"w": "For", "b": [0.791, 0.751, 0.82, 0.7724]}, {"w": "this", "b": [0.8264, 0.751, 0.8571, 0.7724]}, {"w": "you", "b": [0.1429, 0.7709, 0.1741, 0.7923]}, {"w": "can", "b": [0.1788, 0.7709, 0.2082, 0.7923]}, {"w": "use", "b": [0.2129, 0.7709, 0.2405, 0.7923]}, {"w": "Scikit-Learn’s", "b": [0.2452, 0.7709, 0.3561, 0.7923]}, {"w": "StratifiedShuffleSplit", "b": [0.3608, 0.7741, 0.5786, 0.7892]}, {"w": "class:", "b": [0.5833, 0.7709, 0.6266, 0.7923]}]}, {"id": "b_6", "type": "equation", "text": "from sklearn.model_selection import StratifiedShuffleSplit", "words": [{"w": "from", "b": [0.1766, 0.8029, 0.2103, 0.8158]}, {"w": "sklearn.model_selection", "b": [0.2188, 0.8029, 0.4127, 0.8158]}, {"w": "import", "b": [0.4211, 0.8029, 0.4717, 0.8158]}, {"w": "StratifiedShuffleSplit", "b": [0.4802, 0.8029, 0.6657, 0.8158]}]}, {"id": "b_7", "type": "paragraph", "text": "split = StratifiedShuffleSplit(n_splits=1, test_size=0.2, random_state=42) for train_index, test_index in split.split(housing, housing[\"income_cat\"]): strat_train_set = housing.loc[train_index] strat_test_set = housing.loc[test_index]", "words": [{"w": "split", "b": [0.1766, 0.8337, 0.2188, 0.8466]}, {"w": "=", "b": [0.2272, 0.8337, 0.2356, 0.8466]}, {"w": "StratifiedShuffleSplit(n_splits=1,", "b": [0.2441, 0.8337, 0.5308, 0.8466]}, {"w": "test_size=0.2,", "b": [0.5392, 0.8337, 0.6572, 0.8466]}, {"w": "random_state=42)", "b": [0.6657, 0.8337, 0.8006, 0.8466]}, {"w": "for", "b": [0.1766, 0.8492, 0.2019, 0.862]}, {"w": "train_index,", "b": [0.2103, 0.8492, 0.3115, 0.862]}, {"w": "test_index", "b": [0.3199, 0.8492, 0.4043, 0.862]}, {"w": "in", "b": [0.4127, 0.8492, 0.4296, 0.862]}, {"w": "split.split(housing,", "b": [0.438, 0.8492, 0.6067, 0.862]}, {"w": "housing[\"income_cat\"]):", "b": [0.6151, 0.8492, 0.809, 0.862]}, {"w": "strat_train_set", "b": [0.2103, 0.8646, 0.3368, 0.8774]}, {"w": "=", "b": [0.3452, 0.8646, 0.3537, 0.8774]}, {"w": "housing.loc[train_index]", "b": [0.3621, 0.8646, 0.5645, 0.8774]}, {"w": "strat_test_set", "b": [0.2103, 0.88, 0.3284, 0.8929]}, {"w": "=", "b": [0.3368, 0.88, 0.3452, 0.8929]}, {"w": "housing.loc[test_index]", "b": [0.3537, 0.88, 0.5476, 0.8929]}]}, {"id": "b_8", "type": "paragraph", "text": "Get the Data | 57", "words": [{"w": "Get", "b": [0.7296, 0.9225, 0.7499, 0.9388]}, {"w": "the", "b": [0.7527, 0.9225, 0.7726, 0.9388]}, {"w": "Data", "b": [0.7755, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "57", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 84, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Let’s see if this worked as expected. You can start by looking at the income category proportions in the test set:", "words": [{"w": "Let’s", "b": [0.1429, 0.0791, 0.179, 0.1005]}, {"w": "see", "b": [0.1854, 0.0791, 0.2107, 0.1005]}, {"w": "if", "b": [0.217, 0.0791, 0.2288, 0.1005]}, {"w": "this", "b": [0.2351, 0.0791, 0.2658, 0.1005]}, {"w": "worked", "b": [0.2722, 0.0791, 0.335, 0.1005]}, {"w": "as", "b": [0.3413, 0.0791, 0.3581, 0.1005]}, {"w": "expected.", "b": [0.3644, 0.0791, 0.4427, 0.1005]}, {"w": "You", "b": [0.449, 0.0791, 0.4814, 0.1005]}, {"w": "can", "b": [0.4877, 0.0791, 0.517, 0.1005]}, {"w": "start", "b": [0.5234, 0.0791, 0.5606, 0.1005]}, {"w": "by", "b": [0.5669, 0.0791, 0.5871, 0.1005]}, {"w": "looking", "b": [0.5934, 0.0791, 0.657, 0.1005]}, {"w": "at", "b": [0.6633, 0.0791, 0.6784, 0.1005]}, {"w": "the", "b": [0.6848, 0.0791, 0.7111, 0.1005]}, {"w": "income", "b": [0.7174, 0.0791, 0.7798, 0.1005]}, {"w": "category", "b": [0.7861, 0.0791, 0.8571, 0.1005]}, {"w": "proportions", "b": [0.1429, 0.0981, 0.243, 0.1195]}, {"w": "in", "b": [0.2477, 0.0981, 0.2647, 0.1195]}, {"w": "the", "b": [0.2694, 0.0981, 0.2958, 0.1195]}, {"w": "test", "b": [0.3005, 0.0981, 0.3297, 0.1195]}, {"w": "set:", "b": [0.3344, 0.0981, 0.362, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> strat_test_set[\"income_cat\"].value_counts() / len(strat_test_set) 3 0.350533 2 0.318798 4 0.176357 5 0.114583 1 0.039729 Name: income_cat, dtype: float64", "words": [{"w": ">>>", "b": [0.1766, 0.1301, 0.2019, 0.1429]}, {"w": "strat_test_set[\"income_cat\"].value_counts()", "b": [0.2103, 0.1301, 0.5729, 0.1429]}, {"w": "/", "b": [0.5814, 0.1301, 0.5898, 0.1429]}, {"w": "len(strat_test_set)", "b": [0.5982, 0.1301, 0.7584, 0.1429]}, {"w": "3", "b": [0.1766, 0.1455, 0.185, 0.1584]}, {"w": "0.350533", "b": [0.2188, 0.1455, 0.2862, 0.1584]}, {"w": "2", "b": [0.1766, 0.1609, 0.185, 0.1738]}, {"w": "0.318798", "b": [0.2188, 0.1609, 0.2862, 0.1738]}, {"w": "4", "b": [0.1766, 0.1763, 0.185, 0.1892]}, {"w": "0.176357", "b": [0.2188, 0.1763, 0.2862, 0.1892]}, {"w": "5", "b": [0.1766, 0.1918, 0.185, 0.2046]}, {"w": "0.114583", "b": [0.2188, 0.1918, 0.2862, 0.2046]}, {"w": "1", "b": [0.1766, 0.2072, 0.185, 0.22]}, {"w": "0.039729", "b": [0.2188, 0.2072, 0.2862, 0.22]}, {"w": "Name:", "b": [0.1766, 0.2226, 0.2188, 0.2354]}, {"w": "income_cat,", "b": [0.2272, 0.2226, 0.3199, 0.2354]}, {"w": "dtype:", "b": [0.3284, 0.2226, 0.379, 0.2354]}, {"w": "float64", "b": [0.3874, 0.2226, 0.4464, 0.2354]}]}, {"id": "b_2", "type": "paragraph", "text": "With similar code you can measure the income category proportions in the full data‐ set. Figure 2-10 compares the income category proportions in the overall dataset, in the test set generated with stratified sampling, and in a test set generated using purely random sampling. As you can see, the test set generated using stratified sampling has income category proportions almost identical to those in the full dataset, whereas the test set generated using purely random sampling is quite skewed.", "words": [{"w": "With", "b": [0.1428, 0.2432, 0.1853, 0.2646]}, {"w": "similar", "b": [0.1907, 0.2432, 0.2487, 0.2646]}, {"w": "code", "b": [0.2541, 0.2432, 0.2934, 0.2646]}, {"w": "you", "b": [0.2987, 0.2432, 0.33, 0.2646]}, {"w": "can", "b": [0.3354, 0.2432, 0.3647, 0.2646]}, {"w": "measure", "b": [0.3701, 0.2432, 0.4405, 0.2646]}, {"w": "the", "b": [0.4459, 0.2432, 0.4722, 0.2646]}, {"w": "income", "b": [0.4776, 0.2432, 0.5399, 0.2646]}, {"w": "category", "b": [0.5453, 0.2432, 0.6163, 0.2646]}, {"w": "proportions", "b": [0.6217, 0.2432, 0.7219, 0.2646]}, {"w": "in", "b": [0.7272, 0.2432, 0.7442, 0.2646]}, {"w": "the", "b": [0.7496, 0.2432, 0.7759, 0.2646]}, {"w": "full", "b": [0.7813, 0.2432, 0.8091, 0.2646]}, {"w": "data‐", "b": [0.8145, 0.2432, 0.8571, 0.2646]}, {"w": "set.", "b": [0.1429, 0.2623, 0.1705, 0.2837]}, {"w": "Figure", "b": [0.1767, 0.2623, 0.2307, 0.2837]}, {"w": "2-10", "b": [0.237, 0.2623, 0.2744, 0.2837]}, {"w": "compares", "b": [0.2807, 0.2623, 0.3611, 0.2837]}, {"w": "the", "b": [0.3674, 0.2623, 0.3937, 0.2837]}, {"w": "income", "b": [0.4, 0.2623, 0.4623, 0.2837]}, {"w": "category", "b": [0.4686, 0.2623, 0.5397, 0.2837]}, {"w": "proportions", "b": [0.5459, 0.2623, 0.6461, 0.2837]}, {"w": "in", "b": [0.6524, 0.2623, 0.6693, 0.2837]}, {"w": "the", "b": [0.6756, 0.2623, 0.7019, 0.2837]}, {"w": "overall", "b": [0.7082, 0.2623, 0.7648, 0.2837]}, {"w": "dataset,", "b": [0.771, 0.2623, 0.8339, 0.2837]}, {"w": "in", "b": [0.8402, 0.2623, 0.8571, 0.2837]}, {"w": "the", "b": [0.1429, 0.2813, 0.1692, 0.3027]}, {"w": "test", "b": [0.1743, 0.2813, 0.2035, 0.3027]}, {"w": "set", "b": [0.2087, 0.2813, 0.2315, 0.3027]}, {"w": "generated", "b": [0.2366, 0.2813, 0.3182, 0.3027]}, {"w": "with", "b": [0.3233, 0.2813, 0.3606, 0.3027]}, {"w": "stratified", "b": [0.3658, 0.2813, 0.4398, 0.3027]}, {"w": "sampling,", "b": [0.4449, 0.2813, 0.526, 0.3027]}, {"w": "and", "b": [0.5312, 0.2813, 0.5627, 0.3027]}, {"w": "in", "b": [0.5678, 0.2813, 0.5848, 0.3027]}, {"w": "a", "b": [0.5899, 0.2813, 0.5991, 0.3027]}, {"w": "test", "b": [0.6042, 0.2813, 0.6334, 0.3027]}, {"w": "set", "b": [0.6385, 0.2813, 0.6614, 0.3027]}, {"w": "generated", "b": [0.6665, 0.2813, 0.7481, 0.3027]}, {"w": "using", "b": [0.7532, 0.2813, 0.7986, 0.3027]}, {"w": "purely", "b": [0.8037, 0.2813, 0.8571, 0.3027]}, {"w": "random", "b": [0.1429, 0.3004, 0.2098, 0.3218]}, {"w": "sampling.", "b": [0.2152, 0.3004, 0.2963, 0.3218]}, {"w": "As", "b": [0.3017, 0.3004, 0.3237, 0.3218]}, {"w": "you", "b": [0.3291, 0.3004, 0.3603, 0.3218]}, {"w": "can", "b": [0.3657, 0.3004, 0.395, 0.3218]}, {"w": "see,", "b": [0.4004, 0.3004, 0.4305, 0.3218]}, {"w": "the", "b": [0.4359, 0.3004, 0.4622, 0.3218]}, {"w": "test", "b": [0.4676, 0.3004, 0.4968, 0.3218]}, {"w": "set", "b": [0.5022, 0.3004, 0.525, 0.3218]}, {"w": "generated", "b": [0.5304, 0.3004, 0.6119, 0.3218]}, {"w": "using", "b": [0.6173, 0.3004, 0.6627, 0.3218]}, {"w": "stratified", "b": [0.6681, 0.3004, 0.7421, 0.3218]}, {"w": "sampling", "b": [0.7475, 0.3004, 0.8239, 0.3218]}, {"w": "has", "b": [0.8292, 0.3004, 0.8571, 0.3218]}, {"w": "income", "b": [0.1429, 0.3194, 0.2052, 0.3408]}, {"w": "category", "b": [0.2105, 0.3194, 0.2815, 0.3408]}, {"w": "proportions", "b": [0.2868, 0.3194, 0.387, 0.3408]}, {"w": "almost", "b": [0.3923, 0.3194, 0.4484, 0.3408]}, {"w": "identical", "b": [0.4537, 0.3194, 0.5253, 0.3408]}, {"w": "to", "b": [0.5306, 0.3194, 0.5476, 0.3408]}, {"w": "those", "b": [0.5529, 0.3194, 0.5975, 0.3408]}, {"w": "in", "b": [0.6028, 0.3194, 0.6197, 0.3408]}, {"w": "the", "b": [0.625, 0.3194, 0.6514, 0.3408]}, {"w": "full", "b": [0.6567, 0.3194, 0.6844, 0.3408]}, {"w": "dataset,", "b": [0.6897, 0.3194, 0.7526, 0.3408]}, {"w": "whereas", "b": [0.7579, 0.3194, 0.8255, 0.3408]}, {"w": "the", "b": [0.8308, 0.3194, 0.8572, 0.3408]}, {"w": "test", "b": [0.1429, 0.3385, 0.1721, 0.3599]}, {"w": "set", "b": [0.1768, 0.3385, 0.1997, 0.3599]}, {"w": "generated", "b": [0.2044, 0.3385, 0.2859, 0.3599]}, {"w": "using", "b": [0.2907, 0.3385, 0.3361, 0.3599]}, {"w": "purely", "b": [0.3408, 0.3385, 0.3942, 0.3599]}, {"w": "random", "b": [0.3989, 0.3385, 0.4659, 0.3599]}, {"w": "sampling", "b": [0.4706, 0.3385, 0.547, 0.3599]}, {"w": "is", "b": [0.5517, 0.3385, 0.565, 0.3599]}, {"w": "quite", "b": [0.5697, 0.3385, 0.6122, 0.3599]}, {"w": "skewed.", "b": [0.6169, 0.3385, 0.6826, 0.3599]}]}, {"id": "b_3", "type": "paragraph", "text": "Figure 2-10. Sampling bias comparison of stratified versus purely random sampling", "words": [{"w": "Figure", "b": [0.1429, 0.543, 0.1943, 0.5646]}, {"w": "2-10.", "b": [0.1991, 0.543, 0.2407, 0.5646]}, {"w": "Sampling", "b": [0.2455, 0.543, 0.3211, 0.5646]}, {"w": "bias", "b": [0.3259, 0.543, 0.3587, 0.5646]}, {"w": "comparison", "b": [0.3634, 0.543, 0.4581, 0.5646]}, {"w": "of", "b": [0.4629, 0.543, 0.4781, 0.5646]}, {"w": "stratified", "b": [0.4829, 0.543, 0.5562, 0.5646]}, {"w": "versus", "b": [0.561, 0.543, 0.6111, 0.5646]}, {"w": "purely", "b": [0.6159, 0.543, 0.6659, 0.5646]}, {"w": "random", "b": [0.6707, 0.543, 0.7352, 0.5646]}, {"w": "sampling", "b": [0.74, 0.543, 0.8128, 0.5646]}]}, {"id": "b_4", "type": "paragraph", "text": "Now you should remove the income_cat attribute so the data is back to its original state:", "words": [{"w": "Now", "b": [0.1429, 0.5813, 0.1827, 0.6027]}, {"w": "you", "b": [0.1894, 0.5813, 0.2206, 0.6027]}, {"w": "should", "b": [0.2273, 0.5813, 0.284, 0.6027]}, {"w": "remove", "b": [0.2907, 0.5813, 0.3534, 0.6027]}, {"w": "the", "b": [0.3601, 0.5813, 0.3864, 0.6027]}, {"w": "income_cat", "b": [0.3931, 0.5844, 0.492, 0.5995]}, {"w": "attribute", "b": [0.4987, 0.5813, 0.5703, 0.6027]}, {"w": "so", "b": [0.577, 0.5813, 0.5952, 0.6027]}, {"w": "the", "b": [0.6019, 0.5813, 0.6282, 0.6027]}, {"w": "data", "b": [0.6349, 0.5813, 0.6701, 0.6027]}, {"w": "is", "b": [0.6768, 0.5813, 0.69, 0.6027]}, {"w": "back", "b": [0.6967, 0.5813, 0.7355, 0.6027]}, {"w": "to", "b": [0.7422, 0.5813, 0.7592, 0.6027]}, {"w": "its", "b": [0.7658, 0.5813, 0.7854, 0.6027]}, {"w": "original", "b": [0.7921, 0.5813, 0.8571, 0.6027]}, {"w": "state:", "b": [0.1429, 0.6003, 0.1856, 0.6217]}]}, {"id": "b_5", "type": "paragraph", "text": "for set_ in (strat_train_set, strat_test_set): set_.drop(\"income_cat\", axis=1, inplace=True)", "words": [{"w": "for", "b": [0.1766, 0.6323, 0.2019, 0.6451]}, {"w": "set_", "b": [0.2103, 0.6323, 0.2441, 0.6451]}, {"w": "in", "b": [0.2525, 0.6323, 0.2693, 0.6451]}, {"w": "(strat_train_set,", "b": [0.2778, 0.6323, 0.4211, 0.6451]}, {"w": "strat_test_set):", "b": [0.4296, 0.6323, 0.5645, 0.6451]}, {"w": "set_.drop(\"income_cat\",", "b": [0.2103, 0.6477, 0.4043, 0.6605]}, {"w": "axis=1,", "b": [0.4127, 0.6477, 0.4717, 0.6605]}, {"w": "inplace=True)", "b": [0.4802, 0.6477, 0.5898, 0.6605]}]}, {"id": "b_6", "type": "paragraph", "text": "We spent quite a bit of time on test set generation for a good reason: this is an often neglected but critical part of a Machine Learning project. Moreover, many of these ideas will be useful later when we discuss cross-validation. Now it’s time to move on to the next stage: exploring the data.", "words": [{"w": "We", "b": [0.1428, 0.6683, 0.1699, 0.6897]}, {"w": "spent", "b": [0.1758, 0.6683, 0.2206, 0.6897]}, {"w": "quite", "b": [0.2265, 0.6683, 0.269, 0.6897]}, {"w": "a", "b": [0.2749, 0.6683, 0.2841, 0.6897]}, {"w": "bit", "b": [0.29, 0.6683, 0.3125, 0.6897]}, {"w": "of", "b": [0.3185, 0.6683, 0.3352, 0.6897]}, {"w": "time", "b": [0.3412, 0.6683, 0.379, 0.6897]}, {"w": "on", "b": [0.3849, 0.6683, 0.407, 0.6897]}, {"w": "test", "b": [0.4129, 0.6683, 0.4421, 0.6897]}, {"w": "set", "b": [0.448, 0.6683, 0.4709, 0.6897]}, {"w": "generation", "b": [0.4768, 0.6683, 0.5661, 0.6897]}, {"w": "for", "b": [0.572, 0.6683, 0.5965, 0.6897]}, {"w": "a", "b": [0.6024, 0.6683, 0.6116, 0.6897]}, {"w": "good", "b": [0.6175, 0.6683, 0.6595, 0.6897]}, {"w": "reason:", "b": [0.6654, 0.6683, 0.7256, 0.6897]}, {"w": "this", "b": [0.7315, 0.6683, 0.7622, 0.6897]}, {"w": "is", "b": [0.7681, 0.6683, 0.7814, 0.6897]}, {"w": "an", "b": [0.7873, 0.6683, 0.8078, 0.6897]}, {"w": "often", "b": [0.8137, 0.6683, 0.8571, 0.6897]}, {"w": "neglected", "b": [0.1429, 0.6874, 0.222, 0.7088]}, {"w": "but", "b": [0.2292, 0.6874, 0.2572, 0.7088]}, {"w": "critical", "b": [0.2644, 0.6874, 0.3217, 0.7088]}, {"w": "part", "b": [0.3289, 0.6874, 0.363, 0.7088]}, {"w": "of", "b": [0.3702, 0.6874, 0.387, 0.7088]}, {"w": "a", "b": [0.3942, 0.6874, 0.4034, 0.7088]}, {"w": "Machine", "b": [0.4106, 0.6874, 0.4837, 0.7088]}, {"w": "Learning", "b": [0.4909, 0.6874, 0.566, 0.7088]}, {"w": "project.", "b": [0.5732, 0.6874, 0.6365, 0.7088]}, {"w": "Moreover,", "b": [0.6437, 0.6874, 0.7292, 0.7088]}, {"w": "many", "b": [0.7364, 0.6874, 0.7831, 0.7088]}, {"w": "of", "b": [0.7903, 0.6874, 0.8071, 0.7088]}, {"w": "these", "b": [0.8143, 0.6874, 0.8571, 0.7088]}, {"w": "ideas", "b": [0.1429, 0.7064, 0.1851, 0.7278]}, {"w": "will", "b": [0.1911, 0.7064, 0.2215, 0.7278]}, {"w": "be", "b": [0.2276, 0.7064, 0.247, 0.7278]}, {"w": "useful", "b": [0.253, 0.7064, 0.3031, 0.7278]}, {"w": "later", "b": [0.3091, 0.7064, 0.3461, 0.7278]}, {"w": "when", "b": [0.3521, 0.7064, 0.3978, 0.7278]}, {"w": "we", "b": [0.4038, 0.7064, 0.4269, 0.7278]}, {"w": "discuss", "b": [0.4329, 0.7064, 0.4923, 0.7278]}, {"w": "cross-validation.", "b": [0.4984, 0.7064, 0.6364, 0.7278]}, {"w": "Now", "b": [0.6424, 0.7064, 0.6822, 0.7278]}, {"w": "it’s", "b": [0.6883, 0.7064, 0.71, 0.7278]}, {"w": "time", "b": [0.716, 0.7064, 0.7539, 0.7278]}, {"w": "to", "b": [0.7599, 0.7064, 0.7769, 0.7278]}, {"w": "move", "b": [0.7829, 0.7064, 0.8291, 0.7278]}, {"w": "on", "b": [0.8351, 0.7064, 0.8571, 0.7278]}, {"w": "to", "b": [0.1429, 0.7255, 0.1598, 0.7469]}, {"w": "the", "b": [0.1646, 0.7255, 0.1909, 0.7469]}, {"w": "next", "b": [0.1956, 0.7255, 0.2321, 0.7469]}, {"w": "stage:", "b": [0.2368, 0.7255, 0.2833, 0.7469]}, {"w": "exploring", "b": [0.288, 0.7255, 0.368, 0.7469]}, {"w": "the", "b": [0.3727, 0.7255, 0.399, 0.7469]}, {"w": "data.", "b": [0.4038, 0.7255, 0.4438, 0.7469]}]}, {"id": "b_7", "type": "paragraph", "text": "Discover and Visualize the Data to Gain Insights", "words": [{"w": "Discover", "b": [0.1429, 0.7599, 0.246, 0.7941]}, {"w": "and", "b": [0.2519, 0.7599, 0.299, 0.7941]}, {"w": "Visualize", "b": [0.3049, 0.7599, 0.4145, 0.7941]}, {"w": "the", "b": [0.4204, 0.7599, 0.4622, 0.7941]}, {"w": "Data", "b": [0.4682, 0.7599, 0.5263, 0.7941]}, {"w": "to", "b": [0.5322, 0.7599, 0.5583, 0.7941]}, {"w": "Gain", "b": [0.5643, 0.7599, 0.6202, 0.7941]}, {"w": "Insights", "b": [0.6262, 0.7599, 0.7248, 0.7941]}]}, {"id": "b_8", "type": "paragraph", "text": "So far you have only taken a quick glance at the data to get a general understanding of the kind of data you are manipulating. Now the goal is to go a little bit more in depth.", "words": [{"w": "So", "b": [0.1429, 0.8011, 0.1634, 0.8225]}, {"w": "far", "b": [0.1682, 0.8011, 0.1912, 0.8225]}, {"w": "you", "b": [0.196, 0.8011, 0.2272, 0.8225]}, {"w": "have", "b": [0.232, 0.8011, 0.2704, 0.8225]}, {"w": "only", "b": [0.2752, 0.8011, 0.3121, 0.8225]}, {"w": "taken", "b": [0.3169, 0.8011, 0.3629, 0.8225]}, {"w": "a", "b": [0.3677, 0.8011, 0.3769, 0.8225]}, {"w": "quick", "b": [0.3817, 0.8011, 0.4281, 0.8225]}, {"w": "glance", "b": [0.4329, 0.8011, 0.4861, 0.8225]}, {"w": "at", "b": [0.4909, 0.8011, 0.506, 0.8225]}, {"w": "the", "b": [0.5108, 0.8011, 0.5372, 0.8225]}, {"w": "data", "b": [0.542, 0.8011, 0.5772, 0.8225]}, {"w": "to", "b": [0.582, 0.8011, 0.599, 0.8225]}, {"w": "get", "b": [0.6038, 0.8011, 0.6287, 0.8225]}, {"w": "a", "b": [0.6335, 0.8011, 0.6427, 0.8225]}, {"w": "general", "b": [0.6475, 0.8011, 0.7085, 0.8225]}, {"w": "understanding", "b": [0.7132, 0.8011, 0.8356, 0.8225]}, {"w": "of", "b": [0.8404, 0.8011, 0.8571, 0.8225]}, {"w": "the", "b": [0.1429, 0.8201, 0.1692, 0.8415]}, {"w": "kind", "b": [0.1739, 0.8201, 0.2122, 0.8415]}, {"w": "of", "b": [0.217, 0.8201, 0.2337, 0.8415]}, {"w": "data", "b": [0.2385, 0.8201, 0.2737, 0.8415]}, {"w": "you", "b": [0.2785, 0.8201, 0.3097, 0.8415]}, {"w": "are", "b": [0.3144, 0.8201, 0.3402, 0.8415]}, {"w": "manipulating.", "b": [0.3449, 0.8201, 0.4619, 0.8415]}, {"w": "Now", "b": [0.4666, 0.8201, 0.5065, 0.8415]}, {"w": "the", "b": [0.5112, 0.8201, 0.5376, 0.8415]}, {"w": "goal", "b": [0.5423, 0.8201, 0.5771, 0.8415]}, {"w": "is", "b": [0.5818, 0.8201, 0.595, 0.8415]}, {"w": "to", "b": [0.5998, 0.8201, 0.6167, 0.8415]}, {"w": "go", "b": [0.6215, 0.8201, 0.6419, 0.8415]}, {"w": "a", "b": [0.6466, 0.8201, 0.6557, 0.8415]}, {"w": "little", "b": [0.6605, 0.8201, 0.6981, 0.8415]}, {"w": "bit", "b": [0.7029, 0.8201, 0.7254, 0.8415]}, {"w": "more", "b": [0.7301, 0.8201, 0.7744, 0.8415]}, {"w": "in", "b": [0.7791, 0.8201, 0.7961, 0.8415]}, {"w": "depth.", "b": [0.8008, 0.8201, 0.8538, 0.8415]}]}, {"id": "b_9", "type": "paragraph", "text": "First, make sure you have put the test set aside and you are only exploring the train‐ ing set. Also, if the training set is very large, you may want to sample an exploration", "words": [{"w": "First,", "b": [0.1429, 0.8482, 0.1859, 0.8696]}, {"w": "make", "b": [0.1917, 0.8482, 0.2371, 0.8696]}, {"w": "sure", "b": [0.2429, 0.8482, 0.2782, 0.8696]}, {"w": "you", "b": [0.284, 0.8482, 0.3152, 0.8696]}, {"w": "have", "b": [0.321, 0.8482, 0.3594, 0.8696]}, {"w": "put", "b": [0.3652, 0.8482, 0.3935, 0.8696]}, {"w": "the", "b": [0.3993, 0.8482, 0.4257, 0.8696]}, {"w": "test", "b": [0.4315, 0.8482, 0.4607, 0.8696]}, {"w": "set", "b": [0.4665, 0.8482, 0.4893, 0.8696]}, {"w": "aside", "b": [0.4951, 0.8482, 0.5373, 0.8696]}, {"w": "and", "b": [0.5431, 0.8482, 0.5747, 0.8696]}, {"w": "you", "b": [0.5804, 0.8482, 0.6117, 0.8696]}, {"w": "are", "b": [0.6175, 0.8482, 0.6432, 0.8696]}, {"w": "only", "b": [0.649, 0.8482, 0.6859, 0.8696]}, {"w": "exploring", "b": [0.6916, 0.8482, 0.7716, 0.8696]}, {"w": "the", "b": [0.7774, 0.8482, 0.8037, 0.8696]}, {"w": "train‐", "b": [0.8095, 0.8482, 0.8571, 0.8696]}, {"w": "ing", "b": [0.1429, 0.8673, 0.1696, 0.8887]}, {"w": "set.", "b": [0.1756, 0.8673, 0.2032, 0.8887]}, {"w": "Also,", "b": [0.2091, 0.8673, 0.2512, 0.8887]}, {"w": "if", "b": [0.2572, 0.8673, 0.2689, 0.8887]}, {"w": "the", "b": [0.2749, 0.8673, 0.3012, 0.8887]}, {"w": "training", "b": [0.3072, 0.8673, 0.3741, 0.8887]}, {"w": "set", "b": [0.3801, 0.8673, 0.403, 0.8887]}, {"w": "is", "b": [0.4089, 0.8673, 0.4222, 0.8887]}, {"w": "very", "b": [0.4281, 0.8673, 0.4645, 0.8887]}, {"w": "large,", "b": [0.4705, 0.8673, 0.516, 0.8887]}, {"w": "you", "b": [0.522, 0.8673, 0.5532, 0.8887]}, {"w": "may", "b": [0.5592, 0.8673, 0.5946, 0.8887]}, {"w": "want", "b": [0.6005, 0.8673, 0.6413, 0.8887]}, {"w": "to", "b": [0.6473, 0.8673, 0.6643, 0.8887]}, {"w": "sample", "b": [0.6702, 0.8673, 0.7287, 0.8887]}, {"w": "an", "b": [0.7347, 0.8673, 0.7552, 0.8887]}, {"w": "exploration", "b": [0.7612, 0.8673, 0.8572, 0.8887]}]}, {"id": "b_10", "type": "equation", "text": "58 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "58", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 85, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "set, to make manipulations easy and fast. In our case, the set is quite small so you can just work directly on the full set. Let’s create a copy so you can play with it without harming the training set:", "words": [{"w": "set,", "b": [0.1429, 0.0791, 0.1705, 0.1005]}, {"w": "to", "b": [0.1756, 0.0791, 0.1926, 0.1005]}, {"w": "make", "b": [0.1977, 0.0791, 0.2431, 0.1005]}, {"w": "manipulations", "b": [0.2483, 0.0791, 0.369, 0.1005]}, {"w": "easy", "b": [0.3742, 0.0791, 0.4094, 0.1005]}, {"w": "and", "b": [0.4145, 0.0791, 0.4461, 0.1005]}, {"w": "fast.", "b": [0.4512, 0.0791, 0.4853, 0.1005]}, {"w": "In", "b": [0.4904, 0.0791, 0.5089, 0.1005]}, {"w": "our", "b": [0.5141, 0.0791, 0.5435, 0.1005]}, {"w": "case,", "b": [0.5486, 0.0791, 0.5878, 0.1005]}, {"w": "the", "b": [0.593, 0.0791, 0.6193, 0.1005]}, {"w": "set", "b": [0.6244, 0.0791, 0.6473, 0.1005]}, {"w": "is", "b": [0.6524, 0.0791, 0.6657, 0.1005]}, {"w": "quite", "b": [0.6708, 0.0791, 0.7133, 0.1005]}, {"w": "small", "b": [0.7185, 0.0791, 0.7628, 0.1005]}, {"w": "so", "b": [0.768, 0.0791, 0.7863, 0.1005]}, {"w": "you", "b": [0.7914, 0.0791, 0.8226, 0.1005]}, {"w": "can", "b": [0.8278, 0.0791, 0.8571, 0.1005]}, {"w": "just", "b": [0.1429, 0.0981, 0.1732, 0.1195]}, {"w": "work", "b": [0.1798, 0.0981, 0.2228, 0.1195]}, {"w": "directly", "b": [0.2293, 0.0981, 0.2925, 0.1195]}, {"w": "on", "b": [0.299, 0.0981, 0.3211, 0.1195]}, {"w": "the", "b": [0.3276, 0.0981, 0.3539, 0.1195]}, {"w": "full", "b": [0.3605, 0.0981, 0.3883, 0.1195]}, {"w": "set.", "b": [0.3948, 0.0981, 0.4224, 0.1195]}, {"w": "Let’s", "b": [0.429, 0.0981, 0.4651, 0.1195]}, {"w": "create", "b": [0.4717, 0.0981, 0.5211, 0.1195]}, {"w": "a", "b": [0.5276, 0.0981, 0.5368, 0.1195]}, {"w": "copy", "b": [0.5433, 0.0981, 0.5832, 0.1195]}, {"w": "so", "b": [0.5898, 0.0981, 0.608, 0.1195]}, {"w": "you", "b": [0.6146, 0.0981, 0.6458, 0.1195]}, {"w": "can", "b": [0.6524, 0.0981, 0.6818, 0.1195]}, {"w": "play", "b": [0.6883, 0.0981, 0.7228, 0.1195]}, {"w": "with", "b": [0.7294, 0.0981, 0.7667, 0.1195]}, {"w": "it", "b": [0.7733, 0.0981, 0.7852, 0.1195]}, {"w": "without", "b": [0.7918, 0.0981, 0.8571, 0.1195]}, {"w": "harming", "b": [0.1429, 0.1172, 0.2147, 0.1386]}, {"w": "the", "b": [0.2194, 0.1172, 0.2457, 0.1386]}, {"w": "training", "b": [0.2504, 0.1172, 0.3174, 0.1386]}, {"w": "set:", "b": [0.3221, 0.1172, 0.3497, 0.1386]}]}, {"id": "b_1", "type": "equation", "text": "housing = strat_train_set.copy()", "words": [{"w": "housing", "b": [0.1766, 0.1491, 0.2356, 0.162]}, {"w": "=", "b": [0.244, 0.1491, 0.2525, 0.162]}, {"w": "strat_train_set.copy()", "b": [0.2609, 0.1491, 0.4464, 0.162]}]}, {"id": "b_2", "type": "paragraph", "text": "Visualizing Geographical Data", "words": [{"w": "Visualizing", "b": [0.1429, 0.1758, 0.2551, 0.2044]}, {"w": "Geographical", "b": [0.2601, 0.1758, 0.3958, 0.2044]}, {"w": "Data", "b": [0.4007, 0.1758, 0.4491, 0.2044]}]}, {"id": "b_3", "type": "paragraph", "text": "Since there is geographical information (latitude and longitude), it is a good idea to create a scatterplot of all districts to visualize the data (Figure 2-11):", "words": [{"w": "Since", "b": [0.1429, 0.2103, 0.1874, 0.2317]}, {"w": "there", "b": [0.1939, 0.2103, 0.2368, 0.2317]}, {"w": "is", "b": [0.2433, 0.2103, 0.2565, 0.2317]}, {"w": "geographical", "b": [0.263, 0.2103, 0.3693, 0.2317]}, {"w": "information", "b": [0.3758, 0.2103, 0.4771, 0.2317]}, {"w": "(latitude", "b": [0.4835, 0.2103, 0.554, 0.2317]}, {"w": "and", "b": [0.5605, 0.2103, 0.592, 0.2317]}, {"w": "longitude),", "b": [0.5985, 0.2103, 0.6903, 0.2317]}, {"w": "it", "b": [0.6968, 0.2103, 0.7088, 0.2317]}, {"w": "is", "b": [0.7153, 0.2103, 0.7285, 0.2317]}, {"w": "a", "b": [0.735, 0.2103, 0.7441, 0.2317]}, {"w": "good", "b": [0.7506, 0.2103, 0.7926, 0.2317]}, {"w": "idea", "b": [0.7991, 0.2103, 0.8337, 0.2317]}, {"w": "to", "b": [0.8402, 0.2103, 0.8571, 0.2317]}, {"w": "create", "b": [0.1428, 0.2293, 0.1922, 0.2508]}, {"w": "a", "b": [0.1969, 0.2293, 0.2061, 0.2508]}, {"w": "scatterplot", "b": [0.2108, 0.2293, 0.2985, 0.2508]}, {"w": "of", "b": [0.3032, 0.2293, 0.32, 0.2508]}, {"w": "all", "b": [0.3247, 0.2293, 0.3444, 0.2508]}, {"w": "districts", "b": [0.3491, 0.2293, 0.4158, 0.2508]}, {"w": "to", "b": [0.4206, 0.2293, 0.4376, 0.2508]}, {"w": "visualize", "b": [0.4423, 0.2293, 0.5138, 0.2508]}, {"w": "the", "b": [0.5186, 0.2293, 0.5449, 0.2508]}, {"w": "data", "b": [0.5496, 0.2293, 0.5849, 0.2508]}, {"w": "(Figure", "b": [0.5896, 0.2293, 0.6508, 0.2508]}, {"w": "2-11):", "b": [0.6555, 0.2293, 0.7049, 0.2508]}]}, {"id": "b_4", "type": "equation", "text": "housing.plot(kind=\"scatter\", x=\"longitude\", y=\"latitude\")", "words": [{"w": "housing.plot(kind=\"scatter\",", "b": [0.1766, 0.2613, 0.4127, 0.2742]}, {"w": "x=\"longitude\",", "b": [0.4211, 0.2613, 0.5392, 0.2742]}, {"w": "y=\"latitude\")", "b": [0.5476, 0.2613, 0.6572, 0.2742]}]}, {"id": "b_5", "type": "equation", "text": "Figure 2-11. A geographical scatterplot of the data", "words": [{"w": "Figure", "b": [0.1429, 0.5484, 0.1943, 0.57]}, {"w": "2-11.", "b": [0.1991, 0.5484, 0.2407, 0.57]}, {"w": "A", "b": [0.2455, 0.5484, 0.2593, 0.57]}, {"w": "geographical", "b": [0.2641, 0.5484, 0.3657, 0.57]}, {"w": "scatterplot", "b": [0.3705, 0.5484, 0.4551, 0.57]}, {"w": "of", "b": [0.4599, 0.5484, 0.4751, 0.57]}, {"w": "the", "b": [0.4798, 0.5484, 0.5049, 0.57]}, {"w": "data", "b": [0.5097, 0.5484, 0.5463, 0.57]}]}, {"id": "b_6", "type": "paragraph", "text": "This looks like California all right, but other than that it is hard to see any particular pattern. Setting the alpha option to 0.1 makes it much easier to visualize the places where there is a high density of data points (Figure 2-12):", "words": [{"w": "This", "b": [0.1429, 0.5858, 0.1801, 0.6072]}, {"w": "looks", "b": [0.1858, 0.5858, 0.2303, 0.6072]}, {"w": "like", "b": [0.2361, 0.5858, 0.2661, 0.6072]}, {"w": "California", "b": [0.2719, 0.5858, 0.3564, 0.6072]}, {"w": "all", "b": [0.3622, 0.5858, 0.3819, 0.6072]}, {"w": "right,", "b": [0.3876, 0.5858, 0.4325, 0.6072]}, {"w": "but", "b": [0.4383, 0.5858, 0.4663, 0.6072]}, {"w": "other", "b": [0.4721, 0.5858, 0.5168, 0.6072]}, {"w": "than", "b": [0.5225, 0.5858, 0.5605, 0.6072]}, {"w": "that", "b": [0.5663, 0.5858, 0.5989, 0.6072]}, {"w": "it", "b": [0.6047, 0.5858, 0.6166, 0.6072]}, {"w": "is", "b": [0.6224, 0.5858, 0.6356, 0.6072]}, {"w": "hard", "b": [0.6414, 0.5858, 0.6804, 0.6072]}, {"w": "to", "b": [0.6861, 0.5858, 0.7031, 0.6072]}, {"w": "see", "b": [0.7089, 0.5858, 0.7342, 0.6072]}, {"w": "any", "b": [0.74, 0.5858, 0.7696, 0.6072]}, {"w": "particular", "b": [0.7754, 0.5858, 0.8571, 0.6072]}, {"w": "pattern.", "b": [0.1429, 0.6058, 0.208, 0.6272]}, {"w": "Setting", "b": [0.2142, 0.6058, 0.2723, 0.6272]}, {"w": "the", "b": [0.2786, 0.6058, 0.3049, 0.6272]}, {"w": "alpha", "b": [0.3111, 0.6089, 0.3606, 0.624]}, {"w": "option", "b": [0.3668, 0.6058, 0.4223, 0.6272]}, {"w": "to", "b": [0.4285, 0.6058, 0.4455, 0.6272]}, {"w": "0.1", "b": [0.4517, 0.6089, 0.4814, 0.624]}, {"w": "makes", "b": [0.4876, 0.6058, 0.5407, 0.6272]}, {"w": "it", "b": [0.5469, 0.6058, 0.5588, 0.6272]}, {"w": "much", "b": [0.5651, 0.6058, 0.6127, 0.6272]}, {"w": "easier", "b": [0.6189, 0.6058, 0.6668, 0.6272]}, {"w": "to", "b": [0.673, 0.6058, 0.69, 0.6272]}, {"w": "visualize", "b": [0.6962, 0.6058, 0.7677, 0.6272]}, {"w": "the", "b": [0.7739, 0.6058, 0.8003, 0.6272]}, {"w": "places", "b": [0.8065, 0.6058, 0.8571, 0.6272]}, {"w": "where", "b": [0.1428, 0.6248, 0.1937, 0.6462]}, {"w": "there", "b": [0.1984, 0.6248, 0.2413, 0.6462]}, {"w": "is", "b": [0.2461, 0.6248, 0.2593, 0.6462]}, {"w": "a", "b": [0.264, 0.6248, 0.2732, 0.6462]}, {"w": "high", "b": [0.2779, 0.6248, 0.3155, 0.6462]}, {"w": "density", "b": [0.3202, 0.6248, 0.3806, 0.6462]}, {"w": "of", "b": [0.3853, 0.6248, 0.4021, 0.6462]}, {"w": "data", "b": [0.4068, 0.6248, 0.4421, 0.6462]}, {"w": "points", "b": [0.4468, 0.6248, 0.499, 0.6462]}, {"w": "(Figure", "b": [0.5037, 0.6248, 0.5649, 0.6462]}, {"w": "2-12):", "b": [0.5696, 0.6248, 0.619, 0.6462]}]}, {"id": "b_7", "type": "equation", "text": "housing.plot(kind=\"scatter\", x=\"longitude\", y=\"latitude\", alpha=0.1)", "words": [{"w": "housing.plot(kind=\"scatter\",", "b": [0.1766, 0.6568, 0.4127, 0.6696]}, {"w": "x=\"longitude\",", "b": [0.4211, 0.6568, 0.5392, 0.6696]}, {"w": "y=\"latitude\",", "b": [0.5476, 0.6568, 0.6572, 0.6696]}, {"w": "alpha=0.1)", "b": [0.6657, 0.6568, 0.75, 0.6696]}]}, {"id": "b_8", "type": "paragraph", "text": "Discover and Visualize the Data to Gain Insights | 59", "words": [{"w": "Discover", "b": [0.5263, 0.9225, 0.5754, 0.9388]}, {"w": "and", "b": [0.5782, 0.9225, 0.6006, 0.9388]}, {"w": "Visualize", "b": [0.6034, 0.9225, 0.6555, 0.9388]}, {"w": "the", "b": [0.6583, 0.9225, 0.6782, 0.9388]}, {"w": "Data", "b": [0.6811, 0.9225, 0.7087, 0.9388]}, {"w": "to", "b": [0.7115, 0.9225, 0.7239, 0.9388]}, {"w": "Gain", "b": [0.7268, 0.9225, 0.7534, 0.9388]}, {"w": "Insights", "b": [0.7562, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "59", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 86, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "16 If you are reading this in grayscale, grab a red pen and scribble over most of the coastline from the Bay Area down to San Diego (as you might expect). You can add a patch of yellow around Sacramento as well.", "words": [{"w": "16", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "If", "b": [0.1587, 0.8598, 0.1688, 0.8761]}, {"w": "you", "b": [0.1724, 0.8598, 0.1963, 0.8761]}, {"w": "are", "b": [0.1999, 0.8598, 0.2195, 0.8761]}, {"w": "reading", "b": [0.2231, 0.8598, 0.2714, 0.8761]}, {"w": "this", "b": [0.275, 0.8598, 0.2984, 0.8761]}, {"w": "in", "b": [0.302, 0.8598, 0.315, 0.8761]}, {"w": "grayscale,", "b": [0.3186, 0.8598, 0.3797, 0.8761]}, {"w": "grab", "b": [0.3833, 0.8598, 0.4117, 0.8761]}, {"w": "a", "b": [0.4153, 0.8598, 0.4223, 0.8761]}, {"w": "red", "b": [0.4259, 0.8598, 0.4469, 0.8761]}, {"w": "pen", "b": [0.4505, 0.8598, 0.4742, 0.8761]}, {"w": "and", "b": [0.4778, 0.8598, 0.5019, 0.8761]}, {"w": "scribble", "b": [0.5055, 0.8598, 0.555, 0.8761]}, {"w": "over", "b": [0.5586, 0.8598, 0.5867, 0.8761]}, {"w": "most", "b": [0.5903, 0.8598, 0.6221, 0.8761]}, {"w": "of", "b": [0.6257, 0.8598, 0.6385, 0.8761]}, {"w": "the", "b": [0.6421, 0.8598, 0.6621, 0.8761]}, {"w": "coastline", "b": [0.6657, 0.8598, 0.7219, 0.8761]}, {"w": "from", "b": [0.7255, 0.8598, 0.7572, 0.8761]}, {"w": "the", "b": [0.7608, 0.8598, 0.7808, 0.8761]}, {"w": "Bay", "b": [0.7844, 0.8598, 0.8077, 0.8761]}, {"w": "Area", "b": [0.8113, 0.8598, 0.8419, 0.8761]}, {"w": "down", "b": [0.1587, 0.8749, 0.1948, 0.8912]}, {"w": "to", "b": [0.1984, 0.8749, 0.2113, 0.8912]}, {"w": "San", "b": [0.2149, 0.8749, 0.2381, 0.8912]}, {"w": "Diego", "b": [0.2417, 0.8749, 0.2799, 0.8912]}, {"w": "(as", "b": [0.2835, 0.8749, 0.3018, 0.8912]}, {"w": "you", "b": [0.3054, 0.8749, 0.3292, 0.8912]}, {"w": "might", "b": [0.3328, 0.8749, 0.3705, 0.8912]}, {"w": "expect).", "b": [0.3741, 0.8749, 0.424, 0.8912]}, {"w": "You", "b": [0.4277, 0.8749, 0.4523, 0.8912]}, {"w": "can", "b": [0.4559, 0.8749, 0.4783, 0.8912]}, {"w": "add", "b": [0.4819, 0.8749, 0.5056, 0.8912]}, {"w": "a", "b": [0.5092, 0.8749, 0.5162, 0.8912]}, {"w": "patch", "b": [0.5198, 0.8749, 0.5548, 0.8912]}, {"w": "of", "b": [0.5584, 0.8749, 0.5712, 0.8912]}, {"w": "yellow", "b": [0.5748, 0.8749, 0.6158, 0.8912]}, {"w": "around", "b": [0.6194, 0.8749, 0.6659, 0.8912]}, {"w": "Sacramento", "b": [0.6695, 0.8749, 0.7446, 0.8912]}, {"w": "as", "b": [0.7482, 0.8749, 0.761, 0.8912]}, {"w": "well.", "b": [0.7646, 0.8749, 0.7939, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 2-12. A better visualization highlighting high-density areas", "words": [{"w": "Figure", "b": [0.1429, 0.3455, 0.1943, 0.3672]}, {"w": "2-12.", "b": [0.1991, 0.3455, 0.2407, 0.3672]}, {"w": "A", "b": [0.2455, 0.3455, 0.2593, 0.3672]}, {"w": "better", "b": [0.2641, 0.3455, 0.3109, 0.3672]}, {"w": "visualization", "b": [0.3156, 0.3455, 0.4204, 0.3672]}, {"w": "highlighting", "b": [0.4252, 0.3455, 0.5207, 0.3672]}, {"w": "high-density", "b": [0.5255, 0.3455, 0.6253, 0.3672]}, {"w": "areas", "b": [0.6301, 0.3455, 0.6726, 0.3672]}]}, {"id": "b_2", "type": "paragraph", "text": "Now that’s much better: you can clearly see the high-density areas, namely the Bay Area and around Los Angeles and San Diego, plus a long line of fairly high density in the Central Valley, in particular around Sacramento and Fresno.", "words": [{"w": "Now", "b": [0.1429, 0.3829, 0.1827, 0.4043]}, {"w": "that’s", "b": [0.1898, 0.3829, 0.2322, 0.4043]}, {"w": "much", "b": [0.2393, 0.3829, 0.287, 0.4043]}, {"w": "better:", "b": [0.2941, 0.3829, 0.3481, 0.4043]}, {"w": "you", "b": [0.3552, 0.3829, 0.3864, 0.4043]}, {"w": "can", "b": [0.3936, 0.3829, 0.4229, 0.4043]}, {"w": "clearly", "b": [0.43, 0.3829, 0.4847, 0.4043]}, {"w": "see", "b": [0.4918, 0.3829, 0.5172, 0.4043]}, {"w": "the", "b": [0.5243, 0.3829, 0.5506, 0.4043]}, {"w": "high-density", "b": [0.5578, 0.3829, 0.6632, 0.4043]}, {"w": "areas,", "b": [0.6703, 0.3829, 0.7176, 0.4043]}, {"w": "namely", "b": [0.7247, 0.3829, 0.786, 0.4043]}, {"w": "the", "b": [0.7931, 0.3829, 0.8194, 0.4043]}, {"w": "Bay", "b": [0.8266, 0.3829, 0.8571, 0.4043]}, {"w": "Area", "b": [0.1429, 0.402, 0.183, 0.4234]}, {"w": "and", "b": [0.1881, 0.402, 0.2197, 0.4234]}, {"w": "around", "b": [0.2248, 0.402, 0.2858, 0.4234]}, {"w": "Los", "b": [0.2909, 0.402, 0.3204, 0.4234]}, {"w": "Angeles", "b": [0.3256, 0.402, 0.3917, 0.4234]}, {"w": "and", "b": [0.3969, 0.402, 0.4284, 0.4234]}, {"w": "San", "b": [0.4336, 0.402, 0.464, 0.4234]}, {"w": "Diego,", "b": [0.4691, 0.402, 0.5234, 0.4234]}, {"w": "plus", "b": [0.5286, 0.402, 0.5635, 0.4234]}, {"w": "a", "b": [0.5686, 0.402, 0.5778, 0.4234]}, {"w": "long", "b": [0.5829, 0.402, 0.6199, 0.4234]}, {"w": "line", "b": [0.6251, 0.402, 0.6562, 0.4234]}, {"w": "of", "b": [0.6613, 0.402, 0.6781, 0.4234]}, {"w": "fairly", "b": [0.6833, 0.402, 0.7267, 0.4234]}, {"w": "high", "b": [0.7319, 0.402, 0.7695, 0.4234]}, {"w": "density", "b": [0.7746, 0.402, 0.835, 0.4234]}, {"w": "in", "b": [0.8402, 0.402, 0.8572, 0.4234]}, {"w": "the", "b": [0.1429, 0.421, 0.1692, 0.4424]}, {"w": "Central", "b": [0.1739, 0.421, 0.2361, 0.4424]}, {"w": "Valley,", "b": [0.2409, 0.421, 0.2948, 0.4424]}, {"w": "in", "b": [0.2995, 0.421, 0.3165, 0.4424]}, {"w": "particular", "b": [0.3212, 0.421, 0.403, 0.4424]}, {"w": "around", "b": [0.4077, 0.421, 0.4687, 0.4424]}, {"w": "Sacramento", "b": [0.4734, 0.421, 0.572, 0.4424]}, {"w": "and", "b": [0.5767, 0.421, 0.6083, 0.4424]}, {"w": "Fresno.", "b": [0.613, 0.421, 0.6744, 0.4424]}]}, {"id": "b_3", "type": "paragraph", "text": "More generally, our brains are very good at spotting patterns on pictures, but you may need to play around with visualization parameters to make the patterns stand out.", "words": [{"w": "More", "b": [0.1429, 0.4491, 0.1881, 0.4706]}, {"w": "generally,", "b": [0.1958, 0.4491, 0.2748, 0.4706]}, {"w": "our", "b": [0.2825, 0.4491, 0.3119, 0.4706]}, {"w": "brains", "b": [0.3196, 0.4491, 0.3717, 0.4706]}, {"w": "are", "b": [0.3793, 0.4491, 0.405, 0.4706]}, {"w": "very", "b": [0.4127, 0.4491, 0.4491, 0.4706]}, {"w": "good", "b": [0.4568, 0.4491, 0.4988, 0.4706]}, {"w": "at", "b": [0.5064, 0.4491, 0.5215, 0.4706]}, {"w": "spotting", "b": [0.5292, 0.4491, 0.5978, 0.4706]}, {"w": "patterns", "b": [0.6055, 0.4491, 0.6735, 0.4706]}, {"w": "on", "b": [0.6812, 0.4491, 0.7032, 0.4706]}, {"w": "pictures,", "b": [0.7109, 0.4491, 0.7826, 0.4706]}, {"w": "but", "b": [0.7902, 0.4491, 0.8182, 0.4706]}, {"w": "you", "b": [0.8259, 0.4491, 0.8571, 0.4706]}, {"w": "may", "b": [0.1429, 0.4682, 0.1783, 0.4896]}, {"w": "need", "b": [0.1856, 0.4682, 0.2257, 0.4896]}, {"w": "to", "b": [0.233, 0.4682, 0.25, 0.4896]}, {"w": "play", "b": [0.2573, 0.4682, 0.2918, 0.4896]}, {"w": "around", "b": [0.2992, 0.4682, 0.3601, 0.4896]}, {"w": "with", "b": [0.3674, 0.4682, 0.4048, 0.4896]}, {"w": "visualization", "b": [0.4121, 0.4682, 0.5175, 0.4896]}, {"w": "parameters", "b": [0.5248, 0.4682, 0.6183, 0.4896]}, {"w": "to", "b": [0.6256, 0.4682, 0.6426, 0.4896]}, {"w": "make", "b": [0.6499, 0.4682, 0.6953, 0.4896]}, {"w": "the", "b": [0.7026, 0.4682, 0.7289, 0.4896]}, {"w": "patterns", "b": [0.7363, 0.4682, 0.8043, 0.4896]}, {"w": "stand", "b": [0.8116, 0.4682, 0.8571, 0.4896]}, {"w": "out.", "b": [0.1428, 0.4872, 0.1756, 0.5086]}]}, {"id": "b_4", "type": "paragraph", "text": "Now let’s look at the housing prices (Figure 2-13). The radius of each circle represents the district’s population (option s), and the color represents the price (option c). We will use a predefined color map (option cmap) called jet, which ranges from blue (low values) to red (high prices):16", "words": [{"w": "Now", "b": [0.1428, 0.5154, 0.1827, 0.5368]}, {"w": "let’s", "b": [0.1876, 0.5154, 0.2178, 0.5368]}, {"w": "look", "b": [0.2227, 0.5154, 0.2595, 0.5368]}, {"w": "at", "b": [0.2644, 0.5154, 0.2795, 0.5368]}, {"w": "the", "b": [0.2844, 0.5154, 0.3107, 0.5368]}, {"w": "housing", "b": [0.3156, 0.5154, 0.3828, 0.5368]}, {"w": "prices", "b": [0.3877, 0.5154, 0.4372, 0.5368]}, {"w": "(Figure", "b": [0.4421, 0.5154, 0.5033, 0.5368]}, {"w": "2-13).", "b": [0.508, 0.5154, 0.5575, 0.5368]}, {"w": "The", "b": [0.5624, 0.5154, 0.5952, 0.5368]}, {"w": "radius", "b": [0.6001, 0.5154, 0.6523, 0.5368]}, {"w": "of", "b": [0.6571, 0.5154, 0.6739, 0.5368]}, {"w": "each", "b": [0.6788, 0.5154, 0.7167, 0.5368]}, {"w": "circle", "b": [0.7216, 0.5154, 0.7667, 0.5368]}, {"w": "represents", "b": [0.7716, 0.5154, 0.8571, 0.5368]}, {"w": "the", "b": [0.1429, 0.5353, 0.1692, 0.5567]}, {"w": "district’s", "b": [0.1751, 0.5353, 0.2439, 0.5567]}, {"w": "population", "b": [0.2498, 0.5353, 0.3413, 0.5567]}, {"w": "(option", "b": [0.3472, 0.5353, 0.4099, 0.5567]}, {"w": "s),", "b": [0.4158, 0.5353, 0.4377, 0.5567]}, {"w": "and", "b": [0.4436, 0.5353, 0.4751, 0.5567]}, {"w": "the", "b": [0.481, 0.5353, 0.5074, 0.5567]}, {"w": "color", "b": [0.5133, 0.5353, 0.5563, 0.5567]}, {"w": "represents", "b": [0.5622, 0.5353, 0.6478, 0.5567]}, {"w": "the", "b": [0.6537, 0.5353, 0.68, 0.5567]}, {"w": "price", "b": [0.6859, 0.5353, 0.7278, 0.5567]}, {"w": "(option", "b": [0.7337, 0.5353, 0.7964, 0.5567]}, {"w": "c).", "b": [0.8023, 0.5353, 0.8242, 0.5567]}, {"w": "We", "b": [0.8301, 0.5353, 0.8572, 0.5567]}, {"w": "will", "b": [0.1429, 0.5552, 0.1733, 0.5767]}, {"w": "use", "b": [0.1811, 0.5552, 0.2087, 0.5767]}, {"w": "a", "b": [0.2165, 0.5552, 0.2257, 0.5767]}, {"w": "predefined", "b": [0.2335, 0.5552, 0.3238, 0.5767]}, {"w": "color", "b": [0.3317, 0.5552, 0.3748, 0.5767]}, {"w": "map", "b": [0.3826, 0.5552, 0.4193, 0.5767]}, {"w": "(option", "b": [0.4272, 0.5552, 0.4899, 0.5767]}, {"w": "cmap)", "b": [0.4977, 0.5552, 0.5445, 0.5767]}, {"w": "called", "b": [0.5524, 0.5552, 0.6007, 0.5767]}, {"w": "jet,", "b": [0.6085, 0.5552, 0.643, 0.5767]}, {"w": "which", "b": [0.6508, 0.5552, 0.7017, 0.5767]}, {"w": "ranges", "b": [0.7096, 0.5552, 0.7641, 0.5767]}, {"w": "from", "b": [0.7719, 0.5552, 0.8135, 0.5767]}, {"w": "blue", "b": [0.8214, 0.5552, 0.8571, 0.5767]}, {"w": "(low", "b": [0.1429, 0.5743, 0.1802, 0.5957]}, {"w": "values)", "b": [0.185, 0.5743, 0.2438, 0.5957]}, {"w": "to", "b": [0.2485, 0.5743, 0.2655, 0.5957]}, {"w": "red", "b": [0.2702, 0.5743, 0.2978, 0.5957]}, {"w": "(high", "b": [0.3025, 0.5743, 0.3473, 0.5957]}, {"w": "prices):16", "b": [0.3521, 0.5743, 0.425, 0.5957]}]}, {"id": "b_5", "type": "paragraph", "text": "housing.plot(kind=\"scatter\", x=\"longitude\", y=\"latitude\", alpha=0.4, s=housing[\"population\"]/100, label=\"population\", figsize=(10,7), c=\"median_house_value\", cmap=plt.get_cmap(\"jet\"), colorbar=True, ) plt.legend()", "words": [{"w": "housing.plot(kind=\"scatter\",", "b": [0.1766, 0.6063, 0.4127, 0.6191]}, {"w": "x=\"longitude\",", "b": [0.4211, 0.6063, 0.5392, 0.6191]}, {"w": "y=\"latitude\",", "b": [0.5476, 0.6063, 0.6572, 0.6191]}, {"w": "alpha=0.4,", "b": [0.6657, 0.6063, 0.75, 0.6191]}, {"w": "s=housing[\"population\"]/100,", "b": [0.2103, 0.6217, 0.4464, 0.6345]}, {"w": "label=\"population\",", "b": [0.4549, 0.6217, 0.6151, 0.6345]}, {"w": "figsize=(10,7),", "b": [0.6235, 0.6217, 0.75, 0.6345]}, {"w": "c=\"median_house_value\",", "b": [0.2103, 0.6371, 0.4043, 0.65]}, {"w": "cmap=plt.get_cmap(\"jet\"),", "b": [0.4127, 0.6371, 0.6235, 0.65]}, {"w": "colorbar=True,", "b": [0.6319, 0.6371, 0.75, 0.65]}, {"w": ")", "b": [0.1766, 0.6525, 0.185, 0.6654]}, {"w": "plt.legend()", "b": [0.1766, 0.6679, 0.2778, 0.6808]}]}, {"id": "b_6", "type": "equation", "text": "60 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "60", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 87, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 2-13. California housing prices", "words": [{"w": "Figure", "b": [0.1429, 0.4663, 0.1943, 0.4879]}, {"w": "2-13.", "b": [0.1991, 0.4663, 0.2407, 0.4879]}, {"w": "California", "b": [0.2455, 0.4663, 0.3285, 0.4879]}, {"w": "housing", "b": [0.3333, 0.4663, 0.3963, 0.4879]}, {"w": "prices", "b": [0.4011, 0.4663, 0.4474, 0.4879]}]}, {"id": "b_1", "type": "paragraph", "text": "Discover and Visualize the Data to Gain Insights | 61", "words": [{"w": "Discover", "b": [0.5263, 0.9225, 0.5754, 0.9388]}, {"w": "and", "b": [0.5782, 0.9225, 0.6006, 0.9388]}, {"w": "Visualize", "b": [0.6034, 0.9225, 0.6555, 0.9388]}, {"w": "the", "b": [0.6583, 0.9225, 0.6782, 0.9388]}, {"w": "Data", "b": [0.681, 0.9225, 0.7087, 0.9388]}, {"w": "to", "b": [0.7115, 0.9225, 0.7239, 0.9388]}, {"w": "Gain", "b": [0.7268, 0.9225, 0.7534, 0.9388]}, {"w": "Insights", "b": [0.7562, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "61", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 88, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "This image tells you that the housing prices are very much related to the location (e.g., close to the ocean) and to the population density, as you probably knew already. It will probably be useful to use a clustering algorithm to detect the main clusters, and add new features that measure the proximity to the cluster centers. The ocean prox‐ imity attribute may be useful as well, although in Northern California the housing prices in coastal districts are not too high, so it is not a simple rule.", "words": [{"w": "This", "b": [0.1429, 0.0791, 0.1801, 0.1005]}, {"w": "image", "b": [0.1879, 0.0791, 0.2383, 0.1005]}, {"w": "tells", "b": [0.246, 0.0791, 0.2794, 0.1005]}, {"w": "you", "b": [0.2872, 0.0791, 0.3185, 0.1005]}, {"w": "that", "b": [0.3263, 0.0791, 0.3588, 0.1005]}, {"w": "the", "b": [0.3666, 0.0791, 0.393, 0.1005]}, {"w": "housing", "b": [0.4008, 0.0791, 0.4679, 0.1005]}, {"w": "prices", "b": [0.4757, 0.0791, 0.5253, 0.1005]}, {"w": "are", "b": [0.5331, 0.0791, 0.5588, 0.1005]}, {"w": "very", "b": [0.5666, 0.0791, 0.603, 0.1005]}, {"w": "much", "b": [0.6108, 0.0791, 0.6584, 0.1005]}, {"w": "related", "b": [0.6662, 0.0791, 0.723, 0.1005]}, {"w": "to", "b": [0.7308, 0.0791, 0.7478, 0.1005]}, {"w": "the", "b": [0.7556, 0.0791, 0.7819, 0.1005]}, {"w": "location", "b": [0.7897, 0.0791, 0.8571, 0.1005]}, {"w": "(e.g.,", "b": [0.1429, 0.0981, 0.1829, 0.1195]}, {"w": "close", "b": [0.1881, 0.0981, 0.2293, 0.1195]}, {"w": "to", "b": [0.2345, 0.0981, 0.2514, 0.1195]}, {"w": "the", "b": [0.2566, 0.0981, 0.283, 0.1195]}, {"w": "ocean)", "b": [0.2881, 0.0981, 0.3442, 0.1195]}, {"w": "and", "b": [0.3493, 0.0981, 0.3809, 0.1195]}, {"w": "to", "b": [0.3861, 0.0981, 0.403, 0.1195]}, {"w": "the", "b": [0.4082, 0.0981, 0.4345, 0.1195]}, {"w": "population", "b": [0.4397, 0.0981, 0.5312, 0.1195]}, {"w": "density,", "b": [0.5364, 0.0981, 0.6, 0.1195]}, {"w": "as", "b": [0.6052, 0.0981, 0.622, 0.1195]}, {"w": "you", "b": [0.6272, 0.0981, 0.6584, 0.1195]}, {"w": "probably", "b": [0.6636, 0.0981, 0.738, 0.1195]}, {"w": "knew", "b": [0.7432, 0.0981, 0.788, 0.1195]}, {"w": "already.", "b": [0.7932, 0.0981, 0.8571, 0.1195]}, {"w": "It", "b": [0.1429, 0.1172, 0.1555, 0.1386]}, {"w": "will", "b": [0.1603, 0.1172, 0.1907, 0.1386]}, {"w": "probably", "b": [0.1955, 0.1172, 0.2699, 0.1386]}, {"w": "be", "b": [0.2748, 0.1172, 0.2942, 0.1386]}, {"w": "useful", "b": [0.299, 0.1172, 0.3491, 0.1386]}, {"w": "to", "b": [0.3539, 0.1172, 0.3709, 0.1386]}, {"w": "use", "b": [0.3757, 0.1172, 0.4032, 0.1386]}, {"w": "a", "b": [0.408, 0.1172, 0.4172, 0.1386]}, {"w": "clustering", "b": [0.422, 0.1172, 0.5044, 0.1386]}, {"w": "algorithm", "b": [0.5093, 0.1172, 0.5919, 0.1386]}, {"w": "to", "b": [0.5967, 0.1172, 0.6137, 0.1386]}, {"w": "detect", "b": [0.6185, 0.1172, 0.6687, 0.1386]}, {"w": "the", "b": [0.6735, 0.1172, 0.6999, 0.1386]}, {"w": "main", "b": [0.7047, 0.1172, 0.7479, 0.1386]}, {"w": "clusters,", "b": [0.7527, 0.1172, 0.8208, 0.1386]}, {"w": "and", "b": [0.8256, 0.1172, 0.8572, 0.1386]}, {"w": "add", "b": [0.1429, 0.1362, 0.174, 0.1576]}, {"w": "new", "b": [0.1801, 0.1362, 0.2146, 0.1576]}, {"w": "features", "b": [0.2208, 0.1362, 0.2862, 0.1576]}, {"w": "that", "b": [0.2923, 0.1362, 0.3249, 0.1576]}, {"w": "measure", "b": [0.331, 0.1362, 0.4013, 0.1576]}, {"w": "the", "b": [0.4074, 0.1362, 0.4338, 0.1576]}, {"w": "proximity", "b": [0.4399, 0.1362, 0.5231, 0.1576]}, {"w": "to", "b": [0.5292, 0.1362, 0.5462, 0.1576]}, {"w": "the", "b": [0.5523, 0.1362, 0.5787, 0.1576]}, {"w": "cluster", "b": [0.5848, 0.1362, 0.6405, 0.1576]}, {"w": "centers.", "b": [0.6466, 0.1362, 0.7106, 0.1576]}, {"w": "The", "b": [0.7167, 0.1362, 0.7496, 0.1576]}, {"w": "ocean", "b": [0.7557, 0.1362, 0.8045, 0.1576]}, {"w": "prox‐", "b": [0.8106, 0.1362, 0.8571, 0.1576]}, {"w": "imity", "b": [0.1429, 0.1553, 0.187, 0.1767]}, {"w": "attribute", "b": [0.1945, 0.1553, 0.2661, 0.1767]}, {"w": "may", "b": [0.2737, 0.1553, 0.3091, 0.1767]}, {"w": "be", "b": [0.3166, 0.1553, 0.336, 0.1767]}, {"w": "useful", "b": [0.3435, 0.1553, 0.3936, 0.1767]}, {"w": "as", "b": [0.4011, 0.1553, 0.4179, 0.1767]}, {"w": "well,", "b": [0.4254, 0.1553, 0.4638, 0.1767]}, {"w": "although", "b": [0.4713, 0.1553, 0.5458, 0.1767]}, {"w": "in", "b": [0.5533, 0.1553, 0.5703, 0.1767]}, {"w": "Northern", "b": [0.5778, 0.1553, 0.6566, 0.1767]}, {"w": "California", "b": [0.6641, 0.1553, 0.7486, 0.1767]}, {"w": "the", "b": [0.7561, 0.1553, 0.7824, 0.1767]}, {"w": "housing", "b": [0.79, 0.1553, 0.8571, 0.1767]}, {"w": "prices", "b": [0.1428, 0.1743, 0.1924, 0.1957]}, {"w": "in", "b": [0.1971, 0.1743, 0.2141, 0.1957]}, {"w": "coastal", "b": [0.2188, 0.1743, 0.2758, 0.1957]}, {"w": "districts", "b": [0.2806, 0.1743, 0.3473, 0.1957]}, {"w": "are", "b": [0.352, 0.1743, 0.3777, 0.1957]}, {"w": "not", "b": [0.3825, 0.1743, 0.4108, 0.1957]}, {"w": "too", "b": [0.4156, 0.1743, 0.4432, 0.1957]}, {"w": "high,", "b": [0.4479, 0.1743, 0.4902, 0.1957]}, {"w": "so", "b": [0.495, 0.1743, 0.5132, 0.1957]}, {"w": "it", "b": [0.518, 0.1743, 0.5299, 0.1957]}, {"w": "is", "b": [0.5346, 0.1743, 0.5478, 0.1957]}, {"w": "not", "b": [0.5526, 0.1743, 0.581, 0.1957]}, {"w": "a", "b": [0.5857, 0.1743, 0.5948, 0.1957]}, {"w": "simple", "b": [0.5996, 0.1743, 0.6545, 0.1957]}, {"w": "rule.", "b": [0.6592, 0.1743, 0.6969, 0.1957]}]}, {"id": "b_1", "type": "paragraph", "text": "Looking for Correlations", "words": [{"w": "Looking", "b": [0.1428, 0.2085, 0.2253, 0.237]}, {"w": "for", "b": [0.2302, 0.2085, 0.2597, 0.237]}, {"w": "Correlations", "b": [0.2647, 0.2085, 0.3893, 0.237]}]}, {"id": "b_2", "type": "paragraph", "text": "Since the dataset is not too large, you can easily compute the standard correlation coefficient (also called Pearson’s r) between every pair of attributes using the corr() method:", "words": [{"w": "Since", "b": [0.1429, 0.2429, 0.1874, 0.2644]}, {"w": "the", "b": [0.1954, 0.2429, 0.2217, 0.2644]}, {"w": "dataset", "b": [0.2298, 0.2429, 0.2879, 0.2644]}, {"w": "is", "b": [0.2959, 0.2429, 0.3092, 0.2644]}, {"w": "not", "b": [0.3172, 0.2429, 0.3456, 0.2644]}, {"w": "too", "b": [0.3536, 0.2429, 0.3812, 0.2644]}, {"w": "large,", "b": [0.3893, 0.2429, 0.4348, 0.2644]}, {"w": "you", "b": [0.4428, 0.2429, 0.474, 0.2644]}, {"w": "can", "b": [0.4821, 0.2429, 0.5114, 0.2644]}, {"w": "easily", "b": [0.5195, 0.2429, 0.5655, 0.2644]}, {"w": "compute", "b": [0.5736, 0.2429, 0.6469, 0.2644]}, {"w": "the", "b": [0.6549, 0.2429, 0.6812, 0.2644]}, {"w": "standard", "b": [0.6893, 0.2427, 0.7613, 0.2644]}, {"w": "correlation", "b": [0.7694, 0.2427, 0.8571, 0.2644]}, {"w": "coefficient", "b": [0.1428, 0.2627, 0.2249, 0.2843]}, {"w": "(also", "b": [0.2317, 0.2629, 0.2716, 0.2843]}, {"w": "called", "b": [0.2784, 0.2629, 0.3268, 0.2843]}, {"w": "Pearson’s", "b": [0.3336, 0.2627, 0.4058, 0.2843]}, {"w": "r)", "b": [0.4126, 0.2627, 0.4275, 0.2843]}, {"w": "between", "b": [0.4343, 0.2629, 0.5035, 0.2843]}, {"w": "every", "b": [0.5103, 0.2629, 0.5556, 0.2843]}, {"w": "pair", "b": [0.5624, 0.2629, 0.5958, 0.2843]}, {"w": "of", "b": [0.6026, 0.2629, 0.6194, 0.2843]}, {"w": "attributes", "b": [0.6262, 0.2629, 0.7055, 0.2843]}, {"w": "using", "b": [0.7123, 0.2629, 0.7578, 0.2843]}, {"w": "the", "b": [0.7646, 0.2629, 0.7909, 0.2843]}, {"w": "corr()", "b": [0.7978, 0.2661, 0.8571, 0.2812]}, {"w": "method:", "b": [0.1429, 0.2819, 0.2126, 0.3033]}]}, {"id": "b_3", "type": "equation", "text": "corr_matrix = housing.corr()", "words": [{"w": "corr_matrix", "b": [0.1766, 0.3139, 0.2694, 0.3268]}, {"w": "=", "b": [0.2778, 0.3139, 0.2862, 0.3268]}, {"w": "housing.corr()", "b": [0.2946, 0.3139, 0.4127, 0.3268]}]}, {"id": "b_4", "type": "paragraph", "text": "Now let’s look at how much each attribute correlates with the median house value:", "words": [{"w": "Now", "b": [0.1429, 0.3345, 0.1827, 0.356]}, {"w": "let’s", "b": [0.1874, 0.3345, 0.2177, 0.356]}, {"w": "look", "b": [0.2224, 0.3345, 0.2592, 0.356]}, {"w": "at", "b": [0.264, 0.3345, 0.2791, 0.356]}, {"w": "how", "b": [0.2838, 0.3345, 0.3198, 0.356]}, {"w": "much", "b": [0.3246, 0.3345, 0.3722, 0.356]}, {"w": "each", "b": [0.377, 0.3345, 0.4149, 0.356]}, {"w": "attribute", "b": [0.4196, 0.3345, 0.4912, 0.356]}, {"w": "correlates", "b": [0.496, 0.3345, 0.5766, 0.356]}, {"w": "with", "b": [0.5813, 0.3345, 0.6187, 0.356]}, {"w": "the", "b": [0.6234, 0.3345, 0.6497, 0.356]}, {"w": "median", "b": [0.6545, 0.3345, 0.7175, 0.356]}, {"w": "house", "b": [0.7222, 0.3345, 0.7715, 0.356]}, {"w": "value:", "b": [0.7763, 0.3345, 0.825, 0.356]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> corr_matrix[\"median_house_value\"].sort_values(ascending=False) median_house_value 1.000000 median_income 0.687170 total_rooms 0.135231 housing_median_age 0.114220 households 0.064702 total_bedrooms 0.047865 population -0.026699 longitude -0.047279 latitude -0.142826 Name: median_house_value, dtype: float64", "words": [{"w": ">>>", "b": [0.1766, 0.3665, 0.2019, 0.3794]}, {"w": "corr_matrix[\"median_house_value\"].sort_values(ascending=False)", "b": [0.2103, 0.3665, 0.7331, 0.3794]}, {"w": "median_house_value", "b": [0.1766, 0.3819, 0.3284, 0.3948]}, {"w": "1.000000", "b": [0.3621, 0.3819, 0.4296, 0.3948]}, {"w": "median_income", "b": [0.1766, 0.3974, 0.2862, 0.4102]}, {"w": "0.687170", "b": [0.3621, 0.3974, 0.4296, 0.4102]}, {"w": "total_rooms", "b": [0.1766, 0.4128, 0.2693, 0.4256]}, {"w": "0.135231", "b": [0.3621, 0.4128, 0.4296, 0.4256]}, {"w": "housing_median_age", "b": [0.1766, 0.4282, 0.3284, 0.441]}, {"w": "0.114220", "b": [0.3621, 0.4282, 0.4296, 0.441]}, {"w": "households", "b": [0.1766, 0.4436, 0.2609, 0.4565]}, {"w": "0.064702", "b": [0.3621, 0.4436, 0.4296, 0.4565]}, {"w": "total_bedrooms", "b": [0.1766, 0.459, 0.2946, 0.4719]}, {"w": "0.047865", "b": [0.3621, 0.459, 0.4296, 0.4719]}, {"w": "population", "b": [0.1766, 0.4745, 0.2609, 0.4873]}, {"w": "-0.026699", "b": [0.3537, 0.4745, 0.4296, 0.4873]}, {"w": "longitude", "b": [0.1766, 0.4899, 0.2525, 0.5027]}, {"w": "-0.047279", "b": [0.3537, 0.4899, 0.4296, 0.5027]}, {"w": "latitude", "b": [0.1766, 0.5053, 0.244, 0.5181]}, {"w": "-0.142826", "b": [0.3537, 0.5053, 0.4296, 0.5181]}, {"w": "Name:", "b": [0.1766, 0.5207, 0.2187, 0.5336]}, {"w": "median_house_value,", "b": [0.2272, 0.5207, 0.3874, 0.5336]}, {"w": "dtype:", "b": [0.3958, 0.5207, 0.4464, 0.5336]}, {"w": "float64", "b": [0.4549, 0.5207, 0.5139, 0.5336]}]}, {"id": "b_6", "type": "paragraph", "text": "The correlation coefficient ranges from –1 to 1. When it is close to 1, it means that there is a strong positive correlation; for example, the median house value tends to go up when the median income goes up. When the coefficient is close to –1, it means that there is a strong negative correlation; you can see a small negative correlation between the latitude and the median house value (i.e., prices have a slight tendency to go down when you go north). Finally, coefficients close to zero mean that there is no linear correlation. Figure 2-14 shows various plots along with the correlation coeffi‐ cient between their horizontal and vertical axes.", "words": [{"w": "The", "b": [0.1429, 0.5413, 0.1757, 0.5628]}, {"w": "correlation", "b": [0.1823, 0.5413, 0.274, 0.5628]}, {"w": "coefficient", "b": [0.2807, 0.5413, 0.3675, 0.5628]}, {"w": "ranges", "b": [0.3741, 0.5413, 0.4286, 0.5628]}, {"w": "from", "b": [0.4352, 0.5413, 0.4768, 0.5628]}, {"w": "–1", "b": [0.4834, 0.5413, 0.5043, 0.5628]}, {"w": "to", "b": [0.5109, 0.5413, 0.5279, 0.5628]}, {"w": "1.", "b": [0.5345, 0.5413, 0.5492, 0.5628]}, {"w": "When", "b": [0.5559, 0.5413, 0.6075, 0.5628]}, {"w": "it", "b": [0.6141, 0.5413, 0.626, 0.5628]}, {"w": "is", "b": [0.6326, 0.5413, 0.6459, 0.5628]}, {"w": "close", "b": [0.6525, 0.5413, 0.6937, 0.5628]}, {"w": "to", "b": [0.7003, 0.5413, 0.7173, 0.5628]}, {"w": "1,", "b": [0.7239, 0.5413, 0.7387, 0.5628]}, {"w": "it", "b": [0.7453, 0.5413, 0.7572, 0.5628]}, {"w": "means", "b": [0.7638, 0.5413, 0.8179, 0.5628]}, {"w": "that", "b": [0.8246, 0.5413, 0.8572, 0.5628]}, {"w": "there", "b": [0.1429, 0.5604, 0.1858, 0.5818]}, {"w": "is", "b": [0.1908, 0.5604, 0.204, 0.5818]}, {"w": "a", "b": [0.209, 0.5604, 0.2181, 0.5818]}, {"w": "strong", "b": [0.2231, 0.5604, 0.2766, 0.5818]}, {"w": "positive", "b": [0.2816, 0.5604, 0.3468, 0.5818]}, {"w": "correlation;", "b": [0.3518, 0.5604, 0.4482, 0.5818]}, {"w": "for", "b": [0.4532, 0.5604, 0.4777, 0.5818]}, {"w": "example,", "b": [0.4827, 0.5604, 0.557, 0.5818]}, {"w": "the", "b": [0.562, 0.5604, 0.5883, 0.5818]}, {"w": "median", "b": [0.5933, 0.5604, 0.6563, 0.5818]}, {"w": "house", "b": [0.6613, 0.5604, 0.7106, 0.5818]}, {"w": "value", "b": [0.7156, 0.5604, 0.7596, 0.5818]}, {"w": "tends", "b": [0.7646, 0.5604, 0.8098, 0.5818]}, {"w": "to", "b": [0.8148, 0.5604, 0.8318, 0.5818]}, {"w": "go", "b": [0.8368, 0.5604, 0.8571, 0.5818]}, {"w": "up", "b": [0.1429, 0.5794, 0.1648, 0.6009]}, {"w": "when", "b": [0.1718, 0.5794, 0.2174, 0.6009]}, {"w": "the", "b": [0.2244, 0.5794, 0.2507, 0.6009]}, {"w": "median", "b": [0.2576, 0.5794, 0.3207, 0.6009]}, {"w": "income", "b": [0.3276, 0.5794, 0.39, 0.6009]}, {"w": "goes", "b": [0.3969, 0.5794, 0.4338, 0.6009]}, {"w": "up.", "b": [0.4407, 0.5794, 0.4669, 0.6009]}, {"w": "When", "b": [0.4738, 0.5794, 0.5254, 0.6009]}, {"w": "the", "b": [0.5323, 0.5794, 0.5587, 0.6009]}, {"w": "coefficient", "b": [0.5656, 0.5794, 0.6524, 0.6009]}, {"w": "is", "b": [0.6594, 0.5794, 0.6726, 0.6009]}, {"w": "close", "b": [0.6796, 0.5794, 0.7208, 0.6009]}, {"w": "to", "b": [0.7277, 0.5794, 0.7447, 0.6009]}, {"w": "–1,", "b": [0.7516, 0.5794, 0.7772, 0.6009]}, {"w": "it", "b": [0.7842, 0.5794, 0.7961, 0.6009]}, {"w": "means", "b": [0.803, 0.5794, 0.8571, 0.6009]}, {"w": "that", "b": [0.1428, 0.5985, 0.1754, 0.6199]}, {"w": "there", "b": [0.1829, 0.5985, 0.2258, 0.6199]}, {"w": "is", "b": [0.2332, 0.5985, 0.2465, 0.6199]}, {"w": "a", "b": [0.2539, 0.5985, 0.2631, 0.6199]}, {"w": "strong", "b": [0.2705, 0.5985, 0.324, 0.6199]}, {"w": "negative", "b": [0.3315, 0.5985, 0.4007, 0.6199]}, {"w": "correlation;", "b": [0.4081, 0.5985, 0.5046, 0.6199]}, {"w": "you", "b": [0.512, 0.5985, 0.5433, 0.6199]}, {"w": "can", "b": [0.5507, 0.5985, 0.5801, 0.6199]}, {"w": "see", "b": [0.5875, 0.5985, 0.6129, 0.6199]}, {"w": "a", "b": [0.6203, 0.5985, 0.6295, 0.6199]}, {"w": "small", "b": [0.6369, 0.5985, 0.6813, 0.6199]}, {"w": "negative", "b": [0.6888, 0.5985, 0.758, 0.6199]}, {"w": "correlation", "b": [0.7654, 0.5985, 0.8571, 0.6199]}, {"w": "between", "b": [0.1429, 0.6175, 0.212, 0.639]}, {"w": "the", "b": [0.217, 0.6175, 0.2434, 0.639]}, {"w": "latitude", "b": [0.2483, 0.6175, 0.3116, 0.639]}, {"w": "and", "b": [0.3166, 0.6175, 0.3481, 0.639]}, {"w": "the", "b": [0.3531, 0.6175, 0.3794, 0.639]}, {"w": "median", "b": [0.3844, 0.6175, 0.4474, 0.639]}, {"w": "house", "b": [0.4524, 0.6175, 0.5017, 0.639]}, {"w": "value", "b": [0.5067, 0.6175, 0.5507, 0.639]}, {"w": "(i.e.,", "b": [0.5557, 0.6175, 0.5916, 0.639]}, {"w": "prices", "b": [0.5966, 0.6175, 0.6461, 0.639]}, {"w": "have", "b": [0.6511, 0.6175, 0.6895, 0.639]}, {"w": "a", "b": [0.6945, 0.6175, 0.7036, 0.639]}, {"w": "slight", "b": [0.7086, 0.6175, 0.754, 0.639]}, {"w": "tendency", "b": [0.759, 0.6175, 0.8352, 0.639]}, {"w": "to", "b": [0.8402, 0.6175, 0.8571, 0.639]}, {"w": "go", "b": [0.1429, 0.6366, 0.1632, 0.658]}, {"w": "down", "b": [0.1688, 0.6366, 0.2161, 0.658]}, {"w": "when", "b": [0.2217, 0.6366, 0.2674, 0.658]}, {"w": "you", "b": [0.2729, 0.6366, 0.3042, 0.658]}, {"w": "go", "b": [0.3098, 0.6366, 0.3302, 0.658]}, {"w": "north).", "b": [0.3358, 0.6366, 0.3949, 0.658]}, {"w": "Finally,", "b": [0.4005, 0.6366, 0.461, 0.658]}, {"w": "coefficients", "b": [0.4666, 0.6366, 0.5611, 0.658]}, {"w": "close", "b": [0.5666, 0.6366, 0.6079, 0.658]}, {"w": "to", "b": [0.6134, 0.6366, 0.6304, 0.658]}, {"w": "zero", "b": [0.636, 0.6366, 0.672, 0.658]}, {"w": "mean", "b": [0.6776, 0.6366, 0.724, 0.658]}, {"w": "that", "b": [0.7296, 0.6366, 0.7622, 0.658]}, {"w": "there", "b": [0.7678, 0.6366, 0.8107, 0.658]}, {"w": "is", "b": [0.8163, 0.6366, 0.8295, 0.658]}, {"w": "no", "b": [0.8351, 0.6366, 0.8571, 0.658]}, {"w": "linear", "b": [0.1429, 0.6556, 0.1908, 0.677]}, {"w": "correlation.", "b": [0.1972, 0.6556, 0.2936, 0.677]}, {"w": "Figure", "b": [0.3, 0.6556, 0.354, 0.677]}, {"w": "2-14", "b": [0.3603, 0.6556, 0.3977, 0.677]}, {"w": "shows", "b": [0.404, 0.6556, 0.4554, 0.677]}, {"w": "various", "b": [0.4617, 0.6556, 0.5231, 0.677]}, {"w": "plots", "b": [0.5295, 0.6556, 0.5703, 0.677]}, {"w": "along", "b": [0.5766, 0.6556, 0.6228, 0.677]}, {"w": "with", "b": [0.6291, 0.6556, 0.6665, 0.677]}, {"w": "the", "b": [0.6728, 0.6556, 0.6991, 0.677]}, {"w": "correlation", "b": [0.7055, 0.6556, 0.7972, 0.677]}, {"w": "coeffi‐", "b": [0.8035, 0.6556, 0.8571, 0.677]}, {"w": "cient", "b": [0.1429, 0.6747, 0.1835, 0.6961]}, {"w": "between", "b": [0.1882, 0.6747, 0.2574, 0.6961]}, {"w": "their", "b": [0.2621, 0.6747, 0.3017, 0.6961]}, {"w": "horizontal", "b": [0.3065, 0.6747, 0.3927, 0.6961]}, {"w": "and", "b": [0.3974, 0.6747, 0.4289, 0.6961]}, {"w": "vertical", "b": [0.4337, 0.6747, 0.4951, 0.6961]}, {"w": "axes.", "b": [0.4998, 0.6747, 0.54, 0.6961]}]}, {"id": "b_7", "type": "equation", "text": "62 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "62", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 89, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Figure 2-14. Standard correlation coefficient of various datasets (source: Wikipedia; public domain image)", "words": [{"w": "Figure", "b": [0.1429, 0.3288, 0.1943, 0.3504]}, {"w": "2-14.", "b": [0.1991, 0.3288, 0.2407, 0.3504]}, {"w": "Standard", "b": [0.2455, 0.3288, 0.3202, 0.3504]}, {"w": "correlation", "b": [0.325, 0.3288, 0.4128, 0.3504]}, {"w": "coefficient", "b": [0.4175, 0.3288, 0.4995, 0.3504]}, {"w": "of", "b": [0.5043, 0.3288, 0.5195, 0.3504]}, {"w": "various", "b": [0.5243, 0.3288, 0.5846, 0.3504]}, {"w": "datasets", "b": [0.5894, 0.3288, 0.6547, 0.3504]}, {"w": "(source:", "b": [0.6595, 0.3288, 0.7223, 0.3504]}, {"w": "Wikipedia;", "b": [0.7271, 0.3288, 0.8156, 0.3504]}, {"w": "public", "b": [0.1429, 0.3479, 0.192, 0.3695]}, {"w": "domain", "b": [0.1968, 0.3479, 0.2595, 0.3695]}, {"w": "image)", "b": [0.2642, 0.3479, 0.3198, 0.3695]}]}, {"id": "b_1", "type": "paragraph", "text": "The correlation coefficient only measures linear correlations (“if x goes up, then y generally goes up/down”). It may completely miss out on nonlinear relationships (e.g., “if x is close to zero then y gen‐ erally goes up”). Note how all the plots of the bottom row have a correlation coefficient equal to zero despite the fact that their axes are clearly not independent: these are examples of nonlinear rela‐ tionships. Also, the second row shows examples where the correla‐ tion coefficient is equal to 1 or –1; notice that this has nothing to do with the slope. For example, your height in inches has a correla‐ tion coefficient of 1 with your height in feet or in nanometers.", "words": [{"w": "The", "b": [0.2714, 0.39, 0.3014, 0.4096]}, {"w": "correlation", "b": [0.3074, 0.39, 0.3913, 0.4096]}, {"w": "coefficient", "b": [0.3973, 0.39, 0.4767, 0.4096]}, {"w": "only", "b": [0.4827, 0.39, 0.5164, 0.4096]}, {"w": "measures", "b": [0.5224, 0.39, 0.5937, 0.4096]}, {"w": "linear", "b": [0.5997, 0.39, 0.6435, 0.4096]}, {"w": "correlations", "b": [0.6495, 0.39, 0.7404, 0.4096]}, {"w": "(“if", "b": [0.7464, 0.39, 0.7707, 0.4096]}, {"w": "x", "b": [0.7767, 0.3898, 0.7857, 0.4096]}, {"w": "goes", "b": [0.2714, 0.4074, 0.3051, 0.427]}, {"w": "up,", "b": [0.3113, 0.4074, 0.3352, 0.427]}, {"w": "then", "b": [0.3414, 0.4074, 0.3759, 0.427]}, {"w": "y", "b": [0.3821, 0.4072, 0.3906, 0.427]}, {"w": "generally", "b": [0.3968, 0.4074, 0.4661, 0.427]}, {"w": "goes", "b": [0.4723, 0.4074, 0.506, 0.427]}, {"w": "up/down”).", "b": [0.5122, 0.4074, 0.5989, 0.427]}, {"w": "It", "b": [0.6051, 0.4074, 0.6167, 0.427]}, {"w": "may", "b": [0.6229, 0.4074, 0.6552, 0.427]}, {"w": "completely", "b": [0.6614, 0.4074, 0.7448, 0.427]}, {"w": "miss", "b": [0.751, 0.4074, 0.7857, 0.427]}, {"w": "out", "b": [0.2714, 0.4248, 0.2971, 0.4444]}, {"w": "on", "b": [0.3014, 0.4248, 0.3215, 0.4444]}, {"w": "nonlinear", "b": [0.3258, 0.4248, 0.4003, 0.4444]}, {"w": "relationships", "b": [0.4046, 0.4248, 0.5028, 0.4444]}, {"w": "(e.g.,", "b": [0.5072, 0.4248, 0.5438, 0.4444]}, {"w": "“if", "b": [0.5481, 0.4248, 0.5659, 0.4444]}, {"w": "x", "b": [0.5706, 0.4246, 0.5796, 0.4444]}, {"w": "is", "b": [0.584, 0.4248, 0.5961, 0.4444]}, {"w": "close", "b": [0.6004, 0.4248, 0.6381, 0.4444]}, {"w": "to", "b": [0.6424, 0.4248, 0.658, 0.4444]}, {"w": "zero", "b": [0.6623, 0.4248, 0.6952, 0.4444]}, {"w": "then", "b": [0.6995, 0.4248, 0.734, 0.4444]}, {"w": "y", "b": [0.7387, 0.4246, 0.7471, 0.4444]}, {"w": "gen‐", "b": [0.7515, 0.4248, 0.7857, 0.4444]}, {"w": "erally", "b": [0.2714, 0.4423, 0.3133, 0.4618]}, {"w": "goes", "b": [0.3197, 0.4423, 0.3534, 0.4618]}, {"w": "up”).", "b": [0.3598, 0.4423, 0.397, 0.4618]}, {"w": "Note", "b": [0.4034, 0.4423, 0.4407, 0.4618]}, {"w": "how", "b": [0.4471, 0.4423, 0.48, 0.4618]}, {"w": "all", "b": [0.4864, 0.4423, 0.5044, 0.4618]}, {"w": "the", "b": [0.5107, 0.4423, 0.5348, 0.4618]}, {"w": "plots", "b": [0.5412, 0.4423, 0.5785, 0.4618]}, {"w": "of", "b": [0.5848, 0.4423, 0.6002, 0.4618]}, {"w": "the", "b": [0.6066, 0.4423, 0.6306, 0.4618]}, {"w": "bottom", "b": [0.637, 0.4423, 0.6933, 0.4618]}, {"w": "row", "b": [0.6997, 0.4423, 0.7295, 0.4618]}, {"w": "have", "b": [0.7359, 0.4423, 0.771, 0.4618]}, {"w": "a", "b": [0.7774, 0.4423, 0.7857, 0.4618]}, {"w": "correlation", "b": [0.2714, 0.4597, 0.3553, 0.4792]}, {"w": "coefficient", "b": [0.361, 0.4597, 0.4404, 0.4792]}, {"w": "equal", "b": [0.4461, 0.4597, 0.4872, 0.4792]}, {"w": "to", "b": [0.4929, 0.4597, 0.5084, 0.4792]}, {"w": "zero", "b": [0.5141, 0.4597, 0.547, 0.4792]}, {"w": "despite", "b": [0.5527, 0.4597, 0.6068, 0.4792]}, {"w": "the", "b": [0.6125, 0.4597, 0.6366, 0.4792]}, {"w": "fact", "b": [0.6423, 0.4597, 0.6701, 0.4792]}, {"w": "that", "b": [0.6758, 0.4597, 0.7056, 0.4792]}, {"w": "their", "b": [0.7113, 0.4597, 0.7476, 0.4792]}, {"w": "axes", "b": [0.7533, 0.4597, 0.7857, 0.4792]}, {"w": "are", "b": [0.2714, 0.4771, 0.2949, 0.4967]}, {"w": "clearly", "b": [0.3012, 0.4771, 0.3511, 0.4967]}, {"w": "not", "b": [0.3574, 0.4771, 0.3833, 0.4967]}, {"w": "independent:", "b": [0.3896, 0.4771, 0.4901, 0.4967]}, {"w": "these", "b": [0.4964, 0.4771, 0.5355, 0.4967]}, {"w": "are", "b": [0.5418, 0.4771, 0.5653, 0.4967]}, {"w": "examples", "b": [0.5715, 0.4771, 0.6421, 0.4967]}, {"w": "of", "b": [0.6483, 0.4771, 0.6637, 0.4967]}, {"w": "nonlinear", "b": [0.6699, 0.4771, 0.7444, 0.4967]}, {"w": "rela‐", "b": [0.7506, 0.4771, 0.7857, 0.4967]}, {"w": "tionships.", "b": [0.2714, 0.4945, 0.346, 0.5141]}, {"w": "Also,", "b": [0.3512, 0.4945, 0.3896, 0.5141]}, {"w": "the", "b": [0.3947, 0.4945, 0.4188, 0.5141]}, {"w": "second", "b": [0.4239, 0.4945, 0.4773, 0.5141]}, {"w": "row", "b": [0.4824, 0.4945, 0.5122, 0.5141]}, {"w": "shows", "b": [0.5173, 0.4945, 0.5642, 0.5141]}, {"w": "examples", "b": [0.5693, 0.4945, 0.6399, 0.5141]}, {"w": "where", "b": [0.645, 0.4945, 0.6915, 0.5141]}, {"w": "the", "b": [0.6966, 0.4945, 0.7207, 0.5141]}, {"w": "correla‐", "b": [0.7258, 0.4945, 0.7857, 0.5141]}, {"w": "tion", "b": [0.2714, 0.5119, 0.3025, 0.5315]}, {"w": "coefficient", "b": [0.3086, 0.5119, 0.3879, 0.5315]}, {"w": "is", "b": [0.394, 0.5119, 0.4061, 0.5315]}, {"w": "equal", "b": [0.4122, 0.5119, 0.4533, 0.5315]}, {"w": "to", "b": [0.4594, 0.5119, 0.4749, 0.5315]}, {"w": "1", "b": [0.481, 0.5119, 0.4902, 0.5315]}, {"w": "or", "b": [0.4963, 0.5119, 0.513, 0.5315]}, {"w": "–1;", "b": [0.5191, 0.5119, 0.5425, 0.5315]}, {"w": "notice", "b": [0.5486, 0.5119, 0.5958, 0.5315]}, {"w": "that", "b": [0.6019, 0.5119, 0.6317, 0.5315]}, {"w": "this", "b": [0.6378, 0.5119, 0.6659, 0.5315]}, {"w": "has", "b": [0.6719, 0.5119, 0.6975, 0.5315]}, {"w": "nothing", "b": [0.7036, 0.5119, 0.7641, 0.5315]}, {"w": "to", "b": [0.7702, 0.5119, 0.7857, 0.5315]}, {"w": "do", "b": [0.2714, 0.5293, 0.2912, 0.5489]}, {"w": "with", "b": [0.2959, 0.5293, 0.33, 0.5489]}, {"w": "the", "b": [0.3347, 0.5293, 0.3587, 0.5489]}, {"w": "slope.", "b": [0.3634, 0.5293, 0.4074, 0.5489]}, {"w": "For", "b": [0.4121, 0.5293, 0.4386, 0.5489]}, {"w": "example,", "b": [0.4432, 0.5293, 0.5112, 0.5489]}, {"w": "your", "b": [0.5158, 0.5293, 0.5515, 0.5489]}, {"w": "height", "b": [0.5562, 0.5293, 0.6041, 0.5489]}, {"w": "in", "b": [0.6088, 0.5293, 0.6243, 0.5489]}, {"w": "inches", "b": [0.629, 0.5293, 0.6778, 0.5489]}, {"w": "has", "b": [0.6825, 0.5293, 0.708, 0.5489]}, {"w": "a", "b": [0.7127, 0.5293, 0.7211, 0.5489]}, {"w": "correla‐", "b": [0.7257, 0.5293, 0.7857, 0.5489]}, {"w": "tion", "b": [0.2714, 0.5467, 0.3024, 0.5663]}, {"w": "coefficient", "b": [0.3068, 0.5467, 0.3861, 0.5663]}, {"w": "of", "b": [0.3905, 0.5467, 0.4058, 0.5663]}, {"w": "1", "b": [0.4101, 0.5467, 0.4193, 0.5663]}, {"w": "with", "b": [0.4236, 0.5467, 0.4577, 0.5663]}, {"w": "your", "b": [0.4621, 0.5467, 0.4977, 0.5663]}, {"w": "height", "b": [0.502, 0.5467, 0.5499, 0.5663]}, {"w": "in", "b": [0.5543, 0.5467, 0.5698, 0.5663]}, {"w": "feet", "b": [0.5741, 0.5467, 0.6017, 0.5663]}, {"w": "or", "b": [0.6061, 0.5467, 0.6228, 0.5663]}, {"w": "in", "b": [0.6272, 0.5467, 0.6427, 0.5663]}, {"w": "nanometers.", "b": [0.647, 0.5467, 0.7419, 0.5663]}]}, {"id": "b_2", "type": "paragraph", "text": "Another way to check for correlation between attributes is to use Pandas’ scatter_matrix function, which plots every numerical attribute against every other numerical attribute. Since there are now 11 numerical attributes, you would get 112 = 121 plots, which would not fit on a page, so let’s just focus on a few promising attributes that seem most correlated with the median housing value (Figure 2-15):", "words": [{"w": "Another", "b": [0.1428, 0.5866, 0.2133, 0.608]}, {"w": "way", "b": [0.2279, 0.5866, 0.2605, 0.608]}, {"w": "to", "b": [0.2751, 0.5866, 0.2921, 0.608]}, {"w": "check", "b": [0.3067, 0.5866, 0.3546, 0.608]}, {"w": "for", "b": [0.3692, 0.5866, 0.3937, 0.608]}, {"w": "correlation", "b": [0.4083, 0.5866, 0.5, 0.608]}, {"w": "between", "b": [0.5146, 0.5866, 0.5838, 0.608]}, {"w": "attributes", "b": [0.5984, 0.5866, 0.6776, 0.608]}, {"w": "is", "b": [0.6922, 0.5866, 0.7054, 0.608]}, {"w": "to", "b": [0.72, 0.5866, 0.737, 0.608]}, {"w": "use", "b": [0.7516, 0.5866, 0.7792, 0.608]}, {"w": "Pandas’", "b": [0.7937, 0.5866, 0.8571, 0.608]}, {"w": "scatter_matrix", "b": [0.1429, 0.6097, 0.2814, 0.6248]}, {"w": "function,", "b": [0.2878, 0.6066, 0.3639, 0.628]}, {"w": "which", "b": [0.3703, 0.6066, 0.4212, 0.628]}, {"w": "plots", "b": [0.4276, 0.6066, 0.4684, 0.628]}, {"w": "every", "b": [0.4748, 0.6066, 0.5201, 0.628]}, {"w": "numerical", "b": [0.5265, 0.6066, 0.611, 0.628]}, {"w": "attribute", "b": [0.6174, 0.6066, 0.689, 0.628]}, {"w": "against", "b": [0.6954, 0.6066, 0.7544, 0.628]}, {"w": "every", "b": [0.7608, 0.6066, 0.8061, 0.628]}, {"w": "other", "b": [0.8125, 0.6066, 0.8571, 0.628]}, {"w": "numerical", "b": [0.1428, 0.6256, 0.2274, 0.647]}, {"w": "attribute.", "b": [0.2327, 0.6256, 0.309, 0.647]}, {"w": "Since", "b": [0.3143, 0.6256, 0.3589, 0.647]}, {"w": "there", "b": [0.3642, 0.6256, 0.4071, 0.647]}, {"w": "are", "b": [0.4124, 0.6256, 0.4381, 0.647]}, {"w": "now", "b": [0.4434, 0.6256, 0.4797, 0.647]}, {"w": "11", "b": [0.485, 0.6256, 0.505, 0.647]}, {"w": "numerical", "b": [0.5103, 0.6256, 0.5948, 0.647]}, {"w": "attributes,", "b": [0.6001, 0.6256, 0.6841, 0.647]}, {"w": "you", "b": [0.6894, 0.6256, 0.7207, 0.647]}, {"w": "would", "b": [0.726, 0.6256, 0.7782, 0.647]}, {"w": "get", "b": [0.7835, 0.6256, 0.8085, 0.647]}, {"w": "112", "b": [0.8138, 0.6256, 0.8398, 0.647]}, {"w": "=", "b": [0.8451, 0.6256, 0.8571, 0.647]}, {"w": "121", "b": [0.1428, 0.6447, 0.1728, 0.6661]}, {"w": "plots,", "b": [0.1819, 0.6447, 0.2274, 0.6661]}, {"w": "which", "b": [0.2365, 0.6447, 0.2874, 0.6661]}, {"w": "would", "b": [0.2964, 0.6447, 0.3487, 0.6661]}, {"w": "not", "b": [0.3577, 0.6447, 0.3861, 0.6661]}, {"w": "fit", "b": [0.3951, 0.6447, 0.4132, 0.6661]}, {"w": "on", "b": [0.4222, 0.6447, 0.4443, 0.6661]}, {"w": "a", "b": [0.4533, 0.6447, 0.4624, 0.6661]}, {"w": "page,", "b": [0.4715, 0.6447, 0.5149, 0.6661]}, {"w": "so", "b": [0.5239, 0.6447, 0.5422, 0.6661]}, {"w": "let’s", "b": [0.5512, 0.6447, 0.5815, 0.6661]}, {"w": "just", "b": [0.5905, 0.6447, 0.6209, 0.6661]}, {"w": "focus", "b": [0.6299, 0.6447, 0.6742, 0.6661]}, {"w": "on", "b": [0.6833, 0.6447, 0.7053, 0.6661]}, {"w": "a", "b": [0.7143, 0.6447, 0.7235, 0.6661]}, {"w": "few", "b": [0.7325, 0.6447, 0.7618, 0.6661]}, {"w": "promising", "b": [0.7708, 0.6447, 0.8571, 0.6661]}, {"w": "attributes", "b": [0.1429, 0.6637, 0.2221, 0.6851]}, {"w": "that", "b": [0.2269, 0.6637, 0.2594, 0.6851]}, {"w": "seem", "b": [0.2642, 0.6637, 0.3066, 0.6851]}, {"w": "most", "b": [0.3113, 0.6637, 0.353, 0.6851]}, {"w": "correlated", "b": [0.3577, 0.6637, 0.4417, 0.6851]}, {"w": "with", "b": [0.4464, 0.6637, 0.4838, 0.6851]}, {"w": "the", "b": [0.4885, 0.6637, 0.5148, 0.6851]}, {"w": "median", "b": [0.5196, 0.6637, 0.5826, 0.6851]}, {"w": "housing", "b": [0.5873, 0.6637, 0.6545, 0.6851]}, {"w": "value", "b": [0.6593, 0.6637, 0.7032, 0.6851]}, {"w": "(Figure", "b": [0.708, 0.6637, 0.7692, 0.6851]}, {"w": "2-15):", "b": [0.7739, 0.6637, 0.8233, 0.6851]}]}, {"id": "b_3", "type": "equation", "text": "from pandas.plotting import scatter_matrix", "words": [{"w": "from", "b": [0.1766, 0.6957, 0.2103, 0.7085]}, {"w": "pandas.plotting", "b": [0.2188, 0.6957, 0.3452, 0.7085]}, {"w": "import", "b": [0.3537, 0.6957, 0.4043, 0.7085]}, {"w": "scatter_matrix", "b": [0.4127, 0.6957, 0.5308, 0.7085]}]}, {"id": "b_4", "type": "paragraph", "text": "attributes = [\"median_house_value\", \"median_income\", \"total_rooms\", \"housing_median_age\"] scatter_matrix(housing[attributes], figsize=(12, 8))", "words": [{"w": "attributes", "b": [0.1766, 0.7265, 0.2609, 0.7394]}, {"w": "=", "b": [0.2693, 0.7265, 0.2778, 0.7394]}, {"w": "[\"median_house_value\",", "b": [0.2862, 0.7265, 0.4717, 0.7394]}, {"w": "\"median_income\",", "b": [0.4802, 0.7265, 0.6151, 0.7394]}, {"w": "\"total_rooms\",", "b": [0.6235, 0.7265, 0.7416, 0.7394]}, {"w": "\"housing_median_age\"]", "b": [0.2946, 0.7419, 0.4717, 0.7548]}, {"w": "scatter_matrix(housing[attributes],", "b": [0.1766, 0.7574, 0.4717, 0.7702]}, {"w": "figsize=(12,", "b": [0.4802, 0.7574, 0.5814, 0.7702]}, {"w": "8))", "b": [0.5898, 0.7574, 0.6151, 0.7702]}]}, {"id": "b_5", "type": "paragraph", "text": "Discover and Visualize the Data to Gain Insights | 63", "words": [{"w": "Discover", "b": [0.5263, 0.9225, 0.5753, 0.9388]}, {"w": "and", "b": [0.5782, 0.9225, 0.6006, 0.9388]}, {"w": "Visualize", "b": [0.6034, 0.9225, 0.6555, 0.9388]}, {"w": "the", "b": [0.6583, 0.9225, 0.6782, 0.9388]}, {"w": "Data", "b": [0.681, 0.9225, 0.7087, 0.9388]}, {"w": "to", "b": [0.7115, 0.9225, 0.7239, 0.9388]}, {"w": "Gain", "b": [0.7268, 0.9225, 0.7534, 0.9388]}, {"w": "Insights", "b": [0.7562, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "63", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 90, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 2-15. Scatter matrix", "words": [{"w": "Figure", "b": [0.1429, 0.4496, 0.1943, 0.4712]}, {"w": "2-15.", "b": [0.1991, 0.4496, 0.2407, 0.4712]}, {"w": "Scatter", "b": [0.2455, 0.4496, 0.3015, 0.4712]}, {"w": "matrix", "b": [0.3063, 0.4496, 0.3618, 0.4712]}]}, {"id": "b_1", "type": "paragraph", "text": "The main diagonal (top left to bottom right) would be full of straight lines if Pandas plotted each variable against itself, which would not be very useful. So instead Pandas displays a histogram of each attribute (other options are available; see Pandas’ docu‐ mentation for more details).", "words": [{"w": "The", "b": [0.1429, 0.487, 0.1757, 0.5084]}, {"w": "main", "b": [0.1816, 0.487, 0.2248, 0.5084]}, {"w": "diagonal", "b": [0.2307, 0.487, 0.3027, 0.5084]}, {"w": "(top", "b": [0.3086, 0.487, 0.3437, 0.5084]}, {"w": "left", "b": [0.3496, 0.487, 0.3763, 0.5084]}, {"w": "to", "b": [0.3822, 0.487, 0.3992, 0.5084]}, {"w": "bottom", "b": [0.4051, 0.487, 0.4667, 0.5084]}, {"w": "right)", "b": [0.4727, 0.487, 0.52, 0.5084]}, {"w": "would", "b": [0.526, 0.487, 0.5782, 0.5084]}, {"w": "be", "b": [0.5841, 0.487, 0.6036, 0.5084]}, {"w": "full", "b": [0.6095, 0.487, 0.6373, 0.5084]}, {"w": "of", "b": [0.6432, 0.487, 0.66, 0.5084]}, {"w": "straight", "b": [0.6659, 0.487, 0.7292, 0.5084]}, {"w": "lines", "b": [0.7352, 0.487, 0.7739, 0.5084]}, {"w": "if", "b": [0.7799, 0.487, 0.7916, 0.5084]}, {"w": "Pandas", "b": [0.7975, 0.487, 0.8571, 0.5084]}, {"w": "plotted", "b": [0.1429, 0.5061, 0.2022, 0.5275]}, {"w": "each", "b": [0.2072, 0.5061, 0.2452, 0.5275]}, {"w": "variable", "b": [0.2502, 0.5061, 0.3161, 0.5275]}, {"w": "against", "b": [0.3211, 0.5061, 0.3802, 0.5275]}, {"w": "itself,", "b": [0.3852, 0.5061, 0.4298, 0.5275]}, {"w": "which", "b": [0.4348, 0.5061, 0.4857, 0.5275]}, {"w": "would", "b": [0.4907, 0.5061, 0.543, 0.5275]}, {"w": "not", "b": [0.548, 0.5061, 0.5764, 0.5275]}, {"w": "be", "b": [0.5814, 0.5061, 0.6008, 0.5275]}, {"w": "very", "b": [0.6058, 0.5061, 0.6422, 0.5275]}, {"w": "useful.", "b": [0.6472, 0.5061, 0.702, 0.5275]}, {"w": "So", "b": [0.707, 0.5061, 0.7275, 0.5275]}, {"w": "instead", "b": [0.7325, 0.5061, 0.7925, 0.5275]}, {"w": "Pandas", "b": [0.7975, 0.5061, 0.8571, 0.5275]}, {"w": "displays", "b": [0.1429, 0.5251, 0.2093, 0.5465]}, {"w": "a", "b": [0.2153, 0.5251, 0.2244, 0.5465]}, {"w": "histogram", "b": [0.2304, 0.5251, 0.3154, 0.5465]}, {"w": "of", "b": [0.3214, 0.5251, 0.3382, 0.5465]}, {"w": "each", "b": [0.3442, 0.5251, 0.3821, 0.5465]}, {"w": "attribute", "b": [0.3881, 0.5251, 0.4597, 0.5465]}, {"w": "(other", "b": [0.4657, 0.5251, 0.5176, 0.5465]}, {"w": "options", "b": [0.5236, 0.5251, 0.5868, 0.5465]}, {"w": "are", "b": [0.5928, 0.5251, 0.6185, 0.5465]}, {"w": "available;", "b": [0.6245, 0.5251, 0.7015, 0.5465]}, {"w": "see", "b": [0.7075, 0.5251, 0.7329, 0.5465]}, {"w": "Pandas’", "b": [0.7388, 0.5251, 0.8022, 0.5465]}, {"w": "docu‐", "b": [0.8082, 0.5251, 0.8572, 0.5465]}, {"w": "mentation", "b": [0.1429, 0.5442, 0.2288, 0.5656]}, {"w": "for", "b": [0.2336, 0.5442, 0.2581, 0.5656]}, {"w": "more", "b": [0.2628, 0.5442, 0.3071, 0.5656]}, {"w": "details).", "b": [0.3118, 0.5442, 0.3776, 0.5656]}]}, {"id": "b_2", "type": "paragraph", "text": "The most promising attribute to predict the median house value is the median income, so let’s zoom in on their correlation scatterplot (Figure 2-16):", "words": [{"w": "The", "b": [0.1429, 0.5723, 0.1757, 0.5937]}, {"w": "most", "b": [0.1857, 0.5723, 0.2274, 0.5937]}, {"w": "promising", "b": [0.2374, 0.5723, 0.3237, 0.5937]}, {"w": "attribute", "b": [0.3338, 0.5723, 0.4054, 0.5937]}, {"w": "to", "b": [0.4154, 0.5723, 0.4324, 0.5937]}, {"w": "predict", "b": [0.4424, 0.5723, 0.5017, 0.5937]}, {"w": "the", "b": [0.5117, 0.5723, 0.538, 0.5937]}, {"w": "median", "b": [0.5481, 0.5723, 0.6111, 0.5937]}, {"w": "house", "b": [0.6211, 0.5723, 0.6704, 0.5937]}, {"w": "value", "b": [0.6805, 0.5723, 0.7245, 0.5937]}, {"w": "is", "b": [0.7345, 0.5723, 0.7477, 0.5937]}, {"w": "the", "b": [0.7577, 0.5723, 0.7841, 0.5937]}, {"w": "median", "b": [0.7941, 0.5723, 0.8571, 0.5937]}, {"w": "income,", "b": [0.1429, 0.5913, 0.2099, 0.6127]}, {"w": "so", "b": [0.2147, 0.5913, 0.2329, 0.6127]}, {"w": "let’s", "b": [0.2377, 0.5913, 0.2679, 0.6127]}, {"w": "zoom", "b": [0.2726, 0.5913, 0.3197, 0.6127]}, {"w": "in", "b": [0.3244, 0.5913, 0.3414, 0.6127]}, {"w": "on", "b": [0.3461, 0.5913, 0.3681, 0.6127]}, {"w": "their", "b": [0.3729, 0.5913, 0.4125, 0.6127]}, {"w": "correlation", "b": [0.4173, 0.5913, 0.509, 0.6127]}, {"w": "scatterplot", "b": [0.5137, 0.5913, 0.6014, 0.6127]}, {"w": "(Figure", "b": [0.6061, 0.5913, 0.6673, 0.6127]}, {"w": "2-16):", "b": [0.672, 0.5913, 0.7214, 0.6127]}]}, {"id": "b_3", "type": "paragraph", "text": "housing.plot(kind=\"scatter\", x=\"median_income\", y=\"median_house_value\", alpha=0.1)", "words": [{"w": "housing.plot(kind=\"scatter\",", "b": [0.1766, 0.6233, 0.4127, 0.6361]}, {"w": "x=\"median_income\",", "b": [0.4211, 0.6233, 0.5729, 0.6361]}, {"w": "y=\"median_house_value\",", "b": [0.5814, 0.6233, 0.7753, 0.6361]}, {"w": "alpha=0.1)", "b": [0.2862, 0.6387, 0.3705, 0.6516]}]}, {"id": "b_4", "type": "paragraph", "text": "This plot reveals a few things. First, the correlation is indeed very strong; you can clearly see the upward trend and the points are not too dispersed. Second, the price cap that we noticed earlier is clearly visible as a horizontal line at $500,000. But this plot reveals other less obvious straight lines: a horizontal line around $450,000, another around $350,000, perhaps one around $280,000, and a few more below that. You may want to try removing the corresponding districts to prevent your algorithms from learning to reproduce these data quirks.", "words": [{"w": "This", "b": [0.1429, 0.6594, 0.1801, 0.6808]}, {"w": "plot", "b": [0.1876, 0.6594, 0.2208, 0.6808]}, {"w": "reveals", "b": [0.2283, 0.6594, 0.2854, 0.6808]}, {"w": "a", "b": [0.293, 0.6594, 0.3021, 0.6808]}, {"w": "few", "b": [0.3096, 0.6594, 0.3389, 0.6808]}, {"w": "things.", "b": [0.3465, 0.6594, 0.4031, 0.6808]}, {"w": "First,", "b": [0.4106, 0.6594, 0.4537, 0.6808]}, {"w": "the", "b": [0.4612, 0.6594, 0.4875, 0.6808]}, {"w": "correlation", "b": [0.4951, 0.6594, 0.5868, 0.6808]}, {"w": "is", "b": [0.5943, 0.6594, 0.6076, 0.6808]}, {"w": "indeed", "b": [0.6151, 0.6594, 0.6718, 0.6808]}, {"w": "very", "b": [0.6793, 0.6594, 0.7157, 0.6808]}, {"w": "strong;", "b": [0.7232, 0.6594, 0.7815, 0.6808]}, {"w": "you", "b": [0.789, 0.6594, 0.8203, 0.6808]}, {"w": "can", "b": [0.8278, 0.6594, 0.8571, 0.6808]}, {"w": "clearly", "b": [0.1429, 0.6784, 0.1975, 0.6998]}, {"w": "see", "b": [0.2039, 0.6784, 0.2292, 0.6998]}, {"w": "the", "b": [0.2356, 0.6784, 0.262, 0.6998]}, {"w": "upward", "b": [0.2683, 0.6784, 0.3325, 0.6998]}, {"w": "trend", "b": [0.3388, 0.6784, 0.3842, 0.6998]}, {"w": "and", "b": [0.3905, 0.6784, 0.4221, 0.6998]}, {"w": "the", "b": [0.4285, 0.6784, 0.4548, 0.6998]}, {"w": "points", "b": [0.4612, 0.6784, 0.5133, 0.6998]}, {"w": "are", "b": [0.5197, 0.6784, 0.5454, 0.6998]}, {"w": "not", "b": [0.5518, 0.6784, 0.5801, 0.6998]}, {"w": "too", "b": [0.5865, 0.6784, 0.6141, 0.6998]}, {"w": "dispersed.", "b": [0.6205, 0.6784, 0.7045, 0.6998]}, {"w": "Second,", "b": [0.7109, 0.6784, 0.7762, 0.6998]}, {"w": "the", "b": [0.7825, 0.6784, 0.8089, 0.6998]}, {"w": "price", "b": [0.8153, 0.6784, 0.8572, 0.6998]}, {"w": "cap", "b": [0.1429, 0.6974, 0.1713, 0.7189]}, {"w": "that", "b": [0.1777, 0.6974, 0.2103, 0.7189]}, {"w": "we", "b": [0.2166, 0.6974, 0.2397, 0.7189]}, {"w": "noticed", "b": [0.2461, 0.6974, 0.3087, 0.7189]}, {"w": "earlier", "b": [0.315, 0.6974, 0.3682, 0.7189]}, {"w": "is", "b": [0.3745, 0.6974, 0.3877, 0.7189]}, {"w": "clearly", "b": [0.3941, 0.6974, 0.4487, 0.7189]}, {"w": "visible", "b": [0.4551, 0.6974, 0.5082, 0.7189]}, {"w": "as", "b": [0.5146, 0.6974, 0.5314, 0.7189]}, {"w": "a", "b": [0.5377, 0.6974, 0.5468, 0.7189]}, {"w": "horizontal", "b": [0.5532, 0.6974, 0.6394, 0.7189]}, {"w": "line", "b": [0.6457, 0.6974, 0.6768, 0.7189]}, {"w": "at", "b": [0.6832, 0.6974, 0.6983, 0.7189]}, {"w": "$500,000.", "b": [0.7046, 0.6974, 0.7841, 0.7189]}, {"w": "But", "b": [0.7904, 0.6974, 0.8201, 0.7189]}, {"w": "this", "b": [0.8264, 0.6974, 0.8571, 0.7189]}, {"w": "plot", "b": [0.1429, 0.7165, 0.176, 0.7379]}, {"w": "reveals", "b": [0.1861, 0.7165, 0.2432, 0.7379]}, {"w": "other", "b": [0.2532, 0.7165, 0.2979, 0.7379]}, {"w": "less", "b": [0.308, 0.7165, 0.3374, 0.7379]}, {"w": "obvious", "b": [0.3474, 0.7165, 0.4132, 0.7379]}, {"w": "straight", "b": [0.4232, 0.7165, 0.4865, 0.7379]}, {"w": "lines:", "b": [0.4965, 0.7165, 0.54, 0.7379]}, {"w": "a", "b": [0.5501, 0.7165, 0.5592, 0.7379]}, {"w": "horizontal", "b": [0.5693, 0.7165, 0.6555, 0.7379]}, {"w": "line", "b": [0.6655, 0.7165, 0.6966, 0.7379]}, {"w": "around", "b": [0.7066, 0.7165, 0.7676, 0.7379]}, {"w": "$450,000,", "b": [0.7776, 0.7165, 0.8571, 0.7379]}, {"w": "another", "b": [0.1428, 0.7355, 0.2081, 0.757]}, {"w": "around", "b": [0.2139, 0.7355, 0.2749, 0.757]}, {"w": "$350,000,", "b": [0.2807, 0.7355, 0.3602, 0.757]}, {"w": "perhaps", "b": [0.3661, 0.7355, 0.432, 0.757]}, {"w": "one", "b": [0.4379, 0.7355, 0.4687, 0.757]}, {"w": "around", "b": [0.4746, 0.7355, 0.5355, 0.757]}, {"w": "$280,000,", "b": [0.5414, 0.7355, 0.6209, 0.757]}, {"w": "and", "b": [0.6267, 0.7355, 0.6583, 0.757]}, {"w": "a", "b": [0.6641, 0.7355, 0.6733, 0.757]}, {"w": "few", "b": [0.6791, 0.7355, 0.7084, 0.757]}, {"w": "more", "b": [0.7142, 0.7355, 0.7585, 0.757]}, {"w": "below", "b": [0.7644, 0.7355, 0.814, 0.757]}, {"w": "that.", "b": [0.8198, 0.7355, 0.8571, 0.757]}, {"w": "You", "b": [0.1429, 0.7546, 0.1752, 0.776]}, {"w": "may", "b": [0.1801, 0.7546, 0.2155, 0.776]}, {"w": "want", "b": [0.2205, 0.7546, 0.2612, 0.776]}, {"w": "to", "b": [0.2662, 0.7546, 0.2832, 0.776]}, {"w": "try", "b": [0.2881, 0.7546, 0.3123, 0.776]}, {"w": "removing", "b": [0.3173, 0.7546, 0.3979, 0.776]}, {"w": "the", "b": [0.4028, 0.7546, 0.4292, 0.776]}, {"w": "corresponding", "b": [0.4341, 0.7546, 0.5562, 0.776]}, {"w": "districts", "b": [0.5611, 0.7546, 0.6278, 0.776]}, {"w": "to", "b": [0.6327, 0.7546, 0.6497, 0.776]}, {"w": "prevent", "b": [0.6547, 0.7546, 0.718, 0.776]}, {"w": "your", "b": [0.7229, 0.7546, 0.7619, 0.776]}, {"w": "algorithms", "b": [0.7669, 0.7546, 0.8571, 0.776]}, {"w": "from", "b": [0.1429, 0.7736, 0.1844, 0.7951]}, {"w": "learning", "b": [0.1892, 0.7736, 0.2583, 0.7951]}, {"w": "to", "b": [0.263, 0.7736, 0.28, 0.7951]}, {"w": "reproduce", "b": [0.2847, 0.7736, 0.3703, 0.7951]}, {"w": "these", "b": [0.375, 0.7736, 0.4179, 0.7951]}, {"w": "data", "b": [0.4226, 0.7736, 0.4579, 0.7951]}, {"w": "quirks.", "b": [0.4626, 0.7736, 0.5203, 0.7951]}]}, {"id": "b_5", "type": "equation", "text": "64 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "64", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 91, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 2-16. Median income versus median house value", "words": [{"w": "Figure", "b": [0.1429, 0.3799, 0.1943, 0.4015]}, {"w": "2-16.", "b": [0.1991, 0.3799, 0.2407, 0.4015]}, {"w": "Median", "b": [0.2455, 0.3799, 0.3082, 0.4015]}, {"w": "income", "b": [0.313, 0.3799, 0.3713, 0.4015]}, {"w": "versus", "b": [0.3761, 0.3799, 0.4262, 0.4015]}, {"w": "median", "b": [0.431, 0.3799, 0.4923, 0.4015]}, {"w": "house", "b": [0.4971, 0.3799, 0.5438, 0.4015]}, {"w": "value", "b": [0.5485, 0.3799, 0.592, 0.4015]}]}, {"id": "b_1", "type": "paragraph", "text": "Experimenting with Attribute Combinations", "words": [{"w": "Experimenting", "b": [0.1429, 0.4145, 0.2954, 0.4431]}, {"w": "with", "b": [0.3003, 0.4145, 0.3478, 0.4431]}, {"w": "Attribute", "b": [0.3528, 0.4145, 0.4476, 0.4431]}, {"w": "Combinations", "b": [0.4526, 0.4145, 0.595, 0.4431]}]}, {"id": "b_2", "type": "paragraph", "text": "Hopefully the previous sections gave you an idea of a few ways you can explore the data and gain insights. You identified a few data quirks that you may want to clean up before feeding the data to a Machine Learning algorithm, and you found interesting correlations between attributes, in particular with the target attribute. You also noticed that some attributes have a tail-heavy distribution, so you may want to trans‐ form them (e.g., by computing their logarithm). Of course, your mileage will vary considerably with each project, but the general ideas are similar.", "words": [{"w": "Hopefully", "b": [0.1429, 0.449, 0.226, 0.4704]}, {"w": "the", "b": [0.2326, 0.449, 0.2589, 0.4704]}, {"w": "previous", "b": [0.2654, 0.449, 0.3375, 0.4704]}, {"w": "sections", "b": [0.344, 0.449, 0.4109, 0.4704]}, {"w": "gave", "b": [0.4174, 0.449, 0.4545, 0.4704]}, {"w": "you", "b": [0.461, 0.449, 0.4922, 0.4704]}, {"w": "an", "b": [0.4988, 0.449, 0.5193, 0.4704]}, {"w": "idea", "b": [0.5258, 0.449, 0.5604, 0.4704]}, {"w": "of", "b": [0.567, 0.449, 0.5837, 0.4704]}, {"w": "a", "b": [0.5903, 0.449, 0.5994, 0.4704]}, {"w": "few", "b": [0.6059, 0.449, 0.6352, 0.4704]}, {"w": "ways", "b": [0.6418, 0.449, 0.682, 0.4704]}, {"w": "you", "b": [0.6885, 0.449, 0.7198, 0.4704]}, {"w": "can", "b": [0.7263, 0.449, 0.7557, 0.4704]}, {"w": "explore", "b": [0.7622, 0.449, 0.8243, 0.4704]}, {"w": "the", "b": [0.8308, 0.449, 0.8571, 0.4704]}, {"w": "data", "b": [0.1429, 0.468, 0.1781, 0.4894]}, {"w": "and", "b": [0.1832, 0.468, 0.2147, 0.4894]}, {"w": "gain", "b": [0.2197, 0.468, 0.2556, 0.4894]}, {"w": "insights.", "b": [0.2607, 0.468, 0.3301, 0.4894]}, {"w": "You", "b": [0.3351, 0.468, 0.3675, 0.4894]}, {"w": "identified", "b": [0.3725, 0.468, 0.4525, 0.4894]}, {"w": "a", "b": [0.4576, 0.468, 0.4667, 0.4894]}, {"w": "few", "b": [0.4718, 0.468, 0.501, 0.4894]}, {"w": "data", "b": [0.5061, 0.468, 0.5413, 0.4894]}, {"w": "quirks", "b": [0.5464, 0.468, 0.5994, 0.4894]}, {"w": "that", "b": [0.6044, 0.468, 0.637, 0.4894]}, {"w": "you", "b": [0.6421, 0.468, 0.6733, 0.4894]}, {"w": "may", "b": [0.6784, 0.468, 0.7138, 0.4894]}, {"w": "want", "b": [0.7188, 0.468, 0.7596, 0.4894]}, {"w": "to", "b": [0.7646, 0.468, 0.7816, 0.4894]}, {"w": "clean", "b": [0.7866, 0.468, 0.8301, 0.4894]}, {"w": "up", "b": [0.8352, 0.468, 0.8571, 0.4894]}, {"w": "before", "b": [0.1428, 0.4871, 0.1957, 0.5085]}, {"w": "feeding", "b": [0.2019, 0.4871, 0.2635, 0.5085]}, {"w": "the", "b": [0.2697, 0.4871, 0.296, 0.5085]}, {"w": "data", "b": [0.3022, 0.4871, 0.3375, 0.5085]}, {"w": "to", "b": [0.3437, 0.4871, 0.3606, 0.5085]}, {"w": "a", "b": [0.3668, 0.4871, 0.376, 0.5085]}, {"w": "Machine", "b": [0.3822, 0.4871, 0.4553, 0.5085]}, {"w": "Learning", "b": [0.4615, 0.4871, 0.5366, 0.5085]}, {"w": "algorithm,", "b": [0.5428, 0.4871, 0.6302, 0.5085]}, {"w": "and", "b": [0.6364, 0.4871, 0.6679, 0.5085]}, {"w": "you", "b": [0.6741, 0.4871, 0.7054, 0.5085]}, {"w": "found", "b": [0.7116, 0.4871, 0.7618, 0.5085]}, {"w": "interesting", "b": [0.768, 0.4871, 0.8571, 0.5085]}, {"w": "correlations", "b": [0.1429, 0.5061, 0.2422, 0.5275]}, {"w": "between", "b": [0.2532, 0.5061, 0.3224, 0.5275]}, {"w": "attributes,", "b": [0.3334, 0.5061, 0.4174, 0.5275]}, {"w": "in", "b": [0.4283, 0.5061, 0.4453, 0.5275]}, {"w": "particular", "b": [0.4563, 0.5061, 0.538, 0.5275]}, {"w": "with", "b": [0.549, 0.5061, 0.5864, 0.5275]}, {"w": "the", "b": [0.5973, 0.5061, 0.6237, 0.5275]}, {"w": "target", "b": [0.6346, 0.5061, 0.6828, 0.5275]}, {"w": "attribute.", "b": [0.6938, 0.5061, 0.7702, 0.5275]}, {"w": "You", "b": [0.7811, 0.5061, 0.8135, 0.5275]}, {"w": "also", "b": [0.8245, 0.5061, 0.8571, 0.5275]}, {"w": "noticed", "b": [0.1429, 0.5252, 0.2055, 0.5466]}, {"w": "that", "b": [0.2108, 0.5252, 0.2434, 0.5466]}, {"w": "some", "b": [0.2488, 0.5252, 0.293, 0.5466]}, {"w": "attributes", "b": [0.2983, 0.5252, 0.3776, 0.5466]}, {"w": "have", "b": [0.383, 0.5252, 0.4214, 0.5466]}, {"w": "a", "b": [0.4267, 0.5252, 0.4359, 0.5466]}, {"w": "tail-heavy", "b": [0.4413, 0.5252, 0.523, 0.5466]}, {"w": "distribution,", "b": [0.5283, 0.5252, 0.6326, 0.5466]}, {"w": "so", "b": [0.638, 0.5252, 0.6562, 0.5466]}, {"w": "you", "b": [0.6616, 0.5252, 0.6929, 0.5466]}, {"w": "may", "b": [0.6982, 0.5252, 0.7336, 0.5466]}, {"w": "want", "b": [0.739, 0.5252, 0.7797, 0.5466]}, {"w": "to", "b": [0.7851, 0.5252, 0.8021, 0.5466]}, {"w": "trans‐", "b": [0.8075, 0.5252, 0.8571, 0.5466]}, {"w": "form", "b": [0.1429, 0.5442, 0.1844, 0.5656]}, {"w": "them", "b": [0.1921, 0.5442, 0.2355, 0.5656]}, {"w": "(e.g.,", "b": [0.2431, 0.5442, 0.2832, 0.5656]}, {"w": "by", "b": [0.2909, 0.5442, 0.311, 0.5656]}, {"w": "computing", "b": [0.3187, 0.5442, 0.4098, 0.5656]}, {"w": "their", "b": [0.4175, 0.5442, 0.4571, 0.5656]}, {"w": "logarithm).", "b": [0.4648, 0.5442, 0.5594, 0.5656]}, {"w": "Of", "b": [0.5671, 0.5442, 0.5888, 0.5656]}, {"w": "course,", "b": [0.5964, 0.5442, 0.6559, 0.5656]}, {"w": "your", "b": [0.6636, 0.5442, 0.7026, 0.5656]}, {"w": "mileage", "b": [0.7102, 0.5442, 0.7747, 0.5656]}, {"w": "will", "b": [0.7824, 0.5442, 0.8128, 0.5656]}, {"w": "vary", "b": [0.8205, 0.5442, 0.8571, 0.5656]}, {"w": "considerably", "b": [0.1429, 0.5633, 0.2491, 0.5847]}, {"w": "with", "b": [0.2538, 0.5633, 0.2911, 0.5847]}, {"w": "each", "b": [0.2959, 0.5633, 0.3338, 0.5847]}, {"w": "project,", "b": [0.3385, 0.5633, 0.4019, 0.5847]}, {"w": "but", "b": [0.4066, 0.5633, 0.4346, 0.5847]}, {"w": "the", "b": [0.4394, 0.5633, 0.4657, 0.5847]}, {"w": "general", "b": [0.4704, 0.5633, 0.5314, 0.5847]}, {"w": "ideas", "b": [0.5362, 0.5633, 0.5784, 0.5847]}, {"w": "are", "b": [0.5831, 0.5633, 0.6088, 0.5847]}, {"w": "similar.", "b": [0.6136, 0.5633, 0.675, 0.5847]}]}, {"id": "b_3", "type": "paragraph", "text": "One last thing you may want to do before actually preparing the data for Machine Learning algorithms is to try out various attribute combinations. For example, the total number of rooms in a district is not very useful if you don’t know how many households there are. What you really want is the number of rooms per household. Similarly, the total number of bedrooms by itself is not very useful: you probably want to compare it to the number of rooms. And the population per household also seems like an interesting attribute combination to look at. Let’s create these new attributes:", "words": [{"w": "One", "b": [0.1429, 0.5914, 0.1787, 0.6128]}, {"w": "last", "b": [0.1859, 0.5914, 0.2143, 0.6128]}, {"w": "thing", "b": [0.2215, 0.5914, 0.2658, 0.6128]}, {"w": "you", "b": [0.273, 0.5914, 0.3042, 0.6128]}, {"w": "may", "b": [0.3115, 0.5914, 0.3468, 0.6128]}, {"w": "want", "b": [0.3541, 0.5914, 0.3948, 0.6128]}, {"w": "to", "b": [0.4021, 0.5914, 0.419, 0.6128]}, {"w": "do", "b": [0.4263, 0.5914, 0.4479, 0.6128]}, {"w": "before", "b": [0.4551, 0.5914, 0.5079, 0.6128]}, {"w": "actually", "b": [0.5152, 0.5914, 0.5798, 0.6128]}, {"w": "preparing", "b": [0.587, 0.5914, 0.669, 0.6128]}, {"w": "the", "b": [0.6763, 0.5914, 0.7026, 0.6128]}, {"w": "data", "b": [0.7098, 0.5914, 0.7451, 0.6128]}, {"w": "for", "b": [0.7523, 0.5914, 0.7768, 0.6128]}, {"w": "Machine", "b": [0.784, 0.5914, 0.8572, 0.6128]}, {"w": "Learning", "b": [0.1429, 0.6104, 0.2179, 0.6318]}, {"w": "algorithms", "b": [0.2256, 0.6104, 0.3159, 0.6318]}, {"w": "is", "b": [0.3236, 0.6104, 0.3368, 0.6318]}, {"w": "to", "b": [0.3445, 0.6104, 0.3615, 0.6318]}, {"w": "try", "b": [0.3692, 0.6104, 0.3934, 0.6318]}, {"w": "out", "b": [0.4011, 0.6104, 0.4292, 0.6318]}, {"w": "various", "b": [0.4369, 0.6104, 0.4983, 0.6318]}, {"w": "attribute", "b": [0.506, 0.6104, 0.5776, 0.6318]}, {"w": "combinations.", "b": [0.5853, 0.6104, 0.7045, 0.6318]}, {"w": "For", "b": [0.7122, 0.6104, 0.7411, 0.6318]}, {"w": "example,", "b": [0.7488, 0.6104, 0.8231, 0.6318]}, {"w": "the", "b": [0.8308, 0.6104, 0.8571, 0.6318]}, {"w": "total", "b": [0.1429, 0.6295, 0.1806, 0.6509]}, {"w": "number", "b": [0.1876, 0.6295, 0.2539, 0.6509]}, {"w": "of", "b": [0.261, 0.6295, 0.2778, 0.6509]}, {"w": "rooms", "b": [0.2848, 0.6295, 0.3385, 0.6509]}, {"w": "in", "b": [0.3455, 0.6295, 0.3625, 0.6509]}, {"w": "a", "b": [0.3695, 0.6295, 0.3787, 0.6509]}, {"w": "district", "b": [0.3857, 0.6295, 0.4448, 0.6509]}, {"w": "is", "b": [0.4518, 0.6295, 0.465, 0.6509]}, {"w": "not", "b": [0.4721, 0.6295, 0.5005, 0.6509]}, {"w": "very", "b": [0.5075, 0.6295, 0.5439, 0.6509]}, {"w": "useful", "b": [0.5509, 0.6295, 0.601, 0.6509]}, {"w": "if", "b": [0.608, 0.6295, 0.6198, 0.6509]}, {"w": "you", "b": [0.6268, 0.6295, 0.6581, 0.6509]}, {"w": "don’t", "b": [0.6651, 0.6295, 0.7067, 0.6509]}, {"w": "know", "b": [0.7137, 0.6295, 0.7604, 0.6509]}, {"w": "how", "b": [0.7674, 0.6295, 0.8034, 0.6509]}, {"w": "many", "b": [0.8105, 0.6295, 0.8571, 0.6509]}, {"w": "households", "b": [0.1428, 0.6485, 0.2378, 0.6699]}, {"w": "there", "b": [0.2444, 0.6485, 0.2873, 0.6699]}, {"w": "are.", "b": [0.2939, 0.6485, 0.3244, 0.6699]}, {"w": "What", "b": [0.331, 0.6485, 0.3775, 0.6699]}, {"w": "you", "b": [0.384, 0.6485, 0.4153, 0.6699]}, {"w": "really", "b": [0.4219, 0.6485, 0.4677, 0.6699]}, {"w": "want", "b": [0.4743, 0.6485, 0.5151, 0.6699]}, {"w": "is", "b": [0.5217, 0.6485, 0.5349, 0.6699]}, {"w": "the", "b": [0.5415, 0.6485, 0.5678, 0.6699]}, {"w": "number", "b": [0.5744, 0.6485, 0.6407, 0.6699]}, {"w": "of", "b": [0.6473, 0.6485, 0.6641, 0.6699]}, {"w": "rooms", "b": [0.6707, 0.6485, 0.7244, 0.6699]}, {"w": "per", "b": [0.731, 0.6485, 0.7585, 0.6699]}, {"w": "household.", "b": [0.7651, 0.6485, 0.8571, 0.6699]}, {"w": "Similarly,", "b": [0.1429, 0.6676, 0.2212, 0.689]}, {"w": "the", "b": [0.2293, 0.6676, 0.2557, 0.689]}, {"w": "total", "b": [0.2638, 0.6676, 0.3016, 0.689]}, {"w": "number", "b": [0.3098, 0.6676, 0.3761, 0.689]}, {"w": "of", "b": [0.3842, 0.6676, 0.401, 0.689]}, {"w": "bedrooms", "b": [0.4092, 0.6676, 0.4933, 0.689]}, {"w": "by", "b": [0.5015, 0.6676, 0.5216, 0.689]}, {"w": "itself", "b": [0.5298, 0.6676, 0.5697, 0.689]}, {"w": "is", "b": [0.5778, 0.6676, 0.5911, 0.689]}, {"w": "not", "b": [0.5992, 0.6676, 0.6276, 0.689]}, {"w": "very", "b": [0.6358, 0.6676, 0.6722, 0.689]}, {"w": "useful:", "b": [0.6803, 0.6676, 0.7351, 0.689]}, {"w": "you", "b": [0.7433, 0.6676, 0.7746, 0.689]}, {"w": "probably", "b": [0.7827, 0.6676, 0.8572, 0.689]}, {"w": "want", "b": [0.1429, 0.6866, 0.1836, 0.708]}, {"w": "to", "b": [0.1897, 0.6866, 0.2067, 0.708]}, {"w": "compare", "b": [0.2127, 0.6866, 0.2855, 0.708]}, {"w": "it", "b": [0.2915, 0.6866, 0.3035, 0.708]}, {"w": "to", "b": [0.3095, 0.6866, 0.3265, 0.708]}, {"w": "the", "b": [0.3326, 0.6866, 0.3589, 0.708]}, {"w": "number", "b": [0.365, 0.6866, 0.4313, 0.708]}, {"w": "of", "b": [0.4373, 0.6866, 0.4541, 0.708]}, {"w": "rooms.", "b": [0.4602, 0.6866, 0.5186, 0.708]}, {"w": "And", "b": [0.5247, 0.6866, 0.5615, 0.708]}, {"w": "the", "b": [0.5675, 0.6866, 0.5939, 0.708]}, {"w": "population", "b": [0.5999, 0.6866, 0.6914, 0.708]}, {"w": "per", "b": [0.6975, 0.6866, 0.725, 0.708]}, {"w": "household", "b": [0.7311, 0.6866, 0.8184, 0.708]}, {"w": "also", "b": [0.8245, 0.6866, 0.8571, 0.708]}, {"w": "seems", "b": [0.1429, 0.7057, 0.1929, 0.7271]}, {"w": "like", "b": [0.202, 0.7057, 0.2321, 0.7271]}, {"w": "an", "b": [0.2412, 0.7057, 0.2618, 0.7271]}, {"w": "interesting", "b": [0.2709, 0.7057, 0.36, 0.7271]}, {"w": "attribute", "b": [0.3691, 0.7057, 0.4408, 0.7271]}, {"w": "combination", "b": [0.4499, 0.7057, 0.5567, 0.7271]}, {"w": "to", "b": [0.5658, 0.7057, 0.5828, 0.7271]}, {"w": "look", "b": [0.5919, 0.7057, 0.6288, 0.7271]}, {"w": "at.", "b": [0.6379, 0.7057, 0.6577, 0.7271]}, {"w": "Let’s", "b": [0.6669, 0.7057, 0.703, 0.7271]}, {"w": "create", "b": [0.7122, 0.7057, 0.7615, 0.7271]}, {"w": "these", "b": [0.7707, 0.7057, 0.8135, 0.7271]}, {"w": "new", "b": [0.8226, 0.7057, 0.8571, 0.7271]}, {"w": "attributes:", "b": [0.1429, 0.7247, 0.2269, 0.7461]}]}, {"id": "b_4", "type": "paragraph", "text": "housing[\"rooms_per_household\"] = housing[\"total_rooms\"]/housing[\"households\"] housing[\"bedrooms_per_room\"] = housing[\"total_bedrooms\"]/housing[\"total_rooms\"] housing[\"population_per_household\"]=housing[\"population\"]/housing[\"households\"]", "words": [{"w": "housing[\"rooms_per_household\"]", "b": [0.1766, 0.7567, 0.4296, 0.7695]}, {"w": "=", "b": [0.438, 0.7567, 0.4464, 0.7695]}, {"w": "housing[\"total_rooms\"]/housing[\"households\"]", "b": [0.4549, 0.7567, 0.8259, 0.7695]}, {"w": "housing[\"bedrooms_per_room\"]", "b": [0.1766, 0.7721, 0.4127, 0.785]}, {"w": "=", "b": [0.4211, 0.7721, 0.4296, 0.785]}, {"w": "housing[\"total_bedrooms\"]/housing[\"total_rooms\"]", "b": [0.438, 0.7721, 0.8428, 0.785]}, {"w": "housing[\"population_per_household\"]=housing[\"population\"]/housing[\"households\"]", "b": [0.1766, 0.7875, 0.8428, 0.8004]}]}, {"id": "b_5", "type": "paragraph", "text": "And now let’s look at the correlation matrix again:", "words": [{"w": "And", "b": [0.1429, 0.8082, 0.1796, 0.8296]}, {"w": "now", "b": [0.1844, 0.8082, 0.2207, 0.8296]}, {"w": "let’s", "b": [0.2254, 0.8082, 0.2556, 0.8296]}, {"w": "look", "b": [0.2604, 0.8082, 0.2972, 0.8296]}, {"w": "at", "b": [0.3019, 0.8082, 0.317, 0.8296]}, {"w": "the", "b": [0.3218, 0.8082, 0.3481, 0.8296]}, {"w": "correlation", "b": [0.3528, 0.8082, 0.4446, 0.8296]}, {"w": "matrix", "b": [0.4493, 0.8082, 0.5046, 0.8296]}, {"w": "again:", "b": [0.5093, 0.8082, 0.5591, 0.8296]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> corr_matrix = housing.corr() >>> corr_matrix[\"median_house_value\"].sort_values(ascending=False) median_house_value 1.000000", "words": [{"w": ">>>", "b": [0.1766, 0.8401, 0.2019, 0.853]}, {"w": "corr_matrix", "b": [0.2103, 0.8401, 0.3031, 0.853]}, {"w": "=", "b": [0.3115, 0.8401, 0.3199, 0.853]}, {"w": "housing.corr()", "b": [0.3284, 0.8401, 0.4464, 0.853]}, {"w": ">>>", "b": [0.1766, 0.8556, 0.2019, 0.8684]}, {"w": "corr_matrix[\"median_house_value\"].sort_values(ascending=False)", "b": [0.2103, 0.8556, 0.7331, 0.8684]}, {"w": "median_house_value", "b": [0.1766, 0.871, 0.3284, 0.8838]}, {"w": "1.000000", "b": [0.4127, 0.871, 0.4802, 0.8838]}]}, {"id": "b_7", "type": "paragraph", "text": "Discover and Visualize the Data to Gain Insights | 65", "words": [{"w": "Discover", "b": [0.5263, 0.9225, 0.5754, 0.9388]}, {"w": "and", "b": [0.5782, 0.9225, 0.6006, 0.9388]}, {"w": "Visualize", "b": [0.6034, 0.9225, 0.6555, 0.9388]}, {"w": "the", "b": [0.6583, 0.9225, 0.6782, 0.9388]}, {"w": "Data", "b": [0.6811, 0.9225, 0.7087, 0.9388]}, {"w": "to", "b": [0.7115, 0.9225, 0.7239, 0.9388]}, {"w": "Gain", "b": [0.7268, 0.9225, 0.7534, 0.9388]}, {"w": "Insights", "b": [0.7562, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "65", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 92, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "median_income 0.687160 rooms_per_household 0.146285 total_rooms 0.135097 housing_median_age 0.114110 households 0.064506 total_bedrooms 0.047689 population_per_household -0.021985 population -0.026920 longitude -0.047432 latitude -0.142724 bedrooms_per_room -0.259984 Name: median_house_value, dtype: float64", "words": [{"w": "median_income", "b": [0.1766, 0.0829, 0.2862, 0.0958]}, {"w": "0.687160", "b": [0.4127, 0.0829, 0.4802, 0.0958]}, {"w": "rooms_per_household", "b": [0.1766, 0.0983, 0.3368, 0.1112]}, {"w": "0.146285", "b": [0.4127, 0.0983, 0.4802, 0.1112]}, {"w": "total_rooms", "b": [0.1766, 0.1138, 0.2693, 0.1266]}, {"w": "0.135097", "b": [0.4127, 0.1138, 0.4802, 0.1266]}, {"w": "housing_median_age", "b": [0.1766, 0.1292, 0.3284, 0.142]}, {"w": "0.114110", "b": [0.4127, 0.1292, 0.4802, 0.142]}, {"w": "households", "b": [0.1766, 0.1446, 0.2609, 0.1574]}, {"w": "0.064506", "b": [0.4127, 0.1446, 0.4802, 0.1574]}, {"w": "total_bedrooms", "b": [0.1766, 0.16, 0.2946, 0.1729]}, {"w": "0.047689", "b": [0.4127, 0.16, 0.4802, 0.1729]}, {"w": "population_per_household", "b": [0.1766, 0.1754, 0.379, 0.1883]}, {"w": "-0.021985", "b": [0.4043, 0.1754, 0.4802, 0.1883]}, {"w": "population", "b": [0.1766, 0.1909, 0.2609, 0.2037]}, {"w": "-0.026920", "b": [0.4043, 0.1909, 0.4802, 0.2037]}, {"w": "longitude", "b": [0.1766, 0.2063, 0.2525, 0.2191]}, {"w": "-0.047432", "b": [0.4043, 0.2063, 0.4802, 0.2191]}, {"w": "latitude", "b": [0.1766, 0.2217, 0.244, 0.2345]}, {"w": "-0.142724", "b": [0.4043, 0.2217, 0.4802, 0.2345]}, {"w": "bedrooms_per_room", "b": [0.1766, 0.2371, 0.3199, 0.25]}, {"w": "-0.259984", "b": [0.4043, 0.2371, 0.4802, 0.25]}, {"w": "Name:", "b": [0.1766, 0.2525, 0.2188, 0.2654]}, {"w": "median_house_value,", "b": [0.2272, 0.2525, 0.3874, 0.2654]}, {"w": "dtype:", "b": [0.3958, 0.2525, 0.4464, 0.2654]}, {"w": "float64", "b": [0.4549, 0.2525, 0.5139, 0.2654]}]}, {"id": "b_1", "type": "paragraph", "text": "Hey, not bad! The new bedrooms_per_room attribute is much more correlated with the median house value than the total number of rooms or bedrooms. Apparently houses with a lower bedroom/room ratio tend to be more expensive. The number of rooms per household is also more informative than the total number of rooms in a district—obviously the larger the houses, the more expensive they are.", "words": [{"w": "Hey,", "b": [0.1428, 0.2741, 0.1799, 0.2955]}, {"w": "not", "b": [0.1871, 0.2741, 0.2155, 0.2955]}, {"w": "bad!", "b": [0.2226, 0.2741, 0.2591, 0.2955]}, {"w": "The", "b": [0.2662, 0.2741, 0.2991, 0.2955]}, {"w": "new", "b": [0.3062, 0.2741, 0.3407, 0.2955]}, {"w": "bedrooms_per_room", "b": [0.3479, 0.2772, 0.5161, 0.2923]}, {"w": "attribute", "b": [0.5233, 0.2741, 0.5949, 0.2955]}, {"w": "is", "b": [0.6021, 0.2741, 0.6153, 0.2955]}, {"w": "much", "b": [0.6224, 0.2741, 0.6701, 0.2955]}, {"w": "more", "b": [0.6773, 0.2741, 0.7215, 0.2955]}, {"w": "correlated", "b": [0.7287, 0.2741, 0.8127, 0.2955]}, {"w": "with", "b": [0.8198, 0.2741, 0.8572, 0.2955]}, {"w": "the", "b": [0.1429, 0.2931, 0.1692, 0.3145]}, {"w": "median", "b": [0.1769, 0.2931, 0.2399, 0.3145]}, {"w": "house", "b": [0.2476, 0.2931, 0.2969, 0.3145]}, {"w": "value", "b": [0.3046, 0.2931, 0.3486, 0.3145]}, {"w": "than", "b": [0.3563, 0.2931, 0.3943, 0.3145]}, {"w": "the", "b": [0.402, 0.2931, 0.4283, 0.3145]}, {"w": "total", "b": [0.436, 0.2931, 0.4737, 0.3145]}, {"w": "number", "b": [0.4814, 0.2931, 0.5477, 0.3145]}, {"w": "of", "b": [0.5554, 0.2931, 0.5722, 0.3145]}, {"w": "rooms", "b": [0.5799, 0.2931, 0.6336, 0.3145]}, {"w": "or", "b": [0.6413, 0.2931, 0.6596, 0.3145]}, {"w": "bedrooms.", "b": [0.6673, 0.2931, 0.7562, 0.3145]}, {"w": "Apparently", "b": [0.7639, 0.2931, 0.8571, 0.3145]}, {"w": "houses", "b": [0.1429, 0.3122, 0.1998, 0.3336]}, {"w": "with", "b": [0.2056, 0.3122, 0.2429, 0.3336]}, {"w": "a", "b": [0.2487, 0.3122, 0.2578, 0.3336]}, {"w": "lower", "b": [0.2636, 0.3122, 0.3104, 0.3336]}, {"w": "bedroom/room", "b": [0.3161, 0.3122, 0.4456, 0.3336]}, {"w": "ratio", "b": [0.4513, 0.3122, 0.4904, 0.3336]}, {"w": "tend", "b": [0.4962, 0.3122, 0.5338, 0.3336]}, {"w": "to", "b": [0.5395, 0.3122, 0.5565, 0.3336]}, {"w": "be", "b": [0.5623, 0.3122, 0.5817, 0.3336]}, {"w": "more", "b": [0.5875, 0.3122, 0.6318, 0.3336]}, {"w": "expensive.", "b": [0.6376, 0.3122, 0.7239, 0.3336]}, {"w": "The", "b": [0.7297, 0.3122, 0.7625, 0.3336]}, {"w": "number", "b": [0.7683, 0.3122, 0.8346, 0.3336]}, {"w": "of", "b": [0.8403, 0.3122, 0.8571, 0.3336]}, {"w": "rooms", "b": [0.1428, 0.3312, 0.1965, 0.3526]}, {"w": "per", "b": [0.2032, 0.3312, 0.2307, 0.3526]}, {"w": "household", "b": [0.2373, 0.3312, 0.3246, 0.3526]}, {"w": "is", "b": [0.3313, 0.3312, 0.3445, 0.3526]}, {"w": "also", "b": [0.3511, 0.3312, 0.3838, 0.3526]}, {"w": "more", "b": [0.3904, 0.3312, 0.4347, 0.3526]}, {"w": "informative", "b": [0.4413, 0.3312, 0.5391, 0.3526]}, {"w": "than", "b": [0.5457, 0.3312, 0.5837, 0.3526]}, {"w": "the", "b": [0.5904, 0.3312, 0.6167, 0.3526]}, {"w": "total", "b": [0.6233, 0.3312, 0.6611, 0.3526]}, {"w": "number", "b": [0.6677, 0.3312, 0.734, 0.3526]}, {"w": "of", "b": [0.7406, 0.3312, 0.7574, 0.3526]}, {"w": "rooms", "b": [0.7641, 0.3312, 0.8177, 0.3526]}, {"w": "in", "b": [0.8244, 0.3312, 0.8414, 0.3526]}, {"w": "a", "b": [0.848, 0.3312, 0.8571, 0.3526]}, {"w": "district—obviously", "b": [0.1429, 0.3503, 0.3017, 0.3717]}, {"w": "the", "b": [0.3065, 0.3503, 0.3328, 0.3717]}, {"w": "larger", "b": [0.3375, 0.3503, 0.386, 0.3717]}, {"w": "the", "b": [0.3907, 0.3503, 0.4171, 0.3717]}, {"w": "houses,", "b": [0.4218, 0.3503, 0.4835, 0.3717]}, {"w": "the", "b": [0.4882, 0.3503, 0.5146, 0.3717]}, {"w": "more", "b": [0.5193, 0.3503, 0.5636, 0.3717]}, {"w": "expensive", "b": [0.5683, 0.3503, 0.6499, 0.3717]}, {"w": "they", "b": [0.6546, 0.3503, 0.6905, 0.3717]}, {"w": "are.", "b": [0.6952, 0.3503, 0.7257, 0.3717]}]}, {"id": "b_2", "type": "paragraph", "text": "This round of exploration does not have to be absolutely thorough; the point is to start off on the right foot and quickly gain insights that will help you get a first rea‐ sonably good prototype. But this is an iterative process: once you get a prototype up and running, you can analyze its output to gain more insights and come back to this exploration step.", "words": [{"w": "This", "b": [0.1429, 0.3784, 0.1801, 0.3998]}, {"w": "round", "b": [0.1874, 0.3784, 0.2392, 0.3998]}, {"w": "of", "b": [0.2466, 0.3784, 0.2633, 0.3998]}, {"w": "exploration", "b": [0.2707, 0.3784, 0.3666, 0.3998]}, {"w": "does", "b": [0.374, 0.3784, 0.4121, 0.3998]}, {"w": "not", "b": [0.4194, 0.3784, 0.4478, 0.3998]}, {"w": "have", "b": [0.4551, 0.3784, 0.4935, 0.3998]}, {"w": "to", "b": [0.5008, 0.3784, 0.5178, 0.3998]}, {"w": "be", "b": [0.5252, 0.3784, 0.5446, 0.3998]}, {"w": "absolutely", "b": [0.5519, 0.3784, 0.6363, 0.3998]}, {"w": "thorough;", "b": [0.6436, 0.3784, 0.7268, 0.3998]}, {"w": "the", "b": [0.7341, 0.3784, 0.7605, 0.3998]}, {"w": "point", "b": [0.7678, 0.3784, 0.8123, 0.3998]}, {"w": "is", "b": [0.8196, 0.3784, 0.8328, 0.3998]}, {"w": "to", "b": [0.8402, 0.3784, 0.8571, 0.3998]}, {"w": "start", "b": [0.1429, 0.3974, 0.1801, 0.4188]}, {"w": "off", "b": [0.1864, 0.3974, 0.2094, 0.4188]}, {"w": "on", "b": [0.2157, 0.3974, 0.2377, 0.4188]}, {"w": "the", "b": [0.244, 0.3974, 0.2703, 0.4188]}, {"w": "right", "b": [0.2767, 0.3974, 0.3168, 0.4188]}, {"w": "foot", "b": [0.3231, 0.3974, 0.3569, 0.4188]}, {"w": "and", "b": [0.3632, 0.3974, 0.3947, 0.4188]}, {"w": "quickly", "b": [0.4011, 0.3974, 0.4623, 0.4188]}, {"w": "gain", "b": [0.4686, 0.3974, 0.5045, 0.4188]}, {"w": "insights", "b": [0.5108, 0.3974, 0.5755, 0.4188]}, {"w": "that", "b": [0.5818, 0.3974, 0.6144, 0.4188]}, {"w": "will", "b": [0.6207, 0.3974, 0.6511, 0.4188]}, {"w": "help", "b": [0.6574, 0.3974, 0.6936, 0.4188]}, {"w": "you", "b": [0.6999, 0.3974, 0.7312, 0.4188]}, {"w": "get", "b": [0.7375, 0.3974, 0.7624, 0.4188]}, {"w": "a", "b": [0.7687, 0.3974, 0.7779, 0.4188]}, {"w": "first", "b": [0.7842, 0.3974, 0.8177, 0.4188]}, {"w": "rea‐", "b": [0.824, 0.3974, 0.8571, 0.4188]}, {"w": "sonably", "b": [0.1429, 0.4165, 0.2071, 0.4379]}, {"w": "good", "b": [0.2131, 0.4165, 0.2551, 0.4379]}, {"w": "prototype.", "b": [0.261, 0.4165, 0.3477, 0.4379]}, {"w": "But", "b": [0.3537, 0.4165, 0.3833, 0.4379]}, {"w": "this", "b": [0.3893, 0.4165, 0.42, 0.4379]}, {"w": "is", "b": [0.426, 0.4165, 0.4392, 0.4379]}, {"w": "an", "b": [0.4452, 0.4165, 0.4657, 0.4379]}, {"w": "iterative", "b": [0.4717, 0.4165, 0.5394, 0.4379]}, {"w": "process:", "b": [0.5454, 0.4165, 0.6124, 0.4379]}, {"w": "once", "b": [0.6183, 0.4165, 0.658, 0.4379]}, {"w": "you", "b": [0.664, 0.4165, 0.6952, 0.4379]}, {"w": "get", "b": [0.7012, 0.4165, 0.7262, 0.4379]}, {"w": "a", "b": [0.7321, 0.4165, 0.7413, 0.4379]}, {"w": "prototype", "b": [0.7473, 0.4165, 0.8292, 0.4379]}, {"w": "up", "b": [0.8352, 0.4165, 0.8571, 0.4379]}, {"w": "and", "b": [0.1429, 0.4355, 0.1744, 0.4569]}, {"w": "running,", "b": [0.1801, 0.4355, 0.2532, 0.4569]}, {"w": "you", "b": [0.2589, 0.4355, 0.2902, 0.4569]}, {"w": "can", "b": [0.2959, 0.4355, 0.3252, 0.4569]}, {"w": "analyze", "b": [0.3309, 0.4355, 0.3931, 0.4569]}, {"w": "its", "b": [0.3988, 0.4355, 0.4184, 0.4569]}, {"w": "output", "b": [0.4241, 0.4355, 0.4804, 0.4569]}, {"w": "to", "b": [0.4862, 0.4355, 0.5031, 0.4569]}, {"w": "gain", "b": [0.5089, 0.4355, 0.5447, 0.4569]}, {"w": "more", "b": [0.5504, 0.4355, 0.5947, 0.4569]}, {"w": "insights", "b": [0.6004, 0.4355, 0.6651, 0.4569]}, {"w": "and", "b": [0.6708, 0.4355, 0.7024, 0.4569]}, {"w": "come", "b": [0.7081, 0.4355, 0.7534, 0.4569]}, {"w": "back", "b": [0.7592, 0.4355, 0.798, 0.4569]}, {"w": "to", "b": [0.8037, 0.4355, 0.8207, 0.4569]}, {"w": "this", "b": [0.8264, 0.4355, 0.8572, 0.4569]}, {"w": "exploration", "b": [0.1429, 0.4546, 0.2388, 0.476]}, {"w": "step.", "b": [0.2435, 0.4546, 0.2814, 0.476]}]}, {"id": "b_3", "type": "paragraph", "text": "Prepare the Data for Machine Learning Algorithms", "words": [{"w": "Prepare", "b": [0.1428, 0.489, 0.2399, 0.5232]}, {"w": "the", "b": [0.2459, 0.489, 0.2877, 0.5232]}, {"w": "Data", "b": [0.2936, 0.489, 0.3517, 0.5232]}, {"w": "for", "b": [0.3576, 0.489, 0.393, 0.5232]}, {"w": "Machine", "b": [0.399, 0.489, 0.5039, 0.5232]}, {"w": "Learning", "b": [0.5099, 0.489, 0.6197, 0.5232]}, {"w": "Algorithms", "b": [0.6256, 0.489, 0.7627, 0.5232]}]}, {"id": "b_4", "type": "paragraph", "text": "It’s time to prepare the data for your Machine Learning algorithms. Instead of just doing this manually, you should write functions to do that, for several good reasons:", "words": [{"w": "It’s", "b": [0.1428, 0.5301, 0.1652, 0.5516]}, {"w": "time", "b": [0.1726, 0.5301, 0.2105, 0.5516]}, {"w": "to", "b": [0.2179, 0.5301, 0.2348, 0.5516]}, {"w": "prepare", "b": [0.2422, 0.5301, 0.3064, 0.5516]}, {"w": "the", "b": [0.3137, 0.5301, 0.3401, 0.5516]}, {"w": "data", "b": [0.3474, 0.5301, 0.3827, 0.5516]}, {"w": "for", "b": [0.3901, 0.5301, 0.4146, 0.5516]}, {"w": "your", "b": [0.422, 0.5301, 0.461, 0.5516]}, {"w": "Machine", "b": [0.4683, 0.5301, 0.5415, 0.5516]}, {"w": "Learning", "b": [0.5488, 0.5301, 0.6239, 0.5516]}, {"w": "algorithms.", "b": [0.6313, 0.5301, 0.7263, 0.5516]}, {"w": "Instead", "b": [0.7337, 0.5301, 0.7952, 0.5516]}, {"w": "of", "b": [0.8026, 0.5301, 0.8194, 0.5516]}, {"w": "just", "b": [0.8267, 0.5301, 0.8571, 0.5516]}, {"w": "doing", "b": [0.1429, 0.5492, 0.1912, 0.5706]}, {"w": "this", "b": [0.1959, 0.5492, 0.2267, 0.5706]}, {"w": "manually,", "b": [0.2314, 0.5492, 0.3121, 0.5706]}, {"w": "you", "b": [0.3169, 0.5492, 0.3481, 0.5706]}, {"w": "should", "b": [0.3528, 0.5492, 0.4096, 0.5706]}, {"w": "write", "b": [0.4143, 0.5492, 0.4571, 0.5706]}, {"w": "functions", "b": [0.4618, 0.5492, 0.5409, 0.5706]}, {"w": "to", "b": [0.5456, 0.5492, 0.5626, 0.5706]}, {"w": "do", "b": [0.5673, 0.5492, 0.5889, 0.5706]}, {"w": "that,", "b": [0.5937, 0.5492, 0.631, 0.5706]}, {"w": "for", "b": [0.6357, 0.5492, 0.6602, 0.5706]}, {"w": "several", "b": [0.665, 0.5492, 0.7221, 0.5706]}, {"w": "good", "b": [0.7268, 0.5492, 0.7688, 0.5706]}, {"w": "reasons:", "b": [0.7736, 0.5492, 0.8414, 0.5706]}]}, {"id": "b_5", "type": "paragraph", "text": "• This will allow you to reproduce these transformations easily on any dataset (e.g., the next time you get a fresh dataset).", "words": [{"w": "•", "b": [0.16, 0.5834, 0.1682, 0.6048]}, {"w": "This", "b": [0.1786, 0.5834, 0.2158, 0.6048]}, {"w": "will", "b": [0.2207, 0.5834, 0.2511, 0.6048]}, {"w": "allow", "b": [0.2561, 0.5834, 0.3007, 0.6048]}, {"w": "you", "b": [0.3057, 0.5834, 0.3369, 0.6048]}, {"w": "to", "b": [0.3419, 0.5834, 0.3589, 0.6048]}, {"w": "reproduce", "b": [0.3638, 0.5834, 0.4494, 0.6048]}, {"w": "these", "b": [0.4544, 0.5834, 0.4972, 0.6048]}, {"w": "transformations", "b": [0.5022, 0.5834, 0.6364, 0.6048]}, {"w": "easily", "b": [0.6414, 0.5834, 0.6874, 0.6048]}, {"w": "on", "b": [0.6924, 0.5834, 0.7144, 0.6048]}, {"w": "any", "b": [0.7194, 0.5834, 0.749, 0.6048]}, {"w": "dataset", "b": [0.754, 0.5834, 0.8121, 0.6048]}, {"w": "(e.g.,", "b": [0.8171, 0.5834, 0.8571, 0.6048]}, {"w": "the", "b": [0.1786, 0.6024, 0.2049, 0.6238]}, {"w": "next", "b": [0.2096, 0.6024, 0.2461, 0.6238]}, {"w": "time", "b": [0.2508, 0.6024, 0.2887, 0.6238]}, {"w": "you", "b": [0.2934, 0.6024, 0.3246, 0.6238]}, {"w": "get", "b": [0.3294, 0.6024, 0.3543, 0.6238]}, {"w": "a", "b": [0.3591, 0.6024, 0.3682, 0.6238]}, {"w": "fresh", "b": [0.3729, 0.6024, 0.4144, 0.6238]}, {"w": "dataset).", "b": [0.4192, 0.6024, 0.4892, 0.6238]}]}, {"id": "b_6", "type": "paragraph", "text": "• You will gradually build a library of transformation functions that you can reuse in future projects.", "words": [{"w": "•", "b": [0.16, 0.6275, 0.1682, 0.6489]}, {"w": "You", "b": [0.1786, 0.6275, 0.2109, 0.6489]}, {"w": "will", "b": [0.2167, 0.6275, 0.2471, 0.6489]}, {"w": "gradually", "b": [0.2529, 0.6275, 0.3308, 0.6489]}, {"w": "build", "b": [0.3366, 0.6275, 0.3801, 0.6489]}, {"w": "a", "b": [0.3859, 0.6275, 0.395, 0.6489]}, {"w": "library", "b": [0.4008, 0.6275, 0.457, 0.6489]}, {"w": "of", "b": [0.4628, 0.6275, 0.4795, 0.6489]}, {"w": "transformation", "b": [0.4853, 0.6275, 0.6119, 0.6489]}, {"w": "functions", "b": [0.6177, 0.6275, 0.6967, 0.6489]}, {"w": "that", "b": [0.7025, 0.6275, 0.7351, 0.6489]}, {"w": "you", "b": [0.7408, 0.6275, 0.7721, 0.6489]}, {"w": "can", "b": [0.7779, 0.6275, 0.8072, 0.6489]}, {"w": "reuse", "b": [0.813, 0.6275, 0.8571, 0.6489]}, {"w": "in", "b": [0.1786, 0.6465, 0.1956, 0.668]}, {"w": "future", "b": [0.2003, 0.6465, 0.2515, 0.668]}, {"w": "projects.", "b": [0.2562, 0.6465, 0.3273, 0.668]}]}, {"id": "b_7", "type": "paragraph", "text": "• You can use these functions in your live system to transform the new data before feeding it to your algorithms.", "words": [{"w": "•", "b": [0.16, 0.6716, 0.1682, 0.6931]}, {"w": "You", "b": [0.1786, 0.6716, 0.2109, 0.6931]}, {"w": "can", "b": [0.2163, 0.6716, 0.2456, 0.6931]}, {"w": "use", "b": [0.251, 0.6716, 0.2786, 0.6931]}, {"w": "these", "b": [0.284, 0.6716, 0.3268, 0.6931]}, {"w": "functions", "b": [0.3322, 0.6716, 0.4112, 0.6931]}, {"w": "in", "b": [0.4166, 0.6716, 0.4336, 0.6931]}, {"w": "your", "b": [0.4389, 0.6716, 0.4779, 0.6931]}, {"w": "live", "b": [0.4833, 0.6716, 0.5126, 0.6931]}, {"w": "system", "b": [0.518, 0.6716, 0.5751, 0.6931]}, {"w": "to", "b": [0.5805, 0.6716, 0.5975, 0.6931]}, {"w": "transform", "b": [0.6029, 0.6716, 0.6867, 0.6931]}, {"w": "the", "b": [0.6921, 0.6716, 0.7184, 0.6931]}, {"w": "new", "b": [0.7238, 0.6716, 0.7583, 0.6931]}, {"w": "data", "b": [0.7637, 0.6716, 0.799, 0.6931]}, {"w": "before", "b": [0.8043, 0.6716, 0.8571, 0.6931]}, {"w": "feeding", "b": [0.1786, 0.6907, 0.2402, 0.7121]}, {"w": "it", "b": [0.2449, 0.6907, 0.2568, 0.7121]}, {"w": "to", "b": [0.2616, 0.6907, 0.2786, 0.7121]}, {"w": "your", "b": [0.2833, 0.6907, 0.3223, 0.7121]}, {"w": "algorithms.", "b": [0.327, 0.6907, 0.422, 0.7121]}]}, {"id": "b_8", "type": "paragraph", "text": "• This will make it possible for you to easily try various transformations and see which combination of transformations works best.", "words": [{"w": "•", "b": [0.16, 0.7158, 0.1682, 0.7372]}, {"w": "This", "b": [0.1786, 0.7158, 0.2158, 0.7372]}, {"w": "will", "b": [0.2228, 0.7158, 0.2532, 0.7372]}, {"w": "make", "b": [0.2602, 0.7158, 0.3056, 0.7372]}, {"w": "it", "b": [0.3125, 0.7158, 0.3245, 0.7372]}, {"w": "possible", "b": [0.3315, 0.7158, 0.3986, 0.7372]}, {"w": "for", "b": [0.4056, 0.7158, 0.4301, 0.7372]}, {"w": "you", "b": [0.4371, 0.7158, 0.4684, 0.7372]}, {"w": "to", "b": [0.4753, 0.7158, 0.4923, 0.7372]}, {"w": "easily", "b": [0.4993, 0.7158, 0.5454, 0.7372]}, {"w": "try", "b": [0.5524, 0.7158, 0.5766, 0.7372]}, {"w": "various", "b": [0.5836, 0.7158, 0.6451, 0.7372]}, {"w": "transformations", "b": [0.652, 0.7158, 0.7863, 0.7372]}, {"w": "and", "b": [0.7932, 0.7158, 0.8248, 0.7372]}, {"w": "see", "b": [0.8318, 0.7158, 0.8571, 0.7372]}, {"w": "which", "b": [0.1786, 0.7348, 0.2295, 0.7562]}, {"w": "combination", "b": [0.2342, 0.7348, 0.341, 0.7562]}, {"w": "of", "b": [0.3457, 0.7348, 0.3625, 0.7562]}, {"w": "transformations", "b": [0.3672, 0.7348, 0.5014, 0.7562]}, {"w": "works", "b": [0.5062, 0.7348, 0.5568, 0.7562]}, {"w": "best.", "b": [0.5615, 0.7348, 0.5997, 0.7562]}]}, {"id": "b_9", "type": "paragraph", "text": "But first let’s revert to a clean training set (by copying strat_train_set once again), and let’s separate the predictors and the labels since we don’t necessarily want to apply the same transformations to the predictors and the target values (note that drop() creates a copy of the data and does not affect strat_train_set):", "words": [{"w": "But", "b": [0.1429, 0.7699, 0.1725, 0.7913]}, {"w": "first", "b": [0.1782, 0.7699, 0.2116, 0.7913]}, {"w": "let’s", "b": [0.2173, 0.7699, 0.2475, 0.7913]}, {"w": "revert", "b": [0.2531, 0.7699, 0.3023, 0.7913]}, {"w": "to", "b": [0.3079, 0.7699, 0.3249, 0.7913]}, {"w": "a", "b": [0.3306, 0.7699, 0.3397, 0.7913]}, {"w": "clean", "b": [0.3453, 0.7699, 0.3888, 0.7913]}, {"w": "training", "b": [0.3945, 0.7699, 0.4614, 0.7913]}, {"w": "set", "b": [0.467, 0.7699, 0.4899, 0.7913]}, {"w": "(by", "b": [0.4955, 0.7699, 0.5229, 0.7913]}, {"w": "copying", "b": [0.5285, 0.7699, 0.5951, 0.7913]}, {"w": "strat_train_set", "b": [0.6008, 0.7731, 0.7492, 0.7882]}, {"w": "once", "b": [0.7549, 0.7699, 0.7945, 0.7913]}, {"w": "again),", "b": [0.8002, 0.7699, 0.8572, 0.7913]}, {"w": "and", "b": [0.1429, 0.7889, 0.1744, 0.8104]}, {"w": "let’s", "b": [0.1792, 0.7889, 0.2094, 0.8104]}, {"w": "separate", "b": [0.2143, 0.7889, 0.2825, 0.8104]}, {"w": "the", "b": [0.2873, 0.7889, 0.3136, 0.8104]}, {"w": "predictors", "b": [0.3185, 0.7889, 0.4037, 0.8104]}, {"w": "and", "b": [0.4085, 0.7889, 0.4401, 0.8104]}, {"w": "the", "b": [0.4449, 0.7889, 0.4712, 0.8104]}, {"w": "labels", "b": [0.476, 0.7889, 0.5228, 0.8104]}, {"w": "since", "b": [0.5276, 0.7889, 0.5699, 0.8104]}, {"w": "we", "b": [0.5747, 0.7889, 0.5978, 0.8104]}, {"w": "don’t", "b": [0.6026, 0.7889, 0.6442, 0.8104]}, {"w": "necessarily", "b": [0.649, 0.7889, 0.7395, 0.8104]}, {"w": "want", "b": [0.7444, 0.7889, 0.7851, 0.8104]}, {"w": "to", "b": [0.7899, 0.7889, 0.8069, 0.8104]}, {"w": "apply", "b": [0.8117, 0.7889, 0.8571, 0.8104]}, {"w": "the", "b": [0.1429, 0.8089, 0.1692, 0.8303]}, {"w": "same", "b": [0.176, 0.8089, 0.2187, 0.8303]}, {"w": "transformations", "b": [0.2255, 0.8089, 0.3597, 0.8303]}, {"w": "to", "b": [0.3665, 0.8089, 0.3835, 0.8303]}, {"w": "the", "b": [0.3903, 0.8089, 0.4166, 0.8303]}, {"w": "predictors", "b": [0.4234, 0.8089, 0.5087, 0.8303]}, {"w": "and", "b": [0.5155, 0.8089, 0.547, 0.8303]}, {"w": "the", "b": [0.5538, 0.8089, 0.5801, 0.8303]}, {"w": "target", "b": [0.5869, 0.8089, 0.6351, 0.8303]}, {"w": "values", "b": [0.6419, 0.8089, 0.6935, 0.8303]}, {"w": "(note", "b": [0.7003, 0.8089, 0.7448, 0.8303]}, {"w": "that", "b": [0.7516, 0.8089, 0.7842, 0.8303]}, {"w": "drop()", "b": [0.791, 0.8121, 0.8503, 0.8271]}, {"w": "creates", "b": [0.1428, 0.8288, 0.1998, 0.8502]}, {"w": "a", "b": [0.2046, 0.8288, 0.2137, 0.8502]}, {"w": "copy", "b": [0.2185, 0.8288, 0.2584, 0.8502]}, {"w": "of", "b": [0.2631, 0.8288, 0.2799, 0.8502]}, {"w": "the", "b": [0.2846, 0.8288, 0.311, 0.8502]}, {"w": "data", "b": [0.3157, 0.8288, 0.3509, 0.8502]}, {"w": "and", "b": [0.3557, 0.8288, 0.3872, 0.8502]}, {"w": "does", "b": [0.3919, 0.8288, 0.4301, 0.8502]}, {"w": "not", "b": [0.4348, 0.8288, 0.4632, 0.8502]}, {"w": "affect", "b": [0.4679, 0.8288, 0.5134, 0.8502]}, {"w": "strat_train_set):", "b": [0.5181, 0.8288, 0.6785, 0.8502]}]}, {"id": "b_10", "type": "paragraph", "text": "housing = strat_train_set.drop(\"median_house_value\", axis=1) housing_labels = strat_train_set[\"median_house_value\"].copy()", "words": [{"w": "housing", "b": [0.1766, 0.8608, 0.2356, 0.8737]}, {"w": "=", "b": [0.2441, 0.8608, 0.2525, 0.8737]}, {"w": "strat_train_set.drop(\"median_house_value\",", "b": [0.2609, 0.8608, 0.6151, 0.8737]}, {"w": "axis=1)", "b": [0.6235, 0.8608, 0.6825, 0.8737]}, {"w": "housing_labels", "b": [0.1766, 0.8762, 0.2946, 0.8891]}, {"w": "=", "b": [0.3031, 0.8762, 0.3115, 0.8891]}, {"w": "strat_train_set[\"median_house_value\"].copy()", "b": [0.3199, 0.8762, 0.691, 0.8891]}]}, {"id": "b_11", "type": "equation", "text": "66 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "66", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.478, 0.9388]}]}]}, {"page": 93, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Data Cleaning", "words": [{"w": "Data", "b": [0.1429, 0.0763, 0.1913, 0.1049]}, {"w": "Cleaning", "b": [0.1962, 0.0763, 0.2864, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "Most Machine Learning algorithms cannot work with missing features, so let’s create a few functions to take care of them. You noticed earlier that the total_bedrooms attribute has some missing values, so let’s fix this. You have three options:", "words": [{"w": "Most", "b": [0.1429, 0.1108, 0.1855, 0.1322]}, {"w": "Machine", "b": [0.1912, 0.1108, 0.2643, 0.1322]}, {"w": "Learning", "b": [0.27, 0.1108, 0.3451, 0.1322]}, {"w": "algorithms", "b": [0.3507, 0.1108, 0.441, 0.1322]}, {"w": "cannot", "b": [0.4467, 0.1108, 0.5044, 0.1322]}, {"w": "work", "b": [0.5101, 0.1108, 0.5531, 0.1322]}, {"w": "with", "b": [0.5587, 0.1108, 0.5961, 0.1322]}, {"w": "missing", "b": [0.6018, 0.1108, 0.6664, 0.1322]}, {"w": "features,", "b": [0.6721, 0.1108, 0.7423, 0.1322]}, {"w": "so", "b": [0.7479, 0.1108, 0.7662, 0.1322]}, {"w": "let’s", "b": [0.7719, 0.1108, 0.8021, 0.1322]}, {"w": "create", "b": [0.8078, 0.1108, 0.8571, 0.1322]}, {"w": "a", "b": [0.1429, 0.1307, 0.152, 0.1521]}, {"w": "few", "b": [0.1597, 0.1307, 0.189, 0.1521]}, {"w": "functions", "b": [0.1967, 0.1307, 0.2757, 0.1521]}, {"w": "to", "b": [0.2834, 0.1307, 0.3004, 0.1521]}, {"w": "take", "b": [0.3081, 0.1307, 0.3428, 0.1521]}, {"w": "care", "b": [0.3505, 0.1307, 0.385, 0.1521]}, {"w": "of", "b": [0.3927, 0.1307, 0.4095, 0.1521]}, {"w": "them.", "b": [0.4172, 0.1307, 0.4654, 0.1521]}, {"w": "You", "b": [0.4731, 0.1307, 0.5054, 0.1521]}, {"w": "noticed", "b": [0.5131, 0.1307, 0.5757, 0.1521]}, {"w": "earlier", "b": [0.5834, 0.1307, 0.6366, 0.1521]}, {"w": "that", "b": [0.6443, 0.1307, 0.6769, 0.1521]}, {"w": "the", "b": [0.6846, 0.1307, 0.7109, 0.1521]}, {"w": "total_bedrooms", "b": [0.7186, 0.1339, 0.8571, 0.149]}, {"w": "attribute", "b": [0.1429, 0.1498, 0.2145, 0.1712]}, {"w": "has", "b": [0.2192, 0.1498, 0.2471, 0.1712]}, {"w": "some", "b": [0.2519, 0.1498, 0.296, 0.1712]}, {"w": "missing", "b": [0.3008, 0.1498, 0.3654, 0.1712]}, {"w": "values,", "b": [0.3702, 0.1498, 0.4265, 0.1712]}, {"w": "so", "b": [0.4313, 0.1498, 0.4495, 0.1712]}, {"w": "let’s", "b": [0.4543, 0.1498, 0.4845, 0.1712]}, {"w": "fix", "b": [0.4892, 0.1498, 0.5108, 0.1712]}, {"w": "this.", "b": [0.5155, 0.1498, 0.551, 0.1712]}, {"w": "You", "b": [0.5557, 0.1498, 0.5881, 0.1712]}, {"w": "have", "b": [0.5928, 0.1498, 0.6312, 0.1712]}, {"w": "three", "b": [0.6359, 0.1498, 0.6789, 0.1712]}, {"w": "options:", "b": [0.6836, 0.1498, 0.7515, 0.1712]}]}, {"id": "b_2", "type": "paragraph", "text": "• Get rid of the corresponding districts.", "words": [{"w": "•", "b": [0.16, 0.1839, 0.1681, 0.2053]}, {"w": "Get", "b": [0.1786, 0.1839, 0.2087, 0.2053]}, {"w": "rid", "b": [0.2134, 0.1839, 0.2377, 0.2053]}, {"w": "of", "b": [0.2424, 0.1839, 0.2592, 0.2053]}, {"w": "the", "b": [0.264, 0.1839, 0.2903, 0.2053]}, {"w": "corresponding", "b": [0.295, 0.1839, 0.4171, 0.2053]}, {"w": "districts.", "b": [0.4218, 0.1839, 0.4933, 0.2053]}]}, {"id": "b_3", "type": "paragraph", "text": "• Get rid of the whole attribute.", "words": [{"w": "•", "b": [0.16, 0.209, 0.1682, 0.2304]}, {"w": "Get", "b": [0.1786, 0.209, 0.2087, 0.2304]}, {"w": "rid", "b": [0.2134, 0.209, 0.2377, 0.2304]}, {"w": "of", "b": [0.2424, 0.209, 0.2592, 0.2304]}, {"w": "the", "b": [0.264, 0.209, 0.2903, 0.2304]}, {"w": "whole", "b": [0.295, 0.209, 0.3452, 0.2304]}, {"w": "attribute.", "b": [0.3499, 0.209, 0.4263, 0.2304]}]}, {"id": "b_4", "type": "paragraph", "text": "• Set the values to some value (zero, the mean, the median, etc.).", "words": [{"w": "•", "b": [0.16, 0.2341, 0.1682, 0.2555]}, {"w": "Set", "b": [0.1786, 0.2341, 0.2036, 0.2555]}, {"w": "the", "b": [0.2084, 0.2341, 0.2347, 0.2555]}, {"w": "values", "b": [0.2394, 0.2341, 0.2911, 0.2555]}, {"w": "to", "b": [0.2958, 0.2341, 0.3128, 0.2555]}, {"w": "some", "b": [0.3175, 0.2341, 0.3617, 0.2555]}, {"w": "value", "b": [0.3664, 0.2341, 0.4104, 0.2555]}, {"w": "(zero,", "b": [0.4151, 0.2341, 0.4624, 0.2555]}, {"w": "the", "b": [0.4672, 0.2341, 0.4935, 0.2555]}, {"w": "mean,", "b": [0.4982, 0.2341, 0.5494, 0.2555]}, {"w": "the", "b": [0.5542, 0.2341, 0.5805, 0.2555]}, {"w": "median,", "b": [0.5852, 0.2341, 0.653, 0.2555]}, {"w": "etc.).", "b": [0.6578, 0.2341, 0.6985, 0.2555]}]}, {"id": "b_5", "type": "paragraph", "text": "You can accomplish these easily using DataFrame’s dropna(), drop(), and fillna() methods:", "words": [{"w": "You", "b": [0.1429, 0.2692, 0.1752, 0.2906]}, {"w": "can", "b": [0.1815, 0.2692, 0.2108, 0.2906]}, {"w": "accomplish", "b": [0.217, 0.2692, 0.3117, 0.2906]}, {"w": "these", "b": [0.3179, 0.2692, 0.3607, 0.2906]}, {"w": "easily", "b": [0.367, 0.2692, 0.413, 0.2906]}, {"w": "using", "b": [0.4193, 0.2692, 0.4647, 0.2906]}, {"w": "DataFrame’s", "b": [0.4709, 0.2692, 0.5734, 0.2906]}, {"w": "dropna(),", "b": [0.5797, 0.2692, 0.6636, 0.2906]}, {"w": "drop(),", "b": [0.6698, 0.2692, 0.734, 0.2906]}, {"w": "and", "b": [0.7402, 0.2692, 0.7717, 0.2906]}, {"w": "fillna()", "b": [0.778, 0.2724, 0.8571, 0.2874]}, {"w": "methods:", "b": [0.1429, 0.2882, 0.2203, 0.3096]}]}, {"id": "b_6", "type": "paragraph", "text": "housing.dropna(subset=[\"total_bedrooms\"]) # option 1 housing.drop(\"total_bedrooms\", axis=1) # option 2 median = housing[\"total_bedrooms\"].median() # option 3 housing[\"total_bedrooms\"].fillna(median, inplace=True)", "words": [{"w": "housing.dropna(subset=[\"total_bedrooms\"])", "b": [0.1766, 0.3202, 0.5223, 0.3331]}, {"w": "#", "b": [0.5561, 0.3202, 0.5645, 0.3331]}, {"w": "option", "b": [0.5729, 0.3202, 0.6235, 0.3331]}, {"w": "1", "b": [0.6319, 0.3202, 0.6404, 0.3331]}, {"w": "housing.drop(\"total_bedrooms\",", "b": [0.1766, 0.3356, 0.4296, 0.3485]}, {"w": "axis=1)", "b": [0.438, 0.3356, 0.497, 0.3485]}, {"w": "#", "b": [0.5561, 0.3356, 0.5645, 0.3485]}, {"w": "option", "b": [0.5729, 0.3356, 0.6235, 0.3485]}, {"w": "2", "b": [0.6319, 0.3356, 0.6404, 0.3485]}, {"w": "median", "b": [0.1766, 0.351, 0.2272, 0.3639]}, {"w": "=", "b": [0.2356, 0.351, 0.244, 0.3639]}, {"w": "housing[\"total_bedrooms\"].median()", "b": [0.2525, 0.351, 0.5392, 0.3639]}, {"w": "#", "b": [0.5561, 0.351, 0.5645, 0.3639]}, {"w": "option", "b": [0.5729, 0.351, 0.6235, 0.3639]}, {"w": "3", "b": [0.6319, 0.351, 0.6404, 0.3639]}, {"w": "housing[\"total_bedrooms\"].fillna(median,", "b": [0.1766, 0.3665, 0.5139, 0.3793]}, {"w": "inplace=True)", "b": [0.5223, 0.3665, 0.6319, 0.3793]}]}, {"id": "b_7", "type": "paragraph", "text": "If you choose option 3, you should compute the median value on the training set, and use it to fill the missing values in the training set, but also don’t forget to save the median value that you have computed. You will need it later to replace missing values in the test set when you want to evaluate your system, and also once the system goes live to replace missing values in new data.", "words": [{"w": "If", "b": [0.1429, 0.3871, 0.1561, 0.4085]}, {"w": "you", "b": [0.161, 0.3871, 0.1922, 0.4085]}, {"w": "choose", "b": [0.1971, 0.3871, 0.2548, 0.4085]}, {"w": "option", "b": [0.2596, 0.3871, 0.3151, 0.4085]}, {"w": "3,", "b": [0.32, 0.3871, 0.3347, 0.4085]}, {"w": "you", "b": [0.3396, 0.3871, 0.3708, 0.4085]}, {"w": "should", "b": [0.3757, 0.3871, 0.4324, 0.4085]}, {"w": "compute", "b": [0.4373, 0.3871, 0.5105, 0.4085]}, {"w": "the", "b": [0.5154, 0.3871, 0.5417, 0.4085]}, {"w": "median", "b": [0.5466, 0.3871, 0.6096, 0.4085]}, {"w": "value", "b": [0.6145, 0.3871, 0.6585, 0.4085]}, {"w": "on", "b": [0.6633, 0.3871, 0.6853, 0.4085]}, {"w": "the", "b": [0.6902, 0.3871, 0.7165, 0.4085]}, {"w": "training", "b": [0.7214, 0.3871, 0.7883, 0.4085]}, {"w": "set,", "b": [0.7932, 0.3871, 0.8208, 0.4085]}, {"w": "and", "b": [0.8256, 0.3871, 0.8571, 0.4085]}, {"w": "use", "b": [0.1429, 0.4061, 0.1704, 0.4276]}, {"w": "it", "b": [0.1778, 0.4061, 0.1897, 0.4276]}, {"w": "to", "b": [0.1971, 0.4061, 0.214, 0.4276]}, {"w": "fill", "b": [0.2214, 0.4061, 0.2437, 0.4276]}, {"w": "the", "b": [0.251, 0.4061, 0.2774, 0.4276]}, {"w": "missing", "b": [0.2847, 0.4061, 0.3494, 0.4276]}, {"w": "values", "b": [0.3568, 0.4061, 0.4084, 0.4276]}, {"w": "in", "b": [0.4157, 0.4061, 0.4327, 0.4276]}, {"w": "the", "b": [0.4401, 0.4061, 0.4664, 0.4276]}, {"w": "training", "b": [0.4738, 0.4061, 0.5407, 0.4276]}, {"w": "set,", "b": [0.5481, 0.4061, 0.5757, 0.4276]}, {"w": "but", "b": [0.583, 0.4061, 0.611, 0.4276]}, {"w": "also", "b": [0.6184, 0.4061, 0.6511, 0.4276]}, {"w": "don’t", "b": [0.6584, 0.4061, 0.7, 0.4276]}, {"w": "forget", "b": [0.7074, 0.4061, 0.7568, 0.4276]}, {"w": "to", "b": [0.7642, 0.4061, 0.7812, 0.4276]}, {"w": "save", "b": [0.7885, 0.4061, 0.8235, 0.4276]}, {"w": "the", "b": [0.8308, 0.4061, 0.8571, 0.4276]}, {"w": "median", "b": [0.1429, 0.4252, 0.2059, 0.4466]}, {"w": "value", "b": [0.211, 0.4252, 0.255, 0.4466]}, {"w": "that", "b": [0.2601, 0.4252, 0.2927, 0.4466]}, {"w": "you", "b": [0.2978, 0.4252, 0.329, 0.4466]}, {"w": "have", "b": [0.3341, 0.4252, 0.3725, 0.4466]}, {"w": "computed.", "b": [0.3776, 0.4252, 0.4666, 0.4466]}, {"w": "You", "b": [0.4717, 0.4252, 0.5041, 0.4466]}, {"w": "will", "b": [0.5092, 0.4252, 0.5396, 0.4466]}, {"w": "need", "b": [0.5447, 0.4252, 0.5848, 0.4466]}, {"w": "it", "b": [0.5899, 0.4252, 0.6018, 0.4466]}, {"w": "later", "b": [0.6069, 0.4252, 0.6439, 0.4466]}, {"w": "to", "b": [0.649, 0.4252, 0.666, 0.4466]}, {"w": "replace", "b": [0.6711, 0.4252, 0.7306, 0.4466]}, {"w": "missing", "b": [0.7357, 0.4252, 0.8004, 0.4466]}, {"w": "values", "b": [0.8055, 0.4252, 0.8571, 0.4466]}, {"w": "in", "b": [0.1429, 0.4442, 0.1598, 0.4657]}, {"w": "the", "b": [0.1655, 0.4442, 0.1919, 0.4657]}, {"w": "test", "b": [0.1976, 0.4442, 0.2268, 0.4657]}, {"w": "set", "b": [0.2325, 0.4442, 0.2553, 0.4657]}, {"w": "when", "b": [0.261, 0.4442, 0.3067, 0.4657]}, {"w": "you", "b": [0.3124, 0.4442, 0.3436, 0.4657]}, {"w": "want", "b": [0.3493, 0.4442, 0.3901, 0.4657]}, {"w": "to", "b": [0.3958, 0.4442, 0.4128, 0.4657]}, {"w": "evaluate", "b": [0.4185, 0.4442, 0.4864, 0.4657]}, {"w": "your", "b": [0.4921, 0.4442, 0.5311, 0.4657]}, {"w": "system,", "b": [0.5368, 0.4442, 0.5987, 0.4657]}, {"w": "and", "b": [0.6044, 0.4442, 0.6359, 0.4657]}, {"w": "also", "b": [0.6416, 0.4442, 0.6743, 0.4657]}, {"w": "once", "b": [0.68, 0.4442, 0.7197, 0.4657]}, {"w": "the", "b": [0.7254, 0.4442, 0.7517, 0.4657]}, {"w": "system", "b": [0.7574, 0.4442, 0.8146, 0.4657]}, {"w": "goes", "b": [0.8203, 0.4442, 0.8572, 0.4657]}, {"w": "live", "b": [0.1429, 0.4633, 0.1722, 0.4847]}, {"w": "to", "b": [0.1769, 0.4633, 0.1939, 0.4847]}, {"w": "replace", "b": [0.1987, 0.4633, 0.2582, 0.4847]}, {"w": "missing", "b": [0.263, 0.4633, 0.3276, 0.4847]}, {"w": "values", "b": [0.3324, 0.4633, 0.384, 0.4847]}, {"w": "in", "b": [0.3887, 0.4633, 0.4057, 0.4847]}, {"w": "new", "b": [0.4104, 0.4633, 0.4449, 0.4847]}, {"w": "data.", "b": [0.4497, 0.4633, 0.4897, 0.4847]}]}, {"id": "b_8", "type": "paragraph", "text": "Scikit-Learn provides a handy class to take care of missing values: SimpleImputer. Here is how to use it. First, you need to create a SimpleImputer instance, specifying that you want to replace each attribute’s missing values with the median of that attribute:", "words": [{"w": "Scikit-Learn", "b": [0.1429, 0.4923, 0.2452, 0.5137]}, {"w": "provides", "b": [0.2527, 0.4923, 0.3247, 0.5137]}, {"w": "a", "b": [0.3322, 0.4923, 0.3413, 0.5137]}, {"w": "handy", "b": [0.3488, 0.4923, 0.4011, 0.5137]}, {"w": "class", "b": [0.4086, 0.4923, 0.4471, 0.5137]}, {"w": "to", "b": [0.4546, 0.4923, 0.4716, 0.5137]}, {"w": "take", "b": [0.4791, 0.4923, 0.5138, 0.5137]}, {"w": "care", "b": [0.5213, 0.4923, 0.5559, 0.5137]}, {"w": "of", "b": [0.5634, 0.4923, 0.5802, 0.5137]}, {"w": "missing", "b": [0.5877, 0.4923, 0.6523, 0.5137]}, {"w": "values:", "b": [0.6599, 0.4923, 0.7162, 0.5137]}, {"w": "SimpleImputer.", "b": [0.7237, 0.4923, 0.8571, 0.5137]}, {"w": "Here", "b": [0.1429, 0.5122, 0.1837, 0.5337]}, {"w": "is", "b": [0.1899, 0.5122, 0.2031, 0.5337]}, {"w": "how", "b": [0.2092, 0.5122, 0.2452, 0.5337]}, {"w": "to", "b": [0.2514, 0.5122, 0.2683, 0.5337]}, {"w": "use", "b": [0.2745, 0.5122, 0.302, 0.5337]}, {"w": "it.", "b": [0.3082, 0.5122, 0.3249, 0.5337]}, {"w": "First,", "b": [0.331, 0.5122, 0.3741, 0.5337]}, {"w": "you", "b": [0.3802, 0.5122, 0.4114, 0.5337]}, {"w": "need", "b": [0.4176, 0.5122, 0.4577, 0.5337]}, {"w": "to", "b": [0.4638, 0.5122, 0.4808, 0.5337]}, {"w": "create", "b": [0.4869, 0.5122, 0.5363, 0.5337]}, {"w": "a", "b": [0.5424, 0.5122, 0.5515, 0.5337]}, {"w": "SimpleImputer", "b": [0.5577, 0.5154, 0.6863, 0.5305]}, {"w": "instance,", "b": [0.6924, 0.5122, 0.7664, 0.5337]}, {"w": "specifying", "b": [0.7725, 0.5122, 0.8571, 0.5337]}, {"w": "that", "b": [0.1429, 0.5313, 0.1755, 0.5527]}, {"w": "you", "b": [0.1848, 0.5313, 0.2161, 0.5527]}, {"w": "want", "b": [0.2255, 0.5313, 0.2663, 0.5527]}, {"w": "to", "b": [0.2756, 0.5313, 0.2926, 0.5527]}, {"w": "replace", "b": [0.302, 0.5313, 0.3616, 0.5527]}, {"w": "each", "b": [0.371, 0.5313, 0.4089, 0.5527]}, {"w": "attribute’s", "b": [0.4183, 0.5313, 0.499, 0.5527]}, {"w": "missing", "b": [0.5084, 0.5313, 0.5731, 0.5527]}, {"w": "values", "b": [0.5825, 0.5313, 0.6341, 0.5527]}, {"w": "with", "b": [0.6435, 0.5313, 0.6808, 0.5527]}, {"w": "the", "b": [0.6902, 0.5313, 0.7166, 0.5527]}, {"w": "median", "b": [0.726, 0.5313, 0.789, 0.5527]}, {"w": "of", "b": [0.7984, 0.5313, 0.8152, 0.5527]}, {"w": "that", "b": [0.8246, 0.5313, 0.8572, 0.5527]}, {"w": "attribute:", "b": [0.1429, 0.5503, 0.2192, 0.5718]}]}, {"id": "b_9", "type": "paragraph", "text": "from sklearn.impute import SimpleImputer", "words": [{"w": "from", "b": [0.1766, 0.5823, 0.2103, 0.5952]}, {"w": "sklearn.impute", "b": [0.2187, 0.5823, 0.3368, 0.5952]}, {"w": "import", "b": [0.3452, 0.5823, 0.3958, 0.5952]}, {"w": "SimpleImputer", "b": [0.4043, 0.5823, 0.5139, 0.5952]}]}, {"id": "b_10", "type": "equation", "text": "imputer = SimpleImputer(strategy=\"median\")", "words": [{"w": "imputer", "b": [0.1766, 0.6132, 0.2356, 0.626]}, {"w": "=", "b": [0.244, 0.6132, 0.2525, 0.626]}, {"w": "SimpleImputer(strategy=\"median\")", "b": [0.2609, 0.6132, 0.5308, 0.626]}]}, {"id": "b_11", "type": "paragraph", "text": "Since the median can only be computed on numerical attributes, we need to create a copy of the data without the text attribute ocean_proximity:", "words": [{"w": "Since", "b": [0.1429, 0.6338, 0.1874, 0.6552]}, {"w": "the", "b": [0.1932, 0.6338, 0.2195, 0.6552]}, {"w": "median", "b": [0.2253, 0.6338, 0.2883, 0.6552]}, {"w": "can", "b": [0.2941, 0.6338, 0.3235, 0.6552]}, {"w": "only", "b": [0.3293, 0.6338, 0.3662, 0.6552]}, {"w": "be", "b": [0.372, 0.6338, 0.3914, 0.6552]}, {"w": "computed", "b": [0.3972, 0.6338, 0.4815, 0.6552]}, {"w": "on", "b": [0.4873, 0.6338, 0.5093, 0.6552]}, {"w": "numerical", "b": [0.5151, 0.6338, 0.5996, 0.6552]}, {"w": "attributes,", "b": [0.6054, 0.6338, 0.6894, 0.6552]}, {"w": "we", "b": [0.6952, 0.6338, 0.7184, 0.6552]}, {"w": "need", "b": [0.7242, 0.6338, 0.7643, 0.6552]}, {"w": "to", "b": [0.7701, 0.6338, 0.787, 0.6552]}, {"w": "create", "b": [0.7928, 0.6338, 0.8422, 0.6552]}, {"w": "a", "b": [0.848, 0.6338, 0.8571, 0.6552]}, {"w": "copy", "b": [0.1429, 0.6537, 0.1828, 0.6751]}, {"w": "of", "b": [0.1875, 0.6537, 0.2043, 0.6751]}, {"w": "the", "b": [0.209, 0.6537, 0.2354, 0.6751]}, {"w": "data", "b": [0.2401, 0.6537, 0.2753, 0.6751]}, {"w": "without", "b": [0.2801, 0.6537, 0.3454, 0.6751]}, {"w": "the", "b": [0.3502, 0.6537, 0.3765, 0.6751]}, {"w": "text", "b": [0.3812, 0.6537, 0.4126, 0.6751]}, {"w": "attribute", "b": [0.4174, 0.6537, 0.489, 0.6751]}, {"w": "ocean_proximity:", "b": [0.4937, 0.6537, 0.6469, 0.6751]}]}, {"id": "b_12", "type": "equation", "text": "housing_num = housing.drop(\"ocean_proximity\", axis=1)", "words": [{"w": "housing_num", "b": [0.1766, 0.6857, 0.2694, 0.6986]}, {"w": "=", "b": [0.2778, 0.6857, 0.2862, 0.6986]}, {"w": "housing.drop(\"ocean_proximity\",", "b": [0.2946, 0.6857, 0.5561, 0.6986]}, {"w": "axis=1)", "b": [0.5645, 0.6857, 0.6235, 0.6986]}]}, {"id": "b_13", "type": "paragraph", "text": "Now you can fit the imputer instance to the training data using the fit() method:", "words": [{"w": "Now", "b": [0.1429, 0.7072, 0.1827, 0.7287]}, {"w": "you", "b": [0.1874, 0.7072, 0.2187, 0.7287]}, {"w": "can", "b": [0.2234, 0.7072, 0.2528, 0.7287]}, {"w": "fit", "b": [0.2575, 0.7072, 0.2756, 0.7287]}, {"w": "the", "b": [0.2803, 0.7072, 0.3067, 0.7287]}, {"w": "imputer", "b": [0.3114, 0.7104, 0.3807, 0.7255]}, {"w": "instance", "b": [0.3854, 0.7072, 0.4546, 0.7287]}, {"w": "to", "b": [0.4593, 0.7072, 0.4763, 0.7287]}, {"w": "the", "b": [0.481, 0.7072, 0.5074, 0.7287]}, {"w": "training", "b": [0.5121, 0.7072, 0.579, 0.7287]}, {"w": "data", "b": [0.5837, 0.7072, 0.619, 0.7287]}, {"w": "using", "b": [0.6237, 0.7072, 0.6692, 0.7287]}, {"w": "the", "b": [0.6739, 0.7072, 0.7002, 0.7287]}, {"w": "fit()", "b": [0.705, 0.7104, 0.7544, 0.7255]}, {"w": "method:", "b": [0.7592, 0.7072, 0.8289, 0.7287]}]}, {"id": "b_14", "type": "equation", "text": "imputer.fit(housing_num)", "words": [{"w": "imputer.fit(housing_num)", "b": [0.1766, 0.7392, 0.379, 0.7521]}]}, {"id": "b_15", "type": "paragraph", "text": "The imputer has simply computed the median of each attribute and stored the result in its statistics_ instance variable. Only the total_bedrooms attribute had missing values, but we cannot be sure that there won’t be any missing values in new data after the system goes live, so it is safer to apply the imputer to all the numerical attributes:", "words": [{"w": "The", "b": [0.1428, 0.7607, 0.1757, 0.7822]}, {"w": "imputer", "b": [0.1812, 0.7639, 0.2505, 0.779]}, {"w": "has", "b": [0.256, 0.7607, 0.2839, 0.7822]}, {"w": "simply", "b": [0.2894, 0.7607, 0.345, 0.7822]}, {"w": "computed", "b": [0.3505, 0.7607, 0.4348, 0.7822]}, {"w": "the", "b": [0.4403, 0.7607, 0.4667, 0.7822]}, {"w": "median", "b": [0.4722, 0.7607, 0.5352, 0.7822]}, {"w": "of", "b": [0.5407, 0.7607, 0.5575, 0.7822]}, {"w": "each", "b": [0.563, 0.7607, 0.601, 0.7822]}, {"w": "attribute", "b": [0.6065, 0.7607, 0.6781, 0.7822]}, {"w": "and", "b": [0.6836, 0.7607, 0.7152, 0.7822]}, {"w": "stored", "b": [0.7207, 0.7607, 0.7729, 0.7822]}, {"w": "the", "b": [0.7784, 0.7607, 0.8047, 0.7822]}, {"w": "result", "b": [0.8102, 0.7607, 0.8571, 0.7822]}, {"w": "in", "b": [0.1429, 0.7807, 0.1598, 0.8021]}, {"w": "its", "b": [0.1653, 0.7807, 0.1849, 0.8021]}, {"w": "statistics_", "b": [0.1904, 0.7839, 0.2992, 0.799]}, {"w": "instance", "b": [0.3047, 0.7807, 0.3739, 0.8021]}, {"w": "variable.", "b": [0.3794, 0.7807, 0.4501, 0.8021]}, {"w": "Only", "b": [0.4555, 0.7807, 0.4973, 0.8021]}, {"w": "the", "b": [0.5028, 0.7807, 0.5291, 0.8021]}, {"w": "total_bedrooms", "b": [0.5346, 0.7839, 0.6732, 0.799]}, {"w": "attribute", "b": [0.6786, 0.7807, 0.7503, 0.8021]}, {"w": "had", "b": [0.7557, 0.7807, 0.787, 0.8021]}, {"w": "missing", "b": [0.7925, 0.7807, 0.8571, 0.8021]}, {"w": "values,", "b": [0.1429, 0.7997, 0.1992, 0.8212]}, {"w": "but", "b": [0.2045, 0.7997, 0.2325, 0.8212]}, {"w": "we", "b": [0.2377, 0.7997, 0.2608, 0.8212]}, {"w": "cannot", "b": [0.266, 0.7997, 0.3238, 0.8212]}, {"w": "be", "b": [0.329, 0.7997, 0.3484, 0.8212]}, {"w": "sure", "b": [0.3536, 0.7997, 0.3889, 0.8212]}, {"w": "that", "b": [0.3942, 0.7997, 0.4267, 0.8212]}, {"w": "there", "b": [0.432, 0.7997, 0.4749, 0.8212]}, {"w": "won’t", "b": [0.4801, 0.7997, 0.525, 0.8212]}, {"w": "be", "b": [0.5302, 0.7997, 0.5497, 0.8212]}, {"w": "any", "b": [0.5549, 0.7997, 0.5845, 0.8212]}, {"w": "missing", "b": [0.5897, 0.7997, 0.6544, 0.8212]}, {"w": "values", "b": [0.6596, 0.7997, 0.7112, 0.8212]}, {"w": "in", "b": [0.7165, 0.7997, 0.7334, 0.8212]}, {"w": "new", "b": [0.7387, 0.7997, 0.7732, 0.8212]}, {"w": "data", "b": [0.7784, 0.7997, 0.8137, 0.8212]}, {"w": "after", "b": [0.8189, 0.7997, 0.8571, 0.8212]}, {"w": "the", "b": [0.1429, 0.8197, 0.1692, 0.8411]}, {"w": "system", "b": [0.1739, 0.8197, 0.231, 0.8411]}, {"w": "goes", "b": [0.2358, 0.8197, 0.2726, 0.8411]}, {"w": "live,", "b": [0.2774, 0.8197, 0.3115, 0.8411]}, {"w": "so", "b": [0.3162, 0.8197, 0.3345, 0.8411]}, {"w": "it", "b": [0.3392, 0.8197, 0.3511, 0.8411]}, {"w": "is", "b": [0.3559, 0.8197, 0.3691, 0.8411]}, {"w": "safer", "b": [0.3738, 0.8197, 0.4134, 0.8411]}, {"w": "to", "b": [0.4181, 0.8197, 0.4351, 0.8411]}, {"w": "apply", "b": [0.4398, 0.8197, 0.4852, 0.8411]}, {"w": "the", "b": [0.49, 0.8197, 0.5163, 0.8411]}, {"w": "imputer", "b": [0.521, 0.8229, 0.5903, 0.8379]}, {"w": "to", "b": [0.595, 0.8197, 0.612, 0.8411]}, {"w": "all", "b": [0.6167, 0.8197, 0.6364, 0.8411]}, {"w": "the", "b": [0.6411, 0.8197, 0.6675, 0.8411]}, {"w": "numerical", "b": [0.6722, 0.8197, 0.7567, 0.8411]}, {"w": "attributes:", "b": [0.7615, 0.8197, 0.8455, 0.8411]}]}, {"id": "b_16", "type": "paragraph", "text": ">>> imputer.statistics_ array([ -118.51 , 34.26 , 29. , 2119.5 , 433. , 1164. , 408. , 3.5409])", "words": [{"w": ">>>", "b": [0.1766, 0.8517, 0.2019, 0.8645]}, {"w": "imputer.statistics_", "b": [0.2103, 0.8517, 0.3705, 0.8645]}, {"w": "array([", "b": [0.1766, 0.8671, 0.2356, 0.8799]}, {"w": "-118.51", "b": [0.2441, 0.8671, 0.3031, 0.8799]}, {"w": ",", "b": [0.3115, 0.8671, 0.3199, 0.8799]}, {"w": "34.26", "b": [0.3284, 0.8671, 0.3705, 0.8799]}, {"w": ",", "b": [0.379, 0.8671, 0.3874, 0.8799]}, {"w": "29.", "b": [0.3958, 0.8671, 0.4211, 0.8799]}, {"w": ",", "b": [0.4296, 0.8671, 0.438, 0.8799]}, {"w": "2119.5", "b": [0.4464, 0.8671, 0.497, 0.8799]}, {"w": ",", "b": [0.5055, 0.8671, 0.5139, 0.8799]}, {"w": "433.", "b": [0.5223, 0.8671, 0.5561, 0.8799]}, {"w": ",", "b": [0.5645, 0.8671, 0.5729, 0.8799]}, {"w": "1164.", "b": [0.5814, 0.8671, 0.6235, 0.8799]}, {"w": ",", "b": [0.6319, 0.8671, 0.6404, 0.8799]}, {"w": "408.", "b": [0.6488, 0.8671, 0.6825, 0.8799]}, {"w": ",", "b": [0.691, 0.8671, 0.6994, 0.8799]}, {"w": "3.5409])", "b": [0.7078, 0.8671, 0.7753, 0.8799]}]}, {"id": "b_17", "type": "paragraph", "text": "Prepare the Data for Machine Learning Algorithms | 67", "words": [{"w": "Prepare", "b": [0.5082, 0.9225, 0.5544, 0.9388]}, {"w": "the", "b": [0.5572, 0.9225, 0.5771, 0.9388]}, {"w": "Data", "b": [0.58, 0.9225, 0.6076, 0.9388]}, {"w": "for", "b": [0.6104, 0.9225, 0.6273, 0.9388]}, {"w": "Machine", "b": [0.6301, 0.9225, 0.68, 0.9388]}, {"w": "Learning", "b": [0.6828, 0.9225, 0.7351, 0.9388]}, {"w": "Algorithms", "b": [0.7379, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "67", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 94, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "17 For more details on the design principles, see “API design for machine learning software: experiences from the scikit-learn project,” L. Buitinck, G. Louppe, M. Blondel, F. Pedregosa, A. Müller, et al. (2013).", "words": [{"w": "17", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "For", "b": [0.1587, 0.8598, 0.1808, 0.8761]}, {"w": "more", "b": [0.1844, 0.8598, 0.2181, 0.8761]}, {"w": "details", "b": [0.2217, 0.8598, 0.2628, 0.8761]}, {"w": "on", "b": [0.2664, 0.8598, 0.2832, 0.8761]}, {"w": "the", "b": [0.2868, 0.8598, 0.3068, 0.8761]}, {"w": "design", "b": [0.3104, 0.8598, 0.3517, 0.8761]}, {"w": "principles,", "b": [0.3553, 0.8598, 0.422, 0.8761]}, {"w": "see", "b": [0.4256, 0.8598, 0.4449, 0.8761]}, {"w": "“API", "b": [0.4485, 0.8598, 0.4778, 0.8761]}, {"w": "design", "b": [0.4814, 0.8598, 0.5227, 0.8761]}, {"w": "for", "b": [0.5263, 0.8598, 0.545, 0.8761]}, {"w": "machine", "b": [0.5486, 0.8598, 0.6034, 0.8761]}, {"w": "learning", "b": [0.607, 0.8598, 0.6597, 0.8761]}, {"w": "software:", "b": [0.6633, 0.8598, 0.7208, 0.8761]}, {"w": "experiences", "b": [0.7244, 0.8598, 0.7986, 0.8761]}, {"w": "from", "b": [0.8022, 0.8598, 0.8339, 0.8761]}, {"w": "the", "b": [0.1587, 0.8749, 0.1788, 0.8912]}, {"w": "scikit-learn", "b": [0.1824, 0.8749, 0.2541, 0.8912]}, {"w": "project,”", "b": [0.2577, 0.8749, 0.3102, 0.8912]}, {"w": "L.", "b": [0.3138, 0.8749, 0.3259, 0.8912]}, {"w": "Buitinck,", "b": [0.3295, 0.8749, 0.3875, 0.8912]}, {"w": "G.", "b": [0.3911, 0.8749, 0.4061, 0.8912]}, {"w": "Louppe,", "b": [0.4097, 0.8749, 0.4618, 0.8912]}, {"w": "M.", "b": [0.4654, 0.8749, 0.4831, 0.8912]}, {"w": "Blondel,", "b": [0.4867, 0.8749, 0.5396, 0.8912]}, {"w": "F.", "b": [0.5432, 0.8749, 0.5535, 0.8912]}, {"w": "Pedregosa,", "b": [0.5571, 0.8749, 0.6252, 0.8912]}, {"w": "A.", "b": [0.6288, 0.8749, 0.6434, 0.8912]}, {"w": "Müller,", "b": [0.647, 0.8749, 0.6924, 0.8912]}, {"w": "et", "b": [0.696, 0.8749, 0.7076, 0.8912]}, {"w": "al.", "b": [0.7112, 0.8749, 0.7258, 0.8912]}, {"w": "(2013).", "b": [0.7294, 0.8749, 0.7744, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> housing_num.median().values array([ -118.51 , 34.26 , 29. , 2119.5 , 433. , 1164. , 408. , 3.5409])", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "housing_num.median().values", "b": [0.2103, 0.0829, 0.438, 0.0958]}, {"w": "array([", "b": [0.1766, 0.0983, 0.2356, 0.1112]}, {"w": "-118.51", "b": [0.2441, 0.0983, 0.3031, 0.1112]}, {"w": ",", "b": [0.3115, 0.0983, 0.3199, 0.1112]}, {"w": "34.26", "b": [0.3284, 0.0983, 0.3705, 0.1112]}, {"w": ",", "b": [0.379, 0.0983, 0.3874, 0.1112]}, {"w": "29.", "b": [0.3958, 0.0983, 0.4211, 0.1112]}, {"w": ",", "b": [0.4296, 0.0983, 0.438, 0.1112]}, {"w": "2119.5", "b": [0.4464, 0.0983, 0.497, 0.1112]}, {"w": ",", "b": [0.5055, 0.0983, 0.5139, 0.1112]}, {"w": "433.", "b": [0.5223, 0.0983, 0.5561, 0.1112]}, {"w": ",", "b": [0.5645, 0.0983, 0.5729, 0.1112]}, {"w": "1164.", "b": [0.5814, 0.0983, 0.6235, 0.1112]}, {"w": ",", "b": [0.632, 0.0983, 0.6404, 0.1112]}, {"w": "408.", "b": [0.6488, 0.0983, 0.6825, 0.1112]}, {"w": ",", "b": [0.691, 0.0983, 0.6994, 0.1112]}, {"w": "3.5409])", "b": [0.7078, 0.0983, 0.7753, 0.1112]}]}, {"id": "b_2", "type": "paragraph", "text": "Now you can use this “trained” imputer to transform the training set by replacing missing values by the learned medians:", "words": [{"w": "Now", "b": [0.1429, 0.1199, 0.1827, 0.1413]}, {"w": "you", "b": [0.1901, 0.1199, 0.2214, 0.1413]}, {"w": "can", "b": [0.2288, 0.1199, 0.2581, 0.1413]}, {"w": "use", "b": [0.2655, 0.1199, 0.2931, 0.1413]}, {"w": "this", "b": [0.3005, 0.1199, 0.3312, 0.1413]}, {"w": "“trained”", "b": [0.3386, 0.1199, 0.4141, 0.1413]}, {"w": "imputer", "b": [0.4215, 0.123, 0.4907, 0.1381]}, {"w": "to", "b": [0.4981, 0.1199, 0.5151, 0.1413]}, {"w": "transform", "b": [0.5225, 0.1199, 0.6064, 0.1413]}, {"w": "the", "b": [0.6138, 0.1199, 0.6401, 0.1413]}, {"w": "training", "b": [0.6475, 0.1199, 0.7145, 0.1413]}, {"w": "set", "b": [0.7219, 0.1199, 0.7447, 0.1413]}, {"w": "by", "b": [0.7521, 0.1199, 0.7723, 0.1413]}, {"w": "replacing", "b": [0.7797, 0.1199, 0.8572, 0.1413]}, {"w": "missing", "b": [0.1429, 0.1389, 0.2075, 0.1603]}, {"w": "values", "b": [0.2123, 0.1389, 0.2639, 0.1603]}, {"w": "by", "b": [0.2686, 0.1389, 0.2888, 0.1603]}, {"w": "the", "b": [0.2935, 0.1389, 0.3198, 0.1603]}, {"w": "learned", "b": [0.3245, 0.1389, 0.3868, 0.1603]}, {"w": "medians:", "b": [0.3915, 0.1389, 0.467, 0.1603]}]}, {"id": "b_3", "type": "equation", "text": "X = imputer.transform(housing_num)", "words": [{"w": "X", "b": [0.1766, 0.1709, 0.185, 0.1837]}, {"w": "=", "b": [0.1934, 0.1709, 0.2019, 0.1837]}, {"w": "imputer.transform(housing_num)", "b": [0.2103, 0.1709, 0.4633, 0.1837]}]}, {"id": "b_4", "type": "paragraph", "text": "The result is a plain NumPy array containing the transformed features. If you want to put it back into a Pandas DataFrame, it’s simple:", "words": [{"w": "The", "b": [0.1429, 0.1915, 0.1757, 0.2129]}, {"w": "result", "b": [0.1807, 0.1915, 0.2276, 0.2129]}, {"w": "is", "b": [0.2327, 0.1915, 0.2459, 0.2129]}, {"w": "a", "b": [0.251, 0.1915, 0.2601, 0.2129]}, {"w": "plain", "b": [0.2652, 0.1915, 0.3075, 0.2129]}, {"w": "NumPy", "b": [0.3125, 0.1915, 0.3767, 0.2129]}, {"w": "array", "b": [0.3817, 0.1915, 0.4247, 0.2129]}, {"w": "containing", "b": [0.4297, 0.1915, 0.5194, 0.2129]}, {"w": "the", "b": [0.5244, 0.1915, 0.5507, 0.2129]}, {"w": "transformed", "b": [0.5558, 0.1915, 0.6595, 0.2129]}, {"w": "features.", "b": [0.6645, 0.1915, 0.7347, 0.2129]}, {"w": "If", "b": [0.7397, 0.1915, 0.753, 0.2129]}, {"w": "you", "b": [0.7581, 0.1915, 0.7893, 0.2129]}, {"w": "want", "b": [0.7943, 0.1915, 0.8351, 0.2129]}, {"w": "to", "b": [0.8402, 0.1915, 0.8571, 0.2129]}, {"w": "put", "b": [0.1429, 0.2106, 0.1712, 0.232]}, {"w": "it", "b": [0.1759, 0.2106, 0.1879, 0.232]}, {"w": "back", "b": [0.1926, 0.2106, 0.2315, 0.232]}, {"w": "into", "b": [0.2362, 0.2106, 0.2698, 0.232]}, {"w": "a", "b": [0.2745, 0.2106, 0.2836, 0.232]}, {"w": "Pandas", "b": [0.2884, 0.2106, 0.348, 0.232]}, {"w": "DataFrame,", "b": [0.3527, 0.2106, 0.4508, 0.232]}, {"w": "it’s", "b": [0.4556, 0.2106, 0.4772, 0.232]}, {"w": "simple:", "b": [0.482, 0.2106, 0.5417, 0.232]}]}, {"id": "b_5", "type": "equation", "text": "housing_tr = pd.DataFrame(X, columns=housing_num.columns)", "words": [{"w": "housing_tr", "b": [0.1766, 0.2425, 0.2609, 0.2554]}, {"w": "=", "b": [0.2693, 0.2425, 0.2778, 0.2554]}, {"w": "pd.DataFrame(X,", "b": [0.2862, 0.2425, 0.4127, 0.2554]}, {"w": "columns=housing_num.columns)", "b": [0.4211, 0.2425, 0.6572, 0.2554]}]}, {"id": "b_6", "type": "equation", "text": "Scikit-Learn Design", "words": [{"w": "Scikit-Learn", "b": [0.4063, 0.2822, 0.5224, 0.3094]}, {"w": "Design", "b": [0.5271, 0.2822, 0.5937, 0.3094]}]}, {"id": "b_7", "type": "paragraph", "text": "Scikit-Learn’s API is remarkably well designed. The main design principles are:17", "words": [{"w": "Scikit-Learn’s", "b": [0.1592, 0.3139, 0.2648, 0.3343]}, {"w": "API", "b": [0.2693, 0.3139, 0.301, 0.3343]}, {"w": "is", "b": [0.3055, 0.3139, 0.3181, 0.3343]}, {"w": "remarkably", "b": [0.3226, 0.3139, 0.4135, 0.3343]}, {"w": "well", "b": [0.418, 0.3139, 0.45, 0.3343]}, {"w": "designed.", "b": [0.4545, 0.3139, 0.5296, 0.3343]}, {"w": "The", "b": [0.5341, 0.3139, 0.5654, 0.3343]}, {"w": "main", "b": [0.5699, 0.3139, 0.611, 0.3343]}, {"w": "design", "b": [0.6155, 0.3139, 0.6672, 0.3343]}, {"w": "principles", "b": [0.6717, 0.3139, 0.7505, 0.3343]}, {"w": "are:17", "b": [0.755, 0.3139, 0.7954, 0.3343]}]}, {"id": "b_8", "type": "paragraph", "text": "• Consistency. All objects share a consistent and simple interface:", "words": [{"w": "•", "b": [0.1773, 0.3472, 0.185, 0.3676]}, {"w": "Consistency.", "b": [0.1949, 0.3467, 0.3001, 0.3676]}, {"w": "All", "b": [0.3046, 0.3472, 0.3283, 0.3676]}, {"w": "objects", "b": [0.3328, 0.3472, 0.3883, 0.3676]}, {"w": "share", "b": [0.3928, 0.3472, 0.4352, 0.3676]}, {"w": "a", "b": [0.4397, 0.3472, 0.4484, 0.3676]}, {"w": "consistent", "b": [0.4529, 0.3472, 0.5331, 0.3676]}, {"w": "and", "b": [0.5376, 0.3472, 0.5677, 0.3676]}, {"w": "simple", "b": [0.5722, 0.3472, 0.6245, 0.3676]}, {"w": "interface:", "b": [0.629, 0.3472, 0.7026, 0.3676]}]}, {"id": "b_9", "type": "paragraph", "text": "— Estimators. Any object that can estimate some parameters based on a dataset", "words": [{"w": "—", "b": [0.1985, 0.3714, 0.2168, 0.3918]}, {"w": "Estimators.", "b": [0.2207, 0.3712, 0.3076, 0.3918]}, {"w": "Any", "b": [0.3136, 0.3714, 0.3468, 0.3918]}, {"w": "object", "b": [0.3528, 0.3714, 0.4009, 0.3918]}, {"w": "that", "b": [0.4069, 0.3714, 0.4379, 0.3918]}, {"w": "can", "b": [0.4439, 0.3714, 0.4718, 0.3918]}, {"w": "estimate", "b": [0.4778, 0.3714, 0.5439, 0.3918]}, {"w": "some", "b": [0.5499, 0.3714, 0.592, 0.3918]}, {"w": "parameters", "b": [0.5979, 0.3714, 0.6869, 0.3918]}, {"w": "based", "b": [0.6929, 0.3714, 0.7379, 0.3918]}, {"w": "on", "b": [0.7438, 0.3714, 0.7648, 0.3918]}, {"w": "a", "b": [0.7708, 0.3714, 0.7795, 0.3918]}, {"w": "dataset", "b": [0.7854, 0.3714, 0.8408, 0.3918]}]}, {"id": "b_10", "type": "paragraph", "text": "is called an estimator (e.g., an imputer is an estimator). The estimation itself is performed by the fit() method, and it takes only a dataset as a parameter (or two for supervised learning algorithms; the second dataset contains the labels). Any other parameter needed to guide the estimation process is con‐ sidered a hyperparameter (such as an imputer’s strategy), and it must be set as an instance variable (generally via a constructor parameter).", "words": [{"w": "is", "b": [0.2207, 0.3904, 0.2333, 0.4108]}, {"w": "called", "b": [0.2378, 0.3904, 0.2839, 0.4108]}, {"w": "an", "b": [0.2884, 0.3904, 0.308, 0.4108]}, {"w": "estimator", "b": [0.3131, 0.3902, 0.3854, 0.4108]}, {"w": "(e.g.,", "b": [0.3901, 0.3904, 0.4283, 0.4108]}, {"w": "an", "b": [0.4328, 0.3904, 0.4524, 0.4108]}, {"w": "imputer", "b": [0.4573, 0.3934, 0.5233, 0.4078]}, {"w": "is", "b": [0.528, 0.3904, 0.5406, 0.4108]}, {"w": "an", "b": [0.5453, 0.3904, 0.5648, 0.4108]}, {"w": "estimator).", "b": [0.5695, 0.3904, 0.6561, 0.4108]}, {"w": "The", "b": [0.6608, 0.3904, 0.6921, 0.4108]}, {"w": "estimation", "b": [0.6968, 0.3904, 0.7808, 0.4108]}, {"w": "itself", "b": [0.7855, 0.3904, 0.8235, 0.4108]}, {"w": "is", "b": [0.8282, 0.3904, 0.8408, 0.4108]}, {"w": "performed", "b": [0.2207, 0.4094, 0.3054, 0.4298]}, {"w": "by", "b": [0.3099, 0.4094, 0.3291, 0.4298]}, {"w": "the", "b": [0.3336, 0.4094, 0.3587, 0.4298]}, {"w": "fit()", "b": [0.3638, 0.4124, 0.4109, 0.4268]}, {"w": "method,", "b": [0.4157, 0.4094, 0.4821, 0.4298]}, {"w": "and", "b": [0.4868, 0.4094, 0.5168, 0.4298]}, {"w": "it", "b": [0.5215, 0.4094, 0.5329, 0.4298]}, {"w": "takes", "b": [0.5376, 0.4094, 0.5779, 0.4298]}, {"w": "only", "b": [0.5826, 0.4094, 0.6177, 0.4298]}, {"w": "a", "b": [0.6225, 0.4094, 0.6312, 0.4298]}, {"w": "dataset", "b": [0.6359, 0.4094, 0.6912, 0.4298]}, {"w": "as", "b": [0.6959, 0.4094, 0.7119, 0.4298]}, {"w": "a", "b": [0.7166, 0.4094, 0.7253, 0.4298]}, {"w": "parameter", "b": [0.73, 0.4094, 0.8117, 0.4298]}, {"w": "(or", "b": [0.8164, 0.4094, 0.8408, 0.4298]}, {"w": "two", "b": [0.2207, 0.4275, 0.2505, 0.4479]}, {"w": "for", "b": [0.2613, 0.4275, 0.2846, 0.4479]}, {"w": "supervised", "b": [0.2954, 0.4275, 0.3807, 0.4479]}, {"w": "learning", "b": [0.3915, 0.4275, 0.4573, 0.4479]}, {"w": "algorithms;", "b": [0.4681, 0.4275, 0.5586, 0.4479]}, {"w": "the", "b": [0.5694, 0.4275, 0.5945, 0.4479]}, {"w": "second", "b": [0.6053, 0.4275, 0.6608, 0.4479]}, {"w": "dataset", "b": [0.6716, 0.4275, 0.7269, 0.4479]}, {"w": "contains", "b": [0.7377, 0.4275, 0.8049, 0.4479]}, {"w": "the", "b": [0.8157, 0.4275, 0.8408, 0.4479]}, {"w": "labels).", "b": [0.2207, 0.4457, 0.2767, 0.4661]}, {"w": "Any", "b": [0.2832, 0.4457, 0.3164, 0.4661]}, {"w": "other", "b": [0.323, 0.4457, 0.3655, 0.4661]}, {"w": "parameter", "b": [0.3721, 0.4457, 0.4538, 0.4661]}, {"w": "needed", "b": [0.4603, 0.4457, 0.5174, 0.4661]}, {"w": "to", "b": [0.5239, 0.4457, 0.5401, 0.4661]}, {"w": "guide", "b": [0.5467, 0.4457, 0.5907, 0.4661]}, {"w": "the", "b": [0.5972, 0.4457, 0.6223, 0.4661]}, {"w": "estimation", "b": [0.6289, 0.4457, 0.7129, 0.4661]}, {"w": "process", "b": [0.7194, 0.4457, 0.7787, 0.4661]}, {"w": "is", "b": [0.7852, 0.4457, 0.7978, 0.4661]}, {"w": "con‐", "b": [0.8043, 0.4457, 0.8408, 0.4661]}, {"w": "sidered", "b": [0.2207, 0.4647, 0.2785, 0.485]}, {"w": "a", "b": [0.2838, 0.4647, 0.2925, 0.485]}, {"w": "hyperparameter", "b": [0.2978, 0.4647, 0.4249, 0.485]}, {"w": "(such", "b": [0.4302, 0.4647, 0.4738, 0.485]}, {"w": "as", "b": [0.4791, 0.4647, 0.4951, 0.485]}, {"w": "an", "b": [0.5004, 0.4647, 0.5199, 0.485]}, {"w": "imputer’s", "b": [0.5252, 0.4647, 0.601, 0.485]}, {"w": "strategy),", "b": [0.6062, 0.4647, 0.693, 0.485]}, {"w": "and", "b": [0.6983, 0.4647, 0.7283, 0.485]}, {"w": "it", "b": [0.7336, 0.4647, 0.745, 0.485]}, {"w": "must", "b": [0.7502, 0.4647, 0.79, 0.485]}, {"w": "be", "b": [0.7952, 0.4647, 0.8137, 0.485]}, {"w": "set", "b": [0.819, 0.4647, 0.8408, 0.485]}, {"w": "as", "b": [0.2207, 0.4828, 0.2367, 0.5032]}, {"w": "an", "b": [0.2412, 0.4828, 0.2608, 0.5032]}, {"w": "instance", "b": [0.2653, 0.4828, 0.3312, 0.5032]}, {"w": "variable", "b": [0.3357, 0.4828, 0.3985, 0.5032]}, {"w": "(generally", "b": [0.403, 0.4828, 0.4821, 0.5032]}, {"w": "via", "b": [0.4866, 0.4828, 0.5098, 0.5032]}, {"w": "a", "b": [0.5143, 0.4828, 0.523, 0.5032]}, {"w": "constructor", "b": [0.5275, 0.4828, 0.6201, 0.5032]}, {"w": "parameter).", "b": [0.6246, 0.4828, 0.7177, 0.5032]}]}, {"id": "b_11", "type": "paragraph", "text": "— Transformers. Some estimators (such as an imputer) can also transform a", "words": [{"w": "—", "b": [0.1985, 0.5078, 0.2168, 0.5282]}, {"w": "Transformers.", "b": [0.2207, 0.5076, 0.3282, 0.5282]}, {"w": "Some", "b": [0.3368, 0.5078, 0.381, 0.5282]}, {"w": "estimators", "b": [0.3896, 0.5078, 0.4721, 0.5282]}, {"w": "(such", "b": [0.4807, 0.5078, 0.5244, 0.5282]}, {"w": "as", "b": [0.533, 0.5078, 0.549, 0.5282]}, {"w": "an", "b": [0.5576, 0.5078, 0.5772, 0.5282]}, {"w": "imputer)", "b": [0.5858, 0.5078, 0.6586, 0.5282]}, {"w": "can", "b": [0.6673, 0.5078, 0.6952, 0.5282]}, {"w": "also", "b": [0.7038, 0.5078, 0.735, 0.5282]}, {"w": "transform", "b": [0.7436, 0.5078, 0.8234, 0.5282]}, {"w": "a", "b": [0.8321, 0.5078, 0.8408, 0.5282]}]}, {"id": "b_12", "type": "paragraph", "text": "dataset; these are called transformers. Once again, the API is quite simple: the transformation is performed by the transform() method with the dataset to transform as a parameter. It returns the transformed dataset. This transforma‐ tion generally relies on the learned parameters, as is the case for an imputer. All transformers also have a convenience method called fit_transform() that is equivalent to calling fit() and then transform() (but sometimes fit_transform() is optimized and runs much faster).", "words": [{"w": "dataset;", "b": [0.2207, 0.526, 0.2806, 0.5464]}, {"w": "these", "b": [0.286, 0.526, 0.3267, 0.5464]}, {"w": "are", "b": [0.3321, 0.526, 0.3566, 0.5464]}, {"w": "called", "b": [0.362, 0.526, 0.408, 0.5464]}, {"w": "transformers.", "b": [0.4134, 0.5258, 0.5163, 0.5464]}, {"w": "Once", "b": [0.5216, 0.526, 0.5641, 0.5464]}, {"w": "again,", "b": [0.5695, 0.526, 0.6169, 0.5464]}, {"w": "the", "b": [0.6223, 0.526, 0.6473, 0.5464]}, {"w": "API", "b": [0.6527, 0.526, 0.6843, 0.5464]}, {"w": "is", "b": [0.6897, 0.526, 0.7023, 0.5464]}, {"w": "quite", "b": [0.7077, 0.526, 0.7481, 0.5464]}, {"w": "simple:", "b": [0.7535, 0.526, 0.8103, 0.5464]}, {"w": "the", "b": [0.8157, 0.526, 0.8408, 0.5464]}, {"w": "transformation", "b": [0.2207, 0.545, 0.3413, 0.5654]}, {"w": "is", "b": [0.3473, 0.545, 0.3599, 0.5654]}, {"w": "performed", "b": [0.3659, 0.545, 0.4506, 0.5654]}, {"w": "by", "b": [0.4566, 0.545, 0.4758, 0.5654]}, {"w": "the", "b": [0.4818, 0.545, 0.5069, 0.5654]}, {"w": "transform()", "b": [0.5129, 0.548, 0.6166, 0.5624]}, {"w": "method", "b": [0.6226, 0.545, 0.6846, 0.5654]}, {"w": "with", "b": [0.6906, 0.545, 0.7261, 0.5654]}, {"w": "the", "b": [0.7321, 0.545, 0.7572, 0.5654]}, {"w": "dataset", "b": [0.7632, 0.545, 0.8186, 0.5654]}, {"w": "to", "b": [0.8246, 0.545, 0.8408, 0.5654]}, {"w": "transform", "b": [0.2207, 0.5631, 0.3006, 0.5835]}, {"w": "as", "b": [0.3052, 0.5631, 0.3212, 0.5835]}, {"w": "a", "b": [0.3257, 0.5631, 0.3345, 0.5835]}, {"w": "parameter.", "b": [0.339, 0.5631, 0.424, 0.5835]}, {"w": "It", "b": [0.4286, 0.5631, 0.4406, 0.5835]}, {"w": "returns", "b": [0.4452, 0.5631, 0.5031, 0.5835]}, {"w": "the", "b": [0.5077, 0.5631, 0.5328, 0.5835]}, {"w": "transformed", "b": [0.5373, 0.5631, 0.6361, 0.5835]}, {"w": "dataset.", "b": [0.6407, 0.5631, 0.7005, 0.5835]}, {"w": "This", "b": [0.7051, 0.5631, 0.7406, 0.5835]}, {"w": "transforma‐", "b": [0.7451, 0.5631, 0.8408, 0.5835]}, {"w": "tion", "b": [0.2207, 0.5821, 0.2531, 0.6025]}, {"w": "generally", "b": [0.2588, 0.5821, 0.3311, 0.6025]}, {"w": "relies", "b": [0.3368, 0.5821, 0.3787, 0.6025]}, {"w": "on", "b": [0.3844, 0.5821, 0.4054, 0.6025]}, {"w": "the", "b": [0.4112, 0.5821, 0.4362, 0.6025]}, {"w": "learned", "b": [0.442, 0.5821, 0.5013, 0.6025]}, {"w": "parameters,", "b": [0.507, 0.5821, 0.6006, 0.6025]}, {"w": "as", "b": [0.6063, 0.5821, 0.6223, 0.6025]}, {"w": "is", "b": [0.6281, 0.5821, 0.6407, 0.6025]}, {"w": "the", "b": [0.6464, 0.5821, 0.6715, 0.6025]}, {"w": "case", "b": [0.6773, 0.5821, 0.7101, 0.6025]}, {"w": "for", "b": [0.7158, 0.5821, 0.7392, 0.6025]}, {"w": "an", "b": [0.745, 0.5821, 0.7645, 0.6025]}, {"w": "imputer.", "b": [0.7703, 0.5821, 0.8408, 0.6025]}, {"w": "All", "b": [0.2207, 0.6011, 0.2445, 0.6215]}, {"w": "transformers", "b": [0.2521, 0.6011, 0.3551, 0.6215]}, {"w": "also", "b": [0.3627, 0.6011, 0.3938, 0.6215]}, {"w": "have", "b": [0.4015, 0.6011, 0.438, 0.6215]}, {"w": "a", "b": [0.4457, 0.6011, 0.4544, 0.6215]}, {"w": "convenience", "b": [0.462, 0.6011, 0.5609, 0.6215]}, {"w": "method", "b": [0.5685, 0.6011, 0.6304, 0.6215]}, {"w": "called", "b": [0.6381, 0.6011, 0.6841, 0.6215]}, {"w": "fit_transform()", "b": [0.6918, 0.6041, 0.8331, 0.6185]}, {"w": "that", "b": [0.2207, 0.6201, 0.2518, 0.6405]}, {"w": "is", "b": [0.2607, 0.6201, 0.2733, 0.6405]}, {"w": "equivalent", "b": [0.2823, 0.6201, 0.3646, 0.6405]}, {"w": "to", "b": [0.3736, 0.6201, 0.3897, 0.6405]}, {"w": "calling", "b": [0.3987, 0.6201, 0.4513, 0.6405]}, {"w": "fit()", "b": [0.4602, 0.6231, 0.5074, 0.6375]}, {"w": "and", "b": [0.5163, 0.6201, 0.5464, 0.6405]}, {"w": "then", "b": [0.5553, 0.6201, 0.5913, 0.6405]}, {"w": "transform()", "b": [0.6002, 0.6231, 0.7039, 0.6375]}, {"w": "(but", "b": [0.7129, 0.6201, 0.7464, 0.6405]}, {"w": "sometimes", "b": [0.7554, 0.6201, 0.8408, 0.6405]}, {"w": "fit_transform()", "b": [0.2207, 0.6421, 0.3621, 0.6565]}, {"w": "is", "b": [0.3666, 0.6391, 0.3792, 0.6595]}, {"w": "optimized", "b": [0.3837, 0.6391, 0.4644, 0.6595]}, {"w": "and", "b": [0.4689, 0.6391, 0.4989, 0.6595]}, {"w": "runs", "b": [0.5034, 0.6391, 0.5395, 0.6595]}, {"w": "much", "b": [0.544, 0.6391, 0.5894, 0.6595]}, {"w": "faster).", "b": [0.5939, 0.6391, 0.649, 0.6595]}]}, {"id": "b_13", "type": "paragraph", "text": "— Predictors. Finally, some estimators are capable of making predictions given a", "words": [{"w": "—", "b": [0.1985, 0.6633, 0.2168, 0.6837]}, {"w": "Predictors.", "b": [0.2207, 0.6631, 0.3026, 0.6837]}, {"w": "Finally,", "b": [0.308, 0.6633, 0.3656, 0.6837]}, {"w": "some", "b": [0.371, 0.6633, 0.4131, 0.6837]}, {"w": "estimators", "b": [0.4185, 0.6633, 0.501, 0.6837]}, {"w": "are", "b": [0.5064, 0.6633, 0.5309, 0.6837]}, {"w": "capable", "b": [0.5363, 0.6633, 0.5957, 0.6837]}, {"w": "of", "b": [0.6011, 0.6633, 0.6171, 0.6837]}, {"w": "making", "b": [0.6225, 0.6633, 0.6828, 0.6837]}, {"w": "predictions", "b": [0.6882, 0.6633, 0.7782, 0.6837]}, {"w": "given", "b": [0.7836, 0.6633, 0.8267, 0.6837]}, {"w": "a", "b": [0.8321, 0.6633, 0.8408, 0.6837]}]}, {"id": "b_14", "type": "paragraph", "text": "dataset; they are called predictors. For example, the LinearRegression model in the previous chapter was a predictor: it predicted life satisfaction given a country’s GDP per capita. A predictor has a predict() method that takes a dataset of new instances and returns a dataset of corresponding predictions. It also has a score() method that measures the quality of the predictions given", "words": [{"w": "dataset;", "b": [0.2207, 0.6823, 0.2806, 0.7027]}, {"w": "they", "b": [0.2856, 0.6823, 0.3198, 0.7027]}, {"w": "are", "b": [0.3249, 0.6823, 0.3494, 0.7027]}, {"w": "called", "b": [0.3544, 0.6823, 0.4005, 0.7027]}, {"w": "predictors.", "b": [0.4056, 0.6821, 0.4859, 0.7027]}, {"w": "For", "b": [0.491, 0.6823, 0.5186, 0.7027]}, {"w": "example,", "b": [0.5236, 0.6823, 0.5944, 0.7027]}, {"w": "the", "b": [0.5994, 0.6823, 0.6245, 0.7027]}, {"w": "LinearRegression", "b": [0.6296, 0.6853, 0.7804, 0.6997]}, {"w": "model", "b": [0.7854, 0.6823, 0.8357, 0.7027]}, {"w": "in", "b": [0.2207, 0.7004, 0.2369, 0.7208]}, {"w": "the", "b": [0.2436, 0.7004, 0.2687, 0.7208]}, {"w": "previous", "b": [0.2754, 0.7004, 0.3441, 0.7208]}, {"w": "chapter", "b": [0.3508, 0.7004, 0.4103, 0.7208]}, {"w": "was", "b": [0.4171, 0.7004, 0.4466, 0.7208]}, {"w": "a", "b": [0.4534, 0.7004, 0.4621, 0.7208]}, {"w": "predictor:", "b": [0.4688, 0.7004, 0.5477, 0.7208]}, {"w": "it", "b": [0.5544, 0.7004, 0.5658, 0.7208]}, {"w": "predicted", "b": [0.5725, 0.7004, 0.6479, 0.7208]}, {"w": "life", "b": [0.6546, 0.7004, 0.6792, 0.7208]}, {"w": "satisfaction", "b": [0.686, 0.7004, 0.7755, 0.7208]}, {"w": "given", "b": [0.7823, 0.7004, 0.8253, 0.7208]}, {"w": "a", "b": [0.8321, 0.7004, 0.8408, 0.7208]}, {"w": "country’s", "b": [0.2207, 0.7194, 0.2932, 0.7398]}, {"w": "GDP", "b": [0.2998, 0.7194, 0.3398, 0.7398]}, {"w": "per", "b": [0.3464, 0.7194, 0.3726, 0.7398]}, {"w": "capita.", "b": [0.3793, 0.7194, 0.431, 0.7398]}, {"w": "A", "b": [0.4377, 0.7194, 0.4514, 0.7398]}, {"w": "predictor", "b": [0.4581, 0.7194, 0.532, 0.7398]}, {"w": "has", "b": [0.5387, 0.7194, 0.5652, 0.7398]}, {"w": "a", "b": [0.5719, 0.7194, 0.5806, 0.7398]}, {"w": "predict()", "b": [0.5873, 0.7224, 0.6721, 0.7368]}, {"w": "method", "b": [0.6788, 0.7194, 0.7407, 0.7398]}, {"w": "that", "b": [0.7474, 0.7194, 0.7784, 0.7398]}, {"w": "takes", "b": [0.7851, 0.7194, 0.8254, 0.7398]}, {"w": "a", "b": [0.8321, 0.7194, 0.8408, 0.7398]}, {"w": "dataset", "b": [0.2207, 0.7375, 0.2761, 0.7579]}, {"w": "of", "b": [0.2808, 0.7375, 0.2968, 0.7579]}, {"w": "new", "b": [0.3015, 0.7375, 0.3344, 0.7579]}, {"w": "instances", "b": [0.3391, 0.7375, 0.4123, 0.7579]}, {"w": "and", "b": [0.417, 0.7375, 0.447, 0.7579]}, {"w": "returns", "b": [0.4517, 0.7375, 0.5096, 0.7579]}, {"w": "a", "b": [0.5143, 0.7375, 0.523, 0.7579]}, {"w": "dataset", "b": [0.5278, 0.7375, 0.5831, 0.7579]}, {"w": "of", "b": [0.5878, 0.7375, 0.6038, 0.7579]}, {"w": "corresponding", "b": [0.6085, 0.7375, 0.7248, 0.7579]}, {"w": "predictions.", "b": [0.7295, 0.7375, 0.824, 0.7579]}, {"w": "It", "b": [0.8287, 0.7375, 0.8408, 0.7579]}, {"w": "also", "b": [0.2207, 0.7565, 0.2519, 0.7769]}, {"w": "has", "b": [0.2574, 0.7565, 0.284, 0.7769]}, {"w": "a", "b": [0.2895, 0.7565, 0.2982, 0.7769]}, {"w": "score()", "b": [0.3037, 0.7596, 0.3697, 0.7739]}, {"w": "method", "b": [0.3752, 0.7565, 0.4371, 0.7769]}, {"w": "that", "b": [0.4427, 0.7565, 0.4737, 0.7769]}, {"w": "measures", "b": [0.4792, 0.7565, 0.5535, 0.7769]}, {"w": "the", "b": [0.559, 0.7565, 0.5841, 0.7769]}, {"w": "quality", "b": [0.5896, 0.7565, 0.6445, 0.7769]}, {"w": "of", "b": [0.65, 0.7565, 0.666, 0.7769]}, {"w": "the", "b": [0.6716, 0.7565, 0.6966, 0.7769]}, {"w": "predictions", "b": [0.7022, 0.7565, 0.7922, 0.7769]}, {"w": "given", "b": [0.7977, 0.7565, 0.8408, 0.7769]}]}, {"id": "b_15", "type": "equation", "text": "68 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "68", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 95, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "18 Some predictors also provide methods to measure the confidence of their predictions.", "words": [{"w": "18", "b": [0.1385, 0.8406, 0.1518, 0.8549]}, {"w": "Some", "b": [0.1587, 0.8391, 0.1941, 0.8554]}, {"w": "predictors", "b": [0.1977, 0.8391, 0.2627, 0.8554]}, {"w": "also", "b": [0.2663, 0.8391, 0.2912, 0.8554]}, {"w": "provide", "b": [0.2948, 0.8391, 0.3438, 0.8554]}, {"w": "methods", "b": [0.3474, 0.8391, 0.4028, 0.8554]}, {"w": "to", "b": [0.4064, 0.8391, 0.4193, 0.8554]}, {"w": "measure", "b": [0.4229, 0.8391, 0.4765, 0.8554]}, {"w": "the", "b": [0.4801, 0.8391, 0.5002, 0.8554]}, {"w": "confidence", "b": [0.5038, 0.8391, 0.5735, 0.8554]}, {"w": "of", "b": [0.5771, 0.8391, 0.5899, 0.8554]}, {"w": "their", "b": [0.5935, 0.8391, 0.6237, 0.8554]}, {"w": "predictions.", "b": [0.6273, 0.8391, 0.7029, 0.8554]}]}, {"id": "b_1", "type": "paragraph", "text": "19 This class is available since Scikit-Learn 0.20. If you use an earlier version, please consider upgrading, or use Pandas’ Series.factorize() method.", "words": [{"w": "19", "b": [0.1384, 0.8602, 0.1518, 0.8745]}, {"w": "This", "b": [0.1587, 0.8587, 0.1871, 0.8751]}, {"w": "class", "b": [0.1907, 0.8587, 0.22, 0.8751]}, {"w": "is", "b": [0.2236, 0.8587, 0.2337, 0.8751]}, {"w": "available", "b": [0.2373, 0.8587, 0.2924, 0.8751]}, {"w": "since", "b": [0.296, 0.8587, 0.3282, 0.8751]}, {"w": "Scikit-Learn", "b": [0.3318, 0.8587, 0.4097, 0.8751]}, {"w": "0.20.", "b": [0.4133, 0.8587, 0.4434, 0.8751]}, {"w": "If", "b": [0.447, 0.8587, 0.4572, 0.8751]}, {"w": "you", "b": [0.4608, 0.8587, 0.4846, 0.8751]}, {"w": "use", "b": [0.4882, 0.8587, 0.5092, 0.8751]}, {"w": "an", "b": [0.5128, 0.8587, 0.5284, 0.8751]}, {"w": "earlier", "b": [0.532, 0.8587, 0.5725, 0.8751]}, {"w": "version,", "b": [0.5761, 0.8587, 0.6266, 0.8751]}, {"w": "please", "b": [0.6302, 0.8587, 0.6688, 0.8751]}, {"w": "consider", "b": [0.6724, 0.8587, 0.727, 0.8751]}, {"w": "upgrading,", "b": [0.7306, 0.8587, 0.8, 0.8751]}, {"w": "or", "b": [0.8036, 0.8587, 0.8176, 0.8751]}, {"w": "use", "b": [0.8212, 0.8587, 0.8422, 0.8751]}, {"w": "Pandas’", "b": [0.1587, 0.8749, 0.207, 0.8912]}, {"w": "Series.factorize()", "b": [0.2106, 0.8773, 0.3463, 0.8888]}, {"w": "method.", "b": [0.35, 0.8749, 0.4031, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "a test set (and the corresponding labels in the case of supervised learning algorithms).18", "words": [{"w": "a", "b": [0.2207, 0.0792, 0.2294, 0.0996]}, {"w": "test", "b": [0.2376, 0.0792, 0.2654, 0.0996]}, {"w": "set", "b": [0.2736, 0.0792, 0.2953, 0.0996]}, {"w": "(and", "b": [0.3035, 0.0792, 0.3404, 0.0996]}, {"w": "the", "b": [0.3485, 0.0792, 0.3736, 0.0996]}, {"w": "corresponding", "b": [0.3818, 0.0792, 0.498, 0.0996]}, {"w": "labels", "b": [0.5062, 0.0792, 0.5507, 0.0996]}, {"w": "in", "b": [0.5589, 0.0792, 0.575, 0.0996]}, {"w": "the", "b": [0.5832, 0.0792, 0.6082, 0.0996]}, {"w": "case", "b": [0.6164, 0.0792, 0.6492, 0.0996]}, {"w": "of", "b": [0.6574, 0.0792, 0.6734, 0.0996]}, {"w": "supervised", "b": [0.6815, 0.0792, 0.7668, 0.0996]}, {"w": "learning", "b": [0.7749, 0.0792, 0.8408, 0.0996]}, {"w": "algorithms).18", "b": [0.2207, 0.0973, 0.3295, 0.1177]}]}, {"id": "b_3", "type": "paragraph", "text": "• Inspection. All the estimator’s hyperparameters are accessible directly via public instance variables (e.g., imputer.strategy), and all the estimator’s learned parameters are also accessible via public instance variables with an underscore suffix (e.g., imputer.statistics_).", "words": [{"w": "•", "b": [0.1773, 0.1215, 0.185, 0.1419]}, {"w": "Inspection.", "b": [0.1949, 0.121, 0.288, 0.1419]}, {"w": "All", "b": [0.2935, 0.1215, 0.3172, 0.1419]}, {"w": "the", "b": [0.3227, 0.1215, 0.3478, 0.1419]}, {"w": "estimator’s", "b": [0.3533, 0.1215, 0.4383, 0.1419]}, {"w": "hyperparameters", "b": [0.4438, 0.1215, 0.5783, 0.1419]}, {"w": "are", "b": [0.5838, 0.1215, 0.6083, 0.1419]}, {"w": "accessible", "b": [0.6138, 0.1215, 0.6911, 0.1419]}, {"w": "directly", "b": [0.6966, 0.1215, 0.7568, 0.1419]}, {"w": "via", "b": [0.7623, 0.1215, 0.7855, 0.1419]}, {"w": "public", "b": [0.791, 0.1215, 0.8408, 0.1419]}, {"w": "instance", "b": [0.1949, 0.1405, 0.2608, 0.1609]}, {"w": "variables", "b": [0.2722, 0.1405, 0.3423, 0.1609]}, {"w": "(e.g.,", "b": [0.3538, 0.1405, 0.3919, 0.1609]}, {"w": "imputer.strategy),", "b": [0.4033, 0.1405, 0.5655, 0.1609]}, {"w": "and", "b": [0.5769, 0.1405, 0.607, 0.1609]}, {"w": "all", "b": [0.6184, 0.1405, 0.6371, 0.1609]}, {"w": "the", "b": [0.6486, 0.1405, 0.6736, 0.1609]}, {"w": "estimator’s", "b": [0.685, 0.1405, 0.7701, 0.1609]}, {"w": "learned", "b": [0.7815, 0.1405, 0.8408, 0.1609]}, {"w": "parameters", "b": [0.1949, 0.1586, 0.2839, 0.179]}, {"w": "are", "b": [0.291, 0.1586, 0.3155, 0.179]}, {"w": "also", "b": [0.3225, 0.1586, 0.3537, 0.179]}, {"w": "accessible", "b": [0.3607, 0.1586, 0.4381, 0.179]}, {"w": "via", "b": [0.4451, 0.1586, 0.4683, 0.179]}, {"w": "public", "b": [0.4754, 0.1586, 0.5251, 0.179]}, {"w": "instance", "b": [0.5322, 0.1586, 0.5981, 0.179]}, {"w": "variables", "b": [0.6051, 0.1586, 0.6752, 0.179]}, {"w": "with", "b": [0.6823, 0.1586, 0.7178, 0.179]}, {"w": "an", "b": [0.7249, 0.1586, 0.7445, 0.179]}, {"w": "underscore", "b": [0.7515, 0.1586, 0.8408, 0.179]}, {"w": "suffix", "b": [0.1949, 0.1776, 0.2392, 0.198]}, {"w": "(e.g.,", "b": [0.2437, 0.1776, 0.2818, 0.198]}, {"w": "imputer.statistics_).", "b": [0.2863, 0.1776, 0.4768, 0.198]}]}, {"id": "b_4", "type": "paragraph", "text": "• Nonproliferation of classes. Datasets are represented as NumPy arrays or SciPy sparse matrices, instead of homemade classes. Hyperparameters are just regular Python strings or numbers.", "words": [{"w": "•", "b": [0.1773, 0.2018, 0.185, 0.2222]}, {"w": "Nonproliferation", "b": [0.1949, 0.2013, 0.3371, 0.2222]}, {"w": "of", "b": [0.3426, 0.2013, 0.3594, 0.2222]}, {"w": "classes.", "b": [0.3649, 0.2013, 0.4243, 0.2222]}, {"w": "Datasets", "b": [0.4301, 0.2018, 0.4968, 0.2222]}, {"w": "are", "b": [0.5025, 0.2018, 0.527, 0.2222]}, {"w": "represented", "b": [0.5328, 0.2018, 0.6259, 0.2222]}, {"w": "as", "b": [0.6317, 0.2018, 0.6476, 0.2222]}, {"w": "NumPy", "b": [0.6534, 0.2018, 0.7145, 0.2222]}, {"w": "arrays", "b": [0.7202, 0.2018, 0.7684, 0.2222]}, {"w": "or", "b": [0.7742, 0.2018, 0.7916, 0.2222]}, {"w": "SciPy", "b": [0.7974, 0.2018, 0.8408, 0.2222]}, {"w": "sparse", "b": [0.1949, 0.22, 0.2444, 0.2404]}, {"w": "matrices,", "b": [0.2506, 0.22, 0.3226, 0.2404]}, {"w": "instead", "b": [0.3288, 0.22, 0.3859, 0.2404]}, {"w": "of", "b": [0.3922, 0.22, 0.4082, 0.2404]}, {"w": "homemade", "b": [0.4144, 0.22, 0.5037, 0.2404]}, {"w": "classes.", "b": [0.5099, 0.22, 0.5668, 0.2404]}, {"w": "Hyperparameters", "b": [0.5731, 0.22, 0.7119, 0.2404]}, {"w": "are", "b": [0.7181, 0.22, 0.7426, 0.2404]}, {"w": "just", "b": [0.7489, 0.22, 0.7778, 0.2404]}, {"w": "regular", "b": [0.7841, 0.22, 0.8408, 0.2404]}, {"w": "Python", "b": [0.1949, 0.2381, 0.2528, 0.2585]}, {"w": "strings", "b": [0.2573, 0.2381, 0.3108, 0.2585]}, {"w": "or", "b": [0.3153, 0.2381, 0.3328, 0.2585]}, {"w": "numbers.", "b": [0.3373, 0.2381, 0.4122, 0.2585]}]}, {"id": "b_5", "type": "paragraph", "text": "• Composition. Existing building blocks are reused as much as possible. For example, it is easy to create a Pipeline estimator from an arbitrary sequence of transformers followed by a final estimator, as we will see.", "words": [{"w": "•", "b": [0.1773, 0.2623, 0.185, 0.2827]}, {"w": "Composition.", "b": [0.1949, 0.2618, 0.3089, 0.2827]}, {"w": "Existing", "b": [0.3188, 0.2623, 0.3835, 0.2827]}, {"w": "building", "b": [0.3934, 0.2623, 0.4603, 0.2827]}, {"w": "blocks", "b": [0.4702, 0.2623, 0.521, 0.2827]}, {"w": "are", "b": [0.5309, 0.2623, 0.5554, 0.2827]}, {"w": "reused", "b": [0.5653, 0.2623, 0.6178, 0.2827]}, {"w": "as", "b": [0.6277, 0.2623, 0.6437, 0.2827]}, {"w": "much", "b": [0.6536, 0.2623, 0.699, 0.2827]}, {"w": "as", "b": [0.7089, 0.2623, 0.7249, 0.2827]}, {"w": "possible.", "b": [0.7348, 0.2623, 0.8033, 0.2827]}, {"w": "For", "b": [0.8132, 0.2623, 0.8408, 0.2827]}, {"w": "example,", "b": [0.1949, 0.2813, 0.2657, 0.3017]}, {"w": "it", "b": [0.2716, 0.2813, 0.283, 0.3017]}, {"w": "is", "b": [0.2889, 0.2813, 0.3015, 0.3017]}, {"w": "easy", "b": [0.3074, 0.2813, 0.3409, 0.3017]}, {"w": "to", "b": [0.3468, 0.2813, 0.363, 0.3017]}, {"w": "create", "b": [0.3689, 0.2813, 0.4159, 0.3017]}, {"w": "a", "b": [0.4218, 0.2813, 0.4305, 0.3017]}, {"w": "Pipeline", "b": [0.4364, 0.2843, 0.5118, 0.2987]}, {"w": "estimator", "b": [0.5177, 0.2813, 0.5929, 0.3017]}, {"w": "from", "b": [0.5988, 0.2813, 0.6385, 0.3017]}, {"w": "an", "b": [0.6444, 0.2813, 0.6639, 0.3017]}, {"w": "arbitrary", "b": [0.6698, 0.2813, 0.7405, 0.3017]}, {"w": "sequence", "b": [0.7464, 0.2813, 0.8189, 0.3017]}, {"w": "of", "b": [0.8248, 0.2813, 0.8408, 0.3017]}, {"w": "transformers", "b": [0.1949, 0.2994, 0.2979, 0.3198]}, {"w": "followed", "b": [0.3024, 0.2994, 0.371, 0.3198]}, {"w": "by", "b": [0.3755, 0.2994, 0.3947, 0.3198]}, {"w": "a", "b": [0.3992, 0.2994, 0.4079, 0.3198]}, {"w": "final", "b": [0.4124, 0.2994, 0.4482, 0.3198]}, {"w": "estimator,", "b": [0.4527, 0.2994, 0.5312, 0.3198]}, {"w": "as", "b": [0.5357, 0.2994, 0.5517, 0.3198]}, {"w": "we", "b": [0.5562, 0.2994, 0.5782, 0.3198]}, {"w": "will", "b": [0.5827, 0.2994, 0.6117, 0.3198]}, {"w": "see.", "b": [0.6162, 0.2994, 0.6448, 0.3198]}]}, {"id": "b_6", "type": "paragraph", "text": "• Sensible defaults. Scikit-Learn provides reasonable default values for most parameters, making it easy to create a baseline working system quickly.", "words": [{"w": "•", "b": [0.1773, 0.3236, 0.185, 0.344]}, {"w": "Sensible", "b": [0.1949, 0.3231, 0.2632, 0.344]}, {"w": "defaults.", "b": [0.2741, 0.3231, 0.345, 0.344]}, {"w": "Scikit-Learn", "b": [0.3561, 0.3236, 0.4535, 0.344]}, {"w": "provides", "b": [0.4646, 0.3236, 0.5332, 0.344]}, {"w": "reasonable", "b": [0.5443, 0.3236, 0.6293, 0.344]}, {"w": "default", "b": [0.6405, 0.3236, 0.6952, 0.344]}, {"w": "values", "b": [0.7063, 0.3236, 0.7555, 0.344]}, {"w": "for", "b": [0.7666, 0.3236, 0.7899, 0.344]}, {"w": "most", "b": [0.8011, 0.3236, 0.8408, 0.344]}, {"w": "parameters,", "b": [0.1949, 0.3418, 0.2885, 0.3622]}, {"w": "making", "b": [0.293, 0.3418, 0.3532, 0.3622]}, {"w": "it", "b": [0.3577, 0.3418, 0.3691, 0.3622]}, {"w": "easy", "b": [0.3736, 0.3418, 0.4071, 0.3622]}, {"w": "to", "b": [0.4116, 0.3418, 0.4278, 0.3622]}, {"w": "create", "b": [0.4323, 0.3418, 0.4793, 0.3622]}, {"w": "a", "b": [0.4838, 0.3418, 0.4925, 0.3622]}, {"w": "baseline", "b": [0.497, 0.3418, 0.5612, 0.3622]}, {"w": "working", "b": [0.5657, 0.3418, 0.632, 0.3622]}, {"w": "system", "b": [0.6365, 0.3418, 0.6909, 0.3622]}, {"w": "quickly.", "b": [0.6954, 0.3418, 0.7569, 0.3622]}]}, {"id": "b_7", "type": "paragraph", "text": "Handling Text and Categorical Attributes", "words": [{"w": "Handling", "b": [0.1429, 0.398, 0.2374, 0.4265]}, {"w": "Text", "b": [0.2423, 0.398, 0.287, 0.4265]}, {"w": "and", "b": [0.2919, 0.398, 0.3312, 0.4265]}, {"w": "Categorical", "b": [0.3361, 0.398, 0.4517, 0.4265]}, {"w": "Attributes", "b": [0.4566, 0.398, 0.5611, 0.4265]}]}, {"id": "b_8", "type": "paragraph", "text": "Earlier we left out the categorical attribute ocean_proximity because it is a text attribute so we cannot compute its median:", "words": [{"w": "Earlier", "b": [0.1429, 0.4333, 0.199, 0.4547]}, {"w": "we", "b": [0.2085, 0.4333, 0.2316, 0.4547]}, {"w": "left", "b": [0.2411, 0.4333, 0.2678, 0.4547]}, {"w": "out", "b": [0.2773, 0.4333, 0.3053, 0.4547]}, {"w": "the", "b": [0.3148, 0.4333, 0.3411, 0.4547]}, {"w": "categorical", "b": [0.3506, 0.4333, 0.4403, 0.4547]}, {"w": "attribute", "b": [0.4498, 0.4333, 0.5214, 0.4547]}, {"w": "ocean_proximity", "b": [0.5309, 0.4365, 0.6794, 0.4516]}, {"w": "because", "b": [0.6889, 0.4333, 0.7534, 0.4547]}, {"w": "it", "b": [0.7629, 0.4333, 0.7749, 0.4547]}, {"w": "is", "b": [0.7844, 0.4333, 0.7976, 0.4547]}, {"w": "a", "b": [0.8071, 0.4333, 0.8162, 0.4547]}, {"w": "text", "b": [0.8257, 0.4333, 0.8571, 0.4547]}, {"w": "attribute", "b": [0.1429, 0.4524, 0.2145, 0.4738]}, {"w": "so", "b": [0.2192, 0.4524, 0.2375, 0.4738]}, {"w": "we", "b": [0.2422, 0.4524, 0.2653, 0.4738]}, {"w": "cannot", "b": [0.2701, 0.4524, 0.3278, 0.4738]}, {"w": "compute", "b": [0.3325, 0.4524, 0.4058, 0.4738]}, {"w": "its", "b": [0.4105, 0.4524, 0.4301, 0.4738]}, {"w": "median:", "b": [0.4349, 0.4524, 0.5026, 0.4738]}]}, {"id": "b_9", "type": "paragraph", "text": ">>> housing_cat = housing[[\"ocean_proximity\"]] >>> housing_cat.head(10) ocean_proximity 17606 <1H OCEAN 18632 <1H OCEAN 14650 NEAR OCEAN 3230 INLAND 3555 <1H OCEAN 19480 INLAND 8879 <1H OCEAN 13685 INLAND 4937 <1H OCEAN 4861 <1H OCEAN", "words": [{"w": ">>>", "b": [0.1766, 0.4843, 0.2019, 0.4972]}, {"w": "housing_cat", "b": [0.2103, 0.4843, 0.3031, 0.4972]}, {"w": "=", "b": [0.3115, 0.4843, 0.3199, 0.4972]}, {"w": "housing[[\"ocean_proximity\"]]", "b": [0.3284, 0.4843, 0.5645, 0.4972]}, {"w": ">>>", "b": [0.1766, 0.4998, 0.2019, 0.5126]}, {"w": "housing_cat.head(10)", "b": [0.2103, 0.4998, 0.379, 0.5126]}, {"w": "ocean_proximity", "b": [0.2272, 0.5152, 0.3537, 0.528]}, {"w": "17606", "b": [0.1766, 0.5306, 0.2188, 0.5435]}, {"w": "<1H", "b": [0.2778, 0.5306, 0.3031, 0.5435]}, {"w": "OCEAN", "b": [0.3115, 0.5306, 0.3537, 0.5435]}, {"w": "18632", "b": [0.1766, 0.546, 0.2188, 0.5589]}, {"w": "<1H", "b": [0.2778, 0.546, 0.3031, 0.5589]}, {"w": "OCEAN", "b": [0.3115, 0.546, 0.3537, 0.5589]}, {"w": "14650", "b": [0.1766, 0.5614, 0.2188, 0.5743]}, {"w": "NEAR", "b": [0.2693, 0.5614, 0.3031, 0.5743]}, {"w": "OCEAN", "b": [0.3115, 0.5614, 0.3537, 0.5743]}, {"w": "3230", "b": [0.1766, 0.5769, 0.2103, 0.5897]}, {"w": "INLAND", "b": [0.3031, 0.5769, 0.3537, 0.5897]}, {"w": "3555", "b": [0.1766, 0.5923, 0.2103, 0.6051]}, {"w": "<1H", "b": [0.2778, 0.5923, 0.3031, 0.6051]}, {"w": "OCEAN", "b": [0.3115, 0.5923, 0.3537, 0.6051]}, {"w": "19480", "b": [0.1766, 0.6077, 0.2188, 0.6206]}, {"w": "INLAND", "b": [0.3031, 0.6077, 0.3537, 0.6206]}, {"w": "8879", "b": [0.1766, 0.6231, 0.2103, 0.636]}, {"w": "<1H", "b": [0.2778, 0.6231, 0.3031, 0.636]}, {"w": "OCEAN", "b": [0.3115, 0.6231, 0.3537, 0.636]}, {"w": "13685", "b": [0.1766, 0.6385, 0.2188, 0.6514]}, {"w": "INLAND", "b": [0.3031, 0.6385, 0.3537, 0.6514]}, {"w": "4937", "b": [0.1766, 0.654, 0.2103, 0.6668]}, {"w": "<1H", "b": [0.2778, 0.654, 0.3031, 0.6668]}, {"w": "OCEAN", "b": [0.3115, 0.654, 0.3537, 0.6668]}, {"w": "4861", "b": [0.1766, 0.6694, 0.2103, 0.6822]}, {"w": "<1H", "b": [0.2778, 0.6694, 0.3031, 0.6822]}, {"w": "OCEAN", "b": [0.3115, 0.6694, 0.3537, 0.6822]}]}, {"id": "b_10", "type": "paragraph", "text": "Most Machine Learning algorithms prefer to work with numbers anyway, so let’s con‐ vert these categories from text to numbers. For this, we can use Scikit-Learn’s Ordina lEncoder class19:", "words": [{"w": "Most", "b": [0.1429, 0.69, 0.1855, 0.7114]}, {"w": "Machine", "b": [0.1905, 0.69, 0.2636, 0.7114]}, {"w": "Learning", "b": [0.2685, 0.69, 0.3436, 0.7114]}, {"w": "algorithms", "b": [0.3486, 0.69, 0.4389, 0.7114]}, {"w": "prefer", "b": [0.4438, 0.69, 0.4941, 0.7114]}, {"w": "to", "b": [0.499, 0.69, 0.516, 0.7114]}, {"w": "work", "b": [0.521, 0.69, 0.5639, 0.7114]}, {"w": "with", "b": [0.5689, 0.69, 0.6062, 0.7114]}, {"w": "numbers", "b": [0.6112, 0.69, 0.6851, 0.7114]}, {"w": "anyway,", "b": [0.6901, 0.69, 0.7555, 0.7114]}, {"w": "so", "b": [0.7605, 0.69, 0.7788, 0.7114]}, {"w": "let’s", "b": [0.7837, 0.69, 0.8139, 0.7114]}, {"w": "con‐", "b": [0.8189, 0.69, 0.8571, 0.7114]}, {"w": "vert", "b": [0.1429, 0.71, 0.1754, 0.7314]}, {"w": "these", "b": [0.181, 0.71, 0.2238, 0.7314]}, {"w": "categories", "b": [0.2293, 0.71, 0.3123, 0.7314]}, {"w": "from", "b": [0.3178, 0.71, 0.3594, 0.7314]}, {"w": "text", "b": [0.3649, 0.71, 0.3963, 0.7314]}, {"w": "to", "b": [0.4018, 0.71, 0.4188, 0.7314]}, {"w": "numbers.", "b": [0.4243, 0.71, 0.503, 0.7314]}, {"w": "For", "b": [0.5085, 0.71, 0.5375, 0.7314]}, {"w": "this,", "b": [0.543, 0.71, 0.5785, 0.7314]}, {"w": "we", "b": [0.584, 0.71, 0.6071, 0.7314]}, {"w": "can", "b": [0.6126, 0.71, 0.642, 0.7314]}, {"w": "use", "b": [0.6475, 0.71, 0.6751, 0.7314]}, {"w": "Scikit-Learn’s", "b": [0.6806, 0.71, 0.7915, 0.7314]}, {"w": "Ordina", "b": [0.797, 0.7131, 0.8564, 0.7282]}, {"w": "lEncoder", "b": [0.1429, 0.7331, 0.222, 0.7482]}, {"w": "class19:", "b": [0.2268, 0.7299, 0.2815, 0.7513]}]}, {"id": "b_11", "type": "paragraph", "text": ">>> from sklearn.preprocessing import OrdinalEncoder >>> ordinal_encoder = OrdinalEncoder()", "words": [{"w": ">>>", "b": [0.1766, 0.7619, 0.2019, 0.7747]}, {"w": "from", "b": [0.2103, 0.7619, 0.244, 0.7747]}, {"w": "sklearn.preprocessing", "b": [0.2525, 0.7619, 0.4296, 0.7747]}, {"w": "import", "b": [0.438, 0.7619, 0.4886, 0.7747]}, {"w": "OrdinalEncoder", "b": [0.497, 0.7619, 0.6151, 0.7747]}, {"w": ">>>", "b": [0.1766, 0.7773, 0.2019, 0.7901]}, {"w": "ordinal_encoder", "b": [0.2103, 0.7773, 0.3368, 0.7901]}, {"w": "=", "b": [0.3452, 0.7773, 0.3537, 0.7901]}, {"w": "OrdinalEncoder()", "b": [0.3621, 0.7773, 0.497, 0.7901]}]}, {"id": "b_12", "type": "paragraph", "text": "Prepare the Data for Machine Learning Algorithms | 69", "words": [{"w": "Prepare", "b": [0.5083, 0.9225, 0.5544, 0.9388]}, {"w": "the", "b": [0.5573, 0.9225, 0.5771, 0.9388]}, {"w": "Data", "b": [0.58, 0.9225, 0.6076, 0.9388]}, {"w": "for", "b": [0.6104, 0.9225, 0.6273, 0.9388]}, {"w": "Machine", "b": [0.6301, 0.9225, 0.68, 0.9388]}, {"w": "Learning", "b": [0.6828, 0.9225, 0.7351, 0.9388]}, {"w": "Algorithms", "b": [0.7379, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "69", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 96, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "20 Before Scikit-Learn 0.20, it could only encode integer categorical values, but since 0.20 it can also handle other types of inputs, including text categorical inputs.", "words": [{"w": "20", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "Before", "b": [0.1587, 0.8598, 0.2006, 0.8761]}, {"w": "Scikit-Learn", "b": [0.2042, 0.8598, 0.2821, 0.8761]}, {"w": "0.20,", "b": [0.2857, 0.8598, 0.3158, 0.8761]}, {"w": "it", "b": [0.3194, 0.8598, 0.3285, 0.8761]}, {"w": "could", "b": [0.3321, 0.8598, 0.3677, 0.8761]}, {"w": "only", "b": [0.3713, 0.8598, 0.3994, 0.8761]}, {"w": "encode", "b": [0.403, 0.8598, 0.4484, 0.8761]}, {"w": "integer", "b": [0.452, 0.8598, 0.4963, 0.8761]}, {"w": "categorical", "b": [0.4999, 0.8598, 0.5682, 0.8761]}, {"w": "values,", "b": [0.5718, 0.8598, 0.6148, 0.8761]}, {"w": "but", "b": [0.6184, 0.8598, 0.6397, 0.8761]}, {"w": "since", "b": [0.6433, 0.8598, 0.6755, 0.8761]}, {"w": "0.20", "b": [0.6791, 0.8598, 0.7056, 0.8761]}, {"w": "it", "b": [0.7092, 0.8598, 0.7183, 0.8761]}, {"w": "can", "b": [0.7219, 0.8598, 0.7443, 0.8761]}, {"w": "also", "b": [0.7479, 0.8598, 0.7728, 0.8761]}, {"w": "handle", "b": [0.7764, 0.8598, 0.8197, 0.8761]}, {"w": "other", "b": [0.1587, 0.8749, 0.1928, 0.8912]}, {"w": "types", "b": [0.1964, 0.8749, 0.2294, 0.8912]}, {"w": "of", "b": [0.233, 0.8749, 0.2458, 0.8912]}, {"w": "inputs,", "b": [0.2494, 0.8749, 0.2931, 0.8912]}, {"w": "including", "b": [0.2967, 0.8749, 0.3575, 0.8912]}, {"w": "text", "b": [0.3611, 0.8749, 0.385, 0.8912]}, {"w": "categorical", "b": [0.3886, 0.8749, 0.457, 0.8912]}, {"w": "inputs.", "b": [0.4606, 0.8749, 0.5042, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> housing_cat_encoded = ordinal_encoder.fit_transform(housing_cat) >>> housing_cat_encoded[:10] array([[0.], [0.], [4.], [1.], [0.], [1.], [0.], [1.], [0.], [0.]])", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "housing_cat_encoded", "b": [0.2103, 0.0829, 0.3705, 0.0958]}, {"w": "=", "b": [0.379, 0.0829, 0.3874, 0.0958]}, {"w": "ordinal_encoder.fit_transform(housing_cat)", "b": [0.3958, 0.0829, 0.75, 0.0958]}, {"w": ">>>", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "housing_cat_encoded[:10]", "b": [0.2103, 0.0983, 0.4127, 0.1112]}, {"w": "array([[0.],", "b": [0.1766, 0.1138, 0.2778, 0.1266]}, {"w": "[0.],", "b": [0.2356, 0.1292, 0.2778, 0.142]}, {"w": "[4.],", "b": [0.2356, 0.1446, 0.2778, 0.1574]}, {"w": "[1.],", "b": [0.2356, 0.16, 0.2778, 0.1729]}, {"w": "[0.],", "b": [0.2356, 0.1754, 0.2778, 0.1883]}, {"w": "[1.],", "b": [0.2356, 0.1909, 0.2778, 0.2037]}, {"w": "[0.],", "b": [0.2356, 0.2063, 0.2778, 0.2191]}, {"w": "[1.],", "b": [0.2356, 0.2217, 0.2778, 0.2345]}, {"w": "[0.],", "b": [0.2356, 0.2371, 0.2778, 0.25]}, {"w": "[0.]])", "b": [0.2356, 0.2525, 0.2862, 0.2654]}]}, {"id": "b_2", "type": "paragraph", "text": "You can get the list of categories using the categories_ instance variable. It is a list containing a 1D array of categories for each categorical attribute (in this case, a list containing a single array since there is just one categorical attribute):", "words": [{"w": "You", "b": [0.1429, 0.2741, 0.1752, 0.2955]}, {"w": "can", "b": [0.1816, 0.2741, 0.211, 0.2955]}, {"w": "get", "b": [0.2174, 0.2741, 0.2424, 0.2955]}, {"w": "the", "b": [0.2488, 0.2741, 0.2751, 0.2955]}, {"w": "list", "b": [0.2815, 0.2741, 0.3064, 0.2955]}, {"w": "of", "b": [0.3128, 0.2741, 0.3296, 0.2955]}, {"w": "categories", "b": [0.336, 0.2741, 0.419, 0.2955]}, {"w": "using", "b": [0.4254, 0.2741, 0.4708, 0.2955]}, {"w": "the", "b": [0.4772, 0.2741, 0.5036, 0.2955]}, {"w": "categories_", "b": [0.51, 0.2772, 0.6189, 0.2923]}, {"w": "instance", "b": [0.6253, 0.2741, 0.6945, 0.2955]}, {"w": "variable.", "b": [0.7009, 0.2741, 0.7716, 0.2955]}, {"w": "It", "b": [0.778, 0.2741, 0.7907, 0.2955]}, {"w": "is", "b": [0.7971, 0.2741, 0.8103, 0.2955]}, {"w": "a", "b": [0.8167, 0.2741, 0.8259, 0.2955]}, {"w": "list", "b": [0.8323, 0.2741, 0.8571, 0.2955]}, {"w": "containing", "b": [0.1429, 0.2931, 0.2325, 0.3145]}, {"w": "a", "b": [0.2393, 0.2931, 0.2485, 0.3145]}, {"w": "1D", "b": [0.2553, 0.2931, 0.2806, 0.3145]}, {"w": "array", "b": [0.2875, 0.2931, 0.3304, 0.3145]}, {"w": "of", "b": [0.3372, 0.2931, 0.354, 0.3145]}, {"w": "categories", "b": [0.3609, 0.2931, 0.4438, 0.3145]}, {"w": "for", "b": [0.4506, 0.2931, 0.4752, 0.3145]}, {"w": "each", "b": [0.482, 0.2931, 0.5199, 0.3145]}, {"w": "categorical", "b": [0.5268, 0.2931, 0.6164, 0.3145]}, {"w": "attribute", "b": [0.6233, 0.2931, 0.6949, 0.3145]}, {"w": "(in", "b": [0.7017, 0.2931, 0.7259, 0.3145]}, {"w": "this", "b": [0.7327, 0.2931, 0.7635, 0.3145]}, {"w": "case,", "b": [0.7703, 0.2931, 0.8095, 0.3145]}, {"w": "a", "b": [0.8163, 0.2931, 0.8255, 0.3145]}, {"w": "list", "b": [0.8323, 0.2931, 0.8572, 0.3145]}, {"w": "containing", "b": [0.1429, 0.3122, 0.2325, 0.3336]}, {"w": "a", "b": [0.2372, 0.3122, 0.2464, 0.3336]}, {"w": "single", "b": [0.2511, 0.3122, 0.2996, 0.3336]}, {"w": "array", "b": [0.3043, 0.3122, 0.3473, 0.3336]}, {"w": "since", "b": [0.352, 0.3122, 0.3943, 0.3336]}, {"w": "there", "b": [0.399, 0.3122, 0.4419, 0.3336]}, {"w": "is", "b": [0.4467, 0.3122, 0.4599, 0.3336]}, {"w": "just", "b": [0.4646, 0.3122, 0.495, 0.3336]}, {"w": "one", "b": [0.4998, 0.3122, 0.5306, 0.3336]}, {"w": "categorical", "b": [0.5354, 0.3122, 0.625, 0.3336]}, {"w": "attribute):", "b": [0.6298, 0.3122, 0.7134, 0.3336]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> ordinal_encoder.categories_ [array(['<1H OCEAN', 'INLAND', 'ISLAND', 'NEAR BAY', 'NEAR OCEAN'], dtype=object)]", "words": [{"w": ">>>", "b": [0.1766, 0.3441, 0.2019, 0.357]}, {"w": "ordinal_encoder.categories_", "b": [0.2103, 0.3441, 0.438, 0.357]}, {"w": "[array(['<1H", "b": [0.1766, 0.3596, 0.2778, 0.3724]}, {"w": "OCEAN',", "b": [0.2862, 0.3596, 0.3452, 0.3724]}, {"w": "'INLAND',", "b": [0.3537, 0.3596, 0.4296, 0.3724]}, {"w": "'ISLAND',", "b": [0.438, 0.3596, 0.5139, 0.3724]}, {"w": "'NEAR", "b": [0.5223, 0.3596, 0.5645, 0.3724]}, {"w": "BAY',", "b": [0.5729, 0.3596, 0.6151, 0.3724]}, {"w": "'NEAR", "b": [0.6235, 0.3596, 0.6657, 0.3724]}, {"w": "OCEAN'],", "b": [0.6741, 0.3596, 0.7416, 0.3724]}, {"w": "dtype=object)]", "b": [0.2356, 0.375, 0.3537, 0.3878]}]}, {"id": "b_4", "type": "paragraph", "text": "One issue with this representation is that ML algorithms will assume that two nearby values are more similar than two distant values. This may be fine in some cases (e.g., for ordered categories such as “bad”, “average”, “good”, “excellent”), but it is obviously not the case for the ocean_proximity column (for example, categories 0 and 4 are clearly more similar than categories 0 and 1). To fix this issue, a common solution is to create one binary attribute per category: one attribute equal to 1 when the category is “<1H OCEAN” (and 0 otherwise), another attribute equal to 1 when the category is “INLAND” (and 0 otherwise), and so on. This is called one-hot encoding, because only one attribute will be equal to 1 (hot), while the others will be 0 (cold). The new attributes are sometimes called dummy attributes. Scikit-Learn provides a OneHotEn coder class to convert categorical values into one-hot vectors20:", "words": [{"w": "One", "b": [0.1429, 0.3956, 0.1787, 0.417]}, {"w": "issue", "b": [0.1841, 0.3956, 0.2249, 0.417]}, {"w": "with", "b": [0.2303, 0.3956, 0.2676, 0.417]}, {"w": "this", "b": [0.273, 0.3956, 0.3037, 0.417]}, {"w": "representation", "b": [0.3091, 0.3956, 0.4297, 0.417]}, {"w": "is", "b": [0.4351, 0.3956, 0.4484, 0.417]}, {"w": "that", "b": [0.4538, 0.3956, 0.4864, 0.417]}, {"w": "ML", "b": [0.4918, 0.3956, 0.5215, 0.417]}, {"w": "algorithms", "b": [0.5269, 0.3956, 0.6172, 0.417]}, {"w": "will", "b": [0.6226, 0.3956, 0.653, 0.417]}, {"w": "assume", "b": [0.6584, 0.3956, 0.7198, 0.417]}, {"w": "that", "b": [0.7252, 0.3956, 0.7578, 0.417]}, {"w": "two", "b": [0.7632, 0.3956, 0.7945, 0.417]}, {"w": "nearby", "b": [0.7999, 0.3956, 0.8571, 0.417]}, {"w": "values", "b": [0.1429, 0.4147, 0.1945, 0.4361]}, {"w": "are", "b": [0.2001, 0.4147, 0.2259, 0.4361]}, {"w": "more", "b": [0.2315, 0.4147, 0.2758, 0.4361]}, {"w": "similar", "b": [0.2814, 0.4147, 0.3394, 0.4361]}, {"w": "than", "b": [0.3451, 0.4147, 0.3831, 0.4361]}, {"w": "two", "b": [0.3887, 0.4147, 0.42, 0.4361]}, {"w": "distant", "b": [0.4256, 0.4147, 0.4827, 0.4361]}, {"w": "values.", "b": [0.4883, 0.4147, 0.5447, 0.4361]}, {"w": "This", "b": [0.5503, 0.4147, 0.5875, 0.4361]}, {"w": "may", "b": [0.5932, 0.4147, 0.6286, 0.4361]}, {"w": "be", "b": [0.6342, 0.4147, 0.6536, 0.4361]}, {"w": "fine", "b": [0.6593, 0.4147, 0.6913, 0.4361]}, {"w": "in", "b": [0.6969, 0.4147, 0.7139, 0.4361]}, {"w": "some", "b": [0.7195, 0.4147, 0.7637, 0.4361]}, {"w": "cases", "b": [0.7693, 0.4147, 0.8115, 0.4361]}, {"w": "(e.g.,", "b": [0.8171, 0.4147, 0.8572, 0.4361]}, {"w": "for", "b": [0.1429, 0.4337, 0.1674, 0.4551]}, {"w": "ordered", "b": [0.173, 0.4337, 0.2388, 0.4551]}, {"w": "categories", "b": [0.2445, 0.4337, 0.3275, 0.4551]}, {"w": "such", "b": [0.3331, 0.4337, 0.3718, 0.4551]}, {"w": "as", "b": [0.3774, 0.4337, 0.3942, 0.4551]}, {"w": "“bad”,", "b": [0.3999, 0.4337, 0.4482, 0.4551]}, {"w": "“average”,", "b": [0.4538, 0.4337, 0.5321, 0.4551]}, {"w": "“good”,", "b": [0.5377, 0.4337, 0.5956, 0.4551]}, {"w": "“excellent”),", "b": [0.6013, 0.4337, 0.7007, 0.4551]}, {"w": "but", "b": [0.7064, 0.4337, 0.7344, 0.4551]}, {"w": "it", "b": [0.74, 0.4337, 0.752, 0.4551]}, {"w": "is", "b": [0.7576, 0.4337, 0.7709, 0.4551]}, {"w": "obviously", "b": [0.7765, 0.4337, 0.8571, 0.4551]}, {"w": "not", "b": [0.1429, 0.4536, 0.1712, 0.4751]}, {"w": "the", "b": [0.1786, 0.4536, 0.2049, 0.4751]}, {"w": "case", "b": [0.2122, 0.4536, 0.2467, 0.4751]}, {"w": "for", "b": [0.254, 0.4536, 0.2785, 0.4751]}, {"w": "the", "b": [0.2859, 0.4536, 0.3122, 0.4751]}, {"w": "ocean_proximity", "b": [0.3195, 0.4568, 0.468, 0.4719]}, {"w": "column", "b": [0.4753, 0.4536, 0.5395, 0.4751]}, {"w": "(for", "b": [0.5469, 0.4536, 0.5786, 0.4751]}, {"w": "example,", "b": [0.5859, 0.4536, 0.6602, 0.4751]}, {"w": "categories", "b": [0.6676, 0.4536, 0.7505, 0.4751]}, {"w": "0", "b": [0.7579, 0.4536, 0.7679, 0.4751]}, {"w": "and", "b": [0.7752, 0.4536, 0.8067, 0.4751]}, {"w": "4", "b": [0.8141, 0.4536, 0.8241, 0.4751]}, {"w": "are", "b": [0.8314, 0.4536, 0.8571, 0.4751]}, {"w": "clearly", "b": [0.1428, 0.4727, 0.1975, 0.4941]}, {"w": "more", "b": [0.2033, 0.4727, 0.2476, 0.4941]}, {"w": "similar", "b": [0.2534, 0.4727, 0.3114, 0.4941]}, {"w": "than", "b": [0.3172, 0.4727, 0.3552, 0.4941]}, {"w": "categories", "b": [0.361, 0.4727, 0.444, 0.4941]}, {"w": "0", "b": [0.4498, 0.4727, 0.4598, 0.4941]}, {"w": "and", "b": [0.4656, 0.4727, 0.4971, 0.4941]}, {"w": "1).", "b": [0.5029, 0.4727, 0.5249, 0.4941]}, {"w": "To", "b": [0.5307, 0.4727, 0.5521, 0.4941]}, {"w": "fix", "b": [0.5579, 0.4727, 0.5795, 0.4941]}, {"w": "this", "b": [0.5853, 0.4727, 0.616, 0.4941]}, {"w": "issue,", "b": [0.6218, 0.4727, 0.6674, 0.4941]}, {"w": "a", "b": [0.6732, 0.4727, 0.6823, 0.4941]}, {"w": "common", "b": [0.6881, 0.4727, 0.7637, 0.4941]}, {"w": "solution", "b": [0.7695, 0.4727, 0.8381, 0.4941]}, {"w": "is", "b": [0.8439, 0.4727, 0.8571, 0.4941]}, {"w": "to", "b": [0.1429, 0.4917, 0.1598, 0.5132]}, {"w": "create", "b": [0.1648, 0.4917, 0.2142, 0.5132]}, {"w": "one", "b": [0.2191, 0.4917, 0.25, 0.5132]}, {"w": "binary", "b": [0.2549, 0.4917, 0.3096, 0.5132]}, {"w": "attribute", "b": [0.3145, 0.4917, 0.3861, 0.5132]}, {"w": "per", "b": [0.3911, 0.4917, 0.4186, 0.5132]}, {"w": "category:", "b": [0.4236, 0.4917, 0.5, 0.5132]}, {"w": "one", "b": [0.505, 0.4917, 0.5358, 0.5132]}, {"w": "attribute", "b": [0.5408, 0.4917, 0.6124, 0.5132]}, {"w": "equal", "b": [0.6174, 0.4917, 0.6624, 0.5132]}, {"w": "to", "b": [0.6673, 0.4917, 0.6843, 0.5132]}, {"w": "1", "b": [0.6892, 0.4917, 0.6992, 0.5132]}, {"w": "when", "b": [0.7042, 0.4917, 0.7499, 0.5132]}, {"w": "the", "b": [0.7548, 0.4917, 0.7811, 0.5132]}, {"w": "category", "b": [0.7861, 0.4917, 0.8571, 0.5132]}, {"w": "is", "b": [0.1429, 0.5108, 0.1561, 0.5322]}, {"w": "“<1H", "b": [0.1609, 0.5108, 0.2067, 0.5322]}, {"w": "OCEAN”", "b": [0.2116, 0.5108, 0.2914, 0.5322]}, {"w": "(and", "b": [0.2963, 0.5108, 0.335, 0.5322]}, {"w": "0", "b": [0.3399, 0.5108, 0.3499, 0.5322]}, {"w": "otherwise),", "b": [0.3547, 0.5108, 0.4483, 0.5322]}, {"w": "another", "b": [0.4532, 0.5108, 0.5184, 0.5322]}, {"w": "attribute", "b": [0.5233, 0.5108, 0.5949, 0.5322]}, {"w": "equal", "b": [0.5998, 0.5108, 0.6448, 0.5322]}, {"w": "to", "b": [0.6496, 0.5108, 0.6666, 0.5322]}, {"w": "1", "b": [0.6715, 0.5108, 0.6815, 0.5322]}, {"w": "when", "b": [0.6863, 0.5108, 0.732, 0.5322]}, {"w": "the", "b": [0.7368, 0.5108, 0.7632, 0.5322]}, {"w": "category", "b": [0.768, 0.5108, 0.8391, 0.5322]}, {"w": "is", "b": [0.8439, 0.5108, 0.8571, 0.5322]}, {"w": "“INLAND”", "b": [0.1429, 0.5298, 0.2377, 0.5512]}, {"w": "(and", "b": [0.2459, 0.5298, 0.2846, 0.5512]}, {"w": "0", "b": [0.2928, 0.5298, 0.3028, 0.5512]}, {"w": "otherwise),", "b": [0.311, 0.5298, 0.4046, 0.5512]}, {"w": "and", "b": [0.4127, 0.5298, 0.4443, 0.5512]}, {"w": "so", "b": [0.4525, 0.5298, 0.4707, 0.5512]}, {"w": "on.", "b": [0.4789, 0.5298, 0.5057, 0.5512]}, {"w": "This", "b": [0.5138, 0.5298, 0.551, 0.5512]}, {"w": "is", "b": [0.5592, 0.5298, 0.5724, 0.5512]}, {"w": "called", "b": [0.5806, 0.5298, 0.6289, 0.5512]}, {"w": "one-hot", "b": [0.6371, 0.5296, 0.6994, 0.5512]}, {"w": "encoding,", "b": [0.7076, 0.5296, 0.7844, 0.5512]}, {"w": "because", "b": [0.7926, 0.5298, 0.8571, 0.5512]}, {"w": "only", "b": [0.1429, 0.5489, 0.1797, 0.5703]}, {"w": "one", "b": [0.1856, 0.5489, 0.2165, 0.5703]}, {"w": "attribute", "b": [0.2224, 0.5489, 0.294, 0.5703]}, {"w": "will", "b": [0.2999, 0.5489, 0.3303, 0.5703]}, {"w": "be", "b": [0.3362, 0.5489, 0.3556, 0.5703]}, {"w": "equal", "b": [0.3615, 0.5489, 0.4065, 0.5703]}, {"w": "to", "b": [0.4123, 0.5489, 0.4293, 0.5703]}, {"w": "1", "b": [0.4352, 0.5489, 0.4452, 0.5703]}, {"w": "(hot),", "b": [0.4511, 0.5489, 0.4984, 0.5703]}, {"w": "while", "b": [0.5042, 0.5489, 0.5493, 0.5703]}, {"w": "the", "b": [0.5552, 0.5489, 0.5816, 0.5703]}, {"w": "others", "b": [0.5874, 0.5489, 0.6398, 0.5703]}, {"w": "will", "b": [0.6457, 0.5489, 0.6761, 0.5703]}, {"w": "be", "b": [0.6819, 0.5489, 0.7014, 0.5703]}, {"w": "0", "b": [0.7073, 0.5489, 0.7173, 0.5703]}, {"w": "(cold).", "b": [0.7232, 0.5489, 0.778, 0.5703]}, {"w": "The", "b": [0.7839, 0.5489, 0.8167, 0.5703]}, {"w": "new", "b": [0.8226, 0.5489, 0.8572, 0.5703]}, {"w": "attributes", "b": [0.1429, 0.5688, 0.2221, 0.5902]}, {"w": "are", "b": [0.2288, 0.5688, 0.2546, 0.5902]}, {"w": "sometimes", "b": [0.2613, 0.5688, 0.351, 0.5902]}, {"w": "called", "b": [0.3577, 0.5688, 0.4061, 0.5902]}, {"w": "dummy", "b": [0.4128, 0.5686, 0.475, 0.5902]}, {"w": "attributes.", "b": [0.4818, 0.5688, 0.5658, 0.5902]}, {"w": "Scikit-Learn", "b": [0.5725, 0.5688, 0.6748, 0.5902]}, {"w": "provides", "b": [0.6815, 0.5688, 0.7535, 0.5902]}, {"w": "a", "b": [0.7602, 0.5688, 0.7694, 0.5902]}, {"w": "OneHotEn", "b": [0.7761, 0.572, 0.8553, 0.5871]}, {"w": "coder", "b": [0.1429, 0.592, 0.1923, 0.607]}, {"w": "class", "b": [0.1971, 0.5888, 0.2356, 0.6102]}, {"w": "to", "b": [0.2403, 0.5888, 0.2573, 0.6102]}, {"w": "convert", "b": [0.262, 0.5888, 0.325, 0.6102]}, {"w": "categorical", "b": [0.3297, 0.5888, 0.4194, 0.6102]}, {"w": "values", "b": [0.4241, 0.5888, 0.4757, 0.6102]}, {"w": "into", "b": [0.4805, 0.5888, 0.514, 0.6102]}, {"w": "one-hot", "b": [0.5188, 0.5888, 0.5851, 0.6102]}, {"w": "vectors20:", "b": [0.5899, 0.5888, 0.6657, 0.6102]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> from sklearn.preprocessing import OneHotEncoder >>> cat_encoder = OneHotEncoder() >>> housing_cat_1hot = cat_encoder.fit_transform(housing_cat) >>> housing_cat_1hot <16512x5 sparse matrix of type '' with 16512 stored elements in Compressed Sparse Row format>", "words": [{"w": ">>>", "b": [0.1766, 0.6207, 0.2019, 0.6336]}, {"w": "from", "b": [0.2103, 0.6207, 0.244, 0.6336]}, {"w": "sklearn.preprocessing", "b": [0.2525, 0.6207, 0.4296, 0.6336]}, {"w": "import", "b": [0.438, 0.6207, 0.4886, 0.6336]}, {"w": "OneHotEncoder", "b": [0.497, 0.6207, 0.6066, 0.6336]}, {"w": ">>>", "b": [0.1766, 0.6362, 0.2019, 0.649]}, {"w": "cat_encoder", "b": [0.2103, 0.6362, 0.3031, 0.649]}, {"w": "=", "b": [0.3115, 0.6362, 0.3199, 0.649]}, {"w": "OneHotEncoder()", "b": [0.3284, 0.6362, 0.4549, 0.649]}, {"w": ">>>", "b": [0.1766, 0.6516, 0.2019, 0.6644]}, {"w": "housing_cat_1hot", "b": [0.2103, 0.6516, 0.3452, 0.6644]}, {"w": "=", "b": [0.3537, 0.6516, 0.3621, 0.6644]}, {"w": "cat_encoder.fit_transform(housing_cat)", "b": [0.3705, 0.6516, 0.691, 0.6644]}, {"w": ">>>", "b": [0.1766, 0.667, 0.2019, 0.6799]}, {"w": "housing_cat_1hot", "b": [0.2103, 0.667, 0.3452, 0.6799]}, {"w": "<16512x5", "b": [0.1766, 0.6824, 0.244, 0.6953]}, {"w": "sparse", "b": [0.2525, 0.6824, 0.3031, 0.6953]}, {"w": "matrix", "b": [0.3115, 0.6824, 0.3621, 0.6953]}, {"w": "of", "b": [0.3705, 0.6824, 0.3874, 0.6953]}, {"w": "type", "b": [0.3958, 0.6824, 0.4296, 0.6953]}, {"w": "''", "b": [0.5055, 0.6824, 0.6488, 0.6953]}, {"w": "with", "b": [0.1935, 0.6978, 0.2272, 0.7107]}, {"w": "16512", "b": [0.2356, 0.6978, 0.2778, 0.7107]}, {"w": "stored", "b": [0.2862, 0.6978, 0.3368, 0.7107]}, {"w": "elements", "b": [0.3452, 0.6978, 0.4127, 0.7107]}, {"w": "in", "b": [0.4211, 0.6978, 0.438, 0.7107]}, {"w": "Compressed", "b": [0.4464, 0.6978, 0.5308, 0.7107]}, {"w": "Sparse", "b": [0.5392, 0.6978, 0.5898, 0.7107]}, {"w": "Row", "b": [0.5982, 0.6978, 0.6235, 0.7107]}, {"w": "format>", "b": [0.6319, 0.6978, 0.691, 0.7107]}]}, {"id": "b_6", "type": "paragraph", "text": "Notice that the output is a SciPy sparse matrix, instead of a NumPy array. This is very useful when you have categorical attributes with thousands of categories. After one- hot encoding we get a matrix with thousands of columns, and the matrix is full of zeros except for a single 1 per row. Using up tons of memory mostly to store zeros would be very wasteful, so instead a sparse matrix only stores the location of the non‐", "words": [{"w": "Notice", "b": [0.1429, 0.7185, 0.1981, 0.7399]}, {"w": "that", "b": [0.2032, 0.7185, 0.2358, 0.7399]}, {"w": "the", "b": [0.241, 0.7185, 0.2673, 0.7399]}, {"w": "output", "b": [0.2725, 0.7185, 0.3289, 0.7399]}, {"w": "is", "b": [0.334, 0.7185, 0.3473, 0.7399]}, {"w": "a", "b": [0.3524, 0.7185, 0.3616, 0.7399]}, {"w": "SciPy", "b": [0.3667, 0.7185, 0.4123, 0.7399]}, {"w": "sparse", "b": [0.4175, 0.7183, 0.4672, 0.7399]}, {"w": "matrix,", "b": [0.472, 0.7183, 0.5327, 0.7399]}, {"w": "instead", "b": [0.5379, 0.7185, 0.5978, 0.7399]}, {"w": "of", "b": [0.603, 0.7185, 0.6198, 0.7399]}, {"w": "a", "b": [0.625, 0.7185, 0.6341, 0.7399]}, {"w": "NumPy", "b": [0.6393, 0.7185, 0.7035, 0.7399]}, {"w": "array.", "b": [0.7086, 0.7185, 0.7548, 0.7399]}, {"w": "This", "b": [0.76, 0.7185, 0.7972, 0.7399]}, {"w": "is", "b": [0.8023, 0.7185, 0.8156, 0.7399]}, {"w": "very", "b": [0.8207, 0.7185, 0.8571, 0.7399]}, {"w": "useful", "b": [0.1429, 0.7375, 0.1929, 0.7589]}, {"w": "when", "b": [0.1993, 0.7375, 0.245, 0.7589]}, {"w": "you", "b": [0.2514, 0.7375, 0.2826, 0.7589]}, {"w": "have", "b": [0.289, 0.7375, 0.3274, 0.7589]}, {"w": "categorical", "b": [0.3338, 0.7375, 0.4235, 0.7589]}, {"w": "attributes", "b": [0.4299, 0.7375, 0.5091, 0.7589]}, {"w": "with", "b": [0.5155, 0.7375, 0.5529, 0.7589]}, {"w": "thousands", "b": [0.5593, 0.7375, 0.6453, 0.7589]}, {"w": "of", "b": [0.6517, 0.7375, 0.6685, 0.7589]}, {"w": "categories.", "b": [0.6748, 0.7375, 0.7626, 0.7589]}, {"w": "After", "b": [0.769, 0.7375, 0.8125, 0.7589]}, {"w": "one-", "b": [0.8188, 0.7375, 0.8571, 0.7589]}, {"w": "hot", "b": [0.1429, 0.7566, 0.171, 0.778]}, {"w": "encoding", "b": [0.1782, 0.7566, 0.2556, 0.778]}, {"w": "we", "b": [0.2629, 0.7566, 0.286, 0.778]}, {"w": "get", "b": [0.2932, 0.7566, 0.3182, 0.778]}, {"w": "a", "b": [0.3254, 0.7566, 0.3345, 0.778]}, {"w": "matrix", "b": [0.3418, 0.7566, 0.3971, 0.778]}, {"w": "with", "b": [0.4043, 0.7566, 0.4417, 0.778]}, {"w": "thousands", "b": [0.4489, 0.7566, 0.5349, 0.778]}, {"w": "of", "b": [0.5421, 0.7566, 0.5589, 0.778]}, {"w": "columns,", "b": [0.5662, 0.7566, 0.6428, 0.778]}, {"w": "and", "b": [0.65, 0.7566, 0.6815, 0.778]}, {"w": "the", "b": [0.6888, 0.7566, 0.7151, 0.778]}, {"w": "matrix", "b": [0.7223, 0.7566, 0.7777, 0.778]}, {"w": "is", "b": [0.7849, 0.7566, 0.7981, 0.778]}, {"w": "full", "b": [0.8054, 0.7566, 0.8331, 0.778]}, {"w": "of", "b": [0.8404, 0.7566, 0.8572, 0.778]}, {"w": "zeros", "b": [0.1429, 0.7756, 0.1865, 0.797]}, {"w": "except", "b": [0.1932, 0.7756, 0.2469, 0.797]}, {"w": "for", "b": [0.2536, 0.7756, 0.2782, 0.797]}, {"w": "a", "b": [0.2849, 0.7756, 0.2941, 0.797]}, {"w": "single", "b": [0.3008, 0.7756, 0.3493, 0.797]}, {"w": "1", "b": [0.3561, 0.7756, 0.3661, 0.797]}, {"w": "per", "b": [0.3729, 0.7756, 0.4004, 0.797]}, {"w": "row.", "b": [0.4071, 0.7756, 0.443, 0.797]}, {"w": "Using", "b": [0.4498, 0.7756, 0.4984, 0.797]}, {"w": "up", "b": [0.5051, 0.7756, 0.5271, 0.797]}, {"w": "tons", "b": [0.5339, 0.7756, 0.5699, 0.797]}, {"w": "of", "b": [0.5767, 0.7756, 0.5935, 0.797]}, {"w": "memory", "b": [0.6003, 0.7756, 0.6718, 0.797]}, {"w": "mostly", "b": [0.6785, 0.7756, 0.735, 0.797]}, {"w": "to", "b": [0.7418, 0.7756, 0.7588, 0.797]}, {"w": "store", "b": [0.7656, 0.7756, 0.8068, 0.797]}, {"w": "zeros", "b": [0.8135, 0.7756, 0.8571, 0.797]}, {"w": "would", "b": [0.1429, 0.7947, 0.1951, 0.8161]}, {"w": "be", "b": [0.2001, 0.7947, 0.2195, 0.8161]}, {"w": "very", "b": [0.2245, 0.7947, 0.2609, 0.8161]}, {"w": "wasteful,", "b": [0.2658, 0.7947, 0.3394, 0.8161]}, {"w": "so", "b": [0.3443, 0.7947, 0.3626, 0.8161]}, {"w": "instead", "b": [0.3676, 0.7947, 0.4276, 0.8161]}, {"w": "a", "b": [0.4325, 0.7947, 0.4417, 0.8161]}, {"w": "sparse", "b": [0.4467, 0.7947, 0.4986, 0.8161]}, {"w": "matrix", "b": [0.5036, 0.7947, 0.5589, 0.8161]}, {"w": "only", "b": [0.5639, 0.7947, 0.6007, 0.8161]}, {"w": "stores", "b": [0.6057, 0.7947, 0.6546, 0.8161]}, {"w": "the", "b": [0.6595, 0.7947, 0.6859, 0.8161]}, {"w": "location", "b": [0.6908, 0.7947, 0.7583, 0.8161]}, {"w": "of", "b": [0.7632, 0.7947, 0.78, 0.8161]}, {"w": "the", "b": [0.785, 0.7947, 0.8113, 0.8161]}, {"w": "non‐", "b": [0.8163, 0.7947, 0.8571, 0.8161]}]}, {"id": "b_7", "type": "equation", "text": "70 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "70", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 97, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "21 See SciPy’s documentation for more details.", "words": [{"w": "21", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "See", "b": [0.1587, 0.8749, 0.1797, 0.8912]}, {"w": "SciPy’s", "b": [0.1833, 0.8749, 0.2259, 0.8912]}, {"w": "documentation", "b": [0.2295, 0.8749, 0.3267, 0.8912]}, {"w": "for", "b": [0.3303, 0.8749, 0.3489, 0.8912]}, {"w": "more", "b": [0.3525, 0.8749, 0.3863, 0.8912]}, {"w": "details.", "b": [0.3899, 0.8749, 0.4345, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "zero elements. You can use it mostly like a normal 2D array,21 but if you really want to convert it to a (dense) NumPy array, just call the toarray() method:", "words": [{"w": "zero", "b": [0.1429, 0.0791, 0.1788, 0.1005]}, {"w": "elements.", "b": [0.1838, 0.0791, 0.2624, 0.1005]}, {"w": "You", "b": [0.2673, 0.0791, 0.2997, 0.1005]}, {"w": "can", "b": [0.3046, 0.0791, 0.334, 0.1005]}, {"w": "use", "b": [0.3389, 0.0791, 0.3665, 0.1005]}, {"w": "it", "b": [0.3715, 0.0791, 0.3834, 0.1005]}, {"w": "mostly", "b": [0.3883, 0.0791, 0.4449, 0.1005]}, {"w": "like", "b": [0.4498, 0.0791, 0.4798, 0.1005]}, {"w": "a", "b": [0.4848, 0.0791, 0.4939, 0.1005]}, {"w": "normal", "b": [0.4989, 0.0791, 0.5601, 0.1005]}, {"w": "2D", "b": [0.565, 0.0791, 0.5904, 0.1005]}, {"w": "array,21", "b": [0.5953, 0.0791, 0.6529, 0.1005]}, {"w": "but", "b": [0.6578, 0.0791, 0.6858, 0.1005]}, {"w": "if", "b": [0.6908, 0.0791, 0.7025, 0.1005]}, {"w": "you", "b": [0.7075, 0.0791, 0.7387, 0.1005]}, {"w": "really", "b": [0.7437, 0.0791, 0.7895, 0.1005]}, {"w": "want", "b": [0.7944, 0.0791, 0.8352, 0.1005]}, {"w": "to", "b": [0.8402, 0.0791, 0.8571, 0.1005]}, {"w": "convert", "b": [0.1429, 0.099, 0.2058, 0.1204]}, {"w": "it", "b": [0.2105, 0.099, 0.2225, 0.1204]}, {"w": "to", "b": [0.2272, 0.099, 0.2442, 0.1204]}, {"w": "a", "b": [0.2489, 0.099, 0.2581, 0.1204]}, {"w": "(dense)", "b": [0.2628, 0.099, 0.3249, 0.1204]}, {"w": "NumPy", "b": [0.3297, 0.099, 0.3938, 0.1204]}, {"w": "array,", "b": [0.3986, 0.099, 0.4447, 0.1204]}, {"w": "just", "b": [0.4495, 0.099, 0.4799, 0.1204]}, {"w": "call", "b": [0.4846, 0.099, 0.5131, 0.1204]}, {"w": "the", "b": [0.5178, 0.099, 0.5442, 0.1204]}, {"w": "toarray()", "b": [0.5489, 0.1022, 0.638, 0.1173]}, {"w": "method:", "b": [0.6427, 0.099, 0.7125, 0.1204]}]}, {"id": "b_2", "type": "paragraph", "text": ">>> housing_cat_1hot.toarray() array([[1., 0., 0., 0., 0.], [1., 0., 0., 0., 0.], [0., 0., 0., 0., 1.], ..., [0., 1., 0., 0., 0.], [1., 0., 0., 0., 0.], [0., 0., 0., 1., 0.]])", "words": [{"w": ">>>", "b": [0.1766, 0.131, 0.2019, 0.1438]}, {"w": "housing_cat_1hot.toarray()", "b": [0.2103, 0.131, 0.4296, 0.1438]}, {"w": "array([[1.,", "b": [0.1766, 0.1464, 0.2694, 0.1592]}, {"w": "0.,", "b": [0.2778, 0.1464, 0.3031, 0.1592]}, {"w": "0.,", "b": [0.3115, 0.1464, 0.3368, 0.1592]}, {"w": "0.,", "b": [0.3452, 0.1464, 0.3705, 0.1592]}, {"w": "0.],", "b": [0.379, 0.1464, 0.4127, 0.1592]}, {"w": "[1.,", "b": [0.2356, 0.1618, 0.2694, 0.1747]}, {"w": "0.,", "b": [0.2778, 0.1618, 0.3031, 0.1747]}, {"w": "0.,", "b": [0.3115, 0.1618, 0.3368, 0.1747]}, {"w": "0.,", "b": [0.3452, 0.1618, 0.3705, 0.1747]}, {"w": "0.],", "b": [0.379, 0.1618, 0.4127, 0.1747]}, {"w": "[0.,", "b": [0.2356, 0.1772, 0.2694, 0.1901]}, {"w": "0.,", "b": [0.2778, 0.1772, 0.3031, 0.1901]}, {"w": "0.,", "b": [0.3115, 0.1772, 0.3368, 0.1901]}, {"w": "0.,", "b": [0.3452, 0.1772, 0.3705, 0.1901]}, {"w": "1.],", "b": [0.379, 0.1772, 0.4127, 0.1901]}, {"w": "...,", "b": [0.2356, 0.1927, 0.2694, 0.2055]}, {"w": "[0.,", "b": [0.2356, 0.2081, 0.2694, 0.2209]}, {"w": "1.,", "b": [0.2778, 0.2081, 0.3031, 0.2209]}, {"w": "0.,", "b": [0.3115, 0.2081, 0.3368, 0.2209]}, {"w": "0.,", "b": [0.3452, 0.2081, 0.3705, 0.2209]}, {"w": "0.],", "b": [0.379, 0.2081, 0.4127, 0.2209]}, {"w": "[1.,", "b": [0.2356, 0.2235, 0.2694, 0.2363]}, {"w": "0.,", "b": [0.2778, 0.2235, 0.3031, 0.2363]}, {"w": "0.,", "b": [0.3115, 0.2235, 0.3368, 0.2363]}, {"w": "0.,", "b": [0.3452, 0.2235, 0.3705, 0.2363]}, {"w": "0.],", "b": [0.379, 0.2235, 0.4127, 0.2363]}, {"w": "[0.,", "b": [0.2356, 0.2389, 0.2694, 0.2518]}, {"w": "0.,", "b": [0.2778, 0.2389, 0.3031, 0.2518]}, {"w": "0.,", "b": [0.3115, 0.2389, 0.3368, 0.2518]}, {"w": "1.,", "b": [0.3452, 0.2389, 0.3705, 0.2518]}, {"w": "0.]])", "b": [0.379, 0.2389, 0.4211, 0.2518]}]}, {"id": "b_3", "type": "paragraph", "text": "Once again, you can get the list of categories using the encoder’s categories_ instance variable:", "words": [{"w": "Once", "b": [0.1428, 0.2604, 0.1875, 0.2819]}, {"w": "again,", "b": [0.1979, 0.2604, 0.2477, 0.2819]}, {"w": "you", "b": [0.2581, 0.2604, 0.2894, 0.2819]}, {"w": "can", "b": [0.2998, 0.2604, 0.3291, 0.2819]}, {"w": "get", "b": [0.3396, 0.2604, 0.3645, 0.2819]}, {"w": "the", "b": [0.375, 0.2604, 0.4013, 0.2819]}, {"w": "list", "b": [0.4117, 0.2604, 0.4366, 0.2819]}, {"w": "of", "b": [0.447, 0.2604, 0.4638, 0.2819]}, {"w": "categories", "b": [0.4742, 0.2604, 0.5572, 0.2819]}, {"w": "using", "b": [0.5676, 0.2604, 0.6131, 0.2819]}, {"w": "the", "b": [0.6235, 0.2604, 0.6498, 0.2819]}, {"w": "encoder’s", "b": [0.6603, 0.2604, 0.7378, 0.2819]}, {"w": "categories_", "b": [0.7483, 0.2636, 0.8572, 0.2787]}, {"w": "instance", "b": [0.1429, 0.2795, 0.212, 0.3009]}, {"w": "variable:", "b": [0.2168, 0.2795, 0.2875, 0.3009]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> cat_encoder.categories_ [array(['<1H OCEAN', 'INLAND', 'ISLAND', 'NEAR BAY', 'NEAR OCEAN'], dtype=object)]", "words": [{"w": ">>>", "b": [0.1766, 0.3115, 0.2019, 0.3243]}, {"w": "cat_encoder.categories_", "b": [0.2103, 0.3115, 0.4043, 0.3243]}, {"w": "[array(['<1H", "b": [0.1766, 0.3269, 0.2778, 0.3397]}, {"w": "OCEAN',", "b": [0.2862, 0.3269, 0.3452, 0.3397]}, {"w": "'INLAND',", "b": [0.3537, 0.3269, 0.4296, 0.3397]}, {"w": "'ISLAND',", "b": [0.438, 0.3269, 0.5139, 0.3397]}, {"w": "'NEAR", "b": [0.5223, 0.3269, 0.5645, 0.3397]}, {"w": "BAY',", "b": [0.5729, 0.3269, 0.6151, 0.3397]}, {"w": "'NEAR", "b": [0.6235, 0.3269, 0.6657, 0.3397]}, {"w": "OCEAN'],", "b": [0.6741, 0.3269, 0.7416, 0.3397]}, {"w": "dtype=object)]", "b": [0.2356, 0.3423, 0.3537, 0.3552]}]}, {"id": "b_5", "type": "paragraph", "text": "If a categorical attribute has a large number of possible categories (e.g., country code, profession, species, etc.), then one-hot encod‐ ing will result in a large number of input features. This may slow down training and degrade performance. If this happens, you may want to replace the categorical input with useful numerical features related to the categories: for example, you could replace the ocean_proximity feature with the distance to the ocean (similarly, a country code could be replaced with the country’s population and GDP per capita). Alternatively, you could replace each category with a learnable low dimensional vector called an embedding. Each category’s representation would be learned during training: this is an example of representation learning (see Chapter 13 and ??? for more details).", "words": [{"w": "If", "b": [0.2714, 0.3768, 0.2835, 0.3963]}, {"w": "a", "b": [0.2897, 0.3768, 0.2981, 0.3963]}, {"w": "categorical", "b": [0.3043, 0.3768, 0.3863, 0.3963]}, {"w": "attribute", "b": [0.3925, 0.3768, 0.458, 0.3963]}, {"w": "has", "b": [0.4642, 0.3768, 0.4897, 0.3963]}, {"w": "a", "b": [0.4959, 0.3768, 0.5043, 0.3963]}, {"w": "large", "b": [0.5105, 0.3768, 0.5477, 0.3963]}, {"w": "number", "b": [0.5539, 0.3768, 0.6145, 0.3963]}, {"w": "of", "b": [0.6207, 0.3768, 0.6361, 0.3963]}, {"w": "possible", "b": [0.6423, 0.3768, 0.7037, 0.3963]}, {"w": "categories", "b": [0.7099, 0.3768, 0.7857, 0.3963]}, {"w": "(e.g.,", "b": [0.2714, 0.3942, 0.308, 0.4138]}, {"w": "country", "b": [0.3143, 0.3942, 0.3744, 0.4138]}, {"w": "code,", "b": [0.3807, 0.3942, 0.4209, 0.4138]}, {"w": "profession,", "b": [0.4272, 0.3942, 0.5112, 0.4138]}, {"w": "species,", "b": [0.5175, 0.3942, 0.5751, 0.4138]}, {"w": "etc.),", "b": [0.5814, 0.3942, 0.6186, 0.4138]}, {"w": "then", "b": [0.6249, 0.3942, 0.6594, 0.4138]}, {"w": "one-hot", "b": [0.6656, 0.3942, 0.7263, 0.4138]}, {"w": "encod‐", "b": [0.7326, 0.3942, 0.7857, 0.4138]}, {"w": "ing", "b": [0.2714, 0.4116, 0.2958, 0.4312]}, {"w": "will", "b": [0.3022, 0.4116, 0.33, 0.4312]}, {"w": "result", "b": [0.3363, 0.4116, 0.3792, 0.4312]}, {"w": "in", "b": [0.3855, 0.4116, 0.401, 0.4312]}, {"w": "a", "b": [0.4073, 0.4116, 0.4157, 0.4312]}, {"w": "large", "b": [0.422, 0.4116, 0.4593, 0.4312]}, {"w": "number", "b": [0.4656, 0.4116, 0.5262, 0.4312]}, {"w": "of", "b": [0.5326, 0.4116, 0.5479, 0.4312]}, {"w": "input", "b": [0.5542, 0.4116, 0.5953, 0.4312]}, {"w": "features.", "b": [0.6016, 0.4116, 0.6658, 0.4312]}, {"w": "This", "b": [0.6721, 0.4116, 0.7061, 0.4312]}, {"w": "may", "b": [0.7124, 0.4116, 0.7448, 0.4312]}, {"w": "slow", "b": [0.7512, 0.4116, 0.7857, 0.4312]}, {"w": "down", "b": [0.2714, 0.429, 0.3146, 0.4486]}, {"w": "training", "b": [0.3201, 0.429, 0.3813, 0.4486]}, {"w": "and", "b": [0.3867, 0.429, 0.4155, 0.4486]}, {"w": "degrade", "b": [0.4209, 0.429, 0.4816, 0.4486]}, {"w": "performance.", "b": [0.487, 0.429, 0.5895, 0.4486]}, {"w": "If", "b": [0.5949, 0.429, 0.607, 0.4486]}, {"w": "this", "b": [0.6124, 0.429, 0.6405, 0.4486]}, {"w": "happens,", "b": [0.6459, 0.429, 0.7139, 0.4486]}, {"w": "you", "b": [0.7193, 0.429, 0.7479, 0.4486]}, {"w": "may", "b": [0.7533, 0.429, 0.7857, 0.4486]}, {"w": "want", "b": [0.2714, 0.4464, 0.3087, 0.466]}, {"w": "to", "b": [0.3134, 0.4464, 0.329, 0.466]}, {"w": "replace", "b": [0.3337, 0.4464, 0.3882, 0.466]}, {"w": "the", "b": [0.393, 0.4464, 0.4171, 0.466]}, {"w": "categorical", "b": [0.4218, 0.4464, 0.5038, 0.466]}, {"w": "input", "b": [0.5086, 0.4464, 0.5496, 0.466]}, {"w": "with", "b": [0.5544, 0.4464, 0.5885, 0.466]}, {"w": "useful", "b": [0.5933, 0.4464, 0.6391, 0.466]}, {"w": "numerical", "b": [0.6439, 0.4464, 0.7211, 0.466]}, {"w": "features", "b": [0.7259, 0.4464, 0.7857, 0.466]}, {"w": "related", "b": [0.2714, 0.4638, 0.3233, 0.4834]}, {"w": "to", "b": [0.3347, 0.4638, 0.3502, 0.4834]}, {"w": "the", "b": [0.3616, 0.4638, 0.3857, 0.4834]}, {"w": "categories:", "b": [0.3971, 0.4638, 0.4772, 0.4834]}, {"w": "for", "b": [0.4886, 0.4638, 0.511, 0.4834]}, {"w": "example,", "b": [0.5224, 0.4638, 0.5903, 0.4834]}, {"w": "you", "b": [0.6017, 0.4638, 0.6303, 0.4834]}, {"w": "could", "b": [0.6416, 0.4638, 0.6844, 0.4834]}, {"w": "replace", "b": [0.6958, 0.4638, 0.7503, 0.4834]}, {"w": "the", "b": [0.7616, 0.4638, 0.7857, 0.4834]}, {"w": "ocean_proximity", "b": [0.2714, 0.485, 0.4071, 0.4988]}, {"w": "feature", "b": [0.4127, 0.4821, 0.4655, 0.5017]}, {"w": "with", "b": [0.471, 0.4821, 0.5051, 0.5017]}, {"w": "the", "b": [0.5107, 0.4821, 0.5347, 0.5017]}, {"w": "distance", "b": [0.5403, 0.4821, 0.6032, 0.5017]}, {"w": "to", "b": [0.6087, 0.4821, 0.6242, 0.5017]}, {"w": "the", "b": [0.6298, 0.4821, 0.6538, 0.5017]}, {"w": "ocean", "b": [0.6594, 0.4821, 0.704, 0.5017]}, {"w": "(similarly,", "b": [0.7096, 0.4821, 0.7857, 0.5017]}, {"w": "a", "b": [0.2714, 0.4995, 0.2798, 0.5191]}, {"w": "country", "b": [0.2842, 0.4995, 0.3443, 0.5191]}, {"w": "code", "b": [0.3488, 0.4995, 0.3847, 0.5191]}, {"w": "could", "b": [0.3892, 0.4995, 0.4319, 0.5191]}, {"w": "be", "b": [0.4364, 0.4995, 0.4542, 0.5191]}, {"w": "replaced", "b": [0.4586, 0.4995, 0.5232, 0.5191]}, {"w": "with", "b": [0.5276, 0.4995, 0.5618, 0.5191]}, {"w": "the", "b": [0.5662, 0.4995, 0.5903, 0.5191]}, {"w": "country’s", "b": [0.5948, 0.4995, 0.6643, 0.5191]}, {"w": "population", "b": [0.6688, 0.4995, 0.7524, 0.5191]}, {"w": "and", "b": [0.7569, 0.4995, 0.7857, 0.5191]}, {"w": "GDP", "b": [0.2714, 0.5169, 0.3097, 0.5365]}, {"w": "per", "b": [0.3182, 0.5169, 0.3433, 0.5365]}, {"w": "capita).", "b": [0.3517, 0.5169, 0.408, 0.5365]}, {"w": "Alternatively,", "b": [0.4164, 0.5169, 0.5181, 0.5365]}, {"w": "you", "b": [0.5266, 0.5169, 0.5551, 0.5365]}, {"w": "could", "b": [0.5636, 0.5169, 0.6063, 0.5365]}, {"w": "replace", "b": [0.6147, 0.5169, 0.6692, 0.5365]}, {"w": "each", "b": [0.6776, 0.5169, 0.7123, 0.5365]}, {"w": "category", "b": [0.7208, 0.5169, 0.7857, 0.5365]}, {"w": "with", "b": [0.2714, 0.5343, 0.3055, 0.5539]}, {"w": "a", "b": [0.3107, 0.5343, 0.3191, 0.5539]}, {"w": "learnable", "b": [0.3243, 0.5343, 0.394, 0.5539]}, {"w": "low", "b": [0.3992, 0.5343, 0.4268, 0.5539]}, {"w": "dimensional", "b": [0.432, 0.5343, 0.5266, 0.5539]}, {"w": "vector", "b": [0.5318, 0.5343, 0.5794, 0.5539]}, {"w": "called", "b": [0.5846, 0.5343, 0.6288, 0.5539]}, {"w": "an", "b": [0.634, 0.5343, 0.6528, 0.5539]}, {"w": "embedding.", "b": [0.6579, 0.5341, 0.7431, 0.5539]}, {"w": "Each", "b": [0.7483, 0.5343, 0.7857, 0.5539]}, {"w": "category’s", "b": [0.2714, 0.5517, 0.3458, 0.5713]}, {"w": "representation", "b": [0.352, 0.5517, 0.4623, 0.5713]}, {"w": "would", "b": [0.4685, 0.5517, 0.5163, 0.5713]}, {"w": "be", "b": [0.5225, 0.5517, 0.5403, 0.5713]}, {"w": "learned", "b": [0.5465, 0.5517, 0.6034, 0.5713]}, {"w": "during", "b": [0.6096, 0.5517, 0.6613, 0.5713]}, {"w": "training:", "b": [0.6675, 0.5517, 0.7331, 0.5713]}, {"w": "this", "b": [0.7393, 0.5517, 0.7674, 0.5713]}, {"w": "is", "b": [0.7736, 0.5517, 0.7857, 0.5713]}, {"w": "an", "b": [0.2714, 0.5692, 0.2902, 0.5887]}, {"w": "example", "b": [0.2969, 0.5692, 0.3605, 0.5887]}, {"w": "of", "b": [0.3673, 0.5692, 0.3826, 0.5887]}, {"w": "representation", "b": [0.3893, 0.569, 0.4947, 0.5887]}, {"w": "learning", "b": [0.5015, 0.569, 0.5625, 0.5887]}, {"w": "(see", "b": [0.5692, 0.5692, 0.599, 0.5887]}, {"w": "Chapter", "b": [0.6057, 0.5692, 0.6675, 0.5887]}, {"w": "13", "b": [0.6743, 0.5692, 0.6926, 0.5887]}, {"w": "and", "b": [0.6993, 0.5692, 0.7281, 0.5887]}, {"w": "???", "b": [0.7349, 0.5692, 0.7565, 0.5887]}, {"w": "for", "b": [0.7633, 0.5692, 0.7857, 0.5887]}, {"w": "more", "b": [0.2714, 0.5866, 0.3119, 0.6061]}, {"w": "details).", "b": [0.3162, 0.5866, 0.3764, 0.6061]}]}, {"id": "b_6", "type": "paragraph", "text": "Custom Transformers", "words": [{"w": "Custom", "b": [0.1429, 0.6237, 0.2201, 0.6523]}, {"w": "Transformers", "b": [0.2251, 0.6237, 0.3615, 0.6523]}]}, {"id": "b_7", "type": "paragraph", "text": "Although Scikit-Learn provides many useful transformers, you will need to write your own for tasks such as custom cleanup operations or combining specific attributes. You will want your transformer to work seamlessly with Scikit-Learn func‐ tionalities (such as pipelines), and since Scikit-Learn relies on duck typing (not inher‐ itance), all you need is to create a class and implement three methods: fit() (returning self), transform(), and fit_transform(). You can get the last one for free by simply adding TransformerMixin as a base class. Also, if you add BaseEstima tor as a base class (and avoid *args and **kargs in your constructor) you will get two extra methods (get_params() and set_params()) that will be useful for auto‐", "words": [{"w": "Although", "b": [0.1428, 0.6582, 0.2226, 0.6796]}, {"w": "Scikit-Learn", "b": [0.2315, 0.6582, 0.3338, 0.6796]}, {"w": "provides", "b": [0.3427, 0.6582, 0.4147, 0.6796]}, {"w": "many", "b": [0.4236, 0.6582, 0.4703, 0.6796]}, {"w": "useful", "b": [0.4792, 0.6582, 0.5293, 0.6796]}, {"w": "transformers,", "b": [0.5382, 0.6582, 0.651, 0.6796]}, {"w": "you", "b": [0.6599, 0.6582, 0.6912, 0.6796]}, {"w": "will", "b": [0.7001, 0.6582, 0.7305, 0.6796]}, {"w": "need", "b": [0.7394, 0.6582, 0.7795, 0.6796]}, {"w": "to", "b": [0.7884, 0.6582, 0.8054, 0.6796]}, {"w": "write", "b": [0.8143, 0.6582, 0.8571, 0.6796]}, {"w": "your", "b": [0.1429, 0.6772, 0.1818, 0.6986]}, {"w": "own", "b": [0.1938, 0.6772, 0.2301, 0.6986]}, {"w": "for", "b": [0.242, 0.6772, 0.2665, 0.6986]}, {"w": "tasks", "b": [0.2785, 0.6772, 0.3196, 0.6986]}, {"w": "such", "b": [0.3315, 0.6772, 0.3702, 0.6986]}, {"w": "as", "b": [0.3821, 0.6772, 0.3989, 0.6986]}, {"w": "custom", "b": [0.4108, 0.6772, 0.4724, 0.6986]}, {"w": "cleanup", "b": [0.4843, 0.6772, 0.5494, 0.6986]}, {"w": "operations", "b": [0.5613, 0.6772, 0.6498, 0.6986]}, {"w": "or", "b": [0.6618, 0.6772, 0.6801, 0.6986]}, {"w": "combining", "b": [0.692, 0.6772, 0.7828, 0.6986]}, {"w": "specific", "b": [0.7948, 0.6772, 0.8571, 0.6986]}, {"w": "attributes.", "b": [0.1429, 0.6962, 0.2269, 0.7177]}, {"w": "You", "b": [0.232, 0.6962, 0.2643, 0.7177]}, {"w": "will", "b": [0.2694, 0.6962, 0.2998, 0.7177]}, {"w": "want", "b": [0.3049, 0.6962, 0.3457, 0.7177]}, {"w": "your", "b": [0.3507, 0.6962, 0.3897, 0.7177]}, {"w": "transformer", "b": [0.3948, 0.6962, 0.4952, 0.7177]}, {"w": "to", "b": [0.5003, 0.6962, 0.5173, 0.7177]}, {"w": "work", "b": [0.5224, 0.6962, 0.5654, 0.7177]}, {"w": "seamlessly", "b": [0.5704, 0.6962, 0.6574, 0.7177]}, {"w": "with", "b": [0.6625, 0.6962, 0.6998, 0.7177]}, {"w": "Scikit-Learn", "b": [0.7049, 0.6962, 0.8072, 0.7177]}, {"w": "func‐", "b": [0.8123, 0.6962, 0.8571, 0.7177]}, {"w": "tionalities", "b": [0.1429, 0.7153, 0.2252, 0.7367]}, {"w": "(such", "b": [0.2301, 0.7153, 0.2759, 0.7367]}, {"w": "as", "b": [0.2807, 0.7153, 0.2975, 0.7367]}, {"w": "pipelines),", "b": [0.3023, 0.7153, 0.3893, 0.7367]}, {"w": "and", "b": [0.3941, 0.7153, 0.4257, 0.7367]}, {"w": "since", "b": [0.4305, 0.7153, 0.4728, 0.7367]}, {"w": "Scikit-Learn", "b": [0.4776, 0.7153, 0.5799, 0.7367]}, {"w": "relies", "b": [0.5847, 0.7153, 0.6286, 0.7367]}, {"w": "on", "b": [0.6334, 0.7153, 0.6554, 0.7367]}, {"w": "duck", "b": [0.6602, 0.7153, 0.7015, 0.7367]}, {"w": "typing", "b": [0.7063, 0.7153, 0.7598, 0.7367]}, {"w": "(not", "b": [0.7646, 0.7153, 0.8002, 0.7367]}, {"w": "inher‐", "b": [0.805, 0.7153, 0.8571, 0.7367]}, {"w": "itance),", "b": [0.1428, 0.7352, 0.205, 0.7567]}, {"w": "all", "b": [0.2159, 0.7352, 0.2356, 0.7567]}, {"w": "you", "b": [0.2465, 0.7352, 0.2777, 0.7567]}, {"w": "need", "b": [0.2887, 0.7352, 0.3288, 0.7567]}, {"w": "is", "b": [0.3397, 0.7352, 0.3529, 0.7567]}, {"w": "to", "b": [0.3638, 0.7352, 0.3808, 0.7567]}, {"w": "create", "b": [0.3917, 0.7352, 0.4411, 0.7567]}, {"w": "a", "b": [0.452, 0.7352, 0.4612, 0.7567]}, {"w": "class", "b": [0.4721, 0.7352, 0.5106, 0.7567]}, {"w": "and", "b": [0.5215, 0.7352, 0.5531, 0.7567]}, {"w": "implement", "b": [0.564, 0.7352, 0.6546, 0.7567]}, {"w": "three", "b": [0.6655, 0.7352, 0.7084, 0.7567]}, {"w": "methods:", "b": [0.7193, 0.7352, 0.7967, 0.7567]}, {"w": "fit()", "b": [0.8077, 0.7384, 0.8571, 0.7535]}, {"w": "(returning", "b": [0.1429, 0.7552, 0.2299, 0.7766]}, {"w": "self),", "b": [0.2372, 0.7552, 0.2888, 0.7766]}, {"w": "transform(),", "b": [0.2961, 0.7552, 0.4097, 0.7766]}, {"w": "and", "b": [0.417, 0.7552, 0.4486, 0.7766]}, {"w": "fit_transform().", "b": [0.4559, 0.7552, 0.6091, 0.7766]}, {"w": "You", "b": [0.6164, 0.7552, 0.6488, 0.7766]}, {"w": "can", "b": [0.6561, 0.7552, 0.6854, 0.7766]}, {"w": "get", "b": [0.6928, 0.7552, 0.7177, 0.7766]}, {"w": "the", "b": [0.725, 0.7552, 0.7514, 0.7766]}, {"w": "last", "b": [0.7587, 0.7552, 0.7871, 0.7766]}, {"w": "one", "b": [0.7944, 0.7552, 0.8253, 0.7766]}, {"w": "for", "b": [0.8326, 0.7552, 0.8571, 0.7766]}, {"w": "free", "b": [0.1429, 0.7751, 0.1745, 0.7965]}, {"w": "by", "b": [0.1798, 0.7751, 0.1999, 0.7965]}, {"w": "simply", "b": [0.2053, 0.7751, 0.2609, 0.7965]}, {"w": "adding", "b": [0.2663, 0.7751, 0.3242, 0.7965]}, {"w": "TransformerMixin", "b": [0.3295, 0.7783, 0.4878, 0.7934]}, {"w": "as", "b": [0.4932, 0.7751, 0.51, 0.7965]}, {"w": "a", "b": [0.5153, 0.7751, 0.5245, 0.7965]}, {"w": "base", "b": [0.5298, 0.7751, 0.566, 0.7965]}, {"w": "class.", "b": [0.5714, 0.7751, 0.6147, 0.7965]}, {"w": "Also,", "b": [0.62, 0.7751, 0.6621, 0.7965]}, {"w": "if", "b": [0.6674, 0.7751, 0.6792, 0.7965]}, {"w": "you", "b": [0.6845, 0.7751, 0.7158, 0.7965]}, {"w": "add", "b": [0.7211, 0.7751, 0.7523, 0.7965]}, {"w": "BaseEstima", "b": [0.7576, 0.7783, 0.8566, 0.7934]}, {"w": "tor", "b": [0.1429, 0.7983, 0.1725, 0.8133]}, {"w": "as", "b": [0.1794, 0.7951, 0.1962, 0.8165]}, {"w": "a", "b": [0.203, 0.7951, 0.2121, 0.8165]}, {"w": "base", "b": [0.219, 0.7951, 0.2552, 0.8165]}, {"w": "class", "b": [0.262, 0.7951, 0.3005, 0.8165]}, {"w": "(and", "b": [0.3073, 0.7951, 0.3461, 0.8165]}, {"w": "avoid", "b": [0.3529, 0.7951, 0.3985, 0.8165]}, {"w": "*args", "b": [0.4054, 0.7983, 0.4548, 0.8133]}, {"w": "and", "b": [0.4617, 0.7951, 0.4932, 0.8165]}, {"w": "**kargs", "b": [0.5, 0.7983, 0.5693, 0.8133]}, {"w": "in", "b": [0.5761, 0.7951, 0.5931, 0.8165]}, {"w": "your", "b": [0.5999, 0.7951, 0.6389, 0.8165]}, {"w": "constructor)", "b": [0.6457, 0.7951, 0.7501, 0.8165]}, {"w": "you", "b": [0.7569, 0.7951, 0.7881, 0.8165]}, {"w": "will", "b": [0.795, 0.7951, 0.8254, 0.8165]}, {"w": "get", "b": [0.8322, 0.7951, 0.8571, 0.8165]}, {"w": "two", "b": [0.1429, 0.815, 0.1741, 0.8364]}, {"w": "extra", "b": [0.1817, 0.815, 0.2236, 0.8364]}, {"w": "methods", "b": [0.2313, 0.815, 0.3039, 0.8364]}, {"w": "(get_params()", "b": [0.3115, 0.815, 0.4375, 0.8364]}, {"w": "and", "b": [0.4451, 0.815, 0.4767, 0.8364]}, {"w": "set_params())", "b": [0.4843, 0.815, 0.6102, 0.8364]}, {"w": "that", "b": [0.6178, 0.815, 0.6504, 0.8364]}, {"w": "will", "b": [0.658, 0.815, 0.6884, 0.8364]}, {"w": "be", "b": [0.6961, 0.815, 0.7155, 0.8364]}, {"w": "useful", "b": [0.7231, 0.815, 0.7732, 0.8364]}, {"w": "for", "b": [0.7808, 0.815, 0.8053, 0.8364]}, {"w": "auto‐", "b": [0.8129, 0.815, 0.8571, 0.8364]}]}, {"id": "b_8", "type": "paragraph", "text": "Prepare the Data for Machine Learning Algorithms | 71", "words": [{"w": "Prepare", "b": [0.5082, 0.9225, 0.5544, 0.9388]}, {"w": "the", "b": [0.5572, 0.9225, 0.5771, 0.9388]}, {"w": "Data", "b": [0.58, 0.9225, 0.6076, 0.9388]}, {"w": "for", "b": [0.6104, 0.9225, 0.6273, 0.9388]}, {"w": "Machine", "b": [0.6301, 0.9225, 0.68, 0.9388]}, {"w": "Learning", "b": [0.6828, 0.9225, 0.7351, 0.9388]}, {"w": "Algorithms", "b": [0.7379, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "71", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 98, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "matic hyperparameter tuning. For example, here is a small transformer class that adds the combined attributes we discussed earlier:", "words": [{"w": "matic", "b": [0.1429, 0.0791, 0.1894, 0.1005]}, {"w": "hyperparameter", "b": [0.1941, 0.0791, 0.3276, 0.1005]}, {"w": "tuning.", "b": [0.3324, 0.0791, 0.3927, 0.1005]}, {"w": "For", "b": [0.3974, 0.0791, 0.4264, 0.1005]}, {"w": "example,", "b": [0.4311, 0.0791, 0.5054, 0.1005]}, {"w": "here", "b": [0.5101, 0.0791, 0.5467, 0.1005]}, {"w": "is", "b": [0.5514, 0.0791, 0.5646, 0.1005]}, {"w": "a", "b": [0.5694, 0.0791, 0.5785, 0.1005]}, {"w": "small", "b": [0.5833, 0.0791, 0.6276, 0.1005]}, {"w": "transformer", "b": [0.6324, 0.0791, 0.7328, 0.1005]}, {"w": "class", "b": [0.7375, 0.0791, 0.7761, 0.1005]}, {"w": "that", "b": [0.7808, 0.0791, 0.8134, 0.1005]}, {"w": "adds", "b": [0.8181, 0.0791, 0.8569, 0.1005]}, {"w": "the", "b": [0.1429, 0.0981, 0.1692, 0.1195]}, {"w": "combined", "b": [0.1739, 0.0981, 0.2578, 0.1195]}, {"w": "attributes", "b": [0.2626, 0.0981, 0.3418, 0.1195]}, {"w": "we", "b": [0.3466, 0.0981, 0.3697, 0.1195]}, {"w": "discussed", "b": [0.3744, 0.0981, 0.4537, 0.1195]}, {"w": "earlier:", "b": [0.4584, 0.0981, 0.5168, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "from sklearn.base import BaseEstimator, TransformerMixin", "words": [{"w": "from", "b": [0.1766, 0.1301, 0.2103, 0.1429]}, {"w": "sklearn.base", "b": [0.2187, 0.1301, 0.3199, 0.1429]}, {"w": "import", "b": [0.3284, 0.1301, 0.379, 0.1429]}, {"w": "BaseEstimator,", "b": [0.3874, 0.1301, 0.5054, 0.1429]}, {"w": "TransformerMixin", "b": [0.5139, 0.1301, 0.6488, 0.1429]}]}, {"id": "b_2", "type": "equation", "text": "rooms_ix, bedrooms_ix, population_ix, households_ix = 3, 4, 5, 6", "words": [{"w": "rooms_ix,", "b": [0.1766, 0.1609, 0.2525, 0.1738]}, {"w": "bedrooms_ix,", "b": [0.2609, 0.1609, 0.3621, 0.1738]}, {"w": "population_ix,", "b": [0.3705, 0.1609, 0.4886, 0.1738]}, {"w": "households_ix", "b": [0.497, 0.1609, 0.6066, 0.1738]}, {"w": "=", "b": [0.6151, 0.1609, 0.6235, 0.1738]}, {"w": "3,", "b": [0.6319, 0.1609, 0.6488, 0.1738]}, {"w": "4,", "b": [0.6572, 0.1609, 0.6741, 0.1738]}, {"w": "5,", "b": [0.6825, 0.1609, 0.6994, 0.1738]}, {"w": "6", "b": [0.7078, 0.1609, 0.7163, 0.1738]}]}, {"id": "b_3", "type": "paragraph", "text": "class CombinedAttributesAdder(BaseEstimator, TransformerMixin): def __init__(self, add_bedrooms_per_room = True): # no *args or **kargs self.add_bedrooms_per_room = add_bedrooms_per_room def fit(self, X, y=None): return self # nothing else to do def transform(self, X, y=None): rooms_per_household = X[:, rooms_ix] / X[:, households_ix] population_per_household = X[:, population_ix] / X[:, households_ix] if self.add_bedrooms_per_room: bedrooms_per_room = X[:, bedrooms_ix] / X[:, rooms_ix] return np.c_[X, rooms_per_household, population_per_household, bedrooms_per_room] else: return np.c_[X, rooms_per_household, population_per_household]", "words": [{"w": "class", "b": [0.1766, 0.1918, 0.2187, 0.2046]}, {"w": "CombinedAttributesAdder(BaseEstimator,", "b": [0.2272, 0.1918, 0.5476, 0.2046]}, {"w": "TransformerMixin):", "b": [0.556, 0.1918, 0.7078, 0.2046]}, {"w": "def", "b": [0.2103, 0.2072, 0.2356, 0.22]}, {"w": "__init__(self,", "b": [0.244, 0.2072, 0.3621, 0.22]}, {"w": "add_bedrooms_per_room", "b": [0.3705, 0.2072, 0.5476, 0.22]}, {"w": "=", "b": [0.556, 0.2072, 0.5645, 0.22]}, {"w": "True):", "b": [0.5729, 0.2072, 0.6235, 0.22]}, {"w": "#", "b": [0.6319, 0.2072, 0.6404, 0.22]}, {"w": "no", "b": [0.6488, 0.2072, 0.6657, 0.22]}, {"w": "*args", "b": [0.6741, 0.2072, 0.7163, 0.22]}, {"w": "or", "b": [0.7247, 0.2072, 0.7416, 0.22]}, {"w": "**kargs", "b": [0.75, 0.2072, 0.809, 0.22]}, {"w": "self.add_bedrooms_per_room", "b": [0.244, 0.2226, 0.4633, 0.2354]}, {"w": "=", "b": [0.4717, 0.2226, 0.4802, 0.2354]}, {"w": "add_bedrooms_per_room", "b": [0.4886, 0.2226, 0.6657, 0.2354]}, {"w": "def", "b": [0.2103, 0.238, 0.2356, 0.2509]}, {"w": "fit(self,", "b": [0.244, 0.238, 0.3199, 0.2509]}, {"w": "X,", "b": [0.3284, 0.238, 0.3452, 0.2509]}, {"w": "y=None):", "b": [0.3537, 0.238, 0.4211, 0.2509]}, {"w": "return", "b": [0.244, 0.2534, 0.2946, 0.2663]}, {"w": "self", "b": [0.3031, 0.2534, 0.3368, 0.2663]}, {"w": "#", "b": [0.3537, 0.2534, 0.3621, 0.2663]}, {"w": "nothing", "b": [0.3705, 0.2534, 0.4296, 0.2663]}, {"w": "else", "b": [0.438, 0.2534, 0.4717, 0.2663]}, {"w": "to", "b": [0.4802, 0.2534, 0.497, 0.2663]}, {"w": "do", "b": [0.5054, 0.2534, 0.5223, 0.2663]}, {"w": "def", "b": [0.2103, 0.2689, 0.2356, 0.2817]}, {"w": "transform(self,", "b": [0.244, 0.2689, 0.3705, 0.2817]}, {"w": "X,", "b": [0.379, 0.2689, 0.3958, 0.2817]}, {"w": "y=None):", "b": [0.4043, 0.2689, 0.4717, 0.2817]}, {"w": "rooms_per_household", "b": [0.244, 0.2843, 0.4043, 0.2971]}, {"w": "=", "b": [0.4127, 0.2843, 0.4211, 0.2971]}, {"w": "X[:,", "b": [0.4296, 0.2843, 0.4633, 0.2971]}, {"w": "rooms_ix]", "b": [0.4717, 0.2843, 0.5476, 0.2971]}, {"w": "/", "b": [0.556, 0.2843, 0.5645, 0.2971]}, {"w": "X[:,", "b": [0.5729, 0.2843, 0.6066, 0.2971]}, {"w": "households_ix]", "b": [0.6151, 0.2843, 0.7331, 0.2971]}, {"w": "population_per_household", "b": [0.244, 0.2997, 0.4464, 0.3125]}, {"w": "=", "b": [0.4549, 0.2997, 0.4633, 0.3125]}, {"w": "X[:,", "b": [0.4717, 0.2997, 0.5054, 0.3125]}, {"w": "population_ix]", "b": [0.5139, 0.2997, 0.6319, 0.3125]}, {"w": "/", "b": [0.6404, 0.2997, 0.6488, 0.3125]}, {"w": "X[:,", "b": [0.6572, 0.2997, 0.691, 0.3125]}, {"w": "households_ix]", "b": [0.6994, 0.2997, 0.8175, 0.3125]}, {"w": "if", "b": [0.244, 0.3151, 0.2609, 0.328]}, {"w": "self.add_bedrooms_per_room:", "b": [0.2693, 0.3151, 0.497, 0.328]}, {"w": "bedrooms_per_room", "b": [0.2778, 0.3305, 0.4211, 0.3434]}, {"w": "=", "b": [0.4296, 0.3305, 0.438, 0.3434]}, {"w": "X[:,", "b": [0.4464, 0.3305, 0.4802, 0.3434]}, {"w": "bedrooms_ix]", "b": [0.4886, 0.3305, 0.5898, 0.3434]}, {"w": "/", "b": [0.5982, 0.3305, 0.6066, 0.3434]}, {"w": "X[:,", "b": [0.6151, 0.3305, 0.6488, 0.3434]}, {"w": "rooms_ix]", "b": [0.6572, 0.3305, 0.7331, 0.3434]}, {"w": "return", "b": [0.2778, 0.346, 0.3284, 0.3588]}, {"w": "np.c_[X,", "b": [0.3368, 0.346, 0.4043, 0.3588]}, {"w": "rooms_per_household,", "b": [0.4127, 0.346, 0.5813, 0.3588]}, {"w": "population_per_household,", "b": [0.5898, 0.346, 0.8006, 0.3588]}, {"w": "bedrooms_per_room]", "b": [0.3874, 0.3614, 0.5392, 0.3742]}, {"w": "else:", "b": [0.244, 0.3768, 0.2862, 0.3896]}, {"w": "return", "b": [0.2778, 0.3922, 0.3284, 0.4051]}, {"w": "np.c_[X,", "b": [0.3368, 0.3922, 0.4043, 0.4051]}, {"w": "rooms_per_household,", "b": [0.4127, 0.3922, 0.5813, 0.4051]}, {"w": "population_per_household]", "b": [0.5898, 0.3922, 0.8006, 0.4051]}]}, {"id": "b_4", "type": "paragraph", "text": "attr_adder = CombinedAttributesAdder(add_bedrooms_per_room=False) housing_extra_attribs = attr_adder.transform(housing.values)", "words": [{"w": "attr_adder", "b": [0.1766, 0.4231, 0.2609, 0.4359]}, {"w": "=", "b": [0.2693, 0.4231, 0.2778, 0.4359]}, {"w": "CombinedAttributesAdder(add_bedrooms_per_room=False)", "b": [0.2862, 0.4231, 0.7247, 0.4359]}, {"w": "housing_extra_attribs", "b": [0.1766, 0.4385, 0.3537, 0.4513]}, {"w": "=", "b": [0.3621, 0.4385, 0.3705, 0.4513]}, {"w": "attr_adder.transform(housing.values)", "b": [0.379, 0.4385, 0.6825, 0.4513]}]}, {"id": "b_5", "type": "paragraph", "text": "In this example the transformer has one hyperparameter, add_bedrooms_per_room, set to True by default (it is often helpful to provide sensible defaults). This hyperpara‐ meter will allow you to easily find out whether adding this attribute helps the Machine Learning algorithms or not. More generally, you can add a hyperparameter to gate any data preparation step that you are not 100% sure about. The more you automate these data preparation steps, the more combinations you can automatically try out, making it much more likely that you will find a great combination (and sav‐ ing you a lot of time).", "words": [{"w": "In", "b": [0.1429, 0.46, 0.1614, 0.4814]}, {"w": "this", "b": [0.1689, 0.46, 0.1996, 0.4814]}, {"w": "example", "b": [0.2072, 0.46, 0.2767, 0.4814]}, {"w": "the", "b": [0.2843, 0.46, 0.3106, 0.4814]}, {"w": "transformer", "b": [0.3182, 0.46, 0.4186, 0.4814]}, {"w": "has", "b": [0.4262, 0.46, 0.4541, 0.4814]}, {"w": "one", "b": [0.4617, 0.46, 0.4925, 0.4814]}, {"w": "hyperparameter,", "b": [0.5001, 0.46, 0.637, 0.4814]}, {"w": "add_bedrooms_per_room,", "b": [0.6446, 0.46, 0.8572, 0.4814]}, {"w": "set", "b": [0.1429, 0.4799, 0.1657, 0.5014]}, {"w": "to", "b": [0.1704, 0.4799, 0.1874, 0.5014]}, {"w": "True", "b": [0.1926, 0.4831, 0.2322, 0.4982]}, {"w": "by", "b": [0.2371, 0.4799, 0.2573, 0.5014]}, {"w": "default", "b": [0.2622, 0.4799, 0.3197, 0.5014]}, {"w": "(it", "b": [0.3246, 0.4799, 0.3438, 0.5014]}, {"w": "is", "b": [0.3487, 0.4799, 0.362, 0.5014]}, {"w": "often", "b": [0.3669, 0.4799, 0.4103, 0.5014]}, {"w": "helpful", "b": [0.4153, 0.4799, 0.4739, 0.5014]}, {"w": "to", "b": [0.4789, 0.4799, 0.4959, 0.5014]}, {"w": "provide", "b": [0.5008, 0.4799, 0.5652, 0.5014]}, {"w": "sensible", "b": [0.5701, 0.4799, 0.636, 0.5014]}, {"w": "defaults).", "b": [0.6409, 0.4799, 0.718, 0.5014]}, {"w": "This", "b": [0.7229, 0.4799, 0.7601, 0.5014]}, {"w": "hyperpara‐", "b": [0.7651, 0.4799, 0.8571, 0.5014]}, {"w": "meter", "b": [0.1429, 0.499, 0.1917, 0.5204]}, {"w": "will", "b": [0.2021, 0.499, 0.2325, 0.5204]}, {"w": "allow", "b": [0.2429, 0.499, 0.2875, 0.5204]}, {"w": "you", "b": [0.2979, 0.499, 0.3292, 0.5204]}, {"w": "to", "b": [0.3396, 0.499, 0.3565, 0.5204]}, {"w": "easily", "b": [0.367, 0.499, 0.413, 0.5204]}, {"w": "find", "b": [0.4234, 0.499, 0.4576, 0.5204]}, {"w": "out", "b": [0.468, 0.499, 0.496, 0.5204]}, {"w": "whether", "b": [0.5064, 0.499, 0.5747, 0.5204]}, {"w": "adding", "b": [0.5851, 0.499, 0.643, 0.5204]}, {"w": "this", "b": [0.6534, 0.499, 0.6841, 0.5204]}, {"w": "attribute", "b": [0.6945, 0.499, 0.7662, 0.5204]}, {"w": "helps", "b": [0.7766, 0.499, 0.8204, 0.5204]}, {"w": "the", "b": [0.8308, 0.499, 0.8571, 0.5204]}, {"w": "Machine", "b": [0.1429, 0.518, 0.216, 0.5395]}, {"w": "Learning", "b": [0.222, 0.518, 0.297, 0.5395]}, {"w": "algorithms", "b": [0.303, 0.518, 0.3933, 0.5395]}, {"w": "or", "b": [0.3992, 0.518, 0.4176, 0.5395]}, {"w": "not.", "b": [0.4236, 0.518, 0.4567, 0.5395]}, {"w": "More", "b": [0.4627, 0.518, 0.5079, 0.5395]}, {"w": "generally,", "b": [0.5139, 0.518, 0.5929, 0.5395]}, {"w": "you", "b": [0.5989, 0.518, 0.6301, 0.5395]}, {"w": "can", "b": [0.6361, 0.518, 0.6655, 0.5395]}, {"w": "add", "b": [0.6714, 0.518, 0.7026, 0.5395]}, {"w": "a", "b": [0.7085, 0.518, 0.7177, 0.5395]}, {"w": "hyperparameter", "b": [0.7237, 0.518, 0.8572, 0.5395]}, {"w": "to", "b": [0.1429, 0.5371, 0.1598, 0.5585]}, {"w": "gate", "b": [0.167, 0.5371, 0.2007, 0.5585]}, {"w": "any", "b": [0.2078, 0.5371, 0.2375, 0.5585]}, {"w": "data", "b": [0.2446, 0.5371, 0.2798, 0.5585]}, {"w": "preparation", "b": [0.287, 0.5371, 0.385, 0.5585]}, {"w": "step", "b": [0.3921, 0.5371, 0.4259, 0.5585]}, {"w": "that", "b": [0.433, 0.5371, 0.4656, 0.5585]}, {"w": "you", "b": [0.4728, 0.5371, 0.504, 0.5585]}, {"w": "are", "b": [0.5111, 0.5371, 0.5369, 0.5585]}, {"w": "not", "b": [0.544, 0.5371, 0.5724, 0.5585]}, {"w": "100%", "b": [0.5795, 0.5371, 0.6253, 0.5585]}, {"w": "sure", "b": [0.6324, 0.5371, 0.6677, 0.5585]}, {"w": "about.", "b": [0.6749, 0.5371, 0.7274, 0.5585]}, {"w": "The", "b": [0.7345, 0.5371, 0.7673, 0.5585]}, {"w": "more", "b": [0.7745, 0.5371, 0.8188, 0.5585]}, {"w": "you", "b": [0.8259, 0.5371, 0.8571, 0.5585]}, {"w": "automate", "b": [0.1429, 0.5561, 0.2207, 0.5776]}, {"w": "these", "b": [0.2263, 0.5561, 0.2691, 0.5776]}, {"w": "data", "b": [0.2747, 0.5561, 0.3099, 0.5776]}, {"w": "preparation", "b": [0.3155, 0.5561, 0.4135, 0.5776]}, {"w": "steps,", "b": [0.4191, 0.5561, 0.4653, 0.5776]}, {"w": "the", "b": [0.4709, 0.5561, 0.4972, 0.5776]}, {"w": "more", "b": [0.5028, 0.5561, 0.5471, 0.5776]}, {"w": "combinations", "b": [0.5527, 0.5561, 0.6671, 0.5776]}, {"w": "you", "b": [0.6727, 0.5561, 0.704, 0.5776]}, {"w": "can", "b": [0.7096, 0.5561, 0.7389, 0.5776]}, {"w": "automatically", "b": [0.7445, 0.5561, 0.8571, 0.5776]}, {"w": "try", "b": [0.1428, 0.5752, 0.1671, 0.5966]}, {"w": "out,", "b": [0.1729, 0.5752, 0.2057, 0.5966]}, {"w": "making", "b": [0.2115, 0.5752, 0.2748, 0.5966]}, {"w": "it", "b": [0.2806, 0.5752, 0.2926, 0.5966]}, {"w": "much", "b": [0.2984, 0.5752, 0.346, 0.5966]}, {"w": "more", "b": [0.3519, 0.5752, 0.3961, 0.5966]}, {"w": "likely", "b": [0.4019, 0.5752, 0.4468, 0.5966]}, {"w": "that", "b": [0.4526, 0.5752, 0.4852, 0.5966]}, {"w": "you", "b": [0.491, 0.5752, 0.5223, 0.5966]}, {"w": "will", "b": [0.5281, 0.5752, 0.5585, 0.5966]}, {"w": "find", "b": [0.5643, 0.5752, 0.5985, 0.5966]}, {"w": "a", "b": [0.6043, 0.5752, 0.6134, 0.5966]}, {"w": "great", "b": [0.6192, 0.5752, 0.6607, 0.5966]}, {"w": "combination", "b": [0.6665, 0.5752, 0.7733, 0.5966]}, {"w": "(and", "b": [0.7791, 0.5752, 0.8178, 0.5966]}, {"w": "sav‐", "b": [0.8237, 0.5752, 0.8571, 0.5966]}, {"w": "ing", "b": [0.1429, 0.5942, 0.1696, 0.6156]}, {"w": "you", "b": [0.1743, 0.5942, 0.2056, 0.6156]}, {"w": "a", "b": [0.2103, 0.5942, 0.2194, 0.6156]}, {"w": "lot", "b": [0.2242, 0.5942, 0.2464, 0.6156]}, {"w": "of", "b": [0.2512, 0.5942, 0.2679, 0.6156]}, {"w": "time).", "b": [0.2727, 0.5942, 0.3225, 0.6156]}]}, {"id": "b_6", "type": "paragraph", "text": "Feature Scaling", "words": [{"w": "Feature", "b": [0.1429, 0.6284, 0.2224, 0.657]}, {"w": "Scaling", "b": [0.2273, 0.6284, 0.3012, 0.657]}]}, {"id": "b_7", "type": "paragraph", "text": "One of the most important transformations you need to apply to your data is feature scaling. With few exceptions, Machine Learning algorithms don’t perform well when the input numerical attributes have very different scales. This is the case for the hous‐ ing data: the total number of rooms ranges from about 6 to 39,320, while the median incomes only range from 0 to 15. Note that scaling the target values is generally not required.", "words": [{"w": "One", "b": [0.1429, 0.6629, 0.1787, 0.6843]}, {"w": "of", "b": [0.1845, 0.6629, 0.2012, 0.6843]}, {"w": "the", "b": [0.207, 0.6629, 0.2334, 0.6843]}, {"w": "most", "b": [0.2391, 0.6629, 0.2808, 0.6843]}, {"w": "important", "b": [0.2866, 0.6629, 0.371, 0.6843]}, {"w": "transformations", "b": [0.3768, 0.6629, 0.511, 0.6843]}, {"w": "you", "b": [0.5167, 0.6629, 0.548, 0.6843]}, {"w": "need", "b": [0.5538, 0.6629, 0.5939, 0.6843]}, {"w": "to", "b": [0.5997, 0.6629, 0.6166, 0.6843]}, {"w": "apply", "b": [0.6224, 0.6629, 0.6678, 0.6843]}, {"w": "to", "b": [0.6736, 0.6629, 0.6906, 0.6843]}, {"w": "your", "b": [0.6964, 0.6629, 0.7353, 0.6843]}, {"w": "data", "b": [0.7411, 0.6629, 0.7764, 0.6843]}, {"w": "is", "b": [0.7821, 0.6629, 0.7954, 0.6843]}, {"w": "feature", "b": [0.8012, 0.6627, 0.8572, 0.6843]}, {"w": "scaling.", "b": [0.1429, 0.6817, 0.2024, 0.7033]}, {"w": "With", "b": [0.2085, 0.6819, 0.2509, 0.7033]}, {"w": "few", "b": [0.257, 0.6819, 0.2863, 0.7033]}, {"w": "exceptions,", "b": [0.2924, 0.6819, 0.386, 0.7033]}, {"w": "Machine", "b": [0.3921, 0.6819, 0.4652, 0.7033]}, {"w": "Learning", "b": [0.4713, 0.6819, 0.5464, 0.7033]}, {"w": "algorithms", "b": [0.5525, 0.6819, 0.6428, 0.7033]}, {"w": "don’t", "b": [0.6489, 0.6819, 0.6905, 0.7033]}, {"w": "perform", "b": [0.6966, 0.6819, 0.7656, 0.7033]}, {"w": "well", "b": [0.7717, 0.6819, 0.8054, 0.7033]}, {"w": "when", "b": [0.8115, 0.6819, 0.8571, 0.7033]}, {"w": "the", "b": [0.1429, 0.701, 0.1692, 0.7224]}, {"w": "input", "b": [0.1742, 0.701, 0.2192, 0.7224]}, {"w": "numerical", "b": [0.2242, 0.701, 0.3087, 0.7224]}, {"w": "attributes", "b": [0.3138, 0.701, 0.393, 0.7224]}, {"w": "have", "b": [0.3981, 0.701, 0.4365, 0.7224]}, {"w": "very", "b": [0.4415, 0.701, 0.4779, 0.7224]}, {"w": "different", "b": [0.483, 0.701, 0.5547, 0.7224]}, {"w": "scales.", "b": [0.5597, 0.701, 0.6119, 0.7224]}, {"w": "This", "b": [0.6169, 0.701, 0.6541, 0.7224]}, {"w": "is", "b": [0.6592, 0.701, 0.6724, 0.7224]}, {"w": "the", "b": [0.6774, 0.701, 0.7038, 0.7224]}, {"w": "case", "b": [0.7088, 0.701, 0.7433, 0.7224]}, {"w": "for", "b": [0.7483, 0.701, 0.7728, 0.7224]}, {"w": "the", "b": [0.7779, 0.701, 0.8042, 0.7224]}, {"w": "hous‐", "b": [0.8093, 0.701, 0.8571, 0.7224]}, {"w": "ing", "b": [0.1428, 0.72, 0.1696, 0.7414]}, {"w": "data:", "b": [0.175, 0.72, 0.215, 0.7414]}, {"w": "the", "b": [0.2205, 0.72, 0.2468, 0.7414]}, {"w": "total", "b": [0.2523, 0.72, 0.29, 0.7414]}, {"w": "number", "b": [0.2955, 0.72, 0.3618, 0.7414]}, {"w": "of", "b": [0.3672, 0.72, 0.384, 0.7414]}, {"w": "rooms", "b": [0.3895, 0.72, 0.4432, 0.7414]}, {"w": "ranges", "b": [0.4486, 0.72, 0.5032, 0.7414]}, {"w": "from", "b": [0.5086, 0.72, 0.5502, 0.7414]}, {"w": "about", "b": [0.5557, 0.72, 0.6034, 0.7414]}, {"w": "6", "b": [0.6089, 0.72, 0.6189, 0.7414]}, {"w": "to", "b": [0.6243, 0.72, 0.6413, 0.7414]}, {"w": "39,320,", "b": [0.6468, 0.72, 0.7063, 0.7414]}, {"w": "while", "b": [0.7117, 0.72, 0.7568, 0.7414]}, {"w": "the", "b": [0.7623, 0.72, 0.7886, 0.7414]}, {"w": "median", "b": [0.7941, 0.72, 0.8571, 0.7414]}, {"w": "incomes", "b": [0.1429, 0.7391, 0.2128, 0.7605]}, {"w": "only", "b": [0.219, 0.7391, 0.2559, 0.7605]}, {"w": "range", "b": [0.2621, 0.7391, 0.3089, 0.7605]}, {"w": "from", "b": [0.3151, 0.7391, 0.3567, 0.7605]}, {"w": "0", "b": [0.3629, 0.7391, 0.3729, 0.7605]}, {"w": "to", "b": [0.3791, 0.7391, 0.396, 0.7605]}, {"w": "15.", "b": [0.4022, 0.7391, 0.427, 0.7605]}, {"w": "Note", "b": [0.4331, 0.7391, 0.4739, 0.7605]}, {"w": "that", "b": [0.4801, 0.7391, 0.5127, 0.7605]}, {"w": "scaling", "b": [0.5189, 0.7391, 0.5765, 0.7605]}, {"w": "the", "b": [0.5827, 0.7391, 0.609, 0.7605]}, {"w": "target", "b": [0.6152, 0.7391, 0.6634, 0.7605]}, {"w": "values", "b": [0.6695, 0.7391, 0.7212, 0.7605]}, {"w": "is", "b": [0.7274, 0.7391, 0.7406, 0.7605]}, {"w": "generally", "b": [0.7468, 0.7391, 0.8226, 0.7605]}, {"w": "not", "b": [0.8288, 0.7391, 0.8571, 0.7605]}, {"w": "required.", "b": [0.1429, 0.7581, 0.2191, 0.7795]}]}, {"id": "b_8", "type": "paragraph", "text": "There are two common ways to get all attributes to have the same scale: min-max scaling and standardization.", "words": [{"w": "There", "b": [0.1429, 0.7862, 0.1923, 0.8076]}, {"w": "are", "b": [0.1999, 0.7862, 0.2256, 0.8076]}, {"w": "two", "b": [0.2332, 0.7862, 0.2645, 0.8076]}, {"w": "common", "b": [0.2721, 0.7862, 0.3476, 0.8076]}, {"w": "ways", "b": [0.3553, 0.7862, 0.3955, 0.8076]}, {"w": "to", "b": [0.4031, 0.7862, 0.4201, 0.8076]}, {"w": "get", "b": [0.4277, 0.7862, 0.4526, 0.8076]}, {"w": "all", "b": [0.4603, 0.7862, 0.4799, 0.8076]}, {"w": "attributes", "b": [0.4875, 0.7862, 0.5668, 0.8076]}, {"w": "to", "b": [0.5744, 0.7862, 0.5914, 0.8076]}, {"w": "have", "b": [0.599, 0.7862, 0.6374, 0.8076]}, {"w": "the", "b": [0.645, 0.7862, 0.6713, 0.8076]}, {"w": "same", "b": [0.6789, 0.7862, 0.7216, 0.8076]}, {"w": "scale:", "b": [0.7292, 0.7862, 0.7737, 0.8076]}, {"w": "min-max", "b": [0.7813, 0.786, 0.8571, 0.8076]}, {"w": "scaling", "b": [0.1429, 0.8051, 0.1976, 0.8267]}, {"w": "and", "b": [0.2024, 0.8053, 0.2339, 0.8267]}, {"w": "standardization.", "b": [0.2386, 0.8051, 0.3718, 0.8267]}]}, {"id": "b_9", "type": "paragraph", "text": "Min-max scaling (many people call this normalization) is quite simple: values are shifted and rescaled so that they end up ranging from 0 to 1. We do this by subtract‐ ing the min value and dividing by the max minus the min. Scikit-Learn provides a", "words": [{"w": "Min-max", "b": [0.1429, 0.8334, 0.2219, 0.8548]}, {"w": "scaling", "b": [0.2303, 0.8334, 0.2879, 0.8548]}, {"w": "(many", "b": [0.2964, 0.8334, 0.3503, 0.8548]}, {"w": "people", "b": [0.3587, 0.8334, 0.4142, 0.8548]}, {"w": "call", "b": [0.4226, 0.8334, 0.4511, 0.8548]}, {"w": "this", "b": [0.4596, 0.8334, 0.4903, 0.8548]}, {"w": "normalization)", "b": [0.4987, 0.8332, 0.6221, 0.8548]}, {"w": "is", "b": [0.6306, 0.8334, 0.6438, 0.8548]}, {"w": "quite", "b": [0.6522, 0.8334, 0.6947, 0.8548]}, {"w": "simple:", "b": [0.7032, 0.8334, 0.7629, 0.8548]}, {"w": "values", "b": [0.7713, 0.8334, 0.823, 0.8548]}, {"w": "are", "b": [0.8314, 0.8334, 0.8571, 0.8548]}, {"w": "shifted", "b": [0.1429, 0.8524, 0.1996, 0.8739]}, {"w": "and", "b": [0.2052, 0.8524, 0.2368, 0.8739]}, {"w": "rescaled", "b": [0.2424, 0.8524, 0.3097, 0.8739]}, {"w": "so", "b": [0.3154, 0.8524, 0.3337, 0.8739]}, {"w": "that", "b": [0.3393, 0.8524, 0.3719, 0.8739]}, {"w": "they", "b": [0.3775, 0.8524, 0.4134, 0.8739]}, {"w": "end", "b": [0.4191, 0.8524, 0.4503, 0.8739]}, {"w": "up", "b": [0.456, 0.8524, 0.478, 0.8739]}, {"w": "ranging", "b": [0.4836, 0.8524, 0.5484, 0.8739]}, {"w": "from", "b": [0.554, 0.8524, 0.5956, 0.8739]}, {"w": "0", "b": [0.6012, 0.8524, 0.6112, 0.8739]}, {"w": "to", "b": [0.6169, 0.8524, 0.6339, 0.8739]}, {"w": "1.", "b": [0.6395, 0.8524, 0.6543, 0.8739]}, {"w": "We", "b": [0.6599, 0.8524, 0.687, 0.8739]}, {"w": "do", "b": [0.6926, 0.8524, 0.7143, 0.8739]}, {"w": "this", "b": [0.7199, 0.8524, 0.7506, 0.8739]}, {"w": "by", "b": [0.7563, 0.8524, 0.7764, 0.8739]}, {"w": "subtract‐", "b": [0.782, 0.8524, 0.8572, 0.8739]}, {"w": "ing", "b": [0.1429, 0.8715, 0.1696, 0.8929]}, {"w": "the", "b": [0.1766, 0.8715, 0.203, 0.8929]}, {"w": "min", "b": [0.21, 0.8715, 0.2441, 0.8929]}, {"w": "value", "b": [0.2511, 0.8715, 0.2951, 0.8929]}, {"w": "and", "b": [0.3021, 0.8715, 0.3337, 0.8929]}, {"w": "dividing", "b": [0.3407, 0.8715, 0.4103, 0.8929]}, {"w": "by", "b": [0.4173, 0.8715, 0.4375, 0.8929]}, {"w": "the", "b": [0.4445, 0.8715, 0.4708, 0.8929]}, {"w": "max", "b": [0.4779, 0.8715, 0.5139, 0.8929]}, {"w": "minus", "b": [0.521, 0.8715, 0.5733, 0.8929]}, {"w": "the", "b": [0.5804, 0.8715, 0.6067, 0.8929]}, {"w": "min.", "b": [0.6138, 0.8715, 0.6526, 0.8929]}, {"w": "Scikit-Learn", "b": [0.6596, 0.8715, 0.7619, 0.8929]}, {"w": "provides", "b": [0.769, 0.8715, 0.841, 0.8929]}, {"w": "a", "b": [0.848, 0.8715, 0.8571, 0.8929]}]}, {"id": "b_10", "type": "equation", "text": "72 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "72", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 99, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "transformer called MinMaxScaler for this. It has a feature_range hyperparameter that lets you change the range if you don’t want 0–1 for some reason.", "words": [{"w": "transformer", "b": [0.1429, 0.08, 0.2433, 0.1014]}, {"w": "called", "b": [0.2516, 0.08, 0.3, 0.1014]}, {"w": "MinMaxScaler", "b": [0.3083, 0.0831, 0.427, 0.0982]}, {"w": "for", "b": [0.4354, 0.08, 0.4599, 0.1014]}, {"w": "this.", "b": [0.4682, 0.08, 0.5037, 0.1014]}, {"w": "It", "b": [0.512, 0.08, 0.5246, 0.1014]}, {"w": "has", "b": [0.533, 0.08, 0.5609, 0.1014]}, {"w": "a", "b": [0.5692, 0.08, 0.5784, 0.1014]}, {"w": "feature_range", "b": [0.5867, 0.0831, 0.7153, 0.0982]}, {"w": "hyperparameter", "b": [0.7236, 0.08, 0.8571, 0.1014]}, {"w": "that", "b": [0.1429, 0.099, 0.1754, 0.1204]}, {"w": "lets", "b": [0.1802, 0.099, 0.2083, 0.1204]}, {"w": "you", "b": [0.213, 0.099, 0.2443, 0.1204]}, {"w": "change", "b": [0.249, 0.099, 0.3081, 0.1204]}, {"w": "the", "b": [0.3128, 0.099, 0.3391, 0.1204]}, {"w": "range", "b": [0.3439, 0.099, 0.3907, 0.1204]}, {"w": "if", "b": [0.3955, 0.099, 0.4072, 0.1204]}, {"w": "you", "b": [0.412, 0.099, 0.4432, 0.1204]}, {"w": "don’t", "b": [0.4479, 0.099, 0.4895, 0.1204]}, {"w": "want", "b": [0.4943, 0.099, 0.535, 0.1204]}, {"w": "0–1", "b": [0.5398, 0.099, 0.5706, 0.1204]}, {"w": "for", "b": [0.5753, 0.099, 0.5999, 0.1204]}, {"w": "some", "b": [0.6046, 0.099, 0.6488, 0.1204]}, {"w": "reason.", "b": [0.6535, 0.099, 0.7136, 0.1204]}]}, {"id": "b_1", "type": "paragraph", "text": "Standardization is quite different: first it subtracts the mean value (so standardized values always have a zero mean), and then it divides by the standard deviation so that the resulting distribution has unit variance. Unlike min-max scaling, standardization does not bound values to a specific range, which may be a problem for some algo‐ rithms (e.g., neural networks often expect an input value ranging from 0 to 1). How‐ ever, standardization is much less affected by outliers. For example, suppose a district had a median income equal to 100 (by mistake). Min-max scaling would then crush all the other values from 0–15 down to 0–0.15, whereas standardization would not be much affected. Scikit-Learn provides a transformer called StandardScaler for stand‐ ardization.", "words": [{"w": "Standardization", "b": [0.1429, 0.1271, 0.2755, 0.1485]}, {"w": "is", "b": [0.2827, 0.1271, 0.2959, 0.1485]}, {"w": "quite", "b": [0.3031, 0.1271, 0.3456, 0.1485]}, {"w": "different:", "b": [0.3528, 0.1271, 0.4292, 0.1485]}, {"w": "first", "b": [0.4364, 0.1271, 0.4699, 0.1485]}, {"w": "it", "b": [0.477, 0.1271, 0.489, 0.1485]}, {"w": "subtracts", "b": [0.4961, 0.1271, 0.5715, 0.1485]}, {"w": "the", "b": [0.5786, 0.1271, 0.605, 0.1485]}, {"w": "mean", "b": [0.6121, 0.1271, 0.6586, 0.1485]}, {"w": "value", "b": [0.6657, 0.1271, 0.7097, 0.1485]}, {"w": "(so", "b": [0.7169, 0.1271, 0.7424, 0.1485]}, {"w": "standardized", "b": [0.7495, 0.1271, 0.8571, 0.1485]}, {"w": "values", "b": [0.1429, 0.1462, 0.1945, 0.1676]}, {"w": "always", "b": [0.1996, 0.1462, 0.2543, 0.1676]}, {"w": "have", "b": [0.2594, 0.1462, 0.2978, 0.1676]}, {"w": "a", "b": [0.303, 0.1462, 0.3121, 0.1676]}, {"w": "zero", "b": [0.3172, 0.1462, 0.3532, 0.1676]}, {"w": "mean),", "b": [0.3583, 0.1462, 0.4167, 0.1676]}, {"w": "and", "b": [0.4219, 0.1462, 0.4534, 0.1676]}, {"w": "then", "b": [0.4586, 0.1462, 0.4963, 0.1676]}, {"w": "it", "b": [0.5014, 0.1462, 0.5134, 0.1676]}, {"w": "divides", "b": [0.5185, 0.1462, 0.5778, 0.1676]}, {"w": "by", "b": [0.5829, 0.1462, 0.6031, 0.1676]}, {"w": "the", "b": [0.6082, 0.1462, 0.6346, 0.1676]}, {"w": "standard", "b": [0.6397, 0.1462, 0.7131, 0.1676]}, {"w": "deviation", "b": [0.7182, 0.1462, 0.796, 0.1676]}, {"w": "so", "b": [0.8012, 0.1462, 0.8194, 0.1676]}, {"w": "that", "b": [0.8246, 0.1462, 0.8572, 0.1676]}, {"w": "the", "b": [0.1429, 0.1652, 0.1692, 0.1866]}, {"w": "resulting", "b": [0.1749, 0.1652, 0.2485, 0.1866]}, {"w": "distribution", "b": [0.2542, 0.1652, 0.3537, 0.1866]}, {"w": "has", "b": [0.3594, 0.1652, 0.3873, 0.1866]}, {"w": "unit", "b": [0.393, 0.1652, 0.4274, 0.1866]}, {"w": "variance.", "b": [0.4331, 0.1652, 0.5082, 0.1866]}, {"w": "Unlike", "b": [0.5139, 0.1652, 0.5698, 0.1866]}, {"w": "min-max", "b": [0.5754, 0.1652, 0.6529, 0.1866]}, {"w": "scaling,", "b": [0.6586, 0.1652, 0.721, 0.1866]}, {"w": "standardization", "b": [0.7267, 0.1652, 0.8571, 0.1866]}, {"w": "does", "b": [0.1429, 0.1843, 0.181, 0.2057]}, {"w": "not", "b": [0.1879, 0.1843, 0.2163, 0.2057]}, {"w": "bound", "b": [0.2233, 0.1843, 0.278, 0.2057]}, {"w": "values", "b": [0.2849, 0.1843, 0.3365, 0.2057]}, {"w": "to", "b": [0.3435, 0.1843, 0.3605, 0.2057]}, {"w": "a", "b": [0.3675, 0.1843, 0.3766, 0.2057]}, {"w": "specific", "b": [0.3836, 0.1843, 0.446, 0.2057]}, {"w": "range,", "b": [0.4529, 0.1843, 0.5045, 0.2057]}, {"w": "which", "b": [0.5115, 0.1843, 0.5624, 0.2057]}, {"w": "may", "b": [0.5694, 0.1843, 0.6048, 0.2057]}, {"w": "be", "b": [0.6118, 0.1843, 0.6312, 0.2057]}, {"w": "a", "b": [0.6382, 0.1843, 0.6473, 0.2057]}, {"w": "problem", "b": [0.6543, 0.1843, 0.7253, 0.2057]}, {"w": "for", "b": [0.7323, 0.1843, 0.7568, 0.2057]}, {"w": "some", "b": [0.7638, 0.1843, 0.808, 0.2057]}, {"w": "algo‐", "b": [0.8149, 0.1843, 0.8571, 0.2057]}, {"w": "rithms", "b": [0.1428, 0.2033, 0.1983, 0.2247]}, {"w": "(e.g.,", "b": [0.204, 0.2033, 0.244, 0.2247]}, {"w": "neural", "b": [0.2496, 0.2033, 0.3031, 0.2247]}, {"w": "networks", "b": [0.3087, 0.2033, 0.3859, 0.2247]}, {"w": "often", "b": [0.3915, 0.2033, 0.4349, 0.2247]}, {"w": "expect", "b": [0.4405, 0.2033, 0.4942, 0.2247]}, {"w": "an", "b": [0.4998, 0.2033, 0.5203, 0.2247]}, {"w": "input", "b": [0.5259, 0.2033, 0.5708, 0.2247]}, {"w": "value", "b": [0.5765, 0.2033, 0.6204, 0.2247]}, {"w": "ranging", "b": [0.626, 0.2033, 0.6908, 0.2247]}, {"w": "from", "b": [0.6964, 0.2033, 0.738, 0.2247]}, {"w": "0", "b": [0.7436, 0.2033, 0.7536, 0.2247]}, {"w": "to", "b": [0.7592, 0.2033, 0.7762, 0.2247]}, {"w": "1).", "b": [0.7818, 0.2033, 0.8038, 0.2247]}, {"w": "How‐", "b": [0.8094, 0.2033, 0.8571, 0.2247]}, {"w": "ever,", "b": [0.1429, 0.2224, 0.1814, 0.2438]}, {"w": "standardization", "b": [0.1866, 0.2224, 0.317, 0.2438]}, {"w": "is", "b": [0.3223, 0.2224, 0.3355, 0.2438]}, {"w": "much", "b": [0.3407, 0.2224, 0.3884, 0.2438]}, {"w": "less", "b": [0.3936, 0.2224, 0.423, 0.2438]}, {"w": "affected", "b": [0.4282, 0.2224, 0.4935, 0.2438]}, {"w": "by", "b": [0.4987, 0.2224, 0.5189, 0.2438]}, {"w": "outliers.", "b": [0.5241, 0.2224, 0.592, 0.2438]}, {"w": "For", "b": [0.5972, 0.2224, 0.6262, 0.2438]}, {"w": "example,", "b": [0.6314, 0.2224, 0.7057, 0.2438]}, {"w": "suppose", "b": [0.7109, 0.2224, 0.7785, 0.2438]}, {"w": "a", "b": [0.7837, 0.2224, 0.7929, 0.2438]}, {"w": "district", "b": [0.7981, 0.2224, 0.8571, 0.2438]}, {"w": "had", "b": [0.1429, 0.2414, 0.1741, 0.2628]}, {"w": "a", "b": [0.1802, 0.2414, 0.1894, 0.2628]}, {"w": "median", "b": [0.1955, 0.2414, 0.2585, 0.2628]}, {"w": "income", "b": [0.2646, 0.2414, 0.327, 0.2628]}, {"w": "equal", "b": [0.3331, 0.2414, 0.378, 0.2628]}, {"w": "to", "b": [0.3841, 0.2414, 0.4011, 0.2628]}, {"w": "100", "b": [0.4072, 0.2414, 0.4372, 0.2628]}, {"w": "(by", "b": [0.4433, 0.2414, 0.4707, 0.2628]}, {"w": "mistake).", "b": [0.4768, 0.2414, 0.5537, 0.2628]}, {"w": "Min-max", "b": [0.5598, 0.2414, 0.6388, 0.2628]}, {"w": "scaling", "b": [0.6449, 0.2414, 0.7025, 0.2628]}, {"w": "would", "b": [0.7086, 0.2414, 0.7608, 0.2628]}, {"w": "then", "b": [0.7669, 0.2414, 0.8047, 0.2628]}, {"w": "crush", "b": [0.8108, 0.2414, 0.8571, 0.2628]}, {"w": "all", "b": [0.1429, 0.2605, 0.1625, 0.2819]}, {"w": "the", "b": [0.1677, 0.2605, 0.194, 0.2819]}, {"w": "other", "b": [0.1991, 0.2605, 0.2438, 0.2819]}, {"w": "values", "b": [0.249, 0.2605, 0.3006, 0.2819]}, {"w": "from", "b": [0.3057, 0.2605, 0.3473, 0.2819]}, {"w": "0–15", "b": [0.3525, 0.2605, 0.3933, 0.2819]}, {"w": "down", "b": [0.3984, 0.2605, 0.4457, 0.2819]}, {"w": "to", "b": [0.4509, 0.2605, 0.4678, 0.2819]}, {"w": "0–0.15,", "b": [0.473, 0.2605, 0.5333, 0.2819]}, {"w": "whereas", "b": [0.5385, 0.2605, 0.6061, 0.2819]}, {"w": "standardization", "b": [0.6112, 0.2605, 0.7417, 0.2819]}, {"w": "would", "b": [0.7468, 0.2605, 0.799, 0.2819]}, {"w": "not", "b": [0.8042, 0.2605, 0.8326, 0.2819]}, {"w": "be", "b": [0.8377, 0.2605, 0.8571, 0.2819]}, {"w": "much", "b": [0.1429, 0.2804, 0.1905, 0.3018]}, {"w": "affected.", "b": [0.1959, 0.2804, 0.266, 0.3018]}, {"w": "Scikit-Learn", "b": [0.2714, 0.2804, 0.3737, 0.3018]}, {"w": "provides", "b": [0.379, 0.2804, 0.451, 0.3018]}, {"w": "a", "b": [0.4564, 0.2804, 0.4655, 0.3018]}, {"w": "transformer", "b": [0.4709, 0.2804, 0.5713, 0.3018]}, {"w": "called", "b": [0.5767, 0.2804, 0.625, 0.3018]}, {"w": "StandardScaler", "b": [0.6304, 0.2836, 0.7689, 0.2987]}, {"w": "for", "b": [0.7743, 0.2804, 0.7988, 0.3018]}, {"w": "stand‐", "b": [0.8036, 0.2804, 0.8565, 0.3018]}, {"w": "ardization.", "b": [0.1429, 0.2994, 0.2325, 0.3209]}]}, {"id": "b_2", "type": "paragraph", "text": "As with all the transformations, it is important to fit the scalers to the training data only, not to the full dataset (including the test set). Only then can you use them to transform the training set and the test set (and new data).", "words": [{"w": "As", "b": [0.2714, 0.3414, 0.2916, 0.361]}, {"w": "with", "b": [0.2973, 0.3414, 0.3314, 0.361]}, {"w": "all", "b": [0.3371, 0.3414, 0.3551, 0.361]}, {"w": "the", "b": [0.3609, 0.3414, 0.3849, 0.361]}, {"w": "transformations,", "b": [0.3907, 0.3414, 0.5177, 0.361]}, {"w": "it", "b": [0.5234, 0.3414, 0.5344, 0.361]}, {"w": "is", "b": [0.5401, 0.3414, 0.5522, 0.361]}, {"w": "important", "b": [0.5579, 0.3414, 0.635, 0.361]}, {"w": "to", "b": [0.6408, 0.3414, 0.6563, 0.361]}, {"w": "fit", "b": [0.662, 0.3414, 0.6786, 0.361]}, {"w": "the", "b": [0.6843, 0.3414, 0.7084, 0.361]}, {"w": "scalers", "b": [0.7141, 0.3414, 0.7645, 0.361]}, {"w": "to", "b": [0.7702, 0.3414, 0.7857, 0.361]}, {"w": "the", "b": [0.2714, 0.3588, 0.2955, 0.3784]}, {"w": "training", "b": [0.3, 0.3588, 0.3612, 0.3784]}, {"w": "data", "b": [0.3657, 0.3588, 0.3979, 0.3784]}, {"w": "only,", "b": [0.4024, 0.3588, 0.439, 0.3784]}, {"w": "not", "b": [0.4435, 0.3588, 0.4695, 0.3784]}, {"w": "to", "b": [0.474, 0.3588, 0.4895, 0.3784]}, {"w": "the", "b": [0.494, 0.3588, 0.518, 0.3784]}, {"w": "full", "b": [0.5225, 0.3588, 0.5479, 0.3784]}, {"w": "dataset", "b": [0.5524, 0.3588, 0.6055, 0.3784]}, {"w": "(including", "b": [0.61, 0.3588, 0.6896, 0.3784]}, {"w": "the", "b": [0.6941, 0.3588, 0.7182, 0.3784]}, {"w": "test", "b": [0.7227, 0.3588, 0.7494, 0.3784]}, {"w": "set).", "b": [0.7539, 0.3588, 0.7857, 0.3784]}, {"w": "Only", "b": [0.2714, 0.3762, 0.3096, 0.3958]}, {"w": "then", "b": [0.3155, 0.3762, 0.3499, 0.3958]}, {"w": "can", "b": [0.3558, 0.3762, 0.3826, 0.3958]}, {"w": "you", "b": [0.3885, 0.3762, 0.417, 0.3958]}, {"w": "use", "b": [0.4229, 0.3762, 0.4481, 0.3958]}, {"w": "them", "b": [0.4539, 0.3762, 0.4936, 0.3958]}, {"w": "to", "b": [0.4994, 0.3762, 0.5149, 0.3958]}, {"w": "transform", "b": [0.5208, 0.3762, 0.5974, 0.3958]}, {"w": "the", "b": [0.6033, 0.3762, 0.6274, 0.3958]}, {"w": "training", "b": [0.6332, 0.3762, 0.6944, 0.3958]}, {"w": "set", "b": [0.7002, 0.3762, 0.7211, 0.3958]}, {"w": "and", "b": [0.727, 0.3762, 0.7558, 0.3958]}, {"w": "the", "b": [0.7616, 0.3762, 0.7857, 0.3958]}, {"w": "test", "b": [0.2714, 0.3936, 0.2981, 0.4132]}, {"w": "set", "b": [0.3024, 0.3936, 0.3233, 0.4132]}, {"w": "(and", "b": [0.3277, 0.3936, 0.3631, 0.4132]}, {"w": "new", "b": [0.3674, 0.3936, 0.399, 0.4132]}, {"w": "data).", "b": [0.4033, 0.3936, 0.4465, 0.4132]}]}, {"id": "b_3", "type": "paragraph", "text": "Transformation Pipelines", "words": [{"w": "Transformation", "b": [0.1429, 0.4373, 0.3029, 0.4659]}, {"w": "Pipelines", "b": [0.3078, 0.4373, 0.4019, 0.4659]}]}, {"id": "b_4", "type": "paragraph", "text": "As you can see, there are many data transformation steps that need to be executed in the right order. Fortunately, Scikit-Learn provides the Pipeline class to help with such sequences of transformations. Here is a small pipeline for the numerical attributes:", "words": [{"w": "As", "b": [0.1428, 0.4718, 0.1649, 0.4932]}, {"w": "you", "b": [0.1704, 0.4718, 0.2017, 0.4932]}, {"w": "can", "b": [0.2072, 0.4718, 0.2366, 0.4932]}, {"w": "see,", "b": [0.2421, 0.4718, 0.2723, 0.4932]}, {"w": "there", "b": [0.2778, 0.4718, 0.3207, 0.4932]}, {"w": "are", "b": [0.3263, 0.4718, 0.352, 0.4932]}, {"w": "many", "b": [0.3575, 0.4718, 0.4042, 0.4932]}, {"w": "data", "b": [0.4098, 0.4718, 0.445, 0.4932]}, {"w": "transformation", "b": [0.4506, 0.4718, 0.5772, 0.4932]}, {"w": "steps", "b": [0.5827, 0.4718, 0.6241, 0.4932]}, {"w": "that", "b": [0.6297, 0.4718, 0.6623, 0.4932]}, {"w": "need", "b": [0.6678, 0.4718, 0.7079, 0.4932]}, {"w": "to", "b": [0.7135, 0.4718, 0.7304, 0.4932]}, {"w": "be", "b": [0.736, 0.4718, 0.7554, 0.4932]}, {"w": "executed", "b": [0.761, 0.4718, 0.8346, 0.4932]}, {"w": "in", "b": [0.8402, 0.4718, 0.8571, 0.4932]}, {"w": "the", "b": [0.1429, 0.4917, 0.1692, 0.5131]}, {"w": "right", "b": [0.1774, 0.4917, 0.2175, 0.5131]}, {"w": "order.", "b": [0.2257, 0.4917, 0.275, 0.5131]}, {"w": "Fortunately,", "b": [0.2832, 0.4917, 0.383, 0.5131]}, {"w": "Scikit-Learn", "b": [0.3912, 0.4917, 0.4935, 0.5131]}, {"w": "provides", "b": [0.5017, 0.4917, 0.5737, 0.5131]}, {"w": "the", "b": [0.5818, 0.4917, 0.6082, 0.5131]}, {"w": "Pipeline", "b": [0.6163, 0.4949, 0.6955, 0.51]}, {"w": "class", "b": [0.7037, 0.4917, 0.7422, 0.5131]}, {"w": "to", "b": [0.7503, 0.4917, 0.7673, 0.5131]}, {"w": "help", "b": [0.7755, 0.4917, 0.8116, 0.5131]}, {"w": "with", "b": [0.8198, 0.4917, 0.8571, 0.5131]}, {"w": "such", "b": [0.1429, 0.5107, 0.1815, 0.5322]}, {"w": "sequences", "b": [0.1929, 0.5107, 0.2767, 0.5322]}, {"w": "of", "b": [0.2881, 0.5107, 0.3049, 0.5322]}, {"w": "transformations.", "b": [0.3164, 0.5107, 0.4553, 0.5322]}, {"w": "Here", "b": [0.4667, 0.5107, 0.5076, 0.5322]}, {"w": "is", "b": [0.519, 0.5107, 0.5323, 0.5322]}, {"w": "a", "b": [0.5437, 0.5107, 0.5529, 0.5322]}, {"w": "small", "b": [0.5643, 0.5107, 0.6087, 0.5322]}, {"w": "pipeline", "b": [0.6201, 0.5107, 0.6875, 0.5322]}, {"w": "for", "b": [0.6989, 0.5107, 0.7234, 0.5322]}, {"w": "the", "b": [0.7349, 0.5107, 0.7612, 0.5322]}, {"w": "numerical", "b": [0.7726, 0.5107, 0.8571, 0.5322]}, {"w": "attributes:", "b": [0.1429, 0.5298, 0.2269, 0.5512]}]}, {"id": "b_5", "type": "paragraph", "text": "from sklearn.pipeline import Pipeline from sklearn.preprocessing import StandardScaler", "words": [{"w": "from", "b": [0.1766, 0.5618, 0.2103, 0.5746]}, {"w": "sklearn.pipeline", "b": [0.2187, 0.5618, 0.3537, 0.5746]}, {"w": "import", "b": [0.3621, 0.5618, 0.4127, 0.5746]}, {"w": "Pipeline", "b": [0.4211, 0.5618, 0.4886, 0.5746]}, {"w": "from", "b": [0.1766, 0.5772, 0.2103, 0.59]}, {"w": "sklearn.preprocessing", "b": [0.2187, 0.5772, 0.3958, 0.59]}, {"w": "import", "b": [0.4043, 0.5772, 0.4549, 0.59]}, {"w": "StandardScaler", "b": [0.4633, 0.5772, 0.5813, 0.59]}]}, {"id": "b_6", "type": "paragraph", "text": "num_pipeline = Pipeline([ ('imputer', SimpleImputer(strategy=\"median\")), ('attribs_adder', CombinedAttributesAdder()), ('std_scaler', StandardScaler()), ])", "words": [{"w": "num_pipeline", "b": [0.1766, 0.608, 0.2778, 0.6209]}, {"w": "=", "b": [0.2862, 0.608, 0.2946, 0.6209]}, {"w": "Pipeline([", "b": [0.3031, 0.608, 0.3874, 0.6209]}, {"w": "('imputer',", "b": [0.244, 0.6234, 0.3368, 0.6363]}, {"w": "SimpleImputer(strategy=\"median\")),", "b": [0.3452, 0.6234, 0.6319, 0.6363]}, {"w": "('attribs_adder',", "b": [0.244, 0.6389, 0.3874, 0.6517]}, {"w": "CombinedAttributesAdder()),", "b": [0.3958, 0.6389, 0.6235, 0.6517]}, {"w": "('std_scaler',", "b": [0.244, 0.6543, 0.3621, 0.6671]}, {"w": "StandardScaler()),", "b": [0.3705, 0.6543, 0.5223, 0.6671]}, {"w": "])", "b": [0.2103, 0.6697, 0.2272, 0.6826]}]}, {"id": "b_7", "type": "equation", "text": "housing_num_tr = num_pipeline.fit_transform(housing_num)", "words": [{"w": "housing_num_tr", "b": [0.1766, 0.7005, 0.2946, 0.7134]}, {"w": "=", "b": [0.3031, 0.7005, 0.3115, 0.7134]}, {"w": "num_pipeline.fit_transform(housing_num)", "b": [0.3199, 0.7005, 0.6488, 0.7134]}]}, {"id": "b_8", "type": "paragraph", "text": "The Pipeline constructor takes a list of name/estimator pairs defining a sequence of steps. All but the last estimator must be transformers (i.e., they must have a fit_transform() method). The names can be anything you like (as long as they are unique and don’t contain double underscores “__”): they will come in handy later for hyperparameter tuning.", "words": [{"w": "The", "b": [0.1429, 0.7221, 0.1757, 0.7435]}, {"w": "Pipeline", "b": [0.1813, 0.7253, 0.2604, 0.7403]}, {"w": "constructor", "b": [0.266, 0.7221, 0.3632, 0.7435]}, {"w": "takes", "b": [0.3687, 0.7221, 0.4111, 0.7435]}, {"w": "a", "b": [0.4166, 0.7221, 0.4258, 0.7435]}, {"w": "list", "b": [0.4314, 0.7221, 0.4562, 0.7435]}, {"w": "of", "b": [0.4618, 0.7221, 0.4786, 0.7435]}, {"w": "name/estimator", "b": [0.4842, 0.7221, 0.6165, 0.7435]}, {"w": "pairs", "b": [0.622, 0.7221, 0.6631, 0.7435]}, {"w": "defining", "b": [0.6686, 0.7221, 0.7384, 0.7435]}, {"w": "a", "b": [0.7439, 0.7221, 0.7531, 0.7435]}, {"w": "sequence", "b": [0.7587, 0.7221, 0.8348, 0.7435]}, {"w": "of", "b": [0.8404, 0.7221, 0.8572, 0.7435]}, {"w": "steps.", "b": [0.1429, 0.7411, 0.189, 0.7625]}, {"w": "All", "b": [0.2007, 0.7411, 0.2256, 0.7625]}, {"w": "but", "b": [0.2372, 0.7411, 0.2652, 0.7625]}, {"w": "the", "b": [0.2768, 0.7411, 0.3032, 0.7625]}, {"w": "last", "b": [0.3148, 0.7411, 0.3432, 0.7625]}, {"w": "estimator", "b": [0.3549, 0.7411, 0.4338, 0.7625]}, {"w": "must", "b": [0.4454, 0.7411, 0.4872, 0.7625]}, {"w": "be", "b": [0.4988, 0.7411, 0.5182, 0.7625]}, {"w": "transformers", "b": [0.5299, 0.7411, 0.6379, 0.7625]}, {"w": "(i.e.,", "b": [0.6496, 0.7411, 0.6855, 0.7625]}, {"w": "they", "b": [0.6971, 0.7411, 0.733, 0.7625]}, {"w": "must", "b": [0.7446, 0.7411, 0.7863, 0.7625]}, {"w": "have", "b": [0.798, 0.7411, 0.8364, 0.7625]}, {"w": "a", "b": [0.848, 0.7411, 0.8571, 0.7625]}, {"w": "fit_transform()", "b": [0.1429, 0.7643, 0.2913, 0.7793]}, {"w": "method).", "b": [0.2973, 0.7611, 0.3743, 0.7825]}, {"w": "The", "b": [0.3804, 0.7611, 0.4132, 0.7825]}, {"w": "names", "b": [0.4192, 0.7611, 0.4733, 0.7825]}, {"w": "can", "b": [0.4794, 0.7611, 0.5087, 0.7825]}, {"w": "be", "b": [0.5148, 0.7611, 0.5342, 0.7825]}, {"w": "anything", "b": [0.5403, 0.7611, 0.6141, 0.7825]}, {"w": "you", "b": [0.6201, 0.7611, 0.6514, 0.7825]}, {"w": "like", "b": [0.6574, 0.7611, 0.6875, 0.7825]}, {"w": "(as", "b": [0.6935, 0.7611, 0.7175, 0.7825]}, {"w": "long", "b": [0.7236, 0.7611, 0.7606, 0.7825]}, {"w": "as", "b": [0.7666, 0.7611, 0.7834, 0.7825]}, {"w": "they", "b": [0.7895, 0.7611, 0.8254, 0.7825]}, {"w": "are", "b": [0.8314, 0.7611, 0.8572, 0.7825]}, {"w": "unique", "b": [0.1429, 0.781, 0.2015, 0.8024]}, {"w": "and", "b": [0.2069, 0.781, 0.2384, 0.8024]}, {"w": "don’t", "b": [0.2438, 0.781, 0.2854, 0.8024]}, {"w": "contain", "b": [0.2908, 0.781, 0.3537, 0.8024]}, {"w": "double", "b": [0.3591, 0.781, 0.4165, 0.8024]}, {"w": "underscores", "b": [0.4219, 0.781, 0.5233, 0.8024]}, {"w": "“__”):", "b": [0.5286, 0.781, 0.577, 0.8024]}, {"w": "they", "b": [0.5824, 0.781, 0.6183, 0.8024]}, {"w": "will", "b": [0.6237, 0.781, 0.6541, 0.8024]}, {"w": "come", "b": [0.6595, 0.781, 0.7049, 0.8024]}, {"w": "in", "b": [0.7103, 0.781, 0.7273, 0.8024]}, {"w": "handy", "b": [0.7326, 0.781, 0.7849, 0.8024]}, {"w": "later", "b": [0.7903, 0.781, 0.8272, 0.8024]}, {"w": "for", "b": [0.8326, 0.781, 0.8571, 0.8024]}, {"w": "hyperparameter", "b": [0.1429, 0.8001, 0.2764, 0.8215]}, {"w": "tuning.", "b": [0.2811, 0.8001, 0.3414, 0.8215]}]}, {"id": "b_9", "type": "paragraph", "text": "When you call the pipeline’s fit() method, it calls fit_transform() sequentially on all transformers, passing the output of each call as the parameter to the next call, until it reaches the final estimator, for which it just calls the fit() method.", "words": [{"w": "When", "b": [0.1429, 0.8291, 0.1945, 0.8505]}, {"w": "you", "b": [0.2002, 0.8291, 0.2314, 0.8505]}, {"w": "call", "b": [0.2372, 0.8291, 0.2657, 0.8505]}, {"w": "the", "b": [0.2714, 0.8291, 0.2977, 0.8505]}, {"w": "pipeline’s", "b": [0.3035, 0.8291, 0.38, 0.8505]}, {"w": "fit()", "b": [0.3857, 0.8323, 0.4352, 0.8473]}, {"w": "method,", "b": [0.4409, 0.8291, 0.5107, 0.8505]}, {"w": "it", "b": [0.5164, 0.8291, 0.5283, 0.8505]}, {"w": "calls", "b": [0.5341, 0.8291, 0.5702, 0.8505]}, {"w": "fit_transform()", "b": [0.576, 0.8323, 0.7244, 0.8473]}, {"w": "sequentially", "b": [0.7301, 0.8291, 0.8294, 0.8505]}, {"w": "on", "b": [0.8351, 0.8291, 0.8571, 0.8505]}, {"w": "all", "b": [0.1429, 0.8481, 0.1626, 0.8695]}, {"w": "transformers,", "b": [0.1674, 0.8481, 0.2802, 0.8695]}, {"w": "passing", "b": [0.2851, 0.8481, 0.3471, 0.8695]}, {"w": "the", "b": [0.352, 0.8481, 0.3783, 0.8695]}, {"w": "output", "b": [0.3832, 0.8481, 0.4395, 0.8695]}, {"w": "of", "b": [0.4444, 0.8481, 0.4612, 0.8695]}, {"w": "each", "b": [0.466, 0.8481, 0.5039, 0.8695]}, {"w": "call", "b": [0.5088, 0.8481, 0.5373, 0.8695]}, {"w": "as", "b": [0.5421, 0.8481, 0.5589, 0.8695]}, {"w": "the", "b": [0.5637, 0.8481, 0.5901, 0.8695]}, {"w": "parameter", "b": [0.5949, 0.8481, 0.6807, 0.8695]}, {"w": "to", "b": [0.6855, 0.8481, 0.7025, 0.8695]}, {"w": "the", "b": [0.7073, 0.8481, 0.7337, 0.8695]}, {"w": "next", "b": [0.7385, 0.8481, 0.775, 0.8695]}, {"w": "call,", "b": [0.7798, 0.8481, 0.813, 0.8695]}, {"w": "until", "b": [0.8179, 0.8481, 0.8572, 0.8695]}, {"w": "it", "b": [0.1429, 0.8681, 0.1548, 0.8895]}, {"w": "reaches", "b": [0.1595, 0.8681, 0.2217, 0.8895]}, {"w": "the", "b": [0.2264, 0.8681, 0.2528, 0.8895]}, {"w": "final", "b": [0.2575, 0.8681, 0.295, 0.8895]}, {"w": "estimator,", "b": [0.2998, 0.8681, 0.3822, 0.8895]}, {"w": "for", "b": [0.3869, 0.8681, 0.4114, 0.8895]}, {"w": "which", "b": [0.4162, 0.8681, 0.4671, 0.8895]}, {"w": "it", "b": [0.4718, 0.8681, 0.4837, 0.8895]}, {"w": "just", "b": [0.4885, 0.8681, 0.5189, 0.8895]}, {"w": "calls", "b": [0.5236, 0.8681, 0.5597, 0.8895]}, {"w": "the", "b": [0.5645, 0.8681, 0.5908, 0.8895]}, {"w": "fit()", "b": [0.5955, 0.8713, 0.645, 0.8863]}, {"w": "method.", "b": [0.6497, 0.8681, 0.7195, 0.8895]}]}, {"id": "b_10", "type": "paragraph", "text": "Prepare the Data for Machine Learning Algorithms | 73", "words": [{"w": "Prepare", "b": [0.5083, 0.9225, 0.5544, 0.9388]}, {"w": "the", "b": [0.5573, 0.9225, 0.5771, 0.9388]}, {"w": "Data", "b": [0.58, 0.9225, 0.6076, 0.9388]}, {"w": "for", "b": [0.6104, 0.9225, 0.6273, 0.9388]}, {"w": "Machine", "b": [0.6301, 0.9225, 0.68, 0.9388]}, {"w": "Learning", "b": [0.6828, 0.9225, 0.7351, 0.9388]}, {"w": "Algorithms", "b": [0.7379, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "73", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 100, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "22 Just like for pipelines, the name can be anything as long as it does not contain double underscores.", "words": [{"w": "22", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "Just", "b": [0.1587, 0.8749, 0.1825, 0.8912]}, {"w": "like", "b": [0.1861, 0.8749, 0.209, 0.8912]}, {"w": "for", "b": [0.2126, 0.8749, 0.2313, 0.8912]}, {"w": "pipelines,", "b": [0.2349, 0.8749, 0.2957, 0.8912]}, {"w": "the", "b": [0.2993, 0.8749, 0.3194, 0.8912]}, {"w": "name", "b": [0.323, 0.8749, 0.3584, 0.8912]}, {"w": "can", "b": [0.362, 0.8749, 0.3843, 0.8912]}, {"w": "be", "b": [0.3879, 0.8749, 0.4027, 0.8912]}, {"w": "anything", "b": [0.4063, 0.8749, 0.4626, 0.8912]}, {"w": "as", "b": [0.4662, 0.8749, 0.479, 0.8912]}, {"w": "long", "b": [0.4826, 0.8749, 0.5108, 0.8912]}, {"w": "as", "b": [0.5144, 0.8749, 0.5272, 0.8912]}, {"w": "it", "b": [0.5308, 0.8749, 0.5399, 0.8912]}, {"w": "does", "b": [0.5435, 0.8749, 0.5726, 0.8912]}, {"w": "not", "b": [0.5762, 0.8749, 0.5978, 0.8912]}, {"w": "contain", "b": [0.6014, 0.8749, 0.6493, 0.8912]}, {"w": "double", "b": [0.6529, 0.8749, 0.6967, 0.8912]}, {"w": "underscores.", "b": [0.7003, 0.8749, 0.7811, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "The pipeline exposes the same methods as the final estimator. In this example, the last estimator is a StandardScaler, which is a transformer, so the pipeline has a trans form() method that applies all the transforms to the data in sequence (and of course also a fit_transform() method, which is the one we used).", "words": [{"w": "The", "b": [0.1429, 0.0791, 0.1757, 0.1005]}, {"w": "pipeline", "b": [0.1804, 0.0791, 0.2478, 0.1005]}, {"w": "exposes", "b": [0.2525, 0.0791, 0.3169, 0.1005]}, {"w": "the", "b": [0.3216, 0.0791, 0.348, 0.1005]}, {"w": "same", "b": [0.3527, 0.0791, 0.3954, 0.1005]}, {"w": "methods", "b": [0.4001, 0.0791, 0.4728, 0.1005]}, {"w": "as", "b": [0.4775, 0.0791, 0.4943, 0.1005]}, {"w": "the", "b": [0.499, 0.0791, 0.5254, 0.1005]}, {"w": "final", "b": [0.5301, 0.0791, 0.5677, 0.1005]}, {"w": "estimator.", "b": [0.5724, 0.0791, 0.6548, 0.1005]}, {"w": "In", "b": [0.6595, 0.0791, 0.678, 0.1005]}, {"w": "this", "b": [0.6828, 0.0791, 0.7135, 0.1005]}, {"w": "example,", "b": [0.7182, 0.0791, 0.7925, 0.1005]}, {"w": "the", "b": [0.7972, 0.0791, 0.8235, 0.1005]}, {"w": "last", "b": [0.8283, 0.0791, 0.8567, 0.1005]}, {"w": "estimator", "b": [0.1429, 0.099, 0.2218, 0.1204]}, {"w": "is", "b": [0.2289, 0.099, 0.2421, 0.1204]}, {"w": "a", "b": [0.2492, 0.099, 0.2583, 0.1204]}, {"w": "StandardScaler,", "b": [0.2654, 0.099, 0.4087, 0.1204]}, {"w": "which", "b": [0.4157, 0.099, 0.4666, 0.1204]}, {"w": "is", "b": [0.4737, 0.099, 0.4869, 0.1204]}, {"w": "a", "b": [0.494, 0.099, 0.5031, 0.1204]}, {"w": "transformer,", "b": [0.5102, 0.099, 0.6141, 0.1204]}, {"w": "so", "b": [0.6211, 0.099, 0.6394, 0.1204]}, {"w": "the", "b": [0.6464, 0.099, 0.6728, 0.1204]}, {"w": "pipeline", "b": [0.6798, 0.099, 0.7472, 0.1204]}, {"w": "has", "b": [0.7543, 0.099, 0.7822, 0.1204]}, {"w": "a", "b": [0.7893, 0.099, 0.7984, 0.1204]}, {"w": "trans", "b": [0.8055, 0.1022, 0.8549, 0.1173]}, {"w": "form()", "b": [0.1428, 0.1221, 0.2022, 0.1372]}, {"w": "method", "b": [0.2079, 0.119, 0.273, 0.1404]}, {"w": "that", "b": [0.2787, 0.119, 0.3112, 0.1404]}, {"w": "applies", "b": [0.317, 0.119, 0.3749, 0.1404]}, {"w": "all", "b": [0.3806, 0.119, 0.4003, 0.1404]}, {"w": "the", "b": [0.406, 0.119, 0.4323, 0.1404]}, {"w": "transforms", "b": [0.438, 0.119, 0.5295, 0.1404]}, {"w": "to", "b": [0.5352, 0.119, 0.5522, 0.1404]}, {"w": "the", "b": [0.5579, 0.119, 0.5843, 0.1404]}, {"w": "data", "b": [0.59, 0.119, 0.6252, 0.1404]}, {"w": "in", "b": [0.6309, 0.119, 0.6479, 0.1404]}, {"w": "sequence", "b": [0.6536, 0.119, 0.7297, 0.1404]}, {"w": "(and", "b": [0.7354, 0.119, 0.7742, 0.1404]}, {"w": "of", "b": [0.7799, 0.119, 0.7967, 0.1404]}, {"w": "course", "b": [0.8024, 0.119, 0.8571, 0.1404]}, {"w": "also", "b": [0.1429, 0.1389, 0.1756, 0.1603]}, {"w": "a", "b": [0.1803, 0.1389, 0.1894, 0.1603]}, {"w": "fit_transform()", "b": [0.1942, 0.1421, 0.3426, 0.1572]}, {"w": "method,", "b": [0.3473, 0.1389, 0.4171, 0.1603]}, {"w": "which", "b": [0.4218, 0.1389, 0.4727, 0.1603]}, {"w": "is", "b": [0.4775, 0.1389, 0.4907, 0.1603]}, {"w": "the", "b": [0.4954, 0.1389, 0.5218, 0.1603]}, {"w": "one", "b": [0.5265, 0.1389, 0.5574, 0.1603]}, {"w": "we", "b": [0.5621, 0.1389, 0.5852, 0.1603]}, {"w": "used).", "b": [0.5899, 0.1389, 0.6405, 0.1603]}]}, {"id": "b_2", "type": "paragraph", "text": "So far, we have handled the categorical columns and the numerical columns sepa‐ rately. It would be more convenient to have a single transformer able to handle all col‐ umns, applying the appropriate transformations to each column. In version 0.20, Scikit-Learn introduced the ColumnTransformer for this purpose, and the good news is that it works great with Pandas DataFrames. Let’s use it to apply all the transforma‐ tions to the housing data:", "words": [{"w": "So", "b": [0.1429, 0.167, 0.1634, 0.1884]}, {"w": "far,", "b": [0.171, 0.167, 0.1975, 0.1884]}, {"w": "we", "b": [0.2052, 0.167, 0.2283, 0.1884]}, {"w": "have", "b": [0.2359, 0.167, 0.2743, 0.1884]}, {"w": "handled", "b": [0.282, 0.167, 0.3498, 0.1884]}, {"w": "the", "b": [0.3574, 0.167, 0.3838, 0.1884]}, {"w": "categorical", "b": [0.3914, 0.167, 0.4811, 0.1884]}, {"w": "columns", "b": [0.4888, 0.167, 0.5606, 0.1884]}, {"w": "and", "b": [0.5683, 0.167, 0.5998, 0.1884]}, {"w": "the", "b": [0.6075, 0.167, 0.6338, 0.1884]}, {"w": "numerical", "b": [0.6415, 0.167, 0.726, 0.1884]}, {"w": "columns", "b": [0.7336, 0.167, 0.8055, 0.1884]}, {"w": "sepa‐", "b": [0.8132, 0.167, 0.8572, 0.1884]}, {"w": "rately.", "b": [0.1429, 0.1861, 0.1926, 0.2075]}, {"w": "It", "b": [0.1973, 0.1861, 0.21, 0.2075]}, {"w": "would", "b": [0.2147, 0.1861, 0.2669, 0.2075]}, {"w": "be", "b": [0.2717, 0.1861, 0.2911, 0.2075]}, {"w": "more", "b": [0.2958, 0.1861, 0.3401, 0.2075]}, {"w": "convenient", "b": [0.3448, 0.1861, 0.4369, 0.2075]}, {"w": "to", "b": [0.4416, 0.1861, 0.4586, 0.2075]}, {"w": "have", "b": [0.4633, 0.1861, 0.5017, 0.2075]}, {"w": "a", "b": [0.5064, 0.1861, 0.5156, 0.2075]}, {"w": "single", "b": [0.5203, 0.1861, 0.5688, 0.2075]}, {"w": "transformer", "b": [0.5735, 0.1861, 0.674, 0.2075]}, {"w": "able", "b": [0.6787, 0.1861, 0.7126, 0.2075]}, {"w": "to", "b": [0.7173, 0.1861, 0.7343, 0.2075]}, {"w": "handle", "b": [0.739, 0.1861, 0.7958, 0.2075]}, {"w": "all", "b": [0.8005, 0.1861, 0.8202, 0.2075]}, {"w": "col‐", "b": [0.8249, 0.1861, 0.8571, 0.2075]}, {"w": "umns,", "b": [0.1429, 0.2051, 0.1948, 0.2265]}, {"w": "applying", "b": [0.2037, 0.2051, 0.2758, 0.2265]}, {"w": "the", "b": [0.2848, 0.2051, 0.3111, 0.2265]}, {"w": "appropriate", "b": [0.32, 0.2051, 0.4171, 0.2265]}, {"w": "transformations", "b": [0.4261, 0.2051, 0.5603, 0.2265]}, {"w": "to", "b": [0.5692, 0.2051, 0.5862, 0.2265]}, {"w": "each", "b": [0.5951, 0.2051, 0.633, 0.2265]}, {"w": "column.", "b": [0.6419, 0.2051, 0.7109, 0.2265]}, {"w": "In", "b": [0.7198, 0.2051, 0.7383, 0.2265]}, {"w": "version", "b": [0.7472, 0.2051, 0.8087, 0.2265]}, {"w": "0.20,", "b": [0.8176, 0.2051, 0.8571, 0.2265]}, {"w": "Scikit-Learn", "b": [0.1429, 0.2251, 0.2451, 0.2465]}, {"w": "introduced", "b": [0.2507, 0.2251, 0.3427, 0.2465]}, {"w": "the", "b": [0.3483, 0.2251, 0.3746, 0.2465]}, {"w": "ColumnTransformer", "b": [0.3802, 0.2282, 0.5484, 0.2433]}, {"w": "for", "b": [0.554, 0.2251, 0.5785, 0.2465]}, {"w": "this", "b": [0.5841, 0.2251, 0.6148, 0.2465]}, {"w": "purpose,", "b": [0.6203, 0.2251, 0.6928, 0.2465]}, {"w": "and", "b": [0.6984, 0.2251, 0.7299, 0.2465]}, {"w": "the", "b": [0.7355, 0.2251, 0.7618, 0.2465]}, {"w": "good", "b": [0.7674, 0.2251, 0.8094, 0.2465]}, {"w": "news", "b": [0.815, 0.2251, 0.8571, 0.2465]}, {"w": "is", "b": [0.1428, 0.2441, 0.1561, 0.2655]}, {"w": "that", "b": [0.1612, 0.2441, 0.1938, 0.2655]}, {"w": "it", "b": [0.199, 0.2441, 0.2109, 0.2655]}, {"w": "works", "b": [0.2161, 0.2441, 0.2667, 0.2655]}, {"w": "great", "b": [0.2718, 0.2441, 0.3132, 0.2655]}, {"w": "with", "b": [0.3184, 0.2441, 0.3557, 0.2655]}, {"w": "Pandas", "b": [0.3609, 0.2441, 0.4205, 0.2655]}, {"w": "DataFrames.", "b": [0.4256, 0.2441, 0.5314, 0.2655]}, {"w": "Let’s", "b": [0.5366, 0.2441, 0.5727, 0.2655]}, {"w": "use", "b": [0.5779, 0.2441, 0.6054, 0.2655]}, {"w": "it", "b": [0.6106, 0.2441, 0.6225, 0.2655]}, {"w": "to", "b": [0.6277, 0.2441, 0.6447, 0.2655]}, {"w": "apply", "b": [0.6498, 0.2441, 0.6952, 0.2655]}, {"w": "all", "b": [0.7004, 0.2441, 0.7201, 0.2655]}, {"w": "the", "b": [0.7252, 0.2441, 0.7516, 0.2655]}, {"w": "transforma‐", "b": [0.7567, 0.2441, 0.8571, 0.2655]}, {"w": "tions", "b": [0.1429, 0.2631, 0.1845, 0.2846]}, {"w": "to", "b": [0.1892, 0.2631, 0.2062, 0.2846]}, {"w": "the", "b": [0.2109, 0.2631, 0.2372, 0.2846]}, {"w": "housing", "b": [0.242, 0.2631, 0.3092, 0.2846]}, {"w": "data:", "b": [0.3139, 0.2631, 0.3539, 0.2846]}]}, {"id": "b_3", "type": "paragraph", "text": "from sklearn.compose import ColumnTransformer", "words": [{"w": "from", "b": [0.1766, 0.2951, 0.2103, 0.308]}, {"w": "sklearn.compose", "b": [0.2187, 0.2951, 0.3452, 0.308]}, {"w": "import", "b": [0.3537, 0.2951, 0.4043, 0.308]}, {"w": "ColumnTransformer", "b": [0.4127, 0.2951, 0.556, 0.308]}]}, {"id": "b_4", "type": "equation", "text": "num_attribs = list(housing_num) cat_attribs = [\"ocean_proximity\"]", "words": [{"w": "num_attribs", "b": [0.1766, 0.326, 0.2693, 0.3388]}, {"w": "=", "b": [0.2778, 0.326, 0.2862, 0.3388]}, {"w": "list(housing_num)", "b": [0.2946, 0.326, 0.438, 0.3388]}, {"w": "cat_attribs", "b": [0.1766, 0.3414, 0.2693, 0.3542]}, {"w": "=", "b": [0.2778, 0.3414, 0.2862, 0.3542]}, {"w": "[\"ocean_proximity\"]", "b": [0.2946, 0.3414, 0.4549, 0.3542]}]}, {"id": "b_5", "type": "paragraph", "text": "full_pipeline = ColumnTransformer([ (\"num\", num_pipeline, num_attribs), (\"cat\", OneHotEncoder(), cat_attribs), ])", "words": [{"w": "full_pipeline", "b": [0.1766, 0.3722, 0.2862, 0.3851]}, {"w": "=", "b": [0.2946, 0.3722, 0.3031, 0.3851]}, {"w": "ColumnTransformer([", "b": [0.3115, 0.3722, 0.4717, 0.3851]}, {"w": "(\"num\",", "b": [0.244, 0.3876, 0.3031, 0.4005]}, {"w": "num_pipeline,", "b": [0.3115, 0.3876, 0.4211, 0.4005]}, {"w": "num_attribs),", "b": [0.4296, 0.3876, 0.5392, 0.4005]}, {"w": "(\"cat\",", "b": [0.244, 0.4031, 0.3031, 0.4159]}, {"w": "OneHotEncoder(),", "b": [0.3115, 0.4031, 0.4464, 0.4159]}, {"w": "cat_attribs),", "b": [0.4549, 0.4031, 0.5645, 0.4159]}, {"w": "])", "b": [0.2103, 0.4185, 0.2272, 0.4313]}]}, {"id": "b_6", "type": "equation", "text": "housing_prepared = full_pipeline.fit_transform(housing)", "words": [{"w": "housing_prepared", "b": [0.1766, 0.4493, 0.3115, 0.4622]}, {"w": "=", "b": [0.3199, 0.4493, 0.3284, 0.4622]}, {"w": "full_pipeline.fit_transform(housing)", "b": [0.3368, 0.4493, 0.6404, 0.4622]}]}, {"id": "b_7", "type": "paragraph", "text": "Here is how this works: first we import the ColumnTransformer class, next we get the list of numerical column names and the list of categorical column names, and we construct a ColumnTransformer. The constructor requires a list of tuples, where each tuple contains a name22, a transformer and a list of names (or indices) of columns that the transformer should be applied to. In this example, we specify that the numer‐ ical columns should be transformed using the num_pipeline that we defined earlier, and the categorical columns should be transformed using a OneHotEncoder. Finally, we apply this ColumnTransformer to the housing data: it applies each transformer to the appropriate columns and concatenates the outputs along the second axis (the transformers must return the same number of rows).", "words": [{"w": "Here", "b": [0.1429, 0.4708, 0.1837, 0.4923]}, {"w": "is", "b": [0.1891, 0.4708, 0.2023, 0.4923]}, {"w": "how", "b": [0.2077, 0.4708, 0.2437, 0.4923]}, {"w": "this", "b": [0.249, 0.4708, 0.2797, 0.4923]}, {"w": "works:", "b": [0.2851, 0.4708, 0.3404, 0.4923]}, {"w": "first", "b": [0.3458, 0.4708, 0.3793, 0.4923]}, {"w": "we", "b": [0.3846, 0.4708, 0.4078, 0.4923]}, {"w": "import", "b": [0.4131, 0.4708, 0.471, 0.4923]}, {"w": "the", "b": [0.4763, 0.4708, 0.5027, 0.4923]}, {"w": "ColumnTransformer", "b": [0.508, 0.474, 0.6762, 0.4891]}, {"w": "class,", "b": [0.6816, 0.4708, 0.7249, 0.4923]}, {"w": "next", "b": [0.7302, 0.4708, 0.7667, 0.4923]}, {"w": "we", "b": [0.772, 0.4708, 0.7951, 0.4923]}, {"w": "get", "b": [0.8005, 0.4708, 0.8255, 0.4923]}, {"w": "the", "b": [0.8308, 0.4708, 0.8571, 0.4923]}, {"w": "list", "b": [0.1429, 0.4899, 0.1677, 0.5113]}, {"w": "of", "b": [0.1756, 0.4899, 0.1924, 0.5113]}, {"w": "numerical", "b": [0.2003, 0.4899, 0.2849, 0.5113]}, {"w": "column", "b": [0.2928, 0.4899, 0.357, 0.5113]}, {"w": "names", "b": [0.3649, 0.4899, 0.419, 0.5113]}, {"w": "and", "b": [0.4269, 0.4899, 0.4585, 0.5113]}, {"w": "the", "b": [0.4664, 0.4899, 0.4927, 0.5113]}, {"w": "list", "b": [0.5006, 0.4899, 0.5255, 0.5113]}, {"w": "of", "b": [0.5334, 0.4899, 0.5502, 0.5113]}, {"w": "categorical", "b": [0.5581, 0.4899, 0.6478, 0.5113]}, {"w": "column", "b": [0.6557, 0.4899, 0.7199, 0.5113]}, {"w": "names,", "b": [0.7278, 0.4899, 0.7867, 0.5113]}, {"w": "and", "b": [0.7946, 0.4899, 0.8261, 0.5113]}, {"w": "we", "b": [0.834, 0.4899, 0.8572, 0.5113]}, {"w": "construct", "b": [0.1429, 0.5098, 0.2217, 0.5313]}, {"w": "a", "b": [0.2272, 0.5098, 0.2363, 0.5313]}, {"w": "ColumnTransformer.", "b": [0.2419, 0.5098, 0.4148, 0.5313]}, {"w": "The", "b": [0.4204, 0.5098, 0.4532, 0.5313]}, {"w": "constructor", "b": [0.4587, 0.5098, 0.5559, 0.5313]}, {"w": "requires", "b": [0.5614, 0.5098, 0.6295, 0.5313]}, {"w": "a", "b": [0.6351, 0.5098, 0.6442, 0.5313]}, {"w": "list", "b": [0.6497, 0.5098, 0.6746, 0.5313]}, {"w": "of", "b": [0.6801, 0.5098, 0.6969, 0.5313]}, {"w": "tuples,", "b": [0.7025, 0.5098, 0.7573, 0.5313]}, {"w": "where", "b": [0.7628, 0.5098, 0.8137, 0.5313]}, {"w": "each", "b": [0.8192, 0.5098, 0.8571, 0.5313]}, {"w": "tuple", "b": [0.1429, 0.5289, 0.1853, 0.5503]}, {"w": "contains", "b": [0.1927, 0.5289, 0.2632, 0.5503]}, {"w": "a", "b": [0.2706, 0.5289, 0.2798, 0.5503]}, {"w": "name22,", "b": [0.2871, 0.5289, 0.3498, 0.5503]}, {"w": "a", "b": [0.3571, 0.5289, 0.3663, 0.5503]}, {"w": "transformer", "b": [0.3736, 0.5289, 0.4741, 0.5503]}, {"w": "and", "b": [0.4814, 0.5289, 0.513, 0.5503]}, {"w": "a", "b": [0.5204, 0.5289, 0.5295, 0.5503]}, {"w": "list", "b": [0.5369, 0.5289, 0.5617, 0.5503]}, {"w": "of", "b": [0.5691, 0.5289, 0.5859, 0.5503]}, {"w": "names", "b": [0.5933, 0.5289, 0.6474, 0.5503]}, {"w": "(or", "b": [0.6547, 0.5289, 0.6803, 0.5503]}, {"w": "indices)", "b": [0.6877, 0.5289, 0.7537, 0.5503]}, {"w": "of", "b": [0.7611, 0.5289, 0.7779, 0.5503]}, {"w": "columns", "b": [0.7853, 0.5289, 0.8571, 0.5503]}, {"w": "that", "b": [0.1428, 0.5479, 0.1754, 0.5693]}, {"w": "the", "b": [0.1804, 0.5479, 0.2068, 0.5693]}, {"w": "transformer", "b": [0.2117, 0.5479, 0.3122, 0.5693]}, {"w": "should", "b": [0.3172, 0.5479, 0.3739, 0.5693]}, {"w": "be", "b": [0.3789, 0.5479, 0.3983, 0.5693]}, {"w": "applied", "b": [0.4033, 0.5479, 0.4646, 0.5693]}, {"w": "to.", "b": [0.4696, 0.5479, 0.4907, 0.5693]}, {"w": "In", "b": [0.4957, 0.5479, 0.5142, 0.5693]}, {"w": "this", "b": [0.5192, 0.5479, 0.5499, 0.5693]}, {"w": "example,", "b": [0.5549, 0.5479, 0.6291, 0.5693]}, {"w": "we", "b": [0.6341, 0.5479, 0.6573, 0.5693]}, {"w": "specify", "b": [0.6622, 0.5479, 0.7201, 0.5693]}, {"w": "that", "b": [0.7251, 0.5479, 0.7577, 0.5693]}, {"w": "the", "b": [0.7627, 0.5479, 0.789, 0.5693]}, {"w": "numer‐", "b": [0.794, 0.5479, 0.8571, 0.5693]}, {"w": "ical", "b": [0.1429, 0.5679, 0.1717, 0.5893]}, {"w": "columns", "b": [0.1779, 0.5679, 0.2497, 0.5893]}, {"w": "should", "b": [0.2559, 0.5679, 0.3127, 0.5893]}, {"w": "be", "b": [0.3188, 0.5679, 0.3383, 0.5893]}, {"w": "transformed", "b": [0.3445, 0.5679, 0.4482, 0.5893]}, {"w": "using", "b": [0.4544, 0.5679, 0.4998, 0.5893]}, {"w": "the", "b": [0.506, 0.5679, 0.5323, 0.5893]}, {"w": "num_pipeline", "b": [0.5385, 0.5711, 0.6572, 0.5861]}, {"w": "that", "b": [0.6634, 0.5679, 0.696, 0.5893]}, {"w": "we", "b": [0.7022, 0.5679, 0.7253, 0.5893]}, {"w": "defined", "b": [0.7315, 0.5679, 0.7944, 0.5893]}, {"w": "earlier,", "b": [0.8005, 0.5679, 0.8572, 0.5893]}, {"w": "and", "b": [0.1429, 0.5878, 0.1744, 0.6092]}, {"w": "the", "b": [0.1811, 0.5878, 0.2074, 0.6092]}, {"w": "categorical", "b": [0.214, 0.5878, 0.3037, 0.6092]}, {"w": "columns", "b": [0.3104, 0.5878, 0.3823, 0.6092]}, {"w": "should", "b": [0.3889, 0.5878, 0.4456, 0.6092]}, {"w": "be", "b": [0.4523, 0.5878, 0.4717, 0.6092]}, {"w": "transformed", "b": [0.4784, 0.5878, 0.5821, 0.6092]}, {"w": "using", "b": [0.5887, 0.5878, 0.6342, 0.6092]}, {"w": "a", "b": [0.6408, 0.5878, 0.65, 0.6092]}, {"w": "OneHotEncoder.", "b": [0.6566, 0.5878, 0.79, 0.6092]}, {"w": "Finally,", "b": [0.7967, 0.5878, 0.8571, 0.6092]}, {"w": "we", "b": [0.1429, 0.6078, 0.166, 0.6292]}, {"w": "apply", "b": [0.1719, 0.6078, 0.2173, 0.6292]}, {"w": "this", "b": [0.2232, 0.6078, 0.254, 0.6292]}, {"w": "ColumnTransformer", "b": [0.2599, 0.611, 0.4281, 0.626]}, {"w": "to", "b": [0.434, 0.6078, 0.451, 0.6292]}, {"w": "the", "b": [0.4569, 0.6078, 0.4833, 0.6292]}, {"w": "housing", "b": [0.4892, 0.6078, 0.5564, 0.6292]}, {"w": "data:", "b": [0.5623, 0.6078, 0.6023, 0.6292]}, {"w": "it", "b": [0.6082, 0.6078, 0.6202, 0.6292]}, {"w": "applies", "b": [0.6261, 0.6078, 0.684, 0.6292]}, {"w": "each", "b": [0.6899, 0.6078, 0.7279, 0.6292]}, {"w": "transformer", "b": [0.7338, 0.6078, 0.8342, 0.6292]}, {"w": "to", "b": [0.8402, 0.6078, 0.8571, 0.6292]}, {"w": "the", "b": [0.1429, 0.6268, 0.1692, 0.6482]}, {"w": "appropriate", "b": [0.1777, 0.6268, 0.2749, 0.6482]}, {"w": "columns", "b": [0.2834, 0.6268, 0.3553, 0.6482]}, {"w": "and", "b": [0.3638, 0.6268, 0.3953, 0.6482]}, {"w": "concatenates", "b": [0.4039, 0.6268, 0.5105, 0.6482]}, {"w": "the", "b": [0.519, 0.6268, 0.5453, 0.6482]}, {"w": "outputs", "b": [0.5539, 0.6268, 0.6179, 0.6482]}, {"w": "along", "b": [0.6264, 0.6268, 0.6726, 0.6482]}, {"w": "the", "b": [0.6811, 0.6268, 0.7075, 0.6482]}, {"w": "second", "b": [0.716, 0.6268, 0.7743, 0.6482]}, {"w": "axis", "b": [0.7829, 0.6268, 0.8151, 0.6482]}, {"w": "(the", "b": [0.8236, 0.6268, 0.8572, 0.6482]}, {"w": "transformers", "b": [0.1429, 0.6459, 0.2509, 0.6673]}, {"w": "must", "b": [0.2557, 0.6459, 0.2974, 0.6673]}, {"w": "return", "b": [0.3021, 0.6459, 0.3553, 0.6673]}, {"w": "the", "b": [0.36, 0.6459, 0.3863, 0.6673]}, {"w": "same", "b": [0.391, 0.6459, 0.4338, 0.6673]}, {"w": "number", "b": [0.4385, 0.6459, 0.5048, 0.6673]}, {"w": "of", "b": [0.5095, 0.6459, 0.5263, 0.6673]}, {"w": "rows).", "b": [0.531, 0.6459, 0.5833, 0.6673]}]}, {"id": "b_8", "type": "paragraph", "text": "Note that the OneHotEncoder returns a sparse matrix, while the num_pipeline returns a dense matrix. When there is such a mix of sparse and dense matrices, the Colum nTransformer estimates the density of the final matrix (i.e., the ratio of non-zero cells), and it returns a sparse matrix if the density is lower than a given threshold (by default, sparse_threshold=0.3). In this example, it returns a dense matrix. And that’s it! We have a preprocessing pipeline that takes the full housing data and applies the appropriate transformations to each column.", "words": [{"w": "Note", "b": [0.1429, 0.6749, 0.1837, 0.6963]}, {"w": "that", "b": [0.1884, 0.6749, 0.221, 0.6963]}, {"w": "the", "b": [0.2257, 0.6749, 0.252, 0.6963]}, {"w": "OneHotEncoder", "b": [0.257, 0.6781, 0.3857, 0.6931]}, {"w": "returns", "b": [0.3905, 0.6749, 0.4513, 0.6963]}, {"w": "a", "b": [0.456, 0.6749, 0.4652, 0.6963]}, {"w": "sparse", "b": [0.4699, 0.6749, 0.5218, 0.6963]}, {"w": "matrix,", "b": [0.5266, 0.6749, 0.5866, 0.6963]}, {"w": "while", "b": [0.5913, 0.6749, 0.6365, 0.6963]}, {"w": "the", "b": [0.6412, 0.6749, 0.6675, 0.6963]}, {"w": "num_pipeline", "b": [0.6728, 0.6781, 0.7915, 0.6931]}, {"w": "returns", "b": [0.7964, 0.6749, 0.8572, 0.6963]}, {"w": "a", "b": [0.1429, 0.6948, 0.152, 0.7162]}, {"w": "dense", "b": [0.1592, 0.6948, 0.2069, 0.7162]}, {"w": "matrix.", "b": [0.2141, 0.6948, 0.2742, 0.7162]}, {"w": "When", "b": [0.2813, 0.6948, 0.3329, 0.7162]}, {"w": "there", "b": [0.3401, 0.6948, 0.383, 0.7162]}, {"w": "is", "b": [0.3902, 0.6948, 0.4034, 0.7162]}, {"w": "such", "b": [0.4106, 0.6948, 0.4493, 0.7162]}, {"w": "a", "b": [0.4564, 0.6948, 0.4656, 0.7162]}, {"w": "mix", "b": [0.4728, 0.6948, 0.5052, 0.7162]}, {"w": "of", "b": [0.5124, 0.6948, 0.5292, 0.7162]}, {"w": "sparse", "b": [0.5364, 0.6948, 0.5883, 0.7162]}, {"w": "and", "b": [0.5955, 0.6948, 0.627, 0.7162]}, {"w": "dense", "b": [0.6342, 0.6948, 0.6819, 0.7162]}, {"w": "matrices,", "b": [0.6891, 0.6948, 0.7647, 0.7162]}, {"w": "the", "b": [0.7718, 0.6948, 0.7982, 0.7162]}, {"w": "Colum", "b": [0.8053, 0.698, 0.8548, 0.7131]}, {"w": "nTransformer", "b": [0.1429, 0.7179, 0.2616, 0.733]}, {"w": "estimates", "b": [0.27, 0.7148, 0.3471, 0.7362]}, {"w": "the", "b": [0.3555, 0.7148, 0.3819, 0.7362]}, {"w": "density", "b": [0.3903, 0.7148, 0.4507, 0.7362]}, {"w": "of", "b": [0.4591, 0.7148, 0.4759, 0.7362]}, {"w": "the", "b": [0.4843, 0.7148, 0.5106, 0.7362]}, {"w": "final", "b": [0.519, 0.7148, 0.5566, 0.7362]}, {"w": "matrix", "b": [0.565, 0.7148, 0.6203, 0.7362]}, {"w": "(i.e.,", "b": [0.6287, 0.7148, 0.6646, 0.7362]}, {"w": "the", "b": [0.673, 0.7148, 0.6993, 0.7362]}, {"w": "ratio", "b": [0.7077, 0.7148, 0.7468, 0.7362]}, {"w": "of", "b": [0.7552, 0.7148, 0.7719, 0.7362]}, {"w": "non-zero", "b": [0.7804, 0.7148, 0.8571, 0.7362]}, {"w": "cells),", "b": [0.1429, 0.7338, 0.1907, 0.7552]}, {"w": "and", "b": [0.1962, 0.7338, 0.2277, 0.7552]}, {"w": "it", "b": [0.2332, 0.7338, 0.2451, 0.7552]}, {"w": "returns", "b": [0.2506, 0.7338, 0.3114, 0.7552]}, {"w": "a", "b": [0.3169, 0.7338, 0.326, 0.7552]}, {"w": "sparse", "b": [0.3315, 0.7338, 0.3835, 0.7552]}, {"w": "matrix", "b": [0.389, 0.7338, 0.4443, 0.7552]}, {"w": "if", "b": [0.4498, 0.7338, 0.4615, 0.7552]}, {"w": "the", "b": [0.467, 0.7338, 0.4933, 0.7552]}, {"w": "density", "b": [0.4988, 0.7338, 0.5592, 0.7552]}, {"w": "is", "b": [0.5647, 0.7338, 0.578, 0.7552]}, {"w": "lower", "b": [0.5834, 0.7338, 0.6302, 0.7552]}, {"w": "than", "b": [0.6357, 0.7338, 0.6737, 0.7552]}, {"w": "a", "b": [0.6792, 0.7338, 0.6883, 0.7552]}, {"w": "given", "b": [0.6938, 0.7338, 0.7391, 0.7552]}, {"w": "threshold", "b": [0.7446, 0.7338, 0.8243, 0.7552]}, {"w": "(by", "b": [0.8298, 0.7338, 0.8571, 0.7552]}, {"w": "default,", "b": [0.1429, 0.7538, 0.2051, 0.7752]}, {"w": "sparse_threshold=0.3).", "b": [0.2143, 0.7538, 0.4242, 0.7752]}, {"w": "In", "b": [0.4334, 0.7538, 0.4519, 0.7752]}, {"w": "this", "b": [0.4611, 0.7538, 0.4918, 0.7752]}, {"w": "example,", "b": [0.5011, 0.7538, 0.5753, 0.7752]}, {"w": "it", "b": [0.5846, 0.7538, 0.5965, 0.7752]}, {"w": "returns", "b": [0.6057, 0.7538, 0.6665, 0.7752]}, {"w": "a", "b": [0.6757, 0.7538, 0.6849, 0.7752]}, {"w": "dense", "b": [0.6941, 0.7538, 0.7419, 0.7752]}, {"w": "matrix.", "b": [0.7511, 0.7538, 0.8111, 0.7752]}, {"w": "And", "b": [0.8204, 0.7538, 0.8572, 0.7752]}, {"w": "that’s", "b": [0.1429, 0.7728, 0.1852, 0.7942]}, {"w": "it!", "b": [0.1905, 0.7728, 0.2082, 0.7942]}, {"w": "We", "b": [0.2136, 0.7728, 0.2406, 0.7942]}, {"w": "have", "b": [0.246, 0.7728, 0.2844, 0.7942]}, {"w": "a", "b": [0.2897, 0.7728, 0.2989, 0.7942]}, {"w": "preprocessing", "b": [0.3042, 0.7728, 0.4207, 0.7942]}, {"w": "pipeline", "b": [0.426, 0.7728, 0.4934, 0.7942]}, {"w": "that", "b": [0.4988, 0.7728, 0.5313, 0.7942]}, {"w": "takes", "b": [0.5367, 0.7728, 0.579, 0.7942]}, {"w": "the", "b": [0.5844, 0.7728, 0.6107, 0.7942]}, {"w": "full", "b": [0.6161, 0.7728, 0.6438, 0.7942]}, {"w": "housing", "b": [0.6492, 0.7728, 0.7164, 0.7942]}, {"w": "data", "b": [0.7217, 0.7728, 0.757, 0.7942]}, {"w": "and", "b": [0.7623, 0.7728, 0.7939, 0.7942]}, {"w": "applies", "b": [0.7992, 0.7728, 0.8571, 0.7942]}, {"w": "the", "b": [0.1429, 0.7919, 0.1692, 0.8133]}, {"w": "appropriate", "b": [0.1739, 0.7919, 0.271, 0.8133]}, {"w": "transformations", "b": [0.2758, 0.7919, 0.41, 0.8133]}, {"w": "to", "b": [0.4147, 0.7919, 0.4317, 0.8133]}, {"w": "each", "b": [0.4364, 0.7919, 0.4744, 0.8133]}, {"w": "column.", "b": [0.4791, 0.7919, 0.5481, 0.8133]}]}, {"id": "b_9", "type": "equation", "text": "74 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "74", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 101, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Instead of a transformer, you can specify the string \"drop\" if you want the columns to be dropped. Or you can specify \"pass through\" if you want the columns to be left untouched. By default, the remaining columns (i.e., the ones that were not listed) will be dropped, but you can set the remainder hyperparameter to any transformer (or to \"passthrough\") if you want these columns to be handled differently.", "words": [{"w": "Instead", "b": [0.2714, 0.0801, 0.3276, 0.0997]}, {"w": "of", "b": [0.3339, 0.0801, 0.3493, 0.0997]}, {"w": "a", "b": [0.3555, 0.0801, 0.3639, 0.0997]}, {"w": "transformer,", "b": [0.3702, 0.0801, 0.4652, 0.0997]}, {"w": "you", "b": [0.4714, 0.0801, 0.5, 0.0997]}, {"w": "can", "b": [0.5063, 0.0801, 0.5331, 0.0997]}, {"w": "specify", "b": [0.5394, 0.0801, 0.5923, 0.0997]}, {"w": "the", "b": [0.5986, 0.0801, 0.6227, 0.0997]}, {"w": "string", "b": [0.629, 0.0801, 0.6733, 0.0997]}, {"w": "\"drop\"", "b": [0.6796, 0.083, 0.7338, 0.0968]}, {"w": "if", "b": [0.7401, 0.0801, 0.7509, 0.0997]}, {"w": "you", "b": [0.7571, 0.0801, 0.7857, 0.0997]}, {"w": "want", "b": [0.2714, 0.0983, 0.3087, 0.1179]}, {"w": "the", "b": [0.3191, 0.0983, 0.3432, 0.1179]}, {"w": "columns", "b": [0.3536, 0.0983, 0.4193, 0.1179]}, {"w": "to", "b": [0.4297, 0.0983, 0.4452, 0.1179]}, {"w": "be", "b": [0.4556, 0.0983, 0.4734, 0.1179]}, {"w": "dropped.", "b": [0.4838, 0.0983, 0.5531, 0.1179]}, {"w": "Or", "b": [0.5635, 0.0983, 0.5848, 0.1179]}, {"w": "you", "b": [0.5952, 0.0983, 0.6237, 0.1179]}, {"w": "can", "b": [0.6341, 0.0983, 0.661, 0.1179]}, {"w": "specify", "b": [0.6714, 0.0983, 0.7243, 0.1179]}, {"w": "\"pass", "b": [0.7347, 0.1012, 0.7799, 0.115]}, {"w": "through\"", "b": [0.2714, 0.1195, 0.3438, 0.1333]}, {"w": "if", "b": [0.3487, 0.1166, 0.3595, 0.1361]}, {"w": "you", "b": [0.3644, 0.1166, 0.393, 0.1361]}, {"w": "want", "b": [0.398, 0.1166, 0.4353, 0.1361]}, {"w": "the", "b": [0.4402, 0.1166, 0.4643, 0.1361]}, {"w": "columns", "b": [0.4692, 0.1166, 0.535, 0.1361]}, {"w": "to", "b": [0.5399, 0.1166, 0.5554, 0.1361]}, {"w": "be", "b": [0.5604, 0.1166, 0.5782, 0.1361]}, {"w": "left", "b": [0.5831, 0.1166, 0.6075, 0.1361]}, {"w": "untouched.", "b": [0.6124, 0.1166, 0.699, 0.1361]}, {"w": "By", "b": [0.7039, 0.1166, 0.7239, 0.1361]}, {"w": "default,", "b": [0.7288, 0.1166, 0.7857, 0.1361]}, {"w": "the", "b": [0.2714, 0.134, 0.2955, 0.1536]}, {"w": "remaining", "b": [0.3017, 0.134, 0.3808, 0.1536]}, {"w": "columns", "b": [0.387, 0.134, 0.4527, 0.1536]}, {"w": "(i.e.,", "b": [0.4589, 0.134, 0.4917, 0.1536]}, {"w": "the", "b": [0.4979, 0.134, 0.522, 0.1536]}, {"w": "ones", "b": [0.5282, 0.134, 0.5634, 0.1536]}, {"w": "that", "b": [0.5696, 0.134, 0.5994, 0.1536]}, {"w": "were", "b": [0.6056, 0.134, 0.6419, 0.1536]}, {"w": "not", "b": [0.6481, 0.134, 0.6741, 0.1536]}, {"w": "listed)", "b": [0.6803, 0.134, 0.7277, 0.1536]}, {"w": "will", "b": [0.734, 0.134, 0.7617, 0.1536]}, {"w": "be", "b": [0.7679, 0.134, 0.7857, 0.1536]}, {"w": "dropped,", "b": [0.2714, 0.1522, 0.3407, 0.1718]}, {"w": "but", "b": [0.3488, 0.1522, 0.3744, 0.1718]}, {"w": "you", "b": [0.3825, 0.1522, 0.4111, 0.1718]}, {"w": "can", "b": [0.4192, 0.1522, 0.446, 0.1718]}, {"w": "set", "b": [0.4541, 0.1522, 0.475, 0.1718]}, {"w": "the", "b": [0.4831, 0.1522, 0.5072, 0.1718]}, {"w": "remainder", "b": [0.5153, 0.1551, 0.5967, 0.1689]}, {"w": "hyperparameter", "b": [0.6048, 0.1522, 0.7269, 0.1718]}, {"w": "to", "b": [0.735, 0.1522, 0.7505, 0.1718]}, {"w": "any", "b": [0.7586, 0.1522, 0.7857, 0.1718]}, {"w": "transformer", "b": [0.2714, 0.1705, 0.3632, 0.19]}, {"w": "(or", "b": [0.3676, 0.1705, 0.3909, 0.19]}, {"w": "to", "b": [0.3953, 0.1705, 0.4108, 0.19]}, {"w": "\"passthrough\")", "b": [0.4155, 0.1705, 0.5397, 0.19]}, {"w": "if", "b": [0.5442, 0.1705, 0.5549, 0.19]}, {"w": "you", "b": [0.5594, 0.1705, 0.588, 0.19]}, {"w": "want", "b": [0.5924, 0.1705, 0.6297, 0.19]}, {"w": "these", "b": [0.6342, 0.1705, 0.6733, 0.19]}, {"w": "columns", "b": [0.6778, 0.1705, 0.7435, 0.19]}, {"w": "to", "b": [0.748, 0.1705, 0.7635, 0.19]}, {"w": "be", "b": [0.768, 0.1705, 0.7857, 0.19]}, {"w": "handled", "b": [0.2714, 0.1879, 0.3334, 0.2074]}, {"w": "differently.", "b": [0.3377, 0.1879, 0.4198, 0.2074]}]}, {"id": "b_1", "type": "paragraph", "text": "If you are using Scikit-Learn 0.19 or earlier, you can use a third-party library such as sklearn-pandas, or roll out your own custom transformer to get the same function‐ ality as the ColumnTransformer. Alternatively, you can use the FeatureUnion class which can also apply different transformers and concatenate their outputs, but you cannot specify different columns for each transformer, they all apply to the whole data. It is possible to work around this limitation using a custom transformer for col‐ umn selection (see the Jupyter notebook for an example).", "words": [{"w": "If", "b": [0.1429, 0.2277, 0.1561, 0.2492]}, {"w": "you", "b": [0.1618, 0.2277, 0.193, 0.2492]}, {"w": "are", "b": [0.1987, 0.2277, 0.2244, 0.2492]}, {"w": "using", "b": [0.2301, 0.2277, 0.2755, 0.2492]}, {"w": "Scikit-Learn", "b": [0.2811, 0.2277, 0.3834, 0.2492]}, {"w": "0.19", "b": [0.3891, 0.2277, 0.4238, 0.2492]}, {"w": "or", "b": [0.4295, 0.2277, 0.4478, 0.2492]}, {"w": "earlier,", "b": [0.4535, 0.2277, 0.5101, 0.2492]}, {"w": "you", "b": [0.5157, 0.2277, 0.547, 0.2492]}, {"w": "can", "b": [0.5526, 0.2277, 0.582, 0.2492]}, {"w": "use", "b": [0.5876, 0.2277, 0.6152, 0.2492]}, {"w": "a", "b": [0.6208, 0.2277, 0.63, 0.2492]}, {"w": "third-party", "b": [0.6356, 0.2277, 0.7286, 0.2492]}, {"w": "library", "b": [0.7342, 0.2277, 0.7904, 0.2492]}, {"w": "such", "b": [0.7961, 0.2277, 0.8347, 0.2492]}, {"w": "as", "b": [0.8404, 0.2277, 0.8571, 0.2492]}, {"w": "sklearn-pandas,", "b": [0.1429, 0.2477, 0.2862, 0.2691]}, {"w": "or", "b": [0.2919, 0.2477, 0.3102, 0.2691]}, {"w": "roll", "b": [0.3159, 0.2477, 0.3448, 0.2691]}, {"w": "out", "b": [0.3506, 0.2477, 0.3786, 0.2691]}, {"w": "your", "b": [0.3843, 0.2477, 0.4233, 0.2691]}, {"w": "own", "b": [0.429, 0.2477, 0.4653, 0.2691]}, {"w": "custom", "b": [0.471, 0.2477, 0.5326, 0.2691]}, {"w": "transformer", "b": [0.5383, 0.2477, 0.6388, 0.2691]}, {"w": "to", "b": [0.6445, 0.2477, 0.6615, 0.2691]}, {"w": "get", "b": [0.6672, 0.2477, 0.6921, 0.2691]}, {"w": "the", "b": [0.6979, 0.2477, 0.7242, 0.2691]}, {"w": "same", "b": [0.7299, 0.2477, 0.7726, 0.2691]}, {"w": "function‐", "b": [0.7783, 0.2477, 0.8571, 0.2691]}, {"w": "ality", "b": [0.1429, 0.2676, 0.1788, 0.289]}, {"w": "as", "b": [0.1867, 0.2676, 0.2035, 0.289]}, {"w": "the", "b": [0.2114, 0.2676, 0.2377, 0.289]}, {"w": "ColumnTransformer.", "b": [0.2457, 0.2676, 0.4187, 0.289]}, {"w": "Alternatively,", "b": [0.4266, 0.2676, 0.5378, 0.289]}, {"w": "you", "b": [0.5458, 0.2676, 0.577, 0.289]}, {"w": "can", "b": [0.5849, 0.2676, 0.6143, 0.289]}, {"w": "use", "b": [0.6222, 0.2676, 0.6498, 0.289]}, {"w": "the", "b": [0.6577, 0.2676, 0.684, 0.289]}, {"w": "FeatureUnion", "b": [0.6919, 0.2708, 0.8107, 0.2859]}, {"w": "class", "b": [0.8186, 0.2676, 0.8571, 0.289]}, {"w": "which", "b": [0.1429, 0.2867, 0.1938, 0.3081]}, {"w": "can", "b": [0.2009, 0.2867, 0.2302, 0.3081]}, {"w": "also", "b": [0.2373, 0.2867, 0.27, 0.3081]}, {"w": "apply", "b": [0.2771, 0.2867, 0.3225, 0.3081]}, {"w": "different", "b": [0.3296, 0.2867, 0.4013, 0.3081]}, {"w": "transformers", "b": [0.4084, 0.2867, 0.5165, 0.3081]}, {"w": "and", "b": [0.5235, 0.2867, 0.5551, 0.3081]}, {"w": "concatenate", "b": [0.5622, 0.2867, 0.6611, 0.3081]}, {"w": "their", "b": [0.6682, 0.2867, 0.7079, 0.3081]}, {"w": "outputs,", "b": [0.7149, 0.2867, 0.7837, 0.3081]}, {"w": "but", "b": [0.7908, 0.2867, 0.8188, 0.3081]}, {"w": "you", "b": [0.8259, 0.2867, 0.8571, 0.3081]}, {"w": "cannot", "b": [0.1429, 0.3057, 0.2006, 0.3271]}, {"w": "specify", "b": [0.2085, 0.3057, 0.2663, 0.3271]}, {"w": "different", "b": [0.2742, 0.3057, 0.3459, 0.3271]}, {"w": "columns", "b": [0.3538, 0.3057, 0.4256, 0.3271]}, {"w": "for", "b": [0.4335, 0.3057, 0.458, 0.3271]}, {"w": "each", "b": [0.4659, 0.3057, 0.5038, 0.3271]}, {"w": "transformer,", "b": [0.5117, 0.3057, 0.6156, 0.3271]}, {"w": "they", "b": [0.6234, 0.3057, 0.6593, 0.3271]}, {"w": "all", "b": [0.6672, 0.3057, 0.6868, 0.3271]}, {"w": "apply", "b": [0.6947, 0.3057, 0.7401, 0.3271]}, {"w": "to", "b": [0.748, 0.3057, 0.765, 0.3271]}, {"w": "the", "b": [0.7728, 0.3057, 0.7992, 0.3271]}, {"w": "whole", "b": [0.807, 0.3057, 0.8572, 0.3271]}, {"w": "data.", "b": [0.1429, 0.3248, 0.1829, 0.3462]}, {"w": "It", "b": [0.1881, 0.3248, 0.2008, 0.3462]}, {"w": "is", "b": [0.2061, 0.3248, 0.2193, 0.3462]}, {"w": "possible", "b": [0.2246, 0.3248, 0.2917, 0.3462]}, {"w": "to", "b": [0.297, 0.3248, 0.314, 0.3462]}, {"w": "work", "b": [0.3192, 0.3248, 0.3622, 0.3462]}, {"w": "around", "b": [0.3675, 0.3248, 0.4284, 0.3462]}, {"w": "this", "b": [0.4337, 0.3248, 0.4644, 0.3462]}, {"w": "limitation", "b": [0.4697, 0.3248, 0.5523, 0.3462]}, {"w": "using", "b": [0.5575, 0.3248, 0.603, 0.3462]}, {"w": "a", "b": [0.6082, 0.3248, 0.6174, 0.3462]}, {"w": "custom", "b": [0.6227, 0.3248, 0.6842, 0.3462]}, {"w": "transformer", "b": [0.6895, 0.3248, 0.7899, 0.3462]}, {"w": "for", "b": [0.7952, 0.3248, 0.8197, 0.3462]}, {"w": "col‐", "b": [0.825, 0.3248, 0.8571, 0.3462]}, {"w": "umn", "b": [0.1429, 0.3438, 0.1824, 0.3652]}, {"w": "selection", "b": [0.1871, 0.3438, 0.2605, 0.3652]}, {"w": "(see", "b": [0.2652, 0.3438, 0.2978, 0.3652]}, {"w": "the", "b": [0.3025, 0.3438, 0.3289, 0.3652]}, {"w": "Jupyter", "b": [0.3336, 0.3438, 0.3943, 0.3652]}, {"w": "notebook", "b": [0.399, 0.3438, 0.4784, 0.3652]}, {"w": "for", "b": [0.4831, 0.3438, 0.5076, 0.3652]}, {"w": "an", "b": [0.5124, 0.3438, 0.5329, 0.3652]}, {"w": "example).", "b": [0.5376, 0.3438, 0.6191, 0.3652]}]}, {"id": "b_2", "type": "paragraph", "text": "Select and Train a Model", "words": [{"w": "Select", "b": [0.1429, 0.3782, 0.217, 0.4125]}, {"w": "and", "b": [0.223, 0.3782, 0.2701, 0.4125]}, {"w": "Train", "b": [0.276, 0.3782, 0.3392, 0.4125]}, {"w": "a", "b": [0.3452, 0.3782, 0.36, 0.4125]}, {"w": "Model", "b": [0.366, 0.3782, 0.4433, 0.4125]}]}, {"id": "b_3", "type": "paragraph", "text": "At last! You framed the problem, you got the data and explored it, you sampled a training set and a test set, and you wrote transformation pipelines to clean up and prepare your data for Machine Learning algorithms automatically. You are now ready to select and train a Machine Learning model.", "words": [{"w": "At", "b": [0.1429, 0.4194, 0.1628, 0.4408]}, {"w": "last!", "b": [0.1704, 0.4194, 0.2046, 0.4408]}, {"w": "You", "b": [0.2123, 0.4194, 0.2446, 0.4408]}, {"w": "framed", "b": [0.2523, 0.4194, 0.3122, 0.4408]}, {"w": "the", "b": [0.3199, 0.4194, 0.3462, 0.4408]}, {"w": "problem,", "b": [0.3539, 0.4194, 0.4297, 0.4408]}, {"w": "you", "b": [0.4374, 0.4194, 0.4686, 0.4408]}, {"w": "got", "b": [0.4763, 0.4194, 0.503, 0.4408]}, {"w": "the", "b": [0.5107, 0.4194, 0.537, 0.4408]}, {"w": "data", "b": [0.5447, 0.4194, 0.5799, 0.4408]}, {"w": "and", "b": [0.5876, 0.4194, 0.6191, 0.4408]}, {"w": "explored", "b": [0.6268, 0.4194, 0.6999, 0.4408]}, {"w": "it,", "b": [0.7076, 0.4194, 0.7242, 0.4408]}, {"w": "you", "b": [0.7319, 0.4194, 0.7632, 0.4408]}, {"w": "sampled", "b": [0.7708, 0.4194, 0.8403, 0.4408]}, {"w": "a", "b": [0.848, 0.4194, 0.8571, 0.4408]}, {"w": "training", "b": [0.1429, 0.4385, 0.2098, 0.4599]}, {"w": "set", "b": [0.217, 0.4385, 0.2398, 0.4599]}, {"w": "and", "b": [0.247, 0.4385, 0.2786, 0.4599]}, {"w": "a", "b": [0.2858, 0.4385, 0.2949, 0.4599]}, {"w": "test", "b": [0.3021, 0.4385, 0.3313, 0.4599]}, {"w": "set,", "b": [0.3385, 0.4385, 0.3661, 0.4599]}, {"w": "and", "b": [0.3733, 0.4385, 0.4049, 0.4599]}, {"w": "you", "b": [0.4121, 0.4385, 0.4433, 0.4599]}, {"w": "wrote", "b": [0.4505, 0.4385, 0.4984, 0.4599]}, {"w": "transformation", "b": [0.5056, 0.4385, 0.6321, 0.4599]}, {"w": "pipelines", "b": [0.6393, 0.4385, 0.7144, 0.4599]}, {"w": "to", "b": [0.7216, 0.4385, 0.7385, 0.4599]}, {"w": "clean", "b": [0.7457, 0.4385, 0.7892, 0.4599]}, {"w": "up", "b": [0.7964, 0.4385, 0.8184, 0.4599]}, {"w": "and", "b": [0.8256, 0.4385, 0.8571, 0.4599]}, {"w": "prepare", "b": [0.1429, 0.4575, 0.207, 0.4789]}, {"w": "your", "b": [0.2121, 0.4575, 0.2511, 0.4789]}, {"w": "data", "b": [0.2562, 0.4575, 0.2915, 0.4789]}, {"w": "for", "b": [0.2966, 0.4575, 0.3211, 0.4789]}, {"w": "Machine", "b": [0.3263, 0.4575, 0.3994, 0.4789]}, {"w": "Learning", "b": [0.4045, 0.4575, 0.4796, 0.4789]}, {"w": "algorithms", "b": [0.4847, 0.4575, 0.575, 0.4789]}, {"w": "automatically.", "b": [0.5801, 0.4575, 0.696, 0.4789]}, {"w": "You", "b": [0.7011, 0.4575, 0.7335, 0.4789]}, {"w": "are", "b": [0.7386, 0.4575, 0.7643, 0.4789]}, {"w": "now", "b": [0.7694, 0.4575, 0.8057, 0.4789]}, {"w": "ready", "b": [0.8109, 0.4575, 0.8572, 0.4789]}, {"w": "to", "b": [0.1429, 0.4766, 0.1598, 0.498]}, {"w": "select", "b": [0.1646, 0.4766, 0.2104, 0.498]}, {"w": "and", "b": [0.2151, 0.4766, 0.2466, 0.498]}, {"w": "train", "b": [0.2514, 0.4766, 0.2916, 0.498]}, {"w": "a", "b": [0.2963, 0.4766, 0.3054, 0.498]}, {"w": "Machine", "b": [0.3102, 0.4766, 0.3833, 0.498]}, {"w": "Learning", "b": [0.388, 0.4766, 0.4631, 0.498]}, {"w": "model.", "b": [0.4678, 0.4766, 0.5254, 0.498]}]}, {"id": "b_4", "type": "paragraph", "text": "Training and Evaluating on the Training Set", "words": [{"w": "Training", "b": [0.1429, 0.5107, 0.2288, 0.5393]}, {"w": "and", "b": [0.2338, 0.5107, 0.2731, 0.5393]}, {"w": "Evaluating", "b": [0.278, 0.5107, 0.3885, 0.5393]}, {"w": "on", "b": [0.3934, 0.5107, 0.4198, 0.5393]}, {"w": "the", "b": [0.4248, 0.5107, 0.4596, 0.5393]}, {"w": "Training", "b": [0.4646, 0.5107, 0.5505, 0.5393]}, {"w": "Set", "b": [0.5555, 0.5107, 0.5886, 0.5393]}]}, {"id": "b_5", "type": "paragraph", "text": "The good news is that thanks to all these previous steps, things are now going to be much simpler than you might think. Let’s first train a Linear Regression model, like we did in the previous chapter:", "words": [{"w": "The", "b": [0.1429, 0.5452, 0.1757, 0.5666]}, {"w": "good", "b": [0.182, 0.5452, 0.224, 0.5666]}, {"w": "news", "b": [0.2302, 0.5452, 0.2724, 0.5666]}, {"w": "is", "b": [0.2787, 0.5452, 0.2919, 0.5666]}, {"w": "that", "b": [0.2982, 0.5452, 0.3308, 0.5666]}, {"w": "thanks", "b": [0.337, 0.5452, 0.393, 0.5666]}, {"w": "to", "b": [0.3993, 0.5452, 0.4163, 0.5666]}, {"w": "all", "b": [0.4226, 0.5452, 0.4422, 0.5666]}, {"w": "these", "b": [0.4485, 0.5452, 0.4914, 0.5666]}, {"w": "previous", "b": [0.4976, 0.5452, 0.5697, 0.5666]}, {"w": "steps,", "b": [0.576, 0.5452, 0.6221, 0.5666]}, {"w": "things", "b": [0.6284, 0.5452, 0.6803, 0.5666]}, {"w": "are", "b": [0.6865, 0.5452, 0.7123, 0.5666]}, {"w": "now", "b": [0.7185, 0.5452, 0.7548, 0.5666]}, {"w": "going", "b": [0.7611, 0.5452, 0.8082, 0.5666]}, {"w": "to", "b": [0.8145, 0.5452, 0.8314, 0.5666]}, {"w": "be", "b": [0.8377, 0.5452, 0.8572, 0.5666]}, {"w": "much", "b": [0.1429, 0.5642, 0.1905, 0.5857]}, {"w": "simpler", "b": [0.197, 0.5642, 0.2597, 0.5857]}, {"w": "than", "b": [0.2661, 0.5642, 0.3042, 0.5857]}, {"w": "you", "b": [0.3106, 0.5642, 0.3419, 0.5857]}, {"w": "might", "b": [0.3483, 0.5642, 0.3978, 0.5857]}, {"w": "think.", "b": [0.4043, 0.5642, 0.4538, 0.5857]}, {"w": "Let’s", "b": [0.4603, 0.5642, 0.4965, 0.5857]}, {"w": "first", "b": [0.5029, 0.5642, 0.5364, 0.5857]}, {"w": "train", "b": [0.5429, 0.5642, 0.5831, 0.5857]}, {"w": "a", "b": [0.5896, 0.5642, 0.5987, 0.5857]}, {"w": "Linear", "b": [0.6052, 0.5642, 0.6591, 0.5857]}, {"w": "Regression", "b": [0.6656, 0.5642, 0.7566, 0.5857]}, {"w": "model,", "b": [0.7631, 0.5642, 0.8206, 0.5857]}, {"w": "like", "b": [0.8271, 0.5642, 0.8571, 0.5857]}, {"w": "we", "b": [0.1429, 0.5833, 0.166, 0.6047]}, {"w": "did", "b": [0.1707, 0.5833, 0.1983, 0.6047]}, {"w": "in", "b": [0.203, 0.5833, 0.22, 0.6047]}, {"w": "the", "b": [0.2247, 0.5833, 0.2511, 0.6047]}, {"w": "previous", "b": [0.2558, 0.5833, 0.3279, 0.6047]}, {"w": "chapter:", "b": [0.3326, 0.5833, 0.4004, 0.6047]}]}, {"id": "b_6", "type": "equation", "text": "from sklearn.linear_model import LinearRegression", "words": [{"w": "from", "b": [0.1766, 0.6153, 0.2103, 0.6281]}, {"w": "sklearn.linear_model", "b": [0.2188, 0.6153, 0.3874, 0.6281]}, {"w": "import", "b": [0.3958, 0.6153, 0.4464, 0.6281]}, {"w": "LinearRegression", "b": [0.4549, 0.6153, 0.5898, 0.6281]}]}, {"id": "b_7", "type": "equation", "text": "lin_reg = LinearRegression() lin_reg.fit(housing_prepared, housing_labels)", "words": [{"w": "lin_reg", "b": [0.1766, 0.6461, 0.2356, 0.659]}, {"w": "=", "b": [0.2441, 0.6461, 0.2525, 0.659]}, {"w": "LinearRegression()", "b": [0.2609, 0.6461, 0.4127, 0.659]}, {"w": "lin_reg.fit(housing_prepared,", "b": [0.1766, 0.6615, 0.4211, 0.6744]}, {"w": "housing_labels)", "b": [0.4296, 0.6615, 0.5561, 0.6744]}]}, {"id": "b_8", "type": "paragraph", "text": "Done! You now have a working Linear Regression model. Let’s try it out on a few instances from the training set:", "words": [{"w": "Done!", "b": [0.1428, 0.6822, 0.1948, 0.7036]}, {"w": "You", "b": [0.2023, 0.6822, 0.2347, 0.7036]}, {"w": "now", "b": [0.2422, 0.6822, 0.2785, 0.7036]}, {"w": "have", "b": [0.2861, 0.6822, 0.3245, 0.7036]}, {"w": "a", "b": [0.332, 0.6822, 0.3411, 0.7036]}, {"w": "working", "b": [0.3487, 0.6822, 0.4184, 0.7036]}, {"w": "Linear", "b": [0.4259, 0.6822, 0.4798, 0.7036]}, {"w": "Regression", "b": [0.4874, 0.6822, 0.5784, 0.7036]}, {"w": "model.", "b": [0.5859, 0.6822, 0.6435, 0.7036]}, {"w": "Let’s", "b": [0.651, 0.6822, 0.6872, 0.7036]}, {"w": "try", "b": [0.6947, 0.6822, 0.719, 0.7036]}, {"w": "it", "b": [0.7265, 0.6822, 0.7385, 0.7036]}, {"w": "out", "b": [0.746, 0.6822, 0.7741, 0.7036]}, {"w": "on", "b": [0.7816, 0.6822, 0.8036, 0.7036]}, {"w": "a", "b": [0.8112, 0.6822, 0.8203, 0.7036]}, {"w": "few", "b": [0.8278, 0.6822, 0.8571, 0.7036]}, {"w": "instances", "b": [0.1429, 0.7012, 0.2197, 0.7226]}, {"w": "from", "b": [0.2244, 0.7012, 0.266, 0.7226]}, {"w": "the", "b": [0.2707, 0.7012, 0.2971, 0.7226]}, {"w": "training", "b": [0.3018, 0.7012, 0.3687, 0.7226]}, {"w": "set:", "b": [0.3735, 0.7012, 0.4011, 0.7226]}]}, {"id": "b_9", "type": "paragraph", "text": ">>> some_data = housing.iloc[:5] >>> some_labels = housing_labels.iloc[:5] >>> some_data_prepared = full_pipeline.transform(some_data) >>> print(\"Predictions:\", lin_reg.predict(some_data_prepared)) Predictions: [ 210644.6045 317768.8069 210956.4333 59218.9888 189747.5584] >>> print(\"Labels:\", list(some_labels)) Labels: [286600.0, 340600.0, 196900.0, 46300.0, 254500.0]", "words": [{"w": ">>>", "b": [0.1766, 0.7332, 0.2019, 0.746]}, {"w": "some_data", "b": [0.2103, 0.7332, 0.2862, 0.746]}, {"w": "=", "b": [0.2946, 0.7332, 0.3031, 0.746]}, {"w": "housing.iloc[:5]", "b": [0.3115, 0.7332, 0.4464, 0.746]}, {"w": ">>>", "b": [0.1766, 0.7486, 0.2019, 0.7614]}, {"w": "some_labels", "b": [0.2103, 0.7486, 0.3031, 0.7614]}, {"w": "=", "b": [0.3115, 0.7486, 0.3199, 0.7614]}, {"w": "housing_labels.iloc[:5]", "b": [0.3284, 0.7486, 0.5223, 0.7614]}, {"w": ">>>", "b": [0.1766, 0.764, 0.2019, 0.7769]}, {"w": "some_data_prepared", "b": [0.2103, 0.764, 0.3621, 0.7769]}, {"w": "=", "b": [0.3705, 0.764, 0.379, 0.7769]}, {"w": "full_pipeline.transform(some_data)", "b": [0.3874, 0.764, 0.6741, 0.7769]}, {"w": ">>>", "b": [0.1766, 0.7794, 0.2019, 0.7923]}, {"w": "print(\"Predictions:\",", "b": [0.2103, 0.7794, 0.3874, 0.7923]}, {"w": "lin_reg.predict(some_data_prepared))", "b": [0.3958, 0.7794, 0.6994, 0.7923]}, {"w": "Predictions:", "b": [0.1766, 0.7949, 0.2778, 0.8077]}, {"w": "[", "b": [0.2862, 0.7949, 0.2946, 0.8077]}, {"w": "210644.6045", "b": [0.3031, 0.7949, 0.3958, 0.8077]}, {"w": "317768.8069", "b": [0.4127, 0.7949, 0.5055, 0.8077]}, {"w": "210956.4333", "b": [0.5223, 0.7949, 0.6151, 0.8077]}, {"w": "59218.9888", "b": [0.6319, 0.7949, 0.7163, 0.8077]}, {"w": "189747.5584]", "b": [0.7331, 0.7949, 0.8343, 0.8077]}, {"w": ">>>", "b": [0.1766, 0.8103, 0.2019, 0.8231]}, {"w": "print(\"Labels:\",", "b": [0.2103, 0.8103, 0.3452, 0.8231]}, {"w": "list(some_labels))", "b": [0.3537, 0.8103, 0.5055, 0.8231]}, {"w": "Labels:", "b": [0.1766, 0.8257, 0.2356, 0.8385]}, {"w": "[286600.0,", "b": [0.244, 0.8257, 0.3284, 0.8385]}, {"w": "340600.0,", "b": [0.3368, 0.8257, 0.4127, 0.8385]}, {"w": "196900.0,", "b": [0.4211, 0.8257, 0.497, 0.8385]}, {"w": "46300.0,", "b": [0.5055, 0.8257, 0.5729, 0.8385]}, {"w": "254500.0]", "b": [0.5813, 0.8257, 0.6572, 0.8385]}]}, {"id": "b_10", "type": "paragraph", "text": "Select and Train a Model | 75", "words": [{"w": "Select", "b": [0.6602, 0.9225, 0.6955, 0.9388]}, {"w": "and", "b": [0.6983, 0.9225, 0.7207, 0.9388]}, {"w": "Train", "b": [0.7236, 0.9225, 0.7536, 0.9388]}, {"w": "a", "b": [0.7565, 0.9225, 0.7635, 0.9388]}, {"w": "Model", "b": [0.7663, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "75", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 102, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "It works, although the predictions are not exactly accurate (e.g., the first prediction is off by close to 40%!). Let’s measure this regression model’s RMSE on the whole train‐ ing set using Scikit-Learn’s mean_squared_error function:", "words": [{"w": "It", "b": [0.1429, 0.0791, 0.1555, 0.1005]}, {"w": "works,", "b": [0.1609, 0.0791, 0.2162, 0.1005]}, {"w": "although", "b": [0.2216, 0.0791, 0.296, 0.1005]}, {"w": "the", "b": [0.3014, 0.0791, 0.3277, 0.1005]}, {"w": "predictions", "b": [0.3331, 0.0791, 0.4276, 0.1005]}, {"w": "are", "b": [0.4329, 0.0791, 0.4586, 0.1005]}, {"w": "not", "b": [0.464, 0.0791, 0.4924, 0.1005]}, {"w": "exactly", "b": [0.4977, 0.0791, 0.5556, 0.1005]}, {"w": "accurate", "b": [0.5609, 0.0791, 0.6304, 0.1005]}, {"w": "(e.g.,", "b": [0.6358, 0.0791, 0.6758, 0.1005]}, {"w": "the", "b": [0.6812, 0.0791, 0.7075, 0.1005]}, {"w": "first", "b": [0.7129, 0.0791, 0.7464, 0.1005]}, {"w": "prediction", "b": [0.7517, 0.0791, 0.8386, 0.1005]}, {"w": "is", "b": [0.8439, 0.0791, 0.8571, 0.1005]}, {"w": "off", "b": [0.1429, 0.0981, 0.1658, 0.1195]}, {"w": "by", "b": [0.1711, 0.0981, 0.1913, 0.1195]}, {"w": "close", "b": [0.1966, 0.0981, 0.2378, 0.1195]}, {"w": "to", "b": [0.2431, 0.0981, 0.2601, 0.1195]}, {"w": "40%!).", "b": [0.2655, 0.0981, 0.3189, 0.1195]}, {"w": "Let’s", "b": [0.3242, 0.0981, 0.3604, 0.1195]}, {"w": "measure", "b": [0.3657, 0.0981, 0.4361, 0.1195]}, {"w": "this", "b": [0.4414, 0.0981, 0.4721, 0.1195]}, {"w": "regression", "b": [0.4774, 0.0981, 0.5633, 0.1195]}, {"w": "model’s", "b": [0.5686, 0.0981, 0.6312, 0.1195]}, {"w": "RMSE", "b": [0.6365, 0.0981, 0.6897, 0.1195]}, {"w": "on", "b": [0.695, 0.0981, 0.7171, 0.1195]}, {"w": "the", "b": [0.7224, 0.0981, 0.7487, 0.1195]}, {"w": "whole", "b": [0.754, 0.0981, 0.8042, 0.1195]}, {"w": "train‐", "b": [0.8095, 0.0981, 0.8571, 0.1195]}, {"w": "ing", "b": [0.1429, 0.1181, 0.1696, 0.1395]}, {"w": "set", "b": [0.1743, 0.1181, 0.1972, 0.1395]}, {"w": "using", "b": [0.2019, 0.1181, 0.2473, 0.1395]}, {"w": "Scikit-Learn’s", "b": [0.2521, 0.1181, 0.363, 0.1395]}, {"w": "mean_squared_error", "b": [0.3677, 0.1212, 0.5458, 0.1363]}, {"w": "function:", "b": [0.5506, 0.1181, 0.6267, 0.1395]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> from sklearn.metrics import mean_squared_error >>> housing_predictions = lin_reg.predict(housing_prepared) >>> lin_mse = mean_squared_error(housing_labels, housing_predictions) >>> lin_rmse = np.sqrt(lin_mse) >>> lin_rmse 68628.19819848922", "words": [{"w": ">>>", "b": [0.1766, 0.15, 0.2019, 0.1629]}, {"w": "from", "b": [0.2103, 0.15, 0.244, 0.1629]}, {"w": "sklearn.metrics", "b": [0.2525, 0.15, 0.379, 0.1629]}, {"w": "import", "b": [0.3874, 0.15, 0.438, 0.1629]}, {"w": "mean_squared_error", "b": [0.4464, 0.15, 0.5982, 0.1629]}, {"w": ">>>", "b": [0.1766, 0.1654, 0.2019, 0.1783]}, {"w": "housing_predictions", "b": [0.2103, 0.1654, 0.3705, 0.1783]}, {"w": "=", "b": [0.379, 0.1654, 0.3874, 0.1783]}, {"w": "lin_reg.predict(housing_prepared)", "b": [0.3958, 0.1654, 0.6741, 0.1783]}, {"w": ">>>", "b": [0.1766, 0.1809, 0.2019, 0.1937]}, {"w": "lin_mse", "b": [0.2103, 0.1809, 0.2693, 0.1937]}, {"w": "=", "b": [0.2778, 0.1809, 0.2862, 0.1937]}, {"w": "mean_squared_error(housing_labels,", "b": [0.2946, 0.1809, 0.5814, 0.1937]}, {"w": "housing_predictions)", "b": [0.5898, 0.1809, 0.7584, 0.1937]}, {"w": ">>>", "b": [0.1766, 0.1963, 0.2019, 0.2091]}, {"w": "lin_rmse", "b": [0.2103, 0.1963, 0.2778, 0.2091]}, {"w": "=", "b": [0.2862, 0.1963, 0.2946, 0.2091]}, {"w": "np.sqrt(lin_mse)", "b": [0.3031, 0.1963, 0.438, 0.2091]}, {"w": ">>>", "b": [0.1766, 0.2117, 0.2019, 0.2246]}, {"w": "lin_rmse", "b": [0.2103, 0.2117, 0.2778, 0.2246]}, {"w": "68628.19819848922", "b": [0.1766, 0.2271, 0.3199, 0.24]}]}, {"id": "b_2", "type": "paragraph", "text": "Okay, this is better than nothing but clearly not a great score: most districts’ median_housing_values range between $120,000 and $265,000, so a typical predic‐ tion error of $68,628 is not very satisfying. This is an example of a model underfitting the training data. When this happens it can mean that the features do not provide enough information to make good predictions, or that the model is not powerful enough. As we saw in the previous chapter, the main ways to fix underfitting are to select a more powerful model, to feed the training algorithm with better features, or to reduce the constraints on the model. This model is not regularized, so this rules out the last option. You could try to add more features (e.g., the log of the popula‐ tion), but first let’s try a more complex model to see how it does.", "words": [{"w": "Okay,", "b": [0.1429, 0.2478, 0.1903, 0.2692]}, {"w": "this", "b": [0.2017, 0.2478, 0.2324, 0.2692]}, {"w": "is", "b": [0.2437, 0.2478, 0.257, 0.2692]}, {"w": "better", "b": [0.2683, 0.2478, 0.3171, 0.2692]}, {"w": "than", "b": [0.3284, 0.2478, 0.3665, 0.2692]}, {"w": "nothing", "b": [0.3778, 0.2478, 0.444, 0.2692]}, {"w": "but", "b": [0.4554, 0.2478, 0.4834, 0.2692]}, {"w": "clearly", "b": [0.4948, 0.2478, 0.5494, 0.2692]}, {"w": "not", "b": [0.5608, 0.2478, 0.5891, 0.2692]}, {"w": "a", "b": [0.6005, 0.2478, 0.6097, 0.2692]}, {"w": "great", "b": [0.621, 0.2478, 0.6625, 0.2692]}, {"w": "score:", "b": [0.6738, 0.2478, 0.7222, 0.2692]}, {"w": "most", "b": [0.7336, 0.2478, 0.7753, 0.2692]}, {"w": "districts’", "b": [0.7866, 0.2478, 0.8571, 0.2692]}, {"w": "median_housing_values", "b": [0.1429, 0.2709, 0.3507, 0.286]}, {"w": "range", "b": [0.3575, 0.2677, 0.4044, 0.2891]}, {"w": "between", "b": [0.4112, 0.2677, 0.4803, 0.2891]}, {"w": "$120,000", "b": [0.4871, 0.2677, 0.5619, 0.2891]}, {"w": "and", "b": [0.5687, 0.2677, 0.6002, 0.2891]}, {"w": "$265,000,", "b": [0.607, 0.2677, 0.6865, 0.2891]}, {"w": "so", "b": [0.6934, 0.2677, 0.7116, 0.2891]}, {"w": "a", "b": [0.7184, 0.2677, 0.7276, 0.2891]}, {"w": "typical", "b": [0.7344, 0.2677, 0.79, 0.2891]}, {"w": "predic‐", "b": [0.7968, 0.2677, 0.8571, 0.2891]}, {"w": "tion", "b": [0.1429, 0.2868, 0.1768, 0.3082]}, {"w": "error", "b": [0.1818, 0.2868, 0.2244, 0.3082]}, {"w": "of", "b": [0.2294, 0.2868, 0.2462, 0.3082]}, {"w": "$68,628", "b": [0.2511, 0.2868, 0.3158, 0.3082]}, {"w": "is", "b": [0.3208, 0.2868, 0.334, 0.3082]}, {"w": "not", "b": [0.3389, 0.2868, 0.3673, 0.3082]}, {"w": "very", "b": [0.3723, 0.2868, 0.4087, 0.3082]}, {"w": "satisfying.", "b": [0.4136, 0.2868, 0.4971, 0.3082]}, {"w": "This", "b": [0.5021, 0.2868, 0.5393, 0.3082]}, {"w": "is", "b": [0.5442, 0.2868, 0.5575, 0.3082]}, {"w": "an", "b": [0.5624, 0.2868, 0.5829, 0.3082]}, {"w": "example", "b": [0.5879, 0.2868, 0.6574, 0.3082]}, {"w": "of", "b": [0.6623, 0.2868, 0.6791, 0.3082]}, {"w": "a", "b": [0.6841, 0.2868, 0.6932, 0.3082]}, {"w": "model", "b": [0.6982, 0.2868, 0.751, 0.3082]}, {"w": "underfitting", "b": [0.7559, 0.2868, 0.8571, 0.3082]}, {"w": "the", "b": [0.1429, 0.3058, 0.1692, 0.3272]}, {"w": "training", "b": [0.1765, 0.3058, 0.2435, 0.3272]}, {"w": "data.", "b": [0.2508, 0.3058, 0.2908, 0.3272]}, {"w": "When", "b": [0.2981, 0.3058, 0.3497, 0.3272]}, {"w": "this", "b": [0.3571, 0.3058, 0.3878, 0.3272]}, {"w": "happens", "b": [0.3951, 0.3058, 0.4647, 0.3272]}, {"w": "it", "b": [0.472, 0.3058, 0.484, 0.3272]}, {"w": "can", "b": [0.4913, 0.3058, 0.5207, 0.3272]}, {"w": "mean", "b": [0.528, 0.3058, 0.5745, 0.3272]}, {"w": "that", "b": [0.5818, 0.3058, 0.6144, 0.3272]}, {"w": "the", "b": [0.6217, 0.3058, 0.648, 0.3272]}, {"w": "features", "b": [0.6554, 0.3058, 0.7208, 0.3272]}, {"w": "do", "b": [0.7281, 0.3058, 0.7497, 0.3272]}, {"w": "not", "b": [0.7571, 0.3058, 0.7855, 0.3272]}, {"w": "provide", "b": [0.7928, 0.3058, 0.8571, 0.3272]}, {"w": "enough", "b": [0.1429, 0.3248, 0.2057, 0.3463]}, {"w": "information", "b": [0.214, 0.3248, 0.3153, 0.3463]}, {"w": "to", "b": [0.3236, 0.3248, 0.3406, 0.3463]}, {"w": "make", "b": [0.3489, 0.3248, 0.3943, 0.3463]}, {"w": "good", "b": [0.4027, 0.3248, 0.4447, 0.3463]}, {"w": "predictions,", "b": [0.453, 0.3248, 0.5522, 0.3463]}, {"w": "or", "b": [0.5606, 0.3248, 0.5789, 0.3463]}, {"w": "that", "b": [0.5873, 0.3248, 0.6198, 0.3463]}, {"w": "the", "b": [0.6282, 0.3248, 0.6545, 0.3463]}, {"w": "model", "b": [0.6628, 0.3248, 0.7157, 0.3463]}, {"w": "is", "b": [0.724, 0.3248, 0.7372, 0.3463]}, {"w": "not", "b": [0.7456, 0.3248, 0.7739, 0.3463]}, {"w": "powerful", "b": [0.7823, 0.3248, 0.8572, 0.3463]}, {"w": "enough.", "b": [0.1429, 0.3439, 0.2104, 0.3653]}, {"w": "As", "b": [0.2169, 0.3439, 0.2389, 0.3653]}, {"w": "we", "b": [0.2454, 0.3439, 0.2686, 0.3653]}, {"w": "saw", "b": [0.275, 0.3439, 0.3057, 0.3653]}, {"w": "in", "b": [0.3122, 0.3439, 0.3292, 0.3653]}, {"w": "the", "b": [0.3357, 0.3439, 0.362, 0.3653]}, {"w": "previous", "b": [0.3685, 0.3439, 0.4406, 0.3653]}, {"w": "chapter,", "b": [0.447, 0.3439, 0.513, 0.3653]}, {"w": "the", "b": [0.5195, 0.3439, 0.5458, 0.3653]}, {"w": "main", "b": [0.5523, 0.3439, 0.5955, 0.3653]}, {"w": "ways", "b": [0.602, 0.3439, 0.6422, 0.3653]}, {"w": "to", "b": [0.6487, 0.3439, 0.6657, 0.3653]}, {"w": "fix", "b": [0.6722, 0.3439, 0.6938, 0.3653]}, {"w": "underfitting", "b": [0.7002, 0.3439, 0.8015, 0.3653]}, {"w": "are", "b": [0.808, 0.3439, 0.8337, 0.3653]}, {"w": "to", "b": [0.8402, 0.3439, 0.8571, 0.3653]}, {"w": "select", "b": [0.1429, 0.3629, 0.1886, 0.3844]}, {"w": "a", "b": [0.1948, 0.3629, 0.204, 0.3844]}, {"w": "more", "b": [0.2101, 0.3629, 0.2544, 0.3844]}, {"w": "powerful", "b": [0.2606, 0.3629, 0.3355, 0.3844]}, {"w": "model,", "b": [0.3417, 0.3629, 0.3992, 0.3844]}, {"w": "to", "b": [0.4054, 0.3629, 0.4224, 0.3844]}, {"w": "feed", "b": [0.4285, 0.3629, 0.4634, 0.3844]}, {"w": "the", "b": [0.4696, 0.3629, 0.4959, 0.3844]}, {"w": "training", "b": [0.5021, 0.3629, 0.569, 0.3844]}, {"w": "algorithm", "b": [0.5752, 0.3629, 0.6579, 0.3844]}, {"w": "with", "b": [0.664, 0.3629, 0.7014, 0.3844]}, {"w": "better", "b": [0.7075, 0.3629, 0.7563, 0.3844]}, {"w": "features,", "b": [0.7624, 0.3629, 0.8326, 0.3844]}, {"w": "or", "b": [0.8388, 0.3629, 0.8571, 0.3844]}, {"w": "to", "b": [0.1429, 0.382, 0.1598, 0.4034]}, {"w": "reduce", "b": [0.1667, 0.382, 0.2231, 0.4034]}, {"w": "the", "b": [0.23, 0.382, 0.2563, 0.4034]}, {"w": "constraints", "b": [0.2632, 0.382, 0.3555, 0.4034]}, {"w": "on", "b": [0.3624, 0.382, 0.3844, 0.4034]}, {"w": "the", "b": [0.3914, 0.382, 0.4177, 0.4034]}, {"w": "model.", "b": [0.4246, 0.382, 0.4822, 0.4034]}, {"w": "This", "b": [0.4891, 0.382, 0.5263, 0.4034]}, {"w": "model", "b": [0.5332, 0.382, 0.586, 0.4034]}, {"w": "is", "b": [0.5929, 0.382, 0.6062, 0.4034]}, {"w": "not", "b": [0.6131, 0.382, 0.6415, 0.4034]}, {"w": "regularized,", "b": [0.6484, 0.382, 0.7469, 0.4034]}, {"w": "so", "b": [0.7538, 0.382, 0.772, 0.4034]}, {"w": "this", "b": [0.779, 0.382, 0.8097, 0.4034]}, {"w": "rules", "b": [0.8166, 0.382, 0.8571, 0.4034]}, {"w": "out", "b": [0.1429, 0.401, 0.1709, 0.4224]}, {"w": "the", "b": [0.1778, 0.401, 0.2041, 0.4224]}, {"w": "last", "b": [0.2109, 0.401, 0.2393, 0.4224]}, {"w": "option.", "b": [0.2462, 0.401, 0.3064, 0.4224]}, {"w": "You", "b": [0.3133, 0.401, 0.3456, 0.4224]}, {"w": "could", "b": [0.3525, 0.401, 0.3993, 0.4224]}, {"w": "try", "b": [0.4061, 0.401, 0.4304, 0.4224]}, {"w": "to", "b": [0.4372, 0.401, 0.4542, 0.4224]}, {"w": "add", "b": [0.461, 0.401, 0.4922, 0.4224]}, {"w": "more", "b": [0.499, 0.401, 0.5433, 0.4224]}, {"w": "features", "b": [0.5501, 0.401, 0.6156, 0.4224]}, {"w": "(e.g.,", "b": [0.6224, 0.401, 0.6625, 0.4224]}, {"w": "the", "b": [0.6693, 0.401, 0.6956, 0.4224]}, {"w": "log", "b": [0.7025, 0.401, 0.7281, 0.4224]}, {"w": "of", "b": [0.735, 0.401, 0.7518, 0.4224]}, {"w": "the", "b": [0.7586, 0.401, 0.785, 0.4224]}, {"w": "popula‐", "b": [0.7918, 0.401, 0.8572, 0.4224]}, {"w": "tion),", "b": [0.1429, 0.4201, 0.1888, 0.4415]}, {"w": "but", "b": [0.1935, 0.4201, 0.2215, 0.4415]}, {"w": "first", "b": [0.2262, 0.4201, 0.2597, 0.4415]}, {"w": "let’s", "b": [0.2644, 0.4201, 0.2947, 0.4415]}, {"w": "try", "b": [0.2994, 0.4201, 0.3237, 0.4415]}, {"w": "a", "b": [0.3284, 0.4201, 0.3375, 0.4415]}, {"w": "more", "b": [0.3423, 0.4201, 0.3865, 0.4415]}, {"w": "complex", "b": [0.3913, 0.4201, 0.4622, 0.4415]}, {"w": "model", "b": [0.467, 0.4201, 0.5198, 0.4415]}, {"w": "to", "b": [0.5245, 0.4201, 0.5415, 0.4415]}, {"w": "see", "b": [0.5462, 0.4201, 0.5716, 0.4415]}, {"w": "how", "b": [0.5763, 0.4201, 0.6123, 0.4415]}, {"w": "it", "b": [0.617, 0.4201, 0.629, 0.4415]}, {"w": "does.", "b": [0.6337, 0.4201, 0.6766, 0.4415]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s train a DecisionTreeRegressor. This is a powerful model, capable of finding complex nonlinear relationships in the data (Decision Trees are presented in more detail in Chapter 6). The code should look familiar by now:", "words": [{"w": "Let’s", "b": [0.1429, 0.4491, 0.179, 0.4705]}, {"w": "train", "b": [0.1867, 0.4491, 0.2269, 0.4705]}, {"w": "a", "b": [0.2345, 0.4491, 0.2437, 0.4705]}, {"w": "DecisionTreeRegressor.", "b": [0.2513, 0.4491, 0.4639, 0.4705]}, {"w": "This", "b": [0.4715, 0.4491, 0.5088, 0.4705]}, {"w": "is", "b": [0.5164, 0.4491, 0.5296, 0.4705]}, {"w": "a", "b": [0.5373, 0.4491, 0.5464, 0.4705]}, {"w": "powerful", "b": [0.5541, 0.4491, 0.629, 0.4705]}, {"w": "model,", "b": [0.6366, 0.4491, 0.6942, 0.4705]}, {"w": "capable", "b": [0.7018, 0.4491, 0.7642, 0.4705]}, {"w": "of", "b": [0.7718, 0.4491, 0.7886, 0.4705]}, {"w": "finding", "b": [0.7963, 0.4491, 0.8571, 0.4705]}, {"w": "complex", "b": [0.1429, 0.4681, 0.2138, 0.4896]}, {"w": "nonlinear", "b": [0.2213, 0.4681, 0.3027, 0.4896]}, {"w": "relationships", "b": [0.3102, 0.4681, 0.4177, 0.4896]}, {"w": "in", "b": [0.4252, 0.4681, 0.4422, 0.4896]}, {"w": "the", "b": [0.4497, 0.4681, 0.476, 0.4896]}, {"w": "data", "b": [0.4835, 0.4681, 0.5187, 0.4896]}, {"w": "(Decision", "b": [0.5262, 0.4681, 0.6073, 0.4896]}, {"w": "Trees", "b": [0.6148, 0.4681, 0.659, 0.4896]}, {"w": "are", "b": [0.6665, 0.4681, 0.6922, 0.4896]}, {"w": "presented", "b": [0.6997, 0.4681, 0.7809, 0.4896]}, {"w": "in", "b": [0.7884, 0.4681, 0.8054, 0.4896]}, {"w": "more", "b": [0.8129, 0.4681, 0.8571, 0.4896]}, {"w": "detail", "b": [0.1429, 0.4872, 0.1891, 0.5086]}, {"w": "in", "b": [0.1938, 0.4872, 0.2108, 0.5086]}, {"w": "Chapter", "b": [0.2155, 0.4872, 0.2831, 0.5086]}, {"w": "6).", "b": [0.2878, 0.4872, 0.3098, 0.5086]}, {"w": "The", "b": [0.3145, 0.4872, 0.3473, 0.5086]}, {"w": "code", "b": [0.3521, 0.4872, 0.3914, 0.5086]}, {"w": "should", "b": [0.3961, 0.4872, 0.4528, 0.5086]}, {"w": "look", "b": [0.4576, 0.4872, 0.4944, 0.5086]}, {"w": "familiar", "b": [0.4991, 0.4872, 0.5648, 0.5086]}, {"w": "by", "b": [0.5696, 0.4872, 0.5897, 0.5086]}, {"w": "now:", "b": [0.5944, 0.4872, 0.6361, 0.5086]}]}, {"id": "b_4", "type": "paragraph", "text": "from sklearn.tree import DecisionTreeRegressor", "words": [{"w": "from", "b": [0.1766, 0.5192, 0.2103, 0.532]}, {"w": "sklearn.tree", "b": [0.2188, 0.5192, 0.3199, 0.532]}, {"w": "import", "b": [0.3284, 0.5192, 0.379, 0.532]}, {"w": "DecisionTreeRegressor", "b": [0.3874, 0.5192, 0.5645, 0.532]}]}, {"id": "b_5", "type": "paragraph", "text": "tree_reg = DecisionTreeRegressor() tree_reg.fit(housing_prepared, housing_labels)", "words": [{"w": "tree_reg", "b": [0.1766, 0.55, 0.2441, 0.5629]}, {"w": "=", "b": [0.2525, 0.55, 0.2609, 0.5629]}, {"w": "DecisionTreeRegressor()", "b": [0.2694, 0.55, 0.4633, 0.5629]}, {"w": "tree_reg.fit(housing_prepared,", "b": [0.1766, 0.5654, 0.4296, 0.5783]}, {"w": "housing_labels)", "b": [0.438, 0.5654, 0.5645, 0.5783]}]}, {"id": "b_6", "type": "paragraph", "text": "Now that the model is trained, let’s evaluate it on the training set:", "words": [{"w": "Now", "b": [0.1429, 0.5861, 0.1827, 0.6075]}, {"w": "that", "b": [0.1875, 0.5861, 0.22, 0.6075]}, {"w": "the", "b": [0.2248, 0.5861, 0.2511, 0.6075]}, {"w": "model", "b": [0.2558, 0.5861, 0.3086, 0.6075]}, {"w": "is", "b": [0.3134, 0.5861, 0.3266, 0.6075]}, {"w": "trained,", "b": [0.3313, 0.5861, 0.3961, 0.6075]}, {"w": "let’s", "b": [0.4009, 0.5861, 0.4311, 0.6075]}, {"w": "evaluate", "b": [0.4358, 0.5861, 0.5038, 0.6075]}, {"w": "it", "b": [0.5085, 0.5861, 0.5204, 0.6075]}, {"w": "on", "b": [0.5252, 0.5861, 0.5472, 0.6075]}, {"w": "the", "b": [0.5519, 0.5861, 0.5782, 0.6075]}, {"w": "training", "b": [0.583, 0.5861, 0.6499, 0.6075]}, {"w": "set:", "b": [0.6546, 0.5861, 0.6822, 0.6075]}]}, {"id": "b_7", "type": "paragraph", "text": ">>> housing_predictions = tree_reg.predict(housing_prepared) >>> tree_mse = mean_squared_error(housing_labels, housing_predictions) >>> tree_rmse = np.sqrt(tree_mse) >>> tree_rmse 0.0", "words": [{"w": ">>>", "b": [0.1766, 0.618, 0.2019, 0.6309]}, {"w": "housing_predictions", "b": [0.2103, 0.618, 0.3705, 0.6309]}, {"w": "=", "b": [0.379, 0.618, 0.3874, 0.6309]}, {"w": "tree_reg.predict(housing_prepared)", "b": [0.3958, 0.618, 0.6825, 0.6309]}, {"w": ">>>", "b": [0.1766, 0.6335, 0.2019, 0.6463]}, {"w": "tree_mse", "b": [0.2103, 0.6335, 0.2778, 0.6463]}, {"w": "=", "b": [0.2862, 0.6335, 0.2946, 0.6463]}, {"w": "mean_squared_error(housing_labels,", "b": [0.3031, 0.6335, 0.5898, 0.6463]}, {"w": "housing_predictions)", "b": [0.5982, 0.6335, 0.7669, 0.6463]}, {"w": ">>>", "b": [0.1766, 0.6489, 0.2019, 0.6617]}, {"w": "tree_rmse", "b": [0.2103, 0.6489, 0.2862, 0.6617]}, {"w": "=", "b": [0.2946, 0.6489, 0.3031, 0.6617]}, {"w": "np.sqrt(tree_mse)", "b": [0.3115, 0.6489, 0.4549, 0.6617]}, {"w": ">>>", "b": [0.1766, 0.6643, 0.2019, 0.6771]}, {"w": "tree_rmse", "b": [0.2103, 0.6643, 0.2862, 0.6771]}, {"w": "0.0", "b": [0.1766, 0.6797, 0.2019, 0.6926]}]}, {"id": "b_8", "type": "paragraph", "text": "Wait, what!? No error at all? Could this model really be absolutely perfect? Of course, it is much more likely that the model has badly overfit the data. How can you be sure? As we saw earlier, you don’t want to touch the test set until you are ready to launch a model you are confident about, so you need to use part of the training set for train‐ ing, and part for model validation.", "words": [{"w": "Wait,", "b": [0.1429, 0.7003, 0.1869, 0.7218]}, {"w": "what!?", "b": [0.1921, 0.7003, 0.2463, 0.7218]}, {"w": "No", "b": [0.2515, 0.7003, 0.2771, 0.7218]}, {"w": "error", "b": [0.2823, 0.7003, 0.325, 0.7218]}, {"w": "at", "b": [0.3302, 0.7003, 0.3454, 0.7218]}, {"w": "all?", "b": [0.3506, 0.7003, 0.3782, 0.7218]}, {"w": "Could", "b": [0.3834, 0.7003, 0.4352, 0.7218]}, {"w": "this", "b": [0.4405, 0.7003, 0.4712, 0.7218]}, {"w": "model", "b": [0.4764, 0.7003, 0.5292, 0.7218]}, {"w": "really", "b": [0.5345, 0.7003, 0.5803, 0.7218]}, {"w": "be", "b": [0.5856, 0.7003, 0.605, 0.7218]}, {"w": "absolutely", "b": [0.6103, 0.7003, 0.6946, 0.7218]}, {"w": "perfect?", "b": [0.6999, 0.7003, 0.7655, 0.7218]}, {"w": "Of", "b": [0.7707, 0.7003, 0.7924, 0.7218]}, {"w": "course,", "b": [0.7977, 0.7003, 0.8572, 0.7218]}, {"w": "it", "b": [0.1429, 0.7194, 0.1548, 0.7408]}, {"w": "is", "b": [0.1596, 0.7194, 0.1729, 0.7408]}, {"w": "much", "b": [0.1777, 0.7194, 0.2254, 0.7408]}, {"w": "more", "b": [0.2302, 0.7194, 0.2745, 0.7408]}, {"w": "likely", "b": [0.2793, 0.7194, 0.3242, 0.7408]}, {"w": "that", "b": [0.329, 0.7194, 0.3616, 0.7408]}, {"w": "the", "b": [0.3665, 0.7194, 0.3928, 0.7408]}, {"w": "model", "b": [0.3976, 0.7194, 0.4504, 0.7408]}, {"w": "has", "b": [0.4553, 0.7194, 0.4832, 0.7408]}, {"w": "badly", "b": [0.488, 0.7194, 0.5336, 0.7408]}, {"w": "overfit", "b": [0.5384, 0.7194, 0.5934, 0.7408]}, {"w": "the", "b": [0.5982, 0.7194, 0.6246, 0.7408]}, {"w": "data.", "b": [0.6294, 0.7194, 0.6694, 0.7408]}, {"w": "How", "b": [0.6742, 0.7194, 0.7146, 0.7408]}, {"w": "can", "b": [0.7194, 0.7194, 0.7488, 0.7408]}, {"w": "you", "b": [0.7536, 0.7194, 0.7848, 0.7408]}, {"w": "be", "b": [0.7897, 0.7194, 0.8091, 0.7408]}, {"w": "sure?", "b": [0.814, 0.7194, 0.8571, 0.7408]}, {"w": "As", "b": [0.1429, 0.7384, 0.1649, 0.7599]}, {"w": "we", "b": [0.1704, 0.7384, 0.1936, 0.7599]}, {"w": "saw", "b": [0.1991, 0.7384, 0.2298, 0.7599]}, {"w": "earlier,", "b": [0.2353, 0.7384, 0.2919, 0.7599]}, {"w": "you", "b": [0.2975, 0.7384, 0.3287, 0.7599]}, {"w": "don’t", "b": [0.3343, 0.7384, 0.3759, 0.7599]}, {"w": "want", "b": [0.3814, 0.7384, 0.4222, 0.7599]}, {"w": "to", "b": [0.4277, 0.7384, 0.4447, 0.7599]}, {"w": "touch", "b": [0.4503, 0.7384, 0.4982, 0.7599]}, {"w": "the", "b": [0.5038, 0.7384, 0.5301, 0.7599]}, {"w": "test", "b": [0.5357, 0.7384, 0.5649, 0.7599]}, {"w": "set", "b": [0.5704, 0.7384, 0.5933, 0.7599]}, {"w": "until", "b": [0.5988, 0.7384, 0.6381, 0.7599]}, {"w": "you", "b": [0.6436, 0.7384, 0.6749, 0.7599]}, {"w": "are", "b": [0.6804, 0.7384, 0.7061, 0.7599]}, {"w": "ready", "b": [0.7117, 0.7384, 0.758, 0.7599]}, {"w": "to", "b": [0.7635, 0.7384, 0.7805, 0.7599]}, {"w": "launch", "b": [0.786, 0.7384, 0.8425, 0.7599]}, {"w": "a", "b": [0.848, 0.7384, 0.8571, 0.7599]}, {"w": "model", "b": [0.1429, 0.7575, 0.1957, 0.7789]}, {"w": "you", "b": [0.2018, 0.7575, 0.2331, 0.7789]}, {"w": "are", "b": [0.2393, 0.7575, 0.265, 0.7789]}, {"w": "confident", "b": [0.2712, 0.7575, 0.351, 0.7789]}, {"w": "about,", "b": [0.3571, 0.7575, 0.4097, 0.7789]}, {"w": "so", "b": [0.4158, 0.7575, 0.4341, 0.7789]}, {"w": "you", "b": [0.4403, 0.7575, 0.4715, 0.7789]}, {"w": "need", "b": [0.4777, 0.7575, 0.5178, 0.7789]}, {"w": "to", "b": [0.524, 0.7575, 0.541, 0.7789]}, {"w": "use", "b": [0.5471, 0.7575, 0.5747, 0.7789]}, {"w": "part", "b": [0.5809, 0.7575, 0.615, 0.7789]}, {"w": "of", "b": [0.6212, 0.7575, 0.638, 0.7789]}, {"w": "the", "b": [0.6442, 0.7575, 0.6705, 0.7789]}, {"w": "training", "b": [0.6767, 0.7575, 0.7436, 0.7789]}, {"w": "set", "b": [0.7498, 0.7575, 0.7726, 0.7789]}, {"w": "for", "b": [0.7788, 0.7575, 0.8033, 0.7789]}, {"w": "train‐", "b": [0.8095, 0.7575, 0.8571, 0.7789]}, {"w": "ing,", "b": [0.1429, 0.7765, 0.1743, 0.7979]}, {"w": "and", "b": [0.1791, 0.7765, 0.2106, 0.7979]}, {"w": "part", "b": [0.2153, 0.7765, 0.2495, 0.7979]}, {"w": "for", "b": [0.2542, 0.7765, 0.2787, 0.7979]}, {"w": "model", "b": [0.2835, 0.7765, 0.3363, 0.7979]}, {"w": "validation.", "b": [0.341, 0.7765, 0.4291, 0.7979]}]}, {"id": "b_9", "type": "equation", "text": "Better Evaluation Using Cross-Validation", "words": [{"w": "Better", "b": [0.1428, 0.8107, 0.2081, 0.8393]}, {"w": "Evaluation", "b": [0.2131, 0.8107, 0.323, 0.8393]}, {"w": "Using", "b": [0.328, 0.8107, 0.386, 0.8393]}, {"w": "Cross-Validation", "b": [0.3909, 0.8107, 0.5585, 0.8393]}]}, {"id": "b_10", "type": "paragraph", "text": "One way to evaluate the Decision Tree model would be to use the train_test_split function to split the training set into a smaller training set and a validation set, then", "words": [{"w": "One", "b": [0.1429, 0.8461, 0.1787, 0.8675]}, {"w": "way", "b": [0.1841, 0.8461, 0.2167, 0.8675]}, {"w": "to", "b": [0.2221, 0.8461, 0.2391, 0.8675]}, {"w": "evaluate", "b": [0.2445, 0.8461, 0.3125, 0.8675]}, {"w": "the", "b": [0.3179, 0.8461, 0.3442, 0.8675]}, {"w": "Decision", "b": [0.3497, 0.8461, 0.4235, 0.8675]}, {"w": "Tree", "b": [0.4289, 0.8461, 0.4655, 0.8675]}, {"w": "model", "b": [0.4709, 0.8461, 0.5237, 0.8675]}, {"w": "would", "b": [0.5291, 0.8461, 0.5814, 0.8675]}, {"w": "be", "b": [0.5868, 0.8461, 0.6062, 0.8675]}, {"w": "to", "b": [0.6117, 0.8461, 0.6286, 0.8675]}, {"w": "use", "b": [0.6341, 0.8461, 0.6616, 0.8675]}, {"w": "the", "b": [0.6671, 0.8461, 0.6934, 0.8675]}, {"w": "train_test_split", "b": [0.6988, 0.8493, 0.8571, 0.8643]}, {"w": "function", "b": [0.1429, 0.8651, 0.2143, 0.8865]}, {"w": "to", "b": [0.2203, 0.8651, 0.2373, 0.8865]}, {"w": "split", "b": [0.2434, 0.8651, 0.2792, 0.8865]}, {"w": "the", "b": [0.2852, 0.8651, 0.3116, 0.8865]}, {"w": "training", "b": [0.3176, 0.8651, 0.3846, 0.8865]}, {"w": "set", "b": [0.3907, 0.8651, 0.4135, 0.8865]}, {"w": "into", "b": [0.4196, 0.8651, 0.4532, 0.8865]}, {"w": "a", "b": [0.4592, 0.8651, 0.4684, 0.8865]}, {"w": "smaller", "b": [0.4745, 0.8651, 0.5354, 0.8865]}, {"w": "training", "b": [0.5415, 0.8651, 0.6085, 0.8865]}, {"w": "set", "b": [0.6145, 0.8651, 0.6374, 0.8865]}, {"w": "and", "b": [0.6435, 0.8651, 0.675, 0.8865]}, {"w": "a", "b": [0.6811, 0.8651, 0.6902, 0.8865]}, {"w": "validation", "b": [0.6963, 0.8651, 0.7797, 0.8865]}, {"w": "set,", "b": [0.7857, 0.8651, 0.8133, 0.8865]}, {"w": "then", "b": [0.8194, 0.8651, 0.8571, 0.8865]}]}, {"id": "b_11", "type": "equation", "text": "76 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "76", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 103, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "train your models against the smaller training set and evaluate them against the vali‐ dation set. It’s a bit of work, but nothing too difficult and it would work fairly well.", "words": [{"w": "train", "b": [0.1429, 0.0791, 0.1831, 0.1005]}, {"w": "your", "b": [0.1887, 0.0791, 0.2277, 0.1005]}, {"w": "models", "b": [0.2333, 0.0791, 0.2938, 0.1005]}, {"w": "against", "b": [0.2994, 0.0791, 0.3584, 0.1005]}, {"w": "the", "b": [0.3641, 0.0791, 0.3904, 0.1005]}, {"w": "smaller", "b": [0.396, 0.0791, 0.457, 0.1005]}, {"w": "training", "b": [0.4626, 0.0791, 0.5296, 0.1005]}, {"w": "set", "b": [0.5352, 0.0791, 0.5581, 0.1005]}, {"w": "and", "b": [0.5637, 0.0791, 0.5952, 0.1005]}, {"w": "evaluate", "b": [0.6009, 0.0791, 0.6688, 0.1005]}, {"w": "them", "b": [0.6744, 0.0791, 0.7178, 0.1005]}, {"w": "against", "b": [0.7235, 0.0791, 0.7825, 0.1005]}, {"w": "the", "b": [0.7881, 0.0791, 0.8144, 0.1005]}, {"w": "vali‐", "b": [0.8201, 0.0791, 0.8571, 0.1005]}, {"w": "dation", "b": [0.1429, 0.0981, 0.1966, 0.1195]}, {"w": "set.", "b": [0.2013, 0.0981, 0.2289, 0.1195]}, {"w": "It’s", "b": [0.2336, 0.0981, 0.256, 0.1195]}, {"w": "a", "b": [0.2607, 0.0981, 0.2699, 0.1195]}, {"w": "bit", "b": [0.2746, 0.0981, 0.2971, 0.1195]}, {"w": "of", "b": [0.3019, 0.0981, 0.3187, 0.1195]}, {"w": "work,", "b": [0.3234, 0.0981, 0.3711, 0.1195]}, {"w": "but", "b": [0.3758, 0.0981, 0.4038, 0.1195]}, {"w": "nothing", "b": [0.4086, 0.0981, 0.4748, 0.1195]}, {"w": "too", "b": [0.4795, 0.0981, 0.5071, 0.1195]}, {"w": "difficult", "b": [0.5119, 0.0981, 0.5779, 0.1195]}, {"w": "and", "b": [0.5826, 0.0981, 0.6141, 0.1195]}, {"w": "it", "b": [0.6189, 0.0981, 0.6308, 0.1195]}, {"w": "would", "b": [0.6355, 0.0981, 0.6877, 0.1195]}, {"w": "work", "b": [0.6925, 0.0981, 0.7354, 0.1195]}, {"w": "fairly", "b": [0.7402, 0.0981, 0.7836, 0.1195]}, {"w": "well.", "b": [0.7884, 0.0981, 0.8268, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "A great alternative is to use Scikit-Learn’s K-fold cross-validation feature. The follow‐ ing code randomly splits the training set into 10 distinct subsets called folds, then it trains and evaluates the Decision Tree model 10 times, picking a different fold for evaluation every time and training on the other 9 folds. The result is an array con‐ taining the 10 evaluation scores:", "words": [{"w": "A", "b": [0.1429, 0.1262, 0.1572, 0.1476]}, {"w": "great", "b": [0.1634, 0.1262, 0.2048, 0.1476]}, {"w": "alternative", "b": [0.2109, 0.1262, 0.2989, 0.1476]}, {"w": "is", "b": [0.305, 0.1262, 0.3182, 0.1476]}, {"w": "to", "b": [0.3244, 0.1262, 0.3414, 0.1476]}, {"w": "use", "b": [0.3475, 0.1262, 0.375, 0.1476]}, {"w": "Scikit-Learn’s", "b": [0.3812, 0.1262, 0.4921, 0.1476]}, {"w": "K-fold", "b": [0.4982, 0.126, 0.5495, 0.1476]}, {"w": "cross-validation", "b": [0.5556, 0.126, 0.6837, 0.1476]}, {"w": "feature.", "b": [0.6899, 0.1262, 0.7524, 0.1476]}, {"w": "The", "b": [0.7585, 0.1262, 0.7914, 0.1476]}, {"w": "follow‐", "b": [0.7975, 0.1262, 0.8571, 0.1476]}, {"w": "ing", "b": [0.1429, 0.1453, 0.1696, 0.1667]}, {"w": "code", "b": [0.176, 0.1453, 0.2153, 0.1667]}, {"w": "randomly", "b": [0.2218, 0.1453, 0.3036, 0.1667]}, {"w": "splits", "b": [0.31, 0.1453, 0.3534, 0.1667]}, {"w": "the", "b": [0.3599, 0.1453, 0.3862, 0.1667]}, {"w": "training", "b": [0.3927, 0.1453, 0.4596, 0.1667]}, {"w": "set", "b": [0.4661, 0.1453, 0.4889, 0.1667]}, {"w": "into", "b": [0.4954, 0.1453, 0.5289, 0.1667]}, {"w": "10", "b": [0.5354, 0.1453, 0.5554, 0.1667]}, {"w": "distinct", "b": [0.5618, 0.1453, 0.6245, 0.1667]}, {"w": "subsets", "b": [0.631, 0.1453, 0.6908, 0.1667]}, {"w": "called", "b": [0.6972, 0.1453, 0.7456, 0.1667]}, {"w": "folds,", "b": [0.752, 0.1451, 0.7946, 0.1667]}, {"w": "then", "b": [0.801, 0.1453, 0.8388, 0.1667]}, {"w": "it", "b": [0.8452, 0.1453, 0.8572, 0.1667]}, {"w": "trains", "b": [0.1429, 0.1643, 0.1907, 0.1857]}, {"w": "and", "b": [0.1983, 0.1643, 0.2298, 0.1857]}, {"w": "evaluates", "b": [0.2374, 0.1643, 0.313, 0.1857]}, {"w": "the", "b": [0.3206, 0.1643, 0.347, 0.1857]}, {"w": "Decision", "b": [0.3545, 0.1643, 0.4284, 0.1857]}, {"w": "Tree", "b": [0.436, 0.1643, 0.4725, 0.1857]}, {"w": "model", "b": [0.4801, 0.1643, 0.5329, 0.1857]}, {"w": "10", "b": [0.5405, 0.1643, 0.5605, 0.1857]}, {"w": "times,", "b": [0.5681, 0.1643, 0.6184, 0.1857]}, {"w": "picking", "b": [0.626, 0.1643, 0.6883, 0.1857]}, {"w": "a", "b": [0.6959, 0.1643, 0.7051, 0.1857]}, {"w": "different", "b": [0.7127, 0.1643, 0.7844, 0.1857]}, {"w": "fold", "b": [0.792, 0.1643, 0.825, 0.1857]}, {"w": "for", "b": [0.8326, 0.1643, 0.8571, 0.1857]}, {"w": "evaluation", "b": [0.1429, 0.1834, 0.2295, 0.2048]}, {"w": "every", "b": [0.2364, 0.1834, 0.2816, 0.2048]}, {"w": "time", "b": [0.2885, 0.1834, 0.3264, 0.2048]}, {"w": "and", "b": [0.3332, 0.1834, 0.3647, 0.2048]}, {"w": "training", "b": [0.3716, 0.1834, 0.4385, 0.2048]}, {"w": "on", "b": [0.4454, 0.1834, 0.4674, 0.2048]}, {"w": "the", "b": [0.4743, 0.1834, 0.5006, 0.2048]}, {"w": "other", "b": [0.5075, 0.1834, 0.5521, 0.2048]}, {"w": "9", "b": [0.559, 0.1834, 0.569, 0.2048]}, {"w": "folds.", "b": [0.5758, 0.1834, 0.6213, 0.2048]}, {"w": "The", "b": [0.6282, 0.1834, 0.661, 0.2048]}, {"w": "result", "b": [0.6678, 0.1834, 0.7148, 0.2048]}, {"w": "is", "b": [0.7216, 0.1834, 0.7348, 0.2048]}, {"w": "an", "b": [0.7417, 0.1834, 0.7622, 0.2048]}, {"w": "array", "b": [0.7691, 0.1834, 0.812, 0.2048]}, {"w": "con‐", "b": [0.8189, 0.1834, 0.8571, 0.2048]}, {"w": "taining", "b": [0.1428, 0.2024, 0.2021, 0.2238]}, {"w": "the", "b": [0.2068, 0.2024, 0.2331, 0.2238]}, {"w": "10", "b": [0.2378, 0.2024, 0.2578, 0.2238]}, {"w": "evaluation", "b": [0.2626, 0.2024, 0.3493, 0.2238]}, {"w": "scores:", "b": [0.354, 0.2024, 0.4101, 0.2238]}]}, {"id": "b_2", "type": "paragraph", "text": "from sklearn.model_selection import cross_val_score scores = cross_val_score(tree_reg, housing_prepared, housing_labels, scoring=\"neg_mean_squared_error\", cv=10) tree_rmse_scores = np.sqrt(-scores)", "words": [{"w": "from", "b": [0.1766, 0.2344, 0.2103, 0.2472]}, {"w": "sklearn.model_selection", "b": [0.2188, 0.2344, 0.4127, 0.2472]}, {"w": "import", "b": [0.4211, 0.2344, 0.4717, 0.2472]}, {"w": "cross_val_score", "b": [0.4802, 0.2344, 0.6067, 0.2472]}, {"w": "scores", "b": [0.1766, 0.2498, 0.2272, 0.2627]}, {"w": "=", "b": [0.2356, 0.2498, 0.2441, 0.2627]}, {"w": "cross_val_score(tree_reg,", "b": [0.2525, 0.2498, 0.4633, 0.2627]}, {"w": "housing_prepared,", "b": [0.4717, 0.2498, 0.6151, 0.2627]}, {"w": "housing_labels,", "b": [0.6235, 0.2498, 0.75, 0.2627]}, {"w": "scoring=\"neg_mean_squared_error\",", "b": [0.3874, 0.2652, 0.6657, 0.2781]}, {"w": "cv=10)", "b": [0.6741, 0.2652, 0.7247, 0.2781]}, {"w": "tree_rmse_scores", "b": [0.1766, 0.2807, 0.3115, 0.2935]}, {"w": "=", "b": [0.3199, 0.2807, 0.3284, 0.2935]}, {"w": "np.sqrt(-scores)", "b": [0.3368, 0.2807, 0.4717, 0.2935]}]}, {"id": "b_3", "type": "paragraph", "text": "Scikit-Learn’s cross-validation features expect a utility function (greater is better) rather than a cost function (lower is better), so the scoring function is actually the opposite of the MSE (i.e., a neg‐ ative value), which is why the preceding code computes -scores before calculating the square root.", "words": [{"w": "Scikit-Learn’s", "b": [0.2714, 0.3151, 0.3728, 0.3347]}, {"w": "cross-validation", "b": [0.3833, 0.3151, 0.5051, 0.3347]}, {"w": "features", "b": [0.5156, 0.3151, 0.5755, 0.3347]}, {"w": "expect", "b": [0.586, 0.3151, 0.635, 0.3347]}, {"w": "a", "b": [0.6455, 0.3151, 0.6539, 0.3347]}, {"w": "utility", "b": [0.6644, 0.3151, 0.7099, 0.3347]}, {"w": "function", "b": [0.7204, 0.3151, 0.7857, 0.3347]}, {"w": "(greater", "b": [0.2714, 0.3325, 0.331, 0.3521]}, {"w": "is", "b": [0.3376, 0.3325, 0.3497, 0.3521]}, {"w": "better)", "b": [0.3563, 0.3325, 0.4075, 0.3521]}, {"w": "rather", "b": [0.4141, 0.3325, 0.4603, 0.3521]}, {"w": "than", "b": [0.4669, 0.3325, 0.5017, 0.3521]}, {"w": "a", "b": [0.5083, 0.3325, 0.5166, 0.3521]}, {"w": "cost", "b": [0.5232, 0.3325, 0.5538, 0.3521]}, {"w": "function", "b": [0.5604, 0.3325, 0.6257, 0.3521]}, {"w": "(lower", "b": [0.6323, 0.3325, 0.6816, 0.3521]}, {"w": "is", "b": [0.6882, 0.3325, 0.7003, 0.3521]}, {"w": "better),", "b": [0.7069, 0.3325, 0.7624, 0.3521]}, {"w": "so", "b": [0.769, 0.3325, 0.7857, 0.3521]}, {"w": "the", "b": [0.2714, 0.3499, 0.2955, 0.3695]}, {"w": "scoring", "b": [0.3002, 0.3499, 0.3565, 0.3695]}, {"w": "function", "b": [0.3612, 0.3499, 0.4264, 0.3695]}, {"w": "is", "b": [0.4311, 0.3499, 0.4432, 0.3695]}, {"w": "actually", "b": [0.4479, 0.3499, 0.507, 0.3695]}, {"w": "the", "b": [0.5117, 0.3499, 0.5358, 0.3695]}, {"w": "opposite", "b": [0.5405, 0.3499, 0.6059, 0.3695]}, {"w": "of", "b": [0.6106, 0.3499, 0.6259, 0.3695]}, {"w": "the", "b": [0.6306, 0.3499, 0.6547, 0.3695]}, {"w": "MSE", "b": [0.6594, 0.3499, 0.6962, 0.3695]}, {"w": "(i.e.,", "b": [0.7009, 0.3499, 0.7337, 0.3695]}, {"w": "a", "b": [0.7384, 0.3499, 0.7468, 0.3695]}, {"w": "neg‐", "b": [0.7515, 0.3499, 0.7857, 0.3695]}, {"w": "ative", "b": [0.2714, 0.3682, 0.3072, 0.3878]}, {"w": "value),", "b": [0.3144, 0.3682, 0.3655, 0.3878]}, {"w": "which", "b": [0.3726, 0.3682, 0.4192, 0.3878]}, {"w": "is", "b": [0.4263, 0.3682, 0.4384, 0.3878]}, {"w": "why", "b": [0.4455, 0.3682, 0.477, 0.3878]}, {"w": "the", "b": [0.4841, 0.3682, 0.5082, 0.3878]}, {"w": "preceding", "b": [0.5153, 0.3682, 0.5911, 0.3878]}, {"w": "code", "b": [0.5982, 0.3682, 0.6342, 0.3878]}, {"w": "computes", "b": [0.6413, 0.3682, 0.7153, 0.3878]}, {"w": "-scores", "b": [0.7224, 0.3711, 0.7857, 0.3849]}, {"w": "before", "b": [0.2714, 0.3856, 0.3197, 0.4052]}, {"w": "calculating", "b": [0.324, 0.3856, 0.4065, 0.4052]}, {"w": "the", "b": [0.4108, 0.3856, 0.4349, 0.4052]}, {"w": "square", "b": [0.4392, 0.3856, 0.4896, 0.4052]}, {"w": "root.", "b": [0.4939, 0.3856, 0.5306, 0.4052]}]}, {"id": "b_4", "type": "paragraph", "text": "Let’s look at the results:", "words": [{"w": "Let’s", "b": [0.1429, 0.4255, 0.179, 0.4469]}, {"w": "look", "b": [0.1838, 0.4255, 0.2206, 0.4469]}, {"w": "at", "b": [0.2253, 0.4255, 0.2404, 0.4469]}, {"w": "the", "b": [0.2452, 0.4255, 0.2715, 0.4469]}, {"w": "results:", "b": [0.2762, 0.4255, 0.3356, 0.4469]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> def display_scores(scores): ... print(\"Scores:\", scores) ... print(\"Mean:\", scores.mean()) ... print(\"Standard deviation:\", scores.std()) ... >>> display_scores(tree_rmse_scores) Scores: [70194.33680785 66855.16363941 72432.58244769 70758.73896782 71115.88230639 75585.14172901 70262.86139133 70273.6325285 75366.87952553 71231.65726027] Mean: 71407.68766037929 Standard deviation: 2439.4345041191004", "words": [{"w": ">>>", "b": [0.1766, 0.4574, 0.2019, 0.4703]}, {"w": "def", "b": [0.2103, 0.4574, 0.2356, 0.4703]}, {"w": "display_scores(scores):", "b": [0.244, 0.4574, 0.438, 0.4703]}, {"w": "...", "b": [0.1766, 0.4729, 0.2019, 0.4857]}, {"w": "print(\"Scores:\",", "b": [0.244, 0.4729, 0.379, 0.4857]}, {"w": "scores)", "b": [0.3874, 0.4729, 0.4464, 0.4857]}, {"w": "...", "b": [0.1766, 0.4883, 0.2019, 0.5011]}, {"w": "print(\"Mean:\",", "b": [0.244, 0.4883, 0.3621, 0.5011]}, {"w": "scores.mean())", "b": [0.3705, 0.4883, 0.4886, 0.5011]}, {"w": "...", "b": [0.1766, 0.5037, 0.2019, 0.5165]}, {"w": "print(\"Standard", "b": [0.244, 0.5037, 0.3705, 0.5165]}, {"w": "deviation:\",", "b": [0.379, 0.5037, 0.4802, 0.5165]}, {"w": "scores.std())", "b": [0.4886, 0.5037, 0.5982, 0.5165]}, {"w": "...", "b": [0.1766, 0.5191, 0.2019, 0.532]}, {"w": ">>>", "b": [0.1766, 0.5345, 0.2019, 0.5474]}, {"w": "display_scores(tree_rmse_scores)", "b": [0.2103, 0.5345, 0.4802, 0.5474]}, {"w": "Scores:", "b": [0.1766, 0.55, 0.2356, 0.5628]}, {"w": "[70194.33680785", "b": [0.244, 0.55, 0.3705, 0.5628]}, {"w": "66855.16363941", "b": [0.379, 0.55, 0.497, 0.5628]}, {"w": "72432.58244769", "b": [0.5055, 0.55, 0.6235, 0.5628]}, {"w": "70758.73896782", "b": [0.6319, 0.55, 0.75, 0.5628]}, {"w": "71115.88230639", "b": [0.185, 0.5654, 0.3031, 0.5782]}, {"w": "75585.14172901", "b": [0.3115, 0.5654, 0.4296, 0.5782]}, {"w": "70262.86139133", "b": [0.438, 0.5654, 0.556, 0.5782]}, {"w": "70273.6325285", "b": [0.5645, 0.5654, 0.6741, 0.5782]}, {"w": "75366.87952553", "b": [0.185, 0.5808, 0.3031, 0.5936]}, {"w": "71231.65726027]", "b": [0.3115, 0.5808, 0.438, 0.5936]}, {"w": "Mean:", "b": [0.1766, 0.5962, 0.2187, 0.6091]}, {"w": "71407.68766037929", "b": [0.2272, 0.5962, 0.3705, 0.6091]}, {"w": "Standard", "b": [0.1766, 0.6116, 0.244, 0.6245]}, {"w": "deviation:", "b": [0.2525, 0.6116, 0.3368, 0.6245]}, {"w": "2439.4345041191004", "b": [0.3452, 0.6116, 0.497, 0.6245]}]}, {"id": "b_6", "type": "paragraph", "text": "Now the Decision Tree doesn’t look as good as it did earlier. In fact, it seems to per‐ form worse than the Linear Regression model! Notice that cross-validation allows you to get not only an estimate of the performance of your model, but also a measure of how precise this estimate is (i.e., its standard deviation). The Decision Tree has a score of approximately 71,407, generally ±2,439. You would not have this information if you just used one validation set. But cross-validation comes at the cost of training the model several times, so it is not always possible.", "words": [{"w": "Now", "b": [0.1429, 0.6323, 0.1827, 0.6537]}, {"w": "the", "b": [0.1888, 0.6323, 0.2151, 0.6537]}, {"w": "Decision", "b": [0.2212, 0.6323, 0.295, 0.6537]}, {"w": "Tree", "b": [0.3011, 0.6323, 0.3377, 0.6537]}, {"w": "doesn’t", "b": [0.3438, 0.6323, 0.4019, 0.6537]}, {"w": "look", "b": [0.4079, 0.6323, 0.4448, 0.6537]}, {"w": "as", "b": [0.4509, 0.6323, 0.4677, 0.6537]}, {"w": "good", "b": [0.4738, 0.6323, 0.5158, 0.6537]}, {"w": "as", "b": [0.5218, 0.6323, 0.5386, 0.6537]}, {"w": "it", "b": [0.5447, 0.6323, 0.5567, 0.6537]}, {"w": "did", "b": [0.5627, 0.6323, 0.5903, 0.6537]}, {"w": "earlier.", "b": [0.5964, 0.6323, 0.653, 0.6537]}, {"w": "In", "b": [0.6591, 0.6323, 0.6776, 0.6537]}, {"w": "fact,", "b": [0.6837, 0.6323, 0.7189, 0.6537]}, {"w": "it", "b": [0.725, 0.6323, 0.7369, 0.6537]}, {"w": "seems", "b": [0.743, 0.6323, 0.7931, 0.6537]}, {"w": "to", "b": [0.7992, 0.6323, 0.8161, 0.6537]}, {"w": "per‐", "b": [0.8222, 0.6323, 0.8571, 0.6537]}, {"w": "form", "b": [0.1428, 0.6513, 0.1844, 0.6727]}, {"w": "worse", "b": [0.1927, 0.6513, 0.2418, 0.6727]}, {"w": "than", "b": [0.2501, 0.6513, 0.2881, 0.6727]}, {"w": "the", "b": [0.2963, 0.6513, 0.3227, 0.6727]}, {"w": "Linear", "b": [0.3309, 0.6513, 0.3848, 0.6727]}, {"w": "Regression", "b": [0.3931, 0.6513, 0.4841, 0.6727]}, {"w": "model!", "b": [0.4923, 0.6513, 0.5509, 0.6727]}, {"w": "Notice", "b": [0.5592, 0.6513, 0.6143, 0.6727]}, {"w": "that", "b": [0.6226, 0.6513, 0.6552, 0.6727]}, {"w": "cross-validation", "b": [0.6634, 0.6513, 0.7967, 0.6727]}, {"w": "allows", "b": [0.8049, 0.6513, 0.8571, 0.6727]}, {"w": "you", "b": [0.1429, 0.6704, 0.1741, 0.6918]}, {"w": "to", "b": [0.1792, 0.6704, 0.1962, 0.6918]}, {"w": "get", "b": [0.2013, 0.6704, 0.2263, 0.6918]}, {"w": "not", "b": [0.2314, 0.6704, 0.2598, 0.6918]}, {"w": "only", "b": [0.2649, 0.6704, 0.3018, 0.6918]}, {"w": "an", "b": [0.3069, 0.6704, 0.3274, 0.6918]}, {"w": "estimate", "b": [0.3325, 0.6704, 0.402, 0.6918]}, {"w": "of", "b": [0.4071, 0.6704, 0.4239, 0.6918]}, {"w": "the", "b": [0.429, 0.6704, 0.4554, 0.6918]}, {"w": "performance", "b": [0.4605, 0.6704, 0.5678, 0.6918]}, {"w": "of", "b": [0.5729, 0.6704, 0.5897, 0.6918]}, {"w": "your", "b": [0.5948, 0.6704, 0.6338, 0.6918]}, {"w": "model,", "b": [0.6389, 0.6704, 0.6965, 0.6918]}, {"w": "but", "b": [0.7016, 0.6704, 0.7296, 0.6918]}, {"w": "also", "b": [0.7347, 0.6704, 0.7674, 0.6918]}, {"w": "a", "b": [0.7725, 0.6704, 0.7817, 0.6918]}, {"w": "measure", "b": [0.7868, 0.6704, 0.8571, 0.6918]}, {"w": "of", "b": [0.1429, 0.6894, 0.1596, 0.7108]}, {"w": "how", "b": [0.1661, 0.6894, 0.2022, 0.7108]}, {"w": "precise", "b": [0.2086, 0.6894, 0.267, 0.7108]}, {"w": "this", "b": [0.2735, 0.6894, 0.3042, 0.7108]}, {"w": "estimate", "b": [0.3107, 0.6894, 0.3802, 0.7108]}, {"w": "is", "b": [0.3866, 0.6894, 0.3999, 0.7108]}, {"w": "(i.e.,", "b": [0.4064, 0.6894, 0.4423, 0.7108]}, {"w": "its", "b": [0.4487, 0.6894, 0.4683, 0.7108]}, {"w": "standard", "b": [0.4748, 0.6894, 0.5482, 0.7108]}, {"w": "deviation).", "b": [0.5547, 0.6894, 0.6445, 0.7108]}, {"w": "The", "b": [0.6509, 0.6894, 0.6838, 0.7108]}, {"w": "Decision", "b": [0.6903, 0.6894, 0.7641, 0.7108]}, {"w": "Tree", "b": [0.7705, 0.6894, 0.8071, 0.7108]}, {"w": "has", "b": [0.8136, 0.6894, 0.8415, 0.7108]}, {"w": "a", "b": [0.848, 0.6894, 0.8571, 0.7108]}, {"w": "score", "b": [0.1428, 0.7085, 0.1865, 0.7299]}, {"w": "of", "b": [0.1914, 0.7085, 0.2082, 0.7299]}, {"w": "approximately", "b": [0.213, 0.7085, 0.3332, 0.7299]}, {"w": "71,407,", "b": [0.3381, 0.7085, 0.3976, 0.7299]}, {"w": "generally", "b": [0.4024, 0.7085, 0.4783, 0.7299]}, {"w": "±2,439.", "b": [0.4831, 0.7085, 0.5447, 0.7299]}, {"w": "You", "b": [0.5495, 0.7085, 0.5819, 0.7299]}, {"w": "would", "b": [0.5867, 0.7085, 0.639, 0.7299]}, {"w": "not", "b": [0.6438, 0.7085, 0.6722, 0.7299]}, {"w": "have", "b": [0.6771, 0.7085, 0.7155, 0.7299]}, {"w": "this", "b": [0.7203, 0.7085, 0.751, 0.7299]}, {"w": "information", "b": [0.7559, 0.7085, 0.8571, 0.7299]}, {"w": "if", "b": [0.1429, 0.7275, 0.1546, 0.7489]}, {"w": "you", "b": [0.1608, 0.7275, 0.192, 0.7489]}, {"w": "just", "b": [0.1981, 0.7275, 0.2285, 0.7489]}, {"w": "used", "b": [0.2347, 0.7275, 0.2732, 0.7489]}, {"w": "one", "b": [0.2794, 0.7275, 0.3103, 0.7489]}, {"w": "validation", "b": [0.3164, 0.7275, 0.3998, 0.7489]}, {"w": "set.", "b": [0.4059, 0.7275, 0.4335, 0.7489]}, {"w": "But", "b": [0.4397, 0.7275, 0.4693, 0.7489]}, {"w": "cross-validation", "b": [0.4755, 0.7275, 0.6087, 0.7489]}, {"w": "comes", "b": [0.6148, 0.7275, 0.6678, 0.7489]}, {"w": "at", "b": [0.674, 0.7275, 0.6891, 0.7489]}, {"w": "the", "b": [0.6952, 0.7275, 0.7216, 0.7489]}, {"w": "cost", "b": [0.7277, 0.7275, 0.7611, 0.7489]}, {"w": "of", "b": [0.7673, 0.7275, 0.7841, 0.7489]}, {"w": "training", "b": [0.7902, 0.7275, 0.8572, 0.7489]}, {"w": "the", "b": [0.1429, 0.7465, 0.1692, 0.768]}, {"w": "model", "b": [0.1739, 0.7465, 0.2267, 0.768]}, {"w": "several", "b": [0.2315, 0.7465, 0.2886, 0.768]}, {"w": "times,", "b": [0.2933, 0.7465, 0.3436, 0.768]}, {"w": "so", "b": [0.3483, 0.7465, 0.3666, 0.768]}, {"w": "it", "b": [0.3713, 0.7465, 0.3833, 0.768]}, {"w": "is", "b": [0.388, 0.7465, 0.4012, 0.768]}, {"w": "not", "b": [0.4059, 0.7465, 0.4343, 0.768]}, {"w": "always", "b": [0.439, 0.7465, 0.4937, 0.768]}, {"w": "possible.", "b": [0.4984, 0.7465, 0.5703, 0.768]}]}, {"id": "b_7", "type": "paragraph", "text": "Let’s compute the same scores for the Linear Regression model just to be sure:", "words": [{"w": "Let’s", "b": [0.1429, 0.7747, 0.179, 0.7961]}, {"w": "compute", "b": [0.1838, 0.7747, 0.257, 0.7961]}, {"w": "the", "b": [0.2618, 0.7747, 0.2881, 0.7961]}, {"w": "same", "b": [0.2928, 0.7747, 0.3355, 0.7961]}, {"w": "scores", "b": [0.3403, 0.7747, 0.3916, 0.7961]}, {"w": "for", "b": [0.3963, 0.7747, 0.4208, 0.7961]}, {"w": "the", "b": [0.4256, 0.7747, 0.4519, 0.7961]}, {"w": "Linear", "b": [0.4566, 0.7747, 0.5105, 0.7961]}, {"w": "Regression", "b": [0.5153, 0.7747, 0.6063, 0.7961]}, {"w": "model", "b": [0.611, 0.7747, 0.6638, 0.7961]}, {"w": "just", "b": [0.6686, 0.7747, 0.699, 0.7961]}, {"w": "to", "b": [0.7037, 0.7747, 0.7207, 0.7961]}, {"w": "be", "b": [0.7254, 0.7747, 0.7448, 0.7961]}, {"w": "sure:", "b": [0.7496, 0.7747, 0.7896, 0.7961]}]}, {"id": "b_8", "type": "paragraph", "text": ">>> lin_scores = cross_val_score(lin_reg, housing_prepared, housing_labels, ... scoring=\"neg_mean_squared_error\", cv=10) ... >>> lin_rmse_scores = np.sqrt(-lin_scores) >>> display_scores(lin_rmse_scores)", "words": [{"w": ">>>", "b": [0.1766, 0.8066, 0.2019, 0.8195]}, {"w": "lin_scores", "b": [0.2103, 0.8066, 0.2946, 0.8195]}, {"w": "=", "b": [0.3031, 0.8066, 0.3115, 0.8195]}, {"w": "cross_val_score(lin_reg,", "b": [0.3199, 0.8066, 0.5223, 0.8195]}, {"w": "housing_prepared,", "b": [0.5307, 0.8066, 0.6741, 0.8195]}, {"w": "housing_labels,", "b": [0.6825, 0.8066, 0.809, 0.8195]}, {"w": "...", "b": [0.1766, 0.8221, 0.2019, 0.8349]}, {"w": "scoring=\"neg_mean_squared_error\",", "b": [0.4549, 0.8221, 0.7331, 0.8349]}, {"w": "cv=10)", "b": [0.7416, 0.8221, 0.7922, 0.8349]}, {"w": "...", "b": [0.1766, 0.8375, 0.2019, 0.8503]}, {"w": ">>>", "b": [0.1766, 0.8529, 0.2019, 0.8657]}, {"w": "lin_rmse_scores", "b": [0.2103, 0.8529, 0.3368, 0.8657]}, {"w": "=", "b": [0.3452, 0.8529, 0.3537, 0.8657]}, {"w": "np.sqrt(-lin_scores)", "b": [0.3621, 0.8529, 0.5307, 0.8657]}, {"w": ">>>", "b": [0.1766, 0.8683, 0.2019, 0.8812]}, {"w": "display_scores(lin_rmse_scores)", "b": [0.2103, 0.8683, 0.4717, 0.8812]}]}, {"id": "b_9", "type": "paragraph", "text": "Select and Train a Model | 77", "words": [{"w": "Select", "b": [0.6602, 0.9225, 0.6955, 0.9388]}, {"w": "and", "b": [0.6983, 0.9225, 0.7207, 0.9388]}, {"w": "Train", "b": [0.7236, 0.9225, 0.7536, 0.9388]}, {"w": "a", "b": [0.7565, 0.9225, 0.7635, 0.9388]}, {"w": "Model", "b": [0.7663, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "77", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 104, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Scores: [66782.73843989 66960.118071 70347.95244419 74739.57052552 68031.13388938 71193.84183426 64969.63056405 68281.61137997 71552.91566558 67665.10082067] Mean: 69052.46136345083 Standard deviation: 2731.674001798348", "words": [{"w": "Scores:", "b": [0.1766, 0.0829, 0.2356, 0.0958]}, {"w": "[66782.73843989", "b": [0.244, 0.0829, 0.3705, 0.0958]}, {"w": "66960.118071", "b": [0.379, 0.0829, 0.4802, 0.0958]}, {"w": "70347.95244419", "b": [0.5055, 0.0829, 0.6235, 0.0958]}, {"w": "74739.57052552", "b": [0.6319, 0.0829, 0.75, 0.0958]}, {"w": "68031.13388938", "b": [0.185, 0.0983, 0.3031, 0.1112]}, {"w": "71193.84183426", "b": [0.3115, 0.0983, 0.4296, 0.1112]}, {"w": "64969.63056405", "b": [0.438, 0.0983, 0.5561, 0.1112]}, {"w": "68281.61137997", "b": [0.5645, 0.0983, 0.6825, 0.1112]}, {"w": "71552.91566558", "b": [0.185, 0.1138, 0.3031, 0.1266]}, {"w": "67665.10082067]", "b": [0.3115, 0.1138, 0.438, 0.1266]}, {"w": "Mean:", "b": [0.1766, 0.1292, 0.2188, 0.142]}, {"w": "69052.46136345083", "b": [0.2272, 0.1292, 0.3705, 0.142]}, {"w": "Standard", "b": [0.1766, 0.1446, 0.244, 0.1574]}, {"w": "deviation:", "b": [0.2525, 0.1446, 0.3368, 0.1574]}, {"w": "2731.674001798348", "b": [0.3452, 0.1446, 0.4886, 0.1574]}]}, {"id": "b_1", "type": "paragraph", "text": "That’s right: the Decision Tree model is overfitting so badly that it performs worse than the Linear Regression model.", "words": [{"w": "That’s", "b": [0.1429, 0.1652, 0.1917, 0.1866]}, {"w": "right:", "b": [0.199, 0.1652, 0.2439, 0.1866]}, {"w": "the", "b": [0.2513, 0.1652, 0.2776, 0.1866]}, {"w": "Decision", "b": [0.285, 0.1652, 0.3588, 0.1866]}, {"w": "Tree", "b": [0.3661, 0.1652, 0.4027, 0.1866]}, {"w": "model", "b": [0.4101, 0.1652, 0.4629, 0.1866]}, {"w": "is", "b": [0.4702, 0.1652, 0.4834, 0.1866]}, {"w": "overfitting", "b": [0.4908, 0.1652, 0.5788, 0.1866]}, {"w": "so", "b": [0.5862, 0.1652, 0.6045, 0.1866]}, {"w": "badly", "b": [0.6118, 0.1652, 0.6574, 0.1866]}, {"w": "that", "b": [0.6647, 0.1652, 0.6973, 0.1866]}, {"w": "it", "b": [0.7047, 0.1652, 0.7166, 0.1866]}, {"w": "performs", "b": [0.7239, 0.1652, 0.8007, 0.1866]}, {"w": "worse", "b": [0.808, 0.1652, 0.8571, 0.1866]}, {"w": "than", "b": [0.1429, 0.1843, 0.1809, 0.2057]}, {"w": "the", "b": [0.1856, 0.1843, 0.2119, 0.2057]}, {"w": "Linear", "b": [0.2167, 0.1843, 0.2706, 0.2057]}, {"w": "Regression", "b": [0.2753, 0.1843, 0.3663, 0.2057]}, {"w": "model.", "b": [0.3711, 0.1843, 0.4286, 0.2057]}]}, {"id": "b_2", "type": "paragraph", "text": "Let’s try one last model now: the RandomForestRegressor. As we will see in Chap‐ ter 7, Random Forests work by training many Decision Trees on random subsets of the features, then averaging out their predictions. Building a model on top of many other models is called Ensemble Learning, and it is often a great way to push ML algo‐ rithms even further. We will skip most of the code since it is essentially the same as for the other models:", "words": [{"w": "Let’s", "b": [0.1429, 0.2133, 0.179, 0.2347]}, {"w": "try", "b": [0.186, 0.2133, 0.2103, 0.2347]}, {"w": "one", "b": [0.2173, 0.2133, 0.2482, 0.2347]}, {"w": "last", "b": [0.2552, 0.2133, 0.2836, 0.2347]}, {"w": "model", "b": [0.2906, 0.2133, 0.3434, 0.2347]}, {"w": "now:", "b": [0.3505, 0.2133, 0.3922, 0.2347]}, {"w": "the", "b": [0.3992, 0.2133, 0.4255, 0.2347]}, {"w": "RandomForestRegressor.", "b": [0.4325, 0.2133, 0.6451, 0.2347]}, {"w": "As", "b": [0.6521, 0.2133, 0.6741, 0.2347]}, {"w": "we", "b": [0.6812, 0.2133, 0.7043, 0.2347]}, {"w": "will", "b": [0.7113, 0.2133, 0.7417, 0.2347]}, {"w": "see", "b": [0.7487, 0.2133, 0.7741, 0.2347]}, {"w": "in", "b": [0.7811, 0.2133, 0.7981, 0.2347]}, {"w": "Chap‐", "b": [0.8051, 0.2133, 0.8571, 0.2347]}, {"w": "ter", "b": [0.1429, 0.2323, 0.1658, 0.2538]}, {"w": "7,", "b": [0.1723, 0.2323, 0.187, 0.2538]}, {"w": "Random", "b": [0.1935, 0.2323, 0.266, 0.2538]}, {"w": "Forests", "b": [0.2725, 0.2323, 0.332, 0.2538]}, {"w": "work", "b": [0.3385, 0.2323, 0.3814, 0.2538]}, {"w": "by", "b": [0.3879, 0.2323, 0.4081, 0.2538]}, {"w": "training", "b": [0.4146, 0.2323, 0.4815, 0.2538]}, {"w": "many", "b": [0.488, 0.2323, 0.5347, 0.2538]}, {"w": "Decision", "b": [0.5411, 0.2323, 0.615, 0.2538]}, {"w": "Trees", "b": [0.6214, 0.2323, 0.6656, 0.2538]}, {"w": "on", "b": [0.6721, 0.2323, 0.6942, 0.2538]}, {"w": "random", "b": [0.7006, 0.2323, 0.7676, 0.2538]}, {"w": "subsets", "b": [0.7741, 0.2323, 0.8339, 0.2538]}, {"w": "of", "b": [0.8403, 0.2323, 0.8571, 0.2538]}, {"w": "the", "b": [0.1429, 0.2514, 0.1692, 0.2728]}, {"w": "features,", "b": [0.1758, 0.2514, 0.2459, 0.2728]}, {"w": "then", "b": [0.2525, 0.2514, 0.2902, 0.2728]}, {"w": "averaging", "b": [0.2968, 0.2514, 0.3774, 0.2728]}, {"w": "out", "b": [0.384, 0.2514, 0.412, 0.2728]}, {"w": "their", "b": [0.4185, 0.2514, 0.4582, 0.2728]}, {"w": "predictions.", "b": [0.4648, 0.2514, 0.564, 0.2728]}, {"w": "Building", "b": [0.5706, 0.2514, 0.6425, 0.2728]}, {"w": "a", "b": [0.649, 0.2514, 0.6582, 0.2728]}, {"w": "model", "b": [0.6647, 0.2514, 0.7175, 0.2728]}, {"w": "on", "b": [0.7241, 0.2514, 0.7461, 0.2728]}, {"w": "top", "b": [0.7527, 0.2514, 0.7806, 0.2728]}, {"w": "of", "b": [0.7871, 0.2514, 0.8039, 0.2728]}, {"w": "many", "b": [0.8105, 0.2514, 0.8572, 0.2728]}, {"w": "other", "b": [0.1429, 0.2704, 0.1875, 0.2918]}, {"w": "models", "b": [0.1925, 0.2704, 0.253, 0.2918]}, {"w": "is", "b": [0.258, 0.2704, 0.2712, 0.2918]}, {"w": "called", "b": [0.2762, 0.2704, 0.3246, 0.2918]}, {"w": "Ensemble", "b": [0.3295, 0.2702, 0.4067, 0.2918]}, {"w": "Learning,", "b": [0.4115, 0.2702, 0.4893, 0.2918]}, {"w": "and", "b": [0.4943, 0.2704, 0.5258, 0.2918]}, {"w": "it", "b": [0.5308, 0.2704, 0.5427, 0.2918]}, {"w": "is", "b": [0.5477, 0.2704, 0.5609, 0.2918]}, {"w": "often", "b": [0.5659, 0.2704, 0.6093, 0.2918]}, {"w": "a", "b": [0.6143, 0.2704, 0.6235, 0.2918]}, {"w": "great", "b": [0.6285, 0.2704, 0.6699, 0.2918]}, {"w": "way", "b": [0.6749, 0.2704, 0.7075, 0.2918]}, {"w": "to", "b": [0.7125, 0.2704, 0.7295, 0.2918]}, {"w": "push", "b": [0.7344, 0.2704, 0.7752, 0.2918]}, {"w": "ML", "b": [0.7802, 0.2704, 0.81, 0.2918]}, {"w": "algo‐", "b": [0.8149, 0.2704, 0.8571, 0.2918]}, {"w": "rithms", "b": [0.1429, 0.2895, 0.1984, 0.3109]}, {"w": "even", "b": [0.2048, 0.2895, 0.2435, 0.3109]}, {"w": "further.", "b": [0.25, 0.2895, 0.3124, 0.3109]}, {"w": "We", "b": [0.3189, 0.2895, 0.346, 0.3109]}, {"w": "will", "b": [0.3524, 0.2895, 0.3828, 0.3109]}, {"w": "skip", "b": [0.3892, 0.2895, 0.4237, 0.3109]}, {"w": "most", "b": [0.4301, 0.2895, 0.4718, 0.3109]}, {"w": "of", "b": [0.4783, 0.2895, 0.4951, 0.3109]}, {"w": "the", "b": [0.5015, 0.2895, 0.5278, 0.3109]}, {"w": "code", "b": [0.5343, 0.2895, 0.5736, 0.3109]}, {"w": "since", "b": [0.58, 0.2895, 0.6223, 0.3109]}, {"w": "it", "b": [0.6287, 0.2895, 0.6407, 0.3109]}, {"w": "is", "b": [0.6471, 0.2895, 0.6604, 0.3109]}, {"w": "essentially", "b": [0.6668, 0.2895, 0.752, 0.3109]}, {"w": "the", "b": [0.7584, 0.2895, 0.7848, 0.3109]}, {"w": "same", "b": [0.7912, 0.2895, 0.8339, 0.3109]}, {"w": "as", "b": [0.8404, 0.2895, 0.8571, 0.3109]}, {"w": "for", "b": [0.1429, 0.3085, 0.1674, 0.3299]}, {"w": "the", "b": [0.1721, 0.3085, 0.1984, 0.3299]}, {"w": "other", "b": [0.2032, 0.3085, 0.2479, 0.3299]}, {"w": "models:", "b": [0.2526, 0.3085, 0.3178, 0.3299]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> from sklearn.ensemble import RandomForestRegressor >>> forest_reg = RandomForestRegressor() >>> forest_reg.fit(housing_prepared, housing_labels) >>> [...] >>> forest_rmse 18603.515021376355 >>> display_scores(forest_rmse_scores) Scores: [49519.80364233 47461.9115823 50029.02762854 52325.28068953 49308.39426421 53446.37892622 48634.8036574 47585.73832311 53490.10699751 50021.5852922 ] Mean: 50182.303100336096 Standard deviation: 2097.0810550985693", "words": [{"w": ">>>", "b": [0.1766, 0.3405, 0.2019, 0.3534]}, {"w": "from", "b": [0.2103, 0.3405, 0.2441, 0.3534]}, {"w": "sklearn.ensemble", "b": [0.2525, 0.3405, 0.3874, 0.3534]}, {"w": "import", "b": [0.3958, 0.3405, 0.4464, 0.3534]}, {"w": "RandomForestRegressor", "b": [0.4549, 0.3405, 0.632, 0.3534]}, {"w": ">>>", "b": [0.1766, 0.3559, 0.2019, 0.3688]}, {"w": "forest_reg", "b": [0.2103, 0.3559, 0.2946, 0.3688]}, {"w": "=", "b": [0.3031, 0.3559, 0.3115, 0.3688]}, {"w": "RandomForestRegressor()", "b": [0.3199, 0.3559, 0.5139, 0.3688]}, {"w": ">>>", "b": [0.1766, 0.3713, 0.2019, 0.3842]}, {"w": "forest_reg.fit(housing_prepared,", "b": [0.2103, 0.3713, 0.4802, 0.3842]}, {"w": "housing_labels)", "b": [0.4886, 0.3713, 0.6151, 0.3842]}, {"w": ">>>", "b": [0.1766, 0.3868, 0.2019, 0.3996]}, {"w": "[...]", "b": [0.2103, 0.3868, 0.2525, 0.3996]}, {"w": ">>>", "b": [0.1766, 0.4022, 0.2019, 0.415]}, {"w": "forest_rmse", "b": [0.2103, 0.4022, 0.3031, 0.415]}, {"w": "18603.515021376355", "b": [0.1766, 0.4176, 0.3284, 0.4305]}, {"w": ">>>", "b": [0.1766, 0.433, 0.2019, 0.4459]}, {"w": "display_scores(forest_rmse_scores)", "b": [0.2103, 0.433, 0.497, 0.4459]}, {"w": "Scores:", "b": [0.1766, 0.4484, 0.2356, 0.4613]}, {"w": "[49519.80364233", "b": [0.2441, 0.4484, 0.3705, 0.4613]}, {"w": "47461.9115823", "b": [0.379, 0.4484, 0.4886, 0.4613]}, {"w": "50029.02762854", "b": [0.5055, 0.4484, 0.6235, 0.4613]}, {"w": "52325.28068953", "b": [0.632, 0.4484, 0.75, 0.4613]}, {"w": "49308.39426421", "b": [0.185, 0.4639, 0.3031, 0.4767]}, {"w": "53446.37892622", "b": [0.3115, 0.4639, 0.4296, 0.4767]}, {"w": "48634.8036574", "b": [0.438, 0.4639, 0.5476, 0.4767]}, {"w": "47585.73832311", "b": [0.5645, 0.4639, 0.6825, 0.4767]}, {"w": "53490.10699751", "b": [0.185, 0.4793, 0.3031, 0.4921]}, {"w": "50021.5852922", "b": [0.3115, 0.4793, 0.4211, 0.4921]}, {"w": "]", "b": [0.4296, 0.4793, 0.438, 0.4921]}, {"w": "Mean:", "b": [0.1766, 0.4947, 0.2188, 0.5075]}, {"w": "50182.303100336096", "b": [0.2272, 0.4947, 0.379, 0.5075]}, {"w": "Standard", "b": [0.1766, 0.5101, 0.2441, 0.523]}, {"w": "deviation:", "b": [0.2525, 0.5101, 0.3368, 0.523]}, {"w": "2097.0810550985693", "b": [0.3452, 0.5101, 0.497, 0.523]}]}, {"id": "b_4", "type": "paragraph", "text": "Wow, this is much better: Random Forests look very promising. However, note that the score on the training set is still much lower than on the validation sets, meaning that the model is still overfitting the training set. Possible solutions for overfitting are to simplify the model, constrain it (i.e., regularize it), or get a lot more training data. However, before you dive much deeper in Random Forests, you should try out many other models from various categories of Machine Learning algorithms (several Sup‐ port Vector Machines with different kernels, possibly a neural network, etc.), without spending too much time tweaking the hyperparameters. The goal is to shortlist a few (two to five) promising models.", "words": [{"w": "Wow,", "b": [0.1429, 0.5308, 0.1892, 0.5522]}, {"w": "this", "b": [0.1956, 0.5308, 0.2264, 0.5522]}, {"w": "is", "b": [0.2328, 0.5308, 0.246, 0.5522]}, {"w": "much", "b": [0.2525, 0.5308, 0.3001, 0.5522]}, {"w": "better:", "b": [0.3066, 0.5308, 0.3606, 0.5522]}, {"w": "Random", "b": [0.367, 0.5308, 0.4396, 0.5522]}, {"w": "Forests", "b": [0.446, 0.5308, 0.5055, 0.5522]}, {"w": "look", "b": [0.5119, 0.5308, 0.5488, 0.5522]}, {"w": "very", "b": [0.5552, 0.5308, 0.5916, 0.5522]}, {"w": "promising.", "b": [0.5981, 0.5308, 0.6891, 0.5522]}, {"w": "However,", "b": [0.6956, 0.5308, 0.7744, 0.5522]}, {"w": "note", "b": [0.7809, 0.5308, 0.8181, 0.5522]}, {"w": "that", "b": [0.8246, 0.5308, 0.8571, 0.5522]}, {"w": "the", "b": [0.1429, 0.5498, 0.1692, 0.5712]}, {"w": "score", "b": [0.1752, 0.5498, 0.2189, 0.5712]}, {"w": "on", "b": [0.2249, 0.5498, 0.2469, 0.5712]}, {"w": "the", "b": [0.2529, 0.5498, 0.2793, 0.5712]}, {"w": "training", "b": [0.2853, 0.5498, 0.3522, 0.5712]}, {"w": "set", "b": [0.3582, 0.5498, 0.3811, 0.5712]}, {"w": "is", "b": [0.3871, 0.5498, 0.4003, 0.5712]}, {"w": "still", "b": [0.4063, 0.5498, 0.4365, 0.5712]}, {"w": "much", "b": [0.4425, 0.5498, 0.4901, 0.5712]}, {"w": "lower", "b": [0.4961, 0.5498, 0.5429, 0.5712]}, {"w": "than", "b": [0.5489, 0.5498, 0.5869, 0.5712]}, {"w": "on", "b": [0.5929, 0.5498, 0.615, 0.5712]}, {"w": "the", "b": [0.621, 0.5498, 0.6473, 0.5712]}, {"w": "validation", "b": [0.6533, 0.5498, 0.7367, 0.5712]}, {"w": "sets,", "b": [0.7427, 0.5498, 0.7779, 0.5712]}, {"w": "meaning", "b": [0.784, 0.5498, 0.8571, 0.5712]}, {"w": "that", "b": [0.1429, 0.5688, 0.1754, 0.5903]}, {"w": "the", "b": [0.1807, 0.5688, 0.207, 0.5903]}, {"w": "model", "b": [0.2123, 0.5688, 0.2651, 0.5903]}, {"w": "is", "b": [0.2704, 0.5688, 0.2836, 0.5903]}, {"w": "still", "b": [0.2889, 0.5688, 0.319, 0.5903]}, {"w": "overfitting", "b": [0.3243, 0.5688, 0.4123, 0.5903]}, {"w": "the", "b": [0.4176, 0.5688, 0.4439, 0.5903]}, {"w": "training", "b": [0.4492, 0.5688, 0.5161, 0.5903]}, {"w": "set.", "b": [0.5214, 0.5688, 0.549, 0.5903]}, {"w": "Possible", "b": [0.5543, 0.5688, 0.6216, 0.5903]}, {"w": "solutions", "b": [0.6268, 0.5688, 0.703, 0.5903]}, {"w": "for", "b": [0.7083, 0.5688, 0.7328, 0.5903]}, {"w": "overfitting", "b": [0.7381, 0.5688, 0.8261, 0.5903]}, {"w": "are", "b": [0.8314, 0.5688, 0.8571, 0.5903]}, {"w": "to", "b": [0.1429, 0.5879, 0.1598, 0.6093]}, {"w": "simplify", "b": [0.1656, 0.5879, 0.2334, 0.6093]}, {"w": "the", "b": [0.2391, 0.5879, 0.2655, 0.6093]}, {"w": "model,", "b": [0.2712, 0.5879, 0.3288, 0.6093]}, {"w": "constrain", "b": [0.3346, 0.5879, 0.4133, 0.6093]}, {"w": "it", "b": [0.419, 0.5879, 0.431, 0.6093]}, {"w": "(i.e.,", "b": [0.4368, 0.5879, 0.4727, 0.6093]}, {"w": "regularize", "b": [0.4784, 0.5879, 0.5612, 0.6093]}, {"w": "it),", "b": [0.5669, 0.5879, 0.5908, 0.6093]}, {"w": "or", "b": [0.5966, 0.5879, 0.615, 0.6093]}, {"w": "get", "b": [0.6207, 0.5879, 0.6457, 0.6093]}, {"w": "a", "b": [0.6515, 0.5879, 0.6606, 0.6093]}, {"w": "lot", "b": [0.6664, 0.5879, 0.6886, 0.6093]}, {"w": "more", "b": [0.6944, 0.5879, 0.7387, 0.6093]}, {"w": "training", "b": [0.7444, 0.5879, 0.8114, 0.6093]}, {"w": "data.", "b": [0.8172, 0.5879, 0.8572, 0.6093]}, {"w": "However,", "b": [0.1429, 0.6069, 0.2217, 0.6284]}, {"w": "before", "b": [0.2272, 0.6069, 0.28, 0.6284]}, {"w": "you", "b": [0.2856, 0.6069, 0.3168, 0.6284]}, {"w": "dive", "b": [0.3223, 0.6069, 0.3574, 0.6284]}, {"w": "much", "b": [0.3629, 0.6069, 0.4106, 0.6284]}, {"w": "deeper", "b": [0.4161, 0.6069, 0.4723, 0.6284]}, {"w": "in", "b": [0.4778, 0.6069, 0.4948, 0.6284]}, {"w": "Random", "b": [0.5003, 0.6069, 0.5729, 0.6284]}, {"w": "Forests,", "b": [0.5784, 0.6069, 0.6426, 0.6284]}, {"w": "you", "b": [0.6481, 0.6069, 0.6794, 0.6284]}, {"w": "should", "b": [0.6849, 0.6069, 0.7416, 0.6284]}, {"w": "try", "b": [0.7471, 0.6069, 0.7714, 0.6284]}, {"w": "out", "b": [0.7769, 0.6069, 0.8049, 0.6284]}, {"w": "many", "b": [0.8105, 0.6069, 0.8571, 0.6284]}, {"w": "other", "b": [0.1429, 0.626, 0.1875, 0.6474]}, {"w": "models", "b": [0.194, 0.626, 0.2544, 0.6474]}, {"w": "from", "b": [0.2609, 0.626, 0.3024, 0.6474]}, {"w": "various", "b": [0.3089, 0.626, 0.3703, 0.6474]}, {"w": "categories", "b": [0.3767, 0.626, 0.4597, 0.6474]}, {"w": "of", "b": [0.4661, 0.626, 0.4829, 0.6474]}, {"w": "Machine", "b": [0.4893, 0.626, 0.5625, 0.6474]}, {"w": "Learning", "b": [0.5689, 0.626, 0.6439, 0.6474]}, {"w": "algorithms", "b": [0.6504, 0.626, 0.7407, 0.6474]}, {"w": "(several", "b": [0.7471, 0.626, 0.8114, 0.6474]}, {"w": "Sup‐", "b": [0.8179, 0.626, 0.8571, 0.6474]}, {"w": "port", "b": [0.1429, 0.645, 0.1785, 0.6665]}, {"w": "Vector", "b": [0.1838, 0.645, 0.2388, 0.6665]}, {"w": "Machines", "b": [0.2441, 0.645, 0.3248, 0.6665]}, {"w": "with", "b": [0.3301, 0.645, 0.3675, 0.6665]}, {"w": "different", "b": [0.3727, 0.645, 0.4445, 0.6665]}, {"w": "kernels,", "b": [0.4497, 0.645, 0.5146, 0.6665]}, {"w": "possibly", "b": [0.5199, 0.645, 0.5877, 0.6665]}, {"w": "a", "b": [0.593, 0.645, 0.6021, 0.6665]}, {"w": "neural", "b": [0.6074, 0.645, 0.6609, 0.6665]}, {"w": "network,", "b": [0.6662, 0.645, 0.7405, 0.6665]}, {"w": "etc.),", "b": [0.7458, 0.645, 0.7865, 0.6665]}, {"w": "without", "b": [0.7918, 0.645, 0.8572, 0.6665]}, {"w": "spending", "b": [0.1429, 0.6641, 0.2194, 0.6855]}, {"w": "too", "b": [0.225, 0.6641, 0.2526, 0.6855]}, {"w": "much", "b": [0.2581, 0.6641, 0.3058, 0.6855]}, {"w": "time", "b": [0.3113, 0.6641, 0.3492, 0.6855]}, {"w": "tweaking", "b": [0.3547, 0.6641, 0.4304, 0.6855]}, {"w": "the", "b": [0.4359, 0.6641, 0.4623, 0.6855]}, {"w": "hyperparameters.", "b": [0.4678, 0.6641, 0.6137, 0.6855]}, {"w": "The", "b": [0.6193, 0.6641, 0.6521, 0.6855]}, {"w": "goal", "b": [0.6576, 0.6641, 0.6924, 0.6855]}, {"w": "is", "b": [0.698, 0.6641, 0.7112, 0.6855]}, {"w": "to", "b": [0.7168, 0.6641, 0.7337, 0.6855]}, {"w": "shortlist", "b": [0.7393, 0.6641, 0.8076, 0.6855]}, {"w": "a", "b": [0.8132, 0.6641, 0.8223, 0.6855]}, {"w": "few", "b": [0.8279, 0.6641, 0.8571, 0.6855]}, {"w": "(two", "b": [0.1429, 0.6831, 0.1813, 0.7045]}, {"w": "to", "b": [0.186, 0.6831, 0.203, 0.7045]}, {"w": "five)", "b": [0.2078, 0.6831, 0.2452, 0.7045]}, {"w": "promising", "b": [0.2499, 0.6831, 0.3362, 0.7045]}, {"w": "models.", "b": [0.341, 0.6831, 0.4062, 0.7045]}]}, {"id": "b_5", "type": "equation", "text": "78 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "78", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 105, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "You should save every model you experiment with, so you can come back easily to any model you want. Make sure you save both the hyperparameters and the trained parameters, as well as the cross-validation scores and perhaps the actual predictions as well. This will allow you to easily compare scores across model types, and compare the types of errors they make. You can easily save Scikit-Learn models by using Python’s pickle module, or using sklearn.externals.joblib, which is more efficient at serializing large NumPy arrays:", "words": [{"w": "You", "b": [0.2714, 0.0793, 0.301, 0.0989]}, {"w": "should", "b": [0.3095, 0.0793, 0.3614, 0.0989]}, {"w": "save", "b": [0.3699, 0.0793, 0.4018, 0.0989]}, {"w": "every", "b": [0.4103, 0.0793, 0.4517, 0.0989]}, {"w": "model", "b": [0.4602, 0.0793, 0.5085, 0.0989]}, {"w": "you", "b": [0.517, 0.0793, 0.5456, 0.0989]}, {"w": "experiment", "b": [0.5541, 0.0793, 0.641, 0.0989]}, {"w": "with,", "b": [0.6496, 0.0793, 0.688, 0.0989]}, {"w": "so", "b": [0.6966, 0.0793, 0.7133, 0.0989]}, {"w": "you", "b": [0.7218, 0.0793, 0.7504, 0.0989]}, {"w": "can", "b": [0.7589, 0.0793, 0.7857, 0.0989]}, {"w": "come", "b": [0.2714, 0.0967, 0.3129, 0.1163]}, {"w": "back", "b": [0.3182, 0.0967, 0.3537, 0.1163]}, {"w": "easily", "b": [0.359, 0.0967, 0.4011, 0.1163]}, {"w": "to", "b": [0.4064, 0.0967, 0.4219, 0.1163]}, {"w": "any", "b": [0.4272, 0.0967, 0.4543, 0.1163]}, {"w": "model", "b": [0.4596, 0.0967, 0.5079, 0.1163]}, {"w": "you", "b": [0.5131, 0.0967, 0.5417, 0.1163]}, {"w": "want.", "b": [0.547, 0.0967, 0.5886, 0.1163]}, {"w": "Make", "b": [0.5939, 0.0967, 0.6364, 0.1163]}, {"w": "sure", "b": [0.6417, 0.0967, 0.674, 0.1163]}, {"w": "you", "b": [0.6793, 0.0967, 0.7079, 0.1163]}, {"w": "save", "b": [0.7131, 0.0967, 0.7451, 0.1163]}, {"w": "both", "b": [0.7503, 0.0967, 0.7857, 0.1163]}, {"w": "the", "b": [0.2714, 0.1141, 0.2955, 0.1337]}, {"w": "hyperparameters", "b": [0.3042, 0.1141, 0.4332, 0.1337]}, {"w": "and", "b": [0.4419, 0.1141, 0.4707, 0.1337]}, {"w": "the", "b": [0.4794, 0.1141, 0.5035, 0.1337]}, {"w": "trained", "b": [0.5121, 0.1141, 0.567, 0.1337]}, {"w": "parameters,", "b": [0.5757, 0.1141, 0.6655, 0.1337]}, {"w": "as", "b": [0.6741, 0.1141, 0.6895, 0.1337]}, {"w": "well", "b": [0.6982, 0.1141, 0.729, 0.1337]}, {"w": "as", "b": [0.7376, 0.1141, 0.753, 0.1337]}, {"w": "the", "b": [0.7616, 0.1141, 0.7857, 0.1337]}, {"w": "cross-validation", "b": [0.2714, 0.1315, 0.3932, 0.1511]}, {"w": "scores", "b": [0.3995, 0.1315, 0.4464, 0.1511]}, {"w": "and", "b": [0.4526, 0.1315, 0.4815, 0.1511]}, {"w": "perhaps", "b": [0.4877, 0.1315, 0.548, 0.1511]}, {"w": "the", "b": [0.5543, 0.1315, 0.5783, 0.1511]}, {"w": "actual", "b": [0.5846, 0.1315, 0.6301, 0.1511]}, {"w": "predictions", "b": [0.6363, 0.1315, 0.7227, 0.1511]}, {"w": "as", "b": [0.729, 0.1315, 0.7443, 0.1511]}, {"w": "well.", "b": [0.7506, 0.1315, 0.7857, 0.1511]}, {"w": "This", "b": [0.2714, 0.1489, 0.3054, 0.1685]}, {"w": "will", "b": [0.3127, 0.1489, 0.3405, 0.1685]}, {"w": "allow", "b": [0.3478, 0.1489, 0.3885, 0.1685]}, {"w": "you", "b": [0.3958, 0.1489, 0.4244, 0.1685]}, {"w": "to", "b": [0.4316, 0.1489, 0.4471, 0.1685]}, {"w": "easily", "b": [0.4544, 0.1489, 0.4965, 0.1685]}, {"w": "compare", "b": [0.5038, 0.1489, 0.5703, 0.1685]}, {"w": "scores", "b": [0.5776, 0.1489, 0.6245, 0.1685]}, {"w": "across", "b": [0.6318, 0.1489, 0.6789, 0.1685]}, {"w": "model", "b": [0.6862, 0.1489, 0.7345, 0.1685]}, {"w": "types,", "b": [0.7418, 0.1489, 0.7857, 0.1685]}, {"w": "and", "b": [0.2714, 0.1664, 0.3003, 0.1859]}, {"w": "compare", "b": [0.308, 0.1664, 0.3745, 0.1859]}, {"w": "the", "b": [0.3822, 0.1664, 0.4063, 0.1859]}, {"w": "types", "b": [0.414, 0.1664, 0.4536, 0.1859]}, {"w": "of", "b": [0.4613, 0.1664, 0.4766, 0.1859]}, {"w": "errors", "b": [0.4844, 0.1664, 0.5304, 0.1859]}, {"w": "they", "b": [0.5381, 0.1664, 0.5709, 0.1859]}, {"w": "make.", "b": [0.5786, 0.1664, 0.6244, 0.1859]}, {"w": "You", "b": [0.6321, 0.1664, 0.6617, 0.1859]}, {"w": "can", "b": [0.6694, 0.1664, 0.6963, 0.1859]}, {"w": "easily", "b": [0.704, 0.1664, 0.7461, 0.1859]}, {"w": "save", "b": [0.7538, 0.1664, 0.7857, 0.1859]}, {"w": "Scikit-Learn", "b": [0.2714, 0.1846, 0.3649, 0.2042]}, {"w": "models", "b": [0.3733, 0.1846, 0.4286, 0.2042]}, {"w": "by", "b": [0.4369, 0.1846, 0.4553, 0.2042]}, {"w": "using", "b": [0.4637, 0.1846, 0.5052, 0.2042]}, {"w": "Python’s", "b": [0.5135, 0.1846, 0.577, 0.2042]}, {"w": "pickle", "b": [0.5853, 0.1875, 0.6396, 0.2013]}, {"w": "module,", "b": [0.648, 0.1846, 0.7107, 0.2042]}, {"w": "or", "b": [0.7191, 0.1846, 0.7358, 0.2042]}, {"w": "using", "b": [0.7442, 0.1846, 0.7857, 0.2042]}, {"w": "sklearn.externals.joblib,", "b": [0.2714, 0.2028, 0.4929, 0.2224]}, {"w": "which", "b": [0.4987, 0.2028, 0.5452, 0.2224]}, {"w": "is", "b": [0.551, 0.2028, 0.5631, 0.2224]}, {"w": "more", "b": [0.5688, 0.2028, 0.6093, 0.2224]}, {"w": "efficient", "b": [0.6151, 0.2028, 0.6767, 0.2224]}, {"w": "at", "b": [0.6824, 0.2028, 0.6962, 0.2224]}, {"w": "serializing", "b": [0.702, 0.2028, 0.78, 0.2224]}, {"w": "large", "b": [0.2714, 0.2202, 0.3087, 0.2398]}, {"w": "NumPy", "b": [0.313, 0.2202, 0.3717, 0.2398]}, {"w": "arrays:", "b": [0.376, 0.2202, 0.4266, 0.2398]}]}, {"id": "b_1", "type": "paragraph", "text": "from sklearn.externals import joblib", "words": [{"w": "from", "b": [0.3051, 0.2473, 0.3389, 0.2602]}, {"w": "sklearn.externals", "b": [0.3473, 0.2473, 0.4906, 0.2602]}, {"w": "import", "b": [0.4991, 0.2473, 0.5497, 0.2602]}, {"w": "joblib", "b": [0.5581, 0.2473, 0.6087, 0.2602]}]}, {"id": "b_2", "type": "paragraph", "text": "joblib.dump(my_model, \"my_model.pkl\") # and later... my_model_loaded = joblib.load(\"my_model.pkl\")", "words": [{"w": "joblib.dump(my_model,", "b": [0.3051, 0.2782, 0.4822, 0.291]}, {"w": "\"my_model.pkl\")", "b": [0.4906, 0.2782, 0.6171, 0.291]}, {"w": "#", "b": [0.3051, 0.2936, 0.3136, 0.3064]}, {"w": "and", "b": [0.322, 0.2936, 0.3473, 0.3064]}, {"w": "later...", "b": [0.3557, 0.2936, 0.4232, 0.3064]}, {"w": "my_model_loaded", "b": [0.3051, 0.309, 0.4316, 0.3219]}, {"w": "=", "b": [0.4401, 0.309, 0.4485, 0.3219]}, {"w": "joblib.load(\"my_model.pkl\")", "b": [0.4569, 0.309, 0.6846, 0.3219]}]}, {"id": "b_3", "type": "equation", "text": "Fine-Tune Your Model", "words": [{"w": "Fine-Tune", "b": [0.1429, 0.3394, 0.2669, 0.3737]}, {"w": "Your", "b": [0.2728, 0.3394, 0.3295, 0.3737]}, {"w": "Model", "b": [0.3354, 0.3394, 0.4127, 0.3737]}]}, {"id": "b_4", "type": "paragraph", "text": "Let’s assume that you now have a shortlist of promising models. You now need to fine-tune them. Let’s look at a few ways you can do that.", "words": [{"w": "Let’s", "b": [0.1429, 0.3806, 0.179, 0.402]}, {"w": "assume", "b": [0.1867, 0.3806, 0.2481, 0.402]}, {"w": "that", "b": [0.2557, 0.3806, 0.2883, 0.402]}, {"w": "you", "b": [0.2959, 0.3806, 0.3271, 0.402]}, {"w": "now", "b": [0.3348, 0.3806, 0.3711, 0.402]}, {"w": "have", "b": [0.3787, 0.3806, 0.4171, 0.402]}, {"w": "a", "b": [0.4247, 0.3806, 0.4338, 0.402]}, {"w": "shortlist", "b": [0.4415, 0.3806, 0.5098, 0.402]}, {"w": "of", "b": [0.5174, 0.3806, 0.5342, 0.402]}, {"w": "promising", "b": [0.5418, 0.3806, 0.6281, 0.402]}, {"w": "models.", "b": [0.6357, 0.3806, 0.7009, 0.402]}, {"w": "You", "b": [0.7086, 0.3806, 0.7409, 0.402]}, {"w": "now", "b": [0.7485, 0.3806, 0.7848, 0.402]}, {"w": "need", "b": [0.7924, 0.3806, 0.8326, 0.402]}, {"w": "to", "b": [0.8402, 0.3806, 0.8571, 0.402]}, {"w": "fine-tune", "b": [0.1429, 0.3997, 0.2199, 0.4211]}, {"w": "them.", "b": [0.2247, 0.3997, 0.2728, 0.4211]}, {"w": "Let’s", "b": [0.2775, 0.3997, 0.3137, 0.4211]}, {"w": "look", "b": [0.3184, 0.3997, 0.3553, 0.4211]}, {"w": "at", "b": [0.36, 0.3997, 0.3751, 0.4211]}, {"w": "a", "b": [0.3799, 0.3997, 0.389, 0.4211]}, {"w": "few", "b": [0.3937, 0.3997, 0.423, 0.4211]}, {"w": "ways", "b": [0.4278, 0.3997, 0.468, 0.4211]}, {"w": "you", "b": [0.4727, 0.3997, 0.504, 0.4211]}, {"w": "can", "b": [0.5087, 0.3997, 0.5381, 0.4211]}, {"w": "do", "b": [0.5428, 0.3997, 0.5644, 0.4211]}, {"w": "that.", "b": [0.5691, 0.3997, 0.6065, 0.4211]}]}, {"id": "b_5", "type": "paragraph", "text": "Grid Search", "words": [{"w": "Grid", "b": [0.1429, 0.4339, 0.1854, 0.4624]}, {"w": "Search", "b": [0.1903, 0.4339, 0.2588, 0.4624]}]}, {"id": "b_6", "type": "paragraph", "text": "One way to do that would be to fiddle with the hyperparameters manually, until you find a great combination of hyperparameter values. This would be very tedious work, and you may not have time to explore many combinations.", "words": [{"w": "One", "b": [0.1429, 0.4683, 0.1787, 0.4897]}, {"w": "way", "b": [0.1845, 0.4683, 0.2171, 0.4897]}, {"w": "to", "b": [0.223, 0.4683, 0.24, 0.4897]}, {"w": "do", "b": [0.2458, 0.4683, 0.2675, 0.4897]}, {"w": "that", "b": [0.2733, 0.4683, 0.3059, 0.4897]}, {"w": "would", "b": [0.3118, 0.4683, 0.364, 0.4897]}, {"w": "be", "b": [0.3699, 0.4683, 0.3893, 0.4897]}, {"w": "to", "b": [0.3952, 0.4683, 0.4122, 0.4897]}, {"w": "fiddle", "b": [0.418, 0.4683, 0.4659, 0.4897]}, {"w": "with", "b": [0.4718, 0.4683, 0.5091, 0.4897]}, {"w": "the", "b": [0.5149, 0.4683, 0.5413, 0.4897]}, {"w": "hyperparameters", "b": [0.5471, 0.4683, 0.6883, 0.4897]}, {"w": "manually,", "b": [0.6942, 0.4683, 0.7749, 0.4897]}, {"w": "until", "b": [0.7808, 0.4683, 0.82, 0.4897]}, {"w": "you", "b": [0.8259, 0.4683, 0.8572, 0.4897]}, {"w": "find", "b": [0.1429, 0.4874, 0.177, 0.5088]}, {"w": "a", "b": [0.1822, 0.4874, 0.1913, 0.5088]}, {"w": "great", "b": [0.1965, 0.4874, 0.2379, 0.5088]}, {"w": "combination", "b": [0.2431, 0.4874, 0.3499, 0.5088]}, {"w": "of", "b": [0.355, 0.4874, 0.3718, 0.5088]}, {"w": "hyperparameter", "b": [0.377, 0.4874, 0.5105, 0.5088]}, {"w": "values.", "b": [0.5157, 0.4874, 0.572, 0.5088]}, {"w": "This", "b": [0.5772, 0.4874, 0.6144, 0.5088]}, {"w": "would", "b": [0.6196, 0.4874, 0.6718, 0.5088]}, {"w": "be", "b": [0.677, 0.4874, 0.6964, 0.5088]}, {"w": "very", "b": [0.7016, 0.4874, 0.738, 0.5088]}, {"w": "tedious", "b": [0.7431, 0.4874, 0.8043, 0.5088]}, {"w": "work,", "b": [0.8094, 0.4874, 0.8571, 0.5088]}, {"w": "and", "b": [0.1429, 0.5064, 0.1744, 0.5278]}, {"w": "you", "b": [0.1791, 0.5064, 0.2104, 0.5278]}, {"w": "may", "b": [0.2151, 0.5064, 0.2505, 0.5278]}, {"w": "not", "b": [0.2552, 0.5064, 0.2836, 0.5278]}, {"w": "have", "b": [0.2883, 0.5064, 0.3267, 0.5278]}, {"w": "time", "b": [0.3315, 0.5064, 0.3693, 0.5278]}, {"w": "to", "b": [0.374, 0.5064, 0.391, 0.5278]}, {"w": "explore", "b": [0.3957, 0.5064, 0.4578, 0.5278]}, {"w": "many", "b": [0.4626, 0.5064, 0.5092, 0.5278]}, {"w": "combinations.", "b": [0.514, 0.5064, 0.6331, 0.5278]}]}, {"id": "b_7", "type": "paragraph", "text": "Instead you should get Scikit-Learn’s GridSearchCV to search for you. All you need to do is tell it which hyperparameters you want it to experiment with, and what values to try out, and it will evaluate all the possible combinations of hyperparameter values, using cross-validation. For example, the following code searches for the best combi‐ nation of hyperparameter values for the RandomForestRegressor:", "words": [{"w": "Instead", "b": [0.1429, 0.5354, 0.2044, 0.5568]}, {"w": "you", "b": [0.2094, 0.5354, 0.2407, 0.5568]}, {"w": "should", "b": [0.2458, 0.5354, 0.3025, 0.5568]}, {"w": "get", "b": [0.3076, 0.5354, 0.3325, 0.5568]}, {"w": "Scikit-Learn’s", "b": [0.3376, 0.5354, 0.4485, 0.5568]}, {"w": "GridSearchCV", "b": [0.4536, 0.5386, 0.5724, 0.5537]}, {"w": "to", "b": [0.5774, 0.5354, 0.5944, 0.5568]}, {"w": "search", "b": [0.5995, 0.5354, 0.6528, 0.5568]}, {"w": "for", "b": [0.6579, 0.5354, 0.6824, 0.5568]}, {"w": "you.", "b": [0.6875, 0.5354, 0.7235, 0.5568]}, {"w": "All", "b": [0.7286, 0.5354, 0.7535, 0.5568]}, {"w": "you", "b": [0.7586, 0.5354, 0.7899, 0.5568]}, {"w": "need", "b": [0.795, 0.5354, 0.8351, 0.5568]}, {"w": "to", "b": [0.8402, 0.5354, 0.8571, 0.5568]}, {"w": "do", "b": [0.1429, 0.5545, 0.1645, 0.5759]}, {"w": "is", "b": [0.1692, 0.5545, 0.1824, 0.5759]}, {"w": "tell", "b": [0.1872, 0.5545, 0.2129, 0.5759]}, {"w": "it", "b": [0.2177, 0.5545, 0.2296, 0.5759]}, {"w": "which", "b": [0.2343, 0.5545, 0.2852, 0.5759]}, {"w": "hyperparameters", "b": [0.29, 0.5545, 0.4311, 0.5759]}, {"w": "you", "b": [0.4358, 0.5545, 0.4671, 0.5759]}, {"w": "want", "b": [0.4718, 0.5545, 0.5126, 0.5759]}, {"w": "it", "b": [0.5173, 0.5545, 0.5293, 0.5759]}, {"w": "to", "b": [0.534, 0.5545, 0.551, 0.5759]}, {"w": "experiment", "b": [0.5557, 0.5545, 0.6507, 0.5759]}, {"w": "with,", "b": [0.6555, 0.5545, 0.6976, 0.5759]}, {"w": "and", "b": [0.7023, 0.5545, 0.7338, 0.5759]}, {"w": "what", "b": [0.7386, 0.5545, 0.7791, 0.5759]}, {"w": "values", "b": [0.7838, 0.5545, 0.8354, 0.5759]}, {"w": "to", "b": [0.8401, 0.5545, 0.8571, 0.5759]}, {"w": "try", "b": [0.1429, 0.5735, 0.1671, 0.5949]}, {"w": "out,", "b": [0.1739, 0.5735, 0.2067, 0.5949]}, {"w": "and", "b": [0.2134, 0.5735, 0.245, 0.5949]}, {"w": "it", "b": [0.2517, 0.5735, 0.2637, 0.5949]}, {"w": "will", "b": [0.2705, 0.5735, 0.3008, 0.5949]}, {"w": "evaluate", "b": [0.3076, 0.5735, 0.3756, 0.5949]}, {"w": "all", "b": [0.3823, 0.5735, 0.402, 0.5949]}, {"w": "the", "b": [0.4088, 0.5735, 0.4351, 0.5949]}, {"w": "possible", "b": [0.4419, 0.5735, 0.509, 0.5949]}, {"w": "combinations", "b": [0.5158, 0.5735, 0.6302, 0.5949]}, {"w": "of", "b": [0.6369, 0.5735, 0.6537, 0.5949]}, {"w": "hyperparameter", "b": [0.6605, 0.5735, 0.794, 0.5949]}, {"w": "values,", "b": [0.8008, 0.5735, 0.8571, 0.5949]}, {"w": "using", "b": [0.1429, 0.5926, 0.1883, 0.614]}, {"w": "cross-validation.", "b": [0.1946, 0.5926, 0.3325, 0.614]}, {"w": "For", "b": [0.3388, 0.5926, 0.3678, 0.614]}, {"w": "example,", "b": [0.374, 0.5926, 0.4483, 0.614]}, {"w": "the", "b": [0.4546, 0.5926, 0.4809, 0.614]}, {"w": "following", "b": [0.4872, 0.5926, 0.5661, 0.614]}, {"w": "code", "b": [0.5724, 0.5926, 0.6117, 0.614]}, {"w": "searches", "b": [0.6179, 0.5926, 0.6877, 0.614]}, {"w": "for", "b": [0.694, 0.5926, 0.7185, 0.614]}, {"w": "the", "b": [0.7248, 0.5926, 0.7511, 0.614]}, {"w": "best", "b": [0.7574, 0.5926, 0.7908, 0.614]}, {"w": "combi‐", "b": [0.7971, 0.5926, 0.8571, 0.614]}, {"w": "nation", "b": [0.1429, 0.6125, 0.197, 0.6339]}, {"w": "of", "b": [0.2017, 0.6125, 0.2185, 0.6339]}, {"w": "hyperparameter", "b": [0.2232, 0.6125, 0.3567, 0.6339]}, {"w": "values", "b": [0.3614, 0.6125, 0.4131, 0.6339]}, {"w": "for", "b": [0.4178, 0.6125, 0.4423, 0.6339]}, {"w": "the", "b": [0.447, 0.6125, 0.4734, 0.6339]}, {"w": "RandomForestRegressor:", "b": [0.4781, 0.6125, 0.6907, 0.6339]}]}, {"id": "b_8", "type": "equation", "text": "from sklearn.model_selection import GridSearchCV", "words": [{"w": "from", "b": [0.1766, 0.6445, 0.2103, 0.6573]}, {"w": "sklearn.model_selection", "b": [0.2187, 0.6445, 0.4127, 0.6573]}, {"w": "import", "b": [0.4211, 0.6445, 0.4717, 0.6573]}, {"w": "GridSearchCV", "b": [0.4802, 0.6445, 0.5813, 0.6573]}]}, {"id": "b_9", "type": "paragraph", "text": "param_grid = [ {'n_estimators': [3, 10, 30], 'max_features': [2, 4, 6, 8]}, {'bootstrap': [False], 'n_estimators': [3, 10], 'max_features': [2, 3, 4]}, ]", "words": [{"w": "param_grid", "b": [0.1766, 0.6753, 0.2609, 0.6882]}, {"w": "=", "b": [0.2693, 0.6753, 0.2778, 0.6882]}, {"w": "[", "b": [0.2862, 0.6753, 0.2946, 0.6882]}, {"w": "{'n_estimators':", "b": [0.2103, 0.6908, 0.3452, 0.7036]}, {"w": "[3,", "b": [0.3537, 0.6908, 0.379, 0.7036]}, {"w": "10,", "b": [0.3874, 0.6908, 0.4127, 0.7036]}, {"w": "30],", "b": [0.4211, 0.6908, 0.4549, 0.7036]}, {"w": "'max_features':", "b": [0.4633, 0.6908, 0.5898, 0.7036]}, {"w": "[2,", "b": [0.5982, 0.6908, 0.6235, 0.7036]}, {"w": "4,", "b": [0.6319, 0.6908, 0.6488, 0.7036]}, {"w": "6,", "b": [0.6572, 0.6908, 0.6741, 0.7036]}, {"w": "8]},", "b": [0.6825, 0.6908, 0.7163, 0.7036]}, {"w": "{'bootstrap':", "b": [0.2103, 0.7062, 0.3199, 0.719]}, {"w": "[False],", "b": [0.3284, 0.7062, 0.3958, 0.719]}, {"w": "'n_estimators':", "b": [0.4043, 0.7062, 0.5307, 0.719]}, {"w": "[3,", "b": [0.5392, 0.7062, 0.5645, 0.719]}, {"w": "10],", "b": [0.5729, 0.7062, 0.6066, 0.719]}, {"w": "'max_features':", "b": [0.6151, 0.7062, 0.7416, 0.719]}, {"w": "[2,", "b": [0.75, 0.7062, 0.7753, 0.719]}, {"w": "3,", "b": [0.7837, 0.7062, 0.8006, 0.719]}, {"w": "4]},", "b": [0.809, 0.7062, 0.8428, 0.719]}, {"w": "]", "b": [0.1934, 0.7216, 0.2019, 0.7344]}]}, {"id": "b_10", "type": "equation", "text": "forest_reg = RandomForestRegressor()", "words": [{"w": "forest_reg", "b": [0.1766, 0.7524, 0.2609, 0.7653]}, {"w": "=", "b": [0.2693, 0.7524, 0.2778, 0.7653]}, {"w": "RandomForestRegressor()", "b": [0.2862, 0.7524, 0.4802, 0.7653]}]}, {"id": "b_11", "type": "paragraph", "text": "grid_search = GridSearchCV(forest_reg, param_grid, cv=5, scoring='neg_mean_squared_error', return_train_score=True)", "words": [{"w": "grid_search", "b": [0.1766, 0.7833, 0.2693, 0.7961]}, {"w": "=", "b": [0.2778, 0.7833, 0.2862, 0.7961]}, {"w": "GridSearchCV(forest_reg,", "b": [0.2946, 0.7833, 0.497, 0.7961]}, {"w": "param_grid,", "b": [0.5055, 0.7833, 0.5982, 0.7961]}, {"w": "cv=5,", "b": [0.6066, 0.7833, 0.6488, 0.7961]}, {"w": "scoring='neg_mean_squared_error',", "b": [0.4043, 0.7987, 0.6825, 0.8115]}, {"w": "return_train_score=True)", "b": [0.4043, 0.8141, 0.6066, 0.827]}]}, {"id": "b_12", "type": "equation", "text": "grid_search.fit(housing_prepared, housing_labels)", "words": [{"w": "grid_search.fit(housing_prepared,", "b": [0.1766, 0.845, 0.4549, 0.8578]}, {"w": "housing_labels)", "b": [0.4633, 0.845, 0.5898, 0.8578]}]}, {"id": "b_13", "type": "equation", "text": "Fine-Tune Your Model | 79", "words": [{"w": "Fine-Tune", "b": [0.6747, 0.9225, 0.7337, 0.9388]}, {"w": "Your", "b": [0.7366, 0.9225, 0.7635, 0.9388]}, {"w": "Model", "b": [0.7663, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "79", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 106, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "When you have no idea what value a hyperparameter should have, a simple approach is to try out consecutive powers of 10 (or a smaller number if you want a more fine-grained search, as shown in this example with the n_estimators hyperparameter).", "words": [{"w": "When", "b": [0.2714, 0.0793, 0.3186, 0.0989]}, {"w": "you", "b": [0.3239, 0.0793, 0.3524, 0.0989]}, {"w": "have", "b": [0.3577, 0.0793, 0.3928, 0.0989]}, {"w": "no", "b": [0.3981, 0.0793, 0.4182, 0.0989]}, {"w": "idea", "b": [0.4235, 0.0793, 0.4551, 0.0989]}, {"w": "what", "b": [0.4604, 0.0793, 0.4974, 0.0989]}, {"w": "value", "b": [0.5027, 0.0793, 0.5429, 0.0989]}, {"w": "a", "b": [0.5482, 0.0793, 0.5565, 0.0989]}, {"w": "hyperparameter", "b": [0.5618, 0.0793, 0.6839, 0.0989]}, {"w": "should", "b": [0.6891, 0.0793, 0.741, 0.0989]}, {"w": "have,", "b": [0.7463, 0.0793, 0.7857, 0.0989]}, {"w": "a", "b": [0.2714, 0.0967, 0.2798, 0.1163]}, {"w": "simple", "b": [0.2881, 0.0967, 0.3383, 0.1163]}, {"w": "approach", "b": [0.3466, 0.0967, 0.4179, 0.1163]}, {"w": "is", "b": [0.4262, 0.0967, 0.4383, 0.1163]}, {"w": "to", "b": [0.4466, 0.0967, 0.4621, 0.1163]}, {"w": "try", "b": [0.4704, 0.0967, 0.4925, 0.1163]}, {"w": "out", "b": [0.5008, 0.0967, 0.5265, 0.1163]}, {"w": "consecutive", "b": [0.5348, 0.0967, 0.624, 0.1163]}, {"w": "powers", "b": [0.6323, 0.0967, 0.6872, 0.1163]}, {"w": "of", "b": [0.6955, 0.0967, 0.7108, 0.1163]}, {"w": "10", "b": [0.7191, 0.0967, 0.7374, 0.1163]}, {"w": "(or", "b": [0.7457, 0.0967, 0.7691, 0.1163]}, {"w": "a", "b": [0.7774, 0.0967, 0.7857, 0.1163]}, {"w": "smaller", "b": [0.2714, 0.1141, 0.3272, 0.1337]}, {"w": "number", "b": [0.3331, 0.1141, 0.3937, 0.1337]}, {"w": "if", "b": [0.3997, 0.1141, 0.4105, 0.1337]}, {"w": "you", "b": [0.4164, 0.1141, 0.445, 0.1337]}, {"w": "want", "b": [0.451, 0.1141, 0.4882, 0.1337]}, {"w": "a", "b": [0.4942, 0.1141, 0.5026, 0.1337]}, {"w": "more", "b": [0.5085, 0.1141, 0.549, 0.1337]}, {"w": "fine-grained", "b": [0.555, 0.1141, 0.649, 0.1337]}, {"w": "search,", "b": [0.655, 0.1141, 0.7081, 0.1337]}, {"w": "as", "b": [0.7141, 0.1141, 0.7294, 0.1337]}, {"w": "shown", "b": [0.7354, 0.1141, 0.7857, 0.1337]}, {"w": "in", "b": [0.2714, 0.1323, 0.2869, 0.1519]}, {"w": "this", "b": [0.2913, 0.1323, 0.3193, 0.1519]}, {"w": "example", "b": [0.3237, 0.1323, 0.3872, 0.1519]}, {"w": "with", "b": [0.3916, 0.1323, 0.4257, 0.1519]}, {"w": "the", "b": [0.43, 0.1323, 0.4541, 0.1519]}, {"w": "n_estimators", "b": [0.4584, 0.1353, 0.567, 0.149]}, {"w": "hyperparameter).", "b": [0.5713, 0.1323, 0.7043, 0.1519]}]}, {"id": "b_1", "type": "paragraph", "text": "This param_grid tells Scikit-Learn to first evaluate all 3 × 4 = 12 combinations of n_estimators and max_features hyperparameter values specified in the first dict (don’t worry about what these hyperparameters mean for now; they will be explained in Chapter 7), then try all 2 × 3 = 6 combinations of hyperparameter values in the second dict, but this time with the bootstrap hyperparameter set to False instead of True (which is the default value for this hyperparameter).", "words": [{"w": "This", "b": [0.1428, 0.1788, 0.1801, 0.2002]}, {"w": "param_grid", "b": [0.1878, 0.182, 0.2868, 0.1971]}, {"w": "tells", "b": [0.2946, 0.1788, 0.328, 0.2002]}, {"w": "Scikit-Learn", "b": [0.3358, 0.1788, 0.4381, 0.2002]}, {"w": "to", "b": [0.4458, 0.1788, 0.4628, 0.2002]}, {"w": "first", "b": [0.4706, 0.1788, 0.5041, 0.2002]}, {"w": "evaluate", "b": [0.5119, 0.1788, 0.5798, 0.2002]}, {"w": "all", "b": [0.5876, 0.1788, 0.6073, 0.2002]}, {"w": "3", "b": [0.6151, 0.1788, 0.6251, 0.2002]}, {"w": "×", "b": [0.6328, 0.1788, 0.6449, 0.2002]}, {"w": "4", "b": [0.6527, 0.1788, 0.6627, 0.2002]}, {"w": "=", "b": [0.6705, 0.1788, 0.6826, 0.2002]}, {"w": "12", "b": [0.6904, 0.1788, 0.7104, 0.2002]}, {"w": "combinations", "b": [0.7181, 0.1788, 0.8326, 0.2002]}, {"w": "of", "b": [0.8403, 0.1788, 0.8571, 0.2002]}, {"w": "n_estimators", "b": [0.1429, 0.202, 0.2616, 0.217]}, {"w": "and", "b": [0.2694, 0.1988, 0.301, 0.2202]}, {"w": "max_features", "b": [0.3088, 0.202, 0.4275, 0.217]}, {"w": "hyperparameter", "b": [0.4353, 0.1988, 0.5688, 0.2202]}, {"w": "values", "b": [0.5767, 0.1988, 0.6283, 0.2202]}, {"w": "specified", "b": [0.6361, 0.1988, 0.7095, 0.2202]}, {"w": "in", "b": [0.7173, 0.1988, 0.7343, 0.2202]}, {"w": "the", "b": [0.7421, 0.1988, 0.7684, 0.2202]}, {"w": "first", "b": [0.7763, 0.1988, 0.8097, 0.2202]}, {"w": "dict", "b": [0.8176, 0.202, 0.8571, 0.217]}, {"w": "(don’t", "b": [0.1428, 0.2178, 0.1917, 0.2392]}, {"w": "worry", "b": [0.1969, 0.2178, 0.2475, 0.2392]}, {"w": "about", "b": [0.2528, 0.2178, 0.3005, 0.2392]}, {"w": "what", "b": [0.3058, 0.2178, 0.3463, 0.2392]}, {"w": "these", "b": [0.3516, 0.2178, 0.3944, 0.2392]}, {"w": "hyperparameters", "b": [0.3997, 0.2178, 0.5409, 0.2392]}, {"w": "mean", "b": [0.5462, 0.2178, 0.5926, 0.2392]}, {"w": "for", "b": [0.5979, 0.2178, 0.6224, 0.2392]}, {"w": "now;", "b": [0.6277, 0.2178, 0.6694, 0.2392]}, {"w": "they", "b": [0.6747, 0.2178, 0.7106, 0.2392]}, {"w": "will", "b": [0.7159, 0.2178, 0.7463, 0.2392]}, {"w": "be", "b": [0.7516, 0.2178, 0.771, 0.2392]}, {"w": "explained", "b": [0.7763, 0.2178, 0.8571, 0.2392]}, {"w": "in", "b": [0.1429, 0.2369, 0.1598, 0.2583]}, {"w": "Chapter", "b": [0.1669, 0.2369, 0.2344, 0.2583]}, {"w": "7),", "b": [0.2415, 0.2369, 0.2634, 0.2583]}, {"w": "then", "b": [0.2704, 0.2369, 0.3082, 0.2583]}, {"w": "try", "b": [0.3152, 0.2369, 0.3394, 0.2583]}, {"w": "all", "b": [0.3465, 0.2369, 0.3661, 0.2583]}, {"w": "2", "b": [0.3732, 0.2369, 0.3832, 0.2583]}, {"w": "×", "b": [0.3902, 0.2369, 0.4023, 0.2583]}, {"w": "3", "b": [0.4093, 0.2369, 0.4193, 0.2583]}, {"w": "=", "b": [0.4263, 0.2369, 0.4384, 0.2583]}, {"w": "6", "b": [0.4454, 0.2369, 0.4554, 0.2583]}, {"w": "combinations", "b": [0.4624, 0.2369, 0.5768, 0.2583]}, {"w": "of", "b": [0.5838, 0.2369, 0.6006, 0.2583]}, {"w": "hyperparameter", "b": [0.6077, 0.2369, 0.7412, 0.2583]}, {"w": "values", "b": [0.7482, 0.2369, 0.7998, 0.2583]}, {"w": "in", "b": [0.8068, 0.2369, 0.8238, 0.2583]}, {"w": "the", "b": [0.8308, 0.2369, 0.8571, 0.2583]}, {"w": "second", "b": [0.1429, 0.2568, 0.2012, 0.2782]}, {"w": "dict,", "b": [0.206, 0.2568, 0.2503, 0.2782]}, {"w": "but", "b": [0.2551, 0.2568, 0.2831, 0.2782]}, {"w": "this", "b": [0.2878, 0.2568, 0.3185, 0.2782]}, {"w": "time", "b": [0.3232, 0.2568, 0.3611, 0.2782]}, {"w": "with", "b": [0.3658, 0.2568, 0.4032, 0.2782]}, {"w": "the", "b": [0.4079, 0.2568, 0.4342, 0.2782]}, {"w": "bootstrap", "b": [0.4395, 0.26, 0.5286, 0.2751]}, {"w": "hyperparameter", "b": [0.5334, 0.2568, 0.6669, 0.2782]}, {"w": "set", "b": [0.6717, 0.2568, 0.6945, 0.2782]}, {"w": "to", "b": [0.6992, 0.2568, 0.7162, 0.2782]}, {"w": "False", "b": [0.7212, 0.26, 0.7707, 0.2751]}, {"w": "instead", "b": [0.7756, 0.2568, 0.8355, 0.2782]}, {"w": "of", "b": [0.8403, 0.2568, 0.8571, 0.2782]}, {"w": "True", "b": [0.1429, 0.2799, 0.1824, 0.295]}, {"w": "(which", "b": [0.1872, 0.2768, 0.2453, 0.2982]}, {"w": "is", "b": [0.25, 0.2768, 0.2632, 0.2982]}, {"w": "the", "b": [0.268, 0.2768, 0.2943, 0.2982]}, {"w": "default", "b": [0.299, 0.2768, 0.3565, 0.2982]}, {"w": "value", "b": [0.3612, 0.2768, 0.4052, 0.2982]}, {"w": "for", "b": [0.4099, 0.2768, 0.4345, 0.2982]}, {"w": "this", "b": [0.4392, 0.2768, 0.4699, 0.2982]}, {"w": "hyperparameter).", "b": [0.4746, 0.2768, 0.6201, 0.2982]}]}, {"id": "b_2", "type": "paragraph", "text": "All in all, the grid search will explore 12 + 6 = 18 combinations of RandomForestRe gressor hyperparameter values, and it will train each model five times (since we are using five-fold cross validation). In other words, all in all, there will be 18 × 5 = 90 rounds of training! It may take quite a long time, but when it is done you can get the best combination of parameters like this:", "words": [{"w": "All", "b": [0.1429, 0.3058, 0.1678, 0.3272]}, {"w": "in", "b": [0.1742, 0.3058, 0.1912, 0.3272]}, {"w": "all,", "b": [0.1976, 0.3058, 0.222, 0.3272]}, {"w": "the", "b": [0.2285, 0.3058, 0.2548, 0.3272]}, {"w": "grid", "b": [0.2612, 0.3058, 0.2953, 0.3272]}, {"w": "search", "b": [0.3017, 0.3058, 0.355, 0.3272]}, {"w": "will", "b": [0.3614, 0.3058, 0.3918, 0.3272]}, {"w": "explore", "b": [0.3982, 0.3058, 0.4603, 0.3272]}, {"w": "12", "b": [0.4667, 0.3058, 0.4867, 0.3272]}, {"w": "+", "b": [0.4931, 0.3058, 0.5052, 0.3272]}, {"w": "6", "b": [0.5116, 0.3058, 0.5216, 0.3272]}, {"w": "=", "b": [0.528, 0.3058, 0.5401, 0.3272]}, {"w": "18", "b": [0.5465, 0.3058, 0.5665, 0.3272]}, {"w": "combinations", "b": [0.573, 0.3058, 0.6874, 0.3272]}, {"w": "of", "b": [0.6938, 0.3058, 0.7106, 0.3272]}, {"w": "RandomForestRe", "b": [0.717, 0.309, 0.8555, 0.324]}, {"w": "gressor", "b": [0.1429, 0.3289, 0.2121, 0.344]}, {"w": "hyperparameter", "b": [0.218, 0.3257, 0.3515, 0.3471]}, {"w": "values,", "b": [0.3574, 0.3257, 0.4137, 0.3471]}, {"w": "and", "b": [0.4196, 0.3257, 0.4511, 0.3471]}, {"w": "it", "b": [0.457, 0.3257, 0.4689, 0.3471]}, {"w": "will", "b": [0.4748, 0.3257, 0.5052, 0.3471]}, {"w": "train", "b": [0.511, 0.3257, 0.5513, 0.3471]}, {"w": "each", "b": [0.5571, 0.3257, 0.5951, 0.3471]}, {"w": "model", "b": [0.6009, 0.3257, 0.6537, 0.3471]}, {"w": "five", "b": [0.6596, 0.3257, 0.6898, 0.3471]}, {"w": "times", "b": [0.6957, 0.3257, 0.7412, 0.3471]}, {"w": "(since", "b": [0.7471, 0.3257, 0.7966, 0.3471]}, {"w": "we", "b": [0.8024, 0.3257, 0.8256, 0.3471]}, {"w": "are", "b": [0.8314, 0.3257, 0.8571, 0.3471]}, {"w": "using", "b": [0.1429, 0.3448, 0.1883, 0.3662]}, {"w": "five-fold", "b": [0.1949, 0.3448, 0.2657, 0.3662]}, {"w": "cross", "b": [0.2723, 0.3448, 0.3148, 0.3662]}, {"w": "validation).", "b": [0.3214, 0.3448, 0.4168, 0.3662]}, {"w": "In", "b": [0.4234, 0.3448, 0.4419, 0.3662]}, {"w": "other", "b": [0.4486, 0.3448, 0.4932, 0.3662]}, {"w": "words,", "b": [0.4999, 0.3448, 0.5559, 0.3662]}, {"w": "all", "b": [0.5626, 0.3448, 0.5823, 0.3662]}, {"w": "in", "b": [0.5889, 0.3448, 0.6059, 0.3662]}, {"w": "all,", "b": [0.6126, 0.3448, 0.637, 0.3662]}, {"w": "there", "b": [0.6436, 0.3448, 0.6866, 0.3662]}, {"w": "will", "b": [0.6932, 0.3448, 0.7236, 0.3662]}, {"w": "be", "b": [0.7303, 0.3448, 0.7497, 0.3662]}, {"w": "18", "b": [0.7564, 0.3448, 0.7764, 0.3662]}, {"w": "×", "b": [0.783, 0.3448, 0.7951, 0.3662]}, {"w": "5", "b": [0.8017, 0.3448, 0.8117, 0.3662]}, {"w": "=", "b": [0.8184, 0.3448, 0.8305, 0.3662]}, {"w": "90", "b": [0.8371, 0.3448, 0.8571, 0.3662]}, {"w": "rounds", "b": [0.1428, 0.3638, 0.2023, 0.3852]}, {"w": "of", "b": [0.2078, 0.3638, 0.2246, 0.3852]}, {"w": "training!", "b": [0.2301, 0.3638, 0.3028, 0.3852]}, {"w": "It", "b": [0.3082, 0.3638, 0.3209, 0.3852]}, {"w": "may", "b": [0.3264, 0.3638, 0.3618, 0.3852]}, {"w": "take", "b": [0.3673, 0.3638, 0.4019, 0.3852]}, {"w": "quite", "b": [0.4074, 0.3638, 0.4499, 0.3852]}, {"w": "a", "b": [0.4554, 0.3638, 0.4646, 0.3852]}, {"w": "long", "b": [0.47, 0.3638, 0.5071, 0.3852]}, {"w": "time,", "b": [0.5126, 0.3638, 0.5552, 0.3852]}, {"w": "but", "b": [0.5607, 0.3638, 0.5887, 0.3852]}, {"w": "when", "b": [0.5941, 0.3638, 0.6398, 0.3852]}, {"w": "it", "b": [0.6453, 0.3638, 0.6572, 0.3852]}, {"w": "is", "b": [0.6627, 0.3638, 0.6759, 0.3852]}, {"w": "done", "b": [0.6814, 0.3638, 0.7233, 0.3852]}, {"w": "you", "b": [0.7288, 0.3638, 0.76, 0.3852]}, {"w": "can", "b": [0.7655, 0.3638, 0.7949, 0.3852]}, {"w": "get", "b": [0.8004, 0.3638, 0.8253, 0.3852]}, {"w": "the", "b": [0.8308, 0.3638, 0.8571, 0.3852]}, {"w": "best", "b": [0.1429, 0.3829, 0.1763, 0.4043]}, {"w": "combination", "b": [0.181, 0.3829, 0.2878, 0.4043]}, {"w": "of", "b": [0.2925, 0.3829, 0.3093, 0.4043]}, {"w": "parameters", "b": [0.314, 0.3829, 0.4075, 0.4043]}, {"w": "like", "b": [0.4122, 0.3829, 0.4423, 0.4043]}, {"w": "this:", "b": [0.447, 0.3829, 0.4824, 0.4043]}]}, {"id": "b_3", "type": "equation", "text": ">>> grid_search.best_params_ {'max_features': 8, 'n_estimators': 30}", "words": [{"w": ">>>", "b": [0.1766, 0.4148, 0.2019, 0.4277]}, {"w": "grid_search.best_params_", "b": [0.2103, 0.4148, 0.4127, 0.4277]}, {"w": "{'max_features':", "b": [0.1766, 0.4302, 0.3115, 0.4431]}, {"w": "8,", "b": [0.3199, 0.4302, 0.3368, 0.4431]}, {"w": "'n_estimators':", "b": [0.3452, 0.4302, 0.4717, 0.4431]}, {"w": "30}", "b": [0.4802, 0.4302, 0.5054, 0.4431]}]}, {"id": "b_4", "type": "paragraph", "text": "Since 8 and 30 are the maximum values that were evaluated, you should probably try searching again with higher values, since the score may continue to improve.", "words": [{"w": "Since", "b": [0.2714, 0.4647, 0.3121, 0.4843]}, {"w": "8", "b": [0.3187, 0.4647, 0.3278, 0.4843]}, {"w": "and", "b": [0.3344, 0.4647, 0.3632, 0.4843]}, {"w": "30", "b": [0.3698, 0.4647, 0.3881, 0.4843]}, {"w": "are", "b": [0.3947, 0.4647, 0.4182, 0.4843]}, {"w": "the", "b": [0.4248, 0.4647, 0.4489, 0.4843]}, {"w": "maximum", "b": [0.4554, 0.4647, 0.5345, 0.4843]}, {"w": "values", "b": [0.541, 0.4647, 0.5882, 0.4843]}, {"w": "that", "b": [0.5948, 0.4647, 0.6246, 0.4843]}, {"w": "were", "b": [0.6312, 0.4647, 0.6675, 0.4843]}, {"w": "evaluated,", "b": [0.6741, 0.4647, 0.7506, 0.4843]}, {"w": "you", "b": [0.7571, 0.4647, 0.7857, 0.4843]}, {"w": "should", "b": [0.2714, 0.4821, 0.3233, 0.5017]}, {"w": "probably", "b": [0.3299, 0.4821, 0.398, 0.5017]}, {"w": "try", "b": [0.4046, 0.4821, 0.4268, 0.5017]}, {"w": "searching", "b": [0.4335, 0.4821, 0.5066, 0.5017]}, {"w": "again", "b": [0.5133, 0.4821, 0.5545, 0.5017]}, {"w": "with", "b": [0.5611, 0.4821, 0.5953, 0.5017]}, {"w": "higher", "b": [0.6019, 0.4821, 0.6514, 0.5017]}, {"w": "values,", "b": [0.6581, 0.4821, 0.7097, 0.5017]}, {"w": "since", "b": [0.7163, 0.4821, 0.755, 0.5017]}, {"w": "the", "b": [0.7616, 0.4821, 0.7857, 0.5017]}, {"w": "score", "b": [0.2714, 0.4995, 0.3113, 0.5191]}, {"w": "may", "b": [0.3157, 0.4995, 0.348, 0.5191]}, {"w": "continue", "b": [0.3523, 0.4995, 0.4194, 0.5191]}, {"w": "to", "b": [0.4237, 0.4995, 0.4392, 0.5191]}, {"w": "improve.", "b": [0.4435, 0.4995, 0.5119, 0.5191]}]}, {"id": "b_5", "type": "paragraph", "text": "You can also get the best estimator directly:", "words": [{"w": "You", "b": [0.1428, 0.5634, 0.1752, 0.5848]}, {"w": "can", "b": [0.1799, 0.5634, 0.2093, 0.5848]}, {"w": "also", "b": [0.214, 0.5634, 0.2467, 0.5848]}, {"w": "get", "b": [0.2514, 0.5634, 0.2764, 0.5848]}, {"w": "the", "b": [0.2811, 0.5634, 0.3074, 0.5848]}, {"w": "best", "b": [0.3122, 0.5634, 0.3456, 0.5848]}, {"w": "estimator", "b": [0.3503, 0.5634, 0.4293, 0.5848]}, {"w": "directly:", "b": [0.434, 0.5634, 0.5026, 0.5848]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> grid_search.best_estimator_ RandomForestRegressor(bootstrap=True, criterion='mse', max_depth=None, max_features=8, max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, min_samples_leaf=1, min_samples_split=2, min_weight_fraction_leaf=0.0, n_estimators=30, n_jobs=None, oob_score=False, random_state=None, verbose=0, warm_start=False)", "words": [{"w": ">>>", "b": [0.1766, 0.5953, 0.2019, 0.6082]}, {"w": "grid_search.best_estimator_", "b": [0.2103, 0.5953, 0.438, 0.6082]}, {"w": "RandomForestRegressor(bootstrap=True,", "b": [0.1766, 0.6107, 0.4886, 0.6236]}, {"w": "criterion='mse',", "b": [0.497, 0.6107, 0.632, 0.6236]}, {"w": "max_depth=None,", "b": [0.6404, 0.6107, 0.7669, 0.6236]}, {"w": "max_features=8,", "b": [0.2694, 0.6262, 0.3958, 0.639]}, {"w": "max_leaf_nodes=None,", "b": [0.4043, 0.6262, 0.5729, 0.639]}, {"w": "min_impurity_decrease=0.0,", "b": [0.5814, 0.6262, 0.8006, 0.639]}, {"w": "min_impurity_split=None,", "b": [0.2694, 0.6416, 0.4717, 0.6544]}, {"w": "min_samples_leaf=1,", "b": [0.4802, 0.6416, 0.6404, 0.6544]}, {"w": "min_samples_split=2,", "b": [0.2694, 0.657, 0.438, 0.6699]}, {"w": "min_weight_fraction_leaf=0.0,", "b": [0.4464, 0.657, 0.691, 0.6699]}, {"w": "n_estimators=30,", "b": [0.2694, 0.6724, 0.4043, 0.6853]}, {"w": "n_jobs=None,", "b": [0.4127, 0.6724, 0.5139, 0.6853]}, {"w": "oob_score=False,", "b": [0.5223, 0.6724, 0.6572, 0.6853]}, {"w": "random_state=None,", "b": [0.6657, 0.6724, 0.8175, 0.6853]}, {"w": "verbose=0,", "b": [0.2694, 0.6878, 0.3537, 0.7007]}, {"w": "warm_start=False)", "b": [0.3621, 0.6878, 0.5055, 0.7007]}]}, {"id": "b_7", "type": "paragraph", "text": "If GridSearchCV is initialized with refit=True (which is the default), then once it finds the best estimator using cross- validation, it retrains it on the whole training set. This is usually a good idea since feeding it more data will likely improve its perfor‐ mance.", "words": [{"w": "If", "b": [0.2714, 0.7231, 0.2835, 0.7427]}, {"w": "GridSearchCV", "b": [0.295, 0.726, 0.4036, 0.7398]}, {"w": "is", "b": [0.415, 0.7231, 0.4271, 0.7427]}, {"w": "initialized", "b": [0.4386, 0.7231, 0.5145, 0.7427]}, {"w": "with", "b": [0.526, 0.7231, 0.5601, 0.7427]}, {"w": "refit=True", "b": [0.5716, 0.726, 0.662, 0.7398]}, {"w": "(which", "b": [0.6735, 0.7231, 0.7266, 0.7427]}, {"w": "is", "b": [0.7381, 0.7231, 0.7502, 0.7427]}, {"w": "the", "b": [0.7616, 0.7231, 0.7857, 0.7427]}, {"w": "default),", "b": [0.2714, 0.7405, 0.3349, 0.7601]}, {"w": "then", "b": [0.3479, 0.7405, 0.3824, 0.7601]}, {"w": "once", "b": [0.3954, 0.7405, 0.4316, 0.7601]}, {"w": "it", "b": [0.4446, 0.7405, 0.4556, 0.7601]}, {"w": "finds", "b": [0.4685, 0.7405, 0.5068, 0.7601]}, {"w": "the", "b": [0.5198, 0.7405, 0.5438, 0.7601]}, {"w": "best", "b": [0.5568, 0.7405, 0.5874, 0.7601]}, {"w": "estimator", "b": [0.6004, 0.7405, 0.6726, 0.7601]}, {"w": "using", "b": [0.6856, 0.7405, 0.7271, 0.7601]}, {"w": "cross-", "b": [0.7401, 0.7405, 0.7857, 0.7601]}, {"w": "validation,", "b": [0.2714, 0.758, 0.352, 0.7775]}, {"w": "it", "b": [0.3576, 0.758, 0.3685, 0.7775]}, {"w": "retrains", "b": [0.3742, 0.758, 0.4331, 0.7775]}, {"w": "it", "b": [0.4388, 0.758, 0.4497, 0.7775]}, {"w": "on", "b": [0.4554, 0.758, 0.4755, 0.7775]}, {"w": "the", "b": [0.4812, 0.758, 0.5053, 0.7775]}, {"w": "whole", "b": [0.5109, 0.758, 0.5568, 0.7775]}, {"w": "training", "b": [0.5625, 0.758, 0.6237, 0.7775]}, {"w": "set.", "b": [0.6293, 0.758, 0.6546, 0.7775]}, {"w": "This", "b": [0.6603, 0.758, 0.6943, 0.7775]}, {"w": "is", "b": [0.6999, 0.758, 0.712, 0.7775]}, {"w": "usually", "b": [0.7177, 0.758, 0.7717, 0.7775]}, {"w": "a", "b": [0.7773, 0.758, 0.7857, 0.7775]}, {"w": "good", "b": [0.2714, 0.7754, 0.3098, 0.7949]}, {"w": "idea", "b": [0.3153, 0.7754, 0.3469, 0.7949]}, {"w": "since", "b": [0.3524, 0.7754, 0.3911, 0.7949]}, {"w": "feeding", "b": [0.3966, 0.7754, 0.4529, 0.7949]}, {"w": "it", "b": [0.4584, 0.7754, 0.4694, 0.7949]}, {"w": "more", "b": [0.4749, 0.7754, 0.5153, 0.7949]}, {"w": "data", "b": [0.5209, 0.7754, 0.5531, 0.7949]}, {"w": "will", "b": [0.5586, 0.7754, 0.5864, 0.7949]}, {"w": "likely", "b": [0.5919, 0.7754, 0.6329, 0.7949]}, {"w": "improve", "b": [0.6384, 0.7754, 0.7024, 0.7949]}, {"w": "its", "b": [0.708, 0.7754, 0.7259, 0.7949]}, {"w": "perfor‐", "b": [0.7314, 0.7754, 0.7857, 0.7949]}, {"w": "mance.", "b": [0.2714, 0.7928, 0.3263, 0.8124]}]}, {"id": "b_8", "type": "paragraph", "text": "And of course the evaluation scores are also available:", "words": [{"w": "And", "b": [0.1428, 0.8327, 0.1796, 0.8541]}, {"w": "of", "b": [0.1844, 0.8327, 0.2012, 0.8541]}, {"w": "course", "b": [0.2059, 0.8327, 0.2606, 0.8541]}, {"w": "the", "b": [0.2653, 0.8327, 0.2917, 0.8541]}, {"w": "evaluation", "b": [0.2964, 0.8327, 0.3831, 0.8541]}, {"w": "scores", "b": [0.3878, 0.8327, 0.4391, 0.8541]}, {"w": "are", "b": [0.4439, 0.8327, 0.4696, 0.8541]}, {"w": "also", "b": [0.4743, 0.8327, 0.507, 0.8541]}, {"w": "available:", "b": [0.5117, 0.8327, 0.5888, 0.8541]}]}, {"id": "b_9", "type": "paragraph", "text": ">>> cvres = grid_search.cv_results_ >>> for mean_score, params in zip(cvres[\"mean_test_score\"], cvres[\"params\"]):", "words": [{"w": ">>>", "b": [0.1766, 0.8646, 0.2019, 0.8775]}, {"w": "cvres", "b": [0.2103, 0.8646, 0.2525, 0.8775]}, {"w": "=", "b": [0.2609, 0.8646, 0.2693, 0.8775]}, {"w": "grid_search.cv_results_", "b": [0.2778, 0.8646, 0.4717, 0.8775]}, {"w": ">>>", "b": [0.1766, 0.88, 0.2019, 0.8929]}, {"w": "for", "b": [0.2103, 0.88, 0.2356, 0.8929]}, {"w": "mean_score,", "b": [0.244, 0.88, 0.3368, 0.8929]}, {"w": "params", "b": [0.3452, 0.88, 0.3958, 0.8929]}, {"w": "in", "b": [0.4043, 0.88, 0.4211, 0.8929]}, {"w": "zip(cvres[\"mean_test_score\"],", "b": [0.4296, 0.88, 0.6741, 0.8929]}, {"w": "cvres[\"params\"]):", "b": [0.6825, 0.88, 0.8259, 0.8929]}]}, {"id": "b_10", "type": "equation", "text": "80 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "80", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.478, 0.9388]}]}]}, {"page": 107, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "... print(np.sqrt(-mean_score), params) ... 63669.05791727153 {'max_features': 2, 'n_estimators': 3} 55627.16171305252 {'max_features': 2, 'n_estimators': 10} 53384.57867637289 {'max_features': 2, 'n_estimators': 30} 60965.99185930139 {'max_features': 4, 'n_estimators': 3} 52740.98248528835 {'max_features': 4, 'n_estimators': 10} 50377.344409590376 {'max_features': 4, 'n_estimators': 30} 58663.84733372485 {'max_features': 6, 'n_estimators': 3} 52006.15355973719 {'max_features': 6, 'n_estimators': 10} 50146.465964159885 {'max_features': 6, 'n_estimators': 30} 57869.25504027614 {'max_features': 8, 'n_estimators': 3} 51711.09443660957 {'max_features': 8, 'n_estimators': 10} 49682.25345942335 {'max_features': 8, 'n_estimators': 30} 62895.088889905004 {'bootstrap': False, 'max_features': 2, 'n_estimators': 3} 54658.14484390074 {'bootstrap': False, 'max_features': 2, 'n_estimators': 10} 59470.399594730654 {'bootstrap': False, 'max_features': 3, 'n_estimators': 3} 52725.01091081235 {'bootstrap': False, 'max_features': 3, 'n_estimators': 10} 57490.612956065226 {'bootstrap': False, 'max_features': 4, 'n_estimators': 3} 51009.51445842374 {'bootstrap': False, 'max_features': 4, 'n_estimators': 10}", "words": [{"w": "...", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "print(np.sqrt(-mean_score),", "b": [0.244, 0.0829, 0.4717, 0.0958]}, {"w": "params)", "b": [0.4802, 0.0829, 0.5392, 0.0958]}, {"w": "...", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "63669.05791727153", "b": [0.1766, 0.1138, 0.3199, 0.1266]}, {"w": "{'max_features':", "b": [0.3284, 0.1138, 0.4633, 0.1266]}, {"w": "2,", "b": [0.4717, 0.1138, 0.4886, 0.1266]}, {"w": "'n_estimators':", "b": [0.497, 0.1138, 0.6235, 0.1266]}, {"w": "3}", "b": [0.6319, 0.1138, 0.6488, 0.1266]}, {"w": "55627.16171305252", "b": [0.1766, 0.1292, 0.3199, 0.142]}, {"w": "{'max_features':", "b": [0.3284, 0.1292, 0.4633, 0.142]}, {"w": "2,", "b": [0.4717, 0.1292, 0.4886, 0.142]}, {"w": "'n_estimators':", "b": [0.497, 0.1292, 0.6235, 0.142]}, {"w": "10}", "b": [0.6319, 0.1292, 0.6572, 0.142]}, {"w": "53384.57867637289", "b": [0.1766, 0.1446, 0.3199, 0.1574]}, {"w": "{'max_features':", "b": [0.3284, 0.1446, 0.4633, 0.1574]}, {"w": "2,", "b": [0.4717, 0.1446, 0.4886, 0.1574]}, {"w": "'n_estimators':", "b": [0.497, 0.1446, 0.6235, 0.1574]}, {"w": "30}", "b": [0.6319, 0.1446, 0.6572, 0.1574]}, {"w": "60965.99185930139", "b": [0.1766, 0.16, 0.3199, 0.1729]}, {"w": "{'max_features':", "b": [0.3284, 0.16, 0.4633, 0.1729]}, {"w": "4,", "b": [0.4717, 0.16, 0.4886, 0.1729]}, {"w": "'n_estimators':", "b": [0.497, 0.16, 0.6235, 0.1729]}, {"w": "3}", "b": [0.6319, 0.16, 0.6488, 0.1729]}, {"w": "52740.98248528835", "b": [0.1766, 0.1754, 0.3199, 0.1883]}, {"w": "{'max_features':", "b": [0.3284, 0.1754, 0.4633, 0.1883]}, {"w": "4,", "b": [0.4717, 0.1754, 0.4886, 0.1883]}, {"w": "'n_estimators':", "b": [0.497, 0.1754, 0.6235, 0.1883]}, {"w": "10}", "b": [0.6319, 0.1754, 0.6572, 0.1883]}, {"w": "50377.344409590376", "b": [0.1766, 0.1909, 0.3284, 0.2037]}, {"w": "{'max_features':", "b": [0.3368, 0.1909, 0.4717, 0.2037]}, {"w": "4,", "b": [0.4802, 0.1909, 0.497, 0.2037]}, {"w": "'n_estimators':", "b": [0.5055, 0.1909, 0.6319, 0.2037]}, {"w": "30}", "b": [0.6404, 0.1909, 0.6657, 0.2037]}, {"w": "58663.84733372485", "b": [0.1766, 0.2063, 0.3199, 0.2191]}, {"w": "{'max_features':", "b": [0.3284, 0.2063, 0.4633, 0.2191]}, {"w": "6,", "b": [0.4717, 0.2063, 0.4886, 0.2191]}, {"w": "'n_estimators':", "b": [0.497, 0.2063, 0.6235, 0.2191]}, {"w": "3}", "b": [0.6319, 0.2063, 0.6488, 0.2191]}, {"w": "52006.15355973719", "b": [0.1766, 0.2217, 0.3199, 0.2345]}, {"w": "{'max_features':", "b": [0.3284, 0.2217, 0.4633, 0.2345]}, {"w": "6,", "b": [0.4717, 0.2217, 0.4886, 0.2345]}, {"w": "'n_estimators':", "b": [0.497, 0.2217, 0.6235, 0.2345]}, {"w": "10}", "b": [0.6319, 0.2217, 0.6572, 0.2345]}, {"w": "50146.465964159885", "b": [0.1766, 0.2371, 0.3284, 0.25]}, {"w": "{'max_features':", "b": [0.3368, 0.2371, 0.4717, 0.25]}, {"w": "6,", "b": [0.4802, 0.2371, 0.497, 0.25]}, {"w": "'n_estimators':", "b": [0.5055, 0.2371, 0.6319, 0.25]}, {"w": "30}", "b": [0.6404, 0.2371, 0.6657, 0.25]}, {"w": "57869.25504027614", "b": [0.1766, 0.2525, 0.3199, 0.2654]}, {"w": "{'max_features':", "b": [0.3284, 0.2525, 0.4633, 0.2654]}, {"w": "8,", "b": [0.4717, 0.2525, 0.4886, 0.2654]}, {"w": "'n_estimators':", "b": [0.497, 0.2525, 0.6235, 0.2654]}, {"w": "3}", "b": [0.6319, 0.2525, 0.6488, 0.2654]}, {"w": "51711.09443660957", "b": [0.1766, 0.268, 0.3199, 0.2808]}, {"w": "{'max_features':", "b": [0.3284, 0.268, 0.4633, 0.2808]}, {"w": "8,", "b": [0.4717, 0.268, 0.4886, 0.2808]}, {"w": "'n_estimators':", "b": [0.497, 0.268, 0.6235, 0.2808]}, {"w": "10}", "b": [0.6319, 0.268, 0.6572, 0.2808]}, {"w": "49682.25345942335", "b": [0.1766, 0.2834, 0.3199, 0.2962]}, {"w": "{'max_features':", "b": [0.3284, 0.2834, 0.4633, 0.2962]}, {"w": "8,", "b": [0.4717, 0.2834, 0.4886, 0.2962]}, {"w": "'n_estimators':", "b": [0.497, 0.2834, 0.6235, 0.2962]}, {"w": "30}", "b": [0.6319, 0.2834, 0.6572, 0.2962]}, {"w": "62895.088889905004", "b": [0.1766, 0.2988, 0.3284, 0.3116]}, {"w": "{'bootstrap':", "b": [0.3368, 0.2988, 0.4464, 0.3116]}, {"w": "False,", "b": [0.4549, 0.2988, 0.5055, 0.3116]}, {"w": "'max_features':", "b": [0.5139, 0.2988, 0.6404, 0.3116]}, {"w": "2,", "b": [0.6488, 0.2988, 0.6657, 0.3116]}, {"w": "'n_estimators':", "b": [0.6741, 0.2988, 0.8006, 0.3116]}, {"w": "3}", "b": [0.809, 0.2988, 0.8259, 0.3116]}, {"w": "54658.14484390074", "b": [0.1766, 0.3142, 0.3199, 0.3271]}, {"w": "{'bootstrap':", "b": [0.3284, 0.3142, 0.438, 0.3271]}, {"w": "False,", "b": [0.4464, 0.3142, 0.497, 0.3271]}, {"w": "'max_features':", "b": [0.5055, 0.3142, 0.6319, 0.3271]}, {"w": "2,", "b": [0.6404, 0.3142, 0.6572, 0.3271]}, {"w": "'n_estimators':", "b": [0.6657, 0.3142, 0.7922, 0.3271]}, {"w": "10}", "b": [0.8006, 0.3142, 0.8259, 0.3271]}, {"w": "59470.399594730654", "b": [0.1766, 0.3296, 0.3284, 0.3425]}, {"w": "{'bootstrap':", "b": [0.3368, 0.3296, 0.4464, 0.3425]}, {"w": "False,", "b": [0.4549, 0.3296, 0.5055, 0.3425]}, {"w": "'max_features':", "b": [0.5139, 0.3296, 0.6404, 0.3425]}, {"w": "3,", "b": [0.6488, 0.3296, 0.6657, 0.3425]}, {"w": "'n_estimators':", "b": [0.6741, 0.3296, 0.8006, 0.3425]}, {"w": "3}", "b": [0.809, 0.3296, 0.8259, 0.3425]}, {"w": "52725.01091081235", "b": [0.1766, 0.345, 0.3199, 0.3579]}, {"w": "{'bootstrap':", "b": [0.3284, 0.345, 0.438, 0.3579]}, {"w": "False,", "b": [0.4464, 0.345, 0.497, 0.3579]}, {"w": "'max_features':", "b": [0.5055, 0.345, 0.6319, 0.3579]}, {"w": "3,", "b": [0.6404, 0.345, 0.6572, 0.3579]}, {"w": "'n_estimators':", "b": [0.6657, 0.345, 0.7922, 0.3579]}, {"w": "10}", "b": [0.8006, 0.345, 0.8259, 0.3579]}, {"w": "57490.612956065226", "b": [0.1766, 0.3605, 0.3284, 0.3733]}, {"w": "{'bootstrap':", "b": [0.3368, 0.3605, 0.4464, 0.3733]}, {"w": "False,", "b": [0.4549, 0.3605, 0.5055, 0.3733]}, {"w": "'max_features':", "b": [0.5139, 0.3605, 0.6404, 0.3733]}, {"w": "4,", "b": [0.6488, 0.3605, 0.6657, 0.3733]}, {"w": "'n_estimators':", "b": [0.6741, 0.3605, 0.8006, 0.3733]}, {"w": "3}", "b": [0.809, 0.3605, 0.8259, 0.3733]}, {"w": "51009.51445842374", "b": [0.1766, 0.3759, 0.3199, 0.3887]}, {"w": "{'bootstrap':", "b": [0.3284, 0.3759, 0.438, 0.3887]}, {"w": "False,", "b": [0.4464, 0.3759, 0.497, 0.3887]}, {"w": "'max_features':", "b": [0.5055, 0.3759, 0.6319, 0.3887]}, {"w": "4,", "b": [0.6404, 0.3759, 0.6572, 0.3887]}, {"w": "'n_estimators':", "b": [0.6657, 0.3759, 0.7922, 0.3887]}, {"w": "10}", "b": [0.8006, 0.3759, 0.8259, 0.3887]}]}, {"id": "b_1", "type": "paragraph", "text": "In this example, we obtain the best solution by setting the max_features hyperpara‐ meter to 8, and the n_estimators hyperparameter to 30. The RMSE score for this combination is 49,682, which is slightly better than the score you got earlier using the default hyperparameter values (which was 50,182). Congratulations, you have suc‐ cessfully fine-tuned your best model!", "words": [{"w": "In", "b": [0.1429, 0.3974, 0.1614, 0.4188]}, {"w": "this", "b": [0.1674, 0.3974, 0.1981, 0.4188]}, {"w": "example,", "b": [0.2041, 0.3974, 0.2784, 0.4188]}, {"w": "we", "b": [0.2845, 0.3974, 0.3076, 0.4188]}, {"w": "obtain", "b": [0.3136, 0.3974, 0.3673, 0.4188]}, {"w": "the", "b": [0.3733, 0.3974, 0.3997, 0.4188]}, {"w": "best", "b": [0.4057, 0.3974, 0.4391, 0.4188]}, {"w": "solution", "b": [0.4452, 0.3974, 0.5137, 0.4188]}, {"w": "by", "b": [0.5198, 0.3974, 0.5399, 0.4188]}, {"w": "setting", "b": [0.546, 0.3974, 0.6019, 0.4188]}, {"w": "the", "b": [0.6079, 0.3974, 0.6343, 0.4188]}, {"w": "max_features", "b": [0.6403, 0.4006, 0.759, 0.4157]}, {"w": "hyperpara‐", "b": [0.7651, 0.3974, 0.8571, 0.4188]}, {"w": "meter", "b": [0.1429, 0.4174, 0.1917, 0.4388]}, {"w": "to", "b": [0.1992, 0.4174, 0.2162, 0.4388]}, {"w": "8,", "b": [0.2237, 0.4174, 0.2383, 0.4388]}, {"w": "and", "b": [0.2458, 0.4174, 0.2773, 0.4388]}, {"w": "the", "b": [0.2848, 0.4174, 0.3111, 0.4388]}, {"w": "n_estimators", "b": [0.3186, 0.4205, 0.4374, 0.4356]}, {"w": "hyperparameter", "b": [0.4448, 0.4174, 0.5783, 0.4388]}, {"w": "to", "b": [0.5858, 0.4174, 0.6028, 0.4388]}, {"w": "30.", "b": [0.6103, 0.4174, 0.6348, 0.4388]}, {"w": "The", "b": [0.6423, 0.4174, 0.6751, 0.4388]}, {"w": "RMSE", "b": [0.6826, 0.4174, 0.7358, 0.4388]}, {"w": "score", "b": [0.7433, 0.4174, 0.787, 0.4388]}, {"w": "for", "b": [0.7944, 0.4174, 0.819, 0.4388]}, {"w": "this", "b": [0.8264, 0.4174, 0.8572, 0.4388]}, {"w": "combination", "b": [0.1429, 0.4364, 0.2496, 0.4578]}, {"w": "is", "b": [0.2547, 0.4364, 0.2679, 0.4578]}, {"w": "49,682,", "b": [0.273, 0.4364, 0.3325, 0.4578]}, {"w": "which", "b": [0.3375, 0.4364, 0.3884, 0.4578]}, {"w": "is", "b": [0.3935, 0.4364, 0.4067, 0.4578]}, {"w": "slightly", "b": [0.4118, 0.4364, 0.472, 0.4578]}, {"w": "better", "b": [0.477, 0.4364, 0.5257, 0.4578]}, {"w": "than", "b": [0.5308, 0.4364, 0.5688, 0.4578]}, {"w": "the", "b": [0.5739, 0.4364, 0.6002, 0.4578]}, {"w": "score", "b": [0.6053, 0.4364, 0.6489, 0.4578]}, {"w": "you", "b": [0.654, 0.4364, 0.6852, 0.4578]}, {"w": "got", "b": [0.6903, 0.4364, 0.717, 0.4578]}, {"w": "earlier", "b": [0.7221, 0.4364, 0.7753, 0.4578]}, {"w": "using", "b": [0.7803, 0.4364, 0.8258, 0.4578]}, {"w": "the", "b": [0.8308, 0.4364, 0.8571, 0.4578]}, {"w": "default", "b": [0.1429, 0.4555, 0.2003, 0.4769]}, {"w": "hyperparameter", "b": [0.2082, 0.4555, 0.3417, 0.4769]}, {"w": "values", "b": [0.3497, 0.4555, 0.4013, 0.4769]}, {"w": "(which", "b": [0.4092, 0.4555, 0.4673, 0.4769]}, {"w": "was", "b": [0.4753, 0.4555, 0.5063, 0.4769]}, {"w": "50,182).", "b": [0.5143, 0.4555, 0.581, 0.4769]}, {"w": "Congratulations,", "b": [0.5889, 0.4555, 0.7288, 0.4769]}, {"w": "you", "b": [0.7367, 0.4555, 0.768, 0.4769]}, {"w": "have", "b": [0.7759, 0.4555, 0.8143, 0.4769]}, {"w": "suc‐", "b": [0.8222, 0.4555, 0.8571, 0.4769]}, {"w": "cessfully", "b": [0.1428, 0.4745, 0.2131, 0.4959]}, {"w": "fine-tuned", "b": [0.2179, 0.4745, 0.306, 0.4959]}, {"w": "your", "b": [0.3107, 0.4745, 0.3497, 0.4959]}, {"w": "best", "b": [0.3544, 0.4745, 0.3878, 0.4959]}, {"w": "model!", "b": [0.3926, 0.4745, 0.4511, 0.4959]}]}, {"id": "b_2", "type": "paragraph", "text": "Don’t forget that you can treat some of the data preparation steps as hyperparameters. For example, the grid search will automatically find out whether or not to add a feature you were not sure about (e.g., using the add_bedrooms_per_room hyperparameter of your CombinedAttributesAdder transformer). It may similarly be used to automatically find the best way to handle outliers, missing fea‐ tures, feature selection, and more.", "words": [{"w": "Don’t", "b": [0.2714, 0.5164, 0.3134, 0.536]}, {"w": "forget", "b": [0.3177, 0.5164, 0.3629, 0.536]}, {"w": "that", "b": [0.3673, 0.5164, 0.3971, 0.536]}, {"w": "you", "b": [0.4014, 0.5164, 0.43, 0.536]}, {"w": "can", "b": [0.4343, 0.5164, 0.4611, 0.536]}, {"w": "treat", "b": [0.4654, 0.5164, 0.5002, 0.536]}, {"w": "some", "b": [0.5045, 0.5164, 0.5449, 0.536]}, {"w": "of", "b": [0.5493, 0.5164, 0.5646, 0.536]}, {"w": "the", "b": [0.5689, 0.5164, 0.593, 0.536]}, {"w": "data", "b": [0.5973, 0.5164, 0.6296, 0.536]}, {"w": "preparation", "b": [0.6339, 0.5164, 0.7235, 0.536]}, {"w": "steps", "b": [0.7278, 0.5164, 0.7657, 0.536]}, {"w": "as", "b": [0.77, 0.5164, 0.7854, 0.536]}, {"w": "hyperparameters.", "b": [0.2714, 0.5339, 0.4048, 0.5534]}, {"w": "For", "b": [0.4122, 0.5339, 0.4387, 0.5534]}, {"w": "example,", "b": [0.4461, 0.5339, 0.514, 0.5534]}, {"w": "the", "b": [0.5214, 0.5339, 0.5455, 0.5534]}, {"w": "grid", "b": [0.5529, 0.5339, 0.584, 0.5534]}, {"w": "search", "b": [0.5914, 0.5339, 0.6402, 0.5534]}, {"w": "will", "b": [0.6476, 0.5339, 0.6754, 0.5534]}, {"w": "automatically", "b": [0.6828, 0.5339, 0.7857, 0.5534]}, {"w": "find", "b": [0.2714, 0.5513, 0.3026, 0.5709]}, {"w": "out", "b": [0.3088, 0.5513, 0.3344, 0.5709]}, {"w": "whether", "b": [0.3406, 0.5513, 0.4031, 0.5709]}, {"w": "or", "b": [0.4093, 0.5513, 0.426, 0.5709]}, {"w": "not", "b": [0.4322, 0.5513, 0.4582, 0.5709]}, {"w": "to", "b": [0.4643, 0.5513, 0.4799, 0.5709]}, {"w": "add", "b": [0.486, 0.5513, 0.5145, 0.5709]}, {"w": "a", "b": [0.5207, 0.5513, 0.5291, 0.5709]}, {"w": "feature", "b": [0.5352, 0.5513, 0.5881, 0.5709]}, {"w": "you", "b": [0.5942, 0.5513, 0.6228, 0.5709]}, {"w": "were", "b": [0.629, 0.5513, 0.6653, 0.5709]}, {"w": "not", "b": [0.6715, 0.5513, 0.6974, 0.5709]}, {"w": "sure", "b": [0.7036, 0.5513, 0.7359, 0.5709]}, {"w": "about", "b": [0.742, 0.5513, 0.7857, 0.5709]}, {"w": "(e.g.,", "b": [0.2714, 0.5695, 0.308, 0.5891]}, {"w": "using", "b": [0.3162, 0.5695, 0.3577, 0.5891]}, {"w": "the", "b": [0.3659, 0.5695, 0.39, 0.5891]}, {"w": "add_bedrooms_per_room", "b": [0.3982, 0.5724, 0.5882, 0.5862]}, {"w": "hyperparameter", "b": [0.5963, 0.5695, 0.7184, 0.5891]}, {"w": "of", "b": [0.7266, 0.5695, 0.7419, 0.5891]}, {"w": "your", "b": [0.7501, 0.5695, 0.7857, 0.5891]}, {"w": "CombinedAttributesAdder", "b": [0.2714, 0.5907, 0.4795, 0.6044]}, {"w": "transformer).", "b": [0.4862, 0.5877, 0.5889, 0.6073]}, {"w": "It", "b": [0.5956, 0.5877, 0.6071, 0.6073]}, {"w": "may", "b": [0.6138, 0.5877, 0.6461, 0.6073]}, {"w": "similarly", "b": [0.6528, 0.5877, 0.7194, 0.6073]}, {"w": "be", "b": [0.726, 0.5877, 0.7438, 0.6073]}, {"w": "used", "b": [0.7505, 0.5877, 0.7857, 0.6073]}, {"w": "to", "b": [0.2714, 0.6052, 0.2869, 0.6247]}, {"w": "automatically", "b": [0.2932, 0.6052, 0.3961, 0.6247]}, {"w": "find", "b": [0.4024, 0.6052, 0.4336, 0.6247]}, {"w": "the", "b": [0.4399, 0.6052, 0.464, 0.6247]}, {"w": "best", "b": [0.4702, 0.6052, 0.5008, 0.6247]}, {"w": "way", "b": [0.5071, 0.6052, 0.5369, 0.6247]}, {"w": "to", "b": [0.5432, 0.6052, 0.5587, 0.6247]}, {"w": "handle", "b": [0.5649, 0.6052, 0.6169, 0.6247]}, {"w": "outliers,", "b": [0.6231, 0.6052, 0.6852, 0.6247]}, {"w": "missing", "b": [0.6914, 0.6052, 0.7506, 0.6247]}, {"w": "fea‐", "b": [0.7568, 0.6052, 0.7857, 0.6247]}, {"w": "tures,", "b": [0.2714, 0.6226, 0.3138, 0.6422]}, {"w": "feature", "b": [0.3182, 0.6226, 0.371, 0.6422]}, {"w": "selection,", "b": [0.3753, 0.6226, 0.4467, 0.6422]}, {"w": "and", "b": [0.4511, 0.6226, 0.4799, 0.6422]}, {"w": "more.", "b": [0.4842, 0.6226, 0.529, 0.6422]}]}, {"id": "b_3", "type": "paragraph", "text": "Randomized Search", "words": [{"w": "Randomized", "b": [0.1429, 0.6597, 0.2718, 0.6883]}, {"w": "Search", "b": [0.2767, 0.6597, 0.3452, 0.6883]}]}, {"id": "b_4", "type": "paragraph", "text": "The grid search approach is fine when you are exploring relatively few combinations, like in the previous example, but when the hyperparameter search space is large, it is often preferable to use RandomizedSearchCV instead. This class can be used in much the same way as the GridSearchCV class, but instead of trying out all possible combi‐ nations, it evaluates a given number of random combinations by selecting a random value for each hyperparameter at every iteration. This approach has two main bene‐ fits:", "words": [{"w": "The", "b": [0.1429, 0.6942, 0.1757, 0.7156]}, {"w": "grid", "b": [0.181, 0.6942, 0.2151, 0.7156]}, {"w": "search", "b": [0.2204, 0.6942, 0.2737, 0.7156]}, {"w": "approach", "b": [0.279, 0.6942, 0.3571, 0.7156]}, {"w": "is", "b": [0.3624, 0.6942, 0.3756, 0.7156]}, {"w": "fine", "b": [0.381, 0.6942, 0.413, 0.7156]}, {"w": "when", "b": [0.4183, 0.6942, 0.4639, 0.7156]}, {"w": "you", "b": [0.4692, 0.6942, 0.5005, 0.7156]}, {"w": "are", "b": [0.5058, 0.6942, 0.5316, 0.7156]}, {"w": "exploring", "b": [0.5369, 0.6942, 0.6168, 0.7156]}, {"w": "relatively", "b": [0.6222, 0.6942, 0.698, 0.7156]}, {"w": "few", "b": [0.7034, 0.6942, 0.7327, 0.7156]}, {"w": "combinations,", "b": [0.738, 0.6942, 0.8571, 0.7156]}, {"w": "like", "b": [0.1429, 0.7132, 0.1729, 0.7346]}, {"w": "in", "b": [0.1789, 0.7132, 0.1958, 0.7346]}, {"w": "the", "b": [0.2018, 0.7132, 0.2281, 0.7346]}, {"w": "previous", "b": [0.2341, 0.7132, 0.3061, 0.7346]}, {"w": "example,", "b": [0.3121, 0.7132, 0.3864, 0.7346]}, {"w": "but", "b": [0.3923, 0.7132, 0.4203, 0.7346]}, {"w": "when", "b": [0.4263, 0.7132, 0.4719, 0.7346]}, {"w": "the", "b": [0.4779, 0.7132, 0.5042, 0.7346]}, {"w": "hyperparameter", "b": [0.5102, 0.7132, 0.6437, 0.7346]}, {"w": "search", "b": [0.6496, 0.713, 0.7004, 0.7346]}, {"w": "space", "b": [0.7064, 0.713, 0.7494, 0.7346]}, {"w": "is", "b": [0.7554, 0.7132, 0.7686, 0.7346]}, {"w": "large,", "b": [0.7746, 0.7132, 0.8201, 0.7346]}, {"w": "it", "b": [0.826, 0.7132, 0.838, 0.7346]}, {"w": "is", "b": [0.8439, 0.7132, 0.8571, 0.7346]}, {"w": "often", "b": [0.1429, 0.7332, 0.1862, 0.7546]}, {"w": "preferable", "b": [0.1922, 0.7332, 0.2763, 0.7546]}, {"w": "to", "b": [0.2823, 0.7332, 0.2993, 0.7546]}, {"w": "use", "b": [0.3052, 0.7332, 0.3328, 0.7546]}, {"w": "RandomizedSearchCV", "b": [0.3388, 0.7363, 0.5169, 0.7514]}, {"w": "instead.", "b": [0.5229, 0.7332, 0.5876, 0.7546]}, {"w": "This", "b": [0.5936, 0.7332, 0.6308, 0.7546]}, {"w": "class", "b": [0.6368, 0.7332, 0.6753, 0.7546]}, {"w": "can", "b": [0.6813, 0.7332, 0.7106, 0.7546]}, {"w": "be", "b": [0.7166, 0.7332, 0.736, 0.7546]}, {"w": "used", "b": [0.742, 0.7332, 0.7805, 0.7546]}, {"w": "in", "b": [0.7865, 0.7332, 0.8035, 0.7546]}, {"w": "much", "b": [0.8095, 0.7332, 0.8571, 0.7546]}, {"w": "the", "b": [0.1429, 0.7531, 0.1692, 0.7745]}, {"w": "same", "b": [0.1747, 0.7531, 0.2174, 0.7745]}, {"w": "way", "b": [0.2229, 0.7531, 0.2555, 0.7745]}, {"w": "as", "b": [0.261, 0.7531, 0.2778, 0.7745]}, {"w": "the", "b": [0.2833, 0.7531, 0.3096, 0.7745]}, {"w": "GridSearchCV", "b": [0.3151, 0.7563, 0.4338, 0.7714]}, {"w": "class,", "b": [0.4393, 0.7531, 0.4826, 0.7745]}, {"w": "but", "b": [0.488, 0.7531, 0.516, 0.7745]}, {"w": "instead", "b": [0.5215, 0.7531, 0.5815, 0.7745]}, {"w": "of", "b": [0.587, 0.7531, 0.6038, 0.7745]}, {"w": "trying", "b": [0.6093, 0.7531, 0.6603, 0.7745]}, {"w": "out", "b": [0.6657, 0.7531, 0.6938, 0.7745]}, {"w": "all", "b": [0.6993, 0.7531, 0.719, 0.7745]}, {"w": "possible", "b": [0.7244, 0.7531, 0.7916, 0.7745]}, {"w": "combi‐", "b": [0.7971, 0.7531, 0.8571, 0.7745]}, {"w": "nations,", "b": [0.1429, 0.7722, 0.2094, 0.7936]}, {"w": "it", "b": [0.2154, 0.7722, 0.2274, 0.7936]}, {"w": "evaluates", "b": [0.2334, 0.7722, 0.309, 0.7936]}, {"w": "a", "b": [0.3151, 0.7722, 0.3242, 0.7936]}, {"w": "given", "b": [0.3303, 0.7722, 0.3755, 0.7936]}, {"w": "number", "b": [0.3815, 0.7722, 0.4478, 0.7936]}, {"w": "of", "b": [0.4539, 0.7722, 0.4707, 0.7936]}, {"w": "random", "b": [0.4767, 0.7722, 0.5437, 0.7936]}, {"w": "combinations", "b": [0.5497, 0.7722, 0.6642, 0.7936]}, {"w": "by", "b": [0.6702, 0.7722, 0.6904, 0.7936]}, {"w": "selecting", "b": [0.6964, 0.7722, 0.7689, 0.7936]}, {"w": "a", "b": [0.775, 0.7722, 0.7841, 0.7936]}, {"w": "random", "b": [0.7902, 0.7722, 0.8572, 0.7936]}, {"w": "value", "b": [0.1429, 0.7912, 0.1868, 0.8126]}, {"w": "for", "b": [0.1929, 0.7912, 0.2175, 0.8126]}, {"w": "each", "b": [0.2236, 0.7912, 0.2615, 0.8126]}, {"w": "hyperparameter", "b": [0.2676, 0.7912, 0.4011, 0.8126]}, {"w": "at", "b": [0.4072, 0.7912, 0.4223, 0.8126]}, {"w": "every", "b": [0.4285, 0.7912, 0.4737, 0.8126]}, {"w": "iteration.", "b": [0.4798, 0.7912, 0.5558, 0.8126]}, {"w": "This", "b": [0.5619, 0.7912, 0.5991, 0.8126]}, {"w": "approach", "b": [0.6052, 0.7912, 0.6832, 0.8126]}, {"w": "has", "b": [0.6894, 0.7912, 0.7173, 0.8126]}, {"w": "two", "b": [0.7234, 0.7912, 0.7546, 0.8126]}, {"w": "main", "b": [0.7607, 0.7912, 0.8039, 0.8126]}, {"w": "bene‐", "b": [0.81, 0.7912, 0.8571, 0.8126]}, {"w": "fits:", "b": [0.1429, 0.8102, 0.1734, 0.8317]}]}, {"id": "b_5", "type": "equation", "text": "Fine-Tune Your Model | 81", "words": [{"w": "Fine-Tune", "b": [0.6747, 0.9225, 0.7337, 0.9388]}, {"w": "Your", "b": [0.7366, 0.9225, 0.7635, 0.9388]}, {"w": "Model", "b": [0.7663, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "81", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 108, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• If you let the randomized search run for, say, 1,000 iterations, this approach will explore 1,000 different values for each hyperparameter (instead of just a few val‐ ues per hyperparameter with the grid search approach).", "words": [{"w": "•", "b": [0.16, 0.0851, 0.1682, 0.1065]}, {"w": "If", "b": [0.1786, 0.0851, 0.1918, 0.1065]}, {"w": "you", "b": [0.1978, 0.0851, 0.2291, 0.1065]}, {"w": "let", "b": [0.2351, 0.0851, 0.2556, 0.1065]}, {"w": "the", "b": [0.2615, 0.0851, 0.2879, 0.1065]}, {"w": "randomized", "b": [0.2939, 0.0851, 0.395, 0.1065]}, {"w": "search", "b": [0.401, 0.0851, 0.4543, 0.1065]}, {"w": "run", "b": [0.4603, 0.0851, 0.4905, 0.1065]}, {"w": "for,", "b": [0.4965, 0.0851, 0.5245, 0.1065]}, {"w": "say,", "b": [0.5305, 0.0851, 0.5597, 0.1065]}, {"w": "1,000", "b": [0.5657, 0.0851, 0.6104, 0.1065]}, {"w": "iterations,", "b": [0.6164, 0.0851, 0.7, 0.1065]}, {"w": "this", "b": [0.706, 0.0851, 0.7367, 0.1065]}, {"w": "approach", "b": [0.7427, 0.0851, 0.8207, 0.1065]}, {"w": "will", "b": [0.8267, 0.0851, 0.8571, 0.1065]}, {"w": "explore", "b": [0.1786, 0.1042, 0.2407, 0.1256]}, {"w": "1,000", "b": [0.2463, 0.1042, 0.2911, 0.1256]}, {"w": "different", "b": [0.2968, 0.1042, 0.3685, 0.1256]}, {"w": "values", "b": [0.3742, 0.1042, 0.4258, 0.1256]}, {"w": "for", "b": [0.4315, 0.1042, 0.456, 0.1256]}, {"w": "each", "b": [0.4617, 0.1042, 0.4996, 0.1256]}, {"w": "hyperparameter", "b": [0.5053, 0.1042, 0.6388, 0.1256]}, {"w": "(instead", "b": [0.6445, 0.1042, 0.7116, 0.1256]}, {"w": "of", "b": [0.7173, 0.1042, 0.7341, 0.1256]}, {"w": "just", "b": [0.7398, 0.1042, 0.7702, 0.1256]}, {"w": "a", "b": [0.7759, 0.1042, 0.785, 0.1256]}, {"w": "few", "b": [0.7907, 0.1042, 0.82, 0.1256]}, {"w": "val‐", "b": [0.8257, 0.1042, 0.8571, 0.1256]}, {"w": "ues", "b": [0.1786, 0.1232, 0.2061, 0.1446]}, {"w": "per", "b": [0.2109, 0.1232, 0.2384, 0.1446]}, {"w": "hyperparameter", "b": [0.2431, 0.1232, 0.3766, 0.1446]}, {"w": "with", "b": [0.3813, 0.1232, 0.4186, 0.1446]}, {"w": "the", "b": [0.4234, 0.1232, 0.4497, 0.1446]}, {"w": "grid", "b": [0.4544, 0.1232, 0.4885, 0.1446]}, {"w": "search", "b": [0.4932, 0.1232, 0.5465, 0.1446]}, {"w": "approach).", "b": [0.5513, 0.1232, 0.6412, 0.1446]}]}, {"id": "b_1", "type": "paragraph", "text": "• You have more control over the computing budget you want to allocate to hyper‐ parameter search, simply by setting the number of iterations.", "words": [{"w": "•", "b": [0.16, 0.1483, 0.1682, 0.1697]}, {"w": "You", "b": [0.1786, 0.1483, 0.2109, 0.1697]}, {"w": "have", "b": [0.2161, 0.1483, 0.2545, 0.1697]}, {"w": "more", "b": [0.2596, 0.1483, 0.3039, 0.1697]}, {"w": "control", "b": [0.309, 0.1483, 0.3695, 0.1697]}, {"w": "over", "b": [0.3746, 0.1483, 0.4115, 0.1697]}, {"w": "the", "b": [0.4166, 0.1483, 0.443, 0.1697]}, {"w": "computing", "b": [0.4481, 0.1483, 0.5393, 0.1697]}, {"w": "budget", "b": [0.5444, 0.1483, 0.602, 0.1697]}, {"w": "you", "b": [0.6072, 0.1483, 0.6384, 0.1697]}, {"w": "want", "b": [0.6436, 0.1483, 0.6844, 0.1697]}, {"w": "to", "b": [0.6895, 0.1483, 0.7065, 0.1697]}, {"w": "allocate", "b": [0.7116, 0.1483, 0.7747, 0.1697]}, {"w": "to", "b": [0.7799, 0.1483, 0.7969, 0.1697]}, {"w": "hyper‐", "b": [0.802, 0.1483, 0.8571, 0.1697]}, {"w": "parameter", "b": [0.1786, 0.1673, 0.2644, 0.1888]}, {"w": "search,", "b": [0.2691, 0.1673, 0.3272, 0.1888]}, {"w": "simply", "b": [0.3319, 0.1673, 0.3875, 0.1888]}, {"w": "by", "b": [0.3923, 0.1673, 0.4124, 0.1888]}, {"w": "setting", "b": [0.4171, 0.1673, 0.4731, 0.1888]}, {"w": "the", "b": [0.4778, 0.1673, 0.5041, 0.1888]}, {"w": "number", "b": [0.5089, 0.1673, 0.5752, 0.1888]}, {"w": "of", "b": [0.5799, 0.1673, 0.5967, 0.1888]}, {"w": "iterations.", "b": [0.6014, 0.1673, 0.685, 0.1888]}]}, {"id": "b_2", "type": "paragraph", "text": "Ensemble Methods", "words": [{"w": "Ensemble", "b": [0.1428, 0.2166, 0.2428, 0.2452]}, {"w": "Methods", "b": [0.2477, 0.2166, 0.3377, 0.2452]}]}, {"id": "b_3", "type": "paragraph", "text": "Another way to fine-tune your system is to try to combine the models that perform best. The group (or “ensemble”) will often perform better than the best individual model (just like Random Forests perform better than the individual Decision Trees they rely on), especially if the individual models make very different types of errors. We will cover this topic in more detail in Chapter 7.", "words": [{"w": "Another", "b": [0.1429, 0.2511, 0.2133, 0.2725]}, {"w": "way", "b": [0.2196, 0.2511, 0.2522, 0.2725]}, {"w": "to", "b": [0.2585, 0.2511, 0.2755, 0.2725]}, {"w": "fine-tune", "b": [0.2818, 0.2511, 0.3589, 0.2725]}, {"w": "your", "b": [0.3652, 0.2511, 0.4042, 0.2725]}, {"w": "system", "b": [0.4105, 0.2511, 0.4676, 0.2725]}, {"w": "is", "b": [0.4739, 0.2511, 0.4871, 0.2725]}, {"w": "to", "b": [0.4934, 0.2511, 0.5104, 0.2725]}, {"w": "try", "b": [0.5167, 0.2511, 0.541, 0.2725]}, {"w": "to", "b": [0.5473, 0.2511, 0.5643, 0.2725]}, {"w": "combine", "b": [0.5706, 0.2511, 0.6435, 0.2725]}, {"w": "the", "b": [0.6498, 0.2511, 0.6761, 0.2725]}, {"w": "models", "b": [0.6824, 0.2511, 0.7429, 0.2725]}, {"w": "that", "b": [0.7492, 0.2511, 0.7818, 0.2725]}, {"w": "perform", "b": [0.7881, 0.2511, 0.8571, 0.2725]}, {"w": "best.", "b": [0.1428, 0.2702, 0.181, 0.2916]}, {"w": "The", "b": [0.1888, 0.2702, 0.2217, 0.2916]}, {"w": "group", "b": [0.2295, 0.2702, 0.2795, 0.2916]}, {"w": "(or", "b": [0.2873, 0.2702, 0.3129, 0.2916]}, {"w": "“ensemble”)", "b": [0.3207, 0.2702, 0.4201, 0.2916]}, {"w": "will", "b": [0.4279, 0.2702, 0.4583, 0.2916]}, {"w": "often", "b": [0.4661, 0.2702, 0.5095, 0.2916]}, {"w": "perform", "b": [0.5173, 0.2702, 0.5864, 0.2916]}, {"w": "better", "b": [0.5942, 0.2702, 0.6429, 0.2916]}, {"w": "than", "b": [0.6507, 0.2702, 0.6887, 0.2916]}, {"w": "the", "b": [0.6965, 0.2702, 0.7228, 0.2916]}, {"w": "best", "b": [0.7306, 0.2702, 0.7641, 0.2916]}, {"w": "individual", "b": [0.7719, 0.2702, 0.8571, 0.2916]}, {"w": "model", "b": [0.1429, 0.2892, 0.1957, 0.3106]}, {"w": "(just", "b": [0.2026, 0.2892, 0.2402, 0.3106]}, {"w": "like", "b": [0.2472, 0.2892, 0.2772, 0.3106]}, {"w": "Random", "b": [0.2841, 0.2892, 0.3567, 0.3106]}, {"w": "Forests", "b": [0.3636, 0.2892, 0.4231, 0.3106]}, {"w": "perform", "b": [0.43, 0.2892, 0.4991, 0.3106]}, {"w": "better", "b": [0.5061, 0.2892, 0.5548, 0.3106]}, {"w": "than", "b": [0.5617, 0.2892, 0.5998, 0.3106]}, {"w": "the", "b": [0.6067, 0.2892, 0.633, 0.3106]}, {"w": "individual", "b": [0.64, 0.2892, 0.7252, 0.3106]}, {"w": "Decision", "b": [0.7322, 0.2892, 0.806, 0.3106]}, {"w": "Trees", "b": [0.8129, 0.2892, 0.8571, 0.3106]}, {"w": "they", "b": [0.1429, 0.3083, 0.1788, 0.3297]}, {"w": "rely", "b": [0.1849, 0.3083, 0.2164, 0.3297]}, {"w": "on),", "b": [0.2226, 0.3083, 0.2565, 0.3297]}, {"w": "especially", "b": [0.2627, 0.3083, 0.3427, 0.3297]}, {"w": "if", "b": [0.3489, 0.3083, 0.3606, 0.3297]}, {"w": "the", "b": [0.3668, 0.3083, 0.3931, 0.3297]}, {"w": "individual", "b": [0.3993, 0.3083, 0.4846, 0.3297]}, {"w": "models", "b": [0.4908, 0.3083, 0.5513, 0.3297]}, {"w": "make", "b": [0.5575, 0.3083, 0.6029, 0.3297]}, {"w": "very", "b": [0.6091, 0.3083, 0.6455, 0.3297]}, {"w": "different", "b": [0.6517, 0.3083, 0.7234, 0.3297]}, {"w": "types", "b": [0.7296, 0.3083, 0.7729, 0.3297]}, {"w": "of", "b": [0.7791, 0.3083, 0.7959, 0.3297]}, {"w": "errors.", "b": [0.8021, 0.3083, 0.8571, 0.3297]}, {"w": "We", "b": [0.1428, 0.3273, 0.1699, 0.3487]}, {"w": "will", "b": [0.1746, 0.3273, 0.205, 0.3487]}, {"w": "cover", "b": [0.2098, 0.3273, 0.2554, 0.3487]}, {"w": "this", "b": [0.2602, 0.3273, 0.2909, 0.3487]}, {"w": "topic", "b": [0.2956, 0.3273, 0.3379, 0.3487]}, {"w": "in", "b": [0.3426, 0.3273, 0.3596, 0.3487]}, {"w": "more", "b": [0.3643, 0.3273, 0.4086, 0.3487]}, {"w": "detail", "b": [0.4133, 0.3273, 0.4595, 0.3487]}, {"w": "in", "b": [0.4643, 0.3273, 0.4812, 0.3487]}, {"w": "Chapter", "b": [0.486, 0.3273, 0.5536, 0.3487]}, {"w": "7.", "b": [0.5583, 0.3273, 0.573, 0.3487]}]}, {"id": "b_4", "type": "paragraph", "text": "Analyze the Best Models and Their Errors", "words": [{"w": "Analyze", "b": [0.1429, 0.3615, 0.2238, 0.39]}, {"w": "the", "b": [0.2287, 0.3615, 0.2636, 0.39]}, {"w": "Best", "b": [0.2685, 0.3615, 0.3136, 0.39]}, {"w": "Models", "b": [0.3186, 0.3615, 0.3926, 0.39]}, {"w": "and", "b": [0.3976, 0.3615, 0.4368, 0.39]}, {"w": "Their", "b": [0.4418, 0.3615, 0.4944, 0.39]}, {"w": "Errors", "b": [0.4994, 0.3615, 0.5592, 0.39]}]}, {"id": "b_5", "type": "paragraph", "text": "You will often gain good insights on the problem by inspecting the best models. For example, the RandomForestRegressor can indicate the relative importance of each attribute for making accurate predictions:", "words": [{"w": "You", "b": [0.1429, 0.3959, 0.1752, 0.4174]}, {"w": "will", "b": [0.1813, 0.3959, 0.2117, 0.4174]}, {"w": "often", "b": [0.2179, 0.3959, 0.2613, 0.4174]}, {"w": "gain", "b": [0.2674, 0.3959, 0.3033, 0.4174]}, {"w": "good", "b": [0.3094, 0.3959, 0.3514, 0.4174]}, {"w": "insights", "b": [0.3575, 0.3959, 0.4222, 0.4174]}, {"w": "on", "b": [0.4283, 0.3959, 0.4503, 0.4174]}, {"w": "the", "b": [0.4565, 0.3959, 0.4828, 0.4174]}, {"w": "problem", "b": [0.4889, 0.3959, 0.56, 0.4174]}, {"w": "by", "b": [0.5661, 0.3959, 0.5863, 0.4174]}, {"w": "inspecting", "b": [0.5924, 0.3959, 0.6787, 0.4174]}, {"w": "the", "b": [0.6848, 0.3959, 0.7111, 0.4174]}, {"w": "best", "b": [0.7173, 0.3959, 0.7507, 0.4174]}, {"w": "models.", "b": [0.7568, 0.3959, 0.822, 0.4174]}, {"w": "For", "b": [0.8282, 0.3959, 0.8571, 0.4174]}, {"w": "example,", "b": [0.1428, 0.4159, 0.2171, 0.4373]}, {"w": "the", "b": [0.2251, 0.4159, 0.2515, 0.4373]}, {"w": "RandomForestRegressor", "b": [0.2595, 0.4191, 0.4673, 0.4342]}, {"w": "can", "b": [0.4753, 0.4159, 0.5046, 0.4373]}, {"w": "indicate", "b": [0.5126, 0.4159, 0.579, 0.4373]}, {"w": "the", "b": [0.587, 0.4159, 0.6133, 0.4373]}, {"w": "relative", "b": [0.6213, 0.4159, 0.6823, 0.4373]}, {"w": "importance", "b": [0.6903, 0.4159, 0.7864, 0.4373]}, {"w": "of", "b": [0.7944, 0.4159, 0.8112, 0.4373]}, {"w": "each", "b": [0.8192, 0.4159, 0.8571, 0.4373]}, {"w": "attribute", "b": [0.1429, 0.4349, 0.2145, 0.4563]}, {"w": "for", "b": [0.2192, 0.4349, 0.2437, 0.4563]}, {"w": "making", "b": [0.2485, 0.4349, 0.3117, 0.4563]}, {"w": "accurate", "b": [0.3165, 0.4349, 0.386, 0.4563]}, {"w": "predictions:", "b": [0.3907, 0.4349, 0.49, 0.4563]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> feature_importances = grid_search.best_estimator_.feature_importances_ >>> feature_importances array([7.33442355e-02, 6.29090705e-02, 4.11437985e-02, 1.46726854e-02, 1.41064835e-02, 1.48742809e-02, 1.42575993e-02, 3.66158981e-01, 5.64191792e-02, 1.08792957e-01, 5.33510773e-02, 1.03114883e-02, 1.64780994e-01, 6.02803867e-05, 1.96041560e-03, 2.85647464e-03])", "words": [{"w": ">>>", "b": [0.1766, 0.4669, 0.2019, 0.4798]}, {"w": "feature_importances", "b": [0.2103, 0.4669, 0.3705, 0.4798]}, {"w": "=", "b": [0.379, 0.4669, 0.3874, 0.4798]}, {"w": "grid_search.best_estimator_.feature_importances_", "b": [0.3958, 0.4669, 0.8006, 0.4798]}, {"w": ">>>", "b": [0.1766, 0.4823, 0.2019, 0.4952]}, {"w": "feature_importances", "b": [0.2103, 0.4823, 0.3705, 0.4952]}, {"w": "array([7.33442355e-02,", "b": [0.1766, 0.4977, 0.3621, 0.5106]}, {"w": "6.29090705e-02,", "b": [0.3705, 0.4977, 0.497, 0.5106]}, {"w": "4.11437985e-02,", "b": [0.5054, 0.4977, 0.6319, 0.5106]}, {"w": "1.46726854e-02,", "b": [0.6404, 0.4977, 0.7669, 0.5106]}, {"w": "1.41064835e-02,", "b": [0.2356, 0.5132, 0.3621, 0.526]}, {"w": "1.48742809e-02,", "b": [0.3705, 0.5132, 0.497, 0.526]}, {"w": "1.42575993e-02,", "b": [0.5054, 0.5132, 0.6319, 0.526]}, {"w": "3.66158981e-01,", "b": [0.6404, 0.5132, 0.7669, 0.526]}, {"w": "5.64191792e-02,", "b": [0.2356, 0.5286, 0.3621, 0.5414]}, {"w": "1.08792957e-01,", "b": [0.3705, 0.5286, 0.497, 0.5414]}, {"w": "5.33510773e-02,", "b": [0.5054, 0.5286, 0.6319, 0.5414]}, {"w": "1.03114883e-02,", "b": [0.6404, 0.5286, 0.7669, 0.5414]}, {"w": "1.64780994e-01,", "b": [0.2356, 0.544, 0.3621, 0.5569]}, {"w": "6.02803867e-05,", "b": [0.3705, 0.544, 0.497, 0.5569]}, {"w": "1.96041560e-03,", "b": [0.5054, 0.544, 0.6319, 0.5569]}, {"w": "2.85647464e-03])", "b": [0.6404, 0.544, 0.7753, 0.5569]}]}, {"id": "b_7", "type": "paragraph", "text": "Let’s display these importance scores next to their corresponding attribute names:", "words": [{"w": "Let’s", "b": [0.1429, 0.5646, 0.179, 0.5861]}, {"w": "display", "b": [0.1837, 0.5646, 0.2425, 0.5861]}, {"w": "these", "b": [0.2472, 0.5646, 0.2901, 0.5861]}, {"w": "importance", "b": [0.2948, 0.5646, 0.3909, 0.5861]}, {"w": "scores", "b": [0.3956, 0.5646, 0.4469, 0.5861]}, {"w": "next", "b": [0.4516, 0.5646, 0.4881, 0.5861]}, {"w": "to", "b": [0.4928, 0.5646, 0.5098, 0.5861]}, {"w": "their", "b": [0.5145, 0.5646, 0.5542, 0.5861]}, {"w": "corresponding", "b": [0.5589, 0.5646, 0.681, 0.5861]}, {"w": "attribute", "b": [0.6857, 0.5646, 0.7573, 0.5861]}, {"w": "names:", "b": [0.762, 0.5646, 0.8209, 0.5861]}]}, {"id": "b_8", "type": "paragraph", "text": ">>> extra_attribs = [\"rooms_per_hhold\", \"pop_per_hhold\", \"bedrooms_per_room\"] >>> cat_encoder = full_pipeline.named_transformers_[\"cat\"] >>> cat_one_hot_attribs = list(cat_encoder.categories_[0]) >>> attributes = num_attribs + extra_attribs + cat_one_hot_attribs >>> sorted(zip(feature_importances, attributes), reverse=True) [(0.3661589806181342, 'median_income'), (0.1647809935615905, 'INLAND'), (0.10879295677551573, 'pop_per_hhold'), (0.07334423551601242, 'longitude'), (0.0629090704826203, 'latitude'), (0.05641917918195401, 'rooms_per_hhold'), (0.05335107734767581, 'bedrooms_per_room'), (0.041143798478729635, 'housing_median_age'), (0.014874280890402767, 'population'), (0.014672685420543237, 'total_rooms'), (0.014257599323407807, 'households'), (0.014106483453584102, 'total_bedrooms'), (0.010311488326303787, '<1H OCEAN'), (0.002856474637320158, 'NEAR OCEAN'),", "words": [{"w": ">>>", "b": [0.1766, 0.5966, 0.2019, 0.6095]}, {"w": "extra_attribs", "b": [0.2103, 0.5966, 0.3199, 0.6095]}, {"w": "=", "b": [0.3284, 0.5966, 0.3368, 0.6095]}, {"w": "[\"rooms_per_hhold\",", "b": [0.3452, 0.5966, 0.5054, 0.6095]}, {"w": "\"pop_per_hhold\",", "b": [0.5139, 0.5966, 0.6488, 0.6095]}, {"w": "\"bedrooms_per_room\"]", "b": [0.6572, 0.5966, 0.8259, 0.6095]}, {"w": ">>>", "b": [0.1766, 0.612, 0.2019, 0.6249]}, {"w": "cat_encoder", "b": [0.2103, 0.612, 0.3031, 0.6249]}, {"w": "=", "b": [0.3115, 0.612, 0.3199, 0.6249]}, {"w": "full_pipeline.named_transformers_[\"cat\"]", "b": [0.3284, 0.612, 0.6657, 0.6249]}, {"w": ">>>", "b": [0.1766, 0.6275, 0.2019, 0.6403]}, {"w": "cat_one_hot_attribs", "b": [0.2103, 0.6275, 0.3705, 0.6403]}, {"w": "=", "b": [0.379, 0.6275, 0.3874, 0.6403]}, {"w": "list(cat_encoder.categories_[0])", "b": [0.3958, 0.6275, 0.6657, 0.6403]}, {"w": ">>>", "b": [0.1766, 0.6429, 0.2019, 0.6557]}, {"w": "attributes", "b": [0.2103, 0.6429, 0.2946, 0.6557]}, {"w": "=", "b": [0.3031, 0.6429, 0.3115, 0.6557]}, {"w": "num_attribs", "b": [0.3199, 0.6429, 0.4127, 0.6557]}, {"w": "+", "b": [0.4211, 0.6429, 0.4296, 0.6557]}, {"w": "extra_attribs", "b": [0.438, 0.6429, 0.5476, 0.6557]}, {"w": "+", "b": [0.556, 0.6429, 0.5645, 0.6557]}, {"w": "cat_one_hot_attribs", "b": [0.5729, 0.6429, 0.7331, 0.6557]}, {"w": ">>>", "b": [0.1766, 0.6583, 0.2019, 0.6711]}, {"w": "sorted(zip(feature_importances,", "b": [0.2103, 0.6583, 0.4717, 0.6711]}, {"w": "attributes),", "b": [0.4802, 0.6583, 0.5813, 0.6711]}, {"w": "reverse=True)", "b": [0.5898, 0.6583, 0.6994, 0.6711]}, {"w": "[(0.3661589806181342,", "b": [0.1766, 0.6737, 0.3537, 0.6866]}, {"w": "'median_income'),", "b": [0.3621, 0.6737, 0.5054, 0.6866]}, {"w": "(0.1647809935615905,", "b": [0.185, 0.6891, 0.3537, 0.702]}, {"w": "'INLAND'),", "b": [0.3621, 0.6891, 0.4464, 0.702]}, {"w": "(0.10879295677551573,", "b": [0.185, 0.7046, 0.3621, 0.7174]}, {"w": "'pop_per_hhold'),", "b": [0.3705, 0.7046, 0.5139, 0.7174]}, {"w": "(0.07334423551601242,", "b": [0.185, 0.72, 0.3621, 0.7328]}, {"w": "'longitude'),", "b": [0.3705, 0.72, 0.4802, 0.7328]}, {"w": "(0.0629090704826203,", "b": [0.185, 0.7354, 0.3537, 0.7482]}, {"w": "'latitude'),", "b": [0.3621, 0.7354, 0.4633, 0.7482]}, {"w": "(0.05641917918195401,", "b": [0.185, 0.7508, 0.3621, 0.7637]}, {"w": "'rooms_per_hhold'),", "b": [0.3705, 0.7508, 0.5307, 0.7637]}, {"w": "(0.05335107734767581,", "b": [0.185, 0.7662, 0.3621, 0.7791]}, {"w": "'bedrooms_per_room'),", "b": [0.3705, 0.7662, 0.5476, 0.7791]}, {"w": "(0.041143798478729635,", "b": [0.185, 0.7817, 0.3705, 0.7945]}, {"w": "'housing_median_age'),", "b": [0.379, 0.7817, 0.5645, 0.7945]}, {"w": "(0.014874280890402767,", "b": [0.185, 0.7971, 0.3705, 0.8099]}, {"w": "'population'),", "b": [0.379, 0.7971, 0.497, 0.8099]}, {"w": "(0.014672685420543237,", "b": [0.185, 0.8125, 0.3705, 0.8253]}, {"w": "'total_rooms'),", "b": [0.379, 0.8125, 0.5054, 0.8253]}, {"w": "(0.014257599323407807,", "b": [0.185, 0.8279, 0.3705, 0.8408]}, {"w": "'households'),", "b": [0.379, 0.8279, 0.497, 0.8408]}, {"w": "(0.014106483453584102,", "b": [0.185, 0.8433, 0.3705, 0.8562]}, {"w": "'total_bedrooms'),", "b": [0.379, 0.8433, 0.5307, 0.8562]}, {"w": "(0.010311488326303787,", "b": [0.185, 0.8587, 0.3705, 0.8716]}, {"w": "'<1H", "b": [0.379, 0.8587, 0.4127, 0.8716]}, {"w": "OCEAN'),", "b": [0.4211, 0.8587, 0.4886, 0.8716]}, {"w": "(0.002856474637320158,", "b": [0.185, 0.8742, 0.3705, 0.887]}, {"w": "'NEAR", "b": [0.379, 0.8742, 0.4211, 0.887]}, {"w": "OCEAN'),", "b": [0.4296, 0.8742, 0.497, 0.887]}]}, {"id": "b_9", "type": "equation", "text": "82 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "82", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 109, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "(0.00196041559947807, 'NEAR BAY'), (6.028038672736599e-05, 'ISLAND')]", "words": [{"w": "(0.00196041559947807,", "b": [0.185, 0.0829, 0.3621, 0.0958]}, {"w": "'NEAR", "b": [0.3705, 0.0829, 0.4127, 0.0958]}, {"w": "BAY'),", "b": [0.4211, 0.0829, 0.4717, 0.0958]}, {"w": "(6.028038672736599e-05,", "b": [0.185, 0.0983, 0.379, 0.1112]}, {"w": "'ISLAND')]", "b": [0.3874, 0.0983, 0.4717, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "With this information, you may want to try dropping some of the less useful features (e.g., apparently only one ocean_proximity category is really useful, so you could try dropping the others).", "words": [{"w": "With", "b": [0.1429, 0.119, 0.1853, 0.1404]}, {"w": "this", "b": [0.1907, 0.119, 0.2215, 0.1404]}, {"w": "information,", "b": [0.2269, 0.119, 0.3329, 0.1404]}, {"w": "you", "b": [0.3384, 0.119, 0.3696, 0.1404]}, {"w": "may", "b": [0.3751, 0.119, 0.4105, 0.1404]}, {"w": "want", "b": [0.4159, 0.119, 0.4567, 0.1404]}, {"w": "to", "b": [0.4622, 0.119, 0.4791, 0.1404]}, {"w": "try", "b": [0.4846, 0.119, 0.5088, 0.1404]}, {"w": "dropping", "b": [0.5143, 0.119, 0.5922, 0.1404]}, {"w": "some", "b": [0.5977, 0.119, 0.6418, 0.1404]}, {"w": "of", "b": [0.6473, 0.119, 0.6641, 0.1404]}, {"w": "the", "b": [0.6695, 0.119, 0.6959, 0.1404]}, {"w": "less", "b": [0.7013, 0.119, 0.7308, 0.1404]}, {"w": "useful", "b": [0.7362, 0.119, 0.7863, 0.1404]}, {"w": "features", "b": [0.7917, 0.119, 0.8571, 0.1404]}, {"w": "(e.g.,", "b": [0.1429, 0.1389, 0.1829, 0.1603]}, {"w": "apparently", "b": [0.1883, 0.1389, 0.2768, 0.1603]}, {"w": "only", "b": [0.2821, 0.1389, 0.319, 0.1603]}, {"w": "one", "b": [0.3243, 0.1389, 0.3552, 0.1603]}, {"w": "ocean_proximity", "b": [0.3605, 0.1421, 0.509, 0.1572]}, {"w": "category", "b": [0.5143, 0.1389, 0.5853, 0.1603]}, {"w": "is", "b": [0.5907, 0.1389, 0.6039, 0.1603]}, {"w": "really", "b": [0.6092, 0.1389, 0.6551, 0.1603]}, {"w": "useful,", "b": [0.6604, 0.1389, 0.7152, 0.1603]}, {"w": "so", "b": [0.7206, 0.1389, 0.7388, 0.1603]}, {"w": "you", "b": [0.7442, 0.1389, 0.7754, 0.1603]}, {"w": "could", "b": [0.7808, 0.1389, 0.8276, 0.1603]}, {"w": "try", "b": [0.8329, 0.1389, 0.8571, 0.1603]}, {"w": "dropping", "b": [0.1429, 0.158, 0.2208, 0.1794]}, {"w": "the", "b": [0.2255, 0.158, 0.2518, 0.1794]}, {"w": "others).", "b": [0.2566, 0.158, 0.3209, 0.1794]}]}, {"id": "b_2", "type": "paragraph", "text": "You should also look at the specific errors that your system makes, then try to under‐ stand why it makes them and what could fix the problem (adding extra features or, on the contrary, getting rid of uninformative ones, cleaning up outliers, etc.).", "words": [{"w": "You", "b": [0.1429, 0.1861, 0.1752, 0.2075]}, {"w": "should", "b": [0.1804, 0.1861, 0.2372, 0.2075]}, {"w": "also", "b": [0.2424, 0.1861, 0.2751, 0.2075]}, {"w": "look", "b": [0.2804, 0.1861, 0.3172, 0.2075]}, {"w": "at", "b": [0.3224, 0.1861, 0.3376, 0.2075]}, {"w": "the", "b": [0.3428, 0.1861, 0.3691, 0.2075]}, {"w": "specific", "b": [0.3744, 0.1861, 0.4367, 0.2075]}, {"w": "errors", "b": [0.442, 0.1861, 0.4923, 0.2075]}, {"w": "that", "b": [0.4975, 0.1861, 0.5301, 0.2075]}, {"w": "your", "b": [0.5354, 0.1861, 0.5743, 0.2075]}, {"w": "system", "b": [0.5796, 0.1861, 0.6367, 0.2075]}, {"w": "makes,", "b": [0.642, 0.1861, 0.6997, 0.2075]}, {"w": "then", "b": [0.705, 0.1861, 0.7427, 0.2075]}, {"w": "try", "b": [0.748, 0.1861, 0.7722, 0.2075]}, {"w": "to", "b": [0.7775, 0.1861, 0.7944, 0.2075]}, {"w": "under‐", "b": [0.7997, 0.1861, 0.8571, 0.2075]}, {"w": "stand", "b": [0.1429, 0.2051, 0.1884, 0.2265]}, {"w": "why", "b": [0.1932, 0.2051, 0.2277, 0.2265]}, {"w": "it", "b": [0.2325, 0.2051, 0.2444, 0.2265]}, {"w": "makes", "b": [0.2492, 0.2051, 0.3022, 0.2265]}, {"w": "them", "b": [0.307, 0.2051, 0.3504, 0.2265]}, {"w": "and", "b": [0.3552, 0.2051, 0.3868, 0.2265]}, {"w": "what", "b": [0.3916, 0.2051, 0.4321, 0.2265]}, {"w": "could", "b": [0.4369, 0.2051, 0.4836, 0.2265]}, {"w": "fix", "b": [0.4884, 0.2051, 0.51, 0.2265]}, {"w": "the", "b": [0.5148, 0.2051, 0.5411, 0.2265]}, {"w": "problem", "b": [0.5459, 0.2051, 0.617, 0.2265]}, {"w": "(adding", "b": [0.6218, 0.2051, 0.6868, 0.2265]}, {"w": "extra", "b": [0.6916, 0.2051, 0.7335, 0.2265]}, {"w": "features", "b": [0.7383, 0.2051, 0.8038, 0.2265]}, {"w": "or,", "b": [0.8085, 0.2051, 0.8303, 0.2265]}, {"w": "on", "b": [0.8351, 0.2051, 0.8572, 0.2265]}, {"w": "the", "b": [0.1429, 0.2242, 0.1692, 0.2456]}, {"w": "contrary,", "b": [0.1739, 0.2242, 0.2487, 0.2456]}, {"w": "getting", "b": [0.2534, 0.2242, 0.3115, 0.2456]}, {"w": "rid", "b": [0.3162, 0.2242, 0.3405, 0.2456]}, {"w": "of", "b": [0.3453, 0.2242, 0.362, 0.2456]}, {"w": "uninformative", "b": [0.3668, 0.2242, 0.487, 0.2456]}, {"w": "ones,", "b": [0.4917, 0.2242, 0.535, 0.2456]}, {"w": "cleaning", "b": [0.5397, 0.2242, 0.6099, 0.2456]}, {"w": "up", "b": [0.6147, 0.2242, 0.6366, 0.2456]}, {"w": "outliers,", "b": [0.6414, 0.2242, 0.7092, 0.2456]}, {"w": "etc.).", "b": [0.714, 0.2242, 0.7547, 0.2456]}]}, {"id": "b_3", "type": "paragraph", "text": "Evaluate Your System on the Test Set", "words": [{"w": "Evaluate", "b": [0.1429, 0.2584, 0.2323, 0.2869]}, {"w": "Your", "b": [0.2373, 0.2584, 0.2845, 0.2869]}, {"w": "System", "b": [0.2894, 0.2584, 0.3642, 0.2869]}, {"w": "on", "b": [0.3692, 0.2584, 0.3956, 0.2869]}, {"w": "the", "b": [0.4005, 0.2584, 0.4354, 0.2869]}, {"w": "Test", "b": [0.4403, 0.2584, 0.483, 0.2869]}, {"w": "Set", "b": [0.4879, 0.2584, 0.5211, 0.2869]}]}, {"id": "b_4", "type": "paragraph", "text": "After tweaking your models for a while, you eventually have a system that performs sufficiently well. Now is the time to evaluate the final model on the test set. There is nothing special about this process; just get the predictors and the labels from your test set, run your full_pipeline to transform the data (call transform(), not fit_transform(), you do not want to fit the test set!), and evaluate the final model on the test set:", "words": [{"w": "After", "b": [0.1429, 0.2928, 0.1864, 0.3142]}, {"w": "tweaking", "b": [0.1927, 0.2928, 0.2683, 0.3142]}, {"w": "your", "b": [0.2746, 0.2928, 0.3136, 0.3142]}, {"w": "models", "b": [0.3199, 0.2928, 0.3804, 0.3142]}, {"w": "for", "b": [0.3867, 0.2928, 0.4112, 0.3142]}, {"w": "a", "b": [0.4175, 0.2928, 0.4266, 0.3142]}, {"w": "while,", "b": [0.4329, 0.2928, 0.4828, 0.3142]}, {"w": "you", "b": [0.4891, 0.2928, 0.5203, 0.3142]}, {"w": "eventually", "b": [0.5266, 0.2928, 0.6117, 0.3142]}, {"w": "have", "b": [0.618, 0.2928, 0.6564, 0.3142]}, {"w": "a", "b": [0.6627, 0.2928, 0.6718, 0.3142]}, {"w": "system", "b": [0.6781, 0.2928, 0.7352, 0.3142]}, {"w": "that", "b": [0.7415, 0.2928, 0.7741, 0.3142]}, {"w": "performs", "b": [0.7804, 0.2928, 0.8571, 0.3142]}, {"w": "sufficiently", "b": [0.1428, 0.3119, 0.2349, 0.3333]}, {"w": "well.", "b": [0.241, 0.3119, 0.2794, 0.3333]}, {"w": "Now", "b": [0.2855, 0.3119, 0.3253, 0.3333]}, {"w": "is", "b": [0.3314, 0.3119, 0.3446, 0.3333]}, {"w": "the", "b": [0.3507, 0.3119, 0.377, 0.3333]}, {"w": "time", "b": [0.3831, 0.3119, 0.4209, 0.3333]}, {"w": "to", "b": [0.427, 0.3119, 0.444, 0.3333]}, {"w": "evaluate", "b": [0.4501, 0.3119, 0.518, 0.3333]}, {"w": "the", "b": [0.5241, 0.3119, 0.5504, 0.3333]}, {"w": "final", "b": [0.5565, 0.3119, 0.594, 0.3333]}, {"w": "model", "b": [0.6001, 0.3119, 0.6529, 0.3333]}, {"w": "on", "b": [0.659, 0.3119, 0.681, 0.3333]}, {"w": "the", "b": [0.6871, 0.3119, 0.7134, 0.3333]}, {"w": "test", "b": [0.7195, 0.3119, 0.7487, 0.3333]}, {"w": "set.", "b": [0.7547, 0.3119, 0.7824, 0.3333]}, {"w": "There", "b": [0.7884, 0.3119, 0.8378, 0.3333]}, {"w": "is", "b": [0.8439, 0.3119, 0.8571, 0.3333]}, {"w": "nothing", "b": [0.1429, 0.3309, 0.2091, 0.3523]}, {"w": "special", "b": [0.2163, 0.3309, 0.2726, 0.3523]}, {"w": "about", "b": [0.2798, 0.3309, 0.3276, 0.3523]}, {"w": "this", "b": [0.3348, 0.3309, 0.3655, 0.3523]}, {"w": "process;", "b": [0.3728, 0.3309, 0.4398, 0.3523]}, {"w": "just", "b": [0.447, 0.3309, 0.4774, 0.3523]}, {"w": "get", "b": [0.4847, 0.3309, 0.5096, 0.3523]}, {"w": "the", "b": [0.5169, 0.3309, 0.5432, 0.3523]}, {"w": "predictors", "b": [0.5505, 0.3309, 0.6357, 0.3523]}, {"w": "and", "b": [0.643, 0.3309, 0.6745, 0.3523]}, {"w": "the", "b": [0.6817, 0.3309, 0.7081, 0.3523]}, {"w": "labels", "b": [0.7153, 0.3309, 0.7621, 0.3523]}, {"w": "from", "b": [0.7693, 0.3309, 0.8109, 0.3523]}, {"w": "your", "b": [0.8182, 0.3309, 0.8572, 0.3523]}, {"w": "test", "b": [0.1429, 0.3509, 0.1721, 0.3723]}, {"w": "set,", "b": [0.1831, 0.3509, 0.2107, 0.3723]}, {"w": "run", "b": [0.2217, 0.3509, 0.2519, 0.3723]}, {"w": "your", "b": [0.2629, 0.3509, 0.3019, 0.3723]}, {"w": "full_pipeline", "b": [0.3129, 0.354, 0.4415, 0.3691]}, {"w": "to", "b": [0.4525, 0.3509, 0.4695, 0.3723]}, {"w": "transform", "b": [0.4805, 0.3509, 0.5643, 0.3723]}, {"w": "the", "b": [0.5754, 0.3509, 0.6017, 0.3723]}, {"w": "data", "b": [0.6127, 0.3509, 0.6479, 0.3723]}, {"w": "(call", "b": [0.6589, 0.3509, 0.6947, 0.3723]}, {"w": "transform(),", "b": [0.7057, 0.3509, 0.8193, 0.3723]}, {"w": "not", "b": [0.8303, 0.3507, 0.8571, 0.3723]}, {"w": "fit_transform(),", "b": [0.1429, 0.3708, 0.2961, 0.3922]}, {"w": "you", "b": [0.3026, 0.3708, 0.3339, 0.3922]}, {"w": "do", "b": [0.3404, 0.3708, 0.362, 0.3922]}, {"w": "not", "b": [0.3686, 0.3708, 0.397, 0.3922]}, {"w": "want", "b": [0.4035, 0.3708, 0.4443, 0.3922]}, {"w": "to", "b": [0.4508, 0.3708, 0.4678, 0.3922]}, {"w": "fit", "b": [0.4744, 0.3708, 0.4925, 0.3922]}, {"w": "the", "b": [0.499, 0.3708, 0.5253, 0.3922]}, {"w": "test", "b": [0.5319, 0.3708, 0.5611, 0.3922]}, {"w": "set!),", "b": [0.5676, 0.3708, 0.6082, 0.3922]}, {"w": "and", "b": [0.6148, 0.3708, 0.6463, 0.3922]}, {"w": "evaluate", "b": [0.6529, 0.3708, 0.7208, 0.3922]}, {"w": "the", "b": [0.7273, 0.3708, 0.7537, 0.3922]}, {"w": "final", "b": [0.7602, 0.3708, 0.7978, 0.3922]}, {"w": "model", "b": [0.8043, 0.3708, 0.8571, 0.3922]}, {"w": "on", "b": [0.1429, 0.3899, 0.1649, 0.4113]}, {"w": "the", "b": [0.1696, 0.3899, 0.1959, 0.4113]}, {"w": "test", "b": [0.2007, 0.3899, 0.2299, 0.4113]}, {"w": "set:", "b": [0.2346, 0.3899, 0.2622, 0.4113]}]}, {"id": "b_5", "type": "equation", "text": "final_model = grid_search.best_estimator_", "words": [{"w": "final_model", "b": [0.1766, 0.4218, 0.2693, 0.4347]}, {"w": "=", "b": [0.2778, 0.4218, 0.2862, 0.4347]}, {"w": "grid_search.best_estimator_", "b": [0.2946, 0.4218, 0.5223, 0.4347]}]}, {"id": "b_6", "type": "paragraph", "text": "X_test = strat_test_set.drop(\"median_house_value\", axis=1) y_test = strat_test_set[\"median_house_value\"].copy()", "words": [{"w": "X_test", "b": [0.1766, 0.4527, 0.2272, 0.4655]}, {"w": "=", "b": [0.2356, 0.4527, 0.244, 0.4655]}, {"w": "strat_test_set.drop(\"median_house_value\",", "b": [0.2525, 0.4527, 0.5982, 0.4655]}, {"w": "axis=1)", "b": [0.6066, 0.4527, 0.6657, 0.4655]}, {"w": "y_test", "b": [0.1766, 0.4681, 0.2272, 0.4809]}, {"w": "=", "b": [0.2356, 0.4681, 0.244, 0.4809]}, {"w": "strat_test_set[\"median_house_value\"].copy()", "b": [0.2525, 0.4681, 0.6151, 0.4809]}]}, {"id": "b_7", "type": "equation", "text": "X_test_prepared = full_pipeline.transform(X_test)", "words": [{"w": "X_test_prepared", "b": [0.1766, 0.4989, 0.3031, 0.5118]}, {"w": "=", "b": [0.3115, 0.4989, 0.3199, 0.5118]}, {"w": "full_pipeline.transform(X_test)", "b": [0.3284, 0.4989, 0.5898, 0.5118]}]}, {"id": "b_8", "type": "equation", "text": "final_predictions = final_model.predict(X_test_prepared)", "words": [{"w": "final_predictions", "b": [0.1766, 0.5298, 0.3199, 0.5426]}, {"w": "=", "b": [0.3284, 0.5298, 0.3368, 0.5426]}, {"w": "final_model.predict(X_test_prepared)", "b": [0.3452, 0.5298, 0.6488, 0.5426]}]}, {"id": "b_9", "type": "paragraph", "text": "final_mse = mean_squared_error(y_test, final_predictions) final_rmse = np.sqrt(final_mse) # => evaluates to 47,730.2", "words": [{"w": "final_mse", "b": [0.1766, 0.5606, 0.2525, 0.5735]}, {"w": "=", "b": [0.2609, 0.5606, 0.2693, 0.5735]}, {"w": "mean_squared_error(y_test,", "b": [0.2778, 0.5606, 0.497, 0.5735]}, {"w": "final_predictions)", "b": [0.5055, 0.5606, 0.6572, 0.5735]}, {"w": "final_rmse", "b": [0.1766, 0.576, 0.2609, 0.5889]}, {"w": "=", "b": [0.2693, 0.576, 0.2778, 0.5889]}, {"w": "np.sqrt(final_mse)", "b": [0.2862, 0.576, 0.438, 0.5889]}, {"w": "#", "b": [0.4633, 0.576, 0.4717, 0.5889]}, {"w": "=>", "b": [0.4802, 0.576, 0.497, 0.5889]}, {"w": "evaluates", "b": [0.5055, 0.576, 0.5813, 0.5889]}, {"w": "to", "b": [0.5898, 0.576, 0.6066, 0.5889]}, {"w": "47,730.2", "b": [0.6151, 0.576, 0.6825, 0.5889]}]}, {"id": "b_10", "type": "paragraph", "text": "In some cases, such a point estimate of the generalization error will not be quite enough to convince you to launch: what if it is just 0.1% better than the model cur‐ rently in production? You might want to have an idea of how precise this estimate is. For this, you can compute a 95% confidence interval for the generalization error using scipy.stats.t.interval():", "words": [{"w": "In", "b": [0.1429, 0.5967, 0.1614, 0.6181]}, {"w": "some", "b": [0.1698, 0.5967, 0.214, 0.6181]}, {"w": "cases,", "b": [0.2225, 0.5967, 0.2693, 0.6181]}, {"w": "such", "b": [0.2778, 0.5967, 0.3164, 0.6181]}, {"w": "a", "b": [0.3249, 0.5967, 0.334, 0.6181]}, {"w": "point", "b": [0.3425, 0.5967, 0.387, 0.6181]}, {"w": "estimate", "b": [0.3954, 0.5967, 0.4649, 0.6181]}, {"w": "of", "b": [0.4734, 0.5967, 0.4902, 0.6181]}, {"w": "the", "b": [0.4986, 0.5967, 0.5249, 0.6181]}, {"w": "generalization", "b": [0.5334, 0.5967, 0.6515, 0.6181]}, {"w": "error", "b": [0.6599, 0.5967, 0.7026, 0.6181]}, {"w": "will", "b": [0.711, 0.5967, 0.7414, 0.6181]}, {"w": "not", "b": [0.7499, 0.5967, 0.7783, 0.6181]}, {"w": "be", "b": [0.7867, 0.5967, 0.8062, 0.6181]}, {"w": "quite", "b": [0.8146, 0.5967, 0.8571, 0.6181]}, {"w": "enough", "b": [0.1428, 0.6157, 0.2057, 0.6371]}, {"w": "to", "b": [0.212, 0.6157, 0.229, 0.6371]}, {"w": "convince", "b": [0.2353, 0.6157, 0.3099, 0.6371]}, {"w": "you", "b": [0.3163, 0.6157, 0.3475, 0.6371]}, {"w": "to", "b": [0.3538, 0.6157, 0.3708, 0.6371]}, {"w": "launch:", "b": [0.3771, 0.6157, 0.4383, 0.6371]}, {"w": "what", "b": [0.4446, 0.6157, 0.4851, 0.6371]}, {"w": "if", "b": [0.4915, 0.6157, 0.5032, 0.6371]}, {"w": "it", "b": [0.5095, 0.6157, 0.5215, 0.6371]}, {"w": "is", "b": [0.5278, 0.6157, 0.541, 0.6371]}, {"w": "just", "b": [0.5474, 0.6157, 0.5778, 0.6371]}, {"w": "0.1%", "b": [0.5841, 0.6157, 0.6246, 0.6371]}, {"w": "better", "b": [0.6309, 0.6157, 0.6796, 0.6371]}, {"w": "than", "b": [0.686, 0.6157, 0.724, 0.6371]}, {"w": "the", "b": [0.7303, 0.6157, 0.7566, 0.6371]}, {"w": "model", "b": [0.763, 0.6157, 0.8158, 0.6371]}, {"w": "cur‐", "b": [0.8221, 0.6157, 0.8571, 0.6371]}, {"w": "rently", "b": [0.1429, 0.6348, 0.1916, 0.6562]}, {"w": "in", "b": [0.1972, 0.6348, 0.2142, 0.6562]}, {"w": "production?", "b": [0.2198, 0.6348, 0.3218, 0.6562]}, {"w": "You", "b": [0.3274, 0.6348, 0.3598, 0.6562]}, {"w": "might", "b": [0.3654, 0.6348, 0.4149, 0.6562]}, {"w": "want", "b": [0.4205, 0.6348, 0.4612, 0.6562]}, {"w": "to", "b": [0.4668, 0.6348, 0.4838, 0.6562]}, {"w": "have", "b": [0.4894, 0.6348, 0.5278, 0.6562]}, {"w": "an", "b": [0.5334, 0.6348, 0.554, 0.6562]}, {"w": "idea", "b": [0.5596, 0.6348, 0.5942, 0.6562]}, {"w": "of", "b": [0.5998, 0.6348, 0.6166, 0.6562]}, {"w": "how", "b": [0.6222, 0.6348, 0.6582, 0.6562]}, {"w": "precise", "b": [0.6638, 0.6348, 0.7222, 0.6562]}, {"w": "this", "b": [0.7278, 0.6348, 0.7585, 0.6562]}, {"w": "estimate", "b": [0.7641, 0.6348, 0.8336, 0.6562]}, {"w": "is.", "b": [0.8392, 0.6348, 0.8571, 0.6562]}, {"w": "For", "b": [0.1429, 0.6538, 0.1718, 0.6752]}, {"w": "this,", "b": [0.1768, 0.6538, 0.2123, 0.6752]}, {"w": "you", "b": [0.2173, 0.6538, 0.2485, 0.6752]}, {"w": "can", "b": [0.2535, 0.6538, 0.2829, 0.6752]}, {"w": "compute", "b": [0.2878, 0.6538, 0.3611, 0.6752]}, {"w": "a", "b": [0.3661, 0.6538, 0.3753, 0.6752]}, {"w": "95%", "b": [0.3803, 0.6538, 0.416, 0.6752]}, {"w": "confidence", "b": [0.421, 0.6536, 0.5072, 0.6752]}, {"w": "interval", "b": [0.512, 0.6536, 0.575, 0.6752]}, {"w": "for", "b": [0.5802, 0.6538, 0.6047, 0.6752]}, {"w": "the", "b": [0.6097, 0.6538, 0.636, 0.6752]}, {"w": "generalization", "b": [0.641, 0.6538, 0.7591, 0.6752]}, {"w": "error", "b": [0.7641, 0.6538, 0.8067, 0.6752]}, {"w": "using", "b": [0.8117, 0.6538, 0.8571, 0.6752]}, {"w": "scipy.stats.t.interval():", "b": [0.1429, 0.6737, 0.3851, 0.6952]}]}, {"id": "b_11", "type": "paragraph", "text": ">>> from scipy import stats >>> confidence = 0.95 >>> squared_errors = (final_predictions - y_test) ** 2 >>> np.sqrt(stats.t.interval(confidence, len(squared_errors) - 1, ... loc=squared_errors.mean(), ... scale=stats.sem(squared_errors))) ... array([45685.10470776, 49691.25001878])", "words": [{"w": ">>>", "b": [0.1766, 0.7057, 0.2019, 0.7186]}, {"w": "from", "b": [0.2103, 0.7057, 0.244, 0.7186]}, {"w": "scipy", "b": [0.2525, 0.7057, 0.2946, 0.7186]}, {"w": "import", "b": [0.3031, 0.7057, 0.3537, 0.7186]}, {"w": "stats", "b": [0.3621, 0.7057, 0.4043, 0.7186]}, {"w": ">>>", "b": [0.1766, 0.7211, 0.2019, 0.734]}, {"w": "confidence", "b": [0.2103, 0.7211, 0.2946, 0.734]}, {"w": "=", "b": [0.3031, 0.7211, 0.3115, 0.734]}, {"w": "0.95", "b": [0.3199, 0.7211, 0.3537, 0.734]}, {"w": ">>>", "b": [0.1766, 0.7366, 0.2019, 0.7494]}, {"w": "squared_errors", "b": [0.2103, 0.7366, 0.3284, 0.7494]}, {"w": "=", "b": [0.3368, 0.7366, 0.3452, 0.7494]}, {"w": "(final_predictions", "b": [0.3537, 0.7366, 0.5054, 0.7494]}, {"w": "-", "b": [0.5139, 0.7366, 0.5223, 0.7494]}, {"w": "y_test)", "b": [0.5307, 0.7366, 0.5898, 0.7494]}, {"w": "**", "b": [0.5982, 0.7366, 0.6151, 0.7494]}, {"w": "2", "b": [0.6235, 0.7366, 0.6319, 0.7494]}, {"w": ">>>", "b": [0.1766, 0.752, 0.2019, 0.7648]}, {"w": "np.sqrt(stats.t.interval(confidence,", "b": [0.2103, 0.752, 0.5139, 0.7648]}, {"w": "len(squared_errors)", "b": [0.5223, 0.752, 0.6825, 0.7648]}, {"w": "-", "b": [0.691, 0.752, 0.6994, 0.7648]}, {"w": "1,", "b": [0.7078, 0.752, 0.7247, 0.7648]}, {"w": "...", "b": [0.1766, 0.7674, 0.2019, 0.7802]}, {"w": "loc=squared_errors.mean(),", "b": [0.4211, 0.7674, 0.6404, 0.7802]}, {"w": "...", "b": [0.1766, 0.7828, 0.2019, 0.7957]}, {"w": "scale=stats.sem(squared_errors)))", "b": [0.4211, 0.7828, 0.6994, 0.7957]}, {"w": "...", "b": [0.1766, 0.7982, 0.2019, 0.8111]}, {"w": "array([45685.10470776,", "b": [0.1766, 0.8137, 0.3621, 0.8265]}, {"w": "49691.25001878])", "b": [0.3705, 0.8137, 0.5054, 0.8265]}]}, {"id": "b_12", "type": "paragraph", "text": "The performance will usually be slightly worse than what you measured using cross- validation if you did a lot of hyperparameter tuning (because your system ends up fine-tuned to perform well on the validation data, and will likely not perform as well", "words": [{"w": "The", "b": [0.1429, 0.8343, 0.1757, 0.8557]}, {"w": "performance", "b": [0.1815, 0.8343, 0.2888, 0.8557]}, {"w": "will", "b": [0.2946, 0.8343, 0.325, 0.8557]}, {"w": "usually", "b": [0.3308, 0.8343, 0.3898, 0.8557]}, {"w": "be", "b": [0.3956, 0.8343, 0.415, 0.8557]}, {"w": "slightly", "b": [0.4208, 0.8343, 0.481, 0.8557]}, {"w": "worse", "b": [0.4868, 0.8343, 0.5359, 0.8557]}, {"w": "than", "b": [0.5417, 0.8343, 0.5797, 0.8557]}, {"w": "what", "b": [0.5855, 0.8343, 0.626, 0.8557]}, {"w": "you", "b": [0.6318, 0.8343, 0.6631, 0.8557]}, {"w": "measured", "b": [0.6689, 0.8343, 0.7502, 0.8557]}, {"w": "using", "b": [0.756, 0.8343, 0.8015, 0.8557]}, {"w": "cross-", "b": [0.8073, 0.8343, 0.8572, 0.8557]}, {"w": "validation", "b": [0.1429, 0.8533, 0.2262, 0.8747]}, {"w": "if", "b": [0.2335, 0.8533, 0.2452, 0.8747]}, {"w": "you", "b": [0.2525, 0.8533, 0.2837, 0.8747]}, {"w": "did", "b": [0.291, 0.8533, 0.3186, 0.8747]}, {"w": "a", "b": [0.3258, 0.8533, 0.335, 0.8747]}, {"w": "lot", "b": [0.3422, 0.8533, 0.3645, 0.8747]}, {"w": "of", "b": [0.3717, 0.8533, 0.3885, 0.8747]}, {"w": "hyperparameter", "b": [0.3958, 0.8533, 0.5293, 0.8747]}, {"w": "tuning", "b": [0.5366, 0.8533, 0.5921, 0.8747]}, {"w": "(because", "b": [0.5994, 0.8533, 0.6711, 0.8747]}, {"w": "your", "b": [0.6784, 0.8533, 0.7174, 0.8747]}, {"w": "system", "b": [0.7246, 0.8533, 0.7818, 0.8747]}, {"w": "ends", "b": [0.789, 0.8533, 0.8279, 0.8747]}, {"w": "up", "b": [0.8352, 0.8533, 0.8571, 0.8747]}, {"w": "fine-tuned", "b": [0.1429, 0.8724, 0.2309, 0.8938]}, {"w": "to", "b": [0.2367, 0.8724, 0.2536, 0.8938]}, {"w": "perform", "b": [0.2594, 0.8724, 0.3284, 0.8938]}, {"w": "well", "b": [0.3342, 0.8724, 0.3678, 0.8938]}, {"w": "on", "b": [0.3735, 0.8724, 0.3956, 0.8938]}, {"w": "the", "b": [0.4013, 0.8724, 0.4276, 0.8938]}, {"w": "validation", "b": [0.4333, 0.8724, 0.5167, 0.8938]}, {"w": "data,", "b": [0.5224, 0.8724, 0.5624, 0.8938]}, {"w": "and", "b": [0.5681, 0.8724, 0.5997, 0.8938]}, {"w": "will", "b": [0.6054, 0.8724, 0.6358, 0.8938]}, {"w": "likely", "b": [0.6415, 0.8724, 0.6864, 0.8938]}, {"w": "not", "b": [0.6921, 0.8724, 0.7204, 0.8938]}, {"w": "perform", "b": [0.7262, 0.8724, 0.7952, 0.8938]}, {"w": "as", "b": [0.801, 0.8724, 0.8178, 0.8938]}, {"w": "well", "b": [0.8235, 0.8724, 0.8571, 0.8938]}]}, {"id": "b_13", "type": "equation", "text": "Fine-Tune Your Model | 83", "words": [{"w": "Fine-Tune", "b": [0.6747, 0.9225, 0.7337, 0.9388]}, {"w": "Your", "b": [0.7366, 0.9225, 0.7635, 0.9388]}, {"w": "Model", "b": [0.7663, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "83", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 110, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "on unknown datasets). It is not the case in this example, but when this happens you must resist the temptation to tweak the hyperparameters to make the numbers look good on the test set; the improvements would be unlikely to generalize to new data.", "words": [{"w": "on", "b": [0.1429, 0.0791, 0.1649, 0.1005]}, {"w": "unknown", "b": [0.171, 0.0791, 0.2515, 0.1005]}, {"w": "datasets).", "b": [0.2576, 0.0791, 0.3353, 0.1005]}, {"w": "It", "b": [0.3414, 0.0791, 0.3541, 0.1005]}, {"w": "is", "b": [0.3602, 0.0791, 0.3734, 0.1005]}, {"w": "not", "b": [0.3796, 0.0791, 0.4079, 0.1005]}, {"w": "the", "b": [0.4141, 0.0791, 0.4404, 0.1005]}, {"w": "case", "b": [0.4465, 0.0791, 0.481, 0.1005]}, {"w": "in", "b": [0.4871, 0.0791, 0.5041, 0.1005]}, {"w": "this", "b": [0.5102, 0.0791, 0.5409, 0.1005]}, {"w": "example,", "b": [0.547, 0.0791, 0.6213, 0.1005]}, {"w": "but", "b": [0.6274, 0.0791, 0.6554, 0.1005]}, {"w": "when", "b": [0.6616, 0.0791, 0.7072, 0.1005]}, {"w": "this", "b": [0.7133, 0.0791, 0.744, 0.1005]}, {"w": "happens", "b": [0.7502, 0.0791, 0.8198, 0.1005]}, {"w": "you", "b": [0.8259, 0.0791, 0.8571, 0.1005]}, {"w": "must", "b": [0.1429, 0.0981, 0.1846, 0.1195]}, {"w": "resist", "b": [0.1911, 0.0981, 0.2349, 0.1195]}, {"w": "the", "b": [0.2413, 0.0981, 0.2677, 0.1195]}, {"w": "temptation", "b": [0.2741, 0.0981, 0.366, 0.1195]}, {"w": "to", "b": [0.3725, 0.0981, 0.3894, 0.1195]}, {"w": "tweak", "b": [0.3959, 0.0981, 0.4449, 0.1195]}, {"w": "the", "b": [0.4513, 0.0981, 0.4777, 0.1195]}, {"w": "hyperparameters", "b": [0.4841, 0.0981, 0.6253, 0.1195]}, {"w": "to", "b": [0.6318, 0.0981, 0.6487, 0.1195]}, {"w": "make", "b": [0.6552, 0.0981, 0.7006, 0.1195]}, {"w": "the", "b": [0.7071, 0.0981, 0.7334, 0.1195]}, {"w": "numbers", "b": [0.7399, 0.0981, 0.8138, 0.1195]}, {"w": "look", "b": [0.8203, 0.0981, 0.8571, 0.1195]}, {"w": "good", "b": [0.1429, 0.1172, 0.1849, 0.1386]}, {"w": "on", "b": [0.1896, 0.1172, 0.2116, 0.1386]}, {"w": "the", "b": [0.2163, 0.1172, 0.2427, 0.1386]}, {"w": "test", "b": [0.2474, 0.1172, 0.2766, 0.1386]}, {"w": "set;", "b": [0.2813, 0.1172, 0.3089, 0.1386]}, {"w": "the", "b": [0.3137, 0.1172, 0.34, 0.1386]}, {"w": "improvements", "b": [0.3447, 0.1172, 0.4657, 0.1386]}, {"w": "would", "b": [0.4704, 0.1172, 0.5226, 0.1386]}, {"w": "be", "b": [0.5274, 0.1172, 0.5468, 0.1386]}, {"w": "unlikely", "b": [0.5515, 0.1172, 0.6189, 0.1386]}, {"w": "to", "b": [0.6236, 0.1172, 0.6406, 0.1386]}, {"w": "generalize", "b": [0.6453, 0.1172, 0.7295, 0.1386]}, {"w": "to", "b": [0.7342, 0.1172, 0.7512, 0.1386]}, {"w": "new", "b": [0.7559, 0.1172, 0.7904, 0.1386]}, {"w": "data.", "b": [0.7952, 0.1172, 0.8352, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "Now comes the project prelaunch phase: you need to present your solution (high‐ lighting what you have learned, what worked and what did not, what assumptions were made, and what your system’s limitations are), document everything, and create nice presentations with clear visualizations and easy-to-remember statements (e.g., “the median income is the number one predictor of housing prices”). In this Califor‐ nia housing example, the final performance of the system is not better than the experts’, but it may still be a good idea to launch it, especially if this frees up some time for the experts so they can work on more interesting and productive tasks.", "words": [{"w": "Now", "b": [0.1429, 0.1453, 0.1827, 0.1667]}, {"w": "comes", "b": [0.1903, 0.1453, 0.2433, 0.1667]}, {"w": "the", "b": [0.2508, 0.1453, 0.2772, 0.1667]}, {"w": "project", "b": [0.2847, 0.1453, 0.3433, 0.1667]}, {"w": "prelaunch", "b": [0.3509, 0.1453, 0.4348, 0.1667]}, {"w": "phase:", "b": [0.4424, 0.1453, 0.4948, 0.1667]}, {"w": "you", "b": [0.5024, 0.1453, 0.5336, 0.1667]}, {"w": "need", "b": [0.5412, 0.1453, 0.5813, 0.1667]}, {"w": "to", "b": [0.5888, 0.1453, 0.6058, 0.1667]}, {"w": "present", "b": [0.6134, 0.1453, 0.6747, 0.1667]}, {"w": "your", "b": [0.6823, 0.1453, 0.7213, 0.1667]}, {"w": "solution", "b": [0.7288, 0.1453, 0.7974, 0.1667]}, {"w": "(high‐", "b": [0.8049, 0.1453, 0.8572, 0.1667]}, {"w": "lighting", "b": [0.1429, 0.1643, 0.2073, 0.1857]}, {"w": "what", "b": [0.2149, 0.1643, 0.2554, 0.1857]}, {"w": "you", "b": [0.263, 0.1643, 0.2943, 0.1857]}, {"w": "have", "b": [0.3019, 0.1643, 0.3403, 0.1857]}, {"w": "learned,", "b": [0.3479, 0.1643, 0.4149, 0.1857]}, {"w": "what", "b": [0.4225, 0.1643, 0.463, 0.1857]}, {"w": "worked", "b": [0.4707, 0.1643, 0.5335, 0.1857]}, {"w": "and", "b": [0.5411, 0.1643, 0.5726, 0.1857]}, {"w": "what", "b": [0.5803, 0.1643, 0.6208, 0.1857]}, {"w": "did", "b": [0.6284, 0.1643, 0.656, 0.1857]}, {"w": "not,", "b": [0.6636, 0.1643, 0.6967, 0.1857]}, {"w": "what", "b": [0.7043, 0.1643, 0.7448, 0.1857]}, {"w": "assumptions", "b": [0.7525, 0.1643, 0.8571, 0.1857]}, {"w": "were", "b": [0.1429, 0.1834, 0.1826, 0.2048]}, {"w": "made,", "b": [0.1879, 0.1834, 0.2388, 0.2048]}, {"w": "and", "b": [0.2441, 0.1834, 0.2757, 0.2048]}, {"w": "what", "b": [0.2811, 0.1834, 0.3216, 0.2048]}, {"w": "your", "b": [0.327, 0.1834, 0.3659, 0.2048]}, {"w": "system’s", "b": [0.3713, 0.1834, 0.4371, 0.2048]}, {"w": "limitations", "b": [0.4424, 0.1834, 0.5326, 0.2048]}, {"w": "are),", "b": [0.538, 0.1834, 0.5757, 0.2048]}, {"w": "document", "b": [0.5811, 0.1834, 0.6659, 0.2048]}, {"w": "everything,", "b": [0.6713, 0.1834, 0.7655, 0.2048]}, {"w": "and", "b": [0.7709, 0.1834, 0.8024, 0.2048]}, {"w": "create", "b": [0.8078, 0.1834, 0.8571, 0.2048]}, {"w": "nice", "b": [0.1428, 0.2024, 0.1775, 0.2238]}, {"w": "presentations", "b": [0.1854, 0.2024, 0.2971, 0.2238]}, {"w": "with", "b": [0.3051, 0.2024, 0.3424, 0.2238]}, {"w": "clear", "b": [0.3504, 0.2024, 0.3902, 0.2238]}, {"w": "visualizations", "b": [0.3981, 0.2024, 0.5111, 0.2238]}, {"w": "and", "b": [0.5191, 0.2024, 0.5506, 0.2238]}, {"w": "easy-to-remember", "b": [0.5586, 0.2024, 0.7123, 0.2238]}, {"w": "statements", "b": [0.7203, 0.2024, 0.8091, 0.2238]}, {"w": "(e.g.,", "b": [0.8171, 0.2024, 0.8571, 0.2238]}, {"w": "“the", "b": [0.1429, 0.2215, 0.1767, 0.2429]}, {"w": "median", "b": [0.1823, 0.2215, 0.2454, 0.2429]}, {"w": "income", "b": [0.251, 0.2215, 0.3133, 0.2429]}, {"w": "is", "b": [0.3189, 0.2215, 0.3321, 0.2429]}, {"w": "the", "b": [0.3377, 0.2215, 0.3641, 0.2429]}, {"w": "number", "b": [0.3696, 0.2215, 0.4359, 0.2429]}, {"w": "one", "b": [0.4415, 0.2215, 0.4724, 0.2429]}, {"w": "predictor", "b": [0.478, 0.2215, 0.5556, 0.2429]}, {"w": "of", "b": [0.5612, 0.2215, 0.578, 0.2429]}, {"w": "housing", "b": [0.5836, 0.2215, 0.6508, 0.2429]}, {"w": "prices”).", "b": [0.6564, 0.2215, 0.7254, 0.2429]}, {"w": "In", "b": [0.731, 0.2215, 0.7495, 0.2429]}, {"w": "this", "b": [0.7551, 0.2215, 0.7858, 0.2429]}, {"w": "Califor‐", "b": [0.7914, 0.2215, 0.8571, 0.2429]}, {"w": "nia", "b": [0.1429, 0.2405, 0.169, 0.2619]}, {"w": "housing", "b": [0.1783, 0.2405, 0.2454, 0.2619]}, {"w": "example,", "b": [0.2547, 0.2405, 0.329, 0.2619]}, {"w": "the", "b": [0.3383, 0.2405, 0.3646, 0.2619]}, {"w": "final", "b": [0.3739, 0.2405, 0.4115, 0.2619]}, {"w": "performance", "b": [0.4207, 0.2405, 0.528, 0.2619]}, {"w": "of", "b": [0.5373, 0.2405, 0.5541, 0.2619]}, {"w": "the", "b": [0.5634, 0.2405, 0.5897, 0.2619]}, {"w": "system", "b": [0.599, 0.2405, 0.6561, 0.2619]}, {"w": "is", "b": [0.6654, 0.2405, 0.6786, 0.2619]}, {"w": "not", "b": [0.6879, 0.2405, 0.7162, 0.2619]}, {"w": "better", "b": [0.7255, 0.2405, 0.7742, 0.2619]}, {"w": "than", "b": [0.7835, 0.2405, 0.8215, 0.2619]}, {"w": "the", "b": [0.8308, 0.2405, 0.8571, 0.2619]}, {"w": "experts’,", "b": [0.1429, 0.2596, 0.2082, 0.281]}, {"w": "but", "b": [0.2153, 0.2596, 0.2433, 0.281]}, {"w": "it", "b": [0.2504, 0.2596, 0.2623, 0.281]}, {"w": "may", "b": [0.2694, 0.2596, 0.3048, 0.281]}, {"w": "still", "b": [0.3119, 0.2596, 0.342, 0.281]}, {"w": "be", "b": [0.3491, 0.2596, 0.3686, 0.281]}, {"w": "a", "b": [0.3756, 0.2596, 0.3848, 0.281]}, {"w": "good", "b": [0.3919, 0.2596, 0.4339, 0.281]}, {"w": "idea", "b": [0.4409, 0.2596, 0.4755, 0.281]}, {"w": "to", "b": [0.4826, 0.2596, 0.4996, 0.281]}, {"w": "launch", "b": [0.5067, 0.2596, 0.5631, 0.281]}, {"w": "it,", "b": [0.5702, 0.2596, 0.5869, 0.281]}, {"w": "especially", "b": [0.5939, 0.2596, 0.6739, 0.281]}, {"w": "if", "b": [0.6809, 0.2596, 0.6927, 0.281]}, {"w": "this", "b": [0.6998, 0.2596, 0.7305, 0.281]}, {"w": "frees", "b": [0.7376, 0.2596, 0.7768, 0.281]}, {"w": "up", "b": [0.7839, 0.2596, 0.8059, 0.281]}, {"w": "some", "b": [0.8129, 0.2596, 0.8571, 0.281]}, {"w": "time", "b": [0.1429, 0.2786, 0.1807, 0.3]}, {"w": "for", "b": [0.1854, 0.2786, 0.21, 0.3]}, {"w": "the", "b": [0.2147, 0.2786, 0.241, 0.3]}, {"w": "experts", "b": [0.2458, 0.2786, 0.3059, 0.3]}, {"w": "so", "b": [0.3107, 0.2786, 0.3289, 0.3]}, {"w": "they", "b": [0.3337, 0.2786, 0.3696, 0.3]}, {"w": "can", "b": [0.3743, 0.2786, 0.4037, 0.3]}, {"w": "work", "b": [0.4084, 0.2786, 0.4513, 0.3]}, {"w": "on", "b": [0.4561, 0.2786, 0.4781, 0.3]}, {"w": "more", "b": [0.4828, 0.2786, 0.5271, 0.3]}, {"w": "interesting", "b": [0.5318, 0.2786, 0.6209, 0.3]}, {"w": "and", "b": [0.6257, 0.2786, 0.6572, 0.3]}, {"w": "productive", "b": [0.6619, 0.2786, 0.7525, 0.3]}, {"w": "tasks.", "b": [0.7572, 0.2786, 0.8031, 0.3]}]}, {"id": "b_2", "type": "paragraph", "text": "Launch, Monitor, and Maintain Your System", "words": [{"w": "Launch,", "b": [0.1429, 0.313, 0.2399, 0.3473]}, {"w": "Monitor,", "b": [0.2458, 0.313, 0.353, 0.3473]}, {"w": "and", "b": [0.3589, 0.313, 0.406, 0.3473]}, {"w": "Maintain", "b": [0.412, 0.313, 0.5237, 0.3473]}, {"w": "Your", "b": [0.5296, 0.313, 0.5862, 0.3473]}, {"w": "System", "b": [0.5922, 0.313, 0.6819, 0.3473]}]}, {"id": "b_3", "type": "paragraph", "text": "Perfect, you got approval to launch! You need to get your solution ready for produc‐ tion, in particular by plugging the production input data sources into your system and writing tests.", "words": [{"w": "Perfect,", "b": [0.1429, 0.3542, 0.2054, 0.3756]}, {"w": "you", "b": [0.2112, 0.3542, 0.2425, 0.3756]}, {"w": "got", "b": [0.2483, 0.3542, 0.275, 0.3756]}, {"w": "approval", "b": [0.2808, 0.3542, 0.3538, 0.3756]}, {"w": "to", "b": [0.3596, 0.3542, 0.3766, 0.3756]}, {"w": "launch!", "b": [0.3824, 0.3542, 0.4446, 0.3756]}, {"w": "You", "b": [0.4504, 0.3542, 0.4827, 0.3756]}, {"w": "need", "b": [0.4886, 0.3542, 0.5287, 0.3756]}, {"w": "to", "b": [0.5345, 0.3542, 0.5514, 0.3756]}, {"w": "get", "b": [0.5572, 0.3542, 0.5822, 0.3756]}, {"w": "your", "b": [0.588, 0.3542, 0.627, 0.3756]}, {"w": "solution", "b": [0.6328, 0.3542, 0.7014, 0.3756]}, {"w": "ready", "b": [0.7072, 0.3542, 0.7535, 0.3756]}, {"w": "for", "b": [0.7593, 0.3542, 0.7838, 0.3756]}, {"w": "produc‐", "b": [0.7896, 0.3542, 0.8571, 0.3756]}, {"w": "tion,", "b": [0.1429, 0.3732, 0.1816, 0.3947]}, {"w": "in", "b": [0.1891, 0.3732, 0.2061, 0.3947]}, {"w": "particular", "b": [0.2136, 0.3732, 0.2954, 0.3947]}, {"w": "by", "b": [0.3029, 0.3732, 0.3231, 0.3947]}, {"w": "plugging", "b": [0.3306, 0.3732, 0.4041, 0.3947]}, {"w": "the", "b": [0.4117, 0.3732, 0.438, 0.3947]}, {"w": "production", "b": [0.4455, 0.3732, 0.5396, 0.3947]}, {"w": "input", "b": [0.5472, 0.3732, 0.5921, 0.3947]}, {"w": "data", "b": [0.5997, 0.3732, 0.6349, 0.3947]}, {"w": "sources", "b": [0.6425, 0.3732, 0.7048, 0.3947]}, {"w": "into", "b": [0.7124, 0.3732, 0.7459, 0.3947]}, {"w": "your", "b": [0.7535, 0.3732, 0.7925, 0.3947]}, {"w": "system", "b": [0.8, 0.3732, 0.8571, 0.3947]}, {"w": "and", "b": [0.1428, 0.3923, 0.1744, 0.4137]}, {"w": "writing", "b": [0.1791, 0.3923, 0.2398, 0.4137]}, {"w": "tests.", "b": [0.2445, 0.3923, 0.2861, 0.4137]}]}, {"id": "b_4", "type": "paragraph", "text": "You also need to write monitoring code to check your system’s live performance at regular intervals and trigger alerts when it drops. This is important to catch not only sudden breakage, but also performance degradation. This is quite common because models tend to “rot” as data evolves over time, unless the models are regularly trained on fresh data.", "words": [{"w": "You", "b": [0.1428, 0.4204, 0.1752, 0.4418]}, {"w": "also", "b": [0.1823, 0.4204, 0.215, 0.4418]}, {"w": "need", "b": [0.2221, 0.4204, 0.2622, 0.4418]}, {"w": "to", "b": [0.2694, 0.4204, 0.2863, 0.4418]}, {"w": "write", "b": [0.2935, 0.4204, 0.3363, 0.4418]}, {"w": "monitoring", "b": [0.3434, 0.4204, 0.4395, 0.4418]}, {"w": "code", "b": [0.4466, 0.4204, 0.4859, 0.4418]}, {"w": "to", "b": [0.493, 0.4204, 0.51, 0.4418]}, {"w": "check", "b": [0.5171, 0.4204, 0.5651, 0.4418]}, {"w": "your", "b": [0.5722, 0.4204, 0.6112, 0.4418]}, {"w": "system’s", "b": [0.6183, 0.4204, 0.684, 0.4418]}, {"w": "live", "b": [0.6911, 0.4204, 0.7205, 0.4418]}, {"w": "performance", "b": [0.7276, 0.4204, 0.8349, 0.4418]}, {"w": "at", "b": [0.842, 0.4204, 0.8571, 0.4418]}, {"w": "regular", "b": [0.1429, 0.4395, 0.2024, 0.4609]}, {"w": "intervals", "b": [0.2081, 0.4395, 0.2799, 0.4609]}, {"w": "and", "b": [0.2856, 0.4395, 0.3171, 0.4609]}, {"w": "trigger", "b": [0.3228, 0.4395, 0.3786, 0.4609]}, {"w": "alerts", "b": [0.3842, 0.4395, 0.4292, 0.4609]}, {"w": "when", "b": [0.4349, 0.4395, 0.4806, 0.4609]}, {"w": "it", "b": [0.4862, 0.4395, 0.4982, 0.4609]}, {"w": "drops.", "b": [0.5039, 0.4395, 0.5565, 0.4609]}, {"w": "This", "b": [0.5622, 0.4395, 0.5994, 0.4609]}, {"w": "is", "b": [0.6051, 0.4395, 0.6183, 0.4609]}, {"w": "important", "b": [0.624, 0.4395, 0.7084, 0.4609]}, {"w": "to", "b": [0.7141, 0.4395, 0.731, 0.4609]}, {"w": "catch", "b": [0.7367, 0.4395, 0.7806, 0.4609]}, {"w": "not", "b": [0.7862, 0.4395, 0.8146, 0.4609]}, {"w": "only", "b": [0.8203, 0.4395, 0.8571, 0.4609]}, {"w": "sudden", "b": [0.1429, 0.4585, 0.2038, 0.4799]}, {"w": "breakage,", "b": [0.2106, 0.4585, 0.2898, 0.4799]}, {"w": "but", "b": [0.2966, 0.4585, 0.3246, 0.4799]}, {"w": "also", "b": [0.3314, 0.4585, 0.3641, 0.4799]}, {"w": "performance", "b": [0.3709, 0.4585, 0.4782, 0.4799]}, {"w": "degradation.", "b": [0.485, 0.4585, 0.59, 0.4799]}, {"w": "This", "b": [0.5968, 0.4585, 0.634, 0.4799]}, {"w": "is", "b": [0.6408, 0.4585, 0.654, 0.4799]}, {"w": "quite", "b": [0.6609, 0.4585, 0.7034, 0.4799]}, {"w": "common", "b": [0.7102, 0.4585, 0.7858, 0.4799]}, {"w": "because", "b": [0.7926, 0.4585, 0.8571, 0.4799]}, {"w": "models", "b": [0.1429, 0.4776, 0.2033, 0.499]}, {"w": "tend", "b": [0.2082, 0.4776, 0.2458, 0.499]}, {"w": "to", "b": [0.2507, 0.4776, 0.2676, 0.499]}, {"w": "“rot”", "b": [0.2725, 0.4776, 0.3127, 0.499]}, {"w": "as", "b": [0.3175, 0.4776, 0.3343, 0.499]}, {"w": "data", "b": [0.3392, 0.4776, 0.3744, 0.499]}, {"w": "evolves", "b": [0.3793, 0.4776, 0.4399, 0.499]}, {"w": "over", "b": [0.4447, 0.4776, 0.4816, 0.499]}, {"w": "time,", "b": [0.4865, 0.4776, 0.5291, 0.499]}, {"w": "unless", "b": [0.5339, 0.4776, 0.5858, 0.499]}, {"w": "the", "b": [0.5907, 0.4776, 0.617, 0.499]}, {"w": "models", "b": [0.6219, 0.4776, 0.6824, 0.499]}, {"w": "are", "b": [0.6872, 0.4776, 0.713, 0.499]}, {"w": "regularly", "b": [0.7178, 0.4776, 0.7922, 0.499]}, {"w": "trained", "b": [0.7971, 0.4776, 0.8571, 0.499]}, {"w": "on", "b": [0.1429, 0.4966, 0.1649, 0.518]}, {"w": "fresh", "b": [0.1696, 0.4966, 0.2111, 0.518]}, {"w": "data.", "b": [0.2159, 0.4966, 0.2559, 0.518]}]}, {"id": "b_5", "type": "paragraph", "text": "Evaluating your system’s performance will require sampling the system’s predictions and evaluating them. This will generally require a human analysis. These analysts may be field experts, or workers on a crowdsourcing platform (such as Amazon Mechanical Turk or CrowdFlower). Either way, you need to plug the human evalua‐ tion pipeline into your system.", "words": [{"w": "Evaluating", "b": [0.1429, 0.5247, 0.2312, 0.5461]}, {"w": "your", "b": [0.2379, 0.5247, 0.2769, 0.5461]}, {"w": "system’s", "b": [0.2836, 0.5247, 0.3493, 0.5461]}, {"w": "performance", "b": [0.356, 0.5247, 0.4633, 0.5461]}, {"w": "will", "b": [0.47, 0.5247, 0.5004, 0.5461]}, {"w": "require", "b": [0.507, 0.5247, 0.5675, 0.5461]}, {"w": "sampling", "b": [0.5742, 0.5247, 0.6505, 0.5461]}, {"w": "the", "b": [0.6572, 0.5247, 0.6836, 0.5461]}, {"w": "system’s", "b": [0.6902, 0.5247, 0.756, 0.5461]}, {"w": "predictions", "b": [0.7627, 0.5247, 0.8572, 0.5461]}, {"w": "and", "b": [0.1429, 0.5438, 0.1744, 0.5652]}, {"w": "evaluating", "b": [0.1826, 0.5438, 0.2685, 0.5652]}, {"w": "them.", "b": [0.2767, 0.5438, 0.3249, 0.5652]}, {"w": "This", "b": [0.3331, 0.5438, 0.3703, 0.5652]}, {"w": "will", "b": [0.3786, 0.5438, 0.4089, 0.5652]}, {"w": "generally", "b": [0.4172, 0.5438, 0.493, 0.5652]}, {"w": "require", "b": [0.5013, 0.5438, 0.5617, 0.5652]}, {"w": "a", "b": [0.57, 0.5438, 0.5791, 0.5652]}, {"w": "human", "b": [0.5874, 0.5438, 0.6468, 0.5652]}, {"w": "analysis.", "b": [0.655, 0.5438, 0.7252, 0.5652]}, {"w": "These", "b": [0.7334, 0.5438, 0.7827, 0.5652]}, {"w": "analysts", "b": [0.791, 0.5438, 0.8571, 0.5652]}, {"w": "may", "b": [0.1429, 0.5628, 0.1782, 0.5842]}, {"w": "be", "b": [0.1873, 0.5628, 0.2068, 0.5842]}, {"w": "field", "b": [0.2159, 0.5628, 0.2527, 0.5842]}, {"w": "experts,", "b": [0.2618, 0.5628, 0.3267, 0.5842]}, {"w": "or", "b": [0.3358, 0.5628, 0.3542, 0.5842]}, {"w": "workers", "b": [0.3633, 0.5628, 0.4305, 0.5842]}, {"w": "on", "b": [0.4395, 0.5628, 0.4616, 0.5842]}, {"w": "a", "b": [0.4706, 0.5628, 0.4798, 0.5842]}, {"w": "crowdsourcing", "b": [0.4889, 0.5628, 0.6139, 0.5842]}, {"w": "platform", "b": [0.623, 0.5628, 0.6959, 0.5842]}, {"w": "(such", "b": [0.705, 0.5628, 0.7508, 0.5842]}, {"w": "as", "b": [0.7599, 0.5628, 0.7767, 0.5842]}, {"w": "Amazon", "b": [0.7858, 0.5628, 0.8571, 0.5842]}, {"w": "Mechanical", "b": [0.1428, 0.5819, 0.239, 0.6033]}, {"w": "Turk", "b": [0.2452, 0.5819, 0.2851, 0.6033]}, {"w": "or", "b": [0.2913, 0.5819, 0.3096, 0.6033]}, {"w": "CrowdFlower).", "b": [0.3157, 0.5819, 0.443, 0.6033]}, {"w": "Either", "b": [0.4491, 0.5819, 0.5006, 0.6033]}, {"w": "way,", "b": [0.5067, 0.5819, 0.5425, 0.6033]}, {"w": "you", "b": [0.5487, 0.5819, 0.5799, 0.6033]}, {"w": "need", "b": [0.5861, 0.5819, 0.6262, 0.6033]}, {"w": "to", "b": [0.6323, 0.5819, 0.6493, 0.6033]}, {"w": "plug", "b": [0.6554, 0.5819, 0.6924, 0.6033]}, {"w": "the", "b": [0.6986, 0.5819, 0.7249, 0.6033]}, {"w": "human", "b": [0.7311, 0.5819, 0.7905, 0.6033]}, {"w": "evalua‐", "b": [0.7966, 0.5819, 0.8571, 0.6033]}, {"w": "tion", "b": [0.1429, 0.6009, 0.1768, 0.6223]}, {"w": "pipeline", "b": [0.1816, 0.6009, 0.2489, 0.6223]}, {"w": "into", "b": [0.2537, 0.6009, 0.2872, 0.6223]}, {"w": "your", "b": [0.2919, 0.6009, 0.3309, 0.6223]}, {"w": "system.", "b": [0.3357, 0.6009, 0.3975, 0.6223]}]}, {"id": "b_6", "type": "paragraph", "text": "You should also make sure you evaluate the system’s input data quality. Sometimes performance will degrade slightly because of a poor quality signal (e.g., a malfunc‐ tioning sensor sending random values, or another team’s output becoming stale), but it may take a while before your system’s performance degrades enough to trigger an alert. If you monitor your system’s inputs, you may catch this earlier. Monitoring the inputs is particularly important for online learning systems.", "words": [{"w": "You", "b": [0.1429, 0.629, 0.1752, 0.6504]}, {"w": "should", "b": [0.1825, 0.629, 0.2392, 0.6504]}, {"w": "also", "b": [0.2466, 0.629, 0.2792, 0.6504]}, {"w": "make", "b": [0.2865, 0.629, 0.3319, 0.6504]}, {"w": "sure", "b": [0.3392, 0.629, 0.3745, 0.6504]}, {"w": "you", "b": [0.3818, 0.629, 0.4131, 0.6504]}, {"w": "evaluate", "b": [0.4204, 0.629, 0.4883, 0.6504]}, {"w": "the", "b": [0.4956, 0.629, 0.522, 0.6504]}, {"w": "system’s", "b": [0.5293, 0.629, 0.595, 0.6504]}, {"w": "input", "b": [0.6023, 0.629, 0.6472, 0.6504]}, {"w": "data", "b": [0.6545, 0.629, 0.6898, 0.6504]}, {"w": "quality.", "b": [0.6971, 0.629, 0.7579, 0.6504]}, {"w": "Sometimes", "b": [0.7652, 0.629, 0.8571, 0.6504]}, {"w": "performance", "b": [0.1429, 0.6481, 0.2501, 0.6695]}, {"w": "will", "b": [0.2575, 0.6481, 0.2879, 0.6695]}, {"w": "degrade", "b": [0.2952, 0.6481, 0.3615, 0.6695]}, {"w": "slightly", "b": [0.3688, 0.6481, 0.429, 0.6695]}, {"w": "because", "b": [0.4363, 0.6481, 0.5009, 0.6695]}, {"w": "of", "b": [0.5082, 0.6481, 0.525, 0.6695]}, {"w": "a", "b": [0.5323, 0.6481, 0.5414, 0.6695]}, {"w": "poor", "b": [0.5487, 0.6481, 0.5886, 0.6695]}, {"w": "quality", "b": [0.5959, 0.6481, 0.6536, 0.6695]}, {"w": "signal", "b": [0.6609, 0.6481, 0.7097, 0.6695]}, {"w": "(e.g.,", "b": [0.717, 0.6481, 0.757, 0.6695]}, {"w": "a", "b": [0.7644, 0.6481, 0.7735, 0.6695]}, {"w": "malfunc‐", "b": [0.7808, 0.6481, 0.8571, 0.6695]}, {"w": "tioning", "b": [0.1429, 0.6671, 0.2035, 0.6885]}, {"w": "sensor", "b": [0.2091, 0.6671, 0.263, 0.6885]}, {"w": "sending", "b": [0.2685, 0.6671, 0.3341, 0.6885]}, {"w": "random", "b": [0.3397, 0.6671, 0.4066, 0.6885]}, {"w": "values,", "b": [0.4122, 0.6671, 0.4685, 0.6885]}, {"w": "or", "b": [0.4741, 0.6671, 0.4924, 0.6885]}, {"w": "another", "b": [0.4979, 0.6671, 0.5632, 0.6885]}, {"w": "team’s", "b": [0.5687, 0.6671, 0.6187, 0.6885]}, {"w": "output", "b": [0.6243, 0.6671, 0.6806, 0.6885]}, {"w": "becoming", "b": [0.6862, 0.6671, 0.7688, 0.6885]}, {"w": "stale),", "b": [0.7744, 0.6671, 0.8236, 0.6885]}, {"w": "but", "b": [0.8291, 0.6671, 0.8571, 0.6885]}, {"w": "it", "b": [0.1429, 0.6862, 0.1548, 0.7076]}, {"w": "may", "b": [0.1612, 0.6862, 0.1966, 0.7076]}, {"w": "take", "b": [0.203, 0.6862, 0.2377, 0.7076]}, {"w": "a", "b": [0.2441, 0.6862, 0.2532, 0.7076]}, {"w": "while", "b": [0.2596, 0.6862, 0.3047, 0.7076]}, {"w": "before", "b": [0.3111, 0.6862, 0.3639, 0.7076]}, {"w": "your", "b": [0.3703, 0.6862, 0.4093, 0.7076]}, {"w": "system’s", "b": [0.4157, 0.6862, 0.4814, 0.7076]}, {"w": "performance", "b": [0.4878, 0.6862, 0.5951, 0.7076]}, {"w": "degrades", "b": [0.6015, 0.6862, 0.6755, 0.7076]}, {"w": "enough", "b": [0.6819, 0.6862, 0.7447, 0.7076]}, {"w": "to", "b": [0.7511, 0.6862, 0.7681, 0.7076]}, {"w": "trigger", "b": [0.7745, 0.6862, 0.8302, 0.7076]}, {"w": "an", "b": [0.8366, 0.6862, 0.8572, 0.7076]}, {"w": "alert.", "b": [0.1429, 0.7052, 0.185, 0.7266]}, {"w": "If", "b": [0.1907, 0.7052, 0.204, 0.7266]}, {"w": "you", "b": [0.2098, 0.7052, 0.241, 0.7266]}, {"w": "monitor", "b": [0.2468, 0.7052, 0.3162, 0.7266]}, {"w": "your", "b": [0.322, 0.7052, 0.3609, 0.7266]}, {"w": "system’s", "b": [0.3667, 0.7052, 0.4324, 0.7266]}, {"w": "inputs,", "b": [0.4382, 0.7052, 0.4955, 0.7266]}, {"w": "you", "b": [0.5013, 0.7052, 0.5325, 0.7266]}, {"w": "may", "b": [0.5383, 0.7052, 0.5737, 0.7266]}, {"w": "catch", "b": [0.5795, 0.7052, 0.6233, 0.7266]}, {"w": "this", "b": [0.6291, 0.7052, 0.6598, 0.7266]}, {"w": "earlier.", "b": [0.6656, 0.7052, 0.7222, 0.7266]}, {"w": "Monitoring", "b": [0.728, 0.7052, 0.825, 0.7266]}, {"w": "the", "b": [0.8308, 0.7052, 0.8571, 0.7266]}, {"w": "inputs", "b": [0.1429, 0.7243, 0.1954, 0.7457]}, {"w": "is", "b": [0.2001, 0.7243, 0.2134, 0.7457]}, {"w": "particularly", "b": [0.2181, 0.7243, 0.3147, 0.7457]}, {"w": "important", "b": [0.3194, 0.7243, 0.4038, 0.7457]}, {"w": "for", "b": [0.4085, 0.7243, 0.433, 0.7457]}, {"w": "online", "b": [0.4378, 0.7243, 0.4909, 0.7457]}, {"w": "learning", "b": [0.4956, 0.7243, 0.5647, 0.7457]}, {"w": "systems.", "b": [0.5695, 0.7243, 0.639, 0.7457]}]}, {"id": "b_7", "type": "paragraph", "text": "Finally, you will generally want to train your models on a regular basis using fresh data. You should automate this process as much as possible. If you don’t, you are very likely to refresh your model only every six months (at best), and your system’s perfor‐ mance may fluctuate severely over time. If your system is an online learning system, you should make sure you save snapshots of its state at regular intervals so you can easily roll back to a previously working state.", "words": [{"w": "Finally,", "b": [0.1429, 0.7524, 0.2033, 0.7738]}, {"w": "you", "b": [0.2105, 0.7524, 0.2418, 0.7738]}, {"w": "will", "b": [0.249, 0.7524, 0.2794, 0.7738]}, {"w": "generally", "b": [0.2865, 0.7524, 0.3624, 0.7738]}, {"w": "want", "b": [0.3696, 0.7524, 0.4103, 0.7738]}, {"w": "to", "b": [0.4175, 0.7524, 0.4345, 0.7738]}, {"w": "train", "b": [0.4417, 0.7524, 0.4819, 0.7738]}, {"w": "your", "b": [0.4891, 0.7524, 0.5281, 0.7738]}, {"w": "models", "b": [0.5353, 0.7524, 0.5957, 0.7738]}, {"w": "on", "b": [0.6029, 0.7524, 0.6249, 0.7738]}, {"w": "a", "b": [0.6321, 0.7524, 0.6413, 0.7738]}, {"w": "regular", "b": [0.6485, 0.7524, 0.708, 0.7738]}, {"w": "basis", "b": [0.7152, 0.7524, 0.7558, 0.7738]}, {"w": "using", "b": [0.763, 0.7524, 0.8084, 0.7738]}, {"w": "fresh", "b": [0.8156, 0.7524, 0.8571, 0.7738]}, {"w": "data.", "b": [0.1428, 0.7714, 0.1828, 0.7928]}, {"w": "You", "b": [0.188, 0.7714, 0.2203, 0.7928]}, {"w": "should", "b": [0.2255, 0.7714, 0.2822, 0.7928]}, {"w": "automate", "b": [0.2873, 0.7714, 0.3652, 0.7928]}, {"w": "this", "b": [0.3703, 0.7714, 0.401, 0.7928]}, {"w": "process", "b": [0.4061, 0.7714, 0.4684, 0.7928]}, {"w": "as", "b": [0.4735, 0.7714, 0.4903, 0.7928]}, {"w": "much", "b": [0.4954, 0.7714, 0.5431, 0.7928]}, {"w": "as", "b": [0.5482, 0.7714, 0.565, 0.7928]}, {"w": "possible.", "b": [0.5702, 0.7714, 0.6421, 0.7928]}, {"w": "If", "b": [0.6472, 0.7714, 0.6605, 0.7928]}, {"w": "you", "b": [0.6656, 0.7714, 0.6969, 0.7928]}, {"w": "don’t,", "b": [0.702, 0.7714, 0.7483, 0.7928]}, {"w": "you", "b": [0.7535, 0.7714, 0.7847, 0.7928]}, {"w": "are", "b": [0.7899, 0.7714, 0.8156, 0.7928]}, {"w": "very", "b": [0.8207, 0.7714, 0.8571, 0.7928]}, {"w": "likely", "b": [0.1429, 0.7905, 0.1877, 0.8119]}, {"w": "to", "b": [0.1927, 0.7905, 0.2097, 0.8119]}, {"w": "refresh", "b": [0.2147, 0.7905, 0.2728, 0.8119]}, {"w": "your", "b": [0.2779, 0.7905, 0.3168, 0.8119]}, {"w": "model", "b": [0.3218, 0.7905, 0.3747, 0.8119]}, {"w": "only", "b": [0.3797, 0.7905, 0.4165, 0.8119]}, {"w": "every", "b": [0.4215, 0.7905, 0.4668, 0.8119]}, {"w": "six", "b": [0.4718, 0.7905, 0.4949, 0.8119]}, {"w": "months", "b": [0.4999, 0.7905, 0.5637, 0.8119]}, {"w": "(at", "b": [0.5687, 0.7905, 0.591, 0.8119]}, {"w": "best),", "b": [0.596, 0.7905, 0.6414, 0.8119]}, {"w": "and", "b": [0.6464, 0.7905, 0.678, 0.8119]}, {"w": "your", "b": [0.683, 0.7905, 0.722, 0.8119]}, {"w": "system’s", "b": [0.727, 0.7905, 0.7927, 0.8119]}, {"w": "perfor‐", "b": [0.7977, 0.7905, 0.8571, 0.8119]}, {"w": "mance", "b": [0.1429, 0.8095, 0.1981, 0.8309]}, {"w": "may", "b": [0.2041, 0.8095, 0.2395, 0.8309]}, {"w": "fluctuate", "b": [0.2455, 0.8095, 0.3182, 0.8309]}, {"w": "severely", "b": [0.3242, 0.8095, 0.3906, 0.8309]}, {"w": "over", "b": [0.3966, 0.8095, 0.4334, 0.8309]}, {"w": "time.", "b": [0.4394, 0.8095, 0.482, 0.8309]}, {"w": "If", "b": [0.488, 0.8095, 0.5013, 0.8309]}, {"w": "your", "b": [0.5072, 0.8095, 0.5462, 0.8309]}, {"w": "system", "b": [0.5522, 0.8095, 0.6093, 0.8309]}, {"w": "is", "b": [0.6153, 0.8095, 0.6285, 0.8309]}, {"w": "an", "b": [0.6345, 0.8095, 0.6551, 0.8309]}, {"w": "online", "b": [0.6611, 0.8095, 0.7142, 0.8309]}, {"w": "learning", "b": [0.7202, 0.8095, 0.7893, 0.8309]}, {"w": "system,", "b": [0.7953, 0.8095, 0.8571, 0.8309]}, {"w": "you", "b": [0.1429, 0.8286, 0.1741, 0.85]}, {"w": "should", "b": [0.1806, 0.8286, 0.2373, 0.85]}, {"w": "make", "b": [0.2439, 0.8286, 0.2892, 0.85]}, {"w": "sure", "b": [0.2958, 0.8286, 0.331, 0.85]}, {"w": "you", "b": [0.3376, 0.8286, 0.3688, 0.85]}, {"w": "save", "b": [0.3753, 0.8286, 0.4102, 0.85]}, {"w": "snapshots", "b": [0.4167, 0.8286, 0.4989, 0.85]}, {"w": "of", "b": [0.5054, 0.8286, 0.5222, 0.85]}, {"w": "its", "b": [0.5287, 0.8286, 0.5482, 0.85]}, {"w": "state", "b": [0.5548, 0.8286, 0.5927, 0.85]}, {"w": "at", "b": [0.5992, 0.8286, 0.6143, 0.85]}, {"w": "regular", "b": [0.6208, 0.8286, 0.6804, 0.85]}, {"w": "intervals", "b": [0.6869, 0.8286, 0.7587, 0.85]}, {"w": "so", "b": [0.7652, 0.8286, 0.7835, 0.85]}, {"w": "you", "b": [0.79, 0.8286, 0.8213, 0.85]}, {"w": "can", "b": [0.8278, 0.8286, 0.8571, 0.85]}, {"w": "easily", "b": [0.1429, 0.8476, 0.1889, 0.869]}, {"w": "roll", "b": [0.1937, 0.8476, 0.2226, 0.869]}, {"w": "back", "b": [0.2273, 0.8476, 0.2662, 0.869]}, {"w": "to", "b": [0.2709, 0.8476, 0.2879, 0.869]}, {"w": "a", "b": [0.2926, 0.8476, 0.3017, 0.869]}, {"w": "previously", "b": [0.3065, 0.8476, 0.3934, 0.869]}, {"w": "working", "b": [0.3981, 0.8476, 0.4678, 0.869]}, {"w": "state.", "b": [0.4725, 0.8476, 0.5152, 0.869]}]}, {"id": "b_8", "type": "equation", "text": "84 | Chapter 2: End-to-End Machine Learning Project", "words": [{"w": "84", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "2:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "End-to-End", "b": [0.26, 0.9225, 0.3261, 0.9388]}, {"w": "Machine", "b": [0.3289, 0.9225, 0.3788, 0.9388]}, {"w": "Learning", "b": [0.3817, 0.9225, 0.4339, 0.9388]}, {"w": "Project", "b": [0.4367, 0.9225, 0.4781, 0.9388]}]}]}, {"page": 111, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Try It Out!", "words": [{"w": "Try", "b": [0.1429, 0.0753, 0.1811, 0.1095]}, {"w": "It", "b": [0.187, 0.0753, 0.2063, 0.1095]}, {"w": "Out!", "b": [0.2122, 0.0753, 0.2648, 0.1095]}]}, {"id": "b_1", "type": "paragraph", "text": "Hopefully this chapter gave you a good idea of what a Machine Learning project looks like, and showed you some of the tools you can use to train a great system. As you can see, much of the work is in the data preparation step, building monitoring tools, setting up human evaluation pipelines, and automating regular model training. The Machine Learning algorithms are also important, of course, but it is probably preferable to be comfortable with the overall process and know three or four algo‐ rithms well rather than to spend all your time exploring advanced algorithms and not enough time on the overall process.", "words": [{"w": "Hopefully", "b": [0.1428, 0.1164, 0.226, 0.1378]}, {"w": "this", "b": [0.2345, 0.1164, 0.2652, 0.1378]}, {"w": "chapter", "b": [0.2737, 0.1164, 0.3363, 0.1378]}, {"w": "gave", "b": [0.3448, 0.1164, 0.3818, 0.1378]}, {"w": "you", "b": [0.3903, 0.1164, 0.4216, 0.1378]}, {"w": "a", "b": [0.4301, 0.1164, 0.4392, 0.1378]}, {"w": "good", "b": [0.4477, 0.1164, 0.4897, 0.1378]}, {"w": "idea", "b": [0.4982, 0.1164, 0.5328, 0.1378]}, {"w": "of", "b": [0.5413, 0.1164, 0.5581, 0.1378]}, {"w": "what", "b": [0.5666, 0.1164, 0.6071, 0.1378]}, {"w": "a", "b": [0.6156, 0.1164, 0.6248, 0.1378]}, {"w": "Machine", "b": [0.6333, 0.1164, 0.7064, 0.1378]}, {"w": "Learning", "b": [0.7149, 0.1164, 0.79, 0.1378]}, {"w": "project", "b": [0.7985, 0.1164, 0.8571, 0.1378]}, {"w": "looks", "b": [0.1429, 0.1355, 0.1874, 0.1569]}, {"w": "like,", "b": [0.1933, 0.1355, 0.2281, 0.1569]}, {"w": "and", "b": [0.234, 0.1355, 0.2656, 0.1569]}, {"w": "showed", "b": [0.2715, 0.1355, 0.335, 0.1569]}, {"w": "you", "b": [0.341, 0.1355, 0.3722, 0.1569]}, {"w": "some", "b": [0.3782, 0.1355, 0.4224, 0.1569]}, {"w": "of", "b": [0.4283, 0.1355, 0.4451, 0.1569]}, {"w": "the", "b": [0.451, 0.1355, 0.4774, 0.1569]}, {"w": "tools", "b": [0.4833, 0.1355, 0.5238, 0.1569]}, {"w": "you", "b": [0.5298, 0.1355, 0.561, 0.1569]}, {"w": "can", "b": [0.567, 0.1355, 0.5963, 0.1569]}, {"w": "use", "b": [0.6023, 0.1355, 0.6298, 0.1569]}, {"w": "to", "b": [0.6358, 0.1355, 0.6527, 0.1569]}, {"w": "train", "b": [0.6587, 0.1355, 0.6989, 0.1569]}, {"w": "a", "b": [0.7048, 0.1355, 0.714, 0.1569]}, {"w": "great", "b": [0.7199, 0.1355, 0.7614, 0.1569]}, {"w": "system.", "b": [0.7673, 0.1355, 0.8292, 0.1569]}, {"w": "As", "b": [0.8351, 0.1355, 0.8571, 0.1569]}, {"w": "you", "b": [0.1429, 0.1545, 0.1741, 0.1759]}, {"w": "can", "b": [0.1809, 0.1545, 0.2103, 0.1759]}, {"w": "see,", "b": [0.2171, 0.1545, 0.2472, 0.1759]}, {"w": "much", "b": [0.2541, 0.1545, 0.3018, 0.1759]}, {"w": "of", "b": [0.3086, 0.1545, 0.3254, 0.1759]}, {"w": "the", "b": [0.3322, 0.1545, 0.3586, 0.1759]}, {"w": "work", "b": [0.3654, 0.1545, 0.4084, 0.1759]}, {"w": "is", "b": [0.4152, 0.1545, 0.4284, 0.1759]}, {"w": "in", "b": [0.4353, 0.1545, 0.4523, 0.1759]}, {"w": "the", "b": [0.4591, 0.1545, 0.4854, 0.1759]}, {"w": "data", "b": [0.4923, 0.1545, 0.5275, 0.1759]}, {"w": "preparation", "b": [0.5344, 0.1545, 0.6324, 0.1759]}, {"w": "step,", "b": [0.6392, 0.1545, 0.6771, 0.1759]}, {"w": "building", "b": [0.684, 0.1545, 0.7542, 0.1759]}, {"w": "monitoring", "b": [0.761, 0.1545, 0.8571, 0.1759]}, {"w": "tools,", "b": [0.1429, 0.1736, 0.1881, 0.195]}, {"w": "setting", "b": [0.1935, 0.1736, 0.2495, 0.195]}, {"w": "up", "b": [0.2549, 0.1736, 0.2768, 0.195]}, {"w": "human", "b": [0.2822, 0.1736, 0.3416, 0.195]}, {"w": "evaluation", "b": [0.347, 0.1736, 0.4337, 0.195]}, {"w": "pipelines,", "b": [0.4391, 0.1736, 0.5189, 0.195]}, {"w": "and", "b": [0.5243, 0.1736, 0.5558, 0.195]}, {"w": "automating", "b": [0.5612, 0.1736, 0.6569, 0.195]}, {"w": "regular", "b": [0.6623, 0.1736, 0.7218, 0.195]}, {"w": "model", "b": [0.7272, 0.1736, 0.7801, 0.195]}, {"w": "training.", "b": [0.7854, 0.1736, 0.8571, 0.195]}, {"w": "The", "b": [0.1429, 0.1926, 0.1757, 0.214]}, {"w": "Machine", "b": [0.1833, 0.1926, 0.2565, 0.214]}, {"w": "Learning", "b": [0.2641, 0.1926, 0.3392, 0.214]}, {"w": "algorithms", "b": [0.3468, 0.1926, 0.4371, 0.214]}, {"w": "are", "b": [0.4447, 0.1926, 0.4704, 0.214]}, {"w": "also", "b": [0.4781, 0.1926, 0.5108, 0.214]}, {"w": "important,", "b": [0.5184, 0.1926, 0.6075, 0.214]}, {"w": "of", "b": [0.6151, 0.1926, 0.6319, 0.214]}, {"w": "course,", "b": [0.6396, 0.1926, 0.699, 0.214]}, {"w": "but", "b": [0.7067, 0.1926, 0.7347, 0.214]}, {"w": "it", "b": [0.7423, 0.1926, 0.7542, 0.214]}, {"w": "is", "b": [0.7619, 0.1926, 0.7751, 0.214]}, {"w": "probably", "b": [0.7827, 0.1926, 0.8572, 0.214]}, {"w": "preferable", "b": [0.1429, 0.2117, 0.227, 0.2331]}, {"w": "to", "b": [0.2341, 0.2117, 0.2511, 0.2331]}, {"w": "be", "b": [0.2582, 0.2117, 0.2777, 0.2331]}, {"w": "comfortable", "b": [0.2848, 0.2117, 0.386, 0.2331]}, {"w": "with", "b": [0.3932, 0.2117, 0.4305, 0.2331]}, {"w": "the", "b": [0.4377, 0.2117, 0.464, 0.2331]}, {"w": "overall", "b": [0.4711, 0.2117, 0.5277, 0.2331]}, {"w": "process", "b": [0.5348, 0.2117, 0.5971, 0.2331]}, {"w": "and", "b": [0.6042, 0.2117, 0.6357, 0.2331]}, {"w": "know", "b": [0.6429, 0.2117, 0.6895, 0.2331]}, {"w": "three", "b": [0.6967, 0.2117, 0.7396, 0.2331]}, {"w": "or", "b": [0.7467, 0.2117, 0.7651, 0.2331]}, {"w": "four", "b": [0.7722, 0.2117, 0.8078, 0.2331]}, {"w": "algo‐", "b": [0.8149, 0.2117, 0.8571, 0.2331]}, {"w": "rithms", "b": [0.1429, 0.2307, 0.1984, 0.2521]}, {"w": "well", "b": [0.2033, 0.2307, 0.237, 0.2521]}, {"w": "rather", "b": [0.2419, 0.2307, 0.2924, 0.2521]}, {"w": "than", "b": [0.2974, 0.2307, 0.3354, 0.2521]}, {"w": "to", "b": [0.3403, 0.2307, 0.3573, 0.2521]}, {"w": "spend", "b": [0.3622, 0.2307, 0.412, 0.2521]}, {"w": "all", "b": [0.4169, 0.2307, 0.4366, 0.2521]}, {"w": "your", "b": [0.4416, 0.2307, 0.4805, 0.2521]}, {"w": "time", "b": [0.4855, 0.2307, 0.5233, 0.2521]}, {"w": "exploring", "b": [0.5283, 0.2307, 0.6082, 0.2521]}, {"w": "advanced", "b": [0.6131, 0.2307, 0.6921, 0.2521]}, {"w": "algorithms", "b": [0.6971, 0.2307, 0.7874, 0.2521]}, {"w": "and", "b": [0.7923, 0.2307, 0.8238, 0.2521]}, {"w": "not", "b": [0.8288, 0.2307, 0.8571, 0.2521]}, {"w": "enough", "b": [0.1428, 0.2498, 0.2057, 0.2712]}, {"w": "time", "b": [0.2104, 0.2498, 0.2482, 0.2712]}, {"w": "on", "b": [0.253, 0.2498, 0.275, 0.2712]}, {"w": "the", "b": [0.2797, 0.2498, 0.3061, 0.2712]}, {"w": "overall", "b": [0.3108, 0.2498, 0.3673, 0.2712]}, {"w": "process.", "b": [0.3721, 0.2498, 0.439, 0.2712]}]}, {"id": "b_2", "type": "paragraph", "text": "So, if you have not already done so, now is a good time to pick up a laptop, select a dataset that you are interested in, and try to go through the whole process from A to Z. A good place to start is on a competition website such as http://kaggle.com/: you will have a dataset to play with, a clear goal, and people to share the experience with.", "words": [{"w": "So,", "b": [0.1428, 0.2779, 0.1675, 0.2993]}, {"w": "if", "b": [0.1738, 0.2779, 0.1856, 0.2993]}, {"w": "you", "b": [0.1919, 0.2779, 0.2232, 0.2993]}, {"w": "have", "b": [0.2295, 0.2779, 0.2679, 0.2993]}, {"w": "not", "b": [0.2743, 0.2779, 0.3027, 0.2993]}, {"w": "already", "b": [0.309, 0.2779, 0.3697, 0.2993]}, {"w": "done", "b": [0.3761, 0.2779, 0.418, 0.2993]}, {"w": "so,", "b": [0.4243, 0.2779, 0.4467, 0.2993]}, {"w": "now", "b": [0.4531, 0.2779, 0.4894, 0.2993]}, {"w": "is", "b": [0.4957, 0.2779, 0.509, 0.2993]}, {"w": "a", "b": [0.5153, 0.2779, 0.5244, 0.2993]}, {"w": "good", "b": [0.5308, 0.2779, 0.5728, 0.2993]}, {"w": "time", "b": [0.5792, 0.2779, 0.617, 0.2993]}, {"w": "to", "b": [0.6234, 0.2779, 0.6403, 0.2993]}, {"w": "pick", "b": [0.6467, 0.2779, 0.6823, 0.2993]}, {"w": "up", "b": [0.6887, 0.2779, 0.7107, 0.2993]}, {"w": "a", "b": [0.717, 0.2779, 0.7262, 0.2993]}, {"w": "laptop,", "b": [0.7325, 0.2779, 0.7895, 0.2993]}, {"w": "select", "b": [0.7958, 0.2779, 0.8416, 0.2993]}, {"w": "a", "b": [0.848, 0.2779, 0.8571, 0.2993]}, {"w": "dataset", "b": [0.1429, 0.2969, 0.201, 0.3183]}, {"w": "that", "b": [0.2066, 0.2969, 0.2392, 0.3183]}, {"w": "you", "b": [0.2448, 0.2969, 0.2761, 0.3183]}, {"w": "are", "b": [0.2817, 0.2969, 0.3074, 0.3183]}, {"w": "interested", "b": [0.313, 0.2969, 0.3953, 0.3183]}, {"w": "in,", "b": [0.4009, 0.2969, 0.4226, 0.3183]}, {"w": "and", "b": [0.4283, 0.2969, 0.4598, 0.3183]}, {"w": "try", "b": [0.4654, 0.2969, 0.4897, 0.3183]}, {"w": "to", "b": [0.4953, 0.2969, 0.5123, 0.3183]}, {"w": "go", "b": [0.5179, 0.2969, 0.5383, 0.3183]}, {"w": "through", "b": [0.5439, 0.2969, 0.6117, 0.3183]}, {"w": "the", "b": [0.6173, 0.2969, 0.6437, 0.3183]}, {"w": "whole", "b": [0.6493, 0.2969, 0.6994, 0.3183]}, {"w": "process", "b": [0.7051, 0.2969, 0.7673, 0.3183]}, {"w": "from", "b": [0.7729, 0.2969, 0.8145, 0.3183]}, {"w": "A", "b": [0.8201, 0.2969, 0.8345, 0.3183]}, {"w": "to", "b": [0.8402, 0.2969, 0.8571, 0.3183]}, {"w": "Z.", "b": [0.1429, 0.316, 0.1602, 0.3374]}, {"w": "A", "b": [0.167, 0.316, 0.1814, 0.3374]}, {"w": "good", "b": [0.1883, 0.316, 0.2303, 0.3374]}, {"w": "place", "b": [0.2371, 0.316, 0.2801, 0.3374]}, {"w": "to", "b": [0.287, 0.316, 0.304, 0.3374]}, {"w": "start", "b": [0.3108, 0.316, 0.3481, 0.3374]}, {"w": "is", "b": [0.3549, 0.316, 0.3681, 0.3374]}, {"w": "on", "b": [0.375, 0.316, 0.397, 0.3374]}, {"w": "a", "b": [0.4039, 0.316, 0.413, 0.3374]}, {"w": "competition", "b": [0.4199, 0.316, 0.5217, 0.3374]}, {"w": "website", "b": [0.5285, 0.316, 0.5907, 0.3374]}, {"w": "such", "b": [0.5975, 0.316, 0.6362, 0.3374]}, {"w": "as", "b": [0.643, 0.316, 0.6598, 0.3374]}, {"w": "http://kaggle.com/:", "b": [0.6667, 0.3158, 0.819, 0.3374]}, {"w": "you", "b": [0.8259, 0.316, 0.8571, 0.3374]}, {"w": "will", "b": [0.1429, 0.335, 0.1732, 0.3564]}, {"w": "have", "b": [0.178, 0.335, 0.2164, 0.3564]}, {"w": "a", "b": [0.2211, 0.335, 0.2302, 0.3564]}, {"w": "dataset", "b": [0.235, 0.335, 0.2931, 0.3564]}, {"w": "to", "b": [0.2978, 0.335, 0.3148, 0.3564]}, {"w": "play", "b": [0.3195, 0.335, 0.354, 0.3564]}, {"w": "with,", "b": [0.3588, 0.335, 0.4009, 0.3564]}, {"w": "a", "b": [0.4056, 0.335, 0.4147, 0.3564]}, {"w": "clear", "b": [0.4195, 0.335, 0.4593, 0.3564]}, {"w": "goal,", "b": [0.464, 0.335, 0.5035, 0.3564]}, {"w": "and", "b": [0.5083, 0.335, 0.5398, 0.3564]}, {"w": "people", "b": [0.5445, 0.335, 0.6, 0.3564]}, {"w": "to", "b": [0.6047, 0.335, 0.6217, 0.3564]}, {"w": "share", "b": [0.6264, 0.335, 0.6709, 0.3564]}, {"w": "the", "b": [0.6756, 0.335, 0.702, 0.3564]}, {"w": "experience", "b": [0.7067, 0.335, 0.7964, 0.3564]}, {"w": "with.", "b": [0.8011, 0.335, 0.8432, 0.3564]}]}, {"id": "b_3", "type": "paragraph", "text": "Exercises", "words": [{"w": "Exercises", "b": [0.1429, 0.3694, 0.2533, 0.4037]}]}, {"id": "b_4", "type": "paragraph", "text": "Using this chapter’s housing dataset:", "words": [{"w": "Using", "b": [0.1429, 0.4106, 0.1915, 0.432]}, {"w": "this", "b": [0.1962, 0.4106, 0.2269, 0.432]}, {"w": "chapter’s", "b": [0.2316, 0.4106, 0.3045, 0.432]}, {"w": "housing", "b": [0.3092, 0.4106, 0.3764, 0.432]}, {"w": "dataset:", "b": [0.3811, 0.4106, 0.444, 0.432]}]}, {"id": "b_5", "type": "paragraph", "text": "1. Try a Support Vector Machine regressor (sklearn.svm.SVR), with various hyper‐ parameters such as kernel=\"linear\" (with various values for the C hyperpara‐ meter) or kernel=\"rbf\" (with various values for the C and gamma hyperparameters). Don’t worry about what these hyperparameters mean for now. How does the best SVR predictor perform?", "words": [{"w": "1.", "b": [0.1534, 0.4457, 0.1682, 0.4671]}, {"w": "Try", "b": [0.1786, 0.4457, 0.2076, 0.4671]}, {"w": "a", "b": [0.2128, 0.4457, 0.2219, 0.4671]}, {"w": "Support", "b": [0.2271, 0.4457, 0.2946, 0.4671]}, {"w": "Vector", "b": [0.2998, 0.4457, 0.3548, 0.4671]}, {"w": "Machine", "b": [0.36, 0.4457, 0.4331, 0.4671]}, {"w": "regressor", "b": [0.4383, 0.4457, 0.5149, 0.4671]}, {"w": "(sklearn.svm.SVR),", "b": [0.5201, 0.4457, 0.6877, 0.4671]}, {"w": "with", "b": [0.6929, 0.4457, 0.7302, 0.4671]}, {"w": "various", "b": [0.7354, 0.4457, 0.7968, 0.4671]}, {"w": "hyper‐", "b": [0.802, 0.4457, 0.8572, 0.4671]}, {"w": "parameters", "b": [0.1786, 0.4656, 0.272, 0.487]}, {"w": "such", "b": [0.2791, 0.4656, 0.3177, 0.487]}, {"w": "as", "b": [0.3248, 0.4656, 0.3416, 0.487]}, {"w": "kernel=\"linear\"", "b": [0.3487, 0.4688, 0.4971, 0.4839]}, {"w": "(with", "b": [0.5042, 0.4656, 0.5488, 0.487]}, {"w": "various", "b": [0.5558, 0.4656, 0.6173, 0.487]}, {"w": "values", "b": [0.6244, 0.4656, 0.676, 0.487]}, {"w": "for", "b": [0.6831, 0.4656, 0.7076, 0.487]}, {"w": "the", "b": [0.7147, 0.4656, 0.741, 0.487]}, {"w": "C", "b": [0.7481, 0.4688, 0.758, 0.4839]}, {"w": "hyperpara‐", "b": [0.7651, 0.4656, 0.8571, 0.487]}, {"w": "meter)", "b": [0.1786, 0.4856, 0.2346, 0.507]}, {"w": "or", "b": [0.2532, 0.4856, 0.2716, 0.507]}, {"w": "kernel=\"rbf\"", "b": [0.2902, 0.4888, 0.409, 0.5038]}, {"w": "(with", "b": [0.4276, 0.4856, 0.4721, 0.507]}, {"w": "various", "b": [0.4907, 0.4856, 0.5521, 0.507]}, {"w": "values", "b": [0.5707, 0.4856, 0.6224, 0.507]}, {"w": "for", "b": [0.641, 0.4856, 0.6655, 0.507]}, {"w": "the", "b": [0.6841, 0.4856, 0.7104, 0.507]}, {"w": "C", "b": [0.729, 0.4888, 0.7389, 0.5038]}, {"w": "and", "b": [0.7575, 0.4856, 0.7891, 0.507]}, {"w": "gamma", "b": [0.8077, 0.4888, 0.8571, 0.5038]}, {"w": "hyperparameters).", "b": [0.1786, 0.5046, 0.3317, 0.526]}, {"w": "Don’t", "b": [0.3368, 0.5046, 0.3827, 0.526]}, {"w": "worry", "b": [0.3879, 0.5046, 0.4384, 0.526]}, {"w": "about", "b": [0.4435, 0.5046, 0.4913, 0.526]}, {"w": "what", "b": [0.4964, 0.5046, 0.5369, 0.526]}, {"w": "these", "b": [0.5421, 0.5046, 0.5849, 0.526]}, {"w": "hyperparameters", "b": [0.5901, 0.5046, 0.7312, 0.526]}, {"w": "mean", "b": [0.7364, 0.5046, 0.7828, 0.526]}, {"w": "for", "b": [0.788, 0.5046, 0.8125, 0.526]}, {"w": "now.", "b": [0.8176, 0.5046, 0.8571, 0.526]}, {"w": "How", "b": [0.1786, 0.5246, 0.2189, 0.546]}, {"w": "does", "b": [0.2236, 0.5246, 0.2618, 0.546]}, {"w": "the", "b": [0.2665, 0.5246, 0.2928, 0.546]}, {"w": "best", "b": [0.2976, 0.5246, 0.331, 0.546]}, {"w": "SVR", "b": [0.3357, 0.5277, 0.3654, 0.5428]}, {"w": "predictor", "b": [0.3701, 0.5246, 0.4477, 0.546]}, {"w": "perform?", "b": [0.4525, 0.5246, 0.5295, 0.546]}]}, {"id": "b_6", "type": "paragraph", "text": "2. Try replacing GridSearchCV with RandomizedSearchCV.", "words": [{"w": "2.", "b": [0.1534, 0.5506, 0.1682, 0.572]}, {"w": "Try", "b": [0.1786, 0.5506, 0.2076, 0.572]}, {"w": "replacing", "b": [0.2123, 0.5506, 0.2898, 0.572]}, {"w": "GridSearchCV", "b": [0.2945, 0.5537, 0.4133, 0.5688]}, {"w": "with", "b": [0.418, 0.5506, 0.4553, 0.572]}, {"w": "RandomizedSearchCV.", "b": [0.46, 0.5506, 0.6429, 0.572]}]}, {"id": "b_7", "type": "paragraph", "text": "3. Try adding a transformer in the preparation pipeline to select only the most important attributes.", "words": [{"w": "3.", "b": [0.1534, 0.5756, 0.1682, 0.5971]}, {"w": "Try", "b": [0.1786, 0.5756, 0.2076, 0.5971]}, {"w": "adding", "b": [0.2164, 0.5756, 0.2743, 0.5971]}, {"w": "a", "b": [0.2831, 0.5756, 0.2922, 0.5971]}, {"w": "transformer", "b": [0.301, 0.5756, 0.4015, 0.5971]}, {"w": "in", "b": [0.4103, 0.5756, 0.4273, 0.5971]}, {"w": "the", "b": [0.4361, 0.5756, 0.4624, 0.5971]}, {"w": "preparation", "b": [0.4712, 0.5756, 0.5692, 0.5971]}, {"w": "pipeline", "b": [0.578, 0.5756, 0.6454, 0.5971]}, {"w": "to", "b": [0.6542, 0.5756, 0.6712, 0.5971]}, {"w": "select", "b": [0.68, 0.5756, 0.7258, 0.5971]}, {"w": "only", "b": [0.7346, 0.5756, 0.7715, 0.5971]}, {"w": "the", "b": [0.7803, 0.5756, 0.8066, 0.5971]}, {"w": "most", "b": [0.8154, 0.5756, 0.8571, 0.5971]}, {"w": "important", "b": [0.1786, 0.5947, 0.2629, 0.6161]}, {"w": "attributes.", "b": [0.2677, 0.5947, 0.3517, 0.6161]}]}, {"id": "b_8", "type": "paragraph", "text": "4. Try creating a single pipeline that does the full data preparation plus the final prediction.", "words": [{"w": "4.", "b": [0.1534, 0.6198, 0.1682, 0.6412]}, {"w": "Try", "b": [0.1786, 0.6198, 0.2076, 0.6412]}, {"w": "creating", "b": [0.2153, 0.6198, 0.2825, 0.6412]}, {"w": "a", "b": [0.2903, 0.6198, 0.2994, 0.6412]}, {"w": "single", "b": [0.3071, 0.6198, 0.3556, 0.6412]}, {"w": "pipeline", "b": [0.3634, 0.6198, 0.4307, 0.6412]}, {"w": "that", "b": [0.4385, 0.6198, 0.4711, 0.6412]}, {"w": "does", "b": [0.4788, 0.6198, 0.5169, 0.6412]}, {"w": "the", "b": [0.5246, 0.6198, 0.551, 0.6412]}, {"w": "full", "b": [0.5587, 0.6198, 0.5865, 0.6412]}, {"w": "data", "b": [0.5942, 0.6198, 0.6294, 0.6412]}, {"w": "preparation", "b": [0.6372, 0.6198, 0.7352, 0.6412]}, {"w": "plus", "b": [0.7429, 0.6198, 0.7778, 0.6412]}, {"w": "the", "b": [0.7855, 0.6198, 0.8118, 0.6412]}, {"w": "final", "b": [0.8196, 0.6198, 0.8571, 0.6412]}, {"w": "prediction.", "b": [0.1786, 0.6388, 0.2702, 0.6602]}]}, {"id": "b_9", "type": "paragraph", "text": "5. Automatically explore some preparation options using GridSearchCV.", "words": [{"w": "5.", "b": [0.1534, 0.6648, 0.1682, 0.6862]}, {"w": "Automatically", "b": [0.1786, 0.6648, 0.296, 0.6862]}, {"w": "explore", "b": [0.3007, 0.6648, 0.3628, 0.6862]}, {"w": "some", "b": [0.3675, 0.6648, 0.4117, 0.6862]}, {"w": "preparation", "b": [0.4164, 0.6648, 0.5144, 0.6862]}, {"w": "options", "b": [0.5191, 0.6648, 0.5823, 0.6862]}, {"w": "using", "b": [0.587, 0.6648, 0.6325, 0.6862]}, {"w": "GridSearchCV.", "b": [0.6372, 0.6648, 0.7607, 0.6862]}]}, {"id": "b_10", "type": "paragraph", "text": "Solutions to these exercises are available in the online Jupyter notebooks at https:// github.com/ageron/handson-ml2.", "words": [{"w": "Solutions", "b": [0.1429, 0.699, 0.2213, 0.7204]}, {"w": "to", "b": [0.2285, 0.699, 0.2455, 0.7204]}, {"w": "these", "b": [0.2527, 0.699, 0.2956, 0.7204]}, {"w": "exercises", "b": [0.3028, 0.699, 0.3766, 0.7204]}, {"w": "are", "b": [0.3838, 0.699, 0.4095, 0.7204]}, {"w": "available", "b": [0.4168, 0.699, 0.489, 0.7204]}, {"w": "in", "b": [0.4962, 0.699, 0.5132, 0.7204]}, {"w": "the", "b": [0.5205, 0.699, 0.5468, 0.7204]}, {"w": "online", "b": [0.554, 0.699, 0.6071, 0.7204]}, {"w": "Jupyter", "b": [0.6144, 0.699, 0.675, 0.7204]}, {"w": "notebooks", "b": [0.6822, 0.699, 0.7693, 0.7204]}, {"w": "at", "b": [0.7765, 0.699, 0.7916, 0.7204]}, {"w": "https://", "b": [0.7988, 0.6988, 0.8571, 0.7204]}, {"w": "github.com/ageron/handson-ml2.", "b": [0.1429, 0.7178, 0.4135, 0.7395]}]}, {"id": "b_11", "type": "paragraph", "text": "Try It Out! | 85", "words": [{"w": "Try", "b": [0.7451, 0.9225, 0.7633, 0.9388]}, {"w": "It", "b": [0.7661, 0.9225, 0.7753, 0.9388]}, {"w": "Out!", "b": [0.7781, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "85", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 112, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": []}, {"page": 113, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 By default Scikit-Learn caches downloaded datasets in a directory called $HOME/scikit_learn_data.", "words": [{"w": "1", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "By", "b": [0.1587, 0.8749, 0.1753, 0.8912]}, {"w": "default", "b": [0.179, 0.8749, 0.2227, 0.8912]}, {"w": "Scikit-Learn", "b": [0.2263, 0.8749, 0.3043, 0.8912]}, {"w": "caches", "b": [0.3079, 0.8749, 0.3493, 0.8912]}, {"w": "downloaded", "b": [0.3529, 0.8749, 0.4315, 0.8912]}, {"w": "datasets", "b": [0.4351, 0.8749, 0.4852, 0.8912]}, {"w": "in", "b": [0.4888, 0.8749, 0.5018, 0.8912]}, {"w": "a", "b": [0.5054, 0.8749, 0.5123, 0.8912]}, {"w": "directory", "b": [0.516, 0.8749, 0.5745, 0.8912]}, {"w": "called", "b": [0.5781, 0.8749, 0.615, 0.8912]}, {"w": "$HOME/scikit_learn_data.", "b": [0.6186, 0.8748, 0.7881, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "CHAPTER 3 Classification", "words": [{"w": "CHAPTER", "b": [0.7398, 0.1146, 0.8382, 0.1451]}, {"w": "3", "b": [0.8435, 0.1146, 0.8571, 0.1451]}, {"w": "Classification", "b": [0.6413, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_2", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 3 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.3643, 0.3102, 0.3839]}, {"w": "Early", "b": [0.3165, 0.3643, 0.3563, 0.3839]}, {"w": "Release", "b": [0.3626, 0.3643, 0.4189, 0.3839]}, {"w": "ebooks,", "b": [0.4251, 0.3643, 0.4831, 0.3839]}, {"w": "you", "b": [0.4894, 0.3643, 0.518, 0.3839]}, {"w": "get", "b": [0.5243, 0.3643, 0.5471, 0.3839]}, {"w": "books", "b": [0.5534, 0.3643, 0.5989, 0.3839]}, {"w": "in", "b": [0.6052, 0.3643, 0.6207, 0.3839]}, {"w": "their", "b": [0.627, 0.3643, 0.6632, 0.3839]}, {"w": "earliest", "b": [0.6695, 0.3643, 0.7239, 0.3839]}, {"w": "form—", "b": [0.7301, 0.3643, 0.7857, 0.3839]}, {"w": "the", "b": [0.2714, 0.3818, 0.2955, 0.4013]}, {"w": "author’s", "b": [0.3012, 0.3818, 0.3615, 0.4013]}, {"w": "raw", "b": [0.3672, 0.3818, 0.3954, 0.4013]}, {"w": "and", "b": [0.4011, 0.3818, 0.4299, 0.4013]}, {"w": "unedited", "b": [0.4357, 0.3818, 0.5034, 0.4013]}, {"w": "content", "b": [0.5092, 0.3818, 0.5668, 0.4013]}, {"w": "as", "b": [0.5725, 0.3818, 0.5878, 0.4013]}, {"w": "he", "b": [0.5936, 0.3818, 0.6118, 0.4013]}, {"w": "or", "b": [0.6175, 0.3818, 0.6343, 0.4013]}, {"w": "she", "b": [0.6401, 0.3818, 0.6653, 0.4013]}, {"w": "writes—so", "b": [0.671, 0.3818, 0.7514, 0.4013]}, {"w": "you", "b": [0.7571, 0.3818, 0.7857, 0.4013]}, {"w": "can", "b": [0.2714, 0.3992, 0.2983, 0.4187]}, {"w": "take", "b": [0.306, 0.3992, 0.3377, 0.4187]}, {"w": "advantage", "b": [0.3455, 0.3992, 0.4223, 0.4187]}, {"w": "of", "b": [0.4301, 0.3992, 0.4454, 0.4187]}, {"w": "these", "b": [0.4532, 0.3992, 0.4924, 0.4187]}, {"w": "technologies", "b": [0.5001, 0.3992, 0.596, 0.4187]}, {"w": "long", "b": [0.6038, 0.3992, 0.6376, 0.4187]}, {"w": "before", "b": [0.6454, 0.3992, 0.6937, 0.4187]}, {"w": "the", "b": [0.7014, 0.3992, 0.7255, 0.4187]}, {"w": "official", "b": [0.7333, 0.3992, 0.7857, 0.4187]}, {"w": "release", "b": [0.2714, 0.4166, 0.3229, 0.4362]}, {"w": "of", "b": [0.3292, 0.4166, 0.3445, 0.4362]}, {"w": "these", "b": [0.3507, 0.4166, 0.3899, 0.4362]}, {"w": "titles.", "b": [0.3961, 0.4166, 0.4371, 0.4362]}, {"w": "The", "b": [0.4433, 0.4166, 0.4733, 0.4362]}, {"w": "following", "b": [0.4795, 0.4166, 0.5517, 0.4362]}, {"w": "will", "b": [0.558, 0.4166, 0.5857, 0.4362]}, {"w": "be", "b": [0.592, 0.4166, 0.6097, 0.4362]}, {"w": "Chapter", "b": [0.616, 0.4166, 0.6778, 0.4362]}, {"w": "3", "b": [0.684, 0.4166, 0.6931, 0.4362]}, {"w": "in", "b": [0.6993, 0.4166, 0.7149, 0.4362]}, {"w": "the", "b": [0.7211, 0.4166, 0.7452, 0.4362]}, {"w": "final", "b": [0.7514, 0.4166, 0.7857, 0.4362]}, {"w": "release", "b": [0.2714, 0.434, 0.3229, 0.4536]}, {"w": "of", "b": [0.3273, 0.434, 0.3426, 0.4536]}, {"w": "the", "b": [0.3469, 0.434, 0.371, 0.4536]}, {"w": "book.", "b": [0.3753, 0.434, 0.4182, 0.4536]}]}, {"id": "b_3", "type": "paragraph", "text": "In Chapter 1 we mentioned that the most common supervised learning tasks are regression (predicting values) and classification (predicting classes). In Chapter 2 we explored a regression task, predicting housing values, using various algorithms such as Linear Regression, Decision Trees, and Random Forests (which will be explained in further detail in later chapters). Now we will turn our attention to classification systems.", "words": [{"w": "In", "b": [0.1429, 0.4739, 0.1614, 0.4953]}, {"w": "Chapter", "b": [0.1699, 0.4739, 0.2375, 0.4953]}, {"w": "1", "b": [0.246, 0.4739, 0.256, 0.4953]}, {"w": "we", "b": [0.2646, 0.4739, 0.2877, 0.4953]}, {"w": "mentioned", "b": [0.2963, 0.4739, 0.387, 0.4953]}, {"w": "that", "b": [0.3956, 0.4739, 0.4281, 0.4953]}, {"w": "the", "b": [0.4367, 0.4739, 0.463, 0.4953]}, {"w": "most", "b": [0.4716, 0.4739, 0.5133, 0.4953]}, {"w": "common", "b": [0.5218, 0.4739, 0.5974, 0.4953]}, {"w": "supervised", "b": [0.606, 0.4739, 0.6955, 0.4953]}, {"w": "learning", "b": [0.7041, 0.4739, 0.7732, 0.4953]}, {"w": "tasks", "b": [0.7817, 0.4739, 0.8229, 0.4953]}, {"w": "are", "b": [0.8314, 0.4739, 0.8571, 0.4953]}, {"w": "regression", "b": [0.1429, 0.4929, 0.2287, 0.5143]}, {"w": "(predicting", "b": [0.2345, 0.4929, 0.3277, 0.5143]}, {"w": "values)", "b": [0.3335, 0.4929, 0.3923, 0.5143]}, {"w": "and", "b": [0.3981, 0.4929, 0.4297, 0.5143]}, {"w": "classification", "b": [0.4355, 0.4929, 0.5429, 0.5143]}, {"w": "(predicting", "b": [0.5487, 0.4929, 0.6419, 0.5143]}, {"w": "classes).", "b": [0.6477, 0.4929, 0.7147, 0.5143]}, {"w": "In", "b": [0.7205, 0.4929, 0.739, 0.5143]}, {"w": "Chapter", "b": [0.7448, 0.4929, 0.8124, 0.5143]}, {"w": "2", "b": [0.8182, 0.4929, 0.8282, 0.5143]}, {"w": "we", "b": [0.834, 0.4929, 0.8571, 0.5143]}, {"w": "explored", "b": [0.1428, 0.512, 0.2159, 0.5334]}, {"w": "a", "b": [0.2222, 0.512, 0.2313, 0.5334]}, {"w": "regression", "b": [0.2376, 0.512, 0.3234, 0.5334]}, {"w": "task,", "b": [0.3297, 0.512, 0.3679, 0.5334]}, {"w": "predicting", "b": [0.3742, 0.512, 0.4602, 0.5334]}, {"w": "housing", "b": [0.4664, 0.512, 0.5336, 0.5334]}, {"w": "values,", "b": [0.5399, 0.512, 0.5963, 0.5334]}, {"w": "using", "b": [0.6025, 0.512, 0.648, 0.5334]}, {"w": "various", "b": [0.6542, 0.512, 0.7157, 0.5334]}, {"w": "algorithms", "b": [0.7219, 0.512, 0.8122, 0.5334]}, {"w": "such", "b": [0.8185, 0.512, 0.8571, 0.5334]}, {"w": "as", "b": [0.1429, 0.531, 0.1597, 0.5524]}, {"w": "Linear", "b": [0.1663, 0.531, 0.2202, 0.5524]}, {"w": "Regression,", "b": [0.2268, 0.531, 0.3226, 0.5524]}, {"w": "Decision", "b": [0.3292, 0.531, 0.403, 0.5524]}, {"w": "Trees,", "b": [0.4096, 0.531, 0.4585, 0.5524]}, {"w": "and", "b": [0.4651, 0.531, 0.4967, 0.5524]}, {"w": "Random", "b": [0.5033, 0.531, 0.5758, 0.5524]}, {"w": "Forests", "b": [0.5824, 0.531, 0.6419, 0.5524]}, {"w": "(which", "b": [0.6485, 0.531, 0.7066, 0.5524]}, {"w": "will", "b": [0.7132, 0.531, 0.7436, 0.5524]}, {"w": "be", "b": [0.7502, 0.531, 0.7697, 0.5524]}, {"w": "explained", "b": [0.7763, 0.531, 0.8571, 0.5524]}, {"w": "in", "b": [0.1429, 0.5501, 0.1598, 0.5715]}, {"w": "further", "b": [0.1673, 0.5501, 0.2263, 0.5715]}, {"w": "detail", "b": [0.2338, 0.5501, 0.28, 0.5715]}, {"w": "in", "b": [0.2875, 0.5501, 0.3044, 0.5715]}, {"w": "later", "b": [0.3119, 0.5501, 0.3489, 0.5715]}, {"w": "chapters).", "b": [0.3563, 0.5501, 0.4385, 0.5715]}, {"w": "Now", "b": [0.4459, 0.5501, 0.4858, 0.5715]}, {"w": "we", "b": [0.4933, 0.5501, 0.5164, 0.5715]}, {"w": "will", "b": [0.5238, 0.5501, 0.5542, 0.5715]}, {"w": "turn", "b": [0.5617, 0.5501, 0.5982, 0.5715]}, {"w": "our", "b": [0.6057, 0.5501, 0.6351, 0.5715]}, {"w": "attention", "b": [0.6426, 0.5501, 0.7179, 0.5715]}, {"w": "to", "b": [0.7253, 0.5501, 0.7423, 0.5715]}, {"w": "classification", "b": [0.7498, 0.5501, 0.8571, 0.5715]}, {"w": "systems.", "b": [0.1428, 0.5691, 0.2124, 0.5905]}]}, {"id": "b_4", "type": "paragraph", "text": "MNIST", "words": [{"w": "MNIST", "b": [0.1428, 0.6035, 0.2215, 0.6378]}]}, {"id": "b_5", "type": "paragraph", "text": "In this chapter, we will be using the MNIST dataset, which is a set of 70,000 small images of digits handwritten by high school students and employees of the US Cen‐ sus Bureau. Each image is labeled with the digit it represents. This set has been stud‐ ied so much that it is often called the “Hello World” of Machine Learning: whenever people come up with a new classification algorithm, they are curious to see how it will perform on MNIST. Whenever someone learns Machine Learning, sooner or later they tackle MNIST.", "words": [{"w": "In", "b": [0.1429, 0.6447, 0.1614, 0.6661]}, {"w": "this", "b": [0.1686, 0.6447, 0.1993, 0.6661]}, {"w": "chapter,", "b": [0.2065, 0.6447, 0.2725, 0.6661]}, {"w": "we", "b": [0.2797, 0.6447, 0.3028, 0.6661]}, {"w": "will", "b": [0.3101, 0.6447, 0.3404, 0.6661]}, {"w": "be", "b": [0.3477, 0.6447, 0.3671, 0.6661]}, {"w": "using", "b": [0.3743, 0.6447, 0.4198, 0.6661]}, {"w": "the", "b": [0.427, 0.6447, 0.4533, 0.6661]}, {"w": "MNIST", "b": [0.4605, 0.6447, 0.5244, 0.6661]}, {"w": "dataset,", "b": [0.5316, 0.6447, 0.5945, 0.6661]}, {"w": "which", "b": [0.6017, 0.6447, 0.6526, 0.6661]}, {"w": "is", "b": [0.6599, 0.6447, 0.6731, 0.6661]}, {"w": "a", "b": [0.6803, 0.6447, 0.6895, 0.6661]}, {"w": "set", "b": [0.6967, 0.6447, 0.7195, 0.6661]}, {"w": "of", "b": [0.7268, 0.6447, 0.7435, 0.6661]}, {"w": "70,000", "b": [0.7508, 0.6447, 0.8055, 0.6661]}, {"w": "small", "b": [0.8127, 0.6447, 0.8571, 0.6661]}, {"w": "images", "b": [0.1429, 0.6637, 0.2009, 0.6852]}, {"w": "of", "b": [0.2071, 0.6637, 0.2238, 0.6852]}, {"w": "digits", "b": [0.23, 0.6637, 0.2759, 0.6852]}, {"w": "handwritten", "b": [0.2821, 0.6637, 0.3853, 0.6852]}, {"w": "by", "b": [0.3914, 0.6637, 0.4116, 0.6852]}, {"w": "high", "b": [0.4177, 0.6637, 0.4553, 0.6852]}, {"w": "school", "b": [0.4614, 0.6637, 0.5155, 0.6852]}, {"w": "students", "b": [0.5217, 0.6637, 0.5916, 0.6852]}, {"w": "and", "b": [0.5978, 0.6637, 0.6293, 0.6852]}, {"w": "employees", "b": [0.6355, 0.6637, 0.7227, 0.6852]}, {"w": "of", "b": [0.7289, 0.6637, 0.7456, 0.6852]}, {"w": "the", "b": [0.7518, 0.6637, 0.7781, 0.6852]}, {"w": "US", "b": [0.7843, 0.6637, 0.8095, 0.6852]}, {"w": "Cen‐", "b": [0.8156, 0.6637, 0.8572, 0.6852]}, {"w": "sus", "b": [0.1429, 0.6828, 0.1692, 0.7042]}, {"w": "Bureau.", "b": [0.1749, 0.6828, 0.2393, 0.7042]}, {"w": "Each", "b": [0.245, 0.6828, 0.2859, 0.7042]}, {"w": "image", "b": [0.2915, 0.6828, 0.3419, 0.7042]}, {"w": "is", "b": [0.3475, 0.6828, 0.3608, 0.7042]}, {"w": "labeled", "b": [0.3664, 0.6828, 0.4254, 0.7042]}, {"w": "with", "b": [0.431, 0.6828, 0.4684, 0.7042]}, {"w": "the", "b": [0.474, 0.6828, 0.5003, 0.7042]}, {"w": "digit", "b": [0.506, 0.6828, 0.5442, 0.7042]}, {"w": "it", "b": [0.5499, 0.6828, 0.5618, 0.7042]}, {"w": "represents.", "b": [0.5675, 0.6828, 0.6578, 0.7042]}, {"w": "This", "b": [0.6634, 0.6828, 0.7006, 0.7042]}, {"w": "set", "b": [0.7063, 0.6828, 0.7291, 0.7042]}, {"w": "has", "b": [0.7348, 0.6828, 0.7627, 0.7042]}, {"w": "been", "b": [0.7683, 0.6828, 0.808, 0.7042]}, {"w": "stud‐", "b": [0.8137, 0.6828, 0.8571, 0.7042]}, {"w": "ied", "b": [0.1429, 0.7018, 0.1683, 0.7233]}, {"w": "so", "b": [0.1742, 0.7018, 0.1924, 0.7233]}, {"w": "much", "b": [0.1983, 0.7018, 0.246, 0.7233]}, {"w": "that", "b": [0.2518, 0.7018, 0.2844, 0.7233]}, {"w": "it", "b": [0.2903, 0.7018, 0.3022, 0.7233]}, {"w": "is", "b": [0.3081, 0.7018, 0.3213, 0.7233]}, {"w": "often", "b": [0.3272, 0.7018, 0.3706, 0.7233]}, {"w": "called", "b": [0.3765, 0.7018, 0.4248, 0.7233]}, {"w": "the", "b": [0.4307, 0.7018, 0.457, 0.7233]}, {"w": "“Hello", "b": [0.4629, 0.7018, 0.5167, 0.7233]}, {"w": "World”", "b": [0.5225, 0.7018, 0.5832, 0.7233]}, {"w": "of", "b": [0.5891, 0.7018, 0.6059, 0.7233]}, {"w": "Machine", "b": [0.6117, 0.7018, 0.6849, 0.7233]}, {"w": "Learning:", "b": [0.6907, 0.7018, 0.7705, 0.7233]}, {"w": "whenever", "b": [0.7764, 0.7018, 0.8571, 0.7233]}, {"w": "people", "b": [0.1428, 0.7209, 0.1983, 0.7423]}, {"w": "come", "b": [0.2055, 0.7209, 0.2509, 0.7423]}, {"w": "up", "b": [0.2581, 0.7209, 0.2801, 0.7423]}, {"w": "with", "b": [0.2873, 0.7209, 0.3247, 0.7423]}, {"w": "a", "b": [0.3319, 0.7209, 0.341, 0.7423]}, {"w": "new", "b": [0.3483, 0.7209, 0.3828, 0.7423]}, {"w": "classification", "b": [0.39, 0.7209, 0.4974, 0.7423]}, {"w": "algorithm,", "b": [0.5046, 0.7209, 0.592, 0.7423]}, {"w": "they", "b": [0.5993, 0.7209, 0.6352, 0.7423]}, {"w": "are", "b": [0.6424, 0.7209, 0.6681, 0.7423]}, {"w": "curious", "b": [0.6754, 0.7209, 0.7379, 0.7423]}, {"w": "to", "b": [0.7451, 0.7209, 0.7621, 0.7423]}, {"w": "see", "b": [0.7693, 0.7209, 0.7947, 0.7423]}, {"w": "how", "b": [0.8019, 0.7209, 0.838, 0.7423]}, {"w": "it", "b": [0.8452, 0.7209, 0.8571, 0.7423]}, {"w": "will", "b": [0.1429, 0.7399, 0.1733, 0.7613]}, {"w": "perform", "b": [0.1819, 0.7399, 0.251, 0.7613]}, {"w": "on", "b": [0.2596, 0.7399, 0.2816, 0.7613]}, {"w": "MNIST.", "b": [0.2902, 0.7399, 0.3568, 0.7613]}, {"w": "Whenever", "b": [0.3654, 0.7399, 0.4521, 0.7613]}, {"w": "someone", "b": [0.4607, 0.7399, 0.5358, 0.7613]}, {"w": "learns", "b": [0.5444, 0.7399, 0.5945, 0.7613]}, {"w": "Machine", "b": [0.6031, 0.7399, 0.6762, 0.7613]}, {"w": "Learning,", "b": [0.6849, 0.7399, 0.7647, 0.7613]}, {"w": "sooner", "b": [0.7733, 0.7399, 0.8302, 0.7613]}, {"w": "or", "b": [0.8388, 0.7399, 0.8571, 0.7613]}, {"w": "later", "b": [0.1429, 0.759, 0.1798, 0.7804]}, {"w": "they", "b": [0.1845, 0.759, 0.2204, 0.7804]}, {"w": "tackle", "b": [0.2252, 0.759, 0.2739, 0.7804]}, {"w": "MNIST.", "b": [0.2787, 0.759, 0.3452, 0.7804]}]}, {"id": "b_6", "type": "paragraph", "text": "Scikit-Learn provides many helper functions to download popular datasets. MNIST is one of them. The following code fetches the MNIST dataset:1", "words": [{"w": "Scikit-Learn", "b": [0.1429, 0.7871, 0.2451, 0.8085]}, {"w": "provides", "b": [0.2499, 0.7871, 0.3219, 0.8085]}, {"w": "many", "b": [0.3266, 0.7871, 0.3733, 0.8085]}, {"w": "helper", "b": [0.378, 0.7871, 0.4308, 0.8085]}, {"w": "functions", "b": [0.4355, 0.7871, 0.5145, 0.8085]}, {"w": "to", "b": [0.5193, 0.7871, 0.5363, 0.8085]}, {"w": "download", "b": [0.541, 0.7871, 0.6243, 0.8085]}, {"w": "popular", "b": [0.629, 0.7871, 0.6947, 0.8085]}, {"w": "datasets.", "b": [0.6994, 0.7871, 0.7699, 0.8085]}, {"w": "MNIST", "b": [0.7747, 0.7871, 0.8385, 0.8085]}, {"w": "is", "b": [0.8433, 0.7871, 0.8565, 0.8085]}, {"w": "one", "b": [0.1429, 0.8061, 0.1737, 0.8276]}, {"w": "of", "b": [0.1785, 0.8061, 0.1953, 0.8276]}, {"w": "them.", "b": [0.2, 0.8061, 0.2481, 0.8276]}, {"w": "The", "b": [0.2529, 0.8061, 0.2857, 0.8276]}, {"w": "following", "b": [0.2904, 0.8061, 0.3694, 0.8276]}, {"w": "code", "b": [0.3741, 0.8061, 0.4134, 0.8276]}, {"w": "fetches", "b": [0.4181, 0.8061, 0.4759, 0.8276]}, {"w": "the", "b": [0.4807, 0.8061, 0.507, 0.8276]}, {"w": "MNIST", "b": [0.5117, 0.8061, 0.5756, 0.8276]}, {"w": "dataset:1", "b": [0.5803, 0.8061, 0.6489, 0.8276]}]}]}, {"page": 114, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": ">>> from sklearn.datasets import fetch_openml >>> mnist = fetch_openml('mnist_784', version=1) >>> mnist.keys() dict_keys(['data', 'target', 'feature_names', 'DESCR', 'details', 'categories', 'url'])", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "from", "b": [0.2103, 0.0829, 0.244, 0.0958]}, {"w": "sklearn.datasets", "b": [0.2525, 0.0829, 0.3874, 0.0958]}, {"w": "import", "b": [0.3958, 0.0829, 0.4464, 0.0958]}, {"w": "fetch_openml", "b": [0.4549, 0.0829, 0.5561, 0.0958]}, {"w": ">>>", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "mnist", "b": [0.2103, 0.0983, 0.2525, 0.1112]}, {"w": "=", "b": [0.2609, 0.0983, 0.2693, 0.1112]}, {"w": "fetch_openml('mnist_784',", "b": [0.2778, 0.0983, 0.4886, 0.1112]}, {"w": "version=1)", "b": [0.497, 0.0983, 0.5813, 0.1112]}, {"w": ">>>", "b": [0.1766, 0.1138, 0.2019, 0.1266]}, {"w": "mnist.keys()", "b": [0.2103, 0.1138, 0.3115, 0.1266]}, {"w": "dict_keys(['data',", "b": [0.1766, 0.1292, 0.3284, 0.142]}, {"w": "'target',", "b": [0.3368, 0.1292, 0.4127, 0.142]}, {"w": "'feature_names',", "b": [0.4211, 0.1292, 0.5561, 0.142]}, {"w": "'DESCR',", "b": [0.5645, 0.1292, 0.6319, 0.142]}, {"w": "'details',", "b": [0.6404, 0.1292, 0.7247, 0.142]}, {"w": "'categories',", "b": [0.2693, 0.1446, 0.379, 0.1574]}, {"w": "'url'])", "b": [0.3874, 0.1446, 0.4464, 0.1574]}]}, {"id": "b_1", "type": "paragraph", "text": "Datasets loaded by Scikit-Learn generally have a similar dictionary structure includ‐ ing:", "words": [{"w": "Datasets", "b": [0.1429, 0.1652, 0.2129, 0.1866]}, {"w": "loaded", "b": [0.2191, 0.1652, 0.275, 0.1866]}, {"w": "by", "b": [0.2812, 0.1652, 0.3014, 0.1866]}, {"w": "Scikit-Learn", "b": [0.3076, 0.1652, 0.4098, 0.1866]}, {"w": "generally", "b": [0.416, 0.1652, 0.4919, 0.1866]}, {"w": "have", "b": [0.4981, 0.1652, 0.5365, 0.1866]}, {"w": "a", "b": [0.5427, 0.1652, 0.5518, 0.1866]}, {"w": "similar", "b": [0.558, 0.1652, 0.616, 0.1866]}, {"w": "dictionary", "b": [0.6222, 0.1652, 0.7086, 0.1866]}, {"w": "structure", "b": [0.7148, 0.1652, 0.7904, 0.1866]}, {"w": "includ‐", "b": [0.7966, 0.1652, 0.8572, 0.1866]}, {"w": "ing:", "b": [0.1429, 0.1843, 0.1743, 0.2057]}]}, {"id": "b_2", "type": "paragraph", "text": "• A DESCR key describing the dataset", "words": [{"w": "•", "b": [0.16, 0.2193, 0.1682, 0.2408]}, {"w": "A", "b": [0.1786, 0.2193, 0.193, 0.2408]}, {"w": "DESCR", "b": [0.1977, 0.2225, 0.2472, 0.2376]}, {"w": "key", "b": [0.2519, 0.2193, 0.2806, 0.2408]}, {"w": "describing", "b": [0.2854, 0.2193, 0.3723, 0.2408]}, {"w": "the", "b": [0.377, 0.2193, 0.4034, 0.2408]}, {"w": "dataset", "b": [0.4081, 0.2193, 0.4662, 0.2408]}]}, {"id": "b_3", "type": "paragraph", "text": "• A data key containing an array with one row per instance and one column per feature", "words": [{"w": "•", "b": [0.16, 0.2453, 0.1682, 0.2667]}, {"w": "A", "b": [0.1786, 0.2453, 0.193, 0.2667]}, {"w": "data", "b": [0.1995, 0.2485, 0.239, 0.2636]}, {"w": "key", "b": [0.2456, 0.2453, 0.2743, 0.2667]}, {"w": "containing", "b": [0.2808, 0.2453, 0.3705, 0.2667]}, {"w": "an", "b": [0.377, 0.2453, 0.3975, 0.2667]}, {"w": "array", "b": [0.404, 0.2453, 0.4469, 0.2667]}, {"w": "with", "b": [0.4534, 0.2453, 0.4908, 0.2667]}, {"w": "one", "b": [0.4973, 0.2453, 0.5282, 0.2667]}, {"w": "row", "b": [0.5347, 0.2453, 0.5673, 0.2667]}, {"w": "per", "b": [0.5738, 0.2453, 0.6013, 0.2667]}, {"w": "instance", "b": [0.6078, 0.2453, 0.677, 0.2667]}, {"w": "and", "b": [0.6835, 0.2453, 0.715, 0.2667]}, {"w": "one", "b": [0.7215, 0.2453, 0.7524, 0.2667]}, {"w": "column", "b": [0.7589, 0.2453, 0.8231, 0.2667]}, {"w": "per", "b": [0.8296, 0.2453, 0.8571, 0.2667]}, {"w": "feature", "b": [0.1786, 0.2644, 0.2363, 0.2858]}]}, {"id": "b_4", "type": "paragraph", "text": "• A target key containing an array with the labels", "words": [{"w": "•", "b": [0.16, 0.2904, 0.1682, 0.3118]}, {"w": "A", "b": [0.1786, 0.2904, 0.193, 0.3118]}, {"w": "target", "b": [0.1977, 0.2936, 0.2571, 0.3086]}, {"w": "key", "b": [0.2618, 0.2904, 0.2905, 0.3118]}, {"w": "containing", "b": [0.2953, 0.2904, 0.3849, 0.3118]}, {"w": "an", "b": [0.3896, 0.2904, 0.4102, 0.3118]}, {"w": "array", "b": [0.4149, 0.2904, 0.4579, 0.3118]}, {"w": "with", "b": [0.4626, 0.2904, 0.4999, 0.3118]}, {"w": "the", "b": [0.5046, 0.2904, 0.531, 0.3118]}, {"w": "labels", "b": [0.5357, 0.2904, 0.5825, 0.3118]}]}, {"id": "b_5", "type": "paragraph", "text": "Let’s look at these arrays:", "words": [{"w": "Let’s", "b": [0.1429, 0.3245, 0.179, 0.3459]}, {"w": "look", "b": [0.1838, 0.3245, 0.2206, 0.3459]}, {"w": "at", "b": [0.2253, 0.3245, 0.2404, 0.3459]}, {"w": "these", "b": [0.2452, 0.3245, 0.288, 0.3459]}, {"w": "arrays:", "b": [0.2927, 0.3245, 0.3481, 0.3459]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> X, y = mnist[\"data\"], mnist[\"target\"] >>> X.shape (70000, 784) >>> y.shape (70000,)", "words": [{"w": ">>>", "b": [0.1766, 0.3565, 0.2019, 0.3694]}, {"w": "X,", "b": [0.2103, 0.3565, 0.2272, 0.3694]}, {"w": "y", "b": [0.2356, 0.3565, 0.244, 0.3694]}, {"w": "=", "b": [0.2525, 0.3565, 0.2609, 0.3694]}, {"w": "mnist[\"data\"],", "b": [0.2693, 0.3565, 0.3874, 0.3694]}, {"w": "mnist[\"target\"]", "b": [0.3958, 0.3565, 0.5223, 0.3694]}, {"w": ">>>", "b": [0.1766, 0.3719, 0.2019, 0.3848]}, {"w": "X.shape", "b": [0.2103, 0.3719, 0.2693, 0.3848]}, {"w": "(70000,", "b": [0.1766, 0.3873, 0.2356, 0.4002]}, {"w": "784)", "b": [0.244, 0.3873, 0.2778, 0.4002]}, {"w": ">>>", "b": [0.1766, 0.4028, 0.2019, 0.4156]}, {"w": "y.shape", "b": [0.2103, 0.4028, 0.2693, 0.4156]}, {"w": "(70000,)", "b": [0.1766, 0.4182, 0.244, 0.431]}]}, {"id": "b_7", "type": "paragraph", "text": "There are 70,000 images, and each image has 784 features. This is because each image is 28×28 pixels, and each feature simply represents one pixel’s intensity, from 0 (white) to 255 (black). Let’s take a peek at one digit from the dataset. All you need to do is grab an instance’s feature vector, reshape it to a 28×28 array, and display it using Matplotlib’s imshow() function:", "words": [{"w": "There", "b": [0.1429, 0.4388, 0.1923, 0.4602]}, {"w": "are", "b": [0.1973, 0.4388, 0.223, 0.4602]}, {"w": "70,000", "b": [0.228, 0.4388, 0.2828, 0.4602]}, {"w": "images,", "b": [0.2878, 0.4388, 0.3506, 0.4602]}, {"w": "and", "b": [0.3556, 0.4388, 0.3872, 0.4602]}, {"w": "each", "b": [0.3922, 0.4388, 0.4301, 0.4602]}, {"w": "image", "b": [0.4352, 0.4388, 0.4855, 0.4602]}, {"w": "has", "b": [0.4906, 0.4388, 0.5185, 0.4602]}, {"w": "784", "b": [0.5235, 0.4388, 0.5535, 0.4602]}, {"w": "features.", "b": [0.5585, 0.4388, 0.6287, 0.4602]}, {"w": "This", "b": [0.6337, 0.4388, 0.6709, 0.4602]}, {"w": "is", "b": [0.6759, 0.4388, 0.6892, 0.4602]}, {"w": "because", "b": [0.6942, 0.4388, 0.7588, 0.4602]}, {"w": "each", "b": [0.7638, 0.4388, 0.8017, 0.4602]}, {"w": "image", "b": [0.8067, 0.4388, 0.8571, 0.4602]}, {"w": "is", "b": [0.1428, 0.4579, 0.1561, 0.4793]}, {"w": "28×28", "b": [0.166, 0.4579, 0.2181, 0.4793]}, {"w": "pixels,", "b": [0.2281, 0.4579, 0.2809, 0.4793]}, {"w": "and", "b": [0.2909, 0.4579, 0.3224, 0.4793]}, {"w": "each", "b": [0.3324, 0.4579, 0.3703, 0.4793]}, {"w": "feature", "b": [0.3802, 0.4579, 0.438, 0.4793]}, {"w": "simply", "b": [0.448, 0.4579, 0.5036, 0.4793]}, {"w": "represents", "b": [0.5136, 0.4579, 0.5991, 0.4793]}, {"w": "one", "b": [0.6091, 0.4579, 0.64, 0.4793]}, {"w": "pixel’s", "b": [0.6499, 0.4579, 0.7001, 0.4793]}, {"w": "intensity,", "b": [0.7101, 0.4579, 0.7857, 0.4793]}, {"w": "from", "b": [0.7956, 0.4579, 0.8372, 0.4793]}, {"w": "0", "b": [0.8471, 0.4579, 0.8571, 0.4793]}, {"w": "(white)", "b": [0.1429, 0.4769, 0.2035, 0.4983]}, {"w": "to", "b": [0.2091, 0.4769, 0.2261, 0.4983]}, {"w": "255", "b": [0.2318, 0.4769, 0.2618, 0.4983]}, {"w": "(black).", "b": [0.2674, 0.4769, 0.3307, 0.4983]}, {"w": "Let’s", "b": [0.3364, 0.4769, 0.3725, 0.4983]}, {"w": "take", "b": [0.3782, 0.4769, 0.4129, 0.4983]}, {"w": "a", "b": [0.4185, 0.4769, 0.4277, 0.4983]}, {"w": "peek", "b": [0.4333, 0.4769, 0.4723, 0.4983]}, {"w": "at", "b": [0.478, 0.4769, 0.4931, 0.4983]}, {"w": "one", "b": [0.4987, 0.4769, 0.5296, 0.4983]}, {"w": "digit", "b": [0.5352, 0.4769, 0.5735, 0.4983]}, {"w": "from", "b": [0.5792, 0.4769, 0.6208, 0.4983]}, {"w": "the", "b": [0.6264, 0.4769, 0.6527, 0.4983]}, {"w": "dataset.", "b": [0.6584, 0.4769, 0.7213, 0.4983]}, {"w": "All", "b": [0.7269, 0.4769, 0.7518, 0.4983]}, {"w": "you", "b": [0.7575, 0.4769, 0.7888, 0.4983]}, {"w": "need", "b": [0.7944, 0.4769, 0.8345, 0.4983]}, {"w": "to", "b": [0.8402, 0.4769, 0.8571, 0.4983]}, {"w": "do", "b": [0.1429, 0.496, 0.1645, 0.5174]}, {"w": "is", "b": [0.1696, 0.496, 0.1829, 0.5174]}, {"w": "grab", "b": [0.188, 0.496, 0.2252, 0.5174]}, {"w": "an", "b": [0.2304, 0.496, 0.2509, 0.5174]}, {"w": "instance’s", "b": [0.256, 0.496, 0.3343, 0.5174]}, {"w": "feature", "b": [0.3395, 0.496, 0.3972, 0.5174]}, {"w": "vector,", "b": [0.4024, 0.496, 0.4578, 0.5174]}, {"w": "reshape", "b": [0.463, 0.496, 0.5269, 0.5174]}, {"w": "it", "b": [0.532, 0.496, 0.5439, 0.5174]}, {"w": "to", "b": [0.5491, 0.496, 0.5661, 0.5174]}, {"w": "a", "b": [0.5712, 0.496, 0.5804, 0.5174]}, {"w": "28×28", "b": [0.5855, 0.496, 0.6376, 0.5174]}, {"w": "array,", "b": [0.6427, 0.496, 0.6889, 0.5174]}, {"w": "and", "b": [0.694, 0.496, 0.7256, 0.5174]}, {"w": "display", "b": [0.7307, 0.496, 0.7895, 0.5174]}, {"w": "it", "b": [0.7946, 0.496, 0.8066, 0.5174]}, {"w": "using", "b": [0.8117, 0.496, 0.8571, 0.5174]}, {"w": "Matplotlib’s", "b": [0.1429, 0.5159, 0.2396, 0.5373]}, {"w": "imshow()", "b": [0.2443, 0.5191, 0.3235, 0.5342]}, {"w": "function:", "b": [0.3282, 0.5159, 0.4043, 0.5373]}]}, {"id": "b_8", "type": "paragraph", "text": "import matplotlib as mpl import matplotlib.pyplot as plt", "words": [{"w": "import", "b": [0.1766, 0.5479, 0.2272, 0.5607]}, {"w": "matplotlib", "b": [0.2356, 0.5479, 0.3199, 0.5607]}, {"w": "as", "b": [0.3284, 0.5479, 0.3452, 0.5607]}, {"w": "mpl", "b": [0.3537, 0.5479, 0.379, 0.5607]}, {"w": "import", "b": [0.1766, 0.5633, 0.2272, 0.5761]}, {"w": "matplotlib.pyplot", "b": [0.2356, 0.5633, 0.379, 0.5761]}, {"w": "as", "b": [0.3874, 0.5633, 0.4043, 0.5761]}, {"w": "plt", "b": [0.4127, 0.5633, 0.438, 0.5761]}]}, {"id": "b_9", "type": "equation", "text": "some_digit = X[0] some_digit_image = some_digit.reshape(28, 28)", "words": [{"w": "some_digit", "b": [0.1766, 0.5941, 0.2609, 0.607]}, {"w": "=", "b": [0.2693, 0.5941, 0.2778, 0.607]}, {"w": "X[0]", "b": [0.2862, 0.5941, 0.3199, 0.607]}, {"w": "some_digit_image", "b": [0.1766, 0.6096, 0.3115, 0.6224]}, {"w": "=", "b": [0.3199, 0.6096, 0.3284, 0.6224]}, {"w": "some_digit.reshape(28,", "b": [0.3368, 0.6096, 0.5223, 0.6224]}, {"w": "28)", "b": [0.5308, 0.6096, 0.556, 0.6224]}]}, {"id": "b_10", "type": "paragraph", "text": "plt.imshow(some_digit_image, cmap = mpl.cm.binary, interpolation=\"nearest\") plt.axis(\"off\") plt.show()", "words": [{"w": "plt.imshow(some_digit_image,", "b": [0.1766, 0.6404, 0.4127, 0.6532]}, {"w": "cmap", "b": [0.4211, 0.6404, 0.4549, 0.6532]}, {"w": "=", "b": [0.4633, 0.6404, 0.4717, 0.6532]}, {"w": "mpl.cm.binary,", "b": [0.4802, 0.6404, 0.5982, 0.6532]}, {"w": "interpolation=\"nearest\")", "b": [0.6066, 0.6404, 0.809, 0.6532]}, {"w": "plt.axis(\"off\")", "b": [0.1766, 0.6558, 0.3031, 0.6687]}, {"w": "plt.show()", "b": [0.1766, 0.6712, 0.2609, 0.6841]}]}, {"id": "b_11", "type": "paragraph", "text": "This looks like a 5, and indeed that’s what the label tells us:", "words": [{"w": "This", "b": [0.1428, 0.8349, 0.1801, 0.8563]}, {"w": "looks", "b": [0.1848, 0.8349, 0.2293, 0.8563]}, {"w": "like", "b": [0.234, 0.8349, 0.2641, 0.8563]}, {"w": "a", "b": [0.2688, 0.8349, 0.2779, 0.8563]}, {"w": "5,", "b": [0.2827, 0.8349, 0.2974, 0.8563]}, {"w": "and", "b": [0.3021, 0.8349, 0.3337, 0.8563]}, {"w": "indeed", "b": [0.3384, 0.8349, 0.3951, 0.8563]}, {"w": "that’s", "b": [0.3998, 0.8349, 0.4422, 0.8563]}, {"w": "what", "b": [0.4469, 0.8349, 0.4874, 0.8563]}, {"w": "the", "b": [0.4921, 0.8349, 0.5185, 0.8563]}, {"w": "label", "b": [0.5232, 0.8349, 0.5623, 0.8563]}, {"w": "tells", "b": [0.567, 0.8349, 0.6004, 0.8563]}, {"w": "us:", "b": [0.6052, 0.8349, 0.6286, 0.8563]}]}, {"id": "b_12", "type": "paragraph", "text": "88 | Chapter 3: Classification", "words": [{"w": "88", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "3:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "Classification", "b": [0.26, 0.9225, 0.337, 0.9388]}]}]}, {"page": 115, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": ">>> y[0] '5'", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "y[0]", "b": [0.2103, 0.0829, 0.244, 0.0958]}, {"w": "'5'", "b": [0.1766, 0.0983, 0.2019, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "Note that the label is a string. We prefer numbers, so let’s cast y to integers:", "words": [{"w": "Note", "b": [0.1429, 0.1199, 0.1837, 0.1413]}, {"w": "that", "b": [0.1884, 0.1199, 0.221, 0.1413]}, {"w": "the", "b": [0.2257, 0.1199, 0.252, 0.1413]}, {"w": "label", "b": [0.2568, 0.1199, 0.2959, 0.1413]}, {"w": "is", "b": [0.3006, 0.1199, 0.3138, 0.1413]}, {"w": "a", "b": [0.3186, 0.1199, 0.3277, 0.1413]}, {"w": "string.", "b": [0.3324, 0.1199, 0.3857, 0.1413]}, {"w": "We", "b": [0.3904, 0.1199, 0.4174, 0.1413]}, {"w": "prefer", "b": [0.4222, 0.1199, 0.4724, 0.1413]}, {"w": "numbers,", "b": [0.4772, 0.1199, 0.5558, 0.1413]}, {"w": "so", "b": [0.5606, 0.1199, 0.5788, 0.1413]}, {"w": "let’s", "b": [0.5836, 0.1199, 0.6138, 0.1413]}, {"w": "cast", "b": [0.6185, 0.1199, 0.6505, 0.1413]}, {"w": "y", "b": [0.6552, 0.123, 0.6651, 0.1381]}, {"w": "to", "b": [0.6698, 0.1199, 0.6868, 0.1413]}, {"w": "integers:", "b": [0.6916, 0.1199, 0.7621, 0.1413]}]}, {"id": "b_2", "type": "equation", "text": ">>> y = y.astype(np.uint8)", "words": [{"w": ">>>", "b": [0.1766, 0.1518, 0.2019, 0.1647]}, {"w": "y", "b": [0.2103, 0.1518, 0.2187, 0.1647]}, {"w": "=", "b": [0.2272, 0.1518, 0.2356, 0.1647]}, {"w": "y.astype(np.uint8)", "b": [0.244, 0.1518, 0.3958, 0.1647]}]}, {"id": "b_3", "type": "paragraph", "text": "Figure 3-1 shows a few more images from the MNIST dataset to give you a feel for the complexity of the classification task.", "words": [{"w": "Figure", "b": [0.1428, 0.1725, 0.1968, 0.1939]}, {"w": "3-1", "b": [0.2035, 0.1725, 0.2309, 0.1939]}, {"w": "shows", "b": [0.2375, 0.1725, 0.2888, 0.1939]}, {"w": "a", "b": [0.2955, 0.1725, 0.3046, 0.1939]}, {"w": "few", "b": [0.3112, 0.1725, 0.3405, 0.1939]}, {"w": "more", "b": [0.3472, 0.1725, 0.3914, 0.1939]}, {"w": "images", "b": [0.3981, 0.1725, 0.4561, 0.1939]}, {"w": "from", "b": [0.4627, 0.1725, 0.5043, 0.1939]}, {"w": "the", "b": [0.5109, 0.1725, 0.5373, 0.1939]}, {"w": "MNIST", "b": [0.5439, 0.1725, 0.6078, 0.1939]}, {"w": "dataset", "b": [0.6144, 0.1725, 0.6725, 0.1939]}, {"w": "to", "b": [0.6791, 0.1725, 0.6961, 0.1939]}, {"w": "give", "b": [0.7027, 0.1725, 0.7366, 0.1939]}, {"w": "you", "b": [0.7432, 0.1725, 0.7744, 0.1939]}, {"w": "a", "b": [0.7811, 0.1725, 0.7902, 0.1939]}, {"w": "feel", "b": [0.7968, 0.1725, 0.826, 0.1939]}, {"w": "for", "b": [0.8326, 0.1725, 0.8571, 0.1939]}, {"w": "the", "b": [0.1429, 0.1915, 0.1692, 0.2129]}, {"w": "complexity", "b": [0.1739, 0.1915, 0.2664, 0.2129]}, {"w": "of", "b": [0.2711, 0.1915, 0.2879, 0.2129]}, {"w": "the", "b": [0.2927, 0.1915, 0.319, 0.2129]}, {"w": "classification", "b": [0.3237, 0.1915, 0.4311, 0.2129]}, {"w": "task.", "b": [0.4358, 0.1915, 0.4741, 0.2129]}]}, {"id": "b_4", "type": "equation", "text": "Figure 3-1. A few digits from the MNIST dataset", "words": [{"w": "Figure", "b": [0.1429, 0.6256, 0.1943, 0.6472]}, {"w": "3-1.", "b": [0.1991, 0.6256, 0.2308, 0.6472]}, {"w": "A", "b": [0.2356, 0.6256, 0.2494, 0.6472]}, {"w": "few", "b": [0.2542, 0.6256, 0.282, 0.6472]}, {"w": "digits", "b": [0.2868, 0.6256, 0.3302, 0.6472]}, {"w": "from", "b": [0.335, 0.6256, 0.374, 0.6472]}, {"w": "the", "b": [0.3788, 0.6256, 0.4038, 0.6472]}, {"w": "MNIST", "b": [0.4086, 0.6256, 0.4704, 0.6472]}, {"w": "dataset", "b": [0.4752, 0.6256, 0.5335, 0.6472]}]}, {"id": "b_5", "type": "paragraph", "text": "But wait! You should always create a test set and set it aside before inspecting the data closely. The MNIST dataset is actually already split into a training set (the first 60,000 images) and a test set (the last 10,000 images):", "words": [{"w": "But", "b": [0.1429, 0.663, 0.1725, 0.6844]}, {"w": "wait!", "b": [0.1775, 0.663, 0.2186, 0.6844]}, {"w": "You", "b": [0.2236, 0.663, 0.256, 0.6844]}, {"w": "should", "b": [0.261, 0.663, 0.3177, 0.6844]}, {"w": "always", "b": [0.3227, 0.663, 0.3774, 0.6844]}, {"w": "create", "b": [0.3824, 0.663, 0.4317, 0.6844]}, {"w": "a", "b": [0.4367, 0.663, 0.4459, 0.6844]}, {"w": "test", "b": [0.4509, 0.663, 0.4801, 0.6844]}, {"w": "set", "b": [0.4851, 0.663, 0.5079, 0.6844]}, {"w": "and", "b": [0.5129, 0.663, 0.5445, 0.6844]}, {"w": "set", "b": [0.5495, 0.663, 0.5723, 0.6844]}, {"w": "it", "b": [0.5773, 0.663, 0.5892, 0.6844]}, {"w": "aside", "b": [0.5942, 0.663, 0.6365, 0.6844]}, {"w": "before", "b": [0.6415, 0.663, 0.6943, 0.6844]}, {"w": "inspecting", "b": [0.6993, 0.663, 0.7856, 0.6844]}, {"w": "the", "b": [0.7906, 0.663, 0.8169, 0.6844]}, {"w": "data", "b": [0.8219, 0.663, 0.8572, 0.6844]}, {"w": "closely.", "b": [0.1429, 0.682, 0.2021, 0.7035]}, {"w": "The", "b": [0.2072, 0.682, 0.2401, 0.7035]}, {"w": "MNIST", "b": [0.2452, 0.682, 0.3091, 0.7035]}, {"w": "dataset", "b": [0.3142, 0.682, 0.3723, 0.7035]}, {"w": "is", "b": [0.3774, 0.682, 0.3906, 0.7035]}, {"w": "actually", "b": [0.3957, 0.682, 0.4604, 0.7035]}, {"w": "already", "b": [0.4655, 0.682, 0.5262, 0.7035]}, {"w": "split", "b": [0.5313, 0.682, 0.5671, 0.7035]}, {"w": "into", "b": [0.5722, 0.682, 0.6058, 0.7035]}, {"w": "a", "b": [0.6109, 0.682, 0.62, 0.7035]}, {"w": "training", "b": [0.6251, 0.682, 0.6921, 0.7035]}, {"w": "set", "b": [0.6972, 0.682, 0.72, 0.7035]}, {"w": "(the", "b": [0.7251, 0.682, 0.7587, 0.7035]}, {"w": "first", "b": [0.7638, 0.682, 0.7973, 0.7035]}, {"w": "60,000", "b": [0.8024, 0.682, 0.8571, 0.7035]}, {"w": "images)", "b": [0.1429, 0.7011, 0.2081, 0.7225]}, {"w": "and", "b": [0.2128, 0.7011, 0.2444, 0.7225]}, {"w": "a", "b": [0.2491, 0.7011, 0.2583, 0.7225]}, {"w": "test", "b": [0.263, 0.7011, 0.2922, 0.7225]}, {"w": "set", "b": [0.2969, 0.7011, 0.3198, 0.7225]}, {"w": "(the", "b": [0.3245, 0.7011, 0.358, 0.7225]}, {"w": "last", "b": [0.3628, 0.7011, 0.3912, 0.7225]}, {"w": "10,000", "b": [0.3959, 0.7011, 0.4507, 0.7225]}, {"w": "images):", "b": [0.4554, 0.7011, 0.5254, 0.7225]}]}, {"id": "b_6", "type": "equation", "text": "X_train, X_test, y_train, y_test = X[:60000], X[60000:], y[:60000], y[60000:]", "words": [{"w": "X_train,", "b": [0.1766, 0.7331, 0.2441, 0.7459]}, {"w": "X_test,", "b": [0.2525, 0.7331, 0.3115, 0.7459]}, {"w": "y_train,", "b": [0.3199, 0.7331, 0.3874, 0.7459]}, {"w": "y_test", "b": [0.3958, 0.7331, 0.4464, 0.7459]}, {"w": "=", "b": [0.4549, 0.7331, 0.4633, 0.7459]}, {"w": "X[:60000],", "b": [0.4717, 0.7331, 0.5561, 0.7459]}, {"w": "X[60000:],", "b": [0.5645, 0.7331, 0.6488, 0.7459]}, {"w": "y[:60000],", "b": [0.6572, 0.7331, 0.7416, 0.7459]}, {"w": "y[60000:]", "b": [0.75, 0.7331, 0.8259, 0.7459]}]}, {"id": "b_7", "type": "paragraph", "text": "The training set is already shuffled for us, which is good as this guarantees that all cross-validation folds will be similar (you don’t want one fold to be missing some dig‐ its). Moreover, some learning algorithms are sensitive to the order of the training", "words": [{"w": "The", "b": [0.1429, 0.7537, 0.1757, 0.7751]}, {"w": "training", "b": [0.1828, 0.7537, 0.2498, 0.7751]}, {"w": "set", "b": [0.2569, 0.7537, 0.2798, 0.7751]}, {"w": "is", "b": [0.287, 0.7537, 0.3002, 0.7751]}, {"w": "already", "b": [0.3073, 0.7537, 0.3681, 0.7751]}, {"w": "shuffled", "b": [0.3752, 0.7537, 0.4421, 0.7751]}, {"w": "for", "b": [0.4493, 0.7537, 0.4738, 0.7751]}, {"w": "us,", "b": [0.481, 0.7537, 0.5044, 0.7751]}, {"w": "which", "b": [0.5116, 0.7537, 0.5625, 0.7751]}, {"w": "is", "b": [0.5696, 0.7537, 0.5829, 0.7751]}, {"w": "good", "b": [0.59, 0.7537, 0.632, 0.7751]}, {"w": "as", "b": [0.6392, 0.7537, 0.656, 0.7751]}, {"w": "this", "b": [0.6631, 0.7537, 0.6939, 0.7751]}, {"w": "guarantees", "b": [0.701, 0.7537, 0.7906, 0.7751]}, {"w": "that", "b": [0.7977, 0.7537, 0.8303, 0.7751]}, {"w": "all", "b": [0.8375, 0.7537, 0.8571, 0.7751]}, {"w": "cross-validation", "b": [0.1429, 0.7727, 0.2761, 0.7942]}, {"w": "folds", "b": [0.281, 0.7727, 0.3217, 0.7942]}, {"w": "will", "b": [0.3266, 0.7727, 0.357, 0.7942]}, {"w": "be", "b": [0.3619, 0.7727, 0.3814, 0.7942]}, {"w": "similar", "b": [0.3863, 0.7727, 0.4443, 0.7942]}, {"w": "(you", "b": [0.4492, 0.7727, 0.4876, 0.7942]}, {"w": "don’t", "b": [0.4926, 0.7727, 0.5342, 0.7942]}, {"w": "want", "b": [0.5391, 0.7727, 0.5798, 0.7942]}, {"w": "one", "b": [0.5847, 0.7727, 0.6156, 0.7942]}, {"w": "fold", "b": [0.6205, 0.7727, 0.6536, 0.7942]}, {"w": "to", "b": [0.6585, 0.7727, 0.6755, 0.7942]}, {"w": "be", "b": [0.6804, 0.7727, 0.6998, 0.7942]}, {"w": "missing", "b": [0.7047, 0.7727, 0.7694, 0.7942]}, {"w": "some", "b": [0.7743, 0.7727, 0.8185, 0.7942]}, {"w": "dig‐", "b": [0.8234, 0.7727, 0.8571, 0.7942]}, {"w": "its).", "b": [0.1429, 0.7918, 0.1744, 0.8132]}, {"w": "Moreover,", "b": [0.1825, 0.7918, 0.268, 0.8132]}, {"w": "some", "b": [0.2761, 0.7918, 0.3203, 0.8132]}, {"w": "learning", "b": [0.3284, 0.7918, 0.3975, 0.8132]}, {"w": "algorithms", "b": [0.4056, 0.7918, 0.4959, 0.8132]}, {"w": "are", "b": [0.5039, 0.7918, 0.5297, 0.8132]}, {"w": "sensitive", "b": [0.5378, 0.7918, 0.6093, 0.8132]}, {"w": "to", "b": [0.6174, 0.7918, 0.6344, 0.8132]}, {"w": "the", "b": [0.6425, 0.7918, 0.6688, 0.8132]}, {"w": "order", "b": [0.6769, 0.7918, 0.7228, 0.8132]}, {"w": "of", "b": [0.7309, 0.7918, 0.7477, 0.8132]}, {"w": "the", "b": [0.7558, 0.7918, 0.7821, 0.8132]}, {"w": "training", "b": [0.7902, 0.7918, 0.8571, 0.8132]}]}, {"id": "b_8", "type": "paragraph", "text": "MNIST | 89", "words": [{"w": "MNIST", "b": [0.7657, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "89", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 116, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "2 Shuffling may be a bad idea in some contexts—for example, if you are working on time series data (such as stock market prices or weather conditions). We will explore this in the next chapters.", "words": [{"w": "2", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Shuffling", "b": [0.1587, 0.8598, 0.2166, 0.8761]}, {"w": "may", "b": [0.2202, 0.8598, 0.2472, 0.8761]}, {"w": "be", "b": [0.2508, 0.8598, 0.2656, 0.8761]}, {"w": "a", "b": [0.2692, 0.8598, 0.2762, 0.8761]}, {"w": "bad", "b": [0.2798, 0.8598, 0.3032, 0.8761]}, {"w": "idea", "b": [0.3068, 0.8598, 0.3332, 0.8761]}, {"w": "in", "b": [0.3368, 0.8598, 0.3497, 0.8761]}, {"w": "some", "b": [0.3533, 0.8598, 0.387, 0.8761]}, {"w": "contexts—for", "b": [0.3906, 0.8598, 0.4768, 0.8761]}, {"w": "example,", "b": [0.4804, 0.8598, 0.537, 0.8761]}, {"w": "if", "b": [0.5406, 0.8598, 0.5496, 0.8761]}, {"w": "you", "b": [0.5532, 0.8598, 0.577, 0.8761]}, {"w": "are", "b": [0.5806, 0.8598, 0.6002, 0.8761]}, {"w": "working", "b": [0.6038, 0.8598, 0.6569, 0.8761]}, {"w": "on", "b": [0.6605, 0.8598, 0.6773, 0.8761]}, {"w": "time", "b": [0.6809, 0.8598, 0.7097, 0.8761]}, {"w": "series", "b": [0.7133, 0.8598, 0.7486, 0.8761]}, {"w": "data", "b": [0.7522, 0.8598, 0.7791, 0.8761]}, {"w": "(such", "b": [0.7827, 0.8598, 0.8176, 0.8761]}, {"w": "as", "b": [0.8212, 0.8598, 0.834, 0.8761]}, {"w": "stock", "b": [0.1587, 0.8749, 0.1921, 0.8912]}, {"w": "market", "b": [0.1957, 0.8749, 0.241, 0.8912]}, {"w": "prices", "b": [0.2446, 0.8749, 0.2823, 0.8912]}, {"w": "or", "b": [0.286, 0.8749, 0.2999, 0.8912]}, {"w": "weather", "b": [0.3035, 0.8749, 0.3538, 0.8912]}, {"w": "conditions).", "b": [0.3574, 0.8749, 0.4343, 0.8912]}, {"w": "We", "b": [0.4379, 0.8749, 0.4585, 0.8912]}, {"w": "will", "b": [0.4621, 0.8749, 0.4853, 0.8912]}, {"w": "explore", "b": [0.4889, 0.8749, 0.5362, 0.8912]}, {"w": "this", "b": [0.5398, 0.8749, 0.5632, 0.8912]}, {"w": "in", "b": [0.5668, 0.8749, 0.5797, 0.8912]}, {"w": "the", "b": [0.5833, 0.8749, 0.6034, 0.8912]}, {"w": "next", "b": [0.607, 0.8749, 0.6348, 0.8912]}, {"w": "chapters.", "b": [0.6384, 0.8749, 0.6955, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "instances, and they perform poorly if they get many similar instances in a row. Shuf‐ fling the dataset ensures that this won’t happen.2", "words": [{"w": "instances,", "b": [0.1429, 0.0791, 0.2244, 0.1005]}, {"w": "and", "b": [0.2302, 0.0791, 0.2617, 0.1005]}, {"w": "they", "b": [0.2674, 0.0791, 0.3033, 0.1005]}, {"w": "perform", "b": [0.309, 0.0791, 0.3781, 0.1005]}, {"w": "poorly", "b": [0.3838, 0.0791, 0.4386, 0.1005]}, {"w": "if", "b": [0.4443, 0.0791, 0.456, 0.1005]}, {"w": "they", "b": [0.4618, 0.0791, 0.4976, 0.1005]}, {"w": "get", "b": [0.5034, 0.0791, 0.5283, 0.1005]}, {"w": "many", "b": [0.534, 0.0791, 0.5807, 0.1005]}, {"w": "similar", "b": [0.5865, 0.0791, 0.6445, 0.1005]}, {"w": "instances", "b": [0.6502, 0.0791, 0.727, 0.1005]}, {"w": "in", "b": [0.7327, 0.0791, 0.7497, 0.1005]}, {"w": "a", "b": [0.7554, 0.0791, 0.7646, 0.1005]}, {"w": "row.", "b": [0.7703, 0.0791, 0.8062, 0.1005]}, {"w": "Shuf‐", "b": [0.8119, 0.0791, 0.8571, 0.1005]}, {"w": "fling", "b": [0.1429, 0.0981, 0.181, 0.1195]}, {"w": "the", "b": [0.1858, 0.0981, 0.2121, 0.1195]}, {"w": "dataset", "b": [0.2168, 0.0981, 0.2749, 0.1195]}, {"w": "ensures", "b": [0.2797, 0.0981, 0.3428, 0.1195]}, {"w": "that", "b": [0.3476, 0.0981, 0.3802, 0.1195]}, {"w": "this", "b": [0.3849, 0.0981, 0.4156, 0.1195]}, {"w": "won’t", "b": [0.4203, 0.0981, 0.4652, 0.1195]}, {"w": "happen.2", "b": [0.4699, 0.0981, 0.5423, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "Training a Binary Classifier", "words": [{"w": "Training", "b": [0.1428, 0.1325, 0.246, 0.1668]}, {"w": "a", "b": [0.2519, 0.1325, 0.2668, 0.1668]}, {"w": "Binary", "b": [0.2727, 0.1325, 0.3527, 0.1668]}, {"w": "Classifier", "b": [0.3587, 0.1325, 0.4689, 0.1668]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s simplify the problem for now and only try to identify one digit—for example, the number 5. This “5-detector” will be an example of a binary classifier, capable of distinguishing between just two classes, 5 and not-5. Let’s create the target vectors for this classification task:", "words": [{"w": "Let’s", "b": [0.1429, 0.1737, 0.179, 0.1951]}, {"w": "simplify", "b": [0.186, 0.1737, 0.2538, 0.1951]}, {"w": "the", "b": [0.2608, 0.1737, 0.2871, 0.1951]}, {"w": "problem", "b": [0.2941, 0.1737, 0.3651, 0.1951]}, {"w": "for", "b": [0.3721, 0.1737, 0.3966, 0.1951]}, {"w": "now", "b": [0.4036, 0.1737, 0.4399, 0.1951]}, {"w": "and", "b": [0.4469, 0.1737, 0.4785, 0.1951]}, {"w": "only", "b": [0.4855, 0.1737, 0.5223, 0.1951]}, {"w": "try", "b": [0.5293, 0.1737, 0.5536, 0.1951]}, {"w": "to", "b": [0.5606, 0.1737, 0.5775, 0.1951]}, {"w": "identify", "b": [0.5845, 0.1737, 0.649, 0.1951]}, {"w": "one", "b": [0.656, 0.1737, 0.6869, 0.1951]}, {"w": "digit—for", "b": [0.6939, 0.1737, 0.7759, 0.1951]}, {"w": "example,", "b": [0.7828, 0.1737, 0.8571, 0.1951]}, {"w": "the", "b": [0.1428, 0.1927, 0.1692, 0.2142]}, {"w": "number", "b": [0.1759, 0.1927, 0.2422, 0.2142]}, {"w": "5.", "b": [0.2489, 0.1927, 0.2636, 0.2142]}, {"w": "This", "b": [0.2703, 0.1927, 0.3075, 0.2142]}, {"w": "“5-detector”", "b": [0.3142, 0.1927, 0.4169, 0.2142]}, {"w": "will", "b": [0.4236, 0.1927, 0.454, 0.2142]}, {"w": "be", "b": [0.4607, 0.1927, 0.4801, 0.2142]}, {"w": "an", "b": [0.4868, 0.1927, 0.5073, 0.2142]}, {"w": "example", "b": [0.514, 0.1927, 0.5836, 0.2142]}, {"w": "of", "b": [0.5903, 0.1927, 0.6071, 0.2142]}, {"w": "a", "b": [0.6138, 0.1927, 0.6229, 0.2142]}, {"w": "binary", "b": [0.6296, 0.1925, 0.683, 0.2142]}, {"w": "classifier,", "b": [0.6898, 0.1925, 0.7646, 0.2142]}, {"w": "capable", "b": [0.7713, 0.1927, 0.8336, 0.2142]}, {"w": "of", "b": [0.8403, 0.1927, 0.8571, 0.2142]}, {"w": "distinguishing", "b": [0.1429, 0.2118, 0.2623, 0.2332]}, {"w": "between", "b": [0.2675, 0.2118, 0.3367, 0.2332]}, {"w": "just", "b": [0.3419, 0.2118, 0.3723, 0.2332]}, {"w": "two", "b": [0.3776, 0.2118, 0.4088, 0.2332]}, {"w": "classes,", "b": [0.414, 0.2118, 0.4738, 0.2332]}, {"w": "5", "b": [0.479, 0.2118, 0.489, 0.2332]}, {"w": "and", "b": [0.4943, 0.2118, 0.5258, 0.2332]}, {"w": "not-5.", "b": [0.531, 0.2118, 0.5816, 0.2332]}, {"w": "Let’s", "b": [0.5868, 0.2118, 0.623, 0.2332]}, {"w": "create", "b": [0.6282, 0.2118, 0.6775, 0.2332]}, {"w": "the", "b": [0.6828, 0.2118, 0.7091, 0.2332]}, {"w": "target", "b": [0.7143, 0.2118, 0.7625, 0.2332]}, {"w": "vectors", "b": [0.7677, 0.2118, 0.8274, 0.2332]}, {"w": "for", "b": [0.8326, 0.2118, 0.8571, 0.2332]}, {"w": "this", "b": [0.1429, 0.2308, 0.1736, 0.2523]}, {"w": "classification", "b": [0.1783, 0.2308, 0.2857, 0.2523]}, {"w": "task:", "b": [0.2904, 0.2308, 0.3286, 0.2523]}]}, {"id": "b_4", "type": "paragraph", "text": "y_train_5 = (y_train == 5) # True for all 5s, False for all other digits. y_test_5 = (y_test == 5)", "words": [{"w": "y_train_5", "b": [0.1766, 0.2628, 0.2525, 0.2757]}, {"w": "=", "b": [0.2609, 0.2628, 0.2693, 0.2757]}, {"w": "(y_train", "b": [0.2778, 0.2628, 0.3452, 0.2757]}, {"w": "==", "b": [0.3537, 0.2628, 0.3705, 0.2757]}, {"w": "5)", "b": [0.379, 0.2628, 0.3958, 0.2757]}, {"w": "#", "b": [0.4127, 0.2628, 0.4211, 0.2757]}, {"w": "True", "b": [0.4296, 0.2628, 0.4633, 0.2757]}, {"w": "for", "b": [0.4717, 0.2628, 0.497, 0.2757]}, {"w": "all", "b": [0.5055, 0.2628, 0.5308, 0.2757]}, {"w": "5s,", "b": [0.5392, 0.2628, 0.5645, 0.2757]}, {"w": "False", "b": [0.5729, 0.2628, 0.6151, 0.2757]}, {"w": "for", "b": [0.6235, 0.2628, 0.6488, 0.2757]}, {"w": "all", "b": [0.6572, 0.2628, 0.6825, 0.2757]}, {"w": "other", "b": [0.691, 0.2628, 0.7331, 0.2757]}, {"w": "digits.", "b": [0.7416, 0.2628, 0.8006, 0.2757]}, {"w": "y_test_5", "b": [0.1766, 0.2782, 0.244, 0.2911]}, {"w": "=", "b": [0.2525, 0.2782, 0.2609, 0.2911]}, {"w": "(y_test", "b": [0.2693, 0.2782, 0.3284, 0.2911]}, {"w": "==", "b": [0.3368, 0.2782, 0.3537, 0.2911]}, {"w": "5)", "b": [0.3621, 0.2782, 0.379, 0.2911]}]}, {"id": "b_5", "type": "paragraph", "text": "Okay, now let’s pick a classifier and train it. A good place to start is with a Stochastic Gradient Descent (SGD) classifier, using Scikit-Learn’s SGDClassifier class. This clas‐ sifier has the advantage of being capable of handling very large datasets efficiently. This is in part because SGD deals with training instances independently, one at a time (which also makes SGD well suited for online learning), as we will see later. Let’s create an SGDClassifier and train it on the whole training set:", "words": [{"w": "Okay,", "b": [0.1429, 0.2989, 0.1903, 0.3203]}, {"w": "now", "b": [0.1963, 0.2989, 0.2326, 0.3203]}, {"w": "let’s", "b": [0.2385, 0.2989, 0.2687, 0.3203]}, {"w": "pick", "b": [0.2747, 0.2989, 0.3103, 0.3203]}, {"w": "a", "b": [0.3162, 0.2989, 0.3254, 0.3203]}, {"w": "classifier", "b": [0.3313, 0.2989, 0.4038, 0.3203]}, {"w": "and", "b": [0.4097, 0.2989, 0.4412, 0.3203]}, {"w": "train", "b": [0.4472, 0.2989, 0.4874, 0.3203]}, {"w": "it.", "b": [0.4933, 0.2989, 0.51, 0.3203]}, {"w": "A", "b": [0.5159, 0.2989, 0.5303, 0.3203]}, {"w": "good", "b": [0.5363, 0.2989, 0.5783, 0.3203]}, {"w": "place", "b": [0.5842, 0.2989, 0.6272, 0.3203]}, {"w": "to", "b": [0.6331, 0.2989, 0.6501, 0.3203]}, {"w": "start", "b": [0.6561, 0.2989, 0.6933, 0.3203]}, {"w": "is", "b": [0.6992, 0.2989, 0.7124, 0.3203]}, {"w": "with", "b": [0.7184, 0.2989, 0.7557, 0.3203]}, {"w": "a", "b": [0.7617, 0.2989, 0.7708, 0.3203]}, {"w": "Stochastic", "b": [0.7767, 0.2987, 0.8572, 0.3203]}, {"w": "Gradient", "b": [0.1429, 0.3186, 0.2153, 0.3402]}, {"w": "Descent", "b": [0.2201, 0.3186, 0.2834, 0.3402]}, {"w": "(SGD)", "b": [0.2885, 0.3188, 0.343, 0.3402]}, {"w": "classifier,", "b": [0.3478, 0.3188, 0.4237, 0.3402]}, {"w": "using", "b": [0.4284, 0.3188, 0.4738, 0.3402]}, {"w": "Scikit-Learn’s", "b": [0.4791, 0.3188, 0.59, 0.3402]}, {"w": "SGDClassifier", "b": [0.595, 0.322, 0.7236, 0.3371]}, {"w": "class.", "b": [0.7285, 0.3188, 0.7718, 0.3402]}, {"w": "This", "b": [0.7765, 0.3188, 0.8137, 0.3402]}, {"w": "clas‐", "b": [0.8185, 0.3188, 0.8567, 0.3402]}, {"w": "sifier", "b": [0.1428, 0.3379, 0.1844, 0.3593]}, {"w": "has", "b": [0.1919, 0.3379, 0.2198, 0.3593]}, {"w": "the", "b": [0.2272, 0.3379, 0.2536, 0.3593]}, {"w": "advantage", "b": [0.261, 0.3379, 0.345, 0.3593]}, {"w": "of", "b": [0.3525, 0.3379, 0.3693, 0.3593]}, {"w": "being", "b": [0.3767, 0.3379, 0.4229, 0.3593]}, {"w": "capable", "b": [0.4303, 0.3379, 0.4927, 0.3593]}, {"w": "of", "b": [0.5001, 0.3379, 0.5169, 0.3593]}, {"w": "handling", "b": [0.5244, 0.3379, 0.599, 0.3593]}, {"w": "very", "b": [0.6065, 0.3379, 0.6429, 0.3593]}, {"w": "large", "b": [0.6503, 0.3379, 0.6911, 0.3593]}, {"w": "datasets", "b": [0.6985, 0.3379, 0.7643, 0.3593]}, {"w": "efficiently.", "b": [0.7717, 0.3379, 0.8571, 0.3593]}, {"w": "This", "b": [0.1429, 0.3569, 0.1801, 0.3783]}, {"w": "is", "b": [0.185, 0.3569, 0.1982, 0.3783]}, {"w": "in", "b": [0.2031, 0.3569, 0.2201, 0.3783]}, {"w": "part", "b": [0.225, 0.3569, 0.2592, 0.3783]}, {"w": "because", "b": [0.2641, 0.3569, 0.3286, 0.3783]}, {"w": "SGD", "b": [0.3336, 0.3569, 0.3736, 0.3783]}, {"w": "deals", "b": [0.3786, 0.3569, 0.4205, 0.3783]}, {"w": "with", "b": [0.4254, 0.3569, 0.4627, 0.3783]}, {"w": "training", "b": [0.4676, 0.3569, 0.5346, 0.3783]}, {"w": "instances", "b": [0.5395, 0.3569, 0.6163, 0.3783]}, {"w": "independently,", "b": [0.6212, 0.3569, 0.7445, 0.3783]}, {"w": "one", "b": [0.7494, 0.3569, 0.7803, 0.3783]}, {"w": "at", "b": [0.7852, 0.3569, 0.8003, 0.3783]}, {"w": "a", "b": [0.8052, 0.3569, 0.8144, 0.3783]}, {"w": "time", "b": [0.8193, 0.3569, 0.8571, 0.3783]}, {"w": "(which", "b": [0.1429, 0.376, 0.201, 0.3974]}, {"w": "also", "b": [0.2057, 0.376, 0.2384, 0.3974]}, {"w": "makes", "b": [0.2431, 0.376, 0.2962, 0.3974]}, {"w": "SGD", "b": [0.3009, 0.376, 0.341, 0.3974]}, {"w": "well", "b": [0.3457, 0.376, 0.3794, 0.3974]}, {"w": "suited", "b": [0.3841, 0.376, 0.4346, 0.3974]}, {"w": "for", "b": [0.4393, 0.376, 0.4639, 0.3974]}, {"w": "online", "b": [0.4688, 0.3757, 0.5188, 0.3974]}, {"w": "learning),", "b": [0.5236, 0.3757, 0.6023, 0.3974]}, {"w": "as", "b": [0.607, 0.376, 0.6238, 0.3974]}, {"w": "we", "b": [0.6285, 0.376, 0.6517, 0.3974]}, {"w": "will", "b": [0.6564, 0.376, 0.6868, 0.3974]}, {"w": "see", "b": [0.6915, 0.376, 0.7169, 0.3974]}, {"w": "later.", "b": [0.7216, 0.376, 0.762, 0.3974]}, {"w": "Let’s", "b": [0.7667, 0.376, 0.8029, 0.3974]}, {"w": "create", "b": [0.8076, 0.376, 0.857, 0.3974]}, {"w": "an", "b": [0.1429, 0.3959, 0.1634, 0.4173]}, {"w": "SGDClassifier", "b": [0.1681, 0.3991, 0.2968, 0.4142]}, {"w": "and", "b": [0.3015, 0.3959, 0.333, 0.4173]}, {"w": "train", "b": [0.3378, 0.3959, 0.378, 0.4173]}, {"w": "it", "b": [0.3827, 0.3959, 0.3946, 0.4173]}, {"w": "on", "b": [0.3994, 0.3959, 0.4214, 0.4173]}, {"w": "the", "b": [0.4261, 0.3959, 0.4525, 0.4173]}, {"w": "whole", "b": [0.4572, 0.3959, 0.5073, 0.4173]}, {"w": "training", "b": [0.5121, 0.3959, 0.579, 0.4173]}, {"w": "set:", "b": [0.5837, 0.3959, 0.6113, 0.4173]}]}, {"id": "b_6", "type": "equation", "text": "from sklearn.linear_model import SGDClassifier", "words": [{"w": "from", "b": [0.1766, 0.4279, 0.2103, 0.4407]}, {"w": "sklearn.linear_model", "b": [0.2188, 0.4279, 0.3874, 0.4407]}, {"w": "import", "b": [0.3958, 0.4279, 0.4464, 0.4407]}, {"w": "SGDClassifier", "b": [0.4549, 0.4279, 0.5645, 0.4407]}]}, {"id": "b_7", "type": "equation", "text": "sgd_clf = SGDClassifier(random_state=42) sgd_clf.fit(X_train, y_train_5)", "words": [{"w": "sgd_clf", "b": [0.1766, 0.4587, 0.2356, 0.4716]}, {"w": "=", "b": [0.244, 0.4587, 0.2525, 0.4716]}, {"w": "SGDClassifier(random_state=42)", "b": [0.2609, 0.4587, 0.5139, 0.4716]}, {"w": "sgd_clf.fit(X_train,", "b": [0.1766, 0.4741, 0.3452, 0.487]}, {"w": "y_train_5)", "b": [0.3537, 0.4741, 0.438, 0.487]}]}, {"id": "b_8", "type": "paragraph", "text": "The SGDClassifier relies on randomness during training (hence the name “stochastic”). If you want reproducible results, you should set the random_state parameter.", "words": [{"w": "The", "b": [0.2714, 0.5094, 0.3014, 0.529]}, {"w": "SGDClassifier", "b": [0.3083, 0.5123, 0.426, 0.5261]}, {"w": "relies", "b": [0.4329, 0.5094, 0.473, 0.529]}, {"w": "on", "b": [0.4799, 0.5094, 0.5001, 0.529]}, {"w": "randomness", "b": [0.507, 0.5094, 0.6007, 0.529]}, {"w": "during", "b": [0.6076, 0.5094, 0.6593, 0.529]}, {"w": "training", "b": [0.6662, 0.5094, 0.7274, 0.529]}, {"w": "(hence", "b": [0.7343, 0.5094, 0.7857, 0.529]}, {"w": "the", "b": [0.2714, 0.5268, 0.2955, 0.5464]}, {"w": "name", "b": [0.3067, 0.5268, 0.3491, 0.5464]}, {"w": "“stochastic”).", "b": [0.3603, 0.5268, 0.46, 0.5464]}, {"w": "If", "b": [0.4712, 0.5268, 0.4833, 0.5464]}, {"w": "you", "b": [0.4945, 0.5268, 0.523, 0.5464]}, {"w": "want", "b": [0.5342, 0.5268, 0.5715, 0.5464]}, {"w": "reproducible", "b": [0.5827, 0.5268, 0.6805, 0.5464]}, {"w": "results,", "b": [0.6917, 0.5268, 0.746, 0.5464]}, {"w": "you", "b": [0.7571, 0.5268, 0.7857, 0.5464]}, {"w": "should", "b": [0.2714, 0.5451, 0.3233, 0.5646]}, {"w": "set", "b": [0.3276, 0.5451, 0.3485, 0.5646]}, {"w": "the", "b": [0.3528, 0.5451, 0.3769, 0.5646]}, {"w": "random_state", "b": [0.3812, 0.548, 0.4898, 0.5618]}, {"w": "parameter.", "b": [0.4941, 0.5451, 0.5757, 0.5646]}]}, {"id": "b_9", "type": "paragraph", "text": "Now you can use it to detect images of the number 5:", "words": [{"w": "Now", "b": [0.1429, 0.6072, 0.1827, 0.6286]}, {"w": "you", "b": [0.1874, 0.6072, 0.2187, 0.6286]}, {"w": "can", "b": [0.2234, 0.6072, 0.2528, 0.6286]}, {"w": "use", "b": [0.2575, 0.6072, 0.2851, 0.6286]}, {"w": "it", "b": [0.2898, 0.6072, 0.3017, 0.6286]}, {"w": "to", "b": [0.3065, 0.6072, 0.3234, 0.6286]}, {"w": "detect", "b": [0.3282, 0.6072, 0.3784, 0.6286]}, {"w": "images", "b": [0.3831, 0.6072, 0.4412, 0.6286]}, {"w": "of", "b": [0.4459, 0.6072, 0.4627, 0.6286]}, {"w": "the", "b": [0.4674, 0.6072, 0.4938, 0.6286]}, {"w": "number", "b": [0.4985, 0.6072, 0.5648, 0.6286]}, {"w": "5:", "b": [0.5695, 0.6072, 0.5843, 0.6286]}]}, {"id": "b_10", "type": "equation", "text": ">>> sgd_clf.predict([some_digit]) array([ True])", "words": [{"w": ">>>", "b": [0.1766, 0.6392, 0.2019, 0.6521]}, {"w": "sgd_clf.predict([some_digit])", "b": [0.2103, 0.6392, 0.4549, 0.6521]}, {"w": "array([", "b": [0.1766, 0.6546, 0.2356, 0.6675]}, {"w": "True])", "b": [0.2441, 0.6546, 0.2946, 0.6675]}]}, {"id": "b_11", "type": "paragraph", "text": "The classifier guesses that this image represents a 5 (True). Looks like it guessed right in this particular case! Now, let’s evaluate this model’s performance.", "words": [{"w": "The", "b": [0.1429, 0.6762, 0.1757, 0.6976]}, {"w": "classifier", "b": [0.1809, 0.6762, 0.2533, 0.6976]}, {"w": "guesses", "b": [0.2586, 0.6762, 0.32, 0.6976]}, {"w": "that", "b": [0.3252, 0.6762, 0.3578, 0.6976]}, {"w": "this", "b": [0.363, 0.6762, 0.3937, 0.6976]}, {"w": "image", "b": [0.399, 0.6762, 0.4494, 0.6976]}, {"w": "represents", "b": [0.4546, 0.6762, 0.5401, 0.6976]}, {"w": "a", "b": [0.5454, 0.6762, 0.5545, 0.6976]}, {"w": "5", "b": [0.5597, 0.6762, 0.5697, 0.6976]}, {"w": "(True).", "b": [0.5749, 0.6762, 0.6337, 0.6976]}, {"w": "Looks", "b": [0.6389, 0.6762, 0.6893, 0.6976]}, {"w": "like", "b": [0.6946, 0.6762, 0.7246, 0.6976]}, {"w": "it", "b": [0.7298, 0.6762, 0.7418, 0.6976]}, {"w": "guessed", "b": [0.747, 0.6762, 0.8118, 0.6976]}, {"w": "right", "b": [0.817, 0.6762, 0.8571, 0.6976]}, {"w": "in", "b": [0.1429, 0.6952, 0.1598, 0.7166]}, {"w": "this", "b": [0.1646, 0.6952, 0.1953, 0.7166]}, {"w": "particular", "b": [0.2, 0.6952, 0.2817, 0.7166]}, {"w": "case!", "b": [0.2865, 0.6952, 0.3267, 0.7166]}, {"w": "Now,", "b": [0.3314, 0.6952, 0.3745, 0.7166]}, {"w": "let’s", "b": [0.3792, 0.6952, 0.4095, 0.7166]}, {"w": "evaluate", "b": [0.4142, 0.6952, 0.4821, 0.7166]}, {"w": "this", "b": [0.4869, 0.6952, 0.5176, 0.7166]}, {"w": "model’s", "b": [0.5223, 0.6952, 0.5849, 0.7166]}, {"w": "performance.", "b": [0.5896, 0.6952, 0.7016, 0.7166]}]}, {"id": "b_12", "type": "paragraph", "text": "Performance Measures", "words": [{"w": "Performance", "b": [0.1429, 0.7296, 0.3017, 0.7639]}, {"w": "Measures", "b": [0.3076, 0.7296, 0.4248, 0.7639]}]}, {"id": "b_13", "type": "paragraph", "text": "Evaluating a classifier is often significantly trickier than evaluating a regressor, so we will spend a large part of this chapter on this topic. There are many performance", "words": [{"w": "Evaluating", "b": [0.1429, 0.7708, 0.2312, 0.7922]}, {"w": "a", "b": [0.2371, 0.7708, 0.2462, 0.7922]}, {"w": "classifier", "b": [0.2521, 0.7708, 0.3246, 0.7922]}, {"w": "is", "b": [0.3304, 0.7708, 0.3437, 0.7922]}, {"w": "often", "b": [0.3495, 0.7708, 0.3929, 0.7922]}, {"w": "significantly", "b": [0.3988, 0.7708, 0.5007, 0.7922]}, {"w": "trickier", "b": [0.5065, 0.7708, 0.5675, 0.7922]}, {"w": "than", "b": [0.5734, 0.7708, 0.6114, 0.7922]}, {"w": "evaluating", "b": [0.6173, 0.7708, 0.7031, 0.7922]}, {"w": "a", "b": [0.709, 0.7708, 0.7181, 0.7922]}, {"w": "regressor,", "b": [0.724, 0.7708, 0.804, 0.7922]}, {"w": "so", "b": [0.8099, 0.7708, 0.8281, 0.7922]}, {"w": "we", "b": [0.834, 0.7708, 0.8571, 0.7922]}, {"w": "will", "b": [0.1429, 0.7898, 0.1733, 0.8113]}, {"w": "spend", "b": [0.1812, 0.7898, 0.231, 0.8113]}, {"w": "a", "b": [0.2389, 0.7898, 0.2481, 0.8113]}, {"w": "large", "b": [0.256, 0.7898, 0.2968, 0.8113]}, {"w": "part", "b": [0.3047, 0.7898, 0.3389, 0.8113]}, {"w": "of", "b": [0.3468, 0.7898, 0.3636, 0.8113]}, {"w": "this", "b": [0.3715, 0.7898, 0.4022, 0.8113]}, {"w": "chapter", "b": [0.4102, 0.7898, 0.4727, 0.8113]}, {"w": "on", "b": [0.4806, 0.7898, 0.5027, 0.8113]}, {"w": "this", "b": [0.5106, 0.7898, 0.5413, 0.8113]}, {"w": "topic.", "b": [0.5492, 0.7898, 0.5963, 0.8113]}, {"w": "There", "b": [0.6042, 0.7898, 0.6536, 0.8113]}, {"w": "are", "b": [0.6616, 0.7898, 0.6873, 0.8113]}, {"w": "many", "b": [0.6952, 0.7898, 0.7419, 0.8113]}, {"w": "performance", "b": [0.7499, 0.7898, 0.8572, 0.8113]}]}, {"id": "b_14", "type": "paragraph", "text": "90 | Chapter 3: Classification", "words": [{"w": "90", "b": [0.1428, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "3:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "Classification", "b": [0.26, 0.9225, 0.337, 0.9388]}]}]}, {"page": 117, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "measures available, so grab another coffee and get ready to learn many new concepts and acronyms!", "words": [{"w": "measures", "b": [0.1429, 0.0791, 0.2209, 0.1005]}, {"w": "available,", "b": [0.2264, 0.0791, 0.3034, 0.1005]}, {"w": "so", "b": [0.309, 0.0791, 0.3273, 0.1005]}, {"w": "grab", "b": [0.3328, 0.0791, 0.37, 0.1005]}, {"w": "another", "b": [0.3756, 0.0791, 0.4408, 0.1005]}, {"w": "coffee", "b": [0.4464, 0.0791, 0.4959, 0.1005]}, {"w": "and", "b": [0.5014, 0.0791, 0.533, 0.1005]}, {"w": "get", "b": [0.5385, 0.0791, 0.5635, 0.1005]}, {"w": "ready", "b": [0.569, 0.0791, 0.6153, 0.1005]}, {"w": "to", "b": [0.6209, 0.0791, 0.6379, 0.1005]}, {"w": "learn", "b": [0.6434, 0.0791, 0.6858, 0.1005]}, {"w": "many", "b": [0.6914, 0.0791, 0.7381, 0.1005]}, {"w": "new", "b": [0.7436, 0.0791, 0.7782, 0.1005]}, {"w": "concepts", "b": [0.7837, 0.0791, 0.8571, 0.1005]}, {"w": "and", "b": [0.1429, 0.0981, 0.1744, 0.1195]}, {"w": "acronyms!", "b": [0.1791, 0.0981, 0.2664, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "Measuring Accuracy Using Cross-Validation", "words": [{"w": "Measuring", "b": [0.1429, 0.1323, 0.2519, 0.1609]}, {"w": "Accuracy", "b": [0.2568, 0.1323, 0.3461, 0.1609]}, {"w": "Using", "b": [0.351, 0.1323, 0.409, 0.1609]}, {"w": "Cross-Validation", "b": [0.414, 0.1323, 0.5816, 0.1609]}]}, {"id": "b_2", "type": "paragraph", "text": "A good way to evaluate a model is to use cross-validation, just as you did in Chap‐ ter 2.", "words": [{"w": "A", "b": [0.1429, 0.1668, 0.1573, 0.1882]}, {"w": "good", "b": [0.164, 0.1668, 0.206, 0.1882]}, {"w": "way", "b": [0.2127, 0.1668, 0.2453, 0.1882]}, {"w": "to", "b": [0.252, 0.1668, 0.269, 0.1882]}, {"w": "evaluate", "b": [0.2757, 0.1668, 0.3437, 0.1882]}, {"w": "a", "b": [0.3504, 0.1668, 0.3595, 0.1882]}, {"w": "model", "b": [0.3663, 0.1668, 0.4191, 0.1882]}, {"w": "is", "b": [0.4258, 0.1668, 0.439, 0.1882]}, {"w": "to", "b": [0.4458, 0.1668, 0.4627, 0.1882]}, {"w": "use", "b": [0.4695, 0.1668, 0.497, 0.1882]}, {"w": "cross-validation,", "b": [0.5037, 0.1668, 0.6417, 0.1882]}, {"w": "just", "b": [0.6485, 0.1668, 0.6788, 0.1882]}, {"w": "as", "b": [0.6856, 0.1668, 0.7024, 0.1882]}, {"w": "you", "b": [0.7091, 0.1668, 0.7403, 0.1882]}, {"w": "did", "b": [0.7471, 0.1668, 0.7746, 0.1882]}, {"w": "in", "b": [0.7814, 0.1668, 0.7984, 0.1882]}, {"w": "Chap‐", "b": [0.8051, 0.1668, 0.8571, 0.1882]}, {"w": "ter", "b": [0.1429, 0.1858, 0.1658, 0.2072]}, {"w": "2.", "b": [0.1705, 0.1858, 0.1853, 0.2072]}]}, {"id": "b_3", "type": "equation", "text": "Implementing Cross-Validation", "words": [{"w": "Implementing", "b": [0.3474, 0.233, 0.4885, 0.2601]}, {"w": "Cross-Validation", "b": [0.4932, 0.233, 0.6526, 0.2601]}]}, {"id": "b_4", "type": "paragraph", "text": "Occasionally you will need more control over the cross-validation process than what Scikit-Learn provides off-the-shelf. In these cases, you can implement cross- validation yourself; it is actually fairly straightforward. The following code does roughly the same thing as Scikit-Learn’s cross_val_score() function, and prints the same result:", "words": [{"w": "Occasionally", "b": [0.1592, 0.2647, 0.261, 0.2851]}, {"w": "you", "b": [0.2666, 0.2647, 0.2964, 0.2851]}, {"w": "will", "b": [0.302, 0.2647, 0.331, 0.2851]}, {"w": "need", "b": [0.3366, 0.2647, 0.3748, 0.2851]}, {"w": "more", "b": [0.3805, 0.2647, 0.4226, 0.2851]}, {"w": "control", "b": [0.4283, 0.2647, 0.4858, 0.2851]}, {"w": "over", "b": [0.4915, 0.2647, 0.5266, 0.2851]}, {"w": "the", "b": [0.5322, 0.2647, 0.5573, 0.2851]}, {"w": "cross-validation", "b": [0.5629, 0.2647, 0.6898, 0.2851]}, {"w": "process", "b": [0.6954, 0.2647, 0.7547, 0.2851]}, {"w": "than", "b": [0.7604, 0.2647, 0.7966, 0.2851]}, {"w": "what", "b": [0.8022, 0.2647, 0.8408, 0.2851]}, {"w": "Scikit-Learn", "b": [0.1592, 0.2828, 0.2567, 0.3032]}, {"w": "provides", "b": [0.2698, 0.2828, 0.3384, 0.3032]}, {"w": "off-the-shelf.", "b": [0.3515, 0.2828, 0.4543, 0.3032]}, {"w": "In", "b": [0.4674, 0.2828, 0.4851, 0.3032]}, {"w": "these", "b": [0.4982, 0.2828, 0.539, 0.3032]}, {"w": "cases,", "b": [0.5521, 0.2828, 0.5968, 0.3032]}, {"w": "you", "b": [0.6099, 0.2828, 0.6397, 0.3032]}, {"w": "can", "b": [0.6528, 0.2828, 0.6808, 0.3032]}, {"w": "implement", "b": [0.6939, 0.2828, 0.7801, 0.3032]}, {"w": "cross-", "b": [0.7933, 0.2828, 0.8408, 0.3032]}, {"w": "validation", "b": [0.1592, 0.301, 0.2386, 0.3214]}, {"w": "yourself;", "b": [0.2484, 0.301, 0.3167, 0.3214]}, {"w": "it", "b": [0.3265, 0.301, 0.3378, 0.3214]}, {"w": "is", "b": [0.3476, 0.301, 0.3602, 0.3214]}, {"w": "actually", "b": [0.37, 0.301, 0.4316, 0.3214]}, {"w": "fairly", "b": [0.4414, 0.301, 0.4827, 0.3214]}, {"w": "straightforward.", "b": [0.4925, 0.301, 0.6214, 0.3214]}, {"w": "The", "b": [0.6312, 0.301, 0.6625, 0.3214]}, {"w": "following", "b": [0.6723, 0.301, 0.7475, 0.3214]}, {"w": "code", "b": [0.7573, 0.301, 0.7947, 0.3214]}, {"w": "does", "b": [0.8045, 0.301, 0.8408, 0.3214]}, {"w": "roughly", "b": [0.1592, 0.32, 0.2213, 0.3404]}, {"w": "the", "b": [0.2263, 0.32, 0.2514, 0.3404]}, {"w": "same", "b": [0.2564, 0.32, 0.2971, 0.3404]}, {"w": "thing", "b": [0.3021, 0.32, 0.3442, 0.3404]}, {"w": "as", "b": [0.3492, 0.32, 0.3652, 0.3404]}, {"w": "Scikit-Learn’s", "b": [0.3703, 0.32, 0.4759, 0.3404]}, {"w": "cross_val_score()", "b": [0.4809, 0.323, 0.6411, 0.3374]}, {"w": "function,", "b": [0.6461, 0.32, 0.7187, 0.3404]}, {"w": "and", "b": [0.7237, 0.32, 0.7537, 0.3404]}, {"w": "prints", "b": [0.7588, 0.32, 0.8056, 0.3404]}, {"w": "the", "b": [0.8107, 0.32, 0.8357, 0.3404]}, {"w": "same", "b": [0.1592, 0.3381, 0.1999, 0.3585]}, {"w": "result:", "b": [0.2044, 0.3381, 0.2536, 0.3585]}]}, {"id": "b_5", "type": "paragraph", "text": "from sklearn.model_selection import StratifiedKFold from sklearn.base import clone", "words": [{"w": "from", "b": [0.193, 0.369, 0.2267, 0.3819]}, {"w": "sklearn.model_selection", "b": [0.2351, 0.369, 0.4291, 0.3819]}, {"w": "import", "b": [0.4375, 0.369, 0.4881, 0.3819]}, {"w": "StratifiedKFold", "b": [0.4965, 0.369, 0.623, 0.3819]}, {"w": "from", "b": [0.193, 0.3845, 0.2267, 0.3973]}, {"w": "sklearn.base", "b": [0.2351, 0.3845, 0.3363, 0.3973]}, {"w": "import", "b": [0.3448, 0.3845, 0.3953, 0.3973]}, {"w": "clone", "b": [0.4038, 0.3845, 0.4459, 0.3973]}]}, {"id": "b_6", "type": "equation", "text": "skfolds = StratifiedKFold(n_splits=3, random_state=42)", "words": [{"w": "skfolds", "b": [0.193, 0.4153, 0.252, 0.4282]}, {"w": "=", "b": [0.2604, 0.4153, 0.2689, 0.4282]}, {"w": "StratifiedKFold(n_splits=3,", "b": [0.2773, 0.4153, 0.505, 0.4282]}, {"w": "random_state=42)", "b": [0.5134, 0.4153, 0.6483, 0.4282]}]}, {"id": "b_7", "type": "paragraph", "text": "for train_index, test_index in skfolds.split(X_train, y_train_5): clone_clf = clone(sgd_clf) X_train_folds = X_train[train_index] y_train_folds = y_train_5[train_index] X_test_fold = X_train[test_index] y_test_fold = y_train_5[test_index]", "words": [{"w": "for", "b": [0.193, 0.4461, 0.2183, 0.459]}, {"w": "train_index,", "b": [0.2267, 0.4461, 0.3279, 0.459]}, {"w": "test_index", "b": [0.3363, 0.4461, 0.4206, 0.459]}, {"w": "in", "b": [0.4291, 0.4461, 0.4459, 0.459]}, {"w": "skfolds.split(X_train,", "b": [0.4544, 0.4461, 0.6399, 0.459]}, {"w": "y_train_5):", "b": [0.6483, 0.4461, 0.7411, 0.459]}, {"w": "clone_clf", "b": [0.2267, 0.4616, 0.3026, 0.4744]}, {"w": "=", "b": [0.311, 0.4616, 0.3195, 0.4744]}, {"w": "clone(sgd_clf)", "b": [0.3279, 0.4616, 0.4459, 0.4744]}, {"w": "X_train_folds", "b": [0.2267, 0.477, 0.3363, 0.4898]}, {"w": "=", "b": [0.3448, 0.477, 0.3532, 0.4898]}, {"w": "X_train[train_index]", "b": [0.3616, 0.477, 0.5303, 0.4898]}, {"w": "y_train_folds", "b": [0.2267, 0.4924, 0.3363, 0.5053]}, {"w": "=", "b": [0.3448, 0.4924, 0.3532, 0.5053]}, {"w": "y_train_5[train_index]", "b": [0.3616, 0.4924, 0.5471, 0.5053]}, {"w": "X_test_fold", "b": [0.2267, 0.5078, 0.3195, 0.5207]}, {"w": "=", "b": [0.3279, 0.5078, 0.3363, 0.5207]}, {"w": "X_train[test_index]", "b": [0.3448, 0.5078, 0.505, 0.5207]}, {"w": "y_test_fold", "b": [0.2267, 0.5232, 0.3195, 0.5361]}, {"w": "=", "b": [0.3279, 0.5232, 0.3363, 0.5361]}, {"w": "y_train_5[test_index]", "b": [0.3448, 0.5232, 0.5218, 0.5361]}]}, {"id": "b_8", "type": "paragraph", "text": "clone_clf.fit(X_train_folds, y_train_folds) y_pred = clone_clf.predict(X_test_fold) n_correct = sum(y_pred == y_test_fold) print(n_correct / len(y_pred)) # prints 0.9502, 0.96565 and 0.96495", "words": [{"w": "clone_clf.fit(X_train_folds,", "b": [0.2267, 0.5541, 0.4628, 0.5669]}, {"w": "y_train_folds)", "b": [0.4712, 0.5541, 0.5893, 0.5669]}, {"w": "y_pred", "b": [0.2267, 0.5695, 0.2773, 0.5823]}, {"w": "=", "b": [0.2857, 0.5695, 0.2942, 0.5823]}, {"w": "clone_clf.predict(X_test_fold)", "b": [0.3026, 0.5695, 0.5556, 0.5823]}, {"w": "n_correct", "b": [0.2267, 0.5849, 0.3026, 0.5978]}, {"w": "=", "b": [0.311, 0.5849, 0.3195, 0.5978]}, {"w": "sum(y_pred", "b": [0.3279, 0.5849, 0.4122, 0.5978]}, {"w": "==", "b": [0.4206, 0.5849, 0.4375, 0.5978]}, {"w": "y_test_fold)", "b": [0.4459, 0.5849, 0.5471, 0.5978]}, {"w": "print(n_correct", "b": [0.2267, 0.6003, 0.3532, 0.6132]}, {"w": "/", "b": [0.3616, 0.6003, 0.37, 0.6132]}, {"w": "len(y_pred))", "b": [0.3785, 0.6003, 0.4797, 0.6132]}, {"w": "#", "b": [0.4965, 0.6003, 0.505, 0.6132]}, {"w": "prints", "b": [0.5134, 0.6003, 0.564, 0.6132]}, {"w": "0.9502,", "b": [0.5724, 0.6003, 0.6315, 0.6132]}, {"w": "0.96565", "b": [0.6399, 0.6003, 0.6989, 0.6132]}, {"w": "and", "b": [0.7073, 0.6003, 0.7326, 0.6132]}, {"w": "0.96495", "b": [0.7411, 0.6003, 0.8001, 0.6132]}]}, {"id": "b_9", "type": "paragraph", "text": "The StratifiedKFold class performs stratified sampling (as explained in Chapter 2) to produce folds that contain a representative ratio of each class. At each iteration the code creates a clone of the classifier, trains that clone on the training folds, and makes predictions on the test fold. Then it counts the number of correct predictions and outputs the ratio of correct predictions.", "words": [{"w": "The", "b": [0.1592, 0.6219, 0.1905, 0.6423]}, {"w": "StratifiedKFold", "b": [0.1964, 0.625, 0.3378, 0.6393]}, {"w": "class", "b": [0.3437, 0.6219, 0.3804, 0.6423]}, {"w": "performs", "b": [0.3863, 0.6219, 0.4594, 0.6423]}, {"w": "stratified", "b": [0.4653, 0.6219, 0.5358, 0.6423]}, {"w": "sampling", "b": [0.5417, 0.6219, 0.6144, 0.6423]}, {"w": "(as", "b": [0.6203, 0.6219, 0.6432, 0.6423]}, {"w": "explained", "b": [0.6491, 0.6219, 0.7261, 0.6423]}, {"w": "in", "b": [0.732, 0.6219, 0.7482, 0.6423]}, {"w": "Chapter", "b": [0.7541, 0.6219, 0.8185, 0.6423]}, {"w": "2)", "b": [0.8244, 0.6219, 0.8408, 0.6423]}, {"w": "to", "b": [0.1592, 0.6401, 0.1754, 0.6605]}, {"w": "produce", "b": [0.1805, 0.6401, 0.2462, 0.6605]}, {"w": "folds", "b": [0.2513, 0.6401, 0.2901, 0.6605]}, {"w": "that", "b": [0.2951, 0.6401, 0.3262, 0.6605]}, {"w": "contain", "b": [0.3313, 0.6401, 0.3912, 0.6605]}, {"w": "a", "b": [0.3963, 0.6401, 0.405, 0.6605]}, {"w": "representative", "b": [0.4101, 0.6401, 0.5216, 0.6605]}, {"w": "ratio", "b": [0.5267, 0.6401, 0.5639, 0.6605]}, {"w": "of", "b": [0.569, 0.6401, 0.5849, 0.6605]}, {"w": "each", "b": [0.59, 0.6401, 0.6262, 0.6605]}, {"w": "class.", "b": [0.6312, 0.6401, 0.6725, 0.6605]}, {"w": "At", "b": [0.6775, 0.6401, 0.6965, 0.6605]}, {"w": "each", "b": [0.7016, 0.6401, 0.7377, 0.6605]}, {"w": "iteration", "b": [0.7428, 0.6401, 0.8106, 0.6605]}, {"w": "the", "b": [0.8157, 0.6401, 0.8408, 0.6605]}, {"w": "code", "b": [0.1592, 0.6582, 0.1967, 0.6786]}, {"w": "creates", "b": [0.2014, 0.6582, 0.2557, 0.6786]}, {"w": "a", "b": [0.2605, 0.6582, 0.2692, 0.6786]}, {"w": "clone", "b": [0.274, 0.6582, 0.3168, 0.6786]}, {"w": "of", "b": [0.3216, 0.6582, 0.3376, 0.6786]}, {"w": "the", "b": [0.3424, 0.6582, 0.3675, 0.6786]}, {"w": "classifier,", "b": [0.3723, 0.6582, 0.4446, 0.6786]}, {"w": "trains", "b": [0.4494, 0.6582, 0.4949, 0.6786]}, {"w": "that", "b": [0.4997, 0.6582, 0.5308, 0.6786]}, {"w": "clone", "b": [0.5356, 0.6582, 0.5784, 0.6786]}, {"w": "on", "b": [0.5832, 0.6582, 0.6041, 0.6786]}, {"w": "the", "b": [0.6089, 0.6582, 0.634, 0.6786]}, {"w": "training", "b": [0.6388, 0.6582, 0.7026, 0.6786]}, {"w": "folds,", "b": [0.7073, 0.6582, 0.7506, 0.6786]}, {"w": "and", "b": [0.7554, 0.6582, 0.7855, 0.6786]}, {"w": "makes", "b": [0.7903, 0.6582, 0.8408, 0.6786]}, {"w": "predictions", "b": [0.1592, 0.6764, 0.2492, 0.6968]}, {"w": "on", "b": [0.2565, 0.6764, 0.2775, 0.6968]}, {"w": "the", "b": [0.2848, 0.6764, 0.3099, 0.6968]}, {"w": "test", "b": [0.3172, 0.6764, 0.345, 0.6968]}, {"w": "fold.", "b": [0.3523, 0.6764, 0.3883, 0.6968]}, {"w": "Then", "b": [0.3956, 0.6764, 0.4378, 0.6968]}, {"w": "it", "b": [0.4451, 0.6764, 0.4564, 0.6968]}, {"w": "counts", "b": [0.4637, 0.6764, 0.5166, 0.6968]}, {"w": "the", "b": [0.5239, 0.6764, 0.549, 0.6968]}, {"w": "number", "b": [0.5563, 0.6764, 0.6194, 0.6968]}, {"w": "of", "b": [0.6267, 0.6764, 0.6427, 0.6968]}, {"w": "correct", "b": [0.65, 0.6764, 0.7061, 0.6968]}, {"w": "predictions", "b": [0.7134, 0.6764, 0.8034, 0.6968]}, {"w": "and", "b": [0.8107, 0.6764, 0.8408, 0.6968]}, {"w": "outputs", "b": [0.1592, 0.6945, 0.2202, 0.7149]}, {"w": "the", "b": [0.2247, 0.6945, 0.2498, 0.7149]}, {"w": "ratio", "b": [0.2543, 0.6945, 0.2915, 0.7149]}, {"w": "of", "b": [0.296, 0.6945, 0.312, 0.7149]}, {"w": "correct", "b": [0.3165, 0.6945, 0.3726, 0.7149]}, {"w": "predictions.", "b": [0.3771, 0.6945, 0.4716, 0.7149]}]}, {"id": "b_10", "type": "paragraph", "text": "Let’s use the cross_val_score() function to evaluate your SGDClassifier model using K-fold cross-validation, with three folds. Remember that K-fold cross- validation means splitting the training set into K-folds (in this case, three), then mak‐ ing predictions and evaluating them on each fold using a model trained on the remaining folds (see Chapter 2):", "words": [{"w": "Let’s", "b": [0.1429, 0.7456, 0.179, 0.767]}, {"w": "use", "b": [0.1878, 0.7456, 0.2154, 0.767]}, {"w": "the", "b": [0.2242, 0.7456, 0.2505, 0.767]}, {"w": "cross_val_score()", "b": [0.2593, 0.7487, 0.4276, 0.7638]}, {"w": "function", "b": [0.4364, 0.7456, 0.5078, 0.767]}, {"w": "to", "b": [0.5166, 0.7456, 0.5336, 0.767]}, {"w": "evaluate", "b": [0.5424, 0.7456, 0.6103, 0.767]}, {"w": "your", "b": [0.6191, 0.7456, 0.6581, 0.767]}, {"w": "SGDClassifier", "b": [0.6669, 0.7487, 0.7955, 0.7638]}, {"w": "model", "b": [0.8043, 0.7456, 0.8572, 0.767]}, {"w": "using", "b": [0.1429, 0.7646, 0.1883, 0.786]}, {"w": "K-fold", "b": [0.2018, 0.7646, 0.2563, 0.786]}, {"w": "cross-validation,", "b": [0.2699, 0.7646, 0.4078, 0.786]}, {"w": "with", "b": [0.4214, 0.7646, 0.4587, 0.786]}, {"w": "three", "b": [0.4722, 0.7646, 0.5151, 0.786]}, {"w": "folds.", "b": [0.5287, 0.7646, 0.5741, 0.786]}, {"w": "Remember", "b": [0.5877, 0.7646, 0.6796, 0.786]}, {"w": "that", "b": [0.6931, 0.7646, 0.7257, 0.786]}, {"w": "K-fold", "b": [0.7392, 0.7646, 0.7937, 0.786]}, {"w": "cross-", "b": [0.8073, 0.7646, 0.8571, 0.786]}, {"w": "validation", "b": [0.1429, 0.7836, 0.2262, 0.8051]}, {"w": "means", "b": [0.2312, 0.7836, 0.2853, 0.8051]}, {"w": "splitting", "b": [0.2904, 0.7836, 0.3592, 0.8051]}, {"w": "the", "b": [0.3643, 0.7836, 0.3906, 0.8051]}, {"w": "training", "b": [0.3956, 0.7836, 0.4626, 0.8051]}, {"w": "set", "b": [0.4676, 0.7836, 0.4905, 0.8051]}, {"w": "into", "b": [0.4955, 0.7836, 0.5291, 0.8051]}, {"w": "K-folds", "b": [0.5341, 0.7836, 0.5963, 0.8051]}, {"w": "(in", "b": [0.6013, 0.7836, 0.6255, 0.8051]}, {"w": "this", "b": [0.6305, 0.7836, 0.6612, 0.8051]}, {"w": "case,", "b": [0.6663, 0.7836, 0.7055, 0.8051]}, {"w": "three),", "b": [0.7105, 0.7836, 0.7654, 0.8051]}, {"w": "then", "b": [0.7704, 0.7836, 0.8081, 0.8051]}, {"w": "mak‐", "b": [0.8132, 0.7836, 0.8571, 0.8051]}, {"w": "ing", "b": [0.1429, 0.8027, 0.1696, 0.8241]}, {"w": "predictions", "b": [0.1791, 0.8027, 0.2736, 0.8241]}, {"w": "and", "b": [0.2831, 0.8027, 0.3146, 0.8241]}, {"w": "evaluating", "b": [0.3241, 0.8027, 0.4099, 0.8241]}, {"w": "them", "b": [0.4194, 0.8027, 0.4628, 0.8241]}, {"w": "on", "b": [0.4723, 0.8027, 0.4944, 0.8241]}, {"w": "each", "b": [0.5039, 0.8027, 0.5418, 0.8241]}, {"w": "fold", "b": [0.5513, 0.8027, 0.5844, 0.8241]}, {"w": "using", "b": [0.5938, 0.8027, 0.6393, 0.8241]}, {"w": "a", "b": [0.6488, 0.8027, 0.6579, 0.8241]}, {"w": "model", "b": [0.6674, 0.8027, 0.7202, 0.8241]}, {"w": "trained", "b": [0.7297, 0.8027, 0.7898, 0.8241]}, {"w": "on", "b": [0.7993, 0.8027, 0.8213, 0.8241]}, {"w": "the", "b": [0.8308, 0.8027, 0.8572, 0.8241]}, {"w": "remaining", "b": [0.1429, 0.8217, 0.2294, 0.8432]}, {"w": "folds", "b": [0.2341, 0.8217, 0.2748, 0.8432]}, {"w": "(see", "b": [0.2795, 0.8217, 0.3121, 0.8432]}, {"w": "Chapter", "b": [0.3168, 0.8217, 0.3844, 0.8432]}, {"w": "2):", "b": [0.3891, 0.8217, 0.4111, 0.8432]}]}, {"id": "b_11", "type": "paragraph", "text": "Performance Measures | 91", "words": [{"w": "Performance", "b": [0.669, 0.9225, 0.7446, 0.9388]}, {"w": "Measures", "b": [0.7474, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "91", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 118, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": ">>> from sklearn.model_selection import cross_val_score >>> cross_val_score(sgd_clf, X_train, y_train_5, cv=3, scoring=\"accuracy\") array([0.96355, 0.93795, 0.95615])", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "from", "b": [0.2103, 0.0829, 0.244, 0.0958]}, {"w": "sklearn.model_selection", "b": [0.2525, 0.0829, 0.4464, 0.0958]}, {"w": "import", "b": [0.4549, 0.0829, 0.5055, 0.0958]}, {"w": "cross_val_score", "b": [0.5139, 0.0829, 0.6404, 0.0958]}, {"w": ">>>", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "cross_val_score(sgd_clf,", "b": [0.2103, 0.0983, 0.4127, 0.1112]}, {"w": "X_train,", "b": [0.4211, 0.0983, 0.4886, 0.1112]}, {"w": "y_train_5,", "b": [0.497, 0.0983, 0.5813, 0.1112]}, {"w": "cv=3,", "b": [0.5898, 0.0983, 0.6319, 0.1112]}, {"w": "scoring=\"accuracy\")", "b": [0.6404, 0.0983, 0.8006, 0.1112]}, {"w": "array([0.96355,", "b": [0.1766, 0.1138, 0.3031, 0.1266]}, {"w": "0.93795,", "b": [0.3115, 0.1138, 0.379, 0.1266]}, {"w": "0.95615])", "b": [0.3874, 0.1138, 0.4633, 0.1266]}]}, {"id": "b_1", "type": "paragraph", "text": "Wow! Above 93% accuracy (ratio of correct predictions) on all cross-validation folds? This looks amazing, doesn’t it? Well, before you get too excited, let’s look at a very dumb classifier that just classifies every single image in the “not-5” class:", "words": [{"w": "Wow!", "b": [0.1429, 0.1344, 0.1917, 0.1558]}, {"w": "Above", "b": [0.1964, 0.1344, 0.2499, 0.1558]}, {"w": "93%", "b": [0.2546, 0.1344, 0.2904, 0.1558]}, {"w": "accuracy", "b": [0.2954, 0.1342, 0.3667, 0.1558]}, {"w": "(ratio", "b": [0.3715, 0.1344, 0.4178, 0.1558]}, {"w": "of", "b": [0.4225, 0.1344, 0.4393, 0.1558]}, {"w": "correct", "b": [0.444, 0.1344, 0.5029, 0.1558]}, {"w": "predictions)", "b": [0.5076, 0.1344, 0.6094, 0.1558]}, {"w": "on", "b": [0.6141, 0.1344, 0.6361, 0.1558]}, {"w": "all", "b": [0.6408, 0.1344, 0.6605, 0.1558]}, {"w": "cross-validation", "b": [0.6653, 0.1344, 0.7985, 0.1558]}, {"w": "folds?", "b": [0.8032, 0.1344, 0.8518, 0.1558]}, {"w": "This", "b": [0.1429, 0.1534, 0.1801, 0.1749]}, {"w": "looks", "b": [0.1873, 0.1534, 0.2318, 0.1749]}, {"w": "amazing,", "b": [0.239, 0.1534, 0.3146, 0.1749]}, {"w": "doesn’t", "b": [0.3218, 0.1534, 0.3799, 0.1749]}, {"w": "it?", "b": [0.3871, 0.1534, 0.407, 0.1749]}, {"w": "Well,", "b": [0.4142, 0.1534, 0.4565, 0.1749]}, {"w": "before", "b": [0.4638, 0.1534, 0.5166, 0.1749]}, {"w": "you", "b": [0.5238, 0.1534, 0.555, 0.1749]}, {"w": "get", "b": [0.5623, 0.1534, 0.5872, 0.1749]}, {"w": "too", "b": [0.5944, 0.1534, 0.622, 0.1749]}, {"w": "excited,", "b": [0.6293, 0.1534, 0.6933, 0.1749]}, {"w": "let’s", "b": [0.7005, 0.1534, 0.7308, 0.1749]}, {"w": "look", "b": [0.738, 0.1534, 0.7748, 0.1749]}, {"w": "at", "b": [0.7821, 0.1534, 0.7972, 0.1749]}, {"w": "a", "b": [0.8044, 0.1534, 0.8135, 0.1749]}, {"w": "very", "b": [0.8207, 0.1534, 0.8571, 0.1749]}, {"w": "dumb", "b": [0.1429, 0.1725, 0.1926, 0.1939]}, {"w": "classifier", "b": [0.1973, 0.1725, 0.2697, 0.1939]}, {"w": "that", "b": [0.2745, 0.1725, 0.307, 0.1939]}, {"w": "just", "b": [0.3118, 0.1725, 0.3422, 0.1939]}, {"w": "classifies", "b": [0.3469, 0.1725, 0.4192, 0.1939]}, {"w": "every", "b": [0.424, 0.1725, 0.4692, 0.1939]}, {"w": "single", "b": [0.474, 0.1725, 0.5225, 0.1939]}, {"w": "image", "b": [0.5272, 0.1725, 0.5776, 0.1939]}, {"w": "in", "b": [0.5823, 0.1725, 0.5993, 0.1939]}, {"w": "the", "b": [0.604, 0.1725, 0.6304, 0.1939]}, {"w": "“not-5”", "b": [0.6351, 0.1725, 0.6969, 0.1939]}, {"w": "class:", "b": [0.7016, 0.1725, 0.7449, 0.1939]}]}, {"id": "b_2", "type": "paragraph", "text": "from sklearn.base import BaseEstimator", "words": [{"w": "from", "b": [0.1766, 0.2045, 0.2103, 0.2173]}, {"w": "sklearn.base", "b": [0.2187, 0.2045, 0.3199, 0.2173]}, {"w": "import", "b": [0.3284, 0.2045, 0.379, 0.2173]}, {"w": "BaseEstimator", "b": [0.3874, 0.2045, 0.497, 0.2173]}]}, {"id": "b_3", "type": "paragraph", "text": "class Never5Classifier(BaseEstimator): def fit(self, X, y=None): pass def predict(self, X): return np.zeros((len(X), 1), dtype=bool)", "words": [{"w": "class", "b": [0.1766, 0.2353, 0.2187, 0.2481]}, {"w": "Never5Classifier(BaseEstimator):", "b": [0.2272, 0.2353, 0.497, 0.2481]}, {"w": "def", "b": [0.2103, 0.2507, 0.2356, 0.2636]}, {"w": "fit(self,", "b": [0.244, 0.2507, 0.3199, 0.2636]}, {"w": "X,", "b": [0.3284, 0.2507, 0.3452, 0.2636]}, {"w": "y=None):", "b": [0.3537, 0.2507, 0.4211, 0.2636]}, {"w": "pass", "b": [0.244, 0.2661, 0.2778, 0.279]}, {"w": "def", "b": [0.2103, 0.2816, 0.2356, 0.2944]}, {"w": "predict(self,", "b": [0.244, 0.2816, 0.3537, 0.2944]}, {"w": "X):", "b": [0.3621, 0.2816, 0.3874, 0.2944]}, {"w": "return", "b": [0.244, 0.297, 0.2946, 0.3098]}, {"w": "np.zeros((len(X),", "b": [0.3031, 0.297, 0.4464, 0.3098]}, {"w": "1),", "b": [0.4549, 0.297, 0.4802, 0.3098]}, {"w": "dtype=bool)", "b": [0.4886, 0.297, 0.5813, 0.3098]}]}, {"id": "b_4", "type": "paragraph", "text": "Can you guess this model’s accuracy? Let’s find out:", "words": [{"w": "Can", "b": [0.1428, 0.3176, 0.1772, 0.339]}, {"w": "you", "b": [0.182, 0.3176, 0.2132, 0.339]}, {"w": "guess", "b": [0.218, 0.3176, 0.2629, 0.339]}, {"w": "this", "b": [0.2676, 0.3176, 0.2983, 0.339]}, {"w": "model’s", "b": [0.3031, 0.3176, 0.3657, 0.339]}, {"w": "accuracy?", "b": [0.3704, 0.3176, 0.4514, 0.339]}, {"w": "Let’s", "b": [0.4561, 0.3176, 0.4923, 0.339]}, {"w": "find", "b": [0.497, 0.3176, 0.5311, 0.339]}, {"w": "out:", "b": [0.5359, 0.3176, 0.5687, 0.339]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> never_5_clf = Never5Classifier() >>> cross_val_score(never_5_clf, X_train, y_train_5, cv=3, scoring=\"accuracy\") array([0.91125, 0.90855, 0.90915])", "words": [{"w": ">>>", "b": [0.1766, 0.3496, 0.2019, 0.3624]}, {"w": "never_5_clf", "b": [0.2103, 0.3496, 0.3031, 0.3624]}, {"w": "=", "b": [0.3115, 0.3496, 0.3199, 0.3624]}, {"w": "Never5Classifier()", "b": [0.3284, 0.3496, 0.4802, 0.3624]}, {"w": ">>>", "b": [0.1766, 0.365, 0.2019, 0.3779]}, {"w": "cross_val_score(never_5_clf,", "b": [0.2103, 0.365, 0.4464, 0.3779]}, {"w": "X_train,", "b": [0.4549, 0.365, 0.5223, 0.3779]}, {"w": "y_train_5,", "b": [0.5307, 0.365, 0.6151, 0.3779]}, {"w": "cv=3,", "b": [0.6235, 0.365, 0.6657, 0.3779]}, {"w": "scoring=\"accuracy\")", "b": [0.6741, 0.365, 0.8343, 0.3779]}, {"w": "array([0.91125,", "b": [0.1766, 0.3804, 0.3031, 0.3933]}, {"w": "0.90855,", "b": [0.3115, 0.3804, 0.379, 0.3933]}, {"w": "0.90915])", "b": [0.3874, 0.3804, 0.4633, 0.3933]}]}, {"id": "b_6", "type": "paragraph", "text": "That’s right, it has over 90% accuracy! This is simply because only about 10% of the images are 5s, so if you always guess that an image is not a 5, you will be right about 90% of the time. Beats Nostradamus.", "words": [{"w": "That’s", "b": [0.1428, 0.4011, 0.1917, 0.4225]}, {"w": "right,", "b": [0.198, 0.4011, 0.2429, 0.4225]}, {"w": "it", "b": [0.2493, 0.4011, 0.2612, 0.4225]}, {"w": "has", "b": [0.2675, 0.4011, 0.2955, 0.4225]}, {"w": "over", "b": [0.3018, 0.4011, 0.3387, 0.4225]}, {"w": "90%", "b": [0.345, 0.4011, 0.3807, 0.4225]}, {"w": "accuracy!", "b": [0.3871, 0.4011, 0.4659, 0.4225]}, {"w": "This", "b": [0.4723, 0.4011, 0.5095, 0.4225]}, {"w": "is", "b": [0.5158, 0.4011, 0.529, 0.4225]}, {"w": "simply", "b": [0.5354, 0.4011, 0.591, 0.4225]}, {"w": "because", "b": [0.5974, 0.4011, 0.6619, 0.4225]}, {"w": "only", "b": [0.6683, 0.4011, 0.7051, 0.4225]}, {"w": "about", "b": [0.7115, 0.4011, 0.7592, 0.4225]}, {"w": "10%", "b": [0.7656, 0.4011, 0.8013, 0.4225]}, {"w": "of", "b": [0.8077, 0.4011, 0.8245, 0.4225]}, {"w": "the", "b": [0.8308, 0.4011, 0.8571, 0.4225]}, {"w": "images", "b": [0.1429, 0.4201, 0.2009, 0.4415]}, {"w": "are", "b": [0.2067, 0.4201, 0.2325, 0.4415]}, {"w": "5s,", "b": [0.2383, 0.4201, 0.2607, 0.4415]}, {"w": "so", "b": [0.2665, 0.4201, 0.2848, 0.4415]}, {"w": "if", "b": [0.2906, 0.4201, 0.3024, 0.4415]}, {"w": "you", "b": [0.3082, 0.4201, 0.3394, 0.4415]}, {"w": "always", "b": [0.3453, 0.4201, 0.3999, 0.4415]}, {"w": "guess", "b": [0.4058, 0.4201, 0.4507, 0.4415]}, {"w": "that", "b": [0.4565, 0.4201, 0.4891, 0.4415]}, {"w": "an", "b": [0.4949, 0.4201, 0.5155, 0.4415]}, {"w": "image", "b": [0.5213, 0.4201, 0.5717, 0.4415]}, {"w": "is", "b": [0.5775, 0.4201, 0.5908, 0.4415]}, {"w": "not", "b": [0.5966, 0.4199, 0.6235, 0.4415]}, {"w": "a", "b": [0.6293, 0.4201, 0.6384, 0.4415]}, {"w": "5,", "b": [0.6443, 0.4201, 0.659, 0.4415]}, {"w": "you", "b": [0.6648, 0.4201, 0.6961, 0.4415]}, {"w": "will", "b": [0.7019, 0.4201, 0.7323, 0.4415]}, {"w": "be", "b": [0.7381, 0.4201, 0.7576, 0.4415]}, {"w": "right", "b": [0.7634, 0.4201, 0.8036, 0.4415]}, {"w": "about", "b": [0.8094, 0.4201, 0.8572, 0.4415]}, {"w": "90%", "b": [0.1429, 0.4392, 0.1786, 0.4606]}, {"w": "of", "b": [0.1833, 0.4392, 0.2001, 0.4606]}, {"w": "the", "b": [0.2049, 0.4392, 0.2312, 0.4606]}, {"w": "time.", "b": [0.2359, 0.4392, 0.2785, 0.4606]}, {"w": "Beats", "b": [0.2833, 0.4392, 0.3275, 0.4606]}, {"w": "Nostradamus.", "b": [0.3323, 0.4392, 0.449, 0.4606]}]}, {"id": "b_7", "type": "paragraph", "text": "This demonstrates why accuracy is generally not the preferred performance measure for classifiers, especially when you are dealing with skewed datasets (i.e., when some classes are much more frequent than others).", "words": [{"w": "This", "b": [0.1429, 0.4673, 0.1801, 0.4887]}, {"w": "demonstrates", "b": [0.1859, 0.4673, 0.2981, 0.4887]}, {"w": "why", "b": [0.3039, 0.4673, 0.3384, 0.4887]}, {"w": "accuracy", "b": [0.3442, 0.4673, 0.4173, 0.4887]}, {"w": "is", "b": [0.4231, 0.4673, 0.4363, 0.4887]}, {"w": "generally", "b": [0.4421, 0.4673, 0.518, 0.4887]}, {"w": "not", "b": [0.5238, 0.4673, 0.5521, 0.4887]}, {"w": "the", "b": [0.5579, 0.4673, 0.5843, 0.4887]}, {"w": "preferred", "b": [0.5901, 0.4673, 0.6679, 0.4887]}, {"w": "performance", "b": [0.6737, 0.4673, 0.781, 0.4887]}, {"w": "measure", "b": [0.7868, 0.4673, 0.8571, 0.4887]}, {"w": "for", "b": [0.1429, 0.4863, 0.1674, 0.5077]}, {"w": "classifiers,", "b": [0.1737, 0.4863, 0.2585, 0.5077]}, {"w": "especially", "b": [0.2648, 0.4863, 0.3447, 0.5077]}, {"w": "when", "b": [0.351, 0.4863, 0.3966, 0.5077]}, {"w": "you", "b": [0.4029, 0.4863, 0.4342, 0.5077]}, {"w": "are", "b": [0.4405, 0.4863, 0.4662, 0.5077]}, {"w": "dealing", "b": [0.4725, 0.4863, 0.5335, 0.5077]}, {"w": "with", "b": [0.5398, 0.4863, 0.5771, 0.5077]}, {"w": "skewed", "b": [0.5834, 0.4861, 0.6409, 0.5077]}, {"w": "datasets", "b": [0.6472, 0.4861, 0.7125, 0.5077]}, {"w": "(i.e.,", "b": [0.7188, 0.4863, 0.7547, 0.5077]}, {"w": "when", "b": [0.761, 0.4863, 0.8067, 0.5077]}, {"w": "some", "b": [0.8129, 0.4863, 0.8571, 0.5077]}, {"w": "classes", "b": [0.1429, 0.5054, 0.1979, 0.5268]}, {"w": "are", "b": [0.2026, 0.5054, 0.2283, 0.5268]}, {"w": "much", "b": [0.2331, 0.5054, 0.2807, 0.5268]}, {"w": "more", "b": [0.2855, 0.5054, 0.3297, 0.5268]}, {"w": "frequent", "b": [0.3345, 0.5054, 0.4051, 0.5268]}, {"w": "than", "b": [0.4099, 0.5054, 0.4479, 0.5268]}, {"w": "others).", "b": [0.4526, 0.5054, 0.5169, 0.5268]}]}, {"id": "b_8", "type": "paragraph", "text": "Confusion Matrix", "words": [{"w": "Confusion", "b": [0.1429, 0.5395, 0.2453, 0.5681]}, {"w": "Matrix", "b": [0.2503, 0.5395, 0.3175, 0.5681]}]}, {"id": "b_9", "type": "paragraph", "text": "A much better way to evaluate the performance of a classifier is to look at the confu‐ sion matrix. The general idea is to count the number of times instances of class A are classified as class B. For example, to know the number of times the classifier confused images of 5s with 3s, you would look in the 5th row and 3rd column of the confusion matrix.", "words": [{"w": "A", "b": [0.1429, 0.574, 0.1573, 0.5954]}, {"w": "much", "b": [0.1631, 0.574, 0.2108, 0.5954]}, {"w": "better", "b": [0.2166, 0.574, 0.2653, 0.5954]}, {"w": "way", "b": [0.2712, 0.574, 0.3038, 0.5954]}, {"w": "to", "b": [0.3096, 0.574, 0.3266, 0.5954]}, {"w": "evaluate", "b": [0.3324, 0.574, 0.4003, 0.5954]}, {"w": "the", "b": [0.4062, 0.574, 0.4325, 0.5954]}, {"w": "performance", "b": [0.4383, 0.574, 0.5456, 0.5954]}, {"w": "of", "b": [0.5515, 0.574, 0.5683, 0.5954]}, {"w": "a", "b": [0.5741, 0.574, 0.5832, 0.5954]}, {"w": "classifier", "b": [0.5891, 0.574, 0.6615, 0.5954]}, {"w": "is", "b": [0.6673, 0.574, 0.6806, 0.5954]}, {"w": "to", "b": [0.6864, 0.574, 0.7034, 0.5954]}, {"w": "look", "b": [0.7092, 0.574, 0.7461, 0.5954]}, {"w": "at", "b": [0.7519, 0.574, 0.767, 0.5954]}, {"w": "the", "b": [0.7728, 0.574, 0.7992, 0.5954]}, {"w": "confu‐", "b": [0.805, 0.5738, 0.8572, 0.5954]}, {"w": "sion", "b": [0.1429, 0.5929, 0.1759, 0.6145]}, {"w": "matrix.", "b": [0.1814, 0.5929, 0.2417, 0.6145]}, {"w": "The", "b": [0.2472, 0.5931, 0.28, 0.6145]}, {"w": "general", "b": [0.2855, 0.5931, 0.3465, 0.6145]}, {"w": "idea", "b": [0.3519, 0.5931, 0.3865, 0.6145]}, {"w": "is", "b": [0.392, 0.5931, 0.4052, 0.6145]}, {"w": "to", "b": [0.4106, 0.5931, 0.4276, 0.6145]}, {"w": "count", "b": [0.4331, 0.5931, 0.4809, 0.6145]}, {"w": "the", "b": [0.4864, 0.5931, 0.5127, 0.6145]}, {"w": "number", "b": [0.5181, 0.5931, 0.5844, 0.6145]}, {"w": "of", "b": [0.5899, 0.5931, 0.6067, 0.6145]}, {"w": "times", "b": [0.6121, 0.5931, 0.6576, 0.6145]}, {"w": "instances", "b": [0.6631, 0.5931, 0.7399, 0.6145]}, {"w": "of", "b": [0.7454, 0.5931, 0.7622, 0.6145]}, {"w": "class", "b": [0.7676, 0.5931, 0.8061, 0.6145]}, {"w": "A", "b": [0.8116, 0.5931, 0.826, 0.6145]}, {"w": "are", "b": [0.8314, 0.5931, 0.8571, 0.6145]}, {"w": "classified", "b": [0.1429, 0.6121, 0.2186, 0.6335]}, {"w": "as", "b": [0.2236, 0.6121, 0.2404, 0.6335]}, {"w": "class", "b": [0.2454, 0.6121, 0.2839, 0.6335]}, {"w": "B.", "b": [0.289, 0.6121, 0.3056, 0.6335]}, {"w": "For", "b": [0.3107, 0.6121, 0.3396, 0.6335]}, {"w": "example,", "b": [0.3447, 0.6121, 0.419, 0.6335]}, {"w": "to", "b": [0.424, 0.6121, 0.441, 0.6335]}, {"w": "know", "b": [0.446, 0.6121, 0.4926, 0.6335]}, {"w": "the", "b": [0.4977, 0.6121, 0.524, 0.6335]}, {"w": "number", "b": [0.529, 0.6121, 0.5953, 0.6335]}, {"w": "of", "b": [0.6004, 0.6121, 0.6172, 0.6335]}, {"w": "times", "b": [0.6222, 0.6121, 0.6677, 0.6335]}, {"w": "the", "b": [0.6727, 0.6121, 0.6991, 0.6335]}, {"w": "classifier", "b": [0.7041, 0.6121, 0.7765, 0.6335]}, {"w": "confused", "b": [0.7816, 0.6121, 0.8571, 0.6335]}, {"w": "images", "b": [0.1428, 0.6312, 0.2009, 0.6526]}, {"w": "of", "b": [0.2069, 0.6312, 0.2237, 0.6526]}, {"w": "5s", "b": [0.2297, 0.6312, 0.2473, 0.6526]}, {"w": "with", "b": [0.2533, 0.6312, 0.2906, 0.6526]}, {"w": "3s,", "b": [0.2966, 0.6312, 0.319, 0.6526]}, {"w": "you", "b": [0.325, 0.6312, 0.3563, 0.6526]}, {"w": "would", "b": [0.3623, 0.6312, 0.4145, 0.6526]}, {"w": "look", "b": [0.4205, 0.6312, 0.4573, 0.6526]}, {"w": "in", "b": [0.4633, 0.6312, 0.4803, 0.6526]}, {"w": "the", "b": [0.4863, 0.6312, 0.5126, 0.6526]}, {"w": "5th", "b": [0.5186, 0.6312, 0.5391, 0.6526]}, {"w": "row", "b": [0.5451, 0.6312, 0.5777, 0.6526]}, {"w": "and", "b": [0.5837, 0.6312, 0.6153, 0.6526]}, {"w": "3rd", "b": [0.6213, 0.6312, 0.6425, 0.6526]}, {"w": "column", "b": [0.6485, 0.6312, 0.7127, 0.6526]}, {"w": "of", "b": [0.7187, 0.6312, 0.7355, 0.6526]}, {"w": "the", "b": [0.7415, 0.6312, 0.7678, 0.6526]}, {"w": "confusion", "b": [0.7738, 0.6312, 0.8571, 0.6526]}, {"w": "matrix.", "b": [0.1429, 0.6502, 0.2029, 0.6716]}]}, {"id": "b_10", "type": "paragraph", "text": "To compute the confusion matrix, you first need to have a set of predictions, so they can be compared to the actual targets. You could make predictions on the test set, but let’s keep it untouched for now (remember that you want to use the test set only at the very end of your project, once you have a classifier that you are ready to launch). Instead, you can use the cross_val_predict() function:", "words": [{"w": "To", "b": [0.1429, 0.6783, 0.1643, 0.6997]}, {"w": "compute", "b": [0.1701, 0.6783, 0.2434, 0.6997]}, {"w": "the", "b": [0.2492, 0.6783, 0.2756, 0.6997]}, {"w": "confusion", "b": [0.2814, 0.6783, 0.3647, 0.6997]}, {"w": "matrix,", "b": [0.3705, 0.6783, 0.4306, 0.6997]}, {"w": "you", "b": [0.4364, 0.6783, 0.4677, 0.6997]}, {"w": "first", "b": [0.4735, 0.6783, 0.507, 0.6997]}, {"w": "need", "b": [0.5128, 0.6783, 0.5529, 0.6997]}, {"w": "to", "b": [0.5588, 0.6783, 0.5757, 0.6997]}, {"w": "have", "b": [0.5816, 0.6783, 0.62, 0.6997]}, {"w": "a", "b": [0.6258, 0.6783, 0.6349, 0.6997]}, {"w": "set", "b": [0.6408, 0.6783, 0.6636, 0.6997]}, {"w": "of", "b": [0.6694, 0.6783, 0.6862, 0.6997]}, {"w": "predictions,", "b": [0.6921, 0.6783, 0.7913, 0.6997]}, {"w": "so", "b": [0.7971, 0.6783, 0.8154, 0.6997]}, {"w": "they", "b": [0.8212, 0.6783, 0.8571, 0.6997]}, {"w": "can", "b": [0.1428, 0.6974, 0.1722, 0.7188]}, {"w": "be", "b": [0.1773, 0.6974, 0.1967, 0.7188]}, {"w": "compared", "b": [0.2018, 0.6974, 0.2855, 0.7188]}, {"w": "to", "b": [0.2906, 0.6974, 0.3075, 0.7188]}, {"w": "the", "b": [0.3126, 0.6974, 0.3389, 0.7188]}, {"w": "actual", "b": [0.344, 0.6974, 0.3938, 0.7188]}, {"w": "targets.", "b": [0.3988, 0.6974, 0.4594, 0.7188]}, {"w": "You", "b": [0.4645, 0.6974, 0.4968, 0.7188]}, {"w": "could", "b": [0.5019, 0.6974, 0.5487, 0.7188]}, {"w": "make", "b": [0.5537, 0.6974, 0.5991, 0.7188]}, {"w": "predictions", "b": [0.6042, 0.6974, 0.6987, 0.7188]}, {"w": "on", "b": [0.7037, 0.6974, 0.7258, 0.7188]}, {"w": "the", "b": [0.7308, 0.6974, 0.7571, 0.7188]}, {"w": "test", "b": [0.7622, 0.6974, 0.7914, 0.7188]}, {"w": "set,", "b": [0.7965, 0.6974, 0.8241, 0.7188]}, {"w": "but", "b": [0.8291, 0.6974, 0.8571, 0.7188]}, {"w": "let’s", "b": [0.1429, 0.7164, 0.1731, 0.7378]}, {"w": "keep", "b": [0.178, 0.7164, 0.2169, 0.7378]}, {"w": "it", "b": [0.2218, 0.7164, 0.2337, 0.7378]}, {"w": "untouched", "b": [0.2386, 0.7164, 0.3285, 0.7378]}, {"w": "for", "b": [0.3333, 0.7164, 0.3579, 0.7378]}, {"w": "now", "b": [0.3627, 0.7164, 0.399, 0.7378]}, {"w": "(remember", "b": [0.4039, 0.7164, 0.4978, 0.7378]}, {"w": "that", "b": [0.5027, 0.7164, 0.5353, 0.7378]}, {"w": "you", "b": [0.5401, 0.7164, 0.5714, 0.7378]}, {"w": "want", "b": [0.5762, 0.7164, 0.617, 0.7378]}, {"w": "to", "b": [0.6219, 0.7164, 0.6389, 0.7378]}, {"w": "use", "b": [0.6437, 0.7164, 0.6713, 0.7378]}, {"w": "the", "b": [0.6761, 0.7164, 0.7025, 0.7378]}, {"w": "test", "b": [0.7073, 0.7164, 0.7365, 0.7378]}, {"w": "set", "b": [0.7414, 0.7164, 0.7643, 0.7378]}, {"w": "only", "b": [0.7691, 0.7164, 0.806, 0.7378]}, {"w": "at", "b": [0.8108, 0.7164, 0.826, 0.7378]}, {"w": "the", "b": [0.8308, 0.7164, 0.8571, 0.7378]}, {"w": "very", "b": [0.1429, 0.7355, 0.1793, 0.7569]}, {"w": "end", "b": [0.1869, 0.7355, 0.2182, 0.7569]}, {"w": "of", "b": [0.2259, 0.7355, 0.2427, 0.7569]}, {"w": "your", "b": [0.2504, 0.7355, 0.2893, 0.7569]}, {"w": "project,", "b": [0.297, 0.7355, 0.3604, 0.7569]}, {"w": "once", "b": [0.3681, 0.7355, 0.4078, 0.7569]}, {"w": "you", "b": [0.4155, 0.7355, 0.4467, 0.7569]}, {"w": "have", "b": [0.4544, 0.7355, 0.4928, 0.7569]}, {"w": "a", "b": [0.5005, 0.7355, 0.5097, 0.7569]}, {"w": "classifier", "b": [0.5173, 0.7355, 0.5898, 0.7569]}, {"w": "that", "b": [0.5975, 0.7355, 0.6301, 0.7569]}, {"w": "you", "b": [0.6378, 0.7355, 0.669, 0.7569]}, {"w": "are", "b": [0.6767, 0.7355, 0.7024, 0.7569]}, {"w": "ready", "b": [0.7101, 0.7355, 0.7564, 0.7569]}, {"w": "to", "b": [0.7641, 0.7355, 0.7811, 0.7569]}, {"w": "launch).", "b": [0.7888, 0.7355, 0.8571, 0.7569]}, {"w": "Instead,", "b": [0.1429, 0.7554, 0.2091, 0.7768]}, {"w": "you", "b": [0.2138, 0.7554, 0.2451, 0.7768]}, {"w": "can", "b": [0.2498, 0.7554, 0.2792, 0.7768]}, {"w": "use", "b": [0.2839, 0.7554, 0.3115, 0.7768]}, {"w": "the", "b": [0.3162, 0.7554, 0.3425, 0.7768]}, {"w": "cross_val_predict()", "b": [0.3472, 0.7586, 0.5353, 0.7737]}, {"w": "function:", "b": [0.54, 0.7554, 0.6161, 0.7768]}]}, {"id": "b_11", "type": "equation", "text": "from sklearn.model_selection import cross_val_predict", "words": [{"w": "from", "b": [0.1766, 0.7874, 0.2103, 0.8002]}, {"w": "sklearn.model_selection", "b": [0.2188, 0.7874, 0.4127, 0.8002]}, {"w": "import", "b": [0.4211, 0.7874, 0.4717, 0.8002]}, {"w": "cross_val_predict", "b": [0.4802, 0.7874, 0.6235, 0.8002]}]}, {"id": "b_12", "type": "equation", "text": "y_train_pred = cross_val_predict(sgd_clf, X_train, y_train_5, cv=3)", "words": [{"w": "y_train_pred", "b": [0.1766, 0.8182, 0.2778, 0.8311]}, {"w": "=", "b": [0.2862, 0.8182, 0.2946, 0.8311]}, {"w": "cross_val_predict(sgd_clf,", "b": [0.3031, 0.8182, 0.5223, 0.8311]}, {"w": "X_train,", "b": [0.5308, 0.8182, 0.5982, 0.8311]}, {"w": "y_train_5,", "b": [0.6066, 0.8182, 0.691, 0.8311]}, {"w": "cv=3)", "b": [0.6994, 0.8182, 0.7416, 0.8311]}]}, {"id": "b_13", "type": "paragraph", "text": "Just like the cross_val_score() function, cross_val_predict() performs K-fold cross-validation, but instead of returning the evaluation scores, it returns the predic‐", "words": [{"w": "Just", "b": [0.1429, 0.8398, 0.1741, 0.8612]}, {"w": "like", "b": [0.1831, 0.8398, 0.2132, 0.8612]}, {"w": "the", "b": [0.2222, 0.8398, 0.2485, 0.8612]}, {"w": "cross_val_score()", "b": [0.2575, 0.8429, 0.4257, 0.858]}, {"w": "function,", "b": [0.4347, 0.8398, 0.5109, 0.8612]}, {"w": "cross_val_predict()", "b": [0.5199, 0.8429, 0.7079, 0.858]}, {"w": "performs", "b": [0.7169, 0.8398, 0.7936, 0.8612]}, {"w": "K-fold", "b": [0.8026, 0.8398, 0.8571, 0.8612]}, {"w": "cross-validation,", "b": [0.1429, 0.8588, 0.2808, 0.8802]}, {"w": "but", "b": [0.2866, 0.8588, 0.3146, 0.8802]}, {"w": "instead", "b": [0.3203, 0.8588, 0.3803, 0.8802]}, {"w": "of", "b": [0.3861, 0.8588, 0.4029, 0.8802]}, {"w": "returning", "b": [0.4086, 0.8588, 0.4885, 0.8802]}, {"w": "the", "b": [0.4942, 0.8588, 0.5205, 0.8802]}, {"w": "evaluation", "b": [0.5263, 0.8588, 0.613, 0.8802]}, {"w": "scores,", "b": [0.6187, 0.8588, 0.6748, 0.8802]}, {"w": "it", "b": [0.6805, 0.8588, 0.6925, 0.8802]}, {"w": "returns", "b": [0.6982, 0.8588, 0.759, 0.8802]}, {"w": "the", "b": [0.7647, 0.8588, 0.7911, 0.8802]}, {"w": "predic‐", "b": [0.7968, 0.8588, 0.8571, 0.8802]}]}, {"id": "b_14", "type": "paragraph", "text": "92 | Chapter 3: Classification", "words": [{"w": "92", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "3:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "Classification", "b": [0.26, 0.9225, 0.337, 0.9388]}]}]}, {"page": 119, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "tions made on each test fold. This means that you get a clean prediction for each instance in the training set (“clean” meaning that the prediction is made by a model that never saw the data during training).", "words": [{"w": "tions", "b": [0.1429, 0.0791, 0.1845, 0.1005]}, {"w": "made", "b": [0.1923, 0.0791, 0.2384, 0.1005]}, {"w": "on", "b": [0.2462, 0.0791, 0.2682, 0.1005]}, {"w": "each", "b": [0.2761, 0.0791, 0.314, 0.1005]}, {"w": "test", "b": [0.3218, 0.0791, 0.3511, 0.1005]}, {"w": "fold.", "b": [0.3589, 0.0791, 0.3967, 0.1005]}, {"w": "This", "b": [0.4045, 0.0791, 0.4418, 0.1005]}, {"w": "means", "b": [0.4496, 0.0791, 0.5037, 0.1005]}, {"w": "that", "b": [0.5115, 0.0791, 0.5441, 0.1005]}, {"w": "you", "b": [0.552, 0.0791, 0.5832, 0.1005]}, {"w": "get", "b": [0.591, 0.0791, 0.616, 0.1005]}, {"w": "a", "b": [0.6238, 0.0791, 0.633, 0.1005]}, {"w": "clean", "b": [0.6408, 0.0791, 0.6843, 0.1005]}, {"w": "prediction", "b": [0.6922, 0.0791, 0.779, 0.1005]}, {"w": "for", "b": [0.7868, 0.0791, 0.8114, 0.1005]}, {"w": "each", "b": [0.8192, 0.0791, 0.8571, 0.1005]}, {"w": "instance", "b": [0.1429, 0.0981, 0.212, 0.1195]}, {"w": "in", "b": [0.2183, 0.0981, 0.2353, 0.1195]}, {"w": "the", "b": [0.2416, 0.0981, 0.2679, 0.1195]}, {"w": "training", "b": [0.2742, 0.0981, 0.3411, 0.1195]}, {"w": "set", "b": [0.3474, 0.0981, 0.3702, 0.1195]}, {"w": "(“clean”", "b": [0.3765, 0.0981, 0.4404, 0.1195]}, {"w": "meaning", "b": [0.4466, 0.0981, 0.5198, 0.1195]}, {"w": "that", "b": [0.5261, 0.0981, 0.5587, 0.1195]}, {"w": "the", "b": [0.5649, 0.0981, 0.5913, 0.1195]}, {"w": "prediction", "b": [0.5975, 0.0981, 0.6844, 0.1195]}, {"w": "is", "b": [0.6907, 0.0981, 0.7039, 0.1195]}, {"w": "made", "b": [0.7102, 0.0981, 0.7562, 0.1195]}, {"w": "by", "b": [0.7625, 0.0981, 0.7826, 0.1195]}, {"w": "a", "b": [0.7889, 0.0981, 0.7981, 0.1195]}, {"w": "model", "b": [0.8043, 0.0981, 0.8571, 0.1195]}, {"w": "that", "b": [0.1429, 0.1172, 0.1754, 0.1386]}, {"w": "never", "b": [0.1802, 0.1172, 0.2267, 0.1386]}, {"w": "saw", "b": [0.2314, 0.1172, 0.2621, 0.1386]}, {"w": "the", "b": [0.2668, 0.1172, 0.2931, 0.1386]}, {"w": "data", "b": [0.2979, 0.1172, 0.3331, 0.1386]}, {"w": "during", "b": [0.3378, 0.1172, 0.3944, 0.1386]}, {"w": "training).", "b": [0.3991, 0.1172, 0.478, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "Now you are ready to get the confusion matrix using the confusion_matrix() func‐ tion. Just pass it the target classes (y_train_5) and the predicted classes (y_train_pred):", "words": [{"w": "Now", "b": [0.1429, 0.1462, 0.1827, 0.1676]}, {"w": "you", "b": [0.1885, 0.1462, 0.2198, 0.1676]}, {"w": "are", "b": [0.2256, 0.1462, 0.2513, 0.1676]}, {"w": "ready", "b": [0.2571, 0.1462, 0.3034, 0.1676]}, {"w": "to", "b": [0.3092, 0.1462, 0.3261, 0.1676]}, {"w": "get", "b": [0.3319, 0.1462, 0.3569, 0.1676]}, {"w": "the", "b": [0.3627, 0.1462, 0.389, 0.1676]}, {"w": "confusion", "b": [0.3948, 0.1462, 0.4781, 0.1676]}, {"w": "matrix", "b": [0.4839, 0.1462, 0.5392, 0.1676]}, {"w": "using", "b": [0.545, 0.1462, 0.5905, 0.1676]}, {"w": "the", "b": [0.5963, 0.1462, 0.6226, 0.1676]}, {"w": "confusion_matrix()", "b": [0.6284, 0.1494, 0.8065, 0.1644]}, {"w": "func‐", "b": [0.8123, 0.1462, 0.8572, 0.1676]}, {"w": "tion.", "b": [0.1429, 0.1661, 0.1816, 0.1875]}, {"w": "Just", "b": [0.1972, 0.1661, 0.2285, 0.1875]}, {"w": "pass", "b": [0.2441, 0.1661, 0.2794, 0.1875]}, {"w": "it", "b": [0.2951, 0.1661, 0.307, 0.1875]}, {"w": "the", "b": [0.3227, 0.1661, 0.349, 0.1875]}, {"w": "target", "b": [0.3646, 0.1661, 0.4128, 0.1875]}, {"w": "classes", "b": [0.4285, 0.1661, 0.4835, 0.1875]}, {"w": "(y_train_5)", "b": [0.4991, 0.1661, 0.6026, 0.1875]}, {"w": "and", "b": [0.6182, 0.1661, 0.6498, 0.1875]}, {"w": "the", "b": [0.6654, 0.1661, 0.6917, 0.1875]}, {"w": "predicted", "b": [0.7074, 0.1661, 0.7865, 0.1875]}, {"w": "classes", "b": [0.8021, 0.1661, 0.8571, 0.1875]}, {"w": "(y_train_pred):", "b": [0.1429, 0.1861, 0.2808, 0.2075]}]}, {"id": "b_2", "type": "paragraph", "text": ">>> from sklearn.metrics import confusion_matrix >>> confusion_matrix(y_train_5, y_train_pred) array([[53057, 1522], [ 1325, 4096]])", "words": [{"w": ">>>", "b": [0.1766, 0.218, 0.2019, 0.2309]}, {"w": "from", "b": [0.2103, 0.218, 0.2441, 0.2309]}, {"w": "sklearn.metrics", "b": [0.2525, 0.218, 0.379, 0.2309]}, {"w": "import", "b": [0.3874, 0.218, 0.438, 0.2309]}, {"w": "confusion_matrix", "b": [0.4464, 0.218, 0.5814, 0.2309]}, {"w": ">>>", "b": [0.1766, 0.2335, 0.2019, 0.2463]}, {"w": "confusion_matrix(y_train_5,", "b": [0.2103, 0.2335, 0.438, 0.2463]}, {"w": "y_train_pred)", "b": [0.4464, 0.2335, 0.5561, 0.2463]}, {"w": "array([[53057,", "b": [0.1766, 0.2489, 0.2947, 0.2617]}, {"w": "1522],", "b": [0.3115, 0.2489, 0.3621, 0.2617]}, {"w": "[", "b": [0.2356, 0.2643, 0.2441, 0.2771]}, {"w": "1325,", "b": [0.2525, 0.2643, 0.2947, 0.2771]}, {"w": "4096]])", "b": [0.3115, 0.2643, 0.3705, 0.2771]}]}, {"id": "b_3", "type": "paragraph", "text": "Each row in a confusion matrix represents an actual class, while each column repre‐ sents a predicted class. The first row of this matrix considers non-5 images (the nega‐ tive class): 53,057 of them were correctly classified as non-5s (they are called true negatives), while the remaining 1,522 were wrongly classified as 5s (false positives). The second row considers the images of 5s (the positive class): 1,325 were wrongly classified as non-5s (false negatives), while the remaining 4,096 were correctly classi‐ fied as 5s (true positives). A perfect classifier would have only true positives and true negatives, so its confusion matrix would have nonzero values only on its main diago‐ nal (top left to bottom right):", "words": [{"w": "Each", "b": [0.1429, 0.2849, 0.1838, 0.3063]}, {"w": "row", "b": [0.1898, 0.2849, 0.2225, 0.3063]}, {"w": "in", "b": [0.2285, 0.2849, 0.2455, 0.3063]}, {"w": "a", "b": [0.2516, 0.2849, 0.2607, 0.3063]}, {"w": "confusion", "b": [0.2668, 0.2849, 0.3501, 0.3063]}, {"w": "matrix", "b": [0.3562, 0.2849, 0.4115, 0.3063]}, {"w": "represents", "b": [0.4176, 0.2849, 0.5032, 0.3063]}, {"w": "an", "b": [0.5092, 0.2849, 0.5298, 0.3063]}, {"w": "actual", "b": [0.5359, 0.2847, 0.5864, 0.3063]}, {"w": "class,", "b": [0.5925, 0.2847, 0.6341, 0.3063]}, {"w": "while", "b": [0.6402, 0.2849, 0.6853, 0.3063]}, {"w": "each", "b": [0.6913, 0.2849, 0.7293, 0.3063]}, {"w": "column", "b": [0.7353, 0.2849, 0.7996, 0.3063]}, {"w": "repre‐", "b": [0.8056, 0.2849, 0.8571, 0.3063]}, {"w": "sents", "b": [0.1429, 0.304, 0.1844, 0.3254]}, {"w": "a", "b": [0.19, 0.304, 0.1992, 0.3254]}, {"w": "predicted", "b": [0.2048, 0.3038, 0.2791, 0.3254]}, {"w": "class.", "b": [0.2848, 0.3038, 0.3264, 0.3254]}, {"w": "The", "b": [0.3321, 0.304, 0.3649, 0.3254]}, {"w": "first", "b": [0.3706, 0.304, 0.404, 0.3254]}, {"w": "row", "b": [0.4097, 0.304, 0.4423, 0.3254]}, {"w": "of", "b": [0.448, 0.304, 0.4648, 0.3254]}, {"w": "this", "b": [0.4704, 0.304, 0.5012, 0.3254]}, {"w": "matrix", "b": [0.5068, 0.304, 0.5621, 0.3254]}, {"w": "considers", "b": [0.5678, 0.304, 0.6471, 0.3254]}, {"w": "non-5", "b": [0.6527, 0.304, 0.7036, 0.3254]}, {"w": "images", "b": [0.7092, 0.304, 0.7673, 0.3254]}, {"w": "(the", "b": [0.7729, 0.304, 0.8065, 0.3254]}, {"w": "nega‐", "b": [0.8121, 0.3038, 0.8571, 0.3254]}, {"w": "tive", "b": [0.1429, 0.3228, 0.172, 0.3444]}, {"w": "class):", "b": [0.1802, 0.3228, 0.229, 0.3444]}, {"w": "53,057", "b": [0.2372, 0.323, 0.292, 0.3444]}, {"w": "of", "b": [0.3002, 0.323, 0.317, 0.3444]}, {"w": "them", "b": [0.3251, 0.323, 0.3685, 0.3444]}, {"w": "were", "b": [0.3767, 0.323, 0.4164, 0.3444]}, {"w": "correctly", "b": [0.4246, 0.323, 0.4983, 0.3444]}, {"w": "classified", "b": [0.5065, 0.323, 0.5822, 0.3444]}, {"w": "as", "b": [0.5904, 0.323, 0.6072, 0.3444]}, {"w": "non-5s", "b": [0.6154, 0.323, 0.6739, 0.3444]}, {"w": "(they", "b": [0.682, 0.323, 0.7252, 0.3444]}, {"w": "are", "b": [0.7333, 0.323, 0.7591, 0.3444]}, {"w": "called", "b": [0.7672, 0.323, 0.8156, 0.3444]}, {"w": "true", "b": [0.8238, 0.3228, 0.8572, 0.3444]}, {"w": "negatives),", "b": [0.1429, 0.3419, 0.2284, 0.3635]}, {"w": "while", "b": [0.2361, 0.3421, 0.2812, 0.3635]}, {"w": "the", "b": [0.2888, 0.3421, 0.3152, 0.3635]}, {"w": "remaining", "b": [0.3229, 0.3421, 0.4094, 0.3635]}, {"w": "1,522", "b": [0.417, 0.3421, 0.4618, 0.3635]}, {"w": "were", "b": [0.4694, 0.3421, 0.5091, 0.3635]}, {"w": "wrongly", "b": [0.5168, 0.3421, 0.5854, 0.3635]}, {"w": "classified", "b": [0.5931, 0.3421, 0.6688, 0.3635]}, {"w": "as", "b": [0.6765, 0.3421, 0.6933, 0.3635]}, {"w": "5s", "b": [0.7009, 0.3421, 0.7186, 0.3635]}, {"w": "(false", "b": [0.7262, 0.3419, 0.7696, 0.3635]}, {"w": "positives).", "b": [0.7773, 0.3419, 0.8571, 0.3635]}, {"w": "The", "b": [0.1429, 0.3611, 0.1757, 0.3825]}, {"w": "second", "b": [0.1831, 0.3611, 0.2414, 0.3825]}, {"w": "row", "b": [0.2488, 0.3611, 0.2814, 0.3825]}, {"w": "considers", "b": [0.2888, 0.3611, 0.3681, 0.3825]}, {"w": "the", "b": [0.3754, 0.3611, 0.4018, 0.3825]}, {"w": "images", "b": [0.4091, 0.3611, 0.4672, 0.3825]}, {"w": "of", "b": [0.4746, 0.3611, 0.4914, 0.3825]}, {"w": "5s", "b": [0.4987, 0.3611, 0.5164, 0.3825]}, {"w": "(the", "b": [0.5237, 0.3611, 0.5573, 0.3825]}, {"w": "positive", "b": [0.5647, 0.3609, 0.6257, 0.3825]}, {"w": "class):", "b": [0.6331, 0.3609, 0.682, 0.3825]}, {"w": "1,325", "b": [0.6893, 0.3611, 0.7341, 0.3825]}, {"w": "were", "b": [0.7415, 0.3611, 0.7812, 0.3825]}, {"w": "wrongly", "b": [0.7885, 0.3611, 0.8571, 0.3825]}, {"w": "classified", "b": [0.1428, 0.3802, 0.2186, 0.4016]}, {"w": "as", "b": [0.2246, 0.3802, 0.2414, 0.4016]}, {"w": "non-5s", "b": [0.2475, 0.3802, 0.306, 0.4016]}, {"w": "(false", "b": [0.312, 0.38, 0.3553, 0.4016]}, {"w": "negatives),", "b": [0.3615, 0.38, 0.447, 0.4016]}, {"w": "while", "b": [0.4531, 0.3802, 0.4982, 0.4016]}, {"w": "the", "b": [0.5042, 0.3802, 0.5306, 0.4016]}, {"w": "remaining", "b": [0.5366, 0.3802, 0.6231, 0.4016]}, {"w": "4,096", "b": [0.6292, 0.3802, 0.674, 0.4016]}, {"w": "were", "b": [0.68, 0.3802, 0.7197, 0.4016]}, {"w": "correctly", "b": [0.7258, 0.3802, 0.7995, 0.4016]}, {"w": "classi‐", "b": [0.8056, 0.3802, 0.8571, 0.4016]}, {"w": "fied", "b": [0.1429, 0.3992, 0.1745, 0.4206]}, {"w": "as", "b": [0.1804, 0.3992, 0.1972, 0.4206]}, {"w": "5s", "b": [0.2032, 0.3992, 0.2208, 0.4206]}, {"w": "(true", "b": [0.2268, 0.399, 0.2673, 0.4206]}, {"w": "positives).", "b": [0.2733, 0.399, 0.3532, 0.4206]}, {"w": "A", "b": [0.3592, 0.3992, 0.3736, 0.4206]}, {"w": "perfect", "b": [0.3795, 0.3992, 0.4372, 0.4206]}, {"w": "classifier", "b": [0.4432, 0.3992, 0.5156, 0.4206]}, {"w": "would", "b": [0.5216, 0.3992, 0.5738, 0.4206]}, {"w": "have", "b": [0.5797, 0.3992, 0.6181, 0.4206]}, {"w": "only", "b": [0.6241, 0.3992, 0.6609, 0.4206]}, {"w": "true", "b": [0.6669, 0.3992, 0.7009, 0.4206]}, {"w": "positives", "b": [0.7068, 0.3992, 0.7797, 0.4206]}, {"w": "and", "b": [0.7857, 0.3992, 0.8172, 0.4206]}, {"w": "true", "b": [0.8231, 0.3992, 0.8571, 0.4206]}, {"w": "negatives,", "b": [0.1429, 0.4183, 0.2244, 0.4397]}, {"w": "so", "b": [0.2298, 0.4183, 0.2481, 0.4397]}, {"w": "its", "b": [0.2534, 0.4183, 0.273, 0.4397]}, {"w": "confusion", "b": [0.2783, 0.4183, 0.3616, 0.4397]}, {"w": "matrix", "b": [0.367, 0.4183, 0.4223, 0.4397]}, {"w": "would", "b": [0.4276, 0.4183, 0.4799, 0.4397]}, {"w": "have", "b": [0.4852, 0.4183, 0.5236, 0.4397]}, {"w": "nonzero", "b": [0.5289, 0.4183, 0.5983, 0.4397]}, {"w": "values", "b": [0.6036, 0.4183, 0.6553, 0.4397]}, {"w": "only", "b": [0.6606, 0.4183, 0.6975, 0.4397]}, {"w": "on", "b": [0.7028, 0.4183, 0.7248, 0.4397]}, {"w": "its", "b": [0.7302, 0.4183, 0.7498, 0.4397]}, {"w": "main", "b": [0.7551, 0.4183, 0.7983, 0.4397]}, {"w": "diago‐", "b": [0.8036, 0.4183, 0.8571, 0.4397]}, {"w": "nal", "b": [0.1429, 0.4373, 0.1687, 0.4587]}, {"w": "(top", "b": [0.1734, 0.4373, 0.2085, 0.4587]}, {"w": "left", "b": [0.2132, 0.4373, 0.2399, 0.4587]}, {"w": "to", "b": [0.2446, 0.4373, 0.2616, 0.4587]}, {"w": "bottom", "b": [0.2663, 0.4373, 0.3279, 0.4587]}, {"w": "right):", "b": [0.3326, 0.4373, 0.3847, 0.4587]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> y_train_perfect_predictions = y_train_5 # pretend we reached perfection >>> confusion_matrix(y_train_5, y_train_perfect_predictions) array([[54579, 0], [ 0, 5421]])", "words": [{"w": ">>>", "b": [0.1766, 0.4693, 0.2019, 0.4821]}, {"w": "y_train_perfect_predictions", "b": [0.2103, 0.4693, 0.438, 0.4821]}, {"w": "=", "b": [0.4464, 0.4693, 0.4549, 0.4821]}, {"w": "y_train_5", "b": [0.4633, 0.4693, 0.5392, 0.4821]}, {"w": "#", "b": [0.556, 0.4693, 0.5645, 0.4821]}, {"w": "pretend", "b": [0.5729, 0.4693, 0.6319, 0.4821]}, {"w": "we", "b": [0.6404, 0.4693, 0.6572, 0.4821]}, {"w": "reached", "b": [0.6657, 0.4693, 0.7247, 0.4821]}, {"w": "perfection", "b": [0.7331, 0.4693, 0.8175, 0.4821]}, {"w": ">>>", "b": [0.1766, 0.4847, 0.2019, 0.4976]}, {"w": "confusion_matrix(y_train_5,", "b": [0.2103, 0.4847, 0.438, 0.4976]}, {"w": "y_train_perfect_predictions)", "b": [0.4464, 0.4847, 0.6825, 0.4976]}, {"w": "array([[54579,", "b": [0.1766, 0.5001, 0.2946, 0.513]}, {"w": "0],", "b": [0.3368, 0.5001, 0.3621, 0.513]}, {"w": "[", "b": [0.2356, 0.5155, 0.244, 0.5284]}, {"w": "0,", "b": [0.2778, 0.5155, 0.2946, 0.5284]}, {"w": "5421]])", "b": [0.3115, 0.5155, 0.3705, 0.5284]}]}, {"id": "b_5", "type": "paragraph", "text": "The confusion matrix gives you a lot of information, but sometimes you may prefer a more concise metric. An interesting one to look at is the accuracy of the positive pre‐ dictions; this is called the precision of the classifier (Equation 3-1).", "words": [{"w": "The", "b": [0.1429, 0.5362, 0.1757, 0.5576]}, {"w": "confusion", "b": [0.1809, 0.5362, 0.2642, 0.5576]}, {"w": "matrix", "b": [0.2693, 0.5362, 0.3246, 0.5576]}, {"w": "gives", "b": [0.3298, 0.5362, 0.3713, 0.5576]}, {"w": "you", "b": [0.3764, 0.5362, 0.4077, 0.5576]}, {"w": "a", "b": [0.4128, 0.5362, 0.422, 0.5576]}, {"w": "lot", "b": [0.4271, 0.5362, 0.4494, 0.5576]}, {"w": "of", "b": [0.4545, 0.5362, 0.4713, 0.5576]}, {"w": "information,", "b": [0.4765, 0.5362, 0.5825, 0.5576]}, {"w": "but", "b": [0.5876, 0.5362, 0.6156, 0.5576]}, {"w": "sometimes", "b": [0.6208, 0.5362, 0.7105, 0.5576]}, {"w": "you", "b": [0.7156, 0.5362, 0.7469, 0.5576]}, {"w": "may", "b": [0.752, 0.5362, 0.7874, 0.5576]}, {"w": "prefer", "b": [0.7926, 0.5362, 0.8428, 0.5576]}, {"w": "a", "b": [0.848, 0.5362, 0.8571, 0.5576]}, {"w": "more", "b": [0.1429, 0.5552, 0.1871, 0.5766]}, {"w": "concise", "b": [0.1924, 0.5552, 0.2541, 0.5766]}, {"w": "metric.", "b": [0.2593, 0.5552, 0.3185, 0.5766]}, {"w": "An", "b": [0.3237, 0.5552, 0.3495, 0.5766]}, {"w": "interesting", "b": [0.3547, 0.5552, 0.4438, 0.5766]}, {"w": "one", "b": [0.4491, 0.5552, 0.48, 0.5766]}, {"w": "to", "b": [0.4852, 0.5552, 0.5022, 0.5766]}, {"w": "look", "b": [0.5074, 0.5552, 0.5443, 0.5766]}, {"w": "at", "b": [0.5495, 0.5552, 0.5646, 0.5766]}, {"w": "is", "b": [0.5698, 0.5552, 0.5831, 0.5766]}, {"w": "the", "b": [0.5883, 0.5552, 0.6146, 0.5766]}, {"w": "accuracy", "b": [0.6199, 0.5552, 0.693, 0.5766]}, {"w": "of", "b": [0.6982, 0.5552, 0.715, 0.5766]}, {"w": "the", "b": [0.7202, 0.5552, 0.7465, 0.5766]}, {"w": "positive", "b": [0.7518, 0.5552, 0.817, 0.5766]}, {"w": "pre‐", "b": [0.8222, 0.5552, 0.8571, 0.5766]}, {"w": "dictions;", "b": [0.1429, 0.5743, 0.2146, 0.5957]}, {"w": "this", "b": [0.2193, 0.5743, 0.25, 0.5957]}, {"w": "is", "b": [0.2548, 0.5743, 0.268, 0.5957]}, {"w": "called", "b": [0.2727, 0.5743, 0.3211, 0.5957]}, {"w": "the", "b": [0.3258, 0.5743, 0.3521, 0.5957]}, {"w": "precision", "b": [0.3569, 0.5741, 0.429, 0.5957]}, {"w": "of", "b": [0.4338, 0.5743, 0.4506, 0.5957]}, {"w": "the", "b": [0.4553, 0.5743, 0.4816, 0.5957]}, {"w": "classifier", "b": [0.4864, 0.5743, 0.5588, 0.5957]}, {"w": "(Equation", "b": [0.5635, 0.5743, 0.647, 0.5957]}, {"w": "3-1).", "b": [0.6517, 0.5743, 0.6911, 0.5957]}]}, {"id": "b_6", "type": "equation", "text": "Equation 3-1. Precision", "words": [{"w": "Equation", "b": [0.1726, 0.6138, 0.2473, 0.6354]}, {"w": "3-1.", "b": [0.2521, 0.6138, 0.2838, 0.6354]}, {"w": "Precision", "b": [0.2886, 0.6138, 0.3623, 0.6354]}]}, {"id": "b_7", "type": "equation", "text": "precision = TP TP + FP", "words": [{"w": "precision", "b": [0.1726, 0.6506, 0.2461, 0.671]}, {"w": "=", "b": [0.2516, 0.6506, 0.2631, 0.671]}, {"w": "TP", "b": [0.2921, 0.6416, 0.3159, 0.6622]}, {"w": "TP", "b": [0.2708, 0.6592, 0.2947, 0.6798]}, {"w": "+", "b": [0.2992, 0.6594, 0.3107, 0.6798]}, {"w": "FP", "b": [0.3151, 0.6592, 0.3372, 0.6798]}]}, {"id": "b_8", "type": "paragraph", "text": "TP is the number of true positives, and FP is the number of false positives.", "words": [{"w": "TP", "b": [0.1429, 0.6986, 0.1674, 0.72]}, {"w": "is", "b": [0.1722, 0.6986, 0.1854, 0.72]}, {"w": "the", "b": [0.1901, 0.6986, 0.2165, 0.72]}, {"w": "number", "b": [0.2212, 0.6986, 0.2875, 0.72]}, {"w": "of", "b": [0.2922, 0.6986, 0.309, 0.72]}, {"w": "true", "b": [0.3137, 0.6986, 0.3477, 0.72]}, {"w": "positives,", "b": [0.3525, 0.6986, 0.4301, 0.72]}, {"w": "and", "b": [0.4348, 0.6986, 0.4663, 0.72]}, {"w": "FP", "b": [0.4711, 0.6986, 0.4938, 0.72]}, {"w": "is", "b": [0.4986, 0.6986, 0.5118, 0.72]}, {"w": "the", "b": [0.5165, 0.6986, 0.5428, 0.72]}, {"w": "number", "b": [0.5476, 0.6986, 0.6139, 0.72]}, {"w": "of", "b": [0.6186, 0.6986, 0.6354, 0.72]}, {"w": "false", "b": [0.6401, 0.6986, 0.6772, 0.72]}, {"w": "positives.", "b": [0.6819, 0.6986, 0.7595, 0.72]}]}, {"id": "b_9", "type": "paragraph", "text": "A trivial way to have perfect precision is to make one single positive prediction and ensure it is correct (precision = 1/1 = 100%). This would not be very useful since the classifier would ignore all but one positive instance. So precision is typically used along with another metric named recall, also called sensitivity or true positive rate", "words": [{"w": "A", "b": [0.1429, 0.7267, 0.1573, 0.7481]}, {"w": "trivial", "b": [0.1636, 0.7267, 0.2129, 0.7481]}, {"w": "way", "b": [0.2193, 0.7267, 0.2519, 0.7481]}, {"w": "to", "b": [0.2583, 0.7267, 0.2753, 0.7481]}, {"w": "have", "b": [0.2816, 0.7267, 0.32, 0.7481]}, {"w": "perfect", "b": [0.3264, 0.7267, 0.3841, 0.7481]}, {"w": "precision", "b": [0.3905, 0.7267, 0.4676, 0.7481]}, {"w": "is", "b": [0.474, 0.7267, 0.4872, 0.7481]}, {"w": "to", "b": [0.4936, 0.7267, 0.5106, 0.7481]}, {"w": "make", "b": [0.5169, 0.7267, 0.5623, 0.7481]}, {"w": "one", "b": [0.5687, 0.7267, 0.5996, 0.7481]}, {"w": "single", "b": [0.6059, 0.7267, 0.6544, 0.7481]}, {"w": "positive", "b": [0.6608, 0.7267, 0.726, 0.7481]}, {"w": "prediction", "b": [0.7324, 0.7267, 0.8192, 0.7481]}, {"w": "and", "b": [0.8256, 0.7267, 0.8571, 0.7481]}, {"w": "ensure", "b": [0.1429, 0.7458, 0.1984, 0.7672]}, {"w": "it", "b": [0.204, 0.7458, 0.2159, 0.7672]}, {"w": "is", "b": [0.2215, 0.7458, 0.2347, 0.7672]}, {"w": "correct", "b": [0.2403, 0.7458, 0.2992, 0.7672]}, {"w": "(precision", "b": [0.3048, 0.7458, 0.3891, 0.7672]}, {"w": "=", "b": [0.3947, 0.7458, 0.4068, 0.7672]}, {"w": "1/1", "b": [0.4124, 0.7458, 0.4393, 0.7672]}, {"w": "=", "b": [0.4448, 0.7458, 0.4569, 0.7672]}, {"w": "100%).", "b": [0.4625, 0.7458, 0.5202, 0.7672]}, {"w": "This", "b": [0.5258, 0.7458, 0.563, 0.7672]}, {"w": "would", "b": [0.5686, 0.7458, 0.6208, 0.7672]}, {"w": "not", "b": [0.6264, 0.7458, 0.6547, 0.7672]}, {"w": "be", "b": [0.6603, 0.7458, 0.6798, 0.7672]}, {"w": "very", "b": [0.6853, 0.7458, 0.7217, 0.7672]}, {"w": "useful", "b": [0.7273, 0.7458, 0.7774, 0.7672]}, {"w": "since", "b": [0.7829, 0.7458, 0.8252, 0.7672]}, {"w": "the", "b": [0.8308, 0.7458, 0.8571, 0.7672]}, {"w": "classifier", "b": [0.1429, 0.7648, 0.2153, 0.7862]}, {"w": "would", "b": [0.2235, 0.7648, 0.2757, 0.7862]}, {"w": "ignore", "b": [0.2839, 0.7648, 0.3378, 0.7862]}, {"w": "all", "b": [0.346, 0.7648, 0.3657, 0.7862]}, {"w": "but", "b": [0.3738, 0.7648, 0.4018, 0.7862]}, {"w": "one", "b": [0.41, 0.7648, 0.4409, 0.7862]}, {"w": "positive", "b": [0.449, 0.7648, 0.5143, 0.7862]}, {"w": "instance.", "b": [0.5224, 0.7648, 0.5964, 0.7862]}, {"w": "So", "b": [0.6045, 0.7648, 0.625, 0.7862]}, {"w": "precision", "b": [0.6332, 0.7648, 0.7104, 0.7862]}, {"w": "is", "b": [0.7185, 0.7648, 0.7318, 0.7862]}, {"w": "typically", "b": [0.7399, 0.7648, 0.8104, 0.7862]}, {"w": "used", "b": [0.8186, 0.7648, 0.8571, 0.7862]}, {"w": "along", "b": [0.1429, 0.7839, 0.1891, 0.8053]}, {"w": "with", "b": [0.1973, 0.7839, 0.2346, 0.8053]}, {"w": "another", "b": [0.2429, 0.7839, 0.3081, 0.8053]}, {"w": "metric", "b": [0.3164, 0.7839, 0.3708, 0.8053]}, {"w": "named", "b": [0.3791, 0.7839, 0.4365, 0.8053]}, {"w": "recall,", "b": [0.4448, 0.7836, 0.493, 0.8053]}, {"w": "also", "b": [0.5013, 0.7839, 0.534, 0.8053]}, {"w": "called", "b": [0.5422, 0.7839, 0.5906, 0.8053]}, {"w": "sensitivity", "b": [0.5989, 0.7836, 0.6797, 0.8053]}, {"w": "or", "b": [0.688, 0.7839, 0.7063, 0.8053]}, {"w": "true", "b": [0.7146, 0.7836, 0.748, 0.8053]}, {"w": "positive", "b": [0.7563, 0.7836, 0.8173, 0.8053]}, {"w": "rate", "b": [0.8257, 0.7836, 0.8572, 0.8053]}]}, {"id": "b_10", "type": "paragraph", "text": "Performance Measures | 93", "words": [{"w": "Performance", "b": [0.669, 0.9225, 0.7445, 0.9388]}, {"w": "Measures", "b": [0.7474, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "93", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 120, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "(TPR): this is the ratio of positive instances that are correctly detected by the classifier (Equation 3-2).", "words": [{"w": "(TPR):", "b": [0.1429, 0.0789, 0.1983, 0.1005]}, {"w": "this", "b": [0.2033, 0.0791, 0.234, 0.1005]}, {"w": "is", "b": [0.239, 0.0791, 0.2522, 0.1005]}, {"w": "the", "b": [0.2572, 0.0791, 0.2835, 0.1005]}, {"w": "ratio", "b": [0.2885, 0.0791, 0.3275, 0.1005]}, {"w": "of", "b": [0.3325, 0.0791, 0.3493, 0.1005]}, {"w": "positive", "b": [0.3543, 0.0791, 0.4195, 0.1005]}, {"w": "instances", "b": [0.4244, 0.0791, 0.5013, 0.1005]}, {"w": "that", "b": [0.5063, 0.0791, 0.5388, 0.1005]}, {"w": "are", "b": [0.5438, 0.0791, 0.5695, 0.1005]}, {"w": "correctly", "b": [0.5745, 0.0791, 0.6483, 0.1005]}, {"w": "detected", "b": [0.6532, 0.0791, 0.7233, 0.1005]}, {"w": "by", "b": [0.7283, 0.0791, 0.7484, 0.1005]}, {"w": "the", "b": [0.7534, 0.0791, 0.7797, 0.1005]}, {"w": "classifier", "b": [0.7847, 0.0791, 0.8571, 0.1005]}, {"w": "(Equation", "b": [0.1429, 0.0981, 0.2263, 0.1195]}, {"w": "3-2).", "b": [0.231, 0.0981, 0.2704, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "Equation 3-2. Recall", "words": [{"w": "Equation", "b": [0.1726, 0.1376, 0.2473, 0.1593]}, {"w": "3-2.", "b": [0.2521, 0.1376, 0.2838, 0.1593]}, {"w": "Recall", "b": [0.2886, 0.1376, 0.3372, 0.1593]}]}, {"id": "b_2", "type": "equation", "text": "recall = TP TP + FN", "words": [{"w": "recall", "b": [0.1726, 0.1744, 0.2156, 0.1948]}, {"w": "=", "b": [0.2211, 0.1744, 0.2326, 0.1948]}, {"w": "TP", "b": [0.2635, 0.1654, 0.2873, 0.186]}, {"w": "TP", "b": [0.2403, 0.1831, 0.2641, 0.2036]}, {"w": "+", "b": [0.2687, 0.1833, 0.2802, 0.2036]}, {"w": "FN", "b": [0.2846, 0.1831, 0.3097, 0.2036]}]}, {"id": "b_3", "type": "paragraph", "text": "FN is of course the number of false negatives.", "words": [{"w": "FN", "b": [0.1429, 0.2224, 0.1694, 0.2438]}, {"w": "is", "b": [0.1741, 0.2224, 0.1873, 0.2438]}, {"w": "of", "b": [0.1921, 0.2224, 0.2088, 0.2438]}, {"w": "course", "b": [0.2136, 0.2224, 0.2683, 0.2438]}, {"w": "the", "b": [0.273, 0.2224, 0.2994, 0.2438]}, {"w": "number", "b": [0.3041, 0.2224, 0.3704, 0.2438]}, {"w": "of", "b": [0.3751, 0.2224, 0.3919, 0.2438]}, {"w": "false", "b": [0.3966, 0.2224, 0.4337, 0.2438]}, {"w": "negatives.", "b": [0.4384, 0.2224, 0.52, 0.2438]}]}, {"id": "b_4", "type": "equation", "text": "If you are confused about the confusion matrix, Figure 3-2 may help.", "words": [{"w": "If", "b": [0.1429, 0.2506, 0.1561, 0.272]}, {"w": "you", "b": [0.1609, 0.2506, 0.1921, 0.272]}, {"w": "are", "b": [0.1968, 0.2506, 0.2226, 0.272]}, {"w": "confused", "b": [0.2273, 0.2506, 0.3029, 0.272]}, {"w": "about", "b": [0.3076, 0.2506, 0.3554, 0.272]}, {"w": "the", "b": [0.3601, 0.2506, 0.3864, 0.272]}, {"w": "confusion", "b": [0.3912, 0.2506, 0.4745, 0.272]}, {"w": "matrix,", "b": [0.4792, 0.2506, 0.5393, 0.272]}, {"w": "Figure", "b": [0.544, 0.2506, 0.598, 0.272]}, {"w": "3-2", "b": [0.6027, 0.2506, 0.6301, 0.272]}, {"w": "may", "b": [0.6349, 0.2506, 0.6703, 0.272]}, {"w": "help.", "b": [0.675, 0.2506, 0.7153, 0.272]}]}, {"id": "b_5", "type": "equation", "text": "Figure 3-2. An illustrated confusion matrix", "words": [{"w": "Figure", "b": [0.1429, 0.5489, 0.1943, 0.5706]}, {"w": "3-2.", "b": [0.1991, 0.5489, 0.2308, 0.5706]}, {"w": "An", "b": [0.2356, 0.5489, 0.2605, 0.5706]}, {"w": "illustrated", "b": [0.2653, 0.5489, 0.347, 0.5706]}, {"w": "confusion", "b": [0.3518, 0.5489, 0.4301, 0.5706]}, {"w": "matrix", "b": [0.4349, 0.5489, 0.4905, 0.5706]}]}, {"id": "b_6", "type": "paragraph", "text": "Precision and Recall", "words": [{"w": "Precision", "b": [0.1429, 0.5836, 0.2359, 0.6122]}, {"w": "and", "b": [0.2408, 0.5836, 0.2801, 0.6122]}, {"w": "Recall", "b": [0.2851, 0.5836, 0.3466, 0.6122]}]}, {"id": "b_7", "type": "paragraph", "text": "Scikit-Learn provides several functions to compute classifier metrics, including preci‐ sion and recall:", "words": [{"w": "Scikit-Learn", "b": [0.1429, 0.6181, 0.2452, 0.6395]}, {"w": "provides", "b": [0.2502, 0.6181, 0.3222, 0.6395]}, {"w": "several", "b": [0.3272, 0.6181, 0.3843, 0.6395]}, {"w": "functions", "b": [0.3893, 0.6181, 0.4684, 0.6395]}, {"w": "to", "b": [0.4734, 0.6181, 0.4904, 0.6395]}, {"w": "compute", "b": [0.4954, 0.6181, 0.5687, 0.6395]}, {"w": "classifier", "b": [0.5737, 0.6181, 0.6461, 0.6395]}, {"w": "metrics,", "b": [0.6512, 0.6181, 0.718, 0.6395]}, {"w": "including", "b": [0.723, 0.6181, 0.8028, 0.6395]}, {"w": "preci‐", "b": [0.8078, 0.6181, 0.8572, 0.6395]}, {"w": "sion", "b": [0.1429, 0.6371, 0.1781, 0.6585]}, {"w": "and", "b": [0.1828, 0.6371, 0.2144, 0.6585]}, {"w": "recall:", "b": [0.2191, 0.6371, 0.2689, 0.6585]}]}, {"id": "b_8", "type": "paragraph", "text": ">>> from sklearn.metrics import precision_score, recall_score >>> precision_score(y_train_5, y_train_pred) # == 4096 / (4096 + 1522) 0.7290850836596654 >>> recall_score(y_train_5, y_train_pred) # == 4096 / (4096 + 1325) 0.7555801512636044", "words": [{"w": ">>>", "b": [0.1766, 0.6691, 0.2019, 0.6819]}, {"w": "from", "b": [0.2103, 0.6691, 0.244, 0.6819]}, {"w": "sklearn.metrics", "b": [0.2525, 0.6691, 0.379, 0.6819]}, {"w": "import", "b": [0.3874, 0.6691, 0.438, 0.6819]}, {"w": "precision_score,", "b": [0.4464, 0.6691, 0.5813, 0.6819]}, {"w": "recall_score", "b": [0.5898, 0.6691, 0.691, 0.6819]}, {"w": ">>>", "b": [0.1766, 0.6845, 0.2019, 0.6974]}, {"w": "precision_score(y_train_5,", "b": [0.2103, 0.6845, 0.4296, 0.6974]}, {"w": "y_train_pred)", "b": [0.438, 0.6845, 0.5476, 0.6974]}, {"w": "#", "b": [0.5561, 0.6845, 0.5645, 0.6974]}, {"w": "==", "b": [0.5729, 0.6845, 0.5898, 0.6974]}, {"w": "4096", "b": [0.5982, 0.6845, 0.6319, 0.6974]}, {"w": "/", "b": [0.6404, 0.6845, 0.6488, 0.6974]}, {"w": "(4096", "b": [0.6572, 0.6845, 0.6994, 0.6974]}, {"w": "+", "b": [0.7078, 0.6845, 0.7163, 0.6974]}, {"w": "1522)", "b": [0.7247, 0.6845, 0.7669, 0.6974]}, {"w": "0.7290850836596654", "b": [0.1766, 0.6999, 0.3284, 0.7128]}, {"w": ">>>", "b": [0.1766, 0.7153, 0.2019, 0.7282]}, {"w": "recall_score(y_train_5,", "b": [0.2103, 0.7153, 0.4043, 0.7282]}, {"w": "y_train_pred)", "b": [0.4127, 0.7153, 0.5223, 0.7282]}, {"w": "#", "b": [0.5308, 0.7153, 0.5392, 0.7282]}, {"w": "==", "b": [0.5476, 0.7153, 0.5645, 0.7282]}, {"w": "4096", "b": [0.5729, 0.7153, 0.6066, 0.7282]}, {"w": "/", "b": [0.6151, 0.7153, 0.6235, 0.7282]}, {"w": "(4096", "b": [0.6319, 0.7153, 0.6741, 0.7282]}, {"w": "+", "b": [0.6825, 0.7153, 0.691, 0.7282]}, {"w": "1325)", "b": [0.6994, 0.7153, 0.7416, 0.7282]}, {"w": "0.7555801512636044", "b": [0.1766, 0.7308, 0.3284, 0.7436]}]}, {"id": "b_9", "type": "paragraph", "text": "Now your 5-detector does not look as shiny as it did when you looked at its accuracy. When it claims an image represents a 5, it is correct only 72.9% of the time. More‐ over, it only detects 75.6% of the 5s.", "words": [{"w": "Now", "b": [0.1429, 0.7514, 0.1827, 0.7728]}, {"w": "your", "b": [0.1879, 0.7514, 0.2269, 0.7728]}, {"w": "5-detector", "b": [0.2321, 0.7514, 0.3181, 0.7728]}, {"w": "does", "b": [0.3234, 0.7514, 0.3615, 0.7728]}, {"w": "not", "b": [0.3667, 0.7514, 0.3951, 0.7728]}, {"w": "look", "b": [0.4003, 0.7514, 0.4372, 0.7728]}, {"w": "as", "b": [0.4424, 0.7514, 0.4592, 0.7728]}, {"w": "shiny", "b": [0.4644, 0.7514, 0.5092, 0.7728]}, {"w": "as", "b": [0.5144, 0.7514, 0.5312, 0.7728]}, {"w": "it", "b": [0.5365, 0.7514, 0.5484, 0.7728]}, {"w": "did", "b": [0.5536, 0.7514, 0.5812, 0.7728]}, {"w": "when", "b": [0.5864, 0.7514, 0.6321, 0.7728]}, {"w": "you", "b": [0.6373, 0.7514, 0.6685, 0.7728]}, {"w": "looked", "b": [0.6738, 0.7514, 0.7305, 0.7728]}, {"w": "at", "b": [0.7357, 0.7514, 0.7508, 0.7728]}, {"w": "its", "b": [0.756, 0.7514, 0.7756, 0.7728]}, {"w": "accuracy.", "b": [0.7808, 0.7514, 0.8571, 0.7728]}, {"w": "When", "b": [0.1428, 0.7704, 0.1945, 0.7919]}, {"w": "it", "b": [0.2011, 0.7704, 0.2131, 0.7919]}, {"w": "claims", "b": [0.2198, 0.7704, 0.2733, 0.7919]}, {"w": "an", "b": [0.28, 0.7704, 0.3005, 0.7919]}, {"w": "image", "b": [0.3072, 0.7704, 0.3576, 0.7919]}, {"w": "represents", "b": [0.3643, 0.7704, 0.4499, 0.7919]}, {"w": "a", "b": [0.4566, 0.7704, 0.4657, 0.7919]}, {"w": "5,", "b": [0.4724, 0.7704, 0.4871, 0.7919]}, {"w": "it", "b": [0.4938, 0.7704, 0.5058, 0.7919]}, {"w": "is", "b": [0.5124, 0.7704, 0.5257, 0.7919]}, {"w": "correct", "b": [0.5324, 0.7704, 0.5913, 0.7919]}, {"w": "only", "b": [0.598, 0.7704, 0.6348, 0.7919]}, {"w": "72.9%", "b": [0.6415, 0.7704, 0.692, 0.7919]}, {"w": "of", "b": [0.6987, 0.7704, 0.7155, 0.7919]}, {"w": "the", "b": [0.7222, 0.7704, 0.7485, 0.7919]}, {"w": "time.", "b": [0.7552, 0.7704, 0.7978, 0.7919]}, {"w": "More‐", "b": [0.8045, 0.7704, 0.8571, 0.7919]}, {"w": "over,", "b": [0.1429, 0.7895, 0.1832, 0.8109]}, {"w": "it", "b": [0.1879, 0.7895, 0.1998, 0.8109]}, {"w": "only", "b": [0.2045, 0.7895, 0.2414, 0.8109]}, {"w": "detects", "b": [0.2461, 0.7895, 0.304, 0.8109]}, {"w": "75.6%", "b": [0.3087, 0.7895, 0.3592, 0.8109]}, {"w": "of", "b": [0.364, 0.7895, 0.3808, 0.8109]}, {"w": "the", "b": [0.3855, 0.7895, 0.4118, 0.8109]}, {"w": "5s.", "b": [0.4165, 0.7895, 0.4389, 0.8109]}]}, {"id": "b_10", "type": "paragraph", "text": "It is often convenient to combine precision and recall into a single metric called the F1 score, in particular if you need a simple way to compare two classifiers. The F1 score is the harmonic mean of precision and recall (Equation 3-3). Whereas the regular mean", "words": [{"w": "It", "b": [0.1429, 0.8176, 0.1555, 0.839]}, {"w": "is", "b": [0.1603, 0.8176, 0.1735, 0.839]}, {"w": "often", "b": [0.1783, 0.8176, 0.2217, 0.839]}, {"w": "convenient", "b": [0.2265, 0.8176, 0.3186, 0.839]}, {"w": "to", "b": [0.3234, 0.8176, 0.3404, 0.839]}, {"w": "combine", "b": [0.3452, 0.8176, 0.4181, 0.839]}, {"w": "precision", "b": [0.4229, 0.8176, 0.5, 0.839]}, {"w": "and", "b": [0.5048, 0.8176, 0.5364, 0.839]}, {"w": "recall", "b": [0.5412, 0.8176, 0.5863, 0.839]}, {"w": "into", "b": [0.5911, 0.8176, 0.6246, 0.839]}, {"w": "a", "b": [0.6295, 0.8176, 0.6386, 0.839]}, {"w": "single", "b": [0.6434, 0.8176, 0.6919, 0.839]}, {"w": "metric", "b": [0.6967, 0.8176, 0.7511, 0.839]}, {"w": "called", "b": [0.7559, 0.8176, 0.8043, 0.839]}, {"w": "the", "b": [0.8091, 0.8176, 0.8354, 0.839]}, {"w": "F1", "b": [0.8402, 0.8174, 0.8571, 0.8399]}, {"w": "score,", "b": [0.1429, 0.8364, 0.1876, 0.8581]}, {"w": "in", "b": [0.1924, 0.8367, 0.2094, 0.8581]}, {"w": "particular", "b": [0.2141, 0.8367, 0.2958, 0.8581]}, {"w": "if", "b": [0.3006, 0.8367, 0.3123, 0.8581]}, {"w": "you", "b": [0.317, 0.8367, 0.3483, 0.8581]}, {"w": "need", "b": [0.353, 0.8367, 0.3931, 0.8581]}, {"w": "a", "b": [0.3979, 0.8367, 0.407, 0.8581]}, {"w": "simple", "b": [0.4117, 0.8367, 0.4667, 0.8581]}, {"w": "way", "b": [0.4714, 0.8367, 0.504, 0.8581]}, {"w": "to", "b": [0.5087, 0.8367, 0.5257, 0.8581]}, {"w": "compare", "b": [0.5304, 0.8367, 0.6032, 0.8581]}, {"w": "two", "b": [0.6079, 0.8367, 0.6392, 0.8581]}, {"w": "classifiers.", "b": [0.6439, 0.8367, 0.7287, 0.8581]}, {"w": "The", "b": [0.7335, 0.8367, 0.7663, 0.8581]}, {"w": "F1", "b": [0.771, 0.8367, 0.788, 0.859]}, {"w": "score", "b": [0.7928, 0.8367, 0.8364, 0.8581]}, {"w": "is", "b": [0.8412, 0.8367, 0.8544, 0.8581]}, {"w": "the", "b": [0.1429, 0.8557, 0.1692, 0.8771]}, {"w": "harmonic", "b": [0.1746, 0.8555, 0.2529, 0.8771]}, {"w": "mean", "b": [0.2577, 0.8555, 0.3031, 0.8771]}, {"w": "of", "b": [0.3092, 0.8557, 0.326, 0.8771]}, {"w": "precision", "b": [0.3314, 0.8557, 0.4085, 0.8771]}, {"w": "and", "b": [0.4139, 0.8557, 0.4455, 0.8771]}, {"w": "recall", "b": [0.4509, 0.8557, 0.4959, 0.8771]}, {"w": "(Equation", "b": [0.5014, 0.8557, 0.5848, 0.8771]}, {"w": "3-3).", "b": [0.5895, 0.8557, 0.6296, 0.8771]}, {"w": "Whereas", "b": [0.635, 0.8557, 0.7086, 0.8771]}, {"w": "the", "b": [0.714, 0.8557, 0.7403, 0.8771]}, {"w": "regular", "b": [0.7457, 0.8557, 0.8053, 0.8771]}, {"w": "mean", "b": [0.8107, 0.8557, 0.8571, 0.8771]}]}, {"id": "b_11", "type": "paragraph", "text": "94 | Chapter 3: Classification", "words": [{"w": "94", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "3:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "Classification", "b": [0.26, 0.9225, 0.337, 0.9388]}]}]}, {"page": 121, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "treats all values equally, the harmonic mean gives much more weight to low values. As a result, the classifier will only get a high F1 score if both recall and precision are high.", "words": [{"w": "treats", "b": [0.1429, 0.0791, 0.1885, 0.1005]}, {"w": "all", "b": [0.1953, 0.0791, 0.215, 0.1005]}, {"w": "values", "b": [0.2217, 0.0791, 0.2733, 0.1005]}, {"w": "equally,", "b": [0.28, 0.0791, 0.3431, 0.1005]}, {"w": "the", "b": [0.3498, 0.0791, 0.3762, 0.1005]}, {"w": "harmonic", "b": [0.3829, 0.0791, 0.4644, 0.1005]}, {"w": "mean", "b": [0.4711, 0.0791, 0.5176, 0.1005]}, {"w": "gives", "b": [0.5243, 0.0791, 0.5658, 0.1005]}, {"w": "much", "b": [0.5725, 0.0791, 0.6202, 0.1005]}, {"w": "more", "b": [0.6269, 0.0791, 0.6712, 0.1005]}, {"w": "weight", "b": [0.6779, 0.0791, 0.7334, 0.1005]}, {"w": "to", "b": [0.7402, 0.0791, 0.7571, 0.1005]}, {"w": "low", "b": [0.7639, 0.0791, 0.794, 0.1005]}, {"w": "values.", "b": [0.8008, 0.0791, 0.8571, 0.1005]}, {"w": "As", "b": [0.1429, 0.0981, 0.1649, 0.1195]}, {"w": "a", "b": [0.171, 0.0981, 0.1801, 0.1195]}, {"w": "result,", "b": [0.1862, 0.0981, 0.2378, 0.1195]}, {"w": "the", "b": [0.2439, 0.0981, 0.2702, 0.1195]}, {"w": "classifier", "b": [0.2763, 0.0981, 0.3487, 0.1195]}, {"w": "will", "b": [0.3548, 0.0981, 0.3852, 0.1195]}, {"w": "only", "b": [0.3913, 0.0981, 0.4281, 0.1195]}, {"w": "get", "b": [0.4342, 0.0981, 0.4591, 0.1195]}, {"w": "a", "b": [0.4652, 0.0981, 0.4743, 0.1195]}, {"w": "high", "b": [0.4804, 0.0981, 0.518, 0.1195]}, {"w": "F1", "b": [0.5241, 0.0981, 0.5411, 0.1204]}, {"w": "score", "b": [0.5471, 0.0981, 0.5908, 0.1195]}, {"w": "if", "b": [0.5969, 0.0981, 0.6086, 0.1195]}, {"w": "both", "b": [0.6147, 0.0981, 0.6534, 0.1195]}, {"w": "recall", "b": [0.6594, 0.0981, 0.7045, 0.1195]}, {"w": "and", "b": [0.7106, 0.0981, 0.7421, 0.1195]}, {"w": "precision", "b": [0.7482, 0.0981, 0.8253, 0.1195]}, {"w": "are", "b": [0.8314, 0.0981, 0.8571, 0.1195]}, {"w": "high.", "b": [0.1429, 0.1172, 0.1852, 0.1386]}]}, {"id": "b_1", "type": "equation", "text": "Equation 3-3. F1", "words": [{"w": "Equation", "b": [0.1726, 0.1567, 0.2473, 0.1783]}, {"w": "3-3.", "b": [0.2521, 0.1567, 0.2838, 0.1783]}, {"w": "F1", "b": [0.2886, 0.1567, 0.3055, 0.1792]}]}, {"id": "b_2", "type": "equation", "text": "F1 = 2 1 precision + 1 recall", "words": [{"w": "F1", "b": [0.1726, 0.1933, 0.1913, 0.2181]}, {"w": "=", "b": [0.1968, 0.1935, 0.2084, 0.2139]}, {"w": "2", "b": [0.2724, 0.1847, 0.282, 0.2051]}, {"w": "1", "b": [0.2439, 0.2031, 0.2515, 0.2194]}, {"w": "precision", "b": [0.2183, 0.2177, 0.277, 0.234]}, {"w": "+", "b": [0.2837, 0.2081, 0.2952, 0.2285]}, {"w": "1", "b": [0.3151, 0.2031, 0.3228, 0.2194]}, {"w": "recall", "b": [0.3018, 0.2177, 0.3361, 0.234]}]}, {"id": "b_3", "type": "equation", "text": "= 2 × precision × recall", "words": [{"w": "=", "b": [0.3461, 0.1935, 0.3576, 0.2139]}, {"w": "2", "b": [0.3631, 0.1935, 0.3726, 0.2139]}, {"w": "×", "b": [0.377, 0.1935, 0.3885, 0.2139]}, {"w": "precision", "b": [0.3995, 0.1847, 0.473, 0.2051]}, {"w": "×", "b": [0.4763, 0.1847, 0.4878, 0.2051]}, {"w": "recall", "b": [0.4911, 0.1847, 0.5341, 0.2051]}]}, {"id": "b_4", "type": "equation", "text": "precision + recall = TP", "words": [{"w": "precision", "b": [0.3995, 0.2023, 0.473, 0.2227]}, {"w": "+", "b": [0.4763, 0.2023, 0.4878, 0.2227]}, {"w": "recall", "b": [0.4911, 0.2023, 0.5341, 0.2227]}, {"w": "=", "b": [0.5462, 0.1935, 0.5577, 0.2139]}, {"w": "TP", "b": [0.6052, 0.1845, 0.6291, 0.2051]}]}, {"id": "b_5", "type": "equation", "text": "TP + FN + FP", "words": [{"w": "TP", "b": [0.5654, 0.2079, 0.5893, 0.2285]}, {"w": "+", "b": [0.5938, 0.2081, 0.6053, 0.2285]}, {"w": "FN", "b": [0.6119, 0.2029, 0.632, 0.2194]}, {"w": "+", "b": [0.6363, 0.2031, 0.6455, 0.2194]}, {"w": "FP", "b": [0.649, 0.2029, 0.6667, 0.2194]}]}, {"id": "b_7", "type": "equation", "text": "To compute the F1 score, simply call the f1_score() function:", "words": [{"w": "To", "b": [0.1429, 0.254, 0.1643, 0.2754]}, {"w": "compute", "b": [0.169, 0.254, 0.2423, 0.2754]}, {"w": "the", "b": [0.2471, 0.254, 0.2734, 0.2754]}, {"w": "F1", "b": [0.2781, 0.254, 0.2951, 0.2763]}, {"w": "score,", "b": [0.2999, 0.254, 0.3483, 0.2754]}, {"w": "simply", "b": [0.353, 0.254, 0.4086, 0.2754]}, {"w": "call", "b": [0.4134, 0.254, 0.4419, 0.2754]}, {"w": "the", "b": [0.4466, 0.254, 0.4729, 0.2754]}, {"w": "f1_score()", "b": [0.4777, 0.2572, 0.5766, 0.2722]}, {"w": "function:", "b": [0.5814, 0.254, 0.6575, 0.2754]}]}, {"id": "b_8", "type": "paragraph", "text": ">>> from sklearn.metrics import f1_score >>> f1_score(y_train_5, y_train_pred) 0.7420962043663375", "words": [{"w": ">>>", "b": [0.1766, 0.2859, 0.2019, 0.2988]}, {"w": "from", "b": [0.2103, 0.2859, 0.2441, 0.2988]}, {"w": "sklearn.metrics", "b": [0.2525, 0.2859, 0.379, 0.2988]}, {"w": "import", "b": [0.3874, 0.2859, 0.438, 0.2988]}, {"w": "f1_score", "b": [0.4464, 0.2859, 0.5139, 0.2988]}, {"w": ">>>", "b": [0.1766, 0.3014, 0.2019, 0.3142]}, {"w": "f1_score(y_train_5,", "b": [0.2103, 0.3014, 0.3705, 0.3142]}, {"w": "y_train_pred)", "b": [0.379, 0.3014, 0.4886, 0.3142]}, {"w": "0.7420962043663375", "b": [0.1766, 0.3168, 0.3284, 0.3296]}]}, {"id": "b_9", "type": "paragraph", "text": "The F1 score favors classifiers that have similar precision and recall. This is not always what you want: in some contexts you mostly care about precision, and in other con‐ texts you really care about recall. For example, if you trained a classifier to detect vid‐ eos that are safe for kids, you would probably prefer a classifier that rejects many good videos (low recall) but keeps only safe ones (high precision), rather than a clas‐ sifier that has a much higher recall but lets a few really bad videos show up in your product (in such cases, you may even want to add a human pipeline to check the clas‐ sifier’s video selection). On the other hand, suppose you train a classifier to detect shoplifters on surveillance images: it is probably fine if your classifier has only 30% precision as long as it has 99% recall (sure, the security guards will get a few false alerts, but almost all shoplifters will get caught).", "words": [{"w": "The", "b": [0.1429, 0.3374, 0.1757, 0.3588]}, {"w": "F1", "b": [0.1804, 0.3374, 0.1977, 0.3597]}, {"w": "score", "b": [0.2026, 0.3374, 0.2463, 0.3588]}, {"w": "favors", "b": [0.2512, 0.3374, 0.3018, 0.3588]}, {"w": "classifiers", "b": [0.3067, 0.3374, 0.3868, 0.3588]}, {"w": "that", "b": [0.3917, 0.3374, 0.4243, 0.3588]}, {"w": "have", "b": [0.4293, 0.3374, 0.4676, 0.3588]}, {"w": "similar", "b": [0.4726, 0.3374, 0.5306, 0.3588]}, {"w": "precision", "b": [0.5355, 0.3374, 0.6127, 0.3588]}, {"w": "and", "b": [0.6176, 0.3374, 0.6492, 0.3588]}, {"w": "recall.", "b": [0.6541, 0.3374, 0.7039, 0.3588]}, {"w": "This", "b": [0.7089, 0.3374, 0.7461, 0.3588]}, {"w": "is", "b": [0.751, 0.3374, 0.7642, 0.3588]}, {"w": "not", "b": [0.7692, 0.3374, 0.7975, 0.3588]}, {"w": "always", "b": [0.8025, 0.3374, 0.8572, 0.3588]}, {"w": "what", "b": [0.1429, 0.3565, 0.1834, 0.3779]}, {"w": "you", "b": [0.1893, 0.3565, 0.2205, 0.3779]}, {"w": "want:", "b": [0.2265, 0.3565, 0.272, 0.3779]}, {"w": "in", "b": [0.2779, 0.3565, 0.2949, 0.3779]}, {"w": "some", "b": [0.3008, 0.3565, 0.345, 0.3779]}, {"w": "contexts", "b": [0.3509, 0.3565, 0.4204, 0.3779]}, {"w": "you", "b": [0.4263, 0.3565, 0.4576, 0.3779]}, {"w": "mostly", "b": [0.4635, 0.3565, 0.52, 0.3779]}, {"w": "care", "b": [0.5259, 0.3565, 0.5605, 0.3779]}, {"w": "about", "b": [0.5664, 0.3565, 0.6142, 0.3779]}, {"w": "precision,", "b": [0.6201, 0.3565, 0.702, 0.3779]}, {"w": "and", "b": [0.7079, 0.3565, 0.7395, 0.3779]}, {"w": "in", "b": [0.7454, 0.3565, 0.7624, 0.3779]}, {"w": "other", "b": [0.7683, 0.3565, 0.813, 0.3779]}, {"w": "con‐", "b": [0.8189, 0.3565, 0.8571, 0.3779]}, {"w": "texts", "b": [0.1429, 0.3755, 0.1819, 0.3969]}, {"w": "you", "b": [0.187, 0.3755, 0.2183, 0.3969]}, {"w": "really", "b": [0.2234, 0.3755, 0.2693, 0.3969]}, {"w": "care", "b": [0.2744, 0.3755, 0.309, 0.3969]}, {"w": "about", "b": [0.3141, 0.3755, 0.3619, 0.3969]}, {"w": "recall.", "b": [0.367, 0.3755, 0.4169, 0.3969]}, {"w": "For", "b": [0.422, 0.3755, 0.451, 0.3969]}, {"w": "example,", "b": [0.4562, 0.3755, 0.5304, 0.3969]}, {"w": "if", "b": [0.5356, 0.3755, 0.5473, 0.3969]}, {"w": "you", "b": [0.5525, 0.3755, 0.5837, 0.3969]}, {"w": "trained", "b": [0.5889, 0.3755, 0.649, 0.3969]}, {"w": "a", "b": [0.6541, 0.3755, 0.6632, 0.3969]}, {"w": "classifier", "b": [0.6684, 0.3755, 0.7408, 0.3969]}, {"w": "to", "b": [0.746, 0.3755, 0.763, 0.3969]}, {"w": "detect", "b": [0.7681, 0.3755, 0.8183, 0.3969]}, {"w": "vid‐", "b": [0.8235, 0.3755, 0.8571, 0.3969]}, {"w": "eos", "b": [0.1428, 0.3946, 0.17, 0.416]}, {"w": "that", "b": [0.1779, 0.3946, 0.2105, 0.416]}, {"w": "are", "b": [0.2184, 0.3946, 0.2441, 0.416]}, {"w": "safe", "b": [0.252, 0.3946, 0.2838, 0.416]}, {"w": "for", "b": [0.2917, 0.3946, 0.3162, 0.416]}, {"w": "kids,", "b": [0.3241, 0.3946, 0.3634, 0.416]}, {"w": "you", "b": [0.3713, 0.3946, 0.4026, 0.416]}, {"w": "would", "b": [0.4105, 0.3946, 0.4627, 0.416]}, {"w": "probably", "b": [0.4706, 0.3946, 0.545, 0.416]}, {"w": "prefer", "b": [0.5529, 0.3946, 0.6032, 0.416]}, {"w": "a", "b": [0.6111, 0.3946, 0.6202, 0.416]}, {"w": "classifier", "b": [0.6281, 0.3946, 0.7006, 0.416]}, {"w": "that", "b": [0.7085, 0.3946, 0.7411, 0.416]}, {"w": "rejects", "b": [0.749, 0.3946, 0.8025, 0.416]}, {"w": "many", "b": [0.8104, 0.3946, 0.8571, 0.416]}, {"w": "good", "b": [0.1429, 0.4136, 0.1849, 0.435]}, {"w": "videos", "b": [0.1904, 0.4136, 0.2438, 0.435]}, {"w": "(low", "b": [0.2493, 0.4136, 0.2867, 0.435]}, {"w": "recall)", "b": [0.2922, 0.4136, 0.3445, 0.435]}, {"w": "but", "b": [0.35, 0.4136, 0.378, 0.435]}, {"w": "keeps", "b": [0.3836, 0.4136, 0.4302, 0.435]}, {"w": "only", "b": [0.4357, 0.4136, 0.4726, 0.435]}, {"w": "safe", "b": [0.4781, 0.4136, 0.5099, 0.435]}, {"w": "ones", "b": [0.5155, 0.4136, 0.554, 0.435]}, {"w": "(high", "b": [0.5595, 0.4136, 0.6043, 0.435]}, {"w": "precision),", "b": [0.6099, 0.4136, 0.699, 0.435]}, {"w": "rather", "b": [0.7045, 0.4136, 0.7551, 0.435]}, {"w": "than", "b": [0.7606, 0.4136, 0.7986, 0.435]}, {"w": "a", "b": [0.8042, 0.4136, 0.8133, 0.435]}, {"w": "clas‐", "b": [0.8189, 0.4136, 0.8571, 0.435]}, {"w": "sifier", "b": [0.1429, 0.4327, 0.1844, 0.4541]}, {"w": "that", "b": [0.1909, 0.4327, 0.2235, 0.4541]}, {"w": "has", "b": [0.23, 0.4327, 0.2579, 0.4541]}, {"w": "a", "b": [0.2643, 0.4327, 0.2735, 0.4541]}, {"w": "much", "b": [0.28, 0.4327, 0.3276, 0.4541]}, {"w": "higher", "b": [0.3341, 0.4327, 0.3883, 0.4541]}, {"w": "recall", "b": [0.3947, 0.4327, 0.4398, 0.4541]}, {"w": "but", "b": [0.4463, 0.4327, 0.4743, 0.4541]}, {"w": "lets", "b": [0.4808, 0.4327, 0.5089, 0.4541]}, {"w": "a", "b": [0.5154, 0.4327, 0.5245, 0.4541]}, {"w": "few", "b": [0.531, 0.4327, 0.5603, 0.4541]}, {"w": "really", "b": [0.5668, 0.4327, 0.6126, 0.4541]}, {"w": "bad", "b": [0.6191, 0.4327, 0.6498, 0.4541]}, {"w": "videos", "b": [0.6563, 0.4327, 0.7096, 0.4541]}, {"w": "show", "b": [0.7161, 0.4327, 0.7598, 0.4541]}, {"w": "up", "b": [0.7663, 0.4327, 0.7882, 0.4541]}, {"w": "in", "b": [0.7947, 0.4327, 0.8117, 0.4541]}, {"w": "your", "b": [0.8182, 0.4327, 0.8571, 0.4541]}, {"w": "product", "b": [0.1429, 0.4517, 0.2094, 0.4731]}, {"w": "(in", "b": [0.2142, 0.4517, 0.2384, 0.4731]}, {"w": "such", "b": [0.2433, 0.4517, 0.282, 0.4731]}, {"w": "cases,", "b": [0.2869, 0.4517, 0.3337, 0.4731]}, {"w": "you", "b": [0.3386, 0.4517, 0.3699, 0.4731]}, {"w": "may", "b": [0.3748, 0.4517, 0.4102, 0.4731]}, {"w": "even", "b": [0.4151, 0.4517, 0.4538, 0.4731]}, {"w": "want", "b": [0.4587, 0.4517, 0.4995, 0.4731]}, {"w": "to", "b": [0.5044, 0.4517, 0.5214, 0.4731]}, {"w": "add", "b": [0.5263, 0.4517, 0.5574, 0.4731]}, {"w": "a", "b": [0.5623, 0.4517, 0.5714, 0.4731]}, {"w": "human", "b": [0.5763, 0.4517, 0.6357, 0.4731]}, {"w": "pipeline", "b": [0.6406, 0.4517, 0.708, 0.4731]}, {"w": "to", "b": [0.7129, 0.4517, 0.7299, 0.4731]}, {"w": "check", "b": [0.7348, 0.4517, 0.7827, 0.4731]}, {"w": "the", "b": [0.7876, 0.4517, 0.8139, 0.4731]}, {"w": "clas‐", "b": [0.8188, 0.4517, 0.8571, 0.4731]}, {"w": "sifier’s", "b": [0.1429, 0.4707, 0.1947, 0.4922]}, {"w": "video", "b": [0.2023, 0.4707, 0.248, 0.4922]}, {"w": "selection).", "b": [0.2555, 0.4707, 0.3409, 0.4922]}, {"w": "On", "b": [0.3484, 0.4707, 0.3754, 0.4922]}, {"w": "the", "b": [0.3829, 0.4707, 0.4093, 0.4922]}, {"w": "other", "b": [0.4168, 0.4707, 0.4615, 0.4922]}, {"w": "hand,", "b": [0.469, 0.4707, 0.5164, 0.4922]}, {"w": "suppose", "b": [0.524, 0.4707, 0.5917, 0.4922]}, {"w": "you", "b": [0.5992, 0.4707, 0.6304, 0.4922]}, {"w": "train", "b": [0.638, 0.4707, 0.6782, 0.4922]}, {"w": "a", "b": [0.6857, 0.4707, 0.6949, 0.4922]}, {"w": "classifier", "b": [0.7024, 0.4707, 0.7749, 0.4922]}, {"w": "to", "b": [0.7824, 0.4707, 0.7994, 0.4922]}, {"w": "detect", "b": [0.8069, 0.4707, 0.8572, 0.4922]}, {"w": "shoplifters", "b": [0.1429, 0.4898, 0.2308, 0.5112]}, {"w": "on", "b": [0.2374, 0.4898, 0.2594, 0.5112]}, {"w": "surveillance", "b": [0.2661, 0.4898, 0.366, 0.5112]}, {"w": "images:", "b": [0.3726, 0.4898, 0.4354, 0.5112]}, {"w": "it", "b": [0.4421, 0.4898, 0.454, 0.5112]}, {"w": "is", "b": [0.4606, 0.4898, 0.4739, 0.5112]}, {"w": "probably", "b": [0.4805, 0.4898, 0.5549, 0.5112]}, {"w": "fine", "b": [0.5616, 0.4898, 0.5936, 0.5112]}, {"w": "if", "b": [0.6002, 0.4898, 0.612, 0.5112]}, {"w": "your", "b": [0.6186, 0.4898, 0.6576, 0.5112]}, {"w": "classifier", "b": [0.6642, 0.4898, 0.7367, 0.5112]}, {"w": "has", "b": [0.7433, 0.4898, 0.7712, 0.5112]}, {"w": "only", "b": [0.7779, 0.4898, 0.8147, 0.5112]}, {"w": "30%", "b": [0.8214, 0.4898, 0.8571, 0.5112]}, {"w": "precision", "b": [0.1429, 0.5088, 0.22, 0.5303]}, {"w": "as", "b": [0.2275, 0.5088, 0.2443, 0.5303]}, {"w": "long", "b": [0.2517, 0.5088, 0.2888, 0.5303]}, {"w": "as", "b": [0.2962, 0.5088, 0.313, 0.5303]}, {"w": "it", "b": [0.3205, 0.5088, 0.3324, 0.5303]}, {"w": "has", "b": [0.3399, 0.5088, 0.3678, 0.5303]}, {"w": "99%", "b": [0.3753, 0.5088, 0.411, 0.5303]}, {"w": "recall", "b": [0.4185, 0.5088, 0.4636, 0.5303]}, {"w": "(sure,", "b": [0.471, 0.5088, 0.5183, 0.5303]}, {"w": "the", "b": [0.5257, 0.5088, 0.5521, 0.5303]}, {"w": "security", "b": [0.5595, 0.5088, 0.6251, 0.5303]}, {"w": "guards", "b": [0.6326, 0.5088, 0.6889, 0.5303]}, {"w": "will", "b": [0.6964, 0.5088, 0.7268, 0.5303]}, {"w": "get", "b": [0.7343, 0.5088, 0.7592, 0.5303]}, {"w": "a", "b": [0.7667, 0.5088, 0.7758, 0.5303]}, {"w": "few", "b": [0.7833, 0.5088, 0.8126, 0.5303]}, {"w": "false", "b": [0.8201, 0.5088, 0.8571, 0.5303]}, {"w": "alerts,", "b": [0.1428, 0.5279, 0.1926, 0.5493]}, {"w": "but", "b": [0.1973, 0.5279, 0.2253, 0.5493]}, {"w": "almost", "b": [0.2301, 0.5279, 0.2862, 0.5493]}, {"w": "all", "b": [0.2909, 0.5279, 0.3106, 0.5493]}, {"w": "shoplifters", "b": [0.3153, 0.5279, 0.4032, 0.5493]}, {"w": "will", "b": [0.408, 0.5279, 0.4383, 0.5493]}, {"w": "get", "b": [0.4431, 0.5279, 0.468, 0.5493]}, {"w": "caught).", "b": [0.4728, 0.5279, 0.5402, 0.5493]}]}, {"id": "b_10", "type": "paragraph", "text": "Unfortunately, you can’t have it both ways: increasing precision reduces recall, and vice versa. This is called the precision/recall tradeoff.", "words": [{"w": "Unfortunately,", "b": [0.1428, 0.556, 0.264, 0.5774]}, {"w": "you", "b": [0.2714, 0.556, 0.3027, 0.5774]}, {"w": "can’t", "b": [0.3101, 0.556, 0.348, 0.5774]}, {"w": "have", "b": [0.3555, 0.556, 0.3939, 0.5774]}, {"w": "it", "b": [0.4013, 0.556, 0.4132, 0.5774]}, {"w": "both", "b": [0.4206, 0.556, 0.4593, 0.5774]}, {"w": "ways:", "b": [0.4667, 0.556, 0.5117, 0.5774]}, {"w": "increasing", "b": [0.5191, 0.556, 0.605, 0.5774]}, {"w": "precision", "b": [0.6124, 0.556, 0.6896, 0.5774]}, {"w": "reduces", "b": [0.697, 0.556, 0.7609, 0.5774]}, {"w": "recall,", "b": [0.7683, 0.556, 0.8182, 0.5774]}, {"w": "and", "b": [0.8256, 0.556, 0.8571, 0.5774]}, {"w": "vice", "b": [0.1429, 0.5751, 0.1758, 0.5965]}, {"w": "versa.", "b": [0.1805, 0.5751, 0.2283, 0.5965]}, {"w": "This", "b": [0.233, 0.5751, 0.2702, 0.5965]}, {"w": "is", "b": [0.2749, 0.5751, 0.2882, 0.5965]}, {"w": "called", "b": [0.2929, 0.5751, 0.3412, 0.5965]}, {"w": "the", "b": [0.346, 0.5751, 0.3723, 0.5965]}, {"w": "precision/recall", "b": [0.377, 0.5749, 0.4994, 0.5965]}, {"w": "tradeoff.", "b": [0.5042, 0.5749, 0.5729, 0.5965]}]}, {"id": "b_11", "type": "equation", "text": "Precision/Recall Tradeoff", "words": [{"w": "Precision/Recall", "b": [0.1429, 0.6092, 0.3062, 0.6378]}, {"w": "Tradeoff", "b": [0.3111, 0.6092, 0.3977, 0.6378]}]}, {"id": "b_12", "type": "paragraph", "text": "To understand this tradeoff, let’s look at how the SGDClassifier makes its classifica‐ tion decisions. For each instance, it computes a score based on a decision function, and if that score is greater than a threshold, it assigns the instance to the positive class, or else it assigns it to the negative class. Figure 3-3 shows a few digits positioned from the lowest score on the left to the highest score on the right. Suppose the deci‐ sion threshold is positioned at the central arrow (between the two 5s): you will find 4 true positives (actual 5s) on the right of that threshold, and one false positive (actually a 6). Therefore, with that threshold, the precision is 80% (4 out of 5). But out of 6 actual 5s, the classifier only detects 4, so the recall is 67% (4 out of 6). Now if you raise the threshold (move it to the arrow on the right), the false positive (the 6) becomes a true negative, thereby increasing precision (up to 100% in this case), but one true positive becomes a false negative, decreasing recall down to 50%. Conversely, lowering the threshold increases recall and reduces precision.", "words": [{"w": "To", "b": [0.1428, 0.6446, 0.1643, 0.666]}, {"w": "understand", "b": [0.17, 0.6446, 0.2656, 0.666]}, {"w": "this", "b": [0.2713, 0.6446, 0.302, 0.666]}, {"w": "tradeoff,", "b": [0.3078, 0.6446, 0.3785, 0.666]}, {"w": "let’s", "b": [0.3843, 0.6446, 0.4145, 0.666]}, {"w": "look", "b": [0.4202, 0.6446, 0.4571, 0.666]}, {"w": "at", "b": [0.4628, 0.6446, 0.4779, 0.666]}, {"w": "how", "b": [0.4836, 0.6446, 0.5197, 0.666]}, {"w": "the", "b": [0.5254, 0.6446, 0.5517, 0.666]}, {"w": "SGDClassifier", "b": [0.5575, 0.6478, 0.6861, 0.6629]}, {"w": "makes", "b": [0.6918, 0.6446, 0.7449, 0.666]}, {"w": "its", "b": [0.7506, 0.6446, 0.7702, 0.666]}, {"w": "classifica‐", "b": [0.7759, 0.6446, 0.8571, 0.666]}, {"w": "tion", "b": [0.1429, 0.6636, 0.1768, 0.6851]}, {"w": "decisions.", "b": [0.1836, 0.6636, 0.2655, 0.6851]}, {"w": "For", "b": [0.2723, 0.6636, 0.3013, 0.6851]}, {"w": "each", "b": [0.3081, 0.6636, 0.346, 0.6851]}, {"w": "instance,", "b": [0.3528, 0.6636, 0.4267, 0.6851]}, {"w": "it", "b": [0.4335, 0.6636, 0.4455, 0.6851]}, {"w": "computes", "b": [0.4523, 0.6636, 0.5332, 0.6851]}, {"w": "a", "b": [0.54, 0.6636, 0.5491, 0.6851]}, {"w": "score", "b": [0.5559, 0.6636, 0.5996, 0.6851]}, {"w": "based", "b": [0.6064, 0.6636, 0.6536, 0.6851]}, {"w": "on", "b": [0.6604, 0.6636, 0.6824, 0.6851]}, {"w": "a", "b": [0.6892, 0.6636, 0.6984, 0.6851]}, {"w": "decision", "b": [0.7051, 0.6634, 0.7707, 0.6851]}, {"w": "function,", "b": [0.7775, 0.6634, 0.8504, 0.6851]}, {"w": "and", "b": [0.1429, 0.6827, 0.1744, 0.7041]}, {"w": "if", "b": [0.1822, 0.6827, 0.194, 0.7041]}, {"w": "that", "b": [0.2018, 0.6827, 0.2343, 0.7041]}, {"w": "score", "b": [0.2421, 0.6827, 0.2858, 0.7041]}, {"w": "is", "b": [0.2936, 0.6827, 0.3068, 0.7041]}, {"w": "greater", "b": [0.3146, 0.6827, 0.3727, 0.7041]}, {"w": "than", "b": [0.3805, 0.6827, 0.4185, 0.7041]}, {"w": "a", "b": [0.4263, 0.6827, 0.4354, 0.7041]}, {"w": "threshold,", "b": [0.4432, 0.6827, 0.5277, 0.7041]}, {"w": "it", "b": [0.5355, 0.6827, 0.5475, 0.7041]}, {"w": "assigns", "b": [0.5553, 0.6827, 0.6141, 0.7041]}, {"w": "the", "b": [0.6219, 0.6827, 0.6482, 0.7041]}, {"w": "instance", "b": [0.656, 0.6827, 0.7252, 0.7041]}, {"w": "to", "b": [0.733, 0.6827, 0.75, 0.7041]}, {"w": "the", "b": [0.7578, 0.6827, 0.7841, 0.7041]}, {"w": "positive", "b": [0.7919, 0.6827, 0.8571, 0.7041]}, {"w": "class,", "b": [0.1429, 0.7017, 0.1861, 0.7232]}, {"w": "or", "b": [0.191, 0.7017, 0.2093, 0.7232]}, {"w": "else", "b": [0.2142, 0.7017, 0.2448, 0.7232]}, {"w": "it", "b": [0.2497, 0.7017, 0.2616, 0.7232]}, {"w": "assigns", "b": [0.2665, 0.7017, 0.3253, 0.7232]}, {"w": "it", "b": [0.3302, 0.7017, 0.3421, 0.7232]}, {"w": "to", "b": [0.347, 0.7017, 0.364, 0.7232]}, {"w": "the", "b": [0.3689, 0.7017, 0.3952, 0.7232]}, {"w": "negative", "b": [0.4001, 0.7017, 0.4692, 0.7232]}, {"w": "class.", "b": [0.4741, 0.7017, 0.5174, 0.7232]}, {"w": "Figure", "b": [0.5223, 0.7017, 0.5763, 0.7232]}, {"w": "3-3", "b": [0.581, 0.7017, 0.6084, 0.7232]}, {"w": "shows", "b": [0.6134, 0.7017, 0.6647, 0.7232]}, {"w": "a", "b": [0.6695, 0.7017, 0.6786, 0.7232]}, {"w": "few", "b": [0.6833, 0.7017, 0.7126, 0.7232]}, {"w": "digits", "b": [0.7174, 0.7017, 0.7633, 0.7232]}, {"w": "positioned", "b": [0.768, 0.7017, 0.8566, 0.7232]}, {"w": "from", "b": [0.1429, 0.7208, 0.1844, 0.7422]}, {"w": "the", "b": [0.1906, 0.7208, 0.2169, 0.7422]}, {"w": "lowest", "b": [0.2231, 0.7208, 0.2761, 0.7422]}, {"w": "score", "b": [0.2823, 0.7208, 0.3259, 0.7422]}, {"w": "on", "b": [0.3321, 0.7208, 0.3541, 0.7422]}, {"w": "the", "b": [0.3603, 0.7208, 0.3866, 0.7422]}, {"w": "left", "b": [0.3927, 0.7208, 0.4194, 0.7422]}, {"w": "to", "b": [0.4255, 0.7208, 0.4425, 0.7422]}, {"w": "the", "b": [0.4487, 0.7208, 0.475, 0.7422]}, {"w": "highest", "b": [0.4812, 0.7208, 0.5416, 0.7422]}, {"w": "score", "b": [0.5478, 0.7208, 0.5914, 0.7422]}, {"w": "on", "b": [0.5976, 0.7208, 0.6196, 0.7422]}, {"w": "the", "b": [0.6258, 0.7208, 0.6521, 0.7422]}, {"w": "right.", "b": [0.6582, 0.7208, 0.7031, 0.7422]}, {"w": "Suppose", "b": [0.7093, 0.7208, 0.7792, 0.7422]}, {"w": "the", "b": [0.7853, 0.7208, 0.8117, 0.7422]}, {"w": "deci‐", "b": [0.8178, 0.7206, 0.8571, 0.7422]}, {"w": "sion", "b": [0.1429, 0.7396, 0.1759, 0.7613]}, {"w": "threshold", "b": [0.1818, 0.7396, 0.2562, 0.7613]}, {"w": "is", "b": [0.2621, 0.7398, 0.2753, 0.7613]}, {"w": "positioned", "b": [0.2811, 0.7398, 0.3697, 0.7613]}, {"w": "at", "b": [0.3755, 0.7398, 0.3906, 0.7613]}, {"w": "the", "b": [0.3965, 0.7398, 0.4228, 0.7613]}, {"w": "central", "b": [0.4286, 0.7398, 0.4858, 0.7613]}, {"w": "arrow", "b": [0.4916, 0.7398, 0.5411, 0.7613]}, {"w": "(between", "b": [0.547, 0.7398, 0.6233, 0.7613]}, {"w": "the", "b": [0.6292, 0.7398, 0.6555, 0.7613]}, {"w": "two", "b": [0.6613, 0.7398, 0.6926, 0.7613]}, {"w": "5s):", "b": [0.6984, 0.7398, 0.728, 0.7613]}, {"w": "you", "b": [0.7339, 0.7398, 0.7651, 0.7613]}, {"w": "will", "b": [0.7709, 0.7398, 0.8013, 0.7613]}, {"w": "find", "b": [0.8072, 0.7398, 0.8413, 0.7613]}, {"w": "4", "b": [0.8471, 0.7398, 0.8571, 0.7613]}, {"w": "true", "b": [0.1429, 0.7589, 0.1769, 0.7803]}, {"w": "positives", "b": [0.1816, 0.7589, 0.2545, 0.7803]}, {"w": "(actual", "b": [0.2592, 0.7589, 0.3162, 0.7803]}, {"w": "5s)", "b": [0.3209, 0.7589, 0.3458, 0.7803]}, {"w": "on", "b": [0.3505, 0.7589, 0.3725, 0.7803]}, {"w": "the", "b": [0.3772, 0.7589, 0.4036, 0.7803]}, {"w": "right", "b": [0.4083, 0.7589, 0.4485, 0.7803]}, {"w": "of", "b": [0.4532, 0.7589, 0.47, 0.7803]}, {"w": "that", "b": [0.4747, 0.7589, 0.5073, 0.7803]}, {"w": "threshold,", "b": [0.512, 0.7589, 0.5965, 0.7803]}, {"w": "and", "b": [0.6012, 0.7589, 0.6328, 0.7803]}, {"w": "one", "b": [0.6375, 0.7589, 0.6684, 0.7803]}, {"w": "false", "b": [0.6731, 0.7589, 0.7102, 0.7803]}, {"w": "positive", "b": [0.7149, 0.7589, 0.7801, 0.7803]}, {"w": "(actually", "b": [0.7848, 0.7589, 0.8567, 0.7803]}, {"w": "a", "b": [0.1429, 0.7779, 0.152, 0.7993]}, {"w": "6).", "b": [0.1591, 0.7779, 0.181, 0.7993]}, {"w": "Therefore,", "b": [0.1881, 0.7779, 0.2757, 0.7993]}, {"w": "with", "b": [0.2827, 0.7779, 0.3201, 0.7993]}, {"w": "that", "b": [0.3272, 0.7779, 0.3597, 0.7993]}, {"w": "threshold,", "b": [0.3668, 0.7779, 0.4513, 0.7993]}, {"w": "the", "b": [0.4584, 0.7779, 0.4847, 0.7993]}, {"w": "precision", "b": [0.4918, 0.7779, 0.5689, 0.7993]}, {"w": "is", "b": [0.576, 0.7779, 0.5892, 0.7993]}, {"w": "80%", "b": [0.5963, 0.7779, 0.632, 0.7993]}, {"w": "(4", "b": [0.6391, 0.7779, 0.6563, 0.7993]}, {"w": "out", "b": [0.6634, 0.7779, 0.6915, 0.7993]}, {"w": "of", "b": [0.6985, 0.7779, 0.7153, 0.7993]}, {"w": "5).", "b": [0.7224, 0.7779, 0.7444, 0.7993]}, {"w": "But", "b": [0.7514, 0.7779, 0.7811, 0.7993]}, {"w": "out", "b": [0.7882, 0.7779, 0.8162, 0.7993]}, {"w": "of", "b": [0.8233, 0.7779, 0.8401, 0.7993]}, {"w": "6", "b": [0.8472, 0.7779, 0.8572, 0.7993]}, {"w": "actual", "b": [0.1429, 0.797, 0.1927, 0.8184]}, {"w": "5s,", "b": [0.1998, 0.797, 0.2222, 0.8184]}, {"w": "the", "b": [0.2293, 0.797, 0.2556, 0.8184]}, {"w": "classifier", "b": [0.2628, 0.797, 0.3352, 0.8184]}, {"w": "only", "b": [0.3423, 0.797, 0.3792, 0.8184]}, {"w": "detects", "b": [0.3863, 0.797, 0.4442, 0.8184]}, {"w": "4,", "b": [0.4513, 0.797, 0.4661, 0.8184]}, {"w": "so", "b": [0.4732, 0.797, 0.4915, 0.8184]}, {"w": "the", "b": [0.4986, 0.797, 0.5249, 0.8184]}, {"w": "recall", "b": [0.5321, 0.797, 0.5772, 0.8184]}, {"w": "is", "b": [0.5843, 0.797, 0.5975, 0.8184]}, {"w": "67%", "b": [0.6046, 0.797, 0.6404, 0.8184]}, {"w": "(4", "b": [0.6475, 0.797, 0.6647, 0.8184]}, {"w": "out", "b": [0.6719, 0.797, 0.6999, 0.8184]}, {"w": "of", "b": [0.707, 0.797, 0.7238, 0.8184]}, {"w": "6).", "b": [0.7309, 0.797, 0.7529, 0.8184]}, {"w": "Now", "b": [0.76, 0.797, 0.7999, 0.8184]}, {"w": "if", "b": [0.807, 0.797, 0.8188, 0.8184]}, {"w": "you", "b": [0.8259, 0.797, 0.8571, 0.8184]}, {"w": "raise", "b": [0.1429, 0.816, 0.1818, 0.8374]}, {"w": "the", "b": [0.1906, 0.816, 0.2169, 0.8374]}, {"w": "threshold", "b": [0.2257, 0.816, 0.3054, 0.8374]}, {"w": "(move", "b": [0.3141, 0.816, 0.3675, 0.8374]}, {"w": "it", "b": [0.3763, 0.816, 0.3882, 0.8374]}, {"w": "to", "b": [0.397, 0.816, 0.414, 0.8374]}, {"w": "the", "b": [0.4227, 0.816, 0.449, 0.8374]}, {"w": "arrow", "b": [0.4578, 0.816, 0.5073, 0.8374]}, {"w": "on", "b": [0.516, 0.816, 0.5381, 0.8374]}, {"w": "the", "b": [0.5468, 0.816, 0.5731, 0.8374]}, {"w": "right),", "b": [0.5819, 0.816, 0.634, 0.8374]}, {"w": "the", "b": [0.6428, 0.816, 0.6691, 0.8374]}, {"w": "false", "b": [0.6778, 0.816, 0.7149, 0.8374]}, {"w": "positive", "b": [0.7237, 0.816, 0.7889, 0.8374]}, {"w": "(the", "b": [0.7976, 0.816, 0.8312, 0.8374]}, {"w": "6)", "b": [0.8399, 0.816, 0.8571, 0.8374]}, {"w": "becomes", "b": [0.1429, 0.8351, 0.2153, 0.8565]}, {"w": "a", "b": [0.2218, 0.8351, 0.2309, 0.8565]}, {"w": "true", "b": [0.2375, 0.8351, 0.2715, 0.8565]}, {"w": "negative,", "b": [0.278, 0.8351, 0.3519, 0.8565]}, {"w": "thereby", "b": [0.3584, 0.8351, 0.4215, 0.8565]}, {"w": "increasing", "b": [0.428, 0.8351, 0.5139, 0.8565]}, {"w": "precision", "b": [0.5204, 0.8351, 0.5975, 0.8565]}, {"w": "(up", "b": [0.6041, 0.8351, 0.6332, 0.8565]}, {"w": "to", "b": [0.6397, 0.8351, 0.6567, 0.8565]}, {"w": "100%", "b": [0.6632, 0.8351, 0.709, 0.8565]}, {"w": "in", "b": [0.7155, 0.8351, 0.7325, 0.8565]}, {"w": "this", "b": [0.739, 0.8351, 0.7697, 0.8565]}, {"w": "case),", "b": [0.7762, 0.8351, 0.8226, 0.8565]}, {"w": "but", "b": [0.8291, 0.8351, 0.8571, 0.8565]}, {"w": "one", "b": [0.1429, 0.8541, 0.1737, 0.8755]}, {"w": "true", "b": [0.1785, 0.8541, 0.2125, 0.8755]}, {"w": "positive", "b": [0.2172, 0.8541, 0.2824, 0.8755]}, {"w": "becomes", "b": [0.2871, 0.8541, 0.3596, 0.8755]}, {"w": "a", "b": [0.3643, 0.8541, 0.3734, 0.8755]}, {"w": "false", "b": [0.3782, 0.8541, 0.4153, 0.8755]}, {"w": "negative,", "b": [0.42, 0.8541, 0.4939, 0.8755]}, {"w": "decreasing", "b": [0.4987, 0.8541, 0.5874, 0.8755]}, {"w": "recall", "b": [0.5922, 0.8541, 0.6372, 0.8755]}, {"w": "down", "b": [0.642, 0.8541, 0.6893, 0.8755]}, {"w": "to", "b": [0.694, 0.8541, 0.711, 0.8755]}, {"w": "50%.", "b": [0.7157, 0.8541, 0.7562, 0.8755]}, {"w": "Conversely,", "b": [0.7609, 0.8541, 0.8571, 0.8755]}, {"w": "lowering", "b": [0.1429, 0.8732, 0.2163, 0.8946]}, {"w": "the", "b": [0.2211, 0.8732, 0.2474, 0.8946]}, {"w": "threshold", "b": [0.2521, 0.8732, 0.3319, 0.8946]}, {"w": "increases", "b": [0.3366, 0.8732, 0.4123, 0.8946]}, {"w": "recall", "b": [0.417, 0.8732, 0.4621, 0.8946]}, {"w": "and", "b": [0.4668, 0.8732, 0.4983, 0.8946]}, {"w": "reduces", "b": [0.5031, 0.8732, 0.567, 0.8946]}, {"w": "precision.", "b": [0.5718, 0.8732, 0.6537, 0.8946]}]}, {"id": "b_13", "type": "paragraph", "text": "Performance Measures | 95", "words": [{"w": "Performance", "b": [0.669, 0.9225, 0.7445, 0.9388]}, {"w": "Measures", "b": [0.7474, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "95", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 122, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 3-3. Decision threshold and precision/recall tradeoff", "words": [{"w": "Figure", "b": [0.1429, 0.2468, 0.1943, 0.2684]}, {"w": "3-3.", "b": [0.1991, 0.2468, 0.2308, 0.2684]}, {"w": "Decision", "b": [0.2356, 0.2468, 0.3055, 0.2684]}, {"w": "threshold", "b": [0.3103, 0.2468, 0.3847, 0.2684]}, {"w": "and", "b": [0.3894, 0.2468, 0.4208, 0.2684]}, {"w": "precision/recall", "b": [0.4256, 0.2468, 0.548, 0.2684]}, {"w": "tradeoff", "b": [0.5528, 0.2468, 0.6167, 0.2684]}]}, {"id": "b_1", "type": "paragraph", "text": "Scikit-Learn does not let you set the threshold directly, but it does give you access to the decision scores that it uses to make predictions. Instead of calling the classifier’s predict() method, you can call its decision_function() method, which returns a score for each instance, and then make predictions based on those scores using any threshold you want:", "words": [{"w": "Scikit-Learn", "b": [0.1429, 0.2842, 0.2451, 0.3056]}, {"w": "does", "b": [0.251, 0.2842, 0.2891, 0.3056]}, {"w": "not", "b": [0.2949, 0.2842, 0.3233, 0.3056]}, {"w": "let", "b": [0.3291, 0.2842, 0.3496, 0.3056]}, {"w": "you", "b": [0.3554, 0.2842, 0.3867, 0.3056]}, {"w": "set", "b": [0.3925, 0.2842, 0.4154, 0.3056]}, {"w": "the", "b": [0.4212, 0.2842, 0.4475, 0.3056]}, {"w": "threshold", "b": [0.4534, 0.2842, 0.5331, 0.3056]}, {"w": "directly,", "b": [0.5389, 0.2842, 0.6053, 0.3056]}, {"w": "but", "b": [0.6111, 0.2842, 0.6391, 0.3056]}, {"w": "it", "b": [0.645, 0.2842, 0.6569, 0.3056]}, {"w": "does", "b": [0.6627, 0.2842, 0.7009, 0.3056]}, {"w": "give", "b": [0.7067, 0.2842, 0.7405, 0.3056]}, {"w": "you", "b": [0.7463, 0.2842, 0.7776, 0.3056]}, {"w": "access", "b": [0.7834, 0.2842, 0.8343, 0.3056]}, {"w": "to", "b": [0.8402, 0.2842, 0.8571, 0.3056]}, {"w": "the", "b": [0.1429, 0.3032, 0.1692, 0.3246]}, {"w": "decision", "b": [0.1756, 0.3032, 0.2451, 0.3246]}, {"w": "scores", "b": [0.2515, 0.3032, 0.3028, 0.3246]}, {"w": "that", "b": [0.3092, 0.3032, 0.3418, 0.3246]}, {"w": "it", "b": [0.3482, 0.3032, 0.3601, 0.3246]}, {"w": "uses", "b": [0.3665, 0.3032, 0.4017, 0.3246]}, {"w": "to", "b": [0.4081, 0.3032, 0.4251, 0.3246]}, {"w": "make", "b": [0.4315, 0.3032, 0.4769, 0.3246]}, {"w": "predictions.", "b": [0.4833, 0.3032, 0.5825, 0.3246]}, {"w": "Instead", "b": [0.5889, 0.3032, 0.6504, 0.3246]}, {"w": "of", "b": [0.6568, 0.3032, 0.6736, 0.3246]}, {"w": "calling", "b": [0.68, 0.3032, 0.7353, 0.3246]}, {"w": "the", "b": [0.7417, 0.3032, 0.768, 0.3246]}, {"w": "classifier’s", "b": [0.7744, 0.3032, 0.8571, 0.3246]}, {"w": "predict()", "b": [0.1429, 0.3264, 0.2319, 0.3414]}, {"w": "method,", "b": [0.2387, 0.3232, 0.3085, 0.3446]}, {"w": "you", "b": [0.3153, 0.3232, 0.3466, 0.3446]}, {"w": "can", "b": [0.3534, 0.3232, 0.3827, 0.3446]}, {"w": "call", "b": [0.3895, 0.3232, 0.418, 0.3446]}, {"w": "its", "b": [0.4249, 0.3232, 0.4444, 0.3446]}, {"w": "decision_function()", "b": [0.4513, 0.3264, 0.6393, 0.3414]}, {"w": "method,", "b": [0.6461, 0.3232, 0.7159, 0.3446]}, {"w": "which", "b": [0.7227, 0.3232, 0.7736, 0.3446]}, {"w": "returns", "b": [0.7804, 0.3232, 0.8412, 0.3446]}, {"w": "a", "b": [0.848, 0.3232, 0.8571, 0.3446]}, {"w": "score", "b": [0.1428, 0.3422, 0.1865, 0.3636]}, {"w": "for", "b": [0.193, 0.3422, 0.2176, 0.3636]}, {"w": "each", "b": [0.2241, 0.3422, 0.262, 0.3636]}, {"w": "instance,", "b": [0.2686, 0.3422, 0.3425, 0.3636]}, {"w": "and", "b": [0.349, 0.3422, 0.3806, 0.3636]}, {"w": "then", "b": [0.3871, 0.3422, 0.4248, 0.3636]}, {"w": "make", "b": [0.4313, 0.3422, 0.4767, 0.3636]}, {"w": "predictions", "b": [0.4833, 0.3422, 0.5778, 0.3636]}, {"w": "based", "b": [0.5843, 0.3422, 0.6315, 0.3636]}, {"w": "on", "b": [0.638, 0.3422, 0.6601, 0.3636]}, {"w": "those", "b": [0.6666, 0.3422, 0.7112, 0.3636]}, {"w": "scores", "b": [0.7177, 0.3422, 0.769, 0.3636]}, {"w": "using", "b": [0.7755, 0.3422, 0.821, 0.3636]}, {"w": "any", "b": [0.8275, 0.3422, 0.8571, 0.3636]}, {"w": "threshold", "b": [0.1429, 0.3613, 0.2226, 0.3827]}, {"w": "you", "b": [0.2273, 0.3613, 0.2586, 0.3827]}, {"w": "want:", "b": [0.2633, 0.3613, 0.3088, 0.3827]}]}, {"id": "b_2", "type": "paragraph", "text": ">>> y_scores = sgd_clf.decision_function([some_digit]) >>> y_scores array([2412.53175101]) >>> threshold = 0 >>> y_some_digit_pred = (y_scores > threshold) array([ True])", "words": [{"w": ">>>", "b": [0.1766, 0.3932, 0.2019, 0.4061]}, {"w": "y_scores", "b": [0.2103, 0.3932, 0.2778, 0.4061]}, {"w": "=", "b": [0.2862, 0.3932, 0.2946, 0.4061]}, {"w": "sgd_clf.decision_function([some_digit])", "b": [0.3031, 0.3932, 0.6319, 0.4061]}, {"w": ">>>", "b": [0.1766, 0.4087, 0.2019, 0.4215]}, {"w": "y_scores", "b": [0.2103, 0.4087, 0.2778, 0.4215]}, {"w": "array([2412.53175101])", "b": [0.1766, 0.4241, 0.3621, 0.4369]}, {"w": ">>>", "b": [0.1766, 0.4395, 0.2019, 0.4524]}, {"w": "threshold", "b": [0.2103, 0.4395, 0.2862, 0.4524]}, {"w": "=", "b": [0.2946, 0.4395, 0.3031, 0.4524]}, {"w": "0", "b": [0.3115, 0.4395, 0.3199, 0.4524]}, {"w": ">>>", "b": [0.1766, 0.4549, 0.2019, 0.4678]}, {"w": "y_some_digit_pred", "b": [0.2103, 0.4549, 0.3537, 0.4678]}, {"w": "=", "b": [0.3621, 0.4549, 0.3705, 0.4678]}, {"w": "(y_scores", "b": [0.379, 0.4549, 0.4549, 0.4678]}, {"w": ">", "b": [0.4633, 0.4549, 0.4717, 0.4678]}, {"w": "threshold)", "b": [0.4802, 0.4549, 0.5645, 0.4678]}, {"w": "array([", "b": [0.1766, 0.4703, 0.2356, 0.4832]}, {"w": "True])", "b": [0.244, 0.4703, 0.2946, 0.4832]}]}, {"id": "b_3", "type": "paragraph", "text": "The SGDClassifier uses a threshold equal to 0, so the previous code returns the same result as the predict() method (i.e., True). Let’s raise the threshold:", "words": [{"w": "The", "b": [0.1428, 0.4919, 0.1757, 0.5133]}, {"w": "SGDClassifier", "b": [0.1804, 0.4951, 0.3091, 0.5101]}, {"w": "uses", "b": [0.3138, 0.4919, 0.349, 0.5133]}, {"w": "a", "b": [0.3537, 0.4919, 0.3629, 0.5133]}, {"w": "threshold", "b": [0.3676, 0.4919, 0.4473, 0.5133]}, {"w": "equal", "b": [0.4521, 0.4919, 0.4971, 0.5133]}, {"w": "to", "b": [0.5018, 0.4919, 0.5188, 0.5133]}, {"w": "0,", "b": [0.5235, 0.4919, 0.5382, 0.5133]}, {"w": "so", "b": [0.543, 0.4919, 0.5612, 0.5133]}, {"w": "the", "b": [0.566, 0.4919, 0.5923, 0.5133]}, {"w": "previous", "b": [0.597, 0.4919, 0.6691, 0.5133]}, {"w": "code", "b": [0.6738, 0.4919, 0.7131, 0.5133]}, {"w": "returns", "b": [0.7178, 0.4919, 0.7786, 0.5133]}, {"w": "the", "b": [0.7833, 0.4919, 0.8097, 0.5133]}, {"w": "same", "b": [0.8144, 0.4919, 0.8571, 0.5133]}, {"w": "result", "b": [0.1428, 0.5118, 0.1898, 0.5332]}, {"w": "as", "b": [0.1945, 0.5118, 0.2113, 0.5332]}, {"w": "the", "b": [0.216, 0.5118, 0.2423, 0.5332]}, {"w": "predict()", "b": [0.2471, 0.515, 0.3362, 0.5301]}, {"w": "method", "b": [0.3409, 0.5118, 0.4059, 0.5332]}, {"w": "(i.e.,", "b": [0.4106, 0.5118, 0.4465, 0.5332]}, {"w": "True).", "b": [0.4513, 0.5118, 0.5028, 0.5332]}, {"w": "Let’s", "b": [0.5075, 0.5118, 0.5437, 0.5332]}, {"w": "raise", "b": [0.5484, 0.5118, 0.5874, 0.5332]}, {"w": "the", "b": [0.5921, 0.5118, 0.6185, 0.5332]}, {"w": "threshold:", "b": [0.6232, 0.5118, 0.7077, 0.5332]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> threshold = 8000 >>> y_some_digit_pred = (y_scores > threshold) >>> y_some_digit_pred array([False])", "words": [{"w": ">>>", "b": [0.1766, 0.5438, 0.2019, 0.5566]}, {"w": "threshold", "b": [0.2103, 0.5438, 0.2862, 0.5566]}, {"w": "=", "b": [0.2946, 0.5438, 0.3031, 0.5566]}, {"w": "8000", "b": [0.3115, 0.5438, 0.3452, 0.5566]}, {"w": ">>>", "b": [0.1766, 0.5592, 0.2019, 0.5721]}, {"w": "y_some_digit_pred", "b": [0.2103, 0.5592, 0.3537, 0.5721]}, {"w": "=", "b": [0.3621, 0.5592, 0.3705, 0.5721]}, {"w": "(y_scores", "b": [0.379, 0.5592, 0.4549, 0.5721]}, {"w": ">", "b": [0.4633, 0.5592, 0.4717, 0.5721]}, {"w": "threshold)", "b": [0.4802, 0.5592, 0.5645, 0.5721]}, {"w": ">>>", "b": [0.1766, 0.5746, 0.2019, 0.5875]}, {"w": "y_some_digit_pred", "b": [0.2103, 0.5746, 0.3537, 0.5875]}, {"w": "array([False])", "b": [0.1766, 0.5901, 0.2946, 0.6029]}]}, {"id": "b_5", "type": "paragraph", "text": "This confirms that raising the threshold decreases recall. The image actually repre‐ sents a 5, and the classifier detects it when the threshold is 0, but it misses it when the threshold is increased to 8,000.", "words": [{"w": "This", "b": [0.1429, 0.6107, 0.1801, 0.6321]}, {"w": "confirms", "b": [0.1872, 0.6107, 0.2623, 0.6321]}, {"w": "that", "b": [0.2694, 0.6107, 0.302, 0.6321]}, {"w": "raising", "b": [0.3092, 0.6107, 0.366, 0.6321]}, {"w": "the", "b": [0.3732, 0.6107, 0.3995, 0.6321]}, {"w": "threshold", "b": [0.4067, 0.6107, 0.4864, 0.6321]}, {"w": "decreases", "b": [0.4936, 0.6107, 0.5721, 0.6321]}, {"w": "recall.", "b": [0.5793, 0.6107, 0.6291, 0.6321]}, {"w": "The", "b": [0.6363, 0.6107, 0.6691, 0.6321]}, {"w": "image", "b": [0.6763, 0.6107, 0.7267, 0.6321]}, {"w": "actually", "b": [0.7339, 0.6107, 0.7985, 0.6321]}, {"w": "repre‐", "b": [0.8056, 0.6107, 0.8571, 0.6321]}, {"w": "sents", "b": [0.1429, 0.6297, 0.1844, 0.6511]}, {"w": "a", "b": [0.1894, 0.6297, 0.1985, 0.6511]}, {"w": "5,", "b": [0.2036, 0.6297, 0.2183, 0.6511]}, {"w": "and", "b": [0.2234, 0.6297, 0.2549, 0.6511]}, {"w": "the", "b": [0.26, 0.6297, 0.2863, 0.6511]}, {"w": "classifier", "b": [0.2913, 0.6297, 0.3638, 0.6511]}, {"w": "detects", "b": [0.3688, 0.6297, 0.4267, 0.6511]}, {"w": "it", "b": [0.4317, 0.6297, 0.4437, 0.6511]}, {"w": "when", "b": [0.4487, 0.6297, 0.4944, 0.6511]}, {"w": "the", "b": [0.4994, 0.6297, 0.5257, 0.6511]}, {"w": "threshold", "b": [0.5308, 0.6297, 0.6105, 0.6511]}, {"w": "is", "b": [0.6156, 0.6297, 0.6288, 0.6511]}, {"w": "0,", "b": [0.6338, 0.6297, 0.6486, 0.6511]}, {"w": "but", "b": [0.6536, 0.6297, 0.6816, 0.6511]}, {"w": "it", "b": [0.6867, 0.6297, 0.6986, 0.6511]}, {"w": "misses", "b": [0.7037, 0.6297, 0.7581, 0.6511]}, {"w": "it", "b": [0.7631, 0.6297, 0.7751, 0.6511]}, {"w": "when", "b": [0.7801, 0.6297, 0.8258, 0.6511]}, {"w": "the", "b": [0.8308, 0.6297, 0.8571, 0.6511]}, {"w": "threshold", "b": [0.1429, 0.6488, 0.2226, 0.6702]}, {"w": "is", "b": [0.2273, 0.6488, 0.2406, 0.6702]}, {"w": "increased", "b": [0.2453, 0.6488, 0.3243, 0.6702]}, {"w": "to", "b": [0.329, 0.6488, 0.346, 0.6702]}, {"w": "8,000.", "b": [0.3507, 0.6488, 0.4002, 0.6702]}]}, {"id": "b_6", "type": "paragraph", "text": "Now how do you decide which threshold to use? For this you will first need to get the scores of all instances in the training set using the cross_val_predict() function again, but this time specifying that you want it to return decision scores instead of predictions:", "words": [{"w": "Now", "b": [0.1429, 0.6769, 0.1827, 0.6983]}, {"w": "how", "b": [0.1877, 0.6769, 0.2238, 0.6983]}, {"w": "do", "b": [0.2288, 0.6769, 0.2504, 0.6983]}, {"w": "you", "b": [0.2554, 0.6769, 0.2866, 0.6983]}, {"w": "decide", "b": [0.2917, 0.6769, 0.3458, 0.6983]}, {"w": "which", "b": [0.3508, 0.6769, 0.4017, 0.6983]}, {"w": "threshold", "b": [0.4067, 0.6769, 0.4864, 0.6983]}, {"w": "to", "b": [0.4914, 0.6769, 0.5084, 0.6983]}, {"w": "use?", "b": [0.5134, 0.6769, 0.5489, 0.6983]}, {"w": "For", "b": [0.5539, 0.6769, 0.5829, 0.6983]}, {"w": "this", "b": [0.5879, 0.6769, 0.6186, 0.6983]}, {"w": "you", "b": [0.6236, 0.6769, 0.6548, 0.6983]}, {"w": "will", "b": [0.6599, 0.6769, 0.6903, 0.6983]}, {"w": "first", "b": [0.6953, 0.6769, 0.7287, 0.6983]}, {"w": "need", "b": [0.7337, 0.6769, 0.7739, 0.6983]}, {"w": "to", "b": [0.7789, 0.6769, 0.7958, 0.6983]}, {"w": "get", "b": [0.8009, 0.6769, 0.8258, 0.6983]}, {"w": "the", "b": [0.8308, 0.6769, 0.8572, 0.6983]}, {"w": "scores", "b": [0.1429, 0.6968, 0.1942, 0.7183]}, {"w": "of", "b": [0.2019, 0.6968, 0.2187, 0.7183]}, {"w": "all", "b": [0.2265, 0.6968, 0.2462, 0.7183]}, {"w": "instances", "b": [0.2539, 0.6968, 0.3308, 0.7183]}, {"w": "in", "b": [0.3385, 0.6968, 0.3555, 0.7183]}, {"w": "the", "b": [0.3633, 0.6968, 0.3896, 0.7183]}, {"w": "training", "b": [0.3974, 0.6968, 0.4643, 0.7183]}, {"w": "set", "b": [0.4721, 0.6968, 0.4949, 0.7183]}, {"w": "using", "b": [0.5027, 0.6968, 0.5481, 0.7183]}, {"w": "the", "b": [0.5559, 0.6968, 0.5822, 0.7183]}, {"w": "cross_val_predict()", "b": [0.59, 0.7, 0.778, 0.7151]}, {"w": "function", "b": [0.7858, 0.6968, 0.8571, 0.7183]}, {"w": "again,", "b": [0.1429, 0.7159, 0.1926, 0.7373]}, {"w": "but", "b": [0.1997, 0.7159, 0.2277, 0.7373]}, {"w": "this", "b": [0.2348, 0.7159, 0.2655, 0.7373]}, {"w": "time", "b": [0.2726, 0.7159, 0.3104, 0.7373]}, {"w": "specifying", "b": [0.3175, 0.7159, 0.4021, 0.7373]}, {"w": "that", "b": [0.4092, 0.7159, 0.4418, 0.7373]}, {"w": "you", "b": [0.4489, 0.7159, 0.4801, 0.7373]}, {"w": "want", "b": [0.4872, 0.7159, 0.528, 0.7373]}, {"w": "it", "b": [0.535, 0.7159, 0.547, 0.7373]}, {"w": "to", "b": [0.5541, 0.7159, 0.571, 0.7373]}, {"w": "return", "b": [0.5781, 0.7159, 0.6312, 0.7373]}, {"w": "decision", "b": [0.6383, 0.7159, 0.7078, 0.7373]}, {"w": "scores", "b": [0.7149, 0.7159, 0.7662, 0.7373]}, {"w": "instead", "b": [0.7733, 0.7159, 0.8333, 0.7373]}, {"w": "of", "b": [0.8404, 0.7159, 0.8571, 0.7373]}, {"w": "predictions:", "b": [0.1429, 0.7349, 0.2421, 0.7564]}]}, {"id": "b_7", "type": "paragraph", "text": "y_scores = cross_val_predict(sgd_clf, X_train, y_train_5, cv=3, method=\"decision_function\")", "words": [{"w": "y_scores", "b": [0.1766, 0.7669, 0.2441, 0.7798]}, {"w": "=", "b": [0.2525, 0.7669, 0.2609, 0.7798]}, {"w": "cross_val_predict(sgd_clf,", "b": [0.2694, 0.7669, 0.4886, 0.7798]}, {"w": "X_train,", "b": [0.497, 0.7669, 0.5645, 0.7798]}, {"w": "y_train_5,", "b": [0.5729, 0.7669, 0.6573, 0.7798]}, {"w": "cv=3,", "b": [0.6657, 0.7669, 0.7078, 0.7798]}, {"w": "method=\"decision_function\")", "b": [0.4211, 0.7823, 0.6488, 0.7952]}]}, {"id": "b_8", "type": "paragraph", "text": "Now with these scores you can compute precision and recall for all possible thresh‐ olds using the precision_recall_curve() function:", "words": [{"w": "Now", "b": [0.1429, 0.803, 0.1827, 0.8244]}, {"w": "with", "b": [0.1892, 0.803, 0.2265, 0.8244]}, {"w": "these", "b": [0.2329, 0.803, 0.2758, 0.8244]}, {"w": "scores", "b": [0.2822, 0.803, 0.3335, 0.8244]}, {"w": "you", "b": [0.3399, 0.803, 0.3712, 0.8244]}, {"w": "can", "b": [0.3776, 0.803, 0.407, 0.8244]}, {"w": "compute", "b": [0.4134, 0.803, 0.4867, 0.8244]}, {"w": "precision", "b": [0.4932, 0.803, 0.5703, 0.8244]}, {"w": "and", "b": [0.5767, 0.803, 0.6083, 0.8244]}, {"w": "recall", "b": [0.6147, 0.803, 0.6598, 0.8244]}, {"w": "for", "b": [0.6662, 0.803, 0.6908, 0.8244]}, {"w": "all", "b": [0.6972, 0.803, 0.7169, 0.8244]}, {"w": "possible", "b": [0.7233, 0.803, 0.7905, 0.8244]}, {"w": "thresh‐", "b": [0.7969, 0.803, 0.8571, 0.8244]}, {"w": "olds", "b": [0.1429, 0.8229, 0.1774, 0.8443]}, {"w": "using", "b": [0.1821, 0.8229, 0.2276, 0.8443]}, {"w": "the", "b": [0.2323, 0.8229, 0.2586, 0.8443]}, {"w": "precision_recall_curve()", "b": [0.2634, 0.8261, 0.5009, 0.8412]}, {"w": "function:", "b": [0.5056, 0.8229, 0.5817, 0.8443]}]}, {"id": "b_9", "type": "paragraph", "text": "96 | Chapter 3: Classification", "words": [{"w": "96", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "3:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "Classification", "b": [0.26, 0.9225, 0.337, 0.9388]}]}]}, {"page": 123, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "from sklearn.metrics import precision_recall_curve", "words": [{"w": "from", "b": [0.1766, 0.0829, 0.2103, 0.0958]}, {"w": "sklearn.metrics", "b": [0.2188, 0.0829, 0.3452, 0.0958]}, {"w": "import", "b": [0.3537, 0.0829, 0.4043, 0.0958]}, {"w": "precision_recall_curve", "b": [0.4127, 0.0829, 0.5982, 0.0958]}]}, {"id": "b_1", "type": "equation", "text": "precisions, recalls, thresholds = precision_recall_curve(y_train_5, y_scores)", "words": [{"w": "precisions,", "b": [0.1766, 0.1138, 0.2693, 0.1266]}, {"w": "recalls,", "b": [0.2778, 0.1138, 0.3452, 0.1266]}, {"w": "thresholds", "b": [0.3537, 0.1138, 0.438, 0.1266]}, {"w": "=", "b": [0.4464, 0.1138, 0.4549, 0.1266]}, {"w": "precision_recall_curve(y_train_5,", "b": [0.4633, 0.1138, 0.7416, 0.1266]}, {"w": "y_scores)", "b": [0.75, 0.1138, 0.8259, 0.1266]}]}, {"id": "b_2", "type": "paragraph", "text": "Finally, you can plot precision and recall as functions of the threshold value using Matplotlib (Figure 3-4):", "words": [{"w": "Finally,", "b": [0.1429, 0.1344, 0.2033, 0.1558]}, {"w": "you", "b": [0.2109, 0.1344, 0.2421, 0.1558]}, {"w": "can", "b": [0.2497, 0.1344, 0.279, 0.1558]}, {"w": "plot", "b": [0.2866, 0.1344, 0.3198, 0.1558]}, {"w": "precision", "b": [0.3273, 0.1344, 0.4045, 0.1558]}, {"w": "and", "b": [0.412, 0.1344, 0.4435, 0.1558]}, {"w": "recall", "b": [0.4511, 0.1344, 0.4962, 0.1558]}, {"w": "as", "b": [0.5037, 0.1344, 0.5205, 0.1558]}, {"w": "functions", "b": [0.5281, 0.1344, 0.6071, 0.1558]}, {"w": "of", "b": [0.6147, 0.1344, 0.6315, 0.1558]}, {"w": "the", "b": [0.639, 0.1344, 0.6653, 0.1558]}, {"w": "threshold", "b": [0.6729, 0.1344, 0.7526, 0.1558]}, {"w": "value", "b": [0.7602, 0.1344, 0.8041, 0.1558]}, {"w": "using", "b": [0.8117, 0.1344, 0.8571, 0.1558]}, {"w": "Matplotlib", "b": [0.1429, 0.1534, 0.2308, 0.1749]}, {"w": "(Figure", "b": [0.2355, 0.1534, 0.2967, 0.1749]}, {"w": "3-4):", "b": [0.3014, 0.1534, 0.3408, 0.1749]}]}, {"id": "b_3", "type": "paragraph", "text": "def plot_precision_recall_vs_threshold(precisions, recalls, thresholds): plt.plot(thresholds, precisions[:-1], \"b--\", label=\"Precision\") plt.plot(thresholds, recalls[:-1], \"g-\", label=\"Recall\") [...] # highlight the threshold, add the legend, axis label and grid", "words": [{"w": "def", "b": [0.1766, 0.1854, 0.2019, 0.1983]}, {"w": "plot_precision_recall_vs_threshold(precisions,", "b": [0.2103, 0.1854, 0.5982, 0.1983]}, {"w": "recalls,", "b": [0.6067, 0.1854, 0.6741, 0.1983]}, {"w": "thresholds):", "b": [0.6825, 0.1854, 0.7837, 0.1983]}, {"w": "plt.plot(thresholds,", "b": [0.2103, 0.2008, 0.379, 0.2137]}, {"w": "precisions[:-1],", "b": [0.3874, 0.2008, 0.5223, 0.2137]}, {"w": "\"b--\",", "b": [0.5308, 0.2008, 0.5814, 0.2137]}, {"w": "label=\"Precision\")", "b": [0.5898, 0.2008, 0.7416, 0.2137]}, {"w": "plt.plot(thresholds,", "b": [0.2103, 0.2163, 0.379, 0.2291]}, {"w": "recalls[:-1],", "b": [0.3874, 0.2163, 0.497, 0.2291]}, {"w": "\"g-\",", "b": [0.5055, 0.2163, 0.5476, 0.2291]}, {"w": "label=\"Recall\")", "b": [0.5561, 0.2163, 0.6825, 0.2291]}, {"w": "[...]", "b": [0.2103, 0.2317, 0.2525, 0.2445]}, {"w": "#", "b": [0.2609, 0.2317, 0.2694, 0.2445]}, {"w": "highlight", "b": [0.2778, 0.2317, 0.3537, 0.2445]}, {"w": "the", "b": [0.3621, 0.2317, 0.3874, 0.2445]}, {"w": "threshold,", "b": [0.3958, 0.2317, 0.4802, 0.2445]}, {"w": "add", "b": [0.4886, 0.2317, 0.5139, 0.2445]}, {"w": "the", "b": [0.5223, 0.2317, 0.5476, 0.2445]}, {"w": "legend,", "b": [0.5561, 0.2317, 0.6151, 0.2445]}, {"w": "axis", "b": [0.6235, 0.2317, 0.6572, 0.2445]}, {"w": "label", "b": [0.6657, 0.2317, 0.7078, 0.2445]}, {"w": "and", "b": [0.7163, 0.2317, 0.7416, 0.2445]}, {"w": "grid", "b": [0.75, 0.2317, 0.7837, 0.2445]}]}, {"id": "b_4", "type": "equation", "text": "plot_precision_recall_vs_threshold(precisions, recalls, thresholds) plt.show()", "words": [{"w": "plot_precision_recall_vs_threshold(precisions,", "b": [0.1766, 0.2625, 0.5645, 0.2754]}, {"w": "recalls,", "b": [0.5729, 0.2625, 0.6404, 0.2754]}, {"w": "thresholds)", "b": [0.6488, 0.2625, 0.7416, 0.2754]}, {"w": "plt.show()", "b": [0.1766, 0.2779, 0.2609, 0.2908]}]}, {"id": "b_5", "type": "equation", "text": "Figure 3-4. Precision and recall versus the decision threshold", "words": [{"w": "Figure", "b": [0.1429, 0.5694, 0.1943, 0.591]}, {"w": "3-4.", "b": [0.1991, 0.5694, 0.2308, 0.591]}, {"w": "Precision", "b": [0.2356, 0.5694, 0.3093, 0.591]}, {"w": "and", "b": [0.3141, 0.5694, 0.3455, 0.591]}, {"w": "recall", "b": [0.3502, 0.5694, 0.3937, 0.591]}, {"w": "versus", "b": [0.3985, 0.5694, 0.4486, 0.591]}, {"w": "the", "b": [0.4534, 0.5694, 0.4784, 0.591]}, {"w": "decision", "b": [0.4832, 0.5694, 0.5487, 0.591]}, {"w": "threshold", "b": [0.5535, 0.5694, 0.6279, 0.591]}]}, {"id": "b_6", "type": "paragraph", "text": "You may wonder why the precision curve is bumpier than the recall curve in Figure 3-4. The reason is that precision may sometimes go down when you raise the threshold (although in general it will go up). To understand why, look back at Figure 3-3 and notice what happens when you start from the central threshold and move it just one digit to the right: precision goes from 4/5 (80%) down to 3/4 (75%). On the other hand, recall can only go down when the thres‐ hold is increased, which explains why its curve looks smooth.", "words": [{"w": "You", "b": [0.2714, 0.6115, 0.301, 0.6311]}, {"w": "may", "b": [0.3053, 0.6115, 0.3377, 0.6311]}, {"w": "wonder", "b": [0.342, 0.6115, 0.4004, 0.6311]}, {"w": "why", "b": [0.4047, 0.6115, 0.4362, 0.6311]}, {"w": "the", "b": [0.4406, 0.6115, 0.4646, 0.6311]}, {"w": "precision", "b": [0.469, 0.6115, 0.5395, 0.6311]}, {"w": "curve", "b": [0.5438, 0.6115, 0.5865, 0.6311]}, {"w": "is", "b": [0.5909, 0.6115, 0.6029, 0.6311]}, {"w": "bumpier", "b": [0.6073, 0.6115, 0.6725, 0.6311]}, {"w": "than", "b": [0.6769, 0.6115, 0.7116, 0.6311]}, {"w": "the", "b": [0.716, 0.6115, 0.74, 0.6311]}, {"w": "recall", "b": [0.7444, 0.6115, 0.7856, 0.6311]}, {"w": "curve", "b": [0.2714, 0.6289, 0.3141, 0.6485]}, {"w": "in", "b": [0.3188, 0.6289, 0.3343, 0.6485]}, {"w": "Figure", "b": [0.3389, 0.6289, 0.3883, 0.6485]}, {"w": "3-4.", "b": [0.3926, 0.6289, 0.4224, 0.6485]}, {"w": "The", "b": [0.427, 0.6289, 0.4571, 0.6485]}, {"w": "reason", "b": [0.4617, 0.6289, 0.5124, 0.6485]}, {"w": "is", "b": [0.517, 0.6289, 0.5291, 0.6485]}, {"w": "that", "b": [0.5338, 0.6289, 0.5636, 0.6485]}, {"w": "precision", "b": [0.5682, 0.6289, 0.6388, 0.6485]}, {"w": "may", "b": [0.6434, 0.6289, 0.6758, 0.6485]}, {"w": "sometimes", "b": [0.6804, 0.6289, 0.7624, 0.6485]}, {"w": "go", "b": [0.7671, 0.6289, 0.7857, 0.6485]}, {"w": "down", "b": [0.2714, 0.6463, 0.3147, 0.6659]}, {"w": "when", "b": [0.3206, 0.6463, 0.3623, 0.6659]}, {"w": "you", "b": [0.3682, 0.6463, 0.3968, 0.6659]}, {"w": "raise", "b": [0.4027, 0.6463, 0.4383, 0.6659]}, {"w": "the", "b": [0.4442, 0.6463, 0.4682, 0.6659]}, {"w": "threshold", "b": [0.4741, 0.6463, 0.547, 0.6659]}, {"w": "(although", "b": [0.5529, 0.6463, 0.6276, 0.6659]}, {"w": "in", "b": [0.6335, 0.6463, 0.649, 0.6659]}, {"w": "general", "b": [0.6549, 0.6463, 0.7107, 0.6659]}, {"w": "it", "b": [0.7166, 0.6463, 0.7275, 0.6659]}, {"w": "will", "b": [0.7334, 0.6463, 0.7612, 0.6659]}, {"w": "go", "b": [0.7671, 0.6463, 0.7857, 0.6659]}, {"w": "up).", "b": [0.2714, 0.6638, 0.3024, 0.6833]}, {"w": "To", "b": [0.3089, 0.6638, 0.3285, 0.6833]}, {"w": "understand", "b": [0.335, 0.6638, 0.4224, 0.6833]}, {"w": "why,", "b": [0.4289, 0.6638, 0.4633, 0.6833]}, {"w": "look", "b": [0.4698, 0.6638, 0.5035, 0.6833]}, {"w": "back", "b": [0.51, 0.6638, 0.5455, 0.6833]}, {"w": "at", "b": [0.552, 0.6638, 0.5658, 0.6833]}, {"w": "Figure", "b": [0.5723, 0.6638, 0.6217, 0.6833]}, {"w": "3-3", "b": [0.6282, 0.6638, 0.6532, 0.6833]}, {"w": "and", "b": [0.6597, 0.6638, 0.6885, 0.6833]}, {"w": "notice", "b": [0.695, 0.6638, 0.7422, 0.6833]}, {"w": "what", "b": [0.7487, 0.6638, 0.7857, 0.6833]}, {"w": "happens", "b": [0.2714, 0.6812, 0.3351, 0.7008]}, {"w": "when", "b": [0.3395, 0.6812, 0.3813, 0.7008]}, {"w": "you", "b": [0.3858, 0.6812, 0.4143, 0.7008]}, {"w": "start", "b": [0.4188, 0.6812, 0.4528, 0.7008]}, {"w": "from", "b": [0.4573, 0.6812, 0.4953, 0.7008]}, {"w": "the", "b": [0.4998, 0.6812, 0.5239, 0.7008]}, {"w": "central", "b": [0.5284, 0.6812, 0.5806, 0.7008]}, {"w": "threshold", "b": [0.5851, 0.6812, 0.658, 0.7008]}, {"w": "and", "b": [0.6625, 0.6812, 0.6913, 0.7008]}, {"w": "move", "b": [0.6958, 0.6812, 0.7381, 0.7008]}, {"w": "it", "b": [0.7425, 0.6812, 0.7535, 0.7008]}, {"w": "just", "b": [0.7579, 0.6812, 0.7857, 0.7008]}, {"w": "one", "b": [0.2714, 0.6986, 0.2996, 0.7182]}, {"w": "digit", "b": [0.3058, 0.6986, 0.3408, 0.7182]}, {"w": "to", "b": [0.347, 0.6986, 0.3626, 0.7182]}, {"w": "the", "b": [0.3688, 0.6986, 0.3928, 0.7182]}, {"w": "right:", "b": [0.399, 0.6986, 0.4401, 0.7182]}, {"w": "precision", "b": [0.4463, 0.6986, 0.5168, 0.7182]}, {"w": "goes", "b": [0.523, 0.6986, 0.5567, 0.7182]}, {"w": "from", "b": [0.5629, 0.6986, 0.6009, 0.7182]}, {"w": "4/5", "b": [0.6071, 0.6986, 0.6317, 0.7182]}, {"w": "(80%)", "b": [0.6379, 0.6986, 0.6838, 0.7182]}, {"w": "down", "b": [0.69, 0.6986, 0.7332, 0.7182]}, {"w": "to", "b": [0.7394, 0.6986, 0.7549, 0.7182]}, {"w": "3/4", "b": [0.7611, 0.6986, 0.7857, 0.7182]}, {"w": "(75%).", "b": [0.2714, 0.716, 0.3216, 0.7356]}, {"w": "On", "b": [0.3264, 0.716, 0.351, 0.7356]}, {"w": "the", "b": [0.3557, 0.716, 0.3798, 0.7356]}, {"w": "other", "b": [0.3846, 0.716, 0.4254, 0.7356]}, {"w": "hand,", "b": [0.4301, 0.716, 0.4735, 0.7356]}, {"w": "recall", "b": [0.4782, 0.716, 0.5195, 0.7356]}, {"w": "can", "b": [0.5242, 0.716, 0.551, 0.7356]}, {"w": "only", "b": [0.5558, 0.716, 0.5895, 0.7356]}, {"w": "go", "b": [0.5942, 0.716, 0.6128, 0.7356]}, {"w": "down", "b": [0.6176, 0.716, 0.6608, 0.7356]}, {"w": "when", "b": [0.6655, 0.716, 0.7073, 0.7356]}, {"w": "the", "b": [0.712, 0.716, 0.7361, 0.7356]}, {"w": "thres‐", "b": [0.7408, 0.716, 0.7857, 0.7356]}, {"w": "hold", "b": [0.2714, 0.7334, 0.3062, 0.753]}, {"w": "is", "b": [0.3105, 0.7334, 0.3226, 0.753]}, {"w": "increased,", "b": [0.3269, 0.7334, 0.4035, 0.753]}, {"w": "which", "b": [0.4078, 0.7334, 0.4544, 0.753]}, {"w": "explains", "b": [0.4587, 0.7334, 0.5215, 0.753]}, {"w": "why", "b": [0.5258, 0.7334, 0.5573, 0.753]}, {"w": "its", "b": [0.5616, 0.7334, 0.5796, 0.753]}, {"w": "curve", "b": [0.5839, 0.7334, 0.6266, 0.753]}, {"w": "looks", "b": [0.6309, 0.7334, 0.6716, 0.753]}, {"w": "smooth.", "b": [0.6759, 0.7334, 0.7383, 0.753]}]}, {"id": "b_7", "type": "paragraph", "text": "Another way to select a good precision/recall tradeoff is to plot precision directly against recall, as shown in Figure 3-5 (the same threshold as earlier is highlighed).", "words": [{"w": "Another", "b": [0.1429, 0.7733, 0.2133, 0.7947]}, {"w": "way", "b": [0.2215, 0.7733, 0.2541, 0.7947]}, {"w": "to", "b": [0.2623, 0.7733, 0.2793, 0.7947]}, {"w": "select", "b": [0.2875, 0.7733, 0.3333, 0.7947]}, {"w": "a", "b": [0.3415, 0.7733, 0.3507, 0.7947]}, {"w": "good", "b": [0.3589, 0.7733, 0.4009, 0.7947]}, {"w": "precision/recall", "b": [0.4091, 0.7733, 0.5382, 0.7947]}, {"w": "tradeoff", "b": [0.5464, 0.7733, 0.6124, 0.7947]}, {"w": "is", "b": [0.6206, 0.7733, 0.6339, 0.7947]}, {"w": "to", "b": [0.6421, 0.7733, 0.6591, 0.7947]}, {"w": "plot", "b": [0.6673, 0.7733, 0.7004, 0.7947]}, {"w": "precision", "b": [0.7086, 0.7733, 0.7858, 0.7947]}, {"w": "directly", "b": [0.794, 0.7733, 0.8571, 0.7947]}, {"w": "against", "b": [0.1429, 0.7923, 0.2019, 0.8138]}, {"w": "recall,", "b": [0.2066, 0.7923, 0.2564, 0.8138]}, {"w": "as", "b": [0.2612, 0.7923, 0.278, 0.8138]}, {"w": "shown", "b": [0.2827, 0.7923, 0.3378, 0.8138]}, {"w": "in", "b": [0.3425, 0.7923, 0.3595, 0.8138]}, {"w": "Figure", "b": [0.3642, 0.7923, 0.4182, 0.8138]}, {"w": "3-5", "b": [0.4229, 0.7923, 0.4503, 0.8138]}, {"w": "(the", "b": [0.4551, 0.7923, 0.4886, 0.8138]}, {"w": "same", "b": [0.4933, 0.7923, 0.536, 0.8138]}, {"w": "threshold", "b": [0.5408, 0.7923, 0.6205, 0.8138]}, {"w": "as", "b": [0.6252, 0.7923, 0.642, 0.8138]}, {"w": "earlier", "b": [0.6468, 0.7923, 0.6999, 0.8138]}, {"w": "is", "b": [0.7046, 0.7923, 0.7179, 0.8138]}, {"w": "highlighed).", "b": [0.7226, 0.7923, 0.8237, 0.8138]}]}, {"id": "b_8", "type": "paragraph", "text": "Performance Measures | 97", "words": [{"w": "Performance", "b": [0.669, 0.9225, 0.7446, 0.9388]}, {"w": "Measures", "b": [0.7474, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "97", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 124, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 3-5. Precision versus recall", "words": [{"w": "Figure", "b": [0.1429, 0.381, 0.1943, 0.4027]}, {"w": "3-5.", "b": [0.1991, 0.381, 0.2308, 0.4027]}, {"w": "Precision", "b": [0.2356, 0.381, 0.3093, 0.4027]}, {"w": "versus", "b": [0.3141, 0.381, 0.3642, 0.4027]}, {"w": "recall", "b": [0.369, 0.381, 0.4125, 0.4027]}]}, {"id": "b_1", "type": "paragraph", "text": "You can see that precision really starts to fall sharply around 80% recall. You will probably want to select a precision/recall tradeoff just before that drop—for example, at around 60% recall. But of course the choice depends on your project.", "words": [{"w": "You", "b": [0.1429, 0.4184, 0.1752, 0.4398]}, {"w": "can", "b": [0.1833, 0.4184, 0.2127, 0.4398]}, {"w": "see", "b": [0.2207, 0.4184, 0.2461, 0.4398]}, {"w": "that", "b": [0.2542, 0.4184, 0.2868, 0.4398]}, {"w": "precision", "b": [0.2949, 0.4184, 0.372, 0.4398]}, {"w": "really", "b": [0.3801, 0.4184, 0.4259, 0.4398]}, {"w": "starts", "b": [0.434, 0.4184, 0.4789, 0.4398]}, {"w": "to", "b": [0.487, 0.4184, 0.504, 0.4398]}, {"w": "fall", "b": [0.5121, 0.4184, 0.5379, 0.4398]}, {"w": "sharply", "b": [0.546, 0.4184, 0.6074, 0.4398]}, {"w": "around", "b": [0.6155, 0.4184, 0.6764, 0.4398]}, {"w": "80%", "b": [0.6845, 0.4184, 0.7203, 0.4398]}, {"w": "recall.", "b": [0.7284, 0.4184, 0.7782, 0.4398]}, {"w": "You", "b": [0.7863, 0.4184, 0.8187, 0.4398]}, {"w": "will", "b": [0.8267, 0.4184, 0.8571, 0.4398]}, {"w": "probably", "b": [0.1429, 0.4375, 0.2173, 0.4589]}, {"w": "want", "b": [0.2225, 0.4375, 0.2633, 0.4589]}, {"w": "to", "b": [0.2686, 0.4375, 0.2856, 0.4589]}, {"w": "select", "b": [0.2908, 0.4375, 0.3366, 0.4589]}, {"w": "a", "b": [0.3419, 0.4375, 0.351, 0.4589]}, {"w": "precision/recall", "b": [0.3563, 0.4375, 0.4854, 0.4589]}, {"w": "tradeoff", "b": [0.4907, 0.4375, 0.5567, 0.4589]}, {"w": "just", "b": [0.562, 0.4375, 0.5924, 0.4589]}, {"w": "before", "b": [0.5976, 0.4375, 0.6505, 0.4589]}, {"w": "that", "b": [0.6557, 0.4375, 0.6883, 0.4589]}, {"w": "drop—for", "b": [0.6936, 0.4375, 0.7776, 0.4589]}, {"w": "example,", "b": [0.7828, 0.4375, 0.8571, 0.4589]}, {"w": "at", "b": [0.1429, 0.4565, 0.158, 0.4779]}, {"w": "around", "b": [0.1627, 0.4565, 0.2237, 0.4779]}, {"w": "60%", "b": [0.2284, 0.4565, 0.2641, 0.4779]}, {"w": "recall.", "b": [0.2689, 0.4565, 0.3187, 0.4779]}, {"w": "But", "b": [0.3234, 0.4565, 0.3531, 0.4779]}, {"w": "of", "b": [0.3578, 0.4565, 0.3746, 0.4779]}, {"w": "course", "b": [0.3793, 0.4565, 0.4341, 0.4779]}, {"w": "the", "b": [0.4388, 0.4565, 0.4651, 0.4779]}, {"w": "choice", "b": [0.4699, 0.4565, 0.5237, 0.4779]}, {"w": "depends", "b": [0.5284, 0.4565, 0.5981, 0.4779]}, {"w": "on", "b": [0.6028, 0.4565, 0.6248, 0.4779]}, {"w": "your", "b": [0.6296, 0.4565, 0.6685, 0.4779]}, {"w": "project.", "b": [0.6733, 0.4565, 0.7366, 0.4779]}]}, {"id": "b_2", "type": "paragraph", "text": "So let’s suppose you decide to aim for 90% precision. You look up the first plot and find that you need to use a threshold of about 8,000. To be more precise you can search for the lowest threshold that gives you at least 90% precision (np.argmax() will give us the first index of the maximum value, which in this case means the first True value):", "words": [{"w": "So", "b": [0.1429, 0.4846, 0.1634, 0.5061]}, {"w": "let’s", "b": [0.1699, 0.4846, 0.2001, 0.5061]}, {"w": "suppose", "b": [0.2066, 0.4846, 0.2742, 0.5061]}, {"w": "you", "b": [0.2807, 0.4846, 0.312, 0.5061]}, {"w": "decide", "b": [0.3185, 0.4846, 0.3726, 0.5061]}, {"w": "to", "b": [0.3791, 0.4846, 0.3961, 0.5061]}, {"w": "aim", "b": [0.4026, 0.4846, 0.4343, 0.5061]}, {"w": "for", "b": [0.4408, 0.4846, 0.4654, 0.5061]}, {"w": "90%", "b": [0.4719, 0.4846, 0.5076, 0.5061]}, {"w": "precision.", "b": [0.5141, 0.4846, 0.596, 0.5061]}, {"w": "You", "b": [0.6025, 0.4846, 0.6348, 0.5061]}, {"w": "look", "b": [0.6413, 0.4846, 0.6782, 0.5061]}, {"w": "up", "b": [0.6847, 0.4846, 0.7067, 0.5061]}, {"w": "the", "b": [0.7132, 0.4846, 0.7395, 0.5061]}, {"w": "first", "b": [0.746, 0.4846, 0.7795, 0.5061]}, {"w": "plot", "b": [0.786, 0.4846, 0.8191, 0.5061]}, {"w": "and", "b": [0.8256, 0.4846, 0.8572, 0.5061]}, {"w": "find", "b": [0.1429, 0.5037, 0.177, 0.5251]}, {"w": "that", "b": [0.1848, 0.5037, 0.2174, 0.5251]}, {"w": "you", "b": [0.2252, 0.5037, 0.2564, 0.5251]}, {"w": "need", "b": [0.2642, 0.5037, 0.3043, 0.5251]}, {"w": "to", "b": [0.3121, 0.5037, 0.3291, 0.5251]}, {"w": "use", "b": [0.3369, 0.5037, 0.3644, 0.5251]}, {"w": "a", "b": [0.3722, 0.5037, 0.3813, 0.5251]}, {"w": "threshold", "b": [0.3891, 0.5037, 0.4689, 0.5251]}, {"w": "of", "b": [0.4766, 0.5037, 0.4934, 0.5251]}, {"w": "about", "b": [0.5012, 0.5037, 0.549, 0.5251]}, {"w": "8,000.", "b": [0.5568, 0.5037, 0.6063, 0.5251]}, {"w": "To", "b": [0.6141, 0.5037, 0.6355, 0.5251]}, {"w": "be", "b": [0.6433, 0.5037, 0.6627, 0.5251]}, {"w": "more", "b": [0.6705, 0.5037, 0.7148, 0.5251]}, {"w": "precise", "b": [0.7226, 0.5037, 0.781, 0.5251]}, {"w": "you", "b": [0.7888, 0.5037, 0.82, 0.5251]}, {"w": "can", "b": [0.8278, 0.5037, 0.8571, 0.5251]}, {"w": "search", "b": [0.1429, 0.5236, 0.1962, 0.545]}, {"w": "for", "b": [0.2037, 0.5236, 0.2282, 0.545]}, {"w": "the", "b": [0.2358, 0.5236, 0.2621, 0.545]}, {"w": "lowest", "b": [0.2697, 0.5236, 0.3227, 0.545]}, {"w": "threshold", "b": [0.3303, 0.5236, 0.41, 0.545]}, {"w": "that", "b": [0.4176, 0.5236, 0.4502, 0.545]}, {"w": "gives", "b": [0.4577, 0.5236, 0.4992, 0.545]}, {"w": "you", "b": [0.5068, 0.5236, 0.538, 0.545]}, {"w": "at", "b": [0.5456, 0.5236, 0.5607, 0.545]}, {"w": "least", "b": [0.5682, 0.5236, 0.6055, 0.545]}, {"w": "90%", "b": [0.6131, 0.5236, 0.6488, 0.545]}, {"w": "precision", "b": [0.6564, 0.5236, 0.7335, 0.545]}, {"w": "(np.argmax()", "b": [0.7411, 0.5236, 0.8571, 0.545]}, {"w": "will", "b": [0.1428, 0.5427, 0.1732, 0.5641]}, {"w": "give", "b": [0.1795, 0.5427, 0.2133, 0.5641]}, {"w": "us", "b": [0.2195, 0.5427, 0.2382, 0.5641]}, {"w": "the", "b": [0.2445, 0.5427, 0.2708, 0.5641]}, {"w": "first", "b": [0.277, 0.5427, 0.3105, 0.5641]}, {"w": "index", "b": [0.3167, 0.5427, 0.3634, 0.5641]}, {"w": "of", "b": [0.3696, 0.5427, 0.3864, 0.5641]}, {"w": "the", "b": [0.3926, 0.5427, 0.419, 0.5641]}, {"w": "maximum", "b": [0.4252, 0.5427, 0.5116, 0.5641]}, {"w": "value,", "b": [0.5178, 0.5427, 0.5666, 0.5641]}, {"w": "which", "b": [0.5728, 0.5427, 0.6237, 0.5641]}, {"w": "in", "b": [0.6299, 0.5427, 0.6469, 0.5641]}, {"w": "this", "b": [0.6531, 0.5427, 0.6839, 0.5641]}, {"w": "case", "b": [0.6901, 0.5427, 0.7245, 0.5641]}, {"w": "means", "b": [0.7308, 0.5427, 0.7849, 0.5641]}, {"w": "the", "b": [0.7911, 0.5427, 0.8174, 0.5641]}, {"w": "first", "b": [0.8237, 0.5427, 0.8571, 0.5641]}, {"w": "True", "b": [0.1429, 0.5658, 0.1824, 0.5809]}, {"w": "value):", "b": [0.1872, 0.5626, 0.2431, 0.584]}]}, {"id": "b_3", "type": "equation", "text": "threshold_90_precision = thresholds[np.argmax(precisions >= 0.90)] # ~7816", "words": [{"w": "threshold_90_precision", "b": [0.1766, 0.5946, 0.3621, 0.6075]}, {"w": "=", "b": [0.3705, 0.5946, 0.379, 0.6075]}, {"w": "thresholds[np.argmax(precisions", "b": [0.3874, 0.5946, 0.6488, 0.6075]}, {"w": ">=", "b": [0.6572, 0.5946, 0.6741, 0.6075]}, {"w": "0.90)]", "b": [0.6825, 0.5946, 0.7331, 0.6075]}, {"w": "#", "b": [0.7416, 0.5946, 0.75, 0.6075]}, {"w": "~7816", "b": [0.7584, 0.5946, 0.8006, 0.6075]}]}, {"id": "b_4", "type": "paragraph", "text": "To make predictions (on the training set for now), instead of calling the classifier’s predict() method, you can just run this code:", "words": [{"w": "To", "b": [0.1429, 0.6152, 0.1643, 0.6366]}, {"w": "make", "b": [0.1715, 0.6152, 0.2169, 0.6366]}, {"w": "predictions", "b": [0.2241, 0.6152, 0.3186, 0.6366]}, {"w": "(on", "b": [0.3258, 0.6152, 0.3551, 0.6366]}, {"w": "the", "b": [0.3623, 0.6152, 0.3886, 0.6366]}, {"w": "training", "b": [0.3958, 0.6152, 0.4628, 0.6366]}, {"w": "set", "b": [0.47, 0.6152, 0.4928, 0.6366]}, {"w": "for", "b": [0.5, 0.6152, 0.5246, 0.6366]}, {"w": "now),", "b": [0.5318, 0.6152, 0.58, 0.6366]}, {"w": "instead", "b": [0.5872, 0.6152, 0.6472, 0.6366]}, {"w": "of", "b": [0.6544, 0.6152, 0.6712, 0.6366]}, {"w": "calling", "b": [0.6784, 0.6152, 0.7336, 0.6366]}, {"w": "the", "b": [0.7409, 0.6152, 0.7672, 0.6366]}, {"w": "classifier’s", "b": [0.7744, 0.6152, 0.8572, 0.6366]}, {"w": "predict()", "b": [0.1428, 0.6384, 0.2319, 0.6534]}, {"w": "method,", "b": [0.2366, 0.6352, 0.3064, 0.6566]}, {"w": "you", "b": [0.3111, 0.6352, 0.3424, 0.6566]}, {"w": "can", "b": [0.3471, 0.6352, 0.3765, 0.6566]}, {"w": "just", "b": [0.3812, 0.6352, 0.4116, 0.6566]}, {"w": "run", "b": [0.4163, 0.6352, 0.4465, 0.6566]}, {"w": "this", "b": [0.4512, 0.6352, 0.482, 0.6566]}, {"w": "code:", "b": [0.4867, 0.6352, 0.5307, 0.6566]}]}, {"id": "b_5", "type": "equation", "text": "y_train_pred_90 = (y_scores >= threshold_90_precision)", "words": [{"w": "y_train_pred_90", "b": [0.1766, 0.6672, 0.3031, 0.68]}, {"w": "=", "b": [0.3115, 0.6672, 0.3199, 0.68]}, {"w": "(y_scores", "b": [0.3284, 0.6672, 0.4043, 0.68]}, {"w": ">=", "b": [0.4127, 0.6672, 0.4296, 0.68]}, {"w": "threshold_90_precision)", "b": [0.438, 0.6672, 0.6319, 0.68]}]}, {"id": "b_6", "type": "paragraph", "text": "Let’s check these predictions’ precision and recall:", "words": [{"w": "Let’s", "b": [0.1429, 0.6878, 0.179, 0.7092]}, {"w": "check", "b": [0.1838, 0.6878, 0.2317, 0.7092]}, {"w": "these", "b": [0.2364, 0.6878, 0.2793, 0.7092]}, {"w": "predictions’", "b": [0.284, 0.6878, 0.3823, 0.7092]}, {"w": "precision", "b": [0.387, 0.6878, 0.4642, 0.7092]}, {"w": "and", "b": [0.4689, 0.6878, 0.5004, 0.7092]}, {"w": "recall:", "b": [0.5052, 0.6878, 0.555, 0.7092]}]}, {"id": "b_7", "type": "paragraph", "text": ">>> precision_score(y_train_5, y_train_pred_90) 0.9000380083618396 >>> recall_score(y_train_5, y_train_pred_90) 0.4368197749492714", "words": [{"w": ">>>", "b": [0.1766, 0.7198, 0.2019, 0.7326]}, {"w": "precision_score(y_train_5,", "b": [0.2103, 0.7198, 0.4296, 0.7326]}, {"w": "y_train_pred_90)", "b": [0.438, 0.7198, 0.5729, 0.7326]}, {"w": "0.9000380083618396", "b": [0.1766, 0.7352, 0.3284, 0.748]}, {"w": ">>>", "b": [0.1766, 0.7506, 0.2019, 0.7635]}, {"w": "recall_score(y_train_5,", "b": [0.2103, 0.7506, 0.4043, 0.7635]}, {"w": "y_train_pred_90)", "b": [0.4127, 0.7506, 0.5476, 0.7635]}, {"w": "0.4368197749492714", "b": [0.1766, 0.766, 0.3284, 0.7789]}]}, {"id": "b_8", "type": "paragraph", "text": "Great, you have a 90% precision classifier ! As you can see, it is fairly easy to create a classifier with virtually any precision you want: just set a high enough threshold, and you’re done. Hmm, not so fast. A high-precision classifier is not very useful if its recall is too low!", "words": [{"w": "Great,", "b": [0.1429, 0.7867, 0.1942, 0.8081]}, {"w": "you", "b": [0.1998, 0.7867, 0.231, 0.8081]}, {"w": "have", "b": [0.2367, 0.7867, 0.2751, 0.8081]}, {"w": "a", "b": [0.2807, 0.7867, 0.2898, 0.8081]}, {"w": "90%", "b": [0.2954, 0.7867, 0.3312, 0.8081]}, {"w": "precision", "b": [0.3368, 0.7867, 0.4139, 0.8081]}, {"w": "classifier", "b": [0.4195, 0.7867, 0.492, 0.8081]}, {"w": "!", "b": [0.4976, 0.7867, 0.5033, 0.8081]}, {"w": "As", "b": [0.509, 0.7867, 0.531, 0.8081]}, {"w": "you", "b": [0.5366, 0.7867, 0.5679, 0.8081]}, {"w": "can", "b": [0.5735, 0.7867, 0.6028, 0.8081]}, {"w": "see,", "b": [0.6084, 0.7867, 0.6385, 0.8081]}, {"w": "it", "b": [0.6442, 0.7867, 0.6561, 0.8081]}, {"w": "is", "b": [0.6617, 0.7867, 0.6749, 0.8081]}, {"w": "fairly", "b": [0.6805, 0.7867, 0.724, 0.8081]}, {"w": "easy", "b": [0.7296, 0.7867, 0.7648, 0.8081]}, {"w": "to", "b": [0.7704, 0.7867, 0.7874, 0.8081]}, {"w": "create", "b": [0.793, 0.7867, 0.8424, 0.8081]}, {"w": "a", "b": [0.848, 0.7867, 0.8571, 0.8081]}, {"w": "classifier", "b": [0.1428, 0.8057, 0.2153, 0.8271]}, {"w": "with", "b": [0.2209, 0.8057, 0.2582, 0.8271]}, {"w": "virtually", "b": [0.2638, 0.8057, 0.3334, 0.8271]}, {"w": "any", "b": [0.339, 0.8057, 0.3686, 0.8271]}, {"w": "precision", "b": [0.3742, 0.8057, 0.4513, 0.8271]}, {"w": "you", "b": [0.4569, 0.8057, 0.4882, 0.8271]}, {"w": "want:", "b": [0.4937, 0.8057, 0.5393, 0.8271]}, {"w": "just", "b": [0.5448, 0.8057, 0.5752, 0.8271]}, {"w": "set", "b": [0.5808, 0.8057, 0.6037, 0.8271]}, {"w": "a", "b": [0.6093, 0.8057, 0.6184, 0.8271]}, {"w": "high", "b": [0.624, 0.8057, 0.6616, 0.8271]}, {"w": "enough", "b": [0.6671, 0.8057, 0.73, 0.8271]}, {"w": "threshold,", "b": [0.7355, 0.8057, 0.82, 0.8271]}, {"w": "and", "b": [0.8256, 0.8057, 0.8571, 0.8271]}, {"w": "you’re", "b": [0.1429, 0.8247, 0.1937, 0.8462]}, {"w": "done.", "b": [0.2012, 0.8247, 0.2478, 0.8462]}, {"w": "Hmm,", "b": [0.2554, 0.8247, 0.3102, 0.8462]}, {"w": "not", "b": [0.3177, 0.8247, 0.3461, 0.8462]}, {"w": "so", "b": [0.3536, 0.8247, 0.3719, 0.8462]}, {"w": "fast.", "b": [0.3794, 0.8247, 0.4135, 0.8462]}, {"w": "A", "b": [0.421, 0.8247, 0.4354, 0.8462]}, {"w": "high-precision", "b": [0.4429, 0.8247, 0.5651, 0.8462]}, {"w": "classifier", "b": [0.5726, 0.8247, 0.6451, 0.8462]}, {"w": "is", "b": [0.6526, 0.8247, 0.6658, 0.8462]}, {"w": "not", "b": [0.6733, 0.8247, 0.7017, 0.8462]}, {"w": "very", "b": [0.7092, 0.8247, 0.7456, 0.8462]}, {"w": "useful", "b": [0.7532, 0.8247, 0.8032, 0.8462]}, {"w": "if", "b": [0.8108, 0.8247, 0.8225, 0.8462]}, {"w": "its", "b": [0.83, 0.8247, 0.8496, 0.8462]}, {"w": "recall", "b": [0.1429, 0.8438, 0.1879, 0.8652]}, {"w": "is", "b": [0.1927, 0.8438, 0.2059, 0.8652]}, {"w": "too", "b": [0.2106, 0.8438, 0.2382, 0.8652]}, {"w": "low!", "b": [0.243, 0.8438, 0.2789, 0.8652]}]}, {"id": "b_9", "type": "paragraph", "text": "98 | Chapter 3: Classification", "words": [{"w": "98", "b": [0.1429, 0.9225, 0.1574, 0.9388]}, {"w": "|", "b": [0.1753, 0.9225, 0.179, 0.9388]}, {"w": "Chapter", "b": [0.1969, 0.9225, 0.2432, 0.9388]}, {"w": "3:", "b": [0.246, 0.9225, 0.2572, 0.9388]}, {"w": "Classification", "b": [0.26, 0.9225, 0.337, 0.9388]}]}]}, {"page": 125, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "If someone says “let’s reach 99% precision,” you should ask, “at what recall?”", "words": [{"w": "If", "b": [0.2714, 0.0793, 0.2835, 0.0989]}, {"w": "someone", "b": [0.2919, 0.0793, 0.3605, 0.0989]}, {"w": "says", "b": [0.3689, 0.0793, 0.3996, 0.0989]}, {"w": "“let’s", "b": [0.408, 0.0793, 0.4432, 0.0989]}, {"w": "reach", "b": [0.4515, 0.0793, 0.4933, 0.0989]}, {"w": "99%", "b": [0.5016, 0.0793, 0.5343, 0.0989]}, {"w": "precision,”", "b": [0.5427, 0.0793, 0.6226, 0.0989]}, {"w": "you", "b": [0.6309, 0.0793, 0.6595, 0.0989]}, {"w": "should", "b": [0.6678, 0.0793, 0.7197, 0.0989]}, {"w": "ask,", "b": [0.7281, 0.0793, 0.7572, 0.0989]}, {"w": "“at", "b": [0.7656, 0.0793, 0.7857, 0.0989]}, {"w": "what", "b": [0.2714, 0.0967, 0.3084, 0.1163]}, {"w": "recall?”", "b": [0.3128, 0.0967, 0.3692, 0.1163]}]}, {"id": "b_1", "type": "paragraph", "text": "The ROC Curve", "words": [{"w": "The", "b": [0.1429, 0.1752, 0.1805, 0.2037]}, {"w": "ROC", "b": [0.1855, 0.1752, 0.2259, 0.2037]}, {"w": "Curve", "b": [0.2309, 0.1752, 0.2889, 0.2037]}]}, {"id": "b_2", "type": "paragraph", "text": "The receiver operating characteristic (ROC) curve is another common tool used with binary classifiers. It is very similar to the precision/recall curve, but instead of plot‐ ting precision versus recall, the ROC curve plots the true positive rate (another name for recall) against the false positive rate. The FPR is the ratio of negative instances that are incorrectly classified as positive. It is equal to one minus the true negative rate, which is the ratio of negative instances that are correctly classified as negative. The TNR is also called specificity. Hence the ROC curve plots sensitivity (recall) versus 1 – specificity.", "words": [{"w": "The", "b": [0.1429, 0.2096, 0.1757, 0.2311]}, {"w": "receiver", "b": [0.1819, 0.2094, 0.244, 0.2311]}, {"w": "operating", "b": [0.2503, 0.2094, 0.3264, 0.2311]}, {"w": "characteristic", "b": [0.3327, 0.2094, 0.4408, 0.2311]}, {"w": "(ROC)", "b": [0.447, 0.2096, 0.5041, 0.2311]}, {"w": "curve", "b": [0.5104, 0.2096, 0.5571, 0.2311]}, {"w": "is", "b": [0.5633, 0.2096, 0.5765, 0.2311]}, {"w": "another", "b": [0.5827, 0.2096, 0.6479, 0.2311]}, {"w": "common", "b": [0.6542, 0.2096, 0.7297, 0.2311]}, {"w": "tool", "b": [0.7359, 0.2096, 0.7688, 0.2311]}, {"w": "used", "b": [0.775, 0.2096, 0.8136, 0.2311]}, {"w": "with", "b": [0.8198, 0.2096, 0.8571, 0.2311]}, {"w": "binary", "b": [0.1429, 0.2287, 0.1975, 0.2501]}, {"w": "classifiers.", "b": [0.204, 0.2287, 0.2889, 0.2501]}, {"w": "It", "b": [0.2954, 0.2287, 0.3081, 0.2501]}, {"w": "is", "b": [0.3146, 0.2287, 0.3279, 0.2501]}, {"w": "very", "b": [0.3344, 0.2287, 0.3708, 0.2501]}, {"w": "similar", "b": [0.3774, 0.2287, 0.4354, 0.2501]}, {"w": "to", "b": [0.442, 0.2287, 0.4589, 0.2501]}, {"w": "the", "b": [0.4655, 0.2287, 0.4918, 0.2501]}, {"w": "precision/recall", "b": [0.4984, 0.2287, 0.6275, 0.2501]}, {"w": "curve,", "b": [0.6341, 0.2287, 0.6855, 0.2501]}, {"w": "but", "b": [0.6921, 0.2287, 0.7201, 0.2501]}, {"w": "instead", "b": [0.7267, 0.2287, 0.7867, 0.2501]}, {"w": "of", "b": [0.7932, 0.2287, 0.81, 0.2501]}, {"w": "plot‐", "b": [0.8166, 0.2287, 0.8572, 0.2501]}, {"w": "ting", "b": [0.1429, 0.2477, 0.1759, 0.2692]}, {"w": "precision", "b": [0.1816, 0.2477, 0.2588, 0.2692]}, {"w": "versus", "b": [0.2644, 0.2477, 0.317, 0.2692]}, {"w": "recall,", "b": [0.3227, 0.2477, 0.3725, 0.2692]}, {"w": "the", "b": [0.3782, 0.2477, 0.4045, 0.2692]}, {"w": "ROC", "b": [0.4102, 0.2477, 0.453, 0.2692]}, {"w": "curve", "b": [0.4586, 0.2477, 0.5053, 0.2692]}, {"w": "plots", "b": [0.511, 0.2477, 0.5518, 0.2692]}, {"w": "the", "b": [0.5575, 0.2477, 0.5838, 0.2692]}, {"w": "true", "b": [0.5895, 0.2475, 0.6229, 0.2692]}, {"w": "positive", "b": [0.6286, 0.2475, 0.6897, 0.2692]}, {"w": "rate", "b": [0.6954, 0.2475, 0.7269, 0.2692]}, {"w": "(another", "b": [0.7326, 0.2477, 0.805, 0.2692]}, {"w": "name", "b": [0.8107, 0.2477, 0.8571, 0.2692]}, {"w": "for", "b": [0.1429, 0.2668, 0.1674, 0.2882]}, {"w": "recall)", "b": [0.1724, 0.2668, 0.2247, 0.2882]}, {"w": "against", "b": [0.2298, 0.2668, 0.2888, 0.2882]}, {"w": "the", "b": [0.2939, 0.2668, 0.3202, 0.2882]}, {"w": "false", "b": [0.3253, 0.2666, 0.3614, 0.2882]}, {"w": "positive", "b": [0.3662, 0.2666, 0.4272, 0.2882]}, {"w": "rate.", "b": [0.432, 0.2666, 0.469, 0.2882]}, {"w": "The", "b": [0.474, 0.2668, 0.5069, 0.2882]}, {"w": "FPR", "b": [0.5119, 0.2668, 0.5476, 0.2882]}, {"w": "is", "b": [0.5527, 0.2668, 0.5659, 0.2882]}, {"w": "the", "b": [0.571, 0.2668, 0.5973, 0.2882]}, {"w": "ratio", "b": [0.6024, 0.2668, 0.6415, 0.2882]}, {"w": "of", "b": [0.6465, 0.2668, 0.6633, 0.2882]}, {"w": "negative", "b": [0.6684, 0.2668, 0.7376, 0.2882]}, {"w": "instances", "b": [0.7427, 0.2668, 0.8195, 0.2882]}, {"w": "that", "b": [0.8246, 0.2668, 0.8571, 0.2882]}, {"w": "are", "b": [0.1429, 0.2858, 0.1686, 0.3072]}, {"w": "incorrectly", "b": [0.1754, 0.2858, 0.2661, 0.3072]}, {"w": "classified", "b": [0.2729, 0.2858, 0.3486, 0.3072]}, {"w": "as", "b": [0.3553, 0.2858, 0.3721, 0.3072]}, {"w": "positive.", "b": [0.3789, 0.2858, 0.4488, 0.3072]}, {"w": "It", "b": [0.4556, 0.2858, 0.4683, 0.3072]}, {"w": "is", "b": [0.475, 0.2858, 0.4883, 0.3072]}, {"w": "equal", "b": [0.495, 0.2858, 0.54, 0.3072]}, {"w": "to", "b": [0.5468, 0.2858, 0.5638, 0.3072]}, {"w": "one", "b": [0.5705, 0.2858, 0.6014, 0.3072]}, {"w": "minus", "b": [0.6082, 0.2858, 0.6605, 0.3072]}, {"w": "the", "b": [0.6673, 0.2858, 0.6936, 0.3072]}, {"w": "true", "b": [0.7004, 0.2856, 0.7338, 0.3072]}, {"w": "negative", "b": [0.7406, 0.2856, 0.8073, 0.3072]}, {"w": "rate,", "b": [0.8141, 0.2856, 0.8504, 0.3072]}, {"w": "which", "b": [0.1429, 0.3049, 0.1938, 0.3263]}, {"w": "is", "b": [0.2007, 0.3049, 0.214, 0.3263]}, {"w": "the", "b": [0.2209, 0.3049, 0.2473, 0.3263]}, {"w": "ratio", "b": [0.2542, 0.3049, 0.2933, 0.3263]}, {"w": "of", "b": [0.3003, 0.3049, 0.317, 0.3263]}, {"w": "negative", "b": [0.324, 0.3049, 0.3932, 0.3263]}, {"w": "instances", "b": [0.4002, 0.3049, 0.477, 0.3263]}, {"w": "that", "b": [0.484, 0.3049, 0.5166, 0.3263]}, {"w": "are", "b": [0.5235, 0.3049, 0.5493, 0.3263]}, {"w": "correctly", "b": [0.5562, 0.3049, 0.63, 0.3263]}, {"w": "classified", "b": [0.637, 0.3049, 0.7127, 0.3263]}, {"w": "as", "b": [0.7196, 0.3049, 0.7364, 0.3263]}, {"w": "negative.", "b": [0.7434, 0.3049, 0.8173, 0.3263]}, {"w": "The", "b": [0.8243, 0.3049, 0.8571, 0.3263]}, {"w": "TNR", "b": [0.1429, 0.3239, 0.1841, 0.3453]}, {"w": "is", "b": [0.1918, 0.3239, 0.205, 0.3453]}, {"w": "also", "b": [0.2126, 0.3239, 0.2453, 0.3453]}, {"w": "called", "b": [0.253, 0.3239, 0.3013, 0.3453]}, {"w": "specificity.", "b": [0.309, 0.3237, 0.3931, 0.3453]}, {"w": "Hence", "b": [0.4008, 0.3239, 0.4541, 0.3453]}, {"w": "the", "b": [0.4618, 0.3239, 0.4881, 0.3453]}, {"w": "ROC", "b": [0.4958, 0.3239, 0.5385, 0.3453]}, {"w": "curve", "b": [0.5461, 0.3239, 0.5928, 0.3453]}, {"w": "plots", "b": [0.6005, 0.3239, 0.6413, 0.3453]}, {"w": "sensitivity", "b": [0.6489, 0.3237, 0.7298, 0.3453]}, {"w": "(recall)", "b": [0.7374, 0.3239, 0.7969, 0.3453]}, {"w": "versus", "b": [0.8046, 0.3239, 0.8572, 0.3453]}, {"w": "1", "b": [0.1429, 0.343, 0.1529, 0.3644]}, {"w": "–", "b": [0.1576, 0.343, 0.1684, 0.3644]}, {"w": "specificity.", "b": [0.1732, 0.3428, 0.2573, 0.3644]}]}, {"id": "b_3", "type": "paragraph", "text": "To plot the ROC curve, you first need to compute the TPR and FPR for various thres‐ hold values, using the roc_curve() function:", "words": [{"w": "To", "b": [0.1429, 0.3711, 0.1643, 0.3925]}, {"w": "plot", "b": [0.1692, 0.3711, 0.2023, 0.3925]}, {"w": "the", "b": [0.2072, 0.3711, 0.2335, 0.3925]}, {"w": "ROC", "b": [0.2384, 0.3711, 0.2811, 0.3925]}, {"w": "curve,", "b": [0.286, 0.3711, 0.3375, 0.3925]}, {"w": "you", "b": [0.3423, 0.3711, 0.3736, 0.3925]}, {"w": "first", "b": [0.3784, 0.3711, 0.4119, 0.3925]}, {"w": "need", "b": [0.4168, 0.3711, 0.4569, 0.3925]}, {"w": "to", "b": [0.4618, 0.3711, 0.4787, 0.3925]}, {"w": "compute", "b": [0.4836, 0.3711, 0.5569, 0.3925]}, {"w": "the", "b": [0.5618, 0.3711, 0.5881, 0.3925]}, {"w": "TPR", "b": [0.593, 0.3711, 0.6305, 0.3925]}, {"w": "and", "b": [0.6354, 0.3711, 0.6669, 0.3925]}, {"w": "FPR", "b": [0.6718, 0.3711, 0.7075, 0.3925]}, {"w": "for", "b": [0.7123, 0.3711, 0.7368, 0.3925]}, {"w": "various", "b": [0.7417, 0.3711, 0.8032, 0.3925]}, {"w": "thres‐", "b": [0.808, 0.3711, 0.8571, 0.3925]}, {"w": "hold", "b": [0.1429, 0.391, 0.1809, 0.4125]}, {"w": "values,", "b": [0.1856, 0.391, 0.242, 0.4125]}, {"w": "using", "b": [0.2467, 0.391, 0.2921, 0.4125]}, {"w": "the", "b": [0.2969, 0.391, 0.3232, 0.4125]}, {"w": "roc_curve()", "b": [0.3279, 0.3942, 0.4368, 0.4093]}, {"w": "function:", "b": [0.4415, 0.391, 0.5177, 0.4125]}]}, {"id": "b_4", "type": "equation", "text": "from sklearn.metrics import roc_curve", "words": [{"w": "from", "b": [0.1766, 0.423, 0.2103, 0.4359]}, {"w": "sklearn.metrics", "b": [0.2188, 0.423, 0.3452, 0.4359]}, {"w": "import", "b": [0.3537, 0.423, 0.4043, 0.4359]}, {"w": "roc_curve", "b": [0.4127, 0.423, 0.4886, 0.4359]}]}, {"id": "b_5", "type": "equation", "text": "fpr, tpr, thresholds = roc_curve(y_train_5, y_scores)", "words": [{"w": "fpr,", "b": [0.1766, 0.4539, 0.2103, 0.4667]}, {"w": "tpr,", "b": [0.2188, 0.4539, 0.2525, 0.4667]}, {"w": "thresholds", "b": [0.2609, 0.4539, 0.3452, 0.4667]}, {"w": "=", "b": [0.3537, 0.4539, 0.3621, 0.4667]}, {"w": "roc_curve(y_train_5,", "b": [0.3705, 0.4539, 0.5392, 0.4667]}, {"w": "y_scores)", "b": [0.5476, 0.4539, 0.6235, 0.4667]}]}, {"id": "b_6", "type": "paragraph", "text": "Then you can plot the FPR against the TPR using Matplotlib. This code produces the plot in Figure 3-6:", "words": [{"w": "Then", "b": [0.1429, 0.4745, 0.1871, 0.4959]}, {"w": "you", "b": [0.1924, 0.4745, 0.2237, 0.4959]}, {"w": "can", "b": [0.229, 0.4745, 0.2583, 0.4959]}, {"w": "plot", "b": [0.2636, 0.4745, 0.2968, 0.4959]}, {"w": "the", "b": [0.3021, 0.4745, 0.3285, 0.4959]}, {"w": "FPR", "b": [0.3338, 0.4745, 0.3695, 0.4959]}, {"w": "against", "b": [0.3748, 0.4745, 0.4338, 0.4959]}, {"w": "the", "b": [0.4391, 0.4745, 0.4654, 0.4959]}, {"w": "TPR", "b": [0.4708, 0.4745, 0.5083, 0.4959]}, {"w": "using", "b": [0.5136, 0.4745, 0.559, 0.4959]}, {"w": "Matplotlib.", "b": [0.5644, 0.4745, 0.6564, 0.4959]}, {"w": "This", "b": [0.6617, 0.4745, 0.6989, 0.4959]}, {"w": "code", "b": [0.7043, 0.4745, 0.7435, 0.4959]}, {"w": "produces", "b": [0.7489, 0.4745, 0.8255, 0.4959]}, {"w": "the", "b": [0.8308, 0.4745, 0.8572, 0.4959]}, {"w": "plot", "b": [0.1429, 0.4935, 0.176, 0.5149]}, {"w": "in", "b": [0.1808, 0.4935, 0.1977, 0.5149]}, {"w": "Figure", "b": [0.2025, 0.4935, 0.2565, 0.5149]}, {"w": "3-6:", "b": [0.2612, 0.4935, 0.2934, 0.5149]}]}, {"id": "b_7", "type": "paragraph", "text": "def plot_roc_curve(fpr, tpr, label=None): plt.plot(fpr, tpr, linewidth=2, label=label) plt.plot([0, 1], [0, 1], 'k--') # dashed diagonal [...] # Add axis labels and grid", "words": [{"w": "def", "b": [0.1766, 0.5255, 0.2019, 0.5384]}, {"w": "plot_roc_curve(fpr,", "b": [0.2103, 0.5255, 0.3705, 0.5384]}, {"w": "tpr,", "b": [0.379, 0.5255, 0.4127, 0.5384]}, {"w": "label=None):", "b": [0.4211, 0.5255, 0.5223, 0.5384]}, {"w": "plt.plot(fpr,", "b": [0.2103, 0.5409, 0.3199, 0.5538]}, {"w": "tpr,", "b": [0.3284, 0.5409, 0.3621, 0.5538]}, {"w": "linewidth=2,", "b": [0.3705, 0.5409, 0.4717, 0.5538]}, {"w": "label=label)", "b": [0.4802, 0.5409, 0.5813, 0.5538]}, {"w": "plt.plot([0,", "b": [0.2103, 0.5563, 0.3115, 0.5692]}, {"w": "1],", "b": [0.3199, 0.5563, 0.3452, 0.5692]}, {"w": "[0,", "b": [0.3537, 0.5563, 0.379, 0.5692]}, {"w": "1],", "b": [0.3874, 0.5563, 0.4127, 0.5692]}, {"w": "'k--')", "b": [0.4211, 0.5563, 0.4717, 0.5692]}, {"w": "#", "b": [0.4802, 0.5563, 0.4886, 0.5692]}, {"w": "dashed", "b": [0.497, 0.5563, 0.5476, 0.5692]}, {"w": "diagonal", "b": [0.5561, 0.5563, 0.6235, 0.5692]}, {"w": "[...]", "b": [0.2103, 0.5718, 0.2525, 0.5846]}, {"w": "#", "b": [0.2609, 0.5718, 0.2693, 0.5846]}, {"w": "Add", "b": [0.2778, 0.5718, 0.3031, 0.5846]}, {"w": "axis", "b": [0.3115, 0.5718, 0.3452, 0.5846]}, {"w": "labels", "b": [0.3537, 0.5718, 0.4043, 0.5846]}, {"w": "and", "b": [0.4127, 0.5718, 0.438, 0.5846]}, {"w": "grid", "b": [0.4464, 0.5718, 0.4802, 0.5846]}]}, {"id": "b_8", "type": "equation", "text": "plot_roc_curve(fpr, tpr) plt.show()", "words": [{"w": "plot_roc_curve(fpr,", "b": [0.1766, 0.6026, 0.3368, 0.6155]}, {"w": "tpr)", "b": [0.3452, 0.6026, 0.379, 0.6155]}, {"w": "plt.show()", "b": [0.1766, 0.618, 0.2609, 0.6309]}]}, {"id": "b_9", "type": "paragraph", "text": "Performance Measures | 99", "words": [{"w": "Performance", "b": [0.669, 0.9225, 0.7446, 0.9388]}, {"w": "Measures", "b": [0.7474, 0.9225, 0.8031, 0.9388]}, {"w": "|", "b": [0.821, 0.9225, 0.8247, 0.9388]}, {"w": "99", "b": [0.8426, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 126, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 3-6. ROC curve", "words": [{"w": "Figure", "b": [0.1429, 0.3803, 0.1943, 0.4019]}, {"w": "3-6.", "b": [0.1991, 0.3803, 0.2308, 0.4019]}, {"w": "ROC", "b": [0.2356, 0.3803, 0.2762, 0.4019]}, {"w": "curve", "b": [0.281, 0.3803, 0.3254, 0.4019]}]}, {"id": "b_1", "type": "paragraph", "text": "Once again there is a tradeoff: the higher the recall (TPR), the more false positives (FPR) the classifier produces. The dotted line represents the ROC curve of a purely random classifier; a good classifier stays as far away from that line as possible (toward the top-left corner).", "words": [{"w": "Once", "b": [0.1429, 0.4177, 0.1875, 0.4391]}, {"w": "again", "b": [0.1946, 0.4177, 0.2396, 0.4391]}, {"w": "there", "b": [0.2467, 0.4177, 0.2896, 0.4391]}, {"w": "is", "b": [0.2967, 0.4177, 0.31, 0.4391]}, {"w": "a", "b": [0.3171, 0.4177, 0.3262, 0.4391]}, {"w": "tradeoff:", "b": [0.3333, 0.4177, 0.4041, 0.4391]}, {"w": "the", "b": [0.4112, 0.4177, 0.4375, 0.4391]}, {"w": "higher", "b": [0.4446, 0.4177, 0.4988, 0.4391]}, {"w": "the", "b": [0.5059, 0.4177, 0.5322, 0.4391]}, {"w": "recall", "b": [0.5393, 0.4177, 0.5844, 0.4391]}, {"w": "(TPR),", "b": [0.5915, 0.4177, 0.6482, 0.4391]}, {"w": "the", "b": [0.6553, 0.4177, 0.6816, 0.4391]}, {"w": "more", "b": [0.6887, 0.4177, 0.733, 0.4391]}, {"w": "false", "b": [0.7401, 0.4177, 0.7772, 0.4391]}, {"w": "positives", "b": [0.7843, 0.4177, 0.8571, 0.4391]}, {"w": "(FPR)", "b": [0.1429, 0.4368, 0.193, 0.4582]}, {"w": "the", "b": [0.1995, 0.4368, 0.2258, 0.4582]}, {"w": "classifier", "b": [0.2324, 0.4368, 0.3048, 0.4582]}, {"w": "produces.", "b": [0.3114, 0.4368, 0.3928, 0.4582]}, {"w": "The", "b": [0.3993, 0.4368, 0.4322, 0.4582]}, {"w": "dotted", "b": [0.4387, 0.4368, 0.4929, 0.4582]}, {"w": "line", "b": [0.4995, 0.4368, 0.5306, 0.4582]}, {"w": "represents", "b": [0.5371, 0.4368, 0.6227, 0.4582]}, {"w": "the", "b": [0.6293, 0.4368, 0.6556, 0.4582]}, {"w": "ROC", "b": [0.6621, 0.4368, 0.7049, 0.4582]}, {"w": "curve", "b": [0.7114, 0.4368, 0.7581, 0.4582]}, {"w": "of", "b": [0.7647, 0.4368, 0.7815, 0.4582]}, {"w": "a", "b": [0.788, 0.4368, 0.7972, 0.4582]}, {"w": "purely", "b": [0.8037, 0.4368, 0.8571, 0.4582]}, {"w": "random", "b": [0.1429, 0.4558, 0.2098, 0.4772]}, {"w": "classifier;", "b": [0.2148, 0.4558, 0.2925, 0.4772]}, {"w": "a", "b": [0.2974, 0.4558, 0.3066, 0.4772]}, {"w": "good", "b": [0.3115, 0.4558, 0.3535, 0.4772]}, {"w": "classifier", "b": [0.3585, 0.4558, 0.4309, 0.4772]}, {"w": "stays", "b": [0.4359, 0.4558, 0.4758, 0.4772]}, {"w": "as", "b": [0.4808, 0.4558, 0.4976, 0.4772]}, {"w": "far", "b": [0.5025, 0.4558, 0.5256, 0.4772]}, {"w": "away", "b": [0.5305, 0.4558, 0.5719, 0.4772]}, {"w": "from", "b": [0.5769, 0.4558, 0.6184, 0.4772]}, {"w": "that", "b": [0.6234, 0.4558, 0.656, 0.4772]}, {"w": "line", "b": [0.6609, 0.4558, 0.692, 0.4772]}, {"w": "as", "b": [0.697, 0.4558, 0.7138, 0.4772]}, {"w": "possible", "b": [0.7187, 0.4558, 0.7859, 0.4772]}, {"w": "(toward", "b": [0.7908, 0.4558, 0.8572, 0.4772]}, {"w": "the", "b": [0.1429, 0.4748, 0.1692, 0.4963]}, {"w": "top-left", "b": [0.1739, 0.4748, 0.2359, 0.4963]}, {"w": "corner).", "b": [0.2406, 0.4748, 0.3077, 0.4963]}]}, {"id": "b_2", "type": "paragraph", "text": "One way to compare classifiers is to measure the area under the curve (AUC). A per‐ fect classifier will have a ROC AUC equal to 1, whereas a purely random classifier will have a ROC AUC equal to 0.5. Scikit-Learn provides a function to compute the ROC AUC:", "words": [{"w": "One", "b": [0.1429, 0.503, 0.1787, 0.5244]}, {"w": "way", "b": [0.1843, 0.503, 0.2169, 0.5244]}, {"w": "to", "b": [0.2226, 0.503, 0.2396, 0.5244]}, {"w": "compare", "b": [0.2453, 0.503, 0.318, 0.5244]}, {"w": "classifiers", "b": [0.3237, 0.503, 0.4038, 0.5244]}, {"w": "is", "b": [0.4094, 0.503, 0.4226, 0.5244]}, {"w": "to", "b": [0.4283, 0.503, 0.4453, 0.5244]}, {"w": "measure", "b": [0.451, 0.503, 0.5213, 0.5244]}, {"w": "the", "b": [0.527, 0.503, 0.5533, 0.5244]}, {"w": "area", "b": [0.559, 0.5028, 0.5945, 0.5244]}, {"w": "under", "b": [0.6002, 0.5028, 0.6484, 0.5244]}, {"w": "the", "b": [0.6541, 0.5028, 0.6792, 0.5244]}, {"w": "curve", "b": [0.6849, 0.5028, 0.7293, 0.5244]}, {"w": "(AUC).", "b": [0.735, 0.503, 0.7965, 0.5244]}, {"w": "A", "b": [0.8022, 0.503, 0.8166, 0.5244]}, {"w": "per‐", "b": [0.8222, 0.503, 0.8571, 0.5244]}, {"w": "fect", "b": [0.1429, 0.522, 0.173, 0.5434]}, {"w": "classifier", "b": [0.178, 0.522, 0.2504, 0.5434]}, {"w": "will", "b": [0.2554, 0.522, 0.2858, 0.5434]}, {"w": "have", "b": [0.2908, 0.522, 0.3292, 0.5434]}, {"w": "a", "b": [0.3342, 0.522, 0.3433, 0.5434]}, {"w": "ROC", "b": [0.3483, 0.5218, 0.3889, 0.5434]}, {"w": "AUC", "b": [0.3937, 0.5218, 0.4355, 0.5434]}, {"w": "equal", "b": [0.4407, 0.522, 0.4857, 0.5434]}, {"w": "to", "b": [0.4907, 0.522, 0.5076, 0.5434]}, {"w": "1,", "b": [0.5126, 0.522, 0.5274, 0.5434]}, {"w": "whereas", "b": [0.5323, 0.522, 0.5999, 0.5434]}, {"w": "a", "b": [0.6049, 0.522, 0.6141, 0.5434]}, {"w": "purely", "b": [0.619, 0.522, 0.6724, 0.5434]}, {"w": "random", "b": [0.6774, 0.522, 0.7444, 0.5434]}, {"w": "classifier", "b": [0.7493, 0.522, 0.8218, 0.5434]}, {"w": "will", "b": [0.8267, 0.522, 0.8571, 0.5434]}, {"w": "have", "b": [0.1429, 0.5411, 0.1813, 0.5625]}, {"w": "a", "b": [0.1867, 0.5411, 0.1958, 0.5625]}, {"w": "ROC", "b": [0.2013, 0.5411, 0.244, 0.5625]}, {"w": "AUC", "b": [0.2494, 0.5411, 0.2918, 0.5625]}, {"w": "equal", "b": [0.2972, 0.5411, 0.3422, 0.5625]}, {"w": "to", "b": [0.3476, 0.5411, 0.3646, 0.5625]}, {"w": "0.5.", "b": [0.37, 0.5411, 0.3995, 0.5625]}, {"w": "Scikit-Learn", "b": [0.405, 0.5411, 0.5073, 0.5625]}, {"w": "provides", "b": [0.5127, 0.5411, 0.5847, 0.5625]}, {"w": "a", "b": [0.5901, 0.5411, 0.5993, 0.5625]}, {"w": "function", "b": [0.6047, 0.5411, 0.6761, 0.5625]}, {"w": "to", "b": [0.6815, 0.5411, 0.6985, 0.5625]}, {"w": "compute", "b": [0.7039, 0.5411, 0.7772, 0.5625]}, {"w": "the", "b": [0.7827, 0.5411, 0.809, 0.5625]}, {"w": "ROC", "b": [0.8144, 0.5411, 0.8572, 0.5625]}, {"w": "AUC:", "b": [0.1429, 0.5601, 0.19, 0.5815]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> from sklearn.metrics import roc_auc_score >>> roc_auc_score(y_train_5, y_scores) 0.9611778893101814", "words": [{"w": ">>>", "b": [0.1766, 0.5921, 0.2019, 0.6049]}, {"w": "from", "b": [0.2103, 0.5921, 0.2441, 0.6049]}, {"w": "sklearn.metrics", "b": [0.2525, 0.5921, 0.379, 0.6049]}, {"w": "import", "b": [0.3874, 0.5921, 0.438, 0.6049]}, {"w": "roc_auc_score", "b": [0.4464, 0.5921, 0.5561, 0.6049]}, {"w": ">>>", "b": [0.1766, 0.6075, 0.2019, 0.6204]}, {"w": "roc_auc_score(y_train_5,", "b": [0.2103, 0.6075, 0.4127, 0.6204]}, {"w": "y_scores)", "b": [0.4211, 0.6075, 0.497, 0.6204]}, {"w": "0.9611778893101814", "b": [0.1766, 0.6229, 0.3284, 0.6358]}]}, {"id": "b_4", "type": "paragraph", "text": "Since the ROC curve is so similar to the precision/recall (or PR) curve, you may wonder how to decide which one to use. As a rule of thumb, you should prefer the PR curve whenever the positive class is rare or when you care more about the false positives than the false negatives, and the ROC curve otherwise. For example, looking at the previous ROC curve (and the ROC AUC score), you may think that the classifier is really good. But this is mostly because there are few positives (5s) compared to the negatives (non-5s). In contrast, the PR curve makes it clear that the classifier has room for improvement (the curve could be closer to the top- right corner).", "words": [{"w": "Since", "b": [0.2714, 0.6574, 0.3121, 0.677]}, {"w": "the", "b": [0.319, 0.6574, 0.3431, 0.677]}, {"w": "ROC", "b": [0.35, 0.6574, 0.389, 0.677]}, {"w": "curve", "b": [0.3959, 0.6574, 0.4386, 0.677]}, {"w": "is", "b": [0.4455, 0.6574, 0.4576, 0.677]}, {"w": "so", "b": [0.4645, 0.6574, 0.4812, 0.677]}, {"w": "similar", "b": [0.4881, 0.6574, 0.5411, 0.677]}, {"w": "to", "b": [0.548, 0.6574, 0.5635, 0.677]}, {"w": "the", "b": [0.5704, 0.6574, 0.5945, 0.677]}, {"w": "precision/recall", "b": [0.6014, 0.6574, 0.7194, 0.677]}, {"w": "(or", "b": [0.7263, 0.6574, 0.7497, 0.677]}, {"w": "PR)", "b": [0.7566, 0.6574, 0.7857, 0.677]}, {"w": "curve,", "b": [0.2714, 0.6748, 0.3185, 0.6944]}, {"w": "you", "b": [0.324, 0.6748, 0.3525, 0.6944]}, {"w": "may", "b": [0.358, 0.6748, 0.3904, 0.6944]}, {"w": "wonder", "b": [0.3959, 0.6748, 0.4543, 0.6944]}, {"w": "how", "b": [0.4598, 0.6748, 0.4927, 0.6944]}, {"w": "to", "b": [0.4982, 0.6748, 0.5138, 0.6944]}, {"w": "decide", "b": [0.5193, 0.6748, 0.5687, 0.6944]}, {"w": "which", "b": [0.5742, 0.6748, 0.6208, 0.6944]}, {"w": "one", "b": [0.6263, 0.6748, 0.6545, 0.6944]}, {"w": "to", "b": [0.66, 0.6748, 0.6755, 0.6944]}, {"w": "use.", "b": [0.6811, 0.6748, 0.7106, 0.6944]}, {"w": "As", "b": [0.7161, 0.6748, 0.7362, 0.6944]}, {"w": "a", "b": [0.7418, 0.6748, 0.7501, 0.6944]}, {"w": "rule", "b": [0.7556, 0.6748, 0.7857, 0.6944]}, {"w": "of", "b": [0.2714, 0.6922, 0.2868, 0.7118]}, {"w": "thumb,", "b": [0.2939, 0.6922, 0.3487, 0.7118]}, {"w": "you", "b": [0.3557, 0.6922, 0.3843, 0.7118]}, {"w": "should", "b": [0.3914, 0.6922, 0.4433, 0.7118]}, {"w": "prefer", "b": [0.4504, 0.6922, 0.4963, 0.7118]}, {"w": "the", "b": [0.5034, 0.6922, 0.5275, 0.7118]}, {"w": "PR", "b": [0.5346, 0.6922, 0.5571, 0.7118]}, {"w": "curve", "b": [0.5642, 0.6922, 0.6069, 0.7118]}, {"w": "whenever", "b": [0.614, 0.6922, 0.6878, 0.7118]}, {"w": "the", "b": [0.6949, 0.6922, 0.719, 0.7118]}, {"w": "positive", "b": [0.7261, 0.6922, 0.7857, 0.7118]}, {"w": "class", "b": [0.2714, 0.7096, 0.3066, 0.7292]}, {"w": "is", "b": [0.3128, 0.7096, 0.3249, 0.7292]}, {"w": "rare", "b": [0.3311, 0.7096, 0.3617, 0.7292]}, {"w": "or", "b": [0.3679, 0.7096, 0.3847, 0.7292]}, {"w": "when", "b": [0.3908, 0.7096, 0.4326, 0.7292]}, {"w": "you", "b": [0.4388, 0.7096, 0.4673, 0.7292]}, {"w": "care", "b": [0.4735, 0.7096, 0.5051, 0.7292]}, {"w": "more", "b": [0.5113, 0.7096, 0.5518, 0.7292]}, {"w": "about", "b": [0.5579, 0.7096, 0.6016, 0.7292]}, {"w": "the", "b": [0.6078, 0.7096, 0.6319, 0.7292]}, {"w": "false", "b": [0.6381, 0.7096, 0.672, 0.7292]}, {"w": "positives", "b": [0.6782, 0.7096, 0.7448, 0.7292]}, {"w": "than", "b": [0.751, 0.7096, 0.7857, 0.7292]}, {"w": "the", "b": [0.2714, 0.727, 0.2955, 0.7466]}, {"w": "false", "b": [0.3037, 0.727, 0.3376, 0.7466]}, {"w": "negatives,", "b": [0.3458, 0.727, 0.4203, 0.7466]}, {"w": "and", "b": [0.4285, 0.727, 0.4574, 0.7466]}, {"w": "the", "b": [0.4655, 0.727, 0.4896, 0.7466]}, {"w": "ROC", "b": [0.4978, 0.727, 0.5369, 0.7466]}, {"w": "curve", "b": [0.5451, 0.727, 0.5878, 0.7466]}, {"w": "otherwise.", "b": [0.5959, 0.727, 0.6749, 0.7466]}, {"w": "For", "b": [0.6831, 0.727, 0.7096, 0.7466]}, {"w": "example,", "b": [0.7178, 0.727, 0.7857, 0.7466]}, {"w": "looking", "b": [0.2714, 0.7445, 0.3295, 0.764]}, {"w": "at", "b": [0.3344, 0.7445, 0.3483, 0.764]}, {"w": "the", "b": [0.3532, 0.7445, 0.3772, 0.764]}, {"w": "previous", "b": [0.3821, 0.7445, 0.448, 0.764]}, {"w": "ROC", "b": [0.4529, 0.7445, 0.492, 0.764]}, {"w": "curve", "b": [0.4969, 0.7445, 0.5396, 0.764]}, {"w": "(and", "b": [0.5445, 0.7445, 0.5799, 0.764]}, {"w": "the", "b": [0.5848, 0.7445, 0.6089, 0.764]}, {"w": "ROC", "b": [0.6138, 0.7445, 0.6528, 0.764]}, {"w": "AUC", "b": [0.6577, 0.7445, 0.6965, 0.764]}, {"w": "score),", "b": [0.7014, 0.7445, 0.7522, 0.764]}, {"w": "you", "b": [0.7571, 0.7445, 0.7857, 0.764]}, {"w": "may", "b": [0.2714, 0.7619, 0.3038, 0.7814]}, {"w": "think", "b": [0.3133, 0.7619, 0.3543, 0.7814]}, {"w": "that", "b": [0.3638, 0.7619, 0.3936, 0.7814]}, {"w": "the", "b": [0.4032, 0.7619, 0.4273, 0.7814]}, {"w": "classifier", "b": [0.4368, 0.7619, 0.5031, 0.7814]}, {"w": "is", "b": [0.5126, 0.7619, 0.5247, 0.7814]}, {"w": "really", "b": [0.5343, 0.7619, 0.5762, 0.7814]}, {"w": "good.", "b": [0.5858, 0.7619, 0.6285, 0.7814]}, {"w": "But", "b": [0.6381, 0.7619, 0.6652, 0.7814]}, {"w": "this", "b": [0.6747, 0.7619, 0.7028, 0.7814]}, {"w": "is", "b": [0.7124, 0.7619, 0.7245, 0.7814]}, {"w": "mostly", "b": [0.734, 0.7619, 0.7857, 0.7814]}, {"w": "because", "b": [0.2714, 0.7793, 0.3304, 0.7989]}, {"w": "there", "b": [0.3397, 0.7793, 0.3789, 0.7989]}, {"w": "are", "b": [0.3882, 0.7793, 0.4117, 0.7989]}, {"w": "few", "b": [0.421, 0.7793, 0.4478, 0.7989]}, {"w": "positives", "b": [0.457, 0.7793, 0.5237, 0.7989]}, {"w": "(5s)", "b": [0.5329, 0.7793, 0.5622, 0.7989]}, {"w": "compared", "b": [0.5715, 0.7793, 0.6481, 0.7989]}, {"w": "to", "b": [0.6573, 0.7793, 0.6729, 0.7989]}, {"w": "the", "b": [0.6821, 0.7793, 0.7062, 0.7989]}, {"w": "negatives", "b": [0.7155, 0.7793, 0.7857, 0.7989]}, {"w": "(non-5s).", "b": [0.2714, 0.7967, 0.3424, 0.8163]}, {"w": "In", "b": [0.3474, 0.7967, 0.3643, 0.8163]}, {"w": "contrast,", "b": [0.3693, 0.7967, 0.4355, 0.8163]}, {"w": "the", "b": [0.4405, 0.7967, 0.4646, 0.8163]}, {"w": "PR", "b": [0.4696, 0.7967, 0.4921, 0.8163]}, {"w": "curve", "b": [0.4971, 0.7967, 0.5398, 0.8163]}, {"w": "makes", "b": [0.5448, 0.7967, 0.5933, 0.8163]}, {"w": "it", "b": [0.5983, 0.7967, 0.6092, 0.8163]}, {"w": "clear", "b": [0.6142, 0.7967, 0.6506, 0.8163]}, {"w": "that", "b": [0.6556, 0.7967, 0.6854, 0.8163]}, {"w": "the", "b": [0.6904, 0.7967, 0.7145, 0.8163]}, {"w": "classifier", "b": [0.7195, 0.7967, 0.7857, 0.8163]}, {"w": "has", "b": [0.2714, 0.8141, 0.2969, 0.8337]}, {"w": "room", "b": [0.3033, 0.8141, 0.3454, 0.8337]}, {"w": "for", "b": [0.3518, 0.8141, 0.3742, 0.8337]}, {"w": "improvement", "b": [0.3806, 0.8141, 0.4842, 0.8337]}, {"w": "(the", "b": [0.4905, 0.8141, 0.5212, 0.8337]}, {"w": "curve", "b": [0.5276, 0.8141, 0.5703, 0.8337]}, {"w": "could", "b": [0.5767, 0.8141, 0.6194, 0.8337]}, {"w": "be", "b": [0.6258, 0.8141, 0.6436, 0.8337]}, {"w": "closer", "b": [0.65, 0.8141, 0.6947, 0.8337]}, {"w": "to", "b": [0.7011, 0.8141, 0.7166, 0.8337]}, {"w": "the", "b": [0.723, 0.8141, 0.7471, 0.8337]}, {"w": "top-", "b": [0.7534, 0.8141, 0.7857, 0.8337]}, {"w": "right", "b": [0.2714, 0.8315, 0.3081, 0.8511]}, {"w": "corner).", "b": [0.3124, 0.8315, 0.3738, 0.8511]}]}, {"id": "b_5", "type": "paragraph", "text": "100 | Chapter 3: Classification", "words": [{"w": "100", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "3:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Classification", "b": [0.2673, 0.9225, 0.3443, 0.9388]}]}]}, {"page": 127, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Let’s train a RandomForestClassifier and compare its ROC curve and ROC AUC score to the SGDClassifier. First, you need to get scores for each instance in the training set. But due to the way it works (see Chapter 7), the RandomForestClassi fier class does not have a decision_function() method. Instead it has a pre dict_proba() method. Scikit-Learn classifiers generally have one or the other. The predict_proba() method returns an array containing a row per instance and a col‐ umn per class, each containing the probability that the given instance belongs to the given class (e.g., 70% chance that the image represents a 5):", "words": [{"w": "Let’s", "b": [0.1429, 0.08, 0.179, 0.1014]}, {"w": "train", "b": [0.1864, 0.08, 0.2266, 0.1014]}, {"w": "a", "b": [0.234, 0.08, 0.2431, 0.1014]}, {"w": "RandomForestClassifier", "b": [0.2505, 0.0831, 0.4682, 0.0982]}, {"w": "and", "b": [0.4756, 0.08, 0.5071, 0.1014]}, {"w": "compare", "b": [0.5145, 0.08, 0.5872, 0.1014]}, {"w": "its", "b": [0.5946, 0.08, 0.6142, 0.1014]}, {"w": "ROC", "b": [0.6216, 0.08, 0.6643, 0.1014]}, {"w": "curve", "b": [0.6717, 0.08, 0.7184, 0.1014]}, {"w": "and", "b": [0.7258, 0.08, 0.7573, 0.1014]}, {"w": "ROC", "b": [0.7647, 0.08, 0.8074, 0.1014]}, {"w": "AUC", "b": [0.8148, 0.08, 0.8571, 0.1014]}, {"w": "score", "b": [0.1429, 0.0999, 0.1865, 0.1213]}, {"w": "to", "b": [0.1945, 0.0999, 0.2114, 0.1213]}, {"w": "the", "b": [0.2194, 0.0999, 0.2457, 0.1213]}, {"w": "SGDClassifier.", "b": [0.2537, 0.0999, 0.3871, 0.1213]}, {"w": "First,", "b": [0.395, 0.0999, 0.4381, 0.1213]}, {"w": "you", "b": [0.446, 0.0999, 0.4773, 0.1213]}, {"w": "need", "b": [0.4852, 0.0999, 0.5253, 0.1213]}, {"w": "to", "b": [0.5333, 0.0999, 0.5503, 0.1213]}, {"w": "get", "b": [0.5582, 0.0999, 0.5832, 0.1213]}, {"w": "scores", "b": [0.5911, 0.0999, 0.6424, 0.1213]}, {"w": "for", "b": [0.6504, 0.0999, 0.6749, 0.1213]}, {"w": "each", "b": [0.6829, 0.0999, 0.7208, 0.1213]}, {"w": "instance", "b": [0.7287, 0.0999, 0.7979, 0.1213]}, {"w": "in", "b": [0.8059, 0.0999, 0.8229, 0.1213]}, {"w": "the", "b": [0.8308, 0.0999, 0.8571, 0.1213]}, {"w": "training", "b": [0.1429, 0.1198, 0.2098, 0.1413]}, {"w": "set.", "b": [0.2169, 0.1198, 0.2445, 0.1413]}, {"w": "But", "b": [0.2515, 0.1198, 0.2812, 0.1413]}, {"w": "due", "b": [0.2883, 0.1198, 0.3192, 0.1413]}, {"w": "to", "b": [0.3263, 0.1198, 0.3433, 0.1413]}, {"w": "the", "b": [0.3503, 0.1198, 0.3767, 0.1413]}, {"w": "way", "b": [0.3837, 0.1198, 0.4163, 0.1413]}, {"w": "it", "b": [0.4234, 0.1198, 0.4353, 0.1413]}, {"w": "works", "b": [0.4424, 0.1198, 0.493, 0.1413]}, {"w": "(see", "b": [0.5001, 0.1198, 0.5326, 0.1413]}, {"w": "Chapter", "b": [0.5397, 0.1198, 0.6073, 0.1413]}, {"w": "7),", "b": [0.6144, 0.1198, 0.6363, 0.1413]}, {"w": "the", "b": [0.6434, 0.1198, 0.6697, 0.1413]}, {"w": "RandomForestClassi", "b": [0.6768, 0.123, 0.8549, 0.1381]}, {"w": "fier", "b": [0.1429, 0.143, 0.1824, 0.1581]}, {"w": "class", "b": [0.1924, 0.1398, 0.2309, 0.1612]}, {"w": "does", "b": [0.2408, 0.1398, 0.279, 0.1612]}, {"w": "not", "b": [0.2889, 0.1398, 0.3173, 0.1612]}, {"w": "have", "b": [0.3272, 0.1398, 0.3656, 0.1612]}, {"w": "a", "b": [0.3755, 0.1398, 0.3847, 0.1612]}, {"w": "decision_function()", "b": [0.3946, 0.143, 0.5826, 0.1581]}, {"w": "method.", "b": [0.5926, 0.1398, 0.6623, 0.1612]}, {"w": "Instead", "b": [0.6723, 0.1398, 0.7338, 0.1612]}, {"w": "it", "b": [0.7437, 0.1398, 0.7556, 0.1612]}, {"w": "has", "b": [0.7656, 0.1398, 0.7935, 0.1612]}, {"w": "a", "b": [0.8034, 0.1398, 0.8126, 0.1612]}, {"w": "pre", "b": [0.8225, 0.143, 0.8522, 0.1581]}, {"w": "dict_proba()", "b": [0.1428, 0.1629, 0.2616, 0.178]}, {"w": "method.", "b": [0.2689, 0.1597, 0.3386, 0.1811]}, {"w": "Scikit-Learn", "b": [0.3459, 0.1597, 0.4482, 0.1811]}, {"w": "classifiers", "b": [0.4555, 0.1597, 0.5355, 0.1811]}, {"w": "generally", "b": [0.5428, 0.1597, 0.6186, 0.1811]}, {"w": "have", "b": [0.6259, 0.1597, 0.6643, 0.1811]}, {"w": "one", "b": [0.6716, 0.1597, 0.7024, 0.1811]}, {"w": "or", "b": [0.7097, 0.1597, 0.7281, 0.1811]}, {"w": "the", "b": [0.7353, 0.1597, 0.7616, 0.1811]}, {"w": "other.", "b": [0.7689, 0.1597, 0.817, 0.1811]}, {"w": "The", "b": [0.8243, 0.1597, 0.8571, 0.1811]}, {"w": "predict_proba()", "b": [0.1429, 0.1829, 0.2913, 0.1979]}, {"w": "method", "b": [0.2976, 0.1797, 0.3626, 0.2011]}, {"w": "returns", "b": [0.3689, 0.1797, 0.4297, 0.2011]}, {"w": "an", "b": [0.436, 0.1797, 0.4565, 0.2011]}, {"w": "array", "b": [0.4628, 0.1797, 0.5058, 0.2011]}, {"w": "containing", "b": [0.5121, 0.1797, 0.6017, 0.2011]}, {"w": "a", "b": [0.608, 0.1797, 0.6172, 0.2011]}, {"w": "row", "b": [0.6235, 0.1797, 0.6561, 0.2011]}, {"w": "per", "b": [0.6624, 0.1797, 0.6899, 0.2011]}, {"w": "instance", "b": [0.6962, 0.1797, 0.7654, 0.2011]}, {"w": "and", "b": [0.7717, 0.1797, 0.8033, 0.2011]}, {"w": "a", "b": [0.8096, 0.1797, 0.8187, 0.2011]}, {"w": "col‐", "b": [0.825, 0.1797, 0.8571, 0.2011]}, {"w": "umn", "b": [0.1428, 0.1987, 0.1824, 0.2201]}, {"w": "per", "b": [0.1883, 0.1987, 0.2158, 0.2201]}, {"w": "class,", "b": [0.2218, 0.1987, 0.265, 0.2201]}, {"w": "each", "b": [0.271, 0.1987, 0.3089, 0.2201]}, {"w": "containing", "b": [0.3149, 0.1987, 0.4045, 0.2201]}, {"w": "the", "b": [0.4105, 0.1987, 0.4368, 0.2201]}, {"w": "probability", "b": [0.4428, 0.1987, 0.5347, 0.2201]}, {"w": "that", "b": [0.5407, 0.1987, 0.5732, 0.2201]}, {"w": "the", "b": [0.5792, 0.1987, 0.6055, 0.2201]}, {"w": "given", "b": [0.6115, 0.1987, 0.6567, 0.2201]}, {"w": "instance", "b": [0.6627, 0.1987, 0.7318, 0.2201]}, {"w": "belongs", "b": [0.7378, 0.1987, 0.8019, 0.2201]}, {"w": "to", "b": [0.8079, 0.1987, 0.8248, 0.2201]}, {"w": "the", "b": [0.8308, 0.1987, 0.8571, 0.2201]}, {"w": "given", "b": [0.1429, 0.2178, 0.1881, 0.2392]}, {"w": "class", "b": [0.1928, 0.2178, 0.2313, 0.2392]}, {"w": "(e.g.,", "b": [0.2361, 0.2178, 0.2761, 0.2392]}, {"w": "70%", "b": [0.2809, 0.2178, 0.3166, 0.2392]}, {"w": "chance", "b": [0.3213, 0.2178, 0.3795, 0.2392]}, {"w": "that", "b": [0.3842, 0.2178, 0.4168, 0.2392]}, {"w": "the", "b": [0.4215, 0.2178, 0.4479, 0.2392]}, {"w": "image", "b": [0.4526, 0.2178, 0.503, 0.2392]}, {"w": "represents", "b": [0.5077, 0.2178, 0.5933, 0.2392]}, {"w": "a", "b": [0.598, 0.2178, 0.6072, 0.2392]}, {"w": "5):", "b": [0.6119, 0.2178, 0.6339, 0.2392]}]}, {"id": "b_1", "type": "paragraph", "text": "from sklearn.ensemble import RandomForestClassifier", "words": [{"w": "from", "b": [0.1766, 0.2497, 0.2103, 0.2626]}, {"w": "sklearn.ensemble", "b": [0.2187, 0.2497, 0.3537, 0.2626]}, {"w": "import", "b": [0.3621, 0.2497, 0.4127, 0.2626]}, {"w": "RandomForestClassifier", "b": [0.4211, 0.2497, 0.6066, 0.2626]}]}, {"id": "b_2", "type": "paragraph", "text": "forest_clf = RandomForestClassifier(random_state=42) y_probas_forest = cross_val_predict(forest_clf, X_train, y_train_5, cv=3, method=\"predict_proba\")", "words": [{"w": "forest_clf", "b": [0.1766, 0.2806, 0.2609, 0.2934]}, {"w": "=", "b": [0.2693, 0.2806, 0.2778, 0.2934]}, {"w": "RandomForestClassifier(random_state=42)", "b": [0.2862, 0.2806, 0.6151, 0.2934]}, {"w": "y_probas_forest", "b": [0.1766, 0.296, 0.3031, 0.3089]}, {"w": "=", "b": [0.3115, 0.296, 0.3199, 0.3089]}, {"w": "cross_val_predict(forest_clf,", "b": [0.3284, 0.296, 0.5729, 0.3089]}, {"w": "X_train,", "b": [0.5813, 0.296, 0.6488, 0.3089]}, {"w": "y_train_5,", "b": [0.6572, 0.296, 0.7416, 0.3089]}, {"w": "cv=3,", "b": [0.75, 0.296, 0.7922, 0.3089]}, {"w": "method=\"predict_proba\")", "b": [0.4802, 0.3114, 0.6741, 0.3243]}]}, {"id": "b_3", "type": "paragraph", "text": "But to plot a ROC curve, you need scores, not probabilities. A simple solution is to use the positive class’s probability as the score:", "words": [{"w": "But", "b": [0.1429, 0.3321, 0.1725, 0.3535]}, {"w": "to", "b": [0.1791, 0.3321, 0.196, 0.3535]}, {"w": "plot", "b": [0.2026, 0.3321, 0.2357, 0.3535]}, {"w": "a", "b": [0.2423, 0.3321, 0.2514, 0.3535]}, {"w": "ROC", "b": [0.258, 0.3321, 0.3007, 0.3535]}, {"w": "curve,", "b": [0.3072, 0.3321, 0.3587, 0.3535]}, {"w": "you", "b": [0.3652, 0.3321, 0.3965, 0.3535]}, {"w": "need", "b": [0.403, 0.3321, 0.4431, 0.3535]}, {"w": "scores,", "b": [0.4496, 0.3321, 0.5057, 0.3535]}, {"w": "not", "b": [0.5122, 0.3321, 0.5406, 0.3535]}, {"w": "probabilities.", "b": [0.5471, 0.3321, 0.6564, 0.3535]}, {"w": "A", "b": [0.6629, 0.3321, 0.6773, 0.3535]}, {"w": "simple", "b": [0.6838, 0.3321, 0.7388, 0.3535]}, {"w": "solution", "b": [0.7453, 0.3321, 0.8139, 0.3535]}, {"w": "is", "b": [0.8204, 0.3321, 0.8336, 0.3535]}, {"w": "to", "b": [0.8402, 0.3321, 0.8571, 0.3535]}, {"w": "use", "b": [0.1428, 0.3511, 0.1704, 0.3725]}, {"w": "the", "b": [0.1751, 0.3511, 0.2015, 0.3725]}, {"w": "positive", "b": [0.2062, 0.3511, 0.2714, 0.3725]}, {"w": "class’s", "b": [0.2761, 0.3511, 0.3241, 0.3725]}, {"w": "probability", "b": [0.3288, 0.3511, 0.4208, 0.3725]}, {"w": "as", "b": [0.4255, 0.3511, 0.4423, 0.3725]}, {"w": "the", "b": [0.447, 0.3511, 0.4734, 0.3725]}, {"w": "score:", "b": [0.4781, 0.3511, 0.5265, 0.3725]}]}, {"id": "b_4", "type": "paragraph", "text": "y_scores_forest = y_probas_forest[:, 1] # score = proba of positive class fpr_forest, tpr_forest, thresholds_forest = roc_curve(y_train_5,y_scores_forest)", "words": [{"w": "y_scores_forest", "b": [0.1766, 0.3831, 0.3031, 0.3959]}, {"w": "=", "b": [0.3115, 0.3831, 0.3199, 0.3959]}, {"w": "y_probas_forest[:,", "b": [0.3284, 0.3831, 0.4802, 0.3959]}, {"w": "1]", "b": [0.4886, 0.3831, 0.5054, 0.3959]}, {"w": "#", "b": [0.5307, 0.3831, 0.5392, 0.3959]}, {"w": "score", "b": [0.5476, 0.3831, 0.5898, 0.3959]}, {"w": "=", "b": [0.5982, 0.3831, 0.6066, 0.3959]}, {"w": "proba", "b": [0.6151, 0.3831, 0.6572, 0.3959]}, {"w": "of", "b": [0.6657, 0.3831, 0.6825, 0.3959]}, {"w": "positive", "b": [0.691, 0.3831, 0.7584, 0.3959]}, {"w": "class", "b": [0.7669, 0.3831, 0.809, 0.3959]}, {"w": "fpr_forest,", "b": [0.1766, 0.3985, 0.2693, 0.4114]}, {"w": "tpr_forest,", "b": [0.2778, 0.3985, 0.3705, 0.4114]}, {"w": "thresholds_forest", "b": [0.379, 0.3985, 0.5223, 0.4114]}, {"w": "=", "b": [0.5307, 0.3985, 0.5392, 0.4114]}, {"w": "roc_curve(y_train_5,y_scores_forest)", "b": [0.5476, 0.3985, 0.8512, 0.4114]}]}, {"id": "b_5", "type": "paragraph", "text": "Now you are ready to plot the ROC curve. It is useful to plot the first ROC curve as well to see how they compare (Figure 3-7):", "words": [{"w": "Now", "b": [0.1429, 0.4191, 0.1827, 0.4405]}, {"w": "you", "b": [0.1887, 0.4191, 0.22, 0.4405]}, {"w": "are", "b": [0.226, 0.4191, 0.2517, 0.4405]}, {"w": "ready", "b": [0.2577, 0.4191, 0.304, 0.4405]}, {"w": "to", "b": [0.3101, 0.4191, 0.327, 0.4405]}, {"w": "plot", "b": [0.3331, 0.4191, 0.3662, 0.4405]}, {"w": "the", "b": [0.3722, 0.4191, 0.3986, 0.4405]}, {"w": "ROC", "b": [0.4046, 0.4191, 0.4473, 0.4405]}, {"w": "curve.", "b": [0.4533, 0.4191, 0.5048, 0.4405]}, {"w": "It", "b": [0.5108, 0.4191, 0.5235, 0.4405]}, {"w": "is", "b": [0.5295, 0.4191, 0.5427, 0.4405]}, {"w": "useful", "b": [0.5487, 0.4191, 0.5988, 0.4405]}, {"w": "to", "b": [0.6048, 0.4191, 0.6218, 0.4405]}, {"w": "plot", "b": [0.6278, 0.4191, 0.661, 0.4405]}, {"w": "the", "b": [0.667, 0.4191, 0.6933, 0.4405]}, {"w": "first", "b": [0.6994, 0.4191, 0.7328, 0.4405]}, {"w": "ROC", "b": [0.7389, 0.4191, 0.7816, 0.4405]}, {"w": "curve", "b": [0.7876, 0.4191, 0.8343, 0.4405]}, {"w": "as", "b": [0.8403, 0.4191, 0.8571, 0.4405]}, {"w": "well", "b": [0.1429, 0.4382, 0.1765, 0.4596]}, {"w": "to", "b": [0.1813, 0.4382, 0.1982, 0.4596]}, {"w": "see", "b": [0.203, 0.4382, 0.2283, 0.4596]}, {"w": "how", "b": [0.2331, 0.4382, 0.2691, 0.4596]}, {"w": "they", "b": [0.2738, 0.4382, 0.3097, 0.4596]}, {"w": "compare", "b": [0.3144, 0.4382, 0.3872, 0.4596]}, {"w": "(Figure", "b": [0.3919, 0.4382, 0.4531, 0.4596]}, {"w": "3-7):", "b": [0.4578, 0.4382, 0.4972, 0.4596]}]}, {"id": "b_6", "type": "paragraph", "text": "plt.plot(fpr, tpr, \"b:\", label=\"SGD\") plot_roc_curve(fpr_forest, tpr_forest, \"Random Forest\") plt.legend(loc=\"lower right\") plt.show()", "words": [{"w": "plt.plot(fpr,", "b": [0.1766, 0.4702, 0.2862, 0.483]}, {"w": "tpr,", "b": [0.2946, 0.4702, 0.3284, 0.483]}, {"w": "\"b:\",", "b": [0.3368, 0.4702, 0.379, 0.483]}, {"w": "label=\"SGD\")", "b": [0.3874, 0.4702, 0.4886, 0.483]}, {"w": "plot_roc_curve(fpr_forest,", "b": [0.1766, 0.4856, 0.3958, 0.4984]}, {"w": "tpr_forest,", "b": [0.4043, 0.4856, 0.497, 0.4984]}, {"w": "\"Random", "b": [0.5054, 0.4856, 0.5645, 0.4984]}, {"w": "Forest\")", "b": [0.5729, 0.4856, 0.6404, 0.4984]}, {"w": "plt.legend(loc=\"lower", "b": [0.1766, 0.501, 0.3537, 0.5138]}, {"w": "right\")", "b": [0.3621, 0.501, 0.4211, 0.5138]}, {"w": "plt.show()", "b": [0.1766, 0.5164, 0.2609, 0.5293]}]}, {"id": "b_7", "type": "equation", "text": "Figure 3-7. Comparing ROC curves", "words": [{"w": "Figure", "b": [0.1429, 0.8383, 0.1943, 0.8599]}, {"w": "3-7.", "b": [0.1991, 0.8383, 0.2308, 0.8599]}, {"w": "Comparing", "b": [0.2356, 0.8383, 0.3272, 0.8599]}, {"w": "ROC", "b": [0.332, 0.8383, 0.3727, 0.8599]}, {"w": "curves", "b": [0.3774, 0.8383, 0.4287, 0.8599]}]}, {"id": "b_8", "type": "paragraph", "text": "Performance Measures | 101", "words": [{"w": "Performance", "b": [0.6617, 0.9225, 0.7373, 0.9388]}, {"w": "Measures", "b": [0.7401, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "101", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 128, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "As you can see in Figure 3-7, the RandomForestClassifier’s ROC curve looks much better than the SGDClassifier’s: it comes much closer to the top-left corner. As a result, its ROC AUC score is also significantly better:", "words": [{"w": "As", "b": [0.1429, 0.08, 0.1649, 0.1014]}, {"w": "you", "b": [0.1705, 0.08, 0.2017, 0.1014]}, {"w": "can", "b": [0.2073, 0.08, 0.2367, 0.1014]}, {"w": "see", "b": [0.2423, 0.08, 0.2677, 0.1014]}, {"w": "in", "b": [0.2733, 0.08, 0.2902, 0.1014]}, {"w": "Figure", "b": [0.2958, 0.08, 0.3498, 0.1014]}, {"w": "3-7,", "b": [0.3554, 0.08, 0.3876, 0.1014]}, {"w": "the", "b": [0.3932, 0.08, 0.4195, 0.1014]}, {"w": "RandomForestClassifier’s", "b": [0.4251, 0.08, 0.6531, 0.1014]}, {"w": "ROC", "b": [0.6587, 0.08, 0.7015, 0.1014]}, {"w": "curve", "b": [0.7071, 0.08, 0.7538, 0.1014]}, {"w": "looks", "b": [0.7594, 0.08, 0.8039, 0.1014]}, {"w": "much", "b": [0.8095, 0.08, 0.8571, 0.1014]}, {"w": "better", "b": [0.1429, 0.0999, 0.1916, 0.1213]}, {"w": "than", "b": [0.1993, 0.0999, 0.2374, 0.1213]}, {"w": "the", "b": [0.2451, 0.0999, 0.2715, 0.1213]}, {"w": "SGDClassifier’s:", "b": [0.2792, 0.0999, 0.4229, 0.1213]}, {"w": "it", "b": [0.4307, 0.0999, 0.4426, 0.1213]}, {"w": "comes", "b": [0.4504, 0.0999, 0.5034, 0.1213]}, {"w": "much", "b": [0.5112, 0.0999, 0.5588, 0.1213]}, {"w": "closer", "b": [0.5666, 0.0999, 0.6155, 0.1213]}, {"w": "to", "b": [0.6233, 0.0999, 0.6403, 0.1213]}, {"w": "the", "b": [0.648, 0.0999, 0.6744, 0.1213]}, {"w": "top-left", "b": [0.6821, 0.0999, 0.7441, 0.1213]}, {"w": "corner.", "b": [0.7518, 0.0999, 0.8104, 0.1213]}, {"w": "As", "b": [0.8182, 0.0999, 0.8402, 0.1213]}, {"w": "a", "b": [0.848, 0.0999, 0.8571, 0.1213]}, {"w": "result,", "b": [0.1429, 0.119, 0.1945, 0.1404]}, {"w": "its", "b": [0.1993, 0.119, 0.2188, 0.1404]}, {"w": "ROC", "b": [0.2236, 0.119, 0.2663, 0.1404]}, {"w": "AUC", "b": [0.271, 0.119, 0.3134, 0.1404]}, {"w": "score", "b": [0.3181, 0.119, 0.3618, 0.1404]}, {"w": "is", "b": [0.3665, 0.119, 0.3798, 0.1404]}, {"w": "also", "b": [0.3845, 0.119, 0.4172, 0.1404]}, {"w": "significantly", "b": [0.4219, 0.119, 0.5238, 0.1404]}, {"w": "better:", "b": [0.5285, 0.119, 0.5825, 0.1404]}]}, {"id": "b_1", "type": "equation", "text": ">>> roc_auc_score(y_train_5, y_scores_forest) 0.9983436731328145", "words": [{"w": ">>>", "b": [0.1766, 0.1509, 0.2019, 0.1638]}, {"w": "roc_auc_score(y_train_5,", "b": [0.2103, 0.1509, 0.4127, 0.1638]}, {"w": "y_scores_forest)", "b": [0.4211, 0.1509, 0.5561, 0.1638]}, {"w": "0.9983436731328145", "b": [0.1766, 0.1663, 0.3284, 0.1792]}]}, {"id": "b_2", "type": "paragraph", "text": "Try measuring the precision and recall scores: you should find 99.0% precision and 86.6% recall. Not too bad!", "words": [{"w": "Try", "b": [0.1429, 0.187, 0.1719, 0.2084]}, {"w": "measuring", "b": [0.1785, 0.187, 0.2667, 0.2084]}, {"w": "the", "b": [0.2734, 0.187, 0.2997, 0.2084]}, {"w": "precision", "b": [0.3063, 0.187, 0.3835, 0.2084]}, {"w": "and", "b": [0.3901, 0.187, 0.4216, 0.2084]}, {"w": "recall", "b": [0.4283, 0.187, 0.4734, 0.2084]}, {"w": "scores:", "b": [0.48, 0.187, 0.5361, 0.2084]}, {"w": "you", "b": [0.5427, 0.187, 0.5739, 0.2084]}, {"w": "should", "b": [0.5806, 0.187, 0.6373, 0.2084]}, {"w": "find", "b": [0.6439, 0.187, 0.6781, 0.2084]}, {"w": "99.0%", "b": [0.6847, 0.187, 0.7352, 0.2084]}, {"w": "precision", "b": [0.7418, 0.187, 0.819, 0.2084]}, {"w": "and", "b": [0.8256, 0.187, 0.8571, 0.2084]}, {"w": "86.6%", "b": [0.1429, 0.206, 0.1934, 0.2274]}, {"w": "recall.", "b": [0.1981, 0.206, 0.2479, 0.2274]}, {"w": "Not", "b": [0.2526, 0.206, 0.2846, 0.2274]}, {"w": "too", "b": [0.2893, 0.206, 0.3169, 0.2274]}, {"w": "bad!", "b": [0.3216, 0.206, 0.3581, 0.2274]}]}, {"id": "b_3", "type": "paragraph", "text": "Hopefully you now know how to train binary classifiers, choose the appropriate met‐ ric for your task, evaluate your classifiers using cross-validation, select the precision/ recall tradeoff that fits your needs, and compare various models using ROC curves and ROC AUC scores. Now let’s try to detect more than just the 5s.", "words": [{"w": "Hopefully", "b": [0.1429, 0.2341, 0.226, 0.2556]}, {"w": "you", "b": [0.2313, 0.2341, 0.2626, 0.2556]}, {"w": "now", "b": [0.2678, 0.2341, 0.3041, 0.2556]}, {"w": "know", "b": [0.3094, 0.2341, 0.3561, 0.2556]}, {"w": "how", "b": [0.3613, 0.2341, 0.3974, 0.2556]}, {"w": "to", "b": [0.4027, 0.2341, 0.4196, 0.2556]}, {"w": "train", "b": [0.4249, 0.2341, 0.4651, 0.2556]}, {"w": "binary", "b": [0.4704, 0.2341, 0.525, 0.2556]}, {"w": "classifiers,", "b": [0.5303, 0.2341, 0.6151, 0.2556]}, {"w": "choose", "b": [0.6204, 0.2341, 0.6781, 0.2556]}, {"w": "the", "b": [0.6834, 0.2341, 0.7097, 0.2556]}, {"w": "appropriate", "b": [0.715, 0.2341, 0.8122, 0.2556]}, {"w": "met‐", "b": [0.8175, 0.2341, 0.8571, 0.2556]}, {"w": "ric", "b": [0.1428, 0.2532, 0.165, 0.2746]}, {"w": "for", "b": [0.1708, 0.2532, 0.1953, 0.2746]}, {"w": "your", "b": [0.2011, 0.2532, 0.2401, 0.2746]}, {"w": "task,", "b": [0.2459, 0.2532, 0.2841, 0.2746]}, {"w": "evaluate", "b": [0.2899, 0.2532, 0.3579, 0.2746]}, {"w": "your", "b": [0.3637, 0.2532, 0.4026, 0.2746]}, {"w": "classifiers", "b": [0.4084, 0.2532, 0.4885, 0.2746]}, {"w": "using", "b": [0.4943, 0.2532, 0.5398, 0.2746]}, {"w": "cross-validation,", "b": [0.5456, 0.2532, 0.6836, 0.2746]}, {"w": "select", "b": [0.6894, 0.2532, 0.7351, 0.2746]}, {"w": "the", "b": [0.741, 0.2532, 0.7673, 0.2746]}, {"w": "precision/", "b": [0.7731, 0.2532, 0.8571, 0.2746]}, {"w": "recall", "b": [0.1429, 0.2722, 0.1879, 0.2937]}, {"w": "tradeoff", "b": [0.195, 0.2722, 0.261, 0.2937]}, {"w": "that", "b": [0.2681, 0.2722, 0.3007, 0.2937]}, {"w": "fits", "b": [0.3077, 0.2722, 0.3335, 0.2937]}, {"w": "your", "b": [0.3405, 0.2722, 0.3795, 0.2937]}, {"w": "needs,", "b": [0.3866, 0.2722, 0.4391, 0.2937]}, {"w": "and", "b": [0.4461, 0.2722, 0.4777, 0.2937]}, {"w": "compare", "b": [0.4847, 0.2722, 0.5575, 0.2937]}, {"w": "various", "b": [0.5645, 0.2722, 0.626, 0.2937]}, {"w": "models", "b": [0.633, 0.2722, 0.6935, 0.2937]}, {"w": "using", "b": [0.7005, 0.2722, 0.746, 0.2937]}, {"w": "ROC", "b": [0.753, 0.2722, 0.7957, 0.2937]}, {"w": "curves", "b": [0.8028, 0.2722, 0.8571, 0.2937]}, {"w": "and", "b": [0.1429, 0.2913, 0.1744, 0.3127]}, {"w": "ROC", "b": [0.1791, 0.2913, 0.2219, 0.3127]}, {"w": "AUC", "b": [0.2266, 0.2913, 0.269, 0.3127]}, {"w": "scores.", "b": [0.2737, 0.2913, 0.3298, 0.3127]}, {"w": "Now", "b": [0.3345, 0.2913, 0.3743, 0.3127]}, {"w": "let’s", "b": [0.3791, 0.2913, 0.4093, 0.3127]}, {"w": "try", "b": [0.414, 0.2913, 0.4383, 0.3127]}, {"w": "to", "b": [0.443, 0.2913, 0.46, 0.3127]}, {"w": "detect", "b": [0.4647, 0.2913, 0.5149, 0.3127]}, {"w": "more", "b": [0.5197, 0.2913, 0.5639, 0.3127]}, {"w": "than", "b": [0.5687, 0.2913, 0.6067, 0.3127]}, {"w": "just", "b": [0.6114, 0.2913, 0.6418, 0.3127]}, {"w": "the", "b": [0.6465, 0.2913, 0.6729, 0.3127]}, {"w": "5s.", "b": [0.6776, 0.2913, 0.7, 0.3127]}]}, {"id": "b_4", "type": "paragraph", "text": "Multiclass Classification", "words": [{"w": "Multiclass", "b": [0.1428, 0.3257, 0.2661, 0.36]}, {"w": "Classification", "b": [0.2721, 0.3257, 0.434, 0.36]}]}, {"id": "b_5", "type": "paragraph", "text": "Whereas binary classifiers distinguish between two classes, multiclass classifiers (also called multinomial classifiers) can distinguish between more than two classes.", "words": [{"w": "Whereas", "b": [0.1429, 0.3669, 0.2164, 0.3883]}, {"w": "binary", "b": [0.2226, 0.3669, 0.2772, 0.3883]}, {"w": "classifiers", "b": [0.2834, 0.3669, 0.3634, 0.3883]}, {"w": "distinguish", "b": [0.3696, 0.3669, 0.4623, 0.3883]}, {"w": "between", "b": [0.4685, 0.3669, 0.5377, 0.3883]}, {"w": "two", "b": [0.5438, 0.3669, 0.5751, 0.3883]}, {"w": "classes,", "b": [0.5812, 0.3669, 0.641, 0.3883]}, {"w": "multiclass", "b": [0.6472, 0.3667, 0.7278, 0.3883]}, {"w": "classifiers", "b": [0.734, 0.3667, 0.8111, 0.3883]}, {"w": "(also", "b": [0.8172, 0.3669, 0.8571, 0.3883]}, {"w": "called", "b": [0.1428, 0.3859, 0.1912, 0.4073]}, {"w": "multinomial", "b": [0.1959, 0.3857, 0.2968, 0.4073]}, {"w": "classifiers)", "b": [0.3016, 0.3857, 0.3859, 0.4073]}, {"w": "can", "b": [0.3907, 0.3859, 0.42, 0.4073]}, {"w": "distinguish", "b": [0.4247, 0.3859, 0.5175, 0.4073]}, {"w": "between", "b": [0.5222, 0.3859, 0.5914, 0.4073]}, {"w": "more", "b": [0.5961, 0.3859, 0.6404, 0.4073]}, {"w": "than", "b": [0.6451, 0.3859, 0.6831, 0.4073]}, {"w": "two", "b": [0.6878, 0.3859, 0.7191, 0.4073]}, {"w": "classes.", "b": [0.7238, 0.3859, 0.7836, 0.4073]}]}, {"id": "b_6", "type": "paragraph", "text": "Some algorithms (such as Random Forest classifiers or naive Bayes classifiers) are capable of handling multiple classes directly. Others (such as Support Vector Machine classifiers or Linear classifiers) are strictly binary classifiers. However, there are vari‐ ous strategies that you can use to perform multiclass classification using multiple binary classifiers.", "words": [{"w": "Some", "b": [0.1428, 0.414, 0.1893, 0.4354]}, {"w": "algorithms", "b": [0.1972, 0.414, 0.2875, 0.4354]}, {"w": "(such", "b": [0.2954, 0.414, 0.3413, 0.4354]}, {"w": "as", "b": [0.3492, 0.414, 0.366, 0.4354]}, {"w": "Random", "b": [0.374, 0.414, 0.4465, 0.4354]}, {"w": "Forest", "b": [0.4545, 0.414, 0.5063, 0.4354]}, {"w": "classifiers", "b": [0.5142, 0.414, 0.5943, 0.4354]}, {"w": "or", "b": [0.6023, 0.414, 0.6206, 0.4354]}, {"w": "naive", "b": [0.6286, 0.414, 0.6732, 0.4354]}, {"w": "Bayes", "b": [0.6811, 0.414, 0.7282, 0.4354]}, {"w": "classifiers)", "b": [0.7362, 0.414, 0.8235, 0.4354]}, {"w": "are", "b": [0.8314, 0.414, 0.8571, 0.4354]}, {"w": "capable", "b": [0.1429, 0.4331, 0.2052, 0.4545]}, {"w": "of", "b": [0.2101, 0.4331, 0.2269, 0.4545]}, {"w": "handling", "b": [0.2317, 0.4331, 0.3064, 0.4545]}, {"w": "multiple", "b": [0.3113, 0.4331, 0.3812, 0.4545]}, {"w": "classes", "b": [0.3861, 0.4331, 0.4411, 0.4545]}, {"w": "directly.", "b": [0.446, 0.4331, 0.5124, 0.4545]}, {"w": "Others", "b": [0.5173, 0.4331, 0.5745, 0.4545]}, {"w": "(such", "b": [0.5794, 0.4331, 0.6253, 0.4545]}, {"w": "as", "b": [0.6301, 0.4331, 0.6469, 0.4545]}, {"w": "Support", "b": [0.6518, 0.4331, 0.7193, 0.4545]}, {"w": "Vector", "b": [0.7242, 0.4331, 0.7792, 0.4545]}, {"w": "Machine", "b": [0.784, 0.4331, 0.8571, 0.4545]}, {"w": "classifiers", "b": [0.1429, 0.4521, 0.2229, 0.4735]}, {"w": "or", "b": [0.2289, 0.4521, 0.2472, 0.4735]}, {"w": "Linear", "b": [0.2531, 0.4521, 0.3071, 0.4735]}, {"w": "classifiers)", "b": [0.313, 0.4521, 0.4003, 0.4735]}, {"w": "are", "b": [0.4062, 0.4521, 0.4319, 0.4735]}, {"w": "strictly", "b": [0.4378, 0.4521, 0.4952, 0.4735]}, {"w": "binary", "b": [0.5011, 0.4521, 0.5557, 0.4735]}, {"w": "classifiers.", "b": [0.5616, 0.4521, 0.6464, 0.4735]}, {"w": "However,", "b": [0.6524, 0.4521, 0.7312, 0.4735]}, {"w": "there", "b": [0.7371, 0.4521, 0.7801, 0.4735]}, {"w": "are", "b": [0.786, 0.4521, 0.8117, 0.4735]}, {"w": "vari‐", "b": [0.8176, 0.4521, 0.8571, 0.4735]}, {"w": "ous", "b": [0.1429, 0.4712, 0.1722, 0.4926]}, {"w": "strategies", "b": [0.1808, 0.4712, 0.2583, 0.4926]}, {"w": "that", "b": [0.2669, 0.4712, 0.2994, 0.4926]}, {"w": "you", "b": [0.308, 0.4712, 0.3393, 0.4926]}, {"w": "can", "b": [0.3479, 0.4712, 0.3772, 0.4926]}, {"w": "use", "b": [0.3858, 0.4712, 0.4134, 0.4926]}, {"w": "to", "b": [0.4219, 0.4712, 0.4389, 0.4926]}, {"w": "perform", "b": [0.4475, 0.4712, 0.5166, 0.4926]}, {"w": "multiclass", "b": [0.5252, 0.4712, 0.6086, 0.4926]}, {"w": "classification", "b": [0.6172, 0.4712, 0.7246, 0.4926]}, {"w": "using", "b": [0.7331, 0.4712, 0.7786, 0.4926]}, {"w": "multiple", "b": [0.7872, 0.4712, 0.8571, 0.4926]}, {"w": "binary", "b": [0.1429, 0.4902, 0.1975, 0.5116]}, {"w": "classifiers.", "b": [0.2022, 0.4902, 0.287, 0.5116]}]}, {"id": "b_7", "type": "paragraph", "text": "For example, one way to create a system that can classify the digit images into 10 classes (from 0 to 9) is to train 10 binary classifiers, one for each digit (a 0-detector, a 1-detector, a 2-detector, and so on). Then when you want to classify an image, you get the decision score from each classifier for that image and you select the class whose classifier outputs the highest score. This is called the one-versus-all (OvA) strategy (also called one-versus-the-rest).", "words": [{"w": "For", "b": [0.1429, 0.5183, 0.1718, 0.5398]}, {"w": "example,", "b": [0.1796, 0.5183, 0.2539, 0.5398]}, {"w": "one", "b": [0.2617, 0.5183, 0.2926, 0.5398]}, {"w": "way", "b": [0.3003, 0.5183, 0.3329, 0.5398]}, {"w": "to", "b": [0.3407, 0.5183, 0.3577, 0.5398]}, {"w": "create", "b": [0.3655, 0.5183, 0.4148, 0.5398]}, {"w": "a", "b": [0.4226, 0.5183, 0.4317, 0.5398]}, {"w": "system", "b": [0.4395, 0.5183, 0.4966, 0.5398]}, {"w": "that", "b": [0.5044, 0.5183, 0.537, 0.5398]}, {"w": "can", "b": [0.5448, 0.5183, 0.5741, 0.5398]}, {"w": "classify", "b": [0.5819, 0.5183, 0.6421, 0.5398]}, {"w": "the", "b": [0.6499, 0.5183, 0.6762, 0.5398]}, {"w": "digit", "b": [0.684, 0.5183, 0.7222, 0.5398]}, {"w": "images", "b": [0.73, 0.5183, 0.788, 0.5398]}, {"w": "into", "b": [0.7958, 0.5183, 0.8294, 0.5398]}, {"w": "10", "b": [0.8372, 0.5183, 0.8572, 0.5398]}, {"w": "classes", "b": [0.1429, 0.5374, 0.1979, 0.5588]}, {"w": "(from", "b": [0.2032, 0.5374, 0.252, 0.5588]}, {"w": "0", "b": [0.2572, 0.5374, 0.2672, 0.5588]}, {"w": "to", "b": [0.2725, 0.5374, 0.2895, 0.5588]}, {"w": "9)", "b": [0.2948, 0.5374, 0.312, 0.5588]}, {"w": "is", "b": [0.3173, 0.5374, 0.3305, 0.5588]}, {"w": "to", "b": [0.3358, 0.5374, 0.3528, 0.5588]}, {"w": "train", "b": [0.3581, 0.5374, 0.3983, 0.5588]}, {"w": "10", "b": [0.4036, 0.5374, 0.4236, 0.5588]}, {"w": "binary", "b": [0.4289, 0.5374, 0.4835, 0.5588]}, {"w": "classifiers,", "b": [0.4888, 0.5374, 0.5736, 0.5588]}, {"w": "one", "b": [0.5789, 0.5374, 0.6098, 0.5588]}, {"w": "for", "b": [0.615, 0.5374, 0.6396, 0.5588]}, {"w": "each", "b": [0.6449, 0.5374, 0.6828, 0.5588]}, {"w": "digit", "b": [0.6881, 0.5374, 0.7263, 0.5588]}, {"w": "(a", "b": [0.7316, 0.5374, 0.748, 0.5588]}, {"w": "0-detector,", "b": [0.7533, 0.5374, 0.8427, 0.5588]}, {"w": "a", "b": [0.848, 0.5374, 0.8571, 0.5588]}, {"w": "1-detector,", "b": [0.1429, 0.5564, 0.2323, 0.5779]}, {"w": "a", "b": [0.237, 0.5564, 0.2462, 0.5779]}, {"w": "2-detector,", "b": [0.2509, 0.5564, 0.3403, 0.5779]}, {"w": "and", "b": [0.3451, 0.5564, 0.3766, 0.5779]}, {"w": "so", "b": [0.3813, 0.5564, 0.3996, 0.5779]}, {"w": "on).", "b": [0.4043, 0.5564, 0.4383, 0.5779]}, {"w": "Then", "b": [0.443, 0.5564, 0.4873, 0.5779]}, {"w": "when", "b": [0.492, 0.5564, 0.5376, 0.5779]}, {"w": "you", "b": [0.5424, 0.5564, 0.5736, 0.5779]}, {"w": "want", "b": [0.5784, 0.5564, 0.6191, 0.5779]}, {"w": "to", "b": [0.6239, 0.5564, 0.6408, 0.5779]}, {"w": "classify", "b": [0.6456, 0.5564, 0.7058, 0.5779]}, {"w": "an", "b": [0.7105, 0.5564, 0.731, 0.5779]}, {"w": "image,", "b": [0.7358, 0.5564, 0.7909, 0.5779]}, {"w": "you", "b": [0.7956, 0.5564, 0.8269, 0.5779]}, {"w": "get", "b": [0.8316, 0.5564, 0.8566, 0.5779]}, {"w": "the", "b": [0.1429, 0.5755, 0.1692, 0.5969]}, {"w": "decision", "b": [0.1756, 0.5755, 0.2451, 0.5969]}, {"w": "score", "b": [0.2515, 0.5755, 0.2951, 0.5969]}, {"w": "from", "b": [0.3015, 0.5755, 0.3431, 0.5969]}, {"w": "each", "b": [0.3495, 0.5755, 0.3874, 0.5969]}, {"w": "classifier", "b": [0.3938, 0.5755, 0.4662, 0.5969]}, {"w": "for", "b": [0.4726, 0.5755, 0.4971, 0.5969]}, {"w": "that", "b": [0.5035, 0.5755, 0.5361, 0.5969]}, {"w": "image", "b": [0.5425, 0.5755, 0.5929, 0.5969]}, {"w": "and", "b": [0.5993, 0.5755, 0.6308, 0.5969]}, {"w": "you", "b": [0.6372, 0.5755, 0.6684, 0.5969]}, {"w": "select", "b": [0.6748, 0.5755, 0.7206, 0.5969]}, {"w": "the", "b": [0.727, 0.5755, 0.7533, 0.5969]}, {"w": "class", "b": [0.7597, 0.5755, 0.7982, 0.5969]}, {"w": "whose", "b": [0.8046, 0.5755, 0.8571, 0.5969]}, {"w": "classifier", "b": [0.1428, 0.5945, 0.2153, 0.6159]}, {"w": "outputs", "b": [0.2223, 0.5945, 0.2863, 0.6159]}, {"w": "the", "b": [0.2934, 0.5945, 0.3197, 0.6159]}, {"w": "highest", "b": [0.3268, 0.5945, 0.3872, 0.6159]}, {"w": "score.", "b": [0.3942, 0.5945, 0.4427, 0.6159]}, {"w": "This", "b": [0.4497, 0.5945, 0.4869, 0.6159]}, {"w": "is", "b": [0.494, 0.5945, 0.5072, 0.6159]}, {"w": "called", "b": [0.5142, 0.5945, 0.5626, 0.6159]}, {"w": "the", "b": [0.5696, 0.5945, 0.5959, 0.6159]}, {"w": "one-versus-all", "b": [0.603, 0.5943, 0.7161, 0.6159]}, {"w": "(OvA)", "b": [0.7232, 0.5945, 0.7776, 0.6159]}, {"w": "strategy", "b": [0.7846, 0.5945, 0.8501, 0.6159]}, {"w": "(also", "b": [0.1429, 0.6136, 0.1828, 0.635]}, {"w": "called", "b": [0.1875, 0.6136, 0.2358, 0.635]}, {"w": "one-versus-the-rest).", "b": [0.2406, 0.6134, 0.406, 0.635]}]}, {"id": "b_8", "type": "paragraph", "text": "Another strategy is to train a binary classifier for every pair of digits: one to distin‐ guish 0s and 1s, another to distinguish 0s and 2s, another for 1s and 2s, and so on. This is called the one-versus-one (OvO) strategy. If there are N classes, you need to train N × (N – 1) / 2 classifiers. For the MNIST problem, this means training 45 binary classifiers! When you want to classify an image, you have to run the image through all 45 classifiers and see which class wins the most duels. The main advan‐ tage of OvO is that each classifier only needs to be trained on the part of the training set for the two classes that it must distinguish.", "words": [{"w": "Another", "b": [0.1429, 0.6417, 0.2133, 0.6631]}, {"w": "strategy", "b": [0.2199, 0.6417, 0.2854, 0.6631]}, {"w": "is", "b": [0.2919, 0.6417, 0.3052, 0.6631]}, {"w": "to", "b": [0.3117, 0.6417, 0.3287, 0.6631]}, {"w": "train", "b": [0.3353, 0.6417, 0.3755, 0.6631]}, {"w": "a", "b": [0.382, 0.6417, 0.3912, 0.6631]}, {"w": "binary", "b": [0.3977, 0.6417, 0.4523, 0.6631]}, {"w": "classifier", "b": [0.4589, 0.6417, 0.5313, 0.6631]}, {"w": "for", "b": [0.5379, 0.6417, 0.5624, 0.6631]}, {"w": "every", "b": [0.5689, 0.6417, 0.6142, 0.6631]}, {"w": "pair", "b": [0.6207, 0.6417, 0.6541, 0.6631]}, {"w": "of", "b": [0.6607, 0.6417, 0.6774, 0.6631]}, {"w": "digits:", "b": [0.684, 0.6417, 0.7347, 0.6631]}, {"w": "one", "b": [0.7412, 0.6417, 0.7721, 0.6631]}, {"w": "to", "b": [0.7786, 0.6417, 0.7956, 0.6631]}, {"w": "distin‐", "b": [0.8022, 0.6417, 0.8571, 0.6631]}, {"w": "guish", "b": [0.1429, 0.6607, 0.188, 0.6822]}, {"w": "0s", "b": [0.1947, 0.6607, 0.2123, 0.6822]}, {"w": "and", "b": [0.219, 0.6607, 0.2505, 0.6822]}, {"w": "1s,", "b": [0.2572, 0.6607, 0.2796, 0.6822]}, {"w": "another", "b": [0.2862, 0.6607, 0.3514, 0.6822]}, {"w": "to", "b": [0.3581, 0.6607, 0.3751, 0.6822]}, {"w": "distinguish", "b": [0.3817, 0.6607, 0.4745, 0.6822]}, {"w": "0s", "b": [0.4811, 0.6607, 0.4988, 0.6822]}, {"w": "and", "b": [0.5054, 0.6607, 0.537, 0.6822]}, {"w": "2s,", "b": [0.5436, 0.6607, 0.566, 0.6822]}, {"w": "another", "b": [0.5727, 0.6607, 0.6379, 0.6822]}, {"w": "for", "b": [0.6445, 0.6607, 0.6691, 0.6822]}, {"w": "1s", "b": [0.6757, 0.6607, 0.6934, 0.6822]}, {"w": "and", "b": [0.7, 0.6607, 0.7316, 0.6822]}, {"w": "2s,", "b": [0.7382, 0.6607, 0.7606, 0.6822]}, {"w": "and", "b": [0.7673, 0.6607, 0.7988, 0.6822]}, {"w": "so", "b": [0.8054, 0.6607, 0.8237, 0.6822]}, {"w": "on.", "b": [0.8304, 0.6607, 0.8571, 0.6822]}, {"w": "This", "b": [0.1429, 0.6798, 0.1801, 0.7012]}, {"w": "is", "b": [0.1871, 0.6798, 0.2003, 0.7012]}, {"w": "called", "b": [0.2074, 0.6798, 0.2557, 0.7012]}, {"w": "the", "b": [0.2627, 0.6798, 0.2891, 0.7012]}, {"w": "one-versus-one", "b": [0.2961, 0.6796, 0.4179, 0.7012]}, {"w": "(OvO)", "b": [0.4249, 0.6798, 0.4804, 0.7012]}, {"w": "strategy.", "b": [0.4875, 0.6798, 0.5562, 0.7012]}, {"w": "If", "b": [0.5632, 0.6798, 0.5765, 0.7012]}, {"w": "there", "b": [0.5835, 0.6798, 0.6264, 0.7012]}, {"w": "are", "b": [0.6335, 0.6798, 0.6592, 0.7012]}, {"w": "N", "b": [0.6662, 0.6796, 0.6809, 0.7012]}, {"w": "classes,", "b": [0.6879, 0.6798, 0.7477, 0.7012]}, {"w": "you", "b": [0.7547, 0.6798, 0.786, 0.7012]}, {"w": "need", "b": [0.793, 0.6798, 0.8331, 0.7012]}, {"w": "to", "b": [0.8402, 0.6798, 0.8571, 0.7012]}, {"w": "train", "b": [0.1429, 0.6988, 0.1831, 0.7203]}, {"w": "N", "b": [0.1911, 0.6986, 0.2058, 0.7203]}, {"w": "×", "b": [0.2139, 0.6988, 0.226, 0.7203]}, {"w": "(N", "b": [0.234, 0.6986, 0.2559, 0.7203]}, {"w": "–", "b": [0.264, 0.6988, 0.2748, 0.7203]}, {"w": "1)", "b": [0.2829, 0.6988, 0.3001, 0.7203]}, {"w": "/", "b": [0.3081, 0.6988, 0.315, 0.7203]}, {"w": "2", "b": [0.3231, 0.6988, 0.3331, 0.7203]}, {"w": "classifiers.", "b": [0.3411, 0.6988, 0.426, 0.7203]}, {"w": "For", "b": [0.434, 0.6988, 0.463, 0.7203]}, {"w": "the", "b": [0.4711, 0.6988, 0.4974, 0.7203]}, {"w": "MNIST", "b": [0.5055, 0.6988, 0.5693, 0.7203]}, {"w": "problem,", "b": [0.5774, 0.6988, 0.6532, 0.7203]}, {"w": "this", "b": [0.6612, 0.6988, 0.6919, 0.7203]}, {"w": "means", "b": [0.7, 0.6988, 0.7541, 0.7203]}, {"w": "training", "b": [0.7622, 0.6988, 0.8291, 0.7203]}, {"w": "45", "b": [0.8372, 0.6988, 0.8572, 0.7203]}, {"w": "binary", "b": [0.1429, 0.7179, 0.1975, 0.7393]}, {"w": "classifiers!", "b": [0.2049, 0.7179, 0.2907, 0.7393]}, {"w": "When", "b": [0.2981, 0.7179, 0.3497, 0.7393]}, {"w": "you", "b": [0.3572, 0.7179, 0.3884, 0.7393]}, {"w": "want", "b": [0.3958, 0.7179, 0.4366, 0.7393]}, {"w": "to", "b": [0.444, 0.7179, 0.461, 0.7393]}, {"w": "classify", "b": [0.4684, 0.7179, 0.5286, 0.7393]}, {"w": "an", "b": [0.536, 0.7179, 0.5565, 0.7393]}, {"w": "image,", "b": [0.564, 0.7179, 0.6191, 0.7393]}, {"w": "you", "b": [0.6265, 0.7179, 0.6578, 0.7393]}, {"w": "have", "b": [0.6652, 0.7179, 0.7036, 0.7393]}, {"w": "to", "b": [0.711, 0.7179, 0.728, 0.7393]}, {"w": "run", "b": [0.7354, 0.7179, 0.7656, 0.7393]}, {"w": "the", "b": [0.773, 0.7179, 0.7993, 0.7393]}, {"w": "image", "b": [0.8068, 0.7179, 0.8571, 0.7393]}, {"w": "through", "b": [0.1429, 0.7369, 0.2106, 0.7584]}, {"w": "all", "b": [0.2171, 0.7369, 0.2368, 0.7584]}, {"w": "45", "b": [0.2433, 0.7369, 0.2633, 0.7584]}, {"w": "classifiers", "b": [0.2698, 0.7369, 0.3499, 0.7584]}, {"w": "and", "b": [0.3564, 0.7369, 0.388, 0.7584]}, {"w": "see", "b": [0.3945, 0.7369, 0.4198, 0.7584]}, {"w": "which", "b": [0.4264, 0.7369, 0.4773, 0.7584]}, {"w": "class", "b": [0.4838, 0.7369, 0.5223, 0.7584]}, {"w": "wins", "b": [0.5288, 0.7369, 0.5677, 0.7584]}, {"w": "the", "b": [0.5742, 0.7369, 0.6005, 0.7584]}, {"w": "most", "b": [0.6071, 0.7369, 0.6487, 0.7584]}, {"w": "duels.", "b": [0.6553, 0.7369, 0.7038, 0.7584]}, {"w": "The", "b": [0.7104, 0.7369, 0.7432, 0.7584]}, {"w": "main", "b": [0.7497, 0.7369, 0.7929, 0.7584]}, {"w": "advan‐", "b": [0.7994, 0.7369, 0.8571, 0.7584]}, {"w": "tage", "b": [0.1428, 0.756, 0.177, 0.7774]}, {"w": "of", "b": [0.1824, 0.756, 0.1992, 0.7774]}, {"w": "OvO", "b": [0.2046, 0.756, 0.2457, 0.7774]}, {"w": "is", "b": [0.2512, 0.756, 0.2644, 0.7774]}, {"w": "that", "b": [0.2698, 0.756, 0.3024, 0.7774]}, {"w": "each", "b": [0.3079, 0.756, 0.3458, 0.7774]}, {"w": "classifier", "b": [0.3512, 0.756, 0.4237, 0.7774]}, {"w": "only", "b": [0.4291, 0.756, 0.466, 0.7774]}, {"w": "needs", "b": [0.4714, 0.756, 0.5192, 0.7774]}, {"w": "to", "b": [0.5246, 0.756, 0.5416, 0.7774]}, {"w": "be", "b": [0.547, 0.756, 0.5664, 0.7774]}, {"w": "trained", "b": [0.5719, 0.756, 0.6319, 0.7774]}, {"w": "on", "b": [0.6374, 0.756, 0.6594, 0.7774]}, {"w": "the", "b": [0.6648, 0.756, 0.6912, 0.7774]}, {"w": "part", "b": [0.6966, 0.756, 0.7308, 0.7774]}, {"w": "of", "b": [0.7362, 0.756, 0.753, 0.7774]}, {"w": "the", "b": [0.7584, 0.756, 0.7848, 0.7774]}, {"w": "training", "b": [0.7902, 0.756, 0.8571, 0.7774]}, {"w": "set", "b": [0.1429, 0.775, 0.1657, 0.7964]}, {"w": "for", "b": [0.1704, 0.775, 0.195, 0.7964]}, {"w": "the", "b": [0.1997, 0.775, 0.226, 0.7964]}, {"w": "two", "b": [0.2308, 0.775, 0.262, 0.7964]}, {"w": "classes", "b": [0.2667, 0.775, 0.3218, 0.7964]}, {"w": "that", "b": [0.3265, 0.775, 0.3591, 0.7964]}, {"w": "it", "b": [0.3638, 0.775, 0.3757, 0.7964]}, {"w": "must", "b": [0.3805, 0.775, 0.4222, 0.7964]}, {"w": "distinguish.", "b": [0.4269, 0.775, 0.5244, 0.7964]}]}, {"id": "b_9", "type": "paragraph", "text": "Some algorithms (such as Support Vector Machine classifiers) scale poorly with the size of the training set, so for these algorithms OvO is preferred since it is faster to train many classifiers on small training sets than training few classifiers on large training sets. For most binary classification algorithms, however, OvA is preferred.", "words": [{"w": "Some", "b": [0.1429, 0.8032, 0.1893, 0.8246]}, {"w": "algorithms", "b": [0.196, 0.8032, 0.2863, 0.8246]}, {"w": "(such", "b": [0.293, 0.8032, 0.3389, 0.8246]}, {"w": "as", "b": [0.3456, 0.8032, 0.3624, 0.8246]}, {"w": "Support", "b": [0.3691, 0.8032, 0.4366, 0.8246]}, {"w": "Vector", "b": [0.4433, 0.8032, 0.4983, 0.8246]}, {"w": "Machine", "b": [0.505, 0.8032, 0.5781, 0.8246]}, {"w": "classifiers)", "b": [0.5849, 0.8032, 0.6721, 0.8246]}, {"w": "scale", "b": [0.6789, 0.8032, 0.7186, 0.8246]}, {"w": "poorly", "b": [0.7253, 0.8032, 0.78, 0.8246]}, {"w": "with", "b": [0.7868, 0.8032, 0.8241, 0.8246]}, {"w": "the", "b": [0.8308, 0.8032, 0.8571, 0.8246]}, {"w": "size", "b": [0.1429, 0.8222, 0.1737, 0.8436]}, {"w": "of", "b": [0.1804, 0.8222, 0.1972, 0.8436]}, {"w": "the", "b": [0.2039, 0.8222, 0.2302, 0.8436]}, {"w": "training", "b": [0.2369, 0.8222, 0.3039, 0.8436]}, {"w": "set,", "b": [0.3106, 0.8222, 0.3382, 0.8436]}, {"w": "so", "b": [0.3449, 0.8222, 0.3632, 0.8436]}, {"w": "for", "b": [0.3699, 0.8222, 0.3944, 0.8436]}, {"w": "these", "b": [0.4011, 0.8222, 0.4439, 0.8436]}, {"w": "algorithms", "b": [0.4507, 0.8222, 0.5409, 0.8436]}, {"w": "OvO", "b": [0.5477, 0.8222, 0.5888, 0.8436]}, {"w": "is", "b": [0.5955, 0.8222, 0.6087, 0.8436]}, {"w": "preferred", "b": [0.6154, 0.8222, 0.6933, 0.8436]}, {"w": "since", "b": [0.7, 0.8222, 0.7423, 0.8436]}, {"w": "it", "b": [0.749, 0.8222, 0.7609, 0.8436]}, {"w": "is", "b": [0.7676, 0.8222, 0.7809, 0.8436]}, {"w": "faster", "b": [0.7876, 0.8222, 0.8335, 0.8436]}, {"w": "to", "b": [0.8402, 0.8222, 0.8571, 0.8436]}, {"w": "train", "b": [0.1429, 0.8412, 0.1831, 0.8627]}, {"w": "many", "b": [0.1919, 0.8412, 0.2386, 0.8627]}, {"w": "classifiers", "b": [0.2475, 0.8412, 0.3276, 0.8627]}, {"w": "on", "b": [0.3364, 0.8412, 0.3584, 0.8627]}, {"w": "small", "b": [0.3673, 0.8412, 0.4117, 0.8627]}, {"w": "training", "b": [0.4206, 0.8412, 0.4875, 0.8627]}, {"w": "sets", "b": [0.4964, 0.8412, 0.5269, 0.8627]}, {"w": "than", "b": [0.5357, 0.8412, 0.5737, 0.8627]}, {"w": "training", "b": [0.5826, 0.8412, 0.6495, 0.8627]}, {"w": "few", "b": [0.6584, 0.8412, 0.6877, 0.8627]}, {"w": "classifiers", "b": [0.6966, 0.8412, 0.7766, 0.8627]}, {"w": "on", "b": [0.7855, 0.8412, 0.8075, 0.8627]}, {"w": "large", "b": [0.8164, 0.8412, 0.8571, 0.8627]}, {"w": "training", "b": [0.1429, 0.8603, 0.2098, 0.8817]}, {"w": "sets.", "b": [0.2145, 0.8603, 0.2498, 0.8817]}, {"w": "For", "b": [0.2545, 0.8603, 0.2835, 0.8817]}, {"w": "most", "b": [0.2882, 0.8603, 0.3299, 0.8817]}, {"w": "binary", "b": [0.3346, 0.8603, 0.3892, 0.8817]}, {"w": "classification", "b": [0.394, 0.8603, 0.5013, 0.8817]}, {"w": "algorithms,", "b": [0.5061, 0.8603, 0.6011, 0.8817]}, {"w": "however,", "b": [0.6058, 0.8603, 0.6804, 0.8817]}, {"w": "OvA", "b": [0.6851, 0.8603, 0.7251, 0.8817]}, {"w": "is", "b": [0.7298, 0.8603, 0.743, 0.8817]}, {"w": "preferred.", "b": [0.7478, 0.8603, 0.8303, 0.8817]}]}, {"id": "b_10", "type": "paragraph", "text": "102 | Chapter 3: Classification", "words": [{"w": "102", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "3:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Classification", "b": [0.2673, 0.9225, 0.3443, 0.9388]}]}]}, {"page": 129, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Scikit-Learn detects when you try to use a binary classification algorithm for a multi‐ class classification task, and it automatically runs OvA (except for SVM classifiers for which it uses OvO). Let’s try this with the SGDClassifier:", "words": [{"w": "Scikit-Learn", "b": [0.1429, 0.0791, 0.2451, 0.1005]}, {"w": "detects", "b": [0.2504, 0.0791, 0.3083, 0.1005]}, {"w": "when", "b": [0.3136, 0.0791, 0.3592, 0.1005]}, {"w": "you", "b": [0.3645, 0.0791, 0.3958, 0.1005]}, {"w": "try", "b": [0.401, 0.0791, 0.4253, 0.1005]}, {"w": "to", "b": [0.4306, 0.0791, 0.4475, 0.1005]}, {"w": "use", "b": [0.4528, 0.0791, 0.4804, 0.1005]}, {"w": "a", "b": [0.4857, 0.0791, 0.4948, 0.1005]}, {"w": "binary", "b": [0.5001, 0.0791, 0.5547, 0.1005]}, {"w": "classification", "b": [0.56, 0.0791, 0.6674, 0.1005]}, {"w": "algorithm", "b": [0.6726, 0.0791, 0.7553, 0.1005]}, {"w": "for", "b": [0.7606, 0.0791, 0.7851, 0.1005]}, {"w": "a", "b": [0.7904, 0.0791, 0.7995, 0.1005]}, {"w": "multi‐", "b": [0.8048, 0.0791, 0.8571, 0.1005]}, {"w": "class", "b": [0.1429, 0.0981, 0.1814, 0.1195]}, {"w": "classification", "b": [0.1866, 0.0981, 0.294, 0.1195]}, {"w": "task,", "b": [0.2993, 0.0981, 0.3375, 0.1195]}, {"w": "and", "b": [0.3428, 0.0981, 0.3743, 0.1195]}, {"w": "it", "b": [0.3796, 0.0981, 0.3915, 0.1195]}, {"w": "automatically", "b": [0.3968, 0.0981, 0.5094, 0.1195]}, {"w": "runs", "b": [0.5147, 0.0981, 0.5525, 0.1195]}, {"w": "OvA", "b": [0.5578, 0.0981, 0.5977, 0.1195]}, {"w": "(except", "b": [0.603, 0.0981, 0.6638, 0.1195]}, {"w": "for", "b": [0.6691, 0.0981, 0.6936, 0.1195]}, {"w": "SVM", "b": [0.6989, 0.0981, 0.742, 0.1195]}, {"w": "classifiers", "b": [0.7473, 0.0981, 0.8273, 0.1195]}, {"w": "for", "b": [0.8326, 0.0981, 0.8571, 0.1195]}, {"w": "which", "b": [0.1429, 0.1181, 0.1938, 0.1395]}, {"w": "it", "b": [0.1985, 0.1181, 0.2104, 0.1395]}, {"w": "uses", "b": [0.2152, 0.1181, 0.2504, 0.1395]}, {"w": "OvO).", "b": [0.2551, 0.1181, 0.3082, 0.1395]}, {"w": "Let’s", "b": [0.3129, 0.1181, 0.3491, 0.1395]}, {"w": "try", "b": [0.3538, 0.1181, 0.3781, 0.1395]}, {"w": "this", "b": [0.3828, 0.1181, 0.4135, 0.1395]}, {"w": "with", "b": [0.4182, 0.1181, 0.4556, 0.1395]}, {"w": "the", "b": [0.4603, 0.1181, 0.4866, 0.1395]}, {"w": "SGDClassifier:", "b": [0.4914, 0.1181, 0.6248, 0.1395]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> sgd_clf.fit(X_train, y_train) # y_train, not y_train_5 >>> sgd_clf.predict([some_digit]) array([5], dtype=uint8)", "words": [{"w": ">>>", "b": [0.1766, 0.15, 0.2019, 0.1629]}, {"w": "sgd_clf.fit(X_train,", "b": [0.2103, 0.15, 0.379, 0.1629]}, {"w": "y_train)", "b": [0.3874, 0.15, 0.4549, 0.1629]}, {"w": "#", "b": [0.4717, 0.15, 0.4802, 0.1629]}, {"w": "y_train,", "b": [0.4886, 0.15, 0.5561, 0.1629]}, {"w": "not", "b": [0.5645, 0.15, 0.5898, 0.1629]}, {"w": "y_train_5", "b": [0.5982, 0.15, 0.6741, 0.1629]}, {"w": ">>>", "b": [0.1766, 0.1654, 0.2019, 0.1783]}, {"w": "sgd_clf.predict([some_digit])", "b": [0.2103, 0.1654, 0.4549, 0.1783]}, {"w": "array([5],", "b": [0.1766, 0.1809, 0.2609, 0.1937]}, {"w": "dtype=uint8)", "b": [0.2693, 0.1809, 0.3705, 0.1937]}]}, {"id": "b_2", "type": "paragraph", "text": "That was easy! This code trains the SGDClassifier on the training set using the origi‐ nal target classes from 0 to 9 (y_train), instead of the 5-versus-all target classes (y_train_5). Then it makes a prediction (a correct one in this case). Under the hood, Scikit-Learn actually trained 10 binary classifiers, got their decision scores for the image, and selected the class with the highest score.", "words": [{"w": "That", "b": [0.1429, 0.2024, 0.1819, 0.2238]}, {"w": "was", "b": [0.1867, 0.2024, 0.2177, 0.2238]}, {"w": "easy!", "b": [0.2225, 0.2024, 0.2634, 0.2238]}, {"w": "This", "b": [0.2681, 0.2024, 0.3054, 0.2238]}, {"w": "code", "b": [0.3101, 0.2024, 0.3494, 0.2238]}, {"w": "trains", "b": [0.3541, 0.2024, 0.402, 0.2238]}, {"w": "the", "b": [0.4067, 0.2024, 0.433, 0.2238]}, {"w": "SGDClassifier", "b": [0.4383, 0.2056, 0.5669, 0.2207]}, {"w": "on", "b": [0.5717, 0.2024, 0.5937, 0.2238]}, {"w": "the", "b": [0.5985, 0.2024, 0.6248, 0.2238]}, {"w": "training", "b": [0.6295, 0.2024, 0.6965, 0.2238]}, {"w": "set", "b": [0.7012, 0.2024, 0.7241, 0.2238]}, {"w": "using", "b": [0.7288, 0.2024, 0.7742, 0.2238]}, {"w": "the", "b": [0.7789, 0.2024, 0.8053, 0.2238]}, {"w": "origi‐", "b": [0.81, 0.2024, 0.8567, 0.2238]}, {"w": "nal", "b": [0.1429, 0.2223, 0.1687, 0.2438]}, {"w": "target", "b": [0.1775, 0.2223, 0.2257, 0.2438]}, {"w": "classes", "b": [0.2345, 0.2223, 0.2896, 0.2438]}, {"w": "from", "b": [0.2984, 0.2223, 0.34, 0.2438]}, {"w": "0", "b": [0.3488, 0.2223, 0.3588, 0.2438]}, {"w": "to", "b": [0.3676, 0.2223, 0.3846, 0.2438]}, {"w": "9", "b": [0.3935, 0.2223, 0.4035, 0.2438]}, {"w": "(y_train),", "b": [0.4123, 0.2223, 0.5007, 0.2438]}, {"w": "instead", "b": [0.5096, 0.2223, 0.5695, 0.2438]}, {"w": "of", "b": [0.5784, 0.2223, 0.5952, 0.2438]}, {"w": "the", "b": [0.604, 0.2223, 0.6303, 0.2438]}, {"w": "5-versus-all", "b": [0.6392, 0.2223, 0.7363, 0.2438]}, {"w": "target", "b": [0.7451, 0.2223, 0.7933, 0.2438]}, {"w": "classes", "b": [0.8021, 0.2223, 0.8572, 0.2438]}, {"w": "(y_train_5).", "b": [0.1429, 0.2423, 0.2511, 0.2637]}, {"w": "Then", "b": [0.2563, 0.2423, 0.3005, 0.2637]}, {"w": "it", "b": [0.3057, 0.2423, 0.3176, 0.2637]}, {"w": "makes", "b": [0.3228, 0.2423, 0.3759, 0.2637]}, {"w": "a", "b": [0.3811, 0.2423, 0.3902, 0.2637]}, {"w": "prediction", "b": [0.3954, 0.2423, 0.4823, 0.2637]}, {"w": "(a", "b": [0.4875, 0.2423, 0.5038, 0.2637]}, {"w": "correct", "b": [0.509, 0.2423, 0.5679, 0.2637]}, {"w": "one", "b": [0.5731, 0.2423, 0.604, 0.2637]}, {"w": "in", "b": [0.6092, 0.2423, 0.6262, 0.2637]}, {"w": "this", "b": [0.6314, 0.2423, 0.6621, 0.2637]}, {"w": "case).", "b": [0.6673, 0.2423, 0.7137, 0.2637]}, {"w": "Under", "b": [0.7189, 0.2423, 0.7723, 0.2637]}, {"w": "the", "b": [0.7775, 0.2423, 0.8038, 0.2637]}, {"w": "hood,", "b": [0.809, 0.2423, 0.8571, 0.2637]}, {"w": "Scikit-Learn", "b": [0.1429, 0.2613, 0.2451, 0.2827]}, {"w": "actually", "b": [0.2533, 0.2613, 0.3179, 0.2827]}, {"w": "trained", "b": [0.3261, 0.2613, 0.3862, 0.2827]}, {"w": "10", "b": [0.3943, 0.2613, 0.4143, 0.2827]}, {"w": "binary", "b": [0.4225, 0.2613, 0.4771, 0.2827]}, {"w": "classifiers,", "b": [0.4853, 0.2613, 0.5701, 0.2827]}, {"w": "got", "b": [0.5783, 0.2613, 0.605, 0.2827]}, {"w": "their", "b": [0.6132, 0.2613, 0.6528, 0.2827]}, {"w": "decision", "b": [0.661, 0.2613, 0.7305, 0.2827]}, {"w": "scores", "b": [0.7386, 0.2613, 0.79, 0.2827]}, {"w": "for", "b": [0.7981, 0.2613, 0.8226, 0.2827]}, {"w": "the", "b": [0.8308, 0.2613, 0.8571, 0.2827]}, {"w": "image,", "b": [0.1429, 0.2804, 0.198, 0.3018]}, {"w": "and", "b": [0.2027, 0.2804, 0.2343, 0.3018]}, {"w": "selected", "b": [0.239, 0.2804, 0.3047, 0.3018]}, {"w": "the", "b": [0.3094, 0.2804, 0.3357, 0.3018]}, {"w": "class", "b": [0.3405, 0.2804, 0.379, 0.3018]}, {"w": "with", "b": [0.3837, 0.2804, 0.421, 0.3018]}, {"w": "the", "b": [0.4258, 0.2804, 0.4521, 0.3018]}, {"w": "highest", "b": [0.4568, 0.2804, 0.5173, 0.3018]}, {"w": "score.", "b": [0.522, 0.2804, 0.5704, 0.3018]}]}, {"id": "b_3", "type": "paragraph", "text": "To see that this is indeed the case, you can call the decision_function() method. Instead of returning just one score per instance, it now returns 10 scores, one per class:", "words": [{"w": "To", "b": [0.1429, 0.3094, 0.1643, 0.3308]}, {"w": "see", "b": [0.1717, 0.3094, 0.197, 0.3308]}, {"w": "that", "b": [0.2044, 0.3094, 0.2369, 0.3308]}, {"w": "this", "b": [0.2443, 0.3094, 0.275, 0.3308]}, {"w": "is", "b": [0.2823, 0.3094, 0.2956, 0.3308]}, {"w": "indeed", "b": [0.3029, 0.3094, 0.3596, 0.3308]}, {"w": "the", "b": [0.367, 0.3094, 0.3933, 0.3308]}, {"w": "case,", "b": [0.4006, 0.3094, 0.4398, 0.3308]}, {"w": "you", "b": [0.4472, 0.3094, 0.4784, 0.3308]}, {"w": "can", "b": [0.4858, 0.3094, 0.5151, 0.3308]}, {"w": "call", "b": [0.5225, 0.3094, 0.551, 0.3308]}, {"w": "the", "b": [0.5583, 0.3094, 0.5847, 0.3308]}, {"w": "decision_function()", "b": [0.592, 0.3126, 0.78, 0.3277]}, {"w": "method.", "b": [0.7874, 0.3094, 0.8572, 0.3308]}, {"w": "Instead", "b": [0.1429, 0.3284, 0.2044, 0.3499]}, {"w": "of", "b": [0.212, 0.3284, 0.2287, 0.3499]}, {"w": "returning", "b": [0.2363, 0.3284, 0.3162, 0.3499]}, {"w": "just", "b": [0.3238, 0.3284, 0.3542, 0.3499]}, {"w": "one", "b": [0.3618, 0.3284, 0.3927, 0.3499]}, {"w": "score", "b": [0.4003, 0.3284, 0.4439, 0.3499]}, {"w": "per", "b": [0.4515, 0.3284, 0.479, 0.3499]}, {"w": "instance,", "b": [0.4866, 0.3284, 0.5605, 0.3499]}, {"w": "it", "b": [0.5681, 0.3284, 0.5801, 0.3499]}, {"w": "now", "b": [0.5877, 0.3284, 0.624, 0.3499]}, {"w": "returns", "b": [0.6316, 0.3284, 0.6923, 0.3499]}, {"w": "10", "b": [0.6999, 0.3284, 0.7199, 0.3499]}, {"w": "scores,", "b": [0.7275, 0.3284, 0.7836, 0.3499]}, {"w": "one", "b": [0.7912, 0.3284, 0.8221, 0.3499]}, {"w": "per", "b": [0.8296, 0.3284, 0.8571, 0.3499]}, {"w": "class:", "b": [0.1429, 0.3475, 0.1861, 0.3689]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> some_digit_scores = sgd_clf.decision_function([some_digit]) >>> some_digit_scores array([[-15955.22627845, -38080.96296175, -13326.66694897, 573.52692379, -17680.6846644 , 2412.53175101, -25526.86498156, -12290.15704709, -7946.05205023, -10631.35888549]])", "words": [{"w": ">>>", "b": [0.1766, 0.3795, 0.2019, 0.3923]}, {"w": "some_digit_scores", "b": [0.2103, 0.3795, 0.3537, 0.3923]}, {"w": "=", "b": [0.3621, 0.3795, 0.3705, 0.3923]}, {"w": "sgd_clf.decision_function([some_digit])", "b": [0.379, 0.3795, 0.7078, 0.3923]}, {"w": ">>>", "b": [0.1766, 0.3949, 0.2019, 0.4077]}, {"w": "some_digit_scores", "b": [0.2103, 0.3949, 0.3537, 0.4077]}, {"w": "array([[-15955.22627845,", "b": [0.1766, 0.4103, 0.379, 0.4232]}, {"w": "-38080.96296175,", "b": [0.3874, 0.4103, 0.5223, 0.4232]}, {"w": "-13326.66694897,", "b": [0.5307, 0.4103, 0.6657, 0.4232]}, {"w": "573.52692379,", "b": [0.2693, 0.4257, 0.379, 0.4386]}, {"w": "-17680.6846644", "b": [0.3874, 0.4257, 0.5055, 0.4386]}, {"w": ",", "b": [0.5139, 0.4257, 0.5223, 0.4386]}, {"w": "2412.53175101,", "b": [0.5476, 0.4257, 0.6657, 0.4386]}, {"w": "-25526.86498156,", "b": [0.244, 0.4411, 0.379, 0.454]}, {"w": "-12290.15704709,", "b": [0.3874, 0.4411, 0.5223, 0.454]}, {"w": "-7946.05205023,", "b": [0.5392, 0.4411, 0.6657, 0.454]}, {"w": "-10631.35888549]])", "b": [0.244, 0.4566, 0.3958, 0.4694]}]}, {"id": "b_5", "type": "paragraph", "text": "The highest score is indeed the one corresponding to class 5:", "words": [{"w": "The", "b": [0.1428, 0.4772, 0.1757, 0.4986]}, {"w": "highest", "b": [0.1804, 0.4772, 0.2408, 0.4986]}, {"w": "score", "b": [0.2456, 0.4772, 0.2892, 0.4986]}, {"w": "is", "b": [0.294, 0.4772, 0.3072, 0.4986]}, {"w": "indeed", "b": [0.3119, 0.4772, 0.3686, 0.4986]}, {"w": "the", "b": [0.3733, 0.4772, 0.3997, 0.4986]}, {"w": "one", "b": [0.4044, 0.4772, 0.4353, 0.4986]}, {"w": "corresponding", "b": [0.44, 0.4772, 0.5621, 0.4986]}, {"w": "to", "b": [0.5668, 0.4772, 0.5838, 0.4986]}, {"w": "class", "b": [0.5885, 0.4772, 0.627, 0.4986]}, {"w": "5:", "b": [0.6318, 0.4772, 0.6465, 0.4986]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> np.argmax(some_digit_scores) 5 >>> sgd_clf.classes_ array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint8) >>> sgd_clf.classes_[5] 5", "words": [{"w": ">>>", "b": [0.1766, 0.5092, 0.2019, 0.522]}, {"w": "np.argmax(some_digit_scores)", "b": [0.2103, 0.5092, 0.4464, 0.522]}, {"w": "5", "b": [0.1766, 0.5246, 0.185, 0.5374]}, {"w": ">>>", "b": [0.1766, 0.54, 0.2019, 0.5529]}, {"w": "sgd_clf.classes_", "b": [0.2103, 0.54, 0.3452, 0.5529]}, {"w": "array([0,", "b": [0.1766, 0.5554, 0.2525, 0.5683]}, {"w": "1,", "b": [0.2609, 0.5554, 0.2778, 0.5683]}, {"w": "2,", "b": [0.2862, 0.5554, 0.3031, 0.5683]}, {"w": "3,", "b": [0.3115, 0.5554, 0.3284, 0.5683]}, {"w": "4,", "b": [0.3368, 0.5554, 0.3537, 0.5683]}, {"w": "5,", "b": [0.3621, 0.5554, 0.379, 0.5683]}, {"w": "6,", "b": [0.3874, 0.5554, 0.4043, 0.5683]}, {"w": "7,", "b": [0.4127, 0.5554, 0.4296, 0.5683]}, {"w": "8,", "b": [0.438, 0.5554, 0.4549, 0.5683]}, {"w": "9],", "b": [0.4633, 0.5554, 0.4886, 0.5683]}, {"w": "dtype=uint8)", "b": [0.497, 0.5554, 0.5982, 0.5683]}, {"w": ">>>", "b": [0.1766, 0.5708, 0.2019, 0.5837]}, {"w": "sgd_clf.classes_[5]", "b": [0.2103, 0.5708, 0.3705, 0.5837]}, {"w": "5", "b": [0.1766, 0.5863, 0.185, 0.5991]}]}, {"id": "b_7", "type": "paragraph", "text": "When a classifier is trained, it stores the list of target classes in its classes_ attribute, ordered by value. In this case, the index of each class in the classes_ array conveniently matches the class itself (e.g., the class at index 5 happens to be class 5), but in general you won’t be so lucky.", "words": [{"w": "When", "b": [0.2714, 0.6207, 0.3186, 0.6403]}, {"w": "a", "b": [0.3244, 0.6207, 0.3328, 0.6403]}, {"w": "classifier", "b": [0.3386, 0.6207, 0.4048, 0.6403]}, {"w": "is", "b": [0.4106, 0.6207, 0.4227, 0.6403]}, {"w": "trained,", "b": [0.4286, 0.6207, 0.4878, 0.6403]}, {"w": "it", "b": [0.4936, 0.6207, 0.5046, 0.6403]}, {"w": "stores", "b": [0.5104, 0.6207, 0.555, 0.6403]}, {"w": "the", "b": [0.5609, 0.6207, 0.5849, 0.6403]}, {"w": "list", "b": [0.5908, 0.6207, 0.6135, 0.6403]}, {"w": "of", "b": [0.6193, 0.6207, 0.6347, 0.6403]}, {"w": "target", "b": [0.6405, 0.6207, 0.6845, 0.6403]}, {"w": "classes", "b": [0.6904, 0.6207, 0.7407, 0.6403]}, {"w": "in", "b": [0.7465, 0.6207, 0.762, 0.6403]}, {"w": "its", "b": [0.7678, 0.6207, 0.7857, 0.6403]}, {"w": "classes_", "b": [0.2714, 0.6419, 0.3438, 0.6557]}, {"w": "attribute,", "b": [0.3485, 0.639, 0.4183, 0.6585]}, {"w": "ordered", "b": [0.4229, 0.639, 0.4831, 0.6585]}, {"w": "by", "b": [0.4878, 0.639, 0.5062, 0.6585]}, {"w": "value.", "b": [0.5109, 0.639, 0.5554, 0.6585]}, {"w": "In", "b": [0.5601, 0.639, 0.577, 0.6585]}, {"w": "this", "b": [0.5817, 0.639, 0.6097, 0.6585]}, {"w": "case,", "b": [0.6144, 0.639, 0.6503, 0.6585]}, {"w": "the", "b": [0.6549, 0.639, 0.679, 0.6585]}, {"w": "index", "b": [0.6837, 0.639, 0.7263, 0.6585]}, {"w": "of", "b": [0.731, 0.639, 0.7464, 0.6585]}, {"w": "each", "b": [0.751, 0.639, 0.7857, 0.6585]}, {"w": "class", "b": [0.2714, 0.6572, 0.3066, 0.6768]}, {"w": "in", "b": [0.3146, 0.6572, 0.3301, 0.6768]}, {"w": "the", "b": [0.3381, 0.6572, 0.3621, 0.6768]}, {"w": "classes_", "b": [0.3701, 0.6601, 0.4425, 0.6739]}, {"w": "array", "b": [0.4505, 0.6572, 0.4897, 0.6768]}, {"w": "conveniently", "b": [0.4977, 0.6572, 0.5954, 0.6768]}, {"w": "matches", "b": [0.6033, 0.6572, 0.6661, 0.6768]}, {"w": "the", "b": [0.674, 0.6572, 0.6981, 0.6768]}, {"w": "class", "b": [0.7061, 0.6572, 0.7413, 0.6768]}, {"w": "itself", "b": [0.7493, 0.6572, 0.7857, 0.6768]}, {"w": "(e.g.,", "b": [0.2714, 0.6746, 0.308, 0.6942]}, {"w": "the", "b": [0.3134, 0.6746, 0.3375, 0.6942]}, {"w": "class", "b": [0.3428, 0.6746, 0.3781, 0.6942]}, {"w": "at", "b": [0.3834, 0.6746, 0.3972, 0.6942]}, {"w": "index", "b": [0.4026, 0.6746, 0.4453, 0.6942]}, {"w": "5", "b": [0.4506, 0.6746, 0.4598, 0.6942]}, {"w": "happens", "b": [0.4651, 0.6746, 0.5288, 0.6942]}, {"w": "to", "b": [0.5341, 0.6746, 0.5496, 0.6942]}, {"w": "be", "b": [0.555, 0.6746, 0.5728, 0.6942]}, {"w": "class", "b": [0.5781, 0.6746, 0.6134, 0.6942]}, {"w": "5),", "b": [0.6187, 0.6746, 0.6388, 0.6942]}, {"w": "but", "b": [0.6442, 0.6746, 0.6698, 0.6942]}, {"w": "in", "b": [0.6751, 0.6746, 0.6906, 0.6942]}, {"w": "general", "b": [0.696, 0.6746, 0.7518, 0.6942]}, {"w": "you", "b": [0.7571, 0.6746, 0.7857, 0.6942]}, {"w": "won’t", "b": [0.2714, 0.692, 0.3124, 0.7116]}, {"w": "be", "b": [0.3168, 0.692, 0.3345, 0.7116]}, {"w": "so", "b": [0.3389, 0.692, 0.3556, 0.7116]}, {"w": "lucky.", "b": [0.3599, 0.692, 0.404, 0.7116]}]}, {"id": "b_8", "type": "paragraph", "text": "If you want to force ScikitLearn to use one-versus-one or one-versus-all, you can use the OneVsOneClassifier or OneVsRestClassifier classes. Simply create an instance and pass a binary classifier to its constructor. For example, this code creates a multi‐ class classifier using the OvO strategy, based on a SGDClassifier:", "words": [{"w": "If", "b": [0.1429, 0.7319, 0.1561, 0.7533]}, {"w": "you", "b": [0.1617, 0.7319, 0.1929, 0.7533]}, {"w": "want", "b": [0.1985, 0.7319, 0.2392, 0.7533]}, {"w": "to", "b": [0.2448, 0.7319, 0.2618, 0.7533]}, {"w": "force", "b": [0.2673, 0.7319, 0.3095, 0.7533]}, {"w": "ScikitLearn", "b": [0.315, 0.7319, 0.4099, 0.7533]}, {"w": "to", "b": [0.4154, 0.7319, 0.4324, 0.7533]}, {"w": "use", "b": [0.4379, 0.7319, 0.4655, 0.7533]}, {"w": "one-versus-one", "b": [0.471, 0.7319, 0.6002, 0.7533]}, {"w": "or", "b": [0.6058, 0.7319, 0.6241, 0.7533]}, {"w": "one-versus-all,", "b": [0.6296, 0.7319, 0.7524, 0.7533]}, {"w": "you", "b": [0.7579, 0.7319, 0.7892, 0.7533]}, {"w": "can", "b": [0.7947, 0.7319, 0.8241, 0.7533]}, {"w": "use", "b": [0.8296, 0.7319, 0.8572, 0.7533]}, {"w": "the", "b": [0.1429, 0.7518, 0.1692, 0.7733]}, {"w": "OneVsOneClassifier", "b": [0.175, 0.755, 0.3532, 0.7701]}, {"w": "or", "b": [0.359, 0.7518, 0.3774, 0.7733]}, {"w": "OneVsRestClassifier", "b": [0.3832, 0.755, 0.5712, 0.7701]}, {"w": "classes.", "b": [0.5771, 0.7518, 0.6368, 0.7733]}, {"w": "Simply", "b": [0.6427, 0.7518, 0.7005, 0.7733]}, {"w": "create", "b": [0.7064, 0.7518, 0.7557, 0.7733]}, {"w": "an", "b": [0.7616, 0.7518, 0.7821, 0.7733]}, {"w": "instance", "b": [0.788, 0.7518, 0.8571, 0.7733]}, {"w": "and", "b": [0.1429, 0.7709, 0.1744, 0.7923]}, {"w": "pass", "b": [0.1803, 0.7709, 0.2156, 0.7923]}, {"w": "a", "b": [0.2215, 0.7709, 0.2307, 0.7923]}, {"w": "binary", "b": [0.2365, 0.7709, 0.2911, 0.7923]}, {"w": "classifier", "b": [0.297, 0.7709, 0.3694, 0.7923]}, {"w": "to", "b": [0.3753, 0.7709, 0.3923, 0.7923]}, {"w": "its", "b": [0.3982, 0.7709, 0.4178, 0.7923]}, {"w": "constructor.", "b": [0.4236, 0.7709, 0.5242, 0.7923]}, {"w": "For", "b": [0.5301, 0.7709, 0.5591, 0.7923]}, {"w": "example,", "b": [0.565, 0.7709, 0.6393, 0.7923]}, {"w": "this", "b": [0.6451, 0.7709, 0.6758, 0.7923]}, {"w": "code", "b": [0.6817, 0.7709, 0.721, 0.7923]}, {"w": "creates", "b": [0.7269, 0.7709, 0.7839, 0.7923]}, {"w": "a", "b": [0.7898, 0.7709, 0.7989, 0.7923]}, {"w": "multi‐", "b": [0.8048, 0.7709, 0.8571, 0.7923]}, {"w": "class", "b": [0.1429, 0.7908, 0.1814, 0.8122]}, {"w": "classifier", "b": [0.1861, 0.7908, 0.2585, 0.8122]}, {"w": "using", "b": [0.2633, 0.7908, 0.3087, 0.8122]}, {"w": "the", "b": [0.3134, 0.7908, 0.3398, 0.8122]}, {"w": "OvO", "b": [0.3445, 0.7908, 0.3856, 0.8122]}, {"w": "strategy,", "b": [0.3904, 0.7908, 0.4591, 0.8122]}, {"w": "based", "b": [0.4638, 0.7908, 0.511, 0.8122]}, {"w": "on", "b": [0.5158, 0.7908, 0.5378, 0.8122]}, {"w": "a", "b": [0.5425, 0.7908, 0.5517, 0.8122]}, {"w": "SGDClassifier:", "b": [0.5564, 0.7908, 0.6898, 0.8122]}]}, {"id": "b_9", "type": "paragraph", "text": ">>> from sklearn.multiclass import OneVsOneClassifier >>> ovo_clf = OneVsOneClassifier(SGDClassifier(random_state=42)) >>> ovo_clf.fit(X_train, y_train) >>> ovo_clf.predict([some_digit])", "words": [{"w": ">>>", "b": [0.1766, 0.8228, 0.2019, 0.8357]}, {"w": "from", "b": [0.2103, 0.8228, 0.244, 0.8357]}, {"w": "sklearn.multiclass", "b": [0.2525, 0.8228, 0.4043, 0.8357]}, {"w": "import", "b": [0.4127, 0.8228, 0.4633, 0.8357]}, {"w": "OneVsOneClassifier", "b": [0.4717, 0.8228, 0.6235, 0.8357]}, {"w": ">>>", "b": [0.1766, 0.8382, 0.2019, 0.8511]}, {"w": "ovo_clf", "b": [0.2103, 0.8382, 0.2693, 0.8511]}, {"w": "=", "b": [0.2778, 0.8382, 0.2862, 0.8511]}, {"w": "OneVsOneClassifier(SGDClassifier(random_state=42))", "b": [0.2946, 0.8382, 0.7163, 0.8511]}, {"w": ">>>", "b": [0.1766, 0.8536, 0.2019, 0.8665]}, {"w": "ovo_clf.fit(X_train,", "b": [0.2103, 0.8536, 0.379, 0.8665]}, {"w": "y_train)", "b": [0.3874, 0.8536, 0.4549, 0.8665]}, {"w": ">>>", "b": [0.1766, 0.8691, 0.2019, 0.8819]}, {"w": "ovo_clf.predict([some_digit])", "b": [0.2103, 0.8691, 0.4549, 0.8819]}]}, {"id": "b_10", "type": "paragraph", "text": "Multiclass Classification | 103", "words": [{"w": "Multiclass", "b": [0.6573, 0.9225, 0.716, 0.9388]}, {"w": "Classification", "b": [0.7188, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "103", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 130, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "array([5], dtype=uint8) >>> len(ovo_clf.estimators_) 45", "words": [{"w": "array([5],", "b": [0.1766, 0.0829, 0.2609, 0.0958]}, {"w": "dtype=uint8)", "b": [0.2693, 0.0829, 0.3705, 0.0958]}, {"w": ">>>", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "len(ovo_clf.estimators_)", "b": [0.2103, 0.0983, 0.4127, 0.1112]}, {"w": "45", "b": [0.1766, 0.1138, 0.1935, 0.1266]}]}, {"id": "b_1", "type": "paragraph", "text": "Training a RandomForestClassifier is just as easy:", "words": [{"w": "Training", "b": [0.1428, 0.1353, 0.2146, 0.1567]}, {"w": "a", "b": [0.2193, 0.1353, 0.2284, 0.1567]}, {"w": "RandomForestClassifier", "b": [0.2332, 0.1385, 0.4509, 0.1535]}, {"w": "is", "b": [0.4556, 0.1353, 0.4688, 0.1567]}, {"w": "just", "b": [0.4736, 0.1353, 0.504, 0.1567]}, {"w": "as", "b": [0.5087, 0.1353, 0.5255, 0.1567]}, {"w": "easy:", "b": [0.5302, 0.1353, 0.5708, 0.1567]}]}, {"id": "b_2", "type": "paragraph", "text": ">>> forest_clf.fit(X_train, y_train) >>> forest_clf.predict([some_digit]) array([5], dtype=uint8)", "words": [{"w": ">>>", "b": [0.1766, 0.1673, 0.2019, 0.1801]}, {"w": "forest_clf.fit(X_train,", "b": [0.2103, 0.1673, 0.4043, 0.1801]}, {"w": "y_train)", "b": [0.4127, 0.1673, 0.4802, 0.1801]}, {"w": ">>>", "b": [0.1766, 0.1827, 0.2019, 0.1955]}, {"w": "forest_clf.predict([some_digit])", "b": [0.2103, 0.1827, 0.4802, 0.1955]}, {"w": "array([5],", "b": [0.1766, 0.1981, 0.2609, 0.2109]}, {"w": "dtype=uint8)", "b": [0.2693, 0.1981, 0.3705, 0.2109]}]}, {"id": "b_3", "type": "paragraph", "text": "This time Scikit-Learn did not have to run OvA or OvO because Random Forest classifiers can directly classify instances into multiple classes. You can call predict_proba() to get the list of probabilities that the classifier assigned to each instance for each class:", "words": [{"w": "This", "b": [0.1429, 0.2187, 0.1801, 0.2401]}, {"w": "time", "b": [0.1883, 0.2187, 0.2262, 0.2401]}, {"w": "Scikit-Learn", "b": [0.2344, 0.2187, 0.3367, 0.2401]}, {"w": "did", "b": [0.3449, 0.2187, 0.3725, 0.2401]}, {"w": "not", "b": [0.3807, 0.2187, 0.4091, 0.2401]}, {"w": "have", "b": [0.4173, 0.2187, 0.4557, 0.2401]}, {"w": "to", "b": [0.464, 0.2187, 0.481, 0.2401]}, {"w": "run", "b": [0.4892, 0.2187, 0.5194, 0.2401]}, {"w": "OvA", "b": [0.5276, 0.2187, 0.5676, 0.2401]}, {"w": "or", "b": [0.5758, 0.2187, 0.5942, 0.2401]}, {"w": "OvO", "b": [0.6024, 0.2187, 0.6435, 0.2401]}, {"w": "because", "b": [0.6517, 0.2187, 0.7163, 0.2401]}, {"w": "Random", "b": [0.7245, 0.2187, 0.7971, 0.2401]}, {"w": "Forest", "b": [0.8053, 0.2187, 0.8572, 0.2401]}, {"w": "classifiers", "b": [0.1429, 0.2378, 0.2229, 0.2592]}, {"w": "can", "b": [0.2381, 0.2378, 0.2674, 0.2592]}, {"w": "directly", "b": [0.2825, 0.2378, 0.3457, 0.2592]}, {"w": "classify", "b": [0.3608, 0.2378, 0.421, 0.2592]}, {"w": "instances", "b": [0.4361, 0.2378, 0.5129, 0.2592]}, {"w": "into", "b": [0.5281, 0.2378, 0.5616, 0.2592]}, {"w": "multiple", "b": [0.5767, 0.2378, 0.6467, 0.2592]}, {"w": "classes.", "b": [0.6618, 0.2378, 0.7216, 0.2592]}, {"w": "You", "b": [0.7367, 0.2378, 0.7691, 0.2592]}, {"w": "can", "b": [0.7842, 0.2378, 0.8135, 0.2592]}, {"w": "call", "b": [0.8286, 0.2378, 0.8571, 0.2592]}, {"w": "predict_proba()", "b": [0.1429, 0.2609, 0.2913, 0.276]}, {"w": "to", "b": [0.2992, 0.2577, 0.3161, 0.2791]}, {"w": "get", "b": [0.324, 0.2577, 0.3489, 0.2791]}, {"w": "the", "b": [0.3568, 0.2577, 0.3831, 0.2791]}, {"w": "list", "b": [0.391, 0.2577, 0.4158, 0.2791]}, {"w": "of", "b": [0.4237, 0.2577, 0.4405, 0.2791]}, {"w": "probabilities", "b": [0.4483, 0.2577, 0.5528, 0.2791]}, {"w": "that", "b": [0.5606, 0.2577, 0.5932, 0.2791]}, {"w": "the", "b": [0.601, 0.2577, 0.6274, 0.2791]}, {"w": "classifier", "b": [0.6352, 0.2577, 0.7077, 0.2791]}, {"w": "assigned", "b": [0.7155, 0.2577, 0.7865, 0.2791]}, {"w": "to", "b": [0.7944, 0.2577, 0.8114, 0.2791]}, {"w": "each", "b": [0.8192, 0.2577, 0.8572, 0.2791]}, {"w": "instance", "b": [0.1429, 0.2768, 0.212, 0.2982]}, {"w": "for", "b": [0.2168, 0.2768, 0.2413, 0.2982]}, {"w": "each", "b": [0.246, 0.2768, 0.284, 0.2982]}, {"w": "class:", "b": [0.2887, 0.2768, 0.332, 0.2982]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> forest_clf.predict_proba([some_digit]) array([[0. , 0. , 0.01, 0.08, 0. , 0.9 , 0. , 0. , 0. , 0.01]])", "words": [{"w": ">>>", "b": [0.1766, 0.3087, 0.2019, 0.3216]}, {"w": "forest_clf.predict_proba([some_digit])", "b": [0.2103, 0.3087, 0.5308, 0.3216]}, {"w": "array([[0.", "b": [0.1766, 0.3242, 0.2609, 0.337]}, {"w": ",", "b": [0.2778, 0.3242, 0.2862, 0.337]}, {"w": "0.", "b": [0.2946, 0.3242, 0.3115, 0.337]}, {"w": ",", "b": [0.3284, 0.3242, 0.3368, 0.337]}, {"w": "0.01,", "b": [0.3452, 0.3242, 0.3874, 0.337]}, {"w": "0.08,", "b": [0.3958, 0.3242, 0.438, 0.337]}, {"w": "0.", "b": [0.4464, 0.3242, 0.4633, 0.337]}, {"w": ",", "b": [0.4802, 0.3242, 0.4886, 0.337]}, {"w": "0.9", "b": [0.497, 0.3242, 0.5223, 0.337]}, {"w": ",", "b": [0.5308, 0.3242, 0.5392, 0.337]}, {"w": "0.", "b": [0.5476, 0.3242, 0.5645, 0.337]}, {"w": ",", "b": [0.5813, 0.3242, 0.5898, 0.337]}, {"w": "0.", "b": [0.5982, 0.3242, 0.6151, 0.337]}, {"w": ",", "b": [0.6319, 0.3242, 0.6404, 0.337]}, {"w": "0.", "b": [0.6488, 0.3242, 0.6657, 0.337]}, {"w": ",", "b": [0.6825, 0.3242, 0.691, 0.337]}, {"w": "0.01]])", "b": [0.6994, 0.3242, 0.7584, 0.337]}]}, {"id": "b_5", "type": "paragraph", "text": "You can see that the classifier is fairly confident about its prediction: the 0.9 at the 5th", "words": [{"w": "You", "b": [0.1428, 0.3448, 0.1752, 0.3662]}, {"w": "can", "b": [0.1807, 0.3448, 0.21, 0.3662]}, {"w": "see", "b": [0.2155, 0.3448, 0.2408, 0.3662]}, {"w": "that", "b": [0.2463, 0.3448, 0.2789, 0.3662]}, {"w": "the", "b": [0.2843, 0.3448, 0.3107, 0.3662]}, {"w": "classifier", "b": [0.3161, 0.3448, 0.3886, 0.3662]}, {"w": "is", "b": [0.394, 0.3448, 0.4073, 0.3662]}, {"w": "fairly", "b": [0.4127, 0.3448, 0.4562, 0.3662]}, {"w": "confident", "b": [0.4617, 0.3448, 0.5415, 0.3662]}, {"w": "about", "b": [0.5469, 0.3448, 0.5947, 0.3662]}, {"w": "its", "b": [0.6002, 0.3448, 0.6197, 0.3662]}, {"w": "prediction:", "b": [0.6252, 0.3448, 0.7168, 0.3662]}, {"w": "the", "b": [0.7223, 0.3448, 0.7486, 0.3662]}, {"w": "0.9", "b": [0.7541, 0.3448, 0.7788, 0.3662]}, {"w": "at", "b": [0.7843, 0.3448, 0.7994, 0.3662]}, {"w": "the", "b": [0.8048, 0.3448, 0.8312, 0.3662]}, {"w": "5th", "b": [0.8366, 0.3448, 0.8571, 0.3662]}]}, {"id": "b_6", "type": "paragraph", "text": "index in the array means that the model estimates a 90% probability that the image represents a 5. It also thinks that the image could instead be a 2, a 3 or a 9, respec‐ tively with 1%, 8% and 1% probability.", "words": [{"w": "index", "b": [0.1429, 0.3638, 0.1895, 0.3853]}, {"w": "in", "b": [0.1961, 0.3638, 0.2131, 0.3853]}, {"w": "the", "b": [0.2197, 0.3638, 0.246, 0.3853]}, {"w": "array", "b": [0.2526, 0.3638, 0.2955, 0.3853]}, {"w": "means", "b": [0.3021, 0.3638, 0.3562, 0.3853]}, {"w": "that", "b": [0.3628, 0.3638, 0.3954, 0.3853]}, {"w": "the", "b": [0.402, 0.3638, 0.4283, 0.3853]}, {"w": "model", "b": [0.4349, 0.3638, 0.4877, 0.3853]}, {"w": "estimates", "b": [0.4943, 0.3638, 0.5714, 0.3853]}, {"w": "a", "b": [0.578, 0.3638, 0.5872, 0.3853]}, {"w": "90%", "b": [0.5938, 0.3638, 0.6295, 0.3853]}, {"w": "probability", "b": [0.6361, 0.3638, 0.7281, 0.3853]}, {"w": "that", "b": [0.7346, 0.3638, 0.7672, 0.3853]}, {"w": "the", "b": [0.7738, 0.3638, 0.8002, 0.3853]}, {"w": "image", "b": [0.8067, 0.3638, 0.8571, 0.3853]}, {"w": "represents", "b": [0.1428, 0.3829, 0.2284, 0.4043]}, {"w": "a", "b": [0.2351, 0.3829, 0.2442, 0.4043]}, {"w": "5.", "b": [0.2508, 0.3829, 0.2656, 0.4043]}, {"w": "It", "b": [0.2722, 0.3829, 0.2849, 0.4043]}, {"w": "also", "b": [0.2915, 0.3829, 0.3242, 0.4043]}, {"w": "thinks", "b": [0.3308, 0.3829, 0.3833, 0.4043]}, {"w": "that", "b": [0.3899, 0.3829, 0.4225, 0.4043]}, {"w": "the", "b": [0.4291, 0.3829, 0.4554, 0.4043]}, {"w": "image", "b": [0.4621, 0.3829, 0.5125, 0.4043]}, {"w": "could", "b": [0.5191, 0.3829, 0.5659, 0.4043]}, {"w": "instead", "b": [0.5725, 0.3829, 0.6325, 0.4043]}, {"w": "be", "b": [0.6391, 0.3829, 0.6586, 0.4043]}, {"w": "a", "b": [0.6652, 0.3829, 0.6743, 0.4043]}, {"w": "2,", "b": [0.681, 0.3829, 0.6957, 0.4043]}, {"w": "a", "b": [0.7023, 0.3829, 0.7115, 0.4043]}, {"w": "3", "b": [0.7181, 0.3829, 0.7281, 0.4043]}, {"w": "or", "b": [0.7348, 0.3829, 0.7531, 0.4043]}, {"w": "a", "b": [0.7597, 0.3829, 0.7689, 0.4043]}, {"w": "9,", "b": [0.7755, 0.3829, 0.7903, 0.4043]}, {"w": "respec‐", "b": [0.7969, 0.3829, 0.8571, 0.4043]}, {"w": "tively", "b": [0.1429, 0.4019, 0.1881, 0.4234]}, {"w": "with", "b": [0.1929, 0.4019, 0.2302, 0.4234]}, {"w": "1%,", "b": [0.2349, 0.4019, 0.2654, 0.4234]}, {"w": "8%", "b": [0.2702, 0.4019, 0.2959, 0.4234]}, {"w": "and", "b": [0.3006, 0.4019, 0.3322, 0.4234]}, {"w": "1%", "b": [0.3369, 0.4019, 0.3627, 0.4234]}, {"w": "probability.", "b": [0.3674, 0.4019, 0.4626, 0.4234]}]}, {"id": "b_7", "type": "paragraph", "text": "Now of course you want to evaluate these classifiers. As usual, you want to use cross- validation. Let’s evaluate the SGDClassifier’s accuracy using the cross_val_score() function:", "words": [{"w": "Now", "b": [0.1429, 0.4301, 0.1827, 0.4515]}, {"w": "of", "b": [0.1881, 0.4301, 0.2049, 0.4515]}, {"w": "course", "b": [0.2103, 0.4301, 0.265, 0.4515]}, {"w": "you", "b": [0.2704, 0.4301, 0.3017, 0.4515]}, {"w": "want", "b": [0.3071, 0.4301, 0.3478, 0.4515]}, {"w": "to", "b": [0.3532, 0.4301, 0.3702, 0.4515]}, {"w": "evaluate", "b": [0.3756, 0.4301, 0.4435, 0.4515]}, {"w": "these", "b": [0.4489, 0.4301, 0.4918, 0.4515]}, {"w": "classifiers.", "b": [0.4972, 0.4301, 0.582, 0.4515]}, {"w": "As", "b": [0.5874, 0.4301, 0.6094, 0.4515]}, {"w": "usual,", "b": [0.6148, 0.4301, 0.6637, 0.4515]}, {"w": "you", "b": [0.6691, 0.4301, 0.7004, 0.4515]}, {"w": "want", "b": [0.7058, 0.4301, 0.7466, 0.4515]}, {"w": "to", "b": [0.7519, 0.4301, 0.7689, 0.4515]}, {"w": "use", "b": [0.7743, 0.4301, 0.8019, 0.4515]}, {"w": "cross-", "b": [0.8073, 0.4301, 0.8572, 0.4515]}, {"w": "validation.", "b": [0.1429, 0.45, 0.231, 0.4714]}, {"w": "Let’s", "b": [0.2364, 0.45, 0.2726, 0.4714]}, {"w": "evaluate", "b": [0.2781, 0.45, 0.346, 0.4714]}, {"w": "the", "b": [0.3515, 0.45, 0.3778, 0.4714]}, {"w": "SGDClassifier’s", "b": [0.3833, 0.45, 0.5222, 0.4714]}, {"w": "accuracy", "b": [0.5277, 0.45, 0.6008, 0.4714]}, {"w": "using", "b": [0.6062, 0.45, 0.6517, 0.4714]}, {"w": "the", "b": [0.6571, 0.45, 0.6835, 0.4714]}, {"w": "cross_val_score()", "b": [0.6889, 0.4532, 0.8571, 0.4683]}, {"w": "function:", "b": [0.1429, 0.4691, 0.219, 0.4905]}]}, {"id": "b_8", "type": "paragraph", "text": ">>> cross_val_score(sgd_clf, X_train, y_train, cv=3, scoring=\"accuracy\") array([0.8489802 , 0.87129356, 0.86988048])", "words": [{"w": ">>>", "b": [0.1766, 0.501, 0.2019, 0.5139]}, {"w": "cross_val_score(sgd_clf,", "b": [0.2103, 0.501, 0.4127, 0.5139]}, {"w": "X_train,", "b": [0.4211, 0.501, 0.4886, 0.5139]}, {"w": "y_train,", "b": [0.497, 0.501, 0.5645, 0.5139]}, {"w": "cv=3,", "b": [0.5729, 0.501, 0.6151, 0.5139]}, {"w": "scoring=\"accuracy\")", "b": [0.6235, 0.501, 0.7837, 0.5139]}, {"w": "array([0.8489802", "b": [0.1766, 0.5164, 0.3115, 0.5293]}, {"w": ",", "b": [0.3199, 0.5164, 0.3284, 0.5293]}, {"w": "0.87129356,", "b": [0.3368, 0.5164, 0.4296, 0.5293]}, {"w": "0.86988048])", "b": [0.438, 0.5164, 0.5392, 0.5293]}]}, {"id": "b_9", "type": "paragraph", "text": "It gets over 84% on all test folds. If you used a random classifier, you would get 10% accuracy, so this is not such a bad score, but you can still do much better. For exam‐ ple, simply scaling the inputs (as discussed in Chapter 2) increases accuracy above 89%:", "words": [{"w": "It", "b": [0.1428, 0.5371, 0.1555, 0.5585]}, {"w": "gets", "b": [0.1614, 0.5371, 0.194, 0.5585]}, {"w": "over", "b": [0.2, 0.5371, 0.2368, 0.5585]}, {"w": "84%", "b": [0.2427, 0.5371, 0.2785, 0.5585]}, {"w": "on", "b": [0.2844, 0.5371, 0.3064, 0.5585]}, {"w": "all", "b": [0.3124, 0.5371, 0.3321, 0.5585]}, {"w": "test", "b": [0.338, 0.5371, 0.3672, 0.5585]}, {"w": "folds.", "b": [0.3731, 0.5371, 0.4186, 0.5585]}, {"w": "If", "b": [0.4245, 0.5371, 0.4378, 0.5585]}, {"w": "you", "b": [0.4437, 0.5371, 0.475, 0.5585]}, {"w": "used", "b": [0.4809, 0.5371, 0.5195, 0.5585]}, {"w": "a", "b": [0.5254, 0.5371, 0.5345, 0.5585]}, {"w": "random", "b": [0.5405, 0.5371, 0.6074, 0.5585]}, {"w": "classifier,", "b": [0.6134, 0.5371, 0.6892, 0.5585]}, {"w": "you", "b": [0.6952, 0.5371, 0.7264, 0.5585]}, {"w": "would", "b": [0.7323, 0.5371, 0.7846, 0.5585]}, {"w": "get", "b": [0.7905, 0.5371, 0.8155, 0.5585]}, {"w": "10%", "b": [0.8214, 0.5371, 0.8571, 0.5585]}, {"w": "accuracy,", "b": [0.1429, 0.5561, 0.2192, 0.5775]}, {"w": "so", "b": [0.225, 0.5561, 0.2433, 0.5775]}, {"w": "this", "b": [0.2491, 0.5561, 0.2798, 0.5775]}, {"w": "is", "b": [0.2856, 0.5561, 0.2989, 0.5775]}, {"w": "not", "b": [0.3047, 0.5561, 0.333, 0.5775]}, {"w": "such", "b": [0.3389, 0.5561, 0.3775, 0.5775]}, {"w": "a", "b": [0.3833, 0.5561, 0.3925, 0.5775]}, {"w": "bad", "b": [0.3983, 0.5561, 0.429, 0.5775]}, {"w": "score,", "b": [0.4349, 0.5561, 0.4833, 0.5775]}, {"w": "but", "b": [0.4891, 0.5561, 0.5171, 0.5775]}, {"w": "you", "b": [0.5229, 0.5561, 0.5542, 0.5775]}, {"w": "can", "b": [0.56, 0.5561, 0.5893, 0.5775]}, {"w": "still", "b": [0.5952, 0.5561, 0.6253, 0.5775]}, {"w": "do", "b": [0.6311, 0.5561, 0.6527, 0.5775]}, {"w": "much", "b": [0.6586, 0.5561, 0.7062, 0.5775]}, {"w": "better.", "b": [0.712, 0.5561, 0.7642, 0.5775]}, {"w": "For", "b": [0.77, 0.5561, 0.799, 0.5775]}, {"w": "exam‐", "b": [0.8048, 0.5561, 0.8572, 0.5775]}, {"w": "ple,", "b": [0.1429, 0.5752, 0.1727, 0.5966]}, {"w": "simply", "b": [0.1801, 0.5752, 0.2358, 0.5966]}, {"w": "scaling", "b": [0.2433, 0.5752, 0.3009, 0.5966]}, {"w": "the", "b": [0.3083, 0.5752, 0.3347, 0.5966]}, {"w": "inputs", "b": [0.3421, 0.5752, 0.3947, 0.5966]}, {"w": "(as", "b": [0.4022, 0.5752, 0.4262, 0.5966]}, {"w": "discussed", "b": [0.4337, 0.5752, 0.5129, 0.5966]}, {"w": "in", "b": [0.5204, 0.5752, 0.5374, 0.5966]}, {"w": "Chapter", "b": [0.5448, 0.5752, 0.6124, 0.5966]}, {"w": "2)", "b": [0.6199, 0.5752, 0.6371, 0.5966]}, {"w": "increases", "b": [0.6446, 0.5752, 0.7203, 0.5966]}, {"w": "accuracy", "b": [0.7277, 0.5752, 0.8008, 0.5966]}, {"w": "above", "b": [0.8083, 0.5752, 0.8571, 0.5966]}, {"w": "89%:", "b": [0.1429, 0.5942, 0.1834, 0.6156]}]}, {"id": "b_10", "type": "paragraph", "text": ">>> from sklearn.preprocessing import StandardScaler >>> scaler = StandardScaler() >>> X_train_scaled = scaler.fit_transform(X_train.astype(np.float64)) >>> cross_val_score(sgd_clf, X_train_scaled, y_train, cv=3, scoring=\"accuracy\") array([0.89707059, 0.8960948 , 0.90693604])", "words": [{"w": ">>>", "b": [0.1766, 0.6262, 0.2019, 0.639]}, {"w": "from", "b": [0.2103, 0.6262, 0.2441, 0.639]}, {"w": "sklearn.preprocessing", "b": [0.2525, 0.6262, 0.4296, 0.639]}, {"w": "import", "b": [0.438, 0.6262, 0.4886, 0.639]}, {"w": "StandardScaler", "b": [0.497, 0.6262, 0.6151, 0.639]}, {"w": ">>>", "b": [0.1766, 0.6416, 0.2019, 0.6545]}, {"w": "scaler", "b": [0.2103, 0.6416, 0.2609, 0.6545]}, {"w": "=", "b": [0.2693, 0.6416, 0.2778, 0.6545]}, {"w": "StandardScaler()", "b": [0.2862, 0.6416, 0.4211, 0.6545]}, {"w": ">>>", "b": [0.1766, 0.657, 0.2019, 0.6699]}, {"w": "X_train_scaled", "b": [0.2103, 0.657, 0.3284, 0.6699]}, {"w": "=", "b": [0.3368, 0.657, 0.3452, 0.6699]}, {"w": "scaler.fit_transform(X_train.astype(np.float64))", "b": [0.3537, 0.657, 0.7584, 0.6699]}, {"w": ">>>", "b": [0.1766, 0.6725, 0.2019, 0.6853]}, {"w": "cross_val_score(sgd_clf,", "b": [0.2103, 0.6725, 0.4127, 0.6853]}, {"w": "X_train_scaled,", "b": [0.4211, 0.6725, 0.5476, 0.6853]}, {"w": "y_train,", "b": [0.5561, 0.6725, 0.6235, 0.6853]}, {"w": "cv=3,", "b": [0.6319, 0.6725, 0.6741, 0.6853]}, {"w": "scoring=\"accuracy\")", "b": [0.6825, 0.6725, 0.8428, 0.6853]}, {"w": "array([0.89707059,", "b": [0.1766, 0.6879, 0.3284, 0.7007]}, {"w": "0.8960948", "b": [0.3368, 0.6879, 0.4127, 0.7007]}, {"w": ",", "b": [0.4211, 0.6879, 0.4296, 0.7007]}, {"w": "0.90693604])", "b": [0.438, 0.6879, 0.5392, 0.7007]}]}, {"id": "b_11", "type": "paragraph", "text": "Error Analysis", "words": [{"w": "Error", "b": [0.1428, 0.7148, 0.2031, 0.7491]}, {"w": "Analysis", "b": [0.209, 0.7148, 0.3096, 0.7491]}]}, {"id": "b_12", "type": "paragraph", "text": "Of course, if this were a real project, you would follow the steps in your Machine Learning project checklist (see ???): exploring data preparation options, trying out multiple models, shortlisting the best ones and fine-tuning their hyperparameters using GridSearchCV, and automating as much as possible, as you did in the previous chapter. Here, we will assume that you have found a promising model and you want to find ways to improve it. One way to do this is to analyze the types of errors it makes.", "words": [{"w": "Of", "b": [0.1429, 0.756, 0.1646, 0.7774]}, {"w": "course,", "b": [0.1723, 0.756, 0.2317, 0.7774]}, {"w": "if", "b": [0.2394, 0.756, 0.2511, 0.7774]}, {"w": "this", "b": [0.2588, 0.756, 0.2895, 0.7774]}, {"w": "were", "b": [0.2972, 0.756, 0.3369, 0.7774]}, {"w": "a", "b": [0.3445, 0.756, 0.3537, 0.7774]}, {"w": "real", "b": [0.3613, 0.756, 0.3923, 0.7774]}, {"w": "project,", "b": [0.4, 0.756, 0.4634, 0.7774]}, {"w": "you", "b": [0.471, 0.756, 0.5023, 0.7774]}, {"w": "would", "b": [0.5099, 0.756, 0.5622, 0.7774]}, {"w": "follow", "b": [0.5698, 0.756, 0.622, 0.7774]}, {"w": "the", "b": [0.6297, 0.756, 0.656, 0.7774]}, {"w": "steps", "b": [0.6637, 0.756, 0.7051, 0.7774]}, {"w": "in", "b": [0.7128, 0.756, 0.7297, 0.7774]}, {"w": "your", "b": [0.7374, 0.756, 0.7764, 0.7774]}, {"w": "Machine", "b": [0.784, 0.756, 0.8572, 0.7774]}, {"w": "Learning", "b": [0.1429, 0.775, 0.2179, 0.7964]}, {"w": "project", "b": [0.2259, 0.775, 0.2845, 0.7964]}, {"w": "checklist", "b": [0.2924, 0.775, 0.3652, 0.7964]}, {"w": "(see", "b": [0.3732, 0.775, 0.4057, 0.7964]}, {"w": "???):", "b": [0.4137, 0.775, 0.4493, 0.7964]}, {"w": "exploring", "b": [0.4573, 0.775, 0.5372, 0.7964]}, {"w": "data", "b": [0.5452, 0.775, 0.5804, 0.7964]}, {"w": "preparation", "b": [0.5884, 0.775, 0.6864, 0.7964]}, {"w": "options,", "b": [0.6943, 0.775, 0.7622, 0.7964]}, {"w": "trying", "b": [0.7702, 0.775, 0.8212, 0.7964]}, {"w": "out", "b": [0.8291, 0.775, 0.8571, 0.7964]}, {"w": "multiple", "b": [0.1429, 0.7941, 0.2128, 0.8155]}, {"w": "models,", "b": [0.2216, 0.7941, 0.2868, 0.8155]}, {"w": "shortlisting", "b": [0.2955, 0.7941, 0.3905, 0.8155]}, {"w": "the", "b": [0.3993, 0.7941, 0.4256, 0.8155]}, {"w": "best", "b": [0.4343, 0.7941, 0.4677, 0.8155]}, {"w": "ones", "b": [0.4765, 0.7941, 0.515, 0.8155]}, {"w": "and", "b": [0.5237, 0.7941, 0.5552, 0.8155]}, {"w": "fine-tuning", "b": [0.564, 0.7941, 0.6589, 0.8155]}, {"w": "their", "b": [0.6676, 0.7941, 0.7073, 0.8155]}, {"w": "hyperparameters", "b": [0.716, 0.7941, 0.8571, 0.8155]}, {"w": "using", "b": [0.1429, 0.814, 0.1883, 0.8354]}, {"w": "GridSearchCV,", "b": [0.194, 0.814, 0.3175, 0.8354]}, {"w": "and", "b": [0.3232, 0.814, 0.3547, 0.8354]}, {"w": "automating", "b": [0.3604, 0.814, 0.4561, 0.8354]}, {"w": "as", "b": [0.4618, 0.814, 0.4786, 0.8354]}, {"w": "much", "b": [0.4843, 0.814, 0.5319, 0.8354]}, {"w": "as", "b": [0.5376, 0.814, 0.5544, 0.8354]}, {"w": "possible,", "b": [0.5601, 0.814, 0.632, 0.8354]}, {"w": "as", "b": [0.6377, 0.814, 0.6545, 0.8354]}, {"w": "you", "b": [0.6602, 0.814, 0.6914, 0.8354]}, {"w": "did", "b": [0.6971, 0.814, 0.7247, 0.8354]}, {"w": "in", "b": [0.7304, 0.814, 0.7474, 0.8354]}, {"w": "the", "b": [0.753, 0.814, 0.7794, 0.8354]}, {"w": "previous", "b": [0.7851, 0.814, 0.8571, 0.8354]}, {"w": "chapter.", "b": [0.1429, 0.8331, 0.2088, 0.8545]}, {"w": "Here,", "b": [0.2148, 0.8331, 0.2604, 0.8545]}, {"w": "we", "b": [0.2664, 0.8331, 0.2895, 0.8545]}, {"w": "will", "b": [0.2955, 0.8331, 0.3259, 0.8545]}, {"w": "assume", "b": [0.3318, 0.8331, 0.3933, 0.8545]}, {"w": "that", "b": [0.3992, 0.8331, 0.4318, 0.8545]}, {"w": "you", "b": [0.4378, 0.8331, 0.469, 0.8545]}, {"w": "have", "b": [0.475, 0.8331, 0.5134, 0.8545]}, {"w": "found", "b": [0.5193, 0.8331, 0.5696, 0.8545]}, {"w": "a", "b": [0.5755, 0.8331, 0.5847, 0.8545]}, {"w": "promising", "b": [0.5906, 0.8331, 0.6769, 0.8545]}, {"w": "model", "b": [0.6829, 0.8331, 0.7357, 0.8545]}, {"w": "and", "b": [0.7417, 0.8331, 0.7732, 0.8545]}, {"w": "you", "b": [0.7792, 0.8331, 0.8104, 0.8545]}, {"w": "want", "b": [0.8164, 0.8331, 0.8572, 0.8545]}, {"w": "to", "b": [0.1429, 0.8521, 0.1598, 0.8735]}, {"w": "find", "b": [0.1676, 0.8521, 0.2018, 0.8735]}, {"w": "ways", "b": [0.2096, 0.8521, 0.2498, 0.8735]}, {"w": "to", "b": [0.2576, 0.8521, 0.2746, 0.8735]}, {"w": "improve", "b": [0.2824, 0.8521, 0.3524, 0.8735]}, {"w": "it.", "b": [0.3602, 0.8521, 0.3769, 0.8735]}, {"w": "One", "b": [0.3847, 0.8521, 0.4206, 0.8735]}, {"w": "way", "b": [0.4284, 0.8521, 0.461, 0.8735]}, {"w": "to", "b": [0.4688, 0.8521, 0.4857, 0.8735]}, {"w": "do", "b": [0.4935, 0.8521, 0.5152, 0.8735]}, {"w": "this", "b": [0.523, 0.8521, 0.5537, 0.8735]}, {"w": "is", "b": [0.5615, 0.8521, 0.5747, 0.8735]}, {"w": "to", "b": [0.5825, 0.8521, 0.5995, 0.8735]}, {"w": "analyze", "b": [0.6073, 0.8521, 0.6694, 0.8735]}, {"w": "the", "b": [0.6772, 0.8521, 0.7036, 0.8735]}, {"w": "types", "b": [0.7114, 0.8521, 0.7547, 0.8735]}, {"w": "of", "b": [0.7625, 0.8521, 0.7793, 0.8735]}, {"w": "errors", "b": [0.7871, 0.8521, 0.8374, 0.8735]}, {"w": "it", "b": [0.8452, 0.8521, 0.8571, 0.8735]}, {"w": "makes.", "b": [0.1429, 0.8712, 0.2006, 0.8926]}]}, {"id": "b_13", "type": "paragraph", "text": "104 | Chapter 3: Classification", "words": [{"w": "104", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "3:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Classification", "b": [0.2673, 0.9225, 0.3443, 0.9388]}]}]}, {"page": 131, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "First, you can look at the confusion matrix. You need to make predictions using the cross_val_predict() function, then call the confusion_matrix() function, just like you did earlier:", "words": [{"w": "First,", "b": [0.1429, 0.0791, 0.1859, 0.1005]}, {"w": "you", "b": [0.1922, 0.0791, 0.2235, 0.1005]}, {"w": "can", "b": [0.2297, 0.0791, 0.2591, 0.1005]}, {"w": "look", "b": [0.2654, 0.0791, 0.3022, 0.1005]}, {"w": "at", "b": [0.3085, 0.0791, 0.3236, 0.1005]}, {"w": "the", "b": [0.3299, 0.0791, 0.3562, 0.1005]}, {"w": "confusion", "b": [0.3625, 0.0791, 0.4458, 0.1005]}, {"w": "matrix.", "b": [0.4521, 0.0791, 0.5121, 0.1005]}, {"w": "You", "b": [0.5184, 0.0791, 0.5508, 0.1005]}, {"w": "need", "b": [0.557, 0.0791, 0.5971, 0.1005]}, {"w": "to", "b": [0.6034, 0.0791, 0.6204, 0.1005]}, {"w": "make", "b": [0.6267, 0.0791, 0.6721, 0.1005]}, {"w": "predictions", "b": [0.6783, 0.0791, 0.7728, 0.1005]}, {"w": "using", "b": [0.7791, 0.0791, 0.8245, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}, {"w": "cross_val_predict()", "b": [0.1429, 0.1022, 0.3309, 0.1173]}, {"w": "function,", "b": [0.3362, 0.099, 0.4124, 0.1204]}, {"w": "then", "b": [0.4177, 0.099, 0.4555, 0.1204]}, {"w": "call", "b": [0.4608, 0.099, 0.4893, 0.1204]}, {"w": "the", "b": [0.4947, 0.099, 0.521, 0.1204]}, {"w": "confusion_matrix()", "b": [0.5264, 0.1022, 0.7045, 0.1173]}, {"w": "function,", "b": [0.7098, 0.099, 0.786, 0.1204]}, {"w": "just", "b": [0.7913, 0.099, 0.8217, 0.1204]}, {"w": "like", "b": [0.8271, 0.099, 0.8571, 0.1204]}, {"w": "you", "b": [0.1429, 0.1181, 0.1741, 0.1395]}, {"w": "did", "b": [0.1788, 0.1181, 0.2064, 0.1395]}, {"w": "earlier:", "b": [0.2111, 0.1181, 0.2696, 0.1395]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> y_train_pred = cross_val_predict(sgd_clf, X_train_scaled, y_train, cv=3) >>> conf_mx = confusion_matrix(y_train, y_train_pred) >>> conf_mx array([[5578, 0, 22, 7, 8, 45, 35, 5, 222, 1], [ 0, 6410, 35, 26, 4, 44, 4, 8, 198, 13], [ 28, 27, 5232, 100, 74, 27, 68, 37, 354, 11], [ 23, 18, 115, 5254, 2, 209, 26, 38, 373, 73], [ 11, 14, 45, 12, 5219, 11, 33, 26, 299, 172], [ 26, 16, 31, 173, 54, 4484, 76, 14, 482, 65], [ 31, 17, 45, 2, 42, 98, 5556, 3, 123, 1], [ 20, 10, 53, 27, 50, 13, 3, 5696, 173, 220], [ 17, 64, 47, 91, 3, 125, 24, 11, 5421, 48], [ 24, 18, 29, 67, 116, 39, 1, 174, 329, 5152]])", "words": [{"w": ">>>", "b": [0.1766, 0.15, 0.2019, 0.1629]}, {"w": "y_train_pred", "b": [0.2103, 0.15, 0.3115, 0.1629]}, {"w": "=", "b": [0.3199, 0.15, 0.3284, 0.1629]}, {"w": "cross_val_predict(sgd_clf,", "b": [0.3368, 0.15, 0.556, 0.1629]}, {"w": "X_train_scaled,", "b": [0.5645, 0.15, 0.691, 0.1629]}, {"w": "y_train,", "b": [0.6994, 0.15, 0.7669, 0.1629]}, {"w": "cv=3)", "b": [0.7753, 0.15, 0.8175, 0.1629]}, {"w": ">>>", "b": [0.1766, 0.1654, 0.2019, 0.1783]}, {"w": "conf_mx", "b": [0.2103, 0.1654, 0.2693, 0.1783]}, {"w": "=", "b": [0.2778, 0.1654, 0.2862, 0.1783]}, {"w": "confusion_matrix(y_train,", "b": [0.2946, 0.1654, 0.5055, 0.1783]}, {"w": "y_train_pred)", "b": [0.5139, 0.1654, 0.6235, 0.1783]}, {"w": ">>>", "b": [0.1766, 0.1809, 0.2019, 0.1937]}, {"w": "conf_mx", "b": [0.2103, 0.1809, 0.2693, 0.1937]}, {"w": "array([[5578,", "b": [0.1766, 0.1963, 0.2862, 0.2091]}, {"w": "0,", "b": [0.3199, 0.1963, 0.3368, 0.2091]}, {"w": "22,", "b": [0.3621, 0.1963, 0.3874, 0.2091]}, {"w": "7,", "b": [0.4211, 0.1963, 0.438, 0.2091]}, {"w": "8,", "b": [0.4717, 0.1963, 0.4886, 0.2091]}, {"w": "45,", "b": [0.5139, 0.1963, 0.5392, 0.2091]}, {"w": "35,", "b": [0.5645, 0.1963, 0.5898, 0.2091]}, {"w": "5,", "b": [0.6235, 0.1963, 0.6404, 0.2091]}, {"w": "222,", "b": [0.6572, 0.1963, 0.691, 0.2091]}, {"w": "1],", "b": [0.7247, 0.1963, 0.75, 0.2091]}, {"w": "[", "b": [0.2356, 0.2117, 0.244, 0.2246]}, {"w": "0,", "b": [0.2693, 0.2117, 0.2862, 0.2246]}, {"w": "6410,", "b": [0.2946, 0.2117, 0.3368, 0.2246]}, {"w": "35,", "b": [0.3621, 0.2117, 0.3874, 0.2246]}, {"w": "26,", "b": [0.4127, 0.2117, 0.438, 0.2246]}, {"w": "4,", "b": [0.4717, 0.2117, 0.4886, 0.2246]}, {"w": "44,", "b": [0.5139, 0.2117, 0.5392, 0.2246]}, {"w": "4,", "b": [0.5729, 0.2117, 0.5898, 0.2246]}, {"w": "8,", "b": [0.6235, 0.2117, 0.6404, 0.2246]}, {"w": "198,", "b": [0.6572, 0.2117, 0.691, 0.2246]}, {"w": "13],", "b": [0.7163, 0.2117, 0.75, 0.2246]}, {"w": "[", "b": [0.2356, 0.2271, 0.244, 0.24]}, {"w": "28,", "b": [0.2609, 0.2271, 0.2862, 0.24]}, {"w": "27,", "b": [0.3115, 0.2271, 0.3368, 0.24]}, {"w": "5232,", "b": [0.3452, 0.2271, 0.3874, 0.24]}, {"w": "100,", "b": [0.4043, 0.2271, 0.438, 0.24]}, {"w": "74,", "b": [0.4633, 0.2271, 0.4886, 0.24]}, {"w": "27,", "b": [0.5139, 0.2271, 0.5392, 0.24]}, {"w": "68,", "b": [0.5645, 0.2271, 0.5898, 0.24]}, {"w": "37,", "b": [0.6151, 0.2271, 0.6404, 0.24]}, {"w": "354,", "b": [0.6572, 0.2271, 0.691, 0.24]}, {"w": "11],", "b": [0.7163, 0.2271, 0.75, 0.24]}, {"w": "[", "b": [0.2356, 0.2425, 0.244, 0.2554]}, {"w": "23,", "b": [0.2609, 0.2425, 0.2862, 0.2554]}, {"w": "18,", "b": [0.3115, 0.2425, 0.3368, 0.2554]}, {"w": "115,", "b": [0.3537, 0.2425, 0.3874, 0.2554]}, {"w": "5254,", "b": [0.3958, 0.2425, 0.438, 0.2554]}, {"w": "2,", "b": [0.4717, 0.2425, 0.4886, 0.2554]}, {"w": "209,", "b": [0.5055, 0.2425, 0.5392, 0.2554]}, {"w": "26,", "b": [0.5645, 0.2425, 0.5898, 0.2554]}, {"w": "38,", "b": [0.6151, 0.2425, 0.6404, 0.2554]}, {"w": "373,", "b": [0.6572, 0.2425, 0.691, 0.2554]}, {"w": "73],", "b": [0.7163, 0.2425, 0.75, 0.2554]}, {"w": "[", "b": [0.2356, 0.258, 0.244, 0.2708]}, {"w": "11,", "b": [0.2609, 0.258, 0.2862, 0.2708]}, {"w": "14,", "b": [0.3115, 0.258, 0.3368, 0.2708]}, {"w": "45,", "b": [0.3621, 0.258, 0.3874, 0.2708]}, {"w": "12,", "b": [0.4127, 0.258, 0.438, 0.2708]}, {"w": "5219,", "b": [0.4464, 0.258, 0.4886, 0.2708]}, {"w": "11,", "b": [0.5139, 0.258, 0.5392, 0.2708]}, {"w": "33,", "b": [0.5645, 0.258, 0.5898, 0.2708]}, {"w": "26,", "b": [0.6151, 0.258, 0.6404, 0.2708]}, {"w": "299,", "b": [0.6572, 0.258, 0.691, 0.2708]}, {"w": "172],", "b": [0.7078, 0.258, 0.75, 0.2708]}, {"w": "[", "b": [0.2356, 0.2734, 0.244, 0.2862]}, {"w": "26,", "b": [0.2609, 0.2734, 0.2862, 0.2862]}, {"w": "16,", "b": [0.3115, 0.2734, 0.3368, 0.2862]}, {"w": "31,", "b": [0.3621, 0.2734, 0.3874, 0.2862]}, {"w": "173,", "b": [0.4043, 0.2734, 0.438, 0.2862]}, {"w": "54,", "b": [0.4633, 0.2734, 0.4886, 0.2862]}, {"w": "4484,", "b": [0.497, 0.2734, 0.5392, 0.2862]}, {"w": "76,", "b": [0.5645, 0.2734, 0.5898, 0.2862]}, {"w": "14,", "b": [0.6151, 0.2734, 0.6404, 0.2862]}, {"w": "482,", "b": [0.6572, 0.2734, 0.691, 0.2862]}, {"w": "65],", "b": [0.7163, 0.2734, 0.75, 0.2862]}, {"w": "[", "b": [0.2356, 0.2888, 0.244, 0.3017]}, {"w": "31,", "b": [0.2609, 0.2888, 0.2862, 0.3017]}, {"w": "17,", "b": [0.3115, 0.2888, 0.3368, 0.3017]}, {"w": "45,", "b": [0.3621, 0.2888, 0.3874, 0.3017]}, {"w": "2,", "b": [0.4211, 0.2888, 0.438, 0.3017]}, {"w": "42,", "b": [0.4633, 0.2888, 0.4886, 0.3017]}, {"w": "98,", "b": [0.5139, 0.2888, 0.5392, 0.3017]}, {"w": "5556,", "b": [0.5476, 0.2888, 0.5898, 0.3017]}, {"w": "3,", "b": [0.6235, 0.2888, 0.6404, 0.3017]}, {"w": "123,", "b": [0.6572, 0.2888, 0.691, 0.3017]}, {"w": "1],", "b": [0.7247, 0.2888, 0.75, 0.3017]}, {"w": "[", "b": [0.2356, 0.3042, 0.244, 0.3171]}, {"w": "20,", "b": [0.2609, 0.3042, 0.2862, 0.3171]}, {"w": "10,", "b": [0.3115, 0.3042, 0.3368, 0.3171]}, {"w": "53,", "b": [0.3621, 0.3042, 0.3874, 0.3171]}, {"w": "27,", "b": [0.4127, 0.3042, 0.438, 0.3171]}, {"w": "50,", "b": [0.4633, 0.3042, 0.4886, 0.3171]}, {"w": "13,", "b": [0.5139, 0.3042, 0.5392, 0.3171]}, {"w": "3,", "b": [0.5729, 0.3042, 0.5898, 0.3171]}, {"w": "5696,", "b": [0.5982, 0.3042, 0.6404, 0.3171]}, {"w": "173,", "b": [0.6572, 0.3042, 0.691, 0.3171]}, {"w": "220],", "b": [0.7078, 0.3042, 0.75, 0.3171]}, {"w": "[", "b": [0.2356, 0.3196, 0.244, 0.3325]}, {"w": "17,", "b": [0.2609, 0.3196, 0.2862, 0.3325]}, {"w": "64,", "b": [0.3115, 0.3196, 0.3368, 0.3325]}, {"w": "47,", "b": [0.3621, 0.3196, 0.3874, 0.3325]}, {"w": "91,", "b": [0.4127, 0.3196, 0.438, 0.3325]}, {"w": "3,", "b": [0.4717, 0.3196, 0.4886, 0.3325]}, {"w": "125,", "b": [0.5055, 0.3196, 0.5392, 0.3325]}, {"w": "24,", "b": [0.5645, 0.3196, 0.5898, 0.3325]}, {"w": "11,", "b": [0.6151, 0.3196, 0.6404, 0.3325]}, {"w": "5421,", "b": [0.6488, 0.3196, 0.691, 0.3325]}, {"w": "48],", "b": [0.7163, 0.3196, 0.75, 0.3325]}, {"w": "[", "b": [0.2356, 0.3351, 0.244, 0.3479]}, {"w": "24,", "b": [0.2609, 0.3351, 0.2862, 0.3479]}, {"w": "18,", "b": [0.3115, 0.3351, 0.3368, 0.3479]}, {"w": "29,", "b": [0.3621, 0.3351, 0.3874, 0.3479]}, {"w": "67,", "b": [0.4127, 0.3351, 0.438, 0.3479]}, {"w": "116,", "b": [0.4549, 0.3351, 0.4886, 0.3479]}, {"w": "39,", "b": [0.5139, 0.3351, 0.5392, 0.3479]}, {"w": "1,", "b": [0.5729, 0.3351, 0.5898, 0.3479]}, {"w": "174,", "b": [0.6066, 0.3351, 0.6404, 0.3479]}, {"w": "329,", "b": [0.6572, 0.3351, 0.691, 0.3479]}, {"w": "5152]])", "b": [0.6994, 0.3351, 0.7584, 0.3479]}]}, {"id": "b_2", "type": "paragraph", "text": "That’s a lot of numbers. It’s often more convenient to look at an image representation of the confusion matrix, using Matplotlib’s matshow() function:", "words": [{"w": "That’s", "b": [0.1429, 0.3557, 0.1917, 0.3771]}, {"w": "a", "b": [0.1971, 0.3557, 0.2063, 0.3771]}, {"w": "lot", "b": [0.2117, 0.3557, 0.2339, 0.3771]}, {"w": "of", "b": [0.2394, 0.3557, 0.2562, 0.3771]}, {"w": "numbers.", "b": [0.2616, 0.3557, 0.3403, 0.3771]}, {"w": "It’s", "b": [0.3457, 0.3557, 0.3681, 0.3771]}, {"w": "often", "b": [0.3735, 0.3557, 0.4169, 0.3771]}, {"w": "more", "b": [0.4223, 0.3557, 0.4666, 0.3771]}, {"w": "convenient", "b": [0.472, 0.3557, 0.5641, 0.3771]}, {"w": "to", "b": [0.5695, 0.3557, 0.5865, 0.3771]}, {"w": "look", "b": [0.5919, 0.3557, 0.6288, 0.3771]}, {"w": "at", "b": [0.6342, 0.3557, 0.6493, 0.3771]}, {"w": "an", "b": [0.6547, 0.3557, 0.6753, 0.3771]}, {"w": "image", "b": [0.6807, 0.3557, 0.7311, 0.3771]}, {"w": "representation", "b": [0.7365, 0.3557, 0.8572, 0.3771]}, {"w": "of", "b": [0.1429, 0.3756, 0.1596, 0.3971]}, {"w": "the", "b": [0.1644, 0.3756, 0.1907, 0.3971]}, {"w": "confusion", "b": [0.1954, 0.3756, 0.2788, 0.3971]}, {"w": "matrix,", "b": [0.2835, 0.3756, 0.3435, 0.3971]}, {"w": "using", "b": [0.3483, 0.3756, 0.3937, 0.3971]}, {"w": "Matplotlib’s", "b": [0.3984, 0.3756, 0.4951, 0.3971]}, {"w": "matshow()", "b": [0.4999, 0.3788, 0.5889, 0.3939]}, {"w": "function:", "b": [0.5937, 0.3756, 0.6698, 0.3971]}]}, {"id": "b_3", "type": "equation", "text": "plt.matshow(conf_mx, cmap=plt.cm.gray) plt.show()", "words": [{"w": "plt.matshow(conf_mx,", "b": [0.1766, 0.4076, 0.3452, 0.4205]}, {"w": "cmap=plt.cm.gray)", "b": [0.3537, 0.4076, 0.497, 0.4205]}, {"w": "plt.show()", "b": [0.1766, 0.423, 0.2609, 0.4359]}]}, {"id": "b_4", "type": "paragraph", "text": "This confusion matrix looks fairly good, since most images are on the main diagonal, which means that they were classified correctly. The 5s look slightly darker than the other digits, which could mean that there are fewer images of 5s in the dataset or that the classifier does not perform as well on 5s as on other digits. In fact, you can verify that both are the case.", "words": [{"w": "This", "b": [0.1429, 0.7308, 0.1801, 0.7522]}, {"w": "confusion", "b": [0.1853, 0.7308, 0.2686, 0.7522]}, {"w": "matrix", "b": [0.2738, 0.7308, 0.3291, 0.7522]}, {"w": "looks", "b": [0.3343, 0.7308, 0.3788, 0.7522]}, {"w": "fairly", "b": [0.3841, 0.7308, 0.4275, 0.7522]}, {"w": "good,", "b": [0.4327, 0.7308, 0.4795, 0.7522]}, {"w": "since", "b": [0.4847, 0.7308, 0.527, 0.7522]}, {"w": "most", "b": [0.5322, 0.7308, 0.5739, 0.7522]}, {"w": "images", "b": [0.5791, 0.7308, 0.6371, 0.7522]}, {"w": "are", "b": [0.6424, 0.7308, 0.6681, 0.7522]}, {"w": "on", "b": [0.6733, 0.7308, 0.6953, 0.7522]}, {"w": "the", "b": [0.7005, 0.7308, 0.7269, 0.7522]}, {"w": "main", "b": [0.7321, 0.7308, 0.7753, 0.7522]}, {"w": "diagonal,", "b": [0.7805, 0.7308, 0.8572, 0.7522]}, {"w": "which", "b": [0.1429, 0.7499, 0.1938, 0.7713]}, {"w": "means", "b": [0.2001, 0.7499, 0.2542, 0.7713]}, {"w": "that", "b": [0.2605, 0.7499, 0.293, 0.7713]}, {"w": "they", "b": [0.2993, 0.7499, 0.3352, 0.7713]}, {"w": "were", "b": [0.3415, 0.7499, 0.3812, 0.7713]}, {"w": "classified", "b": [0.3875, 0.7499, 0.4632, 0.7713]}, {"w": "correctly.", "b": [0.4695, 0.7499, 0.5465, 0.7713]}, {"w": "The", "b": [0.5528, 0.7499, 0.5856, 0.7713]}, {"w": "5s", "b": [0.5919, 0.7499, 0.6095, 0.7713]}, {"w": "look", "b": [0.6158, 0.7499, 0.6527, 0.7713]}, {"w": "slightly", "b": [0.659, 0.7499, 0.7191, 0.7713]}, {"w": "darker", "b": [0.7254, 0.7499, 0.7802, 0.7713]}, {"w": "than", "b": [0.7865, 0.7499, 0.8245, 0.7713]}, {"w": "the", "b": [0.8308, 0.7499, 0.8571, 0.7713]}, {"w": "other", "b": [0.1429, 0.7689, 0.1875, 0.7903]}, {"w": "digits,", "b": [0.1927, 0.7689, 0.2434, 0.7903]}, {"w": "which", "b": [0.2486, 0.7689, 0.2995, 0.7903]}, {"w": "could", "b": [0.3047, 0.7689, 0.3514, 0.7903]}, {"w": "mean", "b": [0.3566, 0.7689, 0.4031, 0.7903]}, {"w": "that", "b": [0.4082, 0.7689, 0.4408, 0.7903]}, {"w": "there", "b": [0.446, 0.7689, 0.4889, 0.7903]}, {"w": "are", "b": [0.4941, 0.7689, 0.5198, 0.7903]}, {"w": "fewer", "b": [0.525, 0.7689, 0.5709, 0.7903]}, {"w": "images", "b": [0.5761, 0.7689, 0.6341, 0.7903]}, {"w": "of", "b": [0.6393, 0.7689, 0.6561, 0.7903]}, {"w": "5s", "b": [0.6612, 0.7689, 0.6789, 0.7903]}, {"w": "in", "b": [0.6841, 0.7689, 0.7011, 0.7903]}, {"w": "the", "b": [0.7062, 0.7689, 0.7326, 0.7903]}, {"w": "dataset", "b": [0.7377, 0.7689, 0.7958, 0.7903]}, {"w": "or", "b": [0.801, 0.7689, 0.8194, 0.7903]}, {"w": "that", "b": [0.8246, 0.7689, 0.8571, 0.7903]}, {"w": "the", "b": [0.1429, 0.788, 0.1692, 0.8094]}, {"w": "classifier", "b": [0.1747, 0.788, 0.2471, 0.8094]}, {"w": "does", "b": [0.2526, 0.788, 0.2908, 0.8094]}, {"w": "not", "b": [0.2962, 0.788, 0.3246, 0.8094]}, {"w": "perform", "b": [0.3301, 0.788, 0.3992, 0.8094]}, {"w": "as", "b": [0.4047, 0.788, 0.4215, 0.8094]}, {"w": "well", "b": [0.427, 0.788, 0.4606, 0.8094]}, {"w": "on", "b": [0.4661, 0.788, 0.4882, 0.8094]}, {"w": "5s", "b": [0.4937, 0.788, 0.5113, 0.8094]}, {"w": "as", "b": [0.5168, 0.788, 0.5336, 0.8094]}, {"w": "on", "b": [0.5391, 0.788, 0.5611, 0.8094]}, {"w": "other", "b": [0.5666, 0.788, 0.6113, 0.8094]}, {"w": "digits.", "b": [0.6168, 0.788, 0.6674, 0.8094]}, {"w": "In", "b": [0.6729, 0.788, 0.6914, 0.8094]}, {"w": "fact,", "b": [0.6969, 0.788, 0.7322, 0.8094]}, {"w": "you", "b": [0.7377, 0.788, 0.7689, 0.8094]}, {"w": "can", "b": [0.7744, 0.788, 0.8038, 0.8094]}, {"w": "verify", "b": [0.8093, 0.788, 0.8572, 0.8094]}, {"w": "that", "b": [0.1429, 0.807, 0.1754, 0.8284]}, {"w": "both", "b": [0.1802, 0.807, 0.2189, 0.8284]}, {"w": "are", "b": [0.2236, 0.807, 0.2493, 0.8284]}, {"w": "the", "b": [0.254, 0.807, 0.2804, 0.8284]}, {"w": "case.", "b": [0.2851, 0.807, 0.3243, 0.8284]}]}, {"id": "b_5", "type": "paragraph", "text": "Let’s focus the plot on the errors. First, you need to divide each value in the confusion matrix by the number of images in the corresponding class, so you can compare error", "words": [{"w": "Let’s", "b": [0.1429, 0.8351, 0.179, 0.8566]}, {"w": "focus", "b": [0.184, 0.8351, 0.2283, 0.8566]}, {"w": "the", "b": [0.2332, 0.8351, 0.2596, 0.8566]}, {"w": "plot", "b": [0.2645, 0.8351, 0.2977, 0.8566]}, {"w": "on", "b": [0.3027, 0.8351, 0.3247, 0.8566]}, {"w": "the", "b": [0.3296, 0.8351, 0.356, 0.8566]}, {"w": "errors.", "b": [0.3609, 0.8351, 0.416, 0.8566]}, {"w": "First,", "b": [0.4209, 0.8351, 0.464, 0.8566]}, {"w": "you", "b": [0.469, 0.8351, 0.5002, 0.8566]}, {"w": "need", "b": [0.5052, 0.8351, 0.5453, 0.8566]}, {"w": "to", "b": [0.5502, 0.8351, 0.5672, 0.8566]}, {"w": "divide", "b": [0.5722, 0.8351, 0.6238, 0.8566]}, {"w": "each", "b": [0.6288, 0.8351, 0.6667, 0.8566]}, {"w": "value", "b": [0.6717, 0.8351, 0.7157, 0.8566]}, {"w": "in", "b": [0.7206, 0.8351, 0.7376, 0.8566]}, {"w": "the", "b": [0.7425, 0.8351, 0.7689, 0.8566]}, {"w": "confusion", "b": [0.7738, 0.8351, 0.8571, 0.8566]}, {"w": "matrix", "b": [0.1429, 0.8542, 0.1982, 0.8756]}, {"w": "by", "b": [0.2031, 0.8542, 0.2232, 0.8756]}, {"w": "the", "b": [0.2281, 0.8542, 0.2544, 0.8756]}, {"w": "number", "b": [0.2593, 0.8542, 0.3256, 0.8756]}, {"w": "of", "b": [0.3305, 0.8542, 0.3473, 0.8756]}, {"w": "images", "b": [0.3522, 0.8542, 0.4102, 0.8756]}, {"w": "in", "b": [0.4151, 0.8542, 0.4321, 0.8756]}, {"w": "the", "b": [0.437, 0.8542, 0.4633, 0.8756]}, {"w": "corresponding", "b": [0.4682, 0.8542, 0.5903, 0.8756]}, {"w": "class,", "b": [0.5951, 0.8542, 0.6384, 0.8756]}, {"w": "so", "b": [0.6433, 0.8542, 0.6616, 0.8756]}, {"w": "you", "b": [0.6665, 0.8542, 0.6977, 0.8756]}, {"w": "can", "b": [0.7026, 0.8542, 0.7319, 0.8756]}, {"w": "compare", "b": [0.7368, 0.8542, 0.8096, 0.8756]}, {"w": "error", "b": [0.8145, 0.8542, 0.8571, 0.8756]}]}, {"id": "b_6", "type": "paragraph", "text": "Error Analysis | 105", "words": [{"w": "Error", "b": [0.7165, 0.9225, 0.7452, 0.9388]}, {"w": "Analysis", "b": [0.748, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "105", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 132, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "rates instead of absolute number of errors (which would make abundant classes look unfairly bad):", "words": [{"w": "rates", "b": [0.1429, 0.0791, 0.1822, 0.1005]}, {"w": "instead", "b": [0.1879, 0.0791, 0.2478, 0.1005]}, {"w": "of", "b": [0.2535, 0.0791, 0.2703, 0.1005]}, {"w": "absolute", "b": [0.2759, 0.0791, 0.3455, 0.1005]}, {"w": "number", "b": [0.3511, 0.0791, 0.4174, 0.1005]}, {"w": "of", "b": [0.4231, 0.0791, 0.4399, 0.1005]}, {"w": "errors", "b": [0.4456, 0.0791, 0.4959, 0.1005]}, {"w": "(which", "b": [0.5015, 0.0791, 0.5597, 0.1005]}, {"w": "would", "b": [0.5653, 0.0791, 0.6175, 0.1005]}, {"w": "make", "b": [0.6232, 0.0791, 0.6686, 0.1005]}, {"w": "abundant", "b": [0.6743, 0.0791, 0.7539, 0.1005]}, {"w": "classes", "b": [0.7596, 0.0791, 0.8146, 0.1005]}, {"w": "look", "b": [0.8203, 0.0791, 0.8571, 0.1005]}, {"w": "unfairly", "b": [0.1429, 0.0981, 0.2088, 0.1195]}, {"w": "bad):", "b": [0.2135, 0.0981, 0.2562, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "row_sums = conf_mx.sum(axis=1, keepdims=True) norm_conf_mx = conf_mx / row_sums", "words": [{"w": "row_sums", "b": [0.1766, 0.1301, 0.244, 0.1429]}, {"w": "=", "b": [0.2525, 0.1301, 0.2609, 0.1429]}, {"w": "conf_mx.sum(axis=1,", "b": [0.2693, 0.1301, 0.4296, 0.1429]}, {"w": "keepdims=True)", "b": [0.438, 0.1301, 0.556, 0.1429]}, {"w": "norm_conf_mx", "b": [0.1766, 0.1455, 0.2778, 0.1584]}, {"w": "=", "b": [0.2862, 0.1455, 0.2946, 0.1584]}, {"w": "conf_mx", "b": [0.3031, 0.1455, 0.3621, 0.1584]}, {"w": "/", "b": [0.3705, 0.1455, 0.379, 0.1584]}, {"w": "row_sums", "b": [0.3874, 0.1455, 0.4549, 0.1584]}]}, {"id": "b_2", "type": "paragraph", "text": "Now let’s fill the diagonal with zeros to keep only the errors, and let’s plot the result:", "words": [{"w": "Now", "b": [0.1429, 0.1661, 0.1827, 0.1875]}, {"w": "let’s", "b": [0.1874, 0.1661, 0.2177, 0.1875]}, {"w": "fill", "b": [0.2224, 0.1661, 0.2447, 0.1875]}, {"w": "the", "b": [0.2494, 0.1661, 0.2758, 0.1875]}, {"w": "diagonal", "b": [0.2805, 0.1661, 0.3524, 0.1875]}, {"w": "with", "b": [0.3571, 0.1661, 0.3945, 0.1875]}, {"w": "zeros", "b": [0.3992, 0.1661, 0.4428, 0.1875]}, {"w": "to", "b": [0.4475, 0.1661, 0.4645, 0.1875]}, {"w": "keep", "b": [0.4692, 0.1661, 0.5082, 0.1875]}, {"w": "only", "b": [0.5129, 0.1661, 0.5498, 0.1875]}, {"w": "the", "b": [0.5545, 0.1661, 0.5808, 0.1875]}, {"w": "errors,", "b": [0.5856, 0.1661, 0.6406, 0.1875]}, {"w": "and", "b": [0.6454, 0.1661, 0.6769, 0.1875]}, {"w": "let’s", "b": [0.6816, 0.1661, 0.7119, 0.1875]}, {"w": "plot", "b": [0.7166, 0.1661, 0.7498, 0.1875]}, {"w": "the", "b": [0.7545, 0.1661, 0.7808, 0.1875]}, {"w": "result:", "b": [0.7855, 0.1661, 0.8372, 0.1875]}]}, {"id": "b_3", "type": "paragraph", "text": "np.fill_diagonal(norm_conf_mx, 0) plt.matshow(norm_conf_mx, cmap=plt.cm.gray) plt.show()", "words": [{"w": "np.fill_diagonal(norm_conf_mx,", "b": [0.1766, 0.1981, 0.4296, 0.211]}, {"w": "0)", "b": [0.438, 0.1981, 0.4549, 0.211]}, {"w": "plt.matshow(norm_conf_mx,", "b": [0.1766, 0.2135, 0.3874, 0.2264]}, {"w": "cmap=plt.cm.gray)", "b": [0.3958, 0.2135, 0.5392, 0.2264]}, {"w": "plt.show()", "b": [0.1766, 0.2289, 0.2609, 0.2418]}]}, {"id": "b_4", "type": "paragraph", "text": "Now you can clearly see the kinds of errors the classifier makes. Remember that rows represent actual classes, while columns represent predicted classes. The column for class 8 is quite bright, which tells you that many images get misclassified as 8s. How‐ ever, the row for class 8 is not that bad, telling you that actual 8s in general get prop‐ erly classified as 8s. As you can see, the confusion matrix is not necessarily symmetrical. You can also see that 3s and 5s often get confused (in both directions).", "words": [{"w": "Now", "b": [0.1429, 0.5368, 0.1827, 0.5582]}, {"w": "you", "b": [0.1879, 0.5368, 0.2192, 0.5582]}, {"w": "can", "b": [0.2244, 0.5368, 0.2537, 0.5582]}, {"w": "clearly", "b": [0.259, 0.5368, 0.3136, 0.5582]}, {"w": "see", "b": [0.3188, 0.5368, 0.3442, 0.5582]}, {"w": "the", "b": [0.3494, 0.5368, 0.3757, 0.5582]}, {"w": "kinds", "b": [0.381, 0.5368, 0.4269, 0.5582]}, {"w": "of", "b": [0.4321, 0.5368, 0.4489, 0.5582]}, {"w": "errors", "b": [0.4542, 0.5368, 0.5045, 0.5582]}, {"w": "the", "b": [0.5097, 0.5368, 0.536, 0.5582]}, {"w": "classifier", "b": [0.5412, 0.5368, 0.6137, 0.5582]}, {"w": "makes.", "b": [0.6189, 0.5368, 0.6767, 0.5582]}, {"w": "Remember", "b": [0.6819, 0.5368, 0.7738, 0.5582]}, {"w": "that", "b": [0.7791, 0.5368, 0.8116, 0.5582]}, {"w": "rows", "b": [0.8169, 0.5368, 0.8571, 0.5582]}, {"w": "represent", "b": [0.1429, 0.5558, 0.2208, 0.5772]}, {"w": "actual", "b": [0.2279, 0.5558, 0.2777, 0.5772]}, {"w": "classes,", "b": [0.2849, 0.5558, 0.3446, 0.5772]}, {"w": "while", "b": [0.3518, 0.5558, 0.3969, 0.5772]}, {"w": "columns", "b": [0.404, 0.5558, 0.4759, 0.5772]}, {"w": "represent", "b": [0.483, 0.5558, 0.561, 0.5772]}, {"w": "predicted", "b": [0.5681, 0.5558, 0.6472, 0.5772]}, {"w": "classes.", "b": [0.6544, 0.5558, 0.7141, 0.5772]}, {"w": "The", "b": [0.7213, 0.5558, 0.7541, 0.5772]}, {"w": "column", "b": [0.7613, 0.5558, 0.8255, 0.5772]}, {"w": "for", "b": [0.8326, 0.5558, 0.8572, 0.5772]}, {"w": "class", "b": [0.1429, 0.5748, 0.1814, 0.5963]}, {"w": "8", "b": [0.187, 0.5748, 0.197, 0.5963]}, {"w": "is", "b": [0.2026, 0.5748, 0.2158, 0.5963]}, {"w": "quite", "b": [0.2214, 0.5748, 0.2639, 0.5963]}, {"w": "bright,", "b": [0.2695, 0.5748, 0.3249, 0.5963]}, {"w": "which", "b": [0.3305, 0.5748, 0.3814, 0.5963]}, {"w": "tells", "b": [0.387, 0.5748, 0.4204, 0.5963]}, {"w": "you", "b": [0.426, 0.5748, 0.4573, 0.5963]}, {"w": "that", "b": [0.4628, 0.5748, 0.4954, 0.5963]}, {"w": "many", "b": [0.501, 0.5748, 0.5477, 0.5963]}, {"w": "images", "b": [0.5533, 0.5748, 0.6113, 0.5963]}, {"w": "get", "b": [0.6169, 0.5748, 0.6419, 0.5963]}, {"w": "misclassified", "b": [0.6475, 0.5748, 0.7535, 0.5963]}, {"w": "as", "b": [0.759, 0.5748, 0.7758, 0.5963]}, {"w": "8s.", "b": [0.7814, 0.5748, 0.8038, 0.5963]}, {"w": "How‐", "b": [0.8094, 0.5748, 0.8571, 0.5963]}, {"w": "ever,", "b": [0.1429, 0.5939, 0.1814, 0.6153]}, {"w": "the", "b": [0.1869, 0.5939, 0.2133, 0.6153]}, {"w": "row", "b": [0.2188, 0.5939, 0.2514, 0.6153]}, {"w": "for", "b": [0.257, 0.5939, 0.2815, 0.6153]}, {"w": "class", "b": [0.287, 0.5939, 0.3256, 0.6153]}, {"w": "8", "b": [0.3311, 0.5939, 0.3411, 0.6153]}, {"w": "is", "b": [0.3466, 0.5939, 0.3599, 0.6153]}, {"w": "not", "b": [0.3654, 0.5939, 0.3938, 0.6153]}, {"w": "that", "b": [0.3993, 0.5939, 0.4319, 0.6153]}, {"w": "bad,", "b": [0.4375, 0.5939, 0.4729, 0.6153]}, {"w": "telling", "b": [0.4785, 0.5939, 0.531, 0.6153]}, {"w": "you", "b": [0.5365, 0.5939, 0.5678, 0.6153]}, {"w": "that", "b": [0.5733, 0.5939, 0.6059, 0.6153]}, {"w": "actual", "b": [0.6114, 0.5939, 0.6612, 0.6153]}, {"w": "8s", "b": [0.6668, 0.5939, 0.6844, 0.6153]}, {"w": "in", "b": [0.69, 0.5939, 0.7069, 0.6153]}, {"w": "general", "b": [0.7125, 0.5939, 0.7735, 0.6153]}, {"w": "get", "b": [0.779, 0.5939, 0.804, 0.6153]}, {"w": "prop‐", "b": [0.8095, 0.5939, 0.8571, 0.6153]}, {"w": "erly", "b": [0.1428, 0.6129, 0.1743, 0.6344]}, {"w": "classified", "b": [0.1864, 0.6129, 0.2621, 0.6344]}, {"w": "as", "b": [0.2743, 0.6129, 0.2911, 0.6344]}, {"w": "8s.", "b": [0.3033, 0.6129, 0.3257, 0.6344]}, {"w": "As", "b": [0.3378, 0.6129, 0.3599, 0.6344]}, {"w": "you", "b": [0.372, 0.6129, 0.4033, 0.6344]}, {"w": "can", "b": [0.4154, 0.6129, 0.4448, 0.6344]}, {"w": "see,", "b": [0.457, 0.6129, 0.4871, 0.6344]}, {"w": "the", "b": [0.4992, 0.6129, 0.5256, 0.6344]}, {"w": "confusion", "b": [0.5377, 0.6129, 0.6211, 0.6344]}, {"w": "matrix", "b": [0.6332, 0.6129, 0.6885, 0.6344]}, {"w": "is", "b": [0.7007, 0.6129, 0.7139, 0.6344]}, {"w": "not", "b": [0.7261, 0.6129, 0.7545, 0.6344]}, {"w": "necessarily", "b": [0.7666, 0.6129, 0.8571, 0.6344]}, {"w": "symmetrical.", "b": [0.1429, 0.632, 0.2507, 0.6534]}, {"w": "You", "b": [0.2554, 0.632, 0.2878, 0.6534]}, {"w": "can", "b": [0.2925, 0.632, 0.3219, 0.6534]}, {"w": "also", "b": [0.3266, 0.632, 0.3593, 0.6534]}, {"w": "see", "b": [0.364, 0.632, 0.3894, 0.6534]}, {"w": "that", "b": [0.3941, 0.632, 0.4267, 0.6534]}, {"w": "3s", "b": [0.4314, 0.632, 0.449, 0.6534]}, {"w": "and", "b": [0.4538, 0.632, 0.4853, 0.6534]}, {"w": "5s", "b": [0.49, 0.632, 0.5077, 0.6534]}, {"w": "often", "b": [0.5124, 0.632, 0.5558, 0.6534]}, {"w": "get", "b": [0.5605, 0.632, 0.5855, 0.6534]}, {"w": "confused", "b": [0.5902, 0.632, 0.6658, 0.6534]}, {"w": "(in", "b": [0.6705, 0.632, 0.6947, 0.6534]}, {"w": "both", "b": [0.6994, 0.632, 0.7381, 0.6534]}, {"w": "directions).", "b": [0.7429, 0.632, 0.8384, 0.6534]}]}, {"id": "b_5", "type": "paragraph", "text": "Analyzing the confusion matrix can often give you insights on ways to improve your classifier. Looking at this plot, it seems that your efforts should be spent on reducing the false 8s. For example, you could try to gather more training data for digits that look like 8s (but are not) so the classifier can learn to distinguish them from real 8s. Or you could engineer new features that would help the classifier—for example, writ‐ ing an algorithm to count the number of closed loops (e.g., 8 has two, 6 has one, 5 has none). Or you could preprocess the images (e.g., using Scikit-Image, Pillow, or OpenCV) to make some patterns stand out more, such as closed loops.", "words": [{"w": "Analyzing", "b": [0.1429, 0.6601, 0.2281, 0.6815]}, {"w": "the", "b": [0.2338, 0.6601, 0.2601, 0.6815]}, {"w": "confusion", "b": [0.2657, 0.6601, 0.349, 0.6815]}, {"w": "matrix", "b": [0.3547, 0.6601, 0.41, 0.6815]}, {"w": "can", "b": [0.4156, 0.6601, 0.445, 0.6815]}, {"w": "often", "b": [0.4506, 0.6601, 0.494, 0.6815]}, {"w": "give", "b": [0.4997, 0.6601, 0.5335, 0.6815]}, {"w": "you", "b": [0.5391, 0.6601, 0.5704, 0.6815]}, {"w": "insights", "b": [0.576, 0.6601, 0.6407, 0.6815]}, {"w": "on", "b": [0.6463, 0.6601, 0.6684, 0.6815]}, {"w": "ways", "b": [0.674, 0.6601, 0.7143, 0.6815]}, {"w": "to", "b": [0.7199, 0.6601, 0.7369, 0.6815]}, {"w": "improve", "b": [0.7425, 0.6601, 0.8125, 0.6815]}, {"w": "your", "b": [0.8182, 0.6601, 0.8571, 0.6815]}, {"w": "classifier.", "b": [0.1429, 0.6792, 0.2187, 0.7006]}, {"w": "Looking", "b": [0.2245, 0.6792, 0.294, 0.7006]}, {"w": "at", "b": [0.2998, 0.6792, 0.3149, 0.7006]}, {"w": "this", "b": [0.3207, 0.6792, 0.3514, 0.7006]}, {"w": "plot,", "b": [0.3572, 0.6792, 0.3951, 0.7006]}, {"w": "it", "b": [0.4009, 0.6792, 0.4128, 0.7006]}, {"w": "seems", "b": [0.4186, 0.6792, 0.4687, 0.7006]}, {"w": "that", "b": [0.4744, 0.6792, 0.507, 0.7006]}, {"w": "your", "b": [0.5128, 0.6792, 0.5518, 0.7006]}, {"w": "efforts", "b": [0.5576, 0.6792, 0.6111, 0.7006]}, {"w": "should", "b": [0.6169, 0.6792, 0.6736, 0.7006]}, {"w": "be", "b": [0.6794, 0.6792, 0.6988, 0.7006]}, {"w": "spent", "b": [0.7046, 0.6792, 0.7494, 0.7006]}, {"w": "on", "b": [0.7552, 0.6792, 0.7772, 0.7006]}, {"w": "reducing", "b": [0.783, 0.6792, 0.8571, 0.7006]}, {"w": "the", "b": [0.1429, 0.6982, 0.1692, 0.7196]}, {"w": "false", "b": [0.1761, 0.6982, 0.2132, 0.7196]}, {"w": "8s.", "b": [0.2201, 0.6982, 0.2425, 0.7196]}, {"w": "For", "b": [0.2494, 0.6982, 0.2784, 0.7196]}, {"w": "example,", "b": [0.2854, 0.6982, 0.3596, 0.7196]}, {"w": "you", "b": [0.3666, 0.6982, 0.3978, 0.7196]}, {"w": "could", "b": [0.4047, 0.6982, 0.4515, 0.7196]}, {"w": "try", "b": [0.4584, 0.6982, 0.4827, 0.7196]}, {"w": "to", "b": [0.4896, 0.6982, 0.5066, 0.7196]}, {"w": "gather", "b": [0.5135, 0.6982, 0.5661, 0.7196]}, {"w": "more", "b": [0.573, 0.6982, 0.6173, 0.7196]}, {"w": "training", "b": [0.6242, 0.6982, 0.6912, 0.7196]}, {"w": "data", "b": [0.6981, 0.6982, 0.7333, 0.7196]}, {"w": "for", "b": [0.7403, 0.6982, 0.7648, 0.7196]}, {"w": "digits", "b": [0.7717, 0.6982, 0.8176, 0.7196]}, {"w": "that", "b": [0.8246, 0.6982, 0.8571, 0.7196]}, {"w": "look", "b": [0.1429, 0.7172, 0.1797, 0.7387]}, {"w": "like", "b": [0.1857, 0.7172, 0.2158, 0.7387]}, {"w": "8s", "b": [0.2218, 0.7172, 0.2395, 0.7387]}, {"w": "(but", "b": [0.2455, 0.7172, 0.2807, 0.7387]}, {"w": "are", "b": [0.2867, 0.7172, 0.3124, 0.7387]}, {"w": "not)", "b": [0.3185, 0.7172, 0.354, 0.7387]}, {"w": "so", "b": [0.3601, 0.7172, 0.3783, 0.7387]}, {"w": "the", "b": [0.3844, 0.7172, 0.4107, 0.7387]}, {"w": "classifier", "b": [0.4167, 0.7172, 0.4891, 0.7387]}, {"w": "can", "b": [0.4952, 0.7172, 0.5245, 0.7387]}, {"w": "learn", "b": [0.5305, 0.7172, 0.5729, 0.7387]}, {"w": "to", "b": [0.579, 0.7172, 0.5959, 0.7387]}, {"w": "distinguish", "b": [0.602, 0.7172, 0.6947, 0.7387]}, {"w": "them", "b": [0.7007, 0.7172, 0.7441, 0.7387]}, {"w": "from", "b": [0.7501, 0.7172, 0.7917, 0.7387]}, {"w": "real", "b": [0.7977, 0.7172, 0.8287, 0.7387]}, {"w": "8s.", "b": [0.8348, 0.7172, 0.8572, 0.7387]}, {"w": "Or", "b": [0.1429, 0.7363, 0.1662, 0.7577]}, {"w": "you", "b": [0.1713, 0.7363, 0.2026, 0.7577]}, {"w": "could", "b": [0.2077, 0.7363, 0.2545, 0.7577]}, {"w": "engineer", "b": [0.2597, 0.7363, 0.3321, 0.7577]}, {"w": "new", "b": [0.3373, 0.7363, 0.3718, 0.7577]}, {"w": "features", "b": [0.3769, 0.7363, 0.4424, 0.7577]}, {"w": "that", "b": [0.4475, 0.7363, 0.4801, 0.7577]}, {"w": "would", "b": [0.4853, 0.7363, 0.5375, 0.7577]}, {"w": "help", "b": [0.5427, 0.7363, 0.5788, 0.7577]}, {"w": "the", "b": [0.584, 0.7363, 0.6103, 0.7577]}, {"w": "classifier—for", "b": [0.6155, 0.7363, 0.7312, 0.7577]}, {"w": "example,", "b": [0.7363, 0.7363, 0.8106, 0.7577]}, {"w": "writ‐", "b": [0.8158, 0.7363, 0.8571, 0.7577]}, {"w": "ing", "b": [0.1429, 0.7553, 0.1696, 0.7768]}, {"w": "an", "b": [0.1745, 0.7553, 0.195, 0.7768]}, {"w": "algorithm", "b": [0.1999, 0.7553, 0.2825, 0.7768]}, {"w": "to", "b": [0.2874, 0.7553, 0.3044, 0.7768]}, {"w": "count", "b": [0.3093, 0.7553, 0.3572, 0.7768]}, {"w": "the", "b": [0.362, 0.7553, 0.3884, 0.7768]}, {"w": "number", "b": [0.3933, 0.7553, 0.4596, 0.7768]}, {"w": "of", "b": [0.4644, 0.7553, 0.4812, 0.7768]}, {"w": "closed", "b": [0.4861, 0.7553, 0.5383, 0.7768]}, {"w": "loops", "b": [0.5432, 0.7553, 0.5883, 0.7768]}, {"w": "(e.g.,", "b": [0.5932, 0.7553, 0.6333, 0.7768]}, {"w": "8", "b": [0.6381, 0.7553, 0.6481, 0.7768]}, {"w": "has", "b": [0.653, 0.7553, 0.681, 0.7768]}, {"w": "two,", "b": [0.6858, 0.7553, 0.7212, 0.7768]}, {"w": "6", "b": [0.7261, 0.7553, 0.7361, 0.7768]}, {"w": "has", "b": [0.741, 0.7553, 0.7689, 0.7768]}, {"w": "one,", "b": [0.7738, 0.7553, 0.8094, 0.7768]}, {"w": "5", "b": [0.8143, 0.7553, 0.8243, 0.7768]}, {"w": "has", "b": [0.8292, 0.7553, 0.8571, 0.7768]}, {"w": "none).", "b": [0.1428, 0.7744, 0.1971, 0.7958]}, {"w": "Or", "b": [0.2075, 0.7744, 0.2307, 0.7958]}, {"w": "you", "b": [0.2411, 0.7744, 0.2724, 0.7958]}, {"w": "could", "b": [0.2828, 0.7744, 0.3295, 0.7958]}, {"w": "preprocess", "b": [0.3399, 0.7744, 0.4296, 0.7958]}, {"w": "the", "b": [0.44, 0.7744, 0.4664, 0.7958]}, {"w": "images", "b": [0.4767, 0.7744, 0.5348, 0.7958]}, {"w": "(e.g.,", "b": [0.5452, 0.7744, 0.5852, 0.7958]}, {"w": "using", "b": [0.5956, 0.7744, 0.641, 0.7958]}, {"w": "Scikit-Image,", "b": [0.6514, 0.7744, 0.762, 0.7958]}, {"w": "Pillow,", "b": [0.7724, 0.7744, 0.8284, 0.7958]}, {"w": "or", "b": [0.8388, 0.7744, 0.8571, 0.7958]}, {"w": "OpenCV)", "b": [0.1429, 0.7934, 0.2253, 0.8149]}, {"w": "to", "b": [0.23, 0.7934, 0.247, 0.8149]}, {"w": "make", "b": [0.2517, 0.7934, 0.2971, 0.8149]}, {"w": "some", "b": [0.3019, 0.7934, 0.3461, 0.8149]}, {"w": "patterns", "b": [0.3508, 0.7934, 0.4188, 0.8149]}, {"w": "stand", "b": [0.4235, 0.7934, 0.4691, 0.8149]}, {"w": "out", "b": [0.4738, 0.7934, 0.5018, 0.8149]}, {"w": "more,", "b": [0.5066, 0.7934, 0.5556, 0.8149]}, {"w": "such", "b": [0.5603, 0.7934, 0.5989, 0.8149]}, {"w": "as", "b": [0.6037, 0.7934, 0.6205, 0.8149]}, {"w": "closed", "b": [0.6252, 0.7934, 0.6774, 0.8149]}, {"w": "loops.", "b": [0.6821, 0.7934, 0.732, 0.8149]}]}, {"id": "b_6", "type": "paragraph", "text": "Analyzing individual errors can also be a good way to gain insights on what your classifier is doing and why it is failing, but it is more difficult and time-consuming.", "words": [{"w": "Analyzing", "b": [0.1429, 0.8216, 0.2281, 0.843]}, {"w": "individual", "b": [0.2359, 0.8216, 0.3212, 0.843]}, {"w": "errors", "b": [0.329, 0.8216, 0.3793, 0.843]}, {"w": "can", "b": [0.3871, 0.8216, 0.4164, 0.843]}, {"w": "also", "b": [0.4242, 0.8216, 0.4569, 0.843]}, {"w": "be", "b": [0.4647, 0.8216, 0.4842, 0.843]}, {"w": "a", "b": [0.492, 0.8216, 0.5011, 0.843]}, {"w": "good", "b": [0.5089, 0.8216, 0.5509, 0.843]}, {"w": "way", "b": [0.5587, 0.8216, 0.5913, 0.843]}, {"w": "to", "b": [0.5991, 0.8216, 0.6161, 0.843]}, {"w": "gain", "b": [0.6239, 0.8216, 0.6598, 0.843]}, {"w": "insights", "b": [0.6676, 0.8216, 0.7323, 0.843]}, {"w": "on", "b": [0.7401, 0.8216, 0.7621, 0.843]}, {"w": "what", "b": [0.7699, 0.8216, 0.8104, 0.843]}, {"w": "your", "b": [0.8182, 0.8216, 0.8571, 0.843]}, {"w": "classifier", "b": [0.1429, 0.8406, 0.2153, 0.862]}, {"w": "is", "b": [0.2219, 0.8406, 0.2352, 0.862]}, {"w": "doing", "b": [0.2418, 0.8406, 0.2902, 0.862]}, {"w": "and", "b": [0.2968, 0.8406, 0.3284, 0.862]}, {"w": "why", "b": [0.335, 0.8406, 0.3695, 0.862]}, {"w": "it", "b": [0.3761, 0.8406, 0.3881, 0.862]}, {"w": "is", "b": [0.3947, 0.8406, 0.408, 0.862]}, {"w": "failing,", "b": [0.4146, 0.8406, 0.4723, 0.862]}, {"w": "but", "b": [0.4789, 0.8406, 0.5069, 0.862]}, {"w": "it", "b": [0.5136, 0.8406, 0.5255, 0.862]}, {"w": "is", "b": [0.5321, 0.8406, 0.5454, 0.862]}, {"w": "more", "b": [0.552, 0.8406, 0.5963, 0.862]}, {"w": "difficult", "b": [0.6029, 0.8406, 0.6689, 0.862]}, {"w": "and", "b": [0.6756, 0.8406, 0.7071, 0.862]}, {"w": "time-consuming.", "b": [0.7138, 0.8406, 0.8571, 0.862]}]}, {"id": "b_7", "type": "paragraph", "text": "106 | Chapter 3: Classification", "words": [{"w": "106", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "3:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Classification", "b": [0.2673, 0.9225, 0.3443, 0.9388]}]}]}, {"page": 133, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "3 But remember that our brain is a fantastic pattern recognition system, and our visual system does a lot of complex preprocessing before any information reaches our consciousness, so the fact that it feels simple does not mean that it is.", "words": [{"w": "3", "b": [0.1451, 0.8462, 0.1518, 0.8604]}, {"w": "But", "b": [0.1587, 0.8447, 0.1813, 0.861]}, {"w": "remember", "b": [0.1849, 0.8447, 0.251, 0.861]}, {"w": "that", "b": [0.2546, 0.8447, 0.2794, 0.861]}, {"w": "our", "b": [0.283, 0.8447, 0.3055, 0.861]}, {"w": "brain", "b": [0.3091, 0.8447, 0.3429, 0.861]}, {"w": "is", "b": [0.3465, 0.8447, 0.3566, 0.861]}, {"w": "a", "b": [0.3602, 0.8447, 0.3672, 0.861]}, {"w": "fantastic", "b": [0.3708, 0.8447, 0.4243, 0.861]}, {"w": "pattern", "b": [0.4279, 0.8447, 0.4739, 0.861]}, {"w": "recognition", "b": [0.4775, 0.8447, 0.5511, 0.861]}, {"w": "system,", "b": [0.5547, 0.8447, 0.6019, 0.861]}, {"w": "and", "b": [0.6055, 0.8447, 0.6295, 0.861]}, {"w": "our", "b": [0.6331, 0.8447, 0.6555, 0.861]}, {"w": "visual", "b": [0.6591, 0.8447, 0.696, 0.861]}, {"w": "system", "b": [0.6996, 0.8447, 0.7431, 0.861]}, {"w": "does", "b": [0.7467, 0.8447, 0.7758, 0.861]}, {"w": "a", "b": [0.7794, 0.8447, 0.7863, 0.861]}, {"w": "lot", "b": [0.7899, 0.8447, 0.8069, 0.861]}, {"w": "of", "b": [0.8105, 0.8447, 0.8233, 0.861]}, {"w": "complex", "b": [0.1587, 0.8598, 0.2128, 0.8761]}, {"w": "preprocessing", "b": [0.2164, 0.8598, 0.3051, 0.8761]}, {"w": "before", "b": [0.3087, 0.8598, 0.349, 0.8761]}, {"w": "any", "b": [0.3526, 0.8598, 0.3752, 0.8761]}, {"w": "information", "b": [0.3788, 0.8598, 0.4559, 0.8761]}, {"w": "reaches", "b": [0.4595, 0.8598, 0.5069, 0.8761]}, {"w": "our", "b": [0.5105, 0.8598, 0.5329, 0.8761]}, {"w": "consciousness,", "b": [0.5365, 0.8598, 0.6298, 0.8761]}, {"w": "so", "b": [0.6334, 0.8598, 0.6474, 0.8761]}, {"w": "the", "b": [0.651, 0.8598, 0.671, 0.8761]}, {"w": "fact", "b": [0.6746, 0.8598, 0.6979, 0.8761]}, {"w": "that", "b": [0.7015, 0.8598, 0.7263, 0.8761]}, {"w": "it", "b": [0.7299, 0.8598, 0.739, 0.8761]}, {"w": "feels", "b": [0.7426, 0.8598, 0.7706, 0.8761]}, {"w": "simple", "b": [0.7742, 0.8598, 0.8161, 0.8761]}, {"w": "does", "b": [0.8197, 0.8598, 0.8487, 0.8761]}, {"w": "not", "b": [0.1587, 0.8749, 0.1803, 0.8912]}, {"w": "mean", "b": [0.184, 0.8749, 0.2193, 0.8912]}, {"w": "that", "b": [0.223, 0.8749, 0.2478, 0.8912]}, {"w": "it", "b": [0.2514, 0.8749, 0.2605, 0.8912]}, {"w": "is.", "b": [0.2641, 0.8749, 0.2778, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "For example, let’s plot examples of 3s and 5s (the plot_digits() function just uses Matplotlib’s imshow() function; see this chapter’s Jupyter notebook for details):", "words": [{"w": "For", "b": [0.1429, 0.08, 0.1718, 0.1014]}, {"w": "example,", "b": [0.1786, 0.08, 0.2529, 0.1014]}, {"w": "let’s", "b": [0.2596, 0.08, 0.2898, 0.1014]}, {"w": "plot", "b": [0.2966, 0.08, 0.3297, 0.1014]}, {"w": "examples", "b": [0.3365, 0.08, 0.4137, 0.1014]}, {"w": "of", "b": [0.4204, 0.08, 0.4372, 0.1014]}, {"w": "3s", "b": [0.4439, 0.08, 0.4616, 0.1014]}, {"w": "and", "b": [0.4683, 0.08, 0.4999, 0.1014]}, {"w": "5s", "b": [0.5066, 0.08, 0.5243, 0.1014]}, {"w": "(the", "b": [0.531, 0.08, 0.5645, 0.1014]}, {"w": "plot_digits()", "b": [0.5713, 0.0831, 0.6999, 0.0982]}, {"w": "function", "b": [0.7067, 0.08, 0.7781, 0.1014]}, {"w": "just", "b": [0.7848, 0.08, 0.8152, 0.1014]}, {"w": "uses", "b": [0.8219, 0.08, 0.8571, 0.1014]}, {"w": "Matplotlib’s", "b": [0.1429, 0.0999, 0.2396, 0.1213]}, {"w": "imshow()", "b": [0.2443, 0.1031, 0.3235, 0.1182]}, {"w": "function;", "b": [0.3282, 0.0999, 0.4043, 0.1213]}, {"w": "see", "b": [0.4091, 0.0999, 0.4344, 0.1213]}, {"w": "this", "b": [0.4391, 0.0999, 0.4699, 0.1213]}, {"w": "chapter’s", "b": [0.4746, 0.0999, 0.5474, 0.1213]}, {"w": "Jupyter", "b": [0.5522, 0.0999, 0.6128, 0.1213]}, {"w": "notebook", "b": [0.6176, 0.0999, 0.697, 0.1213]}, {"w": "for", "b": [0.7017, 0.0999, 0.7262, 0.1213]}, {"w": "details):", "b": [0.7309, 0.0999, 0.7968, 0.1213]}]}, {"id": "b_2", "type": "paragraph", "text": "cl_a, cl_b = 3, 5 X_aa = X_train[(y_train == cl_a) & (y_train_pred == cl_a)] X_ab = X_train[(y_train == cl_a) & (y_train_pred == cl_b)] X_ba = X_train[(y_train == cl_b) & (y_train_pred == cl_a)] X_bb = X_train[(y_train == cl_b) & (y_train_pred == cl_b)]", "words": [{"w": "cl_a,", "b": [0.1766, 0.1319, 0.2188, 0.1447]}, {"w": "cl_b", "b": [0.2272, 0.1319, 0.2609, 0.1447]}, {"w": "=", "b": [0.2693, 0.1319, 0.2778, 0.1447]}, {"w": "3,", "b": [0.2862, 0.1319, 0.3031, 0.1447]}, {"w": "5", "b": [0.3115, 0.1319, 0.3199, 0.1447]}, {"w": "X_aa", "b": [0.1766, 0.1473, 0.2103, 0.1601]}, {"w": "=", "b": [0.2188, 0.1473, 0.2272, 0.1601]}, {"w": "X_train[(y_train", "b": [0.2356, 0.1473, 0.3705, 0.1601]}, {"w": "==", "b": [0.379, 0.1473, 0.3958, 0.1601]}, {"w": "cl_a)", "b": [0.4043, 0.1473, 0.4464, 0.1601]}, {"w": "&", "b": [0.4549, 0.1473, 0.4633, 0.1601]}, {"w": "(y_train_pred", "b": [0.4717, 0.1473, 0.5814, 0.1601]}, {"w": "==", "b": [0.5898, 0.1473, 0.6066, 0.1601]}, {"w": "cl_a)]", "b": [0.6151, 0.1473, 0.6657, 0.1601]}, {"w": "X_ab", "b": [0.1766, 0.1627, 0.2103, 0.1756]}, {"w": "=", "b": [0.2188, 0.1627, 0.2272, 0.1756]}, {"w": "X_train[(y_train", "b": [0.2356, 0.1627, 0.3705, 0.1756]}, {"w": "==", "b": [0.379, 0.1627, 0.3958, 0.1756]}, {"w": "cl_a)", "b": [0.4043, 0.1627, 0.4464, 0.1756]}, {"w": "&", "b": [0.4549, 0.1627, 0.4633, 0.1756]}, {"w": "(y_train_pred", "b": [0.4717, 0.1627, 0.5814, 0.1756]}, {"w": "==", "b": [0.5898, 0.1627, 0.6066, 0.1756]}, {"w": "cl_b)]", "b": [0.6151, 0.1627, 0.6657, 0.1756]}, {"w": "X_ba", "b": [0.1766, 0.1781, 0.2103, 0.191]}, {"w": "=", "b": [0.2188, 0.1781, 0.2272, 0.191]}, {"w": "X_train[(y_train", "b": [0.2356, 0.1781, 0.3705, 0.191]}, {"w": "==", "b": [0.379, 0.1781, 0.3958, 0.191]}, {"w": "cl_b)", "b": [0.4043, 0.1781, 0.4464, 0.191]}, {"w": "&", "b": [0.4549, 0.1781, 0.4633, 0.191]}, {"w": "(y_train_pred", "b": [0.4717, 0.1781, 0.5814, 0.191]}, {"w": "==", "b": [0.5898, 0.1781, 0.6066, 0.191]}, {"w": "cl_a)]", "b": [0.6151, 0.1781, 0.6657, 0.191]}, {"w": "X_bb", "b": [0.1766, 0.1936, 0.2103, 0.2064]}, {"w": "=", "b": [0.2188, 0.1936, 0.2272, 0.2064]}, {"w": "X_train[(y_train", "b": [0.2356, 0.1936, 0.3705, 0.2064]}, {"w": "==", "b": [0.379, 0.1936, 0.3958, 0.2064]}, {"w": "cl_b)", "b": [0.4043, 0.1936, 0.4464, 0.2064]}, {"w": "&", "b": [0.4549, 0.1936, 0.4633, 0.2064]}, {"w": "(y_train_pred", "b": [0.4717, 0.1936, 0.5814, 0.2064]}, {"w": "==", "b": [0.5898, 0.1936, 0.6066, 0.2064]}, {"w": "cl_b)]", "b": [0.6151, 0.1936, 0.6657, 0.2064]}]}, {"id": "b_3", "type": "paragraph", "text": "plt.figure(figsize=(8,8)) plt.subplot(221); plot_digits(X_aa[:25], images_per_row=5) plt.subplot(222); plot_digits(X_ab[:25], images_per_row=5) plt.subplot(223); plot_digits(X_ba[:25], images_per_row=5) plt.subplot(224); plot_digits(X_bb[:25], images_per_row=5) plt.show()", "words": [{"w": "plt.figure(figsize=(8,8))", "b": [0.1766, 0.2244, 0.3874, 0.2372]}, {"w": "plt.subplot(221);", "b": [0.1766, 0.2398, 0.3199, 0.2527]}, {"w": "plot_digits(X_aa[:25],", "b": [0.3284, 0.2398, 0.5139, 0.2527]}, {"w": "images_per_row=5)", "b": [0.5223, 0.2398, 0.6657, 0.2527]}, {"w": "plt.subplot(222);", "b": [0.1766, 0.2552, 0.3199, 0.2681]}, {"w": "plot_digits(X_ab[:25],", "b": [0.3284, 0.2552, 0.5139, 0.2681]}, {"w": "images_per_row=5)", "b": [0.5223, 0.2552, 0.6657, 0.2681]}, {"w": "plt.subplot(223);", "b": [0.1766, 0.2707, 0.3199, 0.2835]}, {"w": "plot_digits(X_ba[:25],", "b": [0.3284, 0.2707, 0.5139, 0.2835]}, {"w": "images_per_row=5)", "b": [0.5223, 0.2707, 0.6657, 0.2835]}, {"w": "plt.subplot(224);", "b": [0.1766, 0.2861, 0.3199, 0.2989]}, {"w": "plot_digits(X_bb[:25],", "b": [0.3284, 0.2861, 0.5139, 0.2989]}, {"w": "images_per_row=5)", "b": [0.5223, 0.2861, 0.6657, 0.2989]}, {"w": "plt.show()", "b": [0.1766, 0.3015, 0.2609, 0.3143]}]}, {"id": "b_4", "type": "paragraph", "text": "The two 5×5 blocks on the left show digits classified as 3s, and the two 5×5 blocks on the right show images classified as 5s. Some of the digits that the classifier gets wrong (i.e., in the bottom-left and top-right blocks) are so badly written that even a human would have trouble classifying them (e.g., the 5 on the 1st row and 2nd column truly looks like a badly written 3). However, most misclassified images seem like obvious errors to us, and it’s hard to understand why the classifier made the mistakes it did.3", "words": [{"w": "The", "b": [0.1429, 0.6004, 0.1757, 0.6218]}, {"w": "two", "b": [0.1809, 0.6004, 0.2122, 0.6218]}, {"w": "5×5", "b": [0.2174, 0.6004, 0.2495, 0.6218]}, {"w": "blocks", "b": [0.2547, 0.6004, 0.308, 0.6218]}, {"w": "on", "b": [0.3132, 0.6004, 0.3352, 0.6218]}, {"w": "the", "b": [0.3404, 0.6004, 0.3668, 0.6218]}, {"w": "left", "b": [0.372, 0.6004, 0.3987, 0.6218]}, {"w": "show", "b": [0.4039, 0.6004, 0.4475, 0.6218]}, {"w": "digits", "b": [0.4528, 0.6004, 0.4987, 0.6218]}, {"w": "classified", "b": [0.5039, 0.6004, 0.5796, 0.6218]}, {"w": "as", "b": [0.5849, 0.6004, 0.6016, 0.6218]}, {"w": "3s,", "b": [0.6069, 0.6004, 0.6293, 0.6218]}, {"w": "and", "b": [0.6345, 0.6004, 0.666, 0.6218]}, {"w": "the", "b": [0.6713, 0.6004, 0.6976, 0.6218]}, {"w": "two", "b": [0.7028, 0.6004, 0.7341, 0.6218]}, {"w": "5×5", "b": [0.7393, 0.6004, 0.7714, 0.6218]}, {"w": "blocks", "b": [0.7766, 0.6004, 0.8299, 0.6218]}, {"w": "on", "b": [0.8351, 0.6004, 0.8571, 0.6218]}, {"w": "the", "b": [0.1429, 0.6194, 0.1692, 0.6408]}, {"w": "right", "b": [0.1744, 0.6194, 0.2145, 0.6408]}, {"w": "show", "b": [0.2197, 0.6194, 0.2634, 0.6408]}, {"w": "images", "b": [0.2686, 0.6194, 0.3267, 0.6408]}, {"w": "classified", "b": [0.3319, 0.6194, 0.4076, 0.6408]}, {"w": "as", "b": [0.4128, 0.6194, 0.4296, 0.6408]}, {"w": "5s.", "b": [0.4348, 0.6194, 0.4572, 0.6408]}, {"w": "Some", "b": [0.4624, 0.6194, 0.5088, 0.6408]}, {"w": "of", "b": [0.514, 0.6194, 0.5308, 0.6408]}, {"w": "the", "b": [0.536, 0.6194, 0.5623, 0.6408]}, {"w": "digits", "b": [0.5675, 0.6194, 0.6134, 0.6408]}, {"w": "that", "b": [0.6186, 0.6194, 0.6512, 0.6408]}, {"w": "the", "b": [0.6564, 0.6194, 0.6827, 0.6408]}, {"w": "classifier", "b": [0.6879, 0.6194, 0.7604, 0.6408]}, {"w": "gets", "b": [0.7656, 0.6194, 0.7982, 0.6408]}, {"w": "wrong", "b": [0.8034, 0.6194, 0.8572, 0.6408]}, {"w": "(i.e.,", "b": [0.1429, 0.6385, 0.1788, 0.6599]}, {"w": "in", "b": [0.1846, 0.6385, 0.2016, 0.6599]}, {"w": "the", "b": [0.2074, 0.6385, 0.2338, 0.6599]}, {"w": "bottom-left", "b": [0.2396, 0.6385, 0.3353, 0.6599]}, {"w": "and", "b": [0.3412, 0.6385, 0.3727, 0.6599]}, {"w": "top-right", "b": [0.3785, 0.6385, 0.454, 0.6599]}, {"w": "blocks)", "b": [0.4599, 0.6385, 0.5203, 0.6599]}, {"w": "are", "b": [0.5262, 0.6385, 0.5519, 0.6599]}, {"w": "so", "b": [0.5578, 0.6385, 0.576, 0.6599]}, {"w": "badly", "b": [0.5819, 0.6385, 0.6275, 0.6599]}, {"w": "written", "b": [0.6333, 0.6385, 0.6939, 0.6599]}, {"w": "that", "b": [0.6997, 0.6385, 0.7323, 0.6599]}, {"w": "even", "b": [0.7381, 0.6385, 0.7769, 0.6599]}, {"w": "a", "b": [0.7828, 0.6385, 0.7919, 0.6599]}, {"w": "human", "b": [0.7978, 0.6385, 0.8571, 0.6599]}, {"w": "would", "b": [0.1429, 0.6575, 0.1951, 0.6789]}, {"w": "have", "b": [0.2016, 0.6575, 0.24, 0.6789]}, {"w": "trouble", "b": [0.2465, 0.6575, 0.307, 0.6789]}, {"w": "classifying", "b": [0.3135, 0.6575, 0.4005, 0.6789]}, {"w": "them", "b": [0.407, 0.6575, 0.4504, 0.6789]}, {"w": "(e.g.,", "b": [0.4569, 0.6575, 0.497, 0.6789]}, {"w": "the", "b": [0.5035, 0.6575, 0.5298, 0.6789]}, {"w": "5", "b": [0.5364, 0.6575, 0.5464, 0.6789]}, {"w": "on", "b": [0.5529, 0.6575, 0.5749, 0.6789]}, {"w": "the", "b": [0.5814, 0.6575, 0.6078, 0.6789]}, {"w": "1st", "b": [0.6143, 0.6575, 0.6327, 0.6789]}, {"w": "row", "b": [0.6392, 0.6575, 0.6718, 0.6789]}, {"w": "and", "b": [0.6784, 0.6575, 0.7099, 0.6789]}, {"w": "2nd", "b": [0.7164, 0.6575, 0.7399, 0.6789]}, {"w": "column", "b": [0.7464, 0.6575, 0.8106, 0.6789]}, {"w": "truly", "b": [0.8172, 0.6575, 0.8571, 0.6789]}, {"w": "looks", "b": [0.1428, 0.6766, 0.1873, 0.698]}, {"w": "like", "b": [0.194, 0.6766, 0.224, 0.698]}, {"w": "a", "b": [0.2307, 0.6766, 0.2398, 0.698]}, {"w": "badly", "b": [0.2465, 0.6766, 0.292, 0.698]}, {"w": "written", "b": [0.2987, 0.6766, 0.3592, 0.698]}, {"w": "3).", "b": [0.3659, 0.6766, 0.3878, 0.698]}, {"w": "However,", "b": [0.3945, 0.6766, 0.4733, 0.698]}, {"w": "most", "b": [0.48, 0.6766, 0.5216, 0.698]}, {"w": "misclassified", "b": [0.5283, 0.6766, 0.6343, 0.698]}, {"w": "images", "b": [0.6409, 0.6766, 0.699, 0.698]}, {"w": "seem", "b": [0.7056, 0.6766, 0.748, 0.698]}, {"w": "like", "b": [0.7547, 0.6766, 0.7847, 0.698]}, {"w": "obvious", "b": [0.7914, 0.6766, 0.8571, 0.698]}, {"w": "errors", "b": [0.1429, 0.6956, 0.1932, 0.717]}, {"w": "to", "b": [0.1992, 0.6956, 0.2162, 0.717]}, {"w": "us,", "b": [0.2222, 0.6956, 0.2457, 0.717]}, {"w": "and", "b": [0.2517, 0.6956, 0.2833, 0.717]}, {"w": "it’s", "b": [0.2893, 0.6956, 0.311, 0.717]}, {"w": "hard", "b": [0.317, 0.6956, 0.356, 0.717]}, {"w": "to", "b": [0.362, 0.6956, 0.379, 0.717]}, {"w": "understand", "b": [0.385, 0.6956, 0.4806, 0.717]}, {"w": "why", "b": [0.4867, 0.6956, 0.5211, 0.717]}, {"w": "the", "b": [0.5272, 0.6956, 0.5535, 0.717]}, {"w": "classifier", "b": [0.5595, 0.6956, 0.632, 0.717]}, {"w": "made", "b": [0.638, 0.6956, 0.6841, 0.717]}, {"w": "the", "b": [0.6901, 0.6956, 0.7164, 0.717]}, {"w": "mistakes", "b": [0.7225, 0.6956, 0.7951, 0.717]}, {"w": "it", "b": [0.8011, 0.6956, 0.8131, 0.717]}, {"w": "did.3", "b": [0.8191, 0.6956, 0.8571, 0.717]}]}, {"id": "b_5", "type": "paragraph", "text": "The reason is that we used a simple SGDClassifier, which is a linear model. All it does is assign a weight per class to each pixel, and when it sees a new image it just sums up the weighted pixel intensities to get a score for each class. So since 3s and 5s differ only by a few pixels, this model will easily confuse them.", "words": [{"w": "The", "b": [0.1429, 0.7155, 0.1757, 0.737]}, {"w": "reason", "b": [0.1827, 0.7155, 0.2381, 0.737]}, {"w": "is", "b": [0.2451, 0.7155, 0.2584, 0.737]}, {"w": "that", "b": [0.2654, 0.7155, 0.298, 0.737]}, {"w": "we", "b": [0.305, 0.7155, 0.3281, 0.737]}, {"w": "used", "b": [0.3352, 0.7155, 0.3737, 0.737]}, {"w": "a", "b": [0.3807, 0.7155, 0.3899, 0.737]}, {"w": "simple", "b": [0.3969, 0.7155, 0.4519, 0.737]}, {"w": "SGDClassifier,", "b": [0.4589, 0.7155, 0.5923, 0.737]}, {"w": "which", "b": [0.5993, 0.7155, 0.6502, 0.737]}, {"w": "is", "b": [0.6572, 0.7155, 0.6705, 0.737]}, {"w": "a", "b": [0.6775, 0.7155, 0.6866, 0.737]}, {"w": "linear", "b": [0.6937, 0.7155, 0.7416, 0.737]}, {"w": "model.", "b": [0.7487, 0.7155, 0.8062, 0.737]}, {"w": "All", "b": [0.8133, 0.7155, 0.8382, 0.737]}, {"w": "it", "b": [0.8452, 0.7155, 0.8572, 0.737]}, {"w": "does", "b": [0.1429, 0.7346, 0.181, 0.756]}, {"w": "is", "b": [0.1878, 0.7346, 0.201, 0.756]}, {"w": "assign", "b": [0.2078, 0.7346, 0.259, 0.756]}, {"w": "a", "b": [0.2658, 0.7346, 0.2749, 0.756]}, {"w": "weight", "b": [0.2817, 0.7346, 0.3373, 0.756]}, {"w": "per", "b": [0.3441, 0.7346, 0.3716, 0.756]}, {"w": "class", "b": [0.3784, 0.7346, 0.4169, 0.756]}, {"w": "to", "b": [0.4237, 0.7346, 0.4407, 0.756]}, {"w": "each", "b": [0.4475, 0.7346, 0.4854, 0.756]}, {"w": "pixel,", "b": [0.4922, 0.7346, 0.5374, 0.756]}, {"w": "and", "b": [0.5442, 0.7346, 0.5758, 0.756]}, {"w": "when", "b": [0.5826, 0.7346, 0.6282, 0.756]}, {"w": "it", "b": [0.635, 0.7346, 0.6469, 0.756]}, {"w": "sees", "b": [0.6537, 0.7346, 0.6867, 0.756]}, {"w": "a", "b": [0.6935, 0.7346, 0.7027, 0.756]}, {"w": "new", "b": [0.7095, 0.7346, 0.744, 0.756]}, {"w": "image", "b": [0.7508, 0.7346, 0.8012, 0.756]}, {"w": "it", "b": [0.808, 0.7346, 0.82, 0.756]}, {"w": "just", "b": [0.8268, 0.7346, 0.8571, 0.756]}, {"w": "sums", "b": [0.1429, 0.7536, 0.1863, 0.7751]}, {"w": "up", "b": [0.1917, 0.7536, 0.2136, 0.7751]}, {"w": "the", "b": [0.219, 0.7536, 0.2454, 0.7751]}, {"w": "weighted", "b": [0.2508, 0.7536, 0.3262, 0.7751]}, {"w": "pixel", "b": [0.3316, 0.7536, 0.372, 0.7751]}, {"w": "intensities", "b": [0.3774, 0.7536, 0.4623, 0.7751]}, {"w": "to", "b": [0.4677, 0.7536, 0.4847, 0.7751]}, {"w": "get", "b": [0.49, 0.7536, 0.515, 0.7751]}, {"w": "a", "b": [0.5204, 0.7536, 0.5296, 0.7751]}, {"w": "score", "b": [0.5349, 0.7536, 0.5786, 0.7751]}, {"w": "for", "b": [0.584, 0.7536, 0.6085, 0.7751]}, {"w": "each", "b": [0.6139, 0.7536, 0.6519, 0.7751]}, {"w": "class.", "b": [0.6573, 0.7536, 0.7005, 0.7751]}, {"w": "So", "b": [0.7059, 0.7536, 0.7264, 0.7751]}, {"w": "since", "b": [0.7318, 0.7536, 0.7741, 0.7751]}, {"w": "3s", "b": [0.7795, 0.7536, 0.7972, 0.7751]}, {"w": "and", "b": [0.8026, 0.7536, 0.8341, 0.7751]}, {"w": "5s", "b": [0.8395, 0.7536, 0.8571, 0.7751]}, {"w": "differ", "b": [0.1429, 0.7727, 0.1884, 0.7941]}, {"w": "only", "b": [0.1931, 0.7727, 0.2299, 0.7941]}, {"w": "by", "b": [0.2347, 0.7727, 0.2548, 0.7941]}, {"w": "a", "b": [0.2595, 0.7727, 0.2687, 0.7941]}, {"w": "few", "b": [0.2734, 0.7727, 0.3027, 0.7941]}, {"w": "pixels,", "b": [0.3074, 0.7727, 0.3603, 0.7941]}, {"w": "this", "b": [0.365, 0.7727, 0.3957, 0.7941]}, {"w": "model", "b": [0.4005, 0.7727, 0.4533, 0.7941]}, {"w": "will", "b": [0.458, 0.7727, 0.4884, 0.7941]}, {"w": "easily", "b": [0.4931, 0.7727, 0.5392, 0.7941]}, {"w": "confuse", "b": [0.5439, 0.7727, 0.6085, 0.7941]}, {"w": "them.", "b": [0.6132, 0.7727, 0.6614, 0.7941]}]}, {"id": "b_6", "type": "paragraph", "text": "Error Analysis | 107", "words": [{"w": "Error", "b": [0.7165, 0.9225, 0.7452, 0.9388]}, {"w": "Analysis", "b": [0.748, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "107", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 134, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "The main difference between 3s and 5s is the position of the small line that joins the top line to the bottom arc. If you draw a 3 with the junction slightly shifted to the left, the classifier might classify it as a 5, and vice versa. In other words, this classifier is quite sensitive to image shifting and rotation. So one way to reduce the 3/5 confusion would be to preprocess the images to ensure that they are well centered and not too rotated. This will probably help reduce other errors as well.", "words": [{"w": "The", "b": [0.1429, 0.0791, 0.1757, 0.1005]}, {"w": "main", "b": [0.1815, 0.0791, 0.2247, 0.1005]}, {"w": "difference", "b": [0.2304, 0.0791, 0.3138, 0.1005]}, {"w": "between", "b": [0.3196, 0.0791, 0.3888, 0.1005]}, {"w": "3s", "b": [0.3946, 0.0791, 0.4122, 0.1005]}, {"w": "and", "b": [0.418, 0.0791, 0.4495, 0.1005]}, {"w": "5s", "b": [0.4553, 0.0791, 0.473, 0.1005]}, {"w": "is", "b": [0.4787, 0.0791, 0.492, 0.1005]}, {"w": "the", "b": [0.4977, 0.0791, 0.5241, 0.1005]}, {"w": "position", "b": [0.5298, 0.0791, 0.5986, 0.1005]}, {"w": "of", "b": [0.6044, 0.0791, 0.6211, 0.1005]}, {"w": "the", "b": [0.6269, 0.0791, 0.6533, 0.1005]}, {"w": "small", "b": [0.659, 0.0791, 0.7034, 0.1005]}, {"w": "line", "b": [0.7092, 0.0791, 0.7403, 0.1005]}, {"w": "that", "b": [0.7461, 0.0791, 0.7787, 0.1005]}, {"w": "joins", "b": [0.7844, 0.0791, 0.825, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}, {"w": "top", "b": [0.1429, 0.0981, 0.1707, 0.1195]}, {"w": "line", "b": [0.1757, 0.0981, 0.2068, 0.1195]}, {"w": "to", "b": [0.2117, 0.0981, 0.2287, 0.1195]}, {"w": "the", "b": [0.2336, 0.0981, 0.2599, 0.1195]}, {"w": "bottom", "b": [0.2649, 0.0981, 0.3265, 0.1195]}, {"w": "arc.", "b": [0.3314, 0.0981, 0.3618, 0.1195]}, {"w": "If", "b": [0.3668, 0.0981, 0.38, 0.1195]}, {"w": "you", "b": [0.385, 0.0981, 0.4162, 0.1195]}, {"w": "draw", "b": [0.4211, 0.0981, 0.4629, 0.1195]}, {"w": "a", "b": [0.4678, 0.0981, 0.477, 0.1195]}, {"w": "3", "b": [0.4819, 0.0981, 0.4919, 0.1195]}, {"w": "with", "b": [0.4968, 0.0981, 0.5342, 0.1195]}, {"w": "the", "b": [0.5391, 0.0981, 0.5654, 0.1195]}, {"w": "junction", "b": [0.5703, 0.0981, 0.6409, 0.1195]}, {"w": "slightly", "b": [0.6458, 0.0981, 0.706, 0.1195]}, {"w": "shifted", "b": [0.7109, 0.0981, 0.7677, 0.1195]}, {"w": "to", "b": [0.7726, 0.0981, 0.7896, 0.1195]}, {"w": "the", "b": [0.7945, 0.0981, 0.8208, 0.1195]}, {"w": "left,", "b": [0.8257, 0.0981, 0.8571, 0.1195]}, {"w": "the", "b": [0.1429, 0.1172, 0.1692, 0.1386]}, {"w": "classifier", "b": [0.1758, 0.1172, 0.2482, 0.1386]}, {"w": "might", "b": [0.2548, 0.1172, 0.3043, 0.1386]}, {"w": "classify", "b": [0.3109, 0.1172, 0.3711, 0.1386]}, {"w": "it", "b": [0.3777, 0.1172, 0.3896, 0.1386]}, {"w": "as", "b": [0.3962, 0.1172, 0.413, 0.1386]}, {"w": "a", "b": [0.4196, 0.1172, 0.4287, 0.1386]}, {"w": "5,", "b": [0.4353, 0.1172, 0.4501, 0.1386]}, {"w": "and", "b": [0.4566, 0.1172, 0.4882, 0.1386]}, {"w": "vice", "b": [0.4948, 0.1172, 0.5277, 0.1386]}, {"w": "versa.", "b": [0.5343, 0.1172, 0.582, 0.1386]}, {"w": "In", "b": [0.5886, 0.1172, 0.6071, 0.1386]}, {"w": "other", "b": [0.6137, 0.1172, 0.6584, 0.1386]}, {"w": "words,", "b": [0.665, 0.1172, 0.721, 0.1386]}, {"w": "this", "b": [0.7276, 0.1172, 0.7583, 0.1386]}, {"w": "classifier", "b": [0.7649, 0.1172, 0.8373, 0.1386]}, {"w": "is", "b": [0.8439, 0.1172, 0.8572, 0.1386]}, {"w": "quite", "b": [0.1429, 0.1362, 0.1854, 0.1576]}, {"w": "sensitive", "b": [0.1905, 0.1362, 0.262, 0.1576]}, {"w": "to", "b": [0.2672, 0.1362, 0.2841, 0.1576]}, {"w": "image", "b": [0.2893, 0.1362, 0.3397, 0.1576]}, {"w": "shifting", "b": [0.3448, 0.1362, 0.4084, 0.1576]}, {"w": "and", "b": [0.4135, 0.1362, 0.4451, 0.1576]}, {"w": "rotation.", "b": [0.4502, 0.1362, 0.5223, 0.1576]}, {"w": "So", "b": [0.5275, 0.1362, 0.548, 0.1576]}, {"w": "one", "b": [0.5531, 0.1362, 0.584, 0.1576]}, {"w": "way", "b": [0.5891, 0.1362, 0.6217, 0.1576]}, {"w": "to", "b": [0.6268, 0.1362, 0.6438, 0.1576]}, {"w": "reduce", "b": [0.6489, 0.1362, 0.7052, 0.1576]}, {"w": "the", "b": [0.7104, 0.1362, 0.7367, 0.1576]}, {"w": "3/5", "b": [0.7418, 0.1362, 0.7687, 0.1576]}, {"w": "confusion", "b": [0.7738, 0.1362, 0.8571, 0.1576]}, {"w": "would", "b": [0.1429, 0.1553, 0.1951, 0.1767]}, {"w": "be", "b": [0.2012, 0.1553, 0.2207, 0.1767]}, {"w": "to", "b": [0.2268, 0.1553, 0.2438, 0.1767]}, {"w": "preprocess", "b": [0.2499, 0.1553, 0.3397, 0.1767]}, {"w": "the", "b": [0.3458, 0.1553, 0.3721, 0.1767]}, {"w": "images", "b": [0.3783, 0.1553, 0.4363, 0.1767]}, {"w": "to", "b": [0.4425, 0.1553, 0.4594, 0.1767]}, {"w": "ensure", "b": [0.4656, 0.1553, 0.5211, 0.1767]}, {"w": "that", "b": [0.5273, 0.1553, 0.5599, 0.1767]}, {"w": "they", "b": [0.566, 0.1553, 0.6019, 0.1767]}, {"w": "are", "b": [0.608, 0.1553, 0.6338, 0.1767]}, {"w": "well", "b": [0.6399, 0.1553, 0.6736, 0.1767]}, {"w": "centered", "b": [0.6797, 0.1553, 0.7512, 0.1767]}, {"w": "and", "b": [0.7573, 0.1553, 0.7889, 0.1767]}, {"w": "not", "b": [0.795, 0.1553, 0.8234, 0.1767]}, {"w": "too", "b": [0.8295, 0.1553, 0.8571, 0.1767]}, {"w": "rotated.", "b": [0.1428, 0.1743, 0.2073, 0.1957]}, {"w": "This", "b": [0.212, 0.1743, 0.2492, 0.1957]}, {"w": "will", "b": [0.2539, 0.1743, 0.2843, 0.1957]}, {"w": "probably", "b": [0.2891, 0.1743, 0.3635, 0.1957]}, {"w": "help", "b": [0.3682, 0.1743, 0.4044, 0.1957]}, {"w": "reduce", "b": [0.4091, 0.1743, 0.4654, 0.1957]}, {"w": "other", "b": [0.4701, 0.1743, 0.5148, 0.1957]}, {"w": "errors", "b": [0.5196, 0.1743, 0.5699, 0.1957]}, {"w": "as", "b": [0.5746, 0.1743, 0.5914, 0.1957]}, {"w": "well.", "b": [0.5961, 0.1743, 0.6345, 0.1957]}]}, {"id": "b_1", "type": "paragraph", "text": "Multilabel Classification", "words": [{"w": "Multilabel", "b": [0.1428, 0.2087, 0.2699, 0.243]}, {"w": "Classification", "b": [0.2758, 0.2087, 0.4377, 0.243]}]}, {"id": "b_2", "type": "paragraph", "text": "Until now each instance has always been assigned to just one class. In some cases you may want your classifier to output multiple classes for each instance. For example, consider a face-recognition classifier: what should it do if it recognizes several people on the same picture? Of course it should attach one tag per person it recognizes. Say the classifier has been trained to recognize three faces, Alice, Bob, and Charlie; then when it is shown a picture of Alice and Charlie, it should output [1, 0, 1] (meaning “Alice yes, Bob no, Charlie yes”). Such a classification system that outputs multiple binary tags is called a multilabel classification system.", "words": [{"w": "Until", "b": [0.1429, 0.2499, 0.1855, 0.2713]}, {"w": "now", "b": [0.1907, 0.2499, 0.2269, 0.2713]}, {"w": "each", "b": [0.2321, 0.2499, 0.27, 0.2713]}, {"w": "instance", "b": [0.2752, 0.2499, 0.3444, 0.2713]}, {"w": "has", "b": [0.3495, 0.2499, 0.3775, 0.2713]}, {"w": "always", "b": [0.3826, 0.2499, 0.4373, 0.2713]}, {"w": "been", "b": [0.4424, 0.2499, 0.4821, 0.2713]}, {"w": "assigned", "b": [0.4873, 0.2499, 0.5583, 0.2713]}, {"w": "to", "b": [0.5635, 0.2499, 0.5804, 0.2713]}, {"w": "just", "b": [0.5856, 0.2499, 0.616, 0.2713]}, {"w": "one", "b": [0.6212, 0.2499, 0.652, 0.2713]}, {"w": "class.", "b": [0.6572, 0.2499, 0.7005, 0.2713]}, {"w": "In", "b": [0.7056, 0.2499, 0.7241, 0.2713]}, {"w": "some", "b": [0.7293, 0.2499, 0.7735, 0.2713]}, {"w": "cases", "b": [0.7786, 0.2499, 0.8207, 0.2713]}, {"w": "you", "b": [0.8259, 0.2499, 0.8571, 0.2713]}, {"w": "may", "b": [0.1429, 0.2689, 0.1783, 0.2903]}, {"w": "want", "b": [0.1856, 0.2689, 0.2264, 0.2903]}, {"w": "your", "b": [0.2338, 0.2689, 0.2728, 0.2903]}, {"w": "classifier", "b": [0.2802, 0.2689, 0.3526, 0.2903]}, {"w": "to", "b": [0.36, 0.2689, 0.377, 0.2903]}, {"w": "output", "b": [0.3844, 0.2689, 0.4408, 0.2903]}, {"w": "multiple", "b": [0.4481, 0.2689, 0.5181, 0.2903]}, {"w": "classes", "b": [0.5255, 0.2689, 0.5805, 0.2903]}, {"w": "for", "b": [0.5879, 0.2689, 0.6124, 0.2903]}, {"w": "each", "b": [0.6198, 0.2689, 0.6578, 0.2903]}, {"w": "instance.", "b": [0.6652, 0.2689, 0.7391, 0.2903]}, {"w": "For", "b": [0.7465, 0.2689, 0.7755, 0.2903]}, {"w": "example,", "b": [0.7829, 0.2689, 0.8571, 0.2903]}, {"w": "consider", "b": [0.1429, 0.288, 0.2145, 0.3094]}, {"w": "a", "b": [0.2198, 0.288, 0.229, 0.3094]}, {"w": "face-recognition", "b": [0.2343, 0.288, 0.3714, 0.3094]}, {"w": "classifier:", "b": [0.3767, 0.288, 0.4544, 0.3094]}, {"w": "what", "b": [0.4597, 0.288, 0.5002, 0.3094]}, {"w": "should", "b": [0.5055, 0.288, 0.5622, 0.3094]}, {"w": "it", "b": [0.5675, 0.288, 0.5794, 0.3094]}, {"w": "do", "b": [0.5847, 0.288, 0.6064, 0.3094]}, {"w": "if", "b": [0.6117, 0.288, 0.6234, 0.3094]}, {"w": "it", "b": [0.6287, 0.288, 0.6407, 0.3094]}, {"w": "recognizes", "b": [0.646, 0.288, 0.734, 0.3094]}, {"w": "several", "b": [0.7393, 0.288, 0.7964, 0.3094]}, {"w": "people", "b": [0.8017, 0.288, 0.8571, 0.3094]}, {"w": "on", "b": [0.1429, 0.307, 0.1649, 0.3284]}, {"w": "the", "b": [0.1707, 0.307, 0.197, 0.3284]}, {"w": "same", "b": [0.2028, 0.307, 0.2455, 0.3284]}, {"w": "picture?", "b": [0.2512, 0.307, 0.3185, 0.3284]}, {"w": "Of", "b": [0.3242, 0.307, 0.346, 0.3284]}, {"w": "course", "b": [0.3517, 0.307, 0.4065, 0.3284]}, {"w": "it", "b": [0.4122, 0.307, 0.4242, 0.3284]}, {"w": "should", "b": [0.43, 0.307, 0.4867, 0.3284]}, {"w": "attach", "b": [0.4925, 0.307, 0.543, 0.3284]}, {"w": "one", "b": [0.5488, 0.307, 0.5797, 0.3284]}, {"w": "tag", "b": [0.5854, 0.307, 0.6107, 0.3284]}, {"w": "per", "b": [0.6165, 0.307, 0.644, 0.3284]}, {"w": "person", "b": [0.6497, 0.307, 0.7069, 0.3284]}, {"w": "it", "b": [0.7127, 0.307, 0.7246, 0.3284]}, {"w": "recognizes.", "b": [0.7304, 0.307, 0.8232, 0.3284]}, {"w": "Say", "b": [0.8289, 0.307, 0.8571, 0.3284]}, {"w": "the", "b": [0.1429, 0.3261, 0.1692, 0.3475]}, {"w": "classifier", "b": [0.1754, 0.3261, 0.2479, 0.3475]}, {"w": "has", "b": [0.2541, 0.3261, 0.282, 0.3475]}, {"w": "been", "b": [0.2882, 0.3261, 0.3279, 0.3475]}, {"w": "trained", "b": [0.3342, 0.3261, 0.3942, 0.3475]}, {"w": "to", "b": [0.4004, 0.3261, 0.4174, 0.3475]}, {"w": "recognize", "b": [0.4236, 0.3261, 0.504, 0.3475]}, {"w": "three", "b": [0.5102, 0.3261, 0.5531, 0.3475]}, {"w": "faces,", "b": [0.5594, 0.3261, 0.6047, 0.3475]}, {"w": "Alice,", "b": [0.611, 0.3261, 0.6586, 0.3475]}, {"w": "Bob,", "b": [0.6649, 0.3261, 0.7029, 0.3475]}, {"w": "and", "b": [0.7091, 0.3261, 0.7407, 0.3475]}, {"w": "Charlie;", "b": [0.7469, 0.3261, 0.8132, 0.3475]}, {"w": "then", "b": [0.8194, 0.3261, 0.8572, 0.3475]}, {"w": "when", "b": [0.1429, 0.3451, 0.1885, 0.3665]}, {"w": "it", "b": [0.1949, 0.3451, 0.2069, 0.3665]}, {"w": "is", "b": [0.2133, 0.3451, 0.2266, 0.3665]}, {"w": "shown", "b": [0.233, 0.3451, 0.2881, 0.3665]}, {"w": "a", "b": [0.2945, 0.3451, 0.3037, 0.3665]}, {"w": "picture", "b": [0.3101, 0.3451, 0.3694, 0.3665]}, {"w": "of", "b": [0.3758, 0.3451, 0.3926, 0.3665]}, {"w": "Alice", "b": [0.3991, 0.3451, 0.442, 0.3665]}, {"w": "and", "b": [0.4484, 0.3451, 0.48, 0.3665]}, {"w": "Charlie,", "b": [0.4864, 0.3451, 0.5527, 0.3665]}, {"w": "it", "b": [0.5592, 0.3451, 0.5711, 0.3665]}, {"w": "should", "b": [0.5776, 0.3451, 0.6343, 0.3665]}, {"w": "output", "b": [0.6407, 0.3451, 0.6971, 0.3665]}, {"w": "[1,", "b": [0.7035, 0.3451, 0.7255, 0.3665]}, {"w": "0,", "b": [0.7319, 0.3451, 0.7467, 0.3665]}, {"w": "1]", "b": [0.7531, 0.3451, 0.7703, 0.3665]}, {"w": "(meaning", "b": [0.7768, 0.3451, 0.8571, 0.3665]}, {"w": "“Alice", "b": [0.1429, 0.3642, 0.1909, 0.3856]}, {"w": "yes,", "b": [0.1982, 0.3642, 0.229, 0.3856]}, {"w": "Bob", "b": [0.2363, 0.3642, 0.2702, 0.3856]}, {"w": "no,", "b": [0.2774, 0.3642, 0.3036, 0.3856]}, {"w": "Charlie", "b": [0.3108, 0.3642, 0.3724, 0.3856]}, {"w": "yes”).", "b": [0.3797, 0.3642, 0.4252, 0.3856]}, {"w": "Such", "b": [0.4325, 0.3642, 0.4733, 0.3856]}, {"w": "a", "b": [0.4806, 0.3642, 0.4897, 0.3856]}, {"w": "classification", "b": [0.497, 0.3642, 0.6044, 0.3856]}, {"w": "system", "b": [0.6116, 0.3642, 0.6688, 0.3856]}, {"w": "that", "b": [0.676, 0.3642, 0.7086, 0.3856]}, {"w": "outputs", "b": [0.7159, 0.3642, 0.7799, 0.3856]}, {"w": "multiple", "b": [0.7872, 0.3642, 0.8571, 0.3856]}, {"w": "binary", "b": [0.1428, 0.3832, 0.1975, 0.4046]}, {"w": "tags", "b": [0.2022, 0.3832, 0.2351, 0.4046]}, {"w": "is", "b": [0.2398, 0.3832, 0.253, 0.4046]}, {"w": "called", "b": [0.2578, 0.3832, 0.3061, 0.4046]}, {"w": "a", "b": [0.3108, 0.3832, 0.32, 0.4046]}, {"w": "multilabel", "b": [0.3247, 0.383, 0.4065, 0.4046]}, {"w": "classification", "b": [0.4113, 0.383, 0.5166, 0.4046]}, {"w": "system.", "b": [0.5213, 0.3832, 0.5832, 0.4046]}]}, {"id": "b_3", "type": "paragraph", "text": "We won’t go into face recognition just yet, but let’s look at a simpler example, just for illustration purposes:", "words": [{"w": "We", "b": [0.1428, 0.4113, 0.1699, 0.4327]}, {"w": "won’t", "b": [0.1754, 0.4113, 0.2203, 0.4327]}, {"w": "go", "b": [0.2257, 0.4113, 0.2461, 0.4327]}, {"w": "into", "b": [0.2516, 0.4113, 0.2851, 0.4327]}, {"w": "face", "b": [0.2906, 0.4113, 0.3236, 0.4327]}, {"w": "recognition", "b": [0.3291, 0.4113, 0.4258, 0.4327]}, {"w": "just", "b": [0.4313, 0.4113, 0.4617, 0.4327]}, {"w": "yet,", "b": [0.4671, 0.4113, 0.4967, 0.4327]}, {"w": "but", "b": [0.5021, 0.4113, 0.5301, 0.4327]}, {"w": "let’s", "b": [0.5356, 0.4113, 0.5658, 0.4327]}, {"w": "look", "b": [0.5713, 0.4113, 0.6082, 0.4327]}, {"w": "at", "b": [0.6136, 0.4113, 0.6287, 0.4327]}, {"w": "a", "b": [0.6342, 0.4113, 0.6434, 0.4327]}, {"w": "simpler", "b": [0.6488, 0.4113, 0.7115, 0.4327]}, {"w": "example,", "b": [0.717, 0.4113, 0.7913, 0.4327]}, {"w": "just", "b": [0.7967, 0.4113, 0.8271, 0.4327]}, {"w": "for", "b": [0.8326, 0.4113, 0.8571, 0.4327]}, {"w": "illustration", "b": [0.1429, 0.4304, 0.2345, 0.4518]}, {"w": "purposes:", "b": [0.2392, 0.4304, 0.3194, 0.4518]}]}, {"id": "b_4", "type": "paragraph", "text": "from sklearn.neighbors import KNeighborsClassifier", "words": [{"w": "from", "b": [0.1766, 0.4624, 0.2103, 0.4752]}, {"w": "sklearn.neighbors", "b": [0.2187, 0.4624, 0.3621, 0.4752]}, {"w": "import", "b": [0.3705, 0.4624, 0.4211, 0.4752]}, {"w": "KNeighborsClassifier", "b": [0.4296, 0.4624, 0.5982, 0.4752]}]}, {"id": "b_5", "type": "paragraph", "text": "y_train_large = (y_train >= 7) y_train_odd = (y_train % 2 == 1) y_multilabel = np.c_[y_train_large, y_train_odd]", "words": [{"w": "y_train_large", "b": [0.1766, 0.4932, 0.2862, 0.506]}, {"w": "=", "b": [0.2946, 0.4932, 0.3031, 0.506]}, {"w": "(y_train", "b": [0.3115, 0.4932, 0.379, 0.506]}, {"w": ">=", "b": [0.3874, 0.4932, 0.4043, 0.506]}, {"w": "7)", "b": [0.4127, 0.4932, 0.4296, 0.506]}, {"w": "y_train_odd", "b": [0.1766, 0.5086, 0.2693, 0.5215]}, {"w": "=", "b": [0.2778, 0.5086, 0.2862, 0.5215]}, {"w": "(y_train", "b": [0.2946, 0.5086, 0.3621, 0.5215]}, {"w": "%", "b": [0.3705, 0.5086, 0.379, 0.5215]}, {"w": "2", "b": [0.3874, 0.5086, 0.3958, 0.5215]}, {"w": "==", "b": [0.4043, 0.5086, 0.4211, 0.5215]}, {"w": "1)", "b": [0.4296, 0.5086, 0.4464, 0.5215]}, {"w": "y_multilabel", "b": [0.1766, 0.524, 0.2778, 0.5369]}, {"w": "=", "b": [0.2862, 0.524, 0.2946, 0.5369]}, {"w": "np.c_[y_train_large,", "b": [0.3031, 0.524, 0.4717, 0.5369]}, {"w": "y_train_odd]", "b": [0.4802, 0.524, 0.5813, 0.5369]}]}, {"id": "b_6", "type": "equation", "text": "knn_clf = KNeighborsClassifier() knn_clf.fit(X_train, y_multilabel)", "words": [{"w": "knn_clf", "b": [0.1766, 0.5549, 0.2356, 0.5677]}, {"w": "=", "b": [0.244, 0.5549, 0.2525, 0.5677]}, {"w": "KNeighborsClassifier()", "b": [0.2609, 0.5549, 0.4464, 0.5677]}, {"w": "knn_clf.fit(X_train,", "b": [0.1766, 0.5703, 0.3452, 0.5831]}, {"w": "y_multilabel)", "b": [0.3537, 0.5703, 0.4633, 0.5831]}]}, {"id": "b_7", "type": "paragraph", "text": "This code creates a y_multilabel array containing two target labels for each digit image: the first indicates whether or not the digit is large (7, 8, or 9) and the second indicates whether or not it is odd. The next lines create a KNeighborsClassifier instance (which supports multilabel classification, but not all classifiers do) and we train it using the multiple targets array. Now you can make a prediction, and notice that it outputs two labels:", "words": [{"w": "This", "b": [0.1429, 0.5918, 0.1801, 0.6132]}, {"w": "code", "b": [0.1878, 0.5918, 0.2271, 0.6132]}, {"w": "creates", "b": [0.2349, 0.5918, 0.2919, 0.6132]}, {"w": "a", "b": [0.2997, 0.5918, 0.3088, 0.6132]}, {"w": "y_multilabel", "b": [0.3166, 0.595, 0.4354, 0.6101]}, {"w": "array", "b": [0.4432, 0.5918, 0.4861, 0.6132]}, {"w": "containing", "b": [0.4939, 0.5918, 0.5835, 0.6132]}, {"w": "two", "b": [0.5913, 0.5918, 0.6225, 0.6132]}, {"w": "target", "b": [0.6303, 0.5918, 0.6785, 0.6132]}, {"w": "labels", "b": [0.6863, 0.5918, 0.7331, 0.6132]}, {"w": "for", "b": [0.7408, 0.5918, 0.7654, 0.6132]}, {"w": "each", "b": [0.7732, 0.5918, 0.8111, 0.6132]}, {"w": "digit", "b": [0.8189, 0.5918, 0.8571, 0.6132]}, {"w": "image:", "b": [0.1428, 0.6109, 0.198, 0.6323]}, {"w": "the", "b": [0.2041, 0.6109, 0.2304, 0.6323]}, {"w": "first", "b": [0.2365, 0.6109, 0.27, 0.6323]}, {"w": "indicates", "b": [0.276, 0.6109, 0.35, 0.6323]}, {"w": "whether", "b": [0.3561, 0.6109, 0.4244, 0.6323]}, {"w": "or", "b": [0.4305, 0.6109, 0.4488, 0.6323]}, {"w": "not", "b": [0.4549, 0.6109, 0.4833, 0.6323]}, {"w": "the", "b": [0.4893, 0.6109, 0.5157, 0.6323]}, {"w": "digit", "b": [0.5217, 0.6109, 0.56, 0.6323]}, {"w": "is", "b": [0.5661, 0.6109, 0.5793, 0.6323]}, {"w": "large", "b": [0.5854, 0.6109, 0.6261, 0.6323]}, {"w": "(7,", "b": [0.6322, 0.6109, 0.6542, 0.6323]}, {"w": "8,", "b": [0.6602, 0.6109, 0.675, 0.6323]}, {"w": "or", "b": [0.6811, 0.6109, 0.6994, 0.6323]}, {"w": "9)", "b": [0.7055, 0.6109, 0.7227, 0.6323]}, {"w": "and", "b": [0.7288, 0.6109, 0.7603, 0.6323]}, {"w": "the", "b": [0.7664, 0.6109, 0.7927, 0.6323]}, {"w": "second", "b": [0.7988, 0.6109, 0.8571, 0.6323]}, {"w": "indicates", "b": [0.1429, 0.6308, 0.2168, 0.6522]}, {"w": "whether", "b": [0.2244, 0.6308, 0.2927, 0.6522]}, {"w": "or", "b": [0.3003, 0.6308, 0.3186, 0.6522]}, {"w": "not", "b": [0.3262, 0.6308, 0.3546, 0.6522]}, {"w": "it", "b": [0.3621, 0.6308, 0.3741, 0.6522]}, {"w": "is", "b": [0.3816, 0.6308, 0.3949, 0.6522]}, {"w": "odd.", "b": [0.4024, 0.6308, 0.4398, 0.6522]}, {"w": "The", "b": [0.4473, 0.6308, 0.4802, 0.6522]}, {"w": "next", "b": [0.4877, 0.6308, 0.5242, 0.6522]}, {"w": "lines", "b": [0.5317, 0.6308, 0.5705, 0.6522]}, {"w": "create", "b": [0.5781, 0.6308, 0.6274, 0.6522]}, {"w": "a", "b": [0.635, 0.6308, 0.6441, 0.6522]}, {"w": "KNeighborsClassifier", "b": [0.6517, 0.634, 0.8496, 0.6491]}, {"w": "instance", "b": [0.1429, 0.6499, 0.212, 0.6713]}, {"w": "(which", "b": [0.2192, 0.6499, 0.2773, 0.6713]}, {"w": "supports", "b": [0.2844, 0.6499, 0.3573, 0.6713]}, {"w": "multilabel", "b": [0.3644, 0.6499, 0.4485, 0.6713]}, {"w": "classification,", "b": [0.4556, 0.6499, 0.5677, 0.6713]}, {"w": "but", "b": [0.5748, 0.6499, 0.6028, 0.6713]}, {"w": "not", "b": [0.6099, 0.6499, 0.6383, 0.6713]}, {"w": "all", "b": [0.6454, 0.6499, 0.6651, 0.6713]}, {"w": "classifiers", "b": [0.6722, 0.6499, 0.7523, 0.6713]}, {"w": "do)", "b": [0.7594, 0.6499, 0.7883, 0.6713]}, {"w": "and", "b": [0.7954, 0.6499, 0.8269, 0.6713]}, {"w": "we", "b": [0.834, 0.6499, 0.8571, 0.6713]}, {"w": "train", "b": [0.1429, 0.6689, 0.1831, 0.6903]}, {"w": "it", "b": [0.1894, 0.6689, 0.2013, 0.6903]}, {"w": "using", "b": [0.2077, 0.6689, 0.2531, 0.6903]}, {"w": "the", "b": [0.2594, 0.6689, 0.2858, 0.6903]}, {"w": "multiple", "b": [0.2921, 0.6689, 0.3621, 0.6903]}, {"w": "targets", "b": [0.3684, 0.6689, 0.4242, 0.6903]}, {"w": "array.", "b": [0.4306, 0.6689, 0.4767, 0.6903]}, {"w": "Now", "b": [0.4831, 0.6689, 0.5229, 0.6903]}, {"w": "you", "b": [0.5292, 0.6689, 0.5605, 0.6903]}, {"w": "can", "b": [0.5668, 0.6689, 0.5962, 0.6903]}, {"w": "make", "b": [0.6025, 0.6689, 0.6479, 0.6903]}, {"w": "a", "b": [0.6542, 0.6689, 0.6634, 0.6903]}, {"w": "prediction,", "b": [0.6697, 0.6689, 0.7613, 0.6903]}, {"w": "and", "b": [0.7676, 0.6689, 0.7992, 0.6903]}, {"w": "notice", "b": [0.8055, 0.6689, 0.8571, 0.6903]}, {"w": "that", "b": [0.1429, 0.688, 0.1755, 0.7094]}, {"w": "it", "b": [0.1802, 0.688, 0.1921, 0.7094]}, {"w": "outputs", "b": [0.1968, 0.688, 0.2609, 0.7094]}, {"w": "two", "b": [0.2656, 0.688, 0.2968, 0.7094]}, {"w": "labels:", "b": [0.3016, 0.688, 0.3531, 0.7094]}]}, {"id": "b_8", "type": "equation", "text": ">>> knn_clf.predict([some_digit]) array([[False, True]])", "words": [{"w": ">>>", "b": [0.1766, 0.7199, 0.2019, 0.7328]}, {"w": "knn_clf.predict([some_digit])", "b": [0.2103, 0.7199, 0.4549, 0.7328]}, {"w": "array([[False,", "b": [0.1766, 0.7354, 0.2946, 0.7482]}, {"w": "True]])", "b": [0.3115, 0.7354, 0.3705, 0.7482]}]}, {"id": "b_9", "type": "paragraph", "text": "And it gets it right! The digit 5 is indeed not large (False) and odd (True).", "words": [{"w": "And", "b": [0.1429, 0.7569, 0.1797, 0.7783]}, {"w": "it", "b": [0.1844, 0.7569, 0.1963, 0.7783]}, {"w": "gets", "b": [0.2011, 0.7569, 0.2337, 0.7783]}, {"w": "it", "b": [0.2384, 0.7569, 0.2503, 0.7783]}, {"w": "right!", "b": [0.2551, 0.7569, 0.301, 0.7783]}, {"w": "The", "b": [0.3057, 0.7569, 0.3385, 0.7783]}, {"w": "digit", "b": [0.3432, 0.7569, 0.3815, 0.7783]}, {"w": "5", "b": [0.3862, 0.7569, 0.3962, 0.7783]}, {"w": "is", "b": [0.401, 0.7569, 0.4142, 0.7783]}, {"w": "indeed", "b": [0.4189, 0.7569, 0.4756, 0.7783]}, {"w": "not", "b": [0.4803, 0.7569, 0.5087, 0.7783]}, {"w": "large", "b": [0.5135, 0.7569, 0.5542, 0.7783]}, {"w": "(False)", "b": [0.5589, 0.7569, 0.6228, 0.7783]}, {"w": "and", "b": [0.6276, 0.7569, 0.6591, 0.7783]}, {"w": "odd", "b": [0.6638, 0.7569, 0.6965, 0.7783]}, {"w": "(True).", "b": [0.7012, 0.7569, 0.7599, 0.7783]}]}, {"id": "b_10", "type": "paragraph", "text": "There are many ways to evaluate a multilabel classifier, and selecting the right metric really depends on your project. For example, one approach is to measure the F1 score for each individual label (or any other binary classifier metric discussed earlier), then simply compute the average score. This code computes the average F1 score across all labels:", "words": [{"w": "There", "b": [0.1429, 0.785, 0.1923, 0.8064]}, {"w": "are", "b": [0.1979, 0.785, 0.2237, 0.8064]}, {"w": "many", "b": [0.2293, 0.785, 0.276, 0.8064]}, {"w": "ways", "b": [0.2816, 0.785, 0.3219, 0.8064]}, {"w": "to", "b": [0.3275, 0.785, 0.3445, 0.8064]}, {"w": "evaluate", "b": [0.3501, 0.785, 0.4181, 0.8064]}, {"w": "a", "b": [0.4237, 0.785, 0.4328, 0.8064]}, {"w": "multilabel", "b": [0.4385, 0.785, 0.5225, 0.8064]}, {"w": "classifier,", "b": [0.5282, 0.785, 0.604, 0.8064]}, {"w": "and", "b": [0.6097, 0.785, 0.6412, 0.8064]}, {"w": "selecting", "b": [0.6469, 0.785, 0.7194, 0.8064]}, {"w": "the", "b": [0.725, 0.785, 0.7513, 0.8064]}, {"w": "right", "b": [0.757, 0.785, 0.7971, 0.8064]}, {"w": "metric", "b": [0.8028, 0.785, 0.8572, 0.8064]}, {"w": "really", "b": [0.1429, 0.8041, 0.1887, 0.8255]}, {"w": "depends", "b": [0.194, 0.8041, 0.2637, 0.8255]}, {"w": "on", "b": [0.269, 0.8041, 0.2911, 0.8255]}, {"w": "your", "b": [0.2964, 0.8041, 0.3354, 0.8255]}, {"w": "project.", "b": [0.3407, 0.8041, 0.4041, 0.8255]}, {"w": "For", "b": [0.4094, 0.8041, 0.4384, 0.8255]}, {"w": "example,", "b": [0.4437, 0.8041, 0.518, 0.8255]}, {"w": "one", "b": [0.5233, 0.8041, 0.5542, 0.8255]}, {"w": "approach", "b": [0.5596, 0.8041, 0.6376, 0.8255]}, {"w": "is", "b": [0.6429, 0.8041, 0.6561, 0.8255]}, {"w": "to", "b": [0.6615, 0.8041, 0.6784, 0.8255]}, {"w": "measure", "b": [0.6838, 0.8041, 0.7541, 0.8255]}, {"w": "the", "b": [0.7595, 0.8041, 0.7858, 0.8255]}, {"w": "F1", "b": [0.7911, 0.8041, 0.8082, 0.8264]}, {"w": "score", "b": [0.8135, 0.8041, 0.8572, 0.8255]}, {"w": "for", "b": [0.1429, 0.8231, 0.1674, 0.8445]}, {"w": "each", "b": [0.1727, 0.8231, 0.2107, 0.8445]}, {"w": "individual", "b": [0.216, 0.8231, 0.3013, 0.8445]}, {"w": "label", "b": [0.3066, 0.8231, 0.3457, 0.8445]}, {"w": "(or", "b": [0.3511, 0.8231, 0.3766, 0.8445]}, {"w": "any", "b": [0.3819, 0.8231, 0.4116, 0.8445]}, {"w": "other", "b": [0.4169, 0.8231, 0.4616, 0.8445]}, {"w": "binary", "b": [0.4669, 0.8231, 0.5215, 0.8445]}, {"w": "classifier", "b": [0.5269, 0.8231, 0.5993, 0.8445]}, {"w": "metric", "b": [0.6046, 0.8231, 0.659, 0.8445]}, {"w": "discussed", "b": [0.6644, 0.8231, 0.7436, 0.8445]}, {"w": "earlier),", "b": [0.749, 0.8231, 0.8141, 0.8445]}, {"w": "then", "b": [0.8194, 0.8231, 0.8571, 0.8445]}, {"w": "simply", "b": [0.1429, 0.8421, 0.1985, 0.8636]}, {"w": "compute", "b": [0.2038, 0.8421, 0.2771, 0.8636]}, {"w": "the", "b": [0.2825, 0.8421, 0.3088, 0.8636]}, {"w": "average", "b": [0.3141, 0.8421, 0.3769, 0.8636]}, {"w": "score.", "b": [0.3822, 0.8421, 0.4306, 0.8636]}, {"w": "This", "b": [0.436, 0.8421, 0.4732, 0.8636]}, {"w": "code", "b": [0.4785, 0.8421, 0.5178, 0.8636]}, {"w": "computes", "b": [0.5231, 0.8421, 0.6041, 0.8636]}, {"w": "the", "b": [0.6094, 0.8421, 0.6357, 0.8636]}, {"w": "average", "b": [0.6411, 0.8421, 0.7038, 0.8636]}, {"w": "F1", "b": [0.7092, 0.8421, 0.7262, 0.8644]}, {"w": "score", "b": [0.7315, 0.8421, 0.7752, 0.8636]}, {"w": "across", "b": [0.7805, 0.8421, 0.8321, 0.8636]}, {"w": "all", "b": [0.8375, 0.8421, 0.8572, 0.8636]}, {"w": "labels:", "b": [0.1429, 0.8612, 0.1944, 0.8826]}]}, {"id": "b_11", "type": "paragraph", "text": "108 | Chapter 3: Classification", "words": [{"w": "108", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "3:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Classification", "b": [0.2673, 0.9225, 0.3443, 0.9388]}]}]}, {"page": 135, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "4 Scikit-Learn offers a few other averaging options and multilabel classifier metrics; see the documentation for more details.", "words": [{"w": "4", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Scikit-Learn", "b": [0.1587, 0.8598, 0.2367, 0.8761]}, {"w": "offers", "b": [0.2403, 0.8598, 0.2762, 0.8761]}, {"w": "a", "b": [0.2798, 0.8598, 0.2868, 0.8761]}, {"w": "few", "b": [0.2904, 0.8598, 0.3127, 0.8761]}, {"w": "other", "b": [0.3163, 0.8598, 0.3504, 0.8761]}, {"w": "averaging", "b": [0.354, 0.8598, 0.4154, 0.8761]}, {"w": "options", "b": [0.419, 0.8598, 0.4671, 0.8761]}, {"w": "and", "b": [0.4707, 0.8598, 0.4947, 0.8761]}, {"w": "multilabel", "b": [0.4983, 0.8598, 0.5624, 0.8761]}, {"w": "classifier", "b": [0.566, 0.8598, 0.6212, 0.8761]}, {"w": "metrics;", "b": [0.6248, 0.8598, 0.6757, 0.8761]}, {"w": "see", "b": [0.6793, 0.8598, 0.6986, 0.8761]}, {"w": "the", "b": [0.7022, 0.8598, 0.7223, 0.8761]}, {"w": "documentation", "b": [0.7259, 0.8598, 0.823, 0.8761]}, {"w": "for", "b": [0.8266, 0.8598, 0.8453, 0.8761]}, {"w": "more", "b": [0.1587, 0.8749, 0.1925, 0.8912]}, {"w": "details.", "b": [0.1961, 0.8749, 0.2407, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> y_train_knn_pred = cross_val_predict(knn_clf, X_train, y_multilabel, cv=3) >>> f1_score(y_multilabel, y_train_knn_pred, average=\"macro\") 0.976410265560605", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "y_train_knn_pred", "b": [0.2103, 0.0829, 0.3452, 0.0958]}, {"w": "=", "b": [0.3537, 0.0829, 0.3621, 0.0958]}, {"w": "cross_val_predict(knn_clf,", "b": [0.3705, 0.0829, 0.5898, 0.0958]}, {"w": "X_train,", "b": [0.5982, 0.0829, 0.6657, 0.0958]}, {"w": "y_multilabel,", "b": [0.6741, 0.0829, 0.7837, 0.0958]}, {"w": "cv=3)", "b": [0.7922, 0.0829, 0.8343, 0.0958]}, {"w": ">>>", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "f1_score(y_multilabel,", "b": [0.2103, 0.0983, 0.3958, 0.1112]}, {"w": "y_train_knn_pred,", "b": [0.4043, 0.0983, 0.5476, 0.1112]}, {"w": "average=\"macro\")", "b": [0.5561, 0.0983, 0.691, 0.1112]}, {"w": "0.976410265560605", "b": [0.1766, 0.1138, 0.3199, 0.1266]}]}, {"id": "b_2", "type": "paragraph", "text": "This assumes that all labels are equally important, which may not be the case. In par‐ ticular, if you have many more pictures of Alice than of Bob or Charlie, you may want to give more weight to the classifier’s score on pictures of Alice. One simple option is to give each label a weight equal to its support (i.e., the number of instances with that target label). To do this, simply set average=\"weighted\" in the preceding code.4", "words": [{"w": "This", "b": [0.1429, 0.1344, 0.1801, 0.1558]}, {"w": "assumes", "b": [0.1855, 0.1344, 0.2545, 0.1558]}, {"w": "that", "b": [0.2599, 0.1344, 0.2925, 0.1558]}, {"w": "all", "b": [0.2979, 0.1344, 0.3176, 0.1558]}, {"w": "labels", "b": [0.323, 0.1344, 0.3698, 0.1558]}, {"w": "are", "b": [0.3752, 0.1344, 0.4009, 0.1558]}, {"w": "equally", "b": [0.4063, 0.1344, 0.4661, 0.1558]}, {"w": "important,", "b": [0.4715, 0.1344, 0.5606, 0.1558]}, {"w": "which", "b": [0.566, 0.1344, 0.6169, 0.1558]}, {"w": "may", "b": [0.6223, 0.1344, 0.6577, 0.1558]}, {"w": "not", "b": [0.6631, 0.1344, 0.6915, 0.1558]}, {"w": "be", "b": [0.6969, 0.1344, 0.7163, 0.1558]}, {"w": "the", "b": [0.7217, 0.1344, 0.748, 0.1558]}, {"w": "case.", "b": [0.7534, 0.1344, 0.7926, 0.1558]}, {"w": "In", "b": [0.798, 0.1344, 0.8165, 0.1558]}, {"w": "par‐", "b": [0.8219, 0.1344, 0.8571, 0.1558]}, {"w": "ticular,", "b": [0.1429, 0.1534, 0.2003, 0.1749]}, {"w": "if", "b": [0.2051, 0.1534, 0.2168, 0.1749]}, {"w": "you", "b": [0.2216, 0.1534, 0.2529, 0.1749]}, {"w": "have", "b": [0.2577, 0.1534, 0.2961, 0.1749]}, {"w": "many", "b": [0.3009, 0.1534, 0.3476, 0.1749]}, {"w": "more", "b": [0.3524, 0.1534, 0.3967, 0.1749]}, {"w": "pictures", "b": [0.4015, 0.1534, 0.4685, 0.1749]}, {"w": "of", "b": [0.4733, 0.1534, 0.4901, 0.1749]}, {"w": "Alice", "b": [0.4949, 0.1534, 0.5378, 0.1749]}, {"w": "than", "b": [0.5426, 0.1534, 0.5807, 0.1749]}, {"w": "of", "b": [0.5855, 0.1534, 0.6023, 0.1749]}, {"w": "Bob", "b": [0.6071, 0.1534, 0.641, 0.1749]}, {"w": "or", "b": [0.6458, 0.1534, 0.6641, 0.1749]}, {"w": "Charlie,", "b": [0.669, 0.1534, 0.7353, 0.1749]}, {"w": "you", "b": [0.7401, 0.1534, 0.7713, 0.1749]}, {"w": "may", "b": [0.7762, 0.1534, 0.8116, 0.1749]}, {"w": "want", "b": [0.8164, 0.1534, 0.8571, 0.1749]}, {"w": "to", "b": [0.1429, 0.1725, 0.1598, 0.1939]}, {"w": "give", "b": [0.1652, 0.1725, 0.1991, 0.1939]}, {"w": "more", "b": [0.2045, 0.1725, 0.2487, 0.1939]}, {"w": "weight", "b": [0.2541, 0.1725, 0.3097, 0.1939]}, {"w": "to", "b": [0.3151, 0.1725, 0.3321, 0.1939]}, {"w": "the", "b": [0.3375, 0.1725, 0.3638, 0.1939]}, {"w": "classifier’s", "b": [0.3692, 0.1725, 0.4519, 0.1939]}, {"w": "score", "b": [0.4573, 0.1725, 0.501, 0.1939]}, {"w": "on", "b": [0.5064, 0.1725, 0.5284, 0.1939]}, {"w": "pictures", "b": [0.5338, 0.1725, 0.6008, 0.1939]}, {"w": "of", "b": [0.6062, 0.1725, 0.623, 0.1939]}, {"w": "Alice.", "b": [0.6284, 0.1725, 0.6761, 0.1939]}, {"w": "One", "b": [0.6815, 0.1725, 0.7173, 0.1939]}, {"w": "simple", "b": [0.7227, 0.1725, 0.7776, 0.1939]}, {"w": "option", "b": [0.783, 0.1725, 0.8385, 0.1939]}, {"w": "is", "b": [0.8439, 0.1725, 0.8571, 0.1939]}, {"w": "to", "b": [0.1429, 0.1915, 0.1598, 0.2129]}, {"w": "give", "b": [0.1652, 0.1915, 0.1991, 0.2129]}, {"w": "each", "b": [0.2045, 0.1915, 0.2424, 0.2129]}, {"w": "label", "b": [0.2478, 0.1915, 0.2869, 0.2129]}, {"w": "a", "b": [0.2923, 0.1915, 0.3015, 0.2129]}, {"w": "weight", "b": [0.3069, 0.1915, 0.3624, 0.2129]}, {"w": "equal", "b": [0.3678, 0.1915, 0.4128, 0.2129]}, {"w": "to", "b": [0.4182, 0.1915, 0.4352, 0.2129]}, {"w": "its", "b": [0.4406, 0.1915, 0.4602, 0.2129]}, {"w": "support", "b": [0.4656, 0.1913, 0.5273, 0.2129]}, {"w": "(i.e.,", "b": [0.5327, 0.1915, 0.5686, 0.2129]}, {"w": "the", "b": [0.574, 0.1915, 0.6003, 0.2129]}, {"w": "number", "b": [0.6057, 0.1915, 0.672, 0.2129]}, {"w": "of", "b": [0.6774, 0.1915, 0.6942, 0.2129]}, {"w": "instances", "b": [0.6996, 0.1915, 0.7764, 0.2129]}, {"w": "with", "b": [0.7818, 0.1915, 0.8192, 0.2129]}, {"w": "that", "b": [0.8246, 0.1915, 0.8571, 0.2129]}, {"w": "target", "b": [0.1429, 0.2115, 0.191, 0.2329]}, {"w": "label).", "b": [0.1958, 0.2115, 0.2469, 0.2329]}, {"w": "To", "b": [0.2516, 0.2115, 0.273, 0.2329]}, {"w": "do", "b": [0.2778, 0.2115, 0.2994, 0.2329]}, {"w": "this,", "b": [0.3041, 0.2115, 0.3396, 0.2329]}, {"w": "simply", "b": [0.3443, 0.2115, 0.3999, 0.2329]}, {"w": "set", "b": [0.4047, 0.2115, 0.4275, 0.2329]}, {"w": "average=\"weighted\"", "b": [0.4323, 0.2147, 0.6104, 0.2297]}, {"w": "in", "b": [0.6151, 0.2115, 0.6321, 0.2329]}, {"w": "the", "b": [0.6368, 0.2115, 0.6631, 0.2329]}, {"w": "preceding", "b": [0.6679, 0.2115, 0.7508, 0.2329]}, {"w": "code.4", "b": [0.7555, 0.2115, 0.8053, 0.2329]}]}, {"id": "b_3", "type": "paragraph", "text": "Multioutput Classification", "words": [{"w": "Multioutput", "b": [0.1429, 0.2459, 0.2935, 0.2801]}, {"w": "Classification", "b": [0.2994, 0.2459, 0.4613, 0.2801]}]}, {"id": "b_4", "type": "paragraph", "text": "The last type of classification task we are going to discuss here is called multioutput- multiclass classification (or simply multioutput classification). It is simply a generaliza‐ tion of multilabel classification where each label can be multiclass (i.e., it can have more than two possible values).", "words": [{"w": "The", "b": [0.1429, 0.2871, 0.1757, 0.3085]}, {"w": "last", "b": [0.1817, 0.2871, 0.2102, 0.3085]}, {"w": "type", "b": [0.2162, 0.2871, 0.2519, 0.3085]}, {"w": "of", "b": [0.2579, 0.2871, 0.2747, 0.3085]}, {"w": "classification", "b": [0.2808, 0.2871, 0.3881, 0.3085]}, {"w": "task", "b": [0.3942, 0.2871, 0.4277, 0.3085]}, {"w": "we", "b": [0.4337, 0.2871, 0.4568, 0.3085]}, {"w": "are", "b": [0.4629, 0.2871, 0.4886, 0.3085]}, {"w": "going", "b": [0.4946, 0.2871, 0.5417, 0.3085]}, {"w": "to", "b": [0.5478, 0.2871, 0.5648, 0.3085]}, {"w": "discuss", "b": [0.5708, 0.2871, 0.6302, 0.3085]}, {"w": "here", "b": [0.6362, 0.2871, 0.6728, 0.3085]}, {"w": "is", "b": [0.6789, 0.2871, 0.6921, 0.3085]}, {"w": "called", "b": [0.6981, 0.2871, 0.7465, 0.3085]}, {"w": "multioutput-", "b": [0.7525, 0.2869, 0.8571, 0.3085]}, {"w": "multiclass", "b": [0.1429, 0.3059, 0.2235, 0.3275]}, {"w": "classification", "b": [0.2285, 0.3059, 0.3337, 0.3275]}, {"w": "(or", "b": [0.3387, 0.3061, 0.3643, 0.3275]}, {"w": "simply", "b": [0.369, 0.3061, 0.4246, 0.3275]}, {"w": "multioutput", "b": [0.4299, 0.3059, 0.5275, 0.3275]}, {"w": "classification).", "b": [0.5325, 0.3059, 0.6497, 0.3275]}, {"w": "It", "b": [0.6547, 0.3061, 0.6674, 0.3275]}, {"w": "is", "b": [0.6723, 0.3061, 0.6856, 0.3275]}, {"w": "simply", "b": [0.6905, 0.3061, 0.7462, 0.3275]}, {"w": "a", "b": [0.7511, 0.3061, 0.7603, 0.3275]}, {"w": "generaliza‐", "b": [0.7652, 0.3061, 0.8571, 0.3275]}, {"w": "tion", "b": [0.1428, 0.3252, 0.1768, 0.3466]}, {"w": "of", "b": [0.1842, 0.3252, 0.201, 0.3466]}, {"w": "multilabel", "b": [0.2084, 0.3252, 0.2925, 0.3466]}, {"w": "classification", "b": [0.2999, 0.3252, 0.4073, 0.3466]}, {"w": "where", "b": [0.4147, 0.3252, 0.4655, 0.3466]}, {"w": "each", "b": [0.4729, 0.3252, 0.5109, 0.3466]}, {"w": "label", "b": [0.5183, 0.3252, 0.5574, 0.3466]}, {"w": "can", "b": [0.5648, 0.3252, 0.5942, 0.3466]}, {"w": "be", "b": [0.6016, 0.3252, 0.621, 0.3466]}, {"w": "multiclass", "b": [0.6284, 0.3252, 0.7119, 0.3466]}, {"w": "(i.e.,", "b": [0.7193, 0.3252, 0.7552, 0.3466]}, {"w": "it", "b": [0.7626, 0.3252, 0.7746, 0.3466]}, {"w": "can", "b": [0.782, 0.3252, 0.8113, 0.3466]}, {"w": "have", "b": [0.8187, 0.3252, 0.8571, 0.3466]}, {"w": "more", "b": [0.1429, 0.3442, 0.1871, 0.3656]}, {"w": "than", "b": [0.1919, 0.3442, 0.2299, 0.3656]}, {"w": "two", "b": [0.2346, 0.3442, 0.2659, 0.3656]}, {"w": "possible", "b": [0.2706, 0.3442, 0.3377, 0.3656]}, {"w": "values).", "b": [0.3424, 0.3442, 0.406, 0.3656]}]}, {"id": "b_5", "type": "paragraph", "text": "To illustrate this, let’s build a system that removes noise from images. It will take as input a noisy digit image, and it will (hopefully) output a clean digit image, repre‐ sented as an array of pixel intensities, just like the MNIST images. Notice that the classifier’s output is multilabel (one label per pixel) and each label can have multiple values (pixel intensity ranges from 0 to 255). It is thus an example of a multioutput classification system.", "words": [{"w": "To", "b": [0.1429, 0.3723, 0.1643, 0.3937]}, {"w": "illustrate", "b": [0.1709, 0.3723, 0.2437, 0.3937]}, {"w": "this,", "b": [0.2503, 0.3723, 0.2858, 0.3937]}, {"w": "let’s", "b": [0.2923, 0.3723, 0.3226, 0.3937]}, {"w": "build", "b": [0.3291, 0.3723, 0.3726, 0.3937]}, {"w": "a", "b": [0.3792, 0.3723, 0.3883, 0.3937]}, {"w": "system", "b": [0.3949, 0.3723, 0.452, 0.3937]}, {"w": "that", "b": [0.4586, 0.3723, 0.4912, 0.3937]}, {"w": "removes", "b": [0.4978, 0.3723, 0.5682, 0.3937]}, {"w": "noise", "b": [0.5747, 0.3723, 0.6188, 0.3937]}, {"w": "from", "b": [0.6254, 0.3723, 0.667, 0.3937]}, {"w": "images.", "b": [0.6736, 0.3723, 0.7364, 0.3937]}, {"w": "It", "b": [0.7429, 0.3723, 0.7556, 0.3937]}, {"w": "will", "b": [0.7621, 0.3723, 0.7925, 0.3937]}, {"w": "take", "b": [0.7991, 0.3723, 0.8338, 0.3937]}, {"w": "as", "b": [0.8404, 0.3723, 0.8571, 0.3937]}, {"w": "input", "b": [0.1429, 0.3914, 0.1878, 0.4128]}, {"w": "a", "b": [0.195, 0.3914, 0.2041, 0.4128]}, {"w": "noisy", "b": [0.2113, 0.3914, 0.2562, 0.4128]}, {"w": "digit", "b": [0.2634, 0.3914, 0.3016, 0.4128]}, {"w": "image,", "b": [0.3088, 0.3914, 0.364, 0.4128]}, {"w": "and", "b": [0.3712, 0.3914, 0.4027, 0.4128]}, {"w": "it", "b": [0.4099, 0.3914, 0.4219, 0.4128]}, {"w": "will", "b": [0.4291, 0.3914, 0.4595, 0.4128]}, {"w": "(hopefully)", "b": [0.4667, 0.3914, 0.56, 0.4128]}, {"w": "output", "b": [0.5672, 0.3914, 0.6236, 0.4128]}, {"w": "a", "b": [0.6308, 0.3914, 0.6399, 0.4128]}, {"w": "clean", "b": [0.6471, 0.3914, 0.6906, 0.4128]}, {"w": "digit", "b": [0.6978, 0.3914, 0.7361, 0.4128]}, {"w": "image,", "b": [0.7433, 0.3914, 0.7984, 0.4128]}, {"w": "repre‐", "b": [0.8056, 0.3914, 0.8571, 0.4128]}, {"w": "sented", "b": [0.1429, 0.4104, 0.1966, 0.4318]}, {"w": "as", "b": [0.2041, 0.4104, 0.2209, 0.4318]}, {"w": "an", "b": [0.2285, 0.4104, 0.249, 0.4318]}, {"w": "array", "b": [0.2566, 0.4104, 0.2995, 0.4318]}, {"w": "of", "b": [0.3071, 0.4104, 0.3239, 0.4318]}, {"w": "pixel", "b": [0.3314, 0.4104, 0.3719, 0.4318]}, {"w": "intensities,", "b": [0.3795, 0.4104, 0.4691, 0.4318]}, {"w": "just", "b": [0.4766, 0.4104, 0.507, 0.4318]}, {"w": "like", "b": [0.5146, 0.4104, 0.5446, 0.4318]}, {"w": "the", "b": [0.5522, 0.4104, 0.5785, 0.4318]}, {"w": "MNIST", "b": [0.5861, 0.4104, 0.65, 0.4318]}, {"w": "images.", "b": [0.6575, 0.4104, 0.7203, 0.4318]}, {"w": "Notice", "b": [0.7279, 0.4104, 0.7831, 0.4318]}, {"w": "that", "b": [0.7907, 0.4104, 0.8232, 0.4318]}, {"w": "the", "b": [0.8308, 0.4104, 0.8571, 0.4318]}, {"w": "classifier’s", "b": [0.1428, 0.4295, 0.2256, 0.4509]}, {"w": "output", "b": [0.2317, 0.4295, 0.2881, 0.4509]}, {"w": "is", "b": [0.2941, 0.4295, 0.3074, 0.4509]}, {"w": "multilabel", "b": [0.3135, 0.4295, 0.3975, 0.4509]}, {"w": "(one", "b": [0.4036, 0.4295, 0.4417, 0.4509]}, {"w": "label", "b": [0.4478, 0.4295, 0.4869, 0.4509]}, {"w": "per", "b": [0.493, 0.4295, 0.5205, 0.4509]}, {"w": "pixel)", "b": [0.5266, 0.4295, 0.5743, 0.4509]}, {"w": "and", "b": [0.5804, 0.4295, 0.6119, 0.4509]}, {"w": "each", "b": [0.618, 0.4295, 0.6559, 0.4509]}, {"w": "label", "b": [0.662, 0.4295, 0.7011, 0.4509]}, {"w": "can", "b": [0.7072, 0.4295, 0.7366, 0.4509]}, {"w": "have", "b": [0.7427, 0.4295, 0.7811, 0.4509]}, {"w": "multiple", "b": [0.7872, 0.4295, 0.8571, 0.4509]}, {"w": "values", "b": [0.1429, 0.4485, 0.1945, 0.4699]}, {"w": "(pixel", "b": [0.2011, 0.4485, 0.2487, 0.4699]}, {"w": "intensity", "b": [0.2553, 0.4485, 0.3276, 0.4699]}, {"w": "ranges", "b": [0.3342, 0.4485, 0.3887, 0.4699]}, {"w": "from", "b": [0.3953, 0.4485, 0.4369, 0.4699]}, {"w": "0", "b": [0.4435, 0.4485, 0.4535, 0.4699]}, {"w": "to", "b": [0.46, 0.4485, 0.477, 0.4699]}, {"w": "255).", "b": [0.4836, 0.4485, 0.5256, 0.4699]}, {"w": "It", "b": [0.5321, 0.4485, 0.5448, 0.4699]}, {"w": "is", "b": [0.5513, 0.4485, 0.5646, 0.4699]}, {"w": "thus", "b": [0.5711, 0.4485, 0.6069, 0.4699]}, {"w": "an", "b": [0.6135, 0.4485, 0.6341, 0.4699]}, {"w": "example", "b": [0.6406, 0.4485, 0.7102, 0.4699]}, {"w": "of", "b": [0.7167, 0.4485, 0.7335, 0.4699]}, {"w": "a", "b": [0.7401, 0.4485, 0.7493, 0.4699]}, {"w": "multioutput", "b": [0.7558, 0.4485, 0.8571, 0.4699]}, {"w": "classification", "b": [0.1429, 0.4676, 0.2502, 0.489]}, {"w": "system.", "b": [0.255, 0.4676, 0.3168, 0.489]}]}, {"id": "b_6", "type": "paragraph", "text": "The line between classification and regression is sometimes blurry, such as in this example. Arguably, predicting pixel intensity is more akin to regression than to classification. Moreover, multioutput systems are not limited to classification tasks; you could even have a system that outputs multiple labels per instance, including both class labels and value labels.", "words": [{"w": "The", "b": [0.2714, 0.5095, 0.3014, 0.5291]}, {"w": "line", "b": [0.3067, 0.5095, 0.3351, 0.5291]}, {"w": "between", "b": [0.3404, 0.5095, 0.4036, 0.5291]}, {"w": "classification", "b": [0.4089, 0.5095, 0.507, 0.5291]}, {"w": "and", "b": [0.5123, 0.5095, 0.5411, 0.5291]}, {"w": "regression", "b": [0.5464, 0.5095, 0.6249, 0.5291]}, {"w": "is", "b": [0.6301, 0.5095, 0.6422, 0.5291]}, {"w": "sometimes", "b": [0.6475, 0.5095, 0.7295, 0.5291]}, {"w": "blurry,", "b": [0.7347, 0.5095, 0.7857, 0.5291]}, {"w": "such", "b": [0.2714, 0.5269, 0.3067, 0.5465]}, {"w": "as", "b": [0.3111, 0.5269, 0.3265, 0.5465]}, {"w": "in", "b": [0.3309, 0.5269, 0.3464, 0.5465]}, {"w": "this", "b": [0.3508, 0.5269, 0.3789, 0.5465]}, {"w": "example.", "b": [0.3833, 0.5269, 0.4512, 0.5465]}, {"w": "Arguably,", "b": [0.4556, 0.5269, 0.5294, 0.5465]}, {"w": "predicting", "b": [0.5338, 0.5269, 0.6124, 0.5465]}, {"w": "pixel", "b": [0.6168, 0.5269, 0.6538, 0.5465]}, {"w": "intensity", "b": [0.6582, 0.5269, 0.7243, 0.5465]}, {"w": "is", "b": [0.7287, 0.5269, 0.7408, 0.5465]}, {"w": "more", "b": [0.7452, 0.5269, 0.7857, 0.5465]}, {"w": "akin", "b": [0.2714, 0.5443, 0.3047, 0.5639]}, {"w": "to", "b": [0.3138, 0.5443, 0.3293, 0.5639]}, {"w": "regression", "b": [0.3384, 0.5443, 0.4168, 0.5639]}, {"w": "than", "b": [0.4259, 0.5443, 0.4606, 0.5639]}, {"w": "to", "b": [0.4697, 0.5443, 0.4852, 0.5639]}, {"w": "classification.", "b": [0.4943, 0.5443, 0.5968, 0.5639]}, {"w": "Moreover,", "b": [0.6058, 0.5443, 0.684, 0.5639]}, {"w": "multioutput", "b": [0.6931, 0.5443, 0.7857, 0.5639]}, {"w": "systems", "b": [0.2714, 0.5618, 0.3306, 0.5813]}, {"w": "are", "b": [0.336, 0.5618, 0.3595, 0.5813]}, {"w": "not", "b": [0.3649, 0.5618, 0.3908, 0.5813]}, {"w": "limited", "b": [0.3962, 0.5618, 0.4507, 0.5813]}, {"w": "to", "b": [0.4561, 0.5618, 0.4716, 0.5813]}, {"w": "classification", "b": [0.477, 0.5618, 0.5751, 0.5813]}, {"w": "tasks;", "b": [0.5805, 0.5618, 0.6224, 0.5813]}, {"w": "you", "b": [0.6278, 0.5618, 0.6564, 0.5813]}, {"w": "could", "b": [0.6617, 0.5618, 0.7045, 0.5813]}, {"w": "even", "b": [0.7098, 0.5618, 0.7453, 0.5813]}, {"w": "have", "b": [0.7506, 0.5618, 0.7857, 0.5813]}, {"w": "a", "b": [0.2714, 0.5792, 0.2798, 0.5987]}, {"w": "system", "b": [0.2862, 0.5792, 0.3384, 0.5987]}, {"w": "that", "b": [0.3448, 0.5792, 0.3746, 0.5987]}, {"w": "outputs", "b": [0.381, 0.5792, 0.4395, 0.5987]}, {"w": "multiple", "b": [0.4459, 0.5792, 0.5099, 0.5987]}, {"w": "labels", "b": [0.5163, 0.5792, 0.559, 0.5987]}, {"w": "per", "b": [0.5654, 0.5792, 0.5906, 0.5987]}, {"w": "instance,", "b": [0.597, 0.5792, 0.6646, 0.5987]}, {"w": "including", "b": [0.6709, 0.5792, 0.744, 0.5987]}, {"w": "both", "b": [0.7503, 0.5792, 0.7857, 0.5987]}, {"w": "class", "b": [0.2714, 0.5966, 0.3066, 0.6162]}, {"w": "labels", "b": [0.311, 0.5966, 0.3537, 0.6162]}, {"w": "and", "b": [0.358, 0.5966, 0.3869, 0.6162]}, {"w": "value", "b": [0.3912, 0.5966, 0.4314, 0.6162]}, {"w": "labels.", "b": [0.4357, 0.5966, 0.4828, 0.6162]}]}, {"id": "b_7", "type": "paragraph", "text": "Let’s start by creating the training and test sets by taking the MNIST images and adding noise to their pixel intensities using NumPy’s randint() function. The target images will be the original images:", "words": [{"w": "Let’s", "b": [0.1429, 0.6365, 0.179, 0.6579]}, {"w": "start", "b": [0.1873, 0.6365, 0.2246, 0.6579]}, {"w": "by", "b": [0.2329, 0.6365, 0.253, 0.6579]}, {"w": "creating", "b": [0.2614, 0.6365, 0.3286, 0.6579]}, {"w": "the", "b": [0.3369, 0.6365, 0.3632, 0.6579]}, {"w": "training", "b": [0.3716, 0.6365, 0.4385, 0.6579]}, {"w": "and", "b": [0.4468, 0.6365, 0.4784, 0.6579]}, {"w": "test", "b": [0.4867, 0.6365, 0.5159, 0.6579]}, {"w": "sets", "b": [0.5242, 0.6365, 0.5547, 0.6579]}, {"w": "by", "b": [0.563, 0.6365, 0.5832, 0.6579]}, {"w": "taking", "b": [0.5915, 0.6365, 0.6441, 0.6579]}, {"w": "the", "b": [0.6524, 0.6365, 0.6787, 0.6579]}, {"w": "MNIST", "b": [0.687, 0.6365, 0.7509, 0.6579]}, {"w": "images", "b": [0.7592, 0.6365, 0.8173, 0.6579]}, {"w": "and", "b": [0.8256, 0.6365, 0.8571, 0.6579]}, {"w": "adding", "b": [0.1429, 0.6564, 0.2007, 0.6778]}, {"w": "noise", "b": [0.2066, 0.6564, 0.2507, 0.6778]}, {"w": "to", "b": [0.2565, 0.6564, 0.2735, 0.6778]}, {"w": "their", "b": [0.2793, 0.6564, 0.319, 0.6778]}, {"w": "pixel", "b": [0.3248, 0.6564, 0.3653, 0.6778]}, {"w": "intensities", "b": [0.3711, 0.6564, 0.456, 0.6778]}, {"w": "using", "b": [0.4618, 0.6564, 0.5072, 0.6778]}, {"w": "NumPy’s", "b": [0.5131, 0.6564, 0.5876, 0.6778]}, {"w": "randint()", "b": [0.5934, 0.6596, 0.6825, 0.6747]}, {"w": "function.", "b": [0.6883, 0.6564, 0.7644, 0.6778]}, {"w": "The", "b": [0.7703, 0.6564, 0.8031, 0.6778]}, {"w": "target", "b": [0.809, 0.6564, 0.8571, 0.6778]}, {"w": "images", "b": [0.1428, 0.6754, 0.2009, 0.6969]}, {"w": "will", "b": [0.2056, 0.6754, 0.236, 0.6969]}, {"w": "be", "b": [0.2407, 0.6754, 0.2602, 0.6969]}, {"w": "the", "b": [0.2649, 0.6754, 0.2912, 0.6969]}, {"w": "original", "b": [0.296, 0.6754, 0.3611, 0.6969]}, {"w": "images:", "b": [0.3658, 0.6754, 0.4286, 0.6969]}]}, {"id": "b_8", "type": "paragraph", "text": "noise = np.random.randint(0, 100, (len(X_train), 784)) X_train_mod = X_train + noise noise = np.random.randint(0, 100, (len(X_test), 784)) X_test_mod = X_test + noise y_train_mod = X_train y_test_mod = X_test", "words": [{"w": "noise", "b": [0.1766, 0.7074, 0.2187, 0.7203]}, {"w": "=", "b": [0.2272, 0.7074, 0.2356, 0.7203]}, {"w": "np.random.randint(0,", "b": [0.244, 0.7074, 0.4127, 0.7203]}, {"w": "100,", "b": [0.4211, 0.7074, 0.4549, 0.7203]}, {"w": "(len(X_train),", "b": [0.4633, 0.7074, 0.5813, 0.7203]}, {"w": "784))", "b": [0.5898, 0.7074, 0.6319, 0.7203]}, {"w": "X_train_mod", "b": [0.1766, 0.7228, 0.2693, 0.7357]}, {"w": "=", "b": [0.2778, 0.7228, 0.2862, 0.7357]}, {"w": "X_train", "b": [0.2946, 0.7228, 0.3537, 0.7357]}, {"w": "+", "b": [0.3621, 0.7228, 0.3705, 0.7357]}, {"w": "noise", "b": [0.379, 0.7228, 0.4211, 0.7357]}, {"w": "noise", "b": [0.1766, 0.7383, 0.2187, 0.7511]}, {"w": "=", "b": [0.2272, 0.7383, 0.2356, 0.7511]}, {"w": "np.random.randint(0,", "b": [0.244, 0.7383, 0.4127, 0.7511]}, {"w": "100,", "b": [0.4211, 0.7383, 0.4549, 0.7511]}, {"w": "(len(X_test),", "b": [0.4633, 0.7383, 0.5729, 0.7511]}, {"w": "784))", "b": [0.5813, 0.7383, 0.6235, 0.7511]}, {"w": "X_test_mod", "b": [0.1766, 0.7537, 0.2609, 0.7665]}, {"w": "=", "b": [0.2693, 0.7537, 0.2778, 0.7665]}, {"w": "X_test", "b": [0.2862, 0.7537, 0.3368, 0.7665]}, {"w": "+", "b": [0.3452, 0.7537, 0.3537, 0.7665]}, {"w": "noise", "b": [0.3621, 0.7537, 0.4043, 0.7665]}, {"w": "y_train_mod", "b": [0.1766, 0.7691, 0.2693, 0.7819]}, {"w": "=", "b": [0.2778, 0.7691, 0.2862, 0.7819]}, {"w": "X_train", "b": [0.2946, 0.7691, 0.3537, 0.7819]}, {"w": "y_test_mod", "b": [0.1766, 0.7845, 0.2609, 0.7974]}, {"w": "=", "b": [0.2693, 0.7845, 0.2778, 0.7974]}, {"w": "X_test", "b": [0.2862, 0.7845, 0.3368, 0.7974]}]}, {"id": "b_9", "type": "paragraph", "text": "Multioutput Classification | 109", "words": [{"w": "Multioutput", "b": [0.6443, 0.9225, 0.716, 0.9388]}, {"w": "Classification", "b": [0.7188, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "109", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 136, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "5 You can use the shift() function from the scipy.ndimage.interpolation module. For example, shift(image, [2, 1], cval=0) shifts the image 2 pixels down and 1 pixel to the right.", "words": [{"w": "5", "b": [0.1451, 0.8602, 0.1518, 0.8745]}, {"w": "You", "b": [0.1587, 0.8587, 0.1834, 0.8751]}, {"w": "can", "b": [0.187, 0.8587, 0.2093, 0.8751]}, {"w": "use", "b": [0.213, 0.8587, 0.234, 0.8751]}, {"w": "the", "b": [0.2376, 0.8587, 0.2576, 0.8751]}, {"w": "shift()", "b": [0.2612, 0.8612, 0.314, 0.8727]}, {"w": "function", "b": [0.3176, 0.8587, 0.372, 0.8751]}, {"w": "from", "b": [0.3756, 0.8587, 0.4073, 0.8751]}, {"w": "the", "b": [0.4109, 0.8587, 0.431, 0.8751]}, {"w": "scipy.ndimage.interpolation", "b": [0.4346, 0.8612, 0.6381, 0.8727]}, {"w": "module.", "b": [0.6417, 0.8587, 0.694, 0.8751]}, {"w": "For", "b": [0.6976, 0.8587, 0.7197, 0.8751]}, {"w": "example,", "b": [0.7233, 0.8587, 0.7799, 0.8751]}, {"w": "shift(image,", "b": [0.1587, 0.8773, 0.2492, 0.8888]}, {"w": "[2,", "b": [0.2567, 0.8773, 0.2794, 0.8888]}, {"w": "1],", "b": [0.2869, 0.8773, 0.3095, 0.8888]}, {"w": "cval=0)", "b": [0.3171, 0.8773, 0.3698, 0.8888]}, {"w": "shifts", "b": [0.3734, 0.8749, 0.4074, 0.8912]}, {"w": "the", "b": [0.411, 0.8749, 0.431, 0.8912]}, {"w": "image", "b": [0.4346, 0.8749, 0.473, 0.8912]}, {"w": "2", "b": [0.4766, 0.8749, 0.4842, 0.8912]}, {"w": "pixels", "b": [0.4879, 0.8749, 0.5245, 0.8912]}, {"w": "down", "b": [0.5281, 0.8749, 0.5641, 0.8912]}, {"w": "and", "b": [0.5677, 0.8749, 0.5918, 0.8912]}, {"w": "1", "b": [0.5954, 0.8749, 0.603, 0.8912]}, {"w": "pixel", "b": [0.6066, 0.8749, 0.6374, 0.8912]}, {"w": "to", "b": [0.641, 0.8749, 0.654, 0.8912]}, {"w": "the", "b": [0.6576, 0.8749, 0.6776, 0.8912]}, {"w": "right.", "b": [0.6812, 0.8749, 0.7154, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Let’s take a peek at an image from the test set (yes, we’re snooping on the test data, so you should be frowning right now):", "words": [{"w": "Let’s", "b": [0.1429, 0.0791, 0.179, 0.1005]}, {"w": "take", "b": [0.1843, 0.0791, 0.219, 0.1005]}, {"w": "a", "b": [0.2243, 0.0791, 0.2335, 0.1005]}, {"w": "peek", "b": [0.2388, 0.0791, 0.2777, 0.1005]}, {"w": "at", "b": [0.283, 0.0791, 0.2981, 0.1005]}, {"w": "an", "b": [0.3034, 0.0791, 0.324, 0.1005]}, {"w": "image", "b": [0.3293, 0.0791, 0.3797, 0.1005]}, {"w": "from", "b": [0.385, 0.0791, 0.4266, 0.1005]}, {"w": "the", "b": [0.4319, 0.0791, 0.4582, 0.1005]}, {"w": "test", "b": [0.4635, 0.0791, 0.4927, 0.1005]}, {"w": "set", "b": [0.498, 0.0791, 0.5209, 0.1005]}, {"w": "(yes,", "b": [0.5262, 0.0791, 0.5642, 0.1005]}, {"w": "we’re", "b": [0.5695, 0.0791, 0.6115, 0.1005]}, {"w": "snooping", "b": [0.6169, 0.0791, 0.6948, 0.1005]}, {"w": "on", "b": [0.7001, 0.0791, 0.7221, 0.1005]}, {"w": "the", "b": [0.7274, 0.0791, 0.7538, 0.1005]}, {"w": "test", "b": [0.7591, 0.0791, 0.7883, 0.1005]}, {"w": "data,", "b": [0.7936, 0.0791, 0.8336, 0.1005]}, {"w": "so", "b": [0.8389, 0.0791, 0.8571, 0.1005]}, {"w": "you", "b": [0.1429, 0.0981, 0.1741, 0.1195]}, {"w": "should", "b": [0.1788, 0.0981, 0.2356, 0.1195]}, {"w": "be", "b": [0.2403, 0.0981, 0.2597, 0.1195]}, {"w": "frowning", "b": [0.2645, 0.0981, 0.3414, 0.1195]}, {"w": "right", "b": [0.3461, 0.0981, 0.3862, 0.1195]}, {"w": "now):", "b": [0.391, 0.0981, 0.4392, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "On the left is the noisy input image, and on the right is the clean target image. Now let’s train the classifier and make it clean this image:", "words": [{"w": "On", "b": [0.1429, 0.2892, 0.1698, 0.3106]}, {"w": "the", "b": [0.1759, 0.2892, 0.2022, 0.3106]}, {"w": "left", "b": [0.2083, 0.2892, 0.235, 0.3106]}, {"w": "is", "b": [0.2411, 0.2892, 0.2543, 0.3106]}, {"w": "the", "b": [0.2604, 0.2892, 0.2867, 0.3106]}, {"w": "noisy", "b": [0.2928, 0.2892, 0.3376, 0.3106]}, {"w": "input", "b": [0.3437, 0.2892, 0.3887, 0.3106]}, {"w": "image,", "b": [0.3948, 0.2892, 0.4499, 0.3106]}, {"w": "and", "b": [0.456, 0.2892, 0.4875, 0.3106]}, {"w": "on", "b": [0.4936, 0.2892, 0.5157, 0.3106]}, {"w": "the", "b": [0.5218, 0.2892, 0.5481, 0.3106]}, {"w": "right", "b": [0.5542, 0.2892, 0.5943, 0.3106]}, {"w": "is", "b": [0.6004, 0.2892, 0.6137, 0.3106]}, {"w": "the", "b": [0.6198, 0.2892, 0.6461, 0.3106]}, {"w": "clean", "b": [0.6522, 0.2892, 0.6957, 0.3106]}, {"w": "target", "b": [0.7018, 0.2892, 0.7499, 0.3106]}, {"w": "image.", "b": [0.756, 0.2892, 0.8112, 0.3106]}, {"w": "Now", "b": [0.8173, 0.2892, 0.8571, 0.3106]}, {"w": "let’s", "b": [0.1429, 0.3082, 0.1731, 0.3296]}, {"w": "train", "b": [0.1778, 0.3082, 0.218, 0.3296]}, {"w": "the", "b": [0.2228, 0.3082, 0.2491, 0.3296]}, {"w": "classifier", "b": [0.2538, 0.3082, 0.3263, 0.3296]}, {"w": "and", "b": [0.331, 0.3082, 0.3625, 0.3296]}, {"w": "make", "b": [0.3673, 0.3082, 0.4127, 0.3296]}, {"w": "it", "b": [0.4174, 0.3082, 0.4293, 0.3296]}, {"w": "clean", "b": [0.4341, 0.3082, 0.4775, 0.3296]}, {"w": "this", "b": [0.4823, 0.3082, 0.513, 0.3296]}, {"w": "image:", "b": [0.5177, 0.3082, 0.5728, 0.3296]}]}, {"id": "b_3", "type": "paragraph", "text": "knn_clf.fit(X_train_mod, y_train_mod) clean_digit = knn_clf.predict([X_test_mod[some_index]]) plot_digit(clean_digit)", "words": [{"w": "knn_clf.fit(X_train_mod,", "b": [0.1766, 0.3402, 0.379, 0.353]}, {"w": "y_train_mod)", "b": [0.3874, 0.3402, 0.4886, 0.353]}, {"w": "clean_digit", "b": [0.1766, 0.3556, 0.2693, 0.3685]}, {"w": "=", "b": [0.2778, 0.3556, 0.2862, 0.3685]}, {"w": "knn_clf.predict([X_test_mod[some_index]])", "b": [0.2946, 0.3556, 0.6404, 0.3685]}, {"w": "plot_digit(clean_digit)", "b": [0.1766, 0.371, 0.3705, 0.3839]}]}, {"id": "b_4", "type": "paragraph", "text": "Looks close enough to the target! This concludes our tour of classification. Hopefully you should now know how to select good metrics for classification tasks, pick the appropriate precision/recall tradeoff, compare classifiers, and more generally build good classification systems for a variety of tasks.", "words": [{"w": "Looks", "b": [0.1429, 0.5468, 0.1933, 0.5682]}, {"w": "close", "b": [0.1987, 0.5468, 0.2399, 0.5682]}, {"w": "enough", "b": [0.2453, 0.5468, 0.3081, 0.5682]}, {"w": "to", "b": [0.3135, 0.5468, 0.3305, 0.5682]}, {"w": "the", "b": [0.3358, 0.5468, 0.3622, 0.5682]}, {"w": "target!", "b": [0.3676, 0.5468, 0.4215, 0.5682]}, {"w": "This", "b": [0.4269, 0.5468, 0.4641, 0.5682]}, {"w": "concludes", "b": [0.4695, 0.5468, 0.553, 0.5682]}, {"w": "our", "b": [0.5583, 0.5468, 0.5878, 0.5682]}, {"w": "tour", "b": [0.5931, 0.5468, 0.6289, 0.5682]}, {"w": "of", "b": [0.6343, 0.5468, 0.6511, 0.5682]}, {"w": "classification.", "b": [0.6565, 0.5468, 0.7686, 0.5682]}, {"w": "Hopefully", "b": [0.774, 0.5468, 0.8571, 0.5682]}, {"w": "you", "b": [0.1429, 0.5658, 0.1741, 0.5872]}, {"w": "should", "b": [0.1819, 0.5658, 0.2386, 0.5872]}, {"w": "now", "b": [0.2463, 0.5658, 0.2826, 0.5872]}, {"w": "know", "b": [0.2904, 0.5658, 0.337, 0.5872]}, {"w": "how", "b": [0.3448, 0.5658, 0.3808, 0.5872]}, {"w": "to", "b": [0.3885, 0.5658, 0.4055, 0.5872]}, {"w": "select", "b": [0.4133, 0.5658, 0.4591, 0.5872]}, {"w": "good", "b": [0.4668, 0.5658, 0.5088, 0.5872]}, {"w": "metrics", "b": [0.5166, 0.5658, 0.5786, 0.5872]}, {"w": "for", "b": [0.5864, 0.5658, 0.6109, 0.5872]}, {"w": "classification", "b": [0.6187, 0.5658, 0.726, 0.5872]}, {"w": "tasks,", "b": [0.7338, 0.5658, 0.7797, 0.5872]}, {"w": "pick", "b": [0.7874, 0.5658, 0.8231, 0.5872]}, {"w": "the", "b": [0.8308, 0.5658, 0.8571, 0.5872]}, {"w": "appropriate", "b": [0.1429, 0.5849, 0.24, 0.6063]}, {"w": "precision/recall", "b": [0.248, 0.5849, 0.3772, 0.6063]}, {"w": "tradeoff,", "b": [0.3852, 0.5849, 0.456, 0.6063]}, {"w": "compare", "b": [0.4641, 0.5849, 0.5368, 0.6063]}, {"w": "classifiers,", "b": [0.5449, 0.5849, 0.6297, 0.6063]}, {"w": "and", "b": [0.6378, 0.5849, 0.6693, 0.6063]}, {"w": "more", "b": [0.6774, 0.5849, 0.7217, 0.6063]}, {"w": "generally", "b": [0.7297, 0.5849, 0.8056, 0.6063]}, {"w": "build", "b": [0.8136, 0.5849, 0.8571, 0.6063]}, {"w": "good", "b": [0.1429, 0.6039, 0.1849, 0.6253]}, {"w": "classification", "b": [0.1896, 0.6039, 0.297, 0.6253]}, {"w": "systems", "b": [0.3017, 0.6039, 0.3665, 0.6253]}, {"w": "for", "b": [0.3712, 0.6039, 0.3957, 0.6253]}, {"w": "a", "b": [0.4005, 0.6039, 0.4096, 0.6253]}, {"w": "variety", "b": [0.4143, 0.6039, 0.4712, 0.6253]}, {"w": "of", "b": [0.4759, 0.6039, 0.4927, 0.6253]}, {"w": "tasks.", "b": [0.4975, 0.6039, 0.5433, 0.6253]}]}, {"id": "b_5", "type": "paragraph", "text": "Exercises", "words": [{"w": "Exercises", "b": [0.1429, 0.6383, 0.2533, 0.6726]}]}, {"id": "b_6", "type": "paragraph", "text": "1. Try to build a classifier for the MNIST dataset that achieves over 97% accuracy on the test set. Hint: the KNeighborsClassifier works quite well for this task; you just need to find good hyperparameter values (try a grid search on the weights and n_neighbors hyperparameters).", "words": [{"w": "1.", "b": [0.1534, 0.6856, 0.1682, 0.707]}, {"w": "Try", "b": [0.1786, 0.6856, 0.2076, 0.707]}, {"w": "to", "b": [0.2143, 0.6856, 0.2312, 0.707]}, {"w": "build", "b": [0.2379, 0.6856, 0.2814, 0.707]}, {"w": "a", "b": [0.2881, 0.6856, 0.2972, 0.707]}, {"w": "classifier", "b": [0.3039, 0.6856, 0.3763, 0.707]}, {"w": "for", "b": [0.383, 0.6856, 0.4075, 0.707]}, {"w": "the", "b": [0.4142, 0.6856, 0.4405, 0.707]}, {"w": "MNIST", "b": [0.4472, 0.6856, 0.5111, 0.707]}, {"w": "dataset", "b": [0.5177, 0.6856, 0.5758, 0.707]}, {"w": "that", "b": [0.5825, 0.6856, 0.6151, 0.707]}, {"w": "achieves", "b": [0.6218, 0.6856, 0.6914, 0.707]}, {"w": "over", "b": [0.6981, 0.6856, 0.735, 0.707]}, {"w": "97%", "b": [0.7416, 0.6856, 0.7774, 0.707]}, {"w": "accuracy", "b": [0.7841, 0.6856, 0.8571, 0.707]}, {"w": "on", "b": [0.1786, 0.7055, 0.2006, 0.7269]}, {"w": "the", "b": [0.2077, 0.7055, 0.234, 0.7269]}, {"w": "test", "b": [0.2411, 0.7055, 0.2704, 0.7269]}, {"w": "set.", "b": [0.2775, 0.7055, 0.3051, 0.7269]}, {"w": "Hint:", "b": [0.3122, 0.7055, 0.3558, 0.7269]}, {"w": "the", "b": [0.3629, 0.7055, 0.3893, 0.7269]}, {"w": "KNeighborsClassifier", "b": [0.3964, 0.7087, 0.5943, 0.7238]}, {"w": "works", "b": [0.6014, 0.7055, 0.652, 0.7269]}, {"w": "quite", "b": [0.6591, 0.7055, 0.7016, 0.7269]}, {"w": "well", "b": [0.7087, 0.7055, 0.7424, 0.7269]}, {"w": "for", "b": [0.7495, 0.7055, 0.774, 0.7269]}, {"w": "this", "b": [0.7811, 0.7055, 0.8118, 0.7269]}, {"w": "task;", "b": [0.8189, 0.7055, 0.8571, 0.7269]}, {"w": "you", "b": [0.1786, 0.7245, 0.2098, 0.746]}, {"w": "just", "b": [0.2192, 0.7245, 0.2496, 0.746]}, {"w": "need", "b": [0.259, 0.7245, 0.2991, 0.746]}, {"w": "to", "b": [0.3085, 0.7245, 0.3255, 0.746]}, {"w": "find", "b": [0.3349, 0.7245, 0.369, 0.746]}, {"w": "good", "b": [0.3785, 0.7245, 0.4205, 0.746]}, {"w": "hyperparameter", "b": [0.4299, 0.7245, 0.5634, 0.746]}, {"w": "values", "b": [0.5728, 0.7245, 0.6244, 0.746]}, {"w": "(try", "b": [0.6338, 0.7245, 0.6652, 0.746]}, {"w": "a", "b": [0.6746, 0.7245, 0.6838, 0.746]}, {"w": "grid", "b": [0.6932, 0.7245, 0.7273, 0.746]}, {"w": "search", "b": [0.7367, 0.7245, 0.79, 0.746]}, {"w": "on", "b": [0.7994, 0.7245, 0.8214, 0.746]}, {"w": "the", "b": [0.8308, 0.7245, 0.8571, 0.746]}, {"w": "weights", "b": [0.1786, 0.7477, 0.2478, 0.7628]}, {"w": "and", "b": [0.2526, 0.7445, 0.2841, 0.7659]}, {"w": "n_neighbors", "b": [0.2888, 0.7477, 0.3977, 0.7628]}, {"w": "hyperparameters).", "b": [0.4024, 0.7445, 0.5555, 0.7659]}]}, {"id": "b_7", "type": "paragraph", "text": "2. Write a function that can shift an MNIST image in any direction (left, right, up, or down) by one pixel.5 Then, for each image in the training set, create four shif‐", "words": [{"w": "2.", "b": [0.1534, 0.7696, 0.1681, 0.791]}, {"w": "Write", "b": [0.1786, 0.7696, 0.2255, 0.791]}, {"w": "a", "b": [0.2316, 0.7696, 0.2408, 0.791]}, {"w": "function", "b": [0.2469, 0.7696, 0.3182, 0.791]}, {"w": "that", "b": [0.3243, 0.7696, 0.3569, 0.791]}, {"w": "can", "b": [0.363, 0.7696, 0.3924, 0.791]}, {"w": "shift", "b": [0.3985, 0.7696, 0.4353, 0.791]}, {"w": "an", "b": [0.4414, 0.7696, 0.462, 0.791]}, {"w": "MNIST", "b": [0.4681, 0.7696, 0.5319, 0.791]}, {"w": "image", "b": [0.538, 0.7696, 0.5884, 0.791]}, {"w": "in", "b": [0.5945, 0.7696, 0.6115, 0.791]}, {"w": "any", "b": [0.6176, 0.7696, 0.6472, 0.791]}, {"w": "direction", "b": [0.6533, 0.7696, 0.7292, 0.791]}, {"w": "(left,", "b": [0.7353, 0.7696, 0.7739, 0.791]}, {"w": "right,", "b": [0.78, 0.7696, 0.8249, 0.791]}, {"w": "up,", "b": [0.831, 0.7696, 0.8571, 0.791]}, {"w": "or", "b": [0.1786, 0.7886, 0.1969, 0.81]}, {"w": "down)", "b": [0.2023, 0.7886, 0.2568, 0.81]}, {"w": "by", "b": [0.2623, 0.7886, 0.2824, 0.81]}, {"w": "one", "b": [0.2878, 0.7886, 0.3187, 0.81]}, {"w": "pixel.5", "b": [0.3241, 0.7886, 0.375, 0.81]}, {"w": "Then,", "b": [0.3804, 0.7886, 0.4294, 0.81]}, {"w": "for", "b": [0.4348, 0.7886, 0.4594, 0.81]}, {"w": "each", "b": [0.4648, 0.7886, 0.5027, 0.81]}, {"w": "image", "b": [0.5081, 0.7886, 0.5585, 0.81]}, {"w": "in", "b": [0.5639, 0.7886, 0.5809, 0.81]}, {"w": "the", "b": [0.5863, 0.7886, 0.6127, 0.81]}, {"w": "training", "b": [0.6181, 0.7886, 0.685, 0.81]}, {"w": "set,", "b": [0.6904, 0.7886, 0.718, 0.81]}, {"w": "create", "b": [0.7234, 0.7886, 0.7728, 0.81]}, {"w": "four", "b": [0.7782, 0.7886, 0.8138, 0.81]}, {"w": "shif‐", "b": [0.8192, 0.7886, 0.8571, 0.81]}]}, {"id": "b_8", "type": "paragraph", "text": "110 | Chapter 3: Classification", "words": [{"w": "110", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "3:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Classification", "b": [0.2673, 0.9225, 0.3443, 0.9388]}]}]}, {"page": 137, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "ted copies (one per direction) and add them to the training set. Finally, train your best model on this expanded training set and measure its accuracy on the test set. You should observe that your model performs even better now! This technique of artificially growing the training set is called data augmentation or training set expansion.", "words": [{"w": "ted", "b": [0.1786, 0.0791, 0.2048, 0.1005]}, {"w": "copies", "b": [0.2096, 0.0791, 0.262, 0.1005]}, {"w": "(one", "b": [0.2669, 0.0791, 0.305, 0.1005]}, {"w": "per", "b": [0.3098, 0.0791, 0.3373, 0.1005]}, {"w": "direction)", "b": [0.3421, 0.0791, 0.4253, 0.1005]}, {"w": "and", "b": [0.4301, 0.0791, 0.4616, 0.1005]}, {"w": "add", "b": [0.4665, 0.0791, 0.4976, 0.1005]}, {"w": "them", "b": [0.5024, 0.0791, 0.5458, 0.1005]}, {"w": "to", "b": [0.5506, 0.0791, 0.5676, 0.1005]}, {"w": "the", "b": [0.5725, 0.0791, 0.5988, 0.1005]}, {"w": "training", "b": [0.6036, 0.0791, 0.6706, 0.1005]}, {"w": "set.", "b": [0.6754, 0.0791, 0.703, 0.1005]}, {"w": "Finally,", "b": [0.7078, 0.0791, 0.7683, 0.1005]}, {"w": "train", "b": [0.7731, 0.0791, 0.8133, 0.1005]}, {"w": "your", "b": [0.8182, 0.0791, 0.8571, 0.1005]}, {"w": "best", "b": [0.1786, 0.0981, 0.212, 0.1195]}, {"w": "model", "b": [0.2169, 0.0981, 0.2698, 0.1195]}, {"w": "on", "b": [0.2747, 0.0981, 0.2967, 0.1195]}, {"w": "this", "b": [0.3016, 0.0981, 0.3324, 0.1195]}, {"w": "expanded", "b": [0.3373, 0.0981, 0.4183, 0.1195]}, {"w": "training", "b": [0.4232, 0.0981, 0.4902, 0.1195]}, {"w": "set", "b": [0.4951, 0.0981, 0.5179, 0.1195]}, {"w": "and", "b": [0.5229, 0.0981, 0.5544, 0.1195]}, {"w": "measure", "b": [0.5594, 0.0981, 0.6297, 0.1195]}, {"w": "its", "b": [0.6346, 0.0981, 0.6542, 0.1195]}, {"w": "accuracy", "b": [0.6592, 0.0981, 0.7322, 0.1195]}, {"w": "on", "b": [0.7372, 0.0981, 0.7592, 0.1195]}, {"w": "the", "b": [0.7641, 0.0981, 0.7905, 0.1195]}, {"w": "test", "b": [0.7954, 0.0981, 0.8246, 0.1195]}, {"w": "set.", "b": [0.8295, 0.0981, 0.8571, 0.1195]}, {"w": "You", "b": [0.1786, 0.1172, 0.2109, 0.1386]}, {"w": "should", "b": [0.2157, 0.1172, 0.2724, 0.1386]}, {"w": "observe", "b": [0.2773, 0.1172, 0.3418, 0.1386]}, {"w": "that", "b": [0.3466, 0.1172, 0.3792, 0.1386]}, {"w": "your", "b": [0.384, 0.1172, 0.423, 0.1386]}, {"w": "model", "b": [0.4278, 0.1172, 0.4806, 0.1386]}, {"w": "performs", "b": [0.4854, 0.1172, 0.5621, 0.1386]}, {"w": "even", "b": [0.5669, 0.1172, 0.6057, 0.1386]}, {"w": "better", "b": [0.6105, 0.1172, 0.6592, 0.1386]}, {"w": "now!", "b": [0.664, 0.1172, 0.706, 0.1386]}, {"w": "This", "b": [0.7108, 0.1172, 0.748, 0.1386]}, {"w": "technique", "b": [0.7529, 0.1172, 0.8355, 0.1386]}, {"w": "of", "b": [0.8403, 0.1172, 0.8571, 0.1386]}, {"w": "artificially", "b": [0.1786, 0.1362, 0.2628, 0.1576]}, {"w": "growing", "b": [0.2712, 0.1362, 0.3403, 0.1576]}, {"w": "the", "b": [0.3488, 0.1362, 0.3751, 0.1576]}, {"w": "training", "b": [0.3836, 0.1362, 0.4505, 0.1576]}, {"w": "set", "b": [0.459, 0.1362, 0.4819, 0.1576]}, {"w": "is", "b": [0.4903, 0.1362, 0.5036, 0.1576]}, {"w": "called", "b": [0.512, 0.1362, 0.5604, 0.1576]}, {"w": "data", "b": [0.5688, 0.136, 0.6055, 0.1576]}, {"w": "augmentation", "b": [0.614, 0.136, 0.7273, 0.1576]}, {"w": "or", "b": [0.7357, 0.1362, 0.7541, 0.1576]}, {"w": "training", "b": [0.7625, 0.136, 0.827, 0.1576]}, {"w": "set", "b": [0.8355, 0.136, 0.8571, 0.1576]}, {"w": "expansion.", "b": [0.1786, 0.155, 0.2656, 0.1767]}]}, {"id": "b_1", "type": "paragraph", "text": "3. Tackle the Titanic dataset. A great place to start is on Kaggle.", "words": [{"w": "3.", "b": [0.1534, 0.1803, 0.1681, 0.2018]}, {"w": "Tackle", "b": [0.1786, 0.1803, 0.2319, 0.2018]}, {"w": "the", "b": [0.2366, 0.1803, 0.263, 0.2018]}, {"w": "Titanic", "b": [0.2677, 0.1801, 0.3249, 0.2018]}, {"w": "dataset.", "b": [0.3296, 0.1803, 0.3925, 0.2018]}, {"w": "A", "b": [0.3972, 0.1803, 0.4116, 0.2018]}, {"w": "great", "b": [0.4164, 0.1803, 0.4578, 0.2018]}, {"w": "place", "b": [0.4625, 0.1803, 0.5055, 0.2018]}, {"w": "to", "b": [0.5103, 0.1803, 0.5272, 0.2018]}, {"w": "start", "b": [0.532, 0.1803, 0.5692, 0.2018]}, {"w": "is", "b": [0.5739, 0.1803, 0.5871, 0.2018]}, {"w": "on", "b": [0.5919, 0.1803, 0.6139, 0.2018]}, {"w": "Kaggle.", "b": [0.6186, 0.1803, 0.6802, 0.2018]}]}, {"id": "b_2", "type": "paragraph", "text": "4. Build a spam classifier (a more challenging exercise):", "words": [{"w": "4.", "b": [0.1534, 0.2054, 0.1682, 0.2269]}, {"w": "Build", "b": [0.1786, 0.2054, 0.2237, 0.2269]}, {"w": "a", "b": [0.2285, 0.2054, 0.2376, 0.2269]}, {"w": "spam", "b": [0.2423, 0.2054, 0.2871, 0.2269]}, {"w": "classifier", "b": [0.2918, 0.2054, 0.3643, 0.2269]}, {"w": "(a", "b": [0.369, 0.2054, 0.3854, 0.2269]}, {"w": "more", "b": [0.3901, 0.2054, 0.4344, 0.2269]}, {"w": "challenging", "b": [0.4391, 0.2054, 0.5354, 0.2269]}, {"w": "exercise):", "b": [0.5402, 0.2054, 0.6183, 0.2269]}]}, {"id": "b_3", "type": "paragraph", "text": "• Download examples of spam and ham from Apache SpamAssassin’s public datasets.", "words": [{"w": "•", "b": [0.1799, 0.2366, 0.188, 0.258]}, {"w": "Download", "b": [0.1984, 0.2366, 0.2861, 0.258]}, {"w": "examples", "b": [0.295, 0.2366, 0.3722, 0.258]}, {"w": "of", "b": [0.3812, 0.2366, 0.3979, 0.258]}, {"w": "spam", "b": [0.4069, 0.2366, 0.4517, 0.258]}, {"w": "and", "b": [0.4606, 0.2366, 0.4922, 0.258]}, {"w": "ham", "b": [0.5011, 0.2366, 0.5384, 0.258]}, {"w": "from", "b": [0.5474, 0.2366, 0.589, 0.258]}, {"w": "Apache", "b": [0.5979, 0.2366, 0.6603, 0.258]}, {"w": "SpamAssassin’s", "b": [0.6693, 0.2366, 0.796, 0.258]}, {"w": "public", "b": [0.8049, 0.2366, 0.8571, 0.258]}, {"w": "datasets.", "b": [0.1984, 0.2556, 0.2689, 0.277]}]}, {"id": "b_4", "type": "paragraph", "text": "• Unzip the datasets and familiarize yourself with the data format.", "words": [{"w": "•", "b": [0.1799, 0.2807, 0.188, 0.3021]}, {"w": "Unzip", "b": [0.1984, 0.2807, 0.2495, 0.3021]}, {"w": "the", "b": [0.2542, 0.2807, 0.2806, 0.3021]}, {"w": "datasets", "b": [0.2853, 0.2807, 0.351, 0.3021]}, {"w": "and", "b": [0.3558, 0.2807, 0.3873, 0.3021]}, {"w": "familiarize", "b": [0.392, 0.2807, 0.4809, 0.3021]}, {"w": "yourself", "b": [0.4856, 0.2807, 0.5526, 0.3021]}, {"w": "with", "b": [0.5573, 0.2807, 0.5946, 0.3021]}, {"w": "the", "b": [0.5994, 0.2807, 0.6257, 0.3021]}, {"w": "data", "b": [0.6304, 0.2807, 0.6657, 0.3021]}, {"w": "format.", "b": [0.6704, 0.2807, 0.7318, 0.3021]}]}, {"id": "b_5", "type": "paragraph", "text": "• Split the datasets into a training set and a test set.", "words": [{"w": "•", "b": [0.1799, 0.3058, 0.188, 0.3272]}, {"w": "Split", "b": [0.1984, 0.3058, 0.2364, 0.3272]}, {"w": "the", "b": [0.2411, 0.3058, 0.2675, 0.3272]}, {"w": "datasets", "b": [0.2722, 0.3058, 0.338, 0.3272]}, {"w": "into", "b": [0.3427, 0.3058, 0.3763, 0.3272]}, {"w": "a", "b": [0.381, 0.3058, 0.3901, 0.3272]}, {"w": "training", "b": [0.3949, 0.3058, 0.4618, 0.3272]}, {"w": "set", "b": [0.4665, 0.3058, 0.4894, 0.3272]}, {"w": "and", "b": [0.4941, 0.3058, 0.5256, 0.3272]}, {"w": "a", "b": [0.5304, 0.3058, 0.5395, 0.3272]}, {"w": "test", "b": [0.5443, 0.3058, 0.5735, 0.3272]}, {"w": "set.", "b": [0.5782, 0.3058, 0.6058, 0.3272]}]}, {"id": "b_6", "type": "paragraph", "text": "• Write a data preparation pipeline to convert each email into a feature vector. Your preparation pipeline should transform an email into a (sparse) vector indicating the presence or absence of each possible word. For example, if all emails only ever contain four words, “Hello,” “how,” “are,” “you,” then the email “Hello you Hello Hello you” would be converted into a vector [1, 0, 0, 1] (meaning [“Hello” is present, “how” is absent, “are” is absent, “you” is present]), or [3, 0, 0, 2] if you prefer to count the number of occurrences of each word.", "words": [{"w": "•", "b": [0.1799, 0.3309, 0.188, 0.3523]}, {"w": "Write", "b": [0.1984, 0.3309, 0.2454, 0.3523]}, {"w": "a", "b": [0.2522, 0.3309, 0.2614, 0.3523]}, {"w": "data", "b": [0.2682, 0.3309, 0.3035, 0.3523]}, {"w": "preparation", "b": [0.3103, 0.3309, 0.4083, 0.3523]}, {"w": "pipeline", "b": [0.4152, 0.3309, 0.4826, 0.3523]}, {"w": "to", "b": [0.4894, 0.3309, 0.5064, 0.3523]}, {"w": "convert", "b": [0.5133, 0.3309, 0.5762, 0.3523]}, {"w": "each", "b": [0.5831, 0.3309, 0.621, 0.3523]}, {"w": "email", "b": [0.6279, 0.3309, 0.6738, 0.3523]}, {"w": "into", "b": [0.6806, 0.3309, 0.7142, 0.3523]}, {"w": "a", "b": [0.7211, 0.3309, 0.7302, 0.3523]}, {"w": "feature", "b": [0.7371, 0.3309, 0.7948, 0.3523]}, {"w": "vector.", "b": [0.8017, 0.3309, 0.8571, 0.3523]}, {"w": "Your", "b": [0.1984, 0.35, 0.2385, 0.3714]}, {"w": "preparation", "b": [0.247, 0.35, 0.345, 0.3714]}, {"w": "pipeline", "b": [0.3535, 0.35, 0.4209, 0.3714]}, {"w": "should", "b": [0.4294, 0.35, 0.4862, 0.3714]}, {"w": "transform", "b": [0.4947, 0.35, 0.5785, 0.3714]}, {"w": "an", "b": [0.587, 0.35, 0.6076, 0.3714]}, {"w": "email", "b": [0.6161, 0.35, 0.662, 0.3714]}, {"w": "into", "b": [0.6705, 0.35, 0.7041, 0.3714]}, {"w": "a", "b": [0.7126, 0.35, 0.7217, 0.3714]}, {"w": "(sparse)", "b": [0.7303, 0.35, 0.7966, 0.3714]}, {"w": "vector", "b": [0.8051, 0.35, 0.8572, 0.3714]}, {"w": "indicating", "b": [0.1984, 0.369, 0.2826, 0.3904]}, {"w": "the", "b": [0.2898, 0.369, 0.3162, 0.3904]}, {"w": "presence", "b": [0.3234, 0.369, 0.3964, 0.3904]}, {"w": "or", "b": [0.4037, 0.369, 0.422, 0.3904]}, {"w": "absence", "b": [0.4292, 0.369, 0.4945, 0.3904]}, {"w": "of", "b": [0.5017, 0.369, 0.5185, 0.3904]}, {"w": "each", "b": [0.5257, 0.369, 0.5637, 0.3904]}, {"w": "possible", "b": [0.5709, 0.369, 0.638, 0.3904]}, {"w": "word.", "b": [0.6452, 0.369, 0.6936, 0.3904]}, {"w": "For", "b": [0.7008, 0.369, 0.7298, 0.3904]}, {"w": "example,", "b": [0.737, 0.369, 0.8113, 0.3904]}, {"w": "if", "b": [0.8185, 0.369, 0.8303, 0.3904]}, {"w": "all", "b": [0.8375, 0.369, 0.8572, 0.3904]}, {"w": "emails", "b": [0.1984, 0.3881, 0.252, 0.4095]}, {"w": "only", "b": [0.257, 0.3881, 0.2938, 0.4095]}, {"w": "ever", "b": [0.2988, 0.3881, 0.3339, 0.4095]}, {"w": "contain", "b": [0.3388, 0.3881, 0.4018, 0.4095]}, {"w": "four", "b": [0.4067, 0.3881, 0.4423, 0.4095]}, {"w": "words,", "b": [0.4473, 0.3881, 0.5033, 0.4095]}, {"w": "“Hello,”", "b": [0.5083, 0.3881, 0.5717, 0.4095]}, {"w": "“how,”", "b": [0.5766, 0.3881, 0.6296, 0.4095]}, {"w": "“are,”", "b": [0.6346, 0.3881, 0.6775, 0.4095]}, {"w": "“you,”", "b": [0.6825, 0.3881, 0.7323, 0.4095]}, {"w": "then", "b": [0.7372, 0.3881, 0.775, 0.4095]}, {"w": "the", "b": [0.7799, 0.3881, 0.8063, 0.4095]}, {"w": "email", "b": [0.8112, 0.3881, 0.8572, 0.4095]}, {"w": "“Hello", "b": [0.1984, 0.4071, 0.2522, 0.4285]}, {"w": "you", "b": [0.2611, 0.4071, 0.2924, 0.4285]}, {"w": "Hello", "b": [0.3014, 0.4071, 0.3469, 0.4285]}, {"w": "Hello", "b": [0.3558, 0.4071, 0.4013, 0.4285]}, {"w": "you”", "b": [0.4103, 0.4071, 0.4494, 0.4285]}, {"w": "would", "b": [0.4584, 0.4071, 0.5106, 0.4285]}, {"w": "be", "b": [0.5196, 0.4071, 0.539, 0.4285]}, {"w": "converted", "b": [0.548, 0.4071, 0.6308, 0.4285]}, {"w": "into", "b": [0.6398, 0.4071, 0.6734, 0.4285]}, {"w": "a", "b": [0.6824, 0.4071, 0.6915, 0.4285]}, {"w": "vector", "b": [0.7005, 0.4071, 0.7525, 0.4285]}, {"w": "[1,", "b": [0.7615, 0.4071, 0.7835, 0.4285]}, {"w": "0,", "b": [0.7925, 0.4071, 0.8072, 0.4285]}, {"w": "0,", "b": [0.8162, 0.4071, 0.831, 0.4285]}, {"w": "1]", "b": [0.8399, 0.4071, 0.8571, 0.4285]}, {"w": "(meaning", "b": [0.1984, 0.4262, 0.2788, 0.4476]}, {"w": "[“Hello”", "b": [0.2911, 0.4262, 0.3588, 0.4476]}, {"w": "is", "b": [0.3711, 0.4262, 0.3844, 0.4476]}, {"w": "present,", "b": [0.3966, 0.4262, 0.4627, 0.4476]}, {"w": "“how”", "b": [0.475, 0.4262, 0.5277, 0.4476]}, {"w": "is", "b": [0.54, 0.4262, 0.5532, 0.4476]}, {"w": "absent,", "b": [0.5655, 0.4262, 0.6238, 0.4476]}, {"w": "“are”", "b": [0.6361, 0.4262, 0.6759, 0.4476]}, {"w": "is", "b": [0.6882, 0.4262, 0.7014, 0.4476]}, {"w": "absent,", "b": [0.7137, 0.4262, 0.772, 0.4476]}, {"w": "“you”", "b": [0.7843, 0.4262, 0.8316, 0.4476]}, {"w": "is", "b": [0.8439, 0.4262, 0.8571, 0.4476]}, {"w": "present]),", "b": [0.1984, 0.4452, 0.2789, 0.4666]}, {"w": "or", "b": [0.286, 0.4452, 0.3044, 0.4666]}, {"w": "[3,", "b": [0.3115, 0.4452, 0.3334, 0.4666]}, {"w": "0,", "b": [0.3405, 0.4452, 0.3553, 0.4666]}, {"w": "0,", "b": [0.3624, 0.4452, 0.3771, 0.4666]}, {"w": "2]", "b": [0.3842, 0.4452, 0.4014, 0.4666]}, {"w": "if", "b": [0.4085, 0.4452, 0.4203, 0.4666]}, {"w": "you", "b": [0.4274, 0.4452, 0.4586, 0.4666]}, {"w": "prefer", "b": [0.4658, 0.4452, 0.516, 0.4666]}, {"w": "to", "b": [0.5231, 0.4452, 0.5401, 0.4666]}, {"w": "count", "b": [0.5472, 0.4452, 0.5951, 0.4666]}, {"w": "the", "b": [0.6022, 0.4452, 0.6285, 0.4666]}, {"w": "number", "b": [0.6356, 0.4452, 0.7019, 0.4666]}, {"w": "of", "b": [0.709, 0.4452, 0.7258, 0.4666]}, {"w": "occurrences", "b": [0.7329, 0.4452, 0.8332, 0.4666]}, {"w": "of", "b": [0.8403, 0.4452, 0.8571, 0.4666]}, {"w": "each", "b": [0.1984, 0.4642, 0.2363, 0.4857]}, {"w": "word.", "b": [0.2411, 0.4642, 0.2894, 0.4857]}]}, {"id": "b_7", "type": "paragraph", "text": "• You may want to add hyperparameters to your preparation pipeline to control whether or not to strip off email headers, convert each email to lowercase, remove punctuation, replace all URLs with “URL,” replace all numbers with “NUMBER,” or even perform stemming (i.e., trim off word endings; there are Python libraries available to do this).", "words": [{"w": "•", "b": [0.1799, 0.4893, 0.188, 0.5108]}, {"w": "You", "b": [0.1984, 0.4893, 0.2308, 0.5108]}, {"w": "may", "b": [0.2364, 0.4893, 0.2718, 0.5108]}, {"w": "want", "b": [0.2775, 0.4893, 0.3183, 0.5108]}, {"w": "to", "b": [0.3239, 0.4893, 0.3409, 0.5108]}, {"w": "add", "b": [0.3465, 0.4893, 0.3777, 0.5108]}, {"w": "hyperparameters", "b": [0.3833, 0.4893, 0.5245, 0.5108]}, {"w": "to", "b": [0.5301, 0.4893, 0.5471, 0.5108]}, {"w": "your", "b": [0.5528, 0.4893, 0.5918, 0.5108]}, {"w": "preparation", "b": [0.5974, 0.4893, 0.6954, 0.5108]}, {"w": "pipeline", "b": [0.7011, 0.4893, 0.7684, 0.5108]}, {"w": "to", "b": [0.7741, 0.4893, 0.7911, 0.5108]}, {"w": "control", "b": [0.7967, 0.4893, 0.8572, 0.5108]}, {"w": "whether", "b": [0.1984, 0.5084, 0.2667, 0.5298]}, {"w": "or", "b": [0.2751, 0.5084, 0.2935, 0.5298]}, {"w": "not", "b": [0.3019, 0.5084, 0.3303, 0.5298]}, {"w": "to", "b": [0.3387, 0.5084, 0.3556, 0.5298]}, {"w": "strip", "b": [0.364, 0.5084, 0.4023, 0.5298]}, {"w": "off", "b": [0.4107, 0.5084, 0.4336, 0.5298]}, {"w": "email", "b": [0.442, 0.5084, 0.4879, 0.5298]}, {"w": "headers,", "b": [0.4963, 0.5084, 0.5654, 0.5298]}, {"w": "convert", "b": [0.5738, 0.5084, 0.6368, 0.5298]}, {"w": "each", "b": [0.6452, 0.5084, 0.6831, 0.5298]}, {"w": "email", "b": [0.6915, 0.5084, 0.7374, 0.5298]}, {"w": "to", "b": [0.7458, 0.5084, 0.7628, 0.5298]}, {"w": "lowercase,", "b": [0.7712, 0.5084, 0.8572, 0.5298]}, {"w": "remove", "b": [0.1984, 0.5274, 0.2612, 0.5488]}, {"w": "punctuation,", "b": [0.2689, 0.5274, 0.3759, 0.5488]}, {"w": "replace", "b": [0.3836, 0.5274, 0.4432, 0.5488]}, {"w": "all", "b": [0.4508, 0.5274, 0.4705, 0.5488]}, {"w": "URLs", "b": [0.4782, 0.5274, 0.5253, 0.5488]}, {"w": "with", "b": [0.533, 0.5274, 0.5703, 0.5488]}, {"w": "“URL,”", "b": [0.578, 0.5274, 0.636, 0.5488]}, {"w": "replace", "b": [0.6436, 0.5274, 0.7032, 0.5488]}, {"w": "all", "b": [0.7109, 0.5274, 0.7306, 0.5488]}, {"w": "numbers", "b": [0.7382, 0.5274, 0.8122, 0.5488]}, {"w": "with", "b": [0.8198, 0.5274, 0.8572, 0.5488]}, {"w": "“NUMBER,”", "b": [0.1984, 0.5465, 0.3033, 0.5679]}, {"w": "or", "b": [0.3098, 0.5465, 0.3281, 0.5679]}, {"w": "even", "b": [0.3346, 0.5465, 0.3734, 0.5679]}, {"w": "perform", "b": [0.3798, 0.5465, 0.4489, 0.5679]}, {"w": "stemming", "b": [0.4553, 0.5463, 0.5337, 0.5679]}, {"w": "(i.e.,", "b": [0.5402, 0.5465, 0.5761, 0.5679]}, {"w": "trim", "b": [0.5825, 0.5465, 0.6193, 0.5679]}, {"w": "off", "b": [0.6257, 0.5465, 0.6487, 0.5679]}, {"w": "word", "b": [0.6551, 0.5465, 0.6988, 0.5679]}, {"w": "endings;", "b": [0.7052, 0.5465, 0.7756, 0.5679]}, {"w": "there", "b": [0.7821, 0.5465, 0.825, 0.5679]}, {"w": "are", "b": [0.8314, 0.5465, 0.8572, 0.5679]}, {"w": "Python", "b": [0.1984, 0.5655, 0.2592, 0.5869]}, {"w": "libraries", "b": [0.2639, 0.5655, 0.332, 0.5869]}, {"w": "available", "b": [0.3368, 0.5655, 0.409, 0.5869]}, {"w": "to", "b": [0.4138, 0.5655, 0.4308, 0.5869]}, {"w": "do", "b": [0.4355, 0.5655, 0.4571, 0.5869]}, {"w": "this).", "b": [0.4618, 0.5655, 0.5045, 0.5869]}]}, {"id": "b_8", "type": "paragraph", "text": "• Then try out several classifiers and see if you can build a great spam classifier, with both high recall and high precision.", "words": [{"w": "•", "b": [0.1799, 0.5906, 0.188, 0.612]}, {"w": "Then", "b": [0.1984, 0.5906, 0.2426, 0.612]}, {"w": "try", "b": [0.2484, 0.5906, 0.2727, 0.612]}, {"w": "out", "b": [0.2785, 0.5906, 0.3065, 0.612]}, {"w": "several", "b": [0.3123, 0.5906, 0.3694, 0.612]}, {"w": "classifiers", "b": [0.3752, 0.5906, 0.4553, 0.612]}, {"w": "and", "b": [0.4611, 0.5906, 0.4926, 0.612]}, {"w": "see", "b": [0.4984, 0.5906, 0.5238, 0.612]}, {"w": "if", "b": [0.5296, 0.5906, 0.5413, 0.612]}, {"w": "you", "b": [0.5471, 0.5906, 0.5784, 0.612]}, {"w": "can", "b": [0.5841, 0.5906, 0.6135, 0.612]}, {"w": "build", "b": [0.6193, 0.5906, 0.6628, 0.612]}, {"w": "a", "b": [0.6686, 0.5906, 0.6777, 0.612]}, {"w": "great", "b": [0.6835, 0.5906, 0.7249, 0.612]}, {"w": "spam", "b": [0.7307, 0.5906, 0.7755, 0.612]}, {"w": "classifier,", "b": [0.7813, 0.5906, 0.8571, 0.612]}, {"w": "with", "b": [0.1984, 0.6097, 0.2358, 0.6311]}, {"w": "both", "b": [0.2405, 0.6097, 0.2792, 0.6311]}, {"w": "high", "b": [0.2839, 0.6097, 0.3215, 0.6311]}, {"w": "recall", "b": [0.3262, 0.6097, 0.3713, 0.6311]}, {"w": "and", "b": [0.376, 0.6097, 0.4076, 0.6311]}, {"w": "high", "b": [0.4123, 0.6097, 0.4499, 0.6311]}, {"w": "precision.", "b": [0.4546, 0.6097, 0.5365, 0.6311]}]}, {"id": "b_9", "type": "paragraph", "text": "Solutions to these exercises are available in the online Jupyter notebooks at https:// github.com/ageron/handson-ml2.", "words": [{"w": "Solutions", "b": [0.1429, 0.6529, 0.2213, 0.6743]}, {"w": "to", "b": [0.2285, 0.6529, 0.2455, 0.6743]}, {"w": "these", "b": [0.2527, 0.6529, 0.2956, 0.6743]}, {"w": "exercises", "b": [0.3028, 0.6529, 0.3766, 0.6743]}, {"w": "are", "b": [0.3838, 0.6529, 0.4095, 0.6743]}, {"w": "available", "b": [0.4168, 0.6529, 0.489, 0.6743]}, {"w": "in", "b": [0.4963, 0.6529, 0.5132, 0.6743]}, {"w": "the", "b": [0.5205, 0.6529, 0.5468, 0.6743]}, {"w": "online", "b": [0.554, 0.6529, 0.6071, 0.6743]}, {"w": "Jupyter", "b": [0.6144, 0.6529, 0.675, 0.6743]}, {"w": "notebooks", "b": [0.6822, 0.6529, 0.7693, 0.6743]}, {"w": "at", "b": [0.7765, 0.6529, 0.7916, 0.6743]}, {"w": "https://", "b": [0.7988, 0.6527, 0.8571, 0.6743]}, {"w": "github.com/ageron/handson-ml2.", "b": [0.1429, 0.6718, 0.4135, 0.6934]}]}, {"id": "b_10", "type": "paragraph", "text": "Exercises | 111", "words": [{"w": "Exercises", "b": [0.7433, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "111", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 138, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": []}, {"page": 139, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "CHAPTER 4 Training Models", "words": [{"w": "CHAPTER", "b": [0.7398, 0.1146, 0.8383, 0.1451]}, {"w": "4", "b": [0.8435, 0.1146, 0.8571, 0.1451]}, {"w": "Training", "b": [0.5933, 0.1478, 0.7308, 0.1935]}, {"w": "Models", "b": [0.7387, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_1", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 4 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.3643, 0.3102, 0.3839]}, {"w": "Early", "b": [0.3165, 0.3643, 0.3563, 0.3839]}, {"w": "Release", "b": [0.3626, 0.3643, 0.4189, 0.3839]}, {"w": "ebooks,", "b": [0.4251, 0.3643, 0.4831, 0.3839]}, {"w": "you", "b": [0.4894, 0.3643, 0.518, 0.3839]}, {"w": "get", "b": [0.5243, 0.3643, 0.5471, 0.3839]}, {"w": "books", "b": [0.5534, 0.3643, 0.5989, 0.3839]}, {"w": "in", "b": [0.6052, 0.3643, 0.6207, 0.3839]}, {"w": "their", "b": [0.627, 0.3643, 0.6632, 0.3839]}, {"w": "earliest", "b": [0.6695, 0.3643, 0.7239, 0.3839]}, {"w": "form—", "b": [0.7301, 0.3643, 0.7857, 0.3839]}, {"w": "the", "b": [0.2714, 0.3818, 0.2955, 0.4013]}, {"w": "author’s", "b": [0.3012, 0.3818, 0.3615, 0.4013]}, {"w": "raw", "b": [0.3672, 0.3818, 0.3954, 0.4013]}, {"w": "and", "b": [0.4011, 0.3818, 0.4299, 0.4013]}, {"w": "unedited", "b": [0.4357, 0.3818, 0.5034, 0.4013]}, {"w": "content", "b": [0.5091, 0.3818, 0.5667, 0.4013]}, {"w": "as", "b": [0.5725, 0.3818, 0.5878, 0.4013]}, {"w": "he", "b": [0.5935, 0.3818, 0.6118, 0.4013]}, {"w": "or", "b": [0.6175, 0.3818, 0.6343, 0.4013]}, {"w": "she", "b": [0.6401, 0.3818, 0.6653, 0.4013]}, {"w": "writes—so", "b": [0.671, 0.3818, 0.7514, 0.4013]}, {"w": "you", "b": [0.7571, 0.3818, 0.7857, 0.4013]}, {"w": "can", "b": [0.2714, 0.3992, 0.2982, 0.4188]}, {"w": "take", "b": [0.306, 0.3992, 0.3377, 0.4188]}, {"w": "advantage", "b": [0.3455, 0.3992, 0.4223, 0.4188]}, {"w": "of", "b": [0.4301, 0.3992, 0.4454, 0.4188]}, {"w": "these", "b": [0.4532, 0.3992, 0.4923, 0.4188]}, {"w": "technologies", "b": [0.5001, 0.3992, 0.596, 0.4188]}, {"w": "long", "b": [0.6038, 0.3992, 0.6376, 0.4188]}, {"w": "before", "b": [0.6454, 0.3992, 0.6937, 0.4188]}, {"w": "the", "b": [0.7014, 0.3992, 0.7255, 0.4188]}, {"w": "official", "b": [0.7333, 0.3992, 0.7857, 0.4188]}, {"w": "release", "b": [0.2714, 0.4166, 0.3229, 0.4362]}, {"w": "of", "b": [0.3292, 0.4166, 0.3445, 0.4362]}, {"w": "these", "b": [0.3507, 0.4166, 0.3899, 0.4362]}, {"w": "titles.", "b": [0.3961, 0.4166, 0.4371, 0.4362]}, {"w": "The", "b": [0.4433, 0.4166, 0.4733, 0.4362]}, {"w": "following", "b": [0.4795, 0.4166, 0.5517, 0.4362]}, {"w": "will", "b": [0.558, 0.4166, 0.5857, 0.4362]}, {"w": "be", "b": [0.592, 0.4166, 0.6097, 0.4362]}, {"w": "Chapter", "b": [0.616, 0.4166, 0.6777, 0.4362]}, {"w": "4", "b": [0.684, 0.4166, 0.6931, 0.4362]}, {"w": "in", "b": [0.6993, 0.4166, 0.7149, 0.4362]}, {"w": "the", "b": [0.7211, 0.4166, 0.7452, 0.4362]}, {"w": "final", "b": [0.7514, 0.4166, 0.7857, 0.4362]}, {"w": "release", "b": [0.2714, 0.434, 0.3229, 0.4536]}, {"w": "of", "b": [0.3273, 0.434, 0.3426, 0.4536]}, {"w": "the", "b": [0.3469, 0.434, 0.371, 0.4536]}, {"w": "book.", "b": [0.3753, 0.434, 0.4182, 0.4536]}]}, {"id": "b_2", "type": "paragraph", "text": "So far we have treated Machine Learning models and their training algorithms mostly like black boxes. If you went through some of the exercises in the previous chapters, you may have been surprised by how much you can get done without knowing any‐ thing about what’s under the hood: you optimized a regression system, you improved a digit image classifier, and you even built a spam classifier from scratch—all this without knowing how they actually work. Indeed, in many situations you don’t really need to know the implementation details.", "words": [{"w": "So", "b": [0.1429, 0.4739, 0.1634, 0.4953]}, {"w": "far", "b": [0.1682, 0.4739, 0.1912, 0.4953]}, {"w": "we", "b": [0.196, 0.4739, 0.2191, 0.4953]}, {"w": "have", "b": [0.224, 0.4739, 0.2624, 0.4953]}, {"w": "treated", "b": [0.2672, 0.4739, 0.3251, 0.4953]}, {"w": "Machine", "b": [0.3299, 0.4739, 0.403, 0.4953]}, {"w": "Learning", "b": [0.4078, 0.4739, 0.4829, 0.4953]}, {"w": "models", "b": [0.4877, 0.4739, 0.5481, 0.4953]}, {"w": "and", "b": [0.553, 0.4739, 0.5845, 0.4953]}, {"w": "their", "b": [0.5893, 0.4739, 0.629, 0.4953]}, {"w": "training", "b": [0.6338, 0.4739, 0.7007, 0.4953]}, {"w": "algorithms", "b": [0.7055, 0.4739, 0.7958, 0.4953]}, {"w": "mostly", "b": [0.8006, 0.4739, 0.8571, 0.4953]}, {"w": "like", "b": [0.1428, 0.4929, 0.1729, 0.5143]}, {"w": "black", "b": [0.1789, 0.4929, 0.223, 0.5143]}, {"w": "boxes.", "b": [0.229, 0.4929, 0.2813, 0.5143]}, {"w": "If", "b": [0.2872, 0.4929, 0.3005, 0.5143]}, {"w": "you", "b": [0.3065, 0.4929, 0.3377, 0.5143]}, {"w": "went", "b": [0.3437, 0.4929, 0.3842, 0.5143]}, {"w": "through", "b": [0.3902, 0.4929, 0.4579, 0.5143]}, {"w": "some", "b": [0.4639, 0.4929, 0.5081, 0.5143]}, {"w": "of", "b": [0.5141, 0.4929, 0.5308, 0.5143]}, {"w": "the", "b": [0.5368, 0.4929, 0.5632, 0.5143]}, {"w": "exercises", "b": [0.5691, 0.4929, 0.6429, 0.5143]}, {"w": "in", "b": [0.6489, 0.4929, 0.6659, 0.5143]}, {"w": "the", "b": [0.6719, 0.4929, 0.6982, 0.5143]}, {"w": "previous", "b": [0.7042, 0.4929, 0.7762, 0.5143]}, {"w": "chapters,", "b": [0.7822, 0.4929, 0.8571, 0.5143]}, {"w": "you", "b": [0.1429, 0.512, 0.1741, 0.5334]}, {"w": "may", "b": [0.1801, 0.512, 0.2155, 0.5334]}, {"w": "have", "b": [0.2216, 0.512, 0.26, 0.5334]}, {"w": "been", "b": [0.266, 0.512, 0.3057, 0.5334]}, {"w": "surprised", "b": [0.3117, 0.512, 0.3899, 0.5334]}, {"w": "by", "b": [0.3959, 0.512, 0.416, 0.5334]}, {"w": "how", "b": [0.4221, 0.512, 0.4581, 0.5334]}, {"w": "much", "b": [0.4641, 0.512, 0.5118, 0.5334]}, {"w": "you", "b": [0.5178, 0.512, 0.549, 0.5334]}, {"w": "can", "b": [0.5551, 0.512, 0.5844, 0.5334]}, {"w": "get", "b": [0.5904, 0.512, 0.6154, 0.5334]}, {"w": "done", "b": [0.6214, 0.512, 0.6633, 0.5334]}, {"w": "without", "b": [0.6693, 0.512, 0.7347, 0.5334]}, {"w": "knowing", "b": [0.7407, 0.512, 0.8141, 0.5334]}, {"w": "any‐", "b": [0.8201, 0.512, 0.8571, 0.5334]}, {"w": "thing", "b": [0.1429, 0.531, 0.1871, 0.5524]}, {"w": "about", "b": [0.1923, 0.531, 0.24, 0.5524]}, {"w": "what’s", "b": [0.2452, 0.531, 0.2955, 0.5524]}, {"w": "under", "b": [0.3007, 0.531, 0.3507, 0.5524]}, {"w": "the", "b": [0.356, 0.531, 0.3823, 0.5524]}, {"w": "hood:", "b": [0.3875, 0.531, 0.4356, 0.5524]}, {"w": "you", "b": [0.4408, 0.531, 0.4721, 0.5524]}, {"w": "optimized", "b": [0.4773, 0.531, 0.562, 0.5524]}, {"w": "a", "b": [0.5672, 0.531, 0.5764, 0.5524]}, {"w": "regression", "b": [0.5816, 0.531, 0.6674, 0.5524]}, {"w": "system,", "b": [0.6726, 0.531, 0.7345, 0.5524]}, {"w": "you", "b": [0.7397, 0.531, 0.7709, 0.5524]}, {"w": "improved", "b": [0.7761, 0.531, 0.8571, 0.5524]}, {"w": "a", "b": [0.1429, 0.5501, 0.152, 0.5715]}, {"w": "digit", "b": [0.16, 0.5501, 0.1982, 0.5715]}, {"w": "image", "b": [0.2062, 0.5501, 0.2566, 0.5715]}, {"w": "classifier,", "b": [0.2645, 0.5501, 0.3404, 0.5715]}, {"w": "and", "b": [0.3484, 0.5501, 0.3799, 0.5715]}, {"w": "you", "b": [0.3879, 0.5501, 0.4191, 0.5715]}, {"w": "even", "b": [0.4271, 0.5501, 0.4658, 0.5715]}, {"w": "built", "b": [0.4738, 0.5501, 0.5126, 0.5715]}, {"w": "a", "b": [0.5206, 0.5501, 0.5297, 0.5715]}, {"w": "spam", "b": [0.5377, 0.5501, 0.5825, 0.5715]}, {"w": "classifier", "b": [0.5904, 0.5501, 0.6629, 0.5715]}, {"w": "from", "b": [0.6708, 0.5501, 0.7124, 0.5715]}, {"w": "scratch—all", "b": [0.7203, 0.5501, 0.8185, 0.5715]}, {"w": "this", "b": [0.8264, 0.5501, 0.8571, 0.5715]}, {"w": "without", "b": [0.1429, 0.5691, 0.2082, 0.5905]}, {"w": "knowing", "b": [0.2137, 0.5691, 0.287, 0.5905]}, {"w": "how", "b": [0.2924, 0.5691, 0.3284, 0.5905]}, {"w": "they", "b": [0.3339, 0.5691, 0.3698, 0.5905]}, {"w": "actually", "b": [0.3752, 0.5691, 0.4398, 0.5905]}, {"w": "work.", "b": [0.4452, 0.5691, 0.4929, 0.5905]}, {"w": "Indeed,", "b": [0.4983, 0.5691, 0.5613, 0.5905]}, {"w": "in", "b": [0.5667, 0.5691, 0.5837, 0.5905]}, {"w": "many", "b": [0.5891, 0.5691, 0.6358, 0.5905]}, {"w": "situations", "b": [0.6412, 0.5691, 0.7222, 0.5905]}, {"w": "you", "b": [0.7276, 0.5691, 0.7589, 0.5905]}, {"w": "don’t", "b": [0.7643, 0.5691, 0.8059, 0.5905]}, {"w": "really", "b": [0.8113, 0.5691, 0.8572, 0.5905]}, {"w": "need", "b": [0.1429, 0.5882, 0.183, 0.6096]}, {"w": "to", "b": [0.1877, 0.5882, 0.2047, 0.6096]}, {"w": "know", "b": [0.2094, 0.5882, 0.256, 0.6096]}, {"w": "the", "b": [0.2608, 0.5882, 0.2871, 0.6096]}, {"w": "implementation", "b": [0.2918, 0.5882, 0.4251, 0.6096]}, {"w": "details.", "b": [0.4298, 0.5882, 0.4884, 0.6096]}]}, {"id": "b_3", "type": "paragraph", "text": "However, having a good understanding of how things work can help you quickly home in on the appropriate model, the right training algorithm to use, and a good set of hyperparameters for your task. Understanding what’s under the hood will also help you debug issues and perform error analysis more efficiently. Lastly, most of the top‐ ics discussed in this chapter will be essential in understanding, building, and training neural networks (discussed in Part II of this book).", "words": [{"w": "However,", "b": [0.1429, 0.6163, 0.2217, 0.6377]}, {"w": "having", "b": [0.2301, 0.6163, 0.2863, 0.6377]}, {"w": "a", "b": [0.2947, 0.6163, 0.3038, 0.6377]}, {"w": "good", "b": [0.3121, 0.6163, 0.3541, 0.6377]}, {"w": "understanding", "b": [0.3625, 0.6163, 0.4848, 0.6377]}, {"w": "of", "b": [0.4931, 0.6163, 0.5099, 0.6377]}, {"w": "how", "b": [0.5183, 0.6163, 0.5543, 0.6377]}, {"w": "things", "b": [0.5626, 0.6163, 0.6145, 0.6377]}, {"w": "work", "b": [0.6228, 0.6163, 0.6658, 0.6377]}, {"w": "can", "b": [0.6741, 0.6163, 0.7034, 0.6377]}, {"w": "help", "b": [0.7118, 0.6163, 0.748, 0.6377]}, {"w": "you", "b": [0.7563, 0.6163, 0.7875, 0.6377]}, {"w": "quickly", "b": [0.7959, 0.6163, 0.8571, 0.6377]}, {"w": "home", "b": [0.1429, 0.6353, 0.1905, 0.6567]}, {"w": "in", "b": [0.1956, 0.6353, 0.2125, 0.6567]}, {"w": "on", "b": [0.2176, 0.6353, 0.2396, 0.6567]}, {"w": "the", "b": [0.2447, 0.6353, 0.271, 0.6567]}, {"w": "appropriate", "b": [0.276, 0.6353, 0.3732, 0.6567]}, {"w": "model,", "b": [0.3782, 0.6353, 0.4358, 0.6567]}, {"w": "the", "b": [0.4408, 0.6353, 0.4672, 0.6567]}, {"w": "right", "b": [0.4722, 0.6353, 0.5123, 0.6567]}, {"w": "training", "b": [0.5174, 0.6353, 0.5843, 0.6567]}, {"w": "algorithm", "b": [0.5894, 0.6353, 0.672, 0.6567]}, {"w": "to", "b": [0.6771, 0.6353, 0.6941, 0.6567]}, {"w": "use,", "b": [0.6991, 0.6353, 0.7314, 0.6567]}, {"w": "and", "b": [0.7365, 0.6353, 0.768, 0.6567]}, {"w": "a", "b": [0.773, 0.6353, 0.7822, 0.6567]}, {"w": "good", "b": [0.7872, 0.6353, 0.8292, 0.6567]}, {"w": "set", "b": [0.8343, 0.6353, 0.8571, 0.6567]}, {"w": "of", "b": [0.1428, 0.6544, 0.1596, 0.6758]}, {"w": "hyperparameters", "b": [0.1646, 0.6544, 0.3058, 0.6758]}, {"w": "for", "b": [0.3107, 0.6544, 0.3353, 0.6758]}, {"w": "your", "b": [0.3402, 0.6544, 0.3792, 0.6758]}, {"w": "task.", "b": [0.3842, 0.6544, 0.4224, 0.6758]}, {"w": "Understanding", "b": [0.4274, 0.6544, 0.5531, 0.6758]}, {"w": "what’s", "b": [0.558, 0.6544, 0.6083, 0.6758]}, {"w": "under", "b": [0.6133, 0.6544, 0.6633, 0.6758]}, {"w": "the", "b": [0.6683, 0.6544, 0.6946, 0.6758]}, {"w": "hood", "b": [0.6996, 0.6544, 0.743, 0.6758]}, {"w": "will", "b": [0.7479, 0.6544, 0.7783, 0.6758]}, {"w": "also", "b": [0.7833, 0.6544, 0.816, 0.6758]}, {"w": "help", "b": [0.821, 0.6544, 0.8571, 0.6758]}, {"w": "you", "b": [0.1429, 0.6734, 0.1741, 0.6948]}, {"w": "debug", "b": [0.1797, 0.6734, 0.2309, 0.6948]}, {"w": "issues", "b": [0.2365, 0.6734, 0.2849, 0.6948]}, {"w": "and", "b": [0.2905, 0.6734, 0.3221, 0.6948]}, {"w": "perform", "b": [0.3276, 0.6734, 0.3967, 0.6948]}, {"w": "error", "b": [0.4023, 0.6734, 0.4449, 0.6948]}, {"w": "analysis", "b": [0.4505, 0.6734, 0.5159, 0.6948]}, {"w": "more", "b": [0.5215, 0.6734, 0.5657, 0.6948]}, {"w": "efficiently.", "b": [0.5713, 0.6734, 0.6568, 0.6948]}, {"w": "Lastly,", "b": [0.6623, 0.6734, 0.7147, 0.6948]}, {"w": "most", "b": [0.7203, 0.6734, 0.762, 0.6948]}, {"w": "of", "b": [0.7676, 0.6734, 0.7844, 0.6948]}, {"w": "the", "b": [0.7899, 0.6734, 0.8163, 0.6948]}, {"w": "top‐", "b": [0.8218, 0.6734, 0.8571, 0.6948]}, {"w": "ics", "b": [0.1429, 0.6925, 0.1649, 0.7139]}, {"w": "discussed", "b": [0.1703, 0.6925, 0.2496, 0.7139]}, {"w": "in", "b": [0.255, 0.6925, 0.272, 0.7139]}, {"w": "this", "b": [0.2774, 0.6925, 0.3081, 0.7139]}, {"w": "chapter", "b": [0.3135, 0.6925, 0.3761, 0.7139]}, {"w": "will", "b": [0.3815, 0.6925, 0.4119, 0.7139]}, {"w": "be", "b": [0.4173, 0.6925, 0.4367, 0.7139]}, {"w": "essential", "b": [0.4422, 0.6925, 0.5125, 0.7139]}, {"w": "in", "b": [0.518, 0.6925, 0.5349, 0.7139]}, {"w": "understanding,", "b": [0.5404, 0.6925, 0.6674, 0.7139]}, {"w": "building,", "b": [0.6728, 0.6925, 0.7478, 0.7139]}, {"w": "and", "b": [0.7532, 0.6925, 0.7848, 0.7139]}, {"w": "training", "b": [0.7902, 0.6925, 0.8571, 0.7139]}, {"w": "neural", "b": [0.1429, 0.7115, 0.1963, 0.7329]}, {"w": "networks", "b": [0.201, 0.7115, 0.2782, 0.7329]}, {"w": "(discussed", "b": [0.283, 0.7115, 0.3694, 0.7329]}, {"w": "in", "b": [0.3742, 0.7115, 0.3911, 0.7329]}, {"w": "Part", "b": [0.3959, 0.7115, 0.4304, 0.7329]}, {"w": "II", "b": [0.4351, 0.7115, 0.4493, 0.7329]}, {"w": "of", "b": [0.454, 0.7115, 0.4708, 0.7329]}, {"w": "this", "b": [0.4756, 0.7115, 0.5063, 0.7329]}, {"w": "book).", "b": [0.511, 0.7115, 0.5651, 0.7329]}]}, {"id": "b_4", "type": "paragraph", "text": "In this chapter, we will start by looking at the Linear Regression model, one of the simplest models there is. We will discuss two very different ways to train it:", "words": [{"w": "In", "b": [0.1429, 0.7396, 0.1614, 0.761]}, {"w": "this", "b": [0.1685, 0.7396, 0.1992, 0.761]}, {"w": "chapter,", "b": [0.2063, 0.7396, 0.2723, 0.761]}, {"w": "we", "b": [0.2794, 0.7396, 0.3025, 0.761]}, {"w": "will", "b": [0.3096, 0.7396, 0.34, 0.761]}, {"w": "start", "b": [0.3471, 0.7396, 0.3843, 0.761]}, {"w": "by", "b": [0.3915, 0.7396, 0.4116, 0.761]}, {"w": "looking", "b": [0.4187, 0.7396, 0.4823, 0.761]}, {"w": "at", "b": [0.4894, 0.7396, 0.5045, 0.761]}, {"w": "the", "b": [0.5116, 0.7396, 0.538, 0.761]}, {"w": "Linear", "b": [0.5451, 0.7396, 0.599, 0.761]}, {"w": "Regression", "b": [0.6061, 0.7396, 0.6971, 0.761]}, {"w": "model,", "b": [0.7042, 0.7396, 0.7618, 0.761]}, {"w": "one", "b": [0.7689, 0.7396, 0.7998, 0.761]}, {"w": "of", "b": [0.8069, 0.7396, 0.8237, 0.761]}, {"w": "the", "b": [0.8308, 0.7396, 0.8571, 0.761]}, {"w": "simplest", "b": [0.1429, 0.7587, 0.2118, 0.7801]}, {"w": "models", "b": [0.2165, 0.7587, 0.277, 0.7801]}, {"w": "there", "b": [0.2817, 0.7587, 0.3246, 0.7801]}, {"w": "is.", "b": [0.3294, 0.7587, 0.3473, 0.7801]}, {"w": "We", "b": [0.3521, 0.7587, 0.3791, 0.7801]}, {"w": "will", "b": [0.3839, 0.7587, 0.4143, 0.7801]}, {"w": "discuss", "b": [0.419, 0.7587, 0.4784, 0.7801]}, {"w": "two", "b": [0.4831, 0.7587, 0.5144, 0.7801]}, {"w": "very", "b": [0.5191, 0.7587, 0.5555, 0.7801]}, {"w": "different", "b": [0.5602, 0.7587, 0.6319, 0.7801]}, {"w": "ways", "b": [0.6367, 0.7587, 0.6769, 0.7801]}, {"w": "to", "b": [0.6816, 0.7587, 0.6986, 0.7801]}, {"w": "train", "b": [0.7033, 0.7587, 0.7436, 0.7801]}, {"w": "it:", "b": [0.7483, 0.7587, 0.765, 0.7801]}]}, {"id": "b_5", "type": "paragraph", "text": "• Using a direct “closed-form” equation that directly computes the model parame‐ ters that best fit the model to the training set (i.e., the model parameters that minimize the cost function over the training set).", "words": [{"w": "•", "b": [0.16, 0.7928, 0.1682, 0.8143]}, {"w": "Using", "b": [0.1786, 0.7928, 0.2272, 0.8143]}, {"w": "a", "b": [0.233, 0.7928, 0.2422, 0.8143]}, {"w": "direct", "b": [0.2481, 0.7928, 0.2964, 0.8143]}, {"w": "“closed-form”", "b": [0.3023, 0.7928, 0.4167, 0.8143]}, {"w": "equation", "b": [0.4225, 0.7928, 0.4958, 0.8143]}, {"w": "that", "b": [0.5017, 0.7928, 0.5343, 0.8143]}, {"w": "directly", "b": [0.5401, 0.7928, 0.6033, 0.8143]}, {"w": "computes", "b": [0.6092, 0.7928, 0.6901, 0.8143]}, {"w": "the", "b": [0.696, 0.7928, 0.7223, 0.8143]}, {"w": "model", "b": [0.7282, 0.7928, 0.781, 0.8143]}, {"w": "parame‐", "b": [0.7869, 0.7928, 0.8571, 0.8143]}, {"w": "ters", "b": [0.1786, 0.8119, 0.2092, 0.8333]}, {"w": "that", "b": [0.2171, 0.8119, 0.2496, 0.8333]}, {"w": "best", "b": [0.2575, 0.8119, 0.291, 0.8333]}, {"w": "fit", "b": [0.2989, 0.8119, 0.317, 0.8333]}, {"w": "the", "b": [0.3249, 0.8119, 0.3512, 0.8333]}, {"w": "model", "b": [0.3591, 0.8119, 0.4119, 0.8333]}, {"w": "to", "b": [0.4198, 0.8119, 0.4368, 0.8333]}, {"w": "the", "b": [0.4447, 0.8119, 0.471, 0.8333]}, {"w": "training", "b": [0.4789, 0.8119, 0.5459, 0.8333]}, {"w": "set", "b": [0.5537, 0.8119, 0.5766, 0.8333]}, {"w": "(i.e.,", "b": [0.5845, 0.8119, 0.6204, 0.8333]}, {"w": "the", "b": [0.6283, 0.8119, 0.6546, 0.8333]}, {"w": "model", "b": [0.6625, 0.8119, 0.7153, 0.8333]}, {"w": "parameters", "b": [0.7232, 0.8119, 0.8167, 0.8333]}, {"w": "that", "b": [0.8246, 0.8119, 0.8571, 0.8333]}, {"w": "minimize", "b": [0.1786, 0.8309, 0.2584, 0.8524]}, {"w": "the", "b": [0.2632, 0.8309, 0.2895, 0.8524]}, {"w": "cost", "b": [0.2942, 0.8309, 0.3277, 0.8524]}, {"w": "function", "b": [0.3324, 0.8309, 0.4038, 0.8524]}, {"w": "over", "b": [0.4085, 0.8309, 0.4454, 0.8524]}, {"w": "the", "b": [0.4501, 0.8309, 0.4764, 0.8524]}, {"w": "training", "b": [0.4812, 0.8309, 0.5481, 0.8524]}, {"w": "set).", "b": [0.5528, 0.8309, 0.5876, 0.8524]}]}, {"id": "b_6", "type": "paragraph", "text": "113", "words": [{"w": "113", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 140, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• Using an iterative optimization approach, called Gradient Descent (GD), that gradually tweaks the model parameters to minimize the cost function over the training set, eventually converging to the same set of parameters as the first method. We will look at a few variants of Gradient Descent that we will use again and again when we study neural networks in Part II: Batch GD, Mini-batch GD, and Stochastic GD.", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "Using", "b": [0.1786, 0.0791, 0.2272, 0.1005]}, {"w": "an", "b": [0.236, 0.0791, 0.2566, 0.1005]}, {"w": "iterative", "b": [0.2654, 0.0791, 0.3331, 0.1005]}, {"w": "optimization", "b": [0.342, 0.0791, 0.4496, 0.1005]}, {"w": "approach,", "b": [0.4584, 0.0791, 0.5412, 0.1005]}, {"w": "called", "b": [0.55, 0.0791, 0.5984, 0.1005]}, {"w": "Gradient", "b": [0.6072, 0.0791, 0.6818, 0.1005]}, {"w": "Descent", "b": [0.6906, 0.0791, 0.7575, 0.1005]}, {"w": "(GD),", "b": [0.7663, 0.0791, 0.8157, 0.1005]}, {"w": "that", "b": [0.8246, 0.0791, 0.8571, 0.1005]}, {"w": "gradually", "b": [0.1786, 0.0981, 0.2565, 0.1195]}, {"w": "tweaks", "b": [0.2638, 0.0981, 0.3204, 0.1195]}, {"w": "the", "b": [0.3277, 0.0981, 0.354, 0.1195]}, {"w": "model", "b": [0.3613, 0.0981, 0.4141, 0.1195]}, {"w": "parameters", "b": [0.4214, 0.0981, 0.5149, 0.1195]}, {"w": "to", "b": [0.5222, 0.0981, 0.5392, 0.1195]}, {"w": "minimize", "b": [0.5464, 0.0981, 0.6263, 0.1195]}, {"w": "the", "b": [0.6336, 0.0981, 0.6599, 0.1195]}, {"w": "cost", "b": [0.6672, 0.0981, 0.7007, 0.1195]}, {"w": "function", "b": [0.708, 0.0981, 0.7794, 0.1195]}, {"w": "over", "b": [0.7867, 0.0981, 0.8235, 0.1195]}, {"w": "the", "b": [0.8308, 0.0981, 0.8571, 0.1195]}, {"w": "training", "b": [0.1786, 0.1172, 0.2455, 0.1386]}, {"w": "set,", "b": [0.2547, 0.1172, 0.2823, 0.1386]}, {"w": "eventually", "b": [0.2915, 0.1172, 0.3765, 0.1386]}, {"w": "converging", "b": [0.3857, 0.1172, 0.4787, 0.1386]}, {"w": "to", "b": [0.4879, 0.1172, 0.5049, 0.1386]}, {"w": "the", "b": [0.5141, 0.1172, 0.5404, 0.1386]}, {"w": "same", "b": [0.5496, 0.1172, 0.5923, 0.1386]}, {"w": "set", "b": [0.6015, 0.1172, 0.6244, 0.1386]}, {"w": "of", "b": [0.6336, 0.1172, 0.6503, 0.1386]}, {"w": "parameters", "b": [0.6595, 0.1172, 0.753, 0.1386]}, {"w": "as", "b": [0.7622, 0.1172, 0.7789, 0.1386]}, {"w": "the", "b": [0.7881, 0.1172, 0.8145, 0.1386]}, {"w": "first", "b": [0.8237, 0.1172, 0.8571, 0.1386]}, {"w": "method.", "b": [0.1786, 0.1362, 0.2483, 0.1576]}, {"w": "We", "b": [0.2535, 0.1362, 0.2806, 0.1576]}, {"w": "will", "b": [0.2858, 0.1362, 0.3162, 0.1576]}, {"w": "look", "b": [0.3214, 0.1362, 0.3582, 0.1576]}, {"w": "at", "b": [0.3634, 0.1362, 0.3785, 0.1576]}, {"w": "a", "b": [0.3837, 0.1362, 0.3928, 0.1576]}, {"w": "few", "b": [0.398, 0.1362, 0.4273, 0.1576]}, {"w": "variants", "b": [0.4325, 0.1362, 0.4988, 0.1576]}, {"w": "of", "b": [0.504, 0.1362, 0.5207, 0.1576]}, {"w": "Gradient", "b": [0.5259, 0.1362, 0.6005, 0.1576]}, {"w": "Descent", "b": [0.6057, 0.1362, 0.6725, 0.1576]}, {"w": "that", "b": [0.6777, 0.1362, 0.7103, 0.1576]}, {"w": "we", "b": [0.7155, 0.1362, 0.7386, 0.1576]}, {"w": "will", "b": [0.7438, 0.1362, 0.7742, 0.1576]}, {"w": "use", "b": [0.7794, 0.1362, 0.8069, 0.1576]}, {"w": "again", "b": [0.8121, 0.1362, 0.8571, 0.1576]}, {"w": "and", "b": [0.1786, 0.1553, 0.2101, 0.1767]}, {"w": "again", "b": [0.216, 0.1553, 0.2611, 0.1767]}, {"w": "when", "b": [0.267, 0.1553, 0.3126, 0.1767]}, {"w": "we", "b": [0.3185, 0.1553, 0.3416, 0.1767]}, {"w": "study", "b": [0.3475, 0.1553, 0.3932, 0.1767]}, {"w": "neural", "b": [0.3991, 0.1553, 0.4525, 0.1767]}, {"w": "networks", "b": [0.4584, 0.1553, 0.5357, 0.1767]}, {"w": "in", "b": [0.5416, 0.1553, 0.5585, 0.1767]}, {"w": "Part", "b": [0.5644, 0.1553, 0.5989, 0.1767]}, {"w": "II:", "b": [0.6049, 0.1553, 0.6238, 0.1767]}, {"w": "Batch", "b": [0.6297, 0.1553, 0.677, 0.1767]}, {"w": "GD,", "b": [0.6829, 0.1553, 0.717, 0.1767]}, {"w": "Mini-batch", "b": [0.723, 0.1553, 0.8171, 0.1767]}, {"w": "GD,", "b": [0.823, 0.1553, 0.8572, 0.1767]}, {"w": "and", "b": [0.1786, 0.1743, 0.2101, 0.1957]}, {"w": "Stochastic", "b": [0.2148, 0.1743, 0.2992, 0.1957]}, {"w": "GD.", "b": [0.3039, 0.1743, 0.338, 0.1957]}]}, {"id": "b_1", "type": "paragraph", "text": "Next we will look at Polynomial Regression, a more complex model that can fit non‐ linear datasets. Since this model has more parameters than Linear Regression, it is more prone to overfitting the training data, so we will look at how to detect whether or not this is the case, using learning curves, and then we will look at several regulari‐ zation techniques that can reduce the risk of overfitting the training set.", "words": [{"w": "Next", "b": [0.1429, 0.2085, 0.1829, 0.2299]}, {"w": "we", "b": [0.1885, 0.2085, 0.2117, 0.2299]}, {"w": "will", "b": [0.2173, 0.2085, 0.2477, 0.2299]}, {"w": "look", "b": [0.2534, 0.2085, 0.2902, 0.2299]}, {"w": "at", "b": [0.2959, 0.2085, 0.311, 0.2299]}, {"w": "Polynomial", "b": [0.3167, 0.2085, 0.4123, 0.2299]}, {"w": "Regression,", "b": [0.4179, 0.2085, 0.5137, 0.2299]}, {"w": "a", "b": [0.5194, 0.2085, 0.5285, 0.2299]}, {"w": "more", "b": [0.5342, 0.2085, 0.5785, 0.2299]}, {"w": "complex", "b": [0.5841, 0.2085, 0.6551, 0.2299]}, {"w": "model", "b": [0.6608, 0.2085, 0.7136, 0.2299]}, {"w": "that", "b": [0.7193, 0.2085, 0.7519, 0.2299]}, {"w": "can", "b": [0.7575, 0.2085, 0.7869, 0.2299]}, {"w": "fit", "b": [0.7925, 0.2085, 0.8106, 0.2299]}, {"w": "non‐", "b": [0.8163, 0.2085, 0.8571, 0.2299]}, {"w": "linear", "b": [0.1429, 0.2275, 0.1908, 0.2489]}, {"w": "datasets.", "b": [0.1983, 0.2275, 0.2688, 0.2489]}, {"w": "Since", "b": [0.2762, 0.2275, 0.3207, 0.2489]}, {"w": "this", "b": [0.3282, 0.2275, 0.3589, 0.2489]}, {"w": "model", "b": [0.3663, 0.2275, 0.4191, 0.2489]}, {"w": "has", "b": [0.4266, 0.2275, 0.4545, 0.2489]}, {"w": "more", "b": [0.4619, 0.2275, 0.5062, 0.2489]}, {"w": "parameters", "b": [0.5136, 0.2275, 0.6071, 0.2489]}, {"w": "than", "b": [0.6145, 0.2275, 0.6525, 0.2489]}, {"w": "Linear", "b": [0.66, 0.2275, 0.7139, 0.2489]}, {"w": "Regression,", "b": [0.7213, 0.2275, 0.8171, 0.2489]}, {"w": "it", "b": [0.8245, 0.2275, 0.8365, 0.2489]}, {"w": "is", "b": [0.8439, 0.2275, 0.8571, 0.2489]}, {"w": "more", "b": [0.1428, 0.2466, 0.1871, 0.268]}, {"w": "prone", "b": [0.1929, 0.2466, 0.2424, 0.268]}, {"w": "to", "b": [0.2482, 0.2466, 0.2652, 0.268]}, {"w": "overfitting", "b": [0.271, 0.2466, 0.359, 0.268]}, {"w": "the", "b": [0.3648, 0.2466, 0.3912, 0.268]}, {"w": "training", "b": [0.397, 0.2466, 0.4639, 0.268]}, {"w": "data,", "b": [0.4697, 0.2466, 0.5097, 0.268]}, {"w": "so", "b": [0.5155, 0.2466, 0.5338, 0.268]}, {"w": "we", "b": [0.5396, 0.2466, 0.5627, 0.268]}, {"w": "will", "b": [0.5685, 0.2466, 0.5989, 0.268]}, {"w": "look", "b": [0.6047, 0.2466, 0.6415, 0.268]}, {"w": "at", "b": [0.6473, 0.2466, 0.6624, 0.268]}, {"w": "how", "b": [0.6682, 0.2466, 0.7042, 0.268]}, {"w": "to", "b": [0.71, 0.2466, 0.727, 0.268]}, {"w": "detect", "b": [0.7328, 0.2466, 0.783, 0.268]}, {"w": "whether", "b": [0.7888, 0.2466, 0.8571, 0.268]}, {"w": "or", "b": [0.1429, 0.2656, 0.1612, 0.287]}, {"w": "not", "b": [0.1662, 0.2656, 0.1946, 0.287]}, {"w": "this", "b": [0.1996, 0.2656, 0.2303, 0.287]}, {"w": "is", "b": [0.2353, 0.2656, 0.2485, 0.287]}, {"w": "the", "b": [0.2535, 0.2656, 0.2799, 0.287]}, {"w": "case,", "b": [0.2849, 0.2656, 0.3241, 0.287]}, {"w": "using", "b": [0.3291, 0.2656, 0.3745, 0.287]}, {"w": "learning", "b": [0.3795, 0.2656, 0.4486, 0.287]}, {"w": "curves,", "b": [0.4536, 0.2656, 0.5127, 0.287]}, {"w": "and", "b": [0.5177, 0.2656, 0.5493, 0.287]}, {"w": "then", "b": [0.5543, 0.2656, 0.592, 0.287]}, {"w": "we", "b": [0.597, 0.2656, 0.6201, 0.287]}, {"w": "will", "b": [0.6251, 0.2656, 0.6555, 0.287]}, {"w": "look", "b": [0.6605, 0.2656, 0.6974, 0.287]}, {"w": "at", "b": [0.7024, 0.2656, 0.7175, 0.287]}, {"w": "several", "b": [0.7225, 0.2656, 0.7796, 0.287]}, {"w": "regulari‐", "b": [0.7846, 0.2656, 0.8571, 0.287]}, {"w": "zation", "b": [0.1429, 0.2847, 0.1943, 0.3061]}, {"w": "techniques", "b": [0.199, 0.2847, 0.2894, 0.3061]}, {"w": "that", "b": [0.2941, 0.2847, 0.3267, 0.3061]}, {"w": "can", "b": [0.3314, 0.2847, 0.3608, 0.3061]}, {"w": "reduce", "b": [0.3655, 0.2847, 0.4218, 0.3061]}, {"w": "the", "b": [0.4265, 0.2847, 0.4529, 0.3061]}, {"w": "risk", "b": [0.4576, 0.2847, 0.4889, 0.3061]}, {"w": "of", "b": [0.4936, 0.2847, 0.5104, 0.3061]}, {"w": "overfitting", "b": [0.5151, 0.2847, 0.6032, 0.3061]}, {"w": "the", "b": [0.6079, 0.2847, 0.6343, 0.3061]}, {"w": "training", "b": [0.639, 0.2847, 0.7059, 0.3061]}, {"w": "set.", "b": [0.7106, 0.2847, 0.7383, 0.3061]}]}, {"id": "b_2", "type": "paragraph", "text": "Finally, we will look at two more models that are commonly used for classification tasks: Logistic Regression and Softmax Regression.", "words": [{"w": "Finally,", "b": [0.1429, 0.3128, 0.2033, 0.3342]}, {"w": "we", "b": [0.2105, 0.3128, 0.2336, 0.3342]}, {"w": "will", "b": [0.2408, 0.3128, 0.2712, 0.3342]}, {"w": "look", "b": [0.2784, 0.3128, 0.3152, 0.3342]}, {"w": "at", "b": [0.3224, 0.3128, 0.3375, 0.3342]}, {"w": "two", "b": [0.3446, 0.3128, 0.3759, 0.3342]}, {"w": "more", "b": [0.3831, 0.3128, 0.4273, 0.3342]}, {"w": "models", "b": [0.4345, 0.3128, 0.495, 0.3342]}, {"w": "that", "b": [0.5021, 0.3128, 0.5347, 0.3342]}, {"w": "are", "b": [0.5419, 0.3128, 0.5676, 0.3342]}, {"w": "commonly", "b": [0.5748, 0.3128, 0.6652, 0.3342]}, {"w": "used", "b": [0.6724, 0.3128, 0.7109, 0.3342]}, {"w": "for", "b": [0.7181, 0.3128, 0.7426, 0.3342]}, {"w": "classification", "b": [0.7498, 0.3128, 0.8571, 0.3342]}, {"w": "tasks:", "b": [0.1429, 0.3318, 0.1887, 0.3532]}, {"w": "Logistic", "b": [0.1935, 0.3318, 0.259, 0.3532]}, {"w": "Regression", "b": [0.2637, 0.3318, 0.3548, 0.3532]}, {"w": "and", "b": [0.3595, 0.3318, 0.391, 0.3532]}, {"w": "Softmax", "b": [0.3958, 0.3318, 0.4648, 0.3532]}, {"w": "Regression.", "b": [0.4696, 0.3318, 0.5653, 0.3532]}]}, {"id": "b_3", "type": "paragraph", "text": "There will be quite a few math equations in this chapter, using basic notions of linear algebra and calculus. To understand these equa‐ tions, you will need to know what vectors and matrices are, how to transpose them, multiply them, and inverse them, and what partial derivatives are. If you are unfamiliar with these concepts, please go through the linear algebra and calculus introductory tutorials avail‐ able as Jupyter notebooks in the online supplemental material. For those who are truly allergic to mathematics, you should still go through this chapter and simply skip the equations; hopefully, the text will be sufficient to help you understand most of the concepts.", "words": [{"w": "There", "b": [0.2714, 0.3738, 0.3166, 0.3933]}, {"w": "will", "b": [0.3209, 0.3738, 0.3487, 0.3933]}, {"w": "be", "b": [0.353, 0.3738, 0.3708, 0.3933]}, {"w": "quite", "b": [0.3751, 0.3738, 0.414, 0.3933]}, {"w": "a", "b": [0.4183, 0.3738, 0.4267, 0.3933]}, {"w": "few", "b": [0.431, 0.3738, 0.4578, 0.3933]}, {"w": "math", "b": [0.4621, 0.3738, 0.5017, 0.3933]}, {"w": "equations", "b": [0.506, 0.3738, 0.58, 0.3933]}, {"w": "in", "b": [0.5843, 0.3738, 0.5998, 0.3933]}, {"w": "this", "b": [0.6041, 0.3738, 0.6322, 0.3933]}, {"w": "chapter,", "b": [0.6365, 0.3738, 0.6969, 0.3933]}, {"w": "using", "b": [0.7012, 0.3738, 0.7427, 0.3933]}, {"w": "basic", "b": [0.7471, 0.3738, 0.7853, 0.3933]}, {"w": "notions", "b": [0.2714, 0.3912, 0.3296, 0.4108]}, {"w": "of", "b": [0.336, 0.3912, 0.3514, 0.4108]}, {"w": "linear", "b": [0.3578, 0.3912, 0.4017, 0.4108]}, {"w": "algebra", "b": [0.4081, 0.3912, 0.4634, 0.4108]}, {"w": "and", "b": [0.4698, 0.3912, 0.4986, 0.4108]}, {"w": "calculus.", "b": [0.5051, 0.3912, 0.5708, 0.4108]}, {"w": "To", "b": [0.5772, 0.3912, 0.5968, 0.4108]}, {"w": "understand", "b": [0.6032, 0.3912, 0.6906, 0.4108]}, {"w": "these", "b": [0.697, 0.3912, 0.7362, 0.4108]}, {"w": "equa‐", "b": [0.7426, 0.3912, 0.7857, 0.4108]}, {"w": "tions,", "b": [0.2714, 0.4086, 0.3138, 0.4282]}, {"w": "you", "b": [0.3187, 0.4086, 0.3473, 0.4282]}, {"w": "will", "b": [0.3522, 0.4086, 0.38, 0.4282]}, {"w": "need", "b": [0.385, 0.4086, 0.4216, 0.4282]}, {"w": "to", "b": [0.4266, 0.4086, 0.4421, 0.4282]}, {"w": "know", "b": [0.447, 0.4086, 0.4897, 0.4282]}, {"w": "what", "b": [0.4946, 0.4086, 0.5316, 0.4282]}, {"w": "vectors", "b": [0.5366, 0.4086, 0.5911, 0.4282]}, {"w": "and", "b": [0.5961, 0.4086, 0.6249, 0.4282]}, {"w": "matrices", "b": [0.6298, 0.4086, 0.6946, 0.4282]}, {"w": "are,", "b": [0.6995, 0.4086, 0.7274, 0.4282]}, {"w": "how", "b": [0.7323, 0.4086, 0.7652, 0.4282]}, {"w": "to", "b": [0.7702, 0.4086, 0.7857, 0.4282]}, {"w": "transpose", "b": [0.2714, 0.426, 0.3448, 0.4456]}, {"w": "them,", "b": [0.3499, 0.426, 0.3939, 0.4456]}, {"w": "multiply", "b": [0.399, 0.426, 0.4637, 0.4456]}, {"w": "them,", "b": [0.4688, 0.426, 0.5128, 0.4456]}, {"w": "and", "b": [0.5179, 0.426, 0.5467, 0.4456]}, {"w": "inverse", "b": [0.5518, 0.426, 0.606, 0.4456]}, {"w": "them,", "b": [0.611, 0.426, 0.6551, 0.4456]}, {"w": "and", "b": [0.6602, 0.426, 0.689, 0.4456]}, {"w": "what", "b": [0.6941, 0.426, 0.7311, 0.4456]}, {"w": "partial", "b": [0.7362, 0.426, 0.7857, 0.4456]}, {"w": "derivatives", "b": [0.2714, 0.4434, 0.3534, 0.463]}, {"w": "are.", "b": [0.3584, 0.4434, 0.3862, 0.463]}, {"w": "If", "b": [0.3912, 0.4434, 0.4034, 0.463]}, {"w": "you", "b": [0.4083, 0.4434, 0.4369, 0.463]}, {"w": "are", "b": [0.4419, 0.4434, 0.4654, 0.463]}, {"w": "unfamiliar", "b": [0.4704, 0.4434, 0.551, 0.463]}, {"w": "with", "b": [0.556, 0.4434, 0.5901, 0.463]}, {"w": "these", "b": [0.5951, 0.4434, 0.6343, 0.463]}, {"w": "concepts,", "b": [0.6393, 0.4434, 0.7108, 0.463]}, {"w": "please", "b": [0.7157, 0.4434, 0.7621, 0.463]}, {"w": "go", "b": [0.7671, 0.4434, 0.7857, 0.463]}, {"w": "through", "b": [0.2714, 0.4608, 0.3334, 0.4804]}, {"w": "the", "b": [0.3378, 0.4608, 0.3619, 0.4804]}, {"w": "linear", "b": [0.3663, 0.4608, 0.4102, 0.4804]}, {"w": "algebra", "b": [0.4146, 0.4608, 0.4699, 0.4804]}, {"w": "and", "b": [0.4743, 0.4608, 0.5031, 0.4804]}, {"w": "calculus", "b": [0.5076, 0.4608, 0.5689, 0.4804]}, {"w": "introductory", "b": [0.5733, 0.4608, 0.6712, 0.4804]}, {"w": "tutorials", "b": [0.6756, 0.4608, 0.7394, 0.4804]}, {"w": "avail‐", "b": [0.7438, 0.4608, 0.7857, 0.4804]}, {"w": "able", "b": [0.2714, 0.4783, 0.3024, 0.4978]}, {"w": "as", "b": [0.3077, 0.4783, 0.3231, 0.4978]}, {"w": "Jupyter", "b": [0.3285, 0.4783, 0.3839, 0.4978]}, {"w": "notebooks", "b": [0.3893, 0.4783, 0.4689, 0.4978]}, {"w": "in", "b": [0.4743, 0.4783, 0.4898, 0.4978]}, {"w": "the", "b": [0.4952, 0.4783, 0.5192, 0.4978]}, {"w": "online", "b": [0.5246, 0.4783, 0.5732, 0.4978]}, {"w": "supplemental", "b": [0.5785, 0.4783, 0.6813, 0.4978]}, {"w": "material.", "b": [0.6866, 0.4783, 0.7538, 0.4978]}, {"w": "For", "b": [0.7592, 0.4783, 0.7857, 0.4978]}, {"w": "those", "b": [0.2714, 0.4957, 0.3122, 0.5152]}, {"w": "who", "b": [0.3203, 0.4957, 0.3533, 0.5152]}, {"w": "are", "b": [0.3614, 0.4957, 0.385, 0.5152]}, {"w": "truly", "b": [0.3931, 0.4957, 0.4297, 0.5152]}, {"w": "allergic", "b": [0.4378, 0.4957, 0.4931, 0.5152]}, {"w": "to", "b": [0.5012, 0.4957, 0.5167, 0.5152]}, {"w": "mathematics,", "b": [0.5249, 0.4957, 0.6265, 0.5152]}, {"w": "you", "b": [0.6346, 0.4957, 0.6632, 0.5152]}, {"w": "should", "b": [0.6714, 0.4957, 0.7232, 0.5152]}, {"w": "still", "b": [0.7314, 0.4957, 0.7589, 0.5152]}, {"w": "go", "b": [0.7671, 0.4957, 0.7857, 0.5152]}, {"w": "through", "b": [0.2714, 0.5131, 0.3334, 0.5327]}, {"w": "this", "b": [0.3394, 0.5131, 0.3675, 0.5327]}, {"w": "chapter", "b": [0.3735, 0.5131, 0.4307, 0.5327]}, {"w": "and", "b": [0.4367, 0.5131, 0.4656, 0.5327]}, {"w": "simply", "b": [0.4716, 0.5131, 0.5225, 0.5327]}, {"w": "skip", "b": [0.5285, 0.5131, 0.56, 0.5327]}, {"w": "the", "b": [0.5661, 0.5131, 0.5902, 0.5327]}, {"w": "equations;", "b": [0.5962, 0.5131, 0.6745, 0.5327]}, {"w": "hopefully,", "b": [0.6806, 0.5131, 0.7556, 0.5327]}, {"w": "the", "b": [0.7616, 0.5131, 0.7857, 0.5327]}, {"w": "text", "b": [0.2714, 0.5305, 0.3001, 0.5501]}, {"w": "will", "b": [0.3044, 0.5305, 0.3322, 0.5501]}, {"w": "be", "b": [0.3366, 0.5305, 0.3543, 0.5501]}, {"w": "sufficient", "b": [0.3586, 0.5305, 0.4293, 0.5501]}, {"w": "to", "b": [0.4336, 0.5305, 0.4491, 0.5501]}, {"w": "help", "b": [0.4534, 0.5305, 0.4865, 0.5501]}, {"w": "you", "b": [0.4908, 0.5305, 0.5194, 0.5501]}, {"w": "understand", "b": [0.5237, 0.5305, 0.6111, 0.5501]}, {"w": "most", "b": [0.6154, 0.5305, 0.6535, 0.5501]}, {"w": "of", "b": [0.6579, 0.5305, 0.6732, 0.5501]}, {"w": "the", "b": [0.6775, 0.5305, 0.7016, 0.5501]}, {"w": "concepts.", "b": [0.7059, 0.5305, 0.7774, 0.5501]}]}, {"id": "b_4", "type": "paragraph", "text": "Linear Regression", "words": [{"w": "Linear", "b": [0.1428, 0.5666, 0.2204, 0.6008]}, {"w": "Regression", "b": [0.2263, 0.5666, 0.3612, 0.6008]}]}, {"id": "b_5", "type": "paragraph", "text": "In Chapter 1, we looked at a simple regression model of life satisfaction: life_satisfac‐ tion = θ0 + θ1 × GDP_per_capita.", "words": [{"w": "In", "b": [0.1429, 0.6077, 0.1614, 0.6292]}, {"w": "Chapter", "b": [0.167, 0.6077, 0.2346, 0.6292]}, {"w": "1,", "b": [0.2403, 0.6077, 0.255, 0.6292]}, {"w": "we", "b": [0.2607, 0.6077, 0.2838, 0.6292]}, {"w": "looked", "b": [0.2895, 0.6077, 0.3462, 0.6292]}, {"w": "at", "b": [0.3518, 0.6077, 0.3669, 0.6292]}, {"w": "a", "b": [0.3726, 0.6077, 0.3818, 0.6292]}, {"w": "simple", "b": [0.3874, 0.6077, 0.4424, 0.6292]}, {"w": "regression", "b": [0.448, 0.6077, 0.5338, 0.6292]}, {"w": "model", "b": [0.5395, 0.6077, 0.5923, 0.6292]}, {"w": "of", "b": [0.598, 0.6077, 0.6148, 0.6292]}, {"w": "life", "b": [0.6204, 0.6077, 0.6463, 0.6292]}, {"w": "satisfaction:", "b": [0.652, 0.6077, 0.7508, 0.6292]}, {"w": "life_satisfac‐", "b": [0.7565, 0.6075, 0.8571, 0.6292]}, {"w": "tion", "b": [0.1429, 0.6266, 0.1753, 0.6482]}, {"w": "=", "b": [0.1801, 0.6268, 0.1922, 0.6482]}, {"w": "θ0", "b": [0.1969, 0.6266, 0.2128, 0.6491]}, {"w": "+", "b": [0.2175, 0.6268, 0.2296, 0.6482]}, {"w": "θ1", "b": [0.2344, 0.6266, 0.2503, 0.6491]}, {"w": "×", "b": [0.255, 0.6268, 0.2671, 0.6482]}, {"w": "GDP_per_capita.", "b": [0.2718, 0.6266, 0.4131, 0.6482]}]}, {"id": "b_6", "type": "paragraph", "text": "This model is just a linear function of the input feature GDP_per_capita. θ0 and θ1 are the model’s parameters.", "words": [{"w": "This", "b": [0.1429, 0.6558, 0.1801, 0.6772]}, {"w": "model", "b": [0.185, 0.6558, 0.2378, 0.6772]}, {"w": "is", "b": [0.2427, 0.6558, 0.256, 0.6772]}, {"w": "just", "b": [0.2609, 0.6558, 0.2913, 0.6772]}, {"w": "a", "b": [0.2962, 0.6558, 0.3053, 0.6772]}, {"w": "linear", "b": [0.3103, 0.6558, 0.3582, 0.6772]}, {"w": "function", "b": [0.3632, 0.6558, 0.4346, 0.6772]}, {"w": "of", "b": [0.4395, 0.6558, 0.4563, 0.6772]}, {"w": "the", "b": [0.4612, 0.6558, 0.4875, 0.6772]}, {"w": "input", "b": [0.4925, 0.6558, 0.5374, 0.6772]}, {"w": "feature", "b": [0.5423, 0.6558, 0.6001, 0.6772]}, {"w": "GDP_per_capita.", "b": [0.605, 0.6558, 0.7483, 0.6772]}, {"w": "θ0", "b": [0.7532, 0.6556, 0.7692, 0.6781]}, {"w": "and", "b": [0.7741, 0.6558, 0.8056, 0.6772]}, {"w": "θ1", "b": [0.8106, 0.6556, 0.8265, 0.6781]}, {"w": "are", "b": [0.8314, 0.6558, 0.8571, 0.6772]}, {"w": "the", "b": [0.1429, 0.6749, 0.1692, 0.6963]}, {"w": "model’s", "b": [0.1739, 0.6749, 0.2365, 0.6963]}, {"w": "parameters.", "b": [0.2412, 0.6749, 0.3394, 0.6963]}]}, {"id": "b_7", "type": "paragraph", "text": "More generally, a linear model makes a prediction by simply computing a weighted sum of the input features, plus a constant called the bias term (also called the intercept term), as shown in Equation 4-1.", "words": [{"w": "More", "b": [0.1429, 0.703, 0.1881, 0.7244]}, {"w": "generally,", "b": [0.1947, 0.703, 0.2738, 0.7244]}, {"w": "a", "b": [0.2804, 0.703, 0.2896, 0.7244]}, {"w": "linear", "b": [0.2962, 0.703, 0.3442, 0.7244]}, {"w": "model", "b": [0.3508, 0.703, 0.4036, 0.7244]}, {"w": "makes", "b": [0.4102, 0.703, 0.4633, 0.7244]}, {"w": "a", "b": [0.4699, 0.703, 0.479, 0.7244]}, {"w": "prediction", "b": [0.4857, 0.703, 0.5725, 0.7244]}, {"w": "by", "b": [0.5791, 0.703, 0.5993, 0.7244]}, {"w": "simply", "b": [0.6059, 0.703, 0.6616, 0.7244]}, {"w": "computing", "b": [0.6682, 0.703, 0.7594, 0.7244]}, {"w": "a", "b": [0.766, 0.703, 0.7751, 0.7244]}, {"w": "weighted", "b": [0.7818, 0.703, 0.8572, 0.7244]}, {"w": "sum", "b": [0.1429, 0.722, 0.1786, 0.7434]}, {"w": "of", "b": [0.1836, 0.722, 0.2004, 0.7434]}, {"w": "the", "b": [0.2053, 0.722, 0.2316, 0.7434]}, {"w": "input", "b": [0.2366, 0.722, 0.2815, 0.7434]}, {"w": "features,", "b": [0.2864, 0.722, 0.3566, 0.7434]}, {"w": "plus", "b": [0.3615, 0.722, 0.3964, 0.7434]}, {"w": "a", "b": [0.4013, 0.722, 0.4105, 0.7434]}, {"w": "constant", "b": [0.4154, 0.722, 0.4868, 0.7434]}, {"w": "called", "b": [0.4917, 0.722, 0.54, 0.7434]}, {"w": "the", "b": [0.545, 0.722, 0.5713, 0.7434]}, {"w": "bias", "b": [0.5762, 0.7218, 0.609, 0.7434]}, {"w": "term", "b": [0.6138, 0.7218, 0.6525, 0.7434]}, {"w": "(also", "b": [0.6576, 0.722, 0.6975, 0.7434]}, {"w": "called", "b": [0.7022, 0.722, 0.7506, 0.7434]}, {"w": "the", "b": [0.7553, 0.722, 0.7817, 0.7434]}, {"w": "intercept", "b": [0.787, 0.7218, 0.8571, 0.7434]}, {"w": "term),", "b": [0.1429, 0.7409, 0.1935, 0.7625]}, {"w": "as", "b": [0.1983, 0.7411, 0.2151, 0.7625]}, {"w": "shown", "b": [0.2198, 0.7411, 0.2749, 0.7625]}, {"w": "in", "b": [0.2796, 0.7411, 0.2966, 0.7625]}, {"w": "Equation", "b": [0.3013, 0.7411, 0.3775, 0.7625]}, {"w": "4-1.", "b": [0.3823, 0.7411, 0.4144, 0.7625]}]}, {"id": "b_8", "type": "equation", "text": "Equation 4-1. Linear Regression model prediction", "words": [{"w": "Equation", "b": [0.1726, 0.7806, 0.2473, 0.8022]}, {"w": "4-1.", "b": [0.2521, 0.7806, 0.2838, 0.8022]}, {"w": "Linear", "b": [0.2886, 0.7806, 0.3412, 0.8022]}, {"w": "Regression", "b": [0.346, 0.7806, 0.4307, 0.8022]}, {"w": "model", "b": [0.4355, 0.7806, 0.4852, 0.8022]}, {"w": "prediction", "b": [0.4899, 0.7806, 0.5717, 0.8022]}]}, {"id": "b_9", "type": "equation", "text": "y = θ0 + θ1x1 + θ2x2 + ⋯+ θnxn", "words": [{"w": "y", "b": [0.1738, 0.8092, 0.1825, 0.8298]}, {"w": "=", "b": [0.1894, 0.8094, 0.2009, 0.8298]}, {"w": "θ0", "b": [0.2064, 0.8092, 0.2235, 0.8341]}, {"w": "+", "b": [0.2279, 0.8094, 0.2394, 0.8298]}, {"w": "θ1x1", "b": [0.2438, 0.8092, 0.2779, 0.8341]}, {"w": "+", "b": [0.2823, 0.8094, 0.2938, 0.8298]}, {"w": "θ2x2", "b": [0.2982, 0.8092, 0.3323, 0.8341]}, {"w": "+", "b": [0.3367, 0.8094, 0.3482, 0.8298]}, {"w": "⋯+", "b": [0.3526, 0.8094, 0.3884, 0.8298]}, {"w": "θnxn", "b": [0.3928, 0.8092, 0.4285, 0.8341]}]}, {"id": "b_10", "type": "paragraph", "text": "• ŷ is the predicted value.", "words": [{"w": "•", "b": [0.16, 0.8592, 0.1682, 0.8806]}, {"w": "ŷ", "b": [0.1786, 0.859, 0.1878, 0.8806]}, {"w": "is", "b": [0.1925, 0.8592, 0.2057, 0.8806]}, {"w": "the", "b": [0.2105, 0.8592, 0.2368, 0.8806]}, {"w": "predicted", "b": [0.2415, 0.8592, 0.3206, 0.8806]}, {"w": "value.", "b": [0.3254, 0.8592, 0.3741, 0.8806]}]}, {"id": "b_11", "type": "paragraph", "text": "114 | Chapter 4: Training Models", "words": [{"w": "114", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 141, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• n is the number of features.", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "n", "b": [0.1786, 0.0789, 0.1896, 0.1005]}, {"w": "is", "b": [0.1944, 0.0791, 0.2076, 0.1005]}, {"w": "the", "b": [0.2123, 0.0791, 0.2387, 0.1005]}, {"w": "number", "b": [0.2434, 0.0791, 0.3097, 0.1005]}, {"w": "of", "b": [0.3144, 0.0791, 0.3312, 0.1005]}, {"w": "features.", "b": [0.3359, 0.0791, 0.4061, 0.1005]}]}, {"id": "b_1", "type": "paragraph", "text": "• xi is the ith feature value.", "words": [{"w": "•", "b": [0.16, 0.1042, 0.1682, 0.1256]}, {"w": "xi", "b": [0.1786, 0.1039, 0.1918, 0.1265]}, {"w": "is", "b": [0.1965, 0.1042, 0.2097, 0.1256]}, {"w": "the", "b": [0.2145, 0.1042, 0.2408, 0.1256]}, {"w": "ith", "b": [0.2455, 0.1042, 0.2616, 0.1256]}, {"w": "feature", "b": [0.2663, 0.1042, 0.3241, 0.1256]}, {"w": "value.", "b": [0.3288, 0.1042, 0.3775, 0.1256]}]}, {"id": "b_2", "type": "paragraph", "text": "• θj is the jth model parameter (including the bias term θ0 and the feature weights θ1, θ2, ⋯, θn).", "words": [{"w": "•", "b": [0.16, 0.1293, 0.1682, 0.1507]}, {"w": "θj", "b": [0.1786, 0.129, 0.1918, 0.1516]}, {"w": "is", "b": [0.1983, 0.1293, 0.2115, 0.1507]}, {"w": "the", "b": [0.2179, 0.1293, 0.2443, 0.1507]}, {"w": "jth", "b": [0.2507, 0.1293, 0.2665, 0.1507]}, {"w": "model", "b": [0.273, 0.1293, 0.3258, 0.1507]}, {"w": "parameter", "b": [0.3322, 0.1293, 0.418, 0.1507]}, {"w": "(including", "b": [0.4245, 0.1293, 0.5115, 0.1507]}, {"w": "the", "b": [0.518, 0.1293, 0.5443, 0.1507]}, {"w": "bias", "b": [0.5508, 0.1293, 0.5837, 0.1507]}, {"w": "term", "b": [0.5902, 0.1293, 0.6302, 0.1507]}, {"w": "θ0", "b": [0.6366, 0.129, 0.6525, 0.1516]}, {"w": "and", "b": [0.659, 0.1293, 0.6905, 0.1507]}, {"w": "the", "b": [0.697, 0.1293, 0.7233, 0.1507]}, {"w": "feature", "b": [0.7297, 0.1293, 0.7875, 0.1507]}, {"w": "weights", "b": [0.794, 0.1293, 0.8571, 0.1507]}, {"w": "θ1,", "b": [0.1786, 0.1481, 0.1993, 0.1706]}, {"w": "θ2,", "b": [0.204, 0.1481, 0.2247, 0.1706]}, {"w": "⋯,", "b": [0.2294, 0.1483, 0.255, 0.1697]}, {"w": "θn).", "b": [0.2597, 0.1481, 0.2883, 0.1706]}]}, {"id": "b_3", "type": "paragraph", "text": "This can be written much more concisely using a vectorized form, as shown in Equa‐ tion 4-2.", "words": [{"w": "This", "b": [0.1429, 0.1825, 0.1801, 0.2039]}, {"w": "can", "b": [0.1853, 0.1825, 0.2146, 0.2039]}, {"w": "be", "b": [0.2199, 0.1825, 0.2393, 0.2039]}, {"w": "written", "b": [0.2445, 0.1825, 0.3051, 0.2039]}, {"w": "much", "b": [0.3103, 0.1825, 0.358, 0.2039]}, {"w": "more", "b": [0.3632, 0.1825, 0.4075, 0.2039]}, {"w": "concisely", "b": [0.4127, 0.1825, 0.4893, 0.2039]}, {"w": "using", "b": [0.4945, 0.1825, 0.5399, 0.2039]}, {"w": "a", "b": [0.5451, 0.1825, 0.5543, 0.2039]}, {"w": "vectorized", "b": [0.5595, 0.1825, 0.6457, 0.2039]}, {"w": "form,", "b": [0.651, 0.1825, 0.6973, 0.2039]}, {"w": "as", "b": [0.7025, 0.1825, 0.7193, 0.2039]}, {"w": "shown", "b": [0.7245, 0.1825, 0.7796, 0.2039]}, {"w": "in", "b": [0.7848, 0.1825, 0.8018, 0.2039]}, {"w": "Equa‐", "b": [0.807, 0.1825, 0.8571, 0.2039]}, {"w": "tion", "b": [0.1429, 0.2015, 0.1768, 0.2229]}, {"w": "4-2.", "b": [0.1816, 0.2015, 0.2137, 0.2229]}]}, {"id": "b_4", "type": "equation", "text": "Equation 4-2. Linear Regression model prediction (vectorized form)", "words": [{"w": "Equation", "b": [0.1726, 0.241, 0.2473, 0.2627]}, {"w": "4-2.", "b": [0.2521, 0.241, 0.2838, 0.2627]}, {"w": "Linear", "b": [0.2886, 0.241, 0.3412, 0.2627]}, {"w": "Regression", "b": [0.346, 0.241, 0.4307, 0.2627]}, {"w": "model", "b": [0.4355, 0.241, 0.4852, 0.2627]}, {"w": "prediction", "b": [0.4899, 0.241, 0.5717, 0.2627]}, {"w": "(vectorized", "b": [0.5765, 0.241, 0.6658, 0.2627]}, {"w": "form)", "b": [0.6706, 0.241, 0.7168, 0.2627]}]}, {"id": "b_5", "type": "equation", "text": "y = hθ x = θ · x", "words": [{"w": "y", "b": [0.1737, 0.2703, 0.1825, 0.2909]}, {"w": "=", "b": [0.1894, 0.2705, 0.2009, 0.2909]}, {"w": "hθ", "b": [0.2064, 0.2703, 0.2246, 0.2952]}, {"w": "x", "b": [0.2315, 0.27, 0.241, 0.2909]}, {"w": "=", "b": [0.2535, 0.2705, 0.265, 0.2909]}, {"w": "θ", "b": [0.2705, 0.27, 0.2806, 0.2909]}, {"w": "·", "b": [0.285, 0.2705, 0.2895, 0.2909]}, {"w": "x", "b": [0.2939, 0.27, 0.3035, 0.2909]}]}, {"id": "b_6", "type": "paragraph", "text": "• θ is the model’s parameter vector, containing the bias term θ0 and the feature weights θ1 to θn.", "words": [{"w": "•", "b": [0.16, 0.3203, 0.1682, 0.3417]}, {"w": "θ", "b": [0.1786, 0.3197, 0.1892, 0.3417]}, {"w": "is", "b": [0.1975, 0.3203, 0.2107, 0.3417]}, {"w": "the", "b": [0.219, 0.3203, 0.2454, 0.3417]}, {"w": "model’s", "b": [0.2537, 0.3203, 0.3162, 0.3417]}, {"w": "parameter", "b": [0.3246, 0.3201, 0.4082, 0.3417]}, {"w": "vector,", "b": [0.4165, 0.3201, 0.4701, 0.3417]}, {"w": "containing", "b": [0.4784, 0.3203, 0.5681, 0.3417]}, {"w": "the", "b": [0.5764, 0.3203, 0.6027, 0.3417]}, {"w": "bias", "b": [0.611, 0.3203, 0.644, 0.3417]}, {"w": "term", "b": [0.6523, 0.3203, 0.6923, 0.3417]}, {"w": "θ0", "b": [0.7006, 0.3201, 0.7166, 0.3426]}, {"w": "and", "b": [0.7249, 0.3203, 0.7564, 0.3417]}, {"w": "the", "b": [0.7647, 0.3203, 0.7911, 0.3417]}, {"w": "feature", "b": [0.7994, 0.3203, 0.8571, 0.3417]}, {"w": "weights", "b": [0.1786, 0.3393, 0.2418, 0.3608]}, {"w": "θ1", "b": [0.2465, 0.3391, 0.2624, 0.3616]}, {"w": "to", "b": [0.2672, 0.3393, 0.2841, 0.3608]}, {"w": "θn.", "b": [0.2889, 0.3391, 0.3104, 0.3616]}]}, {"id": "b_7", "type": "paragraph", "text": "• x is the instance’s feature vector, containing x0 to xn, with x0 always equal to 1.", "words": [{"w": "•", "b": [0.16, 0.3644, 0.1681, 0.3858]}, {"w": "x", "b": [0.1786, 0.3639, 0.1886, 0.3858]}, {"w": "is", "b": [0.1933, 0.3644, 0.2066, 0.3858]}, {"w": "the", "b": [0.2113, 0.3644, 0.2376, 0.3858]}, {"w": "instance’s", "b": [0.2424, 0.3644, 0.3206, 0.3858]}, {"w": "feature", "b": [0.3254, 0.3642, 0.3814, 0.3858]}, {"w": "vector,", "b": [0.3861, 0.3642, 0.4398, 0.3858]}, {"w": "containing", "b": [0.4445, 0.3644, 0.5341, 0.3858]}, {"w": "x0", "b": [0.5389, 0.3642, 0.5547, 0.3867]}, {"w": "to", "b": [0.5595, 0.3644, 0.5764, 0.3858]}, {"w": "xn,", "b": [0.5812, 0.3642, 0.6024, 0.3867]}, {"w": "with", "b": [0.6072, 0.3644, 0.6445, 0.3858]}, {"w": "x0", "b": [0.6492, 0.3642, 0.6651, 0.3867]}, {"w": "always", "b": [0.6698, 0.3644, 0.7245, 0.3858]}, {"w": "equal", "b": [0.7292, 0.3644, 0.7742, 0.3858]}, {"w": "to", "b": [0.7789, 0.3644, 0.7959, 0.3858]}, {"w": "1.", "b": [0.8006, 0.3644, 0.8154, 0.3858]}]}, {"id": "b_8", "type": "paragraph", "text": "• θ · x is the dot product of the vectors θ and x, which is of course equal to θ0x0 + θ1x1 + θ2x2 + ⋯+ θnxn.", "words": [{"w": "•", "b": [0.16, 0.3895, 0.1682, 0.4109]}, {"w": "θ", "b": [0.1786, 0.389, 0.1892, 0.4109]}, {"w": "·", "b": [0.1982, 0.3895, 0.2029, 0.4109]}, {"w": "x", "b": [0.2119, 0.389, 0.2219, 0.4109]}, {"w": "is", "b": [0.2309, 0.3895, 0.2441, 0.4109]}, {"w": "the", "b": [0.2531, 0.3895, 0.2794, 0.4109]}, {"w": "dot", "b": [0.2884, 0.3895, 0.3164, 0.4109]}, {"w": "product", "b": [0.3254, 0.3895, 0.3919, 0.4109]}, {"w": "of", "b": [0.4009, 0.3895, 0.4177, 0.4109]}, {"w": "the", "b": [0.4267, 0.3895, 0.453, 0.4109]}, {"w": "vectors", "b": [0.462, 0.3895, 0.5217, 0.4109]}, {"w": "θ", "b": [0.5307, 0.389, 0.5413, 0.4109]}, {"w": "and", "b": [0.5502, 0.3895, 0.5818, 0.4109]}, {"w": "x,", "b": [0.5908, 0.389, 0.6056, 0.4109]}, {"w": "which", "b": [0.6146, 0.3895, 0.6655, 0.4109]}, {"w": "is", "b": [0.6745, 0.3895, 0.6877, 0.4109]}, {"w": "of", "b": [0.6967, 0.3895, 0.7135, 0.4109]}, {"w": "course", "b": [0.7225, 0.3895, 0.7772, 0.4109]}, {"w": "equal", "b": [0.7862, 0.3895, 0.8312, 0.4109]}, {"w": "to", "b": [0.8402, 0.3895, 0.8571, 0.4109]}, {"w": "θ0x0", "b": [0.1786, 0.4084, 0.2136, 0.4338]}, {"w": "+", "b": [0.2182, 0.4086, 0.2303, 0.43]}, {"w": "θ1x1", "b": [0.2349, 0.4084, 0.27, 0.4338]}, {"w": "+", "b": [0.2746, 0.4086, 0.2867, 0.43]}, {"w": "θ2x2", "b": [0.2913, 0.4084, 0.3263, 0.4338]}, {"w": "+", "b": [0.331, 0.4086, 0.343, 0.43]}, {"w": "⋯+", "b": [0.3477, 0.4086, 0.3852, 0.43]}, {"w": "θnxn.", "b": [0.3899, 0.4084, 0.4313, 0.4338]}]}, {"id": "b_9", "type": "paragraph", "text": "• hθ is the hypothesis function, using the model parameters θ.", "words": [{"w": "•", "b": [0.16, 0.4362, 0.1681, 0.4577]}, {"w": "hθ", "b": [0.1786, 0.436, 0.1956, 0.4585]}, {"w": "is", "b": [0.2003, 0.4362, 0.2135, 0.4577]}, {"w": "the", "b": [0.2183, 0.4362, 0.2446, 0.4577]}, {"w": "hypothesis", "b": [0.2493, 0.4362, 0.3383, 0.4577]}, {"w": "function,", "b": [0.343, 0.4362, 0.4192, 0.4577]}, {"w": "using", "b": [0.4239, 0.4362, 0.4693, 0.4577]}, {"w": "the", "b": [0.4741, 0.4362, 0.5004, 0.4577]}, {"w": "model", "b": [0.5051, 0.4362, 0.5579, 0.4577]}, {"w": "parameters", "b": [0.5627, 0.4362, 0.6561, 0.4577]}, {"w": "θ.", "b": [0.6608, 0.4357, 0.6762, 0.4577]}]}, {"id": "b_10", "type": "paragraph", "text": "In Machine Learning, vectors are often represented as column vec‐ tors, which are 2D arrays with a single column. If θ and x are col‐ umn vectors, then the prediction is: y = θTx, where θT is the transpose of θ (a row vector instead of a column vector) and θTx is the matrix multiplication of θT and x. It is of course the same pre‐ diction, except it is now represented as a single cell matrix rather than a scalar value. In this book we will use this notation to avoid switching between dot products and matrix multiplications.", "words": [{"w": "In", "b": [0.2714, 0.4933, 0.2883, 0.5129]}, {"w": "Machine", "b": [0.2939, 0.4933, 0.3608, 0.5129]}, {"w": "Learning,", "b": [0.3664, 0.4933, 0.4393, 0.5129]}, {"w": "vectors", "b": [0.4449, 0.4933, 0.4995, 0.5129]}, {"w": "are", "b": [0.5051, 0.4933, 0.5286, 0.5129]}, {"w": "often", "b": [0.5342, 0.4933, 0.5739, 0.5129]}, {"w": "represented", "b": [0.5795, 0.4933, 0.6689, 0.5129]}, {"w": "as", "b": [0.6745, 0.4933, 0.6898, 0.5129]}, {"w": "column", "b": [0.6954, 0.4931, 0.7505, 0.5129]}, {"w": "vec‐", "b": [0.7561, 0.4931, 0.7857, 0.5129]}, {"w": "tors,", "b": [0.2714, 0.5105, 0.3035, 0.5303]}, {"w": "which", "b": [0.3092, 0.5107, 0.3558, 0.5303]}, {"w": "are", "b": [0.3615, 0.5107, 0.385, 0.5303]}, {"w": "2D", "b": [0.3907, 0.5107, 0.4139, 0.5303]}, {"w": "arrays", "b": [0.4196, 0.5107, 0.4658, 0.5303]}, {"w": "with", "b": [0.4716, 0.5107, 0.5057, 0.5303]}, {"w": "a", "b": [0.5114, 0.5107, 0.5198, 0.5303]}, {"w": "single", "b": [0.5255, 0.5107, 0.5699, 0.5303]}, {"w": "column.", "b": [0.5756, 0.5107, 0.6386, 0.5303]}, {"w": "If", "b": [0.6444, 0.5107, 0.6565, 0.5303]}, {"w": "θ", "b": [0.6622, 0.5102, 0.6719, 0.5303]}, {"w": "and", "b": [0.6776, 0.5107, 0.7065, 0.5303]}, {"w": "x", "b": [0.7122, 0.5102, 0.7214, 0.5303]}, {"w": "are", "b": [0.7271, 0.5107, 0.7506, 0.5303]}, {"w": "col‐", "b": [0.7564, 0.5107, 0.7857, 0.5303]}, {"w": "umn", "b": [0.2714, 0.5315, 0.3076, 0.5511]}, {"w": "vectors,", "b": [0.3172, 0.5315, 0.3761, 0.5511]}, {"w": "then", "b": [0.3857, 0.5315, 0.4202, 0.5511]}, {"w": "the", "b": [0.4299, 0.5315, 0.4539, 0.5511]}, {"w": "prediction", "b": [0.4636, 0.5315, 0.543, 0.5511]}, {"w": "is:", "b": [0.5526, 0.5315, 0.5691, 0.5511]}, {"w": "y", "b": [0.5798, 0.5313, 0.5882, 0.5511]}, {"w": "=", "b": [0.5948, 0.5315, 0.6058, 0.5511]}, {"w": "θTx,", "b": [0.6111, 0.5269, 0.6446, 0.5511]}, {"w": "where", "b": [0.6543, 0.5315, 0.7008, 0.5511]}, {"w": "θT", "b": [0.7104, 0.5269, 0.7303, 0.5511]}, {"w": "is", "b": [0.7399, 0.5315, 0.752, 0.5511]}, {"w": "the", "b": [0.7616, 0.5315, 0.7857, 0.5511]}, {"w": "transpose", "b": [0.2714, 0.5521, 0.3412, 0.5719]}, {"w": "of", "b": [0.3463, 0.5523, 0.3616, 0.5719]}, {"w": "θ", "b": [0.3667, 0.5518, 0.3763, 0.5719]}, {"w": "(a", "b": [0.3814, 0.5523, 0.3963, 0.5719]}, {"w": "row", "b": [0.4014, 0.5523, 0.4312, 0.5719]}, {"w": "vector", "b": [0.4363, 0.5523, 0.4838, 0.5719]}, {"w": "instead", "b": [0.4889, 0.5523, 0.5437, 0.5719]}, {"w": "of", "b": [0.5488, 0.5523, 0.5641, 0.5719]}, {"w": "a", "b": [0.5691, 0.5523, 0.5775, 0.5719]}, {"w": "column", "b": [0.5826, 0.5523, 0.6413, 0.5719]}, {"w": "vector)", "b": [0.6463, 0.5523, 0.7005, 0.5719]}, {"w": "and", "b": [0.7055, 0.5523, 0.7344, 0.5719]}, {"w": "θTx", "b": [0.7394, 0.5477, 0.7685, 0.5719]}, {"w": "is", "b": [0.7736, 0.5523, 0.7857, 0.5719]}, {"w": "the", "b": [0.2714, 0.5731, 0.2955, 0.5927]}, {"w": "matrix", "b": [0.3009, 0.5731, 0.3514, 0.5927]}, {"w": "multiplication", "b": [0.3568, 0.5731, 0.4649, 0.5927]}, {"w": "of", "b": [0.4703, 0.5731, 0.4856, 0.5927]}, {"w": "θT", "b": [0.491, 0.5685, 0.5109, 0.5927]}, {"w": "and", "b": [0.5163, 0.5731, 0.5451, 0.5927]}, {"w": "x.", "b": [0.5505, 0.5726, 0.564, 0.5927]}, {"w": "It", "b": [0.5694, 0.5731, 0.5809, 0.5927]}, {"w": "is", "b": [0.5863, 0.5731, 0.5984, 0.5927]}, {"w": "of", "b": [0.6038, 0.5731, 0.6191, 0.5927]}, {"w": "course", "b": [0.6245, 0.5731, 0.6745, 0.5927]}, {"w": "the", "b": [0.6799, 0.5731, 0.704, 0.5927]}, {"w": "same", "b": [0.7094, 0.5731, 0.7484, 0.5927]}, {"w": "pre‐", "b": [0.7538, 0.5731, 0.7857, 0.5927]}, {"w": "diction,", "b": [0.2714, 0.5905, 0.33, 0.6101]}, {"w": "except", "b": [0.3364, 0.5905, 0.3855, 0.6101]}, {"w": "it", "b": [0.3919, 0.5905, 0.4028, 0.6101]}, {"w": "is", "b": [0.4092, 0.5905, 0.4213, 0.6101]}, {"w": "now", "b": [0.4277, 0.5905, 0.4609, 0.6101]}, {"w": "represented", "b": [0.4673, 0.5905, 0.5567, 0.6101]}, {"w": "as", "b": [0.5631, 0.5905, 0.5784, 0.6101]}, {"w": "a", "b": [0.5848, 0.5905, 0.5932, 0.6101]}, {"w": "single", "b": [0.5996, 0.5905, 0.6439, 0.6101]}, {"w": "cell", "b": [0.6503, 0.5905, 0.6761, 0.6101]}, {"w": "matrix", "b": [0.6825, 0.5905, 0.7331, 0.6101]}, {"w": "rather", "b": [0.7395, 0.5905, 0.7857, 0.6101]}, {"w": "than", "b": [0.2714, 0.608, 0.3062, 0.6275]}, {"w": "a", "b": [0.3119, 0.608, 0.3203, 0.6275]}, {"w": "scalar", "b": [0.3261, 0.608, 0.3697, 0.6275]}, {"w": "value.", "b": [0.3755, 0.608, 0.4201, 0.6275]}, {"w": "In", "b": [0.4258, 0.608, 0.4427, 0.6275]}, {"w": "this", "b": [0.4485, 0.608, 0.4766, 0.6275]}, {"w": "book", "b": [0.4824, 0.608, 0.5209, 0.6275]}, {"w": "we", "b": [0.5267, 0.608, 0.5478, 0.6275]}, {"w": "will", "b": [0.5536, 0.608, 0.5814, 0.6275]}, {"w": "use", "b": [0.5871, 0.608, 0.6123, 0.6275]}, {"w": "this", "b": [0.6181, 0.608, 0.6462, 0.6275]}, {"w": "notation", "b": [0.652, 0.608, 0.7169, 0.6275]}, {"w": "to", "b": [0.7227, 0.608, 0.7382, 0.6275]}, {"w": "avoid", "b": [0.744, 0.608, 0.7857, 0.6275]}, {"w": "switching", "b": [0.2714, 0.6254, 0.345, 0.6449]}, {"w": "between", "b": [0.3493, 0.6254, 0.4126, 0.6449]}, {"w": "dot", "b": [0.4169, 0.6254, 0.4425, 0.6449]}, {"w": "products", "b": [0.4468, 0.6254, 0.5146, 0.6449]}, {"w": "and", "b": [0.5189, 0.6254, 0.5478, 0.6449]}, {"w": "matrix", "b": [0.5521, 0.6254, 0.6027, 0.6449]}, {"w": "multiplications.", "b": [0.607, 0.6254, 0.7264, 0.6449]}]}, {"id": "b_11", "type": "paragraph", "text": "Okay, that’s the Linear Regression model, so now how do we train it? Well, recall that training a model means setting its parameters so that the model best fits the training set. For this purpose, we first need a measure of how well (or poorly) the model fits the training data. In Chapter 2 we saw that the most common performance measure of a regression model is the Root Mean Square Error (RMSE) (Equation 2-1). There‐ fore, to train a Linear Regression model, you need to find the value of θ that minimi‐ zes the RMSE. In practice, it is simpler to minimize the Mean Square Error (MSE)", "words": [{"w": "Okay,", "b": [0.1429, 0.6652, 0.1903, 0.6866]}, {"w": "that’s", "b": [0.1957, 0.6652, 0.238, 0.6866]}, {"w": "the", "b": [0.2434, 0.6652, 0.2697, 0.6866]}, {"w": "Linear", "b": [0.275, 0.6652, 0.329, 0.6866]}, {"w": "Regression", "b": [0.3343, 0.6652, 0.4253, 0.6866]}, {"w": "model,", "b": [0.4307, 0.6652, 0.4882, 0.6866]}, {"w": "so", "b": [0.4936, 0.6652, 0.5119, 0.6866]}, {"w": "now", "b": [0.5172, 0.6652, 0.5535, 0.6866]}, {"w": "how", "b": [0.5589, 0.6652, 0.5949, 0.6866]}, {"w": "do", "b": [0.6002, 0.6652, 0.6219, 0.6866]}, {"w": "we", "b": [0.6272, 0.6652, 0.6503, 0.6866]}, {"w": "train", "b": [0.6557, 0.6652, 0.6959, 0.6866]}, {"w": "it?", "b": [0.7012, 0.6652, 0.7211, 0.6866]}, {"w": "Well,", "b": [0.7264, 0.6652, 0.7688, 0.6866]}, {"w": "recall", "b": [0.7741, 0.6652, 0.8192, 0.6866]}, {"w": "that", "b": [0.8246, 0.6652, 0.8572, 0.6866]}, {"w": "training", "b": [0.1429, 0.6843, 0.2098, 0.7057]}, {"w": "a", "b": [0.2155, 0.6843, 0.2246, 0.7057]}, {"w": "model", "b": [0.2304, 0.6843, 0.2832, 0.7057]}, {"w": "means", "b": [0.2889, 0.6843, 0.343, 0.7057]}, {"w": "setting", "b": [0.3487, 0.6843, 0.4046, 0.7057]}, {"w": "its", "b": [0.4103, 0.6843, 0.4299, 0.7057]}, {"w": "parameters", "b": [0.4356, 0.6843, 0.529, 0.7057]}, {"w": "so", "b": [0.5348, 0.6843, 0.553, 0.7057]}, {"w": "that", "b": [0.5587, 0.6843, 0.5913, 0.7057]}, {"w": "the", "b": [0.597, 0.6843, 0.6234, 0.7057]}, {"w": "model", "b": [0.6291, 0.6843, 0.6819, 0.7057]}, {"w": "best", "b": [0.6876, 0.6843, 0.721, 0.7057]}, {"w": "fits", "b": [0.7267, 0.6843, 0.7525, 0.7057]}, {"w": "the", "b": [0.7582, 0.6843, 0.7845, 0.7057]}, {"w": "training", "b": [0.7902, 0.6843, 0.8571, 0.7057]}, {"w": "set.", "b": [0.1429, 0.7033, 0.1705, 0.7247]}, {"w": "For", "b": [0.1767, 0.7033, 0.2057, 0.7247]}, {"w": "this", "b": [0.2119, 0.7033, 0.2426, 0.7247]}, {"w": "purpose,", "b": [0.2488, 0.7033, 0.3213, 0.7247]}, {"w": "we", "b": [0.3275, 0.7033, 0.3506, 0.7247]}, {"w": "first", "b": [0.3568, 0.7033, 0.3903, 0.7247]}, {"w": "need", "b": [0.3965, 0.7033, 0.4366, 0.7247]}, {"w": "a", "b": [0.4428, 0.7033, 0.452, 0.7247]}, {"w": "measure", "b": [0.4582, 0.7033, 0.5286, 0.7247]}, {"w": "of", "b": [0.5348, 0.7033, 0.5516, 0.7247]}, {"w": "how", "b": [0.5578, 0.7033, 0.5938, 0.7247]}, {"w": "well", "b": [0.6, 0.7033, 0.6337, 0.7247]}, {"w": "(or", "b": [0.6399, 0.7033, 0.6655, 0.7247]}, {"w": "poorly)", "b": [0.6717, 0.7033, 0.7336, 0.7247]}, {"w": "the", "b": [0.7398, 0.7033, 0.7662, 0.7247]}, {"w": "model", "b": [0.7724, 0.7033, 0.8252, 0.7247]}, {"w": "fits", "b": [0.8314, 0.7033, 0.8571, 0.7247]}, {"w": "the", "b": [0.1428, 0.7224, 0.1692, 0.7438]}, {"w": "training", "b": [0.1751, 0.7224, 0.2421, 0.7438]}, {"w": "data.", "b": [0.248, 0.7224, 0.288, 0.7438]}, {"w": "In", "b": [0.294, 0.7224, 0.3125, 0.7438]}, {"w": "Chapter", "b": [0.3184, 0.7224, 0.386, 0.7438]}, {"w": "2", "b": [0.3919, 0.7224, 0.4019, 0.7438]}, {"w": "we", "b": [0.4079, 0.7224, 0.431, 0.7438]}, {"w": "saw", "b": [0.4369, 0.7224, 0.4676, 0.7438]}, {"w": "that", "b": [0.4736, 0.7224, 0.5062, 0.7438]}, {"w": "the", "b": [0.5121, 0.7224, 0.5384, 0.7438]}, {"w": "most", "b": [0.5444, 0.7224, 0.5861, 0.7438]}, {"w": "common", "b": [0.592, 0.7224, 0.6676, 0.7438]}, {"w": "performance", "b": [0.6735, 0.7224, 0.7808, 0.7438]}, {"w": "measure", "b": [0.7868, 0.7224, 0.8571, 0.7438]}, {"w": "of", "b": [0.1429, 0.7414, 0.1597, 0.7628]}, {"w": "a", "b": [0.1652, 0.7414, 0.1743, 0.7628]}, {"w": "regression", "b": [0.1799, 0.7414, 0.2657, 0.7628]}, {"w": "model", "b": [0.2712, 0.7414, 0.324, 0.7628]}, {"w": "is", "b": [0.3296, 0.7414, 0.3428, 0.7628]}, {"w": "the", "b": [0.3483, 0.7414, 0.3747, 0.7628]}, {"w": "Root", "b": [0.3802, 0.7414, 0.4207, 0.7628]}, {"w": "Mean", "b": [0.4263, 0.7414, 0.4737, 0.7628]}, {"w": "Square", "b": [0.4792, 0.7414, 0.5365, 0.7628]}, {"w": "Error", "b": [0.5421, 0.7414, 0.5877, 0.7628]}, {"w": "(RMSE)", "b": [0.5933, 0.7414, 0.6609, 0.7628]}, {"w": "(Equation", "b": [0.6664, 0.7414, 0.7499, 0.7628]}, {"w": "2-1).", "b": [0.7554, 0.7414, 0.7948, 0.7628]}, {"w": "There‐", "b": [0.8003, 0.7414, 0.8571, 0.7628]}, {"w": "fore,", "b": [0.1429, 0.7605, 0.181, 0.7819]}, {"w": "to", "b": [0.1863, 0.7605, 0.2033, 0.7819]}, {"w": "train", "b": [0.2086, 0.7605, 0.2488, 0.7819]}, {"w": "a", "b": [0.2541, 0.7605, 0.2632, 0.7819]}, {"w": "Linear", "b": [0.2685, 0.7605, 0.3225, 0.7819]}, {"w": "Regression", "b": [0.3278, 0.7605, 0.4188, 0.7819]}, {"w": "model,", "b": [0.4241, 0.7605, 0.4816, 0.7819]}, {"w": "you", "b": [0.4869, 0.7605, 0.5182, 0.7819]}, {"w": "need", "b": [0.5235, 0.7605, 0.5636, 0.7819]}, {"w": "to", "b": [0.5689, 0.7605, 0.5859, 0.7819]}, {"w": "find", "b": [0.5912, 0.7605, 0.6253, 0.7819]}, {"w": "the", "b": [0.6306, 0.7605, 0.657, 0.7819]}, {"w": "value", "b": [0.6623, 0.7605, 0.7063, 0.7819]}, {"w": "of", "b": [0.7116, 0.7605, 0.7284, 0.7819]}, {"w": "θ", "b": [0.7337, 0.7599, 0.7443, 0.7819]}, {"w": "that", "b": [0.7496, 0.7605, 0.7822, 0.7819]}, {"w": "minimi‐", "b": [0.7869, 0.7605, 0.8566, 0.7819]}, {"w": "zes", "b": [0.1428, 0.7795, 0.1681, 0.8009]}, {"w": "the", "b": [0.1752, 0.7795, 0.2015, 0.8009]}, {"w": "RMSE.", "b": [0.2086, 0.7795, 0.2666, 0.8009]}, {"w": "In", "b": [0.2736, 0.7795, 0.2921, 0.8009]}, {"w": "practice,", "b": [0.2992, 0.7795, 0.3702, 0.8009]}, {"w": "it", "b": [0.3773, 0.7795, 0.3892, 0.8009]}, {"w": "is", "b": [0.3963, 0.7795, 0.4095, 0.8009]}, {"w": "simpler", "b": [0.4166, 0.7795, 0.4793, 0.8009]}, {"w": "to", "b": [0.4864, 0.7795, 0.5033, 0.8009]}, {"w": "minimize", "b": [0.5104, 0.7795, 0.5903, 0.8009]}, {"w": "the", "b": [0.5974, 0.7795, 0.6237, 0.8009]}, {"w": "Mean", "b": [0.6308, 0.7795, 0.6782, 0.8009]}, {"w": "Square", "b": [0.6853, 0.7795, 0.7426, 0.8009]}, {"w": "Error", "b": [0.7497, 0.7795, 0.7954, 0.8009]}, {"w": "(MSE)", "b": [0.8024, 0.7795, 0.8571, 0.8009]}]}, {"id": "b_12", "type": "paragraph", "text": "Linear Regression | 115", "words": [{"w": "Linear", "b": [0.6919, 0.9225, 0.7288, 0.9388]}, {"w": "Regression", "b": [0.7317, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "115", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 142, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 It is often the case that a learning algorithm will try to optimize a different function than the performance measure used to evaluate the final model. This is generally because that function is easier to compute, because it has useful differentiation properties that the performance measure lacks, or because we want to constrain the model during training, as we will see when we discuss regularization.", "words": [{"w": "1", "b": [0.1451, 0.7963, 0.1518, 0.8106]}, {"w": "It", "b": [0.1587, 0.7948, 0.1684, 0.8111]}, {"w": "is", "b": [0.172, 0.7948, 0.182, 0.8111]}, {"w": "often", "b": [0.1857, 0.7948, 0.2187, 0.8111]}, {"w": "the", "b": [0.2223, 0.7948, 0.2424, 0.8111]}, {"w": "case", "b": [0.246, 0.7948, 0.2722, 0.8111]}, {"w": "that", "b": [0.2758, 0.7948, 0.3007, 0.8111]}, {"w": "a", "b": [0.3043, 0.7948, 0.3112, 0.8111]}, {"w": "learning", "b": [0.3148, 0.7948, 0.3675, 0.8111]}, {"w": "algorithm", "b": [0.3711, 0.7948, 0.4341, 0.8111]}, {"w": "will", "b": [0.4377, 0.7948, 0.4608, 0.8111]}, {"w": "try", "b": [0.4644, 0.7948, 0.4829, 0.8111]}, {"w": "to", "b": [0.4865, 0.7948, 0.4995, 0.8111]}, {"w": "optimize", "b": [0.5031, 0.7948, 0.5592, 0.8111]}, {"w": "a", "b": [0.5628, 0.7948, 0.5698, 0.8111]}, {"w": "different", "b": [0.5734, 0.7948, 0.628, 0.8111]}, {"w": "function", "b": [0.6317, 0.7948, 0.686, 0.8111]}, {"w": "than", "b": [0.6897, 0.7948, 0.7186, 0.8111]}, {"w": "the", "b": [0.7222, 0.7948, 0.7423, 0.8111]}, {"w": "performance", "b": [0.7459, 0.7948, 0.8276, 0.8111]}, {"w": "measure", "b": [0.1587, 0.8099, 0.2123, 0.8262]}, {"w": "used", "b": [0.2159, 0.8099, 0.2453, 0.8262]}, {"w": "to", "b": [0.2489, 0.8099, 0.2619, 0.8262]}, {"w": "evaluate", "b": [0.2655, 0.8099, 0.3172, 0.8262]}, {"w": "the", "b": [0.3208, 0.8099, 0.3409, 0.8262]}, {"w": "final", "b": [0.3445, 0.8099, 0.3731, 0.8262]}, {"w": "model.", "b": [0.3767, 0.8099, 0.4206, 0.8262]}, {"w": "This", "b": [0.4242, 0.8099, 0.4525, 0.8262]}, {"w": "is", "b": [0.4561, 0.8099, 0.4662, 0.8262]}, {"w": "generally", "b": [0.4698, 0.8099, 0.5276, 0.8262]}, {"w": "because", "b": [0.5312, 0.8099, 0.5804, 0.8262]}, {"w": "that", "b": [0.584, 0.8099, 0.6088, 0.8262]}, {"w": "function", "b": [0.6124, 0.8099, 0.6668, 0.8262]}, {"w": "is", "b": [0.6704, 0.8099, 0.6805, 0.8262]}, {"w": "easier", "b": [0.6841, 0.8099, 0.7205, 0.8262]}, {"w": "to", "b": [0.7241, 0.8099, 0.7371, 0.8262]}, {"w": "compute,", "b": [0.7407, 0.8099, 0.8001, 0.8262]}, {"w": "because", "b": [0.8037, 0.8099, 0.8529, 0.8262]}, {"w": "it", "b": [0.1587, 0.825, 0.1678, 0.8413]}, {"w": "has", "b": [0.1714, 0.825, 0.1927, 0.8413]}, {"w": "useful", "b": [0.1963, 0.825, 0.2344, 0.8413]}, {"w": "differentiation", "b": [0.238, 0.825, 0.3295, 0.8413]}, {"w": "properties", "b": [0.3331, 0.825, 0.398, 0.8413]}, {"w": "that", "b": [0.4016, 0.825, 0.4264, 0.8413]}, {"w": "the", "b": [0.43, 0.825, 0.4501, 0.8413]}, {"w": "performance", "b": [0.4537, 0.825, 0.5354, 0.8413]}, {"w": "measure", "b": [0.539, 0.825, 0.5927, 0.8413]}, {"w": "lacks,", "b": [0.5963, 0.825, 0.6313, 0.8413]}, {"w": "or", "b": [0.6349, 0.825, 0.6489, 0.8413]}, {"w": "because", "b": [0.6525, 0.825, 0.7017, 0.8413]}, {"w": "we", "b": [0.7053, 0.825, 0.7229, 0.8413]}, {"w": "want", "b": [0.7265, 0.825, 0.7575, 0.8413]}, {"w": "to", "b": [0.7611, 0.825, 0.7741, 0.8413]}, {"w": "constrain", "b": [0.7777, 0.825, 0.8376, 0.8413]}, {"w": "the", "b": [0.1587, 0.8401, 0.1788, 0.8565]}, {"w": "model", "b": [0.1824, 0.8401, 0.2226, 0.8565]}, {"w": "during", "b": [0.2262, 0.8401, 0.2693, 0.8565]}, {"w": "training,", "b": [0.2729, 0.8401, 0.3275, 0.8565]}, {"w": "as", "b": [0.3311, 0.8401, 0.3439, 0.8565]}, {"w": "we", "b": [0.3475, 0.8401, 0.3651, 0.8565]}, {"w": "will", "b": [0.3687, 0.8401, 0.3919, 0.8565]}, {"w": "see", "b": [0.3955, 0.8401, 0.4148, 0.8565]}, {"w": "when", "b": [0.4184, 0.8401, 0.4532, 0.8565]}, {"w": "we", "b": [0.4568, 0.8401, 0.4744, 0.8565]}, {"w": "discuss", "b": [0.478, 0.8401, 0.5233, 0.8565]}, {"w": "regularization.", "b": [0.5269, 0.8401, 0.6193, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "2 The demonstration that this returns the value of θ that minimizes the cost function is outside the scope of this book.", "words": [{"w": "2", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "The", "b": [0.1587, 0.8598, 0.1837, 0.8761]}, {"w": "demonstration", "b": [0.1873, 0.8598, 0.2813, 0.8761]}, {"w": "that", "b": [0.285, 0.8598, 0.3098, 0.8761]}, {"w": "this", "b": [0.3134, 0.8598, 0.3368, 0.8761]}, {"w": "returns", "b": [0.3404, 0.8598, 0.3867, 0.8761]}, {"w": "the", "b": [0.3903, 0.8598, 0.4103, 0.8761]}, {"w": "value", "b": [0.414, 0.8598, 0.4475, 0.8761]}, {"w": "of", "b": [0.4511, 0.8598, 0.4639, 0.8761]}, {"w": "θ", "b": [0.4675, 0.8594, 0.4755, 0.8761]}, {"w": "that", "b": [0.4791, 0.8598, 0.504, 0.8761]}, {"w": "minimizes", "b": [0.5076, 0.8598, 0.5743, 0.8761]}, {"w": "the", "b": [0.5779, 0.8598, 0.5979, 0.8761]}, {"w": "cost", "b": [0.6015, 0.8598, 0.627, 0.8761]}, {"w": "function", "b": [0.6306, 0.8598, 0.685, 0.8761]}, {"w": "is", "b": [0.6886, 0.8598, 0.6987, 0.8761]}, {"w": "outside", "b": [0.7023, 0.8598, 0.7489, 0.8761]}, {"w": "the", "b": [0.7525, 0.8598, 0.7725, 0.8761]}, {"w": "scope", "b": [0.7761, 0.8598, 0.8118, 0.8761]}, {"w": "of", "b": [0.8154, 0.8598, 0.8282, 0.8761]}, {"w": "this", "b": [0.8318, 0.8598, 0.8552, 0.8761]}, {"w": "book.", "b": [0.1587, 0.8749, 0.1945, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "than the RMSE, and it leads to the same result (because the value that minimizes a function also minimizes its square root).1", "words": [{"w": "than", "b": [0.1429, 0.0791, 0.1809, 0.1005]}, {"w": "the", "b": [0.1877, 0.0791, 0.214, 0.1005]}, {"w": "RMSE,", "b": [0.2208, 0.0791, 0.2788, 0.1005]}, {"w": "and", "b": [0.2856, 0.0791, 0.3172, 0.1005]}, {"w": "it", "b": [0.324, 0.0791, 0.3359, 0.1005]}, {"w": "leads", "b": [0.3427, 0.0791, 0.3847, 0.1005]}, {"w": "to", "b": [0.3915, 0.0791, 0.4085, 0.1005]}, {"w": "the", "b": [0.4153, 0.0791, 0.4416, 0.1005]}, {"w": "same", "b": [0.4484, 0.0791, 0.4911, 0.1005]}, {"w": "result", "b": [0.498, 0.0791, 0.5449, 0.1005]}, {"w": "(because", "b": [0.5517, 0.0791, 0.6235, 0.1005]}, {"w": "the", "b": [0.6303, 0.0791, 0.6566, 0.1005]}, {"w": "value", "b": [0.6634, 0.0791, 0.7074, 0.1005]}, {"w": "that", "b": [0.7142, 0.0791, 0.7468, 0.1005]}, {"w": "minimizes", "b": [0.7536, 0.0791, 0.8412, 0.1005]}, {"w": "a", "b": [0.848, 0.0791, 0.8571, 0.1005]}, {"w": "function", "b": [0.1429, 0.0981, 0.2143, 0.1195]}, {"w": "also", "b": [0.219, 0.0981, 0.2517, 0.1195]}, {"w": "minimizes", "b": [0.2564, 0.0981, 0.3439, 0.1195]}, {"w": "its", "b": [0.3487, 0.0981, 0.3682, 0.1195]}, {"w": "square", "b": [0.373, 0.0981, 0.4281, 0.1195]}, {"w": "root).1", "b": [0.4328, 0.0981, 0.4858, 0.1195]}]}, {"id": "b_3", "type": "paragraph", "text": "The MSE of a Linear Regression hypothesis hθ on a training set X is calculated using Equation 4-3.", "words": [{"w": "The", "b": [0.1429, 0.1262, 0.1757, 0.1476]}, {"w": "MSE", "b": [0.1815, 0.1262, 0.2218, 0.1476]}, {"w": "of", "b": [0.2276, 0.1262, 0.2443, 0.1476]}, {"w": "a", "b": [0.2501, 0.1262, 0.2593, 0.1476]}, {"w": "Linear", "b": [0.2651, 0.1262, 0.319, 0.1476]}, {"w": "Regression", "b": [0.3248, 0.1262, 0.4158, 0.1476]}, {"w": "hypothesis", "b": [0.4216, 0.1262, 0.5106, 0.1476]}, {"w": "hθ", "b": [0.5164, 0.126, 0.5334, 0.1485]}, {"w": "on", "b": [0.5392, 0.1262, 0.5612, 0.1476]}, {"w": "a", "b": [0.567, 0.1262, 0.5761, 0.1476]}, {"w": "training", "b": [0.5819, 0.1262, 0.6489, 0.1476]}, {"w": "set", "b": [0.6547, 0.1262, 0.6775, 0.1476]}, {"w": "X", "b": [0.6833, 0.1257, 0.6978, 0.1476]}, {"w": "is", "b": [0.7036, 0.1262, 0.7168, 0.1476]}, {"w": "calculated", "b": [0.7226, 0.1262, 0.8059, 0.1476]}, {"w": "using", "b": [0.8117, 0.1262, 0.8571, 0.1476]}, {"w": "Equation", "b": [0.1429, 0.1453, 0.2191, 0.1667]}, {"w": "4-3.", "b": [0.2238, 0.1453, 0.256, 0.1667]}]}, {"id": "b_4", "type": "equation", "text": "Equation 4-3. MSE cost function for a Linear Regression model", "words": [{"w": "Equation", "b": [0.1726, 0.1848, 0.2473, 0.2064]}, {"w": "4-3.", "b": [0.2521, 0.1848, 0.2838, 0.2064]}, {"w": "MSE", "b": [0.2886, 0.1848, 0.328, 0.2064]}, {"w": "cost", "b": [0.3328, 0.1848, 0.3635, 0.2064]}, {"w": "function", "b": [0.3683, 0.1848, 0.4364, 0.2064]}, {"w": "for", "b": [0.4411, 0.1848, 0.4638, 0.2064]}, {"w": "a", "b": [0.4686, 0.1848, 0.4788, 0.2064]}, {"w": "Linear", "b": [0.4835, 0.1848, 0.5362, 0.2064]}, {"w": "Regression", "b": [0.541, 0.1848, 0.6257, 0.2064]}, {"w": "model", "b": [0.6305, 0.1848, 0.6801, 0.2064]}]}, {"id": "b_5", "type": "equation", "text": "MSE X, hθ = 1", "words": [{"w": "MSE", "b": [0.1726, 0.2264, 0.211, 0.2468]}, {"w": "X,", "b": [0.2178, 0.2259, 0.2361, 0.2468]}, {"w": "hθ", "b": [0.2394, 0.2262, 0.2576, 0.2511]}, {"w": "=", "b": [0.27, 0.2264, 0.2815, 0.2468]}, {"w": "1", "b": [0.2923, 0.2176, 0.3018, 0.238]}]}, {"id": "b_6", "type": "paragraph", "text": "m ∑", "words": [{"w": "m", "b": [0.2892, 0.235, 0.3048, 0.2556]}, {"w": "∑", "b": [0.3156, 0.2216, 0.3307, 0.2505]}]}, {"id": "b_7", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.3082, 0.2411, 0.3125, 0.2576]}, {"w": "=", "b": [0.3169, 0.2413, 0.3261, 0.2576]}, {"w": "1", "b": [0.3305, 0.2413, 0.3381, 0.2576]}]}, {"id": "b_9", "type": "paragraph", "text": "θTx i −y i 2", "words": [{"w": "θTx", "b": [0.3472, 0.2225, 0.3772, 0.2468]}, {"w": "i", "b": [0.3828, 0.2225, 0.3871, 0.239]}, {"w": "−y", "b": [0.397, 0.2262, 0.4228, 0.2468]}, {"w": "i", "b": [0.4283, 0.2225, 0.4327, 0.239]}, {"w": "2", "b": [0.445, 0.2194, 0.4526, 0.2357]}]}, {"id": "b_10", "type": "paragraph", "text": "Most of these notations were presented in Chapter 2 (see “Notations” on page 43). The only difference is that we write hθ instead of just h in order to make it clear that the model is parametrized by the vector θ. To simplify notations, we will just write MSE(θ) instead of MSE(X, hθ).", "words": [{"w": "Most", "b": [0.1429, 0.2766, 0.1855, 0.298]}, {"w": "of", "b": [0.1928, 0.2766, 0.2096, 0.298]}, {"w": "these", "b": [0.2168, 0.2766, 0.2597, 0.298]}, {"w": "notations", "b": [0.2669, 0.2766, 0.3457, 0.298]}, {"w": "were", "b": [0.3529, 0.2766, 0.3927, 0.298]}, {"w": "presented", "b": [0.3999, 0.2766, 0.4811, 0.298]}, {"w": "in", "b": [0.4884, 0.2766, 0.5054, 0.298]}, {"w": "Chapter", "b": [0.5126, 0.2766, 0.5802, 0.298]}, {"w": "2", "b": [0.5875, 0.2766, 0.5975, 0.298]}, {"w": "(see", "b": [0.6048, 0.2766, 0.6373, 0.298]}, {"w": "“Notations”", "b": [0.6446, 0.2766, 0.7427, 0.298]}, {"w": "on", "b": [0.75, 0.2766, 0.772, 0.298]}, {"w": "page", "b": [0.7793, 0.2766, 0.8179, 0.298]}, {"w": "43).", "b": [0.8252, 0.2766, 0.8571, 0.298]}, {"w": "The", "b": [0.1429, 0.2957, 0.1757, 0.3171]}, {"w": "only", "b": [0.1815, 0.2957, 0.2184, 0.3171]}, {"w": "difference", "b": [0.2242, 0.2957, 0.3076, 0.3171]}, {"w": "is", "b": [0.3135, 0.2957, 0.3267, 0.3171]}, {"w": "that", "b": [0.3325, 0.2957, 0.3651, 0.3171]}, {"w": "we", "b": [0.3709, 0.2957, 0.3941, 0.3171]}, {"w": "write", "b": [0.3999, 0.2957, 0.4427, 0.3171]}, {"w": "hθ", "b": [0.4485, 0.2955, 0.4655, 0.318]}, {"w": "instead", "b": [0.4714, 0.2957, 0.5313, 0.3171]}, {"w": "of", "b": [0.5372, 0.2957, 0.554, 0.3171]}, {"w": "just", "b": [0.5598, 0.2957, 0.5902, 0.3171]}, {"w": "h", "b": [0.596, 0.2955, 0.6067, 0.3171]}, {"w": "in", "b": [0.6125, 0.2957, 0.6295, 0.3171]}, {"w": "order", "b": [0.6353, 0.2957, 0.6813, 0.3171]}, {"w": "to", "b": [0.6871, 0.2957, 0.7041, 0.3171]}, {"w": "make", "b": [0.7099, 0.2957, 0.7553, 0.3171]}, {"w": "it", "b": [0.7611, 0.2957, 0.7731, 0.3171]}, {"w": "clear", "b": [0.7789, 0.2957, 0.8187, 0.3171]}, {"w": "that", "b": [0.8246, 0.2957, 0.8571, 0.3171]}, {"w": "the", "b": [0.1428, 0.3147, 0.1692, 0.3361]}, {"w": "model", "b": [0.1761, 0.3147, 0.229, 0.3361]}, {"w": "is", "b": [0.2359, 0.3147, 0.2492, 0.3361]}, {"w": "parametrized", "b": [0.2561, 0.3147, 0.3673, 0.3361]}, {"w": "by", "b": [0.3742, 0.3147, 0.3944, 0.3361]}, {"w": "the", "b": [0.4013, 0.3147, 0.4277, 0.3361]}, {"w": "vector", "b": [0.4346, 0.3147, 0.4867, 0.3361]}, {"w": "θ.", "b": [0.4936, 0.3142, 0.509, 0.3361]}, {"w": "To", "b": [0.5159, 0.3147, 0.5374, 0.3361]}, {"w": "simplify", "b": [0.5444, 0.3147, 0.6121, 0.3361]}, {"w": "notations,", "b": [0.6191, 0.3147, 0.7026, 0.3361]}, {"w": "we", "b": [0.7095, 0.3147, 0.7326, 0.3361]}, {"w": "will", "b": [0.7396, 0.3147, 0.77, 0.3361]}, {"w": "just", "b": [0.777, 0.3147, 0.8074, 0.3361]}, {"w": "write", "b": [0.8143, 0.3147, 0.8571, 0.3361]}, {"w": "MSE(θ)", "b": [0.1429, 0.3332, 0.2082, 0.3552]}, {"w": "instead", "b": [0.2129, 0.3338, 0.2729, 0.3552]}, {"w": "of", "b": [0.2776, 0.3338, 0.2944, 0.3552]}, {"w": "MSE(X,", "b": [0.2991, 0.3332, 0.3658, 0.3552]}, {"w": "hθ).", "b": [0.3705, 0.3336, 0.3995, 0.3561]}]}, {"id": "b_11", "type": "paragraph", "text": "The Normal Equation", "words": [{"w": "The", "b": [0.1429, 0.3679, 0.1805, 0.3965]}, {"w": "Normal", "b": [0.1855, 0.3679, 0.2617, 0.3965]}, {"w": "Equation", "b": [0.2666, 0.3679, 0.3592, 0.3965]}]}, {"id": "b_12", "type": "paragraph", "text": "To find the value of θ that minimizes the cost function, there is a closed-form solution —in other words, a mathematical equation that gives the result directly. This is called the Normal Equation (Equation 4-4).2", "words": [{"w": "To", "b": [0.1428, 0.4024, 0.1643, 0.4238]}, {"w": "find", "b": [0.1696, 0.4024, 0.2038, 0.4238]}, {"w": "the", "b": [0.2091, 0.4024, 0.2355, 0.4238]}, {"w": "value", "b": [0.2408, 0.4024, 0.2848, 0.4238]}, {"w": "of", "b": [0.2901, 0.4024, 0.3069, 0.4238]}, {"w": "θ", "b": [0.3123, 0.4019, 0.3229, 0.4238]}, {"w": "that", "b": [0.3282, 0.4024, 0.3608, 0.4238]}, {"w": "minimizes", "b": [0.3662, 0.4024, 0.4537, 0.4238]}, {"w": "the", "b": [0.459, 0.4024, 0.4854, 0.4238]}, {"w": "cost", "b": [0.4907, 0.4024, 0.5242, 0.4238]}, {"w": "function,", "b": [0.5295, 0.4024, 0.6057, 0.4238]}, {"w": "there", "b": [0.611, 0.4024, 0.6539, 0.4238]}, {"w": "is", "b": [0.6593, 0.4024, 0.6725, 0.4238]}, {"w": "a", "b": [0.6778, 0.4024, 0.687, 0.4238]}, {"w": "closed-form", "b": [0.6923, 0.4022, 0.7869, 0.4238]}, {"w": "solution", "b": [0.7917, 0.4022, 0.8565, 0.4238]}, {"w": "—in", "b": [0.1429, 0.4215, 0.179, 0.4429]}, {"w": "other", "b": [0.1844, 0.4215, 0.2291, 0.4429]}, {"w": "words,", "b": [0.2344, 0.4215, 0.2904, 0.4429]}, {"w": "a", "b": [0.2958, 0.4215, 0.3049, 0.4429]}, {"w": "mathematical", "b": [0.3102, 0.4215, 0.4234, 0.4429]}, {"w": "equation", "b": [0.4287, 0.4215, 0.502, 0.4429]}, {"w": "that", "b": [0.5073, 0.4215, 0.5399, 0.4429]}, {"w": "gives", "b": [0.5452, 0.4215, 0.5867, 0.4429]}, {"w": "the", "b": [0.592, 0.4215, 0.6184, 0.4429]}, {"w": "result", "b": [0.6237, 0.4215, 0.6706, 0.4429]}, {"w": "directly.", "b": [0.676, 0.4215, 0.7423, 0.4429]}, {"w": "This", "b": [0.7477, 0.4215, 0.7849, 0.4429]}, {"w": "is", "b": [0.7902, 0.4215, 0.8035, 0.4429]}, {"w": "called", "b": [0.8088, 0.4215, 0.8571, 0.4429]}, {"w": "the", "b": [0.1429, 0.4405, 0.1692, 0.4619]}, {"w": "Normal", "b": [0.1739, 0.4403, 0.2368, 0.4619]}, {"w": "Equation", "b": [0.2416, 0.4403, 0.3162, 0.4619]}, {"w": "(Equation", "b": [0.321, 0.4405, 0.4044, 0.4619]}, {"w": "4-4).2", "b": [0.4092, 0.4405, 0.4543, 0.4619]}]}, {"id": "b_13", "type": "equation", "text": "Equation 4-4. Normal Equation", "words": [{"w": "Equation", "b": [0.1726, 0.48, 0.2473, 0.5017]}, {"w": "4-4.", "b": [0.252, 0.48, 0.2838, 0.5017]}, {"w": "Normal", "b": [0.2885, 0.48, 0.3514, 0.5017]}, {"w": "Equation", "b": [0.3562, 0.48, 0.4309, 0.5017]}]}, {"id": "b_14", "type": "equation", "text": "θ = XTX", "words": [{"w": "θ", "b": [0.1732, 0.5153, 0.1833, 0.5362]}, {"w": "=", "b": [0.1894, 0.5158, 0.2009, 0.5362]}, {"w": "XTX", "b": [0.2133, 0.5119, 0.251, 0.5362]}]}, {"id": "b_15", "type": "paragraph", "text": "−1 XT y", "words": [{"w": "−1", "b": [0.2579, 0.5088, 0.2756, 0.5251]}, {"w": "XT", "b": [0.2911, 0.5119, 0.3144, 0.5362]}, {"w": "y", "b": [0.3308, 0.5153, 0.34, 0.5362]}]}, {"id": "b_16", "type": "paragraph", "text": "• θ is the value of θ that minimizes the cost function.", "words": [{"w": "•", "b": [0.16, 0.5681, 0.1682, 0.5896]}, {"w": "θ", "b": [0.1792, 0.5676, 0.1898, 0.5896]}, {"w": "is", "b": [0.1951, 0.5681, 0.2083, 0.5896]}, {"w": "the", "b": [0.213, 0.5681, 0.2394, 0.5896]}, {"w": "value", "b": [0.2441, 0.5681, 0.2881, 0.5896]}, {"w": "of", "b": [0.2928, 0.5681, 0.3096, 0.5896]}, {"w": "θ", "b": [0.3143, 0.5676, 0.3249, 0.5896]}, {"w": "that", "b": [0.3297, 0.5681, 0.3623, 0.5896]}, {"w": "minimizes", "b": [0.367, 0.5681, 0.4545, 0.5896]}, {"w": "the", "b": [0.4592, 0.5681, 0.4856, 0.5896]}, {"w": "cost", "b": [0.4903, 0.5681, 0.5237, 0.5896]}, {"w": "function.", "b": [0.5285, 0.5681, 0.6046, 0.5896]}]}, {"id": "b_17", "type": "paragraph", "text": "• y is the vector of target values containing y(1) to y(m).", "words": [{"w": "•", "b": [0.16, 0.5932, 0.1682, 0.6147]}, {"w": "y", "b": [0.1786, 0.5927, 0.1883, 0.6147]}, {"w": "is", "b": [0.193, 0.5932, 0.2062, 0.6147]}, {"w": "the", "b": [0.2109, 0.5932, 0.2373, 0.6147]}, {"w": "vector", "b": [0.242, 0.5932, 0.294, 0.6147]}, {"w": "of", "b": [0.2988, 0.5932, 0.3155, 0.6147]}, {"w": "target", "b": [0.3203, 0.5932, 0.3685, 0.6147]}, {"w": "values", "b": [0.3732, 0.5932, 0.4248, 0.6147]}, {"w": "containing", "b": [0.4295, 0.5932, 0.5192, 0.6147]}, {"w": "y(1)", "b": [0.5239, 0.593, 0.5478, 0.6147]}, {"w": "to", "b": [0.5525, 0.5932, 0.5695, 0.6147]}, {"w": "y(m).", "b": [0.5742, 0.593, 0.6067, 0.6147]}]}, {"id": "b_18", "type": "equation", "text": "Let’s generate some linear-looking data to test this equation on (Figure 4-1):", "words": [{"w": "Let’s", "b": [0.1428, 0.6274, 0.179, 0.6488]}, {"w": "generate", "b": [0.1837, 0.6274, 0.2543, 0.6488]}, {"w": "some", "b": [0.259, 0.6274, 0.3032, 0.6488]}, {"w": "linear-looking", "b": [0.3079, 0.6274, 0.4264, 0.6488]}, {"w": "data", "b": [0.4311, 0.6274, 0.4664, 0.6488]}, {"w": "to", "b": [0.4711, 0.6274, 0.4881, 0.6488]}, {"w": "test", "b": [0.4928, 0.6274, 0.522, 0.6488]}, {"w": "this", "b": [0.5268, 0.6274, 0.5575, 0.6488]}, {"w": "equation", "b": [0.5622, 0.6274, 0.6355, 0.6488]}, {"w": "on", "b": [0.6402, 0.6274, 0.6622, 0.6488]}, {"w": "(Figure", "b": [0.667, 0.6274, 0.7282, 0.6488]}, {"w": "4-1):", "b": [0.7329, 0.6274, 0.7723, 0.6488]}]}, {"id": "b_19", "type": "paragraph", "text": "import numpy as np", "words": [{"w": "import", "b": [0.1766, 0.6594, 0.2272, 0.6722]}, {"w": "numpy", "b": [0.2356, 0.6594, 0.2778, 0.6722]}, {"w": "as", "b": [0.2862, 0.6594, 0.3031, 0.6722]}, {"w": "np", "b": [0.3115, 0.6594, 0.3284, 0.6722]}]}, {"id": "b_20", "type": "equation", "text": "X = 2 * np.random.rand(100, 1) y = 4 + 3 * X + np.random.randn(100, 1)", "words": [{"w": "X", "b": [0.1766, 0.6902, 0.185, 0.7031]}, {"w": "=", "b": [0.1935, 0.6902, 0.2019, 0.7031]}, {"w": "2", "b": [0.2103, 0.6902, 0.2188, 0.7031]}, {"w": "*", "b": [0.2272, 0.6902, 0.2356, 0.7031]}, {"w": "np.random.rand(100,", "b": [0.2441, 0.6902, 0.4043, 0.7031]}, {"w": "1)", "b": [0.4127, 0.6902, 0.4296, 0.7031]}, {"w": "y", "b": [0.1766, 0.7056, 0.185, 0.7185]}, {"w": "=", "b": [0.1935, 0.7056, 0.2019, 0.7185]}, {"w": "4", "b": [0.2103, 0.7056, 0.2188, 0.7185]}, {"w": "+", "b": [0.2272, 0.7056, 0.2356, 0.7185]}, {"w": "3", "b": [0.2441, 0.7056, 0.2525, 0.7185]}, {"w": "*", "b": [0.2609, 0.7056, 0.2693, 0.7185]}, {"w": "X", "b": [0.2778, 0.7056, 0.2862, 0.7185]}, {"w": "+", "b": [0.2946, 0.7056, 0.3031, 0.7185]}, {"w": "np.random.randn(100,", "b": [0.3115, 0.7056, 0.4802, 0.7185]}, {"w": "1)", "b": [0.4886, 0.7056, 0.5055, 0.7185]}]}, {"id": "b_21", "type": "paragraph", "text": "116 | Chapter 4: Training Models", "words": [{"w": "116", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 143, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 4-1. Randomly generated linear dataset", "words": [{"w": "Figure", "b": [0.1429, 0.3609, 0.1943, 0.3825]}, {"w": "4-1.", "b": [0.1991, 0.3609, 0.2308, 0.3825]}, {"w": "Randomly", "b": [0.2356, 0.3609, 0.3192, 0.3825]}, {"w": "generated", "b": [0.3239, 0.3609, 0.4023, 0.3825]}, {"w": "linear", "b": [0.407, 0.3609, 0.454, 0.3825]}, {"w": "dataset", "b": [0.4588, 0.3609, 0.5171, 0.3825]}]}, {"id": "b_1", "type": "paragraph", "text": "Now let’s compute θ using the Normal Equation. We will use the inv() function from NumPy’s Linear Algebra module (np.linalg) to compute the inverse of a matrix, and the dot() method for matrix multiplication:", "words": [{"w": "Now", "b": [0.1429, 0.4014, 0.1827, 0.4229]}, {"w": "let’s", "b": [0.1874, 0.4014, 0.2177, 0.4229]}, {"w": "compute", "b": [0.2224, 0.4014, 0.2957, 0.4229]}, {"w": "θ", "b": [0.3013, 0.4009, 0.3119, 0.4229]}, {"w": "using", "b": [0.3174, 0.4014, 0.3628, 0.4229]}, {"w": "the", "b": [0.3677, 0.4014, 0.394, 0.4229]}, {"w": "Normal", "b": [0.3988, 0.4014, 0.4636, 0.4229]}, {"w": "Equation.", "b": [0.4685, 0.4014, 0.5495, 0.4229]}, {"w": "We", "b": [0.5543, 0.4014, 0.5814, 0.4229]}, {"w": "will", "b": [0.5862, 0.4014, 0.6166, 0.4229]}, {"w": "use", "b": [0.6214, 0.4014, 0.649, 0.4229]}, {"w": "the", "b": [0.6538, 0.4014, 0.6802, 0.4229]}, {"w": "inv()", "b": [0.685, 0.4046, 0.7345, 0.4197]}, {"w": "function", "b": [0.7393, 0.4014, 0.8107, 0.4229]}, {"w": "from", "b": [0.8154, 0.4014, 0.857, 0.4229]}, {"w": "NumPy’s", "b": [0.1429, 0.4214, 0.2173, 0.4428]}, {"w": "Linear", "b": [0.2223, 0.4214, 0.2762, 0.4428]}, {"w": "Algebra", "b": [0.2812, 0.4214, 0.3469, 0.4428]}, {"w": "module", "b": [0.3518, 0.4214, 0.4157, 0.4428]}, {"w": "(np.linalg)", "b": [0.4207, 0.4214, 0.5241, 0.4428]}, {"w": "to", "b": [0.5291, 0.4214, 0.5461, 0.4428]}, {"w": "compute", "b": [0.551, 0.4214, 0.6243, 0.4428]}, {"w": "the", "b": [0.6293, 0.4214, 0.6556, 0.4428]}, {"w": "inverse", "b": [0.6606, 0.4214, 0.7198, 0.4428]}, {"w": "of", "b": [0.7247, 0.4214, 0.7415, 0.4428]}, {"w": "a", "b": [0.7465, 0.4214, 0.7556, 0.4428]}, {"w": "matrix,", "b": [0.7606, 0.4214, 0.8207, 0.4428]}, {"w": "and", "b": [0.8256, 0.4214, 0.8571, 0.4428]}, {"w": "the", "b": [0.1429, 0.4413, 0.1692, 0.4628]}, {"w": "dot()", "b": [0.1739, 0.4445, 0.2234, 0.4596]}, {"w": "method", "b": [0.2281, 0.4413, 0.2931, 0.4628]}, {"w": "for", "b": [0.2979, 0.4413, 0.3224, 0.4628]}, {"w": "matrix", "b": [0.3271, 0.4413, 0.3824, 0.4628]}, {"w": "multiplication:", "b": [0.3872, 0.4413, 0.5101, 0.4628]}]}, {"id": "b_2", "type": "paragraph", "text": "X_b = np.c_[np.ones((100, 1)), X] # add x0 = 1 to each instance theta_best = np.linalg.inv(X_b.T.dot(X_b)).dot(X_b.T).dot(y)", "words": [{"w": "X_b", "b": [0.1766, 0.4733, 0.2019, 0.4862]}, {"w": "=", "b": [0.2103, 0.4733, 0.2188, 0.4862]}, {"w": "np.c_[np.ones((100,", "b": [0.2272, 0.4733, 0.3874, 0.4862]}, {"w": "1)),", "b": [0.3958, 0.4733, 0.4296, 0.4862]}, {"w": "X]", "b": [0.438, 0.4733, 0.4549, 0.4862]}, {"w": "#", "b": [0.4717, 0.4733, 0.4802, 0.4862]}, {"w": "add", "b": [0.4886, 0.4733, 0.5139, 0.4862]}, {"w": "x0", "b": [0.5223, 0.4733, 0.5392, 0.4862]}, {"w": "=", "b": [0.5476, 0.4733, 0.5561, 0.4862]}, {"w": "1", "b": [0.5645, 0.4733, 0.5729, 0.4862]}, {"w": "to", "b": [0.5814, 0.4733, 0.5982, 0.4862]}, {"w": "each", "b": [0.6066, 0.4733, 0.6404, 0.4862]}, {"w": "instance", "b": [0.6488, 0.4733, 0.7163, 0.4862]}, {"w": "theta_best", "b": [0.1766, 0.4887, 0.2609, 0.5016]}, {"w": "=", "b": [0.2693, 0.4887, 0.2778, 0.5016]}, {"w": "np.linalg.inv(X_b.T.dot(X_b)).dot(X_b.T).dot(y)", "b": [0.2862, 0.4887, 0.6825, 0.5016]}]}, {"id": "b_3", "type": "paragraph", "text": "The actual function that we used to generate the data is y = 4 + 3x1 + Gaussian noise. Let’s see what the equation found:", "words": [{"w": "The", "b": [0.1429, 0.5094, 0.1757, 0.5308]}, {"w": "actual", "b": [0.1811, 0.5094, 0.2309, 0.5308]}, {"w": "function", "b": [0.2363, 0.5094, 0.3077, 0.5308]}, {"w": "that", "b": [0.3131, 0.5094, 0.3457, 0.5308]}, {"w": "we", "b": [0.3511, 0.5094, 0.3742, 0.5308]}, {"w": "used", "b": [0.3796, 0.5094, 0.4182, 0.5308]}, {"w": "to", "b": [0.4236, 0.5094, 0.4406, 0.5308]}, {"w": "generate", "b": [0.446, 0.5094, 0.5165, 0.5308]}, {"w": "the", "b": [0.5219, 0.5094, 0.5483, 0.5308]}, {"w": "data", "b": [0.5537, 0.5094, 0.5889, 0.5308]}, {"w": "is", "b": [0.5943, 0.5094, 0.6076, 0.5308]}, {"w": "y", "b": [0.613, 0.5092, 0.6222, 0.5308]}, {"w": "=", "b": [0.6276, 0.5094, 0.6397, 0.5308]}, {"w": "4", "b": [0.6451, 0.5094, 0.6551, 0.5308]}, {"w": "+", "b": [0.6605, 0.5094, 0.6726, 0.5308]}, {"w": "3x1", "b": [0.678, 0.5092, 0.7039, 0.5317]}, {"w": "+", "b": [0.7093, 0.5094, 0.7213, 0.5308]}, {"w": "Gaussian", "b": [0.7267, 0.5094, 0.8029, 0.5308]}, {"w": "noise.", "b": [0.8083, 0.5094, 0.8571, 0.5308]}, {"w": "Let’s", "b": [0.1429, 0.5284, 0.179, 0.5498]}, {"w": "see", "b": [0.1838, 0.5284, 0.2091, 0.5498]}, {"w": "what", "b": [0.2138, 0.5284, 0.2543, 0.5498]}, {"w": "the", "b": [0.2591, 0.5284, 0.2854, 0.5498]}, {"w": "equation", "b": [0.2901, 0.5284, 0.3634, 0.5498]}, {"w": "found:", "b": [0.3681, 0.5284, 0.4231, 0.5498]}]}, {"id": "b_4", "type": "equation", "text": ">>> theta_best array([[4.21509616], [2.77011339]])", "words": [{"w": ">>>", "b": [0.1766, 0.5604, 0.2019, 0.5732]}, {"w": "theta_best", "b": [0.2103, 0.5604, 0.2946, 0.5732]}, {"w": "array([[4.21509616],", "b": [0.1766, 0.5758, 0.3452, 0.5887]}, {"w": "[2.77011339]])", "b": [0.2356, 0.5912, 0.3537, 0.6041]}]}, {"id": "b_5", "type": "paragraph", "text": "We would have hoped for θ0 = 4 and θ1 = 3 instead of θ0 = 4.215 and θ1 = 2.770. Close enough, but the noise made it impossible to recover the exact parameters of the origi‐ nal function.", "words": [{"w": "We", "b": [0.1429, 0.6119, 0.1699, 0.6333]}, {"w": "would", "b": [0.175, 0.6119, 0.2272, 0.6333]}, {"w": "have", "b": [0.2323, 0.6119, 0.2707, 0.6333]}, {"w": "hoped", "b": [0.2758, 0.6119, 0.3284, 0.6333]}, {"w": "for", "b": [0.3335, 0.6119, 0.358, 0.6333]}, {"w": "θ0", "b": [0.3631, 0.6117, 0.379, 0.6342]}, {"w": "=", "b": [0.3841, 0.6119, 0.3962, 0.6333]}, {"w": "4", "b": [0.4013, 0.6119, 0.4113, 0.6333]}, {"w": "and", "b": [0.4164, 0.6119, 0.448, 0.6333]}, {"w": "θ1", "b": [0.4531, 0.6117, 0.469, 0.6342]}, {"w": "=", "b": [0.4741, 0.6119, 0.4862, 0.6333]}, {"w": "3", "b": [0.4913, 0.6119, 0.5013, 0.6333]}, {"w": "instead", "b": [0.5064, 0.6119, 0.5664, 0.6333]}, {"w": "of", "b": [0.5715, 0.6119, 0.5883, 0.6333]}, {"w": "θ0", "b": [0.5934, 0.6117, 0.6093, 0.6342]}, {"w": "=", "b": [0.6144, 0.6119, 0.6265, 0.6333]}, {"w": "4.215", "b": [0.6316, 0.6119, 0.6763, 0.6333]}, {"w": "and", "b": [0.6814, 0.6119, 0.713, 0.6333]}, {"w": "θ1", "b": [0.7181, 0.6117, 0.734, 0.6342]}, {"w": "=", "b": [0.7391, 0.6119, 0.7512, 0.6333]}, {"w": "2.770.", "b": [0.7563, 0.6119, 0.8058, 0.6333]}, {"w": "Close", "b": [0.8109, 0.6119, 0.8572, 0.6333]}, {"w": "enough,", "b": [0.1429, 0.6309, 0.2104, 0.6523]}, {"w": "but", "b": [0.2154, 0.6309, 0.2434, 0.6523]}, {"w": "the", "b": [0.2483, 0.6309, 0.2746, 0.6523]}, {"w": "noise", "b": [0.2796, 0.6309, 0.3237, 0.6523]}, {"w": "made", "b": [0.3286, 0.6309, 0.3747, 0.6523]}, {"w": "it", "b": [0.3796, 0.6309, 0.3915, 0.6523]}, {"w": "impossible", "b": [0.3965, 0.6309, 0.4859, 0.6523]}, {"w": "to", "b": [0.4908, 0.6309, 0.5078, 0.6523]}, {"w": "recover", "b": [0.5127, 0.6309, 0.575, 0.6523]}, {"w": "the", "b": [0.5799, 0.6309, 0.6062, 0.6523]}, {"w": "exact", "b": [0.6112, 0.6309, 0.6542, 0.6523]}, {"w": "parameters", "b": [0.6591, 0.6309, 0.7525, 0.6523]}, {"w": "of", "b": [0.7575, 0.6309, 0.7743, 0.6523]}, {"w": "the", "b": [0.7792, 0.6309, 0.8055, 0.6523]}, {"w": "origi‐", "b": [0.8105, 0.6309, 0.8571, 0.6523]}, {"w": "nal", "b": [0.1429, 0.65, 0.1687, 0.6714]}, {"w": "function.", "b": [0.1734, 0.65, 0.2495, 0.6714]}]}, {"id": "b_6", "type": "paragraph", "text": "Now you can make predictions using θ:", "words": [{"w": "Now", "b": [0.1429, 0.6812, 0.1827, 0.7026]}, {"w": "you", "b": [0.1874, 0.6812, 0.2187, 0.7026]}, {"w": "can", "b": [0.2234, 0.6812, 0.2528, 0.7026]}, {"w": "make", "b": [0.2575, 0.6812, 0.3029, 0.7026]}, {"w": "predictions", "b": [0.3076, 0.6812, 0.4021, 0.7026]}, {"w": "using", "b": [0.4069, 0.6812, 0.4523, 0.7026]}, {"w": "θ:", "b": [0.4576, 0.6806, 0.4736, 0.7026]}]}, {"id": "b_7", "type": "paragraph", "text": ">>> X_new = np.array([[0], [2]]) >>> X_new_b = np.c_[np.ones((2, 1)), X_new] # add x0 = 1 to each instance >>> y_predict = X_new_b.dot(theta_best) >>> y_predict array([[4.21509616], [9.75532293]])", "words": [{"w": ">>>", "b": [0.1766, 0.7132, 0.2019, 0.726]}, {"w": "X_new", "b": [0.2103, 0.7132, 0.2525, 0.726]}, {"w": "=", "b": [0.2609, 0.7132, 0.2693, 0.726]}, {"w": "np.array([[0],", "b": [0.2778, 0.7132, 0.3958, 0.726]}, {"w": "[2]])", "b": [0.4043, 0.7132, 0.4464, 0.726]}, {"w": ">>>", "b": [0.1766, 0.7286, 0.2019, 0.7414]}, {"w": "X_new_b", "b": [0.2103, 0.7286, 0.2693, 0.7414]}, {"w": "=", "b": [0.2778, 0.7286, 0.2862, 0.7414]}, {"w": "np.c_[np.ones((2,", "b": [0.2946, 0.7286, 0.438, 0.7414]}, {"w": "1)),", "b": [0.4464, 0.7286, 0.4802, 0.7414]}, {"w": "X_new]", "b": [0.4886, 0.7286, 0.5392, 0.7414]}, {"w": "#", "b": [0.5476, 0.7286, 0.5561, 0.7414]}, {"w": "add", "b": [0.5645, 0.7286, 0.5898, 0.7414]}, {"w": "x0", "b": [0.5982, 0.7286, 0.6151, 0.7414]}, {"w": "=", "b": [0.6235, 0.7286, 0.6319, 0.7414]}, {"w": "1", "b": [0.6404, 0.7286, 0.6488, 0.7414]}, {"w": "to", "b": [0.6572, 0.7286, 0.6741, 0.7414]}, {"w": "each", "b": [0.6825, 0.7286, 0.7163, 0.7414]}, {"w": "instance", "b": [0.7247, 0.7286, 0.7922, 0.7414]}, {"w": ">>>", "b": [0.1766, 0.744, 0.2019, 0.7569]}, {"w": "y_predict", "b": [0.2103, 0.744, 0.2862, 0.7569]}, {"w": "=", "b": [0.2946, 0.744, 0.3031, 0.7569]}, {"w": "X_new_b.dot(theta_best)", "b": [0.3115, 0.744, 0.5055, 0.7569]}, {"w": ">>>", "b": [0.1766, 0.7594, 0.2019, 0.7723]}, {"w": "y_predict", "b": [0.2103, 0.7594, 0.2862, 0.7723]}, {"w": "array([[4.21509616],", "b": [0.1766, 0.7749, 0.3452, 0.7877]}, {"w": "[9.75532293]])", "b": [0.2356, 0.7903, 0.3537, 0.8031]}]}, {"id": "b_8", "type": "equation", "text": "Let’s plot this model’s predictions (Figure 4-2):", "words": [{"w": "Let’s", "b": [0.1429, 0.8109, 0.179, 0.8323]}, {"w": "plot", "b": [0.1838, 0.8109, 0.2169, 0.8323]}, {"w": "this", "b": [0.2217, 0.8109, 0.2524, 0.8323]}, {"w": "model’s", "b": [0.2571, 0.8109, 0.3197, 0.8323]}, {"w": "predictions", "b": [0.3244, 0.8109, 0.4189, 0.8323]}, {"w": "(Figure", "b": [0.4236, 0.8109, 0.4848, 0.8323]}, {"w": "4-2):", "b": [0.4896, 0.8109, 0.5289, 0.8323]}]}, {"id": "b_9", "type": "equation", "text": "plt.plot(X_new, y_predict, \"r-\") plt.plot(X, y, \"b.\")", "words": [{"w": "plt.plot(X_new,", "b": [0.1766, 0.8429, 0.3031, 0.8557]}, {"w": "y_predict,", "b": [0.3115, 0.8429, 0.3958, 0.8557]}, {"w": "\"r-\")", "b": [0.4043, 0.8429, 0.4464, 0.8557]}, {"w": "plt.plot(X,", "b": [0.1766, 0.8583, 0.2693, 0.8711]}, {"w": "y,", "b": [0.2778, 0.8583, 0.2946, 0.8711]}, {"w": "\"b.\")", "b": [0.3031, 0.8583, 0.3452, 0.8711]}]}, {"id": "b_10", "type": "paragraph", "text": "Linear Regression | 117", "words": [{"w": "Linear", "b": [0.6919, 0.9225, 0.7288, 0.9388]}, {"w": "Regression", "b": [0.7316, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "117", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 144, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "3 Note that Scikit-Learn separates the bias term (intercept_) from the feature weights (coef_).", "words": [{"w": "3", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "Note", "b": [0.1587, 0.8749, 0.1898, 0.8912]}, {"w": "that", "b": [0.1934, 0.8749, 0.2182, 0.8912]}, {"w": "Scikit-Learn", "b": [0.2218, 0.8749, 0.2998, 0.8912]}, {"w": "separates", "b": [0.3034, 0.8749, 0.3612, 0.8912]}, {"w": "the", "b": [0.3648, 0.8749, 0.3849, 0.8912]}, {"w": "bias", "b": [0.3885, 0.8749, 0.4136, 0.8912]}, {"w": "term", "b": [0.4172, 0.8749, 0.4477, 0.8912]}, {"w": "(intercept_)", "b": [0.4513, 0.8749, 0.5377, 0.8912]}, {"w": "from", "b": [0.5413, 0.8749, 0.5729, 0.8912]}, {"w": "the", "b": [0.5765, 0.8749, 0.5966, 0.8912]}, {"w": "feature", "b": [0.6002, 0.8749, 0.6442, 0.8912]}, {"w": "weights", "b": [0.6478, 0.8749, 0.696, 0.8912]}, {"w": "(coef_).", "b": [0.6996, 0.8749, 0.7519, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "plt.axis([0, 2, 0, 15]) plt.show()", "words": [{"w": "plt.axis([0,", "b": [0.1766, 0.0829, 0.2778, 0.0958]}, {"w": "2,", "b": [0.2862, 0.0829, 0.3031, 0.0958]}, {"w": "0,", "b": [0.3115, 0.0829, 0.3284, 0.0958]}, {"w": "15])", "b": [0.3368, 0.0829, 0.3705, 0.0958]}, {"w": "plt.show()", "b": [0.1766, 0.0983, 0.2609, 0.1112]}]}, {"id": "b_2", "type": "equation", "text": "Figure 4-2. Linear Regression model predictions", "words": [{"w": "Figure", "b": [0.1429, 0.3835, 0.1943, 0.4051]}, {"w": "4-2.", "b": [0.1991, 0.3835, 0.2308, 0.4051]}, {"w": "Linear", "b": [0.2356, 0.3835, 0.2882, 0.4051]}, {"w": "Regression", "b": [0.293, 0.3835, 0.3777, 0.4051]}, {"w": "model", "b": [0.3825, 0.3835, 0.4322, 0.4051]}, {"w": "predictions", "b": [0.4369, 0.3835, 0.5257, 0.4051]}]}, {"id": "b_3", "type": "equation", "text": "Performing linear regression using Scikit-Learn is quite simple:3", "words": [{"w": "Performing", "b": [0.1429, 0.4209, 0.2388, 0.4423]}, {"w": "linear", "b": [0.2435, 0.4209, 0.2915, 0.4423]}, {"w": "regression", "b": [0.2962, 0.4209, 0.3821, 0.4423]}, {"w": "using", "b": [0.3868, 0.4209, 0.4322, 0.4423]}, {"w": "Scikit-Learn", "b": [0.437, 0.4209, 0.5392, 0.4423]}, {"w": "is", "b": [0.544, 0.4209, 0.5572, 0.4423]}, {"w": "quite", "b": [0.5619, 0.4209, 0.6044, 0.4423]}, {"w": "simple:3", "b": [0.6092, 0.4209, 0.6746, 0.4423]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> from sklearn.linear_model import LinearRegression >>> lin_reg = LinearRegression() >>> lin_reg.fit(X, y) >>> lin_reg.intercept_, lin_reg.coef_ (array([4.21509616]), array([[2.77011339]])) >>> lin_reg.predict(X_new) array([[4.21509616], [9.75532293]])", "words": [{"w": ">>>", "b": [0.1766, 0.4529, 0.2019, 0.4657]}, {"w": "from", "b": [0.2103, 0.4529, 0.244, 0.4657]}, {"w": "sklearn.linear_model", "b": [0.2525, 0.4529, 0.4211, 0.4657]}, {"w": "import", "b": [0.4296, 0.4529, 0.4802, 0.4657]}, {"w": "LinearRegression", "b": [0.4886, 0.4529, 0.6235, 0.4657]}, {"w": ">>>", "b": [0.1766, 0.4683, 0.2019, 0.4812]}, {"w": "lin_reg", "b": [0.2103, 0.4683, 0.2693, 0.4812]}, {"w": "=", "b": [0.2778, 0.4683, 0.2862, 0.4812]}, {"w": "LinearRegression()", "b": [0.2946, 0.4683, 0.4464, 0.4812]}, {"w": ">>>", "b": [0.1766, 0.4837, 0.2019, 0.4966]}, {"w": "lin_reg.fit(X,", "b": [0.2103, 0.4837, 0.3284, 0.4966]}, {"w": "y)", "b": [0.3368, 0.4837, 0.3537, 0.4966]}, {"w": ">>>", "b": [0.1766, 0.4992, 0.2019, 0.512]}, {"w": "lin_reg.intercept_,", "b": [0.2103, 0.4992, 0.3705, 0.512]}, {"w": "lin_reg.coef_", "b": [0.379, 0.4992, 0.4886, 0.512]}, {"w": "(array([4.21509616]),", "b": [0.1766, 0.5146, 0.3537, 0.5274]}, {"w": "array([[2.77011339]]))", "b": [0.3621, 0.5146, 0.5476, 0.5274]}, {"w": ">>>", "b": [0.1766, 0.53, 0.2019, 0.5428]}, {"w": "lin_reg.predict(X_new)", "b": [0.2103, 0.53, 0.3958, 0.5428]}, {"w": "array([[4.21509616],", "b": [0.1766, 0.5454, 0.3452, 0.5583]}, {"w": "[9.75532293]])", "b": [0.2356, 0.5608, 0.3537, 0.5737]}]}, {"id": "b_5", "type": "paragraph", "text": "The LinearRegression class is based on the scipy.linalg.lstsq() function (the name stands for “least squares”), which you could call directly:", "words": [{"w": "The", "b": [0.1429, 0.5824, 0.1757, 0.6038]}, {"w": "LinearRegression", "b": [0.1838, 0.5855, 0.3421, 0.6006]}, {"w": "class", "b": [0.3502, 0.5824, 0.3888, 0.6038]}, {"w": "is", "b": [0.3969, 0.5824, 0.4101, 0.6038]}, {"w": "based", "b": [0.4182, 0.5824, 0.4654, 0.6038]}, {"w": "on", "b": [0.4735, 0.5824, 0.4955, 0.6038]}, {"w": "the", "b": [0.5036, 0.5824, 0.53, 0.6038]}, {"w": "scipy.linalg.lstsq()", "b": [0.5381, 0.5855, 0.736, 0.6006]}, {"w": "function", "b": [0.7441, 0.5824, 0.8155, 0.6038]}, {"w": "(the", "b": [0.8236, 0.5824, 0.8571, 0.6038]}, {"w": "name", "b": [0.1429, 0.6014, 0.1893, 0.6228]}, {"w": "stands", "b": [0.194, 0.6014, 0.2472, 0.6228]}, {"w": "for", "b": [0.252, 0.6014, 0.2765, 0.6228]}, {"w": "“least", "b": [0.2812, 0.6014, 0.3268, 0.6228]}, {"w": "squares”),", "b": [0.3315, 0.6014, 0.4137, 0.6228]}, {"w": "which", "b": [0.4184, 0.6014, 0.4693, 0.6228]}, {"w": "you", "b": [0.4741, 0.6014, 0.5053, 0.6228]}, {"w": "could", "b": [0.51, 0.6014, 0.5568, 0.6228]}, {"w": "call", "b": [0.5615, 0.6014, 0.59, 0.6228]}, {"w": "directly:", "b": [0.5948, 0.6014, 0.6633, 0.6228]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> theta_best_svd, residuals, rank, s = np.linalg.lstsq(X_b, y, rcond=1e-6) >>> theta_best_svd array([[4.21509616], [2.77011339]])", "words": [{"w": ">>>", "b": [0.1766, 0.6334, 0.2019, 0.6462]}, {"w": "theta_best_svd,", "b": [0.2103, 0.6334, 0.3368, 0.6462]}, {"w": "residuals,", "b": [0.3452, 0.6334, 0.4296, 0.6462]}, {"w": "rank,", "b": [0.438, 0.6334, 0.4802, 0.6462]}, {"w": "s", "b": [0.4886, 0.6334, 0.497, 0.6462]}, {"w": "=", "b": [0.5055, 0.6334, 0.5139, 0.6462]}, {"w": "np.linalg.lstsq(X_b,", "b": [0.5223, 0.6334, 0.691, 0.6462]}, {"w": "y,", "b": [0.6994, 0.6334, 0.7163, 0.6462]}, {"w": "rcond=1e-6)", "b": [0.7247, 0.6334, 0.8175, 0.6462]}, {"w": ">>>", "b": [0.1766, 0.6488, 0.2019, 0.6617]}, {"w": "theta_best_svd", "b": [0.2103, 0.6488, 0.3284, 0.6617]}, {"w": "array([[4.21509616],", "b": [0.1766, 0.6642, 0.3452, 0.6771]}, {"w": "[2.77011339]])", "b": [0.2356, 0.6796, 0.3537, 0.6925]}]}, {"id": "b_7", "type": "paragraph", "text": "This function computes θ = X+y, where �+ is the pseudoinverse of X (specifically the Moore-Penrose inverse). You can use np.linalg.pinv() to compute the pseudoin‐ verse directly:", "words": [{"w": "This", "b": [0.1429, 0.7038, 0.1801, 0.7252]}, {"w": "function", "b": [0.1856, 0.7038, 0.257, 0.7252]}, {"w": "computes", "b": [0.2626, 0.7038, 0.3435, 0.7252]}, {"w": "θ", "b": [0.3497, 0.7032, 0.3603, 0.7252]}, {"w": "=", "b": [0.3667, 0.7038, 0.3788, 0.7252]}, {"w": "X+y,", "b": [0.3846, 0.7006, 0.4229, 0.7252]}, {"w": "where", "b": [0.4285, 0.7038, 0.4793, 0.7252]}, {"w": "�+", "b": [0.4849, 0.6997, 0.5092, 0.7229]}, {"w": "is", "b": [0.5148, 0.7038, 0.528, 0.7252]}, {"w": "the", "b": [0.5336, 0.7038, 0.5599, 0.7252]}, {"w": "pseudoinverse", "b": [0.5655, 0.7035, 0.6785, 0.7252]}, {"w": "of", "b": [0.684, 0.7038, 0.7008, 0.7252]}, {"w": "X", "b": [0.7064, 0.7032, 0.7208, 0.7252]}, {"w": "(specifically", "b": [0.7264, 0.7038, 0.8252, 0.7252]}, {"w": "the", "b": [0.8308, 0.7038, 0.8571, 0.7252]}, {"w": "Moore-Penrose", "b": [0.1429, 0.7237, 0.2723, 0.7451]}, {"w": "inverse).", "b": [0.2795, 0.7237, 0.3507, 0.7451]}, {"w": "You", "b": [0.3579, 0.7237, 0.3903, 0.7451]}, {"w": "can", "b": [0.3975, 0.7237, 0.4268, 0.7451]}, {"w": "use", "b": [0.4341, 0.7237, 0.4616, 0.7451]}, {"w": "np.linalg.pinv()", "b": [0.4688, 0.7269, 0.6272, 0.742]}, {"w": "to", "b": [0.6344, 0.7237, 0.6514, 0.7451]}, {"w": "compute", "b": [0.6586, 0.7237, 0.7319, 0.7451]}, {"w": "the", "b": [0.7391, 0.7237, 0.7654, 0.7451]}, {"w": "pseudoin‐", "b": [0.7726, 0.7237, 0.8571, 0.7451]}, {"w": "verse", "b": [0.1428, 0.7427, 0.1856, 0.7642]}, {"w": "directly:", "b": [0.1903, 0.7427, 0.2589, 0.7642]}]}, {"id": "b_8", "type": "equation", "text": ">>> np.linalg.pinv(X_b).dot(y) array([[4.21509616], [2.77011339]])", "words": [{"w": ">>>", "b": [0.1766, 0.7747, 0.2019, 0.7876]}, {"w": "np.linalg.pinv(X_b).dot(y)", "b": [0.2103, 0.7747, 0.4296, 0.7876]}, {"w": "array([[4.21509616],", "b": [0.1766, 0.7901, 0.3452, 0.803]}, {"w": "[2.77011339]])", "b": [0.2356, 0.8056, 0.3537, 0.8184]}]}, {"id": "b_9", "type": "paragraph", "text": "118 | Chapter 4: Training Models", "words": [{"w": "118", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 145, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "The pseudoinverse itself is computed using a standard matrix factorization technique called Singular Value Decomposition (SVD) that can decompose the training set matrix X into the matrix multiplication of three matrices U Σ VT (see numpy.linalg.svd()). The pseudoinverse is computed as X+ = VΣ+UT. To compute the matrix Σ+, the algorithm takes Σ and sets to zero all values smaller than a tiny threshold value, then it replaces all the non-zero values with their inverse, and finally it transposes the resulting matrix. This approach is more efficient than computing the Normal Equation, plus it handles edge cases nicely: indeed, the Normal Equation may not work if the matrix XTX is not invertible (i.e., singular), such as if m < n or if some features are redundant, but the pseudoinverse is always defined.", "words": [{"w": "The", "b": [0.1429, 0.0791, 0.1757, 0.1005]}, {"w": "pseudoinverse", "b": [0.1805, 0.0791, 0.2998, 0.1005]}, {"w": "itself", "b": [0.3046, 0.0791, 0.3445, 0.1005]}, {"w": "is", "b": [0.3493, 0.0791, 0.3625, 0.1005]}, {"w": "computed", "b": [0.3673, 0.0791, 0.4516, 0.1005]}, {"w": "using", "b": [0.4564, 0.0791, 0.5019, 0.1005]}, {"w": "a", "b": [0.5067, 0.0791, 0.5158, 0.1005]}, {"w": "standard", "b": [0.5206, 0.0791, 0.5941, 0.1005]}, {"w": "matrix", "b": [0.5989, 0.0791, 0.6542, 0.1005]}, {"w": "factorization", "b": [0.659, 0.0791, 0.7648, 0.1005]}, {"w": "technique", "b": [0.7697, 0.0791, 0.8523, 0.1005]}, {"w": "called", "b": [0.1429, 0.0981, 0.1912, 0.1195]}, {"w": "Singular", "b": [0.2016, 0.0979, 0.2698, 0.1195]}, {"w": "Value", "b": [0.2802, 0.0979, 0.3266, 0.1195]}, {"w": "Decomposition", "b": [0.3371, 0.0979, 0.458, 0.1195]}, {"w": "(SVD)", "b": [0.4684, 0.0981, 0.5227, 0.1195]}, {"w": "that", "b": [0.5331, 0.0981, 0.5657, 0.1195]}, {"w": "can", "b": [0.5761, 0.0981, 0.6054, 0.1195]}, {"w": "decompose", "b": [0.6158, 0.0981, 0.7098, 0.1195]}, {"w": "the", "b": [0.7202, 0.0981, 0.7465, 0.1195]}, {"w": "training", "b": [0.7569, 0.0981, 0.8239, 0.1195]}, {"w": "set", "b": [0.8343, 0.0981, 0.8571, 0.1195]}, {"w": "matrix", "b": [0.1429, 0.1172, 0.1982, 0.1386]}, {"w": "X", "b": [0.2147, 0.1166, 0.2291, 0.1386]}, {"w": "into", "b": [0.2456, 0.1172, 0.2791, 0.1386]}, {"w": "the", "b": [0.2956, 0.1172, 0.3219, 0.1386]}, {"w": "matrix", "b": [0.3384, 0.1172, 0.3937, 0.1386]}, {"w": "multiplication", "b": [0.4102, 0.1172, 0.5284, 0.1386]}, {"w": "of", "b": [0.5449, 0.1172, 0.5617, 0.1386]}, {"w": "three", "b": [0.5782, 0.1172, 0.6211, 0.1386]}, {"w": "matrices", "b": [0.6376, 0.1172, 0.7084, 0.1386]}, {"w": "U", "b": [0.7249, 0.1166, 0.7401, 0.1386]}, {"w": "Σ", "b": [0.7565, 0.1166, 0.7693, 0.1386]}, {"w": "VT", "b": [0.7858, 0.1166, 0.8081, 0.1386]}, {"w": "(see", "b": [0.8246, 0.1172, 0.8571, 0.1386]}, {"w": "numpy.linalg.svd()).", "b": [0.1429, 0.1388, 0.3329, 0.1602]}, {"w": "The", "b": [0.3391, 0.1388, 0.3719, 0.1602]}, {"w": "pseudoinverse", "b": [0.3781, 0.1388, 0.4974, 0.1602]}, {"w": "is", "b": [0.5036, 0.1388, 0.5168, 0.1602]}, {"w": "computed", "b": [0.5229, 0.1388, 0.6072, 0.1602]}, {"w": "as", "b": [0.6134, 0.1388, 0.6302, 0.1602]}, {"w": "X+", "b": [0.6363, 0.1356, 0.66, 0.1602]}, {"w": "=", "b": [0.6657, 0.1388, 0.6778, 0.1602]}, {"w": "VΣ+UT.", "b": [0.6836, 0.1356, 0.7501, 0.1602]}, {"w": "To", "b": [0.7563, 0.1388, 0.7777, 0.1602]}, {"w": "compute", "b": [0.7838, 0.1388, 0.8571, 0.1602]}, {"w": "the", "b": [0.1429, 0.1604, 0.1692, 0.1818]}, {"w": "matrix", "b": [0.1764, 0.1604, 0.2317, 0.1818]}, {"w": "Σ+,", "b": [0.2389, 0.1572, 0.2656, 0.1818]}, {"w": "the", "b": [0.2728, 0.1604, 0.2991, 0.1818]}, {"w": "algorithm", "b": [0.3063, 0.1604, 0.3889, 0.1818]}, {"w": "takes", "b": [0.3961, 0.1604, 0.4385, 0.1818]}, {"w": "Σ", "b": [0.4456, 0.1598, 0.4584, 0.1818]}, {"w": "and", "b": [0.4656, 0.1604, 0.4971, 0.1818]}, {"w": "sets", "b": [0.5043, 0.1604, 0.5348, 0.1818]}, {"w": "to", "b": [0.542, 0.1604, 0.559, 0.1818]}, {"w": "zero", "b": [0.5662, 0.1604, 0.6021, 0.1818]}, {"w": "all", "b": [0.6093, 0.1604, 0.629, 0.1818]}, {"w": "values", "b": [0.6362, 0.1604, 0.6878, 0.1818]}, {"w": "smaller", "b": [0.695, 0.1604, 0.756, 0.1818]}, {"w": "than", "b": [0.7632, 0.1604, 0.8012, 0.1818]}, {"w": "a", "b": [0.8084, 0.1604, 0.8175, 0.1818]}, {"w": "tiny", "b": [0.8247, 0.1604, 0.8572, 0.1818]}, {"w": "threshold", "b": [0.1429, 0.1794, 0.2226, 0.2009]}, {"w": "value,", "b": [0.2279, 0.1794, 0.2767, 0.2009]}, {"w": "then", "b": [0.282, 0.1794, 0.3198, 0.2009]}, {"w": "it", "b": [0.3251, 0.1794, 0.337, 0.2009]}, {"w": "replaces", "b": [0.3424, 0.1794, 0.4096, 0.2009]}, {"w": "all", "b": [0.415, 0.1794, 0.4347, 0.2009]}, {"w": "the", "b": [0.44, 0.1794, 0.4664, 0.2009]}, {"w": "non-zero", "b": [0.4717, 0.1794, 0.5485, 0.2009]}, {"w": "values", "b": [0.5539, 0.1794, 0.6055, 0.2009]}, {"w": "with", "b": [0.6108, 0.1794, 0.6482, 0.2009]}, {"w": "their", "b": [0.6535, 0.1794, 0.6932, 0.2009]}, {"w": "inverse,", "b": [0.6985, 0.1794, 0.7625, 0.2009]}, {"w": "and", "b": [0.7679, 0.1794, 0.7994, 0.2009]}, {"w": "finally", "b": [0.8048, 0.1794, 0.8571, 0.2009]}, {"w": "it", "b": [0.1429, 0.1985, 0.1548, 0.2199]}, {"w": "transposes", "b": [0.1597, 0.1985, 0.2476, 0.2199]}, {"w": "the", "b": [0.2525, 0.1985, 0.2789, 0.2199]}, {"w": "resulting", "b": [0.2838, 0.1985, 0.3574, 0.2199]}, {"w": "matrix.", "b": [0.3623, 0.1985, 0.4224, 0.2199]}, {"w": "This", "b": [0.4273, 0.1985, 0.4645, 0.2199]}, {"w": "approach", "b": [0.4694, 0.1985, 0.5474, 0.2199]}, {"w": "is", "b": [0.5523, 0.1985, 0.5655, 0.2199]}, {"w": "more", "b": [0.5704, 0.1985, 0.6147, 0.2199]}, {"w": "efficient", "b": [0.6196, 0.1985, 0.6869, 0.2199]}, {"w": "than", "b": [0.6918, 0.1985, 0.7299, 0.2199]}, {"w": "computing", "b": [0.7347, 0.1985, 0.8259, 0.2199]}, {"w": "the", "b": [0.8308, 0.1985, 0.8571, 0.2199]}, {"w": "Normal", "b": [0.1428, 0.2175, 0.2076, 0.2389]}, {"w": "Equation,", "b": [0.2124, 0.2175, 0.2934, 0.2389]}, {"w": "plus", "b": [0.2982, 0.2175, 0.3331, 0.2389]}, {"w": "it", "b": [0.3379, 0.2175, 0.3499, 0.2389]}, {"w": "handles", "b": [0.3547, 0.2175, 0.4191, 0.2389]}, {"w": "edge", "b": [0.4239, 0.2175, 0.4624, 0.2389]}, {"w": "cases", "b": [0.4672, 0.2175, 0.5093, 0.2389]}, {"w": "nicely:", "b": [0.5141, 0.2175, 0.5689, 0.2389]}, {"w": "indeed,", "b": [0.5737, 0.2175, 0.6352, 0.2389]}, {"w": "the", "b": [0.64, 0.2175, 0.6663, 0.2389]}, {"w": "Normal", "b": [0.6711, 0.2175, 0.7359, 0.2389]}, {"w": "Equation", "b": [0.7407, 0.2175, 0.8169, 0.2389]}, {"w": "may", "b": [0.8217, 0.2175, 0.8571, 0.2389]}, {"w": "not", "b": [0.1429, 0.2366, 0.1712, 0.258]}, {"w": "work", "b": [0.1763, 0.2366, 0.2193, 0.258]}, {"w": "if", "b": [0.2243, 0.2366, 0.2361, 0.258]}, {"w": "the", "b": [0.2411, 0.2366, 0.2675, 0.258]}, {"w": "matrix", "b": [0.2725, 0.2366, 0.3278, 0.258]}, {"w": "XTX", "b": [0.3329, 0.236, 0.3695, 0.258]}, {"w": "is", "b": [0.3745, 0.2366, 0.3877, 0.258]}, {"w": "not", "b": [0.3928, 0.2366, 0.4212, 0.258]}, {"w": "invertible", "b": [0.4262, 0.2366, 0.5056, 0.258]}, {"w": "(i.e.,", "b": [0.5107, 0.2366, 0.5466, 0.258]}, {"w": "singular),", "b": [0.5516, 0.2366, 0.6312, 0.258]}, {"w": "such", "b": [0.6362, 0.2366, 0.6749, 0.258]}, {"w": "as", "b": [0.6799, 0.2366, 0.6967, 0.258]}, {"w": "if", "b": [0.7018, 0.2366, 0.7135, 0.258]}, {"w": "m", "b": [0.7186, 0.2364, 0.735, 0.258]}, {"w": "<", "b": [0.74, 0.2366, 0.7515, 0.258]}, {"w": "n", "b": [0.7566, 0.2364, 0.7677, 0.258]}, {"w": "or", "b": [0.7727, 0.2366, 0.7911, 0.258]}, {"w": "if", "b": [0.7958, 0.2366, 0.8076, 0.258]}, {"w": "some", "b": [0.8123, 0.2366, 0.8565, 0.258]}, {"w": "features", "b": [0.1429, 0.2556, 0.2083, 0.277]}, {"w": "are", "b": [0.213, 0.2556, 0.2387, 0.277]}, {"w": "redundant,", "b": [0.2435, 0.2556, 0.3358, 0.277]}, {"w": "but", "b": [0.3405, 0.2556, 0.3685, 0.277]}, {"w": "the", "b": [0.3732, 0.2556, 0.3995, 0.277]}, {"w": "pseudoinverse", "b": [0.4043, 0.2556, 0.5236, 0.277]}, {"w": "is", "b": [0.5283, 0.2556, 0.5416, 0.277]}, {"w": "always", "b": [0.5463, 0.2556, 0.601, 0.277]}, {"w": "defined.", "b": [0.6057, 0.2556, 0.6733, 0.277]}]}, {"id": "b_1", "type": "paragraph", "text": "Computational Complexity", "words": [{"w": "Computational", "b": [0.1429, 0.2898, 0.2969, 0.3184]}, {"w": "Complexity", "b": [0.3019, 0.2898, 0.4179, 0.3184]}]}, {"id": "b_2", "type": "paragraph", "text": "The Normal Equation computes the inverse of XT X, which is an (n + 1) × (n + 1) matrix (where n is the number of features). The computational complexity of inverting such a matrix is typically about O(n2.4) to O(n3) (depending on the implementation). In other words, if you double the number of features, you multiply the computation time by roughly 22.4 = 5.3 to 23 = 8.", "words": [{"w": "The", "b": [0.1429, 0.3243, 0.1757, 0.3457]}, {"w": "Normal", "b": [0.1826, 0.3243, 0.2474, 0.3457]}, {"w": "Equation", "b": [0.2543, 0.3243, 0.3305, 0.3457]}, {"w": "computes", "b": [0.3374, 0.3243, 0.4183, 0.3457]}, {"w": "the", "b": [0.4252, 0.3243, 0.4516, 0.3457]}, {"w": "inverse", "b": [0.4585, 0.3243, 0.5177, 0.3457]}, {"w": "of", "b": [0.5246, 0.3243, 0.5414, 0.3457]}, {"w": "XT", "b": [0.5483, 0.3237, 0.5702, 0.3457]}, {"w": "X,", "b": [0.5771, 0.3237, 0.5963, 0.3457]}, {"w": "which", "b": [0.6032, 0.3243, 0.6541, 0.3457]}, {"w": "is", "b": [0.661, 0.3243, 0.6742, 0.3457]}, {"w": "an", "b": [0.6811, 0.3243, 0.7017, 0.3457]}, {"w": "(n", "b": [0.7085, 0.3241, 0.7268, 0.3457]}, {"w": "+", "b": [0.7337, 0.3243, 0.7458, 0.3457]}, {"w": "1)", "b": [0.7527, 0.3243, 0.7699, 0.3457]}, {"w": "×", "b": [0.7768, 0.3243, 0.7889, 0.3457]}, {"w": "(n", "b": [0.7958, 0.3241, 0.8141, 0.3457]}, {"w": "+", "b": [0.821, 0.3243, 0.833, 0.3457]}, {"w": "1)", "b": [0.8399, 0.3243, 0.8571, 0.3457]}, {"w": "matrix", "b": [0.1429, 0.3433, 0.1982, 0.3647]}, {"w": "(where", "b": [0.2029, 0.3433, 0.261, 0.3647]}, {"w": "n", "b": [0.2661, 0.3431, 0.2771, 0.3647]}, {"w": "is", "b": [0.2821, 0.3433, 0.2953, 0.3647]}, {"w": "the", "b": [0.3002, 0.3433, 0.3265, 0.3647]}, {"w": "number", "b": [0.3315, 0.3433, 0.3978, 0.3647]}, {"w": "of", "b": [0.4027, 0.3433, 0.4195, 0.3647]}, {"w": "features).", "b": [0.4244, 0.3433, 0.5018, 0.3647]}, {"w": "The", "b": [0.5067, 0.3433, 0.5395, 0.3647]}, {"w": "computational", "b": [0.5444, 0.3431, 0.6621, 0.3647]}, {"w": "complexity", "b": [0.6668, 0.3431, 0.7545, 0.3647]}, {"w": "of", "b": [0.7596, 0.3433, 0.7764, 0.3647]}, {"w": "inverting", "b": [0.7811, 0.3433, 0.857, 0.3647]}, {"w": "such", "b": [0.1429, 0.3624, 0.1815, 0.3838]}, {"w": "a", "b": [0.1875, 0.3624, 0.1966, 0.3838]}, {"w": "matrix", "b": [0.2026, 0.3624, 0.2579, 0.3838]}, {"w": "is", "b": [0.2639, 0.3624, 0.2771, 0.3838]}, {"w": "typically", "b": [0.2831, 0.3624, 0.3536, 0.3838]}, {"w": "about", "b": [0.3596, 0.3624, 0.4074, 0.3838]}, {"w": "O(n2.4)", "b": [0.4134, 0.3622, 0.4685, 0.3838]}, {"w": "to", "b": [0.4744, 0.3624, 0.4914, 0.3838]}, {"w": "O(n3)", "b": [0.4974, 0.3622, 0.5437, 0.3838]}, {"w": "(depending", "b": [0.5496, 0.3624, 0.6456, 0.3838]}, {"w": "on", "b": [0.6516, 0.3624, 0.6736, 0.3838]}, {"w": "the", "b": [0.6796, 0.3624, 0.7059, 0.3838]}, {"w": "implementation).", "b": [0.7119, 0.3624, 0.8571, 0.3838]}, {"w": "In", "b": [0.1429, 0.3814, 0.1614, 0.4028]}, {"w": "other", "b": [0.1675, 0.3814, 0.2122, 0.4028]}, {"w": "words,", "b": [0.2183, 0.3814, 0.2743, 0.4028]}, {"w": "if", "b": [0.2804, 0.3814, 0.2922, 0.4028]}, {"w": "you", "b": [0.2983, 0.3814, 0.3296, 0.4028]}, {"w": "double", "b": [0.3357, 0.3814, 0.3931, 0.4028]}, {"w": "the", "b": [0.3992, 0.3814, 0.4256, 0.4028]}, {"w": "number", "b": [0.4317, 0.3814, 0.498, 0.4028]}, {"w": "of", "b": [0.5041, 0.3814, 0.5209, 0.4028]}, {"w": "features,", "b": [0.527, 0.3814, 0.5972, 0.4028]}, {"w": "you", "b": [0.6033, 0.3814, 0.6346, 0.4028]}, {"w": "multiply", "b": [0.6407, 0.3814, 0.7114, 0.4028]}, {"w": "the", "b": [0.7175, 0.3814, 0.7439, 0.4028]}, {"w": "computation", "b": [0.75, 0.3814, 0.8571, 0.4028]}, {"w": "time", "b": [0.1429, 0.4005, 0.1807, 0.4219]}, {"w": "by", "b": [0.1854, 0.4005, 0.2056, 0.4219]}, {"w": "roughly", "b": [0.2103, 0.4005, 0.2754, 0.4219]}, {"w": "22.4", "b": [0.2802, 0.4005, 0.305, 0.4219]}, {"w": "=", "b": [0.3098, 0.4005, 0.3218, 0.4219]}, {"w": "5.3", "b": [0.3266, 0.4005, 0.3513, 0.4219]}, {"w": "to", "b": [0.356, 0.4005, 0.373, 0.4219]}, {"w": "23", "b": [0.3778, 0.4005, 0.3938, 0.4219]}, {"w": "=", "b": [0.3985, 0.4005, 0.4106, 0.4219]}, {"w": "8.", "b": [0.4153, 0.4005, 0.43, 0.4219]}]}, {"id": "b_3", "type": "paragraph", "text": "The SVD approach used by Scikit-Learn’s LinearRegression class is about O(n2). If you double the number of features, you multiply the computation time by roughly 4.", "words": [{"w": "The", "b": [0.1429, 0.4295, 0.1757, 0.4509]}, {"w": "SVD", "b": [0.1822, 0.4295, 0.2221, 0.4509]}, {"w": "approach", "b": [0.2286, 0.4295, 0.3066, 0.4509]}, {"w": "used", "b": [0.3132, 0.4295, 0.3517, 0.4509]}, {"w": "by", "b": [0.3582, 0.4295, 0.3784, 0.4509]}, {"w": "Scikit-Learn’s", "b": [0.3849, 0.4295, 0.4958, 0.4509]}, {"w": "LinearRegression", "b": [0.5024, 0.4327, 0.6607, 0.4477]}, {"w": "class", "b": [0.6672, 0.4295, 0.7057, 0.4509]}, {"w": "is", "b": [0.7123, 0.4295, 0.7255, 0.4509]}, {"w": "about", "b": [0.732, 0.4295, 0.7798, 0.4509]}, {"w": "O(n2).", "b": [0.7863, 0.4293, 0.8373, 0.4509]}, {"w": "If", "b": [0.8439, 0.4295, 0.8571, 0.4509]}, {"w": "you", "b": [0.1429, 0.4485, 0.1741, 0.4699]}, {"w": "double", "b": [0.1788, 0.4485, 0.2362, 0.4699]}, {"w": "the", "b": [0.241, 0.4485, 0.2673, 0.4699]}, {"w": "number", "b": [0.272, 0.4485, 0.3383, 0.4699]}, {"w": "of", "b": [0.343, 0.4485, 0.3598, 0.4699]}, {"w": "features,", "b": [0.3646, 0.4485, 0.4347, 0.4699]}, {"w": "you", "b": [0.4395, 0.4485, 0.4707, 0.4699]}, {"w": "multiply", "b": [0.4754, 0.4485, 0.5461, 0.4699]}, {"w": "the", "b": [0.5509, 0.4485, 0.5772, 0.4699]}, {"w": "computation", "b": [0.5819, 0.4485, 0.6891, 0.4699]}, {"w": "time", "b": [0.6938, 0.4485, 0.7316, 0.4699]}, {"w": "by", "b": [0.7364, 0.4485, 0.7565, 0.4699]}, {"w": "roughly", "b": [0.7613, 0.4485, 0.8264, 0.4699]}, {"w": "4.", "b": [0.8311, 0.4485, 0.8459, 0.4699]}]}, {"id": "b_4", "type": "paragraph", "text": "Both the Normal Equation and the SVD approach get very slow when the number of features grows large (e.g., 100,000). On the positive side, both are linear with regards to the number of instan‐ ces in the training set (they are O(m)), so they handle large training sets efficiently, provided they can fit in memory.", "words": [{"w": "Both", "b": [0.2714, 0.4905, 0.3087, 0.51]}, {"w": "the", "b": [0.316, 0.4905, 0.34, 0.51]}, {"w": "Normal", "b": [0.3473, 0.4905, 0.4065, 0.51]}, {"w": "Equation", "b": [0.4138, 0.4905, 0.4835, 0.51]}, {"w": "and", "b": [0.4908, 0.4905, 0.5196, 0.51]}, {"w": "the", "b": [0.5269, 0.4905, 0.551, 0.51]}, {"w": "SVD", "b": [0.5582, 0.4905, 0.5947, 0.51]}, {"w": "approach", "b": [0.6019, 0.4905, 0.6733, 0.51]}, {"w": "get", "b": [0.6805, 0.4905, 0.7033, 0.51]}, {"w": "very", "b": [0.7106, 0.4905, 0.7439, 0.51]}, {"w": "slow", "b": [0.7512, 0.4905, 0.7857, 0.51]}, {"w": "when", "b": [0.2714, 0.5079, 0.3132, 0.5275]}, {"w": "the", "b": [0.3206, 0.5079, 0.3447, 0.5275]}, {"w": "number", "b": [0.3521, 0.5079, 0.4127, 0.5275]}, {"w": "of", "b": [0.4201, 0.5079, 0.4355, 0.5275]}, {"w": "features", "b": [0.4429, 0.5079, 0.5027, 0.5275]}, {"w": "grows", "b": [0.5101, 0.5079, 0.5559, 0.5275]}, {"w": "large", "b": [0.5633, 0.5079, 0.6005, 0.5275]}, {"w": "(e.g.,", "b": [0.608, 0.5079, 0.6446, 0.5275]}, {"w": "100,000).", "b": [0.652, 0.5079, 0.7221, 0.5275]}, {"w": "On", "b": [0.7296, 0.5079, 0.7542, 0.5275]}, {"w": "the", "b": [0.7616, 0.5079, 0.7857, 0.5275]}, {"w": "positive", "b": [0.2714, 0.5253, 0.331, 0.5449]}, {"w": "side,", "b": [0.3362, 0.5253, 0.3708, 0.5449]}, {"w": "both", "b": [0.376, 0.5253, 0.4114, 0.5449]}, {"w": "are", "b": [0.4166, 0.5253, 0.4401, 0.5449]}, {"w": "linear", "b": [0.4453, 0.5253, 0.4892, 0.5449]}, {"w": "with", "b": [0.4944, 0.5253, 0.5285, 0.5449]}, {"w": "regards", "b": [0.5337, 0.5253, 0.5903, 0.5449]}, {"w": "to", "b": [0.5955, 0.5253, 0.611, 0.5449]}, {"w": "the", "b": [0.6162, 0.5253, 0.6403, 0.5449]}, {"w": "number", "b": [0.6455, 0.5253, 0.7061, 0.5449]}, {"w": "of", "b": [0.7113, 0.5253, 0.7266, 0.5449]}, {"w": "instan‐", "b": [0.7318, 0.5253, 0.7857, 0.5449]}, {"w": "ces", "b": [0.2714, 0.5427, 0.2946, 0.5623]}, {"w": "in", "b": [0.2991, 0.5427, 0.3146, 0.5623]}, {"w": "the", "b": [0.3191, 0.5427, 0.3432, 0.5623]}, {"w": "training", "b": [0.3477, 0.5427, 0.4089, 0.5623]}, {"w": "set", "b": [0.4134, 0.5427, 0.4343, 0.5623]}, {"w": "(they", "b": [0.4388, 0.5427, 0.4782, 0.5623]}, {"w": "are", "b": [0.4827, 0.5427, 0.5062, 0.5623]}, {"w": "O(m)),", "b": [0.5107, 0.5425, 0.5633, 0.5623]}, {"w": "so", "b": [0.5678, 0.5427, 0.5845, 0.5623]}, {"w": "they", "b": [0.589, 0.5427, 0.6218, 0.5623]}, {"w": "handle", "b": [0.6263, 0.5427, 0.6783, 0.5623]}, {"w": "large", "b": [0.6828, 0.5427, 0.72, 0.5623]}, {"w": "training", "b": [0.7245, 0.5427, 0.7857, 0.5623]}, {"w": "sets", "b": [0.2714, 0.5601, 0.2993, 0.5797]}, {"w": "efficiently,", "b": [0.3036, 0.5601, 0.3817, 0.5797]}, {"w": "provided", "b": [0.3861, 0.5601, 0.455, 0.5797]}, {"w": "they", "b": [0.4593, 0.5601, 0.4921, 0.5797]}, {"w": "can", "b": [0.4964, 0.5601, 0.5233, 0.5797]}, {"w": "fit", "b": [0.5276, 0.5601, 0.5441, 0.5797]}, {"w": "in", "b": [0.5485, 0.5601, 0.564, 0.5797]}, {"w": "memory.", "b": [0.5683, 0.5601, 0.6366, 0.5797]}]}, {"id": "b_5", "type": "paragraph", "text": "Also, once you have trained your Linear Regression model (using the Normal Equa‐ tion or any other algorithm), predictions are very fast: the computational complexity is linear with regards to both the number of instances you want to make predictions on and the number of features. In other words, making predictions on twice as many instances (or twice as many features) will just take roughly twice as much time.", "words": [{"w": "Also,", "b": [0.1429, 0.6, 0.185, 0.6214]}, {"w": "once", "b": [0.191, 0.6, 0.2307, 0.6214]}, {"w": "you", "b": [0.2367, 0.6, 0.2679, 0.6214]}, {"w": "have", "b": [0.2739, 0.6, 0.3123, 0.6214]}, {"w": "trained", "b": [0.3184, 0.6, 0.3784, 0.6214]}, {"w": "your", "b": [0.3844, 0.6, 0.4234, 0.6214]}, {"w": "Linear", "b": [0.4294, 0.6, 0.4833, 0.6214]}, {"w": "Regression", "b": [0.4894, 0.6, 0.5804, 0.6214]}, {"w": "model", "b": [0.5864, 0.6, 0.6392, 0.6214]}, {"w": "(using", "b": [0.6452, 0.6, 0.6979, 0.6214]}, {"w": "the", "b": [0.7039, 0.6, 0.7302, 0.6214]}, {"w": "Normal", "b": [0.7362, 0.6, 0.801, 0.6214]}, {"w": "Equa‐", "b": [0.807, 0.6, 0.8572, 0.6214]}, {"w": "tion", "b": [0.1429, 0.619, 0.1768, 0.6405]}, {"w": "or", "b": [0.1825, 0.619, 0.2008, 0.6405]}, {"w": "any", "b": [0.2064, 0.619, 0.2361, 0.6405]}, {"w": "other", "b": [0.2417, 0.619, 0.2864, 0.6405]}, {"w": "algorithm),", "b": [0.292, 0.619, 0.3866, 0.6405]}, {"w": "predictions", "b": [0.3923, 0.619, 0.4868, 0.6405]}, {"w": "are", "b": [0.4924, 0.619, 0.5181, 0.6405]}, {"w": "very", "b": [0.5238, 0.619, 0.5602, 0.6405]}, {"w": "fast:", "b": [0.5658, 0.619, 0.5999, 0.6405]}, {"w": "the", "b": [0.6055, 0.619, 0.6318, 0.6405]}, {"w": "computational", "b": [0.6375, 0.619, 0.759, 0.6405]}, {"w": "complexity", "b": [0.7647, 0.619, 0.8571, 0.6405]}, {"w": "is", "b": [0.1429, 0.6381, 0.1561, 0.6595]}, {"w": "linear", "b": [0.162, 0.6381, 0.21, 0.6595]}, {"w": "with", "b": [0.2159, 0.6381, 0.2533, 0.6595]}, {"w": "regards", "b": [0.2592, 0.6381, 0.3211, 0.6595]}, {"w": "to", "b": [0.327, 0.6381, 0.344, 0.6595]}, {"w": "both", "b": [0.3499, 0.6381, 0.3886, 0.6595]}, {"w": "the", "b": [0.3945, 0.6381, 0.4209, 0.6595]}, {"w": "number", "b": [0.4268, 0.6381, 0.4931, 0.6595]}, {"w": "of", "b": [0.499, 0.6381, 0.5158, 0.6595]}, {"w": "instances", "b": [0.5217, 0.6381, 0.5986, 0.6595]}, {"w": "you", "b": [0.6045, 0.6381, 0.6358, 0.6595]}, {"w": "want", "b": [0.6417, 0.6381, 0.6825, 0.6595]}, {"w": "to", "b": [0.6884, 0.6381, 0.7054, 0.6595]}, {"w": "make", "b": [0.7113, 0.6381, 0.7567, 0.6595]}, {"w": "predictions", "b": [0.7626, 0.6381, 0.8571, 0.6595]}, {"w": "on", "b": [0.1429, 0.6571, 0.1649, 0.6786]}, {"w": "and", "b": [0.1702, 0.6571, 0.2018, 0.6786]}, {"w": "the", "b": [0.2071, 0.6571, 0.2334, 0.6786]}, {"w": "number", "b": [0.2388, 0.6571, 0.3051, 0.6786]}, {"w": "of", "b": [0.3104, 0.6571, 0.3272, 0.6786]}, {"w": "features.", "b": [0.3325, 0.6571, 0.4027, 0.6786]}, {"w": "In", "b": [0.408, 0.6571, 0.4265, 0.6786]}, {"w": "other", "b": [0.4319, 0.6571, 0.4766, 0.6786]}, {"w": "words,", "b": [0.4819, 0.6571, 0.5379, 0.6786]}, {"w": "making", "b": [0.5433, 0.6571, 0.6066, 0.6786]}, {"w": "predictions", "b": [0.6119, 0.6571, 0.7064, 0.6786]}, {"w": "on", "b": [0.7117, 0.6571, 0.7338, 0.6786]}, {"w": "twice", "b": [0.7391, 0.6571, 0.783, 0.6786]}, {"w": "as", "b": [0.7883, 0.6571, 0.8051, 0.6786]}, {"w": "many", "b": [0.8104, 0.6571, 0.8571, 0.6786]}, {"w": "instances", "b": [0.1429, 0.6762, 0.2197, 0.6976]}, {"w": "(or", "b": [0.2244, 0.6762, 0.25, 0.6976]}, {"w": "twice", "b": [0.2547, 0.6762, 0.2986, 0.6976]}, {"w": "as", "b": [0.3033, 0.6762, 0.3201, 0.6976]}, {"w": "many", "b": [0.3248, 0.6762, 0.3715, 0.6976]}, {"w": "features)", "b": [0.3763, 0.6762, 0.4489, 0.6976]}, {"w": "will", "b": [0.4536, 0.6762, 0.484, 0.6976]}, {"w": "just", "b": [0.4887, 0.6762, 0.5191, 0.6976]}, {"w": "take", "b": [0.5239, 0.6762, 0.5586, 0.6976]}, {"w": "roughly", "b": [0.5633, 0.6762, 0.6284, 0.6976]}, {"w": "twice", "b": [0.6331, 0.6762, 0.677, 0.6976]}, {"w": "as", "b": [0.6817, 0.6762, 0.6985, 0.6976]}, {"w": "much", "b": [0.7033, 0.6762, 0.7509, 0.6976]}, {"w": "time.", "b": [0.7557, 0.6762, 0.7983, 0.6976]}]}, {"id": "b_6", "type": "paragraph", "text": "Now we will look at very different ways to train a Linear Regression model, better suited for cases where there are a large number of features, or too many training instances to fit in memory.", "words": [{"w": "Now", "b": [0.1429, 0.7043, 0.1827, 0.7257]}, {"w": "we", "b": [0.1901, 0.7043, 0.2132, 0.7257]}, {"w": "will", "b": [0.2206, 0.7043, 0.251, 0.7257]}, {"w": "look", "b": [0.2583, 0.7043, 0.2952, 0.7257]}, {"w": "at", "b": [0.3025, 0.7043, 0.3176, 0.7257]}, {"w": "very", "b": [0.325, 0.7043, 0.3614, 0.7257]}, {"w": "different", "b": [0.3688, 0.7043, 0.4405, 0.7257]}, {"w": "ways", "b": [0.4478, 0.7043, 0.4881, 0.7257]}, {"w": "to", "b": [0.4954, 0.7043, 0.5124, 0.7257]}, {"w": "train", "b": [0.5198, 0.7043, 0.56, 0.7257]}, {"w": "a", "b": [0.5673, 0.7043, 0.5765, 0.7257]}, {"w": "Linear", "b": [0.5838, 0.7043, 0.6378, 0.7257]}, {"w": "Regression", "b": [0.6451, 0.7043, 0.7361, 0.7257]}, {"w": "model,", "b": [0.7435, 0.7043, 0.8011, 0.7257]}, {"w": "better", "b": [0.8084, 0.7043, 0.8572, 0.7257]}, {"w": "suited", "b": [0.1429, 0.7234, 0.1934, 0.7448]}, {"w": "for", "b": [0.2016, 0.7234, 0.2261, 0.7448]}, {"w": "cases", "b": [0.2343, 0.7234, 0.2764, 0.7448]}, {"w": "where", "b": [0.2846, 0.7234, 0.3355, 0.7448]}, {"w": "there", "b": [0.3437, 0.7234, 0.3866, 0.7448]}, {"w": "are", "b": [0.3948, 0.7234, 0.4205, 0.7448]}, {"w": "a", "b": [0.4287, 0.7234, 0.4379, 0.7448]}, {"w": "large", "b": [0.4461, 0.7234, 0.4868, 0.7448]}, {"w": "number", "b": [0.495, 0.7234, 0.5613, 0.7448]}, {"w": "of", "b": [0.5695, 0.7234, 0.5863, 0.7448]}, {"w": "features,", "b": [0.5946, 0.7234, 0.6647, 0.7448]}, {"w": "or", "b": [0.6729, 0.7234, 0.6913, 0.7448]}, {"w": "too", "b": [0.6995, 0.7234, 0.7271, 0.7448]}, {"w": "many", "b": [0.7353, 0.7234, 0.782, 0.7448]}, {"w": "training", "b": [0.7902, 0.7234, 0.8571, 0.7448]}, {"w": "instances", "b": [0.1429, 0.7424, 0.2197, 0.7638]}, {"w": "to", "b": [0.2244, 0.7424, 0.2414, 0.7638]}, {"w": "fit", "b": [0.2461, 0.7424, 0.2642, 0.7638]}, {"w": "in", "b": [0.269, 0.7424, 0.2859, 0.7638]}, {"w": "memory.", "b": [0.2907, 0.7424, 0.3654, 0.7638]}]}, {"id": "b_7", "type": "paragraph", "text": "Gradient Descent", "words": [{"w": "Gradient", "b": [0.1429, 0.7768, 0.2506, 0.8111]}, {"w": "Descent", "b": [0.2565, 0.7768, 0.3541, 0.8111]}]}, {"id": "b_8", "type": "paragraph", "text": "Gradient Descent is a very generic optimization algorithm capable of finding optimal solutions to a wide range of problems. The general idea of Gradient Descent is to tweak parameters iteratively in order to minimize a cost function.", "words": [{"w": "Gradient", "b": [0.1428, 0.8178, 0.2153, 0.8394]}, {"w": "Descent", "b": [0.2211, 0.8178, 0.2845, 0.8394]}, {"w": "is", "b": [0.2902, 0.818, 0.3035, 0.8394]}, {"w": "a", "b": [0.3092, 0.818, 0.3184, 0.8394]}, {"w": "very", "b": [0.3242, 0.818, 0.3606, 0.8394]}, {"w": "generic", "b": [0.3663, 0.818, 0.4273, 0.8394]}, {"w": "optimization", "b": [0.4331, 0.818, 0.5407, 0.8394]}, {"w": "algorithm", "b": [0.5464, 0.818, 0.6291, 0.8394]}, {"w": "capable", "b": [0.6349, 0.818, 0.6972, 0.8394]}, {"w": "of", "b": [0.703, 0.818, 0.7198, 0.8394]}, {"w": "finding", "b": [0.7255, 0.818, 0.7864, 0.8394]}, {"w": "optimal", "b": [0.7922, 0.818, 0.8571, 0.8394]}, {"w": "solutions", "b": [0.1429, 0.837, 0.2191, 0.8585]}, {"w": "to", "b": [0.2268, 0.837, 0.2438, 0.8585]}, {"w": "a", "b": [0.2515, 0.837, 0.2607, 0.8585]}, {"w": "wide", "b": [0.2684, 0.837, 0.3081, 0.8585]}, {"w": "range", "b": [0.3159, 0.837, 0.3627, 0.8585]}, {"w": "of", "b": [0.3705, 0.837, 0.3873, 0.8585]}, {"w": "problems.", "b": [0.395, 0.837, 0.4784, 0.8585]}, {"w": "The", "b": [0.4862, 0.837, 0.519, 0.8585]}, {"w": "general", "b": [0.5267, 0.837, 0.5877, 0.8585]}, {"w": "idea", "b": [0.5955, 0.837, 0.6301, 0.8585]}, {"w": "of", "b": [0.6378, 0.837, 0.6546, 0.8585]}, {"w": "Gradient", "b": [0.6623, 0.837, 0.7369, 0.8585]}, {"w": "Descent", "b": [0.7446, 0.837, 0.8115, 0.8585]}, {"w": "is", "b": [0.8192, 0.837, 0.8324, 0.8585]}, {"w": "to", "b": [0.8402, 0.837, 0.8572, 0.8585]}, {"w": "tweak", "b": [0.1429, 0.8561, 0.1918, 0.8775]}, {"w": "parameters", "b": [0.1965, 0.8561, 0.29, 0.8775]}, {"w": "iteratively", "b": [0.2947, 0.8561, 0.3773, 0.8775]}, {"w": "in", "b": [0.382, 0.8561, 0.399, 0.8775]}, {"w": "order", "b": [0.4037, 0.8561, 0.4496, 0.8775]}, {"w": "to", "b": [0.4544, 0.8561, 0.4713, 0.8775]}, {"w": "minimize", "b": [0.4761, 0.8561, 0.5559, 0.8775]}, {"w": "a", "b": [0.5607, 0.8561, 0.5698, 0.8775]}, {"w": "cost", "b": [0.5745, 0.8561, 0.608, 0.8775]}, {"w": "function.", "b": [0.6127, 0.8561, 0.6889, 0.8775]}]}, {"id": "b_9", "type": "paragraph", "text": "Gradient Descent | 119", "words": [{"w": "Gradient", "b": [0.6954, 0.9225, 0.7466, 0.9388]}, {"w": "Descent", "b": [0.7494, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "119", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 146, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Suppose you are lost in the mountains in a dense fog; you can only feel the slope of the ground below your feet. A good strategy to get to the bottom of the valley quickly is to go downhill in the direction of the steepest slope. This is exactly what Gradient Descent does: it measures the local gradient of the error function with regards to the parameter vector θ, and it goes in the direction of descending gradient. Once the gra‐ dient is zero, you have reached a minimum!", "words": [{"w": "Suppose", "b": [0.1429, 0.0791, 0.2128, 0.1005]}, {"w": "you", "b": [0.219, 0.0791, 0.2502, 0.1005]}, {"w": "are", "b": [0.2565, 0.0791, 0.2822, 0.1005]}, {"w": "lost", "b": [0.2885, 0.0791, 0.3184, 0.1005]}, {"w": "in", "b": [0.3246, 0.0791, 0.3416, 0.1005]}, {"w": "the", "b": [0.3478, 0.0791, 0.3742, 0.1005]}, {"w": "mountains", "b": [0.3804, 0.0791, 0.4703, 0.1005]}, {"w": "in", "b": [0.4765, 0.0791, 0.4935, 0.1005]}, {"w": "a", "b": [0.4997, 0.0791, 0.5089, 0.1005]}, {"w": "dense", "b": [0.5151, 0.0791, 0.5629, 0.1005]}, {"w": "fog;", "b": [0.5691, 0.0791, 0.6004, 0.1005]}, {"w": "you", "b": [0.6066, 0.0791, 0.6379, 0.1005]}, {"w": "can", "b": [0.6441, 0.0791, 0.6735, 0.1005]}, {"w": "only", "b": [0.6797, 0.0791, 0.7166, 0.1005]}, {"w": "feel", "b": [0.7228, 0.0791, 0.752, 0.1005]}, {"w": "the", "b": [0.7582, 0.0791, 0.7846, 0.1005]}, {"w": "slope", "b": [0.7908, 0.0791, 0.8341, 0.1005]}, {"w": "of", "b": [0.8404, 0.0791, 0.8571, 0.1005]}, {"w": "the", "b": [0.1429, 0.0981, 0.1692, 0.1195]}, {"w": "ground", "b": [0.1743, 0.0981, 0.2359, 0.1195]}, {"w": "below", "b": [0.241, 0.0981, 0.2906, 0.1195]}, {"w": "your", "b": [0.2957, 0.0981, 0.3347, 0.1195]}, {"w": "feet.", "b": [0.3398, 0.0981, 0.3748, 0.1195]}, {"w": "A", "b": [0.3799, 0.0981, 0.3943, 0.1195]}, {"w": "good", "b": [0.3994, 0.0981, 0.4414, 0.1195]}, {"w": "strategy", "b": [0.4466, 0.0981, 0.5121, 0.1195]}, {"w": "to", "b": [0.5172, 0.0981, 0.5342, 0.1195]}, {"w": "get", "b": [0.5393, 0.0981, 0.5642, 0.1195]}, {"w": "to", "b": [0.5694, 0.0981, 0.5863, 0.1195]}, {"w": "the", "b": [0.5914, 0.0981, 0.6178, 0.1195]}, {"w": "bottom", "b": [0.6229, 0.0981, 0.6845, 0.1195]}, {"w": "of", "b": [0.6896, 0.0981, 0.7064, 0.1195]}, {"w": "the", "b": [0.7115, 0.0981, 0.7379, 0.1195]}, {"w": "valley", "b": [0.743, 0.0981, 0.7907, 0.1195]}, {"w": "quickly", "b": [0.7959, 0.0981, 0.8571, 0.1195]}, {"w": "is", "b": [0.1429, 0.1172, 0.1561, 0.1386]}, {"w": "to", "b": [0.1621, 0.1172, 0.1791, 0.1386]}, {"w": "go", "b": [0.1851, 0.1172, 0.2054, 0.1386]}, {"w": "downhill", "b": [0.2114, 0.1172, 0.286, 0.1386]}, {"w": "in", "b": [0.292, 0.1172, 0.3089, 0.1386]}, {"w": "the", "b": [0.3149, 0.1172, 0.3413, 0.1386]}, {"w": "direction", "b": [0.3473, 0.1172, 0.4232, 0.1386]}, {"w": "of", "b": [0.4292, 0.1172, 0.446, 0.1386]}, {"w": "the", "b": [0.452, 0.1172, 0.4783, 0.1386]}, {"w": "steepest", "b": [0.4843, 0.1172, 0.5498, 0.1386]}, {"w": "slope.", "b": [0.5558, 0.1172, 0.6038, 0.1386]}, {"w": "This", "b": [0.6098, 0.1172, 0.6471, 0.1386]}, {"w": "is", "b": [0.653, 0.1172, 0.6663, 0.1386]}, {"w": "exactly", "b": [0.6723, 0.1172, 0.7301, 0.1386]}, {"w": "what", "b": [0.7361, 0.1172, 0.7766, 0.1386]}, {"w": "Gradient", "b": [0.7826, 0.1172, 0.8572, 0.1386]}, {"w": "Descent", "b": [0.1429, 0.1362, 0.2097, 0.1576]}, {"w": "does:", "b": [0.215, 0.1362, 0.2579, 0.1576]}, {"w": "it", "b": [0.2632, 0.1362, 0.2752, 0.1576]}, {"w": "measures", "b": [0.2805, 0.1362, 0.3585, 0.1576]}, {"w": "the", "b": [0.3639, 0.1362, 0.3902, 0.1576]}, {"w": "local", "b": [0.3955, 0.1362, 0.4347, 0.1576]}, {"w": "gradient", "b": [0.44, 0.1362, 0.5094, 0.1576]}, {"w": "of", "b": [0.5148, 0.1362, 0.5315, 0.1576]}, {"w": "the", "b": [0.5369, 0.1362, 0.5632, 0.1576]}, {"w": "error", "b": [0.5686, 0.1362, 0.6112, 0.1576]}, {"w": "function", "b": [0.6166, 0.1362, 0.688, 0.1576]}, {"w": "with", "b": [0.6933, 0.1362, 0.7306, 0.1576]}, {"w": "regards", "b": [0.736, 0.1362, 0.7978, 0.1576]}, {"w": "to", "b": [0.8032, 0.1362, 0.8201, 0.1576]}, {"w": "the", "b": [0.8255, 0.1362, 0.8518, 0.1576]}, {"w": "parameter", "b": [0.1429, 0.1553, 0.2286, 0.1767]}, {"w": "vector", "b": [0.2337, 0.1553, 0.2858, 0.1767]}, {"w": "θ,", "b": [0.2908, 0.1547, 0.3062, 0.1767]}, {"w": "and", "b": [0.3113, 0.1553, 0.3428, 0.1767]}, {"w": "it", "b": [0.3479, 0.1553, 0.3599, 0.1767]}, {"w": "goes", "b": [0.365, 0.1553, 0.4018, 0.1767]}, {"w": "in", "b": [0.4069, 0.1553, 0.4239, 0.1767]}, {"w": "the", "b": [0.429, 0.1553, 0.4553, 0.1767]}, {"w": "direction", "b": [0.4604, 0.1553, 0.5363, 0.1767]}, {"w": "of", "b": [0.5414, 0.1553, 0.5582, 0.1767]}, {"w": "descending", "b": [0.5633, 0.1553, 0.6576, 0.1767]}, {"w": "gradient.", "b": [0.6627, 0.1553, 0.7369, 0.1767]}, {"w": "Once", "b": [0.742, 0.1553, 0.7866, 0.1767]}, {"w": "the", "b": [0.7917, 0.1553, 0.818, 0.1767]}, {"w": "gra‐", "b": [0.8231, 0.1553, 0.8571, 0.1767]}, {"w": "dient", "b": [0.1428, 0.1743, 0.1856, 0.1957]}, {"w": "is", "b": [0.1904, 0.1743, 0.2036, 0.1957]}, {"w": "zero,", "b": [0.2083, 0.1743, 0.2484, 0.1957]}, {"w": "you", "b": [0.2532, 0.1743, 0.2844, 0.1957]}, {"w": "have", "b": [0.2891, 0.1743, 0.3275, 0.1957]}, {"w": "reached", "b": [0.3323, 0.1743, 0.3978, 0.1957]}, {"w": "a", "b": [0.4025, 0.1743, 0.4117, 0.1957]}, {"w": "minimum!", "b": [0.4164, 0.1743, 0.5066, 0.1957]}]}, {"id": "b_1", "type": "paragraph", "text": "Concretely, you start by filling θ with random values (this is called random initializa‐ tion), and then you improve it gradually, taking one baby step at a time, each step attempting to decrease the cost function (e.g., the MSE), until the algorithm converges to a minimum (see Figure 4-3).", "words": [{"w": "Concretely,", "b": [0.1428, 0.2024, 0.2374, 0.2238]}, {"w": "you", "b": [0.2429, 0.2024, 0.2742, 0.2238]}, {"w": "start", "b": [0.2797, 0.2024, 0.3169, 0.2238]}, {"w": "by", "b": [0.3224, 0.2024, 0.3425, 0.2238]}, {"w": "filling", "b": [0.3481, 0.2024, 0.3971, 0.2238]}, {"w": "θ", "b": [0.4026, 0.2019, 0.4132, 0.2238]}, {"w": "with", "b": [0.4187, 0.2024, 0.456, 0.2238]}, {"w": "random", "b": [0.4615, 0.2024, 0.5285, 0.2238]}, {"w": "values", "b": [0.534, 0.2024, 0.5856, 0.2238]}, {"w": "(this", "b": [0.5912, 0.2024, 0.6291, 0.2238]}, {"w": "is", "b": [0.6346, 0.2024, 0.6478, 0.2238]}, {"w": "called", "b": [0.6533, 0.2024, 0.7017, 0.2238]}, {"w": "random", "b": [0.7072, 0.2022, 0.7717, 0.2238]}, {"w": "initializa‐", "b": [0.7773, 0.2022, 0.8571, 0.2238]}, {"w": "tion),", "b": [0.1429, 0.2213, 0.1873, 0.2429]}, {"w": "and", "b": [0.1947, 0.2215, 0.2262, 0.2429]}, {"w": "then", "b": [0.2336, 0.2215, 0.2713, 0.2429]}, {"w": "you", "b": [0.2787, 0.2215, 0.3099, 0.2429]}, {"w": "improve", "b": [0.3173, 0.2215, 0.3873, 0.2429]}, {"w": "it", "b": [0.3947, 0.2215, 0.4066, 0.2429]}, {"w": "gradually,", "b": [0.414, 0.2215, 0.4952, 0.2429]}, {"w": "taking", "b": [0.5025, 0.2215, 0.5551, 0.2429]}, {"w": "one", "b": [0.5625, 0.2215, 0.5933, 0.2429]}, {"w": "baby", "b": [0.6007, 0.2215, 0.6406, 0.2429]}, {"w": "step", "b": [0.648, 0.2215, 0.6817, 0.2429]}, {"w": "at", "b": [0.6891, 0.2215, 0.7042, 0.2429]}, {"w": "a", "b": [0.7116, 0.2215, 0.7207, 0.2429]}, {"w": "time,", "b": [0.7281, 0.2215, 0.7707, 0.2429]}, {"w": "each", "b": [0.7781, 0.2215, 0.816, 0.2429]}, {"w": "step", "b": [0.8234, 0.2215, 0.8571, 0.2429]}, {"w": "attempting", "b": [0.1429, 0.2405, 0.2338, 0.2619]}, {"w": "to", "b": [0.2389, 0.2405, 0.2559, 0.2619]}, {"w": "decrease", "b": [0.2609, 0.2405, 0.3318, 0.2619]}, {"w": "the", "b": [0.3368, 0.2405, 0.3632, 0.2619]}, {"w": "cost", "b": [0.3682, 0.2405, 0.4016, 0.2619]}, {"w": "function", "b": [0.4067, 0.2405, 0.4781, 0.2619]}, {"w": "(e.g.,", "b": [0.4831, 0.2405, 0.5232, 0.2619]}, {"w": "the", "b": [0.5282, 0.2405, 0.5545, 0.2619]}, {"w": "MSE),", "b": [0.5596, 0.2405, 0.6118, 0.2619]}, {"w": "until", "b": [0.6168, 0.2405, 0.6561, 0.2619]}, {"w": "the", "b": [0.6612, 0.2405, 0.6875, 0.2619]}, {"w": "algorithm", "b": [0.6925, 0.2405, 0.7752, 0.2619]}, {"w": "converges", "b": [0.7802, 0.2403, 0.8571, 0.2619]}, {"w": "to", "b": [0.1429, 0.2596, 0.1598, 0.281]}, {"w": "a", "b": [0.1646, 0.2596, 0.1737, 0.281]}, {"w": "minimum", "b": [0.1784, 0.2596, 0.2629, 0.281]}, {"w": "(see", "b": [0.2676, 0.2596, 0.3001, 0.281]}, {"w": "Figure", "b": [0.3049, 0.2596, 0.3589, 0.281]}, {"w": "4-3).", "b": [0.3636, 0.2596, 0.403, 0.281]}]}, {"id": "b_2", "type": "equation", "text": "Figure 4-3. Gradient Descent", "words": [{"w": "Figure", "b": [0.1429, 0.5638, 0.1943, 0.5854]}, {"w": "4-3.", "b": [0.1991, 0.5638, 0.2308, 0.5854]}, {"w": "Gradient", "b": [0.2356, 0.5638, 0.308, 0.5854]}, {"w": "Descent", "b": [0.3128, 0.5638, 0.3761, 0.5854]}]}, {"id": "b_3", "type": "paragraph", "text": "An important parameter in Gradient Descent is the size of the steps, determined by the learning rate hyperparameter. If the learning rate is too small, then the algorithm will have to go through many iterations to converge, which will take a long time (see Figure 4-4).", "words": [{"w": "An", "b": [0.1429, 0.6012, 0.1686, 0.6226]}, {"w": "important", "b": [0.1746, 0.6012, 0.259, 0.6226]}, {"w": "parameter", "b": [0.2649, 0.6012, 0.3507, 0.6226]}, {"w": "in", "b": [0.3567, 0.6012, 0.3737, 0.6226]}, {"w": "Gradient", "b": [0.3796, 0.6012, 0.4542, 0.6226]}, {"w": "Descent", "b": [0.4601, 0.6012, 0.527, 0.6226]}, {"w": "is", "b": [0.5329, 0.6012, 0.5462, 0.6226]}, {"w": "the", "b": [0.5521, 0.6012, 0.5785, 0.6226]}, {"w": "size", "b": [0.5844, 0.6012, 0.6153, 0.6226]}, {"w": "of", "b": [0.6212, 0.6012, 0.638, 0.6226]}, {"w": "the", "b": [0.644, 0.6012, 0.6703, 0.6226]}, {"w": "steps,", "b": [0.6763, 0.6012, 0.7224, 0.6226]}, {"w": "determined", "b": [0.7284, 0.6012, 0.8251, 0.6226]}, {"w": "by", "b": [0.831, 0.6012, 0.8512, 0.6226]}, {"w": "the", "b": [0.1429, 0.6202, 0.1692, 0.6416]}, {"w": "learning", "b": [0.175, 0.62, 0.2417, 0.6416]}, {"w": "rate", "b": [0.2476, 0.62, 0.2791, 0.6416]}, {"w": "hyperparameter.", "b": [0.2849, 0.6202, 0.4218, 0.6416]}, {"w": "If", "b": [0.4277, 0.6202, 0.4409, 0.6416]}, {"w": "the", "b": [0.4468, 0.6202, 0.4731, 0.6416]}, {"w": "learning", "b": [0.4789, 0.6202, 0.548, 0.6416]}, {"w": "rate", "b": [0.5539, 0.6202, 0.5855, 0.6416]}, {"w": "is", "b": [0.5914, 0.6202, 0.6046, 0.6416]}, {"w": "too", "b": [0.6104, 0.6202, 0.638, 0.6416]}, {"w": "small,", "b": [0.6438, 0.6202, 0.693, 0.6416]}, {"w": "then", "b": [0.6988, 0.6202, 0.7365, 0.6416]}, {"w": "the", "b": [0.7424, 0.6202, 0.7687, 0.6416]}, {"w": "algorithm", "b": [0.7745, 0.6202, 0.8572, 0.6416]}, {"w": "will", "b": [0.1429, 0.6393, 0.1733, 0.6607]}, {"w": "have", "b": [0.1789, 0.6393, 0.2173, 0.6607]}, {"w": "to", "b": [0.223, 0.6393, 0.24, 0.6607]}, {"w": "go", "b": [0.2457, 0.6393, 0.2661, 0.6607]}, {"w": "through", "b": [0.2717, 0.6393, 0.3395, 0.6607]}, {"w": "many", "b": [0.3452, 0.6393, 0.3919, 0.6607]}, {"w": "iterations", "b": [0.3976, 0.6393, 0.4765, 0.6607]}, {"w": "to", "b": [0.4821, 0.6393, 0.4991, 0.6607]}, {"w": "converge,", "b": [0.5048, 0.6393, 0.5847, 0.6607]}, {"w": "which", "b": [0.5904, 0.6393, 0.6413, 0.6607]}, {"w": "will", "b": [0.647, 0.6393, 0.6774, 0.6607]}, {"w": "take", "b": [0.6831, 0.6393, 0.7178, 0.6607]}, {"w": "a", "b": [0.7235, 0.6393, 0.7326, 0.6607]}, {"w": "long", "b": [0.7383, 0.6393, 0.7754, 0.6607]}, {"w": "time", "b": [0.781, 0.6393, 0.8189, 0.6607]}, {"w": "(see", "b": [0.8246, 0.6393, 0.8571, 0.6607]}, {"w": "Figure", "b": [0.1429, 0.6583, 0.1969, 0.6797]}, {"w": "4-4).", "b": [0.2016, 0.6583, 0.241, 0.6797]}]}, {"id": "b_4", "type": "paragraph", "text": "120 | Chapter 4: Training Models", "words": [{"w": "120", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 147, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 4-4. Learning rate too small", "words": [{"w": "Figure", "b": [0.1429, 0.319, 0.1943, 0.3406]}, {"w": "4-4.", "b": [0.1991, 0.319, 0.2308, 0.3406]}, {"w": "Learning", "b": [0.2356, 0.319, 0.3083, 0.3406]}, {"w": "rate", "b": [0.3131, 0.319, 0.3446, 0.3406]}, {"w": "too", "b": [0.3494, 0.319, 0.375, 0.3406]}, {"w": "small", "b": [0.3798, 0.319, 0.4231, 0.3406]}]}, {"id": "b_1", "type": "paragraph", "text": "On the other hand, if the learning rate is too high, you might jump across the valley and end up on the other side, possibly even higher up than you were before. This might make the algorithm diverge, with larger and larger values, failing to find a good solution (see Figure 4-5).", "words": [{"w": "On", "b": [0.1429, 0.3564, 0.1698, 0.3778]}, {"w": "the", "b": [0.1758, 0.3564, 0.2022, 0.3778]}, {"w": "other", "b": [0.2082, 0.3564, 0.2529, 0.3778]}, {"w": "hand,", "b": [0.2589, 0.3564, 0.3063, 0.3778]}, {"w": "if", "b": [0.3124, 0.3564, 0.3241, 0.3778]}, {"w": "the", "b": [0.3301, 0.3564, 0.3565, 0.3778]}, {"w": "learning", "b": [0.3625, 0.3564, 0.4316, 0.3778]}, {"w": "rate", "b": [0.4377, 0.3564, 0.4693, 0.3778]}, {"w": "is", "b": [0.4754, 0.3564, 0.4886, 0.3778]}, {"w": "too", "b": [0.4946, 0.3564, 0.5222, 0.3778]}, {"w": "high,", "b": [0.5283, 0.3564, 0.5706, 0.3778]}, {"w": "you", "b": [0.5766, 0.3564, 0.6079, 0.3778]}, {"w": "might", "b": [0.6139, 0.3564, 0.6634, 0.3778]}, {"w": "jump", "b": [0.6694, 0.3564, 0.7134, 0.3778]}, {"w": "across", "b": [0.7194, 0.3564, 0.771, 0.3778]}, {"w": "the", "b": [0.777, 0.3564, 0.8034, 0.3778]}, {"w": "valley", "b": [0.8094, 0.3564, 0.8571, 0.3778]}, {"w": "and", "b": [0.1429, 0.3754, 0.1744, 0.3968]}, {"w": "end", "b": [0.1819, 0.3754, 0.2131, 0.3968]}, {"w": "up", "b": [0.2206, 0.3754, 0.2426, 0.3968]}, {"w": "on", "b": [0.2501, 0.3754, 0.2721, 0.3968]}, {"w": "the", "b": [0.2796, 0.3754, 0.3059, 0.3968]}, {"w": "other", "b": [0.3134, 0.3754, 0.3581, 0.3968]}, {"w": "side,", "b": [0.3655, 0.3754, 0.4034, 0.3968]}, {"w": "possibly", "b": [0.4108, 0.3754, 0.4787, 0.3968]}, {"w": "even", "b": [0.4861, 0.3754, 0.5249, 0.3968]}, {"w": "higher", "b": [0.5324, 0.3754, 0.5865, 0.3968]}, {"w": "up", "b": [0.594, 0.3754, 0.616, 0.3968]}, {"w": "than", "b": [0.6235, 0.3754, 0.6615, 0.3968]}, {"w": "you", "b": [0.669, 0.3754, 0.7002, 0.3968]}, {"w": "were", "b": [0.7077, 0.3754, 0.7474, 0.3968]}, {"w": "before.", "b": [0.7549, 0.3754, 0.8125, 0.3968]}, {"w": "This", "b": [0.8199, 0.3754, 0.8571, 0.3968]}, {"w": "might", "b": [0.1429, 0.3945, 0.1923, 0.4159]}, {"w": "make", "b": [0.1971, 0.3945, 0.2425, 0.4159]}, {"w": "the", "b": [0.2472, 0.3945, 0.2735, 0.4159]}, {"w": "algorithm", "b": [0.2783, 0.3945, 0.3609, 0.4159]}, {"w": "diverge,", "b": [0.3656, 0.3945, 0.4318, 0.4159]}, {"w": "with", "b": [0.4365, 0.3945, 0.4739, 0.4159]}, {"w": "larger", "b": [0.4786, 0.3945, 0.5271, 0.4159]}, {"w": "and", "b": [0.5318, 0.3945, 0.5633, 0.4159]}, {"w": "larger", "b": [0.5681, 0.3945, 0.6166, 0.4159]}, {"w": "values,", "b": [0.6213, 0.3945, 0.6777, 0.4159]}, {"w": "failing", "b": [0.6824, 0.3945, 0.7353, 0.4159]}, {"w": "to", "b": [0.74, 0.3945, 0.757, 0.4159]}, {"w": "find", "b": [0.7617, 0.3945, 0.7959, 0.4159]}, {"w": "a", "b": [0.8006, 0.3945, 0.8097, 0.4159]}, {"w": "good", "b": [0.8145, 0.3945, 0.8565, 0.4159]}, {"w": "solution", "b": [0.1429, 0.4135, 0.2114, 0.4349]}, {"w": "(see", "b": [0.2162, 0.4135, 0.2487, 0.4349]}, {"w": "Figure", "b": [0.2534, 0.4135, 0.3074, 0.4349]}, {"w": "4-5).", "b": [0.3122, 0.4135, 0.3516, 0.4349]}]}, {"id": "b_2", "type": "equation", "text": "Figure 4-5. Learning rate too large", "words": [{"w": "Figure", "b": [0.1429, 0.6835, 0.1943, 0.7051]}, {"w": "4-5.", "b": [0.1991, 0.6835, 0.2308, 0.7051]}, {"w": "Learning", "b": [0.2356, 0.6835, 0.3083, 0.7051]}, {"w": "rate", "b": [0.3131, 0.6835, 0.3446, 0.7051]}, {"w": "too", "b": [0.3494, 0.6835, 0.3751, 0.7051]}, {"w": "large", "b": [0.3798, 0.6835, 0.4194, 0.7051]}]}, {"id": "b_3", "type": "paragraph", "text": "Finally, not all cost functions look like nice regular bowls. There may be holes, ridges, plateaus, and all sorts of irregular terrains, making convergence to the minimum very difficult. Figure 4-6 shows the two main challenges with Gradient Descent: if the ran‐ dom initialization starts the algorithm on the left, then it will converge to a local mini‐ mum, which is not as good as the global minimum. If it starts on the right, then it will take a very long time to cross the plateau, and if you stop too early you will never reach the global minimum.", "words": [{"w": "Finally,", "b": [0.1429, 0.7209, 0.2033, 0.7423]}, {"w": "not", "b": [0.2084, 0.7209, 0.2368, 0.7423]}, {"w": "all", "b": [0.2419, 0.7209, 0.2616, 0.7423]}, {"w": "cost", "b": [0.2667, 0.7209, 0.3001, 0.7423]}, {"w": "functions", "b": [0.3052, 0.7209, 0.3842, 0.7423]}, {"w": "look", "b": [0.3893, 0.7209, 0.4262, 0.7423]}, {"w": "like", "b": [0.4313, 0.7209, 0.4613, 0.7423]}, {"w": "nice", "b": [0.4664, 0.7209, 0.501, 0.7423]}, {"w": "regular", "b": [0.5061, 0.7209, 0.5657, 0.7423]}, {"w": "bowls.", "b": [0.5707, 0.7209, 0.6239, 0.7423]}, {"w": "There", "b": [0.629, 0.7209, 0.6784, 0.7423]}, {"w": "may", "b": [0.6835, 0.7209, 0.7189, 0.7423]}, {"w": "be", "b": [0.724, 0.7209, 0.7434, 0.7423]}, {"w": "holes,", "b": [0.7485, 0.7209, 0.7968, 0.7423]}, {"w": "ridges,", "b": [0.8018, 0.7209, 0.8572, 0.7423]}, {"w": "plateaus,", "b": [0.1429, 0.74, 0.2152, 0.7614]}, {"w": "and", "b": [0.2202, 0.74, 0.2518, 0.7614]}, {"w": "all", "b": [0.2568, 0.74, 0.2765, 0.7614]}, {"w": "sorts", "b": [0.2815, 0.74, 0.3215, 0.7614]}, {"w": "of", "b": [0.3265, 0.74, 0.3433, 0.7614]}, {"w": "irregular", "b": [0.3483, 0.74, 0.4212, 0.7614]}, {"w": "terrains,", "b": [0.4262, 0.74, 0.4954, 0.7614]}, {"w": "making", "b": [0.5004, 0.74, 0.5637, 0.7614]}, {"w": "convergence", "b": [0.5687, 0.74, 0.6729, 0.7614]}, {"w": "to", "b": [0.678, 0.74, 0.6949, 0.7614]}, {"w": "the", "b": [0.7, 0.74, 0.7263, 0.7614]}, {"w": "minimum", "b": [0.7313, 0.74, 0.8157, 0.7614]}, {"w": "very", "b": [0.8208, 0.74, 0.8571, 0.7614]}, {"w": "difficult.", "b": [0.1429, 0.759, 0.2136, 0.7804]}, {"w": "Figure", "b": [0.2187, 0.759, 0.2727, 0.7804]}, {"w": "4-6", "b": [0.2775, 0.759, 0.3049, 0.7804]}, {"w": "shows", "b": [0.3104, 0.759, 0.3617, 0.7804]}, {"w": "the", "b": [0.3669, 0.759, 0.3932, 0.7804]}, {"w": "two", "b": [0.3983, 0.759, 0.4296, 0.7804]}, {"w": "main", "b": [0.4347, 0.759, 0.4779, 0.7804]}, {"w": "challenges", "b": [0.483, 0.759, 0.5691, 0.7804]}, {"w": "with", "b": [0.5743, 0.759, 0.6116, 0.7804]}, {"w": "Gradient", "b": [0.6167, 0.759, 0.6913, 0.7804]}, {"w": "Descent:", "b": [0.6964, 0.759, 0.768, 0.7804]}, {"w": "if", "b": [0.7731, 0.759, 0.7849, 0.7804]}, {"w": "the", "b": [0.79, 0.759, 0.8163, 0.7804]}, {"w": "ran‐", "b": [0.8215, 0.759, 0.8572, 0.7804]}, {"w": "dom", "b": [0.1429, 0.7781, 0.1815, 0.7995]}, {"w": "initialization", "b": [0.1863, 0.7781, 0.2923, 0.7995]}, {"w": "starts", "b": [0.2971, 0.7781, 0.342, 0.7995]}, {"w": "the", "b": [0.3468, 0.7781, 0.3731, 0.7995]}, {"w": "algorithm", "b": [0.3779, 0.7781, 0.4606, 0.7995]}, {"w": "on", "b": [0.4654, 0.7781, 0.4874, 0.7995]}, {"w": "the", "b": [0.4922, 0.7781, 0.5185, 0.7995]}, {"w": "left,", "b": [0.5233, 0.7781, 0.5547, 0.7995]}, {"w": "then", "b": [0.5595, 0.7781, 0.5972, 0.7995]}, {"w": "it", "b": [0.602, 0.7781, 0.614, 0.7995]}, {"w": "will", "b": [0.6188, 0.7781, 0.6492, 0.7995]}, {"w": "converge", "b": [0.654, 0.7781, 0.7292, 0.7995]}, {"w": "to", "b": [0.734, 0.7781, 0.7509, 0.7995]}, {"w": "a", "b": [0.7557, 0.7781, 0.7649, 0.7995]}, {"w": "local", "b": [0.7697, 0.7778, 0.8075, 0.7995]}, {"w": "mini‐", "b": [0.8122, 0.7778, 0.8571, 0.7995]}, {"w": "mum,", "b": [0.1428, 0.7969, 0.1909, 0.8185]}, {"w": "which", "b": [0.1961, 0.7971, 0.247, 0.8185]}, {"w": "is", "b": [0.2522, 0.7971, 0.2655, 0.8185]}, {"w": "not", "b": [0.2707, 0.7971, 0.2991, 0.8185]}, {"w": "as", "b": [0.3043, 0.7971, 0.3211, 0.8185]}, {"w": "good", "b": [0.3263, 0.7971, 0.3683, 0.8185]}, {"w": "as", "b": [0.3736, 0.7971, 0.3904, 0.8185]}, {"w": "the", "b": [0.3956, 0.7971, 0.4219, 0.8185]}, {"w": "global", "b": [0.4272, 0.7969, 0.4757, 0.8185]}, {"w": "minimum.", "b": [0.4805, 0.7969, 0.5667, 0.8185]}, {"w": "If", "b": [0.5719, 0.7971, 0.5852, 0.8185]}, {"w": "it", "b": [0.5904, 0.7971, 0.6023, 0.8185]}, {"w": "starts", "b": [0.6076, 0.7971, 0.6524, 0.8185]}, {"w": "on", "b": [0.6577, 0.7971, 0.6797, 0.8185]}, {"w": "the", "b": [0.6849, 0.7971, 0.7113, 0.8185]}, {"w": "right,", "b": [0.7165, 0.7971, 0.7614, 0.8185]}, {"w": "then", "b": [0.7666, 0.7971, 0.8044, 0.8185]}, {"w": "it", "b": [0.8096, 0.7971, 0.8215, 0.8185]}, {"w": "will", "b": [0.8268, 0.7971, 0.8572, 0.8185]}, {"w": "take", "b": [0.1429, 0.8161, 0.1775, 0.8376]}, {"w": "a", "b": [0.1847, 0.8161, 0.1939, 0.8376]}, {"w": "very", "b": [0.2011, 0.8161, 0.2375, 0.8376]}, {"w": "long", "b": [0.2447, 0.8161, 0.2817, 0.8376]}, {"w": "time", "b": [0.2889, 0.8161, 0.3268, 0.8376]}, {"w": "to", "b": [0.334, 0.8161, 0.3509, 0.8376]}, {"w": "cross", "b": [0.3581, 0.8161, 0.4006, 0.8376]}, {"w": "the", "b": [0.4078, 0.8161, 0.4341, 0.8376]}, {"w": "plateau,", "b": [0.4413, 0.8161, 0.506, 0.8376]}, {"w": "and", "b": [0.5132, 0.8161, 0.5448, 0.8376]}, {"w": "if", "b": [0.5519, 0.8161, 0.5637, 0.8376]}, {"w": "you", "b": [0.5709, 0.8161, 0.6021, 0.8376]}, {"w": "stop", "b": [0.6093, 0.8161, 0.6449, 0.8376]}, {"w": "too", "b": [0.6521, 0.8161, 0.6797, 0.8376]}, {"w": "early", "b": [0.6869, 0.8161, 0.7274, 0.8376]}, {"w": "you", "b": [0.7346, 0.8161, 0.7659, 0.8376]}, {"w": "will", "b": [0.7731, 0.8161, 0.8035, 0.8376]}, {"w": "never", "b": [0.8107, 0.8161, 0.8571, 0.8376]}, {"w": "reach", "b": [0.1429, 0.8352, 0.1885, 0.8566]}, {"w": "the", "b": [0.1932, 0.8352, 0.2196, 0.8566]}, {"w": "global", "b": [0.2243, 0.8352, 0.275, 0.8566]}, {"w": "minimum.", "b": [0.2797, 0.8352, 0.3689, 0.8566]}]}, {"id": "b_4", "type": "paragraph", "text": "Gradient Descent | 121", "words": [{"w": "Gradient", "b": [0.6954, 0.9225, 0.7466, 0.9388]}, {"w": "Descent", "b": [0.7494, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "121", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 148, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "4 Technically speaking, its derivative is Lipschitz continuous.", "words": [{"w": "4", "b": [0.1451, 0.8416, 0.1518, 0.8559]}, {"w": "Technically", "b": [0.1587, 0.8401, 0.2308, 0.8565]}, {"w": "speaking,", "b": [0.2344, 0.8401, 0.2942, 0.8565]}, {"w": "its", "b": [0.2978, 0.8401, 0.3127, 0.8565]}, {"w": "derivative", "b": [0.3163, 0.8401, 0.3788, 0.8565]}, {"w": "is", "b": [0.3824, 0.8401, 0.3924, 0.8565]}, {"w": "Lipschitz", "b": [0.396, 0.84, 0.4507, 0.8565]}, {"w": "continuous.", "b": [0.4543, 0.84, 0.5259, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "5 Since feature 1 is smaller, it takes a larger change in θ1 to affect the cost function, which is why the bowl is elongated along the θ1 axis.", "words": [{"w": "5", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Since", "b": [0.1587, 0.8598, 0.1927, 0.8761]}, {"w": "feature", "b": [0.1963, 0.8598, 0.2403, 0.8761]}, {"w": "1", "b": [0.2439, 0.8598, 0.2515, 0.8761]}, {"w": "is", "b": [0.2551, 0.8598, 0.2652, 0.8761]}, {"w": "smaller,", "b": [0.2688, 0.8598, 0.3179, 0.8761]}, {"w": "it", "b": [0.3215, 0.8598, 0.3306, 0.8761]}, {"w": "takes", "b": [0.3342, 0.8598, 0.3664, 0.8761]}, {"w": "a", "b": [0.37, 0.8598, 0.377, 0.8761]}, {"w": "larger", "b": [0.3806, 0.8598, 0.4175, 0.8761]}, {"w": "change", "b": [0.4211, 0.8598, 0.4661, 0.8761]}, {"w": "in", "b": [0.4697, 0.8598, 0.4827, 0.8761]}, {"w": "θ1", "b": [0.4863, 0.8596, 0.4999, 0.8776]}, {"w": "to", "b": [0.5035, 0.8598, 0.5164, 0.8761]}, {"w": "affect", "b": [0.52, 0.8598, 0.5547, 0.8761]}, {"w": "the", "b": [0.5583, 0.8598, 0.5783, 0.8761]}, {"w": "cost", "b": [0.5819, 0.8598, 0.6074, 0.8761]}, {"w": "function,", "b": [0.611, 0.8598, 0.669, 0.8761]}, {"w": "which", "b": [0.6726, 0.8598, 0.7114, 0.8761]}, {"w": "is", "b": [0.715, 0.8598, 0.7251, 0.8761]}, {"w": "why", "b": [0.7287, 0.8598, 0.755, 0.8761]}, {"w": "the", "b": [0.7586, 0.8598, 0.7787, 0.8761]}, {"w": "bowl", "b": [0.7823, 0.8598, 0.8133, 0.8761]}, {"w": "is", "b": [0.8169, 0.8598, 0.827, 0.8761]}, {"w": "elongated", "b": [0.1587, 0.8749, 0.2203, 0.8912]}, {"w": "along", "b": [0.2239, 0.8749, 0.2591, 0.8912]}, {"w": "the", "b": [0.2627, 0.8749, 0.2828, 0.8912]}, {"w": "θ1", "b": [0.2864, 0.8748, 0.3, 0.8927]}, {"w": "axis.", "b": [0.3036, 0.8749, 0.3317, 0.8912]}]}, {"id": "b_2", "type": "equation", "text": "Figure 4-6. Gradient Descent pitfalls", "words": [{"w": "Figure", "b": [0.1429, 0.3349, 0.1943, 0.3566]}, {"w": "4-6.", "b": [0.1991, 0.3349, 0.2308, 0.3566]}, {"w": "Gradient", "b": [0.2356, 0.3349, 0.308, 0.3566]}, {"w": "Descent", "b": [0.3128, 0.3349, 0.3761, 0.3566]}, {"w": "pitfalls", "b": [0.3809, 0.3349, 0.4353, 0.3566]}]}, {"id": "b_3", "type": "paragraph", "text": "Fortunately, the MSE cost function for a Linear Regression model happens to be a convex function, which means that if you pick any two points on the curve, the line segment joining them never crosses the curve. This implies that there are no local minima, just one global minimum. It is also a continuous function with a slope that never changes abruptly.4 These two facts have a great consequence: Gradient Descent is guaranteed to approach arbitrarily close the global minimum (if you wait long enough and if the learning rate is not too high).", "words": [{"w": "Fortunately,", "b": [0.1429, 0.3723, 0.2427, 0.3937]}, {"w": "the", "b": [0.2501, 0.3723, 0.2764, 0.3937]}, {"w": "MSE", "b": [0.2838, 0.3723, 0.3241, 0.3937]}, {"w": "cost", "b": [0.3315, 0.3723, 0.365, 0.3937]}, {"w": "function", "b": [0.3724, 0.3723, 0.4438, 0.3937]}, {"w": "for", "b": [0.4512, 0.3723, 0.4757, 0.3937]}, {"w": "a", "b": [0.4831, 0.3723, 0.4923, 0.3937]}, {"w": "Linear", "b": [0.4997, 0.3723, 0.5536, 0.3937]}, {"w": "Regression", "b": [0.561, 0.3723, 0.6521, 0.3937]}, {"w": "model", "b": [0.6595, 0.3723, 0.7123, 0.3937]}, {"w": "happens", "b": [0.7197, 0.3723, 0.7893, 0.3937]}, {"w": "to", "b": [0.7967, 0.3723, 0.8137, 0.3937]}, {"w": "be", "b": [0.8211, 0.3723, 0.8406, 0.3937]}, {"w": "a", "b": [0.848, 0.3723, 0.8571, 0.3937]}, {"w": "convex", "b": [0.1428, 0.3912, 0.1982, 0.4128]}, {"w": "function,", "b": [0.2049, 0.3912, 0.2778, 0.4128]}, {"w": "which", "b": [0.2844, 0.3914, 0.3353, 0.4128]}, {"w": "means", "b": [0.3419, 0.3914, 0.396, 0.4128]}, {"w": "that", "b": [0.4027, 0.3914, 0.4353, 0.4128]}, {"w": "if", "b": [0.4419, 0.3914, 0.4536, 0.4128]}, {"w": "you", "b": [0.4603, 0.3914, 0.4915, 0.4128]}, {"w": "pick", "b": [0.4982, 0.3914, 0.5338, 0.4128]}, {"w": "any", "b": [0.5404, 0.3914, 0.5701, 0.4128]}, {"w": "two", "b": [0.5767, 0.3914, 0.608, 0.4128]}, {"w": "points", "b": [0.6146, 0.3914, 0.6667, 0.4128]}, {"w": "on", "b": [0.6733, 0.3914, 0.6954, 0.4128]}, {"w": "the", "b": [0.702, 0.3914, 0.7283, 0.4128]}, {"w": "curve,", "b": [0.735, 0.3914, 0.7864, 0.4128]}, {"w": "the", "b": [0.7931, 0.3914, 0.8194, 0.4128]}, {"w": "line", "b": [0.826, 0.3914, 0.8571, 0.4128]}, {"w": "segment", "b": [0.1429, 0.4104, 0.2124, 0.4318]}, {"w": "joining", "b": [0.22, 0.4104, 0.2796, 0.4318]}, {"w": "them", "b": [0.2872, 0.4104, 0.3306, 0.4318]}, {"w": "never", "b": [0.3381, 0.4104, 0.3846, 0.4318]}, {"w": "crosses", "b": [0.3922, 0.4104, 0.4512, 0.4318]}, {"w": "the", "b": [0.4587, 0.4104, 0.4851, 0.4318]}, {"w": "curve.", "b": [0.4926, 0.4104, 0.5441, 0.4318]}, {"w": "This", "b": [0.5516, 0.4104, 0.5889, 0.4318]}, {"w": "implies", "b": [0.5964, 0.4104, 0.6569, 0.4318]}, {"w": "that", "b": [0.6645, 0.4104, 0.6971, 0.4318]}, {"w": "there", "b": [0.7047, 0.4104, 0.7476, 0.4318]}, {"w": "are", "b": [0.7551, 0.4104, 0.7809, 0.4318]}, {"w": "no", "b": [0.7884, 0.4104, 0.8105, 0.4318]}, {"w": "local", "b": [0.818, 0.4104, 0.8571, 0.4318]}, {"w": "minima,", "b": [0.1429, 0.4295, 0.2134, 0.4509]}, {"w": "just", "b": [0.2197, 0.4295, 0.2501, 0.4509]}, {"w": "one", "b": [0.2563, 0.4295, 0.2872, 0.4509]}, {"w": "global", "b": [0.2934, 0.4295, 0.3441, 0.4509]}, {"w": "minimum.", "b": [0.3503, 0.4295, 0.4395, 0.4509]}, {"w": "It", "b": [0.4457, 0.4295, 0.4584, 0.4509]}, {"w": "is", "b": [0.4646, 0.4295, 0.4778, 0.4509]}, {"w": "also", "b": [0.4841, 0.4295, 0.5168, 0.4509]}, {"w": "a", "b": [0.523, 0.4295, 0.5322, 0.4509]}, {"w": "continuous", "b": [0.5384, 0.4295, 0.6322, 0.4509]}, {"w": "function", "b": [0.6384, 0.4295, 0.7098, 0.4509]}, {"w": "with", "b": [0.716, 0.4295, 0.7534, 0.4509]}, {"w": "a", "b": [0.7596, 0.4295, 0.7688, 0.4509]}, {"w": "slope", "b": [0.775, 0.4295, 0.8183, 0.4509]}, {"w": "that", "b": [0.8246, 0.4295, 0.8571, 0.4509]}, {"w": "never", "b": [0.1429, 0.4485, 0.1893, 0.4699]}, {"w": "changes", "b": [0.1949, 0.4485, 0.2616, 0.4699]}, {"w": "abruptly.4", "b": [0.2671, 0.4485, 0.3467, 0.4699]}, {"w": "These", "b": [0.3522, 0.4485, 0.4015, 0.4699]}, {"w": "two", "b": [0.407, 0.4485, 0.4383, 0.4699]}, {"w": "facts", "b": [0.4438, 0.4485, 0.4819, 0.4699]}, {"w": "have", "b": [0.4875, 0.4485, 0.5259, 0.4699]}, {"w": "a", "b": [0.5314, 0.4485, 0.5405, 0.4699]}, {"w": "great", "b": [0.546, 0.4485, 0.5875, 0.4699]}, {"w": "consequence:", "b": [0.593, 0.4485, 0.7047, 0.4699]}, {"w": "Gradient", "b": [0.7102, 0.4485, 0.7848, 0.4699]}, {"w": "Descent", "b": [0.7903, 0.4485, 0.8571, 0.4699]}, {"w": "is", "b": [0.1428, 0.4676, 0.1561, 0.489]}, {"w": "guaranteed", "b": [0.1647, 0.4676, 0.2576, 0.489]}, {"w": "to", "b": [0.2662, 0.4676, 0.2832, 0.489]}, {"w": "approach", "b": [0.2918, 0.4676, 0.3699, 0.489]}, {"w": "arbitrarily", "b": [0.3785, 0.4676, 0.4629, 0.489]}, {"w": "close", "b": [0.4715, 0.4676, 0.5127, 0.489]}, {"w": "the", "b": [0.5214, 0.4676, 0.5477, 0.489]}, {"w": "global", "b": [0.5563, 0.4676, 0.607, 0.489]}, {"w": "minimum", "b": [0.6156, 0.4676, 0.7, 0.489]}, {"w": "(if", "b": [0.7087, 0.4676, 0.7276, 0.489]}, {"w": "you", "b": [0.7363, 0.4676, 0.7675, 0.489]}, {"w": "wait", "b": [0.7761, 0.4676, 0.8115, 0.489]}, {"w": "long", "b": [0.8201, 0.4676, 0.8572, 0.489]}, {"w": "enough", "b": [0.1429, 0.4866, 0.2057, 0.508]}, {"w": "and", "b": [0.2104, 0.4866, 0.2419, 0.508]}, {"w": "if", "b": [0.2467, 0.4866, 0.2584, 0.508]}, {"w": "the", "b": [0.2632, 0.4866, 0.2895, 0.508]}, {"w": "learning", "b": [0.2942, 0.4866, 0.3633, 0.508]}, {"w": "rate", "b": [0.3681, 0.4866, 0.3998, 0.508]}, {"w": "is", "b": [0.4045, 0.4866, 0.4177, 0.508]}, {"w": "not", "b": [0.4224, 0.4866, 0.4508, 0.508]}, {"w": "too", "b": [0.4555, 0.4866, 0.4832, 0.508]}, {"w": "high).", "b": [0.4879, 0.4866, 0.5374, 0.508]}]}, {"id": "b_4", "type": "paragraph", "text": "In fact, the cost function has the shape of a bowl, but it can be an elongated bowl if the features have very different scales. Figure 4-7 shows Gradient Descent on a train‐ ing set where features 1 and 2 have the same scale (on the left), and on a training set where feature 1 has much smaller values than feature 2 (on the right).5", "words": [{"w": "In", "b": [0.1429, 0.5147, 0.1614, 0.5361]}, {"w": "fact,", "b": [0.1677, 0.5147, 0.2029, 0.5361]}, {"w": "the", "b": [0.2092, 0.5147, 0.2356, 0.5361]}, {"w": "cost", "b": [0.2419, 0.5147, 0.2753, 0.5361]}, {"w": "function", "b": [0.2816, 0.5147, 0.353, 0.5361]}, {"w": "has", "b": [0.3594, 0.5147, 0.3873, 0.5361]}, {"w": "the", "b": [0.3936, 0.5147, 0.4199, 0.5361]}, {"w": "shape", "b": [0.4263, 0.5147, 0.4735, 0.5361]}, {"w": "of", "b": [0.4799, 0.5147, 0.4967, 0.5361]}, {"w": "a", "b": [0.503, 0.5147, 0.5121, 0.5361]}, {"w": "bowl,", "b": [0.5185, 0.5147, 0.564, 0.5361]}, {"w": "but", "b": [0.5703, 0.5147, 0.5983, 0.5361]}, {"w": "it", "b": [0.6046, 0.5147, 0.6165, 0.5361]}, {"w": "can", "b": [0.6229, 0.5147, 0.6522, 0.5361]}, {"w": "be", "b": [0.6585, 0.5147, 0.678, 0.5361]}, {"w": "an", "b": [0.6843, 0.5147, 0.7048, 0.5361]}, {"w": "elongated", "b": [0.7112, 0.5147, 0.792, 0.5361]}, {"w": "bowl", "b": [0.7983, 0.5147, 0.8391, 0.5361]}, {"w": "if", "b": [0.8454, 0.5147, 0.8571, 0.5361]}, {"w": "the", "b": [0.1429, 0.5338, 0.1692, 0.5552]}, {"w": "features", "b": [0.1747, 0.5338, 0.2401, 0.5552]}, {"w": "have", "b": [0.2455, 0.5338, 0.2839, 0.5552]}, {"w": "very", "b": [0.2894, 0.5338, 0.3258, 0.5552]}, {"w": "different", "b": [0.3312, 0.5338, 0.403, 0.5552]}, {"w": "scales.", "b": [0.4084, 0.5338, 0.4605, 0.5552]}, {"w": "Figure", "b": [0.466, 0.5338, 0.52, 0.5552]}, {"w": "4-7", "b": [0.5255, 0.5338, 0.5529, 0.5552]}, {"w": "shows", "b": [0.5583, 0.5338, 0.6096, 0.5552]}, {"w": "Gradient", "b": [0.6151, 0.5338, 0.6897, 0.5552]}, {"w": "Descent", "b": [0.6951, 0.5338, 0.762, 0.5552]}, {"w": "on", "b": [0.7674, 0.5338, 0.7894, 0.5552]}, {"w": "a", "b": [0.7949, 0.5338, 0.8041, 0.5552]}, {"w": "train‐", "b": [0.8095, 0.5338, 0.8571, 0.5552]}, {"w": "ing", "b": [0.1428, 0.5528, 0.1696, 0.5742]}, {"w": "set", "b": [0.1753, 0.5528, 0.1982, 0.5742]}, {"w": "where", "b": [0.2039, 0.5528, 0.2547, 0.5742]}, {"w": "features", "b": [0.2604, 0.5528, 0.3259, 0.5742]}, {"w": "1", "b": [0.3316, 0.5528, 0.3416, 0.5742]}, {"w": "and", "b": [0.3473, 0.5528, 0.3789, 0.5742]}, {"w": "2", "b": [0.3846, 0.5528, 0.3946, 0.5742]}, {"w": "have", "b": [0.4003, 0.5528, 0.4387, 0.5742]}, {"w": "the", "b": [0.4444, 0.5528, 0.4708, 0.5742]}, {"w": "same", "b": [0.4765, 0.5528, 0.5192, 0.5742]}, {"w": "scale", "b": [0.5249, 0.5528, 0.5647, 0.5742]}, {"w": "(on", "b": [0.5704, 0.5528, 0.5996, 0.5742]}, {"w": "the", "b": [0.6053, 0.5528, 0.6317, 0.5742]}, {"w": "left),", "b": [0.6374, 0.5528, 0.676, 0.5742]}, {"w": "and", "b": [0.6817, 0.5528, 0.7133, 0.5742]}, {"w": "on", "b": [0.719, 0.5528, 0.741, 0.5742]}, {"w": "a", "b": [0.7467, 0.5528, 0.7559, 0.5742]}, {"w": "training", "b": [0.7616, 0.5528, 0.8286, 0.5742]}, {"w": "set", "b": [0.8343, 0.5528, 0.8571, 0.5742]}, {"w": "where", "b": [0.1429, 0.5719, 0.1937, 0.5933]}, {"w": "feature", "b": [0.1984, 0.5719, 0.2562, 0.5933]}, {"w": "1", "b": [0.2609, 0.5719, 0.2709, 0.5933]}, {"w": "has", "b": [0.2757, 0.5719, 0.3036, 0.5933]}, {"w": "much", "b": [0.3083, 0.5719, 0.356, 0.5933]}, {"w": "smaller", "b": [0.3607, 0.5719, 0.4217, 0.5933]}, {"w": "values", "b": [0.4264, 0.5719, 0.478, 0.5933]}, {"w": "than", "b": [0.4828, 0.5719, 0.5208, 0.5933]}, {"w": "feature", "b": [0.5255, 0.5719, 0.5833, 0.5933]}, {"w": "2", "b": [0.588, 0.5719, 0.598, 0.5933]}, {"w": "(on", "b": [0.6027, 0.5719, 0.632, 0.5933]}, {"w": "the", "b": [0.6367, 0.5719, 0.663, 0.5933]}, {"w": "right).5", "b": [0.6678, 0.5719, 0.7256, 0.5933]}]}, {"id": "b_5", "type": "equation", "text": "Figure 4-7. Gradient Descent with and without feature scaling", "words": [{"w": "Figure", "b": [0.1429, 0.771, 0.1943, 0.7926]}, {"w": "4-7.", "b": [0.1991, 0.771, 0.2308, 0.7926]}, {"w": "Gradient", "b": [0.2356, 0.771, 0.308, 0.7926]}, {"w": "Descent", "b": [0.3128, 0.771, 0.3761, 0.7926]}, {"w": "with", "b": [0.3809, 0.771, 0.4174, 0.7926]}, {"w": "and", "b": [0.4222, 0.771, 0.4535, 0.7926]}, {"w": "without", "b": [0.4583, 0.771, 0.5214, 0.7926]}, {"w": "feature", "b": [0.5262, 0.771, 0.5822, 0.7926]}, {"w": "scaling", "b": [0.587, 0.771, 0.6418, 0.7926]}]}, {"id": "b_6", "type": "paragraph", "text": "122 | Chapter 4: Training Models", "words": [{"w": "122", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 149, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "As you can see, on the left the Gradient Descent algorithm goes straight toward the minimum, thereby reaching it quickly, whereas on the right it first goes in a direction almost orthogonal to the direction of the global minimum, and it ends with a long march down an almost flat valley. It will eventually reach the minimum, but it will take a long time.", "words": [{"w": "As", "b": [0.1429, 0.0791, 0.1649, 0.1005]}, {"w": "you", "b": [0.1714, 0.0791, 0.2026, 0.1005]}, {"w": "can", "b": [0.2091, 0.0791, 0.2384, 0.1005]}, {"w": "see,", "b": [0.2449, 0.0791, 0.275, 0.1005]}, {"w": "on", "b": [0.2815, 0.0791, 0.3035, 0.1005]}, {"w": "the", "b": [0.31, 0.0791, 0.3363, 0.1005]}, {"w": "left", "b": [0.3428, 0.0791, 0.3694, 0.1005]}, {"w": "the", "b": [0.3759, 0.0791, 0.4022, 0.1005]}, {"w": "Gradient", "b": [0.4087, 0.0791, 0.4832, 0.1005]}, {"w": "Descent", "b": [0.4897, 0.0791, 0.5565, 0.1005]}, {"w": "algorithm", "b": [0.563, 0.0791, 0.6457, 0.1005]}, {"w": "goes", "b": [0.6521, 0.0791, 0.689, 0.1005]}, {"w": "straight", "b": [0.6955, 0.0791, 0.7588, 0.1005]}, {"w": "toward", "b": [0.7652, 0.0791, 0.8243, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}, {"w": "minimum,", "b": [0.1429, 0.0981, 0.232, 0.1195]}, {"w": "thereby", "b": [0.2372, 0.0981, 0.3003, 0.1195]}, {"w": "reaching", "b": [0.3055, 0.0981, 0.3779, 0.1195]}, {"w": "it", "b": [0.3831, 0.0981, 0.395, 0.1195]}, {"w": "quickly,", "b": [0.4002, 0.0981, 0.4647, 0.1195]}, {"w": "whereas", "b": [0.4699, 0.0981, 0.5375, 0.1195]}, {"w": "on", "b": [0.5427, 0.0981, 0.5647, 0.1195]}, {"w": "the", "b": [0.5699, 0.0981, 0.5963, 0.1195]}, {"w": "right", "b": [0.6015, 0.0981, 0.6416, 0.1195]}, {"w": "it", "b": [0.6468, 0.0981, 0.6587, 0.1195]}, {"w": "first", "b": [0.6639, 0.0981, 0.6974, 0.1195]}, {"w": "goes", "b": [0.7026, 0.0981, 0.7395, 0.1195]}, {"w": "in", "b": [0.7447, 0.0981, 0.7617, 0.1195]}, {"w": "a", "b": [0.7669, 0.0981, 0.776, 0.1195]}, {"w": "direction", "b": [0.7812, 0.0981, 0.8571, 0.1195]}, {"w": "almost", "b": [0.1429, 0.1172, 0.199, 0.1386]}, {"w": "orthogonal", "b": [0.2059, 0.1172, 0.2986, 0.1386]}, {"w": "to", "b": [0.3055, 0.1172, 0.3225, 0.1386]}, {"w": "the", "b": [0.3295, 0.1172, 0.3558, 0.1386]}, {"w": "direction", "b": [0.3628, 0.1172, 0.4387, 0.1386]}, {"w": "of", "b": [0.4457, 0.1172, 0.4625, 0.1386]}, {"w": "the", "b": [0.4694, 0.1172, 0.4958, 0.1386]}, {"w": "global", "b": [0.5027, 0.1172, 0.5534, 0.1386]}, {"w": "minimum,", "b": [0.5603, 0.1172, 0.6495, 0.1386]}, {"w": "and", "b": [0.6565, 0.1172, 0.688, 0.1386]}, {"w": "it", "b": [0.695, 0.1172, 0.7069, 0.1386]}, {"w": "ends", "b": [0.7139, 0.1172, 0.7527, 0.1386]}, {"w": "with", "b": [0.7597, 0.1172, 0.797, 0.1386]}, {"w": "a", "b": [0.804, 0.1172, 0.8131, 0.1386]}, {"w": "long", "b": [0.8201, 0.1172, 0.8572, 0.1386]}, {"w": "march", "b": [0.1429, 0.1362, 0.1967, 0.1576]}, {"w": "down", "b": [0.2038, 0.1362, 0.2511, 0.1576]}, {"w": "an", "b": [0.2582, 0.1362, 0.2788, 0.1576]}, {"w": "almost", "b": [0.2859, 0.1362, 0.342, 0.1576]}, {"w": "flat", "b": [0.3491, 0.1362, 0.3756, 0.1576]}, {"w": "valley.", "b": [0.3827, 0.1362, 0.4337, 0.1576]}, {"w": "It", "b": [0.4408, 0.1362, 0.4534, 0.1576]}, {"w": "will", "b": [0.4605, 0.1362, 0.4909, 0.1576]}, {"w": "eventually", "b": [0.498, 0.1362, 0.5831, 0.1576]}, {"w": "reach", "b": [0.5901, 0.1362, 0.6358, 0.1576]}, {"w": "the", "b": [0.6429, 0.1362, 0.6692, 0.1576]}, {"w": "minimum,", "b": [0.6763, 0.1362, 0.7655, 0.1576]}, {"w": "but", "b": [0.7726, 0.1362, 0.8006, 0.1576]}, {"w": "it", "b": [0.8077, 0.1362, 0.8197, 0.1576]}, {"w": "will", "b": [0.8268, 0.1362, 0.8571, 0.1576]}, {"w": "take", "b": [0.1429, 0.1553, 0.1775, 0.1767]}, {"w": "a", "b": [0.1823, 0.1553, 0.1914, 0.1767]}, {"w": "long", "b": [0.1961, 0.1553, 0.2332, 0.1767]}, {"w": "time.", "b": [0.2379, 0.1553, 0.2805, 0.1767]}]}, {"id": "b_1", "type": "paragraph", "text": "When using Gradient Descent, you should ensure that all features have a similar scale (e.g., using Scikit-Learn’s StandardScaler class), or else it will take much longer to converge.", "words": [{"w": "When", "b": [0.2714, 0.1972, 0.3186, 0.2168]}, {"w": "using", "b": [0.3245, 0.1972, 0.366, 0.2168]}, {"w": "Gradient", "b": [0.3719, 0.1972, 0.4401, 0.2168]}, {"w": "Descent,", "b": [0.446, 0.1972, 0.5115, 0.2168]}, {"w": "you", "b": [0.5174, 0.1972, 0.5459, 0.2168]}, {"w": "should", "b": [0.5519, 0.1972, 0.6037, 0.2168]}, {"w": "ensure", "b": [0.6096, 0.1972, 0.6604, 0.2168]}, {"w": "that", "b": [0.6663, 0.1972, 0.6961, 0.2168]}, {"w": "all", "b": [0.702, 0.1972, 0.72, 0.2168]}, {"w": "features", "b": [0.7259, 0.1972, 0.7857, 0.2168]}, {"w": "have", "b": [0.2714, 0.2154, 0.3065, 0.235]}, {"w": "a", "b": [0.3173, 0.2154, 0.3256, 0.235]}, {"w": "similar", "b": [0.3364, 0.2154, 0.3894, 0.235]}, {"w": "scale", "b": [0.4002, 0.2154, 0.4365, 0.235]}, {"w": "(e.g.,", "b": [0.4472, 0.2154, 0.4839, 0.235]}, {"w": "using", "b": [0.4946, 0.2154, 0.5362, 0.235]}, {"w": "Scikit-Learn’s", "b": [0.5469, 0.2154, 0.6483, 0.235]}, {"w": "StandardScaler", "b": [0.6591, 0.2183, 0.7857, 0.2321]}, {"w": "class),", "b": [0.2714, 0.2328, 0.3176, 0.2524]}, {"w": "or", "b": [0.3219, 0.2328, 0.3387, 0.2524]}, {"w": "else", "b": [0.343, 0.2328, 0.371, 0.2524]}, {"w": "it", "b": [0.3753, 0.2328, 0.3862, 0.2524]}, {"w": "will", "b": [0.3906, 0.2328, 0.4184, 0.2524]}, {"w": "take", "b": [0.4227, 0.2328, 0.4544, 0.2524]}, {"w": "much", "b": [0.4587, 0.2328, 0.5023, 0.2524]}, {"w": "longer", "b": [0.5066, 0.2328, 0.5556, 0.2524]}, {"w": "to", "b": [0.56, 0.2328, 0.5755, 0.2524]}, {"w": "converge.", "b": [0.5798, 0.2328, 0.6529, 0.2524]}]}, {"id": "b_2", "type": "paragraph", "text": "This diagram also illustrates the fact that training a model means searching for a combination of model parameters that minimizes a cost function (over the training set). It is a search in the model’s parameter space: the more parameters a model has, the more dimensions this space has, and the harder the search is: searching for a nee‐ dle in a 300-dimensional haystack is much trickier than in three dimensions. Fortu‐ nately, since the cost function is convex in the case of Linear Regression, the needle is simply at the bottom of the bowl.", "words": [{"w": "This", "b": [0.1429, 0.2958, 0.1801, 0.3173]}, {"w": "diagram", "b": [0.1884, 0.2958, 0.2578, 0.3173]}, {"w": "also", "b": [0.2662, 0.2958, 0.2988, 0.3173]}, {"w": "illustrates", "b": [0.3072, 0.2958, 0.3877, 0.3173]}, {"w": "the", "b": [0.396, 0.2958, 0.4224, 0.3173]}, {"w": "fact", "b": [0.4307, 0.2958, 0.4612, 0.3173]}, {"w": "that", "b": [0.4695, 0.2958, 0.5021, 0.3173]}, {"w": "training", "b": [0.5104, 0.2958, 0.5774, 0.3173]}, {"w": "a", "b": [0.5857, 0.2958, 0.5948, 0.3173]}, {"w": "model", "b": [0.6032, 0.2958, 0.656, 0.3173]}, {"w": "means", "b": [0.6643, 0.2958, 0.7184, 0.3173]}, {"w": "searching", "b": [0.7268, 0.2958, 0.8068, 0.3173]}, {"w": "for", "b": [0.8151, 0.2958, 0.8397, 0.3173]}, {"w": "a", "b": [0.848, 0.2958, 0.8571, 0.3173]}, {"w": "combination", "b": [0.1429, 0.3149, 0.2496, 0.3363]}, {"w": "of", "b": [0.2563, 0.3149, 0.2731, 0.3363]}, {"w": "model", "b": [0.2797, 0.3149, 0.3325, 0.3363]}, {"w": "parameters", "b": [0.3392, 0.3149, 0.4326, 0.3363]}, {"w": "that", "b": [0.4392, 0.3149, 0.4718, 0.3363]}, {"w": "minimizes", "b": [0.4785, 0.3149, 0.566, 0.3363]}, {"w": "a", "b": [0.5726, 0.3149, 0.5818, 0.3363]}, {"w": "cost", "b": [0.5884, 0.3149, 0.6218, 0.3363]}, {"w": "function", "b": [0.6285, 0.3149, 0.6999, 0.3363]}, {"w": "(over", "b": [0.7065, 0.3149, 0.7506, 0.3363]}, {"w": "the", "b": [0.7572, 0.3149, 0.7836, 0.3363]}, {"w": "training", "b": [0.7902, 0.3149, 0.8571, 0.3363]}, {"w": "set).", "b": [0.1428, 0.3339, 0.1777, 0.3553]}, {"w": "It", "b": [0.184, 0.3339, 0.1966, 0.3553]}, {"w": "is", "b": [0.203, 0.3339, 0.2162, 0.3553]}, {"w": "a", "b": [0.2226, 0.3339, 0.2317, 0.3553]}, {"w": "search", "b": [0.238, 0.3339, 0.2914, 0.3553]}, {"w": "in", "b": [0.2977, 0.3339, 0.3147, 0.3553]}, {"w": "the", "b": [0.321, 0.3339, 0.3473, 0.3553]}, {"w": "model’s", "b": [0.3537, 0.3339, 0.4163, 0.3553]}, {"w": "parameter", "b": [0.4226, 0.3337, 0.5062, 0.3553]}, {"w": "space:", "b": [0.5126, 0.3337, 0.5604, 0.3553]}, {"w": "the", "b": [0.5668, 0.3339, 0.5931, 0.3553]}, {"w": "more", "b": [0.5994, 0.3339, 0.6437, 0.3553]}, {"w": "parameters", "b": [0.6501, 0.3339, 0.7435, 0.3553]}, {"w": "a", "b": [0.7498, 0.3339, 0.759, 0.3553]}, {"w": "model", "b": [0.7653, 0.3339, 0.8181, 0.3553]}, {"w": "has,", "b": [0.8245, 0.3339, 0.8571, 0.3553]}, {"w": "the", "b": [0.1429, 0.353, 0.1692, 0.3744]}, {"w": "more", "b": [0.1743, 0.353, 0.2186, 0.3744]}, {"w": "dimensions", "b": [0.2237, 0.353, 0.3205, 0.3744]}, {"w": "this", "b": [0.3256, 0.353, 0.3563, 0.3744]}, {"w": "space", "b": [0.3615, 0.353, 0.4068, 0.3744]}, {"w": "has,", "b": [0.412, 0.353, 0.4446, 0.3744]}, {"w": "and", "b": [0.4497, 0.353, 0.4813, 0.3744]}, {"w": "the", "b": [0.4864, 0.353, 0.5127, 0.3744]}, {"w": "harder", "b": [0.5179, 0.353, 0.5734, 0.3744]}, {"w": "the", "b": [0.5786, 0.353, 0.6049, 0.3744]}, {"w": "search", "b": [0.61, 0.353, 0.6633, 0.3744]}, {"w": "is:", "b": [0.6685, 0.353, 0.6864, 0.3744]}, {"w": "searching", "b": [0.6916, 0.353, 0.7716, 0.3744]}, {"w": "for", "b": [0.7767, 0.353, 0.8012, 0.3744]}, {"w": "a", "b": [0.8064, 0.353, 0.8155, 0.3744]}, {"w": "nee‐", "b": [0.8206, 0.353, 0.8571, 0.3744]}, {"w": "dle", "b": [0.1429, 0.372, 0.168, 0.3934]}, {"w": "in", "b": [0.1742, 0.372, 0.1912, 0.3934]}, {"w": "a", "b": [0.1975, 0.372, 0.2066, 0.3934]}, {"w": "300-dimensional", "b": [0.2129, 0.372, 0.3539, 0.3934]}, {"w": "haystack", "b": [0.3601, 0.372, 0.4319, 0.3934]}, {"w": "is", "b": [0.4382, 0.372, 0.4514, 0.3934]}, {"w": "much", "b": [0.4576, 0.372, 0.5053, 0.3934]}, {"w": "trickier", "b": [0.5116, 0.372, 0.5726, 0.3934]}, {"w": "than", "b": [0.5788, 0.372, 0.6168, 0.3934]}, {"w": "in", "b": [0.6231, 0.372, 0.6401, 0.3934]}, {"w": "three", "b": [0.6463, 0.372, 0.6893, 0.3934]}, {"w": "dimensions.", "b": [0.6955, 0.372, 0.7971, 0.3934]}, {"w": "Fortu‐", "b": [0.8033, 0.372, 0.8571, 0.3934]}, {"w": "nately,", "b": [0.1429, 0.3911, 0.1963, 0.4125]}, {"w": "since", "b": [0.2014, 0.3911, 0.2437, 0.4125]}, {"w": "the", "b": [0.2489, 0.3911, 0.2752, 0.4125]}, {"w": "cost", "b": [0.2804, 0.3911, 0.3138, 0.4125]}, {"w": "function", "b": [0.319, 0.3911, 0.3904, 0.4125]}, {"w": "is", "b": [0.3955, 0.3911, 0.4088, 0.4125]}, {"w": "convex", "b": [0.4139, 0.3911, 0.4726, 0.4125]}, {"w": "in", "b": [0.4778, 0.3911, 0.4948, 0.4125]}, {"w": "the", "b": [0.4999, 0.3911, 0.5263, 0.4125]}, {"w": "case", "b": [0.5314, 0.3911, 0.5659, 0.4125]}, {"w": "of", "b": [0.571, 0.3911, 0.5878, 0.4125]}, {"w": "Linear", "b": [0.593, 0.3911, 0.6469, 0.4125]}, {"w": "Regression,", "b": [0.6521, 0.3911, 0.7479, 0.4125]}, {"w": "the", "b": [0.753, 0.3911, 0.7794, 0.4125]}, {"w": "needle", "b": [0.7845, 0.3911, 0.8387, 0.4125]}, {"w": "is", "b": [0.8439, 0.3911, 0.8571, 0.4125]}, {"w": "simply", "b": [0.1428, 0.4101, 0.1985, 0.4315]}, {"w": "at", "b": [0.2032, 0.4101, 0.2183, 0.4315]}, {"w": "the", "b": [0.2231, 0.4101, 0.2494, 0.4315]}, {"w": "bottom", "b": [0.2541, 0.4101, 0.3157, 0.4315]}, {"w": "of", "b": [0.3204, 0.4101, 0.3372, 0.4315]}, {"w": "the", "b": [0.342, 0.4101, 0.3683, 0.4315]}, {"w": "bowl.", "b": [0.373, 0.4101, 0.4185, 0.4315]}]}, {"id": "b_3", "type": "paragraph", "text": "Batch Gradient Descent", "words": [{"w": "Batch", "b": [0.1429, 0.4443, 0.2018, 0.4729]}, {"w": "Gradient", "b": [0.2067, 0.4443, 0.2965, 0.4729]}, {"w": "Descent", "b": [0.3014, 0.4443, 0.3827, 0.4729]}]}, {"id": "b_4", "type": "paragraph", "text": "To implement Gradient Descent, you need to compute the gradient of the cost func‐ tion with regards to each model parameter θj. In other words, you need to calculate how much the cost function will change if you change θj just a little bit. This is called a partial derivative. It is like asking “what is the slope of the mountain under my feet if I face east?” and then asking the same question facing north (and so on for all other dimensions, if you can imagine a universe with more than three dimensions). Equa‐ tion 4-5 computes the partial derivative of the cost function with regards to parame‐ ter θj, noted ∂", "words": [{"w": "To", "b": [0.1429, 0.4788, 0.1643, 0.5002]}, {"w": "implement", "b": [0.1702, 0.4788, 0.2608, 0.5002]}, {"w": "Gradient", "b": [0.2668, 0.4788, 0.3413, 0.5002]}, {"w": "Descent,", "b": [0.3473, 0.4788, 0.4189, 0.5002]}, {"w": "you", "b": [0.4248, 0.4788, 0.4561, 0.5002]}, {"w": "need", "b": [0.462, 0.4788, 0.5021, 0.5002]}, {"w": "to", "b": [0.5081, 0.4788, 0.525, 0.5002]}, {"w": "compute", "b": [0.531, 0.4788, 0.6043, 0.5002]}, {"w": "the", "b": [0.6102, 0.4788, 0.6366, 0.5002]}, {"w": "gradient", "b": [0.6425, 0.4788, 0.7119, 0.5002]}, {"w": "of", "b": [0.7179, 0.4788, 0.7347, 0.5002]}, {"w": "the", "b": [0.7406, 0.4788, 0.767, 0.5002]}, {"w": "cost", "b": [0.7729, 0.4788, 0.8063, 0.5002]}, {"w": "func‐", "b": [0.8123, 0.4788, 0.8571, 0.5002]}, {"w": "tion", "b": [0.1429, 0.4978, 0.1768, 0.5192]}, {"w": "with", "b": [0.1832, 0.4978, 0.2206, 0.5192]}, {"w": "regards", "b": [0.227, 0.4978, 0.2888, 0.5192]}, {"w": "to", "b": [0.2952, 0.4978, 0.3122, 0.5192]}, {"w": "each", "b": [0.3186, 0.4978, 0.3566, 0.5192]}, {"w": "model", "b": [0.363, 0.4978, 0.4158, 0.5192]}, {"w": "parameter", "b": [0.4222, 0.4978, 0.508, 0.5192]}, {"w": "θj.", "b": [0.5144, 0.4976, 0.5324, 0.5201]}, {"w": "In", "b": [0.5388, 0.4978, 0.5573, 0.5192]}, {"w": "other", "b": [0.5637, 0.4978, 0.6084, 0.5192]}, {"w": "words,", "b": [0.6148, 0.4978, 0.6708, 0.5192]}, {"w": "you", "b": [0.6772, 0.4978, 0.7085, 0.5192]}, {"w": "need", "b": [0.7149, 0.4978, 0.755, 0.5192]}, {"w": "to", "b": [0.7614, 0.4978, 0.7784, 0.5192]}, {"w": "calculate", "b": [0.7848, 0.4978, 0.8571, 0.5192]}, {"w": "how", "b": [0.1428, 0.5169, 0.1789, 0.5383]}, {"w": "much", "b": [0.1839, 0.5169, 0.2316, 0.5383]}, {"w": "the", "b": [0.2367, 0.5169, 0.263, 0.5383]}, {"w": "cost", "b": [0.2681, 0.5169, 0.3015, 0.5383]}, {"w": "function", "b": [0.3066, 0.5169, 0.378, 0.5383]}, {"w": "will", "b": [0.3831, 0.5169, 0.4135, 0.5383]}, {"w": "change", "b": [0.4185, 0.5169, 0.4776, 0.5383]}, {"w": "if", "b": [0.4827, 0.5169, 0.4944, 0.5383]}, {"w": "you", "b": [0.4995, 0.5169, 0.5308, 0.5383]}, {"w": "change", "b": [0.5358, 0.5169, 0.5949, 0.5383]}, {"w": "θj", "b": [0.6, 0.5167, 0.6133, 0.5392]}, {"w": "just", "b": [0.6183, 0.5169, 0.6487, 0.5383]}, {"w": "a", "b": [0.6538, 0.5169, 0.663, 0.5383]}, {"w": "little", "b": [0.668, 0.5169, 0.7057, 0.5383]}, {"w": "bit.", "b": [0.7108, 0.5169, 0.7381, 0.5383]}, {"w": "This", "b": [0.7431, 0.5169, 0.7803, 0.5383]}, {"w": "is", "b": [0.7854, 0.5169, 0.7986, 0.5383]}, {"w": "called", "b": [0.8037, 0.5169, 0.8521, 0.5383]}, {"w": "a", "b": [0.1429, 0.5359, 0.152, 0.5573]}, {"w": "partial", "b": [0.1578, 0.5357, 0.2127, 0.5573]}, {"w": "derivative.", "b": [0.2185, 0.5357, 0.3034, 0.5573]}, {"w": "It", "b": [0.3091, 0.5359, 0.3218, 0.5573]}, {"w": "is", "b": [0.3275, 0.5359, 0.3407, 0.5573]}, {"w": "like", "b": [0.3465, 0.5359, 0.3765, 0.5573]}, {"w": "asking", "b": [0.3823, 0.5359, 0.4362, 0.5573]}, {"w": "“what", "b": [0.4419, 0.5359, 0.4907, 0.5573]}, {"w": "is", "b": [0.4965, 0.5359, 0.5097, 0.5573]}, {"w": "the", "b": [0.5154, 0.5359, 0.5418, 0.5573]}, {"w": "slope", "b": [0.5475, 0.5359, 0.5908, 0.5573]}, {"w": "of", "b": [0.5966, 0.5359, 0.6134, 0.5573]}, {"w": "the", "b": [0.6191, 0.5359, 0.6455, 0.5573]}, {"w": "mountain", "b": [0.6512, 0.5359, 0.7335, 0.5573]}, {"w": "under", "b": [0.7392, 0.5359, 0.7893, 0.5573]}, {"w": "my", "b": [0.795, 0.5359, 0.8212, 0.5573]}, {"w": "feet", "b": [0.8269, 0.5359, 0.8571, 0.5573]}, {"w": "if", "b": [0.1428, 0.555, 0.1546, 0.5764]}, {"w": "I", "b": [0.1595, 0.555, 0.1666, 0.5764]}, {"w": "face", "b": [0.1715, 0.555, 0.2045, 0.5764]}, {"w": "east?”", "b": [0.2094, 0.555, 0.258, 0.5764]}, {"w": "and", "b": [0.2629, 0.555, 0.2945, 0.5764]}, {"w": "then", "b": [0.2994, 0.555, 0.3371, 0.5764]}, {"w": "asking", "b": [0.342, 0.555, 0.3959, 0.5764]}, {"w": "the", "b": [0.4008, 0.555, 0.4271, 0.5764]}, {"w": "same", "b": [0.432, 0.555, 0.4748, 0.5764]}, {"w": "question", "b": [0.4797, 0.555, 0.5518, 0.5764]}, {"w": "facing", "b": [0.5567, 0.555, 0.6076, 0.5764]}, {"w": "north", "b": [0.6125, 0.555, 0.6597, 0.5764]}, {"w": "(and", "b": [0.6646, 0.555, 0.7034, 0.5764]}, {"w": "so", "b": [0.7083, 0.555, 0.7266, 0.5764]}, {"w": "on", "b": [0.7315, 0.555, 0.7535, 0.5764]}, {"w": "for", "b": [0.7584, 0.555, 0.7829, 0.5764]}, {"w": "all", "b": [0.7878, 0.555, 0.8075, 0.5764]}, {"w": "other", "b": [0.8124, 0.555, 0.8571, 0.5764]}, {"w": "dimensions,", "b": [0.1429, 0.574, 0.2444, 0.5954]}, {"w": "if", "b": [0.2504, 0.574, 0.2621, 0.5954]}, {"w": "you", "b": [0.2681, 0.574, 0.2994, 0.5954]}, {"w": "can", "b": [0.3053, 0.574, 0.3347, 0.5954]}, {"w": "imagine", "b": [0.3407, 0.574, 0.408, 0.5954]}, {"w": "a", "b": [0.414, 0.574, 0.4232, 0.5954]}, {"w": "universe", "b": [0.4291, 0.574, 0.4999, 0.5954]}, {"w": "with", "b": [0.5059, 0.574, 0.5432, 0.5954]}, {"w": "more", "b": [0.5492, 0.574, 0.5935, 0.5954]}, {"w": "than", "b": [0.5994, 0.574, 0.6375, 0.5954]}, {"w": "three", "b": [0.6434, 0.574, 0.6863, 0.5954]}, {"w": "dimensions).", "b": [0.6923, 0.574, 0.8011, 0.5954]}, {"w": "Equa‐", "b": [0.807, 0.574, 0.8571, 0.5954]}, {"w": "tion", "b": [0.1429, 0.5931, 0.1768, 0.6145]}, {"w": "4-5", "b": [0.1826, 0.5931, 0.21, 0.6145]}, {"w": "computes", "b": [0.2158, 0.5931, 0.2967, 0.6145]}, {"w": "the", "b": [0.3025, 0.5931, 0.3288, 0.6145]}, {"w": "partial", "b": [0.3346, 0.5931, 0.3888, 0.6145]}, {"w": "derivative", "b": [0.3945, 0.5931, 0.4765, 0.6145]}, {"w": "of", "b": [0.4823, 0.5931, 0.4991, 0.6145]}, {"w": "the", "b": [0.5049, 0.5931, 0.5312, 0.6145]}, {"w": "cost", "b": [0.537, 0.5931, 0.5704, 0.6145]}, {"w": "function", "b": [0.5762, 0.5931, 0.6476, 0.6145]}, {"w": "with", "b": [0.6534, 0.5931, 0.6907, 0.6145]}, {"w": "regards", "b": [0.6965, 0.5931, 0.7583, 0.6145]}, {"w": "to", "b": [0.7641, 0.5931, 0.7811, 0.6145]}, {"w": "parame‐", "b": [0.7869, 0.5931, 0.8571, 0.6145]}, {"w": "ter", "b": [0.1429, 0.616, 0.1658, 0.6374]}, {"w": "θj,", "b": [0.1705, 0.6158, 0.1885, 0.6383]}, {"w": "noted", "b": [0.1933, 0.616, 0.2415, 0.6374]}, {"w": "∂", "b": [0.2552, 0.6115, 0.263, 0.6278]}]}, {"id": "b_5", "type": "paragraph", "text": "∂θj MSE(θ).", "words": [{"w": "∂θj", "b": [0.2485, 0.6261, 0.2697, 0.6486]}, {"w": "MSE(θ).", "b": [0.2768, 0.6154, 0.3468, 0.6374]}]}, {"id": "b_6", "type": "equation", "text": "Equation 4-5. Partial derivatives of the cost function", "words": [{"w": "Equation", "b": [0.1726, 0.6655, 0.2473, 0.6871]}, {"w": "4-5.", "b": [0.2521, 0.6655, 0.2838, 0.6871]}, {"w": "Partial", "b": [0.2886, 0.6655, 0.3445, 0.6871]}, {"w": "derivatives", "b": [0.3493, 0.6655, 0.4363, 0.6871]}, {"w": "of", "b": [0.441, 0.6655, 0.4563, 0.6871]}, {"w": "the", "b": [0.461, 0.6655, 0.4861, 0.6871]}, {"w": "cost", "b": [0.4908, 0.6655, 0.5215, 0.6871]}, {"w": "function", "b": [0.5263, 0.6655, 0.5944, 0.6871]}]}, {"id": "b_7", "type": "paragraph", "text": "∂ ∂θj", "words": [{"w": "∂", "b": [0.1825, 0.6982, 0.1922, 0.7186]}, {"w": "∂θj", "b": [0.1748, 0.7157, 0.1998, 0.7405]}]}, {"id": "b_8", "type": "equation", "text": "MSE θ = 2", "words": [{"w": "MSE", "b": [0.202, 0.7071, 0.2404, 0.7275]}, {"w": "θ", "b": [0.2473, 0.7065, 0.2574, 0.7275]}, {"w": "=", "b": [0.2697, 0.7071, 0.2813, 0.7275]}, {"w": "2", "b": [0.292, 0.6982, 0.3016, 0.7186]}]}, {"id": "b_9", "type": "paragraph", "text": "m ∑", "words": [{"w": "m", "b": [0.289, 0.7157, 0.3046, 0.7363]}, {"w": "∑", "b": [0.3154, 0.7023, 0.3304, 0.7311]}]}, {"id": "b_10", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.3079, 0.7218, 0.3122, 0.7382]}, {"w": "=", "b": [0.3166, 0.7219, 0.3258, 0.7382]}, {"w": "1", "b": [0.3303, 0.7219, 0.3379, 0.7382]}]}, {"id": "b_12", "type": "paragraph", "text": "θTx i −y i xj", "words": [{"w": "θTx", "b": [0.3469, 0.7032, 0.3769, 0.7275]}, {"w": "i", "b": [0.3825, 0.7032, 0.3868, 0.7196]}, {"w": "−y", "b": [0.3967, 0.7069, 0.4226, 0.7275]}, {"w": "i", "b": [0.4281, 0.7032, 0.4324, 0.7196]}, {"w": "xj", "b": [0.4481, 0.7069, 0.4633, 0.7317]}]}, {"id": "b_14", "type": "paragraph", "text": "Instead of computing these partial derivatives individually, you can use Equation 4-6 to compute them all in one go. The gradient vector, noted ∇θMSE(θ), contains all the partial derivatives of the cost function (one for each model parameter).", "words": [{"w": "Instead", "b": [0.1429, 0.7596, 0.2044, 0.781]}, {"w": "of", "b": [0.2101, 0.7596, 0.2269, 0.781]}, {"w": "computing", "b": [0.2326, 0.7596, 0.3238, 0.781]}, {"w": "these", "b": [0.3295, 0.7596, 0.3723, 0.781]}, {"w": "partial", "b": [0.3781, 0.7596, 0.4322, 0.781]}, {"w": "derivatives", "b": [0.438, 0.7596, 0.5276, 0.781]}, {"w": "individually,", "b": [0.5333, 0.7596, 0.6367, 0.781]}, {"w": "you", "b": [0.6424, 0.7596, 0.6736, 0.781]}, {"w": "can", "b": [0.6794, 0.7596, 0.7087, 0.781]}, {"w": "use", "b": [0.7145, 0.7596, 0.742, 0.781]}, {"w": "Equation", "b": [0.7478, 0.7596, 0.824, 0.781]}, {"w": "4-6", "b": [0.8297, 0.7596, 0.8571, 0.781]}, {"w": "to", "b": [0.1429, 0.7786, 0.1598, 0.8001]}, {"w": "compute", "b": [0.165, 0.7786, 0.2383, 0.8001]}, {"w": "them", "b": [0.2435, 0.7786, 0.2869, 0.8001]}, {"w": "all", "b": [0.292, 0.7786, 0.3117, 0.8001]}, {"w": "in", "b": [0.3169, 0.7786, 0.3339, 0.8001]}, {"w": "one", "b": [0.339, 0.7786, 0.3699, 0.8001]}, {"w": "go.", "b": [0.3751, 0.7786, 0.3996, 0.8001]}, {"w": "The", "b": [0.4048, 0.7786, 0.4376, 0.8001]}, {"w": "gradient", "b": [0.4428, 0.7786, 0.5122, 0.8001]}, {"w": "vector,", "b": [0.5174, 0.7786, 0.5728, 0.8001]}, {"w": "noted", "b": [0.578, 0.7786, 0.6262, 0.8001]}, {"w": "∇θMSE(θ),", "b": [0.6314, 0.7781, 0.725, 0.8009]}, {"w": "contains", "b": [0.7302, 0.7786, 0.8008, 0.8001]}, {"w": "all", "b": [0.8059, 0.7786, 0.8256, 0.8001]}, {"w": "the", "b": [0.8308, 0.7786, 0.8571, 0.8001]}, {"w": "partial", "b": [0.1428, 0.7977, 0.197, 0.8191]}, {"w": "derivatives", "b": [0.2017, 0.7977, 0.2914, 0.8191]}, {"w": "of", "b": [0.2961, 0.7977, 0.3129, 0.8191]}, {"w": "the", "b": [0.3176, 0.7977, 0.344, 0.8191]}, {"w": "cost", "b": [0.3487, 0.7977, 0.3821, 0.8191]}, {"w": "function", "b": [0.3868, 0.7977, 0.4582, 0.8191]}, {"w": "(one", "b": [0.463, 0.7977, 0.5011, 0.8191]}, {"w": "for", "b": [0.5058, 0.7977, 0.5303, 0.8191]}, {"w": "each", "b": [0.535, 0.7977, 0.573, 0.8191]}, {"w": "model", "b": [0.5777, 0.7977, 0.6305, 0.8191]}, {"w": "parameter).", "b": [0.6352, 0.7977, 0.733, 0.8191]}]}, {"id": "b_15", "type": "paragraph", "text": "Gradient Descent | 123", "words": [{"w": "Gradient", "b": [0.6954, 0.9225, 0.7466, 0.9388]}, {"w": "Descent", "b": [0.7494, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "123", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 150, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 Eta (η) is the 7th letter of the Greek alphabet.", "words": [{"w": "6", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "Eta", "b": [0.1587, 0.8749, 0.1792, 0.8912]}, {"w": "(η)", "b": [0.1828, 0.8748, 0.2019, 0.8912]}, {"w": "is", "b": [0.2055, 0.8749, 0.2156, 0.8912]}, {"w": "the", "b": [0.2192, 0.8749, 0.2392, 0.8912]}, {"w": "7th", "b": [0.2428, 0.8734, 0.2609, 0.8912]}, {"w": "letter", "b": [0.2645, 0.8749, 0.2976, 0.8912]}, {"w": "of", "b": [0.3012, 0.8749, 0.314, 0.8912]}, {"w": "the", "b": [0.3176, 0.8749, 0.3377, 0.8912]}, {"w": "Greek", "b": [0.3413, 0.8749, 0.3799, 0.8912]}, {"w": "alphabet.", "b": [0.3835, 0.8749, 0.4415, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Equation 4-6. Gradient vector of the cost function", "words": [{"w": "Equation", "b": [0.1726, 0.0769, 0.2473, 0.0985]}, {"w": "4-6.", "b": [0.2521, 0.0769, 0.2838, 0.0985]}, {"w": "Gradient", "b": [0.2886, 0.0769, 0.361, 0.0985]}, {"w": "vector", "b": [0.3658, 0.0769, 0.4147, 0.0985]}, {"w": "of", "b": [0.4195, 0.0769, 0.4347, 0.0985]}, {"w": "the", "b": [0.4394, 0.0769, 0.4645, 0.0985]}, {"w": "cost", "b": [0.4693, 0.0769, 0.4999, 0.0985]}, {"w": "function", "b": [0.5047, 0.0769, 0.5728, 0.0985]}]}, {"id": "b_2", "type": "equation", "text": "∇θ MSE θ =", "words": [{"w": "∇θ", "b": [0.1726, 0.1738, 0.1971, 0.1945]}, {"w": "MSE", "b": [0.2004, 0.1707, 0.2388, 0.1911]}, {"w": "θ", "b": [0.2456, 0.1702, 0.2557, 0.1911]}, {"w": "=", "b": [0.2681, 0.1707, 0.2796, 0.1911]}]}, {"id": "b_3", "type": "paragraph", "text": "∂ ∂θ0", "words": [{"w": "∂", "b": [0.3032, 0.1048, 0.3129, 0.1252]}, {"w": "∂θ0", "b": [0.2946, 0.1223, 0.3214, 0.1471]}]}, {"id": "b_4", "type": "paragraph", "text": "MSE θ", "words": [{"w": "MSE", "b": [0.3236, 0.1137, 0.362, 0.1341]}, {"w": "θ", "b": [0.3688, 0.1131, 0.3789, 0.1341]}]}, {"id": "b_5", "type": "paragraph", "text": "∂ ∂θ1", "words": [{"w": "∂", "b": [0.3032, 0.1488, 0.3129, 0.1691]}, {"w": "∂θ1", "b": [0.2946, 0.1662, 0.3214, 0.1911]}]}, {"id": "b_6", "type": "paragraph", "text": "MSE θ", "words": [{"w": "MSE", "b": [0.3236, 0.1576, 0.362, 0.178]}, {"w": "θ", "b": [0.3688, 0.157, 0.3789, 0.178]}]}, {"id": "b_7", "type": "paragraph", "text": "⋮ ∂ ∂θn", "words": [{"w": "⋮", "b": [0.3358, 0.1966, 0.3424, 0.2117]}, {"w": "∂", "b": [0.3032, 0.2144, 0.3129, 0.2348]}, {"w": "∂θn", "b": [0.2942, 0.2318, 0.3218, 0.2567]}]}, {"id": "b_8", "type": "paragraph", "text": "MSE θ", "words": [{"w": "MSE", "b": [0.324, 0.2232, 0.3624, 0.2436]}, {"w": "θ", "b": [0.3692, 0.2227, 0.3793, 0.2436]}]}, {"id": "b_9", "type": "equation", "text": "= 2", "words": [{"w": "=", "b": [0.3986, 0.1707, 0.4101, 0.1911]}, {"w": "2", "b": [0.4209, 0.1619, 0.4304, 0.1823]}]}, {"id": "b_10", "type": "paragraph", "text": "mXT Xθ −y", "words": [{"w": "mXT", "b": [0.4178, 0.1668, 0.459, 0.1999]}, {"w": "Xθ", "b": [0.4665, 0.1702, 0.4904, 0.1911]}, {"w": "−y", "b": [0.4948, 0.1702, 0.5201, 0.1911]}]}, {"id": "b_11", "type": "paragraph", "text": "Notice that this formula involves calculations over the full training set X, at each Gradient Descent step! This is why the algorithm is called Batch Gradient Descent: it uses the whole batch of training data at every step (actually, Full Gradient Descent would probably be a better name). As a result it is terribly slow on very large train‐ ing sets (but we will see much faster Gradient Descent algorithms shortly). However, Gradient Descent scales well with the number of features; training a Linear Regression model when there are hun‐ dreds of thousands of features is much faster using Gradient Descent than using the Normal Equation or SVD decomposition.", "words": [{"w": "Notice", "b": [0.2714, 0.276, 0.3219, 0.2956]}, {"w": "that", "b": [0.3272, 0.276, 0.357, 0.2956]}, {"w": "this", "b": [0.3623, 0.276, 0.3904, 0.2956]}, {"w": "formula", "b": [0.3958, 0.276, 0.4567, 0.2956]}, {"w": "involves", "b": [0.462, 0.276, 0.5244, 0.2956]}, {"w": "calculations", "b": [0.5297, 0.276, 0.62, 0.2956]}, {"w": "over", "b": [0.6253, 0.276, 0.659, 0.2956]}, {"w": "the", "b": [0.6644, 0.276, 0.6884, 0.2956]}, {"w": "full", "b": [0.6938, 0.276, 0.7192, 0.2956]}, {"w": "training", "b": [0.7245, 0.276, 0.7857, 0.2956]}, {"w": "set", "b": [0.2714, 0.2934, 0.2923, 0.313]}, {"w": "X,", "b": [0.2984, 0.2929, 0.3159, 0.313]}, {"w": "at", "b": [0.3219, 0.2934, 0.3358, 0.313]}, {"w": "each", "b": [0.3418, 0.2934, 0.3765, 0.313]}, {"w": "Gradient", "b": [0.3825, 0.2934, 0.4507, 0.313]}, {"w": "Descent", "b": [0.4568, 0.2934, 0.5179, 0.313]}, {"w": "step!", "b": [0.5239, 0.2934, 0.56, 0.313]}, {"w": "This", "b": [0.5661, 0.2934, 0.6001, 0.313]}, {"w": "is", "b": [0.6062, 0.2934, 0.6183, 0.313]}, {"w": "why", "b": [0.6243, 0.2934, 0.6558, 0.313]}, {"w": "the", "b": [0.6619, 0.2934, 0.686, 0.313]}, {"w": "algorithm", "b": [0.692, 0.2934, 0.7676, 0.313]}, {"w": "is", "b": [0.7736, 0.2934, 0.7857, 0.313]}, {"w": "called", "b": [0.2714, 0.3108, 0.3156, 0.3304]}, {"w": "Batch", "b": [0.3224, 0.3106, 0.3648, 0.3304]}, {"w": "Gradient", "b": [0.3717, 0.3106, 0.4379, 0.3304]}, {"w": "Descent:", "b": [0.4447, 0.3106, 0.507, 0.3304]}, {"w": "it", "b": [0.5137, 0.3108, 0.5247, 0.3304]}, {"w": "uses", "b": [0.5314, 0.3108, 0.5636, 0.3304]}, {"w": "the", "b": [0.5704, 0.3108, 0.5945, 0.3304]}, {"w": "whole", "b": [0.6013, 0.3108, 0.6471, 0.3304]}, {"w": "batch", "b": [0.6539, 0.3108, 0.6956, 0.3304]}, {"w": "of", "b": [0.7024, 0.3108, 0.7177, 0.3304]}, {"w": "training", "b": [0.7245, 0.3108, 0.7857, 0.3304]}, {"w": "data", "b": [0.2714, 0.3282, 0.3036, 0.3478]}, {"w": "at", "b": [0.3101, 0.3282, 0.3239, 0.3478]}, {"w": "every", "b": [0.3304, 0.3282, 0.3718, 0.3478]}, {"w": "step", "b": [0.3783, 0.3282, 0.4091, 0.3478]}, {"w": "(actually,", "b": [0.4156, 0.3282, 0.4843, 0.3478]}, {"w": "Full", "b": [0.4907, 0.328, 0.5198, 0.3478]}, {"w": "Gradient", "b": [0.5263, 0.328, 0.5926, 0.3478]}, {"w": "Descent", "b": [0.5991, 0.328, 0.657, 0.3478]}, {"w": "would", "b": [0.6634, 0.3282, 0.7112, 0.3478]}, {"w": "probably", "b": [0.7177, 0.3282, 0.7857, 0.3478]}, {"w": "be", "b": [0.2714, 0.3456, 0.2892, 0.3652]}, {"w": "a", "b": [0.2942, 0.3456, 0.3026, 0.3652]}, {"w": "better", "b": [0.3076, 0.3456, 0.3522, 0.3652]}, {"w": "name).", "b": [0.3572, 0.3456, 0.4106, 0.3652]}, {"w": "As", "b": [0.4157, 0.3456, 0.4358, 0.3652]}, {"w": "a", "b": [0.4409, 0.3456, 0.4492, 0.3652]}, {"w": "result", "b": [0.4543, 0.3456, 0.4972, 0.3652]}, {"w": "it", "b": [0.5022, 0.3456, 0.5131, 0.3652]}, {"w": "is", "b": [0.5182, 0.3456, 0.5303, 0.3652]}, {"w": "terribly", "b": [0.5353, 0.3456, 0.5917, 0.3652]}, {"w": "slow", "b": [0.5968, 0.3456, 0.6313, 0.3652]}, {"w": "on", "b": [0.6364, 0.3456, 0.6565, 0.3652]}, {"w": "very", "b": [0.6616, 0.3456, 0.6948, 0.3652]}, {"w": "large", "b": [0.6999, 0.3456, 0.7371, 0.3652]}, {"w": "train‐", "b": [0.7422, 0.3456, 0.7857, 0.3652]}, {"w": "ing", "b": [0.2714, 0.3631, 0.2959, 0.3826]}, {"w": "sets", "b": [0.3019, 0.3631, 0.3298, 0.3826]}, {"w": "(but", "b": [0.3358, 0.3631, 0.368, 0.3826]}, {"w": "we", "b": [0.374, 0.3631, 0.3952, 0.3826]}, {"w": "will", "b": [0.4012, 0.3631, 0.429, 0.3826]}, {"w": "see", "b": [0.435, 0.3631, 0.4582, 0.3826]}, {"w": "much", "b": [0.4642, 0.3631, 0.5078, 0.3826]}, {"w": "faster", "b": [0.5138, 0.3631, 0.5558, 0.3826]}, {"w": "Gradient", "b": [0.5618, 0.3631, 0.63, 0.3826]}, {"w": "Descent", "b": [0.636, 0.3631, 0.6971, 0.3826]}, {"w": "algorithms", "b": [0.7032, 0.3631, 0.7857, 0.3826]}, {"w": "shortly).", "b": [0.2714, 0.3805, 0.3357, 0.4]}, {"w": "However,", "b": [0.3402, 0.3805, 0.4122, 0.4]}, {"w": "Gradient", "b": [0.4167, 0.3805, 0.4849, 0.4]}, {"w": "Descent", "b": [0.4894, 0.3805, 0.5505, 0.4]}, {"w": "scales", "b": [0.555, 0.3805, 0.5983, 0.4]}, {"w": "well", "b": [0.6028, 0.3805, 0.6336, 0.4]}, {"w": "with", "b": [0.6381, 0.3805, 0.6722, 0.4]}, {"w": "the", "b": [0.6767, 0.3805, 0.7008, 0.4]}, {"w": "number", "b": [0.7053, 0.3805, 0.7659, 0.4]}, {"w": "of", "b": [0.7704, 0.3805, 0.7857, 0.4]}, {"w": "features;", "b": [0.2714, 0.3979, 0.3356, 0.4175]}, {"w": "training", "b": [0.342, 0.3979, 0.4032, 0.4175]}, {"w": "a", "b": [0.4097, 0.3979, 0.4181, 0.4175]}, {"w": "Linear", "b": [0.4245, 0.3979, 0.4738, 0.4175]}, {"w": "Regression", "b": [0.4803, 0.3979, 0.5635, 0.4175]}, {"w": "model", "b": [0.57, 0.3979, 0.6182, 0.4175]}, {"w": "when", "b": [0.6247, 0.3979, 0.6664, 0.4175]}, {"w": "there", "b": [0.6729, 0.3979, 0.7121, 0.4175]}, {"w": "are", "b": [0.7186, 0.3979, 0.7421, 0.4175]}, {"w": "hun‐", "b": [0.7486, 0.3979, 0.7857, 0.4175]}, {"w": "dreds", "b": [0.2714, 0.4153, 0.3137, 0.4349]}, {"w": "of", "b": [0.3243, 0.4153, 0.3396, 0.4349]}, {"w": "thousands", "b": [0.3503, 0.4153, 0.4289, 0.4349]}, {"w": "of", "b": [0.4395, 0.4153, 0.4549, 0.4349]}, {"w": "features", "b": [0.4655, 0.4153, 0.5253, 0.4349]}, {"w": "is", "b": [0.5359, 0.4153, 0.548, 0.4349]}, {"w": "much", "b": [0.5586, 0.4153, 0.6022, 0.4349]}, {"w": "faster", "b": [0.6128, 0.4153, 0.6548, 0.4349]}, {"w": "using", "b": [0.6654, 0.4153, 0.7069, 0.4349]}, {"w": "Gradient", "b": [0.7175, 0.4153, 0.7857, 0.4349]}, {"w": "Descent", "b": [0.2714, 0.4327, 0.3325, 0.4523]}, {"w": "than", "b": [0.3368, 0.4327, 0.3716, 0.4523]}, {"w": "using", "b": [0.3759, 0.4327, 0.4175, 0.4523]}, {"w": "the", "b": [0.4218, 0.4327, 0.4459, 0.4523]}, {"w": "Normal", "b": [0.4502, 0.4327, 0.5094, 0.4523]}, {"w": "Equation", "b": [0.5138, 0.4327, 0.5835, 0.4523]}, {"w": "or", "b": [0.5878, 0.4327, 0.6046, 0.4523]}, {"w": "SVD", "b": [0.6089, 0.4327, 0.6453, 0.4523]}, {"w": "decomposition.", "b": [0.6496, 0.4327, 0.768, 0.4523]}]}, {"id": "b_12", "type": "paragraph", "text": "Once you have the gradient vector, which points uphill, just go in the opposite direc‐ tion to go downhill. This means subtracting ∇θMSE(θ) from θ. This is where the learning rate η comes into play:6 multiply the gradient vector by η to determine the size of the downhill step (Equation 4-7).", "words": [{"w": "Once", "b": [0.1429, 0.4726, 0.1875, 0.494]}, {"w": "you", "b": [0.193, 0.4726, 0.2242, 0.494]}, {"w": "have", "b": [0.2297, 0.4726, 0.2681, 0.494]}, {"w": "the", "b": [0.2736, 0.4726, 0.2999, 0.494]}, {"w": "gradient", "b": [0.3054, 0.4726, 0.3748, 0.494]}, {"w": "vector,", "b": [0.3803, 0.4726, 0.4358, 0.494]}, {"w": "which", "b": [0.4412, 0.4726, 0.4922, 0.494]}, {"w": "points", "b": [0.4977, 0.4726, 0.5498, 0.494]}, {"w": "uphill,", "b": [0.5553, 0.4726, 0.6092, 0.494]}, {"w": "just", "b": [0.6147, 0.4726, 0.6451, 0.494]}, {"w": "go", "b": [0.6506, 0.4726, 0.671, 0.494]}, {"w": "in", "b": [0.6765, 0.4726, 0.6934, 0.494]}, {"w": "the", "b": [0.6989, 0.4726, 0.7253, 0.494]}, {"w": "opposite", "b": [0.7307, 0.4726, 0.8023, 0.494]}, {"w": "direc‐", "b": [0.8078, 0.4726, 0.8571, 0.494]}, {"w": "tion", "b": [0.1429, 0.4916, 0.1768, 0.513]}, {"w": "to", "b": [0.1843, 0.4916, 0.2013, 0.513]}, {"w": "go", "b": [0.2087, 0.4916, 0.2291, 0.513]}, {"w": "downhill.", "b": [0.2366, 0.4916, 0.3159, 0.513]}, {"w": "This", "b": [0.3233, 0.4916, 0.3605, 0.513]}, {"w": "means", "b": [0.368, 0.4916, 0.4221, 0.513]}, {"w": "subtracting", "b": [0.4296, 0.4916, 0.524, 0.513]}, {"w": "∇θMSE(θ)", "b": [0.5315, 0.4911, 0.6203, 0.5139]}, {"w": "from", "b": [0.6278, 0.4916, 0.6694, 0.513]}, {"w": "θ.", "b": [0.6768, 0.4911, 0.6922, 0.513]}, {"w": "This", "b": [0.6997, 0.4916, 0.7369, 0.513]}, {"w": "is", "b": [0.7443, 0.4916, 0.7576, 0.513]}, {"w": "where", "b": [0.765, 0.4916, 0.8159, 0.513]}, {"w": "the", "b": [0.8233, 0.4916, 0.8497, 0.513]}, {"w": "learning", "b": [0.1429, 0.5107, 0.212, 0.5321]}, {"w": "rate", "b": [0.2186, 0.5107, 0.2503, 0.5321]}, {"w": "η", "b": [0.2569, 0.5105, 0.2675, 0.5321]}, {"w": "comes", "b": [0.2741, 0.5107, 0.3271, 0.5321]}, {"w": "into", "b": [0.3337, 0.5107, 0.3673, 0.5321]}, {"w": "play:6", "b": [0.3739, 0.5107, 0.4195, 0.5321]}, {"w": "multiply", "b": [0.4261, 0.5107, 0.4968, 0.5321]}, {"w": "the", "b": [0.5034, 0.5107, 0.5297, 0.5321]}, {"w": "gradient", "b": [0.5363, 0.5107, 0.6057, 0.5321]}, {"w": "vector", "b": [0.6123, 0.5107, 0.6644, 0.5321]}, {"w": "by", "b": [0.671, 0.5107, 0.6911, 0.5321]}, {"w": "η", "b": [0.6977, 0.5105, 0.7083, 0.5321]}, {"w": "to", "b": [0.7149, 0.5107, 0.7319, 0.5321]}, {"w": "determine", "b": [0.7385, 0.5107, 0.8242, 0.5321]}, {"w": "the", "b": [0.8308, 0.5107, 0.8571, 0.5321]}, {"w": "size", "b": [0.1428, 0.5297, 0.1737, 0.5511]}, {"w": "of", "b": [0.1784, 0.5297, 0.1952, 0.5511]}, {"w": "the", "b": [0.1999, 0.5297, 0.2263, 0.5511]}, {"w": "downhill", "b": [0.231, 0.5297, 0.3055, 0.5511]}, {"w": "step", "b": [0.3103, 0.5297, 0.344, 0.5511]}, {"w": "(Equation", "b": [0.3488, 0.5297, 0.4322, 0.5511]}, {"w": "4-7).", "b": [0.437, 0.5297, 0.4763, 0.5511]}]}, {"id": "b_13", "type": "equation", "text": "Equation 4-7. Gradient Descent step", "words": [{"w": "Equation", "b": [0.1726, 0.5693, 0.2473, 0.5909]}, {"w": "4-7.", "b": [0.2521, 0.5693, 0.2838, 0.5909]}, {"w": "Gradient", "b": [0.2886, 0.5693, 0.361, 0.5909]}, {"w": "Descent", "b": [0.3658, 0.5693, 0.4291, 0.5909]}, {"w": "step", "b": [0.4339, 0.5693, 0.4653, 0.5909]}]}, {"id": "b_14", "type": "equation", "text": "θ next step = θ −η∇θ MSE θ", "words": [{"w": "θ", "b": [0.1726, 0.6012, 0.1827, 0.6222]}, {"w": "next", "b": [0.1882, 0.598, 0.216, 0.6143]}, {"w": "step", "b": [0.2196, 0.598, 0.2453, 0.6143]}, {"w": "=", "b": [0.2563, 0.6018, 0.2678, 0.6222]}, {"w": "θ", "b": [0.2733, 0.6012, 0.2834, 0.6222]}, {"w": "−η∇θ", "b": [0.2878, 0.6016, 0.3405, 0.6256]}, {"w": "MSE", "b": [0.3436, 0.6018, 0.382, 0.6222]}, {"w": "θ", "b": [0.3889, 0.6012, 0.399, 0.6222]}]}, {"id": "b_15", "type": "paragraph", "text": "Let’s look at a quick implementation of this algorithm:", "words": [{"w": "Let’s", "b": [0.1429, 0.6451, 0.179, 0.6665]}, {"w": "look", "b": [0.1838, 0.6451, 0.2206, 0.6665]}, {"w": "at", "b": [0.2253, 0.6451, 0.2404, 0.6665]}, {"w": "a", "b": [0.2452, 0.6451, 0.2543, 0.6665]}, {"w": "quick", "b": [0.259, 0.6451, 0.3055, 0.6665]}, {"w": "implementation", "b": [0.3102, 0.6451, 0.4435, 0.6665]}, {"w": "of", "b": [0.4482, 0.6451, 0.465, 0.6665]}, {"w": "this", "b": [0.4697, 0.6451, 0.5004, 0.6665]}, {"w": "algorithm:", "b": [0.5052, 0.6451, 0.5926, 0.6665]}]}, {"id": "b_16", "type": "equation", "text": "eta = 0.1 # learning rate n_iterations = 1000 m = 100", "words": [{"w": "eta", "b": [0.1766, 0.677, 0.2019, 0.6899]}, {"w": "=", "b": [0.2103, 0.677, 0.2188, 0.6899]}, {"w": "0.1", "b": [0.2272, 0.677, 0.2525, 0.6899]}, {"w": "#", "b": [0.2694, 0.677, 0.2778, 0.6899]}, {"w": "learning", "b": [0.2862, 0.677, 0.3537, 0.6899]}, {"w": "rate", "b": [0.3621, 0.677, 0.3958, 0.6899]}, {"w": "n_iterations", "b": [0.1766, 0.6924, 0.2778, 0.7053]}, {"w": "=", "b": [0.2862, 0.6924, 0.2946, 0.7053]}, {"w": "1000", "b": [0.3031, 0.6924, 0.3368, 0.7053]}, {"w": "m", "b": [0.1766, 0.7079, 0.185, 0.7207]}, {"w": "=", "b": [0.1935, 0.7079, 0.2019, 0.7207]}, {"w": "100", "b": [0.2103, 0.7079, 0.2356, 0.7207]}]}, {"id": "b_17", "type": "equation", "text": "theta = np.random.randn(2,1) # random initialization", "words": [{"w": "theta", "b": [0.1766, 0.7387, 0.2188, 0.7516]}, {"w": "=", "b": [0.2272, 0.7387, 0.2356, 0.7516]}, {"w": "np.random.randn(2,1)", "b": [0.2441, 0.7387, 0.4127, 0.7516]}, {"w": "#", "b": [0.4296, 0.7387, 0.438, 0.7516]}, {"w": "random", "b": [0.4464, 0.7387, 0.497, 0.7516]}, {"w": "initialization", "b": [0.5055, 0.7387, 0.6235, 0.7516]}]}, {"id": "b_18", "type": "paragraph", "text": "for iteration in range(n_iterations): gradients = 2/m * X_b.T.dot(X_b.dot(theta) - y) theta = theta - eta * gradients", "words": [{"w": "for", "b": [0.1766, 0.7695, 0.2019, 0.7824]}, {"w": "iteration", "b": [0.2103, 0.7695, 0.2862, 0.7824]}, {"w": "in", "b": [0.2946, 0.7695, 0.3115, 0.7824]}, {"w": "range(n_iterations):", "b": [0.3199, 0.7695, 0.4886, 0.7824]}, {"w": "gradients", "b": [0.2103, 0.785, 0.2862, 0.7978]}, {"w": "=", "b": [0.2946, 0.785, 0.3031, 0.7978]}, {"w": "2/m", "b": [0.3115, 0.785, 0.3368, 0.7978]}, {"w": "*", "b": [0.3452, 0.785, 0.3537, 0.7978]}, {"w": "X_b.T.dot(X_b.dot(theta)", "b": [0.3621, 0.785, 0.5645, 0.7978]}, {"w": "-", "b": [0.5729, 0.785, 0.5814, 0.7978]}, {"w": "y)", "b": [0.5898, 0.785, 0.6067, 0.7978]}, {"w": "theta", "b": [0.2103, 0.8004, 0.2525, 0.8132]}, {"w": "=", "b": [0.2609, 0.8004, 0.2694, 0.8132]}, {"w": "theta", "b": [0.2778, 0.8004, 0.3199, 0.8132]}, {"w": "-", "b": [0.3284, 0.8004, 0.3368, 0.8132]}, {"w": "eta", "b": [0.3452, 0.8004, 0.3705, 0.8132]}, {"w": "*", "b": [0.379, 0.8004, 0.3874, 0.8132]}, {"w": "gradients", "b": [0.3958, 0.8004, 0.4717, 0.8132]}]}, {"id": "b_19", "type": "paragraph", "text": "124 | Chapter 4: Training Models", "words": [{"w": "124", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 151, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "That wasn’t too hard! Let’s look at the resulting theta:", "words": [{"w": "That", "b": [0.1429, 0.08, 0.1819, 0.1014]}, {"w": "wasn’t", "b": [0.1867, 0.08, 0.2377, 0.1014]}, {"w": "too", "b": [0.2424, 0.08, 0.27, 0.1014]}, {"w": "hard!", "b": [0.2748, 0.08, 0.3195, 0.1014]}, {"w": "Let’s", "b": [0.3243, 0.08, 0.3604, 0.1014]}, {"w": "look", "b": [0.3651, 0.08, 0.402, 0.1014]}, {"w": "at", "b": [0.4067, 0.08, 0.4218, 0.1014]}, {"w": "the", "b": [0.4266, 0.08, 0.4529, 0.1014]}, {"w": "resulting", "b": [0.4576, 0.08, 0.5313, 0.1014]}, {"w": "theta:", "b": [0.536, 0.08, 0.5902, 0.1014]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> theta array([[4.21509616], [2.77011339]])", "words": [{"w": ">>>", "b": [0.1766, 0.1119, 0.2019, 0.1248]}, {"w": "theta", "b": [0.2103, 0.1119, 0.2525, 0.1248]}, {"w": "array([[4.21509616],", "b": [0.1766, 0.1274, 0.3452, 0.1402]}, {"w": "[2.77011339]])", "b": [0.2356, 0.1428, 0.3537, 0.1556]}]}, {"id": "b_2", "type": "paragraph", "text": "Hey, that’s exactly what the Normal Equation found! Gradient Descent worked per‐ fectly. But what if you had used a different learning rate eta? Figure 4-8 shows the first 10 steps of Gradient Descent using three different learning rates (the dashed line represents the starting point).", "words": [{"w": "Hey,", "b": [0.1429, 0.1634, 0.1799, 0.1848]}, {"w": "that’s", "b": [0.1867, 0.1634, 0.229, 0.1848]}, {"w": "exactly", "b": [0.2357, 0.1634, 0.2936, 0.1848]}, {"w": "what", "b": [0.3003, 0.1634, 0.3408, 0.1848]}, {"w": "the", "b": [0.3475, 0.1634, 0.3739, 0.1848]}, {"w": "Normal", "b": [0.3806, 0.1634, 0.4454, 0.1848]}, {"w": "Equation", "b": [0.4521, 0.1634, 0.5284, 0.1848]}, {"w": "found!", "b": [0.5351, 0.1634, 0.5911, 0.1848]}, {"w": "Gradient", "b": [0.5978, 0.1634, 0.6724, 0.1848]}, {"w": "Descent", "b": [0.6791, 0.1634, 0.746, 0.1848]}, {"w": "worked", "b": [0.7527, 0.1634, 0.8155, 0.1848]}, {"w": "per‐", "b": [0.8222, 0.1634, 0.8571, 0.1848]}, {"w": "fectly.", "b": [0.1428, 0.1833, 0.1911, 0.2048]}, {"w": "But", "b": [0.1981, 0.1833, 0.2277, 0.2048]}, {"w": "what", "b": [0.2347, 0.1833, 0.2752, 0.2048]}, {"w": "if", "b": [0.2822, 0.1833, 0.294, 0.2048]}, {"w": "you", "b": [0.3009, 0.1833, 0.3322, 0.2048]}, {"w": "had", "b": [0.3392, 0.1833, 0.3704, 0.2048]}, {"w": "used", "b": [0.3774, 0.1833, 0.416, 0.2048]}, {"w": "a", "b": [0.423, 0.1833, 0.4321, 0.2048]}, {"w": "different", "b": [0.4391, 0.1833, 0.5108, 0.2048]}, {"w": "learning", "b": [0.5178, 0.1833, 0.5869, 0.2048]}, {"w": "rate", "b": [0.5939, 0.1833, 0.6256, 0.2048]}, {"w": "eta?", "b": [0.6326, 0.1833, 0.6701, 0.2048]}, {"w": "Figure", "b": [0.6771, 0.1833, 0.7311, 0.2048]}, {"w": "4-8", "b": [0.7381, 0.1833, 0.7655, 0.2048]}, {"w": "shows", "b": [0.7725, 0.1833, 0.8238, 0.2048]}, {"w": "the", "b": [0.8308, 0.1833, 0.8571, 0.2048]}, {"w": "first", "b": [0.1429, 0.2024, 0.1763, 0.2238]}, {"w": "10", "b": [0.1817, 0.2024, 0.2017, 0.2238]}, {"w": "steps", "b": [0.207, 0.2024, 0.2484, 0.2238]}, {"w": "of", "b": [0.2537, 0.2024, 0.2705, 0.2238]}, {"w": "Gradient", "b": [0.2759, 0.2024, 0.3504, 0.2238]}, {"w": "Descent", "b": [0.3558, 0.2024, 0.4226, 0.2238]}, {"w": "using", "b": [0.4279, 0.2024, 0.4734, 0.2238]}, {"w": "three", "b": [0.4787, 0.2024, 0.5216, 0.2238]}, {"w": "different", "b": [0.5269, 0.2024, 0.5986, 0.2238]}, {"w": "learning", "b": [0.604, 0.2024, 0.6731, 0.2238]}, {"w": "rates", "b": [0.6784, 0.2024, 0.7178, 0.2238]}, {"w": "(the", "b": [0.7231, 0.2024, 0.7566, 0.2238]}, {"w": "dashed", "b": [0.7619, 0.2024, 0.8207, 0.2238]}, {"w": "line", "b": [0.826, 0.2024, 0.8572, 0.2238]}, {"w": "represents", "b": [0.1429, 0.2214, 0.2284, 0.2429]}, {"w": "the", "b": [0.2332, 0.2214, 0.2595, 0.2429]}, {"w": "starting", "b": [0.2642, 0.2214, 0.3282, 0.2429]}, {"w": "point).", "b": [0.3329, 0.2214, 0.3894, 0.2429]}]}, {"id": "b_3", "type": "equation", "text": "Figure 4-8. Gradient Descent with various learning rates", "words": [{"w": "Figure", "b": [0.1429, 0.4679, 0.1943, 0.4895]}, {"w": "4-8.", "b": [0.1991, 0.4679, 0.2308, 0.4895]}, {"w": "Gradient", "b": [0.2356, 0.4679, 0.308, 0.4895]}, {"w": "Descent", "b": [0.3128, 0.4679, 0.3761, 0.4895]}, {"w": "with", "b": [0.3809, 0.4679, 0.4174, 0.4895]}, {"w": "various", "b": [0.4221, 0.4679, 0.4825, 0.4895]}, {"w": "learning", "b": [0.4872, 0.4679, 0.5539, 0.4895]}, {"w": "rates", "b": [0.5587, 0.4679, 0.5971, 0.4895]}]}, {"id": "b_4", "type": "paragraph", "text": "On the left, the learning rate is too low: the algorithm will eventually reach the solu‐ tion, but it will take a long time. In the middle, the learning rate looks pretty good: in just a few iterations, it has already converged to the solution. On the right, the learn‐ ing rate is too high: the algorithm diverges, jumping all over the place and actually getting further and further away from the solution at every step.", "words": [{"w": "On", "b": [0.1429, 0.5053, 0.1698, 0.5267]}, {"w": "the", "b": [0.1757, 0.5053, 0.202, 0.5267]}, {"w": "left,", "b": [0.2078, 0.5053, 0.2392, 0.5267]}, {"w": "the", "b": [0.2451, 0.5053, 0.2714, 0.5267]}, {"w": "learning", "b": [0.2772, 0.5053, 0.3464, 0.5267]}, {"w": "rate", "b": [0.3522, 0.5053, 0.3839, 0.5267]}, {"w": "is", "b": [0.3897, 0.5053, 0.403, 0.5267]}, {"w": "too", "b": [0.4088, 0.5053, 0.4364, 0.5267]}, {"w": "low:", "b": [0.4423, 0.5053, 0.4778, 0.5267]}, {"w": "the", "b": [0.4837, 0.5053, 0.51, 0.5267]}, {"w": "algorithm", "b": [0.5158, 0.5053, 0.5985, 0.5267]}, {"w": "will", "b": [0.6043, 0.5053, 0.6347, 0.5267]}, {"w": "eventually", "b": [0.6406, 0.5053, 0.7256, 0.5267]}, {"w": "reach", "b": [0.7314, 0.5053, 0.7771, 0.5267]}, {"w": "the", "b": [0.7829, 0.5053, 0.8093, 0.5267]}, {"w": "solu‐", "b": [0.8151, 0.5053, 0.8571, 0.5267]}, {"w": "tion,", "b": [0.1429, 0.5243, 0.1816, 0.5457]}, {"w": "but", "b": [0.1868, 0.5243, 0.2148, 0.5457]}, {"w": "it", "b": [0.2199, 0.5243, 0.2319, 0.5457]}, {"w": "will", "b": [0.2371, 0.5243, 0.2675, 0.5457]}, {"w": "take", "b": [0.2727, 0.5243, 0.3073, 0.5457]}, {"w": "a", "b": [0.3125, 0.5243, 0.3217, 0.5457]}, {"w": "long", "b": [0.3269, 0.5243, 0.3639, 0.5457]}, {"w": "time.", "b": [0.3691, 0.5243, 0.4117, 0.5457]}, {"w": "In", "b": [0.4169, 0.5243, 0.4354, 0.5457]}, {"w": "the", "b": [0.4406, 0.5243, 0.4669, 0.5457]}, {"w": "middle,", "b": [0.4721, 0.5243, 0.5356, 0.5457]}, {"w": "the", "b": [0.5408, 0.5243, 0.5672, 0.5457]}, {"w": "learning", "b": [0.5724, 0.5243, 0.6415, 0.5457]}, {"w": "rate", "b": [0.6467, 0.5243, 0.6784, 0.5457]}, {"w": "looks", "b": [0.6836, 0.5243, 0.7281, 0.5457]}, {"w": "pretty", "b": [0.7333, 0.5243, 0.783, 0.5457]}, {"w": "good:", "b": [0.7882, 0.5243, 0.835, 0.5457]}, {"w": "in", "b": [0.8402, 0.5243, 0.8571, 0.5457]}, {"w": "just", "b": [0.1429, 0.5434, 0.1733, 0.5648]}, {"w": "a", "b": [0.1789, 0.5434, 0.188, 0.5648]}, {"w": "few", "b": [0.1936, 0.5434, 0.2229, 0.5648]}, {"w": "iterations,", "b": [0.2285, 0.5434, 0.3121, 0.5648]}, {"w": "it", "b": [0.3178, 0.5434, 0.3297, 0.5648]}, {"w": "has", "b": [0.3353, 0.5434, 0.3632, 0.5648]}, {"w": "already", "b": [0.3688, 0.5434, 0.4295, 0.5648]}, {"w": "converged", "b": [0.4351, 0.5434, 0.5213, 0.5648]}, {"w": "to", "b": [0.5269, 0.5434, 0.5439, 0.5648]}, {"w": "the", "b": [0.5495, 0.5434, 0.5759, 0.5648]}, {"w": "solution.", "b": [0.5815, 0.5434, 0.6548, 0.5648]}, {"w": "On", "b": [0.6604, 0.5434, 0.6873, 0.5648]}, {"w": "the", "b": [0.693, 0.5434, 0.7193, 0.5648]}, {"w": "right,", "b": [0.7249, 0.5434, 0.7698, 0.5648]}, {"w": "the", "b": [0.7754, 0.5434, 0.8017, 0.5648]}, {"w": "learn‐", "b": [0.8073, 0.5434, 0.8572, 0.5648]}, {"w": "ing", "b": [0.1429, 0.5624, 0.1696, 0.5838]}, {"w": "rate", "b": [0.1765, 0.5624, 0.2082, 0.5838]}, {"w": "is", "b": [0.2152, 0.5624, 0.2284, 0.5838]}, {"w": "too", "b": [0.2353, 0.5624, 0.2629, 0.5838]}, {"w": "high:", "b": [0.2699, 0.5624, 0.3122, 0.5838]}, {"w": "the", "b": [0.3191, 0.5624, 0.3455, 0.5838]}, {"w": "algorithm", "b": [0.3524, 0.5624, 0.4351, 0.5838]}, {"w": "diverges,", "b": [0.442, 0.5624, 0.5158, 0.5838]}, {"w": "jumping", "b": [0.5228, 0.5624, 0.5935, 0.5838]}, {"w": "all", "b": [0.6004, 0.5624, 0.6201, 0.5838]}, {"w": "over", "b": [0.627, 0.5624, 0.6639, 0.5838]}, {"w": "the", "b": [0.6708, 0.5624, 0.6972, 0.5838]}, {"w": "place", "b": [0.7041, 0.5624, 0.7471, 0.5838]}, {"w": "and", "b": [0.754, 0.5624, 0.7856, 0.5838]}, {"w": "actually", "b": [0.7925, 0.5624, 0.8571, 0.5838]}, {"w": "getting", "b": [0.1429, 0.5815, 0.2009, 0.6029]}, {"w": "further", "b": [0.2056, 0.5815, 0.2646, 0.6029]}, {"w": "and", "b": [0.2694, 0.5815, 0.3009, 0.6029]}, {"w": "further", "b": [0.3056, 0.5815, 0.3647, 0.6029]}, {"w": "away", "b": [0.3694, 0.5815, 0.4108, 0.6029]}, {"w": "from", "b": [0.4155, 0.5815, 0.4571, 0.6029]}, {"w": "the", "b": [0.4618, 0.5815, 0.4881, 0.6029]}, {"w": "solution", "b": [0.4929, 0.5815, 0.5614, 0.6029]}, {"w": "at", "b": [0.5662, 0.5815, 0.5813, 0.6029]}, {"w": "every", "b": [0.586, 0.5815, 0.6312, 0.6029]}, {"w": "step.", "b": [0.636, 0.5815, 0.6739, 0.6029]}]}, {"id": "b_5", "type": "paragraph", "text": "To find a good learning rate, you can use grid search (see Chapter 2). However, you may want to limit the number of iterations so that grid search can eliminate models that take too long to converge.", "words": [{"w": "To", "b": [0.1429, 0.6096, 0.1643, 0.631]}, {"w": "find", "b": [0.1706, 0.6096, 0.2047, 0.631]}, {"w": "a", "b": [0.211, 0.6096, 0.2201, 0.631]}, {"w": "good", "b": [0.2264, 0.6096, 0.2684, 0.631]}, {"w": "learning", "b": [0.2747, 0.6096, 0.3438, 0.631]}, {"w": "rate,", "b": [0.3501, 0.6096, 0.3866, 0.631]}, {"w": "you", "b": [0.3928, 0.6096, 0.4241, 0.631]}, {"w": "can", "b": [0.4304, 0.6096, 0.4597, 0.631]}, {"w": "use", "b": [0.466, 0.6096, 0.4936, 0.631]}, {"w": "grid", "b": [0.4999, 0.6096, 0.5339, 0.631]}, {"w": "search", "b": [0.5402, 0.6096, 0.5935, 0.631]}, {"w": "(see", "b": [0.5998, 0.6096, 0.6324, 0.631]}, {"w": "Chapter", "b": [0.6386, 0.6096, 0.7062, 0.631]}, {"w": "2).", "b": [0.7125, 0.6096, 0.7345, 0.631]}, {"w": "However,", "b": [0.7408, 0.6096, 0.8196, 0.631]}, {"w": "you", "b": [0.8259, 0.6096, 0.8571, 0.631]}, {"w": "may", "b": [0.1428, 0.6286, 0.1782, 0.65]}, {"w": "want", "b": [0.1845, 0.6286, 0.2252, 0.65]}, {"w": "to", "b": [0.2315, 0.6286, 0.2485, 0.65]}, {"w": "limit", "b": [0.2547, 0.6286, 0.2945, 0.65]}, {"w": "the", "b": [0.3008, 0.6286, 0.3271, 0.65]}, {"w": "number", "b": [0.3333, 0.6286, 0.3996, 0.65]}, {"w": "of", "b": [0.4059, 0.6286, 0.4227, 0.65]}, {"w": "iterations", "b": [0.4289, 0.6286, 0.5078, 0.65]}, {"w": "so", "b": [0.514, 0.6286, 0.5323, 0.65]}, {"w": "that", "b": [0.5385, 0.6286, 0.5711, 0.65]}, {"w": "grid", "b": [0.5773, 0.6286, 0.6114, 0.65]}, {"w": "search", "b": [0.6176, 0.6286, 0.6709, 0.65]}, {"w": "can", "b": [0.6771, 0.6286, 0.7065, 0.65]}, {"w": "eliminate", "b": [0.7127, 0.6286, 0.7904, 0.65]}, {"w": "models", "b": [0.7967, 0.6286, 0.8571, 0.65]}, {"w": "that", "b": [0.1429, 0.6477, 0.1754, 0.6691]}, {"w": "take", "b": [0.1802, 0.6477, 0.2149, 0.6691]}, {"w": "too", "b": [0.2196, 0.6477, 0.2472, 0.6691]}, {"w": "long", "b": [0.2519, 0.6477, 0.289, 0.6691]}, {"w": "to", "b": [0.2937, 0.6477, 0.3107, 0.6691]}, {"w": "converge.", "b": [0.3154, 0.6477, 0.3953, 0.6691]}]}, {"id": "b_6", "type": "paragraph", "text": "You may wonder how to set the number of iterations. If it is too low, you will still be far away from the optimal solution when the algorithm stops, but if it is too high, you will waste time while the model parameters do not change anymore. A simple solu‐ tion is to set a very large number of iterations but to interrupt the algorithm when the gradient vector becomes tiny—that is, when its norm becomes smaller than a tiny number ϵ (called the tolerance)—because this happens when Gradient Descent has (almost) reached the minimum.", "words": [{"w": "You", "b": [0.1429, 0.6758, 0.1752, 0.6972]}, {"w": "may", "b": [0.1809, 0.6758, 0.2163, 0.6972]}, {"w": "wonder", "b": [0.2221, 0.6758, 0.2859, 0.6972]}, {"w": "how", "b": [0.2917, 0.6758, 0.3277, 0.6972]}, {"w": "to", "b": [0.3334, 0.6758, 0.3504, 0.6972]}, {"w": "set", "b": [0.3561, 0.6758, 0.379, 0.6972]}, {"w": "the", "b": [0.3847, 0.6758, 0.411, 0.6972]}, {"w": "number", "b": [0.4168, 0.6758, 0.4831, 0.6972]}, {"w": "of", "b": [0.4888, 0.6758, 0.5056, 0.6972]}, {"w": "iterations.", "b": [0.5113, 0.6758, 0.5949, 0.6972]}, {"w": "If", "b": [0.6007, 0.6758, 0.6139, 0.6972]}, {"w": "it", "b": [0.6197, 0.6758, 0.6316, 0.6972]}, {"w": "is", "b": [0.6373, 0.6758, 0.6506, 0.6972]}, {"w": "too", "b": [0.6563, 0.6758, 0.6839, 0.6972]}, {"w": "low,", "b": [0.6896, 0.6758, 0.723, 0.6972]}, {"w": "you", "b": [0.7288, 0.6758, 0.76, 0.6972]}, {"w": "will", "b": [0.7657, 0.6758, 0.7961, 0.6972]}, {"w": "still", "b": [0.8019, 0.6758, 0.832, 0.6972]}, {"w": "be", "b": [0.8377, 0.6758, 0.8571, 0.6972]}, {"w": "far", "b": [0.1429, 0.6948, 0.1659, 0.7162]}, {"w": "away", "b": [0.1709, 0.6948, 0.2123, 0.7162]}, {"w": "from", "b": [0.2172, 0.6948, 0.2588, 0.7162]}, {"w": "the", "b": [0.2638, 0.6948, 0.2901, 0.7162]}, {"w": "optimal", "b": [0.2951, 0.6948, 0.3601, 0.7162]}, {"w": "solution", "b": [0.3651, 0.6948, 0.4336, 0.7162]}, {"w": "when", "b": [0.4386, 0.6948, 0.4843, 0.7162]}, {"w": "the", "b": [0.4893, 0.6948, 0.5156, 0.7162]}, {"w": "algorithm", "b": [0.5206, 0.6948, 0.6032, 0.7162]}, {"w": "stops,", "b": [0.6082, 0.6948, 0.6561, 0.7162]}, {"w": "but", "b": [0.6611, 0.6948, 0.6891, 0.7162]}, {"w": "if", "b": [0.6941, 0.6948, 0.7059, 0.7162]}, {"w": "it", "b": [0.7108, 0.6948, 0.7228, 0.7162]}, {"w": "is", "b": [0.7278, 0.6948, 0.741, 0.7162]}, {"w": "too", "b": [0.746, 0.6948, 0.7736, 0.7162]}, {"w": "high,", "b": [0.7786, 0.6948, 0.8209, 0.7162]}, {"w": "you", "b": [0.8259, 0.6948, 0.8571, 0.7162]}, {"w": "will", "b": [0.1429, 0.7139, 0.1732, 0.7353]}, {"w": "waste", "b": [0.1796, 0.7139, 0.2259, 0.7353]}, {"w": "time", "b": [0.2323, 0.7139, 0.2701, 0.7353]}, {"w": "while", "b": [0.2765, 0.7139, 0.3216, 0.7353]}, {"w": "the", "b": [0.328, 0.7139, 0.3543, 0.7353]}, {"w": "model", "b": [0.3607, 0.7139, 0.4135, 0.7353]}, {"w": "parameters", "b": [0.4199, 0.7139, 0.5134, 0.7353]}, {"w": "do", "b": [0.5197, 0.7139, 0.5414, 0.7353]}, {"w": "not", "b": [0.5478, 0.7139, 0.5761, 0.7353]}, {"w": "change", "b": [0.5825, 0.7139, 0.6416, 0.7353]}, {"w": "anymore.", "b": [0.648, 0.7139, 0.7266, 0.7353]}, {"w": "A", "b": [0.733, 0.7139, 0.7474, 0.7353]}, {"w": "simple", "b": [0.7538, 0.7139, 0.8087, 0.7353]}, {"w": "solu‐", "b": [0.8151, 0.7139, 0.8571, 0.7353]}, {"w": "tion", "b": [0.1429, 0.7329, 0.1768, 0.7543]}, {"w": "is", "b": [0.1817, 0.7329, 0.1949, 0.7543]}, {"w": "to", "b": [0.1997, 0.7329, 0.2167, 0.7543]}, {"w": "set", "b": [0.2216, 0.7329, 0.2444, 0.7543]}, {"w": "a", "b": [0.2493, 0.7329, 0.2584, 0.7543]}, {"w": "very", "b": [0.2633, 0.7329, 0.2996, 0.7543]}, {"w": "large", "b": [0.3045, 0.7329, 0.3452, 0.7543]}, {"w": "number", "b": [0.3501, 0.7329, 0.4164, 0.7543]}, {"w": "of", "b": [0.4212, 0.7329, 0.438, 0.7543]}, {"w": "iterations", "b": [0.4429, 0.7329, 0.5217, 0.7543]}, {"w": "but", "b": [0.5266, 0.7329, 0.5546, 0.7543]}, {"w": "to", "b": [0.5594, 0.7329, 0.5764, 0.7543]}, {"w": "interrupt", "b": [0.5812, 0.7329, 0.6568, 0.7543]}, {"w": "the", "b": [0.6617, 0.7329, 0.688, 0.7543]}, {"w": "algorithm", "b": [0.6928, 0.7329, 0.7755, 0.7543]}, {"w": "when", "b": [0.7803, 0.7329, 0.826, 0.7543]}, {"w": "the", "b": [0.8308, 0.7329, 0.8572, 0.7543]}, {"w": "gradient", "b": [0.1429, 0.752, 0.2123, 0.7734]}, {"w": "vector", "b": [0.22, 0.752, 0.2721, 0.7734]}, {"w": "becomes", "b": [0.2798, 0.752, 0.3523, 0.7734]}, {"w": "tiny—that", "b": [0.36, 0.752, 0.4442, 0.7734]}, {"w": "is,", "b": [0.452, 0.752, 0.47, 0.7734]}, {"w": "when", "b": [0.4777, 0.752, 0.5234, 0.7734]}, {"w": "its", "b": [0.5312, 0.752, 0.5507, 0.7734]}, {"w": "norm", "b": [0.5585, 0.752, 0.6053, 0.7734]}, {"w": "becomes", "b": [0.6131, 0.752, 0.6855, 0.7734]}, {"w": "smaller", "b": [0.6933, 0.752, 0.7543, 0.7734]}, {"w": "than", "b": [0.762, 0.752, 0.8001, 0.7734]}, {"w": "a", "b": [0.8078, 0.752, 0.817, 0.7734]}, {"w": "tiny", "b": [0.8247, 0.752, 0.8571, 0.7734]}, {"w": "number", "b": [0.1429, 0.771, 0.2091, 0.7924]}, {"w": "ϵ", "b": [0.2169, 0.7743, 0.2315, 0.7901]}, {"w": "(called", "b": [0.2339, 0.771, 0.2895, 0.7924]}, {"w": "the", "b": [0.2972, 0.771, 0.3235, 0.7924]}, {"w": "tolerance)—because", "b": [0.3312, 0.7708, 0.4956, 0.7924]}, {"w": "this", "b": [0.5033, 0.771, 0.534, 0.7924]}, {"w": "happens", "b": [0.5417, 0.771, 0.6113, 0.7924]}, {"w": "when", "b": [0.619, 0.771, 0.6647, 0.7924]}, {"w": "Gradient", "b": [0.6724, 0.771, 0.747, 0.7924]}, {"w": "Descent", "b": [0.7547, 0.771, 0.8215, 0.7924]}, {"w": "has", "b": [0.8292, 0.771, 0.8571, 0.7924]}, {"w": "(almost)", "b": [0.1429, 0.7901, 0.2134, 0.8115]}, {"w": "reached", "b": [0.2181, 0.7901, 0.2836, 0.8115]}, {"w": "the", "b": [0.2884, 0.7901, 0.3147, 0.8115]}, {"w": "minimum.", "b": [0.3194, 0.7901, 0.4086, 0.8115]}]}, {"id": "b_7", "type": "paragraph", "text": "Gradient Descent | 125", "words": [{"w": "Gradient", "b": [0.6954, 0.9225, 0.7466, 0.9388]}, {"w": "Descent", "b": [0.7494, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "125", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 152, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "7 Out-of-core algorithms are discussed in Chapter 1.", "words": [{"w": "7", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "Out-of-core", "b": [0.1587, 0.8749, 0.2354, 0.8912]}, {"w": "algorithms", "b": [0.239, 0.8749, 0.3078, 0.8912]}, {"w": "are", "b": [0.3114, 0.8749, 0.331, 0.8912]}, {"w": "discussed", "b": [0.3346, 0.8749, 0.395, 0.8912]}, {"w": "in", "b": [0.3986, 0.8749, 0.4115, 0.8912]}, {"w": "Chapter", "b": [0.4151, 0.8749, 0.4666, 0.8912]}, {"w": "1.", "b": [0.4702, 0.8749, 0.4815, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Convergence Rate", "words": [{"w": "Convergence", "b": [0.4121, 0.0921, 0.538, 0.1192]}, {"w": "Rate", "b": [0.5427, 0.0921, 0.5879, 0.1192]}]}, {"id": "b_2", "type": "paragraph", "text": "When the cost function is convex and its slope does not change abruptly (as is the case for the MSE cost function), Batch Gradient Descent with a fixed learning rate will eventually converge to the optimal solution, but you may have to wait a while: it can take O(1/ϵ) iterations to reach the optimum within a range of ϵ depending on the shape of the cost function. If you divide the tolerance by 10 to have a more precise solution, then the algorithm may have to run about 10 times longer.", "words": [{"w": "When", "b": [0.1592, 0.1238, 0.2084, 0.1442]}, {"w": "the", "b": [0.2151, 0.1238, 0.2402, 0.1442]}, {"w": "cost", "b": [0.247, 0.1238, 0.2788, 0.1442]}, {"w": "function", "b": [0.2856, 0.1238, 0.3536, 0.1442]}, {"w": "is", "b": [0.3604, 0.1238, 0.373, 0.1442]}, {"w": "convex", "b": [0.3798, 0.1238, 0.4357, 0.1442]}, {"w": "and", "b": [0.4424, 0.1238, 0.4725, 0.1442]}, {"w": "its", "b": [0.4793, 0.1238, 0.4979, 0.1442]}, {"w": "slope", "b": [0.5047, 0.1238, 0.5459, 0.1442]}, {"w": "does", "b": [0.5527, 0.1238, 0.589, 0.1442]}, {"w": "not", "b": [0.5958, 0.1238, 0.6228, 0.1442]}, {"w": "change", "b": [0.6296, 0.1238, 0.6859, 0.1442]}, {"w": "abruptly", "b": [0.6926, 0.1238, 0.7599, 0.1442]}, {"w": "(as", "b": [0.7667, 0.1238, 0.7895, 0.1442]}, {"w": "is", "b": [0.7963, 0.1238, 0.8089, 0.1442]}, {"w": "the", "b": [0.8157, 0.1238, 0.8408, 0.1442]}, {"w": "case", "b": [0.1592, 0.1419, 0.192, 0.1623]}, {"w": "for", "b": [0.1991, 0.1419, 0.2224, 0.1623]}, {"w": "the", "b": [0.2294, 0.1419, 0.2545, 0.1623]}, {"w": "MSE", "b": [0.2615, 0.1419, 0.2999, 0.1623]}, {"w": "cost", "b": [0.3069, 0.1419, 0.3387, 0.1623]}, {"w": "function),", "b": [0.3458, 0.1419, 0.4252, 0.1623]}, {"w": "Batch", "b": [0.4322, 0.1419, 0.4772, 0.1623]}, {"w": "Gradient", "b": [0.4842, 0.1419, 0.5552, 0.1623]}, {"w": "Descent", "b": [0.5623, 0.1419, 0.6259, 0.1623]}, {"w": "with", "b": [0.6329, 0.1419, 0.6685, 0.1623]}, {"w": "a", "b": [0.6755, 0.1419, 0.6842, 0.1623]}, {"w": "fixed", "b": [0.6912, 0.1419, 0.7307, 0.1623]}, {"w": "learning", "b": [0.7377, 0.1419, 0.8036, 0.1623]}, {"w": "rate", "b": [0.8106, 0.1419, 0.8408, 0.1623]}, {"w": "will", "b": [0.1592, 0.1601, 0.1882, 0.1805]}, {"w": "eventually", "b": [0.1937, 0.1601, 0.2747, 0.1805]}, {"w": "converge", "b": [0.2802, 0.1601, 0.3518, 0.1805]}, {"w": "to", "b": [0.3573, 0.1601, 0.3735, 0.1805]}, {"w": "the", "b": [0.379, 0.1601, 0.4041, 0.1805]}, {"w": "optimal", "b": [0.4097, 0.1601, 0.4715, 0.1805]}, {"w": "solution,", "b": [0.4771, 0.1601, 0.5469, 0.1805]}, {"w": "but", "b": [0.5524, 0.1601, 0.5791, 0.1805]}, {"w": "you", "b": [0.5846, 0.1601, 0.6144, 0.1805]}, {"w": "may", "b": [0.6199, 0.1601, 0.6536, 0.1805]}, {"w": "have", "b": [0.6591, 0.1601, 0.6957, 0.1805]}, {"w": "to", "b": [0.7012, 0.1601, 0.7174, 0.1805]}, {"w": "wait", "b": [0.7229, 0.1601, 0.7566, 0.1805]}, {"w": "a", "b": [0.7621, 0.1601, 0.7709, 0.1805]}, {"w": "while:", "b": [0.7764, 0.1601, 0.8239, 0.1805]}, {"w": "it", "b": [0.8294, 0.1601, 0.8408, 0.1805]}, {"w": "can", "b": [0.1592, 0.1782, 0.1872, 0.1986]}, {"w": "take", "b": [0.1917, 0.1782, 0.2247, 0.1986]}, {"w": "O(1/ϵ)", "b": [0.2292, 0.1782, 0.2834, 0.1986]}, {"w": "iterations", "b": [0.2882, 0.1782, 0.3633, 0.1986]}, {"w": "to", "b": [0.3681, 0.1782, 0.3843, 0.1986]}, {"w": "reach", "b": [0.3891, 0.1782, 0.4326, 0.1986]}, {"w": "the", "b": [0.4374, 0.1782, 0.4625, 0.1986]}, {"w": "optimum", "b": [0.4673, 0.1782, 0.5418, 0.1986]}, {"w": "within", "b": [0.5466, 0.1782, 0.5983, 0.1986]}, {"w": "a", "b": [0.6031, 0.1782, 0.6118, 0.1986]}, {"w": "range", "b": [0.6166, 0.1782, 0.6613, 0.1986]}, {"w": "of", "b": [0.6661, 0.1782, 0.6821, 0.1986]}, {"w": "ϵ", "b": [0.6869, 0.1813, 0.7008, 0.1964]}, {"w": "depending", "b": [0.7006, 0.1782, 0.7851, 0.1986]}, {"w": "on", "b": [0.7896, 0.1782, 0.8106, 0.1986]}, {"w": "the", "b": [0.8151, 0.1782, 0.8402, 0.1986]}, {"w": "shape", "b": [0.1592, 0.1963, 0.2043, 0.2167]}, {"w": "of", "b": [0.2107, 0.1963, 0.2267, 0.2167]}, {"w": "the", "b": [0.2332, 0.1963, 0.2583, 0.2167]}, {"w": "cost", "b": [0.2648, 0.1963, 0.2966, 0.2167]}, {"w": "function.", "b": [0.3031, 0.1963, 0.3756, 0.2167]}, {"w": "If", "b": [0.3821, 0.1963, 0.3947, 0.2167]}, {"w": "you", "b": [0.4012, 0.1963, 0.4309, 0.2167]}, {"w": "divide", "b": [0.4374, 0.1963, 0.4866, 0.2167]}, {"w": "the", "b": [0.4931, 0.1963, 0.5182, 0.2167]}, {"w": "tolerance", "b": [0.5246, 0.1963, 0.598, 0.2167]}, {"w": "by", "b": [0.6045, 0.1963, 0.6237, 0.2167]}, {"w": "10", "b": [0.6301, 0.1963, 0.6492, 0.2167]}, {"w": "to", "b": [0.6557, 0.1963, 0.6718, 0.2167]}, {"w": "have", "b": [0.6783, 0.1963, 0.7149, 0.2167]}, {"w": "a", "b": [0.7213, 0.1963, 0.7301, 0.2167]}, {"w": "more", "b": [0.7365, 0.1963, 0.7787, 0.2167]}, {"w": "precise", "b": [0.7852, 0.1963, 0.8408, 0.2167]}, {"w": "solution,", "b": [0.1592, 0.2145, 0.229, 0.2349]}, {"w": "then", "b": [0.2336, 0.2145, 0.2695, 0.2349]}, {"w": "the", "b": [0.274, 0.2145, 0.2991, 0.2349]}, {"w": "algorithm", "b": [0.3036, 0.2145, 0.3823, 0.2349]}, {"w": "may", "b": [0.3868, 0.2145, 0.4205, 0.2349]}, {"w": "have", "b": [0.425, 0.2145, 0.4616, 0.2349]}, {"w": "to", "b": [0.4661, 0.2145, 0.4822, 0.2349]}, {"w": "run", "b": [0.4867, 0.2145, 0.5155, 0.2349]}, {"w": "about", "b": [0.52, 0.2145, 0.5655, 0.2349]}, {"w": "10", "b": [0.57, 0.2145, 0.589, 0.2349]}, {"w": "times", "b": [0.5936, 0.2145, 0.6369, 0.2349]}, {"w": "longer.", "b": [0.6414, 0.2145, 0.6957, 0.2349]}]}, {"id": "b_3", "type": "paragraph", "text": "Stochastic Gradient Descent", "words": [{"w": "Stochastic", "b": [0.1428, 0.2646, 0.247, 0.2932]}, {"w": "Gradient", "b": [0.252, 0.2646, 0.3418, 0.2932]}, {"w": "Descent", "b": [0.3467, 0.2646, 0.428, 0.2932]}]}, {"id": "b_4", "type": "paragraph", "text": "The main problem with Batch Gradient Descent is the fact that it uses the whole training set to compute the gradients at every step, which makes it very slow when the training set is large. At the opposite extreme, Stochastic Gradient Descent just picks a random instance in the training set at every step and computes the gradients based only on that single instance. Obviously this makes the algorithm much faster since it has very little data to manipulate at every iteration. It also makes it possible to train on huge training sets, since only one instance needs to be in memory at each iteration (SGD can be implemented as an out-of-core algorithm.7)", "words": [{"w": "The", "b": [0.1429, 0.2991, 0.1757, 0.3205]}, {"w": "main", "b": [0.1839, 0.2991, 0.2271, 0.3205]}, {"w": "problem", "b": [0.2353, 0.2991, 0.3063, 0.3205]}, {"w": "with", "b": [0.3145, 0.2991, 0.3519, 0.3205]}, {"w": "Batch", "b": [0.3601, 0.2991, 0.4074, 0.3205]}, {"w": "Gradient", "b": [0.4156, 0.2991, 0.4902, 0.3205]}, {"w": "Descent", "b": [0.4984, 0.2991, 0.5652, 0.3205]}, {"w": "is", "b": [0.5734, 0.2991, 0.5866, 0.3205]}, {"w": "the", "b": [0.5949, 0.2991, 0.6212, 0.3205]}, {"w": "fact", "b": [0.6294, 0.2991, 0.6599, 0.3205]}, {"w": "that", "b": [0.6681, 0.2991, 0.7007, 0.3205]}, {"w": "it", "b": [0.7089, 0.2991, 0.7208, 0.3205]}, {"w": "uses", "b": [0.729, 0.2991, 0.7642, 0.3205]}, {"w": "the", "b": [0.7724, 0.2991, 0.7988, 0.3205]}, {"w": "whole", "b": [0.807, 0.2991, 0.8571, 0.3205]}, {"w": "training", "b": [0.1429, 0.3182, 0.2098, 0.3396]}, {"w": "set", "b": [0.2167, 0.3182, 0.2396, 0.3396]}, {"w": "to", "b": [0.2465, 0.3182, 0.2635, 0.3396]}, {"w": "compute", "b": [0.2704, 0.3182, 0.3437, 0.3396]}, {"w": "the", "b": [0.3506, 0.3182, 0.3769, 0.3396]}, {"w": "gradients", "b": [0.3838, 0.3182, 0.4609, 0.3396]}, {"w": "at", "b": [0.4678, 0.3182, 0.4829, 0.3396]}, {"w": "every", "b": [0.4898, 0.3182, 0.5351, 0.3396]}, {"w": "step,", "b": [0.542, 0.3182, 0.5799, 0.3396]}, {"w": "which", "b": [0.5868, 0.3182, 0.6377, 0.3396]}, {"w": "makes", "b": [0.6447, 0.3182, 0.6977, 0.3396]}, {"w": "it", "b": [0.7046, 0.3182, 0.7166, 0.3396]}, {"w": "very", "b": [0.7235, 0.3182, 0.7599, 0.3396]}, {"w": "slow", "b": [0.7668, 0.3182, 0.8046, 0.3396]}, {"w": "when", "b": [0.8115, 0.3182, 0.8572, 0.3396]}, {"w": "the", "b": [0.1429, 0.3372, 0.1692, 0.3586]}, {"w": "training", "b": [0.1778, 0.3372, 0.2447, 0.3586]}, {"w": "set", "b": [0.2533, 0.3372, 0.2761, 0.3586]}, {"w": "is", "b": [0.2847, 0.3372, 0.2979, 0.3586]}, {"w": "large.", "b": [0.3065, 0.3372, 0.352, 0.3586]}, {"w": "At", "b": [0.3605, 0.3372, 0.3804, 0.3586]}, {"w": "the", "b": [0.389, 0.3372, 0.4153, 0.3586]}, {"w": "opposite", "b": [0.4239, 0.3372, 0.4954, 0.3586]}, {"w": "extreme,", "b": [0.5039, 0.3372, 0.5762, 0.3586]}, {"w": "Stochastic", "b": [0.5848, 0.337, 0.6652, 0.3586]}, {"w": "Gradient", "b": [0.6738, 0.337, 0.7463, 0.3586]}, {"w": "Descent", "b": [0.7549, 0.337, 0.8182, 0.3586]}, {"w": "just", "b": [0.8268, 0.3372, 0.8571, 0.3586]}, {"w": "picks", "b": [0.1429, 0.3562, 0.1861, 0.3777]}, {"w": "a", "b": [0.192, 0.3562, 0.2012, 0.3777]}, {"w": "random", "b": [0.2071, 0.3562, 0.2741, 0.3777]}, {"w": "instance", "b": [0.28, 0.3562, 0.3491, 0.3777]}, {"w": "in", "b": [0.355, 0.3562, 0.372, 0.3777]}, {"w": "the", "b": [0.3779, 0.3562, 0.4043, 0.3777]}, {"w": "training", "b": [0.4102, 0.3562, 0.4771, 0.3777]}, {"w": "set", "b": [0.483, 0.3562, 0.5058, 0.3777]}, {"w": "at", "b": [0.5117, 0.3562, 0.5268, 0.3777]}, {"w": "every", "b": [0.5327, 0.3562, 0.578, 0.3777]}, {"w": "step", "b": [0.5839, 0.3562, 0.6177, 0.3777]}, {"w": "and", "b": [0.6236, 0.3562, 0.6551, 0.3777]}, {"w": "computes", "b": [0.661, 0.3562, 0.7419, 0.3777]}, {"w": "the", "b": [0.7478, 0.3562, 0.7742, 0.3777]}, {"w": "gradients", "b": [0.7801, 0.3562, 0.8571, 0.3777]}, {"w": "based", "b": [0.1428, 0.3753, 0.1901, 0.3967]}, {"w": "only", "b": [0.1969, 0.3753, 0.2337, 0.3967]}, {"w": "on", "b": [0.2405, 0.3753, 0.2625, 0.3967]}, {"w": "that", "b": [0.2693, 0.3753, 0.3019, 0.3967]}, {"w": "single", "b": [0.3086, 0.3753, 0.3571, 0.3967]}, {"w": "instance.", "b": [0.3639, 0.3753, 0.4379, 0.3967]}, {"w": "Obviously", "b": [0.4446, 0.3753, 0.5302, 0.3967]}, {"w": "this", "b": [0.537, 0.3753, 0.5677, 0.3967]}, {"w": "makes", "b": [0.5744, 0.3753, 0.6275, 0.3967]}, {"w": "the", "b": [0.6343, 0.3753, 0.6606, 0.3967]}, {"w": "algorithm", "b": [0.6674, 0.3753, 0.75, 0.3967]}, {"w": "much", "b": [0.7568, 0.3753, 0.8045, 0.3967]}, {"w": "faster", "b": [0.8112, 0.3753, 0.8571, 0.3967]}, {"w": "since", "b": [0.1429, 0.3943, 0.1852, 0.4158]}, {"w": "it", "b": [0.1902, 0.3943, 0.2021, 0.4158]}, {"w": "has", "b": [0.2072, 0.3943, 0.2351, 0.4158]}, {"w": "very", "b": [0.2401, 0.3943, 0.2765, 0.4158]}, {"w": "little", "b": [0.2816, 0.3943, 0.3193, 0.4158]}, {"w": "data", "b": [0.3243, 0.3943, 0.3596, 0.4158]}, {"w": "to", "b": [0.3646, 0.3943, 0.3816, 0.4158]}, {"w": "manipulate", "b": [0.3866, 0.3943, 0.481, 0.4158]}, {"w": "at", "b": [0.4861, 0.3943, 0.5012, 0.4158]}, {"w": "every", "b": [0.5062, 0.3943, 0.5515, 0.4158]}, {"w": "iteration.", "b": [0.5565, 0.3943, 0.6325, 0.4158]}, {"w": "It", "b": [0.6375, 0.3943, 0.6502, 0.4158]}, {"w": "also", "b": [0.6552, 0.3943, 0.6879, 0.4158]}, {"w": "makes", "b": [0.6929, 0.3943, 0.746, 0.4158]}, {"w": "it", "b": [0.751, 0.3943, 0.763, 0.4158]}, {"w": "possible", "b": [0.768, 0.3943, 0.8351, 0.4158]}, {"w": "to", "b": [0.8402, 0.3943, 0.8571, 0.4158]}, {"w": "train", "b": [0.1429, 0.4134, 0.1831, 0.4348]}, {"w": "on", "b": [0.19, 0.4134, 0.2121, 0.4348]}, {"w": "huge", "b": [0.219, 0.4134, 0.2594, 0.4348]}, {"w": "training", "b": [0.2664, 0.4134, 0.3333, 0.4348]}, {"w": "sets,", "b": [0.3403, 0.4134, 0.3756, 0.4348]}, {"w": "since", "b": [0.3825, 0.4134, 0.4248, 0.4348]}, {"w": "only", "b": [0.4318, 0.4134, 0.4686, 0.4348]}, {"w": "one", "b": [0.4756, 0.4134, 0.5065, 0.4348]}, {"w": "instance", "b": [0.5135, 0.4134, 0.5827, 0.4348]}, {"w": "needs", "b": [0.5896, 0.4134, 0.6374, 0.4348]}, {"w": "to", "b": [0.6443, 0.4134, 0.6613, 0.4348]}, {"w": "be", "b": [0.6683, 0.4134, 0.6877, 0.4348]}, {"w": "in", "b": [0.6947, 0.4134, 0.7117, 0.4348]}, {"w": "memory", "b": [0.7187, 0.4134, 0.7902, 0.4348]}, {"w": "at", "b": [0.7971, 0.4134, 0.8122, 0.4348]}, {"w": "each", "b": [0.8192, 0.4134, 0.8571, 0.4348]}, {"w": "iteration", "b": [0.1429, 0.4324, 0.2141, 0.4539]}, {"w": "(SGD", "b": [0.2188, 0.4324, 0.2661, 0.4539]}, {"w": "can", "b": [0.2708, 0.4324, 0.3002, 0.4539]}, {"w": "be", "b": [0.3049, 0.4324, 0.3244, 0.4539]}, {"w": "implemented", "b": [0.3291, 0.4324, 0.4395, 0.4539]}, {"w": "as", "b": [0.4442, 0.4324, 0.461, 0.4539]}, {"w": "an", "b": [0.4657, 0.4324, 0.4863, 0.4539]}, {"w": "out-of-core", "b": [0.491, 0.4324, 0.5867, 0.4539]}, {"w": "algorithm.7)", "b": [0.5914, 0.4324, 0.6918, 0.4539]}]}, {"id": "b_5", "type": "paragraph", "text": "On the other hand, due to its stochastic (i.e., random) nature, this algorithm is much less regular than Batch Gradient Descent: instead of gently decreasing until it reaches the minimum, the cost function will bounce up and down, decreasing only on aver‐ age. Over time it will end up very close to the minimum, but once it gets there it will continue to bounce around, never settling down (see Figure 4-9). So once the algo‐ rithm stops, the final parameter values are good, but not optimal.", "words": [{"w": "On", "b": [0.1429, 0.4606, 0.1698, 0.482]}, {"w": "the", "b": [0.1753, 0.4606, 0.2016, 0.482]}, {"w": "other", "b": [0.207, 0.4606, 0.2517, 0.482]}, {"w": "hand,", "b": [0.2571, 0.4606, 0.3046, 0.482]}, {"w": "due", "b": [0.31, 0.4606, 0.3409, 0.482]}, {"w": "to", "b": [0.3463, 0.4606, 0.3633, 0.482]}, {"w": "its", "b": [0.3688, 0.4606, 0.3883, 0.482]}, {"w": "stochastic", "b": [0.3938, 0.4606, 0.4759, 0.482]}, {"w": "(i.e.,", "b": [0.4813, 0.4606, 0.5172, 0.482]}, {"w": "random)", "b": [0.5227, 0.4606, 0.5968, 0.482]}, {"w": "nature,", "b": [0.6023, 0.4606, 0.6612, 0.482]}, {"w": "this", "b": [0.6666, 0.4606, 0.6973, 0.482]}, {"w": "algorithm", "b": [0.7027, 0.4606, 0.7854, 0.482]}, {"w": "is", "b": [0.7908, 0.4606, 0.804, 0.482]}, {"w": "much", "b": [0.8095, 0.4606, 0.8571, 0.482]}, {"w": "less", "b": [0.1429, 0.4796, 0.1723, 0.501]}, {"w": "regular", "b": [0.1776, 0.4796, 0.2372, 0.501]}, {"w": "than", "b": [0.2425, 0.4796, 0.2805, 0.501]}, {"w": "Batch", "b": [0.2859, 0.4796, 0.3332, 0.501]}, {"w": "Gradient", "b": [0.3385, 0.4796, 0.4131, 0.501]}, {"w": "Descent:", "b": [0.4184, 0.4796, 0.49, 0.501]}, {"w": "instead", "b": [0.4953, 0.4796, 0.5553, 0.501]}, {"w": "of", "b": [0.5607, 0.4796, 0.5775, 0.501]}, {"w": "gently", "b": [0.5828, 0.4796, 0.6336, 0.501]}, {"w": "decreasing", "b": [0.639, 0.4796, 0.7277, 0.501]}, {"w": "until", "b": [0.7331, 0.4796, 0.7723, 0.501]}, {"w": "it", "b": [0.7777, 0.4796, 0.7896, 0.501]}, {"w": "reaches", "b": [0.795, 0.4796, 0.8571, 0.501]}, {"w": "the", "b": [0.1429, 0.4987, 0.1692, 0.5201]}, {"w": "minimum,", "b": [0.1754, 0.4987, 0.2645, 0.5201]}, {"w": "the", "b": [0.2707, 0.4987, 0.297, 0.5201]}, {"w": "cost", "b": [0.3032, 0.4987, 0.3367, 0.5201]}, {"w": "function", "b": [0.3428, 0.4987, 0.4142, 0.5201]}, {"w": "will", "b": [0.4204, 0.4987, 0.4508, 0.5201]}, {"w": "bounce", "b": [0.457, 0.4987, 0.5183, 0.5201]}, {"w": "up", "b": [0.5245, 0.4987, 0.5465, 0.5201]}, {"w": "and", "b": [0.5526, 0.4987, 0.5842, 0.5201]}, {"w": "down,", "b": [0.5904, 0.4987, 0.6424, 0.5201]}, {"w": "decreasing", "b": [0.6486, 0.4987, 0.7373, 0.5201]}, {"w": "only", "b": [0.7435, 0.4987, 0.7804, 0.5201]}, {"w": "on", "b": [0.7865, 0.4987, 0.8086, 0.5201]}, {"w": "aver‐", "b": [0.8147, 0.4987, 0.8572, 0.5201]}, {"w": "age.", "b": [0.1429, 0.5177, 0.1754, 0.5391]}, {"w": "Over", "b": [0.1808, 0.5177, 0.223, 0.5391]}, {"w": "time", "b": [0.2285, 0.5177, 0.2663, 0.5391]}, {"w": "it", "b": [0.2718, 0.5177, 0.2837, 0.5391]}, {"w": "will", "b": [0.2892, 0.5177, 0.3196, 0.5391]}, {"w": "end", "b": [0.3251, 0.5177, 0.3564, 0.5391]}, {"w": "up", "b": [0.3618, 0.5177, 0.3838, 0.5391]}, {"w": "very", "b": [0.3893, 0.5177, 0.4257, 0.5391]}, {"w": "close", "b": [0.4312, 0.5177, 0.4724, 0.5391]}, {"w": "to", "b": [0.4779, 0.5177, 0.4948, 0.5391]}, {"w": "the", "b": [0.5003, 0.5177, 0.5267, 0.5391]}, {"w": "minimum,", "b": [0.5321, 0.5177, 0.6213, 0.5391]}, {"w": "but", "b": [0.6268, 0.5177, 0.6548, 0.5391]}, {"w": "once", "b": [0.6603, 0.5177, 0.6999, 0.5391]}, {"w": "it", "b": [0.7054, 0.5177, 0.7174, 0.5391]}, {"w": "gets", "b": [0.7228, 0.5177, 0.7555, 0.5391]}, {"w": "there", "b": [0.7609, 0.5177, 0.8039, 0.5391]}, {"w": "it", "b": [0.8093, 0.5177, 0.8213, 0.5391]}, {"w": "will", "b": [0.8268, 0.5177, 0.8571, 0.5391]}, {"w": "continue", "b": [0.1429, 0.5367, 0.2161, 0.5582]}, {"w": "to", "b": [0.2229, 0.5367, 0.2398, 0.5582]}, {"w": "bounce", "b": [0.2466, 0.5367, 0.3079, 0.5582]}, {"w": "around,", "b": [0.3146, 0.5367, 0.3803, 0.5582]}, {"w": "never", "b": [0.387, 0.5367, 0.4335, 0.5582]}, {"w": "settling", "b": [0.4402, 0.5367, 0.5014, 0.5582]}, {"w": "down", "b": [0.5082, 0.5367, 0.5555, 0.5582]}, {"w": "(see", "b": [0.5622, 0.5367, 0.5947, 0.5582]}, {"w": "Figure", "b": [0.6014, 0.5367, 0.6554, 0.5582]}, {"w": "4-9).", "b": [0.6622, 0.5367, 0.7015, 0.5582]}, {"w": "So", "b": [0.7083, 0.5367, 0.7288, 0.5582]}, {"w": "once", "b": [0.7355, 0.5367, 0.7752, 0.5582]}, {"w": "the", "b": [0.7819, 0.5367, 0.8082, 0.5582]}, {"w": "algo‐", "b": [0.8149, 0.5367, 0.8571, 0.5582]}, {"w": "rithm", "b": [0.1428, 0.5558, 0.1907, 0.5772]}, {"w": "stops,", "b": [0.1954, 0.5558, 0.2434, 0.5772]}, {"w": "the", "b": [0.2481, 0.5558, 0.2744, 0.5772]}, {"w": "final", "b": [0.2792, 0.5558, 0.3167, 0.5772]}, {"w": "parameter", "b": [0.3215, 0.5558, 0.4072, 0.5772]}, {"w": "values", "b": [0.412, 0.5558, 0.4636, 0.5772]}, {"w": "are", "b": [0.4683, 0.5558, 0.4941, 0.5772]}, {"w": "good,", "b": [0.4988, 0.5558, 0.5455, 0.5772]}, {"w": "but", "b": [0.5503, 0.5558, 0.5783, 0.5772]}, {"w": "not", "b": [0.583, 0.5558, 0.6114, 0.5772]}, {"w": "optimal.", "b": [0.6161, 0.5558, 0.6858, 0.5772]}]}, {"id": "b_6", "type": "equation", "text": "Figure 4-9. Stochastic Gradient Descent", "words": [{"w": "Figure", "b": [0.1428, 0.8101, 0.1943, 0.8317]}, {"w": "4-9.", "b": [0.1991, 0.8101, 0.2308, 0.8317]}, {"w": "Stochastic", "b": [0.2356, 0.8101, 0.316, 0.8317]}, {"w": "Gradient", "b": [0.3207, 0.8101, 0.3932, 0.8317]}, {"w": "Descent", "b": [0.398, 0.8101, 0.4613, 0.8317]}]}, {"id": "b_7", "type": "paragraph", "text": "126 | Chapter 4: Training Models", "words": [{"w": "126", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 153, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "When the cost function is very irregular (as in Figure 4-6), this can actually help the algorithm jump out of local minima, so Stochastic Gradient Descent has a better chance of finding the global minimum than Batch Gradient Descent does.", "words": [{"w": "When", "b": [0.1429, 0.0791, 0.1945, 0.1005]}, {"w": "the", "b": [0.2003, 0.0791, 0.2266, 0.1005]}, {"w": "cost", "b": [0.2325, 0.0791, 0.2659, 0.1005]}, {"w": "function", "b": [0.2717, 0.0791, 0.3431, 0.1005]}, {"w": "is", "b": [0.349, 0.0791, 0.3622, 0.1005]}, {"w": "very", "b": [0.368, 0.0791, 0.4044, 0.1005]}, {"w": "irregular", "b": [0.4103, 0.0791, 0.4831, 0.1005]}, {"w": "(as", "b": [0.4889, 0.0791, 0.5129, 0.1005]}, {"w": "in", "b": [0.5188, 0.0791, 0.5357, 0.1005]}, {"w": "Figure", "b": [0.5416, 0.0791, 0.5956, 0.1005]}, {"w": "4-6),", "b": [0.6014, 0.0791, 0.6408, 0.1005]}, {"w": "this", "b": [0.6466, 0.0791, 0.6773, 0.1005]}, {"w": "can", "b": [0.6832, 0.0791, 0.7125, 0.1005]}, {"w": "actually", "b": [0.7184, 0.0791, 0.783, 0.1005]}, {"w": "help", "b": [0.7888, 0.0791, 0.825, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}, {"w": "algorithm", "b": [0.1429, 0.0981, 0.2255, 0.1195]}, {"w": "jump", "b": [0.2341, 0.0981, 0.2781, 0.1195]}, {"w": "out", "b": [0.2867, 0.0981, 0.3147, 0.1195]}, {"w": "of", "b": [0.3234, 0.0981, 0.3401, 0.1195]}, {"w": "local", "b": [0.3488, 0.0981, 0.3879, 0.1195]}, {"w": "minima,", "b": [0.3965, 0.0981, 0.4671, 0.1195]}, {"w": "so", "b": [0.4757, 0.0981, 0.494, 0.1195]}, {"w": "Stochastic", "b": [0.5026, 0.0981, 0.5869, 0.1195]}, {"w": "Gradient", "b": [0.5955, 0.0981, 0.6701, 0.1195]}, {"w": "Descent", "b": [0.6787, 0.0981, 0.7455, 0.1195]}, {"w": "has", "b": [0.7541, 0.0981, 0.782, 0.1195]}, {"w": "a", "b": [0.7907, 0.0981, 0.7998, 0.1195]}, {"w": "better", "b": [0.8084, 0.0981, 0.8571, 0.1195]}, {"w": "chance", "b": [0.1429, 0.1172, 0.201, 0.1386]}, {"w": "of", "b": [0.2057, 0.1172, 0.2225, 0.1386]}, {"w": "finding", "b": [0.2273, 0.1172, 0.2881, 0.1386]}, {"w": "the", "b": [0.2929, 0.1172, 0.3192, 0.1386]}, {"w": "global", "b": [0.3239, 0.1172, 0.3746, 0.1386]}, {"w": "minimum", "b": [0.3793, 0.1172, 0.4637, 0.1386]}, {"w": "than", "b": [0.4685, 0.1172, 0.5065, 0.1386]}, {"w": "Batch", "b": [0.5112, 0.1172, 0.5585, 0.1386]}, {"w": "Gradient", "b": [0.5632, 0.1172, 0.6378, 0.1386]}, {"w": "Descent", "b": [0.6425, 0.1172, 0.7093, 0.1386]}, {"w": "does.", "b": [0.7141, 0.1172, 0.757, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "Therefore randomness is good to escape from local optima, but bad because it means that the algorithm can never settle at the minimum. One solution to this dilemma is to gradually reduce the learning rate. The steps start out large (which helps make quick progress and escape local minima), then get smaller and smaller, allowing the algorithm to settle at the global minimum. This process is akin to simulated anneal‐ ing, an algorithm inspired from the process of annealing in metallurgy where molten metal is slowly cooled down. The function that determines the learning rate at each iteration is called the learning schedule. If the learning rate is reduced too quickly, you may get stuck in a local minimum, or even end up frozen halfway to the minimum. If the learning rate is reduced too slowly, you may jump around the minimum for a long time and end up with a suboptimal solution if you halt training too early.", "words": [{"w": "Therefore", "b": [0.1429, 0.1453, 0.2257, 0.1667]}, {"w": "randomness", "b": [0.2309, 0.1453, 0.3334, 0.1667]}, {"w": "is", "b": [0.3387, 0.1453, 0.3519, 0.1667]}, {"w": "good", "b": [0.3572, 0.1453, 0.3992, 0.1667]}, {"w": "to", "b": [0.4045, 0.1453, 0.4214, 0.1667]}, {"w": "escape", "b": [0.4267, 0.1453, 0.4805, 0.1667]}, {"w": "from", "b": [0.4858, 0.1453, 0.5274, 0.1667]}, {"w": "local", "b": [0.5327, 0.1453, 0.5718, 0.1667]}, {"w": "optima,", "b": [0.577, 0.1453, 0.6415, 0.1667]}, {"w": "but", "b": [0.6468, 0.1453, 0.6748, 0.1667]}, {"w": "bad", "b": [0.68, 0.1453, 0.7107, 0.1667]}, {"w": "because", "b": [0.716, 0.1453, 0.7806, 0.1667]}, {"w": "it", "b": [0.7858, 0.1453, 0.7978, 0.1667]}, {"w": "means", "b": [0.803, 0.1453, 0.8572, 0.1667]}, {"w": "that", "b": [0.1429, 0.1643, 0.1754, 0.1857]}, {"w": "the", "b": [0.1814, 0.1643, 0.2078, 0.1857]}, {"w": "algorithm", "b": [0.2137, 0.1643, 0.2964, 0.1857]}, {"w": "can", "b": [0.3024, 0.1643, 0.3317, 0.1857]}, {"w": "never", "b": [0.3377, 0.1643, 0.3842, 0.1857]}, {"w": "settle", "b": [0.3901, 0.1643, 0.4335, 0.1857]}, {"w": "at", "b": [0.4395, 0.1643, 0.4546, 0.1857]}, {"w": "the", "b": [0.4605, 0.1643, 0.4869, 0.1857]}, {"w": "minimum.", "b": [0.4928, 0.1643, 0.582, 0.1857]}, {"w": "One", "b": [0.588, 0.1643, 0.6238, 0.1857]}, {"w": "solution", "b": [0.6298, 0.1643, 0.6983, 0.1857]}, {"w": "to", "b": [0.7043, 0.1643, 0.7213, 0.1857]}, {"w": "this", "b": [0.7273, 0.1643, 0.758, 0.1857]}, {"w": "dilemma", "b": [0.764, 0.1643, 0.8379, 0.1857]}, {"w": "is", "b": [0.8439, 0.1643, 0.8571, 0.1857]}, {"w": "to", "b": [0.1429, 0.1834, 0.1598, 0.2048]}, {"w": "gradually", "b": [0.1678, 0.1834, 0.2457, 0.2048]}, {"w": "reduce", "b": [0.2537, 0.1834, 0.31, 0.2048]}, {"w": "the", "b": [0.318, 0.1834, 0.3443, 0.2048]}, {"w": "learning", "b": [0.3523, 0.1834, 0.4214, 0.2048]}, {"w": "rate.", "b": [0.4294, 0.1834, 0.4658, 0.2048]}, {"w": "The", "b": [0.4738, 0.1834, 0.5066, 0.2048]}, {"w": "steps", "b": [0.5146, 0.1834, 0.556, 0.2048]}, {"w": "start", "b": [0.564, 0.1834, 0.6012, 0.2048]}, {"w": "out", "b": [0.6092, 0.1834, 0.6372, 0.2048]}, {"w": "large", "b": [0.6452, 0.1834, 0.6859, 0.2048]}, {"w": "(which", "b": [0.6939, 0.1834, 0.752, 0.2048]}, {"w": "helps", "b": [0.76, 0.1834, 0.8038, 0.2048]}, {"w": "make", "b": [0.8117, 0.1834, 0.8571, 0.2048]}, {"w": "quick", "b": [0.1429, 0.2024, 0.1893, 0.2238]}, {"w": "progress", "b": [0.1957, 0.2024, 0.2666, 0.2238]}, {"w": "and", "b": [0.2731, 0.2024, 0.3046, 0.2238]}, {"w": "escape", "b": [0.3111, 0.2024, 0.3649, 0.2238]}, {"w": "local", "b": [0.3714, 0.2024, 0.4105, 0.2238]}, {"w": "minima),", "b": [0.4169, 0.2024, 0.4947, 0.2238]}, {"w": "then", "b": [0.5012, 0.2024, 0.5389, 0.2238]}, {"w": "get", "b": [0.5453, 0.2024, 0.5703, 0.2238]}, {"w": "smaller", "b": [0.5768, 0.2024, 0.6377, 0.2238]}, {"w": "and", "b": [0.6442, 0.2024, 0.6757, 0.2238]}, {"w": "smaller,", "b": [0.6822, 0.2024, 0.7466, 0.2238]}, {"w": "allowing", "b": [0.753, 0.2024, 0.8244, 0.2238]}, {"w": "the", "b": [0.8308, 0.2024, 0.8571, 0.2238]}, {"w": "algorithm", "b": [0.1429, 0.2215, 0.2255, 0.2429]}, {"w": "to", "b": [0.2319, 0.2215, 0.2489, 0.2429]}, {"w": "settle", "b": [0.2553, 0.2215, 0.2986, 0.2429]}, {"w": "at", "b": [0.305, 0.2215, 0.3201, 0.2429]}, {"w": "the", "b": [0.3265, 0.2215, 0.3528, 0.2429]}, {"w": "global", "b": [0.3592, 0.2215, 0.4098, 0.2429]}, {"w": "minimum.", "b": [0.4162, 0.2215, 0.5054, 0.2429]}, {"w": "This", "b": [0.5117, 0.2215, 0.5489, 0.2429]}, {"w": "process", "b": [0.5553, 0.2215, 0.6176, 0.2429]}, {"w": "is", "b": [0.6239, 0.2215, 0.6372, 0.2429]}, {"w": "akin", "b": [0.6435, 0.2215, 0.68, 0.2429]}, {"w": "to", "b": [0.6864, 0.2215, 0.7034, 0.2429]}, {"w": "simulated", "b": [0.7097, 0.2213, 0.7889, 0.2429]}, {"w": "anneal‐", "b": [0.7953, 0.2213, 0.8571, 0.2429]}, {"w": "ing,", "b": [0.1429, 0.2403, 0.1726, 0.2619]}, {"w": "an", "b": [0.1781, 0.2405, 0.1986, 0.2619]}, {"w": "algorithm", "b": [0.2041, 0.2405, 0.2868, 0.2619]}, {"w": "inspired", "b": [0.2922, 0.2405, 0.3609, 0.2619]}, {"w": "from", "b": [0.3664, 0.2405, 0.408, 0.2619]}, {"w": "the", "b": [0.4135, 0.2405, 0.4398, 0.2619]}, {"w": "process", "b": [0.4453, 0.2405, 0.5076, 0.2619]}, {"w": "of", "b": [0.513, 0.2405, 0.5298, 0.2619]}, {"w": "annealing", "b": [0.5353, 0.2405, 0.6173, 0.2619]}, {"w": "in", "b": [0.6227, 0.2405, 0.6397, 0.2619]}, {"w": "metallurgy", "b": [0.6452, 0.2405, 0.7358, 0.2619]}, {"w": "where", "b": [0.7413, 0.2405, 0.7921, 0.2619]}, {"w": "molten", "b": [0.7976, 0.2405, 0.8571, 0.2619]}, {"w": "metal", "b": [0.1429, 0.2596, 0.1895, 0.281]}, {"w": "is", "b": [0.196, 0.2596, 0.2092, 0.281]}, {"w": "slowly", "b": [0.2157, 0.2596, 0.2684, 0.281]}, {"w": "cooled", "b": [0.2748, 0.2596, 0.33, 0.281]}, {"w": "down.", "b": [0.3365, 0.2596, 0.3885, 0.281]}, {"w": "The", "b": [0.395, 0.2596, 0.4278, 0.281]}, {"w": "function", "b": [0.4343, 0.2596, 0.5057, 0.281]}, {"w": "that", "b": [0.5122, 0.2596, 0.5448, 0.281]}, {"w": "determines", "b": [0.5512, 0.2596, 0.6446, 0.281]}, {"w": "the", "b": [0.6511, 0.2596, 0.6774, 0.281]}, {"w": "learning", "b": [0.6839, 0.2596, 0.753, 0.281]}, {"w": "rate", "b": [0.7595, 0.2596, 0.7911, 0.281]}, {"w": "at", "b": [0.7976, 0.2596, 0.8127, 0.281]}, {"w": "each", "b": [0.8192, 0.2596, 0.8571, 0.281]}, {"w": "iteration", "b": [0.1429, 0.2786, 0.2141, 0.3]}, {"w": "is", "b": [0.2192, 0.2786, 0.2324, 0.3]}, {"w": "called", "b": [0.2375, 0.2786, 0.2858, 0.3]}, {"w": "the", "b": [0.2909, 0.2786, 0.3172, 0.3]}, {"w": "learning", "b": [0.3223, 0.2784, 0.389, 0.3]}, {"w": "schedule.", "b": [0.3938, 0.2784, 0.4671, 0.3]}, {"w": "If", "b": [0.4722, 0.2786, 0.4855, 0.3]}, {"w": "the", "b": [0.4906, 0.2786, 0.5169, 0.3]}, {"w": "learning", "b": [0.522, 0.2786, 0.5911, 0.3]}, {"w": "rate", "b": [0.5962, 0.2786, 0.6279, 0.3]}, {"w": "is", "b": [0.6329, 0.2786, 0.6462, 0.3]}, {"w": "reduced", "b": [0.6512, 0.2786, 0.7186, 0.3]}, {"w": "too", "b": [0.7236, 0.2786, 0.7512, 0.3]}, {"w": "quickly,", "b": [0.7563, 0.2786, 0.8208, 0.3]}, {"w": "you", "b": [0.8259, 0.2786, 0.8571, 0.3]}, {"w": "may", "b": [0.1429, 0.2977, 0.1783, 0.3191]}, {"w": "get", "b": [0.1833, 0.2977, 0.2083, 0.3191]}, {"w": "stuck", "b": [0.2133, 0.2977, 0.2575, 0.3191]}, {"w": "in", "b": [0.2626, 0.2977, 0.2796, 0.3191]}, {"w": "a", "b": [0.2847, 0.2977, 0.2938, 0.3191]}, {"w": "local", "b": [0.2989, 0.2977, 0.338, 0.3191]}, {"w": "minimum,", "b": [0.3431, 0.2977, 0.4322, 0.3191]}, {"w": "or", "b": [0.4373, 0.2977, 0.4556, 0.3191]}, {"w": "even", "b": [0.4607, 0.2977, 0.4995, 0.3191]}, {"w": "end", "b": [0.5045, 0.2977, 0.5358, 0.3191]}, {"w": "up", "b": [0.5408, 0.2977, 0.5628, 0.3191]}, {"w": "frozen", "b": [0.5679, 0.2977, 0.6214, 0.3191]}, {"w": "halfway", "b": [0.6265, 0.2977, 0.6911, 0.3191]}, {"w": "to", "b": [0.6962, 0.2977, 0.7132, 0.3191]}, {"w": "the", "b": [0.7182, 0.2977, 0.7446, 0.3191]}, {"w": "minimum.", "b": [0.7496, 0.2977, 0.8388, 0.3191]}, {"w": "If", "b": [0.8439, 0.2977, 0.8571, 0.3191]}, {"w": "the", "b": [0.1429, 0.3167, 0.1692, 0.3381]}, {"w": "learning", "b": [0.1769, 0.3167, 0.246, 0.3381]}, {"w": "rate", "b": [0.2536, 0.3167, 0.2853, 0.3381]}, {"w": "is", "b": [0.293, 0.3167, 0.3062, 0.3381]}, {"w": "reduced", "b": [0.3138, 0.3167, 0.3812, 0.3381]}, {"w": "too", "b": [0.3888, 0.3167, 0.4164, 0.3381]}, {"w": "slowly,", "b": [0.4241, 0.3167, 0.4799, 0.3381]}, {"w": "you", "b": [0.4876, 0.3167, 0.5188, 0.3381]}, {"w": "may", "b": [0.5265, 0.3167, 0.5619, 0.3381]}, {"w": "jump", "b": [0.5695, 0.3167, 0.6135, 0.3381]}, {"w": "around", "b": [0.6212, 0.3167, 0.6821, 0.3381]}, {"w": "the", "b": [0.6898, 0.3167, 0.7161, 0.3381]}, {"w": "minimum", "b": [0.7238, 0.3167, 0.8082, 0.3381]}, {"w": "for", "b": [0.8158, 0.3167, 0.8404, 0.3381]}, {"w": "a", "b": [0.848, 0.3167, 0.8572, 0.3381]}, {"w": "long", "b": [0.1429, 0.3358, 0.1799, 0.3572]}, {"w": "time", "b": [0.1846, 0.3358, 0.2225, 0.3572]}, {"w": "and", "b": [0.2272, 0.3358, 0.2588, 0.3572]}, {"w": "end", "b": [0.2635, 0.3358, 0.2947, 0.3572]}, {"w": "up", "b": [0.2995, 0.3358, 0.3214, 0.3572]}, {"w": "with", "b": [0.3262, 0.3358, 0.3635, 0.3572]}, {"w": "a", "b": [0.3682, 0.3358, 0.3774, 0.3572]}, {"w": "suboptimal", "b": [0.3821, 0.3358, 0.4764, 0.3572]}, {"w": "solution", "b": [0.4811, 0.3358, 0.5497, 0.3572]}, {"w": "if", "b": [0.5544, 0.3358, 0.5661, 0.3572]}, {"w": "you", "b": [0.5709, 0.3358, 0.6021, 0.3572]}, {"w": "halt", "b": [0.6068, 0.3358, 0.6387, 0.3572]}, {"w": "training", "b": [0.6435, 0.3358, 0.7104, 0.3572]}, {"w": "too", "b": [0.7151, 0.3358, 0.7427, 0.3572]}, {"w": "early.", "b": [0.7475, 0.3358, 0.7913, 0.3572]}]}, {"id": "b_2", "type": "paragraph", "text": "This code implements Stochastic Gradient Descent using a simple learning schedule:", "words": [{"w": "This", "b": [0.1429, 0.3639, 0.1801, 0.3853]}, {"w": "code", "b": [0.1848, 0.3639, 0.2241, 0.3853]}, {"w": "implements", "b": [0.2288, 0.3639, 0.327, 0.3853]}, {"w": "Stochastic", "b": [0.3318, 0.3639, 0.4161, 0.3853]}, {"w": "Gradient", "b": [0.4208, 0.3639, 0.4954, 0.3853]}, {"w": "Descent", "b": [0.5001, 0.3639, 0.5669, 0.3853]}, {"w": "using", "b": [0.5717, 0.3639, 0.6171, 0.3853]}, {"w": "a", "b": [0.6218, 0.3639, 0.631, 0.3853]}, {"w": "simple", "b": [0.6357, 0.3639, 0.6907, 0.3853]}, {"w": "learning", "b": [0.6954, 0.3639, 0.7645, 0.3853]}, {"w": "schedule:", "b": [0.7692, 0.3639, 0.8466, 0.3853]}]}, {"id": "b_3", "type": "equation", "text": "n_epochs = 50 t0, t1 = 5, 50 # learning schedule hyperparameters", "words": [{"w": "n_epochs", "b": [0.1766, 0.3958, 0.2441, 0.4087]}, {"w": "=", "b": [0.2525, 0.3958, 0.2609, 0.4087]}, {"w": "50", "b": [0.2694, 0.3958, 0.2862, 0.4087]}, {"w": "t0,", "b": [0.1766, 0.4113, 0.2019, 0.4241]}, {"w": "t1", "b": [0.2103, 0.4113, 0.2272, 0.4241]}, {"w": "=", "b": [0.2356, 0.4113, 0.2441, 0.4241]}, {"w": "5,", "b": [0.2525, 0.4113, 0.2694, 0.4241]}, {"w": "50", "b": [0.2778, 0.4113, 0.2947, 0.4241]}, {"w": "#", "b": [0.3115, 0.4113, 0.32, 0.4241]}, {"w": "learning", "b": [0.3284, 0.4113, 0.3958, 0.4241]}, {"w": "schedule", "b": [0.4043, 0.4113, 0.4717, 0.4241]}, {"w": "hyperparameters", "b": [0.4802, 0.4113, 0.6067, 0.4241]}]}, {"id": "b_4", "type": "equation", "text": "def learning_schedule(t): return t0 / (t + t1)", "words": [{"w": "def", "b": [0.1766, 0.4421, 0.2019, 0.455]}, {"w": "learning_schedule(t):", "b": [0.2103, 0.4421, 0.3874, 0.455]}, {"w": "return", "b": [0.2103, 0.4575, 0.2609, 0.4704]}, {"w": "t0", "b": [0.2694, 0.4575, 0.2862, 0.4704]}, {"w": "/", "b": [0.2947, 0.4575, 0.3031, 0.4704]}, {"w": "(t", "b": [0.3115, 0.4575, 0.3284, 0.4704]}, {"w": "+", "b": [0.3368, 0.4575, 0.3452, 0.4704]}, {"w": "t1)", "b": [0.3537, 0.4575, 0.379, 0.4704]}]}, {"id": "b_5", "type": "equation", "text": "theta = np.random.randn(2,1) # random initialization", "words": [{"w": "theta", "b": [0.1766, 0.4884, 0.2188, 0.5012]}, {"w": "=", "b": [0.2272, 0.4884, 0.2356, 0.5012]}, {"w": "np.random.randn(2,1)", "b": [0.2441, 0.4884, 0.4127, 0.5012]}, {"w": "#", "b": [0.4296, 0.4884, 0.438, 0.5012]}, {"w": "random", "b": [0.4464, 0.4884, 0.497, 0.5012]}, {"w": "initialization", "b": [0.5055, 0.4884, 0.6235, 0.5012]}]}, {"id": "b_6", "type": "paragraph", "text": "for epoch in range(n_epochs): for i in range(m): random_index = np.random.randint(m) xi = X_b[random_index:random_index+1] yi = y[random_index:random_index+1] gradients = 2 * xi.T.dot(xi.dot(theta) - yi) eta = learning_schedule(epoch * m + i) theta = theta - eta * gradients", "words": [{"w": "for", "b": [0.1766, 0.5192, 0.2019, 0.532]}, {"w": "epoch", "b": [0.2103, 0.5192, 0.2525, 0.532]}, {"w": "in", "b": [0.2609, 0.5192, 0.2778, 0.532]}, {"w": "range(n_epochs):", "b": [0.2862, 0.5192, 0.4211, 0.532]}, {"w": "for", "b": [0.2103, 0.5346, 0.2356, 0.5475]}, {"w": "i", "b": [0.244, 0.5346, 0.2525, 0.5475]}, {"w": "in", "b": [0.2609, 0.5346, 0.2778, 0.5475]}, {"w": "range(m):", "b": [0.2862, 0.5346, 0.3621, 0.5475]}, {"w": "random_index", "b": [0.244, 0.55, 0.3452, 0.5629]}, {"w": "=", "b": [0.3537, 0.55, 0.3621, 0.5629]}, {"w": "np.random.randint(m)", "b": [0.3705, 0.55, 0.5392, 0.5629]}, {"w": "xi", "b": [0.244, 0.5655, 0.2609, 0.5783]}, {"w": "=", "b": [0.2693, 0.5655, 0.2778, 0.5783]}, {"w": "X_b[random_index:random_index+1]", "b": [0.2862, 0.5655, 0.556, 0.5783]}, {"w": "yi", "b": [0.244, 0.5809, 0.2609, 0.5937]}, {"w": "=", "b": [0.2693, 0.5809, 0.2778, 0.5937]}, {"w": "y[random_index:random_index+1]", "b": [0.2862, 0.5809, 0.5392, 0.5937]}, {"w": "gradients", "b": [0.244, 0.5963, 0.3199, 0.6091]}, {"w": "=", "b": [0.3284, 0.5963, 0.3368, 0.6091]}, {"w": "2", "b": [0.3452, 0.5963, 0.3537, 0.6091]}, {"w": "*", "b": [0.3621, 0.5963, 0.3705, 0.6091]}, {"w": "xi.T.dot(xi.dot(theta)", "b": [0.379, 0.5963, 0.5645, 0.6091]}, {"w": "-", "b": [0.5729, 0.5963, 0.5813, 0.6091]}, {"w": "yi)", "b": [0.5898, 0.5963, 0.6151, 0.6091]}, {"w": "eta", "b": [0.244, 0.6117, 0.2693, 0.6246]}, {"w": "=", "b": [0.2778, 0.6117, 0.2862, 0.6246]}, {"w": "learning_schedule(epoch", "b": [0.2946, 0.6117, 0.4886, 0.6246]}, {"w": "*", "b": [0.497, 0.6117, 0.5055, 0.6246]}, {"w": "m", "b": [0.5139, 0.6117, 0.5223, 0.6246]}, {"w": "+", "b": [0.5307, 0.6117, 0.5392, 0.6246]}, {"w": "i)", "b": [0.5476, 0.6117, 0.5645, 0.6246]}, {"w": "theta", "b": [0.244, 0.6271, 0.2862, 0.64]}, {"w": "=", "b": [0.2946, 0.6271, 0.3031, 0.64]}, {"w": "theta", "b": [0.3115, 0.6271, 0.3537, 0.64]}, {"w": "-", "b": [0.3621, 0.6271, 0.3705, 0.64]}, {"w": "eta", "b": [0.379, 0.6271, 0.4043, 0.64]}, {"w": "*", "b": [0.4127, 0.6271, 0.4211, 0.64]}, {"w": "gradients", "b": [0.4296, 0.6271, 0.5055, 0.64]}]}, {"id": "b_7", "type": "paragraph", "text": "By convention we iterate by rounds of m iterations; each round is called an epoch. While the Batch Gradient Descent code iterated 1,000 times through the whole train‐ ing set, this code goes through the training set only 50 times and reaches a fairly good solution:", "words": [{"w": "By", "b": [0.1429, 0.6478, 0.1647, 0.6692]}, {"w": "convention", "b": [0.1716, 0.6478, 0.2654, 0.6692]}, {"w": "we", "b": [0.2723, 0.6478, 0.2954, 0.6692]}, {"w": "iterate", "b": [0.3023, 0.6478, 0.3548, 0.6692]}, {"w": "by", "b": [0.3617, 0.6478, 0.3819, 0.6692]}, {"w": "rounds", "b": [0.3888, 0.6478, 0.4483, 0.6692]}, {"w": "of", "b": [0.4552, 0.6478, 0.472, 0.6692]}, {"w": "m", "b": [0.4789, 0.6476, 0.4953, 0.6692]}, {"w": "iterations;", "b": [0.5022, 0.6478, 0.5858, 0.6692]}, {"w": "each", "b": [0.5927, 0.6478, 0.6306, 0.6692]}, {"w": "round", "b": [0.6376, 0.6478, 0.6894, 0.6692]}, {"w": "is", "b": [0.6963, 0.6478, 0.7095, 0.6692]}, {"w": "called", "b": [0.7164, 0.6478, 0.7648, 0.6692]}, {"w": "an", "b": [0.7717, 0.6478, 0.7922, 0.6692]}, {"w": "epoch.", "b": [0.7991, 0.6476, 0.8502, 0.6692]}, {"w": "While", "b": [0.1429, 0.6668, 0.1939, 0.6882]}, {"w": "the", "b": [0.1992, 0.6668, 0.2255, 0.6882]}, {"w": "Batch", "b": [0.2308, 0.6668, 0.2781, 0.6882]}, {"w": "Gradient", "b": [0.2834, 0.6668, 0.3579, 0.6882]}, {"w": "Descent", "b": [0.3632, 0.6668, 0.43, 0.6882]}, {"w": "code", "b": [0.4353, 0.6668, 0.4746, 0.6882]}, {"w": "iterated", "b": [0.4799, 0.6668, 0.5434, 0.6882]}, {"w": "1,000", "b": [0.5486, 0.6668, 0.5934, 0.6882]}, {"w": "times", "b": [0.5987, 0.6668, 0.6442, 0.6882]}, {"w": "through", "b": [0.6494, 0.6668, 0.7172, 0.6882]}, {"w": "the", "b": [0.7225, 0.6668, 0.7488, 0.6882]}, {"w": "whole", "b": [0.7541, 0.6668, 0.8042, 0.6882]}, {"w": "train‐", "b": [0.8095, 0.6668, 0.8571, 0.6882]}, {"w": "ing", "b": [0.1429, 0.6859, 0.1696, 0.7073]}, {"w": "set,", "b": [0.1745, 0.6859, 0.2021, 0.7073]}, {"w": "this", "b": [0.207, 0.6859, 0.2377, 0.7073]}, {"w": "code", "b": [0.2426, 0.6859, 0.2819, 0.7073]}, {"w": "goes", "b": [0.2868, 0.6859, 0.3237, 0.7073]}, {"w": "through", "b": [0.3286, 0.6859, 0.3964, 0.7073]}, {"w": "the", "b": [0.4013, 0.6859, 0.4276, 0.7073]}, {"w": "training", "b": [0.4325, 0.6859, 0.4995, 0.7073]}, {"w": "set", "b": [0.5044, 0.6859, 0.5272, 0.7073]}, {"w": "only", "b": [0.5321, 0.6859, 0.569, 0.7073]}, {"w": "50", "b": [0.5739, 0.6859, 0.5939, 0.7073]}, {"w": "times", "b": [0.5988, 0.6859, 0.6443, 0.7073]}, {"w": "and", "b": [0.6492, 0.6859, 0.6807, 0.7073]}, {"w": "reaches", "b": [0.6856, 0.6859, 0.7478, 0.7073]}, {"w": "a", "b": [0.7527, 0.6859, 0.7619, 0.7073]}, {"w": "fairly", "b": [0.7668, 0.6859, 0.8102, 0.7073]}, {"w": "good", "b": [0.8151, 0.6859, 0.8571, 0.7073]}, {"w": "solution:", "b": [0.1428, 0.7049, 0.2162, 0.7263]}]}, {"id": "b_8", "type": "paragraph", "text": ">>> theta array([[4.21076011], [2.74856079]])", "words": [{"w": ">>>", "b": [0.1766, 0.7369, 0.2019, 0.7497]}, {"w": "theta", "b": [0.2103, 0.7369, 0.2525, 0.7497]}, {"w": "array([[4.21076011],", "b": [0.1766, 0.7523, 0.3452, 0.7652]}, {"w": "[2.74856079]])", "b": [0.2356, 0.7677, 0.3537, 0.7806]}]}, {"id": "b_9", "type": "paragraph", "text": "Figure 4-10 shows the first 20 steps of training (notice how irregular the steps are).", "words": [{"w": "Figure", "b": [0.1429, 0.7884, 0.1969, 0.8098]}, {"w": "4-10", "b": [0.2016, 0.7884, 0.239, 0.8098]}, {"w": "shows", "b": [0.2437, 0.7884, 0.2951, 0.8098]}, {"w": "the", "b": [0.2998, 0.7884, 0.3261, 0.8098]}, {"w": "first", "b": [0.3308, 0.7884, 0.3643, 0.8098]}, {"w": "20", "b": [0.3691, 0.7884, 0.3891, 0.8098]}, {"w": "steps", "b": [0.3938, 0.7884, 0.4352, 0.8098]}, {"w": "of", "b": [0.4399, 0.7884, 0.4567, 0.8098]}, {"w": "training", "b": [0.4615, 0.7884, 0.5284, 0.8098]}, {"w": "(notice", "b": [0.5331, 0.7884, 0.592, 0.8098]}, {"w": "how", "b": [0.5967, 0.7884, 0.6327, 0.8098]}, {"w": "irregular", "b": [0.6374, 0.7884, 0.7103, 0.8098]}, {"w": "the", "b": [0.715, 0.7884, 0.7413, 0.8098]}, {"w": "steps", "b": [0.7461, 0.7884, 0.7875, 0.8098]}, {"w": "are).", "b": [0.7922, 0.7884, 0.8299, 0.8098]}]}, {"id": "b_10", "type": "paragraph", "text": "Gradient Descent | 127", "words": [{"w": "Gradient", "b": [0.6954, 0.9225, 0.7466, 0.9388]}, {"w": "Descent", "b": [0.7494, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "127", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 154, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 4-10. Stochastic Gradient Descent first 20 steps", "words": [{"w": "Figure", "b": [0.1429, 0.3609, 0.1943, 0.3825]}, {"w": "4-10.", "b": [0.1991, 0.3609, 0.2407, 0.3825]}, {"w": "Stochastic", "b": [0.2455, 0.3609, 0.3259, 0.3825]}, {"w": "Gradient", "b": [0.3307, 0.3609, 0.4032, 0.3825]}, {"w": "Descent", "b": [0.4079, 0.3609, 0.4713, 0.3825]}, {"w": "first", "b": [0.476, 0.3609, 0.5081, 0.3825]}, {"w": "20", "b": [0.5129, 0.3609, 0.5328, 0.3825]}, {"w": "steps", "b": [0.5375, 0.3609, 0.5758, 0.3825]}]}, {"id": "b_1", "type": "paragraph", "text": "Note that since instances are picked randomly, some instances may be picked several times per epoch while others may not be picked at all. If you want to be sure that the algorithm goes through every instance at each epoch, another approach is to shuffle the training set (making sure to shuffle the input features and the labels jointly), then go through it instance by instance, then shuffle it again, and so on. However, this gen‐ erally converges more slowly.", "words": [{"w": "Note", "b": [0.1429, 0.3983, 0.1836, 0.4197]}, {"w": "that", "b": [0.1892, 0.3983, 0.2218, 0.4197]}, {"w": "since", "b": [0.2274, 0.3983, 0.2697, 0.4197]}, {"w": "instances", "b": [0.2753, 0.3983, 0.3521, 0.4197]}, {"w": "are", "b": [0.3577, 0.3983, 0.3834, 0.4197]}, {"w": "picked", "b": [0.389, 0.3983, 0.4445, 0.4197]}, {"w": "randomly,", "b": [0.4501, 0.3983, 0.5351, 0.4197]}, {"w": "some", "b": [0.5407, 0.3983, 0.5849, 0.4197]}, {"w": "instances", "b": [0.5905, 0.3983, 0.6673, 0.4197]}, {"w": "may", "b": [0.6729, 0.3983, 0.7083, 0.4197]}, {"w": "be", "b": [0.7139, 0.3983, 0.7333, 0.4197]}, {"w": "picked", "b": [0.7389, 0.3983, 0.7944, 0.4197]}, {"w": "several", "b": [0.8, 0.3983, 0.8571, 0.4197]}, {"w": "times", "b": [0.1429, 0.4174, 0.1884, 0.4388]}, {"w": "per", "b": [0.1939, 0.4174, 0.2214, 0.4388]}, {"w": "epoch", "b": [0.2269, 0.4174, 0.2772, 0.4388]}, {"w": "while", "b": [0.2827, 0.4174, 0.3278, 0.4388]}, {"w": "others", "b": [0.3334, 0.4174, 0.3857, 0.4388]}, {"w": "may", "b": [0.3912, 0.4174, 0.4266, 0.4388]}, {"w": "not", "b": [0.4321, 0.4174, 0.4605, 0.4388]}, {"w": "be", "b": [0.466, 0.4174, 0.4855, 0.4388]}, {"w": "picked", "b": [0.491, 0.4174, 0.5465, 0.4388]}, {"w": "at", "b": [0.552, 0.4174, 0.5671, 0.4388]}, {"w": "all.", "b": [0.5726, 0.4174, 0.5971, 0.4388]}, {"w": "If", "b": [0.6026, 0.4174, 0.6159, 0.4388]}, {"w": "you", "b": [0.6214, 0.4174, 0.6526, 0.4388]}, {"w": "want", "b": [0.6581, 0.4174, 0.6989, 0.4388]}, {"w": "to", "b": [0.7044, 0.4174, 0.7214, 0.4388]}, {"w": "be", "b": [0.7269, 0.4174, 0.7464, 0.4388]}, {"w": "sure", "b": [0.7519, 0.4174, 0.7872, 0.4388]}, {"w": "that", "b": [0.7927, 0.4174, 0.8253, 0.4388]}, {"w": "the", "b": [0.8308, 0.4174, 0.8571, 0.4388]}, {"w": "algorithm", "b": [0.1429, 0.4364, 0.2255, 0.4578]}, {"w": "goes", "b": [0.2318, 0.4364, 0.2686, 0.4578]}, {"w": "through", "b": [0.2749, 0.4364, 0.3427, 0.4578]}, {"w": "every", "b": [0.3489, 0.4364, 0.3942, 0.4578]}, {"w": "instance", "b": [0.4004, 0.4364, 0.4696, 0.4578]}, {"w": "at", "b": [0.4759, 0.4364, 0.491, 0.4578]}, {"w": "each", "b": [0.4972, 0.4364, 0.5352, 0.4578]}, {"w": "epoch,", "b": [0.5414, 0.4364, 0.5965, 0.4578]}, {"w": "another", "b": [0.6028, 0.4364, 0.668, 0.4578]}, {"w": "approach", "b": [0.6743, 0.4364, 0.7523, 0.4578]}, {"w": "is", "b": [0.7585, 0.4364, 0.7718, 0.4578]}, {"w": "to", "b": [0.778, 0.4364, 0.795, 0.4578]}, {"w": "shuffle", "b": [0.8013, 0.4364, 0.8572, 0.4578]}, {"w": "the", "b": [0.1429, 0.4555, 0.1692, 0.4769]}, {"w": "training", "b": [0.1745, 0.4555, 0.2415, 0.4769]}, {"w": "set", "b": [0.2468, 0.4555, 0.2697, 0.4769]}, {"w": "(making", "b": [0.275, 0.4555, 0.3455, 0.4769]}, {"w": "sure", "b": [0.3508, 0.4555, 0.3861, 0.4769]}, {"w": "to", "b": [0.3915, 0.4555, 0.4084, 0.4769]}, {"w": "shuffle", "b": [0.4138, 0.4555, 0.4697, 0.4769]}, {"w": "the", "b": [0.475, 0.4555, 0.5014, 0.4769]}, {"w": "input", "b": [0.5067, 0.4555, 0.5516, 0.4769]}, {"w": "features", "b": [0.557, 0.4555, 0.6224, 0.4769]}, {"w": "and", "b": [0.6277, 0.4555, 0.6593, 0.4769]}, {"w": "the", "b": [0.6646, 0.4555, 0.6909, 0.4769]}, {"w": "labels", "b": [0.6963, 0.4555, 0.743, 0.4769]}, {"w": "jointly),", "b": [0.7484, 0.4555, 0.8141, 0.4769]}, {"w": "then", "b": [0.8194, 0.4555, 0.8571, 0.4769]}, {"w": "go", "b": [0.1429, 0.4745, 0.1632, 0.4959]}, {"w": "through", "b": [0.168, 0.4745, 0.2358, 0.4959]}, {"w": "it", "b": [0.2406, 0.4745, 0.2525, 0.4959]}, {"w": "instance", "b": [0.2573, 0.4745, 0.3265, 0.4959]}, {"w": "by", "b": [0.3313, 0.4745, 0.3515, 0.4959]}, {"w": "instance,", "b": [0.3563, 0.4745, 0.4302, 0.4959]}, {"w": "then", "b": [0.435, 0.4745, 0.4728, 0.4959]}, {"w": "shuffle", "b": [0.4776, 0.4745, 0.5334, 0.4959]}, {"w": "it", "b": [0.5383, 0.4745, 0.5502, 0.4959]}, {"w": "again,", "b": [0.555, 0.4745, 0.6048, 0.4959]}, {"w": "and", "b": [0.6096, 0.4745, 0.6411, 0.4959]}, {"w": "so", "b": [0.6459, 0.4745, 0.6642, 0.4959]}, {"w": "on.", "b": [0.669, 0.4745, 0.6958, 0.4959]}, {"w": "However,", "b": [0.7006, 0.4745, 0.7794, 0.4959]}, {"w": "this", "b": [0.7842, 0.4745, 0.8149, 0.4959]}, {"w": "gen‐", "b": [0.8197, 0.4745, 0.8571, 0.4959]}, {"w": "erally", "b": [0.1428, 0.4936, 0.1887, 0.515]}, {"w": "converges", "b": [0.1934, 0.4936, 0.2762, 0.515]}, {"w": "more", "b": [0.281, 0.4936, 0.3252, 0.515]}, {"w": "slowly.", "b": [0.33, 0.4936, 0.3858, 0.515]}]}, {"id": "b_2", "type": "paragraph", "text": "When using Stochastic Gradient Descent, the training instances must be independent and identically distributed (IID), to ensure that the parameters get pulled towards the global optimum, on average. A simple way to ensure this is to shuffle the instances dur‐ ing training (e.g., pick each instance randomly, or shuffle the train‐ ing set at the beginning of each epoch). If you do not do this, for example if the instances are sorted by label, then SGD will start by optimizing for one label, then the next, and so on, and it will not settle close to the global minimum.", "words": [{"w": "When", "b": [0.2714, 0.5355, 0.3186, 0.5551]}, {"w": "using", "b": [0.3271, 0.5355, 0.3686, 0.5551]}, {"w": "Stochastic", "b": [0.3771, 0.5355, 0.4542, 0.5551]}, {"w": "Gradient", "b": [0.4627, 0.5355, 0.5308, 0.5551]}, {"w": "Descent,", "b": [0.5393, 0.5355, 0.6048, 0.5551]}, {"w": "the", "b": [0.6132, 0.5355, 0.6373, 0.5551]}, {"w": "training", "b": [0.6458, 0.5355, 0.707, 0.5551]}, {"w": "instances", "b": [0.7155, 0.5355, 0.7857, 0.5551]}, {"w": "must", "b": [0.2714, 0.5529, 0.3096, 0.5725]}, {"w": "be", "b": [0.317, 0.5529, 0.3348, 0.5725]}, {"w": "independent", "b": [0.3422, 0.5529, 0.4384, 0.5725]}, {"w": "and", "b": [0.4459, 0.5529, 0.4747, 0.5725]}, {"w": "identically", "b": [0.4822, 0.5529, 0.5612, 0.5725]}, {"w": "distributed", "b": [0.5687, 0.5529, 0.6525, 0.5725]}, {"w": "(IID),", "b": [0.66, 0.5529, 0.7045, 0.5725]}, {"w": "to", "b": [0.712, 0.5529, 0.7275, 0.5725]}, {"w": "ensure", "b": [0.7349, 0.5529, 0.7857, 0.5725]}, {"w": "that", "b": [0.2714, 0.5703, 0.3012, 0.5899]}, {"w": "the", "b": [0.3097, 0.5703, 0.3338, 0.5899]}, {"w": "parameters", "b": [0.3424, 0.5703, 0.4278, 0.5899]}, {"w": "get", "b": [0.4363, 0.5703, 0.4591, 0.5899]}, {"w": "pulled", "b": [0.4677, 0.5703, 0.5156, 0.5899]}, {"w": "towards", "b": [0.5241, 0.5703, 0.5851, 0.5899]}, {"w": "the", "b": [0.5937, 0.5703, 0.6178, 0.5899]}, {"w": "global", "b": [0.6263, 0.5703, 0.6726, 0.5899]}, {"w": "optimum,", "b": [0.6811, 0.5703, 0.757, 0.5899]}, {"w": "on", "b": [0.7656, 0.5703, 0.7857, 0.5899]}, {"w": "average.", "b": [0.2714, 0.5877, 0.3331, 0.6073]}, {"w": "A", "b": [0.338, 0.5877, 0.3511, 0.6073]}, {"w": "simple", "b": [0.3559, 0.5877, 0.4062, 0.6073]}, {"w": "way", "b": [0.411, 0.5877, 0.4408, 0.6073]}, {"w": "to", "b": [0.4456, 0.5877, 0.4612, 0.6073]}, {"w": "ensure", "b": [0.466, 0.5877, 0.5168, 0.6073]}, {"w": "this", "b": [0.5216, 0.5877, 0.5497, 0.6073]}, {"w": "is", "b": [0.5545, 0.5877, 0.5666, 0.6073]}, {"w": "to", "b": [0.5714, 0.5877, 0.587, 0.6073]}, {"w": "shuffle", "b": [0.5918, 0.5877, 0.6429, 0.6073]}, {"w": "the", "b": [0.6477, 0.5877, 0.6718, 0.6073]}, {"w": "instances", "b": [0.6766, 0.5877, 0.7469, 0.6073]}, {"w": "dur‐", "b": [0.7517, 0.5877, 0.7857, 0.6073]}, {"w": "ing", "b": [0.2714, 0.6052, 0.2959, 0.6247]}, {"w": "training", "b": [0.3007, 0.6052, 0.3619, 0.6247]}, {"w": "(e.g.,", "b": [0.3667, 0.6052, 0.4033, 0.6247]}, {"w": "pick", "b": [0.4082, 0.6052, 0.4408, 0.6247]}, {"w": "each", "b": [0.4456, 0.6052, 0.4803, 0.6247]}, {"w": "instance", "b": [0.4851, 0.6052, 0.5483, 0.6247]}, {"w": "randomly,", "b": [0.5532, 0.6052, 0.6309, 0.6247]}, {"w": "or", "b": [0.6357, 0.6052, 0.6525, 0.6247]}, {"w": "shuffle", "b": [0.6573, 0.6052, 0.7084, 0.6247]}, {"w": "the", "b": [0.7133, 0.6052, 0.7373, 0.6247]}, {"w": "train‐", "b": [0.7422, 0.6052, 0.7857, 0.6247]}, {"w": "ing", "b": [0.2714, 0.6226, 0.2959, 0.6422]}, {"w": "set", "b": [0.302, 0.6226, 0.3229, 0.6422]}, {"w": "at", "b": [0.329, 0.6226, 0.3428, 0.6422]}, {"w": "the", "b": [0.349, 0.6226, 0.3731, 0.6422]}, {"w": "beginning", "b": [0.3792, 0.6226, 0.4563, 0.6422]}, {"w": "of", "b": [0.4624, 0.6226, 0.4778, 0.6422]}, {"w": "each", "b": [0.4839, 0.6226, 0.5186, 0.6422]}, {"w": "epoch).", "b": [0.5247, 0.6226, 0.5817, 0.6422]}, {"w": "If", "b": [0.5878, 0.6226, 0.6, 0.6422]}, {"w": "you", "b": [0.6061, 0.6226, 0.6347, 0.6422]}, {"w": "do", "b": [0.6408, 0.6226, 0.6606, 0.6422]}, {"w": "not", "b": [0.6667, 0.6226, 0.6927, 0.6422]}, {"w": "do", "b": [0.6988, 0.6226, 0.7186, 0.6422]}, {"w": "this,", "b": [0.7247, 0.6226, 0.7572, 0.6422]}, {"w": "for", "b": [0.7633, 0.6226, 0.7857, 0.6422]}, {"w": "example", "b": [0.2714, 0.64, 0.335, 0.6596]}, {"w": "if", "b": [0.3404, 0.64, 0.3511, 0.6596]}, {"w": "the", "b": [0.3565, 0.64, 0.3806, 0.6596]}, {"w": "instances", "b": [0.3859, 0.64, 0.4562, 0.6596]}, {"w": "are", "b": [0.4616, 0.64, 0.4851, 0.6596]}, {"w": "sorted", "b": [0.4905, 0.64, 0.5382, 0.6596]}, {"w": "by", "b": [0.5436, 0.64, 0.562, 0.6596]}, {"w": "label,", "b": [0.5673, 0.64, 0.6075, 0.6596]}, {"w": "then", "b": [0.6128, 0.64, 0.6473, 0.6596]}, {"w": "SGD", "b": [0.6527, 0.64, 0.6894, 0.6596]}, {"w": "will", "b": [0.6947, 0.64, 0.7225, 0.6596]}, {"w": "start", "b": [0.7279, 0.64, 0.7619, 0.6596]}, {"w": "by", "b": [0.7673, 0.64, 0.7857, 0.6596]}, {"w": "optimizing", "b": [0.2714, 0.6574, 0.3552, 0.677]}, {"w": "for", "b": [0.3613, 0.6574, 0.3837, 0.677]}, {"w": "one", "b": [0.3899, 0.6574, 0.4181, 0.677]}, {"w": "label,", "b": [0.4243, 0.6574, 0.4644, 0.677]}, {"w": "then", "b": [0.4706, 0.6574, 0.5051, 0.677]}, {"w": "the", "b": [0.5112, 0.6574, 0.5353, 0.677]}, {"w": "next,", "b": [0.5415, 0.6574, 0.5791, 0.677]}, {"w": "and", "b": [0.5853, 0.6574, 0.6141, 0.677]}, {"w": "so", "b": [0.6203, 0.6574, 0.637, 0.677]}, {"w": "on,", "b": [0.6431, 0.6574, 0.6676, 0.677]}, {"w": "and", "b": [0.6738, 0.6574, 0.7026, 0.677]}, {"w": "it", "b": [0.7088, 0.6574, 0.7197, 0.677]}, {"w": "will", "b": [0.7258, 0.6574, 0.7536, 0.677]}, {"w": "not", "b": [0.7598, 0.6574, 0.7857, 0.677]}, {"w": "settle", "b": [0.2714, 0.6748, 0.311, 0.6944]}, {"w": "close", "b": [0.3154, 0.6748, 0.353, 0.6944]}, {"w": "to", "b": [0.3574, 0.6748, 0.3729, 0.6944]}, {"w": "the", "b": [0.3772, 0.6748, 0.4013, 0.6944]}, {"w": "global", "b": [0.4056, 0.6748, 0.4519, 0.6944]}, {"w": "minimum.", "b": [0.4562, 0.6748, 0.5378, 0.6944]}]}, {"id": "b_3", "type": "paragraph", "text": "To perform Linear Regression using SGD with Scikit-Learn, you can use the SGDRe gressor class, which defaults to optimizing the squared error cost function. The fol‐ lowing code runs for maximum 1000 epochs (max_iter=1000) or until the loss drops by less than 1e-3 during one epoch (tol=1e-3), starting with a learning rate of 0.1 (eta0=0.1), using the default learning schedule (different from the preceding one), and it does not use any regularization (penalty=None; more details on this shortly):", "words": [{"w": "To", "b": [0.1429, 0.7156, 0.1643, 0.737]}, {"w": "perform", "b": [0.1712, 0.7156, 0.2403, 0.737]}, {"w": "Linear", "b": [0.2472, 0.7156, 0.3011, 0.737]}, {"w": "Regression", "b": [0.308, 0.7156, 0.399, 0.737]}, {"w": "using", "b": [0.4059, 0.7156, 0.4514, 0.737]}, {"w": "SGD", "b": [0.4583, 0.7156, 0.4984, 0.737]}, {"w": "with", "b": [0.5053, 0.7156, 0.5426, 0.737]}, {"w": "Scikit-Learn,", "b": [0.5495, 0.7156, 0.6566, 0.737]}, {"w": "you", "b": [0.6635, 0.7156, 0.6947, 0.737]}, {"w": "can", "b": [0.7016, 0.7156, 0.731, 0.737]}, {"w": "use", "b": [0.7379, 0.7156, 0.7655, 0.737]}, {"w": "the", "b": [0.7724, 0.7156, 0.7987, 0.737]}, {"w": "SGDRe", "b": [0.8056, 0.7188, 0.8551, 0.7339]}, {"w": "gressor", "b": [0.1429, 0.7387, 0.2121, 0.7538]}, {"w": "class,", "b": [0.218, 0.7355, 0.2612, 0.7569]}, {"w": "which", "b": [0.2671, 0.7355, 0.318, 0.7569]}, {"w": "defaults", "b": [0.3239, 0.7355, 0.389, 0.7569]}, {"w": "to", "b": [0.3948, 0.7355, 0.4118, 0.7569]}, {"w": "optimizing", "b": [0.4176, 0.7355, 0.5092, 0.7569]}, {"w": "the", "b": [0.5151, 0.7355, 0.5414, 0.7569]}, {"w": "squared", "b": [0.5473, 0.7355, 0.6133, 0.7569]}, {"w": "error", "b": [0.6192, 0.7355, 0.6619, 0.7569]}, {"w": "cost", "b": [0.6677, 0.7355, 0.7011, 0.7569]}, {"w": "function.", "b": [0.707, 0.7355, 0.7831, 0.7569]}, {"w": "The", "b": [0.789, 0.7355, 0.8218, 0.7569]}, {"w": "fol‐", "b": [0.8277, 0.7355, 0.8571, 0.7569]}, {"w": "lowing", "b": [0.1429, 0.7555, 0.1997, 0.7769]}, {"w": "code", "b": [0.2052, 0.7555, 0.2445, 0.7769]}, {"w": "runs", "b": [0.2499, 0.7555, 0.2877, 0.7769]}, {"w": "for", "b": [0.2932, 0.7555, 0.3177, 0.7769]}, {"w": "maximum", "b": [0.3231, 0.7555, 0.4096, 0.7769]}, {"w": "1000", "b": [0.415, 0.7555, 0.455, 0.7769]}, {"w": "epochs", "b": [0.4604, 0.7555, 0.5184, 0.7769]}, {"w": "(max_iter=1000)", "b": [0.5238, 0.7555, 0.6669, 0.7769]}, {"w": "or", "b": [0.6723, 0.7555, 0.6907, 0.7769]}, {"w": "until", "b": [0.6961, 0.7555, 0.7354, 0.7769]}, {"w": "the", "b": [0.7408, 0.7555, 0.7672, 0.7769]}, {"w": "loss", "b": [0.7726, 0.7555, 0.8038, 0.7769]}, {"w": "drops", "b": [0.8092, 0.7555, 0.8571, 0.7769]}, {"w": "by", "b": [0.1429, 0.7754, 0.163, 0.7968]}, {"w": "less", "b": [0.1703, 0.7754, 0.1997, 0.7968]}, {"w": "than", "b": [0.2069, 0.7754, 0.245, 0.7968]}, {"w": "1e-3", "b": [0.2522, 0.7754, 0.2885, 0.7968]}, {"w": "during", "b": [0.2957, 0.7754, 0.3523, 0.7968]}, {"w": "one", "b": [0.3595, 0.7754, 0.3904, 0.7968]}, {"w": "epoch", "b": [0.3976, 0.7754, 0.448, 0.7968]}, {"w": "(tol=1e-3),", "b": [0.4552, 0.7754, 0.5536, 0.7968]}, {"w": "starting", "b": [0.5608, 0.7754, 0.6248, 0.7968]}, {"w": "with", "b": [0.632, 0.7754, 0.6694, 0.7968]}, {"w": "a", "b": [0.6766, 0.7754, 0.6858, 0.7968]}, {"w": "learning", "b": [0.693, 0.7754, 0.7622, 0.7968]}, {"w": "rate", "b": [0.7694, 0.7754, 0.8011, 0.7968]}, {"w": "of", "b": [0.8084, 0.7754, 0.8251, 0.7968]}, {"w": "0.1", "b": [0.8324, 0.7754, 0.8572, 0.7968]}, {"w": "(eta0=0.1),", "b": [0.1429, 0.7954, 0.2412, 0.8168]}, {"w": "using", "b": [0.2484, 0.7954, 0.2939, 0.8168]}, {"w": "the", "b": [0.3011, 0.7954, 0.3274, 0.8168]}, {"w": "default", "b": [0.3347, 0.7954, 0.3921, 0.8168]}, {"w": "learning", "b": [0.3994, 0.7954, 0.4685, 0.8168]}, {"w": "schedule", "b": [0.4758, 0.7954, 0.5484, 0.8168]}, {"w": "(different", "b": [0.5556, 0.7954, 0.6345, 0.8168]}, {"w": "from", "b": [0.6418, 0.7954, 0.6834, 0.8168]}, {"w": "the", "b": [0.6906, 0.7954, 0.7169, 0.8168]}, {"w": "preceding", "b": [0.7242, 0.7954, 0.8071, 0.8168]}, {"w": "one),", "b": [0.8143, 0.7954, 0.8571, 0.8168]}, {"w": "and", "b": [0.1429, 0.8153, 0.1744, 0.8367]}, {"w": "it", "b": [0.1791, 0.8153, 0.1911, 0.8367]}, {"w": "does", "b": [0.1958, 0.8153, 0.2339, 0.8367]}, {"w": "not", "b": [0.2386, 0.8153, 0.267, 0.8367]}, {"w": "use", "b": [0.2717, 0.8153, 0.2993, 0.8367]}, {"w": "any", "b": [0.304, 0.8153, 0.3337, 0.8367]}, {"w": "regularization", "b": [0.3384, 0.8153, 0.455, 0.8367]}, {"w": "(penalty=None;", "b": [0.4597, 0.8153, 0.5904, 0.8367]}, {"w": "more", "b": [0.5951, 0.8153, 0.6394, 0.8367]}, {"w": "details", "b": [0.6441, 0.8153, 0.698, 0.8367]}, {"w": "on", "b": [0.7027, 0.8153, 0.7248, 0.8367]}, {"w": "this", "b": [0.7295, 0.8153, 0.7602, 0.8367]}, {"w": "shortly):", "b": [0.7649, 0.8153, 0.8352, 0.8367]}]}, {"id": "b_4", "type": "paragraph", "text": "from sklearn.linear_model import SGDRegressor sgd_reg = SGDRegressor(max_iter=1000, tol=1e-3, penalty=None, eta0=0.1) sgd_reg.fit(X, y.ravel())", "words": [{"w": "from", "b": [0.1766, 0.8473, 0.2103, 0.8601]}, {"w": "sklearn.linear_model", "b": [0.2188, 0.8473, 0.3874, 0.8601]}, {"w": "import", "b": [0.3958, 0.8473, 0.4464, 0.8601]}, {"w": "SGDRegressor", "b": [0.4549, 0.8473, 0.5561, 0.8601]}, {"w": "sgd_reg", "b": [0.1766, 0.8627, 0.2356, 0.8756]}, {"w": "=", "b": [0.2441, 0.8627, 0.2525, 0.8756]}, {"w": "SGDRegressor(max_iter=1000,", "b": [0.2609, 0.8627, 0.4886, 0.8756]}, {"w": "tol=1e-3,", "b": [0.497, 0.8627, 0.5729, 0.8756]}, {"w": "penalty=None,", "b": [0.5814, 0.8627, 0.691, 0.8756]}, {"w": "eta0=0.1)", "b": [0.6994, 0.8627, 0.7753, 0.8756]}, {"w": "sgd_reg.fit(X,", "b": [0.1766, 0.8781, 0.2946, 0.891]}, {"w": "y.ravel())", "b": [0.3031, 0.8781, 0.3874, 0.891]}]}, {"id": "b_5", "type": "paragraph", "text": "128 | Chapter 4: Training Models", "words": [{"w": "128", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 155, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Once again, you find a solution quite close to the one returned by the Normal Equa‐ tion:", "words": [{"w": "Once", "b": [0.1429, 0.0791, 0.1875, 0.1005]}, {"w": "again,", "b": [0.1931, 0.0791, 0.2429, 0.1005]}, {"w": "you", "b": [0.2485, 0.0791, 0.2798, 0.1005]}, {"w": "find", "b": [0.2854, 0.0791, 0.3196, 0.1005]}, {"w": "a", "b": [0.3252, 0.0791, 0.3343, 0.1005]}, {"w": "solution", "b": [0.34, 0.0791, 0.4085, 0.1005]}, {"w": "quite", "b": [0.4142, 0.0791, 0.4567, 0.1005]}, {"w": "close", "b": [0.4623, 0.0791, 0.5035, 0.1005]}, {"w": "to", "b": [0.5092, 0.0791, 0.5261, 0.1005]}, {"w": "the", "b": [0.5318, 0.0791, 0.5581, 0.1005]}, {"w": "one", "b": [0.5637, 0.0791, 0.5946, 0.1005]}, {"w": "returned", "b": [0.6002, 0.0791, 0.6732, 0.1005]}, {"w": "by", "b": [0.6789, 0.0791, 0.699, 0.1005]}, {"w": "the", "b": [0.7046, 0.0791, 0.731, 0.1005]}, {"w": "Normal", "b": [0.7366, 0.0791, 0.8014, 0.1005]}, {"w": "Equa‐", "b": [0.807, 0.0791, 0.8571, 0.1005]}, {"w": "tion:", "b": [0.1429, 0.0981, 0.1816, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": ">>> sgd_reg.intercept_, sgd_reg.coef_ (array([4.24365286]), array([2.8250878]))", "words": [{"w": ">>>", "b": [0.1766, 0.1301, 0.2019, 0.1429]}, {"w": "sgd_reg.intercept_,", "b": [0.2103, 0.1301, 0.3705, 0.1429]}, {"w": "sgd_reg.coef_", "b": [0.379, 0.1301, 0.4886, 0.1429]}, {"w": "(array([4.24365286]),", "b": [0.1766, 0.1455, 0.3537, 0.1584]}, {"w": "array([2.8250878]))", "b": [0.3621, 0.1455, 0.5223, 0.1584]}]}, {"id": "b_2", "type": "equation", "text": "Mini-batch Gradient Descent", "words": [{"w": "Mini-batch", "b": [0.1429, 0.1722, 0.2551, 0.2008]}, {"w": "Gradient", "b": [0.26, 0.1722, 0.3498, 0.2008]}, {"w": "Descent", "b": [0.3547, 0.1722, 0.4361, 0.2008]}]}, {"id": "b_3", "type": "paragraph", "text": "The last Gradient Descent algorithm we will look at is called Mini-batch Gradient Descent. It is quite simple to understand once you know Batch and Stochastic Gradi‐ ent Descent: at each step, instead of computing the gradients based on the full train‐ ing set (as in Batch GD) or based on just one instance (as in Stochastic GD), Mini- batch GD computes the gradients on small random sets of instances called mini- batches. The main advantage of Mini-batch GD over Stochastic GD is that you can get a performance boost from hardware optimization of matrix operations, especially when using GPUs.", "words": [{"w": "The", "b": [0.1429, 0.2067, 0.1757, 0.2281]}, {"w": "last", "b": [0.1839, 0.2067, 0.2123, 0.2281]}, {"w": "Gradient", "b": [0.2206, 0.2067, 0.2951, 0.2281]}, {"w": "Descent", "b": [0.3033, 0.2067, 0.3702, 0.2281]}, {"w": "algorithm", "b": [0.3784, 0.2067, 0.461, 0.2281]}, {"w": "we", "b": [0.4692, 0.2067, 0.4924, 0.2281]}, {"w": "will", "b": [0.5006, 0.2067, 0.531, 0.2281]}, {"w": "look", "b": [0.5392, 0.2067, 0.5761, 0.2281]}, {"w": "at", "b": [0.5843, 0.2067, 0.5994, 0.2281]}, {"w": "is", "b": [0.6076, 0.2067, 0.6208, 0.2281]}, {"w": "called", "b": [0.629, 0.2067, 0.6774, 0.2281]}, {"w": "Mini-batch", "b": [0.6856, 0.2065, 0.7764, 0.2281]}, {"w": "Gradient", "b": [0.7847, 0.2065, 0.8572, 0.2281]}, {"w": "Descent.", "b": [0.1429, 0.2255, 0.2109, 0.2471]}, {"w": "It", "b": [0.2166, 0.2257, 0.2292, 0.2471]}, {"w": "is", "b": [0.2349, 0.2257, 0.2482, 0.2471]}, {"w": "quite", "b": [0.2538, 0.2257, 0.2963, 0.2471]}, {"w": "simple", "b": [0.302, 0.2257, 0.357, 0.2471]}, {"w": "to", "b": [0.3626, 0.2257, 0.3796, 0.2471]}, {"w": "understand", "b": [0.3853, 0.2257, 0.4809, 0.2471]}, {"w": "once", "b": [0.4866, 0.2257, 0.5262, 0.2471]}, {"w": "you", "b": [0.5319, 0.2257, 0.5632, 0.2471]}, {"w": "know", "b": [0.5689, 0.2257, 0.6155, 0.2471]}, {"w": "Batch", "b": [0.6212, 0.2257, 0.6685, 0.2471]}, {"w": "and", "b": [0.6741, 0.2257, 0.7057, 0.2471]}, {"w": "Stochastic", "b": [0.7114, 0.2257, 0.7957, 0.2471]}, {"w": "Gradi‐", "b": [0.8014, 0.2257, 0.8571, 0.2471]}, {"w": "ent", "b": [0.1429, 0.2448, 0.1691, 0.2662]}, {"w": "Descent:", "b": [0.175, 0.2448, 0.2466, 0.2662]}, {"w": "at", "b": [0.2525, 0.2448, 0.2676, 0.2662]}, {"w": "each", "b": [0.2736, 0.2448, 0.3115, 0.2662]}, {"w": "step,", "b": [0.3175, 0.2448, 0.3554, 0.2662]}, {"w": "instead", "b": [0.3613, 0.2448, 0.4213, 0.2662]}, {"w": "of", "b": [0.4272, 0.2448, 0.444, 0.2662]}, {"w": "computing", "b": [0.45, 0.2448, 0.5412, 0.2662]}, {"w": "the", "b": [0.5471, 0.2448, 0.5734, 0.2662]}, {"w": "gradients", "b": [0.5794, 0.2448, 0.6564, 0.2662]}, {"w": "based", "b": [0.6624, 0.2448, 0.7096, 0.2662]}, {"w": "on", "b": [0.7156, 0.2448, 0.7376, 0.2662]}, {"w": "the", "b": [0.7435, 0.2448, 0.7699, 0.2662]}, {"w": "full", "b": [0.7758, 0.2448, 0.8036, 0.2662]}, {"w": "train‐", "b": [0.8095, 0.2448, 0.8571, 0.2662]}, {"w": "ing", "b": [0.1428, 0.2638, 0.1696, 0.2852]}, {"w": "set", "b": [0.1761, 0.2638, 0.199, 0.2852]}, {"w": "(as", "b": [0.2055, 0.2638, 0.2295, 0.2852]}, {"w": "in", "b": [0.2361, 0.2638, 0.2531, 0.2852]}, {"w": "Batch", "b": [0.2596, 0.2638, 0.3069, 0.2852]}, {"w": "GD)", "b": [0.3135, 0.2638, 0.3509, 0.2852]}, {"w": "or", "b": [0.3575, 0.2638, 0.3758, 0.2852]}, {"w": "based", "b": [0.3824, 0.2638, 0.4296, 0.2852]}, {"w": "on", "b": [0.4362, 0.2638, 0.4582, 0.2852]}, {"w": "just", "b": [0.4647, 0.2638, 0.4951, 0.2852]}, {"w": "one", "b": [0.5017, 0.2638, 0.5326, 0.2852]}, {"w": "instance", "b": [0.5391, 0.2638, 0.6083, 0.2852]}, {"w": "(as", "b": [0.6149, 0.2638, 0.6389, 0.2852]}, {"w": "in", "b": [0.6454, 0.2638, 0.6624, 0.2852]}, {"w": "Stochastic", "b": [0.669, 0.2638, 0.7533, 0.2852]}, {"w": "GD),", "b": [0.7599, 0.2638, 0.802, 0.2852]}, {"w": "Mini-", "b": [0.8086, 0.2638, 0.8571, 0.2852]}, {"w": "batch", "b": [0.1429, 0.2829, 0.1885, 0.3043]}, {"w": "GD", "b": [0.1971, 0.2829, 0.2273, 0.3043]}, {"w": "computes", "b": [0.2359, 0.2829, 0.3169, 0.3043]}, {"w": "the", "b": [0.3255, 0.2829, 0.3518, 0.3043]}, {"w": "gradients", "b": [0.3604, 0.2829, 0.4375, 0.3043]}, {"w": "on", "b": [0.4461, 0.2829, 0.4681, 0.3043]}, {"w": "small", "b": [0.4768, 0.2829, 0.5212, 0.3043]}, {"w": "random", "b": [0.5298, 0.2829, 0.5967, 0.3043]}, {"w": "sets", "b": [0.6054, 0.2829, 0.6359, 0.3043]}, {"w": "of", "b": [0.6445, 0.2829, 0.6613, 0.3043]}, {"w": "instances", "b": [0.6699, 0.2829, 0.7467, 0.3043]}, {"w": "called", "b": [0.7553, 0.2829, 0.8037, 0.3043]}, {"w": "mini-", "b": [0.8123, 0.2826, 0.8571, 0.3043]}, {"w": "batches.", "b": [0.1429, 0.3017, 0.207, 0.3233]}, {"w": "The", "b": [0.214, 0.3019, 0.2468, 0.3233]}, {"w": "main", "b": [0.2538, 0.3019, 0.297, 0.3233]}, {"w": "advantage", "b": [0.304, 0.3019, 0.3881, 0.3233]}, {"w": "of", "b": [0.3951, 0.3019, 0.4119, 0.3233]}, {"w": "Mini-batch", "b": [0.4189, 0.3019, 0.513, 0.3233]}, {"w": "GD", "b": [0.5201, 0.3019, 0.5503, 0.3233]}, {"w": "over", "b": [0.5573, 0.3019, 0.5941, 0.3233]}, {"w": "Stochastic", "b": [0.6011, 0.3019, 0.6855, 0.3233]}, {"w": "GD", "b": [0.6925, 0.3019, 0.7227, 0.3233]}, {"w": "is", "b": [0.7297, 0.3019, 0.7429, 0.3233]}, {"w": "that", "b": [0.7499, 0.3019, 0.7825, 0.3233]}, {"w": "you", "b": [0.7895, 0.3019, 0.8208, 0.3233]}, {"w": "can", "b": [0.8278, 0.3019, 0.8571, 0.3233]}, {"w": "get", "b": [0.1429, 0.3209, 0.1678, 0.3424]}, {"w": "a", "b": [0.1732, 0.3209, 0.1823, 0.3424]}, {"w": "performance", "b": [0.1877, 0.3209, 0.295, 0.3424]}, {"w": "boost", "b": [0.3003, 0.3209, 0.3462, 0.3424]}, {"w": "from", "b": [0.3515, 0.3209, 0.3931, 0.3424]}, {"w": "hardware", "b": [0.3985, 0.3209, 0.4775, 0.3424]}, {"w": "optimization", "b": [0.4828, 0.3209, 0.5904, 0.3424]}, {"w": "of", "b": [0.5958, 0.3209, 0.6126, 0.3424]}, {"w": "matrix", "b": [0.6179, 0.3209, 0.6733, 0.3424]}, {"w": "operations,", "b": [0.6786, 0.3209, 0.7719, 0.3424]}, {"w": "especially", "b": [0.7772, 0.3209, 0.8571, 0.3424]}, {"w": "when", "b": [0.1429, 0.34, 0.1885, 0.3614]}, {"w": "using", "b": [0.1932, 0.34, 0.2387, 0.3614]}, {"w": "GPUs.", "b": [0.2434, 0.34, 0.2967, 0.3614]}]}, {"id": "b_4", "type": "paragraph", "text": "The algorithm’s progress in parameter space is less erratic than with SGD, especially with fairly large mini-batches. As a result, Mini-batch GD will end up walking around a bit closer to the minimum than SGD. But, on the other hand, it may be harder for it to escape from local minima (in the case of problems that suffer from local minima, unlike Linear Regression as we saw earlier). Figure 4-11 shows the paths taken by the three Gradient Descent algorithms in parameter space during training. They all end up near the minimum, but Batch GD’s path actually stops at the minimum, while both Stochastic GD and Mini-batch GD continue to walk around. However, don’t forget that Batch GD takes a lot of time to take each step, and Stochas‐ tic GD and Mini-batch GD would also reach the minimum if you used a good learn‐ ing schedule.", "words": [{"w": "The", "b": [0.1429, 0.3681, 0.1757, 0.3895]}, {"w": "algorithm’s", "b": [0.182, 0.3681, 0.2732, 0.3895]}, {"w": "progress", "b": [0.2795, 0.3681, 0.3504, 0.3895]}, {"w": "in", "b": [0.3567, 0.3681, 0.3737, 0.3895]}, {"w": "parameter", "b": [0.38, 0.3681, 0.4658, 0.3895]}, {"w": "space", "b": [0.472, 0.3681, 0.5174, 0.3895]}, {"w": "is", "b": [0.5237, 0.3681, 0.5369, 0.3895]}, {"w": "less", "b": [0.5432, 0.3681, 0.5726, 0.3895]}, {"w": "erratic", "b": [0.5789, 0.3681, 0.6327, 0.3895]}, {"w": "than", "b": [0.639, 0.3681, 0.677, 0.3895]}, {"w": "with", "b": [0.6833, 0.3681, 0.7207, 0.3895]}, {"w": "SGD,", "b": [0.7269, 0.3681, 0.7709, 0.3895]}, {"w": "especially", "b": [0.7772, 0.3681, 0.8572, 0.3895]}, {"w": "with", "b": [0.1429, 0.3872, 0.1802, 0.4086]}, {"w": "fairly", "b": [0.1904, 0.3872, 0.2338, 0.4086]}, {"w": "large", "b": [0.244, 0.3872, 0.2848, 0.4086]}, {"w": "mini-batches.", "b": [0.295, 0.3872, 0.4089, 0.4086]}, {"w": "As", "b": [0.4191, 0.3872, 0.4411, 0.4086]}, {"w": "a", "b": [0.4513, 0.3872, 0.4604, 0.4086]}, {"w": "result,", "b": [0.4706, 0.3872, 0.5223, 0.4086]}, {"w": "Mini-batch", "b": [0.5325, 0.3872, 0.6266, 0.4086]}, {"w": "GD", "b": [0.6368, 0.3872, 0.667, 0.4086]}, {"w": "will", "b": [0.6772, 0.3872, 0.7076, 0.4086]}, {"w": "end", "b": [0.7178, 0.3872, 0.749, 0.4086]}, {"w": "up", "b": [0.7592, 0.3872, 0.7812, 0.4086]}, {"w": "walking", "b": [0.7914, 0.3872, 0.8571, 0.4086]}, {"w": "around", "b": [0.1429, 0.4062, 0.2038, 0.4276]}, {"w": "a", "b": [0.2114, 0.4062, 0.2205, 0.4276]}, {"w": "bit", "b": [0.2281, 0.4062, 0.2506, 0.4276]}, {"w": "closer", "b": [0.2582, 0.4062, 0.3072, 0.4276]}, {"w": "to", "b": [0.3147, 0.4062, 0.3317, 0.4276]}, {"w": "the", "b": [0.3393, 0.4062, 0.3656, 0.4276]}, {"w": "minimum", "b": [0.3732, 0.4062, 0.4576, 0.4276]}, {"w": "than", "b": [0.4652, 0.4062, 0.5032, 0.4276]}, {"w": "SGD.", "b": [0.5108, 0.4062, 0.5548, 0.4276]}, {"w": "But,", "b": [0.5624, 0.4062, 0.5968, 0.4276]}, {"w": "on", "b": [0.6044, 0.4062, 0.6264, 0.4276]}, {"w": "the", "b": [0.634, 0.4062, 0.6603, 0.4276]}, {"w": "other", "b": [0.6679, 0.4062, 0.7126, 0.4276]}, {"w": "hand,", "b": [0.7202, 0.4062, 0.7676, 0.4276]}, {"w": "it", "b": [0.7752, 0.4062, 0.7871, 0.4276]}, {"w": "may", "b": [0.7947, 0.4062, 0.8301, 0.4276]}, {"w": "be", "b": [0.8377, 0.4062, 0.8571, 0.4276]}, {"w": "harder", "b": [0.1428, 0.4253, 0.1984, 0.4467]}, {"w": "for", "b": [0.2053, 0.4253, 0.2298, 0.4467]}, {"w": "it", "b": [0.2366, 0.4253, 0.2486, 0.4467]}, {"w": "to", "b": [0.2554, 0.4253, 0.2724, 0.4467]}, {"w": "escape", "b": [0.2792, 0.4253, 0.3331, 0.4467]}, {"w": "from", "b": [0.3399, 0.4253, 0.3815, 0.4467]}, {"w": "local", "b": [0.3883, 0.4253, 0.4275, 0.4467]}, {"w": "minima", "b": [0.4343, 0.4253, 0.5001, 0.4467]}, {"w": "(in", "b": [0.507, 0.4253, 0.5312, 0.4467]}, {"w": "the", "b": [0.538, 0.4253, 0.5643, 0.4467]}, {"w": "case", "b": [0.5712, 0.4253, 0.6056, 0.4467]}, {"w": "of", "b": [0.6125, 0.4253, 0.6293, 0.4467]}, {"w": "problems", "b": [0.6361, 0.4253, 0.7148, 0.4467]}, {"w": "that", "b": [0.7217, 0.4253, 0.7542, 0.4467]}, {"w": "suffer", "b": [0.7611, 0.4253, 0.8087, 0.4467]}, {"w": "from", "b": [0.8155, 0.4253, 0.8571, 0.4467]}, {"w": "local", "b": [0.1429, 0.4443, 0.182, 0.4657]}, {"w": "minima,", "b": [0.1905, 0.4443, 0.2611, 0.4657]}, {"w": "unlike", "b": [0.2696, 0.4443, 0.3221, 0.4657]}, {"w": "Linear", "b": [0.3307, 0.4443, 0.3846, 0.4657]}, {"w": "Regression", "b": [0.3931, 0.4443, 0.4841, 0.4657]}, {"w": "as", "b": [0.4927, 0.4443, 0.5094, 0.4657]}, {"w": "we", "b": [0.518, 0.4443, 0.5411, 0.4657]}, {"w": "saw", "b": [0.5496, 0.4443, 0.5803, 0.4657]}, {"w": "earlier).", "b": [0.5888, 0.4443, 0.654, 0.4657]}, {"w": "Figure", "b": [0.6625, 0.4443, 0.7165, 0.4657]}, {"w": "4-11", "b": [0.725, 0.4443, 0.7624, 0.4657]}, {"w": "shows", "b": [0.771, 0.4443, 0.8223, 0.4657]}, {"w": "the", "b": [0.8308, 0.4443, 0.8571, 0.4657]}, {"w": "paths", "b": [0.1429, 0.4634, 0.1876, 0.4848]}, {"w": "taken", "b": [0.1965, 0.4634, 0.2426, 0.4848]}, {"w": "by", "b": [0.2515, 0.4634, 0.2716, 0.4848]}, {"w": "the", "b": [0.2805, 0.4634, 0.3068, 0.4848]}, {"w": "three", "b": [0.3157, 0.4634, 0.3586, 0.4848]}, {"w": "Gradient", "b": [0.3675, 0.4634, 0.4421, 0.4848]}, {"w": "Descent", "b": [0.451, 0.4634, 0.5178, 0.4848]}, {"w": "algorithms", "b": [0.5267, 0.4634, 0.617, 0.4848]}, {"w": "in", "b": [0.6258, 0.4634, 0.6428, 0.4848]}, {"w": "parameter", "b": [0.6517, 0.4634, 0.7375, 0.4848]}, {"w": "space", "b": [0.7464, 0.4634, 0.7917, 0.4848]}, {"w": "during", "b": [0.8006, 0.4634, 0.8571, 0.4848]}, {"w": "training.", "b": [0.1429, 0.4824, 0.2145, 0.5038]}, {"w": "They", "b": [0.2194, 0.4824, 0.2618, 0.5038]}, {"w": "all", "b": [0.2667, 0.4824, 0.2864, 0.5038]}, {"w": "end", "b": [0.2913, 0.4824, 0.3225, 0.5038]}, {"w": "up", "b": [0.3274, 0.4824, 0.3494, 0.5038]}, {"w": "near", "b": [0.3543, 0.4824, 0.3914, 0.5038]}, {"w": "the", "b": [0.3963, 0.4824, 0.4226, 0.5038]}, {"w": "minimum,", "b": [0.4275, 0.4824, 0.5166, 0.5038]}, {"w": "but", "b": [0.5215, 0.4824, 0.5495, 0.5038]}, {"w": "Batch", "b": [0.5544, 0.4824, 0.6017, 0.5038]}, {"w": "GD’s", "b": [0.6066, 0.4824, 0.6463, 0.5038]}, {"w": "path", "b": [0.6512, 0.4824, 0.6884, 0.5038]}, {"w": "actually", "b": [0.6932, 0.4824, 0.7579, 0.5038]}, {"w": "stops", "b": [0.7628, 0.4824, 0.8059, 0.5038]}, {"w": "at", "b": [0.8108, 0.4824, 0.8259, 0.5038]}, {"w": "the", "b": [0.8308, 0.4824, 0.8571, 0.5038]}, {"w": "minimum,", "b": [0.1429, 0.5014, 0.232, 0.5229]}, {"w": "while", "b": [0.2389, 0.5014, 0.284, 0.5229]}, {"w": "both", "b": [0.2909, 0.5014, 0.3296, 0.5229]}, {"w": "Stochastic", "b": [0.3365, 0.5014, 0.4208, 0.5229]}, {"w": "GD", "b": [0.4277, 0.5014, 0.458, 0.5229]}, {"w": "and", "b": [0.4649, 0.5014, 0.4964, 0.5229]}, {"w": "Mini-batch", "b": [0.5033, 0.5014, 0.5975, 0.5229]}, {"w": "GD", "b": [0.6044, 0.5014, 0.6346, 0.5229]}, {"w": "continue", "b": [0.6415, 0.5014, 0.7148, 0.5229]}, {"w": "to", "b": [0.7216, 0.5014, 0.7386, 0.5229]}, {"w": "walk", "b": [0.7455, 0.5014, 0.7845, 0.5229]}, {"w": "around.", "b": [0.7914, 0.5014, 0.8572, 0.5229]}, {"w": "However,", "b": [0.1429, 0.5205, 0.2217, 0.5419]}, {"w": "don’t", "b": [0.2264, 0.5205, 0.268, 0.5419]}, {"w": "forget", "b": [0.2728, 0.5205, 0.3223, 0.5419]}, {"w": "that", "b": [0.327, 0.5205, 0.3596, 0.5419]}, {"w": "Batch", "b": [0.3643, 0.5205, 0.4116, 0.5419]}, {"w": "GD", "b": [0.4163, 0.5205, 0.4465, 0.5419]}, {"w": "takes", "b": [0.4513, 0.5205, 0.4936, 0.5419]}, {"w": "a", "b": [0.4983, 0.5205, 0.5075, 0.5419]}, {"w": "lot", "b": [0.5122, 0.5205, 0.5344, 0.5419]}, {"w": "of", "b": [0.5392, 0.5205, 0.556, 0.5419]}, {"w": "time", "b": [0.5607, 0.5205, 0.5985, 0.5419]}, {"w": "to", "b": [0.6033, 0.5205, 0.6203, 0.5419]}, {"w": "take", "b": [0.625, 0.5205, 0.6597, 0.5419]}, {"w": "each", "b": [0.6644, 0.5205, 0.7023, 0.5419]}, {"w": "step,", "b": [0.7071, 0.5205, 0.745, 0.5419]}, {"w": "and", "b": [0.7497, 0.5205, 0.7813, 0.5419]}, {"w": "Stochas‐", "b": [0.786, 0.5205, 0.857, 0.5419]}, {"w": "tic", "b": [0.1429, 0.5395, 0.1636, 0.561]}, {"w": "GD", "b": [0.1692, 0.5395, 0.1994, 0.561]}, {"w": "and", "b": [0.205, 0.5395, 0.2365, 0.561]}, {"w": "Mini-batch", "b": [0.2421, 0.5395, 0.3362, 0.561]}, {"w": "GD", "b": [0.3418, 0.5395, 0.372, 0.561]}, {"w": "would", "b": [0.3776, 0.5395, 0.4298, 0.561]}, {"w": "also", "b": [0.4354, 0.5395, 0.4681, 0.561]}, {"w": "reach", "b": [0.4736, 0.5395, 0.5193, 0.561]}, {"w": "the", "b": [0.5249, 0.5395, 0.5512, 0.561]}, {"w": "minimum", "b": [0.5568, 0.5395, 0.6412, 0.561]}, {"w": "if", "b": [0.6468, 0.5395, 0.6585, 0.561]}, {"w": "you", "b": [0.6641, 0.5395, 0.6953, 0.561]}, {"w": "used", "b": [0.7009, 0.5395, 0.7395, 0.561]}, {"w": "a", "b": [0.745, 0.5395, 0.7542, 0.561]}, {"w": "good", "b": [0.7598, 0.5395, 0.8018, 0.561]}, {"w": "learn‐", "b": [0.8073, 0.5395, 0.8571, 0.561]}, {"w": "ing", "b": [0.1429, 0.5586, 0.1696, 0.58]}, {"w": "schedule.", "b": [0.1743, 0.5586, 0.2517, 0.58]}]}, {"id": "b_5", "type": "equation", "text": "Figure 4-11. Gradient Descent paths in parameter space", "words": [{"w": "Figure", "b": [0.1429, 0.8289, 0.1943, 0.8505]}, {"w": "4-11.", "b": [0.1991, 0.8289, 0.2407, 0.8505]}, {"w": "Gradient", "b": [0.2455, 0.8289, 0.318, 0.8505]}, {"w": "Descent", "b": [0.3227, 0.8289, 0.3861, 0.8505]}, {"w": "paths", "b": [0.3908, 0.8289, 0.4345, 0.8505]}, {"w": "in", "b": [0.4393, 0.8289, 0.4558, 0.8505]}, {"w": "parameter", "b": [0.4605, 0.8289, 0.5441, 0.8505]}, {"w": "space", "b": [0.5489, 0.8289, 0.592, 0.8505]}]}, {"id": "b_6", "type": "paragraph", "text": "Gradient Descent | 129", "words": [{"w": "Gradient", "b": [0.6954, 0.9225, 0.7466, 0.9388]}, {"w": "Descent", "b": [0.7494, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "129", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 156, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "8 While the Normal Equation can only perform Linear Regression, the Gradient Descent algorithms can be used to train many other models, as we will see.", "words": [{"w": "8", "b": [0.1451, 0.8416, 0.1518, 0.8559]}, {"w": "While", "b": [0.1587, 0.8401, 0.1976, 0.8565]}, {"w": "the", "b": [0.2012, 0.8401, 0.2213, 0.8565]}, {"w": "Normal", "b": [0.2249, 0.8401, 0.2743, 0.8565]}, {"w": "Equation", "b": [0.2779, 0.8401, 0.336, 0.8565]}, {"w": "can", "b": [0.3396, 0.8401, 0.3619, 0.8565]}, {"w": "only", "b": [0.3655, 0.8401, 0.3936, 0.8565]}, {"w": "perform", "b": [0.3972, 0.8401, 0.4499, 0.8565]}, {"w": "Linear", "b": [0.4535, 0.8401, 0.4945, 0.8565]}, {"w": "Regression,", "b": [0.4981, 0.8401, 0.5711, 0.8565]}, {"w": "the", "b": [0.5747, 0.8401, 0.5948, 0.8565]}, {"w": "Gradient", "b": [0.5984, 0.8401, 0.6552, 0.8565]}, {"w": "Descent", "b": [0.6588, 0.8401, 0.7097, 0.8565]}, {"w": "algorithms", "b": [0.7133, 0.8401, 0.7821, 0.8565]}, {"w": "can", "b": [0.7857, 0.8401, 0.8081, 0.8565]}, {"w": "be", "b": [0.8117, 0.8401, 0.8265, 0.8565]}, {"w": "used", "b": [0.1587, 0.8553, 0.1881, 0.8716]}, {"w": "to", "b": [0.1917, 0.8553, 0.2047, 0.8716]}, {"w": "train", "b": [0.2083, 0.8553, 0.2389, 0.8716]}, {"w": "many", "b": [0.2425, 0.8553, 0.2781, 0.8716]}, {"w": "other", "b": [0.2817, 0.8553, 0.3157, 0.8716]}, {"w": "models,", "b": [0.3193, 0.8553, 0.369, 0.8716]}, {"w": "as", "b": [0.3726, 0.8553, 0.3854, 0.8716]}, {"w": "we", "b": [0.389, 0.8553, 0.4066, 0.8716]}, {"w": "will", "b": [0.4102, 0.8553, 0.4334, 0.8716]}, {"w": "see.", "b": [0.437, 0.8553, 0.4599, 0.8716]}]}, {"id": "b_1", "type": "equation", "text": "9 A quadratic equation is of the form y = ax2 + bx + c.", "words": [{"w": "9", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "A", "b": [0.1587, 0.8749, 0.1697, 0.8912]}, {"w": "quadratic", "b": [0.1733, 0.8749, 0.2336, 0.8912]}, {"w": "equation", "b": [0.2372, 0.8749, 0.293, 0.8912]}, {"w": "is", "b": [0.2966, 0.8749, 0.3067, 0.8912]}, {"w": "of", "b": [0.3103, 0.8749, 0.3231, 0.8912]}, {"w": "the", "b": [0.3267, 0.8749, 0.3467, 0.8912]}, {"w": "form", "b": [0.3503, 0.8749, 0.382, 0.8912]}, {"w": "y", "b": [0.3856, 0.8748, 0.3926, 0.8912]}, {"w": "=", "b": [0.3962, 0.8749, 0.4054, 0.8912]}, {"w": "ax2", "b": [0.409, 0.8734, 0.4303, 0.8912]}, {"w": "+", "b": [0.4339, 0.8749, 0.4431, 0.8912]}, {"w": "bx", "b": [0.4467, 0.8748, 0.4617, 0.8912]}, {"w": "+", "b": [0.4653, 0.8749, 0.4745, 0.8912]}, {"w": "c.", "b": [0.4781, 0.8748, 0.4878, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "Let’s compare the algorithms we’ve discussed so far for Linear Regression8 (recall that m is the number of training instances and n is the number of features); see Table 4-1.", "words": [{"w": "Let’s", "b": [0.1429, 0.0791, 0.179, 0.1005]}, {"w": "compare", "b": [0.1843, 0.0791, 0.2571, 0.1005]}, {"w": "the", "b": [0.2624, 0.0791, 0.2887, 0.1005]}, {"w": "algorithms", "b": [0.294, 0.0791, 0.3843, 0.1005]}, {"w": "we’ve", "b": [0.3896, 0.0791, 0.434, 0.1005]}, {"w": "discussed", "b": [0.4394, 0.0791, 0.5186, 0.1005]}, {"w": "so", "b": [0.5239, 0.0791, 0.5422, 0.1005]}, {"w": "far", "b": [0.5475, 0.0791, 0.5705, 0.1005]}, {"w": "for", "b": [0.5759, 0.0791, 0.6004, 0.1005]}, {"w": "Linear", "b": [0.6057, 0.0791, 0.6596, 0.1005]}, {"w": "Regression8", "b": [0.6649, 0.0791, 0.7616, 0.1005]}, {"w": "(recall", "b": [0.767, 0.0791, 0.8193, 0.1005]}, {"w": "that", "b": [0.824, 0.0791, 0.8566, 0.1005]}, {"w": "m", "b": [0.1429, 0.0979, 0.1593, 0.1195]}, {"w": "is", "b": [0.164, 0.0981, 0.1772, 0.1195]}, {"w": "the", "b": [0.1819, 0.0981, 0.2083, 0.1195]}, {"w": "number", "b": [0.213, 0.0981, 0.2793, 0.1195]}, {"w": "of", "b": [0.284, 0.0981, 0.3008, 0.1195]}, {"w": "training", "b": [0.3055, 0.0981, 0.3725, 0.1195]}, {"w": "instances", "b": [0.3772, 0.0981, 0.454, 0.1195]}, {"w": "and", "b": [0.4588, 0.0981, 0.4903, 0.1195]}, {"w": "n", "b": [0.495, 0.0979, 0.5061, 0.1195]}, {"w": "is", "b": [0.5109, 0.0981, 0.5241, 0.1195]}, {"w": "the", "b": [0.5288, 0.0981, 0.5551, 0.1195]}, {"w": "number", "b": [0.5599, 0.0981, 0.6262, 0.1195]}, {"w": "of", "b": [0.6309, 0.0981, 0.6477, 0.1195]}, {"w": "features);", "b": [0.6524, 0.0981, 0.7298, 0.1195]}, {"w": "see", "b": [0.7345, 0.0981, 0.7599, 0.1195]}, {"w": "Table", "b": [0.7646, 0.0981, 0.8094, 0.1195]}, {"w": "4-1.", "b": [0.8141, 0.0981, 0.8463, 0.1195]}]}, {"id": "b_3", "type": "equation", "text": "Table 4-1. Comparison of algorithms for Linear Regression", "words": [{"w": "Table", "b": [0.1429, 0.136, 0.1844, 0.1566]}, {"w": "4-1.", "b": [0.189, 0.136, 0.2192, 0.1566]}, {"w": "Comparison", "b": [0.2237, 0.136, 0.3192, 0.1566]}, {"w": "of", "b": [0.3237, 0.136, 0.3382, 0.1566]}, {"w": "algorithms", "b": [0.3427, 0.136, 0.425, 0.1566]}, {"w": "for", "b": [0.4296, 0.136, 0.4511, 0.1566]}, {"w": "Linear", "b": [0.4557, 0.136, 0.5059, 0.1566]}, {"w": "Regression", "b": [0.5104, 0.136, 0.5911, 0.1566]}]}, {"id": "b_4", "type": "paragraph", "text": "Algorithm Large m Out-of-core support Large n Hyperparams Scaling required Scikit-Learn Normal Equation Fast No Slow 0 No n/a", "words": [{"w": "Algorithm", "b": [0.15, 0.1645, 0.2097, 0.1808]}, {"w": "Large", "b": [0.2572, 0.1645, 0.2903, 0.1808]}, {"w": "m", "b": [0.2937, 0.1645, 0.3049, 0.1808]}, {"w": "Out-of-core", "b": [0.3192, 0.1645, 0.3866, 0.1808]}, {"w": "support", "b": [0.39, 0.1645, 0.4356, 0.1808]}, {"w": "Large", "b": [0.4499, 0.1645, 0.483, 0.1808]}, {"w": "n", "b": [0.4864, 0.1645, 0.4939, 0.1808]}, {"w": "Hyperparams", "b": [0.5082, 0.1645, 0.5869, 0.1808]}, {"w": "Scaling", "b": [0.6011, 0.1645, 0.6433, 0.1808]}, {"w": "required", "b": [0.6467, 0.1645, 0.697, 0.1808]}, {"w": "Scikit-Learn", "b": [0.7113, 0.1645, 0.781, 0.1808]}, {"w": "Normal", "b": [0.15, 0.1849, 0.1906, 0.201]}, {"w": "Equation", "b": [0.194, 0.1849, 0.2429, 0.201]}, {"w": "Fast", "b": [0.2572, 0.1849, 0.2796, 0.201]}, {"w": "No", "b": [0.3192, 0.1849, 0.3343, 0.201]}, {"w": "Slow", "b": [0.4499, 0.1849, 0.4767, 0.201]}, {"w": "0", "b": [0.5082, 0.1849, 0.5151, 0.201]}, {"w": "No", "b": [0.6011, 0.1849, 0.6163, 0.201]}, {"w": "n/a", "b": [0.7113, 0.1849, 0.7301, 0.201]}]}, {"id": "b_5", "type": "paragraph", "text": "SVD Fast No Slow 0 No LinearRegression", "words": [{"w": "SVD", "b": [0.15, 0.2059, 0.1719, 0.222]}, {"w": "Fast", "b": [0.2572, 0.2059, 0.2796, 0.222]}, {"w": "No", "b": [0.3192, 0.2059, 0.3343, 0.222]}, {"w": "Slow", "b": [0.4499, 0.2059, 0.4767, 0.222]}, {"w": "0", "b": [0.5082, 0.2059, 0.5151, 0.222]}, {"w": "No", "b": [0.6011, 0.2059, 0.6163, 0.222]}, {"w": "LinearRegression", "b": [0.7113, 0.2088, 0.8462, 0.2216]}]}, {"id": "b_6", "type": "paragraph", "text": "Batch GD Slow No Fast 2 Yes SGDRegressor", "words": [{"w": "Batch", "b": [0.15, 0.2277, 0.1811, 0.2438]}, {"w": "GD", "b": [0.1845, 0.2277, 0.2002, 0.2438]}, {"w": "Slow", "b": [0.2572, 0.2277, 0.284, 0.2438]}, {"w": "No", "b": [0.3192, 0.2277, 0.3343, 0.2438]}, {"w": "Fast", "b": [0.4499, 0.2277, 0.4723, 0.2438]}, {"w": "2", "b": [0.5082, 0.2277, 0.5151, 0.2438]}, {"w": "Yes", "b": [0.6011, 0.2277, 0.6198, 0.2438]}, {"w": "SGDRegressor", "b": [0.7113, 0.2306, 0.8125, 0.2435]}]}, {"id": "b_7", "type": "paragraph", "text": "Stochastic GD Fast Yes Fast ≥2 Yes SGDRegressor", "words": [{"w": "Stochastic", "b": [0.15, 0.2496, 0.2054, 0.2657]}, {"w": "GD", "b": [0.2087, 0.2496, 0.2245, 0.2657]}, {"w": "Fast", "b": [0.2572, 0.2496, 0.2796, 0.2657]}, {"w": "Yes", "b": [0.3192, 0.2496, 0.3379, 0.2657]}, {"w": "Fast", "b": [0.4499, 0.2496, 0.4723, 0.2657]}, {"w": "≥2", "b": [0.5082, 0.2496, 0.5257, 0.2657]}, {"w": "Yes", "b": [0.6011, 0.2496, 0.6198, 0.2657]}, {"w": "SGDRegressor", "b": [0.7113, 0.2525, 0.8125, 0.2653]}]}, {"id": "b_8", "type": "equation", "text": "Mini-batch GD Fast Yes Fast ≥2 Yes SGDRegressor", "words": [{"w": "Mini-batch", "b": [0.15, 0.2714, 0.2103, 0.2876]}, {"w": "GD", "b": [0.2137, 0.2714, 0.2294, 0.2876]}, {"w": "Fast", "b": [0.2572, 0.2714, 0.2796, 0.2876]}, {"w": "Yes", "b": [0.3192, 0.2714, 0.3379, 0.2876]}, {"w": "Fast", "b": [0.4499, 0.2714, 0.4723, 0.2876]}, {"w": "≥2", "b": [0.5082, 0.2714, 0.5257, 0.2876]}, {"w": "Yes", "b": [0.6011, 0.2714, 0.6198, 0.2876]}, {"w": "SGDRegressor", "b": [0.7113, 0.2743, 0.8125, 0.2872]}]}, {"id": "b_9", "type": "paragraph", "text": "There is almost no difference after training: all these algorithms end up with very similar models and make predictions in exactly the same way.", "words": [{"w": "There", "b": [0.2714, 0.3128, 0.3166, 0.3324]}, {"w": "is", "b": [0.3243, 0.3128, 0.3364, 0.3324]}, {"w": "almost", "b": [0.344, 0.3128, 0.3953, 0.3324]}, {"w": "no", "b": [0.403, 0.3128, 0.4231, 0.3324]}, {"w": "difference", "b": [0.4308, 0.3128, 0.5071, 0.3324]}, {"w": "after", "b": [0.5148, 0.3128, 0.5497, 0.3324]}, {"w": "training:", "b": [0.5574, 0.3128, 0.623, 0.3324]}, {"w": "all", "b": [0.6306, 0.3128, 0.6486, 0.3324]}, {"w": "these", "b": [0.6563, 0.3128, 0.6955, 0.3324]}, {"w": "algorithms", "b": [0.7032, 0.3128, 0.7857, 0.3324]}, {"w": "end", "b": [0.2714, 0.3302, 0.3, 0.3498]}, {"w": "up", "b": [0.3059, 0.3302, 0.326, 0.3498]}, {"w": "with", "b": [0.3319, 0.3302, 0.366, 0.3498]}, {"w": "very", "b": [0.3719, 0.3302, 0.4051, 0.3498]}, {"w": "similar", "b": [0.411, 0.3302, 0.4641, 0.3498]}, {"w": "models", "b": [0.47, 0.3302, 0.5252, 0.3498]}, {"w": "and", "b": [0.5311, 0.3302, 0.56, 0.3498]}, {"w": "make", "b": [0.5659, 0.3302, 0.6074, 0.3498]}, {"w": "predictions", "b": [0.6133, 0.3302, 0.6997, 0.3498]}, {"w": "in", "b": [0.7055, 0.3302, 0.7211, 0.3498]}, {"w": "exactly", "b": [0.727, 0.3302, 0.7798, 0.3498]}, {"w": "the", "b": [0.2714, 0.3476, 0.2955, 0.3672]}, {"w": "same", "b": [0.2998, 0.3476, 0.3389, 0.3672]}, {"w": "way.", "b": [0.3432, 0.3476, 0.3759, 0.3672]}]}, {"id": "b_10", "type": "paragraph", "text": "Polynomial Regression", "words": [{"w": "Polynomial", "b": [0.1429, 0.4076, 0.2828, 0.4419]}, {"w": "Regression", "b": [0.2888, 0.4076, 0.4237, 0.4419]}]}, {"id": "b_11", "type": "paragraph", "text": "What if your data is actually more complex than a simple straight line? Surprisingly, you can actually use a linear model to fit nonlinear data. A simple way to do this is to add powers of each feature as new features, then train a linear model on this extended set of features. This technique is called Polynomial Regression.", "words": [{"w": "What", "b": [0.1429, 0.4488, 0.1893, 0.4702]}, {"w": "if", "b": [0.1954, 0.4488, 0.2071, 0.4702]}, {"w": "your", "b": [0.2132, 0.4488, 0.2522, 0.4702]}, {"w": "data", "b": [0.2583, 0.4488, 0.2935, 0.4702]}, {"w": "is", "b": [0.2996, 0.4488, 0.3128, 0.4702]}, {"w": "actually", "b": [0.3189, 0.4488, 0.3835, 0.4702]}, {"w": "more", "b": [0.3896, 0.4488, 0.4339, 0.4702]}, {"w": "complex", "b": [0.44, 0.4488, 0.5109, 0.4702]}, {"w": "than", "b": [0.517, 0.4488, 0.555, 0.4702]}, {"w": "a", "b": [0.5611, 0.4488, 0.5703, 0.4702]}, {"w": "simple", "b": [0.5764, 0.4488, 0.6313, 0.4702]}, {"w": "straight", "b": [0.6374, 0.4488, 0.7007, 0.4702]}, {"w": "line?", "b": [0.7067, 0.4488, 0.7457, 0.4702]}, {"w": "Surprisingly,", "b": [0.7518, 0.4488, 0.8571, 0.4702]}, {"w": "you", "b": [0.1429, 0.4679, 0.1741, 0.4893]}, {"w": "can", "b": [0.1793, 0.4679, 0.2087, 0.4893]}, {"w": "actually", "b": [0.2139, 0.4679, 0.2785, 0.4893]}, {"w": "use", "b": [0.2837, 0.4679, 0.3113, 0.4893]}, {"w": "a", "b": [0.3165, 0.4679, 0.3256, 0.4893]}, {"w": "linear", "b": [0.3308, 0.4679, 0.3788, 0.4893]}, {"w": "model", "b": [0.384, 0.4679, 0.4368, 0.4893]}, {"w": "to", "b": [0.442, 0.4679, 0.459, 0.4893]}, {"w": "fit", "b": [0.4642, 0.4679, 0.4823, 0.4893]}, {"w": "nonlinear", "b": [0.4875, 0.4679, 0.5689, 0.4893]}, {"w": "data.", "b": [0.5741, 0.4679, 0.6141, 0.4893]}, {"w": "A", "b": [0.6193, 0.4679, 0.6337, 0.4893]}, {"w": "simple", "b": [0.6389, 0.4679, 0.6938, 0.4893]}, {"w": "way", "b": [0.699, 0.4679, 0.7316, 0.4893]}, {"w": "to", "b": [0.7368, 0.4679, 0.7538, 0.4893]}, {"w": "do", "b": [0.759, 0.4679, 0.7806, 0.4893]}, {"w": "this", "b": [0.7858, 0.4679, 0.8165, 0.4893]}, {"w": "is", "b": [0.8217, 0.4679, 0.835, 0.4893]}, {"w": "to", "b": [0.8402, 0.4679, 0.8571, 0.4893]}, {"w": "add", "b": [0.1428, 0.4869, 0.174, 0.5083]}, {"w": "powers", "b": [0.1788, 0.4869, 0.2389, 0.5083]}, {"w": "of", "b": [0.2437, 0.4869, 0.2605, 0.5083]}, {"w": "each", "b": [0.2653, 0.4869, 0.3032, 0.5083]}, {"w": "feature", "b": [0.3081, 0.4869, 0.3658, 0.5083]}, {"w": "as", "b": [0.3707, 0.4869, 0.3875, 0.5083]}, {"w": "new", "b": [0.3923, 0.4869, 0.4268, 0.5083]}, {"w": "features,", "b": [0.4316, 0.4869, 0.5018, 0.5083]}, {"w": "then", "b": [0.5066, 0.4869, 0.5443, 0.5083]}, {"w": "train", "b": [0.5492, 0.4869, 0.5894, 0.5083]}, {"w": "a", "b": [0.5942, 0.4869, 0.6033, 0.5083]}, {"w": "linear", "b": [0.6082, 0.4869, 0.6561, 0.5083]}, {"w": "model", "b": [0.661, 0.4869, 0.7138, 0.5083]}, {"w": "on", "b": [0.7186, 0.4869, 0.7406, 0.5083]}, {"w": "this", "b": [0.7455, 0.4869, 0.7762, 0.5083]}, {"w": "extended", "b": [0.781, 0.4869, 0.8571, 0.5083]}, {"w": "set", "b": [0.1429, 0.506, 0.1657, 0.5274]}, {"w": "of", "b": [0.1704, 0.506, 0.1872, 0.5274]}, {"w": "features.", "b": [0.192, 0.506, 0.2621, 0.5274]}, {"w": "This", "b": [0.2669, 0.506, 0.3041, 0.5274]}, {"w": "technique", "b": [0.3088, 0.506, 0.3915, 0.5274]}, {"w": "is", "b": [0.3962, 0.506, 0.4094, 0.5274]}, {"w": "called", "b": [0.4142, 0.506, 0.4625, 0.5274]}, {"w": "Polynomial", "b": [0.4673, 0.5058, 0.5596, 0.5274]}, {"w": "Regression.", "b": [0.5644, 0.5058, 0.6538, 0.5274]}]}, {"id": "b_12", "type": "paragraph", "text": "Let’s look at an example. First, let’s generate some nonlinear data, based on a simple quadratic equation9 (plus some noise; see Figure 4-12):", "words": [{"w": "Let’s", "b": [0.1429, 0.5341, 0.179, 0.5555]}, {"w": "look", "b": [0.1854, 0.5341, 0.2222, 0.5555]}, {"w": "at", "b": [0.2285, 0.5341, 0.2436, 0.5555]}, {"w": "an", "b": [0.25, 0.5341, 0.2705, 0.5555]}, {"w": "example.", "b": [0.2768, 0.5341, 0.3511, 0.5555]}, {"w": "First,", "b": [0.3574, 0.5341, 0.4005, 0.5555]}, {"w": "let’s", "b": [0.4069, 0.5341, 0.4371, 0.5555]}, {"w": "generate", "b": [0.4434, 0.5341, 0.514, 0.5555]}, {"w": "some", "b": [0.5203, 0.5341, 0.5645, 0.5555]}, {"w": "nonlinear", "b": [0.5708, 0.5341, 0.6522, 0.5555]}, {"w": "data,", "b": [0.6585, 0.5341, 0.6985, 0.5555]}, {"w": "based", "b": [0.7048, 0.5341, 0.7521, 0.5555]}, {"w": "on", "b": [0.7584, 0.5341, 0.7804, 0.5555]}, {"w": "a", "b": [0.7867, 0.5341, 0.7959, 0.5555]}, {"w": "simple", "b": [0.8022, 0.5341, 0.8571, 0.5555]}, {"w": "quadratic", "b": [0.1429, 0.5529, 0.2208, 0.5745]}, {"w": "equation9", "b": [0.2255, 0.5529, 0.3025, 0.5745]}, {"w": "(plus", "b": [0.3072, 0.5531, 0.3493, 0.5745]}, {"w": "some", "b": [0.3541, 0.5531, 0.3982, 0.5745]}, {"w": "noise;", "b": [0.403, 0.5531, 0.4518, 0.5745]}, {"w": "see", "b": [0.4566, 0.5531, 0.4819, 0.5745]}, {"w": "Figure", "b": [0.4866, 0.5531, 0.5406, 0.5745]}, {"w": "4-12):", "b": [0.5454, 0.5531, 0.5947, 0.5745]}]}, {"id": "b_13", "type": "paragraph", "text": "m = 100 X = 6 * np.random.rand(m, 1) - 3 y = 0.5 * X**2 + X + 2 + np.random.randn(m, 1)", "words": [{"w": "m", "b": [0.1766, 0.5851, 0.185, 0.5979]}, {"w": "=", "b": [0.1935, 0.5851, 0.2019, 0.5979]}, {"w": "100", "b": [0.2103, 0.5851, 0.2356, 0.5979]}, {"w": "X", "b": [0.1766, 0.6005, 0.185, 0.6134]}, {"w": "=", "b": [0.1935, 0.6005, 0.2019, 0.6134]}, {"w": "6", "b": [0.2103, 0.6005, 0.2187, 0.6134]}, {"w": "*", "b": [0.2272, 0.6005, 0.2356, 0.6134]}, {"w": "np.random.rand(m,", "b": [0.244, 0.6005, 0.3874, 0.6134]}, {"w": "1)", "b": [0.3958, 0.6005, 0.4127, 0.6134]}, {"w": "-", "b": [0.4211, 0.6005, 0.4296, 0.6134]}, {"w": "3", "b": [0.438, 0.6005, 0.4464, 0.6134]}, {"w": "y", "b": [0.1766, 0.6159, 0.185, 0.6288]}, {"w": "=", "b": [0.1935, 0.6159, 0.2019, 0.6288]}, {"w": "0.5", "b": [0.2103, 0.6159, 0.2356, 0.6288]}, {"w": "*", "b": [0.244, 0.6159, 0.2525, 0.6288]}, {"w": "X**2", "b": [0.2609, 0.6159, 0.2946, 0.6288]}, {"w": "+", "b": [0.3031, 0.6159, 0.3115, 0.6288]}, {"w": "X", "b": [0.3199, 0.6159, 0.3284, 0.6288]}, {"w": "+", "b": [0.3368, 0.6159, 0.3452, 0.6288]}, {"w": "2", "b": [0.3537, 0.6159, 0.3621, 0.6288]}, {"w": "+", "b": [0.3705, 0.6159, 0.379, 0.6288]}, {"w": "np.random.randn(m,", "b": [0.3874, 0.6159, 0.5392, 0.6288]}, {"w": "1)", "b": [0.5476, 0.6159, 0.5645, 0.6288]}]}, {"id": "b_14", "type": "paragraph", "text": "130 | Chapter 4: Training Models", "words": [{"w": "130", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 157, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 4-12. Generated nonlinear and noisy dataset", "words": [{"w": "Figure", "b": [0.1429, 0.3636, 0.1943, 0.3852]}, {"w": "4-12.", "b": [0.1991, 0.3636, 0.2407, 0.3852]}, {"w": "Generated", "b": [0.2455, 0.3636, 0.3293, 0.3852]}, {"w": "nonlinear", "b": [0.3341, 0.3636, 0.4125, 0.3852]}, {"w": "and", "b": [0.4173, 0.3636, 0.4487, 0.3852]}, {"w": "noisy", "b": [0.4534, 0.3636, 0.4958, 0.3852]}, {"w": "dataset", "b": [0.5006, 0.3636, 0.5589, 0.3852]}]}, {"id": "b_1", "type": "paragraph", "text": "Clearly, a straight line will never fit this data properly. So let’s use Scikit-Learn’s Poly nomialFeatures class to transform our training data, adding the square (2nd-degree polynomial) of each feature in the training set as new features (in this case there is just one feature):", "words": [{"w": "Clearly,", "b": [0.1429, 0.4019, 0.2058, 0.4233]}, {"w": "a", "b": [0.2116, 0.4019, 0.2208, 0.4233]}, {"w": "straight", "b": [0.2267, 0.4019, 0.29, 0.4233]}, {"w": "line", "b": [0.2958, 0.4019, 0.3269, 0.4233]}, {"w": "will", "b": [0.3328, 0.4019, 0.3632, 0.4233]}, {"w": "never", "b": [0.3691, 0.4019, 0.4155, 0.4233]}, {"w": "fit", "b": [0.4214, 0.4019, 0.4395, 0.4233]}, {"w": "this", "b": [0.4454, 0.4019, 0.4761, 0.4233]}, {"w": "data", "b": [0.482, 0.4019, 0.5172, 0.4233]}, {"w": "properly.", "b": [0.5231, 0.4019, 0.5979, 0.4233]}, {"w": "So", "b": [0.6038, 0.4019, 0.6243, 0.4233]}, {"w": "let’s", "b": [0.6302, 0.4019, 0.6604, 0.4233]}, {"w": "use", "b": [0.6663, 0.4019, 0.6938, 0.4233]}, {"w": "Scikit-Learn’s", "b": [0.6997, 0.4019, 0.8106, 0.4233]}, {"w": "Poly", "b": [0.8165, 0.405, 0.8561, 0.4201]}, {"w": "nomialFeatures", "b": [0.1429, 0.425, 0.2814, 0.4401]}, {"w": "class", "b": [0.2882, 0.4218, 0.3267, 0.4432]}, {"w": "to", "b": [0.3335, 0.4218, 0.3504, 0.4432]}, {"w": "transform", "b": [0.3572, 0.4218, 0.4411, 0.4432]}, {"w": "our", "b": [0.4478, 0.4218, 0.4772, 0.4432]}, {"w": "training", "b": [0.484, 0.4218, 0.5509, 0.4432]}, {"w": "data,", "b": [0.5577, 0.4218, 0.5977, 0.4432]}, {"w": "adding", "b": [0.6045, 0.4218, 0.6623, 0.4432]}, {"w": "the", "b": [0.6691, 0.4218, 0.6954, 0.4432]}, {"w": "square", "b": [0.7022, 0.4218, 0.7573, 0.4432]}, {"w": "(2nd-degree", "b": [0.764, 0.4218, 0.8571, 0.4432]}, {"w": "polynomial)", "b": [0.1429, 0.4408, 0.2455, 0.4623]}, {"w": "of", "b": [0.2525, 0.4408, 0.2692, 0.4623]}, {"w": "each", "b": [0.2762, 0.4408, 0.3141, 0.4623]}, {"w": "feature", "b": [0.321, 0.4408, 0.3788, 0.4623]}, {"w": "in", "b": [0.3857, 0.4408, 0.4027, 0.4623]}, {"w": "the", "b": [0.4096, 0.4408, 0.4359, 0.4623]}, {"w": "training", "b": [0.4429, 0.4408, 0.5098, 0.4623]}, {"w": "set", "b": [0.5167, 0.4408, 0.5396, 0.4623]}, {"w": "as", "b": [0.5465, 0.4408, 0.5633, 0.4623]}, {"w": "new", "b": [0.5702, 0.4408, 0.6047, 0.4623]}, {"w": "features", "b": [0.6116, 0.4408, 0.6771, 0.4623]}, {"w": "(in", "b": [0.684, 0.4408, 0.7082, 0.4623]}, {"w": "this", "b": [0.7151, 0.4408, 0.7458, 0.4623]}, {"w": "case", "b": [0.7527, 0.4408, 0.7872, 0.4623]}, {"w": "there", "b": [0.7941, 0.4408, 0.837, 0.4623]}, {"w": "is", "b": [0.8439, 0.4408, 0.8572, 0.4623]}, {"w": "just", "b": [0.1429, 0.4599, 0.1733, 0.4813]}, {"w": "one", "b": [0.178, 0.4599, 0.2089, 0.4813]}, {"w": "feature):", "b": [0.2136, 0.4599, 0.2833, 0.4813]}]}, {"id": "b_2", "type": "paragraph", "text": ">>> from sklearn.preprocessing import PolynomialFeatures >>> poly_features = PolynomialFeatures(degree=2, include_bias=False) >>> X_poly = poly_features.fit_transform(X) >>> X[0] array([-0.75275929]) >>> X_poly[0] array([-0.75275929, 0.56664654])", "words": [{"w": ">>>", "b": [0.1766, 0.4919, 0.2019, 0.5047]}, {"w": "from", "b": [0.2103, 0.4919, 0.244, 0.5047]}, {"w": "sklearn.preprocessing", "b": [0.2525, 0.4919, 0.4296, 0.5047]}, {"w": "import", "b": [0.438, 0.4919, 0.4886, 0.5047]}, {"w": "PolynomialFeatures", "b": [0.497, 0.4919, 0.6488, 0.5047]}, {"w": ">>>", "b": [0.1766, 0.5073, 0.2019, 0.5201]}, {"w": "poly_features", "b": [0.2103, 0.5073, 0.3199, 0.5201]}, {"w": "=", "b": [0.3284, 0.5073, 0.3368, 0.5201]}, {"w": "PolynomialFeatures(degree=2,", "b": [0.3452, 0.5073, 0.5813, 0.5201]}, {"w": "include_bias=False)", "b": [0.5898, 0.5073, 0.75, 0.5201]}, {"w": ">>>", "b": [0.1766, 0.5227, 0.2019, 0.5356]}, {"w": "X_poly", "b": [0.2103, 0.5227, 0.2609, 0.5356]}, {"w": "=", "b": [0.2693, 0.5227, 0.2778, 0.5356]}, {"w": "poly_features.fit_transform(X)", "b": [0.2862, 0.5227, 0.5392, 0.5356]}, {"w": ">>>", "b": [0.1766, 0.5381, 0.2019, 0.551]}, {"w": "X[0]", "b": [0.2103, 0.5381, 0.244, 0.551]}, {"w": "array([-0.75275929])", "b": [0.1766, 0.5535, 0.3452, 0.5664]}, {"w": ">>>", "b": [0.1766, 0.569, 0.2019, 0.5818]}, {"w": "X_poly[0]", "b": [0.2103, 0.569, 0.2862, 0.5818]}, {"w": "array([-0.75275929,", "b": [0.1766, 0.5844, 0.3368, 0.5972]}, {"w": "0.56664654])", "b": [0.3452, 0.5844, 0.4464, 0.5972]}]}, {"id": "b_3", "type": "paragraph", "text": "X_poly now contains the original feature of X plus the square of this feature. Now you can fit a LinearRegression model to this extended training data (Figure 4-13):", "words": [{"w": "X_poly", "b": [0.1429, 0.6091, 0.2022, 0.6242]}, {"w": "now", "b": [0.2072, 0.6059, 0.2435, 0.6273]}, {"w": "contains", "b": [0.2485, 0.6059, 0.319, 0.6273]}, {"w": "the", "b": [0.324, 0.6059, 0.3504, 0.6273]}, {"w": "original", "b": [0.3553, 0.6059, 0.4204, 0.6273]}, {"w": "feature", "b": [0.4254, 0.6059, 0.4832, 0.6273]}, {"w": "of", "b": [0.4882, 0.6059, 0.505, 0.6273]}, {"w": "X", "b": [0.5099, 0.6091, 0.5198, 0.6242]}, {"w": "plus", "b": [0.5248, 0.6059, 0.5597, 0.6273]}, {"w": "the", "b": [0.5647, 0.6059, 0.591, 0.6273]}, {"w": "square", "b": [0.596, 0.6059, 0.6511, 0.6273]}, {"w": "of", "b": [0.6561, 0.6059, 0.6729, 0.6273]}, {"w": "this", "b": [0.6779, 0.6059, 0.7086, 0.6273]}, {"w": "feature.", "b": [0.7135, 0.6059, 0.7761, 0.6273]}, {"w": "Now", "b": [0.781, 0.6059, 0.8209, 0.6273]}, {"w": "you", "b": [0.8259, 0.6059, 0.8571, 0.6273]}, {"w": "can", "b": [0.1429, 0.6259, 0.1722, 0.6473]}, {"w": "fit", "b": [0.1769, 0.6259, 0.1951, 0.6473]}, {"w": "a", "b": [0.1998, 0.6259, 0.2089, 0.6473]}, {"w": "LinearRegression", "b": [0.2137, 0.629, 0.372, 0.6441]}, {"w": "model", "b": [0.3767, 0.6259, 0.4295, 0.6473]}, {"w": "to", "b": [0.4343, 0.6259, 0.4512, 0.6473]}, {"w": "this", "b": [0.456, 0.6259, 0.4867, 0.6473]}, {"w": "extended", "b": [0.4914, 0.6259, 0.5676, 0.6473]}, {"w": "training", "b": [0.5723, 0.6259, 0.6392, 0.6473]}, {"w": "data", "b": [0.6439, 0.6259, 0.6792, 0.6473]}, {"w": "(Figure", "b": [0.6839, 0.6259, 0.7451, 0.6473]}, {"w": "4-13):", "b": [0.7499, 0.6259, 0.7992, 0.6473]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> lin_reg = LinearRegression() >>> lin_reg.fit(X_poly, y) >>> lin_reg.intercept_, lin_reg.coef_ (array([1.78134581]), array([[0.93366893, 0.56456263]]))", "words": [{"w": ">>>", "b": [0.1766, 0.6578, 0.2019, 0.6707]}, {"w": "lin_reg", "b": [0.2103, 0.6578, 0.2693, 0.6707]}, {"w": "=", "b": [0.2778, 0.6578, 0.2862, 0.6707]}, {"w": "LinearRegression()", "b": [0.2946, 0.6578, 0.4464, 0.6707]}, {"w": ">>>", "b": [0.1766, 0.6733, 0.2019, 0.6861]}, {"w": "lin_reg.fit(X_poly,", "b": [0.2103, 0.6733, 0.3705, 0.6861]}, {"w": "y)", "b": [0.379, 0.6733, 0.3958, 0.6861]}, {"w": ">>>", "b": [0.1766, 0.6887, 0.2019, 0.7015]}, {"w": "lin_reg.intercept_,", "b": [0.2103, 0.6887, 0.3705, 0.7015]}, {"w": "lin_reg.coef_", "b": [0.379, 0.6887, 0.4886, 0.7015]}, {"w": "(array([1.78134581]),", "b": [0.1766, 0.7041, 0.3537, 0.7169]}, {"w": "array([[0.93366893,", "b": [0.3621, 0.7041, 0.5223, 0.7169]}, {"w": "0.56456263]]))", "b": [0.5307, 0.7041, 0.6488, 0.7169]}]}, {"id": "b_5", "type": "paragraph", "text": "Polynomial Regression | 131", "words": [{"w": "Polynomial", "b": [0.6622, 0.9225, 0.7288, 0.9388]}, {"w": "Regression", "b": [0.7316, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "131", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 158, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 4-13. Polynomial Regression model predictions", "words": [{"w": "Figure", "b": [0.1429, 0.3636, 0.1943, 0.3852]}, {"w": "4-13.", "b": [0.1991, 0.3636, 0.2407, 0.3852]}, {"w": "Polynomial", "b": [0.2455, 0.3636, 0.3378, 0.3852]}, {"w": "Regression", "b": [0.3426, 0.3636, 0.4273, 0.3852]}, {"w": "model", "b": [0.4321, 0.3636, 0.4818, 0.3852]}, {"w": "predictions", "b": [0.4865, 0.3636, 0.5753, 0.3852]}]}, {"id": "b_1", "type": "equation", "text": "Not bad: the model estimates y = 0 . 56x1", "words": [{"w": "Not", "b": [0.1429, 0.4035, 0.1748, 0.4249]}, {"w": "bad:", "b": [0.1816, 0.4035, 0.2171, 0.4249]}, {"w": "the", "b": [0.2239, 0.4035, 0.2502, 0.4249]}, {"w": "model", "b": [0.257, 0.4035, 0.3098, 0.4249]}, {"w": "estimates", "b": [0.3166, 0.4035, 0.3937, 0.4249]}, {"w": "y", "b": [0.4017, 0.4033, 0.4109, 0.4249]}, {"w": "=", "b": [0.4181, 0.4035, 0.4302, 0.4249]}, {"w": "0", "b": [0.4359, 0.4035, 0.4459, 0.4249]}, {"w": ".", "b": [0.4494, 0.4035, 0.4542, 0.4249]}, {"w": "56x1", "b": [0.4576, 0.4033, 0.4951, 0.4288]}]}, {"id": "b_2", "type": "equation", "text": "2 + 0 . 93x1 + 1 . 78 when in fact the original", "words": [{"w": "2", "b": [0.4875, 0.4004, 0.4951, 0.4167]}, {"w": "+", "b": [0.4997, 0.4035, 0.5118, 0.4249]}, {"w": "0", "b": [0.5164, 0.4035, 0.5264, 0.4249]}, {"w": ".", "b": [0.5299, 0.4035, 0.5347, 0.4249]}, {"w": "93x1", "b": [0.5382, 0.4033, 0.5756, 0.4288]}, {"w": "+", "b": [0.5802, 0.4035, 0.5923, 0.4249]}, {"w": "1", "b": [0.597, 0.4035, 0.607, 0.4249]}, {"w": ".", "b": [0.6104, 0.4035, 0.6152, 0.4249]}, {"w": "78", "b": [0.6186, 0.4035, 0.6386, 0.4249]}, {"w": "when", "b": [0.6455, 0.4035, 0.6911, 0.4249]}, {"w": "in", "b": [0.6979, 0.4035, 0.7149, 0.4249]}, {"w": "fact", "b": [0.7217, 0.4035, 0.7521, 0.4249]}, {"w": "the", "b": [0.7589, 0.4035, 0.7853, 0.4249]}, {"w": "original", "b": [0.7921, 0.4035, 0.8571, 0.4249]}]}, {"id": "b_3", "type": "equation", "text": "function was y = 0 . 5x1", "words": [{"w": "function", "b": [0.1429, 0.4277, 0.2142, 0.4491]}, {"w": "was", "b": [0.219, 0.4277, 0.25, 0.4491]}, {"w": "y", "b": [0.256, 0.4275, 0.2652, 0.4491]}, {"w": "=", "b": [0.271, 0.4277, 0.2831, 0.4491]}, {"w": "0", "b": [0.2889, 0.4277, 0.2989, 0.4491]}, {"w": ".", "b": [0.3023, 0.4277, 0.3071, 0.4491]}, {"w": "5x1", "b": [0.3105, 0.4275, 0.338, 0.453]}]}, {"id": "b_4", "type": "equation", "text": "2 + 1 . 0x1 + 2 . 0 + Gaussian noise.", "words": [{"w": "2", "b": [0.3304, 0.4245, 0.338, 0.4409]}, {"w": "+", "b": [0.3426, 0.4277, 0.3547, 0.4491]}, {"w": "1", "b": [0.3593, 0.4277, 0.3693, 0.4491]}, {"w": ".", "b": [0.3728, 0.4277, 0.3776, 0.4491]}, {"w": "0x1", "b": [0.3811, 0.4275, 0.4085, 0.453]}, {"w": "+", "b": [0.4132, 0.4277, 0.4252, 0.4491]}, {"w": "2", "b": [0.4299, 0.4277, 0.4399, 0.4491]}, {"w": ".", "b": [0.4433, 0.4277, 0.4481, 0.4491]}, {"w": "0", "b": [0.4516, 0.4277, 0.4616, 0.4491]}, {"w": "+", "b": [0.4662, 0.4277, 0.4783, 0.4491]}, {"w": "Gaussian", "b": [0.4829, 0.4277, 0.5594, 0.4491]}, {"w": "noise.", "b": [0.5674, 0.4277, 0.6162, 0.4491]}]}, {"id": "b_5", "type": "paragraph", "text": "Note that when there are multiple features, Polynomial Regression is capable of find‐ ing relationships between features (which is something a plain Linear Regression model cannot do). This is made possible by the fact that PolynomialFeatures also adds all combinations of features up to the given degree. For example, if there were two features a and b, PolynomialFeatures with degree=3 would not only add the features a2, a3, b2, and b3, but also the combinations ab, a2b, and ab2.", "words": [{"w": "Note", "b": [0.1429, 0.4584, 0.1837, 0.4798]}, {"w": "that", "b": [0.1891, 0.4584, 0.2217, 0.4798]}, {"w": "when", "b": [0.2272, 0.4584, 0.2729, 0.4798]}, {"w": "there", "b": [0.2784, 0.4584, 0.3213, 0.4798]}, {"w": "are", "b": [0.3268, 0.4584, 0.3525, 0.4798]}, {"w": "multiple", "b": [0.358, 0.4584, 0.428, 0.4798]}, {"w": "features,", "b": [0.4335, 0.4584, 0.5036, 0.4798]}, {"w": "Polynomial", "b": [0.5091, 0.4584, 0.6047, 0.4798]}, {"w": "Regression", "b": [0.6102, 0.4584, 0.7013, 0.4798]}, {"w": "is", "b": [0.7067, 0.4584, 0.72, 0.4798]}, {"w": "capable", "b": [0.7255, 0.4584, 0.7878, 0.4798]}, {"w": "of", "b": [0.7933, 0.4584, 0.8101, 0.4798]}, {"w": "find‐", "b": [0.8156, 0.4584, 0.8571, 0.4798]}, {"w": "ing", "b": [0.1429, 0.4774, 0.1696, 0.4989]}, {"w": "relationships", "b": [0.1785, 0.4774, 0.286, 0.4989]}, {"w": "between", "b": [0.2949, 0.4774, 0.3641, 0.4989]}, {"w": "features", "b": [0.373, 0.4774, 0.4385, 0.4989]}, {"w": "(which", "b": [0.4474, 0.4774, 0.5055, 0.4989]}, {"w": "is", "b": [0.5144, 0.4774, 0.5277, 0.4989]}, {"w": "something", "b": [0.5366, 0.4774, 0.625, 0.4989]}, {"w": "a", "b": [0.6339, 0.4774, 0.6431, 0.4989]}, {"w": "plain", "b": [0.652, 0.4774, 0.6943, 0.4989]}, {"w": "Linear", "b": [0.7033, 0.4774, 0.7572, 0.4989]}, {"w": "Regression", "b": [0.7661, 0.4774, 0.8571, 0.4989]}, {"w": "model", "b": [0.1429, 0.4974, 0.1957, 0.5188]}, {"w": "cannot", "b": [0.2028, 0.4974, 0.2606, 0.5188]}, {"w": "do).", "b": [0.2678, 0.4974, 0.3013, 0.5188]}, {"w": "This", "b": [0.3085, 0.4974, 0.3457, 0.5188]}, {"w": "is", "b": [0.3529, 0.4974, 0.3661, 0.5188]}, {"w": "made", "b": [0.3733, 0.4974, 0.4194, 0.5188]}, {"w": "possible", "b": [0.4266, 0.4974, 0.4937, 0.5188]}, {"w": "by", "b": [0.5009, 0.4974, 0.521, 0.5188]}, {"w": "the", "b": [0.5282, 0.4974, 0.5545, 0.5188]}, {"w": "fact", "b": [0.5617, 0.4974, 0.5922, 0.5188]}, {"w": "that", "b": [0.5994, 0.4974, 0.632, 0.5188]}, {"w": "PolynomialFeatures", "b": [0.6391, 0.5006, 0.8173, 0.5157]}, {"w": "also", "b": [0.8244, 0.4974, 0.8571, 0.5188]}, {"w": "adds", "b": [0.1429, 0.5164, 0.1817, 0.5379]}, {"w": "all", "b": [0.1882, 0.5164, 0.2079, 0.5379]}, {"w": "combinations", "b": [0.2144, 0.5164, 0.3288, 0.5379]}, {"w": "of", "b": [0.3353, 0.5164, 0.3521, 0.5379]}, {"w": "features", "b": [0.3586, 0.5164, 0.424, 0.5379]}, {"w": "up", "b": [0.4306, 0.5164, 0.4525, 0.5379]}, {"w": "to", "b": [0.459, 0.5164, 0.476, 0.5379]}, {"w": "the", "b": [0.4825, 0.5164, 0.5089, 0.5379]}, {"w": "given", "b": [0.5154, 0.5164, 0.5606, 0.5379]}, {"w": "degree.", "b": [0.5671, 0.5164, 0.6269, 0.5379]}, {"w": "For", "b": [0.6334, 0.5164, 0.6624, 0.5379]}, {"w": "example,", "b": [0.6689, 0.5164, 0.7432, 0.5379]}, {"w": "if", "b": [0.7497, 0.5164, 0.7615, 0.5379]}, {"w": "there", "b": [0.768, 0.5164, 0.8109, 0.5379]}, {"w": "were", "b": [0.8174, 0.5164, 0.8572, 0.5379]}, {"w": "two", "b": [0.1429, 0.5364, 0.1741, 0.5578]}, {"w": "features", "b": [0.1817, 0.5364, 0.2471, 0.5578]}, {"w": "a", "b": [0.2548, 0.5362, 0.265, 0.5578]}, {"w": "and", "b": [0.2726, 0.5364, 0.3041, 0.5578]}, {"w": "b,", "b": [0.3118, 0.5362, 0.3266, 0.5578]}, {"w": "PolynomialFeatures", "b": [0.3342, 0.5396, 0.5124, 0.5546]}, {"w": "with", "b": [0.52, 0.5364, 0.5573, 0.5578]}, {"w": "degree=3", "b": [0.5649, 0.5396, 0.6441, 0.5546]}, {"w": "would", "b": [0.6517, 0.5364, 0.704, 0.5578]}, {"w": "not", "b": [0.7116, 0.5364, 0.74, 0.5578]}, {"w": "only", "b": [0.7476, 0.5364, 0.7844, 0.5578]}, {"w": "add", "b": [0.792, 0.5364, 0.8232, 0.5578]}, {"w": "the", "b": [0.8308, 0.5364, 0.8571, 0.5578]}, {"w": "features", "b": [0.1429, 0.5554, 0.2083, 0.5768]}, {"w": "a2,", "b": [0.213, 0.5552, 0.234, 0.5768]}, {"w": "a3,", "b": [0.2387, 0.5552, 0.2596, 0.5768]}, {"w": "b2,", "b": [0.2644, 0.5552, 0.2853, 0.5768]}, {"w": "and", "b": [0.29, 0.5554, 0.3215, 0.5768]}, {"w": "b3,", "b": [0.3263, 0.5552, 0.3471, 0.5768]}, {"w": "but", "b": [0.3519, 0.5554, 0.3799, 0.5768]}, {"w": "also", "b": [0.3846, 0.5554, 0.4173, 0.5768]}, {"w": "the", "b": [0.422, 0.5554, 0.4483, 0.5768]}, {"w": "combinations", "b": [0.4531, 0.5554, 0.5675, 0.5768]}, {"w": "ab,", "b": [0.5722, 0.5552, 0.5968, 0.5768]}, {"w": "a2b,", "b": [0.6016, 0.5552, 0.6326, 0.5768]}, {"w": "and", "b": [0.6374, 0.5554, 0.6689, 0.5768]}, {"w": "ab2.", "b": [0.6736, 0.5552, 0.7043, 0.5768]}]}, {"id": "b_6", "type": "equation", "text": "PolynomialFeatures(degree=d) transforms an array containing n", "words": [{"w": "PolynomialFeatures(degree=d)", "b": [0.2714, 0.6011, 0.5247, 0.6149]}, {"w": "transforms", "b": [0.5302, 0.5982, 0.6138, 0.6178]}, {"w": "an", "b": [0.6193, 0.5982, 0.6381, 0.6178]}, {"w": "array", "b": [0.6435, 0.5982, 0.6828, 0.6178]}, {"w": "containing", "b": [0.6882, 0.5982, 0.7702, 0.6178]}, {"w": "n", "b": [0.7756, 0.598, 0.7857, 0.6178]}]}, {"id": "b_7", "type": "equation", "text": "features into an array containing n + d !", "words": [{"w": "features", "b": [0.2714, 0.6226, 0.3312, 0.6422]}, {"w": "into", "b": [0.3371, 0.6226, 0.3677, 0.6422]}, {"w": "an", "b": [0.3736, 0.6226, 0.3924, 0.6422]}, {"w": "array", "b": [0.3982, 0.6226, 0.4374, 0.6422]}, {"w": "containing", "b": [0.4433, 0.6226, 0.5252, 0.6422]}, {"w": "n", "b": [0.5398, 0.614, 0.5499, 0.6337]}, {"w": "+", "b": [0.5541, 0.6142, 0.5652, 0.6337]}, {"w": "d", "b": [0.5694, 0.614, 0.5791, 0.6337]}, {"w": "!", "b": [0.587, 0.6142, 0.5922, 0.6337]}]}, {"id": "b_8", "type": "paragraph", "text": "d! n! features, where n! is the", "words": [{"w": "d!", "b": [0.5448, 0.6309, 0.561, 0.6507]}, {"w": "n!", "b": [0.5642, 0.6309, 0.5806, 0.6507]}, {"w": "features,", "b": [0.6002, 0.6226, 0.6643, 0.6422]}, {"w": "where", "b": [0.6702, 0.6226, 0.7167, 0.6422]}, {"w": "n!", "b": [0.7225, 0.6224, 0.7379, 0.6422]}, {"w": "is", "b": [0.7437, 0.6226, 0.7558, 0.6422]}, {"w": "the", "b": [0.7616, 0.6226, 0.7857, 0.6422]}]}, {"id": "b_9", "type": "paragraph", "text": "factorial of n, equal to 1 × 2 × 3 × ⋯ × n. Beware of the combinato‐ rial explosion of the number of features!", "words": [{"w": "factorial", "b": [0.2714, 0.6469, 0.3335, 0.6666]}, {"w": "of", "b": [0.338, 0.6471, 0.3533, 0.6666]}, {"w": "n,", "b": [0.3578, 0.6469, 0.3723, 0.6666]}, {"w": "equal", "b": [0.3767, 0.6471, 0.4179, 0.6666]}, {"w": "to", "b": [0.4223, 0.6471, 0.4379, 0.6666]}, {"w": "1", "b": [0.4423, 0.6471, 0.4515, 0.6666]}, {"w": "×", "b": [0.456, 0.6471, 0.467, 0.6666]}, {"w": "2", "b": [0.4715, 0.6471, 0.4806, 0.6666]}, {"w": "×", "b": [0.4851, 0.6471, 0.4961, 0.6666]}, {"w": "3", "b": [0.5006, 0.6471, 0.5098, 0.6666]}, {"w": "×", "b": [0.5142, 0.6471, 0.5253, 0.6666]}, {"w": "⋯", "b": [0.5298, 0.65, 0.5488, 0.6645]}, {"w": "×", "b": [0.5531, 0.6471, 0.5642, 0.6666]}, {"w": "n.", "b": [0.5688, 0.6469, 0.5833, 0.6666]}, {"w": "Beware", "b": [0.5876, 0.6471, 0.6438, 0.6666]}, {"w": "of", "b": [0.6482, 0.6471, 0.6635, 0.6666]}, {"w": "the", "b": [0.6678, 0.6471, 0.6919, 0.6666]}, {"w": "combinato‐", "b": [0.6962, 0.6471, 0.7851, 0.6666]}, {"w": "rial", "b": [0.2714, 0.6645, 0.2968, 0.684]}, {"w": "explosion", "b": [0.3011, 0.6645, 0.3749, 0.684]}, {"w": "of", "b": [0.3792, 0.6645, 0.3946, 0.684]}, {"w": "the", "b": [0.3989, 0.6645, 0.423, 0.684]}, {"w": "number", "b": [0.4273, 0.6645, 0.4879, 0.684]}, {"w": "of", "b": [0.4922, 0.6645, 0.5076, 0.684]}, {"w": "features!", "b": [0.5119, 0.6645, 0.577, 0.684]}]}, {"id": "b_10", "type": "paragraph", "text": "Learning Curves", "words": [{"w": "Learning", "b": [0.1428, 0.7005, 0.2526, 0.7348]}, {"w": "Curves", "b": [0.2586, 0.7005, 0.3397, 0.7348]}]}, {"id": "b_11", "type": "paragraph", "text": "If you perform high-degree Polynomial Regression, you will likely fit the training data much better than with plain Linear Regression. For example, Figure 4-14 applies a 300-degree polynomial model to the preceding training data, and compares the result with a pure linear model and a quadratic model (2nd-degree polynomial). Notice how the 300-degree polynomial model wiggles around to get as close as possi‐ ble to the training instances.", "words": [{"w": "If", "b": [0.1429, 0.7417, 0.1561, 0.7631]}, {"w": "you", "b": [0.1644, 0.7417, 0.1957, 0.7631]}, {"w": "perform", "b": [0.204, 0.7417, 0.2731, 0.7631]}, {"w": "high-degree", "b": [0.2814, 0.7417, 0.3814, 0.7631]}, {"w": "Polynomial", "b": [0.3897, 0.7417, 0.4853, 0.7631]}, {"w": "Regression,", "b": [0.4936, 0.7417, 0.5894, 0.7631]}, {"w": "you", "b": [0.5977, 0.7417, 0.629, 0.7631]}, {"w": "will", "b": [0.6373, 0.7417, 0.6677, 0.7631]}, {"w": "likely", "b": [0.676, 0.7417, 0.7209, 0.7631]}, {"w": "fit", "b": [0.7292, 0.7417, 0.7473, 0.7631]}, {"w": "the", "b": [0.7556, 0.7417, 0.7819, 0.7631]}, {"w": "training", "b": [0.7902, 0.7417, 0.8572, 0.7631]}, {"w": "data", "b": [0.1429, 0.7608, 0.1781, 0.7822]}, {"w": "much", "b": [0.1833, 0.7608, 0.231, 0.7822]}, {"w": "better", "b": [0.2362, 0.7608, 0.2849, 0.7822]}, {"w": "than", "b": [0.2902, 0.7608, 0.3282, 0.7822]}, {"w": "with", "b": [0.3334, 0.7608, 0.3707, 0.7822]}, {"w": "plain", "b": [0.376, 0.7608, 0.4183, 0.7822]}, {"w": "Linear", "b": [0.4235, 0.7608, 0.4774, 0.7822]}, {"w": "Regression.", "b": [0.4826, 0.7608, 0.5784, 0.7822]}, {"w": "For", "b": [0.5836, 0.7608, 0.6126, 0.7822]}, {"w": "example,", "b": [0.6178, 0.7608, 0.6921, 0.7822]}, {"w": "Figure", "b": [0.6973, 0.7608, 0.7513, 0.7822]}, {"w": "4-14", "b": [0.7561, 0.7608, 0.7935, 0.7822]}, {"w": "applies", "b": [0.7992, 0.7608, 0.8571, 0.7822]}, {"w": "a", "b": [0.1428, 0.7798, 0.152, 0.8012]}, {"w": "300-degree", "b": [0.1604, 0.7798, 0.2529, 0.8012]}, {"w": "polynomial", "b": [0.2614, 0.7798, 0.3568, 0.8012]}, {"w": "model", "b": [0.3653, 0.7798, 0.4181, 0.8012]}, {"w": "to", "b": [0.4265, 0.7798, 0.4435, 0.8012]}, {"w": "the", "b": [0.452, 0.7798, 0.4783, 0.8012]}, {"w": "preceding", "b": [0.4868, 0.7798, 0.5697, 0.8012]}, {"w": "training", "b": [0.5781, 0.7798, 0.645, 0.8012]}, {"w": "data,", "b": [0.6535, 0.7798, 0.6935, 0.8012]}, {"w": "and", "b": [0.702, 0.7798, 0.7335, 0.8012]}, {"w": "compares", "b": [0.742, 0.7798, 0.8223, 0.8012]}, {"w": "the", "b": [0.8308, 0.7798, 0.8571, 0.8012]}, {"w": "result", "b": [0.1429, 0.7989, 0.1898, 0.8203]}, {"w": "with", "b": [0.1996, 0.7989, 0.237, 0.8203]}, {"w": "a", "b": [0.2468, 0.7989, 0.256, 0.8203]}, {"w": "pure", "b": [0.2658, 0.7989, 0.3044, 0.8203]}, {"w": "linear", "b": [0.3143, 0.7989, 0.3622, 0.8203]}, {"w": "model", "b": [0.3721, 0.7989, 0.4249, 0.8203]}, {"w": "and", "b": [0.4348, 0.7989, 0.4663, 0.8203]}, {"w": "a", "b": [0.4762, 0.7989, 0.4853, 0.8203]}, {"w": "quadratic", "b": [0.4952, 0.7989, 0.5742, 0.8203]}, {"w": "model", "b": [0.5841, 0.7989, 0.6369, 0.8203]}, {"w": "(2nd-degree", "b": [0.6468, 0.7989, 0.7399, 0.8203]}, {"w": "polynomial).", "b": [0.7497, 0.7989, 0.8571, 0.8203]}, {"w": "Notice", "b": [0.1429, 0.8179, 0.198, 0.8393]}, {"w": "how", "b": [0.2032, 0.8179, 0.2392, 0.8393]}, {"w": "the", "b": [0.2444, 0.8179, 0.2708, 0.8393]}, {"w": "300-degree", "b": [0.2759, 0.8179, 0.3684, 0.8393]}, {"w": "polynomial", "b": [0.3736, 0.8179, 0.469, 0.8393]}, {"w": "model", "b": [0.4742, 0.8179, 0.527, 0.8393]}, {"w": "wiggles", "b": [0.5322, 0.8179, 0.5933, 0.8393]}, {"w": "around", "b": [0.5985, 0.8179, 0.6595, 0.8393]}, {"w": "to", "b": [0.6647, 0.8179, 0.6816, 0.8393]}, {"w": "get", "b": [0.6868, 0.8179, 0.7118, 0.8393]}, {"w": "as", "b": [0.717, 0.8179, 0.7338, 0.8393]}, {"w": "close", "b": [0.7389, 0.8179, 0.7802, 0.8393]}, {"w": "as", "b": [0.7853, 0.8179, 0.8021, 0.8393]}, {"w": "possi‐", "b": [0.8073, 0.8179, 0.8571, 0.8393]}, {"w": "ble", "b": [0.1429, 0.837, 0.1676, 0.8584]}, {"w": "to", "b": [0.1723, 0.837, 0.1893, 0.8584]}, {"w": "the", "b": [0.194, 0.837, 0.2203, 0.8584]}, {"w": "training", "b": [0.2251, 0.837, 0.292, 0.8584]}, {"w": "instances.", "b": [0.2967, 0.837, 0.3783, 0.8584]}]}, {"id": "b_12", "type": "paragraph", "text": "132 | Chapter 4: Training Models", "words": [{"w": "132", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 159, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 4-14. High-degree Polynomial Regression", "words": [{"w": "Figure", "b": [0.1429, 0.381, 0.1943, 0.4027]}, {"w": "4-14.", "b": [0.1991, 0.381, 0.2407, 0.4027]}, {"w": "High-degree", "b": [0.2455, 0.381, 0.3433, 0.4027]}, {"w": "Polynomial", "b": [0.348, 0.381, 0.4404, 0.4027]}, {"w": "Regression", "b": [0.4451, 0.381, 0.5299, 0.4027]}]}, {"id": "b_1", "type": "paragraph", "text": "Of course, this high-degree Polynomial Regression model is severely overfitting the training data, while the linear model is underfitting it. The model that will generalize best in this case is the quadratic model. It makes sense since the data was generated using a quadratic model, but in general you won’t know what function generated the data, so how can you decide how complex your model should be? How can you tell that your model is overfitting or underfitting the data?", "words": [{"w": "Of", "b": [0.1429, 0.4184, 0.1646, 0.4399]}, {"w": "course,", "b": [0.1715, 0.4184, 0.231, 0.4399]}, {"w": "this", "b": [0.2378, 0.4184, 0.2685, 0.4399]}, {"w": "high-degree", "b": [0.2754, 0.4184, 0.3755, 0.4399]}, {"w": "Polynomial", "b": [0.3824, 0.4184, 0.478, 0.4399]}, {"w": "Regression", "b": [0.4849, 0.4184, 0.5759, 0.4399]}, {"w": "model", "b": [0.5828, 0.4184, 0.6356, 0.4399]}, {"w": "is", "b": [0.6425, 0.4184, 0.6557, 0.4399]}, {"w": "severely", "b": [0.6626, 0.4184, 0.729, 0.4399]}, {"w": "overfitting", "b": [0.7359, 0.4184, 0.8239, 0.4399]}, {"w": "the", "b": [0.8308, 0.4184, 0.8571, 0.4399]}, {"w": "training", "b": [0.1429, 0.4375, 0.2098, 0.4589]}, {"w": "data,", "b": [0.2153, 0.4375, 0.2553, 0.4589]}, {"w": "while", "b": [0.2607, 0.4375, 0.3058, 0.4589]}, {"w": "the", "b": [0.3113, 0.4375, 0.3376, 0.4589]}, {"w": "linear", "b": [0.3431, 0.4375, 0.3911, 0.4589]}, {"w": "model", "b": [0.3966, 0.4375, 0.4494, 0.4589]}, {"w": "is", "b": [0.4549, 0.4375, 0.4681, 0.4589]}, {"w": "underfitting", "b": [0.4736, 0.4375, 0.5748, 0.4589]}, {"w": "it.", "b": [0.5803, 0.4375, 0.597, 0.4589]}, {"w": "The", "b": [0.6024, 0.4375, 0.6353, 0.4589]}, {"w": "model", "b": [0.6407, 0.4375, 0.6935, 0.4589]}, {"w": "that", "b": [0.699, 0.4375, 0.7316, 0.4589]}, {"w": "will", "b": [0.7371, 0.4375, 0.7675, 0.4589]}, {"w": "generalize", "b": [0.7729, 0.4375, 0.8571, 0.4589]}, {"w": "best", "b": [0.1429, 0.4565, 0.1763, 0.478]}, {"w": "in", "b": [0.1827, 0.4565, 0.1997, 0.478]}, {"w": "this", "b": [0.2061, 0.4565, 0.2368, 0.478]}, {"w": "case", "b": [0.2432, 0.4565, 0.2776, 0.478]}, {"w": "is", "b": [0.284, 0.4565, 0.2973, 0.478]}, {"w": "the", "b": [0.3037, 0.4565, 0.33, 0.478]}, {"w": "quadratic", "b": [0.3364, 0.4565, 0.4155, 0.478]}, {"w": "model.", "b": [0.4219, 0.4565, 0.4794, 0.478]}, {"w": "It", "b": [0.4858, 0.4565, 0.4985, 0.478]}, {"w": "makes", "b": [0.5049, 0.4565, 0.5579, 0.478]}, {"w": "sense", "b": [0.5643, 0.4565, 0.6087, 0.478]}, {"w": "since", "b": [0.6151, 0.4565, 0.6574, 0.478]}, {"w": "the", "b": [0.6638, 0.4565, 0.6901, 0.478]}, {"w": "data", "b": [0.6965, 0.4565, 0.7318, 0.478]}, {"w": "was", "b": [0.7382, 0.4565, 0.7692, 0.478]}, {"w": "generated", "b": [0.7756, 0.4565, 0.8572, 0.478]}, {"w": "using", "b": [0.1429, 0.4756, 0.1883, 0.497]}, {"w": "a", "b": [0.194, 0.4756, 0.2032, 0.497]}, {"w": "quadratic", "b": [0.2089, 0.4756, 0.288, 0.497]}, {"w": "model,", "b": [0.2937, 0.4756, 0.3513, 0.497]}, {"w": "but", "b": [0.357, 0.4756, 0.385, 0.497]}, {"w": "in", "b": [0.3908, 0.4756, 0.4077, 0.497]}, {"w": "general", "b": [0.4135, 0.4756, 0.4745, 0.497]}, {"w": "you", "b": [0.4802, 0.4756, 0.5115, 0.497]}, {"w": "won’t", "b": [0.5172, 0.4756, 0.5621, 0.497]}, {"w": "know", "b": [0.5678, 0.4756, 0.6144, 0.497]}, {"w": "what", "b": [0.6202, 0.4756, 0.6607, 0.497]}, {"w": "function", "b": [0.6664, 0.4756, 0.7378, 0.497]}, {"w": "generated", "b": [0.7435, 0.4756, 0.8251, 0.497]}, {"w": "the", "b": [0.8308, 0.4756, 0.8571, 0.497]}, {"w": "data,", "b": [0.1429, 0.4946, 0.1829, 0.516]}, {"w": "so", "b": [0.1892, 0.4946, 0.2075, 0.516]}, {"w": "how", "b": [0.2139, 0.4946, 0.2499, 0.516]}, {"w": "can", "b": [0.2563, 0.4946, 0.2856, 0.516]}, {"w": "you", "b": [0.292, 0.4946, 0.3233, 0.516]}, {"w": "decide", "b": [0.3297, 0.4946, 0.3838, 0.516]}, {"w": "how", "b": [0.3902, 0.4946, 0.4262, 0.516]}, {"w": "complex", "b": [0.4326, 0.4946, 0.5035, 0.516]}, {"w": "your", "b": [0.5099, 0.4946, 0.5489, 0.516]}, {"w": "model", "b": [0.5553, 0.4946, 0.6081, 0.516]}, {"w": "should", "b": [0.6145, 0.4946, 0.6712, 0.516]}, {"w": "be?", "b": [0.6776, 0.4946, 0.7049, 0.516]}, {"w": "How", "b": [0.7113, 0.4946, 0.7516, 0.516]}, {"w": "can", "b": [0.758, 0.4946, 0.7874, 0.516]}, {"w": "you", "b": [0.7938, 0.4946, 0.825, 0.516]}, {"w": "tell", "b": [0.8314, 0.4946, 0.8571, 0.516]}, {"w": "that", "b": [0.1428, 0.5137, 0.1754, 0.5351]}, {"w": "your", "b": [0.1802, 0.5137, 0.2191, 0.5351]}, {"w": "model", "b": [0.2239, 0.5137, 0.2767, 0.5351]}, {"w": "is", "b": [0.2814, 0.5137, 0.2946, 0.5351]}, {"w": "overfitting", "b": [0.2994, 0.5137, 0.3874, 0.5351]}, {"w": "or", "b": [0.3921, 0.5137, 0.4105, 0.5351]}, {"w": "underfitting", "b": [0.4152, 0.5137, 0.5165, 0.5351]}, {"w": "the", "b": [0.5212, 0.5137, 0.5475, 0.5351]}, {"w": "data?", "b": [0.5522, 0.5137, 0.5954, 0.5351]}]}, {"id": "b_2", "type": "paragraph", "text": "In Chapter 2 you used cross-validation to get an estimate of a model’s generalization performance. If a model performs well on the training data but generalizes poorly according to the cross-validation metrics, then your model is overfitting. If it per‐ forms poorly on both, then it is underfitting. This is one way to tell when a model is too simple or too complex.", "words": [{"w": "In", "b": [0.1428, 0.5418, 0.1613, 0.5632]}, {"w": "Chapter", "b": [0.1672, 0.5418, 0.2348, 0.5632]}, {"w": "2", "b": [0.2407, 0.5418, 0.2507, 0.5632]}, {"w": "you", "b": [0.2566, 0.5418, 0.2879, 0.5632]}, {"w": "used", "b": [0.2938, 0.5418, 0.3323, 0.5632]}, {"w": "cross-validation", "b": [0.3382, 0.5418, 0.4715, 0.5632]}, {"w": "to", "b": [0.4774, 0.5418, 0.4943, 0.5632]}, {"w": "get", "b": [0.5002, 0.5418, 0.5252, 0.5632]}, {"w": "an", "b": [0.5311, 0.5418, 0.5516, 0.5632]}, {"w": "estimate", "b": [0.5575, 0.5418, 0.627, 0.5632]}, {"w": "of", "b": [0.6329, 0.5418, 0.6497, 0.5632]}, {"w": "a", "b": [0.6556, 0.5418, 0.6647, 0.5632]}, {"w": "model’s", "b": [0.6706, 0.5418, 0.7332, 0.5632]}, {"w": "generalization", "b": [0.7391, 0.5418, 0.8571, 0.5632]}, {"w": "performance.", "b": [0.1429, 0.5608, 0.2549, 0.5823]}, {"w": "If", "b": [0.2625, 0.5608, 0.2758, 0.5823]}, {"w": "a", "b": [0.2834, 0.5608, 0.2926, 0.5823]}, {"w": "model", "b": [0.3002, 0.5608, 0.353, 0.5823]}, {"w": "performs", "b": [0.3606, 0.5608, 0.4374, 0.5823]}, {"w": "well", "b": [0.445, 0.5608, 0.4787, 0.5823]}, {"w": "on", "b": [0.4863, 0.5608, 0.5083, 0.5823]}, {"w": "the", "b": [0.5159, 0.5608, 0.5423, 0.5823]}, {"w": "training", "b": [0.5499, 0.5608, 0.6168, 0.5823]}, {"w": "data", "b": [0.6245, 0.5608, 0.6597, 0.5823]}, {"w": "but", "b": [0.6673, 0.5608, 0.6953, 0.5823]}, {"w": "generalizes", "b": [0.703, 0.5608, 0.7948, 0.5823]}, {"w": "poorly", "b": [0.8024, 0.5608, 0.8571, 0.5823]}, {"w": "according", "b": [0.1429, 0.5799, 0.2257, 0.6013]}, {"w": "to", "b": [0.2334, 0.5799, 0.2504, 0.6013]}, {"w": "the", "b": [0.2581, 0.5799, 0.2844, 0.6013]}, {"w": "cross-validation", "b": [0.2921, 0.5799, 0.4254, 0.6013]}, {"w": "metrics,", "b": [0.4331, 0.5799, 0.4999, 0.6013]}, {"w": "then", "b": [0.5076, 0.5799, 0.5453, 0.6013]}, {"w": "your", "b": [0.553, 0.5799, 0.592, 0.6013]}, {"w": "model", "b": [0.5997, 0.5799, 0.6525, 0.6013]}, {"w": "is", "b": [0.6602, 0.5799, 0.6734, 0.6013]}, {"w": "overfitting.", "b": [0.6811, 0.5799, 0.7739, 0.6013]}, {"w": "If", "b": [0.7816, 0.5799, 0.7949, 0.6013]}, {"w": "it", "b": [0.8026, 0.5799, 0.8145, 0.6013]}, {"w": "per‐", "b": [0.8222, 0.5799, 0.8571, 0.6013]}, {"w": "forms", "b": [0.1429, 0.5989, 0.1921, 0.6204]}, {"w": "poorly", "b": [0.1979, 0.5989, 0.2526, 0.6204]}, {"w": "on", "b": [0.2584, 0.5989, 0.2804, 0.6204]}, {"w": "both,", "b": [0.2862, 0.5989, 0.3297, 0.6204]}, {"w": "then", "b": [0.3354, 0.5989, 0.3732, 0.6204]}, {"w": "it", "b": [0.379, 0.5989, 0.3909, 0.6204]}, {"w": "is", "b": [0.3967, 0.5989, 0.4099, 0.6204]}, {"w": "underfitting.", "b": [0.4157, 0.5989, 0.5217, 0.6204]}, {"w": "This", "b": [0.5275, 0.5989, 0.5647, 0.6204]}, {"w": "is", "b": [0.5705, 0.5989, 0.5837, 0.6204]}, {"w": "one", "b": [0.5895, 0.5989, 0.6204, 0.6204]}, {"w": "way", "b": [0.6262, 0.5989, 0.6588, 0.6204]}, {"w": "to", "b": [0.6646, 0.5989, 0.6816, 0.6204]}, {"w": "tell", "b": [0.6874, 0.5989, 0.7131, 0.6204]}, {"w": "when", "b": [0.7189, 0.5989, 0.7646, 0.6204]}, {"w": "a", "b": [0.7704, 0.5989, 0.7795, 0.6204]}, {"w": "model", "b": [0.7853, 0.5989, 0.8381, 0.6204]}, {"w": "is", "b": [0.8439, 0.5989, 0.8571, 0.6204]}, {"w": "too", "b": [0.1429, 0.618, 0.1705, 0.6394]}, {"w": "simple", "b": [0.1752, 0.618, 0.2301, 0.6394]}, {"w": "or", "b": [0.2349, 0.618, 0.2532, 0.6394]}, {"w": "too", "b": [0.2579, 0.618, 0.2856, 0.6394]}, {"w": "complex.", "b": [0.2903, 0.618, 0.366, 0.6394]}]}, {"id": "b_3", "type": "paragraph", "text": "Another way is to look at the learning curves: these are plots of the model’s perfor‐ mance on the training set and the validation set as a function of the training set size (or the training iteration). To generate the plots, simply train the model several times on different sized subsets of the training set. The following code defines a function that plots the learning curves of a model given some training data:", "words": [{"w": "Another", "b": [0.1429, 0.6461, 0.2133, 0.6675]}, {"w": "way", "b": [0.2204, 0.6461, 0.253, 0.6675]}, {"w": "is", "b": [0.26, 0.6461, 0.2732, 0.6675]}, {"w": "to", "b": [0.2803, 0.6461, 0.2972, 0.6675]}, {"w": "look", "b": [0.3043, 0.6461, 0.3411, 0.6675]}, {"w": "at", "b": [0.3482, 0.6461, 0.3633, 0.6675]}, {"w": "the", "b": [0.3703, 0.6461, 0.3966, 0.6675]}, {"w": "learning", "b": [0.4036, 0.6459, 0.4704, 0.6675]}, {"w": "curves:", "b": [0.4774, 0.6459, 0.5334, 0.6675]}, {"w": "these", "b": [0.5405, 0.6461, 0.5833, 0.6675]}, {"w": "are", "b": [0.5903, 0.6461, 0.616, 0.6675]}, {"w": "plots", "b": [0.6231, 0.6461, 0.6639, 0.6675]}, {"w": "of", "b": [0.6709, 0.6461, 0.6877, 0.6675]}, {"w": "the", "b": [0.6947, 0.6461, 0.7211, 0.6675]}, {"w": "model’s", "b": [0.7281, 0.6461, 0.7907, 0.6675]}, {"w": "perfor‐", "b": [0.7977, 0.6461, 0.8572, 0.6675]}, {"w": "mance", "b": [0.1429, 0.6652, 0.1981, 0.6866]}, {"w": "on", "b": [0.2041, 0.6652, 0.2261, 0.6866]}, {"w": "the", "b": [0.2321, 0.6652, 0.2584, 0.6866]}, {"w": "training", "b": [0.2644, 0.6652, 0.3314, 0.6866]}, {"w": "set", "b": [0.3373, 0.6652, 0.3602, 0.6866]}, {"w": "and", "b": [0.3662, 0.6652, 0.3977, 0.6866]}, {"w": "the", "b": [0.4037, 0.6652, 0.43, 0.6866]}, {"w": "validation", "b": [0.436, 0.6652, 0.5194, 0.6866]}, {"w": "set", "b": [0.5254, 0.6652, 0.5482, 0.6866]}, {"w": "as", "b": [0.5542, 0.6652, 0.571, 0.6866]}, {"w": "a", "b": [0.577, 0.6652, 0.5861, 0.6866]}, {"w": "function", "b": [0.5921, 0.6652, 0.6635, 0.6866]}, {"w": "of", "b": [0.6695, 0.6652, 0.6863, 0.6866]}, {"w": "the", "b": [0.6922, 0.6652, 0.7186, 0.6866]}, {"w": "training", "b": [0.7246, 0.6652, 0.7915, 0.6866]}, {"w": "set", "b": [0.7975, 0.6652, 0.8203, 0.6866]}, {"w": "size", "b": [0.8263, 0.6652, 0.8571, 0.6866]}, {"w": "(or", "b": [0.1429, 0.6842, 0.1684, 0.7056]}, {"w": "the", "b": [0.1739, 0.6842, 0.2002, 0.7056]}, {"w": "training", "b": [0.2056, 0.6842, 0.2726, 0.7056]}, {"w": "iteration).", "b": [0.278, 0.6842, 0.3612, 0.7056]}, {"w": "To", "b": [0.3666, 0.6842, 0.3881, 0.7056]}, {"w": "generate", "b": [0.3935, 0.6842, 0.4641, 0.7056]}, {"w": "the", "b": [0.4695, 0.6842, 0.4958, 0.7056]}, {"w": "plots,", "b": [0.5013, 0.6842, 0.5468, 0.7056]}, {"w": "simply", "b": [0.5523, 0.6842, 0.6079, 0.7056]}, {"w": "train", "b": [0.6134, 0.6842, 0.6536, 0.7056]}, {"w": "the", "b": [0.659, 0.6842, 0.6854, 0.7056]}, {"w": "model", "b": [0.6908, 0.6842, 0.7436, 0.7056]}, {"w": "several", "b": [0.7491, 0.6842, 0.8062, 0.7056]}, {"w": "times", "b": [0.8116, 0.6842, 0.8571, 0.7056]}, {"w": "on", "b": [0.1428, 0.7032, 0.1649, 0.7247]}, {"w": "different", "b": [0.1718, 0.7032, 0.2435, 0.7247]}, {"w": "sized", "b": [0.2504, 0.7032, 0.2923, 0.7247]}, {"w": "subsets", "b": [0.2992, 0.7032, 0.359, 0.7247]}, {"w": "of", "b": [0.3659, 0.7032, 0.3827, 0.7247]}, {"w": "the", "b": [0.3897, 0.7032, 0.416, 0.7247]}, {"w": "training", "b": [0.4229, 0.7032, 0.4899, 0.7247]}, {"w": "set.", "b": [0.4968, 0.7032, 0.5244, 0.7247]}, {"w": "The", "b": [0.5313, 0.7032, 0.5642, 0.7247]}, {"w": "following", "b": [0.5711, 0.7032, 0.6501, 0.7247]}, {"w": "code", "b": [0.657, 0.7032, 0.6963, 0.7247]}, {"w": "defines", "b": [0.7032, 0.7032, 0.7627, 0.7247]}, {"w": "a", "b": [0.7697, 0.7032, 0.7788, 0.7247]}, {"w": "function", "b": [0.7857, 0.7032, 0.8571, 0.7247]}, {"w": "that", "b": [0.1429, 0.7223, 0.1754, 0.7437]}, {"w": "plots", "b": [0.1802, 0.7223, 0.221, 0.7437]}, {"w": "the", "b": [0.2257, 0.7223, 0.252, 0.7437]}, {"w": "learning", "b": [0.2568, 0.7223, 0.3259, 0.7437]}, {"w": "curves", "b": [0.3306, 0.7223, 0.385, 0.7437]}, {"w": "of", "b": [0.3897, 0.7223, 0.4065, 0.7437]}, {"w": "a", "b": [0.4112, 0.7223, 0.4204, 0.7437]}, {"w": "model", "b": [0.4251, 0.7223, 0.4779, 0.7437]}, {"w": "given", "b": [0.4827, 0.7223, 0.5279, 0.7437]}, {"w": "some", "b": [0.5326, 0.7223, 0.5768, 0.7437]}, {"w": "training", "b": [0.5815, 0.7223, 0.6485, 0.7437]}, {"w": "data:", "b": [0.6532, 0.7223, 0.6932, 0.7437]}]}, {"id": "b_4", "type": "paragraph", "text": "from sklearn.metrics import mean_squared_error from sklearn.model_selection import train_test_split", "words": [{"w": "from", "b": [0.1766, 0.7543, 0.2103, 0.7671]}, {"w": "sklearn.metrics", "b": [0.2187, 0.7543, 0.3452, 0.7671]}, {"w": "import", "b": [0.3537, 0.7543, 0.4043, 0.7671]}, {"w": "mean_squared_error", "b": [0.4127, 0.7543, 0.5645, 0.7671]}, {"w": "from", "b": [0.1766, 0.7697, 0.2103, 0.7825]}, {"w": "sklearn.model_selection", "b": [0.2187, 0.7697, 0.4127, 0.7825]}, {"w": "import", "b": [0.4211, 0.7697, 0.4717, 0.7825]}, {"w": "train_test_split", "b": [0.4802, 0.7697, 0.6151, 0.7825]}]}, {"id": "b_5", "type": "paragraph", "text": "def plot_learning_curves(model, X, y): X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.2) train_errors, val_errors = [], [] for m in range(1, len(X_train)): model.fit(X_train[:m], y_train[:m]) y_train_predict = model.predict(X_train[:m])", "words": [{"w": "def", "b": [0.1766, 0.8005, 0.2019, 0.8134]}, {"w": "plot_learning_curves(model,", "b": [0.2103, 0.8005, 0.438, 0.8134]}, {"w": "X,", "b": [0.4464, 0.8005, 0.4633, 0.8134]}, {"w": "y):", "b": [0.4717, 0.8005, 0.497, 0.8134]}, {"w": "X_train,", "b": [0.2103, 0.8159, 0.2778, 0.8288]}, {"w": "X_val,", "b": [0.2862, 0.8159, 0.3368, 0.8288]}, {"w": "y_train,", "b": [0.3452, 0.8159, 0.4127, 0.8288]}, {"w": "y_val", "b": [0.4211, 0.8159, 0.4633, 0.8288]}, {"w": "=", "b": [0.4717, 0.8159, 0.4802, 0.8288]}, {"w": "train_test_split(X,", "b": [0.4886, 0.8159, 0.6488, 0.8288]}, {"w": "y,", "b": [0.6572, 0.8159, 0.6741, 0.8288]}, {"w": "test_size=0.2)", "b": [0.6825, 0.8159, 0.8006, 0.8288]}, {"w": "train_errors,", "b": [0.2103, 0.8314, 0.3199, 0.8442]}, {"w": "val_errors", "b": [0.3284, 0.8314, 0.4127, 0.8442]}, {"w": "=", "b": [0.4211, 0.8314, 0.4296, 0.8442]}, {"w": "[],", "b": [0.438, 0.8314, 0.4633, 0.8442]}, {"w": "[]", "b": [0.4717, 0.8314, 0.4886, 0.8442]}, {"w": "for", "b": [0.2103, 0.8468, 0.2356, 0.8596]}, {"w": "m", "b": [0.244, 0.8468, 0.2525, 0.8596]}, {"w": "in", "b": [0.2609, 0.8468, 0.2778, 0.8596]}, {"w": "range(1,", "b": [0.2862, 0.8468, 0.3537, 0.8596]}, {"w": "len(X_train)):", "b": [0.3621, 0.8468, 0.4802, 0.8596]}, {"w": "model.fit(X_train[:m],", "b": [0.244, 0.8622, 0.4296, 0.8751]}, {"w": "y_train[:m])", "b": [0.438, 0.8622, 0.5392, 0.8751]}, {"w": "y_train_predict", "b": [0.244, 0.8776, 0.3705, 0.8905]}, {"w": "=", "b": [0.379, 0.8776, 0.3874, 0.8905]}, {"w": "model.predict(X_train[:m])", "b": [0.3958, 0.8776, 0.6151, 0.8905]}]}, {"id": "b_6", "type": "paragraph", "text": "Learning Curves | 133", "words": [{"w": "Learning", "b": [0.7022, 0.9225, 0.7544, 0.9388]}, {"w": "Curves", "b": [0.7572, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "133", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 160, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "y_val_predict = model.predict(X_val) train_errors.append(mean_squared_error(y_train[:m], y_train_predict)) val_errors.append(mean_squared_error(y_val, y_val_predict)) plt.plot(np.sqrt(train_errors), \"r-+\", linewidth=2, label=\"train\") plt.plot(np.sqrt(val_errors), \"b-\", linewidth=3, label=\"val\")", "words": [{"w": "y_val_predict", "b": [0.244, 0.0829, 0.3537, 0.0958]}, {"w": "=", "b": [0.3621, 0.0829, 0.3705, 0.0958]}, {"w": "model.predict(X_val)", "b": [0.379, 0.0829, 0.5476, 0.0958]}, {"w": "train_errors.append(mean_squared_error(y_train[:m],", "b": [0.244, 0.0983, 0.6741, 0.1112]}, {"w": "y_train_predict))", "b": [0.6825, 0.0983, 0.8259, 0.1112]}, {"w": "val_errors.append(mean_squared_error(y_val,", "b": [0.244, 0.1138, 0.6066, 0.1266]}, {"w": "y_val_predict))", "b": [0.6151, 0.1138, 0.7416, 0.1266]}, {"w": "plt.plot(np.sqrt(train_errors),", "b": [0.2103, 0.1292, 0.4717, 0.142]}, {"w": "\"r-+\",", "b": [0.4802, 0.1292, 0.5308, 0.142]}, {"w": "linewidth=2,", "b": [0.5392, 0.1292, 0.6404, 0.142]}, {"w": "label=\"train\")", "b": [0.6488, 0.1292, 0.7669, 0.142]}, {"w": "plt.plot(np.sqrt(val_errors),", "b": [0.2103, 0.1446, 0.4549, 0.1574]}, {"w": "\"b-\",", "b": [0.4633, 0.1446, 0.5055, 0.1574]}, {"w": "linewidth=3,", "b": [0.5139, 0.1446, 0.6151, 0.1574]}, {"w": "label=\"val\")", "b": [0.6235, 0.1446, 0.7247, 0.1574]}]}, {"id": "b_1", "type": "paragraph", "text": "Let’s look at the learning curves of the plain Linear Regression model (a straight line; Figure 4-15):", "words": [{"w": "Let’s", "b": [0.1428, 0.1652, 0.179, 0.1866]}, {"w": "look", "b": [0.1846, 0.1652, 0.2214, 0.1866]}, {"w": "at", "b": [0.227, 0.1652, 0.2421, 0.1866]}, {"w": "the", "b": [0.2476, 0.1652, 0.2739, 0.1866]}, {"w": "learning", "b": [0.2795, 0.1652, 0.3486, 0.1866]}, {"w": "curves", "b": [0.3542, 0.1652, 0.4085, 0.1866]}, {"w": "of", "b": [0.4141, 0.1652, 0.4309, 0.1866]}, {"w": "the", "b": [0.4364, 0.1652, 0.4627, 0.1866]}, {"w": "plain", "b": [0.4683, 0.1652, 0.5106, 0.1866]}, {"w": "Linear", "b": [0.5161, 0.1652, 0.5701, 0.1866]}, {"w": "Regression", "b": [0.5756, 0.1652, 0.6666, 0.1866]}, {"w": "model", "b": [0.6722, 0.1652, 0.725, 0.1866]}, {"w": "(a", "b": [0.7305, 0.1652, 0.7469, 0.1866]}, {"w": "straight", "b": [0.7524, 0.1652, 0.8157, 0.1866]}, {"w": "line;", "b": [0.8213, 0.1652, 0.8571, 0.1866]}, {"w": "Figure", "b": [0.1429, 0.1843, 0.1969, 0.2057]}, {"w": "4-15):", "b": [0.2016, 0.1843, 0.251, 0.2057]}]}, {"id": "b_2", "type": "equation", "text": "lin_reg = LinearRegression() plot_learning_curves(lin_reg, X, y)", "words": [{"w": "lin_reg", "b": [0.1766, 0.2163, 0.2356, 0.2291]}, {"w": "=", "b": [0.2441, 0.2163, 0.2525, 0.2291]}, {"w": "LinearRegression()", "b": [0.2609, 0.2163, 0.4127, 0.2291]}, {"w": "plot_learning_curves(lin_reg,", "b": [0.1766, 0.2317, 0.4211, 0.2445]}, {"w": "X,", "b": [0.4296, 0.2317, 0.4464, 0.2445]}, {"w": "y)", "b": [0.4549, 0.2317, 0.4717, 0.2445]}]}, {"id": "b_3", "type": "equation", "text": "Figure 4-15. Learning curves", "words": [{"w": "Figure", "b": [0.1429, 0.5211, 0.1943, 0.5427]}, {"w": "4-15.", "b": [0.1991, 0.5211, 0.2407, 0.5427]}, {"w": "Learning", "b": [0.2455, 0.5211, 0.3183, 0.5427]}, {"w": "curves", "b": [0.323, 0.5211, 0.3743, 0.5427]}]}, {"id": "b_4", "type": "paragraph", "text": "This deserves a bit of explanation. First, let’s look at the performance on the training data: when there are just one or two instances in the training set, the model can fit them perfectly, which is why the curve starts at zero. But as new instances are added to the training set, it becomes impossible for the model to fit the training data per‐ fectly, both because the data is noisy and because it is not linear at all. So the error on the training data goes up until it reaches a plateau, at which point adding new instan‐ ces to the training set doesn’t make the average error much better or worse. Now let’s look at the performance of the model on the validation data. When the model is trained on very few training instances, it is incapable of generalizing properly, which is why the validation error is initially quite big. Then as the model is shown more training examples, it learns and thus the validation error slowly goes down. However, once again a straight line cannot do a good job modeling the data, so the error ends up at a plateau, very close to the other curve.", "words": [{"w": "This", "b": [0.1429, 0.5585, 0.1801, 0.5799]}, {"w": "deserves", "b": [0.1858, 0.5585, 0.2567, 0.5799]}, {"w": "a", "b": [0.2624, 0.5585, 0.2716, 0.5799]}, {"w": "bit", "b": [0.2773, 0.5585, 0.2999, 0.5799]}, {"w": "of", "b": [0.3056, 0.5585, 0.3224, 0.5799]}, {"w": "explanation.", "b": [0.3282, 0.5585, 0.4311, 0.5799]}, {"w": "First,", "b": [0.4368, 0.5585, 0.4799, 0.5799]}, {"w": "let’s", "b": [0.4857, 0.5585, 0.5159, 0.5799]}, {"w": "look", "b": [0.5217, 0.5585, 0.5585, 0.5799]}, {"w": "at", "b": [0.5643, 0.5585, 0.5794, 0.5799]}, {"w": "the", "b": [0.5852, 0.5585, 0.6115, 0.5799]}, {"w": "performance", "b": [0.6173, 0.5585, 0.7246, 0.5799]}, {"w": "on", "b": [0.7303, 0.5585, 0.7523, 0.5799]}, {"w": "the", "b": [0.7581, 0.5585, 0.7844, 0.5799]}, {"w": "training", "b": [0.7902, 0.5585, 0.8571, 0.5799]}, {"w": "data:", "b": [0.1429, 0.5775, 0.1829, 0.5989]}, {"w": "when", "b": [0.1896, 0.5775, 0.2352, 0.5989]}, {"w": "there", "b": [0.242, 0.5775, 0.2849, 0.5989]}, {"w": "are", "b": [0.2916, 0.5775, 0.3174, 0.5989]}, {"w": "just", "b": [0.3241, 0.5775, 0.3545, 0.5989]}, {"w": "one", "b": [0.3612, 0.5775, 0.3921, 0.5989]}, {"w": "or", "b": [0.3988, 0.5775, 0.4172, 0.5989]}, {"w": "two", "b": [0.4239, 0.5775, 0.4552, 0.5989]}, {"w": "instances", "b": [0.4619, 0.5775, 0.5388, 0.5989]}, {"w": "in", "b": [0.5455, 0.5775, 0.5625, 0.5989]}, {"w": "the", "b": [0.5692, 0.5775, 0.5956, 0.5989]}, {"w": "training", "b": [0.6023, 0.5775, 0.6692, 0.5989]}, {"w": "set,", "b": [0.676, 0.5775, 0.7036, 0.5989]}, {"w": "the", "b": [0.7103, 0.5775, 0.7366, 0.5989]}, {"w": "model", "b": [0.7434, 0.5775, 0.7962, 0.5989]}, {"w": "can", "b": [0.8029, 0.5775, 0.8323, 0.5989]}, {"w": "fit", "b": [0.839, 0.5775, 0.8571, 0.5989]}, {"w": "them", "b": [0.1429, 0.5966, 0.1863, 0.618]}, {"w": "perfectly,", "b": [0.1922, 0.5966, 0.2679, 0.618]}, {"w": "which", "b": [0.2739, 0.5966, 0.3248, 0.618]}, {"w": "is", "b": [0.3307, 0.5966, 0.3439, 0.618]}, {"w": "why", "b": [0.3498, 0.5966, 0.3843, 0.618]}, {"w": "the", "b": [0.3903, 0.5966, 0.4166, 0.618]}, {"w": "curve", "b": [0.4225, 0.5966, 0.4692, 0.618]}, {"w": "starts", "b": [0.4751, 0.5966, 0.52, 0.618]}, {"w": "at", "b": [0.5259, 0.5966, 0.541, 0.618]}, {"w": "zero.", "b": [0.547, 0.5966, 0.5871, 0.618]}, {"w": "But", "b": [0.593, 0.5966, 0.6227, 0.618]}, {"w": "as", "b": [0.6286, 0.5966, 0.6454, 0.618]}, {"w": "new", "b": [0.6513, 0.5966, 0.6858, 0.618]}, {"w": "instances", "b": [0.6917, 0.5966, 0.7686, 0.618]}, {"w": "are", "b": [0.7745, 0.5966, 0.8002, 0.618]}, {"w": "added", "b": [0.8062, 0.5966, 0.8572, 0.618]}, {"w": "to", "b": [0.1429, 0.6156, 0.1598, 0.637]}, {"w": "the", "b": [0.1665, 0.6156, 0.1929, 0.637]}, {"w": "training", "b": [0.1996, 0.6156, 0.2665, 0.637]}, {"w": "set,", "b": [0.2732, 0.6156, 0.3008, 0.637]}, {"w": "it", "b": [0.3075, 0.6156, 0.3194, 0.637]}, {"w": "becomes", "b": [0.3261, 0.6156, 0.3986, 0.637]}, {"w": "impossible", "b": [0.4053, 0.6156, 0.4947, 0.637]}, {"w": "for", "b": [0.5014, 0.6156, 0.5259, 0.637]}, {"w": "the", "b": [0.5326, 0.6156, 0.5589, 0.637]}, {"w": "model", "b": [0.5656, 0.6156, 0.6184, 0.637]}, {"w": "to", "b": [0.6251, 0.6156, 0.6421, 0.637]}, {"w": "fit", "b": [0.6488, 0.6156, 0.6669, 0.637]}, {"w": "the", "b": [0.6736, 0.6156, 0.6999, 0.637]}, {"w": "training", "b": [0.7066, 0.6156, 0.7736, 0.637]}, {"w": "data", "b": [0.7803, 0.6156, 0.8155, 0.637]}, {"w": "per‐", "b": [0.8222, 0.6156, 0.8571, 0.637]}, {"w": "fectly,", "b": [0.1429, 0.6347, 0.1911, 0.6561]}, {"w": "both", "b": [0.1964, 0.6347, 0.235, 0.6561]}, {"w": "because", "b": [0.2403, 0.6347, 0.3049, 0.6561]}, {"w": "the", "b": [0.3101, 0.6347, 0.3364, 0.6561]}, {"w": "data", "b": [0.3417, 0.6347, 0.3769, 0.6561]}, {"w": "is", "b": [0.3822, 0.6347, 0.3954, 0.6561]}, {"w": "noisy", "b": [0.4007, 0.6347, 0.4455, 0.6561]}, {"w": "and", "b": [0.4507, 0.6347, 0.4823, 0.6561]}, {"w": "because", "b": [0.4875, 0.6347, 0.5521, 0.6561]}, {"w": "it", "b": [0.5573, 0.6347, 0.5693, 0.6561]}, {"w": "is", "b": [0.5745, 0.6347, 0.5877, 0.6561]}, {"w": "not", "b": [0.593, 0.6347, 0.6214, 0.6561]}, {"w": "linear", "b": [0.6266, 0.6347, 0.6746, 0.6561]}, {"w": "at", "b": [0.6798, 0.6347, 0.6949, 0.6561]}, {"w": "all.", "b": [0.7002, 0.6347, 0.7246, 0.6561]}, {"w": "So", "b": [0.7299, 0.6347, 0.7504, 0.6561]}, {"w": "the", "b": [0.7556, 0.6347, 0.782, 0.6561]}, {"w": "error", "b": [0.7872, 0.6347, 0.8299, 0.6561]}, {"w": "on", "b": [0.8351, 0.6347, 0.8571, 0.6561]}, {"w": "the", "b": [0.1428, 0.6537, 0.1692, 0.6751]}, {"w": "training", "b": [0.1744, 0.6537, 0.2413, 0.6751]}, {"w": "data", "b": [0.2465, 0.6537, 0.2817, 0.6751]}, {"w": "goes", "b": [0.2869, 0.6537, 0.3238, 0.6751]}, {"w": "up", "b": [0.329, 0.6537, 0.351, 0.6751]}, {"w": "until", "b": [0.3562, 0.6537, 0.3954, 0.6751]}, {"w": "it", "b": [0.4006, 0.6537, 0.4126, 0.6751]}, {"w": "reaches", "b": [0.4178, 0.6537, 0.4799, 0.6751]}, {"w": "a", "b": [0.4851, 0.6537, 0.4943, 0.6751]}, {"w": "plateau,", "b": [0.4995, 0.6537, 0.5642, 0.6751]}, {"w": "at", "b": [0.5694, 0.6537, 0.5845, 0.6751]}, {"w": "which", "b": [0.5896, 0.6537, 0.6406, 0.6751]}, {"w": "point", "b": [0.6458, 0.6537, 0.6902, 0.6751]}, {"w": "adding", "b": [0.6954, 0.6537, 0.7533, 0.6751]}, {"w": "new", "b": [0.7585, 0.6537, 0.793, 0.6751]}, {"w": "instan‐", "b": [0.7982, 0.6537, 0.8571, 0.6751]}, {"w": "ces", "b": [0.1429, 0.6728, 0.1682, 0.6942]}, {"w": "to", "b": [0.1736, 0.6728, 0.1906, 0.6942]}, {"w": "the", "b": [0.1961, 0.6728, 0.2224, 0.6942]}, {"w": "training", "b": [0.2279, 0.6728, 0.2948, 0.6942]}, {"w": "set", "b": [0.3003, 0.6728, 0.3231, 0.6942]}, {"w": "doesn’t", "b": [0.3286, 0.6728, 0.3867, 0.6942]}, {"w": "make", "b": [0.3921, 0.6728, 0.4375, 0.6942]}, {"w": "the", "b": [0.443, 0.6728, 0.4693, 0.6942]}, {"w": "average", "b": [0.4748, 0.6728, 0.5375, 0.6942]}, {"w": "error", "b": [0.543, 0.6728, 0.5857, 0.6942]}, {"w": "much", "b": [0.5911, 0.6728, 0.6388, 0.6942]}, {"w": "better", "b": [0.6443, 0.6728, 0.693, 0.6942]}, {"w": "or", "b": [0.6985, 0.6728, 0.7168, 0.6942]}, {"w": "worse.", "b": [0.7223, 0.6728, 0.7761, 0.6942]}, {"w": "Now", "b": [0.7816, 0.6728, 0.8215, 0.6942]}, {"w": "let’s", "b": [0.8269, 0.6728, 0.8571, 0.6942]}, {"w": "look", "b": [0.1429, 0.6918, 0.1797, 0.7132]}, {"w": "at", "b": [0.1881, 0.6918, 0.2032, 0.7132]}, {"w": "the", "b": [0.2115, 0.6918, 0.2379, 0.7132]}, {"w": "performance", "b": [0.2462, 0.6918, 0.3535, 0.7132]}, {"w": "of", "b": [0.3619, 0.6918, 0.3787, 0.7132]}, {"w": "the", "b": [0.387, 0.6918, 0.4134, 0.7132]}, {"w": "model", "b": [0.4217, 0.6918, 0.4746, 0.7132]}, {"w": "on", "b": [0.4829, 0.6918, 0.5049, 0.7132]}, {"w": "the", "b": [0.5133, 0.6918, 0.5396, 0.7132]}, {"w": "validation", "b": [0.548, 0.6918, 0.6313, 0.7132]}, {"w": "data.", "b": [0.6397, 0.6918, 0.6797, 0.7132]}, {"w": "When", "b": [0.6881, 0.6918, 0.7397, 0.7132]}, {"w": "the", "b": [0.748, 0.6918, 0.7744, 0.7132]}, {"w": "model", "b": [0.7827, 0.6918, 0.8356, 0.7132]}, {"w": "is", "b": [0.8439, 0.6918, 0.8571, 0.7132]}, {"w": "trained", "b": [0.1429, 0.7109, 0.2029, 0.7323]}, {"w": "on", "b": [0.2087, 0.7109, 0.2307, 0.7323]}, {"w": "very", "b": [0.2364, 0.7109, 0.2728, 0.7323]}, {"w": "few", "b": [0.2786, 0.7109, 0.3078, 0.7323]}, {"w": "training", "b": [0.3136, 0.7109, 0.3805, 0.7323]}, {"w": "instances,", "b": [0.3863, 0.7109, 0.4679, 0.7323]}, {"w": "it", "b": [0.4736, 0.7109, 0.4855, 0.7323]}, {"w": "is", "b": [0.4913, 0.7109, 0.5045, 0.7323]}, {"w": "incapable", "b": [0.5102, 0.7109, 0.5896, 0.7323]}, {"w": "of", "b": [0.5953, 0.7109, 0.6121, 0.7323]}, {"w": "generalizing", "b": [0.6178, 0.7109, 0.7199, 0.7323]}, {"w": "properly,", "b": [0.7256, 0.7109, 0.8005, 0.7323]}, {"w": "which", "b": [0.8062, 0.7109, 0.8571, 0.7323]}, {"w": "is", "b": [0.1429, 0.7299, 0.1561, 0.7513]}, {"w": "why", "b": [0.1635, 0.7299, 0.198, 0.7513]}, {"w": "the", "b": [0.2054, 0.7299, 0.2318, 0.7513]}, {"w": "validation", "b": [0.2392, 0.7299, 0.3225, 0.7513]}, {"w": "error", "b": [0.33, 0.7299, 0.3726, 0.7513]}, {"w": "is", "b": [0.38, 0.7299, 0.3933, 0.7513]}, {"w": "initially", "b": [0.4007, 0.7299, 0.4644, 0.7513]}, {"w": "quite", "b": [0.4719, 0.7299, 0.5144, 0.7513]}, {"w": "big.", "b": [0.5218, 0.7299, 0.5525, 0.7513]}, {"w": "Then", "b": [0.5599, 0.7299, 0.6041, 0.7513]}, {"w": "as", "b": [0.6115, 0.7299, 0.6283, 0.7513]}, {"w": "the", "b": [0.6357, 0.7299, 0.6621, 0.7513]}, {"w": "model", "b": [0.6695, 0.7299, 0.7223, 0.7513]}, {"w": "is", "b": [0.7297, 0.7299, 0.743, 0.7513]}, {"w": "shown", "b": [0.7504, 0.7299, 0.8055, 0.7513]}, {"w": "more", "b": [0.8129, 0.7299, 0.8572, 0.7513]}, {"w": "training", "b": [0.1429, 0.749, 0.2098, 0.7704]}, {"w": "examples,", "b": [0.2151, 0.749, 0.297, 0.7704]}, {"w": "it", "b": [0.3023, 0.749, 0.3142, 0.7704]}, {"w": "learns", "b": [0.3195, 0.749, 0.3695, 0.7704]}, {"w": "and", "b": [0.3748, 0.749, 0.4064, 0.7704]}, {"w": "thus", "b": [0.4116, 0.749, 0.4474, 0.7704]}, {"w": "the", "b": [0.4527, 0.749, 0.479, 0.7704]}, {"w": "validation", "b": [0.4843, 0.749, 0.5677, 0.7704]}, {"w": "error", "b": [0.573, 0.749, 0.6156, 0.7704]}, {"w": "slowly", "b": [0.6209, 0.749, 0.6735, 0.7704]}, {"w": "goes", "b": [0.6788, 0.749, 0.7157, 0.7704]}, {"w": "down.", "b": [0.721, 0.749, 0.773, 0.7704]}, {"w": "However,", "b": [0.7783, 0.749, 0.8571, 0.7704]}, {"w": "once", "b": [0.1429, 0.768, 0.1825, 0.7894]}, {"w": "again", "b": [0.1886, 0.768, 0.2336, 0.7894]}, {"w": "a", "b": [0.2397, 0.768, 0.2488, 0.7894]}, {"w": "straight", "b": [0.2549, 0.768, 0.3182, 0.7894]}, {"w": "line", "b": [0.3242, 0.768, 0.3553, 0.7894]}, {"w": "cannot", "b": [0.3614, 0.768, 0.4191, 0.7894]}, {"w": "do", "b": [0.4252, 0.768, 0.4468, 0.7894]}, {"w": "a", "b": [0.4529, 0.768, 0.462, 0.7894]}, {"w": "good", "b": [0.4681, 0.768, 0.5101, 0.7894]}, {"w": "job", "b": [0.5161, 0.768, 0.5427, 0.7894]}, {"w": "modeling", "b": [0.5487, 0.768, 0.6283, 0.7894]}, {"w": "the", "b": [0.6343, 0.768, 0.6607, 0.7894]}, {"w": "data,", "b": [0.6667, 0.768, 0.7067, 0.7894]}, {"w": "so", "b": [0.7128, 0.768, 0.7311, 0.7894]}, {"w": "the", "b": [0.7371, 0.768, 0.7635, 0.7894]}, {"w": "error", "b": [0.7695, 0.768, 0.8122, 0.7894]}, {"w": "ends", "b": [0.8182, 0.768, 0.8571, 0.7894]}, {"w": "up", "b": [0.1428, 0.7871, 0.1648, 0.8085]}, {"w": "at", "b": [0.1696, 0.7871, 0.1847, 0.8085]}, {"w": "a", "b": [0.1894, 0.7871, 0.1985, 0.8085]}, {"w": "plateau,", "b": [0.2033, 0.7871, 0.268, 0.8085]}, {"w": "very", "b": [0.2727, 0.7871, 0.3091, 0.8085]}, {"w": "close", "b": [0.3138, 0.7871, 0.355, 0.8085]}, {"w": "to", "b": [0.3598, 0.7871, 0.3767, 0.8085]}, {"w": "the", "b": [0.3815, 0.7871, 0.4078, 0.8085]}, {"w": "other", "b": [0.4125, 0.7871, 0.4572, 0.8085]}, {"w": "curve.", "b": [0.462, 0.7871, 0.5134, 0.8085]}]}, {"id": "b_5", "type": "paragraph", "text": "These learning curves are typical of an underfitting model. Both curves have reached a plateau; they are close and fairly high.", "words": [{"w": "These", "b": [0.1428, 0.8152, 0.1922, 0.8366]}, {"w": "learning", "b": [0.1976, 0.8152, 0.2667, 0.8366]}, {"w": "curves", "b": [0.2721, 0.8152, 0.3265, 0.8366]}, {"w": "are", "b": [0.3319, 0.8152, 0.3576, 0.8366]}, {"w": "typical", "b": [0.363, 0.8152, 0.4187, 0.8366]}, {"w": "of", "b": [0.4241, 0.8152, 0.4409, 0.8366]}, {"w": "an", "b": [0.4463, 0.8152, 0.4668, 0.8366]}, {"w": "underfitting", "b": [0.4722, 0.8152, 0.5735, 0.8366]}, {"w": "model.", "b": [0.5789, 0.8152, 0.6364, 0.8366]}, {"w": "Both", "b": [0.6419, 0.8152, 0.6826, 0.8366]}, {"w": "curves", "b": [0.688, 0.8152, 0.7424, 0.8366]}, {"w": "have", "b": [0.7478, 0.8152, 0.7862, 0.8366]}, {"w": "reached", "b": [0.7916, 0.8152, 0.8571, 0.8366]}, {"w": "a", "b": [0.1429, 0.8342, 0.152, 0.8556]}, {"w": "plateau;", "b": [0.1567, 0.8342, 0.2214, 0.8556]}, {"w": "they", "b": [0.2262, 0.8342, 0.2621, 0.8556]}, {"w": "are", "b": [0.2668, 0.8342, 0.2925, 0.8556]}, {"w": "close", "b": [0.2973, 0.8342, 0.3385, 0.8556]}, {"w": "and", "b": [0.3432, 0.8342, 0.3747, 0.8556]}, {"w": "fairly", "b": [0.3795, 0.8342, 0.4229, 0.8556]}, {"w": "high.", "b": [0.4277, 0.8342, 0.47, 0.8556]}]}, {"id": "b_6", "type": "paragraph", "text": "134 | Chapter 4: Training Models", "words": [{"w": "134", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 161, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "If your model is underfitting the training data, adding more train‐ ing examples will not help. You need to use a more complex model or come up with better features.", "words": [{"w": "If", "b": [0.2714, 0.0793, 0.2835, 0.0989]}, {"w": "your", "b": [0.289, 0.0793, 0.3247, 0.0989]}, {"w": "model", "b": [0.3301, 0.0793, 0.3784, 0.0989]}, {"w": "is", "b": [0.3839, 0.0793, 0.396, 0.0989]}, {"w": "underfitting", "b": [0.4015, 0.0793, 0.494, 0.0989]}, {"w": "the", "b": [0.4995, 0.0793, 0.5236, 0.0989]}, {"w": "training", "b": [0.5291, 0.0793, 0.5903, 0.0989]}, {"w": "data,", "b": [0.5958, 0.0793, 0.6323, 0.0989]}, {"w": "adding", "b": [0.6378, 0.0793, 0.6907, 0.0989]}, {"w": "more", "b": [0.6962, 0.0793, 0.7367, 0.0989]}, {"w": "train‐", "b": [0.7422, 0.0793, 0.7857, 0.0989]}, {"w": "ing", "b": [0.2714, 0.0967, 0.2958, 0.1163]}, {"w": "examples", "b": [0.3008, 0.0967, 0.3714, 0.1163]}, {"w": "will", "b": [0.3764, 0.0967, 0.4042, 0.1163]}, {"w": "not", "b": [0.4091, 0.0967, 0.4351, 0.1163]}, {"w": "help.", "b": [0.4401, 0.0967, 0.4769, 0.1163]}, {"w": "You", "b": [0.4819, 0.0967, 0.5115, 0.1163]}, {"w": "need", "b": [0.5164, 0.0967, 0.5531, 0.1163]}, {"w": "to", "b": [0.5581, 0.0967, 0.5736, 0.1163]}, {"w": "use", "b": [0.5786, 0.0967, 0.6038, 0.1163]}, {"w": "a", "b": [0.6088, 0.0967, 0.6171, 0.1163]}, {"w": "more", "b": [0.6221, 0.0967, 0.6626, 0.1163]}, {"w": "complex", "b": [0.6676, 0.0967, 0.7325, 0.1163]}, {"w": "model", "b": [0.7374, 0.0967, 0.7857, 0.1163]}, {"w": "or", "b": [0.2714, 0.1141, 0.2882, 0.1337]}, {"w": "come", "b": [0.2925, 0.1141, 0.334, 0.1337]}, {"w": "up", "b": [0.3383, 0.1141, 0.3584, 0.1337]}, {"w": "with", "b": [0.3627, 0.1141, 0.3969, 0.1337]}, {"w": "better", "b": [0.4012, 0.1141, 0.4457, 0.1337]}, {"w": "features.", "b": [0.4501, 0.1141, 0.5142, 0.1337]}]}, {"id": "b_1", "type": "paragraph", "text": "Now let’s look at the learning curves of a 10th-degree polynomial model on the same data (Figure 4-16):", "words": [{"w": "Now", "b": [0.1429, 0.1779, 0.1827, 0.1993]}, {"w": "let’s", "b": [0.1887, 0.1779, 0.219, 0.1993]}, {"w": "look", "b": [0.225, 0.1779, 0.2618, 0.1993]}, {"w": "at", "b": [0.2678, 0.1779, 0.2829, 0.1993]}, {"w": "the", "b": [0.289, 0.1779, 0.3153, 0.1993]}, {"w": "learning", "b": [0.3213, 0.1779, 0.3904, 0.1993]}, {"w": "curves", "b": [0.3964, 0.1779, 0.4508, 0.1993]}, {"w": "of", "b": [0.4568, 0.1779, 0.4736, 0.1993]}, {"w": "a", "b": [0.4796, 0.1779, 0.4888, 0.1993]}, {"w": "10th-degree", "b": [0.4948, 0.1779, 0.5877, 0.1993]}, {"w": "polynomial", "b": [0.5937, 0.1779, 0.6892, 0.1993]}, {"w": "model", "b": [0.6952, 0.1779, 0.748, 0.1993]}, {"w": "on", "b": [0.7541, 0.1779, 0.7761, 0.1993]}, {"w": "the", "b": [0.7821, 0.1779, 0.8084, 0.1993]}, {"w": "same", "b": [0.8144, 0.1779, 0.8571, 0.1993]}, {"w": "data", "b": [0.1429, 0.197, 0.1781, 0.2184]}, {"w": "(Figure", "b": [0.1828, 0.197, 0.244, 0.2184]}, {"w": "4-16):", "b": [0.2488, 0.197, 0.2981, 0.2184]}]}, {"id": "b_2", "type": "paragraph", "text": "from sklearn.pipeline import Pipeline", "words": [{"w": "from", "b": [0.1766, 0.2289, 0.2103, 0.2418]}, {"w": "sklearn.pipeline", "b": [0.2187, 0.2289, 0.3537, 0.2418]}, {"w": "import", "b": [0.3621, 0.2289, 0.4127, 0.2418]}, {"w": "Pipeline", "b": [0.4211, 0.2289, 0.4886, 0.2418]}]}, {"id": "b_3", "type": "paragraph", "text": "polynomial_regression = Pipeline([ (\"poly_features\", PolynomialFeatures(degree=10, include_bias=False)), (\"lin_reg\", LinearRegression()), ])", "words": [{"w": "polynomial_regression", "b": [0.1766, 0.2598, 0.3537, 0.2726]}, {"w": "=", "b": [0.3621, 0.2598, 0.3705, 0.2726]}, {"w": "Pipeline([", "b": [0.379, 0.2598, 0.4633, 0.2726]}, {"w": "(\"poly_features\",", "b": [0.244, 0.2752, 0.3874, 0.2881]}, {"w": "PolynomialFeatures(degree=10,", "b": [0.3958, 0.2752, 0.6404, 0.2881]}, {"w": "include_bias=False)),", "b": [0.6488, 0.2752, 0.8259, 0.2881]}, {"w": "(\"lin_reg\",", "b": [0.244, 0.2906, 0.3368, 0.3035]}, {"w": "LinearRegression()),", "b": [0.3452, 0.2906, 0.5139, 0.3035]}, {"w": "])", "b": [0.2103, 0.306, 0.2272, 0.3189]}]}, {"id": "b_4", "type": "equation", "text": "plot_learning_curves(polynomial_regression, X, y)", "words": [{"w": "plot_learning_curves(polynomial_regression,", "b": [0.1766, 0.3369, 0.5392, 0.3497]}, {"w": "X,", "b": [0.5476, 0.3369, 0.5645, 0.3497]}, {"w": "y)", "b": [0.5729, 0.3369, 0.5898, 0.3497]}]}, {"id": "b_5", "type": "paragraph", "text": "These learning curves look a bit like the previous ones, but there are two very impor‐ tant differences:", "words": [{"w": "These", "b": [0.1429, 0.3575, 0.1922, 0.3789]}, {"w": "learning", "b": [0.1974, 0.3575, 0.2665, 0.3789]}, {"w": "curves", "b": [0.2717, 0.3575, 0.3261, 0.3789]}, {"w": "look", "b": [0.3313, 0.3575, 0.3681, 0.3789]}, {"w": "a", "b": [0.3733, 0.3575, 0.3825, 0.3789]}, {"w": "bit", "b": [0.3877, 0.3575, 0.4102, 0.3789]}, {"w": "like", "b": [0.4154, 0.3575, 0.4454, 0.3789]}, {"w": "the", "b": [0.4506, 0.3575, 0.477, 0.3789]}, {"w": "previous", "b": [0.4822, 0.3575, 0.5542, 0.3789]}, {"w": "ones,", "b": [0.5594, 0.3575, 0.6027, 0.3789]}, {"w": "but", "b": [0.6079, 0.3575, 0.6359, 0.3789]}, {"w": "there", "b": [0.6411, 0.3575, 0.684, 0.3789]}, {"w": "are", "b": [0.6892, 0.3575, 0.715, 0.3789]}, {"w": "two", "b": [0.7202, 0.3575, 0.7514, 0.3789]}, {"w": "very", "b": [0.7566, 0.3575, 0.793, 0.3789]}, {"w": "impor‐", "b": [0.7982, 0.3575, 0.8571, 0.3789]}, {"w": "tant", "b": [0.1429, 0.3766, 0.1757, 0.398]}, {"w": "differences:", "b": [0.1804, 0.3766, 0.2762, 0.398]}]}, {"id": "b_6", "type": "paragraph", "text": "• The error on the training data is much lower than with the Linear Regression model.", "words": [{"w": "•", "b": [0.16, 0.4107, 0.1681, 0.4321]}, {"w": "The", "b": [0.1786, 0.4107, 0.2114, 0.4321]}, {"w": "error", "b": [0.219, 0.4107, 0.2616, 0.4321]}, {"w": "on", "b": [0.2692, 0.4107, 0.2912, 0.4321]}, {"w": "the", "b": [0.2988, 0.4107, 0.3251, 0.4321]}, {"w": "training", "b": [0.3327, 0.4107, 0.3996, 0.4321]}, {"w": "data", "b": [0.4071, 0.4107, 0.4424, 0.4321]}, {"w": "is", "b": [0.45, 0.4107, 0.4632, 0.4321]}, {"w": "much", "b": [0.4707, 0.4107, 0.5184, 0.4321]}, {"w": "lower", "b": [0.526, 0.4107, 0.5727, 0.4321]}, {"w": "than", "b": [0.5803, 0.4107, 0.6183, 0.4321]}, {"w": "with", "b": [0.6259, 0.4107, 0.6632, 0.4321]}, {"w": "the", "b": [0.6707, 0.4107, 0.6971, 0.4321]}, {"w": "Linear", "b": [0.7046, 0.4107, 0.7586, 0.4321]}, {"w": "Regression", "b": [0.7661, 0.4107, 0.8571, 0.4321]}, {"w": "model.", "b": [0.1786, 0.4298, 0.2361, 0.4512]}]}, {"id": "b_7", "type": "paragraph", "text": "• There is a gap between the curves. This means that the model performs signifi‐ cantly better on the training data than on the validation data, which is the hall‐ mark of an overfitting model. However, if you used a much larger training set, the two curves would continue to get closer.", "words": [{"w": "•", "b": [0.16, 0.4549, 0.1682, 0.4763]}, {"w": "There", "b": [0.1786, 0.4549, 0.228, 0.4763]}, {"w": "is", "b": [0.2344, 0.4549, 0.2477, 0.4763]}, {"w": "a", "b": [0.2541, 0.4549, 0.2633, 0.4763]}, {"w": "gap", "b": [0.2697, 0.4549, 0.2991, 0.4763]}, {"w": "between", "b": [0.3056, 0.4549, 0.3747, 0.4763]}, {"w": "the", "b": [0.3812, 0.4549, 0.4075, 0.4763]}, {"w": "curves.", "b": [0.414, 0.4549, 0.4731, 0.4763]}, {"w": "This", "b": [0.4795, 0.4549, 0.5167, 0.4763]}, {"w": "means", "b": [0.5232, 0.4549, 0.5773, 0.4763]}, {"w": "that", "b": [0.5837, 0.4549, 0.6163, 0.4763]}, {"w": "the", "b": [0.6228, 0.4549, 0.6491, 0.4763]}, {"w": "model", "b": [0.6556, 0.4549, 0.7084, 0.4763]}, {"w": "performs", "b": [0.7148, 0.4549, 0.7916, 0.4763]}, {"w": "signifi‐", "b": [0.798, 0.4549, 0.8571, 0.4763]}, {"w": "cantly", "b": [0.1786, 0.4739, 0.2287, 0.4953]}, {"w": "better", "b": [0.2352, 0.4739, 0.2839, 0.4953]}, {"w": "on", "b": [0.2904, 0.4739, 0.3124, 0.4953]}, {"w": "the", "b": [0.3189, 0.4739, 0.3452, 0.4953]}, {"w": "training", "b": [0.3517, 0.4739, 0.4187, 0.4953]}, {"w": "data", "b": [0.4251, 0.4739, 0.4604, 0.4953]}, {"w": "than", "b": [0.4669, 0.4739, 0.5049, 0.4953]}, {"w": "on", "b": [0.5114, 0.4739, 0.5334, 0.4953]}, {"w": "the", "b": [0.5399, 0.4739, 0.5662, 0.4953]}, {"w": "validation", "b": [0.5727, 0.4739, 0.656, 0.4953]}, {"w": "data,", "b": [0.6625, 0.4739, 0.7025, 0.4953]}, {"w": "which", "b": [0.709, 0.4739, 0.7599, 0.4953]}, {"w": "is", "b": [0.7664, 0.4739, 0.7796, 0.4953]}, {"w": "the", "b": [0.7861, 0.4739, 0.8124, 0.4953]}, {"w": "hall‐", "b": [0.8189, 0.4739, 0.8571, 0.4953]}, {"w": "mark", "b": [0.1786, 0.493, 0.2228, 0.5144]}, {"w": "of", "b": [0.2298, 0.493, 0.2466, 0.5144]}, {"w": "an", "b": [0.2536, 0.493, 0.2742, 0.5144]}, {"w": "overfitting", "b": [0.2812, 0.493, 0.3692, 0.5144]}, {"w": "model.", "b": [0.3762, 0.493, 0.4338, 0.5144]}, {"w": "However,", "b": [0.4408, 0.493, 0.5197, 0.5144]}, {"w": "if", "b": [0.5267, 0.493, 0.5384, 0.5144]}, {"w": "you", "b": [0.5454, 0.493, 0.5767, 0.5144]}, {"w": "used", "b": [0.5837, 0.493, 0.6223, 0.5144]}, {"w": "a", "b": [0.6293, 0.493, 0.6384, 0.5144]}, {"w": "much", "b": [0.6454, 0.493, 0.6931, 0.5144]}, {"w": "larger", "b": [0.7001, 0.493, 0.7486, 0.5144]}, {"w": "training", "b": [0.7556, 0.493, 0.8225, 0.5144]}, {"w": "set,", "b": [0.8295, 0.493, 0.8571, 0.5144]}, {"w": "the", "b": [0.1786, 0.512, 0.2049, 0.5334]}, {"w": "two", "b": [0.2096, 0.512, 0.2409, 0.5334]}, {"w": "curves", "b": [0.2456, 0.512, 0.3, 0.5334]}, {"w": "would", "b": [0.3047, 0.512, 0.3569, 0.5334]}, {"w": "continue", "b": [0.3617, 0.512, 0.4349, 0.5334]}, {"w": "to", "b": [0.4397, 0.512, 0.4567, 0.5334]}, {"w": "get", "b": [0.4614, 0.512, 0.4863, 0.5334]}, {"w": "closer.", "b": [0.4911, 0.512, 0.5434, 0.5334]}]}, {"id": "b_8", "type": "equation", "text": "Figure 4-16. Learning curves for the polynomial model", "words": [{"w": "Figure", "b": [0.1429, 0.815, 0.1943, 0.8366]}, {"w": "4-16.", "b": [0.1991, 0.815, 0.2407, 0.8366]}, {"w": "Learning", "b": [0.2455, 0.815, 0.3183, 0.8366]}, {"w": "curves", "b": [0.323, 0.815, 0.3743, 0.8366]}, {"w": "for", "b": [0.3791, 0.815, 0.4017, 0.8366]}, {"w": "the", "b": [0.4065, 0.815, 0.4315, 0.8366]}, {"w": "polynomial", "b": [0.4363, 0.815, 0.5276, 0.8366]}, {"w": "model", "b": [0.5324, 0.815, 0.582, 0.8366]}]}, {"id": "b_9", "type": "paragraph", "text": "Learning Curves | 135", "words": [{"w": "Learning", "b": [0.7022, 0.9225, 0.7544, 0.9388]}, {"w": "Curves", "b": [0.7572, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "135", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 162, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "10 This notion of bias is not to be confused with the bias term of linear models.", "words": [{"w": "10", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "This", "b": [0.1587, 0.8749, 0.1871, 0.8912]}, {"w": "notion", "b": [0.1907, 0.8749, 0.2333, 0.8912]}, {"w": "of", "b": [0.2369, 0.8749, 0.2497, 0.8912]}, {"w": "bias", "b": [0.2533, 0.8749, 0.2784, 0.8912]}, {"w": "is", "b": [0.282, 0.8749, 0.2921, 0.8912]}, {"w": "not", "b": [0.2957, 0.8749, 0.3173, 0.8912]}, {"w": "to", "b": [0.321, 0.8749, 0.3339, 0.8912]}, {"w": "be", "b": [0.3375, 0.8749, 0.3523, 0.8912]}, {"w": "confused", "b": [0.3559, 0.8749, 0.4135, 0.8912]}, {"w": "with", "b": [0.4171, 0.8749, 0.4455, 0.8912]}, {"w": "the", "b": [0.4491, 0.8749, 0.4692, 0.8912]}, {"w": "bias", "b": [0.4728, 0.8749, 0.4979, 0.8912]}, {"w": "term", "b": [0.5015, 0.8749, 0.532, 0.8912]}, {"w": "of", "b": [0.5356, 0.8749, 0.5484, 0.8912]}, {"w": "linear", "b": [0.552, 0.8749, 0.5885, 0.8912]}, {"w": "models.", "b": [0.5921, 0.8749, 0.6418, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "One way to improve an overfitting model is to feed it more training data until the validation error reaches the training error.", "words": [{"w": "One", "b": [0.2714, 0.0793, 0.3041, 0.0989]}, {"w": "way", "b": [0.3085, 0.0793, 0.3383, 0.0989]}, {"w": "to", "b": [0.3427, 0.0793, 0.3582, 0.0989]}, {"w": "improve", "b": [0.3626, 0.0793, 0.4266, 0.0989]}, {"w": "an", "b": [0.431, 0.0793, 0.4498, 0.0989]}, {"w": "overfitting", "b": [0.4542, 0.0793, 0.5347, 0.0989]}, {"w": "model", "b": [0.5391, 0.0793, 0.5873, 0.0989]}, {"w": "is", "b": [0.5917, 0.0793, 0.6038, 0.0989]}, {"w": "to", "b": [0.6082, 0.0793, 0.6237, 0.0989]}, {"w": "feed", "b": [0.6281, 0.0793, 0.66, 0.0989]}, {"w": "it", "b": [0.6644, 0.0793, 0.6753, 0.0989]}, {"w": "more", "b": [0.6797, 0.0793, 0.7201, 0.0989]}, {"w": "training", "b": [0.7245, 0.0793, 0.7857, 0.0989]}, {"w": "data", "b": [0.2714, 0.0967, 0.3036, 0.1163]}, {"w": "until", "b": [0.308, 0.0967, 0.3439, 0.1163]}, {"w": "the", "b": [0.3482, 0.0967, 0.3723, 0.1163]}, {"w": "validation", "b": [0.3766, 0.0967, 0.4528, 0.1163]}, {"w": "error", "b": [0.4571, 0.0967, 0.4961, 0.1163]}, {"w": "reaches", "b": [0.5005, 0.0967, 0.5573, 0.1163]}, {"w": "the", "b": [0.5616, 0.0967, 0.5857, 0.1163]}, {"w": "training", "b": [0.59, 0.0967, 0.6512, 0.1163]}, {"w": "error.", "b": [0.6555, 0.0967, 0.6977, 0.1163]}]}, {"id": "b_2", "type": "equation", "text": "The Bias/Variance Tradeoff", "words": [{"w": "The", "b": [0.3694, 0.1909, 0.4052, 0.2181]}, {"w": "Bias/Variance", "b": [0.4099, 0.1909, 0.5436, 0.2181]}, {"w": "Tradeoff", "b": [0.5483, 0.1909, 0.6307, 0.2181]}]}, {"id": "b_3", "type": "paragraph", "text": "An important theoretical result of statistics and Machine Learning is the fact that a model’s generalization error can be expressed as the sum of three very different errors:", "words": [{"w": "An", "b": [0.1592, 0.2226, 0.1838, 0.243]}, {"w": "important", "b": [0.1904, 0.2226, 0.2708, 0.243]}, {"w": "theoretical", "b": [0.2774, 0.2226, 0.3619, 0.243]}, {"w": "result", "b": [0.3686, 0.2226, 0.4133, 0.243]}, {"w": "of", "b": [0.4199, 0.2226, 0.4359, 0.243]}, {"w": "statistics", "b": [0.4426, 0.2226, 0.5099, 0.243]}, {"w": "and", "b": [0.5166, 0.2226, 0.5466, 0.243]}, {"w": "Machine", "b": [0.5533, 0.2226, 0.6229, 0.243]}, {"w": "Learning", "b": [0.6296, 0.2226, 0.7011, 0.243]}, {"w": "is", "b": [0.7077, 0.2226, 0.7203, 0.243]}, {"w": "the", "b": [0.727, 0.2226, 0.752, 0.243]}, {"w": "fact", "b": [0.7587, 0.2226, 0.7877, 0.243]}, {"w": "that", "b": [0.7944, 0.2226, 0.8254, 0.243]}, {"w": "a", "b": [0.8321, 0.2226, 0.8408, 0.243]}, {"w": "model’s", "b": [0.1592, 0.2408, 0.2188, 0.2612]}, {"w": "generalization", "b": [0.228, 0.2408, 0.3404, 0.2612]}, {"w": "error", "b": [0.3496, 0.2408, 0.3902, 0.2612]}, {"w": "can", "b": [0.3994, 0.2408, 0.4273, 0.2612]}, {"w": "be", "b": [0.4365, 0.2408, 0.455, 0.2612]}, {"w": "expressed", "b": [0.4642, 0.2408, 0.5416, 0.2612]}, {"w": "as", "b": [0.5508, 0.2408, 0.5668, 0.2612]}, {"w": "the", "b": [0.576, 0.2408, 0.601, 0.2612]}, {"w": "sum", "b": [0.6102, 0.2408, 0.6443, 0.2612]}, {"w": "of", "b": [0.6534, 0.2408, 0.6694, 0.2612]}, {"w": "three", "b": [0.6786, 0.2408, 0.7195, 0.2612]}, {"w": "very", "b": [0.7286, 0.2408, 0.7633, 0.2612]}, {"w": "different", "b": [0.7725, 0.2408, 0.8408, 0.2612]}, {"w": "errors:", "b": [0.1592, 0.2589, 0.2117, 0.2793]}]}, {"id": "b_4", "type": "paragraph", "text": "Bias", "words": [{"w": "Bias", "b": [0.1592, 0.2875, 0.1921, 0.308]}]}, {"id": "b_5", "type": "paragraph", "text": "This part of the generalization error is due to wrong assumptions, such as assum‐ ing that the data is linear when it is actually quadratic. A high-bias model is most likely to underfit the training data.10", "words": [{"w": "This", "b": [0.1949, 0.3058, 0.2304, 0.3262]}, {"w": "part", "b": [0.235, 0.3058, 0.2675, 0.3262]}, {"w": "of", "b": [0.2721, 0.3058, 0.2881, 0.3262]}, {"w": "the", "b": [0.2928, 0.3058, 0.3179, 0.3262]}, {"w": "generalization", "b": [0.3225, 0.3058, 0.4349, 0.3262]}, {"w": "error", "b": [0.4395, 0.3058, 0.4802, 0.3262]}, {"w": "is", "b": [0.4848, 0.3058, 0.4974, 0.3262]}, {"w": "due", "b": [0.502, 0.3058, 0.5315, 0.3262]}, {"w": "to", "b": [0.5361, 0.3058, 0.5523, 0.3262]}, {"w": "wrong", "b": [0.5569, 0.3058, 0.6081, 0.3262]}, {"w": "assumptions,", "b": [0.6127, 0.3058, 0.717, 0.3262]}, {"w": "such", "b": [0.7216, 0.3058, 0.7584, 0.3262]}, {"w": "as", "b": [0.763, 0.3058, 0.779, 0.3262]}, {"w": "assum‐", "b": [0.7836, 0.3058, 0.8408, 0.3262]}, {"w": "ing", "b": [0.1949, 0.3239, 0.2204, 0.3443]}, {"w": "that", "b": [0.2253, 0.3239, 0.2563, 0.3443]}, {"w": "the", "b": [0.2612, 0.3239, 0.2862, 0.3443]}, {"w": "data", "b": [0.2911, 0.3239, 0.3247, 0.3443]}, {"w": "is", "b": [0.3295, 0.3239, 0.3421, 0.3443]}, {"w": "linear", "b": [0.347, 0.3239, 0.3927, 0.3443]}, {"w": "when", "b": [0.3976, 0.3239, 0.441, 0.3443]}, {"w": "it", "b": [0.4459, 0.3239, 0.4573, 0.3443]}, {"w": "is", "b": [0.4622, 0.3239, 0.4747, 0.3443]}, {"w": "actually", "b": [0.4796, 0.3239, 0.5412, 0.3443]}, {"w": "quadratic.", "b": [0.546, 0.3239, 0.6259, 0.3443]}, {"w": "A", "b": [0.6307, 0.3239, 0.6445, 0.3443]}, {"w": "high-bias", "b": [0.6493, 0.3239, 0.7236, 0.3443]}, {"w": "model", "b": [0.7284, 0.3239, 0.7787, 0.3443]}, {"w": "is", "b": [0.7836, 0.3239, 0.7962, 0.3443]}, {"w": "most", "b": [0.8011, 0.3239, 0.8408, 0.3443]}, {"w": "likely", "b": [0.1949, 0.3421, 0.2377, 0.3625]}, {"w": "to", "b": [0.2422, 0.3421, 0.2583, 0.3625]}, {"w": "underfit", "b": [0.2629, 0.3421, 0.3278, 0.3625]}, {"w": "the", "b": [0.3323, 0.3421, 0.3573, 0.3625]}, {"w": "training", "b": [0.3618, 0.3421, 0.4256, 0.3625]}, {"w": "data.10", "b": [0.4301, 0.3421, 0.4796, 0.3625]}]}, {"id": "b_6", "type": "paragraph", "text": "Variance", "words": [{"w": "Variance", "b": [0.1592, 0.3706, 0.2281, 0.3912]}]}, {"id": "b_7", "type": "paragraph", "text": "This part is due to the model’s excessive sensitivity to small variations in the training data. A model with many degrees of freedom (such as a high-degree pol‐ ynomial model) is likely to have high variance, and thus to overfit the training data.", "words": [{"w": "This", "b": [0.1949, 0.3889, 0.2304, 0.4093]}, {"w": "part", "b": [0.2384, 0.3889, 0.2709, 0.4093]}, {"w": "is", "b": [0.279, 0.3889, 0.2916, 0.4093]}, {"w": "due", "b": [0.2996, 0.3889, 0.329, 0.4093]}, {"w": "to", "b": [0.3371, 0.3889, 0.3532, 0.4093]}, {"w": "the", "b": [0.3613, 0.3889, 0.3863, 0.4093]}, {"w": "model’s", "b": [0.3944, 0.3889, 0.454, 0.4093]}, {"w": "excessive", "b": [0.462, 0.3889, 0.5341, 0.4093]}, {"w": "sensitivity", "b": [0.5422, 0.3889, 0.6224, 0.4093]}, {"w": "to", "b": [0.6304, 0.3889, 0.6466, 0.4093]}, {"w": "small", "b": [0.6546, 0.3889, 0.6969, 0.4093]}, {"w": "variations", "b": [0.7049, 0.3889, 0.7835, 0.4093]}, {"w": "in", "b": [0.7915, 0.3889, 0.8077, 0.4093]}, {"w": "the", "b": [0.8157, 0.3889, 0.8408, 0.4093]}, {"w": "training", "b": [0.1949, 0.4071, 0.2587, 0.4275]}, {"w": "data.", "b": [0.2634, 0.4071, 0.3015, 0.4275]}, {"w": "A", "b": [0.3062, 0.4071, 0.3199, 0.4275]}, {"w": "model", "b": [0.3246, 0.4071, 0.3749, 0.4275]}, {"w": "with", "b": [0.3796, 0.4071, 0.4151, 0.4275]}, {"w": "many", "b": [0.4198, 0.4071, 0.4643, 0.4275]}, {"w": "degrees", "b": [0.469, 0.4071, 0.5287, 0.4275]}, {"w": "of", "b": [0.5334, 0.4071, 0.5494, 0.4275]}, {"w": "freedom", "b": [0.5541, 0.4071, 0.621, 0.4275]}, {"w": "(such", "b": [0.6257, 0.4071, 0.6694, 0.4275]}, {"w": "as", "b": [0.6741, 0.4071, 0.6901, 0.4275]}, {"w": "a", "b": [0.6948, 0.4071, 0.7035, 0.4275]}, {"w": "high-degree", "b": [0.7082, 0.4071, 0.8035, 0.4275]}, {"w": "pol‐", "b": [0.8082, 0.4071, 0.8408, 0.4275]}, {"w": "ynomial", "b": [0.1949, 0.4252, 0.2603, 0.4456]}, {"w": "model)", "b": [0.267, 0.4252, 0.3241, 0.4456]}, {"w": "is", "b": [0.3308, 0.4252, 0.3434, 0.4456]}, {"w": "likely", "b": [0.35, 0.4252, 0.3928, 0.4456]}, {"w": "to", "b": [0.3994, 0.4252, 0.4156, 0.4456]}, {"w": "have", "b": [0.4222, 0.4252, 0.4588, 0.4456]}, {"w": "high", "b": [0.4655, 0.4252, 0.5013, 0.4456]}, {"w": "variance,", "b": [0.5079, 0.4252, 0.5794, 0.4456]}, {"w": "and", "b": [0.586, 0.4252, 0.6161, 0.4456]}, {"w": "thus", "b": [0.6227, 0.4252, 0.6568, 0.4456]}, {"w": "to", "b": [0.6635, 0.4252, 0.6796, 0.4456]}, {"w": "overfit", "b": [0.6863, 0.4252, 0.7386, 0.4456]}, {"w": "the", "b": [0.7453, 0.4252, 0.7704, 0.4456]}, {"w": "training", "b": [0.777, 0.4252, 0.8408, 0.4456]}, {"w": "data.", "b": [0.1949, 0.4434, 0.233, 0.4637]}]}, {"id": "b_8", "type": "paragraph", "text": "Irreducible error", "words": [{"w": "Irreducible", "b": [0.1592, 0.4719, 0.2425, 0.4925]}, {"w": "error", "b": [0.2471, 0.4719, 0.2857, 0.4925]}]}, {"id": "b_9", "type": "paragraph", "text": "This part is due to the noisiness of the data itself. The only way to reduce this part of the error is to clean up the data (e.g., fix the data sources, such as broken sensors, or detect and remove outliers).", "words": [{"w": "This", "b": [0.1949, 0.4902, 0.2304, 0.5106]}, {"w": "part", "b": [0.2371, 0.4902, 0.2697, 0.5106]}, {"w": "is", "b": [0.2764, 0.4902, 0.289, 0.5106]}, {"w": "due", "b": [0.2958, 0.4902, 0.3252, 0.5106]}, {"w": "to", "b": [0.332, 0.4902, 0.3482, 0.5106]}, {"w": "the", "b": [0.3549, 0.4902, 0.38, 0.5106]}, {"w": "noisiness", "b": [0.3868, 0.4902, 0.4595, 0.5106]}, {"w": "of", "b": [0.4663, 0.4902, 0.4823, 0.5106]}, {"w": "the", "b": [0.489, 0.4902, 0.5141, 0.5106]}, {"w": "data", "b": [0.5209, 0.4902, 0.5544, 0.5106]}, {"w": "itself.", "b": [0.5612, 0.4902, 0.6037, 0.5106]}, {"w": "The", "b": [0.6105, 0.4902, 0.6417, 0.5106]}, {"w": "only", "b": [0.6485, 0.4902, 0.6836, 0.5106]}, {"w": "way", "b": [0.6904, 0.4902, 0.7214, 0.5106]}, {"w": "to", "b": [0.7282, 0.4902, 0.7444, 0.5106]}, {"w": "reduce", "b": [0.7511, 0.4902, 0.8048, 0.5106]}, {"w": "this", "b": [0.8115, 0.4902, 0.8408, 0.5106]}, {"w": "part", "b": [0.1949, 0.5084, 0.2275, 0.5288]}, {"w": "of", "b": [0.2328, 0.5084, 0.2488, 0.5288]}, {"w": "the", "b": [0.2542, 0.5084, 0.2792, 0.5288]}, {"w": "error", "b": [0.2846, 0.5084, 0.3252, 0.5288]}, {"w": "is", "b": [0.3306, 0.5084, 0.3432, 0.5288]}, {"w": "to", "b": [0.3485, 0.5084, 0.3647, 0.5288]}, {"w": "clean", "b": [0.3701, 0.5084, 0.4115, 0.5288]}, {"w": "up", "b": [0.4168, 0.5084, 0.4378, 0.5288]}, {"w": "the", "b": [0.4431, 0.5084, 0.4682, 0.5288]}, {"w": "data", "b": [0.4736, 0.5084, 0.5071, 0.5288]}, {"w": "(e.g.,", "b": [0.5125, 0.5084, 0.5506, 0.5288]}, {"w": "fix", "b": [0.556, 0.5084, 0.5766, 0.5288]}, {"w": "the", "b": [0.5819, 0.5084, 0.607, 0.5288]}, {"w": "data", "b": [0.6124, 0.5084, 0.6459, 0.5288]}, {"w": "sources,", "b": [0.6513, 0.5084, 0.7152, 0.5288]}, {"w": "such", "b": [0.7206, 0.5084, 0.7574, 0.5288]}, {"w": "as", "b": [0.7627, 0.5084, 0.7787, 0.5288]}, {"w": "broken", "b": [0.7841, 0.5084, 0.8408, 0.5288]}, {"w": "sensors,", "b": [0.1949, 0.5265, 0.2581, 0.5469]}, {"w": "or", "b": [0.2626, 0.5265, 0.2801, 0.5469]}, {"w": "detect", "b": [0.2846, 0.5265, 0.3324, 0.5469]}, {"w": "and", "b": [0.3369, 0.5265, 0.3669, 0.5469]}, {"w": "remove", "b": [0.3714, 0.5265, 0.4312, 0.5469]}, {"w": "outliers).", "b": [0.4357, 0.5265, 0.5072, 0.5469]}]}, {"id": "b_10", "type": "paragraph", "text": "Increasing a model’s complexity will typically increase its variance and reduce its bias. Conversely, reducing a model’s complexity increases its bias and reduces its variance. This is why it is called a tradeoff.", "words": [{"w": "Increasing", "b": [0.1592, 0.5537, 0.2425, 0.5741]}, {"w": "a", "b": [0.2472, 0.5537, 0.256, 0.5741]}, {"w": "model’s", "b": [0.2607, 0.5537, 0.3203, 0.5741]}, {"w": "complexity", "b": [0.3251, 0.5537, 0.4132, 0.5741]}, {"w": "will", "b": [0.4179, 0.5537, 0.4469, 0.5741]}, {"w": "typically", "b": [0.4516, 0.5537, 0.5188, 0.5741]}, {"w": "increase", "b": [0.5235, 0.5537, 0.5883, 0.5741]}, {"w": "its", "b": [0.5931, 0.5537, 0.6117, 0.5741]}, {"w": "variance", "b": [0.6165, 0.5537, 0.6835, 0.5741]}, {"w": "and", "b": [0.6882, 0.5537, 0.7183, 0.5741]}, {"w": "reduce", "b": [0.723, 0.5537, 0.7767, 0.5741]}, {"w": "its", "b": [0.7814, 0.5537, 0.8001, 0.5741]}, {"w": "bias.", "b": [0.8049, 0.5537, 0.8408, 0.5741]}, {"w": "Conversely,", "b": [0.1592, 0.5719, 0.2508, 0.5922]}, {"w": "reducing", "b": [0.2558, 0.5719, 0.3265, 0.5922]}, {"w": "a", "b": [0.3314, 0.5719, 0.3401, 0.5922]}, {"w": "model’s", "b": [0.3451, 0.5719, 0.4047, 0.5922]}, {"w": "complexity", "b": [0.4097, 0.5719, 0.4978, 0.5922]}, {"w": "increases", "b": [0.5027, 0.5719, 0.5748, 0.5922]}, {"w": "its", "b": [0.5798, 0.5719, 0.5984, 0.5922]}, {"w": "bias", "b": [0.6034, 0.5719, 0.6348, 0.5922]}, {"w": "and", "b": [0.6398, 0.5719, 0.6698, 0.5922]}, {"w": "reduces", "b": [0.6748, 0.5719, 0.7357, 0.5922]}, {"w": "its", "b": [0.7407, 0.5719, 0.7593, 0.5922]}, {"w": "variance.", "b": [0.7643, 0.5719, 0.8358, 0.5922]}, {"w": "This", "b": [0.1592, 0.59, 0.1947, 0.6104]}, {"w": "is", "b": [0.1992, 0.59, 0.2118, 0.6104]}, {"w": "why", "b": [0.2163, 0.59, 0.2491, 0.6104]}, {"w": "it", "b": [0.2536, 0.59, 0.265, 0.6104]}, {"w": "is", "b": [0.2695, 0.59, 0.2821, 0.6104]}, {"w": "called", "b": [0.2866, 0.59, 0.3326, 0.6104]}, {"w": "a", "b": [0.3371, 0.59, 0.3458, 0.6104]}, {"w": "tradeoff.", "b": [0.3504, 0.59, 0.4178, 0.6104]}]}, {"id": "b_11", "type": "paragraph", "text": "Regularized Linear Models", "words": [{"w": "Regularized", "b": [0.1429, 0.6404, 0.2903, 0.6746]}, {"w": "Linear", "b": [0.2962, 0.6404, 0.3738, 0.6746]}, {"w": "Models", "b": [0.3797, 0.6404, 0.4686, 0.6746]}]}, {"id": "b_12", "type": "paragraph", "text": "As we saw in Chapters 1 and 2, a good way to reduce overfitting is to regularize the model (i.e., to constrain it): the fewer degrees of freedom it has, the harder it will be for it to overfit the data. For example, a simple way to regularize a polynomial model is to reduce the number of polynomial degrees.", "words": [{"w": "As", "b": [0.1429, 0.6816, 0.1649, 0.703]}, {"w": "we", "b": [0.1711, 0.6816, 0.1942, 0.703]}, {"w": "saw", "b": [0.2004, 0.6816, 0.2311, 0.703]}, {"w": "in", "b": [0.2373, 0.6816, 0.2543, 0.703]}, {"w": "Chapters", "b": [0.2605, 0.6816, 0.3358, 0.703]}, {"w": "1", "b": [0.342, 0.6816, 0.352, 0.703]}, {"w": "and", "b": [0.3582, 0.6816, 0.3897, 0.703]}, {"w": "2,", "b": [0.3959, 0.6816, 0.4107, 0.703]}, {"w": "a", "b": [0.4169, 0.6816, 0.426, 0.703]}, {"w": "good", "b": [0.4322, 0.6816, 0.4742, 0.703]}, {"w": "way", "b": [0.4805, 0.6816, 0.5131, 0.703]}, {"w": "to", "b": [0.5193, 0.6816, 0.5363, 0.703]}, {"w": "reduce", "b": [0.5425, 0.6816, 0.5988, 0.703]}, {"w": "overfitting", "b": [0.605, 0.6816, 0.693, 0.703]}, {"w": "is", "b": [0.6992, 0.6816, 0.7125, 0.703]}, {"w": "to", "b": [0.7187, 0.6816, 0.7357, 0.703]}, {"w": "regularize", "b": [0.7419, 0.6816, 0.8246, 0.703]}, {"w": "the", "b": [0.8308, 0.6816, 0.8571, 0.703]}, {"w": "model", "b": [0.1428, 0.7006, 0.1957, 0.722]}, {"w": "(i.e.,", "b": [0.2016, 0.7006, 0.2375, 0.722]}, {"w": "to", "b": [0.2435, 0.7006, 0.2605, 0.722]}, {"w": "constrain", "b": [0.2665, 0.7006, 0.3452, 0.722]}, {"w": "it):", "b": [0.3512, 0.7006, 0.3751, 0.722]}, {"w": "the", "b": [0.381, 0.7006, 0.4074, 0.722]}, {"w": "fewer", "b": [0.4134, 0.7006, 0.4592, 0.722]}, {"w": "degrees", "b": [0.4652, 0.7006, 0.5279, 0.722]}, {"w": "of", "b": [0.5339, 0.7006, 0.5507, 0.722]}, {"w": "freedom", "b": [0.5567, 0.7006, 0.627, 0.722]}, {"w": "it", "b": [0.6329, 0.7006, 0.6449, 0.722]}, {"w": "has,", "b": [0.6509, 0.7006, 0.6835, 0.722]}, {"w": "the", "b": [0.6895, 0.7006, 0.7158, 0.722]}, {"w": "harder", "b": [0.7218, 0.7006, 0.7774, 0.722]}, {"w": "it", "b": [0.7834, 0.7006, 0.7953, 0.722]}, {"w": "will", "b": [0.8013, 0.7006, 0.8317, 0.722]}, {"w": "be", "b": [0.8377, 0.7006, 0.8571, 0.722]}, {"w": "for", "b": [0.1429, 0.7197, 0.1674, 0.7411]}, {"w": "it", "b": [0.1729, 0.7197, 0.1848, 0.7411]}, {"w": "to", "b": [0.1903, 0.7197, 0.2073, 0.7411]}, {"w": "overfit", "b": [0.2128, 0.7197, 0.2678, 0.7411]}, {"w": "the", "b": [0.2733, 0.7197, 0.2996, 0.7411]}, {"w": "data.", "b": [0.3051, 0.7197, 0.3451, 0.7411]}, {"w": "For", "b": [0.3506, 0.7197, 0.3796, 0.7411]}, {"w": "example,", "b": [0.3851, 0.7197, 0.4594, 0.7411]}, {"w": "a", "b": [0.4649, 0.7197, 0.474, 0.7411]}, {"w": "simple", "b": [0.4795, 0.7197, 0.5344, 0.7411]}, {"w": "way", "b": [0.5399, 0.7197, 0.5725, 0.7411]}, {"w": "to", "b": [0.578, 0.7197, 0.595, 0.7411]}, {"w": "regularize", "b": [0.6005, 0.7197, 0.6832, 0.7411]}, {"w": "a", "b": [0.6887, 0.7197, 0.6979, 0.7411]}, {"w": "polynomial", "b": [0.7034, 0.7197, 0.7988, 0.7411]}, {"w": "model", "b": [0.8043, 0.7197, 0.8572, 0.7411]}, {"w": "is", "b": [0.1429, 0.7387, 0.1561, 0.7601]}, {"w": "to", "b": [0.1608, 0.7387, 0.1778, 0.7601]}, {"w": "reduce", "b": [0.1825, 0.7387, 0.2388, 0.7601]}, {"w": "the", "b": [0.2436, 0.7387, 0.2699, 0.7601]}, {"w": "number", "b": [0.2746, 0.7387, 0.3409, 0.7601]}, {"w": "of", "b": [0.3457, 0.7387, 0.3624, 0.7601]}, {"w": "polynomial", "b": [0.3672, 0.7387, 0.4626, 0.7601]}, {"w": "degrees.", "b": [0.4674, 0.7387, 0.5348, 0.7601]}]}, {"id": "b_13", "type": "paragraph", "text": "For a linear model, regularization is typically achieved by constraining the weights of the model. We will now look at Ridge Regression, Lasso Regression, and Elastic Net, which implement three different ways to constrain the weights.", "words": [{"w": "For", "b": [0.1429, 0.7668, 0.1718, 0.7882]}, {"w": "a", "b": [0.1773, 0.7668, 0.1864, 0.7882]}, {"w": "linear", "b": [0.1919, 0.7668, 0.2399, 0.7882]}, {"w": "model,", "b": [0.2453, 0.7668, 0.3029, 0.7882]}, {"w": "regularization", "b": [0.3083, 0.7668, 0.4249, 0.7882]}, {"w": "is", "b": [0.4304, 0.7668, 0.4436, 0.7882]}, {"w": "typically", "b": [0.4491, 0.7668, 0.5195, 0.7882]}, {"w": "achieved", "b": [0.525, 0.7668, 0.598, 0.7882]}, {"w": "by", "b": [0.6035, 0.7668, 0.6236, 0.7882]}, {"w": "constraining", "b": [0.6291, 0.7668, 0.7345, 0.7882]}, {"w": "the", "b": [0.7399, 0.7668, 0.7663, 0.7882]}, {"w": "weights", "b": [0.7717, 0.7668, 0.8349, 0.7882]}, {"w": "of", "b": [0.8404, 0.7668, 0.8571, 0.7882]}, {"w": "the", "b": [0.1429, 0.7859, 0.1692, 0.8073]}, {"w": "model.", "b": [0.1752, 0.7859, 0.2327, 0.8073]}, {"w": "We", "b": [0.2387, 0.7859, 0.2658, 0.8073]}, {"w": "will", "b": [0.2717, 0.7859, 0.3021, 0.8073]}, {"w": "now", "b": [0.3081, 0.7859, 0.3444, 0.8073]}, {"w": "look", "b": [0.3504, 0.7859, 0.3872, 0.8073]}, {"w": "at", "b": [0.3932, 0.7859, 0.4083, 0.8073]}, {"w": "Ridge", "b": [0.4143, 0.7859, 0.4624, 0.8073]}, {"w": "Regression,", "b": [0.4684, 0.7859, 0.5641, 0.8073]}, {"w": "Lasso", "b": [0.5701, 0.7859, 0.6164, 0.8073]}, {"w": "Regression,", "b": [0.6223, 0.7859, 0.7181, 0.8073]}, {"w": "and", "b": [0.7241, 0.7859, 0.7556, 0.8073]}, {"w": "Elastic", "b": [0.7616, 0.7859, 0.8162, 0.8073]}, {"w": "Net,", "b": [0.8222, 0.7859, 0.8571, 0.8073]}, {"w": "which", "b": [0.1429, 0.8049, 0.1938, 0.8263]}, {"w": "implement", "b": [0.1985, 0.8049, 0.2891, 0.8263]}, {"w": "three", "b": [0.2938, 0.8049, 0.3367, 0.8263]}, {"w": "different", "b": [0.3415, 0.8049, 0.4132, 0.8263]}, {"w": "ways", "b": [0.4179, 0.8049, 0.4581, 0.8263]}, {"w": "to", "b": [0.4629, 0.8049, 0.4798, 0.8263]}, {"w": "constrain", "b": [0.4846, 0.8049, 0.5633, 0.8263]}, {"w": "the", "b": [0.568, 0.8049, 0.5943, 0.8263]}, {"w": "weights.", "b": [0.5991, 0.8049, 0.667, 0.8263]}]}, {"id": "b_14", "type": "paragraph", "text": "136 | Chapter 4: Training Models", "words": [{"w": "136", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 163, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "11 It is common to use the notation J(θ) for cost functions that don’t have a short name; we will often use this notation throughout the rest of this book. The context will make it clear which cost function is being dis‐ cussed.", "words": [{"w": "11", "b": [0.1385, 0.8265, 0.1518, 0.8408]}, {"w": "It", "b": [0.1587, 0.825, 0.1684, 0.8413]}, {"w": "is", "b": [0.172, 0.825, 0.182, 0.8413]}, {"w": "common", "b": [0.1857, 0.825, 0.2432, 0.8413]}, {"w": "to", "b": [0.2468, 0.825, 0.2598, 0.8413]}, {"w": "use", "b": [0.2634, 0.825, 0.2844, 0.8413]}, {"w": "the", "b": [0.288, 0.825, 0.308, 0.8413]}, {"w": "notation", "b": [0.3117, 0.825, 0.3658, 0.8413]}, {"w": "J(θ)", "b": [0.3694, 0.8246, 0.3936, 0.8413]}, {"w": "for", "b": [0.3972, 0.825, 0.4159, 0.8413]}, {"w": "cost", "b": [0.4195, 0.825, 0.4449, 0.8413]}, {"w": "functions", "b": [0.4485, 0.825, 0.5088, 0.8413]}, {"w": "that", "b": [0.5124, 0.825, 0.5372, 0.8413]}, {"w": "don’t", "b": [0.5408, 0.825, 0.5725, 0.8413]}, {"w": "have", "b": [0.5761, 0.825, 0.6053, 0.8413]}, {"w": "a", "b": [0.609, 0.825, 0.6159, 0.8413]}, {"w": "short", "b": [0.6195, 0.825, 0.6527, 0.8413]}, {"w": "name;", "b": [0.6563, 0.825, 0.6953, 0.8413]}, {"w": "we", "b": [0.6989, 0.825, 0.7165, 0.8413]}, {"w": "will", "b": [0.7201, 0.825, 0.7433, 0.8413]}, {"w": "often", "b": [0.7469, 0.825, 0.7799, 0.8413]}, {"w": "use", "b": [0.7835, 0.825, 0.8045, 0.8413]}, {"w": "this", "b": [0.8081, 0.825, 0.8315, 0.8413]}, {"w": "notation", "b": [0.1587, 0.8401, 0.2129, 0.8565]}, {"w": "throughout", "b": [0.2165, 0.8401, 0.2895, 0.8565]}, {"w": "the", "b": [0.2931, 0.8401, 0.3132, 0.8565]}, {"w": "rest", "b": [0.3168, 0.8401, 0.3401, 0.8565]}, {"w": "of", "b": [0.3437, 0.8401, 0.3565, 0.8565]}, {"w": "this", "b": [0.3601, 0.8401, 0.3835, 0.8565]}, {"w": "book.", "b": [0.3871, 0.8401, 0.4228, 0.8565]}, {"w": "The", "b": [0.4264, 0.8401, 0.4514, 0.8565]}, {"w": "context", "b": [0.455, 0.8401, 0.5021, 0.8565]}, {"w": "will", "b": [0.5057, 0.8401, 0.5289, 0.8565]}, {"w": "make", "b": [0.5325, 0.8401, 0.5671, 0.8565]}, {"w": "it", "b": [0.5707, 0.8401, 0.5798, 0.8565]}, {"w": "clear", "b": [0.5834, 0.8401, 0.6137, 0.8565]}, {"w": "which", "b": [0.6173, 0.8401, 0.6561, 0.8565]}, {"w": "cost", "b": [0.6597, 0.8401, 0.6852, 0.8565]}, {"w": "function", "b": [0.6888, 0.8401, 0.7432, 0.8565]}, {"w": "is", "b": [0.7468, 0.8401, 0.7569, 0.8565]}, {"w": "being", "b": [0.7605, 0.8401, 0.7957, 0.8565]}, {"w": "dis‐", "b": [0.7993, 0.8401, 0.8234, 0.8565]}, {"w": "cussed.", "b": [0.1587, 0.8553, 0.2043, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "12 Norms are discussed in Chapter 2.", "words": [{"w": "12", "b": [0.1384, 0.8764, 0.1518, 0.8907]}, {"w": "Norms", "b": [0.1587, 0.8749, 0.2029, 0.8912]}, {"w": "are", "b": [0.2065, 0.8749, 0.2261, 0.8912]}, {"w": "discussed", "b": [0.2297, 0.8749, 0.2901, 0.8912]}, {"w": "in", "b": [0.2937, 0.8749, 0.3067, 0.8912]}, {"w": "Chapter", "b": [0.3103, 0.8749, 0.3618, 0.8912]}, {"w": "2.", "b": [0.3654, 0.8749, 0.3766, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "Ridge Regression", "words": [{"w": "Ridge", "b": [0.1429, 0.0763, 0.2021, 0.1049]}, {"w": "Regression", "b": [0.207, 0.0763, 0.3195, 0.1049]}]}, {"id": "b_3", "type": "paragraph", "text": "Ridge Regression (also called Tikhonov regularization) is a regularized version of Lin‐ ear Regression: a regularization term equal to α∑i = 1", "words": [{"w": "Ridge", "b": [0.1429, 0.1106, 0.1881, 0.1322]}, {"w": "Regression", "b": [0.1943, 0.1106, 0.279, 0.1322]}, {"w": "(also", "b": [0.2852, 0.1108, 0.3251, 0.1322]}, {"w": "called", "b": [0.3312, 0.1108, 0.3796, 0.1322]}, {"w": "Tikhonov", "b": [0.3857, 0.1106, 0.4622, 0.1322]}, {"w": "regularization)", "b": [0.4684, 0.1106, 0.5903, 0.1322]}, {"w": "is", "b": [0.5965, 0.1108, 0.6097, 0.1322]}, {"w": "a", "b": [0.6158, 0.1108, 0.625, 0.1322]}, {"w": "regularized", "b": [0.6311, 0.1108, 0.7249, 0.1322]}, {"w": "version", "b": [0.731, 0.1108, 0.7925, 0.1322]}, {"w": "of", "b": [0.7986, 0.1108, 0.8154, 0.1322]}, {"w": "Lin‐", "b": [0.8215, 0.1108, 0.8571, 0.1322]}, {"w": "ear", "b": [0.1429, 0.1324, 0.1686, 0.1538]}, {"w": "Regression:", "b": [0.1738, 0.1324, 0.2696, 0.1538]}, {"w": "a", "b": [0.2748, 0.1324, 0.284, 0.1538]}, {"w": "regularization", "b": [0.2892, 0.1322, 0.404, 0.1538]}, {"w": "term", "b": [0.4087, 0.1322, 0.4475, 0.1538]}, {"w": "equal", "b": [0.4532, 0.1324, 0.4982, 0.1538]}, {"w": "to", "b": [0.5034, 0.1324, 0.5204, 0.1538]}, {"w": "α∑i", "b": [0.5257, 0.1322, 0.5535, 0.1576]}, {"w": "=", "b": [0.5579, 0.1413, 0.5671, 0.1576]}, {"w": "1", "b": [0.5715, 0.1413, 0.5791, 0.1576]}]}, {"id": "b_4", "type": "paragraph", "text": "n θi", "words": [{"w": "n", "b": [0.5491, 0.1291, 0.5576, 0.1455]}, {"w": "θi", "b": [0.5814, 0.1322, 0.5957, 0.1576]}]}, {"id": "b_5", "type": "paragraph", "text": "2 is added to the cost function. This forces the learning algorithm to not only fit the data but also keep the model weights as small as possible. Note that the regularization term should only be added to the cost function during training. Once the model is trained, you want to evaluate the model’s performance using the unregularized performance measure.", "words": [{"w": "2", "b": [0.5957, 0.1292, 0.6033, 0.1455]}, {"w": "is", "b": [0.6086, 0.1324, 0.6218, 0.1538]}, {"w": "added", "b": [0.627, 0.1324, 0.678, 0.1538]}, {"w": "to", "b": [0.6833, 0.1324, 0.7002, 0.1538]}, {"w": "the", "b": [0.7055, 0.1324, 0.7318, 0.1538]}, {"w": "cost", "b": [0.7371, 0.1324, 0.7705, 0.1538]}, {"w": "function.", "b": [0.7758, 0.1324, 0.8519, 0.1538]}, {"w": "This", "b": [0.1428, 0.154, 0.1801, 0.1754]}, {"w": "forces", "b": [0.1873, 0.154, 0.2371, 0.1754]}, {"w": "the", "b": [0.2443, 0.154, 0.2707, 0.1754]}, {"w": "learning", "b": [0.2779, 0.154, 0.347, 0.1754]}, {"w": "algorithm", "b": [0.3543, 0.154, 0.4369, 0.1754]}, {"w": "to", "b": [0.4441, 0.154, 0.4611, 0.1754]}, {"w": "not", "b": [0.4684, 0.154, 0.4967, 0.1754]}, {"w": "only", "b": [0.504, 0.154, 0.5408, 0.1754]}, {"w": "fit", "b": [0.548, 0.154, 0.5661, 0.1754]}, {"w": "the", "b": [0.5734, 0.154, 0.5997, 0.1754]}, {"w": "data", "b": [0.6069, 0.154, 0.6422, 0.1754]}, {"w": "but", "b": [0.6494, 0.154, 0.6774, 0.1754]}, {"w": "also", "b": [0.6846, 0.154, 0.7173, 0.1754]}, {"w": "keep", "b": [0.7246, 0.154, 0.7635, 0.1754]}, {"w": "the", "b": [0.7708, 0.154, 0.7971, 0.1754]}, {"w": "model", "b": [0.8043, 0.154, 0.8571, 0.1754]}, {"w": "weights", "b": [0.1429, 0.1731, 0.206, 0.1945]}, {"w": "as", "b": [0.2123, 0.1731, 0.2291, 0.1945]}, {"w": "small", "b": [0.2353, 0.1731, 0.2797, 0.1945]}, {"w": "as", "b": [0.2859, 0.1731, 0.3027, 0.1945]}, {"w": "possible.", "b": [0.3089, 0.1731, 0.3808, 0.1945]}, {"w": "Note", "b": [0.387, 0.1731, 0.4278, 0.1945]}, {"w": "that", "b": [0.434, 0.1731, 0.4666, 0.1945]}, {"w": "the", "b": [0.4729, 0.1731, 0.4992, 0.1945]}, {"w": "regularization", "b": [0.5054, 0.1731, 0.622, 0.1945]}, {"w": "term", "b": [0.6282, 0.1731, 0.6682, 0.1945]}, {"w": "should", "b": [0.6744, 0.1731, 0.7312, 0.1945]}, {"w": "only", "b": [0.7374, 0.1731, 0.7743, 0.1945]}, {"w": "be", "b": [0.7805, 0.1731, 0.7999, 0.1945]}, {"w": "added", "b": [0.8061, 0.1731, 0.8571, 0.1945]}, {"w": "to", "b": [0.1429, 0.1921, 0.1598, 0.2135]}, {"w": "the", "b": [0.1655, 0.1921, 0.1918, 0.2135]}, {"w": "cost", "b": [0.1975, 0.1921, 0.2309, 0.2135]}, {"w": "function", "b": [0.2366, 0.1921, 0.308, 0.2135]}, {"w": "during", "b": [0.3136, 0.1921, 0.3701, 0.2135]}, {"w": "training.", "b": [0.3758, 0.1921, 0.4475, 0.2135]}, {"w": "Once", "b": [0.4531, 0.1921, 0.4978, 0.2135]}, {"w": "the", "b": [0.5034, 0.1921, 0.5298, 0.2135]}, {"w": "model", "b": [0.5354, 0.1921, 0.5882, 0.2135]}, {"w": "is", "b": [0.5939, 0.1921, 0.6071, 0.2135]}, {"w": "trained,", "b": [0.6128, 0.1921, 0.6776, 0.2135]}, {"w": "you", "b": [0.6832, 0.1921, 0.7145, 0.2135]}, {"w": "want", "b": [0.7201, 0.1921, 0.7609, 0.2135]}, {"w": "to", "b": [0.7666, 0.1921, 0.7835, 0.2135]}, {"w": "evaluate", "b": [0.7892, 0.1921, 0.8571, 0.2135]}, {"w": "the", "b": [0.1428, 0.2112, 0.1692, 0.2326]}, {"w": "model’s", "b": [0.1739, 0.2112, 0.2365, 0.2326]}, {"w": "performance", "b": [0.2412, 0.2112, 0.3485, 0.2326]}, {"w": "using", "b": [0.3532, 0.2112, 0.3987, 0.2326]}, {"w": "the", "b": [0.4034, 0.2112, 0.4297, 0.2326]}, {"w": "unregularized", "b": [0.4345, 0.2112, 0.5507, 0.2326]}, {"w": "performance", "b": [0.5554, 0.2112, 0.6627, 0.2326]}, {"w": "measure.", "b": [0.6674, 0.2112, 0.7425, 0.2326]}]}, {"id": "b_6", "type": "paragraph", "text": "It is quite common for the cost function used during training to be different from the performance measure used for testing. Apart from regularization, another reason why they might be different is that a good training cost function should have optimization- friendly derivatives, while the performance measure used for test‐ ing should be as close as possible to the final objective. A good example of this is a classifier trained using a cost function such as the log loss (discussed in a moment) but evaluated using precision/ recall.", "words": [{"w": "It", "b": [0.2714, 0.2531, 0.283, 0.2727]}, {"w": "is", "b": [0.2879, 0.2531, 0.3, 0.2727]}, {"w": "quite", "b": [0.3049, 0.2531, 0.3437, 0.2727]}, {"w": "common", "b": [0.3487, 0.2531, 0.4178, 0.2727]}, {"w": "for", "b": [0.4227, 0.2531, 0.4451, 0.2727]}, {"w": "the", "b": [0.45, 0.2531, 0.4741, 0.2727]}, {"w": "cost", "b": [0.479, 0.2531, 0.5096, 0.2727]}, {"w": "function", "b": [0.5145, 0.2531, 0.5797, 0.2727]}, {"w": "used", "b": [0.5846, 0.2531, 0.6199, 0.2727]}, {"w": "during", "b": [0.6248, 0.2531, 0.6765, 0.2727]}, {"w": "training", "b": [0.6814, 0.2531, 0.7426, 0.2727]}, {"w": "to", "b": [0.7475, 0.2531, 0.763, 0.2727]}, {"w": "be", "b": [0.7679, 0.2531, 0.7857, 0.2727]}, {"w": "different", "b": [0.2714, 0.2705, 0.337, 0.2901]}, {"w": "from", "b": [0.3454, 0.2705, 0.3834, 0.2901]}, {"w": "the", "b": [0.3919, 0.2705, 0.4159, 0.2901]}, {"w": "performance", "b": [0.4244, 0.2705, 0.5225, 0.2901]}, {"w": "measure", "b": [0.5309, 0.2705, 0.5952, 0.2901]}, {"w": "used", "b": [0.6037, 0.2705, 0.6389, 0.2901]}, {"w": "for", "b": [0.6473, 0.2705, 0.6698, 0.2901]}, {"w": "testing.", "b": [0.6782, 0.2705, 0.7337, 0.2901]}, {"w": "Apart", "b": [0.7421, 0.2705, 0.7857, 0.2901]}, {"w": "from", "b": [0.2714, 0.2879, 0.3094, 0.3075]}, {"w": "regularization,", "b": [0.315, 0.2879, 0.4259, 0.3075]}, {"w": "another", "b": [0.4315, 0.2879, 0.4911, 0.3075]}, {"w": "reason", "b": [0.4967, 0.2879, 0.5473, 0.3075]}, {"w": "why", "b": [0.5529, 0.2879, 0.5844, 0.3075]}, {"w": "they", "b": [0.59, 0.2879, 0.6228, 0.3075]}, {"w": "might", "b": [0.6284, 0.2879, 0.6736, 0.3075]}, {"w": "be", "b": [0.6792, 0.2879, 0.6969, 0.3075]}, {"w": "different", "b": [0.7025, 0.2879, 0.7681, 0.3075]}, {"w": "is", "b": [0.7736, 0.2879, 0.7857, 0.3075]}, {"w": "that", "b": [0.2714, 0.3053, 0.3012, 0.3249]}, {"w": "a", "b": [0.3123, 0.3053, 0.3206, 0.3249]}, {"w": "good", "b": [0.3317, 0.3053, 0.3701, 0.3249]}, {"w": "training", "b": [0.3812, 0.3053, 0.4424, 0.3249]}, {"w": "cost", "b": [0.4535, 0.3053, 0.484, 0.3249]}, {"w": "function", "b": [0.4951, 0.3053, 0.5604, 0.3249]}, {"w": "should", "b": [0.5715, 0.3053, 0.6233, 0.3249]}, {"w": "have", "b": [0.6344, 0.3053, 0.6695, 0.3249]}, {"w": "optimization-", "b": [0.6806, 0.3053, 0.7857, 0.3249]}, {"w": "friendly", "b": [0.2714, 0.3228, 0.3314, 0.3423]}, {"w": "derivatives,", "b": [0.3375, 0.3228, 0.4238, 0.3423]}, {"w": "while", "b": [0.43, 0.3228, 0.4712, 0.3423]}, {"w": "the", "b": [0.4773, 0.3228, 0.5014, 0.3423]}, {"w": "performance", "b": [0.5076, 0.3228, 0.6057, 0.3423]}, {"w": "measure", "b": [0.6118, 0.3228, 0.6761, 0.3423]}, {"w": "used", "b": [0.6823, 0.3228, 0.7175, 0.3423]}, {"w": "for", "b": [0.7237, 0.3228, 0.7461, 0.3423]}, {"w": "test‐", "b": [0.7522, 0.3228, 0.7857, 0.3423]}, {"w": "ing", "b": [0.2714, 0.3402, 0.2959, 0.3598]}, {"w": "should", "b": [0.3036, 0.3402, 0.3554, 0.3598]}, {"w": "be", "b": [0.3631, 0.3402, 0.3809, 0.3598]}, {"w": "as", "b": [0.3886, 0.3402, 0.4039, 0.3598]}, {"w": "close", "b": [0.4116, 0.3402, 0.4493, 0.3598]}, {"w": "as", "b": [0.457, 0.3402, 0.4724, 0.3598]}, {"w": "possible", "b": [0.4801, 0.3402, 0.5414, 0.3598]}, {"w": "to", "b": [0.5491, 0.3402, 0.5647, 0.3598]}, {"w": "the", "b": [0.5724, 0.3402, 0.5964, 0.3598]}, {"w": "final", "b": [0.6041, 0.3402, 0.6385, 0.3598]}, {"w": "objective.", "b": [0.6462, 0.3402, 0.7188, 0.3598]}, {"w": "A", "b": [0.7265, 0.3402, 0.7396, 0.3598]}, {"w": "good", "b": [0.7473, 0.3402, 0.7857, 0.3598]}, {"w": "example", "b": [0.2714, 0.3576, 0.335, 0.3772]}, {"w": "of", "b": [0.3408, 0.3576, 0.3561, 0.3772]}, {"w": "this", "b": [0.3619, 0.3576, 0.39, 0.3772]}, {"w": "is", "b": [0.3957, 0.3576, 0.4078, 0.3772]}, {"w": "a", "b": [0.4136, 0.3576, 0.422, 0.3772]}, {"w": "classifier", "b": [0.4277, 0.3576, 0.494, 0.3772]}, {"w": "trained", "b": [0.4997, 0.3576, 0.5547, 0.3772]}, {"w": "using", "b": [0.5604, 0.3576, 0.602, 0.3772]}, {"w": "a", "b": [0.6077, 0.3576, 0.6161, 0.3772]}, {"w": "cost", "b": [0.6219, 0.3576, 0.6524, 0.3772]}, {"w": "function", "b": [0.6582, 0.3576, 0.7235, 0.3772]}, {"w": "such", "b": [0.7293, 0.3576, 0.7646, 0.3772]}, {"w": "as", "b": [0.7704, 0.3576, 0.7857, 0.3772]}, {"w": "the", "b": [0.2714, 0.375, 0.2955, 0.3946]}, {"w": "log", "b": [0.3003, 0.375, 0.3237, 0.3946]}, {"w": "loss", "b": [0.3285, 0.375, 0.357, 0.3946]}, {"w": "(discussed", "b": [0.3618, 0.375, 0.4408, 0.3946]}, {"w": "in", "b": [0.4456, 0.375, 0.4611, 0.3946]}, {"w": "a", "b": [0.4659, 0.375, 0.4742, 0.3946]}, {"w": "moment)", "b": [0.479, 0.375, 0.5505, 0.3946]}, {"w": "but", "b": [0.5553, 0.375, 0.5809, 0.3946]}, {"w": "evaluated", "b": [0.5856, 0.375, 0.6578, 0.3946]}, {"w": "using", "b": [0.6626, 0.375, 0.7041, 0.3946]}, {"w": "precision/", "b": [0.7089, 0.375, 0.7857, 0.3946]}, {"w": "recall.", "b": [0.2714, 0.3924, 0.317, 0.412]}]}, {"id": "b_7", "type": "paragraph", "text": "The hyperparameter α controls how much you want to regularize the model. If α = 0 then Ridge Regression is just Linear Regression. If α is very large, then all weights end up very close to zero and the result is a flat line going through the data’s mean. Equa‐ tion 4-8 presents the Ridge Regression cost function.11", "words": [{"w": "The", "b": [0.1429, 0.4323, 0.1757, 0.4537]}, {"w": "hyperparameter", "b": [0.1812, 0.4323, 0.3147, 0.4537]}, {"w": "α", "b": [0.3202, 0.4321, 0.3314, 0.4537]}, {"w": "controls", "b": [0.3369, 0.4323, 0.405, 0.4537]}, {"w": "how", "b": [0.4105, 0.4323, 0.4465, 0.4537]}, {"w": "much", "b": [0.4521, 0.4323, 0.4997, 0.4537]}, {"w": "you", "b": [0.5053, 0.4323, 0.5365, 0.4537]}, {"w": "want", "b": [0.542, 0.4323, 0.5828, 0.4537]}, {"w": "to", "b": [0.5883, 0.4323, 0.6053, 0.4537]}, {"w": "regularize", "b": [0.6108, 0.4323, 0.6936, 0.4537]}, {"w": "the", "b": [0.6991, 0.4323, 0.7254, 0.4537]}, {"w": "model.", "b": [0.731, 0.4323, 0.7885, 0.4537]}, {"w": "If", "b": [0.7941, 0.4323, 0.8073, 0.4537]}, {"w": "α", "b": [0.8129, 0.4321, 0.824, 0.4537]}, {"w": "=", "b": [0.8295, 0.4323, 0.8416, 0.4537]}, {"w": "0", "b": [0.8471, 0.4323, 0.8571, 0.4537]}, {"w": "then", "b": [0.1428, 0.4513, 0.1806, 0.4728]}, {"w": "Ridge", "b": [0.1854, 0.4513, 0.2335, 0.4728]}, {"w": "Regression", "b": [0.2384, 0.4513, 0.3294, 0.4728]}, {"w": "is", "b": [0.3343, 0.4513, 0.3475, 0.4728]}, {"w": "just", "b": [0.3523, 0.4513, 0.3827, 0.4728]}, {"w": "Linear", "b": [0.3876, 0.4513, 0.4415, 0.4728]}, {"w": "Regression.", "b": [0.4463, 0.4513, 0.5421, 0.4728]}, {"w": "If", "b": [0.547, 0.4513, 0.5602, 0.4728]}, {"w": "α", "b": [0.5651, 0.4511, 0.5762, 0.4728]}, {"w": "is", "b": [0.5811, 0.4513, 0.5943, 0.4728]}, {"w": "very", "b": [0.5992, 0.4513, 0.6356, 0.4728]}, {"w": "large,", "b": [0.6404, 0.4513, 0.6859, 0.4728]}, {"w": "then", "b": [0.6907, 0.4513, 0.7285, 0.4728]}, {"w": "all", "b": [0.7333, 0.4513, 0.753, 0.4728]}, {"w": "weights", "b": [0.7579, 0.4513, 0.821, 0.4728]}, {"w": "end", "b": [0.8259, 0.4513, 0.8571, 0.4728]}, {"w": "up", "b": [0.1428, 0.4704, 0.1648, 0.4918]}, {"w": "very", "b": [0.1702, 0.4704, 0.2065, 0.4918]}, {"w": "close", "b": [0.2119, 0.4704, 0.2531, 0.4918]}, {"w": "to", "b": [0.2584, 0.4704, 0.2754, 0.4918]}, {"w": "zero", "b": [0.2807, 0.4704, 0.3167, 0.4918]}, {"w": "and", "b": [0.322, 0.4704, 0.3535, 0.4918]}, {"w": "the", "b": [0.3589, 0.4704, 0.3852, 0.4918]}, {"w": "result", "b": [0.3905, 0.4704, 0.4374, 0.4918]}, {"w": "is", "b": [0.4428, 0.4704, 0.456, 0.4918]}, {"w": "a", "b": [0.4613, 0.4704, 0.4705, 0.4918]}, {"w": "flat", "b": [0.4758, 0.4704, 0.5023, 0.4918]}, {"w": "line", "b": [0.5076, 0.4704, 0.5387, 0.4918]}, {"w": "going", "b": [0.5441, 0.4704, 0.5912, 0.4918]}, {"w": "through", "b": [0.5965, 0.4704, 0.6643, 0.4918]}, {"w": "the", "b": [0.6696, 0.4704, 0.6959, 0.4918]}, {"w": "data’s", "b": [0.7013, 0.4704, 0.7452, 0.4918]}, {"w": "mean.", "b": [0.7505, 0.4704, 0.8017, 0.4918]}, {"w": "Equa‐", "b": [0.807, 0.4704, 0.8571, 0.4918]}, {"w": "tion", "b": [0.1429, 0.4894, 0.1768, 0.5108]}, {"w": "4-8", "b": [0.1816, 0.4894, 0.209, 0.5108]}, {"w": "presents", "b": [0.2137, 0.4894, 0.2827, 0.5108]}, {"w": "the", "b": [0.2874, 0.4894, 0.3138, 0.5108]}, {"w": "Ridge", "b": [0.3185, 0.4894, 0.3666, 0.5108]}, {"w": "Regression", "b": [0.3713, 0.4894, 0.4624, 0.5108]}, {"w": "cost", "b": [0.4671, 0.4894, 0.5005, 0.5108]}, {"w": "function.11", "b": [0.5053, 0.4894, 0.5928, 0.5108]}]}, {"id": "b_8", "type": "equation", "text": "Equation 4-8. Ridge Regression cost function", "words": [{"w": "Equation", "b": [0.1726, 0.529, 0.2473, 0.5506]}, {"w": "4-8.", "b": [0.2521, 0.529, 0.2838, 0.5506]}, {"w": "Ridge", "b": [0.2886, 0.529, 0.3338, 0.5506]}, {"w": "Regression", "b": [0.3386, 0.529, 0.4233, 0.5506]}, {"w": "cost", "b": [0.4281, 0.529, 0.4588, 0.5506]}, {"w": "function", "b": [0.4635, 0.529, 0.5316, 0.5506]}]}, {"id": "b_9", "type": "equation", "text": "J θ = MSE θ + α1", "words": [{"w": "J", "b": [0.1731, 0.5625, 0.1795, 0.5831]}, {"w": "θ", "b": [0.1874, 0.5622, 0.1975, 0.5831]}, {"w": "=", "b": [0.2098, 0.5627, 0.2213, 0.5831]}, {"w": "MSE", "b": [0.2269, 0.5627, 0.2652, 0.5831]}, {"w": "θ", "b": [0.2721, 0.5622, 0.2822, 0.5831]}, {"w": "+", "b": [0.2935, 0.5627, 0.305, 0.5831]}, {"w": "α1", "b": [0.3094, 0.5577, 0.3298, 0.5831]}]}, {"id": "b_10", "type": "equation", "text": "2 ∑i = 1 n θi", "words": [{"w": "2", "b": [0.3222, 0.5723, 0.3298, 0.5887]}, {"w": "∑i", "b": [0.3331, 0.5627, 0.3481, 0.5874]}, {"w": "=", "b": [0.3525, 0.5711, 0.3617, 0.5874]}, {"w": "1", "b": [0.3661, 0.5711, 0.3737, 0.5874]}, {"w": "n", "b": [0.3437, 0.5588, 0.3522, 0.5753]}, {"w": "θi", "b": [0.3759, 0.5625, 0.3897, 0.5874]}]}, {"id": "b_12", "type": "paragraph", "text": "Note that the bias term θ0 is not regularized (the sum starts at i = 1, not 0). If we define w as the vector of feature weights (θ1 to θn), then the regularization term is simply equal to ½(∥ w ∥2)2, where ∥ w ∥2 represents the ℓ2 norm of the weight vector.12", "words": [{"w": "Note", "b": [0.1429, 0.6077, 0.1836, 0.6291]}, {"w": "that", "b": [0.1911, 0.6077, 0.2237, 0.6291]}, {"w": "the", "b": [0.2312, 0.6077, 0.2575, 0.6291]}, {"w": "bias", "b": [0.265, 0.6077, 0.2979, 0.6291]}, {"w": "term", "b": [0.3054, 0.6077, 0.3454, 0.6291]}, {"w": "θ0", "b": [0.3528, 0.6075, 0.3688, 0.63]}, {"w": "is", "b": [0.3762, 0.6077, 0.3895, 0.6291]}, {"w": "not", "b": [0.3969, 0.6077, 0.4253, 0.6291]}, {"w": "regularized", "b": [0.4328, 0.6077, 0.5265, 0.6291]}, {"w": "(the", "b": [0.534, 0.6077, 0.5675, 0.6291]}, {"w": "sum", "b": [0.575, 0.6077, 0.6107, 0.6291]}, {"w": "starts", "b": [0.6182, 0.6077, 0.6631, 0.6291]}, {"w": "at", "b": [0.6705, 0.6077, 0.6856, 0.6291]}, {"w": "i", "b": [0.6931, 0.6075, 0.6988, 0.6291]}, {"w": "=", "b": [0.7063, 0.6077, 0.7183, 0.6291]}, {"w": "1,", "b": [0.7258, 0.6077, 0.7406, 0.6291]}, {"w": "not", "b": [0.748, 0.6077, 0.7764, 0.6291]}, {"w": "0).", "b": [0.7839, 0.6077, 0.8058, 0.6291]}, {"w": "If", "b": [0.8133, 0.6077, 0.8266, 0.6291]}, {"w": "we", "b": [0.834, 0.6077, 0.8571, 0.6291]}, {"w": "define", "b": [0.1429, 0.6268, 0.1947, 0.6482]}, {"w": "w", "b": [0.2022, 0.6262, 0.2165, 0.6482]}, {"w": "as", "b": [0.224, 0.6268, 0.2408, 0.6482]}, {"w": "the", "b": [0.2483, 0.6268, 0.2746, 0.6482]}, {"w": "vector", "b": [0.2821, 0.6268, 0.3342, 0.6482]}, {"w": "of", "b": [0.3417, 0.6268, 0.3585, 0.6482]}, {"w": "feature", "b": [0.366, 0.6268, 0.4237, 0.6482]}, {"w": "weights", "b": [0.4313, 0.6268, 0.4945, 0.6482]}, {"w": "(θ1", "b": [0.502, 0.6266, 0.5251, 0.6491]}, {"w": "to", "b": [0.5326, 0.6268, 0.5496, 0.6482]}, {"w": "θn),", "b": [0.5571, 0.6266, 0.5857, 0.6491]}, {"w": "then", "b": [0.5932, 0.6268, 0.6309, 0.6482]}, {"w": "the", "b": [0.6384, 0.6268, 0.6648, 0.6482]}, {"w": "regularization", "b": [0.6723, 0.6268, 0.7889, 0.6482]}, {"w": "term", "b": [0.7964, 0.6268, 0.8364, 0.6482]}, {"w": "is", "b": [0.8439, 0.6268, 0.8571, 0.6482]}, {"w": "simply", "b": [0.1429, 0.6458, 0.1985, 0.6672]}, {"w": "equal", "b": [0.2032, 0.6458, 0.2482, 0.6672]}, {"w": "to", "b": [0.2529, 0.6458, 0.2699, 0.6672]}, {"w": "½(∥", "b": [0.2747, 0.6458, 0.3088, 0.6672]}, {"w": "w", "b": [0.3137, 0.6453, 0.3279, 0.6672]}, {"w": "∥2)2,", "b": [0.3328, 0.6458, 0.3672, 0.6681]}, {"w": "where", "b": [0.3719, 0.6458, 0.4228, 0.6672]}, {"w": "∥", "b": [0.4279, 0.6491, 0.4383, 0.6649]}, {"w": "w", "b": [0.4433, 0.6453, 0.4575, 0.6672]}, {"w": "∥2", "b": [0.4624, 0.6491, 0.4788, 0.6681]}, {"w": "represents", "b": [0.4838, 0.6458, 0.5694, 0.6672]}, {"w": "the", "b": [0.5741, 0.6458, 0.6004, 0.6672]}, {"w": "ℓ2", "b": [0.6052, 0.6458, 0.6201, 0.6681]}, {"w": "norm", "b": [0.6251, 0.6458, 0.6719, 0.6672]}, {"w": "of", "b": [0.6768, 0.6458, 0.6936, 0.6672]}, {"w": "the", "b": [0.6985, 0.6458, 0.7249, 0.6672]}, {"w": "weight", "b": [0.7298, 0.6458, 0.7853, 0.6672]}, {"w": "vector.12", "b": [0.7903, 0.6458, 0.8571, 0.6672]}]}, {"id": "b_13", "type": "equation", "text": "For Gradient Descent, just add αw to the MSE gradient vector (Equation 4-6).", "words": [{"w": "For", "b": [0.1428, 0.6649, 0.1718, 0.6863]}, {"w": "Gradient", "b": [0.1766, 0.6649, 0.2511, 0.6863]}, {"w": "Descent,", "b": [0.2558, 0.6649, 0.3274, 0.6863]}, {"w": "just", "b": [0.3322, 0.6649, 0.3626, 0.6863]}, {"w": "add", "b": [0.3673, 0.6649, 0.3984, 0.6863]}, {"w": "αw", "b": [0.4032, 0.6643, 0.4285, 0.6863]}, {"w": "to", "b": [0.4333, 0.6649, 0.4502, 0.6863]}, {"w": "the", "b": [0.455, 0.6649, 0.4813, 0.6863]}, {"w": "MSE", "b": [0.486, 0.6649, 0.5263, 0.6863]}, {"w": "gradient", "b": [0.531, 0.6649, 0.6005, 0.6863]}, {"w": "vector", "b": [0.6052, 0.6649, 0.6572, 0.6863]}, {"w": "(Equation", "b": [0.6619, 0.6649, 0.7454, 0.6863]}, {"w": "4-6).", "b": [0.7501, 0.6649, 0.7895, 0.6863]}]}, {"id": "b_14", "type": "paragraph", "text": "It is important to scale the data (e.g., using a StandardScaler) before performing Ridge Regression, as it is sensitive to the scale of the input features. This is true of most regularized models.", "words": [{"w": "It", "b": [0.2714, 0.7076, 0.283, 0.7272]}, {"w": "is", "b": [0.2908, 0.7076, 0.3029, 0.7272]}, {"w": "important", "b": [0.3106, 0.7076, 0.3878, 0.7272]}, {"w": "to", "b": [0.3956, 0.7076, 0.4111, 0.7272]}, {"w": "scale", "b": [0.4189, 0.7076, 0.4552, 0.7272]}, {"w": "the", "b": [0.463, 0.7076, 0.487, 0.7272]}, {"w": "data", "b": [0.4948, 0.7076, 0.527, 0.7272]}, {"w": "(e.g.,", "b": [0.5348, 0.7076, 0.5714, 0.7272]}, {"w": "using", "b": [0.5792, 0.7076, 0.6208, 0.7272]}, {"w": "a", "b": [0.6285, 0.7076, 0.6369, 0.7272]}, {"w": "StandardScaler)", "b": [0.6447, 0.7076, 0.7779, 0.7272]}, {"w": "before", "b": [0.2714, 0.725, 0.3197, 0.7446]}, {"w": "performing", "b": [0.3244, 0.725, 0.412, 0.7446]}, {"w": "Ridge", "b": [0.4167, 0.725, 0.4607, 0.7446]}, {"w": "Regression,", "b": [0.4654, 0.725, 0.553, 0.7446]}, {"w": "as", "b": [0.5577, 0.725, 0.5731, 0.7446]}, {"w": "it", "b": [0.5778, 0.725, 0.5887, 0.7446]}, {"w": "is", "b": [0.5934, 0.725, 0.6055, 0.7446]}, {"w": "sensitive", "b": [0.6102, 0.725, 0.6756, 0.7446]}, {"w": "to", "b": [0.6803, 0.725, 0.6958, 0.7446]}, {"w": "the", "b": [0.7006, 0.725, 0.7246, 0.7446]}, {"w": "scale", "b": [0.7293, 0.725, 0.7657, 0.7446]}, {"w": "of", "b": [0.7704, 0.725, 0.7857, 0.7446]}, {"w": "the", "b": [0.2714, 0.7425, 0.2955, 0.762]}, {"w": "input", "b": [0.2998, 0.7425, 0.3409, 0.762]}, {"w": "features.", "b": [0.3452, 0.7425, 0.4093, 0.762]}, {"w": "This", "b": [0.4137, 0.7425, 0.4477, 0.762]}, {"w": "is", "b": [0.452, 0.7425, 0.4641, 0.762]}, {"w": "true", "b": [0.4684, 0.7425, 0.4995, 0.762]}, {"w": "of", "b": [0.5038, 0.7425, 0.5192, 0.762]}, {"w": "most", "b": [0.5235, 0.7425, 0.5616, 0.762]}, {"w": "regularized", "b": [0.566, 0.7425, 0.6516, 0.762]}, {"w": "models.", "b": [0.656, 0.7425, 0.7156, 0.762]}]}, {"id": "b_15", "type": "paragraph", "text": "Regularized Linear Models | 137", "words": [{"w": "Regularized", "b": [0.6409, 0.9225, 0.711, 0.9388]}, {"w": "Linear", "b": [0.7138, 0.9225, 0.7507, 0.9388]}, {"w": "Models", "b": [0.7536, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "137", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 164, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "13 A square matrix full of 0s except for 1s on the main diagonal (top-left to bottom-right).", "words": [{"w": "13", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "A", "b": [0.1587, 0.8749, 0.1697, 0.8912]}, {"w": "square", "b": [0.1733, 0.8749, 0.2153, 0.8912]}, {"w": "matrix", "b": [0.2189, 0.8749, 0.261, 0.8912]}, {"w": "full", "b": [0.2646, 0.8749, 0.2858, 0.8912]}, {"w": "of", "b": [0.2894, 0.8749, 0.3022, 0.8912]}, {"w": "0s", "b": [0.3058, 0.8749, 0.3192, 0.8912]}, {"w": "except", "b": [0.3228, 0.8749, 0.3637, 0.8912]}, {"w": "for", "b": [0.3673, 0.8749, 0.386, 0.8912]}, {"w": "1s", "b": [0.3896, 0.8749, 0.403, 0.8912]}, {"w": "on", "b": [0.4066, 0.8749, 0.4234, 0.8912]}, {"w": "the", "b": [0.427, 0.8749, 0.4471, 0.8912]}, {"w": "main", "b": [0.4507, 0.8749, 0.4836, 0.8912]}, {"w": "diagonal", "b": [0.4872, 0.8749, 0.542, 0.8912]}, {"w": "(top-left", "b": [0.5456, 0.8749, 0.5983, 0.8912]}, {"w": "to", "b": [0.6019, 0.8749, 0.6148, 0.8912]}, {"w": "bottom-right).", "b": [0.6184, 0.8749, 0.7107, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Figure 4-17 shows several Ridge models trained on some linear data using different α value. On the left, plain Ridge models are used, leading to linear predictions. On the right, the data is first expanded using PolynomialFeatures(degree=10), then it is scaled using a StandardScaler, and finally the Ridge models are applied to the result‐ ing features: this is Polynomial Regression with Ridge regularization. Note how increasing α leads to flatter (i.e., less extreme, more reasonable) predictions; this reduces the model’s variance but increases its bias.", "words": [{"w": "Figure", "b": [0.1429, 0.0791, 0.1969, 0.1005]}, {"w": "4-17", "b": [0.2016, 0.0791, 0.239, 0.1005]}, {"w": "shows", "b": [0.2447, 0.0791, 0.2961, 0.1005]}, {"w": "several", "b": [0.3013, 0.0791, 0.3584, 0.1005]}, {"w": "Ridge", "b": [0.3637, 0.0791, 0.4118, 0.1005]}, {"w": "models", "b": [0.417, 0.0791, 0.4775, 0.1005]}, {"w": "trained", "b": [0.4827, 0.0791, 0.5428, 0.1005]}, {"w": "on", "b": [0.548, 0.0791, 0.57, 0.1005]}, {"w": "some", "b": [0.5753, 0.0791, 0.6195, 0.1005]}, {"w": "linear", "b": [0.6247, 0.0791, 0.6727, 0.1005]}, {"w": "data", "b": [0.6779, 0.0791, 0.7131, 0.1005]}, {"w": "using", "b": [0.7184, 0.0791, 0.7638, 0.1005]}, {"w": "different", "b": [0.7691, 0.0791, 0.8408, 0.1005]}, {"w": "α", "b": [0.846, 0.0789, 0.8571, 0.1005]}, {"w": "value.", "b": [0.1429, 0.0981, 0.1916, 0.1195]}, {"w": "On", "b": [0.1975, 0.0981, 0.2244, 0.1195]}, {"w": "the", "b": [0.2303, 0.0981, 0.2566, 0.1195]}, {"w": "left,", "b": [0.2625, 0.0981, 0.2939, 0.1195]}, {"w": "plain", "b": [0.2998, 0.0981, 0.3421, 0.1195]}, {"w": "Ridge", "b": [0.348, 0.0981, 0.3961, 0.1195]}, {"w": "models", "b": [0.402, 0.0981, 0.4625, 0.1195]}, {"w": "are", "b": [0.4684, 0.0981, 0.4941, 0.1195]}, {"w": "used,", "b": [0.5, 0.0981, 0.5433, 0.1195]}, {"w": "leading", "b": [0.5492, 0.0981, 0.6102, 0.1195]}, {"w": "to", "b": [0.6161, 0.0981, 0.6331, 0.1195]}, {"w": "linear", "b": [0.639, 0.0981, 0.6869, 0.1195]}, {"w": "predictions.", "b": [0.6928, 0.0981, 0.7921, 0.1195]}, {"w": "On", "b": [0.798, 0.0981, 0.8249, 0.1195]}, {"w": "the", "b": [0.8308, 0.0981, 0.8571, 0.1195]}, {"w": "right,", "b": [0.1429, 0.1181, 0.1878, 0.1395]}, {"w": "the", "b": [0.1958, 0.1181, 0.2221, 0.1395]}, {"w": "data", "b": [0.2301, 0.1181, 0.2654, 0.1395]}, {"w": "is", "b": [0.2734, 0.1181, 0.2866, 0.1395]}, {"w": "first", "b": [0.2946, 0.1181, 0.3281, 0.1395]}, {"w": "expanded", "b": [0.3361, 0.1181, 0.4171, 0.1395]}, {"w": "using", "b": [0.4251, 0.1181, 0.4705, 0.1395]}, {"w": "PolynomialFeatures(degree=10),", "b": [0.4785, 0.1181, 0.7702, 0.1395]}, {"w": "then", "b": [0.7782, 0.1181, 0.816, 0.1395]}, {"w": "it", "b": [0.824, 0.1181, 0.8359, 0.1395]}, {"w": "is", "b": [0.8439, 0.1181, 0.8572, 0.1395]}, {"w": "scaled", "b": [0.1429, 0.138, 0.1936, 0.1594]}, {"w": "using", "b": [0.1983, 0.138, 0.2438, 0.1594]}, {"w": "a", "b": [0.2485, 0.138, 0.2576, 0.1594]}, {"w": "StandardScaler,", "b": [0.2625, 0.138, 0.4058, 0.1594]}, {"w": "and", "b": [0.4105, 0.138, 0.4421, 0.1594]}, {"w": "finally", "b": [0.4468, 0.138, 0.4992, 0.1594]}, {"w": "the", "b": [0.5039, 0.138, 0.5303, 0.1594]}, {"w": "Ridge", "b": [0.535, 0.138, 0.5831, 0.1594]}, {"w": "models", "b": [0.5879, 0.138, 0.6483, 0.1594]}, {"w": "are", "b": [0.653, 0.138, 0.6788, 0.1594]}, {"w": "applied", "b": [0.6835, 0.138, 0.7448, 0.1594]}, {"w": "to", "b": [0.7495, 0.138, 0.7665, 0.1594]}, {"w": "the", "b": [0.7712, 0.138, 0.7976, 0.1594]}, {"w": "result‐", "b": [0.8023, 0.138, 0.8566, 0.1594]}, {"w": "ing", "b": [0.1429, 0.157, 0.1696, 0.1785]}, {"w": "features:", "b": [0.1799, 0.157, 0.2501, 0.1785]}, {"w": "this", "b": [0.2604, 0.157, 0.2911, 0.1785]}, {"w": "is", "b": [0.3014, 0.157, 0.3147, 0.1785]}, {"w": "Polynomial", "b": [0.325, 0.157, 0.4206, 0.1785]}, {"w": "Regression", "b": [0.4309, 0.157, 0.5219, 0.1785]}, {"w": "with", "b": [0.5322, 0.157, 0.5696, 0.1785]}, {"w": "Ridge", "b": [0.5799, 0.157, 0.628, 0.1785]}, {"w": "regularization.", "b": [0.6383, 0.157, 0.7597, 0.1785]}, {"w": "Note", "b": [0.77, 0.157, 0.8108, 0.1785]}, {"w": "how", "b": [0.8211, 0.157, 0.8571, 0.1785]}, {"w": "increasing", "b": [0.1429, 0.1761, 0.2288, 0.1975]}, {"w": "α", "b": [0.2379, 0.1759, 0.2491, 0.1975]}, {"w": "leads", "b": [0.2582, 0.1761, 0.3001, 0.1975]}, {"w": "to", "b": [0.3093, 0.1761, 0.3262, 0.1975]}, {"w": "flatter", "b": [0.3354, 0.1761, 0.3849, 0.1975]}, {"w": "(i.e.,", "b": [0.394, 0.1761, 0.4299, 0.1975]}, {"w": "less", "b": [0.439, 0.1761, 0.4685, 0.1975]}, {"w": "extreme,", "b": [0.4776, 0.1761, 0.5499, 0.1975]}, {"w": "more", "b": [0.559, 0.1761, 0.6033, 0.1975]}, {"w": "reasonable)", "b": [0.6124, 0.1761, 0.7089, 0.1975]}, {"w": "predictions;", "b": [0.7181, 0.1761, 0.8173, 0.1975]}, {"w": "this", "b": [0.8264, 0.1761, 0.8572, 0.1975]}, {"w": "reduces", "b": [0.1429, 0.1951, 0.2068, 0.2166]}, {"w": "the", "b": [0.2115, 0.1951, 0.2379, 0.2166]}, {"w": "model’s", "b": [0.2426, 0.1951, 0.3052, 0.2166]}, {"w": "variance", "b": [0.3099, 0.1951, 0.3802, 0.2166]}, {"w": "but", "b": [0.385, 0.1951, 0.413, 0.2166]}, {"w": "increases", "b": [0.4177, 0.1951, 0.4934, 0.2166]}, {"w": "its", "b": [0.4981, 0.1951, 0.5177, 0.2166]}, {"w": "bias.", "b": [0.5224, 0.1951, 0.5601, 0.2166]}]}, {"id": "b_2", "type": "paragraph", "text": "As with Linear Regression, we can perform Ridge Regression either by computing a closed-form equation or by performing Gradient Descent. The pros and cons are the same. Equation 4-9 shows the closed-form solution (where A is the (n + 1) × (n + 1) identity matrix13 except with a 0 in the top-left cell, corresponding to the bias term).", "words": [{"w": "As", "b": [0.1429, 0.2233, 0.1649, 0.2447]}, {"w": "with", "b": [0.1707, 0.2233, 0.208, 0.2447]}, {"w": "Linear", "b": [0.2139, 0.2233, 0.2678, 0.2447]}, {"w": "Regression,", "b": [0.2736, 0.2233, 0.3694, 0.2447]}, {"w": "we", "b": [0.3752, 0.2233, 0.3983, 0.2447]}, {"w": "can", "b": [0.4041, 0.2233, 0.4335, 0.2447]}, {"w": "perform", "b": [0.4393, 0.2233, 0.5084, 0.2447]}, {"w": "Ridge", "b": [0.5142, 0.2233, 0.5623, 0.2447]}, {"w": "Regression", "b": [0.5681, 0.2233, 0.6591, 0.2447]}, {"w": "either", "b": [0.6649, 0.2233, 0.7134, 0.2447]}, {"w": "by", "b": [0.7193, 0.2233, 0.7394, 0.2447]}, {"w": "computing", "b": [0.7452, 0.2233, 0.8364, 0.2447]}, {"w": "a", "b": [0.8422, 0.2233, 0.8513, 0.2447]}, {"w": "closed-form", "b": [0.1429, 0.2423, 0.2441, 0.2637]}, {"w": "equation", "b": [0.2497, 0.2423, 0.323, 0.2637]}, {"w": "or", "b": [0.3286, 0.2423, 0.3469, 0.2637]}, {"w": "by", "b": [0.3526, 0.2423, 0.3727, 0.2637]}, {"w": "performing", "b": [0.3783, 0.2423, 0.4742, 0.2637]}, {"w": "Gradient", "b": [0.4798, 0.2423, 0.5543, 0.2637]}, {"w": "Descent.", "b": [0.56, 0.2423, 0.6316, 0.2637]}, {"w": "The", "b": [0.6372, 0.2423, 0.67, 0.2637]}, {"w": "pros", "b": [0.6756, 0.2423, 0.7126, 0.2637]}, {"w": "and", "b": [0.7182, 0.2423, 0.7497, 0.2637]}, {"w": "cons", "b": [0.7553, 0.2423, 0.7938, 0.2637]}, {"w": "are", "b": [0.7995, 0.2423, 0.8252, 0.2637]}, {"w": "the", "b": [0.8308, 0.2423, 0.8571, 0.2637]}, {"w": "same.", "b": [0.1428, 0.2614, 0.1903, 0.2828]}, {"w": "Equation", "b": [0.196, 0.2614, 0.2722, 0.2828]}, {"w": "4-9", "b": [0.2779, 0.2614, 0.3053, 0.2828]}, {"w": "shows", "b": [0.3109, 0.2614, 0.3623, 0.2828]}, {"w": "the", "b": [0.3679, 0.2614, 0.3943, 0.2828]}, {"w": "closed-form", "b": [0.3999, 0.2614, 0.5011, 0.2828]}, {"w": "solution", "b": [0.5068, 0.2614, 0.5753, 0.2828]}, {"w": "(where", "b": [0.581, 0.2614, 0.639, 0.2828]}, {"w": "A", "b": [0.6447, 0.2608, 0.6594, 0.2828]}, {"w": "is", "b": [0.6651, 0.2614, 0.6783, 0.2828]}, {"w": "the", "b": [0.6839, 0.2614, 0.7103, 0.2828]}, {"w": "(n", "b": [0.7159, 0.2611, 0.7342, 0.2828]}, {"w": "+", "b": [0.7399, 0.2614, 0.752, 0.2828]}, {"w": "1)", "b": [0.7576, 0.2614, 0.7748, 0.2828]}, {"w": "×", "b": [0.7805, 0.2614, 0.7926, 0.2828]}, {"w": "(n", "b": [0.7982, 0.2611, 0.8165, 0.2828]}, {"w": "+", "b": [0.8222, 0.2614, 0.8343, 0.2828]}, {"w": "1)", "b": [0.8399, 0.2614, 0.8571, 0.2828]}, {"w": "identity", "b": [0.1429, 0.2802, 0.2051, 0.3018]}, {"w": "matrix13", "b": [0.2099, 0.2802, 0.2769, 0.3018]}, {"w": "except", "b": [0.2816, 0.2804, 0.3353, 0.3018]}, {"w": "with", "b": [0.34, 0.2804, 0.3773, 0.3018]}, {"w": "a", "b": [0.382, 0.2804, 0.3912, 0.3018]}, {"w": "0", "b": [0.3959, 0.2804, 0.4059, 0.3018]}, {"w": "in", "b": [0.4106, 0.2804, 0.4276, 0.3018]}, {"w": "the", "b": [0.4324, 0.2804, 0.4587, 0.3018]}, {"w": "top-left", "b": [0.4634, 0.2804, 0.5254, 0.3018]}, {"w": "cell,", "b": [0.5301, 0.2804, 0.5631, 0.3018]}, {"w": "corresponding", "b": [0.5678, 0.2804, 0.6899, 0.3018]}, {"w": "to", "b": [0.6946, 0.2804, 0.7116, 0.3018]}, {"w": "the", "b": [0.7163, 0.2804, 0.7426, 0.3018]}, {"w": "bias", "b": [0.7474, 0.2804, 0.7803, 0.3018]}, {"w": "term).", "b": [0.785, 0.2804, 0.837, 0.3018]}]}, {"id": "b_3", "type": "equation", "text": "Figure 4-17. Ridge Regression", "words": [{"w": "Figure", "b": [0.1429, 0.5765, 0.1943, 0.5981]}, {"w": "4-17.", "b": [0.1991, 0.5765, 0.2407, 0.5981]}, {"w": "Ridge", "b": [0.2455, 0.5765, 0.2907, 0.5981]}, {"w": "Regression", "b": [0.2955, 0.5765, 0.3802, 0.5981]}]}, {"id": "b_4", "type": "equation", "text": "Equation 4-9. Ridge Regression closed-form solution", "words": [{"w": "Equation", "b": [0.1726, 0.6162, 0.2473, 0.6378]}, {"w": "4-9.", "b": [0.2521, 0.6162, 0.2838, 0.6378]}, {"w": "Ridge", "b": [0.2886, 0.6162, 0.3338, 0.6378]}, {"w": "Regression", "b": [0.3386, 0.6162, 0.4233, 0.6378]}, {"w": "closed-form", "b": [0.4281, 0.6162, 0.5226, 0.6378]}, {"w": "solution", "b": [0.5274, 0.6162, 0.5923, 0.6378]}]}, {"id": "b_5", "type": "equation", "text": "θ = XTX + αA", "words": [{"w": "θ", "b": [0.1732, 0.6515, 0.1833, 0.6724]}, {"w": "=", "b": [0.1894, 0.652, 0.2009, 0.6724]}, {"w": "XTX", "b": [0.2133, 0.6481, 0.251, 0.6724]}, {"w": "+", "b": [0.2554, 0.652, 0.267, 0.6724]}, {"w": "αA", "b": [0.2714, 0.6515, 0.296, 0.6724]}]}, {"id": "b_6", "type": "paragraph", "text": "−1 XT y", "words": [{"w": "−1", "b": [0.3028, 0.645, 0.3206, 0.6613]}, {"w": "XT", "b": [0.3361, 0.6481, 0.3594, 0.6724]}, {"w": "y", "b": [0.3758, 0.6515, 0.385, 0.6724]}]}, {"id": "b_7", "type": "paragraph", "text": "Here is how to perform Ridge Regression with Scikit-Learn using a closed-form solu‐ tion (a variant of Equation 4-9 using a matrix factorization technique by André-Louis Cholesky):", "words": [{"w": "Here", "b": [0.1428, 0.6951, 0.1837, 0.7166]}, {"w": "is", "b": [0.1888, 0.6951, 0.2021, 0.7166]}, {"w": "how", "b": [0.2072, 0.6951, 0.2432, 0.7166]}, {"w": "to", "b": [0.2484, 0.6951, 0.2653, 0.7166]}, {"w": "perform", "b": [0.2705, 0.6951, 0.3395, 0.7166]}, {"w": "Ridge", "b": [0.3447, 0.6951, 0.3928, 0.7166]}, {"w": "Regression", "b": [0.3979, 0.6951, 0.4889, 0.7166]}, {"w": "with", "b": [0.4941, 0.6951, 0.5314, 0.7166]}, {"w": "Scikit-Learn", "b": [0.5365, 0.6951, 0.6388, 0.7166]}, {"w": "using", "b": [0.6439, 0.6951, 0.6894, 0.7166]}, {"w": "a", "b": [0.6945, 0.6951, 0.7037, 0.7166]}, {"w": "closed-form", "b": [0.7088, 0.6951, 0.81, 0.7166]}, {"w": "solu‐", "b": [0.8151, 0.6951, 0.8571, 0.7166]}, {"w": "tion", "b": [0.1429, 0.7142, 0.1768, 0.7356]}, {"w": "(a", "b": [0.1818, 0.7142, 0.1981, 0.7356]}, {"w": "variant", "b": [0.2031, 0.7142, 0.2617, 0.7356]}, {"w": "of", "b": [0.2666, 0.7142, 0.2834, 0.7356]}, {"w": "Equation", "b": [0.2884, 0.7142, 0.3646, 0.7356]}, {"w": "4-9", "b": [0.3693, 0.7142, 0.3968, 0.7356]}, {"w": "using", "b": [0.4019, 0.7142, 0.4474, 0.7356]}, {"w": "a", "b": [0.4523, 0.7142, 0.4615, 0.7356]}, {"w": "matrix", "b": [0.4664, 0.7142, 0.5217, 0.7356]}, {"w": "factorization", "b": [0.5267, 0.7142, 0.6325, 0.7356]}, {"w": "technique", "b": [0.6375, 0.7142, 0.7202, 0.7356]}, {"w": "by", "b": [0.7251, 0.7142, 0.7453, 0.7356]}, {"w": "André-Louis", "b": [0.7502, 0.7142, 0.8571, 0.7356]}, {"w": "Cholesky):", "b": [0.1429, 0.7332, 0.2321, 0.7547]}]}, {"id": "b_8", "type": "paragraph", "text": ">>> from sklearn.linear_model import Ridge >>> ridge_reg = Ridge(alpha=1, solver=\"cholesky\") >>> ridge_reg.fit(X, y)", "words": [{"w": ">>>", "b": [0.1766, 0.7652, 0.2019, 0.7781]}, {"w": "from", "b": [0.2103, 0.7652, 0.244, 0.7781]}, {"w": "sklearn.linear_model", "b": [0.2525, 0.7652, 0.4211, 0.7781]}, {"w": "import", "b": [0.4296, 0.7652, 0.4802, 0.7781]}, {"w": "Ridge", "b": [0.4886, 0.7652, 0.5307, 0.7781]}, {"w": ">>>", "b": [0.1766, 0.7806, 0.2019, 0.7935]}, {"w": "ridge_reg", "b": [0.2103, 0.7806, 0.2862, 0.7935]}, {"w": "=", "b": [0.2946, 0.7806, 0.3031, 0.7935]}, {"w": "Ridge(alpha=1,", "b": [0.3115, 0.7806, 0.4296, 0.7935]}, {"w": "solver=\"cholesky\")", "b": [0.438, 0.7806, 0.5898, 0.7935]}, {"w": ">>>", "b": [0.1766, 0.7961, 0.2019, 0.8089]}, {"w": "ridge_reg.fit(X,", "b": [0.2103, 0.7961, 0.3452, 0.8089]}, {"w": "y)", "b": [0.3537, 0.7961, 0.3705, 0.8089]}]}, {"id": "b_9", "type": "paragraph", "text": "138 | Chapter 4: Training Models", "words": [{"w": "138", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 165, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "14 Alternatively you can use the Ridge class with the \"sag\" solver. Stochastic Average GD is a variant of SGD. For more details, see the presentation “Minimizing Finite Sums with the Stochastic Average Gradient Algo‐ rithm” by Mark Schmidt et al. from the University of British Columbia.", "words": [{"w": "14", "b": [0.1385, 0.8462, 0.1518, 0.8604]}, {"w": "Alternatively", "b": [0.1587, 0.8447, 0.241, 0.861]}, {"w": "you", "b": [0.2446, 0.8447, 0.2684, 0.861]}, {"w": "can", "b": [0.272, 0.8447, 0.2944, 0.861]}, {"w": "use", "b": [0.298, 0.8447, 0.319, 0.861]}, {"w": "the", "b": [0.3226, 0.8447, 0.3427, 0.861]}, {"w": "Ridge", "b": [0.3463, 0.8471, 0.384, 0.8586]}, {"w": "class", "b": [0.3876, 0.8447, 0.4169, 0.861]}, {"w": "with", "b": [0.4205, 0.8447, 0.449, 0.861]}, {"w": "the", "b": [0.4526, 0.8447, 0.4727, 0.861]}, {"w": "\"sag\"", "b": [0.4763, 0.8471, 0.514, 0.8586]}, {"w": "solver.", "b": [0.5176, 0.8447, 0.5581, 0.861]}, {"w": "Stochastic", "b": [0.5617, 0.8447, 0.626, 0.861]}, {"w": "Average", "b": [0.6296, 0.8447, 0.6806, 0.861]}, {"w": "GD", "b": [0.6842, 0.8447, 0.7072, 0.861]}, {"w": "is", "b": [0.7108, 0.8447, 0.7209, 0.861]}, {"w": "a", "b": [0.7245, 0.8447, 0.7315, 0.861]}, {"w": "variant", "b": [0.7351, 0.8447, 0.7797, 0.861]}, {"w": "of", "b": [0.7833, 0.8447, 0.7961, 0.861]}, {"w": "SGD.", "b": [0.7997, 0.8447, 0.8333, 0.861]}, {"w": "For", "b": [0.1587, 0.8598, 0.1808, 0.8761]}, {"w": "more", "b": [0.1844, 0.8598, 0.2181, 0.8761]}, {"w": "details,", "b": [0.2217, 0.8598, 0.2664, 0.8761]}, {"w": "see", "b": [0.27, 0.8598, 0.2893, 0.8761]}, {"w": "the", "b": [0.2929, 0.8598, 0.313, 0.8761]}, {"w": "presentation", "b": [0.3166, 0.8598, 0.3959, 0.8761]}, {"w": "“Minimizing", "b": [0.3995, 0.8598, 0.481, 0.8761]}, {"w": "Finite", "b": [0.4846, 0.8598, 0.5218, 0.8761]}, {"w": "Sums", "b": [0.5254, 0.8598, 0.5602, 0.8761]}, {"w": "with", "b": [0.5638, 0.8598, 0.5922, 0.8761]}, {"w": "the", "b": [0.5958, 0.8598, 0.6159, 0.8761]}, {"w": "Stochastic", "b": [0.6195, 0.8598, 0.6837, 0.8761]}, {"w": "Average", "b": [0.6873, 0.8598, 0.7384, 0.8761]}, {"w": "Gradient", "b": [0.742, 0.8598, 0.7988, 0.8761]}, {"w": "Algo‐", "b": [0.8024, 0.8598, 0.8386, 0.8761]}, {"w": "rithm”", "b": [0.1587, 0.8749, 0.2003, 0.8912]}, {"w": "by", "b": [0.2039, 0.8749, 0.2192, 0.8912]}, {"w": "Mark", "b": [0.2228, 0.8749, 0.2574, 0.8912]}, {"w": "Schmidt", "b": [0.261, 0.8749, 0.3142, 0.8912]}, {"w": "et", "b": [0.3178, 0.8749, 0.3294, 0.8912]}, {"w": "al.", "b": [0.333, 0.8749, 0.3476, 0.8912]}, {"w": "from", "b": [0.3512, 0.8749, 0.3829, 0.8912]}, {"w": "the", "b": [0.3865, 0.8749, 0.4066, 0.8912]}, {"w": "University", "b": [0.4102, 0.8749, 0.4763, 0.8912]}, {"w": "of", "b": [0.4799, 0.8749, 0.4927, 0.8912]}, {"w": "British", "b": [0.4963, 0.8749, 0.5392, 0.8912]}, {"w": "Columbia.", "b": [0.5428, 0.8749, 0.6098, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": ">>> ridge_reg.predict([[1.5]]) array([[1.55071465]])", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "ridge_reg.predict([[1.5]])", "b": [0.2103, 0.0829, 0.4296, 0.0958]}, {"w": "array([[1.55071465]])", "b": [0.1766, 0.0983, 0.3537, 0.1112]}]}, {"id": "b_2", "type": "paragraph", "text": "And using Stochastic Gradient Descent:14", "words": [{"w": "And", "b": [0.1429, 0.119, 0.1796, 0.1404]}, {"w": "using", "b": [0.1844, 0.119, 0.2298, 0.1404]}, {"w": "Stochastic", "b": [0.2345, 0.119, 0.3189, 0.1404]}, {"w": "Gradient", "b": [0.3236, 0.119, 0.3982, 0.1404]}, {"w": "Descent:14", "b": [0.4029, 0.119, 0.4859, 0.1404]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> sgd_reg = SGDRegressor(penalty=\"l2\") >>> sgd_reg.fit(X, y.ravel()) >>> sgd_reg.predict([[1.5]]) array([1.47012588])", "words": [{"w": ">>>", "b": [0.1766, 0.1509, 0.2019, 0.1638]}, {"w": "sgd_reg", "b": [0.2103, 0.1509, 0.2693, 0.1638]}, {"w": "=", "b": [0.2778, 0.1509, 0.2862, 0.1638]}, {"w": "SGDRegressor(penalty=\"l2\")", "b": [0.2946, 0.1509, 0.5139, 0.1638]}, {"w": ">>>", "b": [0.1766, 0.1664, 0.2019, 0.1792]}, {"w": "sgd_reg.fit(X,", "b": [0.2103, 0.1664, 0.3284, 0.1792]}, {"w": "y.ravel())", "b": [0.3368, 0.1664, 0.4211, 0.1792]}, {"w": ">>>", "b": [0.1766, 0.1818, 0.2019, 0.1946]}, {"w": "sgd_reg.predict([[1.5]])", "b": [0.2103, 0.1818, 0.4127, 0.1946]}, {"w": "array([1.47012588])", "b": [0.1766, 0.1972, 0.3368, 0.2101]}]}, {"id": "b_4", "type": "paragraph", "text": "The penalty hyperparameter sets the type of regularization term to use. Specifying \"l2\" indicates that you want SGD to add a regularization term to the cost function equal to half the square of the ℓ2 norm of the weight vector: this is simply Ridge Regression.", "words": [{"w": "The", "b": [0.1429, 0.2187, 0.1757, 0.2401]}, {"w": "penalty", "b": [0.1827, 0.2219, 0.2519, 0.237]}, {"w": "hyperparameter", "b": [0.2589, 0.2187, 0.3924, 0.2401]}, {"w": "sets", "b": [0.3994, 0.2187, 0.4299, 0.2401]}, {"w": "the", "b": [0.4368, 0.2187, 0.4632, 0.2401]}, {"w": "type", "b": [0.4701, 0.2187, 0.5058, 0.2401]}, {"w": "of", "b": [0.5128, 0.2187, 0.5296, 0.2401]}, {"w": "regularization", "b": [0.5366, 0.2187, 0.6531, 0.2401]}, {"w": "term", "b": [0.6601, 0.2187, 0.7001, 0.2401]}, {"w": "to", "b": [0.7071, 0.2187, 0.7241, 0.2401]}, {"w": "use.", "b": [0.731, 0.2187, 0.7633, 0.2401]}, {"w": "Specifying", "b": [0.7703, 0.2187, 0.8572, 0.2401]}, {"w": "\"l2\"", "b": [0.1429, 0.2419, 0.1824, 0.2569]}, {"w": "indicates", "b": [0.1887, 0.2387, 0.2627, 0.2601]}, {"w": "that", "b": [0.269, 0.2387, 0.3015, 0.2601]}, {"w": "you", "b": [0.3078, 0.2387, 0.3391, 0.2601]}, {"w": "want", "b": [0.3453, 0.2387, 0.3861, 0.2601]}, {"w": "SGD", "b": [0.3924, 0.2387, 0.4324, 0.2601]}, {"w": "to", "b": [0.4387, 0.2387, 0.4557, 0.2601]}, {"w": "add", "b": [0.462, 0.2387, 0.4931, 0.2601]}, {"w": "a", "b": [0.4994, 0.2387, 0.5085, 0.2601]}, {"w": "regularization", "b": [0.5148, 0.2387, 0.6314, 0.2601]}, {"w": "term", "b": [0.6376, 0.2387, 0.6776, 0.2601]}, {"w": "to", "b": [0.6839, 0.2387, 0.7009, 0.2601]}, {"w": "the", "b": [0.7072, 0.2387, 0.7335, 0.2601]}, {"w": "cost", "b": [0.7398, 0.2387, 0.7732, 0.2601]}, {"w": "function", "b": [0.7795, 0.2387, 0.8509, 0.2601]}, {"w": "equal", "b": [0.1429, 0.2577, 0.1878, 0.2791]}, {"w": "to", "b": [0.196, 0.2577, 0.213, 0.2791]}, {"w": "half", "b": [0.2212, 0.2577, 0.2529, 0.2791]}, {"w": "the", "b": [0.2611, 0.2577, 0.2874, 0.2791]}, {"w": "square", "b": [0.2956, 0.2577, 0.3507, 0.2791]}, {"w": "of", "b": [0.3589, 0.2577, 0.3757, 0.2791]}, {"w": "the", "b": [0.3839, 0.2577, 0.4102, 0.2791]}, {"w": "ℓ2", "b": [0.4184, 0.2577, 0.433, 0.28]}, {"w": "norm", "b": [0.4412, 0.2577, 0.488, 0.2791]}, {"w": "of", "b": [0.4962, 0.2577, 0.5129, 0.2791]}, {"w": "the", "b": [0.5211, 0.2577, 0.5475, 0.2791]}, {"w": "weight", "b": [0.5557, 0.2577, 0.6112, 0.2791]}, {"w": "vector:", "b": [0.6194, 0.2577, 0.6767, 0.2791]}, {"w": "this", "b": [0.6849, 0.2577, 0.7156, 0.2791]}, {"w": "is", "b": [0.7238, 0.2577, 0.737, 0.2791]}, {"w": "simply", "b": [0.7452, 0.2577, 0.8008, 0.2791]}, {"w": "Ridge", "b": [0.809, 0.2577, 0.8571, 0.2791]}, {"w": "Regression.", "b": [0.1429, 0.2768, 0.2386, 0.2982]}]}, {"id": "b_5", "type": "paragraph", "text": "Lasso Regression", "words": [{"w": "Lasso", "b": [0.1429, 0.311, 0.1987, 0.3395]}, {"w": "Regression", "b": [0.2037, 0.311, 0.3161, 0.3395]}]}, {"id": "b_6", "type": "paragraph", "text": "Least Absolute Shrinkage and Selection Operator Regression (simply called Lasso Regression) is another regularized version of Linear Regression: just like Ridge Regression, it adds a regularization term to the cost function, but it uses the ℓ1 norm of the weight vector instead of half the square of the ℓ2 norm (see Equation 4-10).", "words": [{"w": "Least", "b": [0.1429, 0.3452, 0.1856, 0.3668]}, {"w": "Absolute", "b": [0.197, 0.3452, 0.2678, 0.3668]}, {"w": "Shrinkage", "b": [0.2792, 0.3452, 0.3598, 0.3668]}, {"w": "and", "b": [0.3712, 0.3452, 0.4026, 0.3668]}, {"w": "Selection", "b": [0.414, 0.3452, 0.4857, 0.3668]}, {"w": "Operator", "b": [0.4971, 0.3452, 0.5707, 0.3668]}, {"w": "Regression", "b": [0.5821, 0.3452, 0.6668, 0.3668]}, {"w": "(simply", "b": [0.6782, 0.3454, 0.741, 0.3668]}, {"w": "called", "b": [0.7524, 0.3454, 0.8007, 0.3668]}, {"w": "Lasso", "b": [0.8121, 0.3452, 0.8571, 0.3668]}, {"w": "Regression)", "b": [0.1429, 0.3643, 0.2348, 0.3859]}, {"w": "is", "b": [0.2462, 0.3645, 0.2594, 0.3859]}, {"w": "another", "b": [0.2708, 0.3645, 0.336, 0.3859]}, {"w": "regularized", "b": [0.3474, 0.3645, 0.4411, 0.3859]}, {"w": "version", "b": [0.4524, 0.3645, 0.5139, 0.3859]}, {"w": "of", "b": [0.5253, 0.3645, 0.5421, 0.3859]}, {"w": "Linear", "b": [0.5534, 0.3645, 0.6074, 0.3859]}, {"w": "Regression:", "b": [0.6187, 0.3645, 0.7145, 0.3859]}, {"w": "just", "b": [0.7259, 0.3645, 0.7563, 0.3859]}, {"w": "like", "b": [0.7676, 0.3645, 0.7977, 0.3859]}, {"w": "Ridge", "b": [0.809, 0.3645, 0.8572, 0.3859]}, {"w": "Regression,", "b": [0.1429, 0.3835, 0.2386, 0.4049]}, {"w": "it", "b": [0.2444, 0.3835, 0.2563, 0.4049]}, {"w": "adds", "b": [0.2621, 0.3835, 0.3009, 0.4049]}, {"w": "a", "b": [0.3066, 0.3835, 0.3158, 0.4049]}, {"w": "regularization", "b": [0.3215, 0.3835, 0.4381, 0.4049]}, {"w": "term", "b": [0.4439, 0.3835, 0.4839, 0.4049]}, {"w": "to", "b": [0.4896, 0.3835, 0.5066, 0.4049]}, {"w": "the", "b": [0.5123, 0.3835, 0.5387, 0.4049]}, {"w": "cost", "b": [0.5444, 0.3835, 0.5779, 0.4049]}, {"w": "function,", "b": [0.5836, 0.3835, 0.6598, 0.4049]}, {"w": "but", "b": [0.6655, 0.3835, 0.6935, 0.4049]}, {"w": "it", "b": [0.6993, 0.3835, 0.7112, 0.4049]}, {"w": "uses", "b": [0.717, 0.3835, 0.7522, 0.4049]}, {"w": "the", "b": [0.7579, 0.3835, 0.7843, 0.4049]}, {"w": "ℓ1", "b": [0.79, 0.3835, 0.8046, 0.4058]}, {"w": "norm", "b": [0.8103, 0.3835, 0.8571, 0.4049]}, {"w": "of", "b": [0.1429, 0.4026, 0.1596, 0.424]}, {"w": "the", "b": [0.1644, 0.4026, 0.1907, 0.424]}, {"w": "weight", "b": [0.1954, 0.4026, 0.251, 0.424]}, {"w": "vector", "b": [0.2557, 0.4026, 0.3077, 0.424]}, {"w": "instead", "b": [0.3125, 0.4026, 0.3724, 0.424]}, {"w": "of", "b": [0.3772, 0.4026, 0.394, 0.424]}, {"w": "half", "b": [0.3987, 0.4026, 0.4304, 0.424]}, {"w": "the", "b": [0.4351, 0.4026, 0.4615, 0.424]}, {"w": "square", "b": [0.4662, 0.4026, 0.5213, 0.424]}, {"w": "of", "b": [0.526, 0.4026, 0.5428, 0.424]}, {"w": "the", "b": [0.5475, 0.4026, 0.5739, 0.424]}, {"w": "ℓ2", "b": [0.5786, 0.4026, 0.5931, 0.4249]}, {"w": "norm", "b": [0.5979, 0.4026, 0.6447, 0.424]}, {"w": "(see", "b": [0.6494, 0.4026, 0.682, 0.424]}, {"w": "Equation", "b": [0.6867, 0.4026, 0.763, 0.424]}, {"w": "4-10).", "b": [0.7677, 0.4026, 0.8171, 0.424]}]}, {"id": "b_7", "type": "equation", "text": "Equation 4-10. Lasso Regression cost function", "words": [{"w": "Equation", "b": [0.1726, 0.4421, 0.2473, 0.4637]}, {"w": "4-10.", "b": [0.2521, 0.4421, 0.2937, 0.4637]}, {"w": "Lasso", "b": [0.2985, 0.4421, 0.3435, 0.4637]}, {"w": "Regression", "b": [0.3483, 0.4421, 0.433, 0.4637]}, {"w": "cost", "b": [0.4378, 0.4421, 0.4685, 0.4637]}, {"w": "function", "b": [0.4733, 0.4421, 0.5414, 0.4637]}]}, {"id": "b_8", "type": "equation", "text": "J θ = MSE θ + α∑i = 1", "words": [{"w": "J", "b": [0.1731, 0.4744, 0.1795, 0.495]}, {"w": "θ", "b": [0.1874, 0.4741, 0.1975, 0.495]}, {"w": "=", "b": [0.2098, 0.4746, 0.2213, 0.495]}, {"w": "MSE", "b": [0.2269, 0.4746, 0.2652, 0.495]}, {"w": "θ", "b": [0.2721, 0.4741, 0.2822, 0.495]}, {"w": "+", "b": [0.2935, 0.4746, 0.305, 0.495]}, {"w": "α∑i", "b": [0.3094, 0.4744, 0.336, 0.4993]}, {"w": "=", "b": [0.3405, 0.483, 0.3497, 0.4993]}, {"w": "1", "b": [0.3541, 0.483, 0.3617, 0.4993]}]}, {"id": "b_9", "type": "paragraph", "text": "n θi", "words": [{"w": "n", "b": [0.3317, 0.4707, 0.3402, 0.4872]}, {"w": "θi", "b": [0.3691, 0.4744, 0.3829, 0.4993]}]}, {"id": "b_10", "type": "paragraph", "text": "Figure 4-18 shows the same thing as Figure 4-17 but replaces Ridge models with Lasso models and uses smaller α values.", "words": [{"w": "Figure", "b": [0.1429, 0.5183, 0.1969, 0.5397]}, {"w": "4-18", "b": [0.2052, 0.5183, 0.2427, 0.5397]}, {"w": "shows", "b": [0.251, 0.5183, 0.3024, 0.5397]}, {"w": "the", "b": [0.3107, 0.5183, 0.3371, 0.5397]}, {"w": "same", "b": [0.3455, 0.5183, 0.3882, 0.5397]}, {"w": "thing", "b": [0.3965, 0.5183, 0.4408, 0.5397]}, {"w": "as", "b": [0.4491, 0.5183, 0.4659, 0.5397]}, {"w": "Figure", "b": [0.4743, 0.5183, 0.5283, 0.5397]}, {"w": "4-17", "b": [0.5367, 0.5183, 0.5741, 0.5397]}, {"w": "but", "b": [0.5825, 0.5183, 0.6105, 0.5397]}, {"w": "replaces", "b": [0.6189, 0.5183, 0.6861, 0.5397]}, {"w": "Ridge", "b": [0.6945, 0.5183, 0.7426, 0.5397]}, {"w": "models", "b": [0.751, 0.5183, 0.8114, 0.5397]}, {"w": "with", "b": [0.8198, 0.5183, 0.8572, 0.5397]}, {"w": "Lasso", "b": [0.1429, 0.5374, 0.1891, 0.5588]}, {"w": "models", "b": [0.1939, 0.5374, 0.2543, 0.5588]}, {"w": "and", "b": [0.2591, 0.5374, 0.2906, 0.5588]}, {"w": "uses", "b": [0.2953, 0.5374, 0.3305, 0.5588]}, {"w": "smaller", "b": [0.3353, 0.5374, 0.3962, 0.5588]}, {"w": "α", "b": [0.401, 0.5372, 0.4121, 0.5588]}, {"w": "values.", "b": [0.4168, 0.5374, 0.4732, 0.5588]}]}, {"id": "b_11", "type": "paragraph", "text": "Regularized Linear Models | 139", "words": [{"w": "Regularized", "b": [0.6409, 0.9225, 0.711, 0.9388]}, {"w": "Linear", "b": [0.7138, 0.9225, 0.7507, 0.9388]}, {"w": "Models", "b": [0.7536, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "139", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 166, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 4-18. Lasso Regression", "words": [{"w": "Figure", "b": [0.1429, 0.347, 0.1943, 0.3686]}, {"w": "4-18.", "b": [0.1991, 0.347, 0.2407, 0.3686]}, {"w": "Lasso", "b": [0.2455, 0.347, 0.2905, 0.3686]}, {"w": "Regression", "b": [0.2953, 0.347, 0.38, 0.3686]}]}, {"id": "b_1", "type": "paragraph", "text": "An important characteristic of Lasso Regression is that it tends to completely elimi‐ nate the weights of the least important features (i.e., set them to zero). For example, the dashed line in the right plot on Figure 4-18 (with α = 10-7) looks quadratic, almost linear: all the weights for the high-degree polynomial features are equal to zero. In other words, Lasso Regression automatically performs feature selection and outputs a sparse model (i.e., with few nonzero feature weights).", "words": [{"w": "An", "b": [0.1429, 0.3844, 0.1686, 0.4058]}, {"w": "important", "b": [0.1751, 0.3844, 0.2595, 0.4058]}, {"w": "characteristic", "b": [0.2659, 0.3844, 0.3776, 0.4058]}, {"w": "of", "b": [0.3841, 0.3844, 0.4009, 0.4058]}, {"w": "Lasso", "b": [0.4073, 0.3844, 0.4536, 0.4058]}, {"w": "Regression", "b": [0.46, 0.3844, 0.551, 0.4058]}, {"w": "is", "b": [0.5575, 0.3844, 0.5707, 0.4058]}, {"w": "that", "b": [0.5772, 0.3844, 0.6098, 0.4058]}, {"w": "it", "b": [0.6162, 0.3844, 0.6282, 0.4058]}, {"w": "tends", "b": [0.6346, 0.3844, 0.6799, 0.4058]}, {"w": "to", "b": [0.6863, 0.3844, 0.7033, 0.4058]}, {"w": "completely", "b": [0.7097, 0.3844, 0.8009, 0.4058]}, {"w": "elimi‐", "b": [0.8074, 0.3844, 0.8571, 0.4058]}, {"w": "nate", "b": [0.1429, 0.4035, 0.1782, 0.4249]}, {"w": "the", "b": [0.1846, 0.4035, 0.2109, 0.4249]}, {"w": "weights", "b": [0.2172, 0.4035, 0.2804, 0.4249]}, {"w": "of", "b": [0.2868, 0.4035, 0.3036, 0.4249]}, {"w": "the", "b": [0.3099, 0.4035, 0.3363, 0.4249]}, {"w": "least", "b": [0.3426, 0.4035, 0.3799, 0.4249]}, {"w": "important", "b": [0.3862, 0.4035, 0.4706, 0.4249]}, {"w": "features", "b": [0.477, 0.4035, 0.5424, 0.4249]}, {"w": "(i.e.,", "b": [0.5487, 0.4035, 0.5846, 0.4249]}, {"w": "set", "b": [0.591, 0.4035, 0.6138, 0.4249]}, {"w": "them", "b": [0.6202, 0.4035, 0.6636, 0.4249]}, {"w": "to", "b": [0.6699, 0.4035, 0.6869, 0.4249]}, {"w": "zero).", "b": [0.6932, 0.4035, 0.7412, 0.4249]}, {"w": "For", "b": [0.7475, 0.4035, 0.7765, 0.4249]}, {"w": "example,", "b": [0.7828, 0.4035, 0.8571, 0.4249]}, {"w": "the", "b": [0.1429, 0.4225, 0.1692, 0.4439]}, {"w": "dashed", "b": [0.1741, 0.4225, 0.2329, 0.4439]}, {"w": "line", "b": [0.2377, 0.4225, 0.2688, 0.4439]}, {"w": "in", "b": [0.2737, 0.4225, 0.2907, 0.4439]}, {"w": "the", "b": [0.2956, 0.4225, 0.3219, 0.4439]}, {"w": "right", "b": [0.3268, 0.4225, 0.367, 0.4439]}, {"w": "plot", "b": [0.3718, 0.4225, 0.405, 0.4439]}, {"w": "on", "b": [0.4099, 0.4225, 0.4319, 0.4439]}, {"w": "Figure", "b": [0.4368, 0.4225, 0.4908, 0.4439]}, {"w": "4-18", "b": [0.4955, 0.4225, 0.5329, 0.4439]}, {"w": "(with", "b": [0.538, 0.4225, 0.5825, 0.4439]}, {"w": "α", "b": [0.5874, 0.4223, 0.5985, 0.4439]}, {"w": "=", "b": [0.6034, 0.4225, 0.6155, 0.4439]}, {"w": "10-7)", "b": [0.6202, 0.4225, 0.6581, 0.4439]}, {"w": "looks", "b": [0.6628, 0.4225, 0.7073, 0.4439]}, {"w": "quadratic,", "b": [0.712, 0.4225, 0.7958, 0.4439]}, {"w": "almost", "b": [0.8006, 0.4225, 0.8567, 0.4439]}, {"w": "linear:", "b": [0.1429, 0.4416, 0.1961, 0.463]}, {"w": "all", "b": [0.2033, 0.4416, 0.223, 0.463]}, {"w": "the", "b": [0.2302, 0.4416, 0.2565, 0.463]}, {"w": "weights", "b": [0.2638, 0.4416, 0.3269, 0.463]}, {"w": "for", "b": [0.3342, 0.4416, 0.3587, 0.463]}, {"w": "the", "b": [0.3659, 0.4416, 0.3922, 0.463]}, {"w": "high-degree", "b": [0.3994, 0.4416, 0.4995, 0.463]}, {"w": "polynomial", "b": [0.5067, 0.4416, 0.6022, 0.463]}, {"w": "features", "b": [0.6094, 0.4416, 0.6748, 0.463]}, {"w": "are", "b": [0.682, 0.4416, 0.7077, 0.463]}, {"w": "equal", "b": [0.7149, 0.4416, 0.7599, 0.463]}, {"w": "to", "b": [0.7671, 0.4416, 0.7841, 0.463]}, {"w": "zero.", "b": [0.7913, 0.4416, 0.8314, 0.463]}, {"w": "In", "b": [0.8387, 0.4416, 0.8572, 0.463]}, {"w": "other", "b": [0.1429, 0.4606, 0.1875, 0.482]}, {"w": "words,", "b": [0.1927, 0.4606, 0.2487, 0.482]}, {"w": "Lasso", "b": [0.2538, 0.4606, 0.3001, 0.482]}, {"w": "Regression", "b": [0.3052, 0.4606, 0.3962, 0.482]}, {"w": "automatically", "b": [0.4013, 0.4606, 0.5139, 0.482]}, {"w": "performs", "b": [0.519, 0.4606, 0.5957, 0.482]}, {"w": "feature", "b": [0.6008, 0.4606, 0.6586, 0.482]}, {"w": "selection", "b": [0.6637, 0.4606, 0.7371, 0.482]}, {"w": "and", "b": [0.7422, 0.4606, 0.7738, 0.482]}, {"w": "outputs", "b": [0.7789, 0.4606, 0.8429, 0.482]}, {"w": "a", "b": [0.848, 0.4606, 0.8571, 0.482]}, {"w": "sparse", "b": [0.1429, 0.4794, 0.1926, 0.5011]}, {"w": "model", "b": [0.1973, 0.4794, 0.247, 0.5011]}, {"w": "(i.e.,", "b": [0.2517, 0.4796, 0.2876, 0.5011]}, {"w": "with", "b": [0.2923, 0.4796, 0.3297, 0.5011]}, {"w": "few", "b": [0.3344, 0.4796, 0.3637, 0.5011]}, {"w": "nonzero", "b": [0.3684, 0.4796, 0.4378, 0.5011]}, {"w": "feature", "b": [0.4425, 0.4796, 0.5003, 0.5011]}, {"w": "weights).", "b": [0.505, 0.4796, 0.5802, 0.5011]}]}, {"id": "b_2", "type": "paragraph", "text": "You can get a sense of why this is the case by looking at Figure 4-19: on the top-left plot, the background contours (ellipses) represent an unregularized MSE cost func‐ tion (α = 0), and the white circles show the Batch Gradient Descent path with that cost function. The foreground contours (diamonds) represent the ℓ1 penalty, and the triangles show the BGD path for this penalty only (α → ∞). Notice how the path first reaches θ1 = 0, then rolls down a gutter until it reaches θ2 = 0. On the top-right plot, the contours represent the same cost function plus an ℓ1 penalty with α = 0.5. The global minimum is on the θ2 = 0 axis. BGD first reaches θ2 = 0, then rolls down the gutter until it reaches the global minimum. The two bottom plots show the same thing but uses an ℓ2 penalty instead. The regularized minimum is closer to θ = 0 than the unregularized minimum, but the weights do not get fully eliminated.", "words": [{"w": "You", "b": [0.1429, 0.5078, 0.1752, 0.5292]}, {"w": "can", "b": [0.1815, 0.5078, 0.2108, 0.5292]}, {"w": "get", "b": [0.2171, 0.5078, 0.2421, 0.5292]}, {"w": "a", "b": [0.2483, 0.5078, 0.2575, 0.5292]}, {"w": "sense", "b": [0.2637, 0.5078, 0.3081, 0.5292]}, {"w": "of", "b": [0.3144, 0.5078, 0.3312, 0.5292]}, {"w": "why", "b": [0.3374, 0.5078, 0.3719, 0.5292]}, {"w": "this", "b": [0.3782, 0.5078, 0.4089, 0.5292]}, {"w": "is", "b": [0.4152, 0.5078, 0.4284, 0.5292]}, {"w": "the", "b": [0.4347, 0.5078, 0.461, 0.5292]}, {"w": "case", "b": [0.4673, 0.5078, 0.5017, 0.5292]}, {"w": "by", "b": [0.508, 0.5078, 0.5281, 0.5292]}, {"w": "looking", "b": [0.5344, 0.5078, 0.598, 0.5292]}, {"w": "at", "b": [0.6042, 0.5078, 0.6193, 0.5292]}, {"w": "Figure", "b": [0.6256, 0.5078, 0.6796, 0.5292]}, {"w": "4-19:", "b": [0.6859, 0.5078, 0.728, 0.5292]}, {"w": "on", "b": [0.7343, 0.5078, 0.7563, 0.5292]}, {"w": "the", "b": [0.7626, 0.5078, 0.7889, 0.5292]}, {"w": "top-left", "b": [0.7952, 0.5078, 0.8571, 0.5292]}, {"w": "plot,", "b": [0.1428, 0.5268, 0.1808, 0.5482]}, {"w": "the", "b": [0.1876, 0.5268, 0.2139, 0.5482]}, {"w": "background", "b": [0.2207, 0.5268, 0.3211, 0.5482]}, {"w": "contours", "b": [0.328, 0.5268, 0.4018, 0.5482]}, {"w": "(ellipses)", "b": [0.4086, 0.5268, 0.4831, 0.5482]}, {"w": "represent", "b": [0.4899, 0.5268, 0.5678, 0.5482]}, {"w": "an", "b": [0.5746, 0.5268, 0.5952, 0.5482]}, {"w": "unregularized", "b": [0.602, 0.5268, 0.7182, 0.5482]}, {"w": "MSE", "b": [0.725, 0.5268, 0.7652, 0.5482]}, {"w": "cost", "b": [0.772, 0.5268, 0.8055, 0.5482]}, {"w": "func‐", "b": [0.8123, 0.5268, 0.8571, 0.5482]}, {"w": "tion", "b": [0.1429, 0.5459, 0.1768, 0.5673]}, {"w": "(α", "b": [0.1839, 0.5457, 0.2022, 0.5673]}, {"w": "=", "b": [0.2092, 0.5459, 0.2213, 0.5673]}, {"w": "0),", "b": [0.2283, 0.5459, 0.2503, 0.5673]}, {"w": "and", "b": [0.2573, 0.5459, 0.2889, 0.5673]}, {"w": "the", "b": [0.2959, 0.5459, 0.3222, 0.5673]}, {"w": "white", "b": [0.3293, 0.5459, 0.3754, 0.5673]}, {"w": "circles", "b": [0.3825, 0.5459, 0.4352, 0.5673]}, {"w": "show", "b": [0.4422, 0.5459, 0.4859, 0.5673]}, {"w": "the", "b": [0.4929, 0.5459, 0.5192, 0.5673]}, {"w": "Batch", "b": [0.5263, 0.5459, 0.5736, 0.5673]}, {"w": "Gradient", "b": [0.5806, 0.5459, 0.6551, 0.5673]}, {"w": "Descent", "b": [0.6622, 0.5459, 0.729, 0.5673]}, {"w": "path", "b": [0.736, 0.5459, 0.7732, 0.5673]}, {"w": "with", "b": [0.7802, 0.5459, 0.8175, 0.5673]}, {"w": "that", "b": [0.8246, 0.5459, 0.8572, 0.5673]}, {"w": "cost", "b": [0.1429, 0.5649, 0.1763, 0.5863]}, {"w": "function.", "b": [0.1821, 0.5649, 0.2582, 0.5863]}, {"w": "The", "b": [0.264, 0.5649, 0.2969, 0.5863]}, {"w": "foreground", "b": [0.3027, 0.5649, 0.3976, 0.5863]}, {"w": "contours", "b": [0.4034, 0.5649, 0.4773, 0.5863]}, {"w": "(diamonds)", "b": [0.4831, 0.5649, 0.5809, 0.5863]}, {"w": "represent", "b": [0.5867, 0.5649, 0.6647, 0.5863]}, {"w": "the", "b": [0.6705, 0.5649, 0.6968, 0.5863]}, {"w": "ℓ1", "b": [0.7026, 0.5649, 0.7172, 0.5872]}, {"w": "penalty,", "b": [0.7229, 0.5649, 0.7877, 0.5863]}, {"w": "and", "b": [0.7935, 0.5649, 0.825, 0.5863]}, {"w": "the", "b": [0.8308, 0.5649, 0.8571, 0.5863]}, {"w": "triangles", "b": [0.1429, 0.584, 0.2146, 0.6054]}, {"w": "show", "b": [0.22, 0.584, 0.2636, 0.6054]}, {"w": "the", "b": [0.269, 0.584, 0.2954, 0.6054]}, {"w": "BGD", "b": [0.3008, 0.584, 0.3437, 0.6054]}, {"w": "path", "b": [0.3491, 0.584, 0.3862, 0.6054]}, {"w": "for", "b": [0.3916, 0.584, 0.4161, 0.6054]}, {"w": "this", "b": [0.4215, 0.584, 0.4522, 0.6054]}, {"w": "penalty", "b": [0.4576, 0.584, 0.5191, 0.6054]}, {"w": "only", "b": [0.5245, 0.584, 0.5614, 0.6054]}, {"w": "(α", "b": [0.5668, 0.5837, 0.5851, 0.6054]}, {"w": "→", "b": [0.5905, 0.584, 0.6088, 0.6054]}, {"w": "∞).", "b": [0.6142, 0.584, 0.642, 0.6054]}, {"w": "Notice", "b": [0.6474, 0.584, 0.7026, 0.6054]}, {"w": "how", "b": [0.708, 0.584, 0.744, 0.6054]}, {"w": "the", "b": [0.7494, 0.584, 0.7757, 0.6054]}, {"w": "path", "b": [0.7811, 0.584, 0.8183, 0.6054]}, {"w": "first", "b": [0.8237, 0.584, 0.8572, 0.6054]}, {"w": "reaches", "b": [0.1429, 0.603, 0.205, 0.6244]}, {"w": "θ1", "b": [0.2109, 0.6028, 0.2268, 0.6253]}, {"w": "=", "b": [0.2327, 0.603, 0.2448, 0.6244]}, {"w": "0,", "b": [0.2507, 0.603, 0.2654, 0.6244]}, {"w": "then", "b": [0.2713, 0.603, 0.309, 0.6244]}, {"w": "rolls", "b": [0.3149, 0.603, 0.3514, 0.6244]}, {"w": "down", "b": [0.3573, 0.603, 0.4046, 0.6244]}, {"w": "a", "b": [0.4105, 0.603, 0.4196, 0.6244]}, {"w": "gutter", "b": [0.4255, 0.603, 0.4756, 0.6244]}, {"w": "until", "b": [0.4815, 0.603, 0.5207, 0.6244]}, {"w": "it", "b": [0.5266, 0.603, 0.5386, 0.6244]}, {"w": "reaches", "b": [0.5444, 0.603, 0.6066, 0.6244]}, {"w": "θ2", "b": [0.6125, 0.6028, 0.6284, 0.6253]}, {"w": "=", "b": [0.6343, 0.603, 0.6464, 0.6244]}, {"w": "0.", "b": [0.6522, 0.603, 0.667, 0.6244]}, {"w": "On", "b": [0.6729, 0.603, 0.6998, 0.6244]}, {"w": "the", "b": [0.7057, 0.603, 0.732, 0.6244]}, {"w": "top-right", "b": [0.7379, 0.603, 0.8134, 0.6244]}, {"w": "plot,", "b": [0.8192, 0.603, 0.8572, 0.6244]}, {"w": "the", "b": [0.1429, 0.622, 0.1692, 0.6435]}, {"w": "contours", "b": [0.1764, 0.622, 0.2502, 0.6435]}, {"w": "represent", "b": [0.2574, 0.622, 0.3354, 0.6435]}, {"w": "the", "b": [0.3426, 0.622, 0.3689, 0.6435]}, {"w": "same", "b": [0.3761, 0.622, 0.4188, 0.6435]}, {"w": "cost", "b": [0.426, 0.622, 0.4594, 0.6435]}, {"w": "function", "b": [0.4666, 0.622, 0.538, 0.6435]}, {"w": "plus", "b": [0.5452, 0.622, 0.5801, 0.6435]}, {"w": "an", "b": [0.5873, 0.622, 0.6078, 0.6435]}, {"w": "ℓ1", "b": [0.615, 0.622, 0.6296, 0.6444]}, {"w": "penalty", "b": [0.6368, 0.622, 0.6983, 0.6435]}, {"w": "with", "b": [0.7055, 0.622, 0.7428, 0.6435]}, {"w": "α", "b": [0.75, 0.6218, 0.7611, 0.6435]}, {"w": "=", "b": [0.7683, 0.622, 0.7804, 0.6435]}, {"w": "0.5.", "b": [0.7876, 0.622, 0.8171, 0.6435]}, {"w": "The", "b": [0.8243, 0.622, 0.8571, 0.6435]}, {"w": "global", "b": [0.1429, 0.6411, 0.1935, 0.6625]}, {"w": "minimum", "b": [0.1998, 0.6411, 0.2842, 0.6625]}, {"w": "is", "b": [0.2905, 0.6411, 0.3038, 0.6625]}, {"w": "on", "b": [0.3101, 0.6411, 0.3321, 0.6625]}, {"w": "the", "b": [0.3384, 0.6411, 0.3647, 0.6625]}, {"w": "θ2", "b": [0.371, 0.6409, 0.387, 0.6634]}, {"w": "=", "b": [0.3933, 0.6411, 0.4054, 0.6625]}, {"w": "0", "b": [0.4117, 0.6411, 0.4217, 0.6625]}, {"w": "axis.", "b": [0.428, 0.6411, 0.4649, 0.6625]}, {"w": "BGD", "b": [0.4712, 0.6411, 0.5141, 0.6625]}, {"w": "first", "b": [0.5204, 0.6411, 0.5539, 0.6625]}, {"w": "reaches", "b": [0.5602, 0.6411, 0.6224, 0.6625]}, {"w": "θ2", "b": [0.6287, 0.6409, 0.6446, 0.6634]}, {"w": "=", "b": [0.6509, 0.6411, 0.663, 0.6625]}, {"w": "0,", "b": [0.6693, 0.6411, 0.684, 0.6625]}, {"w": "then", "b": [0.6903, 0.6411, 0.7281, 0.6625]}, {"w": "rolls", "b": [0.7344, 0.6411, 0.7709, 0.6625]}, {"w": "down", "b": [0.7772, 0.6411, 0.8245, 0.6625]}, {"w": "the", "b": [0.8308, 0.6411, 0.8571, 0.6625]}, {"w": "gutter", "b": [0.1429, 0.6601, 0.193, 0.6816]}, {"w": "until", "b": [0.2011, 0.6601, 0.2403, 0.6816]}, {"w": "it", "b": [0.2485, 0.6601, 0.2604, 0.6816]}, {"w": "reaches", "b": [0.2685, 0.6601, 0.3307, 0.6816]}, {"w": "the", "b": [0.3388, 0.6601, 0.3651, 0.6816]}, {"w": "global", "b": [0.3732, 0.6601, 0.4239, 0.6816]}, {"w": "minimum.", "b": [0.432, 0.6601, 0.5212, 0.6816]}, {"w": "The", "b": [0.5293, 0.6601, 0.5621, 0.6816]}, {"w": "two", "b": [0.5702, 0.6601, 0.6015, 0.6816]}, {"w": "bottom", "b": [0.6096, 0.6601, 0.6712, 0.6816]}, {"w": "plots", "b": [0.6793, 0.6601, 0.7201, 0.6816]}, {"w": "show", "b": [0.7282, 0.6601, 0.7719, 0.6816]}, {"w": "the", "b": [0.78, 0.6601, 0.8063, 0.6816]}, {"w": "same", "b": [0.8144, 0.6601, 0.8571, 0.6816]}, {"w": "thing", "b": [0.1429, 0.6792, 0.1871, 0.7006]}, {"w": "but", "b": [0.1923, 0.6792, 0.2203, 0.7006]}, {"w": "uses", "b": [0.2256, 0.6792, 0.2608, 0.7006]}, {"w": "an", "b": [0.2661, 0.6792, 0.2866, 0.7006]}, {"w": "ℓ2", "b": [0.2919, 0.6792, 0.3065, 0.7015]}, {"w": "penalty", "b": [0.3117, 0.6792, 0.3732, 0.7006]}, {"w": "instead.", "b": [0.3785, 0.6792, 0.4432, 0.7006]}, {"w": "The", "b": [0.4485, 0.6792, 0.4813, 0.7006]}, {"w": "regularized", "b": [0.4866, 0.6792, 0.5803, 0.7006]}, {"w": "minimum", "b": [0.5856, 0.6792, 0.67, 0.7006]}, {"w": "is", "b": [0.6753, 0.6792, 0.6885, 0.7006]}, {"w": "closer", "b": [0.6938, 0.6792, 0.7427, 0.7006]}, {"w": "to", "b": [0.748, 0.6792, 0.765, 0.7006]}, {"w": "θ", "b": [0.7702, 0.6786, 0.7808, 0.7006]}, {"w": "=", "b": [0.7861, 0.6792, 0.7982, 0.7006]}, {"w": "0", "b": [0.8034, 0.6786, 0.8138, 0.7006]}, {"w": "than", "b": [0.8191, 0.6792, 0.8571, 0.7006]}, {"w": "the", "b": [0.1428, 0.6982, 0.1692, 0.7197]}, {"w": "unregularized", "b": [0.1739, 0.6982, 0.2901, 0.7197]}, {"w": "minimum,", "b": [0.2948, 0.6982, 0.384, 0.7197]}, {"w": "but", "b": [0.3887, 0.6982, 0.4167, 0.7197]}, {"w": "the", "b": [0.4215, 0.6982, 0.4478, 0.7197]}, {"w": "weights", "b": [0.4525, 0.6982, 0.5157, 0.7197]}, {"w": "do", "b": [0.5204, 0.6982, 0.5421, 0.7197]}, {"w": "not", "b": [0.5468, 0.6982, 0.5752, 0.7197]}, {"w": "get", "b": [0.5799, 0.6982, 0.6048, 0.7197]}, {"w": "fully", "b": [0.6096, 0.6982, 0.6469, 0.7197]}, {"w": "eliminated.", "b": [0.6516, 0.6982, 0.7451, 0.7197]}]}, {"id": "b_3", "type": "paragraph", "text": "140 | Chapter 4: Training Models", "words": [{"w": "140", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 167, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "15 You can think of a subgradient vector at a nondifferentiable point as an intermediate vector between the gra‐ dient vectors around that point.", "words": [{"w": "15", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "You", "b": [0.1587, 0.8598, 0.1834, 0.8761]}, {"w": "can", "b": [0.187, 0.8598, 0.2093, 0.8761]}, {"w": "think", "b": [0.213, 0.8598, 0.2471, 0.8761]}, {"w": "of", "b": [0.2507, 0.8598, 0.2635, 0.8761]}, {"w": "a", "b": [0.2671, 0.8598, 0.274, 0.8761]}, {"w": "subgradient", "b": [0.2777, 0.8598, 0.3529, 0.8761]}, {"w": "vector", "b": [0.3565, 0.8598, 0.3961, 0.8761]}, {"w": "at", "b": [0.3997, 0.8598, 0.4112, 0.8761]}, {"w": "a", "b": [0.4148, 0.8598, 0.4218, 0.8761]}, {"w": "nondifferentiable", "b": [0.4254, 0.8598, 0.5355, 0.8761]}, {"w": "point", "b": [0.5391, 0.8598, 0.573, 0.8761]}, {"w": "as", "b": [0.5766, 0.8598, 0.5894, 0.8761]}, {"w": "an", "b": [0.593, 0.8598, 0.6087, 0.8761]}, {"w": "intermediate", "b": [0.6123, 0.8598, 0.693, 0.8761]}, {"w": "vector", "b": [0.6966, 0.8598, 0.7363, 0.8761]}, {"w": "between", "b": [0.7399, 0.8598, 0.7926, 0.8761]}, {"w": "the", "b": [0.7962, 0.8598, 0.8162, 0.8761]}, {"w": "gra‐", "b": [0.8198, 0.8598, 0.8458, 0.8761]}, {"w": "dient", "b": [0.1587, 0.8749, 0.1913, 0.8912]}, {"w": "vectors", "b": [0.1949, 0.8749, 0.2404, 0.8912]}, {"w": "around", "b": [0.244, 0.8749, 0.2904, 0.8912]}, {"w": "that", "b": [0.294, 0.8749, 0.3189, 0.8912]}, {"w": "point.", "b": [0.3225, 0.8749, 0.36, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 4-19. Lasso versus Ridge regularization", "words": [{"w": "Figure", "b": [0.1429, 0.4421, 0.1943, 0.4637]}, {"w": "4-19.", "b": [0.1991, 0.4421, 0.2407, 0.4637]}, {"w": "Lasso", "b": [0.2455, 0.4421, 0.2905, 0.4637]}, {"w": "versus", "b": [0.2953, 0.4421, 0.3454, 0.4637]}, {"w": "Ridge", "b": [0.3502, 0.4421, 0.3955, 0.4637]}, {"w": "regularization", "b": [0.4002, 0.4421, 0.515, 0.4637]}]}, {"id": "b_2", "type": "paragraph", "text": "On the Lasso cost function, the BGD path tends to bounce across the gutter toward the end. This is because the slope changes abruptly at θ2 = 0. You need to gradually reduce the learning rate in order to actually converge to the global minimum.", "words": [{"w": "On", "b": [0.2714, 0.4843, 0.296, 0.5038]}, {"w": "the", "b": [0.302, 0.4843, 0.3261, 0.5038]}, {"w": "Lasso", "b": [0.3321, 0.4843, 0.3744, 0.5038]}, {"w": "cost", "b": [0.3803, 0.4843, 0.4109, 0.5038]}, {"w": "function,", "b": [0.4169, 0.4843, 0.4865, 0.5038]}, {"w": "the", "b": [0.4925, 0.4843, 0.5166, 0.5038]}, {"w": "BGD", "b": [0.5225, 0.4843, 0.5617, 0.5038]}, {"w": "path", "b": [0.5677, 0.4843, 0.6017, 0.5038]}, {"w": "tends", "b": [0.6076, 0.4843, 0.649, 0.5038]}, {"w": "to", "b": [0.655, 0.4843, 0.6705, 0.5038]}, {"w": "bounce", "b": [0.6765, 0.4843, 0.7326, 0.5038]}, {"w": "across", "b": [0.7385, 0.4843, 0.7857, 0.5038]}, {"w": "the", "b": [0.2714, 0.5017, 0.2955, 0.5213]}, {"w": "gutter", "b": [0.3058, 0.5017, 0.3516, 0.5213]}, {"w": "toward", "b": [0.362, 0.5017, 0.4161, 0.5213]}, {"w": "the", "b": [0.4264, 0.5017, 0.4505, 0.5213]}, {"w": "end.", "b": [0.4608, 0.5017, 0.4938, 0.5213]}, {"w": "This", "b": [0.5041, 0.5017, 0.5381, 0.5213]}, {"w": "is", "b": [0.5485, 0.5017, 0.5606, 0.5213]}, {"w": "because", "b": [0.5709, 0.5017, 0.63, 0.5213]}, {"w": "the", "b": [0.6403, 0.5017, 0.6644, 0.5213]}, {"w": "slope", "b": [0.6747, 0.5017, 0.7143, 0.5213]}, {"w": "changes", "b": [0.7247, 0.5017, 0.7857, 0.5213]}, {"w": "abruptly", "b": [0.2714, 0.5191, 0.336, 0.5387]}, {"w": "at", "b": [0.3403, 0.5191, 0.3541, 0.5387]}, {"w": "θ2", "b": [0.359, 0.5189, 0.3741, 0.5398]}, {"w": "=", "b": [0.3787, 0.5191, 0.3898, 0.5387]}, {"w": "0.", "b": [0.3944, 0.5191, 0.4079, 0.5387]}, {"w": "You", "b": [0.4125, 0.5191, 0.4421, 0.5387]}, {"w": "need", "b": [0.4467, 0.5191, 0.4833, 0.5387]}, {"w": "to", "b": [0.488, 0.5191, 0.5035, 0.5387]}, {"w": "gradually", "b": [0.5081, 0.5191, 0.5794, 0.5387]}, {"w": "reduce", "b": [0.584, 0.5191, 0.6355, 0.5387]}, {"w": "the", "b": [0.6401, 0.5191, 0.6642, 0.5387]}, {"w": "learning", "b": [0.6688, 0.5191, 0.732, 0.5387]}, {"w": "rate", "b": [0.7366, 0.5191, 0.7656, 0.5387]}, {"w": "in", "b": [0.7702, 0.5191, 0.7857, 0.5387]}, {"w": "order", "b": [0.2714, 0.5365, 0.3134, 0.5561]}, {"w": "to", "b": [0.3177, 0.5365, 0.3332, 0.5561]}, {"w": "actually", "b": [0.3376, 0.5365, 0.3967, 0.5561]}, {"w": "converge", "b": [0.401, 0.5365, 0.4697, 0.5561]}, {"w": "to", "b": [0.474, 0.5365, 0.4896, 0.5561]}, {"w": "the", "b": [0.4939, 0.5365, 0.518, 0.5561]}, {"w": "global", "b": [0.5223, 0.5365, 0.5686, 0.5561]}, {"w": "minimum.", "b": [0.5729, 0.5365, 0.6544, 0.5561]}]}, {"id": "b_3", "type": "paragraph", "text": "The Lasso cost function is not differentiable at θi = 0 (for i = 1, 2, ⋯, n), but Gradient Descent still works fine if you use a subgradient vector g15 instead when any θi = 0. Equation 4-11 shows a subgradient vector equation you can use for Gradient Descent with the Lasso cost function.", "words": [{"w": "The", "b": [0.1429, 0.5829, 0.1757, 0.6043]}, {"w": "Lasso", "b": [0.1808, 0.5829, 0.2271, 0.6043]}, {"w": "cost", "b": [0.2322, 0.5829, 0.2656, 0.6043]}, {"w": "function", "b": [0.2707, 0.5829, 0.3421, 0.6043]}, {"w": "is", "b": [0.3472, 0.5829, 0.3604, 0.6043]}, {"w": "not", "b": [0.3655, 0.5829, 0.3939, 0.6043]}, {"w": "differentiable", "b": [0.399, 0.5829, 0.5101, 0.6043]}, {"w": "at", "b": [0.5152, 0.5829, 0.5303, 0.6043]}, {"w": "θi", "b": [0.5354, 0.5827, 0.5488, 0.6052]}, {"w": "=", "b": [0.5539, 0.5829, 0.566, 0.6043]}, {"w": "0", "b": [0.5711, 0.5829, 0.5811, 0.6043]}, {"w": "(for", "b": [0.5862, 0.5829, 0.6179, 0.6043]}, {"w": "i", "b": [0.623, 0.5827, 0.6287, 0.6043]}, {"w": "=", "b": [0.6338, 0.5829, 0.6459, 0.6043]}, {"w": "1,", "b": [0.651, 0.5829, 0.6657, 0.6043]}, {"w": "2,", "b": [0.6708, 0.5829, 0.6856, 0.6043]}, {"w": "⋯,", "b": [0.6907, 0.5829, 0.7163, 0.6043]}, {"w": "n),", "b": [0.7213, 0.5827, 0.7444, 0.6043]}, {"w": "but", "b": [0.7495, 0.5829, 0.7775, 0.6043]}, {"w": "Gradient", "b": [0.7826, 0.5829, 0.8571, 0.6043]}, {"w": "Descent", "b": [0.1429, 0.602, 0.2097, 0.6234]}, {"w": "still", "b": [0.2168, 0.602, 0.2469, 0.6234]}, {"w": "works", "b": [0.254, 0.602, 0.3047, 0.6234]}, {"w": "fine", "b": [0.3118, 0.602, 0.3438, 0.6234]}, {"w": "if", "b": [0.3509, 0.602, 0.3626, 0.6234]}, {"w": "you", "b": [0.3697, 0.602, 0.401, 0.6234]}, {"w": "use", "b": [0.4081, 0.602, 0.4357, 0.6234]}, {"w": "a", "b": [0.4428, 0.602, 0.4519, 0.6234]}, {"w": "subgradient", "b": [0.459, 0.6017, 0.5542, 0.6234]}, {"w": "vector", "b": [0.5614, 0.6017, 0.6103, 0.6234]}, {"w": "g15", "b": [0.6174, 0.6014, 0.639, 0.6234]}, {"w": "instead", "b": [0.6461, 0.602, 0.7061, 0.6234]}, {"w": "when", "b": [0.7132, 0.602, 0.7589, 0.6234]}, {"w": "any", "b": [0.766, 0.602, 0.7956, 0.6234]}, {"w": "θi", "b": [0.8027, 0.6017, 0.8161, 0.6243]}, {"w": "=", "b": [0.8232, 0.602, 0.8353, 0.6234]}, {"w": "0.", "b": [0.8424, 0.602, 0.8571, 0.6234]}, {"w": "Equation", "b": [0.1429, 0.621, 0.2191, 0.6424]}, {"w": "4-11", "b": [0.2238, 0.621, 0.2613, 0.6424]}, {"w": "shows", "b": [0.2669, 0.621, 0.3182, 0.6424]}, {"w": "a", "b": [0.3234, 0.621, 0.3325, 0.6424]}, {"w": "subgradient", "b": [0.3377, 0.621, 0.4364, 0.6424]}, {"w": "vector", "b": [0.4416, 0.621, 0.4936, 0.6424]}, {"w": "equation", "b": [0.4987, 0.621, 0.572, 0.6424]}, {"w": "you", "b": [0.5772, 0.621, 0.6084, 0.6424]}, {"w": "can", "b": [0.6136, 0.621, 0.643, 0.6424]}, {"w": "use", "b": [0.6481, 0.621, 0.6757, 0.6424]}, {"w": "for", "b": [0.6809, 0.621, 0.7054, 0.6424]}, {"w": "Gradient", "b": [0.7106, 0.621, 0.7851, 0.6424]}, {"w": "Descent", "b": [0.7903, 0.621, 0.8571, 0.6424]}, {"w": "with", "b": [0.1428, 0.6401, 0.1802, 0.6615]}, {"w": "the", "b": [0.1849, 0.6401, 0.2112, 0.6615]}, {"w": "Lasso", "b": [0.216, 0.6401, 0.2622, 0.6615]}, {"w": "cost", "b": [0.267, 0.6401, 0.3004, 0.6615]}, {"w": "function.", "b": [0.3051, 0.6401, 0.3813, 0.6615]}]}, {"id": "b_4", "type": "equation", "text": "Equation 4-11. Lasso Regression subgradient vector", "words": [{"w": "Equation", "b": [0.1726, 0.6796, 0.2473, 0.7012]}, {"w": "4-11.", "b": [0.2521, 0.6796, 0.2937, 0.7012]}, {"w": "Lasso", "b": [0.2985, 0.6796, 0.3435, 0.7012]}, {"w": "Regression", "b": [0.3483, 0.6796, 0.433, 0.7012]}, {"w": "subgradient", "b": [0.4378, 0.6796, 0.533, 0.7012]}, {"w": "vector", "b": [0.5378, 0.6796, 0.5866, 0.7012]}]}, {"id": "b_5", "type": "equation", "text": "g θ, J = ∇θ MSE θ + α", "words": [{"w": "g", "b": [0.1735, 0.7487, 0.1818, 0.7693]}, {"w": "θ,", "b": [0.1897, 0.7484, 0.2043, 0.7693]}, {"w": "J", "b": [0.2082, 0.7487, 0.2145, 0.7693]}, {"w": "=", "b": [0.2279, 0.7489, 0.2394, 0.7693]}, {"w": "∇θ", "b": [0.2471, 0.752, 0.2716, 0.7727]}, {"w": "MSE", "b": [0.2747, 0.7489, 0.3131, 0.7693]}, {"w": "θ", "b": [0.3199, 0.7484, 0.33, 0.7693]}, {"w": "+", "b": [0.3413, 0.7489, 0.3528, 0.7693]}, {"w": "α", "b": [0.3572, 0.7487, 0.3678, 0.7693]}]}, {"id": "b_6", "type": "paragraph", "text": "sign θ1 sign θ2", "words": [{"w": "sign", "b": [0.3751, 0.7088, 0.4078, 0.7292]}, {"w": "θ1", "b": [0.4202, 0.7086, 0.4373, 0.7335]}, {"w": "sign", "b": [0.3751, 0.7363, 0.4078, 0.7567]}, {"w": "θ2", "b": [0.4202, 0.7361, 0.4373, 0.761]}]}, {"id": "b_7", "type": "paragraph", "text": "⋮ sign θn", "words": [{"w": "⋮", "b": [0.4063, 0.7665, 0.4129, 0.7816]}, {"w": "sign", "b": [0.3747, 0.7857, 0.4074, 0.8061]}, {"w": "θn", "b": [0.4198, 0.7855, 0.4377, 0.8104]}]}, {"id": "b_8", "type": "equation", "text": "where sign θi =", "words": [{"w": "where", "b": [0.4715, 0.7489, 0.5199, 0.7693]}, {"w": "sign", "b": [0.5299, 0.7489, 0.5626, 0.7693]}, {"w": "θi", "b": [0.575, 0.7487, 0.5888, 0.7736]}, {"w": "=", "b": [0.6012, 0.7489, 0.6127, 0.7693]}]}, {"id": "b_9", "type": "paragraph", "text": "−1 if θi < 0", "words": [{"w": "−1", "b": [0.6251, 0.7203, 0.6472, 0.7407]}, {"w": "if", "b": [0.6562, 0.7203, 0.6674, 0.7407]}, {"w": "θi", "b": [0.6719, 0.7202, 0.6857, 0.745]}, {"w": "<", "b": [0.6912, 0.7203, 0.7022, 0.7407]}, {"w": "0", "b": [0.7077, 0.7203, 0.7172, 0.7407]}]}, {"id": "b_10", "type": "equation", "text": "0 if θi = 0", "words": [{"w": "0", "b": [0.6314, 0.7466, 0.6409, 0.767]}, {"w": "if", "b": [0.6559, 0.7466, 0.6671, 0.767]}, {"w": "θi", "b": [0.6716, 0.7464, 0.6854, 0.7713]}, {"w": "=", "b": [0.6909, 0.7466, 0.7024, 0.767]}, {"w": "0", "b": [0.7079, 0.7466, 0.7175, 0.767]}]}, {"id": "b_11", "type": "equation", "text": "+1 if θi > 0", "words": [{"w": "+1", "b": [0.6251, 0.7729, 0.6472, 0.7933]}, {"w": "if", "b": [0.6562, 0.7729, 0.6674, 0.7933]}, {"w": "θi", "b": [0.6719, 0.7727, 0.6857, 0.7976]}, {"w": ">", "b": [0.6912, 0.7729, 0.7022, 0.7933]}, {"w": "0", "b": [0.7077, 0.7729, 0.7172, 0.7933]}]}, {"id": "b_12", "type": "paragraph", "text": "Regularized Linear Models | 141", "words": [{"w": "Regularized", "b": [0.6409, 0.9225, 0.711, 0.9388]}, {"w": "Linear", "b": [0.7138, 0.9225, 0.7507, 0.9388]}, {"w": "Models", "b": [0.7536, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "141", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 168, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Here is a small Scikit-Learn example using the Lasso class. Note that you could instead use an SGDRegressor(penalty=\"l1\").", "words": [{"w": "Here", "b": [0.1429, 0.08, 0.1837, 0.1014]}, {"w": "is", "b": [0.1929, 0.08, 0.2061, 0.1014]}, {"w": "a", "b": [0.2153, 0.08, 0.2244, 0.1014]}, {"w": "small", "b": [0.2335, 0.08, 0.2779, 0.1014]}, {"w": "Scikit-Learn", "b": [0.2871, 0.08, 0.3894, 0.1014]}, {"w": "example", "b": [0.3985, 0.08, 0.4681, 0.1014]}, {"w": "using", "b": [0.4772, 0.08, 0.5226, 0.1014]}, {"w": "the", "b": [0.5318, 0.08, 0.5581, 0.1014]}, {"w": "Lasso", "b": [0.5673, 0.0831, 0.6167, 0.0982]}, {"w": "class.", "b": [0.6259, 0.08, 0.6692, 0.1014]}, {"w": "Note", "b": [0.6783, 0.08, 0.7191, 0.1014]}, {"w": "that", "b": [0.7282, 0.08, 0.7608, 0.1014]}, {"w": "you", "b": [0.77, 0.08, 0.8012, 0.1014]}, {"w": "could", "b": [0.8104, 0.08, 0.8571, 0.1014]}, {"w": "instead", "b": [0.1429, 0.0999, 0.2028, 0.1213]}, {"w": "use", "b": [0.2076, 0.0999, 0.2351, 0.1213]}, {"w": "an", "b": [0.2399, 0.0999, 0.2604, 0.1213]}, {"w": "SGDRegressor(penalty=\"l1\").", "b": [0.2651, 0.0999, 0.5272, 0.1213]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> from sklearn.linear_model import Lasso >>> lasso_reg = Lasso(alpha=0.1) >>> lasso_reg.fit(X, y) >>> lasso_reg.predict([[1.5]]) array([1.53788174])", "words": [{"w": ">>>", "b": [0.1766, 0.1319, 0.2019, 0.1447]}, {"w": "from", "b": [0.2103, 0.1319, 0.244, 0.1447]}, {"w": "sklearn.linear_model", "b": [0.2525, 0.1319, 0.4211, 0.1447]}, {"w": "import", "b": [0.4296, 0.1319, 0.4802, 0.1447]}, {"w": "Lasso", "b": [0.4886, 0.1319, 0.5308, 0.1447]}, {"w": ">>>", "b": [0.1766, 0.1473, 0.2019, 0.1601]}, {"w": "lasso_reg", "b": [0.2103, 0.1473, 0.2862, 0.1601]}, {"w": "=", "b": [0.2946, 0.1473, 0.3031, 0.1601]}, {"w": "Lasso(alpha=0.1)", "b": [0.3115, 0.1473, 0.4464, 0.1601]}, {"w": ">>>", "b": [0.1766, 0.1627, 0.2019, 0.1756]}, {"w": "lasso_reg.fit(X,", "b": [0.2103, 0.1627, 0.3452, 0.1756]}, {"w": "y)", "b": [0.3537, 0.1627, 0.3705, 0.1756]}, {"w": ">>>", "b": [0.1766, 0.1781, 0.2019, 0.191]}, {"w": "lasso_reg.predict([[1.5]])", "b": [0.2103, 0.1781, 0.4296, 0.191]}, {"w": "array([1.53788174])", "b": [0.1766, 0.1936, 0.3368, 0.2064]}]}, {"id": "b_2", "type": "paragraph", "text": "Elastic Net", "words": [{"w": "Elastic", "b": [0.1428, 0.2203, 0.2084, 0.2488]}, {"w": "Net", "b": [0.2133, 0.2203, 0.25, 0.2488]}]}, {"id": "b_3", "type": "paragraph", "text": "Elastic Net is a middle ground between Ridge Regression and Lasso Regression. The regularization term is a simple mix of both Ridge and Lasso’s regularization terms, and you can control the mix ratio r. When r = 0, Elastic Net is equivalent to Ridge Regression, and when r = 1, it is equivalent to Lasso Regression (see Equation 4-12).", "words": [{"w": "Elastic", "b": [0.1429, 0.2547, 0.1975, 0.2761]}, {"w": "Net", "b": [0.2035, 0.2547, 0.2337, 0.2761]}, {"w": "is", "b": [0.2397, 0.2547, 0.2529, 0.2761]}, {"w": "a", "b": [0.2589, 0.2547, 0.2681, 0.2761]}, {"w": "middle", "b": [0.2741, 0.2547, 0.3328, 0.2761]}, {"w": "ground", "b": [0.3388, 0.2547, 0.4004, 0.2761]}, {"w": "between", "b": [0.4064, 0.2547, 0.4756, 0.2761]}, {"w": "Ridge", "b": [0.4816, 0.2547, 0.5297, 0.2761]}, {"w": "Regression", "b": [0.5357, 0.2547, 0.6267, 0.2761]}, {"w": "and", "b": [0.6327, 0.2547, 0.6643, 0.2761]}, {"w": "Lasso", "b": [0.6703, 0.2547, 0.7165, 0.2761]}, {"w": "Regression.", "b": [0.7225, 0.2547, 0.8183, 0.2761]}, {"w": "The", "b": [0.8243, 0.2547, 0.8571, 0.2761]}, {"w": "regularization", "b": [0.1429, 0.2738, 0.2594, 0.2952]}, {"w": "term", "b": [0.2668, 0.2738, 0.3068, 0.2952]}, {"w": "is", "b": [0.3142, 0.2738, 0.3275, 0.2952]}, {"w": "a", "b": [0.3349, 0.2738, 0.344, 0.2952]}, {"w": "simple", "b": [0.3514, 0.2738, 0.4063, 0.2952]}, {"w": "mix", "b": [0.4137, 0.2738, 0.4462, 0.2952]}, {"w": "of", "b": [0.4536, 0.2738, 0.4704, 0.2952]}, {"w": "both", "b": [0.4778, 0.2738, 0.5165, 0.2952]}, {"w": "Ridge", "b": [0.5239, 0.2738, 0.572, 0.2952]}, {"w": "and", "b": [0.5794, 0.2738, 0.6109, 0.2952]}, {"w": "Lasso’s", "b": [0.6183, 0.2738, 0.6734, 0.2952]}, {"w": "regularization", "b": [0.6808, 0.2738, 0.7974, 0.2952]}, {"w": "terms,", "b": [0.8047, 0.2738, 0.8571, 0.2952]}, {"w": "and", "b": [0.1429, 0.2928, 0.1744, 0.3142]}, {"w": "you", "b": [0.1812, 0.2928, 0.2125, 0.3142]}, {"w": "can", "b": [0.2193, 0.2928, 0.2486, 0.3142]}, {"w": "control", "b": [0.2554, 0.2928, 0.3159, 0.3142]}, {"w": "the", "b": [0.3227, 0.2928, 0.349, 0.3142]}, {"w": "mix", "b": [0.3558, 0.2928, 0.3883, 0.3142]}, {"w": "ratio", "b": [0.3951, 0.2928, 0.4342, 0.3142]}, {"w": "r.", "b": [0.441, 0.2926, 0.4534, 0.3142]}, {"w": "When", "b": [0.4602, 0.2928, 0.5118, 0.3142]}, {"w": "r", "b": [0.5186, 0.2926, 0.5262, 0.3142]}, {"w": "=", "b": [0.533, 0.2928, 0.5451, 0.3142]}, {"w": "0,", "b": [0.5519, 0.2928, 0.5667, 0.3142]}, {"w": "Elastic", "b": [0.5735, 0.2928, 0.6281, 0.3142]}, {"w": "Net", "b": [0.635, 0.2928, 0.6651, 0.3142]}, {"w": "is", "b": [0.6719, 0.2928, 0.6852, 0.3142]}, {"w": "equivalent", "b": [0.692, 0.2928, 0.7784, 0.3142]}, {"w": "to", "b": [0.7852, 0.2928, 0.8022, 0.3142]}, {"w": "Ridge", "b": [0.809, 0.2928, 0.8571, 0.3142]}, {"w": "Regression,", "b": [0.1429, 0.3119, 0.2386, 0.3333]}, {"w": "and", "b": [0.2434, 0.3119, 0.2749, 0.3333]}, {"w": "when", "b": [0.2796, 0.3119, 0.3253, 0.3333]}, {"w": "r", "b": [0.33, 0.3117, 0.3376, 0.3333]}, {"w": "=", "b": [0.3424, 0.3119, 0.3544, 0.3333]}, {"w": "1,", "b": [0.3592, 0.3119, 0.3739, 0.3333]}, {"w": "it", "b": [0.3787, 0.3119, 0.3906, 0.3333]}, {"w": "is", "b": [0.3953, 0.3119, 0.4086, 0.3333]}, {"w": "equivalent", "b": [0.4133, 0.3119, 0.4997, 0.3333]}, {"w": "to", "b": [0.5044, 0.3119, 0.5214, 0.3333]}, {"w": "Lasso", "b": [0.5261, 0.3119, 0.5724, 0.3333]}, {"w": "Regression", "b": [0.5771, 0.3119, 0.6682, 0.3333]}, {"w": "(see", "b": [0.6729, 0.3119, 0.7054, 0.3333]}, {"w": "Equation", "b": [0.7102, 0.3119, 0.7864, 0.3333]}, {"w": "4-12).", "b": [0.7912, 0.3119, 0.8405, 0.3333]}]}, {"id": "b_4", "type": "equation", "text": "Equation 4-12. Elastic Net cost function", "words": [{"w": "Equation", "b": [0.1726, 0.3514, 0.2473, 0.373]}, {"w": "4-12.", "b": [0.2521, 0.3514, 0.2937, 0.373]}, {"w": "Elastic", "b": [0.2985, 0.3514, 0.352, 0.373]}, {"w": "Net", "b": [0.3567, 0.3514, 0.3854, 0.373]}, {"w": "cost", "b": [0.3902, 0.3514, 0.4209, 0.373]}, {"w": "function", "b": [0.4256, 0.3514, 0.4937, 0.373]}]}, {"id": "b_5", "type": "equation", "text": "J θ = MSE θ + rα∑i = 1", "words": [{"w": "J", "b": [0.1731, 0.385, 0.1795, 0.4056]}, {"w": "θ", "b": [0.1874, 0.3846, 0.1975, 0.4056]}, {"w": "=", "b": [0.2098, 0.3852, 0.2213, 0.4056]}, {"w": "MSE", "b": [0.2269, 0.3852, 0.2652, 0.4056]}, {"w": "θ", "b": [0.2721, 0.3846, 0.2822, 0.4056]}, {"w": "+", "b": [0.2935, 0.3852, 0.305, 0.4056]}, {"w": "rα∑i", "b": [0.3094, 0.385, 0.3437, 0.4098]}, {"w": "=", "b": [0.3481, 0.3935, 0.3573, 0.4098]}, {"w": "1", "b": [0.3617, 0.3935, 0.3693, 0.4098]}]}, {"id": "b_6", "type": "equation", "text": "n θi + 1 −r", "words": [{"w": "n", "b": [0.3393, 0.3813, 0.3478, 0.3977]}, {"w": "θi", "b": [0.3768, 0.385, 0.3906, 0.4098]}, {"w": "+", "b": [0.4002, 0.3852, 0.4117, 0.4056]}, {"w": "1", "b": [0.4183, 0.3802, 0.4259, 0.3965]}, {"w": "−r", "b": [0.4295, 0.38, 0.448, 0.3965]}]}, {"id": "b_7", "type": "equation", "text": "2 α∑i = 1 n θi", "words": [{"w": "2", "b": [0.4295, 0.3948, 0.4371, 0.4111]}, {"w": "α∑i", "b": [0.4505, 0.385, 0.4772, 0.4098]}, {"w": "=", "b": [0.4816, 0.3935, 0.4908, 0.4098]}, {"w": "1", "b": [0.4952, 0.3935, 0.5028, 0.4098]}, {"w": "n", "b": [0.4729, 0.3813, 0.4813, 0.3977]}, {"w": "θi", "b": [0.505, 0.385, 0.5188, 0.4098]}]}, {"id": "b_9", "type": "paragraph", "text": "So when should you use plain Linear Regression (i.e., without any regularization), Ridge, Lasso, or Elastic Net? It is almost always preferable to have at least a little bit of regularization, so generally you should avoid plain Linear Regression. Ridge is a good default, but if you suspect that only a few features are actually useful, you should pre‐ fer Lasso or Elastic Net since they tend to reduce the useless features’ weights down to zero as we have discussed. In general, Elastic Net is preferred over Lasso since Lasso may behave erratically when the number of features is greater than the number of training instances or when several features are strongly correlated.", "words": [{"w": "So", "b": [0.1429, 0.4301, 0.1634, 0.4516]}, {"w": "when", "b": [0.1712, 0.4301, 0.2168, 0.4516]}, {"w": "should", "b": [0.2246, 0.4301, 0.2813, 0.4516]}, {"w": "you", "b": [0.2892, 0.4301, 0.3204, 0.4516]}, {"w": "use", "b": [0.3282, 0.4301, 0.3558, 0.4516]}, {"w": "plain", "b": [0.3636, 0.4301, 0.4059, 0.4516]}, {"w": "Linear", "b": [0.4137, 0.4301, 0.4676, 0.4516]}, {"w": "Regression", "b": [0.4754, 0.4301, 0.5665, 0.4516]}, {"w": "(i.e.,", "b": [0.5743, 0.4301, 0.6102, 0.4516]}, {"w": "without", "b": [0.618, 0.4301, 0.6834, 0.4516]}, {"w": "any", "b": [0.6912, 0.4301, 0.7208, 0.4516]}, {"w": "regularization),", "b": [0.7286, 0.4301, 0.8571, 0.4516]}, {"w": "Ridge,", "b": [0.1428, 0.4492, 0.1957, 0.4706]}, {"w": "Lasso,", "b": [0.2007, 0.4492, 0.2512, 0.4706]}, {"w": "or", "b": [0.2562, 0.4492, 0.2745, 0.4706]}, {"w": "Elastic", "b": [0.2795, 0.4492, 0.3342, 0.4706]}, {"w": "Net?", "b": [0.3392, 0.4492, 0.3773, 0.4706]}, {"w": "It", "b": [0.3823, 0.4492, 0.3949, 0.4706]}, {"w": "is", "b": [0.3999, 0.4492, 0.4132, 0.4706]}, {"w": "almost", "b": [0.4182, 0.4492, 0.4743, 0.4706]}, {"w": "always", "b": [0.4793, 0.4492, 0.534, 0.4706]}, {"w": "preferable", "b": [0.539, 0.4492, 0.6231, 0.4706]}, {"w": "to", "b": [0.6281, 0.4492, 0.6451, 0.4706]}, {"w": "have", "b": [0.6501, 0.4492, 0.6885, 0.4706]}, {"w": "at", "b": [0.6935, 0.4492, 0.7086, 0.4706]}, {"w": "least", "b": [0.7136, 0.4492, 0.7509, 0.4706]}, {"w": "a", "b": [0.7559, 0.4492, 0.7651, 0.4706]}, {"w": "little", "b": [0.7701, 0.4492, 0.8078, 0.4706]}, {"w": "bit", "b": [0.8128, 0.4492, 0.8353, 0.4706]}, {"w": "of", "b": [0.8403, 0.4492, 0.8571, 0.4706]}, {"w": "regularization,", "b": [0.1429, 0.4682, 0.2642, 0.4896]}, {"w": "so", "b": [0.2693, 0.4682, 0.2875, 0.4896]}, {"w": "generally", "b": [0.2926, 0.4682, 0.3684, 0.4896]}, {"w": "you", "b": [0.3735, 0.4682, 0.4047, 0.4896]}, {"w": "should", "b": [0.4098, 0.4682, 0.4665, 0.4896]}, {"w": "avoid", "b": [0.4716, 0.4682, 0.5172, 0.4896]}, {"w": "plain", "b": [0.5223, 0.4682, 0.5646, 0.4896]}, {"w": "Linear", "b": [0.5697, 0.4682, 0.6236, 0.4896]}, {"w": "Regression.", "b": [0.6286, 0.4682, 0.7244, 0.4896]}, {"w": "Ridge", "b": [0.7295, 0.4682, 0.7776, 0.4896]}, {"w": "is", "b": [0.7826, 0.4682, 0.7959, 0.4896]}, {"w": "a", "b": [0.8009, 0.4682, 0.8101, 0.4896]}, {"w": "good", "b": [0.8151, 0.4682, 0.8571, 0.4896]}, {"w": "default,", "b": [0.1429, 0.4873, 0.2051, 0.5087]}, {"w": "but", "b": [0.2103, 0.4873, 0.2383, 0.5087]}, {"w": "if", "b": [0.2435, 0.4873, 0.2553, 0.5087]}, {"w": "you", "b": [0.2605, 0.4873, 0.2918, 0.5087]}, {"w": "suspect", "b": [0.297, 0.4873, 0.3583, 0.5087]}, {"w": "that", "b": [0.3635, 0.4873, 0.3961, 0.5087]}, {"w": "only", "b": [0.4013, 0.4873, 0.4382, 0.5087]}, {"w": "a", "b": [0.4434, 0.4873, 0.4525, 0.5087]}, {"w": "few", "b": [0.4578, 0.4873, 0.4871, 0.5087]}, {"w": "features", "b": [0.4923, 0.4873, 0.5577, 0.5087]}, {"w": "are", "b": [0.5629, 0.4873, 0.5887, 0.5087]}, {"w": "actually", "b": [0.5939, 0.4873, 0.6585, 0.5087]}, {"w": "useful,", "b": [0.6637, 0.4873, 0.7186, 0.5087]}, {"w": "you", "b": [0.7238, 0.4873, 0.755, 0.5087]}, {"w": "should", "b": [0.7603, 0.4873, 0.817, 0.5087]}, {"w": "pre‐", "b": [0.8222, 0.4873, 0.8571, 0.5087]}, {"w": "fer", "b": [0.1429, 0.5063, 0.1656, 0.5277]}, {"w": "Lasso", "b": [0.1705, 0.5063, 0.2167, 0.5277]}, {"w": "or", "b": [0.2216, 0.5063, 0.24, 0.5277]}, {"w": "Elastic", "b": [0.2448, 0.5063, 0.2995, 0.5277]}, {"w": "Net", "b": [0.3043, 0.5063, 0.3345, 0.5277]}, {"w": "since", "b": [0.3394, 0.5063, 0.3817, 0.5277]}, {"w": "they", "b": [0.3865, 0.5063, 0.4224, 0.5277]}, {"w": "tend", "b": [0.4273, 0.5063, 0.4649, 0.5277]}, {"w": "to", "b": [0.4698, 0.5063, 0.4868, 0.5277]}, {"w": "reduce", "b": [0.4916, 0.5063, 0.5479, 0.5277]}, {"w": "the", "b": [0.5528, 0.5063, 0.5791, 0.5277]}, {"w": "useless", "b": [0.584, 0.5063, 0.641, 0.5277]}, {"w": "features’", "b": [0.6459, 0.5063, 0.7151, 0.5277]}, {"w": "weights", "b": [0.7199, 0.5063, 0.7831, 0.5277]}, {"w": "down", "b": [0.788, 0.5063, 0.8353, 0.5277]}, {"w": "to", "b": [0.8402, 0.5063, 0.8571, 0.5277]}, {"w": "zero", "b": [0.1429, 0.5254, 0.1788, 0.5468]}, {"w": "as", "b": [0.1848, 0.5254, 0.2016, 0.5468]}, {"w": "we", "b": [0.2076, 0.5254, 0.2308, 0.5468]}, {"w": "have", "b": [0.2368, 0.5254, 0.2752, 0.5468]}, {"w": "discussed.", "b": [0.2812, 0.5254, 0.3652, 0.5468]}, {"w": "In", "b": [0.3712, 0.5254, 0.3897, 0.5468]}, {"w": "general,", "b": [0.3957, 0.5254, 0.4615, 0.5468]}, {"w": "Elastic", "b": [0.4675, 0.5254, 0.5221, 0.5468]}, {"w": "Net", "b": [0.5281, 0.5254, 0.5583, 0.5468]}, {"w": "is", "b": [0.5643, 0.5254, 0.5776, 0.5468]}, {"w": "preferred", "b": [0.5836, 0.5254, 0.6614, 0.5468]}, {"w": "over", "b": [0.6674, 0.5254, 0.7043, 0.5468]}, {"w": "Lasso", "b": [0.7103, 0.5254, 0.7566, 0.5468]}, {"w": "since", "b": [0.7626, 0.5254, 0.8049, 0.5468]}, {"w": "Lasso", "b": [0.8109, 0.5254, 0.8572, 0.5468]}, {"w": "may", "b": [0.1429, 0.5444, 0.1783, 0.5658]}, {"w": "behave", "b": [0.1859, 0.5444, 0.2437, 0.5658]}, {"w": "erratically", "b": [0.2513, 0.5444, 0.3344, 0.5658]}, {"w": "when", "b": [0.342, 0.5444, 0.3876, 0.5658]}, {"w": "the", "b": [0.3952, 0.5444, 0.4215, 0.5658]}, {"w": "number", "b": [0.4291, 0.5444, 0.4954, 0.5658]}, {"w": "of", "b": [0.503, 0.5444, 0.5198, 0.5658]}, {"w": "features", "b": [0.5274, 0.5444, 0.5928, 0.5658]}, {"w": "is", "b": [0.6004, 0.5444, 0.6137, 0.5658]}, {"w": "greater", "b": [0.6213, 0.5444, 0.6793, 0.5658]}, {"w": "than", "b": [0.6869, 0.5444, 0.7249, 0.5658]}, {"w": "the", "b": [0.7325, 0.5444, 0.7589, 0.5658]}, {"w": "number", "b": [0.7665, 0.5444, 0.8328, 0.5658]}, {"w": "of", "b": [0.8404, 0.5444, 0.8571, 0.5658]}, {"w": "training", "b": [0.1429, 0.5635, 0.2098, 0.5849]}, {"w": "instances", "b": [0.2145, 0.5635, 0.2914, 0.5849]}, {"w": "or", "b": [0.2961, 0.5635, 0.3144, 0.5849]}, {"w": "when", "b": [0.3192, 0.5635, 0.3648, 0.5849]}, {"w": "several", "b": [0.3695, 0.5635, 0.4267, 0.5849]}, {"w": "features", "b": [0.4314, 0.5635, 0.4968, 0.5849]}, {"w": "are", "b": [0.5016, 0.5635, 0.5273, 0.5849]}, {"w": "strongly", "b": [0.532, 0.5635, 0.6004, 0.5849]}, {"w": "correlated.", "b": [0.6051, 0.5635, 0.6938, 0.5849]}]}, {"id": "b_10", "type": "paragraph", "text": "Here is a short example using Scikit-Learn’s ElasticNet (l1_ratio corresponds to the mix ratio r):", "words": [{"w": "Here", "b": [0.1429, 0.5925, 0.1837, 0.6139]}, {"w": "is", "b": [0.1914, 0.5925, 0.2046, 0.6139]}, {"w": "a", "b": [0.2122, 0.5925, 0.2214, 0.6139]}, {"w": "short", "b": [0.229, 0.5925, 0.2725, 0.6139]}, {"w": "example", "b": [0.2801, 0.5925, 0.3497, 0.6139]}, {"w": "using", "b": [0.3573, 0.5925, 0.4028, 0.6139]}, {"w": "Scikit-Learn’s", "b": [0.4104, 0.5925, 0.5213, 0.6139]}, {"w": "ElasticNet", "b": [0.5289, 0.5957, 0.6279, 0.6107]}, {"w": "(l1_ratio", "b": [0.6355, 0.5925, 0.7219, 0.6139]}, {"w": "corresponds", "b": [0.7295, 0.5925, 0.8325, 0.6139]}, {"w": "to", "b": [0.8402, 0.5925, 0.8571, 0.6139]}, {"w": "the", "b": [0.1428, 0.6115, 0.1692, 0.6329]}, {"w": "mix", "b": [0.1739, 0.6115, 0.2064, 0.6329]}, {"w": "ratio", "b": [0.2111, 0.6115, 0.2502, 0.6329]}, {"w": "r):", "b": [0.2549, 0.6113, 0.2745, 0.6329]}]}, {"id": "b_11", "type": "paragraph", "text": ">>> from sklearn.linear_model import ElasticNet >>> elastic_net = ElasticNet(alpha=0.1, l1_ratio=0.5) >>> elastic_net.fit(X, y) >>> elastic_net.predict([[1.5]]) array([1.54333232])", "words": [{"w": ">>>", "b": [0.1766, 0.6435, 0.2019, 0.6564]}, {"w": "from", "b": [0.2103, 0.6435, 0.244, 0.6564]}, {"w": "sklearn.linear_model", "b": [0.2525, 0.6435, 0.4211, 0.6564]}, {"w": "import", "b": [0.4296, 0.6435, 0.4802, 0.6564]}, {"w": "ElasticNet", "b": [0.4886, 0.6435, 0.5729, 0.6564]}, {"w": ">>>", "b": [0.1766, 0.6589, 0.2019, 0.6718]}, {"w": "elastic_net", "b": [0.2103, 0.6589, 0.3031, 0.6718]}, {"w": "=", "b": [0.3115, 0.6589, 0.3199, 0.6718]}, {"w": "ElasticNet(alpha=0.1,", "b": [0.3284, 0.6589, 0.5055, 0.6718]}, {"w": "l1_ratio=0.5)", "b": [0.5139, 0.6589, 0.6235, 0.6718]}, {"w": ">>>", "b": [0.1766, 0.6743, 0.2019, 0.6872]}, {"w": "elastic_net.fit(X,", "b": [0.2103, 0.6743, 0.3621, 0.6872]}, {"w": "y)", "b": [0.3705, 0.6743, 0.3874, 0.6872]}, {"w": ">>>", "b": [0.1766, 0.6898, 0.2019, 0.7026]}, {"w": "elastic_net.predict([[1.5]])", "b": [0.2103, 0.6898, 0.4464, 0.7026]}, {"w": "array([1.54333232])", "b": [0.1766, 0.7052, 0.3368, 0.718]}]}, {"id": "b_12", "type": "paragraph", "text": "Early Stopping", "words": [{"w": "Early", "b": [0.1429, 0.7319, 0.1937, 0.7604]}, {"w": "Stopping", "b": [0.1987, 0.7319, 0.2922, 0.7604]}]}, {"id": "b_13", "type": "paragraph", "text": "A very different way to regularize iterative learning algorithms such as Gradient Descent is to stop training as soon as the validation error reaches a minimum. This is called early stopping. Figure 4-20 shows a complex model (in this case a high-degree Polynomial Regression model) being trained using Batch Gradient Descent. As the epochs go by, the algorithm learns and its prediction error (RMSE) on the training set naturally goes down, and so does its prediction error on the validation set. However,", "words": [{"w": "A", "b": [0.1429, 0.7663, 0.1572, 0.7878]}, {"w": "very", "b": [0.1666, 0.7663, 0.2029, 0.7878]}, {"w": "different", "b": [0.2123, 0.7663, 0.284, 0.7878]}, {"w": "way", "b": [0.2933, 0.7663, 0.3259, 0.7878]}, {"w": "to", "b": [0.3352, 0.7663, 0.3522, 0.7878]}, {"w": "regularize", "b": [0.3615, 0.7663, 0.4442, 0.7878]}, {"w": "iterative", "b": [0.4535, 0.7663, 0.5212, 0.7878]}, {"w": "learning", "b": [0.5305, 0.7663, 0.5996, 0.7878]}, {"w": "algorithms", "b": [0.6089, 0.7663, 0.6992, 0.7878]}, {"w": "such", "b": [0.7085, 0.7663, 0.7472, 0.7878]}, {"w": "as", "b": [0.7565, 0.7663, 0.7733, 0.7878]}, {"w": "Gradient", "b": [0.7826, 0.7663, 0.8571, 0.7878]}, {"w": "Descent", "b": [0.1428, 0.7854, 0.2097, 0.8068]}, {"w": "is", "b": [0.2149, 0.7854, 0.2281, 0.8068]}, {"w": "to", "b": [0.2333, 0.7854, 0.2502, 0.8068]}, {"w": "stop", "b": [0.2554, 0.7854, 0.291, 0.8068]}, {"w": "training", "b": [0.2961, 0.7854, 0.3631, 0.8068]}, {"w": "as", "b": [0.3682, 0.7854, 0.385, 0.8068]}, {"w": "soon", "b": [0.3902, 0.7854, 0.4305, 0.8068]}, {"w": "as", "b": [0.4357, 0.7854, 0.4525, 0.8068]}, {"w": "the", "b": [0.4576, 0.7854, 0.484, 0.8068]}, {"w": "validation", "b": [0.4891, 0.7854, 0.5725, 0.8068]}, {"w": "error", "b": [0.5777, 0.7854, 0.6203, 0.8068]}, {"w": "reaches", "b": [0.6255, 0.7854, 0.6877, 0.8068]}, {"w": "a", "b": [0.6929, 0.7854, 0.702, 0.8068]}, {"w": "minimum.", "b": [0.7072, 0.7854, 0.7963, 0.8068]}, {"w": "This", "b": [0.8015, 0.7854, 0.8387, 0.8068]}, {"w": "is", "b": [0.8439, 0.7854, 0.8571, 0.8068]}, {"w": "called", "b": [0.1429, 0.8044, 0.1912, 0.8259]}, {"w": "early", "b": [0.1974, 0.8042, 0.237, 0.8259]}, {"w": "stopping.", "b": [0.2432, 0.8042, 0.3154, 0.8259]}, {"w": "Figure", "b": [0.3215, 0.8044, 0.3755, 0.8259]}, {"w": "4-20", "b": [0.3816, 0.8044, 0.4191, 0.8259]}, {"w": "shows", "b": [0.4252, 0.8044, 0.4765, 0.8259]}, {"w": "a", "b": [0.4827, 0.8044, 0.4918, 0.8259]}, {"w": "complex", "b": [0.498, 0.8044, 0.5689, 0.8259]}, {"w": "model", "b": [0.5751, 0.8044, 0.6279, 0.8259]}, {"w": "(in", "b": [0.634, 0.8044, 0.6582, 0.8259]}, {"w": "this", "b": [0.6644, 0.8044, 0.6951, 0.8259]}, {"w": "case", "b": [0.7012, 0.8044, 0.7357, 0.8259]}, {"w": "a", "b": [0.7418, 0.8044, 0.751, 0.8259]}, {"w": "high-degree", "b": [0.7571, 0.8044, 0.8571, 0.8259]}, {"w": "Polynomial", "b": [0.1429, 0.8235, 0.2385, 0.8449]}, {"w": "Regression", "b": [0.2459, 0.8235, 0.3369, 0.8449]}, {"w": "model)", "b": [0.3443, 0.8235, 0.4043, 0.8449]}, {"w": "being", "b": [0.4118, 0.8235, 0.4579, 0.8449]}, {"w": "trained", "b": [0.4653, 0.8235, 0.5254, 0.8449]}, {"w": "using", "b": [0.5328, 0.8235, 0.5782, 0.8449]}, {"w": "Batch", "b": [0.5857, 0.8235, 0.633, 0.8449]}, {"w": "Gradient", "b": [0.6404, 0.8235, 0.7149, 0.8449]}, {"w": "Descent.", "b": [0.7224, 0.8235, 0.7939, 0.8449]}, {"w": "As", "b": [0.8014, 0.8235, 0.8234, 0.8449]}, {"w": "the", "b": [0.8308, 0.8235, 0.8571, 0.8449]}, {"w": "epochs", "b": [0.1429, 0.8425, 0.2008, 0.864]}, {"w": "go", "b": [0.2056, 0.8425, 0.226, 0.864]}, {"w": "by,", "b": [0.2308, 0.8425, 0.2542, 0.864]}, {"w": "the", "b": [0.259, 0.8425, 0.2853, 0.864]}, {"w": "algorithm", "b": [0.2901, 0.8425, 0.3727, 0.864]}, {"w": "learns", "b": [0.3775, 0.8425, 0.4276, 0.864]}, {"w": "and", "b": [0.4324, 0.8425, 0.4639, 0.864]}, {"w": "its", "b": [0.4687, 0.8425, 0.4883, 0.864]}, {"w": "prediction", "b": [0.4931, 0.8425, 0.5799, 0.864]}, {"w": "error", "b": [0.5847, 0.8425, 0.6274, 0.864]}, {"w": "(RMSE)", "b": [0.6322, 0.8425, 0.6998, 0.864]}, {"w": "on", "b": [0.7046, 0.8425, 0.7266, 0.864]}, {"w": "the", "b": [0.7314, 0.8425, 0.7578, 0.864]}, {"w": "training", "b": [0.7626, 0.8425, 0.8295, 0.864]}, {"w": "set", "b": [0.8343, 0.8425, 0.8571, 0.864]}, {"w": "naturally", "b": [0.1429, 0.8616, 0.2174, 0.883]}, {"w": "goes", "b": [0.2232, 0.8616, 0.2601, 0.883]}, {"w": "down,", "b": [0.2659, 0.8616, 0.318, 0.883]}, {"w": "and", "b": [0.3238, 0.8616, 0.3553, 0.883]}, {"w": "so", "b": [0.3611, 0.8616, 0.3794, 0.883]}, {"w": "does", "b": [0.3852, 0.8616, 0.4233, 0.883]}, {"w": "its", "b": [0.4292, 0.8616, 0.4487, 0.883]}, {"w": "prediction", "b": [0.4546, 0.8616, 0.5414, 0.883]}, {"w": "error", "b": [0.5472, 0.8616, 0.5899, 0.883]}, {"w": "on", "b": [0.5957, 0.8616, 0.6177, 0.883]}, {"w": "the", "b": [0.6236, 0.8616, 0.6499, 0.883]}, {"w": "validation", "b": [0.6557, 0.8616, 0.7391, 0.883]}, {"w": "set.", "b": [0.7449, 0.8616, 0.7725, 0.883]}, {"w": "However,", "b": [0.7783, 0.8616, 0.8572, 0.883]}]}, {"id": "b_14", "type": "paragraph", "text": "142 | Chapter 4: Training Models", "words": [{"w": "142", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 169, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "after a while the validation error stops decreasing and actually starts to go back up. This indicates that the model has started to overfit the training data. With early stop‐ ping you just stop training as soon as the validation error reaches the minimum. It is such a simple and efficient regularization technique that Geoffrey Hinton called it a “beautiful free lunch.”", "words": [{"w": "after", "b": [0.1429, 0.0791, 0.1811, 0.1005]}, {"w": "a", "b": [0.1878, 0.0791, 0.197, 0.1005]}, {"w": "while", "b": [0.2037, 0.0791, 0.2488, 0.1005]}, {"w": "the", "b": [0.2555, 0.0791, 0.2818, 0.1005]}, {"w": "validation", "b": [0.2886, 0.0791, 0.3719, 0.1005]}, {"w": "error", "b": [0.3786, 0.0791, 0.4213, 0.1005]}, {"w": "stops", "b": [0.428, 0.0791, 0.4712, 0.1005]}, {"w": "decreasing", "b": [0.4779, 0.0791, 0.5667, 0.1005]}, {"w": "and", "b": [0.5734, 0.0791, 0.605, 0.1005]}, {"w": "actually", "b": [0.6117, 0.0791, 0.6763, 0.1005]}, {"w": "starts", "b": [0.683, 0.0791, 0.7279, 0.1005]}, {"w": "to", "b": [0.7346, 0.0791, 0.7516, 0.1005]}, {"w": "go", "b": [0.7583, 0.0791, 0.7787, 0.1005]}, {"w": "back", "b": [0.7854, 0.0791, 0.8243, 0.1005]}, {"w": "up.", "b": [0.831, 0.0791, 0.8571, 0.1005]}, {"w": "This", "b": [0.1429, 0.0981, 0.1801, 0.1195]}, {"w": "indicates", "b": [0.1854, 0.0981, 0.2594, 0.1195]}, {"w": "that", "b": [0.2648, 0.0981, 0.2974, 0.1195]}, {"w": "the", "b": [0.3027, 0.0981, 0.3291, 0.1195]}, {"w": "model", "b": [0.3344, 0.0981, 0.3873, 0.1195]}, {"w": "has", "b": [0.3926, 0.0981, 0.4205, 0.1195]}, {"w": "started", "b": [0.4259, 0.0981, 0.483, 0.1195]}, {"w": "to", "b": [0.4884, 0.0981, 0.5053, 0.1195]}, {"w": "overfit", "b": [0.5107, 0.0981, 0.5657, 0.1195]}, {"w": "the", "b": [0.571, 0.0981, 0.5974, 0.1195]}, {"w": "training", "b": [0.6028, 0.0981, 0.6697, 0.1195]}, {"w": "data.", "b": [0.6751, 0.0981, 0.7151, 0.1195]}, {"w": "With", "b": [0.7204, 0.0981, 0.7629, 0.1195]}, {"w": "early", "b": [0.7682, 0.0981, 0.8088, 0.1195]}, {"w": "stop‐", "b": [0.8142, 0.0981, 0.8571, 0.1195]}, {"w": "ping", "b": [0.1429, 0.1172, 0.1805, 0.1386]}, {"w": "you", "b": [0.186, 0.1172, 0.2173, 0.1386]}, {"w": "just", "b": [0.2228, 0.1172, 0.2532, 0.1386]}, {"w": "stop", "b": [0.2587, 0.1172, 0.2942, 0.1386]}, {"w": "training", "b": [0.2998, 0.1172, 0.3667, 0.1386]}, {"w": "as", "b": [0.3722, 0.1172, 0.389, 0.1386]}, {"w": "soon", "b": [0.3945, 0.1172, 0.4348, 0.1386]}, {"w": "as", "b": [0.4403, 0.1172, 0.4571, 0.1386]}, {"w": "the", "b": [0.4626, 0.1172, 0.489, 0.1386]}, {"w": "validation", "b": [0.4945, 0.1172, 0.5778, 0.1386]}, {"w": "error", "b": [0.5834, 0.1172, 0.626, 0.1386]}, {"w": "reaches", "b": [0.6315, 0.1172, 0.6937, 0.1386]}, {"w": "the", "b": [0.6992, 0.1172, 0.7256, 0.1386]}, {"w": "minimum.", "b": [0.7311, 0.1172, 0.8202, 0.1386]}, {"w": "It", "b": [0.8258, 0.1172, 0.8384, 0.1386]}, {"w": "is", "b": [0.8439, 0.1172, 0.8572, 0.1386]}, {"w": "such", "b": [0.1429, 0.1362, 0.1815, 0.1576]}, {"w": "a", "b": [0.188, 0.1362, 0.1971, 0.1576]}, {"w": "simple", "b": [0.2036, 0.1362, 0.2585, 0.1576]}, {"w": "and", "b": [0.265, 0.1362, 0.2965, 0.1576]}, {"w": "efficient", "b": [0.303, 0.1362, 0.3704, 0.1576]}, {"w": "regularization", "b": [0.3768, 0.1362, 0.4934, 0.1576]}, {"w": "technique", "b": [0.4999, 0.1362, 0.5826, 0.1576]}, {"w": "that", "b": [0.589, 0.1362, 0.6216, 0.1576]}, {"w": "Geoffrey", "b": [0.6281, 0.1362, 0.7009, 0.1576]}, {"w": "Hinton", "b": [0.7074, 0.1362, 0.7683, 0.1576]}, {"w": "called", "b": [0.7748, 0.1362, 0.8231, 0.1576]}, {"w": "it", "b": [0.8296, 0.1362, 0.8415, 0.1576]}, {"w": "a", "b": [0.848, 0.1362, 0.8571, 0.1576]}, {"w": "“beautiful", "b": [0.1429, 0.1553, 0.2248, 0.1767]}, {"w": "free", "b": [0.2296, 0.1553, 0.2612, 0.1767]}, {"w": "lunch.”", "b": [0.2659, 0.1553, 0.3238, 0.1767]}]}, {"id": "b_1", "type": "equation", "text": "Figure 4-20. Early stopping regularization", "words": [{"w": "Figure", "b": [0.1429, 0.4861, 0.1943, 0.5077]}, {"w": "4-20.", "b": [0.1991, 0.4861, 0.2407, 0.5077]}, {"w": "Early", "b": [0.2455, 0.4861, 0.2886, 0.5077]}, {"w": "stopping", "b": [0.2933, 0.4861, 0.3608, 0.5077]}, {"w": "regularization", "b": [0.3655, 0.4861, 0.4803, 0.5077]}]}, {"id": "b_2", "type": "paragraph", "text": "With Stochastic and Mini-batch Gradient Descent, the curves are not so smooth, and it may be hard to know whether you have reached the minimum or not. One solution is to stop only after the validation error has been above the minimum for some time (when you are confident that the model will not do any better), then roll back the model parameters to the point where the validation error was at a minimum.", "words": [{"w": "With", "b": [0.2714, 0.5282, 0.3102, 0.5478]}, {"w": "Stochastic", "b": [0.3168, 0.5282, 0.3939, 0.5478]}, {"w": "and", "b": [0.4005, 0.5282, 0.4293, 0.5478]}, {"w": "Mini-batch", "b": [0.4359, 0.5282, 0.522, 0.5478]}, {"w": "Gradient", "b": [0.5285, 0.5282, 0.5967, 0.5478]}, {"w": "Descent,", "b": [0.6033, 0.5282, 0.6687, 0.5478]}, {"w": "the", "b": [0.6753, 0.5282, 0.6994, 0.5478]}, {"w": "curves", "b": [0.7059, 0.5282, 0.7556, 0.5478]}, {"w": "are", "b": [0.7622, 0.5282, 0.7857, 0.5478]}, {"w": "not", "b": [0.2714, 0.5456, 0.2974, 0.5652]}, {"w": "so", "b": [0.3056, 0.5456, 0.3224, 0.5652]}, {"w": "smooth,", "b": [0.3306, 0.5456, 0.393, 0.5652]}, {"w": "and", "b": [0.4013, 0.5456, 0.4301, 0.5652]}, {"w": "it", "b": [0.4384, 0.5456, 0.4493, 0.5652]}, {"w": "may", "b": [0.4576, 0.5456, 0.49, 0.5652]}, {"w": "be", "b": [0.4983, 0.5456, 0.516, 0.5652]}, {"w": "hard", "b": [0.5243, 0.5456, 0.56, 0.5652]}, {"w": "to", "b": [0.5683, 0.5456, 0.5838, 0.5652]}, {"w": "know", "b": [0.5921, 0.5456, 0.6347, 0.5652]}, {"w": "whether", "b": [0.643, 0.5456, 0.7055, 0.5652]}, {"w": "you", "b": [0.7138, 0.5456, 0.7423, 0.5652]}, {"w": "have", "b": [0.7506, 0.5456, 0.7857, 0.5652]}, {"w": "reached", "b": [0.2714, 0.563, 0.3313, 0.5826]}, {"w": "the", "b": [0.3361, 0.563, 0.3602, 0.5826]}, {"w": "minimum", "b": [0.365, 0.563, 0.4422, 0.5826]}, {"w": "or", "b": [0.447, 0.563, 0.4638, 0.5826]}, {"w": "not.", "b": [0.4686, 0.563, 0.4989, 0.5826]}, {"w": "One", "b": [0.5037, 0.563, 0.5365, 0.5826]}, {"w": "solution", "b": [0.5413, 0.563, 0.604, 0.5826]}, {"w": "is", "b": [0.6088, 0.563, 0.6209, 0.5826]}, {"w": "to", "b": [0.6257, 0.563, 0.6412, 0.5826]}, {"w": "stop", "b": [0.646, 0.563, 0.6785, 0.5826]}, {"w": "only", "b": [0.6833, 0.563, 0.717, 0.5826]}, {"w": "after", "b": [0.7219, 0.563, 0.7568, 0.5826]}, {"w": "the", "b": [0.7616, 0.563, 0.7857, 0.5826]}, {"w": "validation", "b": [0.2714, 0.5804, 0.3476, 0.6]}, {"w": "error", "b": [0.3522, 0.5804, 0.3912, 0.6]}, {"w": "has", "b": [0.3958, 0.5804, 0.4213, 0.6]}, {"w": "been", "b": [0.4258, 0.5804, 0.4621, 0.6]}, {"w": "above", "b": [0.4667, 0.5804, 0.5114, 0.6]}, {"w": "the", "b": [0.5159, 0.5804, 0.54, 0.6]}, {"w": "minimum", "b": [0.5445, 0.5804, 0.6217, 0.6]}, {"w": "for", "b": [0.6263, 0.5804, 0.6487, 0.6]}, {"w": "some", "b": [0.6533, 0.5804, 0.6937, 0.6]}, {"w": "time", "b": [0.6982, 0.5804, 0.7328, 0.6]}, {"w": "(when", "b": [0.7374, 0.5804, 0.7857, 0.6]}, {"w": "you", "b": [0.2714, 0.5979, 0.3, 0.6174]}, {"w": "are", "b": [0.3058, 0.5979, 0.3294, 0.6174]}, {"w": "confident", "b": [0.3352, 0.5979, 0.4082, 0.6174]}, {"w": "that", "b": [0.414, 0.5979, 0.4438, 0.6174]}, {"w": "the", "b": [0.4496, 0.5979, 0.4737, 0.6174]}, {"w": "model", "b": [0.4795, 0.5979, 0.5278, 0.6174]}, {"w": "will", "b": [0.5337, 0.5979, 0.5615, 0.6174]}, {"w": "not", "b": [0.5673, 0.5979, 0.5933, 0.6174]}, {"w": "do", "b": [0.5991, 0.5979, 0.6189, 0.6174]}, {"w": "any", "b": [0.6247, 0.5979, 0.6518, 0.6174]}, {"w": "better),", "b": [0.6576, 0.5979, 0.7131, 0.6174]}, {"w": "then", "b": [0.719, 0.5979, 0.7535, 0.6174]}, {"w": "roll", "b": [0.7593, 0.5979, 0.7857, 0.6174]}, {"w": "back", "b": [0.2714, 0.6153, 0.307, 0.6349]}, {"w": "the", "b": [0.3125, 0.6153, 0.3365, 0.6349]}, {"w": "model", "b": [0.342, 0.6153, 0.3903, 0.6349]}, {"w": "parameters", "b": [0.3958, 0.6153, 0.4812, 0.6349]}, {"w": "to", "b": [0.4867, 0.6153, 0.5022, 0.6349]}, {"w": "the", "b": [0.5077, 0.6153, 0.5318, 0.6349]}, {"w": "point", "b": [0.5373, 0.6153, 0.578, 0.6349]}, {"w": "where", "b": [0.5835, 0.6153, 0.6299, 0.6349]}, {"w": "the", "b": [0.6354, 0.6153, 0.6595, 0.6349]}, {"w": "validation", "b": [0.665, 0.6153, 0.7412, 0.6349]}, {"w": "error", "b": [0.7467, 0.6153, 0.7857, 0.6349]}, {"w": "was", "b": [0.2714, 0.6327, 0.2998, 0.6523]}, {"w": "at", "b": [0.3041, 0.6327, 0.318, 0.6523]}, {"w": "a", "b": [0.3223, 0.6327, 0.3306, 0.6523]}, {"w": "minimum.", "b": [0.335, 0.6327, 0.4165, 0.6523]}]}, {"id": "b_3", "type": "paragraph", "text": "Here is a basic implementation of early stopping:", "words": [{"w": "Here", "b": [0.1429, 0.6726, 0.1837, 0.694]}, {"w": "is", "b": [0.1885, 0.6726, 0.2017, 0.694]}, {"w": "a", "b": [0.2064, 0.6726, 0.2156, 0.694]}, {"w": "basic", "b": [0.2203, 0.6726, 0.2621, 0.694]}, {"w": "implementation", "b": [0.2668, 0.6726, 0.4001, 0.694]}, {"w": "of", "b": [0.4048, 0.6726, 0.4216, 0.694]}, {"w": "early", "b": [0.4263, 0.6726, 0.4669, 0.694]}, {"w": "stopping:", "b": [0.4716, 0.6726, 0.5495, 0.694]}]}, {"id": "b_4", "type": "paragraph", "text": "from sklearn.base import clone", "words": [{"w": "from", "b": [0.1766, 0.7045, 0.2103, 0.7174]}, {"w": "sklearn.base", "b": [0.2188, 0.7045, 0.3199, 0.7174]}, {"w": "import", "b": [0.3284, 0.7045, 0.379, 0.7174]}, {"w": "clone", "b": [0.3874, 0.7045, 0.4296, 0.7174]}]}, {"id": "b_5", "type": "paragraph", "text": "# prepare the data poly_scaler = Pipeline([ (\"poly_features\", PolynomialFeatures(degree=90, include_bias=False)), (\"std_scaler\", StandardScaler()) ]) X_train_poly_scaled = poly_scaler.fit_transform(X_train) X_val_poly_scaled = poly_scaler.transform(X_val)", "words": [{"w": "#", "b": [0.1766, 0.7354, 0.185, 0.7482]}, {"w": "prepare", "b": [0.1935, 0.7354, 0.2525, 0.7482]}, {"w": "the", "b": [0.2609, 0.7354, 0.2862, 0.7482]}, {"w": "data", "b": [0.2946, 0.7354, 0.3284, 0.7482]}, {"w": "poly_scaler", "b": [0.1766, 0.7508, 0.2694, 0.7636]}, {"w": "=", "b": [0.2778, 0.7508, 0.2862, 0.7636]}, {"w": "Pipeline([", "b": [0.2946, 0.7508, 0.379, 0.7636]}, {"w": "(\"poly_features\",", "b": [0.2441, 0.7662, 0.3874, 0.7791]}, {"w": "PolynomialFeatures(degree=90,", "b": [0.3958, 0.7662, 0.6404, 0.7791]}, {"w": "include_bias=False)),", "b": [0.6488, 0.7662, 0.8259, 0.7791]}, {"w": "(\"std_scaler\",", "b": [0.2441, 0.7816, 0.3621, 0.7945]}, {"w": "StandardScaler())", "b": [0.3705, 0.7816, 0.5139, 0.7945]}, {"w": "])", "b": [0.2103, 0.7971, 0.2272, 0.8099]}, {"w": "X_train_poly_scaled", "b": [0.1766, 0.8125, 0.3368, 0.8253]}, {"w": "=", "b": [0.3452, 0.8125, 0.3537, 0.8253]}, {"w": "poly_scaler.fit_transform(X_train)", "b": [0.3621, 0.8125, 0.6488, 0.8253]}, {"w": "X_val_poly_scaled", "b": [0.1766, 0.8279, 0.3199, 0.8407]}, {"w": "=", "b": [0.3284, 0.8279, 0.3368, 0.8407]}, {"w": "poly_scaler.transform(X_val)", "b": [0.3452, 0.8279, 0.5814, 0.8407]}]}, {"id": "b_6", "type": "paragraph", "text": "sgd_reg = SGDRegressor(max_iter=1, tol=-np.infty, warm_start=True, penalty=None, learning_rate=\"constant\", eta0=0.0005)", "words": [{"w": "sgd_reg", "b": [0.1766, 0.8587, 0.2356, 0.8716]}, {"w": "=", "b": [0.2441, 0.8587, 0.2525, 0.8716]}, {"w": "SGDRegressor(max_iter=1,", "b": [0.2609, 0.8587, 0.4633, 0.8716]}, {"w": "tol=-np.infty,", "b": [0.4717, 0.8587, 0.5898, 0.8716]}, {"w": "warm_start=True,", "b": [0.5982, 0.8587, 0.7331, 0.8716]}, {"w": "penalty=None,", "b": [0.3705, 0.8742, 0.4802, 0.887]}, {"w": "learning_rate=\"constant\",", "b": [0.4886, 0.8742, 0.6994, 0.887]}, {"w": "eta0=0.0005)", "b": [0.7078, 0.8742, 0.809, 0.887]}]}, {"id": "b_7", "type": "paragraph", "text": "Regularized Linear Models | 143", "words": [{"w": "Regularized", "b": [0.6409, 0.9225, 0.711, 0.9388]}, {"w": "Linear", "b": [0.7138, 0.9225, 0.7507, 0.9388]}, {"w": "Models", "b": [0.7536, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "143", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 170, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "minimum_val_error = float(\"inf\") best_epoch = None best_model = None for epoch in range(1000): sgd_reg.fit(X_train_poly_scaled, y_train) # continues where it left off y_val_predict = sgd_reg.predict(X_val_poly_scaled) val_error = mean_squared_error(y_val, y_val_predict) if val_error < minimum_val_error: minimum_val_error = val_error best_epoch = epoch best_model = clone(sgd_reg)", "words": [{"w": "minimum_val_error", "b": [0.1766, 0.0983, 0.3199, 0.1112]}, {"w": "=", "b": [0.3284, 0.0983, 0.3368, 0.1112]}, {"w": "float(\"inf\")", "b": [0.3452, 0.0983, 0.4464, 0.1112]}, {"w": "best_epoch", "b": [0.1766, 0.1138, 0.2609, 0.1266]}, {"w": "=", "b": [0.2693, 0.1138, 0.2778, 0.1266]}, {"w": "None", "b": [0.2862, 0.1138, 0.3199, 0.1266]}, {"w": "best_model", "b": [0.1766, 0.1292, 0.2609, 0.142]}, {"w": "=", "b": [0.2693, 0.1292, 0.2778, 0.142]}, {"w": "None", "b": [0.2862, 0.1292, 0.3199, 0.142]}, {"w": "for", "b": [0.1766, 0.1446, 0.2019, 0.1574]}, {"w": "epoch", "b": [0.2103, 0.1446, 0.2525, 0.1574]}, {"w": "in", "b": [0.2609, 0.1446, 0.2778, 0.1574]}, {"w": "range(1000):", "b": [0.2862, 0.1446, 0.3874, 0.1574]}, {"w": "sgd_reg.fit(X_train_poly_scaled,", "b": [0.2103, 0.16, 0.4802, 0.1729]}, {"w": "y_train)", "b": [0.4886, 0.16, 0.5561, 0.1729]}, {"w": "#", "b": [0.5729, 0.16, 0.5813, 0.1729]}, {"w": "continues", "b": [0.5898, 0.16, 0.6657, 0.1729]}, {"w": "where", "b": [0.6741, 0.16, 0.7163, 0.1729]}, {"w": "it", "b": [0.7247, 0.16, 0.7416, 0.1729]}, {"w": "left", "b": [0.75, 0.16, 0.7837, 0.1729]}, {"w": "off", "b": [0.7922, 0.16, 0.8175, 0.1729]}, {"w": "y_val_predict", "b": [0.2103, 0.1754, 0.3199, 0.1883]}, {"w": "=", "b": [0.3284, 0.1754, 0.3368, 0.1883]}, {"w": "sgd_reg.predict(X_val_poly_scaled)", "b": [0.3452, 0.1754, 0.6319, 0.1883]}, {"w": "val_error", "b": [0.2103, 0.1909, 0.2862, 0.2037]}, {"w": "=", "b": [0.2946, 0.1909, 0.3031, 0.2037]}, {"w": "mean_squared_error(y_val,", "b": [0.3115, 0.1909, 0.5223, 0.2037]}, {"w": "y_val_predict)", "b": [0.5308, 0.1909, 0.6488, 0.2037]}, {"w": "if", "b": [0.2103, 0.2063, 0.2272, 0.2191]}, {"w": "val_error", "b": [0.2356, 0.2063, 0.3115, 0.2191]}, {"w": "<", "b": [0.3199, 0.2063, 0.3284, 0.2191]}, {"w": "minimum_val_error:", "b": [0.3368, 0.2063, 0.4886, 0.2191]}, {"w": "minimum_val_error", "b": [0.244, 0.2217, 0.3874, 0.2345]}, {"w": "=", "b": [0.3958, 0.2217, 0.4043, 0.2345]}, {"w": "val_error", "b": [0.4127, 0.2217, 0.4886, 0.2345]}, {"w": "best_epoch", "b": [0.244, 0.2371, 0.3284, 0.25]}, {"w": "=", "b": [0.3368, 0.2371, 0.3452, 0.25]}, {"w": "epoch", "b": [0.3537, 0.2371, 0.3958, 0.25]}, {"w": "best_model", "b": [0.244, 0.2525, 0.3284, 0.2654]}, {"w": "=", "b": [0.3368, 0.2525, 0.3452, 0.2654]}, {"w": "clone(sgd_reg)", "b": [0.3537, 0.2525, 0.4717, 0.2654]}]}, {"id": "b_1", "type": "paragraph", "text": "Note that with warm_start=True, when the fit() method is called, it just continues training where it left off instead of restarting from scratch.", "words": [{"w": "Note", "b": [0.1429, 0.2741, 0.1836, 0.2955]}, {"w": "that", "b": [0.1898, 0.2741, 0.2224, 0.2955]}, {"w": "with", "b": [0.2286, 0.2741, 0.2659, 0.2955]}, {"w": "warm_start=True,", "b": [0.2721, 0.2741, 0.4253, 0.2955]}, {"w": "when", "b": [0.4315, 0.2741, 0.4772, 0.2955]}, {"w": "the", "b": [0.4834, 0.2741, 0.5097, 0.2955]}, {"w": "fit()", "b": [0.5159, 0.2772, 0.5654, 0.2923]}, {"w": "method", "b": [0.5716, 0.2741, 0.6366, 0.2955]}, {"w": "is", "b": [0.6428, 0.2741, 0.656, 0.2955]}, {"w": "called,", "b": [0.6622, 0.2741, 0.7153, 0.2955]}, {"w": "it", "b": [0.7215, 0.2741, 0.7334, 0.2955]}, {"w": "just", "b": [0.7396, 0.2741, 0.77, 0.2955]}, {"w": "continues", "b": [0.7762, 0.2741, 0.8571, 0.2955]}, {"w": "training", "b": [0.1429, 0.2931, 0.2098, 0.3145]}, {"w": "where", "b": [0.2145, 0.2931, 0.2654, 0.3145]}, {"w": "it", "b": [0.2701, 0.2931, 0.282, 0.3145]}, {"w": "left", "b": [0.2868, 0.2931, 0.3134, 0.3145]}, {"w": "off", "b": [0.3181, 0.2931, 0.3411, 0.3145]}, {"w": "instead", "b": [0.3458, 0.2931, 0.4058, 0.3145]}, {"w": "of", "b": [0.4105, 0.2931, 0.4273, 0.3145]}, {"w": "restarting", "b": [0.4321, 0.2931, 0.5126, 0.3145]}, {"w": "from", "b": [0.5173, 0.2931, 0.5589, 0.3145]}, {"w": "scratch.", "b": [0.5636, 0.2931, 0.6276, 0.3145]}]}, {"id": "b_2", "type": "paragraph", "text": "Logistic Regression", "words": [{"w": "Logistic", "b": [0.1429, 0.3275, 0.2373, 0.3618]}, {"w": "Regression", "b": [0.2432, 0.3275, 0.3782, 0.3618]}]}, {"id": "b_3", "type": "paragraph", "text": "As we discussed in Chapter 1, some regression algorithms can be used for classifica‐ tion as well (and vice versa). Logistic Regression (also called Logit Regression) is com‐ monly used to estimate the probability that an instance belongs to a particular class (e.g., what is the probability that this email is spam?). If the estimated probability is greater than 50%, then the model predicts that the instance belongs to that class (called the positive class, labeled “1”), or else it predicts that it does not (i.e., it belongs to the negative class, labeled “0”). This makes it a binary classifier.", "words": [{"w": "As", "b": [0.1429, 0.3687, 0.1649, 0.3901]}, {"w": "we", "b": [0.1708, 0.3687, 0.194, 0.3901]}, {"w": "discussed", "b": [0.1999, 0.3687, 0.2791, 0.3901]}, {"w": "in", "b": [0.2851, 0.3687, 0.3021, 0.3901]}, {"w": "Chapter", "b": [0.308, 0.3687, 0.3756, 0.3901]}, {"w": "1,", "b": [0.3815, 0.3687, 0.3963, 0.3901]}, {"w": "some", "b": [0.4022, 0.3687, 0.4464, 0.3901]}, {"w": "regression", "b": [0.4523, 0.3687, 0.5381, 0.3901]}, {"w": "algorithms", "b": [0.5441, 0.3687, 0.6344, 0.3901]}, {"w": "can", "b": [0.6403, 0.3687, 0.6696, 0.3901]}, {"w": "be", "b": [0.6756, 0.3687, 0.695, 0.3901]}, {"w": "used", "b": [0.701, 0.3687, 0.7395, 0.3901]}, {"w": "for", "b": [0.7455, 0.3687, 0.77, 0.3901]}, {"w": "classifica‐", "b": [0.7759, 0.3687, 0.8571, 0.3901]}, {"w": "tion", "b": [0.1429, 0.3877, 0.1768, 0.4092]}, {"w": "as", "b": [0.1828, 0.3877, 0.1996, 0.4092]}, {"w": "well", "b": [0.2055, 0.3877, 0.2392, 0.4092]}, {"w": "(and", "b": [0.2451, 0.3877, 0.2839, 0.4092]}, {"w": "vice", "b": [0.2898, 0.3877, 0.3227, 0.4092]}, {"w": "versa).", "b": [0.3287, 0.3877, 0.3837, 0.4092]}, {"w": "Logistic", "b": [0.3896, 0.3875, 0.4518, 0.4092]}, {"w": "Regression", "b": [0.4578, 0.3875, 0.5425, 0.4092]}, {"w": "(also", "b": [0.5484, 0.3877, 0.5883, 0.4092]}, {"w": "called", "b": [0.5943, 0.3877, 0.6426, 0.4092]}, {"w": "Logit", "b": [0.6486, 0.3875, 0.6902, 0.4092]}, {"w": "Regression)", "b": [0.6962, 0.3875, 0.7881, 0.4092]}, {"w": "is", "b": [0.7941, 0.3877, 0.8073, 0.4092]}, {"w": "com‐", "b": [0.8132, 0.3877, 0.8572, 0.4092]}, {"w": "monly", "b": [0.1429, 0.4068, 0.1968, 0.4282]}, {"w": "used", "b": [0.2033, 0.4068, 0.2418, 0.4282]}, {"w": "to", "b": [0.2483, 0.4068, 0.2653, 0.4282]}, {"w": "estimate", "b": [0.2718, 0.4068, 0.3412, 0.4282]}, {"w": "the", "b": [0.3477, 0.4068, 0.374, 0.4282]}, {"w": "probability", "b": [0.3805, 0.4068, 0.4725, 0.4282]}, {"w": "that", "b": [0.4789, 0.4068, 0.5115, 0.4282]}, {"w": "an", "b": [0.518, 0.4068, 0.5385, 0.4282]}, {"w": "instance", "b": [0.545, 0.4068, 0.6142, 0.4282]}, {"w": "belongs", "b": [0.6207, 0.4068, 0.6848, 0.4282]}, {"w": "to", "b": [0.6913, 0.4068, 0.7083, 0.4282]}, {"w": "a", "b": [0.7148, 0.4068, 0.7239, 0.4282]}, {"w": "particular", "b": [0.7304, 0.4068, 0.8121, 0.4282]}, {"w": "class", "b": [0.8186, 0.4068, 0.8571, 0.4282]}, {"w": "(e.g.,", "b": [0.1429, 0.4258, 0.1829, 0.4473]}, {"w": "what", "b": [0.1893, 0.4258, 0.2298, 0.4473]}, {"w": "is", "b": [0.2363, 0.4258, 0.2495, 0.4473]}, {"w": "the", "b": [0.2559, 0.4258, 0.2823, 0.4473]}, {"w": "probability", "b": [0.2887, 0.4258, 0.3806, 0.4473]}, {"w": "that", "b": [0.387, 0.4258, 0.4196, 0.4473]}, {"w": "this", "b": [0.426, 0.4258, 0.4568, 0.4473]}, {"w": "email", "b": [0.4632, 0.4258, 0.5091, 0.4473]}, {"w": "is", "b": [0.5155, 0.4258, 0.5287, 0.4473]}, {"w": "spam?).", "b": [0.5352, 0.4258, 0.5998, 0.4473]}, {"w": "If", "b": [0.6062, 0.4258, 0.6195, 0.4473]}, {"w": "the", "b": [0.6259, 0.4258, 0.6522, 0.4473]}, {"w": "estimated", "b": [0.6587, 0.4258, 0.7391, 0.4473]}, {"w": "probability", "b": [0.7456, 0.4258, 0.8375, 0.4473]}, {"w": "is", "b": [0.8439, 0.4258, 0.8571, 0.4473]}, {"w": "greater", "b": [0.1429, 0.4449, 0.2009, 0.4663]}, {"w": "than", "b": [0.2096, 0.4449, 0.2476, 0.4663]}, {"w": "50%,", "b": [0.2564, 0.4449, 0.2969, 0.4663]}, {"w": "then", "b": [0.3056, 0.4449, 0.3434, 0.4663]}, {"w": "the", "b": [0.3521, 0.4449, 0.3784, 0.4663]}, {"w": "model", "b": [0.3872, 0.4449, 0.44, 0.4663]}, {"w": "predicts", "b": [0.4487, 0.4449, 0.5156, 0.4663]}, {"w": "that", "b": [0.5244, 0.4449, 0.5569, 0.4663]}, {"w": "the", "b": [0.5657, 0.4449, 0.592, 0.4663]}, {"w": "instance", "b": [0.6008, 0.4449, 0.67, 0.4663]}, {"w": "belongs", "b": [0.6787, 0.4449, 0.7428, 0.4663]}, {"w": "to", "b": [0.7516, 0.4449, 0.7685, 0.4663]}, {"w": "that", "b": [0.7773, 0.4449, 0.8099, 0.4663]}, {"w": "class", "b": [0.8186, 0.4449, 0.8571, 0.4663]}, {"w": "(called", "b": [0.1429, 0.4639, 0.1984, 0.4853]}, {"w": "the", "b": [0.2077, 0.4639, 0.2341, 0.4853]}, {"w": "positive", "b": [0.2434, 0.4639, 0.3086, 0.4853]}, {"w": "class,", "b": [0.3179, 0.4639, 0.3612, 0.4853]}, {"w": "labeled", "b": [0.3705, 0.4639, 0.4295, 0.4853]}, {"w": "“1”),", "b": [0.4388, 0.4639, 0.4774, 0.4853]}, {"w": "or", "b": [0.4867, 0.4639, 0.505, 0.4853]}, {"w": "else", "b": [0.5144, 0.4639, 0.545, 0.4853]}, {"w": "it", "b": [0.5543, 0.4639, 0.5662, 0.4853]}, {"w": "predicts", "b": [0.5755, 0.4639, 0.6424, 0.4853]}, {"w": "that", "b": [0.6517, 0.4639, 0.6843, 0.4853]}, {"w": "it", "b": [0.6936, 0.4639, 0.7056, 0.4853]}, {"w": "does", "b": [0.7149, 0.4639, 0.753, 0.4853]}, {"w": "not", "b": [0.7623, 0.4639, 0.7907, 0.4853]}, {"w": "(i.e.,", "b": [0.8, 0.4639, 0.8359, 0.4853]}, {"w": "it", "b": [0.8452, 0.4639, 0.8572, 0.4853]}, {"w": "belongs", "b": [0.1429, 0.483, 0.207, 0.5044]}, {"w": "to", "b": [0.2117, 0.483, 0.2287, 0.5044]}, {"w": "the", "b": [0.2334, 0.483, 0.2598, 0.5044]}, {"w": "negative", "b": [0.2645, 0.483, 0.3337, 0.5044]}, {"w": "class,", "b": [0.3384, 0.483, 0.3817, 0.5044]}, {"w": "labeled", "b": [0.3864, 0.483, 0.4454, 0.5044]}, {"w": "“0”).", "b": [0.4501, 0.483, 0.4887, 0.5044]}, {"w": "This", "b": [0.4934, 0.483, 0.5307, 0.5044]}, {"w": "makes", "b": [0.5354, 0.483, 0.5884, 0.5044]}, {"w": "it", "b": [0.5932, 0.483, 0.6051, 0.5044]}, {"w": "a", "b": [0.6098, 0.483, 0.619, 0.5044]}, {"w": "binary", "b": [0.6237, 0.483, 0.6783, 0.5044]}, {"w": "classifier.", "b": [0.683, 0.483, 0.7589, 0.5044]}]}, {"id": "b_4", "type": "paragraph", "text": "Estimating Probabilities", "words": [{"w": "Estimating", "b": [0.1429, 0.5172, 0.2547, 0.5457]}, {"w": "Probabilities", "b": [0.2596, 0.5172, 0.3902, 0.5457]}]}, {"id": "b_5", "type": "paragraph", "text": "So how does it work? Just like a Linear Regression model, a Logistic Regression model computes a weighted sum of the input features (plus a bias term), but instead of outputting the result directly like the Linear Regression model does, it outputs the logistic of this result (see Equation 4-13).", "words": [{"w": "So", "b": [0.1429, 0.5516, 0.1634, 0.573]}, {"w": "how", "b": [0.1725, 0.5516, 0.2085, 0.573]}, {"w": "does", "b": [0.2176, 0.5516, 0.2557, 0.573]}, {"w": "it", "b": [0.2648, 0.5516, 0.2767, 0.573]}, {"w": "work?", "b": [0.2858, 0.5516, 0.3367, 0.573]}, {"w": "Just", "b": [0.3458, 0.5516, 0.377, 0.573]}, {"w": "like", "b": [0.3861, 0.5516, 0.4161, 0.573]}, {"w": "a", "b": [0.4252, 0.5516, 0.4344, 0.573]}, {"w": "Linear", "b": [0.4435, 0.5516, 0.4974, 0.573]}, {"w": "Regression", "b": [0.5065, 0.5516, 0.5975, 0.573]}, {"w": "model,", "b": [0.6066, 0.5516, 0.6641, 0.573]}, {"w": "a", "b": [0.6732, 0.5516, 0.6824, 0.573]}, {"w": "Logistic", "b": [0.6915, 0.5516, 0.757, 0.573]}, {"w": "Regression", "b": [0.7661, 0.5516, 0.8571, 0.573]}, {"w": "model", "b": [0.1429, 0.5707, 0.1957, 0.5921]}, {"w": "computes", "b": [0.2016, 0.5707, 0.2825, 0.5921]}, {"w": "a", "b": [0.2884, 0.5707, 0.2976, 0.5921]}, {"w": "weighted", "b": [0.3035, 0.5707, 0.3789, 0.5921]}, {"w": "sum", "b": [0.3848, 0.5707, 0.4205, 0.5921]}, {"w": "of", "b": [0.4264, 0.5707, 0.4432, 0.5921]}, {"w": "the", "b": [0.4491, 0.5707, 0.4755, 0.5921]}, {"w": "input", "b": [0.4814, 0.5707, 0.5263, 0.5921]}, {"w": "features", "b": [0.5322, 0.5707, 0.5976, 0.5921]}, {"w": "(plus", "b": [0.6035, 0.5707, 0.6456, 0.5921]}, {"w": "a", "b": [0.6515, 0.5707, 0.6606, 0.5921]}, {"w": "bias", "b": [0.6665, 0.5707, 0.6995, 0.5921]}, {"w": "term),", "b": [0.7054, 0.5707, 0.7574, 0.5921]}, {"w": "but", "b": [0.7633, 0.5707, 0.7913, 0.5921]}, {"w": "instead", "b": [0.7972, 0.5707, 0.8571, 0.5921]}, {"w": "of", "b": [0.1428, 0.5897, 0.1596, 0.6111]}, {"w": "outputting", "b": [0.1652, 0.5897, 0.2547, 0.6111]}, {"w": "the", "b": [0.2602, 0.5897, 0.2866, 0.6111]}, {"w": "result", "b": [0.2921, 0.5897, 0.339, 0.6111]}, {"w": "directly", "b": [0.3446, 0.5897, 0.4078, 0.6111]}, {"w": "like", "b": [0.4133, 0.5897, 0.4434, 0.6111]}, {"w": "the", "b": [0.4489, 0.5897, 0.4753, 0.6111]}, {"w": "Linear", "b": [0.4808, 0.5897, 0.5348, 0.6111]}, {"w": "Regression", "b": [0.5403, 0.5897, 0.6313, 0.6111]}, {"w": "model", "b": [0.6369, 0.5897, 0.6897, 0.6111]}, {"w": "does,", "b": [0.6953, 0.5897, 0.7382, 0.6111]}, {"w": "it", "b": [0.7437, 0.5897, 0.7557, 0.6111]}, {"w": "outputs", "b": [0.7612, 0.5897, 0.8252, 0.6111]}, {"w": "the", "b": [0.8308, 0.5897, 0.8571, 0.6111]}, {"w": "logistic", "b": [0.1429, 0.6086, 0.199, 0.6302]}, {"w": "of", "b": [0.2037, 0.6088, 0.2205, 0.6302]}, {"w": "this", "b": [0.2252, 0.6088, 0.2559, 0.6302]}, {"w": "result", "b": [0.2607, 0.6088, 0.3076, 0.6302]}, {"w": "(see", "b": [0.3123, 0.6088, 0.3449, 0.6302]}, {"w": "Equation", "b": [0.3496, 0.6088, 0.4259, 0.6302]}, {"w": "4-13).", "b": [0.4306, 0.6088, 0.48, 0.6302]}]}, {"id": "b_6", "type": "paragraph", "text": "Equation 4-13. Logistic Regression model estimated probability (vectorized form)", "words": [{"w": "Equation", "b": [0.1726, 0.6483, 0.2473, 0.6699]}, {"w": "4-13.", "b": [0.2521, 0.6483, 0.2937, 0.6699]}, {"w": "Logistic", "b": [0.2985, 0.6483, 0.3607, 0.6699]}, {"w": "Regression", "b": [0.3654, 0.6483, 0.4502, 0.6699]}, {"w": "model", "b": [0.4549, 0.6483, 0.5046, 0.6699]}, {"w": "estimated", "b": [0.5093, 0.6483, 0.5869, 0.6699]}, {"w": "probability", "b": [0.5917, 0.6483, 0.6796, 0.6699]}, {"w": "(vectorized", "b": [0.6843, 0.6483, 0.7737, 0.6699]}, {"w": "form)", "b": [0.7785, 0.6483, 0.8246, 0.6699]}]}, {"id": "b_7", "type": "equation", "text": "p = hθ x = σ xTθ", "words": [{"w": "p", "b": [0.174, 0.6806, 0.1836, 0.7012]}, {"w": "=", "b": [0.1894, 0.6808, 0.2009, 0.7012]}, {"w": "hθ", "b": [0.2064, 0.6806, 0.2246, 0.7055]}, {"w": "x", "b": [0.2315, 0.6803, 0.241, 0.7012]}, {"w": "=", "b": [0.2535, 0.6808, 0.265, 0.7012]}, {"w": "σ", "b": [0.2705, 0.6806, 0.28, 0.7012]}, {"w": "xTθ", "b": [0.2877, 0.6769, 0.3178, 0.7012]}]}, {"id": "b_8", "type": "paragraph", "text": "The logistic—noted σ(·)—is a sigmoid function (i.e., S-shaped) that outputs a number between 0 and 1. It is defined as shown in Equation 4-14 and Figure 4-21.", "words": [{"w": "The", "b": [0.1429, 0.7245, 0.1757, 0.7459]}, {"w": "logistic—noted", "b": [0.1813, 0.7245, 0.3084, 0.7459]}, {"w": "σ(·)—is", "b": [0.314, 0.7243, 0.3755, 0.7459]}, {"w": "a", "b": [0.3811, 0.7245, 0.3902, 0.7459]}, {"w": "sigmoid", "b": [0.3959, 0.7243, 0.459, 0.7459]}, {"w": "function", "b": [0.4647, 0.7243, 0.5328, 0.7459]}, {"w": "(i.e.,", "b": [0.5384, 0.7245, 0.5743, 0.7459]}, {"w": "S-shaped)", "b": [0.58, 0.7243, 0.6626, 0.7459]}, {"w": "that", "b": [0.6682, 0.7245, 0.7008, 0.7459]}, {"w": "outputs", "b": [0.7064, 0.7245, 0.7705, 0.7459]}, {"w": "a", "b": [0.7761, 0.7245, 0.7852, 0.7459]}, {"w": "number", "b": [0.7909, 0.7245, 0.8571, 0.7459]}, {"w": "between", "b": [0.1429, 0.7436, 0.212, 0.765]}, {"w": "0", "b": [0.2167, 0.7436, 0.2267, 0.765]}, {"w": "and", "b": [0.2315, 0.7436, 0.263, 0.765]}, {"w": "1.", "b": [0.2677, 0.7436, 0.2825, 0.765]}, {"w": "It", "b": [0.2872, 0.7436, 0.2999, 0.765]}, {"w": "is", "b": [0.3046, 0.7436, 0.3178, 0.765]}, {"w": "defined", "b": [0.3226, 0.7436, 0.3854, 0.765]}, {"w": "as", "b": [0.3901, 0.7436, 0.4069, 0.765]}, {"w": "shown", "b": [0.4117, 0.7436, 0.4667, 0.765]}, {"w": "in", "b": [0.4715, 0.7436, 0.4884, 0.765]}, {"w": "Equation", "b": [0.4932, 0.7436, 0.5694, 0.765]}, {"w": "4-14", "b": [0.5741, 0.7436, 0.6116, 0.765]}, {"w": "and", "b": [0.6163, 0.7436, 0.6478, 0.765]}, {"w": "Figure", "b": [0.6526, 0.7436, 0.7066, 0.765]}, {"w": "4-21.", "b": [0.7113, 0.7436, 0.7535, 0.765]}]}, {"id": "b_9", "type": "equation", "text": "Equation 4-14. Logistic function", "words": [{"w": "Equation", "b": [0.1726, 0.7831, 0.2473, 0.8047]}, {"w": "4-14.", "b": [0.2521, 0.7831, 0.2937, 0.8047]}, {"w": "Logistic", "b": [0.2985, 0.7831, 0.3607, 0.8047]}, {"w": "function", "b": [0.3654, 0.7831, 0.4335, 0.8047]}]}, {"id": "b_10", "type": "equation", "text": "σ t = 1 1 + exp −t", "words": [{"w": "σ", "b": [0.1726, 0.8197, 0.1821, 0.8403]}, {"w": "t", "b": [0.1898, 0.8197, 0.1959, 0.8403]}, {"w": "=", "b": [0.2088, 0.8199, 0.2203, 0.8403]}, {"w": "1", "b": [0.2781, 0.8111, 0.2876, 0.8315]}, {"w": "1", "b": [0.228, 0.8287, 0.2375, 0.8491]}, {"w": "+", "b": [0.2419, 0.8287, 0.2534, 0.8491]}, {"w": "exp", "b": [0.2634, 0.8287, 0.2915, 0.8491]}, {"w": "−t", "b": [0.3083, 0.8285, 0.3303, 0.8491]}]}, {"id": "b_11", "type": "paragraph", "text": "144 | Chapter 4: Training Models", "words": [{"w": "144", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 171, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 4-21. Logistic function", "words": [{"w": "Figure", "b": [0.1429, 0.2573, 0.1943, 0.2789]}, {"w": "4-21.", "b": [0.1991, 0.2573, 0.2407, 0.2789]}, {"w": "Logistic", "b": [0.2455, 0.2573, 0.3077, 0.2789]}, {"w": "function", "b": [0.3124, 0.2573, 0.3805, 0.2789]}]}, {"id": "b_1", "type": "paragraph", "text": "Once the Logistic Regression model has estimated the probability p = hθ(x) that an instance x belongs to the positive class, it can make its prediction ŷ easily (see Equa‐ tion 4-15).", "words": [{"w": "Once", "b": [0.1429, 0.2949, 0.1875, 0.3163]}, {"w": "the", "b": [0.1943, 0.2949, 0.2206, 0.3163]}, {"w": "Logistic", "b": [0.2275, 0.2949, 0.293, 0.3163]}, {"w": "Regression", "b": [0.2999, 0.2949, 0.3909, 0.3163]}, {"w": "model", "b": [0.3977, 0.2949, 0.4505, 0.3163]}, {"w": "has", "b": [0.4574, 0.2949, 0.4853, 0.3163]}, {"w": "estimated", "b": [0.4921, 0.2949, 0.5726, 0.3163]}, {"w": "the", "b": [0.5794, 0.2949, 0.6057, 0.3163]}, {"w": "probability", "b": [0.6126, 0.2949, 0.7045, 0.3163]}, {"w": "p", "b": [0.7128, 0.2947, 0.7229, 0.3163]}, {"w": "=", "b": [0.73, 0.2949, 0.7421, 0.3163]}, {"w": "hθ(x)", "b": [0.7489, 0.2943, 0.7904, 0.3172]}, {"w": "that", "b": [0.7972, 0.2949, 0.8298, 0.3163]}, {"w": "an", "b": [0.8366, 0.2949, 0.8571, 0.3163]}, {"w": "instance", "b": [0.1428, 0.3139, 0.212, 0.3353]}, {"w": "x", "b": [0.2179, 0.3134, 0.2279, 0.3353]}, {"w": "belongs", "b": [0.2338, 0.3139, 0.2979, 0.3353]}, {"w": "to", "b": [0.3038, 0.3139, 0.3208, 0.3353]}, {"w": "the", "b": [0.3267, 0.3139, 0.353, 0.3353]}, {"w": "positive", "b": [0.3589, 0.3139, 0.4241, 0.3353]}, {"w": "class,", "b": [0.43, 0.3139, 0.4732, 0.3353]}, {"w": "it", "b": [0.4791, 0.3139, 0.491, 0.3353]}, {"w": "can", "b": [0.4969, 0.3139, 0.5263, 0.3353]}, {"w": "make", "b": [0.5321, 0.3139, 0.5775, 0.3353]}, {"w": "its", "b": [0.5834, 0.3139, 0.603, 0.3353]}, {"w": "prediction", "b": [0.6089, 0.3139, 0.6957, 0.3353]}, {"w": "ŷ", "b": [0.7016, 0.3137, 0.7108, 0.3353]}, {"w": "easily", "b": [0.7167, 0.3139, 0.7627, 0.3353]}, {"w": "(see", "b": [0.7686, 0.3139, 0.8012, 0.3353]}, {"w": "Equa‐", "b": [0.807, 0.3139, 0.8571, 0.3353]}, {"w": "tion", "b": [0.1429, 0.333, 0.1768, 0.3544]}, {"w": "4-15).", "b": [0.1816, 0.333, 0.2309, 0.3544]}]}, {"id": "b_2", "type": "equation", "text": "Equation 4-15. Logistic Regression model prediction", "words": [{"w": "Equation", "b": [0.1726, 0.3725, 0.2473, 0.3941]}, {"w": "4-15.", "b": [0.2521, 0.3725, 0.2937, 0.3941]}, {"w": "Logistic", "b": [0.2985, 0.3725, 0.3607, 0.3941]}, {"w": "Regression", "b": [0.3654, 0.3725, 0.4502, 0.3941]}, {"w": "model", "b": [0.4549, 0.3725, 0.5046, 0.3941]}, {"w": "prediction", "b": [0.5093, 0.3725, 0.5911, 0.3941]}]}, {"id": "b_3", "type": "equation", "text": "y = 0 if p < 0 . 5", "words": [{"w": "y", "b": [0.1738, 0.4128, 0.1825, 0.4334]}, {"w": "=", "b": [0.1894, 0.413, 0.2009, 0.4334]}, {"w": "0", "b": [0.2133, 0.4022, 0.2228, 0.4225]}, {"w": "if", "b": [0.2315, 0.4022, 0.2427, 0.4225]}, {"w": "p", "b": [0.2537, 0.402, 0.2633, 0.4225]}, {"w": "<", "b": [0.269, 0.4022, 0.2799, 0.4225]}, {"w": "0", "b": [0.2855, 0.4022, 0.295, 0.4225]}, {"w": ".", "b": [0.2983, 0.4022, 0.3028, 0.4225]}, {"w": "5", "b": [0.3061, 0.4022, 0.3156, 0.4225]}]}, {"id": "b_4", "type": "paragraph", "text": "1 if p ≥0 . 5", "words": [{"w": "1", "b": [0.2133, 0.4256, 0.2228, 0.446]}, {"w": "if", "b": [0.2315, 0.4256, 0.2427, 0.446]}, {"w": "p", "b": [0.2537, 0.4254, 0.2633, 0.446]}, {"w": "≥0", "b": [0.269, 0.4256, 0.2955, 0.446]}, {"w": ".", "b": [0.2988, 0.4256, 0.3034, 0.446]}, {"w": "5", "b": [0.3066, 0.4256, 0.3162, 0.446]}]}, {"id": "b_5", "type": "paragraph", "text": "Notice that σ(t) < 0.5 when t < 0, and σ(t) ≥ 0.5 when t ≥ 0, so a Logistic Regression model predicts 1 if xT θ is positive, and 0 if it is negative.", "words": [{"w": "Notice", "b": [0.1429, 0.4648, 0.1981, 0.4862]}, {"w": "that", "b": [0.204, 0.4648, 0.2366, 0.4862]}, {"w": "σ(t)", "b": [0.2426, 0.4645, 0.2733, 0.4862]}, {"w": "<", "b": [0.2793, 0.4648, 0.2908, 0.4862]}, {"w": "0.5", "b": [0.2967, 0.4648, 0.3215, 0.4862]}, {"w": "when", "b": [0.3274, 0.4648, 0.3731, 0.4862]}, {"w": "t", "b": [0.3791, 0.4645, 0.3855, 0.4862]}, {"w": "<", "b": [0.3914, 0.4648, 0.4029, 0.4862]}, {"w": "0,", "b": [0.4089, 0.4648, 0.4236, 0.4862]}, {"w": "and", "b": [0.4296, 0.4648, 0.4611, 0.4862]}, {"w": "σ(t)", "b": [0.4671, 0.4645, 0.4978, 0.4862]}, {"w": "≥", "b": [0.5038, 0.4648, 0.5159, 0.4862]}, {"w": "0.5", "b": [0.5218, 0.4648, 0.5466, 0.4862]}, {"w": "when", "b": [0.5525, 0.4648, 0.5982, 0.4862]}, {"w": "t", "b": [0.6042, 0.4645, 0.6105, 0.4862]}, {"w": "≥", "b": [0.6165, 0.4648, 0.6286, 0.4862]}, {"w": "0,", "b": [0.6345, 0.4648, 0.6493, 0.4862]}, {"w": "so", "b": [0.6553, 0.4648, 0.6735, 0.4862]}, {"w": "a", "b": [0.6795, 0.4648, 0.6886, 0.4862]}, {"w": "Logistic", "b": [0.6946, 0.4648, 0.7602, 0.4862]}, {"w": "Regression", "b": [0.7661, 0.4648, 0.8572, 0.4862]}, {"w": "model", "b": [0.1429, 0.4838, 0.1957, 0.5052]}, {"w": "predicts", "b": [0.2004, 0.4838, 0.2673, 0.5052]}, {"w": "1", "b": [0.272, 0.4838, 0.282, 0.5052]}, {"w": "if", "b": [0.2868, 0.4838, 0.2985, 0.5052]}, {"w": "xT", "b": [0.3032, 0.4832, 0.3208, 0.5052]}, {"w": "θ", "b": [0.3255, 0.4832, 0.3361, 0.5052]}, {"w": "is", "b": [0.3409, 0.4838, 0.3541, 0.5052]}, {"w": "positive,", "b": [0.3588, 0.4838, 0.4288, 0.5052]}, {"w": "and", "b": [0.4335, 0.4838, 0.4651, 0.5052]}, {"w": "0", "b": [0.4698, 0.4838, 0.4798, 0.5052]}, {"w": "if", "b": [0.4845, 0.4838, 0.4963, 0.5052]}, {"w": "it", "b": [0.501, 0.4838, 0.5129, 0.5052]}, {"w": "is", "b": [0.5177, 0.4838, 0.5309, 0.5052]}, {"w": "negative.", "b": [0.5356, 0.4838, 0.6096, 0.5052]}]}, {"id": "b_6", "type": "paragraph", "text": "The score t is often called the logit: this name comes from the fact that the logit function, defined as logit(p) = log(p / (1 - p)), is the inverse of the logistic function. Indeed, if you compute the logit of the estimated probability p, you will find that the result is t. The logit is also called the log-odds, since it is the log of the ratio between the estimated probability for the positive class and the estimated probability for the negative class.", "words": [{"w": "The", "b": [0.2714, 0.5257, 0.3014, 0.5453]}, {"w": "score", "b": [0.307, 0.5257, 0.3469, 0.5453]}, {"w": "t", "b": [0.3525, 0.5256, 0.3584, 0.5453]}, {"w": "is", "b": [0.364, 0.5257, 0.3761, 0.5453]}, {"w": "often", "b": [0.3816, 0.5257, 0.4213, 0.5453]}, {"w": "called", "b": [0.4269, 0.5257, 0.4711, 0.5453]}, {"w": "the", "b": [0.4767, 0.5257, 0.5008, 0.5453]}, {"w": "logit:", "b": [0.5064, 0.5256, 0.5432, 0.5453]}, {"w": "this", "b": [0.5488, 0.5257, 0.5769, 0.5453]}, {"w": "name", "b": [0.5825, 0.5257, 0.625, 0.5453]}, {"w": "comes", "b": [0.6305, 0.5257, 0.679, 0.5453]}, {"w": "from", "b": [0.6846, 0.5257, 0.7226, 0.5453]}, {"w": "the", "b": [0.7282, 0.5257, 0.7523, 0.5453]}, {"w": "fact", "b": [0.7579, 0.5257, 0.7857, 0.5453]}, {"w": "that", "b": [0.2714, 0.5432, 0.3012, 0.5627]}, {"w": "the", "b": [0.3073, 0.5432, 0.3313, 0.5627]}, {"w": "logit", "b": [0.3374, 0.5432, 0.3717, 0.5627]}, {"w": "function,", "b": [0.3778, 0.5432, 0.4474, 0.5627]}, {"w": "defined", "b": [0.4535, 0.5432, 0.5109, 0.5627]}, {"w": "as", "b": [0.517, 0.5432, 0.5323, 0.5627]}, {"w": "logit(p)", "b": [0.5384, 0.543, 0.5952, 0.5627]}, {"w": "=", "b": [0.6012, 0.5432, 0.6123, 0.5627]}, {"w": "log(p", "b": [0.6183, 0.543, 0.6576, 0.5627]}, {"w": "/", "b": [0.6637, 0.5432, 0.67, 0.5627]}, {"w": "(1", "b": [0.676, 0.5432, 0.6918, 0.5627]}, {"w": "-", "b": [0.6978, 0.5432, 0.7046, 0.5627]}, {"w": "p)),", "b": [0.7107, 0.543, 0.7374, 0.5627]}, {"w": "is", "b": [0.7435, 0.5432, 0.7556, 0.5627]}, {"w": "the", "b": [0.7616, 0.5432, 0.7857, 0.5627]}, {"w": "inverse", "b": [0.2714, 0.5606, 0.3256, 0.5802]}, {"w": "of", "b": [0.3309, 0.5606, 0.3463, 0.5802]}, {"w": "the", "b": [0.3516, 0.5606, 0.3757, 0.5802]}, {"w": "logistic", "b": [0.3811, 0.5606, 0.4356, 0.5802]}, {"w": "function.", "b": [0.4409, 0.5606, 0.5106, 0.5802]}, {"w": "Indeed,", "b": [0.5159, 0.5606, 0.5735, 0.5802]}, {"w": "if", "b": [0.5788, 0.5606, 0.5896, 0.5802]}, {"w": "you", "b": [0.5949, 0.5606, 0.6235, 0.5802]}, {"w": "compute", "b": [0.6289, 0.5606, 0.6959, 0.5802]}, {"w": "the", "b": [0.7012, 0.5606, 0.7253, 0.5802]}, {"w": "logit", "b": [0.7306, 0.5606, 0.765, 0.5802]}, {"w": "of", "b": [0.7704, 0.5606, 0.7857, 0.5802]}, {"w": "the", "b": [0.2714, 0.578, 0.2955, 0.5976]}, {"w": "estimated", "b": [0.3024, 0.578, 0.3759, 0.5976]}, {"w": "probability", "b": [0.3828, 0.578, 0.4668, 0.5976]}, {"w": "p,", "b": [0.4737, 0.5778, 0.4873, 0.5976]}, {"w": "you", "b": [0.4942, 0.578, 0.5227, 0.5976]}, {"w": "will", "b": [0.5296, 0.578, 0.5574, 0.5976]}, {"w": "find", "b": [0.5643, 0.578, 0.5955, 0.5976]}, {"w": "that", "b": [0.6023, 0.578, 0.6321, 0.5976]}, {"w": "the", "b": [0.639, 0.578, 0.6631, 0.5976]}, {"w": "result", "b": [0.6699, 0.578, 0.7128, 0.5976]}, {"w": "is", "b": [0.7197, 0.578, 0.7318, 0.5976]}, {"w": "t.", "b": [0.7386, 0.5778, 0.7488, 0.5976]}, {"w": "The", "b": [0.7557, 0.578, 0.7857, 0.5976]}, {"w": "logit", "b": [0.2714, 0.5954, 0.3058, 0.615]}, {"w": "is", "b": [0.3149, 0.5954, 0.327, 0.615]}, {"w": "also", "b": [0.3361, 0.5954, 0.366, 0.615]}, {"w": "called", "b": [0.3751, 0.5954, 0.4193, 0.615]}, {"w": "the", "b": [0.4284, 0.5954, 0.4525, 0.615]}, {"w": "log-odds,", "b": [0.4616, 0.5952, 0.5285, 0.615]}, {"w": "since", "b": [0.5377, 0.5954, 0.5763, 0.615]}, {"w": "it", "b": [0.5854, 0.5954, 0.5963, 0.615]}, {"w": "is", "b": [0.6054, 0.5954, 0.6175, 0.615]}, {"w": "the", "b": [0.6266, 0.5954, 0.6507, 0.615]}, {"w": "log", "b": [0.6598, 0.5954, 0.6833, 0.615]}, {"w": "of", "b": [0.6924, 0.5954, 0.7077, 0.615]}, {"w": "the", "b": [0.7168, 0.5954, 0.7409, 0.615]}, {"w": "ratio", "b": [0.75, 0.5954, 0.7857, 0.615]}, {"w": "between", "b": [0.2714, 0.6128, 0.3347, 0.6324]}, {"w": "the", "b": [0.343, 0.6128, 0.3671, 0.6324]}, {"w": "estimated", "b": [0.3754, 0.6128, 0.449, 0.6324]}, {"w": "probability", "b": [0.4573, 0.6128, 0.5414, 0.6324]}, {"w": "for", "b": [0.5497, 0.6128, 0.5722, 0.6324]}, {"w": "the", "b": [0.5805, 0.6128, 0.6046, 0.6324]}, {"w": "positive", "b": [0.6129, 0.6128, 0.6725, 0.6324]}, {"w": "class", "b": [0.6809, 0.6128, 0.7161, 0.6324]}, {"w": "and", "b": [0.7245, 0.6128, 0.7533, 0.6324]}, {"w": "the", "b": [0.7616, 0.6128, 0.7857, 0.6324]}, {"w": "estimated", "b": [0.2714, 0.6302, 0.345, 0.6498]}, {"w": "probability", "b": [0.3493, 0.6302, 0.4334, 0.6498]}, {"w": "for", "b": [0.4377, 0.6302, 0.4601, 0.6498]}, {"w": "the", "b": [0.4644, 0.6302, 0.4885, 0.6498]}, {"w": "negative", "b": [0.4928, 0.6302, 0.5561, 0.6498]}, {"w": "class.", "b": [0.5604, 0.6302, 0.6, 0.6498]}]}, {"id": "b_7", "type": "paragraph", "text": "Training and Cost Function", "words": [{"w": "Training", "b": [0.1429, 0.6674, 0.2288, 0.6959]}, {"w": "and", "b": [0.2338, 0.6674, 0.2731, 0.6959]}, {"w": "Cost", "b": [0.278, 0.6674, 0.3215, 0.6959]}, {"w": "Function", "b": [0.3264, 0.6674, 0.4165, 0.6959]}]}, {"id": "b_8", "type": "paragraph", "text": "Good, now you know how a Logistic Regression model estimates probabilities and makes predictions. But how is it trained? The objective of training is to set the param‐ eter vector θ so that the model estimates high probabilities for positive instances (y = 1) and low probabilities for negative instances (y = 0). This idea is captured by the cost function shown in Equation 4-16 for a single training instance x.", "words": [{"w": "Good,", "b": [0.1429, 0.7018, 0.1948, 0.7232]}, {"w": "now", "b": [0.2021, 0.7018, 0.2384, 0.7232]}, {"w": "you", "b": [0.2457, 0.7018, 0.2769, 0.7232]}, {"w": "know", "b": [0.2843, 0.7018, 0.3309, 0.7232]}, {"w": "how", "b": [0.3382, 0.7018, 0.3742, 0.7232]}, {"w": "a", "b": [0.3816, 0.7018, 0.3907, 0.7232]}, {"w": "Logistic", "b": [0.398, 0.7018, 0.4636, 0.7232]}, {"w": "Regression", "b": [0.4709, 0.7018, 0.5619, 0.7232]}, {"w": "model", "b": [0.5693, 0.7018, 0.6221, 0.7232]}, {"w": "estimates", "b": [0.6294, 0.7018, 0.7065, 0.7232]}, {"w": "probabilities", "b": [0.7138, 0.7018, 0.8183, 0.7232]}, {"w": "and", "b": [0.8256, 0.7018, 0.8571, 0.7232]}, {"w": "makes", "b": [0.1429, 0.7209, 0.1959, 0.7423]}, {"w": "predictions.", "b": [0.2006, 0.7209, 0.2999, 0.7423]}, {"w": "But", "b": [0.3046, 0.7209, 0.3343, 0.7423]}, {"w": "how", "b": [0.339, 0.7209, 0.375, 0.7423]}, {"w": "is", "b": [0.3798, 0.7209, 0.393, 0.7423]}, {"w": "it", "b": [0.3977, 0.7209, 0.4096, 0.7423]}, {"w": "trained?", "b": [0.4144, 0.7209, 0.4823, 0.7423]}, {"w": "The", "b": [0.4871, 0.7209, 0.5199, 0.7423]}, {"w": "objective", "b": [0.5246, 0.7209, 0.5993, 0.7423]}, {"w": "of", "b": [0.604, 0.7209, 0.6208, 0.7423]}, {"w": "training", "b": [0.6255, 0.7209, 0.6925, 0.7423]}, {"w": "is", "b": [0.6972, 0.7209, 0.7104, 0.7423]}, {"w": "to", "b": [0.7151, 0.7209, 0.7321, 0.7423]}, {"w": "set", "b": [0.7369, 0.7209, 0.7597, 0.7423]}, {"w": "the", "b": [0.7644, 0.7209, 0.7908, 0.7423]}, {"w": "param‐", "b": [0.7957, 0.7209, 0.8571, 0.7423]}, {"w": "eter", "b": [0.1429, 0.7399, 0.1746, 0.7613]}, {"w": "vector", "b": [0.1801, 0.7399, 0.2321, 0.7613]}, {"w": "θ", "b": [0.2375, 0.7394, 0.2481, 0.7613]}, {"w": "so", "b": [0.2535, 0.7399, 0.2717, 0.7613]}, {"w": "that", "b": [0.2772, 0.7399, 0.3097, 0.7613]}, {"w": "the", "b": [0.3151, 0.7399, 0.3415, 0.7613]}, {"w": "model", "b": [0.3469, 0.7399, 0.3997, 0.7613]}, {"w": "estimates", "b": [0.4051, 0.7399, 0.4822, 0.7613]}, {"w": "high", "b": [0.4876, 0.7399, 0.5252, 0.7613]}, {"w": "probabilities", "b": [0.5306, 0.7399, 0.635, 0.7613]}, {"w": "for", "b": [0.6405, 0.7399, 0.665, 0.7613]}, {"w": "positive", "b": [0.6704, 0.7399, 0.7356, 0.7613]}, {"w": "instances", "b": [0.741, 0.7399, 0.8178, 0.7613]}, {"w": "(y", "b": [0.8232, 0.7397, 0.8396, 0.7613]}, {"w": "=", "b": [0.8451, 0.7399, 0.8571, 0.7613]}, {"w": "1)", "b": [0.1429, 0.759, 0.1601, 0.7804]}, {"w": "and", "b": [0.1671, 0.759, 0.1986, 0.7804]}, {"w": "low", "b": [0.2056, 0.759, 0.2358, 0.7804]}, {"w": "probabilities", "b": [0.2428, 0.759, 0.3472, 0.7804]}, {"w": "for", "b": [0.3542, 0.759, 0.3787, 0.7804]}, {"w": "negative", "b": [0.3857, 0.759, 0.4549, 0.7804]}, {"w": "instances", "b": [0.4619, 0.759, 0.5387, 0.7804]}, {"w": "(y", "b": [0.5457, 0.7588, 0.5622, 0.7804]}, {"w": "=", "b": [0.5691, 0.759, 0.5812, 0.7804]}, {"w": "0).", "b": [0.5882, 0.759, 0.6102, 0.7804]}, {"w": "This", "b": [0.6172, 0.759, 0.6544, 0.7804]}, {"w": "idea", "b": [0.6614, 0.759, 0.696, 0.7804]}, {"w": "is", "b": [0.703, 0.759, 0.7162, 0.7804]}, {"w": "captured", "b": [0.7232, 0.759, 0.7967, 0.7804]}, {"w": "by", "b": [0.8037, 0.759, 0.8238, 0.7804]}, {"w": "the", "b": [0.8308, 0.759, 0.8571, 0.7804]}, {"w": "cost", "b": [0.1428, 0.778, 0.1763, 0.7994]}, {"w": "function", "b": [0.181, 0.778, 0.2524, 0.7994]}, {"w": "shown", "b": [0.2571, 0.778, 0.3122, 0.7994]}, {"w": "in", "b": [0.3169, 0.778, 0.3339, 0.7994]}, {"w": "Equation", "b": [0.3386, 0.778, 0.4149, 0.7994]}, {"w": "4-16", "b": [0.4196, 0.778, 0.457, 0.7994]}, {"w": "for", "b": [0.4618, 0.778, 0.4863, 0.7994]}, {"w": "a", "b": [0.491, 0.778, 0.5002, 0.7994]}, {"w": "single", "b": [0.5049, 0.778, 0.5534, 0.7994]}, {"w": "training", "b": [0.5581, 0.778, 0.6251, 0.7994]}, {"w": "instance", "b": [0.6298, 0.778, 0.699, 0.7994]}, {"w": "x.", "b": [0.7037, 0.7775, 0.7185, 0.7994]}]}, {"id": "b_9", "type": "equation", "text": "Equation 4-16. Cost function of a single training instance", "words": [{"w": "Equation", "b": [0.1726, 0.8175, 0.2473, 0.8392]}, {"w": "4-16.", "b": [0.2521, 0.8175, 0.2937, 0.8392]}, {"w": "Cost", "b": [0.2985, 0.8175, 0.3347, 0.8392]}, {"w": "function", "b": [0.3394, 0.8175, 0.4075, 0.8392]}, {"w": "of", "b": [0.4123, 0.8175, 0.4275, 0.8392]}, {"w": "a", "b": [0.4323, 0.8175, 0.4425, 0.8392]}, {"w": "single", "b": [0.4473, 0.8175, 0.4925, 0.8392]}, {"w": "training", "b": [0.4973, 0.8175, 0.5617, 0.8392]}, {"w": "instance", "b": [0.5665, 0.8175, 0.6329, 0.8392]}]}, {"id": "b_10", "type": "equation", "text": "c θ =", "words": [{"w": "c", "b": [0.1726, 0.8596, 0.1802, 0.8801]}, {"w": "θ", "b": [0.1871, 0.8592, 0.1972, 0.8801]}, {"w": "=", "b": [0.2095, 0.8597, 0.2211, 0.8801]}]}, {"id": "b_11", "type": "equation", "text": "−log p if y = 1", "words": [{"w": "−log", "b": [0.2484, 0.8472, 0.2854, 0.8676]}, {"w": "p", "b": [0.2937, 0.847, 0.3033, 0.8676]}, {"w": "if", "b": [0.334, 0.8472, 0.3452, 0.8676]}, {"w": "y", "b": [0.3508, 0.847, 0.3596, 0.8676]}, {"w": "=", "b": [0.3651, 0.8472, 0.3766, 0.8676]}, {"w": "1", "b": [0.3821, 0.8472, 0.3916, 0.8676]}]}, {"id": "b_12", "type": "equation", "text": "−log 1 −p if y = 0", "words": [{"w": "−log", "b": [0.2335, 0.8723, 0.2705, 0.8927]}, {"w": "1", "b": [0.2773, 0.8723, 0.2869, 0.8927]}, {"w": "−p", "b": [0.2913, 0.8721, 0.3182, 0.8927]}, {"w": "if", "b": [0.334, 0.8723, 0.3452, 0.8927]}, {"w": "y", "b": [0.3508, 0.8721, 0.3596, 0.8927]}, {"w": "=", "b": [0.3651, 0.8723, 0.3766, 0.8927]}, {"w": "0", "b": [0.3821, 0.8723, 0.3916, 0.8927]}]}, {"id": "b_13", "type": "paragraph", "text": "Logistic Regression | 145", "words": [{"w": "Logistic", "b": [0.6839, 0.9225, 0.7288, 0.9388]}, {"w": "Regression", "b": [0.7316, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "145", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 172, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "This cost function makes sense because – log(t) grows very large when t approaches 0, so the cost will be large if the model estimates a probability close to 0 for a positive instance, and it will also be very large if the model estimates a probability close to 1 for a negative instance. On the other hand, – log(t) is close to 0 when t is close to 1, so the cost will be close to 0 if the estimated probability is close to 0 for a negative instance or close to 1 for a positive instance, which is precisely what we want.", "words": [{"w": "This", "b": [0.1429, 0.0791, 0.1801, 0.1005]}, {"w": "cost", "b": [0.1862, 0.0791, 0.2196, 0.1005]}, {"w": "function", "b": [0.2257, 0.0791, 0.2971, 0.1005]}, {"w": "makes", "b": [0.3032, 0.0791, 0.3562, 0.1005]}, {"w": "sense", "b": [0.3623, 0.0791, 0.4067, 0.1005]}, {"w": "because", "b": [0.4128, 0.0791, 0.4774, 0.1005]}, {"w": "–", "b": [0.4835, 0.0791, 0.4943, 0.1005]}, {"w": "log(t)", "b": [0.5004, 0.0789, 0.5468, 0.1005]}, {"w": "grows", "b": [0.5529, 0.0791, 0.603, 0.1005]}, {"w": "very", "b": [0.6091, 0.0791, 0.6455, 0.1005]}, {"w": "large", "b": [0.6515, 0.0791, 0.6923, 0.1005]}, {"w": "when", "b": [0.6984, 0.0791, 0.744, 0.1005]}, {"w": "t", "b": [0.7501, 0.0789, 0.7565, 0.1005]}, {"w": "approaches", "b": [0.7626, 0.0791, 0.8571, 0.1005]}, {"w": "0,", "b": [0.1429, 0.0981, 0.1576, 0.1195]}, {"w": "so", "b": [0.1629, 0.0981, 0.1811, 0.1195]}, {"w": "the", "b": [0.1864, 0.0981, 0.2127, 0.1195]}, {"w": "cost", "b": [0.218, 0.0981, 0.2514, 0.1195]}, {"w": "will", "b": [0.2567, 0.0981, 0.2871, 0.1195]}, {"w": "be", "b": [0.2924, 0.0981, 0.3118, 0.1195]}, {"w": "large", "b": [0.3171, 0.0981, 0.3578, 0.1195]}, {"w": "if", "b": [0.3631, 0.0981, 0.3748, 0.1195]}, {"w": "the", "b": [0.3801, 0.0981, 0.4064, 0.1195]}, {"w": "model", "b": [0.4117, 0.0981, 0.4645, 0.1195]}, {"w": "estimates", "b": [0.4698, 0.0981, 0.5469, 0.1195]}, {"w": "a", "b": [0.5521, 0.0981, 0.5613, 0.1195]}, {"w": "probability", "b": [0.5665, 0.0981, 0.6585, 0.1195]}, {"w": "close", "b": [0.6638, 0.0981, 0.705, 0.1195]}, {"w": "to", "b": [0.7102, 0.0981, 0.7272, 0.1195]}, {"w": "0", "b": [0.7325, 0.0981, 0.7425, 0.1195]}, {"w": "for", "b": [0.7477, 0.0981, 0.7723, 0.1195]}, {"w": "a", "b": [0.7775, 0.0981, 0.7867, 0.1195]}, {"w": "positive", "b": [0.7919, 0.0981, 0.8571, 0.1195]}, {"w": "instance,", "b": [0.1429, 0.1172, 0.2168, 0.1386]}, {"w": "and", "b": [0.2231, 0.1172, 0.2546, 0.1386]}, {"w": "it", "b": [0.2608, 0.1172, 0.2728, 0.1386]}, {"w": "will", "b": [0.279, 0.1172, 0.3094, 0.1386]}, {"w": "also", "b": [0.3157, 0.1172, 0.3483, 0.1386]}, {"w": "be", "b": [0.3546, 0.1172, 0.374, 0.1386]}, {"w": "very", "b": [0.3803, 0.1172, 0.4167, 0.1386]}, {"w": "large", "b": [0.4229, 0.1172, 0.4637, 0.1386]}, {"w": "if", "b": [0.4699, 0.1172, 0.4817, 0.1386]}, {"w": "the", "b": [0.4879, 0.1172, 0.5142, 0.1386]}, {"w": "model", "b": [0.5205, 0.1172, 0.5733, 0.1386]}, {"w": "estimates", "b": [0.5795, 0.1172, 0.6567, 0.1386]}, {"w": "a", "b": [0.6629, 0.1172, 0.672, 0.1386]}, {"w": "probability", "b": [0.6783, 0.1172, 0.7702, 0.1386]}, {"w": "close", "b": [0.7765, 0.1172, 0.8177, 0.1386]}, {"w": "to", "b": [0.8239, 0.1172, 0.8409, 0.1386]}, {"w": "1", "b": [0.8472, 0.1172, 0.8572, 0.1386]}, {"w": "for", "b": [0.1429, 0.1362, 0.1674, 0.1576]}, {"w": "a", "b": [0.1722, 0.1362, 0.1814, 0.1576]}, {"w": "negative", "b": [0.1862, 0.1362, 0.2554, 0.1576]}, {"w": "instance.", "b": [0.2603, 0.1362, 0.3342, 0.1576]}, {"w": "On", "b": [0.339, 0.1362, 0.366, 0.1576]}, {"w": "the", "b": [0.3708, 0.1362, 0.3972, 0.1576]}, {"w": "other", "b": [0.402, 0.1362, 0.4467, 0.1576]}, {"w": "hand,", "b": [0.4516, 0.1362, 0.499, 0.1576]}, {"w": "–", "b": [0.5038, 0.1362, 0.5146, 0.1576]}, {"w": "log(t)", "b": [0.5195, 0.136, 0.5659, 0.1576]}, {"w": "is", "b": [0.5708, 0.1362, 0.584, 0.1576]}, {"w": "close", "b": [0.5889, 0.1362, 0.6301, 0.1576]}, {"w": "to", "b": [0.6349, 0.1362, 0.6519, 0.1576]}, {"w": "0", "b": [0.6567, 0.1362, 0.6667, 0.1576]}, {"w": "when", "b": [0.6716, 0.1362, 0.7172, 0.1576]}, {"w": "t", "b": [0.7221, 0.136, 0.7285, 0.1576]}, {"w": "is", "b": [0.7333, 0.1362, 0.7465, 0.1576]}, {"w": "close", "b": [0.7513, 0.1362, 0.7925, 0.1576]}, {"w": "to", "b": [0.7972, 0.1362, 0.8142, 0.1576]}, {"w": "1,", "b": [0.8189, 0.1362, 0.8337, 0.1576]}, {"w": "so", "b": [0.8384, 0.1362, 0.8567, 0.1576]}, {"w": "the", "b": [0.1429, 0.1553, 0.1692, 0.1767]}, {"w": "cost", "b": [0.1775, 0.1553, 0.211, 0.1767]}, {"w": "will", "b": [0.2193, 0.1553, 0.2497, 0.1767]}, {"w": "be", "b": [0.258, 0.1553, 0.2775, 0.1767]}, {"w": "close", "b": [0.2858, 0.1553, 0.327, 0.1767]}, {"w": "to", "b": [0.3354, 0.1553, 0.3523, 0.1767]}, {"w": "0", "b": [0.3607, 0.1553, 0.3707, 0.1767]}, {"w": "if", "b": [0.379, 0.1553, 0.3908, 0.1767]}, {"w": "the", "b": [0.3991, 0.1553, 0.4254, 0.1767]}, {"w": "estimated", "b": [0.4338, 0.1553, 0.5142, 0.1767]}, {"w": "probability", "b": [0.5226, 0.1553, 0.6145, 0.1767]}, {"w": "is", "b": [0.6228, 0.1553, 0.6361, 0.1767]}, {"w": "close", "b": [0.6444, 0.1553, 0.6856, 0.1767]}, {"w": "to", "b": [0.694, 0.1553, 0.7109, 0.1767]}, {"w": "0", "b": [0.7193, 0.1553, 0.7293, 0.1767]}, {"w": "for", "b": [0.7376, 0.1553, 0.7621, 0.1767]}, {"w": "a", "b": [0.7705, 0.1553, 0.7796, 0.1767]}, {"w": "negative", "b": [0.788, 0.1553, 0.8571, 0.1767]}, {"w": "instance", "b": [0.1428, 0.1743, 0.212, 0.1957]}, {"w": "or", "b": [0.2168, 0.1743, 0.2351, 0.1957]}, {"w": "close", "b": [0.2398, 0.1743, 0.2811, 0.1957]}, {"w": "to", "b": [0.2858, 0.1743, 0.3028, 0.1957]}, {"w": "1", "b": [0.3075, 0.1743, 0.3175, 0.1957]}, {"w": "for", "b": [0.3222, 0.1743, 0.3467, 0.1957]}, {"w": "a", "b": [0.3515, 0.1743, 0.3606, 0.1957]}, {"w": "positive", "b": [0.3653, 0.1743, 0.4306, 0.1957]}, {"w": "instance,", "b": [0.4353, 0.1743, 0.5092, 0.1957]}, {"w": "which", "b": [0.514, 0.1743, 0.5649, 0.1957]}, {"w": "is", "b": [0.5696, 0.1743, 0.5828, 0.1957]}, {"w": "precisely", "b": [0.5876, 0.1743, 0.6608, 0.1957]}, {"w": "what", "b": [0.6655, 0.1743, 0.706, 0.1957]}, {"w": "we", "b": [0.7107, 0.1743, 0.7339, 0.1957]}, {"w": "want.", "b": [0.7386, 0.1743, 0.7841, 0.1957]}]}, {"id": "b_1", "type": "paragraph", "text": "The cost function over the whole training set is simply the average cost over all train‐ ing instances. It can be written in a single expression (as you can verify easily), called the log loss, shown in Equation 4-17.", "words": [{"w": "The", "b": [0.1428, 0.2024, 0.1757, 0.2238]}, {"w": "cost", "b": [0.1809, 0.2024, 0.2143, 0.2238]}, {"w": "function", "b": [0.2195, 0.2024, 0.2909, 0.2238]}, {"w": "over", "b": [0.2961, 0.2024, 0.333, 0.2238]}, {"w": "the", "b": [0.3382, 0.2024, 0.3645, 0.2238]}, {"w": "whole", "b": [0.3697, 0.2024, 0.4198, 0.2238]}, {"w": "training", "b": [0.425, 0.2024, 0.492, 0.2238]}, {"w": "set", "b": [0.4972, 0.2024, 0.52, 0.2238]}, {"w": "is", "b": [0.5252, 0.2024, 0.5384, 0.2238]}, {"w": "simply", "b": [0.5436, 0.2024, 0.5993, 0.2238]}, {"w": "the", "b": [0.6045, 0.2024, 0.6308, 0.2238]}, {"w": "average", "b": [0.636, 0.2024, 0.6987, 0.2238]}, {"w": "cost", "b": [0.7039, 0.2024, 0.7374, 0.2238]}, {"w": "over", "b": [0.7426, 0.2024, 0.7794, 0.2238]}, {"w": "all", "b": [0.7846, 0.2024, 0.8043, 0.2238]}, {"w": "train‐", "b": [0.8095, 0.2024, 0.8571, 0.2238]}, {"w": "ing", "b": [0.1429, 0.2215, 0.1696, 0.2429]}, {"w": "instances.", "b": [0.1747, 0.2215, 0.2563, 0.2429]}, {"w": "It", "b": [0.2614, 0.2215, 0.274, 0.2429]}, {"w": "can", "b": [0.2791, 0.2215, 0.3084, 0.2429]}, {"w": "be", "b": [0.3135, 0.2215, 0.333, 0.2429]}, {"w": "written", "b": [0.3381, 0.2215, 0.3986, 0.2429]}, {"w": "in", "b": [0.4037, 0.2215, 0.4207, 0.2429]}, {"w": "a", "b": [0.4258, 0.2215, 0.4349, 0.2429]}, {"w": "single", "b": [0.44, 0.2215, 0.4885, 0.2429]}, {"w": "expression", "b": [0.4936, 0.2215, 0.5827, 0.2429]}, {"w": "(as", "b": [0.5877, 0.2215, 0.6117, 0.2429]}, {"w": "you", "b": [0.6168, 0.2215, 0.6481, 0.2429]}, {"w": "can", "b": [0.6532, 0.2215, 0.6825, 0.2429]}, {"w": "verify", "b": [0.6876, 0.2215, 0.7355, 0.2429]}, {"w": "easily),", "b": [0.7406, 0.2215, 0.7986, 0.2429]}, {"w": "called", "b": [0.8037, 0.2215, 0.8521, 0.2429]}, {"w": "the", "b": [0.1429, 0.2405, 0.1692, 0.2619]}, {"w": "log", "b": [0.1739, 0.2403, 0.1976, 0.2619]}, {"w": "loss,", "b": [0.2023, 0.2403, 0.2357, 0.2619]}, {"w": "shown", "b": [0.2404, 0.2405, 0.2955, 0.2619]}, {"w": "in", "b": [0.3002, 0.2405, 0.3172, 0.2619]}, {"w": "Equation", "b": [0.3219, 0.2405, 0.3982, 0.2619]}, {"w": "4-17.", "b": [0.4029, 0.2405, 0.4451, 0.2619]}]}, {"id": "b_2", "type": "equation", "text": "Equation 4-17. Logistic Regression cost function (log loss)", "words": [{"w": "Equation", "b": [0.1726, 0.28, 0.2473, 0.3017]}, {"w": "4-17.", "b": [0.252, 0.28, 0.2937, 0.3017]}, {"w": "Logistic", "b": [0.2985, 0.28, 0.3607, 0.3017]}, {"w": "Regression", "b": [0.3654, 0.28, 0.4502, 0.3017]}, {"w": "cost", "b": [0.4549, 0.28, 0.4856, 0.3017]}, {"w": "function", "b": [0.4904, 0.28, 0.5585, 0.3017]}, {"w": "(log", "b": [0.5633, 0.28, 0.5939, 0.3017]}, {"w": "loss)", "b": [0.5987, 0.28, 0.6343, 0.3017]}]}, {"id": "b_3", "type": "equation", "text": "J θ = −1", "words": [{"w": "J", "b": [0.1731, 0.3136, 0.1795, 0.3342]}, {"w": "θ", "b": [0.1874, 0.3133, 0.1975, 0.3342]}, {"w": "=", "b": [0.2098, 0.3138, 0.2213, 0.3342]}, {"w": "−1", "b": [0.2269, 0.3088, 0.2517, 0.3342]}]}, {"id": "b_4", "type": "equation", "text": "m ∑i = 1", "words": [{"w": "m", "b": [0.2417, 0.3233, 0.2542, 0.3397]}, {"w": "∑i", "b": [0.2575, 0.3138, 0.2724, 0.3385]}, {"w": "=", "b": [0.2768, 0.3222, 0.286, 0.3385]}, {"w": "1", "b": [0.2905, 0.3222, 0.2981, 0.3385]}]}, {"id": "b_5", "type": "equation", "text": "m y i log p i + 1 −y i log 1 −p i", "words": [{"w": "m", "b": [0.2681, 0.3099, 0.2806, 0.3264]}, {"w": "y", "b": [0.3083, 0.3136, 0.317, 0.3342]}, {"w": "i", "b": [0.3225, 0.3099, 0.3269, 0.3264]}, {"w": "log", "b": [0.3324, 0.3136, 0.356, 0.3342]}, {"w": "p", "b": [0.3652, 0.3136, 0.3749, 0.3342]}, {"w": "i", "b": [0.3806, 0.3095, 0.3849, 0.3259]}, {"w": "+", "b": [0.4017, 0.3138, 0.4132, 0.3342]}, {"w": "1", "b": [0.4245, 0.3138, 0.434, 0.3342]}, {"w": "−y", "b": [0.4384, 0.3136, 0.4642, 0.3342]}, {"w": "i", "b": [0.4697, 0.3099, 0.4741, 0.3264]}, {"w": "log", "b": [0.4864, 0.3136, 0.51, 0.3342]}, {"w": "1", "b": [0.5179, 0.3138, 0.5274, 0.3342]}, {"w": "−p", "b": [0.5318, 0.3136, 0.5588, 0.3342]}, {"w": "i", "b": [0.5645, 0.3095, 0.5688, 0.3259]}]}, {"id": "b_6", "type": "paragraph", "text": "The bad news is that there is no known closed-form equation to compute the value of θ that minimizes this cost function (there is no equivalent of the Normal Equation). But the good news is that this cost function is convex, so Gradient Descent (or any other optimization algorithm) is guaranteed to find the global minimum (if the learn‐ ing rate is not too large and you wait long enough). The partial derivatives of the cost function with regards to the jth model parameter θj is given by Equation 4-18.", "words": [{"w": "The", "b": [0.1429, 0.3588, 0.1757, 0.3802]}, {"w": "bad", "b": [0.1807, 0.3588, 0.2114, 0.3802]}, {"w": "news", "b": [0.2164, 0.3588, 0.2585, 0.3802]}, {"w": "is", "b": [0.2635, 0.3588, 0.2768, 0.3802]}, {"w": "that", "b": [0.2817, 0.3588, 0.3143, 0.3802]}, {"w": "there", "b": [0.3193, 0.3588, 0.3622, 0.3802]}, {"w": "is", "b": [0.3672, 0.3588, 0.3804, 0.3802]}, {"w": "no", "b": [0.3854, 0.3588, 0.4074, 0.3802]}, {"w": "known", "b": [0.4124, 0.3588, 0.4704, 0.3802]}, {"w": "closed-form", "b": [0.4754, 0.3588, 0.5766, 0.3802]}, {"w": "equation", "b": [0.5816, 0.3588, 0.6549, 0.3802]}, {"w": "to", "b": [0.6598, 0.3588, 0.6768, 0.3802]}, {"w": "compute", "b": [0.6818, 0.3588, 0.7551, 0.3802]}, {"w": "the", "b": [0.7601, 0.3588, 0.7864, 0.3802]}, {"w": "value", "b": [0.7914, 0.3588, 0.8354, 0.3802]}, {"w": "of", "b": [0.8403, 0.3588, 0.8571, 0.3802]}, {"w": "θ", "b": [0.1429, 0.3773, 0.1535, 0.3993]}, {"w": "that", "b": [0.1596, 0.3778, 0.1922, 0.3993]}, {"w": "minimizes", "b": [0.1984, 0.3778, 0.2859, 0.3993]}, {"w": "this", "b": [0.2921, 0.3778, 0.3228, 0.3993]}, {"w": "cost", "b": [0.3289, 0.3778, 0.3624, 0.3993]}, {"w": "function", "b": [0.3685, 0.3778, 0.4399, 0.3993]}, {"w": "(there", "b": [0.4461, 0.3778, 0.4962, 0.3993]}, {"w": "is", "b": [0.5024, 0.3778, 0.5156, 0.3993]}, {"w": "no", "b": [0.5218, 0.3778, 0.5438, 0.3993]}, {"w": "equivalent", "b": [0.55, 0.3778, 0.6364, 0.3993]}, {"w": "of", "b": [0.6425, 0.3778, 0.6593, 0.3993]}, {"w": "the", "b": [0.6655, 0.3778, 0.6918, 0.3993]}, {"w": "Normal", "b": [0.698, 0.3778, 0.7628, 0.3993]}, {"w": "Equation).", "b": [0.7689, 0.3778, 0.8572, 0.3993]}, {"w": "But", "b": [0.1429, 0.3969, 0.1725, 0.4183]}, {"w": "the", "b": [0.1793, 0.3969, 0.2056, 0.4183]}, {"w": "good", "b": [0.2124, 0.3969, 0.2544, 0.4183]}, {"w": "news", "b": [0.2611, 0.3969, 0.3033, 0.4183]}, {"w": "is", "b": [0.31, 0.3969, 0.3233, 0.4183]}, {"w": "that", "b": [0.33, 0.3969, 0.3626, 0.4183]}, {"w": "this", "b": [0.3693, 0.3969, 0.4, 0.4183]}, {"w": "cost", "b": [0.4068, 0.3969, 0.4402, 0.4183]}, {"w": "function", "b": [0.447, 0.3969, 0.5184, 0.4183]}, {"w": "is", "b": [0.5251, 0.3969, 0.5384, 0.4183]}, {"w": "convex,", "b": [0.5451, 0.3969, 0.6085, 0.4183]}, {"w": "so", "b": [0.6153, 0.3969, 0.6336, 0.4183]}, {"w": "Gradient", "b": [0.6403, 0.3969, 0.7149, 0.4183]}, {"w": "Descent", "b": [0.7216, 0.3969, 0.7885, 0.4183]}, {"w": "(or", "b": [0.7952, 0.3969, 0.8208, 0.4183]}, {"w": "any", "b": [0.8275, 0.3969, 0.8571, 0.4183]}, {"w": "other", "b": [0.1429, 0.4159, 0.1875, 0.4373]}, {"w": "optimization", "b": [0.1924, 0.4159, 0.3, 0.4373]}, {"w": "algorithm)", "b": [0.3049, 0.4159, 0.3947, 0.4373]}, {"w": "is", "b": [0.3996, 0.4159, 0.4128, 0.4373]}, {"w": "guaranteed", "b": [0.4177, 0.4159, 0.5106, 0.4373]}, {"w": "to", "b": [0.5154, 0.4159, 0.5324, 0.4373]}, {"w": "find", "b": [0.5373, 0.4159, 0.5714, 0.4373]}, {"w": "the", "b": [0.5763, 0.4159, 0.6026, 0.4373]}, {"w": "global", "b": [0.6075, 0.4159, 0.6581, 0.4373]}, {"w": "minimum", "b": [0.663, 0.4159, 0.7474, 0.4373]}, {"w": "(if", "b": [0.7523, 0.4159, 0.7713, 0.4373]}, {"w": "the", "b": [0.7761, 0.4159, 0.8025, 0.4373]}, {"w": "learn‐", "b": [0.8073, 0.4159, 0.8571, 0.4373]}, {"w": "ing", "b": [0.1428, 0.435, 0.1696, 0.4564]}, {"w": "rate", "b": [0.1748, 0.435, 0.2064, 0.4564]}, {"w": "is", "b": [0.2116, 0.435, 0.2248, 0.4564]}, {"w": "not", "b": [0.23, 0.435, 0.2584, 0.4564]}, {"w": "too", "b": [0.2636, 0.435, 0.2912, 0.4564]}, {"w": "large", "b": [0.2963, 0.435, 0.3371, 0.4564]}, {"w": "and", "b": [0.3423, 0.435, 0.3738, 0.4564]}, {"w": "you", "b": [0.379, 0.435, 0.4102, 0.4564]}, {"w": "wait", "b": [0.4154, 0.435, 0.4508, 0.4564]}, {"w": "long", "b": [0.4559, 0.435, 0.493, 0.4564]}, {"w": "enough).", "b": [0.4981, 0.435, 0.5729, 0.4564]}, {"w": "The", "b": [0.5781, 0.435, 0.6109, 0.4564]}, {"w": "partial", "b": [0.6161, 0.435, 0.6702, 0.4564]}, {"w": "derivatives", "b": [0.6754, 0.435, 0.7651, 0.4564]}, {"w": "of", "b": [0.7702, 0.435, 0.787, 0.4564]}, {"w": "the", "b": [0.7922, 0.435, 0.8185, 0.4564]}, {"w": "cost", "b": [0.8237, 0.435, 0.8571, 0.4564]}, {"w": "function", "b": [0.1429, 0.454, 0.2143, 0.4754]}, {"w": "with", "b": [0.219, 0.454, 0.2563, 0.4754]}, {"w": "regards", "b": [0.2611, 0.454, 0.3229, 0.4754]}, {"w": "to", "b": [0.3276, 0.454, 0.3446, 0.4754]}, {"w": "the", "b": [0.3493, 0.454, 0.3757, 0.4754]}, {"w": "jth", "b": [0.3804, 0.454, 0.3962, 0.4754]}, {"w": "model", "b": [0.4009, 0.454, 0.4538, 0.4754]}, {"w": "parameter", "b": [0.4585, 0.454, 0.5443, 0.4754]}, {"w": "θj", "b": [0.549, 0.4538, 0.5623, 0.4763]}, {"w": "is", "b": [0.567, 0.454, 0.5802, 0.4754]}, {"w": "given", "b": [0.585, 0.454, 0.6302, 0.4754]}, {"w": "by", "b": [0.6349, 0.454, 0.6551, 0.4754]}, {"w": "Equation", "b": [0.6598, 0.454, 0.736, 0.4754]}, {"w": "4-18.", "b": [0.7408, 0.454, 0.7829, 0.4754]}]}, {"id": "b_7", "type": "equation", "text": "Equation 4-18. Logistic cost function partial derivatives", "words": [{"w": "Equation", "b": [0.1726, 0.4936, 0.2473, 0.5152]}, {"w": "4-18.", "b": [0.2521, 0.4936, 0.2937, 0.5152]}, {"w": "Logistic", "b": [0.2985, 0.4936, 0.3607, 0.5152]}, {"w": "cost", "b": [0.3654, 0.4936, 0.3961, 0.5152]}, {"w": "function", "b": [0.4009, 0.4936, 0.469, 0.5152]}, {"w": "partial", "b": [0.4738, 0.4936, 0.5287, 0.5152]}, {"w": "derivatives", "b": [0.5335, 0.4936, 0.6205, 0.5152]}]}, {"id": "b_8", "type": "paragraph", "text": "∂ ∂θj", "words": [{"w": "∂", "b": [0.1825, 0.5263, 0.1922, 0.5467]}, {"w": "∂θj", "b": [0.1748, 0.5438, 0.1998, 0.5686]}]}, {"id": "b_9", "type": "equation", "text": "J θ = 1", "words": [{"w": "J", "b": [0.2021, 0.5352, 0.2086, 0.5556]}, {"w": "θ", "b": [0.2154, 0.5346, 0.2255, 0.5556]}, {"w": "=", "b": [0.2379, 0.5352, 0.2494, 0.5556]}, {"w": "1", "b": [0.2602, 0.5263, 0.2697, 0.5467]}]}, {"id": "b_10", "type": "paragraph", "text": "m ∑", "words": [{"w": "m", "b": [0.2572, 0.5438, 0.2728, 0.5644]}, {"w": "∑", "b": [0.2835, 0.5304, 0.2986, 0.5592]}]}, {"id": "b_11", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.2761, 0.5498, 0.2804, 0.5663]}, {"w": "=", "b": [0.2848, 0.55, 0.294, 0.5663]}, {"w": "1", "b": [0.2984, 0.55, 0.3061, 0.5663]}]}, {"id": "b_13", "type": "paragraph", "text": "σ θTx i −y i xj", "words": [{"w": "σ", "b": [0.3151, 0.535, 0.3246, 0.5556]}, {"w": "θTx", "b": [0.3323, 0.5313, 0.3623, 0.5556]}, {"w": "i", "b": [0.3679, 0.5313, 0.3722, 0.5477]}, {"w": "−y", "b": [0.389, 0.535, 0.4148, 0.5556]}, {"w": "i", "b": [0.4203, 0.5313, 0.4246, 0.5477]}, {"w": "xj", "b": [0.4403, 0.535, 0.4555, 0.5598]}]}, {"id": "b_15", "type": "paragraph", "text": "This equation looks very much like Equation 4-5: for each instance it computes the prediction error and multiplies it by the jth feature value, and then it computes the average over all training instances. Once you have the gradient vector containing all the partial derivatives you can use it in the Batch Gradient Descent algorithm. That’s it: you now know how to train a Logistic Regression model. For Stochastic GD you would of course just take one instance at a time, and for Mini-batch GD you would use a mini-batch at a time.", "words": [{"w": "This", "b": [0.1429, 0.5877, 0.1801, 0.6091]}, {"w": "equation", "b": [0.1867, 0.5877, 0.2599, 0.6091]}, {"w": "looks", "b": [0.2666, 0.5877, 0.3111, 0.6091]}, {"w": "very", "b": [0.3177, 0.5877, 0.3541, 0.6091]}, {"w": "much", "b": [0.3607, 0.5877, 0.4083, 0.6091]}, {"w": "like", "b": [0.4149, 0.5877, 0.445, 0.6091]}, {"w": "Equation", "b": [0.4516, 0.5877, 0.5279, 0.6091]}, {"w": "4-5:", "b": [0.5345, 0.5877, 0.5666, 0.6091]}, {"w": "for", "b": [0.5732, 0.5877, 0.5978, 0.6091]}, {"w": "each", "b": [0.6044, 0.5877, 0.6423, 0.6091]}, {"w": "instance", "b": [0.6489, 0.5877, 0.7181, 0.6091]}, {"w": "it", "b": [0.7247, 0.5877, 0.7367, 0.6091]}, {"w": "computes", "b": [0.7433, 0.5877, 0.8242, 0.6091]}, {"w": "the", "b": [0.8308, 0.5877, 0.8571, 0.6091]}, {"w": "prediction", "b": [0.1429, 0.6067, 0.2297, 0.6282]}, {"w": "error", "b": [0.2369, 0.6067, 0.2796, 0.6282]}, {"w": "and", "b": [0.2868, 0.6067, 0.3183, 0.6282]}, {"w": "multiplies", "b": [0.3255, 0.6067, 0.4087, 0.6282]}, {"w": "it", "b": [0.4159, 0.6067, 0.4279, 0.6282]}, {"w": "by", "b": [0.4351, 0.6067, 0.4552, 0.6282]}, {"w": "the", "b": [0.4624, 0.6067, 0.4887, 0.6282]}, {"w": "jth", "b": [0.4959, 0.6067, 0.5118, 0.6282]}, {"w": "feature", "b": [0.519, 0.6067, 0.5767, 0.6282]}, {"w": "value,", "b": [0.5839, 0.6067, 0.6327, 0.6282]}, {"w": "and", "b": [0.6399, 0.6067, 0.6714, 0.6282]}, {"w": "then", "b": [0.6786, 0.6067, 0.7163, 0.6282]}, {"w": "it", "b": [0.7235, 0.6067, 0.7355, 0.6282]}, {"w": "computes", "b": [0.7427, 0.6067, 0.8236, 0.6282]}, {"w": "the", "b": [0.8308, 0.6067, 0.8571, 0.6282]}, {"w": "average", "b": [0.1429, 0.6258, 0.2056, 0.6472]}, {"w": "over", "b": [0.2119, 0.6258, 0.2487, 0.6472]}, {"w": "all", "b": [0.255, 0.6258, 0.2747, 0.6472]}, {"w": "training", "b": [0.2809, 0.6258, 0.3479, 0.6472]}, {"w": "instances.", "b": [0.3541, 0.6258, 0.4357, 0.6472]}, {"w": "Once", "b": [0.442, 0.6258, 0.4866, 0.6472]}, {"w": "you", "b": [0.4928, 0.6258, 0.5241, 0.6472]}, {"w": "have", "b": [0.5304, 0.6258, 0.5687, 0.6472]}, {"w": "the", "b": [0.575, 0.6258, 0.6013, 0.6472]}, {"w": "gradient", "b": [0.6076, 0.6258, 0.677, 0.6472]}, {"w": "vector", "b": [0.6833, 0.6258, 0.7353, 0.6472]}, {"w": "containing", "b": [0.7416, 0.6258, 0.8312, 0.6472]}, {"w": "all", "b": [0.8375, 0.6258, 0.8571, 0.6472]}, {"w": "the", "b": [0.1429, 0.6448, 0.1692, 0.6662]}, {"w": "partial", "b": [0.175, 0.6448, 0.2292, 0.6662]}, {"w": "derivatives", "b": [0.235, 0.6448, 0.3246, 0.6662]}, {"w": "you", "b": [0.3305, 0.6448, 0.3617, 0.6662]}, {"w": "can", "b": [0.3676, 0.6448, 0.3969, 0.6662]}, {"w": "use", "b": [0.4027, 0.6448, 0.4303, 0.6662]}, {"w": "it", "b": [0.4361, 0.6448, 0.4481, 0.6662]}, {"w": "in", "b": [0.4539, 0.6448, 0.4709, 0.6662]}, {"w": "the", "b": [0.4767, 0.6448, 0.5031, 0.6662]}, {"w": "Batch", "b": [0.5089, 0.6448, 0.5562, 0.6662]}, {"w": "Gradient", "b": [0.562, 0.6448, 0.6366, 0.6662]}, {"w": "Descent", "b": [0.6424, 0.6448, 0.7092, 0.6662]}, {"w": "algorithm.", "b": [0.7151, 0.6448, 0.8025, 0.6662]}, {"w": "That’s", "b": [0.8083, 0.6448, 0.8571, 0.6662]}, {"w": "it:", "b": [0.1429, 0.6639, 0.1596, 0.6853]}, {"w": "you", "b": [0.1661, 0.6639, 0.1974, 0.6853]}, {"w": "now", "b": [0.204, 0.6639, 0.2403, 0.6853]}, {"w": "know", "b": [0.2468, 0.6639, 0.2935, 0.6853]}, {"w": "how", "b": [0.3001, 0.6639, 0.3361, 0.6853]}, {"w": "to", "b": [0.3427, 0.6639, 0.3596, 0.6853]}, {"w": "train", "b": [0.3662, 0.6639, 0.4064, 0.6853]}, {"w": "a", "b": [0.413, 0.6639, 0.4222, 0.6853]}, {"w": "Logistic", "b": [0.4287, 0.6639, 0.4943, 0.6853]}, {"w": "Regression", "b": [0.5009, 0.6639, 0.5919, 0.6853]}, {"w": "model.", "b": [0.5985, 0.6639, 0.6561, 0.6853]}, {"w": "For", "b": [0.6626, 0.6639, 0.6916, 0.6853]}, {"w": "Stochastic", "b": [0.6982, 0.6639, 0.7825, 0.6853]}, {"w": "GD", "b": [0.7891, 0.6639, 0.8193, 0.6853]}, {"w": "you", "b": [0.8259, 0.6639, 0.8572, 0.6853]}, {"w": "would", "b": [0.1429, 0.6829, 0.1951, 0.7043]}, {"w": "of", "b": [0.2014, 0.6829, 0.2182, 0.7043]}, {"w": "course", "b": [0.2245, 0.6829, 0.2792, 0.7043]}, {"w": "just", "b": [0.2855, 0.6829, 0.3159, 0.7043]}, {"w": "take", "b": [0.3222, 0.6829, 0.3569, 0.7043]}, {"w": "one", "b": [0.3632, 0.6829, 0.3941, 0.7043]}, {"w": "instance", "b": [0.4004, 0.6829, 0.4696, 0.7043]}, {"w": "at", "b": [0.4759, 0.6829, 0.491, 0.7043]}, {"w": "a", "b": [0.4973, 0.6829, 0.5065, 0.7043]}, {"w": "time,", "b": [0.5128, 0.6829, 0.5554, 0.7043]}, {"w": "and", "b": [0.5617, 0.6829, 0.5932, 0.7043]}, {"w": "for", "b": [0.5995, 0.6829, 0.6241, 0.7043]}, {"w": "Mini-batch", "b": [0.6304, 0.6829, 0.7245, 0.7043]}, {"w": "GD", "b": [0.7308, 0.6829, 0.7611, 0.7043]}, {"w": "you", "b": [0.7674, 0.6829, 0.7986, 0.7043]}, {"w": "would", "b": [0.8049, 0.6829, 0.8571, 0.7043]}, {"w": "use", "b": [0.1429, 0.702, 0.1704, 0.7234]}, {"w": "a", "b": [0.1751, 0.702, 0.1843, 0.7234]}, {"w": "mini-batch", "b": [0.189, 0.702, 0.2817, 0.7234]}, {"w": "at", "b": [0.2864, 0.702, 0.3015, 0.7234]}, {"w": "a", "b": [0.3063, 0.702, 0.3154, 0.7234]}, {"w": "time.", "b": [0.3201, 0.702, 0.3627, 0.7234]}]}, {"id": "b_16", "type": "paragraph", "text": "Decision Boundaries", "words": [{"w": "Decision", "b": [0.1429, 0.7362, 0.2286, 0.7647]}, {"w": "Boundaries", "b": [0.2335, 0.7362, 0.3501, 0.7647]}]}, {"id": "b_17", "type": "paragraph", "text": "Let’s use the iris dataset to illustrate Logistic Regression. This is a famous dataset that contains the sepal and petal length and width of 150 iris flowers of three different species: Iris-Setosa, Iris-Versicolor, and Iris-Virginica (see Figure 4-22).", "words": [{"w": "Let’s", "b": [0.1429, 0.7706, 0.179, 0.792]}, {"w": "use", "b": [0.1845, 0.7706, 0.212, 0.792]}, {"w": "the", "b": [0.2175, 0.7706, 0.2438, 0.792]}, {"w": "iris", "b": [0.2493, 0.7706, 0.2758, 0.792]}, {"w": "dataset", "b": [0.2813, 0.7706, 0.3394, 0.792]}, {"w": "to", "b": [0.3449, 0.7706, 0.3618, 0.792]}, {"w": "illustrate", "b": [0.3673, 0.7706, 0.4402, 0.792]}, {"w": "Logistic", "b": [0.4456, 0.7706, 0.5112, 0.792]}, {"w": "Regression.", "b": [0.5166, 0.7706, 0.6124, 0.792]}, {"w": "This", "b": [0.6179, 0.7706, 0.6551, 0.792]}, {"w": "is", "b": [0.6605, 0.7706, 0.6738, 0.792]}, {"w": "a", "b": [0.6792, 0.7706, 0.6884, 0.792]}, {"w": "famous", "b": [0.6938, 0.7706, 0.7555, 0.792]}, {"w": "dataset", "b": [0.761, 0.7706, 0.8191, 0.792]}, {"w": "that", "b": [0.8246, 0.7706, 0.8571, 0.792]}, {"w": "contains", "b": [0.1429, 0.7897, 0.2134, 0.8111]}, {"w": "the", "b": [0.221, 0.7897, 0.2473, 0.8111]}, {"w": "sepal", "b": [0.2548, 0.7897, 0.2967, 0.8111]}, {"w": "and", "b": [0.3042, 0.7897, 0.3357, 0.8111]}, {"w": "petal", "b": [0.3433, 0.7897, 0.3838, 0.8111]}, {"w": "length", "b": [0.3914, 0.7897, 0.4441, 0.8111]}, {"w": "and", "b": [0.4516, 0.7897, 0.4832, 0.8111]}, {"w": "width", "b": [0.4907, 0.7897, 0.5391, 0.8111]}, {"w": "of", "b": [0.5466, 0.7897, 0.5634, 0.8111]}, {"w": "150", "b": [0.5709, 0.7897, 0.6009, 0.8111]}, {"w": "iris", "b": [0.6085, 0.7897, 0.635, 0.8111]}, {"w": "flowers", "b": [0.6425, 0.7897, 0.7031, 0.8111]}, {"w": "of", "b": [0.7106, 0.7897, 0.7274, 0.8111]}, {"w": "three", "b": [0.735, 0.7897, 0.7779, 0.8111]}, {"w": "different", "b": [0.7854, 0.7897, 0.8571, 0.8111]}, {"w": "species:", "b": [0.1428, 0.8087, 0.2059, 0.8301]}, {"w": "Iris-Setosa,", "b": [0.2106, 0.8087, 0.3034, 0.8301]}, {"w": "Iris-Versicolor,", "b": [0.3081, 0.8087, 0.4325, 0.8301]}, {"w": "and", "b": [0.4372, 0.8087, 0.4688, 0.8301]}, {"w": "Iris-Virginica", "b": [0.4735, 0.8087, 0.5864, 0.8301]}, {"w": "(see", "b": [0.5911, 0.8087, 0.6237, 0.8301]}, {"w": "Figure", "b": [0.6284, 0.8087, 0.6824, 0.8301]}, {"w": "4-22).", "b": [0.6871, 0.8087, 0.7365, 0.8301]}]}, {"id": "b_18", "type": "paragraph", "text": "146 | Chapter 4: Training Models", "words": [{"w": "146", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 173, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "16 Photos reproduced from the corresponding Wikipedia pages. Iris-Virginica photo by Frank Mayfield (Crea‐ tive Commons BY-SA 2.0), Iris-Versicolor photo by D. Gordon E. Robertson (Creative Commons BY-SA 3.0), and Iris-Setosa photo is public domain.", "words": [{"w": "16", "b": [0.1385, 0.8104, 0.1518, 0.8246]}, {"w": "Photos", "b": [0.1587, 0.8089, 0.203, 0.8252]}, {"w": "reproduced", "b": [0.2066, 0.8089, 0.2802, 0.8252]}, {"w": "from", "b": [0.2838, 0.8089, 0.3155, 0.8252]}, {"w": "the", "b": [0.3191, 0.8089, 0.3391, 0.8252]}, {"w": "corresponding", "b": [0.3427, 0.8089, 0.4357, 0.8252]}, {"w": "Wikipedia", "b": [0.4393, 0.8089, 0.5052, 0.8252]}, {"w": "pages.", "b": [0.5088, 0.8089, 0.5477, 0.8252]}, {"w": "Iris-Virginica", "b": [0.5513, 0.8089, 0.6373, 0.8252]}, {"w": "photo", "b": [0.6409, 0.8089, 0.6787, 0.8252]}, {"w": "by", "b": [0.6823, 0.8089, 0.6976, 0.8252]}, {"w": "Frank", "b": [0.7012, 0.8089, 0.739, 0.8252]}, {"w": "Mayfield", "b": [0.7427, 0.8089, 0.7986, 0.8252]}, {"w": "(Crea‐", "b": [0.8022, 0.8089, 0.8435, 0.8252]}, {"w": "tive", "b": [0.1587, 0.824, 0.1819, 0.8403]}, {"w": "Commons", "b": [0.1855, 0.824, 0.2528, 0.8403]}, {"w": "BY-SA", "b": [0.2564, 0.824, 0.2986, 0.8403]}, {"w": "2.0),", "b": [0.3022, 0.824, 0.3301, 0.8403]}, {"w": "Iris-Versicolor", "b": [0.3337, 0.824, 0.4259, 0.8403]}, {"w": "photo", "b": [0.4295, 0.824, 0.4673, 0.8403]}, {"w": "by", "b": [0.4709, 0.824, 0.4863, 0.8403]}, {"w": "D.", "b": [0.4899, 0.824, 0.5045, 0.8403]}, {"w": "Gordon", "b": [0.5081, 0.824, 0.5586, 0.8403]}, {"w": "E.", "b": [0.5622, 0.824, 0.5749, 0.8403]}, {"w": "Robertson", "b": [0.5785, 0.824, 0.6446, 0.8403]}, {"w": "(Creative", "b": [0.6482, 0.824, 0.7067, 0.8403]}, {"w": "Commons", "b": [0.7103, 0.824, 0.7776, 0.8403]}, {"w": "BY-SA", "b": [0.7812, 0.824, 0.8233, 0.8403]}, {"w": "3.0),", "b": [0.827, 0.824, 0.8549, 0.8403]}, {"w": "and", "b": [0.1587, 0.8391, 0.1828, 0.8554]}, {"w": "Iris-Setosa", "b": [0.1864, 0.8391, 0.2534, 0.8554]}, {"w": "photo", "b": [0.257, 0.8391, 0.2948, 0.8554]}, {"w": "is", "b": [0.2984, 0.8391, 0.3085, 0.8554]}, {"w": "public", "b": [0.3121, 0.8391, 0.3519, 0.8554]}, {"w": "domain.", "b": [0.3555, 0.8391, 0.4085, 0.8554]}]}, {"id": "b_1", "type": "paragraph", "text": "17 NumPy’s reshape() function allows one dimension to be –1, which means “unspecified”: the value is inferred from the length of the array and the remaining dimensions.", "words": [{"w": "17", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "NumPy’s", "b": [0.1587, 0.8598, 0.2155, 0.8761]}, {"w": "reshape()", "b": [0.2191, 0.8622, 0.2869, 0.8737]}, {"w": "function", "b": [0.2905, 0.8598, 0.3449, 0.8761]}, {"w": "allows", "b": [0.3485, 0.8598, 0.3883, 0.8761]}, {"w": "one", "b": [0.3919, 0.8598, 0.4155, 0.8761]}, {"w": "dimension", "b": [0.4191, 0.8598, 0.487, 0.8761]}, {"w": "to", "b": [0.4906, 0.8598, 0.5035, 0.8761]}, {"w": "be", "b": [0.5071, 0.8598, 0.5219, 0.8761]}, {"w": "–1,", "b": [0.5255, 0.8598, 0.545, 0.8761]}, {"w": "which", "b": [0.5486, 0.8598, 0.5874, 0.8761]}, {"w": "means", "b": [0.591, 0.8598, 0.6323, 0.8761]}, {"w": "“unspecified”:", "b": [0.6359, 0.8598, 0.7242, 0.8761]}, {"w": "the", "b": [0.7278, 0.8598, 0.7479, 0.8761]}, {"w": "value", "b": [0.7515, 0.8598, 0.785, 0.8761]}, {"w": "is", "b": [0.7886, 0.8598, 0.7987, 0.8761]}, {"w": "inferred", "b": [0.8023, 0.8598, 0.8536, 0.8761]}, {"w": "from", "b": [0.1587, 0.8749, 0.1904, 0.8912]}, {"w": "the", "b": [0.194, 0.8749, 0.2141, 0.8912]}, {"w": "length", "b": [0.2177, 0.8749, 0.2579, 0.8912]}, {"w": "of", "b": [0.2615, 0.8749, 0.2743, 0.8912]}, {"w": "the", "b": [0.2779, 0.8749, 0.2979, 0.8912]}, {"w": "array", "b": [0.3015, 0.8749, 0.3343, 0.8912]}, {"w": "and", "b": [0.3379, 0.8749, 0.3619, 0.8912]}, {"w": "the", "b": [0.3655, 0.8749, 0.3856, 0.8912]}, {"w": "remaining", "b": [0.3892, 0.8749, 0.4551, 0.8912]}, {"w": "dimensions.", "b": [0.4587, 0.8749, 0.536, 0.8912]}]}, {"id": "b_2", "type": "equation", "text": "Figure 4-22. Flowers of three iris plant species16", "words": [{"w": "Figure", "b": [0.1429, 0.3916, 0.1943, 0.4132]}, {"w": "4-22.", "b": [0.1991, 0.3916, 0.2407, 0.4132]}, {"w": "Flowers", "b": [0.2455, 0.3916, 0.3078, 0.4132]}, {"w": "of", "b": [0.3126, 0.3916, 0.3278, 0.4132]}, {"w": "three", "b": [0.3326, 0.3916, 0.3728, 0.4132]}, {"w": "iris", "b": [0.3776, 0.3916, 0.4036, 0.4132]}, {"w": "plant", "b": [0.4084, 0.3916, 0.4503, 0.4132]}, {"w": "species16", "b": [0.4551, 0.3916, 0.5203, 0.4132]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s try to build a classifier to detect the Iris-Virginica type based only on the petal width feature. First let’s load the data:", "words": [{"w": "Let’s", "b": [0.1429, 0.429, 0.179, 0.4504]}, {"w": "try", "b": [0.1855, 0.429, 0.2097, 0.4504]}, {"w": "to", "b": [0.2162, 0.429, 0.2332, 0.4504]}, {"w": "build", "b": [0.2396, 0.429, 0.2831, 0.4504]}, {"w": "a", "b": [0.2895, 0.429, 0.2987, 0.4504]}, {"w": "classifier", "b": [0.3051, 0.429, 0.3776, 0.4504]}, {"w": "to", "b": [0.384, 0.429, 0.401, 0.4504]}, {"w": "detect", "b": [0.4075, 0.429, 0.4577, 0.4504]}, {"w": "the", "b": [0.4641, 0.429, 0.4905, 0.4504]}, {"w": "Iris-Virginica", "b": [0.4969, 0.429, 0.6098, 0.4504]}, {"w": "type", "b": [0.6162, 0.429, 0.6519, 0.4504]}, {"w": "based", "b": [0.6584, 0.429, 0.7056, 0.4504]}, {"w": "only", "b": [0.712, 0.429, 0.7489, 0.4504]}, {"w": "on", "b": [0.7553, 0.429, 0.7774, 0.4504]}, {"w": "the", "b": [0.7838, 0.429, 0.8101, 0.4504]}, {"w": "petal", "b": [0.8166, 0.429, 0.8571, 0.4504]}, {"w": "width", "b": [0.1428, 0.448, 0.1912, 0.4694]}, {"w": "feature.", "b": [0.1959, 0.448, 0.2584, 0.4694]}, {"w": "First", "b": [0.2632, 0.448, 0.3015, 0.4694]}, {"w": "let’s", "b": [0.3062, 0.448, 0.3365, 0.4694]}, {"w": "load", "b": [0.3412, 0.448, 0.3772, 0.4694]}, {"w": "the", "b": [0.382, 0.448, 0.4083, 0.4694]}, {"w": "data:", "b": [0.413, 0.448, 0.453, 0.4694]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> from sklearn import datasets >>> iris = datasets.load_iris() >>> list(iris.keys()) ['data', 'target', 'target_names', 'DESCR', 'feature_names', 'filename'] >>> X = iris[\"data\"][:, 3:] # petal width >>> y = (iris[\"target\"] == 2).astype(np.int) # 1 if Iris-Virginica, else 0", "words": [{"w": ">>>", "b": [0.1766, 0.48, 0.2019, 0.4928]}, {"w": "from", "b": [0.2103, 0.48, 0.244, 0.4928]}, {"w": "sklearn", "b": [0.2525, 0.48, 0.3115, 0.4928]}, {"w": "import", "b": [0.3199, 0.48, 0.3705, 0.4928]}, {"w": "datasets", "b": [0.379, 0.48, 0.4464, 0.4928]}, {"w": ">>>", "b": [0.1766, 0.4954, 0.2019, 0.5082]}, {"w": "iris", "b": [0.2103, 0.4954, 0.244, 0.5082]}, {"w": "=", "b": [0.2525, 0.4954, 0.2609, 0.5082]}, {"w": "datasets.load_iris()", "b": [0.2693, 0.4954, 0.438, 0.5082]}, {"w": ">>>", "b": [0.1766, 0.5108, 0.2019, 0.5237]}, {"w": "list(iris.keys())", "b": [0.2103, 0.5108, 0.3537, 0.5237]}, {"w": "['data',", "b": [0.1766, 0.5262, 0.244, 0.5391]}, {"w": "'target',", "b": [0.2525, 0.5262, 0.3284, 0.5391]}, {"w": "'target_names',", "b": [0.3368, 0.5262, 0.4633, 0.5391]}, {"w": "'DESCR',", "b": [0.4717, 0.5262, 0.5392, 0.5391]}, {"w": "'feature_names',", "b": [0.5476, 0.5262, 0.6825, 0.5391]}, {"w": "'filename']", "b": [0.691, 0.5262, 0.7837, 0.5391]}, {"w": ">>>", "b": [0.1766, 0.5417, 0.2019, 0.5545]}, {"w": "X", "b": [0.2103, 0.5417, 0.2187, 0.5545]}, {"w": "=", "b": [0.2272, 0.5417, 0.2356, 0.5545]}, {"w": "iris[\"data\"][:,", "b": [0.244, 0.5417, 0.3705, 0.5545]}, {"w": "3:]", "b": [0.379, 0.5417, 0.4043, 0.5545]}, {"w": "#", "b": [0.4211, 0.5417, 0.4296, 0.5545]}, {"w": "petal", "b": [0.438, 0.5417, 0.4802, 0.5545]}, {"w": "width", "b": [0.4886, 0.5417, 0.5307, 0.5545]}, {"w": ">>>", "b": [0.1766, 0.5571, 0.2019, 0.5699]}, {"w": "y", "b": [0.2103, 0.5571, 0.2187, 0.5699]}, {"w": "=", "b": [0.2272, 0.5571, 0.2356, 0.5699]}, {"w": "(iris[\"target\"]", "b": [0.244, 0.5571, 0.3705, 0.5699]}, {"w": "==", "b": [0.379, 0.5571, 0.3958, 0.5699]}, {"w": "2).astype(np.int)", "b": [0.4043, 0.5571, 0.5476, 0.5699]}, {"w": "#", "b": [0.5645, 0.5571, 0.5729, 0.5699]}, {"w": "1", "b": [0.5813, 0.5571, 0.5898, 0.5699]}, {"w": "if", "b": [0.5982, 0.5571, 0.6151, 0.5699]}, {"w": "Iris-Virginica,", "b": [0.6235, 0.5571, 0.75, 0.5699]}, {"w": "else", "b": [0.7584, 0.5571, 0.7922, 0.5699]}, {"w": "0", "b": [0.8006, 0.5571, 0.809, 0.5699]}]}, {"id": "b_5", "type": "paragraph", "text": "Now let’s train a Logistic Regression model:", "words": [{"w": "Now", "b": [0.1429, 0.5777, 0.1827, 0.5991]}, {"w": "let’s", "b": [0.1874, 0.5777, 0.2177, 0.5991]}, {"w": "train", "b": [0.2224, 0.5777, 0.2626, 0.5991]}, {"w": "a", "b": [0.2673, 0.5777, 0.2765, 0.5991]}, {"w": "Logistic", "b": [0.2812, 0.5777, 0.3468, 0.5991]}, {"w": "Regression", "b": [0.3515, 0.5777, 0.4425, 0.5991]}, {"w": "model:", "b": [0.4472, 0.5777, 0.5048, 0.5991]}]}, {"id": "b_6", "type": "equation", "text": "from sklearn.linear_model import LogisticRegression", "words": [{"w": "from", "b": [0.1766, 0.6097, 0.2103, 0.6225]}, {"w": "sklearn.linear_model", "b": [0.2187, 0.6097, 0.3874, 0.6225]}, {"w": "import", "b": [0.3958, 0.6097, 0.4464, 0.6225]}, {"w": "LogisticRegression", "b": [0.4549, 0.6097, 0.6066, 0.6225]}]}, {"id": "b_7", "type": "equation", "text": "log_reg = LogisticRegression() log_reg.fit(X, y)", "words": [{"w": "log_reg", "b": [0.1766, 0.6405, 0.2356, 0.6534]}, {"w": "=", "b": [0.244, 0.6405, 0.2525, 0.6534]}, {"w": "LogisticRegression()", "b": [0.2609, 0.6405, 0.4296, 0.6534]}, {"w": "log_reg.fit(X,", "b": [0.1766, 0.6559, 0.2946, 0.6688]}, {"w": "y)", "b": [0.3031, 0.6559, 0.3199, 0.6688]}]}, {"id": "b_8", "type": "paragraph", "text": "Let’s look at the model’s estimated probabilities for flowers with petal widths varying from 0 to 3 cm (Figure 4-23)17:", "words": [{"w": "Let’s", "b": [0.1429, 0.6766, 0.179, 0.698]}, {"w": "look", "b": [0.1849, 0.6766, 0.2217, 0.698]}, {"w": "at", "b": [0.2275, 0.6766, 0.2426, 0.698]}, {"w": "the", "b": [0.2485, 0.6766, 0.2748, 0.698]}, {"w": "model’s", "b": [0.2806, 0.6766, 0.3432, 0.698]}, {"w": "estimated", "b": [0.3491, 0.6766, 0.4295, 0.698]}, {"w": "probabilities", "b": [0.4353, 0.6766, 0.5398, 0.698]}, {"w": "for", "b": [0.5456, 0.6766, 0.5702, 0.698]}, {"w": "flowers", "b": [0.576, 0.6766, 0.6365, 0.698]}, {"w": "with", "b": [0.6424, 0.6766, 0.6797, 0.698]}, {"w": "petal", "b": [0.6855, 0.6766, 0.7261, 0.698]}, {"w": "widths", "b": [0.7319, 0.6766, 0.7879, 0.698]}, {"w": "varying", "b": [0.7937, 0.6766, 0.8571, 0.698]}, {"w": "from", "b": [0.1428, 0.6956, 0.1844, 0.717]}, {"w": "0", "b": [0.1892, 0.6956, 0.1992, 0.717]}, {"w": "to", "b": [0.2039, 0.6956, 0.2209, 0.717]}, {"w": "3", "b": [0.2256, 0.6956, 0.2356, 0.717]}, {"w": "cm", "b": [0.2403, 0.6956, 0.2662, 0.717]}, {"w": "(Figure", "b": [0.2709, 0.6956, 0.3321, 0.717]}, {"w": "4-23)17:", "b": [0.3369, 0.6956, 0.3977, 0.717]}]}, {"id": "b_9", "type": "paragraph", "text": "X_new = np.linspace(0, 3, 1000).reshape(-1, 1) y_proba = log_reg.predict_proba(X_new) plt.plot(X_new, y_proba[:, 1], \"g-\", label=\"Iris-Virginica\")", "words": [{"w": "X_new", "b": [0.1766, 0.7276, 0.2187, 0.7404]}, {"w": "=", "b": [0.2272, 0.7276, 0.2356, 0.7404]}, {"w": "np.linspace(0,", "b": [0.244, 0.7276, 0.3621, 0.7404]}, {"w": "3,", "b": [0.3705, 0.7276, 0.3874, 0.7404]}, {"w": "1000).reshape(-1,", "b": [0.3958, 0.7276, 0.5392, 0.7404]}, {"w": "1)", "b": [0.5476, 0.7276, 0.5645, 0.7404]}, {"w": "y_proba", "b": [0.1766, 0.743, 0.2356, 0.7559]}, {"w": "=", "b": [0.244, 0.743, 0.2525, 0.7559]}, {"w": "log_reg.predict_proba(X_new)", "b": [0.2609, 0.743, 0.497, 0.7559]}, {"w": "plt.plot(X_new,", "b": [0.1766, 0.7584, 0.3031, 0.7713]}, {"w": "y_proba[:,", "b": [0.3115, 0.7584, 0.3958, 0.7713]}, {"w": "1],", "b": [0.4043, 0.7584, 0.4296, 0.7713]}, {"w": "\"g-\",", "b": [0.438, 0.7584, 0.4802, 0.7713]}, {"w": "label=\"Iris-Virginica\")", "b": [0.4886, 0.7584, 0.6825, 0.7713]}]}, {"id": "b_10", "type": "paragraph", "text": "Logistic Regression | 147", "words": [{"w": "Logistic", "b": [0.6839, 0.9225, 0.7288, 0.9388]}, {"w": "Regression", "b": [0.7316, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "147", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 174, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "18 It is the the set of points x such that θ0 + θ1x1 + θ2x2 = 0, which defines a straight line.", "words": [{"w": "18", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "It", "b": [0.1587, 0.8749, 0.1684, 0.8912]}, {"w": "is", "b": [0.172, 0.8749, 0.182, 0.8912]}, {"w": "the", "b": [0.1857, 0.8749, 0.2057, 0.8912]}, {"w": "the", "b": [0.2093, 0.8749, 0.2294, 0.8912]}, {"w": "set", "b": [0.233, 0.8749, 0.2504, 0.8912]}, {"w": "of", "b": [0.254, 0.8749, 0.2668, 0.8912]}, {"w": "points", "b": [0.2704, 0.8749, 0.3101, 0.8912]}, {"w": "x", "b": [0.3137, 0.8745, 0.3214, 0.8912]}, {"w": "such", "b": [0.325, 0.8749, 0.3544, 0.8912]}, {"w": "that", "b": [0.358, 0.8749, 0.3828, 0.8912]}, {"w": "θ0", "b": [0.3864, 0.8748, 0.4, 0.8927]}, {"w": "+", "b": [0.4036, 0.8749, 0.4128, 0.8912]}, {"w": "θ1x1", "b": [0.4164, 0.8748, 0.4435, 0.8927]}, {"w": "+", "b": [0.4471, 0.8749, 0.4563, 0.8912]}, {"w": "θ2x2", "b": [0.4599, 0.8748, 0.487, 0.8927]}, {"w": "=", "b": [0.4906, 0.8749, 0.4998, 0.8912]}, {"w": "0,", "b": [0.5034, 0.8749, 0.5147, 0.8912]}, {"w": "which", "b": [0.5183, 0.8749, 0.557, 0.8912]}, {"w": "defines", "b": [0.5607, 0.8749, 0.606, 0.8912]}, {"w": "a", "b": [0.6096, 0.8749, 0.6166, 0.8912]}, {"w": "straight", "b": [0.6202, 0.8749, 0.6684, 0.8912]}, {"w": "line.", "b": [0.672, 0.8749, 0.6993, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "plt.plot(X_new, y_proba[:, 0], \"b--\", label=\"Not Iris-Virginica\") # + more Matplotlib code to make the image look pretty", "words": [{"w": "plt.plot(X_new,", "b": [0.1766, 0.0829, 0.3031, 0.0958]}, {"w": "y_proba[:,", "b": [0.3115, 0.0829, 0.3958, 0.0958]}, {"w": "0],", "b": [0.4043, 0.0829, 0.4296, 0.0958]}, {"w": "\"b--\",", "b": [0.438, 0.0829, 0.4886, 0.0958]}, {"w": "label=\"Not", "b": [0.497, 0.0829, 0.5813, 0.0958]}, {"w": "Iris-Virginica\")", "b": [0.5898, 0.0829, 0.7247, 0.0958]}, {"w": "#", "b": [0.1766, 0.0983, 0.185, 0.1112]}, {"w": "+", "b": [0.1935, 0.0983, 0.2019, 0.1112]}, {"w": "more", "b": [0.2103, 0.0983, 0.244, 0.1112]}, {"w": "Matplotlib", "b": [0.2525, 0.0983, 0.3368, 0.1112]}, {"w": "code", "b": [0.3452, 0.0983, 0.379, 0.1112]}, {"w": "to", "b": [0.3874, 0.0983, 0.4043, 0.1112]}, {"w": "make", "b": [0.4127, 0.0983, 0.4464, 0.1112]}, {"w": "the", "b": [0.4549, 0.0983, 0.4802, 0.1112]}, {"w": "image", "b": [0.4886, 0.0983, 0.5308, 0.1112]}, {"w": "look", "b": [0.5392, 0.0983, 0.5729, 0.1112]}, {"w": "pretty", "b": [0.5813, 0.0983, 0.6319, 0.1112]}]}, {"id": "b_2", "type": "equation", "text": "Figure 4-23. Estimated probabilities and decision boundary", "words": [{"w": "Figure", "b": [0.1429, 0.3208, 0.1943, 0.3424]}, {"w": "4-23.", "b": [0.1991, 0.3208, 0.2407, 0.3424]}, {"w": "Estimated", "b": [0.2455, 0.3208, 0.3267, 0.3424]}, {"w": "probabilities", "b": [0.3314, 0.3208, 0.4307, 0.3424]}, {"w": "and", "b": [0.4355, 0.3208, 0.4669, 0.3424]}, {"w": "decision", "b": [0.4716, 0.3208, 0.5372, 0.3424]}, {"w": "boundary", "b": [0.5419, 0.3208, 0.6209, 0.3424]}]}, {"id": "b_3", "type": "paragraph", "text": "The petal width of Iris-Virginica flowers (represented by triangles) ranges from 1.4 cm to 2.5 cm, while the other iris flowers (represented by squares) generally have a smaller petal width, ranging from 0.1 cm to 1.8 cm. Notice that there is a bit of over‐ lap. Above about 2 cm the classifier is highly confident that the flower is an Iris- Virginica (it outputs a high probability to that class), while below 1 cm it is highly confident that it is not an Iris-Virginica (high probability for the “Not Iris-Virginica” class). In between these extremes, the classifier is unsure. However, if you ask it to predict the class (using the predict() method rather than the predict_proba() method), it will return whichever class is the most likely. Therefore, there is a decision boundary at around 1.6 cm where both probabilities are equal to 50%: if the petal width is higher than 1.6 cm, the classifier will predict that the flower is an Iris- Virginica, or else it will predict that it is not (even if it is not very confident):", "words": [{"w": "The", "b": [0.1429, 0.3582, 0.1757, 0.3796]}, {"w": "petal", "b": [0.1827, 0.3582, 0.2233, 0.3796]}, {"w": "width", "b": [0.2303, 0.3582, 0.2786, 0.3796]}, {"w": "of", "b": [0.2857, 0.3582, 0.3025, 0.3796]}, {"w": "Iris-Virginica", "b": [0.3095, 0.3582, 0.4224, 0.3796]}, {"w": "flowers", "b": [0.4294, 0.3582, 0.49, 0.3796]}, {"w": "(represented", "b": [0.497, 0.3582, 0.602, 0.3796]}, {"w": "by", "b": [0.6091, 0.3582, 0.6292, 0.3796]}, {"w": "triangles)", "b": [0.6362, 0.3582, 0.7152, 0.3796]}, {"w": "ranges", "b": [0.7222, 0.3582, 0.7767, 0.3796]}, {"w": "from", "b": [0.7838, 0.3582, 0.8254, 0.3796]}, {"w": "1.4", "b": [0.8324, 0.3582, 0.8571, 0.3796]}, {"w": "cm", "b": [0.1429, 0.3772, 0.1687, 0.3986]}, {"w": "to", "b": [0.1755, 0.3772, 0.1924, 0.3986]}, {"w": "2.5", "b": [0.1992, 0.3772, 0.2239, 0.3986]}, {"w": "cm,", "b": [0.2307, 0.3772, 0.2613, 0.3986]}, {"w": "while", "b": [0.268, 0.3772, 0.3131, 0.3986]}, {"w": "the", "b": [0.3199, 0.3772, 0.3462, 0.3986]}, {"w": "other", "b": [0.353, 0.3772, 0.3977, 0.3986]}, {"w": "iris", "b": [0.4044, 0.3772, 0.4309, 0.3986]}, {"w": "flowers", "b": [0.4377, 0.3772, 0.4982, 0.3986]}, {"w": "(represented", "b": [0.505, 0.3772, 0.61, 0.3986]}, {"w": "by", "b": [0.6167, 0.3772, 0.6369, 0.3986]}, {"w": "squares)", "b": [0.6436, 0.3772, 0.7135, 0.3986]}, {"w": "generally", "b": [0.7203, 0.3772, 0.7961, 0.3986]}, {"w": "have", "b": [0.8029, 0.3772, 0.8413, 0.3986]}, {"w": "a", "b": [0.848, 0.3772, 0.8571, 0.3986]}, {"w": "smaller", "b": [0.1428, 0.3963, 0.2038, 0.4177]}, {"w": "petal", "b": [0.2093, 0.3963, 0.2499, 0.4177]}, {"w": "width,", "b": [0.2554, 0.3963, 0.3085, 0.4177]}, {"w": "ranging", "b": [0.314, 0.3963, 0.3787, 0.4177]}, {"w": "from", "b": [0.3843, 0.3963, 0.4258, 0.4177]}, {"w": "0.1", "b": [0.4314, 0.3963, 0.4561, 0.4177]}, {"w": "cm", "b": [0.4616, 0.3963, 0.4875, 0.4177]}, {"w": "to", "b": [0.493, 0.3963, 0.51, 0.4177]}, {"w": "1.8", "b": [0.5155, 0.3963, 0.5402, 0.4177]}, {"w": "cm.", "b": [0.5458, 0.3963, 0.5764, 0.4177]}, {"w": "Notice", "b": [0.5819, 0.3963, 0.6371, 0.4177]}, {"w": "that", "b": [0.6426, 0.3963, 0.6752, 0.4177]}, {"w": "there", "b": [0.6807, 0.3963, 0.7236, 0.4177]}, {"w": "is", "b": [0.7291, 0.3963, 0.7424, 0.4177]}, {"w": "a", "b": [0.7479, 0.3963, 0.757, 0.4177]}, {"w": "bit", "b": [0.7625, 0.3963, 0.785, 0.4177]}, {"w": "of", "b": [0.7906, 0.3963, 0.8073, 0.4177]}, {"w": "over‐", "b": [0.8129, 0.3963, 0.8571, 0.4177]}, {"w": "lap.", "b": [0.1429, 0.4153, 0.1719, 0.4367]}, {"w": "Above", "b": [0.1801, 0.4153, 0.2336, 0.4367]}, {"w": "about", "b": [0.2418, 0.4153, 0.2896, 0.4367]}, {"w": "2", "b": [0.2978, 0.4153, 0.3078, 0.4367]}, {"w": "cm", "b": [0.3159, 0.4153, 0.3418, 0.4367]}, {"w": "the", "b": [0.35, 0.4153, 0.3763, 0.4367]}, {"w": "classifier", "b": [0.3845, 0.4153, 0.457, 0.4367]}, {"w": "is", "b": [0.4651, 0.4153, 0.4784, 0.4367]}, {"w": "highly", "b": [0.4866, 0.4153, 0.539, 0.4367]}, {"w": "confident", "b": [0.5472, 0.4153, 0.627, 0.4367]}, {"w": "that", "b": [0.6351, 0.4153, 0.6677, 0.4367]}, {"w": "the", "b": [0.6759, 0.4153, 0.7022, 0.4367]}, {"w": "flower", "b": [0.7104, 0.4153, 0.7633, 0.4367]}, {"w": "is", "b": [0.7715, 0.4153, 0.7848, 0.4367]}, {"w": "an", "b": [0.7929, 0.4153, 0.8135, 0.4367]}, {"w": "Iris-", "b": [0.8217, 0.4153, 0.8571, 0.4367]}, {"w": "Virginica", "b": [0.1429, 0.4344, 0.2202, 0.4558]}, {"w": "(it", "b": [0.2274, 0.4344, 0.2465, 0.4558]}, {"w": "outputs", "b": [0.2536, 0.4344, 0.3176, 0.4558]}, {"w": "a", "b": [0.3248, 0.4344, 0.3339, 0.4558]}, {"w": "high", "b": [0.341, 0.4344, 0.3786, 0.4558]}, {"w": "probability", "b": [0.3857, 0.4344, 0.4777, 0.4558]}, {"w": "to", "b": [0.4848, 0.4344, 0.5018, 0.4558]}, {"w": "that", "b": [0.5089, 0.4344, 0.5415, 0.4558]}, {"w": "class),", "b": [0.5486, 0.4344, 0.5991, 0.4558]}, {"w": "while", "b": [0.6062, 0.4344, 0.6513, 0.4558]}, {"w": "below", "b": [0.6585, 0.4344, 0.7081, 0.4558]}, {"w": "1", "b": [0.7152, 0.4344, 0.7252, 0.4558]}, {"w": "cm", "b": [0.7323, 0.4344, 0.7582, 0.4558]}, {"w": "it", "b": [0.7653, 0.4344, 0.7772, 0.4558]}, {"w": "is", "b": [0.7844, 0.4344, 0.7976, 0.4558]}, {"w": "highly", "b": [0.8047, 0.4344, 0.8571, 0.4558]}, {"w": "confident", "b": [0.1429, 0.4534, 0.2226, 0.4748]}, {"w": "that", "b": [0.2283, 0.4534, 0.2609, 0.4748]}, {"w": "it", "b": [0.2665, 0.4534, 0.2784, 0.4748]}, {"w": "is", "b": [0.2841, 0.4534, 0.2973, 0.4748]}, {"w": "not", "b": [0.3029, 0.4534, 0.3313, 0.4748]}, {"w": "an", "b": [0.3369, 0.4534, 0.3575, 0.4748]}, {"w": "Iris-Virginica", "b": [0.3631, 0.4534, 0.476, 0.4748]}, {"w": "(high", "b": [0.4816, 0.4534, 0.5264, 0.4748]}, {"w": "probability", "b": [0.532, 0.4534, 0.624, 0.4748]}, {"w": "for", "b": [0.6296, 0.4534, 0.6541, 0.4748]}, {"w": "the", "b": [0.6597, 0.4534, 0.6861, 0.4748]}, {"w": "“Not", "b": [0.6917, 0.4534, 0.7319, 0.4748]}, {"w": "Iris-Virginica”", "b": [0.7376, 0.4534, 0.8571, 0.4748]}, {"w": "class).", "b": [0.1429, 0.4725, 0.1933, 0.4939]}, {"w": "In", "b": [0.2006, 0.4725, 0.2191, 0.4939]}, {"w": "between", "b": [0.2263, 0.4725, 0.2954, 0.4939]}, {"w": "these", "b": [0.3026, 0.4725, 0.3455, 0.4939]}, {"w": "extremes,", "b": [0.3527, 0.4725, 0.4326, 0.4939]}, {"w": "the", "b": [0.4398, 0.4725, 0.4662, 0.4939]}, {"w": "classifier", "b": [0.4734, 0.4725, 0.5458, 0.4939]}, {"w": "is", "b": [0.553, 0.4725, 0.5663, 0.4939]}, {"w": "unsure.", "b": [0.5735, 0.4725, 0.636, 0.4939]}, {"w": "However,", "b": [0.6432, 0.4725, 0.722, 0.4939]}, {"w": "if", "b": [0.7293, 0.4725, 0.741, 0.4939]}, {"w": "you", "b": [0.7482, 0.4725, 0.7795, 0.4939]}, {"w": "ask", "b": [0.7867, 0.4725, 0.8138, 0.4939]}, {"w": "it", "b": [0.821, 0.4725, 0.833, 0.4939]}, {"w": "to", "b": [0.8402, 0.4725, 0.8572, 0.4939]}, {"w": "predict", "b": [0.1429, 0.4924, 0.2021, 0.5138]}, {"w": "the", "b": [0.2115, 0.4924, 0.2378, 0.5138]}, {"w": "class", "b": [0.2472, 0.4924, 0.2857, 0.5138]}, {"w": "(using", "b": [0.2951, 0.4924, 0.3477, 0.5138]}, {"w": "the", "b": [0.3571, 0.4924, 0.3835, 0.5138]}, {"w": "predict()", "b": [0.3928, 0.4956, 0.4819, 0.5107]}, {"w": "method", "b": [0.4913, 0.4924, 0.5563, 0.5138]}, {"w": "rather", "b": [0.5657, 0.4924, 0.6162, 0.5138]}, {"w": "than", "b": [0.6256, 0.4924, 0.6636, 0.5138]}, {"w": "the", "b": [0.673, 0.4924, 0.6993, 0.5138]}, {"w": "predict_proba()", "b": [0.7087, 0.4956, 0.8571, 0.5107]}, {"w": "method),", "b": [0.1429, 0.5115, 0.2198, 0.5329]}, {"w": "it", "b": [0.2248, 0.5115, 0.2367, 0.5329]}, {"w": "will", "b": [0.2417, 0.5115, 0.2721, 0.5329]}, {"w": "return", "b": [0.2771, 0.5115, 0.3302, 0.5329]}, {"w": "whichever", "b": [0.3352, 0.5115, 0.4212, 0.5329]}, {"w": "class", "b": [0.4262, 0.5115, 0.4647, 0.5329]}, {"w": "is", "b": [0.4696, 0.5115, 0.4829, 0.5329]}, {"w": "the", "b": [0.4878, 0.5115, 0.5142, 0.5329]}, {"w": "most", "b": [0.5192, 0.5115, 0.5608, 0.5329]}, {"w": "likely.", "b": [0.5658, 0.5115, 0.6139, 0.5329]}, {"w": "Therefore,", "b": [0.6189, 0.5115, 0.7064, 0.5329]}, {"w": "there", "b": [0.7114, 0.5115, 0.7543, 0.5329]}, {"w": "is", "b": [0.7593, 0.5115, 0.7725, 0.5329]}, {"w": "a", "b": [0.7775, 0.5115, 0.7866, 0.5329]}, {"w": "decision", "b": [0.7916, 0.5112, 0.8571, 0.5329]}, {"w": "boundary", "b": [0.1428, 0.5303, 0.2219, 0.5519]}, {"w": "at", "b": [0.2296, 0.5305, 0.2447, 0.5519]}, {"w": "around", "b": [0.2524, 0.5305, 0.3133, 0.5519]}, {"w": "1.6", "b": [0.321, 0.5305, 0.3458, 0.5519]}, {"w": "cm", "b": [0.3535, 0.5305, 0.3794, 0.5519]}, {"w": "where", "b": [0.3871, 0.5305, 0.4379, 0.5519]}, {"w": "both", "b": [0.4456, 0.5305, 0.4843, 0.5519]}, {"w": "probabilities", "b": [0.492, 0.5305, 0.5964, 0.5519]}, {"w": "are", "b": [0.6041, 0.5305, 0.6299, 0.5519]}, {"w": "equal", "b": [0.6376, 0.5305, 0.6825, 0.5519]}, {"w": "to", "b": [0.6902, 0.5305, 0.7072, 0.5519]}, {"w": "50%:", "b": [0.7149, 0.5305, 0.7554, 0.5519]}, {"w": "if", "b": [0.7631, 0.5305, 0.7749, 0.5519]}, {"w": "the", "b": [0.7826, 0.5305, 0.8089, 0.5519]}, {"w": "petal", "b": [0.8166, 0.5305, 0.8571, 0.5519]}, {"w": "width", "b": [0.1429, 0.5495, 0.1912, 0.571]}, {"w": "is", "b": [0.2002, 0.5495, 0.2135, 0.571]}, {"w": "higher", "b": [0.2225, 0.5495, 0.2767, 0.571]}, {"w": "than", "b": [0.2857, 0.5495, 0.3237, 0.571]}, {"w": "1.6", "b": [0.3328, 0.5495, 0.3575, 0.571]}, {"w": "cm,", "b": [0.3666, 0.5495, 0.3972, 0.571]}, {"w": "the", "b": [0.4063, 0.5495, 0.4326, 0.571]}, {"w": "classifier", "b": [0.4416, 0.5495, 0.5141, 0.571]}, {"w": "will", "b": [0.5231, 0.5495, 0.5535, 0.571]}, {"w": "predict", "b": [0.5626, 0.5495, 0.6218, 0.571]}, {"w": "that", "b": [0.6308, 0.5495, 0.6634, 0.571]}, {"w": "the", "b": [0.6725, 0.5495, 0.6988, 0.571]}, {"w": "flower", "b": [0.7078, 0.5495, 0.7608, 0.571]}, {"w": "is", "b": [0.7698, 0.5495, 0.783, 0.571]}, {"w": "an", "b": [0.7921, 0.5495, 0.8126, 0.571]}, {"w": "Iris-", "b": [0.8217, 0.5495, 0.8571, 0.571]}, {"w": "Virginica,", "b": [0.1429, 0.5686, 0.225, 0.59]}, {"w": "or", "b": [0.2297, 0.5686, 0.2481, 0.59]}, {"w": "else", "b": [0.2528, 0.5686, 0.2834, 0.59]}, {"w": "it", "b": [0.2881, 0.5686, 0.3001, 0.59]}, {"w": "will", "b": [0.3048, 0.5686, 0.3352, 0.59]}, {"w": "predict", "b": [0.3399, 0.5686, 0.3992, 0.59]}, {"w": "that", "b": [0.4039, 0.5686, 0.4365, 0.59]}, {"w": "it", "b": [0.4412, 0.5686, 0.4532, 0.59]}, {"w": "is", "b": [0.4579, 0.5686, 0.4711, 0.59]}, {"w": "not", "b": [0.4759, 0.5686, 0.5042, 0.59]}, {"w": "(even", "b": [0.509, 0.5686, 0.5549, 0.59]}, {"w": "if", "b": [0.5596, 0.5686, 0.5714, 0.59]}, {"w": "it", "b": [0.5761, 0.5686, 0.5881, 0.59]}, {"w": "is", "b": [0.5928, 0.5686, 0.606, 0.59]}, {"w": "not", "b": [0.6108, 0.5686, 0.6391, 0.59]}, {"w": "very", "b": [0.6439, 0.5686, 0.6803, 0.59]}, {"w": "confident):", "b": [0.685, 0.5686, 0.7767, 0.59]}]}, {"id": "b_4", "type": "equation", "text": ">>> log_reg.predict([[1.7], [1.5]]) array([1, 0])", "words": [{"w": ">>>", "b": [0.1766, 0.6006, 0.2019, 0.6134]}, {"w": "log_reg.predict([[1.7],", "b": [0.2103, 0.6006, 0.4043, 0.6134]}, {"w": "[1.5]])", "b": [0.4127, 0.6006, 0.4717, 0.6134]}, {"w": "array([1,", "b": [0.1766, 0.616, 0.2525, 0.6288]}, {"w": "0])", "b": [0.2609, 0.616, 0.2862, 0.6288]}]}, {"id": "b_5", "type": "paragraph", "text": "Figure 4-24 shows the same dataset but this time displaying two features: petal width and length. Once trained, the Logistic Regression classifier can estimate the probabil‐ ity that a new flower is an Iris-Virginica based on these two features. The dashed line represents the points where the model estimates a 50% probability: this is the model’s decision boundary. Note that it is a linear boundary.18 Each parallel line represents the points where the model outputs a specific probability, from 15% (bottom left) to 90% (top right). All the flowers beyond the top-right line have an over 90% chance of being Iris-Virginica according to the model.", "words": [{"w": "Figure", "b": [0.1429, 0.6366, 0.1969, 0.658]}, {"w": "4-24", "b": [0.2024, 0.6366, 0.2398, 0.658]}, {"w": "shows", "b": [0.2454, 0.6366, 0.2967, 0.658]}, {"w": "the", "b": [0.3022, 0.6366, 0.3286, 0.658]}, {"w": "same", "b": [0.3341, 0.6366, 0.3768, 0.658]}, {"w": "dataset", "b": [0.3823, 0.6366, 0.4405, 0.658]}, {"w": "but", "b": [0.446, 0.6366, 0.474, 0.658]}, {"w": "this", "b": [0.4795, 0.6366, 0.5103, 0.658]}, {"w": "time", "b": [0.5158, 0.6366, 0.5536, 0.658]}, {"w": "displaying", "b": [0.5592, 0.6366, 0.6447, 0.658]}, {"w": "two", "b": [0.6502, 0.6366, 0.6815, 0.658]}, {"w": "features:", "b": [0.687, 0.6366, 0.7572, 0.658]}, {"w": "petal", "b": [0.7627, 0.6366, 0.8033, 0.658]}, {"w": "width", "b": [0.8088, 0.6366, 0.8571, 0.658]}, {"w": "and", "b": [0.1429, 0.6557, 0.1744, 0.6771]}, {"w": "length.", "b": [0.1796, 0.6557, 0.2371, 0.6771]}, {"w": "Once", "b": [0.2423, 0.6557, 0.287, 0.6771]}, {"w": "trained,", "b": [0.2922, 0.6557, 0.357, 0.6771]}, {"w": "the", "b": [0.3622, 0.6557, 0.3886, 0.6771]}, {"w": "Logistic", "b": [0.3938, 0.6557, 0.4593, 0.6771]}, {"w": "Regression", "b": [0.4646, 0.6557, 0.5556, 0.6771]}, {"w": "classifier", "b": [0.5608, 0.6557, 0.6332, 0.6771]}, {"w": "can", "b": [0.6385, 0.6557, 0.6678, 0.6771]}, {"w": "estimate", "b": [0.673, 0.6557, 0.7425, 0.6771]}, {"w": "the", "b": [0.7477, 0.6557, 0.7741, 0.6771]}, {"w": "probabil‐", "b": [0.7793, 0.6557, 0.8571, 0.6771]}, {"w": "ity", "b": [0.1429, 0.6747, 0.1644, 0.6961]}, {"w": "that", "b": [0.1698, 0.6747, 0.2023, 0.6961]}, {"w": "a", "b": [0.2077, 0.6747, 0.2169, 0.6961]}, {"w": "new", "b": [0.2223, 0.6747, 0.2568, 0.6961]}, {"w": "flower", "b": [0.2622, 0.6747, 0.3151, 0.6961]}, {"w": "is", "b": [0.3205, 0.6747, 0.3337, 0.6961]}, {"w": "an", "b": [0.3391, 0.6747, 0.3596, 0.6961]}, {"w": "Iris-Virginica", "b": [0.365, 0.6747, 0.4779, 0.6961]}, {"w": "based", "b": [0.4832, 0.6747, 0.5305, 0.6961]}, {"w": "on", "b": [0.5359, 0.6747, 0.5579, 0.6961]}, {"w": "these", "b": [0.5633, 0.6747, 0.6061, 0.6961]}, {"w": "two", "b": [0.6115, 0.6747, 0.6427, 0.6961]}, {"w": "features.", "b": [0.6481, 0.6747, 0.7183, 0.6961]}, {"w": "The", "b": [0.7237, 0.6747, 0.7565, 0.6961]}, {"w": "dashed", "b": [0.7619, 0.6747, 0.8207, 0.6961]}, {"w": "line", "b": [0.826, 0.6747, 0.8572, 0.6961]}, {"w": "represents", "b": [0.1429, 0.6938, 0.2284, 0.7152]}, {"w": "the", "b": [0.2337, 0.6938, 0.26, 0.7152]}, {"w": "points", "b": [0.2653, 0.6938, 0.3174, 0.7152]}, {"w": "where", "b": [0.3226, 0.6938, 0.3734, 0.7152]}, {"w": "the", "b": [0.3787, 0.6938, 0.405, 0.7152]}, {"w": "model", "b": [0.4103, 0.6938, 0.4631, 0.7152]}, {"w": "estimates", "b": [0.4683, 0.6938, 0.5454, 0.7152]}, {"w": "a", "b": [0.5506, 0.6938, 0.5598, 0.7152]}, {"w": "50%", "b": [0.565, 0.6938, 0.6008, 0.7152]}, {"w": "probability:", "b": [0.606, 0.6938, 0.7033, 0.7152]}, {"w": "this", "b": [0.7086, 0.6938, 0.7393, 0.7152]}, {"w": "is", "b": [0.7445, 0.6938, 0.7578, 0.7152]}, {"w": "the", "b": [0.763, 0.6938, 0.7893, 0.7152]}, {"w": "model’s", "b": [0.7946, 0.6938, 0.8571, 0.7152]}, {"w": "decision", "b": [0.1429, 0.7128, 0.2124, 0.7342]}, {"w": "boundary.", "b": [0.2171, 0.7128, 0.302, 0.7342]}, {"w": "Note", "b": [0.3068, 0.7128, 0.3475, 0.7342]}, {"w": "that", "b": [0.3523, 0.7128, 0.3849, 0.7342]}, {"w": "it", "b": [0.3896, 0.7128, 0.4015, 0.7342]}, {"w": "is", "b": [0.4063, 0.7128, 0.4195, 0.7342]}, {"w": "a", "b": [0.4242, 0.7128, 0.4334, 0.7342]}, {"w": "linear", "b": [0.4381, 0.7128, 0.4861, 0.7342]}, {"w": "boundary.18", "b": [0.4908, 0.7128, 0.5876, 0.7342]}, {"w": "Each", "b": [0.5924, 0.7128, 0.6334, 0.7342]}, {"w": "parallel", "b": [0.6381, 0.7128, 0.6997, 0.7342]}, {"w": "line", "b": [0.7044, 0.7128, 0.7355, 0.7342]}, {"w": "represents", "b": [0.7403, 0.7128, 0.8258, 0.7342]}, {"w": "the", "b": [0.8306, 0.7128, 0.8569, 0.7342]}, {"w": "points", "b": [0.1429, 0.7319, 0.195, 0.7533]}, {"w": "where", "b": [0.2003, 0.7319, 0.2511, 0.7533]}, {"w": "the", "b": [0.2564, 0.7319, 0.2827, 0.7533]}, {"w": "model", "b": [0.288, 0.7319, 0.3408, 0.7533]}, {"w": "outputs", "b": [0.3461, 0.7319, 0.4101, 0.7533]}, {"w": "a", "b": [0.4154, 0.7319, 0.4246, 0.7533]}, {"w": "specific", "b": [0.4299, 0.7319, 0.4922, 0.7533]}, {"w": "probability,", "b": [0.4975, 0.7319, 0.5927, 0.7533]}, {"w": "from", "b": [0.598, 0.7319, 0.6396, 0.7533]}, {"w": "15%", "b": [0.6448, 0.7319, 0.6806, 0.7533]}, {"w": "(bottom", "b": [0.6859, 0.7319, 0.7547, 0.7533]}, {"w": "left)", "b": [0.76, 0.7319, 0.7938, 0.7533]}, {"w": "to", "b": [0.7991, 0.7319, 0.8161, 0.7533]}, {"w": "90%", "b": [0.8214, 0.7319, 0.8571, 0.7533]}, {"w": "(top", "b": [0.1428, 0.7509, 0.178, 0.7723]}, {"w": "right).", "b": [0.1861, 0.7509, 0.2382, 0.7723]}, {"w": "All", "b": [0.2463, 0.7509, 0.2713, 0.7723]}, {"w": "the", "b": [0.2794, 0.7509, 0.3057, 0.7723]}, {"w": "flowers", "b": [0.3139, 0.7509, 0.3744, 0.7723]}, {"w": "beyond", "b": [0.3826, 0.7509, 0.4446, 0.7723]}, {"w": "the", "b": [0.4527, 0.7509, 0.479, 0.7723]}, {"w": "top-right", "b": [0.4872, 0.7509, 0.5626, 0.7723]}, {"w": "line", "b": [0.5708, 0.7509, 0.6019, 0.7723]}, {"w": "have", "b": [0.61, 0.7509, 0.6484, 0.7723]}, {"w": "an", "b": [0.6565, 0.7509, 0.6771, 0.7723]}, {"w": "over", "b": [0.6852, 0.7509, 0.7221, 0.7723]}, {"w": "90%", "b": [0.7302, 0.7509, 0.7659, 0.7723]}, {"w": "chance", "b": [0.7741, 0.7509, 0.8322, 0.7723]}, {"w": "of", "b": [0.8403, 0.7509, 0.8571, 0.7723]}, {"w": "being", "b": [0.1429, 0.77, 0.189, 0.7914]}, {"w": "Iris-Virginica", "b": [0.1938, 0.77, 0.3066, 0.7914]}, {"w": "according", "b": [0.3113, 0.77, 0.3942, 0.7914]}, {"w": "to", "b": [0.3989, 0.77, 0.4159, 0.7914]}, {"w": "the", "b": [0.4206, 0.77, 0.447, 0.7914]}, {"w": "model.", "b": [0.4517, 0.77, 0.5093, 0.7914]}]}, {"id": "b_6", "type": "paragraph", "text": "148 | Chapter 4: Training Models", "words": [{"w": "148", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 175, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 4-24. Linear decision boundary", "words": [{"w": "Figure", "b": [0.1429, 0.2971, 0.1943, 0.3187]}, {"w": "4-24.", "b": [0.1991, 0.2971, 0.2407, 0.3187]}, {"w": "Linear", "b": [0.2455, 0.2971, 0.2982, 0.3187]}, {"w": "decision", "b": [0.303, 0.2971, 0.3685, 0.3187]}, {"w": "boundary", "b": [0.3733, 0.2971, 0.4523, 0.3187]}]}, {"id": "b_1", "type": "paragraph", "text": "Just like the other linear models, Logistic Regression models can be regularized using ℓ1 or ℓ2 penalties. Scitkit-Learn actually adds an ℓ2 penalty by default.", "words": [{"w": "Just", "b": [0.1429, 0.3345, 0.1741, 0.3559]}, {"w": "like", "b": [0.179, 0.3345, 0.2091, 0.3559]}, {"w": "the", "b": [0.214, 0.3345, 0.2403, 0.3559]}, {"w": "other", "b": [0.2452, 0.3345, 0.2899, 0.3559]}, {"w": "linear", "b": [0.2948, 0.3345, 0.3428, 0.3559]}, {"w": "models,", "b": [0.3477, 0.3345, 0.4129, 0.3559]}, {"w": "Logistic", "b": [0.4178, 0.3345, 0.4834, 0.3559]}, {"w": "Regression", "b": [0.4883, 0.3345, 0.5793, 0.3559]}, {"w": "models", "b": [0.5842, 0.3345, 0.6447, 0.3559]}, {"w": "can", "b": [0.6496, 0.3345, 0.6789, 0.3559]}, {"w": "be", "b": [0.6838, 0.3345, 0.7033, 0.3559]}, {"w": "regularized", "b": [0.7082, 0.3345, 0.8019, 0.3559]}, {"w": "using", "b": [0.8068, 0.3345, 0.8522, 0.3559]}, {"w": "ℓ1", "b": [0.1429, 0.3535, 0.1574, 0.3758]}, {"w": "or", "b": [0.1621, 0.3535, 0.1805, 0.375]}, {"w": "ℓ2", "b": [0.1852, 0.3535, 0.1998, 0.3758]}, {"w": "penalties.", "b": [0.2045, 0.3535, 0.2833, 0.375]}, {"w": "Scitkit-Learn", "b": [0.288, 0.3535, 0.3967, 0.375]}, {"w": "actually", "b": [0.4014, 0.3535, 0.466, 0.375]}, {"w": "adds", "b": [0.4707, 0.3535, 0.5095, 0.375]}, {"w": "an", "b": [0.5143, 0.3535, 0.5348, 0.375]}, {"w": "ℓ2", "b": [0.5395, 0.3535, 0.5541, 0.3758]}, {"w": "penalty", "b": [0.5588, 0.3535, 0.6203, 0.375]}, {"w": "by", "b": [0.6251, 0.3535, 0.6452, 0.375]}, {"w": "default.", "b": [0.6499, 0.3535, 0.7121, 0.375]}]}, {"id": "b_2", "type": "paragraph", "text": "The hyperparameter controlling the regularization strength of a Scikit-Learn LogisticRegression model is not alpha (as in other linear models), but its inverse: C. The higher the value of C, the less the model is regularized.", "words": [{"w": "The", "b": [0.2714, 0.3955, 0.3014, 0.4151]}, {"w": "hyperparameter", "b": [0.31, 0.3955, 0.4321, 0.4151]}, {"w": "controlling", "b": [0.4406, 0.3955, 0.5251, 0.4151]}, {"w": "the", "b": [0.5337, 0.3955, 0.5578, 0.4151]}, {"w": "regularization", "b": [0.5664, 0.3955, 0.673, 0.4151]}, {"w": "strength", "b": [0.6815, 0.3955, 0.7448, 0.4151]}, {"w": "of", "b": [0.7534, 0.3955, 0.7688, 0.4151]}, {"w": "a", "b": [0.7773, 0.3955, 0.7857, 0.4151]}, {"w": "Scikit-Learn", "b": [0.2714, 0.4137, 0.3649, 0.4333]}, {"w": "LogisticRegression", "b": [0.3709, 0.4166, 0.5338, 0.4304]}, {"w": "model", "b": [0.5398, 0.4137, 0.5881, 0.4333]}, {"w": "is", "b": [0.5941, 0.4137, 0.6062, 0.4333]}, {"w": "not", "b": [0.6122, 0.4137, 0.6381, 0.4333]}, {"w": "alpha", "b": [0.6441, 0.4166, 0.6894, 0.4304]}, {"w": "(as", "b": [0.6954, 0.4137, 0.7173, 0.4333]}, {"w": "in", "b": [0.7233, 0.4137, 0.7388, 0.4333]}, {"w": "other", "b": [0.7448, 0.4137, 0.7857, 0.4333]}, {"w": "linear", "b": [0.2714, 0.432, 0.3153, 0.4515]}, {"w": "models),", "b": [0.3205, 0.432, 0.3867, 0.4515]}, {"w": "but", "b": [0.3918, 0.432, 0.4174, 0.4515]}, {"w": "its", "b": [0.4226, 0.432, 0.4405, 0.4515]}, {"w": "inverse:", "b": [0.4457, 0.432, 0.5042, 0.4515]}, {"w": "C.", "b": [0.5094, 0.432, 0.5228, 0.4515]}, {"w": "The", "b": [0.528, 0.432, 0.558, 0.4515]}, {"w": "higher", "b": [0.5632, 0.432, 0.6127, 0.4515]}, {"w": "the", "b": [0.6179, 0.432, 0.642, 0.4515]}, {"w": "value", "b": [0.6472, 0.432, 0.6874, 0.4515]}, {"w": "of", "b": [0.6926, 0.432, 0.7079, 0.4515]}, {"w": "C,", "b": [0.7131, 0.432, 0.7265, 0.4515]}, {"w": "the", "b": [0.7317, 0.432, 0.7557, 0.4515]}, {"w": "less", "b": [0.7609, 0.4318, 0.7857, 0.4515]}, {"w": "the", "b": [0.2714, 0.4494, 0.2955, 0.469]}, {"w": "model", "b": [0.2998, 0.4494, 0.3481, 0.469]}, {"w": "is", "b": [0.3524, 0.4494, 0.3645, 0.469]}, {"w": "regularized.", "b": [0.3688, 0.4494, 0.4589, 0.469]}]}, {"id": "b_3", "type": "paragraph", "text": "Softmax Regression", "words": [{"w": "Softmax", "b": [0.1428, 0.4914, 0.229, 0.5199]}, {"w": "Regression", "b": [0.234, 0.4914, 0.3464, 0.5199]}]}, {"id": "b_4", "type": "paragraph", "text": "The Logistic Regression model can be generalized to support multiple classes directly, without having to train and combine multiple binary classifiers (as discussed in Chapter 3). This is called Softmax Regression, or Multinomial Logistic Regression.", "words": [{"w": "The", "b": [0.1429, 0.5259, 0.1757, 0.5473]}, {"w": "Logistic", "b": [0.1806, 0.5259, 0.2462, 0.5473]}, {"w": "Regression", "b": [0.2512, 0.5259, 0.3422, 0.5473]}, {"w": "model", "b": [0.3471, 0.5259, 0.3999, 0.5473]}, {"w": "can", "b": [0.4049, 0.5259, 0.4342, 0.5473]}, {"w": "be", "b": [0.4392, 0.5259, 0.4586, 0.5473]}, {"w": "generalized", "b": [0.4636, 0.5259, 0.5588, 0.5473]}, {"w": "to", "b": [0.5637, 0.5259, 0.5807, 0.5473]}, {"w": "support", "b": [0.5856, 0.5259, 0.6509, 0.5473]}, {"w": "multiple", "b": [0.6558, 0.5259, 0.7258, 0.5473]}, {"w": "classes", "b": [0.7308, 0.5259, 0.7858, 0.5473]}, {"w": "directly,", "b": [0.7908, 0.5259, 0.8571, 0.5473]}, {"w": "without", "b": [0.1429, 0.5449, 0.2082, 0.5663]}, {"w": "having", "b": [0.2179, 0.5449, 0.2741, 0.5663]}, {"w": "to", "b": [0.2838, 0.5449, 0.3008, 0.5663]}, {"w": "train", "b": [0.3104, 0.5449, 0.3506, 0.5663]}, {"w": "and", "b": [0.3603, 0.5449, 0.3918, 0.5663]}, {"w": "combine", "b": [0.4015, 0.5449, 0.4744, 0.5663]}, {"w": "multiple", "b": [0.484, 0.5449, 0.554, 0.5663]}, {"w": "binary", "b": [0.5636, 0.5449, 0.6182, 0.5663]}, {"w": "classifiers", "b": [0.6279, 0.5449, 0.708, 0.5663]}, {"w": "(as", "b": [0.7176, 0.5449, 0.7416, 0.5663]}, {"w": "discussed", "b": [0.7513, 0.5449, 0.8305, 0.5663]}, {"w": "in", "b": [0.8402, 0.5449, 0.8571, 0.5663]}, {"w": "Chapter", "b": [0.1428, 0.5639, 0.2104, 0.5854]}, {"w": "3).", "b": [0.2152, 0.5639, 0.2371, 0.5854]}, {"w": "This", "b": [0.2418, 0.5639, 0.2791, 0.5854]}, {"w": "is", "b": [0.2838, 0.5639, 0.297, 0.5854]}, {"w": "called", "b": [0.3017, 0.5639, 0.3501, 0.5854]}, {"w": "Softmax", "b": [0.3548, 0.5637, 0.4226, 0.5854]}, {"w": "Regression,", "b": [0.4274, 0.5637, 0.5169, 0.5854]}, {"w": "or", "b": [0.5216, 0.5639, 0.54, 0.5854]}, {"w": "Multinomial", "b": [0.5447, 0.5637, 0.6472, 0.5854]}, {"w": "Logistic", "b": [0.652, 0.5637, 0.7142, 0.5854]}, {"w": "Regression.", "b": [0.7189, 0.5637, 0.8084, 0.5854]}]}, {"id": "b_5", "type": "paragraph", "text": "The idea is quite simple: when given an instance x, the Softmax Regression model first computes a score sk(x) for each class k, then estimates the probability of each class by applying the softmax function (also called the normalized exponential) to the scores. The equation to compute sk(x) should look familiar, as it is just like the equa‐ tion for Linear Regression prediction (see Equation 4-19).", "words": [{"w": "The", "b": [0.1428, 0.5921, 0.1757, 0.6135]}, {"w": "idea", "b": [0.1831, 0.5921, 0.2177, 0.6135]}, {"w": "is", "b": [0.2252, 0.5921, 0.2384, 0.6135]}, {"w": "quite", "b": [0.2458, 0.5921, 0.2883, 0.6135]}, {"w": "simple:", "b": [0.2958, 0.5921, 0.3555, 0.6135]}, {"w": "when", "b": [0.3629, 0.5921, 0.4086, 0.6135]}, {"w": "given", "b": [0.416, 0.5921, 0.4612, 0.6135]}, {"w": "an", "b": [0.4687, 0.5921, 0.4892, 0.6135]}, {"w": "instance", "b": [0.4967, 0.5921, 0.5659, 0.6135]}, {"w": "x,", "b": [0.5733, 0.5915, 0.5881, 0.6135]}, {"w": "the", "b": [0.5956, 0.5921, 0.6219, 0.6135]}, {"w": "Softmax", "b": [0.6293, 0.5921, 0.6984, 0.6135]}, {"w": "Regression", "b": [0.7059, 0.5921, 0.7969, 0.6135]}, {"w": "model", "b": [0.8043, 0.5921, 0.8571, 0.6135]}, {"w": "first", "b": [0.1429, 0.6111, 0.1763, 0.6325]}, {"w": "computes", "b": [0.1839, 0.6111, 0.2649, 0.6325]}, {"w": "a", "b": [0.2725, 0.6111, 0.2816, 0.6325]}, {"w": "score", "b": [0.2892, 0.6111, 0.3329, 0.6325]}, {"w": "sk(x)", "b": [0.3405, 0.6106, 0.3778, 0.6334]}, {"w": "for", "b": [0.3854, 0.6111, 0.4099, 0.6325]}, {"w": "each", "b": [0.4175, 0.6111, 0.4555, 0.6325]}, {"w": "class", "b": [0.4631, 0.6111, 0.5016, 0.6325]}, {"w": "k,", "b": [0.5092, 0.6109, 0.5237, 0.6325]}, {"w": "then", "b": [0.5313, 0.6111, 0.5691, 0.6325]}, {"w": "estimates", "b": [0.5767, 0.6111, 0.6538, 0.6325]}, {"w": "the", "b": [0.6614, 0.6111, 0.6877, 0.6325]}, {"w": "probability", "b": [0.6953, 0.6111, 0.7872, 0.6325]}, {"w": "of", "b": [0.7948, 0.6111, 0.8116, 0.6325]}, {"w": "each", "b": [0.8192, 0.6111, 0.8571, 0.6325]}, {"w": "class", "b": [0.1429, 0.6302, 0.1814, 0.6516]}, {"w": "by", "b": [0.1873, 0.6302, 0.2075, 0.6516]}, {"w": "applying", "b": [0.2134, 0.6302, 0.2856, 0.6516]}, {"w": "the", "b": [0.2915, 0.6302, 0.3178, 0.6516]}, {"w": "softmax", "b": [0.3238, 0.63, 0.3889, 0.6516]}, {"w": "function", "b": [0.3949, 0.63, 0.463, 0.6516]}, {"w": "(also", "b": [0.4689, 0.6302, 0.5088, 0.6516]}, {"w": "called", "b": [0.5147, 0.6302, 0.5631, 0.6516]}, {"w": "the", "b": [0.569, 0.6302, 0.5954, 0.6516]}, {"w": "normalized", "b": [0.6013, 0.63, 0.6941, 0.6516]}, {"w": "exponential)", "b": [0.7, 0.63, 0.8019, 0.6516]}, {"w": "to", "b": [0.8079, 0.6302, 0.8249, 0.6516]}, {"w": "the", "b": [0.8308, 0.6302, 0.8571, 0.6516]}, {"w": "scores.", "b": [0.1429, 0.6492, 0.1989, 0.6706]}, {"w": "The", "b": [0.2046, 0.6492, 0.2375, 0.6706]}, {"w": "equation", "b": [0.2432, 0.6492, 0.3165, 0.6706]}, {"w": "to", "b": [0.3222, 0.6492, 0.3392, 0.6706]}, {"w": "compute", "b": [0.3449, 0.6492, 0.4182, 0.6706]}, {"w": "sk(x)", "b": [0.4239, 0.6487, 0.4613, 0.6715]}, {"w": "should", "b": [0.467, 0.6492, 0.5238, 0.6706]}, {"w": "look", "b": [0.5295, 0.6492, 0.5663, 0.6706]}, {"w": "familiar,", "b": [0.5721, 0.6492, 0.6412, 0.6706]}, {"w": "as", "b": [0.6469, 0.6492, 0.6637, 0.6706]}, {"w": "it", "b": [0.6694, 0.6492, 0.6814, 0.6706]}, {"w": "is", "b": [0.6871, 0.6492, 0.7003, 0.6706]}, {"w": "just", "b": [0.7061, 0.6492, 0.7365, 0.6706]}, {"w": "like", "b": [0.7422, 0.6492, 0.7722, 0.6706]}, {"w": "the", "b": [0.778, 0.6492, 0.8043, 0.6706]}, {"w": "equa‐", "b": [0.81, 0.6492, 0.8571, 0.6706]}, {"w": "tion", "b": [0.1429, 0.6683, 0.1768, 0.6897]}, {"w": "for", "b": [0.1815, 0.6683, 0.2061, 0.6897]}, {"w": "Linear", "b": [0.2108, 0.6683, 0.2647, 0.6897]}, {"w": "Regression", "b": [0.2694, 0.6683, 0.3605, 0.6897]}, {"w": "prediction", "b": [0.3652, 0.6683, 0.452, 0.6897]}, {"w": "(see", "b": [0.4568, 0.6683, 0.4893, 0.6897]}, {"w": "Equation", "b": [0.4941, 0.6683, 0.5703, 0.6897]}, {"w": "4-19).", "b": [0.575, 0.6683, 0.6244, 0.6897]}]}, {"id": "b_6", "type": "equation", "text": "Equation 4-19. Softmax score for class k", "words": [{"w": "Equation", "b": [0.1726, 0.7078, 0.2473, 0.7294]}, {"w": "4-19.", "b": [0.2521, 0.7078, 0.2937, 0.7294]}, {"w": "Softmax", "b": [0.2985, 0.7078, 0.3663, 0.7294]}, {"w": "score", "b": [0.3711, 0.7078, 0.4111, 0.7294]}, {"w": "for", "b": [0.4159, 0.7078, 0.4385, 0.7294]}, {"w": "class", "b": [0.4433, 0.7078, 0.4802, 0.7294]}, {"w": "k", "b": [0.4849, 0.7078, 0.4947, 0.7294]}]}, {"id": "b_7", "type": "equation", "text": "sk x = xTθ k", "words": [{"w": "sk", "b": [0.1726, 0.7401, 0.1868, 0.765]}, {"w": "x", "b": [0.1936, 0.7398, 0.2032, 0.7607]}, {"w": "=", "b": [0.2157, 0.7403, 0.2272, 0.7607]}, {"w": "xTθ", "b": [0.2327, 0.7364, 0.2628, 0.7607]}, {"w": "k", "b": [0.2683, 0.7364, 0.2757, 0.7529]}]}, {"id": "b_8", "type": "paragraph", "text": "Note that each class has its own dedicated parameter vector θ(k). All these vectors are typically stored as rows in a parameter matrix Θ.", "words": [{"w": "Note", "b": [0.1429, 0.784, 0.1836, 0.8054]}, {"w": "that", "b": [0.1894, 0.784, 0.2219, 0.8054]}, {"w": "each", "b": [0.2276, 0.784, 0.2656, 0.8054]}, {"w": "class", "b": [0.2713, 0.784, 0.3098, 0.8054]}, {"w": "has", "b": [0.3155, 0.784, 0.3434, 0.8054]}, {"w": "its", "b": [0.3491, 0.784, 0.3687, 0.8054]}, {"w": "own", "b": [0.3744, 0.784, 0.4107, 0.8054]}, {"w": "dedicated", "b": [0.4164, 0.784, 0.4966, 0.8054]}, {"w": "parameter", "b": [0.5023, 0.784, 0.5881, 0.8054]}, {"w": "vector", "b": [0.5938, 0.784, 0.6458, 0.8054]}, {"w": "θ(k).", "b": [0.6515, 0.7835, 0.6812, 0.8054]}, {"w": "All", "b": [0.6869, 0.784, 0.7118, 0.8054]}, {"w": "these", "b": [0.7175, 0.784, 0.7603, 0.8054]}, {"w": "vectors", "b": [0.766, 0.784, 0.8257, 0.8054]}, {"w": "are", "b": [0.8314, 0.784, 0.8571, 0.8054]}, {"w": "typically", "b": [0.1429, 0.8031, 0.2133, 0.8245]}, {"w": "stored", "b": [0.2181, 0.8031, 0.2703, 0.8245]}, {"w": "as", "b": [0.275, 0.8031, 0.2918, 0.8245]}, {"w": "rows", "b": [0.2965, 0.8031, 0.3368, 0.8245]}, {"w": "in", "b": [0.3415, 0.8031, 0.3585, 0.8245]}, {"w": "a", "b": [0.3632, 0.8031, 0.3724, 0.8245]}, {"w": "parameter", "b": [0.3771, 0.8029, 0.4607, 0.8245]}, {"w": "matrix", "b": [0.4655, 0.8029, 0.521, 0.8245]}, {"w": "Θ.", "b": [0.5258, 0.8025, 0.5464, 0.8245]}]}, {"id": "b_9", "type": "paragraph", "text": "Once you have computed the score of every class for the instance x, you can estimate the probability pk that the instance belongs to class k by running the scores through the softmax function (Equation 4-20): it computes the exponential of every score,", "words": [{"w": "Once", "b": [0.1429, 0.8312, 0.1875, 0.8526]}, {"w": "you", "b": [0.1928, 0.8312, 0.2241, 0.8526]}, {"w": "have", "b": [0.2294, 0.8312, 0.2678, 0.8526]}, {"w": "computed", "b": [0.2732, 0.8312, 0.3575, 0.8526]}, {"w": "the", "b": [0.3628, 0.8312, 0.3892, 0.8526]}, {"w": "score", "b": [0.3945, 0.8312, 0.4382, 0.8526]}, {"w": "of", "b": [0.4435, 0.8312, 0.4603, 0.8526]}, {"w": "every", "b": [0.4657, 0.8312, 0.5109, 0.8526]}, {"w": "class", "b": [0.5163, 0.8312, 0.5548, 0.8526]}, {"w": "for", "b": [0.5601, 0.8312, 0.5847, 0.8526]}, {"w": "the", "b": [0.59, 0.8312, 0.6163, 0.8526]}, {"w": "instance", "b": [0.6217, 0.8312, 0.6909, 0.8526]}, {"w": "x,", "b": [0.6962, 0.8306, 0.711, 0.8526]}, {"w": "you", "b": [0.7164, 0.8312, 0.7476, 0.8526]}, {"w": "can", "b": [0.753, 0.8312, 0.7823, 0.8526]}, {"w": "estimate", "b": [0.7877, 0.8312, 0.8571, 0.8526]}, {"w": "the", "b": [0.1429, 0.8504, 0.1692, 0.8718]}, {"w": "probability", "b": [0.1754, 0.8504, 0.2673, 0.8718]}, {"w": "pk", "b": [0.275, 0.8502, 0.2912, 0.8727]}, {"w": "that", "b": [0.2974, 0.8504, 0.33, 0.8718]}, {"w": "the", "b": [0.3362, 0.8504, 0.3626, 0.8718]}, {"w": "instance", "b": [0.3688, 0.8504, 0.438, 0.8718]}, {"w": "belongs", "b": [0.4442, 0.8504, 0.5083, 0.8718]}, {"w": "to", "b": [0.5145, 0.8504, 0.5315, 0.8718]}, {"w": "class", "b": [0.5377, 0.8504, 0.5762, 0.8718]}, {"w": "k", "b": [0.5824, 0.8502, 0.5922, 0.8718]}, {"w": "by", "b": [0.5984, 0.8504, 0.6186, 0.8718]}, {"w": "running", "b": [0.6248, 0.8504, 0.6931, 0.8718]}, {"w": "the", "b": [0.6993, 0.8504, 0.7256, 0.8718]}, {"w": "scores", "b": [0.7319, 0.8504, 0.7832, 0.8718]}, {"w": "through", "b": [0.7894, 0.8504, 0.8571, 0.8718]}, {"w": "the", "b": [0.1429, 0.8695, 0.1692, 0.8909]}, {"w": "softmax", "b": [0.1773, 0.8695, 0.2441, 0.8909]}, {"w": "function", "b": [0.2523, 0.8695, 0.3237, 0.8909]}, {"w": "(Equation", "b": [0.3318, 0.8695, 0.4153, 0.8909]}, {"w": "4-20):", "b": [0.4234, 0.8695, 0.4728, 0.8909]}, {"w": "it", "b": [0.4809, 0.8695, 0.4928, 0.8909]}, {"w": "computes", "b": [0.5009, 0.8695, 0.5819, 0.8909]}, {"w": "the", "b": [0.59, 0.8695, 0.6163, 0.8909]}, {"w": "exponential", "b": [0.6245, 0.8695, 0.7223, 0.8909]}, {"w": "of", "b": [0.7304, 0.8695, 0.7472, 0.8909]}, {"w": "every", "b": [0.7553, 0.8695, 0.8006, 0.8909]}, {"w": "score,", "b": [0.8087, 0.8695, 0.8571, 0.8909]}]}, {"id": "b_10", "type": "paragraph", "text": "Logistic Regression | 149", "words": [{"w": "Logistic", "b": [0.6839, 0.9225, 0.7288, 0.9388]}, {"w": "Regression", "b": [0.7316, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "149", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 176, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "then normalizes them (dividing by the sum of all the exponentials). The scores are generally called logits or log-odds (although they are actually unnormalized log- odds).", "words": [{"w": "then", "b": [0.1429, 0.0791, 0.1806, 0.1005]}, {"w": "normalizes", "b": [0.1877, 0.0791, 0.2797, 0.1005]}, {"w": "them", "b": [0.2868, 0.0791, 0.3302, 0.1005]}, {"w": "(dividing", "b": [0.3373, 0.0791, 0.414, 0.1005]}, {"w": "by", "b": [0.4211, 0.0791, 0.4412, 0.1005]}, {"w": "the", "b": [0.4483, 0.0791, 0.4746, 0.1005]}, {"w": "sum", "b": [0.4817, 0.0791, 0.5175, 0.1005]}, {"w": "of", "b": [0.5246, 0.0791, 0.5414, 0.1005]}, {"w": "all", "b": [0.5484, 0.0791, 0.5681, 0.1005]}, {"w": "the", "b": [0.5752, 0.0791, 0.6015, 0.1005]}, {"w": "exponentials).", "b": [0.6086, 0.0791, 0.726, 0.1005]}, {"w": "The", "b": [0.7331, 0.0791, 0.766, 0.1005]}, {"w": "scores", "b": [0.773, 0.0791, 0.8243, 0.1005]}, {"w": "are", "b": [0.8314, 0.0791, 0.8571, 0.1005]}, {"w": "generally", "b": [0.1429, 0.0981, 0.2187, 0.1195]}, {"w": "called", "b": [0.2281, 0.0981, 0.2765, 0.1195]}, {"w": "logits", "b": [0.2859, 0.0981, 0.3311, 0.1195]}, {"w": "or", "b": [0.3406, 0.0981, 0.3589, 0.1195]}, {"w": "log-odds", "b": [0.3684, 0.0981, 0.4417, 0.1195]}, {"w": "(although", "b": [0.4511, 0.0981, 0.5328, 0.1195]}, {"w": "they", "b": [0.5422, 0.0981, 0.5781, 0.1195]}, {"w": "are", "b": [0.5875, 0.0981, 0.6133, 0.1195]}, {"w": "actually", "b": [0.6227, 0.0981, 0.6873, 0.1195]}, {"w": "unnormalized", "b": [0.6968, 0.0981, 0.8146, 0.1195]}, {"w": "log-", "b": [0.8241, 0.0981, 0.8571, 0.1195]}, {"w": "odds).", "b": [0.1429, 0.1172, 0.1951, 0.1386]}]}, {"id": "b_1", "type": "equation", "text": "Equation 4-20. Softmax function", "words": [{"w": "Equation", "b": [0.1726, 0.1567, 0.2473, 0.1783]}, {"w": "4-20.", "b": [0.2521, 0.1567, 0.2937, 0.1783]}, {"w": "Softmax", "b": [0.2985, 0.1567, 0.3663, 0.1783]}, {"w": "function", "b": [0.3711, 0.1567, 0.4392, 0.1783]}]}, {"id": "b_2", "type": "equation", "text": "pk = σ s x k =", "words": [{"w": "pk", "b": [0.174, 0.1992, 0.1913, 0.2241]}, {"w": "=", "b": [0.1968, 0.1994, 0.2083, 0.2198]}, {"w": "σ", "b": [0.2138, 0.1992, 0.2233, 0.2198]}, {"w": "s", "b": [0.231, 0.1989, 0.2386, 0.2198]}, {"w": "x", "b": [0.2455, 0.1989, 0.255, 0.2198]}, {"w": "k", "b": [0.2689, 0.2076, 0.2764, 0.2241]}, {"w": "=", "b": [0.2819, 0.1994, 0.2934, 0.2198]}]}, {"id": "b_3", "type": "paragraph", "text": "exp sk x", "words": [{"w": "exp", "b": [0.3252, 0.1861, 0.3534, 0.2064]}, {"w": "sk", "b": [0.3658, 0.1859, 0.3799, 0.2107]}, {"w": "x", "b": [0.3868, 0.1855, 0.3963, 0.2064]}]}, {"id": "b_4", "type": "equation", "text": "∑j = 1", "words": [{"w": "∑j", "b": [0.3011, 0.2128, 0.3176, 0.2374]}, {"w": "=", "b": [0.322, 0.2211, 0.3312, 0.2374]}, {"w": "1", "b": [0.3356, 0.2211, 0.3432, 0.2374]}]}, {"id": "b_5", "type": "paragraph", "text": "K exp sj x", "words": [{"w": "K", "b": [0.3117, 0.2089, 0.3221, 0.2253]}, {"w": "exp", "b": [0.3509, 0.2128, 0.3791, 0.2332]}, {"w": "sj", "b": [0.3915, 0.2126, 0.404, 0.2374]}, {"w": "x", "b": [0.4109, 0.2122, 0.4205, 0.2332]}]}, {"id": "b_6", "type": "paragraph", "text": "• K is the number of classes.", "words": [{"w": "•", "b": [0.16, 0.2625, 0.1681, 0.2839]}, {"w": "K", "b": [0.1786, 0.2623, 0.1922, 0.2839]}, {"w": "is", "b": [0.1969, 0.2625, 0.2101, 0.2839]}, {"w": "the", "b": [0.2149, 0.2625, 0.2412, 0.2839]}, {"w": "number", "b": [0.2459, 0.2625, 0.3122, 0.2839]}, {"w": "of", "b": [0.3169, 0.2625, 0.3337, 0.2839]}, {"w": "classes.", "b": [0.3385, 0.2625, 0.3982, 0.2839]}]}, {"id": "b_7", "type": "paragraph", "text": "• s(x) is a vector containing the scores of each class for the instance x.", "words": [{"w": "•", "b": [0.16, 0.2876, 0.1682, 0.309]}, {"w": "s(x)", "b": [0.1786, 0.2871, 0.211, 0.309]}, {"w": "is", "b": [0.2157, 0.2876, 0.229, 0.309]}, {"w": "a", "b": [0.2337, 0.2876, 0.2428, 0.309]}, {"w": "vector", "b": [0.2476, 0.2876, 0.2996, 0.309]}, {"w": "containing", "b": [0.3043, 0.2876, 0.394, 0.309]}, {"w": "the", "b": [0.3987, 0.2876, 0.425, 0.309]}, {"w": "scores", "b": [0.4298, 0.2876, 0.4811, 0.309]}, {"w": "of", "b": [0.4858, 0.2876, 0.5026, 0.309]}, {"w": "each", "b": [0.5073, 0.2876, 0.5453, 0.309]}, {"w": "class", "b": [0.55, 0.2876, 0.5885, 0.309]}, {"w": "for", "b": [0.5932, 0.2876, 0.6178, 0.309]}, {"w": "the", "b": [0.6225, 0.2876, 0.6488, 0.309]}, {"w": "instance", "b": [0.6535, 0.2876, 0.7227, 0.309]}, {"w": "x.", "b": [0.7275, 0.2871, 0.7423, 0.309]}]}, {"id": "b_8", "type": "paragraph", "text": "• σ(s(x))k is the estimated probability that the instance x belongs to class k given the scores of each class for that instance.", "words": [{"w": "•", "b": [0.16, 0.3127, 0.1682, 0.3341]}, {"w": "σ(s(x))k", "b": [0.1786, 0.3122, 0.2412, 0.335]}, {"w": "is", "b": [0.2482, 0.3127, 0.2615, 0.3341]}, {"w": "the", "b": [0.2685, 0.3127, 0.2948, 0.3341]}, {"w": "estimated", "b": [0.3018, 0.3127, 0.3823, 0.3341]}, {"w": "probability", "b": [0.3893, 0.3127, 0.4812, 0.3341]}, {"w": "that", "b": [0.4882, 0.3127, 0.5208, 0.3341]}, {"w": "the", "b": [0.5278, 0.3127, 0.5542, 0.3341]}, {"w": "instance", "b": [0.5612, 0.3127, 0.6304, 0.3341]}, {"w": "x", "b": [0.6374, 0.3122, 0.6474, 0.3341]}, {"w": "belongs", "b": [0.6544, 0.3127, 0.7186, 0.3341]}, {"w": "to", "b": [0.7256, 0.3127, 0.7426, 0.3341]}, {"w": "class", "b": [0.7496, 0.3127, 0.7881, 0.3341]}, {"w": "k", "b": [0.7951, 0.3125, 0.8049, 0.3341]}, {"w": "given", "b": [0.8119, 0.3127, 0.8571, 0.3341]}, {"w": "the", "b": [0.1786, 0.3318, 0.2049, 0.3532]}, {"w": "scores", "b": [0.2096, 0.3318, 0.2609, 0.3532]}, {"w": "of", "b": [0.2657, 0.3318, 0.2825, 0.3532]}, {"w": "each", "b": [0.2872, 0.3318, 0.3251, 0.3532]}, {"w": "class", "b": [0.3299, 0.3318, 0.3684, 0.3532]}, {"w": "for", "b": [0.3731, 0.3318, 0.3976, 0.3532]}, {"w": "that", "b": [0.4024, 0.3318, 0.4349, 0.3532]}, {"w": "instance.", "b": [0.4397, 0.3318, 0.5136, 0.3532]}]}, {"id": "b_9", "type": "paragraph", "text": "Just like the Logistic Regression classifier, the Softmax Regression classifier predicts the class with the highest estimated probability (which is simply the class with the highest score), as shown in Equation 4-21.", "words": [{"w": "Just", "b": [0.1429, 0.3659, 0.1741, 0.3873]}, {"w": "like", "b": [0.181, 0.3659, 0.211, 0.3873]}, {"w": "the", "b": [0.2178, 0.3659, 0.2442, 0.3873]}, {"w": "Logistic", "b": [0.251, 0.3659, 0.3166, 0.3873]}, {"w": "Regression", "b": [0.3234, 0.3659, 0.4145, 0.3873]}, {"w": "classifier,", "b": [0.4213, 0.3659, 0.4972, 0.3873]}, {"w": "the", "b": [0.504, 0.3659, 0.5304, 0.3873]}, {"w": "Softmax", "b": [0.5372, 0.3659, 0.6063, 0.3873]}, {"w": "Regression", "b": [0.6131, 0.3659, 0.7041, 0.3873]}, {"w": "classifier", "b": [0.711, 0.3659, 0.7834, 0.3873]}, {"w": "predicts", "b": [0.7903, 0.3659, 0.8572, 0.3873]}, {"w": "the", "b": [0.1429, 0.385, 0.1692, 0.4064]}, {"w": "class", "b": [0.1767, 0.385, 0.2152, 0.4064]}, {"w": "with", "b": [0.2227, 0.385, 0.26, 0.4064]}, {"w": "the", "b": [0.2675, 0.385, 0.2939, 0.4064]}, {"w": "highest", "b": [0.3014, 0.385, 0.3618, 0.4064]}, {"w": "estimated", "b": [0.3693, 0.385, 0.4497, 0.4064]}, {"w": "probability", "b": [0.4572, 0.385, 0.5492, 0.4064]}, {"w": "(which", "b": [0.5567, 0.385, 0.6148, 0.4064]}, {"w": "is", "b": [0.6223, 0.385, 0.6355, 0.4064]}, {"w": "simply", "b": [0.643, 0.385, 0.6987, 0.4064]}, {"w": "the", "b": [0.7061, 0.385, 0.7325, 0.4064]}, {"w": "class", "b": [0.74, 0.385, 0.7785, 0.4064]}, {"w": "with", "b": [0.786, 0.385, 0.8233, 0.4064]}, {"w": "the", "b": [0.8308, 0.385, 0.8571, 0.4064]}, {"w": "highest", "b": [0.1429, 0.404, 0.2033, 0.4254]}, {"w": "score),", "b": [0.208, 0.404, 0.2636, 0.4254]}, {"w": "as", "b": [0.2684, 0.404, 0.2852, 0.4254]}, {"w": "shown", "b": [0.2899, 0.404, 0.345, 0.4254]}, {"w": "in", "b": [0.3497, 0.404, 0.3667, 0.4254]}, {"w": "Equation", "b": [0.3714, 0.404, 0.4476, 0.4254]}, {"w": "4-21.", "b": [0.4524, 0.404, 0.4945, 0.4254]}]}, {"id": "b_10", "type": "equation", "text": "Equation 4-21. Softmax Regression classifier prediction", "words": [{"w": "Equation", "b": [0.1726, 0.4436, 0.2473, 0.4652]}, {"w": "4-21.", "b": [0.2521, 0.4436, 0.2937, 0.4652]}, {"w": "Softmax", "b": [0.2985, 0.4436, 0.3663, 0.4652]}, {"w": "Regression", "b": [0.3711, 0.4436, 0.4558, 0.4652]}, {"w": "classifier", "b": [0.4606, 0.4436, 0.5307, 0.4652]}, {"w": "prediction", "b": [0.5355, 0.4436, 0.6173, 0.4652]}]}, {"id": "b_11", "type": "equation", "text": "y = argmax", "words": [{"w": "y", "b": [0.1738, 0.4792, 0.1825, 0.4998]}, {"w": "=", "b": [0.1894, 0.4794, 0.2009, 0.4998]}, {"w": "argmax", "b": [0.2119, 0.4794, 0.2716, 0.4998]}]}, {"id": "b_13", "type": "equation", "text": "σ s x k = argmax", "words": [{"w": "σ", "b": [0.2804, 0.4792, 0.2898, 0.4998]}, {"w": "s", "b": [0.2976, 0.4788, 0.3052, 0.4998]}, {"w": "x", "b": [0.312, 0.4788, 0.3216, 0.4998]}, {"w": "k", "b": [0.3354, 0.4876, 0.3429, 0.504]}, {"w": "=", "b": [0.3484, 0.4794, 0.3599, 0.4998]}, {"w": "argmax", "b": [0.371, 0.4794, 0.4306, 0.4998]}]}, {"id": "b_15", "type": "equation", "text": "sk x = argmax", "words": [{"w": "sk", "b": [0.4395, 0.4792, 0.4536, 0.504]}, {"w": "x", "b": [0.4605, 0.4788, 0.47, 0.4998]}, {"w": "=", "b": [0.4825, 0.4794, 0.494, 0.4998]}, {"w": "argmax", "b": [0.5051, 0.4794, 0.5647, 0.4998]}]}, {"id": "b_17", "type": "paragraph", "text": "θ k Tx", "words": [{"w": "θ", "b": [0.5873, 0.4788, 0.5974, 0.4998]}, {"w": "k", "b": [0.6029, 0.4755, 0.6103, 0.4919]}, {"w": "Tx", "b": [0.6227, 0.4722, 0.6425, 0.4998]}]}, {"id": "b_18", "type": "paragraph", "text": "• The argmax operator returns the value of a variable that maximizes a function. In this equation, it returns the value of k that maximizes the estimated probability σ(s(x))k.", "words": [{"w": "•", "b": [0.16, 0.5364, 0.1681, 0.5578]}, {"w": "The", "b": [0.1786, 0.5364, 0.2114, 0.5578]}, {"w": "argmax", "b": [0.2162, 0.5362, 0.2788, 0.5578]}, {"w": "operator", "b": [0.2836, 0.5364, 0.3552, 0.5578]}, {"w": "returns", "b": [0.36, 0.5364, 0.4208, 0.5578]}, {"w": "the", "b": [0.4256, 0.5364, 0.4519, 0.5578]}, {"w": "value", "b": [0.4568, 0.5364, 0.5008, 0.5578]}, {"w": "of", "b": [0.5056, 0.5364, 0.5224, 0.5578]}, {"w": "a", "b": [0.5272, 0.5364, 0.5363, 0.5578]}, {"w": "variable", "b": [0.5412, 0.5364, 0.6071, 0.5578]}, {"w": "that", "b": [0.612, 0.5364, 0.6445, 0.5578]}, {"w": "maximizes", "b": [0.6494, 0.5364, 0.7389, 0.5578]}, {"w": "a", "b": [0.7437, 0.5364, 0.7529, 0.5578]}, {"w": "function.", "b": [0.7577, 0.5364, 0.8338, 0.5578]}, {"w": "In", "b": [0.8387, 0.5364, 0.8572, 0.5578]}, {"w": "this", "b": [0.1786, 0.5555, 0.2093, 0.5769]}, {"w": "equation,", "b": [0.2159, 0.5555, 0.2939, 0.5769]}, {"w": "it", "b": [0.3005, 0.5555, 0.3125, 0.5769]}, {"w": "returns", "b": [0.3191, 0.5555, 0.3799, 0.5769]}, {"w": "the", "b": [0.3865, 0.5555, 0.4128, 0.5769]}, {"w": "value", "b": [0.4194, 0.5555, 0.4634, 0.5769]}, {"w": "of", "b": [0.47, 0.5555, 0.4868, 0.5769]}, {"w": "k", "b": [0.4934, 0.5553, 0.5032, 0.5769]}, {"w": "that", "b": [0.5098, 0.5555, 0.5424, 0.5769]}, {"w": "maximizes", "b": [0.549, 0.5555, 0.6386, 0.5769]}, {"w": "the", "b": [0.6452, 0.5555, 0.6715, 0.5769]}, {"w": "estimated", "b": [0.6781, 0.5555, 0.7586, 0.5769]}, {"w": "probability", "b": [0.7652, 0.5555, 0.8571, 0.5769]}, {"w": "σ(s(x))k.", "b": [0.1786, 0.574, 0.246, 0.5968]}]}, {"id": "b_19", "type": "paragraph", "text": "The Softmax Regression classifier predicts only one class at a time (i.e., it is multiclass, not multioutput) so it should be used only with mutually exclusive classes such as different types of plants. You cannot use it to recognize multiple people in one picture.", "words": [{"w": "The", "b": [0.2714, 0.6316, 0.3014, 0.6512]}, {"w": "Softmax", "b": [0.3071, 0.6316, 0.3702, 0.6512]}, {"w": "Regression", "b": [0.3759, 0.6316, 0.4591, 0.6512]}, {"w": "classifier", "b": [0.4648, 0.6316, 0.531, 0.6512]}, {"w": "predicts", "b": [0.5367, 0.6316, 0.5978, 0.6512]}, {"w": "only", "b": [0.6035, 0.6316, 0.6372, 0.6512]}, {"w": "one", "b": [0.6428, 0.6316, 0.6711, 0.6512]}, {"w": "class", "b": [0.6767, 0.6316, 0.7119, 0.6512]}, {"w": "at", "b": [0.7176, 0.6316, 0.7314, 0.6512]}, {"w": "a", "b": [0.7371, 0.6316, 0.7454, 0.6512]}, {"w": "time", "b": [0.7511, 0.6316, 0.7857, 0.6512]}, {"w": "(i.e.,", "b": [0.2714, 0.649, 0.3042, 0.6686]}, {"w": "it", "b": [0.3085, 0.649, 0.3195, 0.6686]}, {"w": "is", "b": [0.3238, 0.649, 0.3359, 0.6686]}, {"w": "multiclass,", "b": [0.3402, 0.649, 0.4209, 0.6686]}, {"w": "not", "b": [0.4252, 0.649, 0.4511, 0.6686]}, {"w": "multioutput)", "b": [0.4554, 0.649, 0.5547, 0.6686]}, {"w": "so", "b": [0.559, 0.649, 0.5757, 0.6686]}, {"w": "it", "b": [0.58, 0.649, 0.5909, 0.6686]}, {"w": "should", "b": [0.5953, 0.649, 0.6471, 0.6686]}, {"w": "be", "b": [0.6514, 0.649, 0.6692, 0.6686]}, {"w": "used", "b": [0.6735, 0.649, 0.7088, 0.6686]}, {"w": "only", "b": [0.7131, 0.649, 0.7468, 0.6686]}, {"w": "with", "b": [0.7511, 0.649, 0.7853, 0.6686]}, {"w": "mutually", "b": [0.2714, 0.6664, 0.3394, 0.686]}, {"w": "exclusive", "b": [0.3478, 0.6664, 0.4169, 0.686]}, {"w": "classes", "b": [0.4253, 0.6664, 0.4756, 0.686]}, {"w": "such", "b": [0.4841, 0.6664, 0.5194, 0.686]}, {"w": "as", "b": [0.5278, 0.6664, 0.5432, 0.686]}, {"w": "different", "b": [0.5516, 0.6664, 0.6171, 0.686]}, {"w": "types", "b": [0.6255, 0.6664, 0.6652, 0.686]}, {"w": "of", "b": [0.6736, 0.6664, 0.6889, 0.686]}, {"w": "plants.", "b": [0.6974, 0.6664, 0.7477, 0.686]}, {"w": "You", "b": [0.7561, 0.6664, 0.7857, 0.686]}, {"w": "cannot", "b": [0.2714, 0.6838, 0.3242, 0.7034]}, {"w": "use", "b": [0.3285, 0.6838, 0.3537, 0.7034]}, {"w": "it", "b": [0.358, 0.6838, 0.3689, 0.7034]}, {"w": "to", "b": [0.3733, 0.6838, 0.3888, 0.7034]}, {"w": "recognize", "b": [0.3931, 0.6838, 0.4666, 0.7034]}, {"w": "multiple", "b": [0.4709, 0.6838, 0.5349, 0.7034]}, {"w": "people", "b": [0.5392, 0.6838, 0.5899, 0.7034]}, {"w": "in", "b": [0.5942, 0.6838, 0.6097, 0.7034]}, {"w": "one", "b": [0.6141, 0.6838, 0.6423, 0.7034]}, {"w": "picture.", "b": [0.6466, 0.6838, 0.7052, 0.7034]}]}, {"id": "b_20", "type": "paragraph", "text": "Now that you know how the model estimates probabilities and makes predictions, let’s take a look at training. The objective is to have a model that estimates a high probability for the target class (and consequently a low probability for the other classes). Minimizing the cost function shown in Equation 4-22, called the cross entropy, should lead to this objective because it penalizes the model when it estimates a low probability for a target class. Cross entropy is frequently used to measure how", "words": [{"w": "Now", "b": [0.1429, 0.7302, 0.1827, 0.7516]}, {"w": "that", "b": [0.1903, 0.7302, 0.2229, 0.7516]}, {"w": "you", "b": [0.2305, 0.7302, 0.2617, 0.7516]}, {"w": "know", "b": [0.2693, 0.7302, 0.3159, 0.7516]}, {"w": "how", "b": [0.3235, 0.7302, 0.3595, 0.7516]}, {"w": "the", "b": [0.3671, 0.7302, 0.3934, 0.7516]}, {"w": "model", "b": [0.401, 0.7302, 0.4538, 0.7516]}, {"w": "estimates", "b": [0.4614, 0.7302, 0.5385, 0.7516]}, {"w": "probabilities", "b": [0.5461, 0.7302, 0.6506, 0.7516]}, {"w": "and", "b": [0.6581, 0.7302, 0.6897, 0.7516]}, {"w": "makes", "b": [0.6973, 0.7302, 0.7503, 0.7516]}, {"w": "predictions,", "b": [0.7579, 0.7302, 0.8571, 0.7516]}, {"w": "let’s", "b": [0.1429, 0.7493, 0.1731, 0.7707]}, {"w": "take", "b": [0.1807, 0.7493, 0.2154, 0.7707]}, {"w": "a", "b": [0.223, 0.7493, 0.2322, 0.7707]}, {"w": "look", "b": [0.2398, 0.7493, 0.2767, 0.7707]}, {"w": "at", "b": [0.2843, 0.7493, 0.2994, 0.7707]}, {"w": "training.", "b": [0.307, 0.7493, 0.3787, 0.7707]}, {"w": "The", "b": [0.3864, 0.7493, 0.4192, 0.7707]}, {"w": "objective", "b": [0.4268, 0.7493, 0.5015, 0.7707]}, {"w": "is", "b": [0.5091, 0.7493, 0.5223, 0.7707]}, {"w": "to", "b": [0.53, 0.7493, 0.5469, 0.7707]}, {"w": "have", "b": [0.5546, 0.7493, 0.593, 0.7707]}, {"w": "a", "b": [0.6006, 0.7493, 0.6097, 0.7707]}, {"w": "model", "b": [0.6174, 0.7493, 0.6702, 0.7707]}, {"w": "that", "b": [0.6778, 0.7493, 0.7104, 0.7707]}, {"w": "estimates", "b": [0.718, 0.7493, 0.7951, 0.7707]}, {"w": "a", "b": [0.8028, 0.7493, 0.8119, 0.7707]}, {"w": "high", "b": [0.8196, 0.7493, 0.8571, 0.7707]}, {"w": "probability", "b": [0.1428, 0.7683, 0.2348, 0.7897]}, {"w": "for", "b": [0.2439, 0.7683, 0.2684, 0.7897]}, {"w": "the", "b": [0.2775, 0.7683, 0.3038, 0.7897]}, {"w": "target", "b": [0.3129, 0.7683, 0.3611, 0.7897]}, {"w": "class", "b": [0.3702, 0.7683, 0.4087, 0.7897]}, {"w": "(and", "b": [0.4178, 0.7683, 0.4566, 0.7897]}, {"w": "consequently", "b": [0.4657, 0.7683, 0.5758, 0.7897]}, {"w": "a", "b": [0.5849, 0.7683, 0.594, 0.7897]}, {"w": "low", "b": [0.6031, 0.7683, 0.6333, 0.7897]}, {"w": "probability", "b": [0.6424, 0.7683, 0.7343, 0.7897]}, {"w": "for", "b": [0.7434, 0.7683, 0.7679, 0.7897]}, {"w": "the", "b": [0.777, 0.7683, 0.8034, 0.7897]}, {"w": "other", "b": [0.8124, 0.7683, 0.8571, 0.7897]}, {"w": "classes).", "b": [0.1429, 0.7874, 0.2098, 0.8088]}, {"w": "Minimizing", "b": [0.2201, 0.7874, 0.3194, 0.8088]}, {"w": "the", "b": [0.3296, 0.7874, 0.356, 0.8088]}, {"w": "cost", "b": [0.3663, 0.7874, 0.3997, 0.8088]}, {"w": "function", "b": [0.41, 0.7874, 0.4814, 0.8088]}, {"w": "shown", "b": [0.4916, 0.7874, 0.5467, 0.8088]}, {"w": "in", "b": [0.557, 0.7874, 0.574, 0.8088]}, {"w": "Equation", "b": [0.5842, 0.7874, 0.6605, 0.8088]}, {"w": "4-22,", "b": [0.6708, 0.7874, 0.7129, 0.8088]}, {"w": "called", "b": [0.7232, 0.7874, 0.7716, 0.8088]}, {"w": "the", "b": [0.7819, 0.7874, 0.8082, 0.8088]}, {"w": "cross", "b": [0.8185, 0.7872, 0.8572, 0.8088]}, {"w": "entropy,", "b": [0.1429, 0.8062, 0.2087, 0.8278]}, {"w": "should", "b": [0.2139, 0.8064, 0.2707, 0.8278]}, {"w": "lead", "b": [0.2759, 0.8064, 0.3102, 0.8278]}, {"w": "to", "b": [0.3155, 0.8064, 0.3324, 0.8278]}, {"w": "this", "b": [0.3377, 0.8064, 0.3684, 0.8278]}, {"w": "objective", "b": [0.3737, 0.8064, 0.4483, 0.8278]}, {"w": "because", "b": [0.4536, 0.8064, 0.5181, 0.8278]}, {"w": "it", "b": [0.5234, 0.8064, 0.5353, 0.8278]}, {"w": "penalizes", "b": [0.5406, 0.8064, 0.617, 0.8278]}, {"w": "the", "b": [0.6223, 0.8064, 0.6486, 0.8278]}, {"w": "model", "b": [0.6539, 0.8064, 0.7067, 0.8278]}, {"w": "when", "b": [0.7119, 0.8064, 0.7576, 0.8278]}, {"w": "it", "b": [0.7628, 0.8064, 0.7748, 0.8278]}, {"w": "estimates", "b": [0.78, 0.8064, 0.8571, 0.8278]}, {"w": "a", "b": [0.1429, 0.8255, 0.152, 0.8469]}, {"w": "low", "b": [0.1581, 0.8255, 0.1882, 0.8469]}, {"w": "probability", "b": [0.1943, 0.8255, 0.2862, 0.8469]}, {"w": "for", "b": [0.2923, 0.8255, 0.3168, 0.8469]}, {"w": "a", "b": [0.3228, 0.8255, 0.332, 0.8469]}, {"w": "target", "b": [0.338, 0.8255, 0.3862, 0.8469]}, {"w": "class.", "b": [0.3923, 0.8255, 0.4355, 0.8469]}, {"w": "Cross", "b": [0.4416, 0.8255, 0.4891, 0.8469]}, {"w": "entropy", "b": [0.4951, 0.8255, 0.5602, 0.8469]}, {"w": "is", "b": [0.5662, 0.8255, 0.5795, 0.8469]}, {"w": "frequently", "b": [0.5855, 0.8255, 0.671, 0.8469]}, {"w": "used", "b": [0.6771, 0.8255, 0.7156, 0.8469]}, {"w": "to", "b": [0.7217, 0.8255, 0.7387, 0.8469]}, {"w": "measure", "b": [0.7447, 0.8255, 0.8151, 0.8469]}, {"w": "how", "b": [0.8211, 0.8255, 0.8571, 0.8469]}]}, {"id": "b_21", "type": "paragraph", "text": "150 | Chapter 4: Training Models", "words": [{"w": "150", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 177, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "well a set of estimated class probabilities match the target classes (we will use it again several times in the following chapters).", "words": [{"w": "well", "b": [0.1429, 0.0791, 0.1765, 0.1005]}, {"w": "a", "b": [0.182, 0.0791, 0.1911, 0.1005]}, {"w": "set", "b": [0.1965, 0.0791, 0.2194, 0.1005]}, {"w": "of", "b": [0.2248, 0.0791, 0.2416, 0.1005]}, {"w": "estimated", "b": [0.247, 0.0791, 0.3275, 0.1005]}, {"w": "class", "b": [0.3329, 0.0791, 0.3715, 0.1005]}, {"w": "probabilities", "b": [0.3769, 0.0791, 0.4814, 0.1005]}, {"w": "match", "b": [0.4868, 0.0791, 0.5389, 0.1005]}, {"w": "the", "b": [0.5443, 0.0791, 0.5707, 0.1005]}, {"w": "target", "b": [0.5761, 0.0791, 0.6243, 0.1005]}, {"w": "classes", "b": [0.6297, 0.0791, 0.6847, 0.1005]}, {"w": "(we", "b": [0.6902, 0.0791, 0.7205, 0.1005]}, {"w": "will", "b": [0.7259, 0.0791, 0.7563, 0.1005]}, {"w": "use", "b": [0.7618, 0.0791, 0.7893, 0.1005]}, {"w": "it", "b": [0.7948, 0.0791, 0.8067, 0.1005]}, {"w": "again", "b": [0.8121, 0.0791, 0.8571, 0.1005]}, {"w": "several", "b": [0.1429, 0.0981, 0.2, 0.1195]}, {"w": "times", "b": [0.2047, 0.0981, 0.2502, 0.1195]}, {"w": "in", "b": [0.255, 0.0981, 0.2719, 0.1195]}, {"w": "the", "b": [0.2767, 0.0981, 0.303, 0.1195]}, {"w": "following", "b": [0.3077, 0.0981, 0.3867, 0.1195]}, {"w": "chapters).", "b": [0.3914, 0.0981, 0.4736, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "Equation 4-22. Cross entropy cost function", "words": [{"w": "Equation", "b": [0.1726, 0.1376, 0.2473, 0.1593]}, {"w": "4-22.", "b": [0.2521, 0.1376, 0.2937, 0.1593]}, {"w": "Cross", "b": [0.2985, 0.1376, 0.3422, 0.1593]}, {"w": "entropy", "b": [0.3469, 0.1376, 0.408, 0.1593]}, {"w": "cost", "b": [0.4128, 0.1376, 0.4435, 0.1593]}, {"w": "function", "b": [0.4482, 0.1376, 0.5163, 0.1593]}]}, {"id": "b_2", "type": "equation", "text": "J Θ = −1", "words": [{"w": "J", "b": [0.1731, 0.1712, 0.1795, 0.1918]}, {"w": "Θ", "b": [0.1874, 0.1709, 0.2024, 0.1918]}, {"w": "=", "b": [0.2148, 0.1714, 0.2263, 0.1918]}, {"w": "−1", "b": [0.2318, 0.1664, 0.2567, 0.1918]}]}, {"id": "b_3", "type": "equation", "text": "m ∑i = 1", "words": [{"w": "m", "b": [0.2467, 0.1809, 0.2591, 0.1973]}, {"w": "∑i", "b": [0.2624, 0.1714, 0.2774, 0.1961]}, {"w": "=", "b": [0.2818, 0.1798, 0.291, 0.1961]}, {"w": "1", "b": [0.2954, 0.1798, 0.3031, 0.1961]}]}, {"id": "b_4", "type": "equation", "text": "m ∑k = 1", "words": [{"w": "m", "b": [0.2731, 0.1675, 0.2856, 0.184]}, {"w": "∑k", "b": [0.3064, 0.1714, 0.3245, 0.1961]}, {"w": "=", "b": [0.3289, 0.1798, 0.3381, 0.1961]}, {"w": "1", "b": [0.3425, 0.1798, 0.3501, 0.1961]}]}, {"id": "b_5", "type": "paragraph", "text": "K yk", "words": [{"w": "K", "b": [0.317, 0.1675, 0.3274, 0.184]}, {"w": "yk", "b": [0.3534, 0.1712, 0.3697, 0.1961]}]}, {"id": "b_6", "type": "paragraph", "text": "i log pk", "words": [{"w": "i", "b": [0.3677, 0.1675, 0.3721, 0.184]}, {"w": "log", "b": [0.3776, 0.1714, 0.402, 0.1918]}, {"w": "pk", "b": [0.4102, 0.1712, 0.4275, 0.1961]}]}, {"id": "b_8", "type": "paragraph", "text": "• yk i is the target probability that the ith instance belongs to class k. In general, it is either equal to 1 or 0, depending on whether the instance belongs to the class or not.", "words": [{"w": "•", "b": [0.16, 0.225, 0.1682, 0.2464]}, {"w": "yk", "b": [0.1798, 0.2248, 0.1964, 0.2502]}, {"w": "i", "b": [0.1945, 0.2217, 0.1988, 0.2382]}, {"w": "is", "b": [0.2097, 0.225, 0.2229, 0.2464]}, {"w": "the", "b": [0.2282, 0.225, 0.2546, 0.2464]}, {"w": "target", "b": [0.2599, 0.225, 0.3081, 0.2464]}, {"w": "probability", "b": [0.3134, 0.225, 0.4054, 0.2464]}, {"w": "that", "b": [0.4107, 0.225, 0.4433, 0.2464]}, {"w": "the", "b": [0.4486, 0.225, 0.4749, 0.2464]}, {"w": "ith", "b": [0.4803, 0.225, 0.4963, 0.2464]}, {"w": "instance", "b": [0.5017, 0.225, 0.5709, 0.2464]}, {"w": "belongs", "b": [0.5762, 0.225, 0.6403, 0.2464]}, {"w": "to", "b": [0.6457, 0.225, 0.6626, 0.2464]}, {"w": "class", "b": [0.668, 0.225, 0.7065, 0.2464]}, {"w": "k.", "b": [0.7118, 0.2248, 0.7264, 0.2464]}, {"w": "In", "b": [0.7317, 0.225, 0.7502, 0.2464]}, {"w": "general,", "b": [0.7555, 0.225, 0.8213, 0.2464]}, {"w": "it", "b": [0.8266, 0.225, 0.8386, 0.2464]}, {"w": "is", "b": [0.8439, 0.225, 0.8571, 0.2464]}, {"w": "either", "b": [0.1786, 0.2466, 0.2271, 0.268]}, {"w": "equal", "b": [0.2328, 0.2466, 0.2778, 0.268]}, {"w": "to", "b": [0.2835, 0.2466, 0.3005, 0.268]}, {"w": "1", "b": [0.3063, 0.2466, 0.3163, 0.268]}, {"w": "or", "b": [0.322, 0.2466, 0.3403, 0.268]}, {"w": "0,", "b": [0.3461, 0.2466, 0.3608, 0.268]}, {"w": "depending", "b": [0.3666, 0.2466, 0.4553, 0.268]}, {"w": "on", "b": [0.4611, 0.2466, 0.4831, 0.268]}, {"w": "whether", "b": [0.4888, 0.2466, 0.5571, 0.268]}, {"w": "the", "b": [0.5629, 0.2466, 0.5892, 0.268]}, {"w": "instance", "b": [0.5949, 0.2466, 0.6641, 0.268]}, {"w": "belongs", "b": [0.6699, 0.2466, 0.734, 0.268]}, {"w": "to", "b": [0.7397, 0.2466, 0.7567, 0.268]}, {"w": "the", "b": [0.7625, 0.2466, 0.7888, 0.268]}, {"w": "class", "b": [0.7945, 0.2466, 0.8331, 0.268]}, {"w": "or", "b": [0.8388, 0.2466, 0.8571, 0.268]}, {"w": "not.", "b": [0.1786, 0.2657, 0.2117, 0.2871]}]}, {"id": "b_9", "type": "paragraph", "text": "Notice that when there are just two classes (K = 2), this cost function is equivalent to the Logistic Regression’s cost function (log loss; see Equation 4-17).", "words": [{"w": "Notice", "b": [0.1429, 0.2998, 0.198, 0.3212]}, {"w": "that", "b": [0.2036, 0.2998, 0.2362, 0.3212]}, {"w": "when", "b": [0.2417, 0.2998, 0.2873, 0.3212]}, {"w": "there", "b": [0.2929, 0.2998, 0.3358, 0.3212]}, {"w": "are", "b": [0.3413, 0.2998, 0.3671, 0.3212]}, {"w": "just", "b": [0.3726, 0.2998, 0.403, 0.3212]}, {"w": "two", "b": [0.4085, 0.2998, 0.4398, 0.3212]}, {"w": "classes", "b": [0.4453, 0.2998, 0.5003, 0.3212]}, {"w": "(K", "b": [0.5059, 0.2996, 0.5267, 0.3212]}, {"w": "=", "b": [0.5322, 0.2998, 0.5443, 0.3212]}, {"w": "2),", "b": [0.5498, 0.2998, 0.5718, 0.3212]}, {"w": "this", "b": [0.5773, 0.2998, 0.608, 0.3212]}, {"w": "cost", "b": [0.6135, 0.2998, 0.647, 0.3212]}, {"w": "function", "b": [0.6525, 0.2998, 0.7239, 0.3212]}, {"w": "is", "b": [0.7294, 0.2998, 0.7427, 0.3212]}, {"w": "equivalent", "b": [0.7482, 0.2998, 0.8346, 0.3212]}, {"w": "to", "b": [0.8402, 0.2998, 0.8571, 0.3212]}, {"w": "the", "b": [0.1428, 0.3189, 0.1692, 0.3403]}, {"w": "Logistic", "b": [0.1739, 0.3189, 0.2395, 0.3403]}, {"w": "Regression’s", "b": [0.2442, 0.3189, 0.3438, 0.3403]}, {"w": "cost", "b": [0.3486, 0.3189, 0.382, 0.3403]}, {"w": "function", "b": [0.3867, 0.3189, 0.4581, 0.3403]}, {"w": "(log", "b": [0.4628, 0.3189, 0.4957, 0.3403]}, {"w": "loss;", "b": [0.5004, 0.3189, 0.5364, 0.3403]}, {"w": "see", "b": [0.5411, 0.3189, 0.5665, 0.3403]}, {"w": "Equation", "b": [0.5712, 0.3189, 0.6474, 0.3403]}, {"w": "4-17).", "b": [0.6522, 0.3189, 0.7015, 0.3403]}]}, {"id": "b_10", "type": "paragraph", "text": "Cross Entropy", "words": [{"w": "Cross", "b": [0.4343, 0.3661, 0.4844, 0.3932]}, {"w": "Entropy", "b": [0.4891, 0.3661, 0.5657, 0.3932]}]}, {"id": "b_11", "type": "paragraph", "text": "Cross entropy originated from information theory. Suppose you want to efficiently transmit information about the weather every day. If there are eight options (sunny, rainy, etc.), you could encode each option using 3 bits since 23 = 8. However, if you think it will be sunny almost every day, it would be much more efficient to code “sunny” on just one bit (0) and the other seven options on 4 bits (starting with a 1). Cross entropy measures the average number of bits you actually send per option. If your assumption about the weather is perfect, cross entropy will just be equal to the entropy of the weather itself (i.e., its intrinsic unpredictability). But if your assump‐ tions are wrong (e.g., if it rains often), cross entropy will be greater by an amount called the Kullback–Leibler divergence.", "words": [{"w": "Cross", "b": [0.1592, 0.3978, 0.2045, 0.4182]}, {"w": "entropy", "b": [0.2117, 0.3978, 0.2736, 0.4182]}, {"w": "originated", "b": [0.2808, 0.3978, 0.3623, 0.4182]}, {"w": "from", "b": [0.3695, 0.3978, 0.4091, 0.4182]}, {"w": "information", "b": [0.4163, 0.3978, 0.5127, 0.4182]}, {"w": "theory.", "b": [0.5199, 0.3978, 0.5752, 0.4182]}, {"w": "Suppose", "b": [0.5824, 0.3978, 0.649, 0.4182]}, {"w": "you", "b": [0.6562, 0.3978, 0.6859, 0.4182]}, {"w": "want", "b": [0.6931, 0.3978, 0.732, 0.4182]}, {"w": "to", "b": [0.7391, 0.3978, 0.7553, 0.4182]}, {"w": "efficiently", "b": [0.7625, 0.3978, 0.8408, 0.4182]}, {"w": "transmit", "b": [0.1592, 0.4159, 0.2271, 0.4363]}, {"w": "information", "b": [0.2333, 0.4159, 0.3297, 0.4363]}, {"w": "about", "b": [0.3359, 0.4159, 0.3814, 0.4363]}, {"w": "the", "b": [0.3876, 0.4159, 0.4127, 0.4363]}, {"w": "weather", "b": [0.4189, 0.4159, 0.4817, 0.4363]}, {"w": "every", "b": [0.4878, 0.4159, 0.5309, 0.4363]}, {"w": "day.", "b": [0.5371, 0.4159, 0.5681, 0.4363]}, {"w": "If", "b": [0.5743, 0.4159, 0.5869, 0.4363]}, {"w": "there", "b": [0.5931, 0.4159, 0.634, 0.4363]}, {"w": "are", "b": [0.6402, 0.4159, 0.6647, 0.4363]}, {"w": "eight", "b": [0.6709, 0.4159, 0.7102, 0.4363]}, {"w": "options", "b": [0.7163, 0.4159, 0.7765, 0.4363]}, {"w": "(sunny,", "b": [0.7827, 0.4159, 0.8408, 0.4363]}, {"w": "rainy,", "b": [0.1592, 0.434, 0.2032, 0.4544]}, {"w": "etc.),", "b": [0.2094, 0.434, 0.2482, 0.4544]}, {"w": "you", "b": [0.2545, 0.434, 0.2842, 0.4544]}, {"w": "could", "b": [0.2905, 0.434, 0.335, 0.4544]}, {"w": "encode", "b": [0.3413, 0.434, 0.398, 0.4544]}, {"w": "each", "b": [0.4042, 0.434, 0.4403, 0.4544]}, {"w": "option", "b": [0.4466, 0.434, 0.4994, 0.4544]}, {"w": "using", "b": [0.5057, 0.434, 0.549, 0.4544]}, {"w": "3", "b": [0.5552, 0.434, 0.5647, 0.4544]}, {"w": "bits", "b": [0.571, 0.434, 0.5997, 0.4544]}, {"w": "since", "b": [0.6059, 0.434, 0.6462, 0.4544]}, {"w": "23", "b": [0.6524, 0.434, 0.668, 0.4544]}, {"w": "=", "b": [0.6742, 0.434, 0.6857, 0.4544]}, {"w": "8.", "b": [0.6919, 0.434, 0.706, 0.4544]}, {"w": "However,", "b": [0.7122, 0.434, 0.7873, 0.4544]}, {"w": "if", "b": [0.7936, 0.434, 0.8048, 0.4544]}, {"w": "you", "b": [0.811, 0.434, 0.8408, 0.4544]}, {"w": "think", "b": [0.1592, 0.4522, 0.2019, 0.4726]}, {"w": "it", "b": [0.2098, 0.4522, 0.2212, 0.4726]}, {"w": "will", "b": [0.2292, 0.4522, 0.2581, 0.4726]}, {"w": "be", "b": [0.2661, 0.4522, 0.2846, 0.4726]}, {"w": "sunny", "b": [0.2926, 0.4522, 0.3407, 0.4726]}, {"w": "almost", "b": [0.3487, 0.4522, 0.4021, 0.4726]}, {"w": "every", "b": [0.4101, 0.4522, 0.4532, 0.4726]}, {"w": "day,", "b": [0.4611, 0.4522, 0.4921, 0.4726]}, {"w": "it", "b": [0.5001, 0.4522, 0.5115, 0.4726]}, {"w": "would", "b": [0.5194, 0.4522, 0.5692, 0.4726]}, {"w": "be", "b": [0.5771, 0.4522, 0.5957, 0.4726]}, {"w": "much", "b": [0.6036, 0.4522, 0.649, 0.4726]}, {"w": "more", "b": [0.657, 0.4522, 0.6991, 0.4726]}, {"w": "efficient", "b": [0.7071, 0.4522, 0.7713, 0.4726]}, {"w": "to", "b": [0.7792, 0.4522, 0.7954, 0.4726]}, {"w": "code", "b": [0.8034, 0.4522, 0.8408, 0.4726]}, {"w": "“sunny”", "b": [0.1592, 0.4703, 0.2221, 0.4907]}, {"w": "on", "b": [0.228, 0.4703, 0.249, 0.4907]}, {"w": "just", "b": [0.2549, 0.4703, 0.2838, 0.4907]}, {"w": "one", "b": [0.2897, 0.4703, 0.3192, 0.4907]}, {"w": "bit", "b": [0.3251, 0.4703, 0.3465, 0.4907]}, {"w": "(0)", "b": [0.3524, 0.4703, 0.3757, 0.4907]}, {"w": "and", "b": [0.3816, 0.4703, 0.4116, 0.4907]}, {"w": "the", "b": [0.4175, 0.4703, 0.4426, 0.4907]}, {"w": "other", "b": [0.4485, 0.4703, 0.4911, 0.4907]}, {"w": "seven", "b": [0.497, 0.4703, 0.5412, 0.4907]}, {"w": "options", "b": [0.5471, 0.4703, 0.6072, 0.4907]}, {"w": "on", "b": [0.6131, 0.4703, 0.6341, 0.4907]}, {"w": "4", "b": [0.64, 0.4703, 0.6495, 0.4907]}, {"w": "bits", "b": [0.6554, 0.4703, 0.6842, 0.4907]}, {"w": "(starting", "b": [0.6901, 0.4703, 0.7579, 0.4907]}, {"w": "with", "b": [0.7638, 0.4703, 0.7993, 0.4907]}, {"w": "a", "b": [0.8052, 0.4703, 0.8139, 0.4907]}, {"w": "1).", "b": [0.8199, 0.4703, 0.8408, 0.4907]}, {"w": "Cross", "b": [0.1592, 0.4885, 0.2045, 0.5089]}, {"w": "entropy", "b": [0.2108, 0.4885, 0.2728, 0.5089]}, {"w": "measures", "b": [0.2791, 0.4885, 0.3534, 0.5089]}, {"w": "the", "b": [0.3598, 0.4885, 0.3849, 0.5089]}, {"w": "average", "b": [0.3913, 0.4885, 0.451, 0.5089]}, {"w": "number", "b": [0.4574, 0.4885, 0.5205, 0.5089]}, {"w": "of", "b": [0.5269, 0.4885, 0.5429, 0.5089]}, {"w": "bits", "b": [0.5493, 0.4885, 0.578, 0.5089]}, {"w": "you", "b": [0.5844, 0.4885, 0.6141, 0.5089]}, {"w": "actually", "b": [0.6205, 0.4885, 0.682, 0.5089]}, {"w": "send", "b": [0.6884, 0.4885, 0.7255, 0.5089]}, {"w": "per", "b": [0.7318, 0.4885, 0.758, 0.5089]}, {"w": "option.", "b": [0.7644, 0.4885, 0.8218, 0.5089]}, {"w": "If", "b": [0.8281, 0.4885, 0.8408, 0.5089]}, {"w": "your", "b": [0.1592, 0.5066, 0.1963, 0.527]}, {"w": "assumption", "b": [0.2023, 0.5066, 0.2947, 0.527]}, {"w": "about", "b": [0.3007, 0.5066, 0.3462, 0.527]}, {"w": "the", "b": [0.3522, 0.5066, 0.3773, 0.527]}, {"w": "weather", "b": [0.3833, 0.5066, 0.4461, 0.527]}, {"w": "is", "b": [0.452, 0.5066, 0.4646, 0.527]}, {"w": "perfect,", "b": [0.4706, 0.5066, 0.5301, 0.527]}, {"w": "cross", "b": [0.536, 0.5066, 0.5765, 0.527]}, {"w": "entropy", "b": [0.5825, 0.5066, 0.6444, 0.527]}, {"w": "will", "b": [0.6504, 0.5066, 0.6793, 0.527]}, {"w": "just", "b": [0.6853, 0.5066, 0.7143, 0.527]}, {"w": "be", "b": [0.7202, 0.5066, 0.7388, 0.527]}, {"w": "equal", "b": [0.7447, 0.5066, 0.7876, 0.527]}, {"w": "to", "b": [0.7935, 0.5066, 0.8097, 0.527]}, {"w": "the", "b": [0.8157, 0.5066, 0.8408, 0.527]}, {"w": "entropy", "b": [0.1592, 0.5247, 0.2212, 0.5451]}, {"w": "of", "b": [0.2275, 0.5247, 0.2435, 0.5451]}, {"w": "the", "b": [0.2499, 0.5247, 0.275, 0.5451]}, {"w": "weather", "b": [0.2813, 0.5247, 0.3441, 0.5451]}, {"w": "itself", "b": [0.3505, 0.5247, 0.3885, 0.5451]}, {"w": "(i.e.,", "b": [0.3949, 0.5247, 0.429, 0.5451]}, {"w": "its", "b": [0.4354, 0.5247, 0.4541, 0.5451]}, {"w": "intrinsic", "b": [0.4604, 0.5247, 0.5268, 0.5451]}, {"w": "unpredictability).", "b": [0.5332, 0.5247, 0.6716, 0.5451]}, {"w": "But", "b": [0.678, 0.5247, 0.7062, 0.5451]}, {"w": "if", "b": [0.7126, 0.5247, 0.7238, 0.5451]}, {"w": "your", "b": [0.7301, 0.5247, 0.7673, 0.5451]}, {"w": "assump‐", "b": [0.7736, 0.5247, 0.8408, 0.5451]}, {"w": "tions", "b": [0.1592, 0.5429, 0.1988, 0.5633]}, {"w": "are", "b": [0.2056, 0.5429, 0.2301, 0.5633]}, {"w": "wrong", "b": [0.2368, 0.5429, 0.288, 0.5633]}, {"w": "(e.g.,", "b": [0.2947, 0.5429, 0.3328, 0.5633]}, {"w": "if", "b": [0.3395, 0.5429, 0.3507, 0.5633]}, {"w": "it", "b": [0.3574, 0.5429, 0.3688, 0.5633]}, {"w": "rains", "b": [0.3755, 0.5429, 0.415, 0.5633]}, {"w": "often),", "b": [0.4217, 0.5429, 0.4744, 0.5633]}, {"w": "cross", "b": [0.4811, 0.5429, 0.5216, 0.5633]}, {"w": "entropy", "b": [0.5283, 0.5429, 0.5902, 0.5633]}, {"w": "will", "b": [0.5969, 0.5429, 0.6259, 0.5633]}, {"w": "be", "b": [0.6326, 0.5429, 0.6511, 0.5633]}, {"w": "greater", "b": [0.6578, 0.5429, 0.7131, 0.5633]}, {"w": "by", "b": [0.7198, 0.5429, 0.739, 0.5633]}, {"w": "an", "b": [0.7457, 0.5429, 0.7652, 0.5633]}, {"w": "amount", "b": [0.7719, 0.5429, 0.8341, 0.5633]}, {"w": "called", "b": [0.1592, 0.561, 0.2053, 0.5814]}, {"w": "the", "b": [0.2098, 0.561, 0.2349, 0.5814]}, {"w": "Kullback–Leibler", "b": [0.2394, 0.5608, 0.3706, 0.5814]}, {"w": "divergence.", "b": [0.3752, 0.5608, 0.4606, 0.5814]}]}, {"id": "b_12", "type": "paragraph", "text": "The cross entropy between two probability distributions p and q is defined as H p, q = −∑x p x log q x (at least when the distributions are discrete). For more details, check out this video.", "words": [{"w": "The", "b": [0.1592, 0.5882, 0.1905, 0.6086]}, {"w": "cross", "b": [0.2009, 0.5882, 0.2413, 0.6086]}, {"w": "entropy", "b": [0.2518, 0.5882, 0.3137, 0.6086]}, {"w": "between", "b": [0.3241, 0.5882, 0.39, 0.6086]}, {"w": "two", "b": [0.4004, 0.5882, 0.4302, 0.6086]}, {"w": "probability", "b": [0.4406, 0.5882, 0.5281, 0.6086]}, {"w": "distributions", "b": [0.5385, 0.5882, 0.6406, 0.6086]}, {"w": "p", "b": [0.651, 0.588, 0.6606, 0.6086]}, {"w": "and", "b": [0.671, 0.5882, 0.7011, 0.6086]}, {"w": "q", "b": [0.7115, 0.588, 0.7211, 0.6086]}, {"w": "is", "b": [0.7315, 0.5882, 0.7441, 0.6086]}, {"w": "defined", "b": [0.7545, 0.5882, 0.8144, 0.6086]}, {"w": "as", "b": [0.8248, 0.5882, 0.8408, 0.6086]}, {"w": "H", "b": [0.1592, 0.6062, 0.1739, 0.6268]}, {"w": "p,", "b": [0.1828, 0.6062, 0.197, 0.6268]}, {"w": "q", "b": [0.2003, 0.6062, 0.2099, 0.6268]}, {"w": "=", "b": [0.2223, 0.6064, 0.2338, 0.6268]}, {"w": "−∑x", "b": [0.2437, 0.6064, 0.2789, 0.631]}, {"w": "p", "b": [0.2824, 0.6062, 0.2921, 0.6268]}, {"w": "x", "b": [0.299, 0.6062, 0.3083, 0.6268]}, {"w": "log", "b": [0.3207, 0.6064, 0.3451, 0.6268]}, {"w": "q", "b": [0.3507, 0.6062, 0.3603, 0.6268]}, {"w": "x", "b": [0.3671, 0.6062, 0.3765, 0.6268]}, {"w": "(at", "b": [0.3903, 0.6064, 0.4116, 0.6268]}, {"w": "least", "b": [0.4186, 0.6064, 0.454, 0.6268]}, {"w": "when", "b": [0.461, 0.6064, 0.5045, 0.6268]}, {"w": "the", "b": [0.5114, 0.6064, 0.5365, 0.6268]}, {"w": "distributions", "b": [0.5435, 0.6064, 0.6455, 0.6268]}, {"w": "are", "b": [0.6525, 0.6064, 0.677, 0.6268]}, {"w": "discrete).", "b": [0.684, 0.6064, 0.7571, 0.6268]}, {"w": "For", "b": [0.7641, 0.6064, 0.7917, 0.6268]}, {"w": "more", "b": [0.7986, 0.6064, 0.8408, 0.6268]}, {"w": "details,", "b": [0.1592, 0.6275, 0.215, 0.6479]}, {"w": "check", "b": [0.2195, 0.6275, 0.2652, 0.6479]}, {"w": "out", "b": [0.2697, 0.6275, 0.2964, 0.6479]}, {"w": "this", "b": [0.3009, 0.6275, 0.3302, 0.6479]}, {"w": "video.", "b": [0.3347, 0.6275, 0.3827, 0.6479]}]}, {"id": "b_13", "type": "paragraph", "text": "The gradient vector of this cost function with regards to θ(k) is given by Equation 4-23:", "words": [{"w": "The", "b": [0.1429, 0.6777, 0.1757, 0.6991]}, {"w": "gradient", "b": [0.1837, 0.6777, 0.2531, 0.6991]}, {"w": "vector", "b": [0.2611, 0.6777, 0.3131, 0.6991]}, {"w": "of", "b": [0.3211, 0.6777, 0.3379, 0.6991]}, {"w": "this", "b": [0.3459, 0.6777, 0.3766, 0.6991]}, {"w": "cost", "b": [0.3846, 0.6777, 0.418, 0.6991]}, {"w": "function", "b": [0.426, 0.6777, 0.4974, 0.6991]}, {"w": "with", "b": [0.5054, 0.6777, 0.5427, 0.6991]}, {"w": "regards", "b": [0.5507, 0.6777, 0.6125, 0.6991]}, {"w": "to", "b": [0.6205, 0.6777, 0.6375, 0.6991]}, {"w": "θ(k)", "b": [0.6455, 0.6771, 0.6703, 0.6991]}, {"w": "is", "b": [0.6783, 0.6777, 0.6916, 0.6991]}, {"w": "given", "b": [0.6995, 0.6777, 0.7448, 0.6991]}, {"w": "by", "b": [0.7528, 0.6777, 0.7729, 0.6991]}, {"w": "Equation", "b": [0.7809, 0.6777, 0.8571, 0.6991]}, {"w": "4-23:", "b": [0.1428, 0.6967, 0.185, 0.7181]}]}, {"id": "b_14", "type": "equation", "text": "Equation 4-23. Cross entropy gradient vector for class k", "words": [{"w": "Equation", "b": [0.1726, 0.7363, 0.2473, 0.7579]}, {"w": "4-23.", "b": [0.2521, 0.7363, 0.2937, 0.7579]}, {"w": "Cross", "b": [0.2985, 0.7363, 0.3422, 0.7579]}, {"w": "entropy", "b": [0.3469, 0.7363, 0.408, 0.7579]}, {"w": "gradient", "b": [0.4128, 0.7363, 0.4802, 0.7579]}, {"w": "vector", "b": [0.485, 0.7363, 0.5338, 0.7579]}, {"w": "for", "b": [0.5386, 0.7363, 0.5613, 0.7579]}, {"w": "class", "b": [0.566, 0.7363, 0.6029, 0.7579]}, {"w": "k", "b": [0.6077, 0.7363, 0.6175, 0.7579]}]}, {"id": "b_16", "type": "equation", "text": "θ k J Θ = 1", "words": [{"w": "θ", "b": [0.189, 0.791, 0.1971, 0.8077]}, {"w": "k", "b": [0.2026, 0.7852, 0.2101, 0.8017]}, {"w": "J", "b": [0.2194, 0.7777, 0.2257, 0.7983]}, {"w": "Θ", "b": [0.2336, 0.7773, 0.2487, 0.7983]}, {"w": "=", "b": [0.2611, 0.7779, 0.2726, 0.7983]}, {"w": "1", "b": [0.2833, 0.769, 0.2928, 0.7894]}]}, {"id": "b_17", "type": "paragraph", "text": "m ∑", "words": [{"w": "m", "b": [0.2803, 0.7865, 0.2959, 0.8071]}, {"w": "∑", "b": [0.3067, 0.7731, 0.3217, 0.8019]}]}, {"id": "b_18", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.2992, 0.7926, 0.3035, 0.809]}, {"w": "=", "b": [0.3079, 0.7927, 0.3172, 0.809]}, {"w": "1", "b": [0.3216, 0.7927, 0.3292, 0.809]}]}, {"id": "b_21", "type": "paragraph", "text": "i −yk", "words": [{"w": "i", "b": [0.355, 0.7735, 0.3593, 0.79]}, {"w": "−yk", "b": [0.3692, 0.7777, 0.4025, 0.8025]}]}, {"id": "b_22", "type": "paragraph", "text": "i x i", "words": [{"w": "i", "b": [0.4005, 0.774, 0.4049, 0.7904]}, {"w": "x", "b": [0.4172, 0.7773, 0.4268, 0.7983]}, {"w": "i", "b": [0.4324, 0.774, 0.4367, 0.7904]}]}, {"id": "b_23", "type": "paragraph", "text": "Now you can compute the gradient vector for every class, then use Gradient Descent (or any other optimization algorithm) to find the parameter matrix Θ that minimizes the cost function.", "words": [{"w": "Now", "b": [0.1428, 0.8281, 0.1827, 0.8495]}, {"w": "you", "b": [0.1883, 0.8281, 0.2196, 0.8495]}, {"w": "can", "b": [0.2252, 0.8281, 0.2545, 0.8495]}, {"w": "compute", "b": [0.2602, 0.8281, 0.3335, 0.8495]}, {"w": "the", "b": [0.3391, 0.8281, 0.3654, 0.8495]}, {"w": "gradient", "b": [0.371, 0.8281, 0.4404, 0.8495]}, {"w": "vector", "b": [0.4461, 0.8281, 0.4981, 0.8495]}, {"w": "for", "b": [0.5037, 0.8281, 0.5282, 0.8495]}, {"w": "every", "b": [0.5338, 0.8281, 0.5791, 0.8495]}, {"w": "class,", "b": [0.5847, 0.8281, 0.628, 0.8495]}, {"w": "then", "b": [0.6336, 0.8281, 0.6713, 0.8495]}, {"w": "use", "b": [0.6769, 0.8281, 0.7045, 0.8495]}, {"w": "Gradient", "b": [0.7101, 0.8281, 0.7847, 0.8495]}, {"w": "Descent", "b": [0.7903, 0.8281, 0.8571, 0.8495]}, {"w": "(or", "b": [0.1429, 0.8471, 0.1684, 0.8685]}, {"w": "any", "b": [0.1736, 0.8471, 0.2033, 0.8685]}, {"w": "other", "b": [0.2085, 0.8471, 0.2532, 0.8685]}, {"w": "optimization", "b": [0.2584, 0.8471, 0.3659, 0.8685]}, {"w": "algorithm)", "b": [0.3711, 0.8471, 0.461, 0.8685]}, {"w": "to", "b": [0.4662, 0.8471, 0.4832, 0.8685]}, {"w": "find", "b": [0.4884, 0.8471, 0.5225, 0.8685]}, {"w": "the", "b": [0.5277, 0.8471, 0.5541, 0.8685]}, {"w": "parameter", "b": [0.5593, 0.8471, 0.6451, 0.8685]}, {"w": "matrix", "b": [0.6503, 0.8471, 0.7056, 0.8685]}, {"w": "Θ", "b": [0.7108, 0.8466, 0.7266, 0.8685]}, {"w": "that", "b": [0.7318, 0.8471, 0.7644, 0.8685]}, {"w": "minimizes", "b": [0.7692, 0.8471, 0.8567, 0.8685]}, {"w": "the", "b": [0.1429, 0.8662, 0.1692, 0.8876]}, {"w": "cost", "b": [0.1739, 0.8662, 0.2074, 0.8876]}, {"w": "function.", "b": [0.2121, 0.8662, 0.2882, 0.8876]}]}, {"id": "b_24", "type": "paragraph", "text": "Logistic Regression | 151", "words": [{"w": "Logistic", "b": [0.6839, 0.9225, 0.7288, 0.9388]}, {"w": "Regression", "b": [0.7316, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "151", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 178, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Let’s use Softmax Regression to classify the iris flowers into all three classes. Scikit- Learn’s LogisticRegression uses one-versus-all by default when you train it on more than two classes, but you can set the multi_class hyperparameter to \"multinomial\" to switch it to Softmax Regression instead. You must also specify a solver that sup‐ ports Softmax Regression, such as the \"lbfgs\" solver (see Scikit-Learn’s documenta‐ tion for more details). It also applies ℓ2 regularization by default, which you can control using the hyperparameter C.", "words": [{"w": "Let’s", "b": [0.1429, 0.0791, 0.179, 0.1005]}, {"w": "use", "b": [0.1859, 0.0791, 0.2135, 0.1005]}, {"w": "Softmax", "b": [0.2204, 0.0791, 0.2895, 0.1005]}, {"w": "Regression", "b": [0.2964, 0.0791, 0.3874, 0.1005]}, {"w": "to", "b": [0.3944, 0.0791, 0.4113, 0.1005]}, {"w": "classify", "b": [0.4183, 0.0791, 0.4784, 0.1005]}, {"w": "the", "b": [0.4854, 0.0791, 0.5117, 0.1005]}, {"w": "iris", "b": [0.5186, 0.0791, 0.5452, 0.1005]}, {"w": "flowers", "b": [0.5521, 0.0791, 0.6126, 0.1005]}, {"w": "into", "b": [0.6196, 0.0791, 0.6531, 0.1005]}, {"w": "all", "b": [0.66, 0.0791, 0.6797, 0.1005]}, {"w": "three", "b": [0.6867, 0.0791, 0.7296, 0.1005]}, {"w": "classes.", "b": [0.7365, 0.0791, 0.7963, 0.1005]}, {"w": "Scikit-", "b": [0.8032, 0.0791, 0.8571, 0.1005]}, {"w": "Learn’s", "b": [0.1429, 0.099, 0.1998, 0.1204]}, {"w": "LogisticRegression", "b": [0.2046, 0.1022, 0.3827, 0.1173]}, {"w": "uses", "b": [0.3876, 0.099, 0.4228, 0.1204]}, {"w": "one-versus-all", "b": [0.4276, 0.099, 0.5456, 0.1204]}, {"w": "by", "b": [0.5504, 0.099, 0.5706, 0.1204]}, {"w": "default", "b": [0.5754, 0.099, 0.6329, 0.1204]}, {"w": "when", "b": [0.6377, 0.099, 0.6833, 0.1204]}, {"w": "you", "b": [0.6882, 0.099, 0.7194, 0.1204]}, {"w": "train", "b": [0.7242, 0.099, 0.7644, 0.1204]}, {"w": "it", "b": [0.7693, 0.099, 0.7812, 0.1204]}, {"w": "on", "b": [0.786, 0.099, 0.8081, 0.1204]}, {"w": "more", "b": [0.8129, 0.099, 0.8572, 0.1204]}, {"w": "than", "b": [0.1429, 0.119, 0.1809, 0.1404]}, {"w": "two", "b": [0.1863, 0.119, 0.2175, 0.1404]}, {"w": "classes,", "b": [0.2229, 0.119, 0.2827, 0.1404]}, {"w": "but", "b": [0.2881, 0.119, 0.3161, 0.1404]}, {"w": "you", "b": [0.3215, 0.119, 0.3528, 0.1404]}, {"w": "can", "b": [0.3582, 0.119, 0.3875, 0.1404]}, {"w": "set", "b": [0.3929, 0.119, 0.4158, 0.1404]}, {"w": "the", "b": [0.4212, 0.119, 0.4475, 0.1404]}, {"w": "multi_class", "b": [0.4529, 0.1221, 0.5618, 0.1372]}, {"w": "hyperparameter", "b": [0.5672, 0.119, 0.7007, 0.1404]}, {"w": "to", "b": [0.7061, 0.119, 0.7231, 0.1404]}, {"w": "\"multinomial\"", "b": [0.7285, 0.1221, 0.8571, 0.1372]}, {"w": "to", "b": [0.1429, 0.138, 0.1598, 0.1594]}, {"w": "switch", "b": [0.1667, 0.138, 0.2205, 0.1594]}, {"w": "it", "b": [0.2274, 0.138, 0.2394, 0.1594]}, {"w": "to", "b": [0.2463, 0.138, 0.2632, 0.1594]}, {"w": "Softmax", "b": [0.2701, 0.138, 0.3392, 0.1594]}, {"w": "Regression", "b": [0.3461, 0.138, 0.4371, 0.1594]}, {"w": "instead.", "b": [0.444, 0.138, 0.5088, 0.1594]}, {"w": "You", "b": [0.5157, 0.138, 0.548, 0.1594]}, {"w": "must", "b": [0.5549, 0.138, 0.5966, 0.1594]}, {"w": "also", "b": [0.6035, 0.138, 0.6362, 0.1594]}, {"w": "specify", "b": [0.6431, 0.138, 0.701, 0.1594]}, {"w": "a", "b": [0.7079, 0.138, 0.7171, 0.1594]}, {"w": "solver", "b": [0.724, 0.138, 0.7737, 0.1594]}, {"w": "that", "b": [0.7806, 0.138, 0.8132, 0.1594]}, {"w": "sup‐", "b": [0.8201, 0.138, 0.8571, 0.1594]}, {"w": "ports", "b": [0.1429, 0.1579, 0.1861, 0.1794]}, {"w": "Softmax", "b": [0.1922, 0.1579, 0.2612, 0.1794]}, {"w": "Regression,", "b": [0.2673, 0.1579, 0.3631, 0.1794]}, {"w": "such", "b": [0.3691, 0.1579, 0.4078, 0.1794]}, {"w": "as", "b": [0.4138, 0.1579, 0.4306, 0.1794]}, {"w": "the", "b": [0.4367, 0.1579, 0.463, 0.1794]}, {"w": "\"lbfgs\"", "b": [0.4691, 0.1611, 0.5384, 0.1762]}, {"w": "solver", "b": [0.5444, 0.1579, 0.5942, 0.1794]}, {"w": "(see", "b": [0.6002, 0.1579, 0.6328, 0.1794]}, {"w": "Scikit-Learn’s", "b": [0.6389, 0.1579, 0.7498, 0.1794]}, {"w": "documenta‐", "b": [0.7558, 0.1579, 0.8571, 0.1794]}, {"w": "tion", "b": [0.1429, 0.177, 0.1768, 0.1984]}, {"w": "for", "b": [0.1858, 0.177, 0.2104, 0.1984]}, {"w": "more", "b": [0.2194, 0.177, 0.2637, 0.1984]}, {"w": "details).", "b": [0.2727, 0.177, 0.3385, 0.1984]}, {"w": "It", "b": [0.3475, 0.177, 0.3602, 0.1984]}, {"w": "also", "b": [0.3692, 0.177, 0.4019, 0.1984]}, {"w": "applies", "b": [0.4109, 0.177, 0.4689, 0.1984]}, {"w": "ℓ2", "b": [0.4779, 0.177, 0.4925, 0.1993]}, {"w": "regularization", "b": [0.5015, 0.177, 0.6181, 0.1984]}, {"w": "by", "b": [0.6271, 0.177, 0.6473, 0.1984]}, {"w": "default,", "b": [0.6563, 0.177, 0.7185, 0.1984]}, {"w": "which", "b": [0.7276, 0.177, 0.7785, 0.1984]}, {"w": "you", "b": [0.7875, 0.177, 0.8188, 0.1984]}, {"w": "can", "b": [0.8278, 0.177, 0.8571, 0.1984]}, {"w": "control", "b": [0.1429, 0.1969, 0.2033, 0.2183]}, {"w": "using", "b": [0.208, 0.1969, 0.2535, 0.2183]}, {"w": "the", "b": [0.2582, 0.1969, 0.2845, 0.2183]}, {"w": "hyperparameter", "b": [0.2892, 0.1969, 0.4227, 0.2183]}, {"w": "C.", "b": [0.4275, 0.1969, 0.4421, 0.2183]}]}, {"id": "b_1", "type": "equation", "text": "X = iris[\"data\"][:, (2, 3)] # petal length, petal width y = iris[\"target\"]", "words": [{"w": "X", "b": [0.1766, 0.2289, 0.185, 0.2418]}, {"w": "=", "b": [0.1935, 0.2289, 0.2019, 0.2418]}, {"w": "iris[\"data\"][:,", "b": [0.2103, 0.2289, 0.3368, 0.2418]}, {"w": "(2,", "b": [0.3452, 0.2289, 0.3705, 0.2418]}, {"w": "3)]", "b": [0.379, 0.2289, 0.4043, 0.2418]}, {"w": "#", "b": [0.4211, 0.2289, 0.4296, 0.2418]}, {"w": "petal", "b": [0.438, 0.2289, 0.4802, 0.2418]}, {"w": "length,", "b": [0.4886, 0.2289, 0.5476, 0.2418]}, {"w": "petal", "b": [0.5561, 0.2289, 0.5982, 0.2418]}, {"w": "width", "b": [0.6067, 0.2289, 0.6488, 0.2418]}, {"w": "y", "b": [0.1766, 0.2443, 0.185, 0.2572]}, {"w": "=", "b": [0.1935, 0.2443, 0.2019, 0.2572]}, {"w": "iris[\"target\"]", "b": [0.2103, 0.2443, 0.3284, 0.2572]}]}, {"id": "b_2", "type": "paragraph", "text": "softmax_reg = LogisticRegression(multi_class=\"multinomial\",solver=\"lbfgs\", C=10) softmax_reg.fit(X, y)", "words": [{"w": "softmax_reg", "b": [0.1766, 0.2752, 0.2694, 0.288]}, {"w": "=", "b": [0.2778, 0.2752, 0.2862, 0.288]}, {"w": "LogisticRegression(multi_class=\"multinomial\",solver=\"lbfgs\",", "b": [0.2946, 0.2752, 0.8006, 0.288]}, {"w": "C=10)", "b": [0.809, 0.2752, 0.8512, 0.288]}, {"w": "softmax_reg.fit(X,", "b": [0.1766, 0.2906, 0.3284, 0.3034]}, {"w": "y)", "b": [0.3368, 0.2906, 0.3537, 0.3034]}]}, {"id": "b_3", "type": "paragraph", "text": "So the next time you find an iris with 5 cm long and 2 cm wide petals, you can ask your model to tell you what type of iris it is, and it will answer Iris-Virginica (class 2) with 94.2% probability (or Iris-Versicolor with 5.8% probability):", "words": [{"w": "So", "b": [0.1429, 0.3112, 0.1634, 0.3326]}, {"w": "the", "b": [0.1698, 0.3112, 0.1962, 0.3326]}, {"w": "next", "b": [0.2026, 0.3112, 0.239, 0.3326]}, {"w": "time", "b": [0.2455, 0.3112, 0.2834, 0.3326]}, {"w": "you", "b": [0.2898, 0.3112, 0.3211, 0.3326]}, {"w": "find", "b": [0.3275, 0.3112, 0.3617, 0.3326]}, {"w": "an", "b": [0.3681, 0.3112, 0.3887, 0.3326]}, {"w": "iris", "b": [0.3951, 0.3112, 0.4217, 0.3326]}, {"w": "with", "b": [0.4281, 0.3112, 0.4654, 0.3326]}, {"w": "5", "b": [0.4719, 0.3112, 0.4819, 0.3326]}, {"w": "cm", "b": [0.4883, 0.3112, 0.5142, 0.3326]}, {"w": "long", "b": [0.5207, 0.3112, 0.5577, 0.3326]}, {"w": "and", "b": [0.5642, 0.3112, 0.5957, 0.3326]}, {"w": "2", "b": [0.6022, 0.3112, 0.6122, 0.3326]}, {"w": "cm", "b": [0.6186, 0.3112, 0.6445, 0.3326]}, {"w": "wide", "b": [0.651, 0.3112, 0.6907, 0.3326]}, {"w": "petals,", "b": [0.6971, 0.3112, 0.7501, 0.3326]}, {"w": "you", "b": [0.7565, 0.3112, 0.7878, 0.3326]}, {"w": "can", "b": [0.7942, 0.3112, 0.8236, 0.3326]}, {"w": "ask", "b": [0.83, 0.3112, 0.8571, 0.3326]}, {"w": "your", "b": [0.1429, 0.3303, 0.1818, 0.3517]}, {"w": "model", "b": [0.1872, 0.3303, 0.24, 0.3517]}, {"w": "to", "b": [0.2453, 0.3303, 0.2623, 0.3517]}, {"w": "tell", "b": [0.2676, 0.3303, 0.2933, 0.3517]}, {"w": "you", "b": [0.2986, 0.3303, 0.3299, 0.3517]}, {"w": "what", "b": [0.3352, 0.3303, 0.3757, 0.3517]}, {"w": "type", "b": [0.381, 0.3303, 0.4167, 0.3517]}, {"w": "of", "b": [0.422, 0.3303, 0.4388, 0.3517]}, {"w": "iris", "b": [0.4441, 0.3303, 0.4707, 0.3517]}, {"w": "it", "b": [0.476, 0.3303, 0.4879, 0.3517]}, {"w": "is,", "b": [0.4932, 0.3303, 0.5112, 0.3517]}, {"w": "and", "b": [0.5165, 0.3303, 0.5481, 0.3517]}, {"w": "it", "b": [0.5534, 0.3303, 0.5653, 0.3517]}, {"w": "will", "b": [0.5707, 0.3303, 0.601, 0.3517]}, {"w": "answer", "b": [0.6064, 0.3303, 0.6654, 0.3517]}, {"w": "Iris-Virginica", "b": [0.6707, 0.3303, 0.7836, 0.3517]}, {"w": "(class", "b": [0.7889, 0.3303, 0.8346, 0.3517]}, {"w": "2)", "b": [0.8399, 0.3303, 0.8571, 0.3517]}, {"w": "with", "b": [0.1429, 0.3493, 0.1802, 0.3707]}, {"w": "94.2%", "b": [0.1849, 0.3493, 0.2354, 0.3707]}, {"w": "probability", "b": [0.2401, 0.3493, 0.3321, 0.3707]}, {"w": "(or", "b": [0.3368, 0.3493, 0.3624, 0.3707]}, {"w": "Iris-Versicolor", "b": [0.3671, 0.3493, 0.4881, 0.3707]}, {"w": "with", "b": [0.4928, 0.3493, 0.5301, 0.3707]}, {"w": "5.8%", "b": [0.5349, 0.3493, 0.5754, 0.3707]}, {"w": "probability):", "b": [0.5801, 0.3493, 0.684, 0.3707]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> softmax_reg.predict([[5, 2]]) array([2]) >>> softmax_reg.predict_proba([[5, 2]]) array([[6.38014896e-07, 5.74929995e-02, 9.42506362e-01]])", "words": [{"w": ">>>", "b": [0.1766, 0.3813, 0.2019, 0.3941]}, {"w": "softmax_reg.predict([[5,", "b": [0.2103, 0.3813, 0.4127, 0.3941]}, {"w": "2]])", "b": [0.4211, 0.3813, 0.4549, 0.3941]}, {"w": "array([2])", "b": [0.1766, 0.3967, 0.2609, 0.4096]}, {"w": ">>>", "b": [0.1766, 0.4121, 0.2019, 0.425]}, {"w": "softmax_reg.predict_proba([[5,", "b": [0.2103, 0.4121, 0.4633, 0.425]}, {"w": "2]])", "b": [0.4717, 0.4121, 0.5055, 0.425]}, {"w": "array([[6.38014896e-07,", "b": [0.1766, 0.4275, 0.3705, 0.4404]}, {"w": "5.74929995e-02,", "b": [0.379, 0.4275, 0.5055, 0.4404]}, {"w": "9.42506362e-01]])", "b": [0.5139, 0.4275, 0.6572, 0.4404]}]}, {"id": "b_5", "type": "paragraph", "text": "Figure 4-25 shows the resulting decision boundaries, represented by the background colors. Notice that the decision boundaries between any two classes are linear. The figure also shows the probabilities for the Iris-Versicolor class, represented by the curved lines (e.g., the line labeled with 0.450 represents the 45% probability bound‐ ary). Notice that the model can predict a class that has an estimated probability below 50%. For example, at the point where all decision boundaries meet, all classes have an equal estimated probability of 33%.", "words": [{"w": "Figure", "b": [0.1429, 0.4482, 0.1969, 0.4696]}, {"w": "4-25", "b": [0.2028, 0.4482, 0.2402, 0.4696]}, {"w": "shows", "b": [0.2461, 0.4482, 0.2974, 0.4696]}, {"w": "the", "b": [0.3033, 0.4482, 0.3296, 0.4696]}, {"w": "resulting", "b": [0.3355, 0.4482, 0.4092, 0.4696]}, {"w": "decision", "b": [0.4151, 0.4482, 0.4846, 0.4696]}, {"w": "boundaries,", "b": [0.4905, 0.4482, 0.5888, 0.4696]}, {"w": "represented", "b": [0.5947, 0.4482, 0.6925, 0.4696]}, {"w": "by", "b": [0.6984, 0.4482, 0.7186, 0.4696]}, {"w": "the", "b": [0.7245, 0.4482, 0.7508, 0.4696]}, {"w": "background", "b": [0.7567, 0.4482, 0.8571, 0.4696]}, {"w": "colors.", "b": [0.1428, 0.4672, 0.1983, 0.4886]}, {"w": "Notice", "b": [0.2055, 0.4672, 0.2607, 0.4886]}, {"w": "that", "b": [0.2679, 0.4672, 0.3005, 0.4886]}, {"w": "the", "b": [0.3077, 0.4672, 0.334, 0.4886]}, {"w": "decision", "b": [0.3413, 0.4672, 0.4108, 0.4886]}, {"w": "boundaries", "b": [0.418, 0.4672, 0.5116, 0.4886]}, {"w": "between", "b": [0.5188, 0.4672, 0.588, 0.4886]}, {"w": "any", "b": [0.5952, 0.4672, 0.6248, 0.4886]}, {"w": "two", "b": [0.632, 0.4672, 0.6633, 0.4886]}, {"w": "classes", "b": [0.6705, 0.4672, 0.7255, 0.4886]}, {"w": "are", "b": [0.7327, 0.4672, 0.7585, 0.4886]}, {"w": "linear.", "b": [0.7657, 0.4672, 0.8171, 0.4886]}, {"w": "The", "b": [0.8243, 0.4672, 0.8571, 0.4886]}, {"w": "figure", "b": [0.1429, 0.4863, 0.192, 0.5077]}, {"w": "also", "b": [0.2003, 0.4863, 0.233, 0.5077]}, {"w": "shows", "b": [0.2412, 0.4863, 0.2925, 0.5077]}, {"w": "the", "b": [0.3008, 0.4863, 0.3272, 0.5077]}, {"w": "probabilities", "b": [0.3354, 0.4863, 0.4399, 0.5077]}, {"w": "for", "b": [0.4482, 0.4863, 0.4727, 0.5077]}, {"w": "the", "b": [0.4809, 0.4863, 0.5073, 0.5077]}, {"w": "Iris-Versicolor", "b": [0.5155, 0.4863, 0.6365, 0.5077]}, {"w": "class,", "b": [0.6448, 0.4863, 0.6881, 0.5077]}, {"w": "represented", "b": [0.6963, 0.4863, 0.7941, 0.5077]}, {"w": "by", "b": [0.8024, 0.4863, 0.8225, 0.5077]}, {"w": "the", "b": [0.8308, 0.4863, 0.8571, 0.5077]}, {"w": "curved", "b": [0.1429, 0.5053, 0.2006, 0.5267]}, {"w": "lines", "b": [0.207, 0.5053, 0.2458, 0.5267]}, {"w": "(e.g.,", "b": [0.2522, 0.5053, 0.2923, 0.5267]}, {"w": "the", "b": [0.2988, 0.5053, 0.3251, 0.5267]}, {"w": "line", "b": [0.3316, 0.5053, 0.3627, 0.5267]}, {"w": "labeled", "b": [0.3691, 0.5053, 0.4281, 0.5267]}, {"w": "with", "b": [0.4346, 0.5053, 0.4719, 0.5267]}, {"w": "0.450", "b": [0.4784, 0.5053, 0.5231, 0.5267]}, {"w": "represents", "b": [0.5296, 0.5053, 0.6152, 0.5267]}, {"w": "the", "b": [0.6216, 0.5053, 0.648, 0.5267]}, {"w": "45%", "b": [0.6544, 0.5053, 0.6902, 0.5267]}, {"w": "probability", "b": [0.6967, 0.5053, 0.7886, 0.5267]}, {"w": "bound‐", "b": [0.7951, 0.5053, 0.8571, 0.5267]}, {"w": "ary).", "b": [0.1429, 0.5244, 0.1819, 0.5458]}, {"w": "Notice", "b": [0.1868, 0.5244, 0.242, 0.5458]}, {"w": "that", "b": [0.2469, 0.5244, 0.2795, 0.5458]}, {"w": "the", "b": [0.2844, 0.5244, 0.3108, 0.5458]}, {"w": "model", "b": [0.3157, 0.5244, 0.3685, 0.5458]}, {"w": "can", "b": [0.3734, 0.5244, 0.4028, 0.5458]}, {"w": "predict", "b": [0.4077, 0.5244, 0.467, 0.5458]}, {"w": "a", "b": [0.4719, 0.5244, 0.481, 0.5458]}, {"w": "class", "b": [0.486, 0.5244, 0.5245, 0.5458]}, {"w": "that", "b": [0.5294, 0.5244, 0.562, 0.5458]}, {"w": "has", "b": [0.5669, 0.5244, 0.5949, 0.5458]}, {"w": "an", "b": [0.5998, 0.5244, 0.6203, 0.5458]}, {"w": "estimated", "b": [0.6253, 0.5244, 0.7057, 0.5458]}, {"w": "probability", "b": [0.7107, 0.5244, 0.8026, 0.5458]}, {"w": "below", "b": [0.8075, 0.5244, 0.8571, 0.5458]}, {"w": "50%.", "b": [0.1429, 0.5434, 0.1834, 0.5648]}, {"w": "For", "b": [0.1885, 0.5434, 0.2174, 0.5648]}, {"w": "example,", "b": [0.2225, 0.5434, 0.2968, 0.5648]}, {"w": "at", "b": [0.3019, 0.5434, 0.317, 0.5648]}, {"w": "the", "b": [0.3221, 0.5434, 0.3485, 0.5648]}, {"w": "point", "b": [0.3536, 0.5434, 0.3981, 0.5648]}, {"w": "where", "b": [0.4032, 0.5434, 0.454, 0.5648]}, {"w": "all", "b": [0.4591, 0.5434, 0.4788, 0.5648]}, {"w": "decision", "b": [0.4839, 0.5434, 0.5534, 0.5648]}, {"w": "boundaries", "b": [0.5585, 0.5434, 0.6521, 0.5648]}, {"w": "meet,", "b": [0.6572, 0.5434, 0.7031, 0.5648]}, {"w": "all", "b": [0.7082, 0.5434, 0.7279, 0.5648]}, {"w": "classes", "b": [0.733, 0.5434, 0.788, 0.5648]}, {"w": "have", "b": [0.7931, 0.5434, 0.8315, 0.5648]}, {"w": "an", "b": [0.8366, 0.5434, 0.8572, 0.5648]}, {"w": "equal", "b": [0.1429, 0.5625, 0.1878, 0.5839]}, {"w": "estimated", "b": [0.1926, 0.5625, 0.273, 0.5839]}, {"w": "probability", "b": [0.2778, 0.5625, 0.3697, 0.5839]}, {"w": "of", "b": [0.3744, 0.5625, 0.3912, 0.5839]}, {"w": "33%.", "b": [0.3959, 0.5625, 0.4364, 0.5839]}]}, {"id": "b_6", "type": "equation", "text": "Figure 4-25. Softmax Regression decision boundaries", "words": [{"w": "Figure", "b": [0.1429, 0.8107, 0.1943, 0.8324]}, {"w": "4-25.", "b": [0.1991, 0.8107, 0.2407, 0.8324]}, {"w": "Softmax", "b": [0.2455, 0.8107, 0.3133, 0.8324]}, {"w": "Regression", "b": [0.3181, 0.8107, 0.4028, 0.8324]}, {"w": "decision", "b": [0.4076, 0.8107, 0.4731, 0.8324]}, {"w": "boundaries", "b": [0.4779, 0.8107, 0.5683, 0.8324]}]}, {"id": "b_7", "type": "paragraph", "text": "152 | Chapter 4: Training Models", "words": [{"w": "152", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "4:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Training", "b": [0.2673, 0.9225, 0.3163, 0.9388]}, {"w": "Models", "b": [0.3192, 0.9225, 0.3614, 0.9388]}]}]}, {"page": 179, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Exercises", "words": [{"w": "Exercises", "b": [0.1429, 0.0753, 0.2533, 0.1095]}]}, {"id": "b_1", "type": "paragraph", "text": "1. What Linear Regression training algorithm can you use if you have a training set with millions of features?", "words": [{"w": "1.", "b": [0.1534, 0.1225, 0.1682, 0.1439]}, {"w": "What", "b": [0.1786, 0.1225, 0.225, 0.1439]}, {"w": "Linear", "b": [0.2303, 0.1225, 0.2843, 0.1439]}, {"w": "Regression", "b": [0.2896, 0.1225, 0.3806, 0.1439]}, {"w": "training", "b": [0.3859, 0.1225, 0.4528, 0.1439]}, {"w": "algorithm", "b": [0.4582, 0.1225, 0.5408, 0.1439]}, {"w": "can", "b": [0.5461, 0.1225, 0.5755, 0.1439]}, {"w": "you", "b": [0.5808, 0.1225, 0.612, 0.1439]}, {"w": "use", "b": [0.6174, 0.1225, 0.6449, 0.1439]}, {"w": "if", "b": [0.6502, 0.1225, 0.662, 0.1439]}, {"w": "you", "b": [0.6673, 0.1225, 0.6985, 0.1439]}, {"w": "have", "b": [0.7039, 0.1225, 0.7423, 0.1439]}, {"w": "a", "b": [0.7476, 0.1225, 0.7567, 0.1439]}, {"w": "training", "b": [0.762, 0.1225, 0.829, 0.1439]}, {"w": "set", "b": [0.8343, 0.1225, 0.8571, 0.1439]}, {"w": "with", "b": [0.1786, 0.1415, 0.2159, 0.1629]}, {"w": "millions", "b": [0.2206, 0.1415, 0.2891, 0.1629]}, {"w": "of", "b": [0.2938, 0.1415, 0.3106, 0.1629]}, {"w": "features?", "b": [0.3153, 0.1415, 0.3886, 0.1629]}]}, {"id": "b_2", "type": "paragraph", "text": "2. Suppose the features in your training set have very different scales. What algo‐ rithms might suffer from this, and how? What can you do about it?", "words": [{"w": "2.", "b": [0.1534, 0.1666, 0.1682, 0.188]}, {"w": "Suppose", "b": [0.1786, 0.1666, 0.2485, 0.188]}, {"w": "the", "b": [0.2555, 0.1666, 0.2818, 0.188]}, {"w": "features", "b": [0.2888, 0.1666, 0.3542, 0.188]}, {"w": "in", "b": [0.3612, 0.1666, 0.3782, 0.188]}, {"w": "your", "b": [0.3852, 0.1666, 0.4241, 0.188]}, {"w": "training", "b": [0.4311, 0.1666, 0.4981, 0.188]}, {"w": "set", "b": [0.505, 0.1666, 0.5279, 0.188]}, {"w": "have", "b": [0.5349, 0.1666, 0.5733, 0.188]}, {"w": "very", "b": [0.5803, 0.1666, 0.6167, 0.188]}, {"w": "different", "b": [0.6237, 0.1666, 0.6954, 0.188]}, {"w": "scales.", "b": [0.7024, 0.1666, 0.7545, 0.188]}, {"w": "What", "b": [0.7615, 0.1666, 0.8079, 0.188]}, {"w": "algo‐", "b": [0.8149, 0.1666, 0.8571, 0.188]}, {"w": "rithms", "b": [0.1786, 0.1857, 0.2341, 0.2071]}, {"w": "might", "b": [0.2388, 0.1857, 0.2883, 0.2071]}, {"w": "suffer", "b": [0.293, 0.1857, 0.3406, 0.2071]}, {"w": "from", "b": [0.3454, 0.1857, 0.3869, 0.2071]}, {"w": "this,", "b": [0.3917, 0.1857, 0.4271, 0.2071]}, {"w": "and", "b": [0.4319, 0.1857, 0.4634, 0.2071]}, {"w": "how?", "b": [0.4681, 0.1857, 0.5121, 0.2071]}, {"w": "What", "b": [0.5168, 0.1857, 0.5632, 0.2071]}, {"w": "can", "b": [0.568, 0.1857, 0.5973, 0.2071]}, {"w": "you", "b": [0.6021, 0.1857, 0.6333, 0.2071]}, {"w": "do", "b": [0.638, 0.1857, 0.6597, 0.2071]}, {"w": "about", "b": [0.6644, 0.1857, 0.7122, 0.2071]}, {"w": "it?", "b": [0.7169, 0.1857, 0.7367, 0.2071]}]}, {"id": "b_3", "type": "paragraph", "text": "3. Can Gradient Descent get stuck in a local minimum when training a Logistic Regression model?", "words": [{"w": "3.", "b": [0.1534, 0.2108, 0.1682, 0.2322]}, {"w": "Can", "b": [0.1786, 0.2108, 0.213, 0.2322]}, {"w": "Gradient", "b": [0.221, 0.2108, 0.2956, 0.2322]}, {"w": "Descent", "b": [0.3036, 0.2108, 0.3705, 0.2322]}, {"w": "get", "b": [0.3785, 0.2108, 0.4035, 0.2322]}, {"w": "stuck", "b": [0.4115, 0.2108, 0.4557, 0.2322]}, {"w": "in", "b": [0.4638, 0.2108, 0.4808, 0.2322]}, {"w": "a", "b": [0.4888, 0.2108, 0.498, 0.2322]}, {"w": "local", "b": [0.506, 0.2108, 0.5452, 0.2322]}, {"w": "minimum", "b": [0.5532, 0.2108, 0.6376, 0.2322]}, {"w": "when", "b": [0.6457, 0.2108, 0.6913, 0.2322]}, {"w": "training", "b": [0.6994, 0.2108, 0.7663, 0.2322]}, {"w": "a", "b": [0.7744, 0.2108, 0.7835, 0.2322]}, {"w": "Logistic", "b": [0.7916, 0.2108, 0.8571, 0.2322]}, {"w": "Regression", "b": [0.1786, 0.2298, 0.2696, 0.2512]}, {"w": "model?", "b": [0.2743, 0.2298, 0.335, 0.2512]}]}, {"id": "b_4", "type": "paragraph", "text": "4. Do all Gradient Descent algorithms lead to the same model provided you let them run long enough?", "words": [{"w": "4.", "b": [0.1534, 0.2549, 0.1682, 0.2763]}, {"w": "Do", "b": [0.1786, 0.2549, 0.2045, 0.2763]}, {"w": "all", "b": [0.2129, 0.2549, 0.2326, 0.2763]}, {"w": "Gradient", "b": [0.241, 0.2549, 0.3156, 0.2763]}, {"w": "Descent", "b": [0.324, 0.2549, 0.3909, 0.2763]}, {"w": "algorithms", "b": [0.3993, 0.2549, 0.4896, 0.2763]}, {"w": "lead", "b": [0.498, 0.2549, 0.5323, 0.2763]}, {"w": "to", "b": [0.5407, 0.2549, 0.5577, 0.2763]}, {"w": "the", "b": [0.5661, 0.2549, 0.5924, 0.2763]}, {"w": "same", "b": [0.6008, 0.2549, 0.6436, 0.2763]}, {"w": "model", "b": [0.652, 0.2549, 0.7048, 0.2763]}, {"w": "provided", "b": [0.7132, 0.2549, 0.7886, 0.2763]}, {"w": "you", "b": [0.797, 0.2549, 0.8282, 0.2763]}, {"w": "let", "b": [0.8367, 0.2549, 0.8571, 0.2763]}, {"w": "them", "b": [0.1786, 0.274, 0.222, 0.2954]}, {"w": "run", "b": [0.2267, 0.274, 0.2569, 0.2954]}, {"w": "long", "b": [0.2616, 0.274, 0.2987, 0.2954]}, {"w": "enough?", "b": [0.3034, 0.274, 0.3741, 0.2954]}]}, {"id": "b_5", "type": "paragraph", "text": "5. Suppose you use Batch Gradient Descent and you plot the validation error at every epoch. If you notice that the validation error consistently goes up, what is likely going on? How can you fix this?", "words": [{"w": "5.", "b": [0.1534, 0.2991, 0.1682, 0.3205]}, {"w": "Suppose", "b": [0.1786, 0.2991, 0.2485, 0.3205]}, {"w": "you", "b": [0.2566, 0.2991, 0.2879, 0.3205]}, {"w": "use", "b": [0.296, 0.2991, 0.3236, 0.3205]}, {"w": "Batch", "b": [0.3317, 0.2991, 0.379, 0.3205]}, {"w": "Gradient", "b": [0.3872, 0.2991, 0.4617, 0.3205]}, {"w": "Descent", "b": [0.4699, 0.2991, 0.5367, 0.3205]}, {"w": "and", "b": [0.5448, 0.2991, 0.5764, 0.3205]}, {"w": "you", "b": [0.5845, 0.2991, 0.6158, 0.3205]}, {"w": "plot", "b": [0.6239, 0.2991, 0.6571, 0.3205]}, {"w": "the", "b": [0.6652, 0.2991, 0.6916, 0.3205]}, {"w": "validation", "b": [0.6997, 0.2991, 0.7831, 0.3205]}, {"w": "error", "b": [0.7912, 0.2991, 0.8339, 0.3205]}, {"w": "at", "b": [0.842, 0.2991, 0.8571, 0.3205]}, {"w": "every", "b": [0.1786, 0.3181, 0.2238, 0.3395]}, {"w": "epoch.", "b": [0.2301, 0.3181, 0.2852, 0.3395]}, {"w": "If", "b": [0.2914, 0.3181, 0.3047, 0.3395]}, {"w": "you", "b": [0.3109, 0.3181, 0.3422, 0.3395]}, {"w": "notice", "b": [0.3485, 0.3181, 0.4001, 0.3395]}, {"w": "that", "b": [0.4063, 0.3181, 0.4389, 0.3395]}, {"w": "the", "b": [0.4452, 0.3181, 0.4715, 0.3395]}, {"w": "validation", "b": [0.4778, 0.3181, 0.5611, 0.3395]}, {"w": "error", "b": [0.5674, 0.3181, 0.61, 0.3395]}, {"w": "consistently", "b": [0.6163, 0.3181, 0.7154, 0.3395]}, {"w": "goes", "b": [0.7217, 0.3181, 0.7585, 0.3395]}, {"w": "up,", "b": [0.7648, 0.3181, 0.7909, 0.3395]}, {"w": "what", "b": [0.7972, 0.3181, 0.8377, 0.3395]}, {"w": "is", "b": [0.8439, 0.3181, 0.8571, 0.3395]}, {"w": "likely", "b": [0.1786, 0.3371, 0.2234, 0.3586]}, {"w": "going", "b": [0.2282, 0.3371, 0.2753, 0.3586]}, {"w": "on?", "b": [0.28, 0.3371, 0.3099, 0.3586]}, {"w": "How", "b": [0.3146, 0.3371, 0.355, 0.3586]}, {"w": "can", "b": [0.3597, 0.3371, 0.3891, 0.3586]}, {"w": "you", "b": [0.3938, 0.3371, 0.425, 0.3586]}, {"w": "fix", "b": [0.4298, 0.3371, 0.4514, 0.3586]}, {"w": "this?", "b": [0.4561, 0.3371, 0.4947, 0.3586]}]}, {"id": "b_6", "type": "paragraph", "text": "6. Is it a good idea to stop Mini-batch Gradient Descent immediately when the vali‐ dation error goes up?", "words": [{"w": "6.", "b": [0.1534, 0.3622, 0.1682, 0.3837]}, {"w": "Is", "b": [0.1786, 0.3622, 0.1929, 0.3837]}, {"w": "it", "b": [0.1979, 0.3622, 0.2098, 0.3837]}, {"w": "a", "b": [0.2149, 0.3622, 0.224, 0.3837]}, {"w": "good", "b": [0.2291, 0.3622, 0.2711, 0.3837]}, {"w": "idea", "b": [0.2761, 0.3622, 0.3107, 0.3837]}, {"w": "to", "b": [0.3157, 0.3622, 0.3327, 0.3837]}, {"w": "stop", "b": [0.3378, 0.3622, 0.3733, 0.3837]}, {"w": "Mini-batch", "b": [0.3783, 0.3622, 0.4725, 0.3837]}, {"w": "Gradient", "b": [0.4776, 0.3622, 0.5521, 0.3837]}, {"w": "Descent", "b": [0.5572, 0.3622, 0.624, 0.3837]}, {"w": "immediately", "b": [0.629, 0.3622, 0.733, 0.3837]}, {"w": "when", "b": [0.738, 0.3622, 0.7837, 0.3837]}, {"w": "the", "b": [0.7887, 0.3622, 0.815, 0.3837]}, {"w": "vali‐", "b": [0.8201, 0.3622, 0.8571, 0.3837]}, {"w": "dation", "b": [0.1786, 0.3813, 0.2323, 0.4027]}, {"w": "error", "b": [0.237, 0.3813, 0.2797, 0.4027]}, {"w": "goes", "b": [0.2844, 0.3813, 0.3213, 0.4027]}, {"w": "up?", "b": [0.326, 0.3813, 0.3559, 0.4027]}]}, {"id": "b_7", "type": "paragraph", "text": "7. Which Gradient Descent algorithm (among those we discussed) will reach the vicinity of the optimal solution the fastest? Which will actually converge? How can you make the others converge as well?", "words": [{"w": "7.", "b": [0.1534, 0.4064, 0.1682, 0.4278]}, {"w": "Which", "b": [0.1786, 0.4064, 0.2354, 0.4278]}, {"w": "Gradient", "b": [0.243, 0.4064, 0.3176, 0.4278]}, {"w": "Descent", "b": [0.3252, 0.4064, 0.392, 0.4278]}, {"w": "algorithm", "b": [0.3996, 0.4064, 0.4822, 0.4278]}, {"w": "(among", "b": [0.4898, 0.4064, 0.555, 0.4278]}, {"w": "those", "b": [0.5626, 0.4064, 0.6072, 0.4278]}, {"w": "we", "b": [0.6148, 0.4064, 0.6379, 0.4278]}, {"w": "discussed)", "b": [0.6455, 0.4064, 0.732, 0.4278]}, {"w": "will", "b": [0.7396, 0.4064, 0.77, 0.4278]}, {"w": "reach", "b": [0.7775, 0.4064, 0.8232, 0.4278]}, {"w": "the", "b": [0.8308, 0.4064, 0.8571, 0.4278]}, {"w": "vicinity", "b": [0.1786, 0.4254, 0.2411, 0.4468]}, {"w": "of", "b": [0.2482, 0.4254, 0.265, 0.4468]}, {"w": "the", "b": [0.272, 0.4254, 0.2983, 0.4468]}, {"w": "optimal", "b": [0.3054, 0.4254, 0.3704, 0.4468]}, {"w": "solution", "b": [0.3774, 0.4254, 0.446, 0.4468]}, {"w": "the", "b": [0.4531, 0.4254, 0.4794, 0.4468]}, {"w": "fastest?", "b": [0.4865, 0.4254, 0.5465, 0.4468]}, {"w": "Which", "b": [0.5536, 0.4254, 0.6105, 0.4468]}, {"w": "will", "b": [0.6175, 0.4254, 0.6479, 0.4468]}, {"w": "actually", "b": [0.655, 0.4254, 0.7196, 0.4468]}, {"w": "converge?", "b": [0.7267, 0.4254, 0.8097, 0.4468]}, {"w": "How", "b": [0.8168, 0.4254, 0.8571, 0.4468]}, {"w": "can", "b": [0.1786, 0.4445, 0.2079, 0.4659]}, {"w": "you", "b": [0.2126, 0.4445, 0.2439, 0.4659]}, {"w": "make", "b": [0.2486, 0.4445, 0.294, 0.4659]}, {"w": "the", "b": [0.2988, 0.4445, 0.3251, 0.4659]}, {"w": "others", "b": [0.3298, 0.4445, 0.3821, 0.4659]}, {"w": "converge", "b": [0.3869, 0.4445, 0.4621, 0.4659]}, {"w": "as", "b": [0.4668, 0.4445, 0.4836, 0.4659]}, {"w": "well?", "b": [0.4883, 0.4445, 0.5299, 0.4659]}]}, {"id": "b_8", "type": "paragraph", "text": "8. Suppose you are using Polynomial Regression. You plot the learning curves and you notice that there is a large gap between the training error and the validation error. What is happening? What are three ways to solve this?", "words": [{"w": "8.", "b": [0.1534, 0.4696, 0.1682, 0.491]}, {"w": "Suppose", "b": [0.1786, 0.4696, 0.2485, 0.491]}, {"w": "you", "b": [0.2546, 0.4696, 0.2859, 0.491]}, {"w": "are", "b": [0.2921, 0.4696, 0.3178, 0.491]}, {"w": "using", "b": [0.324, 0.4696, 0.3694, 0.491]}, {"w": "Polynomial", "b": [0.3756, 0.4696, 0.4712, 0.491]}, {"w": "Regression.", "b": [0.4774, 0.4696, 0.5732, 0.491]}, {"w": "You", "b": [0.5793, 0.4696, 0.6117, 0.491]}, {"w": "plot", "b": [0.6179, 0.4696, 0.6511, 0.491]}, {"w": "the", "b": [0.6572, 0.4696, 0.6836, 0.491]}, {"w": "learning", "b": [0.6898, 0.4696, 0.7589, 0.491]}, {"w": "curves", "b": [0.7651, 0.4696, 0.8194, 0.491]}, {"w": "and", "b": [0.8256, 0.4696, 0.8571, 0.491]}, {"w": "you", "b": [0.1786, 0.4886, 0.2098, 0.51]}, {"w": "notice", "b": [0.2156, 0.4886, 0.2673, 0.51]}, {"w": "that", "b": [0.2731, 0.4886, 0.3057, 0.51]}, {"w": "there", "b": [0.3115, 0.4886, 0.3544, 0.51]}, {"w": "is", "b": [0.3602, 0.4886, 0.3734, 0.51]}, {"w": "a", "b": [0.3792, 0.4886, 0.3884, 0.51]}, {"w": "large", "b": [0.3942, 0.4886, 0.4349, 0.51]}, {"w": "gap", "b": [0.4407, 0.4886, 0.4702, 0.51]}, {"w": "between", "b": [0.476, 0.4886, 0.5451, 0.51]}, {"w": "the", "b": [0.5509, 0.4886, 0.5773, 0.51]}, {"w": "training", "b": [0.5831, 0.4886, 0.65, 0.51]}, {"w": "error", "b": [0.6558, 0.4886, 0.6985, 0.51]}, {"w": "and", "b": [0.7043, 0.4886, 0.7358, 0.51]}, {"w": "the", "b": [0.7416, 0.4886, 0.768, 0.51]}, {"w": "validation", "b": [0.7738, 0.4886, 0.8571, 0.51]}, {"w": "error.", "b": [0.1786, 0.5077, 0.2247, 0.5291]}, {"w": "What", "b": [0.2294, 0.5077, 0.2759, 0.5291]}, {"w": "is", "b": [0.2806, 0.5077, 0.2938, 0.5291]}, {"w": "happening?", "b": [0.2985, 0.5077, 0.3951, 0.5291]}, {"w": "What", "b": [0.3999, 0.5077, 0.4463, 0.5291]}, {"w": "are", "b": [0.451, 0.5077, 0.4768, 0.5291]}, {"w": "three", "b": [0.4815, 0.5077, 0.5244, 0.5291]}, {"w": "ways", "b": [0.5291, 0.5077, 0.5694, 0.5291]}, {"w": "to", "b": [0.5741, 0.5077, 0.5911, 0.5291]}, {"w": "solve", "b": [0.5958, 0.5077, 0.6379, 0.5291]}, {"w": "this?", "b": [0.6426, 0.5077, 0.6812, 0.5291]}]}, {"id": "b_9", "type": "paragraph", "text": "9. Suppose you are using Ridge Regression and you notice that the training error and the validation error are almost equal and fairly high. Would you say that the model suffers from high bias or high variance? Should you increase the regulari‐ zation hyperparameter α or reduce it?", "words": [{"w": "9.", "b": [0.1534, 0.5328, 0.1682, 0.5542]}, {"w": "Suppose", "b": [0.1786, 0.5328, 0.2485, 0.5542]}, {"w": "you", "b": [0.2555, 0.5328, 0.2867, 0.5542]}, {"w": "are", "b": [0.2937, 0.5328, 0.3195, 0.5542]}, {"w": "using", "b": [0.3265, 0.5328, 0.3719, 0.5542]}, {"w": "Ridge", "b": [0.3789, 0.5328, 0.4271, 0.5542]}, {"w": "Regression", "b": [0.4341, 0.5328, 0.5251, 0.5542]}, {"w": "and", "b": [0.5321, 0.5328, 0.5637, 0.5542]}, {"w": "you", "b": [0.5707, 0.5328, 0.6019, 0.5542]}, {"w": "notice", "b": [0.6089, 0.5328, 0.6606, 0.5542]}, {"w": "that", "b": [0.6676, 0.5328, 0.7002, 0.5542]}, {"w": "the", "b": [0.7072, 0.5328, 0.7335, 0.5542]}, {"w": "training", "b": [0.7405, 0.5328, 0.8075, 0.5542]}, {"w": "error", "b": [0.8145, 0.5328, 0.8571, 0.5542]}, {"w": "and", "b": [0.1786, 0.5518, 0.2101, 0.5732]}, {"w": "the", "b": [0.2157, 0.5518, 0.242, 0.5732]}, {"w": "validation", "b": [0.2476, 0.5518, 0.331, 0.5732]}, {"w": "error", "b": [0.3366, 0.5518, 0.3792, 0.5732]}, {"w": "are", "b": [0.3848, 0.5518, 0.4105, 0.5732]}, {"w": "almost", "b": [0.4161, 0.5518, 0.4722, 0.5732]}, {"w": "equal", "b": [0.4778, 0.5518, 0.5228, 0.5732]}, {"w": "and", "b": [0.5284, 0.5518, 0.5599, 0.5732]}, {"w": "fairly", "b": [0.5655, 0.5518, 0.609, 0.5732]}, {"w": "high.", "b": [0.6146, 0.5518, 0.6569, 0.5732]}, {"w": "Would", "b": [0.6625, 0.5518, 0.7187, 0.5732]}, {"w": "you", "b": [0.7242, 0.5518, 0.7555, 0.5732]}, {"w": "say", "b": [0.7611, 0.5518, 0.7871, 0.5732]}, {"w": "that", "b": [0.7926, 0.5518, 0.8252, 0.5732]}, {"w": "the", "b": [0.8308, 0.5518, 0.8571, 0.5732]}, {"w": "model", "b": [0.1786, 0.5709, 0.2314, 0.5923]}, {"w": "suffers", "b": [0.237, 0.5709, 0.2922, 0.5923]}, {"w": "from", "b": [0.2978, 0.5709, 0.3394, 0.5923]}, {"w": "high", "b": [0.345, 0.5709, 0.3826, 0.5923]}, {"w": "bias", "b": [0.3882, 0.5709, 0.4211, 0.5923]}, {"w": "or", "b": [0.4267, 0.5709, 0.4451, 0.5923]}, {"w": "high", "b": [0.4507, 0.5709, 0.4883, 0.5923]}, {"w": "variance?", "b": [0.4939, 0.5709, 0.5721, 0.5923]}, {"w": "Should", "b": [0.5777, 0.5709, 0.6366, 0.5923]}, {"w": "you", "b": [0.6422, 0.5709, 0.6735, 0.5923]}, {"w": "increase", "b": [0.6791, 0.5709, 0.7471, 0.5923]}, {"w": "the", "b": [0.7527, 0.5709, 0.779, 0.5923]}, {"w": "regulari‐", "b": [0.7846, 0.5709, 0.8571, 0.5923]}, {"w": "zation", "b": [0.1786, 0.5899, 0.23, 0.6113]}, {"w": "hyperparameter", "b": [0.2348, 0.5899, 0.3683, 0.6113]}, {"w": "α", "b": [0.373, 0.5897, 0.3841, 0.6113]}, {"w": "or", "b": [0.3889, 0.5899, 0.4072, 0.6113]}, {"w": "reduce", "b": [0.4119, 0.5899, 0.4683, 0.6113]}, {"w": "it?", "b": [0.473, 0.5899, 0.4928, 0.6113]}]}, {"id": "b_10", "type": "paragraph", "text": "10. Why would you want to use:", "words": [{"w": "10.", "b": [0.1434, 0.615, 0.1682, 0.6364]}, {"w": "Why", "b": [0.1786, 0.615, 0.219, 0.6364]}, {"w": "would", "b": [0.2237, 0.615, 0.276, 0.6364]}, {"w": "you", "b": [0.2807, 0.615, 0.3119, 0.6364]}, {"w": "want", "b": [0.3167, 0.615, 0.3574, 0.6364]}, {"w": "to", "b": [0.3622, 0.615, 0.3791, 0.6364]}, {"w": "use:", "b": [0.3839, 0.615, 0.4162, 0.6364]}]}, {"id": "b_11", "type": "paragraph", "text": "• Ridge Regression instead of plain Linear Regression (i.e., without any regulari‐ zation)?", "words": [{"w": "•", "b": [0.1799, 0.6461, 0.188, 0.6676]}, {"w": "Ridge", "b": [0.1984, 0.6461, 0.2465, 0.6676]}, {"w": "Regression", "b": [0.2518, 0.6461, 0.3428, 0.6676]}, {"w": "instead", "b": [0.348, 0.6461, 0.408, 0.6676]}, {"w": "of", "b": [0.4132, 0.6461, 0.43, 0.6676]}, {"w": "plain", "b": [0.4352, 0.6461, 0.4775, 0.6676]}, {"w": "Linear", "b": [0.4827, 0.6461, 0.5366, 0.6676]}, {"w": "Regression", "b": [0.5418, 0.6461, 0.6329, 0.6676]}, {"w": "(i.e.,", "b": [0.6381, 0.6461, 0.674, 0.6676]}, {"w": "without", "b": [0.6792, 0.6461, 0.7446, 0.6676]}, {"w": "any", "b": [0.7498, 0.6461, 0.7794, 0.6676]}, {"w": "regulari‐", "b": [0.7846, 0.6461, 0.8572, 0.6676]}, {"w": "zation)?", "b": [0.1984, 0.6652, 0.265, 0.6866]}]}, {"id": "b_12", "type": "paragraph", "text": "• Lasso instead of Ridge Regression?", "words": [{"w": "•", "b": [0.1799, 0.6903, 0.188, 0.7117]}, {"w": "Lasso", "b": [0.1984, 0.6903, 0.2447, 0.7117]}, {"w": "instead", "b": [0.2494, 0.6903, 0.3094, 0.7117]}, {"w": "of", "b": [0.3141, 0.6903, 0.3309, 0.7117]}, {"w": "Ridge", "b": [0.3356, 0.6903, 0.3838, 0.7117]}, {"w": "Regression?", "b": [0.3885, 0.6903, 0.4874, 0.7117]}]}, {"id": "b_13", "type": "paragraph", "text": "• Elastic Net instead of Lasso?", "words": [{"w": "•", "b": [0.1799, 0.7154, 0.188, 0.7368]}, {"w": "Elastic", "b": [0.1984, 0.7154, 0.2531, 0.7368]}, {"w": "Net", "b": [0.2578, 0.7154, 0.288, 0.7368]}, {"w": "instead", "b": [0.2927, 0.7154, 0.3527, 0.7368]}, {"w": "of", "b": [0.3574, 0.7154, 0.3742, 0.7368]}, {"w": "Lasso?", "b": [0.3789, 0.7154, 0.4331, 0.7368]}]}, {"id": "b_14", "type": "paragraph", "text": "11. Suppose you want to classify pictures as outdoor/indoor and daytime/nighttime. Should you implement two Logistic Regression classifiers or one Softmax Regres‐ sion classifier?", "words": [{"w": "11.", "b": [0.1434, 0.7495, 0.1682, 0.771]}, {"w": "Suppose", "b": [0.1786, 0.7495, 0.2485, 0.771]}, {"w": "you", "b": [0.2542, 0.7495, 0.2855, 0.771]}, {"w": "want", "b": [0.2912, 0.7495, 0.332, 0.771]}, {"w": "to", "b": [0.3378, 0.7495, 0.3547, 0.771]}, {"w": "classify", "b": [0.3605, 0.7495, 0.4207, 0.771]}, {"w": "pictures", "b": [0.4264, 0.7495, 0.4934, 0.771]}, {"w": "as", "b": [0.4992, 0.7495, 0.5159, 0.771]}, {"w": "outdoor/indoor", "b": [0.5217, 0.7495, 0.6536, 0.771]}, {"w": "and", "b": [0.6593, 0.7495, 0.6909, 0.771]}, {"w": "daytime/nighttime.", "b": [0.6966, 0.7495, 0.8571, 0.771]}, {"w": "Should", "b": [0.1786, 0.7686, 0.2375, 0.79]}, {"w": "you", "b": [0.2424, 0.7686, 0.2736, 0.79]}, {"w": "implement", "b": [0.2785, 0.7686, 0.369, 0.79]}, {"w": "two", "b": [0.3739, 0.7686, 0.4051, 0.79]}, {"w": "Logistic", "b": [0.41, 0.7686, 0.4755, 0.79]}, {"w": "Regression", "b": [0.4804, 0.7686, 0.5714, 0.79]}, {"w": "classifiers", "b": [0.5762, 0.7686, 0.6563, 0.79]}, {"w": "or", "b": [0.6611, 0.7686, 0.6795, 0.79]}, {"w": "one", "b": [0.6843, 0.7686, 0.7152, 0.79]}, {"w": "Softmax", "b": [0.7201, 0.7686, 0.7891, 0.79]}, {"w": "Regres‐", "b": [0.794, 0.7686, 0.8571, 0.79]}, {"w": "sion", "b": [0.1786, 0.7876, 0.2138, 0.8091]}, {"w": "classifier?", "b": [0.2185, 0.7876, 0.2989, 0.8091]}]}, {"id": "b_15", "type": "paragraph", "text": "12. Implement Batch Gradient Descent with early stopping for Softmax Regression (without using Scikit-Learn).", "words": [{"w": "12.", "b": [0.1434, 0.8127, 0.1682, 0.8341]}, {"w": "Implement", "b": [0.1786, 0.8127, 0.2706, 0.8341]}, {"w": "Batch", "b": [0.2769, 0.8127, 0.3242, 0.8341]}, {"w": "Gradient", "b": [0.3304, 0.8127, 0.4049, 0.8341]}, {"w": "Descent", "b": [0.4111, 0.8127, 0.478, 0.8341]}, {"w": "with", "b": [0.4842, 0.8127, 0.5215, 0.8341]}, {"w": "early", "b": [0.5277, 0.8127, 0.5683, 0.8341]}, {"w": "stopping", "b": [0.5745, 0.8127, 0.6477, 0.8341]}, {"w": "for", "b": [0.6539, 0.8127, 0.6784, 0.8341]}, {"w": "Softmax", "b": [0.6846, 0.8127, 0.7537, 0.8341]}, {"w": "Regression", "b": [0.7599, 0.8127, 0.8509, 0.8341]}, {"w": "(without", "b": [0.1786, 0.8318, 0.2512, 0.8532]}, {"w": "using", "b": [0.2559, 0.8318, 0.3013, 0.8532]}, {"w": "Scikit-Learn).", "b": [0.3061, 0.8318, 0.4203, 0.8532]}]}, {"id": "b_16", "type": "paragraph", "text": "Solutions to these exercises are available in ???.", "words": [{"w": "Solutions", "b": [0.1429, 0.8659, 0.2213, 0.8874]}, {"w": "to", "b": [0.226, 0.8659, 0.243, 0.8874]}, {"w": "these", "b": [0.2477, 0.8659, 0.2906, 0.8874]}, {"w": "exercises", "b": [0.2953, 0.8659, 0.3691, 0.8874]}, {"w": "are", "b": [0.3738, 0.8659, 0.3996, 0.8874]}, {"w": "available", "b": [0.4043, 0.8659, 0.4766, 0.8874]}, {"w": "in", "b": [0.4813, 0.8659, 0.4983, 0.8874]}, {"w": "???.", "b": [0.503, 0.8659, 0.5314, 0.8874]}]}, {"id": "b_17", "type": "paragraph", "text": "Exercises | 153", "words": [{"w": "Exercises", "b": [0.7433, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "153", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 180, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": []}, {"page": 181, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "CHAPTER 5 Support Vector Machines", "words": [{"w": "CHAPTER", "b": [0.7398, 0.1146, 0.8383, 0.1451]}, {"w": "5", "b": [0.8435, 0.1146, 0.8571, 0.1451]}, {"w": "Support", "b": [0.4488, 0.1478, 0.5802, 0.1935]}, {"w": "Vector", "b": [0.5881, 0.1478, 0.6939, 0.1935]}, {"w": "Machines", "b": [0.7018, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_1", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 5 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.3643, 0.3102, 0.3839]}, {"w": "Early", "b": [0.3165, 0.3643, 0.3563, 0.3839]}, {"w": "Release", "b": [0.3626, 0.3643, 0.4189, 0.3839]}, {"w": "ebooks,", "b": [0.4251, 0.3643, 0.4831, 0.3839]}, {"w": "you", "b": [0.4894, 0.3643, 0.518, 0.3839]}, {"w": "get", "b": [0.5243, 0.3643, 0.5471, 0.3839]}, {"w": "books", "b": [0.5534, 0.3643, 0.5989, 0.3839]}, {"w": "in", "b": [0.6052, 0.3643, 0.6207, 0.3839]}, {"w": "their", "b": [0.627, 0.3643, 0.6632, 0.3839]}, {"w": "earliest", "b": [0.6695, 0.3643, 0.7239, 0.3839]}, {"w": "form—", "b": [0.7301, 0.3643, 0.7857, 0.3839]}, {"w": "the", "b": [0.2714, 0.3818, 0.2955, 0.4013]}, {"w": "author’s", "b": [0.3012, 0.3818, 0.3615, 0.4013]}, {"w": "raw", "b": [0.3672, 0.3818, 0.3954, 0.4013]}, {"w": "and", "b": [0.4011, 0.3818, 0.4299, 0.4013]}, {"w": "unedited", "b": [0.4357, 0.3818, 0.5034, 0.4013]}, {"w": "content", "b": [0.5091, 0.3818, 0.5667, 0.4013]}, {"w": "as", "b": [0.5725, 0.3818, 0.5878, 0.4013]}, {"w": "he", "b": [0.5936, 0.3818, 0.6118, 0.4013]}, {"w": "or", "b": [0.6175, 0.3818, 0.6343, 0.4013]}, {"w": "she", "b": [0.6401, 0.3818, 0.6653, 0.4013]}, {"w": "writes—so", "b": [0.671, 0.3818, 0.7514, 0.4013]}, {"w": "you", "b": [0.7571, 0.3818, 0.7857, 0.4013]}, {"w": "can", "b": [0.2714, 0.3992, 0.2982, 0.4188]}, {"w": "take", "b": [0.306, 0.3992, 0.3377, 0.4188]}, {"w": "advantage", "b": [0.3455, 0.3992, 0.4223, 0.4188]}, {"w": "of", "b": [0.4301, 0.3992, 0.4454, 0.4188]}, {"w": "these", "b": [0.4532, 0.3992, 0.4923, 0.4188]}, {"w": "technologies", "b": [0.5001, 0.3992, 0.596, 0.4188]}, {"w": "long", "b": [0.6038, 0.3992, 0.6376, 0.4188]}, {"w": "before", "b": [0.6454, 0.3992, 0.6937, 0.4188]}, {"w": "the", "b": [0.7014, 0.3992, 0.7255, 0.4188]}, {"w": "official", "b": [0.7333, 0.3992, 0.7857, 0.4188]}, {"w": "release", "b": [0.2714, 0.4166, 0.3229, 0.4362]}, {"w": "of", "b": [0.3292, 0.4166, 0.3445, 0.4362]}, {"w": "these", "b": [0.3507, 0.4166, 0.3899, 0.4362]}, {"w": "titles.", "b": [0.3961, 0.4166, 0.4371, 0.4362]}, {"w": "The", "b": [0.4433, 0.4166, 0.4733, 0.4362]}, {"w": "following", "b": [0.4795, 0.4166, 0.5517, 0.4362]}, {"w": "will", "b": [0.558, 0.4166, 0.5857, 0.4362]}, {"w": "be", "b": [0.592, 0.4166, 0.6097, 0.4362]}, {"w": "Chapter", "b": [0.616, 0.4166, 0.6777, 0.4362]}, {"w": "5", "b": [0.684, 0.4166, 0.6931, 0.4362]}, {"w": "in", "b": [0.6993, 0.4166, 0.7149, 0.4362]}, {"w": "the", "b": [0.7211, 0.4166, 0.7452, 0.4362]}, {"w": "final", "b": [0.7514, 0.4166, 0.7857, 0.4362]}, {"w": "release", "b": [0.2714, 0.434, 0.3229, 0.4536]}, {"w": "of", "b": [0.3273, 0.434, 0.3426, 0.4536]}, {"w": "the", "b": [0.3469, 0.434, 0.371, 0.4536]}, {"w": "book.", "b": [0.3753, 0.434, 0.4182, 0.4536]}]}, {"id": "b_2", "type": "paragraph", "text": "A Support Vector Machine (SVM) is a very powerful and versatile Machine Learning model, capable of performing linear or nonlinear classification, regression, and even outlier detection. It is one of the most popular models in Machine Learning, and any‐ one interested in Machine Learning should have it in their toolbox. SVMs are partic‐ ularly well suited for classification of complex but small- or medium-sized datasets.", "words": [{"w": "A", "b": [0.1429, 0.4739, 0.1573, 0.4953]}, {"w": "Support", "b": [0.1634, 0.4737, 0.2277, 0.4953]}, {"w": "Vector", "b": [0.2339, 0.4737, 0.2857, 0.4953]}, {"w": "Machine", "b": [0.2919, 0.4737, 0.3623, 0.4953]}, {"w": "(SVM)", "b": [0.3684, 0.4739, 0.4259, 0.4953]}, {"w": "is", "b": [0.4321, 0.4739, 0.4453, 0.4953]}, {"w": "a", "b": [0.4514, 0.4739, 0.4606, 0.4953]}, {"w": "very", "b": [0.4667, 0.4739, 0.5031, 0.4953]}, {"w": "powerful", "b": [0.5093, 0.4739, 0.5841, 0.4953]}, {"w": "and", "b": [0.5903, 0.4739, 0.6218, 0.4953]}, {"w": "versatile", "b": [0.628, 0.4739, 0.6967, 0.4953]}, {"w": "Machine", "b": [0.7028, 0.4739, 0.7759, 0.4953]}, {"w": "Learning", "b": [0.7821, 0.4739, 0.8571, 0.4953]}, {"w": "model,", "b": [0.1428, 0.4929, 0.2004, 0.5143]}, {"w": "capable", "b": [0.2065, 0.4929, 0.2689, 0.5143]}, {"w": "of", "b": [0.275, 0.4929, 0.2918, 0.5143]}, {"w": "performing", "b": [0.2979, 0.4929, 0.3937, 0.5143]}, {"w": "linear", "b": [0.3998, 0.4929, 0.4478, 0.5143]}, {"w": "or", "b": [0.4539, 0.4929, 0.4722, 0.5143]}, {"w": "nonlinear", "b": [0.4783, 0.4929, 0.5597, 0.5143]}, {"w": "classification,", "b": [0.5658, 0.4929, 0.678, 0.5143]}, {"w": "regression,", "b": [0.6841, 0.4929, 0.7746, 0.5143]}, {"w": "and", "b": [0.7807, 0.4929, 0.8123, 0.5143]}, {"w": "even", "b": [0.8184, 0.4929, 0.8571, 0.5143]}, {"w": "outlier", "b": [0.1429, 0.512, 0.1983, 0.5334]}, {"w": "detection.", "b": [0.2033, 0.512, 0.2859, 0.5334]}, {"w": "It", "b": [0.2909, 0.512, 0.3036, 0.5334]}, {"w": "is", "b": [0.3086, 0.512, 0.3218, 0.5334]}, {"w": "one", "b": [0.3268, 0.512, 0.3577, 0.5334]}, {"w": "of", "b": [0.3627, 0.512, 0.3795, 0.5334]}, {"w": "the", "b": [0.3845, 0.512, 0.4108, 0.5334]}, {"w": "most", "b": [0.4158, 0.512, 0.4575, 0.5334]}, {"w": "popular", "b": [0.4625, 0.512, 0.5282, 0.5334]}, {"w": "models", "b": [0.5332, 0.512, 0.5936, 0.5334]}, {"w": "in", "b": [0.5986, 0.512, 0.6156, 0.5334]}, {"w": "Machine", "b": [0.6206, 0.512, 0.6937, 0.5334]}, {"w": "Learning,", "b": [0.6987, 0.512, 0.7786, 0.5334]}, {"w": "and", "b": [0.7836, 0.512, 0.8151, 0.5334]}, {"w": "any‐", "b": [0.8201, 0.512, 0.8571, 0.5334]}, {"w": "one", "b": [0.1429, 0.531, 0.1737, 0.5524]}, {"w": "interested", "b": [0.1792, 0.531, 0.2614, 0.5524]}, {"w": "in", "b": [0.2669, 0.531, 0.2839, 0.5524]}, {"w": "Machine", "b": [0.2894, 0.531, 0.3625, 0.5524]}, {"w": "Learning", "b": [0.368, 0.531, 0.443, 0.5524]}, {"w": "should", "b": [0.4485, 0.531, 0.5053, 0.5524]}, {"w": "have", "b": [0.5107, 0.531, 0.5491, 0.5524]}, {"w": "it", "b": [0.5546, 0.531, 0.5666, 0.5524]}, {"w": "in", "b": [0.572, 0.531, 0.589, 0.5524]}, {"w": "their", "b": [0.5945, 0.531, 0.6341, 0.5524]}, {"w": "toolbox.", "b": [0.6396, 0.531, 0.7083, 0.5524]}, {"w": "SVMs", "b": [0.7138, 0.531, 0.7645, 0.5524]}, {"w": "are", "b": [0.77, 0.531, 0.7957, 0.5524]}, {"w": "partic‐", "b": [0.8012, 0.531, 0.8571, 0.5524]}, {"w": "ularly", "b": [0.1429, 0.5501, 0.1909, 0.5715]}, {"w": "well", "b": [0.1956, 0.5501, 0.2293, 0.5715]}, {"w": "suited", "b": [0.234, 0.5501, 0.2845, 0.5715]}, {"w": "for", "b": [0.2892, 0.5501, 0.3138, 0.5715]}, {"w": "classification", "b": [0.3185, 0.5501, 0.4259, 0.5715]}, {"w": "of", "b": [0.4306, 0.5501, 0.4474, 0.5715]}, {"w": "complex", "b": [0.4521, 0.5501, 0.5231, 0.5715]}, {"w": "but", "b": [0.5278, 0.5501, 0.5558, 0.5715]}, {"w": "small-", "b": [0.5606, 0.5501, 0.6124, 0.5715]}, {"w": "or", "b": [0.6171, 0.5501, 0.6355, 0.5715]}, {"w": "medium-sized", "b": [0.6402, 0.5501, 0.7601, 0.5715]}, {"w": "datasets.", "b": [0.7648, 0.5501, 0.8353, 0.5715]}]}, {"id": "b_3", "type": "paragraph", "text": "This chapter will explain the core concepts of SVMs, how to use them, and how they work.", "words": [{"w": "This", "b": [0.1429, 0.5782, 0.1801, 0.5996]}, {"w": "chapter", "b": [0.1856, 0.5782, 0.2481, 0.5996]}, {"w": "will", "b": [0.2537, 0.5782, 0.2841, 0.5996]}, {"w": "explain", "b": [0.2896, 0.5782, 0.3506, 0.5996]}, {"w": "the", "b": [0.3561, 0.5782, 0.3824, 0.5996]}, {"w": "core", "b": [0.388, 0.5782, 0.424, 0.5996]}, {"w": "concepts", "b": [0.4295, 0.5782, 0.5029, 0.5996]}, {"w": "of", "b": [0.5085, 0.5782, 0.5253, 0.5996]}, {"w": "SVMs,", "b": [0.5308, 0.5782, 0.5863, 0.5996]}, {"w": "how", "b": [0.5918, 0.5782, 0.6278, 0.5996]}, {"w": "to", "b": [0.6333, 0.5782, 0.6503, 0.5996]}, {"w": "use", "b": [0.6559, 0.5782, 0.6834, 0.5996]}, {"w": "them,", "b": [0.6889, 0.5782, 0.7371, 0.5996]}, {"w": "and", "b": [0.7426, 0.5782, 0.7742, 0.5996]}, {"w": "how", "b": [0.7797, 0.5782, 0.8157, 0.5996]}, {"w": "they", "b": [0.8212, 0.5782, 0.8571, 0.5996]}, {"w": "work.", "b": [0.1429, 0.5972, 0.1906, 0.6186]}]}, {"id": "b_4", "type": "paragraph", "text": "Linear SVM Classification", "words": [{"w": "Linear", "b": [0.1429, 0.6316, 0.2204, 0.6659]}, {"w": "SVM", "b": [0.2264, 0.6316, 0.2803, 0.6659]}, {"w": "Classification", "b": [0.2862, 0.6316, 0.4481, 0.6659]}]}, {"id": "b_5", "type": "paragraph", "text": "The fundamental idea behind SVMs is best explained with some pictures. Figure 5-1 shows part of the iris dataset that was introduced at the end of Chapter 4. The two classes can clearly be separated easily with a straight line (they are linearly separable). The left plot shows the decision boundaries of three possible linear classifiers. The model whose decision boundary is represented by the dashed line is so bad that it does not even separate the classes properly. The other two models work perfectly on this training set, but their decision boundaries come so close to the instances that these models will probably not perform as well on new instances. In contrast, the solid line in the plot on the right represents the decision boundary of an SVM classi‐ fier; this line not only separates the two classes but also stays as far away from the closest training instances as possible. You can think of an SVM classifier as fitting the", "words": [{"w": "The", "b": [0.1429, 0.6728, 0.1757, 0.6942]}, {"w": "fundamental", "b": [0.1814, 0.6728, 0.2879, 0.6942]}, {"w": "idea", "b": [0.2936, 0.6728, 0.3282, 0.6942]}, {"w": "behind", "b": [0.334, 0.6728, 0.3925, 0.6942]}, {"w": "SVMs", "b": [0.3983, 0.6728, 0.449, 0.6942]}, {"w": "is", "b": [0.4547, 0.6728, 0.468, 0.6942]}, {"w": "best", "b": [0.4737, 0.6728, 0.5072, 0.6942]}, {"w": "explained", "b": [0.5129, 0.6728, 0.5938, 0.6942]}, {"w": "with", "b": [0.5995, 0.6728, 0.6368, 0.6942]}, {"w": "some", "b": [0.6426, 0.6728, 0.6868, 0.6942]}, {"w": "pictures.", "b": [0.6925, 0.6728, 0.7642, 0.6942]}, {"w": "Figure", "b": [0.77, 0.6728, 0.824, 0.6942]}, {"w": "5-1", "b": [0.8297, 0.6728, 0.8571, 0.6942]}, {"w": "shows", "b": [0.1429, 0.6919, 0.1942, 0.7133]}, {"w": "part", "b": [0.201, 0.6919, 0.2352, 0.7133]}, {"w": "of", "b": [0.242, 0.6919, 0.2588, 0.7133]}, {"w": "the", "b": [0.2656, 0.6919, 0.292, 0.7133]}, {"w": "iris", "b": [0.2988, 0.6919, 0.3254, 0.7133]}, {"w": "dataset", "b": [0.3322, 0.6919, 0.3903, 0.7133]}, {"w": "that", "b": [0.3971, 0.6919, 0.4297, 0.7133]}, {"w": "was", "b": [0.4366, 0.6919, 0.4676, 0.7133]}, {"w": "introduced", "b": [0.4745, 0.6919, 0.5665, 0.7133]}, {"w": "at", "b": [0.5733, 0.6919, 0.5884, 0.7133]}, {"w": "the", "b": [0.5953, 0.6919, 0.6216, 0.7133]}, {"w": "end", "b": [0.6285, 0.6919, 0.6597, 0.7133]}, {"w": "of", "b": [0.6666, 0.6919, 0.6834, 0.7133]}, {"w": "Chapter", "b": [0.6902, 0.6919, 0.7578, 0.7133]}, {"w": "4.", "b": [0.7646, 0.6919, 0.7794, 0.7133]}, {"w": "The", "b": [0.7862, 0.6919, 0.819, 0.7133]}, {"w": "two", "b": [0.8259, 0.6919, 0.8571, 0.7133]}, {"w": "classes", "b": [0.1429, 0.7109, 0.1979, 0.7323]}, {"w": "can", "b": [0.2034, 0.7109, 0.2328, 0.7323]}, {"w": "clearly", "b": [0.2384, 0.7109, 0.293, 0.7323]}, {"w": "be", "b": [0.2986, 0.7109, 0.318, 0.7323]}, {"w": "separated", "b": [0.3236, 0.7109, 0.4028, 0.7323]}, {"w": "easily", "b": [0.4084, 0.7109, 0.4544, 0.7323]}, {"w": "with", "b": [0.46, 0.7109, 0.4973, 0.7323]}, {"w": "a", "b": [0.5029, 0.7109, 0.512, 0.7323]}, {"w": "straight", "b": [0.5176, 0.7109, 0.5809, 0.7323]}, {"w": "line", "b": [0.5865, 0.7109, 0.6176, 0.7323]}, {"w": "(they", "b": [0.6231, 0.7109, 0.6662, 0.7323]}, {"w": "are", "b": [0.6718, 0.7109, 0.6975, 0.7323]}, {"w": "linearly", "b": [0.7031, 0.7107, 0.764, 0.7323]}, {"w": "separable).", "b": [0.7696, 0.7107, 0.8571, 0.7323]}, {"w": "The", "b": [0.1429, 0.73, 0.1757, 0.7514]}, {"w": "left", "b": [0.1831, 0.73, 0.2097, 0.7514]}, {"w": "plot", "b": [0.2171, 0.73, 0.2502, 0.7514]}, {"w": "shows", "b": [0.2576, 0.73, 0.3089, 0.7514]}, {"w": "the", "b": [0.3163, 0.73, 0.3426, 0.7514]}, {"w": "decision", "b": [0.35, 0.73, 0.4195, 0.7514]}, {"w": "boundaries", "b": [0.4269, 0.73, 0.5205, 0.7514]}, {"w": "of", "b": [0.5278, 0.73, 0.5446, 0.7514]}, {"w": "three", "b": [0.552, 0.73, 0.5949, 0.7514]}, {"w": "possible", "b": [0.6023, 0.73, 0.6694, 0.7514]}, {"w": "linear", "b": [0.6768, 0.73, 0.7248, 0.7514]}, {"w": "classifiers.", "b": [0.7321, 0.73, 0.817, 0.7514]}, {"w": "The", "b": [0.8243, 0.73, 0.8572, 0.7514]}, {"w": "model", "b": [0.1429, 0.749, 0.1957, 0.7704]}, {"w": "whose", "b": [0.2031, 0.749, 0.2556, 0.7704]}, {"w": "decision", "b": [0.263, 0.749, 0.3325, 0.7704]}, {"w": "boundary", "b": [0.3399, 0.749, 0.4216, 0.7704]}, {"w": "is", "b": [0.429, 0.749, 0.4422, 0.7704]}, {"w": "represented", "b": [0.4496, 0.749, 0.5474, 0.7704]}, {"w": "by", "b": [0.5548, 0.749, 0.575, 0.7704]}, {"w": "the", "b": [0.5824, 0.749, 0.6087, 0.7704]}, {"w": "dashed", "b": [0.6161, 0.749, 0.6749, 0.7704]}, {"w": "line", "b": [0.6823, 0.749, 0.7134, 0.7704]}, {"w": "is", "b": [0.7208, 0.749, 0.734, 0.7704]}, {"w": "so", "b": [0.7414, 0.749, 0.7597, 0.7704]}, {"w": "bad", "b": [0.7671, 0.749, 0.7978, 0.7704]}, {"w": "that", "b": [0.8052, 0.749, 0.8378, 0.7704]}, {"w": "it", "b": [0.8452, 0.749, 0.8571, 0.7704]}, {"w": "does", "b": [0.1429, 0.7681, 0.181, 0.7895]}, {"w": "not", "b": [0.187, 0.7681, 0.2153, 0.7895]}, {"w": "even", "b": [0.2213, 0.7681, 0.2601, 0.7895]}, {"w": "separate", "b": [0.2661, 0.7681, 0.3343, 0.7895]}, {"w": "the", "b": [0.3403, 0.7681, 0.3666, 0.7895]}, {"w": "classes", "b": [0.3726, 0.7681, 0.4277, 0.7895]}, {"w": "properly.", "b": [0.4336, 0.7681, 0.5085, 0.7895]}, {"w": "The", "b": [0.5145, 0.7681, 0.5473, 0.7895]}, {"w": "other", "b": [0.5533, 0.7681, 0.598, 0.7895]}, {"w": "two", "b": [0.604, 0.7681, 0.6352, 0.7895]}, {"w": "models", "b": [0.6412, 0.7681, 0.7017, 0.7895]}, {"w": "work", "b": [0.7077, 0.7681, 0.7506, 0.7895]}, {"w": "perfectly", "b": [0.7566, 0.7681, 0.8291, 0.7895]}, {"w": "on", "b": [0.8351, 0.7681, 0.8571, 0.7895]}, {"w": "this", "b": [0.1428, 0.7871, 0.1736, 0.8085]}, {"w": "training", "b": [0.1813, 0.7871, 0.2482, 0.8085]}, {"w": "set,", "b": [0.256, 0.7871, 0.2836, 0.8085]}, {"w": "but", "b": [0.2913, 0.7871, 0.3193, 0.8085]}, {"w": "their", "b": [0.3271, 0.7871, 0.3667, 0.8085]}, {"w": "decision", "b": [0.3745, 0.7871, 0.444, 0.8085]}, {"w": "boundaries", "b": [0.4517, 0.7871, 0.5453, 0.8085]}, {"w": "come", "b": [0.5531, 0.7871, 0.5984, 0.8085]}, {"w": "so", "b": [0.6062, 0.7871, 0.6245, 0.8085]}, {"w": "close", "b": [0.6322, 0.7871, 0.6734, 0.8085]}, {"w": "to", "b": [0.6812, 0.7871, 0.6981, 0.8085]}, {"w": "the", "b": [0.7059, 0.7871, 0.7322, 0.8085]}, {"w": "instances", "b": [0.74, 0.7871, 0.8168, 0.8085]}, {"w": "that", "b": [0.8246, 0.7871, 0.8571, 0.8085]}, {"w": "these", "b": [0.1429, 0.8061, 0.1857, 0.8276]}, {"w": "models", "b": [0.1936, 0.8061, 0.2541, 0.8276]}, {"w": "will", "b": [0.262, 0.8061, 0.2924, 0.8276]}, {"w": "probably", "b": [0.3003, 0.8061, 0.3747, 0.8276]}, {"w": "not", "b": [0.3826, 0.8061, 0.411, 0.8276]}, {"w": "perform", "b": [0.4189, 0.8061, 0.488, 0.8276]}, {"w": "as", "b": [0.4959, 0.8061, 0.5127, 0.8276]}, {"w": "well", "b": [0.5206, 0.8061, 0.5543, 0.8276]}, {"w": "on", "b": [0.5622, 0.8061, 0.5842, 0.8276]}, {"w": "new", "b": [0.5921, 0.8061, 0.6267, 0.8276]}, {"w": "instances.", "b": [0.6346, 0.8061, 0.7162, 0.8276]}, {"w": "In", "b": [0.7241, 0.8061, 0.7426, 0.8276]}, {"w": "contrast,", "b": [0.7505, 0.8061, 0.8229, 0.8276]}, {"w": "the", "b": [0.8308, 0.8061, 0.8571, 0.8276]}, {"w": "solid", "b": [0.1429, 0.8252, 0.183, 0.8466]}, {"w": "line", "b": [0.1885, 0.8252, 0.2196, 0.8466]}, {"w": "in", "b": [0.2252, 0.8252, 0.2421, 0.8466]}, {"w": "the", "b": [0.2477, 0.8252, 0.274, 0.8466]}, {"w": "plot", "b": [0.2795, 0.8252, 0.3127, 0.8466]}, {"w": "on", "b": [0.3182, 0.8252, 0.3403, 0.8466]}, {"w": "the", "b": [0.3458, 0.8252, 0.3721, 0.8466]}, {"w": "right", "b": [0.3777, 0.8252, 0.4178, 0.8466]}, {"w": "represents", "b": [0.4233, 0.8252, 0.5089, 0.8466]}, {"w": "the", "b": [0.5145, 0.8252, 0.5408, 0.8466]}, {"w": "decision", "b": [0.5463, 0.8252, 0.6158, 0.8466]}, {"w": "boundary", "b": [0.6214, 0.8252, 0.7031, 0.8466]}, {"w": "of", "b": [0.7086, 0.8252, 0.7254, 0.8466]}, {"w": "an", "b": [0.7309, 0.8252, 0.7515, 0.8466]}, {"w": "SVM", "b": [0.757, 0.8252, 0.8001, 0.8466]}, {"w": "classi‐", "b": [0.8056, 0.8252, 0.8571, 0.8466]}, {"w": "fier;", "b": [0.1429, 0.8442, 0.1764, 0.8657]}, {"w": "this", "b": [0.1836, 0.8442, 0.2144, 0.8657]}, {"w": "line", "b": [0.2216, 0.8442, 0.2527, 0.8657]}, {"w": "not", "b": [0.2599, 0.8442, 0.2883, 0.8657]}, {"w": "only", "b": [0.2955, 0.8442, 0.3323, 0.8657]}, {"w": "separates", "b": [0.3395, 0.8442, 0.4154, 0.8657]}, {"w": "the", "b": [0.4226, 0.8442, 0.449, 0.8657]}, {"w": "two", "b": [0.4562, 0.8442, 0.4874, 0.8657]}, {"w": "classes", "b": [0.4946, 0.8442, 0.5497, 0.8657]}, {"w": "but", "b": [0.5569, 0.8442, 0.5849, 0.8657]}, {"w": "also", "b": [0.5921, 0.8442, 0.6248, 0.8657]}, {"w": "stays", "b": [0.632, 0.8442, 0.672, 0.8657]}, {"w": "as", "b": [0.6792, 0.8442, 0.696, 0.8657]}, {"w": "far", "b": [0.7032, 0.8442, 0.7262, 0.8657]}, {"w": "away", "b": [0.7334, 0.8442, 0.7748, 0.8657]}, {"w": "from", "b": [0.782, 0.8442, 0.8236, 0.8657]}, {"w": "the", "b": [0.8308, 0.8442, 0.8571, 0.8657]}, {"w": "closest", "b": [0.1429, 0.8633, 0.1981, 0.8847]}, {"w": "training", "b": [0.2033, 0.8633, 0.2702, 0.8847]}, {"w": "instances", "b": [0.2754, 0.8633, 0.3523, 0.8847]}, {"w": "as", "b": [0.3575, 0.8633, 0.3743, 0.8847]}, {"w": "possible.", "b": [0.3795, 0.8633, 0.4514, 0.8847]}, {"w": "You", "b": [0.4566, 0.8633, 0.4889, 0.8847]}, {"w": "can", "b": [0.4941, 0.8633, 0.5235, 0.8847]}, {"w": "think", "b": [0.5287, 0.8633, 0.5735, 0.8847]}, {"w": "of", "b": [0.5787, 0.8633, 0.5955, 0.8847]}, {"w": "an", "b": [0.6007, 0.8633, 0.6213, 0.8847]}, {"w": "SVM", "b": [0.6265, 0.8633, 0.6696, 0.8847]}, {"w": "classifier", "b": [0.6748, 0.8633, 0.7472, 0.8847]}, {"w": "as", "b": [0.7524, 0.8633, 0.7692, 0.8847]}, {"w": "fitting", "b": [0.7744, 0.8633, 0.8256, 0.8847]}, {"w": "the", "b": [0.8308, 0.8633, 0.8572, 0.8847]}]}, {"id": "b_6", "type": "paragraph", "text": "155", "words": [{"w": "155", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 182, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "widest possible street (represented by the parallel dashed lines) between the classes. This is called large margin classification.", "words": [{"w": "widest", "b": [0.1429, 0.0791, 0.1966, 0.1005]}, {"w": "possible", "b": [0.2033, 0.0791, 0.2705, 0.1005]}, {"w": "street", "b": [0.2773, 0.0791, 0.323, 0.1005]}, {"w": "(represented", "b": [0.3298, 0.0791, 0.4348, 0.1005]}, {"w": "by", "b": [0.4416, 0.0791, 0.4617, 0.1005]}, {"w": "the", "b": [0.4685, 0.0791, 0.4949, 0.1005]}, {"w": "parallel", "b": [0.5016, 0.0791, 0.5632, 0.1005]}, {"w": "dashed", "b": [0.57, 0.0791, 0.6288, 0.1005]}, {"w": "lines)", "b": [0.6356, 0.0791, 0.6815, 0.1005]}, {"w": "between", "b": [0.6883, 0.0791, 0.7575, 0.1005]}, {"w": "the", "b": [0.7643, 0.0791, 0.7906, 0.1005]}, {"w": "classes.", "b": [0.7974, 0.0791, 0.8571, 0.1005]}, {"w": "This", "b": [0.1429, 0.0981, 0.1801, 0.1195]}, {"w": "is", "b": [0.1848, 0.0981, 0.198, 0.1195]}, {"w": "called", "b": [0.2027, 0.0981, 0.2511, 0.1195]}, {"w": "large", "b": [0.2558, 0.0979, 0.2954, 0.1195]}, {"w": "margin", "b": [0.3001, 0.0979, 0.3591, 0.1195]}, {"w": "classification.", "b": [0.3639, 0.0979, 0.4739, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "Figure 5-1. Large margin classification", "words": [{"w": "Figure", "b": [0.1429, 0.2545, 0.1943, 0.2761]}, {"w": "5-1.", "b": [0.1991, 0.2545, 0.2308, 0.2761]}, {"w": "Large", "b": [0.2356, 0.2545, 0.2811, 0.2761]}, {"w": "margin", "b": [0.2859, 0.2545, 0.3449, 0.2761]}, {"w": "classification", "b": [0.3497, 0.2545, 0.4549, 0.2761]}]}, {"id": "b_2", "type": "paragraph", "text": "Notice that adding more training instances “off the street” will not affect the decision boundary at all: it is fully determined (or “supported”) by the instances located on the edge of the street. These instances are called the support vectors (they are circled in Figure 5-1).", "words": [{"w": "Notice", "b": [0.1429, 0.2919, 0.198, 0.3133]}, {"w": "that", "b": [0.2035, 0.2919, 0.2361, 0.3133]}, {"w": "adding", "b": [0.2416, 0.2919, 0.2994, 0.3133]}, {"w": "more", "b": [0.3049, 0.2919, 0.3492, 0.3133]}, {"w": "training", "b": [0.3546, 0.2919, 0.4216, 0.3133]}, {"w": "instances", "b": [0.427, 0.2919, 0.5039, 0.3133]}, {"w": "“off", "b": [0.5093, 0.2919, 0.5389, 0.3133]}, {"w": "the", "b": [0.5443, 0.2919, 0.5707, 0.3133]}, {"w": "street”", "b": [0.5761, 0.2919, 0.6297, 0.3133]}, {"w": "will", "b": [0.6352, 0.2919, 0.6656, 0.3133]}, {"w": "not", "b": [0.671, 0.2919, 0.6994, 0.3133]}, {"w": "affect", "b": [0.7049, 0.2919, 0.7504, 0.3133]}, {"w": "the", "b": [0.7558, 0.2919, 0.7822, 0.3133]}, {"w": "decision", "b": [0.7876, 0.2919, 0.8571, 0.3133]}, {"w": "boundary", "b": [0.1429, 0.3109, 0.2246, 0.3323]}, {"w": "at", "b": [0.2296, 0.3109, 0.2447, 0.3323]}, {"w": "all:", "b": [0.2496, 0.3109, 0.2741, 0.3323]}, {"w": "it", "b": [0.2791, 0.3109, 0.291, 0.3323]}, {"w": "is", "b": [0.296, 0.3109, 0.3092, 0.3323]}, {"w": "fully", "b": [0.3142, 0.3109, 0.3515, 0.3323]}, {"w": "determined", "b": [0.3565, 0.3109, 0.4532, 0.3323]}, {"w": "(or", "b": [0.4582, 0.3109, 0.4837, 0.3323]}, {"w": "“supported”)", "b": [0.4887, 0.3109, 0.5959, 0.3323]}, {"w": "by", "b": [0.6009, 0.3109, 0.6211, 0.3323]}, {"w": "the", "b": [0.626, 0.3109, 0.6524, 0.3323]}, {"w": "instances", "b": [0.6574, 0.3109, 0.7342, 0.3323]}, {"w": "located", "b": [0.7392, 0.3109, 0.7988, 0.3323]}, {"w": "on", "b": [0.8038, 0.3109, 0.8258, 0.3323]}, {"w": "the", "b": [0.8308, 0.3109, 0.8572, 0.3323]}, {"w": "edge", "b": [0.1429, 0.33, 0.1813, 0.3514]}, {"w": "of", "b": [0.1882, 0.33, 0.205, 0.3514]}, {"w": "the", "b": [0.2118, 0.33, 0.2382, 0.3514]}, {"w": "street.", "b": [0.245, 0.33, 0.2956, 0.3514]}, {"w": "These", "b": [0.3025, 0.33, 0.3518, 0.3514]}, {"w": "instances", "b": [0.3587, 0.33, 0.4355, 0.3514]}, {"w": "are", "b": [0.4424, 0.33, 0.4681, 0.3514]}, {"w": "called", "b": [0.475, 0.33, 0.5233, 0.3514]}, {"w": "the", "b": [0.5302, 0.33, 0.5565, 0.3514]}, {"w": "support", "b": [0.5634, 0.3298, 0.6251, 0.3514]}, {"w": "vectors", "b": [0.632, 0.3298, 0.6878, 0.3514]}, {"w": "(they", "b": [0.6947, 0.33, 0.7378, 0.3514]}, {"w": "are", "b": [0.7446, 0.33, 0.7704, 0.3514]}, {"w": "circled", "b": [0.7772, 0.33, 0.8333, 0.3514]}, {"w": "in", "b": [0.8402, 0.33, 0.8571, 0.3514]}, {"w": "Figure", "b": [0.1429, 0.349, 0.1969, 0.3704]}, {"w": "5-1).", "b": [0.2016, 0.349, 0.241, 0.3704]}]}, {"id": "b_3", "type": "paragraph", "text": "SVMs are sensitive to the feature scales, as you can see in Figure 5-2: on the left plot, the vertical scale is much larger than the horizontal scale, so the widest possible street is close to horizontal. After feature scaling (e.g., using Scikit-Learn’s StandardScaler), the decision boundary looks much better (on the right plot).", "words": [{"w": "SVMs", "b": [0.2714, 0.391, 0.3178, 0.4105]}, {"w": "are", "b": [0.3296, 0.391, 0.3531, 0.4105]}, {"w": "sensitive", "b": [0.3649, 0.391, 0.4303, 0.4105]}, {"w": "to", "b": [0.442, 0.391, 0.4576, 0.4105]}, {"w": "the", "b": [0.4693, 0.391, 0.4934, 0.4105]}, {"w": "feature", "b": [0.5052, 0.391, 0.558, 0.4105]}, {"w": "scales,", "b": [0.5698, 0.391, 0.6174, 0.4105]}, {"w": "as", "b": [0.6292, 0.391, 0.6445, 0.4105]}, {"w": "you", "b": [0.6563, 0.391, 0.6849, 0.4105]}, {"w": "can", "b": [0.6966, 0.391, 0.7235, 0.4105]}, {"w": "see", "b": [0.7352, 0.391, 0.7584, 0.4105]}, {"w": "in", "b": [0.7702, 0.391, 0.7857, 0.4105]}, {"w": "Figure", "b": [0.2714, 0.4084, 0.3208, 0.428]}, {"w": "5-2:", "b": [0.3251, 0.4084, 0.3546, 0.428]}, {"w": "on", "b": [0.3589, 0.4084, 0.3791, 0.428]}, {"w": "the", "b": [0.3834, 0.4084, 0.4075, 0.428]}, {"w": "left", "b": [0.4119, 0.4084, 0.4363, 0.428]}, {"w": "plot,", "b": [0.4406, 0.4084, 0.4753, 0.428]}, {"w": "the", "b": [0.4797, 0.4084, 0.5038, 0.428]}, {"w": "vertical", "b": [0.5081, 0.4084, 0.5643, 0.428]}, {"w": "scale", "b": [0.5687, 0.4084, 0.605, 0.428]}, {"w": "is", "b": [0.6094, 0.4084, 0.6214, 0.428]}, {"w": "much", "b": [0.6258, 0.4084, 0.6694, 0.428]}, {"w": "larger", "b": [0.6738, 0.4084, 0.7181, 0.428]}, {"w": "than", "b": [0.7225, 0.4084, 0.7573, 0.428]}, {"w": "the", "b": [0.7616, 0.4084, 0.7857, 0.428]}, {"w": "horizontal", "b": [0.2714, 0.4258, 0.3502, 0.4454]}, {"w": "scale,", "b": [0.3555, 0.4258, 0.3962, 0.4454]}, {"w": "so", "b": [0.4015, 0.4258, 0.4182, 0.4454]}, {"w": "the", "b": [0.4236, 0.4258, 0.4476, 0.4454]}, {"w": "widest", "b": [0.453, 0.4258, 0.5021, 0.4454]}, {"w": "possible", "b": [0.5074, 0.4258, 0.5688, 0.4454]}, {"w": "street", "b": [0.5741, 0.4258, 0.616, 0.4454]}, {"w": "is", "b": [0.6213, 0.4258, 0.6334, 0.4454]}, {"w": "close", "b": [0.6387, 0.4258, 0.6764, 0.4454]}, {"w": "to", "b": [0.6817, 0.4258, 0.6972, 0.4454]}, {"w": "horizontal.", "b": [0.7025, 0.4258, 0.7857, 0.4454]}, {"w": "After", "b": [0.2714, 0.444, 0.3112, 0.4636]}, {"w": "feature", "b": [0.3186, 0.444, 0.3714, 0.4636]}, {"w": "scaling", "b": [0.3788, 0.444, 0.4315, 0.4636]}, {"w": "(e.g.,", "b": [0.4389, 0.444, 0.4755, 0.4636]}, {"w": "using", "b": [0.4829, 0.444, 0.5245, 0.4636]}, {"w": "Scikit-Learn’s", "b": [0.5319, 0.444, 0.6333, 0.4636]}, {"w": "StandardScaler),", "b": [0.6407, 0.444, 0.7783, 0.4636]}, {"w": "the", "b": [0.2714, 0.4614, 0.2955, 0.481]}, {"w": "decision", "b": [0.2998, 0.4614, 0.3633, 0.481]}, {"w": "boundary", "b": [0.3677, 0.4614, 0.4424, 0.481]}, {"w": "looks", "b": [0.4467, 0.4614, 0.4874, 0.481]}, {"w": "much", "b": [0.4917, 0.4614, 0.5353, 0.481]}, {"w": "better", "b": [0.5396, 0.4614, 0.5842, 0.481]}, {"w": "(on", "b": [0.5885, 0.4614, 0.6152, 0.481]}, {"w": "the", "b": [0.6195, 0.4614, 0.6436, 0.481]}, {"w": "right", "b": [0.6479, 0.4614, 0.6846, 0.481]}, {"w": "plot).", "b": [0.689, 0.4614, 0.7302, 0.481]}]}, {"id": "b_4", "type": "equation", "text": "Figure 5-2. Sensitivity to feature scales", "words": [{"w": "Figure", "b": [0.1429, 0.6522, 0.1943, 0.6738]}, {"w": "5-2.", "b": [0.1991, 0.6522, 0.2308, 0.6738]}, {"w": "Sensitivity", "b": [0.2356, 0.6522, 0.3192, 0.6738]}, {"w": "to", "b": [0.324, 0.6522, 0.34, 0.6738]}, {"w": "feature", "b": [0.3448, 0.6522, 0.4008, 0.6738]}, {"w": "scales", "b": [0.4055, 0.6522, 0.4507, 0.6738]}]}, {"id": "b_5", "type": "paragraph", "text": "Soft Margin Classification", "words": [{"w": "Soft", "b": [0.1429, 0.6868, 0.1846, 0.7154]}, {"w": "Margin", "b": [0.1896, 0.6868, 0.2632, 0.7154]}, {"w": "Classification", "b": [0.2682, 0.6868, 0.4031, 0.7154]}]}, {"id": "b_6", "type": "paragraph", "text": "If we strictly impose that all instances be off the street and on the right side, this is called hard margin classification. There are two main issues with hard margin classifi‐ cation. First, it only works if the data is linearly separable, and second it is quite sensi‐ tive to outliers. Figure 5-3 shows the iris dataset with just one additional outlier: on the left, it is impossible to find a hard margin, and on the right the decision boundary ends up very different from the one we saw in Figure 5-1 without the outlier, and it will probably not generalize as well.", "words": [{"w": "If", "b": [0.1429, 0.7213, 0.1561, 0.7427]}, {"w": "we", "b": [0.1629, 0.7213, 0.186, 0.7427]}, {"w": "strictly", "b": [0.1928, 0.7213, 0.2501, 0.7427]}, {"w": "impose", "b": [0.2568, 0.7213, 0.3171, 0.7427]}, {"w": "that", "b": [0.3239, 0.7213, 0.3565, 0.7427]}, {"w": "all", "b": [0.3632, 0.7213, 0.3829, 0.7427]}, {"w": "instances", "b": [0.3897, 0.7213, 0.4665, 0.7427]}, {"w": "be", "b": [0.4733, 0.7213, 0.4927, 0.7427]}, {"w": "off", "b": [0.4994, 0.7213, 0.5224, 0.7427]}, {"w": "the", "b": [0.5292, 0.7213, 0.5555, 0.7427]}, {"w": "street", "b": [0.5622, 0.7213, 0.608, 0.7427]}, {"w": "and", "b": [0.6148, 0.7213, 0.6463, 0.7427]}, {"w": "on", "b": [0.6531, 0.7213, 0.6751, 0.7427]}, {"w": "the", "b": [0.6819, 0.7213, 0.7082, 0.7427]}, {"w": "right", "b": [0.715, 0.7213, 0.7551, 0.7427]}, {"w": "side,", "b": [0.7619, 0.7213, 0.7997, 0.7427]}, {"w": "this", "b": [0.8065, 0.7213, 0.8372, 0.7427]}, {"w": "is", "b": [0.8439, 0.7213, 0.8571, 0.7427]}, {"w": "called", "b": [0.1429, 0.7404, 0.1912, 0.7618]}, {"w": "hard", "b": [0.1962, 0.7402, 0.2344, 0.7618]}, {"w": "margin", "b": [0.2392, 0.7402, 0.2982, 0.7618]}, {"w": "classification.", "b": [0.3036, 0.7402, 0.4136, 0.7618]}, {"w": "There", "b": [0.4186, 0.7404, 0.468, 0.7618]}, {"w": "are", "b": [0.473, 0.7404, 0.4988, 0.7618]}, {"w": "two", "b": [0.5038, 0.7404, 0.5351, 0.7618]}, {"w": "main", "b": [0.5401, 0.7404, 0.5833, 0.7618]}, {"w": "issues", "b": [0.5883, 0.7404, 0.6367, 0.7618]}, {"w": "with", "b": [0.6418, 0.7404, 0.6791, 0.7618]}, {"w": "hard", "b": [0.6841, 0.7404, 0.7231, 0.7618]}, {"w": "margin", "b": [0.7282, 0.7404, 0.7888, 0.7618]}, {"w": "classifi‐", "b": [0.7939, 0.7404, 0.8571, 0.7618]}, {"w": "cation.", "b": [0.1428, 0.7594, 0.1991, 0.7808]}, {"w": "First,", "b": [0.2039, 0.7594, 0.247, 0.7808]}, {"w": "it", "b": [0.2519, 0.7594, 0.2638, 0.7808]}, {"w": "only", "b": [0.2686, 0.7594, 0.3055, 0.7808]}, {"w": "works", "b": [0.3103, 0.7594, 0.3609, 0.7808]}, {"w": "if", "b": [0.3657, 0.7594, 0.3775, 0.7808]}, {"w": "the", "b": [0.3823, 0.7594, 0.4086, 0.7808]}, {"w": "data", "b": [0.4134, 0.7594, 0.4487, 0.7808]}, {"w": "is", "b": [0.4535, 0.7594, 0.4668, 0.7808]}, {"w": "linearly", "b": [0.4716, 0.7594, 0.5344, 0.7808]}, {"w": "separable,", "b": [0.5392, 0.7594, 0.6221, 0.7808]}, {"w": "and", "b": [0.6269, 0.7594, 0.6585, 0.7808]}, {"w": "second", "b": [0.6633, 0.7594, 0.7216, 0.7808]}, {"w": "it", "b": [0.7265, 0.7594, 0.7384, 0.7808]}, {"w": "is", "b": [0.7432, 0.7594, 0.7564, 0.7808]}, {"w": "quite", "b": [0.7613, 0.7594, 0.8038, 0.7808]}, {"w": "sensi‐", "b": [0.8086, 0.7594, 0.8571, 0.7808]}, {"w": "tive", "b": [0.1429, 0.7785, 0.1733, 0.7999]}, {"w": "to", "b": [0.1796, 0.7785, 0.1966, 0.7999]}, {"w": "outliers.", "b": [0.203, 0.7785, 0.2708, 0.7999]}, {"w": "Figure", "b": [0.2772, 0.7785, 0.3312, 0.7999]}, {"w": "5-3", "b": [0.3375, 0.7785, 0.365, 0.7999]}, {"w": "shows", "b": [0.3713, 0.7785, 0.4226, 0.7999]}, {"w": "the", "b": [0.429, 0.7785, 0.4553, 0.7999]}, {"w": "iris", "b": [0.4616, 0.7785, 0.4882, 0.7999]}, {"w": "dataset", "b": [0.4945, 0.7785, 0.5526, 0.7999]}, {"w": "with", "b": [0.559, 0.7785, 0.5963, 0.7999]}, {"w": "just", "b": [0.6026, 0.7785, 0.633, 0.7999]}, {"w": "one", "b": [0.6394, 0.7785, 0.6703, 0.7999]}, {"w": "additional", "b": [0.6766, 0.7785, 0.7617, 0.7999]}, {"w": "outlier:", "b": [0.7681, 0.7785, 0.8288, 0.7999]}, {"w": "on", "b": [0.8351, 0.7785, 0.8571, 0.7999]}, {"w": "the", "b": [0.1429, 0.7975, 0.1692, 0.8189]}, {"w": "left,", "b": [0.1742, 0.7975, 0.2056, 0.8189]}, {"w": "it", "b": [0.2106, 0.7975, 0.2225, 0.8189]}, {"w": "is", "b": [0.2275, 0.7975, 0.2407, 0.8189]}, {"w": "impossible", "b": [0.2457, 0.7975, 0.3351, 0.8189]}, {"w": "to", "b": [0.34, 0.7975, 0.357, 0.8189]}, {"w": "find", "b": [0.362, 0.7975, 0.3962, 0.8189]}, {"w": "a", "b": [0.4011, 0.7975, 0.4103, 0.8189]}, {"w": "hard", "b": [0.4153, 0.7975, 0.4543, 0.8189]}, {"w": "margin,", "b": [0.4593, 0.7975, 0.5247, 0.8189]}, {"w": "and", "b": [0.5297, 0.7975, 0.5612, 0.8189]}, {"w": "on", "b": [0.5662, 0.7975, 0.5882, 0.8189]}, {"w": "the", "b": [0.5932, 0.7975, 0.6195, 0.8189]}, {"w": "right", "b": [0.6245, 0.7975, 0.6646, 0.8189]}, {"w": "the", "b": [0.6696, 0.7975, 0.696, 0.8189]}, {"w": "decision", "b": [0.701, 0.7975, 0.7705, 0.8189]}, {"w": "boundary", "b": [0.7754, 0.7975, 0.8571, 0.8189]}, {"w": "ends", "b": [0.1429, 0.8166, 0.1817, 0.838]}, {"w": "up", "b": [0.188, 0.8166, 0.21, 0.838]}, {"w": "very", "b": [0.2163, 0.8166, 0.2526, 0.838]}, {"w": "different", "b": [0.2589, 0.8166, 0.3306, 0.838]}, {"w": "from", "b": [0.3369, 0.8166, 0.3785, 0.838]}, {"w": "the", "b": [0.3847, 0.8166, 0.4111, 0.838]}, {"w": "one", "b": [0.4173, 0.8166, 0.4482, 0.838]}, {"w": "we", "b": [0.4545, 0.8166, 0.4776, 0.838]}, {"w": "saw", "b": [0.4838, 0.8166, 0.5145, 0.838]}, {"w": "in", "b": [0.5208, 0.8166, 0.5378, 0.838]}, {"w": "Figure", "b": [0.544, 0.8166, 0.598, 0.838]}, {"w": "5-1", "b": [0.6043, 0.8166, 0.6317, 0.838]}, {"w": "without", "b": [0.638, 0.8166, 0.7034, 0.838]}, {"w": "the", "b": [0.7096, 0.8166, 0.736, 0.838]}, {"w": "outlier,", "b": [0.7422, 0.8166, 0.8011, 0.838]}, {"w": "and", "b": [0.8074, 0.8166, 0.8389, 0.838]}, {"w": "it", "b": [0.8452, 0.8166, 0.8571, 0.838]}, {"w": "will", "b": [0.1429, 0.8356, 0.1733, 0.857]}, {"w": "probably", "b": [0.178, 0.8356, 0.2524, 0.857]}, {"w": "not", "b": [0.2571, 0.8356, 0.2855, 0.857]}, {"w": "generalize", "b": [0.2902, 0.8356, 0.3744, 0.857]}, {"w": "as", "b": [0.3792, 0.8356, 0.3959, 0.857]}, {"w": "well.", "b": [0.4007, 0.8356, 0.4391, 0.857]}]}, {"id": "b_7", "type": "paragraph", "text": "156 | Chapter 5: Support Vector Machines", "words": [{"w": "156", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "5:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Support", "b": [0.2673, 0.9225, 0.3142, 0.9388]}, {"w": "Vector", "b": [0.317, 0.9225, 0.3547, 0.9388]}, {"w": "Machines", "b": [0.3576, 0.9225, 0.413, 0.9388]}]}]}, {"page": 183, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 5-3. Hard margin sensitivity to outliers", "words": [{"w": "Figure", "b": [0.1429, 0.2073, 0.1943, 0.2289]}, {"w": "5-3.", "b": [0.1991, 0.2073, 0.2308, 0.2289]}, {"w": "Hard", "b": [0.2356, 0.2073, 0.2781, 0.2289]}, {"w": "margin", "b": [0.2828, 0.2073, 0.3418, 0.2289]}, {"w": "sensitivity", "b": [0.3466, 0.2073, 0.4275, 0.2289]}, {"w": "to", "b": [0.4322, 0.2073, 0.4482, 0.2289]}, {"w": "outliers", "b": [0.453, 0.2073, 0.513, 0.2289]}]}, {"id": "b_1", "type": "paragraph", "text": "To avoid these issues it is preferable to use a more flexible model. The objective is to find a good balance between keeping the street as large as possible and limiting the margin violations (i.e., instances that end up in the middle of the street or even on the wrong side). This is called soft margin classification.", "words": [{"w": "To", "b": [0.1429, 0.2447, 0.1643, 0.2661]}, {"w": "avoid", "b": [0.1701, 0.2447, 0.2157, 0.2661]}, {"w": "these", "b": [0.2216, 0.2447, 0.2644, 0.2661]}, {"w": "issues", "b": [0.2702, 0.2447, 0.3186, 0.2661]}, {"w": "it", "b": [0.3245, 0.2447, 0.3364, 0.2661]}, {"w": "is", "b": [0.3422, 0.2447, 0.3554, 0.2661]}, {"w": "preferable", "b": [0.3613, 0.2447, 0.4454, 0.2661]}, {"w": "to", "b": [0.4512, 0.2447, 0.4682, 0.2661]}, {"w": "use", "b": [0.474, 0.2447, 0.5015, 0.2661]}, {"w": "a", "b": [0.5073, 0.2447, 0.5165, 0.2661]}, {"w": "more", "b": [0.5223, 0.2447, 0.5666, 0.2661]}, {"w": "flexible", "b": [0.5724, 0.2447, 0.6328, 0.2661]}, {"w": "model.", "b": [0.6386, 0.2447, 0.6962, 0.2661]}, {"w": "The", "b": [0.702, 0.2447, 0.7348, 0.2661]}, {"w": "objective", "b": [0.7407, 0.2447, 0.8153, 0.2661]}, {"w": "is", "b": [0.8211, 0.2447, 0.8343, 0.2661]}, {"w": "to", "b": [0.8402, 0.2447, 0.8571, 0.2661]}, {"w": "find", "b": [0.1429, 0.2638, 0.177, 0.2852]}, {"w": "a", "b": [0.1836, 0.2638, 0.1928, 0.2852]}, {"w": "good", "b": [0.1994, 0.2638, 0.2414, 0.2852]}, {"w": "balance", "b": [0.248, 0.2638, 0.3113, 0.2852]}, {"w": "between", "b": [0.3179, 0.2638, 0.3871, 0.2852]}, {"w": "keeping", "b": [0.3937, 0.2638, 0.4594, 0.2852]}, {"w": "the", "b": [0.466, 0.2638, 0.4923, 0.2852]}, {"w": "street", "b": [0.499, 0.2638, 0.5448, 0.2852]}, {"w": "as", "b": [0.5514, 0.2638, 0.5682, 0.2852]}, {"w": "large", "b": [0.5748, 0.2638, 0.6156, 0.2852]}, {"w": "as", "b": [0.6222, 0.2638, 0.639, 0.2852]}, {"w": "possible", "b": [0.6456, 0.2638, 0.7128, 0.2852]}, {"w": "and", "b": [0.7194, 0.2638, 0.751, 0.2852]}, {"w": "limiting", "b": [0.7576, 0.2638, 0.8242, 0.2852]}, {"w": "the", "b": [0.8308, 0.2638, 0.8571, 0.2852]}, {"w": "margin", "b": [0.1429, 0.2826, 0.2018, 0.3042]}, {"w": "violations", "b": [0.2066, 0.2826, 0.2857, 0.3042]}, {"w": "(i.e.,", "b": [0.2911, 0.2828, 0.327, 0.3042]}, {"w": "instances", "b": [0.3321, 0.2828, 0.4089, 0.3042]}, {"w": "that", "b": [0.414, 0.2828, 0.4466, 0.3042]}, {"w": "end", "b": [0.4517, 0.2828, 0.4829, 0.3042]}, {"w": "up", "b": [0.488, 0.2828, 0.51, 0.3042]}, {"w": "in", "b": [0.515, 0.2828, 0.532, 0.3042]}, {"w": "the", "b": [0.5371, 0.2828, 0.5634, 0.3042]}, {"w": "middle", "b": [0.5685, 0.2828, 0.6273, 0.3042]}, {"w": "of", "b": [0.6323, 0.2828, 0.6491, 0.3042]}, {"w": "the", "b": [0.6542, 0.2828, 0.6805, 0.3042]}, {"w": "street", "b": [0.6856, 0.2828, 0.7314, 0.3042]}, {"w": "or", "b": [0.7365, 0.2828, 0.7548, 0.3042]}, {"w": "even", "b": [0.7599, 0.2828, 0.7986, 0.3042]}, {"w": "on", "b": [0.8037, 0.2828, 0.8257, 0.3042]}, {"w": "the", "b": [0.8308, 0.2828, 0.8571, 0.3042]}, {"w": "wrong", "b": [0.1429, 0.3019, 0.1966, 0.3233]}, {"w": "side).", "b": [0.2014, 0.3019, 0.2464, 0.3233]}, {"w": "This", "b": [0.2511, 0.3019, 0.2883, 0.3233]}, {"w": "is", "b": [0.2931, 0.3019, 0.3063, 0.3233]}, {"w": "called", "b": [0.311, 0.3019, 0.3594, 0.3233]}, {"w": "soft", "b": [0.3641, 0.3016, 0.3927, 0.3233]}, {"w": "margin", "b": [0.3975, 0.3016, 0.4565, 0.3233]}, {"w": "classification.", "b": [0.4613, 0.3016, 0.5713, 0.3233]}]}, {"id": "b_2", "type": "paragraph", "text": "In Scikit-Learn’s SVM classes, you can control this balance using the C hyperparame‐ ter: a smaller C value leads to a wider street but more margin violations. Figure 5-4 shows the decision boundaries and margins of two soft margin SVM classifiers on a nonlinearly separable dataset. On the left, using a low C value the margin is quite large, but many instances end up on the street. On the right, using a high C value the classifier makes fewer margin violations but ends up with a smaller margin. However, it seems likely that the first classifier will generalize better: in fact even on this train‐ ing set it makes fewer prediction errors, since most of the margin violations are actually on the correct side of the decision boundary.", "words": [{"w": "In", "b": [0.1429, 0.3309, 0.1614, 0.3523]}, {"w": "Scikit-Learn’s", "b": [0.167, 0.3309, 0.2779, 0.3523]}, {"w": "SVM", "b": [0.2835, 0.3309, 0.3266, 0.3523]}, {"w": "classes,", "b": [0.3322, 0.3309, 0.392, 0.3523]}, {"w": "you", "b": [0.3976, 0.3309, 0.4288, 0.3523]}, {"w": "can", "b": [0.4345, 0.3309, 0.4638, 0.3523]}, {"w": "control", "b": [0.4694, 0.3309, 0.5299, 0.3523]}, {"w": "this", "b": [0.5355, 0.3309, 0.5662, 0.3523]}, {"w": "balance", "b": [0.5718, 0.3309, 0.635, 0.3523]}, {"w": "using", "b": [0.6406, 0.3309, 0.6861, 0.3523]}, {"w": "the", "b": [0.6917, 0.3309, 0.718, 0.3523]}, {"w": "C", "b": [0.7237, 0.3341, 0.7335, 0.3491]}, {"w": "hyperparame‐", "b": [0.7392, 0.3309, 0.8571, 0.3523]}, {"w": "ter:", "b": [0.1429, 0.3508, 0.171, 0.3722]}, {"w": "a", "b": [0.1777, 0.3508, 0.1869, 0.3722]}, {"w": "smaller", "b": [0.1936, 0.3508, 0.2545, 0.3722]}, {"w": "C", "b": [0.2612, 0.354, 0.2711, 0.3691]}, {"w": "value", "b": [0.2778, 0.3508, 0.3218, 0.3722]}, {"w": "leads", "b": [0.3285, 0.3508, 0.3704, 0.3722]}, {"w": "to", "b": [0.3771, 0.3508, 0.394, 0.3722]}, {"w": "a", "b": [0.4007, 0.3508, 0.4099, 0.3722]}, {"w": "wider", "b": [0.4166, 0.3508, 0.464, 0.3722]}, {"w": "street", "b": [0.4707, 0.3508, 0.5165, 0.3722]}, {"w": "but", "b": [0.5231, 0.3508, 0.5511, 0.3722]}, {"w": "more", "b": [0.5578, 0.3508, 0.6021, 0.3722]}, {"w": "margin", "b": [0.6088, 0.3508, 0.6694, 0.3722]}, {"w": "violations.", "b": [0.6761, 0.3508, 0.7624, 0.3722]}, {"w": "Figure", "b": [0.769, 0.3508, 0.823, 0.3722]}, {"w": "5-4", "b": [0.8297, 0.3508, 0.8571, 0.3722]}, {"w": "shows", "b": [0.1429, 0.3699, 0.1942, 0.3913]}, {"w": "the", "b": [0.2003, 0.3699, 0.2266, 0.3913]}, {"w": "decision", "b": [0.2328, 0.3699, 0.3023, 0.3913]}, {"w": "boundaries", "b": [0.3084, 0.3699, 0.402, 0.3913]}, {"w": "and", "b": [0.4082, 0.3699, 0.4397, 0.3913]}, {"w": "margins", "b": [0.4459, 0.3699, 0.5142, 0.3913]}, {"w": "of", "b": [0.5203, 0.3699, 0.5371, 0.3913]}, {"w": "two", "b": [0.5433, 0.3699, 0.5745, 0.3913]}, {"w": "soft", "b": [0.5806, 0.3699, 0.6114, 0.3913]}, {"w": "margin", "b": [0.6176, 0.3699, 0.6782, 0.3913]}, {"w": "SVM", "b": [0.6844, 0.3699, 0.7275, 0.3913]}, {"w": "classifiers", "b": [0.7336, 0.3699, 0.8137, 0.3913]}, {"w": "on", "b": [0.8198, 0.3699, 0.8419, 0.3913]}, {"w": "a", "b": [0.848, 0.3699, 0.8571, 0.3913]}, {"w": "nonlinearly", "b": [0.1429, 0.3898, 0.2391, 0.4112]}, {"w": "separable", "b": [0.247, 0.3898, 0.3252, 0.4112]}, {"w": "dataset.", "b": [0.3331, 0.3898, 0.396, 0.4112]}, {"w": "On", "b": [0.4039, 0.3898, 0.4308, 0.4112]}, {"w": "the", "b": [0.4388, 0.3898, 0.4651, 0.4112]}, {"w": "left,", "b": [0.473, 0.3898, 0.5044, 0.4112]}, {"w": "using", "b": [0.5124, 0.3898, 0.5578, 0.4112]}, {"w": "a", "b": [0.5657, 0.3898, 0.5749, 0.4112]}, {"w": "low", "b": [0.5828, 0.3898, 0.613, 0.4112]}, {"w": "C", "b": [0.6209, 0.393, 0.6308, 0.4081]}, {"w": "value", "b": [0.6387, 0.3898, 0.6827, 0.4112]}, {"w": "the", "b": [0.6906, 0.3898, 0.717, 0.4112]}, {"w": "margin", "b": [0.7249, 0.3898, 0.7856, 0.4112]}, {"w": "is", "b": [0.7935, 0.3898, 0.8067, 0.4112]}, {"w": "quite", "b": [0.8147, 0.3898, 0.8572, 0.4112]}, {"w": "large,", "b": [0.1429, 0.4098, 0.1884, 0.4312]}, {"w": "but", "b": [0.1939, 0.4098, 0.2219, 0.4312]}, {"w": "many", "b": [0.2275, 0.4098, 0.2742, 0.4312]}, {"w": "instances", "b": [0.2797, 0.4098, 0.3566, 0.4312]}, {"w": "end", "b": [0.3621, 0.4098, 0.3934, 0.4312]}, {"w": "up", "b": [0.3989, 0.4098, 0.4209, 0.4312]}, {"w": "on", "b": [0.4265, 0.4098, 0.4485, 0.4312]}, {"w": "the", "b": [0.4541, 0.4098, 0.4804, 0.4312]}, {"w": "street.", "b": [0.486, 0.4098, 0.5365, 0.4312]}, {"w": "On", "b": [0.5421, 0.4098, 0.569, 0.4312]}, {"w": "the", "b": [0.5746, 0.4098, 0.6009, 0.4312]}, {"w": "right,", "b": [0.6065, 0.4098, 0.6514, 0.4312]}, {"w": "using", "b": [0.657, 0.4098, 0.7024, 0.4312]}, {"w": "a", "b": [0.708, 0.4098, 0.7171, 0.4312]}, {"w": "high", "b": [0.7227, 0.4098, 0.7602, 0.4312]}, {"w": "C", "b": [0.7658, 0.4129, 0.7757, 0.428]}, {"w": "value", "b": [0.7813, 0.4098, 0.8253, 0.4312]}, {"w": "the", "b": [0.8308, 0.4098, 0.8571, 0.4312]}, {"w": "classifier", "b": [0.1429, 0.4288, 0.2153, 0.4502]}, {"w": "makes", "b": [0.2203, 0.4288, 0.2733, 0.4502]}, {"w": "fewer", "b": [0.2784, 0.4288, 0.3242, 0.4502]}, {"w": "margin", "b": [0.3293, 0.4288, 0.3899, 0.4502]}, {"w": "violations", "b": [0.3949, 0.4288, 0.4764, 0.4502]}, {"w": "but", "b": [0.4814, 0.4288, 0.5094, 0.4502]}, {"w": "ends", "b": [0.5144, 0.4288, 0.5533, 0.4502]}, {"w": "up", "b": [0.5584, 0.4288, 0.5803, 0.4502]}, {"w": "with", "b": [0.5854, 0.4288, 0.6227, 0.4502]}, {"w": "a", "b": [0.6277, 0.4288, 0.6368, 0.4502]}, {"w": "smaller", "b": [0.6419, 0.4288, 0.7028, 0.4502]}, {"w": "margin.", "b": [0.7079, 0.4288, 0.7733, 0.4502]}, {"w": "However,", "b": [0.7783, 0.4288, 0.8571, 0.4502]}, {"w": "it", "b": [0.1428, 0.4478, 0.1548, 0.4693]}, {"w": "seems", "b": [0.1606, 0.4478, 0.2107, 0.4693]}, {"w": "likely", "b": [0.2165, 0.4478, 0.2614, 0.4693]}, {"w": "that", "b": [0.2672, 0.4478, 0.2998, 0.4693]}, {"w": "the", "b": [0.3056, 0.4478, 0.332, 0.4693]}, {"w": "first", "b": [0.3378, 0.4478, 0.3713, 0.4693]}, {"w": "classifier", "b": [0.3771, 0.4478, 0.4495, 0.4693]}, {"w": "will", "b": [0.4554, 0.4478, 0.4858, 0.4693]}, {"w": "generalize", "b": [0.4916, 0.4478, 0.5758, 0.4693]}, {"w": "better:", "b": [0.5816, 0.4478, 0.6356, 0.4693]}, {"w": "in", "b": [0.6414, 0.4478, 0.6584, 0.4693]}, {"w": "fact", "b": [0.6642, 0.4478, 0.6947, 0.4693]}, {"w": "even", "b": [0.7005, 0.4478, 0.7393, 0.4693]}, {"w": "on", "b": [0.7451, 0.4478, 0.7671, 0.4693]}, {"w": "this", "b": [0.773, 0.4478, 0.8037, 0.4693]}, {"w": "train‐", "b": [0.8095, 0.4478, 0.8571, 0.4693]}, {"w": "ing", "b": [0.1429, 0.4669, 0.1696, 0.4883]}, {"w": "set", "b": [0.1786, 0.4669, 0.2014, 0.4883]}, {"w": "it", "b": [0.2104, 0.4669, 0.2224, 0.4883]}, {"w": "makes", "b": [0.2314, 0.4669, 0.2844, 0.4883]}, {"w": "fewer", "b": [0.2934, 0.4669, 0.3393, 0.4883]}, {"w": "prediction", "b": [0.3483, 0.4669, 0.4351, 0.4883]}, {"w": "errors,", "b": [0.4441, 0.4669, 0.4992, 0.4883]}, {"w": "since", "b": [0.5082, 0.4669, 0.5505, 0.4883]}, {"w": "most", "b": [0.5595, 0.4669, 0.6012, 0.4883]}, {"w": "of", "b": [0.6102, 0.4669, 0.627, 0.4883]}, {"w": "the", "b": [0.636, 0.4669, 0.6623, 0.4883]}, {"w": "margin", "b": [0.6713, 0.4669, 0.7319, 0.4883]}, {"w": "violations", "b": [0.7409, 0.4669, 0.8224, 0.4883]}, {"w": "are", "b": [0.8314, 0.4669, 0.8571, 0.4883]}, {"w": "actually", "b": [0.1429, 0.4859, 0.2075, 0.5074]}, {"w": "on", "b": [0.2122, 0.4859, 0.2342, 0.5074]}, {"w": "the", "b": [0.239, 0.4859, 0.2653, 0.5074]}, {"w": "correct", "b": [0.27, 0.4859, 0.3289, 0.5074]}, {"w": "side", "b": [0.3337, 0.4859, 0.3668, 0.5074]}, {"w": "of", "b": [0.3715, 0.4859, 0.3883, 0.5074]}, {"w": "the", "b": [0.393, 0.4859, 0.4193, 0.5074]}, {"w": "decision", "b": [0.4241, 0.4859, 0.4936, 0.5074]}, {"w": "boundary.", "b": [0.4983, 0.4859, 0.5832, 0.5074]}]}, {"id": "b_3", "type": "equation", "text": "Figure 5-4. Large margin (left) versus fewer margin violations (right)", "words": [{"w": "Figure", "b": [0.1429, 0.6644, 0.1943, 0.686]}, {"w": "5-4.", "b": [0.1991, 0.6644, 0.2308, 0.686]}, {"w": "Large", "b": [0.2356, 0.6644, 0.2811, 0.686]}, {"w": "margin", "b": [0.2859, 0.6644, 0.3449, 0.686]}, {"w": "(left)", "b": [0.3497, 0.6644, 0.389, 0.686]}, {"w": "versus", "b": [0.3938, 0.6644, 0.4439, 0.686]}, {"w": "fewer", "b": [0.4486, 0.6644, 0.4923, 0.686]}, {"w": "margin", "b": [0.4971, 0.6644, 0.5561, 0.686]}, {"w": "violations", "b": [0.5609, 0.6644, 0.64, 0.686]}, {"w": "(right)", "b": [0.6448, 0.6644, 0.6974, 0.686]}]}, {"id": "b_4", "type": "paragraph", "text": "If your SVM model is overfitting, you can try regularizing it by reducing C.", "words": [{"w": "If", "b": [0.2714, 0.7065, 0.2835, 0.7261]}, {"w": "your", "b": [0.2911, 0.7065, 0.3267, 0.7261]}, {"w": "SVM", "b": [0.3343, 0.7065, 0.3737, 0.7261]}, {"w": "model", "b": [0.3812, 0.7065, 0.4295, 0.7261]}, {"w": "is", "b": [0.4371, 0.7065, 0.4491, 0.7261]}, {"w": "overfitting,", "b": [0.4567, 0.7065, 0.5415, 0.7261]}, {"w": "you", "b": [0.5491, 0.7065, 0.5777, 0.7261]}, {"w": "can", "b": [0.5852, 0.7065, 0.612, 0.7261]}, {"w": "try", "b": [0.6196, 0.7065, 0.6418, 0.7261]}, {"w": "regularizing", "b": [0.6493, 0.7065, 0.7413, 0.7261]}, {"w": "it", "b": [0.7488, 0.7065, 0.7598, 0.7261]}, {"w": "by", "b": [0.7673, 0.7065, 0.7857, 0.7261]}, {"w": "reducing", "b": [0.2714, 0.7248, 0.3392, 0.7443]}, {"w": "C.", "b": [0.3436, 0.7248, 0.357, 0.7443]}]}, {"id": "b_5", "type": "paragraph", "text": "The following Scikit-Learn code loads the iris dataset, scales the features, and then trains a linear SVM model (using the LinearSVC class with C = 1 and the hinge loss function, described shortly) to detect Iris-Virginica flowers. The resulting model is represented on the left of Figure 5-4.", "words": [{"w": "The", "b": [0.1429, 0.8052, 0.1757, 0.8266]}, {"w": "following", "b": [0.183, 0.8052, 0.262, 0.8266]}, {"w": "Scikit-Learn", "b": [0.2694, 0.8052, 0.3717, 0.8266]}, {"w": "code", "b": [0.379, 0.8052, 0.4183, 0.8266]}, {"w": "loads", "b": [0.4257, 0.8052, 0.4694, 0.8266]}, {"w": "the", "b": [0.4767, 0.8052, 0.5031, 0.8266]}, {"w": "iris", "b": [0.5104, 0.8052, 0.537, 0.8266]}, {"w": "dataset,", "b": [0.5443, 0.8052, 0.6072, 0.8266]}, {"w": "scales", "b": [0.6145, 0.8052, 0.6619, 0.8266]}, {"w": "the", "b": [0.6693, 0.8052, 0.6956, 0.8266]}, {"w": "features,", "b": [0.703, 0.8052, 0.7731, 0.8266]}, {"w": "and", "b": [0.7805, 0.8052, 0.812, 0.8266]}, {"w": "then", "b": [0.8194, 0.8052, 0.8571, 0.8266]}, {"w": "trains", "b": [0.1428, 0.8251, 0.1907, 0.8465]}, {"w": "a", "b": [0.1972, 0.8251, 0.2064, 0.8465]}, {"w": "linear", "b": [0.2129, 0.8251, 0.2608, 0.8465]}, {"w": "SVM", "b": [0.2673, 0.8251, 0.3104, 0.8465]}, {"w": "model", "b": [0.3169, 0.8251, 0.3697, 0.8465]}, {"w": "(using", "b": [0.3762, 0.8251, 0.4289, 0.8465]}, {"w": "the", "b": [0.4354, 0.8251, 0.4617, 0.8465]}, {"w": "LinearSVC", "b": [0.4682, 0.8283, 0.5573, 0.8434]}, {"w": "class", "b": [0.5638, 0.8251, 0.6023, 0.8465]}, {"w": "with", "b": [0.6088, 0.8251, 0.6462, 0.8465]}, {"w": "C", "b": [0.6527, 0.8249, 0.6659, 0.8465]}, {"w": "=", "b": [0.6724, 0.8251, 0.6845, 0.8465]}, {"w": "1", "b": [0.691, 0.8251, 0.701, 0.8465]}, {"w": "and", "b": [0.7075, 0.8251, 0.739, 0.8465]}, {"w": "the", "b": [0.7455, 0.8251, 0.7719, 0.8465]}, {"w": "hinge", "b": [0.7784, 0.8249, 0.822, 0.8465]}, {"w": "loss", "b": [0.8285, 0.8249, 0.8571, 0.8465]}, {"w": "function,", "b": [0.1429, 0.8442, 0.219, 0.8656]}, {"w": "described", "b": [0.2265, 0.8442, 0.3065, 0.8656]}, {"w": "shortly)", "b": [0.314, 0.8442, 0.3795, 0.8656]}, {"w": "to", "b": [0.387, 0.8442, 0.404, 0.8656]}, {"w": "detect", "b": [0.4114, 0.8442, 0.4617, 0.8656]}, {"w": "Iris-Virginica", "b": [0.4691, 0.8442, 0.582, 0.8656]}, {"w": "flowers.", "b": [0.5895, 0.8442, 0.6548, 0.8656]}, {"w": "The", "b": [0.6622, 0.8442, 0.6951, 0.8656]}, {"w": "resulting", "b": [0.7025, 0.8442, 0.7762, 0.8656]}, {"w": "model", "b": [0.7836, 0.8442, 0.8365, 0.8656]}, {"w": "is", "b": [0.8439, 0.8442, 0.8571, 0.8656]}, {"w": "represented", "b": [0.1429, 0.8632, 0.2406, 0.8846]}, {"w": "on", "b": [0.2454, 0.8632, 0.2674, 0.8846]}, {"w": "the", "b": [0.2721, 0.8632, 0.2985, 0.8846]}, {"w": "left", "b": [0.3032, 0.8632, 0.3298, 0.8846]}, {"w": "of", "b": [0.3346, 0.8632, 0.3514, 0.8846]}, {"w": "Figure", "b": [0.3561, 0.8632, 0.4101, 0.8846]}, {"w": "5-4.", "b": [0.4148, 0.8632, 0.447, 0.8846]}]}, {"id": "b_6", "type": "paragraph", "text": "Linear SVM Classification | 157", "words": [{"w": "Linear", "b": [0.6506, 0.9225, 0.6875, 0.9388]}, {"w": "SVM", "b": [0.6903, 0.9225, 0.716, 0.9388]}, {"w": "Classification", "b": [0.7188, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "157", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 184, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "import numpy as np from sklearn import datasets from sklearn.pipeline import Pipeline from sklearn.preprocessing import StandardScaler from sklearn.svm import LinearSVC", "words": [{"w": "import", "b": [0.1766, 0.0829, 0.2272, 0.0958]}, {"w": "numpy", "b": [0.2356, 0.0829, 0.2778, 0.0958]}, {"w": "as", "b": [0.2862, 0.0829, 0.3031, 0.0958]}, {"w": "np", "b": [0.3115, 0.0829, 0.3284, 0.0958]}, {"w": "from", "b": [0.1766, 0.0983, 0.2103, 0.1112]}, {"w": "sklearn", "b": [0.2188, 0.0983, 0.2778, 0.1112]}, {"w": "import", "b": [0.2862, 0.0983, 0.3368, 0.1112]}, {"w": "datasets", "b": [0.3452, 0.0983, 0.4127, 0.1112]}, {"w": "from", "b": [0.1766, 0.1138, 0.2103, 0.1266]}, {"w": "sklearn.pipeline", "b": [0.2188, 0.1138, 0.3537, 0.1266]}, {"w": "import", "b": [0.3621, 0.1138, 0.4127, 0.1266]}, {"w": "Pipeline", "b": [0.4211, 0.1138, 0.4886, 0.1266]}, {"w": "from", "b": [0.1766, 0.1292, 0.2103, 0.142]}, {"w": "sklearn.preprocessing", "b": [0.2188, 0.1292, 0.3958, 0.142]}, {"w": "import", "b": [0.4043, 0.1292, 0.4549, 0.142]}, {"w": "StandardScaler", "b": [0.4633, 0.1292, 0.5813, 0.142]}, {"w": "from", "b": [0.1766, 0.1446, 0.2103, 0.1574]}, {"w": "sklearn.svm", "b": [0.2188, 0.1446, 0.3115, 0.1574]}, {"w": "import", "b": [0.3199, 0.1446, 0.3705, 0.1574]}, {"w": "LinearSVC", "b": [0.379, 0.1446, 0.4549, 0.1574]}]}, {"id": "b_1", "type": "paragraph", "text": "iris = datasets.load_iris() X = iris[\"data\"][:, (2, 3)] # petal length, petal width y = (iris[\"target\"] == 2).astype(np.float64) # Iris-Virginica", "words": [{"w": "iris", "b": [0.1766, 0.1754, 0.2103, 0.1883]}, {"w": "=", "b": [0.2188, 0.1754, 0.2272, 0.1883]}, {"w": "datasets.load_iris()", "b": [0.2356, 0.1754, 0.4043, 0.1883]}, {"w": "X", "b": [0.1766, 0.1909, 0.185, 0.2037]}, {"w": "=", "b": [0.1935, 0.1909, 0.2019, 0.2037]}, {"w": "iris[\"data\"][:,", "b": [0.2103, 0.1909, 0.3368, 0.2037]}, {"w": "(2,", "b": [0.3452, 0.1909, 0.3705, 0.2037]}, {"w": "3)]", "b": [0.379, 0.1909, 0.4043, 0.2037]}, {"w": "#", "b": [0.4211, 0.1909, 0.4296, 0.2037]}, {"w": "petal", "b": [0.438, 0.1909, 0.4802, 0.2037]}, {"w": "length,", "b": [0.4886, 0.1909, 0.5476, 0.2037]}, {"w": "petal", "b": [0.5561, 0.1909, 0.5982, 0.2037]}, {"w": "width", "b": [0.6066, 0.1909, 0.6488, 0.2037]}, {"w": "y", "b": [0.1766, 0.2063, 0.185, 0.2191]}, {"w": "=", "b": [0.1935, 0.2063, 0.2019, 0.2191]}, {"w": "(iris[\"target\"]", "b": [0.2103, 0.2063, 0.3368, 0.2191]}, {"w": "==", "b": [0.3452, 0.2063, 0.3621, 0.2191]}, {"w": "2).astype(np.float64)", "b": [0.3705, 0.2063, 0.5476, 0.2191]}, {"w": "#", "b": [0.5645, 0.2063, 0.5729, 0.2191]}, {"w": "Iris-Virginica", "b": [0.5813, 0.2063, 0.6994, 0.2191]}]}, {"id": "b_2", "type": "paragraph", "text": "svm_clf = Pipeline([ (\"scaler\", StandardScaler()), (\"linear_svc\", LinearSVC(C=1, loss=\"hinge\")), ])", "words": [{"w": "svm_clf", "b": [0.1766, 0.2371, 0.2356, 0.25]}, {"w": "=", "b": [0.244, 0.2371, 0.2525, 0.25]}, {"w": "Pipeline([", "b": [0.2609, 0.2371, 0.3452, 0.25]}, {"w": "(\"scaler\",", "b": [0.244, 0.2525, 0.3284, 0.2654]}, {"w": "StandardScaler()),", "b": [0.3368, 0.2525, 0.4886, 0.2654]}, {"w": "(\"linear_svc\",", "b": [0.244, 0.268, 0.3621, 0.2808]}, {"w": "LinearSVC(C=1,", "b": [0.3705, 0.268, 0.4886, 0.2808]}, {"w": "loss=\"hinge\")),", "b": [0.497, 0.268, 0.6235, 0.2808]}, {"w": "])", "b": [0.2103, 0.2834, 0.2272, 0.2962]}]}, {"id": "b_3", "type": "equation", "text": "svm_clf.fit(X, y)", "words": [{"w": "svm_clf.fit(X,", "b": [0.1766, 0.3142, 0.2946, 0.3271]}, {"w": "y)", "b": [0.3031, 0.3142, 0.3199, 0.3271]}]}, {"id": "b_4", "type": "paragraph", "text": "Then, as usual, you can use the model to make predictions:", "words": [{"w": "Then,", "b": [0.1429, 0.3348, 0.1918, 0.3563]}, {"w": "as", "b": [0.1966, 0.3348, 0.2134, 0.3563]}, {"w": "usual,", "b": [0.2181, 0.3348, 0.267, 0.3563]}, {"w": "you", "b": [0.2718, 0.3348, 0.303, 0.3563]}, {"w": "can", "b": [0.3077, 0.3348, 0.3371, 0.3563]}, {"w": "use", "b": [0.3418, 0.3348, 0.3694, 0.3563]}, {"w": "the", "b": [0.3741, 0.3348, 0.4004, 0.3563]}, {"w": "model", "b": [0.4052, 0.3348, 0.458, 0.3563]}, {"w": "to", "b": [0.4627, 0.3348, 0.4797, 0.3563]}, {"w": "make", "b": [0.4844, 0.3348, 0.5298, 0.3563]}, {"w": "predictions:", "b": [0.5345, 0.3348, 0.6338, 0.3563]}]}, {"id": "b_5", "type": "equation", "text": ">>> svm_clf.predict([[5.5, 1.7]]) array([1.])", "words": [{"w": ">>>", "b": [0.1766, 0.3668, 0.2019, 0.3797]}, {"w": "svm_clf.predict([[5.5,", "b": [0.2103, 0.3668, 0.3958, 0.3797]}, {"w": "1.7]])", "b": [0.4043, 0.3668, 0.4549, 0.3797]}, {"w": "array([1.])", "b": [0.1766, 0.3822, 0.2693, 0.3951]}]}, {"id": "b_6", "type": "paragraph", "text": "Unlike Logistic Regression classifiers, SVM classifiers do not out‐ put probabilities for each class.", "words": [{"w": "Unlike", "b": [0.2714, 0.4167, 0.3225, 0.4363]}, {"w": "Logistic", "b": [0.329, 0.4167, 0.3889, 0.4363]}, {"w": "Regression", "b": [0.3954, 0.4167, 0.4786, 0.4363]}, {"w": "classifiers,", "b": [0.4851, 0.4167, 0.5626, 0.4363]}, {"w": "SVM", "b": [0.5691, 0.4167, 0.6085, 0.4363]}, {"w": "classifiers", "b": [0.615, 0.4167, 0.6882, 0.4363]}, {"w": "do", "b": [0.6947, 0.4167, 0.7144, 0.4363]}, {"w": "not", "b": [0.7209, 0.4167, 0.7468, 0.4363]}, {"w": "out‐", "b": [0.7533, 0.4167, 0.7857, 0.4363]}, {"w": "put", "b": [0.2714, 0.4341, 0.2973, 0.4537]}, {"w": "probabilities", "b": [0.3016, 0.4341, 0.3972, 0.4537]}, {"w": "for", "b": [0.4015, 0.4341, 0.4239, 0.4537]}, {"w": "each", "b": [0.4282, 0.4341, 0.4629, 0.4537]}, {"w": "class.", "b": [0.4672, 0.4341, 0.5068, 0.4537]}]}, {"id": "b_7", "type": "paragraph", "text": "Alternatively, you could use the SVC class, using SVC(kernel=\"linear\", C=1), but it is much slower, especially with large training sets, so it is not recommended. Another option is to use the SGDClassifier class, with SGDClassifier(loss=\"hinge\", alpha=1/(m*C)). This applies regular Stochastic Gradient Descent (see Chapter 4) to train a linear SVM classifier. It does not converge as fast as the LinearSVC class, but it can be useful to handle huge datasets that do not fit in memory (out-of-core train‐ ing), or to handle online classification tasks.", "words": [{"w": "Alternatively,", "b": [0.1429, 0.5162, 0.2541, 0.5377]}, {"w": "you", "b": [0.26, 0.5162, 0.2913, 0.5377]}, {"w": "could", "b": [0.2972, 0.5162, 0.344, 0.5377]}, {"w": "use", "b": [0.35, 0.5162, 0.3775, 0.5377]}, {"w": "the", "b": [0.3835, 0.5162, 0.4098, 0.5377]}, {"w": "SVC", "b": [0.4158, 0.5194, 0.4454, 0.5345]}, {"w": "class,", "b": [0.4514, 0.5162, 0.4947, 0.5377]}, {"w": "using", "b": [0.5006, 0.5162, 0.546, 0.5377]}, {"w": "SVC(kernel=\"linear\",", "b": [0.552, 0.5194, 0.7499, 0.5345]}, {"w": "C=1),", "b": [0.761, 0.5162, 0.8053, 0.5377]}, {"w": "but", "b": [0.8113, 0.5162, 0.8393, 0.5377]}, {"w": "it", "b": [0.8452, 0.5162, 0.8571, 0.5377]}, {"w": "is", "b": [0.1429, 0.5353, 0.1561, 0.5567]}, {"w": "much", "b": [0.1613, 0.5353, 0.2089, 0.5567]}, {"w": "slower,", "b": [0.2141, 0.5353, 0.2719, 0.5567]}, {"w": "especially", "b": [0.2771, 0.5353, 0.357, 0.5567]}, {"w": "with", "b": [0.3622, 0.5353, 0.3995, 0.5567]}, {"w": "large", "b": [0.4046, 0.5353, 0.4454, 0.5567]}, {"w": "training", "b": [0.4506, 0.5353, 0.5175, 0.5567]}, {"w": "sets,", "b": [0.5227, 0.5353, 0.5579, 0.5567]}, {"w": "so", "b": [0.5631, 0.5353, 0.5813, 0.5567]}, {"w": "it", "b": [0.5865, 0.5353, 0.5984, 0.5567]}, {"w": "is", "b": [0.6036, 0.5353, 0.6168, 0.5567]}, {"w": "not", "b": [0.622, 0.5353, 0.6504, 0.5567]}, {"w": "recommended.", "b": [0.6555, 0.5353, 0.7815, 0.5567]}, {"w": "Another", "b": [0.7867, 0.5353, 0.8572, 0.5567]}, {"w": "option", "b": [0.1429, 0.5552, 0.1984, 0.5766]}, {"w": "is", "b": [0.2106, 0.5552, 0.2239, 0.5766]}, {"w": "to", "b": [0.2361, 0.5552, 0.2531, 0.5766]}, {"w": "use", "b": [0.2654, 0.5552, 0.293, 0.5766]}, {"w": "the", "b": [0.3053, 0.5552, 0.3316, 0.5766]}, {"w": "SGDClassifier", "b": [0.3439, 0.5584, 0.4725, 0.5735]}, {"w": "class,", "b": [0.4848, 0.5552, 0.5281, 0.5766]}, {"w": "with", "b": [0.5403, 0.5552, 0.5777, 0.5766]}, {"w": "SGDClassifier(loss=\"hinge\",", "b": [0.59, 0.5584, 0.8571, 0.5735]}, {"w": "alpha=1/(m*C)).", "b": [0.1429, 0.5752, 0.2862, 0.5966]}, {"w": "This", "b": [0.2918, 0.5752, 0.329, 0.5966]}, {"w": "applies", "b": [0.3346, 0.5752, 0.3925, 0.5966]}, {"w": "regular", "b": [0.3982, 0.5752, 0.4577, 0.5966]}, {"w": "Stochastic", "b": [0.4633, 0.5752, 0.5477, 0.5966]}, {"w": "Gradient", "b": [0.5533, 0.5752, 0.6279, 0.5966]}, {"w": "Descent", "b": [0.6335, 0.5752, 0.7003, 0.5966]}, {"w": "(see", "b": [0.7059, 0.5752, 0.7385, 0.5966]}, {"w": "Chapter", "b": [0.7441, 0.5752, 0.8117, 0.5966]}, {"w": "4)", "b": [0.8173, 0.5752, 0.8345, 0.5966]}, {"w": "to", "b": [0.8402, 0.5752, 0.8571, 0.5966]}, {"w": "train", "b": [0.1429, 0.5951, 0.1831, 0.6165]}, {"w": "a", "b": [0.1882, 0.5951, 0.1973, 0.6165]}, {"w": "linear", "b": [0.2025, 0.5951, 0.2505, 0.6165]}, {"w": "SVM", "b": [0.2556, 0.5951, 0.2987, 0.6165]}, {"w": "classifier.", "b": [0.3038, 0.5951, 0.3797, 0.6165]}, {"w": "It", "b": [0.3848, 0.5951, 0.3975, 0.6165]}, {"w": "does", "b": [0.4026, 0.5951, 0.4407, 0.6165]}, {"w": "not", "b": [0.4459, 0.5951, 0.4742, 0.6165]}, {"w": "converge", "b": [0.4794, 0.5951, 0.5546, 0.6165]}, {"w": "as", "b": [0.5597, 0.5951, 0.5765, 0.6165]}, {"w": "fast", "b": [0.5816, 0.5951, 0.6109, 0.6165]}, {"w": "as", "b": [0.6161, 0.5951, 0.6329, 0.6165]}, {"w": "the", "b": [0.638, 0.5951, 0.6643, 0.6165]}, {"w": "LinearSVC", "b": [0.6695, 0.5983, 0.7585, 0.6134]}, {"w": "class,", "b": [0.7637, 0.5951, 0.8069, 0.6165]}, {"w": "but", "b": [0.8121, 0.5951, 0.8401, 0.6165]}, {"w": "it", "b": [0.8452, 0.5951, 0.8571, 0.6165]}, {"w": "can", "b": [0.1429, 0.6142, 0.1722, 0.6356]}, {"w": "be", "b": [0.1791, 0.6142, 0.1985, 0.6356]}, {"w": "useful", "b": [0.2053, 0.6142, 0.2554, 0.6356]}, {"w": "to", "b": [0.2623, 0.6142, 0.2792, 0.6356]}, {"w": "handle", "b": [0.2861, 0.6142, 0.3429, 0.6356]}, {"w": "huge", "b": [0.3497, 0.6142, 0.3901, 0.6356]}, {"w": "datasets", "b": [0.397, 0.6142, 0.4627, 0.6356]}, {"w": "that", "b": [0.4695, 0.6142, 0.5021, 0.6356]}, {"w": "do", "b": [0.509, 0.6142, 0.5306, 0.6356]}, {"w": "not", "b": [0.5374, 0.6142, 0.5658, 0.6356]}, {"w": "fit", "b": [0.5727, 0.6142, 0.5908, 0.6356]}, {"w": "in", "b": [0.5976, 0.6142, 0.6146, 0.6356]}, {"w": "memory", "b": [0.6214, 0.6142, 0.6929, 0.6356]}, {"w": "(out-of-core", "b": [0.6998, 0.6142, 0.8027, 0.6356]}, {"w": "train‐", "b": [0.8095, 0.6142, 0.8571, 0.6356]}, {"w": "ing),", "b": [0.1429, 0.6332, 0.1815, 0.6546]}, {"w": "or", "b": [0.1863, 0.6332, 0.2046, 0.6546]}, {"w": "to", "b": [0.2094, 0.6332, 0.2263, 0.6546]}, {"w": "handle", "b": [0.2311, 0.6332, 0.2879, 0.6546]}, {"w": "online", "b": [0.2926, 0.6332, 0.3457, 0.6546]}, {"w": "classification", "b": [0.3504, 0.6332, 0.4578, 0.6546]}, {"w": "tasks.", "b": [0.4625, 0.6332, 0.5084, 0.6546]}]}, {"id": "b_8", "type": "paragraph", "text": "The LinearSVC class regularizes the bias term, so you should center the training set first by subtracting its mean. This is automatic if you scale the data using the StandardScaler. Moreover, make sure you set the loss hyperparameter to \"hinge\", as it is not the default value. Finally, for better performance you should set the dual hyperparameter to False, unless there are more features than training instances (we will discuss duality later in the chapter).", "words": [{"w": "The", "b": [0.2714, 0.676, 0.3014, 0.6956]}, {"w": "LinearSVC", "b": [0.306, 0.6789, 0.3874, 0.6927]}, {"w": "class", "b": [0.392, 0.676, 0.4272, 0.6956]}, {"w": "regularizes", "b": [0.4317, 0.676, 0.5144, 0.6956]}, {"w": "the", "b": [0.5189, 0.676, 0.543, 0.6956]}, {"w": "bias", "b": [0.5476, 0.676, 0.5777, 0.6956]}, {"w": "term,", "b": [0.5823, 0.676, 0.6232, 0.6956]}, {"w": "so", "b": [0.6277, 0.676, 0.6444, 0.6956]}, {"w": "you", "b": [0.649, 0.676, 0.6776, 0.6956]}, {"w": "should", "b": [0.6821, 0.676, 0.734, 0.6956]}, {"w": "center", "b": [0.7385, 0.676, 0.7857, 0.6956]}, {"w": "the", "b": [0.2714, 0.6934, 0.2955, 0.713]}, {"w": "training", "b": [0.3023, 0.6934, 0.3635, 0.713]}, {"w": "set", "b": [0.3703, 0.6934, 0.3912, 0.713]}, {"w": "first", "b": [0.398, 0.6934, 0.4286, 0.713]}, {"w": "by", "b": [0.4355, 0.6934, 0.4539, 0.713]}, {"w": "subtracting", "b": [0.4607, 0.6934, 0.547, 0.713]}, {"w": "its", "b": [0.5538, 0.6934, 0.5717, 0.713]}, {"w": "mean.", "b": [0.5786, 0.6934, 0.6254, 0.713]}, {"w": "This", "b": [0.6322, 0.6934, 0.6662, 0.713]}, {"w": "is", "b": [0.673, 0.6934, 0.6851, 0.713]}, {"w": "automatic", "b": [0.6919, 0.6934, 0.7682, 0.713]}, {"w": "if", "b": [0.775, 0.6934, 0.7857, 0.713]}, {"w": "you", "b": [0.2714, 0.7116, 0.3, 0.7312]}, {"w": "scale", "b": [0.3049, 0.7116, 0.3413, 0.7312]}, {"w": "the", "b": [0.3462, 0.7116, 0.3703, 0.7312]}, {"w": "data", "b": [0.3752, 0.7116, 0.4074, 0.7312]}, {"w": "using", "b": [0.4124, 0.7116, 0.4539, 0.7312]}, {"w": "the", "b": [0.4589, 0.7116, 0.483, 0.7312]}, {"w": "StandardScaler.", "b": [0.4879, 0.7116, 0.6189, 0.7312]}, {"w": "Moreover,", "b": [0.6239, 0.7116, 0.7021, 0.7312]}, {"w": "make", "b": [0.707, 0.7116, 0.7485, 0.7312]}, {"w": "sure", "b": [0.7534, 0.7116, 0.7857, 0.7312]}, {"w": "you", "b": [0.2714, 0.7299, 0.3, 0.7494]}, {"w": "set", "b": [0.3048, 0.7299, 0.3257, 0.7494]}, {"w": "the", "b": [0.3306, 0.7299, 0.3547, 0.7494]}, {"w": "loss", "b": [0.3596, 0.7328, 0.3957, 0.7466]}, {"w": "hyperparameter", "b": [0.4006, 0.7299, 0.5227, 0.7494]}, {"w": "to", "b": [0.5275, 0.7299, 0.543, 0.7494]}, {"w": "\"hinge\",", "b": [0.5479, 0.7299, 0.6156, 0.7494]}, {"w": "as", "b": [0.6205, 0.7299, 0.6358, 0.7494]}, {"w": "it", "b": [0.6407, 0.7299, 0.6516, 0.7494]}, {"w": "is", "b": [0.6565, 0.7299, 0.6686, 0.7494]}, {"w": "not", "b": [0.6734, 0.7299, 0.6994, 0.7494]}, {"w": "the", "b": [0.7042, 0.7299, 0.7283, 0.7494]}, {"w": "default", "b": [0.7332, 0.7299, 0.7857, 0.7494]}, {"w": "value.", "b": [0.2714, 0.7481, 0.316, 0.7677]}, {"w": "Finally,", "b": [0.3257, 0.7481, 0.381, 0.7677]}, {"w": "for", "b": [0.3908, 0.7481, 0.4132, 0.7677]}, {"w": "better", "b": [0.4229, 0.7481, 0.4675, 0.7677]}, {"w": "performance", "b": [0.4772, 0.7481, 0.5753, 0.7677]}, {"w": "you", "b": [0.5851, 0.7481, 0.6137, 0.7677]}, {"w": "should", "b": [0.6234, 0.7481, 0.6753, 0.7677]}, {"w": "set", "b": [0.685, 0.7481, 0.7059, 0.7677]}, {"w": "the", "b": [0.7157, 0.7481, 0.7398, 0.7677]}, {"w": "dual", "b": [0.7495, 0.751, 0.7857, 0.7648]}, {"w": "hyperparameter", "b": [0.2714, 0.7663, 0.3935, 0.7859]}, {"w": "to", "b": [0.4037, 0.7663, 0.4192, 0.7859]}, {"w": "False,", "b": [0.4295, 0.7663, 0.479, 0.7859]}, {"w": "unless", "b": [0.4893, 0.7663, 0.5367, 0.7859]}, {"w": "there", "b": [0.5469, 0.7663, 0.5862, 0.7859]}, {"w": "are", "b": [0.5964, 0.7663, 0.6199, 0.7859]}, {"w": "more", "b": [0.6302, 0.7663, 0.6707, 0.7859]}, {"w": "features", "b": [0.6809, 0.7663, 0.7407, 0.7859]}, {"w": "than", "b": [0.7509, 0.7663, 0.7857, 0.7859]}, {"w": "training", "b": [0.2714, 0.7837, 0.3326, 0.8033]}, {"w": "instances", "b": [0.3369, 0.7837, 0.4072, 0.8033]}, {"w": "(we", "b": [0.4115, 0.7837, 0.4392, 0.8033]}, {"w": "will", "b": [0.4436, 0.7837, 0.4713, 0.8033]}, {"w": "discuss", "b": [0.4757, 0.7837, 0.53, 0.8033]}, {"w": "duality", "b": [0.5343, 0.7837, 0.5873, 0.8033]}, {"w": "later", "b": [0.5916, 0.7837, 0.6254, 0.8033]}, {"w": "in", "b": [0.6297, 0.7837, 0.6453, 0.8033]}, {"w": "the", "b": [0.6496, 0.7837, 0.6737, 0.8033]}, {"w": "chapter).", "b": [0.678, 0.7837, 0.7461, 0.8033]}]}, {"id": "b_9", "type": "paragraph", "text": "158 | Chapter 5: Support Vector Machines", "words": [{"w": "158", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "5:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Support", "b": [0.2673, 0.9225, 0.3142, 0.9388]}, {"w": "Vector", "b": [0.317, 0.9225, 0.3547, 0.9388]}, {"w": "Machines", "b": [0.3576, 0.9225, 0.413, 0.9388]}]}]}, {"page": 185, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Nonlinear SVM Classification", "words": [{"w": "Nonlinear", "b": [0.1429, 0.0753, 0.2648, 0.1095]}, {"w": "SVM", "b": [0.2708, 0.0753, 0.3247, 0.1095]}, {"w": "Classification", "b": [0.3306, 0.0753, 0.4925, 0.1095]}]}, {"id": "b_1", "type": "paragraph", "text": "Although linear SVM classifiers are efficient and work surprisingly well in many cases, many datasets are not even close to being linearly separable. One approach to handling nonlinear datasets is to add more features, such as polynomial features (as you did in Chapter 4); in some cases this can result in a linearly separable dataset. Consider the left plot in Figure 5-5: it represents a simple dataset with just one feature x1. This dataset is not linearly separable, as you can see. But if you add a second fea‐ ture x2 = (x1)2, the resulting 2D dataset is perfectly linearly separable.", "words": [{"w": "Although", "b": [0.1429, 0.1164, 0.2226, 0.1378]}, {"w": "linear", "b": [0.2315, 0.1164, 0.2795, 0.1378]}, {"w": "SVM", "b": [0.2885, 0.1164, 0.3316, 0.1378]}, {"w": "classifiers", "b": [0.3405, 0.1164, 0.4206, 0.1378]}, {"w": "are", "b": [0.4296, 0.1164, 0.4553, 0.1378]}, {"w": "efficient", "b": [0.4643, 0.1164, 0.5316, 0.1378]}, {"w": "and", "b": [0.5406, 0.1164, 0.5721, 0.1378]}, {"w": "work", "b": [0.5811, 0.1164, 0.6241, 0.1378]}, {"w": "surprisingly", "b": [0.633, 0.1164, 0.7329, 0.1378]}, {"w": "well", "b": [0.7419, 0.1164, 0.7755, 0.1378]}, {"w": "in", "b": [0.7845, 0.1164, 0.8015, 0.1378]}, {"w": "many", "b": [0.8105, 0.1164, 0.8571, 0.1378]}, {"w": "cases,", "b": [0.1429, 0.1355, 0.1897, 0.1569]}, {"w": "many", "b": [0.196, 0.1355, 0.2427, 0.1569]}, {"w": "datasets", "b": [0.2489, 0.1355, 0.3147, 0.1569]}, {"w": "are", "b": [0.3209, 0.1355, 0.3466, 0.1569]}, {"w": "not", "b": [0.3529, 0.1355, 0.3813, 0.1569]}, {"w": "even", "b": [0.3875, 0.1355, 0.4263, 0.1569]}, {"w": "close", "b": [0.4325, 0.1355, 0.4737, 0.1569]}, {"w": "to", "b": [0.48, 0.1355, 0.497, 0.1569]}, {"w": "being", "b": [0.5032, 0.1355, 0.5494, 0.1569]}, {"w": "linearly", "b": [0.5556, 0.1355, 0.6184, 0.1569]}, {"w": "separable.", "b": [0.6247, 0.1355, 0.7076, 0.1569]}, {"w": "One", "b": [0.7138, 0.1355, 0.7497, 0.1569]}, {"w": "approach", "b": [0.7559, 0.1355, 0.8339, 0.1569]}, {"w": "to", "b": [0.8402, 0.1355, 0.8572, 0.1569]}, {"w": "handling", "b": [0.1429, 0.1545, 0.2175, 0.1759]}, {"w": "nonlinear", "b": [0.2239, 0.1545, 0.3053, 0.1759]}, {"w": "datasets", "b": [0.3117, 0.1545, 0.3774, 0.1759]}, {"w": "is", "b": [0.3838, 0.1545, 0.397, 0.1759]}, {"w": "to", "b": [0.4034, 0.1545, 0.4203, 0.1759]}, {"w": "add", "b": [0.4267, 0.1545, 0.4578, 0.1759]}, {"w": "more", "b": [0.4642, 0.1545, 0.5085, 0.1759]}, {"w": "features,", "b": [0.5148, 0.1545, 0.585, 0.1759]}, {"w": "such", "b": [0.5914, 0.1545, 0.63, 0.1759]}, {"w": "as", "b": [0.6364, 0.1545, 0.6532, 0.1759]}, {"w": "polynomial", "b": [0.6595, 0.1545, 0.755, 0.1759]}, {"w": "features", "b": [0.7614, 0.1545, 0.8268, 0.1759]}, {"w": "(as", "b": [0.8331, 0.1545, 0.8571, 0.1759]}, {"w": "you", "b": [0.1429, 0.1736, 0.1741, 0.195]}, {"w": "did", "b": [0.1814, 0.1736, 0.2089, 0.195]}, {"w": "in", "b": [0.2162, 0.1736, 0.2332, 0.195]}, {"w": "Chapter", "b": [0.2404, 0.1736, 0.308, 0.195]}, {"w": "4);", "b": [0.3152, 0.1736, 0.3372, 0.195]}, {"w": "in", "b": [0.3445, 0.1736, 0.3614, 0.195]}, {"w": "some", "b": [0.3687, 0.1736, 0.4129, 0.195]}, {"w": "cases", "b": [0.4201, 0.1736, 0.4622, 0.195]}, {"w": "this", "b": [0.4695, 0.1736, 0.5002, 0.195]}, {"w": "can", "b": [0.5074, 0.1736, 0.5368, 0.195]}, {"w": "result", "b": [0.544, 0.1736, 0.591, 0.195]}, {"w": "in", "b": [0.5982, 0.1736, 0.6152, 0.195]}, {"w": "a", "b": [0.6224, 0.1736, 0.6316, 0.195]}, {"w": "linearly", "b": [0.6388, 0.1736, 0.7016, 0.195]}, {"w": "separable", "b": [0.7089, 0.1736, 0.787, 0.195]}, {"w": "dataset.", "b": [0.7943, 0.1736, 0.8571, 0.195]}, {"w": "Consider", "b": [0.1428, 0.1926, 0.2195, 0.214]}, {"w": "the", "b": [0.2243, 0.1926, 0.2506, 0.214]}, {"w": "left", "b": [0.2553, 0.1926, 0.282, 0.214]}, {"w": "plot", "b": [0.2867, 0.1926, 0.3199, 0.214]}, {"w": "in", "b": [0.3246, 0.1926, 0.3416, 0.214]}, {"w": "Figure", "b": [0.3467, 0.1926, 0.4007, 0.214]}, {"w": "5-5:", "b": [0.4055, 0.1926, 0.4377, 0.214]}, {"w": "it", "b": [0.4425, 0.1926, 0.4545, 0.214]}, {"w": "represents", "b": [0.4593, 0.1926, 0.5449, 0.214]}, {"w": "a", "b": [0.5497, 0.1926, 0.5588, 0.214]}, {"w": "simple", "b": [0.5637, 0.1926, 0.6186, 0.214]}, {"w": "dataset", "b": [0.6234, 0.1926, 0.6815, 0.214]}, {"w": "with", "b": [0.6863, 0.1926, 0.7237, 0.214]}, {"w": "just", "b": [0.7285, 0.1926, 0.7589, 0.214]}, {"w": "one", "b": [0.7637, 0.1926, 0.7946, 0.214]}, {"w": "feature", "b": [0.7994, 0.1926, 0.8571, 0.214]}, {"w": "x1.", "b": [0.1428, 0.2115, 0.1635, 0.234]}, {"w": "This", "b": [0.1694, 0.2117, 0.2066, 0.2331]}, {"w": "dataset", "b": [0.2125, 0.2117, 0.2706, 0.2331]}, {"w": "is", "b": [0.2765, 0.2117, 0.2898, 0.2331]}, {"w": "not", "b": [0.2957, 0.2117, 0.3241, 0.2331]}, {"w": "linearly", "b": [0.33, 0.2117, 0.3928, 0.2331]}, {"w": "separable,", "b": [0.3987, 0.2117, 0.4816, 0.2331]}, {"w": "as", "b": [0.4875, 0.2117, 0.5043, 0.2331]}, {"w": "you", "b": [0.5103, 0.2117, 0.5415, 0.2331]}, {"w": "can", "b": [0.5474, 0.2117, 0.5768, 0.2331]}, {"w": "see.", "b": [0.5827, 0.2117, 0.6128, 0.2331]}, {"w": "But", "b": [0.6187, 0.2117, 0.6484, 0.2331]}, {"w": "if", "b": [0.6543, 0.2117, 0.6661, 0.2331]}, {"w": "you", "b": [0.672, 0.2117, 0.7032, 0.2331]}, {"w": "add", "b": [0.7092, 0.2117, 0.7403, 0.2331]}, {"w": "a", "b": [0.7462, 0.2117, 0.7554, 0.2331]}, {"w": "second", "b": [0.7613, 0.2117, 0.8196, 0.2331]}, {"w": "fea‐", "b": [0.8256, 0.2117, 0.8571, 0.2331]}, {"w": "ture", "b": [0.1429, 0.2307, 0.1769, 0.2521]}, {"w": "x2", "b": [0.1816, 0.2305, 0.1974, 0.253]}, {"w": "=", "b": [0.2022, 0.2307, 0.2143, 0.2521]}, {"w": "(x1)2,", "b": [0.219, 0.2305, 0.26, 0.253]}, {"w": "the", "b": [0.2647, 0.2307, 0.2911, 0.2521]}, {"w": "resulting", "b": [0.2958, 0.2307, 0.3694, 0.2521]}, {"w": "2D", "b": [0.3742, 0.2307, 0.3995, 0.2521]}, {"w": "dataset", "b": [0.4042, 0.2307, 0.4623, 0.2521]}, {"w": "is", "b": [0.467, 0.2307, 0.4803, 0.2521]}, {"w": "perfectly", "b": [0.485, 0.2307, 0.5575, 0.2521]}, {"w": "linearly", "b": [0.5623, 0.2307, 0.6251, 0.2521]}, {"w": "separable.", "b": [0.6298, 0.2307, 0.7127, 0.2521]}]}, {"id": "b_2", "type": "equation", "text": "Figure 5-5. Adding features to make a dataset linearly separable", "words": [{"w": "Figure", "b": [0.1429, 0.4724, 0.1943, 0.494]}, {"w": "5-5.", "b": [0.1991, 0.4724, 0.2308, 0.494]}, {"w": "Adding", "b": [0.2356, 0.4724, 0.2952, 0.494]}, {"w": "features", "b": [0.3, 0.4724, 0.3628, 0.494]}, {"w": "to", "b": [0.3676, 0.4724, 0.3836, 0.494]}, {"w": "make", "b": [0.3883, 0.4724, 0.4325, 0.494]}, {"w": "a", "b": [0.4373, 0.4724, 0.4475, 0.494]}, {"w": "dataset", "b": [0.4523, 0.4724, 0.5106, 0.494]}, {"w": "linearly", "b": [0.5154, 0.4724, 0.5763, 0.494]}, {"w": "separable", "b": [0.581, 0.4724, 0.6566, 0.494]}]}, {"id": "b_3", "type": "paragraph", "text": "To implement this idea using Scikit-Learn, you can create a Pipeline containing a PolynomialFeatures transformer (discussed in “Polynomial Regression” on page 130), followed by a StandardScaler and a LinearSVC. Let’s test this on the moons dataset: this is a toy dataset for binary classification in which the data points are sha‐ ped as two interleaving half circles (see Figure 5-6). You can generate this dataset using the make_moons() function:", "words": [{"w": "To", "b": [0.1429, 0.5107, 0.1643, 0.5321]}, {"w": "implement", "b": [0.1716, 0.5107, 0.2621, 0.5321]}, {"w": "this", "b": [0.2694, 0.5107, 0.3001, 0.5321]}, {"w": "idea", "b": [0.3074, 0.5107, 0.342, 0.5321]}, {"w": "using", "b": [0.3493, 0.5107, 0.3947, 0.5321]}, {"w": "Scikit-Learn,", "b": [0.402, 0.5107, 0.5091, 0.5321]}, {"w": "you", "b": [0.5164, 0.5107, 0.5476, 0.5321]}, {"w": "can", "b": [0.5549, 0.5107, 0.5842, 0.5321]}, {"w": "create", "b": [0.5915, 0.5107, 0.6409, 0.5321]}, {"w": "a", "b": [0.6482, 0.5107, 0.6573, 0.5321]}, {"w": "Pipeline", "b": [0.6646, 0.5139, 0.7438, 0.5289]}, {"w": "containing", "b": [0.7511, 0.5107, 0.8407, 0.5321]}, {"w": "a", "b": [0.848, 0.5107, 0.8571, 0.5321]}, {"w": "PolynomialFeatures", "b": [0.1429, 0.5338, 0.321, 0.5489]}, {"w": "transformer", "b": [0.331, 0.5306, 0.4314, 0.552]}, {"w": "(discussed", "b": [0.4414, 0.5306, 0.5279, 0.552]}, {"w": "in", "b": [0.5379, 0.5306, 0.5549, 0.552]}, {"w": "“Polynomial", "b": [0.5649, 0.5306, 0.6688, 0.552]}, {"w": "Regression”", "b": [0.6788, 0.5306, 0.7764, 0.552]}, {"w": "on", "b": [0.7865, 0.5306, 0.8085, 0.552]}, {"w": "page", "b": [0.8185, 0.5306, 0.8571, 0.552]}, {"w": "130),", "b": [0.1429, 0.5506, 0.1848, 0.572]}, {"w": "followed", "b": [0.1922, 0.5506, 0.2643, 0.572]}, {"w": "by", "b": [0.2717, 0.5506, 0.2918, 0.572]}, {"w": "a", "b": [0.2992, 0.5506, 0.3084, 0.572]}, {"w": "StandardScaler", "b": [0.3158, 0.5537, 0.4543, 0.5688]}, {"w": "and", "b": [0.4617, 0.5506, 0.4932, 0.572]}, {"w": "a", "b": [0.5006, 0.5506, 0.5098, 0.572]}, {"w": "LinearSVC.", "b": [0.5172, 0.5506, 0.611, 0.572]}, {"w": "Let’s", "b": [0.6184, 0.5506, 0.6545, 0.572]}, {"w": "test", "b": [0.6619, 0.5506, 0.6911, 0.572]}, {"w": "this", "b": [0.6985, 0.5506, 0.7293, 0.572]}, {"w": "on", "b": [0.7366, 0.5506, 0.7587, 0.572]}, {"w": "the", "b": [0.7661, 0.5506, 0.7924, 0.572]}, {"w": "moons", "b": [0.7998, 0.5506, 0.8571, 0.572]}, {"w": "dataset:", "b": [0.1428, 0.5696, 0.2057, 0.591]}, {"w": "this", "b": [0.2113, 0.5696, 0.242, 0.591]}, {"w": "is", "b": [0.2477, 0.5696, 0.2609, 0.591]}, {"w": "a", "b": [0.2665, 0.5696, 0.2757, 0.591]}, {"w": "toy", "b": [0.2813, 0.5696, 0.3079, 0.591]}, {"w": "dataset", "b": [0.3135, 0.5696, 0.3716, 0.591]}, {"w": "for", "b": [0.3772, 0.5696, 0.4018, 0.591]}, {"w": "binary", "b": [0.4074, 0.5696, 0.462, 0.591]}, {"w": "classification", "b": [0.4676, 0.5696, 0.575, 0.591]}, {"w": "in", "b": [0.5807, 0.5696, 0.5976, 0.591]}, {"w": "which", "b": [0.6033, 0.5696, 0.6542, 0.591]}, {"w": "the", "b": [0.6598, 0.5696, 0.6862, 0.591]}, {"w": "data", "b": [0.6918, 0.5696, 0.727, 0.591]}, {"w": "points", "b": [0.7327, 0.5696, 0.7848, 0.591]}, {"w": "are", "b": [0.7904, 0.5696, 0.8162, 0.591]}, {"w": "sha‐", "b": [0.8218, 0.5696, 0.8571, 0.591]}, {"w": "ped", "b": [0.1429, 0.5887, 0.1736, 0.6101]}, {"w": "as", "b": [0.1817, 0.5887, 0.1985, 0.6101]}, {"w": "two", "b": [0.2066, 0.5887, 0.2379, 0.6101]}, {"w": "interleaving", "b": [0.246, 0.5887, 0.3448, 0.6101]}, {"w": "half", "b": [0.3529, 0.5887, 0.3846, 0.6101]}, {"w": "circles", "b": [0.3927, 0.5887, 0.4454, 0.6101]}, {"w": "(see", "b": [0.4535, 0.5887, 0.486, 0.6101]}, {"w": "Figure", "b": [0.4941, 0.5887, 0.5481, 0.6101]}, {"w": "5-6).", "b": [0.5562, 0.5887, 0.5956, 0.6101]}, {"w": "You", "b": [0.6037, 0.5887, 0.6361, 0.6101]}, {"w": "can", "b": [0.6441, 0.5887, 0.6735, 0.6101]}, {"w": "generate", "b": [0.6816, 0.5887, 0.7521, 0.6101]}, {"w": "this", "b": [0.7602, 0.5887, 0.7909, 0.6101]}, {"w": "dataset", "b": [0.799, 0.5887, 0.8571, 0.6101]}, {"w": "using", "b": [0.1429, 0.6086, 0.1883, 0.63]}, {"w": "the", "b": [0.193, 0.6086, 0.2194, 0.63]}, {"w": "make_moons()", "b": [0.2241, 0.6118, 0.3428, 0.6269]}, {"w": "function:", "b": [0.3476, 0.6086, 0.4237, 0.63]}]}, {"id": "b_4", "type": "paragraph", "text": "from sklearn.datasets import make_moons from sklearn.pipeline import Pipeline from sklearn.preprocessing import PolynomialFeatures", "words": [{"w": "from", "b": [0.1766, 0.6406, 0.2103, 0.6534]}, {"w": "sklearn.datasets", "b": [0.2188, 0.6406, 0.3537, 0.6534]}, {"w": "import", "b": [0.3621, 0.6406, 0.4127, 0.6534]}, {"w": "make_moons", "b": [0.4211, 0.6406, 0.5055, 0.6534]}, {"w": "from", "b": [0.1766, 0.656, 0.2103, 0.6688]}, {"w": "sklearn.pipeline", "b": [0.2188, 0.656, 0.3537, 0.6688]}, {"w": "import", "b": [0.3621, 0.656, 0.4127, 0.6688]}, {"w": "Pipeline", "b": [0.4211, 0.656, 0.4886, 0.6688]}, {"w": "from", "b": [0.1766, 0.6714, 0.2103, 0.6843]}, {"w": "sklearn.preprocessing", "b": [0.2188, 0.6714, 0.3958, 0.6843]}, {"w": "import", "b": [0.4043, 0.6714, 0.4549, 0.6843]}, {"w": "PolynomialFeatures", "b": [0.4633, 0.6714, 0.6151, 0.6843]}]}, {"id": "b_5", "type": "paragraph", "text": "polynomial_svm_clf = Pipeline([ (\"poly_features\", PolynomialFeatures(degree=3)), (\"scaler\", StandardScaler()), (\"svm_clf\", LinearSVC(C=10, loss=\"hinge\")) ])", "words": [{"w": "polynomial_svm_clf", "b": [0.1766, 0.7023, 0.3284, 0.7151]}, {"w": "=", "b": [0.3368, 0.7023, 0.3452, 0.7151]}, {"w": "Pipeline([", "b": [0.3537, 0.7023, 0.438, 0.7151]}, {"w": "(\"poly_features\",", "b": [0.244, 0.7177, 0.3874, 0.7305]}, {"w": "PolynomialFeatures(degree=3)),", "b": [0.3958, 0.7177, 0.6488, 0.7305]}, {"w": "(\"scaler\",", "b": [0.244, 0.7331, 0.3284, 0.7459]}, {"w": "StandardScaler()),", "b": [0.3368, 0.7331, 0.4886, 0.7459]}, {"w": "(\"svm_clf\",", "b": [0.244, 0.7485, 0.3368, 0.7614]}, {"w": "LinearSVC(C=10,", "b": [0.3452, 0.7485, 0.4717, 0.7614]}, {"w": "loss=\"hinge\"))", "b": [0.4802, 0.7485, 0.5982, 0.7614]}, {"w": "])", "b": [0.2103, 0.7639, 0.2272, 0.7768]}]}, {"id": "b_6", "type": "equation", "text": "polynomial_svm_clf.fit(X, y)", "words": [{"w": "polynomial_svm_clf.fit(X,", "b": [0.1766, 0.7948, 0.3874, 0.8076]}, {"w": "y)", "b": [0.3958, 0.7948, 0.4127, 0.8076]}]}, {"id": "b_7", "type": "paragraph", "text": "Nonlinear SVM Classification | 159", "words": [{"w": "Nonlinear", "b": [0.6295, 0.9225, 0.6875, 0.9388]}, {"w": "SVM", "b": [0.6903, 0.9225, 0.716, 0.9388]}, {"w": "Classification", "b": [0.7188, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "159", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 186, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 5-6. Linear SVM classifier using polynomial features", "words": [{"w": "Figure", "b": [0.1429, 0.4376, 0.1943, 0.4592]}, {"w": "5-6.", "b": [0.1991, 0.4376, 0.2308, 0.4592]}, {"w": "Linear", "b": [0.2356, 0.4376, 0.2883, 0.4592]}, {"w": "SVM", "b": [0.293, 0.4376, 0.3351, 0.4592]}, {"w": "classifier", "b": [0.3399, 0.4376, 0.41, 0.4592]}, {"w": "using", "b": [0.4147, 0.4376, 0.4577, 0.4592]}, {"w": "polynomial", "b": [0.4625, 0.4376, 0.5538, 0.4592]}, {"w": "features", "b": [0.5586, 0.4376, 0.6214, 0.4592]}]}, {"id": "b_1", "type": "paragraph", "text": "Polynomial Kernel", "words": [{"w": "Polynomial", "b": [0.1428, 0.4723, 0.2595, 0.5008]}, {"w": "Kernel", "b": [0.2645, 0.4723, 0.3314, 0.5008]}]}, {"id": "b_2", "type": "paragraph", "text": "Adding polynomial features is simple to implement and can work great with all sorts of Machine Learning algorithms (not just SVMs), but at a low polynomial degree it cannot deal with very complex datasets, and with a high polynomial degree it creates a huge number of features, making the model too slow.", "words": [{"w": "Adding", "b": [0.1429, 0.5067, 0.2054, 0.5281]}, {"w": "polynomial", "b": [0.211, 0.5067, 0.3065, 0.5281]}, {"w": "features", "b": [0.3121, 0.5067, 0.3775, 0.5281]}, {"w": "is", "b": [0.3831, 0.5067, 0.3963, 0.5281]}, {"w": "simple", "b": [0.4019, 0.5067, 0.4569, 0.5281]}, {"w": "to", "b": [0.4625, 0.5067, 0.4795, 0.5281]}, {"w": "implement", "b": [0.4851, 0.5067, 0.5756, 0.5281]}, {"w": "and", "b": [0.5812, 0.5067, 0.6128, 0.5281]}, {"w": "can", "b": [0.6184, 0.5067, 0.6477, 0.5281]}, {"w": "work", "b": [0.6533, 0.5067, 0.6963, 0.5281]}, {"w": "great", "b": [0.7019, 0.5067, 0.7433, 0.5281]}, {"w": "with", "b": [0.7489, 0.5067, 0.7863, 0.5281]}, {"w": "all", "b": [0.7919, 0.5067, 0.8115, 0.5281]}, {"w": "sorts", "b": [0.8171, 0.5067, 0.8571, 0.5281]}, {"w": "of", "b": [0.1428, 0.5258, 0.1596, 0.5472]}, {"w": "Machine", "b": [0.1662, 0.5258, 0.2393, 0.5472]}, {"w": "Learning", "b": [0.2459, 0.5258, 0.321, 0.5472]}, {"w": "algorithms", "b": [0.3276, 0.5258, 0.4178, 0.5472]}, {"w": "(not", "b": [0.4244, 0.5258, 0.46, 0.5472]}, {"w": "just", "b": [0.4666, 0.5258, 0.497, 0.5472]}, {"w": "SVMs),", "b": [0.5036, 0.5258, 0.5662, 0.5472]}, {"w": "but", "b": [0.5728, 0.5258, 0.6008, 0.5472]}, {"w": "at", "b": [0.6074, 0.5258, 0.6225, 0.5472]}, {"w": "a", "b": [0.6291, 0.5258, 0.6382, 0.5472]}, {"w": "low", "b": [0.6448, 0.5258, 0.675, 0.5472]}, {"w": "polynomial", "b": [0.6815, 0.5258, 0.777, 0.5472]}, {"w": "degree", "b": [0.7836, 0.5258, 0.8386, 0.5472]}, {"w": "it", "b": [0.8452, 0.5258, 0.8571, 0.5472]}, {"w": "cannot", "b": [0.1429, 0.5448, 0.2006, 0.5662]}, {"w": "deal", "b": [0.2061, 0.5448, 0.2404, 0.5662]}, {"w": "with", "b": [0.2459, 0.5448, 0.2833, 0.5662]}, {"w": "very", "b": [0.2888, 0.5448, 0.3252, 0.5662]}, {"w": "complex", "b": [0.3308, 0.5448, 0.4017, 0.5662]}, {"w": "datasets,", "b": [0.4073, 0.5448, 0.4778, 0.5662]}, {"w": "and", "b": [0.4833, 0.5448, 0.5149, 0.5662]}, {"w": "with", "b": [0.5204, 0.5448, 0.5577, 0.5662]}, {"w": "a", "b": [0.5633, 0.5448, 0.5724, 0.5662]}, {"w": "high", "b": [0.578, 0.5448, 0.6155, 0.5662]}, {"w": "polynomial", "b": [0.6211, 0.5448, 0.7165, 0.5662]}, {"w": "degree", "b": [0.7221, 0.5448, 0.7771, 0.5662]}, {"w": "it", "b": [0.7827, 0.5448, 0.7946, 0.5662]}, {"w": "creates", "b": [0.8001, 0.5448, 0.8571, 0.5662]}, {"w": "a", "b": [0.1429, 0.5639, 0.152, 0.5853]}, {"w": "huge", "b": [0.1567, 0.5639, 0.1971, 0.5853]}, {"w": "number", "b": [0.2019, 0.5639, 0.2681, 0.5853]}, {"w": "of", "b": [0.2729, 0.5639, 0.2897, 0.5853]}, {"w": "features,", "b": [0.2944, 0.5639, 0.3646, 0.5853]}, {"w": "making", "b": [0.3693, 0.5639, 0.4326, 0.5853]}, {"w": "the", "b": [0.4373, 0.5639, 0.4636, 0.5853]}, {"w": "model", "b": [0.4684, 0.5639, 0.5212, 0.5853]}, {"w": "too", "b": [0.5259, 0.5639, 0.5535, 0.5853]}, {"w": "slow.", "b": [0.5582, 0.5639, 0.5993, 0.5853]}]}, {"id": "b_3", "type": "paragraph", "text": "Fortunately, when using SVMs you can apply an almost miraculous mathematical technique called the kernel trick (it is explained in a moment). It makes it possible to get the same result as if you added many polynomial features, even with very high- degree polynomials, without actually having to add them. So there is no combinato‐ rial explosion of the number of features since you don’t actually add any features. This trick is implemented by the SVC class. Let’s test it on the moons dataset:", "words": [{"w": "Fortunately,", "b": [0.1429, 0.592, 0.2427, 0.6134]}, {"w": "when", "b": [0.251, 0.592, 0.2966, 0.6134]}, {"w": "using", "b": [0.3049, 0.592, 0.3503, 0.6134]}, {"w": "SVMs", "b": [0.3586, 0.592, 0.4093, 0.6134]}, {"w": "you", "b": [0.4176, 0.592, 0.4489, 0.6134]}, {"w": "can", "b": [0.4572, 0.592, 0.4865, 0.6134]}, {"w": "apply", "b": [0.4948, 0.592, 0.5402, 0.6134]}, {"w": "an", "b": [0.5485, 0.592, 0.5691, 0.6134]}, {"w": "almost", "b": [0.5773, 0.592, 0.6334, 0.6134]}, {"w": "miraculous", "b": [0.6417, 0.592, 0.7357, 0.6134]}, {"w": "mathematical", "b": [0.744, 0.592, 0.8571, 0.6134]}, {"w": "technique", "b": [0.1429, 0.611, 0.2255, 0.6324]}, {"w": "called", "b": [0.2313, 0.611, 0.2796, 0.6324]}, {"w": "the", "b": [0.2853, 0.611, 0.3117, 0.6324]}, {"w": "kernel", "b": [0.3174, 0.6108, 0.3673, 0.6324]}, {"w": "trick", "b": [0.3731, 0.6108, 0.4102, 0.6324]}, {"w": "(it", "b": [0.4159, 0.611, 0.4351, 0.6324]}, {"w": "is", "b": [0.4408, 0.611, 0.454, 0.6324]}, {"w": "explained", "b": [0.4597, 0.611, 0.5406, 0.6324]}, {"w": "in", "b": [0.5463, 0.611, 0.5633, 0.6324]}, {"w": "a", "b": [0.569, 0.611, 0.5782, 0.6324]}, {"w": "moment).", "b": [0.5839, 0.611, 0.6668, 0.6324]}, {"w": "It", "b": [0.6725, 0.611, 0.6852, 0.6324]}, {"w": "makes", "b": [0.6909, 0.611, 0.7439, 0.6324]}, {"w": "it", "b": [0.7497, 0.611, 0.7616, 0.6324]}, {"w": "possible", "b": [0.7673, 0.611, 0.8344, 0.6324]}, {"w": "to", "b": [0.8402, 0.611, 0.8571, 0.6324]}, {"w": "get", "b": [0.1429, 0.6301, 0.1678, 0.6515]}, {"w": "the", "b": [0.1745, 0.6301, 0.2008, 0.6515]}, {"w": "same", "b": [0.2074, 0.6301, 0.2501, 0.6515]}, {"w": "result", "b": [0.2567, 0.6301, 0.3037, 0.6515]}, {"w": "as", "b": [0.3103, 0.6301, 0.3271, 0.6515]}, {"w": "if", "b": [0.3337, 0.6301, 0.3455, 0.6515]}, {"w": "you", "b": [0.3521, 0.6301, 0.3833, 0.6515]}, {"w": "added", "b": [0.39, 0.6301, 0.441, 0.6515]}, {"w": "many", "b": [0.4476, 0.6301, 0.4943, 0.6515]}, {"w": "polynomial", "b": [0.5009, 0.6301, 0.5964, 0.6515]}, {"w": "features,", "b": [0.603, 0.6301, 0.6732, 0.6515]}, {"w": "even", "b": [0.6798, 0.6301, 0.7185, 0.6515]}, {"w": "with", "b": [0.7252, 0.6301, 0.7625, 0.6515]}, {"w": "very", "b": [0.7691, 0.6301, 0.8055, 0.6515]}, {"w": "high-", "b": [0.8122, 0.6301, 0.8572, 0.6515]}, {"w": "degree", "b": [0.1429, 0.6491, 0.1979, 0.6705]}, {"w": "polynomials,", "b": [0.204, 0.6491, 0.3118, 0.6705]}, {"w": "without", "b": [0.3179, 0.6491, 0.3833, 0.6705]}, {"w": "actually", "b": [0.3894, 0.6491, 0.454, 0.6705]}, {"w": "having", "b": [0.4601, 0.6491, 0.5163, 0.6705]}, {"w": "to", "b": [0.5224, 0.6491, 0.5394, 0.6705]}, {"w": "add", "b": [0.5455, 0.6491, 0.5766, 0.6705]}, {"w": "them.", "b": [0.5827, 0.6491, 0.6309, 0.6705]}, {"w": "So", "b": [0.6369, 0.6491, 0.6574, 0.6705]}, {"w": "there", "b": [0.6635, 0.6491, 0.7064, 0.6705]}, {"w": "is", "b": [0.7125, 0.6491, 0.7258, 0.6705]}, {"w": "no", "b": [0.7318, 0.6491, 0.7539, 0.6705]}, {"w": "combinato‐", "b": [0.7599, 0.6491, 0.8571, 0.6705]}, {"w": "rial", "b": [0.1429, 0.6682, 0.1706, 0.6896]}, {"w": "explosion", "b": [0.1753, 0.6682, 0.2561, 0.6896]}, {"w": "of", "b": [0.2608, 0.6682, 0.2776, 0.6896]}, {"w": "the", "b": [0.2823, 0.6682, 0.3086, 0.6896]}, {"w": "number", "b": [0.3134, 0.6682, 0.3797, 0.6896]}, {"w": "of", "b": [0.3844, 0.6682, 0.4012, 0.6896]}, {"w": "features", "b": [0.4059, 0.6682, 0.4713, 0.6896]}, {"w": "since", "b": [0.4761, 0.6682, 0.5184, 0.6896]}, {"w": "you", "b": [0.5231, 0.6682, 0.5543, 0.6896]}, {"w": "don’t", "b": [0.5591, 0.6682, 0.6007, 0.6896]}, {"w": "actually", "b": [0.6054, 0.6682, 0.67, 0.6896]}, {"w": "add", "b": [0.6747, 0.6682, 0.7059, 0.6896]}, {"w": "any", "b": [0.7106, 0.6682, 0.7402, 0.6896]}, {"w": "features.", "b": [0.745, 0.6682, 0.8151, 0.6896]}, {"w": "This", "b": [0.8199, 0.6682, 0.8571, 0.6896]}, {"w": "trick", "b": [0.1429, 0.6881, 0.1817, 0.7095]}, {"w": "is", "b": [0.1864, 0.6881, 0.1996, 0.7095]}, {"w": "implemented", "b": [0.2044, 0.6881, 0.3148, 0.7095]}, {"w": "by", "b": [0.3195, 0.6881, 0.3396, 0.7095]}, {"w": "the", "b": [0.3444, 0.6881, 0.3707, 0.7095]}, {"w": "SVC", "b": [0.3754, 0.6913, 0.4051, 0.7064]}, {"w": "class.", "b": [0.4099, 0.6881, 0.4531, 0.7095]}, {"w": "Let’s", "b": [0.4579, 0.6881, 0.494, 0.7095]}, {"w": "test", "b": [0.4987, 0.6881, 0.528, 0.7095]}, {"w": "it", "b": [0.5327, 0.6881, 0.5446, 0.7095]}, {"w": "on", "b": [0.5494, 0.6881, 0.5714, 0.7095]}, {"w": "the", "b": [0.5761, 0.6881, 0.6024, 0.7095]}, {"w": "moons", "b": [0.6072, 0.6881, 0.6645, 0.7095]}, {"w": "dataset:", "b": [0.6692, 0.6881, 0.7321, 0.7095]}]}, {"id": "b_4", "type": "paragraph", "text": "from sklearn.svm import SVC poly_kernel_svm_clf = Pipeline([ (\"scaler\", StandardScaler()), (\"svm_clf\", SVC(kernel=\"poly\", degree=3, coef0=1, C=5)) ]) poly_kernel_svm_clf.fit(X, y)", "words": [{"w": "from", "b": [0.1766, 0.7201, 0.2103, 0.7329]}, {"w": "sklearn.svm", "b": [0.2187, 0.7201, 0.3115, 0.7329]}, {"w": "import", "b": [0.3199, 0.7201, 0.3705, 0.7329]}, {"w": "SVC", "b": [0.379, 0.7201, 0.4043, 0.7329]}, {"w": "poly_kernel_svm_clf", "b": [0.1766, 0.7355, 0.3368, 0.7484]}, {"w": "=", "b": [0.3452, 0.7355, 0.3537, 0.7484]}, {"w": "Pipeline([", "b": [0.3621, 0.7355, 0.4464, 0.7484]}, {"w": "(\"scaler\",", "b": [0.244, 0.7509, 0.3284, 0.7638]}, {"w": "StandardScaler()),", "b": [0.3368, 0.7509, 0.4886, 0.7638]}, {"w": "(\"svm_clf\",", "b": [0.244, 0.7664, 0.3368, 0.7792]}, {"w": "SVC(kernel=\"poly\",", "b": [0.3452, 0.7664, 0.497, 0.7792]}, {"w": "degree=3,", "b": [0.5055, 0.7664, 0.5813, 0.7792]}, {"w": "coef0=1,", "b": [0.5898, 0.7664, 0.6572, 0.7792]}, {"w": "C=5))", "b": [0.6657, 0.7664, 0.7078, 0.7792]}, {"w": "])", "b": [0.2103, 0.7818, 0.2272, 0.7946]}, {"w": "poly_kernel_svm_clf.fit(X,", "b": [0.1766, 0.7972, 0.3958, 0.81]}, {"w": "y)", "b": [0.4043, 0.7972, 0.4211, 0.81]}]}, {"id": "b_5", "type": "paragraph", "text": "This code trains an SVM classifier using a 3rd-degree polynomial kernel. It is repre‐ sented on the left of Figure 5-7. On the right is another SVM classifier using a 10th- degree polynomial kernel. Obviously, if your model is overfitting, you might want to", "words": [{"w": "This", "b": [0.1429, 0.8178, 0.1801, 0.8392]}, {"w": "code", "b": [0.1866, 0.8178, 0.2259, 0.8392]}, {"w": "trains", "b": [0.2325, 0.8178, 0.2804, 0.8392]}, {"w": "an", "b": [0.287, 0.8178, 0.3075, 0.8392]}, {"w": "SVM", "b": [0.3141, 0.8178, 0.3572, 0.8392]}, {"w": "classifier", "b": [0.3637, 0.8178, 0.4362, 0.8392]}, {"w": "using", "b": [0.4428, 0.8178, 0.4882, 0.8392]}, {"w": "a", "b": [0.4948, 0.8178, 0.5039, 0.8392]}, {"w": "3rd-degree", "b": [0.5105, 0.8178, 0.5942, 0.8392]}, {"w": "polynomial", "b": [0.6008, 0.8178, 0.6963, 0.8392]}, {"w": "kernel.", "b": [0.7028, 0.8178, 0.76, 0.8392]}, {"w": "It", "b": [0.7666, 0.8178, 0.7792, 0.8392]}, {"w": "is", "b": [0.7858, 0.8178, 0.7991, 0.8392]}, {"w": "repre‐", "b": [0.8056, 0.8178, 0.8571, 0.8392]}, {"w": "sented", "b": [0.1429, 0.8369, 0.1966, 0.8583]}, {"w": "on", "b": [0.203, 0.8369, 0.225, 0.8583]}, {"w": "the", "b": [0.2314, 0.8369, 0.2578, 0.8583]}, {"w": "left", "b": [0.2642, 0.8369, 0.2908, 0.8583]}, {"w": "of", "b": [0.2972, 0.8369, 0.314, 0.8583]}, {"w": "Figure", "b": [0.3204, 0.8369, 0.3744, 0.8583]}, {"w": "5-7.", "b": [0.3809, 0.8369, 0.413, 0.8583]}, {"w": "On", "b": [0.4195, 0.8369, 0.4464, 0.8583]}, {"w": "the", "b": [0.4528, 0.8369, 0.4792, 0.8583]}, {"w": "right", "b": [0.4856, 0.8369, 0.5257, 0.8583]}, {"w": "is", "b": [0.5322, 0.8369, 0.5454, 0.8583]}, {"w": "another", "b": [0.5518, 0.8369, 0.617, 0.8583]}, {"w": "SVM", "b": [0.6234, 0.8369, 0.6665, 0.8583]}, {"w": "classifier", "b": [0.673, 0.8369, 0.7454, 0.8583]}, {"w": "using", "b": [0.7518, 0.8369, 0.7972, 0.8583]}, {"w": "a", "b": [0.8037, 0.8369, 0.8128, 0.8583]}, {"w": "10th-", "b": [0.8192, 0.8369, 0.8571, 0.8583]}, {"w": "degree", "b": [0.1429, 0.8559, 0.1979, 0.8773]}, {"w": "polynomial", "b": [0.2037, 0.8559, 0.2992, 0.8773]}, {"w": "kernel.", "b": [0.305, 0.8559, 0.3622, 0.8773]}, {"w": "Obviously,", "b": [0.368, 0.8559, 0.4568, 0.8773]}, {"w": "if", "b": [0.4626, 0.8559, 0.4743, 0.8773]}, {"w": "your", "b": [0.4802, 0.8559, 0.5191, 0.8773]}, {"w": "model", "b": [0.5249, 0.8559, 0.5778, 0.8773]}, {"w": "is", "b": [0.5836, 0.8559, 0.5968, 0.8773]}, {"w": "overfitting,", "b": [0.6026, 0.8559, 0.6954, 0.8773]}, {"w": "you", "b": [0.7012, 0.8559, 0.7325, 0.8773]}, {"w": "might", "b": [0.7383, 0.8559, 0.7878, 0.8773]}, {"w": "want", "b": [0.7936, 0.8559, 0.8344, 0.8773]}, {"w": "to", "b": [0.8402, 0.8559, 0.8572, 0.8773]}]}, {"id": "b_6", "type": "paragraph", "text": "160 | Chapter 5: Support Vector Machines", "words": [{"w": "160", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "5:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Support", "b": [0.2673, 0.9225, 0.3142, 0.9388]}, {"w": "Vector", "b": [0.317, 0.9225, 0.3547, 0.9388]}, {"w": "Machines", "b": [0.3575, 0.9225, 0.413, 0.9388]}]}]}, {"page": 187, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "reduce the polynomial degree. Conversely, if it is underfitting, you can try increasing it. The hyperparameter coef0 controls how much the model is influenced by high- degree polynomials versus low-degree polynomials.", "words": [{"w": "reduce", "b": [0.1429, 0.0791, 0.1992, 0.1005]}, {"w": "the", "b": [0.2047, 0.0791, 0.231, 0.1005]}, {"w": "polynomial", "b": [0.2366, 0.0791, 0.3321, 0.1005]}, {"w": "degree.", "b": [0.3376, 0.0791, 0.3974, 0.1005]}, {"w": "Conversely,", "b": [0.4029, 0.0791, 0.4991, 0.1005]}, {"w": "if", "b": [0.5047, 0.0791, 0.5164, 0.1005]}, {"w": "it", "b": [0.522, 0.0791, 0.5339, 0.1005]}, {"w": "is", "b": [0.5395, 0.0791, 0.5527, 0.1005]}, {"w": "underfitting,", "b": [0.5582, 0.0791, 0.6642, 0.1005]}, {"w": "you", "b": [0.6698, 0.0791, 0.701, 0.1005]}, {"w": "can", "b": [0.7066, 0.0791, 0.7359, 0.1005]}, {"w": "try", "b": [0.7415, 0.0791, 0.7657, 0.1005]}, {"w": "increasing", "b": [0.7712, 0.0791, 0.8571, 0.1005]}, {"w": "it.", "b": [0.1429, 0.099, 0.1595, 0.1204]}, {"w": "The", "b": [0.1665, 0.099, 0.1994, 0.1204]}, {"w": "hyperparameter", "b": [0.2064, 0.099, 0.3399, 0.1204]}, {"w": "coef0", "b": [0.3469, 0.1022, 0.3964, 0.1173]}, {"w": "controls", "b": [0.4034, 0.099, 0.4715, 0.1204]}, {"w": "how", "b": [0.4785, 0.099, 0.5145, 0.1204]}, {"w": "much", "b": [0.5215, 0.099, 0.5692, 0.1204]}, {"w": "the", "b": [0.5762, 0.099, 0.6025, 0.1204]}, {"w": "model", "b": [0.6095, 0.099, 0.6623, 0.1204]}, {"w": "is", "b": [0.6693, 0.099, 0.6826, 0.1204]}, {"w": "influenced", "b": [0.6896, 0.099, 0.778, 0.1204]}, {"w": "by", "b": [0.785, 0.099, 0.8051, 0.1204]}, {"w": "high-", "b": [0.8121, 0.099, 0.8571, 0.1204]}, {"w": "degree", "b": [0.1429, 0.1181, 0.1979, 0.1395]}, {"w": "polynomials", "b": [0.2026, 0.1181, 0.3057, 0.1395]}, {"w": "versus", "b": [0.3105, 0.1181, 0.3631, 0.1395]}, {"w": "low-degree", "b": [0.3678, 0.1181, 0.4604, 0.1395]}, {"w": "polynomials.", "b": [0.4651, 0.1181, 0.573, 0.1395]}]}, {"id": "b_1", "type": "equation", "text": "Figure 5-7. SVM classifiers with a polynomial kernel", "words": [{"w": "Figure", "b": [0.1429, 0.345, 0.1943, 0.3666]}, {"w": "5-7.", "b": [0.1991, 0.345, 0.2308, 0.3666]}, {"w": "SVM", "b": [0.2356, 0.345, 0.2776, 0.3666]}, {"w": "classifiers", "b": [0.2824, 0.345, 0.3595, 0.3666]}, {"w": "with", "b": [0.3643, 0.345, 0.4008, 0.3666]}, {"w": "a", "b": [0.4056, 0.345, 0.4158, 0.3666]}, {"w": "polynomial", "b": [0.4205, 0.345, 0.5118, 0.3666]}, {"w": "kernel", "b": [0.5166, 0.345, 0.5665, 0.3666]}]}, {"id": "b_2", "type": "paragraph", "text": "A common approach to find the right hyperparameter values is to use grid search (see Chapter 2). It is often faster to first do a very coarse grid search, then a finer grid search around the best values found. Having a good sense of what each hyperparameter actually does can also help you search in the right part of the hyperparame‐ ter space.", "words": [{"w": "A", "b": [0.2714, 0.3871, 0.2846, 0.4067]}, {"w": "common", "b": [0.2902, 0.3871, 0.3593, 0.4067]}, {"w": "approach", "b": [0.3649, 0.3871, 0.4363, 0.4067]}, {"w": "to", "b": [0.4419, 0.3871, 0.4574, 0.4067]}, {"w": "find", "b": [0.4631, 0.3871, 0.4943, 0.4067]}, {"w": "the", "b": [0.4999, 0.3871, 0.524, 0.4067]}, {"w": "right", "b": [0.5296, 0.3871, 0.5663, 0.4067]}, {"w": "hyperparameter", "b": [0.5719, 0.3871, 0.694, 0.4067]}, {"w": "values", "b": [0.6996, 0.3871, 0.7468, 0.4067]}, {"w": "is", "b": [0.7525, 0.3871, 0.7646, 0.4067]}, {"w": "to", "b": [0.7702, 0.3871, 0.7857, 0.4067]}, {"w": "use", "b": [0.2714, 0.4045, 0.2966, 0.4241]}, {"w": "grid", "b": [0.3027, 0.4045, 0.3338, 0.4241]}, {"w": "search", "b": [0.3399, 0.4045, 0.3886, 0.4241]}, {"w": "(see", "b": [0.3947, 0.4045, 0.4244, 0.4241]}, {"w": "Chapter", "b": [0.4305, 0.4045, 0.4923, 0.4241]}, {"w": "2).", "b": [0.4983, 0.4045, 0.5184, 0.4241]}, {"w": "It", "b": [0.5245, 0.4045, 0.536, 0.4241]}, {"w": "is", "b": [0.5421, 0.4045, 0.5542, 0.4241]}, {"w": "often", "b": [0.5602, 0.4045, 0.5999, 0.4241]}, {"w": "faster", "b": [0.6059, 0.4045, 0.6479, 0.4241]}, {"w": "to", "b": [0.654, 0.4045, 0.6695, 0.4241]}, {"w": "first", "b": [0.6755, 0.4045, 0.7061, 0.4241]}, {"w": "do", "b": [0.7122, 0.4045, 0.732, 0.4241]}, {"w": "a", "b": [0.738, 0.4045, 0.7464, 0.4241]}, {"w": "very", "b": [0.7524, 0.4045, 0.7857, 0.4241]}, {"w": "coarse", "b": [0.2714, 0.4219, 0.3197, 0.4415]}, {"w": "grid", "b": [0.3256, 0.4219, 0.3568, 0.4415]}, {"w": "search,", "b": [0.3627, 0.4219, 0.4158, 0.4415]}, {"w": "then", "b": [0.4217, 0.4219, 0.4562, 0.4415]}, {"w": "a", "b": [0.4621, 0.4219, 0.4705, 0.4415]}, {"w": "finer", "b": [0.4764, 0.4219, 0.5127, 0.4415]}, {"w": "grid", "b": [0.5186, 0.4219, 0.5498, 0.4415]}, {"w": "search", "b": [0.5557, 0.4219, 0.6044, 0.4415]}, {"w": "around", "b": [0.6104, 0.4219, 0.6661, 0.4415]}, {"w": "the", "b": [0.672, 0.4219, 0.6961, 0.4415]}, {"w": "best", "b": [0.702, 0.4219, 0.7326, 0.4415]}, {"w": "values", "b": [0.7385, 0.4219, 0.7857, 0.4415]}, {"w": "found.", "b": [0.2714, 0.4394, 0.3217, 0.4589]}, {"w": "Having", "b": [0.3276, 0.4394, 0.383, 0.4589]}, {"w": "a", "b": [0.3889, 0.4394, 0.3973, 0.4589]}, {"w": "good", "b": [0.4032, 0.4394, 0.4416, 0.4589]}, {"w": "sense", "b": [0.4474, 0.4394, 0.488, 0.4589]}, {"w": "of", "b": [0.4939, 0.4394, 0.5093, 0.4589]}, {"w": "what", "b": [0.5152, 0.4394, 0.5522, 0.4589]}, {"w": "each", "b": [0.5581, 0.4394, 0.5928, 0.4589]}, {"w": "hyperparameter", "b": [0.5987, 0.4394, 0.7207, 0.4589]}, {"w": "actually", "b": [0.7266, 0.4394, 0.7857, 0.4589]}, {"w": "does", "b": [0.2714, 0.4568, 0.3063, 0.4763]}, {"w": "can", "b": [0.3111, 0.4568, 0.3379, 0.4763]}, {"w": "also", "b": [0.3427, 0.4568, 0.3726, 0.4763]}, {"w": "help", "b": [0.3774, 0.4568, 0.4104, 0.4763]}, {"w": "you", "b": [0.4152, 0.4568, 0.4438, 0.4763]}, {"w": "search", "b": [0.4486, 0.4568, 0.4973, 0.4763]}, {"w": "in", "b": [0.5021, 0.4568, 0.5177, 0.4763]}, {"w": "the", "b": [0.5225, 0.4568, 0.5465, 0.4763]}, {"w": "right", "b": [0.5513, 0.4568, 0.588, 0.4763]}, {"w": "part", "b": [0.5928, 0.4568, 0.624, 0.4763]}, {"w": "of", "b": [0.6288, 0.4568, 0.6442, 0.4763]}, {"w": "the", "b": [0.649, 0.4568, 0.6731, 0.4763]}, {"w": "hyperparame‐", "b": [0.6779, 0.4568, 0.7857, 0.4763]}, {"w": "ter", "b": [0.2714, 0.4742, 0.2924, 0.4938]}, {"w": "space.", "b": [0.2967, 0.4742, 0.3425, 0.4938]}]}, {"id": "b_3", "type": "paragraph", "text": "Adding Similarity Features", "words": [{"w": "Adding", "b": [0.1428, 0.5113, 0.2168, 0.5399]}, {"w": "Similarity", "b": [0.2217, 0.5113, 0.3213, 0.5399]}, {"w": "Features", "b": [0.3262, 0.5113, 0.4154, 0.5399]}]}, {"id": "b_4", "type": "paragraph", "text": "Another technique to tackle nonlinear problems is to add features computed using a similarity function that measures how much each instance resembles a particular landmark. For example, let’s take the one-dimensional dataset discussed earlier and add two landmarks to it at x1 = –2 and x1 = 1 (see the left plot in Figure 5-8). Next, let’s define the similarity function to be the Gaussian Radial Basis Function (RBF) with γ = 0.3 (see Equation 5-1).", "words": [{"w": "Another", "b": [0.1429, 0.5458, 0.2133, 0.5672]}, {"w": "technique", "b": [0.2191, 0.5458, 0.3018, 0.5672]}, {"w": "to", "b": [0.3076, 0.5458, 0.3246, 0.5672]}, {"w": "tackle", "b": [0.3304, 0.5458, 0.3792, 0.5672]}, {"w": "nonlinear", "b": [0.385, 0.5458, 0.4664, 0.5672]}, {"w": "problems", "b": [0.4722, 0.5458, 0.5509, 0.5672]}, {"w": "is", "b": [0.5567, 0.5458, 0.5699, 0.5672]}, {"w": "to", "b": [0.5757, 0.5458, 0.5927, 0.5672]}, {"w": "add", "b": [0.5985, 0.5458, 0.6296, 0.5672]}, {"w": "features", "b": [0.6354, 0.5458, 0.7009, 0.5672]}, {"w": "computed", "b": [0.7067, 0.5458, 0.791, 0.5672]}, {"w": "using", "b": [0.7968, 0.5458, 0.8422, 0.5672]}, {"w": "a", "b": [0.848, 0.5458, 0.8571, 0.5672]}, {"w": "similarity", "b": [0.1429, 0.5646, 0.2205, 0.5862]}, {"w": "function", "b": [0.2299, 0.5646, 0.298, 0.5862]}, {"w": "that", "b": [0.3074, 0.5648, 0.34, 0.5862]}, {"w": "measures", "b": [0.3493, 0.5648, 0.4273, 0.5862]}, {"w": "how", "b": [0.4367, 0.5648, 0.4727, 0.5862]}, {"w": "much", "b": [0.4821, 0.5648, 0.5298, 0.5862]}, {"w": "each", "b": [0.5391, 0.5648, 0.5771, 0.5862]}, {"w": "instance", "b": [0.5864, 0.5648, 0.6556, 0.5862]}, {"w": "resembles", "b": [0.665, 0.5648, 0.7475, 0.5862]}, {"w": "a", "b": [0.7569, 0.5648, 0.766, 0.5862]}, {"w": "particular", "b": [0.7754, 0.5648, 0.8571, 0.5862]}, {"w": "landmark.", "b": [0.1429, 0.5837, 0.2272, 0.6053]}, {"w": "For", "b": [0.2344, 0.5839, 0.2633, 0.6053]}, {"w": "example,", "b": [0.2705, 0.5839, 0.3448, 0.6053]}, {"w": "let’s", "b": [0.3519, 0.5839, 0.3822, 0.6053]}, {"w": "take", "b": [0.3893, 0.5839, 0.424, 0.6053]}, {"w": "the", "b": [0.4312, 0.5839, 0.4575, 0.6053]}, {"w": "one-dimensional", "b": [0.4646, 0.5839, 0.6065, 0.6053]}, {"w": "dataset", "b": [0.6136, 0.5839, 0.6717, 0.6053]}, {"w": "discussed", "b": [0.6789, 0.5839, 0.7581, 0.6053]}, {"w": "earlier", "b": [0.7653, 0.5839, 0.8185, 0.6053]}, {"w": "and", "b": [0.8256, 0.5839, 0.8572, 0.6053]}, {"w": "add", "b": [0.1429, 0.6029, 0.174, 0.6243]}, {"w": "two", "b": [0.1804, 0.6029, 0.2116, 0.6243]}, {"w": "landmarks", "b": [0.218, 0.6029, 0.3067, 0.6243]}, {"w": "to", "b": [0.313, 0.6029, 0.33, 0.6243]}, {"w": "it", "b": [0.3364, 0.6029, 0.3483, 0.6243]}, {"w": "at", "b": [0.3547, 0.6029, 0.3698, 0.6243]}, {"w": "x1", "b": [0.3761, 0.6027, 0.392, 0.6252]}, {"w": "=", "b": [0.3983, 0.6029, 0.4104, 0.6243]}, {"w": "–2", "b": [0.4168, 0.6029, 0.4376, 0.6243]}, {"w": "and", "b": [0.444, 0.6029, 0.4755, 0.6243]}, {"w": "x1", "b": [0.4819, 0.6027, 0.4977, 0.6252]}, {"w": "=", "b": [0.5041, 0.6029, 0.5162, 0.6243]}, {"w": "1", "b": [0.5225, 0.6029, 0.5325, 0.6243]}, {"w": "(see", "b": [0.5389, 0.6029, 0.5714, 0.6243]}, {"w": "the", "b": [0.5778, 0.6029, 0.6041, 0.6243]}, {"w": "left", "b": [0.6105, 0.6029, 0.6371, 0.6243]}, {"w": "plot", "b": [0.6435, 0.6029, 0.6766, 0.6243]}, {"w": "in", "b": [0.683, 0.6029, 0.7, 0.6243]}, {"w": "Figure", "b": [0.7063, 0.6029, 0.7603, 0.6243]}, {"w": "5-8).", "b": [0.7667, 0.6029, 0.806, 0.6243]}, {"w": "Next,", "b": [0.8124, 0.6029, 0.8571, 0.6243]}, {"w": "let’s", "b": [0.1429, 0.622, 0.1731, 0.6434]}, {"w": "define", "b": [0.1812, 0.622, 0.2331, 0.6434]}, {"w": "the", "b": [0.2412, 0.622, 0.2676, 0.6434]}, {"w": "similarity", "b": [0.2757, 0.622, 0.3552, 0.6434]}, {"w": "function", "b": [0.3634, 0.622, 0.4348, 0.6434]}, {"w": "to", "b": [0.4429, 0.622, 0.4599, 0.6434]}, {"w": "be", "b": [0.4681, 0.622, 0.4875, 0.6434]}, {"w": "the", "b": [0.4956, 0.622, 0.522, 0.6434]}, {"w": "Gaussian", "b": [0.5301, 0.622, 0.6063, 0.6434]}, {"w": "Radial", "b": [0.6144, 0.6218, 0.668, 0.6434]}, {"w": "Basis", "b": [0.6762, 0.6218, 0.7181, 0.6434]}, {"w": "Function", "b": [0.7263, 0.6218, 0.7991, 0.6434]}, {"w": "(RBF)", "b": [0.8072, 0.6218, 0.8571, 0.6434]}, {"w": "with", "b": [0.1428, 0.641, 0.1802, 0.6624]}, {"w": "γ", "b": [0.1849, 0.6408, 0.1948, 0.6624]}, {"w": "=", "b": [0.1995, 0.641, 0.2116, 0.6624]}, {"w": "0.3", "b": [0.2163, 0.641, 0.2411, 0.6624]}, {"w": "(see", "b": [0.2458, 0.641, 0.2784, 0.6624]}, {"w": "Equation", "b": [0.2831, 0.641, 0.3593, 0.6624]}, {"w": "5-1).", "b": [0.3641, 0.641, 0.4035, 0.6624]}]}, {"id": "b_5", "type": "equation", "text": "Equation 5-1. Gaussian RBF", "words": [{"w": "Equation", "b": [0.1726, 0.6805, 0.2473, 0.7022]}, {"w": "5-1.", "b": [0.2521, 0.6805, 0.2838, 0.7022]}, {"w": "Gaussian", "b": [0.2886, 0.6805, 0.3641, 0.7022]}, {"w": "RBF", "b": [0.3688, 0.6805, 0.4044, 0.7022]}]}, {"id": "b_6", "type": "equation", "text": "ϕγ x, ℓ= exp −γ∥x −ℓ∥2", "words": [{"w": "ϕγ", "b": [0.1726, 0.7137, 0.1912, 0.7386]}, {"w": "x,", "b": [0.1981, 0.7134, 0.2123, 0.7343]}, {"w": "ℓ=", "b": [0.2156, 0.7139, 0.2476, 0.7343]}, {"w": "exp", "b": [0.2587, 0.7139, 0.2869, 0.7343]}, {"w": "−γ∥x", "b": [0.2992, 0.7134, 0.3462, 0.7343]}, {"w": "−ℓ∥2", "b": [0.3508, 0.7093, 0.3979, 0.7343]}]}, {"id": "b_7", "type": "paragraph", "text": "It is a bell-shaped function varying from 0 (very far away from the landmark) to 1 (at the landmark). Now we are ready to compute the new features. For example, let’s look at the instance x1 = –1: it is located at a distance of 1 from the first landmark, and 2 from the second landmark. Therefore its new features are x2 = exp (–0.3 × 12) ≈ 0.74 and x3 = exp (–0.3 × 22) ≈ 0.30. The plot on the right of Figure 5-8 shows the trans‐ formed dataset (dropping the original features). As you can see, it is now linearly separable.", "words": [{"w": "It", "b": [0.1429, 0.7576, 0.1555, 0.779]}, {"w": "is", "b": [0.1607, 0.7576, 0.174, 0.779]}, {"w": "a", "b": [0.1792, 0.7576, 0.1883, 0.779]}, {"w": "bell-shaped", "b": [0.1936, 0.7576, 0.2892, 0.779]}, {"w": "function", "b": [0.2945, 0.7576, 0.3659, 0.779]}, {"w": "varying", "b": [0.3711, 0.7576, 0.4345, 0.779]}, {"w": "from", "b": [0.4397, 0.7576, 0.4813, 0.779]}, {"w": "0", "b": [0.4866, 0.7576, 0.4966, 0.779]}, {"w": "(very", "b": [0.5018, 0.7576, 0.5454, 0.779]}, {"w": "far", "b": [0.5506, 0.7576, 0.5737, 0.779]}, {"w": "away", "b": [0.5789, 0.7576, 0.6203, 0.779]}, {"w": "from", "b": [0.6255, 0.7576, 0.6671, 0.779]}, {"w": "the", "b": [0.6723, 0.7576, 0.6986, 0.779]}, {"w": "landmark)", "b": [0.7039, 0.7576, 0.7922, 0.779]}, {"w": "to", "b": [0.7974, 0.7576, 0.8144, 0.779]}, {"w": "1", "b": [0.8196, 0.7576, 0.8296, 0.779]}, {"w": "(at", "b": [0.8348, 0.7576, 0.8571, 0.779]}, {"w": "the", "b": [0.1428, 0.7767, 0.1692, 0.7981]}, {"w": "landmark).", "b": [0.1741, 0.7767, 0.2671, 0.7981]}, {"w": "Now", "b": [0.272, 0.7767, 0.3118, 0.7981]}, {"w": "we", "b": [0.3167, 0.7767, 0.3398, 0.7981]}, {"w": "are", "b": [0.3447, 0.7767, 0.3704, 0.7981]}, {"w": "ready", "b": [0.3753, 0.7767, 0.4216, 0.7981]}, {"w": "to", "b": [0.4265, 0.7767, 0.4435, 0.7981]}, {"w": "compute", "b": [0.4483, 0.7767, 0.5216, 0.7981]}, {"w": "the", "b": [0.5265, 0.7767, 0.5528, 0.7981]}, {"w": "new", "b": [0.5577, 0.7767, 0.5922, 0.7981]}, {"w": "features.", "b": [0.5971, 0.7767, 0.6673, 0.7981]}, {"w": "For", "b": [0.6722, 0.7767, 0.7011, 0.7981]}, {"w": "example,", "b": [0.706, 0.7767, 0.7803, 0.7981]}, {"w": "let’s", "b": [0.7852, 0.7767, 0.8154, 0.7981]}, {"w": "look", "b": [0.8203, 0.7767, 0.8571, 0.7981]}, {"w": "at", "b": [0.1429, 0.7957, 0.158, 0.8171]}, {"w": "the", "b": [0.1641, 0.7957, 0.1904, 0.8171]}, {"w": "instance", "b": [0.1966, 0.7957, 0.2658, 0.8171]}, {"w": "x1", "b": [0.2719, 0.7955, 0.2878, 0.818]}, {"w": "=", "b": [0.2939, 0.7957, 0.306, 0.8171]}, {"w": "–1:", "b": [0.3121, 0.7957, 0.3377, 0.8171]}, {"w": "it", "b": [0.3439, 0.7957, 0.3558, 0.8171]}, {"w": "is", "b": [0.3619, 0.7957, 0.3752, 0.8171]}, {"w": "located", "b": [0.3813, 0.7957, 0.441, 0.8171]}, {"w": "at", "b": [0.4471, 0.7957, 0.4622, 0.8171]}, {"w": "a", "b": [0.4684, 0.7957, 0.4775, 0.8171]}, {"w": "distance", "b": [0.4837, 0.7957, 0.5524, 0.8171]}, {"w": "of", "b": [0.5586, 0.7957, 0.5754, 0.8171]}, {"w": "1", "b": [0.5815, 0.7957, 0.5915, 0.8171]}, {"w": "from", "b": [0.5977, 0.7957, 0.6392, 0.8171]}, {"w": "the", "b": [0.6454, 0.7957, 0.6717, 0.8171]}, {"w": "first", "b": [0.6779, 0.7957, 0.7113, 0.8171]}, {"w": "landmark,", "b": [0.7175, 0.7957, 0.8033, 0.8171]}, {"w": "and", "b": [0.8095, 0.7957, 0.841, 0.8171]}, {"w": "2", "b": [0.8471, 0.7957, 0.8571, 0.8171]}, {"w": "from", "b": [0.1429, 0.8148, 0.1844, 0.8362]}, {"w": "the", "b": [0.1902, 0.8148, 0.2165, 0.8362]}, {"w": "second", "b": [0.2222, 0.8148, 0.2806, 0.8362]}, {"w": "landmark.", "b": [0.2863, 0.8148, 0.3721, 0.8362]}, {"w": "Therefore", "b": [0.3778, 0.8148, 0.4606, 0.8362]}, {"w": "its", "b": [0.4663, 0.8148, 0.4859, 0.8362]}, {"w": "new", "b": [0.4917, 0.8148, 0.5262, 0.8362]}, {"w": "features", "b": [0.5319, 0.8148, 0.5973, 0.8362]}, {"w": "are", "b": [0.603, 0.8148, 0.6288, 0.8362]}, {"w": "x2", "b": [0.6345, 0.8146, 0.6503, 0.8371]}, {"w": "=", "b": [0.6561, 0.8148, 0.6682, 0.8362]}, {"w": "exp", "b": [0.6739, 0.8148, 0.7035, 0.8362]}, {"w": "(–0.3", "b": [0.7092, 0.8148, 0.752, 0.8362]}, {"w": "×", "b": [0.7577, 0.8148, 0.7698, 0.8362]}, {"w": "12)", "b": [0.7755, 0.8148, 0.7987, 0.8362]}, {"w": "≈", "b": [0.8045, 0.8148, 0.8167, 0.8362]}, {"w": "0.74", "b": [0.8224, 0.8148, 0.8571, 0.8362]}, {"w": "and", "b": [0.1429, 0.8338, 0.1744, 0.8552]}, {"w": "x3", "b": [0.1805, 0.8336, 0.1963, 0.8561]}, {"w": "=", "b": [0.2024, 0.8338, 0.2145, 0.8552]}, {"w": "exp", "b": [0.2206, 0.8338, 0.2502, 0.8552]}, {"w": "(–0.3", "b": [0.2562, 0.8338, 0.299, 0.8552]}, {"w": "×", "b": [0.3051, 0.8338, 0.3172, 0.8552]}, {"w": "22)", "b": [0.3233, 0.8338, 0.3465, 0.8552]}, {"w": "≈", "b": [0.3525, 0.8338, 0.3647, 0.8552]}, {"w": "0.30.", "b": [0.3708, 0.8338, 0.4103, 0.8552]}, {"w": "The", "b": [0.4164, 0.8338, 0.4492, 0.8552]}, {"w": "plot", "b": [0.4553, 0.8338, 0.4885, 0.8552]}, {"w": "on", "b": [0.4945, 0.8338, 0.5166, 0.8552]}, {"w": "the", "b": [0.5226, 0.8338, 0.549, 0.8552]}, {"w": "right", "b": [0.555, 0.8338, 0.5952, 0.8552]}, {"w": "of", "b": [0.6012, 0.8338, 0.618, 0.8552]}, {"w": "Figure", "b": [0.6241, 0.8338, 0.6781, 0.8552]}, {"w": "5-8", "b": [0.6842, 0.8338, 0.7116, 0.8552]}, {"w": "shows", "b": [0.7177, 0.8338, 0.769, 0.8552]}, {"w": "the", "b": [0.7751, 0.8338, 0.8014, 0.8552]}, {"w": "trans‐", "b": [0.8075, 0.8338, 0.8571, 0.8552]}, {"w": "formed", "b": [0.1429, 0.8529, 0.2043, 0.8743]}, {"w": "dataset", "b": [0.2123, 0.8529, 0.2704, 0.8743]}, {"w": "(dropping", "b": [0.2784, 0.8529, 0.3635, 0.8743]}, {"w": "the", "b": [0.3715, 0.8529, 0.3978, 0.8743]}, {"w": "original", "b": [0.4058, 0.8529, 0.4709, 0.8743]}, {"w": "features).", "b": [0.4789, 0.8529, 0.5562, 0.8743]}, {"w": "As", "b": [0.5642, 0.8529, 0.5863, 0.8743]}, {"w": "you", "b": [0.5943, 0.8529, 0.6255, 0.8743]}, {"w": "can", "b": [0.6335, 0.8529, 0.6628, 0.8743]}, {"w": "see,", "b": [0.6708, 0.8529, 0.7009, 0.8743]}, {"w": "it", "b": [0.7089, 0.8529, 0.7209, 0.8743]}, {"w": "is", "b": [0.7288, 0.8529, 0.7421, 0.8743]}, {"w": "now", "b": [0.7501, 0.8529, 0.7863, 0.8743]}, {"w": "linearly", "b": [0.7943, 0.8529, 0.8571, 0.8743]}, {"w": "separable.", "b": [0.1429, 0.8719, 0.2257, 0.8933]}]}, {"id": "b_8", "type": "paragraph", "text": "Nonlinear SVM Classification | 161", "words": [{"w": "Nonlinear", "b": [0.6295, 0.9225, 0.6875, 0.9388]}, {"w": "SVM", "b": [0.6903, 0.9225, 0.716, 0.9388]}, {"w": "Classification", "b": [0.7188, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "161", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 188, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 5-8. Similarity features using the Gaussian RBF", "words": [{"w": "Figure", "b": [0.1429, 0.2792, 0.1943, 0.3008]}, {"w": "5-8.", "b": [0.1991, 0.2792, 0.2308, 0.3008]}, {"w": "Similarity", "b": [0.2356, 0.2792, 0.3159, 0.3008]}, {"w": "features", "b": [0.3206, 0.2792, 0.3835, 0.3008]}, {"w": "using", "b": [0.3883, 0.2792, 0.4313, 0.3008]}, {"w": "the", "b": [0.436, 0.2792, 0.4611, 0.3008]}, {"w": "Gaussian", "b": [0.4658, 0.2792, 0.5414, 0.3008]}, {"w": "RBF", "b": [0.5461, 0.2792, 0.5816, 0.3008]}]}, {"id": "b_1", "type": "paragraph", "text": "You may wonder how to select the landmarks. The simplest approach is to create a landmark at the location of each and every instance in the dataset. This creates many dimensions and thus increases the chances that the transformed training set will be linearly separable. The downside is that a training set with m instances and n features gets transformed into a training set with m instances and m features (assuming you drop the original features). If your training set is very large, you end up with an equally large number of features.", "words": [{"w": "You", "b": [0.1429, 0.3166, 0.1752, 0.338]}, {"w": "may", "b": [0.182, 0.3166, 0.2174, 0.338]}, {"w": "wonder", "b": [0.2243, 0.3166, 0.2881, 0.338]}, {"w": "how", "b": [0.295, 0.3166, 0.331, 0.338]}, {"w": "to", "b": [0.3378, 0.3166, 0.3548, 0.338]}, {"w": "select", "b": [0.3616, 0.3166, 0.4074, 0.338]}, {"w": "the", "b": [0.4142, 0.3166, 0.4406, 0.338]}, {"w": "landmarks.", "b": [0.4474, 0.3166, 0.5409, 0.338]}, {"w": "The", "b": [0.5477, 0.3166, 0.5805, 0.338]}, {"w": "simplest", "b": [0.5873, 0.3166, 0.6563, 0.338]}, {"w": "approach", "b": [0.6631, 0.3166, 0.7411, 0.338]}, {"w": "is", "b": [0.748, 0.3166, 0.7612, 0.338]}, {"w": "to", "b": [0.768, 0.3166, 0.785, 0.338]}, {"w": "create", "b": [0.7918, 0.3166, 0.8412, 0.338]}, {"w": "a", "b": [0.848, 0.3166, 0.8571, 0.338]}, {"w": "landmark", "b": [0.1429, 0.3356, 0.2239, 0.357]}, {"w": "at", "b": [0.2294, 0.3356, 0.2445, 0.357]}, {"w": "the", "b": [0.25, 0.3356, 0.2763, 0.357]}, {"w": "location", "b": [0.2818, 0.3356, 0.3492, 0.357]}, {"w": "of", "b": [0.3547, 0.3356, 0.3715, 0.357]}, {"w": "each", "b": [0.3769, 0.3356, 0.4149, 0.357]}, {"w": "and", "b": [0.4203, 0.3356, 0.4519, 0.357]}, {"w": "every", "b": [0.4573, 0.3356, 0.5026, 0.357]}, {"w": "instance", "b": [0.5081, 0.3356, 0.5773, 0.357]}, {"w": "in", "b": [0.5827, 0.3356, 0.5997, 0.357]}, {"w": "the", "b": [0.6052, 0.3356, 0.6315, 0.357]}, {"w": "dataset.", "b": [0.637, 0.3356, 0.6998, 0.357]}, {"w": "This", "b": [0.7053, 0.3356, 0.7425, 0.357]}, {"w": "creates", "b": [0.748, 0.3356, 0.805, 0.357]}, {"w": "many", "b": [0.8104, 0.3356, 0.8571, 0.357]}, {"w": "dimensions", "b": [0.1429, 0.3547, 0.2397, 0.3761]}, {"w": "and", "b": [0.2463, 0.3547, 0.2779, 0.3761]}, {"w": "thus", "b": [0.2846, 0.3547, 0.3203, 0.3761]}, {"w": "increases", "b": [0.327, 0.3547, 0.4027, 0.3761]}, {"w": "the", "b": [0.4094, 0.3547, 0.4357, 0.3761]}, {"w": "chances", "b": [0.4424, 0.3547, 0.5082, 0.3761]}, {"w": "that", "b": [0.5148, 0.3547, 0.5474, 0.3761]}, {"w": "the", "b": [0.5541, 0.3547, 0.5804, 0.3761]}, {"w": "transformed", "b": [0.5871, 0.3547, 0.6908, 0.3761]}, {"w": "training", "b": [0.6975, 0.3547, 0.7644, 0.3761]}, {"w": "set", "b": [0.7711, 0.3547, 0.794, 0.3761]}, {"w": "will", "b": [0.8006, 0.3547, 0.831, 0.3761]}, {"w": "be", "b": [0.8377, 0.3547, 0.8572, 0.3761]}, {"w": "linearly", "b": [0.1429, 0.3737, 0.2057, 0.3951]}, {"w": "separable.", "b": [0.2108, 0.3737, 0.2937, 0.3951]}, {"w": "The", "b": [0.2989, 0.3737, 0.3317, 0.3951]}, {"w": "downside", "b": [0.3368, 0.3737, 0.4172, 0.3951]}, {"w": "is", "b": [0.4224, 0.3737, 0.4356, 0.3951]}, {"w": "that", "b": [0.4407, 0.3737, 0.4733, 0.3951]}, {"w": "a", "b": [0.4785, 0.3737, 0.4876, 0.3951]}, {"w": "training", "b": [0.4927, 0.3737, 0.5597, 0.3951]}, {"w": "set", "b": [0.5648, 0.3737, 0.5877, 0.3951]}, {"w": "with", "b": [0.5928, 0.3737, 0.6302, 0.3951]}, {"w": "m", "b": [0.6353, 0.3735, 0.6517, 0.3951]}, {"w": "instances", "b": [0.6568, 0.3737, 0.7337, 0.3951]}, {"w": "and", "b": [0.7388, 0.3737, 0.7704, 0.3951]}, {"w": "n", "b": [0.7755, 0.3735, 0.7866, 0.3951]}, {"w": "features", "b": [0.7917, 0.3737, 0.8571, 0.3951]}, {"w": "gets", "b": [0.1429, 0.3928, 0.1755, 0.4142]}, {"w": "transformed", "b": [0.1819, 0.3928, 0.2856, 0.4142]}, {"w": "into", "b": [0.2921, 0.3928, 0.3256, 0.4142]}, {"w": "a", "b": [0.3321, 0.3928, 0.3412, 0.4142]}, {"w": "training", "b": [0.3477, 0.3928, 0.4146, 0.4142]}, {"w": "set", "b": [0.421, 0.3928, 0.4439, 0.4142]}, {"w": "with", "b": [0.4504, 0.3928, 0.4877, 0.4142]}, {"w": "m", "b": [0.4941, 0.3926, 0.5105, 0.4142]}, {"w": "instances", "b": [0.517, 0.3928, 0.5938, 0.4142]}, {"w": "and", "b": [0.6003, 0.3928, 0.6318, 0.4142]}, {"w": "m", "b": [0.6382, 0.3926, 0.6546, 0.4142]}, {"w": "features", "b": [0.6611, 0.3928, 0.7265, 0.4142]}, {"w": "(assuming", "b": [0.7329, 0.3928, 0.8194, 0.4142]}, {"w": "you", "b": [0.8259, 0.3928, 0.8571, 0.4142]}, {"w": "drop", "b": [0.1429, 0.4118, 0.1831, 0.4332]}, {"w": "the", "b": [0.1915, 0.4118, 0.2178, 0.4332]}, {"w": "original", "b": [0.2262, 0.4118, 0.2913, 0.4332]}, {"w": "features).", "b": [0.2997, 0.4118, 0.3771, 0.4332]}, {"w": "If", "b": [0.3854, 0.4118, 0.3987, 0.4332]}, {"w": "your", "b": [0.4071, 0.4118, 0.4461, 0.4332]}, {"w": "training", "b": [0.4544, 0.4118, 0.5214, 0.4332]}, {"w": "set", "b": [0.5298, 0.4118, 0.5526, 0.4332]}, {"w": "is", "b": [0.561, 0.4118, 0.5742, 0.4332]}, {"w": "very", "b": [0.5826, 0.4118, 0.619, 0.4332]}, {"w": "large,", "b": [0.6274, 0.4118, 0.6729, 0.4332]}, {"w": "you", "b": [0.6813, 0.4118, 0.7125, 0.4332]}, {"w": "end", "b": [0.7209, 0.4118, 0.7521, 0.4332]}, {"w": "up", "b": [0.7605, 0.4118, 0.7825, 0.4332]}, {"w": "with", "b": [0.7909, 0.4118, 0.8282, 0.4332]}, {"w": "an", "b": [0.8366, 0.4118, 0.8571, 0.4332]}, {"w": "equally", "b": [0.1429, 0.4309, 0.2027, 0.4523]}, {"w": "large", "b": [0.2074, 0.4309, 0.2482, 0.4523]}, {"w": "number", "b": [0.2529, 0.4309, 0.3192, 0.4523]}, {"w": "of", "b": [0.3239, 0.4309, 0.3407, 0.4523]}, {"w": "features.", "b": [0.3454, 0.4309, 0.4156, 0.4523]}]}, {"id": "b_2", "type": "paragraph", "text": "Gaussian RBF Kernel", "words": [{"w": "Gaussian", "b": [0.1428, 0.465, 0.2346, 0.4936]}, {"w": "RBF", "b": [0.2395, 0.465, 0.2791, 0.4936]}, {"w": "Kernel", "b": [0.2841, 0.465, 0.351, 0.4936]}]}, {"id": "b_3", "type": "paragraph", "text": "Just like the polynomial features method, the similarity features method can be useful with any Machine Learning algorithm, but it may be computationally expensive to compute all the additional features, especially on large training sets. However, once again the kernel trick does its SVM magic: it makes it possible to obtain a similar result as if you had added many similarity features, without actually having to add them. Let’s try the Gaussian RBF kernel using the SVC class:", "words": [{"w": "Just", "b": [0.1428, 0.4995, 0.1741, 0.5209]}, {"w": "like", "b": [0.1792, 0.4995, 0.2092, 0.5209]}, {"w": "the", "b": [0.2143, 0.4995, 0.2406, 0.5209]}, {"w": "polynomial", "b": [0.2457, 0.4995, 0.3412, 0.5209]}, {"w": "features", "b": [0.3462, 0.4995, 0.4116, 0.5209]}, {"w": "method,", "b": [0.4167, 0.4995, 0.4865, 0.5209]}, {"w": "the", "b": [0.4916, 0.4995, 0.5179, 0.5209]}, {"w": "similarity", "b": [0.523, 0.4995, 0.6025, 0.5209]}, {"w": "features", "b": [0.6076, 0.4995, 0.673, 0.5209]}, {"w": "method", "b": [0.6781, 0.4995, 0.7431, 0.5209]}, {"w": "can", "b": [0.7481, 0.4995, 0.7775, 0.5209]}, {"w": "be", "b": [0.7826, 0.4995, 0.802, 0.5209]}, {"w": "useful", "b": [0.8071, 0.4995, 0.8571, 0.5209]}, {"w": "with", "b": [0.1429, 0.5186, 0.1802, 0.54]}, {"w": "any", "b": [0.1876, 0.5186, 0.2173, 0.54]}, {"w": "Machine", "b": [0.2247, 0.5186, 0.2978, 0.54]}, {"w": "Learning", "b": [0.3053, 0.5186, 0.3804, 0.54]}, {"w": "algorithm,", "b": [0.3878, 0.5186, 0.4752, 0.54]}, {"w": "but", "b": [0.4827, 0.5186, 0.5107, 0.54]}, {"w": "it", "b": [0.5181, 0.5186, 0.5301, 0.54]}, {"w": "may", "b": [0.5375, 0.5186, 0.5729, 0.54]}, {"w": "be", "b": [0.5804, 0.5186, 0.5998, 0.54]}, {"w": "computationally", "b": [0.6073, 0.5186, 0.7437, 0.54]}, {"w": "expensive", "b": [0.7511, 0.5186, 0.8327, 0.54]}, {"w": "to", "b": [0.8402, 0.5186, 0.8571, 0.54]}, {"w": "compute", "b": [0.1429, 0.5376, 0.2162, 0.559]}, {"w": "all", "b": [0.2231, 0.5376, 0.2428, 0.559]}, {"w": "the", "b": [0.2497, 0.5376, 0.276, 0.559]}, {"w": "additional", "b": [0.283, 0.5376, 0.3681, 0.559]}, {"w": "features,", "b": [0.375, 0.5376, 0.4452, 0.559]}, {"w": "especially", "b": [0.4521, 0.5376, 0.532, 0.559]}, {"w": "on", "b": [0.539, 0.5376, 0.561, 0.559]}, {"w": "large", "b": [0.5679, 0.5376, 0.6087, 0.559]}, {"w": "training", "b": [0.6156, 0.5376, 0.6826, 0.559]}, {"w": "sets.", "b": [0.6895, 0.5376, 0.7247, 0.559]}, {"w": "However,", "b": [0.7317, 0.5376, 0.8105, 0.559]}, {"w": "once", "b": [0.8175, 0.5376, 0.8572, 0.559]}, {"w": "again", "b": [0.1429, 0.5567, 0.1879, 0.5781]}, {"w": "the", "b": [0.1955, 0.5567, 0.2218, 0.5781]}, {"w": "kernel", "b": [0.2294, 0.5567, 0.2818, 0.5781]}, {"w": "trick", "b": [0.2894, 0.5567, 0.3282, 0.5781]}, {"w": "does", "b": [0.3358, 0.5567, 0.374, 0.5781]}, {"w": "its", "b": [0.3816, 0.5567, 0.4011, 0.5781]}, {"w": "SVM", "b": [0.4087, 0.5567, 0.4518, 0.5781]}, {"w": "magic:", "b": [0.4594, 0.5567, 0.5145, 0.5781]}, {"w": "it", "b": [0.5221, 0.5567, 0.5341, 0.5781]}, {"w": "makes", "b": [0.5416, 0.5567, 0.5947, 0.5781]}, {"w": "it", "b": [0.6023, 0.5567, 0.6142, 0.5781]}, {"w": "possible", "b": [0.6218, 0.5567, 0.6889, 0.5781]}, {"w": "to", "b": [0.6965, 0.5567, 0.7135, 0.5781]}, {"w": "obtain", "b": [0.7211, 0.5567, 0.7748, 0.5781]}, {"w": "a", "b": [0.7824, 0.5567, 0.7915, 0.5781]}, {"w": "similar", "b": [0.7991, 0.5567, 0.8571, 0.5781]}, {"w": "result", "b": [0.1429, 0.5757, 0.1898, 0.5971]}, {"w": "as", "b": [0.197, 0.5757, 0.2138, 0.5971]}, {"w": "if", "b": [0.2211, 0.5757, 0.2329, 0.5971]}, {"w": "you", "b": [0.2401, 0.5757, 0.2714, 0.5971]}, {"w": "had", "b": [0.2787, 0.5757, 0.3099, 0.5971]}, {"w": "added", "b": [0.3172, 0.5757, 0.3682, 0.5971]}, {"w": "many", "b": [0.3755, 0.5757, 0.4222, 0.5971]}, {"w": "similarity", "b": [0.4294, 0.5757, 0.5089, 0.5971]}, {"w": "features,", "b": [0.5162, 0.5757, 0.5864, 0.5971]}, {"w": "without", "b": [0.5937, 0.5757, 0.659, 0.5971]}, {"w": "actually", "b": [0.6663, 0.5757, 0.7309, 0.5971]}, {"w": "having", "b": [0.7382, 0.5757, 0.7945, 0.5971]}, {"w": "to", "b": [0.8017, 0.5757, 0.8187, 0.5971]}, {"w": "add", "b": [0.826, 0.5757, 0.8571, 0.5971]}, {"w": "them.", "b": [0.1428, 0.5956, 0.191, 0.6171]}, {"w": "Let’s", "b": [0.1957, 0.5956, 0.2319, 0.6171]}, {"w": "try", "b": [0.2366, 0.5956, 0.2609, 0.6171]}, {"w": "the", "b": [0.2656, 0.5956, 0.2919, 0.6171]}, {"w": "Gaussian", "b": [0.2967, 0.5956, 0.3728, 0.6171]}, {"w": "RBF", "b": [0.3775, 0.5956, 0.4137, 0.6171]}, {"w": "kernel", "b": [0.4185, 0.5956, 0.4709, 0.6171]}, {"w": "using", "b": [0.4756, 0.5956, 0.5211, 0.6171]}, {"w": "the", "b": [0.5258, 0.5956, 0.5521, 0.6171]}, {"w": "SVC", "b": [0.5568, 0.5988, 0.5865, 0.6139]}, {"w": "class:", "b": [0.5913, 0.5956, 0.6345, 0.6171]}]}, {"id": "b_4", "type": "paragraph", "text": "rbf_kernel_svm_clf = Pipeline([ (\"scaler\", StandardScaler()), (\"svm_clf\", SVC(kernel=\"rbf\", gamma=5, C=0.001)) ]) rbf_kernel_svm_clf.fit(X, y)", "words": [{"w": "rbf_kernel_svm_clf", "b": [0.1766, 0.6276, 0.3284, 0.6405]}, {"w": "=", "b": [0.3368, 0.6276, 0.3452, 0.6405]}, {"w": "Pipeline([", "b": [0.3537, 0.6276, 0.438, 0.6405]}, {"w": "(\"scaler\",", "b": [0.244, 0.643, 0.3284, 0.6559]}, {"w": "StandardScaler()),", "b": [0.3368, 0.643, 0.4886, 0.6559]}, {"w": "(\"svm_clf\",", "b": [0.244, 0.6585, 0.3368, 0.6713]}, {"w": "SVC(kernel=\"rbf\",", "b": [0.3452, 0.6585, 0.4886, 0.6713]}, {"w": "gamma=5,", "b": [0.497, 0.6585, 0.5645, 0.6713]}, {"w": "C=0.001))", "b": [0.5729, 0.6585, 0.6488, 0.6713]}, {"w": "])", "b": [0.2103, 0.6739, 0.2272, 0.6867]}, {"w": "rbf_kernel_svm_clf.fit(X,", "b": [0.1766, 0.6893, 0.3874, 0.7021]}, {"w": "y)", "b": [0.3958, 0.6893, 0.4127, 0.7021]}]}, {"id": "b_5", "type": "paragraph", "text": "This model is represented on the bottom left of Figure 5-9. The other plots show models trained with different values of hyperparameters gamma (γ) and C. Increasing gamma makes the bell-shape curve narrower (see the left plot of Figure 5-8), and as a result each instance’s range of influence is smaller: the decision boundary ends up being more irregular, wiggling around individual instances. Conversely, a small gamma value makes the bell-shaped curve wider, so instances have a larger range of influ‐ ence, and the decision boundary ends up smoother. So γ acts like a regularization hyperparameter: if your model is overfitting, you should reduce it, and if it is under‐ fitting, you should increase it (similar to the C hyperparameter).", "words": [{"w": "This", "b": [0.1429, 0.7099, 0.1801, 0.7313]}, {"w": "model", "b": [0.188, 0.7099, 0.2409, 0.7313]}, {"w": "is", "b": [0.2488, 0.7099, 0.2621, 0.7313]}, {"w": "represented", "b": [0.27, 0.7099, 0.3678, 0.7313]}, {"w": "on", "b": [0.3758, 0.7099, 0.3978, 0.7313]}, {"w": "the", "b": [0.4058, 0.7099, 0.4321, 0.7313]}, {"w": "bottom", "b": [0.4401, 0.7099, 0.5017, 0.7313]}, {"w": "left", "b": [0.5097, 0.7099, 0.5363, 0.7313]}, {"w": "of", "b": [0.5443, 0.7099, 0.5611, 0.7313]}, {"w": "Figure", "b": [0.5691, 0.7099, 0.6231, 0.7313]}, {"w": "5-9.", "b": [0.6311, 0.7099, 0.6632, 0.7313]}, {"w": "The", "b": [0.6712, 0.7099, 0.704, 0.7313]}, {"w": "other", "b": [0.712, 0.7099, 0.7567, 0.7313]}, {"w": "plots", "b": [0.7647, 0.7099, 0.8055, 0.7313]}, {"w": "show", "b": [0.8135, 0.7099, 0.8571, 0.7313]}, {"w": "models", "b": [0.1429, 0.7299, 0.2033, 0.7513]}, {"w": "trained", "b": [0.2092, 0.7299, 0.2692, 0.7513]}, {"w": "with", "b": [0.2751, 0.7299, 0.3124, 0.7513]}, {"w": "different", "b": [0.3183, 0.7299, 0.39, 0.7513]}, {"w": "values", "b": [0.3959, 0.7299, 0.4475, 0.7513]}, {"w": "of", "b": [0.4533, 0.7299, 0.4701, 0.7513]}, {"w": "hyperparameters", "b": [0.476, 0.7299, 0.6171, 0.7513]}, {"w": "gamma", "b": [0.623, 0.7331, 0.6725, 0.7481]}, {"w": "(γ)", "b": [0.6783, 0.7297, 0.7026, 0.7513]}, {"w": "and", "b": [0.7085, 0.7299, 0.74, 0.7513]}, {"w": "C.", "b": [0.7459, 0.7297, 0.7639, 0.7513]}, {"w": "Increasing", "b": [0.7697, 0.7299, 0.8571, 0.7513]}, {"w": "gamma", "b": [0.1429, 0.753, 0.1923, 0.7681]}, {"w": "makes", "b": [0.1983, 0.7498, 0.2514, 0.7712]}, {"w": "the", "b": [0.2574, 0.7498, 0.2837, 0.7712]}, {"w": "bell-shape", "b": [0.2898, 0.7498, 0.3744, 0.7712]}, {"w": "curve", "b": [0.3805, 0.7498, 0.4272, 0.7712]}, {"w": "narrower", "b": [0.4332, 0.7498, 0.5107, 0.7712]}, {"w": "(see", "b": [0.5167, 0.7498, 0.5492, 0.7712]}, {"w": "the", "b": [0.5552, 0.7498, 0.5816, 0.7712]}, {"w": "left", "b": [0.5876, 0.7498, 0.6142, 0.7712]}, {"w": "plot", "b": [0.6202, 0.7498, 0.6534, 0.7712]}, {"w": "of", "b": [0.6594, 0.7498, 0.6762, 0.7712]}, {"w": "Figure", "b": [0.6822, 0.7498, 0.7362, 0.7712]}, {"w": "5-8),", "b": [0.7422, 0.7498, 0.7816, 0.7712]}, {"w": "and", "b": [0.7876, 0.7498, 0.8192, 0.7712]}, {"w": "as", "b": [0.8252, 0.7498, 0.842, 0.7712]}, {"w": "a", "b": [0.848, 0.7498, 0.8571, 0.7712]}, {"w": "result", "b": [0.1429, 0.7689, 0.1898, 0.7903]}, {"w": "each", "b": [0.1975, 0.7689, 0.2354, 0.7903]}, {"w": "instance’s", "b": [0.2431, 0.7689, 0.3214, 0.7903]}, {"w": "range", "b": [0.329, 0.7689, 0.3759, 0.7903]}, {"w": "of", "b": [0.3836, 0.7689, 0.4004, 0.7903]}, {"w": "influence", "b": [0.4081, 0.7689, 0.4855, 0.7903]}, {"w": "is", "b": [0.4932, 0.7689, 0.5064, 0.7903]}, {"w": "smaller:", "b": [0.5141, 0.7689, 0.5803, 0.7903]}, {"w": "the", "b": [0.588, 0.7689, 0.6143, 0.7903]}, {"w": "decision", "b": [0.622, 0.7689, 0.6915, 0.7903]}, {"w": "boundary", "b": [0.6992, 0.7689, 0.7809, 0.7903]}, {"w": "ends", "b": [0.7886, 0.7689, 0.8275, 0.7903]}, {"w": "up", "b": [0.8352, 0.7689, 0.8571, 0.7903]}, {"w": "being", "b": [0.1428, 0.7888, 0.189, 0.8102]}, {"w": "more", "b": [0.1937, 0.7888, 0.238, 0.8102]}, {"w": "irregular,", "b": [0.2427, 0.7888, 0.319, 0.8102]}, {"w": "wiggling", "b": [0.3238, 0.7888, 0.3951, 0.8102]}, {"w": "around", "b": [0.3998, 0.7888, 0.4608, 0.8102]}, {"w": "individual", "b": [0.4655, 0.7888, 0.5508, 0.8102]}, {"w": "instances.", "b": [0.5555, 0.7888, 0.6371, 0.8102]}, {"w": "Conversely,", "b": [0.6418, 0.7888, 0.738, 0.8102]}, {"w": "a", "b": [0.7428, 0.7888, 0.7519, 0.8102]}, {"w": "small", "b": [0.7566, 0.7888, 0.801, 0.8102]}, {"w": "gamma", "b": [0.8058, 0.792, 0.8552, 0.8071]}, {"w": "value", "b": [0.1428, 0.8079, 0.1868, 0.8293]}, {"w": "makes", "b": [0.1942, 0.8079, 0.2473, 0.8293]}, {"w": "the", "b": [0.2546, 0.8079, 0.281, 0.8293]}, {"w": "bell-shaped", "b": [0.2883, 0.8079, 0.384, 0.8293]}, {"w": "curve", "b": [0.3914, 0.8079, 0.4381, 0.8293]}, {"w": "wider,", "b": [0.4455, 0.8079, 0.4964, 0.8293]}, {"w": "so", "b": [0.5038, 0.8079, 0.522, 0.8293]}, {"w": "instances", "b": [0.5294, 0.8079, 0.6063, 0.8293]}, {"w": "have", "b": [0.6136, 0.8079, 0.652, 0.8293]}, {"w": "a", "b": [0.6594, 0.8079, 0.6686, 0.8293]}, {"w": "larger", "b": [0.6759, 0.8079, 0.7244, 0.8293]}, {"w": "range", "b": [0.7318, 0.8079, 0.7787, 0.8293]}, {"w": "of", "b": [0.7861, 0.8079, 0.8029, 0.8293]}, {"w": "influ‐", "b": [0.8102, 0.8079, 0.8571, 0.8293]}, {"w": "ence,", "b": [0.1429, 0.8269, 0.1855, 0.8483]}, {"w": "and", "b": [0.1932, 0.8269, 0.2248, 0.8483]}, {"w": "the", "b": [0.2325, 0.8269, 0.2588, 0.8483]}, {"w": "decision", "b": [0.2665, 0.8269, 0.336, 0.8483]}, {"w": "boundary", "b": [0.3437, 0.8269, 0.4254, 0.8483]}, {"w": "ends", "b": [0.4331, 0.8269, 0.472, 0.8483]}, {"w": "up", "b": [0.4797, 0.8269, 0.5017, 0.8483]}, {"w": "smoother.", "b": [0.5094, 0.8269, 0.5928, 0.8483]}, {"w": "So", "b": [0.6005, 0.8269, 0.621, 0.8483]}, {"w": "γ", "b": [0.6287, 0.8267, 0.6386, 0.8483]}, {"w": "acts", "b": [0.6463, 0.8269, 0.6783, 0.8483]}, {"w": "like", "b": [0.686, 0.8269, 0.716, 0.8483]}, {"w": "a", "b": [0.7237, 0.8269, 0.7329, 0.8483]}, {"w": "regularization", "b": [0.7406, 0.8269, 0.8571, 0.8483]}, {"w": "hyperparameter:", "b": [0.1429, 0.846, 0.2816, 0.8674]}, {"w": "if", "b": [0.2873, 0.846, 0.299, 0.8674]}, {"w": "your", "b": [0.3047, 0.846, 0.3436, 0.8674]}, {"w": "model", "b": [0.3493, 0.846, 0.4021, 0.8674]}, {"w": "is", "b": [0.4077, 0.846, 0.421, 0.8674]}, {"w": "overfitting,", "b": [0.4266, 0.846, 0.5194, 0.8674]}, {"w": "you", "b": [0.5251, 0.846, 0.5563, 0.8674]}, {"w": "should", "b": [0.562, 0.846, 0.6187, 0.8674]}, {"w": "reduce", "b": [0.6243, 0.846, 0.6806, 0.8674]}, {"w": "it,", "b": [0.6863, 0.846, 0.703, 0.8674]}, {"w": "and", "b": [0.7086, 0.846, 0.7402, 0.8674]}, {"w": "if", "b": [0.7458, 0.846, 0.7576, 0.8674]}, {"w": "it", "b": [0.7632, 0.846, 0.7752, 0.8674]}, {"w": "is", "b": [0.7808, 0.846, 0.794, 0.8674]}, {"w": "under‐", "b": [0.7997, 0.846, 0.8571, 0.8674]}, {"w": "fitting,", "b": [0.1428, 0.8659, 0.1988, 0.8873]}, {"w": "you", "b": [0.2035, 0.8659, 0.2348, 0.8873]}, {"w": "should", "b": [0.2395, 0.8659, 0.2962, 0.8873]}, {"w": "increase", "b": [0.301, 0.8659, 0.369, 0.8873]}, {"w": "it", "b": [0.3737, 0.8659, 0.3856, 0.8873]}, {"w": "(similar", "b": [0.3904, 0.8659, 0.4556, 0.8873]}, {"w": "to", "b": [0.4603, 0.8659, 0.4773, 0.8873]}, {"w": "the", "b": [0.482, 0.8659, 0.5084, 0.8873]}, {"w": "C", "b": [0.5131, 0.8691, 0.523, 0.8842]}, {"w": "hyperparameter).", "b": [0.5277, 0.8659, 0.6732, 0.8873]}]}, {"id": "b_6", "type": "paragraph", "text": "162 | Chapter 5: Support Vector Machines", "words": [{"w": "162", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "5:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Support", "b": [0.2673, 0.9225, 0.3142, 0.9388]}, {"w": "Vector", "b": [0.317, 0.9225, 0.3547, 0.9388]}, {"w": "Machines", "b": [0.3576, 0.9225, 0.413, 0.9388]}]}]}, {"page": 189, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 “A Dual Coordinate Descent Method for Large-scale Linear SVM,” Lin et al. (2008).", "words": [{"w": "1", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“A", "b": [0.1587, 0.8749, 0.1736, 0.8912]}, {"w": "Dual", "b": [0.1772, 0.8749, 0.2083, 0.8912]}, {"w": "Coordinate", "b": [0.2119, 0.8749, 0.2841, 0.8912]}, {"w": "Descent", "b": [0.2877, 0.8749, 0.3387, 0.8912]}, {"w": "Method", "b": [0.3423, 0.8749, 0.3925, 0.8912]}, {"w": "for", "b": [0.3961, 0.8749, 0.4148, 0.8912]}, {"w": "Large-scale", "b": [0.4184, 0.8749, 0.4899, 0.8912]}, {"w": "Linear", "b": [0.4935, 0.8749, 0.5346, 0.8912]}, {"w": "SVM,”", "b": [0.5382, 0.8749, 0.5788, 0.8912]}, {"w": "Lin", "b": [0.5824, 0.8749, 0.6039, 0.8912]}, {"w": "et", "b": [0.6075, 0.8749, 0.6191, 0.8912]}, {"w": "al.", "b": [0.6227, 0.8749, 0.6373, 0.8912]}, {"w": "(2008).", "b": [0.6409, 0.8749, 0.686, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 5-9. SVM classifiers using an RBF kernel", "words": [{"w": "Figure", "b": [0.1429, 0.424, 0.1943, 0.4456]}, {"w": "5-9.", "b": [0.1991, 0.424, 0.2308, 0.4456]}, {"w": "SVM", "b": [0.2356, 0.424, 0.2776, 0.4456]}, {"w": "classifiers", "b": [0.2824, 0.424, 0.3595, 0.4456]}, {"w": "using", "b": [0.3643, 0.424, 0.4073, 0.4456]}, {"w": "an", "b": [0.4121, 0.424, 0.433, 0.4456]}, {"w": "RBF", "b": [0.4378, 0.424, 0.4733, 0.4456]}, {"w": "kernel", "b": [0.4781, 0.424, 0.528, 0.4456]}]}, {"id": "b_2", "type": "paragraph", "text": "Other kernels exist but are used much more rarely. For example, some kernels are specialized for specific data structures. String kernels are sometimes used when classi‐ fying text documents or DNA sequences (e.g., using the string subsequence kernel or kernels based on the Levenshtein distance).", "words": [{"w": "Other", "b": [0.1429, 0.4614, 0.1925, 0.4828]}, {"w": "kernels", "b": [0.2, 0.4614, 0.2601, 0.4828]}, {"w": "exist", "b": [0.2675, 0.4614, 0.3058, 0.4828]}, {"w": "but", "b": [0.3133, 0.4614, 0.3413, 0.4828]}, {"w": "are", "b": [0.3488, 0.4614, 0.3745, 0.4828]}, {"w": "used", "b": [0.382, 0.4614, 0.4206, 0.4828]}, {"w": "much", "b": [0.428, 0.4614, 0.4757, 0.4828]}, {"w": "more", "b": [0.4832, 0.4614, 0.5275, 0.4828]}, {"w": "rarely.", "b": [0.5349, 0.4614, 0.5865, 0.4828]}, {"w": "For", "b": [0.5939, 0.4614, 0.6229, 0.4828]}, {"w": "example,", "b": [0.6304, 0.4614, 0.7047, 0.4828]}, {"w": "some", "b": [0.7122, 0.4614, 0.7564, 0.4828]}, {"w": "kernels", "b": [0.7639, 0.4614, 0.8239, 0.4828]}, {"w": "are", "b": [0.8314, 0.4614, 0.8572, 0.4828]}, {"w": "specialized", "b": [0.1429, 0.4804, 0.2333, 0.5019]}, {"w": "for", "b": [0.2385, 0.4804, 0.263, 0.5019]}, {"w": "specific", "b": [0.2682, 0.4804, 0.3305, 0.5019]}, {"w": "data", "b": [0.3357, 0.4804, 0.371, 0.5019]}, {"w": "structures.", "b": [0.3761, 0.4804, 0.4641, 0.5019]}, {"w": "String", "b": [0.4693, 0.4802, 0.5178, 0.5019]}, {"w": "kernels", "b": [0.5226, 0.4802, 0.5796, 0.5019]}, {"w": "are", "b": [0.5853, 0.4804, 0.611, 0.5019]}, {"w": "sometimes", "b": [0.6162, 0.4804, 0.7059, 0.5019]}, {"w": "used", "b": [0.711, 0.4804, 0.7496, 0.5019]}, {"w": "when", "b": [0.7548, 0.4804, 0.8004, 0.5019]}, {"w": "classi‐", "b": [0.8056, 0.4804, 0.8571, 0.5019]}, {"w": "fying", "b": [0.1429, 0.4995, 0.1857, 0.5209]}, {"w": "text", "b": [0.192, 0.4995, 0.2234, 0.5209]}, {"w": "documents", "b": [0.2297, 0.4995, 0.3222, 0.5209]}, {"w": "or", "b": [0.3285, 0.4995, 0.3468, 0.5209]}, {"w": "DNA", "b": [0.3532, 0.4995, 0.3976, 0.5209]}, {"w": "sequences", "b": [0.4039, 0.4995, 0.4877, 0.5209]}, {"w": "(e.g.,", "b": [0.494, 0.4995, 0.5341, 0.5209]}, {"w": "using", "b": [0.5404, 0.4995, 0.5859, 0.5209]}, {"w": "the", "b": [0.5922, 0.4995, 0.6185, 0.5209]}, {"w": "string", "b": [0.6249, 0.4993, 0.6707, 0.5209]}, {"w": "subsequence", "b": [0.677, 0.4993, 0.7762, 0.5209]}, {"w": "kernel", "b": [0.7825, 0.4993, 0.8325, 0.5209]}, {"w": "or", "b": [0.8388, 0.4995, 0.8572, 0.5209]}, {"w": "kernels", "b": [0.1429, 0.5185, 0.2029, 0.54]}, {"w": "based", "b": [0.2077, 0.5185, 0.2549, 0.54]}, {"w": "on", "b": [0.2596, 0.5185, 0.2817, 0.54]}, {"w": "the", "b": [0.2864, 0.5185, 0.3127, 0.54]}, {"w": "Levenshtein", "b": [0.3174, 0.5183, 0.4136, 0.54]}, {"w": "distance).", "b": [0.4184, 0.5183, 0.4964, 0.54]}]}, {"id": "b_3", "type": "paragraph", "text": "With so many kernels to choose from, how can you decide which one to use? As a rule of thumb, you should always try the linear kernel first (remember that LinearSVC is much faster than SVC(ker nel=\"linear\")), especially if the training set is very large or if it has plenty of features. If the training set is not too large, you should try the Gaussian RBF kernel as well; it works well in most cases. Then if you have spare time and computing power, you can also experiment with a few other kernels using cross-validation and grid search, especially if there are kernels specialized for your training set’s data structure.", "words": [{"w": "With", "b": [0.2714, 0.5605, 0.3102, 0.5801]}, {"w": "so", "b": [0.3162, 0.5605, 0.3329, 0.5801]}, {"w": "many", "b": [0.3389, 0.5605, 0.3816, 0.5801]}, {"w": "kernels", "b": [0.3877, 0.5605, 0.4426, 0.5801]}, {"w": "to", "b": [0.4486, 0.5605, 0.4641, 0.5801]}, {"w": "choose", "b": [0.4701, 0.5605, 0.5229, 0.5801]}, {"w": "from,", "b": [0.5289, 0.5605, 0.5713, 0.5801]}, {"w": "how", "b": [0.5773, 0.5605, 0.6102, 0.5801]}, {"w": "can", "b": [0.6162, 0.5605, 0.6431, 0.5801]}, {"w": "you", "b": [0.6491, 0.5605, 0.6777, 0.5801]}, {"w": "decide", "b": [0.6837, 0.5605, 0.7331, 0.5801]}, {"w": "which", "b": [0.7392, 0.5605, 0.7857, 0.5801]}, {"w": "one", "b": [0.2714, 0.5779, 0.2996, 0.5975]}, {"w": "to", "b": [0.3065, 0.5779, 0.322, 0.5975]}, {"w": "use?", "b": [0.3288, 0.5779, 0.3612, 0.5975]}, {"w": "As", "b": [0.3681, 0.5779, 0.3882, 0.5975]}, {"w": "a", "b": [0.3951, 0.5779, 0.4034, 0.5975]}, {"w": "rule", "b": [0.4103, 0.5779, 0.4404, 0.5975]}, {"w": "of", "b": [0.4472, 0.5779, 0.4625, 0.5975]}, {"w": "thumb,", "b": [0.4694, 0.5779, 0.5242, 0.5975]}, {"w": "you", "b": [0.531, 0.5779, 0.5596, 0.5975]}, {"w": "should", "b": [0.5664, 0.5779, 0.6183, 0.5975]}, {"w": "always", "b": [0.6251, 0.5779, 0.6751, 0.5975]}, {"w": "try", "b": [0.6819, 0.5779, 0.7041, 0.5975]}, {"w": "the", "b": [0.7109, 0.5779, 0.735, 0.5975]}, {"w": "linear", "b": [0.7418, 0.5779, 0.7857, 0.5975]}, {"w": "kernel", "b": [0.2714, 0.5961, 0.3194, 0.6157]}, {"w": "first", "b": [0.3241, 0.5961, 0.3547, 0.6157]}, {"w": "(remember", "b": [0.3594, 0.5961, 0.4453, 0.6157]}, {"w": "that", "b": [0.45, 0.5961, 0.4798, 0.6157]}, {"w": "LinearSVC", "b": [0.4845, 0.599, 0.566, 0.6128]}, {"w": "is", "b": [0.5707, 0.5961, 0.5828, 0.6157]}, {"w": "much", "b": [0.5875, 0.5961, 0.6311, 0.6157]}, {"w": "faster", "b": [0.6358, 0.5961, 0.6778, 0.6157]}, {"w": "than", "b": [0.6825, 0.5961, 0.7173, 0.6157]}, {"w": "SVC(ker", "b": [0.722, 0.599, 0.7853, 0.6128]}, {"w": "nel=\"linear\")),", "b": [0.2714, 0.6144, 0.4, 0.6339]}, {"w": "especially", "b": [0.4068, 0.6144, 0.4798, 0.6339]}, {"w": "if", "b": [0.4866, 0.6144, 0.4974, 0.6339]}, {"w": "the", "b": [0.5041, 0.6144, 0.5282, 0.6339]}, {"w": "training", "b": [0.535, 0.6144, 0.5962, 0.6339]}, {"w": "set", "b": [0.603, 0.6144, 0.6239, 0.6339]}, {"w": "is", "b": [0.6307, 0.6144, 0.6428, 0.6339]}, {"w": "very", "b": [0.6496, 0.6144, 0.6829, 0.6339]}, {"w": "large", "b": [0.6896, 0.6144, 0.7269, 0.6339]}, {"w": "or", "b": [0.7337, 0.6144, 0.7505, 0.6339]}, {"w": "if", "b": [0.7573, 0.6144, 0.768, 0.6339]}, {"w": "it", "b": [0.7748, 0.6144, 0.7857, 0.6339]}, {"w": "has", "b": [0.2714, 0.6318, 0.2969, 0.6514]}, {"w": "plenty", "b": [0.3014, 0.6318, 0.3489, 0.6514]}, {"w": "of", "b": [0.3534, 0.6318, 0.3687, 0.6514]}, {"w": "features.", "b": [0.3732, 0.6318, 0.4374, 0.6514]}, {"w": "If", "b": [0.4418, 0.6318, 0.454, 0.6514]}, {"w": "the", "b": [0.4584, 0.6318, 0.4825, 0.6514]}, {"w": "training", "b": [0.487, 0.6318, 0.5482, 0.6514]}, {"w": "set", "b": [0.5527, 0.6318, 0.5736, 0.6514]}, {"w": "is", "b": [0.578, 0.6318, 0.5901, 0.6514]}, {"w": "not", "b": [0.5946, 0.6318, 0.6205, 0.6514]}, {"w": "too", "b": [0.625, 0.6318, 0.6503, 0.6514]}, {"w": "large,", "b": [0.6547, 0.6318, 0.6963, 0.6514]}, {"w": "you", "b": [0.7008, 0.6318, 0.7294, 0.6514]}, {"w": "should", "b": [0.7338, 0.6318, 0.7857, 0.6514]}, {"w": "try", "b": [0.2714, 0.6492, 0.2936, 0.6688]}, {"w": "the", "b": [0.3005, 0.6492, 0.3245, 0.6688]}, {"w": "Gaussian", "b": [0.3314, 0.6492, 0.401, 0.6688]}, {"w": "RBF", "b": [0.4079, 0.6492, 0.441, 0.6688]}, {"w": "kernel", "b": [0.4479, 0.6492, 0.4958, 0.6688]}, {"w": "as", "b": [0.5027, 0.6492, 0.518, 0.6688]}, {"w": "well;", "b": [0.5249, 0.6492, 0.56, 0.6688]}, {"w": "it", "b": [0.5669, 0.6492, 0.5778, 0.6688]}, {"w": "works", "b": [0.5847, 0.6492, 0.631, 0.6688]}, {"w": "well", "b": [0.6378, 0.6492, 0.6686, 0.6688]}, {"w": "in", "b": [0.6755, 0.6492, 0.691, 0.6688]}, {"w": "most", "b": [0.6979, 0.6492, 0.736, 0.6688]}, {"w": "cases.", "b": [0.7429, 0.6492, 0.7857, 0.6688]}, {"w": "Then", "b": [0.2714, 0.6666, 0.3118, 0.6862]}, {"w": "if", "b": [0.3187, 0.6666, 0.3295, 0.6862]}, {"w": "you", "b": [0.3364, 0.6666, 0.3649, 0.6862]}, {"w": "have", "b": [0.3718, 0.6666, 0.4069, 0.6862]}, {"w": "spare", "b": [0.4138, 0.6666, 0.4543, 0.6862]}, {"w": "time", "b": [0.4612, 0.6666, 0.4958, 0.6862]}, {"w": "and", "b": [0.5027, 0.6666, 0.5316, 0.6862]}, {"w": "computing", "b": [0.5385, 0.6666, 0.6218, 0.6862]}, {"w": "power,", "b": [0.6287, 0.6666, 0.6797, 0.6862]}, {"w": "you", "b": [0.6866, 0.6666, 0.7152, 0.6862]}, {"w": "can", "b": [0.7221, 0.6666, 0.7489, 0.6862]}, {"w": "also", "b": [0.7558, 0.6666, 0.7857, 0.6862]}, {"w": "experiment", "b": [0.2714, 0.684, 0.3583, 0.7036]}, {"w": "with", "b": [0.3626, 0.684, 0.3968, 0.7036]}, {"w": "a", "b": [0.4011, 0.684, 0.4095, 0.7036]}, {"w": "few", "b": [0.4138, 0.684, 0.4406, 0.7036]}, {"w": "other", "b": [0.4449, 0.684, 0.4857, 0.7036]}, {"w": "kernels", "b": [0.4901, 0.684, 0.545, 0.7036]}, {"w": "using", "b": [0.5493, 0.684, 0.5909, 0.7036]}, {"w": "cross-validation", "b": [0.5952, 0.684, 0.717, 0.7036]}, {"w": "and", "b": [0.7213, 0.684, 0.7502, 0.7036]}, {"w": "grid", "b": [0.7545, 0.684, 0.7856, 0.7036]}, {"w": "search,", "b": [0.2714, 0.7014, 0.3245, 0.721]}, {"w": "especially", "b": [0.3309, 0.7014, 0.404, 0.721]}, {"w": "if", "b": [0.4104, 0.7014, 0.4211, 0.721]}, {"w": "there", "b": [0.4276, 0.7014, 0.4668, 0.721]}, {"w": "are", "b": [0.4732, 0.7014, 0.4968, 0.721]}, {"w": "kernels", "b": [0.5032, 0.7014, 0.5581, 0.721]}, {"w": "specialized", "b": [0.5645, 0.7014, 0.6472, 0.721]}, {"w": "for", "b": [0.6536, 0.7014, 0.676, 0.721]}, {"w": "your", "b": [0.6825, 0.7014, 0.7181, 0.721]}, {"w": "training", "b": [0.7245, 0.7014, 0.7857, 0.721]}, {"w": "set’s", "b": [0.2714, 0.7189, 0.3012, 0.7384]}, {"w": "data", "b": [0.3055, 0.7189, 0.3378, 0.7384]}, {"w": "structure.", "b": [0.3421, 0.7189, 0.4156, 0.7384]}]}, {"id": "b_4", "type": "paragraph", "text": "Computational Complexity", "words": [{"w": "Computational", "b": [0.1428, 0.756, 0.2969, 0.7845]}, {"w": "Complexity", "b": [0.3019, 0.756, 0.4179, 0.7845]}]}, {"id": "b_5", "type": "paragraph", "text": "The LinearSVC class is based on the liblinear library, which implements an optimized algorithm for linear SVMs.1 It does not support the kernel trick, but it scales almost", "words": [{"w": "The", "b": [0.1429, 0.7913, 0.1757, 0.8128]}, {"w": "LinearSVC", "b": [0.181, 0.7945, 0.2701, 0.8096]}, {"w": "class", "b": [0.2754, 0.7913, 0.314, 0.8128]}, {"w": "is", "b": [0.3193, 0.7913, 0.3325, 0.8128]}, {"w": "based", "b": [0.3379, 0.7913, 0.3851, 0.8128]}, {"w": "on", "b": [0.3904, 0.7913, 0.4124, 0.8128]}, {"w": "the", "b": [0.4178, 0.7913, 0.4441, 0.8128]}, {"w": "liblinear", "b": [0.4494, 0.7911, 0.5166, 0.8128]}, {"w": "library,", "b": [0.522, 0.7913, 0.5814, 0.8128]}, {"w": "which", "b": [0.5868, 0.7913, 0.6377, 0.8128]}, {"w": "implements", "b": [0.643, 0.7913, 0.7412, 0.8128]}, {"w": "an", "b": [0.7465, 0.7913, 0.7671, 0.8128]}, {"w": "optimized", "b": [0.7724, 0.7913, 0.8572, 0.8128]}, {"w": "algorithm", "b": [0.1429, 0.8104, 0.2255, 0.8318]}, {"w": "for", "b": [0.2318, 0.8104, 0.2563, 0.8318]}, {"w": "linear", "b": [0.2626, 0.8104, 0.3105, 0.8318]}, {"w": "SVMs.1", "b": [0.3168, 0.8104, 0.378, 0.8318]}, {"w": "It", "b": [0.3843, 0.8104, 0.3969, 0.8318]}, {"w": "does", "b": [0.4032, 0.8104, 0.4413, 0.8318]}, {"w": "not", "b": [0.4476, 0.8104, 0.476, 0.8318]}, {"w": "support", "b": [0.4822, 0.8104, 0.5475, 0.8318]}, {"w": "the", "b": [0.5538, 0.8104, 0.5801, 0.8318]}, {"w": "kernel", "b": [0.5864, 0.8104, 0.6388, 0.8318]}, {"w": "trick,", "b": [0.6451, 0.8104, 0.6886, 0.8318]}, {"w": "but", "b": [0.6949, 0.8104, 0.7229, 0.8318]}, {"w": "it", "b": [0.7292, 0.8104, 0.7411, 0.8318]}, {"w": "scales", "b": [0.7474, 0.8104, 0.7948, 0.8318]}, {"w": "almost", "b": [0.801, 0.8104, 0.8571, 0.8318]}]}, {"id": "b_6", "type": "paragraph", "text": "Nonlinear SVM Classification | 163", "words": [{"w": "Nonlinear", "b": [0.6295, 0.9225, 0.6875, 0.9388]}, {"w": "SVM", "b": [0.6903, 0.9225, 0.716, 0.9388]}, {"w": "Classification", "b": [0.7188, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "163", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 190, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "2 “Sequential Minimal Optimization (SMO),” J. Platt (1998).", "words": [{"w": "2", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Sequential", "b": [0.1587, 0.8749, 0.2306, 0.8912]}, {"w": "Minimal", "b": [0.2342, 0.8749, 0.2896, 0.8912]}, {"w": "Optimization", "b": [0.2932, 0.8749, 0.3789, 0.8912]}, {"w": "(SMO),”", "b": [0.3825, 0.8749, 0.4348, 0.8912]}, {"w": "J.", "b": [0.4384, 0.8749, 0.4466, 0.8912]}, {"w": "Platt", "b": [0.4502, 0.8749, 0.4795, 0.8912]}, {"w": "(1998).", "b": [0.4831, 0.8749, 0.5282, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "linearly with the number of training instances and the number of features: its training time complexity is roughly O(m × n).", "words": [{"w": "linearly", "b": [0.1429, 0.0791, 0.2057, 0.1005]}, {"w": "with", "b": [0.2105, 0.0791, 0.2479, 0.1005]}, {"w": "the", "b": [0.2528, 0.0791, 0.2791, 0.1005]}, {"w": "number", "b": [0.284, 0.0791, 0.3502, 0.1005]}, {"w": "of", "b": [0.3551, 0.0791, 0.3719, 0.1005]}, {"w": "training", "b": [0.3768, 0.0791, 0.4437, 0.1005]}, {"w": "instances", "b": [0.4486, 0.0791, 0.5254, 0.1005]}, {"w": "and", "b": [0.5303, 0.0791, 0.5618, 0.1005]}, {"w": "the", "b": [0.5667, 0.0791, 0.593, 0.1005]}, {"w": "number", "b": [0.5979, 0.0791, 0.6642, 0.1005]}, {"w": "of", "b": [0.6691, 0.0791, 0.6859, 0.1005]}, {"w": "features:", "b": [0.6907, 0.0791, 0.7609, 0.1005]}, {"w": "its", "b": [0.7658, 0.0791, 0.7853, 0.1005]}, {"w": "training", "b": [0.7902, 0.0791, 0.8572, 0.1005]}, {"w": "time", "b": [0.1429, 0.0981, 0.1807, 0.1195]}, {"w": "complexity", "b": [0.1854, 0.0981, 0.2779, 0.1195]}, {"w": "is", "b": [0.2827, 0.0981, 0.2959, 0.1195]}, {"w": "roughly", "b": [0.3006, 0.0981, 0.3657, 0.1195]}, {"w": "O(m", "b": [0.3705, 0.0979, 0.4088, 0.1195]}, {"w": "×", "b": [0.4135, 0.0981, 0.4256, 0.1195]}, {"w": "n).", "b": [0.4304, 0.0979, 0.4534, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "The algorithm takes longer if you require a very high precision. This is controlled by the tolerance hyperparameter ϵ (called tol in Scikit-Learn). In most classification tasks, the default tolerance is fine.", "words": [{"w": "The", "b": [0.1429, 0.1262, 0.1757, 0.1476]}, {"w": "algorithm", "b": [0.1813, 0.1262, 0.2639, 0.1476]}, {"w": "takes", "b": [0.2695, 0.1262, 0.3119, 0.1476]}, {"w": "longer", "b": [0.3174, 0.1262, 0.3711, 0.1476]}, {"w": "if", "b": [0.3767, 0.1262, 0.3884, 0.1476]}, {"w": "you", "b": [0.394, 0.1262, 0.4252, 0.1476]}, {"w": "require", "b": [0.4308, 0.1262, 0.4913, 0.1476]}, {"w": "a", "b": [0.4969, 0.1262, 0.506, 0.1476]}, {"w": "very", "b": [0.5116, 0.1262, 0.548, 0.1476]}, {"w": "high", "b": [0.5536, 0.1262, 0.5912, 0.1476]}, {"w": "precision.", "b": [0.5968, 0.1262, 0.6787, 0.1476]}, {"w": "This", "b": [0.6843, 0.1262, 0.7215, 0.1476]}, {"w": "is", "b": [0.7271, 0.1262, 0.7403, 0.1476]}, {"w": "controlled", "b": [0.7459, 0.1262, 0.8314, 0.1476]}, {"w": "by", "b": [0.837, 0.1262, 0.8571, 0.1476]}, {"w": "the", "b": [0.1429, 0.1462, 0.1692, 0.1676]}, {"w": "tolerance", "b": [0.1776, 0.1462, 0.2546, 0.1676]}, {"w": "hyperparameter", "b": [0.263, 0.1462, 0.3965, 0.1676]}, {"w": "ϵ", "b": [0.4049, 0.1494, 0.4196, 0.1653]}, {"w": "(called", "b": [0.4227, 0.1462, 0.4783, 0.1676]}, {"w": "tol", "b": [0.4867, 0.1494, 0.5163, 0.1644]}, {"w": "in", "b": [0.5247, 0.1462, 0.5417, 0.1676]}, {"w": "Scikit-Learn).", "b": [0.5501, 0.1462, 0.6644, 0.1676]}, {"w": "In", "b": [0.6728, 0.1462, 0.6913, 0.1676]}, {"w": "most", "b": [0.6997, 0.1462, 0.7414, 0.1676]}, {"w": "classification", "b": [0.7498, 0.1462, 0.8571, 0.1676]}, {"w": "tasks,", "b": [0.1429, 0.1652, 0.1887, 0.1866]}, {"w": "the", "b": [0.1935, 0.1652, 0.2198, 0.1866]}, {"w": "default", "b": [0.2245, 0.1652, 0.282, 0.1866]}, {"w": "tolerance", "b": [0.2867, 0.1652, 0.3638, 0.1866]}, {"w": "is", "b": [0.3685, 0.1652, 0.3817, 0.1866]}, {"w": "fine.", "b": [0.3864, 0.1652, 0.4232, 0.1866]}]}, {"id": "b_3", "type": "paragraph", "text": "The SVC class is based on the libsvm library, which implements an algorithm that sup‐ ports the kernel trick.2 The training time complexity is usually between O(m2 × n) and O(m3 × n). Unfortunately, this means that it gets dreadfully slow when the num‐ ber of training instances gets large (e.g., hundreds of thousands of instances). This algorithm is perfect for complex but small or medium training sets. However, it scales well with the number of features, especially with sparse features (i.e., when each instance has few nonzero features). In this case, the algorithm scales roughly with the average number of nonzero features per instance. Table 5-1 compares Scikit-Learn’s SVM classification classes.", "words": [{"w": "The", "b": [0.1429, 0.1942, 0.1757, 0.2156]}, {"w": "SVC", "b": [0.1807, 0.1974, 0.2104, 0.2125]}, {"w": "class", "b": [0.2154, 0.1942, 0.2539, 0.2156]}, {"w": "is", "b": [0.2589, 0.1942, 0.2721, 0.2156]}, {"w": "based", "b": [0.2771, 0.1942, 0.3243, 0.2156]}, {"w": "on", "b": [0.3293, 0.1942, 0.3514, 0.2156]}, {"w": "the", "b": [0.3563, 0.1942, 0.3827, 0.2156]}, {"w": "libsvm", "b": [0.3877, 0.194, 0.4408, 0.2156]}, {"w": "library,", "b": [0.4458, 0.1942, 0.5052, 0.2156]}, {"w": "which", "b": [0.5102, 0.1942, 0.5612, 0.2156]}, {"w": "implements", "b": [0.5661, 0.1942, 0.6644, 0.2156]}, {"w": "an", "b": [0.6693, 0.1942, 0.6899, 0.2156]}, {"w": "algorithm", "b": [0.6946, 0.1942, 0.7773, 0.2156]}, {"w": "that", "b": [0.7825, 0.1942, 0.8151, 0.2156]}, {"w": "sup‐", "b": [0.8198, 0.1942, 0.8569, 0.2156]}, {"w": "ports", "b": [0.1429, 0.2133, 0.1861, 0.2347]}, {"w": "the", "b": [0.1936, 0.2133, 0.2199, 0.2347]}, {"w": "kernel", "b": [0.2273, 0.2133, 0.2798, 0.2347]}, {"w": "trick.2", "b": [0.2872, 0.2133, 0.3365, 0.2347]}, {"w": "The", "b": [0.3439, 0.2133, 0.3768, 0.2347]}, {"w": "training", "b": [0.3842, 0.2133, 0.4512, 0.2347]}, {"w": "time", "b": [0.4586, 0.2133, 0.4964, 0.2347]}, {"w": "complexity", "b": [0.5039, 0.2133, 0.5964, 0.2347]}, {"w": "is", "b": [0.6038, 0.2133, 0.617, 0.2347]}, {"w": "usually", "b": [0.6245, 0.2133, 0.6835, 0.2347]}, {"w": "between", "b": [0.6909, 0.2133, 0.7601, 0.2347]}, {"w": "O(m2", "b": [0.7675, 0.2131, 0.8119, 0.2347]}, {"w": "×", "b": [0.8193, 0.2133, 0.8314, 0.2347]}, {"w": "n)", "b": [0.8389, 0.2131, 0.8571, 0.2347]}, {"w": "and", "b": [0.1429, 0.2323, 0.1744, 0.2537]}, {"w": "O(m3", "b": [0.18, 0.2321, 0.2244, 0.2537]}, {"w": "×", "b": [0.23, 0.2323, 0.2421, 0.2537]}, {"w": "n).", "b": [0.2477, 0.2321, 0.2708, 0.2537]}, {"w": "Unfortunately,", "b": [0.2764, 0.2323, 0.3976, 0.2537]}, {"w": "this", "b": [0.4032, 0.2323, 0.4339, 0.2537]}, {"w": "means", "b": [0.4395, 0.2323, 0.4936, 0.2537]}, {"w": "that", "b": [0.4992, 0.2323, 0.5318, 0.2537]}, {"w": "it", "b": [0.5375, 0.2323, 0.5494, 0.2537]}, {"w": "gets", "b": [0.555, 0.2323, 0.5876, 0.2537]}, {"w": "dreadfully", "b": [0.5932, 0.2323, 0.6783, 0.2537]}, {"w": "slow", "b": [0.6839, 0.2323, 0.7217, 0.2537]}, {"w": "when", "b": [0.7274, 0.2323, 0.773, 0.2537]}, {"w": "the", "b": [0.7786, 0.2323, 0.805, 0.2537]}, {"w": "num‐", "b": [0.8106, 0.2323, 0.8571, 0.2537]}, {"w": "ber", "b": [0.1429, 0.2514, 0.17, 0.2728]}, {"w": "of", "b": [0.1774, 0.2514, 0.1942, 0.2728]}, {"w": "training", "b": [0.2015, 0.2514, 0.2684, 0.2728]}, {"w": "instances", "b": [0.2758, 0.2514, 0.3526, 0.2728]}, {"w": "gets", "b": [0.36, 0.2514, 0.3926, 0.2728]}, {"w": "large", "b": [0.3999, 0.2514, 0.4407, 0.2728]}, {"w": "(e.g.,", "b": [0.448, 0.2514, 0.4881, 0.2728]}, {"w": "hundreds", "b": [0.4954, 0.2514, 0.5748, 0.2728]}, {"w": "of", "b": [0.5822, 0.2514, 0.599, 0.2728]}, {"w": "thousands", "b": [0.6063, 0.2514, 0.6923, 0.2728]}, {"w": "of", "b": [0.6997, 0.2514, 0.7164, 0.2728]}, {"w": "instances).", "b": [0.7238, 0.2514, 0.8126, 0.2728]}, {"w": "This", "b": [0.8199, 0.2514, 0.8571, 0.2728]}, {"w": "algorithm", "b": [0.1429, 0.2704, 0.2255, 0.2918]}, {"w": "is", "b": [0.2304, 0.2704, 0.2436, 0.2918]}, {"w": "perfect", "b": [0.2485, 0.2704, 0.3062, 0.2918]}, {"w": "for", "b": [0.3111, 0.2704, 0.3356, 0.2918]}, {"w": "complex", "b": [0.3405, 0.2704, 0.4115, 0.2918]}, {"w": "but", "b": [0.4163, 0.2704, 0.4443, 0.2918]}, {"w": "small", "b": [0.4492, 0.2704, 0.4936, 0.2918]}, {"w": "or", "b": [0.4985, 0.2704, 0.5169, 0.2918]}, {"w": "medium", "b": [0.5218, 0.2704, 0.5924, 0.2918]}, {"w": "training", "b": [0.5973, 0.2704, 0.6642, 0.2918]}, {"w": "sets.", "b": [0.6691, 0.2704, 0.7043, 0.2918]}, {"w": "However,", "b": [0.7092, 0.2704, 0.7881, 0.2918]}, {"w": "it", "b": [0.793, 0.2704, 0.8049, 0.2918]}, {"w": "scales", "b": [0.8098, 0.2704, 0.8572, 0.2918]}, {"w": "well", "b": [0.1429, 0.2895, 0.1765, 0.3109]}, {"w": "with", "b": [0.1861, 0.2895, 0.2234, 0.3109]}, {"w": "the", "b": [0.2329, 0.2895, 0.2593, 0.3109]}, {"w": "number", "b": [0.2688, 0.2895, 0.3351, 0.3109]}, {"w": "of", "b": [0.3446, 0.2895, 0.3614, 0.3109]}, {"w": "features,", "b": [0.3709, 0.2895, 0.4411, 0.3109]}, {"w": "especially", "b": [0.4506, 0.2895, 0.5305, 0.3109]}, {"w": "with", "b": [0.5401, 0.2895, 0.5774, 0.3109]}, {"w": "sparse", "b": [0.5869, 0.2893, 0.6366, 0.3109]}, {"w": "features", "b": [0.6462, 0.2893, 0.7091, 0.3109]}, {"w": "(i.e.,", "b": [0.7186, 0.2895, 0.7545, 0.3109]}, {"w": "when", "b": [0.764, 0.2895, 0.8097, 0.3109]}, {"w": "each", "b": [0.8192, 0.2895, 0.8571, 0.3109]}, {"w": "instance", "b": [0.1429, 0.3085, 0.212, 0.3299]}, {"w": "has", "b": [0.2172, 0.3085, 0.2452, 0.3299]}, {"w": "few", "b": [0.2504, 0.3085, 0.2796, 0.3299]}, {"w": "nonzero", "b": [0.2848, 0.3085, 0.3542, 0.3299]}, {"w": "features).", "b": [0.3594, 0.3085, 0.4368, 0.3299]}, {"w": "In", "b": [0.442, 0.3085, 0.4605, 0.3299]}, {"w": "this", "b": [0.4657, 0.3085, 0.4964, 0.3299]}, {"w": "case,", "b": [0.5016, 0.3085, 0.5408, 0.3299]}, {"w": "the", "b": [0.546, 0.3085, 0.5723, 0.3299]}, {"w": "algorithm", "b": [0.5775, 0.3085, 0.6602, 0.3299]}, {"w": "scales", "b": [0.6654, 0.3085, 0.7128, 0.3299]}, {"w": "roughly", "b": [0.718, 0.3085, 0.7831, 0.3299]}, {"w": "with", "b": [0.7883, 0.3085, 0.8256, 0.3299]}, {"w": "the", "b": [0.8308, 0.3085, 0.8571, 0.3299]}, {"w": "average", "b": [0.1429, 0.3276, 0.2056, 0.349]}, {"w": "number", "b": [0.2125, 0.3276, 0.2788, 0.349]}, {"w": "of", "b": [0.2857, 0.3276, 0.3024, 0.349]}, {"w": "nonzero", "b": [0.3093, 0.3276, 0.3787, 0.349]}, {"w": "features", "b": [0.3856, 0.3276, 0.451, 0.349]}, {"w": "per", "b": [0.4579, 0.3276, 0.4854, 0.349]}, {"w": "instance.", "b": [0.4922, 0.3276, 0.5662, 0.349]}, {"w": "Table", "b": [0.573, 0.3276, 0.6178, 0.349]}, {"w": "5-1", "b": [0.6247, 0.3276, 0.6521, 0.349]}, {"w": "compares", "b": [0.659, 0.3276, 0.7394, 0.349]}, {"w": "Scikit-Learn’s", "b": [0.7463, 0.3276, 0.8572, 0.349]}, {"w": "SVM", "b": [0.1429, 0.3466, 0.1859, 0.368]}, {"w": "classification", "b": [0.1907, 0.3466, 0.2981, 0.368]}, {"w": "classes.", "b": [0.3028, 0.3466, 0.3626, 0.368]}]}, {"id": "b_4", "type": "equation", "text": "Table 5-1. Comparison of Scikit-Learn classes for SVM classification", "words": [{"w": "Table", "b": [0.1429, 0.3845, 0.1844, 0.4051]}, {"w": "5-1.", "b": [0.189, 0.3845, 0.2192, 0.4051]}, {"w": "Comparison", "b": [0.2237, 0.3845, 0.3192, 0.4051]}, {"w": "of", "b": [0.3237, 0.3845, 0.3382, 0.4051]}, {"w": "Scikit-Learn", "b": [0.3427, 0.3845, 0.4377, 0.4051]}, {"w": "classes", "b": [0.4423, 0.3845, 0.4919, 0.4051]}, {"w": "for", "b": [0.4964, 0.3845, 0.518, 0.4051]}, {"w": "SVM", "b": [0.5225, 0.3845, 0.5626, 0.4051]}, {"w": "classification", "b": [0.5671, 0.3845, 0.6674, 0.4051]}]}, {"id": "b_5", "type": "equation", "text": "Class Time complexity Out-of-core support Scaling required Kernel trick", "words": [{"w": "Class", "b": [0.15, 0.413, 0.1787, 0.4293]}, {"w": "Time", "b": [0.2739, 0.413, 0.3029, 0.4293]}, {"w": "complexity", "b": [0.3063, 0.413, 0.3713, 0.4293]}, {"w": "Out-of-core", "b": [0.4191, 0.413, 0.4865, 0.4293]}, {"w": "support", "b": [0.4899, 0.413, 0.5355, 0.4293]}, {"w": "Scaling", "b": [0.5498, 0.413, 0.592, 0.4293]}, {"w": "required", "b": [0.5954, 0.413, 0.6457, 0.4293]}, {"w": "Kernel", "b": [0.66, 0.413, 0.6982, 0.4293]}, {"w": "trick", "b": [0.7016, 0.413, 0.7277, 0.4293]}]}, {"id": "b_6", "type": "paragraph", "text": "LinearSVC O(m × n) No Yes No", "words": [{"w": "LinearSVC", "b": [0.15, 0.4363, 0.2259, 0.4491]}, {"w": "O(m", "b": [0.2739, 0.4334, 0.297, 0.4495]}, {"w": "×", "b": [0.3004, 0.4334, 0.311, 0.4495]}, {"w": "n)", "b": [0.3144, 0.4334, 0.326, 0.4495]}, {"w": "No", "b": [0.4191, 0.4334, 0.4342, 0.4495]}, {"w": "Yes", "b": [0.5498, 0.4334, 0.5685, 0.4495]}, {"w": "No", "b": [0.66, 0.4334, 0.6751, 0.4495]}]}, {"id": "b_7", "type": "paragraph", "text": "SGDClassifier O(m × n) Yes Yes No", "words": [{"w": "SGDClassifier", "b": [0.15, 0.4581, 0.2596, 0.471]}, {"w": "O(m", "b": [0.2739, 0.4552, 0.297, 0.4713]}, {"w": "×", "b": [0.3004, 0.4552, 0.311, 0.4713]}, {"w": "n)", "b": [0.3144, 0.4552, 0.326, 0.4713]}, {"w": "Yes", "b": [0.4191, 0.4552, 0.4377, 0.4713]}, {"w": "Yes", "b": [0.5498, 0.4552, 0.5685, 0.4713]}, {"w": "No", "b": [0.66, 0.4552, 0.6751, 0.4713]}]}, {"id": "b_8", "type": "paragraph", "text": "SVC O(m² × n) to O(m³ × n) No Yes Yes", "words": [{"w": "SVC", "b": [0.15, 0.48, 0.1753, 0.4928]}, {"w": "O(m²", "b": [0.2739, 0.4771, 0.3014, 0.4932]}, {"w": "×", "b": [0.3047, 0.4771, 0.3154, 0.4932]}, {"w": "n)", "b": [0.3188, 0.4771, 0.3303, 0.4932]}, {"w": "to", "b": [0.3337, 0.4771, 0.3451, 0.4932]}, {"w": "O(m³", "b": [0.3485, 0.4771, 0.3758, 0.4932]}, {"w": "×", "b": [0.3792, 0.4771, 0.3898, 0.4932]}, {"w": "n)", "b": [0.3932, 0.4771, 0.4048, 0.4932]}, {"w": "No", "b": [0.4191, 0.4771, 0.4342, 0.4932]}, {"w": "Yes", "b": [0.5498, 0.4771, 0.5685, 0.4932]}, {"w": "Yes", "b": [0.66, 0.4771, 0.6787, 0.4932]}]}, {"id": "b_9", "type": "paragraph", "text": "SVM Regression", "words": [{"w": "SVM", "b": [0.1429, 0.5109, 0.1968, 0.5452]}, {"w": "Regression", "b": [0.2027, 0.5109, 0.3377, 0.5452]}]}, {"id": "b_10", "type": "paragraph", "text": "As we mentioned earlier, the SVM algorithm is quite versatile: not only does it sup‐ port linear and nonlinear classification, but it also supports linear and nonlinear regression. The trick is to reverse the objective: instead of trying to fit the largest pos‐ sible street between two classes while limiting margin violations, SVM Regression tries to fit as many instances as possible on the street while limiting margin violations (i.e., instances off the street). The width of the street is controlled by a hyperparame‐ ter ϵ. Figure 5-10 shows two linear SVM Regression models trained on some random linear data, one with a large margin (ϵ = 1.5) and the other with a small margin (ϵ = 0.5).", "words": [{"w": "As", "b": [0.1429, 0.5521, 0.1649, 0.5735]}, {"w": "we", "b": [0.1712, 0.5521, 0.1943, 0.5735]}, {"w": "mentioned", "b": [0.2006, 0.5521, 0.2914, 0.5735]}, {"w": "earlier,", "b": [0.2977, 0.5521, 0.3543, 0.5735]}, {"w": "the", "b": [0.3606, 0.5521, 0.3869, 0.5735]}, {"w": "SVM", "b": [0.3932, 0.5521, 0.4363, 0.5735]}, {"w": "algorithm", "b": [0.4426, 0.5521, 0.5252, 0.5735]}, {"w": "is", "b": [0.5315, 0.5521, 0.5448, 0.5735]}, {"w": "quite", "b": [0.5511, 0.5521, 0.5936, 0.5735]}, {"w": "versatile:", "b": [0.5999, 0.5521, 0.6733, 0.5735]}, {"w": "not", "b": [0.6796, 0.5521, 0.708, 0.5735]}, {"w": "only", "b": [0.7143, 0.5521, 0.7511, 0.5735]}, {"w": "does", "b": [0.7574, 0.5521, 0.7956, 0.5735]}, {"w": "it", "b": [0.8019, 0.5521, 0.8138, 0.5735]}, {"w": "sup‐", "b": [0.8201, 0.5521, 0.8571, 0.5735]}, {"w": "port", "b": [0.1429, 0.5711, 0.1785, 0.5925]}, {"w": "linear", "b": [0.1875, 0.5711, 0.2355, 0.5925]}, {"w": "and", "b": [0.2445, 0.5711, 0.276, 0.5925]}, {"w": "nonlinear", "b": [0.285, 0.5711, 0.3664, 0.5925]}, {"w": "classification,", "b": [0.3755, 0.5711, 0.4876, 0.5925]}, {"w": "but", "b": [0.4966, 0.5711, 0.5246, 0.5925]}, {"w": "it", "b": [0.5336, 0.5711, 0.5456, 0.5925]}, {"w": "also", "b": [0.5546, 0.5711, 0.5873, 0.5925]}, {"w": "supports", "b": [0.5963, 0.5711, 0.6692, 0.5925]}, {"w": "linear", "b": [0.6782, 0.5711, 0.7262, 0.5925]}, {"w": "and", "b": [0.7352, 0.5711, 0.7667, 0.5925]}, {"w": "nonlinear", "b": [0.7757, 0.5711, 0.8571, 0.5925]}, {"w": "regression.", "b": [0.1428, 0.5902, 0.2334, 0.6116]}, {"w": "The", "b": [0.2385, 0.5902, 0.2713, 0.6116]}, {"w": "trick", "b": [0.2764, 0.5902, 0.3152, 0.6116]}, {"w": "is", "b": [0.3203, 0.5902, 0.3335, 0.6116]}, {"w": "to", "b": [0.3386, 0.5902, 0.3556, 0.6116]}, {"w": "reverse", "b": [0.3607, 0.5902, 0.42, 0.6116]}, {"w": "the", "b": [0.4251, 0.5902, 0.4514, 0.6116]}, {"w": "objective:", "b": [0.4565, 0.5902, 0.5359, 0.6116]}, {"w": "instead", "b": [0.541, 0.5902, 0.601, 0.6116]}, {"w": "of", "b": [0.6061, 0.5902, 0.6229, 0.6116]}, {"w": "trying", "b": [0.6279, 0.5902, 0.6789, 0.6116]}, {"w": "to", "b": [0.684, 0.5902, 0.701, 0.6116]}, {"w": "fit", "b": [0.7061, 0.5902, 0.7242, 0.6116]}, {"w": "the", "b": [0.7293, 0.5902, 0.7556, 0.6116]}, {"w": "largest", "b": [0.7607, 0.5902, 0.8154, 0.6116]}, {"w": "pos‐", "b": [0.8205, 0.5902, 0.8571, 0.6116]}, {"w": "sible", "b": [0.1429, 0.6092, 0.1808, 0.6306]}, {"w": "street", "b": [0.189, 0.6092, 0.2348, 0.6306]}, {"w": "between", "b": [0.2431, 0.6092, 0.3122, 0.6306]}, {"w": "two", "b": [0.3205, 0.6092, 0.3517, 0.6306]}, {"w": "classes", "b": [0.36, 0.6092, 0.415, 0.6306]}, {"w": "while", "b": [0.4232, 0.6092, 0.4683, 0.6306]}, {"w": "limiting", "b": [0.4766, 0.6092, 0.5432, 0.6306]}, {"w": "margin", "b": [0.5514, 0.6092, 0.6121, 0.6306]}, {"w": "violations,", "b": [0.6203, 0.6092, 0.7066, 0.6306]}, {"w": "SVM", "b": [0.7148, 0.6092, 0.7579, 0.6306]}, {"w": "Regression", "b": [0.7661, 0.6092, 0.8571, 0.6306]}, {"w": "tries", "b": [0.1429, 0.6283, 0.179, 0.6497]}, {"w": "to", "b": [0.1842, 0.6283, 0.2012, 0.6497]}, {"w": "fit", "b": [0.2063, 0.6283, 0.2244, 0.6497]}, {"w": "as", "b": [0.2296, 0.6283, 0.2464, 0.6497]}, {"w": "many", "b": [0.2515, 0.6283, 0.2982, 0.6497]}, {"w": "instances", "b": [0.3034, 0.6283, 0.3802, 0.6497]}, {"w": "as", "b": [0.3854, 0.6283, 0.4021, 0.6497]}, {"w": "possible", "b": [0.4073, 0.6283, 0.4744, 0.6497]}, {"w": "on", "b": [0.4796, 0.6281, 0.5002, 0.6497]}, {"w": "the", "b": [0.5054, 0.6283, 0.5317, 0.6497]}, {"w": "street", "b": [0.5369, 0.6283, 0.5827, 0.6497]}, {"w": "while", "b": [0.5879, 0.6283, 0.633, 0.6497]}, {"w": "limiting", "b": [0.6381, 0.6283, 0.7047, 0.6497]}, {"w": "margin", "b": [0.7099, 0.6283, 0.7705, 0.6497]}, {"w": "violations", "b": [0.7757, 0.6283, 0.8572, 0.6497]}, {"w": "(i.e.,", "b": [0.1429, 0.6473, 0.1788, 0.6687]}, {"w": "instances", "b": [0.1845, 0.6473, 0.2613, 0.6687]}, {"w": "off", "b": [0.2671, 0.6471, 0.2879, 0.6687]}, {"w": "the", "b": [0.2937, 0.6473, 0.32, 0.6687]}, {"w": "street).", "b": [0.3258, 0.6473, 0.3835, 0.6687]}, {"w": "The", "b": [0.3893, 0.6473, 0.4221, 0.6687]}, {"w": "width", "b": [0.4278, 0.6473, 0.4762, 0.6687]}, {"w": "of", "b": [0.4819, 0.6473, 0.4987, 0.6687]}, {"w": "the", "b": [0.5045, 0.6473, 0.5308, 0.6687]}, {"w": "street", "b": [0.5366, 0.6473, 0.5823, 0.6687]}, {"w": "is", "b": [0.5881, 0.6473, 0.6013, 0.6687]}, {"w": "controlled", "b": [0.6071, 0.6473, 0.6926, 0.6687]}, {"w": "by", "b": [0.6984, 0.6473, 0.7185, 0.6687]}, {"w": "a", "b": [0.7243, 0.6473, 0.7334, 0.6687]}, {"w": "hyperparame‐", "b": [0.7392, 0.6473, 0.8571, 0.6687]}, {"w": "ter", "b": [0.1429, 0.6664, 0.1658, 0.6878]}, {"w": "ϵ.", "b": [0.171, 0.6664, 0.1856, 0.6878]}, {"w": "Figure", "b": [0.1903, 0.6664, 0.2443, 0.6878]}, {"w": "5-10", "b": [0.249, 0.6664, 0.2864, 0.6878]}, {"w": "shows", "b": [0.2921, 0.6664, 0.3434, 0.6878]}, {"w": "two", "b": [0.3486, 0.6664, 0.3798, 0.6878]}, {"w": "linear", "b": [0.385, 0.6664, 0.433, 0.6878]}, {"w": "SVM", "b": [0.4382, 0.6664, 0.4813, 0.6878]}, {"w": "Regression", "b": [0.4865, 0.6664, 0.5775, 0.6878]}, {"w": "models", "b": [0.5827, 0.6664, 0.6431, 0.6878]}, {"w": "trained", "b": [0.6483, 0.6664, 0.7084, 0.6878]}, {"w": "on", "b": [0.7136, 0.6664, 0.7356, 0.6878]}, {"w": "some", "b": [0.7408, 0.6664, 0.785, 0.6878]}, {"w": "random", "b": [0.7902, 0.6664, 0.8571, 0.6878]}, {"w": "linear", "b": [0.1428, 0.6854, 0.1908, 0.7068]}, {"w": "data,", "b": [0.1966, 0.6854, 0.2366, 0.7068]}, {"w": "one", "b": [0.2424, 0.6854, 0.2733, 0.7068]}, {"w": "with", "b": [0.2791, 0.6854, 0.3164, 0.7068]}, {"w": "a", "b": [0.3222, 0.6854, 0.3313, 0.7068]}, {"w": "large", "b": [0.3371, 0.6854, 0.3779, 0.7068]}, {"w": "margin", "b": [0.3837, 0.6854, 0.4443, 0.7068]}, {"w": "(ϵ", "b": [0.4501, 0.6854, 0.472, 0.7068]}, {"w": "=", "b": [0.4725, 0.6854, 0.4846, 0.7068]}, {"w": "1.5)", "b": [0.4904, 0.6854, 0.5223, 0.7068]}, {"w": "and", "b": [0.5281, 0.6854, 0.5596, 0.7068]}, {"w": "the", "b": [0.5654, 0.6854, 0.5918, 0.7068]}, {"w": "other", "b": [0.5975, 0.6854, 0.6422, 0.7068]}, {"w": "with", "b": [0.648, 0.6854, 0.6854, 0.7068]}, {"w": "a", "b": [0.6911, 0.6854, 0.7003, 0.7068]}, {"w": "small", "b": [0.7061, 0.6854, 0.7505, 0.7068]}, {"w": "margin", "b": [0.7563, 0.6854, 0.8169, 0.7068]}, {"w": "(ϵ", "b": [0.8227, 0.6854, 0.8446, 0.7068]}, {"w": "=", "b": [0.8451, 0.6854, 0.8571, 0.7068]}, {"w": "0.5).", "b": [0.1429, 0.7045, 0.1796, 0.7259]}]}, {"id": "b_11", "type": "paragraph", "text": "164 | Chapter 5: Support Vector Machines", "words": [{"w": "164", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "5:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Support", "b": [0.2673, 0.9225, 0.3142, 0.9388]}, {"w": "Vector", "b": [0.317, 0.9225, 0.3547, 0.9388]}, {"w": "Machines", "b": [0.3575, 0.9225, 0.413, 0.9388]}]}]}, {"page": 191, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 5-10. SVM Regression", "words": [{"w": "Figure", "b": [0.1429, 0.321, 0.1943, 0.3426]}, {"w": "5-10.", "b": [0.1991, 0.321, 0.2407, 0.3426]}, {"w": "SVM", "b": [0.2455, 0.321, 0.2876, 0.3426]}, {"w": "Regression", "b": [0.2923, 0.321, 0.3771, 0.3426]}]}, {"id": "b_1", "type": "paragraph", "text": "Adding more training instances within the margin does not affect the model’s predic‐ tions; thus, the model is said to be ϵ-insensitive.", "words": [{"w": "Adding", "b": [0.1429, 0.3584, 0.2054, 0.3798]}, {"w": "more", "b": [0.2105, 0.3584, 0.2548, 0.3798]}, {"w": "training", "b": [0.2599, 0.3584, 0.3268, 0.3798]}, {"w": "instances", "b": [0.3319, 0.3584, 0.4088, 0.3798]}, {"w": "within", "b": [0.4139, 0.3584, 0.4682, 0.3798]}, {"w": "the", "b": [0.4733, 0.3584, 0.4996, 0.3798]}, {"w": "margin", "b": [0.5047, 0.3584, 0.5654, 0.3798]}, {"w": "does", "b": [0.5704, 0.3584, 0.6086, 0.3798]}, {"w": "not", "b": [0.6137, 0.3584, 0.642, 0.3798]}, {"w": "affect", "b": [0.6471, 0.3584, 0.6926, 0.3798]}, {"w": "the", "b": [0.6977, 0.3584, 0.7241, 0.3798]}, {"w": "model’s", "b": [0.7292, 0.3584, 0.7917, 0.3798]}, {"w": "predic‐", "b": [0.7968, 0.3584, 0.8571, 0.3798]}, {"w": "tions;", "b": [0.1429, 0.3774, 0.1892, 0.3988]}, {"w": "thus,", "b": [0.1939, 0.3774, 0.2345, 0.3988]}, {"w": "the", "b": [0.2392, 0.3774, 0.2655, 0.3988]}, {"w": "model", "b": [0.2703, 0.3774, 0.3231, 0.3988]}, {"w": "is", "b": [0.3278, 0.3774, 0.341, 0.3988]}, {"w": "said", "b": [0.3458, 0.3774, 0.3791, 0.3988]}, {"w": "to", "b": [0.3839, 0.3774, 0.4009, 0.3988]}, {"w": "be", "b": [0.4056, 0.3774, 0.425, 0.3988]}, {"w": "ϵ-insensitive.", "b": [0.4297, 0.3772, 0.5352, 0.3988]}]}, {"id": "b_2", "type": "paragraph", "text": "You can use Scikit-Learn’s LinearSVR class to perform linear SVM Regression. The following code produces the model represented on the left of Figure 5-10 (the train‐ ing data should be scaled and centered first):", "words": [{"w": "You", "b": [0.1429, 0.4064, 0.1752, 0.4278]}, {"w": "can", "b": [0.1826, 0.4064, 0.2119, 0.4278]}, {"w": "use", "b": [0.2193, 0.4064, 0.2468, 0.4278]}, {"w": "Scikit-Learn’s", "b": [0.2542, 0.4064, 0.3651, 0.4278]}, {"w": "LinearSVR", "b": [0.3724, 0.4096, 0.4615, 0.4247]}, {"w": "class", "b": [0.4688, 0.4064, 0.5073, 0.4278]}, {"w": "to", "b": [0.5147, 0.4064, 0.5317, 0.4278]}, {"w": "perform", "b": [0.539, 0.4064, 0.6081, 0.4278]}, {"w": "linear", "b": [0.6154, 0.4064, 0.6634, 0.4278]}, {"w": "SVM", "b": [0.6708, 0.4064, 0.7138, 0.4278]}, {"w": "Regression.", "b": [0.7212, 0.4064, 0.817, 0.4278]}, {"w": "The", "b": [0.8243, 0.4064, 0.8571, 0.4278]}, {"w": "following", "b": [0.1429, 0.4255, 0.2218, 0.4469]}, {"w": "code", "b": [0.2278, 0.4255, 0.2671, 0.4469]}, {"w": "produces", "b": [0.2731, 0.4255, 0.3498, 0.4469]}, {"w": "the", "b": [0.3558, 0.4255, 0.3821, 0.4469]}, {"w": "model", "b": [0.3881, 0.4255, 0.4409, 0.4469]}, {"w": "represented", "b": [0.4469, 0.4255, 0.5447, 0.4469]}, {"w": "on", "b": [0.5507, 0.4255, 0.5728, 0.4469]}, {"w": "the", "b": [0.5788, 0.4255, 0.6051, 0.4469]}, {"w": "left", "b": [0.6111, 0.4255, 0.6377, 0.4469]}, {"w": "of", "b": [0.6438, 0.4255, 0.6605, 0.4469]}, {"w": "Figure", "b": [0.6665, 0.4255, 0.7205, 0.4469]}, {"w": "5-10", "b": [0.7266, 0.4255, 0.764, 0.4469]}, {"w": "(the", "b": [0.77, 0.4255, 0.8035, 0.4469]}, {"w": "train‐", "b": [0.8095, 0.4255, 0.8572, 0.4469]}, {"w": "ing", "b": [0.1429, 0.4445, 0.1696, 0.4659]}, {"w": "data", "b": [0.1743, 0.4445, 0.2096, 0.4659]}, {"w": "should", "b": [0.2143, 0.4445, 0.271, 0.4659]}, {"w": "be", "b": [0.2758, 0.4445, 0.2952, 0.4659]}, {"w": "scaled", "b": [0.2999, 0.4445, 0.3507, 0.4659]}, {"w": "and", "b": [0.3554, 0.4445, 0.3869, 0.4659]}, {"w": "centered", "b": [0.3917, 0.4445, 0.4631, 0.4659]}, {"w": "first):", "b": [0.4678, 0.4445, 0.5133, 0.4659]}]}, {"id": "b_3", "type": "paragraph", "text": "from sklearn.svm import LinearSVR", "words": [{"w": "from", "b": [0.1766, 0.4765, 0.2103, 0.4893]}, {"w": "sklearn.svm", "b": [0.2187, 0.4765, 0.3115, 0.4893]}, {"w": "import", "b": [0.3199, 0.4765, 0.3705, 0.4893]}, {"w": "LinearSVR", "b": [0.379, 0.4765, 0.4549, 0.4893]}]}, {"id": "b_4", "type": "equation", "text": "svm_reg = LinearSVR(epsilon=1.5) svm_reg.fit(X, y)", "words": [{"w": "svm_reg", "b": [0.1766, 0.5073, 0.2356, 0.5202]}, {"w": "=", "b": [0.244, 0.5073, 0.2525, 0.5202]}, {"w": "LinearSVR(epsilon=1.5)", "b": [0.2609, 0.5073, 0.4464, 0.5202]}, {"w": "svm_reg.fit(X,", "b": [0.1766, 0.5228, 0.2946, 0.5356]}, {"w": "y)", "b": [0.3031, 0.5228, 0.3199, 0.5356]}]}, {"id": "b_5", "type": "paragraph", "text": "To tackle nonlinear regression tasks, you can use a kernelized SVM model. For exam‐ ple, Figure 5-11 shows SVM Regression on a random quadratic training set, using a 2nd-degree polynomial kernel. There is little regularization on the left plot (i.e., a large C value), and much more regularization on the right plot (i.e., a small C value).", "words": [{"w": "To", "b": [0.1429, 0.5434, 0.1643, 0.5648]}, {"w": "tackle", "b": [0.1693, 0.5434, 0.2181, 0.5648]}, {"w": "nonlinear", "b": [0.2231, 0.5434, 0.3045, 0.5648]}, {"w": "regression", "b": [0.3095, 0.5434, 0.3953, 0.5648]}, {"w": "tasks,", "b": [0.4003, 0.5434, 0.4462, 0.5648]}, {"w": "you", "b": [0.4512, 0.5434, 0.4824, 0.5648]}, {"w": "can", "b": [0.4874, 0.5434, 0.5168, 0.5648]}, {"w": "use", "b": [0.5218, 0.5434, 0.5494, 0.5648]}, {"w": "a", "b": [0.5544, 0.5434, 0.5635, 0.5648]}, {"w": "kernelized", "b": [0.5685, 0.5434, 0.6552, 0.5648]}, {"w": "SVM", "b": [0.6602, 0.5434, 0.7033, 0.5648]}, {"w": "model.", "b": [0.7083, 0.5434, 0.7658, 0.5648]}, {"w": "For", "b": [0.7708, 0.5434, 0.7998, 0.5648]}, {"w": "exam‐", "b": [0.8048, 0.5434, 0.8571, 0.5648]}, {"w": "ple,", "b": [0.1429, 0.5624, 0.1727, 0.5838]}, {"w": "Figure", "b": [0.1789, 0.5624, 0.2329, 0.5838]}, {"w": "5-11", "b": [0.2392, 0.5624, 0.2766, 0.5838]}, {"w": "shows", "b": [0.2828, 0.5624, 0.3342, 0.5838]}, {"w": "SVM", "b": [0.3404, 0.5624, 0.3835, 0.5838]}, {"w": "Regression", "b": [0.3898, 0.5624, 0.4808, 0.5838]}, {"w": "on", "b": [0.487, 0.5624, 0.509, 0.5838]}, {"w": "a", "b": [0.5153, 0.5624, 0.5244, 0.5838]}, {"w": "random", "b": [0.5307, 0.5624, 0.5977, 0.5838]}, {"w": "quadratic", "b": [0.6039, 0.5624, 0.683, 0.5838]}, {"w": "training", "b": [0.6893, 0.5624, 0.7562, 0.5838]}, {"w": "set,", "b": [0.7625, 0.5624, 0.7901, 0.5838]}, {"w": "using", "b": [0.7963, 0.5624, 0.8418, 0.5838]}, {"w": "a", "b": [0.848, 0.5624, 0.8572, 0.5838]}, {"w": "2nd-degree", "b": [0.1429, 0.5815, 0.2288, 0.6029]}, {"w": "polynomial", "b": [0.2337, 0.5815, 0.3292, 0.6029]}, {"w": "kernel.", "b": [0.3342, 0.5815, 0.3914, 0.6029]}, {"w": "There", "b": [0.3964, 0.5815, 0.4458, 0.6029]}, {"w": "is", "b": [0.4508, 0.5815, 0.464, 0.6029]}, {"w": "little", "b": [0.469, 0.5815, 0.5067, 0.6029]}, {"w": "regularization", "b": [0.5117, 0.5815, 0.6283, 0.6029]}, {"w": "on", "b": [0.6332, 0.5815, 0.6553, 0.6029]}, {"w": "the", "b": [0.6603, 0.5815, 0.6866, 0.6029]}, {"w": "left", "b": [0.6916, 0.5815, 0.7182, 0.6029]}, {"w": "plot", "b": [0.7232, 0.5815, 0.7564, 0.6029]}, {"w": "(i.e.,", "b": [0.7614, 0.5815, 0.7973, 0.6029]}, {"w": "a", "b": [0.8023, 0.5815, 0.8114, 0.6029]}, {"w": "large", "b": [0.8164, 0.5815, 0.8571, 0.6029]}, {"w": "C", "b": [0.1429, 0.6046, 0.1528, 0.6197]}, {"w": "value),", "b": [0.1575, 0.6014, 0.2134, 0.6228]}, {"w": "and", "b": [0.2182, 0.6014, 0.2497, 0.6228]}, {"w": "much", "b": [0.2544, 0.6014, 0.3021, 0.6228]}, {"w": "more", "b": [0.3068, 0.6014, 0.3511, 0.6228]}, {"w": "regularization", "b": [0.3558, 0.6014, 0.4724, 0.6228]}, {"w": "on", "b": [0.4771, 0.6014, 0.4992, 0.6228]}, {"w": "the", "b": [0.5039, 0.6014, 0.5302, 0.6228]}, {"w": "right", "b": [0.5349, 0.6014, 0.5751, 0.6228]}, {"w": "plot", "b": [0.5798, 0.6014, 0.613, 0.6228]}, {"w": "(i.e.,", "b": [0.6177, 0.6014, 0.6536, 0.6228]}, {"w": "a", "b": [0.6583, 0.6014, 0.6675, 0.6228]}, {"w": "small", "b": [0.6722, 0.6014, 0.7166, 0.6228]}, {"w": "C", "b": [0.7213, 0.6046, 0.7312, 0.6197]}, {"w": "value).", "b": [0.736, 0.6014, 0.7919, 0.6228]}]}, {"id": "b_6", "type": "equation", "text": "Figure 5-11. SVM regression using a 2nd-degree polynomial kernel", "words": [{"w": "Figure", "b": [0.1429, 0.8706, 0.1943, 0.8922]}, {"w": "5-11.", "b": [0.1991, 0.8706, 0.2407, 0.8922]}, {"w": "SVM", "b": [0.2455, 0.8706, 0.2876, 0.8922]}, {"w": "regression", "b": [0.2923, 0.8706, 0.3719, 0.8922]}, {"w": "using", "b": [0.3767, 0.8706, 0.4196, 0.8922]}, {"w": "a", "b": [0.4244, 0.8706, 0.4346, 0.8922]}, {"w": "2nd-degree", "b": [0.4394, 0.8706, 0.5205, 0.8922]}, {"w": "polynomial", "b": [0.5252, 0.8706, 0.6166, 0.8922]}, {"w": "kernel", "b": [0.6213, 0.8706, 0.6712, 0.8922]}]}, {"id": "b_7", "type": "paragraph", "text": "SVM Regression | 165", "words": [{"w": "SVM", "b": [0.7032, 0.9225, 0.7288, 0.9388]}, {"w": "Regression", "b": [0.7316, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "165", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 192, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "The following code produces the model represented on the left of Figure 5-11 using Scikit-Learn’s SVR class (which supports the kernel trick). The SVR class is the regres‐ sion equivalent of the SVC class, and the LinearSVR class is the regression equivalent of the LinearSVC class. The LinearSVR class scales linearly with the size of the train‐ ing set (just like the LinearSVC class), while the SVR class gets much too slow when the training set grows large (just like the SVC class).", "words": [{"w": "The", "b": [0.1429, 0.0791, 0.1757, 0.1005]}, {"w": "following", "b": [0.1819, 0.0791, 0.2609, 0.1005]}, {"w": "code", "b": [0.2671, 0.0791, 0.3064, 0.1005]}, {"w": "produces", "b": [0.3126, 0.0791, 0.3893, 0.1005]}, {"w": "the", "b": [0.3955, 0.0791, 0.4218, 0.1005]}, {"w": "model", "b": [0.4281, 0.0791, 0.4809, 0.1005]}, {"w": "represented", "b": [0.4871, 0.0791, 0.5849, 0.1005]}, {"w": "on", "b": [0.5911, 0.0791, 0.6131, 0.1005]}, {"w": "the", "b": [0.6194, 0.0791, 0.6457, 0.1005]}, {"w": "left", "b": [0.6519, 0.0791, 0.6786, 0.1005]}, {"w": "of", "b": [0.6848, 0.0791, 0.7016, 0.1005]}, {"w": "Figure", "b": [0.7078, 0.0791, 0.7618, 0.1005]}, {"w": "5-11", "b": [0.7681, 0.0791, 0.8055, 0.1005]}, {"w": "using", "b": [0.8117, 0.0791, 0.8571, 0.1005]}, {"w": "Scikit-Learn’s", "b": [0.1429, 0.099, 0.2537, 0.1204]}, {"w": "SVR", "b": [0.2596, 0.1022, 0.2893, 0.1173]}, {"w": "class", "b": [0.2951, 0.099, 0.3337, 0.1204]}, {"w": "(which", "b": [0.3395, 0.099, 0.3976, 0.1204]}, {"w": "supports", "b": [0.4035, 0.099, 0.4764, 0.1204]}, {"w": "the", "b": [0.4822, 0.099, 0.5086, 0.1204]}, {"w": "kernel", "b": [0.5144, 0.099, 0.5668, 0.1204]}, {"w": "trick).", "b": [0.5727, 0.099, 0.6235, 0.1204]}, {"w": "The", "b": [0.6293, 0.099, 0.6621, 0.1204]}, {"w": "SVR", "b": [0.668, 0.1022, 0.6977, 0.1173]}, {"w": "class", "b": [0.7035, 0.099, 0.7421, 0.1204]}, {"w": "is", "b": [0.7479, 0.099, 0.7611, 0.1204]}, {"w": "the", "b": [0.767, 0.099, 0.7933, 0.1204]}, {"w": "regres‐", "b": [0.7992, 0.099, 0.8571, 0.1204]}, {"w": "sion", "b": [0.1429, 0.119, 0.1781, 0.1404]}, {"w": "equivalent", "b": [0.1842, 0.119, 0.2706, 0.1404]}, {"w": "of", "b": [0.2767, 0.119, 0.2935, 0.1404]}, {"w": "the", "b": [0.2996, 0.119, 0.326, 0.1404]}, {"w": "SVC", "b": [0.3321, 0.1221, 0.3617, 0.1372]}, {"w": "class,", "b": [0.3678, 0.119, 0.4111, 0.1404]}, {"w": "and", "b": [0.4172, 0.119, 0.4488, 0.1404]}, {"w": "the", "b": [0.4549, 0.119, 0.4812, 0.1404]}, {"w": "LinearSVR", "b": [0.4873, 0.1221, 0.5763, 0.1372]}, {"w": "class", "b": [0.5824, 0.119, 0.621, 0.1404]}, {"w": "is", "b": [0.6271, 0.119, 0.6403, 0.1404]}, {"w": "the", "b": [0.6464, 0.119, 0.6727, 0.1404]}, {"w": "regression", "b": [0.6788, 0.119, 0.7646, 0.1404]}, {"w": "equivalent", "b": [0.7707, 0.119, 0.8572, 0.1404]}, {"w": "of", "b": [0.1429, 0.1389, 0.1597, 0.1603]}, {"w": "the", "b": [0.1656, 0.1389, 0.1919, 0.1603]}, {"w": "LinearSVC", "b": [0.1978, 0.1421, 0.2869, 0.1572]}, {"w": "class.", "b": [0.2928, 0.1389, 0.3361, 0.1603]}, {"w": "The", "b": [0.342, 0.1389, 0.3749, 0.1603]}, {"w": "LinearSVR", "b": [0.3808, 0.1421, 0.4698, 0.1572]}, {"w": "class", "b": [0.4758, 0.1389, 0.5143, 0.1603]}, {"w": "scales", "b": [0.5202, 0.1389, 0.5676, 0.1603]}, {"w": "linearly", "b": [0.5735, 0.1389, 0.6363, 0.1603]}, {"w": "with", "b": [0.6423, 0.1389, 0.6796, 0.1603]}, {"w": "the", "b": [0.6855, 0.1389, 0.7119, 0.1603]}, {"w": "size", "b": [0.7178, 0.1389, 0.7486, 0.1603]}, {"w": "of", "b": [0.7545, 0.1389, 0.7713, 0.1603]}, {"w": "the", "b": [0.7773, 0.1389, 0.8036, 0.1603]}, {"w": "train‐", "b": [0.8095, 0.1389, 0.8571, 0.1603]}, {"w": "ing", "b": [0.1429, 0.1588, 0.1696, 0.1803]}, {"w": "set", "b": [0.1763, 0.1588, 0.1991, 0.1803]}, {"w": "(just", "b": [0.2058, 0.1588, 0.2434, 0.1803]}, {"w": "like", "b": [0.2501, 0.1588, 0.2801, 0.1803]}, {"w": "the", "b": [0.2868, 0.1588, 0.3131, 0.1803]}, {"w": "LinearSVC", "b": [0.3198, 0.162, 0.4089, 0.1771]}, {"w": "class),", "b": [0.4156, 0.1588, 0.466, 0.1803]}, {"w": "while", "b": [0.4727, 0.1588, 0.5178, 0.1803]}, {"w": "the", "b": [0.5245, 0.1588, 0.5508, 0.1803]}, {"w": "SVR", "b": [0.5575, 0.162, 0.5872, 0.1771]}, {"w": "class", "b": [0.5939, 0.1588, 0.6324, 0.1803]}, {"w": "gets", "b": [0.6391, 0.1588, 0.6717, 0.1803]}, {"w": "much", "b": [0.6784, 0.1588, 0.726, 0.1803]}, {"w": "too", "b": [0.7327, 0.1588, 0.7603, 0.1803]}, {"w": "slow", "b": [0.767, 0.1588, 0.8048, 0.1803]}, {"w": "when", "b": [0.8115, 0.1588, 0.8571, 0.1803]}, {"w": "the", "b": [0.1428, 0.1788, 0.1692, 0.2002]}, {"w": "training", "b": [0.1739, 0.1788, 0.2408, 0.2002]}, {"w": "set", "b": [0.2456, 0.1788, 0.2684, 0.2002]}, {"w": "grows", "b": [0.2732, 0.1788, 0.3232, 0.2002]}, {"w": "large", "b": [0.3279, 0.1788, 0.3687, 0.2002]}, {"w": "(just", "b": [0.3734, 0.1788, 0.411, 0.2002]}, {"w": "like", "b": [0.4157, 0.1788, 0.4458, 0.2002]}, {"w": "the", "b": [0.4505, 0.1788, 0.4768, 0.2002]}, {"w": "SVC", "b": [0.4816, 0.182, 0.5112, 0.197]}, {"w": "class).", "b": [0.516, 0.1788, 0.5665, 0.2002]}]}, {"id": "b_1", "type": "paragraph", "text": "from sklearn.svm import SVR", "words": [{"w": "from", "b": [0.1766, 0.2108, 0.2103, 0.2236]}, {"w": "sklearn.svm", "b": [0.2187, 0.2108, 0.3115, 0.2236]}, {"w": "import", "b": [0.3199, 0.2108, 0.3705, 0.2236]}, {"w": "SVR", "b": [0.379, 0.2108, 0.4043, 0.2236]}]}, {"id": "b_2", "type": "paragraph", "text": "svm_poly_reg = SVR(kernel=\"poly\", degree=2, C=100, epsilon=0.1) svm_poly_reg.fit(X, y)", "words": [{"w": "svm_poly_reg", "b": [0.1766, 0.2416, 0.2778, 0.2544]}, {"w": "=", "b": [0.2862, 0.2416, 0.2946, 0.2544]}, {"w": "SVR(kernel=\"poly\",", "b": [0.3031, 0.2416, 0.4549, 0.2544]}, {"w": "degree=2,", "b": [0.4633, 0.2416, 0.5392, 0.2544]}, {"w": "C=100,", "b": [0.5476, 0.2416, 0.5982, 0.2544]}, {"w": "epsilon=0.1)", "b": [0.6066, 0.2416, 0.7078, 0.2544]}, {"w": "svm_poly_reg.fit(X,", "b": [0.1766, 0.257, 0.3368, 0.2699]}, {"w": "y)", "b": [0.3452, 0.257, 0.3621, 0.2699]}]}, {"id": "b_3", "type": "paragraph", "text": "SVMs can also be used for outlier detection; see Scikit-Learn’s doc‐ umentation for more details.", "words": [{"w": "SVMs", "b": [0.2714, 0.2915, 0.3178, 0.3111]}, {"w": "can", "b": [0.3228, 0.2915, 0.3497, 0.3111]}, {"w": "also", "b": [0.3547, 0.2915, 0.3846, 0.3111]}, {"w": "be", "b": [0.3896, 0.2915, 0.4074, 0.3111]}, {"w": "used", "b": [0.4124, 0.2915, 0.4477, 0.3111]}, {"w": "for", "b": [0.4527, 0.2915, 0.4751, 0.3111]}, {"w": "outlier", "b": [0.4802, 0.2915, 0.5309, 0.3111]}, {"w": "detection;", "b": [0.5359, 0.2915, 0.6114, 0.3111]}, {"w": "see", "b": [0.6165, 0.2915, 0.6397, 0.3111]}, {"w": "Scikit-Learn’s", "b": [0.6447, 0.2915, 0.7461, 0.3111]}, {"w": "doc‐", "b": [0.7511, 0.2915, 0.7857, 0.3111]}, {"w": "umentation", "b": [0.2714, 0.3089, 0.3601, 0.3285]}, {"w": "for", "b": [0.3645, 0.3089, 0.3869, 0.3285]}, {"w": "more", "b": [0.3912, 0.3089, 0.4317, 0.3285]}, {"w": "details.", "b": [0.436, 0.3089, 0.4896, 0.3285]}]}, {"id": "b_4", "type": "paragraph", "text": "Under the Hood", "words": [{"w": "Under", "b": [0.1429, 0.3863, 0.2182, 0.4206]}, {"w": "the", "b": [0.2241, 0.3863, 0.266, 0.4206]}, {"w": "Hood", "b": [0.2719, 0.3863, 0.3371, 0.4206]}]}, {"id": "b_5", "type": "paragraph", "text": "This section explains how SVMs make predictions and how their training algorithms work, starting with linear SVM classifiers. You can safely skip it and go straight to the exercises at the end of this chapter if you are just getting started with Machine Learn‐ ing, and come back later when you want to get a deeper understanding of SVMs.", "words": [{"w": "This", "b": [0.1428, 0.4275, 0.1801, 0.4489]}, {"w": "section", "b": [0.1853, 0.4275, 0.2446, 0.4489]}, {"w": "explains", "b": [0.2499, 0.4275, 0.3185, 0.4489]}, {"w": "how", "b": [0.3238, 0.4275, 0.3598, 0.4489]}, {"w": "SVMs", "b": [0.3651, 0.4275, 0.4159, 0.4489]}, {"w": "make", "b": [0.4211, 0.4275, 0.4665, 0.4489]}, {"w": "predictions", "b": [0.4718, 0.4275, 0.5663, 0.4489]}, {"w": "and", "b": [0.5716, 0.4275, 0.6031, 0.4489]}, {"w": "how", "b": [0.6084, 0.4275, 0.6444, 0.4489]}, {"w": "their", "b": [0.6497, 0.4275, 0.6894, 0.4489]}, {"w": "training", "b": [0.6946, 0.4275, 0.7616, 0.4489]}, {"w": "algorithms", "b": [0.7669, 0.4275, 0.8571, 0.4489]}, {"w": "work,", "b": [0.1429, 0.4465, 0.1906, 0.468]}, {"w": "starting", "b": [0.1956, 0.4465, 0.2596, 0.468]}, {"w": "with", "b": [0.2647, 0.4465, 0.302, 0.468]}, {"w": "linear", "b": [0.3071, 0.4465, 0.3551, 0.468]}, {"w": "SVM", "b": [0.3601, 0.4465, 0.4032, 0.468]}, {"w": "classifiers.", "b": [0.4083, 0.4465, 0.4931, 0.468]}, {"w": "You", "b": [0.4982, 0.4465, 0.5305, 0.468]}, {"w": "can", "b": [0.5356, 0.4465, 0.565, 0.468]}, {"w": "safely", "b": [0.57, 0.4465, 0.6167, 0.468]}, {"w": "skip", "b": [0.6218, 0.4465, 0.6562, 0.468]}, {"w": "it", "b": [0.6613, 0.4465, 0.6733, 0.468]}, {"w": "and", "b": [0.6783, 0.4465, 0.7099, 0.468]}, {"w": "go", "b": [0.7149, 0.4465, 0.7353, 0.468]}, {"w": "straight", "b": [0.7404, 0.4465, 0.8037, 0.468]}, {"w": "to", "b": [0.8088, 0.4465, 0.8257, 0.468]}, {"w": "the", "b": [0.8308, 0.4465, 0.8571, 0.468]}, {"w": "exercises", "b": [0.1428, 0.4656, 0.2167, 0.487]}, {"w": "at", "b": [0.2218, 0.4656, 0.2369, 0.487]}, {"w": "the", "b": [0.2421, 0.4656, 0.2684, 0.487]}, {"w": "end", "b": [0.2736, 0.4656, 0.3048, 0.487]}, {"w": "of", "b": [0.31, 0.4656, 0.3268, 0.487]}, {"w": "this", "b": [0.3319, 0.4656, 0.3626, 0.487]}, {"w": "chapter", "b": [0.3678, 0.4656, 0.4303, 0.487]}, {"w": "if", "b": [0.4355, 0.4656, 0.4472, 0.487]}, {"w": "you", "b": [0.4524, 0.4656, 0.4836, 0.487]}, {"w": "are", "b": [0.4888, 0.4656, 0.5145, 0.487]}, {"w": "just", "b": [0.5196, 0.4656, 0.55, 0.487]}, {"w": "getting", "b": [0.5552, 0.4656, 0.6132, 0.487]}, {"w": "started", "b": [0.6184, 0.4656, 0.6755, 0.487]}, {"w": "with", "b": [0.6806, 0.4656, 0.718, 0.487]}, {"w": "Machine", "b": [0.7231, 0.4656, 0.7962, 0.487]}, {"w": "Learn‐", "b": [0.8014, 0.4656, 0.8571, 0.487]}, {"w": "ing,", "b": [0.1429, 0.4846, 0.1743, 0.5061]}, {"w": "and", "b": [0.1791, 0.4846, 0.2106, 0.5061]}, {"w": "come", "b": [0.2153, 0.4846, 0.2607, 0.5061]}, {"w": "back", "b": [0.2654, 0.4846, 0.3043, 0.5061]}, {"w": "later", "b": [0.309, 0.4846, 0.346, 0.5061]}, {"w": "when", "b": [0.3507, 0.4846, 0.3964, 0.5061]}, {"w": "you", "b": [0.4011, 0.4846, 0.4323, 0.5061]}, {"w": "want", "b": [0.4371, 0.4846, 0.4778, 0.5061]}, {"w": "to", "b": [0.4826, 0.4846, 0.4996, 0.5061]}, {"w": "get", "b": [0.5043, 0.4846, 0.5292, 0.5061]}, {"w": "a", "b": [0.534, 0.4846, 0.5431, 0.5061]}, {"w": "deeper", "b": [0.5478, 0.4846, 0.6041, 0.5061]}, {"w": "understanding", "b": [0.6088, 0.4846, 0.7311, 0.5061]}, {"w": "of", "b": [0.7358, 0.4846, 0.7526, 0.5061]}, {"w": "SVMs.", "b": [0.7573, 0.4846, 0.8128, 0.5061]}]}, {"id": "b_6", "type": "paragraph", "text": "First, a word about notations: in Chapter 4 we used the convention of putting all the model parameters in one vector θ, including the bias term θ0 and the input feature weights θ1 to θn, and adding a bias input x0 = 1 to all instances. In this chapter, we will use a different convention, which is more convenient (and more common) when you are dealing with SVMs: the bias term will be called b and the feature weights vector will be called w. No bias feature will be added to the input feature vectors.", "words": [{"w": "First,", "b": [0.1429, 0.5128, 0.1859, 0.5342]}, {"w": "a", "b": [0.1914, 0.5128, 0.2005, 0.5342]}, {"w": "word", "b": [0.2059, 0.5128, 0.2495, 0.5342]}, {"w": "about", "b": [0.2549, 0.5128, 0.3027, 0.5342]}, {"w": "notations:", "b": [0.3081, 0.5128, 0.3916, 0.5342]}, {"w": "in", "b": [0.397, 0.5128, 0.414, 0.5342]}, {"w": "Chapter", "b": [0.4194, 0.5128, 0.487, 0.5342]}, {"w": "4", "b": [0.4917, 0.5128, 0.5017, 0.5342]}, {"w": "we", "b": [0.5078, 0.5128, 0.5309, 0.5342]}, {"w": "used", "b": [0.5363, 0.5128, 0.5749, 0.5342]}, {"w": "the", "b": [0.5803, 0.5128, 0.6066, 0.5342]}, {"w": "convention", "b": [0.6121, 0.5128, 0.7059, 0.5342]}, {"w": "of", "b": [0.7113, 0.5128, 0.7281, 0.5342]}, {"w": "putting", "b": [0.7335, 0.5128, 0.7949, 0.5342]}, {"w": "all", "b": [0.8003, 0.5128, 0.82, 0.5342]}, {"w": "the", "b": [0.8254, 0.5128, 0.8517, 0.5342]}, {"w": "model", "b": [0.1429, 0.5318, 0.1957, 0.5532]}, {"w": "parameters", "b": [0.2026, 0.5318, 0.296, 0.5532]}, {"w": "in", "b": [0.303, 0.5318, 0.32, 0.5532]}, {"w": "one", "b": [0.3269, 0.5318, 0.3578, 0.5532]}, {"w": "vector", "b": [0.3647, 0.5318, 0.4167, 0.5532]}, {"w": "θ,", "b": [0.4237, 0.5312, 0.439, 0.5532]}, {"w": "including", "b": [0.446, 0.5318, 0.5258, 0.5532]}, {"w": "the", "b": [0.5328, 0.5318, 0.5591, 0.5532]}, {"w": "bias", "b": [0.566, 0.5318, 0.599, 0.5532]}, {"w": "term", "b": [0.6059, 0.5318, 0.6459, 0.5532]}, {"w": "θ0", "b": [0.6529, 0.5316, 0.6688, 0.5541]}, {"w": "and", "b": [0.6758, 0.5318, 0.7073, 0.5532]}, {"w": "the", "b": [0.7142, 0.5318, 0.7406, 0.5532]}, {"w": "input", "b": [0.7475, 0.5318, 0.7924, 0.5532]}, {"w": "feature", "b": [0.7994, 0.5318, 0.8571, 0.5532]}, {"w": "weights", "b": [0.1429, 0.5509, 0.206, 0.5723]}, {"w": "θ1", "b": [0.2111, 0.5506, 0.227, 0.5732]}, {"w": "to", "b": [0.232, 0.5509, 0.249, 0.5723]}, {"w": "θn,", "b": [0.254, 0.5506, 0.2754, 0.5732]}, {"w": "and", "b": [0.2804, 0.5509, 0.312, 0.5723]}, {"w": "adding", "b": [0.317, 0.5509, 0.3749, 0.5723]}, {"w": "a", "b": [0.3799, 0.5509, 0.389, 0.5723]}, {"w": "bias", "b": [0.3941, 0.5509, 0.427, 0.5723]}, {"w": "input", "b": [0.432, 0.5509, 0.477, 0.5723]}, {"w": "x0", "b": [0.482, 0.5506, 0.4978, 0.5732]}, {"w": "=", "b": [0.5029, 0.5509, 0.5149, 0.5723]}, {"w": "1", "b": [0.52, 0.5509, 0.53, 0.5723]}, {"w": "to", "b": [0.535, 0.5509, 0.552, 0.5723]}, {"w": "all", "b": [0.557, 0.5509, 0.5767, 0.5723]}, {"w": "instances.", "b": [0.5817, 0.5509, 0.6633, 0.5723]}, {"w": "In", "b": [0.6683, 0.5509, 0.6868, 0.5723]}, {"w": "this", "b": [0.6919, 0.5509, 0.7226, 0.5723]}, {"w": "chapter,", "b": [0.7276, 0.5509, 0.7936, 0.5723]}, {"w": "we", "b": [0.7986, 0.5509, 0.8217, 0.5723]}, {"w": "will", "b": [0.8267, 0.5509, 0.8571, 0.5723]}, {"w": "use", "b": [0.1428, 0.5699, 0.1704, 0.5913]}, {"w": "a", "b": [0.1758, 0.5699, 0.1849, 0.5913]}, {"w": "different", "b": [0.1902, 0.5699, 0.262, 0.5913]}, {"w": "convention,", "b": [0.2673, 0.5699, 0.3659, 0.5913]}, {"w": "which", "b": [0.3712, 0.5699, 0.4221, 0.5913]}, {"w": "is", "b": [0.4275, 0.5699, 0.4407, 0.5913]}, {"w": "more", "b": [0.446, 0.5699, 0.4903, 0.5913]}, {"w": "convenient", "b": [0.4957, 0.5699, 0.5877, 0.5913]}, {"w": "(and", "b": [0.593, 0.5699, 0.6318, 0.5913]}, {"w": "more", "b": [0.6371, 0.5699, 0.6814, 0.5913]}, {"w": "common)", "b": [0.6868, 0.5699, 0.7695, 0.5913]}, {"w": "when", "b": [0.7749, 0.5699, 0.8205, 0.5913]}, {"w": "you", "b": [0.8259, 0.5699, 0.8571, 0.5913]}, {"w": "are", "b": [0.1429, 0.5889, 0.1686, 0.6104]}, {"w": "dealing", "b": [0.175, 0.5889, 0.236, 0.6104]}, {"w": "with", "b": [0.2424, 0.5889, 0.2798, 0.6104]}, {"w": "SVMs:", "b": [0.2862, 0.5889, 0.3417, 0.6104]}, {"w": "the", "b": [0.3481, 0.5889, 0.3744, 0.6104]}, {"w": "bias", "b": [0.3808, 0.5889, 0.4138, 0.6104]}, {"w": "term", "b": [0.4202, 0.5889, 0.4602, 0.6104]}, {"w": "will", "b": [0.4666, 0.5889, 0.497, 0.6104]}, {"w": "be", "b": [0.5034, 0.5889, 0.5229, 0.6104]}, {"w": "called", "b": [0.5293, 0.5889, 0.5777, 0.6104]}, {"w": "b", "b": [0.5841, 0.5887, 0.5942, 0.6104]}, {"w": "and", "b": [0.6006, 0.5889, 0.6322, 0.6104]}, {"w": "the", "b": [0.6386, 0.5889, 0.6649, 0.6104]}, {"w": "feature", "b": [0.6713, 0.5889, 0.7291, 0.6104]}, {"w": "weights", "b": [0.7355, 0.5889, 0.7987, 0.6104]}, {"w": "vector", "b": [0.8051, 0.5889, 0.8572, 0.6104]}, {"w": "will", "b": [0.1429, 0.608, 0.1733, 0.6294]}, {"w": "be", "b": [0.178, 0.608, 0.1974, 0.6294]}, {"w": "called", "b": [0.2022, 0.608, 0.2505, 0.6294]}, {"w": "w.", "b": [0.2552, 0.6074, 0.2742, 0.6294]}, {"w": "No", "b": [0.2789, 0.608, 0.3045, 0.6294]}, {"w": "bias", "b": [0.3093, 0.608, 0.3422, 0.6294]}, {"w": "feature", "b": [0.3469, 0.608, 0.4047, 0.6294]}, {"w": "will", "b": [0.4094, 0.608, 0.4398, 0.6294]}, {"w": "be", "b": [0.4446, 0.608, 0.464, 0.6294]}, {"w": "added", "b": [0.4687, 0.608, 0.5197, 0.6294]}, {"w": "to", "b": [0.5245, 0.608, 0.5414, 0.6294]}, {"w": "the", "b": [0.5462, 0.608, 0.5725, 0.6294]}, {"w": "input", "b": [0.5772, 0.608, 0.6222, 0.6294]}, {"w": "feature", "b": [0.6269, 0.608, 0.6847, 0.6294]}, {"w": "vectors.", "b": [0.6894, 0.608, 0.7538, 0.6294]}]}, {"id": "b_7", "type": "paragraph", "text": "Decision Function and Predictions", "words": [{"w": "Decision", "b": [0.1429, 0.6422, 0.2286, 0.6707]}, {"w": "Function", "b": [0.2335, 0.6422, 0.3237, 0.6707]}, {"w": "and", "b": [0.3286, 0.6422, 0.3679, 0.6707]}, {"w": "Predictions", "b": [0.3728, 0.6422, 0.4881, 0.6707]}]}, {"id": "b_8", "type": "paragraph", "text": "The linear SVM classifier model predicts the class of a new instance x by simply com‐ puting the decision function wT x + b = w1 x1 + ⋯ + wn xn + b: if the result is positive, the predicted class ŷ is the positive class (1), or else it is the negative class (0); see Equation 5-2.", "words": [{"w": "The", "b": [0.1429, 0.6766, 0.1757, 0.6981]}, {"w": "linear", "b": [0.1806, 0.6766, 0.2286, 0.6981]}, {"w": "SVM", "b": [0.2335, 0.6766, 0.2766, 0.6981]}, {"w": "classifier", "b": [0.2816, 0.6766, 0.354, 0.6981]}, {"w": "model", "b": [0.3589, 0.6766, 0.4117, 0.6981]}, {"w": "predicts", "b": [0.4167, 0.6766, 0.4836, 0.6981]}, {"w": "the", "b": [0.4885, 0.6766, 0.5148, 0.6981]}, {"w": "class", "b": [0.5198, 0.6766, 0.5583, 0.6981]}, {"w": "of", "b": [0.5632, 0.6766, 0.58, 0.6981]}, {"w": "a", "b": [0.5849, 0.6766, 0.5941, 0.6981]}, {"w": "new", "b": [0.599, 0.6766, 0.6335, 0.6981]}, {"w": "instance", "b": [0.6385, 0.6766, 0.7077, 0.6981]}, {"w": "x", "b": [0.7126, 0.6761, 0.7226, 0.6981]}, {"w": "by", "b": [0.7276, 0.6766, 0.7477, 0.6981]}, {"w": "simply", "b": [0.7525, 0.6766, 0.8081, 0.6981]}, {"w": "com‐", "b": [0.8128, 0.6766, 0.8567, 0.6981]}, {"w": "puting", "b": [0.1429, 0.6957, 0.1979, 0.7171]}, {"w": "the", "b": [0.2031, 0.6957, 0.2294, 0.7171]}, {"w": "decision", "b": [0.2345, 0.6957, 0.304, 0.7171]}, {"w": "function", "b": [0.3092, 0.6957, 0.3805, 0.7171]}, {"w": "wT", "b": [0.3857, 0.6951, 0.4074, 0.7171]}, {"w": "x", "b": [0.4126, 0.6951, 0.4226, 0.7171]}, {"w": "+", "b": [0.4277, 0.6957, 0.4398, 0.7171]}, {"w": "b", "b": [0.445, 0.6955, 0.4551, 0.7171]}, {"w": "=", "b": [0.4602, 0.6957, 0.4723, 0.7171]}, {"w": "w1", "b": [0.4774, 0.6955, 0.4974, 0.718]}, {"w": "x1", "b": [0.5025, 0.6955, 0.5183, 0.718]}, {"w": "+", "b": [0.5235, 0.6957, 0.5356, 0.7171]}, {"w": "⋯", "b": [0.5407, 0.6989, 0.5615, 0.7148]}, {"w": "+", "b": [0.5666, 0.6957, 0.5787, 0.7171]}, {"w": "wn", "b": [0.5839, 0.6955, 0.6045, 0.718]}, {"w": "xn", "b": [0.6096, 0.6955, 0.6261, 0.718]}, {"w": "+", "b": [0.6312, 0.6957, 0.6433, 0.7171]}, {"w": "b:", "b": [0.6484, 0.6955, 0.6633, 0.7171]}, {"w": "if", "b": [0.6684, 0.6957, 0.6802, 0.7171]}, {"w": "the", "b": [0.6853, 0.6957, 0.7117, 0.7171]}, {"w": "result", "b": [0.7168, 0.6957, 0.7637, 0.7171]}, {"w": "is", "b": [0.7688, 0.6957, 0.7821, 0.7171]}, {"w": "positive,", "b": [0.7872, 0.6957, 0.8571, 0.7171]}, {"w": "the", "b": [0.1429, 0.7147, 0.1692, 0.7361]}, {"w": "predicted", "b": [0.1766, 0.7147, 0.2557, 0.7361]}, {"w": "class", "b": [0.2631, 0.7147, 0.3016, 0.7361]}, {"w": "ŷ", "b": [0.3091, 0.7145, 0.3183, 0.7361]}, {"w": "is", "b": [0.3257, 0.7147, 0.3389, 0.7361]}, {"w": "the", "b": [0.3463, 0.7147, 0.3726, 0.7361]}, {"w": "positive", "b": [0.3801, 0.7147, 0.4453, 0.7361]}, {"w": "class", "b": [0.4527, 0.7147, 0.4912, 0.7361]}, {"w": "(1),", "b": [0.4986, 0.7147, 0.5278, 0.7361]}, {"w": "or", "b": [0.5352, 0.7147, 0.5535, 0.7361]}, {"w": "else", "b": [0.5609, 0.7147, 0.5916, 0.7361]}, {"w": "it", "b": [0.599, 0.7147, 0.6109, 0.7361]}, {"w": "is", "b": [0.6183, 0.7147, 0.6315, 0.7361]}, {"w": "the", "b": [0.639, 0.7147, 0.6653, 0.7361]}, {"w": "negative", "b": [0.6727, 0.7147, 0.7419, 0.7361]}, {"w": "class", "b": [0.7493, 0.7147, 0.7878, 0.7361]}, {"w": "(0);", "b": [0.7952, 0.7147, 0.8244, 0.7361]}, {"w": "see", "b": [0.8318, 0.7147, 0.8572, 0.7361]}, {"w": "Equation", "b": [0.1429, 0.7338, 0.2191, 0.7552]}, {"w": "5-2.", "b": [0.2238, 0.7338, 0.256, 0.7552]}]}, {"id": "b_9", "type": "equation", "text": "Equation 5-2. Linear SVM classifier prediction", "words": [{"w": "Equation", "b": [0.1726, 0.7733, 0.2473, 0.7949]}, {"w": "5-2.", "b": [0.2521, 0.7733, 0.2838, 0.7949]}, {"w": "Linear", "b": [0.2886, 0.7733, 0.3412, 0.7949]}, {"w": "SVM", "b": [0.346, 0.7733, 0.3881, 0.7949]}, {"w": "classifier", "b": [0.3928, 0.7733, 0.4629, 0.7949]}, {"w": "prediction", "b": [0.4677, 0.7733, 0.5495, 0.7949]}]}, {"id": "b_10", "type": "equation", "text": "y = 0 if wTx + b < 0,", "words": [{"w": "y", "b": [0.1738, 0.8165, 0.1825, 0.8371]}, {"w": "=", "b": [0.1894, 0.8167, 0.2009, 0.8371]}, {"w": "0", "b": [0.2133, 0.8058, 0.2228, 0.8262]}, {"w": "if", "b": [0.2315, 0.8058, 0.2427, 0.8262]}, {"w": "wTx", "b": [0.2523, 0.8019, 0.2856, 0.8262]}, {"w": "+", "b": [0.2902, 0.8058, 0.3017, 0.8262]}, {"w": "b", "b": [0.3061, 0.8056, 0.3157, 0.8262]}, {"w": "<", "b": [0.3213, 0.8058, 0.3322, 0.8262]}, {"w": "0,", "b": [0.3377, 0.8058, 0.3518, 0.8262]}]}, {"id": "b_11", "type": "equation", "text": "1 if wTx + b ≥0", "words": [{"w": "1", "b": [0.2133, 0.8321, 0.2228, 0.8525]}, {"w": "if", "b": [0.2315, 0.8321, 0.2427, 0.8525]}, {"w": "wTx", "b": [0.2523, 0.8282, 0.2857, 0.8525]}, {"w": "+", "b": [0.2902, 0.8321, 0.3017, 0.8525]}, {"w": "b", "b": [0.3061, 0.8319, 0.3157, 0.8525]}, {"w": "≥0", "b": [0.3213, 0.8321, 0.3478, 0.8525]}]}, {"id": "b_12", "type": "paragraph", "text": "166 | Chapter 5: Support Vector Machines", "words": [{"w": "166", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "5:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Support", "b": [0.2673, 0.9225, 0.3142, 0.9388]}, {"w": "Vector", "b": [0.317, 0.9225, 0.3547, 0.9388]}, {"w": "Machines", "b": [0.3576, 0.9225, 0.413, 0.9388]}]}]}, {"page": 193, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "3 More generally, when there are n features, the decision function is an n-dimensional hyperplane, and the deci‐ sion boundary is an (n – 1)-dimensional hyperplane.", "words": [{"w": "3", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "More", "b": [0.1587, 0.8598, 0.1932, 0.8761]}, {"w": "generally,", "b": [0.1968, 0.8598, 0.257, 0.8761]}, {"w": "when", "b": [0.2606, 0.8598, 0.2954, 0.8761]}, {"w": "there", "b": [0.299, 0.8598, 0.3317, 0.8761]}, {"w": "are", "b": [0.3353, 0.8598, 0.3549, 0.8761]}, {"w": "n", "b": [0.3585, 0.8596, 0.367, 0.8761]}, {"w": "features,", "b": [0.3706, 0.8598, 0.424, 0.8761]}, {"w": "the", "b": [0.4276, 0.8598, 0.4477, 0.8761]}, {"w": "decision", "b": [0.4513, 0.8598, 0.5043, 0.8761]}, {"w": "function", "b": [0.5079, 0.8598, 0.5623, 0.8761]}, {"w": "is", "b": [0.5659, 0.8598, 0.5759, 0.8761]}, {"w": "an", "b": [0.5795, 0.8598, 0.5952, 0.8761]}, {"w": "n-dimensional", "b": [0.5988, 0.8596, 0.6918, 0.8761]}, {"w": "hyperplane,", "b": [0.6954, 0.8596, 0.7677, 0.8761]}, {"w": "and", "b": [0.7713, 0.8598, 0.7954, 0.8761]}, {"w": "the", "b": [0.799, 0.8598, 0.819, 0.8761]}, {"w": "deci‐", "b": [0.8227, 0.8598, 0.8544, 0.8761]}, {"w": "sion", "b": [0.1587, 0.8749, 0.1856, 0.8912]}, {"w": "boundary", "b": [0.1892, 0.8749, 0.2514, 0.8912]}, {"w": "is", "b": [0.255, 0.8749, 0.2651, 0.8912]}, {"w": "an", "b": [0.2687, 0.8749, 0.2844, 0.8912]}, {"w": "(n", "b": [0.288, 0.8748, 0.3019, 0.8912]}, {"w": "–", "b": [0.3055, 0.8749, 0.3138, 0.8912]}, {"w": "1)-dimensional", "b": [0.3174, 0.8749, 0.415, 0.8912]}, {"w": "hyperplane.", "b": [0.4187, 0.8749, 0.4933, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Figure 5-12 shows the decision function that corresponds to the model on the left of Figure 5-4: it is a two-dimensional plane since this dataset has two features (petal width and petal length). The decision boundary is the set of points where the decision function is equal to 0: it is the intersection of two planes, which is a straight line (rep‐ resented by the thick solid line).3", "words": [{"w": "Figure", "b": [0.1428, 0.0791, 0.1968, 0.1005]}, {"w": "5-12", "b": [0.2026, 0.0791, 0.24, 0.1005]}, {"w": "shows", "b": [0.2458, 0.0791, 0.2971, 0.1005]}, {"w": "the", "b": [0.3029, 0.0791, 0.3292, 0.1005]}, {"w": "decision", "b": [0.335, 0.0791, 0.4045, 0.1005]}, {"w": "function", "b": [0.4103, 0.0791, 0.4817, 0.1005]}, {"w": "that", "b": [0.4875, 0.0791, 0.52, 0.1005]}, {"w": "corresponds", "b": [0.5258, 0.0791, 0.6288, 0.1005]}, {"w": "to", "b": [0.6346, 0.0791, 0.6515, 0.1005]}, {"w": "the", "b": [0.6573, 0.0791, 0.6837, 0.1005]}, {"w": "model", "b": [0.6894, 0.0791, 0.7422, 0.1005]}, {"w": "on", "b": [0.748, 0.0791, 0.77, 0.1005]}, {"w": "the", "b": [0.7758, 0.0791, 0.8021, 0.1005]}, {"w": "left", "b": [0.8079, 0.0791, 0.8346, 0.1005]}, {"w": "of", "b": [0.8403, 0.0791, 0.8571, 0.1005]}, {"w": "Figure", "b": [0.1429, 0.0981, 0.1969, 0.1195]}, {"w": "5-4:", "b": [0.2048, 0.0981, 0.2369, 0.1195]}, {"w": "it", "b": [0.2448, 0.0981, 0.2567, 0.1195]}, {"w": "is", "b": [0.2646, 0.0981, 0.2779, 0.1195]}, {"w": "a", "b": [0.2858, 0.0981, 0.2949, 0.1195]}, {"w": "two-dimensional", "b": [0.3028, 0.0981, 0.445, 0.1195]}, {"w": "plane", "b": [0.4529, 0.0981, 0.4985, 0.1195]}, {"w": "since", "b": [0.5064, 0.0981, 0.5487, 0.1195]}, {"w": "this", "b": [0.5566, 0.0981, 0.5873, 0.1195]}, {"w": "dataset", "b": [0.5952, 0.0981, 0.6533, 0.1195]}, {"w": "has", "b": [0.6611, 0.0981, 0.6891, 0.1195]}, {"w": "two", "b": [0.697, 0.0981, 0.7282, 0.1195]}, {"w": "features", "b": [0.7361, 0.0981, 0.8015, 0.1195]}, {"w": "(petal", "b": [0.8094, 0.0981, 0.8571, 0.1195]}, {"w": "width", "b": [0.1429, 0.1172, 0.1912, 0.1386]}, {"w": "and", "b": [0.196, 0.1172, 0.2275, 0.1386]}, {"w": "petal", "b": [0.2323, 0.1172, 0.2729, 0.1386]}, {"w": "length).", "b": [0.2777, 0.1172, 0.3424, 0.1386]}, {"w": "The", "b": [0.3472, 0.1172, 0.38, 0.1386]}, {"w": "decision", "b": [0.3848, 0.1172, 0.4543, 0.1386]}, {"w": "boundary", "b": [0.4591, 0.1172, 0.5408, 0.1386]}, {"w": "is", "b": [0.5456, 0.1172, 0.5588, 0.1386]}, {"w": "the", "b": [0.5636, 0.1172, 0.5899, 0.1386]}, {"w": "set", "b": [0.5947, 0.1172, 0.6176, 0.1386]}, {"w": "of", "b": [0.6224, 0.1172, 0.6392, 0.1386]}, {"w": "points", "b": [0.644, 0.1172, 0.6961, 0.1386]}, {"w": "where", "b": [0.7009, 0.1172, 0.7517, 0.1386]}, {"w": "the", "b": [0.7565, 0.1172, 0.7828, 0.1386]}, {"w": "decision", "b": [0.7876, 0.1172, 0.8571, 0.1386]}, {"w": "function", "b": [0.1429, 0.1362, 0.2142, 0.1576]}, {"w": "is", "b": [0.2194, 0.1362, 0.2326, 0.1576]}, {"w": "equal", "b": [0.2377, 0.1362, 0.2827, 0.1576]}, {"w": "to", "b": [0.2878, 0.1362, 0.3048, 0.1576]}, {"w": "0:", "b": [0.3099, 0.1362, 0.3246, 0.1576]}, {"w": "it", "b": [0.3297, 0.1362, 0.3417, 0.1576]}, {"w": "is", "b": [0.3468, 0.1362, 0.36, 0.1576]}, {"w": "the", "b": [0.3651, 0.1362, 0.3914, 0.1576]}, {"w": "intersection", "b": [0.3965, 0.1362, 0.4953, 0.1576]}, {"w": "of", "b": [0.5004, 0.1362, 0.5172, 0.1576]}, {"w": "two", "b": [0.5223, 0.1362, 0.5536, 0.1576]}, {"w": "planes,", "b": [0.5587, 0.1362, 0.6167, 0.1576]}, {"w": "which", "b": [0.6218, 0.1362, 0.6727, 0.1576]}, {"w": "is", "b": [0.6778, 0.1362, 0.691, 0.1576]}, {"w": "a", "b": [0.6961, 0.1362, 0.7053, 0.1576]}, {"w": "straight", "b": [0.7104, 0.1362, 0.7737, 0.1576]}, {"w": "line", "b": [0.7788, 0.1362, 0.8099, 0.1576]}, {"w": "(rep‐", "b": [0.815, 0.1362, 0.8571, 0.1576]}, {"w": "resented", "b": [0.1429, 0.1553, 0.2132, 0.1767]}, {"w": "by", "b": [0.2179, 0.1553, 0.238, 0.1767]}, {"w": "the", "b": [0.2428, 0.1553, 0.2691, 0.1767]}, {"w": "thick", "b": [0.2738, 0.1553, 0.316, 0.1767]}, {"w": "solid", "b": [0.3208, 0.1553, 0.3609, 0.1767]}, {"w": "line).3", "b": [0.3656, 0.1553, 0.4144, 0.1767]}]}, {"id": "b_2", "type": "equation", "text": "Figure 5-12. Decision function for the iris dataset", "words": [{"w": "Figure", "b": [0.1429, 0.4875, 0.1943, 0.5091]}, {"w": "5-12.", "b": [0.1991, 0.4875, 0.2407, 0.5091]}, {"w": "Decision", "b": [0.2455, 0.4875, 0.3154, 0.5091]}, {"w": "function", "b": [0.3202, 0.4875, 0.3883, 0.5091]}, {"w": "for", "b": [0.3931, 0.4875, 0.4157, 0.5091]}, {"w": "the", "b": [0.4205, 0.4875, 0.4455, 0.5091]}, {"w": "iris", "b": [0.4503, 0.4875, 0.4763, 0.5091]}, {"w": "dataset", "b": [0.4811, 0.4875, 0.5394, 0.5091]}]}, {"id": "b_3", "type": "paragraph", "text": "The dashed lines represent the points where the decision function is equal to 1 or –1: they are parallel and at equal distance to the decision boundary, forming a margin around it. Training a linear SVM classifier means finding the value of w and b that make this margin as wide as possible while avoiding margin violations (hard margin) or limiting them (soft margin).", "words": [{"w": "The", "b": [0.1429, 0.5249, 0.1757, 0.5463]}, {"w": "dashed", "b": [0.1811, 0.5249, 0.2398, 0.5463]}, {"w": "lines", "b": [0.2452, 0.5249, 0.2839, 0.5463]}, {"w": "represent", "b": [0.2893, 0.5249, 0.3672, 0.5463]}, {"w": "the", "b": [0.3726, 0.5249, 0.3989, 0.5463]}, {"w": "points", "b": [0.4043, 0.5249, 0.4564, 0.5463]}, {"w": "where", "b": [0.4618, 0.5249, 0.5126, 0.5463]}, {"w": "the", "b": [0.5179, 0.5249, 0.5443, 0.5463]}, {"w": "decision", "b": [0.5496, 0.5249, 0.6191, 0.5463]}, {"w": "function", "b": [0.6245, 0.5249, 0.6959, 0.5463]}, {"w": "is", "b": [0.7012, 0.5249, 0.7145, 0.5463]}, {"w": "equal", "b": [0.7198, 0.5249, 0.7648, 0.5463]}, {"w": "to", "b": [0.7702, 0.5249, 0.7871, 0.5463]}, {"w": "1", "b": [0.7925, 0.5249, 0.8025, 0.5463]}, {"w": "or", "b": [0.8079, 0.5249, 0.8262, 0.5463]}, {"w": "–1:", "b": [0.8316, 0.5249, 0.8571, 0.5463]}, {"w": "they", "b": [0.1429, 0.5439, 0.1788, 0.5653]}, {"w": "are", "b": [0.186, 0.5439, 0.2118, 0.5653]}, {"w": "parallel", "b": [0.2191, 0.5439, 0.2807, 0.5653]}, {"w": "and", "b": [0.288, 0.5439, 0.3195, 0.5653]}, {"w": "at", "b": [0.3268, 0.5439, 0.3419, 0.5653]}, {"w": "equal", "b": [0.3492, 0.5439, 0.3942, 0.5653]}, {"w": "distance", "b": [0.4014, 0.5439, 0.4702, 0.5653]}, {"w": "to", "b": [0.4775, 0.5439, 0.4945, 0.5653]}, {"w": "the", "b": [0.5018, 0.5439, 0.5281, 0.5653]}, {"w": "decision", "b": [0.5354, 0.5439, 0.6049, 0.5653]}, {"w": "boundary,", "b": [0.6122, 0.5439, 0.6971, 0.5653]}, {"w": "forming", "b": [0.7044, 0.5439, 0.7727, 0.5653]}, {"w": "a", "b": [0.78, 0.5439, 0.7892, 0.5653]}, {"w": "margin", "b": [0.7965, 0.5439, 0.8571, 0.5653]}, {"w": "around", "b": [0.1428, 0.563, 0.2038, 0.5844]}, {"w": "it.", "b": [0.2106, 0.563, 0.2273, 0.5844]}, {"w": "Training", "b": [0.2341, 0.563, 0.3058, 0.5844]}, {"w": "a", "b": [0.3125, 0.563, 0.3217, 0.5844]}, {"w": "linear", "b": [0.3285, 0.563, 0.3765, 0.5844]}, {"w": "SVM", "b": [0.3832, 0.563, 0.4263, 0.5844]}, {"w": "classifier", "b": [0.4331, 0.563, 0.5055, 0.5844]}, {"w": "means", "b": [0.5123, 0.563, 0.5664, 0.5844]}, {"w": "finding", "b": [0.5732, 0.563, 0.6341, 0.5844]}, {"w": "the", "b": [0.6409, 0.563, 0.6672, 0.5844]}, {"w": "value", "b": [0.674, 0.563, 0.718, 0.5844]}, {"w": "of", "b": [0.7247, 0.563, 0.7415, 0.5844]}, {"w": "w", "b": [0.7483, 0.5624, 0.7625, 0.5844]}, {"w": "and", "b": [0.7693, 0.563, 0.8009, 0.5844]}, {"w": "b", "b": [0.8076, 0.5628, 0.8178, 0.5844]}, {"w": "that", "b": [0.8246, 0.563, 0.8571, 0.5844]}, {"w": "make", "b": [0.1429, 0.582, 0.1883, 0.6034]}, {"w": "this", "b": [0.1935, 0.582, 0.2243, 0.6034]}, {"w": "margin", "b": [0.2295, 0.582, 0.2902, 0.6034]}, {"w": "as", "b": [0.2955, 0.582, 0.3123, 0.6034]}, {"w": "wide", "b": [0.3176, 0.582, 0.3573, 0.6034]}, {"w": "as", "b": [0.3626, 0.582, 0.3793, 0.6034]}, {"w": "possible", "b": [0.3846, 0.582, 0.4518, 0.6034]}, {"w": "while", "b": [0.457, 0.582, 0.5021, 0.6034]}, {"w": "avoiding", "b": [0.5074, 0.582, 0.5798, 0.6034]}, {"w": "margin", "b": [0.5851, 0.582, 0.6457, 0.6034]}, {"w": "violations", "b": [0.651, 0.582, 0.7325, 0.6034]}, {"w": "(hard", "b": [0.7378, 0.582, 0.784, 0.6034]}, {"w": "margin)", "b": [0.7893, 0.582, 0.8572, 0.6034]}, {"w": "or", "b": [0.1429, 0.6011, 0.1612, 0.6225]}, {"w": "limiting", "b": [0.1659, 0.6011, 0.2325, 0.6225]}, {"w": "them", "b": [0.2373, 0.6011, 0.2807, 0.6225]}, {"w": "(soft", "b": [0.2854, 0.6011, 0.3234, 0.6225]}, {"w": "margin).", "b": [0.3281, 0.6011, 0.4007, 0.6225]}]}, {"id": "b_4", "type": "paragraph", "text": "Training Objective", "words": [{"w": "Training", "b": [0.1428, 0.6352, 0.2288, 0.6638]}, {"w": "Objective", "b": [0.2338, 0.6352, 0.3296, 0.6638]}]}, {"id": "b_5", "type": "paragraph", "text": "Consider the slope of the decision function: it is equal to the norm of the weight vec‐ tor, ∥ w ∥. If we divide this slope by 2, the points where the decision function is equal to ±1 are going to be twice as far away from the decision boundary. In other words, dividing the slope by 2 will multiply the margin by 2. Perhaps this is easier to visual‐ ize in 2D in Figure 5-13. The smaller the weight vector w, the larger the margin.", "words": [{"w": "Consider", "b": [0.1429, 0.6697, 0.2195, 0.6911]}, {"w": "the", "b": [0.2249, 0.6697, 0.2512, 0.6911]}, {"w": "slope", "b": [0.2566, 0.6697, 0.2999, 0.6911]}, {"w": "of", "b": [0.3052, 0.6697, 0.322, 0.6911]}, {"w": "the", "b": [0.3274, 0.6697, 0.3537, 0.6911]}, {"w": "decision", "b": [0.359, 0.6697, 0.4285, 0.6911]}, {"w": "function:", "b": [0.4339, 0.6697, 0.51, 0.6911]}, {"w": "it", "b": [0.5154, 0.6697, 0.5273, 0.6911]}, {"w": "is", "b": [0.5327, 0.6697, 0.5459, 0.6911]}, {"w": "equal", "b": [0.5512, 0.6697, 0.5962, 0.6911]}, {"w": "to", "b": [0.6016, 0.6697, 0.6185, 0.6911]}, {"w": "the", "b": [0.6239, 0.6697, 0.6502, 0.6911]}, {"w": "norm", "b": [0.6556, 0.6697, 0.7024, 0.6911]}, {"w": "of", "b": [0.7077, 0.6697, 0.7245, 0.6911]}, {"w": "the", "b": [0.7299, 0.6697, 0.7562, 0.6911]}, {"w": "weight", "b": [0.7615, 0.6697, 0.8171, 0.6911]}, {"w": "vec‐", "b": [0.8224, 0.6697, 0.8571, 0.6911]}, {"w": "tor,", "b": [0.1429, 0.6888, 0.171, 0.7102]}, {"w": "∥", "b": [0.1763, 0.692, 0.1867, 0.7079]}, {"w": "w", "b": [0.1919, 0.6882, 0.2062, 0.7102]}, {"w": "∥.", "b": [0.2114, 0.6888, 0.2266, 0.7102]}, {"w": "If", "b": [0.2318, 0.6888, 0.2451, 0.7102]}, {"w": "we", "b": [0.2504, 0.6888, 0.2735, 0.7102]}, {"w": "divide", "b": [0.2788, 0.6888, 0.3304, 0.7102]}, {"w": "this", "b": [0.3357, 0.6888, 0.3664, 0.7102]}, {"w": "slope", "b": [0.3716, 0.6888, 0.415, 0.7102]}, {"w": "by", "b": [0.4202, 0.6888, 0.4404, 0.7102]}, {"w": "2,", "b": [0.4456, 0.6888, 0.4604, 0.7102]}, {"w": "the", "b": [0.4656, 0.6888, 0.492, 0.7102]}, {"w": "points", "b": [0.4972, 0.6888, 0.5493, 0.7102]}, {"w": "where", "b": [0.5546, 0.6888, 0.6054, 0.7102]}, {"w": "the", "b": [0.6107, 0.6888, 0.637, 0.7102]}, {"w": "decision", "b": [0.6423, 0.6888, 0.7118, 0.7102]}, {"w": "function", "b": [0.717, 0.6888, 0.7884, 0.7102]}, {"w": "is", "b": [0.7937, 0.6888, 0.8069, 0.7102]}, {"w": "equal", "b": [0.8122, 0.6888, 0.8571, 0.7102]}, {"w": "to", "b": [0.1429, 0.7078, 0.1598, 0.7292]}, {"w": "±1", "b": [0.166, 0.7078, 0.1881, 0.7292]}, {"w": "are", "b": [0.1943, 0.7078, 0.2201, 0.7292]}, {"w": "going", "b": [0.2263, 0.7078, 0.2734, 0.7292]}, {"w": "to", "b": [0.2796, 0.7078, 0.2966, 0.7292]}, {"w": "be", "b": [0.3028, 0.7078, 0.3222, 0.7292]}, {"w": "twice", "b": [0.3284, 0.7078, 0.3723, 0.7292]}, {"w": "as", "b": [0.3785, 0.7078, 0.3953, 0.7292]}, {"w": "far", "b": [0.4015, 0.7078, 0.4245, 0.7292]}, {"w": "away", "b": [0.4307, 0.7078, 0.4721, 0.7292]}, {"w": "from", "b": [0.4783, 0.7078, 0.5199, 0.7292]}, {"w": "the", "b": [0.5261, 0.7078, 0.5525, 0.7292]}, {"w": "decision", "b": [0.5587, 0.7078, 0.6282, 0.7292]}, {"w": "boundary.", "b": [0.6344, 0.7078, 0.7193, 0.7292]}, {"w": "In", "b": [0.7255, 0.7078, 0.744, 0.7292]}, {"w": "other", "b": [0.7502, 0.7078, 0.7949, 0.7292]}, {"w": "words,", "b": [0.8011, 0.7078, 0.8571, 0.7292]}, {"w": "dividing", "b": [0.1429, 0.7269, 0.2124, 0.7483]}, {"w": "the", "b": [0.2181, 0.7269, 0.2445, 0.7483]}, {"w": "slope", "b": [0.2502, 0.7269, 0.2935, 0.7483]}, {"w": "by", "b": [0.2992, 0.7269, 0.3193, 0.7483]}, {"w": "2", "b": [0.325, 0.7269, 0.335, 0.7483]}, {"w": "will", "b": [0.3408, 0.7269, 0.3712, 0.7483]}, {"w": "multiply", "b": [0.3769, 0.7269, 0.4476, 0.7483]}, {"w": "the", "b": [0.4533, 0.7269, 0.4796, 0.7483]}, {"w": "margin", "b": [0.4853, 0.7269, 0.546, 0.7483]}, {"w": "by", "b": [0.5517, 0.7269, 0.5718, 0.7483]}, {"w": "2.", "b": [0.5775, 0.7269, 0.5923, 0.7483]}, {"w": "Perhaps", "b": [0.598, 0.7269, 0.6641, 0.7483]}, {"w": "this", "b": [0.6698, 0.7269, 0.7005, 0.7483]}, {"w": "is", "b": [0.7062, 0.7269, 0.7195, 0.7483]}, {"w": "easier", "b": [0.7252, 0.7269, 0.773, 0.7483]}, {"w": "to", "b": [0.7787, 0.7269, 0.7957, 0.7483]}, {"w": "visual‐", "b": [0.8014, 0.7269, 0.8572, 0.7483]}, {"w": "ize", "b": [0.1429, 0.7459, 0.166, 0.7673]}, {"w": "in", "b": [0.1708, 0.7459, 0.1878, 0.7673]}, {"w": "2D", "b": [0.1925, 0.7459, 0.2178, 0.7673]}, {"w": "in", "b": [0.2225, 0.7459, 0.2395, 0.7673]}, {"w": "Figure", "b": [0.2442, 0.7459, 0.2982, 0.7673]}, {"w": "5-13.", "b": [0.303, 0.7459, 0.3451, 0.7673]}, {"w": "The", "b": [0.3499, 0.7459, 0.3827, 0.7673]}, {"w": "smaller", "b": [0.3874, 0.7459, 0.4484, 0.7673]}, {"w": "the", "b": [0.4531, 0.7459, 0.4795, 0.7673]}, {"w": "weight", "b": [0.4842, 0.7459, 0.5397, 0.7673]}, {"w": "vector", "b": [0.5445, 0.7459, 0.5965, 0.7673]}, {"w": "w,", "b": [0.6012, 0.7453, 0.6202, 0.7673]}, {"w": "the", "b": [0.6249, 0.7459, 0.6513, 0.7673]}, {"w": "larger", "b": [0.656, 0.7459, 0.7045, 0.7673]}, {"w": "the", "b": [0.7092, 0.7459, 0.7355, 0.7673]}, {"w": "margin.", "b": [0.7403, 0.7459, 0.8057, 0.7673]}]}, {"id": "b_6", "type": "paragraph", "text": "Under the Hood | 167", "words": [{"w": "Under", "b": [0.7034, 0.9225, 0.7393, 0.9388]}, {"w": "the", "b": [0.7421, 0.9225, 0.762, 0.9388]}, {"w": "Hood", "b": [0.7648, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "167", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 194, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "4 Zeta (ζ) is the 6th letter of the Greek alphabet.", "words": [{"w": "4", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "Zeta", "b": [0.1587, 0.8749, 0.1869, 0.8912]}, {"w": "(ζ)", "b": [0.1905, 0.8748, 0.2075, 0.8912]}, {"w": "is", "b": [0.2111, 0.8749, 0.2212, 0.8912]}, {"w": "the", "b": [0.2248, 0.8749, 0.2449, 0.8912]}, {"w": "6th", "b": [0.2485, 0.8734, 0.2666, 0.8912]}, {"w": "letter", "b": [0.2702, 0.8749, 0.3032, 0.8912]}, {"w": "of", "b": [0.3069, 0.8749, 0.3196, 0.8912]}, {"w": "the", "b": [0.3232, 0.8749, 0.3433, 0.8912]}, {"w": "Greek", "b": [0.3469, 0.8749, 0.3855, 0.8912]}, {"w": "alphabet.", "b": [0.3891, 0.8749, 0.4471, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 5-13. A smaller weight vector results in a larger margin", "words": [{"w": "Figure", "b": [0.1429, 0.229, 0.1943, 0.2506]}, {"w": "5-13.", "b": [0.1991, 0.229, 0.2407, 0.2506]}, {"w": "A", "b": [0.2455, 0.229, 0.2593, 0.2506]}, {"w": "smaller", "b": [0.2641, 0.229, 0.3233, 0.2506]}, {"w": "weight", "b": [0.3281, 0.229, 0.3811, 0.2506]}, {"w": "vector", "b": [0.3859, 0.229, 0.4347, 0.2506]}, {"w": "results", "b": [0.4395, 0.229, 0.491, 0.2506]}, {"w": "in", "b": [0.4958, 0.229, 0.5123, 0.2506]}, {"w": "a", "b": [0.5171, 0.229, 0.5273, 0.2506]}, {"w": "larger", "b": [0.5321, 0.229, 0.5792, 0.2506]}, {"w": "margin", "b": [0.584, 0.229, 0.643, 0.2506]}]}, {"id": "b_2", "type": "paragraph", "text": "So we want to minimize ∥ w ∥ to get a large margin. However, if we also want to avoid any margin violation (hard margin), then we need the decision function to be greater than 1 for all positive training instances, and lower than –1 for negative training instances. If we define t(i) = –1 for negative instances (if y(i) = 0) and t(i) = 1 for positive instances (if y(i) = 1), then we can express this constraint as t(i)(wT x(i) + b) ≥ 1 for all instances.", "words": [{"w": "So", "b": [0.1429, 0.2664, 0.1634, 0.2878]}, {"w": "we", "b": [0.1681, 0.2664, 0.1912, 0.2878]}, {"w": "want", "b": [0.196, 0.2664, 0.2367, 0.2878]}, {"w": "to", "b": [0.2415, 0.2664, 0.2584, 0.2878]}, {"w": "minimize", "b": [0.2632, 0.2664, 0.343, 0.2878]}, {"w": "∥", "b": [0.348, 0.2696, 0.3585, 0.2855]}, {"w": "w", "b": [0.3632, 0.2658, 0.3775, 0.2878]}, {"w": "∥", "b": [0.3823, 0.2696, 0.3927, 0.2855]}, {"w": "to", "b": [0.3974, 0.2664, 0.4144, 0.2878]}, {"w": "get", "b": [0.4191, 0.2664, 0.4441, 0.2878]}, {"w": "a", "b": [0.4488, 0.2664, 0.458, 0.2878]}, {"w": "large", "b": [0.4627, 0.2664, 0.5034, 0.2878]}, {"w": "margin.", "b": [0.5082, 0.2664, 0.5736, 0.2878]}, {"w": "However,", "b": [0.5783, 0.2664, 0.6572, 0.2878]}, {"w": "if", "b": [0.6619, 0.2664, 0.6736, 0.2878]}, {"w": "we", "b": [0.6784, 0.2664, 0.7015, 0.2878]}, {"w": "also", "b": [0.7062, 0.2664, 0.7389, 0.2878]}, {"w": "want", "b": [0.7436, 0.2664, 0.7844, 0.2878]}, {"w": "to", "b": [0.7891, 0.2664, 0.8061, 0.2878]}, {"w": "avoid", "b": [0.8108, 0.2664, 0.8565, 0.2878]}, {"w": "any", "b": [0.1429, 0.2854, 0.1725, 0.3068]}, {"w": "margin", "b": [0.1778, 0.2854, 0.2384, 0.3068]}, {"w": "violation", "b": [0.2437, 0.2854, 0.3176, 0.3068]}, {"w": "(hard", "b": [0.3228, 0.2854, 0.3691, 0.3068]}, {"w": "margin),", "b": [0.3743, 0.2854, 0.447, 0.3068]}, {"w": "then", "b": [0.4523, 0.2854, 0.49, 0.3068]}, {"w": "we", "b": [0.4953, 0.2854, 0.5184, 0.3068]}, {"w": "need", "b": [0.5237, 0.2854, 0.5638, 0.3068]}, {"w": "the", "b": [0.5691, 0.2854, 0.5954, 0.3068]}, {"w": "decision", "b": [0.6007, 0.2854, 0.6702, 0.3068]}, {"w": "function", "b": [0.6755, 0.2854, 0.7469, 0.3068]}, {"w": "to", "b": [0.7521, 0.2854, 0.7691, 0.3068]}, {"w": "be", "b": [0.7744, 0.2854, 0.7938, 0.3068]}, {"w": "greater", "b": [0.7991, 0.2854, 0.8572, 0.3068]}, {"w": "than", "b": [0.1429, 0.3045, 0.1809, 0.3259]}, {"w": "1", "b": [0.1894, 0.3045, 0.1994, 0.3259]}, {"w": "for", "b": [0.2079, 0.3045, 0.2324, 0.3259]}, {"w": "all", "b": [0.2409, 0.3045, 0.2606, 0.3259]}, {"w": "positive", "b": [0.2691, 0.3045, 0.3343, 0.3259]}, {"w": "training", "b": [0.3428, 0.3045, 0.4098, 0.3259]}, {"w": "instances,", "b": [0.4183, 0.3045, 0.4998, 0.3259]}, {"w": "and", "b": [0.5083, 0.3045, 0.5399, 0.3259]}, {"w": "lower", "b": [0.5484, 0.3045, 0.5951, 0.3259]}, {"w": "than", "b": [0.6036, 0.3045, 0.6417, 0.3259]}, {"w": "–1", "b": [0.6502, 0.3045, 0.671, 0.3259]}, {"w": "for", "b": [0.6795, 0.3045, 0.704, 0.3259]}, {"w": "negative", "b": [0.7125, 0.3045, 0.7817, 0.3259]}, {"w": "training", "b": [0.7902, 0.3045, 0.8571, 0.3259]}, {"w": "instances.", "b": [0.1429, 0.3235, 0.2244, 0.3449]}, {"w": "If", "b": [0.2292, 0.3235, 0.2424, 0.3449]}, {"w": "we", "b": [0.2472, 0.3235, 0.2703, 0.3449]}, {"w": "define", "b": [0.275, 0.3235, 0.3269, 0.3449]}, {"w": "t(i)", "b": [0.3321, 0.3233, 0.3502, 0.3449]}, {"w": "=", "b": [0.3551, 0.3235, 0.3672, 0.3449]}, {"w": "–1", "b": [0.3719, 0.3235, 0.3927, 0.3449]}, {"w": "for", "b": [0.3975, 0.3235, 0.422, 0.3449]}, {"w": "negative", "b": [0.4267, 0.3235, 0.4959, 0.3449]}, {"w": "instances", "b": [0.5006, 0.3235, 0.5775, 0.3449]}, {"w": "(if", "b": [0.5822, 0.3235, 0.6012, 0.3449]}, {"w": "y(i)", "b": [0.6066, 0.3233, 0.6276, 0.3449]}, {"w": "=", "b": [0.6324, 0.3235, 0.6445, 0.3449]}, {"w": "0)", "b": [0.6492, 0.3235, 0.6664, 0.3449]}, {"w": "and", "b": [0.6712, 0.3235, 0.7027, 0.3449]}, {"w": "t(i)", "b": [0.7078, 0.3233, 0.726, 0.3449]}, {"w": "=", "b": [0.7308, 0.3235, 0.7429, 0.3449]}, {"w": "1", "b": [0.7476, 0.3235, 0.7576, 0.3449]}, {"w": "for", "b": [0.7624, 0.3235, 0.7869, 0.3449]}, {"w": "positive", "b": [0.7916, 0.3235, 0.8568, 0.3449]}, {"w": "instances", "b": [0.1429, 0.3426, 0.2197, 0.364]}, {"w": "(if", "b": [0.2257, 0.3426, 0.2447, 0.364]}, {"w": "y(i)", "b": [0.2507, 0.3424, 0.2718, 0.364]}, {"w": "=", "b": [0.2778, 0.3426, 0.2899, 0.364]}, {"w": "1),", "b": [0.2959, 0.3426, 0.3179, 0.364]}, {"w": "then", "b": [0.3239, 0.3426, 0.3617, 0.364]}, {"w": "we", "b": [0.3677, 0.3426, 0.3908, 0.364]}, {"w": "can", "b": [0.3969, 0.3426, 0.4262, 0.364]}, {"w": "express", "b": [0.4323, 0.3426, 0.4938, 0.364]}, {"w": "this", "b": [0.4998, 0.3426, 0.5305, 0.364]}, {"w": "constraint", "b": [0.5366, 0.3426, 0.6212, 0.364]}, {"w": "as", "b": [0.6273, 0.3426, 0.6441, 0.364]}, {"w": "t(i)(wT", "b": [0.6501, 0.342, 0.6973, 0.364]}, {"w": "x(i)", "b": [0.7033, 0.342, 0.7252, 0.364]}, {"w": "+", "b": [0.7312, 0.3426, 0.7433, 0.364]}, {"w": "b)", "b": [0.7493, 0.3424, 0.7667, 0.364]}, {"w": "≥", "b": [0.7727, 0.3426, 0.7848, 0.364]}, {"w": "1", "b": [0.7908, 0.3426, 0.8008, 0.364]}, {"w": "for", "b": [0.8069, 0.3426, 0.8314, 0.364]}, {"w": "all", "b": [0.8375, 0.3426, 0.8571, 0.364]}, {"w": "instances.", "b": [0.1429, 0.3616, 0.2244, 0.383]}]}, {"id": "b_3", "type": "paragraph", "text": "We can therefore express the hard margin linear SVM classifier objective as the con‐ strained optimization problem in Equation 5-3.", "words": [{"w": "We", "b": [0.1429, 0.3897, 0.1699, 0.4111]}, {"w": "can", "b": [0.1759, 0.3897, 0.2052, 0.4111]}, {"w": "therefore", "b": [0.2112, 0.3897, 0.2875, 0.4111]}, {"w": "express", "b": [0.2934, 0.3897, 0.3549, 0.4111]}, {"w": "the", "b": [0.3609, 0.3897, 0.3872, 0.4111]}, {"w": "hard", "b": [0.3931, 0.3897, 0.4321, 0.4111]}, {"w": "margin", "b": [0.4381, 0.3897, 0.4988, 0.4111]}, {"w": "linear", "b": [0.5047, 0.3897, 0.5527, 0.4111]}, {"w": "SVM", "b": [0.5586, 0.3897, 0.6017, 0.4111]}, {"w": "classifier", "b": [0.6077, 0.3897, 0.6801, 0.4111]}, {"w": "objective", "b": [0.6861, 0.3897, 0.7607, 0.4111]}, {"w": "as", "b": [0.7667, 0.3897, 0.7835, 0.4111]}, {"w": "the", "b": [0.7894, 0.3897, 0.8157, 0.4111]}, {"w": "con‐", "b": [0.8217, 0.3895, 0.8571, 0.4111]}, {"w": "strained", "b": [0.1429, 0.4086, 0.2081, 0.4302]}, {"w": "optimization", "b": [0.2129, 0.4086, 0.3167, 0.4302]}, {"w": "problem", "b": [0.3215, 0.4088, 0.3925, 0.4302]}, {"w": "in", "b": [0.3972, 0.4088, 0.4142, 0.4302]}, {"w": "Equation", "b": [0.419, 0.4088, 0.4952, 0.4302]}, {"w": "5-3.", "b": [0.4999, 0.4088, 0.5321, 0.4302]}]}, {"id": "b_4", "type": "equation", "text": "Equation 5-3. Hard margin linear SVM classifier objective", "words": [{"w": "Equation", "b": [0.1726, 0.4483, 0.2473, 0.4699]}, {"w": "5-3.", "b": [0.2521, 0.4483, 0.2838, 0.4699]}, {"w": "Hard", "b": [0.2886, 0.4483, 0.3311, 0.4699]}, {"w": "margin", "b": [0.3358, 0.4483, 0.3948, 0.4699]}, {"w": "linear", "b": [0.3996, 0.4483, 0.4466, 0.4699]}, {"w": "SVM", "b": [0.4513, 0.4483, 0.4934, 0.4699]}, {"w": "classifier", "b": [0.4982, 0.4483, 0.5683, 0.4699]}, {"w": "objective", "b": [0.573, 0.4483, 0.6434, 0.4699]}]}, {"id": "b_5", "type": "paragraph", "text": "minimize w, b", "words": [{"w": "minimize", "b": [0.1813, 0.4851, 0.2574, 0.5055]}, {"w": "w,", "b": [0.2069, 0.4966, 0.2214, 0.5134]}, {"w": "b", "b": [0.224, 0.4969, 0.2318, 0.5134]}]}, {"id": "b_6", "type": "paragraph", "text": "1 2wTw", "words": [{"w": "1", "b": [0.2849, 0.4763, 0.2945, 0.4967]}, {"w": "2wTw", "b": [0.2849, 0.4812, 0.334, 0.5143]}]}, {"id": "b_7", "type": "equation", "text": "subject to t i wTx i + b ≥1 for i = 1, 2, ⋯, m", "words": [{"w": "subject", "b": [0.1813, 0.5202, 0.2372, 0.5406]}, {"w": "to", "b": [0.2451, 0.5202, 0.2613, 0.5406]}, {"w": "t", "b": [0.2811, 0.52, 0.2872, 0.5406]}, {"w": "i", "b": [0.2932, 0.5163, 0.2975, 0.5328]}, {"w": "wTx", "b": [0.3099, 0.5163, 0.3433, 0.5406]}, {"w": "i", "b": [0.3489, 0.5163, 0.3532, 0.5328]}, {"w": "+", "b": [0.3631, 0.5202, 0.3746, 0.5406]}, {"w": "b", "b": [0.3791, 0.52, 0.3887, 0.5406]}, {"w": "≥1", "b": [0.4011, 0.5202, 0.4276, 0.5406]}, {"w": "for", "b": [0.4474, 0.5202, 0.4708, 0.5406]}, {"w": "i", "b": [0.4787, 0.52, 0.4841, 0.5406]}, {"w": "=", "b": [0.4896, 0.5202, 0.5012, 0.5406]}, {"w": "1,", "b": [0.5067, 0.5202, 0.5207, 0.5406]}, {"w": "2,", "b": [0.524, 0.5202, 0.5381, 0.5406]}, {"w": "⋯,", "b": [0.5414, 0.5202, 0.5657, 0.5406]}, {"w": "m", "b": [0.5691, 0.52, 0.5847, 0.5406]}]}, {"id": "b_8", "type": "paragraph", "text": "We are minimizing 1", "words": [{"w": "We", "b": [0.2714, 0.5681, 0.2961, 0.5877]}, {"w": "are", "b": [0.302, 0.5681, 0.3255, 0.5877]}, {"w": "minimizing", "b": [0.3314, 0.5681, 0.4208, 0.5877]}, {"w": "1", "b": [0.4288, 0.5627, 0.4364, 0.579]}]}, {"id": "b_9", "type": "paragraph", "text": "2wT w, which is equal to 1 2∥ w ∥2, rather than", "words": [{"w": "2wT", "b": [0.4288, 0.5676, 0.4591, 0.5935]}, {"w": "w,", "b": [0.4649, 0.5676, 0.4823, 0.5877]}, {"w": "which", "b": [0.4882, 0.5681, 0.5347, 0.5877]}, {"w": "is", "b": [0.5406, 0.5681, 0.5527, 0.5877]}, {"w": "equal", "b": [0.5586, 0.5681, 0.5997, 0.5877]}, {"w": "to", "b": [0.6056, 0.5681, 0.6211, 0.5877]}, {"w": "1", "b": [0.6291, 0.5627, 0.6367, 0.579]}, {"w": "2∥", "b": [0.6291, 0.5711, 0.6484, 0.5935]}, {"w": "w", "b": [0.6542, 0.5676, 0.6672, 0.5877]}, {"w": "∥2,", "b": [0.6731, 0.5681, 0.693, 0.5877]}, {"w": "rather", "b": [0.6989, 0.5681, 0.7451, 0.5877]}, {"w": "than", "b": [0.7509, 0.5681, 0.7857, 0.5877]}]}, {"id": "b_10", "type": "paragraph", "text": "minimizing ∥ w ∥. Indeed, 1", "words": [{"w": "minimizing", "b": [0.2714, 0.5947, 0.3608, 0.6143]}, {"w": "∥", "b": [0.3655, 0.5977, 0.375, 0.6122]}, {"w": "w", "b": [0.3798, 0.5942, 0.3928, 0.6143]}, {"w": "∥.", "b": [0.3975, 0.5947, 0.4114, 0.6143]}, {"w": "Indeed,", "b": [0.4161, 0.5947, 0.4737, 0.6143]}, {"w": "1", "b": [0.4805, 0.5893, 0.4881, 0.6056]}]}, {"id": "b_11", "type": "paragraph", "text": "2∥ w ∥2 has a nice and simple derivative", "words": [{"w": "2∥", "b": [0.4805, 0.5977, 0.4998, 0.6201]}, {"w": "w", "b": [0.5045, 0.5942, 0.5175, 0.6143]}, {"w": "∥2", "b": [0.5222, 0.5948, 0.5378, 0.6122]}, {"w": "has", "b": [0.5425, 0.5947, 0.568, 0.6143]}, {"w": "a", "b": [0.5727, 0.5947, 0.5811, 0.6143]}, {"w": "nice", "b": [0.5858, 0.5947, 0.6175, 0.6143]}, {"w": "and", "b": [0.6222, 0.5947, 0.6511, 0.6143]}, {"w": "simple", "b": [0.6558, 0.5947, 0.706, 0.6143]}, {"w": "derivative", "b": [0.7107, 0.5947, 0.7857, 0.6143]}]}, {"id": "b_12", "type": "paragraph", "text": "(it is just w) while ∥ w ∥ is not differentiable at w = 0. Optimization algorithms work much better on differentiable functions.", "words": [{"w": "(it", "b": [0.2714, 0.6167, 0.2889, 0.6363]}, {"w": "is", "b": [0.2936, 0.6167, 0.3057, 0.6363]}, {"w": "just", "b": [0.3103, 0.6167, 0.3381, 0.6363]}, {"w": "w)", "b": [0.3428, 0.6162, 0.3624, 0.6363]}, {"w": "while", "b": [0.367, 0.6167, 0.4082, 0.6363]}, {"w": "∥", "b": [0.4129, 0.6197, 0.4224, 0.6342]}, {"w": "w", "b": [0.4271, 0.6162, 0.4401, 0.6363]}, {"w": "∥", "b": [0.4447, 0.6197, 0.4542, 0.6342]}, {"w": "is", "b": [0.4589, 0.6167, 0.471, 0.6363]}, {"w": "not", "b": [0.4756, 0.6167, 0.5016, 0.6363]}, {"w": "differentiable", "b": [0.5062, 0.6167, 0.6078, 0.6363]}, {"w": "at", "b": [0.6125, 0.6167, 0.6263, 0.6363]}, {"w": "w", "b": [0.631, 0.6162, 0.644, 0.6363]}, {"w": "=", "b": [0.6486, 0.6167, 0.6597, 0.6363]}, {"w": "0.", "b": [0.6643, 0.6162, 0.6782, 0.6363]}, {"w": "Optimization", "b": [0.6825, 0.6167, 0.7854, 0.6363]}, {"w": "algorithms", "b": [0.2714, 0.6342, 0.354, 0.6537]}, {"w": "work", "b": [0.3583, 0.6342, 0.3976, 0.6537]}, {"w": "much", "b": [0.4019, 0.6342, 0.4455, 0.6537]}, {"w": "better", "b": [0.4498, 0.6342, 0.4944, 0.6537]}, {"w": "on", "b": [0.4987, 0.6342, 0.5188, 0.6537]}, {"w": "differentiable", "b": [0.5231, 0.6342, 0.6248, 0.6537]}, {"w": "functions.", "b": [0.6291, 0.6342, 0.7057, 0.6537]}]}, {"id": "b_13", "type": "paragraph", "text": "To get the soft margin objective, we need to introduce a slack variable ζ(i) ≥ 0 for each instance:4 ζ(i) measures how much the ith instance is allowed to violate the margin. We now have two conflicting objectives: making the slack variables as small as possible to reduce the margin violations, and making 1", "words": [{"w": "To", "b": [0.1429, 0.674, 0.1643, 0.6954]}, {"w": "get", "b": [0.1696, 0.674, 0.1946, 0.6954]}, {"w": "the", "b": [0.1999, 0.674, 0.2263, 0.6954]}, {"w": "soft", "b": [0.2316, 0.674, 0.2624, 0.6954]}, {"w": "margin", "b": [0.2678, 0.674, 0.3284, 0.6954]}, {"w": "objective,", "b": [0.3338, 0.674, 0.4132, 0.6954]}, {"w": "we", "b": [0.4185, 0.674, 0.4417, 0.6954]}, {"w": "need", "b": [0.447, 0.674, 0.4871, 0.6954]}, {"w": "to", "b": [0.4925, 0.674, 0.5094, 0.6954]}, {"w": "introduce", "b": [0.5148, 0.674, 0.5958, 0.6954]}, {"w": "a", "b": [0.6012, 0.674, 0.6103, 0.6954]}, {"w": "slack", "b": [0.6157, 0.6738, 0.6551, 0.6954]}, {"w": "variable", "b": [0.6599, 0.6738, 0.7255, 0.6954]}, {"w": "ζ(i)", "b": [0.7315, 0.6738, 0.7512, 0.6954]}, {"w": "≥", "b": [0.7566, 0.674, 0.7686, 0.6954]}, {"w": "0", "b": [0.774, 0.674, 0.784, 0.6954]}, {"w": "for", "b": [0.7893, 0.674, 0.8139, 0.6954]}, {"w": "each", "b": [0.8192, 0.674, 0.8572, 0.6954]}, {"w": "instance:4", "b": [0.1429, 0.6931, 0.2225, 0.7145]}, {"w": "ζ(i)", "b": [0.2277, 0.6929, 0.2475, 0.7145]}, {"w": "measures", "b": [0.2527, 0.6931, 0.3307, 0.7145]}, {"w": "how", "b": [0.3359, 0.6931, 0.3719, 0.7145]}, {"w": "much", "b": [0.3772, 0.6931, 0.4248, 0.7145]}, {"w": "the", "b": [0.43, 0.6931, 0.4564, 0.7145]}, {"w": "ith", "b": [0.4616, 0.6931, 0.4777, 0.7145]}, {"w": "instance", "b": [0.4829, 0.6931, 0.5521, 0.7145]}, {"w": "is", "b": [0.5573, 0.6931, 0.5705, 0.7145]}, {"w": "allowed", "b": [0.5757, 0.6931, 0.6402, 0.7145]}, {"w": "to", "b": [0.6454, 0.6931, 0.6624, 0.7145]}, {"w": "violate", "b": [0.6676, 0.6931, 0.7227, 0.7145]}, {"w": "the", "b": [0.7279, 0.6931, 0.7542, 0.7145]}, {"w": "margin.", "b": [0.7594, 0.6931, 0.8249, 0.7145]}, {"w": "We", "b": [0.8301, 0.6931, 0.8571, 0.7145]}, {"w": "now", "b": [0.1428, 0.7121, 0.1791, 0.7335]}, {"w": "have", "b": [0.1841, 0.7121, 0.2225, 0.7335]}, {"w": "two", "b": [0.2275, 0.7121, 0.2588, 0.7335]}, {"w": "conflicting", "b": [0.2638, 0.7121, 0.3535, 0.7335]}, {"w": "objectives:", "b": [0.3586, 0.7121, 0.4456, 0.7335]}, {"w": "making", "b": [0.4506, 0.7121, 0.5139, 0.7335]}, {"w": "the", "b": [0.5189, 0.7121, 0.5452, 0.7335]}, {"w": "slack", "b": [0.5502, 0.7121, 0.5914, 0.7335]}, {"w": "variables", "b": [0.5964, 0.7121, 0.67, 0.7335]}, {"w": "as", "b": [0.675, 0.7121, 0.6918, 0.7335]}, {"w": "small", "b": [0.6968, 0.7121, 0.7412, 0.7335]}, {"w": "as", "b": [0.7462, 0.7121, 0.763, 0.7335]}, {"w": "possible", "b": [0.768, 0.7121, 0.8352, 0.7335]}, {"w": "to", "b": [0.8402, 0.7121, 0.8571, 0.7335]}, {"w": "reduce", "b": [0.1429, 0.7351, 0.1992, 0.7565]}, {"w": "the", "b": [0.2053, 0.7351, 0.2316, 0.7565]}, {"w": "margin", "b": [0.2377, 0.7351, 0.2984, 0.7565]}, {"w": "violations,", "b": [0.3044, 0.7351, 0.3907, 0.7565]}, {"w": "and", "b": [0.3968, 0.7351, 0.4283, 0.7565]}, {"w": "making", "b": [0.4344, 0.7351, 0.4977, 0.7565]}, {"w": "1", "b": [0.5061, 0.7306, 0.5137, 0.7469]}]}, {"id": "b_14", "type": "paragraph", "text": "2wT w as small as possible to increase the", "words": [{"w": "2wT", "b": [0.5061, 0.7345, 0.5378, 0.7616]}, {"w": "w", "b": [0.5438, 0.7345, 0.5581, 0.7565]}, {"w": "as", "b": [0.5642, 0.7351, 0.581, 0.7565]}, {"w": "small", "b": [0.587, 0.7351, 0.6314, 0.7565]}, {"w": "as", "b": [0.6375, 0.7351, 0.6543, 0.7565]}, {"w": "possible", "b": [0.6604, 0.7351, 0.7275, 0.7565]}, {"w": "to", "b": [0.7336, 0.7351, 0.7506, 0.7565]}, {"w": "increase", "b": [0.7567, 0.7351, 0.8247, 0.7565]}, {"w": "the", "b": [0.8308, 0.7351, 0.8571, 0.7565]}]}, {"id": "b_15", "type": "paragraph", "text": "margin. This is where the C hyperparameter comes in: it allows us to define the trade‐", "words": [{"w": "margin.", "b": [0.1429, 0.7589, 0.2083, 0.7803]}, {"w": "This", "b": [0.2133, 0.7589, 0.2505, 0.7803]}, {"w": "is", "b": [0.2554, 0.7589, 0.2687, 0.7803]}, {"w": "where", "b": [0.2736, 0.7589, 0.3245, 0.7803]}, {"w": "the", "b": [0.3294, 0.7589, 0.3558, 0.7803]}, {"w": "C", "b": [0.3608, 0.7621, 0.3706, 0.7772]}, {"w": "hyperparameter", "b": [0.3756, 0.7589, 0.5091, 0.7803]}, {"w": "comes", "b": [0.5141, 0.7589, 0.5671, 0.7803]}, {"w": "in:", "b": [0.5721, 0.7589, 0.5938, 0.7803]}, {"w": "it", "b": [0.5988, 0.7589, 0.6107, 0.7803]}, {"w": "allows", "b": [0.6157, 0.7589, 0.6679, 0.7803]}, {"w": "us", "b": [0.6729, 0.7589, 0.6916, 0.7803]}, {"w": "to", "b": [0.6966, 0.7589, 0.7135, 0.7803]}, {"w": "define", "b": [0.7185, 0.7589, 0.7704, 0.7803]}, {"w": "the", "b": [0.7753, 0.7589, 0.8017, 0.7803]}, {"w": "trade‐", "b": [0.8066, 0.7589, 0.8571, 0.7803]}]}, {"id": "b_16", "type": "paragraph", "text": "168 | Chapter 5: Support Vector Machines", "words": [{"w": "168", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "5:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Support", "b": [0.2673, 0.9225, 0.3142, 0.9388]}, {"w": "Vector", "b": [0.317, 0.9225, 0.3547, 0.9388]}, {"w": "Machines", "b": [0.3575, 0.9225, 0.413, 0.9388]}]}]}, {"page": 195, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "5 To learn more about Quadratic Programming, you can start by reading Stephen Boyd and Lieven Vanden‐ berghe, Convex Optimization (Cambridge, UK: Cambridge University Press, 2004) or watch Richard Brown’s series of video lectures.", "words": [{"w": "5", "b": [0.1451, 0.8462, 0.1518, 0.8604]}, {"w": "To", "b": [0.1587, 0.8447, 0.1751, 0.861]}, {"w": "learn", "b": [0.1787, 0.8447, 0.211, 0.861]}, {"w": "more", "b": [0.2146, 0.8447, 0.2483, 0.861]}, {"w": "about", "b": [0.2519, 0.8447, 0.2883, 0.861]}, {"w": "Quadratic", "b": [0.2919, 0.8447, 0.3559, 0.861]}, {"w": "Programming,", "b": [0.3595, 0.8447, 0.4527, 0.861]}, {"w": "you", "b": [0.4563, 0.8447, 0.4801, 0.861]}, {"w": "can", "b": [0.4837, 0.8447, 0.506, 0.861]}, {"w": "start", "b": [0.5097, 0.8447, 0.538, 0.861]}, {"w": "by", "b": [0.5416, 0.8447, 0.557, 0.861]}, {"w": "reading", "b": [0.5606, 0.8447, 0.6089, 0.861]}, {"w": "Stephen", "b": [0.6125, 0.8447, 0.6639, 0.861]}, {"w": "Boyd", "b": [0.6675, 0.8447, 0.7009, 0.861]}, {"w": "and", "b": [0.7045, 0.8447, 0.7285, 0.861]}, {"w": "Lieven", "b": [0.7321, 0.8447, 0.7744, 0.861]}, {"w": "Vanden‐", "b": [0.778, 0.8447, 0.8327, 0.861]}, {"w": "berghe,", "b": [0.1587, 0.8598, 0.2057, 0.8761]}, {"w": "Convex", "b": [0.2093, 0.8596, 0.2557, 0.8761]}, {"w": "Optimization", "b": [0.2593, 0.8596, 0.3424, 0.8761]}, {"w": "(Cambridge,", "b": [0.346, 0.8598, 0.4264, 0.8761]}, {"w": "UK:", "b": [0.43, 0.8598, 0.456, 0.8761]}, {"w": "Cambridge", "b": [0.4596, 0.8598, 0.5309, 0.8761]}, {"w": "University", "b": [0.5345, 0.8598, 0.6007, 0.8761]}, {"w": "Press,", "b": [0.6043, 0.8598, 0.6411, 0.8761]}, {"w": "2004)", "b": [0.6447, 0.8598, 0.6807, 0.8761]}, {"w": "or", "b": [0.6843, 0.8598, 0.6983, 0.8761]}, {"w": "watch", "b": [0.7019, 0.8598, 0.7394, 0.8761]}, {"w": "Richard", "b": [0.743, 0.8598, 0.7936, 0.8761]}, {"w": "Brown’s", "b": [0.7972, 0.8598, 0.8466, 0.8761]}, {"w": "series", "b": [0.1587, 0.8749, 0.194, 0.8912]}, {"w": "of", "b": [0.1976, 0.8749, 0.2104, 0.8912]}, {"w": "video", "b": [0.214, 0.8749, 0.2488, 0.8912]}, {"w": "lectures.", "b": [0.2524, 0.8749, 0.3053, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "off between these two objectives. This gives us the constrained optimization problem in Equation 5-4.", "words": [{"w": "off", "b": [0.1429, 0.0791, 0.1658, 0.1005]}, {"w": "between", "b": [0.1713, 0.0791, 0.2404, 0.1005]}, {"w": "these", "b": [0.2459, 0.0791, 0.2887, 0.1005]}, {"w": "two", "b": [0.2942, 0.0791, 0.3255, 0.1005]}, {"w": "objectives.", "b": [0.3309, 0.0791, 0.418, 0.1005]}, {"w": "This", "b": [0.4234, 0.0791, 0.4606, 0.1005]}, {"w": "gives", "b": [0.4661, 0.0791, 0.5076, 0.1005]}, {"w": "us", "b": [0.5131, 0.0791, 0.5318, 0.1005]}, {"w": "the", "b": [0.5372, 0.0791, 0.5636, 0.1005]}, {"w": "constrained", "b": [0.569, 0.0791, 0.6676, 0.1005]}, {"w": "optimization", "b": [0.673, 0.0791, 0.7806, 0.1005]}, {"w": "problem", "b": [0.7861, 0.0791, 0.8571, 0.1005]}, {"w": "in", "b": [0.1428, 0.0981, 0.1598, 0.1195]}, {"w": "Equation", "b": [0.1646, 0.0981, 0.2408, 0.1195]}, {"w": "5-4.", "b": [0.2455, 0.0981, 0.2777, 0.1195]}]}, {"id": "b_2", "type": "equation", "text": "Equation 5-4. Soft margin linear SVM classifier objective", "words": [{"w": "Equation", "b": [0.1726, 0.1376, 0.2473, 0.1593]}, {"w": "5-4.", "b": [0.2521, 0.1376, 0.2838, 0.1593]}, {"w": "Soft", "b": [0.2886, 0.1376, 0.3199, 0.1593]}, {"w": "margin", "b": [0.3247, 0.1376, 0.3837, 0.1593]}, {"w": "linear", "b": [0.3884, 0.1376, 0.4354, 0.1593]}, {"w": "SVM", "b": [0.4402, 0.1376, 0.4822, 0.1593]}, {"w": "classifier", "b": [0.487, 0.1376, 0.5571, 0.1593]}, {"w": "objective", "b": [0.5619, 0.1376, 0.6323, 0.1593]}]}, {"id": "b_3", "type": "paragraph", "text": "minimize w, b, ζ", "words": [{"w": "minimize", "b": [0.1813, 0.1792, 0.2574, 0.1996]}, {"w": "w,", "b": [0.2003, 0.191, 0.2147, 0.2077]}, {"w": "b,", "b": [0.2174, 0.1912, 0.2287, 0.2077]}, {"w": "ζ", "b": [0.2314, 0.1912, 0.2374, 0.2077]}]}, {"id": "b_4", "type": "equation", "text": "1 2wTw + C ∑ i = 1", "words": [{"w": "1", "b": [0.2849, 0.1704, 0.2945, 0.1908]}, {"w": "2wTw", "b": [0.2849, 0.1753, 0.334, 0.2084]}, {"w": "+", "b": [0.3385, 0.1792, 0.35, 0.1996]}, {"w": "C", "b": [0.3544, 0.179, 0.367, 0.1996]}, {"w": "∑", "b": [0.3757, 0.1745, 0.3907, 0.2033]}, {"w": "i", "b": [0.3682, 0.1939, 0.3726, 0.2104]}, {"w": "=", "b": [0.377, 0.1941, 0.3862, 0.2104]}, {"w": "1", "b": [0.3906, 0.1941, 0.3982, 0.2104]}]}, {"id": "b_6", "type": "paragraph", "text": "ζ i", "words": [{"w": "ζ", "b": [0.4004, 0.179, 0.408, 0.1996]}, {"w": "i", "b": [0.4147, 0.1753, 0.4191, 0.1918]}]}, {"id": "b_7", "type": "equation", "text": "subject to t i wTx i + b ≥1 −ζ i and ζ i ≥0 for i = 1, 2, ⋯, m", "words": [{"w": "subject", "b": [0.1813, 0.2165, 0.2372, 0.2369]}, {"w": "to", "b": [0.2451, 0.2165, 0.2613, 0.2369]}, {"w": "t", "b": [0.2811, 0.2163, 0.2872, 0.2369]}, {"w": "i", "b": [0.2932, 0.2126, 0.2975, 0.2291]}, {"w": "wTx", "b": [0.3099, 0.2126, 0.3433, 0.2369]}, {"w": "i", "b": [0.3489, 0.2126, 0.3532, 0.2291]}, {"w": "+", "b": [0.3631, 0.2165, 0.3746, 0.2369]}, {"w": "b", "b": [0.379, 0.2163, 0.3887, 0.2369]}, {"w": "≥1", "b": [0.4011, 0.2165, 0.4276, 0.2369]}, {"w": "−ζ", "b": [0.432, 0.2163, 0.4555, 0.2369]}, {"w": "i", "b": [0.4622, 0.2126, 0.4666, 0.2291]}, {"w": "and", "b": [0.4919, 0.2165, 0.5219, 0.2369]}, {"w": "ζ", "b": [0.5418, 0.2163, 0.5494, 0.2369]}, {"w": "i", "b": [0.5561, 0.2126, 0.5604, 0.2291]}, {"w": "≥0", "b": [0.5714, 0.2165, 0.598, 0.2369]}, {"w": "for", "b": [0.6178, 0.2165, 0.6412, 0.2369]}, {"w": "i", "b": [0.6491, 0.2163, 0.6545, 0.2369]}, {"w": "=", "b": [0.66, 0.2165, 0.6715, 0.2369]}, {"w": "1,", "b": [0.677, 0.2165, 0.6911, 0.2369]}, {"w": "2,", "b": [0.6944, 0.2165, 0.7084, 0.2369]}, {"w": "⋯,", "b": [0.7118, 0.2165, 0.7361, 0.2369]}, {"w": "m", "b": [0.7394, 0.2163, 0.755, 0.2369]}]}, {"id": "b_8", "type": "paragraph", "text": "Quadratic Programming", "words": [{"w": "Quadratic", "b": [0.1429, 0.2569, 0.2426, 0.2855]}, {"w": "Programming", "b": [0.2475, 0.2569, 0.3908, 0.2855]}]}, {"id": "b_9", "type": "paragraph", "text": "The hard margin and soft margin problems are both convex quadratic optimization problems with linear constraints. Such problems are known as Quadratic Program‐ ming (QP) problems. Many off-the-shelf solvers are available to solve QP problems using a variety of techniques that are outside the scope of this book.5 The general problem formulation is given by Equation 5-5.", "words": [{"w": "The", "b": [0.1428, 0.2914, 0.1757, 0.3128]}, {"w": "hard", "b": [0.1821, 0.2914, 0.2211, 0.3128]}, {"w": "margin", "b": [0.2275, 0.2914, 0.2881, 0.3128]}, {"w": "and", "b": [0.2945, 0.2914, 0.3261, 0.3128]}, {"w": "soft", "b": [0.3325, 0.2914, 0.3633, 0.3128]}, {"w": "margin", "b": [0.3697, 0.2914, 0.4303, 0.3128]}, {"w": "problems", "b": [0.4367, 0.2914, 0.5154, 0.3128]}, {"w": "are", "b": [0.5218, 0.2914, 0.5475, 0.3128]}, {"w": "both", "b": [0.5539, 0.2914, 0.5926, 0.3128]}, {"w": "convex", "b": [0.599, 0.2914, 0.6577, 0.3128]}, {"w": "quadratic", "b": [0.6641, 0.2914, 0.7432, 0.3128]}, {"w": "optimization", "b": [0.7496, 0.2914, 0.8571, 0.3128]}, {"w": "problems", "b": [0.1429, 0.3104, 0.2216, 0.3318]}, {"w": "with", "b": [0.2288, 0.3104, 0.2661, 0.3318]}, {"w": "linear", "b": [0.2733, 0.3104, 0.3213, 0.3318]}, {"w": "constraints.", "b": [0.3285, 0.3104, 0.4256, 0.3318]}, {"w": "Such", "b": [0.4328, 0.3104, 0.4737, 0.3318]}, {"w": "problems", "b": [0.4809, 0.3104, 0.5596, 0.3318]}, {"w": "are", "b": [0.5668, 0.3104, 0.5926, 0.3318]}, {"w": "known", "b": [0.5998, 0.3104, 0.6578, 0.3318]}, {"w": "as", "b": [0.665, 0.3104, 0.6818, 0.3318]}, {"w": "Quadratic", "b": [0.689, 0.3102, 0.772, 0.3318]}, {"w": "Program‐", "b": [0.7793, 0.3102, 0.8572, 0.3318]}, {"w": "ming", "b": [0.1429, 0.3293, 0.1839, 0.3509]}, {"w": "(QP)", "b": [0.1909, 0.3295, 0.2325, 0.3509]}, {"w": "problems.", "b": [0.2395, 0.3295, 0.3229, 0.3509]}, {"w": "Many", "b": [0.3299, 0.3295, 0.3778, 0.3509]}, {"w": "off-the-shelf", "b": [0.3847, 0.3295, 0.4879, 0.3509]}, {"w": "solvers", "b": [0.4949, 0.3295, 0.5523, 0.3509]}, {"w": "are", "b": [0.5593, 0.3295, 0.585, 0.3509]}, {"w": "available", "b": [0.592, 0.3295, 0.6643, 0.3509]}, {"w": "to", "b": [0.6713, 0.3295, 0.6882, 0.3509]}, {"w": "solve", "b": [0.6952, 0.3295, 0.7372, 0.3509]}, {"w": "QP", "b": [0.7442, 0.3295, 0.7715, 0.3509]}, {"w": "problems", "b": [0.7785, 0.3295, 0.8571, 0.3509]}, {"w": "using", "b": [0.1429, 0.3485, 0.1883, 0.3699]}, {"w": "a", "b": [0.1961, 0.3485, 0.2052, 0.3699]}, {"w": "variety", "b": [0.213, 0.3485, 0.2699, 0.3699]}, {"w": "of", "b": [0.2777, 0.3485, 0.2945, 0.3699]}, {"w": "techniques", "b": [0.3023, 0.3485, 0.3926, 0.3699]}, {"w": "that", "b": [0.4004, 0.3485, 0.433, 0.3699]}, {"w": "are", "b": [0.4408, 0.3485, 0.4665, 0.3699]}, {"w": "outside", "b": [0.4743, 0.3485, 0.5354, 0.3699]}, {"w": "the", "b": [0.5432, 0.3485, 0.5696, 0.3699]}, {"w": "scope", "b": [0.5774, 0.3485, 0.6242, 0.3699]}, {"w": "of", "b": [0.632, 0.3485, 0.6488, 0.3699]}, {"w": "this", "b": [0.6566, 0.3485, 0.6873, 0.3699]}, {"w": "book.5", "b": [0.6951, 0.3485, 0.7477, 0.3699]}, {"w": "The", "b": [0.7555, 0.3485, 0.7883, 0.3699]}, {"w": "general", "b": [0.7961, 0.3485, 0.8571, 0.3699]}, {"w": "problem", "b": [0.1428, 0.3676, 0.2139, 0.389]}, {"w": "formulation", "b": [0.2186, 0.3676, 0.3188, 0.389]}, {"w": "is", "b": [0.3236, 0.3676, 0.3368, 0.389]}, {"w": "given", "b": [0.3415, 0.3676, 0.3868, 0.389]}, {"w": "by", "b": [0.3915, 0.3676, 0.4116, 0.389]}, {"w": "Equation", "b": [0.4164, 0.3676, 0.4926, 0.389]}, {"w": "5-5.", "b": [0.4974, 0.3676, 0.5295, 0.389]}]}, {"id": "b_10", "type": "equation", "text": "Equation 5-5. Quadratic Programming problem", "words": [{"w": "Equation", "b": [0.1726, 0.4071, 0.2473, 0.4287]}, {"w": "5-5.", "b": [0.2521, 0.4071, 0.2838, 0.4287]}, {"w": "Quadratic", "b": [0.2886, 0.4071, 0.3716, 0.4287]}, {"w": "Programming", "b": [0.3763, 0.4071, 0.4879, 0.4287]}, {"w": "problem", "b": [0.4926, 0.4071, 0.5591, 0.4287]}]}, {"id": "b_11", "type": "paragraph", "text": "Minimize", "words": [{"w": "Minimize", "b": [0.1751, 0.4439, 0.2526, 0.4643]}]}, {"id": "b_13", "type": "equation", "text": "1 2pTHp + fTp", "words": [{"w": "1", "b": [0.2833, 0.4351, 0.2928, 0.4555]}, {"w": "2pTHp", "b": [0.2833, 0.44, 0.3426, 0.4731]}, {"w": "+", "b": [0.3668, 0.4439, 0.3783, 0.4643]}, {"w": "fTp", "b": [0.4026, 0.44, 0.4317, 0.4643]}]}, {"id": "b_14", "type": "paragraph", "text": "subject to Ap ≤b", "words": [{"w": "subject", "b": [0.1726, 0.4777, 0.2285, 0.4981]}, {"w": "to", "b": [0.2364, 0.4777, 0.2526, 0.4981]}, {"w": "Ap", "b": [0.2811, 0.4772, 0.306, 0.4981]}, {"w": "≤b", "b": [0.3115, 0.4772, 0.3391, 0.4981]}]}, {"id": "b_15", "type": "paragraph", "text": "where", "words": [{"w": "where", "b": [0.2161, 0.5543, 0.2645, 0.5747]}]}, {"id": "b_16", "type": "equation", "text": "p is an np‐dimensional vector (np = number of parameters),", "words": [{"w": "p", "b": [0.288, 0.4989, 0.2989, 0.5199]}, {"w": "is", "b": [0.3202, 0.4995, 0.3328, 0.5199]}, {"w": "an", "b": [0.3407, 0.4995, 0.3603, 0.5199]}, {"w": "np‐dimensional", "b": [0.3682, 0.4993, 0.4933, 0.5241]}, {"w": "vector", "b": [0.5012, 0.4995, 0.5508, 0.5199]}, {"w": "(np", "b": [0.5587, 0.4993, 0.5849, 0.5241]}, {"w": "=", "b": [0.5905, 0.4995, 0.602, 0.5199]}, {"w": "number", "b": [0.6075, 0.4995, 0.671, 0.5199]}, {"w": "of", "b": [0.6789, 0.4995, 0.6949, 0.5199]}, {"w": "parameters),", "b": [0.7045, 0.4995, 0.8049, 0.5199]}]}, {"id": "b_17", "type": "paragraph", "text": "H is an np × np matrix,", "words": [{"w": "H", "b": [0.288, 0.5252, 0.3035, 0.5461]}, {"w": "is", "b": [0.3202, 0.5257, 0.3328, 0.5461]}, {"w": "an", "b": [0.3407, 0.5257, 0.3603, 0.5461]}, {"w": "np", "b": [0.3682, 0.5256, 0.3876, 0.5504]}, {"w": "×", "b": [0.392, 0.5257, 0.4035, 0.5461]}, {"w": "np", "b": [0.4079, 0.5256, 0.4273, 0.5504]}, {"w": "matrix,", "b": [0.4352, 0.5257, 0.4928, 0.5461]}]}, {"id": "b_18", "type": "paragraph", "text": "f is an np‐dimensional vector,", "words": [{"w": "f", "b": [0.288, 0.5515, 0.2946, 0.5724]}, {"w": "is", "b": [0.3202, 0.552, 0.3328, 0.5724]}, {"w": "an", "b": [0.3407, 0.552, 0.3603, 0.5724]}, {"w": "np‐dimensional", "b": [0.3682, 0.5518, 0.4933, 0.5767]}, {"w": "vector,", "b": [0.5012, 0.552, 0.5553, 0.5724]}]}, {"id": "b_19", "type": "equation", "text": "A is an nc × np matrix (nc = number of constraints),", "words": [{"w": "A", "b": [0.288, 0.5778, 0.302, 0.5987]}, {"w": "is", "b": [0.3202, 0.5783, 0.3328, 0.5987]}, {"w": "an", "b": [0.3407, 0.5783, 0.3603, 0.5987]}, {"w": "nc", "b": [0.3682, 0.5781, 0.3848, 0.603]}, {"w": "×", "b": [0.3892, 0.5783, 0.4007, 0.5987]}, {"w": "np", "b": [0.4051, 0.5781, 0.4245, 0.603]}, {"w": "matrix", "b": [0.4325, 0.5783, 0.4855, 0.5987]}, {"w": "(nc", "b": [0.4934, 0.5781, 0.5169, 0.603]}, {"w": "=", "b": [0.5224, 0.5783, 0.534, 0.5987]}, {"w": "number", "b": [0.5395, 0.5783, 0.603, 0.5987]}, {"w": "of", "b": [0.6109, 0.5783, 0.6269, 0.5987]}, {"w": "constraints),", "b": [0.6365, 0.5783, 0.7362, 0.5987]}]}, {"id": "b_20", "type": "paragraph", "text": "b is an nc‐dimensional vector.", "words": [{"w": "b", "b": [0.288, 0.604, 0.2986, 0.625]}, {"w": "is", "b": [0.3202, 0.6046, 0.3328, 0.625]}, {"w": "an", "b": [0.3407, 0.6046, 0.3603, 0.625]}, {"w": "nc‐dimensional", "b": [0.3682, 0.6044, 0.4905, 0.6292]}, {"w": "vector.", "b": [0.4984, 0.6046, 0.5525, 0.625]}]}, {"id": "b_21", "type": "paragraph", "text": "Note that the expression A p ≤ b actually defines nc constraints: pT a(i) ≤ b(i) for i = 1, 2, ⋯, nc, where a(i) is the vector containing the elements of the ith row of A and b(i) is the ith element of b.", "words": [{"w": "Note", "b": [0.1429, 0.6483, 0.1836, 0.6697]}, {"w": "that", "b": [0.1893, 0.6483, 0.2219, 0.6697]}, {"w": "the", "b": [0.2276, 0.6483, 0.2539, 0.6697]}, {"w": "expression", "b": [0.2596, 0.6483, 0.3487, 0.6697]}, {"w": "A", "b": [0.3543, 0.6477, 0.369, 0.6697]}, {"w": "p", "b": [0.3747, 0.6477, 0.3861, 0.6697]}, {"w": "≤", "b": [0.3918, 0.6483, 0.4038, 0.6697]}, {"w": "b", "b": [0.4095, 0.6477, 0.4206, 0.6697]}, {"w": "actually", "b": [0.4263, 0.6483, 0.4909, 0.6697]}, {"w": "defines", "b": [0.4966, 0.6483, 0.5561, 0.6697]}, {"w": "nc", "b": [0.5618, 0.6481, 0.5776, 0.6706]}, {"w": "constraints:", "b": [0.5833, 0.6483, 0.6803, 0.6697]}, {"w": "pT", "b": [0.686, 0.6477, 0.7049, 0.6697]}, {"w": "a(i)", "b": [0.7106, 0.6477, 0.7321, 0.6697]}, {"w": "≤", "b": [0.7378, 0.6483, 0.7498, 0.6697]}, {"w": "b(i)", "b": [0.7555, 0.6481, 0.7774, 0.6697]}, {"w": "for", "b": [0.7831, 0.6483, 0.8076, 0.6697]}, {"w": "i", "b": [0.8133, 0.6481, 0.819, 0.6697]}, {"w": "=", "b": [0.8246, 0.6483, 0.8367, 0.6697]}, {"w": "1,", "b": [0.8424, 0.6483, 0.8571, 0.6697]}, {"w": "2,", "b": [0.1429, 0.6673, 0.1576, 0.6887]}, {"w": "⋯,", "b": [0.1634, 0.6673, 0.1889, 0.6887]}, {"w": "nc,", "b": [0.1947, 0.6671, 0.2153, 0.6896]}, {"w": "where", "b": [0.2211, 0.6673, 0.2719, 0.6887]}, {"w": "a(i)", "b": [0.2777, 0.6668, 0.2992, 0.6887]}, {"w": "is", "b": [0.305, 0.6673, 0.3182, 0.6887]}, {"w": "the", "b": [0.324, 0.6673, 0.3503, 0.6887]}, {"w": "vector", "b": [0.356, 0.6673, 0.4081, 0.6887]}, {"w": "containing", "b": [0.4138, 0.6673, 0.5035, 0.6887]}, {"w": "the", "b": [0.5092, 0.6673, 0.5356, 0.6887]}, {"w": "elements", "b": [0.5413, 0.6673, 0.6152, 0.6887]}, {"w": "of", "b": [0.621, 0.6673, 0.6378, 0.6887]}, {"w": "the", "b": [0.6436, 0.6673, 0.6699, 0.6887]}, {"w": "ith", "b": [0.6757, 0.6673, 0.6917, 0.6887]}, {"w": "row", "b": [0.6975, 0.6673, 0.7301, 0.6887]}, {"w": "of", "b": [0.7359, 0.6673, 0.7527, 0.6887]}, {"w": "A", "b": [0.7584, 0.6668, 0.7731, 0.6887]}, {"w": "and", "b": [0.7789, 0.6673, 0.8105, 0.6887]}, {"w": "b(i)", "b": [0.8162, 0.6671, 0.8381, 0.6887]}, {"w": "is", "b": [0.8439, 0.6673, 0.8571, 0.6887]}, {"w": "the", "b": [0.1429, 0.6864, 0.1692, 0.7078]}, {"w": "ith", "b": [0.1739, 0.6864, 0.19, 0.7078]}, {"w": "element", "b": [0.1947, 0.6864, 0.261, 0.7078]}, {"w": "of", "b": [0.2657, 0.6864, 0.2825, 0.7078]}, {"w": "b.", "b": [0.2872, 0.6858, 0.3031, 0.7078]}]}, {"id": "b_22", "type": "paragraph", "text": "You can easily verify that if you set the QP parameters in the following way, you get the hard margin linear SVM classifier objective:", "words": [{"w": "You", "b": [0.1429, 0.7145, 0.1752, 0.7359]}, {"w": "can", "b": [0.1814, 0.7145, 0.2107, 0.7359]}, {"w": "easily", "b": [0.2169, 0.7145, 0.263, 0.7359]}, {"w": "verify", "b": [0.2692, 0.7145, 0.3171, 0.7359]}, {"w": "that", "b": [0.3232, 0.7145, 0.3558, 0.7359]}, {"w": "if", "b": [0.362, 0.7145, 0.3738, 0.7359]}, {"w": "you", "b": [0.3799, 0.7145, 0.4112, 0.7359]}, {"w": "set", "b": [0.4174, 0.7145, 0.4402, 0.7359]}, {"w": "the", "b": [0.4464, 0.7145, 0.4727, 0.7359]}, {"w": "QP", "b": [0.4789, 0.7145, 0.5062, 0.7359]}, {"w": "parameters", "b": [0.5123, 0.7145, 0.6058, 0.7359]}, {"w": "in", "b": [0.6119, 0.7145, 0.6289, 0.7359]}, {"w": "the", "b": [0.6351, 0.7145, 0.6614, 0.7359]}, {"w": "following", "b": [0.6676, 0.7145, 0.7466, 0.7359]}, {"w": "way,", "b": [0.7527, 0.7145, 0.7886, 0.7359]}, {"w": "you", "b": [0.7948, 0.7145, 0.826, 0.7359]}, {"w": "get", "b": [0.8322, 0.7145, 0.8571, 0.7359]}, {"w": "the", "b": [0.1429, 0.7335, 0.1692, 0.755]}, {"w": "hard", "b": [0.1739, 0.7335, 0.2129, 0.755]}, {"w": "margin", "b": [0.2176, 0.7335, 0.2783, 0.755]}, {"w": "linear", "b": [0.283, 0.7335, 0.331, 0.755]}, {"w": "SVM", "b": [0.3358, 0.7335, 0.3788, 0.755]}, {"w": "classifier", "b": [0.3836, 0.7335, 0.456, 0.755]}, {"w": "objective:", "b": [0.4607, 0.7335, 0.5401, 0.755]}]}, {"id": "b_23", "type": "equation", "text": "• np = n + 1, where n is the number of features (the +1 is for the bias term).", "words": [{"w": "•", "b": [0.16, 0.7677, 0.1682, 0.7891]}, {"w": "np", "b": [0.1786, 0.7675, 0.1957, 0.79]}, {"w": "=", "b": [0.2005, 0.7677, 0.2125, 0.7891]}, {"w": "n", "b": [0.2173, 0.7675, 0.2283, 0.7891]}, {"w": "+", "b": [0.2331, 0.7677, 0.2452, 0.7891]}, {"w": "1,", "b": [0.2499, 0.7677, 0.2646, 0.7891]}, {"w": "where", "b": [0.2694, 0.7677, 0.3202, 0.7891]}, {"w": "n", "b": [0.3249, 0.7675, 0.336, 0.7891]}, {"w": "is", "b": [0.3407, 0.7677, 0.354, 0.7891]}, {"w": "the", "b": [0.3587, 0.7677, 0.385, 0.7891]}, {"w": "number", "b": [0.3898, 0.7677, 0.4561, 0.7891]}, {"w": "of", "b": [0.4608, 0.7677, 0.4776, 0.7891]}, {"w": "features", "b": [0.4823, 0.7677, 0.5477, 0.7891]}, {"w": "(the", "b": [0.5525, 0.7677, 0.586, 0.7891]}, {"w": "+1", "b": [0.5907, 0.7677, 0.6128, 0.7891]}, {"w": "is", "b": [0.6175, 0.7677, 0.6308, 0.7891]}, {"w": "for", "b": [0.6355, 0.7677, 0.66, 0.7891]}, {"w": "the", "b": [0.6647, 0.7677, 0.6911, 0.7891]}, {"w": "bias", "b": [0.6958, 0.7677, 0.7288, 0.7891]}, {"w": "term).", "b": [0.7335, 0.7677, 0.7855, 0.7891]}]}, {"id": "b_24", "type": "paragraph", "text": "Under the Hood | 169", "words": [{"w": "Under", "b": [0.7034, 0.9225, 0.7393, 0.9388]}, {"w": "the", "b": [0.7421, 0.9225, 0.762, 0.9388]}, {"w": "Hood", "b": [0.7648, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "169", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 196, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 The objective function is convex, and the inequality constraints are continuously differentiable and convex functions.", "words": [{"w": "6", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "The", "b": [0.1587, 0.8598, 0.1837, 0.8761]}, {"w": "objective", "b": [0.1873, 0.8598, 0.2442, 0.8761]}, {"w": "function", "b": [0.2478, 0.8598, 0.3022, 0.8761]}, {"w": "is", "b": [0.3058, 0.8598, 0.3159, 0.8761]}, {"w": "convex,", "b": [0.3195, 0.8598, 0.3678, 0.8761]}, {"w": "and", "b": [0.3714, 0.8598, 0.3955, 0.8761]}, {"w": "the", "b": [0.3991, 0.8598, 0.4191, 0.8761]}, {"w": "inequality", "b": [0.4227, 0.8598, 0.4863, 0.8761]}, {"w": "constraints", "b": [0.4899, 0.8598, 0.5603, 0.8761]}, {"w": "are", "b": [0.5639, 0.8598, 0.5835, 0.8761]}, {"w": "continuously", "b": [0.5871, 0.8598, 0.6698, 0.8761]}, {"w": "differentiable", "b": [0.6734, 0.8598, 0.7581, 0.8761]}, {"w": "and", "b": [0.7617, 0.8598, 0.7857, 0.8761]}, {"w": "convex", "b": [0.7893, 0.8598, 0.834, 0.8761]}, {"w": "functions.", "b": [0.1587, 0.8749, 0.2226, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "• nc = m, where m is the number of training instances.", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "nc", "b": [0.1786, 0.0789, 0.1944, 0.1014]}, {"w": "=", "b": [0.1992, 0.0791, 0.2112, 0.1005]}, {"w": "m,", "b": [0.216, 0.0789, 0.2371, 0.1005]}, {"w": "where", "b": [0.2418, 0.0791, 0.2927, 0.1005]}, {"w": "m", "b": [0.2974, 0.0789, 0.3138, 0.1005]}, {"w": "is", "b": [0.3185, 0.0791, 0.3318, 0.1005]}, {"w": "the", "b": [0.3365, 0.0791, 0.3628, 0.1005]}, {"w": "number", "b": [0.3675, 0.0791, 0.4338, 0.1005]}, {"w": "of", "b": [0.4386, 0.0791, 0.4554, 0.1005]}, {"w": "training", "b": [0.4601, 0.0791, 0.527, 0.1005]}, {"w": "instances.", "b": [0.5318, 0.0791, 0.6133, 0.1005]}]}, {"id": "b_2", "type": "paragraph", "text": "• H is the np × np identity matrix, except with a zero in the top-left cell (to ignore the bias term).", "words": [{"w": "•", "b": [0.16, 0.1042, 0.1682, 0.1256]}, {"w": "H", "b": [0.1786, 0.1036, 0.1949, 0.1256]}, {"w": "is", "b": [0.201, 0.1042, 0.2142, 0.1256]}, {"w": "the", "b": [0.2204, 0.1042, 0.2467, 0.1256]}, {"w": "np", "b": [0.2528, 0.1039, 0.27, 0.1265]}, {"w": "×", "b": [0.2761, 0.1042, 0.2882, 0.1256]}, {"w": "np", "b": [0.2944, 0.1039, 0.3115, 0.1265]}, {"w": "identity", "b": [0.3176, 0.1042, 0.3819, 0.1256]}, {"w": "matrix,", "b": [0.3881, 0.1042, 0.4481, 0.1256]}, {"w": "except", "b": [0.4543, 0.1042, 0.5079, 0.1256]}, {"w": "with", "b": [0.514, 0.1042, 0.5514, 0.1256]}, {"w": "a", "b": [0.5575, 0.1042, 0.5666, 0.1256]}, {"w": "zero", "b": [0.5728, 0.1042, 0.6087, 0.1256]}, {"w": "in", "b": [0.6149, 0.1042, 0.6318, 0.1256]}, {"w": "the", "b": [0.638, 0.1042, 0.6643, 0.1256]}, {"w": "top-left", "b": [0.6704, 0.1042, 0.7324, 0.1256]}, {"w": "cell", "b": [0.7385, 0.1042, 0.7667, 0.1256]}, {"w": "(to", "b": [0.7729, 0.1042, 0.7971, 0.1256]}, {"w": "ignore", "b": [0.8032, 0.1042, 0.8571, 0.1256]}, {"w": "the", "b": [0.1786, 0.1232, 0.2049, 0.1446]}, {"w": "bias", "b": [0.2096, 0.1232, 0.2426, 0.1446]}, {"w": "term).", "b": [0.2473, 0.1232, 0.2993, 0.1446]}]}, {"id": "b_3", "type": "equation", "text": "• f = 0, an np-dimensional vector full of 0s.", "words": [{"w": "•", "b": [0.16, 0.1483, 0.1682, 0.1697]}, {"w": "f", "b": [0.1786, 0.1477, 0.1855, 0.1697]}, {"w": "=", "b": [0.1902, 0.1483, 0.2023, 0.1697]}, {"w": "0,", "b": [0.207, 0.1477, 0.2222, 0.1697]}, {"w": "an", "b": [0.2269, 0.1483, 0.2474, 0.1697]}, {"w": "np-dimensional", "b": [0.2522, 0.1481, 0.3803, 0.1706]}, {"w": "vector", "b": [0.385, 0.1483, 0.4371, 0.1697]}, {"w": "full", "b": [0.4418, 0.1483, 0.4696, 0.1697]}, {"w": "of", "b": [0.4743, 0.1483, 0.4911, 0.1697]}, {"w": "0s.", "b": [0.4958, 0.1483, 0.5182, 0.1697]}]}, {"id": "b_4", "type": "equation", "text": "• b = –1, an nc-dimensional vector full of –1s.", "words": [{"w": "•", "b": [0.16, 0.1734, 0.1681, 0.1948]}, {"w": "b", "b": [0.1786, 0.1728, 0.1897, 0.1948]}, {"w": "=", "b": [0.1944, 0.1734, 0.2065, 0.1948]}, {"w": "–1,", "b": [0.2112, 0.1728, 0.237, 0.1948]}, {"w": "an", "b": [0.2418, 0.1734, 0.2623, 0.1948]}, {"w": "nc-dimensional", "b": [0.267, 0.1732, 0.3939, 0.1957]}, {"w": "vector", "b": [0.3986, 0.1734, 0.4506, 0.1948]}, {"w": "full", "b": [0.4554, 0.1734, 0.4831, 0.1948]}, {"w": "of", "b": [0.4879, 0.1734, 0.5047, 0.1948]}, {"w": "–1s.", "b": [0.5094, 0.1734, 0.5426, 0.1948]}]}, {"id": "b_5", "type": "paragraph", "text": "• a(i) = –t(i) x˙ (i), where x˙ (i) is equal to x(i) with an extra bias feature x˙ 0 = 1.", "words": [{"w": "•", "b": [0.16, 0.1985, 0.1682, 0.2199]}, {"w": "a(i)", "b": [0.1786, 0.1979, 0.2001, 0.2199]}, {"w": "=", "b": [0.2048, 0.1985, 0.2169, 0.2199]}, {"w": "–t(i)", "b": [0.2216, 0.1983, 0.2506, 0.2199]}, {"w": "x˙", "b": [0.2554, 0.1977, 0.2654, 0.2199]}, {"w": "(i),", "b": [0.2703, 0.1985, 0.2868, 0.2199]}, {"w": "where", "b": [0.2915, 0.1985, 0.3424, 0.2199]}, {"w": "x˙", "b": [0.3471, 0.1977, 0.3572, 0.2199]}, {"w": "(i)", "b": [0.362, 0.1994, 0.3738, 0.2123]}, {"w": "is", "b": [0.3785, 0.1985, 0.3918, 0.2199]}, {"w": "equal", "b": [0.3965, 0.1985, 0.4415, 0.2199]}, {"w": "to", "b": [0.4462, 0.1985, 0.4632, 0.2199]}, {"w": "x(i)", "b": [0.4679, 0.1979, 0.4898, 0.2199]}, {"w": "with", "b": [0.4945, 0.1985, 0.5318, 0.2199]}, {"w": "an", "b": [0.5365, 0.1985, 0.5571, 0.2199]}, {"w": "extra", "b": [0.5618, 0.1985, 0.6037, 0.2199]}, {"w": "bias", "b": [0.6085, 0.1985, 0.6414, 0.2199]}, {"w": "feature", "b": [0.6461, 0.1985, 0.7039, 0.2199]}, {"w": "x˙", "b": [0.7087, 0.1977, 0.7187, 0.2199]}, {"w": "0", "b": [0.7236, 0.2079, 0.7296, 0.2208]}, {"w": "=", "b": [0.7343, 0.1985, 0.7464, 0.2199]}, {"w": "1.", "b": [0.7511, 0.1985, 0.7658, 0.2199]}]}, {"id": "b_6", "type": "paragraph", "text": "So one way to train a hard margin linear SVM classifier is just to use an off-the-shelf QP solver by passing it the preceding parameters. The resulting vector p will contain the bias term b = p0 and the feature weights wi = pi for i = 1, 2, ⋯, n. Similarly, you can use a QP solver to solve the soft margin problem (see the exercises at the end of the chapter).", "words": [{"w": "So", "b": [0.1428, 0.2327, 0.1633, 0.2541]}, {"w": "one", "b": [0.1689, 0.2327, 0.1998, 0.2541]}, {"w": "way", "b": [0.2053, 0.2327, 0.2379, 0.2541]}, {"w": "to", "b": [0.2435, 0.2327, 0.2605, 0.2541]}, {"w": "train", "b": [0.266, 0.2327, 0.3062, 0.2541]}, {"w": "a", "b": [0.3118, 0.2327, 0.3209, 0.2541]}, {"w": "hard", "b": [0.3265, 0.2327, 0.3655, 0.2541]}, {"w": "margin", "b": [0.3711, 0.2327, 0.4317, 0.2541]}, {"w": "linear", "b": [0.4373, 0.2327, 0.4853, 0.2541]}, {"w": "SVM", "b": [0.4908, 0.2327, 0.5339, 0.2541]}, {"w": "classifier", "b": [0.5395, 0.2327, 0.6119, 0.2541]}, {"w": "is", "b": [0.6175, 0.2327, 0.6307, 0.2541]}, {"w": "just", "b": [0.6362, 0.2327, 0.6666, 0.2541]}, {"w": "to", "b": [0.6722, 0.2327, 0.6892, 0.2541]}, {"w": "use", "b": [0.6947, 0.2327, 0.7223, 0.2541]}, {"w": "an", "b": [0.7278, 0.2327, 0.7484, 0.2541]}, {"w": "off-the-shelf", "b": [0.7539, 0.2327, 0.8571, 0.2541]}, {"w": "QP", "b": [0.1429, 0.2517, 0.1701, 0.2731]}, {"w": "solver", "b": [0.1757, 0.2517, 0.2255, 0.2731]}, {"w": "by", "b": [0.231, 0.2517, 0.2512, 0.2731]}, {"w": "passing", "b": [0.2568, 0.2517, 0.3188, 0.2731]}, {"w": "it", "b": [0.3244, 0.2517, 0.3364, 0.2731]}, {"w": "the", "b": [0.3419, 0.2517, 0.3683, 0.2731]}, {"w": "preceding", "b": [0.3738, 0.2517, 0.4567, 0.2731]}, {"w": "parameters.", "b": [0.4623, 0.2517, 0.5605, 0.2731]}, {"w": "The", "b": [0.5661, 0.2517, 0.5989, 0.2731]}, {"w": "resulting", "b": [0.6045, 0.2517, 0.6781, 0.2731]}, {"w": "vector", "b": [0.6837, 0.2517, 0.7357, 0.2731]}, {"w": "p", "b": [0.7413, 0.2511, 0.7527, 0.2731]}, {"w": "will", "b": [0.7583, 0.2517, 0.7887, 0.2731]}, {"w": "contain", "b": [0.7942, 0.2517, 0.8572, 0.2731]}, {"w": "the", "b": [0.1429, 0.2707, 0.1692, 0.2922]}, {"w": "bias", "b": [0.1755, 0.2707, 0.2084, 0.2922]}, {"w": "term", "b": [0.2147, 0.2707, 0.2547, 0.2922]}, {"w": "b", "b": [0.261, 0.2705, 0.2711, 0.2922]}, {"w": "=", "b": [0.2774, 0.2707, 0.2895, 0.2922]}, {"w": "p0", "b": [0.2958, 0.2705, 0.3119, 0.293]}, {"w": "and", "b": [0.3182, 0.2707, 0.3498, 0.2922]}, {"w": "the", "b": [0.356, 0.2707, 0.3824, 0.2922]}, {"w": "feature", "b": [0.3887, 0.2707, 0.4464, 0.2922]}, {"w": "weights", "b": [0.4527, 0.2707, 0.5159, 0.2922]}, {"w": "wi", "b": [0.5222, 0.2705, 0.5396, 0.293]}, {"w": "=", "b": [0.5459, 0.2707, 0.5579, 0.2922]}, {"w": "pi", "b": [0.5642, 0.2705, 0.5778, 0.293]}, {"w": "for", "b": [0.5841, 0.2707, 0.6086, 0.2922]}, {"w": "i", "b": [0.6149, 0.2705, 0.6206, 0.2922]}, {"w": "=", "b": [0.6268, 0.2707, 0.6389, 0.2922]}, {"w": "1,", "b": [0.6452, 0.2707, 0.66, 0.2922]}, {"w": "2,", "b": [0.6663, 0.2707, 0.681, 0.2922]}, {"w": "⋯,", "b": [0.6873, 0.2707, 0.7129, 0.2922]}, {"w": "n.", "b": [0.7192, 0.2705, 0.735, 0.2922]}, {"w": "Similarly,", "b": [0.7413, 0.2707, 0.8196, 0.2922]}, {"w": "you", "b": [0.8259, 0.2707, 0.8571, 0.2922]}, {"w": "can", "b": [0.1429, 0.2898, 0.1722, 0.3112]}, {"w": "use", "b": [0.1782, 0.2898, 0.2057, 0.3112]}, {"w": "a", "b": [0.2117, 0.2898, 0.2208, 0.3112]}, {"w": "QP", "b": [0.2268, 0.2898, 0.254, 0.3112]}, {"w": "solver", "b": [0.26, 0.2898, 0.3097, 0.3112]}, {"w": "to", "b": [0.3157, 0.2898, 0.3327, 0.3112]}, {"w": "solve", "b": [0.3386, 0.2898, 0.3807, 0.3112]}, {"w": "the", "b": [0.3866, 0.2898, 0.4129, 0.3112]}, {"w": "soft", "b": [0.4189, 0.2898, 0.4497, 0.3112]}, {"w": "margin", "b": [0.4556, 0.2898, 0.5163, 0.3112]}, {"w": "problem", "b": [0.5223, 0.2898, 0.5933, 0.3112]}, {"w": "(see", "b": [0.5992, 0.2898, 0.6318, 0.3112]}, {"w": "the", "b": [0.6378, 0.2898, 0.6641, 0.3112]}, {"w": "exercises", "b": [0.67, 0.2898, 0.7439, 0.3112]}, {"w": "at", "b": [0.7498, 0.2898, 0.7649, 0.3112]}, {"w": "the", "b": [0.7709, 0.2898, 0.7972, 0.3112]}, {"w": "end", "b": [0.8031, 0.2898, 0.8344, 0.3112]}, {"w": "of", "b": [0.8403, 0.2898, 0.8571, 0.3112]}, {"w": "the", "b": [0.1429, 0.3088, 0.1692, 0.3303]}, {"w": "chapter).", "b": [0.1739, 0.3088, 0.2484, 0.3303]}]}, {"id": "b_7", "type": "paragraph", "text": "However, to use the kernel trick we are going to look at a different constrained opti‐ mization problem.", "words": [{"w": "However,", "b": [0.1429, 0.337, 0.2217, 0.3584]}, {"w": "to", "b": [0.2276, 0.337, 0.2446, 0.3584]}, {"w": "use", "b": [0.2505, 0.337, 0.278, 0.3584]}, {"w": "the", "b": [0.2839, 0.337, 0.3102, 0.3584]}, {"w": "kernel", "b": [0.3161, 0.337, 0.3685, 0.3584]}, {"w": "trick", "b": [0.3744, 0.337, 0.4132, 0.3584]}, {"w": "we", "b": [0.4191, 0.337, 0.4422, 0.3584]}, {"w": "are", "b": [0.4481, 0.337, 0.4738, 0.3584]}, {"w": "going", "b": [0.4797, 0.337, 0.5268, 0.3584]}, {"w": "to", "b": [0.5327, 0.337, 0.5497, 0.3584]}, {"w": "look", "b": [0.5555, 0.337, 0.5924, 0.3584]}, {"w": "at", "b": [0.5983, 0.337, 0.6134, 0.3584]}, {"w": "a", "b": [0.6192, 0.337, 0.6284, 0.3584]}, {"w": "different", "b": [0.6343, 0.337, 0.706, 0.3584]}, {"w": "constrained", "b": [0.7118, 0.337, 0.8104, 0.3584]}, {"w": "opti‐", "b": [0.8163, 0.337, 0.8572, 0.3584]}, {"w": "mization", "b": [0.1429, 0.356, 0.217, 0.3774]}, {"w": "problem.", "b": [0.2217, 0.356, 0.2975, 0.3774]}]}, {"id": "b_8", "type": "paragraph", "text": "The Dual Problem", "words": [{"w": "The", "b": [0.1429, 0.3902, 0.1805, 0.4188]}, {"w": "Dual", "b": [0.1855, 0.3902, 0.2325, 0.4188]}, {"w": "Problem", "b": [0.2375, 0.3902, 0.325, 0.4188]}]}, {"id": "b_9", "type": "paragraph", "text": "Given a constrained optimization problem, known as the primal problem, it is possi‐ ble to express a different but closely related problem, called its dual problem. The sol‐ ution to the dual problem typically gives a lower bound to the solution of the primal problem, but under some conditions it can even have the same solutions as the pri‐ mal problem. Luckily, the SVM problem happens to meet these conditions,6 so you can choose to solve the primal problem or the dual problem; both will have the same solution. Equation 5-6 shows the dual form of the linear SVM objective (if you are interested in knowing how to derive the dual problem from the primal problem, see ???).", "words": [{"w": "Given", "b": [0.1429, 0.4247, 0.1932, 0.4461]}, {"w": "a", "b": [0.1991, 0.4247, 0.2083, 0.4461]}, {"w": "constrained", "b": [0.2142, 0.4247, 0.3127, 0.4461]}, {"w": "optimization", "b": [0.3187, 0.4247, 0.4262, 0.4461]}, {"w": "problem,", "b": [0.4321, 0.4247, 0.5079, 0.4461]}, {"w": "known", "b": [0.5138, 0.4247, 0.5719, 0.4461]}, {"w": "as", "b": [0.5778, 0.4247, 0.5946, 0.4461]}, {"w": "the", "b": [0.6005, 0.4247, 0.6268, 0.4461]}, {"w": "primal", "b": [0.6327, 0.4244, 0.6873, 0.4461]}, {"w": "problem,", "b": [0.6932, 0.4244, 0.7644, 0.4461]}, {"w": "it", "b": [0.7703, 0.4247, 0.7823, 0.4461]}, {"w": "is", "b": [0.7882, 0.4247, 0.8014, 0.4461]}, {"w": "possi‐", "b": [0.8073, 0.4247, 0.8571, 0.4461]}, {"w": "ble", "b": [0.1428, 0.4437, 0.1676, 0.4651]}, {"w": "to", "b": [0.1729, 0.4437, 0.1898, 0.4651]}, {"w": "express", "b": [0.1951, 0.4437, 0.2566, 0.4651]}, {"w": "a", "b": [0.2619, 0.4437, 0.2711, 0.4651]}, {"w": "different", "b": [0.2764, 0.4437, 0.3481, 0.4651]}, {"w": "but", "b": [0.3534, 0.4437, 0.3814, 0.4651]}, {"w": "closely", "b": [0.3867, 0.4437, 0.4427, 0.4651]}, {"w": "related", "b": [0.448, 0.4437, 0.5048, 0.4651]}, {"w": "problem,", "b": [0.5101, 0.4437, 0.5859, 0.4651]}, {"w": "called", "b": [0.5912, 0.4437, 0.6396, 0.4651]}, {"w": "its", "b": [0.6449, 0.4437, 0.6644, 0.4651]}, {"w": "dual", "b": [0.6698, 0.4435, 0.7063, 0.4651]}, {"w": "problem.", "b": [0.711, 0.4435, 0.7828, 0.4651]}, {"w": "The", "b": [0.7881, 0.4437, 0.8209, 0.4651]}, {"w": "sol‐", "b": [0.8262, 0.4437, 0.8571, 0.4651]}, {"w": "ution", "b": [0.1428, 0.4627, 0.1879, 0.4842]}, {"w": "to", "b": [0.1936, 0.4627, 0.2105, 0.4842]}, {"w": "the", "b": [0.2162, 0.4627, 0.2425, 0.4842]}, {"w": "dual", "b": [0.2482, 0.4627, 0.2847, 0.4842]}, {"w": "problem", "b": [0.2904, 0.4627, 0.3614, 0.4842]}, {"w": "typically", "b": [0.3671, 0.4627, 0.4376, 0.4842]}, {"w": "gives", "b": [0.4433, 0.4627, 0.4847, 0.4842]}, {"w": "a", "b": [0.4904, 0.4627, 0.4996, 0.4842]}, {"w": "lower", "b": [0.5052, 0.4627, 0.552, 0.4842]}, {"w": "bound", "b": [0.5577, 0.4627, 0.6123, 0.4842]}, {"w": "to", "b": [0.618, 0.4627, 0.635, 0.4842]}, {"w": "the", "b": [0.6407, 0.4627, 0.667, 0.4842]}, {"w": "solution", "b": [0.6727, 0.4627, 0.7413, 0.4842]}, {"w": "of", "b": [0.7469, 0.4627, 0.7637, 0.4842]}, {"w": "the", "b": [0.7694, 0.4627, 0.7957, 0.4842]}, {"w": "primal", "b": [0.8014, 0.4627, 0.8571, 0.4842]}, {"w": "problem,", "b": [0.1429, 0.4818, 0.2187, 0.5032]}, {"w": "but", "b": [0.225, 0.4818, 0.253, 0.5032]}, {"w": "under", "b": [0.2593, 0.4818, 0.3094, 0.5032]}, {"w": "some", "b": [0.3157, 0.4818, 0.3599, 0.5032]}, {"w": "conditions", "b": [0.3663, 0.4818, 0.4553, 0.5032]}, {"w": "it", "b": [0.4616, 0.4818, 0.4736, 0.5032]}, {"w": "can", "b": [0.4799, 0.4818, 0.5092, 0.5032]}, {"w": "even", "b": [0.5156, 0.4818, 0.5543, 0.5032]}, {"w": "have", "b": [0.5607, 0.4818, 0.5991, 0.5032]}, {"w": "the", "b": [0.6054, 0.4818, 0.6318, 0.5032]}, {"w": "same", "b": [0.6381, 0.4818, 0.6808, 0.5032]}, {"w": "solutions", "b": [0.6871, 0.4818, 0.7634, 0.5032]}, {"w": "as", "b": [0.7697, 0.4818, 0.7865, 0.5032]}, {"w": "the", "b": [0.7928, 0.4818, 0.8192, 0.5032]}, {"w": "pri‐", "b": [0.8255, 0.4818, 0.8572, 0.5032]}, {"w": "mal", "b": [0.1429, 0.5008, 0.1743, 0.5223]}, {"w": "problem.", "b": [0.1812, 0.5008, 0.257, 0.5223]}, {"w": "Luckily,", "b": [0.2639, 0.5008, 0.3285, 0.5223]}, {"w": "the", "b": [0.3354, 0.5008, 0.3617, 0.5223]}, {"w": "SVM", "b": [0.3685, 0.5008, 0.4116, 0.5223]}, {"w": "problem", "b": [0.4185, 0.5008, 0.4895, 0.5223]}, {"w": "happens", "b": [0.4964, 0.5008, 0.566, 0.5223]}, {"w": "to", "b": [0.5729, 0.5008, 0.5899, 0.5223]}, {"w": "meet", "b": [0.5967, 0.5008, 0.6378, 0.5223]}, {"w": "these", "b": [0.6447, 0.5008, 0.6875, 0.5223]}, {"w": "conditions,6", "b": [0.6944, 0.5008, 0.7939, 0.5223]}, {"w": "so", "b": [0.8008, 0.5008, 0.819, 0.5223]}, {"w": "you", "b": [0.8259, 0.5008, 0.8571, 0.5223]}, {"w": "can", "b": [0.1429, 0.5199, 0.1722, 0.5413]}, {"w": "choose", "b": [0.1777, 0.5199, 0.2353, 0.5413]}, {"w": "to", "b": [0.2408, 0.5199, 0.2578, 0.5413]}, {"w": "solve", "b": [0.2632, 0.5199, 0.3052, 0.5413]}, {"w": "the", "b": [0.3107, 0.5199, 0.337, 0.5413]}, {"w": "primal", "b": [0.3425, 0.5199, 0.3982, 0.5413]}, {"w": "problem", "b": [0.4036, 0.5199, 0.4747, 0.5413]}, {"w": "or", "b": [0.4801, 0.5199, 0.4985, 0.5413]}, {"w": "the", "b": [0.5039, 0.5199, 0.5302, 0.5413]}, {"w": "dual", "b": [0.5357, 0.5199, 0.5722, 0.5413]}, {"w": "problem;", "b": [0.5776, 0.5199, 0.6534, 0.5413]}, {"w": "both", "b": [0.6588, 0.5199, 0.6975, 0.5413]}, {"w": "will", "b": [0.703, 0.5199, 0.7334, 0.5413]}, {"w": "have", "b": [0.7388, 0.5199, 0.7772, 0.5413]}, {"w": "the", "b": [0.7827, 0.5199, 0.809, 0.5413]}, {"w": "same", "b": [0.8144, 0.5199, 0.8571, 0.5413]}, {"w": "solution.", "b": [0.1429, 0.5389, 0.2162, 0.5604]}, {"w": "Equation", "b": [0.2231, 0.5389, 0.2993, 0.5604]}, {"w": "5-6", "b": [0.3063, 0.5389, 0.3337, 0.5604]}, {"w": "shows", "b": [0.3406, 0.5389, 0.3919, 0.5604]}, {"w": "the", "b": [0.3988, 0.5389, 0.4252, 0.5604]}, {"w": "dual", "b": [0.4321, 0.5389, 0.4686, 0.5604]}, {"w": "form", "b": [0.4755, 0.5389, 0.5171, 0.5604]}, {"w": "of", "b": [0.524, 0.5389, 0.5408, 0.5604]}, {"w": "the", "b": [0.5477, 0.5389, 0.574, 0.5604]}, {"w": "linear", "b": [0.5809, 0.5389, 0.6289, 0.5604]}, {"w": "SVM", "b": [0.6358, 0.5389, 0.6789, 0.5604]}, {"w": "objective", "b": [0.6858, 0.5389, 0.7605, 0.5604]}, {"w": "(if", "b": [0.7674, 0.5389, 0.7863, 0.5604]}, {"w": "you", "b": [0.7933, 0.5389, 0.8245, 0.5604]}, {"w": "are", "b": [0.8314, 0.5389, 0.8572, 0.5604]}, {"w": "interested", "b": [0.1429, 0.558, 0.2251, 0.5794]}, {"w": "in", "b": [0.2337, 0.558, 0.2507, 0.5794]}, {"w": "knowing", "b": [0.2594, 0.558, 0.3327, 0.5794]}, {"w": "how", "b": [0.3414, 0.558, 0.3774, 0.5794]}, {"w": "to", "b": [0.386, 0.558, 0.403, 0.5794]}, {"w": "derive", "b": [0.4117, 0.558, 0.4633, 0.5794]}, {"w": "the", "b": [0.472, 0.558, 0.4983, 0.5794]}, {"w": "dual", "b": [0.507, 0.558, 0.5434, 0.5794]}, {"w": "problem", "b": [0.5521, 0.558, 0.6231, 0.5794]}, {"w": "from", "b": [0.6318, 0.558, 0.6734, 0.5794]}, {"w": "the", "b": [0.682, 0.558, 0.7083, 0.5794]}, {"w": "primal", "b": [0.717, 0.558, 0.7727, 0.5794]}, {"w": "problem,", "b": [0.7814, 0.558, 0.8571, 0.5794]}, {"w": "see", "b": [0.1429, 0.577, 0.1682, 0.5984]}, {"w": "???).", "b": [0.1729, 0.577, 0.2086, 0.5984]}]}, {"id": "b_10", "type": "equation", "text": "Equation 5-6. Dual form of the linear SVM objective", "words": [{"w": "Equation", "b": [0.1726, 0.6166, 0.2473, 0.6382]}, {"w": "5-6.", "b": [0.2521, 0.6166, 0.2838, 0.6382]}, {"w": "Dual", "b": [0.2886, 0.6166, 0.3296, 0.6382]}, {"w": "form", "b": [0.3344, 0.6166, 0.3736, 0.6382]}, {"w": "of", "b": [0.3784, 0.6166, 0.3936, 0.6382]}, {"w": "the", "b": [0.3983, 0.6166, 0.4234, 0.6382]}, {"w": "linear", "b": [0.4281, 0.6166, 0.4751, 0.6382]}, {"w": "SVM", "b": [0.4799, 0.6166, 0.522, 0.6382]}, {"w": "objective", "b": [0.5267, 0.6166, 0.5971, 0.6382]}]}, {"id": "b_11", "type": "paragraph", "text": "minimize α", "words": [{"w": "minimize", "b": [0.1726, 0.6582, 0.2487, 0.6786]}, {"w": "α", "b": [0.2064, 0.67, 0.2149, 0.6864]}]}, {"id": "b_12", "type": "equation", "text": "1 2 ∑ i = 1", "words": [{"w": "1", "b": [0.2564, 0.6493, 0.2659, 0.6697]}, {"w": "2", "b": [0.2564, 0.667, 0.2659, 0.6874]}, {"w": "∑", "b": [0.2767, 0.6534, 0.2917, 0.6822]}, {"w": "i", "b": [0.2692, 0.6729, 0.2736, 0.6893]}, {"w": "=", "b": [0.278, 0.673, 0.2872, 0.6893]}, {"w": "1", "b": [0.2916, 0.673, 0.2992, 0.6893]}]}, {"id": "b_14", "type": "equation", "text": "∑ j = 1", "words": [{"w": "∑", "b": [0.3108, 0.6534, 0.3258, 0.6822]}, {"w": "j", "b": [0.3041, 0.6729, 0.3084, 0.6893]}, {"w": "=", "b": [0.3128, 0.673, 0.322, 0.6893]}, {"w": "1", "b": [0.3264, 0.673, 0.334, 0.6893]}]}, {"id": "b_16", "type": "equation", "text": "α i α j t i t j x i Tx j − ∑ i = 1", "words": [{"w": "α", "b": [0.3362, 0.658, 0.3468, 0.6786]}, {"w": "i", "b": [0.3523, 0.6543, 0.3567, 0.6707]}, {"w": "α", "b": [0.3621, 0.658, 0.3728, 0.6786]}, {"w": "j", "b": [0.3799, 0.6543, 0.3841, 0.6707]}, {"w": "t", "b": [0.3896, 0.658, 0.3957, 0.6786]}, {"w": "i", "b": [0.4017, 0.6543, 0.406, 0.6707]}, {"w": "t", "b": [0.4115, 0.658, 0.4176, 0.6786]}, {"w": "j", "b": [0.4252, 0.6543, 0.4294, 0.6707]}, {"w": "x", "b": [0.4349, 0.6576, 0.4445, 0.6786]}, {"w": "i", "b": [0.4501, 0.6543, 0.4544, 0.6707]}, {"w": "Tx", "b": [0.4599, 0.651, 0.4798, 0.6786]}, {"w": "j", "b": [0.487, 0.6543, 0.4912, 0.6707]}, {"w": "−", "b": [0.521, 0.6582, 0.5325, 0.6786]}, {"w": "∑", "b": [0.5653, 0.6534, 0.5803, 0.6822]}, {"w": "i", "b": [0.5578, 0.6729, 0.5621, 0.6893]}, {"w": "=", "b": [0.5665, 0.673, 0.5758, 0.6893]}, {"w": "1", "b": [0.5802, 0.673, 0.5878, 0.6893]}]}, {"id": "b_18", "type": "paragraph", "text": "α i", "words": [{"w": "α", "b": [0.59, 0.658, 0.6006, 0.6786]}, {"w": "i", "b": [0.6061, 0.6543, 0.6104, 0.6707]}]}, {"id": "b_19", "type": "equation", "text": "subject to α i ≥0 for i = 1, 2, ⋯, m", "words": [{"w": "subject", "b": [0.3011, 0.6955, 0.3569, 0.7159]}, {"w": "to", "b": [0.3649, 0.6955, 0.381, 0.7159]}, {"w": "α", "b": [0.4009, 0.6953, 0.4115, 0.7159]}, {"w": "i", "b": [0.417, 0.6916, 0.4213, 0.708]}, {"w": "≥0", "b": [0.4323, 0.6955, 0.4588, 0.7159]}, {"w": "for", "b": [0.4787, 0.6955, 0.502, 0.7159]}, {"w": "i", "b": [0.51, 0.6953, 0.5154, 0.7159]}, {"w": "=", "b": [0.5209, 0.6955, 0.5324, 0.7159]}, {"w": "1,", "b": [0.5379, 0.6955, 0.552, 0.7159]}, {"w": "2,", "b": [0.5553, 0.6955, 0.5693, 0.7159]}, {"w": "⋯,", "b": [0.5726, 0.6955, 0.597, 0.7159]}, {"w": "m", "b": [0.6003, 0.6953, 0.6159, 0.7159]}]}, {"id": "b_20", "type": "paragraph", "text": "170 | Chapter 5: Support Vector Machines", "words": [{"w": "170", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "5:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Support", "b": [0.2673, 0.9225, 0.3142, 0.9388]}, {"w": "Vector", "b": [0.317, 0.9225, 0.3547, 0.9388]}, {"w": "Machines", "b": [0.3576, 0.9225, 0.413, 0.9388]}]}]}, {"page": 197, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "7 As explained in Chapter 4, the dot product of two vectors a and b is normally noted a · b. However, in Machine Learning, vectors are frequently represented as column vectors (i.e., single-column matrices), so the dot product is achieved by computing aTb. To remain consistent with the rest of the book, we will use this notation here, ignoring the fact that this technically results in a single-cell matrix rather than a scalar value.", "words": [{"w": "7", "b": [0.1451, 0.8311, 0.1518, 0.8453]}, {"w": "As", "b": [0.1587, 0.8296, 0.1755, 0.8459]}, {"w": "explained", "b": [0.1791, 0.8296, 0.2407, 0.8459]}, {"w": "in", "b": [0.2443, 0.8296, 0.2573, 0.8459]}, {"w": "Chapter", "b": [0.2609, 0.8296, 0.3124, 0.8459]}, {"w": "4,", "b": [0.316, 0.8296, 0.3272, 0.8459]}, {"w": "the", "b": [0.3308, 0.8296, 0.3509, 0.8459]}, {"w": "dot", "b": [0.3545, 0.8296, 0.3758, 0.8459]}, {"w": "product", "b": [0.3794, 0.8296, 0.4301, 0.8459]}, {"w": "of", "b": [0.4337, 0.8296, 0.4465, 0.8459]}, {"w": "two", "b": [0.4501, 0.8296, 0.4739, 0.8459]}, {"w": "vectors", "b": [0.4775, 0.8296, 0.5229, 0.8459]}, {"w": "a", "b": [0.5265, 0.8291, 0.5339, 0.8459]}, {"w": "and", "b": [0.5375, 0.8296, 0.5616, 0.8459]}, {"w": "b", "b": [0.5652, 0.8291, 0.5737, 0.8459]}, {"w": "is", "b": [0.5773, 0.8296, 0.5873, 0.8459]}, {"w": "normally", "b": [0.5909, 0.8296, 0.6489, 0.8459]}, {"w": "noted", "b": [0.6525, 0.8296, 0.6892, 0.8459]}, {"w": "a", "b": [0.6928, 0.8291, 0.7002, 0.8459]}, {"w": "·", "b": [0.7038, 0.8296, 0.7074, 0.8459]}, {"w": "b.", "b": [0.711, 0.8291, 0.7231, 0.8459]}, {"w": "However,", "b": [0.7267, 0.8296, 0.7868, 0.8459]}, {"w": "in", "b": [0.7904, 0.8296, 0.8033, 0.8459]}, {"w": "Machine", "b": [0.1587, 0.8447, 0.2144, 0.861]}, {"w": "Learning,", "b": [0.218, 0.8447, 0.2789, 0.861]}, {"w": "vectors", "b": [0.2825, 0.8447, 0.3279, 0.861]}, {"w": "are", "b": [0.3315, 0.8447, 0.3511, 0.861]}, {"w": "frequently", "b": [0.3547, 0.8447, 0.4199, 0.861]}, {"w": "represented", "b": [0.4235, 0.8447, 0.498, 0.861]}, {"w": "as", "b": [0.5016, 0.8447, 0.5144, 0.861]}, {"w": "column", "b": [0.518, 0.8447, 0.5669, 0.861]}, {"w": "vectors", "b": [0.5705, 0.8447, 0.616, 0.861]}, {"w": "(i.e.,", "b": [0.6196, 0.8447, 0.6469, 0.861]}, {"w": "single-column", "b": [0.6505, 0.8447, 0.7421, 0.861]}, {"w": "matrices),", "b": [0.7457, 0.8447, 0.8087, 0.861]}, {"w": "so", "b": [0.8123, 0.8447, 0.8263, 0.861]}, {"w": "the", "b": [0.8299, 0.8447, 0.8499, 0.861]}, {"w": "dot", "b": [0.1587, 0.8598, 0.18, 0.8761]}, {"w": "product", "b": [0.1837, 0.8598, 0.2343, 0.8761]}, {"w": "is", "b": [0.2379, 0.8598, 0.248, 0.8761]}, {"w": "achieved", "b": [0.2516, 0.8598, 0.3072, 0.8761]}, {"w": "by", "b": [0.3108, 0.8598, 0.3262, 0.8761]}, {"w": "computing", "b": [0.3298, 0.8598, 0.3993, 0.8761]}, {"w": "aTb.", "b": [0.4029, 0.8583, 0.4301, 0.8761]}, {"w": "To", "b": [0.4337, 0.8598, 0.45, 0.8761]}, {"w": "remain", "b": [0.4536, 0.8598, 0.4991, 0.8761]}, {"w": "consistent", "b": [0.5027, 0.8598, 0.567, 0.8761]}, {"w": "with", "b": [0.5706, 0.8598, 0.599, 0.8761]}, {"w": "the", "b": [0.6026, 0.8598, 0.6227, 0.8761]}, {"w": "rest", "b": [0.6263, 0.8598, 0.6496, 0.8761]}, {"w": "of", "b": [0.6532, 0.8598, 0.666, 0.8761]}, {"w": "the", "b": [0.6696, 0.8598, 0.6896, 0.8761]}, {"w": "book,", "b": [0.6932, 0.8598, 0.729, 0.8761]}, {"w": "we", "b": [0.7326, 0.8598, 0.7502, 0.8761]}, {"w": "will", "b": [0.7538, 0.8598, 0.777, 0.8761]}, {"w": "use", "b": [0.7806, 0.8598, 0.8016, 0.8761]}, {"w": "this", "b": [0.8052, 0.8598, 0.8286, 0.8761]}, {"w": "notation", "b": [0.1587, 0.8749, 0.2129, 0.8912]}, {"w": "here,", "b": [0.2165, 0.8749, 0.248, 0.8912]}, {"w": "ignoring", "b": [0.2516, 0.8749, 0.3063, 0.8912]}, {"w": "the", "b": [0.3099, 0.8749, 0.33, 0.8912]}, {"w": "fact", "b": [0.3336, 0.8749, 0.3568, 0.8912]}, {"w": "that", "b": [0.3604, 0.8749, 0.3852, 0.8912]}, {"w": "this", "b": [0.3888, 0.8749, 0.4122, 0.8912]}, {"w": "technically", "b": [0.4158, 0.8749, 0.4845, 0.8912]}, {"w": "results", "b": [0.4881, 0.8749, 0.5297, 0.8912]}, {"w": "in", "b": [0.5333, 0.8749, 0.5462, 0.8912]}, {"w": "a", "b": [0.5498, 0.8749, 0.5568, 0.8912]}, {"w": "single-cell", "b": [0.5604, 0.8749, 0.6245, 0.8912]}, {"w": "matrix", "b": [0.6281, 0.8749, 0.6703, 0.8912]}, {"w": "rather", "b": [0.6739, 0.8749, 0.7124, 0.8912]}, {"w": "than", "b": [0.716, 0.8749, 0.7449, 0.8912]}, {"w": "a", "b": [0.7485, 0.8749, 0.7555, 0.8912]}, {"w": "scalar", "b": [0.7591, 0.8749, 0.7955, 0.8912]}, {"w": "value.", "b": [0.7991, 0.8749, 0.8362, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Once you find the vector α that minimizes this equation (using a QP solver), you can compute w and b that minimize the primal problem by using Equation 5-7.", "words": [{"w": "Once", "b": [0.1429, 0.0791, 0.1875, 0.1005]}, {"w": "you", "b": [0.1927, 0.0791, 0.224, 0.1005]}, {"w": "find", "b": [0.2292, 0.0791, 0.2634, 0.1005]}, {"w": "the", "b": [0.2686, 0.0791, 0.295, 0.1005]}, {"w": "vector", "b": [0.3002, 0.0791, 0.3522, 0.1005]}, {"w": "α", "b": [0.3575, 0.0789, 0.3686, 0.1005]}, {"w": "that", "b": [0.3745, 0.0791, 0.4071, 0.1005]}, {"w": "minimizes", "b": [0.4123, 0.0791, 0.4998, 0.1005]}, {"w": "this", "b": [0.5051, 0.0791, 0.5358, 0.1005]}, {"w": "equation", "b": [0.541, 0.0791, 0.6143, 0.1005]}, {"w": "(using", "b": [0.6195, 0.0791, 0.6722, 0.1005]}, {"w": "a", "b": [0.6774, 0.0791, 0.6866, 0.1005]}, {"w": "QP", "b": [0.6918, 0.0791, 0.7191, 0.1005]}, {"w": "solver),", "b": [0.7243, 0.0791, 0.786, 0.1005]}, {"w": "you", "b": [0.7913, 0.0791, 0.8225, 0.1005]}, {"w": "can", "b": [0.8278, 0.0791, 0.8571, 0.1005]}, {"w": "compute", "b": [0.1429, 0.1013, 0.2162, 0.1227]}, {"w": "w", "b": [0.2209, 0.1008, 0.2351, 0.1227]}, {"w": "and", "b": [0.2398, 0.1013, 0.2714, 0.1227]}, {"w": "b", "b": [0.2761, 0.1011, 0.2862, 0.1227]}, {"w": "that", "b": [0.2926, 0.1013, 0.3252, 0.1227]}, {"w": "minimize", "b": [0.3299, 0.1013, 0.4098, 0.1227]}, {"w": "the", "b": [0.4145, 0.1013, 0.4409, 0.1227]}, {"w": "primal", "b": [0.4456, 0.1013, 0.5013, 0.1227]}, {"w": "problem", "b": [0.506, 0.1013, 0.5771, 0.1227]}, {"w": "by", "b": [0.5818, 0.1013, 0.602, 0.1227]}, {"w": "using", "b": [0.6067, 0.1013, 0.6521, 0.1227]}, {"w": "Equation", "b": [0.6569, 0.1013, 0.7331, 0.1227]}, {"w": "5-7.", "b": [0.7378, 0.1013, 0.77, 0.1227]}]}, {"id": "b_2", "type": "equation", "text": "Equation 5-7. From the dual solution to the primal solution", "words": [{"w": "Equation", "b": [0.1726, 0.1409, 0.2473, 0.1625]}, {"w": "5-7.", "b": [0.2521, 0.1409, 0.2838, 0.1625]}, {"w": "From", "b": [0.2886, 0.1409, 0.3323, 0.1625]}, {"w": "the", "b": [0.337, 0.1409, 0.3621, 0.1625]}, {"w": "dual", "b": [0.3668, 0.1409, 0.4033, 0.1625]}, {"w": "solution", "b": [0.4081, 0.1409, 0.473, 0.1625]}, {"w": "to", "b": [0.4778, 0.1409, 0.4937, 0.1625]}, {"w": "the", "b": [0.4985, 0.1409, 0.5235, 0.1625]}, {"w": "primal", "b": [0.5283, 0.1409, 0.5829, 0.1625]}, {"w": "solution", "b": [0.5876, 0.1409, 0.6525, 0.1625]}]}, {"id": "b_3", "type": "equation", "text": "w = ∑", "words": [{"w": "w", "b": [0.1813, 0.1819, 0.1949, 0.2029]}, {"w": "=", "b": [0.2004, 0.1825, 0.2119, 0.2029]}, {"w": "∑", "b": [0.226, 0.1777, 0.241, 0.2065]}]}, {"id": "b_4", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.2185, 0.1971, 0.2228, 0.2136]}, {"w": "=", "b": [0.2272, 0.1973, 0.2364, 0.2136]}, {"w": "1", "b": [0.2409, 0.1973, 0.2485, 0.2136]}]}, {"id": "b_6", "type": "paragraph", "text": "α i t i x i", "words": [{"w": "α", "b": [0.2507, 0.1823, 0.2613, 0.2029]}, {"w": "i", "b": [0.2674, 0.1786, 0.2717, 0.195]}, {"w": "t", "b": [0.2772, 0.1823, 0.2833, 0.2029]}, {"w": "i", "b": [0.2893, 0.1786, 0.2936, 0.195]}, {"w": "x", "b": [0.2991, 0.1819, 0.3087, 0.2029]}, {"w": "i", "b": [0.3143, 0.1786, 0.3186, 0.195]}]}, {"id": "b_7", "type": "equation", "text": "b = 1", "words": [{"w": "b", "b": [0.1813, 0.2287, 0.191, 0.2492]}, {"w": "=", "b": [0.198, 0.2288, 0.2096, 0.2492]}, {"w": "1", "b": [0.2205, 0.22, 0.23, 0.2404]}]}, {"id": "b_8", "type": "paragraph", "text": "ns ∑", "words": [{"w": "ns", "b": [0.2173, 0.2375, 0.2332, 0.2623]}, {"w": "∑", "b": [0.2555, 0.2241, 0.2705, 0.2529]}]}, {"id": "b_9", "type": "equation", "text": "i = 1 α i > 0", "words": [{"w": "i", "b": [0.248, 0.2435, 0.2523, 0.26]}, {"w": "=", "b": [0.2568, 0.2437, 0.266, 0.26]}, {"w": "1", "b": [0.2704, 0.2437, 0.278, 0.26]}, {"w": "α", "b": [0.2382, 0.2617, 0.2467, 0.2782]}, {"w": "i", "b": [0.2527, 0.2556, 0.2571, 0.2721]}, {"w": ">", "b": [0.267, 0.2618, 0.2757, 0.2782]}, {"w": "0", "b": [0.2801, 0.2618, 0.2878, 0.2782]}]}, {"id": "b_11", "type": "paragraph", "text": "t i −wTx i", "words": [{"w": "t", "b": [0.2986, 0.2287, 0.3047, 0.2492]}, {"w": "i", "b": [0.3107, 0.2249, 0.315, 0.2414]}, {"w": "−wTx", "b": [0.3249, 0.2249, 0.3742, 0.2492]}, {"w": "i", "b": [0.3798, 0.2249, 0.3842, 0.2414]}]}, {"id": "b_12", "type": "paragraph", "text": "The dual problem is faster to solve than the primal when the number of training instances is smaller than the number of features. More importantly, it makes the ker‐ nel trick possible, while the primal does not. So what is this kernel trick anyway?", "words": [{"w": "The", "b": [0.1429, 0.2972, 0.1757, 0.3186]}, {"w": "dual", "b": [0.1838, 0.2972, 0.2203, 0.3186]}, {"w": "problem", "b": [0.2284, 0.2972, 0.2995, 0.3186]}, {"w": "is", "b": [0.3076, 0.2972, 0.3208, 0.3186]}, {"w": "faster", "b": [0.3289, 0.2972, 0.3748, 0.3186]}, {"w": "to", "b": [0.383, 0.2972, 0.3999, 0.3186]}, {"w": "solve", "b": [0.4081, 0.2972, 0.4501, 0.3186]}, {"w": "than", "b": [0.4582, 0.2972, 0.4962, 0.3186]}, {"w": "the", "b": [0.5044, 0.2972, 0.5307, 0.3186]}, {"w": "primal", "b": [0.5388, 0.2972, 0.5945, 0.3186]}, {"w": "when", "b": [0.6027, 0.2972, 0.6483, 0.3186]}, {"w": "the", "b": [0.6564, 0.2972, 0.6828, 0.3186]}, {"w": "number", "b": [0.6909, 0.2972, 0.7572, 0.3186]}, {"w": "of", "b": [0.7653, 0.2972, 0.7821, 0.3186]}, {"w": "training", "b": [0.7902, 0.2972, 0.8571, 0.3186]}, {"w": "instances", "b": [0.1429, 0.3163, 0.2197, 0.3377]}, {"w": "is", "b": [0.2253, 0.3163, 0.2385, 0.3377]}, {"w": "smaller", "b": [0.244, 0.3163, 0.305, 0.3377]}, {"w": "than", "b": [0.3106, 0.3163, 0.3486, 0.3377]}, {"w": "the", "b": [0.3542, 0.3163, 0.3805, 0.3377]}, {"w": "number", "b": [0.3861, 0.3163, 0.4524, 0.3377]}, {"w": "of", "b": [0.4579, 0.3163, 0.4747, 0.3377]}, {"w": "features.", "b": [0.4803, 0.3163, 0.5504, 0.3377]}, {"w": "More", "b": [0.556, 0.3163, 0.6012, 0.3377]}, {"w": "importantly,", "b": [0.6068, 0.3163, 0.7092, 0.3377]}, {"w": "it", "b": [0.7148, 0.3163, 0.7267, 0.3377]}, {"w": "makes", "b": [0.7323, 0.3163, 0.7853, 0.3377]}, {"w": "the", "b": [0.7909, 0.3163, 0.8172, 0.3377]}, {"w": "ker‐", "b": [0.8228, 0.3163, 0.8571, 0.3377]}, {"w": "nel", "b": [0.1429, 0.3353, 0.1684, 0.3567]}, {"w": "trick", "b": [0.1731, 0.3353, 0.2119, 0.3567]}, {"w": "possible,", "b": [0.2166, 0.3353, 0.2885, 0.3567]}, {"w": "while", "b": [0.2932, 0.3353, 0.3384, 0.3567]}, {"w": "the", "b": [0.3431, 0.3353, 0.3694, 0.3567]}, {"w": "primal", "b": [0.3741, 0.3353, 0.4299, 0.3567]}, {"w": "does", "b": [0.4346, 0.3353, 0.4727, 0.3567]}, {"w": "not.", "b": [0.4774, 0.3353, 0.5106, 0.3567]}, {"w": "So", "b": [0.5153, 0.3353, 0.5358, 0.3567]}, {"w": "what", "b": [0.5405, 0.3353, 0.581, 0.3567]}, {"w": "is", "b": [0.5857, 0.3353, 0.599, 0.3567]}, {"w": "this", "b": [0.6037, 0.3353, 0.6344, 0.3567]}, {"w": "kernel", "b": [0.6391, 0.3353, 0.6916, 0.3567]}, {"w": "trick", "b": [0.6963, 0.3353, 0.7351, 0.3567]}, {"w": "anyway?", "b": [0.7399, 0.3353, 0.81, 0.3567]}]}, {"id": "b_13", "type": "paragraph", "text": "Kernelized SVM", "words": [{"w": "Kernelized", "b": [0.1428, 0.3695, 0.2523, 0.398]}, {"w": "SVM", "b": [0.2572, 0.3695, 0.3022, 0.398]}]}, {"id": "b_14", "type": "paragraph", "text": "Suppose you want to apply a 2nd-degree polynomial transformation to a two- dimensional training set (such as the moons training set), then train a linear SVM classifier on the transformed training set. Equation 5-8 shows the 2nd-degree polyno‐ mial mapping function ϕ that you want to apply.", "words": [{"w": "Suppose", "b": [0.1429, 0.4039, 0.2128, 0.4254]}, {"w": "you", "b": [0.2244, 0.4039, 0.2557, 0.4254]}, {"w": "want", "b": [0.2673, 0.4039, 0.3081, 0.4254]}, {"w": "to", "b": [0.3197, 0.4039, 0.3367, 0.4254]}, {"w": "apply", "b": [0.3483, 0.4039, 0.3938, 0.4254]}, {"w": "a", "b": [0.4054, 0.4039, 0.4146, 0.4254]}, {"w": "2nd-degree", "b": [0.4262, 0.4039, 0.5121, 0.4254]}, {"w": "polynomial", "b": [0.5237, 0.4039, 0.6192, 0.4254]}, {"w": "transformation", "b": [0.6309, 0.4039, 0.7574, 0.4254]}, {"w": "to", "b": [0.7691, 0.4039, 0.786, 0.4254]}, {"w": "a", "b": [0.7977, 0.4039, 0.8068, 0.4254]}, {"w": "two-", "b": [0.8185, 0.4039, 0.8571, 0.4254]}, {"w": "dimensional", "b": [0.1429, 0.423, 0.2464, 0.4444]}, {"w": "training", "b": [0.2537, 0.423, 0.3206, 0.4444]}, {"w": "set", "b": [0.3279, 0.423, 0.3508, 0.4444]}, {"w": "(such", "b": [0.3581, 0.423, 0.4039, 0.4444]}, {"w": "as", "b": [0.4112, 0.423, 0.428, 0.4444]}, {"w": "the", "b": [0.4353, 0.423, 0.4616, 0.4444]}, {"w": "moons", "b": [0.4689, 0.423, 0.5263, 0.4444]}, {"w": "training", "b": [0.5335, 0.423, 0.6005, 0.4444]}, {"w": "set),", "b": [0.6078, 0.423, 0.6426, 0.4444]}, {"w": "then", "b": [0.6499, 0.423, 0.6876, 0.4444]}, {"w": "train", "b": [0.6949, 0.423, 0.7351, 0.4444]}, {"w": "a", "b": [0.7424, 0.423, 0.7515, 0.4444]}, {"w": "linear", "b": [0.7588, 0.423, 0.8068, 0.4444]}, {"w": "SVM", "b": [0.8141, 0.423, 0.8571, 0.4444]}, {"w": "classifier", "b": [0.1429, 0.442, 0.2153, 0.4635]}, {"w": "on", "b": [0.2209, 0.442, 0.243, 0.4635]}, {"w": "the", "b": [0.2486, 0.442, 0.275, 0.4635]}, {"w": "transformed", "b": [0.2806, 0.442, 0.3843, 0.4635]}, {"w": "training", "b": [0.39, 0.442, 0.4569, 0.4635]}, {"w": "set.", "b": [0.4626, 0.442, 0.4902, 0.4635]}, {"w": "Equation", "b": [0.4958, 0.442, 0.5721, 0.4635]}, {"w": "5-8", "b": [0.5777, 0.442, 0.6052, 0.4635]}, {"w": "shows", "b": [0.6108, 0.442, 0.6621, 0.4635]}, {"w": "the", "b": [0.6678, 0.442, 0.6941, 0.4635]}, {"w": "2nd-degree", "b": [0.6998, 0.442, 0.7857, 0.4635]}, {"w": "polyno‐", "b": [0.7913, 0.442, 0.8571, 0.4635]}, {"w": "mial", "b": [0.1429, 0.4611, 0.1799, 0.4825]}, {"w": "mapping", "b": [0.1847, 0.4611, 0.259, 0.4825]}, {"w": "function", "b": [0.2638, 0.4611, 0.3352, 0.4825]}, {"w": "ϕ", "b": [0.3399, 0.4609, 0.3515, 0.4825]}, {"w": "that", "b": [0.3562, 0.4611, 0.3888, 0.4825]}, {"w": "you", "b": [0.3936, 0.4611, 0.4248, 0.4825]}, {"w": "want", "b": [0.4295, 0.4611, 0.4703, 0.4825]}, {"w": "to", "b": [0.475, 0.4611, 0.492, 0.4825]}, {"w": "apply.", "b": [0.4967, 0.4611, 0.5454, 0.4825]}]}, {"id": "b_15", "type": "equation", "text": "Equation 5-8. Second-degree polynomial mapping", "words": [{"w": "Equation", "b": [0.1726, 0.5006, 0.2473, 0.5222]}, {"w": "5-8.", "b": [0.2521, 0.5006, 0.2838, 0.5222]}, {"w": "Second-degree", "b": [0.2886, 0.5006, 0.4038, 0.5222]}, {"w": "polynomial", "b": [0.4086, 0.5006, 0.4999, 0.5222]}, {"w": "mapping", "b": [0.5047, 0.5006, 0.5757, 0.5222]}]}, {"id": "b_16", "type": "equation", "text": "ϕ x = ϕ", "words": [{"w": "ϕ", "b": [0.1726, 0.5621, 0.1837, 0.5827]}, {"w": "x", "b": [0.1906, 0.5618, 0.2001, 0.5827]}, {"w": "=", "b": [0.2126, 0.5623, 0.2241, 0.5827]}, {"w": "ϕ", "b": [0.2296, 0.5621, 0.2407, 0.5827]}]}, {"id": "b_17", "type": "paragraph", "text": "x1 x2", "words": [{"w": "x1", "b": [0.2544, 0.5467, 0.2714, 0.5716]}, {"w": "x2", "b": [0.2544, 0.573, 0.2714, 0.5978]}]}, {"id": "b_21", "type": "paragraph", "text": "2 x1x2", "words": [{"w": "2", "b": [0.3267, 0.5607, 0.3362, 0.5811]}, {"w": "x1x2", "b": [0.3395, 0.5605, 0.3735, 0.5853]}]}, {"id": "b_24", "type": "paragraph", "text": "Notice that the transformed vector is three-dimensional instead of two-dimensional. Now let’s look at what happens to a couple of two-dimensional vectors, a and b, if we apply this 2nd-degree polynomial mapping and then compute the dot product7 of the transformed vectors (See Equation 5-9).", "words": [{"w": "Notice", "b": [0.1429, 0.6352, 0.198, 0.6566]}, {"w": "that", "b": [0.204, 0.6352, 0.2366, 0.6566]}, {"w": "the", "b": [0.2425, 0.6352, 0.2689, 0.6566]}, {"w": "transformed", "b": [0.2748, 0.6352, 0.3785, 0.6566]}, {"w": "vector", "b": [0.3845, 0.6352, 0.4365, 0.6566]}, {"w": "is", "b": [0.4425, 0.6352, 0.4557, 0.6566]}, {"w": "three-dimensional", "b": [0.4616, 0.6352, 0.6155, 0.6566]}, {"w": "instead", "b": [0.6215, 0.6352, 0.6815, 0.6566]}, {"w": "of", "b": [0.6874, 0.6352, 0.7042, 0.6566]}, {"w": "two-dimensional.", "b": [0.7102, 0.6352, 0.8571, 0.6566]}, {"w": "Now", "b": [0.1429, 0.6542, 0.1827, 0.6757]}, {"w": "let’s", "b": [0.188, 0.6542, 0.2183, 0.6757]}, {"w": "look", "b": [0.2236, 0.6542, 0.2604, 0.6757]}, {"w": "at", "b": [0.2657, 0.6542, 0.2808, 0.6757]}, {"w": "what", "b": [0.2862, 0.6542, 0.3267, 0.6757]}, {"w": "happens", "b": [0.332, 0.6542, 0.4016, 0.6757]}, {"w": "to", "b": [0.4069, 0.6542, 0.4239, 0.6757]}, {"w": "a", "b": [0.4292, 0.6542, 0.4383, 0.6757]}, {"w": "couple", "b": [0.4436, 0.6542, 0.4992, 0.6757]}, {"w": "of", "b": [0.5045, 0.6542, 0.5213, 0.6757]}, {"w": "two-dimensional", "b": [0.5266, 0.6542, 0.6688, 0.6757]}, {"w": "vectors,", "b": [0.6742, 0.6542, 0.7386, 0.6757]}, {"w": "a", "b": [0.7439, 0.6537, 0.7536, 0.6757]}, {"w": "and", "b": [0.7589, 0.6542, 0.7904, 0.6757]}, {"w": "b,", "b": [0.7958, 0.6537, 0.8116, 0.6757]}, {"w": "if", "b": [0.8169, 0.6542, 0.8287, 0.6757]}, {"w": "we", "b": [0.834, 0.6542, 0.8571, 0.6757]}, {"w": "apply", "b": [0.1429, 0.6733, 0.1883, 0.6947]}, {"w": "this", "b": [0.1941, 0.6733, 0.2248, 0.6947]}, {"w": "2nd-degree", "b": [0.2307, 0.6733, 0.3166, 0.6947]}, {"w": "polynomial", "b": [0.3224, 0.6733, 0.4179, 0.6947]}, {"w": "mapping", "b": [0.4237, 0.6733, 0.4981, 0.6947]}, {"w": "and", "b": [0.504, 0.6733, 0.5355, 0.6947]}, {"w": "then", "b": [0.5414, 0.6733, 0.5791, 0.6947]}, {"w": "compute", "b": [0.5849, 0.6733, 0.6582, 0.6947]}, {"w": "the", "b": [0.6641, 0.6733, 0.6904, 0.6947]}, {"w": "dot", "b": [0.6963, 0.6733, 0.7242, 0.6947]}, {"w": "product7", "b": [0.7301, 0.6733, 0.8023, 0.6947]}, {"w": "of", "b": [0.8082, 0.6733, 0.825, 0.6947]}, {"w": "the", "b": [0.8308, 0.6733, 0.8571, 0.6947]}, {"w": "transformed", "b": [0.1428, 0.6923, 0.2466, 0.7137]}, {"w": "vectors", "b": [0.2513, 0.6923, 0.311, 0.7137]}, {"w": "(See", "b": [0.3157, 0.6923, 0.3505, 0.7137]}, {"w": "Equation", "b": [0.3552, 0.6923, 0.4315, 0.7137]}, {"w": "5-9).", "b": [0.4362, 0.6923, 0.4756, 0.7137]}]}, {"id": "b_25", "type": "paragraph", "text": "Under the Hood | 171", "words": [{"w": "Under", "b": [0.7034, 0.9225, 0.7393, 0.9388]}, {"w": "the", "b": [0.7421, 0.9225, 0.762, 0.9388]}, {"w": "Hood", "b": [0.7648, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "171", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 198, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Equation 5-9. Kernel trick for a 2nd-degree polynomial mapping", "words": [{"w": "Equation", "b": [0.1726, 0.0769, 0.2473, 0.0985]}, {"w": "5-9.", "b": [0.2521, 0.0769, 0.2838, 0.0985]}, {"w": "Kernel", "b": [0.2886, 0.0769, 0.3419, 0.0985]}, {"w": "trick", "b": [0.3467, 0.0769, 0.3838, 0.0985]}, {"w": "for", "b": [0.3886, 0.0769, 0.4112, 0.0985]}, {"w": "a", "b": [0.416, 0.0769, 0.4262, 0.0985]}, {"w": "2nd-degree", "b": [0.431, 0.0769, 0.512, 0.0985]}, {"w": "polynomial", "b": [0.5168, 0.0769, 0.6081, 0.0985]}, {"w": "mapping", "b": [0.6129, 0.0769, 0.684, 0.0985]}]}, {"id": "b_1", "type": "equation", "text": "ϕ a Tϕ b =", "words": [{"w": "ϕ", "b": [0.1726, 0.1417, 0.1837, 0.1622]}, {"w": "a", "b": [0.1906, 0.1413, 0.1998, 0.1622]}, {"w": "Tϕ", "b": [0.2067, 0.138, 0.228, 0.1622]}, {"w": "b", "b": [0.2349, 0.1413, 0.2455, 0.1622]}, {"w": "=", "b": [0.2864, 0.1419, 0.2979, 0.1622]}]}, {"id": "b_4", "type": "paragraph", "text": "2 a1a2", "words": [{"w": "2", "b": [0.3224, 0.1402, 0.3319, 0.1606]}, {"w": "a1a2", "b": [0.3352, 0.14, 0.3699, 0.1649]}]}, {"id": "b_7", "type": "paragraph", "text": "T b1", "words": [{"w": "T", "b": [0.3768, 0.1055, 0.3863, 0.122]}, {"w": "b1", "b": [0.4112, 0.1125, 0.4285, 0.1373]}]}, {"id": "b_9", "type": "paragraph", "text": "2 b1b2", "words": [{"w": "2", "b": [0.406, 0.1402, 0.4155, 0.1606]}, {"w": "b1b2", "b": [0.4188, 0.14, 0.4534, 0.1649]}]}, {"id": "b_11", "type": "equation", "text": "2 = a1", "words": [{"w": "2", "b": [0.4285, 0.1673, 0.4361, 0.1836]}, {"w": "=", "b": [0.4657, 0.1419, 0.4773, 0.1622]}, {"w": "a1", "b": [0.4827, 0.1417, 0.5001, 0.1665]}]}, {"id": "b_12", "type": "equation", "text": "2b1 2 + 2a1b1a2b2 + a2 2b2 2", "words": [{"w": "2b1", "b": [0.5001, 0.1381, 0.525, 0.1665]}, {"w": "2", "b": [0.525, 0.1381, 0.5326, 0.1544]}, {"w": "+", "b": [0.537, 0.1419, 0.5485, 0.1622]}, {"w": "2a1b1a2b2", "b": [0.5529, 0.1417, 0.6317, 0.1665]}, {"w": "+", "b": [0.6361, 0.1419, 0.6476, 0.1622]}, {"w": "a2", "b": [0.652, 0.1417, 0.6693, 0.1665]}, {"w": "2b2", "b": [0.6693, 0.1381, 0.6942, 0.1665]}, {"w": "2", "b": [0.6942, 0.1381, 0.7018, 0.1544]}]}, {"id": "b_13", "type": "equation", "text": "= a1b1 + a2b2", "words": [{"w": "=", "b": [0.2864, 0.2193, 0.2979, 0.2397]}, {"w": "a1b1", "b": [0.3103, 0.2191, 0.3449, 0.244]}, {"w": "+", "b": [0.3493, 0.2193, 0.3608, 0.2397]}, {"w": "a2b2", "b": [0.3652, 0.2191, 0.3998, 0.244]}]}, {"id": "b_14", "type": "equation", "text": "2 = a1 a2", "words": [{"w": "2", "b": [0.4067, 0.2156, 0.4143, 0.2319]}, {"w": "=", "b": [0.4198, 0.2193, 0.4313, 0.2397]}, {"w": "a1", "b": [0.4506, 0.2037, 0.4679, 0.2286]}, {"w": "a2", "b": [0.4506, 0.23, 0.4679, 0.2548]}]}, {"id": "b_15", "type": "paragraph", "text": "T b1", "words": [{"w": "T", "b": [0.4748, 0.2012, 0.4843, 0.2177]}, {"w": "b1", "b": [0.4919, 0.2037, 0.5092, 0.2286]}]}, {"id": "b_18", "type": "equation", "text": "= aTb", "words": [{"w": "=", "b": [0.536, 0.2193, 0.5475, 0.2397]}, {"w": "aTb", "b": [0.5599, 0.2154, 0.5901, 0.2397]}]}, {"id": "b_20", "type": "paragraph", "text": "How about that? The dot product of the transformed vectors is equal to the square of the dot product of the original vectors: ϕ(a)T ϕ(b) = (aT b)2.", "words": [{"w": "How", "b": [0.1429, 0.2766, 0.1832, 0.298]}, {"w": "about", "b": [0.1884, 0.2766, 0.2362, 0.298]}, {"w": "that?", "b": [0.2414, 0.2766, 0.2819, 0.298]}, {"w": "The", "b": [0.2871, 0.2766, 0.32, 0.298]}, {"w": "dot", "b": [0.3252, 0.2766, 0.3532, 0.298]}, {"w": "product", "b": [0.3584, 0.2766, 0.4249, 0.298]}, {"w": "of", "b": [0.4301, 0.2766, 0.4469, 0.298]}, {"w": "the", "b": [0.4522, 0.2766, 0.4785, 0.298]}, {"w": "transformed", "b": [0.4837, 0.2766, 0.5874, 0.298]}, {"w": "vectors", "b": [0.5927, 0.2766, 0.6523, 0.298]}, {"w": "is", "b": [0.6576, 0.2766, 0.6708, 0.298]}, {"w": "equal", "b": [0.676, 0.2766, 0.721, 0.298]}, {"w": "to", "b": [0.7262, 0.2766, 0.7432, 0.298]}, {"w": "the", "b": [0.7485, 0.2766, 0.7748, 0.298]}, {"w": "square", "b": [0.78, 0.2766, 0.8351, 0.298]}, {"w": "of", "b": [0.8403, 0.2766, 0.8571, 0.298]}, {"w": "the", "b": [0.1429, 0.2956, 0.1692, 0.3171]}, {"w": "dot", "b": [0.1739, 0.2956, 0.2019, 0.3171]}, {"w": "product", "b": [0.2066, 0.2956, 0.2731, 0.3171]}, {"w": "of", "b": [0.2779, 0.2956, 0.2947, 0.3171]}, {"w": "the", "b": [0.2994, 0.2956, 0.3257, 0.3171]}, {"w": "original", "b": [0.3304, 0.2956, 0.3955, 0.3171]}, {"w": "vectors:", "b": [0.4003, 0.2956, 0.4647, 0.3171]}, {"w": "ϕ(a)T", "b": [0.4694, 0.2951, 0.5127, 0.3171]}, {"w": "ϕ(b)", "b": [0.5174, 0.2951, 0.5546, 0.3171]}, {"w": "=", "b": [0.5593, 0.2956, 0.5714, 0.3171]}, {"w": "(aT", "b": [0.5761, 0.2951, 0.6006, 0.3171]}, {"w": "b)2.", "b": [0.6053, 0.2951, 0.6344, 0.3171]}]}, {"id": "b_21", "type": "paragraph", "text": "Now here is the key insight: if you apply the transformation ϕ to all training instan‐ ces, then the dual problem (see Equation 5-6) will contain the dot product ϕ(x(i))T", "words": [{"w": "Now", "b": [0.1429, 0.3238, 0.1827, 0.3452]}, {"w": "here", "b": [0.1889, 0.3238, 0.2254, 0.3452]}, {"w": "is", "b": [0.2316, 0.3238, 0.2448, 0.3452]}, {"w": "the", "b": [0.251, 0.3238, 0.2773, 0.3452]}, {"w": "key", "b": [0.2835, 0.3238, 0.3122, 0.3452]}, {"w": "insight:", "b": [0.3184, 0.3238, 0.3801, 0.3452]}, {"w": "if", "b": [0.3863, 0.3238, 0.3981, 0.3452]}, {"w": "you", "b": [0.4042, 0.3238, 0.4355, 0.3452]}, {"w": "apply", "b": [0.4416, 0.3238, 0.487, 0.3452]}, {"w": "the", "b": [0.4932, 0.3238, 0.5195, 0.3452]}, {"w": "transformation", "b": [0.5257, 0.3238, 0.6522, 0.3452]}, {"w": "ϕ", "b": [0.6584, 0.3236, 0.67, 0.3452]}, {"w": "to", "b": [0.6762, 0.3238, 0.6931, 0.3452]}, {"w": "all", "b": [0.6993, 0.3238, 0.719, 0.3452]}, {"w": "training", "b": [0.7251, 0.3238, 0.7921, 0.3452]}, {"w": "instan‐", "b": [0.7982, 0.3238, 0.8572, 0.3452]}, {"w": "ces,", "b": [0.1429, 0.3428, 0.1729, 0.3642]}, {"w": "then", "b": [0.1806, 0.3428, 0.2183, 0.3642]}, {"w": "the", "b": [0.226, 0.3428, 0.2523, 0.3642]}, {"w": "dual", "b": [0.26, 0.3428, 0.2965, 0.3642]}, {"w": "problem", "b": [0.3041, 0.3428, 0.3752, 0.3642]}, {"w": "(see", "b": [0.3828, 0.3428, 0.4154, 0.3642]}, {"w": "Equation", "b": [0.4231, 0.3428, 0.4993, 0.3642]}, {"w": "5-6)", "b": [0.507, 0.3428, 0.5416, 0.3642]}, {"w": "will", "b": [0.5493, 0.3428, 0.5797, 0.3642]}, {"w": "contain", "b": [0.5873, 0.3428, 0.6502, 0.3642]}, {"w": "the", "b": [0.6579, 0.3428, 0.6842, 0.3642]}, {"w": "dot", "b": [0.6919, 0.3428, 0.7199, 0.3642]}, {"w": "product", "b": [0.7276, 0.3428, 0.7941, 0.3642]}, {"w": "ϕ(x(i))T", "b": [0.8017, 0.3423, 0.8571, 0.3642]}]}, {"id": "b_22", "type": "paragraph", "text": "ϕ(x(j)). But if ϕ is the 2nd-degree polynomial transformation defined in Equation 5-8,", "words": [{"w": "ϕ(x(j)).", "b": [0.1429, 0.3613, 0.1954, 0.3833]}, {"w": "But", "b": [0.2015, 0.3619, 0.2311, 0.3833]}, {"w": "if", "b": [0.2372, 0.3619, 0.249, 0.3833]}, {"w": "ϕ", "b": [0.2551, 0.3617, 0.2667, 0.3833]}, {"w": "is", "b": [0.2728, 0.3619, 0.286, 0.3833]}, {"w": "the", "b": [0.2921, 0.3619, 0.3184, 0.3833]}, {"w": "2nd-degree", "b": [0.3245, 0.3619, 0.4104, 0.3833]}, {"w": "polynomial", "b": [0.4165, 0.3619, 0.5119, 0.3833]}, {"w": "transformation", "b": [0.518, 0.3619, 0.6446, 0.3833]}, {"w": "defined", "b": [0.6506, 0.3619, 0.7135, 0.3833]}, {"w": "in", "b": [0.7196, 0.3619, 0.7366, 0.3833]}, {"w": "Equation", "b": [0.7426, 0.3619, 0.8189, 0.3833]}, {"w": "5-8,", "b": [0.825, 0.3619, 0.8571, 0.3833]}]}, {"id": "b_23", "type": "paragraph", "text": "then you can replace this dot product of transformed vectors simply by x i Tx j 2 . So", "words": [{"w": "then", "b": [0.1428, 0.3901, 0.1806, 0.4115]}, {"w": "you", "b": [0.1856, 0.3901, 0.2168, 0.4115]}, {"w": "can", "b": [0.2219, 0.3901, 0.2512, 0.4115]}, {"w": "replace", "b": [0.2562, 0.3901, 0.3158, 0.4115]}, {"w": "this", "b": [0.3208, 0.3901, 0.3515, 0.4115]}, {"w": "dot", "b": [0.3565, 0.3901, 0.3845, 0.4115]}, {"w": "product", "b": [0.3895, 0.3901, 0.456, 0.4115]}, {"w": "of", "b": [0.461, 0.3901, 0.4778, 0.4115]}, {"w": "transformed", "b": [0.4829, 0.3901, 0.5866, 0.4115]}, {"w": "vectors", "b": [0.5916, 0.3901, 0.6512, 0.4115]}, {"w": "simply", "b": [0.6563, 0.3901, 0.7119, 0.4115]}, {"w": "by", "b": [0.7169, 0.3901, 0.7371, 0.4115]}, {"w": "x", "b": [0.7493, 0.3895, 0.7593, 0.4115]}, {"w": "i", "b": [0.7649, 0.3868, 0.7693, 0.4032]}, {"w": "Tx", "b": [0.7748, 0.3835, 0.7951, 0.4115]}, {"w": "j", "b": [0.8023, 0.3868, 0.8066, 0.4032]}, {"w": "2", "b": [0.8193, 0.3803, 0.8269, 0.3966]}, {"w": ".", "b": [0.8269, 0.3901, 0.8316, 0.4115]}, {"w": "So", "b": [0.8364, 0.3901, 0.8569, 0.4115]}]}, {"id": "b_24", "type": "paragraph", "text": "you don’t actually need to transform the training instances at all: just replace the dot product by its square in Equation 5-6. The result will be strictly the same as if you went through the trouble of actually transforming the training set then fitting a linear SVM algorithm, but this trick makes the whole process much more computationally efficient. This is the essence of the kernel trick.", "words": [{"w": "you", "b": [0.1428, 0.4144, 0.1741, 0.4358]}, {"w": "don’t", "b": [0.18, 0.4144, 0.2216, 0.4358]}, {"w": "actually", "b": [0.2274, 0.4144, 0.292, 0.4358]}, {"w": "need", "b": [0.2979, 0.4144, 0.338, 0.4358]}, {"w": "to", "b": [0.3438, 0.4144, 0.3608, 0.4358]}, {"w": "transform", "b": [0.3667, 0.4144, 0.4505, 0.4358]}, {"w": "the", "b": [0.4564, 0.4144, 0.4827, 0.4358]}, {"w": "training", "b": [0.4886, 0.4144, 0.5555, 0.4358]}, {"w": "instances", "b": [0.5614, 0.4144, 0.6382, 0.4358]}, {"w": "at", "b": [0.644, 0.4144, 0.6591, 0.4358]}, {"w": "all:", "b": [0.665, 0.4144, 0.6894, 0.4358]}, {"w": "just", "b": [0.6953, 0.4144, 0.7257, 0.4358]}, {"w": "replace", "b": [0.7315, 0.4144, 0.7911, 0.4358]}, {"w": "the", "b": [0.797, 0.4144, 0.8233, 0.4358]}, {"w": "dot", "b": [0.8292, 0.4144, 0.8571, 0.4358]}, {"w": "product", "b": [0.1429, 0.4335, 0.2094, 0.4549]}, {"w": "by", "b": [0.2164, 0.4335, 0.2365, 0.4549]}, {"w": "its", "b": [0.2435, 0.4335, 0.2631, 0.4549]}, {"w": "square", "b": [0.2701, 0.4335, 0.3251, 0.4549]}, {"w": "in", "b": [0.3321, 0.4335, 0.3491, 0.4549]}, {"w": "Equation", "b": [0.3561, 0.4335, 0.4324, 0.4549]}, {"w": "5-6.", "b": [0.4393, 0.4335, 0.4715, 0.4549]}, {"w": "The", "b": [0.4785, 0.4335, 0.5113, 0.4549]}, {"w": "result", "b": [0.5183, 0.4335, 0.5652, 0.4549]}, {"w": "will", "b": [0.5722, 0.4335, 0.6026, 0.4549]}, {"w": "be", "b": [0.6096, 0.4335, 0.6291, 0.4549]}, {"w": "strictly", "b": [0.6361, 0.4335, 0.6934, 0.4549]}, {"w": "the", "b": [0.7004, 0.4335, 0.7267, 0.4549]}, {"w": "same", "b": [0.7337, 0.4335, 0.7764, 0.4549]}, {"w": "as", "b": [0.7834, 0.4335, 0.8002, 0.4549]}, {"w": "if", "b": [0.8072, 0.4335, 0.8189, 0.4549]}, {"w": "you", "b": [0.8259, 0.4335, 0.8571, 0.4549]}, {"w": "went", "b": [0.1429, 0.4525, 0.1833, 0.4739]}, {"w": "through", "b": [0.1883, 0.4525, 0.2561, 0.4739]}, {"w": "the", "b": [0.2611, 0.4525, 0.2875, 0.4739]}, {"w": "trouble", "b": [0.2925, 0.4525, 0.3529, 0.4739]}, {"w": "of", "b": [0.3579, 0.4525, 0.3747, 0.4739]}, {"w": "actually", "b": [0.3797, 0.4525, 0.4444, 0.4739]}, {"w": "transforming", "b": [0.4494, 0.4525, 0.5599, 0.4739]}, {"w": "the", "b": [0.565, 0.4525, 0.5913, 0.4739]}, {"w": "training", "b": [0.5963, 0.4525, 0.6632, 0.4739]}, {"w": "set", "b": [0.6682, 0.4525, 0.6911, 0.4739]}, {"w": "then", "b": [0.6961, 0.4525, 0.7338, 0.4739]}, {"w": "fitting", "b": [0.7388, 0.4525, 0.79, 0.4739]}, {"w": "a", "b": [0.795, 0.4525, 0.8042, 0.4739]}, {"w": "linear", "b": [0.8092, 0.4525, 0.8571, 0.4739]}, {"w": "SVM", "b": [0.1429, 0.4716, 0.1859, 0.493]}, {"w": "algorithm,", "b": [0.192, 0.4716, 0.2794, 0.493]}, {"w": "but", "b": [0.2854, 0.4716, 0.3134, 0.493]}, {"w": "this", "b": [0.3194, 0.4716, 0.3501, 0.493]}, {"w": "trick", "b": [0.3561, 0.4716, 0.3949, 0.493]}, {"w": "makes", "b": [0.4009, 0.4716, 0.454, 0.493]}, {"w": "the", "b": [0.46, 0.4716, 0.4863, 0.493]}, {"w": "whole", "b": [0.4924, 0.4716, 0.5425, 0.493]}, {"w": "process", "b": [0.5485, 0.4716, 0.6107, 0.493]}, {"w": "much", "b": [0.6168, 0.4716, 0.6644, 0.493]}, {"w": "more", "b": [0.6705, 0.4716, 0.7147, 0.493]}, {"w": "computationally", "b": [0.7207, 0.4716, 0.8571, 0.493]}, {"w": "efficient.", "b": [0.1428, 0.4906, 0.215, 0.512]}, {"w": "This", "b": [0.2197, 0.4906, 0.2569, 0.512]}, {"w": "is", "b": [0.2616, 0.4906, 0.2749, 0.512]}, {"w": "the", "b": [0.2796, 0.4906, 0.3059, 0.512]}, {"w": "essence", "b": [0.3107, 0.4906, 0.3727, 0.512]}, {"w": "of", "b": [0.3775, 0.4906, 0.3942, 0.512]}, {"w": "the", "b": [0.399, 0.4906, 0.4253, 0.512]}, {"w": "kernel", "b": [0.43, 0.4906, 0.4825, 0.512]}, {"w": "trick.", "b": [0.4872, 0.4906, 0.5308, 0.512]}]}, {"id": "b_25", "type": "paragraph", "text": "The function K(a, b) = (aT b)2 is called a 2nd-degree polynomial kernel. In Machine Learning, a kernel is a function capable of computing the dot product ϕ(a)T ϕ(b) based only on the original vectors a and b, without having to compute (or even to know about) the transformation ϕ. Equation 5-10 lists some of the most commonly used kernels.", "words": [{"w": "The", "b": [0.1428, 0.5187, 0.1757, 0.5401]}, {"w": "function", "b": [0.1829, 0.5187, 0.2543, 0.5401]}, {"w": "K(a,", "b": [0.2615, 0.5182, 0.2968, 0.5401]}, {"w": "b)", "b": [0.3041, 0.5182, 0.3224, 0.5401]}, {"w": "=", "b": [0.3296, 0.5187, 0.3417, 0.5401]}, {"w": "(aT", "b": [0.3489, 0.5182, 0.3734, 0.5401]}, {"w": "b)2", "b": [0.3806, 0.5182, 0.405, 0.5401]}, {"w": "is", "b": [0.4122, 0.5187, 0.4254, 0.5401]}, {"w": "called", "b": [0.4327, 0.5187, 0.481, 0.5401]}, {"w": "a", "b": [0.4883, 0.5187, 0.4974, 0.5401]}, {"w": "2nd-degree", "b": [0.5047, 0.5187, 0.5906, 0.5401]}, {"w": "polynomial", "b": [0.5978, 0.5185, 0.6891, 0.5401]}, {"w": "kernel.", "b": [0.6964, 0.5185, 0.751, 0.5401]}, {"w": "In", "b": [0.7583, 0.5187, 0.7768, 0.5401]}, {"w": "Machine", "b": [0.784, 0.5187, 0.8571, 0.5401]}, {"w": "Learning,", "b": [0.1429, 0.5378, 0.2227, 0.5592]}, {"w": "a", "b": [0.2311, 0.5378, 0.2403, 0.5592]}, {"w": "kernel", "b": [0.2487, 0.5376, 0.2987, 0.5592]}, {"w": "is", "b": [0.3071, 0.5378, 0.3204, 0.5592]}, {"w": "a", "b": [0.3288, 0.5378, 0.338, 0.5592]}, {"w": "function", "b": [0.3464, 0.5378, 0.4178, 0.5592]}, {"w": "capable", "b": [0.4263, 0.5378, 0.4886, 0.5592]}, {"w": "of", "b": [0.4971, 0.5378, 0.5139, 0.5592]}, {"w": "computing", "b": [0.5224, 0.5378, 0.6135, 0.5592]}, {"w": "the", "b": [0.622, 0.5378, 0.6483, 0.5592]}, {"w": "dot", "b": [0.6568, 0.5378, 0.6848, 0.5592]}, {"w": "product", "b": [0.6932, 0.5378, 0.7597, 0.5592]}, {"w": "ϕ(a)T", "b": [0.7682, 0.5372, 0.8115, 0.5592]}, {"w": "ϕ(b)", "b": [0.82, 0.5372, 0.8571, 0.5592]}, {"w": "based", "b": [0.1428, 0.5568, 0.1901, 0.5782]}, {"w": "only", "b": [0.1972, 0.5568, 0.234, 0.5782]}, {"w": "on", "b": [0.2412, 0.5568, 0.2632, 0.5782]}, {"w": "the", "b": [0.2703, 0.5568, 0.2966, 0.5782]}, {"w": "original", "b": [0.3038, 0.5568, 0.3688, 0.5782]}, {"w": "vectors", "b": [0.376, 0.5568, 0.4356, 0.5782]}, {"w": "a", "b": [0.4427, 0.5563, 0.4524, 0.5782]}, {"w": "and", "b": [0.4596, 0.5568, 0.4911, 0.5782]}, {"w": "b,", "b": [0.4982, 0.5563, 0.5141, 0.5782]}, {"w": "without", "b": [0.5212, 0.5568, 0.5866, 0.5782]}, {"w": "having", "b": [0.5937, 0.5568, 0.65, 0.5782]}, {"w": "to", "b": [0.6571, 0.5568, 0.6741, 0.5782]}, {"w": "compute", "b": [0.6812, 0.5568, 0.7545, 0.5782]}, {"w": "(or", "b": [0.7616, 0.5568, 0.7872, 0.5782]}, {"w": "even", "b": [0.7943, 0.5568, 0.833, 0.5782]}, {"w": "to", "b": [0.8402, 0.5568, 0.8571, 0.5782]}, {"w": "know", "b": [0.1429, 0.5759, 0.1895, 0.5973]}, {"w": "about)", "b": [0.196, 0.5759, 0.251, 0.5973]}, {"w": "the", "b": [0.2574, 0.5759, 0.2838, 0.5973]}, {"w": "transformation", "b": [0.2903, 0.5759, 0.4168, 0.5973]}, {"w": "ϕ.", "b": [0.4233, 0.5757, 0.4397, 0.5973]}, {"w": "Equation", "b": [0.4462, 0.5759, 0.5224, 0.5973]}, {"w": "5-10", "b": [0.5289, 0.5759, 0.5663, 0.5973]}, {"w": "lists", "b": [0.5728, 0.5759, 0.6053, 0.5973]}, {"w": "some", "b": [0.6118, 0.5759, 0.656, 0.5973]}, {"w": "of", "b": [0.6625, 0.5759, 0.6793, 0.5973]}, {"w": "the", "b": [0.6857, 0.5759, 0.7121, 0.5973]}, {"w": "most", "b": [0.7186, 0.5759, 0.7602, 0.5973]}, {"w": "commonly", "b": [0.7667, 0.5759, 0.8571, 0.5973]}, {"w": "used", "b": [0.1429, 0.5949, 0.1814, 0.6163]}, {"w": "kernels.", "b": [0.1861, 0.5949, 0.251, 0.6163]}]}, {"id": "b_26", "type": "equation", "text": "Equation 5-10. Common kernels", "words": [{"w": "Equation", "b": [0.1726, 0.6344, 0.2473, 0.6561]}, {"w": "5-10.", "b": [0.2521, 0.6344, 0.2937, 0.6561]}, {"w": "Common", "b": [0.2985, 0.6344, 0.3743, 0.6561]}, {"w": "kernels", "b": [0.3791, 0.6344, 0.4361, 0.6561]}]}, {"id": "b_27", "type": "equation", "text": "Linear: K a, b = aTb", "words": [{"w": "Linear:", "b": [0.2366, 0.6669, 0.2924, 0.6873]}, {"w": "K", "b": [0.321, 0.6668, 0.3339, 0.6873]}, {"w": "a,", "b": [0.3418, 0.6664, 0.3556, 0.6873]}, {"w": "b", "b": [0.3589, 0.6664, 0.3695, 0.6873]}, {"w": "=", "b": [0.3819, 0.6669, 0.3934, 0.6873]}, {"w": "aTb", "b": [0.3989, 0.663, 0.429, 0.6873]}]}, {"id": "b_28", "type": "equation", "text": "Polynomial: K a, b = γaTb + r", "words": [{"w": "Polynomial:", "b": [0.1962, 0.6965, 0.2924, 0.7169]}, {"w": "K", "b": [0.321, 0.6963, 0.3339, 0.7169]}, {"w": "a,", "b": [0.3418, 0.696, 0.3556, 0.7169]}, {"w": "b", "b": [0.3589, 0.696, 0.3695, 0.7169]}, {"w": "=", "b": [0.3818, 0.6965, 0.3934, 0.7169]}, {"w": "γaTb", "b": [0.4057, 0.6926, 0.4453, 0.7169]}, {"w": "+", "b": [0.4497, 0.6965, 0.4612, 0.7169]}, {"w": "r", "b": [0.4656, 0.6963, 0.4728, 0.7169]}]}, {"id": "b_30", "type": "equation", "text": "Gaussian RBF: K a, b = exp −γ∥a −b ∥2", "words": [{"w": "Gaussian", "b": [0.1726, 0.7276, 0.2455, 0.748]}, {"w": "RBF:", "b": [0.2534, 0.7276, 0.2924, 0.748]}, {"w": "K", "b": [0.321, 0.7274, 0.3339, 0.748]}, {"w": "a,", "b": [0.3418, 0.7271, 0.3556, 0.748]}, {"w": "b", "b": [0.3589, 0.7271, 0.3695, 0.748]}, {"w": "=", "b": [0.3819, 0.7276, 0.3934, 0.748]}, {"w": "exp", "b": [0.4044, 0.7276, 0.4326, 0.748]}, {"w": "−γ∥a", "b": [0.445, 0.7271, 0.4916, 0.748]}, {"w": "−b", "b": [0.4961, 0.7271, 0.5226, 0.748]}, {"w": "∥2", "b": [0.5281, 0.723, 0.5456, 0.7458]}]}, {"id": "b_31", "type": "equation", "text": "Sigmoid: K a, b = tanh γaTb + r", "words": [{"w": "Sigmoid:", "b": [0.2217, 0.7564, 0.2924, 0.7768]}, {"w": "K", "b": [0.321, 0.7562, 0.3339, 0.7768]}, {"w": "a,", "b": [0.3418, 0.7559, 0.3556, 0.7768]}, {"w": "b", "b": [0.3589, 0.7559, 0.3695, 0.7768]}, {"w": "=", "b": [0.3819, 0.7564, 0.3934, 0.7768]}, {"w": "tanh", "b": [0.4044, 0.7564, 0.4406, 0.7768]}, {"w": "γaTb", "b": [0.453, 0.7525, 0.4925, 0.7768]}, {"w": "+", "b": [0.4969, 0.7564, 0.5084, 0.7768]}, {"w": "r", "b": [0.5128, 0.7562, 0.5201, 0.7768]}]}, {"id": "b_32", "type": "paragraph", "text": "172 | Chapter 5: Support Vector Machines", "words": [{"w": "172", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "5:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Support", "b": [0.2673, 0.9225, 0.3142, 0.9388]}, {"w": "Vector", "b": [0.317, 0.9225, 0.3547, 0.9388]}, {"w": "Machines", "b": [0.3576, 0.9225, 0.413, 0.9388]}]}]}, {"page": 199, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Mercer’s Theorem", "words": [{"w": "Mercer’s", "b": [0.4129, 0.0921, 0.495, 0.1192]}, {"w": "Theorem", "b": [0.4997, 0.0921, 0.5871, 0.1192]}]}, {"id": "b_1", "type": "paragraph", "text": "According to Mercer’s theorem, if a function K(a, b) respects a few mathematical con‐ ditions called Mercer’s conditions (K must be continuous, symmetric in its arguments so K(a, b) = K(b, a), etc.), then there exists a function ϕ that maps a and b into another space (possibly with much higher dimensions) such that K(a, b) = ϕ(a)T ϕ(b). So you can use K as a kernel since you know ϕ exists, even if you don’t know what ϕ is. In the case of the Gaussian RBF kernel, it can be shown that ϕ actually maps each training instance to an infinite-dimensional space, so it’s a good thing you don’t need to actually perform the mapping!", "words": [{"w": "According", "b": [0.1592, 0.1238, 0.2426, 0.1442]}, {"w": "to", "b": [0.2478, 0.1238, 0.264, 0.1442]}, {"w": "Mercer’s", "b": [0.2692, 0.1236, 0.3323, 0.1442]}, {"w": "theorem,", "b": [0.3376, 0.1236, 0.4054, 0.1442]}, {"w": "if", "b": [0.4106, 0.1238, 0.4217, 0.1442]}, {"w": "a", "b": [0.427, 0.1238, 0.4357, 0.1442]}, {"w": "function", "b": [0.4409, 0.1238, 0.5089, 0.1442]}, {"w": "K(a,", "b": [0.5141, 0.1233, 0.5477, 0.1442]}, {"w": "b)", "b": [0.5529, 0.1233, 0.5703, 0.1442]}, {"w": "respects", "b": [0.5755, 0.1238, 0.6392, 0.1442]}, {"w": "a", "b": [0.6444, 0.1238, 0.6531, 0.1442]}, {"w": "few", "b": [0.6583, 0.1238, 0.6862, 0.1442]}, {"w": "mathematical", "b": [0.6914, 0.1238, 0.7991, 0.1442]}, {"w": "con‐", "b": [0.8043, 0.1238, 0.8408, 0.1442]}, {"w": "ditions", "b": [0.1592, 0.1419, 0.2146, 0.1623]}, {"w": "called", "b": [0.2203, 0.1419, 0.2663, 0.1623]}, {"w": "Mercer’s", "b": [0.2719, 0.1417, 0.335, 0.1623]}, {"w": "conditions", "b": [0.3407, 0.1417, 0.4202, 0.1623]}, {"w": "(K", "b": [0.4259, 0.1417, 0.4457, 0.1623]}, {"w": "must", "b": [0.4513, 0.1419, 0.491, 0.1623]}, {"w": "be", "b": [0.4967, 0.1419, 0.5152, 0.1623]}, {"w": "continuous,", "b": [0.5208, 0.1419, 0.6146, 0.1623]}, {"w": "symmetric", "b": [0.6203, 0.1419, 0.7047, 0.1623]}, {"w": "in", "b": [0.7103, 0.1419, 0.7265, 0.1623]}, {"w": "its", "b": [0.7321, 0.1419, 0.7508, 0.1623]}, {"w": "arguments", "b": [0.7564, 0.1419, 0.8408, 0.1623]}, {"w": "so", "b": [0.1592, 0.1601, 0.1766, 0.1805]}, {"w": "K(a,", "b": [0.1846, 0.1595, 0.2182, 0.1805]}, {"w": "b)", "b": [0.2262, 0.1595, 0.2436, 0.1805]}, {"w": "=", "b": [0.2516, 0.1601, 0.2631, 0.1805]}, {"w": "K(b,", "b": [0.2711, 0.1595, 0.3061, 0.1805]}, {"w": "a),", "b": [0.3141, 0.1595, 0.3347, 0.1805]}, {"w": "etc.),", "b": [0.3427, 0.1601, 0.3815, 0.1805]}, {"w": "then", "b": [0.3895, 0.1601, 0.4254, 0.1805]}, {"w": "there", "b": [0.4334, 0.1601, 0.4742, 0.1805]}, {"w": "exists", "b": [0.4822, 0.1601, 0.526, 0.1805]}, {"w": "a", "b": [0.5339, 0.1601, 0.5427, 0.1805]}, {"w": "function", "b": [0.5506, 0.1601, 0.6186, 0.1805]}, {"w": "ϕ", "b": [0.6266, 0.1599, 0.6377, 0.1805]}, {"w": "that", "b": [0.6457, 0.1601, 0.6767, 0.1805]}, {"w": "maps", "b": [0.6847, 0.1601, 0.727, 0.1805]}, {"w": "a", "b": [0.735, 0.1595, 0.7442, 0.1805]}, {"w": "and", "b": [0.7522, 0.1601, 0.7822, 0.1805]}, {"w": "b", "b": [0.7902, 0.1595, 0.8008, 0.1805]}, {"w": "into", "b": [0.8088, 0.1601, 0.8408, 0.1805]}, {"w": "another", "b": [0.1592, 0.1782, 0.2213, 0.1986]}, {"w": "space", "b": [0.2261, 0.1782, 0.2693, 0.1986]}, {"w": "(possibly", "b": [0.274, 0.1782, 0.3454, 0.1986]}, {"w": "with", "b": [0.3502, 0.1782, 0.3857, 0.1986]}, {"w": "much", "b": [0.3904, 0.1782, 0.4358, 0.1986]}, {"w": "higher", "b": [0.4405, 0.1782, 0.4921, 0.1986]}, {"w": "dimensions)", "b": [0.4968, 0.1782, 0.5959, 0.1986]}, {"w": "such", "b": [0.6006, 0.1782, 0.6374, 0.1986]}, {"w": "that", "b": [0.6421, 0.1782, 0.6731, 0.1986]}, {"w": "K(a,", "b": [0.6779, 0.1777, 0.7114, 0.1986]}, {"w": "b)", "b": [0.7162, 0.1777, 0.7336, 0.1986]}, {"w": "=", "b": [0.7381, 0.1782, 0.7496, 0.1986]}, {"w": "ϕ(a)T", "b": [0.7546, 0.1777, 0.7961, 0.1986]}, {"w": "ϕ(b).", "b": [0.8008, 0.1777, 0.8408, 0.1986]}, {"w": "So", "b": [0.1592, 0.1963, 0.1787, 0.2167]}, {"w": "you", "b": [0.1843, 0.1963, 0.214, 0.2167]}, {"w": "can", "b": [0.2196, 0.1963, 0.2475, 0.2167]}, {"w": "use", "b": [0.2531, 0.1963, 0.2793, 0.2167]}, {"w": "K", "b": [0.2848, 0.1961, 0.2978, 0.2167]}, {"w": "as", "b": [0.3033, 0.1963, 0.3193, 0.2167]}, {"w": "a", "b": [0.3249, 0.1963, 0.3336, 0.2167]}, {"w": "kernel", "b": [0.3391, 0.1963, 0.3891, 0.2167]}, {"w": "since", "b": [0.3946, 0.1963, 0.4349, 0.2167]}, {"w": "you", "b": [0.4404, 0.1963, 0.4702, 0.2167]}, {"w": "know", "b": [0.4757, 0.1963, 0.5201, 0.2167]}, {"w": "ϕ", "b": [0.5256, 0.1961, 0.5367, 0.2167]}, {"w": "exists,", "b": [0.5422, 0.1963, 0.5905, 0.2167]}, {"w": "even", "b": [0.596, 0.1963, 0.6329, 0.2167]}, {"w": "if", "b": [0.6385, 0.1963, 0.6497, 0.2167]}, {"w": "you", "b": [0.6552, 0.1963, 0.685, 0.2167]}, {"w": "don’t", "b": [0.6905, 0.1963, 0.7301, 0.2167]}, {"w": "know", "b": [0.7356, 0.1963, 0.7801, 0.2167]}, {"w": "what", "b": [0.7856, 0.1963, 0.8242, 0.2167]}, {"w": "ϕ", "b": [0.8297, 0.1961, 0.8408, 0.2167]}, {"w": "is.", "b": [0.1592, 0.2145, 0.1763, 0.2349]}, {"w": "In", "b": [0.1819, 0.2145, 0.1995, 0.2349]}, {"w": "the", "b": [0.205, 0.2145, 0.2301, 0.2349]}, {"w": "case", "b": [0.2356, 0.2145, 0.2685, 0.2349]}, {"w": "of", "b": [0.274, 0.2145, 0.29, 0.2349]}, {"w": "the", "b": [0.2955, 0.2145, 0.3206, 0.2349]}, {"w": "Gaussian", "b": [0.3261, 0.2145, 0.3986, 0.2349]}, {"w": "RBF", "b": [0.4042, 0.2145, 0.4386, 0.2349]}, {"w": "kernel,", "b": [0.4442, 0.2145, 0.4986, 0.2349]}, {"w": "it", "b": [0.5042, 0.2145, 0.5155, 0.2349]}, {"w": "can", "b": [0.5211, 0.2145, 0.549, 0.2349]}, {"w": "be", "b": [0.5546, 0.2145, 0.5731, 0.2349]}, {"w": "shown", "b": [0.5786, 0.2145, 0.6311, 0.2349]}, {"w": "that", "b": [0.6366, 0.2145, 0.6676, 0.2349]}, {"w": "ϕ", "b": [0.6732, 0.2143, 0.6842, 0.2349]}, {"w": "actually", "b": [0.6898, 0.2145, 0.7513, 0.2349]}, {"w": "maps", "b": [0.7568, 0.2145, 0.7991, 0.2349]}, {"w": "each", "b": [0.8046, 0.2145, 0.8408, 0.2349]}, {"w": "training", "b": [0.1592, 0.2326, 0.223, 0.253]}, {"w": "instance", "b": [0.2282, 0.2326, 0.2941, 0.253]}, {"w": "to", "b": [0.2994, 0.2326, 0.3155, 0.253]}, {"w": "an", "b": [0.3208, 0.2326, 0.3404, 0.253]}, {"w": "infinite-dimensional", "b": [0.3456, 0.2326, 0.5093, 0.253]}, {"w": "space,", "b": [0.5146, 0.2326, 0.5623, 0.253]}, {"w": "so", "b": [0.5676, 0.2326, 0.585, 0.253]}, {"w": "it’s", "b": [0.5902, 0.2326, 0.6109, 0.253]}, {"w": "a", "b": [0.6161, 0.2326, 0.6248, 0.253]}, {"w": "good", "b": [0.6301, 0.2326, 0.6701, 0.253]}, {"w": "thing", "b": [0.6753, 0.2326, 0.7174, 0.253]}, {"w": "you", "b": [0.7227, 0.2326, 0.7524, 0.253]}, {"w": "don’t", "b": [0.7577, 0.2326, 0.7973, 0.253]}, {"w": "need", "b": [0.8026, 0.2326, 0.8408, 0.253]}, {"w": "to", "b": [0.1592, 0.2508, 0.1754, 0.2712]}, {"w": "actually", "b": [0.1799, 0.2508, 0.2414, 0.2712]}, {"w": "perform", "b": [0.2459, 0.2508, 0.3117, 0.2712]}, {"w": "the", "b": [0.3162, 0.2508, 0.3413, 0.2712]}, {"w": "mapping!", "b": [0.3458, 0.2508, 0.4221, 0.2712]}]}, {"id": "b_2", "type": "paragraph", "text": "Note that some frequently used kernels (such as the Sigmoid kernel) don’t respect all of Mercer’s conditions, yet they generally work well in practice.", "words": [{"w": "Note", "b": [0.1592, 0.278, 0.1981, 0.2984]}, {"w": "that", "b": [0.2036, 0.278, 0.2346, 0.2984]}, {"w": "some", "b": [0.2401, 0.278, 0.2822, 0.2984]}, {"w": "frequently", "b": [0.2877, 0.278, 0.3692, 0.2984]}, {"w": "used", "b": [0.3747, 0.278, 0.4114, 0.2984]}, {"w": "kernels", "b": [0.4169, 0.278, 0.4742, 0.2984]}, {"w": "(such", "b": [0.4797, 0.278, 0.5234, 0.2984]}, {"w": "as", "b": [0.5289, 0.278, 0.5449, 0.2984]}, {"w": "the", "b": [0.5504, 0.278, 0.5755, 0.2984]}, {"w": "Sigmoid", "b": [0.581, 0.278, 0.6472, 0.2984]}, {"w": "kernel)", "b": [0.6527, 0.278, 0.7095, 0.2984]}, {"w": "don’t", "b": [0.715, 0.278, 0.7546, 0.2984]}, {"w": "respect", "b": [0.7601, 0.278, 0.8165, 0.2984]}, {"w": "all", "b": [0.822, 0.278, 0.8408, 0.2984]}, {"w": "of", "b": [0.1592, 0.2961, 0.1752, 0.3165]}, {"w": "Mercer’s", "b": [0.1797, 0.2961, 0.2467, 0.3165]}, {"w": "conditions,", "b": [0.2512, 0.2961, 0.3405, 0.3165]}, {"w": "yet", "b": [0.345, 0.2961, 0.3686, 0.3165]}, {"w": "they", "b": [0.3731, 0.2961, 0.4073, 0.3165]}, {"w": "generally", "b": [0.4118, 0.2961, 0.484, 0.3165]}, {"w": "work", "b": [0.4885, 0.2961, 0.5294, 0.3165]}, {"w": "well", "b": [0.5339, 0.2961, 0.566, 0.3165]}, {"w": "in", "b": [0.5705, 0.2961, 0.5867, 0.3165]}, {"w": "practice.", "b": [0.5912, 0.2961, 0.6587, 0.3165]}]}, {"id": "b_3", "type": "paragraph", "text": "There is still one loose end we must tie. Equation 5-7 shows how to go from the dual solution to the primal solution in the case of a linear SVM classifier, but if you apply the kernel trick you end up with equations that include ϕ(x(i)). In fact, w must have the same number of dimensions as ϕ(x(i)), which may be huge or even infinite, so you can’t compute it. But how can you make predictions without knowing w? Well, the good news is that you can plug in the formula for w from Equation 5-7 into the deci‐ sion function for a new instance x(n), and you get an equation with only dot products between input vectors. This makes it possible to use the kernel trick, once again (Equation 5-11).", "words": [{"w": "There", "b": [0.1428, 0.3463, 0.1923, 0.3677]}, {"w": "is", "b": [0.1977, 0.3463, 0.211, 0.3677]}, {"w": "still", "b": [0.2165, 0.3463, 0.2466, 0.3677]}, {"w": "one", "b": [0.2521, 0.3463, 0.2829, 0.3677]}, {"w": "loose", "b": [0.2884, 0.3463, 0.3314, 0.3677]}, {"w": "end", "b": [0.3369, 0.3463, 0.3682, 0.3677]}, {"w": "we", "b": [0.3737, 0.3463, 0.3968, 0.3677]}, {"w": "must", "b": [0.4023, 0.3463, 0.444, 0.3677]}, {"w": "tie.", "b": [0.4495, 0.3463, 0.475, 0.3677]}, {"w": "Equation", "b": [0.4805, 0.3463, 0.5568, 0.3677]}, {"w": "5-7", "b": [0.5622, 0.3463, 0.5897, 0.3677]}, {"w": "shows", "b": [0.5951, 0.3463, 0.6465, 0.3677]}, {"w": "how", "b": [0.6519, 0.3463, 0.688, 0.3677]}, {"w": "to", "b": [0.6934, 0.3463, 0.7104, 0.3677]}, {"w": "go", "b": [0.7159, 0.3463, 0.7363, 0.3677]}, {"w": "from", "b": [0.7418, 0.3463, 0.7834, 0.3677]}, {"w": "the", "b": [0.7888, 0.3463, 0.8152, 0.3677]}, {"w": "dual", "b": [0.8207, 0.3463, 0.8571, 0.3677]}, {"w": "solution", "b": [0.1429, 0.3653, 0.2114, 0.3867]}, {"w": "to", "b": [0.2171, 0.3653, 0.2341, 0.3867]}, {"w": "the", "b": [0.2398, 0.3653, 0.2661, 0.3867]}, {"w": "primal", "b": [0.2718, 0.3653, 0.3275, 0.3867]}, {"w": "solution", "b": [0.3332, 0.3653, 0.4018, 0.3867]}, {"w": "in", "b": [0.4075, 0.3653, 0.4244, 0.3867]}, {"w": "the", "b": [0.4301, 0.3653, 0.4565, 0.3867]}, {"w": "case", "b": [0.4622, 0.3653, 0.4966, 0.3867]}, {"w": "of", "b": [0.5023, 0.3653, 0.5191, 0.3867]}, {"w": "a", "b": [0.5248, 0.3653, 0.5339, 0.3867]}, {"w": "linear", "b": [0.5396, 0.3653, 0.5876, 0.3867]}, {"w": "SVM", "b": [0.5933, 0.3653, 0.6364, 0.3867]}, {"w": "classifier,", "b": [0.6421, 0.3653, 0.718, 0.3867]}, {"w": "but", "b": [0.7237, 0.3653, 0.7517, 0.3867]}, {"w": "if", "b": [0.7573, 0.3653, 0.7691, 0.3867]}, {"w": "you", "b": [0.7748, 0.3653, 0.806, 0.3867]}, {"w": "apply", "b": [0.8117, 0.3653, 0.8571, 0.3867]}, {"w": "the", "b": [0.1429, 0.3844, 0.1692, 0.4058]}, {"w": "kernel", "b": [0.1758, 0.3844, 0.2282, 0.4058]}, {"w": "trick", "b": [0.2348, 0.3844, 0.2736, 0.4058]}, {"w": "you", "b": [0.2802, 0.3844, 0.3115, 0.4058]}, {"w": "end", "b": [0.3181, 0.3844, 0.3493, 0.4058]}, {"w": "up", "b": [0.3559, 0.3844, 0.3779, 0.4058]}, {"w": "with", "b": [0.3845, 0.3844, 0.4218, 0.4058]}, {"w": "equations", "b": [0.4284, 0.3844, 0.5093, 0.4058]}, {"w": "that", "b": [0.5159, 0.3844, 0.5485, 0.4058]}, {"w": "include", "b": [0.5551, 0.3844, 0.6171, 0.4058]}, {"w": "ϕ(x(i)).", "b": [0.6237, 0.3841, 0.6761, 0.4058]}, {"w": "In", "b": [0.6827, 0.3844, 0.7012, 0.4058]}, {"w": "fact,", "b": [0.7078, 0.3844, 0.743, 0.4058]}, {"w": "w", "b": [0.7496, 0.3838, 0.7638, 0.4058]}, {"w": "must", "b": [0.7704, 0.3844, 0.8122, 0.4058]}, {"w": "have", "b": [0.8187, 0.3844, 0.8571, 0.4058]}, {"w": "the", "b": [0.1429, 0.4034, 0.1692, 0.4248]}, {"w": "same", "b": [0.1744, 0.4034, 0.2171, 0.4248]}, {"w": "number", "b": [0.2223, 0.4034, 0.2885, 0.4248]}, {"w": "of", "b": [0.2937, 0.4034, 0.3105, 0.4248]}, {"w": "dimensions", "b": [0.3157, 0.4034, 0.4125, 0.4248]}, {"w": "as", "b": [0.4177, 0.4034, 0.4345, 0.4248]}, {"w": "ϕ(x(i)),", "b": [0.4396, 0.4032, 0.4921, 0.4248]}, {"w": "which", "b": [0.4973, 0.4034, 0.5482, 0.4248]}, {"w": "may", "b": [0.5534, 0.4034, 0.5888, 0.4248]}, {"w": "be", "b": [0.5939, 0.4034, 0.6134, 0.4248]}, {"w": "huge", "b": [0.6186, 0.4034, 0.6589, 0.4248]}, {"w": "or", "b": [0.6641, 0.4034, 0.6825, 0.4248]}, {"w": "even", "b": [0.6877, 0.4034, 0.7264, 0.4248]}, {"w": "infinite,", "b": [0.7316, 0.4034, 0.7973, 0.4248]}, {"w": "so", "b": [0.8024, 0.4034, 0.8207, 0.4248]}, {"w": "you", "b": [0.8259, 0.4034, 0.8571, 0.4248]}, {"w": "can’t", "b": [0.1428, 0.4224, 0.1808, 0.4439]}, {"w": "compute", "b": [0.1878, 0.4224, 0.261, 0.4439]}, {"w": "it.", "b": [0.268, 0.4224, 0.2847, 0.4439]}, {"w": "But", "b": [0.2917, 0.4224, 0.3213, 0.4439]}, {"w": "how", "b": [0.3283, 0.4224, 0.3643, 0.4439]}, {"w": "can", "b": [0.3713, 0.4224, 0.4007, 0.4439]}, {"w": "you", "b": [0.4076, 0.4224, 0.4389, 0.4439]}, {"w": "make", "b": [0.4459, 0.4224, 0.4913, 0.4439]}, {"w": "predictions", "b": [0.4982, 0.4224, 0.5927, 0.4439]}, {"w": "without", "b": [0.5997, 0.4224, 0.6651, 0.4439]}, {"w": "knowing", "b": [0.672, 0.4224, 0.7454, 0.4439]}, {"w": "w?", "b": [0.7524, 0.4219, 0.7745, 0.4439]}, {"w": "Well,", "b": [0.7815, 0.4224, 0.8238, 0.4439]}, {"w": "the", "b": [0.8308, 0.4224, 0.8571, 0.4439]}, {"w": "good", "b": [0.1429, 0.4415, 0.1849, 0.4629]}, {"w": "news", "b": [0.1902, 0.4415, 0.2324, 0.4629]}, {"w": "is", "b": [0.2378, 0.4415, 0.251, 0.4629]}, {"w": "that", "b": [0.2563, 0.4415, 0.2889, 0.4629]}, {"w": "you", "b": [0.2943, 0.4415, 0.3255, 0.4629]}, {"w": "can", "b": [0.3309, 0.4415, 0.3603, 0.4629]}, {"w": "plug", "b": [0.3656, 0.4415, 0.4026, 0.4629]}, {"w": "in", "b": [0.408, 0.4415, 0.425, 0.4629]}, {"w": "the", "b": [0.4303, 0.4415, 0.4567, 0.4629]}, {"w": "formula", "b": [0.462, 0.4415, 0.5287, 0.4629]}, {"w": "for", "b": [0.5341, 0.4415, 0.5586, 0.4629]}, {"w": "w", "b": [0.5639, 0.4409, 0.5782, 0.4629]}, {"w": "from", "b": [0.5835, 0.4415, 0.6251, 0.4629]}, {"w": "Equation", "b": [0.6305, 0.4415, 0.7067, 0.4629]}, {"w": "5-7", "b": [0.7114, 0.4415, 0.7389, 0.4629]}, {"w": "into", "b": [0.7449, 0.4415, 0.7784, 0.4629]}, {"w": "the", "b": [0.7838, 0.4415, 0.8101, 0.4629]}, {"w": "deci‐", "b": [0.8155, 0.4415, 0.8571, 0.4629]}, {"w": "sion", "b": [0.1429, 0.4605, 0.1781, 0.482]}, {"w": "function", "b": [0.1836, 0.4605, 0.255, 0.482]}, {"w": "for", "b": [0.2605, 0.4605, 0.285, 0.482]}, {"w": "a", "b": [0.2905, 0.4605, 0.2997, 0.482]}, {"w": "new", "b": [0.3052, 0.4605, 0.3397, 0.482]}, {"w": "instance", "b": [0.3452, 0.4605, 0.4144, 0.482]}, {"w": "x(n),", "b": [0.4199, 0.46, 0.4497, 0.482]}, {"w": "and", "b": [0.4552, 0.4605, 0.4868, 0.482]}, {"w": "you", "b": [0.4923, 0.4605, 0.5235, 0.482]}, {"w": "get", "b": [0.529, 0.4605, 0.554, 0.482]}, {"w": "an", "b": [0.5595, 0.4605, 0.58, 0.482]}, {"w": "equation", "b": [0.5855, 0.4605, 0.6588, 0.482]}, {"w": "with", "b": [0.6643, 0.4605, 0.7016, 0.482]}, {"w": "only", "b": [0.7072, 0.4605, 0.744, 0.482]}, {"w": "dot", "b": [0.7495, 0.4605, 0.7775, 0.482]}, {"w": "products", "b": [0.783, 0.4605, 0.8571, 0.482]}, {"w": "between", "b": [0.1428, 0.4796, 0.212, 0.501]}, {"w": "input", "b": [0.2209, 0.4796, 0.2658, 0.501]}, {"w": "vectors.", "b": [0.2746, 0.4796, 0.339, 0.501]}, {"w": "This", "b": [0.3479, 0.4796, 0.3851, 0.501]}, {"w": "makes", "b": [0.3939, 0.4796, 0.4469, 0.501]}, {"w": "it", "b": [0.4558, 0.4796, 0.4677, 0.501]}, {"w": "possible", "b": [0.4766, 0.4796, 0.5437, 0.501]}, {"w": "to", "b": [0.5525, 0.4796, 0.5695, 0.501]}, {"w": "use", "b": [0.5783, 0.4796, 0.6059, 0.501]}, {"w": "the", "b": [0.6147, 0.4796, 0.6411, 0.501]}, {"w": "kernel", "b": [0.6499, 0.4796, 0.7023, 0.501]}, {"w": "trick,", "b": [0.7112, 0.4796, 0.7547, 0.501]}, {"w": "once", "b": [0.7636, 0.4796, 0.8033, 0.501]}, {"w": "again", "b": [0.8121, 0.4796, 0.8571, 0.501]}, {"w": "(Equation", "b": [0.1429, 0.4986, 0.2263, 0.5201]}, {"w": "5-11).", "b": [0.231, 0.4986, 0.2804, 0.5201]}]}, {"id": "b_4", "type": "equation", "text": "Equation 5-11. Making predictions with a kernelized SVM", "words": [{"w": "Equation", "b": [0.1726, 0.5382, 0.2473, 0.5598]}, {"w": "5-11.", "b": [0.252, 0.5382, 0.2937, 0.5598]}, {"w": "Making", "b": [0.2985, 0.5382, 0.3605, 0.5598]}, {"w": "predictions", "b": [0.3653, 0.5382, 0.4541, 0.5598]}, {"w": "with", "b": [0.4589, 0.5382, 0.4953, 0.5598]}, {"w": "a", "b": [0.5001, 0.5382, 0.5103, 0.5598]}, {"w": "kernelized", "b": [0.5151, 0.5382, 0.598, 0.5598]}, {"w": "SVM", "b": [0.6028, 0.5382, 0.6448, 0.5598]}]}, {"id": "b_5", "type": "equation", "text": "hw, b ϕ x n = wTϕ x n + b = ∑", "words": [{"w": "hw,", "b": [0.1726, 0.5829, 0.1972, 0.6114]}, {"w": "b", "b": [0.1999, 0.5949, 0.2076, 0.6114]}, {"w": "ϕ", "b": [0.2157, 0.5829, 0.2268, 0.6035]}, {"w": "x", "b": [0.2337, 0.5825, 0.2432, 0.6035]}, {"w": "n", "b": [0.2488, 0.5792, 0.2573, 0.5956]}, {"w": "=", "b": [0.2852, 0.5831, 0.2967, 0.6035]}, {"w": "wTϕ", "b": [0.3055, 0.5792, 0.3404, 0.6035]}, {"w": "x", "b": [0.3473, 0.5825, 0.3569, 0.6035]}, {"w": "n", "b": [0.3625, 0.5792, 0.3709, 0.5956]}, {"w": "+", "b": [0.3877, 0.5831, 0.3992, 0.6035]}, {"w": "b", "b": [0.4036, 0.5829, 0.4132, 0.6035]}, {"w": "=", "b": [0.4203, 0.5831, 0.4318, 0.6035]}, {"w": "∑", "b": [0.4528, 0.5783, 0.4678, 0.6071]}]}, {"id": "b_6", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.4453, 0.5978, 0.4497, 0.6142]}, {"w": "=", "b": [0.454, 0.5979, 0.4633, 0.6142]}, {"w": "1", "b": [0.4677, 0.5979, 0.4753, 0.6142]}]}, {"id": "b_8", "type": "paragraph", "text": "α i t i ϕ x i", "words": [{"w": "α", "b": [0.4775, 0.5829, 0.4881, 0.6035]}, {"w": "i", "b": [0.4942, 0.5792, 0.4986, 0.5956]}, {"w": "t", "b": [0.504, 0.5829, 0.5101, 0.6035]}, {"w": "i", "b": [0.5161, 0.5792, 0.5205, 0.5956]}, {"w": "ϕ", "b": [0.526, 0.5829, 0.537, 0.6035]}, {"w": "x", "b": [0.5439, 0.5825, 0.5535, 0.6035]}, {"w": "i", "b": [0.5591, 0.5792, 0.5634, 0.5956]}]}, {"id": "b_10", "type": "equation", "text": "ϕ x n + b", "words": [{"w": "ϕ", "b": [0.5929, 0.5829, 0.604, 0.6035]}, {"w": "x", "b": [0.6108, 0.5825, 0.6204, 0.6035]}, {"w": "n", "b": [0.626, 0.5792, 0.6344, 0.5956]}, {"w": "+", "b": [0.6512, 0.5831, 0.6627, 0.6035]}, {"w": "b", "b": [0.6671, 0.5829, 0.6768, 0.6035]}]}, {"id": "b_11", "type": "equation", "text": "= ∑", "words": [{"w": "=", "b": [0.2852, 0.6295, 0.2967, 0.6499]}, {"w": "∑", "b": [0.3141, 0.6247, 0.3291, 0.6535]}]}, {"id": "b_12", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.3066, 0.6441, 0.3109, 0.6606]}, {"w": "=", "b": [0.3154, 0.6443, 0.3246, 0.6606]}, {"w": "1", "b": [0.329, 0.6443, 0.3366, 0.6606]}]}, {"id": "b_14", "type": "equation", "text": "α i t i ϕ x i Tϕ x n + b", "words": [{"w": "α", "b": [0.3388, 0.6293, 0.3494, 0.6499]}, {"w": "i", "b": [0.3555, 0.6256, 0.3598, 0.642]}, {"w": "t", "b": [0.3653, 0.6293, 0.3714, 0.6499]}, {"w": "i", "b": [0.3774, 0.6256, 0.3817, 0.642]}, {"w": "ϕ", "b": [0.3941, 0.6293, 0.4052, 0.6499]}, {"w": "x", "b": [0.412, 0.6289, 0.4216, 0.6499]}, {"w": "i", "b": [0.4272, 0.6256, 0.4316, 0.642]}, {"w": "Tϕ", "b": [0.4439, 0.6223, 0.4653, 0.6499]}, {"w": "x", "b": [0.4721, 0.6289, 0.4817, 0.6499]}, {"w": "n", "b": [0.4873, 0.6256, 0.4958, 0.642]}, {"w": "+", "b": [0.5194, 0.6295, 0.5309, 0.6499]}, {"w": "b", "b": [0.5353, 0.6293, 0.5449, 0.6499]}]}, {"id": "b_15", "type": "equation", "text": "= ∑ i = 1 α i > 0", "words": [{"w": "=", "b": [0.2852, 0.6758, 0.2967, 0.6962]}, {"w": "∑", "b": [0.3223, 0.6711, 0.3373, 0.6999]}, {"w": "i", "b": [0.3148, 0.6905, 0.3192, 0.707]}, {"w": "=", "b": [0.3236, 0.6907, 0.3328, 0.707]}, {"w": "1", "b": [0.3372, 0.6907, 0.3448, 0.707]}, {"w": "α", "b": [0.3051, 0.7087, 0.3136, 0.7252]}, {"w": "i", "b": [0.3195, 0.7026, 0.3239, 0.7191]}, {"w": ">", "b": [0.3338, 0.7088, 0.3425, 0.7252]}, {"w": "0", "b": [0.3469, 0.7088, 0.3546, 0.7252]}]}, {"id": "b_17", "type": "equation", "text": "α i t i K x i , x n + b", "words": [{"w": "α", "b": [0.3585, 0.6757, 0.3692, 0.6962]}, {"w": "i", "b": [0.3753, 0.6719, 0.3796, 0.6884]}, {"w": "t", "b": [0.3851, 0.6757, 0.3912, 0.6962]}, {"w": "i", "b": [0.3972, 0.6719, 0.4015, 0.6884]}, {"w": "K", "b": [0.407, 0.6757, 0.42, 0.6962]}, {"w": "x", "b": [0.4278, 0.6753, 0.4374, 0.6962]}, {"w": "i", "b": [0.443, 0.6719, 0.4473, 0.6884]}, {"w": ",", "b": [0.4528, 0.6758, 0.4573, 0.6962]}, {"w": "x", "b": [0.4606, 0.6753, 0.4702, 0.6962]}, {"w": "n", "b": [0.4758, 0.6719, 0.4843, 0.6884]}, {"w": "+", "b": [0.501, 0.6758, 0.5125, 0.6962]}, {"w": "b", "b": [0.5169, 0.6757, 0.5266, 0.6962]}]}, {"id": "b_18", "type": "paragraph", "text": "Note that since α(i) ≠ 0 only for support vectors, making predictions involves comput‐ ing the dot product of the new input vector x(n) with only the support vectors, not all the training instances. Of course, you also need to compute the bias term b, using the same trick (Equation 5-12).", "words": [{"w": "Note", "b": [0.1428, 0.7442, 0.1836, 0.7656]}, {"w": "that", "b": [0.1886, 0.7442, 0.2212, 0.7656]}, {"w": "since", "b": [0.2262, 0.7442, 0.2685, 0.7656]}, {"w": "α(i)", "b": [0.2734, 0.744, 0.2964, 0.7656]}, {"w": "≠", "b": [0.3013, 0.7442, 0.3136, 0.7656]}, {"w": "0", "b": [0.3185, 0.7442, 0.3285, 0.7656]}, {"w": "only", "b": [0.3335, 0.7442, 0.3704, 0.7656]}, {"w": "for", "b": [0.3753, 0.7442, 0.3998, 0.7656]}, {"w": "support", "b": [0.4048, 0.7442, 0.4701, 0.7656]}, {"w": "vectors,", "b": [0.475, 0.7442, 0.5395, 0.7656]}, {"w": "making", "b": [0.5444, 0.7442, 0.6077, 0.7656]}, {"w": "predictions", "b": [0.6127, 0.7442, 0.7072, 0.7656]}, {"w": "involves", "b": [0.7121, 0.7442, 0.7803, 0.7656]}, {"w": "comput‐", "b": [0.7853, 0.7442, 0.8571, 0.7656]}, {"w": "ing", "b": [0.1429, 0.7633, 0.1696, 0.7847]}, {"w": "the", "b": [0.1751, 0.7633, 0.2015, 0.7847]}, {"w": "dot", "b": [0.207, 0.7633, 0.235, 0.7847]}, {"w": "product", "b": [0.2406, 0.7633, 0.3071, 0.7847]}, {"w": "of", "b": [0.3126, 0.7633, 0.3294, 0.7847]}, {"w": "the", "b": [0.335, 0.7633, 0.3613, 0.7847]}, {"w": "new", "b": [0.3668, 0.7633, 0.4014, 0.7847]}, {"w": "input", "b": [0.4069, 0.7633, 0.4518, 0.7847]}, {"w": "vector", "b": [0.4574, 0.7633, 0.5094, 0.7847]}, {"w": "x(n)", "b": [0.515, 0.7627, 0.54, 0.7847]}, {"w": "with", "b": [0.5456, 0.7633, 0.5829, 0.7847]}, {"w": "only", "b": [0.5885, 0.7633, 0.6253, 0.7847]}, {"w": "the", "b": [0.6309, 0.7633, 0.6572, 0.7847]}, {"w": "support", "b": [0.6628, 0.7633, 0.728, 0.7847]}, {"w": "vectors,", "b": [0.7336, 0.7633, 0.798, 0.7847]}, {"w": "not", "b": [0.8035, 0.7633, 0.8319, 0.7847]}, {"w": "all", "b": [0.8375, 0.7633, 0.8571, 0.7847]}, {"w": "the", "b": [0.1428, 0.7855, 0.1692, 0.8069]}, {"w": "training", "b": [0.1743, 0.7855, 0.2412, 0.8069]}, {"w": "instances.", "b": [0.2463, 0.7855, 0.3279, 0.8069]}, {"w": "Of", "b": [0.333, 0.7855, 0.3547, 0.8069]}, {"w": "course,", "b": [0.3598, 0.7855, 0.4193, 0.8069]}, {"w": "you", "b": [0.4243, 0.7855, 0.4556, 0.8069]}, {"w": "also", "b": [0.4607, 0.7855, 0.4934, 0.8069]}, {"w": "need", "b": [0.4985, 0.7855, 0.5386, 0.8069]}, {"w": "to", "b": [0.5436, 0.7855, 0.5606, 0.8069]}, {"w": "compute", "b": [0.5657, 0.7855, 0.639, 0.8069]}, {"w": "the", "b": [0.6441, 0.7855, 0.6704, 0.8069]}, {"w": "bias", "b": [0.6755, 0.7855, 0.7085, 0.8069]}, {"w": "term", "b": [0.7136, 0.7855, 0.7536, 0.8069]}, {"w": "b,", "b": [0.7587, 0.7853, 0.7752, 0.8069]}, {"w": "using", "b": [0.7803, 0.7855, 0.8257, 0.8069]}, {"w": "the", "b": [0.8308, 0.7855, 0.8571, 0.8069]}, {"w": "same", "b": [0.1429, 0.8046, 0.1856, 0.826]}, {"w": "trick", "b": [0.1903, 0.8046, 0.2291, 0.826]}, {"w": "(Equation", "b": [0.2338, 0.8046, 0.3173, 0.826]}, {"w": "5-12).", "b": [0.322, 0.8046, 0.3714, 0.826]}]}, {"id": "b_19", "type": "paragraph", "text": "Under the Hood | 173", "words": [{"w": "Under", "b": [0.7034, 0.9225, 0.7393, 0.9388]}, {"w": "the", "b": [0.7421, 0.9225, 0.762, 0.9388]}, {"w": "Hood", "b": [0.7648, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "173", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 200, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Equation 5-12. Computing the bias term using the kernel trick", "words": [{"w": "Equation", "b": [0.1726, 0.0769, 0.2473, 0.0985]}, {"w": "5-12.", "b": [0.2521, 0.0769, 0.2937, 0.0985]}, {"w": "Computing", "b": [0.2985, 0.0769, 0.3894, 0.0985]}, {"w": "the", "b": [0.3941, 0.0769, 0.4192, 0.0985]}, {"w": "bias", "b": [0.4239, 0.0769, 0.4567, 0.0985]}, {"w": "term", "b": [0.4615, 0.0769, 0.5002, 0.0985]}, {"w": "using", "b": [0.505, 0.0769, 0.5479, 0.0985]}, {"w": "the", "b": [0.5527, 0.0769, 0.5778, 0.0985]}, {"w": "kernel", "b": [0.5825, 0.0769, 0.6324, 0.0985]}, {"w": "trick", "b": [0.6372, 0.0769, 0.6743, 0.0985]}]}, {"id": "b_1", "type": "equation", "text": "b = 1", "words": [{"w": "b", "b": [0.1726, 0.1216, 0.1823, 0.1422]}, {"w": "=", "b": [0.1925, 0.1218, 0.204, 0.1422]}, {"w": "1", "b": [0.215, 0.1129, 0.2245, 0.1333]}]}, {"id": "b_2", "type": "paragraph", "text": "ns ∑", "words": [{"w": "ns", "b": [0.2118, 0.1304, 0.2277, 0.1553]}, {"w": "∑", "b": [0.25, 0.117, 0.265, 0.1458]}]}, {"id": "b_3", "type": "equation", "text": "i = 1 α i > 0", "words": [{"w": "i", "b": [0.2425, 0.1365, 0.2468, 0.1529]}, {"w": "=", "b": [0.2512, 0.1366, 0.2604, 0.1529]}, {"w": "1", "b": [0.2649, 0.1366, 0.2725, 0.1529]}, {"w": "α", "b": [0.2327, 0.1546, 0.2412, 0.1711]}, {"w": "i", "b": [0.2472, 0.1486, 0.2515, 0.165]}, {"w": ">", "b": [0.2614, 0.1548, 0.2702, 0.1711]}, {"w": "0", "b": [0.2746, 0.1548, 0.2822, 0.1711]}]}, {"id": "b_5", "type": "equation", "text": "t i −wTϕ x i = 1", "words": [{"w": "t", "b": [0.2931, 0.1216, 0.2992, 0.1422]}, {"w": "i", "b": [0.3052, 0.1179, 0.3095, 0.1343]}, {"w": "−wTϕ", "b": [0.3194, 0.1179, 0.3702, 0.1422]}, {"w": "x", "b": [0.3771, 0.1212, 0.3866, 0.1422]}, {"w": "i", "b": [0.3923, 0.1179, 0.3966, 0.1343]}, {"w": "=", "b": [0.4213, 0.1218, 0.4328, 0.1422]}, {"w": "1", "b": [0.4437, 0.1129, 0.4533, 0.1333]}]}, {"id": "b_6", "type": "paragraph", "text": "ns ∑", "words": [{"w": "ns", "b": [0.4405, 0.1304, 0.4564, 0.1553]}, {"w": "∑", "b": [0.4787, 0.117, 0.4938, 0.1458]}]}, {"id": "b_7", "type": "equation", "text": "i = 1 α i > 0", "words": [{"w": "i", "b": [0.4713, 0.1365, 0.4756, 0.1529]}, {"w": "=", "b": [0.48, 0.1366, 0.4892, 0.1529]}, {"w": "1", "b": [0.4936, 0.1366, 0.5013, 0.1529]}, {"w": "α", "b": [0.4615, 0.1546, 0.47, 0.1711]}, {"w": "i", "b": [0.476, 0.1486, 0.4803, 0.165]}, {"w": ">", "b": [0.4902, 0.1548, 0.499, 0.1711]}, {"w": "0", "b": [0.5034, 0.1548, 0.511, 0.1711]}]}, {"id": "b_9", "type": "paragraph", "text": "t i −∑", "words": [{"w": "t", "b": [0.5219, 0.1216, 0.528, 0.1422]}, {"w": "i", "b": [0.5339, 0.1179, 0.5383, 0.1343]}, {"w": "−∑", "b": [0.5482, 0.117, 0.5953, 0.1458]}]}, {"id": "b_10", "type": "equation", "text": "j = 1", "words": [{"w": "j", "b": [0.5737, 0.1365, 0.5779, 0.1529]}, {"w": "=", "b": [0.5823, 0.1366, 0.5915, 0.1529]}, {"w": "1", "b": [0.5959, 0.1366, 0.6035, 0.1529]}]}, {"id": "b_12", "type": "paragraph", "text": "α j t j ϕ x j", "words": [{"w": "α", "b": [0.6057, 0.1216, 0.6164, 0.1422]}, {"w": "j", "b": [0.6241, 0.1179, 0.6283, 0.1343]}, {"w": "t", "b": [0.6338, 0.1216, 0.6399, 0.1422]}, {"w": "j", "b": [0.6475, 0.1179, 0.6517, 0.1343]}, {"w": "ϕ", "b": [0.6572, 0.1216, 0.6683, 0.1422]}, {"w": "x", "b": [0.6751, 0.1212, 0.6847, 0.1422]}, {"w": "j", "b": [0.6919, 0.1179, 0.6962, 0.1343]}]}, {"id": "b_14", "type": "paragraph", "text": "ϕ x i", "words": [{"w": "ϕ", "b": [0.7257, 0.1216, 0.7367, 0.1422]}, {"w": "x", "b": [0.7436, 0.1212, 0.7532, 0.1422]}, {"w": "i", "b": [0.7588, 0.1179, 0.7631, 0.1343]}]}, {"id": "b_15", "type": "equation", "text": "= 1", "words": [{"w": "=", "b": [0.1925, 0.1987, 0.204, 0.2191]}, {"w": "1", "b": [0.215, 0.1899, 0.2245, 0.2103]}]}, {"id": "b_16", "type": "paragraph", "text": "ns ∑", "words": [{"w": "ns", "b": [0.2118, 0.2073, 0.2277, 0.2322]}, {"w": "∑", "b": [0.25, 0.1939, 0.265, 0.2228]}]}, {"id": "b_17", "type": "equation", "text": "i = 1 α i > 0", "words": [{"w": "i", "b": [0.2425, 0.2134, 0.2468, 0.2299]}, {"w": "=", "b": [0.2512, 0.2136, 0.2605, 0.2299]}, {"w": "1", "b": [0.2649, 0.2136, 0.2725, 0.2299]}, {"w": "α", "b": [0.2327, 0.2315, 0.2412, 0.248]}, {"w": "i", "b": [0.2472, 0.2255, 0.2515, 0.242]}, {"w": ">", "b": [0.2615, 0.2317, 0.2702, 0.248]}, {"w": "0", "b": [0.2746, 0.2317, 0.2822, 0.248]}]}, {"id": "b_19", "type": "equation", "text": "t i − ∑ j = 1 α j > 0", "words": [{"w": "t", "b": [0.2931, 0.1985, 0.2992, 0.2191]}, {"w": "i", "b": [0.3052, 0.1948, 0.3095, 0.2113]}, {"w": "−", "b": [0.3194, 0.1987, 0.3309, 0.2191]}, {"w": "∑", "b": [0.3561, 0.1939, 0.3712, 0.2228]}, {"w": "j", "b": [0.3496, 0.2134, 0.3538, 0.2299]}, {"w": "=", "b": [0.3582, 0.2136, 0.3674, 0.2299]}, {"w": "1", "b": [0.3718, 0.2136, 0.3794, 0.2299]}, {"w": "α", "b": [0.3382, 0.2315, 0.3467, 0.248]}, {"w": "j", "b": [0.3543, 0.2255, 0.3585, 0.242]}, {"w": ">", "b": [0.3684, 0.2317, 0.3772, 0.248]}, {"w": "0", "b": [0.3816, 0.2317, 0.3892, 0.248]}]}, {"id": "b_21", "type": "paragraph", "text": "α j t j K x i , x j", "words": [{"w": "α", "b": [0.3931, 0.1985, 0.4038, 0.2191]}, {"w": "j", "b": [0.4115, 0.1948, 0.4157, 0.2113]}, {"w": "t", "b": [0.4212, 0.1985, 0.4273, 0.2191]}, {"w": "j", "b": [0.4349, 0.1948, 0.4391, 0.2113]}, {"w": "K", "b": [0.4446, 0.1985, 0.4576, 0.2191]}, {"w": "x", "b": [0.4655, 0.1982, 0.475, 0.2191]}, {"w": "i", "b": [0.4806, 0.1948, 0.485, 0.2113]}, {"w": ",", "b": [0.4905, 0.1987, 0.495, 0.2191]}, {"w": "x", "b": [0.4983, 0.1982, 0.5079, 0.2191]}, {"w": "j", "b": [0.5151, 0.1948, 0.5193, 0.2113]}]}, {"id": "b_22", "type": "paragraph", "text": "If you are starting to get a headache, it’s perfectly normal: it’s an unfortunate side effect of the kernel trick.", "words": [{"w": "If", "b": [0.1428, 0.2671, 0.1561, 0.2885]}, {"w": "you", "b": [0.164, 0.2671, 0.1953, 0.2885]}, {"w": "are", "b": [0.2032, 0.2671, 0.2289, 0.2885]}, {"w": "starting", "b": [0.2369, 0.2671, 0.3008, 0.2885]}, {"w": "to", "b": [0.3088, 0.2671, 0.3257, 0.2885]}, {"w": "get", "b": [0.3337, 0.2671, 0.3586, 0.2885]}, {"w": "a", "b": [0.3665, 0.2671, 0.3757, 0.2885]}, {"w": "headache,", "b": [0.3836, 0.2671, 0.4664, 0.2885]}, {"w": "it’s", "b": [0.4743, 0.2671, 0.496, 0.2885]}, {"w": "perfectly", "b": [0.504, 0.2671, 0.5765, 0.2885]}, {"w": "normal:", "b": [0.5844, 0.2671, 0.6504, 0.2885]}, {"w": "it’s", "b": [0.6583, 0.2671, 0.68, 0.2885]}, {"w": "an", "b": [0.6879, 0.2671, 0.7085, 0.2885]}, {"w": "unfortunate", "b": [0.7164, 0.2671, 0.8161, 0.2885]}, {"w": "side", "b": [0.824, 0.2671, 0.8571, 0.2885]}, {"w": "effect", "b": [0.1429, 0.2861, 0.1881, 0.3075]}, {"w": "of", "b": [0.1928, 0.2861, 0.2096, 0.3075]}, {"w": "the", "b": [0.2143, 0.2861, 0.2407, 0.3075]}, {"w": "kernel", "b": [0.2454, 0.2861, 0.2978, 0.3075]}, {"w": "trick.", "b": [0.3025, 0.2861, 0.3461, 0.3075]}]}, {"id": "b_23", "type": "paragraph", "text": "Online SVMs", "words": [{"w": "Online", "b": [0.1429, 0.3203, 0.2099, 0.3489]}, {"w": "SVMs", "b": [0.2148, 0.3203, 0.2694, 0.3489]}]}, {"id": "b_24", "type": "paragraph", "text": "Before concluding this chapter, let’s take a quick look at online SVM classifiers (recall that online learning means learning incrementally, typically as new instances arrive).", "words": [{"w": "Before", "b": [0.1429, 0.3548, 0.1978, 0.3762]}, {"w": "concluding", "b": [0.203, 0.3548, 0.2967, 0.3762]}, {"w": "this", "b": [0.3019, 0.3548, 0.3326, 0.3762]}, {"w": "chapter,", "b": [0.3379, 0.3548, 0.4038, 0.3762]}, {"w": "let’s", "b": [0.4091, 0.3548, 0.4393, 0.3762]}, {"w": "take", "b": [0.4445, 0.3548, 0.4792, 0.3762]}, {"w": "a", "b": [0.4844, 0.3548, 0.4936, 0.3762]}, {"w": "quick", "b": [0.4988, 0.3548, 0.5452, 0.3762]}, {"w": "look", "b": [0.5505, 0.3548, 0.5873, 0.3762]}, {"w": "at", "b": [0.5926, 0.3548, 0.6077, 0.3762]}, {"w": "online", "b": [0.6129, 0.3548, 0.666, 0.3762]}, {"w": "SVM", "b": [0.6712, 0.3548, 0.7143, 0.3762]}, {"w": "classifiers", "b": [0.7195, 0.3548, 0.7996, 0.3762]}, {"w": "(recall", "b": [0.8049, 0.3548, 0.8571, 0.3762]}, {"w": "that", "b": [0.1429, 0.3738, 0.1754, 0.3952]}, {"w": "online", "b": [0.1802, 0.3738, 0.2333, 0.3952]}, {"w": "learning", "b": [0.238, 0.3738, 0.3071, 0.3952]}, {"w": "means", "b": [0.3119, 0.3738, 0.366, 0.3952]}, {"w": "learning", "b": [0.3707, 0.3738, 0.4398, 0.3952]}, {"w": "incrementally,", "b": [0.4446, 0.3738, 0.5627, 0.3952]}, {"w": "typically", "b": [0.5674, 0.3738, 0.6379, 0.3952]}, {"w": "as", "b": [0.6426, 0.3738, 0.6594, 0.3952]}, {"w": "new", "b": [0.6641, 0.3738, 0.6987, 0.3952]}, {"w": "instances", "b": [0.7034, 0.3738, 0.7802, 0.3952]}, {"w": "arrive).", "b": [0.785, 0.3738, 0.8456, 0.3952]}]}, {"id": "b_25", "type": "paragraph", "text": "For linear SVM classifiers, one method is to use Gradient Descent (e.g., using SGDClassifier) to minimize the cost function in Equation 5-13, which is derived from the primal problem. Unfortunately it converges much more slowly than the methods based on QP.", "words": [{"w": "For", "b": [0.1429, 0.4019, 0.1718, 0.4233]}, {"w": "linear", "b": [0.1826, 0.4019, 0.2306, 0.4233]}, {"w": "SVM", "b": [0.2413, 0.4019, 0.2844, 0.4233]}, {"w": "classifiers,", "b": [0.2951, 0.4019, 0.3799, 0.4233]}, {"w": "one", "b": [0.3907, 0.4019, 0.4216, 0.4233]}, {"w": "method", "b": [0.4323, 0.4019, 0.4973, 0.4233]}, {"w": "is", "b": [0.508, 0.4019, 0.5213, 0.4233]}, {"w": "to", "b": [0.532, 0.4019, 0.549, 0.4233]}, {"w": "use", "b": [0.5597, 0.4019, 0.5873, 0.4233]}, {"w": "Gradient", "b": [0.598, 0.4019, 0.6726, 0.4233]}, {"w": "Descent", "b": [0.6833, 0.4019, 0.7502, 0.4233]}, {"w": "(e.g.,", "b": [0.7609, 0.4019, 0.801, 0.4233]}, {"w": "using", "b": [0.8117, 0.4019, 0.8571, 0.4233]}, {"w": "SGDClassifier)", "b": [0.1429, 0.4219, 0.2787, 0.4433]}, {"w": "to", "b": [0.2867, 0.4219, 0.3037, 0.4433]}, {"w": "minimize", "b": [0.3117, 0.4219, 0.3916, 0.4433]}, {"w": "the", "b": [0.3996, 0.4219, 0.426, 0.4433]}, {"w": "cost", "b": [0.434, 0.4219, 0.4674, 0.4433]}, {"w": "function", "b": [0.4754, 0.4219, 0.5468, 0.4433]}, {"w": "in", "b": [0.5548, 0.4219, 0.5718, 0.4433]}, {"w": "Equation", "b": [0.5798, 0.4219, 0.6561, 0.4433]}, {"w": "5-13,", "b": [0.6641, 0.4219, 0.7063, 0.4433]}, {"w": "which", "b": [0.7143, 0.4219, 0.7652, 0.4433]}, {"w": "is", "b": [0.7732, 0.4219, 0.7865, 0.4433]}, {"w": "derived", "b": [0.7945, 0.4219, 0.8571, 0.4433]}, {"w": "from", "b": [0.1429, 0.4409, 0.1844, 0.4623]}, {"w": "the", "b": [0.1929, 0.4409, 0.2192, 0.4623]}, {"w": "primal", "b": [0.2277, 0.4409, 0.2834, 0.4623]}, {"w": "problem.", "b": [0.2919, 0.4409, 0.3677, 0.4623]}, {"w": "Unfortunately", "b": [0.3762, 0.4409, 0.4941, 0.4623]}, {"w": "it", "b": [0.5026, 0.4409, 0.5145, 0.4623]}, {"w": "converges", "b": [0.523, 0.4409, 0.6058, 0.4623]}, {"w": "much", "b": [0.6143, 0.4409, 0.662, 0.4623]}, {"w": "more", "b": [0.6704, 0.4409, 0.7147, 0.4623]}, {"w": "slowly", "b": [0.7232, 0.4409, 0.7758, 0.4623]}, {"w": "than", "b": [0.7843, 0.4409, 0.8223, 0.4623]}, {"w": "the", "b": [0.8308, 0.4409, 0.8571, 0.4623]}, {"w": "methods", "b": [0.1428, 0.46, 0.2155, 0.4814]}, {"w": "based", "b": [0.2202, 0.46, 0.2675, 0.4814]}, {"w": "on", "b": [0.2722, 0.46, 0.2942, 0.4814]}, {"w": "QP.", "b": [0.299, 0.46, 0.3281, 0.4814]}]}, {"id": "b_26", "type": "equation", "text": "Equation 5-13. Linear SVM classifier cost function", "words": [{"w": "Equation", "b": [0.1726, 0.4995, 0.2473, 0.5211]}, {"w": "5-13.", "b": [0.2521, 0.4995, 0.2937, 0.5211]}, {"w": "Linear", "b": [0.2985, 0.4995, 0.3512, 0.5211]}, {"w": "SVM", "b": [0.356, 0.4995, 0.398, 0.5211]}, {"w": "classifier", "b": [0.4028, 0.4995, 0.4729, 0.5211]}, {"w": "cost", "b": [0.4777, 0.4995, 0.5083, 0.5211]}, {"w": "function", "b": [0.5131, 0.4995, 0.5812, 0.5211]}]}, {"id": "b_27", "type": "equation", "text": "J w, b = 1", "words": [{"w": "J", "b": [0.1731, 0.5409, 0.1795, 0.5615]}, {"w": "w,", "b": [0.1874, 0.5406, 0.2054, 0.5615]}, {"w": "b", "b": [0.2087, 0.5409, 0.2184, 0.5615]}, {"w": "=", "b": [0.2308, 0.5411, 0.2423, 0.5615]}, {"w": "1", "b": [0.25, 0.5323, 0.2595, 0.5527]}]}, {"id": "b_28", "type": "equation", "text": "2wTw + C ∑", "words": [{"w": "2wTw", "b": [0.25, 0.5372, 0.2991, 0.5703]}, {"w": "+", "b": [0.3234, 0.5411, 0.3349, 0.5615]}, {"w": "C", "b": [0.3591, 0.5409, 0.3717, 0.5615]}, {"w": "∑", "b": [0.3804, 0.5363, 0.3955, 0.5652]}]}, {"id": "b_29", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.3729, 0.5558, 0.3773, 0.5723]}, {"w": "=", "b": [0.3817, 0.5559, 0.3909, 0.5723]}, {"w": "1", "b": [0.3953, 0.5559, 0.4029, 0.5723]}]}, {"id": "b_31", "type": "equation", "text": "max 0, 1 −t i wTx i + b", "words": [{"w": "max", "b": [0.4051, 0.5409, 0.4399, 0.5615]}, {"w": "0,", "b": [0.4467, 0.5411, 0.4608, 0.5615]}, {"w": "1", "b": [0.4641, 0.5411, 0.4736, 0.5615]}, {"w": "−t", "b": [0.478, 0.5409, 0.5, 0.5615]}, {"w": "i", "b": [0.506, 0.5372, 0.5103, 0.5537]}, {"w": "wTx", "b": [0.5227, 0.5372, 0.5561, 0.5615]}, {"w": "i", "b": [0.5617, 0.5372, 0.566, 0.5537]}, {"w": "+", "b": [0.5759, 0.5411, 0.5874, 0.5615]}, {"w": "b", "b": [0.5919, 0.5409, 0.6015, 0.5615]}]}, {"id": "b_32", "type": "paragraph", "text": "The first sum in the cost function will push the model to have a small weight vector w, leading to a larger margin. The second sum computes the total of all margin viola‐ tions. An instance’s margin violation is equal to 0 if it is located off the street and on the correct side, or else it is proportional to the distance to the correct side of the street. Minimizing this term ensures that the model makes the margin violations as small and as few as possible", "words": [{"w": "The", "b": [0.1429, 0.5913, 0.1757, 0.6127]}, {"w": "first", "b": [0.1818, 0.5913, 0.2152, 0.6127]}, {"w": "sum", "b": [0.2213, 0.5913, 0.2571, 0.6127]}, {"w": "in", "b": [0.2632, 0.5913, 0.2802, 0.6127]}, {"w": "the", "b": [0.2862, 0.5913, 0.3126, 0.6127]}, {"w": "cost", "b": [0.3187, 0.5913, 0.3521, 0.6127]}, {"w": "function", "b": [0.3582, 0.5913, 0.4296, 0.6127]}, {"w": "will", "b": [0.4356, 0.5913, 0.466, 0.6127]}, {"w": "push", "b": [0.4721, 0.5913, 0.5129, 0.6127]}, {"w": "the", "b": [0.519, 0.5913, 0.5453, 0.6127]}, {"w": "model", "b": [0.5514, 0.5913, 0.6042, 0.6127]}, {"w": "to", "b": [0.6103, 0.5913, 0.6272, 0.6127]}, {"w": "have", "b": [0.6333, 0.5913, 0.6717, 0.6127]}, {"w": "a", "b": [0.6778, 0.5913, 0.6869, 0.6127]}, {"w": "small", "b": [0.693, 0.5913, 0.7374, 0.6127]}, {"w": "weight", "b": [0.7435, 0.5913, 0.799, 0.6127]}, {"w": "vector", "b": [0.8051, 0.5913, 0.8571, 0.6127]}, {"w": "w,", "b": [0.1429, 0.6098, 0.1618, 0.6318]}, {"w": "leading", "b": [0.167, 0.6104, 0.228, 0.6318]}, {"w": "to", "b": [0.2332, 0.6104, 0.2501, 0.6318]}, {"w": "a", "b": [0.2553, 0.6104, 0.2645, 0.6318]}, {"w": "larger", "b": [0.2696, 0.6104, 0.3181, 0.6318]}, {"w": "margin.", "b": [0.3233, 0.6104, 0.3887, 0.6318]}, {"w": "The", "b": [0.3938, 0.6104, 0.4267, 0.6318]}, {"w": "second", "b": [0.4318, 0.6104, 0.4902, 0.6318]}, {"w": "sum", "b": [0.4953, 0.6104, 0.5311, 0.6318]}, {"w": "computes", "b": [0.5363, 0.6104, 0.6172, 0.6318]}, {"w": "the", "b": [0.6224, 0.6104, 0.6487, 0.6318]}, {"w": "total", "b": [0.6539, 0.6104, 0.6916, 0.6318]}, {"w": "of", "b": [0.6968, 0.6104, 0.7136, 0.6318]}, {"w": "all", "b": [0.7188, 0.6104, 0.7384, 0.6318]}, {"w": "margin", "b": [0.7436, 0.6104, 0.8043, 0.6318]}, {"w": "viola‐", "b": [0.8094, 0.6104, 0.8571, 0.6318]}, {"w": "tions.", "b": [0.1429, 0.6294, 0.1892, 0.6508]}, {"w": "An", "b": [0.195, 0.6294, 0.2208, 0.6508]}, {"w": "instance’s", "b": [0.2267, 0.6294, 0.3049, 0.6508]}, {"w": "margin", "b": [0.3108, 0.6294, 0.3714, 0.6508]}, {"w": "violation", "b": [0.3772, 0.6294, 0.4511, 0.6508]}, {"w": "is", "b": [0.4569, 0.6294, 0.4701, 0.6508]}, {"w": "equal", "b": [0.4759, 0.6294, 0.5209, 0.6508]}, {"w": "to", "b": [0.5267, 0.6294, 0.5437, 0.6508]}, {"w": "0", "b": [0.5495, 0.6294, 0.5595, 0.6508]}, {"w": "if", "b": [0.5654, 0.6294, 0.5771, 0.6508]}, {"w": "it", "b": [0.5829, 0.6294, 0.5949, 0.6508]}, {"w": "is", "b": [0.6007, 0.6294, 0.6139, 0.6508]}, {"w": "located", "b": [0.6197, 0.6294, 0.6794, 0.6508]}, {"w": "off", "b": [0.6852, 0.6294, 0.7082, 0.6508]}, {"w": "the", "b": [0.714, 0.6294, 0.7403, 0.6508]}, {"w": "street", "b": [0.7462, 0.6294, 0.7919, 0.6508]}, {"w": "and", "b": [0.7978, 0.6294, 0.8293, 0.6508]}, {"w": "on", "b": [0.8351, 0.6294, 0.8572, 0.6508]}, {"w": "the", "b": [0.1429, 0.6484, 0.1692, 0.6699]}, {"w": "correct", "b": [0.1767, 0.6484, 0.2356, 0.6699]}, {"w": "side,", "b": [0.2431, 0.6484, 0.2809, 0.6699]}, {"w": "or", "b": [0.2884, 0.6484, 0.3067, 0.6699]}, {"w": "else", "b": [0.3142, 0.6484, 0.3448, 0.6699]}, {"w": "it", "b": [0.3523, 0.6484, 0.3642, 0.6699]}, {"w": "is", "b": [0.3717, 0.6484, 0.3849, 0.6699]}, {"w": "proportional", "b": [0.3924, 0.6484, 0.4993, 0.6699]}, {"w": "to", "b": [0.5068, 0.6484, 0.5238, 0.6699]}, {"w": "the", "b": [0.5313, 0.6484, 0.5576, 0.6699]}, {"w": "distance", "b": [0.5651, 0.6484, 0.6339, 0.6699]}, {"w": "to", "b": [0.6413, 0.6484, 0.6583, 0.6699]}, {"w": "the", "b": [0.6658, 0.6484, 0.6921, 0.6699]}, {"w": "correct", "b": [0.6996, 0.6484, 0.7585, 0.6699]}, {"w": "side", "b": [0.766, 0.6484, 0.7991, 0.6699]}, {"w": "of", "b": [0.8065, 0.6484, 0.8233, 0.6699]}, {"w": "the", "b": [0.8308, 0.6484, 0.8571, 0.6699]}, {"w": "street.", "b": [0.1429, 0.6675, 0.1934, 0.6889]}, {"w": "Minimizing", "b": [0.2001, 0.6675, 0.2994, 0.6889]}, {"w": "this", "b": [0.3061, 0.6675, 0.3368, 0.6889]}, {"w": "term", "b": [0.3435, 0.6675, 0.3835, 0.6889]}, {"w": "ensures", "b": [0.3902, 0.6675, 0.4534, 0.6889]}, {"w": "that", "b": [0.4601, 0.6675, 0.4927, 0.6889]}, {"w": "the", "b": [0.4994, 0.6675, 0.5257, 0.6889]}, {"w": "model", "b": [0.5324, 0.6675, 0.5853, 0.6889]}, {"w": "makes", "b": [0.592, 0.6675, 0.645, 0.6889]}, {"w": "the", "b": [0.6517, 0.6675, 0.6781, 0.6889]}, {"w": "margin", "b": [0.6848, 0.6675, 0.7454, 0.6889]}, {"w": "violations", "b": [0.7522, 0.6675, 0.8336, 0.6889]}, {"w": "as", "b": [0.8403, 0.6675, 0.8571, 0.6889]}, {"w": "small", "b": [0.1428, 0.6865, 0.1872, 0.708]}, {"w": "and", "b": [0.192, 0.6865, 0.2235, 0.708]}, {"w": "as", "b": [0.2282, 0.6865, 0.245, 0.708]}, {"w": "few", "b": [0.2498, 0.6865, 0.2791, 0.708]}, {"w": "as", "b": [0.2838, 0.6865, 0.3006, 0.708]}, {"w": "possible", "b": [0.3053, 0.6865, 0.3724, 0.708]}]}, {"id": "b_33", "type": "paragraph", "text": "Hinge Loss", "words": [{"w": "Hinge", "b": [0.4479, 0.7337, 0.506, 0.7609]}, {"w": "Loss", "b": [0.5107, 0.7337, 0.552, 0.7609]}]}, {"id": "b_34", "type": "paragraph", "text": "The function max(0, 1 – t) is called the hinge loss function (represented below). It is equal to 0 when t ≥ 1. Its derivative (slope) is equal to –1 if t < 1 and 0 if t > 1. It is not differentiable at t = 1, but just like for Lasso Regression (see “Lasso Regression” on page 139) you can still use Gradient Descent using any subderivative at t = 1 (i.e., any value between –1 and 0).", "words": [{"w": "The", "b": [0.1592, 0.7654, 0.1905, 0.7858]}, {"w": "function", "b": [0.1965, 0.7654, 0.2645, 0.7858]}, {"w": "max(0,", "b": [0.2705, 0.7652, 0.326, 0.7858]}, {"w": "1", "b": [0.332, 0.7654, 0.3415, 0.7858]}, {"w": "–", "b": [0.3476, 0.7654, 0.3579, 0.7858]}, {"w": "t)", "b": [0.3639, 0.7652, 0.3768, 0.7858]}, {"w": "is", "b": [0.3829, 0.7654, 0.3955, 0.7858]}, {"w": "called", "b": [0.4015, 0.7654, 0.4475, 0.7858]}, {"w": "the", "b": [0.4535, 0.7654, 0.4786, 0.7858]}, {"w": "hinge", "b": [0.4846, 0.7652, 0.5262, 0.7858]}, {"w": "loss", "b": [0.5322, 0.7652, 0.5594, 0.7858]}, {"w": "function", "b": [0.5655, 0.7654, 0.6335, 0.7858]}, {"w": "(represented", "b": [0.6395, 0.7654, 0.7395, 0.7858]}, {"w": "below).", "b": [0.7455, 0.7654, 0.8041, 0.7858]}, {"w": "It", "b": [0.8101, 0.7654, 0.8222, 0.7858]}, {"w": "is", "b": [0.8282, 0.7654, 0.8408, 0.7858]}, {"w": "equal", "b": [0.1592, 0.7836, 0.2021, 0.804]}, {"w": "to", "b": [0.2068, 0.7836, 0.223, 0.804]}, {"w": "0", "b": [0.2277, 0.7836, 0.2372, 0.804]}, {"w": "when", "b": [0.2419, 0.7836, 0.2854, 0.804]}, {"w": "t", "b": [0.2901, 0.7834, 0.2962, 0.804]}, {"w": "≥", "b": [0.3009, 0.7836, 0.3124, 0.804]}, {"w": "1.", "b": [0.3171, 0.7836, 0.3312, 0.804]}, {"w": "Its", "b": [0.3359, 0.7836, 0.3552, 0.804]}, {"w": "derivative", "b": [0.36, 0.7836, 0.4381, 0.804]}, {"w": "(slope)", "b": [0.4428, 0.7836, 0.4978, 0.804]}, {"w": "is", "b": [0.5025, 0.7836, 0.5151, 0.804]}, {"w": "equal", "b": [0.5198, 0.7836, 0.5626, 0.804]}, {"w": "to", "b": [0.5674, 0.7836, 0.5835, 0.804]}, {"w": "–1", "b": [0.5883, 0.7836, 0.6081, 0.804]}, {"w": "if", "b": [0.6128, 0.7836, 0.624, 0.804]}, {"w": "t", "b": [0.6287, 0.7834, 0.6348, 0.804]}, {"w": "<", "b": [0.6396, 0.7836, 0.6505, 0.804]}, {"w": "1", "b": [0.6552, 0.7836, 0.6648, 0.804]}, {"w": "and", "b": [0.6695, 0.7836, 0.6995, 0.804]}, {"w": "0", "b": [0.7042, 0.7836, 0.7138, 0.804]}, {"w": "if", "b": [0.7185, 0.7836, 0.7297, 0.804]}, {"w": "t", "b": [0.7344, 0.7834, 0.7405, 0.804]}, {"w": ">", "b": [0.7452, 0.7836, 0.7562, 0.804]}, {"w": "1.", "b": [0.7609, 0.7836, 0.7749, 0.804]}, {"w": "It", "b": [0.7797, 0.7836, 0.7917, 0.804]}, {"w": "is", "b": [0.7964, 0.7836, 0.809, 0.804]}, {"w": "not", "b": [0.8137, 0.7836, 0.8408, 0.804]}, {"w": "differentiable", "b": [0.1592, 0.8017, 0.2651, 0.8221]}, {"w": "at", "b": [0.2718, 0.8017, 0.2862, 0.8221]}, {"w": "t", "b": [0.2929, 0.8015, 0.299, 0.8221]}, {"w": "=", "b": [0.3058, 0.8017, 0.3173, 0.8221]}, {"w": "1,", "b": [0.324, 0.8017, 0.3381, 0.8221]}, {"w": "but", "b": [0.3448, 0.8017, 0.3715, 0.8221]}, {"w": "just", "b": [0.3782, 0.8017, 0.4072, 0.8221]}, {"w": "like", "b": [0.4139, 0.8017, 0.4425, 0.8221]}, {"w": "for", "b": [0.4493, 0.8017, 0.4726, 0.8221]}, {"w": "Lasso", "b": [0.4794, 0.8017, 0.5234, 0.8221]}, {"w": "Regression", "b": [0.5302, 0.8017, 0.6168, 0.8221]}, {"w": "(see", "b": [0.6236, 0.8017, 0.6546, 0.8221]}, {"w": "“Lasso", "b": [0.6613, 0.8017, 0.7133, 0.8221]}, {"w": "Regression”", "b": [0.72, 0.8017, 0.8131, 0.8221]}, {"w": "on", "b": [0.8198, 0.8017, 0.8408, 0.8221]}, {"w": "page", "b": [0.1592, 0.8198, 0.196, 0.8402]}, {"w": "139)", "b": [0.2013, 0.8198, 0.2367, 0.8402]}, {"w": "you", "b": [0.242, 0.8198, 0.2717, 0.8402]}, {"w": "can", "b": [0.277, 0.8198, 0.3049, 0.8402]}, {"w": "still", "b": [0.3102, 0.8198, 0.3389, 0.8402]}, {"w": "use", "b": [0.3441, 0.8198, 0.3704, 0.8402]}, {"w": "Gradient", "b": [0.3756, 0.8198, 0.4466, 0.8402]}, {"w": "Descent", "b": [0.4519, 0.8198, 0.5155, 0.8402]}, {"w": "using", "b": [0.5208, 0.8198, 0.564, 0.8402]}, {"w": "any", "b": [0.5693, 0.8198, 0.5975, 0.8402]}, {"w": "subderivative", "b": [0.6027, 0.8197, 0.7054, 0.8402]}, {"w": "at", "b": [0.7106, 0.8198, 0.725, 0.8402]}, {"w": "t", "b": [0.7303, 0.8197, 0.7364, 0.8402]}, {"w": "=", "b": [0.7416, 0.8198, 0.7531, 0.8402]}, {"w": "1", "b": [0.7584, 0.8198, 0.7679, 0.8402]}, {"w": "(i.e.,", "b": [0.7731, 0.8198, 0.8073, 0.8402]}, {"w": "any", "b": [0.8126, 0.8198, 0.8408, 0.8402]}, {"w": "value", "b": [0.1592, 0.838, 0.2011, 0.8584]}, {"w": "between", "b": [0.2056, 0.838, 0.2715, 0.8584]}, {"w": "–1", "b": [0.276, 0.838, 0.2958, 0.8584]}, {"w": "and", "b": [0.3003, 0.838, 0.3304, 0.8584]}, {"w": "0).", "b": [0.3349, 0.838, 0.3558, 0.8584]}]}, {"id": "b_35", "type": "paragraph", "text": "174 | Chapter 5: Support Vector Machines", "words": [{"w": "174", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "5:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Support", "b": [0.2673, 0.9225, 0.3142, 0.9388]}, {"w": "Vector", "b": [0.317, 0.9225, 0.3547, 0.9388]}, {"w": "Machines", "b": [0.3576, 0.9225, 0.413, 0.9388]}]}]}, {"page": 201, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "8 “Incremental and Decremental Support Vector Machine Learning,” G. Cauwenberghs, T. Poggio (2001).", "words": [{"w": "8", "b": [0.1451, 0.8568, 0.1518, 0.871]}, {"w": "“Incremental", "b": [0.1587, 0.8553, 0.2424, 0.8716]}, {"w": "and", "b": [0.246, 0.8553, 0.2701, 0.8716]}, {"w": "Decremental", "b": [0.2737, 0.8553, 0.3554, 0.8716]}, {"w": "Support", "b": [0.359, 0.8553, 0.4104, 0.8716]}, {"w": "Vector", "b": [0.414, 0.8553, 0.4559, 0.8716]}, {"w": "Machine", "b": [0.4595, 0.8553, 0.5152, 0.8716]}, {"w": "Learning,”", "b": [0.5188, 0.8553, 0.5838, 0.8716]}, {"w": "G.", "b": [0.5874, 0.8553, 0.6024, 0.8716]}, {"w": "Cauwenberghs,", "b": [0.606, 0.8553, 0.704, 0.8716]}, {"w": "T.", "b": [0.7076, 0.8553, 0.7194, 0.8716]}, {"w": "Poggio", "b": [0.723, 0.8553, 0.7668, 0.8716]}, {"w": "(2001).", "b": [0.7704, 0.8553, 0.8155, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "9 “Fast Kernel Classifiers with Online and Active Learning,“ A. Bordes, S. Ertekin, J. Weston, L. Bottou (2005).", "words": [{"w": "9", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Fast", "b": [0.1587, 0.8749, 0.1908, 0.8912]}, {"w": "Kernel", "b": [0.1944, 0.8749, 0.2367, 0.8912]}, {"w": "Classifiers", "b": [0.2403, 0.8749, 0.3052, 0.8912]}, {"w": "with", "b": [0.3088, 0.8749, 0.3373, 0.8912]}, {"w": "Online", "b": [0.3409, 0.8749, 0.3851, 0.8912]}, {"w": "and", "b": [0.3887, 0.8749, 0.4127, 0.8912]}, {"w": "Active", "b": [0.4163, 0.8749, 0.4568, 0.8912]}, {"w": "Learning,“", "b": [0.4604, 0.8749, 0.5275, 0.8912]}, {"w": "A.", "b": [0.5311, 0.8749, 0.5457, 0.8912]}, {"w": "Bordes,", "b": [0.5493, 0.8749, 0.5975, 0.8912]}, {"w": "S.", "b": [0.6011, 0.8749, 0.6123, 0.8912]}, {"w": "Ertekin,", "b": [0.6159, 0.8749, 0.6668, 0.8912]}, {"w": "J.", "b": [0.6704, 0.8749, 0.6786, 0.8912]}, {"w": "Weston,", "b": [0.6822, 0.8749, 0.7339, 0.8912]}, {"w": "L.", "b": [0.7375, 0.8749, 0.7496, 0.8912]}, {"w": "Bottou", "b": [0.7532, 0.8749, 0.7972, 0.8912]}, {"w": "(2005).", "b": [0.8008, 0.8749, 0.8459, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "It is also possible to implement online kernelized SVMs—for example, using “Incre‐ mental and Decremental SVM Learning”8 or “Fast Kernel Classifiers with Online and Active Learning.”9 However, these are implemented in Matlab and C++. For large- scale nonlinear problems, you may want to consider using neural networks instead (see Part II).", "words": [{"w": "It", "b": [0.1429, 0.2955, 0.1555, 0.3169]}, {"w": "is", "b": [0.1616, 0.2955, 0.1749, 0.3169]}, {"w": "also", "b": [0.181, 0.2955, 0.2137, 0.3169]}, {"w": "possible", "b": [0.2198, 0.2955, 0.287, 0.3169]}, {"w": "to", "b": [0.2931, 0.2955, 0.3101, 0.3169]}, {"w": "implement", "b": [0.3162, 0.2955, 0.4068, 0.3169]}, {"w": "online", "b": [0.4129, 0.2955, 0.466, 0.3169]}, {"w": "kernelized", "b": [0.4722, 0.2955, 0.5588, 0.3169]}, {"w": "SVMs—for", "b": [0.5649, 0.2955, 0.6594, 0.3169]}, {"w": "example,", "b": [0.6655, 0.2955, 0.7398, 0.3169]}, {"w": "using", "b": [0.746, 0.2955, 0.7914, 0.3169]}, {"w": "“Incre‐", "b": [0.7975, 0.2955, 0.8571, 0.3169]}, {"w": "mental", "b": [0.1429, 0.3145, 0.2005, 0.3359]}, {"w": "and", "b": [0.2058, 0.3145, 0.2373, 0.3359]}, {"w": "Decremental", "b": [0.2426, 0.3145, 0.3499, 0.3359]}, {"w": "SVM", "b": [0.3551, 0.3145, 0.3982, 0.3359]}, {"w": "Learning”8", "b": [0.4035, 0.3145, 0.4922, 0.3359]}, {"w": "or", "b": [0.4975, 0.3145, 0.5158, 0.3359]}, {"w": "“Fast", "b": [0.5211, 0.3145, 0.5631, 0.3359]}, {"w": "Kernel", "b": [0.5684, 0.3145, 0.624, 0.3359]}, {"w": "Classifiers", "b": [0.6293, 0.3145, 0.7144, 0.3359]}, {"w": "with", "b": [0.7197, 0.3145, 0.757, 0.3359]}, {"w": "Online", "b": [0.7623, 0.3145, 0.8203, 0.3359]}, {"w": "and", "b": [0.8256, 0.3145, 0.8571, 0.3359]}, {"w": "Active", "b": [0.1429, 0.3336, 0.196, 0.355]}, {"w": "Learning.”9", "b": [0.2037, 0.3336, 0.2947, 0.355]}, {"w": "However,", "b": [0.3025, 0.3336, 0.3814, 0.355]}, {"w": "these", "b": [0.3892, 0.3336, 0.432, 0.355]}, {"w": "are", "b": [0.4398, 0.3336, 0.4655, 0.355]}, {"w": "implemented", "b": [0.4733, 0.3336, 0.5837, 0.355]}, {"w": "in", "b": [0.5915, 0.3336, 0.6085, 0.355]}, {"w": "Matlab", "b": [0.6162, 0.3336, 0.6746, 0.355]}, {"w": "and", "b": [0.6823, 0.3336, 0.7139, 0.355]}, {"w": "C++.", "b": [0.7217, 0.3336, 0.7644, 0.355]}, {"w": "For", "b": [0.7722, 0.3336, 0.8012, 0.355]}, {"w": "large-", "b": [0.809, 0.3336, 0.8571, 0.355]}, {"w": "scale", "b": [0.1429, 0.3526, 0.1826, 0.374]}, {"w": "nonlinear", "b": [0.189, 0.3526, 0.2704, 0.374]}, {"w": "problems,", "b": [0.2769, 0.3526, 0.3603, 0.374]}, {"w": "you", "b": [0.3668, 0.3526, 0.3981, 0.374]}, {"w": "may", "b": [0.4045, 0.3526, 0.4399, 0.374]}, {"w": "want", "b": [0.4464, 0.3526, 0.4872, 0.374]}, {"w": "to", "b": [0.4936, 0.3526, 0.5106, 0.374]}, {"w": "consider", "b": [0.5171, 0.3526, 0.5887, 0.374]}, {"w": "using", "b": [0.5952, 0.3526, 0.6406, 0.374]}, {"w": "neural", "b": [0.6471, 0.3526, 0.7006, 0.374]}, {"w": "networks", "b": [0.707, 0.3526, 0.7842, 0.374]}, {"w": "instead", "b": [0.7907, 0.3526, 0.8507, 0.374]}, {"w": "(see", "b": [0.1428, 0.3717, 0.1754, 0.3931]}, {"w": "Part", "b": [0.1801, 0.3717, 0.2146, 0.3931]}, {"w": "II).", "b": [0.2194, 0.3717, 0.2455, 0.3931]}]}, {"id": "b_3", "type": "paragraph", "text": "Exercises", "words": [{"w": "Exercises", "b": [0.1429, 0.4061, 0.2533, 0.4403]}]}, {"id": "b_4", "type": "paragraph", "text": "1. What is the fundamental idea behind Support Vector Machines?", "words": [{"w": "1.", "b": [0.1534, 0.4533, 0.1681, 0.4747]}, {"w": "What", "b": [0.1786, 0.4533, 0.225, 0.4747]}, {"w": "is", "b": [0.2298, 0.4533, 0.243, 0.4747]}, {"w": "the", "b": [0.2477, 0.4533, 0.274, 0.4747]}, {"w": "fundamental", "b": [0.2788, 0.4533, 0.3852, 0.4747]}, {"w": "idea", "b": [0.39, 0.4533, 0.4245, 0.4747]}, {"w": "behind", "b": [0.4293, 0.4533, 0.4878, 0.4747]}, {"w": "Support", "b": [0.4925, 0.4533, 0.56, 0.4747]}, {"w": "Vector", "b": [0.5648, 0.4533, 0.6198, 0.4747]}, {"w": "Machines?", "b": [0.6245, 0.4533, 0.7131, 0.4747]}]}, {"id": "b_5", "type": "paragraph", "text": "2. What is a support vector?", "words": [{"w": "2.", "b": [0.1534, 0.4784, 0.1682, 0.4998]}, {"w": "What", "b": [0.1786, 0.4784, 0.225, 0.4998]}, {"w": "is", "b": [0.2298, 0.4784, 0.243, 0.4998]}, {"w": "a", "b": [0.2477, 0.4784, 0.2569, 0.4998]}, {"w": "support", "b": [0.2616, 0.4784, 0.3268, 0.4998]}, {"w": "vector?", "b": [0.3316, 0.4784, 0.3915, 0.4998]}]}, {"id": "b_6", "type": "paragraph", "text": "3. Why is it important to scale the inputs when using SVMs?", "words": [{"w": "3.", "b": [0.1534, 0.5035, 0.1682, 0.5249]}, {"w": "Why", "b": [0.1786, 0.5035, 0.219, 0.5249]}, {"w": "is", "b": [0.2237, 0.5035, 0.237, 0.5249]}, {"w": "it", "b": [0.2417, 0.5035, 0.2536, 0.5249]}, {"w": "important", "b": [0.2584, 0.5035, 0.3427, 0.5249]}, {"w": "to", "b": [0.3475, 0.5035, 0.3644, 0.5249]}, {"w": "scale", "b": [0.3692, 0.5035, 0.4089, 0.5249]}, {"w": "the", "b": [0.4136, 0.5035, 0.44, 0.5249]}, {"w": "inputs", "b": [0.4447, 0.5035, 0.4973, 0.5249]}, {"w": "when", "b": [0.502, 0.5035, 0.5476, 0.5249]}, {"w": "using", "b": [0.5524, 0.5035, 0.5978, 0.5249]}, {"w": "SVMs?", "b": [0.6025, 0.5035, 0.6611, 0.5249]}]}, {"id": "b_7", "type": "paragraph", "text": "4. Can an SVM classifier output a confidence score when it classifies an instance? What about a probability?", "words": [{"w": "4.", "b": [0.1534, 0.5286, 0.1682, 0.55]}, {"w": "Can", "b": [0.1786, 0.5286, 0.213, 0.55]}, {"w": "an", "b": [0.2196, 0.5286, 0.2402, 0.55]}, {"w": "SVM", "b": [0.2468, 0.5286, 0.2899, 0.55]}, {"w": "classifier", "b": [0.2966, 0.5286, 0.369, 0.55]}, {"w": "output", "b": [0.3756, 0.5286, 0.432, 0.55]}, {"w": "a", "b": [0.4387, 0.5286, 0.4478, 0.55]}, {"w": "confidence", "b": [0.4545, 0.5286, 0.546, 0.55]}, {"w": "score", "b": [0.5526, 0.5286, 0.5963, 0.55]}, {"w": "when", "b": [0.603, 0.5286, 0.6486, 0.55]}, {"w": "it", "b": [0.6553, 0.5286, 0.6672, 0.55]}, {"w": "classifies", "b": [0.6738, 0.5286, 0.7462, 0.55]}, {"w": "an", "b": [0.7529, 0.5286, 0.7734, 0.55]}, {"w": "instance?", "b": [0.7801, 0.5286, 0.8571, 0.55]}, {"w": "What", "b": [0.1786, 0.5476, 0.225, 0.569]}, {"w": "about", "b": [0.2298, 0.5476, 0.2775, 0.569]}, {"w": "a", "b": [0.2823, 0.5476, 0.2914, 0.569]}, {"w": "probability?", "b": [0.2961, 0.5476, 0.396, 0.569]}]}, {"id": "b_8", "type": "paragraph", "text": "5. Should you use the primal or the dual form of the SVM problem to train a model on a training set with millions of instances and hundreds of features?", "words": [{"w": "5.", "b": [0.1534, 0.5727, 0.1682, 0.5941]}, {"w": "Should", "b": [0.1786, 0.5727, 0.2375, 0.5941]}, {"w": "you", "b": [0.2425, 0.5727, 0.2737, 0.5941]}, {"w": "use", "b": [0.2787, 0.5727, 0.3063, 0.5941]}, {"w": "the", "b": [0.3113, 0.5727, 0.3376, 0.5941]}, {"w": "primal", "b": [0.3426, 0.5727, 0.3983, 0.5941]}, {"w": "or", "b": [0.4033, 0.5727, 0.4216, 0.5941]}, {"w": "the", "b": [0.4266, 0.5727, 0.4529, 0.5941]}, {"w": "dual", "b": [0.4579, 0.5727, 0.4944, 0.5941]}, {"w": "form", "b": [0.4994, 0.5727, 0.5409, 0.5941]}, {"w": "of", "b": [0.5459, 0.5727, 0.5627, 0.5941]}, {"w": "the", "b": [0.5677, 0.5727, 0.594, 0.5941]}, {"w": "SVM", "b": [0.599, 0.5727, 0.6421, 0.5941]}, {"w": "problem", "b": [0.647, 0.5727, 0.7181, 0.5941]}, {"w": "to", "b": [0.7231, 0.5727, 0.74, 0.5941]}, {"w": "train", "b": [0.745, 0.5727, 0.7852, 0.5941]}, {"w": "a", "b": [0.7902, 0.5727, 0.7993, 0.5941]}, {"w": "model", "b": [0.8043, 0.5727, 0.8571, 0.5941]}, {"w": "on", "b": [0.1786, 0.5918, 0.2006, 0.6132]}, {"w": "a", "b": [0.2053, 0.5918, 0.2145, 0.6132]}, {"w": "training", "b": [0.2192, 0.5918, 0.2861, 0.6132]}, {"w": "set", "b": [0.2909, 0.5918, 0.3137, 0.6132]}, {"w": "with", "b": [0.3184, 0.5918, 0.3558, 0.6132]}, {"w": "millions", "b": [0.3605, 0.5918, 0.4289, 0.6132]}, {"w": "of", "b": [0.4337, 0.5918, 0.4505, 0.6132]}, {"w": "instances", "b": [0.4552, 0.5918, 0.532, 0.6132]}, {"w": "and", "b": [0.5368, 0.5918, 0.5683, 0.6132]}, {"w": "hundreds", "b": [0.573, 0.5918, 0.6524, 0.6132]}, {"w": "of", "b": [0.6572, 0.5918, 0.674, 0.6132]}, {"w": "features?", "b": [0.6787, 0.5918, 0.752, 0.6132]}]}, {"id": "b_9", "type": "paragraph", "text": "6. Say you trained an SVM classifier with an RBF kernel. It seems to underfit the training set: should you increase or decrease γ (gamma)? What about C?", "words": [{"w": "6.", "b": [0.1534, 0.6169, 0.1682, 0.6383]}, {"w": "Say", "b": [0.1786, 0.6169, 0.2068, 0.6383]}, {"w": "you", "b": [0.2137, 0.6169, 0.245, 0.6383]}, {"w": "trained", "b": [0.252, 0.6169, 0.312, 0.6383]}, {"w": "an", "b": [0.319, 0.6169, 0.3395, 0.6383]}, {"w": "SVM", "b": [0.3465, 0.6169, 0.3896, 0.6383]}, {"w": "classifier", "b": [0.3966, 0.6169, 0.469, 0.6383]}, {"w": "with", "b": [0.476, 0.6169, 0.5133, 0.6383]}, {"w": "an", "b": [0.5203, 0.6169, 0.5408, 0.6383]}, {"w": "RBF", "b": [0.5478, 0.6169, 0.584, 0.6383]}, {"w": "kernel.", "b": [0.5909, 0.6169, 0.6481, 0.6383]}, {"w": "It", "b": [0.6551, 0.6169, 0.6677, 0.6383]}, {"w": "seems", "b": [0.6747, 0.6169, 0.7248, 0.6383]}, {"w": "to", "b": [0.7317, 0.6169, 0.7487, 0.6383]}, {"w": "underfit", "b": [0.7557, 0.6169, 0.8238, 0.6383]}, {"w": "the", "b": [0.8308, 0.6169, 0.8571, 0.6383]}, {"w": "training", "b": [0.1786, 0.6368, 0.2455, 0.6582]}, {"w": "set:", "b": [0.2502, 0.6368, 0.2778, 0.6582]}, {"w": "should", "b": [0.2826, 0.6368, 0.3393, 0.6582]}, {"w": "you", "b": [0.344, 0.6368, 0.3753, 0.6582]}, {"w": "increase", "b": [0.38, 0.6368, 0.448, 0.6582]}, {"w": "or", "b": [0.4528, 0.6368, 0.4711, 0.6582]}, {"w": "decrease", "b": [0.4758, 0.6368, 0.5467, 0.6582]}, {"w": "γ", "b": [0.5515, 0.6366, 0.5613, 0.6582]}, {"w": "(gamma)?", "b": [0.5661, 0.6368, 0.6379, 0.6582]}, {"w": "What", "b": [0.6426, 0.6368, 0.6891, 0.6582]}, {"w": "about", "b": [0.6938, 0.6368, 0.7416, 0.6582]}, {"w": "C?", "b": [0.7463, 0.6368, 0.7641, 0.6582]}]}, {"id": "b_10", "type": "paragraph", "text": "7. How should you set the QP parameters (H, f, A, and b) to solve the soft margin linear SVM classifier problem using an off-the-shelf QP solver?", "words": [{"w": "7.", "b": [0.1534, 0.6619, 0.1682, 0.6833]}, {"w": "How", "b": [0.1786, 0.6619, 0.2189, 0.6833]}, {"w": "should", "b": [0.2248, 0.6619, 0.2815, 0.6833]}, {"w": "you", "b": [0.2874, 0.6619, 0.3187, 0.6833]}, {"w": "set", "b": [0.3246, 0.6619, 0.3474, 0.6833]}, {"w": "the", "b": [0.3533, 0.6619, 0.3796, 0.6833]}, {"w": "QP", "b": [0.3855, 0.6619, 0.4128, 0.6833]}, {"w": "parameters", "b": [0.4187, 0.6619, 0.5121, 0.6833]}, {"w": "(H,", "b": [0.518, 0.6614, 0.5463, 0.6833]}, {"w": "f,", "b": [0.5522, 0.6614, 0.5638, 0.6833]}, {"w": "A,", "b": [0.5697, 0.6614, 0.5892, 0.6833]}, {"w": "and", "b": [0.5951, 0.6619, 0.6266, 0.6833]}, {"w": "b)", "b": [0.6325, 0.6614, 0.6508, 0.6833]}, {"w": "to", "b": [0.6567, 0.6619, 0.6737, 0.6833]}, {"w": "solve", "b": [0.6796, 0.6619, 0.7217, 0.6833]}, {"w": "the", "b": [0.7276, 0.6619, 0.7539, 0.6833]}, {"w": "soft", "b": [0.7598, 0.6619, 0.7906, 0.6833]}, {"w": "margin", "b": [0.7965, 0.6619, 0.8571, 0.6833]}, {"w": "linear", "b": [0.1786, 0.681, 0.2266, 0.7024]}, {"w": "SVM", "b": [0.2313, 0.681, 0.2744, 0.7024]}, {"w": "classifier", "b": [0.2791, 0.681, 0.3515, 0.7024]}, {"w": "problem", "b": [0.3563, 0.681, 0.4273, 0.7024]}, {"w": "using", "b": [0.432, 0.681, 0.4775, 0.7024]}, {"w": "an", "b": [0.4822, 0.681, 0.5027, 0.7024]}, {"w": "off-the-shelf", "b": [0.5075, 0.681, 0.6107, 0.7024]}, {"w": "QP", "b": [0.6154, 0.681, 0.6426, 0.7024]}, {"w": "solver?", "b": [0.6474, 0.681, 0.705, 0.7024]}]}, {"id": "b_11", "type": "paragraph", "text": "8. Train a LinearSVC on a linearly separable dataset. Then train an SVC and a SGDClassifier on the same dataset. See if you can get them to produce roughly the same model.", "words": [{"w": "8.", "b": [0.1534, 0.7069, 0.1682, 0.7284]}, {"w": "Train", "b": [0.1786, 0.7069, 0.2235, 0.7284]}, {"w": "a", "b": [0.2332, 0.7069, 0.2423, 0.7284]}, {"w": "LinearSVC", "b": [0.2519, 0.7101, 0.341, 0.7252]}, {"w": "on", "b": [0.3506, 0.7069, 0.3726, 0.7284]}, {"w": "a", "b": [0.3823, 0.7069, 0.3914, 0.7284]}, {"w": "linearly", "b": [0.401, 0.7069, 0.4638, 0.7284]}, {"w": "separable", "b": [0.4734, 0.7069, 0.5516, 0.7284]}, {"w": "dataset.", "b": [0.5612, 0.7069, 0.6241, 0.7284]}, {"w": "Then", "b": [0.6337, 0.7069, 0.6779, 0.7284]}, {"w": "train", "b": [0.6875, 0.7069, 0.7277, 0.7284]}, {"w": "an", "b": [0.7374, 0.7069, 0.7579, 0.7284]}, {"w": "SVC", "b": [0.7675, 0.7101, 0.7972, 0.7252]}, {"w": "and", "b": [0.8068, 0.7069, 0.8384, 0.7284]}, {"w": "a", "b": [0.848, 0.7069, 0.8571, 0.7284]}, {"w": "SGDClassifier", "b": [0.1786, 0.7301, 0.3072, 0.7452]}, {"w": "on", "b": [0.3131, 0.7269, 0.3351, 0.7483]}, {"w": "the", "b": [0.341, 0.7269, 0.3674, 0.7483]}, {"w": "same", "b": [0.3733, 0.7269, 0.416, 0.7483]}, {"w": "dataset.", "b": [0.4219, 0.7269, 0.4847, 0.7483]}, {"w": "See", "b": [0.4906, 0.7269, 0.5182, 0.7483]}, {"w": "if", "b": [0.5241, 0.7269, 0.5358, 0.7483]}, {"w": "you", "b": [0.5417, 0.7269, 0.573, 0.7483]}, {"w": "can", "b": [0.5789, 0.7269, 0.6082, 0.7483]}, {"w": "get", "b": [0.6141, 0.7269, 0.6391, 0.7483]}, {"w": "them", "b": [0.645, 0.7269, 0.6884, 0.7483]}, {"w": "to", "b": [0.6943, 0.7269, 0.7112, 0.7483]}, {"w": "produce", "b": [0.7171, 0.7269, 0.7861, 0.7483]}, {"w": "roughly", "b": [0.792, 0.7269, 0.8572, 0.7483]}, {"w": "the", "b": [0.1786, 0.7459, 0.2049, 0.7674]}, {"w": "same", "b": [0.2096, 0.7459, 0.2523, 0.7674]}, {"w": "model.", "b": [0.2571, 0.7459, 0.3146, 0.7674]}]}, {"id": "b_12", "type": "paragraph", "text": "9. Train an SVM classifier on the MNIST dataset. Since SVM classifiers are binary classifiers, you will need to use one-versus-all to classify all 10 digits. You may", "words": [{"w": "9.", "b": [0.1534, 0.771, 0.1682, 0.7924]}, {"w": "Train", "b": [0.1786, 0.771, 0.2235, 0.7924]}, {"w": "an", "b": [0.2297, 0.771, 0.2503, 0.7924]}, {"w": "SVM", "b": [0.2565, 0.771, 0.2996, 0.7924]}, {"w": "classifier", "b": [0.3058, 0.771, 0.3782, 0.7924]}, {"w": "on", "b": [0.3844, 0.771, 0.4064, 0.7924]}, {"w": "the", "b": [0.4126, 0.771, 0.439, 0.7924]}, {"w": "MNIST", "b": [0.4452, 0.771, 0.509, 0.7924]}, {"w": "dataset.", "b": [0.5153, 0.771, 0.5781, 0.7924]}, {"w": "Since", "b": [0.5843, 0.771, 0.6288, 0.7924]}, {"w": "SVM", "b": [0.635, 0.771, 0.6781, 0.7924]}, {"w": "classifiers", "b": [0.6843, 0.771, 0.7644, 0.7924]}, {"w": "are", "b": [0.7706, 0.771, 0.7963, 0.7924]}, {"w": "binary", "b": [0.8025, 0.771, 0.8571, 0.7924]}, {"w": "classifiers,", "b": [0.1786, 0.7901, 0.2634, 0.8115]}, {"w": "you", "b": [0.2707, 0.7901, 0.3019, 0.8115]}, {"w": "will", "b": [0.3091, 0.7901, 0.3395, 0.8115]}, {"w": "need", "b": [0.3468, 0.7901, 0.3869, 0.8115]}, {"w": "to", "b": [0.3941, 0.7901, 0.4111, 0.8115]}, {"w": "use", "b": [0.4184, 0.7901, 0.4459, 0.8115]}, {"w": "one-versus-all", "b": [0.4532, 0.7901, 0.5712, 0.8115]}, {"w": "to", "b": [0.5784, 0.7901, 0.5954, 0.8115]}, {"w": "classify", "b": [0.6026, 0.7901, 0.6628, 0.8115]}, {"w": "all", "b": [0.6701, 0.7901, 0.6897, 0.8115]}, {"w": "10", "b": [0.697, 0.7901, 0.717, 0.8115]}, {"w": "digits.", "b": [0.7242, 0.7901, 0.7749, 0.8115]}, {"w": "You", "b": [0.7821, 0.7901, 0.8145, 0.8115]}, {"w": "may", "b": [0.8218, 0.7901, 0.8571, 0.8115]}]}, {"id": "b_13", "type": "paragraph", "text": "Exercises | 175", "words": [{"w": "Exercises", "b": [0.7433, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "175", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 202, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "want to tune the hyperparameters using small validation sets to speed up the pro‐ cess. What accuracy can you reach?", "words": [{"w": "want", "b": [0.1786, 0.0791, 0.2193, 0.1005]}, {"w": "to", "b": [0.2242, 0.0791, 0.2411, 0.1005]}, {"w": "tune", "b": [0.246, 0.0791, 0.2836, 0.1005]}, {"w": "the", "b": [0.2885, 0.0791, 0.3148, 0.1005]}, {"w": "hyperparameters", "b": [0.3196, 0.0791, 0.4608, 0.1005]}, {"w": "using", "b": [0.4656, 0.0791, 0.511, 0.1005]}, {"w": "small", "b": [0.5159, 0.0791, 0.5603, 0.1005]}, {"w": "validation", "b": [0.5651, 0.0791, 0.6484, 0.1005]}, {"w": "sets", "b": [0.6533, 0.0791, 0.6838, 0.1005]}, {"w": "to", "b": [0.6886, 0.0791, 0.7056, 0.1005]}, {"w": "speed", "b": [0.7104, 0.0791, 0.7577, 0.1005]}, {"w": "up", "b": [0.7625, 0.0791, 0.7845, 0.1005]}, {"w": "the", "b": [0.7893, 0.0791, 0.8156, 0.1005]}, {"w": "pro‐", "b": [0.8204, 0.0791, 0.8571, 0.1005]}, {"w": "cess.", "b": [0.1786, 0.0981, 0.2163, 0.1195]}, {"w": "What", "b": [0.221, 0.0981, 0.2675, 0.1195]}, {"w": "accuracy", "b": [0.2722, 0.0981, 0.3453, 0.1195]}, {"w": "can", "b": [0.35, 0.0981, 0.3794, 0.1195]}, {"w": "you", "b": [0.3841, 0.0981, 0.4153, 0.1195]}, {"w": "reach?", "b": [0.4201, 0.0981, 0.4736, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "10. Train an SVM regressor on the California housing dataset.", "words": [{"w": "10.", "b": [0.1434, 0.1232, 0.1682, 0.1446]}, {"w": "Train", "b": [0.1786, 0.1232, 0.2235, 0.1446]}, {"w": "an", "b": [0.2283, 0.1232, 0.2488, 0.1446]}, {"w": "SVM", "b": [0.2535, 0.1232, 0.2966, 0.1446]}, {"w": "regressor", "b": [0.3014, 0.1232, 0.3779, 0.1446]}, {"w": "on", "b": [0.3826, 0.1232, 0.4047, 0.1446]}, {"w": "the", "b": [0.4094, 0.1232, 0.4357, 0.1446]}, {"w": "California", "b": [0.4405, 0.1232, 0.525, 0.1446]}, {"w": "housing", "b": [0.5297, 0.1232, 0.5969, 0.1446]}, {"w": "dataset.", "b": [0.6016, 0.1232, 0.6645, 0.1446]}]}, {"id": "b_2", "type": "paragraph", "text": "Solutions to these exercises are available in ???.", "words": [{"w": "Solutions", "b": [0.1429, 0.1574, 0.2213, 0.1788]}, {"w": "to", "b": [0.226, 0.1574, 0.243, 0.1788]}, {"w": "these", "b": [0.2477, 0.1574, 0.2906, 0.1788]}, {"w": "exercises", "b": [0.2953, 0.1574, 0.3691, 0.1788]}, {"w": "are", "b": [0.3738, 0.1574, 0.3996, 0.1788]}, {"w": "available", "b": [0.4043, 0.1574, 0.4766, 0.1788]}, {"w": "in", "b": [0.4813, 0.1574, 0.4983, 0.1788]}, {"w": "???.", "b": [0.503, 0.1574, 0.5314, 0.1788]}]}, {"id": "b_3", "type": "paragraph", "text": "176 | Chapter 5: Support Vector Machines", "words": [{"w": "176", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "5:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Support", "b": [0.2673, 0.9225, 0.3142, 0.9388]}, {"w": "Vector", "b": [0.317, 0.9225, 0.3547, 0.9388]}, {"w": "Machines", "b": [0.3575, 0.9225, 0.413, 0.9388]}]}]}, {"page": 203, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "CHAPTER 6 Decision Trees", "words": [{"w": "CHAPTER", "b": [0.7398, 0.1146, 0.8383, 0.1451]}, {"w": "6", "b": [0.8435, 0.1146, 0.8571, 0.1451]}, {"w": "Decision", "b": [0.6249, 0.1478, 0.7619, 0.1935]}, {"w": "Trees", "b": [0.7698, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_1", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 6 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.3643, 0.3102, 0.3839]}, {"w": "Early", "b": [0.3165, 0.3643, 0.3563, 0.3839]}, {"w": "Release", "b": [0.3626, 0.3643, 0.4189, 0.3839]}, {"w": "ebooks,", "b": [0.4251, 0.3643, 0.4831, 0.3839]}, {"w": "you", "b": [0.4894, 0.3643, 0.518, 0.3839]}, {"w": "get", "b": [0.5243, 0.3643, 0.5471, 0.3839]}, {"w": "books", "b": [0.5534, 0.3643, 0.5989, 0.3839]}, {"w": "in", "b": [0.6052, 0.3643, 0.6207, 0.3839]}, {"w": "their", "b": [0.627, 0.3643, 0.6632, 0.3839]}, {"w": "earliest", "b": [0.6695, 0.3643, 0.7239, 0.3839]}, {"w": "form—", "b": [0.7301, 0.3643, 0.7857, 0.3839]}, {"w": "the", "b": [0.2714, 0.3818, 0.2955, 0.4013]}, {"w": "author’s", "b": [0.3012, 0.3818, 0.3615, 0.4013]}, {"w": "raw", "b": [0.3672, 0.3818, 0.3954, 0.4013]}, {"w": "and", "b": [0.4011, 0.3818, 0.4299, 0.4013]}, {"w": "unedited", "b": [0.4357, 0.3818, 0.5034, 0.4013]}, {"w": "content", "b": [0.5091, 0.3818, 0.5667, 0.4013]}, {"w": "as", "b": [0.5725, 0.3818, 0.5878, 0.4013]}, {"w": "he", "b": [0.5936, 0.3818, 0.6118, 0.4013]}, {"w": "or", "b": [0.6175, 0.3818, 0.6343, 0.4013]}, {"w": "she", "b": [0.6401, 0.3818, 0.6653, 0.4013]}, {"w": "writes—so", "b": [0.671, 0.3818, 0.7514, 0.4013]}, {"w": "you", "b": [0.7571, 0.3818, 0.7857, 0.4013]}, {"w": "can", "b": [0.2714, 0.3992, 0.2982, 0.4188]}, {"w": "take", "b": [0.306, 0.3992, 0.3377, 0.4188]}, {"w": "advantage", "b": [0.3455, 0.3992, 0.4223, 0.4188]}, {"w": "of", "b": [0.4301, 0.3992, 0.4454, 0.4188]}, {"w": "these", "b": [0.4532, 0.3992, 0.4923, 0.4188]}, {"w": "technologies", "b": [0.5001, 0.3992, 0.596, 0.4188]}, {"w": "long", "b": [0.6038, 0.3992, 0.6376, 0.4188]}, {"w": "before", "b": [0.6454, 0.3992, 0.6937, 0.4188]}, {"w": "the", "b": [0.7014, 0.3992, 0.7255, 0.4188]}, {"w": "official", "b": [0.7333, 0.3992, 0.7857, 0.4188]}, {"w": "release", "b": [0.2714, 0.4166, 0.3229, 0.4362]}, {"w": "of", "b": [0.3292, 0.4166, 0.3445, 0.4362]}, {"w": "these", "b": [0.3507, 0.4166, 0.3899, 0.4362]}, {"w": "titles.", "b": [0.3961, 0.4166, 0.4371, 0.4362]}, {"w": "The", "b": [0.4433, 0.4166, 0.4733, 0.4362]}, {"w": "following", "b": [0.4795, 0.4166, 0.5517, 0.4362]}, {"w": "will", "b": [0.558, 0.4166, 0.5857, 0.4362]}, {"w": "be", "b": [0.592, 0.4166, 0.6097, 0.4362]}, {"w": "Chapter", "b": [0.616, 0.4166, 0.6777, 0.4362]}, {"w": "6", "b": [0.684, 0.4166, 0.6931, 0.4362]}, {"w": "in", "b": [0.6993, 0.4166, 0.7149, 0.4362]}, {"w": "the", "b": [0.7211, 0.4166, 0.7452, 0.4362]}, {"w": "final", "b": [0.7514, 0.4166, 0.7857, 0.4362]}, {"w": "release", "b": [0.2714, 0.434, 0.3229, 0.4536]}, {"w": "of", "b": [0.3273, 0.434, 0.3426, 0.4536]}, {"w": "the", "b": [0.3469, 0.434, 0.371, 0.4536]}, {"w": "book.", "b": [0.3753, 0.434, 0.4182, 0.4536]}]}, {"id": "b_2", "type": "paragraph", "text": "Like SVMs, Decision Trees are versatile Machine Learning algorithms that can per‐ form both classification and regression tasks, and even multioutput tasks. They are very powerful algorithms, capable of fitting complex datasets. For example, in Chap‐ ter 2 you trained a DecisionTreeRegressor model on the California housing dataset, fitting it perfectly (actually overfitting it).", "words": [{"w": "Like", "b": [0.1429, 0.4739, 0.1788, 0.4953]}, {"w": "SVMs,", "b": [0.1862, 0.4739, 0.2417, 0.4953]}, {"w": "Decision", "b": [0.2491, 0.4737, 0.319, 0.4953]}, {"w": "Trees", "b": [0.3265, 0.4737, 0.3681, 0.4953]}, {"w": "are", "b": [0.3755, 0.4739, 0.4013, 0.4953]}, {"w": "versatile", "b": [0.4087, 0.4739, 0.4774, 0.4953]}, {"w": "Machine", "b": [0.4848, 0.4739, 0.5579, 0.4953]}, {"w": "Learning", "b": [0.5653, 0.4739, 0.6404, 0.4953]}, {"w": "algorithms", "b": [0.6478, 0.4739, 0.7381, 0.4953]}, {"w": "that", "b": [0.7455, 0.4739, 0.7781, 0.4953]}, {"w": "can", "b": [0.7855, 0.4739, 0.8148, 0.4953]}, {"w": "per‐", "b": [0.8222, 0.4739, 0.8571, 0.4953]}, {"w": "form", "b": [0.1428, 0.4929, 0.1844, 0.5143]}, {"w": "both", "b": [0.1915, 0.4929, 0.2302, 0.5143]}, {"w": "classification", "b": [0.2373, 0.4929, 0.3446, 0.5143]}, {"w": "and", "b": [0.3517, 0.4929, 0.3833, 0.5143]}, {"w": "regression", "b": [0.3903, 0.4929, 0.4761, 0.5143]}, {"w": "tasks,", "b": [0.4832, 0.4929, 0.5291, 0.5143]}, {"w": "and", "b": [0.5362, 0.4929, 0.5677, 0.5143]}, {"w": "even", "b": [0.5748, 0.4929, 0.6135, 0.5143]}, {"w": "multioutput", "b": [0.6206, 0.4929, 0.7219, 0.5143]}, {"w": "tasks.", "b": [0.729, 0.4929, 0.7749, 0.5143]}, {"w": "They", "b": [0.7819, 0.4929, 0.8243, 0.5143]}, {"w": "are", "b": [0.8314, 0.4929, 0.8571, 0.5143]}, {"w": "very", "b": [0.1429, 0.512, 0.1793, 0.5334]}, {"w": "powerful", "b": [0.1851, 0.512, 0.26, 0.5334]}, {"w": "algorithms,", "b": [0.2658, 0.512, 0.3608, 0.5334]}, {"w": "capable", "b": [0.3666, 0.512, 0.4289, 0.5334]}, {"w": "of", "b": [0.4347, 0.512, 0.4515, 0.5334]}, {"w": "fitting", "b": [0.4573, 0.512, 0.5085, 0.5334]}, {"w": "complex", "b": [0.5143, 0.512, 0.5853, 0.5334]}, {"w": "datasets.", "b": [0.5911, 0.512, 0.6616, 0.5334]}, {"w": "For", "b": [0.6674, 0.512, 0.6964, 0.5334]}, {"w": "example,", "b": [0.7022, 0.512, 0.7765, 0.5334]}, {"w": "in", "b": [0.7823, 0.512, 0.7993, 0.5334]}, {"w": "Chap‐", "b": [0.8051, 0.512, 0.8571, 0.5334]}, {"w": "ter", "b": [0.1429, 0.5319, 0.1658, 0.5533]}, {"w": "2", "b": [0.1705, 0.5319, 0.1805, 0.5533]}, {"w": "you", "b": [0.1862, 0.5319, 0.2175, 0.5533]}, {"w": "trained", "b": [0.2227, 0.5319, 0.2828, 0.5533]}, {"w": "a", "b": [0.288, 0.5319, 0.2971, 0.5533]}, {"w": "DecisionTreeRegressor", "b": [0.3023, 0.5351, 0.5101, 0.5502]}, {"w": "model", "b": [0.5154, 0.5319, 0.5682, 0.5533]}, {"w": "on", "b": [0.5734, 0.5319, 0.5954, 0.5533]}, {"w": "the", "b": [0.6006, 0.5319, 0.627, 0.5533]}, {"w": "California", "b": [0.6322, 0.5319, 0.7167, 0.5533]}, {"w": "housing", "b": [0.7219, 0.5319, 0.7891, 0.5533]}, {"w": "dataset,", "b": [0.7943, 0.5319, 0.8571, 0.5533]}, {"w": "fitting", "b": [0.1429, 0.551, 0.194, 0.5724]}, {"w": "it", "b": [0.1988, 0.551, 0.2107, 0.5724]}, {"w": "perfectly", "b": [0.2154, 0.551, 0.288, 0.5724]}, {"w": "(actually", "b": [0.2927, 0.551, 0.3645, 0.5724]}, {"w": "overfitting", "b": [0.3692, 0.551, 0.4573, 0.5724]}, {"w": "it).", "b": [0.462, 0.551, 0.4859, 0.5724]}]}, {"id": "b_3", "type": "paragraph", "text": "Decision Trees are also the fundamental components of Random Forests (see Chap‐ ter 7), which are among the most powerful Machine Learning algorithms available today.", "words": [{"w": "Decision", "b": [0.1429, 0.5791, 0.2167, 0.6005]}, {"w": "Trees", "b": [0.2229, 0.5791, 0.2671, 0.6005]}, {"w": "are", "b": [0.2734, 0.5791, 0.2991, 0.6005]}, {"w": "also", "b": [0.3053, 0.5791, 0.338, 0.6005]}, {"w": "the", "b": [0.3443, 0.5791, 0.3706, 0.6005]}, {"w": "fundamental", "b": [0.3769, 0.5791, 0.4833, 0.6005]}, {"w": "components", "b": [0.4896, 0.5791, 0.5925, 0.6005]}, {"w": "of", "b": [0.5987, 0.5791, 0.6155, 0.6005]}, {"w": "Random", "b": [0.6217, 0.5791, 0.6943, 0.6005]}, {"w": "Forests", "b": [0.7005, 0.5791, 0.76, 0.6005]}, {"w": "(see", "b": [0.7663, 0.5791, 0.7988, 0.6005]}, {"w": "Chap‐", "b": [0.8051, 0.5791, 0.8571, 0.6005]}, {"w": "ter", "b": [0.1429, 0.5981, 0.1658, 0.6195]}, {"w": "7),", "b": [0.1732, 0.5981, 0.1951, 0.6195]}, {"w": "which", "b": [0.2025, 0.5981, 0.2534, 0.6195]}, {"w": "are", "b": [0.2608, 0.5981, 0.2865, 0.6195]}, {"w": "among", "b": [0.2939, 0.5981, 0.3519, 0.6195]}, {"w": "the", "b": [0.3593, 0.5981, 0.3856, 0.6195]}, {"w": "most", "b": [0.393, 0.5981, 0.4346, 0.6195]}, {"w": "powerful", "b": [0.442, 0.5981, 0.5169, 0.6195]}, {"w": "Machine", "b": [0.5243, 0.5981, 0.5974, 0.6195]}, {"w": "Learning", "b": [0.6048, 0.5981, 0.6798, 0.6195]}, {"w": "algorithms", "b": [0.6872, 0.5981, 0.7775, 0.6195]}, {"w": "available", "b": [0.7849, 0.5981, 0.8572, 0.6195]}, {"w": "today.", "b": [0.1429, 0.6172, 0.1924, 0.6386]}]}, {"id": "b_4", "type": "paragraph", "text": "In this chapter we will start by discussing how to train, visualize, and make predic‐ tions with Decision Trees. Then we will go through the CART training algorithm used by Scikit-Learn, and we will discuss how to regularize trees and use them for regression tasks. Finally, we will discuss some of the limitations of Decision Trees.", "words": [{"w": "In", "b": [0.1429, 0.6453, 0.1614, 0.6667]}, {"w": "this", "b": [0.1681, 0.6453, 0.1988, 0.6667]}, {"w": "chapter", "b": [0.2055, 0.6453, 0.268, 0.6667]}, {"w": "we", "b": [0.2748, 0.6453, 0.2979, 0.6667]}, {"w": "will", "b": [0.3046, 0.6453, 0.335, 0.6667]}, {"w": "start", "b": [0.3417, 0.6453, 0.3789, 0.6667]}, {"w": "by", "b": [0.3857, 0.6453, 0.4058, 0.6667]}, {"w": "discussing", "b": [0.4125, 0.6453, 0.4986, 0.6667]}, {"w": "how", "b": [0.5054, 0.6453, 0.5414, 0.6667]}, {"w": "to", "b": [0.5481, 0.6453, 0.5651, 0.6667]}, {"w": "train,", "b": [0.5718, 0.6453, 0.6167, 0.6667]}, {"w": "visualize,", "b": [0.6235, 0.6453, 0.6998, 0.6667]}, {"w": "and", "b": [0.7065, 0.6453, 0.738, 0.6667]}, {"w": "make", "b": [0.7447, 0.6453, 0.7901, 0.6667]}, {"w": "predic‐", "b": [0.7968, 0.6453, 0.8571, 0.6667]}, {"w": "tions", "b": [0.1429, 0.6643, 0.1845, 0.6858]}, {"w": "with", "b": [0.1926, 0.6643, 0.2299, 0.6858]}, {"w": "Decision", "b": [0.238, 0.6643, 0.3118, 0.6858]}, {"w": "Trees.", "b": [0.32, 0.6643, 0.3689, 0.6858]}, {"w": "Then", "b": [0.377, 0.6643, 0.4213, 0.6858]}, {"w": "we", "b": [0.4294, 0.6643, 0.4525, 0.6858]}, {"w": "will", "b": [0.4606, 0.6643, 0.491, 0.6858]}, {"w": "go", "b": [0.4991, 0.6643, 0.5195, 0.6858]}, {"w": "through", "b": [0.5276, 0.6643, 0.5954, 0.6858]}, {"w": "the", "b": [0.6035, 0.6643, 0.6298, 0.6858]}, {"w": "CART", "b": [0.638, 0.6643, 0.6913, 0.6858]}, {"w": "training", "b": [0.6994, 0.6643, 0.7664, 0.6858]}, {"w": "algorithm", "b": [0.7745, 0.6643, 0.8571, 0.6858]}, {"w": "used", "b": [0.1428, 0.6834, 0.1814, 0.7048]}, {"w": "by", "b": [0.1887, 0.6834, 0.2088, 0.7048]}, {"w": "Scikit-Learn,", "b": [0.2161, 0.6834, 0.3232, 0.7048]}, {"w": "and", "b": [0.3304, 0.6834, 0.362, 0.7048]}, {"w": "we", "b": [0.3693, 0.6834, 0.3924, 0.7048]}, {"w": "will", "b": [0.3997, 0.6834, 0.4301, 0.7048]}, {"w": "discuss", "b": [0.4373, 0.6834, 0.4967, 0.7048]}, {"w": "how", "b": [0.504, 0.6834, 0.54, 0.7048]}, {"w": "to", "b": [0.5473, 0.6834, 0.5643, 0.7048]}, {"w": "regularize", "b": [0.5716, 0.6834, 0.6543, 0.7048]}, {"w": "trees", "b": [0.6616, 0.6834, 0.701, 0.7048]}, {"w": "and", "b": [0.7083, 0.6834, 0.7398, 0.7048]}, {"w": "use", "b": [0.7471, 0.6834, 0.7747, 0.7048]}, {"w": "them", "b": [0.7819, 0.6834, 0.8253, 0.7048]}, {"w": "for", "b": [0.8326, 0.6834, 0.8571, 0.7048]}, {"w": "regression", "b": [0.1429, 0.7024, 0.2287, 0.7238]}, {"w": "tasks.", "b": [0.2334, 0.7024, 0.2793, 0.7238]}, {"w": "Finally,", "b": [0.284, 0.7024, 0.3445, 0.7238]}, {"w": "we", "b": [0.3492, 0.7024, 0.3723, 0.7238]}, {"w": "will", "b": [0.3771, 0.7024, 0.4075, 0.7238]}, {"w": "discuss", "b": [0.4122, 0.7024, 0.4716, 0.7238]}, {"w": "some", "b": [0.4763, 0.7024, 0.5205, 0.7238]}, {"w": "of", "b": [0.5252, 0.7024, 0.542, 0.7238]}, {"w": "the", "b": [0.5468, 0.7024, 0.5731, 0.7238]}, {"w": "limitations", "b": [0.5778, 0.7024, 0.668, 0.7238]}, {"w": "of", "b": [0.6728, 0.7024, 0.6896, 0.7238]}, {"w": "Decision", "b": [0.6943, 0.7024, 0.7681, 0.7238]}, {"w": "Trees.", "b": [0.7728, 0.7024, 0.8218, 0.7238]}]}, {"id": "b_5", "type": "paragraph", "text": "Training and Visualizing a Decision Tree", "words": [{"w": "Training", "b": [0.1429, 0.7368, 0.246, 0.7711]}, {"w": "and", "b": [0.252, 0.7368, 0.2991, 0.7711]}, {"w": "Visualizing", "b": [0.305, 0.7368, 0.4397, 0.7711]}, {"w": "a", "b": [0.4456, 0.7368, 0.4605, 0.7711]}, {"w": "Decision", "b": [0.4664, 0.7368, 0.5693, 0.7711]}, {"w": "Tree", "b": [0.5752, 0.7368, 0.6291, 0.7711]}]}, {"id": "b_6", "type": "paragraph", "text": "To understand Decision Trees, let’s just build one and take a look at how it makes pre‐ dictions. The following code trains a DecisionTreeClassifier on the iris dataset (see Chapter 4):", "words": [{"w": "To", "b": [0.1429, 0.778, 0.1643, 0.7994]}, {"w": "understand", "b": [0.1691, 0.778, 0.2646, 0.7994]}, {"w": "Decision", "b": [0.2694, 0.778, 0.3432, 0.7994]}, {"w": "Trees,", "b": [0.3479, 0.778, 0.3969, 0.7994]}, {"w": "let’s", "b": [0.4016, 0.778, 0.4318, 0.7994]}, {"w": "just", "b": [0.4366, 0.778, 0.467, 0.7994]}, {"w": "build", "b": [0.4717, 0.778, 0.5152, 0.7994]}, {"w": "one", "b": [0.5199, 0.778, 0.5508, 0.7994]}, {"w": "and", "b": [0.5555, 0.778, 0.5871, 0.7994]}, {"w": "take", "b": [0.5918, 0.778, 0.6265, 0.7994]}, {"w": "a", "b": [0.6312, 0.778, 0.6404, 0.7994]}, {"w": "look", "b": [0.6451, 0.778, 0.6819, 0.7994]}, {"w": "at", "b": [0.6867, 0.778, 0.7018, 0.7994]}, {"w": "how", "b": [0.7065, 0.778, 0.7425, 0.7994]}, {"w": "it", "b": [0.7473, 0.778, 0.7592, 0.7994]}, {"w": "makes", "b": [0.7639, 0.778, 0.817, 0.7994]}, {"w": "pre‐", "b": [0.8217, 0.778, 0.8566, 0.7994]}, {"w": "dictions.", "b": [0.1429, 0.798, 0.2146, 0.8194]}, {"w": "The", "b": [0.223, 0.798, 0.2558, 0.8194]}, {"w": "following", "b": [0.2642, 0.798, 0.3431, 0.8194]}, {"w": "code", "b": [0.3515, 0.798, 0.3908, 0.8194]}, {"w": "trains", "b": [0.3992, 0.798, 0.447, 0.8194]}, {"w": "a", "b": [0.4554, 0.798, 0.4646, 0.8194]}, {"w": "DecisionTreeClassifier", "b": [0.4729, 0.8011, 0.6906, 0.8162]}, {"w": "on", "b": [0.699, 0.798, 0.721, 0.8194]}, {"w": "the", "b": [0.7294, 0.798, 0.7557, 0.8194]}, {"w": "iris", "b": [0.7641, 0.798, 0.7907, 0.8194]}, {"w": "dataset", "b": [0.799, 0.798, 0.8571, 0.8194]}, {"w": "(see", "b": [0.1428, 0.817, 0.1754, 0.8384]}, {"w": "Chapter", "b": [0.1801, 0.817, 0.2477, 0.8384]}, {"w": "4):", "b": [0.2525, 0.817, 0.2744, 0.8384]}]}, {"id": "b_7", "type": "paragraph", "text": "from sklearn.datasets import load_iris from sklearn.tree import DecisionTreeClassifier", "words": [{"w": "from", "b": [0.1766, 0.849, 0.2103, 0.8618]}, {"w": "sklearn.datasets", "b": [0.2188, 0.849, 0.3537, 0.8618]}, {"w": "import", "b": [0.3621, 0.849, 0.4127, 0.8618]}, {"w": "load_iris", "b": [0.4211, 0.849, 0.497, 0.8618]}, {"w": "from", "b": [0.1766, 0.8644, 0.2103, 0.8773]}, {"w": "sklearn.tree", "b": [0.2188, 0.8644, 0.3199, 0.8773]}, {"w": "import", "b": [0.3284, 0.8644, 0.379, 0.8773]}, {"w": "DecisionTreeClassifier", "b": [0.3874, 0.8644, 0.5729, 0.8773]}]}, {"id": "b_8", "type": "paragraph", "text": "177", "words": [{"w": "177", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 204, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 Graphviz is an open source graph visualization software package, available at http://www.graphviz.org/.", "words": [{"w": "1", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "Graphviz", "b": [0.1587, 0.8749, 0.2173, 0.8912]}, {"w": "is", "b": [0.2209, 0.8749, 0.231, 0.8912]}, {"w": "an", "b": [0.2346, 0.8749, 0.2503, 0.8912]}, {"w": "open", "b": [0.2539, 0.8749, 0.2857, 0.8912]}, {"w": "source", "b": [0.2893, 0.8749, 0.331, 0.8912]}, {"w": "graph", "b": [0.3346, 0.8749, 0.3714, 0.8912]}, {"w": "visualization", "b": [0.375, 0.8749, 0.4553, 0.8912]}, {"w": "software", "b": [0.4589, 0.8749, 0.5128, 0.8912]}, {"w": "package,", "b": [0.5164, 0.8749, 0.5711, 0.8912]}, {"w": "available", "b": [0.5747, 0.8749, 0.6297, 0.8912]}, {"w": "at", "b": [0.6333, 0.8749, 0.6449, 0.8912]}, {"w": "http://www.graphviz.org/.", "b": [0.6485, 0.8748, 0.8081, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "iris = load_iris() X = iris.data[:, 2:] # petal length and width y = iris.target", "words": [{"w": "iris", "b": [0.1766, 0.0829, 0.2103, 0.0958]}, {"w": "=", "b": [0.2187, 0.0829, 0.2272, 0.0958]}, {"w": "load_iris()", "b": [0.2356, 0.0829, 0.3284, 0.0958]}, {"w": "X", "b": [0.1766, 0.0983, 0.185, 0.1112]}, {"w": "=", "b": [0.1934, 0.0983, 0.2019, 0.1112]}, {"w": "iris.data[:,", "b": [0.2103, 0.0983, 0.3115, 0.1112]}, {"w": "2:]", "b": [0.3199, 0.0983, 0.3452, 0.1112]}, {"w": "#", "b": [0.3537, 0.0983, 0.3621, 0.1112]}, {"w": "petal", "b": [0.3705, 0.0983, 0.4127, 0.1112]}, {"w": "length", "b": [0.4211, 0.0983, 0.4717, 0.1112]}, {"w": "and", "b": [0.4802, 0.0983, 0.5055, 0.1112]}, {"w": "width", "b": [0.5139, 0.0983, 0.556, 0.1112]}, {"w": "y", "b": [0.1766, 0.1138, 0.185, 0.1266]}, {"w": "=", "b": [0.1934, 0.1138, 0.2019, 0.1266]}, {"w": "iris.target", "b": [0.2103, 0.1138, 0.3031, 0.1266]}]}, {"id": "b_2", "type": "equation", "text": "tree_clf = DecisionTreeClassifier(max_depth=2) tree_clf.fit(X, y)", "words": [{"w": "tree_clf", "b": [0.1766, 0.1446, 0.244, 0.1574]}, {"w": "=", "b": [0.2525, 0.1446, 0.2609, 0.1574]}, {"w": "DecisionTreeClassifier(max_depth=2)", "b": [0.2693, 0.1446, 0.5645, 0.1574]}, {"w": "tree_clf.fit(X,", "b": [0.1766, 0.16, 0.3031, 0.1729]}, {"w": "y)", "b": [0.3115, 0.16, 0.3284, 0.1729]}]}, {"id": "b_3", "type": "paragraph", "text": "You can visualize the trained Decision Tree by first using the export_graphviz() method to output a graph definition file called iris_tree.dot:", "words": [{"w": "You", "b": [0.1429, 0.1815, 0.1752, 0.203]}, {"w": "can", "b": [0.1828, 0.1815, 0.2121, 0.203]}, {"w": "visualize", "b": [0.2197, 0.1815, 0.2912, 0.203]}, {"w": "the", "b": [0.2988, 0.1815, 0.3251, 0.203]}, {"w": "trained", "b": [0.3327, 0.1815, 0.3927, 0.203]}, {"w": "Decision", "b": [0.4003, 0.1815, 0.4741, 0.203]}, {"w": "Tree", "b": [0.4816, 0.1815, 0.5182, 0.203]}, {"w": "by", "b": [0.5258, 0.1815, 0.5459, 0.203]}, {"w": "first", "b": [0.5535, 0.1815, 0.5869, 0.203]}, {"w": "using", "b": [0.5945, 0.1815, 0.6399, 0.203]}, {"w": "the", "b": [0.6475, 0.1815, 0.6738, 0.203]}, {"w": "export_graphviz()", "b": [0.6814, 0.1847, 0.8496, 0.1998]}, {"w": "method", "b": [0.1429, 0.2006, 0.2079, 0.222]}, {"w": "to", "b": [0.2126, 0.2006, 0.2296, 0.222]}, {"w": "output", "b": [0.2343, 0.2006, 0.2907, 0.222]}, {"w": "a", "b": [0.2954, 0.2006, 0.3046, 0.222]}, {"w": "graph", "b": [0.3093, 0.2006, 0.3576, 0.222]}, {"w": "definition", "b": [0.3623, 0.2006, 0.4448, 0.222]}, {"w": "file", "b": [0.4496, 0.2006, 0.4754, 0.222]}, {"w": "called", "b": [0.4802, 0.2006, 0.5285, 0.222]}, {"w": "iris_tree.dot:", "b": [0.5333, 0.2004, 0.6358, 0.222]}]}, {"id": "b_4", "type": "equation", "text": "from sklearn.tree import export_graphviz", "words": [{"w": "from", "b": [0.1766, 0.2326, 0.2103, 0.2454]}, {"w": "sklearn.tree", "b": [0.2188, 0.2326, 0.3199, 0.2454]}, {"w": "import", "b": [0.3284, 0.2326, 0.379, 0.2454]}, {"w": "export_graphviz", "b": [0.3874, 0.2326, 0.5139, 0.2454]}]}, {"id": "b_5", "type": "paragraph", "text": "export_graphviz( tree_clf, out_file=image_path(\"iris_tree.dot\"), feature_names=iris.feature_names[2:], class_names=iris.target_names, rounded=True, filled=True )", "words": [{"w": "export_graphviz(", "b": [0.1766, 0.2634, 0.3115, 0.2763]}, {"w": "tree_clf,", "b": [0.244, 0.2788, 0.3199, 0.2917]}, {"w": "out_file=image_path(\"iris_tree.dot\"),", "b": [0.244, 0.2942, 0.5561, 0.3071]}, {"w": "feature_names=iris.feature_names[2:],", "b": [0.244, 0.3097, 0.5561, 0.3225]}, {"w": "class_names=iris.target_names,", "b": [0.244, 0.3251, 0.497, 0.3379]}, {"w": "rounded=True,", "b": [0.244, 0.3405, 0.3537, 0.3534]}, {"w": "filled=True", "b": [0.244, 0.3559, 0.3368, 0.3688]}, {"w": ")", "b": [0.2103, 0.3713, 0.2188, 0.3842]}]}, {"id": "b_6", "type": "paragraph", "text": "Then you can convert this .dot file to a variety of formats such as PDF or PNG using the dot command-line tool from the graphviz package.1 This command line converts the .dot file to a .png image file:", "words": [{"w": "Then", "b": [0.1429, 0.392, 0.1871, 0.4134]}, {"w": "you", "b": [0.1927, 0.392, 0.2239, 0.4134]}, {"w": "can", "b": [0.2295, 0.392, 0.2589, 0.4134]}, {"w": "convert", "b": [0.2645, 0.392, 0.3274, 0.4134]}, {"w": "this", "b": [0.333, 0.392, 0.3637, 0.4134]}, {"w": ".dot", "b": [0.3693, 0.3918, 0.4006, 0.4134]}, {"w": "file", "b": [0.4062, 0.392, 0.4321, 0.4134]}, {"w": "to", "b": [0.4377, 0.392, 0.4547, 0.4134]}, {"w": "a", "b": [0.4603, 0.392, 0.4694, 0.4134]}, {"w": "variety", "b": [0.475, 0.392, 0.5319, 0.4134]}, {"w": "of", "b": [0.5375, 0.392, 0.5543, 0.4134]}, {"w": "formats", "b": [0.5599, 0.392, 0.6242, 0.4134]}, {"w": "such", "b": [0.6298, 0.392, 0.6684, 0.4134]}, {"w": "as", "b": [0.674, 0.392, 0.6908, 0.4134]}, {"w": "PDF", "b": [0.6964, 0.392, 0.7345, 0.4134]}, {"w": "or", "b": [0.7401, 0.392, 0.7584, 0.4134]}, {"w": "PNG", "b": [0.764, 0.392, 0.8061, 0.4134]}, {"w": "using", "b": [0.8117, 0.392, 0.8571, 0.4134]}, {"w": "the", "b": [0.1428, 0.4119, 0.1692, 0.4333]}, {"w": "dot", "b": [0.1748, 0.4151, 0.2045, 0.4302]}, {"w": "command-line", "b": [0.2102, 0.4119, 0.3338, 0.4333]}, {"w": "tool", "b": [0.3395, 0.4119, 0.3724, 0.4333]}, {"w": "from", "b": [0.378, 0.4119, 0.4196, 0.4333]}, {"w": "the", "b": [0.4253, 0.4119, 0.4516, 0.4333]}, {"w": "graphviz", "b": [0.4573, 0.4117, 0.5274, 0.4333]}, {"w": "package.1", "b": [0.533, 0.4119, 0.6105, 0.4333]}, {"w": "This", "b": [0.6161, 0.4119, 0.6534, 0.4333]}, {"w": "command", "b": [0.659, 0.4119, 0.7441, 0.4333]}, {"w": "line", "b": [0.7498, 0.4119, 0.7809, 0.4333]}, {"w": "converts", "b": [0.7866, 0.4119, 0.8571, 0.4333]}, {"w": "the", "b": [0.1429, 0.431, 0.1692, 0.4524]}, {"w": ".dot", "b": [0.1739, 0.4308, 0.2053, 0.4524]}, {"w": "file", "b": [0.21, 0.431, 0.2359, 0.4524]}, {"w": "to", "b": [0.2406, 0.431, 0.2576, 0.4524]}, {"w": "a", "b": [0.2623, 0.431, 0.2714, 0.4524]}, {"w": ".png", "b": [0.2762, 0.4308, 0.3105, 0.4524]}, {"w": "image", "b": [0.3153, 0.431, 0.3657, 0.4524]}, {"w": "file:", "b": [0.3704, 0.431, 0.401, 0.4524]}]}, {"id": "b_7", "type": "equation", "text": "$ dot -Tpng iris_tree.dot -o iris_tree.png", "words": [{"w": "$", "b": [0.1766, 0.4629, 0.185, 0.4758]}, {"w": "dot", "b": [0.1934, 0.4629, 0.2187, 0.4758]}, {"w": "-Tpng", "b": [0.2272, 0.4629, 0.2693, 0.4758]}, {"w": "iris_tree.dot", "b": [0.2778, 0.4629, 0.3874, 0.4758]}, {"w": "-o", "b": [0.3958, 0.4629, 0.4127, 0.4758]}, {"w": "iris_tree.png", "b": [0.4211, 0.4629, 0.5307, 0.4758]}]}, {"id": "b_8", "type": "equation", "text": "Your first decision tree looks like Figure 6-1.", "words": [{"w": "Your", "b": [0.1429, 0.4836, 0.1829, 0.505]}, {"w": "first", "b": [0.1877, 0.4836, 0.2211, 0.505]}, {"w": "decision", "b": [0.2259, 0.4836, 0.2954, 0.505]}, {"w": "tree", "b": [0.3001, 0.4836, 0.3319, 0.505]}, {"w": "looks", "b": [0.3366, 0.4836, 0.3811, 0.505]}, {"w": "like", "b": [0.3859, 0.4836, 0.4159, 0.505]}, {"w": "Figure", "b": [0.4206, 0.4836, 0.4746, 0.505]}, {"w": "6-1.", "b": [0.4794, 0.4836, 0.5115, 0.505]}]}, {"id": "b_9", "type": "paragraph", "text": "178 | Chapter 6: Decision Trees", "words": [{"w": "178", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "6:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Decision", "b": [0.2673, 0.9225, 0.3162, 0.9388]}, {"w": "Trees", "b": [0.319, 0.9225, 0.3502, 0.9388]}]}]}, {"page": 205, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 6-1. Iris Decision Tree", "words": [{"w": "Figure", "b": [0.1429, 0.4795, 0.1943, 0.5011]}, {"w": "6-1.", "b": [0.1991, 0.4795, 0.2308, 0.5011]}, {"w": "Iris", "b": [0.2356, 0.4795, 0.2623, 0.5011]}, {"w": "Decision", "b": [0.2671, 0.4795, 0.337, 0.5011]}, {"w": "Tree", "b": [0.3418, 0.4795, 0.3766, 0.5011]}]}, {"id": "b_1", "type": "paragraph", "text": "Making Predictions", "words": [{"w": "Making", "b": [0.1428, 0.5141, 0.2354, 0.5483]}, {"w": "Predictions", "b": [0.2413, 0.5141, 0.3796, 0.5483]}]}, {"id": "b_2", "type": "paragraph", "text": "Let’s see how the tree represented in Figure 6-1 makes predictions. Suppose you find an iris flower and you want to classify it. You start at the root node (depth 0, at the top): this node asks whether the flower’s petal length is smaller than 2.45 cm. If it is, then you move down to the root’s left child node (depth 1, left). In this case, it is a leaf node (i.e., it does not have any children nodes), so it does not ask any questions: you can simply look at the predicted class for that node and the Decision Tree predicts that your flower is an Iris-Setosa (class=setosa).", "words": [{"w": "Let’s", "b": [0.1429, 0.5553, 0.179, 0.5767]}, {"w": "see", "b": [0.1848, 0.5553, 0.2101, 0.5767]}, {"w": "how", "b": [0.2159, 0.5553, 0.2519, 0.5767]}, {"w": "the", "b": [0.2577, 0.5553, 0.284, 0.5767]}, {"w": "tree", "b": [0.2898, 0.5553, 0.3215, 0.5767]}, {"w": "represented", "b": [0.3273, 0.5553, 0.4251, 0.5767]}, {"w": "in", "b": [0.4309, 0.5553, 0.4478, 0.5767]}, {"w": "Figure", "b": [0.4536, 0.5553, 0.5076, 0.5767]}, {"w": "6-1", "b": [0.5133, 0.5553, 0.5408, 0.5767]}, {"w": "makes", "b": [0.5465, 0.5553, 0.5996, 0.5767]}, {"w": "predictions.", "b": [0.6053, 0.5553, 0.7046, 0.5767]}, {"w": "Suppose", "b": [0.7103, 0.5553, 0.7802, 0.5767]}, {"w": "you", "b": [0.786, 0.5553, 0.8172, 0.5767]}, {"w": "find", "b": [0.823, 0.5553, 0.8571, 0.5767]}, {"w": "an", "b": [0.1429, 0.5743, 0.1634, 0.5957]}, {"w": "iris", "b": [0.1702, 0.5743, 0.1967, 0.5957]}, {"w": "flower", "b": [0.2035, 0.5743, 0.2564, 0.5957]}, {"w": "and", "b": [0.2632, 0.5743, 0.2947, 0.5957]}, {"w": "you", "b": [0.3015, 0.5743, 0.3327, 0.5957]}, {"w": "want", "b": [0.3395, 0.5743, 0.3803, 0.5957]}, {"w": "to", "b": [0.387, 0.5743, 0.404, 0.5957]}, {"w": "classify", "b": [0.4108, 0.5743, 0.471, 0.5957]}, {"w": "it.", "b": [0.4777, 0.5743, 0.4944, 0.5957]}, {"w": "You", "b": [0.5012, 0.5743, 0.5335, 0.5957]}, {"w": "start", "b": [0.5403, 0.5743, 0.5775, 0.5957]}, {"w": "at", "b": [0.5843, 0.5743, 0.5994, 0.5957]}, {"w": "the", "b": [0.6062, 0.5743, 0.6325, 0.5957]}, {"w": "root", "b": [0.6393, 0.5741, 0.6722, 0.5957]}, {"w": "node", "b": [0.679, 0.5741, 0.7184, 0.5957]}, {"w": "(depth", "b": [0.7252, 0.5743, 0.7807, 0.5957]}, {"w": "0,", "b": [0.7874, 0.5743, 0.8022, 0.5957]}, {"w": "at", "b": [0.8089, 0.5743, 0.8241, 0.5957]}, {"w": "the", "b": [0.8308, 0.5743, 0.8572, 0.5957]}, {"w": "top):", "b": [0.1429, 0.5933, 0.1827, 0.6148]}, {"w": "this", "b": [0.1887, 0.5933, 0.2194, 0.6148]}, {"w": "node", "b": [0.2253, 0.5933, 0.2672, 0.6148]}, {"w": "asks", "b": [0.2731, 0.5933, 0.3079, 0.6148]}, {"w": "whether", "b": [0.3139, 0.5933, 0.3822, 0.6148]}, {"w": "the", "b": [0.3881, 0.5933, 0.4144, 0.6148]}, {"w": "flower’s", "b": [0.4204, 0.5933, 0.4836, 0.6148]}, {"w": "petal", "b": [0.4896, 0.5933, 0.5301, 0.6148]}, {"w": "length", "b": [0.536, 0.5933, 0.5888, 0.6148]}, {"w": "is", "b": [0.5947, 0.5933, 0.608, 0.6148]}, {"w": "smaller", "b": [0.6139, 0.5933, 0.6749, 0.6148]}, {"w": "than", "b": [0.6808, 0.5933, 0.7189, 0.6148]}, {"w": "2.45", "b": [0.7248, 0.5933, 0.7596, 0.6148]}, {"w": "cm.", "b": [0.7655, 0.5933, 0.7961, 0.6148]}, {"w": "If", "b": [0.8021, 0.5933, 0.8153, 0.6148]}, {"w": "it", "b": [0.8213, 0.5933, 0.8332, 0.6148]}, {"w": "is,", "b": [0.8392, 0.5933, 0.8571, 0.6148]}, {"w": "then", "b": [0.1429, 0.6124, 0.1806, 0.6338]}, {"w": "you", "b": [0.1855, 0.6124, 0.2167, 0.6338]}, {"w": "move", "b": [0.2216, 0.6124, 0.2678, 0.6338]}, {"w": "down", "b": [0.2727, 0.6124, 0.3199, 0.6338]}, {"w": "to", "b": [0.3248, 0.6124, 0.3418, 0.6338]}, {"w": "the", "b": [0.3467, 0.6124, 0.373, 0.6338]}, {"w": "root’s", "b": [0.3779, 0.6124, 0.423, 0.6338]}, {"w": "left", "b": [0.4279, 0.6124, 0.4545, 0.6338]}, {"w": "child", "b": [0.4594, 0.6124, 0.5012, 0.6338]}, {"w": "node", "b": [0.506, 0.6124, 0.5479, 0.6338]}, {"w": "(depth", "b": [0.5528, 0.6124, 0.6083, 0.6338]}, {"w": "1,", "b": [0.6131, 0.6124, 0.6279, 0.6338]}, {"w": "left).", "b": [0.6328, 0.6124, 0.6714, 0.6338]}, {"w": "In", "b": [0.6762, 0.6124, 0.6947, 0.6338]}, {"w": "this", "b": [0.6996, 0.6124, 0.7303, 0.6338]}, {"w": "case,", "b": [0.7352, 0.6124, 0.7744, 0.6338]}, {"w": "it", "b": [0.7793, 0.6124, 0.7912, 0.6338]}, {"w": "is", "b": [0.7961, 0.6124, 0.8093, 0.6338]}, {"w": "a", "b": [0.8142, 0.6124, 0.8234, 0.6338]}, {"w": "leaf", "b": [0.8282, 0.6122, 0.8571, 0.6338]}, {"w": "node", "b": [0.1429, 0.6312, 0.1823, 0.6529]}, {"w": "(i.e.,", "b": [0.1881, 0.6314, 0.224, 0.6529]}, {"w": "it", "b": [0.2297, 0.6314, 0.2417, 0.6529]}, {"w": "does", "b": [0.2474, 0.6314, 0.2855, 0.6529]}, {"w": "not", "b": [0.2913, 0.6314, 0.3196, 0.6529]}, {"w": "have", "b": [0.3254, 0.6314, 0.3638, 0.6529]}, {"w": "any", "b": [0.3695, 0.6314, 0.3992, 0.6529]}, {"w": "children", "b": [0.4049, 0.6314, 0.4747, 0.6529]}, {"w": "nodes),", "b": [0.4804, 0.6314, 0.5419, 0.6529]}, {"w": "so", "b": [0.5476, 0.6314, 0.5659, 0.6529]}, {"w": "it", "b": [0.5717, 0.6314, 0.5836, 0.6529]}, {"w": "does", "b": [0.5893, 0.6314, 0.6275, 0.6529]}, {"w": "not", "b": [0.6332, 0.6314, 0.6616, 0.6529]}, {"w": "ask", "b": [0.6673, 0.6314, 0.6945, 0.6529]}, {"w": "any", "b": [0.7002, 0.6314, 0.7298, 0.6529]}, {"w": "questions:", "b": [0.7356, 0.6314, 0.8201, 0.6529]}, {"w": "you", "b": [0.8259, 0.6314, 0.8571, 0.6529]}, {"w": "can", "b": [0.1429, 0.6505, 0.1722, 0.6719]}, {"w": "simply", "b": [0.1793, 0.6505, 0.235, 0.6719]}, {"w": "look", "b": [0.242, 0.6505, 0.2789, 0.6719]}, {"w": "at", "b": [0.286, 0.6505, 0.3011, 0.6719]}, {"w": "the", "b": [0.3082, 0.6505, 0.3345, 0.6719]}, {"w": "predicted", "b": [0.3416, 0.6505, 0.4207, 0.6719]}, {"w": "class", "b": [0.4278, 0.6505, 0.4663, 0.6719]}, {"w": "for", "b": [0.4734, 0.6505, 0.4979, 0.6719]}, {"w": "that", "b": [0.505, 0.6505, 0.5376, 0.6719]}, {"w": "node", "b": [0.5447, 0.6505, 0.5866, 0.6719]}, {"w": "and", "b": [0.5937, 0.6505, 0.6252, 0.6719]}, {"w": "the", "b": [0.6323, 0.6505, 0.6586, 0.6719]}, {"w": "Decision", "b": [0.6657, 0.6505, 0.7395, 0.6719]}, {"w": "Tree", "b": [0.7466, 0.6505, 0.7832, 0.6719]}, {"w": "predicts", "b": [0.7903, 0.6505, 0.8572, 0.6719]}, {"w": "that", "b": [0.1429, 0.6704, 0.1754, 0.6918]}, {"w": "your", "b": [0.1802, 0.6704, 0.2192, 0.6918]}, {"w": "flower", "b": [0.2239, 0.6704, 0.2768, 0.6918]}, {"w": "is", "b": [0.2815, 0.6704, 0.2948, 0.6918]}, {"w": "an", "b": [0.2995, 0.6704, 0.32, 0.6918]}, {"w": "Iris-Setosa", "b": [0.3248, 0.6704, 0.4127, 0.6918]}, {"w": "(class=setosa).", "b": [0.4175, 0.6704, 0.5554, 0.6918]}]}, {"id": "b_3", "type": "paragraph", "text": "Now suppose you find another flower, but this time the petal length is greater than 2.45 cm. You must move down to the root’s right child node (depth 1, right), which is not a leaf node, so it asks another question: is the petal width smaller than 1.75 cm? If it is, then your flower is most likely an Iris-Versicolor (depth 2, left). If not, it is likely an Iris-Virginica (depth 2, right). It’s really that simple.", "words": [{"w": "Now", "b": [0.1429, 0.6986, 0.1827, 0.72]}, {"w": "suppose", "b": [0.1895, 0.6986, 0.2571, 0.72]}, {"w": "you", "b": [0.2639, 0.6986, 0.2951, 0.72]}, {"w": "find", "b": [0.3018, 0.6986, 0.336, 0.72]}, {"w": "another", "b": [0.3427, 0.6986, 0.408, 0.72]}, {"w": "flower,", "b": [0.4147, 0.6986, 0.471, 0.72]}, {"w": "but", "b": [0.4778, 0.6986, 0.5058, 0.72]}, {"w": "this", "b": [0.5125, 0.6986, 0.5432, 0.72]}, {"w": "time", "b": [0.55, 0.6986, 0.5878, 0.72]}, {"w": "the", "b": [0.5946, 0.6986, 0.6209, 0.72]}, {"w": "petal", "b": [0.6276, 0.6986, 0.6682, 0.72]}, {"w": "length", "b": [0.6749, 0.6986, 0.7277, 0.72]}, {"w": "is", "b": [0.7344, 0.6986, 0.7476, 0.72]}, {"w": "greater", "b": [0.7544, 0.6986, 0.8124, 0.72]}, {"w": "than", "b": [0.8191, 0.6986, 0.8571, 0.72]}, {"w": "2.45", "b": [0.1429, 0.7176, 0.1776, 0.739]}, {"w": "cm.", "b": [0.1828, 0.7176, 0.2134, 0.739]}, {"w": "You", "b": [0.2186, 0.7176, 0.2509, 0.739]}, {"w": "must", "b": [0.2561, 0.7176, 0.2978, 0.739]}, {"w": "move", "b": [0.303, 0.7176, 0.3492, 0.739]}, {"w": "down", "b": [0.3543, 0.7176, 0.4016, 0.739]}, {"w": "to", "b": [0.4068, 0.7176, 0.4238, 0.739]}, {"w": "the", "b": [0.4289, 0.7176, 0.4553, 0.739]}, {"w": "root’s", "b": [0.4604, 0.7176, 0.5055, 0.739]}, {"w": "right", "b": [0.5107, 0.7176, 0.5508, 0.739]}, {"w": "child", "b": [0.556, 0.7176, 0.5978, 0.739]}, {"w": "node", "b": [0.603, 0.7176, 0.6448, 0.739]}, {"w": "(depth", "b": [0.65, 0.7176, 0.7055, 0.739]}, {"w": "1,", "b": [0.7106, 0.7176, 0.7254, 0.739]}, {"w": "right),", "b": [0.7306, 0.7176, 0.7827, 0.739]}, {"w": "which", "b": [0.7878, 0.7176, 0.8387, 0.739]}, {"w": "is", "b": [0.8439, 0.7176, 0.8571, 0.739]}, {"w": "not", "b": [0.1429, 0.7366, 0.1712, 0.7581]}, {"w": "a", "b": [0.1762, 0.7366, 0.1854, 0.7581]}, {"w": "leaf", "b": [0.1903, 0.7366, 0.2198, 0.7581]}, {"w": "node,", "b": [0.2247, 0.7366, 0.2713, 0.7581]}, {"w": "so", "b": [0.2763, 0.7366, 0.2946, 0.7581]}, {"w": "it", "b": [0.2995, 0.7366, 0.3115, 0.7581]}, {"w": "asks", "b": [0.3164, 0.7366, 0.3512, 0.7581]}, {"w": "another", "b": [0.3562, 0.7366, 0.4214, 0.7581]}, {"w": "question:", "b": [0.4264, 0.7366, 0.5033, 0.7581]}, {"w": "is", "b": [0.5082, 0.7366, 0.5215, 0.7581]}, {"w": "the", "b": [0.5264, 0.7366, 0.5528, 0.7581]}, {"w": "petal", "b": [0.5577, 0.7366, 0.5983, 0.7581]}, {"w": "width", "b": [0.6032, 0.7366, 0.6516, 0.7581]}, {"w": "smaller", "b": [0.6565, 0.7366, 0.7175, 0.7581]}, {"w": "than", "b": [0.7225, 0.7366, 0.7605, 0.7581]}, {"w": "1.75", "b": [0.7654, 0.7366, 0.8002, 0.7581]}, {"w": "cm?", "b": [0.8052, 0.7366, 0.8389, 0.7581]}, {"w": "If", "b": [0.8439, 0.7366, 0.8572, 0.7581]}, {"w": "it", "b": [0.1429, 0.7557, 0.1548, 0.7771]}, {"w": "is,", "b": [0.16, 0.7557, 0.178, 0.7771]}, {"w": "then", "b": [0.1832, 0.7557, 0.2209, 0.7771]}, {"w": "your", "b": [0.2261, 0.7557, 0.2651, 0.7771]}, {"w": "flower", "b": [0.2702, 0.7557, 0.3232, 0.7771]}, {"w": "is", "b": [0.3283, 0.7557, 0.3416, 0.7771]}, {"w": "most", "b": [0.3468, 0.7557, 0.3884, 0.7771]}, {"w": "likely", "b": [0.3936, 0.7557, 0.4385, 0.7771]}, {"w": "an", "b": [0.4437, 0.7557, 0.4642, 0.7771]}, {"w": "Iris-Versicolor", "b": [0.4694, 0.7557, 0.5904, 0.7771]}, {"w": "(depth", "b": [0.5956, 0.7557, 0.651, 0.7771]}, {"w": "2,", "b": [0.6562, 0.7557, 0.671, 0.7771]}, {"w": "left).", "b": [0.6762, 0.7557, 0.7148, 0.7771]}, {"w": "If", "b": [0.72, 0.7557, 0.7332, 0.7771]}, {"w": "not,", "b": [0.7384, 0.7557, 0.7715, 0.7771]}, {"w": "it", "b": [0.7767, 0.7557, 0.7887, 0.7771]}, {"w": "is", "b": [0.7939, 0.7557, 0.8071, 0.7771]}, {"w": "likely", "b": [0.8123, 0.7557, 0.8572, 0.7771]}, {"w": "an", "b": [0.1429, 0.7747, 0.1634, 0.7962]}, {"w": "Iris-Virginica", "b": [0.1681, 0.7747, 0.281, 0.7962]}, {"w": "(depth", "b": [0.2857, 0.7747, 0.3412, 0.7962]}, {"w": "2,", "b": [0.3459, 0.7747, 0.3606, 0.7962]}, {"w": "right).", "b": [0.3654, 0.7747, 0.4175, 0.7962]}, {"w": "It’s", "b": [0.4222, 0.7747, 0.4446, 0.7962]}, {"w": "really", "b": [0.4493, 0.7747, 0.4952, 0.7962]}, {"w": "that", "b": [0.4999, 0.7747, 0.5325, 0.7962]}, {"w": "simple.", "b": [0.5372, 0.7747, 0.5969, 0.7962]}]}, {"id": "b_4", "type": "paragraph", "text": "One of the many qualities of Decision Trees is that they require very little data preparation. In particular, they don’t require feature scaling or centering at all.", "words": [{"w": "One", "b": [0.2714, 0.8167, 0.3042, 0.8363]}, {"w": "of", "b": [0.3116, 0.8167, 0.327, 0.8363]}, {"w": "the", "b": [0.3344, 0.8167, 0.3585, 0.8363]}, {"w": "many", "b": [0.366, 0.8167, 0.4087, 0.8363]}, {"w": "qualities", "b": [0.4161, 0.8167, 0.4803, 0.8363]}, {"w": "of", "b": [0.4877, 0.8167, 0.5031, 0.8363]}, {"w": "Decision", "b": [0.5105, 0.8167, 0.578, 0.8363]}, {"w": "Trees", "b": [0.5855, 0.8167, 0.6259, 0.8363]}, {"w": "is", "b": [0.6334, 0.8167, 0.6454, 0.8363]}, {"w": "that", "b": [0.6529, 0.8167, 0.6827, 0.8363]}, {"w": "they", "b": [0.6902, 0.8167, 0.723, 0.8363]}, {"w": "require", "b": [0.7304, 0.8167, 0.7857, 0.8363]}, {"w": "very", "b": [0.2714, 0.8341, 0.3047, 0.8537]}, {"w": "little", "b": [0.3099, 0.8341, 0.3443, 0.8537]}, {"w": "data", "b": [0.3495, 0.8341, 0.3817, 0.8537]}, {"w": "preparation.", "b": [0.3869, 0.8341, 0.4809, 0.8537]}, {"w": "In", "b": [0.4861, 0.8341, 0.503, 0.8537]}, {"w": "particular,", "b": [0.5081, 0.8341, 0.586, 0.8537]}, {"w": "they", "b": [0.5912, 0.8341, 0.624, 0.8537]}, {"w": "don’t", "b": [0.6292, 0.8341, 0.6673, 0.8537]}, {"w": "require", "b": [0.6724, 0.8341, 0.7277, 0.8537]}, {"w": "feature", "b": [0.7329, 0.8341, 0.7857, 0.8537]}, {"w": "scaling", "b": [0.2714, 0.8515, 0.3241, 0.8711]}, {"w": "or", "b": [0.3284, 0.8515, 0.3452, 0.8711]}, {"w": "centering", "b": [0.3495, 0.8515, 0.4211, 0.8711]}, {"w": "at", "b": [0.4255, 0.8515, 0.4393, 0.8711]}, {"w": "all.", "b": [0.4436, 0.8515, 0.4659, 0.8711]}]}, {"id": "b_5", "type": "paragraph", "text": "Making Predictions | 179", "words": [{"w": "Making", "b": [0.6832, 0.9225, 0.7272, 0.9388]}, {"w": "Predictions", "b": [0.73, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "179", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 206, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "A node’s samples attribute counts how many training instances it applies to. For example, 100 training instances have a petal length greater than 2.45 cm (depth 1, right), among which 54 have a petal width smaller than 1.75 cm (depth 2, left). A node’s value attribute tells you how many training instances of each class this node applies to: for example, the bottom-right node applies to 0 Iris-Setosa, 1 Iris- Versicolor, and 45 Iris-Virginica. Finally, a node’s gini attribute measures its impur‐ ity: a node is “pure” (gini=0) if all training instances it applies to belong to the same class. For example, since the depth-1 left node applies only to Iris-Setosa training instances, it is pure and its gini score is 0. Equation 6-1 shows how the training algo‐ rithm computes the gini score Gi of the ith node. For example, the depth-2 left node has a gini score equal to 1 – (0/54)2 – (49/54)2 – (5/54)2 ≈ 0.168. Another impurity measure is discussed shortly.", "words": [{"w": "A", "b": [0.1429, 0.08, 0.1573, 0.1014]}, {"w": "node’s", "b": [0.1661, 0.08, 0.2171, 0.1014]}, {"w": "samples", "b": [0.2259, 0.0831, 0.2952, 0.0982]}, {"w": "attribute", "b": [0.304, 0.08, 0.3756, 0.1014]}, {"w": "counts", "b": [0.3845, 0.08, 0.44, 0.1014]}, {"w": "how", "b": [0.4488, 0.08, 0.4848, 0.1014]}, {"w": "many", "b": [0.4937, 0.08, 0.5404, 0.1014]}, {"w": "training", "b": [0.5492, 0.08, 0.6161, 0.1014]}, {"w": "instances", "b": [0.625, 0.08, 0.7018, 0.1014]}, {"w": "it", "b": [0.7106, 0.08, 0.7226, 0.1014]}, {"w": "applies", "b": [0.7314, 0.08, 0.7894, 0.1014]}, {"w": "to.", "b": [0.7982, 0.08, 0.8193, 0.1014]}, {"w": "For", "b": [0.8282, 0.08, 0.8571, 0.1014]}, {"w": "example,", "b": [0.1429, 0.099, 0.2171, 0.1204]}, {"w": "100", "b": [0.2247, 0.099, 0.2547, 0.1204]}, {"w": "training", "b": [0.2623, 0.099, 0.3292, 0.1204]}, {"w": "instances", "b": [0.3368, 0.099, 0.4136, 0.1204]}, {"w": "have", "b": [0.4212, 0.099, 0.4596, 0.1204]}, {"w": "a", "b": [0.4672, 0.099, 0.4763, 0.1204]}, {"w": "petal", "b": [0.4839, 0.099, 0.5245, 0.1204]}, {"w": "length", "b": [0.532, 0.099, 0.5848, 0.1204]}, {"w": "greater", "b": [0.5924, 0.099, 0.6504, 0.1204]}, {"w": "than", "b": [0.658, 0.099, 0.696, 0.1204]}, {"w": "2.45", "b": [0.7036, 0.099, 0.7383, 0.1204]}, {"w": "cm", "b": [0.7459, 0.099, 0.7718, 0.1204]}, {"w": "(depth", "b": [0.7794, 0.099, 0.8348, 0.1204]}, {"w": "1,", "b": [0.8424, 0.099, 0.8571, 0.1204]}, {"w": "right),", "b": [0.1429, 0.1181, 0.195, 0.1395]}, {"w": "among", "b": [0.2026, 0.1181, 0.2606, 0.1395]}, {"w": "which", "b": [0.2682, 0.1181, 0.3191, 0.1395]}, {"w": "54", "b": [0.3267, 0.1181, 0.3467, 0.1395]}, {"w": "have", "b": [0.3543, 0.1181, 0.3927, 0.1395]}, {"w": "a", "b": [0.4003, 0.1181, 0.4094, 0.1395]}, {"w": "petal", "b": [0.417, 0.1181, 0.4576, 0.1395]}, {"w": "width", "b": [0.4652, 0.1181, 0.5135, 0.1395]}, {"w": "smaller", "b": [0.5211, 0.1181, 0.5821, 0.1395]}, {"w": "than", "b": [0.5897, 0.1181, 0.6277, 0.1395]}, {"w": "1.75", "b": [0.6353, 0.1181, 0.6701, 0.1395]}, {"w": "cm", "b": [0.6777, 0.1181, 0.7035, 0.1395]}, {"w": "(depth", "b": [0.7111, 0.1181, 0.7666, 0.1395]}, {"w": "2,", "b": [0.7742, 0.1181, 0.7889, 0.1395]}, {"w": "left).", "b": [0.7965, 0.1181, 0.8352, 0.1395]}, {"w": "A", "b": [0.8428, 0.1181, 0.8572, 0.1395]}, {"w": "node’s", "b": [0.1429, 0.138, 0.1938, 0.1594]}, {"w": "value", "b": [0.2004, 0.1412, 0.2499, 0.1563]}, {"w": "attribute", "b": [0.2564, 0.138, 0.3281, 0.1594]}, {"w": "tells", "b": [0.3346, 0.138, 0.368, 0.1594]}, {"w": "you", "b": [0.3746, 0.138, 0.4058, 0.1594]}, {"w": "how", "b": [0.4124, 0.138, 0.4484, 0.1594]}, {"w": "many", "b": [0.455, 0.138, 0.5016, 0.1594]}, {"w": "training", "b": [0.5082, 0.138, 0.5751, 0.1594]}, {"w": "instances", "b": [0.5817, 0.138, 0.6585, 0.1594]}, {"w": "of", "b": [0.6651, 0.138, 0.6819, 0.1594]}, {"w": "each", "b": [0.6884, 0.138, 0.7264, 0.1594]}, {"w": "class", "b": [0.7329, 0.138, 0.7714, 0.1594]}, {"w": "this", "b": [0.778, 0.138, 0.8087, 0.1594]}, {"w": "node", "b": [0.8153, 0.138, 0.8571, 0.1594]}, {"w": "applies", "b": [0.1429, 0.157, 0.2008, 0.1785]}, {"w": "to:", "b": [0.2121, 0.157, 0.2338, 0.1785]}, {"w": "for", "b": [0.2451, 0.157, 0.2696, 0.1785]}, {"w": "example,", "b": [0.2809, 0.157, 0.3552, 0.1785]}, {"w": "the", "b": [0.3664, 0.157, 0.3928, 0.1785]}, {"w": "bottom-right", "b": [0.404, 0.157, 0.5132, 0.1785]}, {"w": "node", "b": [0.5245, 0.157, 0.5664, 0.1785]}, {"w": "applies", "b": [0.5776, 0.157, 0.6356, 0.1785]}, {"w": "to", "b": [0.6469, 0.157, 0.6638, 0.1785]}, {"w": "0", "b": [0.6751, 0.157, 0.6851, 0.1785]}, {"w": "Iris-Setosa,", "b": [0.6964, 0.157, 0.7891, 0.1785]}, {"w": "1", "b": [0.8004, 0.157, 0.8104, 0.1785]}, {"w": "Iris-", "b": [0.8217, 0.157, 0.8571, 0.1785]}, {"w": "Versicolor,", "b": [0.1428, 0.177, 0.2318, 0.1984]}, {"w": "and", "b": [0.2381, 0.177, 0.2697, 0.1984]}, {"w": "45", "b": [0.2761, 0.177, 0.2961, 0.1984]}, {"w": "Iris-Virginica.", "b": [0.3024, 0.177, 0.42, 0.1984]}, {"w": "Finally,", "b": [0.4264, 0.177, 0.4869, 0.1984]}, {"w": "a", "b": [0.4932, 0.177, 0.5024, 0.1984]}, {"w": "node’s", "b": [0.5087, 0.177, 0.5597, 0.1984]}, {"w": "gini", "b": [0.5661, 0.1802, 0.6057, 0.1953]}, {"w": "attribute", "b": [0.612, 0.177, 0.6836, 0.1984]}, {"w": "measures", "b": [0.69, 0.177, 0.768, 0.1984]}, {"w": "its", "b": [0.7744, 0.177, 0.794, 0.1984]}, {"w": "impur‐", "b": [0.8003, 0.1768, 0.8571, 0.1984]}, {"w": "ity:", "b": [0.1429, 0.1967, 0.1686, 0.2183]}, {"w": "a", "b": [0.1744, 0.1969, 0.1836, 0.2183]}, {"w": "node", "b": [0.1893, 0.1969, 0.2312, 0.2183]}, {"w": "is", "b": [0.237, 0.1969, 0.2502, 0.2183]}, {"w": "“pure”", "b": [0.256, 0.1969, 0.3093, 0.2183]}, {"w": "(gini=0)", "b": [0.3151, 0.1969, 0.3889, 0.2183]}, {"w": "if", "b": [0.3947, 0.1969, 0.4064, 0.2183]}, {"w": "all", "b": [0.4122, 0.1969, 0.4319, 0.2183]}, {"w": "training", "b": [0.4377, 0.1969, 0.5046, 0.2183]}, {"w": "instances", "b": [0.5104, 0.1969, 0.5872, 0.2183]}, {"w": "it", "b": [0.593, 0.1969, 0.605, 0.2183]}, {"w": "applies", "b": [0.6108, 0.1969, 0.6687, 0.2183]}, {"w": "to", "b": [0.6745, 0.1969, 0.6915, 0.2183]}, {"w": "belong", "b": [0.6973, 0.1969, 0.7538, 0.2183]}, {"w": "to", "b": [0.7595, 0.1969, 0.7765, 0.2183]}, {"w": "the", "b": [0.7823, 0.1969, 0.8086, 0.2183]}, {"w": "same", "b": [0.8144, 0.1969, 0.8572, 0.2183]}, {"w": "class.", "b": [0.1429, 0.216, 0.1861, 0.2374]}, {"w": "For", "b": [0.1943, 0.216, 0.2233, 0.2374]}, {"w": "example,", "b": [0.2315, 0.216, 0.3058, 0.2374]}, {"w": "since", "b": [0.314, 0.216, 0.3563, 0.2374]}, {"w": "the", "b": [0.3644, 0.216, 0.3908, 0.2374]}, {"w": "depth-1", "b": [0.399, 0.216, 0.4646, 0.2374]}, {"w": "left", "b": [0.4728, 0.216, 0.4995, 0.2374]}, {"w": "node", "b": [0.5076, 0.216, 0.5495, 0.2374]}, {"w": "applies", "b": [0.5577, 0.216, 0.6156, 0.2374]}, {"w": "only", "b": [0.6238, 0.216, 0.6607, 0.2374]}, {"w": "to", "b": [0.6689, 0.216, 0.6859, 0.2374]}, {"w": "Iris-Setosa", "b": [0.694, 0.216, 0.782, 0.2374]}, {"w": "training", "b": [0.7902, 0.216, 0.8571, 0.2374]}, {"w": "instances,", "b": [0.1429, 0.2359, 0.2244, 0.2573]}, {"w": "it", "b": [0.2294, 0.2359, 0.2414, 0.2573]}, {"w": "is", "b": [0.2464, 0.2359, 0.2596, 0.2573]}, {"w": "pure", "b": [0.2646, 0.2359, 0.3032, 0.2573]}, {"w": "and", "b": [0.3082, 0.2359, 0.3397, 0.2573]}, {"w": "its", "b": [0.3448, 0.2359, 0.3643, 0.2573]}, {"w": "gini", "b": [0.3693, 0.2391, 0.4089, 0.2542]}, {"w": "score", "b": [0.4139, 0.2359, 0.4576, 0.2573]}, {"w": "is", "b": [0.4626, 0.2359, 0.4759, 0.2573]}, {"w": "0.", "b": [0.4809, 0.2359, 0.4956, 0.2573]}, {"w": "Equation", "b": [0.5006, 0.2359, 0.5769, 0.2573]}, {"w": "6-1", "b": [0.5816, 0.2359, 0.609, 0.2573]}, {"w": "shows", "b": [0.6143, 0.2359, 0.6656, 0.2573]}, {"w": "how", "b": [0.6706, 0.2359, 0.7066, 0.2573]}, {"w": "the", "b": [0.7117, 0.2359, 0.738, 0.2573]}, {"w": "training", "b": [0.743, 0.2359, 0.8099, 0.2573]}, {"w": "algo‐", "b": [0.8149, 0.2359, 0.8572, 0.2573]}, {"w": "rithm", "b": [0.1429, 0.255, 0.1907, 0.2764]}, {"w": "computes", "b": [0.1971, 0.255, 0.2781, 0.2764]}, {"w": "the", "b": [0.2844, 0.255, 0.3108, 0.2764]}, {"w": "gini", "b": [0.3172, 0.255, 0.3495, 0.2764]}, {"w": "score", "b": [0.3559, 0.255, 0.3996, 0.2764]}, {"w": "Gi", "b": [0.406, 0.2548, 0.4236, 0.2773]}, {"w": "of", "b": [0.43, 0.255, 0.4467, 0.2764]}, {"w": "the", "b": [0.4531, 0.255, 0.4795, 0.2764]}, {"w": "ith", "b": [0.4859, 0.255, 0.5019, 0.2764]}, {"w": "node.", "b": [0.5083, 0.255, 0.555, 0.2764]}, {"w": "For", "b": [0.5614, 0.255, 0.5903, 0.2764]}, {"w": "example,", "b": [0.5967, 0.255, 0.671, 0.2764]}, {"w": "the", "b": [0.6774, 0.255, 0.7038, 0.2764]}, {"w": "depth-2", "b": [0.7102, 0.255, 0.7758, 0.2764]}, {"w": "left", "b": [0.7822, 0.255, 0.8089, 0.2764]}, {"w": "node", "b": [0.8153, 0.255, 0.8571, 0.2764]}, {"w": "has", "b": [0.1429, 0.2749, 0.1708, 0.2963]}, {"w": "a", "b": [0.1773, 0.2749, 0.1864, 0.2963]}, {"w": "gini", "b": [0.193, 0.2781, 0.2325, 0.2932]}, {"w": "score", "b": [0.2391, 0.2749, 0.2827, 0.2963]}, {"w": "equal", "b": [0.2893, 0.2749, 0.3342, 0.2963]}, {"w": "to", "b": [0.3408, 0.2749, 0.3577, 0.2963]}, {"w": "1", "b": [0.3643, 0.2749, 0.3743, 0.2963]}, {"w": "–", "b": [0.3808, 0.2749, 0.3916, 0.2963]}, {"w": "(0/54)2", "b": [0.3981, 0.2749, 0.4554, 0.2963]}, {"w": "–", "b": [0.462, 0.2749, 0.4728, 0.2963]}, {"w": "(49/54)2", "b": [0.4793, 0.2749, 0.5466, 0.2963]}, {"w": "–", "b": [0.5532, 0.2749, 0.564, 0.2963]}, {"w": "(5/54)2", "b": [0.5705, 0.2749, 0.6278, 0.2963]}, {"w": "≈", "b": [0.6343, 0.2749, 0.6466, 0.2963]}, {"w": "0.168.", "b": [0.6531, 0.2749, 0.7026, 0.2963]}, {"w": "Another", "b": [0.7091, 0.2749, 0.7796, 0.2963]}, {"w": "impurity", "b": [0.7861, 0.2747, 0.8571, 0.2963]}, {"w": "measure", "b": [0.1428, 0.2938, 0.2107, 0.3154]}, {"w": "is", "b": [0.2155, 0.294, 0.2287, 0.3154]}, {"w": "discussed", "b": [0.2334, 0.294, 0.3127, 0.3154]}, {"w": "shortly.", "b": [0.3174, 0.294, 0.3789, 0.3154]}]}, {"id": "b_1", "type": "equation", "text": "Equation 6-1. Gini impurity", "words": [{"w": "Equation", "b": [0.1726, 0.3335, 0.2473, 0.3551]}, {"w": "6-1.", "b": [0.2521, 0.3335, 0.2838, 0.3551]}, {"w": "Gini", "b": [0.2886, 0.3335, 0.3243, 0.3551]}, {"w": "impurity", "b": [0.3291, 0.3335, 0.4001, 0.3551]}]}, {"id": "b_2", "type": "equation", "text": "Gi = 1 −∑", "words": [{"w": "Gi", "b": [0.1726, 0.3749, 0.1905, 0.3998]}, {"w": "=", "b": [0.196, 0.3751, 0.2075, 0.3955]}, {"w": "1", "b": [0.213, 0.3751, 0.2225, 0.3955]}, {"w": "−∑", "b": [0.2269, 0.3703, 0.268, 0.3992]}]}, {"id": "b_3", "type": "equation", "text": "k = 1", "words": [{"w": "k", "b": [0.2439, 0.3898, 0.2514, 0.4063]}, {"w": "=", "b": [0.2558, 0.3899, 0.265, 0.4063]}, {"w": "1", "b": [0.2694, 0.3899, 0.2771, 0.4063]}]}, {"id": "b_5", "type": "paragraph", "text": "pi, k", "words": [{"w": "pi,", "b": [0.2806, 0.3749, 0.2982, 0.3998]}, {"w": "k", "b": [0.3009, 0.3833, 0.3083, 0.3998]}]}, {"id": "b_7", "type": "paragraph", "text": "• pi,k is the ratio of class k instances among the training instances in the ith node.", "words": [{"w": "•", "b": [0.16, 0.4314, 0.1681, 0.4528]}, {"w": "pi,k", "b": [0.1786, 0.4311, 0.2008, 0.4537]}, {"w": "is", "b": [0.2056, 0.4314, 0.2188, 0.4528]}, {"w": "the", "b": [0.2235, 0.4314, 0.2498, 0.4528]}, {"w": "ratio", "b": [0.2546, 0.4314, 0.2936, 0.4528]}, {"w": "of", "b": [0.2983, 0.4314, 0.3151, 0.4528]}, {"w": "class", "b": [0.3199, 0.4314, 0.3584, 0.4528]}, {"w": "k", "b": [0.3631, 0.4311, 0.3729, 0.4528]}, {"w": "instances", "b": [0.3776, 0.4314, 0.4545, 0.4528]}, {"w": "among", "b": [0.4592, 0.4314, 0.5172, 0.4528]}, {"w": "the", "b": [0.5219, 0.4314, 0.5482, 0.4528]}, {"w": "training", "b": [0.553, 0.4314, 0.6199, 0.4528]}, {"w": "instances", "b": [0.6246, 0.4314, 0.7015, 0.4528]}, {"w": "in", "b": [0.7062, 0.4314, 0.7232, 0.4528]}, {"w": "the", "b": [0.7279, 0.4314, 0.7542, 0.4528]}, {"w": "ith", "b": [0.759, 0.4311, 0.7751, 0.4528]}, {"w": "node.", "b": [0.7799, 0.4314, 0.8265, 0.4528]}]}, {"id": "b_8", "type": "paragraph", "text": "Scikit-Learn uses the CART algorithm, which produces only binary trees: nonleaf nodes always have two children (i.e., questions only have yes/no answers). However, other algorithms such as ID3 can produce Decision Trees with nodes that have more than two chil‐ dren.", "words": [{"w": "Scikit-Learn", "b": [0.2714, 0.4884, 0.3649, 0.508]}, {"w": "uses", "b": [0.3695, 0.4884, 0.4017, 0.508]}, {"w": "the", "b": [0.406, 0.4884, 0.4301, 0.508]}, {"w": "CART", "b": [0.4349, 0.4884, 0.4837, 0.508]}, {"w": "algorithm,", "b": [0.4883, 0.4884, 0.5682, 0.508]}, {"w": "which", "b": [0.5728, 0.4884, 0.6194, 0.508]}, {"w": "produces", "b": [0.6239, 0.4884, 0.694, 0.508]}, {"w": "only", "b": [0.6986, 0.4884, 0.7323, 0.508]}, {"w": "binary", "b": [0.7369, 0.4882, 0.7857, 0.508]}, {"w": "trees:", "b": [0.2714, 0.5056, 0.3094, 0.5254]}, {"w": "nonleaf", "b": [0.3157, 0.5058, 0.3732, 0.5254]}, {"w": "nodes", "b": [0.3795, 0.5058, 0.4247, 0.5254]}, {"w": "always", "b": [0.431, 0.5058, 0.481, 0.5254]}, {"w": "have", "b": [0.4873, 0.5058, 0.5224, 0.5254]}, {"w": "two", "b": [0.5287, 0.5058, 0.5573, 0.5254]}, {"w": "children", "b": [0.5636, 0.5058, 0.6274, 0.5254]}, {"w": "(i.e.,", "b": [0.6336, 0.5058, 0.6665, 0.5254]}, {"w": "questions", "b": [0.6728, 0.5058, 0.7457, 0.5254]}, {"w": "only", "b": [0.752, 0.5058, 0.7857, 0.5254]}, {"w": "have", "b": [0.2714, 0.5232, 0.3065, 0.5428]}, {"w": "yes/no", "b": [0.3126, 0.5232, 0.3628, 0.5428]}, {"w": "answers).", "b": [0.3689, 0.5232, 0.4408, 0.5428]}, {"w": "However,", "b": [0.4468, 0.5232, 0.5189, 0.5428]}, {"w": "other", "b": [0.5249, 0.5232, 0.5658, 0.5428]}, {"w": "algorithms", "b": [0.5718, 0.5232, 0.6544, 0.5428]}, {"w": "such", "b": [0.6604, 0.5232, 0.6958, 0.5428]}, {"w": "as", "b": [0.7018, 0.5232, 0.7172, 0.5428]}, {"w": "ID3", "b": [0.7232, 0.5232, 0.7528, 0.5428]}, {"w": "can", "b": [0.7589, 0.5232, 0.7857, 0.5428]}, {"w": "produce", "b": [0.2714, 0.5407, 0.3345, 0.5602]}, {"w": "Decision", "b": [0.3405, 0.5407, 0.408, 0.5602]}, {"w": "Trees", "b": [0.414, 0.5407, 0.4545, 0.5602]}, {"w": "with", "b": [0.4605, 0.5407, 0.4946, 0.5602]}, {"w": "nodes", "b": [0.5006, 0.5407, 0.5459, 0.5602]}, {"w": "that", "b": [0.5519, 0.5407, 0.5817, 0.5602]}, {"w": "have", "b": [0.5878, 0.5407, 0.6229, 0.5602]}, {"w": "more", "b": [0.6289, 0.5407, 0.6694, 0.5602]}, {"w": "than", "b": [0.6754, 0.5407, 0.7102, 0.5602]}, {"w": "two", "b": [0.7162, 0.5407, 0.7448, 0.5602]}, {"w": "chil‐", "b": [0.7508, 0.5407, 0.7857, 0.5602]}, {"w": "dren.", "b": [0.2714, 0.5581, 0.3114, 0.5777]}]}, {"id": "b_9", "type": "paragraph", "text": "Figure 6-2 shows this Decision Tree’s decision boundaries. The thick vertical line rep‐ resents the decision boundary of the root node (depth 0): petal length = 2.45 cm. Since the left area is pure (only Iris-Setosa), it cannot be split any further. However, the right area is impure, so the depth-1 right node splits it at petal width = 1.75 cm (represented by the dashed line). Since max_depth was set to 2, the Decision Tree stops right there. However, if you set max_depth to 3, then the two depth-2 nodes would each add another decision boundary (represented by the dotted lines).", "words": [{"w": "Figure", "b": [0.1428, 0.5979, 0.1968, 0.6194]}, {"w": "6-2", "b": [0.2016, 0.5979, 0.229, 0.6194]}, {"w": "shows", "b": [0.2345, 0.5979, 0.2858, 0.6194]}, {"w": "this", "b": [0.2909, 0.5979, 0.3216, 0.6194]}, {"w": "Decision", "b": [0.3266, 0.5979, 0.4005, 0.6194]}, {"w": "Tree’s", "b": [0.4055, 0.5979, 0.4512, 0.6194]}, {"w": "decision", "b": [0.4563, 0.5979, 0.5258, 0.6194]}, {"w": "boundaries.", "b": [0.5309, 0.5979, 0.6293, 0.6194]}, {"w": "The", "b": [0.6343, 0.5979, 0.6672, 0.6194]}, {"w": "thick", "b": [0.6723, 0.5979, 0.7145, 0.6194]}, {"w": "vertical", "b": [0.7196, 0.5979, 0.781, 0.6194]}, {"w": "line", "b": [0.786, 0.5979, 0.8171, 0.6194]}, {"w": "rep‐", "b": [0.8222, 0.5979, 0.8571, 0.6194]}, {"w": "resents", "b": [0.1429, 0.617, 0.2009, 0.6384]}, {"w": "the", "b": [0.2088, 0.617, 0.2351, 0.6384]}, {"w": "decision", "b": [0.243, 0.617, 0.3125, 0.6384]}, {"w": "boundary", "b": [0.3204, 0.617, 0.4021, 0.6384]}, {"w": "of", "b": [0.41, 0.617, 0.4267, 0.6384]}, {"w": "the", "b": [0.4346, 0.617, 0.4609, 0.6384]}, {"w": "root", "b": [0.4688, 0.617, 0.5042, 0.6384]}, {"w": "node", "b": [0.512, 0.617, 0.5539, 0.6384]}, {"w": "(depth", "b": [0.5618, 0.617, 0.6172, 0.6384]}, {"w": "0):", "b": [0.6251, 0.617, 0.647, 0.6384]}, {"w": "petal", "b": [0.6549, 0.617, 0.6955, 0.6384]}, {"w": "length", "b": [0.7033, 0.617, 0.7561, 0.6384]}, {"w": "=", "b": [0.7639, 0.617, 0.776, 0.6384]}, {"w": "2.45", "b": [0.7839, 0.617, 0.8186, 0.6384]}, {"w": "cm.", "b": [0.8265, 0.617, 0.8571, 0.6384]}, {"w": "Since", "b": [0.1429, 0.636, 0.1874, 0.6575]}, {"w": "the", "b": [0.1938, 0.636, 0.2202, 0.6575]}, {"w": "left", "b": [0.2266, 0.636, 0.2533, 0.6575]}, {"w": "area", "b": [0.2597, 0.636, 0.2946, 0.6575]}, {"w": "is", "b": [0.301, 0.636, 0.3143, 0.6575]}, {"w": "pure", "b": [0.3207, 0.636, 0.3593, 0.6575]}, {"w": "(only", "b": [0.3657, 0.636, 0.4098, 0.6575]}, {"w": "Iris-Setosa),", "b": [0.4162, 0.636, 0.5162, 0.6575]}, {"w": "it", "b": [0.5226, 0.636, 0.5346, 0.6575]}, {"w": "cannot", "b": [0.541, 0.636, 0.5987, 0.6575]}, {"w": "be", "b": [0.6052, 0.636, 0.6246, 0.6575]}, {"w": "split", "b": [0.6311, 0.636, 0.6668, 0.6575]}, {"w": "any", "b": [0.6733, 0.636, 0.7029, 0.6575]}, {"w": "further.", "b": [0.7094, 0.636, 0.7718, 0.6575]}, {"w": "However,", "b": [0.7783, 0.636, 0.8571, 0.6575]}, {"w": "the", "b": [0.1429, 0.6551, 0.1692, 0.6765]}, {"w": "right", "b": [0.1757, 0.6551, 0.2158, 0.6765]}, {"w": "area", "b": [0.2223, 0.6551, 0.2571, 0.6765]}, {"w": "is", "b": [0.2636, 0.6551, 0.2768, 0.6765]}, {"w": "impure,", "b": [0.2833, 0.6551, 0.3488, 0.6765]}, {"w": "so", "b": [0.3553, 0.6551, 0.3736, 0.6765]}, {"w": "the", "b": [0.38, 0.6551, 0.4064, 0.6765]}, {"w": "depth-1", "b": [0.4128, 0.6551, 0.4785, 0.6765]}, {"w": "right", "b": [0.485, 0.6551, 0.5251, 0.6765]}, {"w": "node", "b": [0.5316, 0.6551, 0.5734, 0.6765]}, {"w": "splits", "b": [0.5799, 0.6551, 0.6233, 0.6765]}, {"w": "it", "b": [0.6298, 0.6551, 0.6417, 0.6765]}, {"w": "at", "b": [0.6482, 0.6551, 0.6633, 0.6765]}, {"w": "petal", "b": [0.6697, 0.6551, 0.7103, 0.6765]}, {"w": "width", "b": [0.7167, 0.6551, 0.7651, 0.6765]}, {"w": "=", "b": [0.7715, 0.6551, 0.7836, 0.6765]}, {"w": "1.75", "b": [0.7901, 0.6551, 0.8248, 0.6765]}, {"w": "cm", "b": [0.8313, 0.6551, 0.8572, 0.6765]}, {"w": "(represented", "b": [0.1429, 0.675, 0.2479, 0.6964]}, {"w": "by", "b": [0.2559, 0.675, 0.2761, 0.6964]}, {"w": "the", "b": [0.2842, 0.675, 0.3105, 0.6964]}, {"w": "dashed", "b": [0.3186, 0.675, 0.3773, 0.6964]}, {"w": "line).", "b": [0.3854, 0.675, 0.4285, 0.6964]}, {"w": "Since", "b": [0.4366, 0.675, 0.4811, 0.6964]}, {"w": "max_depth", "b": [0.4892, 0.6782, 0.5782, 0.6933]}, {"w": "was", "b": [0.5863, 0.675, 0.6174, 0.6964]}, {"w": "set", "b": [0.6255, 0.675, 0.6483, 0.6964]}, {"w": "to", "b": [0.6564, 0.675, 0.6734, 0.6964]}, {"w": "2,", "b": [0.6814, 0.675, 0.6962, 0.6964]}, {"w": "the", "b": [0.7043, 0.675, 0.7306, 0.6964]}, {"w": "Decision", "b": [0.7387, 0.675, 0.8125, 0.6964]}, {"w": "Tree", "b": [0.8206, 0.675, 0.8571, 0.6964]}, {"w": "stops", "b": [0.1429, 0.695, 0.186, 0.7164]}, {"w": "right", "b": [0.1937, 0.695, 0.2339, 0.7164]}, {"w": "there.", "b": [0.2415, 0.695, 0.2892, 0.7164]}, {"w": "However,", "b": [0.2968, 0.695, 0.3757, 0.7164]}, {"w": "if", "b": [0.3834, 0.695, 0.3951, 0.7164]}, {"w": "you", "b": [0.4028, 0.695, 0.434, 0.7164]}, {"w": "set", "b": [0.4417, 0.695, 0.4645, 0.7164]}, {"w": "max_depth", "b": [0.4722, 0.6982, 0.5613, 0.7132]}, {"w": "to", "b": [0.5689, 0.695, 0.5859, 0.7164]}, {"w": "3,", "b": [0.5936, 0.695, 0.6083, 0.7164]}, {"w": "then", "b": [0.616, 0.695, 0.6537, 0.7164]}, {"w": "the", "b": [0.6614, 0.695, 0.6877, 0.7164]}, {"w": "two", "b": [0.6954, 0.695, 0.7266, 0.7164]}, {"w": "depth-2", "b": [0.7343, 0.695, 0.8, 0.7164]}, {"w": "nodes", "b": [0.8076, 0.695, 0.8571, 0.7164]}, {"w": "would", "b": [0.1428, 0.714, 0.1951, 0.7354]}, {"w": "each", "b": [0.1998, 0.714, 0.2377, 0.7354]}, {"w": "add", "b": [0.2425, 0.714, 0.2736, 0.7354]}, {"w": "another", "b": [0.2783, 0.714, 0.3436, 0.7354]}, {"w": "decision", "b": [0.3483, 0.714, 0.4178, 0.7354]}, {"w": "boundary", "b": [0.4225, 0.714, 0.5042, 0.7354]}, {"w": "(represented", "b": [0.509, 0.714, 0.614, 0.7354]}, {"w": "by", "b": [0.6187, 0.714, 0.6388, 0.7354]}, {"w": "the", "b": [0.6436, 0.714, 0.6699, 0.7354]}, {"w": "dotted", "b": [0.6746, 0.714, 0.7288, 0.7354]}, {"w": "lines).", "b": [0.7336, 0.714, 0.7843, 0.7354]}]}, {"id": "b_10", "type": "paragraph", "text": "180 | Chapter 6: Decision Trees", "words": [{"w": "180", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "6:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Decision", "b": [0.2673, 0.9225, 0.3162, 0.9388]}, {"w": "Trees", "b": [0.319, 0.9225, 0.3502, 0.9388]}]}]}, {"page": 207, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 6-2. Decision Tree decision boundaries", "words": [{"w": "Figure", "b": [0.1429, 0.2968, 0.1943, 0.3184]}, {"w": "6-2.", "b": [0.1991, 0.2968, 0.2308, 0.3184]}, {"w": "Decision", "b": [0.2356, 0.2968, 0.3055, 0.3184]}, {"w": "Tree", "b": [0.3103, 0.2968, 0.345, 0.3184]}, {"w": "decision", "b": [0.3498, 0.2968, 0.4153, 0.3184]}, {"w": "boundaries", "b": [0.4201, 0.2968, 0.5105, 0.3184]}]}, {"id": "b_1", "type": "paragraph", "text": "Model Interpretation: White Box Versus Black Box", "words": [{"w": "Model", "b": [0.2574, 0.3472, 0.3186, 0.3744]}, {"w": "Interpretation:", "b": [0.3233, 0.3472, 0.4703, 0.3744]}, {"w": "White", "b": [0.475, 0.3472, 0.5342, 0.3744]}, {"w": "Box", "b": [0.5389, 0.3472, 0.5756, 0.3744]}, {"w": "Versus", "b": [0.5803, 0.3472, 0.6442, 0.3744]}, {"w": "Black", "b": [0.6489, 0.3472, 0.7012, 0.3744]}, {"w": "Box", "b": [0.7059, 0.3472, 0.7426, 0.3744]}]}, {"id": "b_2", "type": "paragraph", "text": "As you can see Decision Trees are fairly intuitive and their decisions are easy to inter‐ pret. Such models are often called white box models. In contrast, as we will see, Ran‐ dom Forests or neural networks are generally considered black box models. They make great predictions, and you can easily check the calculations that they performed to make these predictions; nevertheless, it is usually hard to explain in simple terms why the predictions were made. For example, if a neural network says that a particu‐ lar person appears on a picture, it is hard to know what actually contributed to this prediction: did the model recognize that person’s eyes? Her mouth? Her nose? Her shoes? Or even the couch that she was sitting on? Conversely, Decision Trees provide nice and simple classification rules that can even be applied manually if need be (e.g., for flower classification).", "words": [{"w": "As", "b": [0.1592, 0.3789, 0.1802, 0.3993]}, {"w": "you", "b": [0.1851, 0.3789, 0.2149, 0.3993]}, {"w": "can", "b": [0.2198, 0.3789, 0.2477, 0.3993]}, {"w": "see", "b": [0.2526, 0.3789, 0.2768, 0.3993]}, {"w": "Decision", "b": [0.2817, 0.3789, 0.352, 0.3993]}, {"w": "Trees", "b": [0.3569, 0.3789, 0.399, 0.3993]}, {"w": "are", "b": [0.4039, 0.3789, 0.4284, 0.3993]}, {"w": "fairly", "b": [0.4333, 0.3789, 0.4747, 0.3993]}, {"w": "intuitive", "b": [0.4796, 0.3789, 0.5463, 0.3993]}, {"w": "and", "b": [0.5512, 0.3789, 0.5812, 0.3993]}, {"w": "their", "b": [0.5861, 0.3789, 0.6239, 0.3993]}, {"w": "decisions", "b": [0.6288, 0.3789, 0.7023, 0.3993]}, {"w": "are", "b": [0.7072, 0.3789, 0.7317, 0.3993]}, {"w": "easy", "b": [0.7366, 0.3789, 0.7701, 0.3993]}, {"w": "to", "b": [0.775, 0.3789, 0.7912, 0.3993]}, {"w": "inter‐", "b": [0.7961, 0.3789, 0.8408, 0.3993]}, {"w": "pret.", "b": [0.1592, 0.3971, 0.196, 0.4175]}, {"w": "Such", "b": [0.2017, 0.3971, 0.2407, 0.4175]}, {"w": "models", "b": [0.2464, 0.3971, 0.304, 0.4175]}, {"w": "are", "b": [0.3098, 0.3971, 0.3343, 0.4175]}, {"w": "often", "b": [0.34, 0.3971, 0.3813, 0.4175]}, {"w": "called", "b": [0.3871, 0.3971, 0.4331, 0.4175]}, {"w": "white", "b": [0.4389, 0.3969, 0.4809, 0.4175]}, {"w": "box", "b": [0.4867, 0.3969, 0.5146, 0.4175]}, {"w": "models.", "b": [0.5204, 0.3969, 0.579, 0.4175]}, {"w": "In", "b": [0.5847, 0.3971, 0.6023, 0.4175]}, {"w": "contrast,", "b": [0.6081, 0.3971, 0.6771, 0.4175]}, {"w": "as", "b": [0.6828, 0.3971, 0.6988, 0.4175]}, {"w": "we", "b": [0.7046, 0.3971, 0.7266, 0.4175]}, {"w": "will", "b": [0.7323, 0.3971, 0.7613, 0.4175]}, {"w": "see,", "b": [0.767, 0.3971, 0.7957, 0.4175]}, {"w": "Ran‐", "b": [0.8015, 0.3971, 0.8408, 0.4175]}, {"w": "dom", "b": [0.1592, 0.4152, 0.1961, 0.4356]}, {"w": "Forests", "b": [0.2047, 0.4152, 0.2613, 0.4356]}, {"w": "or", "b": [0.2699, 0.4152, 0.2874, 0.4356]}, {"w": "neural", "b": [0.296, 0.4152, 0.3469, 0.4356]}, {"w": "networks", "b": [0.3556, 0.4152, 0.4291, 0.4356]}, {"w": "are", "b": [0.4377, 0.4152, 0.4622, 0.4356]}, {"w": "generally", "b": [0.4708, 0.4152, 0.5431, 0.4356]}, {"w": "considered", "b": [0.5517, 0.4152, 0.6388, 0.4356]}, {"w": "black", "b": [0.6474, 0.415, 0.688, 0.4356]}, {"w": "box", "b": [0.6966, 0.415, 0.7246, 0.4356]}, {"w": "models.", "b": [0.7332, 0.415, 0.7918, 0.4356]}, {"w": "They", "b": [0.8004, 0.4152, 0.8408, 0.4356]}, {"w": "make", "b": [0.1592, 0.4334, 0.2025, 0.4538]}, {"w": "great", "b": [0.2073, 0.4334, 0.2468, 0.4538]}, {"w": "predictions,", "b": [0.2516, 0.4334, 0.3461, 0.4538]}, {"w": "and", "b": [0.3509, 0.4334, 0.381, 0.4538]}, {"w": "you", "b": [0.3858, 0.4334, 0.4156, 0.4538]}, {"w": "can", "b": [0.4204, 0.4334, 0.4484, 0.4538]}, {"w": "easily", "b": [0.4532, 0.4334, 0.4971, 0.4538]}, {"w": "check", "b": [0.5019, 0.4334, 0.5476, 0.4538]}, {"w": "the", "b": [0.5524, 0.4334, 0.5775, 0.4538]}, {"w": "calculations", "b": [0.5823, 0.4334, 0.6763, 0.4538]}, {"w": "that", "b": [0.6812, 0.4334, 0.7122, 0.4538]}, {"w": "they", "b": [0.717, 0.4334, 0.7512, 0.4538]}, {"w": "performed", "b": [0.7561, 0.4334, 0.8408, 0.4538]}, {"w": "to", "b": [0.1592, 0.4515, 0.1754, 0.4719]}, {"w": "make", "b": [0.1815, 0.4515, 0.2247, 0.4719]}, {"w": "these", "b": [0.2309, 0.4515, 0.2716, 0.4719]}, {"w": "predictions;", "b": [0.2778, 0.4515, 0.3723, 0.4719]}, {"w": "nevertheless,", "b": [0.3784, 0.4515, 0.4803, 0.4719]}, {"w": "it", "b": [0.4864, 0.4515, 0.4978, 0.4719]}, {"w": "is", "b": [0.5039, 0.4515, 0.5165, 0.4719]}, {"w": "usually", "b": [0.5226, 0.4515, 0.5788, 0.4719]}, {"w": "hard", "b": [0.5849, 0.4515, 0.6221, 0.4719]}, {"w": "to", "b": [0.6282, 0.4515, 0.6443, 0.4719]}, {"w": "explain", "b": [0.6505, 0.4515, 0.7086, 0.4719]}, {"w": "in", "b": [0.7147, 0.4515, 0.7308, 0.4719]}, {"w": "simple", "b": [0.737, 0.4515, 0.7893, 0.4719]}, {"w": "terms", "b": [0.7954, 0.4515, 0.8408, 0.4719]}, {"w": "why", "b": [0.1592, 0.4696, 0.1921, 0.49]}, {"w": "the", "b": [0.1975, 0.4696, 0.2226, 0.49]}, {"w": "predictions", "b": [0.2281, 0.4696, 0.3181, 0.49]}, {"w": "were", "b": [0.3235, 0.4696, 0.3613, 0.49]}, {"w": "made.", "b": [0.3668, 0.4696, 0.4152, 0.49]}, {"w": "For", "b": [0.4206, 0.4696, 0.4482, 0.49]}, {"w": "example,", "b": [0.4537, 0.4696, 0.5244, 0.49]}, {"w": "if", "b": [0.5299, 0.4696, 0.5411, 0.49]}, {"w": "a", "b": [0.5466, 0.4696, 0.5553, 0.49]}, {"w": "neural", "b": [0.5607, 0.4696, 0.6116, 0.49]}, {"w": "network", "b": [0.6171, 0.4696, 0.6833, 0.49]}, {"w": "says", "b": [0.6888, 0.4696, 0.7208, 0.49]}, {"w": "that", "b": [0.7263, 0.4696, 0.7573, 0.49]}, {"w": "a", "b": [0.7628, 0.4696, 0.7715, 0.49]}, {"w": "particu‐", "b": [0.7769, 0.4696, 0.8408, 0.49]}, {"w": "lar", "b": [0.1592, 0.4878, 0.1803, 0.5082]}, {"w": "person", "b": [0.1866, 0.4878, 0.241, 0.5082]}, {"w": "appears", "b": [0.2473, 0.4878, 0.3082, 0.5082]}, {"w": "on", "b": [0.3144, 0.4878, 0.3354, 0.5082]}, {"w": "a", "b": [0.3417, 0.4878, 0.3504, 0.5082]}, {"w": "picture,", "b": [0.3566, 0.4878, 0.4177, 0.5082]}, {"w": "it", "b": [0.4239, 0.4878, 0.4353, 0.5082]}, {"w": "is", "b": [0.4415, 0.4878, 0.4541, 0.5082]}, {"w": "hard", "b": [0.4604, 0.4878, 0.4975, 0.5082]}, {"w": "to", "b": [0.5038, 0.4878, 0.52, 0.5082]}, {"w": "know", "b": [0.5262, 0.4878, 0.5706, 0.5082]}, {"w": "what", "b": [0.5769, 0.4878, 0.6155, 0.5082]}, {"w": "actually", "b": [0.6217, 0.4878, 0.6833, 0.5082]}, {"w": "contributed", "b": [0.6895, 0.4878, 0.7828, 0.5082]}, {"w": "to", "b": [0.7891, 0.4878, 0.8053, 0.5082]}, {"w": "this", "b": [0.8115, 0.4878, 0.8408, 0.5082]}, {"w": "prediction:", "b": [0.1592, 0.5059, 0.2465, 0.5263]}, {"w": "did", "b": [0.2535, 0.5059, 0.2798, 0.5263]}, {"w": "the", "b": [0.2869, 0.5059, 0.312, 0.5263]}, {"w": "model", "b": [0.319, 0.5059, 0.3693, 0.5263]}, {"w": "recognize", "b": [0.3764, 0.5059, 0.4529, 0.5263]}, {"w": "that", "b": [0.46, 0.5059, 0.4911, 0.5263]}, {"w": "person’s", "b": [0.4981, 0.5059, 0.5608, 0.5263]}, {"w": "eyes?", "b": [0.5678, 0.5059, 0.6086, 0.5263]}, {"w": "Her", "b": [0.6157, 0.5059, 0.6462, 0.5263]}, {"w": "mouth?", "b": [0.6533, 0.5059, 0.7143, 0.5263]}, {"w": "Her", "b": [0.7214, 0.5059, 0.7519, 0.5263]}, {"w": "nose?", "b": [0.759, 0.5059, 0.8032, 0.5263]}, {"w": "Her", "b": [0.8103, 0.5059, 0.8408, 0.5263]}, {"w": "shoes?", "b": [0.1592, 0.5241, 0.2105, 0.5445]}, {"w": "Or", "b": [0.2156, 0.5241, 0.2378, 0.5445]}, {"w": "even", "b": [0.243, 0.5241, 0.2799, 0.5445]}, {"w": "the", "b": [0.2851, 0.5241, 0.3101, 0.5445]}, {"w": "couch", "b": [0.3153, 0.5241, 0.3633, 0.5445]}, {"w": "that", "b": [0.3685, 0.5241, 0.3995, 0.5445]}, {"w": "she", "b": [0.4047, 0.5241, 0.431, 0.5445]}, {"w": "was", "b": [0.4362, 0.5241, 0.4658, 0.5445]}, {"w": "sitting", "b": [0.471, 0.5241, 0.5211, 0.5445]}, {"w": "on?", "b": [0.5263, 0.5241, 0.5548, 0.5445]}, {"w": "Conversely,", "b": [0.56, 0.5241, 0.6516, 0.5445]}, {"w": "Decision", "b": [0.6567, 0.5241, 0.727, 0.5445]}, {"w": "Trees", "b": [0.7322, 0.5241, 0.7743, 0.5445]}, {"w": "provide", "b": [0.7795, 0.5241, 0.8408, 0.5445]}, {"w": "nice", "b": [0.1592, 0.5422, 0.1922, 0.5626]}, {"w": "and", "b": [0.1974, 0.5422, 0.2274, 0.5626]}, {"w": "simple", "b": [0.2326, 0.5422, 0.285, 0.5626]}, {"w": "classification", "b": [0.2901, 0.5422, 0.3924, 0.5626]}, {"w": "rules", "b": [0.3976, 0.5422, 0.4362, 0.5626]}, {"w": "that", "b": [0.4414, 0.5422, 0.4724, 0.5626]}, {"w": "can", "b": [0.4776, 0.5422, 0.5056, 0.5626]}, {"w": "even", "b": [0.5108, 0.5422, 0.5477, 0.5626]}, {"w": "be", "b": [0.5529, 0.5422, 0.5714, 0.5626]}, {"w": "applied", "b": [0.5766, 0.5422, 0.6349, 0.5626]}, {"w": "manually", "b": [0.6401, 0.5422, 0.714, 0.5626]}, {"w": "if", "b": [0.7192, 0.5422, 0.7303, 0.5626]}, {"w": "need", "b": [0.7355, 0.5422, 0.7737, 0.5626]}, {"w": "be", "b": [0.7789, 0.5422, 0.7974, 0.5626]}, {"w": "(e.g.,", "b": [0.8026, 0.5422, 0.8408, 0.5626]}, {"w": "for", "b": [0.1592, 0.5603, 0.1826, 0.5807]}, {"w": "flower", "b": [0.1871, 0.5603, 0.2375, 0.5807]}, {"w": "classification).", "b": [0.242, 0.5603, 0.3556, 0.5807]}]}, {"id": "b_3", "type": "paragraph", "text": "Estimating Class Probabilities", "words": [{"w": "Estimating", "b": [0.1429, 0.6107, 0.277, 0.645]}, {"w": "Class", "b": [0.283, 0.6107, 0.3433, 0.645]}, {"w": "Probabilities", "b": [0.3492, 0.6107, 0.5059, 0.645]}]}, {"id": "b_4", "type": "paragraph", "text": "A Decision Tree can also estimate the probability that an instance belongs to a partic‐ ular class k: first it traverses the tree to find the leaf node for this instance, and then it returns the ratio of training instances of class k in this node. For example, suppose you have found a flower whose petals are 5 cm long and 1.5 cm wide. The corre‐ sponding leaf node is the depth-2 left node, so the Decision Tree should output the following probabilities: 0% for Iris-Setosa (0/54), 90.7% for Iris-Versicolor (49/54), and 9.3% for Iris-Virginica (5/54). And of course if you ask it to predict the class, it should output Iris-Versicolor (class 1) since it has the highest probability. Let’s check this:", "words": [{"w": "A", "b": [0.1429, 0.6519, 0.1573, 0.6733]}, {"w": "Decision", "b": [0.1623, 0.6519, 0.2362, 0.6733]}, {"w": "Tree", "b": [0.2412, 0.6519, 0.2778, 0.6733]}, {"w": "can", "b": [0.2829, 0.6519, 0.3122, 0.6733]}, {"w": "also", "b": [0.3173, 0.6519, 0.35, 0.6733]}, {"w": "estimate", "b": [0.3551, 0.6519, 0.4246, 0.6733]}, {"w": "the", "b": [0.4297, 0.6519, 0.456, 0.6733]}, {"w": "probability", "b": [0.4611, 0.6519, 0.553, 0.6733]}, {"w": "that", "b": [0.5581, 0.6519, 0.5907, 0.6733]}, {"w": "an", "b": [0.5958, 0.6519, 0.6163, 0.6733]}, {"w": "instance", "b": [0.6214, 0.6519, 0.6906, 0.6733]}, {"w": "belongs", "b": [0.6957, 0.6519, 0.7598, 0.6733]}, {"w": "to", "b": [0.7649, 0.6519, 0.7819, 0.6733]}, {"w": "a", "b": [0.787, 0.6519, 0.7961, 0.6733]}, {"w": "partic‐", "b": [0.8012, 0.6519, 0.8571, 0.6733]}, {"w": "ular", "b": [0.1429, 0.671, 0.1761, 0.6924]}, {"w": "class", "b": [0.1812, 0.671, 0.2197, 0.6924]}, {"w": "k:", "b": [0.2248, 0.6708, 0.2394, 0.6924]}, {"w": "first", "b": [0.2445, 0.671, 0.278, 0.6924]}, {"w": "it", "b": [0.2831, 0.671, 0.295, 0.6924]}, {"w": "traverses", "b": [0.3001, 0.671, 0.3734, 0.6924]}, {"w": "the", "b": [0.3785, 0.671, 0.4048, 0.6924]}, {"w": "tree", "b": [0.4099, 0.671, 0.4417, 0.6924]}, {"w": "to", "b": [0.4468, 0.671, 0.4638, 0.6924]}, {"w": "find", "b": [0.4689, 0.671, 0.5031, 0.6924]}, {"w": "the", "b": [0.5082, 0.671, 0.5345, 0.6924]}, {"w": "leaf", "b": [0.5396, 0.671, 0.5691, 0.6924]}, {"w": "node", "b": [0.5742, 0.671, 0.6161, 0.6924]}, {"w": "for", "b": [0.6212, 0.671, 0.6457, 0.6924]}, {"w": "this", "b": [0.6508, 0.671, 0.6815, 0.6924]}, {"w": "instance,", "b": [0.6866, 0.671, 0.7606, 0.6924]}, {"w": "and", "b": [0.7657, 0.671, 0.7972, 0.6924]}, {"w": "then", "b": [0.8024, 0.671, 0.8401, 0.6924]}, {"w": "it", "b": [0.8452, 0.671, 0.8571, 0.6924]}, {"w": "returns", "b": [0.1428, 0.69, 0.2036, 0.7114]}, {"w": "the", "b": [0.2106, 0.69, 0.2369, 0.7114]}, {"w": "ratio", "b": [0.2438, 0.69, 0.2829, 0.7114]}, {"w": "of", "b": [0.2898, 0.69, 0.3066, 0.7114]}, {"w": "training", "b": [0.3136, 0.69, 0.3805, 0.7114]}, {"w": "instances", "b": [0.3874, 0.69, 0.4643, 0.7114]}, {"w": "of", "b": [0.4712, 0.69, 0.488, 0.7114]}, {"w": "class", "b": [0.495, 0.69, 0.5335, 0.7114]}, {"w": "k", "b": [0.5404, 0.6898, 0.5502, 0.7114]}, {"w": "in", "b": [0.5572, 0.69, 0.5741, 0.7114]}, {"w": "this", "b": [0.5811, 0.69, 0.6118, 0.7114]}, {"w": "node.", "b": [0.6187, 0.69, 0.6654, 0.7114]}, {"w": "For", "b": [0.6723, 0.69, 0.7013, 0.7114]}, {"w": "example,", "b": [0.7082, 0.69, 0.7825, 0.7114]}, {"w": "suppose", "b": [0.7895, 0.69, 0.8571, 0.7114]}, {"w": "you", "b": [0.1429, 0.7091, 0.1741, 0.7305]}, {"w": "have", "b": [0.1818, 0.7091, 0.2202, 0.7305]}, {"w": "found", "b": [0.2278, 0.7091, 0.2781, 0.7305]}, {"w": "a", "b": [0.2857, 0.7091, 0.2948, 0.7305]}, {"w": "flower", "b": [0.3025, 0.7091, 0.3554, 0.7305]}, {"w": "whose", "b": [0.3631, 0.7091, 0.4156, 0.7305]}, {"w": "petals", "b": [0.4232, 0.7091, 0.4714, 0.7305]}, {"w": "are", "b": [0.4791, 0.7091, 0.5048, 0.7305]}, {"w": "5", "b": [0.5124, 0.7091, 0.5224, 0.7305]}, {"w": "cm", "b": [0.5301, 0.7091, 0.556, 0.7305]}, {"w": "long", "b": [0.5636, 0.7091, 0.6006, 0.7305]}, {"w": "and", "b": [0.6083, 0.7091, 0.6398, 0.7305]}, {"w": "1.5", "b": [0.6475, 0.7091, 0.6722, 0.7305]}, {"w": "cm", "b": [0.6799, 0.7091, 0.7058, 0.7305]}, {"w": "wide.", "b": [0.7134, 0.7091, 0.7579, 0.7305]}, {"w": "The", "b": [0.7655, 0.7091, 0.7983, 0.7305]}, {"w": "corre‐", "b": [0.806, 0.7091, 0.8572, 0.7305]}, {"w": "sponding", "b": [0.1429, 0.7281, 0.2212, 0.7495]}, {"w": "leaf", "b": [0.2277, 0.7281, 0.2572, 0.7495]}, {"w": "node", "b": [0.2637, 0.7281, 0.3056, 0.7495]}, {"w": "is", "b": [0.3121, 0.7281, 0.3254, 0.7495]}, {"w": "the", "b": [0.3319, 0.7281, 0.3583, 0.7495]}, {"w": "depth-2", "b": [0.3648, 0.7281, 0.4305, 0.7495]}, {"w": "left", "b": [0.437, 0.7281, 0.4637, 0.7495]}, {"w": "node,", "b": [0.4702, 0.7281, 0.5169, 0.7495]}, {"w": "so", "b": [0.5234, 0.7281, 0.5417, 0.7495]}, {"w": "the", "b": [0.5482, 0.7281, 0.5746, 0.7495]}, {"w": "Decision", "b": [0.5811, 0.7281, 0.6549, 0.7495]}, {"w": "Tree", "b": [0.6615, 0.7281, 0.698, 0.7495]}, {"w": "should", "b": [0.7046, 0.7281, 0.7613, 0.7495]}, {"w": "output", "b": [0.7679, 0.7281, 0.8243, 0.7495]}, {"w": "the", "b": [0.8308, 0.7281, 0.8571, 0.7495]}, {"w": "following", "b": [0.1429, 0.7472, 0.2218, 0.7686]}, {"w": "probabilities:", "b": [0.2296, 0.7472, 0.3388, 0.7686]}, {"w": "0%", "b": [0.3465, 0.7472, 0.3723, 0.7686]}, {"w": "for", "b": [0.38, 0.7472, 0.4045, 0.7686]}, {"w": "Iris-Setosa", "b": [0.4123, 0.7472, 0.5003, 0.7686]}, {"w": "(0/54),", "b": [0.508, 0.7472, 0.5641, 0.7686]}, {"w": "90.7%", "b": [0.5718, 0.7472, 0.6223, 0.7686]}, {"w": "for", "b": [0.6301, 0.7472, 0.6546, 0.7686]}, {"w": "Iris-Versicolor", "b": [0.6623, 0.7472, 0.7833, 0.7686]}, {"w": "(49/54),", "b": [0.7911, 0.7472, 0.8571, 0.7686]}, {"w": "and", "b": [0.1429, 0.7662, 0.1744, 0.7876]}, {"w": "9.3%", "b": [0.1807, 0.7662, 0.2212, 0.7876]}, {"w": "for", "b": [0.2275, 0.7662, 0.252, 0.7876]}, {"w": "Iris-Virginica", "b": [0.2583, 0.7662, 0.3712, 0.7876]}, {"w": "(5/54).", "b": [0.3774, 0.7662, 0.4335, 0.7876]}, {"w": "And", "b": [0.4398, 0.7662, 0.4766, 0.7876]}, {"w": "of", "b": [0.4829, 0.7662, 0.4997, 0.7876]}, {"w": "course", "b": [0.506, 0.7662, 0.5607, 0.7876]}, {"w": "if", "b": [0.567, 0.7662, 0.5787, 0.7876]}, {"w": "you", "b": [0.585, 0.7662, 0.6163, 0.7876]}, {"w": "ask", "b": [0.6226, 0.7662, 0.6497, 0.7876]}, {"w": "it", "b": [0.656, 0.7662, 0.6679, 0.7876]}, {"w": "to", "b": [0.6742, 0.7662, 0.6912, 0.7876]}, {"w": "predict", "b": [0.6975, 0.7662, 0.7567, 0.7876]}, {"w": "the", "b": [0.763, 0.7662, 0.7894, 0.7876]}, {"w": "class,", "b": [0.7957, 0.7662, 0.8389, 0.7876]}, {"w": "it", "b": [0.8452, 0.7662, 0.8572, 0.7876]}, {"w": "should", "b": [0.1429, 0.7852, 0.1996, 0.8067]}, {"w": "output", "b": [0.2053, 0.7852, 0.2617, 0.8067]}, {"w": "Iris-Versicolor", "b": [0.2675, 0.7852, 0.3885, 0.8067]}, {"w": "(class", "b": [0.3942, 0.7852, 0.4399, 0.8067]}, {"w": "1)", "b": [0.4457, 0.7852, 0.4629, 0.8067]}, {"w": "since", "b": [0.4687, 0.7852, 0.511, 0.8067]}, {"w": "it", "b": [0.5167, 0.7852, 0.5286, 0.8067]}, {"w": "has", "b": [0.5344, 0.7852, 0.5623, 0.8067]}, {"w": "the", "b": [0.5681, 0.7852, 0.5944, 0.8067]}, {"w": "highest", "b": [0.6002, 0.7852, 0.6606, 0.8067]}, {"w": "probability.", "b": [0.6664, 0.7852, 0.7615, 0.8067]}, {"w": "Let’s", "b": [0.7673, 0.7852, 0.8035, 0.8067]}, {"w": "check", "b": [0.8092, 0.7852, 0.8571, 0.8067]}, {"w": "this:", "b": [0.1429, 0.8043, 0.1783, 0.8257]}]}, {"id": "b_5", "type": "equation", "text": ">>> tree_clf.predict_proba([[5, 1.5]]) array([[0. , 0.90740741, 0.09259259]])", "words": [{"w": ">>>", "b": [0.1766, 0.8363, 0.2019, 0.8491]}, {"w": "tree_clf.predict_proba([[5,", "b": [0.2103, 0.8363, 0.438, 0.8491]}, {"w": "1.5]])", "b": [0.4464, 0.8363, 0.497, 0.8491]}, {"w": "array([[0.", "b": [0.1766, 0.8517, 0.2609, 0.8645]}, {"w": ",", "b": [0.3284, 0.8517, 0.3368, 0.8645]}, {"w": "0.90740741,", "b": [0.3452, 0.8517, 0.438, 0.8645]}, {"w": "0.09259259]])", "b": [0.4464, 0.8517, 0.5561, 0.8645]}]}, {"id": "b_6", "type": "paragraph", "text": "Estimating Class Probabilities | 181", "words": [{"w": "Estimating", "b": [0.6231, 0.9225, 0.687, 0.9388]}, {"w": "Class", "b": [0.6898, 0.9225, 0.7185, 0.9388]}, {"w": "Probabilities", "b": [0.7213, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "181", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 208, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": ">>> tree_clf.predict([[5, 1.5]]) array([1])", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "tree_clf.predict([[5,", "b": [0.2103, 0.0829, 0.3874, 0.0958]}, {"w": "1.5]])", "b": [0.3958, 0.0829, 0.4464, 0.0958]}, {"w": "array([1])", "b": [0.1766, 0.0983, 0.2609, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "Perfect! Notice that the estimated probabilities would be identical anywhere else in the bottom-right rectangle of Figure 6-2—for example, if the petals were 6 cm long and 1.5 cm wide (even though it seems obvious that it would most likely be an Iris- Virginica in this case).", "words": [{"w": "Perfect!", "b": [0.1429, 0.119, 0.2064, 0.1404]}, {"w": "Notice", "b": [0.2137, 0.119, 0.2689, 0.1404]}, {"w": "that", "b": [0.2762, 0.119, 0.3088, 0.1404]}, {"w": "the", "b": [0.3161, 0.119, 0.3425, 0.1404]}, {"w": "estimated", "b": [0.3498, 0.119, 0.4302, 0.1404]}, {"w": "probabilities", "b": [0.4375, 0.119, 0.542, 0.1404]}, {"w": "would", "b": [0.5493, 0.119, 0.6015, 0.1404]}, {"w": "be", "b": [0.6088, 0.119, 0.6283, 0.1404]}, {"w": "identical", "b": [0.6356, 0.119, 0.7072, 0.1404]}, {"w": "anywhere", "b": [0.7145, 0.119, 0.7949, 0.1404]}, {"w": "else", "b": [0.8022, 0.119, 0.8329, 0.1404]}, {"w": "in", "b": [0.8402, 0.119, 0.8571, 0.1404]}, {"w": "the", "b": [0.1429, 0.138, 0.1692, 0.1594]}, {"w": "bottom-right", "b": [0.1759, 0.138, 0.2851, 0.1594]}, {"w": "rectangle", "b": [0.2918, 0.138, 0.368, 0.1594]}, {"w": "of", "b": [0.3747, 0.138, 0.3915, 0.1594]}, {"w": "Figure", "b": [0.3982, 0.138, 0.4522, 0.1594]}, {"w": "6-2—for", "b": [0.459, 0.138, 0.5301, 0.1594]}, {"w": "example,", "b": [0.5369, 0.138, 0.6111, 0.1594]}, {"w": "if", "b": [0.6179, 0.138, 0.6296, 0.1594]}, {"w": "the", "b": [0.6364, 0.138, 0.6627, 0.1594]}, {"w": "petals", "b": [0.6694, 0.138, 0.7176, 0.1594]}, {"w": "were", "b": [0.7243, 0.138, 0.764, 0.1594]}, {"w": "6", "b": [0.7708, 0.138, 0.7808, 0.1594]}, {"w": "cm", "b": [0.7875, 0.138, 0.8134, 0.1594]}, {"w": "long", "b": [0.8201, 0.138, 0.8572, 0.1594]}, {"w": "and", "b": [0.1429, 0.1571, 0.1744, 0.1785]}, {"w": "1.5", "b": [0.1806, 0.1571, 0.2054, 0.1785]}, {"w": "cm", "b": [0.2116, 0.1571, 0.2375, 0.1785]}, {"w": "wide", "b": [0.2438, 0.1571, 0.2835, 0.1785]}, {"w": "(even", "b": [0.2897, 0.1571, 0.3357, 0.1785]}, {"w": "though", "b": [0.3419, 0.1571, 0.4019, 0.1785]}, {"w": "it", "b": [0.4082, 0.1571, 0.4201, 0.1785]}, {"w": "seems", "b": [0.4264, 0.1571, 0.4764, 0.1785]}, {"w": "obvious", "b": [0.4827, 0.1571, 0.5484, 0.1785]}, {"w": "that", "b": [0.5547, 0.1571, 0.5873, 0.1785]}, {"w": "it", "b": [0.5935, 0.1571, 0.6054, 0.1785]}, {"w": "would", "b": [0.6117, 0.1571, 0.6639, 0.1785]}, {"w": "most", "b": [0.6702, 0.1571, 0.7118, 0.1785]}, {"w": "likely", "b": [0.7181, 0.1571, 0.763, 0.1785]}, {"w": "be", "b": [0.7692, 0.1571, 0.7886, 0.1785]}, {"w": "an", "b": [0.7949, 0.1571, 0.8154, 0.1785]}, {"w": "Iris-", "b": [0.8217, 0.1571, 0.8571, 0.1785]}, {"w": "Virginica", "b": [0.1429, 0.1761, 0.2202, 0.1975]}, {"w": "in", "b": [0.225, 0.1761, 0.2419, 0.1975]}, {"w": "this", "b": [0.2467, 0.1761, 0.2774, 0.1975]}, {"w": "case).", "b": [0.2821, 0.1761, 0.3285, 0.1975]}]}, {"id": "b_2", "type": "paragraph", "text": "The CART Training Algorithm", "words": [{"w": "The", "b": [0.1428, 0.2105, 0.188, 0.2448]}, {"w": "CART", "b": [0.194, 0.2105, 0.256, 0.2448]}, {"w": "Training", "b": [0.2619, 0.2105, 0.3651, 0.2448]}, {"w": "Algorithm", "b": [0.371, 0.2105, 0.4965, 0.2448]}]}, {"id": "b_3", "type": "paragraph", "text": "Scikit-Learn uses the Classification And Regression Tree (CART) algorithm to train Decision Trees (also called “growing” trees). The idea is really quite simple: the algo‐ rithm first splits the training set in two subsets using a single feature k and a thres‐ hold tk (e.g., “petal length ≤ 2.45 cm”). How does it choose k and tk? It searches for the pair (k, tk) that produces the purest subsets (weighted by their size). The cost function that the algorithm tries to minimize is given by Equation 6-2.", "words": [{"w": "Scikit-Learn", "b": [0.1429, 0.2517, 0.2452, 0.2731]}, {"w": "uses", "b": [0.2529, 0.2517, 0.2881, 0.2731]}, {"w": "the", "b": [0.2958, 0.2517, 0.3222, 0.2731]}, {"w": "Classification", "b": [0.3299, 0.2515, 0.4404, 0.2731]}, {"w": "And", "b": [0.4482, 0.2515, 0.4836, 0.2731]}, {"w": "Regression", "b": [0.4913, 0.2515, 0.5761, 0.2731]}, {"w": "Tree", "b": [0.5838, 0.2515, 0.6186, 0.2731]}, {"w": "(CART)", "b": [0.6263, 0.2517, 0.6941, 0.2731]}, {"w": "algorithm", "b": [0.7019, 0.2517, 0.7845, 0.2731]}, {"w": "to", "b": [0.7922, 0.2517, 0.8092, 0.2731]}, {"w": "train", "b": [0.8169, 0.2517, 0.8571, 0.2731]}, {"w": "Decision", "b": [0.1429, 0.2707, 0.2167, 0.2922]}, {"w": "Trees", "b": [0.2225, 0.2707, 0.2667, 0.2922]}, {"w": "(also", "b": [0.2725, 0.2707, 0.3124, 0.2922]}, {"w": "called", "b": [0.3182, 0.2707, 0.3666, 0.2922]}, {"w": "“growing”", "b": [0.3724, 0.2707, 0.4561, 0.2922]}, {"w": "trees).", "b": [0.4619, 0.2707, 0.5133, 0.2922]}, {"w": "The", "b": [0.5192, 0.2707, 0.552, 0.2922]}, {"w": "idea", "b": [0.5578, 0.2707, 0.5924, 0.2922]}, {"w": "is", "b": [0.5982, 0.2707, 0.6115, 0.2922]}, {"w": "really", "b": [0.6173, 0.2707, 0.6631, 0.2922]}, {"w": "quite", "b": [0.6689, 0.2707, 0.7114, 0.2922]}, {"w": "simple:", "b": [0.7173, 0.2707, 0.777, 0.2922]}, {"w": "the", "b": [0.7828, 0.2707, 0.8091, 0.2922]}, {"w": "algo‐", "b": [0.8149, 0.2707, 0.8571, 0.2922]}, {"w": "rithm", "b": [0.1428, 0.2898, 0.1907, 0.3112]}, {"w": "first", "b": [0.1973, 0.2898, 0.2307, 0.3112]}, {"w": "splits", "b": [0.2373, 0.2898, 0.2807, 0.3112]}, {"w": "the", "b": [0.2873, 0.2898, 0.3136, 0.3112]}, {"w": "training", "b": [0.3202, 0.2898, 0.3871, 0.3112]}, {"w": "set", "b": [0.3937, 0.2898, 0.4165, 0.3112]}, {"w": "in", "b": [0.4231, 0.2898, 0.4401, 0.3112]}, {"w": "two", "b": [0.4466, 0.2898, 0.4779, 0.3112]}, {"w": "subsets", "b": [0.4844, 0.2898, 0.5442, 0.3112]}, {"w": "using", "b": [0.5508, 0.2898, 0.5962, 0.3112]}, {"w": "a", "b": [0.6028, 0.2898, 0.6119, 0.3112]}, {"w": "single", "b": [0.6185, 0.2898, 0.667, 0.3112]}, {"w": "feature", "b": [0.6735, 0.2898, 0.7313, 0.3112]}, {"w": "k", "b": [0.7379, 0.2896, 0.7476, 0.3112]}, {"w": "and", "b": [0.7542, 0.2898, 0.7857, 0.3112]}, {"w": "a", "b": [0.7923, 0.2898, 0.8014, 0.3112]}, {"w": "thres‐", "b": [0.808, 0.2898, 0.8571, 0.3112]}, {"w": "hold", "b": [0.1429, 0.3088, 0.1809, 0.3303]}, {"w": "tk", "b": [0.1858, 0.3086, 0.1981, 0.3311]}, {"w": "(e.g.,", "b": [0.203, 0.3088, 0.2431, 0.3303]}, {"w": "“petal", "b": [0.2478, 0.3088, 0.2959, 0.3303]}, {"w": "length", "b": [0.3006, 0.3088, 0.3534, 0.3303]}, {"w": "≤", "b": [0.3587, 0.3088, 0.3708, 0.3303]}, {"w": "2.45", "b": [0.3757, 0.3088, 0.4105, 0.3303]}, {"w": "cm”).", "b": [0.4154, 0.3088, 0.4599, 0.3303]}, {"w": "How", "b": [0.4648, 0.3088, 0.5052, 0.3303]}, {"w": "does", "b": [0.5101, 0.3088, 0.5482, 0.3303]}, {"w": "it", "b": [0.5532, 0.3088, 0.5651, 0.3303]}, {"w": "choose", "b": [0.5701, 0.3088, 0.6277, 0.3303]}, {"w": "k", "b": [0.6327, 0.3086, 0.6425, 0.3303]}, {"w": "and", "b": [0.6474, 0.3088, 0.679, 0.3303]}, {"w": "tk?", "b": [0.6839, 0.3086, 0.7041, 0.3311]}, {"w": "It", "b": [0.709, 0.3088, 0.7217, 0.3303]}, {"w": "searches", "b": [0.7266, 0.3088, 0.7964, 0.3303]}, {"w": "for", "b": [0.8014, 0.3088, 0.8259, 0.3303]}, {"w": "the", "b": [0.8308, 0.3088, 0.8571, 0.3303]}, {"w": "pair", "b": [0.1429, 0.3279, 0.1762, 0.3493]}, {"w": "(k,", "b": [0.181, 0.3277, 0.2029, 0.3493]}, {"w": "tk)", "b": [0.2078, 0.3277, 0.2273, 0.3502]}, {"w": "that", "b": [0.2322, 0.3279, 0.2648, 0.3493]}, {"w": "produces", "b": [0.2697, 0.3279, 0.3464, 0.3493]}, {"w": "the", "b": [0.3513, 0.3279, 0.3776, 0.3493]}, {"w": "purest", "b": [0.3826, 0.3279, 0.4351, 0.3493]}, {"w": "subsets", "b": [0.44, 0.3279, 0.4998, 0.3493]}, {"w": "(weighted", "b": [0.5048, 0.3279, 0.5874, 0.3493]}, {"w": "by", "b": [0.5923, 0.3279, 0.6124, 0.3493]}, {"w": "their", "b": [0.6173, 0.3279, 0.657, 0.3493]}, {"w": "size).", "b": [0.6619, 0.3279, 0.7047, 0.3493]}, {"w": "The", "b": [0.7096, 0.3279, 0.7425, 0.3493]}, {"w": "cost", "b": [0.7474, 0.3279, 0.7808, 0.3493]}, {"w": "function", "b": [0.7857, 0.3279, 0.8571, 0.3493]}, {"w": "that", "b": [0.1428, 0.3469, 0.1754, 0.3684]}, {"w": "the", "b": [0.1802, 0.3469, 0.2065, 0.3684]}, {"w": "algorithm", "b": [0.2112, 0.3469, 0.2939, 0.3684]}, {"w": "tries", "b": [0.2986, 0.3469, 0.3348, 0.3684]}, {"w": "to", "b": [0.3395, 0.3469, 0.3565, 0.3684]}, {"w": "minimize", "b": [0.3612, 0.3469, 0.4411, 0.3684]}, {"w": "is", "b": [0.4458, 0.3469, 0.459, 0.3684]}, {"w": "given", "b": [0.4638, 0.3469, 0.509, 0.3684]}, {"w": "by", "b": [0.5137, 0.3469, 0.5339, 0.3684]}, {"w": "Equation", "b": [0.5386, 0.3469, 0.6148, 0.3684]}, {"w": "6-2.", "b": [0.6196, 0.3469, 0.6517, 0.3684]}]}, {"id": "b_4", "type": "equation", "text": "Equation 6-2. CART cost function for classification", "words": [{"w": "Equation", "b": [0.1726, 0.3865, 0.2473, 0.4081]}, {"w": "6-2.", "b": [0.2521, 0.3865, 0.2838, 0.4081]}, {"w": "CART", "b": [0.2886, 0.3865, 0.3397, 0.4081]}, {"w": "cost", "b": [0.3445, 0.3865, 0.3751, 0.4081]}, {"w": "function", "b": [0.3799, 0.3865, 0.448, 0.4081]}, {"w": "for", "b": [0.4528, 0.3865, 0.4754, 0.4081]}, {"w": "classification", "b": [0.4802, 0.3865, 0.5855, 0.4081]}]}, {"id": "b_5", "type": "equation", "text": "J k, tk =", "words": [{"w": "J", "b": [0.1818, 0.4276, 0.1882, 0.4482]}, {"w": "k,", "b": [0.1961, 0.4276, 0.2099, 0.4482]}, {"w": "tk", "b": [0.2132, 0.4276, 0.2273, 0.4525]}, {"w": "=", "b": [0.2396, 0.4278, 0.2511, 0.4482]}]}, {"id": "b_6", "type": "paragraph", "text": "mleft", "words": [{"w": "mleft", "b": [0.2589, 0.4142, 0.2948, 0.4391]}]}, {"id": "b_7", "type": "equation", "text": "m Gleft +", "words": [{"w": "m", "b": [0.269, 0.4364, 0.2846, 0.457]}, {"w": "Gleft", "b": [0.297, 0.4276, 0.3308, 0.4525]}, {"w": "+", "b": [0.3352, 0.4278, 0.3467, 0.4482]}]}, {"id": "b_8", "type": "paragraph", "text": "mright", "words": [{"w": "mright", "b": [0.3533, 0.4142, 0.3998, 0.4391]}]}, {"id": "b_9", "type": "paragraph", "text": "m Gright", "words": [{"w": "m", "b": [0.3688, 0.4364, 0.3844, 0.457]}, {"w": "Gright", "b": [0.402, 0.4276, 0.4464, 0.4525]}]}, {"id": "b_10", "type": "paragraph", "text": "where", "words": [{"w": "where", "b": [0.1813, 0.4738, 0.2297, 0.4942]}]}, {"id": "b_11", "type": "equation", "text": "Gleft/right measures the impurity of the left/right subset,", "words": [{"w": "Gleft/right", "b": [0.2445, 0.4582, 0.3145, 0.483]}, {"w": "measures", "b": [0.3224, 0.4584, 0.3967, 0.4787]}, {"w": "the", "b": [0.4047, 0.4584, 0.4297, 0.4787]}, {"w": "impurity", "b": [0.4377, 0.4584, 0.508, 0.4787]}, {"w": "of", "b": [0.5161, 0.4584, 0.5321, 0.4787]}, {"w": "the", "b": [0.5417, 0.4584, 0.5667, 0.4787]}, {"w": "left/right", "b": [0.5747, 0.4584, 0.6452, 0.4787]}, {"w": "subset,", "b": [0.6532, 0.4584, 0.7074, 0.4787]}]}, {"id": "b_12", "type": "equation", "text": "mleft/right is the number of instances in the left/right subset.", "words": [{"w": "mleft/right", "b": [0.2445, 0.4844, 0.3166, 0.5093]}, {"w": "is", "b": [0.3245, 0.4846, 0.3371, 0.505]}, {"w": "the", "b": [0.3451, 0.4846, 0.3702, 0.505]}, {"w": "number", "b": [0.3781, 0.4846, 0.4416, 0.505]}, {"w": "of", "b": [0.4495, 0.4846, 0.4655, 0.505]}, {"w": "instances", "b": [0.4751, 0.4846, 0.5483, 0.505]}, {"w": "in", "b": [0.5562, 0.4846, 0.5724, 0.505]}, {"w": "the", "b": [0.5803, 0.4846, 0.6054, 0.505]}, {"w": "left/right", "b": [0.6134, 0.4846, 0.6839, 0.505]}, {"w": "subset.", "b": [0.6918, 0.4846, 0.746, 0.505]}]}, {"id": "b_13", "type": "paragraph", "text": "Once it has successfully split the training set in two, it splits the subsets using the same logic, then the sub-subsets and so on, recursively. It stops recursing once it rea‐ ches the maximum depth (defined by the max_depth hyperparameter), or if it cannot find a split that will reduce impurity. A few other hyperparameters (described in a moment) control additional stopping conditions (min_samples_split, min_sam ples_leaf, min_weight_fraction_leaf, and max_leaf_nodes).", "words": [{"w": "Once", "b": [0.1429, 0.5283, 0.1875, 0.5498]}, {"w": "it", "b": [0.1951, 0.5283, 0.2071, 0.5498]}, {"w": "has", "b": [0.2147, 0.5283, 0.2426, 0.5498]}, {"w": "successfully", "b": [0.2502, 0.5283, 0.348, 0.5498]}, {"w": "split", "b": [0.3557, 0.5283, 0.3914, 0.5498]}, {"w": "the", "b": [0.3991, 0.5283, 0.4254, 0.5498]}, {"w": "training", "b": [0.433, 0.5283, 0.5, 0.5498]}, {"w": "set", "b": [0.5076, 0.5283, 0.5305, 0.5498]}, {"w": "in", "b": [0.5381, 0.5283, 0.5551, 0.5498]}, {"w": "two,", "b": [0.5627, 0.5283, 0.5981, 0.5498]}, {"w": "it", "b": [0.6057, 0.5283, 0.6177, 0.5498]}, {"w": "splits", "b": [0.6253, 0.5283, 0.6687, 0.5498]}, {"w": "the", "b": [0.6764, 0.5283, 0.7027, 0.5498]}, {"w": "subsets", "b": [0.7103, 0.5283, 0.7701, 0.5498]}, {"w": "using", "b": [0.7777, 0.5283, 0.8232, 0.5498]}, {"w": "the", "b": [0.8308, 0.5283, 0.8571, 0.5498]}, {"w": "same", "b": [0.1429, 0.5474, 0.1856, 0.5688]}, {"w": "logic,", "b": [0.191, 0.5474, 0.2358, 0.5688]}, {"w": "then", "b": [0.2413, 0.5474, 0.279, 0.5688]}, {"w": "the", "b": [0.2845, 0.5474, 0.3108, 0.5688]}, {"w": "sub-subsets", "b": [0.3163, 0.5474, 0.4128, 0.5688]}, {"w": "and", "b": [0.4182, 0.5474, 0.4498, 0.5688]}, {"w": "so", "b": [0.4552, 0.5474, 0.4735, 0.5688]}, {"w": "on,", "b": [0.479, 0.5474, 0.5057, 0.5688]}, {"w": "recursively.", "b": [0.5112, 0.5474, 0.6052, 0.5688]}, {"w": "It", "b": [0.6107, 0.5474, 0.6233, 0.5688]}, {"w": "stops", "b": [0.6288, 0.5474, 0.6719, 0.5688]}, {"w": "recursing", "b": [0.6774, 0.5474, 0.756, 0.5688]}, {"w": "once", "b": [0.7614, 0.5474, 0.8011, 0.5688]}, {"w": "it", "b": [0.8066, 0.5474, 0.8185, 0.5688]}, {"w": "rea‐", "b": [0.824, 0.5474, 0.8571, 0.5688]}, {"w": "ches", "b": [0.1429, 0.5673, 0.1793, 0.5888]}, {"w": "the", "b": [0.1848, 0.5673, 0.2111, 0.5888]}, {"w": "maximum", "b": [0.2166, 0.5673, 0.3031, 0.5888]}, {"w": "depth", "b": [0.3086, 0.5673, 0.3568, 0.5888]}, {"w": "(defined", "b": [0.3623, 0.5673, 0.4324, 0.5888]}, {"w": "by", "b": [0.4379, 0.5673, 0.458, 0.5888]}, {"w": "the", "b": [0.4635, 0.5673, 0.4899, 0.5888]}, {"w": "max_depth", "b": [0.4954, 0.5705, 0.5844, 0.5856]}, {"w": "hyperparameter),", "b": [0.5899, 0.5673, 0.7354, 0.5888]}, {"w": "or", "b": [0.7409, 0.5673, 0.7592, 0.5888]}, {"w": "if", "b": [0.7647, 0.5673, 0.7765, 0.5888]}, {"w": "it", "b": [0.782, 0.5673, 0.7939, 0.5888]}, {"w": "cannot", "b": [0.7994, 0.5673, 0.8572, 0.5888]}, {"w": "find", "b": [0.1429, 0.5864, 0.177, 0.6078]}, {"w": "a", "b": [0.1844, 0.5864, 0.1936, 0.6078]}, {"w": "split", "b": [0.201, 0.5864, 0.2367, 0.6078]}, {"w": "that", "b": [0.2442, 0.5864, 0.2767, 0.6078]}, {"w": "will", "b": [0.2841, 0.5864, 0.3145, 0.6078]}, {"w": "reduce", "b": [0.322, 0.5864, 0.3783, 0.6078]}, {"w": "impurity.", "b": [0.3857, 0.5864, 0.4624, 0.6078]}, {"w": "A", "b": [0.4698, 0.5864, 0.4842, 0.6078]}, {"w": "few", "b": [0.4916, 0.5864, 0.5209, 0.6078]}, {"w": "other", "b": [0.5283, 0.5864, 0.573, 0.6078]}, {"w": "hyperparameters", "b": [0.5804, 0.5864, 0.7215, 0.6078]}, {"w": "(described", "b": [0.7289, 0.5864, 0.8162, 0.6078]}, {"w": "in", "b": [0.8236, 0.5864, 0.8406, 0.6078]}, {"w": "a", "b": [0.848, 0.5864, 0.8571, 0.6078]}, {"w": "moment)", "b": [0.1429, 0.6063, 0.221, 0.6277]}, {"w": "control", "b": [0.233, 0.6063, 0.2934, 0.6277]}, {"w": "additional", "b": [0.3054, 0.6063, 0.3905, 0.6277]}, {"w": "stopping", "b": [0.4026, 0.6063, 0.4757, 0.6277]}, {"w": "conditions", "b": [0.4877, 0.6063, 0.5768, 0.6277]}, {"w": "(min_samples_split,", "b": [0.5888, 0.6063, 0.769, 0.6277]}, {"w": "min_sam", "b": [0.781, 0.6095, 0.8502, 0.6246]}, {"w": "ples_leaf,", "b": [0.1429, 0.6263, 0.2367, 0.6477]}, {"w": "min_weight_fraction_leaf,", "b": [0.2414, 0.6263, 0.4836, 0.6477]}, {"w": "and", "b": [0.4884, 0.6263, 0.5199, 0.6477]}, {"w": "max_leaf_nodes).", "b": [0.5246, 0.6263, 0.6751, 0.6477]}]}, {"id": "b_14", "type": "paragraph", "text": "182 | Chapter 6: Decision Trees", "words": [{"w": "182", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "6:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Decision", "b": [0.2673, 0.9225, 0.3162, 0.9388]}, {"w": "Trees", "b": [0.319, 0.9225, 0.3502, 0.9388]}]}]}, {"page": 209, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "2 P is the set of problems that can be solved in polynomial time. NP is the set of problems whose solutions can be verified in polynomial time. An NP-Hard problem is a problem to which any NP problem can be reduced in polynomial time. An NP-Complete problem is both NP and NP-Hard. A major open mathematical ques‐ tion is whether or not P = NP. If P ≠ NP (which seems likely), then no polynomial algorithm will ever be found for any NP-Complete problem (except perhaps on a quantum computer).", "words": [{"w": "2", "b": [0.1451, 0.7766, 0.1518, 0.7909]}, {"w": "P", "b": [0.1587, 0.7751, 0.1677, 0.7915]}, {"w": "is", "b": [0.1713, 0.7751, 0.1813, 0.7915]}, {"w": "the", "b": [0.185, 0.7751, 0.205, 0.7915]}, {"w": "set", "b": [0.2086, 0.7751, 0.226, 0.7915]}, {"w": "of", "b": [0.2296, 0.7751, 0.2424, 0.7915]}, {"w": "problems", "b": [0.246, 0.7751, 0.306, 0.7915]}, {"w": "that", "b": [0.3096, 0.7751, 0.3344, 0.7915]}, {"w": "can", "b": [0.338, 0.7751, 0.3604, 0.7915]}, {"w": "be", "b": [0.364, 0.7751, 0.3788, 0.7915]}, {"w": "solved", "b": [0.3824, 0.7751, 0.4228, 0.7915]}, {"w": "in", "b": [0.4264, 0.7751, 0.4393, 0.7915]}, {"w": "polynomial", "b": [0.443, 0.7751, 0.5157, 0.7915]}, {"w": "time.", "b": [0.5193, 0.7751, 0.5517, 0.7915]}, {"w": "NP", "b": [0.5553, 0.7751, 0.5761, 0.7915]}, {"w": "is", "b": [0.5797, 0.7751, 0.5898, 0.7915]}, {"w": "the", "b": [0.5934, 0.7751, 0.6134, 0.7915]}, {"w": "set", "b": [0.617, 0.7751, 0.6344, 0.7915]}, {"w": "of", "b": [0.638, 0.7751, 0.6508, 0.7915]}, {"w": "problems", "b": [0.6544, 0.7751, 0.7144, 0.7915]}, {"w": "whose", "b": [0.718, 0.7751, 0.758, 0.7915]}, {"w": "solutions", "b": [0.7616, 0.7751, 0.8197, 0.7915]}, {"w": "can", "b": [0.8233, 0.7751, 0.8457, 0.7915]}, {"w": "be", "b": [0.1587, 0.7903, 0.1735, 0.8066]}, {"w": "verified", "b": [0.1771, 0.7903, 0.2255, 0.8066]}, {"w": "in", "b": [0.2291, 0.7903, 0.242, 0.8066]}, {"w": "polynomial", "b": [0.2456, 0.7903, 0.3183, 0.8066]}, {"w": "time.", "b": [0.3219, 0.7903, 0.3544, 0.8066]}, {"w": "An", "b": [0.358, 0.7903, 0.3777, 0.8066]}, {"w": "NP-Hard", "b": [0.3813, 0.7903, 0.4399, 0.8066]}, {"w": "problem", "b": [0.4435, 0.7903, 0.4976, 0.8066]}, {"w": "is", "b": [0.5012, 0.7903, 0.5113, 0.8066]}, {"w": "a", "b": [0.5149, 0.7903, 0.5219, 0.8066]}, {"w": "problem", "b": [0.5255, 0.7903, 0.5796, 0.8066]}, {"w": "to", "b": [0.5832, 0.7903, 0.5961, 0.8066]}, {"w": "which", "b": [0.5997, 0.7903, 0.6385, 0.8066]}, {"w": "any", "b": [0.6421, 0.7903, 0.6647, 0.8066]}, {"w": "NP", "b": [0.6683, 0.7903, 0.689, 0.8066]}, {"w": "problem", "b": [0.6926, 0.7903, 0.7468, 0.8066]}, {"w": "can", "b": [0.7504, 0.7903, 0.7727, 0.8066]}, {"w": "be", "b": [0.7763, 0.7903, 0.7911, 0.8066]}, {"w": "reduced", "b": [0.7947, 0.7903, 0.846, 0.8066]}, {"w": "in", "b": [0.1587, 0.8054, 0.1717, 0.8217]}, {"w": "polynomial", "b": [0.1753, 0.8054, 0.248, 0.8217]}, {"w": "time.", "b": [0.2516, 0.8054, 0.2841, 0.8217]}, {"w": "An", "b": [0.2877, 0.8054, 0.3073, 0.8217]}, {"w": "NP-Complete", "b": [0.3109, 0.8054, 0.3985, 0.8217]}, {"w": "problem", "b": [0.4021, 0.8054, 0.4563, 0.8217]}, {"w": "is", "b": [0.4599, 0.8054, 0.47, 0.8217]}, {"w": "both", "b": [0.4736, 0.8054, 0.503, 0.8217]}, {"w": "NP", "b": [0.5066, 0.8054, 0.5274, 0.8217]}, {"w": "and", "b": [0.531, 0.8054, 0.555, 0.8217]}, {"w": "NP-Hard.", "b": [0.5586, 0.8054, 0.6208, 0.8217]}, {"w": "A", "b": [0.6244, 0.8054, 0.6354, 0.8217]}, {"w": "major", "b": [0.639, 0.8054, 0.6767, 0.8217]}, {"w": "open", "b": [0.6803, 0.8054, 0.7122, 0.8217]}, {"w": "mathematical", "b": [0.7158, 0.8054, 0.802, 0.8217]}, {"w": "ques‐", "b": [0.8056, 0.8054, 0.8403, 0.8217]}, {"w": "tion", "b": [0.1587, 0.8205, 0.1846, 0.8368]}, {"w": "is", "b": [0.1882, 0.8205, 0.1983, 0.8368]}, {"w": "whether", "b": [0.2019, 0.8205, 0.2539, 0.8368]}, {"w": "or", "b": [0.2575, 0.8205, 0.2715, 0.8368]}, {"w": "not", "b": [0.2751, 0.8205, 0.2967, 0.8368]}, {"w": "P", "b": [0.3003, 0.8205, 0.3093, 0.8368]}, {"w": "=", "b": [0.3129, 0.8205, 0.3221, 0.8368]}, {"w": "NP.", "b": [0.3257, 0.8205, 0.3478, 0.8368]}, {"w": "If", "b": [0.3514, 0.8205, 0.3616, 0.8368]}, {"w": "P", "b": [0.3652, 0.8205, 0.3741, 0.8368]}, {"w": "≠", "b": [0.3777, 0.8205, 0.387, 0.8368]}, {"w": "NP", "b": [0.3906, 0.8205, 0.4113, 0.8368]}, {"w": "(which", "b": [0.415, 0.8205, 0.4592, 0.8368]}, {"w": "seems", "b": [0.4628, 0.8205, 0.501, 0.8368]}, {"w": "likely),", "b": [0.5046, 0.8205, 0.5479, 0.8368]}, {"w": "then", "b": [0.5515, 0.8205, 0.5802, 0.8368]}, {"w": "no", "b": [0.5838, 0.8205, 0.6006, 0.8368]}, {"w": "polynomial", "b": [0.6042, 0.8205, 0.677, 0.8368]}, {"w": "algorithm", "b": [0.6806, 0.8205, 0.7435, 0.8368]}, {"w": "will", "b": [0.7471, 0.8205, 0.7703, 0.8368]}, {"w": "ever", "b": [0.7739, 0.8205, 0.8006, 0.8368]}, {"w": "be", "b": [0.8042, 0.8205, 0.819, 0.8368]}, {"w": "found", "b": [0.1587, 0.8356, 0.197, 0.8519]}, {"w": "for", "b": [0.2006, 0.8356, 0.2193, 0.8519]}, {"w": "any", "b": [0.2229, 0.8356, 0.2455, 0.8519]}, {"w": "NP-Complete", "b": [0.2491, 0.8356, 0.3367, 0.8519]}, {"w": "problem", "b": [0.3403, 0.8356, 0.3944, 0.8519]}, {"w": "(except", "b": [0.398, 0.8356, 0.4444, 0.8519]}, {"w": "perhaps", "b": [0.448, 0.8356, 0.4982, 0.8519]}, {"w": "on", "b": [0.5018, 0.8356, 0.5186, 0.8519]}, {"w": "a", "b": [0.5222, 0.8356, 0.5292, 0.8519]}, {"w": "quantum", "b": [0.5328, 0.8356, 0.5909, 0.8519]}, {"w": "computer).", "b": [0.5945, 0.8356, 0.6654, 0.8519]}]}, {"id": "b_1", "type": "equation", "text": "3 log2 is the binary logarithm. It is equal to log2(m) = log(m) / log(2).", "words": [{"w": "3", "b": [0.1451, 0.8568, 0.1518, 0.871]}, {"w": "log2", "b": [0.1587, 0.8551, 0.1827, 0.8731]}, {"w": "is", "b": [0.1863, 0.8553, 0.1964, 0.8716]}, {"w": "the", "b": [0.2, 0.8553, 0.2201, 0.8716]}, {"w": "binary", "b": [0.2237, 0.8553, 0.2653, 0.8716]}, {"w": "logarithm.", "b": [0.2689, 0.8553, 0.3355, 0.8716]}, {"w": "It", "b": [0.3391, 0.8553, 0.3487, 0.8716]}, {"w": "is", "b": [0.3523, 0.8553, 0.3624, 0.8716]}, {"w": "equal", "b": [0.366, 0.8553, 0.4003, 0.8716]}, {"w": "to", "b": [0.4039, 0.8553, 0.4168, 0.8716]}, {"w": "log2(m)", "b": [0.4204, 0.8551, 0.4679, 0.8731]}, {"w": "=", "b": [0.4715, 0.8553, 0.4807, 0.8716]}, {"w": "log(m)", "b": [0.4843, 0.8551, 0.5258, 0.8716]}, {"w": "/", "b": [0.5294, 0.8553, 0.5347, 0.8716]}, {"w": "log(2).", "b": [0.5383, 0.8551, 0.5785, 0.8716]}]}, {"id": "b_2", "type": "paragraph", "text": "4 A reduction of entropy is often called an information gain.", "words": [{"w": "4", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "A", "b": [0.1587, 0.8749, 0.1697, 0.8912]}, {"w": "reduction", "b": [0.1733, 0.8749, 0.2353, 0.8912]}, {"w": "of", "b": [0.2389, 0.8749, 0.2517, 0.8912]}, {"w": "entropy", "b": [0.2553, 0.8749, 0.3049, 0.8912]}, {"w": "is", "b": [0.3085, 0.8749, 0.3186, 0.8912]}, {"w": "often", "b": [0.3222, 0.8749, 0.3552, 0.8912]}, {"w": "called", "b": [0.3588, 0.8749, 0.3957, 0.8912]}, {"w": "an", "b": [0.3993, 0.8749, 0.4149, 0.8912]}, {"w": "information", "b": [0.4185, 0.8748, 0.4929, 0.8912]}, {"w": "gain.", "b": [0.4965, 0.8748, 0.5269, 0.8912]}]}, {"id": "b_3", "type": "paragraph", "text": "As you can see, the CART algorithm is a greedy algorithm: it greed‐ ily searches for an optimum split at the top level, then repeats the process at each level. It does not check whether or not the split will lead to the lowest possible impurity several levels down. A greedy algorithm often produces a reasonably good solution, but it is not guaranteed to be the optimal solution.", "words": [{"w": "As", "b": [0.2714, 0.0793, 0.2916, 0.0989]}, {"w": "you", "b": [0.2964, 0.0793, 0.325, 0.0989]}, {"w": "can", "b": [0.3298, 0.0793, 0.3566, 0.0989]}, {"w": "see,", "b": [0.3614, 0.0793, 0.389, 0.0989]}, {"w": "the", "b": [0.3938, 0.0793, 0.4179, 0.0989]}, {"w": "CART", "b": [0.4227, 0.0793, 0.4715, 0.0989]}, {"w": "algorithm", "b": [0.4763, 0.0793, 0.5519, 0.0989]}, {"w": "is", "b": [0.5567, 0.0793, 0.5688, 0.0989]}, {"w": "a", "b": [0.5736, 0.0793, 0.582, 0.0989]}, {"w": "greedy", "b": [0.5868, 0.0791, 0.6343, 0.0989]}, {"w": "algorithm:", "b": [0.6387, 0.0791, 0.7161, 0.0989]}, {"w": "it", "b": [0.721, 0.0793, 0.7319, 0.0989]}, {"w": "greed‐", "b": [0.7367, 0.0793, 0.7857, 0.0989]}, {"w": "ily", "b": [0.2714, 0.0967, 0.2901, 0.1163]}, {"w": "searches", "b": [0.296, 0.0967, 0.3598, 0.1163]}, {"w": "for", "b": [0.3658, 0.0967, 0.3882, 0.1163]}, {"w": "an", "b": [0.3942, 0.0967, 0.4129, 0.1163]}, {"w": "optimum", "b": [0.4189, 0.0967, 0.4904, 0.1163]}, {"w": "split", "b": [0.4964, 0.0967, 0.5291, 0.1163]}, {"w": "at", "b": [0.535, 0.0967, 0.5489, 0.1163]}, {"w": "the", "b": [0.5548, 0.0967, 0.5789, 0.1163]}, {"w": "top", "b": [0.5848, 0.0967, 0.6103, 0.1163]}, {"w": "level,", "b": [0.6163, 0.0967, 0.6553, 0.1163]}, {"w": "then", "b": [0.6612, 0.0967, 0.6957, 0.1163]}, {"w": "repeats", "b": [0.7017, 0.0967, 0.7557, 0.1163]}, {"w": "the", "b": [0.7616, 0.0967, 0.7857, 0.1163]}, {"w": "process", "b": [0.2714, 0.1141, 0.3283, 0.1337]}, {"w": "at", "b": [0.3332, 0.1141, 0.347, 0.1337]}, {"w": "each", "b": [0.352, 0.1141, 0.3866, 0.1337]}, {"w": "level.", "b": [0.3916, 0.1141, 0.4306, 0.1337]}, {"w": "It", "b": [0.4355, 0.1141, 0.447, 0.1337]}, {"w": "does", "b": [0.452, 0.1141, 0.4868, 0.1337]}, {"w": "not", "b": [0.4917, 0.1141, 0.5177, 0.1337]}, {"w": "check", "b": [0.5226, 0.1141, 0.5664, 0.1337]}, {"w": "whether", "b": [0.5714, 0.1141, 0.6338, 0.1337]}, {"w": "or", "b": [0.6387, 0.1141, 0.6555, 0.1337]}, {"w": "not", "b": [0.6604, 0.1141, 0.6864, 0.1337]}, {"w": "the", "b": [0.6913, 0.1141, 0.7154, 0.1337]}, {"w": "split", "b": [0.7203, 0.1141, 0.753, 0.1337]}, {"w": "will", "b": [0.7579, 0.1141, 0.7857, 0.1337]}, {"w": "lead", "b": [0.2714, 0.1315, 0.3027, 0.1511]}, {"w": "to", "b": [0.3088, 0.1315, 0.3243, 0.1511]}, {"w": "the", "b": [0.3304, 0.1315, 0.3545, 0.1511]}, {"w": "lowest", "b": [0.3606, 0.1315, 0.409, 0.1511]}, {"w": "possible", "b": [0.4151, 0.1315, 0.4765, 0.1511]}, {"w": "impurity", "b": [0.4826, 0.1315, 0.5497, 0.1511]}, {"w": "several", "b": [0.5558, 0.1315, 0.6081, 0.1511]}, {"w": "levels", "b": [0.6141, 0.1315, 0.6558, 0.1511]}, {"w": "down.", "b": [0.6618, 0.1315, 0.7094, 0.1511]}, {"w": "A", "b": [0.7155, 0.1315, 0.7287, 0.1511]}, {"w": "greedy", "b": [0.7347, 0.1315, 0.7857, 0.1511]}, {"w": "algorithm", "b": [0.2714, 0.1489, 0.347, 0.1685]}, {"w": "often", "b": [0.3528, 0.1489, 0.3925, 0.1685]}, {"w": "produces", "b": [0.3983, 0.1489, 0.4684, 0.1685]}, {"w": "a", "b": [0.4742, 0.1489, 0.4826, 0.1685]}, {"w": "reasonably", "b": [0.4884, 0.1489, 0.5707, 0.1685]}, {"w": "good", "b": [0.5765, 0.1489, 0.6149, 0.1685]}, {"w": "solution,", "b": [0.6208, 0.1489, 0.6878, 0.1685]}, {"w": "but", "b": [0.6936, 0.1489, 0.7192, 0.1685]}, {"w": "it", "b": [0.7251, 0.1489, 0.736, 0.1685]}, {"w": "is", "b": [0.7418, 0.1489, 0.7539, 0.1685]}, {"w": "not", "b": [0.7598, 0.1489, 0.7857, 0.1685]}, {"w": "guaranteed", "b": [0.2714, 0.1664, 0.3563, 0.1859]}, {"w": "to", "b": [0.3607, 0.1664, 0.3762, 0.1859]}, {"w": "be", "b": [0.3805, 0.1664, 0.3983, 0.1859]}, {"w": "the", "b": [0.4026, 0.1664, 0.4267, 0.1859]}, {"w": "optimal", "b": [0.431, 0.1664, 0.4904, 0.1859]}, {"w": "solution.", "b": [0.4947, 0.1664, 0.5618, 0.1859]}]}, {"id": "b_4", "type": "paragraph", "text": "Unfortunately, finding the optimal tree is known to be an NP- Complete problem:2 it requires O(exp(m)) time, making the prob‐ lem intractable even for fairly small training sets. This is why we must settle for a “reasonably good” solution.", "words": [{"w": "Unfortunately,", "b": [0.2714, 0.1898, 0.3822, 0.2094]}, {"w": "finding", "b": [0.391, 0.1898, 0.4467, 0.2094]}, {"w": "the", "b": [0.4555, 0.1898, 0.4796, 0.2094]}, {"w": "optimal", "b": [0.4884, 0.1898, 0.5478, 0.2094]}, {"w": "tree", "b": [0.5566, 0.1898, 0.5857, 0.2094]}, {"w": "is", "b": [0.5945, 0.1898, 0.6066, 0.2094]}, {"w": "known", "b": [0.6154, 0.1898, 0.6684, 0.2094]}, {"w": "to", "b": [0.6773, 0.1898, 0.6928, 0.2094]}, {"w": "be", "b": [0.7016, 0.1898, 0.7194, 0.2094]}, {"w": "an", "b": [0.7282, 0.1898, 0.747, 0.2094]}, {"w": "NP-", "b": [0.7558, 0.1896, 0.7857, 0.2094]}, {"w": "Complete", "b": [0.2714, 0.207, 0.3415, 0.2268]}, {"w": "problem:2", "b": [0.3478, 0.2072, 0.4228, 0.2268]}, {"w": "it", "b": [0.429, 0.2072, 0.4399, 0.2268]}, {"w": "requires", "b": [0.4462, 0.2072, 0.5085, 0.2268]}, {"w": "O(exp(m))", "b": [0.5147, 0.207, 0.5966, 0.2268]}, {"w": "time,", "b": [0.6029, 0.2072, 0.6418, 0.2268]}, {"w": "making", "b": [0.6481, 0.2072, 0.7059, 0.2268]}, {"w": "the", "b": [0.7122, 0.2072, 0.7362, 0.2268]}, {"w": "prob‐", "b": [0.7425, 0.2072, 0.7857, 0.2268]}, {"w": "lem", "b": [0.2714, 0.2246, 0.2999, 0.2442]}, {"w": "intractable", "b": [0.3067, 0.2246, 0.3879, 0.2442]}, {"w": "even", "b": [0.3946, 0.2246, 0.4301, 0.2442]}, {"w": "for", "b": [0.4368, 0.2246, 0.4592, 0.2442]}, {"w": "fairly", "b": [0.466, 0.2246, 0.5057, 0.2442]}, {"w": "small", "b": [0.5125, 0.2246, 0.553, 0.2442]}, {"w": "training", "b": [0.5598, 0.2246, 0.621, 0.2442]}, {"w": "sets.", "b": [0.6277, 0.2246, 0.66, 0.2442]}, {"w": "This", "b": [0.6667, 0.2246, 0.7007, 0.2442]}, {"w": "is", "b": [0.7075, 0.2246, 0.7196, 0.2442]}, {"w": "why", "b": [0.7263, 0.2246, 0.7578, 0.2442]}, {"w": "we", "b": [0.7646, 0.2246, 0.7857, 0.2442]}, {"w": "must", "b": [0.2714, 0.2421, 0.3096, 0.2616]}, {"w": "settle", "b": [0.3139, 0.2421, 0.3535, 0.2616]}, {"w": "for", "b": [0.3578, 0.2421, 0.3803, 0.2616]}, {"w": "a", "b": [0.3846, 0.2421, 0.3929, 0.2616]}, {"w": "“reasonably", "b": [0.3973, 0.2421, 0.4865, 0.2616]}, {"w": "good”", "b": [0.4908, 0.2421, 0.5364, 0.2616]}, {"w": "solution.", "b": [0.5407, 0.2421, 0.6077, 0.2616]}]}, {"id": "b_5", "type": "paragraph", "text": "Computational Complexity", "words": [{"w": "Computational", "b": [0.1429, 0.2781, 0.3277, 0.3124]}, {"w": "Complexity", "b": [0.3336, 0.2781, 0.4728, 0.3124]}]}, {"id": "b_6", "type": "paragraph", "text": "Making predictions requires traversing the Decision Tree from the root to a leaf. Decision Trees are generally approximately balanced, so traversing the Decision Tree requires going through roughly O(log2(m)) nodes.3 Since each node only requires checking the value of one feature, the overall prediction complexity is just O(log2(m)), independent of the number of features. So predictions are very fast, even when deal‐ ing with large training sets.", "words": [{"w": "Making", "b": [0.1429, 0.3193, 0.2073, 0.3407]}, {"w": "predictions", "b": [0.2159, 0.3193, 0.3104, 0.3407]}, {"w": "requires", "b": [0.319, 0.3193, 0.3871, 0.3407]}, {"w": "traversing", "b": [0.3958, 0.3193, 0.4792, 0.3407]}, {"w": "the", "b": [0.4879, 0.3193, 0.5142, 0.3407]}, {"w": "Decision", "b": [0.5228, 0.3193, 0.5966, 0.3407]}, {"w": "Tree", "b": [0.6053, 0.3193, 0.6418, 0.3407]}, {"w": "from", "b": [0.6504, 0.3193, 0.692, 0.3407]}, {"w": "the", "b": [0.7007, 0.3193, 0.727, 0.3407]}, {"w": "root", "b": [0.7356, 0.3193, 0.7709, 0.3407]}, {"w": "to", "b": [0.7796, 0.3193, 0.7966, 0.3407]}, {"w": "a", "b": [0.8052, 0.3193, 0.8143, 0.3407]}, {"w": "leaf.", "b": [0.823, 0.3193, 0.8571, 0.3407]}, {"w": "Decision", "b": [0.1429, 0.3384, 0.2167, 0.3598]}, {"w": "Trees", "b": [0.2224, 0.3384, 0.2666, 0.3598]}, {"w": "are", "b": [0.2723, 0.3384, 0.298, 0.3598]}, {"w": "generally", "b": [0.3037, 0.3384, 0.3796, 0.3598]}, {"w": "approximately", "b": [0.3853, 0.3384, 0.5055, 0.3598]}, {"w": "balanced,", "b": [0.5112, 0.3384, 0.5902, 0.3598]}, {"w": "so", "b": [0.5959, 0.3384, 0.6141, 0.3598]}, {"w": "traversing", "b": [0.6198, 0.3384, 0.7033, 0.3598]}, {"w": "the", "b": [0.709, 0.3384, 0.7353, 0.3598]}, {"w": "Decision", "b": [0.7411, 0.3384, 0.8149, 0.3598]}, {"w": "Tree", "b": [0.8206, 0.3384, 0.8571, 0.3598]}, {"w": "requires", "b": [0.1429, 0.3574, 0.211, 0.3788]}, {"w": "going", "b": [0.2197, 0.3574, 0.2668, 0.3788]}, {"w": "through", "b": [0.2755, 0.3574, 0.3433, 0.3788]}, {"w": "roughly", "b": [0.352, 0.3574, 0.4172, 0.3788]}, {"w": "O(log2(m))", "b": [0.4259, 0.3572, 0.5155, 0.3797]}, {"w": "nodes.3", "b": [0.5242, 0.3574, 0.5842, 0.3788]}, {"w": "Since", "b": [0.5929, 0.3574, 0.6375, 0.3788]}, {"w": "each", "b": [0.6462, 0.3574, 0.6841, 0.3788]}, {"w": "node", "b": [0.6929, 0.3574, 0.7347, 0.3788]}, {"w": "only", "b": [0.7435, 0.3574, 0.7803, 0.3788]}, {"w": "requires", "b": [0.789, 0.3574, 0.8571, 0.3788]}, {"w": "checking", "b": [0.1428, 0.3765, 0.2175, 0.3979]}, {"w": "the", "b": [0.2224, 0.3765, 0.2488, 0.3979]}, {"w": "value", "b": [0.2537, 0.3765, 0.2976, 0.3979]}, {"w": "of", "b": [0.3026, 0.3765, 0.3193, 0.3979]}, {"w": "one", "b": [0.3243, 0.3765, 0.3551, 0.3979]}, {"w": "feature,", "b": [0.36, 0.3765, 0.4226, 0.3979]}, {"w": "the", "b": [0.4275, 0.3765, 0.4538, 0.3979]}, {"w": "overall", "b": [0.4587, 0.3765, 0.5153, 0.3979]}, {"w": "prediction", "b": [0.5202, 0.3765, 0.607, 0.3979]}, {"w": "complexity", "b": [0.6119, 0.3765, 0.7044, 0.3979]}, {"w": "is", "b": [0.7093, 0.3765, 0.7225, 0.3979]}, {"w": "just", "b": [0.7275, 0.3765, 0.7579, 0.3979]}, {"w": "O(log2(m)),", "b": [0.7628, 0.3762, 0.8571, 0.3988]}, {"w": "independent", "b": [0.1429, 0.3955, 0.2481, 0.4169]}, {"w": "of", "b": [0.2539, 0.3955, 0.2707, 0.4169]}, {"w": "the", "b": [0.2765, 0.3955, 0.3028, 0.4169]}, {"w": "number", "b": [0.3086, 0.3955, 0.3749, 0.4169]}, {"w": "of", "b": [0.3807, 0.3955, 0.3975, 0.4169]}, {"w": "features.", "b": [0.4033, 0.3955, 0.4735, 0.4169]}, {"w": "So", "b": [0.4793, 0.3955, 0.4998, 0.4169]}, {"w": "predictions", "b": [0.5056, 0.3955, 0.6001, 0.4169]}, {"w": "are", "b": [0.6059, 0.3955, 0.6316, 0.4169]}, {"w": "very", "b": [0.6374, 0.3955, 0.6738, 0.4169]}, {"w": "fast,", "b": [0.6796, 0.3955, 0.7137, 0.4169]}, {"w": "even", "b": [0.7195, 0.3955, 0.7582, 0.4169]}, {"w": "when", "b": [0.764, 0.3955, 0.8097, 0.4169]}, {"w": "deal‐", "b": [0.8155, 0.3955, 0.8571, 0.4169]}, {"w": "ing", "b": [0.1428, 0.4145, 0.1696, 0.436]}, {"w": "with", "b": [0.1743, 0.4145, 0.2116, 0.436]}, {"w": "large", "b": [0.2164, 0.4145, 0.2571, 0.436]}, {"w": "training", "b": [0.2618, 0.4145, 0.3288, 0.436]}, {"w": "sets.", "b": [0.3335, 0.4145, 0.3688, 0.436]}]}, {"id": "b_7", "type": "paragraph", "text": "However, the training algorithm compares all features (or less if max_features is set) on all samples at each node. This results in a training complexity of O(n × m log(m)). For small training sets (less than a few thousand instances), Scikit-Learn can speed up training by presorting the data (set presort=True), but this slows down training con‐ siderably for larger training sets.", "words": [{"w": "However,", "b": [0.1428, 0.4436, 0.2217, 0.465]}, {"w": "the", "b": [0.2271, 0.4436, 0.2535, 0.465]}, {"w": "training", "b": [0.2589, 0.4436, 0.3258, 0.465]}, {"w": "algorithm", "b": [0.3313, 0.4436, 0.4139, 0.465]}, {"w": "compares", "b": [0.4194, 0.4436, 0.4998, 0.465]}, {"w": "all", "b": [0.5052, 0.4436, 0.5249, 0.465]}, {"w": "features", "b": [0.5303, 0.4436, 0.5957, 0.465]}, {"w": "(or", "b": [0.6012, 0.4436, 0.6267, 0.465]}, {"w": "less", "b": [0.6322, 0.4436, 0.6616, 0.465]}, {"w": "if", "b": [0.667, 0.4436, 0.6788, 0.465]}, {"w": "max_features", "b": [0.6842, 0.4467, 0.803, 0.4618]}, {"w": "is", "b": [0.8084, 0.4436, 0.8216, 0.465]}, {"w": "set)", "b": [0.8271, 0.4436, 0.8571, 0.465]}, {"w": "on", "b": [0.1429, 0.4626, 0.1649, 0.484]}, {"w": "all", "b": [0.1702, 0.4626, 0.1899, 0.484]}, {"w": "samples", "b": [0.1952, 0.4626, 0.2613, 0.484]}, {"w": "at", "b": [0.2666, 0.4626, 0.2817, 0.484]}, {"w": "each", "b": [0.287, 0.4626, 0.3249, 0.484]}, {"w": "node.", "b": [0.3302, 0.4626, 0.3769, 0.484]}, {"w": "This", "b": [0.3822, 0.4626, 0.4194, 0.484]}, {"w": "results", "b": [0.4247, 0.4626, 0.4792, 0.484]}, {"w": "in", "b": [0.4845, 0.4626, 0.5015, 0.484]}, {"w": "a", "b": [0.5068, 0.4626, 0.5159, 0.484]}, {"w": "training", "b": [0.5212, 0.4626, 0.5882, 0.484]}, {"w": "complexity", "b": [0.5935, 0.4626, 0.6859, 0.484]}, {"w": "of", "b": [0.6912, 0.4626, 0.708, 0.484]}, {"w": "O(n", "b": [0.7133, 0.4624, 0.7464, 0.484]}, {"w": "×", "b": [0.7517, 0.4626, 0.7637, 0.484]}, {"w": "m", "b": [0.769, 0.4624, 0.7854, 0.484]}, {"w": "log(m)).", "b": [0.7907, 0.4624, 0.8571, 0.484]}, {"w": "For", "b": [0.1429, 0.4817, 0.1718, 0.5031]}, {"w": "small", "b": [0.1766, 0.4817, 0.221, 0.5031]}, {"w": "training", "b": [0.2258, 0.4817, 0.2928, 0.5031]}, {"w": "sets", "b": [0.2976, 0.4817, 0.3281, 0.5031]}, {"w": "(less", "b": [0.3329, 0.4817, 0.3695, 0.5031]}, {"w": "than", "b": [0.3743, 0.4817, 0.4123, 0.5031]}, {"w": "a", "b": [0.4171, 0.4817, 0.4262, 0.5031]}, {"w": "few", "b": [0.431, 0.4817, 0.4603, 0.5031]}, {"w": "thousand", "b": [0.4651, 0.4817, 0.5435, 0.5031]}, {"w": "instances),", "b": [0.5483, 0.4817, 0.6371, 0.5031]}, {"w": "Scikit-Learn", "b": [0.6419, 0.4817, 0.7442, 0.5031]}, {"w": "can", "b": [0.749, 0.4817, 0.7783, 0.5031]}, {"w": "speed", "b": [0.7831, 0.4817, 0.8304, 0.5031]}, {"w": "up", "b": [0.8352, 0.4817, 0.8572, 0.5031]}, {"w": "training", "b": [0.1429, 0.5016, 0.2098, 0.523]}, {"w": "by", "b": [0.2149, 0.5016, 0.2351, 0.523]}, {"w": "presorting", "b": [0.2402, 0.5016, 0.3268, 0.523]}, {"w": "the", "b": [0.3319, 0.5016, 0.3583, 0.523]}, {"w": "data", "b": [0.3634, 0.5016, 0.3987, 0.523]}, {"w": "(set", "b": [0.4038, 0.5016, 0.4338, 0.523]}, {"w": "presort=True),", "b": [0.439, 0.5016, 0.5697, 0.523]}, {"w": "but", "b": [0.5748, 0.5016, 0.6028, 0.523]}, {"w": "this", "b": [0.608, 0.5016, 0.6387, 0.523]}, {"w": "slows", "b": [0.6438, 0.5016, 0.6893, 0.523]}, {"w": "down", "b": [0.6944, 0.5016, 0.7417, 0.523]}, {"w": "training", "b": [0.7468, 0.5016, 0.8138, 0.523]}, {"w": "con‐", "b": [0.8189, 0.5016, 0.8571, 0.523]}, {"w": "siderably", "b": [0.1429, 0.5206, 0.2182, 0.5421]}, {"w": "for", "b": [0.223, 0.5206, 0.2475, 0.5421]}, {"w": "larger", "b": [0.2522, 0.5206, 0.3007, 0.5421]}, {"w": "training", "b": [0.3054, 0.5206, 0.3724, 0.5421]}, {"w": "sets.", "b": [0.3771, 0.5206, 0.4123, 0.5421]}]}, {"id": "b_8", "type": "paragraph", "text": "Gini Impurity or Entropy?", "words": [{"w": "Gini", "b": [0.1429, 0.5551, 0.1917, 0.5893]}, {"w": "Impurity", "b": [0.1976, 0.5551, 0.3052, 0.5893]}, {"w": "or", "b": [0.3111, 0.5551, 0.3368, 0.5893]}, {"w": "Entropy?", "b": [0.3427, 0.5551, 0.4515, 0.5893]}]}, {"id": "b_9", "type": "paragraph", "text": "By default, the Gini impurity measure is used, but you can select the entropy impurity measure instead by setting the criterion hyperparameter to \"entropy\". The concept of entropy originated in thermodynamics as a measure of molecular disorder: entropy approaches zero when molecules are still and well ordered. It later spread to a wide variety of domains, including Shannon’s information theory, where it measures the average information content of a message:4 entropy is zero when all messages are identical. In Machine Learning, it is frequently used as an impurity measure: a set’s", "words": [{"w": "By", "b": [0.1428, 0.5962, 0.1647, 0.6176]}, {"w": "default,", "b": [0.1697, 0.5962, 0.2319, 0.6176]}, {"w": "the", "b": [0.237, 0.5962, 0.2633, 0.6176]}, {"w": "Gini", "b": [0.2684, 0.5962, 0.3058, 0.6176]}, {"w": "impurity", "b": [0.3109, 0.5962, 0.3844, 0.6176]}, {"w": "measure", "b": [0.3894, 0.5962, 0.4598, 0.6176]}, {"w": "is", "b": [0.4648, 0.5962, 0.4781, 0.6176]}, {"w": "used,", "b": [0.4831, 0.5962, 0.5264, 0.6176]}, {"w": "but", "b": [0.5315, 0.5962, 0.5595, 0.6176]}, {"w": "you", "b": [0.5646, 0.5962, 0.5958, 0.6176]}, {"w": "can", "b": [0.6009, 0.5962, 0.6302, 0.6176]}, {"w": "select", "b": [0.6353, 0.5962, 0.6811, 0.6176]}, {"w": "the", "b": [0.6862, 0.5962, 0.7125, 0.6176]}, {"w": "entropy", "b": [0.7175, 0.596, 0.7786, 0.6176]}, {"w": "impurity", "b": [0.7837, 0.5962, 0.8571, 0.6176]}, {"w": "measure", "b": [0.1429, 0.6162, 0.2132, 0.6376]}, {"w": "instead", "b": [0.2182, 0.6162, 0.2782, 0.6376]}, {"w": "by", "b": [0.2831, 0.6162, 0.3033, 0.6376]}, {"w": "setting", "b": [0.3082, 0.6162, 0.3642, 0.6376]}, {"w": "the", "b": [0.3691, 0.6162, 0.3954, 0.6376]}, {"w": "criterion", "b": [0.4004, 0.6194, 0.4895, 0.6344]}, {"w": "hyperparameter", "b": [0.4944, 0.6162, 0.6279, 0.6376]}, {"w": "to", "b": [0.6326, 0.6162, 0.6496, 0.6376]}, {"w": "\"entropy\".", "b": [0.6548, 0.6162, 0.7486, 0.6376]}, {"w": "The", "b": [0.7534, 0.6162, 0.7862, 0.6376]}, {"w": "concept", "b": [0.7909, 0.6162, 0.8567, 0.6376]}, {"w": "of", "b": [0.1429, 0.6352, 0.1596, 0.6566]}, {"w": "entropy", "b": [0.1712, 0.6352, 0.2362, 0.6566]}, {"w": "originated", "b": [0.2478, 0.6352, 0.3334, 0.6566]}, {"w": "in", "b": [0.345, 0.6352, 0.362, 0.6566]}, {"w": "thermodynamics", "b": [0.3735, 0.6352, 0.5155, 0.6566]}, {"w": "as", "b": [0.527, 0.6352, 0.5438, 0.6566]}, {"w": "a", "b": [0.5554, 0.6352, 0.5645, 0.6566]}, {"w": "measure", "b": [0.5761, 0.6352, 0.6464, 0.6566]}, {"w": "of", "b": [0.658, 0.6352, 0.6748, 0.6566]}, {"w": "molecular", "b": [0.6863, 0.6352, 0.7702, 0.6566]}, {"w": "disorder:", "b": [0.7817, 0.6352, 0.8571, 0.6566]}, {"w": "entropy", "b": [0.1429, 0.6543, 0.2079, 0.6757]}, {"w": "approaches", "b": [0.2127, 0.6543, 0.3072, 0.6757]}, {"w": "zero", "b": [0.312, 0.6543, 0.3479, 0.6757]}, {"w": "when", "b": [0.3527, 0.6543, 0.3984, 0.6757]}, {"w": "molecules", "b": [0.4032, 0.6543, 0.4866, 0.6757]}, {"w": "are", "b": [0.4914, 0.6543, 0.5171, 0.6757]}, {"w": "still", "b": [0.5219, 0.6543, 0.5521, 0.6757]}, {"w": "and", "b": [0.5568, 0.6543, 0.5884, 0.6757]}, {"w": "well", "b": [0.5932, 0.6543, 0.6268, 0.6757]}, {"w": "ordered.", "b": [0.6316, 0.6543, 0.7022, 0.6757]}, {"w": "It", "b": [0.707, 0.6543, 0.7196, 0.6757]}, {"w": "later", "b": [0.7244, 0.6543, 0.7614, 0.6757]}, {"w": "spread", "b": [0.7661, 0.6543, 0.8214, 0.6757]}, {"w": "to", "b": [0.8262, 0.6543, 0.8432, 0.6757]}, {"w": "a", "b": [0.848, 0.6543, 0.8571, 0.6757]}, {"w": "wide", "b": [0.1429, 0.6733, 0.1826, 0.6947]}, {"w": "variety", "b": [0.1891, 0.6733, 0.246, 0.6947]}, {"w": "of", "b": [0.2525, 0.6733, 0.2693, 0.6947]}, {"w": "domains,", "b": [0.2759, 0.6733, 0.3531, 0.6947]}, {"w": "including", "b": [0.3596, 0.6733, 0.4395, 0.6947]}, {"w": "Shannon’s", "b": [0.446, 0.6733, 0.5295, 0.6947]}, {"w": "information", "b": [0.5361, 0.6731, 0.6337, 0.6947]}, {"w": "theory,", "b": [0.6403, 0.6731, 0.6968, 0.6947]}, {"w": "where", "b": [0.7033, 0.6733, 0.7541, 0.6947]}, {"w": "it", "b": [0.7607, 0.6733, 0.7726, 0.6947]}, {"w": "measures", "b": [0.7792, 0.6733, 0.8572, 0.6947]}, {"w": "the", "b": [0.1429, 0.6924, 0.1692, 0.7138]}, {"w": "average", "b": [0.1749, 0.6924, 0.2376, 0.7138]}, {"w": "information", "b": [0.2433, 0.6924, 0.3445, 0.7138]}, {"w": "content", "b": [0.3502, 0.6924, 0.4132, 0.7138]}, {"w": "of", "b": [0.4189, 0.6924, 0.4357, 0.7138]}, {"w": "a", "b": [0.4413, 0.6924, 0.4505, 0.7138]}, {"w": "message:4", "b": [0.4562, 0.6924, 0.5356, 0.7138]}, {"w": "entropy", "b": [0.5412, 0.6924, 0.6063, 0.7138]}, {"w": "is", "b": [0.612, 0.6924, 0.6252, 0.7138]}, {"w": "zero", "b": [0.6309, 0.6924, 0.6668, 0.7138]}, {"w": "when", "b": [0.6725, 0.6924, 0.7181, 0.7138]}, {"w": "all", "b": [0.7238, 0.6924, 0.7435, 0.7138]}, {"w": "messages", "b": [0.7491, 0.6924, 0.8257, 0.7138]}, {"w": "are", "b": [0.8314, 0.6924, 0.8571, 0.7138]}, {"w": "identical.", "b": [0.1429, 0.7114, 0.2192, 0.7328]}, {"w": "In", "b": [0.2261, 0.7114, 0.2446, 0.7328]}, {"w": "Machine", "b": [0.2515, 0.7114, 0.3246, 0.7328]}, {"w": "Learning,", "b": [0.3315, 0.7114, 0.4113, 0.7328]}, {"w": "it", "b": [0.4182, 0.7114, 0.4302, 0.7328]}, {"w": "is", "b": [0.4371, 0.7114, 0.4503, 0.7328]}, {"w": "frequently", "b": [0.4572, 0.7114, 0.5427, 0.7328]}, {"w": "used", "b": [0.5496, 0.7114, 0.5881, 0.7328]}, {"w": "as", "b": [0.595, 0.7114, 0.6118, 0.7328]}, {"w": "an", "b": [0.6187, 0.7114, 0.6393, 0.7328]}, {"w": "impurity", "b": [0.6461, 0.7114, 0.7196, 0.7328]}, {"w": "measure:", "b": [0.7265, 0.7114, 0.8016, 0.7328]}, {"w": "a", "b": [0.8085, 0.7114, 0.8176, 0.7328]}, {"w": "set’s", "b": [0.8245, 0.7114, 0.8571, 0.7328]}]}, {"id": "b_10", "type": "paragraph", "text": "Computational Complexity | 183", "words": [{"w": "Computational", "b": [0.6389, 0.9225, 0.7268, 0.9388]}, {"w": "Complexity", "b": [0.7296, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "183", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 210, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "5 See Sebastian Raschka’s interesting analysis for more details.", "words": [{"w": "5", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "See", "b": [0.1587, 0.8749, 0.1797, 0.8912]}, {"w": "Sebastian", "b": [0.1833, 0.8749, 0.2432, 0.8912]}, {"w": "Raschka’s", "b": [0.2468, 0.8749, 0.3064, 0.8912]}, {"w": "interesting", "b": [0.31, 0.8749, 0.3779, 0.8912]}, {"w": "analysis", "b": [0.3815, 0.8749, 0.4313, 0.8912]}, {"w": "for", "b": [0.4349, 0.8749, 0.4536, 0.8912]}, {"w": "more", "b": [0.4572, 0.8749, 0.4909, 0.8912]}, {"w": "details.", "b": [0.4945, 0.8749, 0.5392, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "entropy is zero when it contains instances of only one class. Equation 6-3 shows the definition of the entropy of the ith node. For example, the depth-2 left node in Figure 6-1 has an entropy equal to −49", "words": [{"w": "entropy", "b": [0.1429, 0.0791, 0.2079, 0.1005]}, {"w": "is", "b": [0.214, 0.0791, 0.2273, 0.1005]}, {"w": "zero", "b": [0.2334, 0.0791, 0.2694, 0.1005]}, {"w": "when", "b": [0.2755, 0.0791, 0.3212, 0.1005]}, {"w": "it", "b": [0.3273, 0.0791, 0.3392, 0.1005]}, {"w": "contains", "b": [0.3454, 0.0791, 0.4159, 0.1005]}, {"w": "instances", "b": [0.4221, 0.0791, 0.4989, 0.1005]}, {"w": "of", "b": [0.5051, 0.0791, 0.5218, 0.1005]}, {"w": "only", "b": [0.528, 0.0791, 0.5648, 0.1005]}, {"w": "one", "b": [0.571, 0.0791, 0.6019, 0.1005]}, {"w": "class.", "b": [0.608, 0.0791, 0.6513, 0.1005]}, {"w": "Equation", "b": [0.6574, 0.0791, 0.7337, 0.1005]}, {"w": "6-3", "b": [0.7398, 0.0791, 0.7672, 0.1005]}, {"w": "shows", "b": [0.7734, 0.0791, 0.8247, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}, {"w": "definition", "b": [0.1429, 0.0981, 0.2254, 0.1195]}, {"w": "of", "b": [0.2352, 0.0981, 0.252, 0.1195]}, {"w": "the", "b": [0.2618, 0.0981, 0.2881, 0.1195]}, {"w": "entropy", "b": [0.2979, 0.0981, 0.3629, 0.1195]}, {"w": "of", "b": [0.3727, 0.0981, 0.3895, 0.1195]}, {"w": "the", "b": [0.3993, 0.0981, 0.4256, 0.1195]}, {"w": "ith", "b": [0.4354, 0.0981, 0.4515, 0.1195]}, {"w": "node.", "b": [0.4612, 0.0981, 0.5079, 0.1195]}, {"w": "For", "b": [0.5177, 0.0981, 0.5466, 0.1195]}, {"w": "example,", "b": [0.5564, 0.0981, 0.6307, 0.1195]}, {"w": "the", "b": [0.6405, 0.0981, 0.6668, 0.1195]}, {"w": "depth-2", "b": [0.6766, 0.0981, 0.7423, 0.1195]}, {"w": "left", "b": [0.7521, 0.0981, 0.7787, 0.1195]}, {"w": "node", "b": [0.7885, 0.0981, 0.8304, 0.1195]}, {"w": "in", "b": [0.8402, 0.0981, 0.8571, 0.1195]}, {"w": "Figure", "b": [0.1429, 0.121, 0.1969, 0.1425]}, {"w": "6-1", "b": [0.2016, 0.121, 0.229, 0.1425]}, {"w": "has", "b": [0.2337, 0.121, 0.2617, 0.1425]}, {"w": "an", "b": [0.2664, 0.121, 0.2869, 0.1425]}, {"w": "entropy", "b": [0.2917, 0.121, 0.3567, 0.1425]}, {"w": "equal", "b": [0.3614, 0.121, 0.4064, 0.1425]}, {"w": "to", "b": [0.4111, 0.121, 0.4281, 0.1425]}, {"w": "−49", "b": [0.4328, 0.1166, 0.4636, 0.1425]}]}, {"id": "b_2", "type": "paragraph", "text": "54 log2 49 54 −5 54 log2 5 54 ≈ 0.445.", "words": [{"w": "54", "b": [0.4484, 0.1313, 0.4636, 0.1476]}, {"w": "log2", "b": [0.4717, 0.121, 0.505, 0.1463]}, {"w": "49", "b": [0.5203, 0.1166, 0.5355, 0.1329]}, {"w": "54", "b": [0.5203, 0.1313, 0.5355, 0.1476]}, {"w": "−5", "b": [0.5497, 0.1166, 0.5802, 0.1425]}, {"w": "54", "b": [0.5687, 0.1313, 0.584, 0.1476]}, {"w": "log2", "b": [0.5921, 0.121, 0.6253, 0.1463]}, {"w": "5", "b": [0.6444, 0.1166, 0.6521, 0.1329]}, {"w": "54", "b": [0.6406, 0.1313, 0.6559, 0.1476]}, {"w": "≈", "b": [0.6701, 0.121, 0.6823, 0.1425]}, {"w": "0.445.", "b": [0.6871, 0.121, 0.7366, 0.1425]}]}, {"id": "b_3", "type": "equation", "text": "Equation 6-3. Entropy", "words": [{"w": "Equation", "b": [0.1726, 0.1645, 0.2473, 0.1861]}, {"w": "6-3.", "b": [0.2521, 0.1645, 0.2838, 0.1861]}, {"w": "Entropy", "b": [0.2886, 0.1645, 0.3526, 0.1861]}]}, {"id": "b_4", "type": "equation", "text": "Hi = − ∑ k = 1 pi, k ≠0", "words": [{"w": "Hi", "b": [0.1726, 0.2059, 0.1923, 0.2307]}, {"w": "=", "b": [0.1978, 0.2061, 0.2093, 0.2265]}, {"w": "−", "b": [0.2192, 0.2061, 0.2307, 0.2265]}, {"w": "∑", "b": [0.2568, 0.2013, 0.2719, 0.2301]}, {"w": "k", "b": [0.2478, 0.2208, 0.2552, 0.2372]}, {"w": "=", "b": [0.2597, 0.2209, 0.2689, 0.2372]}, {"w": "1", "b": [0.2733, 0.2209, 0.2809, 0.2372]}, {"w": "pi,", "b": [0.2391, 0.2329, 0.2548, 0.2554]}, {"w": "k", "b": [0.2574, 0.2389, 0.2649, 0.2554]}, {"w": "≠0", "b": [0.2693, 0.233, 0.2907, 0.2493]}]}, {"id": "b_6", "type": "paragraph", "text": "pi, k log2 pi, k", "words": [{"w": "pi,", "b": [0.296, 0.2059, 0.3136, 0.2307]}, {"w": "k", "b": [0.3162, 0.2143, 0.3237, 0.2307]}, {"w": "log2", "b": [0.3292, 0.2061, 0.3613, 0.2307]}, {"w": "pi,", "b": [0.375, 0.2059, 0.3926, 0.2307]}, {"w": "k", "b": [0.3953, 0.2143, 0.4027, 0.2307]}]}, {"id": "b_7", "type": "paragraph", "text": "So should you use Gini impurity or entropy? The truth is, most of the time it does not make a big difference: they lead to similar trees. Gini impurity is slightly faster to compute, so it is a good default. However, when they differ, Gini impurity tends to isolate the most frequent class in its own branch of the tree, while entropy tends to produce slightly more balanced trees.5", "words": [{"w": "So", "b": [0.1429, 0.2744, 0.1634, 0.2958]}, {"w": "should", "b": [0.1682, 0.2744, 0.2249, 0.2958]}, {"w": "you", "b": [0.2297, 0.2744, 0.2609, 0.2958]}, {"w": "use", "b": [0.2657, 0.2744, 0.2933, 0.2958]}, {"w": "Gini", "b": [0.2981, 0.2744, 0.3355, 0.2958]}, {"w": "impurity", "b": [0.3403, 0.2744, 0.4138, 0.2958]}, {"w": "or", "b": [0.4186, 0.2744, 0.4369, 0.2958]}, {"w": "entropy?", "b": [0.4417, 0.2744, 0.5147, 0.2958]}, {"w": "The", "b": [0.5195, 0.2744, 0.5523, 0.2958]}, {"w": "truth", "b": [0.5571, 0.2744, 0.5997, 0.2958]}, {"w": "is,", "b": [0.6045, 0.2744, 0.6225, 0.2958]}, {"w": "most", "b": [0.6273, 0.2744, 0.669, 0.2958]}, {"w": "of", "b": [0.6738, 0.2744, 0.6906, 0.2958]}, {"w": "the", "b": [0.6953, 0.2744, 0.7217, 0.2958]}, {"w": "time", "b": [0.7265, 0.2744, 0.7643, 0.2958]}, {"w": "it", "b": [0.7691, 0.2744, 0.7811, 0.2958]}, {"w": "does", "b": [0.7859, 0.2744, 0.824, 0.2958]}, {"w": "not", "b": [0.8288, 0.2744, 0.8571, 0.2958]}, {"w": "make", "b": [0.1429, 0.2935, 0.1883, 0.3149]}, {"w": "a", "b": [0.196, 0.2935, 0.2052, 0.3149]}, {"w": "big", "b": [0.213, 0.2935, 0.2389, 0.3149]}, {"w": "difference:", "b": [0.2467, 0.2935, 0.3349, 0.3149]}, {"w": "they", "b": [0.3427, 0.2935, 0.3786, 0.3149]}, {"w": "lead", "b": [0.3863, 0.2935, 0.4206, 0.3149]}, {"w": "to", "b": [0.4284, 0.2935, 0.4454, 0.3149]}, {"w": "similar", "b": [0.4532, 0.2935, 0.5112, 0.3149]}, {"w": "trees.", "b": [0.519, 0.2935, 0.5632, 0.3149]}, {"w": "Gini", "b": [0.571, 0.2935, 0.6084, 0.3149]}, {"w": "impurity", "b": [0.6162, 0.2935, 0.6897, 0.3149]}, {"w": "is", "b": [0.6975, 0.2935, 0.7107, 0.3149]}, {"w": "slightly", "b": [0.7185, 0.2935, 0.7787, 0.3149]}, {"w": "faster", "b": [0.7865, 0.2935, 0.8324, 0.3149]}, {"w": "to", "b": [0.8402, 0.2935, 0.8571, 0.3149]}, {"w": "compute,", "b": [0.1428, 0.3125, 0.2209, 0.3339]}, {"w": "so", "b": [0.2278, 0.3125, 0.2461, 0.3339]}, {"w": "it", "b": [0.253, 0.3125, 0.265, 0.3339]}, {"w": "is", "b": [0.2719, 0.3125, 0.2851, 0.3339]}, {"w": "a", "b": [0.292, 0.3125, 0.3012, 0.3339]}, {"w": "good", "b": [0.3081, 0.3125, 0.3501, 0.3339]}, {"w": "default.", "b": [0.357, 0.3125, 0.4192, 0.3339]}, {"w": "However,", "b": [0.4262, 0.3125, 0.505, 0.3339]}, {"w": "when", "b": [0.5119, 0.3125, 0.5576, 0.3339]}, {"w": "they", "b": [0.5645, 0.3125, 0.6004, 0.3339]}, {"w": "differ,", "b": [0.6073, 0.3125, 0.6563, 0.3339]}, {"w": "Gini", "b": [0.6632, 0.3125, 0.7007, 0.3339]}, {"w": "impurity", "b": [0.7076, 0.3125, 0.7811, 0.3339]}, {"w": "tends", "b": [0.788, 0.3125, 0.8332, 0.3339]}, {"w": "to", "b": [0.8402, 0.3125, 0.8571, 0.3339]}, {"w": "isolate", "b": [0.1429, 0.3316, 0.1959, 0.353]}, {"w": "the", "b": [0.2026, 0.3316, 0.229, 0.353]}, {"w": "most", "b": [0.2357, 0.3316, 0.2773, 0.353]}, {"w": "frequent", "b": [0.284, 0.3316, 0.3547, 0.353]}, {"w": "class", "b": [0.3614, 0.3316, 0.3999, 0.353]}, {"w": "in", "b": [0.4066, 0.3316, 0.4236, 0.353]}, {"w": "its", "b": [0.4303, 0.3316, 0.4498, 0.353]}, {"w": "own", "b": [0.4565, 0.3316, 0.4928, 0.353]}, {"w": "branch", "b": [0.4995, 0.3316, 0.5583, 0.353]}, {"w": "of", "b": [0.565, 0.3316, 0.5818, 0.353]}, {"w": "the", "b": [0.5885, 0.3316, 0.6148, 0.353]}, {"w": "tree,", "b": [0.6215, 0.3316, 0.658, 0.353]}, {"w": "while", "b": [0.6647, 0.3316, 0.7098, 0.353]}, {"w": "entropy", "b": [0.7165, 0.3316, 0.7815, 0.353]}, {"w": "tends", "b": [0.7882, 0.3316, 0.8335, 0.353]}, {"w": "to", "b": [0.8402, 0.3316, 0.8571, 0.353]}, {"w": "produce", "b": [0.1429, 0.3506, 0.2119, 0.372]}, {"w": "slightly", "b": [0.2166, 0.3506, 0.2768, 0.372]}, {"w": "more", "b": [0.2815, 0.3506, 0.3258, 0.372]}, {"w": "balanced", "b": [0.3305, 0.3506, 0.4047, 0.372]}, {"w": "trees.5", "b": [0.4094, 0.3506, 0.4593, 0.372]}]}, {"id": "b_8", "type": "paragraph", "text": "Regularization Hyperparameters", "words": [{"w": "Regularization", "b": [0.1429, 0.385, 0.3245, 0.4193]}, {"w": "Hyperparameters", "b": [0.3304, 0.385, 0.5464, 0.4193]}]}, {"id": "b_9", "type": "paragraph", "text": "Decision Trees make very few assumptions about the training data (as opposed to lin‐ ear models, which obviously assume that the data is linear, for example). If left unconstrained, the tree structure will adapt itself to the training data, fitting it very closely, and most likely overfitting it. Such a model is often called a nonparametric model, not because it does not have any parameters (it often has a lot) but because the number of parameters is not determined prior to training, so the model structure is free to stick closely to the data. In contrast, a parametric model such as a linear model has a predetermined number of parameters, so its degree of freedom is limited, reducing the risk of overfitting (but increasing the risk of underfitting).", "words": [{"w": "Decision", "b": [0.1429, 0.4262, 0.2167, 0.4476]}, {"w": "Trees", "b": [0.2214, 0.4262, 0.2656, 0.4476]}, {"w": "make", "b": [0.2706, 0.4262, 0.316, 0.4476]}, {"w": "very", "b": [0.3208, 0.4262, 0.3572, 0.4476]}, {"w": "few", "b": [0.362, 0.4262, 0.3913, 0.4476]}, {"w": "assumptions", "b": [0.3962, 0.4262, 0.5009, 0.4476]}, {"w": "about", "b": [0.5057, 0.4262, 0.5535, 0.4476]}, {"w": "the", "b": [0.5583, 0.4262, 0.5847, 0.4476]}, {"w": "training", "b": [0.5895, 0.4262, 0.6564, 0.4476]}, {"w": "data", "b": [0.6613, 0.4262, 0.6965, 0.4476]}, {"w": "(as", "b": [0.7014, 0.4262, 0.7254, 0.4476]}, {"w": "opposed", "b": [0.7302, 0.4262, 0.8008, 0.4476]}, {"w": "to", "b": [0.8057, 0.4262, 0.8226, 0.4476]}, {"w": "lin‐", "b": [0.8275, 0.4262, 0.8571, 0.4476]}, {"w": "ear", "b": [0.1428, 0.4453, 0.1686, 0.4667]}, {"w": "models,", "b": [0.1782, 0.4453, 0.2435, 0.4667]}, {"w": "which", "b": [0.2531, 0.4453, 0.304, 0.4667]}, {"w": "obviously", "b": [0.3137, 0.4453, 0.3943, 0.4667]}, {"w": "assume", "b": [0.404, 0.4453, 0.4654, 0.4667]}, {"w": "that", "b": [0.4751, 0.4453, 0.5076, 0.4667]}, {"w": "the", "b": [0.5173, 0.4453, 0.5436, 0.4667]}, {"w": "data", "b": [0.5533, 0.4453, 0.5886, 0.4667]}, {"w": "is", "b": [0.5982, 0.4453, 0.6114, 0.4667]}, {"w": "linear,", "b": [0.6211, 0.4453, 0.6725, 0.4667]}, {"w": "for", "b": [0.6822, 0.4453, 0.7067, 0.4667]}, {"w": "example).", "b": [0.7164, 0.4453, 0.7979, 0.4667]}, {"w": "If", "b": [0.8076, 0.4453, 0.8208, 0.4667]}, {"w": "left", "b": [0.8305, 0.4453, 0.8571, 0.4667]}, {"w": "unconstrained,", "b": [0.1429, 0.4643, 0.2686, 0.4857]}, {"w": "the", "b": [0.2754, 0.4643, 0.3018, 0.4857]}, {"w": "tree", "b": [0.3086, 0.4643, 0.3404, 0.4857]}, {"w": "structure", "b": [0.3472, 0.4643, 0.4228, 0.4857]}, {"w": "will", "b": [0.4296, 0.4643, 0.46, 0.4857]}, {"w": "adapt", "b": [0.4668, 0.4643, 0.513, 0.4857]}, {"w": "itself", "b": [0.5198, 0.4643, 0.5597, 0.4857]}, {"w": "to", "b": [0.5665, 0.4643, 0.5835, 0.4857]}, {"w": "the", "b": [0.5903, 0.4643, 0.6166, 0.4857]}, {"w": "training", "b": [0.6234, 0.4643, 0.6904, 0.4857]}, {"w": "data,", "b": [0.6972, 0.4643, 0.7372, 0.4857]}, {"w": "fitting", "b": [0.744, 0.4643, 0.7952, 0.4857]}, {"w": "it", "b": [0.802, 0.4643, 0.8139, 0.4857]}, {"w": "very", "b": [0.8208, 0.4643, 0.8571, 0.4857]}, {"w": "closely,", "b": [0.1429, 0.4833, 0.2021, 0.5048]}, {"w": "and", "b": [0.2094, 0.4833, 0.241, 0.5048]}, {"w": "most", "b": [0.2483, 0.4833, 0.29, 0.5048]}, {"w": "likely", "b": [0.2973, 0.4833, 0.3421, 0.5048]}, {"w": "overfitting", "b": [0.3494, 0.4833, 0.4375, 0.5048]}, {"w": "it.", "b": [0.4448, 0.4833, 0.4615, 0.5048]}, {"w": "Such", "b": [0.4688, 0.4833, 0.5096, 0.5048]}, {"w": "a", "b": [0.5169, 0.4833, 0.5261, 0.5048]}, {"w": "model", "b": [0.5334, 0.4833, 0.5862, 0.5048]}, {"w": "is", "b": [0.5935, 0.4833, 0.6067, 0.5048]}, {"w": "often", "b": [0.614, 0.4833, 0.6574, 0.5048]}, {"w": "called", "b": [0.6647, 0.4833, 0.7131, 0.5048]}, {"w": "a", "b": [0.7204, 0.4833, 0.7295, 0.5048]}, {"w": "nonparametric", "b": [0.7368, 0.4831, 0.8571, 0.5048]}, {"w": "model,", "b": [0.1428, 0.5022, 0.1972, 0.5238]}, {"w": "not", "b": [0.2022, 0.5024, 0.2306, 0.5238]}, {"w": "because", "b": [0.2355, 0.5024, 0.3001, 0.5238]}, {"w": "it", "b": [0.305, 0.5024, 0.317, 0.5238]}, {"w": "does", "b": [0.3219, 0.5024, 0.36, 0.5238]}, {"w": "not", "b": [0.365, 0.5024, 0.3934, 0.5238]}, {"w": "have", "b": [0.3983, 0.5024, 0.4367, 0.5238]}, {"w": "any", "b": [0.4416, 0.5024, 0.4713, 0.5238]}, {"w": "parameters", "b": [0.4762, 0.5024, 0.5696, 0.5238]}, {"w": "(it", "b": [0.5746, 0.5024, 0.5937, 0.5238]}, {"w": "often", "b": [0.5987, 0.5024, 0.6421, 0.5238]}, {"w": "has", "b": [0.647, 0.5024, 0.6749, 0.5238]}, {"w": "a", "b": [0.6799, 0.5024, 0.689, 0.5238]}, {"w": "lot)", "b": [0.694, 0.5024, 0.7234, 0.5238]}, {"w": "but", "b": [0.7284, 0.5024, 0.7564, 0.5238]}, {"w": "because", "b": [0.7613, 0.5024, 0.8259, 0.5238]}, {"w": "the", "b": [0.8308, 0.5024, 0.8571, 0.5238]}, {"w": "number", "b": [0.1429, 0.5214, 0.2091, 0.5429]}, {"w": "of", "b": [0.2155, 0.5214, 0.2322, 0.5429]}, {"w": "parameters", "b": [0.2386, 0.5214, 0.332, 0.5429]}, {"w": "is", "b": [0.3383, 0.5214, 0.3515, 0.5429]}, {"w": "not", "b": [0.3578, 0.5214, 0.3862, 0.5429]}, {"w": "determined", "b": [0.3925, 0.5214, 0.4892, 0.5429]}, {"w": "prior", "b": [0.4955, 0.5214, 0.5381, 0.5429]}, {"w": "to", "b": [0.5444, 0.5214, 0.5614, 0.5429]}, {"w": "training,", "b": [0.5677, 0.5214, 0.6394, 0.5429]}, {"w": "so", "b": [0.6457, 0.5214, 0.6639, 0.5429]}, {"w": "the", "b": [0.6702, 0.5214, 0.6966, 0.5429]}, {"w": "model", "b": [0.7029, 0.5214, 0.7557, 0.5429]}, {"w": "structure", "b": [0.762, 0.5214, 0.8376, 0.5429]}, {"w": "is", "b": [0.8439, 0.5214, 0.8571, 0.5429]}, {"w": "free", "b": [0.1429, 0.5405, 0.1745, 0.5619]}, {"w": "to", "b": [0.1797, 0.5405, 0.1967, 0.5619]}, {"w": "stick", "b": [0.2019, 0.5405, 0.2406, 0.5619]}, {"w": "closely", "b": [0.2458, 0.5405, 0.3019, 0.5619]}, {"w": "to", "b": [0.3071, 0.5405, 0.324, 0.5619]}, {"w": "the", "b": [0.3293, 0.5405, 0.3556, 0.5619]}, {"w": "data.", "b": [0.3608, 0.5405, 0.4008, 0.5619]}, {"w": "In", "b": [0.406, 0.5405, 0.4245, 0.5619]}, {"w": "contrast,", "b": [0.4297, 0.5405, 0.5022, 0.5619]}, {"w": "a", "b": [0.5074, 0.5405, 0.5165, 0.5619]}, {"w": "parametric", "b": [0.5217, 0.5403, 0.6108, 0.5619]}, {"w": "model", "b": [0.6155, 0.5403, 0.6652, 0.5619]}, {"w": "such", "b": [0.6709, 0.5405, 0.7095, 0.5619]}, {"w": "as", "b": [0.7148, 0.5405, 0.7316, 0.5619]}, {"w": "a", "b": [0.7368, 0.5405, 0.7459, 0.5619]}, {"w": "linear", "b": [0.7511, 0.5405, 0.7991, 0.5619]}, {"w": "model", "b": [0.8043, 0.5405, 0.8571, 0.5619]}, {"w": "has", "b": [0.1428, 0.5595, 0.1708, 0.5809]}, {"w": "a", "b": [0.1803, 0.5595, 0.1894, 0.5809]}, {"w": "predetermined", "b": [0.1989, 0.5595, 0.3231, 0.5809]}, {"w": "number", "b": [0.3326, 0.5595, 0.3989, 0.5809]}, {"w": "of", "b": [0.4084, 0.5595, 0.4252, 0.5809]}, {"w": "parameters,", "b": [0.4347, 0.5595, 0.5329, 0.5809]}, {"w": "so", "b": [0.5424, 0.5595, 0.5607, 0.5809]}, {"w": "its", "b": [0.5702, 0.5595, 0.5898, 0.5809]}, {"w": "degree", "b": [0.5993, 0.5595, 0.6543, 0.5809]}, {"w": "of", "b": [0.6638, 0.5595, 0.6806, 0.5809]}, {"w": "freedom", "b": [0.6901, 0.5595, 0.7604, 0.5809]}, {"w": "is", "b": [0.7699, 0.5595, 0.7832, 0.5809]}, {"w": "limited,", "b": [0.7927, 0.5595, 0.8571, 0.5809]}, {"w": "reducing", "b": [0.1429, 0.5786, 0.217, 0.6]}, {"w": "the", "b": [0.2218, 0.5786, 0.2481, 0.6]}, {"w": "risk", "b": [0.2528, 0.5786, 0.2841, 0.6]}, {"w": "of", "b": [0.2889, 0.5786, 0.3057, 0.6]}, {"w": "overfitting", "b": [0.3104, 0.5786, 0.3984, 0.6]}, {"w": "(but", "b": [0.4032, 0.5786, 0.4384, 0.6]}, {"w": "increasing", "b": [0.4431, 0.5786, 0.529, 0.6]}, {"w": "the", "b": [0.5337, 0.5786, 0.56, 0.6]}, {"w": "risk", "b": [0.5648, 0.5786, 0.5961, 0.6]}, {"w": "of", "b": [0.6008, 0.5786, 0.6176, 0.6]}, {"w": "underfitting).", "b": [0.6223, 0.5786, 0.7355, 0.6]}]}, {"id": "b_10", "type": "paragraph", "text": "To avoid overfitting the training data, you need to restrict the Decision Tree’s freedom during training. As you know by now, this is called regularization. The regularization hyperparameters depend on the algorithm used, but generally you can at least restrict the maximum depth of the Decision Tree. In Scikit-Learn, this is controlled by the max_depth hyperparameter (the default value is None, which means unlimited). Reducing max_depth will regularize the model and thus reduce the risk of overfitting.", "words": [{"w": "To", "b": [0.1429, 0.6067, 0.1643, 0.6281]}, {"w": "avoid", "b": [0.169, 0.6067, 0.2147, 0.6281]}, {"w": "overfitting", "b": [0.2195, 0.6067, 0.3076, 0.6281]}, {"w": "the", "b": [0.3124, 0.6067, 0.3387, 0.6281]}, {"w": "training", "b": [0.3435, 0.6067, 0.4104, 0.6281]}, {"w": "data,", "b": [0.4152, 0.6067, 0.4552, 0.6281]}, {"w": "you", "b": [0.46, 0.6067, 0.4913, 0.6281]}, {"w": "need", "b": [0.4961, 0.6067, 0.5362, 0.6281]}, {"w": "to", "b": [0.541, 0.6067, 0.558, 0.6281]}, {"w": "restrict", "b": [0.5628, 0.6067, 0.6218, 0.6281]}, {"w": "the", "b": [0.6266, 0.6067, 0.653, 0.6281]}, {"w": "Decision", "b": [0.6578, 0.6067, 0.7316, 0.6281]}, {"w": "Tree’s", "b": [0.7364, 0.6067, 0.7821, 0.6281]}, {"w": "freedom", "b": [0.7869, 0.6067, 0.8571, 0.6281]}, {"w": "during", "b": [0.1429, 0.6257, 0.1994, 0.6472]}, {"w": "training.", "b": [0.2047, 0.6257, 0.2764, 0.6472]}, {"w": "As", "b": [0.2816, 0.6257, 0.3037, 0.6472]}, {"w": "you", "b": [0.309, 0.6257, 0.3402, 0.6472]}, {"w": "know", "b": [0.3455, 0.6257, 0.3921, 0.6472]}, {"w": "by", "b": [0.3974, 0.6257, 0.4176, 0.6472]}, {"w": "now,", "b": [0.4229, 0.6257, 0.4624, 0.6472]}, {"w": "this", "b": [0.4677, 0.6257, 0.4984, 0.6472]}, {"w": "is", "b": [0.5037, 0.6257, 0.5169, 0.6472]}, {"w": "called", "b": [0.5222, 0.6257, 0.5705, 0.6472]}, {"w": "regularization.", "b": [0.5758, 0.6257, 0.6972, 0.6472]}, {"w": "The", "b": [0.7024, 0.6257, 0.7353, 0.6472]}, {"w": "regularization", "b": [0.7406, 0.6257, 0.8571, 0.6472]}, {"w": "hyperparameters", "b": [0.1429, 0.6448, 0.284, 0.6662]}, {"w": "depend", "b": [0.2891, 0.6448, 0.3511, 0.6662]}, {"w": "on", "b": [0.3562, 0.6448, 0.3782, 0.6662]}, {"w": "the", "b": [0.3833, 0.6448, 0.4096, 0.6662]}, {"w": "algorithm", "b": [0.4147, 0.6448, 0.4973, 0.6662]}, {"w": "used,", "b": [0.5024, 0.6448, 0.5457, 0.6662]}, {"w": "but", "b": [0.5508, 0.6448, 0.5788, 0.6662]}, {"w": "generally", "b": [0.5839, 0.6448, 0.6597, 0.6662]}, {"w": "you", "b": [0.6648, 0.6448, 0.696, 0.6662]}, {"w": "can", "b": [0.7011, 0.6448, 0.7305, 0.6662]}, {"w": "at", "b": [0.7355, 0.6448, 0.7506, 0.6662]}, {"w": "least", "b": [0.7557, 0.6448, 0.793, 0.6662]}, {"w": "restrict", "b": [0.7981, 0.6448, 0.8571, 0.6662]}, {"w": "the", "b": [0.1428, 0.6638, 0.1692, 0.6853]}, {"w": "maximum", "b": [0.1764, 0.6638, 0.2628, 0.6853]}, {"w": "depth", "b": [0.27, 0.6638, 0.3182, 0.6853]}, {"w": "of", "b": [0.3254, 0.6638, 0.3422, 0.6853]}, {"w": "the", "b": [0.3494, 0.6638, 0.3757, 0.6853]}, {"w": "Decision", "b": [0.3829, 0.6638, 0.4568, 0.6853]}, {"w": "Tree.", "b": [0.464, 0.6638, 0.5053, 0.6853]}, {"w": "In", "b": [0.5125, 0.6638, 0.531, 0.6853]}, {"w": "Scikit-Learn,", "b": [0.5382, 0.6638, 0.6452, 0.6853]}, {"w": "this", "b": [0.6524, 0.6638, 0.6831, 0.6853]}, {"w": "is", "b": [0.6903, 0.6638, 0.7035, 0.6853]}, {"w": "controlled", "b": [0.7107, 0.6638, 0.7963, 0.6853]}, {"w": "by", "b": [0.8035, 0.6638, 0.8236, 0.6853]}, {"w": "the", "b": [0.8308, 0.6638, 0.8571, 0.6853]}, {"w": "max_depth", "b": [0.1428, 0.687, 0.2319, 0.7021]}, {"w": "hyperparameter", "b": [0.243, 0.6838, 0.3765, 0.7052]}, {"w": "(the", "b": [0.3876, 0.6838, 0.4212, 0.7052]}, {"w": "default", "b": [0.4323, 0.6838, 0.4898, 0.7052]}, {"w": "value", "b": [0.5009, 0.6838, 0.5449, 0.7052]}, {"w": "is", "b": [0.556, 0.6838, 0.5692, 0.7052]}, {"w": "None,", "b": [0.5803, 0.6838, 0.6246, 0.7052]}, {"w": "which", "b": [0.6358, 0.6838, 0.6867, 0.7052]}, {"w": "means", "b": [0.6978, 0.6838, 0.7519, 0.7052]}, {"w": "unlimited).", "b": [0.763, 0.6838, 0.8571, 0.7052]}, {"w": "Reducing", "b": [0.1429, 0.7037, 0.2223, 0.7251]}, {"w": "max_depth", "b": [0.227, 0.7069, 0.3161, 0.722]}, {"w": "will", "b": [0.3208, 0.7037, 0.3512, 0.7251]}, {"w": "regularize", "b": [0.3559, 0.7037, 0.4386, 0.7251]}, {"w": "the", "b": [0.4434, 0.7037, 0.4697, 0.7251]}, {"w": "model", "b": [0.4744, 0.7037, 0.5272, 0.7251]}, {"w": "and", "b": [0.532, 0.7037, 0.5635, 0.7251]}, {"w": "thus", "b": [0.5682, 0.7037, 0.604, 0.7251]}, {"w": "reduce", "b": [0.6088, 0.7037, 0.6651, 0.7251]}, {"w": "the", "b": [0.6698, 0.7037, 0.6961, 0.7251]}, {"w": "risk", "b": [0.7009, 0.7037, 0.7322, 0.7251]}, {"w": "of", "b": [0.7369, 0.7037, 0.7537, 0.7251]}, {"w": "overfitting.", "b": [0.7584, 0.7037, 0.8512, 0.7251]}]}, {"id": "b_11", "type": "paragraph", "text": "The DecisionTreeClassifier class has a few other parameters that similarly restrict the shape of the Decision Tree: min_samples_split (the minimum number of sam‐ ples a node must have before it can be split), min_samples_leaf (the minimum num‐ ber of samples a leaf node must have), min_weight_fraction_leaf (same as min_samples_leaf but expressed as a fraction of the total number of weighted", "words": [{"w": "The", "b": [0.1429, 0.7327, 0.1757, 0.7542]}, {"w": "DecisionTreeClassifier", "b": [0.1813, 0.7359, 0.399, 0.751]}, {"w": "class", "b": [0.4047, 0.7327, 0.4432, 0.7542]}, {"w": "has", "b": [0.4488, 0.7327, 0.4767, 0.7542]}, {"w": "a", "b": [0.4823, 0.7327, 0.4915, 0.7542]}, {"w": "few", "b": [0.4971, 0.7327, 0.5264, 0.7542]}, {"w": "other", "b": [0.532, 0.7327, 0.5767, 0.7542]}, {"w": "parameters", "b": [0.5823, 0.7327, 0.6758, 0.7542]}, {"w": "that", "b": [0.6814, 0.7327, 0.714, 0.7542]}, {"w": "similarly", "b": [0.7196, 0.7327, 0.7925, 0.7542]}, {"w": "restrict", "b": [0.7981, 0.7327, 0.8571, 0.7542]}, {"w": "the", "b": [0.1429, 0.7527, 0.1692, 0.7741]}, {"w": "shape", "b": [0.1757, 0.7527, 0.223, 0.7741]}, {"w": "of", "b": [0.2295, 0.7527, 0.2463, 0.7741]}, {"w": "the", "b": [0.2529, 0.7527, 0.2792, 0.7741]}, {"w": "Decision", "b": [0.2857, 0.7527, 0.3596, 0.7741]}, {"w": "Tree:", "b": [0.3661, 0.7527, 0.4074, 0.7741]}, {"w": "min_samples_split", "b": [0.4139, 0.7559, 0.5822, 0.771]}, {"w": "(the", "b": [0.5887, 0.7527, 0.6222, 0.7741]}, {"w": "minimum", "b": [0.6288, 0.7527, 0.7132, 0.7741]}, {"w": "number", "b": [0.7197, 0.7527, 0.786, 0.7741]}, {"w": "of", "b": [0.7925, 0.7527, 0.8093, 0.7741]}, {"w": "sam‐", "b": [0.8159, 0.7527, 0.8571, 0.7741]}, {"w": "ples", "b": [0.1429, 0.7726, 0.1755, 0.794]}, {"w": "a", "b": [0.1806, 0.7726, 0.1898, 0.794]}, {"w": "node", "b": [0.1949, 0.7726, 0.2368, 0.794]}, {"w": "must", "b": [0.2419, 0.7726, 0.2836, 0.794]}, {"w": "have", "b": [0.2887, 0.7726, 0.3271, 0.794]}, {"w": "before", "b": [0.3322, 0.7726, 0.385, 0.794]}, {"w": "it", "b": [0.3901, 0.7726, 0.4021, 0.794]}, {"w": "can", "b": [0.4072, 0.7726, 0.4365, 0.794]}, {"w": "be", "b": [0.4416, 0.7726, 0.4611, 0.794]}, {"w": "split),", "b": [0.4662, 0.7726, 0.5139, 0.794]}, {"w": "min_samples_leaf", "b": [0.519, 0.7758, 0.6773, 0.7909]}, {"w": "(the", "b": [0.6824, 0.7726, 0.716, 0.794]}, {"w": "minimum", "b": [0.7211, 0.7726, 0.8055, 0.794]}, {"w": "num‐", "b": [0.8106, 0.7726, 0.8571, 0.794]}, {"w": "ber", "b": [0.1428, 0.7926, 0.17, 0.814]}, {"w": "of", "b": [0.1828, 0.7926, 0.1995, 0.814]}, {"w": "samples", "b": [0.2123, 0.7926, 0.2784, 0.814]}, {"w": "a", "b": [0.2912, 0.7926, 0.3003, 0.814]}, {"w": "leaf", "b": [0.3131, 0.7926, 0.3425, 0.814]}, {"w": "node", "b": [0.3552, 0.7926, 0.3971, 0.814]}, {"w": "must", "b": [0.4099, 0.7926, 0.4516, 0.814]}, {"w": "have),", "b": [0.4643, 0.7926, 0.5147, 0.814]}, {"w": "min_weight_fraction_leaf", "b": [0.5274, 0.7958, 0.7649, 0.8108]}, {"w": "(same", "b": [0.7777, 0.7926, 0.8276, 0.814]}, {"w": "as", "b": [0.8403, 0.7926, 0.8571, 0.814]}, {"w": "min_samples_leaf", "b": [0.1429, 0.8157, 0.3012, 0.8308]}, {"w": "but", "b": [0.3117, 0.8125, 0.3397, 0.8339]}, {"w": "expressed", "b": [0.3502, 0.8125, 0.4315, 0.8339]}, {"w": "as", "b": [0.442, 0.8125, 0.4588, 0.8339]}, {"w": "a", "b": [0.4693, 0.8125, 0.4785, 0.8339]}, {"w": "fraction", "b": [0.489, 0.8125, 0.5548, 0.8339]}, {"w": "of", "b": [0.5653, 0.8125, 0.5821, 0.8339]}, {"w": "the", "b": [0.5926, 0.8125, 0.6189, 0.8339]}, {"w": "total", "b": [0.6294, 0.8125, 0.6672, 0.8339]}, {"w": "number", "b": [0.6777, 0.8125, 0.7439, 0.8339]}, {"w": "of", "b": [0.7544, 0.8125, 0.7712, 0.8339]}, {"w": "weighted", "b": [0.7817, 0.8125, 0.8571, 0.8339]}]}, {"id": "b_12", "type": "paragraph", "text": "184 | Chapter 6: Decision Trees", "words": [{"w": "184", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "6:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Decision", "b": [0.2673, 0.9225, 0.3162, 0.9388]}, {"w": "Trees", "b": [0.319, 0.9225, 0.3502, 0.9388]}]}]}, {"page": 211, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "instances), max_leaf_nodes (maximum number of leaf nodes), and max_features (maximum number of features that are evaluated for splitting at each node). Increas‐ ing min_* hyperparameters or reducing max_* hyperparameters will regularize the model.", "words": [{"w": "instances),", "b": [0.1429, 0.08, 0.2316, 0.1014]}, {"w": "max_leaf_nodes", "b": [0.2403, 0.0831, 0.3788, 0.0982]}, {"w": "(maximum", "b": [0.3874, 0.08, 0.4811, 0.1014]}, {"w": "number", "b": [0.4897, 0.08, 0.556, 0.1014]}, {"w": "of", "b": [0.5646, 0.08, 0.5814, 0.1014]}, {"w": "leaf", "b": [0.59, 0.08, 0.6195, 0.1014]}, {"w": "nodes),", "b": [0.6281, 0.08, 0.6896, 0.1014]}, {"w": "and", "b": [0.6982, 0.08, 0.7298, 0.1014]}, {"w": "max_features", "b": [0.7384, 0.0831, 0.8571, 0.0982]}, {"w": "(maximum", "b": [0.1429, 0.099, 0.2365, 0.1204]}, {"w": "number", "b": [0.242, 0.099, 0.3083, 0.1204]}, {"w": "of", "b": [0.3139, 0.099, 0.3307, 0.1204]}, {"w": "features", "b": [0.3362, 0.099, 0.4016, 0.1204]}, {"w": "that", "b": [0.4072, 0.099, 0.4397, 0.1204]}, {"w": "are", "b": [0.4453, 0.099, 0.471, 0.1204]}, {"w": "evaluated", "b": [0.4766, 0.099, 0.5555, 0.1204]}, {"w": "for", "b": [0.5611, 0.099, 0.5856, 0.1204]}, {"w": "splitting", "b": [0.5911, 0.099, 0.66, 0.1204]}, {"w": "at", "b": [0.6655, 0.099, 0.6806, 0.1204]}, {"w": "each", "b": [0.6862, 0.099, 0.7241, 0.1204]}, {"w": "node).", "b": [0.7297, 0.099, 0.7835, 0.1204]}, {"w": "Increas‐", "b": [0.789, 0.099, 0.8571, 0.1204]}, {"w": "ing", "b": [0.1429, 0.119, 0.1696, 0.1404]}, {"w": "min_*", "b": [0.1779, 0.1221, 0.2273, 0.1372]}, {"w": "hyperparameters", "b": [0.2356, 0.119, 0.3767, 0.1404]}, {"w": "or", "b": [0.385, 0.119, 0.4033, 0.1404]}, {"w": "reducing", "b": [0.4116, 0.119, 0.4858, 0.1404]}, {"w": "max_*", "b": [0.494, 0.1221, 0.5435, 0.1372]}, {"w": "hyperparameters", "b": [0.5518, 0.119, 0.6929, 0.1404]}, {"w": "will", "b": [0.7012, 0.119, 0.7316, 0.1404]}, {"w": "regularize", "b": [0.7398, 0.119, 0.8226, 0.1404]}, {"w": "the", "b": [0.8308, 0.119, 0.8572, 0.1404]}, {"w": "model.", "b": [0.1429, 0.138, 0.2004, 0.1594]}]}, {"id": "b_1", "type": "paragraph", "text": "Other algorithms work by first training the Decision Tree without restrictions, then pruning (deleting) unnecessary nodes. A node whose children are all leaf nodes is considered unnecessary if the purity improvement it provides is not statistically significant. Stan‐ dard statistical tests, such as the χ2 test, are used to estimate the probability that the improvement is purely the result of chance (which is called the null hypothesis). If this probability, called the p- value, is higher than a given threshold (typically 5%, controlled by a hyperparameter), then the node is considered unnecessary and its children are deleted. The pruning continues until all unnecessary nodes have been pruned.", "words": [{"w": "Other", "b": [0.2714, 0.1799, 0.3168, 0.1995]}, {"w": "algorithms", "b": [0.3226, 0.1799, 0.4051, 0.1995]}, {"w": "work", "b": [0.4109, 0.1799, 0.4502, 0.1995]}, {"w": "by", "b": [0.456, 0.1799, 0.4744, 0.1995]}, {"w": "first", "b": [0.4802, 0.1799, 0.5108, 0.1995]}, {"w": "training", "b": [0.5166, 0.1799, 0.5778, 0.1995]}, {"w": "the", "b": [0.5836, 0.1799, 0.6077, 0.1995]}, {"w": "Decision", "b": [0.6135, 0.1799, 0.6809, 0.1995]}, {"w": "Tree", "b": [0.6867, 0.1799, 0.7202, 0.1995]}, {"w": "without", "b": [0.7259, 0.1799, 0.7857, 0.1995]}, {"w": "restrictions,", "b": [0.2714, 0.1974, 0.362, 0.2169]}, {"w": "then", "b": [0.3707, 0.1974, 0.4052, 0.2169]}, {"w": "pruning", "b": [0.4139, 0.1972, 0.4727, 0.2169]}, {"w": "(deleting)", "b": [0.4814, 0.1974, 0.5559, 0.2169]}, {"w": "unnecessary", "b": [0.5646, 0.1974, 0.6585, 0.2169]}, {"w": "nodes.", "b": [0.6672, 0.1974, 0.7168, 0.2169]}, {"w": "A", "b": [0.7256, 0.1974, 0.7387, 0.2169]}, {"w": "node", "b": [0.7474, 0.1974, 0.7857, 0.2169]}, {"w": "whose", "b": [0.2714, 0.2148, 0.3194, 0.2343]}, {"w": "children", "b": [0.3259, 0.2148, 0.3897, 0.2343]}, {"w": "are", "b": [0.3961, 0.2148, 0.4196, 0.2343]}, {"w": "all", "b": [0.426, 0.2148, 0.444, 0.2343]}, {"w": "leaf", "b": [0.4505, 0.2148, 0.4774, 0.2343]}, {"w": "nodes", "b": [0.4838, 0.2148, 0.5291, 0.2343]}, {"w": "is", "b": [0.5355, 0.2148, 0.5476, 0.2343]}, {"w": "considered", "b": [0.554, 0.2148, 0.6377, 0.2343]}, {"w": "unnecessary", "b": [0.6441, 0.2148, 0.738, 0.2343]}, {"w": "if", "b": [0.7445, 0.2148, 0.7552, 0.2343]}, {"w": "the", "b": [0.7616, 0.2148, 0.7857, 0.2343]}, {"w": "purity", "b": [0.2714, 0.2322, 0.3182, 0.2518]}, {"w": "improvement", "b": [0.3237, 0.2322, 0.4273, 0.2518]}, {"w": "it", "b": [0.4328, 0.2322, 0.4438, 0.2518]}, {"w": "provides", "b": [0.4493, 0.2322, 0.5151, 0.2518]}, {"w": "is", "b": [0.5206, 0.2322, 0.5327, 0.2518]}, {"w": "not", "b": [0.5382, 0.2322, 0.5642, 0.2518]}, {"w": "statistically", "b": [0.5697, 0.232, 0.6523, 0.2518]}, {"w": "significant.", "b": [0.6578, 0.232, 0.7398, 0.2518]}, {"w": "Stan‐", "b": [0.7453, 0.2322, 0.7857, 0.2518]}, {"w": "dard", "b": [0.2714, 0.2496, 0.307, 0.2692]}, {"w": "statistical", "b": [0.3144, 0.2496, 0.3853, 0.2692]}, {"w": "tests,", "b": [0.3927, 0.2496, 0.4307, 0.2692]}, {"w": "such", "b": [0.4382, 0.2496, 0.4735, 0.2692]}, {"w": "as", "b": [0.4809, 0.2496, 0.4963, 0.2692]}, {"w": "the", "b": [0.5037, 0.2496, 0.5278, 0.2692]}, {"w": "χ2", "b": [0.5352, 0.2494, 0.5497, 0.2692]}, {"w": "test,", "b": [0.5571, 0.2494, 0.5866, 0.2692]}, {"w": "are", "b": [0.5941, 0.2496, 0.6176, 0.2692]}, {"w": "used", "b": [0.625, 0.2496, 0.6603, 0.2692]}, {"w": "to", "b": [0.6677, 0.2496, 0.6833, 0.2692]}, {"w": "estimate", "b": [0.6907, 0.2496, 0.7542, 0.2692]}, {"w": "the", "b": [0.7616, 0.2496, 0.7857, 0.2692]}, {"w": "probability", "b": [0.2714, 0.267, 0.3555, 0.2866]}, {"w": "that", "b": [0.364, 0.267, 0.3937, 0.2866]}, {"w": "the", "b": [0.4022, 0.267, 0.4263, 0.2866]}, {"w": "improvement", "b": [0.4348, 0.267, 0.5384, 0.2866]}, {"w": "is", "b": [0.5469, 0.267, 0.559, 0.2866]}, {"w": "purely", "b": [0.5674, 0.267, 0.6163, 0.2866]}, {"w": "the", "b": [0.6248, 0.267, 0.6488, 0.2866]}, {"w": "result", "b": [0.6573, 0.267, 0.7002, 0.2866]}, {"w": "of", "b": [0.7087, 0.267, 0.7241, 0.2866]}, {"w": "chance", "b": [0.7325, 0.267, 0.7857, 0.2866]}, {"w": "(which", "b": [0.2714, 0.2844, 0.3245, 0.304]}, {"w": "is", "b": [0.3294, 0.2844, 0.3415, 0.304]}, {"w": "called", "b": [0.3463, 0.2844, 0.3905, 0.304]}, {"w": "the", "b": [0.3953, 0.2844, 0.4194, 0.304]}, {"w": "null", "b": [0.4242, 0.2842, 0.4534, 0.304]}, {"w": "hypothesis).", "b": [0.4578, 0.2842, 0.5457, 0.304]}, {"w": "If", "b": [0.5505, 0.2844, 0.5627, 0.304]}, {"w": "this", "b": [0.5675, 0.2844, 0.5955, 0.304]}, {"w": "probability,", "b": [0.6004, 0.2844, 0.6874, 0.304]}, {"w": "called", "b": [0.6922, 0.2844, 0.7364, 0.304]}, {"w": "the", "b": [0.7412, 0.2844, 0.7653, 0.304]}, {"w": "p-", "b": [0.7701, 0.2842, 0.7857, 0.304]}, {"w": "value,", "b": [0.2714, 0.3017, 0.3155, 0.3214]}, {"w": "is", "b": [0.3211, 0.3018, 0.3332, 0.3214]}, {"w": "higher", "b": [0.3387, 0.3018, 0.3883, 0.3214]}, {"w": "than", "b": [0.3938, 0.3018, 0.4286, 0.3214]}, {"w": "a", "b": [0.4341, 0.3018, 0.4425, 0.3214]}, {"w": "given", "b": [0.4481, 0.3018, 0.4894, 0.3214]}, {"w": "threshold", "b": [0.495, 0.3018, 0.5679, 0.3214]}, {"w": "(typically", "b": [0.5735, 0.3018, 0.6445, 0.3214]}, {"w": "5%,", "b": [0.6501, 0.3018, 0.6779, 0.3214]}, {"w": "controlled", "b": [0.6835, 0.3018, 0.7617, 0.3214]}, {"w": "by", "b": [0.7673, 0.3018, 0.7857, 0.3214]}, {"w": "a", "b": [0.2714, 0.3193, 0.2798, 0.3388]}, {"w": "hyperparameter),", "b": [0.2842, 0.3193, 0.4172, 0.3388]}, {"w": "then", "b": [0.4216, 0.3193, 0.4561, 0.3388]}, {"w": "the", "b": [0.4605, 0.3193, 0.4846, 0.3388]}, {"w": "node", "b": [0.489, 0.3193, 0.5273, 0.3388]}, {"w": "is", "b": [0.5317, 0.3193, 0.5438, 0.3388]}, {"w": "considered", "b": [0.5482, 0.3193, 0.6318, 0.3388]}, {"w": "unnecessary", "b": [0.6362, 0.3193, 0.7301, 0.3388]}, {"w": "and", "b": [0.7346, 0.3193, 0.7634, 0.3388]}, {"w": "its", "b": [0.7678, 0.3193, 0.7857, 0.3388]}, {"w": "children", "b": [0.2714, 0.3367, 0.3352, 0.3563]}, {"w": "are", "b": [0.3419, 0.3367, 0.3654, 0.3563]}, {"w": "deleted.", "b": [0.3722, 0.3367, 0.4315, 0.3563]}, {"w": "The", "b": [0.4383, 0.3367, 0.4683, 0.3563]}, {"w": "pruning", "b": [0.475, 0.3367, 0.537, 0.3563]}, {"w": "continues", "b": [0.5437, 0.3367, 0.6177, 0.3563]}, {"w": "until", "b": [0.6245, 0.3367, 0.6604, 0.3563]}, {"w": "all", "b": [0.6671, 0.3367, 0.6851, 0.3563]}, {"w": "unnecessary", "b": [0.6918, 0.3367, 0.7857, 0.3563]}, {"w": "nodes", "b": [0.2714, 0.3541, 0.3167, 0.3737]}, {"w": "have", "b": [0.321, 0.3541, 0.3561, 0.3737]}, {"w": "been", "b": [0.3604, 0.3541, 0.3967, 0.3737]}, {"w": "pruned.", "b": [0.401, 0.3541, 0.4611, 0.3737]}]}, {"id": "b_2", "type": "paragraph", "text": "Figure 6-3 shows two Decision Trees trained on the moons dataset (introduced in Chapter 5). On the left, the Decision Tree is trained with the default hyperparameters (i.e., no restrictions), and on the right the Decision Tree is trained with min_sam ples_leaf=4. It is quite obvious that the model on the left is overfitting, and the model on the right will probably generalize better.", "words": [{"w": "Figure", "b": [0.1429, 0.394, 0.1969, 0.4154]}, {"w": "6-3", "b": [0.2046, 0.394, 0.232, 0.4154]}, {"w": "shows", "b": [0.2397, 0.394, 0.291, 0.4154]}, {"w": "two", "b": [0.2986, 0.394, 0.3299, 0.4154]}, {"w": "Decision", "b": [0.3376, 0.394, 0.4114, 0.4154]}, {"w": "Trees", "b": [0.4191, 0.394, 0.4633, 0.4154]}, {"w": "trained", "b": [0.471, 0.394, 0.531, 0.4154]}, {"w": "on", "b": [0.5387, 0.394, 0.5607, 0.4154]}, {"w": "the", "b": [0.5684, 0.394, 0.5948, 0.4154]}, {"w": "moons", "b": [0.6024, 0.394, 0.6598, 0.4154]}, {"w": "dataset", "b": [0.6675, 0.394, 0.7256, 0.4154]}, {"w": "(introduced", "b": [0.7333, 0.394, 0.8325, 0.4154]}, {"w": "in", "b": [0.8402, 0.394, 0.8572, 0.4154]}, {"w": "Chapter", "b": [0.1429, 0.413, 0.2104, 0.4344]}, {"w": "5).", "b": [0.2152, 0.413, 0.2376, 0.4344]}, {"w": "On", "b": [0.2428, 0.413, 0.2698, 0.4344]}, {"w": "the", "b": [0.275, 0.413, 0.3013, 0.4344]}, {"w": "left,", "b": [0.3065, 0.413, 0.3379, 0.4344]}, {"w": "the", "b": [0.3432, 0.413, 0.3695, 0.4344]}, {"w": "Decision", "b": [0.3747, 0.413, 0.4485, 0.4344]}, {"w": "Tree", "b": [0.4537, 0.413, 0.4903, 0.4344]}, {"w": "is", "b": [0.4955, 0.413, 0.5087, 0.4344]}, {"w": "trained", "b": [0.514, 0.413, 0.574, 0.4344]}, {"w": "with", "b": [0.5792, 0.413, 0.6166, 0.4344]}, {"w": "the", "b": [0.6218, 0.413, 0.6481, 0.4344]}, {"w": "default", "b": [0.6533, 0.413, 0.7108, 0.4344]}, {"w": "hyperparameters", "b": [0.716, 0.413, 0.8571, 0.4344]}, {"w": "(i.e.,", "b": [0.1428, 0.433, 0.1787, 0.4544]}, {"w": "no", "b": [0.1872, 0.433, 0.2092, 0.4544]}, {"w": "restrictions),", "b": [0.2177, 0.433, 0.3239, 0.4544]}, {"w": "and", "b": [0.3324, 0.433, 0.3639, 0.4544]}, {"w": "on", "b": [0.3724, 0.433, 0.3944, 0.4544]}, {"w": "the", "b": [0.4029, 0.433, 0.4292, 0.4544]}, {"w": "right", "b": [0.4377, 0.433, 0.4778, 0.4544]}, {"w": "the", "b": [0.4863, 0.433, 0.5126, 0.4544]}, {"w": "Decision", "b": [0.5211, 0.433, 0.5949, 0.4544]}, {"w": "Tree", "b": [0.6033, 0.433, 0.6399, 0.4544]}, {"w": "is", "b": [0.6483, 0.433, 0.6616, 0.4544]}, {"w": "trained", "b": [0.67, 0.433, 0.7301, 0.4544]}, {"w": "with", "b": [0.7385, 0.433, 0.7759, 0.4544]}, {"w": "min_sam", "b": [0.7843, 0.4361, 0.8536, 0.4512]}, {"w": "ples_leaf=4.", "b": [0.1429, 0.4529, 0.2565, 0.4743]}, {"w": "It", "b": [0.2647, 0.4529, 0.2774, 0.4743]}, {"w": "is", "b": [0.2857, 0.4529, 0.2989, 0.4743]}, {"w": "quite", "b": [0.3072, 0.4529, 0.3497, 0.4743]}, {"w": "obvious", "b": [0.358, 0.4529, 0.4237, 0.4743]}, {"w": "that", "b": [0.432, 0.4529, 0.4646, 0.4743]}, {"w": "the", "b": [0.4729, 0.4529, 0.4992, 0.4743]}, {"w": "model", "b": [0.5075, 0.4529, 0.5603, 0.4743]}, {"w": "on", "b": [0.5686, 0.4529, 0.5906, 0.4743]}, {"w": "the", "b": [0.5989, 0.4529, 0.6252, 0.4743]}, {"w": "left", "b": [0.6335, 0.4529, 0.6601, 0.4743]}, {"w": "is", "b": [0.6684, 0.4529, 0.6816, 0.4743]}, {"w": "overfitting,", "b": [0.6899, 0.4529, 0.7827, 0.4743]}, {"w": "and", "b": [0.791, 0.4529, 0.8225, 0.4743]}, {"w": "the", "b": [0.8308, 0.4529, 0.8571, 0.4743]}, {"w": "model", "b": [0.1429, 0.4719, 0.1957, 0.4934]}, {"w": "on", "b": [0.2004, 0.4719, 0.2224, 0.4934]}, {"w": "the", "b": [0.2271, 0.4719, 0.2535, 0.4934]}, {"w": "right", "b": [0.2582, 0.4719, 0.2984, 0.4934]}, {"w": "will", "b": [0.3031, 0.4719, 0.3335, 0.4934]}, {"w": "probably", "b": [0.3382, 0.4719, 0.4126, 0.4934]}, {"w": "generalize", "b": [0.4174, 0.4719, 0.5015, 0.4934]}, {"w": "better.", "b": [0.5063, 0.4719, 0.5584, 0.4934]}]}, {"id": "b_3", "type": "equation", "text": "Figure 6-3. Regularization using min_samples_leaf", "words": [{"w": "Figure", "b": [0.1429, 0.7001, 0.1943, 0.7218]}, {"w": "6-3.", "b": [0.1991, 0.7001, 0.2308, 0.7218]}, {"w": "Regularization", "b": [0.2356, 0.7001, 0.3555, 0.7218]}, {"w": "using", "b": [0.3602, 0.7001, 0.4032, 0.7218]}, {"w": "min_samples_leaf", "b": [0.408, 0.7001, 0.5535, 0.7218]}]}, {"id": "b_4", "type": "paragraph", "text": "Regression", "words": [{"w": "Regression", "b": [0.1429, 0.7348, 0.2778, 0.769]}]}, {"id": "b_5", "type": "paragraph", "text": "Decision Trees are also capable of performing regression tasks. Let’s build a regres‐ sion tree using Scikit-Learn’s DecisionTreeRegressor class, training it on a noisy quadratic dataset with max_depth=2:", "words": [{"w": "Decision", "b": [0.1429, 0.7759, 0.2167, 0.7974]}, {"w": "Trees", "b": [0.2237, 0.7759, 0.2679, 0.7974]}, {"w": "are", "b": [0.2749, 0.7759, 0.3007, 0.7974]}, {"w": "also", "b": [0.3077, 0.7759, 0.3404, 0.7974]}, {"w": "capable", "b": [0.3474, 0.7759, 0.4098, 0.7974]}, {"w": "of", "b": [0.4168, 0.7759, 0.4336, 0.7974]}, {"w": "performing", "b": [0.4406, 0.7759, 0.5364, 0.7974]}, {"w": "regression", "b": [0.5435, 0.7759, 0.6293, 0.7974]}, {"w": "tasks.", "b": [0.6363, 0.7759, 0.6822, 0.7974]}, {"w": "Let’s", "b": [0.6892, 0.7759, 0.7254, 0.7974]}, {"w": "build", "b": [0.7324, 0.7759, 0.7759, 0.7974]}, {"w": "a", "b": [0.783, 0.7759, 0.7921, 0.7974]}, {"w": "regres‐", "b": [0.7992, 0.7759, 0.8571, 0.7974]}, {"w": "sion", "b": [0.1429, 0.7959, 0.1781, 0.8173]}, {"w": "tree", "b": [0.1866, 0.7959, 0.2184, 0.8173]}, {"w": "using", "b": [0.2269, 0.7959, 0.2723, 0.8173]}, {"w": "Scikit-Learn’s", "b": [0.2808, 0.7959, 0.3917, 0.8173]}, {"w": "DecisionTreeRegressor", "b": [0.4002, 0.7991, 0.608, 0.8141]}, {"w": "class,", "b": [0.6165, 0.7959, 0.6598, 0.8173]}, {"w": "training", "b": [0.6683, 0.7959, 0.7352, 0.8173]}, {"w": "it", "b": [0.7437, 0.7959, 0.7557, 0.8173]}, {"w": "on", "b": [0.7642, 0.7959, 0.7862, 0.8173]}, {"w": "a", "b": [0.7947, 0.7959, 0.8038, 0.8173]}, {"w": "noisy", "b": [0.8123, 0.7959, 0.8572, 0.8173]}, {"w": "quadratic", "b": [0.1429, 0.8158, 0.2219, 0.8372]}, {"w": "dataset", "b": [0.2267, 0.8158, 0.2848, 0.8372]}, {"w": "with", "b": [0.2895, 0.8158, 0.3268, 0.8372]}, {"w": "max_depth=2:", "b": [0.3316, 0.8158, 0.4452, 0.8372]}]}, {"id": "b_6", "type": "paragraph", "text": "from sklearn.tree import DecisionTreeRegressor", "words": [{"w": "from", "b": [0.1766, 0.8478, 0.2103, 0.8607]}, {"w": "sklearn.tree", "b": [0.2187, 0.8478, 0.3199, 0.8607]}, {"w": "import", "b": [0.3284, 0.8478, 0.379, 0.8607]}, {"w": "DecisionTreeRegressor", "b": [0.3874, 0.8478, 0.5645, 0.8607]}]}, {"id": "b_7", "type": "paragraph", "text": "Regression | 185", "words": [{"w": "Regression", "b": [0.7316, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "185", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 212, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "tree_reg = DecisionTreeRegressor(max_depth=2) tree_reg.fit(X, y)", "words": [{"w": "tree_reg", "b": [0.1766, 0.0829, 0.244, 0.0958]}, {"w": "=", "b": [0.2525, 0.0829, 0.2609, 0.0958]}, {"w": "DecisionTreeRegressor(max_depth=2)", "b": [0.2693, 0.0829, 0.5561, 0.0958]}, {"w": "tree_reg.fit(X,", "b": [0.1766, 0.0983, 0.3031, 0.1112]}, {"w": "y)", "b": [0.3115, 0.0983, 0.3284, 0.1112]}]}, {"id": "b_1", "type": "equation", "text": "The resulting tree is represented on Figure 6-4.", "words": [{"w": "The", "b": [0.1429, 0.119, 0.1757, 0.1404]}, {"w": "resulting", "b": [0.1804, 0.119, 0.2541, 0.1404]}, {"w": "tree", "b": [0.2588, 0.119, 0.2906, 0.1404]}, {"w": "is", "b": [0.2953, 0.119, 0.3085, 0.1404]}, {"w": "represented", "b": [0.3133, 0.119, 0.4111, 0.1404]}, {"w": "on", "b": [0.4158, 0.119, 0.4378, 0.1404]}, {"w": "Figure", "b": [0.4425, 0.119, 0.4965, 0.1404]}, {"w": "6-4.", "b": [0.5013, 0.119, 0.5334, 0.1404]}]}, {"id": "b_2", "type": "equation", "text": "Figure 6-4. A Decision Tree for regression", "words": [{"w": "Figure", "b": [0.1429, 0.4623, 0.1943, 0.484]}, {"w": "6-4.", "b": [0.1991, 0.4623, 0.2308, 0.484]}, {"w": "A", "b": [0.2356, 0.4623, 0.2494, 0.484]}, {"w": "Decision", "b": [0.2542, 0.4623, 0.3241, 0.484]}, {"w": "Tree", "b": [0.3289, 0.4623, 0.3636, 0.484]}, {"w": "for", "b": [0.3684, 0.4623, 0.391, 0.484]}, {"w": "regression", "b": [0.3958, 0.4623, 0.4754, 0.484]}]}, {"id": "b_3", "type": "paragraph", "text": "This tree looks very similar to the classification tree you built earlier. The main differ‐ ence is that instead of predicting a class in each node, it predicts a value. For example, suppose you want to make a prediction for a new instance with x1 = 0.6. You traverse the tree starting at the root, and you eventually reach the leaf node that predicts value=0.1106. This prediction is simply the average target value of the 110 training instances associated to this leaf node. This prediction results in a Mean Squared Error (MSE) equal to 0.0151 over these 110 instances.", "words": [{"w": "This", "b": [0.1429, 0.4997, 0.1801, 0.5211]}, {"w": "tree", "b": [0.1849, 0.4997, 0.2167, 0.5211]}, {"w": "looks", "b": [0.2216, 0.4997, 0.2661, 0.5211]}, {"w": "very", "b": [0.271, 0.4997, 0.3074, 0.5211]}, {"w": "similar", "b": [0.3122, 0.4997, 0.3703, 0.5211]}, {"w": "to", "b": [0.3751, 0.4997, 0.3921, 0.5211]}, {"w": "the", "b": [0.397, 0.4997, 0.4233, 0.5211]}, {"w": "classification", "b": [0.4282, 0.4997, 0.5356, 0.5211]}, {"w": "tree", "b": [0.5405, 0.4997, 0.5722, 0.5211]}, {"w": "you", "b": [0.5771, 0.4997, 0.6084, 0.5211]}, {"w": "built", "b": [0.6132, 0.4997, 0.6521, 0.5211]}, {"w": "earlier.", "b": [0.657, 0.4997, 0.7136, 0.5211]}, {"w": "The", "b": [0.7185, 0.4997, 0.7513, 0.5211]}, {"w": "main", "b": [0.7562, 0.4997, 0.7993, 0.5211]}, {"w": "differ‐", "b": [0.8042, 0.4997, 0.8571, 0.5211]}, {"w": "ence", "b": [0.1429, 0.5188, 0.1808, 0.5402]}, {"w": "is", "b": [0.1857, 0.5188, 0.1989, 0.5402]}, {"w": "that", "b": [0.2038, 0.5188, 0.2364, 0.5402]}, {"w": "instead", "b": [0.2413, 0.5188, 0.3013, 0.5402]}, {"w": "of", "b": [0.3062, 0.5188, 0.323, 0.5402]}, {"w": "predicting", "b": [0.3279, 0.5188, 0.4139, 0.5402]}, {"w": "a", "b": [0.4188, 0.5188, 0.428, 0.5402]}, {"w": "class", "b": [0.4329, 0.5188, 0.4714, 0.5402]}, {"w": "in", "b": [0.4763, 0.5188, 0.4933, 0.5402]}, {"w": "each", "b": [0.4982, 0.5188, 0.5362, 0.5402]}, {"w": "node,", "b": [0.5411, 0.5188, 0.5877, 0.5402]}, {"w": "it", "b": [0.5926, 0.5188, 0.6045, 0.5402]}, {"w": "predicts", "b": [0.6095, 0.5188, 0.6764, 0.5402]}, {"w": "a", "b": [0.6813, 0.5188, 0.6904, 0.5402]}, {"w": "value.", "b": [0.6953, 0.5188, 0.7441, 0.5402]}, {"w": "For", "b": [0.749, 0.5188, 0.7779, 0.5402]}, {"w": "example,", "b": [0.7829, 0.5188, 0.8572, 0.5402]}, {"w": "suppose", "b": [0.1429, 0.5378, 0.2105, 0.5592]}, {"w": "you", "b": [0.2159, 0.5378, 0.2472, 0.5592]}, {"w": "want", "b": [0.2525, 0.5378, 0.2933, 0.5592]}, {"w": "to", "b": [0.2987, 0.5378, 0.3157, 0.5592]}, {"w": "make", "b": [0.3211, 0.5378, 0.3665, 0.5592]}, {"w": "a", "b": [0.3718, 0.5378, 0.381, 0.5592]}, {"w": "prediction", "b": [0.3864, 0.5378, 0.4732, 0.5592]}, {"w": "for", "b": [0.4786, 0.5378, 0.5031, 0.5592]}, {"w": "a", "b": [0.5085, 0.5378, 0.5177, 0.5592]}, {"w": "new", "b": [0.523, 0.5378, 0.5576, 0.5592]}, {"w": "instance", "b": [0.5629, 0.5378, 0.6321, 0.5592]}, {"w": "with", "b": [0.6375, 0.5378, 0.6749, 0.5592]}, {"w": "x1", "b": [0.6802, 0.5376, 0.6961, 0.5601]}, {"w": "=", "b": [0.7015, 0.5378, 0.7135, 0.5592]}, {"w": "0.6.", "b": [0.7189, 0.5378, 0.7484, 0.5592]}, {"w": "You", "b": [0.7538, 0.5378, 0.7862, 0.5592]}, {"w": "traverse", "b": [0.7916, 0.5378, 0.8571, 0.5592]}, {"w": "the", "b": [0.1429, 0.5569, 0.1692, 0.5783]}, {"w": "tree", "b": [0.1778, 0.5569, 0.2096, 0.5783]}, {"w": "starting", "b": [0.2181, 0.5569, 0.2821, 0.5783]}, {"w": "at", "b": [0.2907, 0.5569, 0.3058, 0.5783]}, {"w": "the", "b": [0.3144, 0.5569, 0.3407, 0.5783]}, {"w": "root,", "b": [0.3493, 0.5569, 0.3894, 0.5783]}, {"w": "and", "b": [0.3979, 0.5569, 0.4295, 0.5783]}, {"w": "you", "b": [0.4381, 0.5569, 0.4693, 0.5783]}, {"w": "eventually", "b": [0.4779, 0.5569, 0.5629, 0.5783]}, {"w": "reach", "b": [0.5715, 0.5569, 0.6171, 0.5783]}, {"w": "the", "b": [0.6257, 0.5569, 0.6521, 0.5783]}, {"w": "leaf", "b": [0.6606, 0.5569, 0.6901, 0.5783]}, {"w": "node", "b": [0.6986, 0.5569, 0.7405, 0.5783]}, {"w": "that", "b": [0.7491, 0.5569, 0.7817, 0.5783]}, {"w": "predicts", "b": [0.7903, 0.5569, 0.8572, 0.5783]}, {"w": "value=0.1106.", "b": [0.1429, 0.5768, 0.2664, 0.5982]}, {"w": "This", "b": [0.2727, 0.5768, 0.3099, 0.5982]}, {"w": "prediction", "b": [0.3163, 0.5768, 0.4032, 0.5982]}, {"w": "is", "b": [0.4095, 0.5768, 0.4228, 0.5982]}, {"w": "simply", "b": [0.4292, 0.5768, 0.4848, 0.5982]}, {"w": "the", "b": [0.4912, 0.5768, 0.5175, 0.5982]}, {"w": "average", "b": [0.5239, 0.5768, 0.5866, 0.5982]}, {"w": "target", "b": [0.593, 0.5768, 0.6412, 0.5982]}, {"w": "value", "b": [0.6476, 0.5768, 0.6916, 0.5982]}, {"w": "of", "b": [0.6979, 0.5768, 0.7147, 0.5982]}, {"w": "the", "b": [0.7211, 0.5768, 0.7474, 0.5982]}, {"w": "110", "b": [0.7538, 0.5768, 0.7838, 0.5982]}, {"w": "training", "b": [0.7902, 0.5768, 0.8571, 0.5982]}, {"w": "instances", "b": [0.1429, 0.5959, 0.2197, 0.6173]}, {"w": "associated", "b": [0.2246, 0.5959, 0.309, 0.6173]}, {"w": "to", "b": [0.3138, 0.5959, 0.3308, 0.6173]}, {"w": "this", "b": [0.3357, 0.5959, 0.3664, 0.6173]}, {"w": "leaf", "b": [0.3712, 0.5959, 0.4007, 0.6173]}, {"w": "node.", "b": [0.4055, 0.5959, 0.4522, 0.6173]}, {"w": "This", "b": [0.457, 0.5959, 0.4942, 0.6173]}, {"w": "prediction", "b": [0.4991, 0.5959, 0.5859, 0.6173]}, {"w": "results", "b": [0.5908, 0.5959, 0.6454, 0.6173]}, {"w": "in", "b": [0.6502, 0.5959, 0.6672, 0.6173]}, {"w": "a", "b": [0.6721, 0.5959, 0.6812, 0.6173]}, {"w": "Mean", "b": [0.6861, 0.5959, 0.7335, 0.6173]}, {"w": "Squared", "b": [0.7383, 0.5959, 0.8066, 0.6173]}, {"w": "Error", "b": [0.8115, 0.5959, 0.8572, 0.6173]}, {"w": "(MSE)", "b": [0.1429, 0.6149, 0.1975, 0.6363]}, {"w": "equal", "b": [0.2023, 0.6149, 0.2473, 0.6363]}, {"w": "to", "b": [0.252, 0.6149, 0.269, 0.6363]}, {"w": "0.0151", "b": [0.2737, 0.6149, 0.3284, 0.6363]}, {"w": "over", "b": [0.3332, 0.6149, 0.37, 0.6363]}, {"w": "these", "b": [0.3748, 0.6149, 0.4176, 0.6363]}, {"w": "110", "b": [0.4223, 0.6149, 0.4523, 0.6363]}, {"w": "instances.", "b": [0.457, 0.6149, 0.5386, 0.6363]}]}, {"id": "b_4", "type": "paragraph", "text": "This model’s predictions are represented on the left of Figure 6-5. If you set max_depth=3, you get the predictions represented on the right. Notice how the pre‐ dicted value for each region is always the average target value of the instances in that region. The algorithm splits each region in a way that makes most training instances as close as possible to that predicted value.", "words": [{"w": "This", "b": [0.1429, 0.643, 0.1801, 0.6644]}, {"w": "model’s", "b": [0.1917, 0.643, 0.2543, 0.6644]}, {"w": "predictions", "b": [0.2659, 0.643, 0.3604, 0.6644]}, {"w": "are", "b": [0.372, 0.643, 0.3978, 0.6644]}, {"w": "represented", "b": [0.4094, 0.643, 0.5072, 0.6644]}, {"w": "on", "b": [0.5188, 0.643, 0.5408, 0.6644]}, {"w": "the", "b": [0.5525, 0.643, 0.5788, 0.6644]}, {"w": "left", "b": [0.5904, 0.643, 0.6171, 0.6644]}, {"w": "of", "b": [0.6287, 0.643, 0.6455, 0.6644]}, {"w": "Figure", "b": [0.6571, 0.643, 0.7111, 0.6644]}, {"w": "6-5.", "b": [0.7227, 0.643, 0.7549, 0.6644]}, {"w": "If", "b": [0.7665, 0.643, 0.7798, 0.6644]}, {"w": "you", "b": [0.7914, 0.643, 0.8227, 0.6644]}, {"w": "set", "b": [0.8343, 0.643, 0.8571, 0.6644]}, {"w": "max_depth=3,", "b": [0.1429, 0.663, 0.2565, 0.6844]}, {"w": "you", "b": [0.2631, 0.663, 0.2944, 0.6844]}, {"w": "get", "b": [0.3011, 0.663, 0.326, 0.6844]}, {"w": "the", "b": [0.3327, 0.663, 0.359, 0.6844]}, {"w": "predictions", "b": [0.3657, 0.663, 0.4602, 0.6844]}, {"w": "represented", "b": [0.4669, 0.663, 0.5647, 0.6844]}, {"w": "on", "b": [0.5714, 0.663, 0.5934, 0.6844]}, {"w": "the", "b": [0.6001, 0.663, 0.6264, 0.6844]}, {"w": "right.", "b": [0.6331, 0.663, 0.678, 0.6844]}, {"w": "Notice", "b": [0.6847, 0.663, 0.7398, 0.6844]}, {"w": "how", "b": [0.7465, 0.663, 0.7825, 0.6844]}, {"w": "the", "b": [0.7892, 0.663, 0.8156, 0.6844]}, {"w": "pre‐", "b": [0.8222, 0.663, 0.8572, 0.6844]}, {"w": "dicted", "b": [0.1429, 0.682, 0.1945, 0.7034]}, {"w": "value", "b": [0.2, 0.682, 0.244, 0.7034]}, {"w": "for", "b": [0.2496, 0.682, 0.2741, 0.7034]}, {"w": "each", "b": [0.2797, 0.682, 0.3176, 0.7034]}, {"w": "region", "b": [0.3232, 0.682, 0.3771, 0.7034]}, {"w": "is", "b": [0.3827, 0.682, 0.3959, 0.7034]}, {"w": "always", "b": [0.4015, 0.682, 0.4562, 0.7034]}, {"w": "the", "b": [0.4618, 0.682, 0.4881, 0.7034]}, {"w": "average", "b": [0.4937, 0.682, 0.5564, 0.7034]}, {"w": "target", "b": [0.562, 0.682, 0.6102, 0.7034]}, {"w": "value", "b": [0.6158, 0.682, 0.6597, 0.7034]}, {"w": "of", "b": [0.6653, 0.682, 0.6821, 0.7034]}, {"w": "the", "b": [0.6877, 0.682, 0.714, 0.7034]}, {"w": "instances", "b": [0.7196, 0.682, 0.7964, 0.7034]}, {"w": "in", "b": [0.802, 0.682, 0.819, 0.7034]}, {"w": "that", "b": [0.8246, 0.682, 0.8571, 0.7034]}, {"w": "region.", "b": [0.1429, 0.7011, 0.2015, 0.7225]}, {"w": "The", "b": [0.2073, 0.7011, 0.2401, 0.7225]}, {"w": "algorithm", "b": [0.2459, 0.7011, 0.3286, 0.7225]}, {"w": "splits", "b": [0.3343, 0.7011, 0.3777, 0.7225]}, {"w": "each", "b": [0.3835, 0.7011, 0.4215, 0.7225]}, {"w": "region", "b": [0.4272, 0.7011, 0.4812, 0.7225]}, {"w": "in", "b": [0.4869, 0.7011, 0.5039, 0.7225]}, {"w": "a", "b": [0.5097, 0.7011, 0.5188, 0.7225]}, {"w": "way", "b": [0.5246, 0.7011, 0.5572, 0.7225]}, {"w": "that", "b": [0.563, 0.7011, 0.5956, 0.7225]}, {"w": "makes", "b": [0.6013, 0.7011, 0.6544, 0.7225]}, {"w": "most", "b": [0.6601, 0.7011, 0.7018, 0.7225]}, {"w": "training", "b": [0.7076, 0.7011, 0.7745, 0.7225]}, {"w": "instances", "b": [0.7803, 0.7011, 0.8571, 0.7225]}, {"w": "as", "b": [0.1428, 0.7201, 0.1596, 0.7415]}, {"w": "close", "b": [0.1644, 0.7201, 0.2056, 0.7415]}, {"w": "as", "b": [0.2103, 0.7201, 0.2271, 0.7415]}, {"w": "possible", "b": [0.2318, 0.7201, 0.299, 0.7415]}, {"w": "to", "b": [0.3037, 0.7201, 0.3207, 0.7415]}, {"w": "that", "b": [0.3254, 0.7201, 0.358, 0.7415]}, {"w": "predicted", "b": [0.3627, 0.7201, 0.4418, 0.7415]}, {"w": "value.", "b": [0.4465, 0.7201, 0.4953, 0.7415]}]}, {"id": "b_5", "type": "paragraph", "text": "186 | Chapter 6: Decision Trees", "words": [{"w": "186", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "6:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Decision", "b": [0.2673, 0.9225, 0.3162, 0.9388]}, {"w": "Trees", "b": [0.319, 0.9225, 0.3502, 0.9388]}]}]}, {"page": 213, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 6-5. Predictions of two Decision Tree regression models", "words": [{"w": "Figure", "b": [0.1429, 0.28, 0.1943, 0.3016]}, {"w": "6-5.", "b": [0.1991, 0.28, 0.2308, 0.3016]}, {"w": "Predictions", "b": [0.2356, 0.28, 0.3259, 0.3016]}, {"w": "of", "b": [0.3307, 0.28, 0.3459, 0.3016]}, {"w": "two", "b": [0.3507, 0.28, 0.3808, 0.3016]}, {"w": "Decision", "b": [0.3855, 0.28, 0.4554, 0.3016]}, {"w": "Tree", "b": [0.4602, 0.28, 0.495, 0.3016]}, {"w": "regression", "b": [0.4998, 0.28, 0.5793, 0.3016]}, {"w": "models", "b": [0.5841, 0.28, 0.6408, 0.3016]}]}, {"id": "b_1", "type": "paragraph", "text": "The CART algorithm works mostly the same way as earlier, except that instead of try‐ ing to split the training set in a way that minimizes impurity, it now tries to split the training set in a way that minimizes the MSE. Equation 6-4 shows the cost function that the algorithm tries to minimize.", "words": [{"w": "The", "b": [0.1429, 0.3174, 0.1757, 0.3388]}, {"w": "CART", "b": [0.1806, 0.3174, 0.234, 0.3388]}, {"w": "algorithm", "b": [0.2389, 0.3174, 0.3215, 0.3388]}, {"w": "works", "b": [0.3264, 0.3174, 0.377, 0.3388]}, {"w": "mostly", "b": [0.3819, 0.3174, 0.4384, 0.3388]}, {"w": "the", "b": [0.4433, 0.3174, 0.4697, 0.3388]}, {"w": "same", "b": [0.4746, 0.3174, 0.5173, 0.3388]}, {"w": "way", "b": [0.5222, 0.3174, 0.5548, 0.3388]}, {"w": "as", "b": [0.5597, 0.3174, 0.5765, 0.3388]}, {"w": "earlier,", "b": [0.5814, 0.3174, 0.638, 0.3388]}, {"w": "except", "b": [0.6429, 0.3174, 0.6965, 0.3388]}, {"w": "that", "b": [0.7014, 0.3174, 0.734, 0.3388]}, {"w": "instead", "b": [0.7389, 0.3174, 0.7989, 0.3388]}, {"w": "of", "b": [0.8038, 0.3174, 0.8206, 0.3388]}, {"w": "try‐", "b": [0.8255, 0.3174, 0.8571, 0.3388]}, {"w": "ing", "b": [0.1429, 0.3364, 0.1696, 0.3578]}, {"w": "to", "b": [0.1755, 0.3364, 0.1924, 0.3578]}, {"w": "split", "b": [0.1983, 0.3364, 0.2341, 0.3578]}, {"w": "the", "b": [0.2399, 0.3364, 0.2663, 0.3578]}, {"w": "training", "b": [0.2721, 0.3364, 0.3391, 0.3578]}, {"w": "set", "b": [0.3449, 0.3364, 0.3678, 0.3578]}, {"w": "in", "b": [0.3737, 0.3364, 0.3906, 0.3578]}, {"w": "a", "b": [0.3965, 0.3364, 0.4056, 0.3578]}, {"w": "way", "b": [0.4115, 0.3364, 0.4441, 0.3578]}, {"w": "that", "b": [0.45, 0.3364, 0.4826, 0.3578]}, {"w": "minimizes", "b": [0.4884, 0.3364, 0.5759, 0.3578]}, {"w": "impurity,", "b": [0.5818, 0.3364, 0.6585, 0.3578]}, {"w": "it", "b": [0.6644, 0.3364, 0.6763, 0.3578]}, {"w": "now", "b": [0.6822, 0.3364, 0.7184, 0.3578]}, {"w": "tries", "b": [0.7243, 0.3364, 0.7605, 0.3578]}, {"w": "to", "b": [0.7663, 0.3364, 0.7833, 0.3578]}, {"w": "split", "b": [0.7892, 0.3364, 0.825, 0.3578]}, {"w": "the", "b": [0.8308, 0.3364, 0.8572, 0.3578]}, {"w": "training", "b": [0.1429, 0.3555, 0.2098, 0.3769]}, {"w": "set", "b": [0.2161, 0.3555, 0.2389, 0.3769]}, {"w": "in", "b": [0.2452, 0.3555, 0.2622, 0.3769]}, {"w": "a", "b": [0.2685, 0.3555, 0.2777, 0.3769]}, {"w": "way", "b": [0.284, 0.3555, 0.3166, 0.3769]}, {"w": "that", "b": [0.3229, 0.3555, 0.3555, 0.3769]}, {"w": "minimizes", "b": [0.3617, 0.3555, 0.4493, 0.3769]}, {"w": "the", "b": [0.4556, 0.3555, 0.4819, 0.3769]}, {"w": "MSE.", "b": [0.4882, 0.3555, 0.5332, 0.3769]}, {"w": "Equation", "b": [0.5395, 0.3555, 0.6158, 0.3769]}, {"w": "6-4", "b": [0.6221, 0.3555, 0.6495, 0.3769]}, {"w": "shows", "b": [0.6558, 0.3555, 0.7071, 0.3769]}, {"w": "the", "b": [0.7134, 0.3555, 0.7397, 0.3769]}, {"w": "cost", "b": [0.746, 0.3555, 0.7795, 0.3769]}, {"w": "function", "b": [0.7858, 0.3555, 0.8571, 0.3769]}, {"w": "that", "b": [0.1429, 0.3745, 0.1754, 0.3959]}, {"w": "the", "b": [0.1802, 0.3745, 0.2065, 0.3959]}, {"w": "algorithm", "b": [0.2112, 0.3745, 0.2939, 0.3959]}, {"w": "tries", "b": [0.2986, 0.3745, 0.3348, 0.3959]}, {"w": "to", "b": [0.3395, 0.3745, 0.3565, 0.3959]}, {"w": "minimize.", "b": [0.3612, 0.3745, 0.4458, 0.3959]}]}, {"id": "b_2", "type": "equation", "text": "Equation 6-4. CART cost function for regression", "words": [{"w": "Equation", "b": [0.1726, 0.4141, 0.2473, 0.4357]}, {"w": "6-4.", "b": [0.2521, 0.4141, 0.2838, 0.4357]}, {"w": "CART", "b": [0.2886, 0.4141, 0.3397, 0.4357]}, {"w": "cost", "b": [0.3445, 0.4141, 0.3751, 0.4357]}, {"w": "function", "b": [0.3799, 0.4141, 0.448, 0.4357]}, {"w": "for", "b": [0.4528, 0.4141, 0.4754, 0.4357]}, {"w": "regression", "b": [0.4802, 0.4141, 0.5598, 0.4357]}]}, {"id": "b_3", "type": "equation", "text": "J k, tk =", "words": [{"w": "J", "b": [0.1731, 0.4736, 0.1795, 0.4942]}, {"w": "k,", "b": [0.1874, 0.4736, 0.2012, 0.4942]}, {"w": "tk", "b": [0.2045, 0.4736, 0.2186, 0.4984]}, {"w": "=", "b": [0.2309, 0.4738, 0.2425, 0.4942]}]}, {"id": "b_4", "type": "paragraph", "text": "mleft", "words": [{"w": "mleft", "b": [0.2502, 0.4602, 0.2861, 0.4851]}]}, {"id": "b_5", "type": "equation", "text": "m MSEleft +", "words": [{"w": "m", "b": [0.2603, 0.4824, 0.2759, 0.503]}, {"w": "MSEleft", "b": [0.2883, 0.4738, 0.3469, 0.4984]}, {"w": "+", "b": [0.3514, 0.4738, 0.3629, 0.4942]}]}, {"id": "b_6", "type": "paragraph", "text": "mright", "words": [{"w": "mright", "b": [0.3695, 0.4602, 0.416, 0.4851]}]}, {"id": "b_7", "type": "paragraph", "text": "m MSEright where", "words": [{"w": "m", "b": [0.3849, 0.4824, 0.4005, 0.503]}, {"w": "MSEright", "b": [0.4182, 0.4738, 0.4874, 0.4984]}, {"w": "where", "b": [0.5073, 0.4738, 0.5557, 0.4942]}]}, {"id": "b_8", "type": "equation", "text": "MSEnode = ∑ i ∈node", "words": [{"w": "MSEnode", "b": [0.5705, 0.4499, 0.6408, 0.4745]}, {"w": "=", "b": [0.6463, 0.4499, 0.6578, 0.4703]}, {"w": "∑", "b": [0.6847, 0.4451, 0.6997, 0.4739]}, {"w": "i", "b": [0.6644, 0.4653, 0.6687, 0.4817]}, {"w": "∈node", "b": [0.6731, 0.4654, 0.72, 0.4817]}]}, {"id": "b_9", "type": "paragraph", "text": "ynode −y i 2", "words": [{"w": "ynode", "b": [0.7302, 0.4497, 0.7722, 0.4745]}, {"w": "−y", "b": [0.7766, 0.4497, 0.8024, 0.4703]}, {"w": "i", "b": [0.808, 0.446, 0.8123, 0.4624]}, {"w": "2", "b": [0.8246, 0.4428, 0.8323, 0.4591]}]}, {"id": "b_10", "type": "equation", "text": "ynode = 1 mnode ∑ i ∈node", "words": [{"w": "ynode", "b": [0.5716, 0.492, 0.6136, 0.5168]}, {"w": "=", "b": [0.6191, 0.4922, 0.6306, 0.5125]}, {"w": "1", "b": [0.6574, 0.4833, 0.6669, 0.5037]}, {"w": "mnode", "b": [0.6384, 0.5008, 0.6859, 0.5256]}, {"w": "∑", "b": [0.7095, 0.4874, 0.7245, 0.5162]}, {"w": "i", "b": [0.6892, 0.5075, 0.6935, 0.524]}, {"w": "∈node", "b": [0.6979, 0.5077, 0.7448, 0.524]}]}, {"id": "b_11", "type": "paragraph", "text": "y i", "words": [{"w": "y", "b": [0.7482, 0.492, 0.7569, 0.5125]}, {"w": "i", "b": [0.7624, 0.4883, 0.7668, 0.5047]}]}, {"id": "b_12", "type": "paragraph", "text": "Just like for classification tasks, Decision Trees are prone to overfitting when dealing with regression tasks. Without any regularization (i.e., using the default hyperpara‐ meters), you get the predictions on the left of Figure 6-6. It is obviously overfitting the training set very badly. Just setting min_samples_leaf=10 results in a much more reasonable model, represented on the right of Figure 6-6.", "words": [{"w": "Just", "b": [0.1429, 0.5447, 0.1741, 0.5661]}, {"w": "like", "b": [0.18, 0.5447, 0.21, 0.5661]}, {"w": "for", "b": [0.2159, 0.5447, 0.2404, 0.5661]}, {"w": "classification", "b": [0.2462, 0.5447, 0.3536, 0.5661]}, {"w": "tasks,", "b": [0.3595, 0.5447, 0.4053, 0.5661]}, {"w": "Decision", "b": [0.4112, 0.5447, 0.485, 0.5661]}, {"w": "Trees", "b": [0.4909, 0.5447, 0.5351, 0.5661]}, {"w": "are", "b": [0.5409, 0.5447, 0.5667, 0.5661]}, {"w": "prone", "b": [0.5725, 0.5447, 0.622, 0.5661]}, {"w": "to", "b": [0.6279, 0.5447, 0.6449, 0.5661]}, {"w": "overfitting", "b": [0.6507, 0.5447, 0.7388, 0.5661]}, {"w": "when", "b": [0.7446, 0.5447, 0.7903, 0.5661]}, {"w": "dealing", "b": [0.7961, 0.5447, 0.8571, 0.5661]}, {"w": "with", "b": [0.1429, 0.5637, 0.1802, 0.5851]}, {"w": "regression", "b": [0.1873, 0.5637, 0.2731, 0.5851]}, {"w": "tasks.", "b": [0.2803, 0.5637, 0.3262, 0.5851]}, {"w": "Without", "b": [0.3333, 0.5637, 0.4038, 0.5851]}, {"w": "any", "b": [0.4109, 0.5637, 0.4405, 0.5851]}, {"w": "regularization", "b": [0.4477, 0.5637, 0.5643, 0.5851]}, {"w": "(i.e.,", "b": [0.5714, 0.5637, 0.6073, 0.5851]}, {"w": "using", "b": [0.6144, 0.5637, 0.6599, 0.5851]}, {"w": "the", "b": [0.667, 0.5637, 0.6933, 0.5851]}, {"w": "default", "b": [0.7005, 0.5637, 0.7579, 0.5851]}, {"w": "hyperpara‐", "b": [0.7651, 0.5637, 0.8571, 0.5851]}, {"w": "meters),", "b": [0.1429, 0.5828, 0.2113, 0.6042]}, {"w": "you", "b": [0.2182, 0.5828, 0.2495, 0.6042]}, {"w": "get", "b": [0.2563, 0.5828, 0.2813, 0.6042]}, {"w": "the", "b": [0.2882, 0.5828, 0.3145, 0.6042]}, {"w": "predictions", "b": [0.3214, 0.5828, 0.4159, 0.6042]}, {"w": "on", "b": [0.4228, 0.5828, 0.4448, 0.6042]}, {"w": "the", "b": [0.4517, 0.5828, 0.478, 0.6042]}, {"w": "left", "b": [0.4849, 0.5828, 0.5115, 0.6042]}, {"w": "of", "b": [0.5184, 0.5828, 0.5352, 0.6042]}, {"w": "Figure", "b": [0.5421, 0.5828, 0.5961, 0.6042]}, {"w": "6-6.", "b": [0.6029, 0.5828, 0.6351, 0.6042]}, {"w": "It", "b": [0.642, 0.5828, 0.6546, 0.6042]}, {"w": "is", "b": [0.6615, 0.5828, 0.6747, 0.6042]}, {"w": "obviously", "b": [0.6816, 0.5828, 0.7622, 0.6042]}, {"w": "overfitting", "b": [0.7691, 0.5828, 0.8572, 0.6042]}, {"w": "the", "b": [0.1429, 0.6027, 0.1692, 0.6241]}, {"w": "training", "b": [0.1746, 0.6027, 0.2416, 0.6241]}, {"w": "set", "b": [0.247, 0.6027, 0.2698, 0.6241]}, {"w": "very", "b": [0.2753, 0.6027, 0.3117, 0.6241]}, {"w": "badly.", "b": [0.3171, 0.6027, 0.3659, 0.6241]}, {"w": "Just", "b": [0.3713, 0.6027, 0.4026, 0.6241]}, {"w": "setting", "b": [0.408, 0.6027, 0.4639, 0.6241]}, {"w": "min_samples_leaf=10", "b": [0.4694, 0.6059, 0.6574, 0.621]}, {"w": "results", "b": [0.6628, 0.6027, 0.7174, 0.6241]}, {"w": "in", "b": [0.7228, 0.6027, 0.7398, 0.6241]}, {"w": "a", "b": [0.7452, 0.6027, 0.7544, 0.6241]}, {"w": "much", "b": [0.7598, 0.6027, 0.8074, 0.6241]}, {"w": "more", "b": [0.8129, 0.6027, 0.8571, 0.6241]}, {"w": "reasonable", "b": [0.1429, 0.6218, 0.2321, 0.6432]}, {"w": "model,", "b": [0.2368, 0.6218, 0.2944, 0.6432]}, {"w": "represented", "b": [0.2991, 0.6218, 0.3969, 0.6432]}, {"w": "on", "b": [0.4016, 0.6218, 0.4237, 0.6432]}, {"w": "the", "b": [0.4284, 0.6218, 0.4547, 0.6432]}, {"w": "right", "b": [0.4595, 0.6218, 0.4996, 0.6432]}, {"w": "of", "b": [0.5043, 0.6218, 0.5211, 0.6432]}, {"w": "Figure", "b": [0.5259, 0.6218, 0.5799, 0.6432]}, {"w": "6-6.", "b": [0.5846, 0.6218, 0.6168, 0.6432]}]}, {"id": "b_13", "type": "equation", "text": "Figure 6-6. Regularizing a Decision Tree regressor", "words": [{"w": "Figure", "b": [0.1429, 0.8508, 0.1943, 0.8724]}, {"w": "6-6.", "b": [0.1991, 0.8508, 0.2308, 0.8724]}, {"w": "Regularizing", "b": [0.2356, 0.8508, 0.3382, 0.8724]}, {"w": "a", "b": [0.3429, 0.8508, 0.3531, 0.8724]}, {"w": "Decision", "b": [0.3579, 0.8508, 0.4278, 0.8724]}, {"w": "Tree", "b": [0.4326, 0.8508, 0.4674, 0.8724]}, {"w": "regressor", "b": [0.4721, 0.8508, 0.5429, 0.8724]}]}, {"id": "b_14", "type": "paragraph", "text": "Regression | 187", "words": [{"w": "Regression", "b": [0.7316, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "187", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 214, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 It randomly selects the set of features to evaluate at each node.", "words": [{"w": "6", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "It", "b": [0.1587, 0.8749, 0.1684, 0.8912]}, {"w": "randomly", "b": [0.172, 0.8749, 0.2343, 0.8912]}, {"w": "selects", "b": [0.2379, 0.8749, 0.2786, 0.8912]}, {"w": "the", "b": [0.2822, 0.8749, 0.3023, 0.8912]}, {"w": "set", "b": [0.3059, 0.8749, 0.3233, 0.8912]}, {"w": "of", "b": [0.3269, 0.8749, 0.3397, 0.8912]}, {"w": "features", "b": [0.3433, 0.8749, 0.3931, 0.8912]}, {"w": "to", "b": [0.3967, 0.8749, 0.4097, 0.8912]}, {"w": "evaluate", "b": [0.4133, 0.8749, 0.465, 0.8912]}, {"w": "at", "b": [0.4686, 0.8749, 0.4801, 0.8912]}, {"w": "each", "b": [0.4837, 0.8749, 0.5127, 0.8912]}, {"w": "node.", "b": [0.5163, 0.8749, 0.5518, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Instability", "words": [{"w": "Instability", "b": [0.1429, 0.0753, 0.2687, 0.1095]}]}, {"id": "b_2", "type": "paragraph", "text": "Hopefully by now you are convinced that Decision Trees have a lot going for them: they are simple to understand and interpret, easy to use, versatile, and powerful. However they do have a few limitations. First, as you may have noticed, Decision Trees love orthogonal decision boundaries (all splits are perpendicular to an axis), which makes them sensitive to training set rotation. For example, Figure 6-7 shows a simple linearly separable dataset: on the left, a Decision Tree can split it easily, while on the right, after the dataset is rotated by 45°, the decision boundary looks unneces‐ sarily convoluted. Although both Decision Trees fit the training set perfectly, it is very likely that the model on the right will not generalize well. One way to limit this prob‐ lem is to use PCA (see Chapter 8), which often results in a better orientation of the training data.", "words": [{"w": "Hopefully", "b": [0.1429, 0.1164, 0.226, 0.1378]}, {"w": "by", "b": [0.2326, 0.1164, 0.2527, 0.1378]}, {"w": "now", "b": [0.2593, 0.1164, 0.2956, 0.1378]}, {"w": "you", "b": [0.3022, 0.1164, 0.3334, 0.1378]}, {"w": "are", "b": [0.34, 0.1164, 0.3657, 0.1378]}, {"w": "convinced", "b": [0.3723, 0.1164, 0.4579, 0.1378]}, {"w": "that", "b": [0.4645, 0.1164, 0.4971, 0.1378]}, {"w": "Decision", "b": [0.5036, 0.1164, 0.5774, 0.1378]}, {"w": "Trees", "b": [0.584, 0.1164, 0.6282, 0.1378]}, {"w": "have", "b": [0.6348, 0.1164, 0.6732, 0.1378]}, {"w": "a", "b": [0.6797, 0.1164, 0.6889, 0.1378]}, {"w": "lot", "b": [0.6954, 0.1164, 0.7177, 0.1378]}, {"w": "going", "b": [0.7242, 0.1164, 0.7714, 0.1378]}, {"w": "for", "b": [0.7779, 0.1164, 0.8024, 0.1378]}, {"w": "them:", "b": [0.809, 0.1164, 0.8571, 0.1378]}, {"w": "they", "b": [0.1429, 0.1355, 0.1788, 0.1569]}, {"w": "are", "b": [0.1876, 0.1355, 0.2133, 0.1569]}, {"w": "simple", "b": [0.2222, 0.1355, 0.2771, 0.1569]}, {"w": "to", "b": [0.286, 0.1355, 0.303, 0.1569]}, {"w": "understand", "b": [0.3119, 0.1355, 0.4074, 0.1569]}, {"w": "and", "b": [0.4163, 0.1355, 0.4478, 0.1569]}, {"w": "interpret,", "b": [0.4567, 0.1355, 0.5348, 0.1569]}, {"w": "easy", "b": [0.5437, 0.1355, 0.5789, 0.1569]}, {"w": "to", "b": [0.5878, 0.1355, 0.6047, 0.1569]}, {"w": "use,", "b": [0.6136, 0.1355, 0.6459, 0.1569]}, {"w": "versatile,", "b": [0.6548, 0.1355, 0.7282, 0.1569]}, {"w": "and", "b": [0.7371, 0.1355, 0.7686, 0.1569]}, {"w": "powerful.", "b": [0.7775, 0.1355, 0.8571, 0.1569]}, {"w": "However", "b": [0.1429, 0.1545, 0.2183, 0.1759]}, {"w": "they", "b": [0.2262, 0.1545, 0.2621, 0.1759]}, {"w": "do", "b": [0.2701, 0.1545, 0.2917, 0.1759]}, {"w": "have", "b": [0.2997, 0.1545, 0.3381, 0.1759]}, {"w": "a", "b": [0.346, 0.1545, 0.3552, 0.1759]}, {"w": "few", "b": [0.3631, 0.1545, 0.3924, 0.1759]}, {"w": "limitations.", "b": [0.4004, 0.1545, 0.4953, 0.1759]}, {"w": "First,", "b": [0.5033, 0.1545, 0.5464, 0.1759]}, {"w": "as", "b": [0.5543, 0.1545, 0.5711, 0.1759]}, {"w": "you", "b": [0.5791, 0.1545, 0.6103, 0.1759]}, {"w": "may", "b": [0.6183, 0.1545, 0.6537, 0.1759]}, {"w": "have", "b": [0.6616, 0.1545, 0.7, 0.1759]}, {"w": "noticed,", "b": [0.708, 0.1545, 0.7754, 0.1759]}, {"w": "Decision", "b": [0.7833, 0.1545, 0.8571, 0.1759]}, {"w": "Trees", "b": [0.1429, 0.1736, 0.1871, 0.195]}, {"w": "love", "b": [0.1948, 0.1736, 0.2292, 0.195]}, {"w": "orthogonal", "b": [0.2369, 0.1736, 0.3296, 0.195]}, {"w": "decision", "b": [0.3373, 0.1736, 0.4068, 0.195]}, {"w": "boundaries", "b": [0.4145, 0.1736, 0.5081, 0.195]}, {"w": "(all", "b": [0.5158, 0.1736, 0.5427, 0.195]}, {"w": "splits", "b": [0.5505, 0.1736, 0.5939, 0.195]}, {"w": "are", "b": [0.6016, 0.1736, 0.6273, 0.195]}, {"w": "perpendicular", "b": [0.635, 0.1736, 0.7523, 0.195]}, {"w": "to", "b": [0.76, 0.1736, 0.777, 0.195]}, {"w": "an", "b": [0.7847, 0.1736, 0.8053, 0.195]}, {"w": "axis),", "b": [0.813, 0.1736, 0.8572, 0.195]}, {"w": "which", "b": [0.1429, 0.1926, 0.1938, 0.214]}, {"w": "makes", "b": [0.1993, 0.1926, 0.2523, 0.214]}, {"w": "them", "b": [0.2578, 0.1926, 0.3012, 0.214]}, {"w": "sensitive", "b": [0.3067, 0.1926, 0.3782, 0.214]}, {"w": "to", "b": [0.3837, 0.1926, 0.4007, 0.214]}, {"w": "training", "b": [0.4062, 0.1926, 0.4731, 0.214]}, {"w": "set", "b": [0.4786, 0.1926, 0.5014, 0.214]}, {"w": "rotation.", "b": [0.5069, 0.1926, 0.5791, 0.214]}, {"w": "For", "b": [0.5846, 0.1926, 0.6136, 0.214]}, {"w": "example,", "b": [0.619, 0.1926, 0.6933, 0.214]}, {"w": "Figure", "b": [0.6988, 0.1926, 0.7528, 0.214]}, {"w": "6-7", "b": [0.7583, 0.1926, 0.7857, 0.214]}, {"w": "shows", "b": [0.7912, 0.1926, 0.8425, 0.214]}, {"w": "a", "b": [0.848, 0.1926, 0.8571, 0.214]}, {"w": "simple", "b": [0.1429, 0.2117, 0.1978, 0.2331]}, {"w": "linearly", "b": [0.2038, 0.2117, 0.2667, 0.2331]}, {"w": "separable", "b": [0.2727, 0.2117, 0.3509, 0.2331]}, {"w": "dataset:", "b": [0.3569, 0.2117, 0.4198, 0.2331]}, {"w": "on", "b": [0.4258, 0.2117, 0.4479, 0.2331]}, {"w": "the", "b": [0.4539, 0.2117, 0.4802, 0.2331]}, {"w": "left,", "b": [0.4863, 0.2117, 0.5177, 0.2331]}, {"w": "a", "b": [0.5238, 0.2117, 0.5329, 0.2331]}, {"w": "Decision", "b": [0.539, 0.2117, 0.6128, 0.2331]}, {"w": "Tree", "b": [0.6188, 0.2117, 0.6554, 0.2331]}, {"w": "can", "b": [0.6615, 0.2117, 0.6908, 0.2331]}, {"w": "split", "b": [0.6969, 0.2117, 0.7326, 0.2331]}, {"w": "it", "b": [0.7387, 0.2117, 0.7506, 0.2331]}, {"w": "easily,", "b": [0.7567, 0.2117, 0.806, 0.2331]}, {"w": "while", "b": [0.812, 0.2117, 0.8571, 0.2331]}, {"w": "on", "b": [0.1428, 0.2307, 0.1649, 0.2521]}, {"w": "the", "b": [0.1703, 0.2307, 0.1966, 0.2521]}, {"w": "right,", "b": [0.202, 0.2307, 0.2469, 0.2521]}, {"w": "after", "b": [0.2524, 0.2307, 0.2906, 0.2521]}, {"w": "the", "b": [0.296, 0.2307, 0.3224, 0.2521]}, {"w": "dataset", "b": [0.3278, 0.2307, 0.3859, 0.2521]}, {"w": "is", "b": [0.3913, 0.2307, 0.4046, 0.2521]}, {"w": "rotated", "b": [0.41, 0.2307, 0.4696, 0.2521]}, {"w": "by", "b": [0.4751, 0.2307, 0.4952, 0.2521]}, {"w": "45°,", "b": [0.5006, 0.2307, 0.5325, 0.2521]}, {"w": "the", "b": [0.538, 0.2307, 0.5643, 0.2521]}, {"w": "decision", "b": [0.5697, 0.2307, 0.6392, 0.2521]}, {"w": "boundary", "b": [0.6446, 0.2307, 0.7263, 0.2521]}, {"w": "looks", "b": [0.7318, 0.2307, 0.7763, 0.2521]}, {"w": "unneces‐", "b": [0.7817, 0.2307, 0.8571, 0.2521]}, {"w": "sarily", "b": [0.1429, 0.2498, 0.1878, 0.2712]}, {"w": "convoluted.", "b": [0.1927, 0.2498, 0.2906, 0.2712]}, {"w": "Although", "b": [0.2955, 0.2498, 0.3752, 0.2712]}, {"w": "both", "b": [0.3801, 0.2498, 0.4188, 0.2712]}, {"w": "Decision", "b": [0.4236, 0.2498, 0.4975, 0.2712]}, {"w": "Trees", "b": [0.5023, 0.2498, 0.5465, 0.2712]}, {"w": "fit", "b": [0.5514, 0.2498, 0.5695, 0.2712]}, {"w": "the", "b": [0.5744, 0.2498, 0.6007, 0.2712]}, {"w": "training", "b": [0.6056, 0.2498, 0.6726, 0.2712]}, {"w": "set", "b": [0.6775, 0.2498, 0.7003, 0.2712]}, {"w": "perfectly,", "b": [0.7052, 0.2498, 0.7809, 0.2712]}, {"w": "it", "b": [0.7858, 0.2498, 0.7978, 0.2712]}, {"w": "is", "b": [0.8026, 0.2498, 0.8159, 0.2712]}, {"w": "very", "b": [0.8208, 0.2498, 0.8571, 0.2712]}, {"w": "likely", "b": [0.1429, 0.2688, 0.1877, 0.2902]}, {"w": "that", "b": [0.193, 0.2688, 0.2256, 0.2902]}, {"w": "the", "b": [0.2309, 0.2688, 0.2572, 0.2902]}, {"w": "model", "b": [0.2625, 0.2688, 0.3153, 0.2902]}, {"w": "on", "b": [0.3206, 0.2688, 0.3426, 0.2902]}, {"w": "the", "b": [0.3479, 0.2688, 0.3742, 0.2902]}, {"w": "right", "b": [0.3795, 0.2688, 0.4197, 0.2902]}, {"w": "will", "b": [0.425, 0.2688, 0.4554, 0.2902]}, {"w": "not", "b": [0.4606, 0.2688, 0.489, 0.2902]}, {"w": "generalize", "b": [0.4943, 0.2688, 0.5785, 0.2902]}, {"w": "well.", "b": [0.5838, 0.2688, 0.6222, 0.2902]}, {"w": "One", "b": [0.6275, 0.2688, 0.6633, 0.2902]}, {"w": "way", "b": [0.6686, 0.2688, 0.7012, 0.2902]}, {"w": "to", "b": [0.7065, 0.2688, 0.7235, 0.2902]}, {"w": "limit", "b": [0.7287, 0.2688, 0.7686, 0.2902]}, {"w": "this", "b": [0.7739, 0.2688, 0.8046, 0.2902]}, {"w": "prob‐", "b": [0.8099, 0.2688, 0.8571, 0.2902]}, {"w": "lem", "b": [0.1429, 0.2879, 0.174, 0.3093]}, {"w": "is", "b": [0.1805, 0.2879, 0.1937, 0.3093]}, {"w": "to", "b": [0.2002, 0.2879, 0.2172, 0.3093]}, {"w": "use", "b": [0.2237, 0.2879, 0.2512, 0.3093]}, {"w": "PCA", "b": [0.2577, 0.2879, 0.2977, 0.3093]}, {"w": "(see", "b": [0.3041, 0.2879, 0.3367, 0.3093]}, {"w": "Chapter", "b": [0.3432, 0.2879, 0.4108, 0.3093]}, {"w": "8),", "b": [0.4172, 0.2879, 0.4392, 0.3093]}, {"w": "which", "b": [0.4457, 0.2879, 0.4966, 0.3093]}, {"w": "often", "b": [0.503, 0.2879, 0.5464, 0.3093]}, {"w": "results", "b": [0.5529, 0.2879, 0.6075, 0.3093]}, {"w": "in", "b": [0.6139, 0.2879, 0.6309, 0.3093]}, {"w": "a", "b": [0.6374, 0.2879, 0.6465, 0.3093]}, {"w": "better", "b": [0.653, 0.2879, 0.7017, 0.3093]}, {"w": "orientation", "b": [0.7082, 0.2879, 0.8011, 0.3093]}, {"w": "of", "b": [0.8075, 0.2879, 0.8243, 0.3093]}, {"w": "the", "b": [0.8308, 0.2879, 0.8571, 0.3093]}, {"w": "training", "b": [0.1429, 0.3069, 0.2098, 0.3283]}, {"w": "data.", "b": [0.2145, 0.3069, 0.2545, 0.3283]}]}, {"id": "b_3", "type": "equation", "text": "Figure 6-7. Sensitivity to training set rotation", "words": [{"w": "Figure", "b": [0.1429, 0.5344, 0.1943, 0.5561]}, {"w": "6-7.", "b": [0.1991, 0.5344, 0.2308, 0.5561]}, {"w": "Sensitivity", "b": [0.2356, 0.5344, 0.3192, 0.5561]}, {"w": "to", "b": [0.324, 0.5344, 0.34, 0.5561]}, {"w": "training", "b": [0.3448, 0.5344, 0.4092, 0.5561]}, {"w": "set", "b": [0.414, 0.5344, 0.4356, 0.5561]}, {"w": "rotation", "b": [0.4404, 0.5344, 0.5056, 0.5561]}]}, {"id": "b_4", "type": "paragraph", "text": "More generally, the main issue with Decision Trees is that they are very sensitive to small variations in the training data. For example, if you just remove the widest Iris- Versicolor from the iris training set (the one with petals 4.8 cm long and 1.8 cm wide) and train a new Decision Tree, you may get the model represented in Figure 6-8. As you can see, it looks very different from the previous Decision Tree (Figure 6-2). Actually, since the training algorithm used by Scikit-Learn is stochastic6 you may get very different models even on the same training data (unless you set the random_state hyperparameter).", "words": [{"w": "More", "b": [0.1429, 0.5718, 0.1881, 0.5933]}, {"w": "generally,", "b": [0.1947, 0.5718, 0.2737, 0.5933]}, {"w": "the", "b": [0.2803, 0.5718, 0.3066, 0.5933]}, {"w": "main", "b": [0.3132, 0.5718, 0.3564, 0.5933]}, {"w": "issue", "b": [0.3629, 0.5718, 0.4037, 0.5933]}, {"w": "with", "b": [0.4103, 0.5718, 0.4476, 0.5933]}, {"w": "Decision", "b": [0.4542, 0.5718, 0.528, 0.5933]}, {"w": "Trees", "b": [0.5346, 0.5718, 0.5788, 0.5933]}, {"w": "is", "b": [0.5854, 0.5718, 0.5986, 0.5933]}, {"w": "that", "b": [0.6052, 0.5718, 0.6377, 0.5933]}, {"w": "they", "b": [0.6443, 0.5718, 0.6802, 0.5933]}, {"w": "are", "b": [0.6868, 0.5718, 0.7125, 0.5933]}, {"w": "very", "b": [0.7191, 0.5718, 0.7555, 0.5933]}, {"w": "sensitive", "b": [0.762, 0.5718, 0.8336, 0.5933]}, {"w": "to", "b": [0.8402, 0.5718, 0.8572, 0.5933]}, {"w": "small", "b": [0.1429, 0.5909, 0.1873, 0.6123]}, {"w": "variations", "b": [0.1931, 0.5909, 0.2756, 0.6123]}, {"w": "in", "b": [0.2815, 0.5909, 0.2984, 0.6123]}, {"w": "the", "b": [0.3043, 0.5909, 0.3306, 0.6123]}, {"w": "training", "b": [0.3365, 0.5909, 0.4035, 0.6123]}, {"w": "data.", "b": [0.4093, 0.5909, 0.4493, 0.6123]}, {"w": "For", "b": [0.4552, 0.5909, 0.4842, 0.6123]}, {"w": "example,", "b": [0.4901, 0.5909, 0.5643, 0.6123]}, {"w": "if", "b": [0.5702, 0.5909, 0.582, 0.6123]}, {"w": "you", "b": [0.5878, 0.5909, 0.6191, 0.6123]}, {"w": "just", "b": [0.625, 0.5909, 0.6554, 0.6123]}, {"w": "remove", "b": [0.6612, 0.5909, 0.724, 0.6123]}, {"w": "the", "b": [0.7299, 0.5909, 0.7562, 0.6123]}, {"w": "widest", "b": [0.7621, 0.5909, 0.8158, 0.6123]}, {"w": "Iris-", "b": [0.8217, 0.5909, 0.8571, 0.6123]}, {"w": "Versicolor", "b": [0.1429, 0.6099, 0.2284, 0.6313]}, {"w": "from", "b": [0.2332, 0.6099, 0.2748, 0.6313]}, {"w": "the", "b": [0.2797, 0.6099, 0.306, 0.6313]}, {"w": "iris", "b": [0.3109, 0.6099, 0.3374, 0.6313]}, {"w": "training", "b": [0.3423, 0.6099, 0.4092, 0.6313]}, {"w": "set", "b": [0.4141, 0.6099, 0.4369, 0.6313]}, {"w": "(the", "b": [0.4418, 0.6099, 0.4753, 0.6313]}, {"w": "one", "b": [0.4802, 0.6099, 0.5111, 0.6313]}, {"w": "with", "b": [0.5159, 0.6099, 0.5533, 0.6313]}, {"w": "petals", "b": [0.5581, 0.6099, 0.6063, 0.6313]}, {"w": "4.8", "b": [0.6112, 0.6099, 0.6359, 0.6313]}, {"w": "cm", "b": [0.6408, 0.6099, 0.6667, 0.6313]}, {"w": "long", "b": [0.6716, 0.6099, 0.7086, 0.6313]}, {"w": "and", "b": [0.7135, 0.6099, 0.745, 0.6313]}, {"w": "1.8", "b": [0.7499, 0.6099, 0.7746, 0.6313]}, {"w": "cm", "b": [0.7795, 0.6099, 0.8054, 0.6313]}, {"w": "wide)", "b": [0.8102, 0.6099, 0.8571, 0.6313]}, {"w": "and", "b": [0.1428, 0.629, 0.1744, 0.6504]}, {"w": "train", "b": [0.1804, 0.629, 0.2206, 0.6504]}, {"w": "a", "b": [0.2266, 0.629, 0.2357, 0.6504]}, {"w": "new", "b": [0.2417, 0.629, 0.2763, 0.6504]}, {"w": "Decision", "b": [0.2823, 0.629, 0.3561, 0.6504]}, {"w": "Tree,", "b": [0.3621, 0.629, 0.4034, 0.6504]}, {"w": "you", "b": [0.4094, 0.629, 0.4406, 0.6504]}, {"w": "may", "b": [0.4466, 0.629, 0.482, 0.6504]}, {"w": "get", "b": [0.488, 0.629, 0.513, 0.6504]}, {"w": "the", "b": [0.519, 0.629, 0.5453, 0.6504]}, {"w": "model", "b": [0.5513, 0.629, 0.6041, 0.6504]}, {"w": "represented", "b": [0.6101, 0.629, 0.7079, 0.6504]}, {"w": "in", "b": [0.7139, 0.629, 0.7309, 0.6504]}, {"w": "Figure", "b": [0.7369, 0.629, 0.7909, 0.6504]}, {"w": "6-8.", "b": [0.7969, 0.629, 0.8291, 0.6504]}, {"w": "As", "b": [0.8351, 0.629, 0.8571, 0.6504]}, {"w": "you", "b": [0.1429, 0.648, 0.1741, 0.6694]}, {"w": "can", "b": [0.1824, 0.648, 0.2118, 0.6694]}, {"w": "see,", "b": [0.2201, 0.648, 0.2502, 0.6694]}, {"w": "it", "b": [0.2585, 0.648, 0.2705, 0.6694]}, {"w": "looks", "b": [0.2788, 0.648, 0.3233, 0.6694]}, {"w": "very", "b": [0.3316, 0.648, 0.368, 0.6694]}, {"w": "different", "b": [0.3763, 0.648, 0.448, 0.6694]}, {"w": "from", "b": [0.4563, 0.648, 0.4979, 0.6694]}, {"w": "the", "b": [0.5062, 0.648, 0.5326, 0.6694]}, {"w": "previous", "b": [0.5409, 0.648, 0.6129, 0.6694]}, {"w": "Decision", "b": [0.6212, 0.648, 0.6951, 0.6694]}, {"w": "Tree", "b": [0.7034, 0.648, 0.7399, 0.6694]}, {"w": "(Figure", "b": [0.7482, 0.648, 0.8095, 0.6694]}, {"w": "6-2).", "b": [0.8178, 0.648, 0.8571, 0.6694]}, {"w": "Actually,", "b": [0.1429, 0.6671, 0.2154, 0.6885]}, {"w": "since", "b": [0.224, 0.6671, 0.2663, 0.6885]}, {"w": "the", "b": [0.275, 0.6671, 0.3013, 0.6885]}, {"w": "training", "b": [0.3099, 0.6671, 0.3768, 0.6885]}, {"w": "algorithm", "b": [0.3855, 0.6671, 0.4681, 0.6885]}, {"w": "used", "b": [0.4767, 0.6671, 0.5153, 0.6885]}, {"w": "by", "b": [0.5239, 0.6671, 0.5441, 0.6885]}, {"w": "Scikit-Learn", "b": [0.5527, 0.6671, 0.655, 0.6885]}, {"w": "is", "b": [0.6636, 0.6671, 0.6768, 0.6885]}, {"w": "stochastic6", "b": [0.6854, 0.6671, 0.7733, 0.6885]}, {"w": "you", "b": [0.7819, 0.6671, 0.8131, 0.6885]}, {"w": "may", "b": [0.8217, 0.6671, 0.8571, 0.6885]}, {"w": "get", "b": [0.1428, 0.6861, 0.1678, 0.7075]}, {"w": "very", "b": [0.1793, 0.6861, 0.2157, 0.7075]}, {"w": "different", "b": [0.2272, 0.6861, 0.2989, 0.7075]}, {"w": "models", "b": [0.3104, 0.6861, 0.3708, 0.7075]}, {"w": "even", "b": [0.3823, 0.6861, 0.421, 0.7075]}, {"w": "on", "b": [0.4325, 0.6861, 0.4545, 0.7075]}, {"w": "the", "b": [0.466, 0.6861, 0.4924, 0.7075]}, {"w": "same", "b": [0.5038, 0.6861, 0.5465, 0.7075]}, {"w": "training", "b": [0.558, 0.6861, 0.625, 0.7075]}, {"w": "data", "b": [0.6364, 0.6861, 0.6717, 0.7075]}, {"w": "(unless", "b": [0.6832, 0.6861, 0.7423, 0.7075]}, {"w": "you", "b": [0.7537, 0.6861, 0.785, 0.7075]}, {"w": "set", "b": [0.7965, 0.6861, 0.8193, 0.7075]}, {"w": "the", "b": [0.8308, 0.6861, 0.8571, 0.7075]}, {"w": "random_state", "b": [0.1429, 0.7093, 0.2616, 0.7243]}, {"w": "hyperparameter).", "b": [0.2663, 0.7061, 0.4118, 0.7275]}]}, {"id": "b_5", "type": "paragraph", "text": "188 | Chapter 6: Decision Trees", "words": [{"w": "188", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "6:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Decision", "b": [0.2673, 0.9225, 0.3162, 0.9388]}, {"w": "Trees", "b": [0.319, 0.9225, 0.3502, 0.9388]}]}]}, {"page": 215, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 6-8. Sensitivity to training set details", "words": [{"w": "Figure", "b": [0.1429, 0.3516, 0.1943, 0.3732]}, {"w": "6-8.", "b": [0.1991, 0.3516, 0.2308, 0.3732]}, {"w": "Sensitivity", "b": [0.2356, 0.3516, 0.3192, 0.3732]}, {"w": "to", "b": [0.324, 0.3516, 0.34, 0.3732]}, {"w": "training", "b": [0.3448, 0.3516, 0.4092, 0.3732]}, {"w": "set", "b": [0.414, 0.3516, 0.4356, 0.3732]}, {"w": "details", "b": [0.4404, 0.3516, 0.493, 0.3732]}]}, {"id": "b_1", "type": "paragraph", "text": "Random Forests can limit this instability by averaging predictions over many trees, as we will see in the next chapter.", "words": [{"w": "Random", "b": [0.1429, 0.389, 0.2154, 0.4104]}, {"w": "Forests", "b": [0.2201, 0.389, 0.2796, 0.4104]}, {"w": "can", "b": [0.2848, 0.389, 0.3141, 0.4104]}, {"w": "limit", "b": [0.3191, 0.389, 0.359, 0.4104]}, {"w": "this", "b": [0.3639, 0.389, 0.3946, 0.4104]}, {"w": "instability", "b": [0.3996, 0.389, 0.4826, 0.4104]}, {"w": "by", "b": [0.4876, 0.389, 0.5078, 0.4104]}, {"w": "averaging", "b": [0.5127, 0.389, 0.5933, 0.4104]}, {"w": "predictions", "b": [0.5983, 0.389, 0.6928, 0.4104]}, {"w": "over", "b": [0.6977, 0.389, 0.7346, 0.4104]}, {"w": "many", "b": [0.7396, 0.389, 0.7862, 0.4104]}, {"w": "trees,", "b": [0.7912, 0.389, 0.8354, 0.4104]}, {"w": "as", "b": [0.8404, 0.389, 0.8571, 0.4104]}, {"w": "we", "b": [0.1429, 0.408, 0.166, 0.4294]}, {"w": "will", "b": [0.1707, 0.408, 0.2011, 0.4294]}, {"w": "see", "b": [0.2058, 0.408, 0.2312, 0.4294]}, {"w": "in", "b": [0.2359, 0.408, 0.2529, 0.4294]}, {"w": "the", "b": [0.2576, 0.408, 0.284, 0.4294]}, {"w": "next", "b": [0.2887, 0.408, 0.3251, 0.4294]}, {"w": "chapter.", "b": [0.3299, 0.408, 0.3958, 0.4294]}]}, {"id": "b_2", "type": "paragraph", "text": "Exercises", "words": [{"w": "Exercises", "b": [0.1429, 0.4424, 0.2533, 0.4767]}]}, {"id": "b_3", "type": "paragraph", "text": "1. What is the approximate depth of a Decision Tree trained (without restrictions) on a training set with 1 million instances?", "words": [{"w": "1.", "b": [0.1534, 0.4897, 0.1682, 0.5111]}, {"w": "What", "b": [0.1786, 0.4897, 0.225, 0.5111]}, {"w": "is", "b": [0.2312, 0.4897, 0.2445, 0.5111]}, {"w": "the", "b": [0.2507, 0.4897, 0.277, 0.5111]}, {"w": "approximate", "b": [0.2833, 0.4897, 0.3886, 0.5111]}, {"w": "depth", "b": [0.3949, 0.4897, 0.4431, 0.5111]}, {"w": "of", "b": [0.4493, 0.4897, 0.4661, 0.5111]}, {"w": "a", "b": [0.4723, 0.4897, 0.4815, 0.5111]}, {"w": "Decision", "b": [0.4877, 0.4897, 0.5615, 0.5111]}, {"w": "Tree", "b": [0.5677, 0.4897, 0.6043, 0.5111]}, {"w": "trained", "b": [0.6105, 0.4897, 0.6706, 0.5111]}, {"w": "(without", "b": [0.6768, 0.4897, 0.7494, 0.5111]}, {"w": "restrictions)", "b": [0.7556, 0.4897, 0.8571, 0.5111]}, {"w": "on", "b": [0.1786, 0.5087, 0.2006, 0.5301]}, {"w": "a", "b": [0.2053, 0.5087, 0.2145, 0.5301]}, {"w": "training", "b": [0.2192, 0.5087, 0.2861, 0.5301]}, {"w": "set", "b": [0.2909, 0.5087, 0.3137, 0.5301]}, {"w": "with", "b": [0.3184, 0.5087, 0.3558, 0.5301]}, {"w": "1", "b": [0.3605, 0.5087, 0.3705, 0.5301]}, {"w": "million", "b": [0.3752, 0.5087, 0.436, 0.5301]}, {"w": "instances?", "b": [0.4408, 0.5087, 0.5255, 0.5301]}]}, {"id": "b_4", "type": "paragraph", "text": "2. Is a node’s Gini impurity generally lower or greater than its parent’s? Is it gener‐ ally lower/greater, or always lower/greater?", "words": [{"w": "2.", "b": [0.1534, 0.5338, 0.1682, 0.5552]}, {"w": "Is", "b": [0.1786, 0.5338, 0.1929, 0.5552]}, {"w": "a", "b": [0.1991, 0.5338, 0.2083, 0.5552]}, {"w": "node’s", "b": [0.2146, 0.5338, 0.2655, 0.5552]}, {"w": "Gini", "b": [0.2718, 0.5338, 0.3093, 0.5552]}, {"w": "impurity", "b": [0.3155, 0.5338, 0.389, 0.5552]}, {"w": "generally", "b": [0.3953, 0.5338, 0.4711, 0.5552]}, {"w": "lower", "b": [0.4774, 0.5338, 0.5241, 0.5552]}, {"w": "or", "b": [0.5304, 0.5338, 0.5488, 0.5552]}, {"w": "greater", "b": [0.555, 0.5338, 0.6131, 0.5552]}, {"w": "than", "b": [0.6193, 0.5338, 0.6574, 0.5552]}, {"w": "its", "b": [0.6636, 0.5338, 0.6832, 0.5552]}, {"w": "parent’s?", "b": [0.6895, 0.5338, 0.7611, 0.5552]}, {"w": "Is", "b": [0.7674, 0.5338, 0.7817, 0.5552]}, {"w": "it", "b": [0.788, 0.5338, 0.7999, 0.5552]}, {"w": "gener‐", "b": [0.8062, 0.5336, 0.8571, 0.5552]}, {"w": "ally", "b": [0.1786, 0.5526, 0.2077, 0.5743]}, {"w": "lower/greater,", "b": [0.2125, 0.5529, 0.3276, 0.5743]}, {"w": "or", "b": [0.3323, 0.5529, 0.3506, 0.5743]}, {"w": "always", "b": [0.3554, 0.5526, 0.4101, 0.5743]}, {"w": "lower/greater?", "b": [0.4148, 0.5529, 0.5343, 0.5743]}]}, {"id": "b_5", "type": "paragraph", "text": "3. If a Decision Tree is overfitting the training set, is it a good idea to try decreasing max_depth?", "words": [{"w": "3.", "b": [0.1534, 0.5779, 0.1682, 0.5994]}, {"w": "If", "b": [0.1786, 0.5779, 0.1918, 0.5994]}, {"w": "a", "b": [0.197, 0.5779, 0.2062, 0.5994]}, {"w": "Decision", "b": [0.2113, 0.5779, 0.2851, 0.5994]}, {"w": "Tree", "b": [0.2903, 0.5779, 0.3269, 0.5994]}, {"w": "is", "b": [0.332, 0.5779, 0.3453, 0.5994]}, {"w": "overfitting", "b": [0.3504, 0.5779, 0.4385, 0.5994]}, {"w": "the", "b": [0.4437, 0.5779, 0.47, 0.5994]}, {"w": "training", "b": [0.4752, 0.5779, 0.5421, 0.5994]}, {"w": "set,", "b": [0.5473, 0.5779, 0.5749, 0.5994]}, {"w": "is", "b": [0.58, 0.5779, 0.5933, 0.5994]}, {"w": "it", "b": [0.5984, 0.5779, 0.6104, 0.5994]}, {"w": "a", "b": [0.6156, 0.5779, 0.6247, 0.5994]}, {"w": "good", "b": [0.6299, 0.5779, 0.6719, 0.5994]}, {"w": "idea", "b": [0.677, 0.5779, 0.7116, 0.5994]}, {"w": "to", "b": [0.7168, 0.5779, 0.7338, 0.5994]}, {"w": "try", "b": [0.7389, 0.5779, 0.7632, 0.5994]}, {"w": "decreasing", "b": [0.7684, 0.5779, 0.8571, 0.5994]}, {"w": "max_depth?", "b": [0.1786, 0.5979, 0.2755, 0.6193]}]}, {"id": "b_6", "type": "paragraph", "text": "4. If a Decision Tree is underfitting the training set, is it a good idea to try scaling the input features?", "words": [{"w": "4.", "b": [0.1534, 0.623, 0.1681, 0.6444]}, {"w": "If", "b": [0.1786, 0.623, 0.1918, 0.6444]}, {"w": "a", "b": [0.1981, 0.623, 0.2073, 0.6444]}, {"w": "Decision", "b": [0.2136, 0.623, 0.2874, 0.6444]}, {"w": "Tree", "b": [0.2937, 0.623, 0.3302, 0.6444]}, {"w": "is", "b": [0.3365, 0.623, 0.3498, 0.6444]}, {"w": "underfitting", "b": [0.3561, 0.623, 0.4573, 0.6444]}, {"w": "the", "b": [0.4636, 0.623, 0.4899, 0.6444]}, {"w": "training", "b": [0.4962, 0.623, 0.5632, 0.6444]}, {"w": "set,", "b": [0.5694, 0.623, 0.597, 0.6444]}, {"w": "is", "b": [0.6033, 0.623, 0.6166, 0.6444]}, {"w": "it", "b": [0.6229, 0.623, 0.6348, 0.6444]}, {"w": "a", "b": [0.6411, 0.623, 0.6502, 0.6444]}, {"w": "good", "b": [0.6565, 0.623, 0.6985, 0.6444]}, {"w": "idea", "b": [0.7048, 0.623, 0.7394, 0.6444]}, {"w": "to", "b": [0.7457, 0.623, 0.7627, 0.6444]}, {"w": "try", "b": [0.769, 0.623, 0.7932, 0.6444]}, {"w": "scaling", "b": [0.7995, 0.623, 0.8571, 0.6444]}, {"w": "the", "b": [0.1786, 0.642, 0.2049, 0.6634]}, {"w": "input", "b": [0.2096, 0.642, 0.2546, 0.6634]}, {"w": "features?", "b": [0.2593, 0.642, 0.3326, 0.6634]}]}, {"id": "b_7", "type": "paragraph", "text": "5. If it takes one hour to train a Decision Tree on a training set containing 1 million instances, roughly how much time will it take to train another Decision Tree on a training set containing 10 million instances?", "words": [{"w": "5.", "b": [0.1534, 0.6671, 0.1682, 0.6885]}, {"w": "If", "b": [0.1786, 0.6671, 0.1918, 0.6885]}, {"w": "it", "b": [0.1969, 0.6671, 0.2089, 0.6885]}, {"w": "takes", "b": [0.214, 0.6671, 0.2563, 0.6885]}, {"w": "one", "b": [0.2614, 0.6671, 0.2923, 0.6885]}, {"w": "hour", "b": [0.2974, 0.6671, 0.3379, 0.6885]}, {"w": "to", "b": [0.343, 0.6671, 0.36, 0.6885]}, {"w": "train", "b": [0.3651, 0.6671, 0.4053, 0.6885]}, {"w": "a", "b": [0.4104, 0.6671, 0.4195, 0.6885]}, {"w": "Decision", "b": [0.4246, 0.6671, 0.4984, 0.6885]}, {"w": "Tree", "b": [0.5035, 0.6671, 0.5401, 0.6885]}, {"w": "on", "b": [0.5452, 0.6671, 0.5672, 0.6885]}, {"w": "a", "b": [0.5723, 0.6671, 0.5814, 0.6885]}, {"w": "training", "b": [0.5865, 0.6671, 0.6535, 0.6885]}, {"w": "set", "b": [0.6586, 0.6671, 0.6814, 0.6885]}, {"w": "containing", "b": [0.6865, 0.6671, 0.7762, 0.6885]}, {"w": "1", "b": [0.7813, 0.6671, 0.7913, 0.6885]}, {"w": "million", "b": [0.7963, 0.6671, 0.8571, 0.6885]}, {"w": "instances,", "b": [0.1786, 0.6862, 0.2602, 0.7076]}, {"w": "roughly", "b": [0.2651, 0.6862, 0.3302, 0.7076]}, {"w": "how", "b": [0.3352, 0.6862, 0.3712, 0.7076]}, {"w": "much", "b": [0.3762, 0.6862, 0.4238, 0.7076]}, {"w": "time", "b": [0.4288, 0.6862, 0.4666, 0.7076]}, {"w": "will", "b": [0.4716, 0.6862, 0.502, 0.7076]}, {"w": "it", "b": [0.5069, 0.6862, 0.5189, 0.7076]}, {"w": "take", "b": [0.5238, 0.6862, 0.5585, 0.7076]}, {"w": "to", "b": [0.5635, 0.6862, 0.5804, 0.7076]}, {"w": "train", "b": [0.5854, 0.6862, 0.6256, 0.7076]}, {"w": "another", "b": [0.6306, 0.6862, 0.6958, 0.7076]}, {"w": "Decision", "b": [0.7007, 0.6862, 0.7746, 0.7076]}, {"w": "Tree", "b": [0.7795, 0.6862, 0.8161, 0.7076]}, {"w": "on", "b": [0.821, 0.6862, 0.843, 0.7076]}, {"w": "a", "b": [0.848, 0.6862, 0.8571, 0.7076]}, {"w": "training", "b": [0.1786, 0.7052, 0.2455, 0.7266]}, {"w": "set", "b": [0.2502, 0.7052, 0.2731, 0.7266]}, {"w": "containing", "b": [0.2778, 0.7052, 0.3675, 0.7266]}, {"w": "10", "b": [0.3722, 0.7052, 0.3922, 0.7266]}, {"w": "million", "b": [0.3969, 0.7052, 0.4577, 0.7266]}, {"w": "instances?", "b": [0.4624, 0.7052, 0.5472, 0.7266]}]}, {"id": "b_8", "type": "paragraph", "text": "6. If your training set contains 100,000 instances, will setting presort=True speed up training?", "words": [{"w": "6.", "b": [0.1534, 0.7312, 0.1682, 0.7526]}, {"w": "If", "b": [0.1786, 0.7312, 0.1918, 0.7526]}, {"w": "your", "b": [0.1986, 0.7312, 0.2375, 0.7526]}, {"w": "training", "b": [0.2443, 0.7312, 0.3112, 0.7526]}, {"w": "set", "b": [0.3179, 0.7312, 0.3408, 0.7526]}, {"w": "contains", "b": [0.3475, 0.7312, 0.4181, 0.7526]}, {"w": "100,000", "b": [0.4248, 0.7312, 0.4896, 0.7526]}, {"w": "instances,", "b": [0.4963, 0.7312, 0.5779, 0.7526]}, {"w": "will", "b": [0.5846, 0.7312, 0.615, 0.7526]}, {"w": "setting", "b": [0.6217, 0.7312, 0.6777, 0.7526]}, {"w": "presort=True", "b": [0.6844, 0.7344, 0.8031, 0.7495]}, {"w": "speed", "b": [0.8099, 0.7312, 0.8571, 0.7526]}, {"w": "up", "b": [0.1786, 0.7503, 0.2006, 0.7717]}, {"w": "training?", "b": [0.2053, 0.7503, 0.2801, 0.7717]}]}, {"id": "b_9", "type": "equation", "text": "7. Train and fine-tune a Decision Tree for the moons dataset.", "words": [{"w": "7.", "b": [0.1534, 0.7754, 0.1682, 0.7968]}, {"w": "Train", "b": [0.1786, 0.7754, 0.2235, 0.7968]}, {"w": "and", "b": [0.2283, 0.7754, 0.2598, 0.7968]}, {"w": "fine-tune", "b": [0.2645, 0.7754, 0.3416, 0.7968]}, {"w": "a", "b": [0.3464, 0.7754, 0.3555, 0.7968]}, {"w": "Decision", "b": [0.3602, 0.7754, 0.434, 0.7968]}, {"w": "Tree", "b": [0.4388, 0.7754, 0.4753, 0.7968]}, {"w": "for", "b": [0.4801, 0.7754, 0.5046, 0.7968]}, {"w": "the", "b": [0.5093, 0.7754, 0.5356, 0.7968]}, {"w": "moons", "b": [0.5404, 0.7754, 0.5977, 0.7968]}, {"w": "dataset.", "b": [0.6025, 0.7754, 0.6653, 0.7968]}]}, {"id": "b_10", "type": "equation", "text": "a. Generate a moons dataset using make_moons(n_samples=10000, noise=0.4).", "words": [{"w": "a.", "b": [0.1801, 0.8013, 0.1939, 0.8228]}, {"w": "Generate", "b": [0.2044, 0.8013, 0.28, 0.8228]}, {"w": "a", "b": [0.2848, 0.8013, 0.2939, 0.8228]}, {"w": "moons", "b": [0.2986, 0.8013, 0.356, 0.8228]}, {"w": "dataset", "b": [0.3607, 0.8013, 0.4188, 0.8228]}, {"w": "using", "b": [0.4236, 0.8013, 0.469, 0.8228]}, {"w": "make_moons(n_samples=10000,", "b": [0.4737, 0.8045, 0.7409, 0.8196]}, {"w": "noise=0.4).", "b": [0.7508, 0.8013, 0.8545, 0.8228]}]}, {"id": "b_11", "type": "equation", "text": "b. Split it into a training set and a test set using train_test_split().", "words": [{"w": "b.", "b": [0.1792, 0.8273, 0.1939, 0.8488]}, {"w": "Split", "b": [0.2044, 0.8273, 0.2424, 0.8487]}, {"w": "it", "b": [0.2471, 0.8273, 0.259, 0.8487]}, {"w": "into", "b": [0.2638, 0.8273, 0.2973, 0.8487]}, {"w": "a", "b": [0.302, 0.8273, 0.3112, 0.8487]}, {"w": "training", "b": [0.3159, 0.8273, 0.3829, 0.8487]}, {"w": "set", "b": [0.3876, 0.8273, 0.4104, 0.8487]}, {"w": "and", "b": [0.4152, 0.8273, 0.4467, 0.8487]}, {"w": "a", "b": [0.4514, 0.8273, 0.4606, 0.8487]}, {"w": "test", "b": [0.4653, 0.8273, 0.4945, 0.8487]}, {"w": "set", "b": [0.4993, 0.8273, 0.5221, 0.8487]}, {"w": "using", "b": [0.5268, 0.8273, 0.5723, 0.8487]}, {"w": "train_test_split().", "b": [0.577, 0.8273, 0.7599, 0.8487]}]}, {"id": "b_12", "type": "paragraph", "text": "Exercises | 189", "words": [{"w": "Exercises", "b": [0.7433, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "189", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 216, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "c. Use grid search with cross-validation (with the help of the GridSearchCV", "words": [{"w": "c.", "b": [0.1804, 0.08, 0.1939, 0.1014]}, {"w": "Use", "b": [0.2044, 0.08, 0.2351, 0.1014]}, {"w": "grid", "b": [0.2446, 0.08, 0.2787, 0.1014]}, {"w": "search", "b": [0.2882, 0.08, 0.3415, 0.1014]}, {"w": "with", "b": [0.351, 0.08, 0.3884, 0.1014]}, {"w": "cross-validation", "b": [0.3979, 0.08, 0.5311, 0.1014]}, {"w": "(with", "b": [0.5406, 0.08, 0.5852, 0.1014]}, {"w": "the", "b": [0.5947, 0.08, 0.621, 0.1014]}, {"w": "help", "b": [0.6305, 0.08, 0.6667, 0.1014]}, {"w": "of", "b": [0.6762, 0.08, 0.693, 0.1014]}, {"w": "the", "b": [0.7025, 0.08, 0.7289, 0.1014]}, {"w": "GridSearchCV", "b": [0.7384, 0.0831, 0.8571, 0.0982]}]}, {"id": "b_1", "type": "paragraph", "text": "class) to find good hyperparameter values for a DecisionTreeClassifier. Hint: try various values for max_leaf_nodes.", "words": [{"w": "class)", "b": [0.2044, 0.0999, 0.2501, 0.1213]}, {"w": "to", "b": [0.2582, 0.0999, 0.2751, 0.1213]}, {"w": "find", "b": [0.2832, 0.0999, 0.3174, 0.1213]}, {"w": "good", "b": [0.3254, 0.0999, 0.3674, 0.1213]}, {"w": "hyperparameter", "b": [0.3755, 0.0999, 0.509, 0.1213]}, {"w": "values", "b": [0.5171, 0.0999, 0.5687, 0.1213]}, {"w": "for", "b": [0.5768, 0.0999, 0.6013, 0.1213]}, {"w": "a", "b": [0.6094, 0.0999, 0.6185, 0.1213]}, {"w": "DecisionTreeClassifier.", "b": [0.6266, 0.0999, 0.8491, 0.1213]}, {"w": "Hint:", "b": [0.2044, 0.1198, 0.248, 0.1413]}, {"w": "try", "b": [0.2527, 0.1198, 0.277, 0.1413]}, {"w": "various", "b": [0.2817, 0.1198, 0.3432, 0.1413]}, {"w": "values", "b": [0.3479, 0.1198, 0.3995, 0.1413]}, {"w": "for", "b": [0.4042, 0.1198, 0.4288, 0.1413]}, {"w": "max_leaf_nodes.", "b": [0.4335, 0.1198, 0.5768, 0.1413]}]}, {"id": "b_2", "type": "paragraph", "text": "d. Train it on the full training set using these hyperparameters, and measure", "words": [{"w": "d.", "b": [0.1782, 0.1449, 0.1939, 0.1664]}, {"w": "Train", "b": [0.2044, 0.1449, 0.2493, 0.1664]}, {"w": "it", "b": [0.2579, 0.1449, 0.2698, 0.1664]}, {"w": "on", "b": [0.2783, 0.1449, 0.3004, 0.1664]}, {"w": "the", "b": [0.3089, 0.1449, 0.3352, 0.1664]}, {"w": "full", "b": [0.3438, 0.1449, 0.3715, 0.1664]}, {"w": "training", "b": [0.3801, 0.1449, 0.447, 0.1664]}, {"w": "set", "b": [0.4555, 0.1449, 0.4784, 0.1664]}, {"w": "using", "b": [0.4869, 0.1449, 0.5324, 0.1664]}, {"w": "these", "b": [0.5409, 0.1449, 0.5837, 0.1664]}, {"w": "hyperparameters,", "b": [0.5923, 0.1449, 0.7382, 0.1664]}, {"w": "and", "b": [0.7467, 0.1449, 0.7782, 0.1664]}, {"w": "measure", "b": [0.7868, 0.1449, 0.8571, 0.1664]}]}, {"id": "b_3", "type": "paragraph", "text": "your model’s performance on the test set. You should get roughly 85% to 87% accuracy.", "words": [{"w": "your", "b": [0.2044, 0.164, 0.2433, 0.1854]}, {"w": "model’s", "b": [0.2488, 0.164, 0.3114, 0.1854]}, {"w": "performance", "b": [0.3169, 0.164, 0.4242, 0.1854]}, {"w": "on", "b": [0.4296, 0.164, 0.4516, 0.1854]}, {"w": "the", "b": [0.4571, 0.164, 0.4835, 0.1854]}, {"w": "test", "b": [0.4889, 0.164, 0.5181, 0.1854]}, {"w": "set.", "b": [0.5236, 0.164, 0.5512, 0.1854]}, {"w": "You", "b": [0.5567, 0.164, 0.589, 0.1854]}, {"w": "should", "b": [0.5945, 0.164, 0.6512, 0.1854]}, {"w": "get", "b": [0.6567, 0.164, 0.6817, 0.1854]}, {"w": "roughly", "b": [0.6871, 0.164, 0.7523, 0.1854]}, {"w": "85%", "b": [0.7577, 0.164, 0.7935, 0.1854]}, {"w": "to", "b": [0.7989, 0.164, 0.8159, 0.1854]}, {"w": "87%", "b": [0.8214, 0.164, 0.8571, 0.1854]}, {"w": "accuracy.", "b": [0.2044, 0.183, 0.2807, 0.2044]}]}, {"id": "b_4", "type": "paragraph", "text": "8. Grow a forest.", "words": [{"w": "8.", "b": [0.1534, 0.2081, 0.1681, 0.2295]}, {"w": "Grow", "b": [0.1786, 0.2081, 0.2261, 0.2295]}, {"w": "a", "b": [0.2308, 0.2081, 0.24, 0.2295]}, {"w": "forest.", "b": [0.2447, 0.2081, 0.2968, 0.2295]}]}, {"id": "b_5", "type": "paragraph", "text": "a. Continuing the previous exercise, generate 1,000 subsets of the training set,", "words": [{"w": "a.", "b": [0.1801, 0.2332, 0.1939, 0.2546]}, {"w": "Continuing", "b": [0.2044, 0.2332, 0.3006, 0.2546]}, {"w": "the", "b": [0.308, 0.2332, 0.3343, 0.2546]}, {"w": "previous", "b": [0.3418, 0.2332, 0.4139, 0.2546]}, {"w": "exercise,", "b": [0.4213, 0.2332, 0.4922, 0.2546]}, {"w": "generate", "b": [0.4997, 0.2332, 0.5702, 0.2546]}, {"w": "1,000", "b": [0.5777, 0.2332, 0.6224, 0.2546]}, {"w": "subsets", "b": [0.6299, 0.2332, 0.6897, 0.2546]}, {"w": "of", "b": [0.6971, 0.2332, 0.7139, 0.2546]}, {"w": "the", "b": [0.7214, 0.2332, 0.7477, 0.2546]}, {"w": "training", "b": [0.7551, 0.2332, 0.8221, 0.2546]}, {"w": "set,", "b": [0.8295, 0.2332, 0.8571, 0.2546]}]}, {"id": "b_6", "type": "paragraph", "text": "each containing 100 instances selected randomly. Hint: you can use Scikit- Learn’s ShuffleSplit class for this.", "words": [{"w": "each", "b": [0.2044, 0.2523, 0.2423, 0.2737]}, {"w": "containing", "b": [0.2505, 0.2523, 0.3401, 0.2737]}, {"w": "100", "b": [0.3483, 0.2523, 0.3783, 0.2737]}, {"w": "instances", "b": [0.3865, 0.2523, 0.4634, 0.2737]}, {"w": "selected", "b": [0.4716, 0.2523, 0.5372, 0.2737]}, {"w": "randomly.", "b": [0.5454, 0.2523, 0.6304, 0.2737]}, {"w": "Hint:", "b": [0.6386, 0.2523, 0.6822, 0.2737]}, {"w": "you", "b": [0.6904, 0.2523, 0.7217, 0.2737]}, {"w": "can", "b": [0.7299, 0.2523, 0.7592, 0.2737]}, {"w": "use", "b": [0.7674, 0.2523, 0.795, 0.2737]}, {"w": "Scikit-", "b": [0.8032, 0.2523, 0.8571, 0.2737]}, {"w": "Learn’s", "b": [0.2044, 0.2722, 0.2613, 0.2936]}, {"w": "ShuffleSplit", "b": [0.266, 0.2754, 0.3848, 0.2905]}, {"w": "class", "b": [0.3895, 0.2722, 0.428, 0.2936]}, {"w": "for", "b": [0.4328, 0.2722, 0.4573, 0.2936]}, {"w": "this.", "b": [0.462, 0.2722, 0.4975, 0.2936]}]}, {"id": "b_7", "type": "paragraph", "text": "b. Train one Decision Tree on each subset, using the best hyperparameter values", "words": [{"w": "b.", "b": [0.1792, 0.2973, 0.1939, 0.3187]}, {"w": "Train", "b": [0.2044, 0.2973, 0.2494, 0.3187]}, {"w": "one", "b": [0.2547, 0.2973, 0.2856, 0.3187]}, {"w": "Decision", "b": [0.291, 0.2973, 0.3648, 0.3187]}, {"w": "Tree", "b": [0.3702, 0.2973, 0.4068, 0.3187]}, {"w": "on", "b": [0.4122, 0.2973, 0.4342, 0.3187]}, {"w": "each", "b": [0.4396, 0.2973, 0.4775, 0.3187]}, {"w": "subset,", "b": [0.4829, 0.2973, 0.5398, 0.3187]}, {"w": "using", "b": [0.5452, 0.2973, 0.5907, 0.3187]}, {"w": "the", "b": [0.5961, 0.2973, 0.6224, 0.3187]}, {"w": "best", "b": [0.6278, 0.2973, 0.6612, 0.3187]}, {"w": "hyperparameter", "b": [0.6666, 0.2973, 0.8001, 0.3187]}, {"w": "values", "b": [0.8055, 0.2973, 0.8571, 0.3187]}]}, {"id": "b_8", "type": "paragraph", "text": "found above. Evaluate these 1,000 Decision Trees on the test set. Since they were trained on smaller sets, these Decision Trees will likely perform worse than the first Decision Tree, achieving only about 80% accuracy.", "words": [{"w": "found", "b": [0.2044, 0.3164, 0.2546, 0.3378]}, {"w": "above.", "b": [0.2619, 0.3164, 0.3155, 0.3378]}, {"w": "Evaluate", "b": [0.3228, 0.3164, 0.3933, 0.3378]}, {"w": "these", "b": [0.4005, 0.3164, 0.4434, 0.3378]}, {"w": "1,000", "b": [0.4506, 0.3164, 0.4954, 0.3378]}, {"w": "Decision", "b": [0.5026, 0.3164, 0.5765, 0.3378]}, {"w": "Trees", "b": [0.5837, 0.3164, 0.6279, 0.3378]}, {"w": "on", "b": [0.6352, 0.3164, 0.6572, 0.3378]}, {"w": "the", "b": [0.6645, 0.3164, 0.6908, 0.3378]}, {"w": "test", "b": [0.6981, 0.3164, 0.7273, 0.3378]}, {"w": "set.", "b": [0.7346, 0.3164, 0.7622, 0.3378]}, {"w": "Since", "b": [0.7694, 0.3164, 0.814, 0.3378]}, {"w": "they", "b": [0.8212, 0.3164, 0.8571, 0.3378]}, {"w": "were", "b": [0.2044, 0.3354, 0.2441, 0.3568]}, {"w": "trained", "b": [0.2514, 0.3354, 0.3114, 0.3568]}, {"w": "on", "b": [0.3188, 0.3354, 0.3408, 0.3568]}, {"w": "smaller", "b": [0.3481, 0.3354, 0.4091, 0.3568]}, {"w": "sets,", "b": [0.4164, 0.3354, 0.4516, 0.3568]}, {"w": "these", "b": [0.4589, 0.3354, 0.5018, 0.3568]}, {"w": "Decision", "b": [0.5091, 0.3354, 0.5829, 0.3568]}, {"w": "Trees", "b": [0.5902, 0.3354, 0.6344, 0.3568]}, {"w": "will", "b": [0.6417, 0.3354, 0.6721, 0.3568]}, {"w": "likely", "b": [0.6794, 0.3354, 0.7243, 0.3568]}, {"w": "perform", "b": [0.7316, 0.3354, 0.8007, 0.3568]}, {"w": "worse", "b": [0.808, 0.3354, 0.8571, 0.3568]}, {"w": "than", "b": [0.2044, 0.3545, 0.2424, 0.3759]}, {"w": "the", "b": [0.2471, 0.3545, 0.2735, 0.3759]}, {"w": "first", "b": [0.2782, 0.3545, 0.3117, 0.3759]}, {"w": "Decision", "b": [0.3164, 0.3545, 0.3902, 0.3759]}, {"w": "Tree,", "b": [0.3949, 0.3545, 0.4362, 0.3759]}, {"w": "achieving", "b": [0.441, 0.3545, 0.5209, 0.3759]}, {"w": "only", "b": [0.5256, 0.3545, 0.5625, 0.3759]}, {"w": "about", "b": [0.5672, 0.3545, 0.615, 0.3759]}, {"w": "80%", "b": [0.6197, 0.3545, 0.6554, 0.3759]}, {"w": "accuracy.", "b": [0.6602, 0.3545, 0.7365, 0.3759]}]}, {"id": "b_9", "type": "paragraph", "text": "c. Now comes the magic. For each test set instance, generate the predictions of", "words": [{"w": "c.", "b": [0.1804, 0.3795, 0.1939, 0.401]}, {"w": "Now", "b": [0.2044, 0.3796, 0.2442, 0.401]}, {"w": "comes", "b": [0.2507, 0.3796, 0.3037, 0.401]}, {"w": "the", "b": [0.3101, 0.3796, 0.3364, 0.401]}, {"w": "magic.", "b": [0.3429, 0.3796, 0.398, 0.401]}, {"w": "For", "b": [0.4044, 0.3796, 0.4334, 0.401]}, {"w": "each", "b": [0.4399, 0.3796, 0.4778, 0.401]}, {"w": "test", "b": [0.4843, 0.3796, 0.5135, 0.401]}, {"w": "set", "b": [0.5199, 0.3796, 0.5428, 0.401]}, {"w": "instance,", "b": [0.5492, 0.3796, 0.6232, 0.401]}, {"w": "generate", "b": [0.6296, 0.3796, 0.7002, 0.401]}, {"w": "the", "b": [0.7066, 0.3796, 0.7329, 0.401]}, {"w": "predictions", "b": [0.7394, 0.3796, 0.8339, 0.401]}, {"w": "of", "b": [0.8403, 0.3796, 0.8571, 0.401]}]}, {"id": "b_10", "type": "paragraph", "text": "the 1,000 Decision Trees, and keep only the most frequent prediction (you can use SciPy’s mode() function for this). This gives you majority-vote predictions over the test set.", "words": [{"w": "the", "b": [0.2044, 0.3986, 0.2307, 0.42]}, {"w": "1,000", "b": [0.2355, 0.3986, 0.2803, 0.42]}, {"w": "Decision", "b": [0.2852, 0.3986, 0.359, 0.42]}, {"w": "Trees,", "b": [0.3638, 0.3986, 0.4128, 0.42]}, {"w": "and", "b": [0.4176, 0.3986, 0.4492, 0.42]}, {"w": "keep", "b": [0.454, 0.3986, 0.493, 0.42]}, {"w": "only", "b": [0.4978, 0.3986, 0.5347, 0.42]}, {"w": "the", "b": [0.5395, 0.3986, 0.5659, 0.42]}, {"w": "most", "b": [0.5707, 0.3986, 0.6124, 0.42]}, {"w": "frequent", "b": [0.6173, 0.3986, 0.6879, 0.42]}, {"w": "prediction", "b": [0.6928, 0.3986, 0.7796, 0.42]}, {"w": "(you", "b": [0.7845, 0.3986, 0.8229, 0.42]}, {"w": "can", "b": [0.8278, 0.3986, 0.8571, 0.42]}, {"w": "use", "b": [0.2044, 0.4185, 0.2319, 0.44]}, {"w": "SciPy’s", "b": [0.2382, 0.4185, 0.294, 0.44]}, {"w": "mode()", "b": [0.3003, 0.4217, 0.3596, 0.4368]}, {"w": "function", "b": [0.3659, 0.4185, 0.4373, 0.44]}, {"w": "for", "b": [0.4435, 0.4185, 0.468, 0.44]}, {"w": "this).", "b": [0.4742, 0.4185, 0.5169, 0.44]}, {"w": "This", "b": [0.5231, 0.4185, 0.5603, 0.44]}, {"w": "gives", "b": [0.5666, 0.4185, 0.608, 0.44]}, {"w": "you", "b": [0.6143, 0.4185, 0.6455, 0.44]}, {"w": "majority-vote", "b": [0.6518, 0.4183, 0.7621, 0.44]}, {"w": "predictions", "b": [0.7683, 0.4183, 0.8571, 0.44]}, {"w": "over", "b": [0.2044, 0.4376, 0.2412, 0.459]}, {"w": "the", "b": [0.2459, 0.4376, 0.2723, 0.459]}, {"w": "test", "b": [0.277, 0.4376, 0.3062, 0.459]}, {"w": "set.", "b": [0.3109, 0.4376, 0.3385, 0.459]}]}, {"id": "b_11", "type": "paragraph", "text": "d. Evaluate these predictions on the test set: you should obtain a slightly higher", "words": [{"w": "d.", "b": [0.1782, 0.4627, 0.1939, 0.4841]}, {"w": "Evaluate", "b": [0.2044, 0.4627, 0.2749, 0.4841]}, {"w": "these", "b": [0.2811, 0.4627, 0.3239, 0.4841]}, {"w": "predictions", "b": [0.3301, 0.4627, 0.4246, 0.4841]}, {"w": "on", "b": [0.4308, 0.4627, 0.4529, 0.4841]}, {"w": "the", "b": [0.4591, 0.4627, 0.4854, 0.4841]}, {"w": "test", "b": [0.4916, 0.4627, 0.5208, 0.4841]}, {"w": "set:", "b": [0.5271, 0.4627, 0.5547, 0.4841]}, {"w": "you", "b": [0.5609, 0.4627, 0.5921, 0.4841]}, {"w": "should", "b": [0.5984, 0.4627, 0.6551, 0.4841]}, {"w": "obtain", "b": [0.6613, 0.4627, 0.715, 0.4841]}, {"w": "a", "b": [0.7212, 0.4627, 0.7304, 0.4841]}, {"w": "slightly", "b": [0.7366, 0.4627, 0.7967, 0.4841]}, {"w": "higher", "b": [0.803, 0.4627, 0.8571, 0.4841]}]}, {"id": "b_12", "type": "paragraph", "text": "accuracy than your first model (about 0.5 to 1.5% higher). Congratulations, you have trained a Random Forest classifier!", "words": [{"w": "accuracy", "b": [0.2044, 0.4817, 0.2774, 0.5031]}, {"w": "than", "b": [0.2848, 0.4817, 0.3228, 0.5031]}, {"w": "your", "b": [0.3301, 0.4817, 0.3691, 0.5031]}, {"w": "first", "b": [0.3764, 0.4817, 0.4099, 0.5031]}, {"w": "model", "b": [0.4172, 0.4817, 0.47, 0.5031]}, {"w": "(about", "b": [0.4773, 0.4817, 0.5323, 0.5031]}, {"w": "0.5", "b": [0.5396, 0.4817, 0.5644, 0.5031]}, {"w": "to", "b": [0.5717, 0.4817, 0.5887, 0.5031]}, {"w": "1.5%", "b": [0.596, 0.4817, 0.6365, 0.5031]}, {"w": "higher).", "b": [0.6438, 0.4817, 0.7099, 0.5031]}, {"w": "Congratulations,", "b": [0.7172, 0.4817, 0.8571, 0.5031]}, {"w": "you", "b": [0.2044, 0.5008, 0.2356, 0.5222]}, {"w": "have", "b": [0.2404, 0.5008, 0.2787, 0.5222]}, {"w": "trained", "b": [0.2835, 0.5008, 0.3435, 0.5222]}, {"w": "a", "b": [0.3483, 0.5008, 0.3574, 0.5222]}, {"w": "Random", "b": [0.3621, 0.5008, 0.4347, 0.5222]}, {"w": "Forest", "b": [0.4394, 0.5008, 0.4912, 0.5222]}, {"w": "classifier!", "b": [0.496, 0.5008, 0.5742, 0.5222]}]}, {"id": "b_13", "type": "paragraph", "text": "Solutions to these exercises are available in ???.", "words": [{"w": "Solutions", "b": [0.1429, 0.5349, 0.2213, 0.5564]}, {"w": "to", "b": [0.226, 0.5349, 0.243, 0.5564]}, {"w": "these", "b": [0.2477, 0.5349, 0.2906, 0.5564]}, {"w": "exercises", "b": [0.2953, 0.5349, 0.3691, 0.5564]}, {"w": "are", "b": [0.3738, 0.5349, 0.3996, 0.5564]}, {"w": "available", "b": [0.4043, 0.5349, 0.4766, 0.5564]}, {"w": "in", "b": [0.4813, 0.5349, 0.4983, 0.5564]}, {"w": "???.", "b": [0.503, 0.5349, 0.5314, 0.5564]}]}, {"id": "b_14", "type": "paragraph", "text": "190 | Chapter 6: Decision Trees", "words": [{"w": "190", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "6:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Decision", "b": [0.2673, 0.9225, 0.3162, 0.9388]}, {"w": "Trees", "b": [0.319, 0.9225, 0.3502, 0.9388]}]}]}, {"page": 217, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "CHAPTER 7 Ensemble Learning and Random Forests", "words": [{"w": "CHAPTER", "b": [0.7398, 0.1146, 0.8383, 0.1451]}, {"w": "7", "b": [0.8435, 0.1146, 0.8571, 0.1451]}, {"w": "Ensemble", "b": [0.2008, 0.1478, 0.3606, 0.1935]}, {"w": "Learning", "b": [0.3685, 0.1478, 0.5149, 0.1935]}, {"w": "and", "b": [0.5228, 0.1478, 0.5856, 0.1935]}, {"w": "Random", "b": [0.5935, 0.1478, 0.7316, 0.1935]}, {"w": "Forests", "b": [0.7395, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_1", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 7 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.3643, 0.3102, 0.3839]}, {"w": "Early", "b": [0.3165, 0.3643, 0.3563, 0.3839]}, {"w": "Release", "b": [0.3626, 0.3643, 0.4189, 0.3839]}, {"w": "ebooks,", "b": [0.4251, 0.3643, 0.4831, 0.3839]}, {"w": "you", "b": [0.4894, 0.3643, 0.518, 0.3839]}, {"w": "get", "b": [0.5243, 0.3643, 0.5471, 0.3839]}, {"w": "books", "b": [0.5534, 0.3643, 0.5989, 0.3839]}, {"w": "in", "b": [0.6052, 0.3643, 0.6207, 0.3839]}, {"w": "their", "b": [0.627, 0.3643, 0.6632, 0.3839]}, {"w": "earliest", "b": [0.6695, 0.3643, 0.7239, 0.3839]}, {"w": "form—", "b": [0.7301, 0.3643, 0.7857, 0.3839]}, {"w": "the", "b": [0.2714, 0.3818, 0.2955, 0.4013]}, {"w": "author’s", "b": [0.3012, 0.3818, 0.3615, 0.4013]}, {"w": "raw", "b": [0.3672, 0.3818, 0.3954, 0.4013]}, {"w": "and", "b": [0.4011, 0.3818, 0.4299, 0.4013]}, {"w": "unedited", "b": [0.4357, 0.3818, 0.5034, 0.4013]}, {"w": "content", "b": [0.5091, 0.3818, 0.5667, 0.4013]}, {"w": "as", "b": [0.5725, 0.3818, 0.5878, 0.4013]}, {"w": "he", "b": [0.5936, 0.3818, 0.6118, 0.4013]}, {"w": "or", "b": [0.6175, 0.3818, 0.6343, 0.4013]}, {"w": "she", "b": [0.6401, 0.3818, 0.6653, 0.4013]}, {"w": "writes—so", "b": [0.671, 0.3818, 0.7514, 0.4013]}, {"w": "you", "b": [0.7571, 0.3818, 0.7857, 0.4013]}, {"w": "can", "b": [0.2714, 0.3992, 0.2982, 0.4188]}, {"w": "take", "b": [0.306, 0.3992, 0.3377, 0.4188]}, {"w": "advantage", "b": [0.3455, 0.3992, 0.4223, 0.4188]}, {"w": "of", "b": [0.4301, 0.3992, 0.4454, 0.4188]}, {"w": "these", "b": [0.4532, 0.3992, 0.4923, 0.4188]}, {"w": "technologies", "b": [0.5001, 0.3992, 0.596, 0.4188]}, {"w": "long", "b": [0.6038, 0.3992, 0.6376, 0.4188]}, {"w": "before", "b": [0.6454, 0.3992, 0.6937, 0.4188]}, {"w": "the", "b": [0.7014, 0.3992, 0.7255, 0.4188]}, {"w": "official", "b": [0.7333, 0.3992, 0.7857, 0.4188]}, {"w": "release", "b": [0.2714, 0.4166, 0.3229, 0.4362]}, {"w": "of", "b": [0.3292, 0.4166, 0.3445, 0.4362]}, {"w": "these", "b": [0.3507, 0.4166, 0.3899, 0.4362]}, {"w": "titles.", "b": [0.3961, 0.4166, 0.4371, 0.4362]}, {"w": "The", "b": [0.4433, 0.4166, 0.4733, 0.4362]}, {"w": "following", "b": [0.4795, 0.4166, 0.5517, 0.4362]}, {"w": "will", "b": [0.558, 0.4166, 0.5857, 0.4362]}, {"w": "be", "b": [0.592, 0.4166, 0.6097, 0.4362]}, {"w": "Chapter", "b": [0.616, 0.4166, 0.6777, 0.4362]}, {"w": "7", "b": [0.684, 0.4166, 0.6931, 0.4362]}, {"w": "in", "b": [0.6993, 0.4166, 0.7149, 0.4362]}, {"w": "the", "b": [0.7211, 0.4166, 0.7452, 0.4362]}, {"w": "final", "b": [0.7514, 0.4166, 0.7857, 0.4362]}, {"w": "release", "b": [0.2714, 0.434, 0.3229, 0.4536]}, {"w": "of", "b": [0.3273, 0.434, 0.3426, 0.4536]}, {"w": "the", "b": [0.3469, 0.434, 0.371, 0.4536]}, {"w": "book.", "b": [0.3753, 0.434, 0.4182, 0.4536]}]}, {"id": "b_2", "type": "paragraph", "text": "Suppose you ask a complex question to thousands of random people, then aggregate their answers. In many cases you will find that this aggregated answer is better than an expert’s answer. This is called the wisdom of the crowd. Similarly, if you aggregate the predictions of a group of predictors (such as classifiers or regressors), you will often get better predictions than with the best individual predictor. A group of pre‐ dictors is called an ensemble; thus, this technique is called Ensemble Learning, and an Ensemble Learning algorithm is called an Ensemble method.", "words": [{"w": "Suppose", "b": [0.1429, 0.4739, 0.2127, 0.4953]}, {"w": "you", "b": [0.2186, 0.4739, 0.2498, 0.4953]}, {"w": "ask", "b": [0.2557, 0.4739, 0.2828, 0.4953]}, {"w": "a", "b": [0.2887, 0.4739, 0.2978, 0.4953]}, {"w": "complex", "b": [0.3037, 0.4739, 0.3746, 0.4953]}, {"w": "question", "b": [0.3805, 0.4739, 0.4526, 0.4953]}, {"w": "to", "b": [0.4585, 0.4739, 0.4755, 0.4953]}, {"w": "thousands", "b": [0.4813, 0.4739, 0.5673, 0.4953]}, {"w": "of", "b": [0.5732, 0.4739, 0.5899, 0.4953]}, {"w": "random", "b": [0.5958, 0.4739, 0.6628, 0.4953]}, {"w": "people,", "b": [0.6686, 0.4739, 0.7288, 0.4953]}, {"w": "then", "b": [0.7346, 0.4739, 0.7724, 0.4953]}, {"w": "aggregate", "b": [0.7782, 0.4739, 0.8571, 0.4953]}, {"w": "their", "b": [0.1428, 0.4929, 0.1825, 0.5143]}, {"w": "answers.", "b": [0.1888, 0.4929, 0.2602, 0.5143]}, {"w": "In", "b": [0.2665, 0.4929, 0.285, 0.5143]}, {"w": "many", "b": [0.2913, 0.4929, 0.3379, 0.5143]}, {"w": "cases", "b": [0.3442, 0.4929, 0.3863, 0.5143]}, {"w": "you", "b": [0.3926, 0.4929, 0.4239, 0.5143]}, {"w": "will", "b": [0.4301, 0.4929, 0.4605, 0.5143]}, {"w": "find", "b": [0.4668, 0.4929, 0.5009, 0.5143]}, {"w": "that", "b": [0.5072, 0.4929, 0.5398, 0.5143]}, {"w": "this", "b": [0.5461, 0.4929, 0.5768, 0.5143]}, {"w": "aggregated", "b": [0.5831, 0.4929, 0.673, 0.5143]}, {"w": "answer", "b": [0.6793, 0.4929, 0.7383, 0.5143]}, {"w": "is", "b": [0.7446, 0.4929, 0.7578, 0.5143]}, {"w": "better", "b": [0.7641, 0.4929, 0.8128, 0.5143]}, {"w": "than", "b": [0.8191, 0.4929, 0.8571, 0.5143]}, {"w": "an", "b": [0.1429, 0.512, 0.1634, 0.5334]}, {"w": "expert’s", "b": [0.1695, 0.512, 0.2318, 0.5334]}, {"w": "answer.", "b": [0.2379, 0.512, 0.3004, 0.5334]}, {"w": "This", "b": [0.3065, 0.512, 0.3438, 0.5334]}, {"w": "is", "b": [0.3499, 0.512, 0.3631, 0.5334]}, {"w": "called", "b": [0.3692, 0.512, 0.4176, 0.5334]}, {"w": "the", "b": [0.4237, 0.512, 0.45, 0.5334]}, {"w": "wisdom", "b": [0.4562, 0.5118, 0.5197, 0.5334]}, {"w": "of", "b": [0.5259, 0.5118, 0.5411, 0.5334]}, {"w": "the", "b": [0.5473, 0.5118, 0.5723, 0.5334]}, {"w": "crowd.", "b": [0.5785, 0.5118, 0.6324, 0.5334]}, {"w": "Similarly,", "b": [0.6385, 0.512, 0.7168, 0.5334]}, {"w": "if", "b": [0.723, 0.512, 0.7347, 0.5334]}, {"w": "you", "b": [0.7408, 0.512, 0.7721, 0.5334]}, {"w": "aggregate", "b": [0.7782, 0.512, 0.8571, 0.5334]}, {"w": "the", "b": [0.1429, 0.531, 0.1692, 0.5524]}, {"w": "predictions", "b": [0.1766, 0.531, 0.2711, 0.5524]}, {"w": "of", "b": [0.2785, 0.531, 0.2953, 0.5524]}, {"w": "a", "b": [0.3027, 0.531, 0.3119, 0.5524]}, {"w": "group", "b": [0.3193, 0.531, 0.3694, 0.5524]}, {"w": "of", "b": [0.3768, 0.531, 0.3936, 0.5524]}, {"w": "predictors", "b": [0.401, 0.531, 0.4863, 0.5524]}, {"w": "(such", "b": [0.4937, 0.531, 0.5396, 0.5524]}, {"w": "as", "b": [0.547, 0.531, 0.5638, 0.5524]}, {"w": "classifiers", "b": [0.5712, 0.531, 0.6513, 0.5524]}, {"w": "or", "b": [0.6587, 0.531, 0.6771, 0.5524]}, {"w": "regressors),", "b": [0.6845, 0.531, 0.7807, 0.5524]}, {"w": "you", "b": [0.7881, 0.531, 0.8193, 0.5524]}, {"w": "will", "b": [0.8267, 0.531, 0.8571, 0.5524]}, {"w": "often", "b": [0.1429, 0.5501, 0.1862, 0.5715]}, {"w": "get", "b": [0.1928, 0.5501, 0.2177, 0.5715]}, {"w": "better", "b": [0.2243, 0.5501, 0.273, 0.5715]}, {"w": "predictions", "b": [0.2796, 0.5501, 0.3741, 0.5715]}, {"w": "than", "b": [0.3806, 0.5501, 0.4186, 0.5715]}, {"w": "with", "b": [0.4252, 0.5501, 0.4625, 0.5715]}, {"w": "the", "b": [0.4691, 0.5501, 0.4954, 0.5715]}, {"w": "best", "b": [0.5019, 0.5501, 0.5354, 0.5715]}, {"w": "individual", "b": [0.5419, 0.5501, 0.6272, 0.5715]}, {"w": "predictor.", "b": [0.6337, 0.5501, 0.7148, 0.5715]}, {"w": "A", "b": [0.7213, 0.5501, 0.7357, 0.5715]}, {"w": "group", "b": [0.7423, 0.5501, 0.7923, 0.5715]}, {"w": "of", "b": [0.7989, 0.5501, 0.8157, 0.5715]}, {"w": "pre‐", "b": [0.8222, 0.5501, 0.8571, 0.5715]}, {"w": "dictors", "b": [0.1429, 0.5691, 0.2006, 0.5905]}, {"w": "is", "b": [0.2062, 0.5691, 0.2195, 0.5905]}, {"w": "called", "b": [0.2251, 0.5691, 0.2734, 0.5905]}, {"w": "an", "b": [0.2791, 0.5691, 0.2996, 0.5905]}, {"w": "ensemble;", "b": [0.3052, 0.5689, 0.3842, 0.5905]}, {"w": "thus,", "b": [0.3898, 0.5691, 0.4304, 0.5905]}, {"w": "this", "b": [0.436, 0.5691, 0.4667, 0.5905]}, {"w": "technique", "b": [0.4723, 0.5691, 0.555, 0.5905]}, {"w": "is", "b": [0.5606, 0.5691, 0.5739, 0.5905]}, {"w": "called", "b": [0.5795, 0.5691, 0.6278, 0.5905]}, {"w": "Ensemble", "b": [0.6335, 0.5689, 0.7107, 0.5905]}, {"w": "Learning,", "b": [0.7163, 0.5689, 0.7938, 0.5905]}, {"w": "and", "b": [0.7994, 0.5691, 0.831, 0.5905]}, {"w": "an", "b": [0.8366, 0.5691, 0.8572, 0.5905]}, {"w": "Ensemble", "b": [0.1429, 0.5882, 0.2244, 0.6096]}, {"w": "Learning", "b": [0.2291, 0.5882, 0.3042, 0.6096]}, {"w": "algorithm", "b": [0.3089, 0.5882, 0.3915, 0.6096]}, {"w": "is", "b": [0.3963, 0.5882, 0.4095, 0.6096]}, {"w": "called", "b": [0.4142, 0.5882, 0.4626, 0.6096]}, {"w": "an", "b": [0.4673, 0.5882, 0.4878, 0.6096]}, {"w": "Ensemble", "b": [0.4926, 0.588, 0.5698, 0.6096]}, {"w": "method.", "b": [0.5745, 0.588, 0.6407, 0.6096]}]}, {"id": "b_3", "type": "paragraph", "text": "For example, you can train a group of Decision Tree classifiers, each on a different random subset of the training set. To make predictions, you just obtain the predic‐ tions of all individual trees, then predict the class that gets the most votes (see the last exercise in Chapter 6). Such an ensemble of Decision Trees is called a Random Forest, and despite its simplicity, this is one of the most powerful Machine Learning algo‐ rithms available today.", "words": [{"w": "For", "b": [0.1429, 0.6163, 0.1718, 0.6377]}, {"w": "example,", "b": [0.1789, 0.6163, 0.2531, 0.6377]}, {"w": "you", "b": [0.2602, 0.6163, 0.2914, 0.6377]}, {"w": "can", "b": [0.2984, 0.6163, 0.3278, 0.6377]}, {"w": "train", "b": [0.3348, 0.6163, 0.375, 0.6377]}, {"w": "a", "b": [0.382, 0.6163, 0.3911, 0.6377]}, {"w": "group", "b": [0.3982, 0.6163, 0.4482, 0.6377]}, {"w": "of", "b": [0.4553, 0.6163, 0.472, 0.6377]}, {"w": "Decision", "b": [0.4791, 0.6163, 0.5529, 0.6377]}, {"w": "Tree", "b": [0.5599, 0.6163, 0.5964, 0.6377]}, {"w": "classifiers,", "b": [0.6035, 0.6163, 0.6883, 0.6377]}, {"w": "each", "b": [0.6953, 0.6163, 0.7332, 0.6377]}, {"w": "on", "b": [0.7402, 0.6163, 0.7623, 0.6377]}, {"w": "a", "b": [0.7693, 0.6163, 0.7784, 0.6377]}, {"w": "different", "b": [0.7854, 0.6163, 0.8571, 0.6377]}, {"w": "random", "b": [0.1429, 0.6353, 0.2098, 0.6567]}, {"w": "subset", "b": [0.2167, 0.6353, 0.2688, 0.6567]}, {"w": "of", "b": [0.2757, 0.6353, 0.2925, 0.6567]}, {"w": "the", "b": [0.2994, 0.6353, 0.3257, 0.6567]}, {"w": "training", "b": [0.3326, 0.6353, 0.3995, 0.6567]}, {"w": "set.", "b": [0.4064, 0.6353, 0.434, 0.6567]}, {"w": "To", "b": [0.4409, 0.6353, 0.4623, 0.6567]}, {"w": "make", "b": [0.4692, 0.6353, 0.5146, 0.6567]}, {"w": "predictions,", "b": [0.5215, 0.6353, 0.6208, 0.6567]}, {"w": "you", "b": [0.6276, 0.6353, 0.6589, 0.6567]}, {"w": "just", "b": [0.6658, 0.6353, 0.6962, 0.6567]}, {"w": "obtain", "b": [0.703, 0.6353, 0.7567, 0.6567]}, {"w": "the", "b": [0.7636, 0.6353, 0.7899, 0.6567]}, {"w": "predic‐", "b": [0.7968, 0.6353, 0.8571, 0.6567]}, {"w": "tions", "b": [0.1428, 0.6544, 0.1845, 0.6758]}, {"w": "of", "b": [0.1895, 0.6544, 0.2063, 0.6758]}, {"w": "all", "b": [0.2114, 0.6544, 0.2311, 0.6758]}, {"w": "individual", "b": [0.2362, 0.6544, 0.3214, 0.6758]}, {"w": "trees,", "b": [0.3265, 0.6544, 0.3707, 0.6758]}, {"w": "then", "b": [0.3758, 0.6544, 0.4135, 0.6758]}, {"w": "predict", "b": [0.4186, 0.6544, 0.4778, 0.6758]}, {"w": "the", "b": [0.4829, 0.6544, 0.5093, 0.6758]}, {"w": "class", "b": [0.5143, 0.6544, 0.5529, 0.6758]}, {"w": "that", "b": [0.5579, 0.6544, 0.5905, 0.6758]}, {"w": "gets", "b": [0.5956, 0.6544, 0.6282, 0.6758]}, {"w": "the", "b": [0.6333, 0.6544, 0.6596, 0.6758]}, {"w": "most", "b": [0.6647, 0.6544, 0.7064, 0.6758]}, {"w": "votes", "b": [0.7115, 0.6544, 0.7546, 0.6758]}, {"w": "(see", "b": [0.7597, 0.6544, 0.7922, 0.6758]}, {"w": "the", "b": [0.7973, 0.6544, 0.8236, 0.6758]}, {"w": "last", "b": [0.8287, 0.6544, 0.8571, 0.6758]}, {"w": "exercise", "b": [0.1429, 0.6734, 0.209, 0.6948]}, {"w": "in", "b": [0.2138, 0.6734, 0.2307, 0.6948]}, {"w": "Chapter", "b": [0.2358, 0.6734, 0.3033, 0.6948]}, {"w": "6).", "b": [0.3081, 0.6734, 0.3302, 0.6948]}, {"w": "Such", "b": [0.3351, 0.6734, 0.3759, 0.6948]}, {"w": "an", "b": [0.3808, 0.6734, 0.4013, 0.6948]}, {"w": "ensemble", "b": [0.4062, 0.6734, 0.4847, 0.6948]}, {"w": "of", "b": [0.4896, 0.6734, 0.5064, 0.6948]}, {"w": "Decision", "b": [0.5113, 0.6734, 0.5851, 0.6948]}, {"w": "Trees", "b": [0.59, 0.6734, 0.6342, 0.6948]}, {"w": "is", "b": [0.639, 0.6734, 0.6523, 0.6948]}, {"w": "called", "b": [0.6572, 0.6734, 0.7055, 0.6948]}, {"w": "a", "b": [0.7104, 0.6734, 0.7195, 0.6948]}, {"w": "Random", "b": [0.7244, 0.6732, 0.7941, 0.6948]}, {"w": "Forest,", "b": [0.7989, 0.6732, 0.8523, 0.6948]}, {"w": "and", "b": [0.1429, 0.6925, 0.1744, 0.7139]}, {"w": "despite", "b": [0.1816, 0.6925, 0.2408, 0.7139]}, {"w": "its", "b": [0.248, 0.6925, 0.2676, 0.7139]}, {"w": "simplicity,", "b": [0.2748, 0.6925, 0.3601, 0.7139]}, {"w": "this", "b": [0.3673, 0.6925, 0.398, 0.7139]}, {"w": "is", "b": [0.4052, 0.6925, 0.4184, 0.7139]}, {"w": "one", "b": [0.4256, 0.6925, 0.4565, 0.7139]}, {"w": "of", "b": [0.4637, 0.6925, 0.4805, 0.7139]}, {"w": "the", "b": [0.4877, 0.6925, 0.5141, 0.7139]}, {"w": "most", "b": [0.5213, 0.6925, 0.563, 0.7139]}, {"w": "powerful", "b": [0.5702, 0.6925, 0.6451, 0.7139]}, {"w": "Machine", "b": [0.6523, 0.6925, 0.7254, 0.7139]}, {"w": "Learning", "b": [0.7327, 0.6925, 0.8077, 0.7139]}, {"w": "algo‐", "b": [0.8149, 0.6925, 0.8571, 0.7139]}, {"w": "rithms", "b": [0.1429, 0.7115, 0.1984, 0.7329]}, {"w": "available", "b": [0.2031, 0.7115, 0.2754, 0.7329]}, {"w": "today.", "b": [0.2801, 0.7115, 0.3296, 0.7329]}]}, {"id": "b_4", "type": "paragraph", "text": "Moreover, as we discussed in Chapter 2, you will often use Ensemble methods near the end of a project, once you have already built a few good predictors, to combine them into an even better predictor. In fact, the winning solutions in Machine Learn‐ ing competitions often involve several Ensemble methods (most famously in the Net‐ flix Prize competition).", "words": [{"w": "Moreover,", "b": [0.1429, 0.7396, 0.2284, 0.761]}, {"w": "as", "b": [0.235, 0.7396, 0.2518, 0.761]}, {"w": "we", "b": [0.2585, 0.7396, 0.2816, 0.761]}, {"w": "discussed", "b": [0.2882, 0.7396, 0.3675, 0.761]}, {"w": "in", "b": [0.3741, 0.7396, 0.3911, 0.761]}, {"w": "Chapter", "b": [0.3977, 0.7396, 0.4653, 0.761]}, {"w": "2,", "b": [0.472, 0.7396, 0.4867, 0.761]}, {"w": "you", "b": [0.4934, 0.7396, 0.5246, 0.761]}, {"w": "will", "b": [0.5313, 0.7396, 0.5617, 0.761]}, {"w": "often", "b": [0.5683, 0.7396, 0.6117, 0.761]}, {"w": "use", "b": [0.6184, 0.7396, 0.6459, 0.761]}, {"w": "Ensemble", "b": [0.6526, 0.7396, 0.7341, 0.761]}, {"w": "methods", "b": [0.7407, 0.7396, 0.8134, 0.761]}, {"w": "near", "b": [0.82, 0.7396, 0.8571, 0.761]}, {"w": "the", "b": [0.1428, 0.7587, 0.1692, 0.7801]}, {"w": "end", "b": [0.1757, 0.7587, 0.207, 0.7801]}, {"w": "of", "b": [0.2135, 0.7587, 0.2303, 0.7801]}, {"w": "a", "b": [0.2369, 0.7587, 0.246, 0.7801]}, {"w": "project,", "b": [0.2525, 0.7587, 0.3159, 0.7801]}, {"w": "once", "b": [0.3225, 0.7587, 0.3622, 0.7801]}, {"w": "you", "b": [0.3687, 0.7587, 0.3999, 0.7801]}, {"w": "have", "b": [0.4065, 0.7587, 0.4449, 0.7801]}, {"w": "already", "b": [0.4515, 0.7587, 0.5122, 0.7801]}, {"w": "built", "b": [0.5187, 0.7587, 0.5576, 0.7801]}, {"w": "a", "b": [0.5641, 0.7587, 0.5732, 0.7801]}, {"w": "few", "b": [0.5798, 0.7587, 0.6091, 0.7801]}, {"w": "good", "b": [0.6156, 0.7587, 0.6576, 0.7801]}, {"w": "predictors,", "b": [0.6642, 0.7587, 0.7542, 0.7801]}, {"w": "to", "b": [0.7607, 0.7587, 0.7777, 0.7801]}, {"w": "combine", "b": [0.7842, 0.7587, 0.8572, 0.7801]}, {"w": "them", "b": [0.1429, 0.7777, 0.1863, 0.7991]}, {"w": "into", "b": [0.1922, 0.7777, 0.2257, 0.7991]}, {"w": "an", "b": [0.2316, 0.7777, 0.2522, 0.7991]}, {"w": "even", "b": [0.2581, 0.7777, 0.2968, 0.7991]}, {"w": "better", "b": [0.3027, 0.7777, 0.3515, 0.7991]}, {"w": "predictor.", "b": [0.3574, 0.7777, 0.4384, 0.7991]}, {"w": "In", "b": [0.4443, 0.7777, 0.4628, 0.7991]}, {"w": "fact,", "b": [0.4687, 0.7777, 0.5039, 0.7991]}, {"w": "the", "b": [0.5099, 0.7777, 0.5362, 0.7991]}, {"w": "winning", "b": [0.5421, 0.7777, 0.6115, 0.7991]}, {"w": "solutions", "b": [0.6174, 0.7777, 0.6936, 0.7991]}, {"w": "in", "b": [0.6995, 0.7777, 0.7165, 0.7991]}, {"w": "Machine", "b": [0.7224, 0.7777, 0.7955, 0.7991]}, {"w": "Learn‐", "b": [0.8014, 0.7777, 0.8571, 0.7991]}, {"w": "ing", "b": [0.1429, 0.7968, 0.1696, 0.8182]}, {"w": "competitions", "b": [0.1747, 0.7968, 0.2841, 0.8182]}, {"w": "often", "b": [0.2893, 0.7968, 0.3327, 0.8182]}, {"w": "involve", "b": [0.3378, 0.7968, 0.3984, 0.8182]}, {"w": "several", "b": [0.4035, 0.7968, 0.4607, 0.8182]}, {"w": "Ensemble", "b": [0.4658, 0.7968, 0.5473, 0.8182]}, {"w": "methods", "b": [0.5524, 0.7968, 0.6251, 0.8182]}, {"w": "(most", "b": [0.6302, 0.7968, 0.6791, 0.8182]}, {"w": "famously", "b": [0.6843, 0.7968, 0.7608, 0.8182]}, {"w": "in", "b": [0.766, 0.7968, 0.7829, 0.8182]}, {"w": "the", "b": [0.7881, 0.7968, 0.8144, 0.8182]}, {"w": "Net‐", "b": [0.8196, 0.7968, 0.8571, 0.8182]}, {"w": "flix", "b": [0.1429, 0.8158, 0.1697, 0.8372]}, {"w": "Prize", "b": [0.1744, 0.8158, 0.2171, 0.8372]}, {"w": "competition).", "b": [0.2218, 0.8158, 0.3355, 0.8372]}]}, {"id": "b_5", "type": "paragraph", "text": "In this chapter we will discuss the most popular Ensemble methods, including bag‐ ging, boosting, stacking, and a few others. We will also explore Random Forests.", "words": [{"w": "In", "b": [0.1429, 0.8439, 0.1614, 0.8654]}, {"w": "this", "b": [0.1681, 0.8439, 0.1989, 0.8654]}, {"w": "chapter", "b": [0.2056, 0.8439, 0.2682, 0.8654]}, {"w": "we", "b": [0.275, 0.8439, 0.2981, 0.8654]}, {"w": "will", "b": [0.3049, 0.8439, 0.3353, 0.8654]}, {"w": "discuss", "b": [0.3421, 0.8439, 0.4015, 0.8654]}, {"w": "the", "b": [0.4083, 0.8439, 0.4346, 0.8654]}, {"w": "most", "b": [0.4414, 0.8439, 0.4831, 0.8654]}, {"w": "popular", "b": [0.4899, 0.8439, 0.5556, 0.8654]}, {"w": "Ensemble", "b": [0.5624, 0.8439, 0.6439, 0.8654]}, {"w": "methods,", "b": [0.6507, 0.8439, 0.7281, 0.8654]}, {"w": "including", "b": [0.7349, 0.8439, 0.8147, 0.8654]}, {"w": "bag‐", "b": [0.8215, 0.8437, 0.8571, 0.8654]}, {"w": "ging,", "b": [0.1429, 0.8628, 0.1815, 0.8844]}, {"w": "boosting,", "b": [0.1862, 0.8628, 0.2584, 0.8844]}, {"w": "stacking,", "b": [0.2631, 0.8628, 0.333, 0.8844]}, {"w": "and", "b": [0.3378, 0.863, 0.3693, 0.8844]}, {"w": "a", "b": [0.374, 0.863, 0.3832, 0.8844]}, {"w": "few", "b": [0.3879, 0.863, 0.4172, 0.8844]}, {"w": "others.", "b": [0.4219, 0.863, 0.479, 0.8844]}, {"w": "We", "b": [0.4837, 0.863, 0.5108, 0.8844]}, {"w": "will", "b": [0.5155, 0.863, 0.5459, 0.8844]}, {"w": "also", "b": [0.5507, 0.863, 0.5833, 0.8844]}, {"w": "explore", "b": [0.5881, 0.863, 0.6502, 0.8844]}, {"w": "Random", "b": [0.6549, 0.863, 0.7274, 0.8844]}, {"w": "Forests.", "b": [0.7322, 0.863, 0.7964, 0.8844]}]}, {"id": "b_6", "type": "paragraph", "text": "191", "words": [{"w": "191", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 218, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Voting Classifiers", "words": [{"w": "Voting", "b": [0.1429, 0.0753, 0.2254, 0.1095]}, {"w": "Classifiers", "b": [0.2313, 0.0753, 0.3531, 0.1095]}]}, {"id": "b_1", "type": "paragraph", "text": "Suppose you have trained a few classifiers, each one achieving about 80% accuracy. You may have a Logistic Regression classifier, an SVM classifier, a Random Forest classifier, a K-Nearest Neighbors classifier, and perhaps a few more (see Figure 7-1).", "words": [{"w": "Suppose", "b": [0.1429, 0.1164, 0.2127, 0.1378]}, {"w": "you", "b": [0.2197, 0.1164, 0.2509, 0.1378]}, {"w": "have", "b": [0.2578, 0.1164, 0.2962, 0.1378]}, {"w": "trained", "b": [0.3031, 0.1164, 0.3632, 0.1378]}, {"w": "a", "b": [0.3701, 0.1164, 0.3792, 0.1378]}, {"w": "few", "b": [0.3861, 0.1164, 0.4154, 0.1378]}, {"w": "classifiers,", "b": [0.4223, 0.1164, 0.5072, 0.1378]}, {"w": "each", "b": [0.5141, 0.1164, 0.552, 0.1378]}, {"w": "one", "b": [0.5589, 0.1164, 0.5898, 0.1378]}, {"w": "achieving", "b": [0.5967, 0.1164, 0.6766, 0.1378]}, {"w": "about", "b": [0.6835, 0.1164, 0.7313, 0.1378]}, {"w": "80%", "b": [0.7382, 0.1164, 0.7739, 0.1378]}, {"w": "accuracy.", "b": [0.7808, 0.1164, 0.8571, 0.1378]}, {"w": "You", "b": [0.1429, 0.1355, 0.1752, 0.1569]}, {"w": "may", "b": [0.183, 0.1355, 0.2184, 0.1569]}, {"w": "have", "b": [0.2262, 0.1355, 0.2646, 0.1569]}, {"w": "a", "b": [0.2724, 0.1355, 0.2815, 0.1569]}, {"w": "Logistic", "b": [0.2893, 0.1355, 0.3549, 0.1569]}, {"w": "Regression", "b": [0.3627, 0.1355, 0.4537, 0.1569]}, {"w": "classifier,", "b": [0.4615, 0.1355, 0.5374, 0.1569]}, {"w": "an", "b": [0.5452, 0.1355, 0.5657, 0.1569]}, {"w": "SVM", "b": [0.5735, 0.1355, 0.6166, 0.1569]}, {"w": "classifier,", "b": [0.6244, 0.1355, 0.7003, 0.1569]}, {"w": "a", "b": [0.708, 0.1355, 0.7172, 0.1569]}, {"w": "Random", "b": [0.725, 0.1355, 0.7975, 0.1569]}, {"w": "Forest", "b": [0.8053, 0.1355, 0.8572, 0.1569]}, {"w": "classifier,", "b": [0.1429, 0.1545, 0.2187, 0.1759]}, {"w": "a", "b": [0.2235, 0.1545, 0.2326, 0.1759]}, {"w": "K-Nearest", "b": [0.2373, 0.1545, 0.3223, 0.1759]}, {"w": "Neighbors", "b": [0.327, 0.1545, 0.4139, 0.1759]}, {"w": "classifier,", "b": [0.4186, 0.1545, 0.4945, 0.1759]}, {"w": "and", "b": [0.4992, 0.1545, 0.5308, 0.1759]}, {"w": "perhaps", "b": [0.5355, 0.1545, 0.6014, 0.1759]}, {"w": "a", "b": [0.6062, 0.1545, 0.6153, 0.1759]}, {"w": "few", "b": [0.62, 0.1545, 0.6493, 0.1759]}, {"w": "more", "b": [0.6541, 0.1545, 0.6983, 0.1759]}, {"w": "(see", "b": [0.7031, 0.1545, 0.7356, 0.1759]}, {"w": "Figure", "b": [0.7404, 0.1545, 0.7944, 0.1759]}, {"w": "7-1).", "b": [0.7991, 0.1545, 0.8385, 0.1759]}]}, {"id": "b_2", "type": "equation", "text": "Figure 7-1. Training diverse classifiers", "words": [{"w": "Figure", "b": [0.1429, 0.4291, 0.1943, 0.4507]}, {"w": "7-1.", "b": [0.1991, 0.4291, 0.2308, 0.4507]}, {"w": "Training", "b": [0.2356, 0.4291, 0.3048, 0.4507]}, {"w": "diverse", "b": [0.3096, 0.4291, 0.3658, 0.4507]}, {"w": "classifiers", "b": [0.3705, 0.4291, 0.4477, 0.4507]}]}, {"id": "b_3", "type": "paragraph", "text": "A very simple way to create an even better classifier is to aggregate the predictions of each classifier and predict the class that gets the most votes. This majority-vote classi‐ fier is called a hard voting classifier (see Figure 7-2).", "words": [{"w": "A", "b": [0.1429, 0.4665, 0.1573, 0.4879]}, {"w": "very", "b": [0.1627, 0.4665, 0.1991, 0.4879]}, {"w": "simple", "b": [0.2046, 0.4665, 0.2596, 0.4879]}, {"w": "way", "b": [0.2651, 0.4665, 0.2977, 0.4879]}, {"w": "to", "b": [0.3032, 0.4665, 0.3201, 0.4879]}, {"w": "create", "b": [0.3256, 0.4665, 0.375, 0.4879]}, {"w": "an", "b": [0.3805, 0.4665, 0.401, 0.4879]}, {"w": "even", "b": [0.4065, 0.4665, 0.4453, 0.4879]}, {"w": "better", "b": [0.4508, 0.4665, 0.4995, 0.4879]}, {"w": "classifier", "b": [0.505, 0.4665, 0.5774, 0.4879]}, {"w": "is", "b": [0.5829, 0.4665, 0.5961, 0.4879]}, {"w": "to", "b": [0.6016, 0.4665, 0.6186, 0.4879]}, {"w": "aggregate", "b": [0.6241, 0.4665, 0.703, 0.4879]}, {"w": "the", "b": [0.7085, 0.4665, 0.7349, 0.4879]}, {"w": "predictions", "b": [0.7404, 0.4665, 0.8349, 0.4879]}, {"w": "of", "b": [0.8404, 0.4665, 0.8571, 0.4879]}, {"w": "each", "b": [0.1429, 0.4855, 0.1808, 0.5069]}, {"w": "classifier", "b": [0.1858, 0.4855, 0.2582, 0.5069]}, {"w": "and", "b": [0.2632, 0.4855, 0.2947, 0.5069]}, {"w": "predict", "b": [0.2997, 0.4855, 0.3589, 0.5069]}, {"w": "the", "b": [0.3639, 0.4855, 0.3902, 0.5069]}, {"w": "class", "b": [0.3952, 0.4855, 0.4337, 0.5069]}, {"w": "that", "b": [0.4387, 0.4855, 0.4713, 0.5069]}, {"w": "gets", "b": [0.4762, 0.4855, 0.5088, 0.5069]}, {"w": "the", "b": [0.5138, 0.4855, 0.5401, 0.5069]}, {"w": "most", "b": [0.5451, 0.4855, 0.5868, 0.5069]}, {"w": "votes.", "b": [0.5917, 0.4855, 0.6396, 0.5069]}, {"w": "This", "b": [0.6446, 0.4855, 0.6818, 0.5069]}, {"w": "majority-vote", "b": [0.6868, 0.4855, 0.8007, 0.5069]}, {"w": "classi‐", "b": [0.8056, 0.4855, 0.8571, 0.5069]}, {"w": "fier", "b": [0.1428, 0.5046, 0.1712, 0.526]}, {"w": "is", "b": [0.1759, 0.5046, 0.1891, 0.526]}, {"w": "called", "b": [0.1939, 0.5046, 0.2422, 0.526]}, {"w": "a", "b": [0.247, 0.5046, 0.2561, 0.526]}, {"w": "hard", "b": [0.2608, 0.5044, 0.299, 0.526]}, {"w": "voting", "b": [0.3038, 0.5044, 0.3537, 0.526]}, {"w": "classifier", "b": [0.3585, 0.5046, 0.4309, 0.526]}, {"w": "(see", "b": [0.4356, 0.5046, 0.4682, 0.526]}, {"w": "Figure", "b": [0.4729, 0.5046, 0.5269, 0.526]}, {"w": "7-2).", "b": [0.5317, 0.5046, 0.571, 0.526]}]}, {"id": "b_4", "type": "equation", "text": "Figure 7-2. Hard voting classifier predictions", "words": [{"w": "Figure", "b": [0.1428, 0.833, 0.1943, 0.8546]}, {"w": "7-2.", "b": [0.1991, 0.833, 0.2308, 0.8546]}, {"w": "Hard", "b": [0.2356, 0.833, 0.2781, 0.8546]}, {"w": "voting", "b": [0.2828, 0.833, 0.3328, 0.8546]}, {"w": "classifier", "b": [0.3376, 0.833, 0.4077, 0.8546]}, {"w": "predictions", "b": [0.4124, 0.833, 0.5012, 0.8546]}]}, {"id": "b_5", "type": "paragraph", "text": "192 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "192", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 219, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Somewhat surprisingly, this voting classifier often achieves a higher accuracy than the best classifier in the ensemble. In fact, even if each classifier is a weak learner (mean‐ ing it does only slightly better than random guessing), the ensemble can still be a strong learner (achieving high accuracy), provided there are a sufficient number of weak learners and they are sufficiently diverse.", "words": [{"w": "Somewhat", "b": [0.1429, 0.0791, 0.2298, 0.1005]}, {"w": "surprisingly,", "b": [0.2347, 0.0791, 0.3378, 0.1005]}, {"w": "this", "b": [0.3427, 0.0791, 0.3734, 0.1005]}, {"w": "voting", "b": [0.3783, 0.0791, 0.4317, 0.1005]}, {"w": "classifier", "b": [0.4366, 0.0791, 0.509, 0.1005]}, {"w": "often", "b": [0.5139, 0.0791, 0.5573, 0.1005]}, {"w": "achieves", "b": [0.5622, 0.0791, 0.6319, 0.1005]}, {"w": "a", "b": [0.6368, 0.0791, 0.6459, 0.1005]}, {"w": "higher", "b": [0.6508, 0.0791, 0.705, 0.1005]}, {"w": "accuracy", "b": [0.7099, 0.0791, 0.783, 0.1005]}, {"w": "than", "b": [0.7879, 0.0791, 0.8259, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}, {"w": "best", "b": [0.1429, 0.0981, 0.1763, 0.1195]}, {"w": "classifier", "b": [0.1819, 0.0981, 0.2543, 0.1195]}, {"w": "in", "b": [0.2599, 0.0981, 0.2769, 0.1195]}, {"w": "the", "b": [0.2825, 0.0981, 0.3088, 0.1195]}, {"w": "ensemble.", "b": [0.3144, 0.0981, 0.3977, 0.1195]}, {"w": "In", "b": [0.4033, 0.0981, 0.4218, 0.1195]}, {"w": "fact,", "b": [0.4274, 0.0981, 0.4626, 0.1195]}, {"w": "even", "b": [0.4682, 0.0981, 0.507, 0.1195]}, {"w": "if", "b": [0.5126, 0.0981, 0.5243, 0.1195]}, {"w": "each", "b": [0.5299, 0.0981, 0.5679, 0.1195]}, {"w": "classifier", "b": [0.5735, 0.0981, 0.6459, 0.1195]}, {"w": "is", "b": [0.6515, 0.0981, 0.6647, 0.1195]}, {"w": "a", "b": [0.6703, 0.0981, 0.6795, 0.1195]}, {"w": "weak", "b": [0.6851, 0.0979, 0.7269, 0.1195]}, {"w": "learner", "b": [0.7326, 0.0979, 0.7905, 0.1195]}, {"w": "(mean‐", "b": [0.7961, 0.0981, 0.8571, 0.1195]}, {"w": "ing", "b": [0.1429, 0.1172, 0.1696, 0.1386]}, {"w": "it", "b": [0.1775, 0.1172, 0.1894, 0.1386]}, {"w": "does", "b": [0.1973, 0.1172, 0.2354, 0.1386]}, {"w": "only", "b": [0.2433, 0.1172, 0.2801, 0.1386]}, {"w": "slightly", "b": [0.288, 0.1172, 0.3482, 0.1386]}, {"w": "better", "b": [0.356, 0.1172, 0.4048, 0.1386]}, {"w": "than", "b": [0.4126, 0.1172, 0.4507, 0.1386]}, {"w": "random", "b": [0.4585, 0.1172, 0.5255, 0.1386]}, {"w": "guessing),", "b": [0.5334, 0.1172, 0.617, 0.1386]}, {"w": "the", "b": [0.6249, 0.1172, 0.6512, 0.1386]}, {"w": "ensemble", "b": [0.6591, 0.1172, 0.7376, 0.1386]}, {"w": "can", "b": [0.7455, 0.1172, 0.7748, 0.1386]}, {"w": "still", "b": [0.7827, 0.1172, 0.8128, 0.1386]}, {"w": "be", "b": [0.8207, 0.1172, 0.8401, 0.1386]}, {"w": "a", "b": [0.848, 0.1172, 0.8572, 0.1386]}, {"w": "strong", "b": [0.1429, 0.136, 0.1923, 0.1576]}, {"w": "learner", "b": [0.1999, 0.136, 0.2578, 0.1576]}, {"w": "(achieving", "b": [0.2654, 0.1362, 0.3525, 0.1576]}, {"w": "high", "b": [0.3601, 0.1362, 0.3977, 0.1576]}, {"w": "accuracy),", "b": [0.4053, 0.1362, 0.4904, 0.1576]}, {"w": "provided", "b": [0.498, 0.1362, 0.5734, 0.1576]}, {"w": "there", "b": [0.581, 0.1362, 0.6239, 0.1576]}, {"w": "are", "b": [0.6315, 0.1362, 0.6572, 0.1576]}, {"w": "a", "b": [0.6648, 0.1362, 0.674, 0.1576]}, {"w": "sufficient", "b": [0.6816, 0.1362, 0.7588, 0.1576]}, {"w": "number", "b": [0.7664, 0.1362, 0.8327, 0.1576]}, {"w": "of", "b": [0.8404, 0.1362, 0.8571, 0.1576]}, {"w": "weak", "b": [0.1429, 0.1553, 0.1855, 0.1767]}, {"w": "learners", "b": [0.1902, 0.1553, 0.2568, 0.1767]}, {"w": "and", "b": [0.2615, 0.1553, 0.2931, 0.1767]}, {"w": "they", "b": [0.2978, 0.1553, 0.3337, 0.1767]}, {"w": "are", "b": [0.3384, 0.1553, 0.3642, 0.1767]}, {"w": "sufficiently", "b": [0.3689, 0.1553, 0.461, 0.1767]}, {"w": "diverse.", "b": [0.4657, 0.1553, 0.5298, 0.1767]}]}, {"id": "b_1", "type": "paragraph", "text": "How is this possible? The following analogy can help shed some light on this mystery. Suppose you have a slightly biased coin that has a 51% chance of coming up heads, and 49% chance of coming up tails. If you toss it 1,000 times, you will generally get more or less 510 heads and 490 tails, and hence a majority of heads. If you do the math, you will find that the probability of obtaining a majority of heads after 1,000 tosses is close to 75%. The more you toss the coin, the higher the probability (e.g., with 10,000 tosses, the probability climbs over 97%). This is due to the law of large numbers: as you keep tossing the coin, the ratio of heads gets closer and closer to the probability of heads (51%). Figure 7-3 shows 10 series of biased coin tosses. You can see that as the number of tosses increases, the ratio of heads approaches 51%. Eventu‐ ally all 10 series end up so close to 51% that they are consistently above 50%.", "words": [{"w": "How", "b": [0.1429, 0.1834, 0.1832, 0.2048]}, {"w": "is", "b": [0.1881, 0.1834, 0.2013, 0.2048]}, {"w": "this", "b": [0.2063, 0.1834, 0.237, 0.2048]}, {"w": "possible?", "b": [0.2419, 0.1834, 0.3169, 0.2048]}, {"w": "The", "b": [0.3218, 0.1834, 0.3547, 0.2048]}, {"w": "following", "b": [0.3596, 0.1834, 0.4386, 0.2048]}, {"w": "analogy", "b": [0.4435, 0.1834, 0.5089, 0.2048]}, {"w": "can", "b": [0.5138, 0.1834, 0.5432, 0.2048]}, {"w": "help", "b": [0.5481, 0.1834, 0.5842, 0.2048]}, {"w": "shed", "b": [0.5892, 0.1834, 0.6278, 0.2048]}, {"w": "some", "b": [0.6327, 0.1834, 0.6769, 0.2048]}, {"w": "light", "b": [0.6818, 0.1834, 0.7195, 0.2048]}, {"w": "on", "b": [0.7244, 0.1834, 0.7465, 0.2048]}, {"w": "this", "b": [0.7514, 0.1834, 0.7821, 0.2048]}, {"w": "mystery.", "b": [0.787, 0.1834, 0.8571, 0.2048]}, {"w": "Suppose", "b": [0.1428, 0.2024, 0.2127, 0.2238]}, {"w": "you", "b": [0.2193, 0.2024, 0.2505, 0.2238]}, {"w": "have", "b": [0.2571, 0.2024, 0.2955, 0.2238]}, {"w": "a", "b": [0.302, 0.2024, 0.3112, 0.2238]}, {"w": "slightly", "b": [0.3177, 0.2024, 0.3779, 0.2238]}, {"w": "biased", "b": [0.3844, 0.2024, 0.4372, 0.2238]}, {"w": "coin", "b": [0.4438, 0.2024, 0.4802, 0.2238]}, {"w": "that", "b": [0.4867, 0.2024, 0.5193, 0.2238]}, {"w": "has", "b": [0.5259, 0.2024, 0.5538, 0.2238]}, {"w": "a", "b": [0.5603, 0.2024, 0.5695, 0.2238]}, {"w": "51%", "b": [0.576, 0.2024, 0.6118, 0.2238]}, {"w": "chance", "b": [0.6183, 0.2024, 0.6764, 0.2238]}, {"w": "of", "b": [0.683, 0.2024, 0.6998, 0.2238]}, {"w": "coming", "b": [0.7063, 0.2024, 0.7696, 0.2238]}, {"w": "up", "b": [0.7761, 0.2024, 0.7981, 0.2238]}, {"w": "heads,", "b": [0.8046, 0.2024, 0.8571, 0.2238]}, {"w": "and", "b": [0.1429, 0.2215, 0.1744, 0.2429]}, {"w": "49%", "b": [0.1808, 0.2215, 0.2165, 0.2429]}, {"w": "chance", "b": [0.2229, 0.2215, 0.281, 0.2429]}, {"w": "of", "b": [0.2874, 0.2215, 0.3042, 0.2429]}, {"w": "coming", "b": [0.3106, 0.2215, 0.3738, 0.2429]}, {"w": "up", "b": [0.3802, 0.2215, 0.4022, 0.2429]}, {"w": "tails.", "b": [0.4085, 0.2215, 0.4473, 0.2429]}, {"w": "If", "b": [0.4536, 0.2215, 0.4669, 0.2429]}, {"w": "you", "b": [0.4733, 0.2215, 0.5045, 0.2429]}, {"w": "toss", "b": [0.5109, 0.2215, 0.5432, 0.2429]}, {"w": "it", "b": [0.5496, 0.2215, 0.5615, 0.2429]}, {"w": "1,000", "b": [0.5679, 0.2215, 0.6126, 0.2429]}, {"w": "times,", "b": [0.619, 0.2215, 0.6692, 0.2429]}, {"w": "you", "b": [0.6756, 0.2215, 0.7069, 0.2429]}, {"w": "will", "b": [0.7132, 0.2215, 0.7436, 0.2429]}, {"w": "generally", "b": [0.75, 0.2215, 0.8258, 0.2429]}, {"w": "get", "b": [0.8322, 0.2215, 0.8572, 0.2429]}, {"w": "more", "b": [0.1429, 0.2405, 0.1871, 0.2619]}, {"w": "or", "b": [0.1943, 0.2405, 0.2126, 0.2619]}, {"w": "less", "b": [0.2198, 0.2405, 0.2492, 0.2619]}, {"w": "510", "b": [0.2564, 0.2405, 0.2864, 0.2619]}, {"w": "heads", "b": [0.2935, 0.2405, 0.3413, 0.2619]}, {"w": "and", "b": [0.3485, 0.2405, 0.38, 0.2619]}, {"w": "490", "b": [0.3872, 0.2405, 0.4172, 0.2619]}, {"w": "tails,", "b": [0.4243, 0.2405, 0.4631, 0.2619]}, {"w": "and", "b": [0.4702, 0.2405, 0.5018, 0.2619]}, {"w": "hence", "b": [0.5089, 0.2405, 0.558, 0.2619]}, {"w": "a", "b": [0.5651, 0.2405, 0.5743, 0.2619]}, {"w": "majority", "b": [0.5814, 0.2405, 0.6524, 0.2619]}, {"w": "of", "b": [0.6596, 0.2405, 0.6764, 0.2619]}, {"w": "heads.", "b": [0.6835, 0.2405, 0.736, 0.2619]}, {"w": "If", "b": [0.7432, 0.2405, 0.7565, 0.2619]}, {"w": "you", "b": [0.7636, 0.2405, 0.7949, 0.2619]}, {"w": "do", "b": [0.802, 0.2405, 0.8237, 0.2619]}, {"w": "the", "b": [0.8308, 0.2405, 0.8571, 0.2619]}, {"w": "math,", "b": [0.1429, 0.2596, 0.1909, 0.281]}, {"w": "you", "b": [0.1977, 0.2596, 0.2289, 0.281]}, {"w": "will", "b": [0.2357, 0.2596, 0.2661, 0.281]}, {"w": "find", "b": [0.2728, 0.2596, 0.307, 0.281]}, {"w": "that", "b": [0.3137, 0.2596, 0.3463, 0.281]}, {"w": "the", "b": [0.3531, 0.2596, 0.3794, 0.281]}, {"w": "probability", "b": [0.3862, 0.2596, 0.4781, 0.281]}, {"w": "of", "b": [0.4849, 0.2596, 0.5017, 0.281]}, {"w": "obtaining", "b": [0.5084, 0.2596, 0.5889, 0.281]}, {"w": "a", "b": [0.5956, 0.2596, 0.6048, 0.281]}, {"w": "majority", "b": [0.6115, 0.2596, 0.6825, 0.281]}, {"w": "of", "b": [0.6893, 0.2596, 0.7061, 0.281]}, {"w": "heads", "b": [0.7128, 0.2596, 0.7606, 0.281]}, {"w": "after", "b": [0.7674, 0.2596, 0.8056, 0.281]}, {"w": "1,000", "b": [0.8124, 0.2596, 0.8571, 0.281]}, {"w": "tosses", "b": [0.1429, 0.2786, 0.1916, 0.3]}, {"w": "is", "b": [0.1987, 0.2786, 0.212, 0.3]}, {"w": "close", "b": [0.2191, 0.2786, 0.2603, 0.3]}, {"w": "to", "b": [0.2674, 0.2786, 0.2844, 0.3]}, {"w": "75%.", "b": [0.2915, 0.2786, 0.332, 0.3]}, {"w": "The", "b": [0.3391, 0.2786, 0.3719, 0.3]}, {"w": "more", "b": [0.379, 0.2786, 0.4233, 0.3]}, {"w": "you", "b": [0.4304, 0.2786, 0.4617, 0.3]}, {"w": "toss", "b": [0.4688, 0.2786, 0.5011, 0.3]}, {"w": "the", "b": [0.5082, 0.2786, 0.5345, 0.3]}, {"w": "coin,", "b": [0.5416, 0.2786, 0.5828, 0.3]}, {"w": "the", "b": [0.5899, 0.2786, 0.6162, 0.3]}, {"w": "higher", "b": [0.6233, 0.2786, 0.6775, 0.3]}, {"w": "the", "b": [0.6846, 0.2786, 0.7109, 0.3]}, {"w": "probability", "b": [0.718, 0.2786, 0.81, 0.3]}, {"w": "(e.g.,", "b": [0.8171, 0.2786, 0.8572, 0.3]}, {"w": "with", "b": [0.1429, 0.2977, 0.1802, 0.3191]}, {"w": "10,000", "b": [0.187, 0.2977, 0.2418, 0.3191]}, {"w": "tosses,", "b": [0.2486, 0.2977, 0.3021, 0.3191]}, {"w": "the", "b": [0.309, 0.2977, 0.3353, 0.3191]}, {"w": "probability", "b": [0.3422, 0.2977, 0.4341, 0.3191]}, {"w": "climbs", "b": [0.4409, 0.2977, 0.4959, 0.3191]}, {"w": "over", "b": [0.5027, 0.2977, 0.5396, 0.3191]}, {"w": "97%).", "b": [0.5464, 0.2977, 0.5941, 0.3191]}, {"w": "This", "b": [0.601, 0.2977, 0.6382, 0.3191]}, {"w": "is", "b": [0.645, 0.2977, 0.6583, 0.3191]}, {"w": "due", "b": [0.6651, 0.2977, 0.696, 0.3191]}, {"w": "to", "b": [0.7029, 0.2977, 0.7198, 0.3191]}, {"w": "the", "b": [0.7267, 0.2977, 0.753, 0.3191]}, {"w": "law", "b": [0.7598, 0.2974, 0.7886, 0.3191]}, {"w": "of", "b": [0.7955, 0.2974, 0.8107, 0.3191]}, {"w": "large", "b": [0.8176, 0.2974, 0.8571, 0.3191]}, {"w": "numbers:", "b": [0.1429, 0.3165, 0.2181, 0.3381]}, {"w": "as", "b": [0.2238, 0.3167, 0.2406, 0.3381]}, {"w": "you", "b": [0.2462, 0.3167, 0.2774, 0.3381]}, {"w": "keep", "b": [0.2831, 0.3167, 0.322, 0.3381]}, {"w": "tossing", "b": [0.3277, 0.3167, 0.3867, 0.3381]}, {"w": "the", "b": [0.3923, 0.3167, 0.4187, 0.3381]}, {"w": "coin,", "b": [0.4243, 0.3167, 0.4655, 0.3381]}, {"w": "the", "b": [0.4711, 0.3167, 0.4974, 0.3381]}, {"w": "ratio", "b": [0.5031, 0.3167, 0.5421, 0.3381]}, {"w": "of", "b": [0.5478, 0.3167, 0.5646, 0.3381]}, {"w": "heads", "b": [0.5702, 0.3167, 0.618, 0.3381]}, {"w": "gets", "b": [0.6236, 0.3167, 0.6562, 0.3381]}, {"w": "closer", "b": [0.6619, 0.3167, 0.7108, 0.3381]}, {"w": "and", "b": [0.7164, 0.3167, 0.748, 0.3381]}, {"w": "closer", "b": [0.7536, 0.3167, 0.8025, 0.3381]}, {"w": "to", "b": [0.8082, 0.3167, 0.8252, 0.3381]}, {"w": "the", "b": [0.8308, 0.3167, 0.8571, 0.3381]}, {"w": "probability", "b": [0.1429, 0.3358, 0.2348, 0.3572]}, {"w": "of", "b": [0.2407, 0.3358, 0.2575, 0.3572]}, {"w": "heads", "b": [0.2634, 0.3358, 0.3111, 0.3572]}, {"w": "(51%).", "b": [0.317, 0.3358, 0.372, 0.3572]}, {"w": "Figure", "b": [0.3779, 0.3358, 0.4319, 0.3572]}, {"w": "7-3", "b": [0.4378, 0.3358, 0.4652, 0.3572]}, {"w": "shows", "b": [0.4711, 0.3358, 0.5224, 0.3572]}, {"w": "10", "b": [0.5283, 0.3358, 0.5483, 0.3572]}, {"w": "series", "b": [0.5542, 0.3358, 0.6005, 0.3572]}, {"w": "of", "b": [0.6064, 0.3358, 0.6232, 0.3572]}, {"w": "biased", "b": [0.6291, 0.3358, 0.6819, 0.3572]}, {"w": "coin", "b": [0.6878, 0.3358, 0.7242, 0.3572]}, {"w": "tosses.", "b": [0.7301, 0.3358, 0.7836, 0.3572]}, {"w": "You", "b": [0.7895, 0.3358, 0.8219, 0.3572]}, {"w": "can", "b": [0.8278, 0.3358, 0.8571, 0.3572]}, {"w": "see", "b": [0.1429, 0.3548, 0.1682, 0.3762]}, {"w": "that", "b": [0.1732, 0.3548, 0.2058, 0.3762]}, {"w": "as", "b": [0.2108, 0.3548, 0.2276, 0.3762]}, {"w": "the", "b": [0.2326, 0.3548, 0.259, 0.3762]}, {"w": "number", "b": [0.264, 0.3548, 0.3303, 0.3762]}, {"w": "of", "b": [0.3353, 0.3548, 0.3521, 0.3762]}, {"w": "tosses", "b": [0.3571, 0.3548, 0.4059, 0.3762]}, {"w": "increases,", "b": [0.4109, 0.3548, 0.4913, 0.3762]}, {"w": "the", "b": [0.4963, 0.3548, 0.5227, 0.3762]}, {"w": "ratio", "b": [0.5277, 0.3548, 0.5667, 0.3762]}, {"w": "of", "b": [0.5717, 0.3548, 0.5885, 0.3762]}, {"w": "heads", "b": [0.5936, 0.3548, 0.6413, 0.3762]}, {"w": "approaches", "b": [0.6463, 0.3548, 0.7409, 0.3762]}, {"w": "51%.", "b": [0.7459, 0.3548, 0.7864, 0.3762]}, {"w": "Eventu‐", "b": [0.7914, 0.3548, 0.8572, 0.3762]}, {"w": "ally", "b": [0.1429, 0.3738, 0.1721, 0.3953]}, {"w": "all", "b": [0.1768, 0.3738, 0.1965, 0.3953]}, {"w": "10", "b": [0.2013, 0.3738, 0.2213, 0.3953]}, {"w": "series", "b": [0.226, 0.3738, 0.2723, 0.3953]}, {"w": "end", "b": [0.277, 0.3738, 0.3083, 0.3953]}, {"w": "up", "b": [0.313, 0.3738, 0.335, 0.3953]}, {"w": "so", "b": [0.3397, 0.3738, 0.358, 0.3953]}, {"w": "close", "b": [0.3627, 0.3738, 0.4039, 0.3953]}, {"w": "to", "b": [0.4087, 0.3738, 0.4256, 0.3953]}, {"w": "51%", "b": [0.4304, 0.3738, 0.4661, 0.3953]}, {"w": "that", "b": [0.4708, 0.3738, 0.5034, 0.3953]}, {"w": "they", "b": [0.5082, 0.3738, 0.544, 0.3953]}, {"w": "are", "b": [0.5488, 0.3738, 0.5745, 0.3953]}, {"w": "consistently", "b": [0.5792, 0.3738, 0.6783, 0.3953]}, {"w": "above", "b": [0.6831, 0.3738, 0.7319, 0.3953]}, {"w": "50%.", "b": [0.7367, 0.3738, 0.7772, 0.3953]}]}, {"id": "b_2", "type": "equation", "text": "Figure 7-3. The law of large numbers", "words": [{"w": "Figure", "b": [0.1429, 0.6341, 0.1943, 0.6557]}, {"w": "7-3.", "b": [0.1991, 0.6341, 0.2308, 0.6557]}, {"w": "The", "b": [0.2356, 0.6341, 0.2654, 0.6557]}, {"w": "law", "b": [0.2702, 0.6341, 0.299, 0.6557]}, {"w": "of", "b": [0.3038, 0.6341, 0.319, 0.6557]}, {"w": "large", "b": [0.3237, 0.6341, 0.3633, 0.6557]}, {"w": "numbers", "b": [0.368, 0.6341, 0.4386, 0.6557]}]}, {"id": "b_3", "type": "paragraph", "text": "Similarly, suppose you build an ensemble containing 1,000 classifiers that are individ‐ ually correct only 51% of the time (barely better than random guessing). If you pre‐ dict the majority voted class, you can hope for up to 75% accuracy! However, this is only true if all classifiers are perfectly independent, making uncorrelated errors, which is clearly not the case since they are trained on the same data. They are likely to make the same types of errors, so there will be many majority votes for the wrong class, reducing the ensemble’s accuracy.", "words": [{"w": "Similarly,", "b": [0.1429, 0.6715, 0.2212, 0.6929]}, {"w": "suppose", "b": [0.2261, 0.6715, 0.2938, 0.6929]}, {"w": "you", "b": [0.2987, 0.6715, 0.33, 0.6929]}, {"w": "build", "b": [0.3349, 0.6715, 0.3784, 0.6929]}, {"w": "an", "b": [0.3834, 0.6715, 0.4039, 0.6929]}, {"w": "ensemble", "b": [0.4089, 0.6715, 0.4874, 0.6929]}, {"w": "containing", "b": [0.4924, 0.6715, 0.582, 0.6929]}, {"w": "1,000", "b": [0.587, 0.6715, 0.6317, 0.6929]}, {"w": "classifiers", "b": [0.6367, 0.6715, 0.7168, 0.6929]}, {"w": "that", "b": [0.7217, 0.6715, 0.7543, 0.6929]}, {"w": "are", "b": [0.7593, 0.6715, 0.785, 0.6929]}, {"w": "individ‐", "b": [0.7899, 0.6715, 0.8571, 0.6929]}, {"w": "ually", "b": [0.1429, 0.6905, 0.1832, 0.7119]}, {"w": "correct", "b": [0.1893, 0.6905, 0.2482, 0.7119]}, {"w": "only", "b": [0.2544, 0.6905, 0.2913, 0.7119]}, {"w": "51%", "b": [0.2974, 0.6905, 0.3332, 0.7119]}, {"w": "of", "b": [0.3394, 0.6905, 0.3561, 0.7119]}, {"w": "the", "b": [0.3623, 0.6905, 0.3886, 0.7119]}, {"w": "time", "b": [0.3948, 0.6905, 0.4327, 0.7119]}, {"w": "(barely", "b": [0.4388, 0.6905, 0.4972, 0.7119]}, {"w": "better", "b": [0.5033, 0.6905, 0.5521, 0.7119]}, {"w": "than", "b": [0.5582, 0.6905, 0.5963, 0.7119]}, {"w": "random", "b": [0.6024, 0.6905, 0.6694, 0.7119]}, {"w": "guessing).", "b": [0.6756, 0.6905, 0.7592, 0.7119]}, {"w": "If", "b": [0.7654, 0.6905, 0.7786, 0.7119]}, {"w": "you", "b": [0.7848, 0.6905, 0.8161, 0.7119]}, {"w": "pre‐", "b": [0.8222, 0.6905, 0.8571, 0.7119]}, {"w": "dict", "b": [0.1429, 0.7096, 0.1746, 0.731]}, {"w": "the", "b": [0.1808, 0.7096, 0.2071, 0.731]}, {"w": "majority", "b": [0.2133, 0.7096, 0.2843, 0.731]}, {"w": "voted", "b": [0.2904, 0.7096, 0.3369, 0.731]}, {"w": "class,", "b": [0.3431, 0.7096, 0.3864, 0.731]}, {"w": "you", "b": [0.3925, 0.7096, 0.4238, 0.731]}, {"w": "can", "b": [0.4299, 0.7096, 0.4593, 0.731]}, {"w": "hope", "b": [0.4655, 0.7096, 0.507, 0.731]}, {"w": "for", "b": [0.5131, 0.7096, 0.5377, 0.731]}, {"w": "up", "b": [0.5438, 0.7096, 0.5658, 0.731]}, {"w": "to", "b": [0.572, 0.7096, 0.589, 0.731]}, {"w": "75%", "b": [0.5951, 0.7096, 0.6309, 0.731]}, {"w": "accuracy!", "b": [0.637, 0.7096, 0.7159, 0.731]}, {"w": "However,", "b": [0.722, 0.7096, 0.8009, 0.731]}, {"w": "this", "b": [0.8071, 0.7096, 0.8378, 0.731]}, {"w": "is", "b": [0.8439, 0.7096, 0.8572, 0.731]}, {"w": "only", "b": [0.1429, 0.7286, 0.1797, 0.75]}, {"w": "true", "b": [0.1896, 0.7286, 0.2236, 0.75]}, {"w": "if", "b": [0.2335, 0.7286, 0.2453, 0.75]}, {"w": "all", "b": [0.2551, 0.7286, 0.2748, 0.75]}, {"w": "classifiers", "b": [0.2847, 0.7286, 0.3648, 0.75]}, {"w": "are", "b": [0.3747, 0.7286, 0.4004, 0.75]}, {"w": "perfectly", "b": [0.4103, 0.7286, 0.4828, 0.75]}, {"w": "independent,", "b": [0.4927, 0.7286, 0.6027, 0.75]}, {"w": "making", "b": [0.6126, 0.7286, 0.6759, 0.75]}, {"w": "uncorrelated", "b": [0.6858, 0.7286, 0.7922, 0.75]}, {"w": "errors,", "b": [0.8021, 0.7286, 0.8571, 0.75]}, {"w": "which", "b": [0.1429, 0.7476, 0.1938, 0.7691]}, {"w": "is", "b": [0.1986, 0.7476, 0.2118, 0.7691]}, {"w": "clearly", "b": [0.2166, 0.7476, 0.2712, 0.7691]}, {"w": "not", "b": [0.276, 0.7476, 0.3044, 0.7691]}, {"w": "the", "b": [0.3092, 0.7476, 0.3355, 0.7691]}, {"w": "case", "b": [0.3403, 0.7476, 0.3747, 0.7691]}, {"w": "since", "b": [0.3795, 0.7476, 0.4218, 0.7691]}, {"w": "they", "b": [0.4266, 0.7476, 0.4625, 0.7691]}, {"w": "are", "b": [0.4673, 0.7476, 0.493, 0.7691]}, {"w": "trained", "b": [0.4978, 0.7476, 0.5578, 0.7691]}, {"w": "on", "b": [0.5626, 0.7476, 0.5846, 0.7691]}, {"w": "the", "b": [0.5894, 0.7476, 0.6158, 0.7691]}, {"w": "same", "b": [0.6205, 0.7476, 0.6632, 0.7691]}, {"w": "data.", "b": [0.668, 0.7476, 0.708, 0.7691]}, {"w": "They", "b": [0.7128, 0.7476, 0.7552, 0.7691]}, {"w": "are", "b": [0.76, 0.7476, 0.7857, 0.7691]}, {"w": "likely", "b": [0.7905, 0.7476, 0.8354, 0.7691]}, {"w": "to", "b": [0.8402, 0.7476, 0.8571, 0.7691]}, {"w": "make", "b": [0.1428, 0.7667, 0.1882, 0.7881]}, {"w": "the", "b": [0.1955, 0.7667, 0.2218, 0.7881]}, {"w": "same", "b": [0.229, 0.7667, 0.2717, 0.7881]}, {"w": "types", "b": [0.2789, 0.7667, 0.3223, 0.7881]}, {"w": "of", "b": [0.3295, 0.7667, 0.3463, 0.7881]}, {"w": "errors,", "b": [0.3535, 0.7667, 0.4085, 0.7881]}, {"w": "so", "b": [0.4158, 0.7667, 0.434, 0.7881]}, {"w": "there", "b": [0.4412, 0.7667, 0.4842, 0.7881]}, {"w": "will", "b": [0.4914, 0.7667, 0.5218, 0.7881]}, {"w": "be", "b": [0.529, 0.7667, 0.5484, 0.7881]}, {"w": "many", "b": [0.5556, 0.7667, 0.6023, 0.7881]}, {"w": "majority", "b": [0.6095, 0.7667, 0.6805, 0.7881]}, {"w": "votes", "b": [0.6877, 0.7667, 0.7309, 0.7881]}, {"w": "for", "b": [0.7381, 0.7667, 0.7626, 0.7881]}, {"w": "the", "b": [0.7698, 0.7667, 0.7962, 0.7881]}, {"w": "wrong", "b": [0.8034, 0.7667, 0.8571, 0.7881]}, {"w": "class,", "b": [0.1429, 0.7857, 0.1861, 0.8072]}, {"w": "reducing", "b": [0.1909, 0.7857, 0.2651, 0.8072]}, {"w": "the", "b": [0.2698, 0.7857, 0.2961, 0.8072]}, {"w": "ensemble’s", "b": [0.3008, 0.7857, 0.3885, 0.8072]}, {"w": "accuracy.", "b": [0.3932, 0.7857, 0.4695, 0.8072]}]}, {"id": "b_4", "type": "paragraph", "text": "Voting Classifiers | 193", "words": [{"w": "Voting", "b": [0.6958, 0.9225, 0.7351, 0.9388]}, {"w": "Classifiers", "b": [0.7379, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "193", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 220, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Ensemble methods work best when the predictors are as independ‐ ent from one another as possible. One way to get diverse classifiers is to train them using very different algorithms. This increases the chance that they will make very different types of errors, improving the ensemble’s accuracy.", "words": [{"w": "Ensemble", "b": [0.2714, 0.0793, 0.3459, 0.0989]}, {"w": "methods", "b": [0.3506, 0.0793, 0.417, 0.0989]}, {"w": "work", "b": [0.4217, 0.0793, 0.4609, 0.0989]}, {"w": "best", "b": [0.4656, 0.0793, 0.4962, 0.0989]}, {"w": "when", "b": [0.5008, 0.0793, 0.5426, 0.0989]}, {"w": "the", "b": [0.5472, 0.0793, 0.5713, 0.0989]}, {"w": "predictors", "b": [0.5759, 0.0793, 0.6539, 0.0989]}, {"w": "are", "b": [0.6585, 0.0793, 0.682, 0.0989]}, {"w": "as", "b": [0.6867, 0.0793, 0.7021, 0.0989]}, {"w": "independ‐", "b": [0.7067, 0.0793, 0.7857, 0.0989]}, {"w": "ent", "b": [0.2714, 0.0967, 0.2954, 0.1163]}, {"w": "from", "b": [0.3004, 0.0967, 0.3384, 0.1163]}, {"w": "one", "b": [0.3434, 0.0967, 0.3716, 0.1163]}, {"w": "another", "b": [0.3766, 0.0967, 0.4363, 0.1163]}, {"w": "as", "b": [0.4413, 0.0967, 0.4566, 0.1163]}, {"w": "possible.", "b": [0.4616, 0.0967, 0.5273, 0.1163]}, {"w": "One", "b": [0.5324, 0.0967, 0.5651, 0.1163]}, {"w": "way", "b": [0.5701, 0.0967, 0.5999, 0.1163]}, {"w": "to", "b": [0.6049, 0.0967, 0.6204, 0.1163]}, {"w": "get", "b": [0.6254, 0.0967, 0.6483, 0.1163]}, {"w": "diverse", "b": [0.6533, 0.0967, 0.7075, 0.1163]}, {"w": "classifiers", "b": [0.7125, 0.0967, 0.7857, 0.1163]}, {"w": "is", "b": [0.2714, 0.1141, 0.2835, 0.1337]}, {"w": "to", "b": [0.2891, 0.1141, 0.3046, 0.1337]}, {"w": "train", "b": [0.3102, 0.1141, 0.3469, 0.1337]}, {"w": "them", "b": [0.3525, 0.1141, 0.3922, 0.1337]}, {"w": "using", "b": [0.3977, 0.1141, 0.4393, 0.1337]}, {"w": "very", "b": [0.4449, 0.1141, 0.4781, 0.1337]}, {"w": "different", "b": [0.4837, 0.1141, 0.5493, 0.1337]}, {"w": "algorithms.", "b": [0.5548, 0.1141, 0.6417, 0.1337]}, {"w": "This", "b": [0.6473, 0.1141, 0.6813, 0.1337]}, {"w": "increases", "b": [0.6869, 0.1141, 0.7561, 0.1337]}, {"w": "the", "b": [0.7616, 0.1141, 0.7857, 0.1337]}, {"w": "chance", "b": [0.2714, 0.1315, 0.3246, 0.1511]}, {"w": "that", "b": [0.329, 0.1315, 0.3588, 0.1511]}, {"w": "they", "b": [0.3633, 0.1315, 0.3961, 0.1511]}, {"w": "will", "b": [0.4006, 0.1315, 0.4284, 0.1511]}, {"w": "make", "b": [0.4329, 0.1315, 0.4744, 0.1511]}, {"w": "very", "b": [0.4788, 0.1315, 0.5121, 0.1511]}, {"w": "different", "b": [0.5166, 0.1315, 0.5822, 0.1511]}, {"w": "types", "b": [0.5866, 0.1315, 0.6262, 0.1511]}, {"w": "of", "b": [0.6307, 0.1315, 0.6461, 0.1511]}, {"w": "errors,", "b": [0.6505, 0.1315, 0.7009, 0.1511]}, {"w": "improving", "b": [0.7054, 0.1315, 0.7857, 0.1511]}, {"w": "the", "b": [0.2714, 0.1489, 0.2955, 0.1685]}, {"w": "ensemble’s", "b": [0.2998, 0.1489, 0.3799, 0.1685]}, {"w": "accuracy.", "b": [0.3843, 0.1489, 0.454, 0.1685]}]}, {"id": "b_1", "type": "paragraph", "text": "The following code creates and trains a voting classifier in Scikit-Learn, composed of three diverse classifiers (the training set is the moons dataset, introduced in Chap‐ ter 5):", "words": [{"w": "The", "b": [0.1429, 0.1888, 0.1757, 0.2102]}, {"w": "following", "b": [0.1812, 0.1888, 0.2601, 0.2102]}, {"w": "code", "b": [0.2656, 0.1888, 0.3049, 0.2102]}, {"w": "creates", "b": [0.3104, 0.1888, 0.3674, 0.2102]}, {"w": "and", "b": [0.3729, 0.1888, 0.4045, 0.2102]}, {"w": "trains", "b": [0.4099, 0.1888, 0.4578, 0.2102]}, {"w": "a", "b": [0.4633, 0.1888, 0.4724, 0.2102]}, {"w": "voting", "b": [0.4779, 0.1888, 0.5313, 0.2102]}, {"w": "classifier", "b": [0.5368, 0.1888, 0.6092, 0.2102]}, {"w": "in", "b": [0.6147, 0.1888, 0.6317, 0.2102]}, {"w": "Scikit-Learn,", "b": [0.6372, 0.1888, 0.7442, 0.2102]}, {"w": "composed", "b": [0.7497, 0.1888, 0.8349, 0.2102]}, {"w": "of", "b": [0.8403, 0.1888, 0.8571, 0.2102]}, {"w": "three", "b": [0.1428, 0.2079, 0.1858, 0.2293]}, {"w": "diverse", "b": [0.1931, 0.2079, 0.2524, 0.2293]}, {"w": "classifiers", "b": [0.2597, 0.2079, 0.3398, 0.2293]}, {"w": "(the", "b": [0.3471, 0.2079, 0.3807, 0.2293]}, {"w": "training", "b": [0.388, 0.2079, 0.4549, 0.2293]}, {"w": "set", "b": [0.4622, 0.2079, 0.4851, 0.2293]}, {"w": "is", "b": [0.4924, 0.2079, 0.5056, 0.2293]}, {"w": "the", "b": [0.5129, 0.2079, 0.5393, 0.2293]}, {"w": "moons", "b": [0.5466, 0.2079, 0.6039, 0.2293]}, {"w": "dataset,", "b": [0.6113, 0.2079, 0.6741, 0.2293]}, {"w": "introduced", "b": [0.6814, 0.2079, 0.7735, 0.2293]}, {"w": "in", "b": [0.7808, 0.2079, 0.7978, 0.2293]}, {"w": "Chap‐", "b": [0.8051, 0.2079, 0.8571, 0.2293]}, {"w": "ter", "b": [0.1429, 0.2269, 0.1658, 0.2483]}, {"w": "5):", "b": [0.1705, 0.2269, 0.1925, 0.2483]}]}, {"id": "b_2", "type": "paragraph", "text": "from sklearn.ensemble import RandomForestClassifier from sklearn.ensemble import VotingClassifier from sklearn.linear_model import LogisticRegression from sklearn.svm import SVC", "words": [{"w": "from", "b": [0.1766, 0.2589, 0.2103, 0.2717]}, {"w": "sklearn.ensemble", "b": [0.2187, 0.2589, 0.3537, 0.2717]}, {"w": "import", "b": [0.3621, 0.2589, 0.4127, 0.2717]}, {"w": "RandomForestClassifier", "b": [0.4211, 0.2589, 0.6066, 0.2717]}, {"w": "from", "b": [0.1766, 0.2743, 0.2103, 0.2872]}, {"w": "sklearn.ensemble", "b": [0.2187, 0.2743, 0.3537, 0.2872]}, {"w": "import", "b": [0.3621, 0.2743, 0.4127, 0.2872]}, {"w": "VotingClassifier", "b": [0.4211, 0.2743, 0.5561, 0.2872]}, {"w": "from", "b": [0.1766, 0.2897, 0.2103, 0.3026]}, {"w": "sklearn.linear_model", "b": [0.2187, 0.2897, 0.3874, 0.3026]}, {"w": "import", "b": [0.3958, 0.2897, 0.4464, 0.3026]}, {"w": "LogisticRegression", "b": [0.4549, 0.2897, 0.6066, 0.3026]}, {"w": "from", "b": [0.1766, 0.3051, 0.2103, 0.318]}, {"w": "sklearn.svm", "b": [0.2187, 0.3051, 0.3115, 0.318]}, {"w": "import", "b": [0.3199, 0.3051, 0.3705, 0.318]}, {"w": "SVC", "b": [0.379, 0.3051, 0.4043, 0.318]}]}, {"id": "b_3", "type": "paragraph", "text": "log_clf = LogisticRegression() rnd_clf = RandomForestClassifier() svm_clf = SVC()", "words": [{"w": "log_clf", "b": [0.1766, 0.336, 0.2356, 0.3488]}, {"w": "=", "b": [0.244, 0.336, 0.2525, 0.3488]}, {"w": "LogisticRegression()", "b": [0.2609, 0.336, 0.4296, 0.3488]}, {"w": "rnd_clf", "b": [0.1766, 0.3514, 0.2356, 0.3642]}, {"w": "=", "b": [0.244, 0.3514, 0.2525, 0.3642]}, {"w": "RandomForestClassifier()", "b": [0.2609, 0.3514, 0.4633, 0.3642]}, {"w": "svm_clf", "b": [0.1766, 0.3668, 0.2356, 0.3797]}, {"w": "=", "b": [0.244, 0.3668, 0.2525, 0.3797]}, {"w": "SVC()", "b": [0.2609, 0.3668, 0.3031, 0.3797]}]}, {"id": "b_4", "type": "paragraph", "text": "voting_clf = VotingClassifier( estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)], voting='hard') voting_clf.fit(X_train, y_train)", "words": [{"w": "voting_clf", "b": [0.1766, 0.3977, 0.2609, 0.4105]}, {"w": "=", "b": [0.2693, 0.3977, 0.2778, 0.4105]}, {"w": "VotingClassifier(", "b": [0.2862, 0.3977, 0.4296, 0.4105]}, {"w": "estimators=[('lr',", "b": [0.2103, 0.4131, 0.3621, 0.4259]}, {"w": "log_clf),", "b": [0.3705, 0.4131, 0.4464, 0.4259]}, {"w": "('rf',", "b": [0.4549, 0.4131, 0.5055, 0.4259]}, {"w": "rnd_clf),", "b": [0.5139, 0.4131, 0.5898, 0.4259]}, {"w": "('svc',", "b": [0.5982, 0.4131, 0.6572, 0.4259]}, {"w": "svm_clf)],", "b": [0.6657, 0.4131, 0.75, 0.4259]}, {"w": "voting='hard')", "b": [0.2103, 0.4285, 0.3284, 0.4413]}, {"w": "voting_clf.fit(X_train,", "b": [0.1766, 0.4439, 0.3705, 0.4568]}, {"w": "y_train)", "b": [0.379, 0.4439, 0.4464, 0.4568]}]}, {"id": "b_5", "type": "paragraph", "text": "Let’s look at each classifier’s accuracy on the test set:", "words": [{"w": "Let’s", "b": [0.1429, 0.4645, 0.179, 0.486]}, {"w": "look", "b": [0.1838, 0.4645, 0.2206, 0.486]}, {"w": "at", "b": [0.2253, 0.4645, 0.2404, 0.486]}, {"w": "each", "b": [0.2452, 0.4645, 0.2831, 0.486]}, {"w": "classifier’s", "b": [0.2878, 0.4645, 0.3706, 0.486]}, {"w": "accuracy", "b": [0.3753, 0.4645, 0.4484, 0.486]}, {"w": "on", "b": [0.4531, 0.4645, 0.4752, 0.486]}, {"w": "the", "b": [0.4799, 0.4645, 0.5062, 0.486]}, {"w": "test", "b": [0.5109, 0.4645, 0.5402, 0.486]}, {"w": "set:", "b": [0.5449, 0.4645, 0.5725, 0.486]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> from sklearn.metrics import accuracy_score >>> for clf in (log_clf, rnd_clf, svm_clf, voting_clf): ... clf.fit(X_train, y_train) ... y_pred = clf.predict(X_test) ... print(clf.__class__.__name__, accuracy_score(y_test, y_pred)) ... LogisticRegression 0.864 RandomForestClassifier 0.896 SVC 0.888 VotingClassifier 0.904", "words": [{"w": ">>>", "b": [0.1766, 0.4965, 0.2019, 0.5094]}, {"w": "from", "b": [0.2103, 0.4965, 0.244, 0.5094]}, {"w": "sklearn.metrics", "b": [0.2525, 0.4965, 0.379, 0.5094]}, {"w": "import", "b": [0.3874, 0.4965, 0.438, 0.5094]}, {"w": "accuracy_score", "b": [0.4464, 0.4965, 0.5645, 0.5094]}, {"w": ">>>", "b": [0.1766, 0.5119, 0.2019, 0.5248]}, {"w": "for", "b": [0.2103, 0.5119, 0.2356, 0.5248]}, {"w": "clf", "b": [0.244, 0.5119, 0.2693, 0.5248]}, {"w": "in", "b": [0.2778, 0.5119, 0.2946, 0.5248]}, {"w": "(log_clf,", "b": [0.3031, 0.5119, 0.379, 0.5248]}, {"w": "rnd_clf,", "b": [0.3874, 0.5119, 0.4549, 0.5248]}, {"w": "svm_clf,", "b": [0.4633, 0.5119, 0.5307, 0.5248]}, {"w": "voting_clf):", "b": [0.5392, 0.5119, 0.6404, 0.5248]}, {"w": "...", "b": [0.1766, 0.5274, 0.2019, 0.5402]}, {"w": "clf.fit(X_train,", "b": [0.244, 0.5274, 0.379, 0.5402]}, {"w": "y_train)", "b": [0.3874, 0.5274, 0.4549, 0.5402]}, {"w": "...", "b": [0.1766, 0.5428, 0.2019, 0.5556]}, {"w": "y_pred", "b": [0.244, 0.5428, 0.2946, 0.5556]}, {"w": "=", "b": [0.3031, 0.5428, 0.3115, 0.5556]}, {"w": "clf.predict(X_test)", "b": [0.3199, 0.5428, 0.4802, 0.5556]}, {"w": "...", "b": [0.1766, 0.5582, 0.2019, 0.5711]}, {"w": "print(clf.__class__.__name__,", "b": [0.244, 0.5582, 0.4886, 0.5711]}, {"w": "accuracy_score(y_test,", "b": [0.497, 0.5582, 0.6825, 0.5711]}, {"w": "y_pred))", "b": [0.691, 0.5582, 0.7584, 0.5711]}, {"w": "...", "b": [0.1766, 0.5736, 0.2019, 0.5865]}, {"w": "LogisticRegression", "b": [0.1766, 0.589, 0.3284, 0.6019]}, {"w": "0.864", "b": [0.3368, 0.589, 0.379, 0.6019]}, {"w": "RandomForestClassifier", "b": [0.1766, 0.6045, 0.3621, 0.6173]}, {"w": "0.896", "b": [0.3705, 0.6045, 0.4127, 0.6173]}, {"w": "SVC", "b": [0.1766, 0.6199, 0.2019, 0.6327]}, {"w": "0.888", "b": [0.2103, 0.6199, 0.2525, 0.6327]}, {"w": "VotingClassifier", "b": [0.1766, 0.6353, 0.3115, 0.6481]}, {"w": "0.904", "b": [0.3199, 0.6353, 0.3621, 0.6481]}]}, {"id": "b_7", "type": "paragraph", "text": "There you have it! The voting classifier slightly outperforms all the individual classifi‐ ers.", "words": [{"w": "There", "b": [0.1428, 0.6559, 0.1923, 0.6773]}, {"w": "you", "b": [0.1972, 0.6559, 0.2285, 0.6773]}, {"w": "have", "b": [0.2334, 0.6559, 0.2718, 0.6773]}, {"w": "it!", "b": [0.2768, 0.6559, 0.2945, 0.6773]}, {"w": "The", "b": [0.2994, 0.6559, 0.3322, 0.6773]}, {"w": "voting", "b": [0.3372, 0.6559, 0.3905, 0.6773]}, {"w": "classifier", "b": [0.3955, 0.6559, 0.4679, 0.6773]}, {"w": "slightly", "b": [0.4729, 0.6559, 0.533, 0.6773]}, {"w": "outperforms", "b": [0.538, 0.6559, 0.6428, 0.6773]}, {"w": "all", "b": [0.6477, 0.6559, 0.6674, 0.6773]}, {"w": "the", "b": [0.6724, 0.6559, 0.6987, 0.6773]}, {"w": "individual", "b": [0.7036, 0.6559, 0.7889, 0.6773]}, {"w": "classifi‐", "b": [0.7939, 0.6559, 0.8571, 0.6773]}, {"w": "ers.", "b": [0.1429, 0.675, 0.1718, 0.6964]}]}, {"id": "b_8", "type": "paragraph", "text": "If all classifiers are able to estimate class probabilities (i.e., they have a pre dict_proba() method), then you can tell Scikit-Learn to predict the class with the highest class probability, averaged over all the individual classifiers. This is called soft voting. It often achieves higher performance than hard voting because it gives more weight to highly confident votes. All you need to do is replace voting=\"hard\" with voting=\"soft\" and ensure that all classifiers can estimate class probabilities. This is not the case of the SVC class by default, so you need to set its probability hyperpara‐ meter to True (this will make the SVC class use cross-validation to estimate class prob‐ abilities, slowing down training, and it will add a predict_proba() method). If you", "words": [{"w": "If", "b": [0.1429, 0.704, 0.1561, 0.7254]}, {"w": "all", "b": [0.1682, 0.704, 0.1878, 0.7254]}, {"w": "classifiers", "b": [0.1999, 0.704, 0.28, 0.7254]}, {"w": "are", "b": [0.292, 0.704, 0.3177, 0.7254]}, {"w": "able", "b": [0.3297, 0.704, 0.3636, 0.7254]}, {"w": "to", "b": [0.3756, 0.704, 0.3926, 0.7254]}, {"w": "estimate", "b": [0.4046, 0.704, 0.4741, 0.7254]}, {"w": "class", "b": [0.4861, 0.704, 0.5246, 0.7254]}, {"w": "probabilities", "b": [0.5366, 0.704, 0.6411, 0.7254]}, {"w": "(i.e.,", "b": [0.6531, 0.704, 0.689, 0.7254]}, {"w": "they", "b": [0.701, 0.704, 0.7369, 0.7254]}, {"w": "have", "b": [0.7489, 0.704, 0.7873, 0.7254]}, {"w": "a", "b": [0.7994, 0.704, 0.8085, 0.7254]}, {"w": "pre", "b": [0.8205, 0.7072, 0.8502, 0.7223]}, {"w": "dict_proba()", "b": [0.1429, 0.7271, 0.2616, 0.7422]}, {"w": "method),", "b": [0.2689, 0.7239, 0.3459, 0.7454]}, {"w": "then", "b": [0.3532, 0.7239, 0.3909, 0.7454]}, {"w": "you", "b": [0.3982, 0.7239, 0.4294, 0.7454]}, {"w": "can", "b": [0.4367, 0.7239, 0.4661, 0.7454]}, {"w": "tell", "b": [0.4734, 0.7239, 0.4991, 0.7454]}, {"w": "Scikit-Learn", "b": [0.5064, 0.7239, 0.6087, 0.7454]}, {"w": "to", "b": [0.616, 0.7239, 0.633, 0.7454]}, {"w": "predict", "b": [0.6402, 0.7239, 0.6995, 0.7454]}, {"w": "the", "b": [0.7068, 0.7239, 0.7331, 0.7454]}, {"w": "class", "b": [0.7404, 0.7239, 0.7789, 0.7454]}, {"w": "with", "b": [0.7862, 0.7239, 0.8235, 0.7454]}, {"w": "the", "b": [0.8308, 0.7239, 0.8572, 0.7454]}, {"w": "highest", "b": [0.1429, 0.743, 0.2033, 0.7644]}, {"w": "class", "b": [0.2088, 0.743, 0.2473, 0.7644]}, {"w": "probability,", "b": [0.2528, 0.743, 0.348, 0.7644]}, {"w": "averaged", "b": [0.3535, 0.743, 0.4272, 0.7644]}, {"w": "over", "b": [0.4327, 0.743, 0.4696, 0.7644]}, {"w": "all", "b": [0.4751, 0.743, 0.4948, 0.7644]}, {"w": "the", "b": [0.5003, 0.743, 0.5266, 0.7644]}, {"w": "individual", "b": [0.5321, 0.743, 0.6174, 0.7644]}, {"w": "classifiers.", "b": [0.6229, 0.743, 0.7077, 0.7644]}, {"w": "This", "b": [0.7132, 0.743, 0.7504, 0.7644]}, {"w": "is", "b": [0.7559, 0.743, 0.7692, 0.7644]}, {"w": "called", "b": [0.7747, 0.743, 0.823, 0.7644]}, {"w": "soft", "b": [0.8285, 0.7428, 0.8571, 0.7644]}, {"w": "voting.", "b": [0.1429, 0.7618, 0.1976, 0.7834]}, {"w": "It", "b": [0.2042, 0.762, 0.2169, 0.7834]}, {"w": "often", "b": [0.2235, 0.762, 0.2669, 0.7834]}, {"w": "achieves", "b": [0.2735, 0.762, 0.3432, 0.7834]}, {"w": "higher", "b": [0.3499, 0.762, 0.404, 0.7834]}, {"w": "performance", "b": [0.4107, 0.762, 0.518, 0.7834]}, {"w": "than", "b": [0.5246, 0.762, 0.5626, 0.7834]}, {"w": "hard", "b": [0.5693, 0.762, 0.6083, 0.7834]}, {"w": "voting", "b": [0.6149, 0.762, 0.6683, 0.7834]}, {"w": "because", "b": [0.6749, 0.762, 0.7395, 0.7834]}, {"w": "it", "b": [0.7462, 0.762, 0.7581, 0.7834]}, {"w": "gives", "b": [0.7647, 0.762, 0.8062, 0.7834]}, {"w": "more", "b": [0.8129, 0.762, 0.8571, 0.7834]}, {"w": "weight", "b": [0.1428, 0.782, 0.1984, 0.8034]}, {"w": "to", "b": [0.2052, 0.782, 0.2221, 0.8034]}, {"w": "highly", "b": [0.2289, 0.782, 0.2813, 0.8034]}, {"w": "confident", "b": [0.2881, 0.782, 0.3679, 0.8034]}, {"w": "votes.", "b": [0.3747, 0.782, 0.4225, 0.8034]}, {"w": "All", "b": [0.4293, 0.782, 0.4542, 0.8034]}, {"w": "you", "b": [0.461, 0.782, 0.4923, 0.8034]}, {"w": "need", "b": [0.499, 0.782, 0.5391, 0.8034]}, {"w": "to", "b": [0.5459, 0.782, 0.5629, 0.8034]}, {"w": "do", "b": [0.5696, 0.782, 0.5913, 0.8034]}, {"w": "is", "b": [0.598, 0.782, 0.6113, 0.8034]}, {"w": "replace", "b": [0.618, 0.782, 0.6776, 0.8034]}, {"w": "voting=\"hard\"", "b": [0.6844, 0.7852, 0.813, 0.8002]}, {"w": "with", "b": [0.8198, 0.782, 0.8571, 0.8034]}, {"w": "voting=\"soft\"", "b": [0.1429, 0.8051, 0.2715, 0.8202]}, {"w": "and", "b": [0.2778, 0.8019, 0.3093, 0.8233]}, {"w": "ensure", "b": [0.3156, 0.8019, 0.3712, 0.8233]}, {"w": "that", "b": [0.3775, 0.8019, 0.41, 0.8233]}, {"w": "all", "b": [0.4163, 0.8019, 0.436, 0.8233]}, {"w": "classifiers", "b": [0.4423, 0.8019, 0.5224, 0.8233]}, {"w": "can", "b": [0.5287, 0.8019, 0.558, 0.8233]}, {"w": "estimate", "b": [0.5643, 0.8019, 0.6338, 0.8233]}, {"w": "class", "b": [0.6401, 0.8019, 0.6786, 0.8233]}, {"w": "probabilities.", "b": [0.6849, 0.8019, 0.7941, 0.8233]}, {"w": "This", "b": [0.8004, 0.8019, 0.8376, 0.8233]}, {"w": "is", "b": [0.8439, 0.8019, 0.8571, 0.8233]}, {"w": "not", "b": [0.1429, 0.8219, 0.1712, 0.8433]}, {"w": "the", "b": [0.1763, 0.8219, 0.2027, 0.8433]}, {"w": "case", "b": [0.2078, 0.8219, 0.2422, 0.8433]}, {"w": "of", "b": [0.2473, 0.8219, 0.2641, 0.8433]}, {"w": "the", "b": [0.2692, 0.8219, 0.2955, 0.8433]}, {"w": "SVC", "b": [0.3006, 0.825, 0.3303, 0.8401]}, {"w": "class", "b": [0.3354, 0.8219, 0.3739, 0.8433]}, {"w": "by", "b": [0.379, 0.8219, 0.3991, 0.8433]}, {"w": "default,", "b": [0.4042, 0.8219, 0.4664, 0.8433]}, {"w": "so", "b": [0.4715, 0.8219, 0.4898, 0.8433]}, {"w": "you", "b": [0.4949, 0.8219, 0.5262, 0.8433]}, {"w": "need", "b": [0.5312, 0.8219, 0.5713, 0.8433]}, {"w": "to", "b": [0.5764, 0.8219, 0.5934, 0.8433]}, {"w": "set", "b": [0.5985, 0.8219, 0.6214, 0.8433]}, {"w": "its", "b": [0.6265, 0.8219, 0.646, 0.8433]}, {"w": "probability", "b": [0.6511, 0.825, 0.76, 0.8401]}, {"w": "hyperpara‐", "b": [0.7651, 0.8219, 0.8571, 0.8433]}, {"w": "meter", "b": [0.1429, 0.8418, 0.1917, 0.8632]}, {"w": "to", "b": [0.1964, 0.8418, 0.2134, 0.8632]}, {"w": "True", "b": [0.2184, 0.845, 0.2579, 0.8601]}, {"w": "(this", "b": [0.2627, 0.8418, 0.3007, 0.8632]}, {"w": "will", "b": [0.3054, 0.8418, 0.3358, 0.8632]}, {"w": "make", "b": [0.3405, 0.8418, 0.3859, 0.8632]}, {"w": "the", "b": [0.3906, 0.8418, 0.417, 0.8632]}, {"w": "SVC", "b": [0.4221, 0.845, 0.4518, 0.8601]}, {"w": "class", "b": [0.4566, 0.8418, 0.4951, 0.8632]}, {"w": "use", "b": [0.4999, 0.8418, 0.5274, 0.8632]}, {"w": "cross-validation", "b": [0.5322, 0.8418, 0.6654, 0.8632]}, {"w": "to", "b": [0.6701, 0.8418, 0.6871, 0.8632]}, {"w": "estimate", "b": [0.6918, 0.8418, 0.7613, 0.8632]}, {"w": "class", "b": [0.766, 0.8418, 0.8045, 0.8632]}, {"w": "prob‐", "b": [0.8093, 0.8418, 0.8565, 0.8632]}, {"w": "abilities,", "b": [0.1429, 0.8618, 0.2122, 0.8832]}, {"w": "slowing", "b": [0.2186, 0.8618, 0.2832, 0.8832]}, {"w": "down", "b": [0.2896, 0.8618, 0.3369, 0.8832]}, {"w": "training,", "b": [0.3434, 0.8618, 0.4151, 0.8832]}, {"w": "and", "b": [0.4215, 0.8618, 0.453, 0.8832]}, {"w": "it", "b": [0.4595, 0.8618, 0.4714, 0.8832]}, {"w": "will", "b": [0.4779, 0.8618, 0.5083, 0.8832]}, {"w": "add", "b": [0.5147, 0.8618, 0.5458, 0.8832]}, {"w": "a", "b": [0.5523, 0.8618, 0.5614, 0.8832]}, {"w": "predict_proba()", "b": [0.5679, 0.8649, 0.7163, 0.88]}, {"w": "method).", "b": [0.7228, 0.8618, 0.7997, 0.8832]}, {"w": "If", "b": [0.8062, 0.8618, 0.8194, 0.8832]}, {"w": "you", "b": [0.8259, 0.8618, 0.8571, 0.8832]}]}, {"id": "b_9", "type": "paragraph", "text": "194 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "194", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 221, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 “Bagging Predictors,” L. Breiman (1996).", "words": [{"w": "1", "b": [0.1451, 0.8371, 0.1518, 0.8514]}, {"w": "“Bagging", "b": [0.1587, 0.8356, 0.2166, 0.8519]}, {"w": "Predictors,”", "b": [0.2202, 0.8356, 0.2935, 0.8519]}, {"w": "L.", "b": [0.2971, 0.8356, 0.3093, 0.8519]}, {"w": "Breiman", "b": [0.3129, 0.8356, 0.3678, 0.8519]}, {"w": "(1996).", "b": [0.3714, 0.8356, 0.4165, 0.8519]}]}, {"id": "b_1", "type": "paragraph", "text": "2 In statistics, resampling with replacement is called bootstrapping.", "words": [{"w": "2", "b": [0.1451, 0.8568, 0.1518, 0.871]}, {"w": "In", "b": [0.1587, 0.8553, 0.1728, 0.8716]}, {"w": "statistics,", "b": [0.1764, 0.8553, 0.2339, 0.8716]}, {"w": "resampling", "b": [0.2375, 0.8553, 0.3084, 0.8716]}, {"w": "with", "b": [0.312, 0.8553, 0.3404, 0.8716]}, {"w": "replacement", "b": [0.344, 0.8553, 0.4224, 0.8716]}, {"w": "is", "b": [0.426, 0.8553, 0.4361, 0.8716]}, {"w": "called", "b": [0.4397, 0.8553, 0.4765, 0.8716]}, {"w": "bootstrapping.", "b": [0.4801, 0.8551, 0.5681, 0.8716]}]}, {"id": "b_2", "type": "paragraph", "text": "3 “Pasting small votes for classification in large databases and on-line,” L. Breiman (1999).", "words": [{"w": "3", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Pasting", "b": [0.1587, 0.8749, 0.2116, 0.8912]}, {"w": "small", "b": [0.2152, 0.8749, 0.2491, 0.8912]}, {"w": "votes", "b": [0.2527, 0.8749, 0.2855, 0.8912]}, {"w": "for", "b": [0.2891, 0.8749, 0.3078, 0.8912]}, {"w": "classification", "b": [0.3114, 0.8749, 0.3932, 0.8912]}, {"w": "in", "b": [0.3968, 0.8749, 0.4098, 0.8912]}, {"w": "large", "b": [0.4134, 0.8749, 0.4444, 0.8912]}, {"w": "databases", "b": [0.448, 0.8749, 0.5083, 0.8912]}, {"w": "and", "b": [0.5119, 0.8749, 0.5359, 0.8912]}, {"w": "on-line,”", "b": [0.5395, 0.8749, 0.5935, 0.8912]}, {"w": "L.", "b": [0.5971, 0.8749, 0.6092, 0.8912]}, {"w": "Breiman", "b": [0.6128, 0.8749, 0.6677, 0.8912]}, {"w": "(1999).", "b": [0.6713, 0.8749, 0.7164, 0.8912]}]}, {"id": "b_3", "type": "paragraph", "text": "modify the preceding code to use soft voting, you will find that the voting classifier achieves over 91.2% accuracy!", "words": [{"w": "modify", "b": [0.1429, 0.0791, 0.2032, 0.1005]}, {"w": "the", "b": [0.2097, 0.0791, 0.2361, 0.1005]}, {"w": "preceding", "b": [0.2426, 0.0791, 0.3255, 0.1005]}, {"w": "code", "b": [0.332, 0.0791, 0.3713, 0.1005]}, {"w": "to", "b": [0.3779, 0.0791, 0.3948, 0.1005]}, {"w": "use", "b": [0.4014, 0.0791, 0.4289, 0.1005]}, {"w": "soft", "b": [0.4355, 0.0791, 0.4663, 0.1005]}, {"w": "voting,", "b": [0.4728, 0.0791, 0.5309, 0.1005]}, {"w": "you", "b": [0.5374, 0.0791, 0.5687, 0.1005]}, {"w": "will", "b": [0.5752, 0.0791, 0.6056, 0.1005]}, {"w": "find", "b": [0.6122, 0.0791, 0.6463, 0.1005]}, {"w": "that", "b": [0.6528, 0.0791, 0.6854, 0.1005]}, {"w": "the", "b": [0.692, 0.0791, 0.7183, 0.1005]}, {"w": "voting", "b": [0.7248, 0.0791, 0.7782, 0.1005]}, {"w": "classifier", "b": [0.7847, 0.0791, 0.8571, 0.1005]}, {"w": "achieves", "b": [0.1429, 0.0981, 0.2125, 0.1195]}, {"w": "over", "b": [0.2173, 0.0981, 0.2541, 0.1195]}, {"w": "91.2%", "b": [0.2588, 0.0981, 0.3093, 0.1195]}, {"w": "accuracy!", "b": [0.3141, 0.0981, 0.3929, 0.1195]}]}, {"id": "b_4", "type": "paragraph", "text": "Bagging and Pasting", "words": [{"w": "Bagging", "b": [0.1428, 0.1325, 0.2466, 0.1668]}, {"w": "and", "b": [0.2525, 0.1325, 0.2996, 0.1668]}, {"w": "Pasting", "b": [0.3055, 0.1325, 0.3988, 0.1668]}]}, {"id": "b_5", "type": "paragraph", "text": "One way to get a diverse set of classifiers is to use very different training algorithms, as just discussed. Another approach is to use the same training algorithm for every predictor, but to train them on different random subsets of the training set. When sampling is performed with replacement, this method is called bagging1 (short for bootstrap aggregating2). When sampling is performed without replacement, it is called pasting.3", "words": [{"w": "One", "b": [0.1428, 0.1737, 0.1787, 0.1951]}, {"w": "way", "b": [0.1845, 0.1737, 0.2171, 0.1951]}, {"w": "to", "b": [0.223, 0.1737, 0.24, 0.1951]}, {"w": "get", "b": [0.2458, 0.1737, 0.2708, 0.1951]}, {"w": "a", "b": [0.2766, 0.1737, 0.2858, 0.1951]}, {"w": "diverse", "b": [0.2916, 0.1737, 0.351, 0.1951]}, {"w": "set", "b": [0.3568, 0.1737, 0.3797, 0.1951]}, {"w": "of", "b": [0.3855, 0.1737, 0.4023, 0.1951]}, {"w": "classifiers", "b": [0.4082, 0.1737, 0.4883, 0.1951]}, {"w": "is", "b": [0.4941, 0.1737, 0.5074, 0.1951]}, {"w": "to", "b": [0.5132, 0.1737, 0.5302, 0.1951]}, {"w": "use", "b": [0.5361, 0.1737, 0.5636, 0.1951]}, {"w": "very", "b": [0.5695, 0.1737, 0.6059, 0.1951]}, {"w": "different", "b": [0.6117, 0.1737, 0.6834, 0.1951]}, {"w": "training", "b": [0.6893, 0.1737, 0.7562, 0.1951]}, {"w": "algorithms,", "b": [0.7621, 0.1737, 0.8571, 0.1951]}, {"w": "as", "b": [0.1429, 0.1927, 0.1597, 0.2142]}, {"w": "just", "b": [0.1665, 0.1927, 0.1969, 0.2142]}, {"w": "discussed.", "b": [0.2037, 0.1927, 0.2877, 0.2142]}, {"w": "Another", "b": [0.2945, 0.1927, 0.3649, 0.2142]}, {"w": "approach", "b": [0.3717, 0.1927, 0.4498, 0.2142]}, {"w": "is", "b": [0.4566, 0.1927, 0.4698, 0.2142]}, {"w": "to", "b": [0.4766, 0.1927, 0.4936, 0.2142]}, {"w": "use", "b": [0.5004, 0.1927, 0.5279, 0.2142]}, {"w": "the", "b": [0.5347, 0.1927, 0.5611, 0.2142]}, {"w": "same", "b": [0.5679, 0.1927, 0.6106, 0.2142]}, {"w": "training", "b": [0.6174, 0.1927, 0.6843, 0.2142]}, {"w": "algorithm", "b": [0.6911, 0.1927, 0.7738, 0.2142]}, {"w": "for", "b": [0.7806, 0.1927, 0.8051, 0.2142]}, {"w": "every", "b": [0.8119, 0.1927, 0.8571, 0.2142]}, {"w": "predictor,", "b": [0.1429, 0.2118, 0.2239, 0.2332]}, {"w": "but", "b": [0.2312, 0.2118, 0.2592, 0.2332]}, {"w": "to", "b": [0.2665, 0.2118, 0.2835, 0.2332]}, {"w": "train", "b": [0.2908, 0.2118, 0.331, 0.2332]}, {"w": "them", "b": [0.3383, 0.2118, 0.3817, 0.2332]}, {"w": "on", "b": [0.389, 0.2118, 0.411, 0.2332]}, {"w": "different", "b": [0.4183, 0.2118, 0.49, 0.2332]}, {"w": "random", "b": [0.4973, 0.2118, 0.5643, 0.2332]}, {"w": "subsets", "b": [0.5716, 0.2118, 0.6314, 0.2332]}, {"w": "of", "b": [0.6387, 0.2118, 0.6555, 0.2332]}, {"w": "the", "b": [0.6628, 0.2118, 0.6891, 0.2332]}, {"w": "training", "b": [0.6964, 0.2118, 0.7633, 0.2332]}, {"w": "set.", "b": [0.7706, 0.2118, 0.7982, 0.2332]}, {"w": "When", "b": [0.8055, 0.2118, 0.8571, 0.2332]}, {"w": "sampling", "b": [0.1429, 0.2308, 0.2192, 0.2523]}, {"w": "is", "b": [0.2275, 0.2308, 0.2407, 0.2523]}, {"w": "performed", "b": [0.2489, 0.2308, 0.3379, 0.2523]}, {"w": "with", "b": [0.3461, 0.2306, 0.3826, 0.2523]}, {"w": "replacement,", "b": [0.3908, 0.2308, 0.4984, 0.2523]}, {"w": "this", "b": [0.5066, 0.2308, 0.5373, 0.2523]}, {"w": "method", "b": [0.5456, 0.2308, 0.6106, 0.2523]}, {"w": "is", "b": [0.6188, 0.2308, 0.6321, 0.2523]}, {"w": "called", "b": [0.6403, 0.2308, 0.6886, 0.2523]}, {"w": "bagging1", "b": [0.6969, 0.2306, 0.7655, 0.2523]}, {"w": "(short", "b": [0.7737, 0.2308, 0.8244, 0.2523]}, {"w": "for", "b": [0.8326, 0.2308, 0.8571, 0.2523]}, {"w": "bootstrap", "b": [0.1429, 0.2497, 0.2189, 0.2713]}, {"w": "aggregating2).", "b": [0.2237, 0.2497, 0.3349, 0.2713]}, {"w": "When", "b": [0.3402, 0.2499, 0.3918, 0.2713]}, {"w": "sampling", "b": [0.3971, 0.2499, 0.4735, 0.2713]}, {"w": "is", "b": [0.4788, 0.2499, 0.492, 0.2713]}, {"w": "performed", "b": [0.4974, 0.2499, 0.5863, 0.2713]}, {"w": "without", "b": [0.5916, 0.2497, 0.6547, 0.2713]}, {"w": "replacement,", "b": [0.66, 0.2499, 0.7677, 0.2713]}, {"w": "it", "b": [0.773, 0.2499, 0.7849, 0.2713]}, {"w": "is", "b": [0.7902, 0.2499, 0.8035, 0.2713]}, {"w": "called", "b": [0.8088, 0.2499, 0.8571, 0.2713]}, {"w": "pasting.3", "b": [0.1429, 0.2687, 0.2116, 0.2903]}]}, {"id": "b_6", "type": "paragraph", "text": "In other words, both bagging and pasting allow training instances to be sampled sev‐ eral times across multiple predictors, but only bagging allows training instances to be sampled several times for the same predictor. This sampling and training process is represented in Figure 7-4.", "words": [{"w": "In", "b": [0.1429, 0.2971, 0.1614, 0.3185]}, {"w": "other", "b": [0.1668, 0.2971, 0.2115, 0.3185]}, {"w": "words,", "b": [0.2169, 0.2971, 0.2729, 0.3185]}, {"w": "both", "b": [0.2783, 0.2971, 0.317, 0.3185]}, {"w": "bagging", "b": [0.3224, 0.2971, 0.3883, 0.3185]}, {"w": "and", "b": [0.3937, 0.2971, 0.4253, 0.3185]}, {"w": "pasting", "b": [0.4307, 0.2971, 0.4915, 0.3185]}, {"w": "allow", "b": [0.4969, 0.2971, 0.5415, 0.3185]}, {"w": "training", "b": [0.5469, 0.2971, 0.6138, 0.3185]}, {"w": "instances", "b": [0.6192, 0.2971, 0.696, 0.3185]}, {"w": "to", "b": [0.7015, 0.2971, 0.7184, 0.3185]}, {"w": "be", "b": [0.7238, 0.2971, 0.7433, 0.3185]}, {"w": "sampled", "b": [0.7487, 0.2971, 0.8182, 0.3185]}, {"w": "sev‐", "b": [0.8236, 0.2971, 0.8571, 0.3185]}, {"w": "eral", "b": [0.1429, 0.3161, 0.1739, 0.3375]}, {"w": "times", "b": [0.1791, 0.3161, 0.2246, 0.3375]}, {"w": "across", "b": [0.2298, 0.3161, 0.2815, 0.3375]}, {"w": "multiple", "b": [0.2867, 0.3161, 0.3567, 0.3375]}, {"w": "predictors,", "b": [0.3619, 0.3161, 0.4519, 0.3375]}, {"w": "but", "b": [0.4572, 0.3161, 0.4852, 0.3375]}, {"w": "only", "b": [0.4904, 0.3161, 0.5273, 0.3375]}, {"w": "bagging", "b": [0.5325, 0.3161, 0.5985, 0.3375]}, {"w": "allows", "b": [0.6037, 0.3161, 0.656, 0.3375]}, {"w": "training", "b": [0.6612, 0.3161, 0.7281, 0.3375]}, {"w": "instances", "b": [0.7334, 0.3161, 0.8102, 0.3375]}, {"w": "to", "b": [0.8155, 0.3161, 0.8325, 0.3375]}, {"w": "be", "b": [0.8377, 0.3161, 0.8571, 0.3375]}, {"w": "sampled", "b": [0.1428, 0.3351, 0.2123, 0.3566]}, {"w": "several", "b": [0.219, 0.3351, 0.2762, 0.3566]}, {"w": "times", "b": [0.2828, 0.3351, 0.3283, 0.3566]}, {"w": "for", "b": [0.335, 0.3351, 0.3595, 0.3566]}, {"w": "the", "b": [0.3662, 0.3351, 0.3925, 0.3566]}, {"w": "same", "b": [0.3992, 0.3351, 0.4419, 0.3566]}, {"w": "predictor.", "b": [0.4486, 0.3351, 0.5296, 0.3566]}, {"w": "This", "b": [0.5363, 0.3351, 0.5735, 0.3566]}, {"w": "sampling", "b": [0.5801, 0.3351, 0.6565, 0.3566]}, {"w": "and", "b": [0.6632, 0.3351, 0.6947, 0.3566]}, {"w": "training", "b": [0.7014, 0.3351, 0.7683, 0.3566]}, {"w": "process", "b": [0.775, 0.3351, 0.8372, 0.3566]}, {"w": "is", "b": [0.8439, 0.3351, 0.8571, 0.3566]}, {"w": "represented", "b": [0.1429, 0.3542, 0.2407, 0.3756]}, {"w": "in", "b": [0.2454, 0.3542, 0.2624, 0.3756]}, {"w": "Figure", "b": [0.2671, 0.3542, 0.3211, 0.3756]}, {"w": "7-4.", "b": [0.3258, 0.3542, 0.358, 0.3756]}]}, {"id": "b_7", "type": "equation", "text": "Figure 7-4. Pasting/bagging training set sampling and training", "words": [{"w": "Figure", "b": [0.1429, 0.6683, 0.1943, 0.6899]}, {"w": "7-4.", "b": [0.1991, 0.6683, 0.2308, 0.6899]}, {"w": "Pasting/bagging", "b": [0.2356, 0.6683, 0.3644, 0.6899]}, {"w": "training", "b": [0.3692, 0.6683, 0.4336, 0.6899]}, {"w": "set", "b": [0.4384, 0.6683, 0.4601, 0.6899]}, {"w": "sampling", "b": [0.4648, 0.6683, 0.5377, 0.6899]}, {"w": "and", "b": [0.5424, 0.6683, 0.5738, 0.6899]}, {"w": "training", "b": [0.5786, 0.6683, 0.643, 0.6899]}]}, {"id": "b_8", "type": "paragraph", "text": "Once all predictors are trained, the ensemble can make a prediction for a new instance by simply aggregating the predictions of all predictors. The aggregation function is typically the statistical mode (i.e., the most frequent prediction, just like a hard voting classifier) for classification, or the average for regression. Each individual", "words": [{"w": "Once", "b": [0.1429, 0.7057, 0.1875, 0.7271]}, {"w": "all", "b": [0.1975, 0.7057, 0.2172, 0.7271]}, {"w": "predictors", "b": [0.2272, 0.7057, 0.3125, 0.7271]}, {"w": "are", "b": [0.3225, 0.7057, 0.3482, 0.7271]}, {"w": "trained,", "b": [0.3583, 0.7057, 0.4231, 0.7271]}, {"w": "the", "b": [0.4331, 0.7057, 0.4594, 0.7271]}, {"w": "ensemble", "b": [0.4695, 0.7057, 0.548, 0.7271]}, {"w": "can", "b": [0.558, 0.7057, 0.5874, 0.7271]}, {"w": "make", "b": [0.5974, 0.7057, 0.6428, 0.7271]}, {"w": "a", "b": [0.6528, 0.7057, 0.662, 0.7271]}, {"w": "prediction", "b": [0.672, 0.7057, 0.7589, 0.7271]}, {"w": "for", "b": [0.7689, 0.7057, 0.7934, 0.7271]}, {"w": "a", "b": [0.8035, 0.7057, 0.8126, 0.7271]}, {"w": "new", "b": [0.8226, 0.7057, 0.8571, 0.7271]}, {"w": "instance", "b": [0.1429, 0.7247, 0.212, 0.7461]}, {"w": "by", "b": [0.2215, 0.7247, 0.2417, 0.7461]}, {"w": "simply", "b": [0.2511, 0.7247, 0.3068, 0.7461]}, {"w": "aggregating", "b": [0.3162, 0.7247, 0.413, 0.7461]}, {"w": "the", "b": [0.4225, 0.7247, 0.4488, 0.7461]}, {"w": "predictions", "b": [0.4583, 0.7247, 0.5528, 0.7461]}, {"w": "of", "b": [0.5623, 0.7247, 0.5791, 0.7461]}, {"w": "all", "b": [0.5885, 0.7247, 0.6082, 0.7461]}, {"w": "predictors.", "b": [0.6177, 0.7247, 0.7077, 0.7461]}, {"w": "The", "b": [0.7172, 0.7247, 0.75, 0.7461]}, {"w": "aggregation", "b": [0.7595, 0.7247, 0.8571, 0.7461]}, {"w": "function", "b": [0.1429, 0.7438, 0.2142, 0.7652]}, {"w": "is", "b": [0.2201, 0.7438, 0.2333, 0.7652]}, {"w": "typically", "b": [0.2392, 0.7438, 0.3096, 0.7652]}, {"w": "the", "b": [0.3155, 0.7438, 0.3418, 0.7652]}, {"w": "statistical", "b": [0.3476, 0.7436, 0.424, 0.7652]}, {"w": "mode", "b": [0.4299, 0.7436, 0.4747, 0.7652]}, {"w": "(i.e.,", "b": [0.4805, 0.7438, 0.5164, 0.7652]}, {"w": "the", "b": [0.5222, 0.7438, 0.5486, 0.7652]}, {"w": "most", "b": [0.5544, 0.7438, 0.5961, 0.7652]}, {"w": "frequent", "b": [0.6019, 0.7438, 0.6726, 0.7652]}, {"w": "prediction,", "b": [0.6784, 0.7438, 0.77, 0.7652]}, {"w": "just", "b": [0.7759, 0.7438, 0.8063, 0.7652]}, {"w": "like", "b": [0.8121, 0.7438, 0.8422, 0.7652]}, {"w": "a", "b": [0.848, 0.7438, 0.8571, 0.7652]}, {"w": "hard", "b": [0.1429, 0.7628, 0.1819, 0.7842]}, {"w": "voting", "b": [0.187, 0.7628, 0.2404, 0.7842]}, {"w": "classifier)", "b": [0.2456, 0.7628, 0.3252, 0.7842]}, {"w": "for", "b": [0.3304, 0.7628, 0.3549, 0.7842]}, {"w": "classification,", "b": [0.3601, 0.7628, 0.4722, 0.7842]}, {"w": "or", "b": [0.4774, 0.7628, 0.4957, 0.7842]}, {"w": "the", "b": [0.5009, 0.7628, 0.5273, 0.7842]}, {"w": "average", "b": [0.5324, 0.7628, 0.5952, 0.7842]}, {"w": "for", "b": [0.6004, 0.7628, 0.6249, 0.7842]}, {"w": "regression.", "b": [0.6301, 0.7628, 0.7206, 0.7842]}, {"w": "Each", "b": [0.7258, 0.7628, 0.7667, 0.7842]}, {"w": "individual", "b": [0.7719, 0.7628, 0.8572, 0.7842]}]}, {"id": "b_9", "type": "paragraph", "text": "Bagging and Pasting | 195", "words": [{"w": "Bagging", "b": [0.6741, 0.9225, 0.7234, 0.9388]}, {"w": "and", "b": [0.7262, 0.9225, 0.7486, 0.9388]}, {"w": "Pasting", "b": [0.7515, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "195", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 222, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "4 Bias and variance were introduced in Chapter 4.", "words": [{"w": "4", "b": [0.1451, 0.8395, 0.1518, 0.8538]}, {"w": "Bias", "b": [0.1587, 0.838, 0.1851, 0.8544]}, {"w": "and", "b": [0.1887, 0.838, 0.2127, 0.8544]}, {"w": "variance", "b": [0.2163, 0.838, 0.2699, 0.8544]}, {"w": "were", "b": [0.2735, 0.838, 0.3038, 0.8544]}, {"w": "introduced", "b": [0.3074, 0.838, 0.3775, 0.8544]}, {"w": "in", "b": [0.3811, 0.838, 0.394, 0.8544]}, {"w": "Chapter", "b": [0.3976, 0.838, 0.4491, 0.8544]}, {"w": "4.", "b": [0.4527, 0.838, 0.464, 0.8544]}]}, {"id": "b_1", "type": "paragraph", "text": "5 max_samples can alternatively be set to a float between 0.0 and 1.0, in which case the max number of instances to sample is equal to the size of the training set times max_samples.", "words": [{"w": "5", "b": [0.1451, 0.8602, 0.1518, 0.8745]}, {"w": "max_samples", "b": [0.1587, 0.8612, 0.2417, 0.8727]}, {"w": "can", "b": [0.2453, 0.8587, 0.2676, 0.8751]}, {"w": "alternatively", "b": [0.2712, 0.8587, 0.3495, 0.8751]}, {"w": "be", "b": [0.3531, 0.8587, 0.368, 0.8751]}, {"w": "set", "b": [0.3716, 0.8587, 0.389, 0.8751]}, {"w": "to", "b": [0.3926, 0.8587, 0.4055, 0.8751]}, {"w": "a", "b": [0.4091, 0.8587, 0.4161, 0.8751]}, {"w": "float", "b": [0.4197, 0.8587, 0.448, 0.8751]}, {"w": "between", "b": [0.4516, 0.8587, 0.5043, 0.8751]}, {"w": "0.0", "b": [0.5079, 0.8587, 0.5268, 0.8751]}, {"w": "and", "b": [0.5304, 0.8587, 0.5544, 0.8751]}, {"w": "1.0,", "b": [0.558, 0.8587, 0.5805, 0.8751]}, {"w": "in", "b": [0.5841, 0.8587, 0.597, 0.8751]}, {"w": "which", "b": [0.6006, 0.8587, 0.6394, 0.8751]}, {"w": "case", "b": [0.643, 0.8587, 0.6693, 0.8751]}, {"w": "the", "b": [0.6729, 0.8587, 0.6929, 0.8751]}, {"w": "max", "b": [0.6965, 0.8587, 0.724, 0.8751]}, {"w": "number", "b": [0.7276, 0.8587, 0.7781, 0.8751]}, {"w": "of", "b": [0.7817, 0.8587, 0.7945, 0.8751]}, {"w": "instances", "b": [0.7981, 0.8587, 0.8567, 0.8751]}, {"w": "to", "b": [0.1587, 0.8749, 0.1717, 0.8912]}, {"w": "sample", "b": [0.1753, 0.8749, 0.2198, 0.8912]}, {"w": "is", "b": [0.2235, 0.8749, 0.2335, 0.8912]}, {"w": "equal", "b": [0.2371, 0.8749, 0.2714, 0.8912]}, {"w": "to", "b": [0.275, 0.8749, 0.2879, 0.8912]}, {"w": "the", "b": [0.2915, 0.8749, 0.3116, 0.8912]}, {"w": "size", "b": [0.3152, 0.8749, 0.3387, 0.8912]}, {"w": "of", "b": [0.3423, 0.8749, 0.3551, 0.8912]}, {"w": "the", "b": [0.3587, 0.8749, 0.3788, 0.8912]}, {"w": "training", "b": [0.3824, 0.8749, 0.4334, 0.8912]}, {"w": "set", "b": [0.437, 0.8749, 0.4544, 0.8912]}, {"w": "times", "b": [0.458, 0.8749, 0.4927, 0.8912]}, {"w": "max_samples.", "b": [0.4963, 0.8749, 0.5828, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "predictor has a higher bias than if it were trained on the original training set, but aggregation reduces both bias and variance.4 Generally, the net result is that the ensemble has a similar bias but a lower variance than a single predictor trained on the original training set.", "words": [{"w": "predictor", "b": [0.1429, 0.0791, 0.2205, 0.1005]}, {"w": "has", "b": [0.2281, 0.0791, 0.256, 0.1005]}, {"w": "a", "b": [0.2637, 0.0791, 0.2729, 0.1005]}, {"w": "higher", "b": [0.2805, 0.0791, 0.3347, 0.1005]}, {"w": "bias", "b": [0.3424, 0.0791, 0.3753, 0.1005]}, {"w": "than", "b": [0.383, 0.0791, 0.421, 0.1005]}, {"w": "if", "b": [0.4287, 0.0791, 0.4404, 0.1005]}, {"w": "it", "b": [0.4481, 0.0791, 0.46, 0.1005]}, {"w": "were", "b": [0.4677, 0.0791, 0.5074, 0.1005]}, {"w": "trained", "b": [0.5151, 0.0791, 0.5751, 0.1005]}, {"w": "on", "b": [0.5828, 0.0791, 0.6048, 0.1005]}, {"w": "the", "b": [0.6125, 0.0791, 0.6388, 0.1005]}, {"w": "original", "b": [0.6465, 0.0791, 0.7116, 0.1005]}, {"w": "training", "b": [0.7193, 0.0791, 0.7862, 0.1005]}, {"w": "set,", "b": [0.7939, 0.0791, 0.8215, 0.1005]}, {"w": "but", "b": [0.8291, 0.0791, 0.8571, 0.1005]}, {"w": "aggregation", "b": [0.1429, 0.0981, 0.2405, 0.1195]}, {"w": "reduces", "b": [0.2499, 0.0981, 0.3139, 0.1195]}, {"w": "both", "b": [0.3232, 0.0981, 0.3619, 0.1195]}, {"w": "bias", "b": [0.3713, 0.0981, 0.4043, 0.1195]}, {"w": "and", "b": [0.4136, 0.0981, 0.4452, 0.1195]}, {"w": "variance.4", "b": [0.4545, 0.0981, 0.5353, 0.1195]}, {"w": "Generally,", "b": [0.5447, 0.0981, 0.6289, 0.1195]}, {"w": "the", "b": [0.6383, 0.0981, 0.6646, 0.1195]}, {"w": "net", "b": [0.674, 0.0981, 0.7006, 0.1195]}, {"w": "result", "b": [0.71, 0.0981, 0.7569, 0.1195]}, {"w": "is", "b": [0.7663, 0.0981, 0.7795, 0.1195]}, {"w": "that", "b": [0.7889, 0.0981, 0.8214, 0.1195]}, {"w": "the", "b": [0.8308, 0.0981, 0.8571, 0.1195]}, {"w": "ensemble", "b": [0.1429, 0.1172, 0.2214, 0.1386]}, {"w": "has", "b": [0.2262, 0.1172, 0.2541, 0.1386]}, {"w": "a", "b": [0.2589, 0.1172, 0.268, 0.1386]}, {"w": "similar", "b": [0.2728, 0.1172, 0.3308, 0.1386]}, {"w": "bias", "b": [0.3356, 0.1172, 0.3686, 0.1386]}, {"w": "but", "b": [0.3734, 0.1172, 0.4014, 0.1386]}, {"w": "a", "b": [0.4062, 0.1172, 0.4153, 0.1386]}, {"w": "lower", "b": [0.4201, 0.1172, 0.4668, 0.1386]}, {"w": "variance", "b": [0.4716, 0.1172, 0.5419, 0.1386]}, {"w": "than", "b": [0.5467, 0.1172, 0.5847, 0.1386]}, {"w": "a", "b": [0.5895, 0.1172, 0.5987, 0.1386]}, {"w": "single", "b": [0.6035, 0.1172, 0.652, 0.1386]}, {"w": "predictor", "b": [0.6568, 0.1172, 0.7344, 0.1386]}, {"w": "trained", "b": [0.7391, 0.1172, 0.7992, 0.1386]}, {"w": "on", "b": [0.804, 0.1172, 0.826, 0.1386]}, {"w": "the", "b": [0.8308, 0.1172, 0.8571, 0.1386]}, {"w": "original", "b": [0.1429, 0.1362, 0.2079, 0.1576]}, {"w": "training", "b": [0.2127, 0.1362, 0.2796, 0.1576]}, {"w": "set.", "b": [0.2843, 0.1362, 0.3119, 0.1576]}]}, {"id": "b_3", "type": "paragraph", "text": "As you can see in Figure 7-4, predictors can all be trained in parallel, via different CPU cores or even different servers. Similarly, predictions can be made in parallel. This is one of the reasons why bagging and pasting are such popular methods: they scale very well.", "words": [{"w": "As", "b": [0.1429, 0.1643, 0.1649, 0.1857]}, {"w": "you", "b": [0.1722, 0.1643, 0.2035, 0.1857]}, {"w": "can", "b": [0.2108, 0.1643, 0.2402, 0.1857]}, {"w": "see", "b": [0.2475, 0.1643, 0.2728, 0.1857]}, {"w": "in", "b": [0.2802, 0.1643, 0.2971, 0.1857]}, {"w": "Figure", "b": [0.3045, 0.1643, 0.3585, 0.1857]}, {"w": "7-4,", "b": [0.3658, 0.1643, 0.398, 0.1857]}, {"w": "predictors", "b": [0.4053, 0.1643, 0.4905, 0.1857]}, {"w": "can", "b": [0.4979, 0.1643, 0.5272, 0.1857]}, {"w": "all", "b": [0.5346, 0.1643, 0.5542, 0.1857]}, {"w": "be", "b": [0.5616, 0.1643, 0.581, 0.1857]}, {"w": "trained", "b": [0.5883, 0.1643, 0.6484, 0.1857]}, {"w": "in", "b": [0.6557, 0.1643, 0.6727, 0.1857]}, {"w": "parallel,", "b": [0.68, 0.1643, 0.7464, 0.1857]}, {"w": "via", "b": [0.7537, 0.1643, 0.7781, 0.1857]}, {"w": "different", "b": [0.7854, 0.1643, 0.8571, 0.1857]}, {"w": "CPU", "b": [0.1429, 0.1834, 0.1838, 0.2048]}, {"w": "cores", "b": [0.191, 0.1834, 0.2347, 0.2048]}, {"w": "or", "b": [0.2419, 0.1834, 0.2602, 0.2048]}, {"w": "even", "b": [0.2674, 0.1834, 0.3062, 0.2048]}, {"w": "different", "b": [0.3134, 0.1834, 0.3851, 0.2048]}, {"w": "servers.", "b": [0.3923, 0.1834, 0.4557, 0.2048]}, {"w": "Similarly,", "b": [0.4629, 0.1834, 0.5412, 0.2048]}, {"w": "predictions", "b": [0.5485, 0.1834, 0.643, 0.2048]}, {"w": "can", "b": [0.6502, 0.1834, 0.6795, 0.2048]}, {"w": "be", "b": [0.6867, 0.1834, 0.7061, 0.2048]}, {"w": "made", "b": [0.7134, 0.1834, 0.7594, 0.2048]}, {"w": "in", "b": [0.7666, 0.1834, 0.7836, 0.2048]}, {"w": "parallel.", "b": [0.7908, 0.1834, 0.8572, 0.2048]}, {"w": "This", "b": [0.1429, 0.2024, 0.1801, 0.2238]}, {"w": "is", "b": [0.1865, 0.2024, 0.1998, 0.2238]}, {"w": "one", "b": [0.2063, 0.2024, 0.2371, 0.2238]}, {"w": "of", "b": [0.2436, 0.2024, 0.2604, 0.2238]}, {"w": "the", "b": [0.2669, 0.2024, 0.2932, 0.2238]}, {"w": "reasons", "b": [0.2997, 0.2024, 0.3627, 0.2238]}, {"w": "why", "b": [0.3692, 0.2024, 0.4037, 0.2238]}, {"w": "bagging", "b": [0.4102, 0.2024, 0.4761, 0.2238]}, {"w": "and", "b": [0.4826, 0.2024, 0.5141, 0.2238]}, {"w": "pasting", "b": [0.5206, 0.2024, 0.5814, 0.2238]}, {"w": "are", "b": [0.5879, 0.2024, 0.6136, 0.2238]}, {"w": "such", "b": [0.6201, 0.2024, 0.6587, 0.2238]}, {"w": "popular", "b": [0.6652, 0.2024, 0.7309, 0.2238]}, {"w": "methods:", "b": [0.7374, 0.2024, 0.8148, 0.2238]}, {"w": "they", "b": [0.8213, 0.2024, 0.8571, 0.2238]}, {"w": "scale", "b": [0.1429, 0.2215, 0.1826, 0.2429]}, {"w": "very", "b": [0.1873, 0.2215, 0.2237, 0.2429]}, {"w": "well.", "b": [0.2284, 0.2215, 0.2669, 0.2429]}]}, {"id": "b_4", "type": "equation", "text": "Bagging and Pasting in Scikit-Learn", "words": [{"w": "Bagging", "b": [0.1429, 0.2556, 0.2293, 0.2842]}, {"w": "and", "b": [0.2343, 0.2556, 0.2735, 0.2842]}, {"w": "Pasting", "b": [0.2785, 0.2556, 0.3562, 0.2842]}, {"w": "in", "b": [0.3612, 0.2556, 0.3812, 0.2842]}, {"w": "Scikit-Learn", "b": [0.3861, 0.2556, 0.5082, 0.2842]}]}, {"id": "b_5", "type": "paragraph", "text": "Scikit-Learn offers a simple API for both bagging and pasting with the BaggingClas sifier class (or BaggingRegressor for regression). The following code trains an ensemble of 500 Decision Tree classifiers,5 each trained on 100 training instances ran‐ domly sampled from the training set with replacement (this is an example of bagging, but if you want to use pasting instead, just set bootstrap=False). The n_jobs param‐ eter tells Scikit-Learn the number of CPU cores to use for training and predictions (–1 tells Scikit-Learn to use all available cores):", "words": [{"w": "Scikit-Learn", "b": [0.1428, 0.291, 0.2451, 0.3124]}, {"w": "offers", "b": [0.2512, 0.291, 0.2983, 0.3124]}, {"w": "a", "b": [0.3044, 0.291, 0.3135, 0.3124]}, {"w": "simple", "b": [0.3195, 0.291, 0.3745, 0.3124]}, {"w": "API", "b": [0.3805, 0.291, 0.4137, 0.3124]}, {"w": "for", "b": [0.4197, 0.291, 0.4443, 0.3124]}, {"w": "both", "b": [0.4503, 0.291, 0.489, 0.3124]}, {"w": "bagging", "b": [0.495, 0.291, 0.561, 0.3124]}, {"w": "and", "b": [0.567, 0.291, 0.5985, 0.3124]}, {"w": "pasting", "b": [0.6045, 0.291, 0.6653, 0.3124]}, {"w": "with", "b": [0.6713, 0.291, 0.7087, 0.3124]}, {"w": "the", "b": [0.7147, 0.291, 0.741, 0.3124]}, {"w": "BaggingClas", "b": [0.7471, 0.2942, 0.8559, 0.3093]}, {"w": "sifier", "b": [0.1429, 0.3141, 0.2022, 0.3292]}, {"w": "class", "b": [0.2113, 0.311, 0.2498, 0.3324]}, {"w": "(or", "b": [0.2589, 0.311, 0.2845, 0.3324]}, {"w": "BaggingRegressor", "b": [0.2935, 0.3141, 0.4519, 0.3292]}, {"w": "for", "b": [0.4609, 0.311, 0.4855, 0.3324]}, {"w": "regression).", "b": [0.4945, 0.311, 0.5923, 0.3324]}, {"w": "The", "b": [0.6014, 0.311, 0.6342, 0.3324]}, {"w": "following", "b": [0.6433, 0.311, 0.7222, 0.3324]}, {"w": "code", "b": [0.7313, 0.311, 0.7706, 0.3324]}, {"w": "trains", "b": [0.7797, 0.311, 0.8275, 0.3324]}, {"w": "an", "b": [0.8366, 0.311, 0.8571, 0.3324]}, {"w": "ensemble", "b": [0.1429, 0.33, 0.2214, 0.3514]}, {"w": "of", "b": [0.2261, 0.33, 0.2429, 0.3514]}, {"w": "500", "b": [0.2479, 0.33, 0.2779, 0.3514]}, {"w": "Decision", "b": [0.2827, 0.33, 0.3565, 0.3514]}, {"w": "Tree", "b": [0.3612, 0.33, 0.3978, 0.3514]}, {"w": "classifiers,5", "b": [0.4025, 0.33, 0.4935, 0.3514]}, {"w": "each", "b": [0.4984, 0.33, 0.5363, 0.3514]}, {"w": "trained", "b": [0.5412, 0.33, 0.6013, 0.3514]}, {"w": "on", "b": [0.6061, 0.33, 0.6282, 0.3514]}, {"w": "100", "b": [0.6331, 0.33, 0.6631, 0.3514]}, {"w": "training", "b": [0.6679, 0.33, 0.7349, 0.3514]}, {"w": "instances", "b": [0.7398, 0.33, 0.8166, 0.3514]}, {"w": "ran‐", "b": [0.8215, 0.33, 0.8572, 0.3514]}, {"w": "domly", "b": [0.1429, 0.349, 0.1964, 0.3705]}, {"w": "sampled", "b": [0.2014, 0.349, 0.2709, 0.3705]}, {"w": "from", "b": [0.2758, 0.349, 0.3174, 0.3705]}, {"w": "the", "b": [0.3224, 0.349, 0.3487, 0.3705]}, {"w": "training", "b": [0.3537, 0.349, 0.4206, 0.3705]}, {"w": "set", "b": [0.4256, 0.349, 0.4485, 0.3705]}, {"w": "with", "b": [0.4534, 0.349, 0.4908, 0.3705]}, {"w": "replacement", "b": [0.4957, 0.349, 0.5986, 0.3705]}, {"w": "(this", "b": [0.6036, 0.349, 0.6415, 0.3705]}, {"w": "is", "b": [0.6464, 0.349, 0.6597, 0.3705]}, {"w": "an", "b": [0.6646, 0.349, 0.6852, 0.3705]}, {"w": "example", "b": [0.6902, 0.349, 0.7597, 0.3705]}, {"w": "of", "b": [0.7647, 0.349, 0.7815, 0.3705]}, {"w": "bagging,", "b": [0.7864, 0.349, 0.8571, 0.3705]}, {"w": "but", "b": [0.1429, 0.369, 0.1709, 0.3904]}, {"w": "if", "b": [0.1759, 0.369, 0.1876, 0.3904]}, {"w": "you", "b": [0.1926, 0.369, 0.2239, 0.3904]}, {"w": "want", "b": [0.2289, 0.369, 0.2697, 0.3904]}, {"w": "to", "b": [0.2747, 0.369, 0.2917, 0.3904]}, {"w": "use", "b": [0.2967, 0.369, 0.3242, 0.3904]}, {"w": "pasting", "b": [0.3293, 0.369, 0.39, 0.3904]}, {"w": "instead,", "b": [0.3951, 0.369, 0.4598, 0.3904]}, {"w": "just", "b": [0.4648, 0.369, 0.4952, 0.3904]}, {"w": "set", "b": [0.5002, 0.369, 0.5231, 0.3904]}, {"w": "bootstrap=False).", "b": [0.5281, 0.369, 0.6885, 0.3904]}, {"w": "The", "b": [0.6932, 0.369, 0.726, 0.3904]}, {"w": "n_jobs", "b": [0.7313, 0.3722, 0.7907, 0.3873]}, {"w": "param‐", "b": [0.7957, 0.369, 0.8572, 0.3904]}, {"w": "eter", "b": [0.1429, 0.388, 0.1747, 0.4095]}, {"w": "tells", "b": [0.1816, 0.388, 0.215, 0.4095]}, {"w": "Scikit-Learn", "b": [0.222, 0.388, 0.3243, 0.4095]}, {"w": "the", "b": [0.3313, 0.388, 0.3576, 0.4095]}, {"w": "number", "b": [0.3646, 0.388, 0.4309, 0.4095]}, {"w": "of", "b": [0.4379, 0.388, 0.4547, 0.4095]}, {"w": "CPU", "b": [0.4616, 0.388, 0.5026, 0.4095]}, {"w": "cores", "b": [0.5095, 0.388, 0.5532, 0.4095]}, {"w": "to", "b": [0.5602, 0.388, 0.5772, 0.4095]}, {"w": "use", "b": [0.5842, 0.388, 0.6117, 0.4095]}, {"w": "for", "b": [0.6187, 0.388, 0.6432, 0.4095]}, {"w": "training", "b": [0.6502, 0.388, 0.7171, 0.4095]}, {"w": "and", "b": [0.7241, 0.388, 0.7557, 0.4095]}, {"w": "predictions", "b": [0.7626, 0.388, 0.8571, 0.4095]}, {"w": "(–1", "b": [0.1429, 0.4071, 0.1709, 0.4285]}, {"w": "tells", "b": [0.1756, 0.4071, 0.209, 0.4285]}, {"w": "Scikit-Learn", "b": [0.2138, 0.4071, 0.316, 0.4285]}, {"w": "to", "b": [0.3208, 0.4071, 0.3378, 0.4285]}, {"w": "use", "b": [0.3425, 0.4071, 0.37, 0.4285]}, {"w": "all", "b": [0.3748, 0.4071, 0.3945, 0.4285]}, {"w": "available", "b": [0.3992, 0.4071, 0.4715, 0.4285]}, {"w": "cores):", "b": [0.4762, 0.4071, 0.5318, 0.4285]}]}, {"id": "b_6", "type": "paragraph", "text": "from sklearn.ensemble import BaggingClassifier from sklearn.tree import DecisionTreeClassifier", "words": [{"w": "from", "b": [0.1766, 0.4391, 0.2103, 0.4519]}, {"w": "sklearn.ensemble", "b": [0.2187, 0.4391, 0.3537, 0.4519]}, {"w": "import", "b": [0.3621, 0.4391, 0.4127, 0.4519]}, {"w": "BaggingClassifier", "b": [0.4211, 0.4391, 0.5645, 0.4519]}, {"w": "from", "b": [0.1766, 0.4545, 0.2103, 0.4673]}, {"w": "sklearn.tree", "b": [0.2187, 0.4545, 0.3199, 0.4673]}, {"w": "import", "b": [0.3284, 0.4545, 0.379, 0.4673]}, {"w": "DecisionTreeClassifier", "b": [0.3874, 0.4545, 0.5729, 0.4673]}]}, {"id": "b_7", "type": "paragraph", "text": "bag_clf = BaggingClassifier( DecisionTreeClassifier(), n_estimators=500, max_samples=100, bootstrap=True, n_jobs=-1) bag_clf.fit(X_train, y_train) y_pred = bag_clf.predict(X_test)", "words": [{"w": "bag_clf", "b": [0.1766, 0.4853, 0.2356, 0.4982]}, {"w": "=", "b": [0.244, 0.4853, 0.2525, 0.4982]}, {"w": "BaggingClassifier(", "b": [0.2609, 0.4853, 0.4127, 0.4982]}, {"w": "DecisionTreeClassifier(),", "b": [0.2103, 0.5007, 0.4211, 0.5136]}, {"w": "n_estimators=500,", "b": [0.4296, 0.5007, 0.5729, 0.5136]}, {"w": "max_samples=100,", "b": [0.2103, 0.5162, 0.3452, 0.529]}, {"w": "bootstrap=True,", "b": [0.3537, 0.5162, 0.4802, 0.529]}, {"w": "n_jobs=-1)", "b": [0.4886, 0.5162, 0.5729, 0.529]}, {"w": "bag_clf.fit(X_train,", "b": [0.1766, 0.5316, 0.3452, 0.5444]}, {"w": "y_train)", "b": [0.3537, 0.5316, 0.4211, 0.5444]}, {"w": "y_pred", "b": [0.1766, 0.547, 0.2272, 0.5598]}, {"w": "=", "b": [0.2356, 0.547, 0.244, 0.5598]}, {"w": "bag_clf.predict(X_test)", "b": [0.2525, 0.547, 0.4464, 0.5598]}]}, {"id": "b_8", "type": "paragraph", "text": "The BaggingClassifier automatically performs soft voting instead of hard voting if the base classifier can estimate class proba‐ bilities (i.e., if it has a predict_proba() method), which is the case with Decision Trees classifiers.", "words": [{"w": "The", "b": [0.2714, 0.5823, 0.3014, 0.6019]}, {"w": "BaggingClassifier", "b": [0.3175, 0.5852, 0.4713, 0.599]}, {"w": "automatically", "b": [0.4874, 0.5823, 0.5904, 0.6019]}, {"w": "performs", "b": [0.6065, 0.5823, 0.6766, 0.6019]}, {"w": "soft", "b": [0.6927, 0.5823, 0.7209, 0.6019]}, {"w": "voting", "b": [0.7369, 0.5823, 0.7857, 0.6019]}, {"w": "instead", "b": [0.2714, 0.5997, 0.3263, 0.6193]}, {"w": "of", "b": [0.3307, 0.5997, 0.346, 0.6193]}, {"w": "hard", "b": [0.3504, 0.5997, 0.3861, 0.6193]}, {"w": "voting", "b": [0.3905, 0.5997, 0.4392, 0.6193]}, {"w": "if", "b": [0.4436, 0.5997, 0.4544, 0.6193]}, {"w": "the", "b": [0.4588, 0.5997, 0.4828, 0.6193]}, {"w": "base", "b": [0.4872, 0.5997, 0.5204, 0.6193]}, {"w": "classifier", "b": [0.5248, 0.5997, 0.591, 0.6193]}, {"w": "can", "b": [0.5954, 0.5997, 0.6222, 0.6193]}, {"w": "estimate", "b": [0.6266, 0.5997, 0.6901, 0.6193]}, {"w": "class", "b": [0.6945, 0.5997, 0.7297, 0.6193]}, {"w": "proba‐", "b": [0.7341, 0.5997, 0.7857, 0.6193]}, {"w": "bilities", "b": [0.2714, 0.6179, 0.3221, 0.6375]}, {"w": "(i.e.,", "b": [0.3271, 0.6179, 0.3599, 0.6375]}, {"w": "if", "b": [0.3649, 0.6179, 0.3757, 0.6375]}, {"w": "it", "b": [0.3807, 0.6179, 0.3916, 0.6375]}, {"w": "has", "b": [0.3966, 0.6179, 0.4221, 0.6375]}, {"w": "a", "b": [0.4271, 0.6179, 0.4354, 0.6375]}, {"w": "predict_proba()", "b": [0.4404, 0.6208, 0.5762, 0.6346]}, {"w": "method),", "b": [0.5811, 0.6179, 0.6515, 0.6375]}, {"w": "which", "b": [0.6565, 0.6179, 0.7031, 0.6375]}, {"w": "is", "b": [0.7081, 0.6179, 0.7202, 0.6375]}, {"w": "the", "b": [0.7251, 0.6179, 0.7492, 0.6375]}, {"w": "case", "b": [0.7542, 0.6179, 0.7857, 0.6375]}, {"w": "with", "b": [0.2714, 0.6353, 0.3056, 0.6549]}, {"w": "Decision", "b": [0.3099, 0.6353, 0.3774, 0.6549]}, {"w": "Trees", "b": [0.3817, 0.6353, 0.4221, 0.6549]}, {"w": "classifiers.", "b": [0.4264, 0.6353, 0.504, 0.6549]}]}, {"id": "b_9", "type": "paragraph", "text": "Figure 7-5 compares the decision boundary of a single Decision Tree with the deci‐ sion boundary of a bagging ensemble of 500 trees (from the preceding code), both trained on the moons dataset. As you can see, the ensemble’s predictions will likely generalize much better than the single Decision Tree’s predictions: the ensemble has a comparable bias but a smaller variance (it makes roughly the same number of errors on the training set, but the decision boundary is less irregular).", "words": [{"w": "Figure", "b": [0.1429, 0.6801, 0.1969, 0.7015]}, {"w": "7-5", "b": [0.2034, 0.6801, 0.2308, 0.7015]}, {"w": "compares", "b": [0.2373, 0.6801, 0.3177, 0.7015]}, {"w": "the", "b": [0.3242, 0.6801, 0.3506, 0.7015]}, {"w": "decision", "b": [0.3571, 0.6801, 0.4266, 0.7015]}, {"w": "boundary", "b": [0.4331, 0.6801, 0.5148, 0.7015]}, {"w": "of", "b": [0.5213, 0.6801, 0.5381, 0.7015]}, {"w": "a", "b": [0.5447, 0.6801, 0.5538, 0.7015]}, {"w": "single", "b": [0.5603, 0.6801, 0.6088, 0.7015]}, {"w": "Decision", "b": [0.6154, 0.6801, 0.6892, 0.7015]}, {"w": "Tree", "b": [0.6957, 0.6801, 0.7322, 0.7015]}, {"w": "with", "b": [0.7388, 0.6801, 0.7761, 0.7015]}, {"w": "the", "b": [0.7826, 0.6801, 0.809, 0.7015]}, {"w": "deci‐", "b": [0.8155, 0.6801, 0.8571, 0.7015]}, {"w": "sion", "b": [0.1429, 0.6992, 0.1781, 0.7206]}, {"w": "boundary", "b": [0.1852, 0.6992, 0.2669, 0.7206]}, {"w": "of", "b": [0.2741, 0.6992, 0.2909, 0.7206]}, {"w": "a", "b": [0.298, 0.6992, 0.3072, 0.7206]}, {"w": "bagging", "b": [0.3143, 0.6992, 0.3802, 0.7206]}, {"w": "ensemble", "b": [0.3874, 0.6992, 0.4659, 0.7206]}, {"w": "of", "b": [0.473, 0.6992, 0.4898, 0.7206]}, {"w": "500", "b": [0.497, 0.6992, 0.527, 0.7206]}, {"w": "trees", "b": [0.5341, 0.6992, 0.5735, 0.7206]}, {"w": "(from", "b": [0.5807, 0.6992, 0.6294, 0.7206]}, {"w": "the", "b": [0.6366, 0.6992, 0.6629, 0.7206]}, {"w": "preceding", "b": [0.67, 0.6992, 0.7529, 0.7206]}, {"w": "code),", "b": [0.7601, 0.6992, 0.8113, 0.7206]}, {"w": "both", "b": [0.8185, 0.6992, 0.8571, 0.7206]}, {"w": "trained", "b": [0.1429, 0.7182, 0.2029, 0.7396]}, {"w": "on", "b": [0.2098, 0.7182, 0.2318, 0.7396]}, {"w": "the", "b": [0.2387, 0.7182, 0.265, 0.7396]}, {"w": "moons", "b": [0.2718, 0.7182, 0.3292, 0.7396]}, {"w": "dataset.", "b": [0.3361, 0.7182, 0.3989, 0.7396]}, {"w": "As", "b": [0.4058, 0.7182, 0.4278, 0.7396]}, {"w": "you", "b": [0.4347, 0.7182, 0.4659, 0.7396]}, {"w": "can", "b": [0.4728, 0.7182, 0.5021, 0.7396]}, {"w": "see,", "b": [0.509, 0.7182, 0.5391, 0.7396]}, {"w": "the", "b": [0.546, 0.7182, 0.5723, 0.7396]}, {"w": "ensemble’s", "b": [0.5792, 0.7182, 0.6668, 0.7396]}, {"w": "predictions", "b": [0.6736, 0.7182, 0.7681, 0.7396]}, {"w": "will", "b": [0.775, 0.7182, 0.8054, 0.7396]}, {"w": "likely", "b": [0.8123, 0.7182, 0.8571, 0.7396]}, {"w": "generalize", "b": [0.1429, 0.7372, 0.2271, 0.7587]}, {"w": "much", "b": [0.2321, 0.7372, 0.2797, 0.7587]}, {"w": "better", "b": [0.2848, 0.7372, 0.3335, 0.7587]}, {"w": "than", "b": [0.3385, 0.7372, 0.3765, 0.7587]}, {"w": "the", "b": [0.3815, 0.7372, 0.4079, 0.7587]}, {"w": "single", "b": [0.4129, 0.7372, 0.4614, 0.7587]}, {"w": "Decision", "b": [0.4664, 0.7372, 0.5402, 0.7587]}, {"w": "Tree’s", "b": [0.5452, 0.7372, 0.5909, 0.7587]}, {"w": "predictions:", "b": [0.5959, 0.7372, 0.6952, 0.7587]}, {"w": "the", "b": [0.7002, 0.7372, 0.7265, 0.7587]}, {"w": "ensemble", "b": [0.7315, 0.7372, 0.8101, 0.7587]}, {"w": "has", "b": [0.8151, 0.7372, 0.843, 0.7587]}, {"w": "a", "b": [0.848, 0.7372, 0.8572, 0.7587]}, {"w": "comparable", "b": [0.1429, 0.7563, 0.2406, 0.7777]}, {"w": "bias", "b": [0.2464, 0.7563, 0.2794, 0.7777]}, {"w": "but", "b": [0.2852, 0.7563, 0.3132, 0.7777]}, {"w": "a", "b": [0.319, 0.7563, 0.3281, 0.7777]}, {"w": "smaller", "b": [0.3339, 0.7563, 0.3949, 0.7777]}, {"w": "variance", "b": [0.4007, 0.7563, 0.471, 0.7777]}, {"w": "(it", "b": [0.4768, 0.7563, 0.4959, 0.7777]}, {"w": "makes", "b": [0.5017, 0.7563, 0.5548, 0.7777]}, {"w": "roughly", "b": [0.5606, 0.7563, 0.6257, 0.7777]}, {"w": "the", "b": [0.6315, 0.7563, 0.6578, 0.7777]}, {"w": "same", "b": [0.6636, 0.7563, 0.7064, 0.7777]}, {"w": "number", "b": [0.7122, 0.7563, 0.7784, 0.7777]}, {"w": "of", "b": [0.7842, 0.7563, 0.801, 0.7777]}, {"w": "errors", "b": [0.8068, 0.7563, 0.8571, 0.7777]}, {"w": "on", "b": [0.1429, 0.7753, 0.1649, 0.7968]}, {"w": "the", "b": [0.1696, 0.7753, 0.1959, 0.7968]}, {"w": "training", "b": [0.2007, 0.7753, 0.2676, 0.7968]}, {"w": "set,", "b": [0.2723, 0.7753, 0.2999, 0.7968]}, {"w": "but", "b": [0.3047, 0.7753, 0.3327, 0.7968]}, {"w": "the", "b": [0.3374, 0.7753, 0.3637, 0.7968]}, {"w": "decision", "b": [0.3685, 0.7753, 0.438, 0.7968]}, {"w": "boundary", "b": [0.4427, 0.7753, 0.5244, 0.7968]}, {"w": "is", "b": [0.5291, 0.7753, 0.5424, 0.7968]}, {"w": "less", "b": [0.5471, 0.7753, 0.5765, 0.7968]}, {"w": "irregular).", "b": [0.5812, 0.7753, 0.666, 0.7968]}]}, {"id": "b_10", "type": "paragraph", "text": "196 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "196", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 223, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 As m grows, this ratio approaches 1 – exp(–1) ≈ 63.212%.", "words": [{"w": "6", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "As", "b": [0.1587, 0.8749, 0.1755, 0.8912]}, {"w": "m", "b": [0.1791, 0.8748, 0.1916, 0.8912]}, {"w": "grows,", "b": [0.1952, 0.8749, 0.237, 0.8912]}, {"w": "this", "b": [0.2406, 0.8749, 0.264, 0.8912]}, {"w": "ratio", "b": [0.2676, 0.8749, 0.2973, 0.8912]}, {"w": "approaches", "b": [0.3009, 0.8749, 0.3729, 0.8912]}, {"w": "1", "b": [0.3765, 0.8749, 0.3841, 0.8912]}, {"w": "–", "b": [0.3877, 0.8749, 0.396, 0.8912]}, {"w": "exp(–1)", "b": [0.3996, 0.8749, 0.449, 0.8912]}, {"w": "≈", "b": [0.4526, 0.8749, 0.4619, 0.8912]}, {"w": "63.212%.", "b": [0.4655, 0.8749, 0.5229, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 7-5. A single Decision Tree versus a bagging ensemble of 500 trees", "words": [{"w": "Figure", "b": [0.1429, 0.2787, 0.1943, 0.3003]}, {"w": "7-5.", "b": [0.1991, 0.2787, 0.2308, 0.3003]}, {"w": "A", "b": [0.2356, 0.2787, 0.2494, 0.3003]}, {"w": "single", "b": [0.2542, 0.2787, 0.2994, 0.3003]}, {"w": "Decision", "b": [0.3042, 0.2787, 0.3741, 0.3003]}, {"w": "Tree", "b": [0.3789, 0.2787, 0.4136, 0.3003]}, {"w": "versus", "b": [0.4184, 0.2787, 0.4685, 0.3003]}, {"w": "a", "b": [0.4733, 0.2787, 0.4835, 0.3003]}, {"w": "bagging", "b": [0.4883, 0.2787, 0.5511, 0.3003]}, {"w": "ensemble", "b": [0.5559, 0.2787, 0.6301, 0.3003]}, {"w": "of", "b": [0.6349, 0.2787, 0.6501, 0.3003]}, {"w": "500", "b": [0.6549, 0.2787, 0.6847, 0.3003]}, {"w": "trees", "b": [0.6895, 0.2787, 0.7263, 0.3003]}]}, {"id": "b_2", "type": "paragraph", "text": "Bootstrapping introduces a bit more diversity in the subsets that each predictor is trained on, so bagging ends up with a slightly higher bias than pasting, but this also means that predictors end up being less correlated so the ensemble’s variance is reduced. Overall, bagging often results in better models, which explains why it is gen‐ erally preferred. However, if you have spare time and CPU power you can use cross- validation to evaluate both bagging and pasting and select the one that works best.", "words": [{"w": "Bootstrapping", "b": [0.1429, 0.3161, 0.2622, 0.3375]}, {"w": "introduces", "b": [0.27, 0.3161, 0.3587, 0.3375]}, {"w": "a", "b": [0.3665, 0.3161, 0.3756, 0.3375]}, {"w": "bit", "b": [0.3835, 0.3161, 0.406, 0.3375]}, {"w": "more", "b": [0.4138, 0.3161, 0.4581, 0.3375]}, {"w": "diversity", "b": [0.4659, 0.3161, 0.5379, 0.3375]}, {"w": "in", "b": [0.5457, 0.3161, 0.5627, 0.3375]}, {"w": "the", "b": [0.5705, 0.3161, 0.5969, 0.3375]}, {"w": "subsets", "b": [0.6047, 0.3161, 0.6645, 0.3375]}, {"w": "that", "b": [0.6723, 0.3161, 0.7049, 0.3375]}, {"w": "each", "b": [0.7127, 0.3161, 0.7507, 0.3375]}, {"w": "predictor", "b": [0.7585, 0.3161, 0.8361, 0.3375]}, {"w": "is", "b": [0.8439, 0.3161, 0.8571, 0.3375]}, {"w": "trained", "b": [0.1429, 0.3351, 0.2029, 0.3565]}, {"w": "on,", "b": [0.2092, 0.3351, 0.2359, 0.3565]}, {"w": "so", "b": [0.2422, 0.3351, 0.2604, 0.3565]}, {"w": "bagging", "b": [0.2667, 0.3351, 0.3326, 0.3565]}, {"w": "ends", "b": [0.3389, 0.3351, 0.3778, 0.3565]}, {"w": "up", "b": [0.384, 0.3351, 0.406, 0.3565]}, {"w": "with", "b": [0.4122, 0.3351, 0.4496, 0.3565]}, {"w": "a", "b": [0.4558, 0.3351, 0.465, 0.3565]}, {"w": "slightly", "b": [0.4712, 0.3351, 0.5314, 0.3565]}, {"w": "higher", "b": [0.5376, 0.3351, 0.5918, 0.3565]}, {"w": "bias", "b": [0.598, 0.3351, 0.631, 0.3565]}, {"w": "than", "b": [0.6372, 0.3351, 0.6752, 0.3565]}, {"w": "pasting,", "b": [0.6815, 0.3351, 0.747, 0.3565]}, {"w": "but", "b": [0.7533, 0.3351, 0.7813, 0.3565]}, {"w": "this", "b": [0.7875, 0.3351, 0.8182, 0.3565]}, {"w": "also", "b": [0.8244, 0.3351, 0.8571, 0.3565]}, {"w": "means", "b": [0.1429, 0.3542, 0.197, 0.3756]}, {"w": "that", "b": [0.2065, 0.3542, 0.239, 0.3756]}, {"w": "predictors", "b": [0.2485, 0.3542, 0.3338, 0.3756]}, {"w": "end", "b": [0.3433, 0.3542, 0.3745, 0.3756]}, {"w": "up", "b": [0.384, 0.3542, 0.406, 0.3756]}, {"w": "being", "b": [0.4154, 0.3542, 0.4616, 0.3756]}, {"w": "less", "b": [0.4711, 0.3542, 0.5005, 0.3756]}, {"w": "correlated", "b": [0.51, 0.3542, 0.594, 0.3756]}, {"w": "so", "b": [0.6035, 0.3542, 0.6217, 0.3756]}, {"w": "the", "b": [0.6312, 0.3542, 0.6575, 0.3756]}, {"w": "ensemble’s", "b": [0.667, 0.3542, 0.7546, 0.3756]}, {"w": "variance", "b": [0.7641, 0.3542, 0.8344, 0.3756]}, {"w": "is", "b": [0.8439, 0.3542, 0.8572, 0.3756]}, {"w": "reduced.", "b": [0.1429, 0.3732, 0.2149, 0.3946]}, {"w": "Overall,", "b": [0.2199, 0.3732, 0.2864, 0.3946]}, {"w": "bagging", "b": [0.2914, 0.3732, 0.3573, 0.3946]}, {"w": "often", "b": [0.3623, 0.3732, 0.4057, 0.3946]}, {"w": "results", "b": [0.4106, 0.3732, 0.4652, 0.3946]}, {"w": "in", "b": [0.4701, 0.3732, 0.4871, 0.3946]}, {"w": "better", "b": [0.492, 0.3732, 0.5408, 0.3946]}, {"w": "models,", "b": [0.5457, 0.3732, 0.6109, 0.3946]}, {"w": "which", "b": [0.6158, 0.3732, 0.6668, 0.3946]}, {"w": "explains", "b": [0.6717, 0.3732, 0.7403, 0.3946]}, {"w": "why", "b": [0.7453, 0.3732, 0.7798, 0.3946]}, {"w": "it", "b": [0.7847, 0.3732, 0.7966, 0.3946]}, {"w": "is", "b": [0.8016, 0.3732, 0.8148, 0.3946]}, {"w": "gen‐", "b": [0.8197, 0.3732, 0.8571, 0.3946]}, {"w": "erally", "b": [0.1429, 0.3922, 0.1887, 0.4137]}, {"w": "preferred.", "b": [0.1944, 0.3922, 0.277, 0.4137]}, {"w": "However,", "b": [0.2828, 0.3922, 0.3616, 0.4137]}, {"w": "if", "b": [0.3674, 0.3922, 0.3791, 0.4137]}, {"w": "you", "b": [0.3849, 0.3922, 0.4161, 0.4137]}, {"w": "have", "b": [0.4219, 0.3922, 0.4603, 0.4137]}, {"w": "spare", "b": [0.4661, 0.3922, 0.5103, 0.4137]}, {"w": "time", "b": [0.5161, 0.3922, 0.554, 0.4137]}, {"w": "and", "b": [0.5597, 0.3922, 0.5913, 0.4137]}, {"w": "CPU", "b": [0.597, 0.3922, 0.6379, 0.4137]}, {"w": "power", "b": [0.6437, 0.3922, 0.6961, 0.4137]}, {"w": "you", "b": [0.7018, 0.3922, 0.7331, 0.4137]}, {"w": "can", "b": [0.7388, 0.3922, 0.7682, 0.4137]}, {"w": "use", "b": [0.7739, 0.3922, 0.8015, 0.4137]}, {"w": "cross-", "b": [0.8073, 0.3922, 0.8571, 0.4137]}, {"w": "validation", "b": [0.1428, 0.4113, 0.2262, 0.4327]}, {"w": "to", "b": [0.2309, 0.4113, 0.2479, 0.4327]}, {"w": "evaluate", "b": [0.2526, 0.4113, 0.3206, 0.4327]}, {"w": "both", "b": [0.3253, 0.4113, 0.364, 0.4327]}, {"w": "bagging", "b": [0.3687, 0.4113, 0.4347, 0.4327]}, {"w": "and", "b": [0.4394, 0.4113, 0.471, 0.4327]}, {"w": "pasting", "b": [0.4757, 0.4113, 0.5365, 0.4327]}, {"w": "and", "b": [0.5412, 0.4113, 0.5727, 0.4327]}, {"w": "select", "b": [0.5775, 0.4113, 0.6233, 0.4327]}, {"w": "the", "b": [0.628, 0.4113, 0.6543, 0.4327]}, {"w": "one", "b": [0.6591, 0.4113, 0.6899, 0.4327]}, {"w": "that", "b": [0.6947, 0.4113, 0.7272, 0.4327]}, {"w": "works", "b": [0.732, 0.4113, 0.7826, 0.4327]}, {"w": "best.", "b": [0.7873, 0.4113, 0.8255, 0.4327]}]}, {"id": "b_3", "type": "equation", "text": "Out-of-Bag Evaluation", "words": [{"w": "Out-of-Bag", "b": [0.1428, 0.4455, 0.2573, 0.474]}, {"w": "Evaluation", "b": [0.2623, 0.4455, 0.3723, 0.474]}]}, {"id": "b_4", "type": "paragraph", "text": "With bagging, some instances may be sampled several times for any given predictor, while others may not be sampled at all. By default a BaggingClassifier samples m training instances with replacement (bootstrap=True), where m is the size of the training set. This means that only about 63% of the training instances are sampled on average for each predictor.6 The remaining 37% of the training instances that are not sampled are called out-of-bag (oob) instances. Note that they are not the same 37% for all predictors.", "words": [{"w": "With", "b": [0.1429, 0.4799, 0.1853, 0.5014]}, {"w": "bagging,", "b": [0.1914, 0.4799, 0.2621, 0.5014]}, {"w": "some", "b": [0.2681, 0.4799, 0.3123, 0.5014]}, {"w": "instances", "b": [0.3184, 0.4799, 0.3952, 0.5014]}, {"w": "may", "b": [0.4013, 0.4799, 0.4367, 0.5014]}, {"w": "be", "b": [0.4427, 0.4799, 0.4622, 0.5014]}, {"w": "sampled", "b": [0.4682, 0.4799, 0.5377, 0.5014]}, {"w": "several", "b": [0.5438, 0.4799, 0.6009, 0.5014]}, {"w": "times", "b": [0.607, 0.4799, 0.6525, 0.5014]}, {"w": "for", "b": [0.6586, 0.4799, 0.6831, 0.5014]}, {"w": "any", "b": [0.6891, 0.4799, 0.7188, 0.5014]}, {"w": "given", "b": [0.7248, 0.4799, 0.7701, 0.5014]}, {"w": "predictor,", "b": [0.7761, 0.4799, 0.8572, 0.5014]}, {"w": "while", "b": [0.1429, 0.4999, 0.188, 0.5213]}, {"w": "others", "b": [0.1945, 0.4999, 0.2469, 0.5213]}, {"w": "may", "b": [0.2534, 0.4999, 0.2888, 0.5213]}, {"w": "not", "b": [0.2954, 0.4999, 0.3238, 0.5213]}, {"w": "be", "b": [0.3303, 0.4999, 0.3498, 0.5213]}, {"w": "sampled", "b": [0.3564, 0.4999, 0.4259, 0.5213]}, {"w": "at", "b": [0.4324, 0.4999, 0.4475, 0.5213]}, {"w": "all.", "b": [0.4541, 0.4999, 0.4785, 0.5213]}, {"w": "By", "b": [0.4851, 0.4999, 0.5069, 0.5213]}, {"w": "default", "b": [0.5135, 0.4999, 0.571, 0.5213]}, {"w": "a", "b": [0.5775, 0.4999, 0.5867, 0.5213]}, {"w": "BaggingClassifier", "b": [0.5932, 0.5031, 0.7615, 0.5181]}, {"w": "samples", "b": [0.768, 0.4999, 0.8342, 0.5213]}, {"w": "m", "b": [0.8408, 0.4997, 0.8571, 0.5213]}, {"w": "training", "b": [0.1429, 0.5198, 0.2098, 0.5412]}, {"w": "instances", "b": [0.2181, 0.5198, 0.295, 0.5412]}, {"w": "with", "b": [0.3033, 0.5198, 0.3407, 0.5412]}, {"w": "replacement", "b": [0.349, 0.5198, 0.4519, 0.5412]}, {"w": "(bootstrap=True),", "b": [0.4602, 0.5198, 0.6179, 0.5412]}, {"w": "where", "b": [0.6263, 0.5198, 0.6771, 0.5412]}, {"w": "m", "b": [0.6855, 0.5196, 0.7019, 0.5412]}, {"w": "is", "b": [0.7102, 0.5198, 0.7234, 0.5412]}, {"w": "the", "b": [0.7318, 0.5198, 0.7581, 0.5412]}, {"w": "size", "b": [0.7665, 0.5198, 0.7973, 0.5412]}, {"w": "of", "b": [0.8057, 0.5198, 0.8225, 0.5412]}, {"w": "the", "b": [0.8308, 0.5198, 0.8571, 0.5412]}, {"w": "training", "b": [0.1429, 0.5389, 0.2098, 0.5603]}, {"w": "set.", "b": [0.2149, 0.5389, 0.2425, 0.5603]}, {"w": "This", "b": [0.2476, 0.5389, 0.2848, 0.5603]}, {"w": "means", "b": [0.2899, 0.5389, 0.344, 0.5603]}, {"w": "that", "b": [0.3491, 0.5389, 0.3817, 0.5603]}, {"w": "only", "b": [0.3868, 0.5389, 0.4236, 0.5603]}, {"w": "about", "b": [0.4287, 0.5389, 0.4765, 0.5603]}, {"w": "63%", "b": [0.4816, 0.5389, 0.5173, 0.5603]}, {"w": "of", "b": [0.5224, 0.5389, 0.5392, 0.5603]}, {"w": "the", "b": [0.5443, 0.5389, 0.5706, 0.5603]}, {"w": "training", "b": [0.5757, 0.5389, 0.6427, 0.5603]}, {"w": "instances", "b": [0.6478, 0.5389, 0.7246, 0.5603]}, {"w": "are", "b": [0.7297, 0.5389, 0.7554, 0.5603]}, {"w": "sampled", "b": [0.7605, 0.5389, 0.83, 0.5603]}, {"w": "on", "b": [0.8351, 0.5389, 0.8571, 0.5603]}, {"w": "average", "b": [0.1429, 0.5579, 0.2056, 0.5793]}, {"w": "for", "b": [0.2113, 0.5579, 0.2358, 0.5793]}, {"w": "each", "b": [0.2415, 0.5579, 0.2794, 0.5793]}, {"w": "predictor.6", "b": [0.2851, 0.5579, 0.3718, 0.5793]}, {"w": "The", "b": [0.3775, 0.5579, 0.4103, 0.5793]}, {"w": "remaining", "b": [0.416, 0.5579, 0.5025, 0.5793]}, {"w": "37%", "b": [0.5081, 0.5579, 0.5439, 0.5793]}, {"w": "of", "b": [0.5496, 0.5579, 0.5664, 0.5793]}, {"w": "the", "b": [0.572, 0.5579, 0.5984, 0.5793]}, {"w": "training", "b": [0.604, 0.5579, 0.671, 0.5793]}, {"w": "instances", "b": [0.6766, 0.5579, 0.7535, 0.5793]}, {"w": "that", "b": [0.7591, 0.5579, 0.7917, 0.5793]}, {"w": "are", "b": [0.7974, 0.5579, 0.8231, 0.5793]}, {"w": "not", "b": [0.8288, 0.5579, 0.8571, 0.5793]}, {"w": "sampled", "b": [0.1429, 0.577, 0.2124, 0.5984]}, {"w": "are", "b": [0.2193, 0.577, 0.245, 0.5984]}, {"w": "called", "b": [0.252, 0.577, 0.3003, 0.5984]}, {"w": "out-of-bag", "b": [0.3073, 0.5768, 0.3918, 0.5984]}, {"w": "(oob)", "b": [0.3988, 0.577, 0.445, 0.5984]}, {"w": "instances.", "b": [0.4519, 0.577, 0.5335, 0.5984]}, {"w": "Note", "b": [0.5405, 0.577, 0.5813, 0.5984]}, {"w": "that", "b": [0.5882, 0.577, 0.6208, 0.5984]}, {"w": "they", "b": [0.6277, 0.577, 0.6636, 0.5984]}, {"w": "are", "b": [0.6705, 0.577, 0.6963, 0.5984]}, {"w": "not", "b": [0.7032, 0.577, 0.7316, 0.5984]}, {"w": "the", "b": [0.7385, 0.577, 0.7648, 0.5984]}, {"w": "same", "b": [0.7718, 0.577, 0.8145, 0.5984]}, {"w": "37%", "b": [0.8214, 0.577, 0.8572, 0.5984]}, {"w": "for", "b": [0.1429, 0.596, 0.1674, 0.6174]}, {"w": "all", "b": [0.1721, 0.596, 0.1918, 0.6174]}, {"w": "predictors.", "b": [0.1965, 0.596, 0.2865, 0.6174]}]}, {"id": "b_5", "type": "paragraph", "text": "Since a predictor never sees the oob instances during training, it can be evaluated on these instances, without the need for a separate validation set. You can evaluate the ensemble itself by averaging out the oob evaluations of each predictor.", "words": [{"w": "Since", "b": [0.1429, 0.6241, 0.1874, 0.6455]}, {"w": "a", "b": [0.193, 0.6241, 0.2021, 0.6455]}, {"w": "predictor", "b": [0.2078, 0.6241, 0.2854, 0.6455]}, {"w": "never", "b": [0.291, 0.6241, 0.3375, 0.6455]}, {"w": "sees", "b": [0.3431, 0.6241, 0.3761, 0.6455]}, {"w": "the", "b": [0.3817, 0.6241, 0.408, 0.6455]}, {"w": "oob", "b": [0.4136, 0.6241, 0.4455, 0.6455]}, {"w": "instances", "b": [0.4511, 0.6241, 0.5279, 0.6455]}, {"w": "during", "b": [0.5336, 0.6241, 0.5901, 0.6455]}, {"w": "training,", "b": [0.5957, 0.6241, 0.6674, 0.6455]}, {"w": "it", "b": [0.673, 0.6241, 0.6849, 0.6455]}, {"w": "can", "b": [0.6905, 0.6241, 0.7199, 0.6455]}, {"w": "be", "b": [0.7255, 0.6241, 0.745, 0.6455]}, {"w": "evaluated", "b": [0.7506, 0.6241, 0.8295, 0.6455]}, {"w": "on", "b": [0.8351, 0.6241, 0.8571, 0.6455]}, {"w": "these", "b": [0.1429, 0.6432, 0.1857, 0.6646]}, {"w": "instances,", "b": [0.1926, 0.6432, 0.2741, 0.6646]}, {"w": "without", "b": [0.281, 0.6432, 0.3464, 0.6646]}, {"w": "the", "b": [0.3532, 0.6432, 0.3796, 0.6646]}, {"w": "need", "b": [0.3864, 0.6432, 0.4265, 0.6646]}, {"w": "for", "b": [0.4334, 0.6432, 0.4579, 0.6646]}, {"w": "a", "b": [0.4648, 0.6432, 0.4739, 0.6646]}, {"w": "separate", "b": [0.4808, 0.6432, 0.549, 0.6646]}, {"w": "validation", "b": [0.5559, 0.6432, 0.6393, 0.6646]}, {"w": "set.", "b": [0.6461, 0.6432, 0.6737, 0.6646]}, {"w": "You", "b": [0.6806, 0.6432, 0.7129, 0.6646]}, {"w": "can", "b": [0.7198, 0.6432, 0.7491, 0.6646]}, {"w": "evaluate", "b": [0.756, 0.6432, 0.8239, 0.6646]}, {"w": "the", "b": [0.8308, 0.6432, 0.8571, 0.6646]}, {"w": "ensemble", "b": [0.1429, 0.6622, 0.2214, 0.6836]}, {"w": "itself", "b": [0.2261, 0.6622, 0.266, 0.6836]}, {"w": "by", "b": [0.2707, 0.6622, 0.2909, 0.6836]}, {"w": "averaging", "b": [0.2956, 0.6622, 0.3762, 0.6836]}, {"w": "out", "b": [0.3809, 0.6622, 0.409, 0.6836]}, {"w": "the", "b": [0.4137, 0.6622, 0.44, 0.6836]}, {"w": "oob", "b": [0.4448, 0.6622, 0.4766, 0.6836]}, {"w": "evaluations", "b": [0.4813, 0.6622, 0.5757, 0.6836]}, {"w": "of", "b": [0.5804, 0.6622, 0.5972, 0.6836]}, {"w": "each", "b": [0.6019, 0.6622, 0.6399, 0.6836]}, {"w": "predictor.", "b": [0.6446, 0.6622, 0.7256, 0.6836]}]}, {"id": "b_6", "type": "paragraph", "text": "In Scikit-Learn, you can set oob_score=True when creating a BaggingClassifier to request an automatic oob evaluation after training. The following code demonstrates this. The resulting evaluation score is available through the oob_score_ variable:", "words": [{"w": "In", "b": [0.1429, 0.6912, 0.1614, 0.7127]}, {"w": "Scikit-Learn,", "b": [0.1673, 0.6912, 0.2743, 0.7127]}, {"w": "you", "b": [0.2803, 0.6912, 0.3115, 0.7127]}, {"w": "can", "b": [0.3175, 0.6912, 0.3469, 0.7127]}, {"w": "set", "b": [0.3528, 0.6912, 0.3757, 0.7127]}, {"w": "oob_score=True", "b": [0.3816, 0.6944, 0.5202, 0.7095]}, {"w": "when", "b": [0.5261, 0.6912, 0.5717, 0.7127]}, {"w": "creating", "b": [0.5777, 0.6912, 0.6449, 0.7127]}, {"w": "a", "b": [0.6509, 0.6912, 0.66, 0.7127]}, {"w": "BaggingClassifier", "b": [0.666, 0.6944, 0.8342, 0.7095]}, {"w": "to", "b": [0.8402, 0.6912, 0.8571, 0.7127]}, {"w": "request", "b": [0.1429, 0.7103, 0.204, 0.7317]}, {"w": "an", "b": [0.2098, 0.7103, 0.2303, 0.7317]}, {"w": "automatic", "b": [0.236, 0.7103, 0.3194, 0.7317]}, {"w": "oob", "b": [0.3251, 0.7103, 0.357, 0.7317]}, {"w": "evaluation", "b": [0.3627, 0.7103, 0.4494, 0.7317]}, {"w": "after", "b": [0.4551, 0.7103, 0.4934, 0.7317]}, {"w": "training.", "b": [0.4991, 0.7103, 0.5708, 0.7317]}, {"w": "The", "b": [0.5766, 0.7103, 0.6094, 0.7317]}, {"w": "following", "b": [0.6151, 0.7103, 0.6941, 0.7317]}, {"w": "code", "b": [0.6998, 0.7103, 0.7391, 0.7317]}, {"w": "demonstrates", "b": [0.7449, 0.7103, 0.8572, 0.7317]}, {"w": "this.", "b": [0.1429, 0.7302, 0.1783, 0.7517]}, {"w": "The", "b": [0.183, 0.7302, 0.2159, 0.7517]}, {"w": "resulting", "b": [0.2206, 0.7302, 0.2943, 0.7517]}, {"w": "evaluation", "b": [0.299, 0.7302, 0.3857, 0.7517]}, {"w": "score", "b": [0.3904, 0.7302, 0.4341, 0.7517]}, {"w": "is", "b": [0.4388, 0.7302, 0.452, 0.7517]}, {"w": "available", "b": [0.4568, 0.7302, 0.529, 0.7517]}, {"w": "through", "b": [0.5338, 0.7302, 0.6015, 0.7517]}, {"w": "the", "b": [0.6063, 0.7302, 0.6326, 0.7517]}, {"w": "oob_score_", "b": [0.6373, 0.7334, 0.7363, 0.7485]}, {"w": "variable:", "b": [0.741, 0.7302, 0.8117, 0.7517]}]}, {"id": "b_7", "type": "paragraph", "text": ">>> bag_clf = BaggingClassifier( ... DecisionTreeClassifier(), n_estimators=500, ... bootstrap=True, n_jobs=-1, oob_score=True) ... >>> bag_clf.fit(X_train, y_train)", "words": [{"w": ">>>", "b": [0.1766, 0.7622, 0.2019, 0.7751]}, {"w": "bag_clf", "b": [0.2103, 0.7622, 0.2694, 0.7751]}, {"w": "=", "b": [0.2778, 0.7622, 0.2862, 0.7751]}, {"w": "BaggingClassifier(", "b": [0.2946, 0.7622, 0.4464, 0.7751]}, {"w": "...", "b": [0.1766, 0.7776, 0.2019, 0.7905]}, {"w": "DecisionTreeClassifier(),", "b": [0.2441, 0.7776, 0.4549, 0.7905]}, {"w": "n_estimators=500,", "b": [0.4633, 0.7776, 0.6067, 0.7905]}, {"w": "...", "b": [0.1766, 0.7931, 0.2019, 0.8059]}, {"w": "bootstrap=True,", "b": [0.2441, 0.7931, 0.3705, 0.8059]}, {"w": "n_jobs=-1,", "b": [0.379, 0.7931, 0.4633, 0.8059]}, {"w": "oob_score=True)", "b": [0.4717, 0.7931, 0.5982, 0.8059]}, {"w": "...", "b": [0.1766, 0.8085, 0.2019, 0.8213]}, {"w": ">>>", "b": [0.1766, 0.8239, 0.2019, 0.8367]}, {"w": "bag_clf.fit(X_train,", "b": [0.2103, 0.8239, 0.379, 0.8367]}, {"w": "y_train)", "b": [0.3874, 0.8239, 0.4549, 0.8367]}]}, {"id": "b_8", "type": "paragraph", "text": "Bagging and Pasting | 197", "words": [{"w": "Bagging", "b": [0.6741, 0.9225, 0.7234, 0.9388]}, {"w": "and", "b": [0.7262, 0.9225, 0.7486, 0.9388]}, {"w": "Pasting", "b": [0.7515, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "197", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 224, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "7 “Ensembles on Random Patches,” G. Louppe and P. Geurts (2012).", "words": [{"w": "7", "b": [0.1451, 0.8568, 0.1518, 0.871]}, {"w": "“Ensembles", "b": [0.1587, 0.8553, 0.233, 0.8716]}, {"w": "on", "b": [0.2366, 0.8553, 0.2533, 0.8716]}, {"w": "Random", "b": [0.257, 0.8553, 0.3122, 0.8716]}, {"w": "Patches,”", "b": [0.3158, 0.8553, 0.3715, 0.8716]}, {"w": "G.", "b": [0.3751, 0.8553, 0.39, 0.8716]}, {"w": "Louppe", "b": [0.3937, 0.8553, 0.4421, 0.8716]}, {"w": "and", "b": [0.4457, 0.8553, 0.4697, 0.8716]}, {"w": "P.", "b": [0.4733, 0.8553, 0.4837, 0.8716]}, {"w": "Geurts", "b": [0.4873, 0.8553, 0.5304, 0.8716]}, {"w": "(2012).", "b": [0.534, 0.8553, 0.579, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "8 “The random subspace method for constructing decision forests,” Tin Kam Ho (1998).", "words": [{"w": "8", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“The", "b": [0.1587, 0.8749, 0.1905, 0.8912]}, {"w": "random", "b": [0.1941, 0.8749, 0.2451, 0.8912]}, {"w": "subspace", "b": [0.2487, 0.8749, 0.3056, 0.8912]}, {"w": "method", "b": [0.3092, 0.8749, 0.3587, 0.8912]}, {"w": "for", "b": [0.3623, 0.8749, 0.381, 0.8912]}, {"w": "constructing", "b": [0.3846, 0.8749, 0.465, 0.8912]}, {"w": "decision", "b": [0.4686, 0.8749, 0.5216, 0.8912]}, {"w": "forests,”", "b": [0.5252, 0.8749, 0.5749, 0.8912]}, {"w": "Tin", "b": [0.5785, 0.8749, 0.6005, 0.8912]}, {"w": "Kam", "b": [0.6041, 0.8749, 0.6348, 0.8912]}, {"w": "Ho", "b": [0.6384, 0.8749, 0.6583, 0.8912]}, {"w": "(1998).", "b": [0.6619, 0.8749, 0.7069, 0.8912]}]}, {"id": "b_2", "type": "equation", "text": ">>> bag_clf.oob_score_ 0.90133333333333332", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "bag_clf.oob_score_", "b": [0.2103, 0.0829, 0.3621, 0.0958]}, {"w": "0.90133333333333332", "b": [0.1766, 0.0983, 0.3368, 0.1112]}]}, {"id": "b_3", "type": "paragraph", "text": "According to this oob evaluation, this BaggingClassifier is likely to achieve about 90.1% accuracy on the test set. Let’s verify this:", "words": [{"w": "According", "b": [0.1429, 0.1199, 0.2304, 0.1413]}, {"w": "to", "b": [0.237, 0.1199, 0.2539, 0.1413]}, {"w": "this", "b": [0.2605, 0.1199, 0.2912, 0.1413]}, {"w": "oob", "b": [0.2977, 0.1199, 0.3296, 0.1413]}, {"w": "evaluation,", "b": [0.3361, 0.1199, 0.4275, 0.1413]}, {"w": "this", "b": [0.4341, 0.1199, 0.4648, 0.1413]}, {"w": "BaggingClassifier", "b": [0.4713, 0.123, 0.6396, 0.1381]}, {"w": "is", "b": [0.6461, 0.1199, 0.6593, 0.1413]}, {"w": "likely", "b": [0.6659, 0.1199, 0.7108, 0.1413]}, {"w": "to", "b": [0.7173, 0.1199, 0.7343, 0.1413]}, {"w": "achieve", "b": [0.7408, 0.1199, 0.8028, 0.1413]}, {"w": "about", "b": [0.8094, 0.1199, 0.8571, 0.1413]}, {"w": "90.1%", "b": [0.1429, 0.1389, 0.1934, 0.1603]}, {"w": "accuracy", "b": [0.1981, 0.1389, 0.2712, 0.1603]}, {"w": "on", "b": [0.2759, 0.1389, 0.2979, 0.1603]}, {"w": "the", "b": [0.3026, 0.1389, 0.329, 0.1603]}, {"w": "test", "b": [0.3337, 0.1389, 0.3629, 0.1603]}, {"w": "set.", "b": [0.3676, 0.1389, 0.3953, 0.1603]}, {"w": "Let’s", "b": [0.4, 0.1389, 0.4361, 0.1603]}, {"w": "verify", "b": [0.4409, 0.1389, 0.4888, 0.1603]}, {"w": "this:", "b": [0.4935, 0.1389, 0.529, 0.1603]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> from sklearn.metrics import accuracy_score >>> y_pred = bag_clf.predict(X_test) >>> accuracy_score(y_test, y_pred) 0.91200000000000003", "words": [{"w": ">>>", "b": [0.1766, 0.1709, 0.2019, 0.1837]}, {"w": "from", "b": [0.2103, 0.1709, 0.244, 0.1837]}, {"w": "sklearn.metrics", "b": [0.2525, 0.1709, 0.379, 0.1837]}, {"w": "import", "b": [0.3874, 0.1709, 0.438, 0.1837]}, {"w": "accuracy_score", "b": [0.4464, 0.1709, 0.5645, 0.1837]}, {"w": ">>>", "b": [0.1766, 0.1863, 0.2019, 0.1992]}, {"w": "y_pred", "b": [0.2103, 0.1863, 0.2609, 0.1992]}, {"w": "=", "b": [0.2693, 0.1863, 0.2778, 0.1992]}, {"w": "bag_clf.predict(X_test)", "b": [0.2862, 0.1863, 0.4802, 0.1992]}, {"w": ">>>", "b": [0.1766, 0.2017, 0.2019, 0.2146]}, {"w": "accuracy_score(y_test,", "b": [0.2103, 0.2017, 0.3958, 0.2146]}, {"w": "y_pred)", "b": [0.4043, 0.2017, 0.4633, 0.2146]}, {"w": "0.91200000000000003", "b": [0.1766, 0.2171, 0.3368, 0.23]}]}, {"id": "b_5", "type": "paragraph", "text": "We get 91.2% accuracy on the test set—close enough!", "words": [{"w": "We", "b": [0.1429, 0.2378, 0.1699, 0.2592]}, {"w": "get", "b": [0.1747, 0.2378, 0.1996, 0.2592]}, {"w": "91.2%", "b": [0.2043, 0.2378, 0.2548, 0.2592]}, {"w": "accuracy", "b": [0.2596, 0.2378, 0.3327, 0.2592]}, {"w": "on", "b": [0.3374, 0.2378, 0.3594, 0.2592]}, {"w": "the", "b": [0.3641, 0.2378, 0.3905, 0.2592]}, {"w": "test", "b": [0.3952, 0.2378, 0.4244, 0.2592]}, {"w": "set—close", "b": [0.4291, 0.2378, 0.5124, 0.2592]}, {"w": "enough!", "b": [0.5171, 0.2378, 0.5857, 0.2592]}]}, {"id": "b_6", "type": "paragraph", "text": "The oob decision function for each training instance is also available through the oob_decision_function_ variable. In this case (since the base estimator has a pre dict_proba() method) the decision function returns the class probabilities for each training instance. For example, the oob evaluation estimates that the first training instance has a 68.25% probability of belonging to the positive class (and 31.75% of belonging to the negative class):", "words": [{"w": "The", "b": [0.1429, 0.2659, 0.1757, 0.2873]}, {"w": "oob", "b": [0.1838, 0.2659, 0.2157, 0.2873]}, {"w": "decision", "b": [0.2238, 0.2659, 0.2933, 0.2873]}, {"w": "function", "b": [0.3015, 0.2659, 0.3729, 0.2873]}, {"w": "for", "b": [0.381, 0.2659, 0.4056, 0.2873]}, {"w": "each", "b": [0.4137, 0.2659, 0.4517, 0.2873]}, {"w": "training", "b": [0.4598, 0.2659, 0.5267, 0.2873]}, {"w": "instance", "b": [0.5349, 0.2659, 0.6041, 0.2873]}, {"w": "is", "b": [0.6122, 0.2659, 0.6255, 0.2873]}, {"w": "also", "b": [0.6336, 0.2659, 0.6663, 0.2873]}, {"w": "available", "b": [0.6745, 0.2659, 0.7467, 0.2873]}, {"w": "through", "b": [0.7549, 0.2659, 0.8227, 0.2873]}, {"w": "the", "b": [0.8308, 0.2659, 0.8571, 0.2873]}, {"w": "oob_decision_function_", "b": [0.1429, 0.289, 0.3606, 0.3041]}, {"w": "variable.", "b": [0.368, 0.2858, 0.4387, 0.3073]}, {"w": "In", "b": [0.4462, 0.2858, 0.4647, 0.3073]}, {"w": "this", "b": [0.4721, 0.2858, 0.5028, 0.3073]}, {"w": "case", "b": [0.5103, 0.2858, 0.5447, 0.3073]}, {"w": "(since", "b": [0.5522, 0.2858, 0.6017, 0.3073]}, {"w": "the", "b": [0.6091, 0.2858, 0.6354, 0.3073]}, {"w": "base", "b": [0.6429, 0.2858, 0.6791, 0.3073]}, {"w": "estimator", "b": [0.6865, 0.2858, 0.7655, 0.3073]}, {"w": "has", "b": [0.7729, 0.2858, 0.8009, 0.3073]}, {"w": "a", "b": [0.8083, 0.2858, 0.8174, 0.3073]}, {"w": "pre", "b": [0.8249, 0.289, 0.8546, 0.3041]}, {"w": "dict_proba()", "b": [0.1429, 0.309, 0.2616, 0.324]}, {"w": "method)", "b": [0.268, 0.3058, 0.3402, 0.3272]}, {"w": "the", "b": [0.3466, 0.3058, 0.3729, 0.3272]}, {"w": "decision", "b": [0.3792, 0.3058, 0.4487, 0.3272]}, {"w": "function", "b": [0.4551, 0.3058, 0.5265, 0.3272]}, {"w": "returns", "b": [0.5328, 0.3058, 0.5936, 0.3272]}, {"w": "the", "b": [0.6, 0.3058, 0.6263, 0.3272]}, {"w": "class", "b": [0.6327, 0.3058, 0.6712, 0.3272]}, {"w": "probabilities", "b": [0.6775, 0.3058, 0.782, 0.3272]}, {"w": "for", "b": [0.7883, 0.3058, 0.8129, 0.3272]}, {"w": "each", "b": [0.8192, 0.3058, 0.8572, 0.3272]}, {"w": "training", "b": [0.1429, 0.3248, 0.2098, 0.3462]}, {"w": "instance.", "b": [0.2179, 0.3248, 0.2918, 0.3462]}, {"w": "For", "b": [0.2999, 0.3248, 0.3289, 0.3462]}, {"w": "example,", "b": [0.3369, 0.3248, 0.4112, 0.3462]}, {"w": "the", "b": [0.4193, 0.3248, 0.4457, 0.3462]}, {"w": "oob", "b": [0.4537, 0.3248, 0.4856, 0.3462]}, {"w": "evaluation", "b": [0.4936, 0.3248, 0.5803, 0.3462]}, {"w": "estimates", "b": [0.5884, 0.3248, 0.6655, 0.3462]}, {"w": "that", "b": [0.6736, 0.3248, 0.7062, 0.3462]}, {"w": "the", "b": [0.7142, 0.3248, 0.7406, 0.3462]}, {"w": "first", "b": [0.7487, 0.3248, 0.7821, 0.3462]}, {"w": "training", "b": [0.7902, 0.3248, 0.8571, 0.3462]}, {"w": "instance", "b": [0.1429, 0.3439, 0.212, 0.3653]}, {"w": "has", "b": [0.2192, 0.3439, 0.2471, 0.3653]}, {"w": "a", "b": [0.2542, 0.3439, 0.2633, 0.3653]}, {"w": "68.25%", "b": [0.2705, 0.3439, 0.331, 0.3653]}, {"w": "probability", "b": [0.3381, 0.3439, 0.43, 0.3653]}, {"w": "of", "b": [0.4371, 0.3439, 0.4539, 0.3653]}, {"w": "belonging", "b": [0.461, 0.3439, 0.5442, 0.3653]}, {"w": "to", "b": [0.5514, 0.3439, 0.5683, 0.3653]}, {"w": "the", "b": [0.5755, 0.3439, 0.6018, 0.3653]}, {"w": "positive", "b": [0.6089, 0.3439, 0.6741, 0.3653]}, {"w": "class", "b": [0.6812, 0.3439, 0.7198, 0.3653]}, {"w": "(and", "b": [0.7269, 0.3439, 0.7656, 0.3653]}, {"w": "31.75%", "b": [0.7727, 0.3439, 0.8332, 0.3653]}, {"w": "of", "b": [0.8404, 0.3439, 0.8571, 0.3653]}, {"w": "belonging", "b": [0.1429, 0.3629, 0.2261, 0.3843]}, {"w": "to", "b": [0.2308, 0.3629, 0.2478, 0.3843]}, {"w": "the", "b": [0.2525, 0.3629, 0.2788, 0.3843]}, {"w": "negative", "b": [0.2836, 0.3629, 0.3527, 0.3843]}, {"w": "class):", "b": [0.3575, 0.3629, 0.408, 0.3843]}]}, {"id": "b_7", "type": "paragraph", "text": ">>> bag_clf.oob_decision_function_ array([[0.31746032, 0.68253968], [0.34117647, 0.65882353], [1. , 0. ], ... [1. , 0. ], [0.03108808, 0.96891192], [0.57291667, 0.42708333]])", "words": [{"w": ">>>", "b": [0.1766, 0.3949, 0.2019, 0.4078]}, {"w": "bag_clf.oob_decision_function_", "b": [0.2103, 0.3949, 0.4633, 0.4078]}, {"w": "array([[0.31746032,", "b": [0.1766, 0.4103, 0.3368, 0.4232]}, {"w": "0.68253968],", "b": [0.3452, 0.4103, 0.4464, 0.4232]}, {"w": "[0.34117647,", "b": [0.2356, 0.4257, 0.3368, 0.4386]}, {"w": "0.65882353],", "b": [0.3452, 0.4257, 0.4464, 0.4386]}, {"w": "[1.", "b": [0.2356, 0.4412, 0.2609, 0.454]}, {"w": ",", "b": [0.3284, 0.4412, 0.3368, 0.454]}, {"w": "0.", "b": [0.3452, 0.4412, 0.3621, 0.454]}, {"w": "],", "b": [0.4296, 0.4412, 0.4464, 0.454]}, {"w": "...", "b": [0.2356, 0.4566, 0.2609, 0.4694]}, {"w": "[1.", "b": [0.2356, 0.472, 0.2609, 0.4849]}, {"w": ",", "b": [0.3284, 0.472, 0.3368, 0.4849]}, {"w": "0.", "b": [0.3452, 0.472, 0.3621, 0.4849]}, {"w": "],", "b": [0.4296, 0.472, 0.4464, 0.4849]}, {"w": "[0.03108808,", "b": [0.2356, 0.4874, 0.3368, 0.5003]}, {"w": "0.96891192],", "b": [0.3452, 0.4874, 0.4464, 0.5003]}, {"w": "[0.57291667,", "b": [0.2356, 0.5028, 0.3368, 0.5157]}, {"w": "0.42708333]])", "b": [0.3452, 0.5028, 0.4549, 0.5157]}]}, {"id": "b_8", "type": "paragraph", "text": "Random Patches and Random Subspaces", "words": [{"w": "Random", "b": [0.1429, 0.5298, 0.2465, 0.564]}, {"w": "Patches", "b": [0.2524, 0.5298, 0.3486, 0.564]}, {"w": "and", "b": [0.3546, 0.5298, 0.4017, 0.564]}, {"w": "Random", "b": [0.4076, 0.5298, 0.5112, 0.564]}, {"w": "Subspaces", "b": [0.5172, 0.5298, 0.6439, 0.564]}]}, {"id": "b_9", "type": "paragraph", "text": "The BaggingClassifier class supports sampling the features as well. This is con‐ trolled by two hyperparameters: max_features and bootstrap_features. They work the same way as max_samples and bootstrap, but for feature sampling instead of instance sampling. Thus, each predictor will be trained on a random subset of the input features.", "words": [{"w": "The", "b": [0.1429, 0.5718, 0.1757, 0.5933]}, {"w": "BaggingClassifier", "b": [0.1839, 0.575, 0.3521, 0.5901]}, {"w": "class", "b": [0.3603, 0.5718, 0.3988, 0.5933]}, {"w": "supports", "b": [0.4069, 0.5718, 0.4798, 0.5933]}, {"w": "sampling", "b": [0.488, 0.5718, 0.5644, 0.5933]}, {"w": "the", "b": [0.5725, 0.5718, 0.5989, 0.5933]}, {"w": "features", "b": [0.607, 0.5718, 0.6724, 0.5933]}, {"w": "as", "b": [0.6806, 0.5718, 0.6974, 0.5933]}, {"w": "well.", "b": [0.7056, 0.5718, 0.744, 0.5933]}, {"w": "This", "b": [0.7521, 0.5718, 0.7893, 0.5933]}, {"w": "is", "b": [0.7975, 0.5718, 0.8107, 0.5933]}, {"w": "con‐", "b": [0.8189, 0.5718, 0.8572, 0.5933]}, {"w": "trolled", "b": [0.1429, 0.5918, 0.198, 0.6132]}, {"w": "by", "b": [0.2034, 0.5918, 0.2235, 0.6132]}, {"w": "two", "b": [0.229, 0.5918, 0.2602, 0.6132]}, {"w": "hyperparameters:", "b": [0.2656, 0.5918, 0.4115, 0.6132]}, {"w": "max_features", "b": [0.4169, 0.595, 0.5357, 0.61]}, {"w": "and", "b": [0.5411, 0.5918, 0.5726, 0.6132]}, {"w": "bootstrap_features.", "b": [0.5781, 0.5918, 0.7609, 0.6132]}, {"w": "They", "b": [0.7664, 0.5918, 0.8088, 0.6132]}, {"w": "work", "b": [0.8142, 0.5918, 0.8571, 0.6132]}, {"w": "the", "b": [0.1429, 0.6117, 0.1692, 0.6331]}, {"w": "same", "b": [0.1774, 0.6117, 0.2201, 0.6331]}, {"w": "way", "b": [0.2283, 0.6117, 0.2609, 0.6331]}, {"w": "as", "b": [0.269, 0.6117, 0.2858, 0.6331]}, {"w": "max_samples", "b": [0.294, 0.6149, 0.4029, 0.63]}, {"w": "and", "b": [0.4111, 0.6117, 0.4426, 0.6331]}, {"w": "bootstrap,", "b": [0.4508, 0.6117, 0.5446, 0.6331]}, {"w": "but", "b": [0.5528, 0.6117, 0.5808, 0.6331]}, {"w": "for", "b": [0.589, 0.6117, 0.6135, 0.6331]}, {"w": "feature", "b": [0.6217, 0.6117, 0.6794, 0.6331]}, {"w": "sampling", "b": [0.6876, 0.6117, 0.764, 0.6331]}, {"w": "instead", "b": [0.7722, 0.6117, 0.8322, 0.6331]}, {"w": "of", "b": [0.8403, 0.6117, 0.8571, 0.6331]}, {"w": "instance", "b": [0.1429, 0.6308, 0.2121, 0.6522]}, {"w": "sampling.", "b": [0.2196, 0.6308, 0.3007, 0.6522]}, {"w": "Thus,", "b": [0.3083, 0.6308, 0.3553, 0.6522]}, {"w": "each", "b": [0.3629, 0.6308, 0.4008, 0.6522]}, {"w": "predictor", "b": [0.4083, 0.6308, 0.4859, 0.6522]}, {"w": "will", "b": [0.4935, 0.6308, 0.5239, 0.6522]}, {"w": "be", "b": [0.5314, 0.6308, 0.5509, 0.6522]}, {"w": "trained", "b": [0.5584, 0.6308, 0.6185, 0.6522]}, {"w": "on", "b": [0.626, 0.6308, 0.648, 0.6522]}, {"w": "a", "b": [0.6556, 0.6308, 0.6647, 0.6522]}, {"w": "random", "b": [0.6723, 0.6308, 0.7392, 0.6522]}, {"w": "subset", "b": [0.7468, 0.6308, 0.7989, 0.6522]}, {"w": "of", "b": [0.8065, 0.6308, 0.8233, 0.6522]}, {"w": "the", "b": [0.8308, 0.6308, 0.8572, 0.6522]}, {"w": "input", "b": [0.1429, 0.6498, 0.1878, 0.6712]}, {"w": "features.", "b": [0.1925, 0.6498, 0.2627, 0.6712]}]}, {"id": "b_10", "type": "paragraph", "text": "This is particularly useful when you are dealing with high-dimensional inputs (such as images). Sampling both training instances and features is called the Random Patches method.7 Keeping all training instances (i.e., bootstrap=False and max_sam ples=1.0) but sampling features (i.e., bootstrap_features=True and/or max_fea tures smaller than 1.0) is called the Random Subspaces method.8", "words": [{"w": "This", "b": [0.1429, 0.6779, 0.1801, 0.6994]}, {"w": "is", "b": [0.1864, 0.6779, 0.1996, 0.6994]}, {"w": "particularly", "b": [0.2059, 0.6779, 0.3025, 0.6994]}, {"w": "useful", "b": [0.3088, 0.6779, 0.3588, 0.6994]}, {"w": "when", "b": [0.3651, 0.6779, 0.4108, 0.6994]}, {"w": "you", "b": [0.4171, 0.6779, 0.4483, 0.6994]}, {"w": "are", "b": [0.4546, 0.6779, 0.4803, 0.6994]}, {"w": "dealing", "b": [0.4866, 0.6779, 0.5476, 0.6994]}, {"w": "with", "b": [0.5539, 0.6779, 0.5913, 0.6994]}, {"w": "high-dimensional", "b": [0.5976, 0.6779, 0.7461, 0.6994]}, {"w": "inputs", "b": [0.7524, 0.6779, 0.805, 0.6994]}, {"w": "(such", "b": [0.8113, 0.6779, 0.8571, 0.6994]}, {"w": "as", "b": [0.1429, 0.697, 0.1596, 0.7184]}, {"w": "images).", "b": [0.1698, 0.697, 0.2398, 0.7184]}, {"w": "Sampling", "b": [0.25, 0.697, 0.3286, 0.7184]}, {"w": "both", "b": [0.3388, 0.697, 0.3774, 0.7184]}, {"w": "training", "b": [0.3876, 0.697, 0.4545, 0.7184]}, {"w": "instances", "b": [0.4647, 0.697, 0.5415, 0.7184]}, {"w": "and", "b": [0.5517, 0.697, 0.5833, 0.7184]}, {"w": "features", "b": [0.5934, 0.697, 0.6588, 0.7184]}, {"w": "is", "b": [0.669, 0.697, 0.6822, 0.7184]}, {"w": "called", "b": [0.6924, 0.697, 0.7408, 0.7184]}, {"w": "the", "b": [0.7509, 0.697, 0.7773, 0.7184]}, {"w": "Random", "b": [0.7874, 0.6968, 0.8571, 0.7184]}, {"w": "Patches", "b": [0.1429, 0.7167, 0.2033, 0.7383]}, {"w": "method.7", "b": [0.2098, 0.7169, 0.2853, 0.7383]}, {"w": "Keeping", "b": [0.2919, 0.7169, 0.3608, 0.7383]}, {"w": "all", "b": [0.3673, 0.7169, 0.387, 0.7383]}, {"w": "training", "b": [0.3936, 0.7169, 0.4605, 0.7383]}, {"w": "instances", "b": [0.4671, 0.7169, 0.5439, 0.7383]}, {"w": "(i.e.,", "b": [0.5505, 0.7169, 0.5864, 0.7383]}, {"w": "bootstrap=False", "b": [0.593, 0.7201, 0.7414, 0.7352]}, {"w": "and", "b": [0.748, 0.7169, 0.7795, 0.7383]}, {"w": "max_sam", "b": [0.7861, 0.7201, 0.8554, 0.7352]}, {"w": "ples=1.0)", "b": [0.1429, 0.7369, 0.2292, 0.7583]}, {"w": "but", "b": [0.2384, 0.7369, 0.2664, 0.7583]}, {"w": "sampling", "b": [0.2756, 0.7369, 0.352, 0.7583]}, {"w": "features", "b": [0.3612, 0.7369, 0.4266, 0.7583]}, {"w": "(i.e.,", "b": [0.4358, 0.7369, 0.4717, 0.7583]}, {"w": "bootstrap_features=True", "b": [0.4809, 0.7401, 0.7085, 0.7551]}, {"w": "and/or", "b": [0.7177, 0.7369, 0.7745, 0.7583]}, {"w": "max_fea", "b": [0.7836, 0.7401, 0.8529, 0.7551]}, {"w": "tures", "b": [0.1429, 0.76, 0.1923, 0.7751]}, {"w": "smaller", "b": [0.1971, 0.7568, 0.258, 0.7782]}, {"w": "than", "b": [0.2628, 0.7568, 0.3008, 0.7782]}, {"w": "1.0)", "b": [0.3055, 0.7568, 0.3375, 0.7782]}, {"w": "is", "b": [0.3422, 0.7568, 0.3554, 0.7782]}, {"w": "called", "b": [0.3602, 0.7568, 0.4085, 0.7782]}, {"w": "the", "b": [0.4132, 0.7568, 0.4396, 0.7782]}, {"w": "Random", "b": [0.4443, 0.7566, 0.514, 0.7782]}, {"w": "Subspaces", "b": [0.5188, 0.7566, 0.599, 0.7782]}, {"w": "method.8", "b": [0.6038, 0.7568, 0.6792, 0.7782]}]}, {"id": "b_11", "type": "paragraph", "text": "198 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "198", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 225, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "9 “Random Decision Forests,” T. Ho (1995).", "words": [{"w": "9", "b": [0.1451, 0.8027, 0.1518, 0.817]}, {"w": "“Random", "b": [0.1587, 0.8012, 0.2203, 0.8175]}, {"w": "Decision", "b": [0.2239, 0.8012, 0.2802, 0.8175]}, {"w": "Forests,”", "b": [0.2838, 0.8012, 0.3369, 0.8175]}, {"w": "T.", "b": [0.3405, 0.8012, 0.3523, 0.8175]}, {"w": "Ho", "b": [0.3559, 0.8012, 0.3758, 0.8175]}, {"w": "(1995).", "b": [0.3794, 0.8012, 0.4245, 0.8175]}]}, {"id": "b_1", "type": "paragraph", "text": "10 The BaggingClassifier class remains useful if you want a bag of something other than Decision Trees.", "words": [{"w": "10", "b": [0.1385, 0.8234, 0.1518, 0.8377]}, {"w": "The", "b": [0.1587, 0.8219, 0.1837, 0.8382]}, {"w": "BaggingClassifier", "b": [0.1873, 0.8243, 0.3155, 0.8358]}, {"w": "class", "b": [0.3191, 0.8219, 0.3485, 0.8382]}, {"w": "remains", "b": [0.3521, 0.8219, 0.4034, 0.8382]}, {"w": "useful", "b": [0.407, 0.8219, 0.4452, 0.8382]}, {"w": "if", "b": [0.4488, 0.8219, 0.4577, 0.8382]}, {"w": "you", "b": [0.4613, 0.8219, 0.4852, 0.8382]}, {"w": "want", "b": [0.4888, 0.8219, 0.5198, 0.8382]}, {"w": "a", "b": [0.5234, 0.8219, 0.5304, 0.8382]}, {"w": "bag", "b": [0.534, 0.8219, 0.5565, 0.8382]}, {"w": "of", "b": [0.5601, 0.8219, 0.5729, 0.8382]}, {"w": "something", "b": [0.5765, 0.8219, 0.6438, 0.8382]}, {"w": "other", "b": [0.6474, 0.8219, 0.6815, 0.8382]}, {"w": "than", "b": [0.6851, 0.8219, 0.714, 0.8382]}, {"w": "Decision", "b": [0.7176, 0.8219, 0.7739, 0.8382]}, {"w": "Trees.", "b": [0.7775, 0.8219, 0.8148, 0.8382]}]}, {"id": "b_2", "type": "paragraph", "text": "11 There are a few notable exceptions: splitter is absent (forced to \"random\"), presort is absent (forced to False), max_samples is absent (forced to 1.0), and base_estimator is absent (forced to DecisionTreeClassi fier with the provided hyperparameters).", "words": [{"w": "11", "b": [0.1385, 0.8441, 0.1518, 0.8584]}, {"w": "There", "b": [0.1587, 0.8426, 0.1964, 0.8589]}, {"w": "are", "b": [0.2, 0.8426, 0.2196, 0.8589]}, {"w": "a", "b": [0.2232, 0.8426, 0.2302, 0.8589]}, {"w": "few", "b": [0.2338, 0.8426, 0.2561, 0.8589]}, {"w": "notable", "b": [0.2597, 0.8426, 0.3071, 0.8589]}, {"w": "exceptions:", "b": [0.3107, 0.8426, 0.382, 0.8589]}, {"w": "splitter", "b": [0.3856, 0.845, 0.446, 0.8565]}, {"w": "is", "b": [0.4496, 0.8426, 0.4596, 0.8589]}, {"w": "absent", "b": [0.4632, 0.8426, 0.5041, 0.8589]}, {"w": "(forced", "b": [0.5077, 0.8426, 0.5537, 0.8589]}, {"w": "to", "b": [0.5573, 0.8426, 0.5702, 0.8589]}, {"w": "\"random\"),", "b": [0.5738, 0.8426, 0.6433, 0.8589]}, {"w": "presort", "b": [0.6469, 0.845, 0.6996, 0.8565]}, {"w": "is", "b": [0.7032, 0.8426, 0.7133, 0.8589]}, {"w": "absent", "b": [0.7169, 0.8426, 0.7577, 0.8589]}, {"w": "(forced", "b": [0.7613, 0.8426, 0.8074, 0.8589]}, {"w": "to", "b": [0.811, 0.8426, 0.8239, 0.8589]}, {"w": "False),", "b": [0.1587, 0.8587, 0.2055, 0.8751]}, {"w": "max_samples", "b": [0.2091, 0.8612, 0.2921, 0.8727]}, {"w": "is", "b": [0.2957, 0.8587, 0.3058, 0.8751]}, {"w": "absent", "b": [0.3094, 0.8587, 0.3502, 0.8751]}, {"w": "(forced", "b": [0.3538, 0.8587, 0.3998, 0.8751]}, {"w": "to", "b": [0.4034, 0.8587, 0.4163, 0.8751]}, {"w": "1.0),", "b": [0.4199, 0.8587, 0.4517, 0.8751]}, {"w": "and", "b": [0.4553, 0.8587, 0.4793, 0.8751]}, {"w": "base_estimator", "b": [0.4829, 0.8612, 0.5885, 0.8727]}, {"w": "is", "b": [0.5921, 0.8587, 0.6022, 0.8751]}, {"w": "absent", "b": [0.6058, 0.8587, 0.6466, 0.8751]}, {"w": "(forced", "b": [0.6502, 0.8587, 0.6962, 0.8751]}, {"w": "to", "b": [0.6998, 0.8587, 0.7127, 0.8751]}, {"w": "DecisionTreeClassi", "b": [0.7163, 0.8612, 0.8521, 0.8727]}, {"w": "fier", "b": [0.1587, 0.8773, 0.1889, 0.8888]}, {"w": "with", "b": [0.1925, 0.8749, 0.2209, 0.8912]}, {"w": "the", "b": [0.2245, 0.8749, 0.2446, 0.8912]}, {"w": "provided", "b": [0.2482, 0.8749, 0.3056, 0.8912]}, {"w": "hyperparameters).", "b": [0.3092, 0.8749, 0.4259, 0.8912]}]}, {"id": "b_3", "type": "paragraph", "text": "Sampling features results in even more predictor diversity, trading a bit more bias for a lower variance.", "words": [{"w": "Sampling", "b": [0.1429, 0.0791, 0.2215, 0.1005]}, {"w": "features", "b": [0.2267, 0.0791, 0.2922, 0.1005]}, {"w": "results", "b": [0.2974, 0.0791, 0.352, 0.1005]}, {"w": "in", "b": [0.3573, 0.0791, 0.3742, 0.1005]}, {"w": "even", "b": [0.3795, 0.0791, 0.4183, 0.1005]}, {"w": "more", "b": [0.4235, 0.0791, 0.4678, 0.1005]}, {"w": "predictor", "b": [0.4731, 0.0791, 0.5507, 0.1005]}, {"w": "diversity,", "b": [0.556, 0.0791, 0.6311, 0.1005]}, {"w": "trading", "b": [0.6364, 0.0791, 0.6974, 0.1005]}, {"w": "a", "b": [0.7026, 0.0791, 0.7118, 0.1005]}, {"w": "bit", "b": [0.7171, 0.0791, 0.7396, 0.1005]}, {"w": "more", "b": [0.7449, 0.0791, 0.7891, 0.1005]}, {"w": "bias", "b": [0.7944, 0.0791, 0.8274, 0.1005]}, {"w": "for", "b": [0.8326, 0.0791, 0.8572, 0.1005]}, {"w": "a", "b": [0.1429, 0.0981, 0.152, 0.1195]}, {"w": "lower", "b": [0.1567, 0.0981, 0.2035, 0.1195]}, {"w": "variance.", "b": [0.2082, 0.0981, 0.2833, 0.1195]}]}, {"id": "b_4", "type": "paragraph", "text": "Random Forests", "words": [{"w": "Random", "b": [0.1428, 0.1325, 0.2465, 0.1668]}, {"w": "Forests", "b": [0.2524, 0.1325, 0.3406, 0.1668]}]}, {"id": "b_5", "type": "paragraph", "text": "As we have discussed, a Random Forest9 is an ensemble of Decision Trees, generally trained via the bagging method (or sometimes pasting), typically with max_samples set to the size of the training set. Instead of building a BaggingClassifier and pass‐ ing it a DecisionTreeClassifier, you can instead use the RandomForestClassifier class, which is more convenient and optimized for Decision Trees10 (similarly, there is a RandomForestRegressor class for regression tasks). The following code trains a Random Forest classifier with 500 trees (each limited to maximum 16 nodes), using all available CPU cores:", "words": [{"w": "As", "b": [0.1429, 0.1737, 0.1649, 0.1951]}, {"w": "we", "b": [0.171, 0.1737, 0.1942, 0.1951]}, {"w": "have", "b": [0.2003, 0.1737, 0.2387, 0.1951]}, {"w": "discussed,", "b": [0.2448, 0.1737, 0.3288, 0.1951]}, {"w": "a", "b": [0.335, 0.1737, 0.3441, 0.1951]}, {"w": "Random", "b": [0.3503, 0.1737, 0.4228, 0.1951]}, {"w": "Forest9", "b": [0.4289, 0.1737, 0.4865, 0.1951]}, {"w": "is", "b": [0.4926, 0.1737, 0.5059, 0.1951]}, {"w": "an", "b": [0.512, 0.1737, 0.5325, 0.1951]}, {"w": "ensemble", "b": [0.5387, 0.1737, 0.6172, 0.1951]}, {"w": "of", "b": [0.6233, 0.1737, 0.6401, 0.1951]}, {"w": "Decision", "b": [0.6463, 0.1737, 0.7201, 0.1951]}, {"w": "Trees,", "b": [0.7262, 0.1737, 0.7752, 0.1951]}, {"w": "generally", "b": [0.7813, 0.1737, 0.8571, 0.1951]}, {"w": "trained", "b": [0.1428, 0.1936, 0.2029, 0.2151]}, {"w": "via", "b": [0.2097, 0.1936, 0.2341, 0.2151]}, {"w": "the", "b": [0.2409, 0.1936, 0.2672, 0.2151]}, {"w": "bagging", "b": [0.274, 0.1936, 0.3399, 0.2151]}, {"w": "method", "b": [0.3467, 0.1936, 0.4117, 0.2151]}, {"w": "(or", "b": [0.4185, 0.1936, 0.4441, 0.2151]}, {"w": "sometimes", "b": [0.4509, 0.1936, 0.5406, 0.2151]}, {"w": "pasting),", "b": [0.5474, 0.1936, 0.6201, 0.2151]}, {"w": "typically", "b": [0.6269, 0.1936, 0.6974, 0.2151]}, {"w": "with", "b": [0.7042, 0.1936, 0.7415, 0.2151]}, {"w": "max_samples", "b": [0.7483, 0.1968, 0.8571, 0.2119]}, {"w": "set", "b": [0.1429, 0.2136, 0.1657, 0.235]}, {"w": "to", "b": [0.1714, 0.2136, 0.1884, 0.235]}, {"w": "the", "b": [0.194, 0.2136, 0.2204, 0.235]}, {"w": "size", "b": [0.226, 0.2136, 0.2569, 0.235]}, {"w": "of", "b": [0.2626, 0.2136, 0.2793, 0.235]}, {"w": "the", "b": [0.285, 0.2136, 0.3113, 0.235]}, {"w": "training", "b": [0.317, 0.2136, 0.384, 0.235]}, {"w": "set.", "b": [0.3896, 0.2136, 0.4172, 0.235]}, {"w": "Instead", "b": [0.4229, 0.2136, 0.4844, 0.235]}, {"w": "of", "b": [0.4901, 0.2136, 0.5069, 0.235]}, {"w": "building", "b": [0.5125, 0.2136, 0.5828, 0.235]}, {"w": "a", "b": [0.5884, 0.2136, 0.5976, 0.235]}, {"w": "BaggingClassifier", "b": [0.6033, 0.2168, 0.7715, 0.2318]}, {"w": "and", "b": [0.7772, 0.2136, 0.8087, 0.235]}, {"w": "pass‐", "b": [0.8144, 0.2136, 0.8571, 0.235]}, {"w": "ing", "b": [0.1429, 0.2335, 0.1696, 0.2549]}, {"w": "it", "b": [0.1753, 0.2335, 0.1873, 0.2549]}, {"w": "a", "b": [0.193, 0.2335, 0.2022, 0.2549]}, {"w": "DecisionTreeClassifier,", "b": [0.2079, 0.2335, 0.4304, 0.2549]}, {"w": "you", "b": [0.4362, 0.2335, 0.4674, 0.2549]}, {"w": "can", "b": [0.4732, 0.2335, 0.5025, 0.2549]}, {"w": "instead", "b": [0.5083, 0.2335, 0.5683, 0.2549]}, {"w": "use", "b": [0.574, 0.2335, 0.6016, 0.2549]}, {"w": "the", "b": [0.6073, 0.2335, 0.6337, 0.2549]}, {"w": "RandomForestClassifier", "b": [0.6394, 0.2367, 0.8571, 0.2518]}, {"w": "class,", "b": [0.1429, 0.2526, 0.1861, 0.274]}, {"w": "which", "b": [0.1912, 0.2526, 0.2421, 0.274]}, {"w": "is", "b": [0.2472, 0.2526, 0.2604, 0.274]}, {"w": "more", "b": [0.2655, 0.2526, 0.3098, 0.274]}, {"w": "convenient", "b": [0.3148, 0.2526, 0.4069, 0.274]}, {"w": "and", "b": [0.4119, 0.2526, 0.4435, 0.274]}, {"w": "optimized", "b": [0.4486, 0.2526, 0.5333, 0.274]}, {"w": "for", "b": [0.5384, 0.2526, 0.5629, 0.274]}, {"w": "Decision", "b": [0.568, 0.2526, 0.6418, 0.274]}, {"w": "Trees10", "b": [0.6468, 0.2526, 0.7025, 0.274]}, {"w": "(similarly,", "b": [0.7076, 0.2526, 0.7909, 0.274]}, {"w": "there", "b": [0.7956, 0.2526, 0.8385, 0.274]}, {"w": "is", "b": [0.8432, 0.2526, 0.8565, 0.274]}, {"w": "a", "b": [0.1429, 0.2725, 0.152, 0.2939]}, {"w": "RandomForestRegressor", "b": [0.1607, 0.2757, 0.3685, 0.2908]}, {"w": "class", "b": [0.3773, 0.2725, 0.4158, 0.2939]}, {"w": "for", "b": [0.4245, 0.2725, 0.449, 0.2939]}, {"w": "regression", "b": [0.4578, 0.2725, 0.5436, 0.2939]}, {"w": "tasks).", "b": [0.5523, 0.2725, 0.6054, 0.2939]}, {"w": "The", "b": [0.6141, 0.2725, 0.647, 0.2939]}, {"w": "following", "b": [0.6557, 0.2725, 0.7347, 0.2939]}, {"w": "code", "b": [0.7434, 0.2725, 0.7827, 0.2939]}, {"w": "trains", "b": [0.7914, 0.2725, 0.8393, 0.2939]}, {"w": "a", "b": [0.848, 0.2725, 0.8571, 0.2939]}, {"w": "Random", "b": [0.1429, 0.2916, 0.2154, 0.313]}, {"w": "Forest", "b": [0.2217, 0.2916, 0.2735, 0.313]}, {"w": "classifier", "b": [0.2798, 0.2916, 0.3523, 0.313]}, {"w": "with", "b": [0.3585, 0.2916, 0.3959, 0.313]}, {"w": "500", "b": [0.4022, 0.2916, 0.4322, 0.313]}, {"w": "trees", "b": [0.4385, 0.2916, 0.4779, 0.313]}, {"w": "(each", "b": [0.4842, 0.2916, 0.5293, 0.313]}, {"w": "limited", "b": [0.5356, 0.2916, 0.5954, 0.313]}, {"w": "to", "b": [0.6016, 0.2916, 0.6186, 0.313]}, {"w": "maximum", "b": [0.6249, 0.2916, 0.7113, 0.313]}, {"w": "16", "b": [0.7176, 0.2916, 0.7376, 0.313]}, {"w": "nodes),", "b": [0.7439, 0.2916, 0.8054, 0.313]}, {"w": "using", "b": [0.8117, 0.2916, 0.8571, 0.313]}, {"w": "all", "b": [0.1429, 0.3106, 0.1626, 0.332]}, {"w": "available", "b": [0.1673, 0.3106, 0.2396, 0.332]}, {"w": "CPU", "b": [0.2443, 0.3106, 0.2852, 0.332]}, {"w": "cores:", "b": [0.2899, 0.3106, 0.3383, 0.332]}]}, {"id": "b_6", "type": "paragraph", "text": "from sklearn.ensemble import RandomForestClassifier", "words": [{"w": "from", "b": [0.1766, 0.3426, 0.2103, 0.3554]}, {"w": "sklearn.ensemble", "b": [0.2188, 0.3426, 0.3537, 0.3554]}, {"w": "import", "b": [0.3621, 0.3426, 0.4127, 0.3554]}, {"w": "RandomForestClassifier", "b": [0.4211, 0.3426, 0.6067, 0.3554]}]}, {"id": "b_7", "type": "paragraph", "text": "rnd_clf = RandomForestClassifier(n_estimators=500, max_leaf_nodes=16, n_jobs=-1) rnd_clf.fit(X_train, y_train)", "words": [{"w": "rnd_clf", "b": [0.1766, 0.3734, 0.2356, 0.3863]}, {"w": "=", "b": [0.2441, 0.3734, 0.2525, 0.3863]}, {"w": "RandomForestClassifier(n_estimators=500,", "b": [0.2609, 0.3734, 0.5982, 0.3863]}, {"w": "max_leaf_nodes=16,", "b": [0.6067, 0.3734, 0.7584, 0.3863]}, {"w": "n_jobs=-1)", "b": [0.7669, 0.3734, 0.8512, 0.3863]}, {"w": "rnd_clf.fit(X_train,", "b": [0.1766, 0.3888, 0.3452, 0.4017]}, {"w": "y_train)", "b": [0.3537, 0.3888, 0.4211, 0.4017]}]}, {"id": "b_8", "type": "equation", "text": "y_pred_rf = rnd_clf.predict(X_test)", "words": [{"w": "y_pred_rf", "b": [0.1766, 0.4197, 0.2525, 0.4325]}, {"w": "=", "b": [0.2609, 0.4197, 0.2694, 0.4325]}, {"w": "rnd_clf.predict(X_test)", "b": [0.2778, 0.4197, 0.4717, 0.4325]}]}, {"id": "b_9", "type": "paragraph", "text": "With a few exceptions, a RandomForestClassifier has all the hyperparameters of a DecisionTreeClassifier (to control how trees are grown), plus all the hyperpara‐ meters of a BaggingClassifier to control the ensemble itself.11", "words": [{"w": "With", "b": [0.1429, 0.4412, 0.1853, 0.4626]}, {"w": "a", "b": [0.1918, 0.4412, 0.201, 0.4626]}, {"w": "few", "b": [0.2075, 0.4412, 0.2368, 0.4626]}, {"w": "exceptions,", "b": [0.2433, 0.4412, 0.337, 0.4626]}, {"w": "a", "b": [0.3435, 0.4412, 0.3527, 0.4626]}, {"w": "RandomForestClassifier", "b": [0.3592, 0.4444, 0.5769, 0.4595]}, {"w": "has", "b": [0.5834, 0.4412, 0.6114, 0.4626]}, {"w": "all", "b": [0.6179, 0.4412, 0.6376, 0.4626]}, {"w": "the", "b": [0.6441, 0.4412, 0.6704, 0.4626]}, {"w": "hyperparameters", "b": [0.677, 0.4412, 0.8181, 0.4626]}, {"w": "of", "b": [0.8247, 0.4412, 0.8415, 0.4626]}, {"w": "a", "b": [0.848, 0.4412, 0.8571, 0.4626]}, {"w": "DecisionTreeClassifier", "b": [0.1429, 0.4643, 0.3606, 0.4794]}, {"w": "(to", "b": [0.3678, 0.4612, 0.392, 0.4826]}, {"w": "control", "b": [0.3992, 0.4612, 0.4596, 0.4826]}, {"w": "how", "b": [0.4668, 0.4612, 0.5028, 0.4826]}, {"w": "trees", "b": [0.51, 0.4612, 0.5495, 0.4826]}, {"w": "are", "b": [0.5567, 0.4612, 0.5824, 0.4826]}, {"w": "grown),", "b": [0.5896, 0.4612, 0.6553, 0.4826]}, {"w": "plus", "b": [0.6625, 0.4612, 0.6974, 0.4826]}, {"w": "all", "b": [0.7046, 0.4612, 0.7243, 0.4826]}, {"w": "the", "b": [0.7315, 0.4612, 0.7579, 0.4826]}, {"w": "hyperpara‐", "b": [0.7651, 0.4612, 0.8571, 0.4826]}, {"w": "meters", "b": [0.1429, 0.4811, 0.1994, 0.5025]}, {"w": "of", "b": [0.2041, 0.4811, 0.2209, 0.5025]}, {"w": "a", "b": [0.2256, 0.4811, 0.2348, 0.5025]}, {"w": "BaggingClassifier", "b": [0.2395, 0.4843, 0.4077, 0.4994]}, {"w": "to", "b": [0.4124, 0.4811, 0.4294, 0.5025]}, {"w": "control", "b": [0.4341, 0.4811, 0.4946, 0.5025]}, {"w": "the", "b": [0.4993, 0.4811, 0.5256, 0.5025]}, {"w": "ensemble", "b": [0.5304, 0.4811, 0.6089, 0.5025]}, {"w": "itself.11", "b": [0.6136, 0.4811, 0.6697, 0.5025]}]}, {"id": "b_10", "type": "paragraph", "text": "The Random Forest algorithm introduces extra randomness when growing trees; instead of searching for the very best feature when splitting a node (see Chapter 6), it searches for the best feature among a random subset of features. This results in a greater tree diversity, which (once again) trades a higher bias for a lower variance, generally yielding an overall better model. The following BaggingClassifier is roughly equivalent to the previous RandomForestClassifier:", "words": [{"w": "The", "b": [0.1429, 0.5092, 0.1757, 0.5306]}, {"w": "Random", "b": [0.1849, 0.5092, 0.2574, 0.5306]}, {"w": "Forest", "b": [0.2666, 0.5092, 0.3184, 0.5306]}, {"w": "algorithm", "b": [0.3275, 0.5092, 0.4102, 0.5306]}, {"w": "introduces", "b": [0.4193, 0.5092, 0.508, 0.5306]}, {"w": "extra", "b": [0.5172, 0.5092, 0.5591, 0.5306]}, {"w": "randomness", "b": [0.5682, 0.5092, 0.6707, 0.5306]}, {"w": "when", "b": [0.6799, 0.5092, 0.7255, 0.5306]}, {"w": "growing", "b": [0.7347, 0.5092, 0.8038, 0.5306]}, {"w": "trees;", "b": [0.813, 0.5092, 0.8572, 0.5306]}, {"w": "instead", "b": [0.1429, 0.5283, 0.2028, 0.5497]}, {"w": "of", "b": [0.2081, 0.5283, 0.2249, 0.5497]}, {"w": "searching", "b": [0.2302, 0.5283, 0.3103, 0.5497]}, {"w": "for", "b": [0.3156, 0.5283, 0.3401, 0.5497]}, {"w": "the", "b": [0.3454, 0.5283, 0.3717, 0.5497]}, {"w": "very", "b": [0.377, 0.5283, 0.4134, 0.5497]}, {"w": "best", "b": [0.4187, 0.5283, 0.4521, 0.5497]}, {"w": "feature", "b": [0.4574, 0.5283, 0.5152, 0.5497]}, {"w": "when", "b": [0.5205, 0.5283, 0.5662, 0.5497]}, {"w": "splitting", "b": [0.5714, 0.5283, 0.6403, 0.5497]}, {"w": "a", "b": [0.6456, 0.5283, 0.6547, 0.5497]}, {"w": "node", "b": [0.66, 0.5283, 0.7019, 0.5497]}, {"w": "(see", "b": [0.7072, 0.5283, 0.7398, 0.5497]}, {"w": "Chapter", "b": [0.7451, 0.5283, 0.8127, 0.5497]}, {"w": "6),", "b": [0.8174, 0.5283, 0.8399, 0.5497]}, {"w": "it", "b": [0.8446, 0.5283, 0.8566, 0.5497]}, {"w": "searches", "b": [0.1429, 0.5473, 0.2127, 0.5687]}, {"w": "for", "b": [0.2206, 0.5473, 0.2452, 0.5687]}, {"w": "the", "b": [0.2531, 0.5473, 0.2794, 0.5687]}, {"w": "best", "b": [0.2874, 0.5473, 0.3208, 0.5687]}, {"w": "feature", "b": [0.3288, 0.5473, 0.3865, 0.5687]}, {"w": "among", "b": [0.3945, 0.5473, 0.4525, 0.5687]}, {"w": "a", "b": [0.4604, 0.5473, 0.4696, 0.5687]}, {"w": "random", "b": [0.4775, 0.5473, 0.5445, 0.5687]}, {"w": "subset", "b": [0.5524, 0.5473, 0.6046, 0.5687]}, {"w": "of", "b": [0.6125, 0.5473, 0.6293, 0.5687]}, {"w": "features.", "b": [0.6373, 0.5473, 0.7074, 0.5687]}, {"w": "This", "b": [0.7154, 0.5473, 0.7526, 0.5687]}, {"w": "results", "b": [0.7606, 0.5473, 0.8151, 0.5687]}, {"w": "in", "b": [0.8231, 0.5473, 0.8401, 0.5687]}, {"w": "a", "b": [0.848, 0.5473, 0.8572, 0.5687]}, {"w": "greater", "b": [0.1429, 0.5664, 0.2009, 0.5878]}, {"w": "tree", "b": [0.2083, 0.5664, 0.2401, 0.5878]}, {"w": "diversity,", "b": [0.2476, 0.5664, 0.3227, 0.5878]}, {"w": "which", "b": [0.3302, 0.5664, 0.3811, 0.5878]}, {"w": "(once", "b": [0.3886, 0.5664, 0.4354, 0.5878]}, {"w": "again)", "b": [0.4429, 0.5664, 0.4951, 0.5878]}, {"w": "trades", "b": [0.5026, 0.5664, 0.5533, 0.5878]}, {"w": "a", "b": [0.5607, 0.5664, 0.5699, 0.5878]}, {"w": "higher", "b": [0.5773, 0.5664, 0.6315, 0.5878]}, {"w": "bias", "b": [0.6389, 0.5664, 0.6719, 0.5878]}, {"w": "for", "b": [0.6793, 0.5664, 0.7039, 0.5878]}, {"w": "a", "b": [0.7113, 0.5664, 0.7204, 0.5878]}, {"w": "lower", "b": [0.7279, 0.5664, 0.7746, 0.5878]}, {"w": "variance,", "b": [0.7821, 0.5664, 0.8571, 0.5878]}, {"w": "generally", "b": [0.1429, 0.5863, 0.2187, 0.6077]}, {"w": "yielding", "b": [0.2292, 0.5863, 0.2962, 0.6077]}, {"w": "an", "b": [0.3068, 0.5863, 0.3273, 0.6077]}, {"w": "overall", "b": [0.3378, 0.5863, 0.3944, 0.6077]}, {"w": "better", "b": [0.4049, 0.5863, 0.4536, 0.6077]}, {"w": "model.", "b": [0.4642, 0.5863, 0.5217, 0.6077]}, {"w": "The", "b": [0.5323, 0.5863, 0.5651, 0.6077]}, {"w": "following", "b": [0.5756, 0.5863, 0.6546, 0.6077]}, {"w": "BaggingClassifier", "b": [0.6651, 0.5895, 0.8334, 0.6046]}, {"w": "is", "b": [0.8439, 0.5863, 0.8571, 0.6077]}, {"w": "roughly", "b": [0.1429, 0.6063, 0.208, 0.6277]}, {"w": "equivalent", "b": [0.2127, 0.6063, 0.2991, 0.6277]}, {"w": "to", "b": [0.3039, 0.6063, 0.3208, 0.6277]}, {"w": "the", "b": [0.3256, 0.6063, 0.3519, 0.6277]}, {"w": "previous", "b": [0.3566, 0.6063, 0.4287, 0.6277]}, {"w": "RandomForestClassifier:", "b": [0.4334, 0.6063, 0.6559, 0.6277]}]}, {"id": "b_11", "type": "paragraph", "text": "bag_clf = BaggingClassifier( DecisionTreeClassifier(splitter=\"random\", max_leaf_nodes=16), n_estimators=500, max_samples=1.0, bootstrap=True, n_jobs=-1)", "words": [{"w": "bag_clf", "b": [0.1766, 0.6382, 0.2356, 0.6511]}, {"w": "=", "b": [0.244, 0.6382, 0.2525, 0.6511]}, {"w": "BaggingClassifier(", "b": [0.2609, 0.6382, 0.4127, 0.6511]}, {"w": "DecisionTreeClassifier(splitter=\"random\",", "b": [0.2103, 0.6537, 0.556, 0.6665]}, {"w": "max_leaf_nodes=16),", "b": [0.5645, 0.6537, 0.7247, 0.6665]}, {"w": "n_estimators=500,", "b": [0.2103, 0.6691, 0.3537, 0.6819]}, {"w": "max_samples=1.0,", "b": [0.3621, 0.6691, 0.497, 0.6819]}, {"w": "bootstrap=True,", "b": [0.5055, 0.6691, 0.6319, 0.6819]}, {"w": "n_jobs=-1)", "b": [0.6404, 0.6691, 0.7247, 0.6819]}]}, {"id": "b_12", "type": "paragraph", "text": "Random Forests | 199", "words": [{"w": "Random", "b": [0.7017, 0.9225, 0.751, 0.9388]}, {"w": "Forests", "b": [0.7539, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "199", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 226, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "12 “Extremely randomized trees,” P. Geurts, D. Ernst, L. Wehenkel (2005).", "words": [{"w": "12", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Extremely", "b": [0.1587, 0.8749, 0.2301, 0.8912]}, {"w": "randomized", "b": [0.2337, 0.8749, 0.3107, 0.8912]}, {"w": "trees,”", "b": [0.3143, 0.8749, 0.3522, 0.8912]}, {"w": "P.", "b": [0.3558, 0.8749, 0.3661, 0.8912]}, {"w": "Geurts,", "b": [0.3697, 0.8749, 0.4164, 0.8912]}, {"w": "D.", "b": [0.42, 0.8749, 0.4347, 0.8912]}, {"w": "Ernst,", "b": [0.4383, 0.8749, 0.4762, 0.8912]}, {"w": "L.", "b": [0.4798, 0.8749, 0.4919, 0.8912]}, {"w": "Wehenkel", "b": [0.4955, 0.8749, 0.5587, 0.8912]}, {"w": "(2005).", "b": [0.5623, 0.8749, 0.6074, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Extra-Trees", "words": [{"w": "Extra-Trees", "b": [0.1429, 0.0763, 0.2591, 0.1049]}]}, {"id": "b_2", "type": "paragraph", "text": "When you are growing a tree in a Random Forest, at each node only a random subset of the features is considered for splitting (as discussed earlier). It is possible to make trees even more random by also using random thresholds for each feature rather than searching for the best possible thresholds (like regular Decision Trees do).", "words": [{"w": "When", "b": [0.1429, 0.1108, 0.1945, 0.1322]}, {"w": "you", "b": [0.1995, 0.1108, 0.2307, 0.1322]}, {"w": "are", "b": [0.2358, 0.1108, 0.2615, 0.1322]}, {"w": "growing", "b": [0.2665, 0.1108, 0.3356, 0.1322]}, {"w": "a", "b": [0.3406, 0.1108, 0.3498, 0.1322]}, {"w": "tree", "b": [0.3548, 0.1108, 0.3866, 0.1322]}, {"w": "in", "b": [0.3916, 0.1108, 0.4086, 0.1322]}, {"w": "a", "b": [0.4136, 0.1108, 0.4228, 0.1322]}, {"w": "Random", "b": [0.4278, 0.1108, 0.5003, 0.1322]}, {"w": "Forest,", "b": [0.5054, 0.1108, 0.5619, 0.1322]}, {"w": "at", "b": [0.567, 0.1108, 0.5821, 0.1322]}, {"w": "each", "b": [0.5871, 0.1108, 0.625, 0.1322]}, {"w": "node", "b": [0.6301, 0.1108, 0.6719, 0.1322]}, {"w": "only", "b": [0.677, 0.1108, 0.7138, 0.1322]}, {"w": "a", "b": [0.7188, 0.1108, 0.728, 0.1322]}, {"w": "random", "b": [0.733, 0.1108, 0.8, 0.1322]}, {"w": "subset", "b": [0.805, 0.1108, 0.8571, 0.1322]}, {"w": "of", "b": [0.1429, 0.1298, 0.1597, 0.1512]}, {"w": "the", "b": [0.1657, 0.1298, 0.192, 0.1512]}, {"w": "features", "b": [0.198, 0.1298, 0.2634, 0.1512]}, {"w": "is", "b": [0.2694, 0.1298, 0.2826, 0.1512]}, {"w": "considered", "b": [0.2886, 0.1298, 0.3801, 0.1512]}, {"w": "for", "b": [0.3861, 0.1298, 0.4106, 0.1512]}, {"w": "splitting", "b": [0.4166, 0.1298, 0.4855, 0.1512]}, {"w": "(as", "b": [0.4915, 0.1298, 0.5155, 0.1512]}, {"w": "discussed", "b": [0.5215, 0.1298, 0.6007, 0.1512]}, {"w": "earlier).", "b": [0.6067, 0.1298, 0.6718, 0.1512]}, {"w": "It", "b": [0.6778, 0.1298, 0.6905, 0.1512]}, {"w": "is", "b": [0.6964, 0.1298, 0.7097, 0.1512]}, {"w": "possible", "b": [0.7157, 0.1298, 0.7828, 0.1512]}, {"w": "to", "b": [0.7888, 0.1298, 0.8058, 0.1512]}, {"w": "make", "b": [0.8118, 0.1298, 0.8572, 0.1512]}, {"w": "trees", "b": [0.1429, 0.1489, 0.1823, 0.1703]}, {"w": "even", "b": [0.1872, 0.1489, 0.2259, 0.1703]}, {"w": "more", "b": [0.2308, 0.1489, 0.2751, 0.1703]}, {"w": "random", "b": [0.28, 0.1489, 0.3469, 0.1703]}, {"w": "by", "b": [0.3518, 0.1489, 0.372, 0.1703]}, {"w": "also", "b": [0.3768, 0.1489, 0.4095, 0.1703]}, {"w": "using", "b": [0.4144, 0.1489, 0.4598, 0.1703]}, {"w": "random", "b": [0.4647, 0.1489, 0.5317, 0.1703]}, {"w": "thresholds", "b": [0.5366, 0.1489, 0.6239, 0.1703]}, {"w": "for", "b": [0.6288, 0.1489, 0.6533, 0.1703]}, {"w": "each", "b": [0.6582, 0.1489, 0.6962, 0.1703]}, {"w": "feature", "b": [0.701, 0.1489, 0.7588, 0.1703]}, {"w": "rather", "b": [0.7637, 0.1489, 0.8142, 0.1703]}, {"w": "than", "b": [0.8191, 0.1489, 0.8571, 0.1703]}, {"w": "searching", "b": [0.1429, 0.1679, 0.2229, 0.1893]}, {"w": "for", "b": [0.2276, 0.1679, 0.2521, 0.1893]}, {"w": "the", "b": [0.2569, 0.1679, 0.2832, 0.1893]}, {"w": "best", "b": [0.2879, 0.1679, 0.3214, 0.1893]}, {"w": "possible", "b": [0.3261, 0.1679, 0.3932, 0.1893]}, {"w": "thresholds", "b": [0.398, 0.1679, 0.4853, 0.1893]}, {"w": "(like", "b": [0.4901, 0.1679, 0.5273, 0.1893]}, {"w": "regular", "b": [0.532, 0.1679, 0.5916, 0.1893]}, {"w": "Decision", "b": [0.5963, 0.1679, 0.6701, 0.1893]}, {"w": "Trees", "b": [0.6749, 0.1679, 0.7191, 0.1893]}, {"w": "do).", "b": [0.7238, 0.1679, 0.7574, 0.1893]}]}, {"id": "b_3", "type": "paragraph", "text": "A forest of such extremely random trees is simply called an Extremely Randomized Trees ensemble12 (or Extra-Trees for short). Once again, this trades more bias for a lower variance. It also makes Extra-Trees much faster to train than regular Random Forests since finding the best possible threshold for each feature at every node is one of the most time-consuming tasks of growing a tree.", "words": [{"w": "A", "b": [0.1429, 0.196, 0.1573, 0.2175]}, {"w": "forest", "b": [0.1644, 0.196, 0.2118, 0.2175]}, {"w": "of", "b": [0.219, 0.196, 0.2357, 0.2175]}, {"w": "such", "b": [0.2429, 0.196, 0.2816, 0.2175]}, {"w": "extremely", "b": [0.2887, 0.196, 0.3711, 0.2175]}, {"w": "random", "b": [0.3783, 0.196, 0.4452, 0.2175]}, {"w": "trees", "b": [0.4524, 0.196, 0.4918, 0.2175]}, {"w": "is", "b": [0.499, 0.196, 0.5122, 0.2175]}, {"w": "simply", "b": [0.5194, 0.196, 0.575, 0.2175]}, {"w": "called", "b": [0.5822, 0.196, 0.6305, 0.2175]}, {"w": "an", "b": [0.6377, 0.196, 0.6582, 0.2175]}, {"w": "Extremely", "b": [0.6654, 0.1958, 0.7473, 0.2175]}, {"w": "Randomized", "b": [0.7545, 0.1958, 0.8571, 0.2175]}, {"w": "Trees", "b": [0.1428, 0.2149, 0.1845, 0.2365]}, {"w": "ensemble12", "b": [0.1919, 0.2151, 0.2819, 0.2365]}, {"w": "(or", "b": [0.2893, 0.2151, 0.3148, 0.2365]}, {"w": "Extra-Trees", "b": [0.3222, 0.2149, 0.4163, 0.2365]}, {"w": "for", "b": [0.4237, 0.2151, 0.4482, 0.2365]}, {"w": "short).", "b": [0.4557, 0.2151, 0.5111, 0.2365]}, {"w": "Once", "b": [0.5185, 0.2151, 0.5631, 0.2365]}, {"w": "again,", "b": [0.5706, 0.2151, 0.6203, 0.2365]}, {"w": "this", "b": [0.6277, 0.2151, 0.6584, 0.2365]}, {"w": "trades", "b": [0.6659, 0.2151, 0.7166, 0.2365]}, {"w": "more", "b": [0.724, 0.2151, 0.7683, 0.2365]}, {"w": "bias", "b": [0.7757, 0.2151, 0.8086, 0.2365]}, {"w": "for", "b": [0.8161, 0.2151, 0.8406, 0.2365]}, {"w": "a", "b": [0.848, 0.2151, 0.8571, 0.2365]}, {"w": "lower", "b": [0.1429, 0.2341, 0.1896, 0.2555]}, {"w": "variance.", "b": [0.196, 0.2341, 0.2711, 0.2555]}, {"w": "It", "b": [0.2775, 0.2341, 0.2901, 0.2555]}, {"w": "also", "b": [0.2965, 0.2341, 0.3292, 0.2555]}, {"w": "makes", "b": [0.3356, 0.2341, 0.3886, 0.2555]}, {"w": "Extra-Trees", "b": [0.395, 0.2341, 0.4915, 0.2555]}, {"w": "much", "b": [0.4979, 0.2341, 0.5456, 0.2555]}, {"w": "faster", "b": [0.552, 0.2341, 0.5979, 0.2555]}, {"w": "to", "b": [0.6043, 0.2341, 0.6213, 0.2555]}, {"w": "train", "b": [0.6276, 0.2341, 0.6679, 0.2555]}, {"w": "than", "b": [0.6743, 0.2341, 0.7123, 0.2555]}, {"w": "regular", "b": [0.7187, 0.2341, 0.7782, 0.2555]}, {"w": "Random", "b": [0.7846, 0.2341, 0.8571, 0.2555]}, {"w": "Forests", "b": [0.1429, 0.2532, 0.2023, 0.2746]}, {"w": "since", "b": [0.2079, 0.2532, 0.2502, 0.2746]}, {"w": "finding", "b": [0.2558, 0.2532, 0.3167, 0.2746]}, {"w": "the", "b": [0.3223, 0.2532, 0.3486, 0.2746]}, {"w": "best", "b": [0.3542, 0.2532, 0.3877, 0.2746]}, {"w": "possible", "b": [0.3933, 0.2532, 0.4604, 0.2746]}, {"w": "threshold", "b": [0.466, 0.2532, 0.5457, 0.2746]}, {"w": "for", "b": [0.5513, 0.2532, 0.5759, 0.2746]}, {"w": "each", "b": [0.5815, 0.2532, 0.6194, 0.2746]}, {"w": "feature", "b": [0.625, 0.2532, 0.6828, 0.2746]}, {"w": "at", "b": [0.6884, 0.2532, 0.7035, 0.2746]}, {"w": "every", "b": [0.7091, 0.2532, 0.7543, 0.2746]}, {"w": "node", "b": [0.7599, 0.2532, 0.8018, 0.2746]}, {"w": "is", "b": [0.8074, 0.2532, 0.8207, 0.2746]}, {"w": "one", "b": [0.8263, 0.2532, 0.8571, 0.2746]}, {"w": "of", "b": [0.1429, 0.2722, 0.1597, 0.2936]}, {"w": "the", "b": [0.1644, 0.2722, 0.1907, 0.2936]}, {"w": "most", "b": [0.1954, 0.2722, 0.2371, 0.2936]}, {"w": "time-consuming", "b": [0.2419, 0.2722, 0.3805, 0.2936]}, {"w": "tasks", "b": [0.3852, 0.2722, 0.4263, 0.2936]}, {"w": "of", "b": [0.4311, 0.2722, 0.4478, 0.2936]}, {"w": "growing", "b": [0.4526, 0.2722, 0.5217, 0.2936]}, {"w": "a", "b": [0.5264, 0.2722, 0.5356, 0.2936]}, {"w": "tree.", "b": [0.5403, 0.2722, 0.5768, 0.2936]}]}, {"id": "b_4", "type": "paragraph", "text": "You can create an Extra-Trees classifier using Scikit-Learn’s ExtraTreesClassifier class. Its API is identical to the RandomForestClassifier class. Similarly, the Extra TreesRegressor class has the same API as the RandomForestRegressor class.", "words": [{"w": "You", "b": [0.1429, 0.3012, 0.1752, 0.3227]}, {"w": "can", "b": [0.1827, 0.3012, 0.212, 0.3227]}, {"w": "create", "b": [0.2194, 0.3012, 0.2688, 0.3227]}, {"w": "an", "b": [0.2762, 0.3012, 0.2968, 0.3227]}, {"w": "Extra-Trees", "b": [0.3042, 0.3012, 0.4007, 0.3227]}, {"w": "classifier", "b": [0.4082, 0.3012, 0.4806, 0.3227]}, {"w": "using", "b": [0.488, 0.3012, 0.5335, 0.3227]}, {"w": "Scikit-Learn’s", "b": [0.5409, 0.3012, 0.6518, 0.3227]}, {"w": "ExtraTreesClassifier", "b": [0.6592, 0.3044, 0.8572, 0.3195]}, {"w": "class.", "b": [0.1429, 0.3212, 0.1861, 0.3426]}, {"w": "Its", "b": [0.1927, 0.3212, 0.213, 0.3426]}, {"w": "API", "b": [0.2196, 0.3212, 0.2528, 0.3426]}, {"w": "is", "b": [0.2594, 0.3212, 0.2726, 0.3426]}, {"w": "identical", "b": [0.2792, 0.3212, 0.3508, 0.3426]}, {"w": "to", "b": [0.3574, 0.3212, 0.3744, 0.3426]}, {"w": "the", "b": [0.381, 0.3212, 0.4073, 0.3426]}, {"w": "RandomForestClassifier", "b": [0.4139, 0.3244, 0.6316, 0.3395]}, {"w": "class.", "b": [0.6382, 0.3212, 0.6815, 0.3426]}, {"w": "Similarly,", "b": [0.6881, 0.3212, 0.7664, 0.3426]}, {"w": "the", "b": [0.773, 0.3212, 0.7993, 0.3426]}, {"w": "Extra", "b": [0.8059, 0.3244, 0.8554, 0.3395]}, {"w": "TreesRegressor", "b": [0.1429, 0.3443, 0.2814, 0.3594]}, {"w": "class", "b": [0.2861, 0.3411, 0.3247, 0.3625]}, {"w": "has", "b": [0.3294, 0.3411, 0.3573, 0.3625]}, {"w": "the", "b": [0.362, 0.3411, 0.3884, 0.3625]}, {"w": "same", "b": [0.3931, 0.3411, 0.4358, 0.3625]}, {"w": "API", "b": [0.4405, 0.3411, 0.4738, 0.3625]}, {"w": "as", "b": [0.4785, 0.3411, 0.4953, 0.3625]}, {"w": "the", "b": [0.5, 0.3411, 0.5263, 0.3625]}, {"w": "RandomForestRegressor", "b": [0.5311, 0.3443, 0.7389, 0.3594]}, {"w": "class.", "b": [0.7436, 0.3411, 0.7869, 0.3625]}]}, {"id": "b_5", "type": "paragraph", "text": "It is hard to tell in advance whether a RandomForestClassifier will perform better or worse than an ExtraTreesClassifier. Gen‐ erally, the only way to know is to try both and compare them using cross-validation (and tuning the hyperparameters using grid search).", "words": [{"w": "It", "b": [0.2714, 0.3839, 0.283, 0.4035]}, {"w": "is", "b": [0.2906, 0.3839, 0.3027, 0.4035]}, {"w": "hard", "b": [0.3103, 0.3839, 0.3459, 0.4035]}, {"w": "to", "b": [0.3535, 0.3839, 0.369, 0.4035]}, {"w": "tell", "b": [0.3766, 0.3839, 0.4002, 0.4035]}, {"w": "in", "b": [0.4078, 0.3839, 0.4233, 0.4035]}, {"w": "advance", "b": [0.4309, 0.3839, 0.4931, 0.4035]}, {"w": "whether", "b": [0.5007, 0.3839, 0.5631, 0.4035]}, {"w": "a", "b": [0.5707, 0.3839, 0.5791, 0.4035]}, {"w": "RandomForestClassifier", "b": [0.5867, 0.3868, 0.7857, 0.4006]}, {"w": "will", "b": [0.2714, 0.4021, 0.2992, 0.4217]}, {"w": "perform", "b": [0.3041, 0.4021, 0.3673, 0.4217]}, {"w": "better", "b": [0.3722, 0.4021, 0.4168, 0.4217]}, {"w": "or", "b": [0.4217, 0.4021, 0.4385, 0.4217]}, {"w": "worse", "b": [0.4434, 0.4021, 0.4883, 0.4217]}, {"w": "than", "b": [0.4932, 0.4021, 0.528, 0.4217]}, {"w": "an", "b": [0.5329, 0.4021, 0.5517, 0.4217]}, {"w": "ExtraTreesClassifier.", "b": [0.5566, 0.4021, 0.7419, 0.4217]}, {"w": "Gen‐", "b": [0.7462, 0.4021, 0.7851, 0.4217]}, {"w": "erally,", "b": [0.2714, 0.4195, 0.3163, 0.4391]}, {"w": "the", "b": [0.321, 0.4195, 0.3451, 0.4391]}, {"w": "only", "b": [0.3499, 0.4195, 0.3836, 0.4391]}, {"w": "way", "b": [0.3883, 0.4195, 0.4182, 0.4391]}, {"w": "to", "b": [0.4229, 0.4195, 0.4384, 0.4391]}, {"w": "know", "b": [0.4432, 0.4195, 0.4858, 0.4391]}, {"w": "is", "b": [0.4906, 0.4195, 0.5027, 0.4391]}, {"w": "to", "b": [0.5075, 0.4195, 0.523, 0.4391]}, {"w": "try", "b": [0.5278, 0.4195, 0.5499, 0.4391]}, {"w": "both", "b": [0.5547, 0.4195, 0.5901, 0.4391]}, {"w": "and", "b": [0.5948, 0.4195, 0.6237, 0.4391]}, {"w": "compare", "b": [0.6284, 0.4195, 0.695, 0.4391]}, {"w": "them", "b": [0.6997, 0.4195, 0.7394, 0.4391]}, {"w": "using", "b": [0.7442, 0.4195, 0.7857, 0.4391]}, {"w": "cross-validation", "b": [0.2714, 0.437, 0.3932, 0.4565]}, {"w": "(and", "b": [0.4066, 0.437, 0.4421, 0.4565]}, {"w": "tuning", "b": [0.4555, 0.437, 0.5063, 0.4565]}, {"w": "the", "b": [0.5197, 0.437, 0.5437, 0.4565]}, {"w": "hyperparameters", "b": [0.5572, 0.437, 0.6862, 0.4565]}, {"w": "using", "b": [0.6996, 0.437, 0.7412, 0.4565]}, {"w": "grid", "b": [0.7546, 0.437, 0.7857, 0.4565]}, {"w": "search).", "b": [0.2714, 0.4544, 0.3311, 0.474]}]}, {"id": "b_6", "type": "paragraph", "text": "Feature Importance", "words": [{"w": "Feature", "b": [0.1428, 0.4915, 0.2224, 0.5201]}, {"w": "Importance", "b": [0.2273, 0.4915, 0.3465, 0.5201]}]}, {"id": "b_7", "type": "paragraph", "text": "Yet another great quality of Random Forests is that they make it easy to measure the relative importance of each feature. Scikit-Learn measures a feature’s importance by looking at how much the tree nodes that use that feature reduce impurity on average (across all trees in the forest). More precisely, it is a weighted average, where each node’s weight is equal to the number of training samples that are associated with it (see Chapter 6).", "words": [{"w": "Yet", "b": [0.1429, 0.526, 0.1687, 0.5474]}, {"w": "another", "b": [0.1742, 0.526, 0.2394, 0.5474]}, {"w": "great", "b": [0.2449, 0.526, 0.2863, 0.5474]}, {"w": "quality", "b": [0.2918, 0.526, 0.3494, 0.5474]}, {"w": "of", "b": [0.3549, 0.526, 0.3717, 0.5474]}, {"w": "Random", "b": [0.3771, 0.526, 0.4497, 0.5474]}, {"w": "Forests", "b": [0.4551, 0.526, 0.5146, 0.5474]}, {"w": "is", "b": [0.5201, 0.526, 0.5333, 0.5474]}, {"w": "that", "b": [0.5388, 0.526, 0.5713, 0.5474]}, {"w": "they", "b": [0.5768, 0.526, 0.6127, 0.5474]}, {"w": "make", "b": [0.6182, 0.526, 0.6636, 0.5474]}, {"w": "it", "b": [0.669, 0.526, 0.681, 0.5474]}, {"w": "easy", "b": [0.6864, 0.526, 0.7216, 0.5474]}, {"w": "to", "b": [0.7271, 0.526, 0.7441, 0.5474]}, {"w": "measure", "b": [0.7495, 0.526, 0.8199, 0.5474]}, {"w": "the", "b": [0.8253, 0.526, 0.8517, 0.5474]}, {"w": "relative", "b": [0.1429, 0.545, 0.2039, 0.5664]}, {"w": "importance", "b": [0.2106, 0.545, 0.3067, 0.5664]}, {"w": "of", "b": [0.3134, 0.545, 0.3302, 0.5664]}, {"w": "each", "b": [0.337, 0.545, 0.3749, 0.5664]}, {"w": "feature.", "b": [0.3817, 0.545, 0.4442, 0.5664]}, {"w": "Scikit-Learn", "b": [0.4509, 0.545, 0.5532, 0.5664]}, {"w": "measures", "b": [0.5599, 0.545, 0.6379, 0.5664]}, {"w": "a", "b": [0.6447, 0.545, 0.6538, 0.5664]}, {"w": "feature’s", "b": [0.6606, 0.545, 0.7274, 0.5664]}, {"w": "importance", "b": [0.7342, 0.545, 0.8303, 0.5664]}, {"w": "by", "b": [0.837, 0.545, 0.8571, 0.5664]}, {"w": "looking", "b": [0.1429, 0.5641, 0.2064, 0.5855]}, {"w": "at", "b": [0.2121, 0.5641, 0.2272, 0.5855]}, {"w": "how", "b": [0.2329, 0.5641, 0.2689, 0.5855]}, {"w": "much", "b": [0.2746, 0.5641, 0.3222, 0.5855]}, {"w": "the", "b": [0.3279, 0.5641, 0.3542, 0.5855]}, {"w": "tree", "b": [0.3599, 0.5641, 0.3917, 0.5855]}, {"w": "nodes", "b": [0.3973, 0.5641, 0.4468, 0.5855]}, {"w": "that", "b": [0.4525, 0.5641, 0.4851, 0.5855]}, {"w": "use", "b": [0.4907, 0.5641, 0.5183, 0.5855]}, {"w": "that", "b": [0.524, 0.5641, 0.5565, 0.5855]}, {"w": "feature", "b": [0.5622, 0.5641, 0.62, 0.5855]}, {"w": "reduce", "b": [0.6256, 0.5641, 0.6819, 0.5855]}, {"w": "impurity", "b": [0.6876, 0.5641, 0.7611, 0.5855]}, {"w": "on", "b": [0.7667, 0.5641, 0.7887, 0.5855]}, {"w": "average", "b": [0.7944, 0.5641, 0.8572, 0.5855]}, {"w": "(across", "b": [0.1429, 0.5831, 0.2017, 0.6045]}, {"w": "all", "b": [0.2092, 0.5831, 0.2289, 0.6045]}, {"w": "trees", "b": [0.2365, 0.5831, 0.2759, 0.6045]}, {"w": "in", "b": [0.2835, 0.5831, 0.3005, 0.6045]}, {"w": "the", "b": [0.3081, 0.5831, 0.3344, 0.6045]}, {"w": "forest).", "b": [0.342, 0.5831, 0.4013, 0.6045]}, {"w": "More", "b": [0.4089, 0.5831, 0.4541, 0.6045]}, {"w": "precisely,", "b": [0.4617, 0.5831, 0.5381, 0.6045]}, {"w": "it", "b": [0.5457, 0.5831, 0.5577, 0.6045]}, {"w": "is", "b": [0.5652, 0.5831, 0.5785, 0.6045]}, {"w": "a", "b": [0.586, 0.5831, 0.5952, 0.6045]}, {"w": "weighted", "b": [0.6028, 0.5831, 0.6782, 0.6045]}, {"w": "average,", "b": [0.6857, 0.5831, 0.7532, 0.6045]}, {"w": "where", "b": [0.7608, 0.5831, 0.8116, 0.6045]}, {"w": "each", "b": [0.8192, 0.5831, 0.8571, 0.6045]}, {"w": "node’s", "b": [0.1429, 0.6022, 0.1938, 0.6236]}, {"w": "weight", "b": [0.2008, 0.6022, 0.2564, 0.6236]}, {"w": "is", "b": [0.2634, 0.6022, 0.2766, 0.6236]}, {"w": "equal", "b": [0.2836, 0.6022, 0.3286, 0.6236]}, {"w": "to", "b": [0.3356, 0.6022, 0.3526, 0.6236]}, {"w": "the", "b": [0.3596, 0.6022, 0.3859, 0.6236]}, {"w": "number", "b": [0.3929, 0.6022, 0.4592, 0.6236]}, {"w": "of", "b": [0.4662, 0.6022, 0.483, 0.6236]}, {"w": "training", "b": [0.49, 0.6022, 0.557, 0.6236]}, {"w": "samples", "b": [0.564, 0.6022, 0.6301, 0.6236]}, {"w": "that", "b": [0.6371, 0.6022, 0.6697, 0.6236]}, {"w": "are", "b": [0.6767, 0.6022, 0.7024, 0.6236]}, {"w": "associated", "b": [0.7094, 0.6022, 0.7939, 0.6236]}, {"w": "with", "b": [0.8009, 0.6022, 0.8382, 0.6236]}, {"w": "it", "b": [0.8452, 0.6022, 0.8571, 0.6236]}, {"w": "(see", "b": [0.1428, 0.6212, 0.1754, 0.6426]}, {"w": "Chapter", "b": [0.1801, 0.6212, 0.2477, 0.6426]}, {"w": "6).", "b": [0.2525, 0.6212, 0.2744, 0.6426]}]}, {"id": "b_8", "type": "paragraph", "text": "Scikit-Learn computes this score automatically for each feature after training, then it scales the results so that the sum of all importances is equal to 1. You can access the result using the feature_importances_ variable. For example, the following code trains a RandomForestClassifier on the iris dataset (introduced in Chapter 4) and outputs each feature’s importance. It seems that the most important features are the petal length (44%) and width (42%), while sepal length and width are rather unim‐ portant in comparison (11% and 2%, respectively).", "words": [{"w": "Scikit-Learn", "b": [0.1428, 0.6493, 0.2451, 0.6707]}, {"w": "computes", "b": [0.251, 0.6493, 0.3319, 0.6707]}, {"w": "this", "b": [0.3378, 0.6493, 0.3685, 0.6707]}, {"w": "score", "b": [0.3743, 0.6493, 0.418, 0.6707]}, {"w": "automatically", "b": [0.4238, 0.6493, 0.5364, 0.6707]}, {"w": "for", "b": [0.5423, 0.6493, 0.5668, 0.6707]}, {"w": "each", "b": [0.5726, 0.6493, 0.6106, 0.6707]}, {"w": "feature", "b": [0.6164, 0.6493, 0.6742, 0.6707]}, {"w": "after", "b": [0.68, 0.6493, 0.7183, 0.6707]}, {"w": "training,", "b": [0.7241, 0.6493, 0.7958, 0.6707]}, {"w": "then", "b": [0.8016, 0.6493, 0.8394, 0.6707]}, {"w": "it", "b": [0.8452, 0.6493, 0.8571, 0.6707]}, {"w": "scales", "b": [0.1429, 0.6684, 0.1902, 0.6898]}, {"w": "the", "b": [0.1964, 0.6684, 0.2227, 0.6898]}, {"w": "results", "b": [0.2288, 0.6684, 0.2834, 0.6898]}, {"w": "so", "b": [0.2895, 0.6684, 0.3077, 0.6898]}, {"w": "that", "b": [0.3139, 0.6684, 0.3464, 0.6898]}, {"w": "the", "b": [0.3526, 0.6684, 0.3789, 0.6898]}, {"w": "sum", "b": [0.385, 0.6684, 0.4208, 0.6898]}, {"w": "of", "b": [0.4269, 0.6684, 0.4437, 0.6898]}, {"w": "all", "b": [0.4498, 0.6684, 0.4695, 0.6898]}, {"w": "importances", "b": [0.4756, 0.6684, 0.5793, 0.6898]}, {"w": "is", "b": [0.5854, 0.6684, 0.5987, 0.6898]}, {"w": "equal", "b": [0.6048, 0.6684, 0.6498, 0.6898]}, {"w": "to", "b": [0.6559, 0.6684, 0.6729, 0.6898]}, {"w": "1.", "b": [0.679, 0.6684, 0.6937, 0.6898]}, {"w": "You", "b": [0.6998, 0.6684, 0.7322, 0.6898]}, {"w": "can", "b": [0.7383, 0.6684, 0.7677, 0.6898]}, {"w": "access", "b": [0.7738, 0.6684, 0.8247, 0.6898]}, {"w": "the", "b": [0.8308, 0.6684, 0.8571, 0.6898]}, {"w": "result", "b": [0.1429, 0.6883, 0.1898, 0.7097]}, {"w": "using", "b": [0.1986, 0.6883, 0.244, 0.7097]}, {"w": "the", "b": [0.2528, 0.6883, 0.2791, 0.7097]}, {"w": "feature_importances_", "b": [0.2879, 0.6915, 0.4858, 0.7066]}, {"w": "variable.", "b": [0.4946, 0.6883, 0.5653, 0.7097]}, {"w": "For", "b": [0.5741, 0.6883, 0.6031, 0.7097]}, {"w": "example,", "b": [0.6119, 0.6883, 0.6862, 0.7097]}, {"w": "the", "b": [0.695, 0.6883, 0.7213, 0.7097]}, {"w": "following", "b": [0.7301, 0.6883, 0.8091, 0.7097]}, {"w": "code", "b": [0.8179, 0.6883, 0.8571, 0.7097]}, {"w": "trains", "b": [0.1429, 0.7083, 0.1907, 0.7297]}, {"w": "a", "b": [0.1974, 0.7083, 0.2066, 0.7297]}, {"w": "RandomForestClassifier", "b": [0.2133, 0.7114, 0.431, 0.7265]}, {"w": "on", "b": [0.4378, 0.7083, 0.4598, 0.7297]}, {"w": "the", "b": [0.4665, 0.7083, 0.4928, 0.7297]}, {"w": "iris", "b": [0.4996, 0.7083, 0.5261, 0.7297]}, {"w": "dataset", "b": [0.5328, 0.7083, 0.5909, 0.7297]}, {"w": "(introduced", "b": [0.5977, 0.7083, 0.6969, 0.7297]}, {"w": "in", "b": [0.7036, 0.7083, 0.7206, 0.7297]}, {"w": "Chapter", "b": [0.7273, 0.7083, 0.7949, 0.7297]}, {"w": "4)", "b": [0.8017, 0.7083, 0.8189, 0.7297]}, {"w": "and", "b": [0.8256, 0.7083, 0.8571, 0.7297]}, {"w": "outputs", "b": [0.1429, 0.7273, 0.2069, 0.7487]}, {"w": "each", "b": [0.2135, 0.7273, 0.2514, 0.7487]}, {"w": "feature’s", "b": [0.2581, 0.7273, 0.3249, 0.7487]}, {"w": "importance.", "b": [0.3316, 0.7273, 0.4324, 0.7487]}, {"w": "It", "b": [0.439, 0.7273, 0.4517, 0.7487]}, {"w": "seems", "b": [0.4583, 0.7273, 0.5083, 0.7487]}, {"w": "that", "b": [0.515, 0.7273, 0.5476, 0.7487]}, {"w": "the", "b": [0.5542, 0.7273, 0.5805, 0.7487]}, {"w": "most", "b": [0.5871, 0.7273, 0.6288, 0.7487]}, {"w": "important", "b": [0.6354, 0.7273, 0.7198, 0.7487]}, {"w": "features", "b": [0.7264, 0.7273, 0.7918, 0.7487]}, {"w": "are", "b": [0.7985, 0.7273, 0.8242, 0.7487]}, {"w": "the", "b": [0.8308, 0.7273, 0.8572, 0.7487]}, {"w": "petal", "b": [0.1429, 0.7464, 0.1834, 0.7678]}, {"w": "length", "b": [0.1901, 0.7464, 0.2429, 0.7678]}, {"w": "(44%)", "b": [0.2496, 0.7464, 0.2998, 0.7678]}, {"w": "and", "b": [0.3066, 0.7464, 0.3381, 0.7678]}, {"w": "width", "b": [0.3448, 0.7464, 0.3932, 0.7678]}, {"w": "(42%),", "b": [0.3999, 0.7464, 0.4548, 0.7678]}, {"w": "while", "b": [0.4616, 0.7464, 0.5067, 0.7678]}, {"w": "sepal", "b": [0.5134, 0.7464, 0.5553, 0.7678]}, {"w": "length", "b": [0.562, 0.7464, 0.6148, 0.7678]}, {"w": "and", "b": [0.6215, 0.7464, 0.653, 0.7678]}, {"w": "width", "b": [0.6598, 0.7464, 0.7081, 0.7678]}, {"w": "are", "b": [0.7149, 0.7464, 0.7406, 0.7678]}, {"w": "rather", "b": [0.7473, 0.7464, 0.7979, 0.7678]}, {"w": "unim‐", "b": [0.8046, 0.7464, 0.8571, 0.7678]}, {"w": "portant", "b": [0.1429, 0.7654, 0.205, 0.7868]}, {"w": "in", "b": [0.2097, 0.7654, 0.2267, 0.7868]}, {"w": "comparison", "b": [0.2314, 0.7654, 0.3306, 0.7868]}, {"w": "(11%", "b": [0.3353, 0.7654, 0.3783, 0.7868]}, {"w": "and", "b": [0.383, 0.7654, 0.4145, 0.7868]}, {"w": "2%,", "b": [0.4193, 0.7654, 0.4498, 0.7868]}, {"w": "respectively).", "b": [0.4545, 0.7654, 0.5645, 0.7868]}]}, {"id": "b_9", "type": "paragraph", "text": "200 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "200", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 227, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": ">>> from sklearn.datasets import load_iris >>> iris = load_iris() >>> rnd_clf = RandomForestClassifier(n_estimators=500, n_jobs=-1) >>> rnd_clf.fit(iris[\"data\"], iris[\"target\"]) >>> for name, score in zip(iris[\"feature_names\"], rnd_clf.feature_importances_): ... print(name, score) ... sepal length (cm) 0.112492250999 sepal width (cm) 0.0231192882825 petal length (cm) 0.441030464364 petal width (cm) 0.423357996355", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "from", "b": [0.2103, 0.0829, 0.244, 0.0958]}, {"w": "sklearn.datasets", "b": [0.2525, 0.0829, 0.3874, 0.0958]}, {"w": "import", "b": [0.3958, 0.0829, 0.4464, 0.0958]}, {"w": "load_iris", "b": [0.4549, 0.0829, 0.5308, 0.0958]}, {"w": ">>>", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "iris", "b": [0.2103, 0.0983, 0.244, 0.1112]}, {"w": "=", "b": [0.2525, 0.0983, 0.2609, 0.1112]}, {"w": "load_iris()", "b": [0.2693, 0.0983, 0.3621, 0.1112]}, {"w": ">>>", "b": [0.1766, 0.1138, 0.2019, 0.1266]}, {"w": "rnd_clf", "b": [0.2103, 0.1138, 0.2693, 0.1266]}, {"w": "=", "b": [0.2778, 0.1138, 0.2862, 0.1266]}, {"w": "RandomForestClassifier(n_estimators=500,", "b": [0.2946, 0.1138, 0.6319, 0.1266]}, {"w": "n_jobs=-1)", "b": [0.6404, 0.1138, 0.7247, 0.1266]}, {"w": ">>>", "b": [0.1766, 0.1292, 0.2019, 0.142]}, {"w": "rnd_clf.fit(iris[\"data\"],", "b": [0.2103, 0.1292, 0.4211, 0.142]}, {"w": "iris[\"target\"])", "b": [0.4296, 0.1292, 0.5561, 0.142]}, {"w": ">>>", "b": [0.1766, 0.1446, 0.2019, 0.1574]}, {"w": "for", "b": [0.2103, 0.1446, 0.2356, 0.1574]}, {"w": "name,", "b": [0.244, 0.1446, 0.2862, 0.1574]}, {"w": "score", "b": [0.2946, 0.1446, 0.3368, 0.1574]}, {"w": "in", "b": [0.3452, 0.1446, 0.3621, 0.1574]}, {"w": "zip(iris[\"feature_names\"],", "b": [0.3705, 0.1446, 0.5898, 0.1574]}, {"w": "rnd_clf.feature_importances_):", "b": [0.5982, 0.1446, 0.8512, 0.1574]}, {"w": "...", "b": [0.1766, 0.16, 0.2019, 0.1729]}, {"w": "print(name,", "b": [0.244, 0.16, 0.3368, 0.1729]}, {"w": "score)", "b": [0.3452, 0.16, 0.3958, 0.1729]}, {"w": "...", "b": [0.1766, 0.1754, 0.2019, 0.1883]}, {"w": "sepal", "b": [0.1766, 0.1909, 0.2188, 0.2037]}, {"w": "length", "b": [0.2272, 0.1909, 0.2778, 0.2037]}, {"w": "(cm)", "b": [0.2862, 0.1909, 0.3199, 0.2037]}, {"w": "0.112492250999", "b": [0.3284, 0.1909, 0.4464, 0.2037]}, {"w": "sepal", "b": [0.1766, 0.2063, 0.2188, 0.2191]}, {"w": "width", "b": [0.2272, 0.2063, 0.2693, 0.2191]}, {"w": "(cm)", "b": [0.2778, 0.2063, 0.3115, 0.2191]}, {"w": "0.0231192882825", "b": [0.3199, 0.2063, 0.4464, 0.2191]}, {"w": "petal", "b": [0.1766, 0.2217, 0.2188, 0.2345]}, {"w": "length", "b": [0.2272, 0.2217, 0.2778, 0.2345]}, {"w": "(cm)", "b": [0.2862, 0.2217, 0.3199, 0.2345]}, {"w": "0.441030464364", "b": [0.3284, 0.2217, 0.4464, 0.2345]}, {"w": "petal", "b": [0.1766, 0.2371, 0.2188, 0.25]}, {"w": "width", "b": [0.2272, 0.2371, 0.2693, 0.25]}, {"w": "(cm)", "b": [0.2778, 0.2371, 0.3115, 0.25]}, {"w": "0.423357996355", "b": [0.3199, 0.2371, 0.438, 0.25]}]}, {"id": "b_1", "type": "paragraph", "text": "Similarly, if you train a Random Forest classifier on the MNIST dataset (introduced in Chapter 3) and plot each pixel’s importance, you get the image represented in Figure 7-6.", "words": [{"w": "Similarly,", "b": [0.1429, 0.2577, 0.2212, 0.2792]}, {"w": "if", "b": [0.2276, 0.2577, 0.2393, 0.2792]}, {"w": "you", "b": [0.2458, 0.2577, 0.277, 0.2792]}, {"w": "train", "b": [0.2835, 0.2577, 0.3237, 0.2792]}, {"w": "a", "b": [0.3301, 0.2577, 0.3393, 0.2792]}, {"w": "Random", "b": [0.3457, 0.2577, 0.4182, 0.2792]}, {"w": "Forest", "b": [0.4247, 0.2577, 0.4765, 0.2792]}, {"w": "classifier", "b": [0.483, 0.2577, 0.5554, 0.2792]}, {"w": "on", "b": [0.5618, 0.2577, 0.5838, 0.2792]}, {"w": "the", "b": [0.5903, 0.2577, 0.6166, 0.2792]}, {"w": "MNIST", "b": [0.6231, 0.2577, 0.6869, 0.2792]}, {"w": "dataset", "b": [0.6934, 0.2577, 0.7515, 0.2792]}, {"w": "(introduced", "b": [0.7579, 0.2577, 0.8571, 0.2792]}, {"w": "in", "b": [0.1429, 0.2768, 0.1598, 0.2982]}, {"w": "Chapter", "b": [0.1684, 0.2768, 0.236, 0.2982]}, {"w": "3)", "b": [0.2445, 0.2768, 0.2617, 0.2982]}, {"w": "and", "b": [0.2703, 0.2768, 0.3018, 0.2982]}, {"w": "plot", "b": [0.3104, 0.2768, 0.3435, 0.2982]}, {"w": "each", "b": [0.3521, 0.2768, 0.39, 0.2982]}, {"w": "pixel’s", "b": [0.3986, 0.2768, 0.4488, 0.2982]}, {"w": "importance,", "b": [0.4573, 0.2768, 0.5582, 0.2982]}, {"w": "you", "b": [0.5667, 0.2768, 0.598, 0.2982]}, {"w": "get", "b": [0.6065, 0.2768, 0.6315, 0.2982]}, {"w": "the", "b": [0.64, 0.2768, 0.6663, 0.2982]}, {"w": "image", "b": [0.6749, 0.2768, 0.7253, 0.2982]}, {"w": "represented", "b": [0.7338, 0.2768, 0.8316, 0.2982]}, {"w": "in", "b": [0.8402, 0.2768, 0.8572, 0.2982]}, {"w": "Figure", "b": [0.1429, 0.2958, 0.1969, 0.3173]}, {"w": "7-6.", "b": [0.2016, 0.2958, 0.2338, 0.3173]}]}, {"id": "b_2", "type": "equation", "text": "Figure 7-6. MNIST pixel importance (according to a Random Forest classifier)", "words": [{"w": "Figure", "b": [0.1429, 0.6449, 0.1943, 0.6665]}, {"w": "7-6.", "b": [0.1991, 0.6449, 0.2308, 0.6665]}, {"w": "MNIST", "b": [0.2356, 0.6449, 0.2974, 0.6665]}, {"w": "pixel", "b": [0.3022, 0.6449, 0.3409, 0.6665]}, {"w": "importance", "b": [0.3457, 0.6449, 0.438, 0.6665]}, {"w": "(according", "b": [0.4427, 0.6449, 0.5276, 0.6665]}, {"w": "to", "b": [0.5323, 0.6449, 0.5483, 0.6665]}, {"w": "a", "b": [0.5531, 0.6449, 0.5633, 0.6665]}, {"w": "Random", "b": [0.5681, 0.6449, 0.6378, 0.6665]}, {"w": "Forest", "b": [0.6425, 0.6449, 0.691, 0.6665]}, {"w": "classifier)", "b": [0.6958, 0.6449, 0.7729, 0.6665]}]}, {"id": "b_3", "type": "paragraph", "text": "Random Forests are very handy to get a quick understanding of what features actually matter, in particular if you need to perform feature selection.", "words": [{"w": "Random", "b": [0.1429, 0.6823, 0.2154, 0.7037]}, {"w": "Forests", "b": [0.2258, 0.6823, 0.2853, 0.7037]}, {"w": "are", "b": [0.2958, 0.6823, 0.3215, 0.7037]}, {"w": "very", "b": [0.332, 0.6823, 0.3683, 0.7037]}, {"w": "handy", "b": [0.3788, 0.6823, 0.431, 0.7037]}, {"w": "to", "b": [0.4415, 0.6823, 0.4585, 0.7037]}, {"w": "get", "b": [0.4689, 0.6823, 0.4939, 0.7037]}, {"w": "a", "b": [0.5043, 0.6823, 0.5134, 0.7037]}, {"w": "quick", "b": [0.5239, 0.6823, 0.5703, 0.7037]}, {"w": "understanding", "b": [0.5808, 0.6823, 0.7031, 0.7037]}, {"w": "of", "b": [0.7135, 0.6823, 0.7303, 0.7037]}, {"w": "what", "b": [0.7408, 0.6823, 0.7813, 0.7037]}, {"w": "features", "b": [0.7917, 0.6823, 0.8571, 0.7037]}, {"w": "actually", "b": [0.1429, 0.7014, 0.2075, 0.7228]}, {"w": "matter,", "b": [0.2122, 0.7014, 0.2707, 0.7228]}, {"w": "in", "b": [0.2755, 0.7014, 0.2925, 0.7228]}, {"w": "particular", "b": [0.2972, 0.7014, 0.3789, 0.7228]}, {"w": "if", "b": [0.3837, 0.7014, 0.3954, 0.7228]}, {"w": "you", "b": [0.4001, 0.7014, 0.4314, 0.7228]}, {"w": "need", "b": [0.4361, 0.7014, 0.4762, 0.7228]}, {"w": "to", "b": [0.481, 0.7014, 0.4979, 0.7228]}, {"w": "perform", "b": [0.5027, 0.7014, 0.5717, 0.7228]}, {"w": "feature", "b": [0.5765, 0.7014, 0.6342, 0.7228]}, {"w": "selection.", "b": [0.639, 0.7014, 0.7171, 0.7228]}]}, {"id": "b_4", "type": "paragraph", "text": "Boosting", "words": [{"w": "Boosting", "b": [0.1428, 0.7358, 0.2529, 0.77]}]}, {"id": "b_5", "type": "paragraph", "text": "Boosting (originally called hypothesis boosting) refers to any Ensemble method that can combine several weak learners into a strong learner. The general idea of most boosting methods is to train predictors sequentially, each trying to correct its prede‐ cessor. There are many boosting methods available, but by far the most popular are", "words": [{"w": "Boosting", "b": [0.1429, 0.7767, 0.2124, 0.7984]}, {"w": "(originally", "b": [0.2202, 0.777, 0.3073, 0.7984]}, {"w": "called", "b": [0.3151, 0.777, 0.3635, 0.7984]}, {"w": "hypothesis", "b": [0.3713, 0.7767, 0.455, 0.7984]}, {"w": "boosting)", "b": [0.4629, 0.7767, 0.5375, 0.7984]}, {"w": "refers", "b": [0.5453, 0.777, 0.5923, 0.7984]}, {"w": "to", "b": [0.6001, 0.777, 0.6171, 0.7984]}, {"w": "any", "b": [0.6249, 0.777, 0.6545, 0.7984]}, {"w": "Ensemble", "b": [0.6624, 0.777, 0.7439, 0.7984]}, {"w": "method", "b": [0.7517, 0.777, 0.8167, 0.7984]}, {"w": "that", "b": [0.8246, 0.777, 0.8571, 0.7984]}, {"w": "can", "b": [0.1429, 0.796, 0.1722, 0.8174]}, {"w": "combine", "b": [0.1799, 0.796, 0.2528, 0.8174]}, {"w": "several", "b": [0.2605, 0.796, 0.3177, 0.8174]}, {"w": "weak", "b": [0.3254, 0.796, 0.368, 0.8174]}, {"w": "learners", "b": [0.3757, 0.796, 0.4423, 0.8174]}, {"w": "into", "b": [0.45, 0.796, 0.4836, 0.8174]}, {"w": "a", "b": [0.4913, 0.796, 0.5004, 0.8174]}, {"w": "strong", "b": [0.5081, 0.796, 0.5616, 0.8174]}, {"w": "learner.", "b": [0.5693, 0.796, 0.6317, 0.8174]}, {"w": "The", "b": [0.6394, 0.796, 0.6723, 0.8174]}, {"w": "general", "b": [0.68, 0.796, 0.741, 0.8174]}, {"w": "idea", "b": [0.7487, 0.796, 0.7833, 0.8174]}, {"w": "of", "b": [0.791, 0.796, 0.8078, 0.8174]}, {"w": "most", "b": [0.8155, 0.796, 0.8572, 0.8174]}, {"w": "boosting", "b": [0.1429, 0.815, 0.2154, 0.8365]}, {"w": "methods", "b": [0.2214, 0.815, 0.2941, 0.8365]}, {"w": "is", "b": [0.3, 0.815, 0.3133, 0.8365]}, {"w": "to", "b": [0.3193, 0.815, 0.3362, 0.8365]}, {"w": "train", "b": [0.3422, 0.815, 0.3824, 0.8365]}, {"w": "predictors", "b": [0.3884, 0.815, 0.4736, 0.8365]}, {"w": "sequentially,", "b": [0.4796, 0.815, 0.5821, 0.8365]}, {"w": "each", "b": [0.5881, 0.815, 0.626, 0.8365]}, {"w": "trying", "b": [0.632, 0.815, 0.683, 0.8365]}, {"w": "to", "b": [0.689, 0.815, 0.7059, 0.8365]}, {"w": "correct", "b": [0.7119, 0.815, 0.7708, 0.8365]}, {"w": "its", "b": [0.7768, 0.815, 0.7964, 0.8365]}, {"w": "prede‐", "b": [0.8024, 0.815, 0.8571, 0.8365]}, {"w": "cessor.", "b": [0.1429, 0.8341, 0.1976, 0.8555]}, {"w": "There", "b": [0.2041, 0.8341, 0.2535, 0.8555]}, {"w": "are", "b": [0.2601, 0.8341, 0.2858, 0.8555]}, {"w": "many", "b": [0.2923, 0.8341, 0.339, 0.8555]}, {"w": "boosting", "b": [0.3455, 0.8341, 0.4181, 0.8555]}, {"w": "methods", "b": [0.4246, 0.8341, 0.4973, 0.8555]}, {"w": "available,", "b": [0.5038, 0.8341, 0.5808, 0.8555]}, {"w": "but", "b": [0.5874, 0.8341, 0.6154, 0.8555]}, {"w": "by", "b": [0.6219, 0.8341, 0.642, 0.8555]}, {"w": "far", "b": [0.6486, 0.8341, 0.6716, 0.8555]}, {"w": "the", "b": [0.6781, 0.8341, 0.7045, 0.8555]}, {"w": "most", "b": [0.711, 0.8341, 0.7527, 0.8555]}, {"w": "popular", "b": [0.7592, 0.8341, 0.8249, 0.8555]}, {"w": "are", "b": [0.8314, 0.8341, 0.8571, 0.8555]}]}, {"id": "b_6", "type": "paragraph", "text": "Boosting | 201", "words": [{"w": "Boosting", "b": [0.7435, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "201", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 228, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "13 “A Decision-Theoretic Generalization of On-Line Learning and an Application to Boosting,” Yoav Freund, Robert E. Schapire (1997).", "words": [{"w": "13", "b": [0.1385, 0.8265, 0.1518, 0.8408]}, {"w": "“A", "b": [0.1587, 0.825, 0.1736, 0.8413]}, {"w": "Decision-Theoretic", "b": [0.1772, 0.825, 0.3007, 0.8413]}, {"w": "Generalization", "b": [0.3043, 0.825, 0.3981, 0.8413]}, {"w": "of", "b": [0.4017, 0.825, 0.4145, 0.8413]}, {"w": "On-Line", "b": [0.4181, 0.825, 0.4726, 0.8413]}, {"w": "Learning", "b": [0.4762, 0.825, 0.5333, 0.8413]}, {"w": "and", "b": [0.537, 0.825, 0.561, 0.8413]}, {"w": "an", "b": [0.5646, 0.825, 0.5802, 0.8413]}, {"w": "Application", "b": [0.5838, 0.825, 0.6583, 0.8413]}, {"w": "to", "b": [0.6619, 0.825, 0.6749, 0.8413]}, {"w": "Boosting,”", "b": [0.6785, 0.825, 0.7431, 0.8413]}, {"w": "Yoav", "b": [0.7467, 0.825, 0.777, 0.8413]}, {"w": "Freund,", "b": [0.7806, 0.825, 0.8307, 0.8413]}, {"w": "Robert", "b": [0.1587, 0.8401, 0.2022, 0.8565]}, {"w": "E.", "b": [0.2058, 0.8401, 0.2185, 0.8565]}, {"w": "Schapire", "b": [0.2221, 0.8401, 0.2767, 0.8565]}, {"w": "(1997).", "b": [0.2803, 0.8401, 0.3253, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "14 This is just for illustrative purposes. SVMs are generally not good base predictors for AdaBoost, because they are slow and tend to be unstable with AdaBoost.", "words": [{"w": "14", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "This", "b": [0.1587, 0.8598, 0.1871, 0.8761]}, {"w": "is", "b": [0.1907, 0.8598, 0.2008, 0.8761]}, {"w": "just", "b": [0.2044, 0.8598, 0.2275, 0.8761]}, {"w": "for", "b": [0.2311, 0.8598, 0.2498, 0.8761]}, {"w": "illustrative", "b": [0.2534, 0.8598, 0.3205, 0.8761]}, {"w": "purposes.", "b": [0.3241, 0.8598, 0.3852, 0.8761]}, {"w": "SVMs", "b": [0.3888, 0.8598, 0.4275, 0.8761]}, {"w": "are", "b": [0.4311, 0.8598, 0.4507, 0.8761]}, {"w": "generally", "b": [0.4543, 0.8598, 0.512, 0.8761]}, {"w": "not", "b": [0.5157, 0.8598, 0.5373, 0.8761]}, {"w": "good", "b": [0.5409, 0.8598, 0.5729, 0.8761]}, {"w": "base", "b": [0.5765, 0.8598, 0.6041, 0.8761]}, {"w": "predictors", "b": [0.6077, 0.8598, 0.6726, 0.8761]}, {"w": "for", "b": [0.6762, 0.8598, 0.6949, 0.8761]}, {"w": "AdaBoost,", "b": [0.6985, 0.8598, 0.7646, 0.8761]}, {"w": "because", "b": [0.7682, 0.8598, 0.8173, 0.8761]}, {"w": "they", "b": [0.821, 0.8598, 0.8483, 0.8761]}, {"w": "are", "b": [0.1587, 0.8749, 0.1783, 0.8912]}, {"w": "slow", "b": [0.1819, 0.8749, 0.2107, 0.8912]}, {"w": "and", "b": [0.2143, 0.8749, 0.2384, 0.8912]}, {"w": "tend", "b": [0.242, 0.8749, 0.2706, 0.8912]}, {"w": "to", "b": [0.2742, 0.8749, 0.2872, 0.8912]}, {"w": "be", "b": [0.2908, 0.8749, 0.3056, 0.8912]}, {"w": "unstable", "b": [0.3092, 0.8749, 0.3628, 0.8912]}, {"w": "with", "b": [0.3664, 0.8749, 0.3948, 0.8912]}, {"w": "AdaBoost.", "b": [0.3984, 0.8749, 0.4644, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "AdaBoost13 (short for Adaptive Boosting) and Gradient Boosting. Let’s start with Ada‐ Boost.", "words": [{"w": "AdaBoost13", "b": [0.1429, 0.0789, 0.2335, 0.1005]}, {"w": "(short", "b": [0.2397, 0.0791, 0.2904, 0.1005]}, {"w": "for", "b": [0.2966, 0.0791, 0.3211, 0.1005]}, {"w": "Adaptive", "b": [0.3273, 0.0789, 0.4006, 0.1005]}, {"w": "Boosting)", "b": [0.4068, 0.0789, 0.4835, 0.1005]}, {"w": "and", "b": [0.4897, 0.0791, 0.5212, 0.1005]}, {"w": "Gradient", "b": [0.5274, 0.0789, 0.5999, 0.1005]}, {"w": "Boosting.", "b": [0.6061, 0.0789, 0.6803, 0.1005]}, {"w": "Let’s", "b": [0.6865, 0.0791, 0.7227, 0.1005]}, {"w": "start", "b": [0.7288, 0.0791, 0.7661, 0.1005]}, {"w": "with", "b": [0.7722, 0.0791, 0.8096, 0.1005]}, {"w": "Ada‐", "b": [0.8157, 0.0791, 0.8571, 0.1005]}, {"w": "Boost.", "b": [0.1429, 0.0981, 0.1955, 0.1195]}]}, {"id": "b_3", "type": "paragraph", "text": "AdaBoost", "words": [{"w": "AdaBoost", "b": [0.1429, 0.1323, 0.241, 0.1609]}]}, {"id": "b_4", "type": "paragraph", "text": "One way for a new predictor to correct its predecessor is to pay a bit more attention to the training instances that the predecessor underfitted. This results in new predic‐ tors focusing more and more on the hard cases. This is the technique used by Ada‐ Boost.", "words": [{"w": "One", "b": [0.1429, 0.1668, 0.1787, 0.1882]}, {"w": "way", "b": [0.1846, 0.1668, 0.2172, 0.1882]}, {"w": "for", "b": [0.2232, 0.1668, 0.2477, 0.1882]}, {"w": "a", "b": [0.2537, 0.1668, 0.2628, 0.1882]}, {"w": "new", "b": [0.2688, 0.1668, 0.3033, 0.1882]}, {"w": "predictor", "b": [0.3092, 0.1668, 0.3868, 0.1882]}, {"w": "to", "b": [0.3928, 0.1668, 0.4098, 0.1882]}, {"w": "correct", "b": [0.4157, 0.1668, 0.4746, 0.1882]}, {"w": "its", "b": [0.4806, 0.1668, 0.5002, 0.1882]}, {"w": "predecessor", "b": [0.5061, 0.1668, 0.6048, 0.1882]}, {"w": "is", "b": [0.6108, 0.1668, 0.624, 0.1882]}, {"w": "to", "b": [0.6299, 0.1668, 0.6469, 0.1882]}, {"w": "pay", "b": [0.6529, 0.1668, 0.6821, 0.1882]}, {"w": "a", "b": [0.6881, 0.1668, 0.6972, 0.1882]}, {"w": "bit", "b": [0.7032, 0.1668, 0.7257, 0.1882]}, {"w": "more", "b": [0.7317, 0.1668, 0.7759, 0.1882]}, {"w": "attention", "b": [0.7819, 0.1668, 0.8571, 0.1882]}, {"w": "to", "b": [0.1429, 0.1858, 0.1598, 0.2072]}, {"w": "the", "b": [0.1654, 0.1858, 0.1917, 0.2072]}, {"w": "training", "b": [0.1973, 0.1858, 0.2643, 0.2072]}, {"w": "instances", "b": [0.2698, 0.1858, 0.3467, 0.2072]}, {"w": "that", "b": [0.3522, 0.1858, 0.3848, 0.2072]}, {"w": "the", "b": [0.3904, 0.1858, 0.4167, 0.2072]}, {"w": "predecessor", "b": [0.4223, 0.1858, 0.521, 0.2072]}, {"w": "underfitted.", "b": [0.5266, 0.1858, 0.6257, 0.2072]}, {"w": "This", "b": [0.6312, 0.1858, 0.6685, 0.2072]}, {"w": "results", "b": [0.674, 0.1858, 0.7286, 0.2072]}, {"w": "in", "b": [0.7342, 0.1858, 0.7512, 0.2072]}, {"w": "new", "b": [0.7567, 0.1858, 0.7913, 0.2072]}, {"w": "predic‐", "b": [0.7968, 0.1858, 0.8571, 0.2072]}, {"w": "tors", "b": [0.1428, 0.2048, 0.1752, 0.2263]}, {"w": "focusing", "b": [0.1817, 0.2048, 0.2527, 0.2263]}, {"w": "more", "b": [0.2592, 0.2048, 0.3035, 0.2263]}, {"w": "and", "b": [0.3099, 0.2048, 0.3415, 0.2263]}, {"w": "more", "b": [0.3479, 0.2048, 0.3922, 0.2263]}, {"w": "on", "b": [0.3987, 0.2048, 0.4207, 0.2263]}, {"w": "the", "b": [0.4272, 0.2048, 0.4535, 0.2263]}, {"w": "hard", "b": [0.46, 0.2048, 0.499, 0.2263]}, {"w": "cases.", "b": [0.5054, 0.2048, 0.5523, 0.2263]}, {"w": "This", "b": [0.5587, 0.2048, 0.596, 0.2263]}, {"w": "is", "b": [0.6024, 0.2048, 0.6157, 0.2263]}, {"w": "the", "b": [0.6221, 0.2048, 0.6485, 0.2263]}, {"w": "technique", "b": [0.6549, 0.2048, 0.7376, 0.2263]}, {"w": "used", "b": [0.7441, 0.2048, 0.7826, 0.2263]}, {"w": "by", "b": [0.7891, 0.2048, 0.8093, 0.2263]}, {"w": "Ada‐", "b": [0.8157, 0.2048, 0.8571, 0.2263]}, {"w": "Boost.", "b": [0.1429, 0.2239, 0.1955, 0.2453]}]}, {"id": "b_5", "type": "paragraph", "text": "For example, to build an AdaBoost classifier, a first base classifier (such as a Decision Tree) is trained and used to make predictions on the training set. The relative weight of misclassified training instances is then increased. A second classifier is trained using the updated weights and again it makes predictions on the training set, weights are updated, and so on (see Figure 7-7).", "words": [{"w": "For", "b": [0.1429, 0.252, 0.1718, 0.2734]}, {"w": "example,", "b": [0.1772, 0.252, 0.2515, 0.2734]}, {"w": "to", "b": [0.2569, 0.252, 0.2739, 0.2734]}, {"w": "build", "b": [0.2793, 0.252, 0.3228, 0.2734]}, {"w": "an", "b": [0.3281, 0.252, 0.3487, 0.2734]}, {"w": "AdaBoost", "b": [0.3541, 0.252, 0.436, 0.2734]}, {"w": "classifier,", "b": [0.4413, 0.252, 0.5172, 0.2734]}, {"w": "a", "b": [0.5226, 0.252, 0.5317, 0.2734]}, {"w": "first", "b": [0.5371, 0.252, 0.5706, 0.2734]}, {"w": "base", "b": [0.576, 0.252, 0.6122, 0.2734]}, {"w": "classifier", "b": [0.6176, 0.252, 0.69, 0.2734]}, {"w": "(such", "b": [0.6954, 0.252, 0.7413, 0.2734]}, {"w": "as", "b": [0.7466, 0.252, 0.7634, 0.2734]}, {"w": "a", "b": [0.7688, 0.252, 0.778, 0.2734]}, {"w": "Decision", "b": [0.7833, 0.252, 0.8571, 0.2734]}, {"w": "Tree)", "b": [0.1429, 0.2711, 0.1866, 0.2925]}, {"w": "is", "b": [0.1922, 0.2711, 0.2054, 0.2925]}, {"w": "trained", "b": [0.211, 0.2711, 0.2711, 0.2925]}, {"w": "and", "b": [0.2766, 0.2711, 0.3082, 0.2925]}, {"w": "used", "b": [0.3137, 0.2711, 0.3523, 0.2925]}, {"w": "to", "b": [0.3579, 0.2711, 0.3748, 0.2925]}, {"w": "make", "b": [0.3804, 0.2711, 0.4258, 0.2925]}, {"w": "predictions", "b": [0.4314, 0.2711, 0.5259, 0.2925]}, {"w": "on", "b": [0.5314, 0.2711, 0.5535, 0.2925]}, {"w": "the", "b": [0.559, 0.2711, 0.5854, 0.2925]}, {"w": "training", "b": [0.5909, 0.2711, 0.6579, 0.2925]}, {"w": "set.", "b": [0.6634, 0.2711, 0.691, 0.2925]}, {"w": "The", "b": [0.6966, 0.2711, 0.7294, 0.2925]}, {"w": "relative", "b": [0.735, 0.2711, 0.796, 0.2925]}, {"w": "weight", "b": [0.8016, 0.2711, 0.8571, 0.2925]}, {"w": "of", "b": [0.1429, 0.2901, 0.1596, 0.3115]}, {"w": "misclassified", "b": [0.1682, 0.2901, 0.2742, 0.3115]}, {"w": "training", "b": [0.2828, 0.2901, 0.3498, 0.3115]}, {"w": "instances", "b": [0.3584, 0.2901, 0.4352, 0.3115]}, {"w": "is", "b": [0.4438, 0.2901, 0.457, 0.3115]}, {"w": "then", "b": [0.4656, 0.2901, 0.5033, 0.3115]}, {"w": "increased.", "b": [0.5119, 0.2901, 0.5957, 0.3115]}, {"w": "A", "b": [0.6043, 0.2901, 0.6187, 0.3115]}, {"w": "second", "b": [0.6273, 0.2901, 0.6856, 0.3115]}, {"w": "classifier", "b": [0.6942, 0.2901, 0.7667, 0.3115]}, {"w": "is", "b": [0.7753, 0.2901, 0.7885, 0.3115]}, {"w": "trained", "b": [0.7971, 0.2901, 0.8571, 0.3115]}, {"w": "using", "b": [0.1429, 0.3092, 0.1883, 0.3306]}, {"w": "the", "b": [0.1936, 0.3092, 0.22, 0.3306]}, {"w": "updated", "b": [0.2253, 0.3092, 0.2932, 0.3306]}, {"w": "weights", "b": [0.2986, 0.3092, 0.3617, 0.3306]}, {"w": "and", "b": [0.3671, 0.3092, 0.3986, 0.3306]}, {"w": "again", "b": [0.4039, 0.3092, 0.449, 0.3306]}, {"w": "it", "b": [0.4543, 0.3092, 0.4662, 0.3306]}, {"w": "makes", "b": [0.4716, 0.3092, 0.5246, 0.3306]}, {"w": "predictions", "b": [0.5299, 0.3092, 0.6244, 0.3306]}, {"w": "on", "b": [0.6298, 0.3092, 0.6518, 0.3306]}, {"w": "the", "b": [0.6571, 0.3092, 0.6834, 0.3306]}, {"w": "training", "b": [0.6888, 0.3092, 0.7557, 0.3306]}, {"w": "set,", "b": [0.761, 0.3092, 0.7886, 0.3306]}, {"w": "weights", "b": [0.794, 0.3092, 0.8572, 0.3306]}, {"w": "are", "b": [0.1429, 0.3282, 0.1686, 0.3496]}, {"w": "updated,", "b": [0.1733, 0.3282, 0.246, 0.3496]}, {"w": "and", "b": [0.2507, 0.3282, 0.2823, 0.3496]}, {"w": "so", "b": [0.287, 0.3282, 0.3053, 0.3496]}, {"w": "on", "b": [0.31, 0.3282, 0.332, 0.3496]}, {"w": "(see", "b": [0.3368, 0.3282, 0.3693, 0.3496]}, {"w": "Figure", "b": [0.374, 0.3282, 0.428, 0.3496]}, {"w": "7-7).", "b": [0.4328, 0.3282, 0.4722, 0.3496]}]}, {"id": "b_6", "type": "equation", "text": "Figure 7-7. AdaBoost sequential training with instance weight updates", "words": [{"w": "Figure", "b": [0.1429, 0.6841, 0.1943, 0.7057]}, {"w": "7-7.", "b": [0.1991, 0.6841, 0.2308, 0.7057]}, {"w": "AdaBoost", "b": [0.2356, 0.6841, 0.3148, 0.7057]}, {"w": "sequential", "b": [0.3196, 0.6841, 0.4016, 0.7057]}, {"w": "training", "b": [0.4064, 0.6841, 0.4708, 0.7057]}, {"w": "with", "b": [0.4756, 0.6841, 0.5121, 0.7057]}, {"w": "instance", "b": [0.5168, 0.6841, 0.5833, 0.7057]}, {"w": "weight", "b": [0.5881, 0.6841, 0.6411, 0.7057]}, {"w": "updates", "b": [0.6459, 0.6841, 0.7084, 0.7057]}]}, {"id": "b_7", "type": "paragraph", "text": "Figure 7-8 shows the decision boundaries of five consecutive predictors on the moons dataset (in this example, each predictor is a highly regularized SVM classifier with an RBF kernel14). The first classifier gets many instances wrong, so their weights", "words": [{"w": "Figure", "b": [0.1429, 0.7215, 0.1969, 0.7429]}, {"w": "7-8", "b": [0.2072, 0.7215, 0.2346, 0.7429]}, {"w": "shows", "b": [0.245, 0.7215, 0.2963, 0.7429]}, {"w": "the", "b": [0.3066, 0.7215, 0.333, 0.7429]}, {"w": "decision", "b": [0.3433, 0.7215, 0.4128, 0.7429]}, {"w": "boundaries", "b": [0.4232, 0.7215, 0.5168, 0.7429]}, {"w": "of", "b": [0.5271, 0.7215, 0.5439, 0.7429]}, {"w": "five", "b": [0.5543, 0.7215, 0.5845, 0.7429]}, {"w": "consecutive", "b": [0.5949, 0.7215, 0.6925, 0.7429]}, {"w": "predictors", "b": [0.7029, 0.7215, 0.7881, 0.7429]}, {"w": "on", "b": [0.7984, 0.7215, 0.8205, 0.7429]}, {"w": "the", "b": [0.8308, 0.7215, 0.8571, 0.7429]}, {"w": "moons", "b": [0.1429, 0.7405, 0.2002, 0.7619]}, {"w": "dataset", "b": [0.206, 0.7405, 0.2642, 0.7619]}, {"w": "(in", "b": [0.27, 0.7405, 0.2942, 0.7619]}, {"w": "this", "b": [0.3, 0.7405, 0.3307, 0.7619]}, {"w": "example,", "b": [0.3366, 0.7405, 0.4109, 0.7619]}, {"w": "each", "b": [0.4167, 0.7405, 0.4546, 0.7619]}, {"w": "predictor", "b": [0.4605, 0.7405, 0.5381, 0.7619]}, {"w": "is", "b": [0.5439, 0.7405, 0.5571, 0.7619]}, {"w": "a", "b": [0.563, 0.7405, 0.5721, 0.7619]}, {"w": "highly", "b": [0.578, 0.7405, 0.6304, 0.7619]}, {"w": "regularized", "b": [0.6362, 0.7405, 0.7299, 0.7619]}, {"w": "SVM", "b": [0.7358, 0.7405, 0.7789, 0.7619]}, {"w": "classifier", "b": [0.7847, 0.7405, 0.8571, 0.7619]}, {"w": "with", "b": [0.1428, 0.7596, 0.1802, 0.781]}, {"w": "an", "b": [0.1856, 0.7596, 0.2061, 0.781]}, {"w": "RBF", "b": [0.2115, 0.7596, 0.2477, 0.781]}, {"w": "kernel14).", "b": [0.2531, 0.7596, 0.3289, 0.781]}, {"w": "The", "b": [0.3343, 0.7596, 0.3671, 0.781]}, {"w": "first", "b": [0.3725, 0.7596, 0.406, 0.781]}, {"w": "classifier", "b": [0.4113, 0.7596, 0.4838, 0.781]}, {"w": "gets", "b": [0.4891, 0.7596, 0.5217, 0.781]}, {"w": "many", "b": [0.5271, 0.7596, 0.5738, 0.781]}, {"w": "instances", "b": [0.5792, 0.7596, 0.656, 0.781]}, {"w": "wrong,", "b": [0.6614, 0.7596, 0.7199, 0.781]}, {"w": "so", "b": [0.7253, 0.7596, 0.7436, 0.781]}, {"w": "their", "b": [0.7489, 0.7596, 0.7886, 0.781]}, {"w": "weights", "b": [0.794, 0.7596, 0.8571, 0.781]}]}, {"id": "b_8", "type": "paragraph", "text": "202 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "202", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 229, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "get boosted. The second classifier therefore does a better job on these instances, and so on. The plot on the right represents the same sequence of predictors except that the learning rate is halved (i.e., the misclassified instance weights are boosted half as much at every iteration). As you can see, this sequential learning technique has some similarities with Gradient Descent, except that instead of tweaking a single predictor’s parameters to minimize a cost function, AdaBoost adds predictors to the ensemble, gradually making it better.", "words": [{"w": "get", "b": [0.1429, 0.0791, 0.1678, 0.1005]}, {"w": "boosted.", "b": [0.1739, 0.0791, 0.2443, 0.1005]}, {"w": "The", "b": [0.2503, 0.0791, 0.2832, 0.1005]}, {"w": "second", "b": [0.2892, 0.0791, 0.3475, 0.1005]}, {"w": "classifier", "b": [0.3536, 0.0791, 0.426, 0.1005]}, {"w": "therefore", "b": [0.432, 0.0791, 0.5083, 0.1005]}, {"w": "does", "b": [0.5144, 0.0791, 0.5525, 0.1005]}, {"w": "a", "b": [0.5585, 0.0791, 0.5677, 0.1005]}, {"w": "better", "b": [0.5737, 0.0791, 0.6224, 0.1005]}, {"w": "job", "b": [0.6285, 0.0791, 0.655, 0.1005]}, {"w": "on", "b": [0.6611, 0.0791, 0.6831, 0.1005]}, {"w": "these", "b": [0.6891, 0.0791, 0.7319, 0.1005]}, {"w": "instances,", "b": [0.738, 0.0791, 0.8196, 0.1005]}, {"w": "and", "b": [0.8256, 0.0791, 0.8571, 0.1005]}, {"w": "so", "b": [0.1429, 0.0981, 0.1611, 0.1195]}, {"w": "on.", "b": [0.168, 0.0981, 0.1947, 0.1195]}, {"w": "The", "b": [0.2016, 0.0981, 0.2344, 0.1195]}, {"w": "plot", "b": [0.2412, 0.0981, 0.2744, 0.1195]}, {"w": "on", "b": [0.2812, 0.0981, 0.3033, 0.1195]}, {"w": "the", "b": [0.3101, 0.0981, 0.3364, 0.1195]}, {"w": "right", "b": [0.3433, 0.0981, 0.3834, 0.1195]}, {"w": "represents", "b": [0.3903, 0.0981, 0.4758, 0.1195]}, {"w": "the", "b": [0.4827, 0.0981, 0.509, 0.1195]}, {"w": "same", "b": [0.5159, 0.0981, 0.5586, 0.1195]}, {"w": "sequence", "b": [0.5654, 0.0981, 0.6415, 0.1195]}, {"w": "of", "b": [0.6484, 0.0981, 0.6652, 0.1195]}, {"w": "predictors", "b": [0.672, 0.0981, 0.7573, 0.1195]}, {"w": "except", "b": [0.7641, 0.0981, 0.8177, 0.1195]}, {"w": "that", "b": [0.8246, 0.0981, 0.8571, 0.1195]}, {"w": "the", "b": [0.1429, 0.1172, 0.1692, 0.1386]}, {"w": "learning", "b": [0.1752, 0.1172, 0.2444, 0.1386]}, {"w": "rate", "b": [0.2504, 0.1172, 0.2821, 0.1386]}, {"w": "is", "b": [0.2881, 0.1172, 0.3013, 0.1386]}, {"w": "halved", "b": [0.3073, 0.1172, 0.3624, 0.1386]}, {"w": "(i.e.,", "b": [0.3684, 0.1172, 0.4043, 0.1386]}, {"w": "the", "b": [0.4103, 0.1172, 0.4367, 0.1386]}, {"w": "misclassified", "b": [0.4427, 0.1172, 0.5487, 0.1386]}, {"w": "instance", "b": [0.5547, 0.1172, 0.6239, 0.1386]}, {"w": "weights", "b": [0.6299, 0.1172, 0.6931, 0.1386]}, {"w": "are", "b": [0.6992, 0.1172, 0.7249, 0.1386]}, {"w": "boosted", "b": [0.7309, 0.1172, 0.7966, 0.1386]}, {"w": "half", "b": [0.8026, 0.1172, 0.8343, 0.1386]}, {"w": "as", "b": [0.8404, 0.1172, 0.8572, 0.1386]}, {"w": "much", "b": [0.1429, 0.1362, 0.1905, 0.1576]}, {"w": "at", "b": [0.196, 0.1362, 0.2111, 0.1576]}, {"w": "every", "b": [0.2166, 0.1362, 0.2618, 0.1576]}, {"w": "iteration).", "b": [0.2673, 0.1362, 0.3505, 0.1576]}, {"w": "As", "b": [0.356, 0.1362, 0.378, 0.1576]}, {"w": "you", "b": [0.3835, 0.1362, 0.4148, 0.1576]}, {"w": "can", "b": [0.4203, 0.1362, 0.4496, 0.1576]}, {"w": "see,", "b": [0.4551, 0.1362, 0.4852, 0.1576]}, {"w": "this", "b": [0.4907, 0.1362, 0.5214, 0.1576]}, {"w": "sequential", "b": [0.5269, 0.1362, 0.6113, 0.1576]}, {"w": "learning", "b": [0.6168, 0.1362, 0.6859, 0.1576]}, {"w": "technique", "b": [0.6914, 0.1362, 0.7741, 0.1576]}, {"w": "has", "b": [0.7796, 0.1362, 0.8075, 0.1576]}, {"w": "some", "b": [0.813, 0.1362, 0.8571, 0.1576]}, {"w": "similarities", "b": [0.1429, 0.1553, 0.2349, 0.1767]}, {"w": "with", "b": [0.2399, 0.1553, 0.2772, 0.1767]}, {"w": "Gradient", "b": [0.2821, 0.1553, 0.3567, 0.1767]}, {"w": "Descent,", "b": [0.3617, 0.1553, 0.4332, 0.1767]}, {"w": "except", "b": [0.4382, 0.1553, 0.4918, 0.1767]}, {"w": "that", "b": [0.4968, 0.1553, 0.5294, 0.1767]}, {"w": "instead", "b": [0.5343, 0.1553, 0.5943, 0.1767]}, {"w": "of", "b": [0.5993, 0.1553, 0.6161, 0.1767]}, {"w": "tweaking", "b": [0.621, 0.1553, 0.6967, 0.1767]}, {"w": "a", "b": [0.7017, 0.1553, 0.7108, 0.1767]}, {"w": "single", "b": [0.7158, 0.1553, 0.7643, 0.1767]}, {"w": "predictor’s", "b": [0.7692, 0.1553, 0.8571, 0.1767]}, {"w": "parameters", "b": [0.1428, 0.1743, 0.2363, 0.1957]}, {"w": "to", "b": [0.2429, 0.1743, 0.2599, 0.1957]}, {"w": "minimize", "b": [0.2665, 0.1743, 0.3464, 0.1957]}, {"w": "a", "b": [0.353, 0.1743, 0.3621, 0.1957]}, {"w": "cost", "b": [0.3687, 0.1743, 0.4022, 0.1957]}, {"w": "function,", "b": [0.4088, 0.1743, 0.4849, 0.1957]}, {"w": "AdaBoost", "b": [0.4915, 0.1743, 0.5735, 0.1957]}, {"w": "adds", "b": [0.5801, 0.1743, 0.6189, 0.1957]}, {"w": "predictors", "b": [0.6255, 0.1743, 0.7107, 0.1957]}, {"w": "to", "b": [0.7173, 0.1743, 0.7343, 0.1957]}, {"w": "the", "b": [0.7409, 0.1743, 0.7673, 0.1957]}, {"w": "ensemble,", "b": [0.7739, 0.1743, 0.8571, 0.1957]}, {"w": "gradually", "b": [0.1429, 0.1933, 0.2208, 0.2148]}, {"w": "making", "b": [0.2255, 0.1933, 0.2888, 0.2148]}, {"w": "it", "b": [0.2935, 0.1933, 0.3055, 0.2148]}, {"w": "better.", "b": [0.3102, 0.1933, 0.3624, 0.2148]}]}, {"id": "b_1", "type": "equation", "text": "Figure 7-8. Decision boundaries of consecutive predictors", "words": [{"w": "Figure", "b": [0.1429, 0.4215, 0.1943, 0.4432]}, {"w": "7-8.", "b": [0.1991, 0.4215, 0.2308, 0.4432]}, {"w": "Decision", "b": [0.2356, 0.4215, 0.3055, 0.4432]}, {"w": "boundaries", "b": [0.3103, 0.4215, 0.4006, 0.4432]}, {"w": "of", "b": [0.4054, 0.4215, 0.4206, 0.4432]}, {"w": "consecutive", "b": [0.4254, 0.4215, 0.5171, 0.4432]}, {"w": "predictors", "b": [0.5218, 0.4215, 0.6015, 0.4432]}]}, {"id": "b_2", "type": "paragraph", "text": "Once all predictors are trained, the ensemble makes predictions very much like bag‐ ging or pasting, except that predictors have different weights depending on their overall accuracy on the weighted training set.", "words": [{"w": "Once", "b": [0.1429, 0.4589, 0.1875, 0.4804]}, {"w": "all", "b": [0.1934, 0.4589, 0.2131, 0.4804]}, {"w": "predictors", "b": [0.219, 0.4589, 0.3042, 0.4804]}, {"w": "are", "b": [0.3101, 0.4589, 0.3359, 0.4804]}, {"w": "trained,", "b": [0.3418, 0.4589, 0.4066, 0.4804]}, {"w": "the", "b": [0.4125, 0.4589, 0.4388, 0.4804]}, {"w": "ensemble", "b": [0.4447, 0.4589, 0.5232, 0.4804]}, {"w": "makes", "b": [0.5291, 0.4589, 0.5822, 0.4804]}, {"w": "predictions", "b": [0.5881, 0.4589, 0.6826, 0.4804]}, {"w": "very", "b": [0.6885, 0.4589, 0.7248, 0.4804]}, {"w": "much", "b": [0.7307, 0.4589, 0.7784, 0.4804]}, {"w": "like", "b": [0.7843, 0.4589, 0.8144, 0.4804]}, {"w": "bag‐", "b": [0.8203, 0.4589, 0.8571, 0.4804]}, {"w": "ging", "b": [0.1429, 0.478, 0.1793, 0.4994]}, {"w": "or", "b": [0.1883, 0.478, 0.2067, 0.4994]}, {"w": "pasting,", "b": [0.2156, 0.478, 0.2812, 0.4994]}, {"w": "except", "b": [0.2902, 0.478, 0.3438, 0.4994]}, {"w": "that", "b": [0.3528, 0.478, 0.3853, 0.4994]}, {"w": "predictors", "b": [0.3943, 0.478, 0.4796, 0.4994]}, {"w": "have", "b": [0.4886, 0.478, 0.5269, 0.4994]}, {"w": "different", "b": [0.5359, 0.478, 0.6076, 0.4994]}, {"w": "weights", "b": [0.6166, 0.478, 0.6798, 0.4994]}, {"w": "depending", "b": [0.6888, 0.478, 0.7775, 0.4994]}, {"w": "on", "b": [0.7865, 0.478, 0.8085, 0.4994]}, {"w": "their", "b": [0.8175, 0.478, 0.8571, 0.4994]}, {"w": "overall", "b": [0.1429, 0.497, 0.1994, 0.5185]}, {"w": "accuracy", "b": [0.2041, 0.497, 0.2772, 0.5185]}, {"w": "on", "b": [0.2819, 0.497, 0.304, 0.5185]}, {"w": "the", "b": [0.3087, 0.497, 0.335, 0.5185]}, {"w": "weighted", "b": [0.3397, 0.497, 0.4151, 0.5185]}, {"w": "training", "b": [0.4199, 0.497, 0.4868, 0.5185]}, {"w": "set.", "b": [0.4915, 0.497, 0.5191, 0.5185]}]}, {"id": "b_3", "type": "paragraph", "text": "There is one important drawback to this sequential learning techni‐ que: it cannot be parallelized (or only partially), since each predic‐ tor can only be trained after the previous predictor has been trained and evaluated. As a result, it does not scale as well as bag‐ ging or pasting.", "words": [{"w": "There", "b": [0.2714, 0.539, 0.3166, 0.5586]}, {"w": "is", "b": [0.3209, 0.539, 0.333, 0.5586]}, {"w": "one", "b": [0.3373, 0.539, 0.3656, 0.5586]}, {"w": "important", "b": [0.3699, 0.539, 0.447, 0.5586]}, {"w": "drawback", "b": [0.4514, 0.539, 0.5251, 0.5586]}, {"w": "to", "b": [0.5294, 0.539, 0.5449, 0.5586]}, {"w": "this", "b": [0.5493, 0.539, 0.5773, 0.5586]}, {"w": "sequential", "b": [0.5817, 0.539, 0.6588, 0.5586]}, {"w": "learning", "b": [0.6632, 0.539, 0.7264, 0.5586]}, {"w": "techni‐", "b": [0.7307, 0.539, 0.7851, 0.5586]}, {"w": "que:", "b": [0.2714, 0.5564, 0.3037, 0.576]}, {"w": "it", "b": [0.309, 0.5564, 0.32, 0.576]}, {"w": "cannot", "b": [0.3253, 0.5564, 0.3781, 0.576]}, {"w": "be", "b": [0.3834, 0.5564, 0.4012, 0.576]}, {"w": "parallelized", "b": [0.4065, 0.5564, 0.4941, 0.576]}, {"w": "(or", "b": [0.4994, 0.5564, 0.5228, 0.576]}, {"w": "only", "b": [0.5282, 0.5564, 0.5619, 0.576]}, {"w": "partially),", "b": [0.5672, 0.5564, 0.6412, 0.576]}, {"w": "since", "b": [0.6465, 0.5564, 0.6852, 0.576]}, {"w": "each", "b": [0.6905, 0.5564, 0.7252, 0.576]}, {"w": "predic‐", "b": [0.7306, 0.5564, 0.7857, 0.576]}, {"w": "tor", "b": [0.2714, 0.5738, 0.294, 0.5934]}, {"w": "can", "b": [0.3041, 0.5738, 0.3309, 0.5934]}, {"w": "only", "b": [0.341, 0.5738, 0.3747, 0.5934]}, {"w": "be", "b": [0.3848, 0.5738, 0.4025, 0.5934]}, {"w": "trained", "b": [0.4126, 0.5738, 0.4675, 0.5934]}, {"w": "after", "b": [0.4776, 0.5738, 0.5126, 0.5934]}, {"w": "the", "b": [0.5227, 0.5738, 0.5467, 0.5934]}, {"w": "previous", "b": [0.5568, 0.5738, 0.6227, 0.5934]}, {"w": "predictor", "b": [0.6328, 0.5738, 0.7037, 0.5934]}, {"w": "has", "b": [0.7138, 0.5738, 0.7393, 0.5934]}, {"w": "been", "b": [0.7494, 0.5738, 0.7857, 0.5934]}, {"w": "trained", "b": [0.2714, 0.5912, 0.3263, 0.6108]}, {"w": "and", "b": [0.3321, 0.5912, 0.3609, 0.6108]}, {"w": "evaluated.", "b": [0.3667, 0.5912, 0.4432, 0.6108]}, {"w": "As", "b": [0.449, 0.5912, 0.4691, 0.6108]}, {"w": "a", "b": [0.4749, 0.5912, 0.4833, 0.6108]}, {"w": "result,", "b": [0.489, 0.5912, 0.5363, 0.6108]}, {"w": "it", "b": [0.5421, 0.5912, 0.553, 0.6108]}, {"w": "does", "b": [0.5587, 0.5912, 0.5936, 0.6108]}, {"w": "not", "b": [0.5994, 0.5912, 0.6253, 0.6108]}, {"w": "scale", "b": [0.6311, 0.5912, 0.6674, 0.6108]}, {"w": "as", "b": [0.6732, 0.5912, 0.6885, 0.6108]}, {"w": "well", "b": [0.6943, 0.5912, 0.7251, 0.6108]}, {"w": "as", "b": [0.7309, 0.5912, 0.7462, 0.6108]}, {"w": "bag‐", "b": [0.752, 0.5912, 0.7857, 0.6108]}, {"w": "ging", "b": [0.2714, 0.6086, 0.3048, 0.6282]}, {"w": "or", "b": [0.3091, 0.6086, 0.3259, 0.6282]}, {"w": "pasting.", "b": [0.3302, 0.6086, 0.3901, 0.6282]}]}, {"id": "b_4", "type": "paragraph", "text": "Let’s take a closer look at the AdaBoost algorithm. Each instance weight w(i) is initially set to 1", "words": [{"w": "Let’s", "b": [0.1429, 0.6485, 0.179, 0.6699]}, {"w": "take", "b": [0.184, 0.6485, 0.2187, 0.6699]}, {"w": "a", "b": [0.2236, 0.6485, 0.2328, 0.6699]}, {"w": "closer", "b": [0.2377, 0.6485, 0.2867, 0.6699]}, {"w": "look", "b": [0.2916, 0.6485, 0.3285, 0.6699]}, {"w": "at", "b": [0.3334, 0.6485, 0.3485, 0.6699]}, {"w": "the", "b": [0.3535, 0.6485, 0.3798, 0.6699]}, {"w": "AdaBoost", "b": [0.3848, 0.6485, 0.4667, 0.6699]}, {"w": "algorithm.", "b": [0.4716, 0.6485, 0.559, 0.6699]}, {"w": "Each", "b": [0.564, 0.6485, 0.6049, 0.6699]}, {"w": "instance", "b": [0.6099, 0.6485, 0.6791, 0.6699]}, {"w": "weight", "b": [0.684, 0.6485, 0.7396, 0.6699]}, {"w": "w(i)", "b": [0.7445, 0.6483, 0.7703, 0.6699]}, {"w": "is", "b": [0.7752, 0.6485, 0.7884, 0.6699]}, {"w": "initially", "b": [0.7932, 0.6485, 0.8569, 0.6699]}, {"w": "set", "b": [0.1429, 0.6715, 0.1657, 0.6929]}, {"w": "to", "b": [0.1712, 0.6715, 0.1882, 0.6929]}, {"w": "1", "b": [0.1984, 0.667, 0.206, 0.6833]}]}, {"id": "b_5", "type": "paragraph", "text": "m. A first predictor is trained and its weighted error rate r1 is computed on the training set; see Equation 7-1.", "words": [{"w": "m.", "b": [0.196, 0.6715, 0.2156, 0.698]}, {"w": "A", "b": [0.2211, 0.6715, 0.2355, 0.6929]}, {"w": "first", "b": [0.241, 0.6715, 0.2744, 0.6929]}, {"w": "predictor", "b": [0.2799, 0.6715, 0.3575, 0.6929]}, {"w": "is", "b": [0.363, 0.6715, 0.3763, 0.6929]}, {"w": "trained", "b": [0.3818, 0.6715, 0.4418, 0.6929]}, {"w": "and", "b": [0.4473, 0.6715, 0.4789, 0.6929]}, {"w": "its", "b": [0.4843, 0.6715, 0.5039, 0.6929]}, {"w": "weighted", "b": [0.5094, 0.6715, 0.5848, 0.6929]}, {"w": "error", "b": [0.5903, 0.6715, 0.633, 0.6929]}, {"w": "rate", "b": [0.6385, 0.6715, 0.6702, 0.6929]}, {"w": "r1", "b": [0.6757, 0.6712, 0.6893, 0.6938]}, {"w": "is", "b": [0.6948, 0.6715, 0.708, 0.6929]}, {"w": "computed", "b": [0.7135, 0.6715, 0.7978, 0.6929]}, {"w": "on", "b": [0.8033, 0.6715, 0.8253, 0.6929]}, {"w": "the", "b": [0.8308, 0.6715, 0.8571, 0.6929]}, {"w": "training", "b": [0.1428, 0.6944, 0.2098, 0.7158]}, {"w": "set;", "b": [0.2145, 0.6944, 0.2421, 0.7158]}, {"w": "see", "b": [0.2468, 0.6944, 0.2722, 0.7158]}, {"w": "Equation", "b": [0.2769, 0.6944, 0.3532, 0.7158]}, {"w": "7-1.", "b": [0.3579, 0.6944, 0.3901, 0.7158]}]}, {"id": "b_6", "type": "equation", "text": "Equation 7-1. Weighted error rate of the jth predictor", "words": [{"w": "Equation", "b": [0.1726, 0.7339, 0.2473, 0.7555]}, {"w": "7-1.", "b": [0.2521, 0.7339, 0.2838, 0.7555]}, {"w": "Weighted", "b": [0.2886, 0.7339, 0.3641, 0.7555]}, {"w": "error", "b": [0.3689, 0.7339, 0.4095, 0.7555]}, {"w": "rate", "b": [0.4142, 0.7339, 0.4457, 0.7555]}, {"w": "of", "b": [0.4505, 0.7339, 0.4657, 0.7555]}, {"w": "the", "b": [0.4705, 0.7339, 0.4955, 0.7555]}, {"w": "jth", "b": [0.5003, 0.7339, 0.516, 0.7555]}, {"w": "predictor", "b": [0.5207, 0.7339, 0.5934, 0.7555]}]}, {"id": "b_7", "type": "equation", "text": "rj =", "words": [{"w": "rj", "b": [0.1726, 0.8194, 0.1861, 0.8442]}, {"w": "=", "b": [0.1916, 0.8196, 0.2031, 0.84]}]}, {"id": "b_8", "type": "equation", "text": "∑ i = 1 y j", "words": [{"w": "∑", "b": [0.2384, 0.7708, 0.2534, 0.7996]}, {"w": "i", "b": [0.2309, 0.7902, 0.2352, 0.8067]}, {"w": "=", "b": [0.2396, 0.7904, 0.2488, 0.8067]}, {"w": "1", "b": [0.2533, 0.7904, 0.2609, 0.8067]}, {"w": "y", "b": [0.2139, 0.8084, 0.221, 0.8248]}, {"w": "j", "b": [0.2236, 0.8144, 0.2279, 0.8309]}]}, {"id": "b_9", "type": "paragraph", "text": "i ≠y i", "words": [{"w": "i", "b": [0.2275, 0.8023, 0.2319, 0.8188]}, {"w": "≠y", "b": [0.2417, 0.8084, 0.2634, 0.8248]}, {"w": "i", "b": [0.2689, 0.8023, 0.2732, 0.8188]}]}, {"id": "b_11", "type": "paragraph", "text": "w i", "words": [{"w": "w", "b": [0.2831, 0.7753, 0.2964, 0.7959]}, {"w": "i", "b": [0.3019, 0.7716, 0.3063, 0.7881]}]}, {"id": "b_12", "type": "equation", "text": "∑ i = 1", "words": [{"w": "∑", "b": [0.2384, 0.8372, 0.2534, 0.8661]}, {"w": "i", "b": [0.2309, 0.8567, 0.2352, 0.8732]}, {"w": "=", "b": [0.2396, 0.8568, 0.2488, 0.8732]}, {"w": "1", "b": [0.2533, 0.8568, 0.2609, 0.8732]}]}, {"id": "b_14", "type": "paragraph", "text": "w i", "words": [{"w": "w", "b": [0.2631, 0.8418, 0.2764, 0.8624]}, {"w": "i", "b": [0.2819, 0.8381, 0.2862, 0.8546]}]}, {"id": "b_15", "type": "paragraph", "text": "where y j", "words": [{"w": "where", "b": [0.3338, 0.8196, 0.3822, 0.84]}, {"w": "y", "b": [0.3913, 0.8194, 0.4, 0.84]}, {"w": "j", "b": [0.403, 0.8278, 0.4072, 0.8442]}]}, {"id": "b_16", "type": "paragraph", "text": "i is the jth predictor’s prediction for the ith instance.", "words": [{"w": "i", "b": [0.4069, 0.8157, 0.4112, 0.8321]}, {"w": "is", "b": [0.4246, 0.8196, 0.4372, 0.84]}, {"w": "the", "b": [0.4452, 0.8196, 0.4702, 0.84]}, {"w": "jth", "b": [0.4802, 0.8158, 0.4988, 0.84]}, {"w": "predictor’s", "b": [0.5067, 0.8196, 0.5924, 0.84]}, {"w": "prediction", "b": [0.6003, 0.8196, 0.683, 0.84]}, {"w": "for", "b": [0.691, 0.8196, 0.7143, 0.84]}, {"w": "the", "b": [0.7222, 0.8196, 0.7473, 0.84]}, {"w": "ith", "b": [0.7553, 0.8158, 0.774, 0.84]}, {"w": "instance.", "b": [0.7819, 0.8196, 0.8523, 0.84]}]}, {"id": "b_17", "type": "paragraph", "text": "Boosting | 203", "words": [{"w": "Boosting", "b": [0.7435, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "203", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 230, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "15 The original AdaBoost algorithm does not use a learning rate hyperparameter.", "words": [{"w": "15", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "The", "b": [0.1587, 0.8749, 0.1837, 0.8912]}, {"w": "original", "b": [0.1873, 0.8749, 0.2369, 0.8912]}, {"w": "AdaBoost", "b": [0.2405, 0.8749, 0.303, 0.8912]}, {"w": "algorithm", "b": [0.3066, 0.8749, 0.3695, 0.8912]}, {"w": "does", "b": [0.3731, 0.8749, 0.4022, 0.8912]}, {"w": "not", "b": [0.4058, 0.8749, 0.4274, 0.8912]}, {"w": "use", "b": [0.431, 0.8749, 0.452, 0.8912]}, {"w": "a", "b": [0.4556, 0.8749, 0.4626, 0.8912]}, {"w": "learning", "b": [0.4662, 0.8749, 0.5188, 0.8912]}, {"w": "rate", "b": [0.5224, 0.8749, 0.5466, 0.8912]}, {"w": "hyperparameter.", "b": [0.5502, 0.8749, 0.6545, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "The predictor’s weight αj is then computed using Equation 7-2, where η is the learn‐ ing rate hyperparameter (defaults to 1).15 The more accurate the predictor is, the higher its weight will be. If it is just guessing randomly, then its weight will be close to zero. However, if it is most often wrong (i.e., less accurate than random guessing), then its weight will be negative.", "words": [{"w": "The", "b": [0.1429, 0.0791, 0.1757, 0.1005]}, {"w": "predictor’s", "b": [0.1817, 0.0791, 0.2696, 0.1005]}, {"w": "weight", "b": [0.2756, 0.0791, 0.3311, 0.1005]}, {"w": "αj", "b": [0.3371, 0.0789, 0.3515, 0.1014]}, {"w": "is", "b": [0.3575, 0.0791, 0.3707, 0.1005]}, {"w": "then", "b": [0.3767, 0.0791, 0.4144, 0.1005]}, {"w": "computed", "b": [0.4204, 0.0791, 0.5047, 0.1005]}, {"w": "using", "b": [0.5107, 0.0791, 0.5561, 0.1005]}, {"w": "Equation", "b": [0.5621, 0.0791, 0.6383, 0.1005]}, {"w": "7-2,", "b": [0.6443, 0.0791, 0.6765, 0.1005]}, {"w": "where", "b": [0.6824, 0.0791, 0.7333, 0.1005]}, {"w": "η", "b": [0.7392, 0.0789, 0.7499, 0.1005]}, {"w": "is", "b": [0.7558, 0.0791, 0.7691, 0.1005]}, {"w": "the", "b": [0.775, 0.0791, 0.8014, 0.1005]}, {"w": "learn‐", "b": [0.8073, 0.0791, 0.8571, 0.1005]}, {"w": "ing", "b": [0.1429, 0.0981, 0.1696, 0.1195]}, {"w": "rate", "b": [0.1783, 0.0981, 0.21, 0.1195]}, {"w": "hyperparameter", "b": [0.2187, 0.0981, 0.3522, 0.1195]}, {"w": "(defaults", "b": [0.361, 0.0981, 0.4333, 0.1195]}, {"w": "to", "b": [0.442, 0.0981, 0.459, 0.1195]}, {"w": "1).15", "b": [0.4677, 0.0981, 0.5011, 0.1195]}, {"w": "The", "b": [0.5099, 0.0981, 0.5427, 0.1195]}, {"w": "more", "b": [0.5514, 0.0981, 0.5957, 0.1195]}, {"w": "accurate", "b": [0.6044, 0.0981, 0.6739, 0.1195]}, {"w": "the", "b": [0.6827, 0.0981, 0.709, 0.1195]}, {"w": "predictor", "b": [0.7178, 0.0981, 0.7954, 0.1195]}, {"w": "is,", "b": [0.8041, 0.0981, 0.8221, 0.1195]}, {"w": "the", "b": [0.8308, 0.0981, 0.8571, 0.1195]}, {"w": "higher", "b": [0.1429, 0.1172, 0.197, 0.1386]}, {"w": "its", "b": [0.202, 0.1172, 0.2216, 0.1386]}, {"w": "weight", "b": [0.2265, 0.1172, 0.282, 0.1386]}, {"w": "will", "b": [0.287, 0.1172, 0.3174, 0.1386]}, {"w": "be.", "b": [0.3223, 0.1172, 0.3465, 0.1386]}, {"w": "If", "b": [0.3514, 0.1172, 0.3647, 0.1386]}, {"w": "it", "b": [0.3697, 0.1172, 0.3816, 0.1386]}, {"w": "is", "b": [0.3865, 0.1172, 0.3998, 0.1386]}, {"w": "just", "b": [0.4047, 0.1172, 0.4351, 0.1386]}, {"w": "guessing", "b": [0.44, 0.1172, 0.5117, 0.1386]}, {"w": "randomly,", "b": [0.5167, 0.1172, 0.6017, 0.1386]}, {"w": "then", "b": [0.6066, 0.1172, 0.6444, 0.1386]}, {"w": "its", "b": [0.6493, 0.1172, 0.6689, 0.1386]}, {"w": "weight", "b": [0.6738, 0.1172, 0.7294, 0.1386]}, {"w": "will", "b": [0.7343, 0.1172, 0.7647, 0.1386]}, {"w": "be", "b": [0.7696, 0.1172, 0.7891, 0.1386]}, {"w": "close", "b": [0.794, 0.1172, 0.8352, 0.1386]}, {"w": "to", "b": [0.8402, 0.1172, 0.8572, 0.1386]}, {"w": "zero.", "b": [0.1429, 0.1362, 0.183, 0.1576]}, {"w": "However,", "b": [0.1904, 0.1362, 0.2692, 0.1576]}, {"w": "if", "b": [0.2766, 0.1362, 0.2884, 0.1576]}, {"w": "it", "b": [0.2957, 0.1362, 0.3077, 0.1576]}, {"w": "is", "b": [0.3151, 0.1362, 0.3283, 0.1576]}, {"w": "most", "b": [0.3357, 0.1362, 0.3774, 0.1576]}, {"w": "often", "b": [0.3848, 0.1362, 0.4282, 0.1576]}, {"w": "wrong", "b": [0.4356, 0.1362, 0.4893, 0.1576]}, {"w": "(i.e.,", "b": [0.4967, 0.1362, 0.5326, 0.1576]}, {"w": "less", "b": [0.54, 0.1362, 0.5694, 0.1576]}, {"w": "accurate", "b": [0.5768, 0.1362, 0.6463, 0.1576]}, {"w": "than", "b": [0.6537, 0.1362, 0.6918, 0.1576]}, {"w": "random", "b": [0.6992, 0.1362, 0.7661, 0.1576]}, {"w": "guessing),", "b": [0.7735, 0.1362, 0.8571, 0.1576]}, {"w": "then", "b": [0.1429, 0.1553, 0.1806, 0.1767]}, {"w": "its", "b": [0.1853, 0.1553, 0.2049, 0.1767]}, {"w": "weight", "b": [0.2096, 0.1553, 0.2652, 0.1767]}, {"w": "will", "b": [0.2699, 0.1553, 0.3003, 0.1767]}, {"w": "be", "b": [0.305, 0.1553, 0.3245, 0.1767]}, {"w": "negative.", "b": [0.3292, 0.1553, 0.4031, 0.1767]}]}, {"id": "b_2", "type": "equation", "text": "Equation 7-2. Predictor weight", "words": [{"w": "Equation", "b": [0.1726, 0.1948, 0.2473, 0.2164]}, {"w": "7-2.", "b": [0.2521, 0.1948, 0.2838, 0.2164]}, {"w": "Predictor", "b": [0.2886, 0.1948, 0.3628, 0.2164]}, {"w": "weight", "b": [0.3676, 0.1948, 0.4206, 0.2164]}]}, {"id": "b_3", "type": "equation", "text": "αj = η log", "words": [{"w": "αj", "b": [0.1726, 0.2359, 0.1891, 0.2608]}, {"w": "=", "b": [0.1946, 0.2361, 0.2061, 0.2565]}, {"w": "η", "b": [0.2116, 0.2359, 0.2217, 0.2565]}, {"w": "log", "b": [0.2272, 0.2361, 0.2516, 0.2565]}]}, {"id": "b_4", "type": "paragraph", "text": "1 −rj rj", "words": [{"w": "1", "b": [0.2594, 0.2228, 0.2689, 0.2432]}, {"w": "−rj", "b": [0.2733, 0.2226, 0.3027, 0.2474]}, {"w": "rj", "b": [0.2743, 0.2447, 0.2878, 0.2696]}]}, {"id": "b_5", "type": "paragraph", "text": "Next the instance weights are updated using Equation 7-3: the misclassified instances are boosted.", "words": [{"w": "Next", "b": [0.1429, 0.2886, 0.1829, 0.3101]}, {"w": "the", "b": [0.1882, 0.2886, 0.2145, 0.3101]}, {"w": "instance", "b": [0.2199, 0.2886, 0.2891, 0.3101]}, {"w": "weights", "b": [0.2944, 0.2886, 0.3576, 0.3101]}, {"w": "are", "b": [0.363, 0.2886, 0.3887, 0.3101]}, {"w": "updated", "b": [0.3941, 0.2886, 0.462, 0.3101]}, {"w": "using", "b": [0.4673, 0.2886, 0.5128, 0.3101]}, {"w": "Equation", "b": [0.5181, 0.2886, 0.5944, 0.3101]}, {"w": "7-3:", "b": [0.5991, 0.2886, 0.6319, 0.3101]}, {"w": "the", "b": [0.6373, 0.2886, 0.6636, 0.3101]}, {"w": "misclassified", "b": [0.669, 0.2886, 0.775, 0.3101]}, {"w": "instances", "b": [0.7803, 0.2886, 0.8571, 0.3101]}, {"w": "are", "b": [0.1428, 0.3077, 0.1686, 0.3291]}, {"w": "boosted.", "b": [0.1733, 0.3077, 0.2437, 0.3291]}]}, {"id": "b_6", "type": "equation", "text": "Equation 7-3. Weight update rule", "words": [{"w": "Equation", "b": [0.1726, 0.3472, 0.2473, 0.3688]}, {"w": "7-3.", "b": [0.2521, 0.3472, 0.2838, 0.3688]}, {"w": "Weight", "b": [0.2886, 0.3472, 0.3455, 0.3688]}, {"w": "update", "b": [0.3503, 0.3472, 0.406, 0.3688]}, {"w": "rule", "b": [0.4108, 0.3472, 0.443, 0.3688]}]}, {"id": "b_7", "type": "equation", "text": "for i = 1, 2, ⋯, m", "words": [{"w": "for", "b": [0.1892, 0.3761, 0.2126, 0.3965]}, {"w": "i", "b": [0.2205, 0.3759, 0.226, 0.3965]}, {"w": "=", "b": [0.2315, 0.3761, 0.243, 0.3965]}, {"w": "1,", "b": [0.2485, 0.3761, 0.2625, 0.3965]}, {"w": "2,", "b": [0.2658, 0.3761, 0.2799, 0.3965]}, {"w": "⋯,", "b": [0.2832, 0.3761, 0.3076, 0.3965]}, {"w": "m", "b": [0.3109, 0.3759, 0.3265, 0.3965]}]}, {"id": "b_8", "type": "paragraph", "text": "w i w i if yj", "words": [{"w": "w", "b": [0.1813, 0.4175, 0.1946, 0.4381]}, {"w": "i", "b": [0.2001, 0.4138, 0.2044, 0.4303]}, {"w": "w", "b": [0.2452, 0.4021, 0.2585, 0.4227]}, {"w": "i", "b": [0.264, 0.3984, 0.2684, 0.4149]}, {"w": "if", "b": [0.3519, 0.4023, 0.3631, 0.4227]}, {"w": "yj", "b": [0.3738, 0.4021, 0.3885, 0.427]}]}, {"id": "b_9", "type": "equation", "text": "i = y i", "words": [{"w": "i", "b": [0.394, 0.3984, 0.3983, 0.4149]}, {"w": "=", "b": [0.4093, 0.4023, 0.4208, 0.4227]}, {"w": "y", "b": [0.4274, 0.4021, 0.4362, 0.4227]}, {"w": "i", "b": [0.4417, 0.3984, 0.4461, 0.4149]}]}, {"id": "b_10", "type": "paragraph", "text": "w i exp αj if yj", "words": [{"w": "w", "b": [0.2452, 0.433, 0.2585, 0.4535]}, {"w": "i", "b": [0.264, 0.4292, 0.2683, 0.4457]}, {"w": "exp", "b": [0.2794, 0.4332, 0.3076, 0.4535]}, {"w": "αj", "b": [0.3199, 0.433, 0.3364, 0.4578]}, {"w": "if", "b": [0.3519, 0.4332, 0.3631, 0.4535]}, {"w": "yj", "b": [0.3738, 0.433, 0.3885, 0.4578]}]}, {"id": "b_11", "type": "paragraph", "text": "i ≠y i", "words": [{"w": "i", "b": [0.394, 0.4292, 0.3983, 0.4457]}, {"w": "≠y", "b": [0.4093, 0.433, 0.4364, 0.4535]}, {"w": "i", "b": [0.4419, 0.4292, 0.4462, 0.4457]}]}, {"id": "b_12", "type": "equation", "text": "Then all the instance weights are normalized (i.e., divided by ∑i = 1", "words": [{"w": "Then", "b": [0.1429, 0.4794, 0.1871, 0.5008]}, {"w": "all", "b": [0.1918, 0.4794, 0.2115, 0.5008]}, {"w": "the", "b": [0.2162, 0.4794, 0.2426, 0.5008]}, {"w": "instance", "b": [0.2473, 0.4794, 0.3165, 0.5008]}, {"w": "weights", "b": [0.3212, 0.4794, 0.3844, 0.5008]}, {"w": "are", "b": [0.3891, 0.4794, 0.4149, 0.5008]}, {"w": "normalized", "b": [0.4196, 0.4794, 0.515, 0.5008]}, {"w": "(i.e.,", "b": [0.5197, 0.4794, 0.5556, 0.5008]}, {"w": "divided", "b": [0.5604, 0.4794, 0.623, 0.5008]}, {"w": "by", "b": [0.6277, 0.4794, 0.6479, 0.5008]}, {"w": "∑i", "b": [0.6526, 0.4794, 0.6681, 0.5047]}, {"w": "=", "b": [0.6725, 0.4884, 0.6817, 0.5047]}, {"w": "1", "b": [0.6862, 0.4884, 0.6938, 0.5047]}]}, {"id": "b_13", "type": "paragraph", "text": "m w i ).", "words": [{"w": "m", "b": [0.6638, 0.4761, 0.6763, 0.4926]}, {"w": "w", "b": [0.6961, 0.4792, 0.7101, 0.5008]}, {"w": "i", "b": [0.7155, 0.4761, 0.7199, 0.4926]}, {"w": ").", "b": [0.7254, 0.4794, 0.7373, 0.5008]}]}, {"id": "b_14", "type": "paragraph", "text": "Finally, a new predictor is trained using the updated weights, and the whole process is repeated (the new predictor’s weight is computed, the instance weights are updated, then another predictor is trained, and so on). The algorithm stops when the desired number of predictors is reached, or when a perfect predictor is found.", "words": [{"w": "Finally,", "b": [0.1429, 0.5101, 0.2033, 0.5315]}, {"w": "a", "b": [0.2082, 0.5101, 0.2173, 0.5315]}, {"w": "new", "b": [0.2222, 0.5101, 0.2567, 0.5315]}, {"w": "predictor", "b": [0.2616, 0.5101, 0.3392, 0.5315]}, {"w": "is", "b": [0.3441, 0.5101, 0.3573, 0.5315]}, {"w": "trained", "b": [0.3622, 0.5101, 0.4222, 0.5315]}, {"w": "using", "b": [0.4271, 0.5101, 0.4725, 0.5315]}, {"w": "the", "b": [0.4774, 0.5101, 0.5037, 0.5315]}, {"w": "updated", "b": [0.5086, 0.5101, 0.5765, 0.5315]}, {"w": "weights,", "b": [0.5814, 0.5101, 0.6493, 0.5315]}, {"w": "and", "b": [0.6542, 0.5101, 0.6857, 0.5315]}, {"w": "the", "b": [0.6906, 0.5101, 0.7169, 0.5315]}, {"w": "whole", "b": [0.7218, 0.5101, 0.772, 0.5315]}, {"w": "process", "b": [0.7768, 0.5101, 0.839, 0.5315]}, {"w": "is", "b": [0.8439, 0.5101, 0.8571, 0.5315]}, {"w": "repeated", "b": [0.1429, 0.5292, 0.2142, 0.5506]}, {"w": "(the", "b": [0.2207, 0.5292, 0.2543, 0.5506]}, {"w": "new", "b": [0.2608, 0.5292, 0.2953, 0.5506]}, {"w": "predictor’s", "b": [0.3019, 0.5292, 0.3898, 0.5506]}, {"w": "weight", "b": [0.3963, 0.5292, 0.4519, 0.5506]}, {"w": "is", "b": [0.4584, 0.5292, 0.4717, 0.5506]}, {"w": "computed,", "b": [0.4782, 0.5292, 0.5673, 0.5506]}, {"w": "the", "b": [0.5738, 0.5292, 0.6001, 0.5506]}, {"w": "instance", "b": [0.6067, 0.5292, 0.6759, 0.5506]}, {"w": "weights", "b": [0.6824, 0.5292, 0.7456, 0.5506]}, {"w": "are", "b": [0.7522, 0.5292, 0.7779, 0.5506]}, {"w": "updated,", "b": [0.7844, 0.5292, 0.8571, 0.5506]}, {"w": "then", "b": [0.1429, 0.5482, 0.1806, 0.5696]}, {"w": "another", "b": [0.1868, 0.5482, 0.252, 0.5696]}, {"w": "predictor", "b": [0.2582, 0.5482, 0.3358, 0.5696]}, {"w": "is", "b": [0.342, 0.5482, 0.3553, 0.5696]}, {"w": "trained,", "b": [0.3615, 0.5482, 0.4263, 0.5696]}, {"w": "and", "b": [0.4325, 0.5482, 0.464, 0.5696]}, {"w": "so", "b": [0.4702, 0.5482, 0.4885, 0.5696]}, {"w": "on).", "b": [0.4947, 0.5482, 0.5286, 0.5696]}, {"w": "The", "b": [0.5348, 0.5482, 0.5677, 0.5696]}, {"w": "algorithm", "b": [0.5739, 0.5482, 0.6565, 0.5696]}, {"w": "stops", "b": [0.6627, 0.5482, 0.7059, 0.5696]}, {"w": "when", "b": [0.7121, 0.5482, 0.7578, 0.5696]}, {"w": "the", "b": [0.764, 0.5482, 0.7903, 0.5696]}, {"w": "desired", "b": [0.7965, 0.5482, 0.8572, 0.5696]}, {"w": "number", "b": [0.1429, 0.5673, 0.2092, 0.5887]}, {"w": "of", "b": [0.2139, 0.5673, 0.2307, 0.5887]}, {"w": "predictors", "b": [0.2354, 0.5673, 0.3207, 0.5887]}, {"w": "is", "b": [0.3254, 0.5673, 0.3386, 0.5887]}, {"w": "reached,", "b": [0.3433, 0.5673, 0.4136, 0.5887]}, {"w": "or", "b": [0.4183, 0.5673, 0.4367, 0.5887]}, {"w": "when", "b": [0.4414, 0.5673, 0.4871, 0.5887]}, {"w": "a", "b": [0.4918, 0.5673, 0.5009, 0.5887]}, {"w": "perfect", "b": [0.5057, 0.5673, 0.5634, 0.5887]}, {"w": "predictor", "b": [0.5681, 0.5673, 0.6457, 0.5887]}, {"w": "is", "b": [0.6504, 0.5673, 0.6637, 0.5887]}, {"w": "found.", "b": [0.6684, 0.5673, 0.7234, 0.5887]}]}, {"id": "b_15", "type": "paragraph", "text": "To make predictions, AdaBoost simply computes the predictions of all the predictors and weighs them using the predictor weights αj. The predicted class is the one that receives the majority of weighted votes (see Equation 7-4).", "words": [{"w": "To", "b": [0.1429, 0.5954, 0.1643, 0.6168]}, {"w": "make", "b": [0.1698, 0.5954, 0.2152, 0.6168]}, {"w": "predictions,", "b": [0.2207, 0.5954, 0.32, 0.6168]}, {"w": "AdaBoost", "b": [0.3255, 0.5954, 0.4074, 0.6168]}, {"w": "simply", "b": [0.413, 0.5954, 0.4686, 0.6168]}, {"w": "computes", "b": [0.4741, 0.5954, 0.5551, 0.6168]}, {"w": "the", "b": [0.5606, 0.5954, 0.5869, 0.6168]}, {"w": "predictions", "b": [0.5925, 0.5954, 0.687, 0.6168]}, {"w": "of", "b": [0.6925, 0.5954, 0.7093, 0.6168]}, {"w": "all", "b": [0.7148, 0.5954, 0.7345, 0.6168]}, {"w": "the", "b": [0.74, 0.5954, 0.7664, 0.6168]}, {"w": "predictors", "b": [0.7719, 0.5954, 0.8571, 0.6168]}, {"w": "and", "b": [0.1429, 0.6144, 0.1744, 0.6358]}, {"w": "weighs", "b": [0.1813, 0.6144, 0.2385, 0.6358]}, {"w": "them", "b": [0.2455, 0.6144, 0.2889, 0.6358]}, {"w": "using", "b": [0.2958, 0.6144, 0.3412, 0.6358]}, {"w": "the", "b": [0.3481, 0.6144, 0.3745, 0.6358]}, {"w": "predictor", "b": [0.3814, 0.6144, 0.459, 0.6358]}, {"w": "weights", "b": [0.4659, 0.6144, 0.5291, 0.6358]}, {"w": "αj.", "b": [0.536, 0.6142, 0.5552, 0.6367]}, {"w": "The", "b": [0.5622, 0.6144, 0.595, 0.6358]}, {"w": "predicted", "b": [0.6019, 0.6144, 0.681, 0.6358]}, {"w": "class", "b": [0.6879, 0.6144, 0.7264, 0.6358]}, {"w": "is", "b": [0.7334, 0.6144, 0.7466, 0.6358]}, {"w": "the", "b": [0.7535, 0.6144, 0.7798, 0.6358]}, {"w": "one", "b": [0.7868, 0.6144, 0.8176, 0.6358]}, {"w": "that", "b": [0.8246, 0.6144, 0.8571, 0.6358]}, {"w": "receives", "b": [0.1428, 0.6335, 0.2088, 0.6549]}, {"w": "the", "b": [0.2136, 0.6335, 0.2399, 0.6549]}, {"w": "majority", "b": [0.2446, 0.6335, 0.3156, 0.6549]}, {"w": "of", "b": [0.3203, 0.6335, 0.3371, 0.6549]}, {"w": "weighted", "b": [0.3419, 0.6335, 0.4173, 0.6549]}, {"w": "votes", "b": [0.422, 0.6335, 0.4651, 0.6549]}, {"w": "(see", "b": [0.4698, 0.6335, 0.5024, 0.6549]}, {"w": "Equation", "b": [0.5071, 0.6335, 0.5834, 0.6549]}, {"w": "7-4).", "b": [0.5881, 0.6335, 0.6275, 0.6549]}]}, {"id": "b_16", "type": "equation", "text": "Equation 7-4. AdaBoost predictions", "words": [{"w": "Equation", "b": [0.1726, 0.673, 0.2473, 0.6946]}, {"w": "7-4.", "b": [0.2521, 0.673, 0.2838, 0.6946]}, {"w": "AdaBoost", "b": [0.2886, 0.673, 0.3678, 0.6946]}, {"w": "predictions", "b": [0.3726, 0.673, 0.4614, 0.6946]}]}, {"id": "b_17", "type": "equation", "text": "y x = argmax", "words": [{"w": "y", "b": [0.1738, 0.7144, 0.1825, 0.735]}, {"w": "x", "b": [0.1907, 0.7141, 0.2003, 0.735]}, {"w": "=", "b": [0.2128, 0.7146, 0.2243, 0.735]}, {"w": "argmax", "b": [0.2353, 0.7146, 0.295, 0.735]}]}, {"id": "b_18", "type": "equation", "text": "k ∑ j = 1 y j x = k", "words": [{"w": "k", "b": [0.2614, 0.7301, 0.2689, 0.7466]}, {"w": "∑", "b": [0.3254, 0.7098, 0.3404, 0.7387]}, {"w": "j", "b": [0.3188, 0.7293, 0.323, 0.7458]}, {"w": "=", "b": [0.3274, 0.7295, 0.3366, 0.7458]}, {"w": "1", "b": [0.341, 0.7295, 0.3486, 0.7458]}, {"w": "y", "b": [0.3043, 0.7419, 0.3113, 0.7584]}, {"w": "j", "b": [0.314, 0.7479, 0.3182, 0.7644]}, {"w": "x", "b": [0.3237, 0.7416, 0.3313, 0.7584]}, {"w": "=", "b": [0.3413, 0.742, 0.3505, 0.7584]}, {"w": "k", "b": [0.355, 0.7419, 0.3624, 0.7584]}]}, {"id": "b_20", "type": "paragraph", "text": "αj where N is the number of predictors.", "words": [{"w": "αj", "b": [0.3664, 0.7144, 0.3828, 0.7393]}, {"w": "where", "b": [0.4027, 0.7146, 0.4511, 0.735]}, {"w": "N", "b": [0.459, 0.7144, 0.473, 0.735]}, {"w": "is", "b": [0.482, 0.7146, 0.4946, 0.735]}, {"w": "the", "b": [0.5025, 0.7146, 0.5276, 0.735]}, {"w": "number", "b": [0.5355, 0.7146, 0.599, 0.735]}, {"w": "of", "b": [0.607, 0.7146, 0.6229, 0.735]}, {"w": "predictors.", "b": [0.6325, 0.7146, 0.7182, 0.735]}]}, {"id": "b_21", "type": "paragraph", "text": "204 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "204", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 231, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "16 For more details, see “Multi-Class AdaBoost,” J. Zhu et al. (2006).", "words": [{"w": "16", "b": [0.1385, 0.8416, 0.1518, 0.8559]}, {"w": "For", "b": [0.1587, 0.8401, 0.1808, 0.8565]}, {"w": "more", "b": [0.1844, 0.8401, 0.2181, 0.8565]}, {"w": "details,", "b": [0.2217, 0.8401, 0.2664, 0.8565]}, {"w": "see", "b": [0.27, 0.8401, 0.2893, 0.8565]}, {"w": "“Multi-Class", "b": [0.2929, 0.8401, 0.3728, 0.8565]}, {"w": "AdaBoost,”", "b": [0.3764, 0.8401, 0.4467, 0.8565]}, {"w": "J.", "b": [0.4503, 0.8401, 0.4584, 0.8565]}, {"w": "Zhu", "b": [0.462, 0.8401, 0.4882, 0.8565]}, {"w": "et", "b": [0.4918, 0.8401, 0.5034, 0.8565]}, {"w": "al.", "b": [0.507, 0.8401, 0.5216, 0.8565]}, {"w": "(2006).", "b": [0.5252, 0.8401, 0.5703, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "17 First introduced in “Arcing the Edge,” L. Breiman (1997), and further developed in the paper “Greedy Func‐ tion Approximation: A Gradient Boosting Machine,” Jerome H. Friedman (1999).", "words": [{"w": "17", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "First", "b": [0.1587, 0.8598, 0.1879, 0.8761]}, {"w": "introduced", "b": [0.1915, 0.8598, 0.2617, 0.8761]}, {"w": "in", "b": [0.2653, 0.8598, 0.2782, 0.8761]}, {"w": "“Arcing", "b": [0.2818, 0.8598, 0.3297, 0.8761]}, {"w": "the", "b": [0.3333, 0.8598, 0.3533, 0.8761]}, {"w": "Edge,”", "b": [0.3569, 0.8598, 0.3963, 0.8761]}, {"w": "L.", "b": [0.3999, 0.8598, 0.4121, 0.8761]}, {"w": "Breiman", "b": [0.4157, 0.8598, 0.4705, 0.8761]}, {"w": "(1997),", "b": [0.4741, 0.8598, 0.5192, 0.8761]}, {"w": "and", "b": [0.5228, 0.8598, 0.5469, 0.8761]}, {"w": "further", "b": [0.5505, 0.8598, 0.5954, 0.8761]}, {"w": "developed", "b": [0.599, 0.8598, 0.6638, 0.8761]}, {"w": "in", "b": [0.6674, 0.8598, 0.6803, 0.8761]}, {"w": "the", "b": [0.684, 0.8598, 0.704, 0.8761]}, {"w": "paper", "b": [0.7076, 0.8598, 0.7436, 0.8761]}, {"w": "“Greedy", "b": [0.7472, 0.8598, 0.7993, 0.8761]}, {"w": "Func‐", "b": [0.8029, 0.8598, 0.8405, 0.8761]}, {"w": "tion", "b": [0.1587, 0.8749, 0.1846, 0.8912]}, {"w": "Approximation:", "b": [0.1882, 0.8749, 0.29, 0.8912]}, {"w": "A", "b": [0.2937, 0.8749, 0.3046, 0.8912]}, {"w": "Gradient", "b": [0.3082, 0.8749, 0.365, 0.8912]}, {"w": "Boosting", "b": [0.3686, 0.8749, 0.4255, 0.8912]}, {"w": "Machine,”", "b": [0.4291, 0.8749, 0.4926, 0.8912]}, {"w": "Jerome", "b": [0.4962, 0.8749, 0.5416, 0.8912]}, {"w": "H.", "b": [0.5452, 0.8749, 0.561, 0.8912]}, {"w": "Friedman", "b": [0.5646, 0.8749, 0.6269, 0.8912]}, {"w": "(1999).", "b": [0.6305, 0.8749, 0.6756, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "Scikit-Learn actually uses a multiclass version of AdaBoost called SAMME16 (which stands for Stagewise Additive Modeling using a Multiclass Exponential loss function). When there are just two classes, SAMME is equivalent to AdaBoost. Moreover, if the predictors can estimate class probabilities (i.e., if they have a predict_proba() method), Scikit-Learn can use a variant of SAMME called SAMME.R (the R stands for “Real”), which relies on class probabilities rather than predictions and generally performs better.", "words": [{"w": "Scikit-Learn", "b": [0.1429, 0.0791, 0.2452, 0.1005]}, {"w": "actually", "b": [0.2521, 0.0791, 0.3168, 0.1005]}, {"w": "uses", "b": [0.3237, 0.0791, 0.3589, 0.1005]}, {"w": "a", "b": [0.3659, 0.0791, 0.3751, 0.1005]}, {"w": "multiclass", "b": [0.382, 0.0791, 0.4655, 0.1005]}, {"w": "version", "b": [0.4725, 0.0791, 0.5339, 0.1005]}, {"w": "of", "b": [0.5409, 0.0791, 0.5577, 0.1005]}, {"w": "AdaBoost", "b": [0.5647, 0.0791, 0.6466, 0.1005]}, {"w": "called", "b": [0.6536, 0.0791, 0.7019, 0.1005]}, {"w": "SAMME16", "b": [0.7089, 0.0789, 0.792, 0.1005]}, {"w": "(which", "b": [0.799, 0.0791, 0.8571, 0.1005]}, {"w": "stands", "b": [0.1429, 0.0981, 0.1961, 0.1195]}, {"w": "for", "b": [0.2031, 0.0981, 0.2276, 0.1195]}, {"w": "Stagewise", "b": [0.2347, 0.0979, 0.3129, 0.1195]}, {"w": "Additive", "b": [0.32, 0.0979, 0.3892, 0.1195]}, {"w": "Modeling", "b": [0.3963, 0.0979, 0.472, 0.1195]}, {"w": "using", "b": [0.4792, 0.0979, 0.5221, 0.1195]}, {"w": "a", "b": [0.5292, 0.0979, 0.5395, 0.1195]}, {"w": "Multiclass", "b": [0.5466, 0.0979, 0.6288, 0.1195]}, {"w": "Exponential", "b": [0.6359, 0.0979, 0.7343, 0.1195]}, {"w": "loss", "b": [0.7414, 0.0979, 0.77, 0.1195]}, {"w": "function).", "b": [0.7771, 0.0979, 0.8572, 0.1195]}, {"w": "When", "b": [0.1429, 0.1172, 0.1945, 0.1386]}, {"w": "there", "b": [0.2, 0.1172, 0.243, 0.1386]}, {"w": "are", "b": [0.2485, 0.1172, 0.2743, 0.1386]}, {"w": "just", "b": [0.2798, 0.1172, 0.3102, 0.1386]}, {"w": "two", "b": [0.3158, 0.1172, 0.3471, 0.1386]}, {"w": "classes,", "b": [0.3526, 0.1172, 0.4124, 0.1386]}, {"w": "SAMME", "b": [0.418, 0.1172, 0.4912, 0.1386]}, {"w": "is", "b": [0.4968, 0.1172, 0.51, 0.1386]}, {"w": "equivalent", "b": [0.5156, 0.1172, 0.602, 0.1386]}, {"w": "to", "b": [0.6076, 0.1172, 0.6246, 0.1386]}, {"w": "AdaBoost.", "b": [0.6301, 0.1172, 0.7168, 0.1386]}, {"w": "Moreover,", "b": [0.7224, 0.1172, 0.8079, 0.1386]}, {"w": "if", "b": [0.8135, 0.1172, 0.8252, 0.1386]}, {"w": "the", "b": [0.8308, 0.1172, 0.8571, 0.1386]}, {"w": "predictors", "b": [0.1429, 0.1371, 0.2281, 0.1585]}, {"w": "can", "b": [0.2389, 0.1371, 0.2682, 0.1585]}, {"w": "estimate", "b": [0.279, 0.1371, 0.3485, 0.1585]}, {"w": "class", "b": [0.3592, 0.1371, 0.3978, 0.1585]}, {"w": "probabilities", "b": [0.4085, 0.1371, 0.513, 0.1585]}, {"w": "(i.e.,", "b": [0.5238, 0.1371, 0.5597, 0.1585]}, {"w": "if", "b": [0.5704, 0.1371, 0.5822, 0.1585]}, {"w": "they", "b": [0.5929, 0.1371, 0.6288, 0.1585]}, {"w": "have", "b": [0.6396, 0.1371, 0.678, 0.1585]}, {"w": "a", "b": [0.6888, 0.1371, 0.6979, 0.1585]}, {"w": "predict_proba()", "b": [0.7087, 0.1403, 0.8571, 0.1554]}, {"w": "method),", "b": [0.1428, 0.1561, 0.2198, 0.1776]}, {"w": "Scikit-Learn", "b": [0.2268, 0.1561, 0.3291, 0.1776]}, {"w": "can", "b": [0.3361, 0.1561, 0.3654, 0.1776]}, {"w": "use", "b": [0.3724, 0.1561, 0.3999, 0.1776]}, {"w": "a", "b": [0.4069, 0.1561, 0.4161, 0.1776]}, {"w": "variant", "b": [0.423, 0.1561, 0.4816, 0.1776]}, {"w": "of", "b": [0.4886, 0.1561, 0.5054, 0.1776]}, {"w": "SAMME", "b": [0.5124, 0.1561, 0.5856, 0.1776]}, {"w": "called", "b": [0.5926, 0.1561, 0.6409, 0.1776]}, {"w": "SAMME.R", "b": [0.6479, 0.1559, 0.737, 0.1776]}, {"w": "(the", "b": [0.744, 0.1561, 0.7775, 0.1776]}, {"w": "R", "b": [0.7845, 0.1559, 0.797, 0.1776]}, {"w": "stands", "b": [0.8039, 0.1561, 0.8571, 0.1776]}, {"w": "for", "b": [0.1429, 0.1752, 0.1674, 0.1966]}, {"w": "“Real”),", "b": [0.1742, 0.1752, 0.2385, 0.1966]}, {"w": "which", "b": [0.2453, 0.1752, 0.2962, 0.1966]}, {"w": "relies", "b": [0.3031, 0.1752, 0.347, 0.1966]}, {"w": "on", "b": [0.3539, 0.1752, 0.3759, 0.1966]}, {"w": "class", "b": [0.3827, 0.1752, 0.4212, 0.1966]}, {"w": "probabilities", "b": [0.4281, 0.1752, 0.5325, 0.1966]}, {"w": "rather", "b": [0.5394, 0.1752, 0.5899, 0.1966]}, {"w": "than", "b": [0.5967, 0.1752, 0.6348, 0.1966]}, {"w": "predictions", "b": [0.6416, 0.1752, 0.7361, 0.1966]}, {"w": "and", "b": [0.7429, 0.1752, 0.7745, 0.1966]}, {"w": "generally", "b": [0.7813, 0.1752, 0.8571, 0.1966]}, {"w": "performs", "b": [0.1429, 0.1942, 0.2196, 0.2157]}, {"w": "better.", "b": [0.2243, 0.1942, 0.2765, 0.2157]}]}, {"id": "b_3", "type": "paragraph", "text": "The following code trains an AdaBoost classifier based on 200 Decision Stumps using Scikit-Learn’s AdaBoostClassifier class (as you might expect, there is also an Ada BoostRegressor class). A Decision Stump is a Decision Tree with max_depth=1—in other words, a tree composed of a single decision node plus two leaf nodes. This is the default base estimator for the AdaBoostClassifier class:", "words": [{"w": "The", "b": [0.1429, 0.2224, 0.1757, 0.2438]}, {"w": "following", "b": [0.1812, 0.2224, 0.2602, 0.2438]}, {"w": "code", "b": [0.2657, 0.2224, 0.305, 0.2438]}, {"w": "trains", "b": [0.3105, 0.2224, 0.3583, 0.2438]}, {"w": "an", "b": [0.3638, 0.2224, 0.3844, 0.2438]}, {"w": "AdaBoost", "b": [0.3899, 0.2224, 0.4718, 0.2438]}, {"w": "classifier", "b": [0.4773, 0.2224, 0.5498, 0.2438]}, {"w": "based", "b": [0.5553, 0.2224, 0.6025, 0.2438]}, {"w": "on", "b": [0.608, 0.2224, 0.63, 0.2438]}, {"w": "200", "b": [0.6356, 0.2224, 0.6656, 0.2438]}, {"w": "Decision", "b": [0.6711, 0.2222, 0.741, 0.2438]}, {"w": "Stumps", "b": [0.7465, 0.2222, 0.8062, 0.2438]}, {"w": "using", "b": [0.8117, 0.2224, 0.8571, 0.2438]}, {"w": "Scikit-Learn’s", "b": [0.1428, 0.2423, 0.2537, 0.2637]}, {"w": "AdaBoostClassifier", "b": [0.2612, 0.2455, 0.4393, 0.2606]}, {"w": "class", "b": [0.4468, 0.2423, 0.4853, 0.2637]}, {"w": "(as", "b": [0.4928, 0.2423, 0.5168, 0.2637]}, {"w": "you", "b": [0.5242, 0.2423, 0.5555, 0.2637]}, {"w": "might", "b": [0.5629, 0.2423, 0.6124, 0.2637]}, {"w": "expect,", "b": [0.6198, 0.2423, 0.6782, 0.2637]}, {"w": "there", "b": [0.6857, 0.2423, 0.7286, 0.2637]}, {"w": "is", "b": [0.736, 0.2423, 0.7493, 0.2637]}, {"w": "also", "b": [0.7567, 0.2423, 0.7894, 0.2637]}, {"w": "an", "b": [0.7969, 0.2423, 0.8174, 0.2637]}, {"w": "Ada", "b": [0.8249, 0.2455, 0.8545, 0.2606]}, {"w": "BoostRegressor", "b": [0.1429, 0.2654, 0.2814, 0.2805]}, {"w": "class).", "b": [0.2881, 0.2623, 0.3386, 0.2837]}, {"w": "A", "b": [0.3453, 0.2623, 0.3597, 0.2837]}, {"w": "Decision", "b": [0.3664, 0.2623, 0.4402, 0.2837]}, {"w": "Stump", "b": [0.4469, 0.2623, 0.5018, 0.2837]}, {"w": "is", "b": [0.5085, 0.2623, 0.5217, 0.2837]}, {"w": "a", "b": [0.5284, 0.2623, 0.5376, 0.2837]}, {"w": "Decision", "b": [0.5443, 0.2623, 0.6181, 0.2837]}, {"w": "Tree", "b": [0.6248, 0.2623, 0.6614, 0.2837]}, {"w": "with", "b": [0.6681, 0.2623, 0.7054, 0.2837]}, {"w": "max_depth=1—in", "b": [0.7121, 0.2623, 0.8571, 0.2837]}, {"w": "other", "b": [0.1429, 0.2813, 0.1875, 0.3027]}, {"w": "words,", "b": [0.1943, 0.2813, 0.2503, 0.3027]}, {"w": "a", "b": [0.2571, 0.2813, 0.2662, 0.3027]}, {"w": "tree", "b": [0.273, 0.2813, 0.3048, 0.3027]}, {"w": "composed", "b": [0.3115, 0.2813, 0.3967, 0.3027]}, {"w": "of", "b": [0.4034, 0.2813, 0.4202, 0.3027]}, {"w": "a", "b": [0.427, 0.2813, 0.4361, 0.3027]}, {"w": "single", "b": [0.4429, 0.2813, 0.4914, 0.3027]}, {"w": "decision", "b": [0.4982, 0.2813, 0.5677, 0.3027]}, {"w": "node", "b": [0.5744, 0.2813, 0.6163, 0.3027]}, {"w": "plus", "b": [0.6231, 0.2813, 0.6579, 0.3027]}, {"w": "two", "b": [0.6647, 0.2813, 0.696, 0.3027]}, {"w": "leaf", "b": [0.7027, 0.2813, 0.7322, 0.3027]}, {"w": "nodes.", "b": [0.7389, 0.2813, 0.7932, 0.3027]}, {"w": "This", "b": [0.7999, 0.2813, 0.8372, 0.3027]}, {"w": "is", "b": [0.8439, 0.2813, 0.8571, 0.3027]}, {"w": "the", "b": [0.1428, 0.3012, 0.1692, 0.3227]}, {"w": "default", "b": [0.1739, 0.3012, 0.2314, 0.3227]}, {"w": "base", "b": [0.2361, 0.3012, 0.2723, 0.3227]}, {"w": "estimator", "b": [0.2771, 0.3012, 0.356, 0.3227]}, {"w": "for", "b": [0.3607, 0.3012, 0.3853, 0.3227]}, {"w": "the", "b": [0.39, 0.3012, 0.4163, 0.3227]}, {"w": "AdaBoostClassifier", "b": [0.4211, 0.3044, 0.5992, 0.3195]}, {"w": "class:", "b": [0.6039, 0.3012, 0.6472, 0.3227]}]}, {"id": "b_4", "type": "paragraph", "text": "from sklearn.ensemble import AdaBoostClassifier", "words": [{"w": "from", "b": [0.1766, 0.3332, 0.2103, 0.3461]}, {"w": "sklearn.ensemble", "b": [0.2188, 0.3332, 0.3537, 0.3461]}, {"w": "import", "b": [0.3621, 0.3332, 0.4127, 0.3461]}, {"w": "AdaBoostClassifier", "b": [0.4211, 0.3332, 0.5729, 0.3461]}]}, {"id": "b_5", "type": "paragraph", "text": "ada_clf = AdaBoostClassifier( DecisionTreeClassifier(max_depth=1), n_estimators=200, algorithm=\"SAMME.R\", learning_rate=0.5) ada_clf.fit(X_train, y_train)", "words": [{"w": "ada_clf", "b": [0.1766, 0.3641, 0.2356, 0.3769]}, {"w": "=", "b": [0.2441, 0.3641, 0.2525, 0.3769]}, {"w": "AdaBoostClassifier(", "b": [0.2609, 0.3641, 0.4211, 0.3769]}, {"w": "DecisionTreeClassifier(max_depth=1),", "b": [0.2103, 0.3795, 0.5139, 0.3923]}, {"w": "n_estimators=200,", "b": [0.5223, 0.3795, 0.6657, 0.3923]}, {"w": "algorithm=\"SAMME.R\",", "b": [0.2103, 0.3949, 0.379, 0.4077]}, {"w": "learning_rate=0.5)", "b": [0.3874, 0.3949, 0.5392, 0.4077]}, {"w": "ada_clf.fit(X_train,", "b": [0.1766, 0.4103, 0.3452, 0.4232]}, {"w": "y_train)", "b": [0.3537, 0.4103, 0.4211, 0.4232]}]}, {"id": "b_6", "type": "paragraph", "text": "If your AdaBoost ensemble is overfitting the training set, you can try reducing the number of estimators or more strongly regulariz‐ ing the base estimator.", "words": [{"w": "If", "b": [0.2714, 0.4448, 0.2835, 0.4644]}, {"w": "your", "b": [0.2897, 0.4448, 0.3253, 0.4644]}, {"w": "AdaBoost", "b": [0.3314, 0.4448, 0.4063, 0.4644]}, {"w": "ensemble", "b": [0.4125, 0.4448, 0.4843, 0.4644]}, {"w": "is", "b": [0.4904, 0.4448, 0.5025, 0.4644]}, {"w": "overfitting", "b": [0.5086, 0.4448, 0.5891, 0.4644]}, {"w": "the", "b": [0.5953, 0.4448, 0.6193, 0.4644]}, {"w": "training", "b": [0.6255, 0.4448, 0.6867, 0.4644]}, {"w": "set,", "b": [0.6928, 0.4448, 0.718, 0.4644]}, {"w": "you", "b": [0.7242, 0.4448, 0.7527, 0.4644]}, {"w": "can", "b": [0.7589, 0.4448, 0.7857, 0.4644]}, {"w": "try", "b": [0.2714, 0.4622, 0.2936, 0.4818]}, {"w": "reducing", "b": [0.2992, 0.4622, 0.3671, 0.4818]}, {"w": "the", "b": [0.3727, 0.4622, 0.3968, 0.4818]}, {"w": "number", "b": [0.4025, 0.4622, 0.4631, 0.4818]}, {"w": "of", "b": [0.4688, 0.4622, 0.4841, 0.4818]}, {"w": "estimators", "b": [0.4898, 0.4622, 0.569, 0.4818]}, {"w": "or", "b": [0.5746, 0.4622, 0.5914, 0.4818]}, {"w": "more", "b": [0.5971, 0.4622, 0.6376, 0.4818]}, {"w": "strongly", "b": [0.6432, 0.4622, 0.7057, 0.4818]}, {"w": "regulariz‐", "b": [0.7114, 0.4622, 0.7857, 0.4818]}, {"w": "ing", "b": [0.2714, 0.4796, 0.2958, 0.4992]}, {"w": "the", "b": [0.3002, 0.4796, 0.3242, 0.4992]}, {"w": "base", "b": [0.3286, 0.4796, 0.3617, 0.4992]}, {"w": "estimator.", "b": [0.366, 0.4796, 0.4414, 0.4992]}]}, {"id": "b_7", "type": "paragraph", "text": "Gradient Boosting", "words": [{"w": "Gradient", "b": [0.1428, 0.5407, 0.2326, 0.5692]}, {"w": "Boosting", "b": [0.2376, 0.5407, 0.3293, 0.5692]}]}, {"id": "b_8", "type": "paragraph", "text": "Another very popular Boosting algorithm is Gradient Boosting.17 Just like AdaBoost, Gradient Boosting works by sequentially adding predictors to an ensemble, each one correcting its predecessor. However, instead of tweaking the instance weights at every iteration like AdaBoost does, this method tries to fit the new predictor to the residual errors made by the previous predictor.", "words": [{"w": "Another", "b": [0.1429, 0.5751, 0.2133, 0.5966]}, {"w": "very", "b": [0.2198, 0.5751, 0.2562, 0.5966]}, {"w": "popular", "b": [0.2627, 0.5751, 0.3284, 0.5966]}, {"w": "Boosting", "b": [0.3349, 0.5751, 0.4096, 0.5966]}, {"w": "algorithm", "b": [0.4161, 0.5751, 0.4987, 0.5966]}, {"w": "is", "b": [0.5052, 0.5751, 0.5185, 0.5966]}, {"w": "Gradient", "b": [0.525, 0.5749, 0.5974, 0.5966]}, {"w": "Boosting.17", "b": [0.604, 0.5749, 0.6897, 0.5966]}, {"w": "Just", "b": [0.6962, 0.5751, 0.7274, 0.5966]}, {"w": "like", "b": [0.7339, 0.5751, 0.764, 0.5966]}, {"w": "AdaBoost,", "b": [0.7705, 0.5751, 0.8571, 0.5966]}, {"w": "Gradient", "b": [0.1428, 0.5942, 0.2174, 0.6156]}, {"w": "Boosting", "b": [0.2231, 0.5942, 0.2977, 0.6156]}, {"w": "works", "b": [0.3034, 0.5942, 0.354, 0.6156]}, {"w": "by", "b": [0.3597, 0.5942, 0.3798, 0.6156]}, {"w": "sequentially", "b": [0.3855, 0.5942, 0.4847, 0.6156]}, {"w": "adding", "b": [0.4904, 0.5942, 0.5483, 0.6156]}, {"w": "predictors", "b": [0.5539, 0.5942, 0.6392, 0.6156]}, {"w": "to", "b": [0.6449, 0.5942, 0.6618, 0.6156]}, {"w": "an", "b": [0.6675, 0.5942, 0.688, 0.6156]}, {"w": "ensemble,", "b": [0.6937, 0.5942, 0.777, 0.6156]}, {"w": "each", "b": [0.7827, 0.5942, 0.8206, 0.6156]}, {"w": "one", "b": [0.8263, 0.5942, 0.8571, 0.6156]}, {"w": "correcting", "b": [0.1429, 0.6132, 0.2285, 0.6346]}, {"w": "its", "b": [0.2337, 0.6132, 0.2532, 0.6346]}, {"w": "predecessor.", "b": [0.2584, 0.6132, 0.3605, 0.6346]}, {"w": "However,", "b": [0.3656, 0.6132, 0.4445, 0.6346]}, {"w": "instead", "b": [0.4496, 0.6132, 0.5096, 0.6346]}, {"w": "of", "b": [0.5147, 0.6132, 0.5315, 0.6346]}, {"w": "tweaking", "b": [0.5367, 0.6132, 0.6124, 0.6346]}, {"w": "the", "b": [0.6175, 0.6132, 0.6438, 0.6346]}, {"w": "instance", "b": [0.649, 0.6132, 0.7182, 0.6346]}, {"w": "weights", "b": [0.7233, 0.6132, 0.7865, 0.6346]}, {"w": "at", "b": [0.7917, 0.6132, 0.8068, 0.6346]}, {"w": "every", "b": [0.8119, 0.6132, 0.8571, 0.6346]}, {"w": "iteration", "b": [0.1429, 0.6323, 0.2141, 0.6537]}, {"w": "like", "b": [0.2195, 0.6323, 0.2495, 0.6537]}, {"w": "AdaBoost", "b": [0.2549, 0.6323, 0.3368, 0.6537]}, {"w": "does,", "b": [0.3422, 0.6323, 0.385, 0.6537]}, {"w": "this", "b": [0.3904, 0.6323, 0.4211, 0.6537]}, {"w": "method", "b": [0.4265, 0.6323, 0.4915, 0.6537]}, {"w": "tries", "b": [0.4969, 0.6323, 0.533, 0.6537]}, {"w": "to", "b": [0.5384, 0.6323, 0.5554, 0.6537]}, {"w": "fit", "b": [0.5607, 0.6323, 0.5788, 0.6537]}, {"w": "the", "b": [0.5842, 0.6323, 0.6106, 0.6537]}, {"w": "new", "b": [0.6159, 0.6323, 0.6504, 0.6537]}, {"w": "predictor", "b": [0.6558, 0.6323, 0.7334, 0.6537]}, {"w": "to", "b": [0.7388, 0.6323, 0.7558, 0.6537]}, {"w": "the", "b": [0.7611, 0.6323, 0.7875, 0.6537]}, {"w": "residual", "b": [0.7928, 0.6321, 0.8571, 0.6537]}, {"w": "errors", "b": [0.1428, 0.6511, 0.1904, 0.6727]}, {"w": "made", "b": [0.1951, 0.6513, 0.2412, 0.6727]}, {"w": "by", "b": [0.2459, 0.6513, 0.266, 0.6727]}, {"w": "the", "b": [0.2708, 0.6513, 0.2971, 0.6727]}, {"w": "previous", "b": [0.3018, 0.6513, 0.3739, 0.6727]}, {"w": "predictor.", "b": [0.3786, 0.6513, 0.4597, 0.6727]}]}, {"id": "b_9", "type": "paragraph", "text": "Let’s go through a simple regression example using Decision Trees as the base predic‐ tors (of course Gradient Boosting also works great with regression tasks). This is called Gradient Tree Boosting, or Gradient Boosted Regression Trees (GBRT). First, let’s fit a DecisionTreeRegressor to the training set (for example, a noisy quadratic train‐ ing set):", "words": [{"w": "Let’s", "b": [0.1428, 0.6794, 0.179, 0.7009]}, {"w": "go", "b": [0.1842, 0.6794, 0.2046, 0.7009]}, {"w": "through", "b": [0.2098, 0.6794, 0.2775, 0.7009]}, {"w": "a", "b": [0.2827, 0.6794, 0.2919, 0.7009]}, {"w": "simple", "b": [0.297, 0.6794, 0.352, 0.7009]}, {"w": "regression", "b": [0.3572, 0.6794, 0.443, 0.7009]}, {"w": "example", "b": [0.4482, 0.6794, 0.5177, 0.7009]}, {"w": "using", "b": [0.5229, 0.6794, 0.5683, 0.7009]}, {"w": "Decision", "b": [0.5735, 0.6794, 0.6473, 0.7009]}, {"w": "Trees", "b": [0.6525, 0.6794, 0.6967, 0.7009]}, {"w": "as", "b": [0.7019, 0.6794, 0.7187, 0.7009]}, {"w": "the", "b": [0.7239, 0.6794, 0.7502, 0.7009]}, {"w": "base", "b": [0.7554, 0.6794, 0.7916, 0.7009]}, {"w": "predic‐", "b": [0.7968, 0.6794, 0.8571, 0.7009]}, {"w": "tors", "b": [0.1429, 0.6985, 0.1752, 0.7199]}, {"w": "(of", "b": [0.1838, 0.6985, 0.2078, 0.7199]}, {"w": "course", "b": [0.2163, 0.6985, 0.271, 0.7199]}, {"w": "Gradient", "b": [0.2796, 0.6985, 0.3542, 0.7199]}, {"w": "Boosting", "b": [0.3627, 0.6985, 0.4374, 0.7199]}, {"w": "also", "b": [0.4459, 0.6985, 0.4786, 0.7199]}, {"w": "works", "b": [0.4871, 0.6985, 0.5377, 0.7199]}, {"w": "great", "b": [0.5463, 0.6985, 0.5877, 0.7199]}, {"w": "with", "b": [0.5963, 0.6985, 0.6336, 0.7199]}, {"w": "regression", "b": [0.6422, 0.6985, 0.728, 0.7199]}, {"w": "tasks).", "b": [0.7365, 0.6985, 0.7896, 0.7199]}, {"w": "This", "b": [0.7982, 0.6985, 0.8354, 0.7199]}, {"w": "is", "b": [0.8439, 0.6985, 0.8572, 0.7199]}, {"w": "called", "b": [0.1429, 0.7175, 0.1912, 0.739]}, {"w": "Gradient", "b": [0.1968, 0.7173, 0.2692, 0.739]}, {"w": "Tree", "b": [0.2748, 0.7173, 0.3096, 0.739]}, {"w": "Boosting,", "b": [0.3152, 0.7173, 0.3894, 0.739]}, {"w": "or", "b": [0.395, 0.7175, 0.4133, 0.739]}, {"w": "Gradient", "b": [0.4189, 0.7173, 0.4913, 0.739]}, {"w": "Boosted", "b": [0.4969, 0.7173, 0.5602, 0.739]}, {"w": "Regression", "b": [0.5658, 0.7173, 0.6505, 0.739]}, {"w": "Trees", "b": [0.6561, 0.7173, 0.6977, 0.739]}, {"w": "(GBRT).", "b": [0.7033, 0.7173, 0.7727, 0.739]}, {"w": "First,", "b": [0.7783, 0.7175, 0.8214, 0.739]}, {"w": "let’s", "b": [0.8269, 0.7175, 0.8571, 0.739]}, {"w": "fit", "b": [0.1429, 0.7375, 0.161, 0.7589]}, {"w": "a", "b": [0.1657, 0.7375, 0.1748, 0.7589]}, {"w": "DecisionTreeRegressor", "b": [0.18, 0.7407, 0.3878, 0.7557]}, {"w": "to", "b": [0.3928, 0.7375, 0.4098, 0.7589]}, {"w": "the", "b": [0.4147, 0.7375, 0.4411, 0.7589]}, {"w": "training", "b": [0.446, 0.7375, 0.5129, 0.7589]}, {"w": "set", "b": [0.5179, 0.7375, 0.5408, 0.7589]}, {"w": "(for", "b": [0.5457, 0.7375, 0.5774, 0.7589]}, {"w": "example,", "b": [0.5824, 0.7375, 0.6567, 0.7589]}, {"w": "a", "b": [0.6616, 0.7375, 0.6708, 0.7589]}, {"w": "noisy", "b": [0.6757, 0.7375, 0.7205, 0.7589]}, {"w": "quadratic", "b": [0.7255, 0.7375, 0.8046, 0.7589]}, {"w": "train‐", "b": [0.8095, 0.7375, 0.8572, 0.7589]}, {"w": "ing", "b": [0.1429, 0.7565, 0.1696, 0.7779]}, {"w": "set):", "b": [0.1743, 0.7565, 0.2091, 0.7779]}]}, {"id": "b_10", "type": "paragraph", "text": "Boosting | 205", "words": [{"w": "Boosting", "b": [0.7435, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "205", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 232, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "from sklearn.tree import DecisionTreeRegressor", "words": [{"w": "from", "b": [0.1766, 0.0829, 0.2103, 0.0958]}, {"w": "sklearn.tree", "b": [0.2188, 0.0829, 0.3199, 0.0958]}, {"w": "import", "b": [0.3284, 0.0829, 0.379, 0.0958]}, {"w": "DecisionTreeRegressor", "b": [0.3874, 0.0829, 0.5645, 0.0958]}]}, {"id": "b_1", "type": "equation", "text": "tree_reg1 = DecisionTreeRegressor(max_depth=2) tree_reg1.fit(X, y)", "words": [{"w": "tree_reg1", "b": [0.1766, 0.1138, 0.2525, 0.1266]}, {"w": "=", "b": [0.2609, 0.1138, 0.2693, 0.1266]}, {"w": "DecisionTreeRegressor(max_depth=2)", "b": [0.2778, 0.1138, 0.5645, 0.1266]}, {"w": "tree_reg1.fit(X,", "b": [0.1766, 0.1292, 0.3115, 0.142]}, {"w": "y)", "b": [0.3199, 0.1292, 0.3368, 0.142]}]}, {"id": "b_2", "type": "paragraph", "text": "Now train a second DecisionTreeRegressor on the residual errors made by the first predictor:", "words": [{"w": "Now", "b": [0.1428, 0.1507, 0.1827, 0.1721]}, {"w": "train", "b": [0.1884, 0.1507, 0.2286, 0.1721]}, {"w": "a", "b": [0.2342, 0.1507, 0.2434, 0.1721]}, {"w": "second", "b": [0.249, 0.1507, 0.3074, 0.1721]}, {"w": "DecisionTreeRegressor", "b": [0.313, 0.1539, 0.5209, 0.169]}, {"w": "on", "b": [0.5265, 0.1507, 0.5485, 0.1721]}, {"w": "the", "b": [0.5542, 0.1507, 0.5805, 0.1721]}, {"w": "residual", "b": [0.5862, 0.1507, 0.6525, 0.1721]}, {"w": "errors", "b": [0.6581, 0.1507, 0.7085, 0.1721]}, {"w": "made", "b": [0.7141, 0.1507, 0.7602, 0.1721]}, {"w": "by", "b": [0.7658, 0.1507, 0.786, 0.1721]}, {"w": "the", "b": [0.7917, 0.1507, 0.818, 0.1721]}, {"w": "first", "b": [0.8237, 0.1507, 0.8571, 0.1721]}, {"w": "predictor:", "b": [0.1429, 0.1698, 0.2257, 0.1912]}]}, {"id": "b_3", "type": "paragraph", "text": "y2 = y - tree_reg1.predict(X) tree_reg2 = DecisionTreeRegressor(max_depth=2) tree_reg2.fit(X, y2)", "words": [{"w": "y2", "b": [0.1766, 0.2017, 0.1935, 0.2146]}, {"w": "=", "b": [0.2019, 0.2017, 0.2103, 0.2146]}, {"w": "y", "b": [0.2188, 0.2017, 0.2272, 0.2146]}, {"w": "-", "b": [0.2356, 0.2017, 0.244, 0.2146]}, {"w": "tree_reg1.predict(X)", "b": [0.2525, 0.2017, 0.4211, 0.2146]}, {"w": "tree_reg2", "b": [0.1766, 0.2171, 0.2525, 0.23]}, {"w": "=", "b": [0.2609, 0.2171, 0.2693, 0.23]}, {"w": "DecisionTreeRegressor(max_depth=2)", "b": [0.2778, 0.2171, 0.5645, 0.23]}, {"w": "tree_reg2.fit(X,", "b": [0.1766, 0.2326, 0.3115, 0.2454]}, {"w": "y2)", "b": [0.3199, 0.2326, 0.3452, 0.2454]}]}, {"id": "b_4", "type": "paragraph", "text": "Then we train a third regressor on the residual errors made by the second predictor:", "words": [{"w": "Then", "b": [0.1429, 0.2532, 0.1871, 0.2746]}, {"w": "we", "b": [0.1918, 0.2532, 0.2149, 0.2746]}, {"w": "train", "b": [0.2197, 0.2532, 0.2599, 0.2746]}, {"w": "a", "b": [0.2646, 0.2532, 0.2738, 0.2746]}, {"w": "third", "b": [0.2785, 0.2532, 0.3203, 0.2746]}, {"w": "regressor", "b": [0.325, 0.2532, 0.4016, 0.2746]}, {"w": "on", "b": [0.4063, 0.2532, 0.4283, 0.2746]}, {"w": "the", "b": [0.4331, 0.2532, 0.4594, 0.2746]}, {"w": "residual", "b": [0.4641, 0.2532, 0.5304, 0.2746]}, {"w": "errors", "b": [0.5351, 0.2532, 0.5854, 0.2746]}, {"w": "made", "b": [0.5902, 0.2532, 0.6362, 0.2746]}, {"w": "by", "b": [0.641, 0.2532, 0.6611, 0.2746]}, {"w": "the", "b": [0.6658, 0.2532, 0.6922, 0.2746]}, {"w": "second", "b": [0.6969, 0.2532, 0.7552, 0.2746]}, {"w": "predictor:", "b": [0.76, 0.2532, 0.8428, 0.2746]}]}, {"id": "b_5", "type": "paragraph", "text": "y3 = y2 - tree_reg2.predict(X) tree_reg3 = DecisionTreeRegressor(max_depth=2) tree_reg3.fit(X, y3)", "words": [{"w": "y3", "b": [0.1766, 0.2852, 0.1934, 0.298]}, {"w": "=", "b": [0.2019, 0.2852, 0.2103, 0.298]}, {"w": "y2", "b": [0.2187, 0.2852, 0.2356, 0.298]}, {"w": "-", "b": [0.244, 0.2852, 0.2525, 0.298]}, {"w": "tree_reg2.predict(X)", "b": [0.2609, 0.2852, 0.4296, 0.298]}, {"w": "tree_reg3", "b": [0.1766, 0.3006, 0.2525, 0.3134]}, {"w": "=", "b": [0.2609, 0.3006, 0.2693, 0.3134]}, {"w": "DecisionTreeRegressor(max_depth=2)", "b": [0.2778, 0.3006, 0.5645, 0.3134]}, {"w": "tree_reg3.fit(X,", "b": [0.1766, 0.316, 0.3115, 0.3289]}, {"w": "y3)", "b": [0.3199, 0.316, 0.3452, 0.3289]}]}, {"id": "b_6", "type": "paragraph", "text": "Now we have an ensemble containing three trees. It can make predictions on a new instance simply by adding up the predictions of all the trees:", "words": [{"w": "Now", "b": [0.1429, 0.3366, 0.1827, 0.3581]}, {"w": "we", "b": [0.1891, 0.3366, 0.2122, 0.3581]}, {"w": "have", "b": [0.2186, 0.3366, 0.257, 0.3581]}, {"w": "an", "b": [0.2634, 0.3366, 0.284, 0.3581]}, {"w": "ensemble", "b": [0.2904, 0.3366, 0.3689, 0.3581]}, {"w": "containing", "b": [0.3753, 0.3366, 0.4649, 0.3581]}, {"w": "three", "b": [0.4713, 0.3366, 0.5142, 0.3581]}, {"w": "trees.", "b": [0.5206, 0.3366, 0.5648, 0.3581]}, {"w": "It", "b": [0.5712, 0.3366, 0.5838, 0.3581]}, {"w": "can", "b": [0.5902, 0.3366, 0.6196, 0.3581]}, {"w": "make", "b": [0.626, 0.3366, 0.6714, 0.3581]}, {"w": "predictions", "b": [0.6778, 0.3366, 0.7723, 0.3581]}, {"w": "on", "b": [0.7787, 0.3366, 0.8007, 0.3581]}, {"w": "a", "b": [0.8071, 0.3366, 0.8162, 0.3581]}, {"w": "new", "b": [0.8226, 0.3366, 0.8571, 0.3581]}, {"w": "instance", "b": [0.1429, 0.3557, 0.212, 0.3771]}, {"w": "simply", "b": [0.2168, 0.3557, 0.2724, 0.3771]}, {"w": "by", "b": [0.2771, 0.3557, 0.2973, 0.3771]}, {"w": "adding", "b": [0.302, 0.3557, 0.3599, 0.3771]}, {"w": "up", "b": [0.3646, 0.3557, 0.3866, 0.3771]}, {"w": "the", "b": [0.3913, 0.3557, 0.4177, 0.3771]}, {"w": "predictions", "b": [0.4224, 0.3557, 0.5169, 0.3771]}, {"w": "of", "b": [0.5216, 0.3557, 0.5384, 0.3771]}, {"w": "all", "b": [0.5431, 0.3557, 0.5628, 0.3771]}, {"w": "the", "b": [0.5676, 0.3557, 0.5939, 0.3771]}, {"w": "trees:", "b": [0.5986, 0.3557, 0.6428, 0.3771]}]}, {"id": "b_7", "type": "equation", "text": "y_pred = sum(tree.predict(X_new) for tree in (tree_reg1, tree_reg2, tree_reg3))", "words": [{"w": "y_pred", "b": [0.1766, 0.3877, 0.2272, 0.4005]}, {"w": "=", "b": [0.2356, 0.3877, 0.2441, 0.4005]}, {"w": "sum(tree.predict(X_new)", "b": [0.2525, 0.3877, 0.4464, 0.4005]}, {"w": "for", "b": [0.4549, 0.3877, 0.4802, 0.4005]}, {"w": "tree", "b": [0.4886, 0.3877, 0.5223, 0.4005]}, {"w": "in", "b": [0.5308, 0.3877, 0.5476, 0.4005]}, {"w": "(tree_reg1,", "b": [0.5561, 0.3877, 0.6488, 0.4005]}, {"w": "tree_reg2,", "b": [0.6572, 0.3877, 0.7416, 0.4005]}, {"w": "tree_reg3))", "b": [0.75, 0.3877, 0.8428, 0.4005]}]}, {"id": "b_8", "type": "paragraph", "text": "Figure 7-9 represents the predictions of these three trees in the left column, and the ensemble’s predictions in the right column. In the first row, the ensemble has just one tree, so its predictions are exactly the same as the first tree’s predictions. In the second row, a new tree is trained on the residual errors of the first tree. On the right you can see that the ensemble’s predictions are equal to the sum of the predictions of the first two trees. Similarly, in the third row another tree is trained on the residual errors of the second tree. You can see that the ensemble’s predictions gradually get better as trees are added to the ensemble.", "words": [{"w": "Figure", "b": [0.1428, 0.4083, 0.1968, 0.4297]}, {"w": "7-9", "b": [0.2031, 0.4083, 0.2305, 0.4297]}, {"w": "represents", "b": [0.2368, 0.4083, 0.3224, 0.4297]}, {"w": "the", "b": [0.3286, 0.4083, 0.355, 0.4297]}, {"w": "predictions", "b": [0.3612, 0.4083, 0.4557, 0.4297]}, {"w": "of", "b": [0.462, 0.4083, 0.4788, 0.4297]}, {"w": "these", "b": [0.485, 0.4083, 0.5279, 0.4297]}, {"w": "three", "b": [0.5341, 0.4083, 0.5771, 0.4297]}, {"w": "trees", "b": [0.5833, 0.4083, 0.6228, 0.4297]}, {"w": "in", "b": [0.629, 0.4083, 0.646, 0.4297]}, {"w": "the", "b": [0.6523, 0.4083, 0.6786, 0.4297]}, {"w": "left", "b": [0.6848, 0.4083, 0.7115, 0.4297]}, {"w": "column,", "b": [0.7178, 0.4083, 0.7867, 0.4297]}, {"w": "and", "b": [0.793, 0.4083, 0.8245, 0.4297]}, {"w": "the", "b": [0.8308, 0.4083, 0.8571, 0.4297]}, {"w": "ensemble’s", "b": [0.1429, 0.4274, 0.2305, 0.4488]}, {"w": "predictions", "b": [0.2356, 0.4274, 0.3301, 0.4488]}, {"w": "in", "b": [0.3352, 0.4274, 0.3522, 0.4488]}, {"w": "the", "b": [0.3573, 0.4274, 0.3836, 0.4488]}, {"w": "right", "b": [0.3887, 0.4274, 0.4289, 0.4488]}, {"w": "column.", "b": [0.434, 0.4274, 0.503, 0.4488]}, {"w": "In", "b": [0.5081, 0.4274, 0.5266, 0.4488]}, {"w": "the", "b": [0.5317, 0.4274, 0.558, 0.4488]}, {"w": "first", "b": [0.5631, 0.4274, 0.5966, 0.4488]}, {"w": "row,", "b": [0.6017, 0.4274, 0.6376, 0.4488]}, {"w": "the", "b": [0.6427, 0.4274, 0.669, 0.4488]}, {"w": "ensemble", "b": [0.6741, 0.4274, 0.7526, 0.4488]}, {"w": "has", "b": [0.7577, 0.4274, 0.7857, 0.4488]}, {"w": "just", "b": [0.7908, 0.4274, 0.8212, 0.4488]}, {"w": "one", "b": [0.8263, 0.4274, 0.8571, 0.4488]}, {"w": "tree,", "b": [0.1429, 0.4464, 0.1794, 0.4678]}, {"w": "so", "b": [0.1843, 0.4464, 0.2025, 0.4678]}, {"w": "its", "b": [0.2074, 0.4464, 0.227, 0.4678]}, {"w": "predictions", "b": [0.2318, 0.4464, 0.3263, 0.4678]}, {"w": "are", "b": [0.3312, 0.4464, 0.3569, 0.4678]}, {"w": "exactly", "b": [0.3618, 0.4464, 0.4196, 0.4678]}, {"w": "the", "b": [0.4245, 0.4464, 0.4508, 0.4678]}, {"w": "same", "b": [0.4557, 0.4464, 0.4984, 0.4678]}, {"w": "as", "b": [0.5032, 0.4464, 0.52, 0.4678]}, {"w": "the", "b": [0.5249, 0.4464, 0.5512, 0.4678]}, {"w": "first", "b": [0.5561, 0.4464, 0.5895, 0.4678]}, {"w": "tree’s", "b": [0.5944, 0.4464, 0.6353, 0.4678]}, {"w": "predictions.", "b": [0.6402, 0.4464, 0.7394, 0.4678]}, {"w": "In", "b": [0.7443, 0.4464, 0.7628, 0.4678]}, {"w": "the", "b": [0.7676, 0.4464, 0.794, 0.4678]}, {"w": "second", "b": [0.7988, 0.4464, 0.8571, 0.4678]}, {"w": "row,", "b": [0.1429, 0.4654, 0.1787, 0.4869]}, {"w": "a", "b": [0.1841, 0.4654, 0.1933, 0.4869]}, {"w": "new", "b": [0.1987, 0.4654, 0.2332, 0.4869]}, {"w": "tree", "b": [0.2386, 0.4654, 0.2704, 0.4869]}, {"w": "is", "b": [0.2758, 0.4654, 0.2891, 0.4869]}, {"w": "trained", "b": [0.2945, 0.4654, 0.3545, 0.4869]}, {"w": "on", "b": [0.36, 0.4654, 0.382, 0.4869]}, {"w": "the", "b": [0.3874, 0.4654, 0.4137, 0.4869]}, {"w": "residual", "b": [0.4192, 0.4654, 0.4854, 0.4869]}, {"w": "errors", "b": [0.4909, 0.4654, 0.5412, 0.4869]}, {"w": "of", "b": [0.5466, 0.4654, 0.5634, 0.4869]}, {"w": "the", "b": [0.5688, 0.4654, 0.5951, 0.4869]}, {"w": "first", "b": [0.6006, 0.4654, 0.634, 0.4869]}, {"w": "tree.", "b": [0.6395, 0.4654, 0.676, 0.4869]}, {"w": "On", "b": [0.6814, 0.4654, 0.7084, 0.4869]}, {"w": "the", "b": [0.7138, 0.4654, 0.7401, 0.4869]}, {"w": "right", "b": [0.7455, 0.4654, 0.7857, 0.4869]}, {"w": "you", "b": [0.7911, 0.4654, 0.8224, 0.4869]}, {"w": "can", "b": [0.8278, 0.4654, 0.8571, 0.4869]}, {"w": "see", "b": [0.1429, 0.4845, 0.1682, 0.5059]}, {"w": "that", "b": [0.1738, 0.4845, 0.2064, 0.5059]}, {"w": "the", "b": [0.212, 0.4845, 0.2383, 0.5059]}, {"w": "ensemble’s", "b": [0.2439, 0.4845, 0.3315, 0.5059]}, {"w": "predictions", "b": [0.3371, 0.4845, 0.4316, 0.5059]}, {"w": "are", "b": [0.4372, 0.4845, 0.4629, 0.5059]}, {"w": "equal", "b": [0.4685, 0.4845, 0.5135, 0.5059]}, {"w": "to", "b": [0.5191, 0.4845, 0.5361, 0.5059]}, {"w": "the", "b": [0.5417, 0.4845, 0.568, 0.5059]}, {"w": "sum", "b": [0.5736, 0.4845, 0.6094, 0.5059]}, {"w": "of", "b": [0.615, 0.4845, 0.6318, 0.5059]}, {"w": "the", "b": [0.6373, 0.4845, 0.6637, 0.5059]}, {"w": "predictions", "b": [0.6693, 0.4845, 0.7638, 0.5059]}, {"w": "of", "b": [0.7694, 0.4845, 0.7862, 0.5059]}, {"w": "the", "b": [0.7917, 0.4845, 0.8181, 0.5059]}, {"w": "first", "b": [0.8237, 0.4845, 0.8572, 0.5059]}, {"w": "two", "b": [0.1429, 0.5035, 0.1741, 0.525]}, {"w": "trees.", "b": [0.1802, 0.5035, 0.2243, 0.525]}, {"w": "Similarly,", "b": [0.2304, 0.5035, 0.3087, 0.525]}, {"w": "in", "b": [0.3148, 0.5035, 0.3317, 0.525]}, {"w": "the", "b": [0.3378, 0.5035, 0.3641, 0.525]}, {"w": "third", "b": [0.3702, 0.5035, 0.412, 0.525]}, {"w": "row", "b": [0.418, 0.5035, 0.4506, 0.525]}, {"w": "another", "b": [0.4567, 0.5035, 0.5219, 0.525]}, {"w": "tree", "b": [0.528, 0.5035, 0.5598, 0.525]}, {"w": "is", "b": [0.5658, 0.5035, 0.579, 0.525]}, {"w": "trained", "b": [0.5851, 0.5035, 0.6451, 0.525]}, {"w": "on", "b": [0.6512, 0.5035, 0.6732, 0.525]}, {"w": "the", "b": [0.6793, 0.5035, 0.7056, 0.525]}, {"w": "residual", "b": [0.7116, 0.5035, 0.7779, 0.525]}, {"w": "errors", "b": [0.784, 0.5035, 0.8343, 0.525]}, {"w": "of", "b": [0.8404, 0.5035, 0.8571, 0.525]}, {"w": "the", "b": [0.1429, 0.5226, 0.1692, 0.544]}, {"w": "second", "b": [0.1766, 0.5226, 0.2349, 0.544]}, {"w": "tree.", "b": [0.2424, 0.5226, 0.2789, 0.544]}, {"w": "You", "b": [0.2863, 0.5226, 0.3187, 0.544]}, {"w": "can", "b": [0.3261, 0.5226, 0.3555, 0.544]}, {"w": "see", "b": [0.3629, 0.5226, 0.3883, 0.544]}, {"w": "that", "b": [0.3957, 0.5226, 0.4283, 0.544]}, {"w": "the", "b": [0.4357, 0.5226, 0.462, 0.544]}, {"w": "ensemble’s", "b": [0.4695, 0.5226, 0.5571, 0.544]}, {"w": "predictions", "b": [0.5645, 0.5226, 0.659, 0.544]}, {"w": "gradually", "b": [0.6664, 0.5226, 0.7444, 0.544]}, {"w": "get", "b": [0.7518, 0.5226, 0.7768, 0.544]}, {"w": "better", "b": [0.7842, 0.5226, 0.8329, 0.544]}, {"w": "as", "b": [0.8403, 0.5226, 0.8571, 0.544]}, {"w": "trees", "b": [0.1428, 0.5416, 0.1823, 0.563]}, {"w": "are", "b": [0.187, 0.5416, 0.2127, 0.563]}, {"w": "added", "b": [0.2175, 0.5416, 0.2685, 0.563]}, {"w": "to", "b": [0.2732, 0.5416, 0.2902, 0.563]}, {"w": "the", "b": [0.2949, 0.5416, 0.3212, 0.563]}, {"w": "ensemble.", "b": [0.326, 0.5416, 0.4092, 0.563]}]}, {"id": "b_9", "type": "paragraph", "text": "A simpler way to train GBRT ensembles is to use Scikit-Learn’s GradientBoostingRe gressor class. Much like the RandomForestRegressor class, it has hyperparameters to control the growth of Decision Trees (e.g., max_depth, min_samples_leaf, and so on), as well as hyperparameters to control the ensemble training, such as the number of trees (n_estimators). The following code creates the same ensemble as the previous one:", "words": [{"w": "A", "b": [0.1428, 0.5707, 0.1572, 0.5921]}, {"w": "simpler", "b": [0.1628, 0.5707, 0.2255, 0.5921]}, {"w": "way", "b": [0.2311, 0.5707, 0.2637, 0.5921]}, {"w": "to", "b": [0.2693, 0.5707, 0.2862, 0.5921]}, {"w": "train", "b": [0.2918, 0.5707, 0.332, 0.5921]}, {"w": "GBRT", "b": [0.3376, 0.5707, 0.3899, 0.5921]}, {"w": "ensembles", "b": [0.3955, 0.5707, 0.4816, 0.5921]}, {"w": "is", "b": [0.4872, 0.5707, 0.5004, 0.5921]}, {"w": "to", "b": [0.506, 0.5707, 0.523, 0.5921]}, {"w": "use", "b": [0.5286, 0.5707, 0.5561, 0.5921]}, {"w": "Scikit-Learn’s", "b": [0.5617, 0.5707, 0.6726, 0.5921]}, {"w": "GradientBoostingRe", "b": [0.6782, 0.5738, 0.8563, 0.5889]}, {"w": "gressor", "b": [0.1429, 0.5938, 0.2121, 0.6089]}, {"w": "class.", "b": [0.2169, 0.5906, 0.2601, 0.612]}, {"w": "Much", "b": [0.2649, 0.5906, 0.3137, 0.612]}, {"w": "like", "b": [0.3185, 0.5906, 0.3485, 0.612]}, {"w": "the", "b": [0.3532, 0.5906, 0.3796, 0.612]}, {"w": "RandomForestRegressor", "b": [0.3844, 0.5938, 0.5922, 0.6089]}, {"w": "class,", "b": [0.5969, 0.5906, 0.6402, 0.612]}, {"w": "it", "b": [0.6449, 0.5906, 0.6569, 0.612]}, {"w": "has", "b": [0.6616, 0.5906, 0.6895, 0.612]}, {"w": "hyperparameters", "b": [0.6942, 0.5906, 0.8354, 0.612]}, {"w": "to", "b": [0.8401, 0.5906, 0.8571, 0.612]}, {"w": "control", "b": [0.1429, 0.6105, 0.2033, 0.632]}, {"w": "the", "b": [0.208, 0.6105, 0.2343, 0.632]}, {"w": "growth", "b": [0.2391, 0.6105, 0.2989, 0.632]}, {"w": "of", "b": [0.3036, 0.6105, 0.3204, 0.632]}, {"w": "Decision", "b": [0.3252, 0.6105, 0.399, 0.632]}, {"w": "Trees", "b": [0.4037, 0.6105, 0.4479, 0.632]}, {"w": "(e.g.,", "b": [0.4526, 0.6105, 0.4927, 0.632]}, {"w": "max_depth,", "b": [0.4975, 0.6105, 0.5913, 0.632]}, {"w": "min_samples_leaf,", "b": [0.5961, 0.6105, 0.7591, 0.632]}, {"w": "and", "b": [0.7639, 0.6105, 0.7954, 0.632]}, {"w": "so", "b": [0.8001, 0.6105, 0.8184, 0.632]}, {"w": "on),", "b": [0.8231, 0.6105, 0.8571, 0.632]}, {"w": "as", "b": [0.1428, 0.6296, 0.1596, 0.651]}, {"w": "well", "b": [0.1663, 0.6296, 0.2, 0.651]}, {"w": "as", "b": [0.2067, 0.6296, 0.2235, 0.651]}, {"w": "hyperparameters", "b": [0.2302, 0.6296, 0.3713, 0.651]}, {"w": "to", "b": [0.378, 0.6296, 0.395, 0.651]}, {"w": "control", "b": [0.4017, 0.6296, 0.4621, 0.651]}, {"w": "the", "b": [0.4688, 0.6296, 0.4952, 0.651]}, {"w": "ensemble", "b": [0.5019, 0.6296, 0.5804, 0.651]}, {"w": "training,", "b": [0.5871, 0.6296, 0.6588, 0.651]}, {"w": "such", "b": [0.6655, 0.6296, 0.7041, 0.651]}, {"w": "as", "b": [0.7108, 0.6296, 0.7276, 0.651]}, {"w": "the", "b": [0.7343, 0.6296, 0.7606, 0.651]}, {"w": "number", "b": [0.7673, 0.6296, 0.8336, 0.651]}, {"w": "of", "b": [0.8403, 0.6296, 0.8571, 0.651]}, {"w": "trees", "b": [0.1429, 0.6495, 0.1823, 0.6709]}, {"w": "(n_estimators).", "b": [0.1883, 0.6495, 0.3262, 0.6709]}, {"w": "The", "b": [0.3322, 0.6495, 0.3651, 0.6709]}, {"w": "following", "b": [0.3711, 0.6495, 0.45, 0.6709]}, {"w": "code", "b": [0.456, 0.6495, 0.4953, 0.6709]}, {"w": "creates", "b": [0.5013, 0.6495, 0.5583, 0.6709]}, {"w": "the", "b": [0.5644, 0.6495, 0.5907, 0.6709]}, {"w": "same", "b": [0.5967, 0.6495, 0.6394, 0.6709]}, {"w": "ensemble", "b": [0.6454, 0.6495, 0.7239, 0.6709]}, {"w": "as", "b": [0.7299, 0.6495, 0.7467, 0.6709]}, {"w": "the", "b": [0.7527, 0.6495, 0.7791, 0.6709]}, {"w": "previous", "b": [0.7851, 0.6495, 0.8571, 0.6709]}, {"w": "one:", "b": [0.1429, 0.6686, 0.1785, 0.69]}]}, {"id": "b_10", "type": "paragraph", "text": "from sklearn.ensemble import GradientBoostingRegressor", "words": [{"w": "from", "b": [0.1766, 0.7006, 0.2103, 0.7134]}, {"w": "sklearn.ensemble", "b": [0.2188, 0.7006, 0.3537, 0.7134]}, {"w": "import", "b": [0.3621, 0.7006, 0.4127, 0.7134]}, {"w": "GradientBoostingRegressor", "b": [0.4211, 0.7006, 0.6319, 0.7134]}]}, {"id": "b_11", "type": "paragraph", "text": "gbrt = GradientBoostingRegressor(max_depth=2, n_estimators=3, learning_rate=1.0) gbrt.fit(X, y)", "words": [{"w": "gbrt", "b": [0.1766, 0.7314, 0.2103, 0.7442]}, {"w": "=", "b": [0.2188, 0.7314, 0.2272, 0.7442]}, {"w": "GradientBoostingRegressor(max_depth=2,", "b": [0.2356, 0.7314, 0.5561, 0.7442]}, {"w": "n_estimators=3,", "b": [0.5645, 0.7314, 0.691, 0.7442]}, {"w": "learning_rate=1.0)", "b": [0.6994, 0.7314, 0.8512, 0.7442]}, {"w": "gbrt.fit(X,", "b": [0.1766, 0.7468, 0.2694, 0.7597]}, {"w": "y)", "b": [0.2778, 0.7468, 0.2946, 0.7597]}]}, {"id": "b_12", "type": "paragraph", "text": "206 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "206", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 233, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 7-9. Gradient Boosting", "words": [{"w": "Figure", "b": [0.1429, 0.6303, 0.1943, 0.6519]}, {"w": "7-9.", "b": [0.1991, 0.6303, 0.2308, 0.6519]}, {"w": "Gradient", "b": [0.2356, 0.6303, 0.308, 0.6519]}, {"w": "Boosting", "b": [0.3128, 0.6303, 0.3823, 0.6519]}]}, {"id": "b_1", "type": "paragraph", "text": "The learning_rate hyperparameter scales the contribution of each tree. If you set it to a low value, such as 0.1, you will need more trees in the ensemble to fit the train‐ ing set, but the predictions will usually generalize better. This is a regularization tech‐ nique called shrinkage. Figure 7-10 shows two GBRT ensembles trained with a low learning rate: the one on the left does not have enough trees to fit the training set, while the one on the right has too many trees and overfits the training set.", "words": [{"w": "The", "b": [0.1429, 0.6686, 0.1757, 0.69]}, {"w": "learning_rate", "b": [0.1815, 0.6718, 0.3101, 0.6869]}, {"w": "hyperparameter", "b": [0.3159, 0.6686, 0.4494, 0.69]}, {"w": "scales", "b": [0.4552, 0.6686, 0.5025, 0.69]}, {"w": "the", "b": [0.5083, 0.6686, 0.5346, 0.69]}, {"w": "contribution", "b": [0.5404, 0.6686, 0.6461, 0.69]}, {"w": "of", "b": [0.6519, 0.6686, 0.6687, 0.69]}, {"w": "each", "b": [0.6745, 0.6686, 0.7124, 0.69]}, {"w": "tree.", "b": [0.7182, 0.6686, 0.7547, 0.69]}, {"w": "If", "b": [0.7605, 0.6686, 0.7738, 0.69]}, {"w": "you", "b": [0.7796, 0.6686, 0.8108, 0.69]}, {"w": "set", "b": [0.8166, 0.6686, 0.8394, 0.69]}, {"w": "it", "b": [0.8452, 0.6686, 0.8571, 0.69]}, {"w": "to", "b": [0.1429, 0.6886, 0.1598, 0.71]}, {"w": "a", "b": [0.1656, 0.6886, 0.1747, 0.71]}, {"w": "low", "b": [0.1804, 0.6886, 0.2106, 0.71]}, {"w": "value,", "b": [0.2163, 0.6886, 0.265, 0.71]}, {"w": "such", "b": [0.2708, 0.6886, 0.3094, 0.71]}, {"w": "as", "b": [0.3151, 0.6886, 0.3319, 0.71]}, {"w": "0.1,", "b": [0.3377, 0.6886, 0.3721, 0.71]}, {"w": "you", "b": [0.3778, 0.6886, 0.4091, 0.71]}, {"w": "will", "b": [0.4148, 0.6886, 0.4452, 0.71]}, {"w": "need", "b": [0.4509, 0.6886, 0.491, 0.71]}, {"w": "more", "b": [0.4968, 0.6886, 0.541, 0.71]}, {"w": "trees", "b": [0.5467, 0.6886, 0.5862, 0.71]}, {"w": "in", "b": [0.5919, 0.6886, 0.6089, 0.71]}, {"w": "the", "b": [0.6146, 0.6886, 0.6409, 0.71]}, {"w": "ensemble", "b": [0.6467, 0.6886, 0.7252, 0.71]}, {"w": "to", "b": [0.7309, 0.6886, 0.7479, 0.71]}, {"w": "fit", "b": [0.7536, 0.6886, 0.7717, 0.71]}, {"w": "the", "b": [0.7775, 0.6886, 0.8038, 0.71]}, {"w": "train‐", "b": [0.8095, 0.6886, 0.8571, 0.71]}, {"w": "ing", "b": [0.1429, 0.7076, 0.1696, 0.729]}, {"w": "set,", "b": [0.1747, 0.7076, 0.2023, 0.729]}, {"w": "but", "b": [0.2074, 0.7076, 0.2354, 0.729]}, {"w": "the", "b": [0.2406, 0.7076, 0.2669, 0.729]}, {"w": "predictions", "b": [0.272, 0.7076, 0.3665, 0.729]}, {"w": "will", "b": [0.3717, 0.7076, 0.4021, 0.729]}, {"w": "usually", "b": [0.4072, 0.7076, 0.4662, 0.729]}, {"w": "generalize", "b": [0.4713, 0.7076, 0.5555, 0.729]}, {"w": "better.", "b": [0.5606, 0.7076, 0.6128, 0.729]}, {"w": "This", "b": [0.6179, 0.7076, 0.6551, 0.729]}, {"w": "is", "b": [0.6603, 0.7076, 0.6735, 0.729]}, {"w": "a", "b": [0.6786, 0.7076, 0.6878, 0.729]}, {"w": "regularization", "b": [0.6929, 0.7076, 0.8095, 0.729]}, {"w": "tech‐", "b": [0.8146, 0.7076, 0.8572, 0.729]}, {"w": "nique", "b": [0.1429, 0.7267, 0.1904, 0.7481]}, {"w": "called", "b": [0.1976, 0.7267, 0.246, 0.7481]}, {"w": "shrinkage.", "b": [0.2532, 0.7265, 0.3357, 0.7481]}, {"w": "Figure", "b": [0.343, 0.7267, 0.397, 0.7481]}, {"w": "7-10", "b": [0.4042, 0.7267, 0.4416, 0.7481]}, {"w": "shows", "b": [0.4488, 0.7267, 0.5001, 0.7481]}, {"w": "two", "b": [0.5074, 0.7267, 0.5386, 0.7481]}, {"w": "GBRT", "b": [0.5459, 0.7267, 0.5981, 0.7481]}, {"w": "ensembles", "b": [0.6054, 0.7267, 0.6915, 0.7481]}, {"w": "trained", "b": [0.6988, 0.7267, 0.7588, 0.7481]}, {"w": "with", "b": [0.766, 0.7267, 0.8034, 0.7481]}, {"w": "a", "b": [0.8106, 0.7267, 0.8197, 0.7481]}, {"w": "low", "b": [0.827, 0.7267, 0.8571, 0.7481]}, {"w": "learning", "b": [0.1429, 0.7457, 0.212, 0.7671]}, {"w": "rate:", "b": [0.2191, 0.7457, 0.2555, 0.7671]}, {"w": "the", "b": [0.2626, 0.7457, 0.2889, 0.7671]}, {"w": "one", "b": [0.296, 0.7457, 0.3269, 0.7671]}, {"w": "on", "b": [0.334, 0.7457, 0.356, 0.7671]}, {"w": "the", "b": [0.3631, 0.7457, 0.3894, 0.7671]}, {"w": "left", "b": [0.3965, 0.7457, 0.4232, 0.7671]}, {"w": "does", "b": [0.4302, 0.7457, 0.4684, 0.7671]}, {"w": "not", "b": [0.4755, 0.7457, 0.5038, 0.7671]}, {"w": "have", "b": [0.5109, 0.7457, 0.5493, 0.7671]}, {"w": "enough", "b": [0.5564, 0.7457, 0.6192, 0.7671]}, {"w": "trees", "b": [0.6263, 0.7457, 0.6657, 0.7671]}, {"w": "to", "b": [0.6728, 0.7457, 0.6898, 0.7671]}, {"w": "fit", "b": [0.6969, 0.7457, 0.715, 0.7671]}, {"w": "the", "b": [0.7221, 0.7457, 0.7484, 0.7671]}, {"w": "training", "b": [0.7555, 0.7457, 0.8224, 0.7671]}, {"w": "set,", "b": [0.8295, 0.7457, 0.8571, 0.7671]}, {"w": "while", "b": [0.1428, 0.7648, 0.188, 0.7862]}, {"w": "the", "b": [0.1927, 0.7648, 0.219, 0.7862]}, {"w": "one", "b": [0.2237, 0.7648, 0.2546, 0.7862]}, {"w": "on", "b": [0.2593, 0.7648, 0.2814, 0.7862]}, {"w": "the", "b": [0.2861, 0.7648, 0.3124, 0.7862]}, {"w": "right", "b": [0.3172, 0.7648, 0.3573, 0.7862]}, {"w": "has", "b": [0.362, 0.7648, 0.39, 0.7862]}, {"w": "too", "b": [0.3947, 0.7648, 0.4223, 0.7862]}, {"w": "many", "b": [0.427, 0.7648, 0.4737, 0.7862]}, {"w": "trees", "b": [0.4784, 0.7648, 0.5179, 0.7862]}, {"w": "and", "b": [0.5226, 0.7648, 0.5541, 0.7862]}, {"w": "overfits", "b": [0.5589, 0.7648, 0.6215, 0.7862]}, {"w": "the", "b": [0.6262, 0.7648, 0.6525, 0.7862]}, {"w": "training", "b": [0.6573, 0.7648, 0.7242, 0.7862]}, {"w": "set.", "b": [0.7289, 0.7648, 0.7565, 0.7862]}]}, {"id": "b_2", "type": "paragraph", "text": "Boosting | 207", "words": [{"w": "Boosting", "b": [0.7435, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "207", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 234, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Figure 7-10. GBRT ensembles with not enough predictors (left) and too many (right)", "words": [{"w": "Figure", "b": [0.1429, 0.2801, 0.1943, 0.3017]}, {"w": "7-10.", "b": [0.1991, 0.2801, 0.2407, 0.3017]}, {"w": "GBRT", "b": [0.2455, 0.2801, 0.2958, 0.3017]}, {"w": "ensembles", "b": [0.3006, 0.2801, 0.3816, 0.3017]}, {"w": "with", "b": [0.3864, 0.2801, 0.4229, 0.3017]}, {"w": "not", "b": [0.4277, 0.2801, 0.4545, 0.3017]}, {"w": "enough", "b": [0.4593, 0.2801, 0.5185, 0.3017]}, {"w": "predictors", "b": [0.5232, 0.2801, 0.6029, 0.3017]}, {"w": "(left)", "b": [0.6076, 0.2801, 0.647, 0.3017]}, {"w": "and", "b": [0.6517, 0.2801, 0.6831, 0.3017]}, {"w": "too", "b": [0.6879, 0.2801, 0.7136, 0.3017]}, {"w": "many", "b": [0.7184, 0.2801, 0.7643, 0.3017]}, {"w": "(right)", "b": [0.769, 0.2801, 0.8216, 0.3017]}]}, {"id": "b_1", "type": "paragraph", "text": "In order to find the optimal number of trees, you can use early stopping (see Chap‐ ter 4). A simple way to implement this is to use the staged_predict() method: it returns an iterator over the predictions made by the ensemble at each stage of train‐ ing (with one tree, two trees, etc.). The following code trains a GBRT ensemble with 120 trees, then measures the validation error at each stage of training to find the opti‐ mal number of trees, and finally trains another GBRT ensemble using the optimal number of trees:", "words": [{"w": "In", "b": [0.1429, 0.3175, 0.1614, 0.3389]}, {"w": "order", "b": [0.1676, 0.3175, 0.2135, 0.3389]}, {"w": "to", "b": [0.2198, 0.3175, 0.2368, 0.3389]}, {"w": "find", "b": [0.243, 0.3175, 0.2771, 0.3389]}, {"w": "the", "b": [0.2834, 0.3175, 0.3097, 0.3389]}, {"w": "optimal", "b": [0.316, 0.3175, 0.3809, 0.3389]}, {"w": "number", "b": [0.3872, 0.3175, 0.4535, 0.3389]}, {"w": "of", "b": [0.4597, 0.3175, 0.4765, 0.3389]}, {"w": "trees,", "b": [0.4827, 0.3175, 0.5269, 0.3389]}, {"w": "you", "b": [0.5332, 0.3175, 0.5644, 0.3389]}, {"w": "can", "b": [0.5706, 0.3175, 0.6, 0.3389]}, {"w": "use", "b": [0.6062, 0.3175, 0.6338, 0.3389]}, {"w": "early", "b": [0.64, 0.3175, 0.6806, 0.3389]}, {"w": "stopping", "b": [0.6868, 0.3175, 0.76, 0.3389]}, {"w": "(see", "b": [0.7663, 0.3175, 0.7988, 0.3389]}, {"w": "Chap‐", "b": [0.8051, 0.3175, 0.8571, 0.3389]}, {"w": "ter", "b": [0.1429, 0.3374, 0.1658, 0.3588]}, {"w": "4).", "b": [0.1733, 0.3374, 0.1953, 0.3588]}, {"w": "A", "b": [0.2028, 0.3374, 0.2172, 0.3588]}, {"w": "simple", "b": [0.2247, 0.3374, 0.2796, 0.3588]}, {"w": "way", "b": [0.2871, 0.3374, 0.3197, 0.3588]}, {"w": "to", "b": [0.3272, 0.3374, 0.3442, 0.3588]}, {"w": "implement", "b": [0.3517, 0.3374, 0.4423, 0.3588]}, {"w": "this", "b": [0.4498, 0.3374, 0.4805, 0.3588]}, {"w": "is", "b": [0.488, 0.3374, 0.5012, 0.3588]}, {"w": "to", "b": [0.5087, 0.3374, 0.5257, 0.3588]}, {"w": "use", "b": [0.5332, 0.3374, 0.5607, 0.3588]}, {"w": "the", "b": [0.5682, 0.3374, 0.5946, 0.3588]}, {"w": "staged_predict()", "b": [0.6021, 0.3406, 0.7604, 0.3557]}, {"w": "method:", "b": [0.7679, 0.3374, 0.8377, 0.3588]}, {"w": "it", "b": [0.8452, 0.3374, 0.8571, 0.3588]}, {"w": "returns", "b": [0.1429, 0.3564, 0.2036, 0.3779]}, {"w": "an", "b": [0.2096, 0.3564, 0.2301, 0.3779]}, {"w": "iterator", "b": [0.236, 0.3564, 0.298, 0.3779]}, {"w": "over", "b": [0.304, 0.3564, 0.3408, 0.3779]}, {"w": "the", "b": [0.3467, 0.3564, 0.3731, 0.3779]}, {"w": "predictions", "b": [0.379, 0.3564, 0.4735, 0.3779]}, {"w": "made", "b": [0.4794, 0.3564, 0.5255, 0.3779]}, {"w": "by", "b": [0.5314, 0.3564, 0.5516, 0.3779]}, {"w": "the", "b": [0.5575, 0.3564, 0.5838, 0.3779]}, {"w": "ensemble", "b": [0.5898, 0.3564, 0.6683, 0.3779]}, {"w": "at", "b": [0.6742, 0.3564, 0.6893, 0.3779]}, {"w": "each", "b": [0.6953, 0.3564, 0.7332, 0.3779]}, {"w": "stage", "b": [0.7391, 0.3564, 0.7809, 0.3779]}, {"w": "of", "b": [0.7868, 0.3564, 0.8036, 0.3779]}, {"w": "train‐", "b": [0.8095, 0.3564, 0.8572, 0.3779]}, {"w": "ing", "b": [0.1429, 0.3755, 0.1696, 0.3969]}, {"w": "(with", "b": [0.1755, 0.3755, 0.2201, 0.3969]}, {"w": "one", "b": [0.226, 0.3755, 0.2569, 0.3969]}, {"w": "tree,", "b": [0.2628, 0.3755, 0.2994, 0.3969]}, {"w": "two", "b": [0.3053, 0.3755, 0.3366, 0.3969]}, {"w": "trees,", "b": [0.3425, 0.3755, 0.3867, 0.3969]}, {"w": "etc.).", "b": [0.3927, 0.3755, 0.4334, 0.3969]}, {"w": "The", "b": [0.4393, 0.3755, 0.4722, 0.3969]}, {"w": "following", "b": [0.4781, 0.3755, 0.5571, 0.3969]}, {"w": "code", "b": [0.563, 0.3755, 0.6023, 0.3969]}, {"w": "trains", "b": [0.6082, 0.3755, 0.6561, 0.3969]}, {"w": "a", "b": [0.662, 0.3755, 0.6712, 0.3969]}, {"w": "GBRT", "b": [0.6771, 0.3755, 0.7294, 0.3969]}, {"w": "ensemble", "b": [0.7353, 0.3755, 0.8139, 0.3969]}, {"w": "with", "b": [0.8198, 0.3755, 0.8571, 0.3969]}, {"w": "120", "b": [0.1429, 0.3945, 0.1729, 0.416]}, {"w": "trees,", "b": [0.1779, 0.3945, 0.2221, 0.416]}, {"w": "then", "b": [0.2271, 0.3945, 0.2648, 0.416]}, {"w": "measures", "b": [0.2698, 0.3945, 0.3478, 0.416]}, {"w": "the", "b": [0.3528, 0.3945, 0.3791, 0.416]}, {"w": "validation", "b": [0.3842, 0.3945, 0.4675, 0.416]}, {"w": "error", "b": [0.4725, 0.3945, 0.5152, 0.416]}, {"w": "at", "b": [0.5202, 0.3945, 0.5353, 0.416]}, {"w": "each", "b": [0.5403, 0.3945, 0.5782, 0.416]}, {"w": "stage", "b": [0.5833, 0.3945, 0.625, 0.416]}, {"w": "of", "b": [0.63, 0.3945, 0.6468, 0.416]}, {"w": "training", "b": [0.6518, 0.3945, 0.7187, 0.416]}, {"w": "to", "b": [0.7238, 0.3945, 0.7407, 0.416]}, {"w": "find", "b": [0.7457, 0.3945, 0.7799, 0.416]}, {"w": "the", "b": [0.7849, 0.3945, 0.8112, 0.416]}, {"w": "opti‐", "b": [0.8162, 0.3945, 0.8571, 0.416]}, {"w": "mal", "b": [0.1428, 0.4136, 0.1743, 0.435]}, {"w": "number", "b": [0.1819, 0.4136, 0.2482, 0.435]}, {"w": "of", "b": [0.2558, 0.4136, 0.2726, 0.435]}, {"w": "trees,", "b": [0.2802, 0.4136, 0.3243, 0.435]}, {"w": "and", "b": [0.3319, 0.4136, 0.3635, 0.435]}, {"w": "finally", "b": [0.3711, 0.4136, 0.4235, 0.435]}, {"w": "trains", "b": [0.431, 0.4136, 0.4789, 0.435]}, {"w": "another", "b": [0.4865, 0.4136, 0.5517, 0.435]}, {"w": "GBRT", "b": [0.5593, 0.4136, 0.6116, 0.435]}, {"w": "ensemble", "b": [0.6191, 0.4136, 0.6977, 0.435]}, {"w": "using", "b": [0.7052, 0.4136, 0.7507, 0.435]}, {"w": "the", "b": [0.7583, 0.4136, 0.7846, 0.435]}, {"w": "optimal", "b": [0.7922, 0.4136, 0.8571, 0.435]}, {"w": "number", "b": [0.1429, 0.4326, 0.2092, 0.454]}, {"w": "of", "b": [0.2139, 0.4326, 0.2307, 0.454]}, {"w": "trees:", "b": [0.2354, 0.4326, 0.2796, 0.454]}]}, {"id": "b_2", "type": "paragraph", "text": "import numpy as np from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error", "words": [{"w": "import", "b": [0.1766, 0.4646, 0.2272, 0.4775]}, {"w": "numpy", "b": [0.2356, 0.4646, 0.2778, 0.4775]}, {"w": "as", "b": [0.2862, 0.4646, 0.3031, 0.4775]}, {"w": "np", "b": [0.3115, 0.4646, 0.3284, 0.4775]}, {"w": "from", "b": [0.1766, 0.48, 0.2103, 0.4929]}, {"w": "sklearn.model_selection", "b": [0.2187, 0.48, 0.4127, 0.4929]}, {"w": "import", "b": [0.4211, 0.48, 0.4717, 0.4929]}, {"w": "train_test_split", "b": [0.4802, 0.48, 0.6151, 0.4929]}, {"w": "from", "b": [0.1766, 0.4954, 0.2103, 0.5083]}, {"w": "sklearn.metrics", "b": [0.2187, 0.4954, 0.3452, 0.5083]}, {"w": "import", "b": [0.3537, 0.4954, 0.4043, 0.5083]}, {"w": "mean_squared_error", "b": [0.4127, 0.4954, 0.5645, 0.5083]}]}, {"id": "b_3", "type": "equation", "text": "X_train, X_val, y_train, y_val = train_test_split(X, y)", "words": [{"w": "X_train,", "b": [0.1766, 0.5263, 0.244, 0.5391]}, {"w": "X_val,", "b": [0.2525, 0.5263, 0.3031, 0.5391]}, {"w": "y_train,", "b": [0.3115, 0.5263, 0.379, 0.5391]}, {"w": "y_val", "b": [0.3874, 0.5263, 0.4296, 0.5391]}, {"w": "=", "b": [0.438, 0.5263, 0.4464, 0.5391]}, {"w": "train_test_split(X,", "b": [0.4549, 0.5263, 0.6151, 0.5391]}, {"w": "y)", "b": [0.6235, 0.5263, 0.6404, 0.5391]}]}, {"id": "b_4", "type": "paragraph", "text": "gbrt = GradientBoostingRegressor(max_depth=2, n_estimators=120) gbrt.fit(X_train, y_train)", "words": [{"w": "gbrt", "b": [0.1766, 0.5571, 0.2103, 0.57]}, {"w": "=", "b": [0.2187, 0.5571, 0.2272, 0.57]}, {"w": "GradientBoostingRegressor(max_depth=2,", "b": [0.2356, 0.5571, 0.556, 0.57]}, {"w": "n_estimators=120)", "b": [0.5645, 0.5571, 0.7078, 0.57]}, {"w": "gbrt.fit(X_train,", "b": [0.1766, 0.5725, 0.3199, 0.5854]}, {"w": "y_train)", "b": [0.3284, 0.5725, 0.3958, 0.5854]}]}, {"id": "b_5", "type": "paragraph", "text": "errors = [mean_squared_error(y_val, y_pred) for y_pred in gbrt.staged_predict(X_val)] bst_n_estimators = np.argmin(errors)", "words": [{"w": "errors", "b": [0.1766, 0.6034, 0.2272, 0.6162]}, {"w": "=", "b": [0.2356, 0.6034, 0.244, 0.6162]}, {"w": "[mean_squared_error(y_val,", "b": [0.2525, 0.6034, 0.4717, 0.6162]}, {"w": "y_pred)", "b": [0.4802, 0.6034, 0.5392, 0.6162]}, {"w": "for", "b": [0.2609, 0.6188, 0.2862, 0.6317]}, {"w": "y_pred", "b": [0.2946, 0.6188, 0.3452, 0.6317]}, {"w": "in", "b": [0.3537, 0.6188, 0.3705, 0.6317]}, {"w": "gbrt.staged_predict(X_val)]", "b": [0.379, 0.6188, 0.6066, 0.6317]}, {"w": "bst_n_estimators", "b": [0.1766, 0.6342, 0.3115, 0.6471]}, {"w": "=", "b": [0.3199, 0.6342, 0.3284, 0.6471]}, {"w": "np.argmin(errors)", "b": [0.3368, 0.6342, 0.4802, 0.6471]}]}, {"id": "b_6", "type": "paragraph", "text": "gbrt_best = GradientBoostingRegressor(max_depth=2,n_estimators=bst_n_estimators) gbrt_best.fit(X_train, y_train)", "words": [{"w": "gbrt_best", "b": [0.1766, 0.6651, 0.2525, 0.6779]}, {"w": "=", "b": [0.2609, 0.6651, 0.2693, 0.6779]}, {"w": "GradientBoostingRegressor(max_depth=2,n_estimators=bst_n_estimators)", "b": [0.2778, 0.6651, 0.8512, 0.6779]}, {"w": "gbrt_best.fit(X_train,", "b": [0.1766, 0.6805, 0.3621, 0.6933]}, {"w": "y_train)", "b": [0.3705, 0.6805, 0.438, 0.6933]}]}, {"id": "b_7", "type": "paragraph", "text": "The validation errors are represented on the left of Figure 7-11, and the best model’s predictions are represented on the right.", "words": [{"w": "The", "b": [0.1429, 0.7011, 0.1757, 0.7225]}, {"w": "validation", "b": [0.1816, 0.7011, 0.2649, 0.7225]}, {"w": "errors", "b": [0.2708, 0.7011, 0.3211, 0.7225]}, {"w": "are", "b": [0.327, 0.7011, 0.3528, 0.7225]}, {"w": "represented", "b": [0.3586, 0.7011, 0.4564, 0.7225]}, {"w": "on", "b": [0.4623, 0.7011, 0.4843, 0.7225]}, {"w": "the", "b": [0.4902, 0.7011, 0.5166, 0.7225]}, {"w": "left", "b": [0.5224, 0.7011, 0.5491, 0.7225]}, {"w": "of", "b": [0.555, 0.7011, 0.5718, 0.7225]}, {"w": "Figure", "b": [0.5777, 0.7011, 0.6317, 0.7225]}, {"w": "7-11,", "b": [0.6375, 0.7011, 0.6797, 0.7225]}, {"w": "and", "b": [0.6856, 0.7011, 0.7171, 0.7225]}, {"w": "the", "b": [0.723, 0.7011, 0.7494, 0.7225]}, {"w": "best", "b": [0.7552, 0.7011, 0.7887, 0.7225]}, {"w": "model’s", "b": [0.7946, 0.7011, 0.8572, 0.7225]}, {"w": "predictions", "b": [0.1429, 0.7202, 0.2374, 0.7416]}, {"w": "are", "b": [0.2421, 0.7202, 0.2678, 0.7416]}, {"w": "represented", "b": [0.2725, 0.7202, 0.3703, 0.7416]}, {"w": "on", "b": [0.3751, 0.7202, 0.3971, 0.7416]}, {"w": "the", "b": [0.4018, 0.7202, 0.4282, 0.7416]}, {"w": "right.", "b": [0.4329, 0.7202, 0.4778, 0.7416]}]}, {"id": "b_8", "type": "paragraph", "text": "208 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "208", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 235, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 7-11. Tuning the number of trees using early stopping", "words": [{"w": "Figure", "b": [0.1429, 0.2795, 0.1943, 0.3011]}, {"w": "7-11.", "b": [0.1991, 0.2795, 0.2407, 0.3011]}, {"w": "Tuning", "b": [0.2455, 0.2795, 0.303, 0.3011]}, {"w": "the", "b": [0.3078, 0.2795, 0.3329, 0.3011]}, {"w": "number", "b": [0.3376, 0.2795, 0.4012, 0.3011]}, {"w": "of", "b": [0.406, 0.2795, 0.4212, 0.3011]}, {"w": "trees", "b": [0.426, 0.2795, 0.4628, 0.3011]}, {"w": "using", "b": [0.4676, 0.2795, 0.5105, 0.3011]}, {"w": "early", "b": [0.5153, 0.2795, 0.5549, 0.3011]}, {"w": "stopping", "b": [0.5597, 0.2795, 0.6271, 0.3011]}]}, {"id": "b_1", "type": "paragraph", "text": "It is also possible to implement early stopping by actually stopping training early (instead of training a large number of trees first and then looking back to find the optimal number). You can do so by setting warm_start=True, which makes Scikit- Learn keep existing trees when the fit() method is called, allowing incremental training. The following code stops training when the validation error does not improve for five iterations in a row:", "words": [{"w": "It", "b": [0.1429, 0.3169, 0.1555, 0.3383]}, {"w": "is", "b": [0.164, 0.3169, 0.1772, 0.3383]}, {"w": "also", "b": [0.1857, 0.3169, 0.2184, 0.3383]}, {"w": "possible", "b": [0.2269, 0.3169, 0.294, 0.3383]}, {"w": "to", "b": [0.3025, 0.3169, 0.3195, 0.3383]}, {"w": "implement", "b": [0.328, 0.3169, 0.4185, 0.3383]}, {"w": "early", "b": [0.427, 0.3169, 0.4676, 0.3383]}, {"w": "stopping", "b": [0.4761, 0.3169, 0.5492, 0.3383]}, {"w": "by", "b": [0.5577, 0.3169, 0.5779, 0.3383]}, {"w": "actually", "b": [0.5864, 0.3169, 0.651, 0.3383]}, {"w": "stopping", "b": [0.6595, 0.3169, 0.7327, 0.3383]}, {"w": "training", "b": [0.7412, 0.3169, 0.8081, 0.3383]}, {"w": "early", "b": [0.8166, 0.3169, 0.8571, 0.3383]}, {"w": "(instead", "b": [0.1429, 0.3359, 0.21, 0.3573]}, {"w": "of", "b": [0.2173, 0.3359, 0.234, 0.3573]}, {"w": "training", "b": [0.2413, 0.3359, 0.3082, 0.3573]}, {"w": "a", "b": [0.3154, 0.3359, 0.3246, 0.3573]}, {"w": "large", "b": [0.3318, 0.3359, 0.3725, 0.3573]}, {"w": "number", "b": [0.3798, 0.3359, 0.4461, 0.3573]}, {"w": "of", "b": [0.4533, 0.3359, 0.4701, 0.3573]}, {"w": "trees", "b": [0.4773, 0.3359, 0.5167, 0.3573]}, {"w": "first", "b": [0.5239, 0.3359, 0.5574, 0.3573]}, {"w": "and", "b": [0.5646, 0.3359, 0.5962, 0.3573]}, {"w": "then", "b": [0.6034, 0.3359, 0.6411, 0.3573]}, {"w": "looking", "b": [0.6483, 0.3359, 0.7119, 0.3573]}, {"w": "back", "b": [0.7191, 0.3359, 0.758, 0.3573]}, {"w": "to", "b": [0.7652, 0.3359, 0.7822, 0.3573]}, {"w": "find", "b": [0.7894, 0.3359, 0.8236, 0.3573]}, {"w": "the", "b": [0.8308, 0.3359, 0.8571, 0.3573]}, {"w": "optimal", "b": [0.1429, 0.3558, 0.2078, 0.3773]}, {"w": "number).", "b": [0.2153, 0.3558, 0.2936, 0.3773]}, {"w": "You", "b": [0.301, 0.3558, 0.3334, 0.3773]}, {"w": "can", "b": [0.3409, 0.3558, 0.3702, 0.3773]}, {"w": "do", "b": [0.3777, 0.3558, 0.3993, 0.3773]}, {"w": "so", "b": [0.4068, 0.3558, 0.4251, 0.3773]}, {"w": "by", "b": [0.4326, 0.3558, 0.4527, 0.3773]}, {"w": "setting", "b": [0.4602, 0.3558, 0.5161, 0.3773]}, {"w": "warm_start=True,", "b": [0.5236, 0.3558, 0.6768, 0.3773]}, {"w": "which", "b": [0.6843, 0.3558, 0.7352, 0.3773]}, {"w": "makes", "b": [0.7427, 0.3558, 0.7957, 0.3773]}, {"w": "Scikit-", "b": [0.8032, 0.3558, 0.8572, 0.3773]}, {"w": "Learn", "b": [0.1429, 0.3758, 0.1912, 0.3972]}, {"w": "keep", "b": [0.2001, 0.3758, 0.2391, 0.3972]}, {"w": "existing", "b": [0.248, 0.3758, 0.313, 0.3972]}, {"w": "trees", "b": [0.322, 0.3758, 0.3614, 0.3972]}, {"w": "when", "b": [0.3704, 0.3758, 0.416, 0.3972]}, {"w": "the", "b": [0.4249, 0.3758, 0.4513, 0.3972]}, {"w": "fit()", "b": [0.4602, 0.379, 0.5097, 0.394]}, {"w": "method", "b": [0.5186, 0.3758, 0.5837, 0.3972]}, {"w": "is", "b": [0.5926, 0.3758, 0.6058, 0.3972]}, {"w": "called,", "b": [0.6148, 0.3758, 0.6679, 0.3972]}, {"w": "allowing", "b": [0.6768, 0.3758, 0.7481, 0.3972]}, {"w": "incremental", "b": [0.7571, 0.3758, 0.8571, 0.3972]}, {"w": "training.", "b": [0.1429, 0.3948, 0.2145, 0.4162]}, {"w": "The", "b": [0.2252, 0.3948, 0.258, 0.4162]}, {"w": "following", "b": [0.2686, 0.3948, 0.3476, 0.4162]}, {"w": "code", "b": [0.3582, 0.3948, 0.3975, 0.4162]}, {"w": "stops", "b": [0.4081, 0.3948, 0.4513, 0.4162]}, {"w": "training", "b": [0.4619, 0.3948, 0.5289, 0.4162]}, {"w": "when", "b": [0.5395, 0.3948, 0.5852, 0.4162]}, {"w": "the", "b": [0.5958, 0.3948, 0.6221, 0.4162]}, {"w": "validation", "b": [0.6327, 0.3948, 0.7161, 0.4162]}, {"w": "error", "b": [0.7267, 0.3948, 0.7694, 0.4162]}, {"w": "does", "b": [0.78, 0.3948, 0.8181, 0.4162]}, {"w": "not", "b": [0.8288, 0.3948, 0.8571, 0.4162]}, {"w": "improve", "b": [0.1429, 0.4139, 0.2129, 0.4353]}, {"w": "for", "b": [0.2176, 0.4139, 0.2421, 0.4353]}, {"w": "five", "b": [0.2469, 0.4139, 0.2771, 0.4353]}, {"w": "iterations", "b": [0.2818, 0.4139, 0.3607, 0.4353]}, {"w": "in", "b": [0.3654, 0.4139, 0.3824, 0.4353]}, {"w": "a", "b": [0.3871, 0.4139, 0.3963, 0.4353]}, {"w": "row:", "b": [0.401, 0.4139, 0.439, 0.4353]}]}, {"id": "b_2", "type": "equation", "text": "gbrt = GradientBoostingRegressor(max_depth=2, warm_start=True)", "words": [{"w": "gbrt", "b": [0.1766, 0.4459, 0.2103, 0.4587]}, {"w": "=", "b": [0.2187, 0.4459, 0.2272, 0.4587]}, {"w": "GradientBoostingRegressor(max_depth=2,", "b": [0.2356, 0.4459, 0.556, 0.4587]}, {"w": "warm_start=True)", "b": [0.5645, 0.4459, 0.6994, 0.4587]}]}, {"id": "b_3", "type": "paragraph", "text": "min_val_error = float(\"inf\") error_going_up = 0 for n_estimators in range(1, 120): gbrt.n_estimators = n_estimators gbrt.fit(X_train, y_train) y_pred = gbrt.predict(X_val) val_error = mean_squared_error(y_val, y_pred) if val_error < min_val_error: min_val_error = val_error error_going_up = 0 else: error_going_up += 1 if error_going_up == 5: break # early stopping", "words": [{"w": "min_val_error", "b": [0.1766, 0.4767, 0.2862, 0.4895]}, {"w": "=", "b": [0.2946, 0.4767, 0.3031, 0.4895]}, {"w": "float(\"inf\")", "b": [0.3115, 0.4767, 0.4127, 0.4895]}, {"w": "error_going_up", "b": [0.1766, 0.4921, 0.2946, 0.505]}, {"w": "=", "b": [0.3031, 0.4921, 0.3115, 0.505]}, {"w": "0", "b": [0.3199, 0.4921, 0.3284, 0.505]}, {"w": "for", "b": [0.1766, 0.5075, 0.2019, 0.5204]}, {"w": "n_estimators", "b": [0.2103, 0.5075, 0.3115, 0.5204]}, {"w": "in", "b": [0.3199, 0.5075, 0.3368, 0.5204]}, {"w": "range(1,", "b": [0.3452, 0.5075, 0.4127, 0.5204]}, {"w": "120):", "b": [0.4211, 0.5075, 0.4633, 0.5204]}, {"w": "gbrt.n_estimators", "b": [0.2103, 0.523, 0.3537, 0.5358]}, {"w": "=", "b": [0.3621, 0.523, 0.3705, 0.5358]}, {"w": "n_estimators", "b": [0.379, 0.523, 0.4802, 0.5358]}, {"w": "gbrt.fit(X_train,", "b": [0.2103, 0.5384, 0.3537, 0.5512]}, {"w": "y_train)", "b": [0.3621, 0.5384, 0.4296, 0.5512]}, {"w": "y_pred", "b": [0.2103, 0.5538, 0.2609, 0.5666]}, {"w": "=", "b": [0.2693, 0.5538, 0.2778, 0.5666]}, {"w": "gbrt.predict(X_val)", "b": [0.2862, 0.5538, 0.4464, 0.5666]}, {"w": "val_error", "b": [0.2103, 0.5692, 0.2862, 0.5821]}, {"w": "=", "b": [0.2946, 0.5692, 0.3031, 0.5821]}, {"w": "mean_squared_error(y_val,", "b": [0.3115, 0.5692, 0.5223, 0.5821]}, {"w": "y_pred)", "b": [0.5308, 0.5692, 0.5898, 0.5821]}, {"w": "if", "b": [0.2103, 0.5846, 0.2272, 0.5975]}, {"w": "val_error", "b": [0.2356, 0.5846, 0.3115, 0.5975]}, {"w": "<", "b": [0.3199, 0.5846, 0.3284, 0.5975]}, {"w": "min_val_error:", "b": [0.3368, 0.5846, 0.4549, 0.5975]}, {"w": "min_val_error", "b": [0.244, 0.6001, 0.3537, 0.6129]}, {"w": "=", "b": [0.3621, 0.6001, 0.3705, 0.6129]}, {"w": "val_error", "b": [0.379, 0.6001, 0.4549, 0.6129]}, {"w": "error_going_up", "b": [0.244, 0.6155, 0.3621, 0.6283]}, {"w": "=", "b": [0.3705, 0.6155, 0.379, 0.6283]}, {"w": "0", "b": [0.3874, 0.6155, 0.3958, 0.6283]}, {"w": "else:", "b": [0.2103, 0.6309, 0.2525, 0.6437]}, {"w": "error_going_up", "b": [0.244, 0.6463, 0.3621, 0.6592]}, {"w": "+=", "b": [0.3705, 0.6463, 0.3874, 0.6592]}, {"w": "1", "b": [0.3958, 0.6463, 0.4043, 0.6592]}, {"w": "if", "b": [0.244, 0.6617, 0.2609, 0.6746]}, {"w": "error_going_up", "b": [0.2693, 0.6617, 0.3874, 0.6746]}, {"w": "==", "b": [0.3958, 0.6617, 0.4127, 0.6746]}, {"w": "5:", "b": [0.4211, 0.6617, 0.438, 0.6746]}, {"w": "break", "b": [0.2778, 0.6771, 0.3199, 0.69]}, {"w": "#", "b": [0.3368, 0.6771, 0.3452, 0.69]}, {"w": "early", "b": [0.3537, 0.6771, 0.3958, 0.69]}, {"w": "stopping", "b": [0.4043, 0.6771, 0.4717, 0.69]}]}, {"id": "b_4", "type": "paragraph", "text": "The GradientBoostingRegressor class also supports a subsample hyperparameter, which specifies the fraction of training instances to be used for training each tree. For example, if subsample=0.25, then each tree is trained on 25% of the training instan‐ ces, selected randomly. As you can probably guess by now, this trades a higher bias for a lower variance. It also speeds up training considerably. This technique is called Stochastic Gradient Boosting.", "words": [{"w": "The", "b": [0.1429, 0.6987, 0.1757, 0.7201]}, {"w": "GradientBoostingRegressor", "b": [0.1835, 0.7019, 0.4309, 0.7169]}, {"w": "class", "b": [0.4388, 0.6987, 0.4773, 0.7201]}, {"w": "also", "b": [0.4851, 0.6987, 0.5178, 0.7201]}, {"w": "supports", "b": [0.5256, 0.6987, 0.5985, 0.7201]}, {"w": "a", "b": [0.6063, 0.6987, 0.6155, 0.7201]}, {"w": "subsample", "b": [0.6233, 0.7019, 0.7124, 0.7169]}, {"w": "hyperparameter,", "b": [0.7202, 0.6987, 0.8572, 0.7201]}, {"w": "which", "b": [0.1429, 0.7177, 0.1938, 0.7391]}, {"w": "specifies", "b": [0.1988, 0.7177, 0.2689, 0.7391]}, {"w": "the", "b": [0.2739, 0.7177, 0.3003, 0.7391]}, {"w": "fraction", "b": [0.3053, 0.7177, 0.3711, 0.7391]}, {"w": "of", "b": [0.3762, 0.7177, 0.393, 0.7391]}, {"w": "training", "b": [0.398, 0.7177, 0.465, 0.7391]}, {"w": "instances", "b": [0.47, 0.7177, 0.5469, 0.7391]}, {"w": "to", "b": [0.5519, 0.7177, 0.5689, 0.7391]}, {"w": "be", "b": [0.5739, 0.7177, 0.5934, 0.7391]}, {"w": "used", "b": [0.5984, 0.7177, 0.637, 0.7391]}, {"w": "for", "b": [0.642, 0.7177, 0.6666, 0.7391]}, {"w": "training", "b": [0.6716, 0.7177, 0.7385, 0.7391]}, {"w": "each", "b": [0.7436, 0.7177, 0.7815, 0.7391]}, {"w": "tree.", "b": [0.7866, 0.7177, 0.8231, 0.7391]}, {"w": "For", "b": [0.8282, 0.7177, 0.8571, 0.7391]}, {"w": "example,", "b": [0.1429, 0.7377, 0.2171, 0.7591]}, {"w": "if", "b": [0.2231, 0.7377, 0.2349, 0.7591]}, {"w": "subsample=0.25,", "b": [0.2408, 0.7377, 0.3841, 0.7591]}, {"w": "then", "b": [0.3901, 0.7377, 0.4278, 0.7591]}, {"w": "each", "b": [0.4337, 0.7377, 0.4717, 0.7591]}, {"w": "tree", "b": [0.4776, 0.7377, 0.5094, 0.7591]}, {"w": "is", "b": [0.5154, 0.7377, 0.5286, 0.7591]}, {"w": "trained", "b": [0.5346, 0.7377, 0.5946, 0.7591]}, {"w": "on", "b": [0.6006, 0.7377, 0.6226, 0.7591]}, {"w": "25%", "b": [0.6286, 0.7377, 0.6643, 0.7591]}, {"w": "of", "b": [0.6703, 0.7377, 0.6871, 0.7591]}, {"w": "the", "b": [0.693, 0.7377, 0.7194, 0.7591]}, {"w": "training", "b": [0.7253, 0.7377, 0.7922, 0.7591]}, {"w": "instan‐", "b": [0.7982, 0.7377, 0.8571, 0.7591]}, {"w": "ces,", "b": [0.1429, 0.7567, 0.1729, 0.7781]}, {"w": "selected", "b": [0.1796, 0.7567, 0.2453, 0.7781]}, {"w": "randomly.", "b": [0.252, 0.7567, 0.337, 0.7781]}, {"w": "As", "b": [0.3438, 0.7567, 0.3658, 0.7781]}, {"w": "you", "b": [0.3725, 0.7567, 0.4038, 0.7781]}, {"w": "can", "b": [0.4105, 0.7567, 0.4399, 0.7781]}, {"w": "probably", "b": [0.4466, 0.7567, 0.521, 0.7781]}, {"w": "guess", "b": [0.5277, 0.7567, 0.5727, 0.7781]}, {"w": "by", "b": [0.5794, 0.7567, 0.5996, 0.7781]}, {"w": "now,", "b": [0.6063, 0.7567, 0.6458, 0.7781]}, {"w": "this", "b": [0.6525, 0.7567, 0.6832, 0.7781]}, {"w": "trades", "b": [0.69, 0.7567, 0.7407, 0.7781]}, {"w": "a", "b": [0.7474, 0.7567, 0.7566, 0.7781]}, {"w": "higher", "b": [0.7633, 0.7567, 0.8175, 0.7781]}, {"w": "bias", "b": [0.8242, 0.7567, 0.8571, 0.7781]}, {"w": "for", "b": [0.1429, 0.7758, 0.1674, 0.7972]}, {"w": "a", "b": [0.1734, 0.7758, 0.1826, 0.7972]}, {"w": "lower", "b": [0.1886, 0.7758, 0.2354, 0.7972]}, {"w": "variance.", "b": [0.2414, 0.7758, 0.3165, 0.7972]}, {"w": "It", "b": [0.3226, 0.7758, 0.3352, 0.7972]}, {"w": "also", "b": [0.3413, 0.7758, 0.374, 0.7972]}, {"w": "speeds", "b": [0.38, 0.7758, 0.4349, 0.7972]}, {"w": "up", "b": [0.441, 0.7758, 0.463, 0.7972]}, {"w": "training", "b": [0.469, 0.7758, 0.536, 0.7972]}, {"w": "considerably.", "b": [0.542, 0.7758, 0.6514, 0.7972]}, {"w": "This", "b": [0.6575, 0.7758, 0.6947, 0.7972]}, {"w": "technique", "b": [0.7008, 0.7758, 0.7835, 0.7972]}, {"w": "is", "b": [0.7895, 0.7758, 0.8027, 0.7972]}, {"w": "called", "b": [0.8088, 0.7758, 0.8572, 0.7972]}, {"w": "Stochastic", "b": [0.1429, 0.7946, 0.2233, 0.8162]}, {"w": "Gradient", "b": [0.228, 0.7946, 0.3005, 0.8162]}, {"w": "Boosting.", "b": [0.3053, 0.7946, 0.3795, 0.8162]}]}, {"id": "b_5", "type": "paragraph", "text": "Boosting | 209", "words": [{"w": "Boosting", "b": [0.7435, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "209", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 236, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "18 “Stacked Generalization,” D. Wolpert (1992).", "words": [{"w": "18", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Stacked", "b": [0.1587, 0.8749, 0.2137, 0.8912]}, {"w": "Generalization,”", "b": [0.2173, 0.8749, 0.3189, 0.8912]}, {"w": "D.", "b": [0.3225, 0.8749, 0.3372, 0.8912]}, {"w": "Wolpert", "b": [0.3408, 0.8749, 0.3926, 0.8912]}, {"w": "(1992).", "b": [0.3962, 0.8749, 0.4412, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "It is possible to use Gradient Boosting with other cost functions. This is controlled by the loss hyperparameter (see Scikit-Learn’s documentation for more details).", "words": [{"w": "It", "b": [0.2714, 0.0793, 0.283, 0.0989]}, {"w": "is", "b": [0.29, 0.0793, 0.3021, 0.0989]}, {"w": "possible", "b": [0.3091, 0.0793, 0.3704, 0.0989]}, {"w": "to", "b": [0.3774, 0.0793, 0.393, 0.0989]}, {"w": "use", "b": [0.3999, 0.0793, 0.4251, 0.0989]}, {"w": "Gradient", "b": [0.4321, 0.0793, 0.5003, 0.0989]}, {"w": "Boosting", "b": [0.5073, 0.0793, 0.5756, 0.0989]}, {"w": "with", "b": [0.5826, 0.0793, 0.6167, 0.0989]}, {"w": "other", "b": [0.6237, 0.0793, 0.6645, 0.0989]}, {"w": "cost", "b": [0.6715, 0.0793, 0.7021, 0.0989]}, {"w": "functions.", "b": [0.7091, 0.0793, 0.7857, 0.0989]}, {"w": "This", "b": [0.2714, 0.0975, 0.3054, 0.1171]}, {"w": "is", "b": [0.3127, 0.0975, 0.3248, 0.1171]}, {"w": "controlled", "b": [0.332, 0.0975, 0.4103, 0.1171]}, {"w": "by", "b": [0.4175, 0.0975, 0.4359, 0.1171]}, {"w": "the", "b": [0.4432, 0.0975, 0.4673, 0.1171]}, {"w": "loss", "b": [0.4745, 0.1004, 0.5107, 0.1142]}, {"w": "hyperparameter", "b": [0.518, 0.0975, 0.64, 0.1171]}, {"w": "(see", "b": [0.6473, 0.0975, 0.6771, 0.1171]}, {"w": "Scikit-Learn’s", "b": [0.6843, 0.0975, 0.7857, 0.1171]}, {"w": "documentation", "b": [0.2714, 0.1149, 0.388, 0.1345]}, {"w": "for", "b": [0.3923, 0.1149, 0.4147, 0.1345]}, {"w": "more", "b": [0.419, 0.1149, 0.4595, 0.1345]}, {"w": "details).", "b": [0.4638, 0.1149, 0.524, 0.1345]}]}, {"id": "b_2", "type": "paragraph", "text": "It is worth noting that an optimized implementation of Gradient Boosting is available in the popular python library XGBoost, which stands for Extreme Gradient Boosting. This package was initially developed by Tianqi Chen as part of the Distributed (Deep) Machine Learning Community (DMLC), and it aims at being extremely fast, scalable and portable. In fact, XGBoost is often an important component of the winning entries in ML competitions. XGBoost’s API is quite similar to Scikit-Learn’s:", "words": [{"w": "It", "b": [0.1429, 0.1779, 0.1555, 0.1993]}, {"w": "is", "b": [0.1605, 0.1779, 0.1738, 0.1993]}, {"w": "worth", "b": [0.1788, 0.1779, 0.2289, 0.1993]}, {"w": "noting", "b": [0.234, 0.1779, 0.2891, 0.1993]}, {"w": "that", "b": [0.2941, 0.1779, 0.3267, 0.1993]}, {"w": "an", "b": [0.3318, 0.1779, 0.3523, 0.1993]}, {"w": "optimized", "b": [0.3574, 0.1779, 0.4421, 0.1993]}, {"w": "implementation", "b": [0.4471, 0.1779, 0.5804, 0.1993]}, {"w": "of", "b": [0.5854, 0.1779, 0.6022, 0.1993]}, {"w": "Gradient", "b": [0.6073, 0.1779, 0.6819, 0.1993]}, {"w": "Boosting", "b": [0.6869, 0.1779, 0.7615, 0.1993]}, {"w": "is", "b": [0.7666, 0.1779, 0.7798, 0.1993]}, {"w": "available", "b": [0.7849, 0.1779, 0.8571, 0.1993]}, {"w": "in", "b": [0.1428, 0.197, 0.1598, 0.2184]}, {"w": "the", "b": [0.1653, 0.197, 0.1916, 0.2184]}, {"w": "popular", "b": [0.197, 0.197, 0.2627, 0.2184]}, {"w": "python", "b": [0.2681, 0.197, 0.3281, 0.2184]}, {"w": "library", "b": [0.3336, 0.197, 0.3898, 0.2184]}, {"w": "XGBoost,", "b": [0.3952, 0.1968, 0.4714, 0.2184]}, {"w": "which", "b": [0.4768, 0.197, 0.5278, 0.2184]}, {"w": "stands", "b": [0.5332, 0.197, 0.5864, 0.2184]}, {"w": "for", "b": [0.5918, 0.197, 0.6163, 0.2184]}, {"w": "Extreme", "b": [0.6218, 0.197, 0.6923, 0.2184]}, {"w": "Gradient", "b": [0.6977, 0.197, 0.7723, 0.2184]}, {"w": "Boosting.", "b": [0.7777, 0.197, 0.8571, 0.2184]}, {"w": "This", "b": [0.1429, 0.216, 0.1801, 0.2374]}, {"w": "package", "b": [0.1848, 0.216, 0.2518, 0.2374]}, {"w": "was", "b": [0.2565, 0.216, 0.2876, 0.2374]}, {"w": "initially", "b": [0.2923, 0.216, 0.356, 0.2374]}, {"w": "developed", "b": [0.3608, 0.216, 0.4458, 0.2374]}, {"w": "by", "b": [0.4505, 0.216, 0.4707, 0.2374]}, {"w": "Tianqi", "b": [0.4754, 0.216, 0.5297, 0.2374]}, {"w": "Chen", "b": [0.5344, 0.216, 0.5797, 0.2374]}, {"w": "as", "b": [0.5844, 0.216, 0.6012, 0.2374]}, {"w": "part", "b": [0.6059, 0.216, 0.6401, 0.2374]}, {"w": "of", "b": [0.6448, 0.216, 0.6616, 0.2374]}, {"w": "the", "b": [0.6663, 0.216, 0.6927, 0.2374]}, {"w": "Distributed", "b": [0.6974, 0.216, 0.7934, 0.2374]}, {"w": "(Deep)", "b": [0.7982, 0.216, 0.8565, 0.2374]}, {"w": "Machine", "b": [0.1429, 0.2351, 0.216, 0.2565]}, {"w": "Learning", "b": [0.2215, 0.2351, 0.2965, 0.2565]}, {"w": "Community", "b": [0.302, 0.2351, 0.4042, 0.2565]}, {"w": "(DMLC),", "b": [0.4097, 0.2351, 0.4878, 0.2565]}, {"w": "and", "b": [0.4933, 0.2351, 0.5249, 0.2565]}, {"w": "it", "b": [0.5304, 0.2351, 0.5423, 0.2565]}, {"w": "aims", "b": [0.5478, 0.2351, 0.5872, 0.2565]}, {"w": "at", "b": [0.5927, 0.2351, 0.6078, 0.2565]}, {"w": "being", "b": [0.6133, 0.2351, 0.6595, 0.2565]}, {"w": "extremely", "b": [0.665, 0.2351, 0.7474, 0.2565]}, {"w": "fast,", "b": [0.7529, 0.2351, 0.7869, 0.2565]}, {"w": "scalable", "b": [0.7924, 0.2351, 0.8571, 0.2565]}, {"w": "and", "b": [0.1429, 0.2541, 0.1744, 0.2755]}, {"w": "portable.", "b": [0.1835, 0.2541, 0.2578, 0.2755]}, {"w": "In", "b": [0.2669, 0.2541, 0.2854, 0.2755]}, {"w": "fact,", "b": [0.2946, 0.2541, 0.3298, 0.2755]}, {"w": "XGBoost", "b": [0.3389, 0.2541, 0.4147, 0.2755]}, {"w": "is", "b": [0.4239, 0.2541, 0.4371, 0.2755]}, {"w": "often", "b": [0.4462, 0.2541, 0.4896, 0.2755]}, {"w": "an", "b": [0.4988, 0.2541, 0.5193, 0.2755]}, {"w": "important", "b": [0.5285, 0.2541, 0.6128, 0.2755]}, {"w": "component", "b": [0.622, 0.2541, 0.7172, 0.2755]}, {"w": "of", "b": [0.7264, 0.2541, 0.7432, 0.2755]}, {"w": "the", "b": [0.7523, 0.2541, 0.7786, 0.2755]}, {"w": "winning", "b": [0.7878, 0.2541, 0.8571, 0.2755]}, {"w": "entries", "b": [0.1429, 0.2732, 0.1989, 0.2946]}, {"w": "in", "b": [0.2036, 0.2732, 0.2206, 0.2946]}, {"w": "ML", "b": [0.2253, 0.2732, 0.2551, 0.2946]}, {"w": "competitions.", "b": [0.2598, 0.2732, 0.374, 0.2946]}, {"w": "XGBoost’s", "b": [0.3787, 0.2732, 0.4642, 0.2946]}, {"w": "API", "b": [0.469, 0.2732, 0.5022, 0.2946]}, {"w": "is", "b": [0.5069, 0.2732, 0.5202, 0.2946]}, {"w": "quite", "b": [0.5249, 0.2732, 0.5674, 0.2946]}, {"w": "similar", "b": [0.5721, 0.2732, 0.6301, 0.2946]}, {"w": "to", "b": [0.6349, 0.2732, 0.6519, 0.2946]}, {"w": "Scikit-Learn’s:", "b": [0.6566, 0.2732, 0.7722, 0.2946]}]}, {"id": "b_3", "type": "paragraph", "text": "import xgboost", "words": [{"w": "import", "b": [0.1766, 0.3051, 0.2272, 0.318]}, {"w": "xgboost", "b": [0.2356, 0.3051, 0.2946, 0.318]}]}, {"id": "b_4", "type": "paragraph", "text": "xgb_reg = xgboost.XGBRegressor() xgb_reg.fit(X_train, y_train) y_pred = xgb_reg.predict(X_val)", "words": [{"w": "xgb_reg", "b": [0.1766, 0.336, 0.2356, 0.3488]}, {"w": "=", "b": [0.244, 0.336, 0.2525, 0.3488]}, {"w": "xgboost.XGBRegressor()", "b": [0.2609, 0.336, 0.4464, 0.3488]}, {"w": "xgb_reg.fit(X_train,", "b": [0.1766, 0.3514, 0.3452, 0.3642]}, {"w": "y_train)", "b": [0.3537, 0.3514, 0.4211, 0.3642]}, {"w": "y_pred", "b": [0.1766, 0.3668, 0.2272, 0.3797]}, {"w": "=", "b": [0.2356, 0.3668, 0.244, 0.3797]}, {"w": "xgb_reg.predict(X_val)", "b": [0.2525, 0.3668, 0.438, 0.3797]}]}, {"id": "b_5", "type": "paragraph", "text": "XGBoost also offers several nice features, such as automatically taking care of early stopping:", "words": [{"w": "XGBoost", "b": [0.1428, 0.3875, 0.2186, 0.4089]}, {"w": "also", "b": [0.2257, 0.3875, 0.2583, 0.4089]}, {"w": "offers", "b": [0.2654, 0.3875, 0.3125, 0.4089]}, {"w": "several", "b": [0.3196, 0.3875, 0.3767, 0.4089]}, {"w": "nice", "b": [0.3837, 0.3875, 0.4184, 0.4089]}, {"w": "features,", "b": [0.4254, 0.3875, 0.4955, 0.4089]}, {"w": "such", "b": [0.5026, 0.3875, 0.5412, 0.4089]}, {"w": "as", "b": [0.5482, 0.3875, 0.565, 0.4089]}, {"w": "automatically", "b": [0.572, 0.3875, 0.6846, 0.4089]}, {"w": "taking", "b": [0.6916, 0.3875, 0.7442, 0.4089]}, {"w": "care", "b": [0.7512, 0.3875, 0.7858, 0.4089]}, {"w": "of", "b": [0.7928, 0.3875, 0.8096, 0.4089]}, {"w": "early", "b": [0.8166, 0.3875, 0.8571, 0.4089]}, {"w": "stopping:", "b": [0.1429, 0.4065, 0.2208, 0.4279]}]}, {"id": "b_6", "type": "paragraph", "text": "xgb_reg.fit(X_train, y_train, eval_set=[(X_val, y_val)], early_stopping_rounds=2) y_pred = xgb_reg.predict(X_val)", "words": [{"w": "xgb_reg.fit(X_train,", "b": [0.1766, 0.4385, 0.3452, 0.4513]}, {"w": "y_train,", "b": [0.3537, 0.4385, 0.4211, 0.4513]}, {"w": "eval_set=[(X_val,", "b": [0.2778, 0.4539, 0.4211, 0.4667]}, {"w": "y_val)],", "b": [0.4296, 0.4539, 0.497, 0.4667]}, {"w": "early_stopping_rounds=2)", "b": [0.5055, 0.4539, 0.7078, 0.4667]}, {"w": "y_pred", "b": [0.1766, 0.4693, 0.2272, 0.4822]}, {"w": "=", "b": [0.2356, 0.4693, 0.244, 0.4822]}, {"w": "xgb_reg.predict(X_val)", "b": [0.2525, 0.4693, 0.438, 0.4822]}]}, {"id": "b_7", "type": "paragraph", "text": "You should definitely check it out!", "words": [{"w": "You", "b": [0.1429, 0.4899, 0.1752, 0.5114]}, {"w": "should", "b": [0.1799, 0.4899, 0.2367, 0.5114]}, {"w": "definitely", "b": [0.2414, 0.4899, 0.32, 0.5114]}, {"w": "check", "b": [0.3248, 0.4899, 0.3727, 0.5114]}, {"w": "it", "b": [0.3774, 0.4899, 0.3894, 0.5114]}, {"w": "out!", "b": [0.3941, 0.4899, 0.4279, 0.5114]}]}, {"id": "b_8", "type": "paragraph", "text": "Stacking", "words": [{"w": "Stacking", "b": [0.1428, 0.5243, 0.2489, 0.5586]}]}, {"id": "b_9", "type": "paragraph", "text": "The last Ensemble method we will discuss in this chapter is called stacking (short for stacked generalization).18 It is based on a simple idea: instead of using trivial functions (such as hard voting) to aggregate the predictions of all predictors in an ensemble, why don’t we train a model to perform this aggregation? Figure 7-12 shows such an ensemble performing a regression task on a new instance. Each of the bottom three predictors predicts a different value (3.1, 2.7, and 2.9), and then the final predictor (called a blender, or a meta learner) takes these predictions as inputs and makes the final prediction (3.0).", "words": [{"w": "The", "b": [0.1429, 0.5655, 0.1757, 0.5869]}, {"w": "last", "b": [0.1815, 0.5655, 0.2099, 0.5869]}, {"w": "Ensemble", "b": [0.2157, 0.5655, 0.2972, 0.5869]}, {"w": "method", "b": [0.3031, 0.5655, 0.3681, 0.5869]}, {"w": "we", "b": [0.3739, 0.5655, 0.397, 0.5869]}, {"w": "will", "b": [0.4028, 0.5655, 0.4332, 0.5869]}, {"w": "discuss", "b": [0.439, 0.5655, 0.4984, 0.5869]}, {"w": "in", "b": [0.5042, 0.5655, 0.5212, 0.5869]}, {"w": "this", "b": [0.527, 0.5655, 0.5577, 0.5869]}, {"w": "chapter", "b": [0.5636, 0.5655, 0.6261, 0.5869]}, {"w": "is", "b": [0.6319, 0.5655, 0.6451, 0.5869]}, {"w": "called", "b": [0.651, 0.5655, 0.6993, 0.5869]}, {"w": "stacking", "b": [0.7051, 0.5653, 0.7703, 0.5869]}, {"w": "(short", "b": [0.7761, 0.5655, 0.8268, 0.5869]}, {"w": "for", "b": [0.8326, 0.5655, 0.8571, 0.5869]}, {"w": "stacked", "b": [0.1429, 0.5844, 0.2021, 0.606]}, {"w": "generalization).18", "b": [0.2068, 0.5844, 0.3458, 0.606]}, {"w": "It", "b": [0.351, 0.5846, 0.3637, 0.606]}, {"w": "is", "b": [0.3689, 0.5846, 0.3821, 0.606]}, {"w": "based", "b": [0.3873, 0.5846, 0.4345, 0.606]}, {"w": "on", "b": [0.4397, 0.5846, 0.4617, 0.606]}, {"w": "a", "b": [0.4669, 0.5846, 0.476, 0.606]}, {"w": "simple", "b": [0.4812, 0.5846, 0.5362, 0.606]}, {"w": "idea:", "b": [0.5413, 0.5846, 0.5807, 0.606]}, {"w": "instead", "b": [0.5859, 0.5846, 0.6458, 0.606]}, {"w": "of", "b": [0.651, 0.5846, 0.6678, 0.606]}, {"w": "using", "b": [0.673, 0.5846, 0.7184, 0.606]}, {"w": "trivial", "b": [0.7236, 0.5846, 0.7729, 0.606]}, {"w": "functions", "b": [0.7781, 0.5846, 0.8571, 0.606]}, {"w": "(such", "b": [0.1429, 0.6036, 0.1887, 0.625]}, {"w": "as", "b": [0.1959, 0.6036, 0.2126, 0.625]}, {"w": "hard", "b": [0.2198, 0.6036, 0.2588, 0.625]}, {"w": "voting)", "b": [0.2659, 0.6036, 0.3265, 0.625]}, {"w": "to", "b": [0.3336, 0.6036, 0.3506, 0.625]}, {"w": "aggregate", "b": [0.3577, 0.6036, 0.4367, 0.625]}, {"w": "the", "b": [0.4438, 0.6036, 0.4701, 0.625]}, {"w": "predictions", "b": [0.4773, 0.6036, 0.5718, 0.625]}, {"w": "of", "b": [0.5789, 0.6036, 0.5957, 0.625]}, {"w": "all", "b": [0.6029, 0.6036, 0.6225, 0.625]}, {"w": "predictors", "b": [0.6297, 0.6036, 0.7149, 0.625]}, {"w": "in", "b": [0.7221, 0.6036, 0.7391, 0.625]}, {"w": "an", "b": [0.7462, 0.6036, 0.7667, 0.625]}, {"w": "ensemble,", "b": [0.7739, 0.6036, 0.8571, 0.625]}, {"w": "why", "b": [0.1429, 0.6227, 0.1773, 0.6441]}, {"w": "don’t", "b": [0.1837, 0.6227, 0.2253, 0.6441]}, {"w": "we", "b": [0.2316, 0.6227, 0.2547, 0.6441]}, {"w": "train", "b": [0.2611, 0.6227, 0.3013, 0.6441]}, {"w": "a", "b": [0.3076, 0.6227, 0.3167, 0.6441]}, {"w": "model", "b": [0.3231, 0.6227, 0.3759, 0.6441]}, {"w": "to", "b": [0.3822, 0.6227, 0.3992, 0.6441]}, {"w": "perform", "b": [0.4055, 0.6227, 0.4746, 0.6441]}, {"w": "this", "b": [0.4809, 0.6227, 0.5116, 0.6441]}, {"w": "aggregation?", "b": [0.518, 0.6227, 0.6236, 0.6441]}, {"w": "Figure", "b": [0.6299, 0.6227, 0.6839, 0.6441]}, {"w": "7-12", "b": [0.6902, 0.6227, 0.7276, 0.6441]}, {"w": "shows", "b": [0.734, 0.6227, 0.7853, 0.6441]}, {"w": "such", "b": [0.7916, 0.6227, 0.8303, 0.6441]}, {"w": "an", "b": [0.8366, 0.6227, 0.8571, 0.6441]}, {"w": "ensemble", "b": [0.1429, 0.6417, 0.2214, 0.6631]}, {"w": "performing", "b": [0.2278, 0.6417, 0.3236, 0.6631]}, {"w": "a", "b": [0.33, 0.6417, 0.3392, 0.6631]}, {"w": "regression", "b": [0.3456, 0.6417, 0.4314, 0.6631]}, {"w": "task", "b": [0.4378, 0.6417, 0.4713, 0.6631]}, {"w": "on", "b": [0.4777, 0.6417, 0.4997, 0.6631]}, {"w": "a", "b": [0.5061, 0.6417, 0.5153, 0.6631]}, {"w": "new", "b": [0.5217, 0.6417, 0.5562, 0.6631]}, {"w": "instance.", "b": [0.5626, 0.6417, 0.6365, 0.6631]}, {"w": "Each", "b": [0.643, 0.6417, 0.6839, 0.6631]}, {"w": "of", "b": [0.6903, 0.6417, 0.7071, 0.6631]}, {"w": "the", "b": [0.7135, 0.6417, 0.7398, 0.6631]}, {"w": "bottom", "b": [0.7462, 0.6417, 0.8078, 0.6631]}, {"w": "three", "b": [0.8142, 0.6417, 0.8572, 0.6631]}, {"w": "predictors", "b": [0.1429, 0.6608, 0.2281, 0.6822]}, {"w": "predicts", "b": [0.2347, 0.6608, 0.3016, 0.6822]}, {"w": "a", "b": [0.3082, 0.6608, 0.3173, 0.6822]}, {"w": "different", "b": [0.3239, 0.6608, 0.3956, 0.6822]}, {"w": "value", "b": [0.4022, 0.6608, 0.4461, 0.6822]}, {"w": "(3.1,", "b": [0.4527, 0.6608, 0.4894, 0.6822]}, {"w": "2.7,", "b": [0.496, 0.6608, 0.5255, 0.6822]}, {"w": "and", "b": [0.5321, 0.6608, 0.5636, 0.6822]}, {"w": "2.9),", "b": [0.5702, 0.6608, 0.6069, 0.6822]}, {"w": "and", "b": [0.6135, 0.6608, 0.645, 0.6822]}, {"w": "then", "b": [0.6516, 0.6608, 0.6893, 0.6822]}, {"w": "the", "b": [0.6959, 0.6608, 0.7222, 0.6822]}, {"w": "final", "b": [0.7288, 0.6608, 0.7664, 0.6822]}, {"w": "predictor", "b": [0.773, 0.6608, 0.8506, 0.6822]}, {"w": "(called", "b": [0.1429, 0.6798, 0.1984, 0.7012]}, {"w": "a", "b": [0.2049, 0.6798, 0.214, 0.7012]}, {"w": "blender,", "b": [0.2205, 0.6796, 0.286, 0.7012]}, {"w": "or", "b": [0.2925, 0.6798, 0.3108, 0.7012]}, {"w": "a", "b": [0.3173, 0.6798, 0.3265, 0.7012]}, {"w": "meta", "b": [0.3329, 0.6796, 0.3738, 0.7012]}, {"w": "learner)", "b": [0.3803, 0.6796, 0.4454, 0.7012]}, {"w": "takes", "b": [0.4519, 0.6798, 0.4942, 0.7012]}, {"w": "these", "b": [0.5007, 0.6798, 0.5435, 0.7012]}, {"w": "predictions", "b": [0.55, 0.6798, 0.6445, 0.7012]}, {"w": "as", "b": [0.651, 0.6798, 0.6678, 0.7012]}, {"w": "inputs", "b": [0.6742, 0.6798, 0.7268, 0.7012]}, {"w": "and", "b": [0.7333, 0.6798, 0.7648, 0.7012]}, {"w": "makes", "b": [0.7713, 0.6798, 0.8243, 0.7012]}, {"w": "the", "b": [0.8308, 0.6798, 0.8571, 0.7012]}, {"w": "final", "b": [0.1428, 0.6989, 0.1804, 0.7203]}, {"w": "prediction", "b": [0.1851, 0.6989, 0.272, 0.7203]}, {"w": "(3.0).", "b": [0.2767, 0.6989, 0.3206, 0.7203]}]}, {"id": "b_10", "type": "paragraph", "text": "210 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "210", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 237, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "19 Alternatively, it is possible to use out-of-fold predictions. In some contexts this is called stacking, while using a hold-out set is called blending. However, for many people these terms are synonymous.", "words": [{"w": "19", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "Alternatively,", "b": [0.1587, 0.8598, 0.2435, 0.8761]}, {"w": "it", "b": [0.2471, 0.8598, 0.2562, 0.8761]}, {"w": "is", "b": [0.2598, 0.8598, 0.2699, 0.8761]}, {"w": "possible", "b": [0.2735, 0.8598, 0.3246, 0.8761]}, {"w": "to", "b": [0.3282, 0.8598, 0.3412, 0.8761]}, {"w": "use", "b": [0.3448, 0.8598, 0.3658, 0.8761]}, {"w": "out-of-fold", "b": [0.3694, 0.8598, 0.44, 0.8761]}, {"w": "predictions.", "b": [0.4436, 0.8598, 0.5192, 0.8761]}, {"w": "In", "b": [0.5228, 0.8598, 0.5369, 0.8761]}, {"w": "some", "b": [0.5405, 0.8598, 0.5742, 0.8761]}, {"w": "contexts", "b": [0.5778, 0.8598, 0.6307, 0.8761]}, {"w": "this", "b": [0.6343, 0.8598, 0.6577, 0.8761]}, {"w": "is", "b": [0.6613, 0.8598, 0.6714, 0.8761]}, {"w": "called", "b": [0.675, 0.8598, 0.7119, 0.8761]}, {"w": "stacking,", "b": [0.7155, 0.8596, 0.7688, 0.8761]}, {"w": "while", "b": [0.7724, 0.8598, 0.8067, 0.8761]}, {"w": "using", "b": [0.8103, 0.8598, 0.845, 0.8761]}, {"w": "a", "b": [0.8486, 0.8598, 0.8555, 0.8761]}, {"w": "hold-out", "b": [0.1587, 0.8749, 0.2147, 0.8912]}, {"w": "set", "b": [0.2183, 0.8749, 0.2357, 0.8912]}, {"w": "is", "b": [0.2393, 0.8749, 0.2494, 0.8912]}, {"w": "called", "b": [0.253, 0.8749, 0.2899, 0.8912]}, {"w": "blending.", "b": [0.2935, 0.8748, 0.3501, 0.8912]}, {"w": "However,", "b": [0.3537, 0.8749, 0.4138, 0.8912]}, {"w": "for", "b": [0.4174, 0.8749, 0.4361, 0.8912]}, {"w": "many", "b": [0.4397, 0.8749, 0.4752, 0.8912]}, {"w": "people", "b": [0.4788, 0.8749, 0.5211, 0.8912]}, {"w": "these", "b": [0.5247, 0.8749, 0.5573, 0.8912]}, {"w": "terms", "b": [0.5609, 0.8749, 0.5972, 0.8912]}, {"w": "are", "b": [0.6008, 0.8749, 0.6204, 0.8912]}, {"w": "synonymous.", "b": [0.624, 0.8749, 0.7085, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 7-12. Aggregating predictions using a blending predictor", "words": [{"w": "Figure", "b": [0.1429, 0.3886, 0.1943, 0.4103]}, {"w": "7-12.", "b": [0.1991, 0.3886, 0.2407, 0.4103]}, {"w": "Aggregating", "b": [0.2455, 0.3886, 0.3424, 0.4103]}, {"w": "predictions", "b": [0.3472, 0.3886, 0.436, 0.4103]}, {"w": "using", "b": [0.4407, 0.3886, 0.4837, 0.4103]}, {"w": "a", "b": [0.4885, 0.3886, 0.4987, 0.4103]}, {"w": "blending", "b": [0.5035, 0.3886, 0.5731, 0.4103]}, {"w": "predictor", "b": [0.5778, 0.3886, 0.6505, 0.4103]}]}, {"id": "b_2", "type": "paragraph", "text": "To train the blender, a common approach is to use a hold-out set.19 Let’s see how it works. First, the training set is split in two subsets. The first subset is used to train the predictors in the first layer (see Figure 7-13).", "words": [{"w": "To", "b": [0.1429, 0.426, 0.1643, 0.4475]}, {"w": "train", "b": [0.171, 0.426, 0.2112, 0.4475]}, {"w": "the", "b": [0.218, 0.426, 0.2443, 0.4475]}, {"w": "blender,", "b": [0.251, 0.426, 0.3181, 0.4475]}, {"w": "a", "b": [0.3249, 0.426, 0.334, 0.4475]}, {"w": "common", "b": [0.3407, 0.426, 0.4163, 0.4475]}, {"w": "approach", "b": [0.423, 0.426, 0.501, 0.4475]}, {"w": "is", "b": [0.5078, 0.426, 0.521, 0.4475]}, {"w": "to", "b": [0.5277, 0.426, 0.5447, 0.4475]}, {"w": "use", "b": [0.5514, 0.426, 0.579, 0.4475]}, {"w": "a", "b": [0.5857, 0.426, 0.5948, 0.4475]}, {"w": "hold-out", "b": [0.6016, 0.426, 0.675, 0.4475]}, {"w": "set.19", "b": [0.6818, 0.426, 0.7208, 0.4475]}, {"w": "Let’s", "b": [0.7275, 0.426, 0.7637, 0.4475]}, {"w": "see", "b": [0.7704, 0.426, 0.7957, 0.4475]}, {"w": "how", "b": [0.8025, 0.426, 0.8385, 0.4475]}, {"w": "it", "b": [0.8452, 0.426, 0.8571, 0.4475]}, {"w": "works.", "b": [0.1428, 0.4451, 0.1982, 0.4665]}, {"w": "First,", "b": [0.2032, 0.4451, 0.2462, 0.4665]}, {"w": "the", "b": [0.2512, 0.4451, 0.2775, 0.4665]}, {"w": "training", "b": [0.2825, 0.4451, 0.3494, 0.4665]}, {"w": "set", "b": [0.3544, 0.4451, 0.3772, 0.4665]}, {"w": "is", "b": [0.3822, 0.4451, 0.3954, 0.4665]}, {"w": "split", "b": [0.4004, 0.4451, 0.4361, 0.4665]}, {"w": "in", "b": [0.4411, 0.4451, 0.4581, 0.4665]}, {"w": "two", "b": [0.463, 0.4451, 0.4943, 0.4665]}, {"w": "subsets.", "b": [0.4992, 0.4451, 0.5637, 0.4665]}, {"w": "The", "b": [0.5687, 0.4451, 0.6015, 0.4665]}, {"w": "first", "b": [0.6065, 0.4451, 0.64, 0.4665]}, {"w": "subset", "b": [0.6449, 0.4451, 0.6971, 0.4665]}, {"w": "is", "b": [0.702, 0.4451, 0.7152, 0.4665]}, {"w": "used", "b": [0.7202, 0.4451, 0.7588, 0.4665]}, {"w": "to", "b": [0.7637, 0.4451, 0.7807, 0.4665]}, {"w": "train", "b": [0.7856, 0.4451, 0.8258, 0.4665]}, {"w": "the", "b": [0.8308, 0.4451, 0.8571, 0.4665]}, {"w": "predictors", "b": [0.1429, 0.4641, 0.2281, 0.4855]}, {"w": "in", "b": [0.2328, 0.4641, 0.2498, 0.4855]}, {"w": "the", "b": [0.2545, 0.4641, 0.2809, 0.4855]}, {"w": "first", "b": [0.2856, 0.4641, 0.3191, 0.4855]}, {"w": "layer", "b": [0.3238, 0.4641, 0.364, 0.4855]}, {"w": "(see", "b": [0.3687, 0.4641, 0.4013, 0.4855]}, {"w": "Figure", "b": [0.406, 0.4641, 0.46, 0.4855]}, {"w": "7-13).", "b": [0.4648, 0.4641, 0.5141, 0.4855]}]}, {"id": "b_3", "type": "equation", "text": "Figure 7-13. Training the first layer", "words": [{"w": "Figure", "b": [0.1429, 0.7245, 0.1943, 0.7461]}, {"w": "7-13.", "b": [0.1991, 0.7245, 0.2407, 0.7461]}, {"w": "Training", "b": [0.2455, 0.7245, 0.3147, 0.7461]}, {"w": "the", "b": [0.3195, 0.7245, 0.3446, 0.7461]}, {"w": "first", "b": [0.3493, 0.7245, 0.3814, 0.7461]}, {"w": "layer", "b": [0.3862, 0.7245, 0.4261, 0.7461]}]}, {"id": "b_4", "type": "paragraph", "text": "Next, the first layer predictors are used to make predictions on the second (held-out) set (see Figure 7-14). This ensures that the predictions are “clean,” since the predictors never saw these instances during training. Now for each instance in the hold-out set", "words": [{"w": "Next,", "b": [0.1429, 0.7619, 0.1876, 0.7833]}, {"w": "the", "b": [0.193, 0.7619, 0.2194, 0.7833]}, {"w": "first", "b": [0.2248, 0.7619, 0.2582, 0.7833]}, {"w": "layer", "b": [0.2637, 0.7619, 0.3038, 0.7833]}, {"w": "predictors", "b": [0.3092, 0.7619, 0.3945, 0.7833]}, {"w": "are", "b": [0.3999, 0.7619, 0.4256, 0.7833]}, {"w": "used", "b": [0.431, 0.7619, 0.4696, 0.7833]}, {"w": "to", "b": [0.475, 0.7619, 0.492, 0.7833]}, {"w": "make", "b": [0.4974, 0.7619, 0.5428, 0.7833]}, {"w": "predictions", "b": [0.5482, 0.7619, 0.6427, 0.7833]}, {"w": "on", "b": [0.6481, 0.7619, 0.6701, 0.7833]}, {"w": "the", "b": [0.6755, 0.7619, 0.7019, 0.7833]}, {"w": "second", "b": [0.7073, 0.7619, 0.7656, 0.7833]}, {"w": "(held-out)", "b": [0.771, 0.7619, 0.8571, 0.7833]}, {"w": "set", "b": [0.1429, 0.7809, 0.1657, 0.8024]}, {"w": "(see", "b": [0.1704, 0.7809, 0.203, 0.8024]}, {"w": "Figure", "b": [0.2078, 0.7809, 0.2618, 0.8024]}, {"w": "7-14).", "b": [0.2665, 0.7809, 0.3159, 0.8024]}, {"w": "This", "b": [0.3206, 0.7809, 0.3579, 0.8024]}, {"w": "ensures", "b": [0.3626, 0.7809, 0.4258, 0.8024]}, {"w": "that", "b": [0.4305, 0.7809, 0.4631, 0.8024]}, {"w": "the", "b": [0.4678, 0.7809, 0.4941, 0.8024]}, {"w": "predictions", "b": [0.4989, 0.7809, 0.5934, 0.8024]}, {"w": "are", "b": [0.5981, 0.7809, 0.6238, 0.8024]}, {"w": "“clean,”", "b": [0.6286, 0.7809, 0.6888, 0.8024]}, {"w": "since", "b": [0.6936, 0.7809, 0.7359, 0.8024]}, {"w": "the", "b": [0.7406, 0.7809, 0.7669, 0.8024]}, {"w": "predictors", "b": [0.7716, 0.7809, 0.8569, 0.8024]}, {"w": "never", "b": [0.1429, 0.8, 0.1893, 0.8214]}, {"w": "saw", "b": [0.1953, 0.8, 0.226, 0.8214]}, {"w": "these", "b": [0.232, 0.8, 0.2749, 0.8214]}, {"w": "instances", "b": [0.2809, 0.8, 0.3577, 0.8214]}, {"w": "during", "b": [0.3637, 0.8, 0.4202, 0.8214]}, {"w": "training.", "b": [0.4262, 0.8, 0.4979, 0.8214]}, {"w": "Now", "b": [0.5039, 0.8, 0.5438, 0.8214]}, {"w": "for", "b": [0.5498, 0.8, 0.5743, 0.8214]}, {"w": "each", "b": [0.5803, 0.8, 0.6183, 0.8214]}, {"w": "instance", "b": [0.6243, 0.8, 0.6935, 0.8214]}, {"w": "in", "b": [0.6995, 0.8, 0.7165, 0.8214]}, {"w": "the", "b": [0.7225, 0.8, 0.7488, 0.8214]}, {"w": "hold-out", "b": [0.7548, 0.8, 0.8283, 0.8214]}, {"w": "set", "b": [0.8343, 0.8, 0.8571, 0.8214]}]}, {"id": "b_5", "type": "paragraph", "text": "Stacking | 211", "words": [{"w": "Stacking", "b": [0.7454, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "211", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 238, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "there are three predicted values. We can create a new training set using these predic‐ ted values as input features (which makes this new training set three-dimensional), and keeping the target values. The blender is trained on this new training set, so it learns to predict the target value given the first layer’s predictions.", "words": [{"w": "there", "b": [0.1429, 0.0791, 0.1858, 0.1005]}, {"w": "are", "b": [0.1914, 0.0791, 0.2172, 0.1005]}, {"w": "three", "b": [0.2229, 0.0791, 0.2658, 0.1005]}, {"w": "predicted", "b": [0.2714, 0.0791, 0.3505, 0.1005]}, {"w": "values.", "b": [0.3562, 0.0791, 0.4126, 0.1005]}, {"w": "We", "b": [0.4183, 0.0791, 0.4453, 0.1005]}, {"w": "can", "b": [0.451, 0.0791, 0.4804, 0.1005]}, {"w": "create", "b": [0.486, 0.0791, 0.5354, 0.1005]}, {"w": "a", "b": [0.5411, 0.0791, 0.5502, 0.1005]}, {"w": "new", "b": [0.5559, 0.0791, 0.5904, 0.1005]}, {"w": "training", "b": [0.5961, 0.0791, 0.663, 0.1005]}, {"w": "set", "b": [0.6687, 0.0791, 0.6915, 0.1005]}, {"w": "using", "b": [0.6972, 0.0791, 0.7426, 0.1005]}, {"w": "these", "b": [0.7483, 0.0791, 0.7912, 0.1005]}, {"w": "predic‐", "b": [0.7968, 0.0791, 0.8571, 0.1005]}, {"w": "ted", "b": [0.1429, 0.0981, 0.1691, 0.1195]}, {"w": "values", "b": [0.1761, 0.0981, 0.2277, 0.1195]}, {"w": "as", "b": [0.2347, 0.0981, 0.2515, 0.1195]}, {"w": "input", "b": [0.2586, 0.0981, 0.3035, 0.1195]}, {"w": "features", "b": [0.3105, 0.0981, 0.3759, 0.1195]}, {"w": "(which", "b": [0.3829, 0.0981, 0.4411, 0.1195]}, {"w": "makes", "b": [0.4481, 0.0981, 0.5011, 0.1195]}, {"w": "this", "b": [0.5082, 0.0981, 0.5389, 0.1195]}, {"w": "new", "b": [0.5459, 0.0981, 0.5804, 0.1195]}, {"w": "training", "b": [0.5874, 0.0981, 0.6544, 0.1195]}, {"w": "set", "b": [0.6614, 0.0981, 0.6843, 0.1195]}, {"w": "three-dimensional),", "b": [0.6913, 0.0981, 0.8571, 0.1195]}, {"w": "and", "b": [0.1429, 0.1172, 0.1744, 0.1386]}, {"w": "keeping", "b": [0.1814, 0.1172, 0.2471, 0.1386]}, {"w": "the", "b": [0.254, 0.1172, 0.2803, 0.1386]}, {"w": "target", "b": [0.2873, 0.1172, 0.3355, 0.1386]}, {"w": "values.", "b": [0.3424, 0.1172, 0.3988, 0.1386]}, {"w": "The", "b": [0.4058, 0.1172, 0.4386, 0.1386]}, {"w": "blender", "b": [0.4456, 0.1172, 0.5093, 0.1386]}, {"w": "is", "b": [0.5162, 0.1172, 0.5294, 0.1386]}, {"w": "trained", "b": [0.5364, 0.1172, 0.5965, 0.1386]}, {"w": "on", "b": [0.6034, 0.1172, 0.6254, 0.1386]}, {"w": "this", "b": [0.6324, 0.1172, 0.6631, 0.1386]}, {"w": "new", "b": [0.6701, 0.1172, 0.7046, 0.1386]}, {"w": "training", "b": [0.7115, 0.1172, 0.7785, 0.1386]}, {"w": "set,", "b": [0.7854, 0.1172, 0.813, 0.1386]}, {"w": "so", "b": [0.82, 0.1172, 0.8383, 0.1386]}, {"w": "it", "b": [0.8452, 0.1172, 0.8572, 0.1386]}, {"w": "learns", "b": [0.1429, 0.1362, 0.1929, 0.1576]}, {"w": "to", "b": [0.1976, 0.1362, 0.2146, 0.1576]}, {"w": "predict", "b": [0.2193, 0.1362, 0.2786, 0.1576]}, {"w": "the", "b": [0.2833, 0.1362, 0.3097, 0.1576]}, {"w": "target", "b": [0.3144, 0.1362, 0.3626, 0.1576]}, {"w": "value", "b": [0.3673, 0.1362, 0.4113, 0.1576]}, {"w": "given", "b": [0.416, 0.1362, 0.4612, 0.1576]}, {"w": "the", "b": [0.466, 0.1362, 0.4923, 0.1576]}, {"w": "first", "b": [0.497, 0.1362, 0.5305, 0.1576]}, {"w": "layer’s", "b": [0.5352, 0.1362, 0.5857, 0.1576]}, {"w": "predictions.", "b": [0.5905, 0.1362, 0.6897, 0.1576]}]}, {"id": "b_1", "type": "equation", "text": "Figure 7-14. Training the blender", "words": [{"w": "Figure", "b": [0.1429, 0.5125, 0.1943, 0.5341]}, {"w": "7-14.", "b": [0.1991, 0.5125, 0.2407, 0.5341]}, {"w": "Training", "b": [0.2455, 0.5125, 0.3147, 0.5341]}, {"w": "the", "b": [0.3195, 0.5125, 0.3445, 0.5341]}, {"w": "blender", "b": [0.3493, 0.5125, 0.4101, 0.5341]}]}, {"id": "b_2", "type": "paragraph", "text": "It is actually possible to train several different blenders this way (e.g., one using Lin‐ ear Regression, another using Random Forest Regression, and so on): we get a whole layer of blenders. The trick is to split the training set into three subsets: the first one is used to train the first layer, the second one is used to create the training set used to train the second layer (using predictions made by the predictors of the first layer), and the third one is used to create the training set to train the third layer (using pre‐ dictions made by the predictors of the second layer). Once this is done, we can make a prediction for a new instance by going through each layer sequentially, as shown in Figure 7-15.", "words": [{"w": "It", "b": [0.1429, 0.5499, 0.1555, 0.5713]}, {"w": "is", "b": [0.1615, 0.5499, 0.1747, 0.5713]}, {"w": "actually", "b": [0.1807, 0.5499, 0.2454, 0.5713]}, {"w": "possible", "b": [0.2514, 0.5499, 0.3185, 0.5713]}, {"w": "to", "b": [0.3245, 0.5499, 0.3415, 0.5713]}, {"w": "train", "b": [0.3475, 0.5499, 0.3877, 0.5713]}, {"w": "several", "b": [0.3937, 0.5499, 0.4508, 0.5713]}, {"w": "different", "b": [0.4568, 0.5499, 0.5285, 0.5713]}, {"w": "blenders", "b": [0.5345, 0.5499, 0.6059, 0.5713]}, {"w": "this", "b": [0.6119, 0.5499, 0.6426, 0.5713]}, {"w": "way", "b": [0.6486, 0.5499, 0.6812, 0.5713]}, {"w": "(e.g.,", "b": [0.6872, 0.5499, 0.7272, 0.5713]}, {"w": "one", "b": [0.7332, 0.5499, 0.7641, 0.5713]}, {"w": "using", "b": [0.7701, 0.5499, 0.8155, 0.5713]}, {"w": "Lin‐", "b": [0.8215, 0.5499, 0.8571, 0.5713]}, {"w": "ear", "b": [0.1429, 0.5689, 0.1686, 0.5903]}, {"w": "Regression,", "b": [0.174, 0.5689, 0.2698, 0.5903]}, {"w": "another", "b": [0.2752, 0.5689, 0.3405, 0.5903]}, {"w": "using", "b": [0.3459, 0.5689, 0.3914, 0.5903]}, {"w": "Random", "b": [0.3968, 0.5689, 0.4693, 0.5903]}, {"w": "Forest", "b": [0.4748, 0.5689, 0.5266, 0.5903]}, {"w": "Regression,", "b": [0.5321, 0.5689, 0.6278, 0.5903]}, {"w": "and", "b": [0.6333, 0.5689, 0.6648, 0.5903]}, {"w": "so", "b": [0.6703, 0.5689, 0.6886, 0.5903]}, {"w": "on):", "b": [0.694, 0.5689, 0.728, 0.5903]}, {"w": "we", "b": [0.7334, 0.5689, 0.7566, 0.5903]}, {"w": "get", "b": [0.762, 0.5689, 0.787, 0.5903]}, {"w": "a", "b": [0.7924, 0.5689, 0.8015, 0.5903]}, {"w": "whole", "b": [0.807, 0.5689, 0.8571, 0.5903]}, {"w": "layer", "b": [0.1428, 0.588, 0.183, 0.6094]}, {"w": "of", "b": [0.1879, 0.588, 0.2047, 0.6094]}, {"w": "blenders.", "b": [0.2095, 0.588, 0.2856, 0.6094]}, {"w": "The", "b": [0.2905, 0.588, 0.3233, 0.6094]}, {"w": "trick", "b": [0.3282, 0.588, 0.367, 0.6094]}, {"w": "is", "b": [0.3718, 0.588, 0.3851, 0.6094]}, {"w": "to", "b": [0.3899, 0.588, 0.4069, 0.6094]}, {"w": "split", "b": [0.4118, 0.588, 0.4475, 0.6094]}, {"w": "the", "b": [0.4524, 0.588, 0.4787, 0.6094]}, {"w": "training", "b": [0.4836, 0.588, 0.5505, 0.6094]}, {"w": "set", "b": [0.5554, 0.588, 0.5782, 0.6094]}, {"w": "into", "b": [0.5831, 0.588, 0.6166, 0.6094]}, {"w": "three", "b": [0.6215, 0.588, 0.6644, 0.6094]}, {"w": "subsets:", "b": [0.6693, 0.588, 0.7338, 0.6094]}, {"w": "the", "b": [0.7387, 0.588, 0.765, 0.6094]}, {"w": "first", "b": [0.7698, 0.588, 0.8033, 0.6094]}, {"w": "one", "b": [0.8082, 0.588, 0.839, 0.6094]}, {"w": "is", "b": [0.8439, 0.588, 0.8571, 0.6094]}, {"w": "used", "b": [0.1429, 0.607, 0.1814, 0.6284]}, {"w": "to", "b": [0.1879, 0.607, 0.2049, 0.6284]}, {"w": "train", "b": [0.2113, 0.607, 0.2515, 0.6284]}, {"w": "the", "b": [0.258, 0.607, 0.2843, 0.6284]}, {"w": "first", "b": [0.2908, 0.607, 0.3243, 0.6284]}, {"w": "layer,", "b": [0.3307, 0.607, 0.3743, 0.6284]}, {"w": "the", "b": [0.3808, 0.607, 0.4071, 0.6284]}, {"w": "second", "b": [0.4136, 0.607, 0.4719, 0.6284]}, {"w": "one", "b": [0.4784, 0.607, 0.5092, 0.6284]}, {"w": "is", "b": [0.5157, 0.607, 0.5289, 0.6284]}, {"w": "used", "b": [0.5354, 0.607, 0.574, 0.6284]}, {"w": "to", "b": [0.5804, 0.607, 0.5974, 0.6284]}, {"w": "create", "b": [0.6038, 0.607, 0.6532, 0.6284]}, {"w": "the", "b": [0.6597, 0.607, 0.686, 0.6284]}, {"w": "training", "b": [0.6924, 0.607, 0.7594, 0.6284]}, {"w": "set", "b": [0.7658, 0.607, 0.7887, 0.6284]}, {"w": "used", "b": [0.7952, 0.607, 0.8337, 0.6284]}, {"w": "to", "b": [0.8402, 0.607, 0.8571, 0.6284]}, {"w": "train", "b": [0.1429, 0.6261, 0.1831, 0.6475]}, {"w": "the", "b": [0.1904, 0.6261, 0.2167, 0.6475]}, {"w": "second", "b": [0.2241, 0.6261, 0.2824, 0.6475]}, {"w": "layer", "b": [0.2898, 0.6261, 0.33, 0.6475]}, {"w": "(using", "b": [0.3373, 0.6261, 0.39, 0.6475]}, {"w": "predictions", "b": [0.3973, 0.6261, 0.4918, 0.6475]}, {"w": "made", "b": [0.4992, 0.6261, 0.5452, 0.6475]}, {"w": "by", "b": [0.5526, 0.6261, 0.5727, 0.6475]}, {"w": "the", "b": [0.5801, 0.6261, 0.6064, 0.6475]}, {"w": "predictors", "b": [0.6137, 0.6261, 0.699, 0.6475]}, {"w": "of", "b": [0.7063, 0.6261, 0.7231, 0.6475]}, {"w": "the", "b": [0.7305, 0.6261, 0.7568, 0.6475]}, {"w": "first", "b": [0.7642, 0.6261, 0.7976, 0.6475]}, {"w": "layer),", "b": [0.805, 0.6261, 0.8571, 0.6475]}, {"w": "and", "b": [0.1429, 0.6451, 0.1744, 0.6665]}, {"w": "the", "b": [0.1801, 0.6451, 0.2064, 0.6665]}, {"w": "third", "b": [0.2121, 0.6451, 0.2539, 0.6665]}, {"w": "one", "b": [0.2595, 0.6451, 0.2904, 0.6665]}, {"w": "is", "b": [0.2961, 0.6451, 0.3093, 0.6665]}, {"w": "used", "b": [0.315, 0.6451, 0.3535, 0.6665]}, {"w": "to", "b": [0.3592, 0.6451, 0.3762, 0.6665]}, {"w": "create", "b": [0.3819, 0.6451, 0.4312, 0.6665]}, {"w": "the", "b": [0.4369, 0.6451, 0.4632, 0.6665]}, {"w": "training", "b": [0.4689, 0.6451, 0.5358, 0.6665]}, {"w": "set", "b": [0.5415, 0.6451, 0.5644, 0.6665]}, {"w": "to", "b": [0.57, 0.6451, 0.587, 0.6665]}, {"w": "train", "b": [0.5927, 0.6451, 0.6329, 0.6665]}, {"w": "the", "b": [0.6386, 0.6451, 0.6649, 0.6665]}, {"w": "third", "b": [0.6706, 0.6451, 0.7124, 0.6665]}, {"w": "layer", "b": [0.718, 0.6451, 0.7582, 0.6665]}, {"w": "(using", "b": [0.7639, 0.6451, 0.8165, 0.6665]}, {"w": "pre‐", "b": [0.8222, 0.6451, 0.8571, 0.6665]}, {"w": "dictions", "b": [0.1429, 0.6642, 0.2099, 0.6856]}, {"w": "made", "b": [0.2154, 0.6642, 0.2615, 0.6856]}, {"w": "by", "b": [0.267, 0.6642, 0.2871, 0.6856]}, {"w": "the", "b": [0.2926, 0.6642, 0.319, 0.6856]}, {"w": "predictors", "b": [0.3245, 0.6642, 0.4097, 0.6856]}, {"w": "of", "b": [0.4153, 0.6642, 0.4321, 0.6856]}, {"w": "the", "b": [0.4376, 0.6642, 0.4639, 0.6856]}, {"w": "second", "b": [0.4694, 0.6642, 0.5278, 0.6856]}, {"w": "layer).", "b": [0.5333, 0.6642, 0.5854, 0.6856]}, {"w": "Once", "b": [0.591, 0.6642, 0.6356, 0.6856]}, {"w": "this", "b": [0.6411, 0.6642, 0.6718, 0.6856]}, {"w": "is", "b": [0.6773, 0.6642, 0.6906, 0.6856]}, {"w": "done,", "b": [0.6961, 0.6642, 0.7427, 0.6856]}, {"w": "we", "b": [0.7482, 0.6642, 0.7714, 0.6856]}, {"w": "can", "b": [0.7769, 0.6642, 0.8062, 0.6856]}, {"w": "make", "b": [0.8118, 0.6642, 0.8572, 0.6856]}, {"w": "a", "b": [0.1429, 0.6832, 0.152, 0.7046]}, {"w": "prediction", "b": [0.1575, 0.6832, 0.2443, 0.7046]}, {"w": "for", "b": [0.2498, 0.6832, 0.2743, 0.7046]}, {"w": "a", "b": [0.2798, 0.6832, 0.2889, 0.7046]}, {"w": "new", "b": [0.2944, 0.6832, 0.3289, 0.7046]}, {"w": "instance", "b": [0.3344, 0.6832, 0.4035, 0.7046]}, {"w": "by", "b": [0.409, 0.6832, 0.4291, 0.7046]}, {"w": "going", "b": [0.4346, 0.6832, 0.4817, 0.7046]}, {"w": "through", "b": [0.4872, 0.6832, 0.5549, 0.7046]}, {"w": "each", "b": [0.5604, 0.6832, 0.5983, 0.7046]}, {"w": "layer", "b": [0.6038, 0.6832, 0.644, 0.7046]}, {"w": "sequentially,", "b": [0.6495, 0.6832, 0.7519, 0.7046]}, {"w": "as", "b": [0.7574, 0.6832, 0.7742, 0.7046]}, {"w": "shown", "b": [0.7796, 0.6832, 0.8347, 0.7046]}, {"w": "in", "b": [0.8402, 0.6832, 0.8571, 0.7046]}, {"w": "Figure", "b": [0.1429, 0.7023, 0.1969, 0.7237]}, {"w": "7-15.", "b": [0.2016, 0.7023, 0.2437, 0.7237]}]}, {"id": "b_3", "type": "paragraph", "text": "212 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "212", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 239, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 7-15. Predictions in a multilayer stacking ensemble", "words": [{"w": "Figure", "b": [0.1429, 0.4387, 0.1943, 0.4603]}, {"w": "7-15.", "b": [0.1991, 0.4387, 0.2407, 0.4603]}, {"w": "Predictions", "b": [0.2455, 0.4387, 0.3359, 0.4603]}, {"w": "in", "b": [0.3406, 0.4387, 0.3571, 0.4603]}, {"w": "a", "b": [0.3619, 0.4387, 0.3721, 0.4603]}, {"w": "multilayer", "b": [0.3769, 0.4387, 0.4605, 0.4603]}, {"w": "stacking", "b": [0.4653, 0.4387, 0.5305, 0.4603]}, {"w": "ensemble", "b": [0.5353, 0.4387, 0.6095, 0.4603]}]}, {"id": "b_1", "type": "paragraph", "text": "Unfortunately, Scikit-Learn does not support stacking directly, but it is not too hard to roll out your own implementation (see the following exercises). Alternatively, you can use an open source implementation such as brew (available at https://github.com/ viisar/brew).", "words": [{"w": "Unfortunately,", "b": [0.1429, 0.4761, 0.264, 0.4975]}, {"w": "Scikit-Learn", "b": [0.2703, 0.4761, 0.3726, 0.4975]}, {"w": "does", "b": [0.3789, 0.4761, 0.417, 0.4975]}, {"w": "not", "b": [0.4233, 0.4761, 0.4517, 0.4975]}, {"w": "support", "b": [0.458, 0.4761, 0.5233, 0.4975]}, {"w": "stacking", "b": [0.5295, 0.4761, 0.5986, 0.4975]}, {"w": "directly,", "b": [0.6049, 0.4761, 0.6712, 0.4975]}, {"w": "but", "b": [0.6775, 0.4761, 0.7055, 0.4975]}, {"w": "it", "b": [0.7118, 0.4761, 0.7238, 0.4975]}, {"w": "is", "b": [0.7301, 0.4761, 0.7433, 0.4975]}, {"w": "not", "b": [0.7496, 0.4761, 0.778, 0.4975]}, {"w": "too", "b": [0.7842, 0.4761, 0.8119, 0.4975]}, {"w": "hard", "b": [0.8181, 0.4761, 0.8571, 0.4975]}, {"w": "to", "b": [0.1429, 0.4952, 0.1598, 0.5166]}, {"w": "roll", "b": [0.1658, 0.4952, 0.1947, 0.5166]}, {"w": "out", "b": [0.2007, 0.4952, 0.2287, 0.5166]}, {"w": "your", "b": [0.2347, 0.4952, 0.2737, 0.5166]}, {"w": "own", "b": [0.2796, 0.4952, 0.3159, 0.5166]}, {"w": "implementation", "b": [0.3219, 0.4952, 0.4552, 0.5166]}, {"w": "(see", "b": [0.4611, 0.4952, 0.4937, 0.5166]}, {"w": "the", "b": [0.4997, 0.4952, 0.526, 0.5166]}, {"w": "following", "b": [0.532, 0.4952, 0.6109, 0.5166]}, {"w": "exercises).", "b": [0.6169, 0.4952, 0.7027, 0.5166]}, {"w": "Alternatively,", "b": [0.7087, 0.4952, 0.8199, 0.5166]}, {"w": "you", "b": [0.8259, 0.4952, 0.8571, 0.5166]}, {"w": "can", "b": [0.1429, 0.5151, 0.1722, 0.5365]}, {"w": "use", "b": [0.1779, 0.5151, 0.2055, 0.5365]}, {"w": "an", "b": [0.2112, 0.5151, 0.2317, 0.5365]}, {"w": "open", "b": [0.2375, 0.5151, 0.2793, 0.5365]}, {"w": "source", "b": [0.285, 0.5151, 0.3397, 0.5365]}, {"w": "implementation", "b": [0.3454, 0.5151, 0.4787, 0.5365]}, {"w": "such", "b": [0.4844, 0.5151, 0.523, 0.5365]}, {"w": "as", "b": [0.5287, 0.5151, 0.5455, 0.5365]}, {"w": "brew", "b": [0.5512, 0.5183, 0.5908, 0.5334]}, {"w": "(available", "b": [0.5965, 0.5151, 0.676, 0.5365]}, {"w": "at", "b": [0.6817, 0.5151, 0.6968, 0.5365]}, {"w": "https://github.com/", "b": [0.7025, 0.5149, 0.8572, 0.5365]}, {"w": "viisar/brew).", "b": [0.1429, 0.5339, 0.2464, 0.5556]}]}, {"id": "b_2", "type": "paragraph", "text": "Exercises", "words": [{"w": "Exercises", "b": [0.1429, 0.5686, 0.2533, 0.6028]}]}, {"id": "b_3", "type": "paragraph", "text": "1. If you have trained five different models on the exact same training data, and they all achieve 95% precision, is there any chance that you can combine these models to get better results? If so, how? If not, why?", "words": [{"w": "1.", "b": [0.1534, 0.6158, 0.1682, 0.6372]}, {"w": "If", "b": [0.1786, 0.6158, 0.1918, 0.6372]}, {"w": "you", "b": [0.1996, 0.6158, 0.2308, 0.6372]}, {"w": "have", "b": [0.2386, 0.6158, 0.277, 0.6372]}, {"w": "trained", "b": [0.2847, 0.6158, 0.3448, 0.6372]}, {"w": "five", "b": [0.3525, 0.6158, 0.3828, 0.6372]}, {"w": "different", "b": [0.3905, 0.6158, 0.4622, 0.6372]}, {"w": "models", "b": [0.4699, 0.6158, 0.5304, 0.6372]}, {"w": "on", "b": [0.5381, 0.6158, 0.5602, 0.6372]}, {"w": "the", "b": [0.5679, 0.6158, 0.5942, 0.6372]}, {"w": "exact", "b": [0.602, 0.6158, 0.645, 0.6372]}, {"w": "same", "b": [0.6527, 0.6158, 0.6954, 0.6372]}, {"w": "training", "b": [0.7032, 0.6158, 0.7701, 0.6372]}, {"w": "data,", "b": [0.7779, 0.6158, 0.8179, 0.6372]}, {"w": "and", "b": [0.8256, 0.6158, 0.8571, 0.6372]}, {"w": "they", "b": [0.1786, 0.6348, 0.2145, 0.6562]}, {"w": "all", "b": [0.2214, 0.6348, 0.2411, 0.6562]}, {"w": "achieve", "b": [0.2481, 0.6348, 0.3101, 0.6562]}, {"w": "95%", "b": [0.3171, 0.6348, 0.3528, 0.6562]}, {"w": "precision,", "b": [0.3598, 0.6348, 0.4417, 0.6562]}, {"w": "is", "b": [0.4486, 0.6348, 0.4618, 0.6562]}, {"w": "there", "b": [0.4688, 0.6348, 0.5117, 0.6562]}, {"w": "any", "b": [0.5187, 0.6348, 0.5483, 0.6562]}, {"w": "chance", "b": [0.5553, 0.6348, 0.6134, 0.6562]}, {"w": "that", "b": [0.6204, 0.6348, 0.653, 0.6562]}, {"w": "you", "b": [0.6599, 0.6348, 0.6912, 0.6562]}, {"w": "can", "b": [0.6981, 0.6348, 0.7275, 0.6562]}, {"w": "combine", "b": [0.7344, 0.6348, 0.8074, 0.6562]}, {"w": "these", "b": [0.8143, 0.6348, 0.8571, 0.6562]}, {"w": "models", "b": [0.1786, 0.6539, 0.239, 0.6753]}, {"w": "to", "b": [0.2438, 0.6539, 0.2607, 0.6753]}, {"w": "get", "b": [0.2655, 0.6539, 0.2904, 0.6753]}, {"w": "better", "b": [0.2951, 0.6539, 0.3439, 0.6753]}, {"w": "results?", "b": [0.3486, 0.6539, 0.4111, 0.6753]}, {"w": "If", "b": [0.4158, 0.6539, 0.4291, 0.6753]}, {"w": "so,", "b": [0.4338, 0.6539, 0.4562, 0.6753]}, {"w": "how?", "b": [0.4609, 0.6539, 0.5049, 0.6753]}, {"w": "If", "b": [0.5096, 0.6539, 0.5229, 0.6753]}, {"w": "not,", "b": [0.5276, 0.6539, 0.5607, 0.6753]}, {"w": "why?", "b": [0.5654, 0.6539, 0.6078, 0.6753]}]}, {"id": "b_4", "type": "paragraph", "text": "2. What is the difference between hard and soft voting classifiers?", "words": [{"w": "2.", "b": [0.1534, 0.679, 0.1682, 0.7004]}, {"w": "What", "b": [0.1786, 0.679, 0.225, 0.7004]}, {"w": "is", "b": [0.2298, 0.679, 0.243, 0.7004]}, {"w": "the", "b": [0.2477, 0.679, 0.274, 0.7004]}, {"w": "difference", "b": [0.2788, 0.679, 0.3622, 0.7004]}, {"w": "between", "b": [0.3669, 0.679, 0.4361, 0.7004]}, {"w": "hard", "b": [0.4408, 0.679, 0.4798, 0.7004]}, {"w": "and", "b": [0.4845, 0.679, 0.5161, 0.7004]}, {"w": "soft", "b": [0.5208, 0.679, 0.5516, 0.7004]}, {"w": "voting", "b": [0.5563, 0.679, 0.6097, 0.7004]}, {"w": "classifiers?", "b": [0.6144, 0.679, 0.7024, 0.7004]}]}, {"id": "b_5", "type": "paragraph", "text": "3. Is it possible to speed up training of a bagging ensemble by distributing it across multiple servers? What about pasting ensembles, boosting ensembles, random forests, or stacking ensembles?", "words": [{"w": "3.", "b": [0.1534, 0.7041, 0.1682, 0.7255]}, {"w": "Is", "b": [0.1786, 0.7041, 0.1929, 0.7255]}, {"w": "it", "b": [0.1985, 0.7041, 0.2105, 0.7255]}, {"w": "possible", "b": [0.2161, 0.7041, 0.2833, 0.7255]}, {"w": "to", "b": [0.2889, 0.7041, 0.3059, 0.7255]}, {"w": "speed", "b": [0.3116, 0.7041, 0.3588, 0.7255]}, {"w": "up", "b": [0.3645, 0.7041, 0.3865, 0.7255]}, {"w": "training", "b": [0.3921, 0.7041, 0.4591, 0.7255]}, {"w": "of", "b": [0.4647, 0.7041, 0.4815, 0.7255]}, {"w": "a", "b": [0.4872, 0.7041, 0.4964, 0.7255]}, {"w": "bagging", "b": [0.502, 0.7041, 0.568, 0.7255]}, {"w": "ensemble", "b": [0.5736, 0.7041, 0.6522, 0.7255]}, {"w": "by", "b": [0.6578, 0.7041, 0.678, 0.7255]}, {"w": "distributing", "b": [0.6836, 0.7041, 0.7823, 0.7255]}, {"w": "it", "b": [0.7879, 0.7041, 0.7999, 0.7255]}, {"w": "across", "b": [0.8055, 0.7041, 0.8571, 0.7255]}, {"w": "multiple", "b": [0.1786, 0.7231, 0.2486, 0.7445]}, {"w": "servers?", "b": [0.2568, 0.7231, 0.3234, 0.7445]}, {"w": "What", "b": [0.3316, 0.7231, 0.378, 0.7445]}, {"w": "about", "b": [0.3862, 0.7231, 0.434, 0.7445]}, {"w": "pasting", "b": [0.4422, 0.7231, 0.503, 0.7445]}, {"w": "ensembles,", "b": [0.5112, 0.7231, 0.6021, 0.7445]}, {"w": "boosting", "b": [0.6103, 0.7231, 0.6829, 0.7445]}, {"w": "ensembles,", "b": [0.6911, 0.7231, 0.782, 0.7445]}, {"w": "random", "b": [0.7902, 0.7231, 0.8571, 0.7445]}, {"w": "forests,", "b": [0.1786, 0.7422, 0.2383, 0.7636]}, {"w": "or", "b": [0.2431, 0.7422, 0.2614, 0.7636]}, {"w": "stacking", "b": [0.2661, 0.7422, 0.3352, 0.7636]}, {"w": "ensembles?", "b": [0.3399, 0.7422, 0.434, 0.7636]}]}, {"id": "b_6", "type": "equation", "text": "4. What is the benefit of out-of-bag evaluation?", "words": [{"w": "4.", "b": [0.1534, 0.7673, 0.1682, 0.7887]}, {"w": "What", "b": [0.1786, 0.7673, 0.225, 0.7887]}, {"w": "is", "b": [0.2298, 0.7673, 0.243, 0.7887]}, {"w": "the", "b": [0.2477, 0.7673, 0.274, 0.7887]}, {"w": "benefit", "b": [0.2788, 0.7673, 0.3366, 0.7887]}, {"w": "of", "b": [0.3413, 0.7673, 0.3581, 0.7887]}, {"w": "out-of-bag", "b": [0.3628, 0.7673, 0.452, 0.7887]}, {"w": "evaluation?", "b": [0.4567, 0.7673, 0.5513, 0.7887]}]}, {"id": "b_7", "type": "paragraph", "text": "5. What makes Extra-Trees more random than regular Random Forests? How can this extra randomness help? Are Extra-Trees slower or faster than regular Ran‐ dom Forests?", "words": [{"w": "5.", "b": [0.1534, 0.7924, 0.1682, 0.8138]}, {"w": "What", "b": [0.1786, 0.7924, 0.225, 0.8138]}, {"w": "makes", "b": [0.2314, 0.7924, 0.2845, 0.8138]}, {"w": "Extra-Trees", "b": [0.2909, 0.7924, 0.3874, 0.8138]}, {"w": "more", "b": [0.3938, 0.7924, 0.4381, 0.8138]}, {"w": "random", "b": [0.4445, 0.7924, 0.5115, 0.8138]}, {"w": "than", "b": [0.5179, 0.7924, 0.5559, 0.8138]}, {"w": "regular", "b": [0.5623, 0.7924, 0.6219, 0.8138]}, {"w": "Random", "b": [0.6283, 0.7924, 0.7008, 0.8138]}, {"w": "Forests?", "b": [0.7072, 0.7924, 0.7746, 0.8138]}, {"w": "How", "b": [0.781, 0.7924, 0.8214, 0.8138]}, {"w": "can", "b": [0.8278, 0.7924, 0.8571, 0.8138]}, {"w": "this", "b": [0.1786, 0.8114, 0.2093, 0.8328]}, {"w": "extra", "b": [0.216, 0.8114, 0.258, 0.8328]}, {"w": "randomness", "b": [0.2647, 0.8114, 0.3672, 0.8328]}, {"w": "help?", "b": [0.374, 0.8114, 0.4181, 0.8328]}, {"w": "Are", "b": [0.4248, 0.8114, 0.4558, 0.8328]}, {"w": "Extra-Trees", "b": [0.4626, 0.8114, 0.5591, 0.8328]}, {"w": "slower", "b": [0.5658, 0.8114, 0.6202, 0.8328]}, {"w": "or", "b": [0.627, 0.8114, 0.6454, 0.8328]}, {"w": "faster", "b": [0.6521, 0.8114, 0.698, 0.8328]}, {"w": "than", "b": [0.7048, 0.8114, 0.7428, 0.8328]}, {"w": "regular", "b": [0.7496, 0.8114, 0.8091, 0.8328]}, {"w": "Ran‐", "b": [0.8159, 0.8114, 0.8571, 0.8328]}, {"w": "dom", "b": [0.1786, 0.8305, 0.2173, 0.8519]}, {"w": "Forests?", "b": [0.222, 0.8305, 0.2894, 0.8519]}]}, {"id": "b_8", "type": "paragraph", "text": "6. If your AdaBoost ensemble underfits the training data, what hyperparameters should you tweak and how?", "words": [{"w": "6.", "b": [0.1534, 0.8555, 0.1682, 0.877]}, {"w": "If", "b": [0.1786, 0.8555, 0.1918, 0.877]}, {"w": "your", "b": [0.2002, 0.8555, 0.2392, 0.877]}, {"w": "AdaBoost", "b": [0.2475, 0.8555, 0.3294, 0.877]}, {"w": "ensemble", "b": [0.3378, 0.8555, 0.4163, 0.877]}, {"w": "underfits", "b": [0.4247, 0.8555, 0.5005, 0.877]}, {"w": "the", "b": [0.5088, 0.8555, 0.5351, 0.877]}, {"w": "training", "b": [0.5435, 0.8555, 0.6104, 0.877]}, {"w": "data,", "b": [0.6188, 0.8555, 0.6588, 0.877]}, {"w": "what", "b": [0.6671, 0.8555, 0.7076, 0.877]}, {"w": "hyperparameters", "b": [0.716, 0.8555, 0.8571, 0.877]}, {"w": "should", "b": [0.1786, 0.8746, 0.2353, 0.896]}, {"w": "you", "b": [0.24, 0.8746, 0.2713, 0.896]}, {"w": "tweak", "b": [0.276, 0.8746, 0.325, 0.896]}, {"w": "and", "b": [0.3297, 0.8746, 0.3612, 0.896]}, {"w": "how?", "b": [0.366, 0.8746, 0.4099, 0.896]}]}, {"id": "b_9", "type": "paragraph", "text": "Exercises | 213", "words": [{"w": "Exercises", "b": [0.7433, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "213", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 240, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "7. If your Gradient Boosting ensemble overfits the training set, should you increase or decrease the learning rate?", "words": [{"w": "7.", "b": [0.1534, 0.0791, 0.1682, 0.1005]}, {"w": "If", "b": [0.1786, 0.0791, 0.1918, 0.1005]}, {"w": "your", "b": [0.1972, 0.0791, 0.2362, 0.1005]}, {"w": "Gradient", "b": [0.2416, 0.0791, 0.3161, 0.1005]}, {"w": "Boosting", "b": [0.3215, 0.0791, 0.3961, 0.1005]}, {"w": "ensemble", "b": [0.4015, 0.0791, 0.48, 0.1005]}, {"w": "overfits", "b": [0.4854, 0.0791, 0.548, 0.1005]}, {"w": "the", "b": [0.5534, 0.0791, 0.5797, 0.1005]}, {"w": "training", "b": [0.5851, 0.0791, 0.652, 0.1005]}, {"w": "set,", "b": [0.6574, 0.0791, 0.685, 0.1005]}, {"w": "should", "b": [0.6904, 0.0791, 0.7471, 0.1005]}, {"w": "you", "b": [0.7525, 0.0791, 0.7837, 0.1005]}, {"w": "increase", "b": [0.7891, 0.0791, 0.8571, 0.1005]}, {"w": "or", "b": [0.1786, 0.0981, 0.1969, 0.1195]}, {"w": "decrease", "b": [0.2017, 0.0981, 0.2726, 0.1195]}, {"w": "the", "b": [0.2773, 0.0981, 0.3036, 0.1195]}, {"w": "learning", "b": [0.3083, 0.0981, 0.3775, 0.1195]}, {"w": "rate?", "b": [0.3822, 0.0981, 0.4218, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "8. Load the MNIST data (introduced in Chapter 3), and split it into a training set, a validation set, and a test set (e.g., use 50,000 instances for training, 10,000 for val‐ idation, and 10,000 for testing). Then train various classifiers, such as a Random Forest classifier, an Extra-Trees classifier, and an SVM. Next, try to combine them into an ensemble that outperforms them all on the validation set, using a soft or hard voting classifier. Once you have found one, try it on the test set. How much better does it perform compared to the individual classifiers?", "words": [{"w": "8.", "b": [0.1534, 0.1232, 0.1682, 0.1446]}, {"w": "Load", "b": [0.1786, 0.1232, 0.2205, 0.1446]}, {"w": "the", "b": [0.2259, 0.1232, 0.2522, 0.1446]}, {"w": "MNIST", "b": [0.2575, 0.1232, 0.3214, 0.1446]}, {"w": "data", "b": [0.3267, 0.1232, 0.362, 0.1446]}, {"w": "(introduced", "b": [0.3673, 0.1232, 0.4665, 0.1446]}, {"w": "in", "b": [0.4718, 0.1232, 0.4888, 0.1446]}, {"w": "Chapter", "b": [0.4941, 0.1232, 0.5617, 0.1446]}, {"w": "3),", "b": [0.5664, 0.1232, 0.589, 0.1446]}, {"w": "and", "b": [0.5943, 0.1232, 0.6258, 0.1446]}, {"w": "split", "b": [0.6311, 0.1232, 0.6669, 0.1446]}, {"w": "it", "b": [0.6722, 0.1232, 0.6842, 0.1446]}, {"w": "into", "b": [0.6895, 0.1232, 0.723, 0.1446]}, {"w": "a", "b": [0.7284, 0.1232, 0.7375, 0.1446]}, {"w": "training", "b": [0.7428, 0.1232, 0.8098, 0.1446]}, {"w": "set,", "b": [0.8151, 0.1232, 0.8427, 0.1446]}, {"w": "a", "b": [0.848, 0.1232, 0.8571, 0.1446]}, {"w": "validation", "b": [0.1786, 0.1423, 0.2619, 0.1637]}, {"w": "set,", "b": [0.2668, 0.1423, 0.2944, 0.1637]}, {"w": "and", "b": [0.2993, 0.1423, 0.3309, 0.1637]}, {"w": "a", "b": [0.3358, 0.1423, 0.3449, 0.1637]}, {"w": "test", "b": [0.3498, 0.1423, 0.3791, 0.1637]}, {"w": "set", "b": [0.384, 0.1423, 0.4068, 0.1637]}, {"w": "(e.g.,", "b": [0.4117, 0.1423, 0.4518, 0.1637]}, {"w": "use", "b": [0.4567, 0.1423, 0.4843, 0.1637]}, {"w": "50,000", "b": [0.4892, 0.1423, 0.5439, 0.1637]}, {"w": "instances", "b": [0.5488, 0.1423, 0.6257, 0.1637]}, {"w": "for", "b": [0.6306, 0.1423, 0.6551, 0.1637]}, {"w": "training,", "b": [0.66, 0.1423, 0.7317, 0.1637]}, {"w": "10,000", "b": [0.7366, 0.1423, 0.7913, 0.1637]}, {"w": "for", "b": [0.7962, 0.1423, 0.8208, 0.1637]}, {"w": "val‐", "b": [0.8257, 0.1423, 0.8571, 0.1637]}, {"w": "idation,", "b": [0.1786, 0.1613, 0.2426, 0.1827]}, {"w": "and", "b": [0.2483, 0.1613, 0.2798, 0.1827]}, {"w": "10,000", "b": [0.2855, 0.1613, 0.3402, 0.1827]}, {"w": "for", "b": [0.3459, 0.1613, 0.3704, 0.1827]}, {"w": "testing).", "b": [0.3761, 0.1613, 0.444, 0.1827]}, {"w": "Then", "b": [0.4497, 0.1613, 0.4939, 0.1827]}, {"w": "train", "b": [0.4996, 0.1613, 0.5398, 0.1827]}, {"w": "various", "b": [0.5454, 0.1613, 0.6069, 0.1827]}, {"w": "classifiers,", "b": [0.6125, 0.1613, 0.6974, 0.1827]}, {"w": "such", "b": [0.703, 0.1613, 0.7417, 0.1827]}, {"w": "as", "b": [0.7473, 0.1613, 0.7641, 0.1827]}, {"w": "a", "b": [0.7698, 0.1613, 0.7789, 0.1827]}, {"w": "Random", "b": [0.7846, 0.1613, 0.8572, 0.1827]}, {"w": "Forest", "b": [0.1786, 0.1803, 0.2304, 0.2018]}, {"w": "classifier,", "b": [0.2394, 0.1803, 0.3153, 0.2018]}, {"w": "an", "b": [0.3243, 0.1803, 0.3448, 0.2018]}, {"w": "Extra-Trees", "b": [0.3539, 0.1803, 0.4504, 0.2018]}, {"w": "classifier,", "b": [0.4594, 0.1803, 0.5353, 0.2018]}, {"w": "and", "b": [0.5443, 0.1803, 0.5758, 0.2018]}, {"w": "an", "b": [0.5848, 0.1803, 0.6054, 0.2018]}, {"w": "SVM.", "b": [0.6144, 0.1803, 0.6622, 0.2018]}, {"w": "Next,", "b": [0.6712, 0.1803, 0.716, 0.2018]}, {"w": "try", "b": [0.725, 0.1803, 0.7492, 0.2018]}, {"w": "to", "b": [0.7582, 0.1803, 0.7752, 0.2018]}, {"w": "combine", "b": [0.7842, 0.1803, 0.8571, 0.2018]}, {"w": "them", "b": [0.1786, 0.1994, 0.222, 0.2208]}, {"w": "into", "b": [0.2288, 0.1994, 0.2623, 0.2208]}, {"w": "an", "b": [0.2691, 0.1994, 0.2897, 0.2208]}, {"w": "ensemble", "b": [0.2964, 0.1994, 0.375, 0.2208]}, {"w": "that", "b": [0.3817, 0.1994, 0.4143, 0.2208]}, {"w": "outperforms", "b": [0.4211, 0.1994, 0.5259, 0.2208]}, {"w": "them", "b": [0.5327, 0.1994, 0.5761, 0.2208]}, {"w": "all", "b": [0.5829, 0.1994, 0.6025, 0.2208]}, {"w": "on", "b": [0.6093, 0.1994, 0.6313, 0.2208]}, {"w": "the", "b": [0.6381, 0.1994, 0.6645, 0.2208]}, {"w": "validation", "b": [0.6713, 0.1994, 0.7546, 0.2208]}, {"w": "set,", "b": [0.7614, 0.1994, 0.789, 0.2208]}, {"w": "using", "b": [0.7958, 0.1994, 0.8412, 0.2208]}, {"w": "a", "b": [0.848, 0.1994, 0.8571, 0.2208]}, {"w": "soft", "b": [0.1786, 0.2184, 0.2094, 0.2399]}, {"w": "or", "b": [0.2143, 0.2184, 0.2327, 0.2399]}, {"w": "hard", "b": [0.2376, 0.2184, 0.2766, 0.2399]}, {"w": "voting", "b": [0.2816, 0.2184, 0.3349, 0.2399]}, {"w": "classifier.", "b": [0.3399, 0.2184, 0.4158, 0.2399]}, {"w": "Once", "b": [0.4207, 0.2184, 0.4654, 0.2399]}, {"w": "you", "b": [0.4703, 0.2184, 0.5016, 0.2399]}, {"w": "have", "b": [0.5065, 0.2184, 0.5449, 0.2399]}, {"w": "found", "b": [0.5499, 0.2184, 0.6001, 0.2399]}, {"w": "one,", "b": [0.6051, 0.2184, 0.6407, 0.2399]}, {"w": "try", "b": [0.6457, 0.2184, 0.6699, 0.2399]}, {"w": "it", "b": [0.6749, 0.2184, 0.6868, 0.2399]}, {"w": "on", "b": [0.6918, 0.2184, 0.7138, 0.2399]}, {"w": "the", "b": [0.7188, 0.2184, 0.7451, 0.2399]}, {"w": "test", "b": [0.7501, 0.2184, 0.7793, 0.2399]}, {"w": "set.", "b": [0.7842, 0.2184, 0.8118, 0.2399]}, {"w": "How", "b": [0.8168, 0.2184, 0.8571, 0.2399]}, {"w": "much", "b": [0.1786, 0.2375, 0.2262, 0.2589]}, {"w": "better", "b": [0.231, 0.2375, 0.2797, 0.2589]}, {"w": "does", "b": [0.2844, 0.2375, 0.3226, 0.2589]}, {"w": "it", "b": [0.3273, 0.2375, 0.3392, 0.2589]}, {"w": "perform", "b": [0.344, 0.2375, 0.413, 0.2589]}, {"w": "compared", "b": [0.4178, 0.2375, 0.5015, 0.2589]}, {"w": "to", "b": [0.5062, 0.2375, 0.5232, 0.2589]}, {"w": "the", "b": [0.528, 0.2375, 0.5543, 0.2589]}, {"w": "individual", "b": [0.559, 0.2375, 0.6443, 0.2589]}, {"w": "classifiers?", "b": [0.649, 0.2375, 0.737, 0.2589]}]}, {"id": "b_2", "type": "paragraph", "text": "9. Run the individual classifiers from the previous exercise to make predictions on the validation set, and create a new training set with the resulting predictions: each training instance is a vector containing the set of predictions from all your classifiers for an image, and the target is the image’s class. Train a classifier on this new training set. Congratulations, you have just trained a blender, and together with the classifiers they form a stacking ensemble! Now let’s evaluate the ensemble on the test set. For each image in the test set, make predictions with all your classifiers, then feed the predictions to the blender to get the ensemble’s pre‐ dictions. How does it compare to the voting classifier you trained earlier?", "words": [{"w": "9.", "b": [0.1534, 0.2626, 0.1682, 0.284]}, {"w": "Run", "b": [0.1786, 0.2626, 0.2135, 0.284]}, {"w": "the", "b": [0.2196, 0.2626, 0.2459, 0.284]}, {"w": "individual", "b": [0.252, 0.2626, 0.3373, 0.284]}, {"w": "classifiers", "b": [0.3434, 0.2626, 0.4235, 0.284]}, {"w": "from", "b": [0.4295, 0.2626, 0.4711, 0.284]}, {"w": "the", "b": [0.4772, 0.2626, 0.5035, 0.284]}, {"w": "previous", "b": [0.5096, 0.2626, 0.5817, 0.284]}, {"w": "exercise", "b": [0.5878, 0.2626, 0.6539, 0.284]}, {"w": "to", "b": [0.66, 0.2626, 0.677, 0.284]}, {"w": "make", "b": [0.6831, 0.2626, 0.7285, 0.284]}, {"w": "predictions", "b": [0.7345, 0.2626, 0.829, 0.284]}, {"w": "on", "b": [0.8351, 0.2626, 0.8571, 0.284]}, {"w": "the", "b": [0.1786, 0.2816, 0.2049, 0.303]}, {"w": "validation", "b": [0.2124, 0.2816, 0.2958, 0.303]}, {"w": "set,", "b": [0.3033, 0.2816, 0.3309, 0.303]}, {"w": "and", "b": [0.3385, 0.2816, 0.37, 0.303]}, {"w": "create", "b": [0.3775, 0.2816, 0.4269, 0.303]}, {"w": "a", "b": [0.4344, 0.2816, 0.4436, 0.303]}, {"w": "new", "b": [0.4511, 0.2816, 0.4856, 0.303]}, {"w": "training", "b": [0.4931, 0.2816, 0.5601, 0.303]}, {"w": "set", "b": [0.5676, 0.2816, 0.5905, 0.303]}, {"w": "with", "b": [0.598, 0.2816, 0.6353, 0.303]}, {"w": "the", "b": [0.6429, 0.2816, 0.6692, 0.303]}, {"w": "resulting", "b": [0.6767, 0.2816, 0.7504, 0.303]}, {"w": "predictions:", "b": [0.7579, 0.2816, 0.8571, 0.303]}, {"w": "each", "b": [0.1786, 0.3007, 0.2165, 0.3221]}, {"w": "training", "b": [0.2226, 0.3007, 0.2896, 0.3221]}, {"w": "instance", "b": [0.2957, 0.3007, 0.3649, 0.3221]}, {"w": "is", "b": [0.371, 0.3007, 0.3843, 0.3221]}, {"w": "a", "b": [0.3904, 0.3007, 0.3995, 0.3221]}, {"w": "vector", "b": [0.4057, 0.3007, 0.4577, 0.3221]}, {"w": "containing", "b": [0.4638, 0.3007, 0.5535, 0.3221]}, {"w": "the", "b": [0.5596, 0.3007, 0.5859, 0.3221]}, {"w": "set", "b": [0.5921, 0.3007, 0.6149, 0.3221]}, {"w": "of", "b": [0.6211, 0.3007, 0.6378, 0.3221]}, {"w": "predictions", "b": [0.644, 0.3007, 0.7385, 0.3221]}, {"w": "from", "b": [0.7446, 0.3007, 0.7862, 0.3221]}, {"w": "all", "b": [0.7923, 0.3007, 0.812, 0.3221]}, {"w": "your", "b": [0.8182, 0.3007, 0.8571, 0.3221]}, {"w": "classifiers", "b": [0.1786, 0.3197, 0.2587, 0.3411]}, {"w": "for", "b": [0.2659, 0.3197, 0.2904, 0.3411]}, {"w": "an", "b": [0.2976, 0.3197, 0.3182, 0.3411]}, {"w": "image,", "b": [0.3254, 0.3197, 0.3806, 0.3411]}, {"w": "and", "b": [0.3878, 0.3197, 0.4193, 0.3411]}, {"w": "the", "b": [0.4266, 0.3197, 0.4529, 0.3411]}, {"w": "target", "b": [0.4602, 0.3197, 0.5083, 0.3411]}, {"w": "is", "b": [0.5156, 0.3197, 0.5288, 0.3411]}, {"w": "the", "b": [0.536, 0.3197, 0.5624, 0.3411]}, {"w": "image’s", "b": [0.5696, 0.3197, 0.6291, 0.3411]}, {"w": "class.", "b": [0.6363, 0.3197, 0.6796, 0.3411]}, {"w": "Train", "b": [0.6869, 0.3197, 0.7318, 0.3411]}, {"w": "a", "b": [0.7391, 0.3197, 0.7482, 0.3411]}, {"w": "classifier", "b": [0.7554, 0.3197, 0.8279, 0.3411]}, {"w": "on", "b": [0.8351, 0.3197, 0.8571, 0.3411]}, {"w": "this", "b": [0.1786, 0.3388, 0.2093, 0.3602]}, {"w": "new", "b": [0.2194, 0.3388, 0.2539, 0.3602]}, {"w": "training", "b": [0.264, 0.3388, 0.3309, 0.3602]}, {"w": "set.", "b": [0.341, 0.3388, 0.3686, 0.3602]}, {"w": "Congratulations,", "b": [0.3787, 0.3388, 0.5186, 0.3602]}, {"w": "you", "b": [0.5287, 0.3388, 0.5599, 0.3602]}, {"w": "have", "b": [0.57, 0.3388, 0.6084, 0.3602]}, {"w": "just", "b": [0.6185, 0.3388, 0.6489, 0.3602]}, {"w": "trained", "b": [0.659, 0.3388, 0.7191, 0.3602]}, {"w": "a", "b": [0.7292, 0.3388, 0.7383, 0.3602]}, {"w": "blender,", "b": [0.7484, 0.3388, 0.8155, 0.3602]}, {"w": "and", "b": [0.8256, 0.3388, 0.8572, 0.3602]}, {"w": "together", "b": [0.1786, 0.3578, 0.2482, 0.3792]}, {"w": "with", "b": [0.2533, 0.3578, 0.2906, 0.3792]}, {"w": "the", "b": [0.2957, 0.3578, 0.322, 0.3792]}, {"w": "classifiers", "b": [0.3271, 0.3578, 0.4072, 0.3792]}, {"w": "they", "b": [0.4123, 0.3578, 0.4482, 0.3792]}, {"w": "form", "b": [0.4532, 0.3578, 0.4948, 0.3792]}, {"w": "a", "b": [0.4999, 0.3578, 0.509, 0.3792]}, {"w": "stacking", "b": [0.5141, 0.3578, 0.5831, 0.3792]}, {"w": "ensemble!", "b": [0.5882, 0.3578, 0.6725, 0.3792]}, {"w": "Now", "b": [0.6776, 0.3578, 0.7174, 0.3792]}, {"w": "let’s", "b": [0.7225, 0.3578, 0.7527, 0.3792]}, {"w": "evaluate", "b": [0.7578, 0.3578, 0.8257, 0.3792]}, {"w": "the", "b": [0.8308, 0.3578, 0.8571, 0.3792]}, {"w": "ensemble", "b": [0.1786, 0.3769, 0.2571, 0.3983]}, {"w": "on", "b": [0.2625, 0.3769, 0.2845, 0.3983]}, {"w": "the", "b": [0.2899, 0.3769, 0.3162, 0.3983]}, {"w": "test", "b": [0.3216, 0.3769, 0.3508, 0.3983]}, {"w": "set.", "b": [0.3561, 0.3769, 0.3837, 0.3983]}, {"w": "For", "b": [0.3891, 0.3769, 0.4181, 0.3983]}, {"w": "each", "b": [0.4235, 0.3769, 0.4614, 0.3983]}, {"w": "image", "b": [0.4668, 0.3769, 0.5172, 0.3983]}, {"w": "in", "b": [0.5225, 0.3769, 0.5395, 0.3983]}, {"w": "the", "b": [0.5449, 0.3769, 0.5712, 0.3983]}, {"w": "test", "b": [0.5766, 0.3769, 0.6058, 0.3983]}, {"w": "set,", "b": [0.6112, 0.3769, 0.6388, 0.3983]}, {"w": "make", "b": [0.6441, 0.3769, 0.6895, 0.3983]}, {"w": "predictions", "b": [0.6949, 0.3769, 0.7894, 0.3983]}, {"w": "with", "b": [0.7948, 0.3769, 0.8321, 0.3983]}, {"w": "all", "b": [0.8375, 0.3769, 0.8571, 0.3983]}, {"w": "your", "b": [0.1786, 0.3959, 0.2175, 0.4173]}, {"w": "classifiers,", "b": [0.2224, 0.3959, 0.3073, 0.4173]}, {"w": "then", "b": [0.3121, 0.3959, 0.3499, 0.4173]}, {"w": "feed", "b": [0.3548, 0.3959, 0.3896, 0.4173]}, {"w": "the", "b": [0.3945, 0.3959, 0.4209, 0.4173]}, {"w": "predictions", "b": [0.4257, 0.3959, 0.5202, 0.4173]}, {"w": "to", "b": [0.5251, 0.3959, 0.5421, 0.4173]}, {"w": "the", "b": [0.547, 0.3959, 0.5733, 0.4173]}, {"w": "blender", "b": [0.5782, 0.3959, 0.6419, 0.4173]}, {"w": "to", "b": [0.6468, 0.3959, 0.6638, 0.4173]}, {"w": "get", "b": [0.6686, 0.3959, 0.6936, 0.4173]}, {"w": "the", "b": [0.6985, 0.3959, 0.7248, 0.4173]}, {"w": "ensemble’s", "b": [0.7297, 0.3959, 0.8173, 0.4173]}, {"w": "pre‐", "b": [0.8222, 0.3959, 0.8571, 0.4173]}, {"w": "dictions.", "b": [0.1786, 0.415, 0.2503, 0.4364]}, {"w": "How", "b": [0.2551, 0.415, 0.2954, 0.4364]}, {"w": "does", "b": [0.3001, 0.415, 0.3382, 0.4364]}, {"w": "it", "b": [0.343, 0.415, 0.3549, 0.4364]}, {"w": "compare", "b": [0.3596, 0.415, 0.4324, 0.4364]}, {"w": "to", "b": [0.4371, 0.415, 0.4541, 0.4364]}, {"w": "the", "b": [0.4588, 0.415, 0.4852, 0.4364]}, {"w": "voting", "b": [0.4899, 0.415, 0.5432, 0.4364]}, {"w": "classifier", "b": [0.548, 0.415, 0.6204, 0.4364]}, {"w": "you", "b": [0.6251, 0.415, 0.6564, 0.4364]}, {"w": "trained", "b": [0.6611, 0.415, 0.7212, 0.4364]}, {"w": "earlier?", "b": [0.7259, 0.415, 0.787, 0.4364]}]}, {"id": "b_3", "type": "paragraph", "text": "Solutions to these exercises are available in ???.", "words": [{"w": "Solutions", "b": [0.1429, 0.4491, 0.2213, 0.4705]}, {"w": "to", "b": [0.226, 0.4491, 0.243, 0.4705]}, {"w": "these", "b": [0.2477, 0.4491, 0.2906, 0.4705]}, {"w": "exercises", "b": [0.2953, 0.4491, 0.3691, 0.4705]}, {"w": "are", "b": [0.3738, 0.4491, 0.3996, 0.4705]}, {"w": "available", "b": [0.4043, 0.4491, 0.4766, 0.4705]}, {"w": "in", "b": [0.4813, 0.4491, 0.4983, 0.4705]}, {"w": "???.", "b": [0.503, 0.4491, 0.5314, 0.4705]}]}, {"id": "b_4", "type": "paragraph", "text": "214 | Chapter 7: Ensemble Learning and Random Forests", "words": [{"w": "214", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "7:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Ensemble", "b": [0.2673, 0.9225, 0.3243, 0.9388]}, {"w": "Learning", "b": [0.3271, 0.9225, 0.3794, 0.9388]}, {"w": "and", "b": [0.3822, 0.9225, 0.4046, 0.9388]}, {"w": "Random", "b": [0.4074, 0.9225, 0.4567, 0.9388]}, {"w": "Forests", "b": [0.4595, 0.9225, 0.5015, 0.9388]}]}]}, {"page": 241, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "CHAPTER 8 Dimensionality Reduction", "words": [{"w": "CHAPTER", "b": [0.7398, 0.1146, 0.8383, 0.1451]}, {"w": "8", "b": [0.8435, 0.1146, 0.8571, 0.1451]}, {"w": "Dimensionality", "b": [0.433, 0.1478, 0.6822, 0.1935]}, {"w": "Reduction", "b": [0.6901, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_1", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 8 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.3643, 0.3102, 0.3839]}, {"w": "Early", "b": [0.3165, 0.3643, 0.3563, 0.3839]}, {"w": "Release", "b": [0.3626, 0.3643, 0.4189, 0.3839]}, {"w": "ebooks,", "b": [0.4251, 0.3643, 0.4831, 0.3839]}, {"w": "you", "b": [0.4894, 0.3643, 0.518, 0.3839]}, {"w": "get", "b": [0.5243, 0.3643, 0.5471, 0.3839]}, {"w": "books", "b": [0.5534, 0.3643, 0.5989, 0.3839]}, {"w": "in", "b": [0.6052, 0.3643, 0.6207, 0.3839]}, {"w": "their", "b": [0.627, 0.3643, 0.6632, 0.3839]}, {"w": "earliest", "b": [0.6695, 0.3643, 0.7239, 0.3839]}, {"w": "form—", "b": [0.7301, 0.3643, 0.7857, 0.3839]}, {"w": "the", "b": [0.2714, 0.3818, 0.2955, 0.4013]}, {"w": "author’s", "b": [0.3012, 0.3818, 0.3615, 0.4013]}, {"w": "raw", "b": [0.3672, 0.3818, 0.3954, 0.4013]}, {"w": "and", "b": [0.4011, 0.3818, 0.4299, 0.4013]}, {"w": "unedited", "b": [0.4357, 0.3818, 0.5034, 0.4013]}, {"w": "content", "b": [0.5091, 0.3818, 0.5667, 0.4013]}, {"w": "as", "b": [0.5725, 0.3818, 0.5878, 0.4013]}, {"w": "he", "b": [0.5936, 0.3818, 0.6118, 0.4013]}, {"w": "or", "b": [0.6175, 0.3818, 0.6343, 0.4013]}, {"w": "she", "b": [0.6401, 0.3818, 0.6653, 0.4013]}, {"w": "writes—so", "b": [0.671, 0.3818, 0.7514, 0.4013]}, {"w": "you", "b": [0.7571, 0.3818, 0.7857, 0.4013]}, {"w": "can", "b": [0.2714, 0.3992, 0.2982, 0.4188]}, {"w": "take", "b": [0.306, 0.3992, 0.3377, 0.4188]}, {"w": "advantage", "b": [0.3455, 0.3992, 0.4223, 0.4188]}, {"w": "of", "b": [0.4301, 0.3992, 0.4454, 0.4188]}, {"w": "these", "b": [0.4532, 0.3992, 0.4923, 0.4188]}, {"w": "technologies", "b": [0.5001, 0.3992, 0.596, 0.4188]}, {"w": "long", "b": [0.6038, 0.3992, 0.6376, 0.4188]}, {"w": "before", "b": [0.6454, 0.3992, 0.6937, 0.4188]}, {"w": "the", "b": [0.7014, 0.3992, 0.7255, 0.4188]}, {"w": "official", "b": [0.7333, 0.3992, 0.7857, 0.4188]}, {"w": "release", "b": [0.2714, 0.4166, 0.3229, 0.4362]}, {"w": "of", "b": [0.3292, 0.4166, 0.3445, 0.4362]}, {"w": "these", "b": [0.3507, 0.4166, 0.3899, 0.4362]}, {"w": "titles.", "b": [0.3961, 0.4166, 0.4371, 0.4362]}, {"w": "The", "b": [0.4433, 0.4166, 0.4733, 0.4362]}, {"w": "following", "b": [0.4795, 0.4166, 0.5517, 0.4362]}, {"w": "will", "b": [0.558, 0.4166, 0.5857, 0.4362]}, {"w": "be", "b": [0.592, 0.4166, 0.6097, 0.4362]}, {"w": "Chapter", "b": [0.616, 0.4166, 0.6777, 0.4362]}, {"w": "8", "b": [0.684, 0.4166, 0.6931, 0.4362]}, {"w": "in", "b": [0.6993, 0.4166, 0.7149, 0.4362]}, {"w": "the", "b": [0.7211, 0.4166, 0.7452, 0.4362]}, {"w": "final", "b": [0.7514, 0.4166, 0.7857, 0.4362]}, {"w": "release", "b": [0.2714, 0.434, 0.3229, 0.4536]}, {"w": "of", "b": [0.3273, 0.434, 0.3426, 0.4536]}, {"w": "the", "b": [0.3469, 0.434, 0.371, 0.4536]}, {"w": "book.", "b": [0.3753, 0.434, 0.4182, 0.4536]}]}, {"id": "b_2", "type": "paragraph", "text": "Many Machine Learning problems involve thousands or even millions of features for each training instance. Not only does this make training extremely slow, it can also make it much harder to find a good solution, as we will see. This problem is often referred to as the curse of dimensionality.", "words": [{"w": "Many", "b": [0.1429, 0.4739, 0.1907, 0.4953]}, {"w": "Machine", "b": [0.1962, 0.4739, 0.2693, 0.4953]}, {"w": "Learning", "b": [0.2749, 0.4739, 0.3499, 0.4953]}, {"w": "problems", "b": [0.3554, 0.4739, 0.4341, 0.4953]}, {"w": "involve", "b": [0.4397, 0.4739, 0.5002, 0.4953]}, {"w": "thousands", "b": [0.5057, 0.4739, 0.5917, 0.4953]}, {"w": "or", "b": [0.5972, 0.4739, 0.6156, 0.4953]}, {"w": "even", "b": [0.6211, 0.4739, 0.6599, 0.4953]}, {"w": "millions", "b": [0.6654, 0.4739, 0.7338, 0.4953]}, {"w": "of", "b": [0.7394, 0.4739, 0.7562, 0.4953]}, {"w": "features", "b": [0.7617, 0.4739, 0.8271, 0.4953]}, {"w": "for", "b": [0.8326, 0.4739, 0.8571, 0.4953]}, {"w": "each", "b": [0.1428, 0.4929, 0.1808, 0.5143]}, {"w": "training", "b": [0.1876, 0.4929, 0.2545, 0.5143]}, {"w": "instance.", "b": [0.2613, 0.4929, 0.3352, 0.5143]}, {"w": "Not", "b": [0.342, 0.4929, 0.3739, 0.5143]}, {"w": "only", "b": [0.3807, 0.4929, 0.4176, 0.5143]}, {"w": "does", "b": [0.4243, 0.4929, 0.4625, 0.5143]}, {"w": "this", "b": [0.4692, 0.4929, 0.5, 0.5143]}, {"w": "make", "b": [0.5067, 0.4929, 0.5521, 0.5143]}, {"w": "training", "b": [0.5589, 0.4929, 0.6258, 0.5143]}, {"w": "extremely", "b": [0.6326, 0.4929, 0.715, 0.5143]}, {"w": "slow,", "b": [0.7218, 0.4929, 0.7628, 0.5143]}, {"w": "it", "b": [0.7696, 0.4929, 0.7815, 0.5143]}, {"w": "can", "b": [0.7883, 0.4929, 0.8177, 0.5143]}, {"w": "also", "b": [0.8244, 0.4929, 0.8571, 0.5143]}, {"w": "make", "b": [0.1429, 0.512, 0.1883, 0.5334]}, {"w": "it", "b": [0.1953, 0.512, 0.2072, 0.5334]}, {"w": "much", "b": [0.2143, 0.512, 0.262, 0.5334]}, {"w": "harder", "b": [0.269, 0.512, 0.3246, 0.5334]}, {"w": "to", "b": [0.3317, 0.512, 0.3486, 0.5334]}, {"w": "find", "b": [0.3557, 0.512, 0.3898, 0.5334]}, {"w": "a", "b": [0.3969, 0.512, 0.406, 0.5334]}, {"w": "good", "b": [0.4131, 0.512, 0.4551, 0.5334]}, {"w": "solution,", "b": [0.4621, 0.512, 0.5354, 0.5334]}, {"w": "as", "b": [0.5425, 0.512, 0.5593, 0.5334]}, {"w": "we", "b": [0.5663, 0.512, 0.5895, 0.5334]}, {"w": "will", "b": [0.5965, 0.512, 0.6269, 0.5334]}, {"w": "see.", "b": [0.634, 0.512, 0.6641, 0.5334]}, {"w": "This", "b": [0.6711, 0.512, 0.7083, 0.5334]}, {"w": "problem", "b": [0.7154, 0.512, 0.7864, 0.5334]}, {"w": "is", "b": [0.7935, 0.512, 0.8067, 0.5334]}, {"w": "often", "b": [0.8138, 0.512, 0.8571, 0.5334]}, {"w": "referred", "b": [0.1429, 0.531, 0.2098, 0.5524]}, {"w": "to", "b": [0.2145, 0.531, 0.2315, 0.5524]}, {"w": "as", "b": [0.2362, 0.531, 0.253, 0.5524]}, {"w": "the", "b": [0.2577, 0.531, 0.2841, 0.5524]}, {"w": "curse", "b": [0.2888, 0.5308, 0.3305, 0.5524]}, {"w": "of", "b": [0.3353, 0.5308, 0.3505, 0.5524]}, {"w": "dimensionality.", "b": [0.3553, 0.5308, 0.4803, 0.5524]}]}, {"id": "b_3", "type": "paragraph", "text": "Fortunately, in real-world problems, it is often possible to reduce the number of fea‐ tures considerably, turning an intractable problem into a tractable one. For example, consider the MNIST images (introduced in Chapter 3): the pixels on the image bor‐ ders are almost always white, so you could completely drop these pixels from the training set without losing much information. Figure 7-6 confirms that these pixels are utterly unimportant for the classification task. Moreover, two neighboring pixels are often highly correlated: if you merge them into a single pixel (e.g., by taking the mean of the two pixel intensities), you will not lose much information.", "words": [{"w": "Fortunately,", "b": [0.1429, 0.5591, 0.2427, 0.5805]}, {"w": "in", "b": [0.2486, 0.5591, 0.2656, 0.5805]}, {"w": "real-world", "b": [0.2715, 0.5591, 0.3588, 0.5805]}, {"w": "problems,", "b": [0.3647, 0.5591, 0.4481, 0.5805]}, {"w": "it", "b": [0.454, 0.5591, 0.466, 0.5805]}, {"w": "is", "b": [0.4719, 0.5591, 0.4851, 0.5805]}, {"w": "often", "b": [0.491, 0.5591, 0.5344, 0.5805]}, {"w": "possible", "b": [0.5403, 0.5591, 0.6074, 0.5805]}, {"w": "to", "b": [0.6133, 0.5591, 0.6303, 0.5805]}, {"w": "reduce", "b": [0.6362, 0.5591, 0.6925, 0.5805]}, {"w": "the", "b": [0.6984, 0.5591, 0.7248, 0.5805]}, {"w": "number", "b": [0.7307, 0.5591, 0.797, 0.5805]}, {"w": "of", "b": [0.8029, 0.5591, 0.8197, 0.5805]}, {"w": "fea‐", "b": [0.8256, 0.5591, 0.8571, 0.5805]}, {"w": "tures", "b": [0.1429, 0.5782, 0.1845, 0.5996]}, {"w": "considerably,", "b": [0.1905, 0.5782, 0.2999, 0.5996]}, {"w": "turning", "b": [0.3059, 0.5782, 0.3691, 0.5996]}, {"w": "an", "b": [0.3751, 0.5782, 0.3957, 0.5996]}, {"w": "intractable", "b": [0.4016, 0.5782, 0.4905, 0.5996]}, {"w": "problem", "b": [0.4964, 0.5782, 0.5675, 0.5996]}, {"w": "into", "b": [0.5734, 0.5782, 0.607, 0.5996]}, {"w": "a", "b": [0.613, 0.5782, 0.6221, 0.5996]}, {"w": "tractable", "b": [0.6281, 0.5782, 0.7003, 0.5996]}, {"w": "one.", "b": [0.7063, 0.5782, 0.7419, 0.5996]}, {"w": "For", "b": [0.7479, 0.5782, 0.7769, 0.5996]}, {"w": "example,", "b": [0.7828, 0.5782, 0.8571, 0.5996]}, {"w": "consider", "b": [0.1429, 0.5972, 0.2145, 0.6186]}, {"w": "the", "b": [0.2206, 0.5972, 0.2469, 0.6186]}, {"w": "MNIST", "b": [0.253, 0.5972, 0.3169, 0.6186]}, {"w": "images", "b": [0.323, 0.5972, 0.381, 0.6186]}, {"w": "(introduced", "b": [0.3871, 0.5972, 0.4863, 0.6186]}, {"w": "in", "b": [0.4924, 0.5972, 0.5094, 0.6186]}, {"w": "Chapter", "b": [0.5155, 0.5972, 0.5831, 0.6186]}, {"w": "3):", "b": [0.5891, 0.5972, 0.6111, 0.6186]}, {"w": "the", "b": [0.6172, 0.5972, 0.6435, 0.6186]}, {"w": "pixels", "b": [0.6496, 0.5972, 0.6977, 0.6186]}, {"w": "on", "b": [0.7038, 0.5972, 0.7258, 0.6186]}, {"w": "the", "b": [0.7319, 0.5972, 0.7582, 0.6186]}, {"w": "image", "b": [0.7643, 0.5972, 0.8147, 0.6186]}, {"w": "bor‐", "b": [0.8208, 0.5972, 0.8572, 0.6186]}, {"w": "ders", "b": [0.1429, 0.6163, 0.1781, 0.6377]}, {"w": "are", "b": [0.1862, 0.6163, 0.2119, 0.6377]}, {"w": "almost", "b": [0.22, 0.6163, 0.2761, 0.6377]}, {"w": "always", "b": [0.2842, 0.6163, 0.3388, 0.6377]}, {"w": "white,", "b": [0.3469, 0.6163, 0.3978, 0.6377]}, {"w": "so", "b": [0.4059, 0.6163, 0.4242, 0.6377]}, {"w": "you", "b": [0.4323, 0.6163, 0.4635, 0.6377]}, {"w": "could", "b": [0.4716, 0.6163, 0.5184, 0.6377]}, {"w": "completely", "b": [0.5264, 0.6163, 0.6176, 0.6377]}, {"w": "drop", "b": [0.6257, 0.6163, 0.666, 0.6377]}, {"w": "these", "b": [0.6741, 0.6163, 0.7169, 0.6377]}, {"w": "pixels", "b": [0.725, 0.6163, 0.7731, 0.6377]}, {"w": "from", "b": [0.7811, 0.6163, 0.8227, 0.6377]}, {"w": "the", "b": [0.8308, 0.6163, 0.8571, 0.6377]}, {"w": "training", "b": [0.1429, 0.6353, 0.2098, 0.6567]}, {"w": "set", "b": [0.2166, 0.6353, 0.2395, 0.6567]}, {"w": "without", "b": [0.2463, 0.6353, 0.3117, 0.6567]}, {"w": "losing", "b": [0.3185, 0.6353, 0.3688, 0.6567]}, {"w": "much", "b": [0.3756, 0.6353, 0.4233, 0.6567]}, {"w": "information.", "b": [0.4301, 0.6353, 0.5362, 0.6567]}, {"w": "Figure", "b": [0.543, 0.6353, 0.597, 0.6567]}, {"w": "7-6", "b": [0.6038, 0.6353, 0.6313, 0.6567]}, {"w": "confirms", "b": [0.6381, 0.6353, 0.7131, 0.6567]}, {"w": "that", "b": [0.7199, 0.6353, 0.7525, 0.6567]}, {"w": "these", "b": [0.7594, 0.6353, 0.8022, 0.6567]}, {"w": "pixels", "b": [0.809, 0.6353, 0.8571, 0.6567]}, {"w": "are", "b": [0.1428, 0.6544, 0.1686, 0.6758]}, {"w": "utterly", "b": [0.1749, 0.6544, 0.23, 0.6758]}, {"w": "unimportant", "b": [0.2363, 0.6544, 0.3432, 0.6758]}, {"w": "for", "b": [0.3494, 0.6544, 0.374, 0.6758]}, {"w": "the", "b": [0.3803, 0.6544, 0.4066, 0.6758]}, {"w": "classification", "b": [0.4129, 0.6544, 0.5202, 0.6758]}, {"w": "task.", "b": [0.5265, 0.6544, 0.5648, 0.6758]}, {"w": "Moreover,", "b": [0.571, 0.6544, 0.6566, 0.6758]}, {"w": "two", "b": [0.6628, 0.6544, 0.6941, 0.6758]}, {"w": "neighboring", "b": [0.7004, 0.6544, 0.8027, 0.6758]}, {"w": "pixels", "b": [0.809, 0.6544, 0.8571, 0.6758]}, {"w": "are", "b": [0.1429, 0.6734, 0.1686, 0.6948]}, {"w": "often", "b": [0.1749, 0.6734, 0.2183, 0.6948]}, {"w": "highly", "b": [0.2246, 0.6734, 0.277, 0.6948]}, {"w": "correlated:", "b": [0.2833, 0.6734, 0.3721, 0.6948]}, {"w": "if", "b": [0.3784, 0.6734, 0.3901, 0.6948]}, {"w": "you", "b": [0.3964, 0.6734, 0.4277, 0.6948]}, {"w": "merge", "b": [0.434, 0.6734, 0.4862, 0.6948]}, {"w": "them", "b": [0.4925, 0.6734, 0.5359, 0.6948]}, {"w": "into", "b": [0.5422, 0.6734, 0.5758, 0.6948]}, {"w": "a", "b": [0.5821, 0.6734, 0.5912, 0.6948]}, {"w": "single", "b": [0.5976, 0.6734, 0.6461, 0.6948]}, {"w": "pixel", "b": [0.6524, 0.6734, 0.6928, 0.6948]}, {"w": "(e.g.,", "b": [0.6991, 0.6734, 0.7392, 0.6948]}, {"w": "by", "b": [0.7455, 0.6734, 0.7656, 0.6948]}, {"w": "taking", "b": [0.7719, 0.6734, 0.8245, 0.6948]}, {"w": "the", "b": [0.8308, 0.6734, 0.8571, 0.6948]}, {"w": "mean", "b": [0.1429, 0.6925, 0.1893, 0.7139]}, {"w": "of", "b": [0.194, 0.6925, 0.2108, 0.7139]}, {"w": "the", "b": [0.2156, 0.6925, 0.2419, 0.7139]}, {"w": "two", "b": [0.2466, 0.6925, 0.2779, 0.7139]}, {"w": "pixel", "b": [0.2826, 0.6925, 0.3231, 0.7139]}, {"w": "intensities),", "b": [0.3278, 0.6925, 0.4246, 0.7139]}, {"w": "you", "b": [0.4293, 0.6925, 0.4606, 0.7139]}, {"w": "will", "b": [0.4653, 0.6925, 0.4957, 0.7139]}, {"w": "not", "b": [0.5004, 0.6925, 0.5288, 0.7139]}, {"w": "lose", "b": [0.5335, 0.6925, 0.5659, 0.7139]}, {"w": "much", "b": [0.5707, 0.6925, 0.6183, 0.7139]}, {"w": "information.", "b": [0.6231, 0.6925, 0.7291, 0.7139]}]}, {"id": "b_4", "type": "paragraph", "text": "215", "words": [{"w": "215", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 242, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 Well, four dimensions if you count time, and a few more if you are a string theorist.", "words": [{"w": "1", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "Well,", "b": [0.1587, 0.8749, 0.191, 0.8912]}, {"w": "four", "b": [0.1946, 0.8749, 0.2217, 0.8912]}, {"w": "dimensions", "b": [0.2253, 0.8749, 0.2991, 0.8912]}, {"w": "if", "b": [0.3027, 0.8749, 0.3116, 0.8912]}, {"w": "you", "b": [0.3152, 0.8749, 0.339, 0.8912]}, {"w": "count", "b": [0.3426, 0.8749, 0.3791, 0.8912]}, {"w": "time,", "b": [0.3827, 0.8749, 0.4152, 0.8912]}, {"w": "and", "b": [0.4188, 0.8749, 0.4428, 0.8912]}, {"w": "a", "b": [0.4464, 0.8749, 0.4534, 0.8912]}, {"w": "few", "b": [0.457, 0.8749, 0.4793, 0.8912]}, {"w": "more", "b": [0.4829, 0.8749, 0.5166, 0.8912]}, {"w": "if", "b": [0.5202, 0.8749, 0.5292, 0.8912]}, {"w": "you", "b": [0.5328, 0.8749, 0.5566, 0.8912]}, {"w": "are", "b": [0.5602, 0.8749, 0.5798, 0.8912]}, {"w": "a", "b": [0.5834, 0.8749, 0.5904, 0.8912]}, {"w": "string", "b": [0.594, 0.8749, 0.6309, 0.8912]}, {"w": "theorist.", "b": [0.6345, 0.8749, 0.6871, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Reducing dimensionality does lose some information (just like compressing an image to JPEG can degrade its quality), so even though it will speed up training, it may also make your system per‐ form slightly worse. It also makes your pipelines a bit more com‐ plex and thus harder to maintain. So you should first try to train your system with the original data before considering using dimen‐ sionality reduction if training is too slow. In some cases, however, reducing the dimensionality of the training data may filter out some noise and unnecessary details and thus result in higher per‐ formance (but in general it won’t; it will just speed up training).", "words": [{"w": "Reducing", "b": [0.2714, 0.0793, 0.344, 0.0989]}, {"w": "dimensionality", "b": [0.3537, 0.0793, 0.4681, 0.0989]}, {"w": "does", "b": [0.4778, 0.0793, 0.5126, 0.0989]}, {"w": "lose", "b": [0.5224, 0.0793, 0.552, 0.0989]}, {"w": "some", "b": [0.5617, 0.0793, 0.6021, 0.0989]}, {"w": "information", "b": [0.6118, 0.0793, 0.7044, 0.0989]}, {"w": "(just", "b": [0.7141, 0.0793, 0.7485, 0.0989]}, {"w": "like", "b": [0.7582, 0.0793, 0.7857, 0.0989]}, {"w": "compressing", "b": [0.2714, 0.0967, 0.368, 0.1163]}, {"w": "an", "b": [0.3755, 0.0967, 0.3942, 0.1163]}, {"w": "image", "b": [0.4017, 0.0967, 0.4478, 0.1163]}, {"w": "to", "b": [0.4553, 0.0967, 0.4708, 0.1163]}, {"w": "JPEG", "b": [0.4783, 0.0967, 0.5197, 0.1163]}, {"w": "can", "b": [0.5272, 0.0967, 0.554, 0.1163]}, {"w": "degrade", "b": [0.5615, 0.0967, 0.6221, 0.1163]}, {"w": "its", "b": [0.6296, 0.0967, 0.6475, 0.1163]}, {"w": "quality),", "b": [0.655, 0.0967, 0.7186, 0.1163]}, {"w": "so", "b": [0.7261, 0.0967, 0.7428, 0.1163]}, {"w": "even", "b": [0.7503, 0.0967, 0.7857, 0.1163]}, {"w": "though", "b": [0.2714, 0.1141, 0.3263, 0.1337]}, {"w": "it", "b": [0.3311, 0.1141, 0.342, 0.1337]}, {"w": "will", "b": [0.3468, 0.1141, 0.3746, 0.1337]}, {"w": "speed", "b": [0.3794, 0.1141, 0.4226, 0.1337]}, {"w": "up", "b": [0.4274, 0.1141, 0.4474, 0.1337]}, {"w": "training,", "b": [0.4522, 0.1141, 0.5178, 0.1337]}, {"w": "it", "b": [0.5226, 0.1141, 0.5335, 0.1337]}, {"w": "may", "b": [0.5383, 0.1141, 0.5706, 0.1337]}, {"w": "also", "b": [0.5754, 0.1141, 0.6053, 0.1337]}, {"w": "make", "b": [0.6101, 0.1141, 0.6516, 0.1337]}, {"w": "your", "b": [0.6564, 0.1141, 0.692, 0.1337]}, {"w": "system", "b": [0.6968, 0.1141, 0.749, 0.1337]}, {"w": "per‐", "b": [0.7538, 0.1141, 0.7857, 0.1337]}, {"w": "form", "b": [0.2714, 0.1315, 0.3094, 0.1511]}, {"w": "slightly", "b": [0.3156, 0.1315, 0.3706, 0.1511]}, {"w": "worse.", "b": [0.3768, 0.1315, 0.4261, 0.1511]}, {"w": "It", "b": [0.4323, 0.1315, 0.4439, 0.1511]}, {"w": "also", "b": [0.4501, 0.1315, 0.48, 0.1511]}, {"w": "makes", "b": [0.4862, 0.1315, 0.5347, 0.1511]}, {"w": "your", "b": [0.5409, 0.1315, 0.5765, 0.1511]}, {"w": "pipelines", "b": [0.5827, 0.1315, 0.6513, 0.1511]}, {"w": "a", "b": [0.6575, 0.1315, 0.6659, 0.1511]}, {"w": "bit", "b": [0.6721, 0.1315, 0.6927, 0.1511]}, {"w": "more", "b": [0.6989, 0.1315, 0.7394, 0.1511]}, {"w": "com‐", "b": [0.7456, 0.1315, 0.7857, 0.1511]}, {"w": "plex", "b": [0.2714, 0.1489, 0.3033, 0.1685]}, {"w": "and", "b": [0.3097, 0.1489, 0.3386, 0.1685]}, {"w": "thus", "b": [0.345, 0.1489, 0.3777, 0.1685]}, {"w": "harder", "b": [0.3841, 0.1489, 0.4349, 0.1685]}, {"w": "to", "b": [0.4414, 0.1489, 0.4569, 0.1685]}, {"w": "maintain.", "b": [0.4633, 0.1489, 0.5365, 0.1685]}, {"w": "So", "b": [0.5429, 0.1489, 0.5617, 0.1685]}, {"w": "you", "b": [0.5681, 0.1489, 0.5967, 0.1685]}, {"w": "should", "b": [0.6031, 0.1489, 0.6549, 0.1685]}, {"w": "first", "b": [0.6614, 0.1489, 0.692, 0.1685]}, {"w": "try", "b": [0.6984, 0.1489, 0.7206, 0.1685]}, {"w": "to", "b": [0.727, 0.1489, 0.7425, 0.1685]}, {"w": "train", "b": [0.7489, 0.1489, 0.7857, 0.1685]}, {"w": "your", "b": [0.2714, 0.1664, 0.307, 0.1859]}, {"w": "system", "b": [0.3116, 0.1664, 0.3638, 0.1859]}, {"w": "with", "b": [0.3683, 0.1664, 0.4024, 0.1859]}, {"w": "the", "b": [0.407, 0.1664, 0.431, 0.1859]}, {"w": "original", "b": [0.4356, 0.1664, 0.4951, 0.1859]}, {"w": "data", "b": [0.4996, 0.1664, 0.5318, 0.1859]}, {"w": "before", "b": [0.5363, 0.1664, 0.5846, 0.1859]}, {"w": "considering", "b": [0.5891, 0.1664, 0.6791, 0.1859]}, {"w": "using", "b": [0.6836, 0.1664, 0.7251, 0.1859]}, {"w": "dimen‐", "b": [0.7297, 0.1664, 0.7857, 0.1859]}, {"w": "sionality", "b": [0.2714, 0.1838, 0.3365, 0.2033]}, {"w": "reduction", "b": [0.3424, 0.1838, 0.4169, 0.2033]}, {"w": "if", "b": [0.4229, 0.1838, 0.4336, 0.2033]}, {"w": "training", "b": [0.4396, 0.1838, 0.5008, 0.2033]}, {"w": "is", "b": [0.5067, 0.1838, 0.5188, 0.2033]}, {"w": "too", "b": [0.5248, 0.1838, 0.55, 0.2033]}, {"w": "slow.", "b": [0.556, 0.1838, 0.5935, 0.2033]}, {"w": "In", "b": [0.5995, 0.1838, 0.6164, 0.2033]}, {"w": "some", "b": [0.6224, 0.1838, 0.6628, 0.2033]}, {"w": "cases,", "b": [0.6688, 0.1838, 0.7116, 0.2033]}, {"w": "however,", "b": [0.7176, 0.1838, 0.7857, 0.2033]}, {"w": "reducing", "b": [0.2714, 0.2012, 0.3392, 0.2208]}, {"w": "the", "b": [0.3482, 0.2012, 0.3723, 0.2208]}, {"w": "dimensionality", "b": [0.3812, 0.2012, 0.4956, 0.2208]}, {"w": "of", "b": [0.5045, 0.2012, 0.5199, 0.2208]}, {"w": "the", "b": [0.5289, 0.2012, 0.5529, 0.2208]}, {"w": "training", "b": [0.5619, 0.2012, 0.6231, 0.2208]}, {"w": "data", "b": [0.6321, 0.2012, 0.6643, 0.2208]}, {"w": "may", "b": [0.6733, 0.2012, 0.7056, 0.2208]}, {"w": "filter", "b": [0.7146, 0.2012, 0.7511, 0.2208]}, {"w": "out", "b": [0.7601, 0.2012, 0.7857, 0.2208]}, {"w": "some", "b": [0.2714, 0.2186, 0.3118, 0.2382]}, {"w": "noise", "b": [0.3178, 0.2186, 0.3581, 0.2382]}, {"w": "and", "b": [0.3642, 0.2186, 0.393, 0.2382]}, {"w": "unnecessary", "b": [0.399, 0.2186, 0.4929, 0.2382]}, {"w": "details", "b": [0.4989, 0.2186, 0.5482, 0.2382]}, {"w": "and", "b": [0.5542, 0.2186, 0.583, 0.2382]}, {"w": "thus", "b": [0.5891, 0.2186, 0.6218, 0.2382]}, {"w": "result", "b": [0.6278, 0.2186, 0.6707, 0.2382]}, {"w": "in", "b": [0.6767, 0.2186, 0.6922, 0.2382]}, {"w": "higher", "b": [0.6982, 0.2186, 0.7478, 0.2382]}, {"w": "per‐", "b": [0.7538, 0.2186, 0.7857, 0.2382]}, {"w": "formance", "b": [0.2714, 0.236, 0.3444, 0.2556]}, {"w": "(but", "b": [0.3487, 0.236, 0.3809, 0.2556]}, {"w": "in", "b": [0.3852, 0.236, 0.4007, 0.2556]}, {"w": "general", "b": [0.405, 0.236, 0.4608, 0.2556]}, {"w": "it", "b": [0.4651, 0.236, 0.4761, 0.2556]}, {"w": "won’t;", "b": [0.4804, 0.236, 0.5258, 0.2556]}, {"w": "it", "b": [0.5301, 0.236, 0.541, 0.2556]}, {"w": "will", "b": [0.5453, 0.236, 0.5731, 0.2556]}, {"w": "just", "b": [0.5774, 0.236, 0.6052, 0.2556]}, {"w": "speed", "b": [0.6095, 0.236, 0.6528, 0.2556]}, {"w": "up", "b": [0.6571, 0.236, 0.6772, 0.2556]}, {"w": "training).", "b": [0.6815, 0.236, 0.7536, 0.2556]}]}, {"id": "b_2", "type": "paragraph", "text": "Apart from speeding up training, dimensionality reduction is also extremely useful for data visualization (or DataViz). Reducing the number of dimensions down to two (or three) makes it possible to plot a condensed view of a high-dimensional training set on a graph and often gain some important insights by visually detecting patterns, such as clusters. Moreover, DataViz is essential to communicate your conclusions to people who are not data scientists, in particular decision makers who will use your results.", "words": [{"w": "Apart", "b": [0.1429, 0.2759, 0.1906, 0.2973]}, {"w": "from", "b": [0.1978, 0.2759, 0.2394, 0.2973]}, {"w": "speeding", "b": [0.2466, 0.2759, 0.3206, 0.2973]}, {"w": "up", "b": [0.3279, 0.2759, 0.3499, 0.2973]}, {"w": "training,", "b": [0.3571, 0.2759, 0.4288, 0.2973]}, {"w": "dimensionality", "b": [0.4361, 0.2759, 0.5611, 0.2973]}, {"w": "reduction", "b": [0.5684, 0.2759, 0.6498, 0.2973]}, {"w": "is", "b": [0.657, 0.2759, 0.6703, 0.2973]}, {"w": "also", "b": [0.6775, 0.2759, 0.7102, 0.2973]}, {"w": "extremely", "b": [0.7175, 0.2759, 0.7998, 0.2973]}, {"w": "useful", "b": [0.8071, 0.2759, 0.8572, 0.2973]}, {"w": "for", "b": [0.1429, 0.2949, 0.1674, 0.3163]}, {"w": "data", "b": [0.1726, 0.2949, 0.2078, 0.3163]}, {"w": "visualization", "b": [0.213, 0.2949, 0.3184, 0.3163]}, {"w": "(or", "b": [0.3235, 0.2949, 0.3491, 0.3163]}, {"w": "DataViz).", "b": [0.3543, 0.2947, 0.4346, 0.3163]}, {"w": "Reducing", "b": [0.4398, 0.2949, 0.5192, 0.3163]}, {"w": "the", "b": [0.5244, 0.2949, 0.5507, 0.3163]}, {"w": "number", "b": [0.5559, 0.2949, 0.6222, 0.3163]}, {"w": "of", "b": [0.6274, 0.2949, 0.6441, 0.3163]}, {"w": "dimensions", "b": [0.6493, 0.2949, 0.7461, 0.3163]}, {"w": "down", "b": [0.7513, 0.2949, 0.7986, 0.3163]}, {"w": "to", "b": [0.8037, 0.2949, 0.8207, 0.3163]}, {"w": "two", "b": [0.8259, 0.2949, 0.8571, 0.3163]}, {"w": "(or", "b": [0.1429, 0.314, 0.1684, 0.3354]}, {"w": "three)", "b": [0.1744, 0.314, 0.2245, 0.3354]}, {"w": "makes", "b": [0.2305, 0.314, 0.2836, 0.3354]}, {"w": "it", "b": [0.2895, 0.314, 0.3015, 0.3354]}, {"w": "possible", "b": [0.3075, 0.314, 0.3746, 0.3354]}, {"w": "to", "b": [0.3806, 0.314, 0.3976, 0.3354]}, {"w": "plot", "b": [0.4035, 0.314, 0.4367, 0.3354]}, {"w": "a", "b": [0.4427, 0.314, 0.4518, 0.3354]}, {"w": "condensed", "b": [0.4578, 0.314, 0.5474, 0.3354]}, {"w": "view", "b": [0.5534, 0.314, 0.5918, 0.3354]}, {"w": "of", "b": [0.5977, 0.314, 0.6145, 0.3354]}, {"w": "a", "b": [0.6205, 0.314, 0.6297, 0.3354]}, {"w": "high-dimensional", "b": [0.6357, 0.314, 0.7842, 0.3354]}, {"w": "training", "b": [0.7902, 0.314, 0.8571, 0.3354]}, {"w": "set", "b": [0.1429, 0.333, 0.1657, 0.3544]}, {"w": "on", "b": [0.1715, 0.333, 0.1935, 0.3544]}, {"w": "a", "b": [0.1992, 0.333, 0.2084, 0.3544]}, {"w": "graph", "b": [0.2142, 0.333, 0.2624, 0.3544]}, {"w": "and", "b": [0.2682, 0.333, 0.2997, 0.3544]}, {"w": "often", "b": [0.3055, 0.333, 0.3489, 0.3544]}, {"w": "gain", "b": [0.3546, 0.333, 0.3905, 0.3544]}, {"w": "some", "b": [0.3963, 0.333, 0.4405, 0.3544]}, {"w": "important", "b": [0.4462, 0.333, 0.5306, 0.3544]}, {"w": "insights", "b": [0.5364, 0.333, 0.6011, 0.3544]}, {"w": "by", "b": [0.6068, 0.333, 0.627, 0.3544]}, {"w": "visually", "b": [0.6327, 0.333, 0.6959, 0.3544]}, {"w": "detecting", "b": [0.7017, 0.333, 0.7786, 0.3544]}, {"w": "patterns,", "b": [0.7844, 0.333, 0.8571, 0.3544]}, {"w": "such", "b": [0.1429, 0.3521, 0.1815, 0.3735]}, {"w": "as", "b": [0.1877, 0.3521, 0.2045, 0.3735]}, {"w": "clusters.", "b": [0.2107, 0.3521, 0.2788, 0.3735]}, {"w": "Moreover,", "b": [0.285, 0.3521, 0.3705, 0.3735]}, {"w": "DataViz", "b": [0.3767, 0.3521, 0.4444, 0.3735]}, {"w": "is", "b": [0.4506, 0.3521, 0.4638, 0.3735]}, {"w": "essential", "b": [0.47, 0.3521, 0.5404, 0.3735]}, {"w": "to", "b": [0.5466, 0.3521, 0.5636, 0.3735]}, {"w": "communicate", "b": [0.5698, 0.3521, 0.6837, 0.3735]}, {"w": "your", "b": [0.6899, 0.3521, 0.7289, 0.3735]}, {"w": "conclusions", "b": [0.7351, 0.3521, 0.834, 0.3735]}, {"w": "to", "b": [0.8402, 0.3521, 0.8572, 0.3735]}, {"w": "people", "b": [0.1429, 0.3711, 0.1983, 0.3925]}, {"w": "who", "b": [0.2053, 0.3711, 0.2413, 0.3925]}, {"w": "are", "b": [0.2484, 0.3711, 0.2741, 0.3925]}, {"w": "not", "b": [0.2811, 0.3711, 0.3095, 0.3925]}, {"w": "data", "b": [0.3165, 0.3711, 0.3518, 0.3925]}, {"w": "scientists,", "b": [0.3588, 0.3711, 0.439, 0.3925]}, {"w": "in", "b": [0.446, 0.3711, 0.463, 0.3925]}, {"w": "particular", "b": [0.47, 0.3711, 0.5518, 0.3925]}, {"w": "decision", "b": [0.5588, 0.3711, 0.6283, 0.3925]}, {"w": "makers", "b": [0.6353, 0.3711, 0.6961, 0.3925]}, {"w": "who", "b": [0.7031, 0.3711, 0.7391, 0.3925]}, {"w": "will", "b": [0.7462, 0.3711, 0.7766, 0.3925]}, {"w": "use", "b": [0.7836, 0.3711, 0.8111, 0.3925]}, {"w": "your", "b": [0.8182, 0.3711, 0.8571, 0.3925]}, {"w": "results.", "b": [0.1429, 0.3902, 0.2022, 0.4116]}]}, {"id": "b_3", "type": "paragraph", "text": "In this chapter we will discuss the curse of dimensionality and get a sense of what goes on in high-dimensional space. Then, we will present the two main approaches to dimensionality reduction (projection and Manifold Learning), and we will go through three of the most popular dimensionality reduction techniques: PCA, Kernel PCA, and LLE.", "words": [{"w": "In", "b": [0.1429, 0.4183, 0.1614, 0.4397]}, {"w": "this", "b": [0.1687, 0.4183, 0.1994, 0.4397]}, {"w": "chapter", "b": [0.2067, 0.4183, 0.2693, 0.4397]}, {"w": "we", "b": [0.2766, 0.4183, 0.2997, 0.4397]}, {"w": "will", "b": [0.3071, 0.4183, 0.3375, 0.4397]}, {"w": "discuss", "b": [0.3448, 0.4183, 0.4042, 0.4397]}, {"w": "the", "b": [0.4115, 0.4183, 0.4379, 0.4397]}, {"w": "curse", "b": [0.4452, 0.4183, 0.4893, 0.4397]}, {"w": "of", "b": [0.4966, 0.4183, 0.5134, 0.4397]}, {"w": "dimensionality", "b": [0.5207, 0.4183, 0.6458, 0.4397]}, {"w": "and", "b": [0.6531, 0.4183, 0.6847, 0.4397]}, {"w": "get", "b": [0.692, 0.4183, 0.717, 0.4397]}, {"w": "a", "b": [0.7243, 0.4183, 0.7335, 0.4397]}, {"w": "sense", "b": [0.7408, 0.4183, 0.7852, 0.4397]}, {"w": "of", "b": [0.7925, 0.4183, 0.8093, 0.4397]}, {"w": "what", "b": [0.8166, 0.4183, 0.8571, 0.4397]}, {"w": "goes", "b": [0.1428, 0.4373, 0.1797, 0.4588]}, {"w": "on", "b": [0.1846, 0.4373, 0.2066, 0.4588]}, {"w": "in", "b": [0.2115, 0.4373, 0.2285, 0.4588]}, {"w": "high-dimensional", "b": [0.2334, 0.4373, 0.382, 0.4588]}, {"w": "space.", "b": [0.3869, 0.4373, 0.437, 0.4588]}, {"w": "Then,", "b": [0.4419, 0.4373, 0.4909, 0.4588]}, {"w": "we", "b": [0.4957, 0.4373, 0.5189, 0.4588]}, {"w": "will", "b": [0.5238, 0.4373, 0.5542, 0.4588]}, {"w": "present", "b": [0.559, 0.4373, 0.6204, 0.4588]}, {"w": "the", "b": [0.6253, 0.4373, 0.6516, 0.4588]}, {"w": "two", "b": [0.6565, 0.4373, 0.6878, 0.4588]}, {"w": "main", "b": [0.6927, 0.4373, 0.7358, 0.4588]}, {"w": "approaches", "b": [0.7407, 0.4373, 0.8353, 0.4588]}, {"w": "to", "b": [0.8402, 0.4373, 0.8571, 0.4588]}, {"w": "dimensionality", "b": [0.1429, 0.4564, 0.2679, 0.4778]}, {"w": "reduction", "b": [0.2805, 0.4564, 0.3619, 0.4778]}, {"w": "(projection", "b": [0.3744, 0.4564, 0.4679, 0.4778]}, {"w": "and", "b": [0.4804, 0.4564, 0.512, 0.4778]}, {"w": "Manifold", "b": [0.5245, 0.4564, 0.6019, 0.4778]}, {"w": "Learning),", "b": [0.6145, 0.4564, 0.7015, 0.4778]}, {"w": "and", "b": [0.7141, 0.4564, 0.7456, 0.4778]}, {"w": "we", "b": [0.7581, 0.4564, 0.7813, 0.4778]}, {"w": "will", "b": [0.7938, 0.4564, 0.8242, 0.4778]}, {"w": "go", "b": [0.8368, 0.4564, 0.8571, 0.4778]}, {"w": "through", "b": [0.1429, 0.4754, 0.2106, 0.4968]}, {"w": "three", "b": [0.2157, 0.4754, 0.2587, 0.4968]}, {"w": "of", "b": [0.2638, 0.4754, 0.2806, 0.4968]}, {"w": "the", "b": [0.2857, 0.4754, 0.312, 0.4968]}, {"w": "most", "b": [0.3172, 0.4754, 0.3588, 0.4968]}, {"w": "popular", "b": [0.364, 0.4754, 0.4296, 0.4968]}, {"w": "dimensionality", "b": [0.4347, 0.4754, 0.5598, 0.4968]}, {"w": "reduction", "b": [0.5649, 0.4754, 0.6463, 0.4968]}, {"w": "techniques:", "b": [0.6515, 0.4754, 0.7465, 0.4968]}, {"w": "PCA,", "b": [0.7517, 0.4754, 0.7964, 0.4968]}, {"w": "Kernel", "b": [0.8015, 0.4754, 0.8571, 0.4968]}, {"w": "PCA,", "b": [0.1429, 0.4945, 0.1876, 0.5159]}, {"w": "and", "b": [0.1923, 0.4945, 0.2239, 0.5159]}, {"w": "LLE.", "b": [0.2286, 0.4945, 0.2676, 0.5159]}]}, {"id": "b_4", "type": "paragraph", "text": "The Curse of Dimensionality", "words": [{"w": "The", "b": [0.1429, 0.5289, 0.1881, 0.5631]}, {"w": "Curse", "b": [0.194, 0.5289, 0.2611, 0.5631]}, {"w": "of", "b": [0.2671, 0.5289, 0.2922, 0.5631]}, {"w": "Dimensionality", "b": [0.2981, 0.5289, 0.4851, 0.5631]}]}, {"id": "b_5", "type": "paragraph", "text": "We are so used to living in three dimensions1 that our intuition fails us when we try to imagine a high-dimensional space. Even a basic 4D hypercube is incredibly hard to picture in our mind (see Figure 8-1), let alone a 200-dimensional ellipsoid bent in a 1,000-dimensional space.", "words": [{"w": "We", "b": [0.1429, 0.5701, 0.1699, 0.5915]}, {"w": "are", "b": [0.176, 0.5701, 0.2017, 0.5915]}, {"w": "so", "b": [0.2078, 0.5701, 0.226, 0.5915]}, {"w": "used", "b": [0.2321, 0.5701, 0.2707, 0.5915]}, {"w": "to", "b": [0.2767, 0.5701, 0.2937, 0.5915]}, {"w": "living", "b": [0.2998, 0.5701, 0.347, 0.5915]}, {"w": "in", "b": [0.3531, 0.5701, 0.37, 0.5915]}, {"w": "three", "b": [0.3761, 0.5701, 0.419, 0.5915]}, {"w": "dimensions1", "b": [0.4251, 0.5701, 0.5276, 0.5915]}, {"w": "that", "b": [0.5336, 0.5701, 0.5662, 0.5915]}, {"w": "our", "b": [0.5723, 0.5701, 0.6017, 0.5915]}, {"w": "intuition", "b": [0.6078, 0.5701, 0.6813, 0.5915]}, {"w": "fails", "b": [0.6874, 0.5701, 0.7212, 0.5915]}, {"w": "us", "b": [0.7272, 0.5701, 0.7459, 0.5915]}, {"w": "when", "b": [0.752, 0.5701, 0.7976, 0.5915]}, {"w": "we", "b": [0.8037, 0.5701, 0.8268, 0.5915]}, {"w": "try", "b": [0.8329, 0.5701, 0.8571, 0.5915]}, {"w": "to", "b": [0.1428, 0.5891, 0.1598, 0.6105]}, {"w": "imagine", "b": [0.1647, 0.5891, 0.2321, 0.6105]}, {"w": "a", "b": [0.237, 0.5891, 0.2462, 0.6105]}, {"w": "high-dimensional", "b": [0.2511, 0.5891, 0.3997, 0.6105]}, {"w": "space.", "b": [0.4046, 0.5891, 0.4547, 0.6105]}, {"w": "Even", "b": [0.4596, 0.5891, 0.5009, 0.6105]}, {"w": "a", "b": [0.5059, 0.5891, 0.515, 0.6105]}, {"w": "basic", "b": [0.5199, 0.5891, 0.5617, 0.6105]}, {"w": "4D", "b": [0.5666, 0.5891, 0.5919, 0.6105]}, {"w": "hypercube", "b": [0.5969, 0.5891, 0.6839, 0.6105]}, {"w": "is", "b": [0.6888, 0.5891, 0.702, 0.6105]}, {"w": "incredibly", "b": [0.7069, 0.5891, 0.7913, 0.6105]}, {"w": "hard", "b": [0.7962, 0.5891, 0.8352, 0.6105]}, {"w": "to", "b": [0.8402, 0.5891, 0.8571, 0.6105]}, {"w": "picture", "b": [0.1429, 0.6082, 0.2022, 0.6296]}, {"w": "in", "b": [0.2085, 0.6082, 0.2254, 0.6296]}, {"w": "our", "b": [0.2317, 0.6082, 0.2611, 0.6296]}, {"w": "mind", "b": [0.2674, 0.6082, 0.3125, 0.6296]}, {"w": "(see", "b": [0.3188, 0.6082, 0.3513, 0.6296]}, {"w": "Figure", "b": [0.3576, 0.6082, 0.4116, 0.6296]}, {"w": "8-1),", "b": [0.4179, 0.6082, 0.4573, 0.6296]}, {"w": "let", "b": [0.4636, 0.6082, 0.484, 0.6296]}, {"w": "alone", "b": [0.4903, 0.6082, 0.5356, 0.6296]}, {"w": "a", "b": [0.5419, 0.6082, 0.5511, 0.6296]}, {"w": "200-dimensional", "b": [0.5574, 0.6082, 0.6983, 0.6296]}, {"w": "ellipsoid", "b": [0.7046, 0.6082, 0.7754, 0.6296]}, {"w": "bent", "b": [0.7817, 0.6082, 0.8184, 0.6296]}, {"w": "in", "b": [0.8247, 0.6082, 0.8417, 0.6296]}, {"w": "a", "b": [0.848, 0.6082, 0.8572, 0.6296]}, {"w": "1,000-dimensional", "b": [0.1429, 0.6272, 0.2986, 0.6486]}, {"w": "space.", "b": [0.3033, 0.6272, 0.3534, 0.6486]}]}, {"id": "b_6", "type": "paragraph", "text": "216 | Chapter 8: Dimensionality Reduction", "words": [{"w": "216", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "8:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Dimensionality", "b": [0.2673, 0.9225, 0.3562, 0.9388]}, {"w": "Reduction", "b": [0.359, 0.9225, 0.4186, 0.9388]}]}]}, {"page": 243, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "2 Watch a rotating tesseract projected into 3D space at https://homl.info/30. Image by Wikipedia user Nerd‐ Boy1392 (Creative Commons BY-SA 3.0). Reproduced from https://en.wikipedia.org/wiki/Tesseract.", "words": [{"w": "2", "b": [0.1451, 0.8265, 0.1518, 0.8408]}, {"w": "Watch", "b": [0.1587, 0.825, 0.1993, 0.8413]}, {"w": "a", "b": [0.2029, 0.825, 0.2098, 0.8413]}, {"w": "rotating", "b": [0.2134, 0.825, 0.2641, 0.8413]}, {"w": "tesseract", "b": [0.2677, 0.825, 0.3221, 0.8413]}, {"w": "projected", "b": [0.3257, 0.825, 0.3855, 0.8413]}, {"w": "into", "b": [0.3891, 0.825, 0.4147, 0.8413]}, {"w": "3D", "b": [0.4183, 0.825, 0.4376, 0.8413]}, {"w": "space", "b": [0.4412, 0.825, 0.4758, 0.8413]}, {"w": "at", "b": [0.4794, 0.825, 0.4909, 0.8413]}, {"w": "https://homl.info/30.", "b": [0.4945, 0.8249, 0.6221, 0.8413]}, {"w": "Image", "b": [0.6257, 0.825, 0.6653, 0.8413]}, {"w": "by", "b": [0.6689, 0.825, 0.6843, 0.8413]}, {"w": "Wikipedia", "b": [0.6879, 0.825, 0.7537, 0.8413]}, {"w": "user", "b": [0.7573, 0.825, 0.7842, 0.8413]}, {"w": "Nerd‐", "b": [0.7878, 0.825, 0.8258, 0.8413]}, {"w": "Boy1392", "b": [0.1587, 0.8401, 0.2142, 0.8565]}, {"w": "(Creative", "b": [0.2178, 0.8401, 0.2764, 0.8565]}, {"w": "Commons", "b": [0.28, 0.8401, 0.3472, 0.8565]}, {"w": "BY-SA", "b": [0.3508, 0.8401, 0.393, 0.8565]}, {"w": "3.0).", "b": [0.3966, 0.8401, 0.4246, 0.8565]}, {"w": "Reproduced", "b": [0.4282, 0.8401, 0.5057, 0.8565]}, {"w": "from", "b": [0.5093, 0.8401, 0.541, 0.8565]}, {"w": "https://en.wikipedia.org/wiki/Tesseract.", "b": [0.5446, 0.84, 0.7871, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "3 Fun fact: anyone you know is probably an extremist in at least one dimension (e.g., how much sugar they put in their coffee), if you consider enough dimensions.", "words": [{"w": "3", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Fun", "b": [0.1587, 0.8598, 0.1839, 0.8761]}, {"w": "fact:", "b": [0.1875, 0.8598, 0.2144, 0.8761]}, {"w": "anyone", "b": [0.218, 0.8598, 0.2641, 0.8761]}, {"w": "you", "b": [0.2677, 0.8598, 0.2915, 0.8761]}, {"w": "know", "b": [0.2951, 0.8598, 0.3306, 0.8761]}, {"w": "is", "b": [0.3342, 0.8598, 0.3443, 0.8761]}, {"w": "probably", "b": [0.3479, 0.8598, 0.4046, 0.8761]}, {"w": "an", "b": [0.4082, 0.8598, 0.4238, 0.8761]}, {"w": "extremist", "b": [0.4274, 0.8598, 0.4871, 0.8761]}, {"w": "in", "b": [0.4907, 0.8598, 0.5036, 0.8761]}, {"w": "at", "b": [0.5072, 0.8598, 0.5187, 0.8761]}, {"w": "least", "b": [0.5223, 0.8598, 0.5507, 0.8761]}, {"w": "one", "b": [0.5543, 0.8598, 0.5779, 0.8761]}, {"w": "dimension", "b": [0.5815, 0.8598, 0.6494, 0.8761]}, {"w": "(e.g.,", "b": [0.653, 0.8598, 0.6835, 0.8761]}, {"w": "how", "b": [0.6871, 0.8598, 0.7146, 0.8761]}, {"w": "much", "b": [0.7182, 0.8598, 0.7545, 0.8761]}, {"w": "sugar", "b": [0.7581, 0.8598, 0.7926, 0.8761]}, {"w": "they", "b": [0.7962, 0.8598, 0.8236, 0.8761]}, {"w": "put", "b": [0.8272, 0.8598, 0.8488, 0.8761]}, {"w": "in", "b": [0.1587, 0.8749, 0.1717, 0.8912]}, {"w": "their", "b": [0.1753, 0.8749, 0.2055, 0.8912]}, {"w": "coffee),", "b": [0.2091, 0.8749, 0.2559, 0.8912]}, {"w": "if", "b": [0.2595, 0.8749, 0.2684, 0.8912]}, {"w": "you", "b": [0.272, 0.8749, 0.2959, 0.8912]}, {"w": "consider", "b": [0.2995, 0.8749, 0.354, 0.8912]}, {"w": "enough", "b": [0.3577, 0.8749, 0.4055, 0.8912]}, {"w": "dimensions.", "b": [0.4091, 0.8749, 0.4865, 0.8912]}]}, {"id": "b_2", "type": "equation", "text": "Figure 8-1. Point, segment, square, cube, and tesseract (0D to 4D hypercubes)2", "words": [{"w": "Figure", "b": [0.1429, 0.2739, 0.1943, 0.2955]}, {"w": "8-1.", "b": [0.1991, 0.2739, 0.2308, 0.2955]}, {"w": "Point,", "b": [0.2356, 0.2739, 0.2835, 0.2955]}, {"w": "segment,", "b": [0.2882, 0.2739, 0.3587, 0.2955]}, {"w": "square,", "b": [0.3635, 0.2739, 0.4217, 0.2955]}, {"w": "cube,", "b": [0.4265, 0.2739, 0.4685, 0.2955]}, {"w": "and", "b": [0.4733, 0.2739, 0.5047, 0.2955]}, {"w": "tesseract", "b": [0.5095, 0.2739, 0.5778, 0.2955]}, {"w": "(0D", "b": [0.5826, 0.2739, 0.6143, 0.2955]}, {"w": "to", "b": [0.6191, 0.2739, 0.635, 0.2955]}, {"w": "4D", "b": [0.6398, 0.2739, 0.6645, 0.2955]}, {"w": "hypercubes)2", "b": [0.6693, 0.2739, 0.7711, 0.2955]}]}, {"id": "b_3", "type": "paragraph", "text": "It turns out that many things behave very differently in high-dimensional space. For example, if you pick a random point in a unit square (a 1 × 1 square), it will have only about a 0.4% chance of being located less than 0.001 from a border (in other words, it is very unlikely that a random point will be “extreme” along any dimension). But in a 10,000-dimensional unit hypercube (a 1 × 1 × ⋯ × 1 cube, with ten thousand 1s), this probability is greater than 99.999999%. Most points in a high-dimensional hypercube are very close to the border.3", "words": [{"w": "It", "b": [0.1429, 0.3113, 0.1555, 0.3327]}, {"w": "turns", "b": [0.1616, 0.3113, 0.2058, 0.3327]}, {"w": "out", "b": [0.2118, 0.3113, 0.2399, 0.3327]}, {"w": "that", "b": [0.246, 0.3113, 0.2785, 0.3327]}, {"w": "many", "b": [0.2846, 0.3113, 0.3313, 0.3327]}, {"w": "things", "b": [0.3374, 0.3113, 0.3892, 0.3327]}, {"w": "behave", "b": [0.3953, 0.3113, 0.4531, 0.3327]}, {"w": "very", "b": [0.4592, 0.3113, 0.4956, 0.3327]}, {"w": "differently", "b": [0.5017, 0.3113, 0.5882, 0.3327]}, {"w": "in", "b": [0.5943, 0.3113, 0.6113, 0.3327]}, {"w": "high-dimensional", "b": [0.6173, 0.3113, 0.7659, 0.3327]}, {"w": "space.", "b": [0.772, 0.3113, 0.8221, 0.3327]}, {"w": "For", "b": [0.8282, 0.3113, 0.8572, 0.3327]}, {"w": "example,", "b": [0.1429, 0.3304, 0.2172, 0.3518]}, {"w": "if", "b": [0.222, 0.3304, 0.2337, 0.3518]}, {"w": "you", "b": [0.2386, 0.3304, 0.2698, 0.3518]}, {"w": "pick", "b": [0.2747, 0.3304, 0.3103, 0.3518]}, {"w": "a", "b": [0.3152, 0.3304, 0.3243, 0.3518]}, {"w": "random", "b": [0.3292, 0.3304, 0.3961, 0.3518]}, {"w": "point", "b": [0.401, 0.3304, 0.4455, 0.3518]}, {"w": "in", "b": [0.4503, 0.3304, 0.4673, 0.3518]}, {"w": "a", "b": [0.4721, 0.3304, 0.4813, 0.3518]}, {"w": "unit", "b": [0.4861, 0.3304, 0.5205, 0.3518]}, {"w": "square", "b": [0.5254, 0.3304, 0.5805, 0.3518]}, {"w": "(a", "b": [0.5853, 0.3304, 0.6017, 0.3518]}, {"w": "1", "b": [0.6065, 0.3304, 0.6165, 0.3518]}, {"w": "×", "b": [0.6214, 0.3304, 0.6334, 0.3518]}, {"w": "1", "b": [0.6383, 0.3304, 0.6483, 0.3518]}, {"w": "square),", "b": [0.6531, 0.3304, 0.7202, 0.3518]}, {"w": "it", "b": [0.725, 0.3304, 0.737, 0.3518]}, {"w": "will", "b": [0.7418, 0.3304, 0.7722, 0.3518]}, {"w": "have", "b": [0.777, 0.3304, 0.8154, 0.3518]}, {"w": "only", "b": [0.8203, 0.3304, 0.8571, 0.3518]}, {"w": "about", "b": [0.1429, 0.3494, 0.1906, 0.3708]}, {"w": "a", "b": [0.1956, 0.3494, 0.2048, 0.3708]}, {"w": "0.4%", "b": [0.2097, 0.3494, 0.2502, 0.3708]}, {"w": "chance", "b": [0.2552, 0.3494, 0.3134, 0.3708]}, {"w": "of", "b": [0.3184, 0.3494, 0.3352, 0.3708]}, {"w": "being", "b": [0.3402, 0.3494, 0.3863, 0.3708]}, {"w": "located", "b": [0.3913, 0.3494, 0.451, 0.3708]}, {"w": "less", "b": [0.456, 0.3494, 0.4854, 0.3708]}, {"w": "than", "b": [0.4904, 0.3494, 0.5284, 0.3708]}, {"w": "0.001", "b": [0.5334, 0.3494, 0.5781, 0.3708]}, {"w": "from", "b": [0.5831, 0.3494, 0.6247, 0.3708]}, {"w": "a", "b": [0.6297, 0.3494, 0.6388, 0.3708]}, {"w": "border", "b": [0.6438, 0.3494, 0.7003, 0.3708]}, {"w": "(in", "b": [0.7053, 0.3494, 0.7295, 0.3708]}, {"w": "other", "b": [0.7345, 0.3494, 0.7792, 0.3708]}, {"w": "words,", "b": [0.7842, 0.3494, 0.8402, 0.3708]}, {"w": "it", "b": [0.8452, 0.3494, 0.8571, 0.3708]}, {"w": "is", "b": [0.1429, 0.3684, 0.1561, 0.3899]}, {"w": "very", "b": [0.1615, 0.3684, 0.1979, 0.3899]}, {"w": "unlikely", "b": [0.2032, 0.3684, 0.2705, 0.3899]}, {"w": "that", "b": [0.2759, 0.3684, 0.3085, 0.3899]}, {"w": "a", "b": [0.3138, 0.3684, 0.323, 0.3899]}, {"w": "random", "b": [0.3283, 0.3684, 0.3953, 0.3899]}, {"w": "point", "b": [0.4007, 0.3684, 0.4451, 0.3899]}, {"w": "will", "b": [0.4505, 0.3684, 0.4809, 0.3899]}, {"w": "be", "b": [0.4863, 0.3684, 0.5057, 0.3899]}, {"w": "“extreme”", "b": [0.511, 0.3684, 0.5923, 0.3899]}, {"w": "along", "b": [0.5977, 0.3684, 0.6438, 0.3899]}, {"w": "any", "b": [0.6492, 0.3684, 0.6788, 0.3899]}, {"w": "dimension).", "b": [0.6842, 0.3684, 0.7853, 0.3899]}, {"w": "But", "b": [0.7906, 0.3684, 0.8203, 0.3899]}, {"w": "in", "b": [0.8257, 0.3684, 0.8427, 0.3899]}, {"w": "a", "b": [0.848, 0.3684, 0.8572, 0.3899]}, {"w": "10,000-dimensional", "b": [0.1429, 0.3875, 0.3086, 0.4089]}, {"w": "unit", "b": [0.3133, 0.3875, 0.3477, 0.4089]}, {"w": "hypercube", "b": [0.3524, 0.3875, 0.4395, 0.4089]}, {"w": "(a", "b": [0.4442, 0.3875, 0.4605, 0.4089]}, {"w": "1", "b": [0.4653, 0.3875, 0.4753, 0.4089]}, {"w": "×", "b": [0.48, 0.3875, 0.4921, 0.4089]}, {"w": "1", "b": [0.4968, 0.3875, 0.5068, 0.4089]}, {"w": "×", "b": [0.5115, 0.3875, 0.5236, 0.4089]}, {"w": "⋯", "b": [0.529, 0.3907, 0.5499, 0.4066]}, {"w": "×", "b": [0.5546, 0.3875, 0.5667, 0.4089]}, {"w": "1", "b": [0.5714, 0.3875, 0.5814, 0.4089]}, {"w": "cube,", "b": [0.5862, 0.3875, 0.6302, 0.4089]}, {"w": "with", "b": [0.6349, 0.3875, 0.6723, 0.4089]}, {"w": "ten", "b": [0.677, 0.3875, 0.7036, 0.4089]}, {"w": "thousand", "b": [0.7083, 0.3875, 0.7867, 0.4089]}, {"w": "1s),", "b": [0.7914, 0.3875, 0.821, 0.4089]}, {"w": "this", "b": [0.8258, 0.3875, 0.8565, 0.4089]}, {"w": "probability", "b": [0.1429, 0.4065, 0.2348, 0.428]}, {"w": "is", "b": [0.2399, 0.4065, 0.2532, 0.428]}, {"w": "greater", "b": [0.2583, 0.4065, 0.3163, 0.428]}, {"w": "than", "b": [0.3215, 0.4065, 0.3595, 0.428]}, {"w": "99.999999%.", "b": [0.3646, 0.4065, 0.4699, 0.428]}, {"w": "Most", "b": [0.475, 0.4065, 0.5176, 0.428]}, {"w": "points", "b": [0.5228, 0.4065, 0.5749, 0.428]}, {"w": "in", "b": [0.58, 0.4065, 0.597, 0.428]}, {"w": "a", "b": [0.6021, 0.4065, 0.6113, 0.428]}, {"w": "high-dimensional", "b": [0.6164, 0.4065, 0.765, 0.428]}, {"w": "hypercube", "b": [0.7701, 0.4065, 0.8571, 0.428]}, {"w": "are", "b": [0.1429, 0.4256, 0.1686, 0.447]}, {"w": "very", "b": [0.1733, 0.4256, 0.2097, 0.447]}, {"w": "close", "b": [0.2144, 0.4256, 0.2556, 0.447]}, {"w": "to", "b": [0.2604, 0.4256, 0.2774, 0.447]}, {"w": "the", "b": [0.2821, 0.4256, 0.3084, 0.447]}, {"w": "border.3", "b": [0.3131, 0.4256, 0.3788, 0.447]}]}, {"id": "b_4", "type": "paragraph", "text": "Here is a more troublesome difference: if you pick two points randomly in a unit square, the distance between these two points will be, on average, roughly 0.52. If you pick two random points in a unit 3D cube, the average distance will be roughly 0.66. But what about two points picked randomly in a 1,000,000-dimensional hypercube? Well, the average distance, believe it or not, will be about 408.25 (roughly", "words": [{"w": "Here", "b": [0.1429, 0.4537, 0.1837, 0.4751]}, {"w": "is", "b": [0.1916, 0.4537, 0.2048, 0.4751]}, {"w": "a", "b": [0.2126, 0.4537, 0.2218, 0.4751]}, {"w": "more", "b": [0.2296, 0.4537, 0.2739, 0.4751]}, {"w": "troublesome", "b": [0.2817, 0.4537, 0.3864, 0.4751]}, {"w": "difference:", "b": [0.3942, 0.4537, 0.4824, 0.4751]}, {"w": "if", "b": [0.4902, 0.4537, 0.5019, 0.4751]}, {"w": "you", "b": [0.5098, 0.4537, 0.541, 0.4751]}, {"w": "pick", "b": [0.5488, 0.4537, 0.5845, 0.4751]}, {"w": "two", "b": [0.5923, 0.4537, 0.6236, 0.4751]}, {"w": "points", "b": [0.6314, 0.4537, 0.6835, 0.4751]}, {"w": "randomly", "b": [0.6914, 0.4537, 0.7731, 0.4751]}, {"w": "in", "b": [0.781, 0.4537, 0.7979, 0.4751]}, {"w": "a", "b": [0.8058, 0.4537, 0.8149, 0.4751]}, {"w": "unit", "b": [0.8228, 0.4537, 0.8571, 0.4751]}, {"w": "square,", "b": [0.1429, 0.4728, 0.2027, 0.4942]}, {"w": "the", "b": [0.2077, 0.4728, 0.2341, 0.4942]}, {"w": "distance", "b": [0.2391, 0.4728, 0.3079, 0.4942]}, {"w": "between", "b": [0.313, 0.4728, 0.3821, 0.4942]}, {"w": "these", "b": [0.3872, 0.4728, 0.43, 0.4942]}, {"w": "two", "b": [0.4351, 0.4728, 0.4663, 0.4942]}, {"w": "points", "b": [0.4714, 0.4728, 0.5235, 0.4942]}, {"w": "will", "b": [0.5285, 0.4728, 0.5589, 0.4942]}, {"w": "be,", "b": [0.564, 0.4728, 0.5882, 0.4942]}, {"w": "on", "b": [0.5932, 0.4728, 0.6152, 0.4942]}, {"w": "average,", "b": [0.6203, 0.4728, 0.6878, 0.4942]}, {"w": "roughly", "b": [0.6928, 0.4728, 0.758, 0.4942]}, {"w": "0.52.", "b": [0.763, 0.4728, 0.8025, 0.4942]}, {"w": "If", "b": [0.8076, 0.4728, 0.8208, 0.4942]}, {"w": "you", "b": [0.8259, 0.4728, 0.8571, 0.4942]}, {"w": "pick", "b": [0.1429, 0.4918, 0.1785, 0.5132]}, {"w": "two", "b": [0.1842, 0.4918, 0.2155, 0.5132]}, {"w": "random", "b": [0.2212, 0.4918, 0.2882, 0.5132]}, {"w": "points", "b": [0.2939, 0.4918, 0.346, 0.5132]}, {"w": "in", "b": [0.3518, 0.4918, 0.3688, 0.5132]}, {"w": "a", "b": [0.3745, 0.4918, 0.3836, 0.5132]}, {"w": "unit", "b": [0.3894, 0.4918, 0.4238, 0.5132]}, {"w": "3D", "b": [0.4295, 0.4918, 0.4548, 0.5132]}, {"w": "cube,", "b": [0.4606, 0.4918, 0.5046, 0.5132]}, {"w": "the", "b": [0.5104, 0.4918, 0.5367, 0.5132]}, {"w": "average", "b": [0.5424, 0.4918, 0.6052, 0.5132]}, {"w": "distance", "b": [0.6109, 0.4918, 0.6797, 0.5132]}, {"w": "will", "b": [0.6855, 0.4918, 0.7159, 0.5132]}, {"w": "be", "b": [0.7216, 0.4918, 0.741, 0.5132]}, {"w": "roughly", "b": [0.7468, 0.4918, 0.8119, 0.5132]}, {"w": "0.66.", "b": [0.8176, 0.4918, 0.8571, 0.5132]}, {"w": "But", "b": [0.1429, 0.5109, 0.1725, 0.5323]}, {"w": "what", "b": [0.1789, 0.5109, 0.2194, 0.5323]}, {"w": "about", "b": [0.2259, 0.5109, 0.2736, 0.5323]}, {"w": "two", "b": [0.2801, 0.5109, 0.3113, 0.5323]}, {"w": "points", "b": [0.3177, 0.5109, 0.3698, 0.5323]}, {"w": "picked", "b": [0.3763, 0.5109, 0.4318, 0.5323]}, {"w": "randomly", "b": [0.4382, 0.5109, 0.52, 0.5323]}, {"w": "in", "b": [0.5264, 0.5109, 0.5434, 0.5323]}, {"w": "a", "b": [0.5498, 0.5109, 0.5589, 0.5323]}, {"w": "1,000,000-dimensional", "b": [0.5653, 0.5109, 0.7558, 0.5323]}, {"w": "hypercube?", "b": [0.7622, 0.5109, 0.8572, 0.5323]}, {"w": "Well,", "b": [0.1429, 0.5299, 0.1852, 0.5513]}, {"w": "the", "b": [0.1988, 0.5299, 0.2252, 0.5513]}, {"w": "average", "b": [0.2388, 0.5299, 0.3016, 0.5513]}, {"w": "distance,", "b": [0.3152, 0.5299, 0.3887, 0.5513]}, {"w": "believe", "b": [0.4024, 0.5299, 0.46, 0.5513]}, {"w": "it", "b": [0.4736, 0.5299, 0.4856, 0.5513]}, {"w": "or", "b": [0.4992, 0.5299, 0.5176, 0.5513]}, {"w": "not,", "b": [0.5312, 0.5299, 0.5643, 0.5513]}, {"w": "will", "b": [0.5779, 0.5299, 0.6083, 0.5513]}, {"w": "be", "b": [0.622, 0.5299, 0.6414, 0.5513]}, {"w": "about", "b": [0.655, 0.5299, 0.7028, 0.5513]}, {"w": "408.25", "b": [0.7164, 0.5299, 0.7712, 0.5513]}, {"w": "(roughly", "b": [0.7848, 0.5299, 0.8571, 0.5513]}]}, {"id": "b_5", "type": "paragraph", "text": "1, 000, 000/6)! This is quite counterintuitive: how can two points be so far apart when they both lie within the same unit hypercube? This fact implies that high- dimensional datasets are at risk of being very sparse: most training instances are likely to be far away from each other. Of course, this also means that a new instance will likely be far away from any training instance, making predictions much less relia‐ ble than in lower dimensions, since they will be based on much larger extrapolations. In short, the more dimensions the training set has, the greater the risk of overfitting it.", "words": [{"w": "1,", "b": [0.1556, 0.5489, 0.1703, 0.5704]}, {"w": "000,", "b": [0.1738, 0.5489, 0.2085, 0.5704]}, {"w": "000/6)!", "b": [0.212, 0.5489, 0.2742, 0.5704]}, {"w": "This", "b": [0.2824, 0.5489, 0.3196, 0.5704]}, {"w": "is", "b": [0.3278, 0.5489, 0.341, 0.5704]}, {"w": "quite", "b": [0.3492, 0.5489, 0.3917, 0.5704]}, {"w": "counterintuitive:", "b": [0.3999, 0.5489, 0.5391, 0.5704]}, {"w": "how", "b": [0.5473, 0.5489, 0.5834, 0.5704]}, {"w": "can", "b": [0.5916, 0.5489, 0.6209, 0.5704]}, {"w": "two", "b": [0.6291, 0.5489, 0.6604, 0.5704]}, {"w": "points", "b": [0.6686, 0.5489, 0.7207, 0.5704]}, {"w": "be", "b": [0.7289, 0.5489, 0.7483, 0.5704]}, {"w": "so", "b": [0.7565, 0.5489, 0.7748, 0.5704]}, {"w": "far", "b": [0.783, 0.5489, 0.8061, 0.5704]}, {"w": "apart", "b": [0.8143, 0.5489, 0.8572, 0.5704]}, {"w": "when", "b": [0.1429, 0.568, 0.1885, 0.5894]}, {"w": "they", "b": [0.1974, 0.568, 0.2333, 0.5894]}, {"w": "both", "b": [0.2422, 0.568, 0.2809, 0.5894]}, {"w": "lie", "b": [0.2898, 0.568, 0.3095, 0.5894]}, {"w": "within", "b": [0.3185, 0.568, 0.3728, 0.5894]}, {"w": "the", "b": [0.3817, 0.568, 0.408, 0.5894]}, {"w": "same", "b": [0.4169, 0.568, 0.4596, 0.5894]}, {"w": "unit", "b": [0.4686, 0.568, 0.503, 0.5894]}, {"w": "hypercube?", "b": [0.5119, 0.568, 0.6068, 0.5894]}, {"w": "This", "b": [0.6157, 0.568, 0.6529, 0.5894]}, {"w": "fact", "b": [0.6618, 0.568, 0.6923, 0.5894]}, {"w": "implies", "b": [0.7012, 0.568, 0.7617, 0.5894]}, {"w": "that", "b": [0.7706, 0.568, 0.8032, 0.5894]}, {"w": "high-", "b": [0.8121, 0.568, 0.8571, 0.5894]}, {"w": "dimensional", "b": [0.1429, 0.587, 0.2464, 0.6085]}, {"w": "datasets", "b": [0.2552, 0.587, 0.321, 0.6085]}, {"w": "are", "b": [0.3298, 0.587, 0.3555, 0.6085]}, {"w": "at", "b": [0.3643, 0.587, 0.3794, 0.6085]}, {"w": "risk", "b": [0.3882, 0.587, 0.4195, 0.6085]}, {"w": "of", "b": [0.4283, 0.587, 0.4451, 0.6085]}, {"w": "being", "b": [0.4539, 0.587, 0.5001, 0.6085]}, {"w": "very", "b": [0.5089, 0.587, 0.5453, 0.6085]}, {"w": "sparse:", "b": [0.5541, 0.587, 0.6107, 0.6085]}, {"w": "most", "b": [0.6195, 0.587, 0.6612, 0.6085]}, {"w": "training", "b": [0.67, 0.587, 0.737, 0.6085]}, {"w": "instances", "b": [0.7458, 0.587, 0.8226, 0.6085]}, {"w": "are", "b": [0.8314, 0.587, 0.8571, 0.6085]}, {"w": "likely", "b": [0.1428, 0.6061, 0.1877, 0.6275]}, {"w": "to", "b": [0.1938, 0.6061, 0.2108, 0.6275]}, {"w": "be", "b": [0.2168, 0.6061, 0.2362, 0.6275]}, {"w": "far", "b": [0.2423, 0.6061, 0.2653, 0.6275]}, {"w": "away", "b": [0.2714, 0.6061, 0.3128, 0.6275]}, {"w": "from", "b": [0.3188, 0.6061, 0.3604, 0.6275]}, {"w": "each", "b": [0.3664, 0.6061, 0.4044, 0.6275]}, {"w": "other.", "b": [0.4104, 0.6061, 0.4585, 0.6275]}, {"w": "Of", "b": [0.4646, 0.6061, 0.4863, 0.6275]}, {"w": "course,", "b": [0.4924, 0.6061, 0.5519, 0.6275]}, {"w": "this", "b": [0.5579, 0.6061, 0.5886, 0.6275]}, {"w": "also", "b": [0.5947, 0.6061, 0.6273, 0.6275]}, {"w": "means", "b": [0.6334, 0.6061, 0.6875, 0.6275]}, {"w": "that", "b": [0.6936, 0.6061, 0.7261, 0.6275]}, {"w": "a", "b": [0.7322, 0.6061, 0.7413, 0.6275]}, {"w": "new", "b": [0.7474, 0.6061, 0.7819, 0.6275]}, {"w": "instance", "b": [0.7879, 0.6061, 0.8571, 0.6275]}, {"w": "will", "b": [0.1429, 0.6251, 0.1733, 0.6466]}, {"w": "likely", "b": [0.1782, 0.6251, 0.2231, 0.6466]}, {"w": "be", "b": [0.228, 0.6251, 0.2475, 0.6466]}, {"w": "far", "b": [0.2524, 0.6251, 0.2754, 0.6466]}, {"w": "away", "b": [0.2804, 0.6251, 0.3218, 0.6466]}, {"w": "from", "b": [0.3267, 0.6251, 0.3683, 0.6466]}, {"w": "any", "b": [0.3732, 0.6251, 0.4028, 0.6466]}, {"w": "training", "b": [0.4078, 0.6251, 0.4747, 0.6466]}, {"w": "instance,", "b": [0.4797, 0.6251, 0.5536, 0.6466]}, {"w": "making", "b": [0.5585, 0.6251, 0.6218, 0.6466]}, {"w": "predictions", "b": [0.6267, 0.6251, 0.7212, 0.6466]}, {"w": "much", "b": [0.7262, 0.6251, 0.7739, 0.6466]}, {"w": "less", "b": [0.7788, 0.6251, 0.8082, 0.6466]}, {"w": "relia‐", "b": [0.8131, 0.6251, 0.8571, 0.6466]}, {"w": "ble", "b": [0.1429, 0.6442, 0.1676, 0.6656]}, {"w": "than", "b": [0.1729, 0.6442, 0.2109, 0.6656]}, {"w": "in", "b": [0.2163, 0.6442, 0.2332, 0.6656]}, {"w": "lower", "b": [0.2386, 0.6442, 0.2853, 0.6656]}, {"w": "dimensions,", "b": [0.2907, 0.6442, 0.3922, 0.6656]}, {"w": "since", "b": [0.3976, 0.6442, 0.4399, 0.6656]}, {"w": "they", "b": [0.4452, 0.6442, 0.4811, 0.6656]}, {"w": "will", "b": [0.4864, 0.6442, 0.5168, 0.6656]}, {"w": "be", "b": [0.5222, 0.6442, 0.5416, 0.6656]}, {"w": "based", "b": [0.5469, 0.6442, 0.5942, 0.6656]}, {"w": "on", "b": [0.5995, 0.6442, 0.6215, 0.6656]}, {"w": "much", "b": [0.6269, 0.6442, 0.6745, 0.6656]}, {"w": "larger", "b": [0.6799, 0.6442, 0.7284, 0.6656]}, {"w": "extrapolations.", "b": [0.7337, 0.6442, 0.8571, 0.6656]}, {"w": "In", "b": [0.1429, 0.6632, 0.1614, 0.6846]}, {"w": "short,", "b": [0.1674, 0.6632, 0.2156, 0.6846]}, {"w": "the", "b": [0.2217, 0.6632, 0.248, 0.6846]}, {"w": "more", "b": [0.254, 0.6632, 0.2983, 0.6846]}, {"w": "dimensions", "b": [0.3043, 0.6632, 0.4011, 0.6846]}, {"w": "the", "b": [0.4072, 0.6632, 0.4335, 0.6846]}, {"w": "training", "b": [0.4395, 0.6632, 0.5065, 0.6846]}, {"w": "set", "b": [0.5125, 0.6632, 0.5354, 0.6846]}, {"w": "has,", "b": [0.5414, 0.6632, 0.5741, 0.6846]}, {"w": "the", "b": [0.5801, 0.6632, 0.6065, 0.6846]}, {"w": "greater", "b": [0.6125, 0.6632, 0.6705, 0.6846]}, {"w": "the", "b": [0.6766, 0.6632, 0.7029, 0.6846]}, {"w": "risk", "b": [0.7089, 0.6632, 0.7402, 0.6846]}, {"w": "of", "b": [0.7463, 0.6632, 0.7631, 0.6846]}, {"w": "overfitting", "b": [0.7691, 0.6632, 0.8571, 0.6846]}, {"w": "it.", "b": [0.1429, 0.6823, 0.1596, 0.7037]}]}, {"id": "b_6", "type": "paragraph", "text": "In theory, one solution to the curse of dimensionality could be to increase the size of the training set to reach a sufficient density of training instances. Unfortunately, in practice, the number of training instances required to reach a given density grows exponentially with the number of dimensions. With just 100 features (much less than", "words": [{"w": "In", "b": [0.1429, 0.7104, 0.1614, 0.7318]}, {"w": "theory,", "b": [0.167, 0.7104, 0.225, 0.7318]}, {"w": "one", "b": [0.2306, 0.7104, 0.2615, 0.7318]}, {"w": "solution", "b": [0.2671, 0.7104, 0.3357, 0.7318]}, {"w": "to", "b": [0.3412, 0.7104, 0.3582, 0.7318]}, {"w": "the", "b": [0.3638, 0.7104, 0.3901, 0.7318]}, {"w": "curse", "b": [0.3957, 0.7104, 0.4398, 0.7318]}, {"w": "of", "b": [0.4454, 0.7104, 0.4622, 0.7318]}, {"w": "dimensionality", "b": [0.4678, 0.7104, 0.5929, 0.7318]}, {"w": "could", "b": [0.5985, 0.7104, 0.6452, 0.7318]}, {"w": "be", "b": [0.6508, 0.7104, 0.6703, 0.7318]}, {"w": "to", "b": [0.6758, 0.7104, 0.6928, 0.7318]}, {"w": "increase", "b": [0.6984, 0.7104, 0.7664, 0.7318]}, {"w": "the", "b": [0.772, 0.7104, 0.7984, 0.7318]}, {"w": "size", "b": [0.8039, 0.7104, 0.8348, 0.7318]}, {"w": "of", "b": [0.8404, 0.7104, 0.8572, 0.7318]}, {"w": "the", "b": [0.1429, 0.7294, 0.1692, 0.7509]}, {"w": "training", "b": [0.1763, 0.7294, 0.2432, 0.7509]}, {"w": "set", "b": [0.2503, 0.7294, 0.2732, 0.7509]}, {"w": "to", "b": [0.2803, 0.7294, 0.2973, 0.7509]}, {"w": "reach", "b": [0.3044, 0.7294, 0.3501, 0.7509]}, {"w": "a", "b": [0.3572, 0.7294, 0.3663, 0.7509]}, {"w": "sufficient", "b": [0.3734, 0.7294, 0.4506, 0.7509]}, {"w": "density", "b": [0.4577, 0.7294, 0.5181, 0.7509]}, {"w": "of", "b": [0.5252, 0.7294, 0.542, 0.7509]}, {"w": "training", "b": [0.5491, 0.7294, 0.6161, 0.7509]}, {"w": "instances.", "b": [0.6232, 0.7294, 0.7048, 0.7509]}, {"w": "Unfortunately,", "b": [0.7119, 0.7294, 0.8331, 0.7509]}, {"w": "in", "b": [0.8402, 0.7294, 0.8571, 0.7509]}, {"w": "practice,", "b": [0.1429, 0.7485, 0.2138, 0.7699]}, {"w": "the", "b": [0.2214, 0.7485, 0.2478, 0.7699]}, {"w": "number", "b": [0.2554, 0.7485, 0.3216, 0.7699]}, {"w": "of", "b": [0.3292, 0.7485, 0.346, 0.7699]}, {"w": "training", "b": [0.3536, 0.7485, 0.4206, 0.7699]}, {"w": "instances", "b": [0.4282, 0.7485, 0.505, 0.7699]}, {"w": "required", "b": [0.5126, 0.7485, 0.5841, 0.7699]}, {"w": "to", "b": [0.5917, 0.7485, 0.6087, 0.7699]}, {"w": "reach", "b": [0.6163, 0.7485, 0.6619, 0.7699]}, {"w": "a", "b": [0.6695, 0.7485, 0.6787, 0.7699]}, {"w": "given", "b": [0.6863, 0.7485, 0.7315, 0.7699]}, {"w": "density", "b": [0.7391, 0.7485, 0.7995, 0.7699]}, {"w": "grows", "b": [0.8071, 0.7485, 0.8571, 0.7699]}, {"w": "exponentially", "b": [0.1428, 0.7675, 0.2555, 0.789]}, {"w": "with", "b": [0.2607, 0.7675, 0.2981, 0.789]}, {"w": "the", "b": [0.3033, 0.7675, 0.3296, 0.789]}, {"w": "number", "b": [0.3349, 0.7675, 0.4012, 0.789]}, {"w": "of", "b": [0.4064, 0.7675, 0.4232, 0.789]}, {"w": "dimensions.", "b": [0.4284, 0.7675, 0.53, 0.789]}, {"w": "With", "b": [0.5352, 0.7675, 0.5776, 0.789]}, {"w": "just", "b": [0.5829, 0.7675, 0.6133, 0.789]}, {"w": "100", "b": [0.6185, 0.7675, 0.6485, 0.789]}, {"w": "features", "b": [0.6537, 0.7675, 0.7191, 0.789]}, {"w": "(much", "b": [0.7244, 0.7675, 0.7792, 0.789]}, {"w": "less", "b": [0.7845, 0.7675, 0.8139, 0.789]}, {"w": "than", "b": [0.8191, 0.7675, 0.8571, 0.789]}]}, {"id": "b_7", "type": "paragraph", "text": "The Curse of Dimensionality | 217", "words": [{"w": "The", "b": [0.633, 0.9225, 0.6545, 0.9388]}, {"w": "Curse", "b": [0.6573, 0.9225, 0.6893, 0.9388]}, {"w": "of", "b": [0.6921, 0.9225, 0.7041, 0.9388]}, {"w": "Dimensionality", "b": [0.7069, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "217", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 244, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "in the MNIST problem), you would need more training instances than atoms in the observable universe in order for training instances to be within 0.1 of each other on average, assuming they were spread out uniformly across all dimensions.", "words": [{"w": "in", "b": [0.1429, 0.0791, 0.1598, 0.1005]}, {"w": "the", "b": [0.166, 0.0791, 0.1924, 0.1005]}, {"w": "MNIST", "b": [0.1986, 0.0791, 0.2625, 0.1005]}, {"w": "problem),", "b": [0.2687, 0.0791, 0.3517, 0.1005]}, {"w": "you", "b": [0.3579, 0.0791, 0.3891, 0.1005]}, {"w": "would", "b": [0.3953, 0.0791, 0.4476, 0.1005]}, {"w": "need", "b": [0.4538, 0.0791, 0.4939, 0.1005]}, {"w": "more", "b": [0.5001, 0.0791, 0.5444, 0.1005]}, {"w": "training", "b": [0.5506, 0.0791, 0.6175, 0.1005]}, {"w": "instances", "b": [0.6237, 0.0791, 0.7005, 0.1005]}, {"w": "than", "b": [0.7067, 0.0791, 0.7448, 0.1005]}, {"w": "atoms", "b": [0.751, 0.0791, 0.8014, 0.1005]}, {"w": "in", "b": [0.8076, 0.0791, 0.8246, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}, {"w": "observable", "b": [0.1429, 0.0981, 0.2324, 0.1195]}, {"w": "universe", "b": [0.2385, 0.0981, 0.3093, 0.1195]}, {"w": "in", "b": [0.3154, 0.0981, 0.3324, 0.1195]}, {"w": "order", "b": [0.3385, 0.0981, 0.3845, 0.1195]}, {"w": "for", "b": [0.3906, 0.0981, 0.4151, 0.1195]}, {"w": "training", "b": [0.4213, 0.0981, 0.4882, 0.1195]}, {"w": "instances", "b": [0.4943, 0.0981, 0.5712, 0.1195]}, {"w": "to", "b": [0.5773, 0.0981, 0.5943, 0.1195]}, {"w": "be", "b": [0.6004, 0.0981, 0.6198, 0.1195]}, {"w": "within", "b": [0.626, 0.0981, 0.6803, 0.1195]}, {"w": "0.1", "b": [0.6864, 0.0981, 0.7112, 0.1195]}, {"w": "of", "b": [0.7173, 0.0981, 0.7341, 0.1195]}, {"w": "each", "b": [0.7402, 0.0981, 0.7782, 0.1195]}, {"w": "other", "b": [0.7843, 0.0981, 0.829, 0.1195]}, {"w": "on", "b": [0.8351, 0.0981, 0.8571, 0.1195]}, {"w": "average,", "b": [0.1429, 0.1172, 0.2104, 0.1386]}, {"w": "assuming", "b": [0.2151, 0.1172, 0.2944, 0.1386]}, {"w": "they", "b": [0.2991, 0.1172, 0.335, 0.1386]}, {"w": "were", "b": [0.3397, 0.1172, 0.3794, 0.1386]}, {"w": "spread", "b": [0.3842, 0.1172, 0.4395, 0.1386]}, {"w": "out", "b": [0.4442, 0.1172, 0.4722, 0.1386]}, {"w": "uniformly", "b": [0.477, 0.1172, 0.5614, 0.1386]}, {"w": "across", "b": [0.5662, 0.1172, 0.6178, 0.1386]}, {"w": "all", "b": [0.6225, 0.1172, 0.6422, 0.1386]}, {"w": "dimensions.", "b": [0.6469, 0.1172, 0.7484, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "Main Approaches for Dimensionality Reduction", "words": [{"w": "Main", "b": [0.1429, 0.1516, 0.205, 0.1858]}, {"w": "Approaches", "b": [0.2109, 0.1516, 0.3545, 0.1858]}, {"w": "for", "b": [0.3605, 0.1516, 0.3959, 0.1858]}, {"w": "Dimensionality", "b": [0.4018, 0.1516, 0.5888, 0.1858]}, {"w": "Reduction", "b": [0.5947, 0.1516, 0.72, 0.1858]}]}, {"id": "b_2", "type": "paragraph", "text": "Before we dive into specific dimensionality reduction algorithms, let’s take a look at the two main approaches to reducing dimensionality: projection and Manifold Learning.", "words": [{"w": "Before", "b": [0.1428, 0.1927, 0.1977, 0.2142]}, {"w": "we", "b": [0.2042, 0.1927, 0.2273, 0.2142]}, {"w": "dive", "b": [0.2338, 0.1927, 0.2689, 0.2142]}, {"w": "into", "b": [0.2754, 0.1927, 0.3089, 0.2142]}, {"w": "specific", "b": [0.3154, 0.1927, 0.3778, 0.2142]}, {"w": "dimensionality", "b": [0.3843, 0.1927, 0.5093, 0.2142]}, {"w": "reduction", "b": [0.5158, 0.1927, 0.5972, 0.2142]}, {"w": "algorithms,", "b": [0.6037, 0.1927, 0.6987, 0.2142]}, {"w": "let’s", "b": [0.7052, 0.1927, 0.7354, 0.2142]}, {"w": "take", "b": [0.7419, 0.1927, 0.7766, 0.2142]}, {"w": "a", "b": [0.7831, 0.1927, 0.7922, 0.2142]}, {"w": "look", "b": [0.7987, 0.1927, 0.8356, 0.2142]}, {"w": "at", "b": [0.842, 0.1927, 0.8571, 0.2142]}, {"w": "the", "b": [0.1429, 0.2118, 0.1692, 0.2332]}, {"w": "two", "b": [0.1806, 0.2118, 0.2118, 0.2332]}, {"w": "main", "b": [0.2232, 0.2118, 0.2663, 0.2332]}, {"w": "approaches", "b": [0.2777, 0.2118, 0.3722, 0.2332]}, {"w": "to", "b": [0.3836, 0.2118, 0.4006, 0.2332]}, {"w": "reducing", "b": [0.4119, 0.2118, 0.4861, 0.2332]}, {"w": "dimensionality:", "b": [0.4975, 0.2118, 0.6279, 0.2332]}, {"w": "projection", "b": [0.6393, 0.2118, 0.7255, 0.2332]}, {"w": "and", "b": [0.7369, 0.2118, 0.7684, 0.2332]}, {"w": "Manifold", "b": [0.7798, 0.2118, 0.8571, 0.2332]}, {"w": "Learning.", "b": [0.1429, 0.2308, 0.2227, 0.2523]}]}, {"id": "b_3", "type": "paragraph", "text": "Projection", "words": [{"w": "Projection", "b": [0.1429, 0.265, 0.2481, 0.2936]}]}, {"id": "b_4", "type": "paragraph", "text": "In most real-world problems, training instances are not spread out uniformly across all dimensions. Many features are almost constant, while others are highly correlated (as discussed earlier for MNIST). As a result, all training instances actually lie within (or close to) a much lower-dimensional subspace of the high-dimensional space. This sounds very abstract, so let’s look at an example. In Figure 8-2 you can see a 3D data‐ set represented by the circles.", "words": [{"w": "In", "b": [0.1429, 0.2995, 0.1614, 0.3209]}, {"w": "most", "b": [0.1675, 0.2995, 0.2092, 0.3209]}, {"w": "real-world", "b": [0.2153, 0.2995, 0.3026, 0.3209]}, {"w": "problems,", "b": [0.3088, 0.2995, 0.3922, 0.3209]}, {"w": "training", "b": [0.3984, 0.2995, 0.4653, 0.3209]}, {"w": "instances", "b": [0.4715, 0.2995, 0.5483, 0.3209]}, {"w": "are", "b": [0.5544, 0.2995, 0.5802, 0.3209]}, {"w": "not", "b": [0.5863, 0.2993, 0.6132, 0.3209]}, {"w": "spread", "b": [0.6193, 0.2995, 0.6746, 0.3209]}, {"w": "out", "b": [0.6808, 0.2995, 0.7088, 0.3209]}, {"w": "uniformly", "b": [0.7149, 0.2995, 0.7994, 0.3209]}, {"w": "across", "b": [0.8055, 0.2995, 0.8571, 0.3209]}, {"w": "all", "b": [0.1429, 0.3185, 0.1625, 0.3399]}, {"w": "dimensions.", "b": [0.1682, 0.3185, 0.2697, 0.3399]}, {"w": "Many", "b": [0.2754, 0.3185, 0.3232, 0.3399]}, {"w": "features", "b": [0.3289, 0.3185, 0.3943, 0.3399]}, {"w": "are", "b": [0.4, 0.3185, 0.4257, 0.3399]}, {"w": "almost", "b": [0.4314, 0.3185, 0.4875, 0.3399]}, {"w": "constant,", "b": [0.4932, 0.3185, 0.5692, 0.3399]}, {"w": "while", "b": [0.5749, 0.3185, 0.62, 0.3399]}, {"w": "others", "b": [0.6257, 0.3185, 0.678, 0.3399]}, {"w": "are", "b": [0.6837, 0.3185, 0.7094, 0.3399]}, {"w": "highly", "b": [0.7151, 0.3185, 0.7675, 0.3399]}, {"w": "correlated", "b": [0.7732, 0.3185, 0.8571, 0.3399]}, {"w": "(as", "b": [0.1428, 0.3376, 0.1668, 0.359]}, {"w": "discussed", "b": [0.1724, 0.3376, 0.2517, 0.359]}, {"w": "earlier", "b": [0.2573, 0.3376, 0.3104, 0.359]}, {"w": "for", "b": [0.316, 0.3376, 0.3405, 0.359]}, {"w": "MNIST).", "b": [0.3461, 0.3376, 0.4219, 0.359]}, {"w": "As", "b": [0.4275, 0.3376, 0.4496, 0.359]}, {"w": "a", "b": [0.4551, 0.3376, 0.4643, 0.359]}, {"w": "result,", "b": [0.4699, 0.3376, 0.5215, 0.359]}, {"w": "all", "b": [0.5271, 0.3376, 0.5468, 0.359]}, {"w": "training", "b": [0.5524, 0.3376, 0.6193, 0.359]}, {"w": "instances", "b": [0.6249, 0.3376, 0.7017, 0.359]}, {"w": "actually", "b": [0.7073, 0.3376, 0.7719, 0.359]}, {"w": "lie", "b": [0.7775, 0.3376, 0.7972, 0.359]}, {"w": "within", "b": [0.8028, 0.3376, 0.8571, 0.359]}, {"w": "(or", "b": [0.1429, 0.3566, 0.1684, 0.378]}, {"w": "close", "b": [0.1738, 0.3566, 0.215, 0.378]}, {"w": "to)", "b": [0.2205, 0.3566, 0.2446, 0.378]}, {"w": "a", "b": [0.2501, 0.3566, 0.2592, 0.378]}, {"w": "much", "b": [0.2646, 0.3566, 0.3123, 0.378]}, {"w": "lower-dimensional", "b": [0.3177, 0.3566, 0.4749, 0.378]}, {"w": "subspace", "b": [0.4803, 0.3564, 0.5511, 0.378]}, {"w": "of", "b": [0.5565, 0.3566, 0.5733, 0.378]}, {"w": "the", "b": [0.5787, 0.3566, 0.605, 0.378]}, {"w": "high-dimensional", "b": [0.6104, 0.3566, 0.759, 0.378]}, {"w": "space.", "b": [0.7644, 0.3566, 0.8145, 0.378]}, {"w": "This", "b": [0.8199, 0.3566, 0.8572, 0.378]}, {"w": "sounds", "b": [0.1429, 0.3757, 0.2022, 0.3971]}, {"w": "very", "b": [0.2075, 0.3757, 0.2439, 0.3971]}, {"w": "abstract,", "b": [0.2492, 0.3757, 0.3197, 0.3971]}, {"w": "so", "b": [0.325, 0.3757, 0.3433, 0.3971]}, {"w": "let’s", "b": [0.3485, 0.3757, 0.3788, 0.3971]}, {"w": "look", "b": [0.384, 0.3757, 0.4209, 0.3971]}, {"w": "at", "b": [0.4262, 0.3757, 0.4413, 0.3971]}, {"w": "an", "b": [0.4465, 0.3757, 0.4671, 0.3971]}, {"w": "example.", "b": [0.4724, 0.3757, 0.5467, 0.3971]}, {"w": "In", "b": [0.5519, 0.3757, 0.5704, 0.3971]}, {"w": "Figure", "b": [0.5757, 0.3757, 0.6297, 0.3971]}, {"w": "8-2", "b": [0.6344, 0.3757, 0.6619, 0.3971]}, {"w": "you", "b": [0.6677, 0.3757, 0.6989, 0.3971]}, {"w": "can", "b": [0.7042, 0.3757, 0.7336, 0.3971]}, {"w": "see", "b": [0.7388, 0.3757, 0.7642, 0.3971]}, {"w": "a", "b": [0.7695, 0.3757, 0.7786, 0.3971]}, {"w": "3D", "b": [0.7839, 0.3757, 0.8092, 0.3971]}, {"w": "data‐", "b": [0.8145, 0.3757, 0.8572, 0.3971]}, {"w": "set", "b": [0.1429, 0.3947, 0.1657, 0.4161]}, {"w": "represented", "b": [0.1704, 0.3947, 0.2682, 0.4161]}, {"w": "by", "b": [0.273, 0.3947, 0.2931, 0.4161]}, {"w": "the", "b": [0.2978, 0.3947, 0.3242, 0.4161]}, {"w": "circles.", "b": [0.3289, 0.3947, 0.3864, 0.4161]}]}, {"id": "b_5", "type": "equation", "text": "Figure 8-2. A 3D dataset lying close to a 2D subspace", "words": [{"w": "Figure", "b": [0.1429, 0.7106, 0.1943, 0.7322]}, {"w": "8-2.", "b": [0.1991, 0.7106, 0.2308, 0.7322]}, {"w": "A", "b": [0.2356, 0.7106, 0.2494, 0.7322]}, {"w": "3D", "b": [0.2542, 0.7106, 0.2789, 0.7322]}, {"w": "dataset", "b": [0.2836, 0.7106, 0.3419, 0.7322]}, {"w": "lying", "b": [0.3467, 0.7106, 0.386, 0.7322]}, {"w": "close", "b": [0.3908, 0.7106, 0.4287, 0.7322]}, {"w": "to", "b": [0.4335, 0.7106, 0.4495, 0.7322]}, {"w": "a", "b": [0.4542, 0.7106, 0.4644, 0.7322]}, {"w": "2D", "b": [0.4692, 0.7106, 0.4939, 0.7322]}, {"w": "subspace", "b": [0.4987, 0.7106, 0.5694, 0.7322]}]}, {"id": "b_6", "type": "paragraph", "text": "Notice that all training instances lie close to a plane: this is a lower-dimensional (2D) subspace of the high-dimensional (3D) space. Now if we project every training instance perpendicularly onto this subspace (as represented by the short lines con‐ necting the instances to the plane), we get the new 2D dataset shown in Figure 8-3. Ta-da! We have just reduced the dataset’s dimensionality from 3D to 2D. Note that the axes correspond to new features z1 and z2 (the coordinates of the projections on the plane).", "words": [{"w": "Notice", "b": [0.1429, 0.7479, 0.198, 0.7694]}, {"w": "that", "b": [0.2035, 0.7479, 0.236, 0.7694]}, {"w": "all", "b": [0.2414, 0.7479, 0.2611, 0.7694]}, {"w": "training", "b": [0.2665, 0.7479, 0.3335, 0.7694]}, {"w": "instances", "b": [0.3389, 0.7479, 0.4157, 0.7694]}, {"w": "lie", "b": [0.4211, 0.7479, 0.4408, 0.7694]}, {"w": "close", "b": [0.4462, 0.7479, 0.4874, 0.7694]}, {"w": "to", "b": [0.4928, 0.7479, 0.5098, 0.7694]}, {"w": "a", "b": [0.5152, 0.7479, 0.5244, 0.7694]}, {"w": "plane:", "b": [0.5298, 0.7479, 0.5801, 0.7694]}, {"w": "this", "b": [0.5855, 0.7479, 0.6162, 0.7694]}, {"w": "is", "b": [0.6216, 0.7479, 0.6348, 0.7694]}, {"w": "a", "b": [0.6402, 0.7479, 0.6494, 0.7694]}, {"w": "lower-dimensional", "b": [0.6548, 0.7479, 0.812, 0.7694]}, {"w": "(2D)", "b": [0.8174, 0.7479, 0.8571, 0.7694]}, {"w": "subspace", "b": [0.1429, 0.767, 0.2175, 0.7884]}, {"w": "of", "b": [0.2278, 0.767, 0.2445, 0.7884]}, {"w": "the", "b": [0.2548, 0.767, 0.2811, 0.7884]}, {"w": "high-dimensional", "b": [0.2913, 0.767, 0.4399, 0.7884]}, {"w": "(3D)", "b": [0.4501, 0.767, 0.4899, 0.7884]}, {"w": "space.", "b": [0.5001, 0.767, 0.5502, 0.7884]}, {"w": "Now", "b": [0.5604, 0.767, 0.6003, 0.7884]}, {"w": "if", "b": [0.6105, 0.767, 0.6223, 0.7884]}, {"w": "we", "b": [0.6325, 0.767, 0.6556, 0.7884]}, {"w": "project", "b": [0.6659, 0.767, 0.7245, 0.7884]}, {"w": "every", "b": [0.7347, 0.767, 0.78, 0.7884]}, {"w": "training", "b": [0.7902, 0.767, 0.8571, 0.7884]}, {"w": "instance", "b": [0.1428, 0.786, 0.212, 0.8075]}, {"w": "perpendicularly", "b": [0.2193, 0.786, 0.3514, 0.8075]}, {"w": "onto", "b": [0.3587, 0.786, 0.3973, 0.8075]}, {"w": "this", "b": [0.4046, 0.786, 0.4353, 0.8075]}, {"w": "subspace", "b": [0.4426, 0.786, 0.5173, 0.8075]}, {"w": "(as", "b": [0.5246, 0.786, 0.5486, 0.8075]}, {"w": "represented", "b": [0.5559, 0.786, 0.6537, 0.8075]}, {"w": "by", "b": [0.661, 0.786, 0.6811, 0.8075]}, {"w": "the", "b": [0.6884, 0.786, 0.7148, 0.8075]}, {"w": "short", "b": [0.7221, 0.786, 0.7655, 0.8075]}, {"w": "lines", "b": [0.7728, 0.786, 0.8116, 0.8075]}, {"w": "con‐", "b": [0.8189, 0.786, 0.8571, 0.8075]}, {"w": "necting", "b": [0.1429, 0.8051, 0.205, 0.8265]}, {"w": "the", "b": [0.2115, 0.8051, 0.2378, 0.8265]}, {"w": "instances", "b": [0.2444, 0.8051, 0.3212, 0.8265]}, {"w": "to", "b": [0.3277, 0.8051, 0.3447, 0.8265]}, {"w": "the", "b": [0.3512, 0.8051, 0.3775, 0.8265]}, {"w": "plane),", "b": [0.384, 0.8051, 0.4415, 0.8265]}, {"w": "we", "b": [0.4481, 0.8051, 0.4712, 0.8265]}, {"w": "get", "b": [0.4777, 0.8051, 0.5026, 0.8265]}, {"w": "the", "b": [0.5091, 0.8051, 0.5355, 0.8265]}, {"w": "new", "b": [0.542, 0.8051, 0.5765, 0.8265]}, {"w": "2D", "b": [0.583, 0.8051, 0.6083, 0.8265]}, {"w": "dataset", "b": [0.6148, 0.8051, 0.6729, 0.8265]}, {"w": "shown", "b": [0.6794, 0.8051, 0.7345, 0.8265]}, {"w": "in", "b": [0.741, 0.8051, 0.758, 0.8265]}, {"w": "Figure", "b": [0.7645, 0.8051, 0.8185, 0.8265]}, {"w": "8-3.", "b": [0.825, 0.8051, 0.8572, 0.8265]}, {"w": "Ta-da!", "b": [0.1429, 0.8241, 0.1963, 0.8456]}, {"w": "We", "b": [0.2033, 0.8241, 0.2304, 0.8456]}, {"w": "have", "b": [0.2375, 0.8241, 0.2759, 0.8456]}, {"w": "just", "b": [0.2829, 0.8241, 0.3133, 0.8456]}, {"w": "reduced", "b": [0.3204, 0.8241, 0.3877, 0.8456]}, {"w": "the", "b": [0.3948, 0.8241, 0.4211, 0.8456]}, {"w": "dataset’s", "b": [0.4282, 0.8241, 0.4961, 0.8456]}, {"w": "dimensionality", "b": [0.5031, 0.8241, 0.6282, 0.8456]}, {"w": "from", "b": [0.6353, 0.8241, 0.6769, 0.8456]}, {"w": "3D", "b": [0.6839, 0.8241, 0.7093, 0.8456]}, {"w": "to", "b": [0.7163, 0.8241, 0.7333, 0.8456]}, {"w": "2D.", "b": [0.7404, 0.8241, 0.7696, 0.8456]}, {"w": "Note", "b": [0.7767, 0.8241, 0.8175, 0.8456]}, {"w": "that", "b": [0.8246, 0.8241, 0.8571, 0.8456]}, {"w": "the", "b": [0.1429, 0.8432, 0.1692, 0.8646]}, {"w": "axes", "b": [0.1756, 0.8432, 0.211, 0.8646]}, {"w": "correspond", "b": [0.2174, 0.8432, 0.3128, 0.8646]}, {"w": "to", "b": [0.3191, 0.8432, 0.3361, 0.8646]}, {"w": "new", "b": [0.3425, 0.8432, 0.377, 0.8646]}, {"w": "features", "b": [0.3834, 0.8432, 0.4488, 0.8646]}, {"w": "z1", "b": [0.4552, 0.843, 0.4699, 0.8655]}, {"w": "and", "b": [0.4763, 0.8432, 0.5078, 0.8646]}, {"w": "z2", "b": [0.5142, 0.843, 0.5289, 0.8655]}, {"w": "(the", "b": [0.5353, 0.8432, 0.5688, 0.8646]}, {"w": "coordinates", "b": [0.5752, 0.8432, 0.6726, 0.8646]}, {"w": "of", "b": [0.679, 0.8432, 0.6958, 0.8646]}, {"w": "the", "b": [0.7021, 0.8432, 0.7285, 0.8646]}, {"w": "projections", "b": [0.7349, 0.8432, 0.8287, 0.8646]}, {"w": "on", "b": [0.8351, 0.8432, 0.8571, 0.8646]}, {"w": "the", "b": [0.1429, 0.8622, 0.1692, 0.8836]}, {"w": "plane).", "b": [0.1739, 0.8622, 0.2315, 0.8836]}]}, {"id": "b_7", "type": "paragraph", "text": "218 | Chapter 8: Dimensionality Reduction", "words": [{"w": "218", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "8:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Dimensionality", "b": [0.2673, 0.9225, 0.3562, 0.9388]}, {"w": "Reduction", "b": [0.359, 0.9225, 0.4186, 0.9388]}]}]}, {"page": 245, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 8-3. The new 2D dataset after projection", "words": [{"w": "Figure", "b": [0.1429, 0.3782, 0.1943, 0.3999]}, {"w": "8-3.", "b": [0.1991, 0.3782, 0.2308, 0.3999]}, {"w": "The", "b": [0.2356, 0.3782, 0.2654, 0.3999]}, {"w": "new", "b": [0.2702, 0.3782, 0.3035, 0.3999]}, {"w": "2D", "b": [0.3083, 0.3782, 0.333, 0.3999]}, {"w": "dataset", "b": [0.3377, 0.3782, 0.396, 0.3999]}, {"w": "after", "b": [0.4008, 0.3782, 0.4388, 0.3999]}, {"w": "projection", "b": [0.4436, 0.3782, 0.5246, 0.3999]}]}, {"id": "b_1", "type": "paragraph", "text": "However, projection is not always the best approach to dimensionality reduction. In many cases the subspace may twist and turn, such as in the famous Swiss roll toy data‐ set represented in Figure 8-4.", "words": [{"w": "However,", "b": [0.1429, 0.4156, 0.2217, 0.437]}, {"w": "projection", "b": [0.2279, 0.4156, 0.3142, 0.437]}, {"w": "is", "b": [0.3204, 0.4156, 0.3336, 0.437]}, {"w": "not", "b": [0.3398, 0.4156, 0.3682, 0.437]}, {"w": "always", "b": [0.3744, 0.4156, 0.4291, 0.437]}, {"w": "the", "b": [0.4353, 0.4156, 0.4617, 0.437]}, {"w": "best", "b": [0.4679, 0.4156, 0.5013, 0.437]}, {"w": "approach", "b": [0.5075, 0.4156, 0.5856, 0.437]}, {"w": "to", "b": [0.5918, 0.4156, 0.6088, 0.437]}, {"w": "dimensionality", "b": [0.615, 0.4156, 0.74, 0.437]}, {"w": "reduction.", "b": [0.7463, 0.4156, 0.8324, 0.437]}, {"w": "In", "b": [0.8386, 0.4156, 0.8571, 0.437]}, {"w": "many", "b": [0.1429, 0.4347, 0.1895, 0.4561]}, {"w": "cases", "b": [0.1943, 0.4347, 0.2364, 0.4561]}, {"w": "the", "b": [0.2411, 0.4347, 0.2674, 0.4561]}, {"w": "subspace", "b": [0.2722, 0.4347, 0.3468, 0.4561]}, {"w": "may", "b": [0.3516, 0.4347, 0.387, 0.4561]}, {"w": "twist", "b": [0.3917, 0.4347, 0.4319, 0.4561]}, {"w": "and", "b": [0.4366, 0.4347, 0.4682, 0.4561]}, {"w": "turn,", "b": [0.4729, 0.4347, 0.5142, 0.4561]}, {"w": "such", "b": [0.5189, 0.4347, 0.5576, 0.4561]}, {"w": "as", "b": [0.5623, 0.4347, 0.5791, 0.4561]}, {"w": "in", "b": [0.5838, 0.4347, 0.6008, 0.4561]}, {"w": "the", "b": [0.6055, 0.4347, 0.6319, 0.4561]}, {"w": "famous", "b": [0.6366, 0.4347, 0.6983, 0.4561]}, {"w": "Swiss", "b": [0.7035, 0.4345, 0.7465, 0.4561]}, {"w": "roll", "b": [0.7513, 0.4345, 0.7784, 0.4561]}, {"w": "toy", "b": [0.7832, 0.4347, 0.8097, 0.4561]}, {"w": "data‐", "b": [0.8144, 0.4347, 0.8571, 0.4561]}, {"w": "set", "b": [0.1429, 0.4537, 0.1657, 0.4751]}, {"w": "represented", "b": [0.1704, 0.4537, 0.2682, 0.4751]}, {"w": "in", "b": [0.273, 0.4537, 0.2899, 0.4751]}, {"w": "Figure", "b": [0.2947, 0.4537, 0.3487, 0.4751]}, {"w": "8-4.", "b": [0.3534, 0.4537, 0.3856, 0.4751]}]}, {"id": "b_2", "type": "equation", "text": "Figure 8-4. Swiss roll dataset", "words": [{"w": "Figure", "b": [0.1429, 0.8184, 0.1943, 0.84]}, {"w": "8-4.", "b": [0.1991, 0.8184, 0.2308, 0.84]}, {"w": "Swiss", "b": [0.2356, 0.8184, 0.2786, 0.84]}, {"w": "roll", "b": [0.2834, 0.8184, 0.3104, 0.84]}, {"w": "dataset", "b": [0.3152, 0.8184, 0.3735, 0.84]}]}, {"id": "b_3", "type": "paragraph", "text": "Main Approaches for Dimensionality Reduction | 219", "words": [{"w": "Main", "b": [0.5213, 0.9225, 0.5508, 0.9388]}, {"w": "Approaches", "b": [0.5537, 0.9225, 0.622, 0.9388]}, {"w": "for", "b": [0.6248, 0.9225, 0.6416, 0.9388]}, {"w": "Dimensionality", "b": [0.6445, 0.9225, 0.7334, 0.9388]}, {"w": "Reduction", "b": [0.7362, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "219", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 246, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Simply projecting onto a plane (e.g., by dropping x3) would squash different layers of the Swiss roll together, as shown on the left of Figure 8-5. However, what you really want is to unroll the Swiss roll to obtain the 2D dataset on the right of Figure 8-5.", "words": [{"w": "Simply", "b": [0.1429, 0.0791, 0.2007, 0.1005]}, {"w": "projecting", "b": [0.2062, 0.0791, 0.2915, 0.1005]}, {"w": "onto", "b": [0.297, 0.0791, 0.3356, 0.1005]}, {"w": "a", "b": [0.341, 0.0791, 0.3502, 0.1005]}, {"w": "plane", "b": [0.3556, 0.0791, 0.4012, 0.1005]}, {"w": "(e.g.,", "b": [0.4066, 0.0791, 0.4467, 0.1005]}, {"w": "by", "b": [0.4521, 0.0791, 0.4723, 0.1005]}, {"w": "dropping", "b": [0.4777, 0.0791, 0.5556, 0.1005]}, {"w": "x3)", "b": [0.5611, 0.0789, 0.5841, 0.1014]}, {"w": "would", "b": [0.5896, 0.0791, 0.6418, 0.1005]}, {"w": "squash", "b": [0.6472, 0.0791, 0.7045, 0.1005]}, {"w": "different", "b": [0.7099, 0.0791, 0.7816, 0.1005]}, {"w": "layers", "b": [0.7871, 0.0791, 0.8349, 0.1005]}, {"w": "of", "b": [0.8404, 0.0791, 0.8571, 0.1005]}, {"w": "the", "b": [0.1429, 0.0981, 0.1692, 0.1195]}, {"w": "Swiss", "b": [0.1755, 0.0981, 0.2205, 0.1195]}, {"w": "roll", "b": [0.2268, 0.0981, 0.2557, 0.1195]}, {"w": "together,", "b": [0.262, 0.0981, 0.3351, 0.1195]}, {"w": "as", "b": [0.3414, 0.0981, 0.3582, 0.1195]}, {"w": "shown", "b": [0.3645, 0.0981, 0.4196, 0.1195]}, {"w": "on", "b": [0.4259, 0.0981, 0.4479, 0.1195]}, {"w": "the", "b": [0.4543, 0.0981, 0.4806, 0.1195]}, {"w": "left", "b": [0.4869, 0.0981, 0.5135, 0.1195]}, {"w": "of", "b": [0.5199, 0.0981, 0.5367, 0.1195]}, {"w": "Figure", "b": [0.543, 0.0981, 0.597, 0.1195]}, {"w": "8-5.", "b": [0.6033, 0.0981, 0.6354, 0.1195]}, {"w": "However,", "b": [0.6418, 0.0981, 0.7206, 0.1195]}, {"w": "what", "b": [0.7269, 0.0981, 0.7674, 0.1195]}, {"w": "you", "b": [0.7737, 0.0981, 0.805, 0.1195]}, {"w": "really", "b": [0.8113, 0.0981, 0.8571, 0.1195]}, {"w": "want", "b": [0.1429, 0.1172, 0.1836, 0.1386]}, {"w": "is", "b": [0.1884, 0.1172, 0.2016, 0.1386]}, {"w": "to", "b": [0.2063, 0.1172, 0.2233, 0.1386]}, {"w": "unroll", "b": [0.228, 0.1172, 0.2794, 0.1386]}, {"w": "the", "b": [0.2841, 0.1172, 0.3104, 0.1386]}, {"w": "Swiss", "b": [0.3152, 0.1172, 0.3602, 0.1386]}, {"w": "roll", "b": [0.3649, 0.1172, 0.3938, 0.1386]}, {"w": "to", "b": [0.3986, 0.1172, 0.4155, 0.1386]}, {"w": "obtain", "b": [0.4203, 0.1172, 0.4739, 0.1386]}, {"w": "the", "b": [0.4787, 0.1172, 0.505, 0.1386]}, {"w": "2D", "b": [0.5097, 0.1172, 0.5351, 0.1386]}, {"w": "dataset", "b": [0.5398, 0.1172, 0.5979, 0.1386]}, {"w": "on", "b": [0.6026, 0.1172, 0.6246, 0.1386]}, {"w": "the", "b": [0.6294, 0.1172, 0.6557, 0.1386]}, {"w": "right", "b": [0.6604, 0.1172, 0.7006, 0.1386]}, {"w": "of", "b": [0.7053, 0.1172, 0.7221, 0.1386]}, {"w": "Figure", "b": [0.7268, 0.1172, 0.7808, 0.1386]}, {"w": "8-5.", "b": [0.7856, 0.1172, 0.8177, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "Figure 8-5. Squashing by projecting onto a plane (left) versus unrolling the Swiss roll (right)", "words": [{"w": "Figure", "b": [0.1429, 0.3447, 0.1943, 0.3664]}, {"w": "8-5.", "b": [0.1991, 0.3447, 0.2308, 0.3664]}, {"w": "Squashing", "b": [0.2356, 0.3447, 0.3185, 0.3664]}, {"w": "by", "b": [0.3232, 0.3447, 0.3423, 0.3664]}, {"w": "projecting", "b": [0.3471, 0.3447, 0.4268, 0.3664]}, {"w": "onto", "b": [0.4316, 0.3447, 0.4677, 0.3664]}, {"w": "a", "b": [0.4725, 0.3447, 0.4827, 0.3664]}, {"w": "plane", "b": [0.4875, 0.3447, 0.5317, 0.3664]}, {"w": "(left)", "b": [0.5364, 0.3447, 0.5757, 0.3664]}, {"w": "versus", "b": [0.5805, 0.3447, 0.6306, 0.3664]}, {"w": "unrolling", "b": [0.6354, 0.3447, 0.7088, 0.3664]}, {"w": "the", "b": [0.7135, 0.3447, 0.7386, 0.3664]}, {"w": "Swiss", "b": [0.7433, 0.3447, 0.7864, 0.3664]}, {"w": "roll", "b": [0.7911, 0.3447, 0.8182, 0.3664]}, {"w": "(right)", "b": [0.1429, 0.3638, 0.1955, 0.3854]}]}, {"id": "b_2", "type": "paragraph", "text": "Manifold Learning", "words": [{"w": "Manifold", "b": [0.1429, 0.3984, 0.2355, 0.427]}, {"w": "Learning", "b": [0.2404, 0.3984, 0.332, 0.427]}]}, {"id": "b_3", "type": "paragraph", "text": "The Swiss roll is an example of a 2D manifold. Put simply, a 2D manifold is a 2D shape that can be bent and twisted in a higher-dimensional space. More generally, a d-dimensional manifold is a part of an n-dimensional space (where d < n) that locally resembles a d-dimensional hyperplane. In the case of the Swiss roll, d = 2 and n = 3: it locally resembles a 2D plane, but it is rolled in the third dimension.", "words": [{"w": "The", "b": [0.1429, 0.4329, 0.1757, 0.4543]}, {"w": "Swiss", "b": [0.1833, 0.4329, 0.2283, 0.4543]}, {"w": "roll", "b": [0.2359, 0.4329, 0.2648, 0.4543]}, {"w": "is", "b": [0.2723, 0.4329, 0.2856, 0.4543]}, {"w": "an", "b": [0.2931, 0.4329, 0.3137, 0.4543]}, {"w": "example", "b": [0.3213, 0.4329, 0.3908, 0.4543]}, {"w": "of", "b": [0.3984, 0.4329, 0.4152, 0.4543]}, {"w": "a", "b": [0.4227, 0.4329, 0.4319, 0.4543]}, {"w": "2D", "b": [0.4395, 0.4329, 0.4648, 0.4543]}, {"w": "manifold.", "b": [0.4724, 0.4327, 0.5501, 0.4543]}, {"w": "Put", "b": [0.5577, 0.4329, 0.5868, 0.4543]}, {"w": "simply,", "b": [0.5944, 0.4329, 0.6533, 0.4543]}, {"w": "a", "b": [0.6609, 0.4329, 0.67, 0.4543]}, {"w": "2D", "b": [0.6776, 0.4329, 0.7029, 0.4543]}, {"w": "manifold", "b": [0.7105, 0.4329, 0.7867, 0.4543]}, {"w": "is", "b": [0.7943, 0.4329, 0.8075, 0.4543]}, {"w": "a", "b": [0.8151, 0.4329, 0.8242, 0.4543]}, {"w": "2D", "b": [0.8318, 0.4329, 0.8571, 0.4543]}, {"w": "shape", "b": [0.1429, 0.452, 0.1902, 0.4734]}, {"w": "that", "b": [0.1965, 0.452, 0.2291, 0.4734]}, {"w": "can", "b": [0.2355, 0.452, 0.2648, 0.4734]}, {"w": "be", "b": [0.2712, 0.452, 0.2907, 0.4734]}, {"w": "bent", "b": [0.297, 0.452, 0.3338, 0.4734]}, {"w": "and", "b": [0.3402, 0.452, 0.3717, 0.4734]}, {"w": "twisted", "b": [0.3781, 0.452, 0.4382, 0.4734]}, {"w": "in", "b": [0.4446, 0.452, 0.4615, 0.4734]}, {"w": "a", "b": [0.4679, 0.452, 0.4771, 0.4734]}, {"w": "higher-dimensional", "b": [0.4834, 0.452, 0.6481, 0.4734]}, {"w": "space.", "b": [0.6545, 0.452, 0.7046, 0.4734]}, {"w": "More", "b": [0.711, 0.452, 0.7562, 0.4734]}, {"w": "generally,", "b": [0.7626, 0.452, 0.8416, 0.4734]}, {"w": "a", "b": [0.848, 0.452, 0.8572, 0.4734]}, {"w": "d-dimensional", "b": [0.1429, 0.4708, 0.2644, 0.4924]}, {"w": "manifold", "b": [0.2694, 0.471, 0.3457, 0.4924]}, {"w": "is", "b": [0.3507, 0.471, 0.3639, 0.4924]}, {"w": "a", "b": [0.3689, 0.471, 0.3781, 0.4924]}, {"w": "part", "b": [0.3831, 0.471, 0.4173, 0.4924]}, {"w": "of", "b": [0.4223, 0.471, 0.4391, 0.4924]}, {"w": "an", "b": [0.4441, 0.471, 0.4646, 0.4924]}, {"w": "n-dimensional", "b": [0.4696, 0.4708, 0.5917, 0.4924]}, {"w": "space", "b": [0.5967, 0.471, 0.6421, 0.4924]}, {"w": "(where", "b": [0.6471, 0.471, 0.7051, 0.4924]}, {"w": "d", "b": [0.7102, 0.4708, 0.7207, 0.4924]}, {"w": "<", "b": [0.7258, 0.471, 0.7373, 0.4924]}, {"w": "n)", "b": [0.7423, 0.4708, 0.7606, 0.4924]}, {"w": "that", "b": [0.7653, 0.471, 0.7979, 0.4924]}, {"w": "locally", "b": [0.8026, 0.471, 0.8566, 0.4924]}, {"w": "resembles", "b": [0.1429, 0.49, 0.2254, 0.5115]}, {"w": "a", "b": [0.2301, 0.49, 0.2392, 0.5115]}, {"w": "d-dimensional", "b": [0.2443, 0.4898, 0.3658, 0.5115]}, {"w": "hyperplane.", "b": [0.3707, 0.49, 0.4687, 0.5115]}, {"w": "In", "b": [0.4736, 0.49, 0.4921, 0.5115]}, {"w": "the", "b": [0.497, 0.49, 0.5233, 0.5115]}, {"w": "case", "b": [0.5282, 0.49, 0.5627, 0.5115]}, {"w": "of", "b": [0.5676, 0.49, 0.5844, 0.5115]}, {"w": "the", "b": [0.5892, 0.49, 0.6156, 0.5115]}, {"w": "Swiss", "b": [0.6205, 0.49, 0.6655, 0.5115]}, {"w": "roll,", "b": [0.6704, 0.49, 0.704, 0.5115]}, {"w": "d", "b": [0.7089, 0.4898, 0.7195, 0.5115]}, {"w": "=", "b": [0.7244, 0.49, 0.7365, 0.5115]}, {"w": "2", "b": [0.7412, 0.49, 0.7512, 0.5115]}, {"w": "and", "b": [0.7559, 0.49, 0.7875, 0.5115]}, {"w": "n", "b": [0.7926, 0.4898, 0.8037, 0.5115]}, {"w": "=", "b": [0.8086, 0.49, 0.8207, 0.5115]}, {"w": "3:", "b": [0.8254, 0.49, 0.8402, 0.5115]}, {"w": "it", "b": [0.8449, 0.49, 0.8568, 0.5115]}, {"w": "locally", "b": [0.1429, 0.5091, 0.1968, 0.5305]}, {"w": "resembles", "b": [0.2015, 0.5091, 0.284, 0.5305]}, {"w": "a", "b": [0.2888, 0.5091, 0.2979, 0.5305]}, {"w": "2D", "b": [0.3026, 0.5091, 0.328, 0.5305]}, {"w": "plane,", "b": [0.3327, 0.5091, 0.383, 0.5305]}, {"w": "but", "b": [0.3877, 0.5091, 0.4157, 0.5305]}, {"w": "it", "b": [0.4205, 0.5091, 0.4324, 0.5305]}, {"w": "is", "b": [0.4371, 0.5091, 0.4504, 0.5305]}, {"w": "rolled", "b": [0.4551, 0.5091, 0.5039, 0.5305]}, {"w": "in", "b": [0.5086, 0.5091, 0.5256, 0.5305]}, {"w": "the", "b": [0.5303, 0.5091, 0.5566, 0.5305]}, {"w": "third", "b": [0.5614, 0.5091, 0.6031, 0.5305]}, {"w": "dimension.", "b": [0.6079, 0.5091, 0.7018, 0.5305]}]}, {"id": "b_4", "type": "paragraph", "text": "Many dimensionality reduction algorithms work by modeling the manifold on which the training instances lie; this is called Manifold Learning. It relies on the manifold assumption, also called the manifold hypothesis, which holds that most real-world high-dimensional datasets lie close to a much lower-dimensional manifold. This assumption is very often empirically observed.", "words": [{"w": "Many", "b": [0.1429, 0.5372, 0.1907, 0.5586]}, {"w": "dimensionality", "b": [0.1962, 0.5372, 0.3212, 0.5586]}, {"w": "reduction", "b": [0.3267, 0.5372, 0.4081, 0.5586]}, {"w": "algorithms", "b": [0.4136, 0.5372, 0.5039, 0.5586]}, {"w": "work", "b": [0.5094, 0.5372, 0.5523, 0.5586]}, {"w": "by", "b": [0.5578, 0.5372, 0.5779, 0.5586]}, {"w": "modeling", "b": [0.5834, 0.5372, 0.663, 0.5586]}, {"w": "the", "b": [0.6684, 0.5372, 0.6948, 0.5586]}, {"w": "manifold", "b": [0.7002, 0.537, 0.7732, 0.5586]}, {"w": "on", "b": [0.7787, 0.5372, 0.8007, 0.5586]}, {"w": "which", "b": [0.8062, 0.5372, 0.8571, 0.5586]}, {"w": "the", "b": [0.1428, 0.5563, 0.1692, 0.5777]}, {"w": "training", "b": [0.1767, 0.5563, 0.2436, 0.5777]}, {"w": "instances", "b": [0.2511, 0.5563, 0.328, 0.5777]}, {"w": "lie;", "b": [0.3355, 0.5563, 0.3599, 0.5777]}, {"w": "this", "b": [0.3674, 0.5563, 0.3981, 0.5777]}, {"w": "is", "b": [0.4056, 0.5563, 0.4189, 0.5777]}, {"w": "called", "b": [0.4264, 0.5563, 0.4747, 0.5777]}, {"w": "Manifold", "b": [0.4822, 0.5561, 0.5566, 0.5777]}, {"w": "Learning.", "b": [0.5642, 0.5561, 0.6417, 0.5777]}, {"w": "It", "b": [0.6492, 0.5563, 0.6618, 0.5777]}, {"w": "relies", "b": [0.6693, 0.5563, 0.7133, 0.5777]}, {"w": "on", "b": [0.7208, 0.5563, 0.7428, 0.5777]}, {"w": "the", "b": [0.7503, 0.5563, 0.7766, 0.5777]}, {"w": "manifold", "b": [0.7841, 0.5561, 0.8571, 0.5777]}, {"w": "assumption,", "b": [0.1429, 0.5751, 0.2407, 0.5967]}, {"w": "also", "b": [0.2496, 0.5753, 0.2823, 0.5967]}, {"w": "called", "b": [0.2913, 0.5753, 0.3396, 0.5967]}, {"w": "the", "b": [0.3486, 0.5753, 0.3749, 0.5967]}, {"w": "manifold", "b": [0.3838, 0.5751, 0.4568, 0.5967]}, {"w": "hypothesis,", "b": [0.4658, 0.5751, 0.5543, 0.5967]}, {"w": "which", "b": [0.5632, 0.5753, 0.6141, 0.5967]}, {"w": "holds", "b": [0.6231, 0.5753, 0.6687, 0.5967]}, {"w": "that", "b": [0.6777, 0.5753, 0.7103, 0.5967]}, {"w": "most", "b": [0.7192, 0.5753, 0.7609, 0.5967]}, {"w": "real-world", "b": [0.7698, 0.5753, 0.8571, 0.5967]}, {"w": "high-dimensional", "b": [0.1429, 0.5944, 0.2914, 0.6158]}, {"w": "datasets", "b": [0.3014, 0.5944, 0.3671, 0.6158]}, {"w": "lie", "b": [0.3771, 0.5944, 0.3968, 0.6158]}, {"w": "close", "b": [0.4068, 0.5944, 0.448, 0.6158]}, {"w": "to", "b": [0.458, 0.5944, 0.475, 0.6158]}, {"w": "a", "b": [0.485, 0.5944, 0.4941, 0.6158]}, {"w": "much", "b": [0.5041, 0.5944, 0.5518, 0.6158]}, {"w": "lower-dimensional", "b": [0.5617, 0.5944, 0.719, 0.6158]}, {"w": "manifold.", "b": [0.729, 0.5944, 0.81, 0.6158]}, {"w": "This", "b": [0.8199, 0.5944, 0.8571, 0.6158]}, {"w": "assumption", "b": [0.1428, 0.6134, 0.2399, 0.6348]}, {"w": "is", "b": [0.2446, 0.6134, 0.2578, 0.6348]}, {"w": "very", "b": [0.2626, 0.6134, 0.299, 0.6348]}, {"w": "often", "b": [0.3037, 0.6134, 0.3471, 0.6348]}, {"w": "empirically", "b": [0.3518, 0.6134, 0.4452, 0.6348]}, {"w": "observed.", "b": [0.45, 0.6134, 0.5302, 0.6348]}]}, {"id": "b_5", "type": "paragraph", "text": "Once again, think about the MNIST dataset: all handwritten digit images have some similarities. They are made of connected lines, the borders are white, they are more or less centered, and so on. If you randomly generated images, only a ridiculously tiny fraction of them would look like handwritten digits. In other words, the degrees of freedom available to you if you try to create a digit image are dramatically lower than the degrees of freedom you would have if you were allowed to generate any image you wanted. These constraints tend to squeeze the dataset into a lower- dimensional manifold.", "words": [{"w": "Once", "b": [0.1428, 0.6415, 0.1875, 0.6629]}, {"w": "again,", "b": [0.1935, 0.6415, 0.2433, 0.6629]}, {"w": "think", "b": [0.2493, 0.6415, 0.2941, 0.6629]}, {"w": "about", "b": [0.3002, 0.6415, 0.3479, 0.6629]}, {"w": "the", "b": [0.354, 0.6415, 0.3803, 0.6629]}, {"w": "MNIST", "b": [0.3863, 0.6415, 0.4502, 0.6629]}, {"w": "dataset:", "b": [0.4563, 0.6415, 0.5191, 0.6629]}, {"w": "all", "b": [0.5251, 0.6415, 0.5448, 0.6629]}, {"w": "handwritten", "b": [0.5509, 0.6415, 0.6541, 0.6629]}, {"w": "digit", "b": [0.6601, 0.6415, 0.6984, 0.6629]}, {"w": "images", "b": [0.7044, 0.6415, 0.7625, 0.6629]}, {"w": "have", "b": [0.7685, 0.6415, 0.8069, 0.6629]}, {"w": "some", "b": [0.8129, 0.6415, 0.8571, 0.6629]}, {"w": "similarities.", "b": [0.1429, 0.6606, 0.2397, 0.682]}, {"w": "They", "b": [0.2461, 0.6606, 0.2885, 0.682]}, {"w": "are", "b": [0.2949, 0.6606, 0.3207, 0.682]}, {"w": "made", "b": [0.3271, 0.6606, 0.3732, 0.682]}, {"w": "of", "b": [0.3796, 0.6606, 0.3964, 0.682]}, {"w": "connected", "b": [0.4029, 0.6606, 0.489, 0.682]}, {"w": "lines,", "b": [0.4954, 0.6606, 0.5389, 0.682]}, {"w": "the", "b": [0.5454, 0.6606, 0.5717, 0.682]}, {"w": "borders", "b": [0.5782, 0.6606, 0.6423, 0.682]}, {"w": "are", "b": [0.6488, 0.6606, 0.6745, 0.682]}, {"w": "white,", "b": [0.681, 0.6606, 0.7319, 0.682]}, {"w": "they", "b": [0.7384, 0.6606, 0.7742, 0.682]}, {"w": "are", "b": [0.7807, 0.6606, 0.8064, 0.682]}, {"w": "more", "b": [0.8129, 0.6606, 0.8571, 0.682]}, {"w": "or", "b": [0.1429, 0.6796, 0.1612, 0.701]}, {"w": "less", "b": [0.1687, 0.6796, 0.1982, 0.701]}, {"w": "centered,", "b": [0.2057, 0.6796, 0.2819, 0.701]}, {"w": "and", "b": [0.2894, 0.6796, 0.321, 0.701]}, {"w": "so", "b": [0.3285, 0.6796, 0.3468, 0.701]}, {"w": "on.", "b": [0.3543, 0.6796, 0.3811, 0.701]}, {"w": "If", "b": [0.3886, 0.6796, 0.4019, 0.701]}, {"w": "you", "b": [0.4094, 0.6796, 0.4406, 0.701]}, {"w": "randomly", "b": [0.4482, 0.6796, 0.53, 0.701]}, {"w": "generated", "b": [0.5375, 0.6796, 0.619, 0.701]}, {"w": "images,", "b": [0.6266, 0.6796, 0.6893, 0.701]}, {"w": "only", "b": [0.6969, 0.6796, 0.7337, 0.701]}, {"w": "a", "b": [0.7413, 0.6796, 0.7504, 0.701]}, {"w": "ridiculously", "b": [0.7579, 0.6796, 0.8571, 0.701]}, {"w": "tiny", "b": [0.1429, 0.6987, 0.1753, 0.7201]}, {"w": "fraction", "b": [0.181, 0.6987, 0.2468, 0.7201]}, {"w": "of", "b": [0.2526, 0.6987, 0.2694, 0.7201]}, {"w": "them", "b": [0.2751, 0.6987, 0.3185, 0.7201]}, {"w": "would", "b": [0.3242, 0.6987, 0.3765, 0.7201]}, {"w": "look", "b": [0.3822, 0.6987, 0.4191, 0.7201]}, {"w": "like", "b": [0.4248, 0.6987, 0.4548, 0.7201]}, {"w": "handwritten", "b": [0.4606, 0.6987, 0.5638, 0.7201]}, {"w": "digits.", "b": [0.5695, 0.6987, 0.6202, 0.7201]}, {"w": "In", "b": [0.6259, 0.6987, 0.6444, 0.7201]}, {"w": "other", "b": [0.6502, 0.6987, 0.6949, 0.7201]}, {"w": "words,", "b": [0.7006, 0.6987, 0.7566, 0.7201]}, {"w": "the", "b": [0.7624, 0.6987, 0.7887, 0.7201]}, {"w": "degrees", "b": [0.7944, 0.6987, 0.8571, 0.7201]}, {"w": "of", "b": [0.1428, 0.7177, 0.1596, 0.7391]}, {"w": "freedom", "b": [0.1662, 0.7177, 0.2365, 0.7391]}, {"w": "available", "b": [0.2431, 0.7177, 0.3154, 0.7391]}, {"w": "to", "b": [0.322, 0.7177, 0.339, 0.7391]}, {"w": "you", "b": [0.3456, 0.7177, 0.3769, 0.7391]}, {"w": "if", "b": [0.3835, 0.7177, 0.3952, 0.7391]}, {"w": "you", "b": [0.4018, 0.7177, 0.4331, 0.7391]}, {"w": "try", "b": [0.4397, 0.7177, 0.4639, 0.7391]}, {"w": "to", "b": [0.4706, 0.7177, 0.4875, 0.7391]}, {"w": "create", "b": [0.4941, 0.7177, 0.5435, 0.7391]}, {"w": "a", "b": [0.5501, 0.7177, 0.5593, 0.7391]}, {"w": "digit", "b": [0.5659, 0.7177, 0.6041, 0.7391]}, {"w": "image", "b": [0.6107, 0.7177, 0.6611, 0.7391]}, {"w": "are", "b": [0.6677, 0.7177, 0.6935, 0.7391]}, {"w": "dramatically", "b": [0.7001, 0.7177, 0.8038, 0.7391]}, {"w": "lower", "b": [0.8104, 0.7177, 0.8571, 0.7391]}, {"w": "than", "b": [0.1429, 0.7368, 0.1809, 0.7582]}, {"w": "the", "b": [0.189, 0.7368, 0.2154, 0.7582]}, {"w": "degrees", "b": [0.2235, 0.7368, 0.2862, 0.7582]}, {"w": "of", "b": [0.2943, 0.7368, 0.3111, 0.7582]}, {"w": "freedom", "b": [0.3193, 0.7368, 0.3896, 0.7582]}, {"w": "you", "b": [0.3977, 0.7368, 0.4289, 0.7582]}, {"w": "would", "b": [0.4371, 0.7368, 0.4893, 0.7582]}, {"w": "have", "b": [0.4975, 0.7368, 0.5359, 0.7582]}, {"w": "if", "b": [0.544, 0.7368, 0.5557, 0.7582]}, {"w": "you", "b": [0.5639, 0.7368, 0.5951, 0.7582]}, {"w": "were", "b": [0.6033, 0.7368, 0.643, 0.7582]}, {"w": "allowed", "b": [0.6511, 0.7368, 0.7156, 0.7582]}, {"w": "to", "b": [0.7237, 0.7368, 0.7407, 0.7582]}, {"w": "generate", "b": [0.7488, 0.7368, 0.8194, 0.7582]}, {"w": "any", "b": [0.8275, 0.7368, 0.8571, 0.7582]}, {"w": "image", "b": [0.1429, 0.7558, 0.1932, 0.7772]}, {"w": "you", "b": [0.2037, 0.7558, 0.235, 0.7772]}, {"w": "wanted.", "b": [0.2454, 0.7558, 0.3108, 0.7772]}, {"w": "These", "b": [0.3213, 0.7558, 0.3706, 0.7772]}, {"w": "constraints", "b": [0.3811, 0.7558, 0.4734, 0.7772]}, {"w": "tend", "b": [0.4838, 0.7558, 0.5214, 0.7772]}, {"w": "to", "b": [0.5319, 0.7558, 0.5489, 0.7772]}, {"w": "squeeze", "b": [0.5593, 0.7558, 0.624, 0.7772]}, {"w": "the", "b": [0.6345, 0.7558, 0.6608, 0.7772]}, {"w": "dataset", "b": [0.6713, 0.7558, 0.7294, 0.7772]}, {"w": "into", "b": [0.7398, 0.7558, 0.7734, 0.7772]}, {"w": "a", "b": [0.7839, 0.7558, 0.793, 0.7772]}, {"w": "lower-", "b": [0.8035, 0.7558, 0.8571, 0.7772]}, {"w": "dimensional", "b": [0.1428, 0.7749, 0.2464, 0.7963]}, {"w": "manifold.", "b": [0.2511, 0.7749, 0.3321, 0.7963]}]}, {"id": "b_6", "type": "paragraph", "text": "The manifold assumption is often accompanied by another implicit assumption: that the task at hand (e.g., classification or regression) will be simpler if expressed in the lower-dimensional space of the manifold. For example, in the top row of Figure 8-6 the Swiss roll is split into two classes: in the 3D space (on the left), the decision", "words": [{"w": "The", "b": [0.1428, 0.803, 0.1757, 0.8244]}, {"w": "manifold", "b": [0.1813, 0.803, 0.2575, 0.8244]}, {"w": "assumption", "b": [0.2631, 0.803, 0.3602, 0.8244]}, {"w": "is", "b": [0.3658, 0.803, 0.379, 0.8244]}, {"w": "often", "b": [0.3846, 0.803, 0.428, 0.8244]}, {"w": "accompanied", "b": [0.4336, 0.803, 0.5446, 0.8244]}, {"w": "by", "b": [0.5502, 0.803, 0.5703, 0.8244]}, {"w": "another", "b": [0.5759, 0.803, 0.6412, 0.8244]}, {"w": "implicit", "b": [0.6468, 0.803, 0.7115, 0.8244]}, {"w": "assumption:", "b": [0.7172, 0.803, 0.8189, 0.8244]}, {"w": "that", "b": [0.8246, 0.803, 0.8571, 0.8244]}, {"w": "the", "b": [0.1429, 0.822, 0.1692, 0.8434]}, {"w": "task", "b": [0.1756, 0.822, 0.209, 0.8434]}, {"w": "at", "b": [0.2154, 0.822, 0.2305, 0.8434]}, {"w": "hand", "b": [0.2368, 0.822, 0.2795, 0.8434]}, {"w": "(e.g.,", "b": [0.2859, 0.822, 0.3259, 0.8434]}, {"w": "classification", "b": [0.3323, 0.822, 0.4397, 0.8434]}, {"w": "or", "b": [0.446, 0.822, 0.4644, 0.8434]}, {"w": "regression)", "b": [0.4707, 0.822, 0.5638, 0.8434]}, {"w": "will", "b": [0.5701, 0.822, 0.6005, 0.8434]}, {"w": "be", "b": [0.6069, 0.822, 0.6263, 0.8434]}, {"w": "simpler", "b": [0.6327, 0.822, 0.6953, 0.8434]}, {"w": "if", "b": [0.7017, 0.822, 0.7134, 0.8434]}, {"w": "expressed", "b": [0.7198, 0.822, 0.8011, 0.8434]}, {"w": "in", "b": [0.8075, 0.822, 0.8245, 0.8434]}, {"w": "the", "b": [0.8308, 0.822, 0.8571, 0.8434]}, {"w": "lower-dimensional", "b": [0.1429, 0.8411, 0.3001, 0.8625]}, {"w": "space", "b": [0.3064, 0.8411, 0.3518, 0.8625]}, {"w": "of", "b": [0.3581, 0.8411, 0.3749, 0.8625]}, {"w": "the", "b": [0.3812, 0.8411, 0.4076, 0.8625]}, {"w": "manifold.", "b": [0.4139, 0.8411, 0.4949, 0.8625]}, {"w": "For", "b": [0.5012, 0.8411, 0.5302, 0.8625]}, {"w": "example,", "b": [0.5365, 0.8411, 0.6108, 0.8625]}, {"w": "in", "b": [0.6171, 0.8411, 0.6341, 0.8625]}, {"w": "the", "b": [0.6404, 0.8411, 0.6668, 0.8625]}, {"w": "top", "b": [0.6731, 0.8411, 0.701, 0.8625]}, {"w": "row", "b": [0.7073, 0.8411, 0.74, 0.8625]}, {"w": "of", "b": [0.7463, 0.8411, 0.7631, 0.8625]}, {"w": "Figure", "b": [0.7694, 0.8411, 0.8234, 0.8625]}, {"w": "8-6", "b": [0.8297, 0.8411, 0.8571, 0.8625]}, {"w": "the", "b": [0.1429, 0.8601, 0.1692, 0.8815]}, {"w": "Swiss", "b": [0.1777, 0.8601, 0.2227, 0.8815]}, {"w": "roll", "b": [0.2313, 0.8601, 0.2602, 0.8815]}, {"w": "is", "b": [0.2687, 0.8601, 0.2819, 0.8815]}, {"w": "split", "b": [0.2904, 0.8601, 0.3262, 0.8815]}, {"w": "into", "b": [0.3347, 0.8601, 0.3683, 0.8815]}, {"w": "two", "b": [0.3768, 0.8601, 0.4081, 0.8815]}, {"w": "classes:", "b": [0.4166, 0.8601, 0.4764, 0.8815]}, {"w": "in", "b": [0.4849, 0.8601, 0.5019, 0.8815]}, {"w": "the", "b": [0.5104, 0.8601, 0.5368, 0.8815]}, {"w": "3D", "b": [0.5453, 0.8601, 0.5706, 0.8815]}, {"w": "space", "b": [0.5791, 0.8601, 0.6245, 0.8815]}, {"w": "(on", "b": [0.633, 0.8601, 0.6623, 0.8815]}, {"w": "the", "b": [0.6708, 0.8601, 0.6971, 0.8815]}, {"w": "left),", "b": [0.7056, 0.8601, 0.7442, 0.8815]}, {"w": "the", "b": [0.7528, 0.8601, 0.7791, 0.8815]}, {"w": "decision", "b": [0.7876, 0.8601, 0.8571, 0.8815]}]}, {"id": "b_7", "type": "paragraph", "text": "220 | Chapter 8: Dimensionality Reduction", "words": [{"w": "220", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "8:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Dimensionality", "b": [0.2673, 0.9225, 0.3562, 0.9388]}, {"w": "Reduction", "b": [0.359, 0.9225, 0.4186, 0.9388]}]}]}, {"page": 247, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "boundary would be fairly complex, but in the 2D unrolled manifold space (on the right), the decision boundary is a simple straight line.", "words": [{"w": "boundary", "b": [0.1429, 0.0791, 0.2246, 0.1005]}, {"w": "would", "b": [0.232, 0.0791, 0.2842, 0.1005]}, {"w": "be", "b": [0.2917, 0.0791, 0.3111, 0.1005]}, {"w": "fairly", "b": [0.3185, 0.0791, 0.362, 0.1005]}, {"w": "complex,", "b": [0.3694, 0.0791, 0.4452, 0.1005]}, {"w": "but", "b": [0.4526, 0.0791, 0.4806, 0.1005]}, {"w": "in", "b": [0.4881, 0.0791, 0.505, 0.1005]}, {"w": "the", "b": [0.5125, 0.0791, 0.5388, 0.1005]}, {"w": "2D", "b": [0.5462, 0.0791, 0.5716, 0.1005]}, {"w": "unrolled", "b": [0.579, 0.0791, 0.6502, 0.1005]}, {"w": "manifold", "b": [0.6576, 0.0791, 0.7339, 0.1005]}, {"w": "space", "b": [0.7413, 0.0791, 0.7867, 0.1005]}, {"w": "(on", "b": [0.7941, 0.0791, 0.8234, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}, {"w": "right),", "b": [0.1429, 0.0981, 0.195, 0.1195]}, {"w": "the", "b": [0.1997, 0.0981, 0.226, 0.1195]}, {"w": "decision", "b": [0.2307, 0.0981, 0.3002, 0.1195]}, {"w": "boundary", "b": [0.305, 0.0981, 0.3867, 0.1195]}, {"w": "is", "b": [0.3914, 0.0981, 0.4046, 0.1195]}, {"w": "a", "b": [0.4094, 0.0981, 0.4185, 0.1195]}, {"w": "simple", "b": [0.4232, 0.0981, 0.4782, 0.1195]}, {"w": "straight", "b": [0.4829, 0.0981, 0.5462, 0.1195]}, {"w": "line.", "b": [0.5509, 0.0981, 0.5868, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "However, this assumption does not always hold. For example, in the bottom row of Figure 8-6, the decision boundary is located at x1 = 5. This decision boundary looks very simple in the original 3D space (a vertical plane), but it looks more complex in the unrolled manifold (a collection of four independent line segments).", "words": [{"w": "However,", "b": [0.1429, 0.1262, 0.2217, 0.1476]}, {"w": "this", "b": [0.2283, 0.1262, 0.259, 0.1476]}, {"w": "assumption", "b": [0.2657, 0.1262, 0.3627, 0.1476]}, {"w": "does", "b": [0.3693, 0.1262, 0.4075, 0.1476]}, {"w": "not", "b": [0.4141, 0.1262, 0.4425, 0.1476]}, {"w": "always", "b": [0.4491, 0.1262, 0.5038, 0.1476]}, {"w": "hold.", "b": [0.5104, 0.1262, 0.5531, 0.1476]}, {"w": "For", "b": [0.5598, 0.1262, 0.5888, 0.1476]}, {"w": "example,", "b": [0.5954, 0.1262, 0.6697, 0.1476]}, {"w": "in", "b": [0.6763, 0.1262, 0.6933, 0.1476]}, {"w": "the", "b": [0.6999, 0.1262, 0.7262, 0.1476]}, {"w": "bottom", "b": [0.7329, 0.1262, 0.7945, 0.1476]}, {"w": "row", "b": [0.8011, 0.1262, 0.8337, 0.1476]}, {"w": "of", "b": [0.8403, 0.1262, 0.8571, 0.1476]}, {"w": "Figure", "b": [0.1429, 0.1453, 0.1969, 0.1667]}, {"w": "8-6,", "b": [0.2031, 0.1453, 0.2352, 0.1667]}, {"w": "the", "b": [0.2415, 0.1453, 0.2678, 0.1667]}, {"w": "decision", "b": [0.274, 0.1453, 0.3435, 0.1667]}, {"w": "boundary", "b": [0.3497, 0.1453, 0.4314, 0.1667]}, {"w": "is", "b": [0.4376, 0.1453, 0.4509, 0.1667]}, {"w": "located", "b": [0.4571, 0.1453, 0.5167, 0.1667]}, {"w": "at", "b": [0.523, 0.1453, 0.5381, 0.1667]}, {"w": "x1", "b": [0.5443, 0.1451, 0.5601, 0.1676]}, {"w": "=", "b": [0.5663, 0.1453, 0.5784, 0.1667]}, {"w": "5.", "b": [0.5846, 0.1453, 0.5994, 0.1667]}, {"w": "This", "b": [0.6056, 0.1453, 0.6428, 0.1667]}, {"w": "decision", "b": [0.649, 0.1453, 0.7185, 0.1667]}, {"w": "boundary", "b": [0.7247, 0.1453, 0.8064, 0.1667]}, {"w": "looks", "b": [0.8126, 0.1453, 0.8571, 0.1667]}, {"w": "very", "b": [0.1428, 0.1643, 0.1792, 0.1857]}, {"w": "simple", "b": [0.1854, 0.1643, 0.2403, 0.1857]}, {"w": "in", "b": [0.2464, 0.1643, 0.2634, 0.1857]}, {"w": "the", "b": [0.2695, 0.1643, 0.2959, 0.1857]}, {"w": "original", "b": [0.302, 0.1643, 0.3671, 0.1857]}, {"w": "3D", "b": [0.3732, 0.1643, 0.3985, 0.1857]}, {"w": "space", "b": [0.4047, 0.1643, 0.45, 0.1857]}, {"w": "(a", "b": [0.4562, 0.1643, 0.4725, 0.1857]}, {"w": "vertical", "b": [0.4786, 0.1643, 0.54, 0.1857]}, {"w": "plane),", "b": [0.5462, 0.1643, 0.6037, 0.1857]}, {"w": "but", "b": [0.6098, 0.1643, 0.6378, 0.1857]}, {"w": "it", "b": [0.644, 0.1643, 0.6559, 0.1857]}, {"w": "looks", "b": [0.662, 0.1643, 0.7065, 0.1857]}, {"w": "more", "b": [0.7126, 0.1643, 0.7569, 0.1857]}, {"w": "complex", "b": [0.763, 0.1643, 0.834, 0.1857]}, {"w": "in", "b": [0.8402, 0.1643, 0.8571, 0.1857]}, {"w": "the", "b": [0.1429, 0.1834, 0.1692, 0.2048]}, {"w": "unrolled", "b": [0.1739, 0.1834, 0.2451, 0.2048]}, {"w": "manifold", "b": [0.2499, 0.1834, 0.3261, 0.2048]}, {"w": "(a", "b": [0.3308, 0.1834, 0.3472, 0.2048]}, {"w": "collection", "b": [0.3519, 0.1834, 0.4335, 0.2048]}, {"w": "of", "b": [0.4383, 0.1834, 0.455, 0.2048]}, {"w": "four", "b": [0.4598, 0.1834, 0.4954, 0.2048]}, {"w": "independent", "b": [0.5001, 0.1834, 0.6053, 0.2048]}, {"w": "line", "b": [0.61, 0.1834, 0.6411, 0.2048]}, {"w": "segments).", "b": [0.6459, 0.1834, 0.735, 0.2048]}]}, {"id": "b_2", "type": "paragraph", "text": "In short, if you reduce the dimensionality of your training set before training a model, it will usually speed up training, but it may not always lead to a better or sim‐ pler solution; it all depends on the dataset.", "words": [{"w": "In", "b": [0.1429, 0.2115, 0.1614, 0.2329]}, {"w": "short,", "b": [0.1708, 0.2115, 0.219, 0.2329]}, {"w": "if", "b": [0.2284, 0.2115, 0.2402, 0.2329]}, {"w": "you", "b": [0.2496, 0.2115, 0.2808, 0.2329]}, {"w": "reduce", "b": [0.2902, 0.2115, 0.3466, 0.2329]}, {"w": "the", "b": [0.356, 0.2115, 0.3823, 0.2329]}, {"w": "dimensionality", "b": [0.3917, 0.2115, 0.5168, 0.2329]}, {"w": "of", "b": [0.5262, 0.2115, 0.543, 0.2329]}, {"w": "your", "b": [0.5524, 0.2115, 0.5914, 0.2329]}, {"w": "training", "b": [0.6008, 0.2115, 0.6677, 0.2329]}, {"w": "set", "b": [0.6772, 0.2115, 0.7, 0.2329]}, {"w": "before", "b": [0.7094, 0.2115, 0.7622, 0.2329]}, {"w": "training", "b": [0.7716, 0.2115, 0.8386, 0.2329]}, {"w": "a", "b": [0.848, 0.2115, 0.8571, 0.2329]}, {"w": "model,", "b": [0.1429, 0.2305, 0.2004, 0.2519]}, {"w": "it", "b": [0.2058, 0.2305, 0.2177, 0.2519]}, {"w": "will", "b": [0.223, 0.2305, 0.2534, 0.2519]}, {"w": "usually", "b": [0.2588, 0.2305, 0.3178, 0.2519]}, {"w": "speed", "b": [0.3232, 0.2305, 0.3704, 0.2519]}, {"w": "up", "b": [0.3758, 0.2305, 0.3977, 0.2519]}, {"w": "training,", "b": [0.4031, 0.2305, 0.4748, 0.2519]}, {"w": "but", "b": [0.4801, 0.2305, 0.5081, 0.2519]}, {"w": "it", "b": [0.5135, 0.2305, 0.5254, 0.2519]}, {"w": "may", "b": [0.5308, 0.2305, 0.5662, 0.2519]}, {"w": "not", "b": [0.5715, 0.2305, 0.5999, 0.2519]}, {"w": "always", "b": [0.6052, 0.2305, 0.6599, 0.2519]}, {"w": "lead", "b": [0.6652, 0.2305, 0.6995, 0.2519]}, {"w": "to", "b": [0.7048, 0.2305, 0.7218, 0.2519]}, {"w": "a", "b": [0.7272, 0.2305, 0.7363, 0.2519]}, {"w": "better", "b": [0.7417, 0.2305, 0.7904, 0.2519]}, {"w": "or", "b": [0.7957, 0.2305, 0.8141, 0.2519]}, {"w": "sim‐", "b": [0.8194, 0.2305, 0.8571, 0.2519]}, {"w": "pler", "b": [0.1428, 0.2496, 0.1756, 0.271]}, {"w": "solution;", "b": [0.1803, 0.2496, 0.2537, 0.271]}, {"w": "it", "b": [0.2584, 0.2496, 0.2703, 0.271]}, {"w": "all", "b": [0.2751, 0.2496, 0.2947, 0.271]}, {"w": "depends", "b": [0.2995, 0.2496, 0.3691, 0.271]}, {"w": "on", "b": [0.3739, 0.2496, 0.3959, 0.271]}, {"w": "the", "b": [0.4006, 0.2496, 0.427, 0.271]}, {"w": "dataset.", "b": [0.4317, 0.2496, 0.4945, 0.271]}]}, {"id": "b_3", "type": "paragraph", "text": "Hopefully you now have a good sense of what the curse of dimensionality is and how dimensionality reduction algorithms can fight it, especially when the manifold assumption holds. The rest of this chapter will go through some of the most popular algorithms.", "words": [{"w": "Hopefully", "b": [0.1428, 0.2777, 0.226, 0.2991]}, {"w": "you", "b": [0.2313, 0.2777, 0.2626, 0.2991]}, {"w": "now", "b": [0.2678, 0.2777, 0.3041, 0.2991]}, {"w": "have", "b": [0.3094, 0.2777, 0.3478, 0.2991]}, {"w": "a", "b": [0.3531, 0.2777, 0.3622, 0.2991]}, {"w": "good", "b": [0.3675, 0.2777, 0.4095, 0.2991]}, {"w": "sense", "b": [0.4148, 0.2777, 0.4592, 0.2991]}, {"w": "of", "b": [0.4645, 0.2777, 0.4813, 0.2991]}, {"w": "what", "b": [0.4866, 0.2777, 0.5271, 0.2991]}, {"w": "the", "b": [0.5323, 0.2777, 0.5587, 0.2991]}, {"w": "curse", "b": [0.564, 0.2777, 0.6081, 0.2991]}, {"w": "of", "b": [0.6134, 0.2777, 0.6301, 0.2991]}, {"w": "dimensionality", "b": [0.6354, 0.2777, 0.7605, 0.2991]}, {"w": "is", "b": [0.7658, 0.2777, 0.779, 0.2991]}, {"w": "and", "b": [0.7843, 0.2777, 0.8158, 0.2991]}, {"w": "how", "b": [0.8211, 0.2777, 0.8571, 0.2991]}, {"w": "dimensionality", "b": [0.1429, 0.2967, 0.2679, 0.3182]}, {"w": "reduction", "b": [0.2796, 0.2967, 0.361, 0.3182]}, {"w": "algorithms", "b": [0.3726, 0.2967, 0.4629, 0.3182]}, {"w": "can", "b": [0.4746, 0.2967, 0.5039, 0.3182]}, {"w": "fight", "b": [0.5155, 0.2967, 0.5541, 0.3182]}, {"w": "it,", "b": [0.5658, 0.2967, 0.5825, 0.3182]}, {"w": "especially", "b": [0.5941, 0.2967, 0.674, 0.3182]}, {"w": "when", "b": [0.6856, 0.2967, 0.7313, 0.3182]}, {"w": "the", "b": [0.7429, 0.2967, 0.7693, 0.3182]}, {"w": "manifold", "b": [0.7809, 0.2967, 0.8572, 0.3182]}, {"w": "assumption", "b": [0.1429, 0.3158, 0.2399, 0.3372]}, {"w": "holds.", "b": [0.2456, 0.3158, 0.296, 0.3372]}, {"w": "The", "b": [0.3018, 0.3158, 0.3346, 0.3372]}, {"w": "rest", "b": [0.3403, 0.3158, 0.3709, 0.3372]}, {"w": "of", "b": [0.3766, 0.3158, 0.3934, 0.3372]}, {"w": "this", "b": [0.3992, 0.3158, 0.4299, 0.3372]}, {"w": "chapter", "b": [0.4356, 0.3158, 0.4981, 0.3372]}, {"w": "will", "b": [0.5039, 0.3158, 0.5343, 0.3372]}, {"w": "go", "b": [0.54, 0.3158, 0.5604, 0.3372]}, {"w": "through", "b": [0.5661, 0.3158, 0.6338, 0.3372]}, {"w": "some", "b": [0.6396, 0.3158, 0.6838, 0.3372]}, {"w": "of", "b": [0.6895, 0.3158, 0.7063, 0.3372]}, {"w": "the", "b": [0.712, 0.3158, 0.7383, 0.3372]}, {"w": "most", "b": [0.7441, 0.3158, 0.7858, 0.3372]}, {"w": "popular", "b": [0.7915, 0.3158, 0.8571, 0.3372]}, {"w": "algorithms.", "b": [0.1429, 0.3348, 0.2379, 0.3563]}]}, {"id": "b_4", "type": "paragraph", "text": "Figure 8-6. The decision boundary may not always be simpler with lower dimensions", "words": [{"w": "Figure", "b": [0.1429, 0.7787, 0.1943, 0.8003]}, {"w": "8-6.", "b": [0.1991, 0.7787, 0.2308, 0.8003]}, {"w": "The", "b": [0.2356, 0.7787, 0.2654, 0.8003]}, {"w": "decision", "b": [0.2702, 0.7787, 0.3357, 0.8003]}, {"w": "boundary", "b": [0.3405, 0.7787, 0.4195, 0.8003]}, {"w": "may", "b": [0.4243, 0.7787, 0.4595, 0.8003]}, {"w": "not", "b": [0.4642, 0.7787, 0.4911, 0.8003]}, {"w": "always", "b": [0.4959, 0.7787, 0.5506, 0.8003]}, {"w": "be", "b": [0.5553, 0.7787, 0.5737, 0.8003]}, {"w": "simpler", "b": [0.5785, 0.7787, 0.6377, 0.8003]}, {"w": "with", "b": [0.6425, 0.7787, 0.679, 0.8003]}, {"w": "lower", "b": [0.6838, 0.7787, 0.7282, 0.8003]}, {"w": "dimensions", "b": [0.733, 0.7787, 0.8245, 0.8003]}]}, {"id": "b_5", "type": "paragraph", "text": "Main Approaches for Dimensionality Reduction | 221", "words": [{"w": "Main", "b": [0.5213, 0.9225, 0.5508, 0.9388]}, {"w": "Approaches", "b": [0.5537, 0.9225, 0.622, 0.9388]}, {"w": "for", "b": [0.6248, 0.9225, 0.6416, 0.9388]}, {"w": "Dimensionality", "b": [0.6445, 0.9225, 0.7334, 0.9388]}, {"w": "Reduction", "b": [0.7362, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "221", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 248, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "4 “On Lines and Planes of Closest Fit to Systems of Points in Space,” K. Pearson (1901).", "words": [{"w": "4", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“On", "b": [0.1587, 0.8749, 0.185, 0.8912]}, {"w": "Lines", "b": [0.1886, 0.8749, 0.2227, 0.8912]}, {"w": "and", "b": [0.2263, 0.8749, 0.2503, 0.8912]}, {"w": "Planes", "b": [0.2539, 0.8749, 0.2951, 0.8912]}, {"w": "of", "b": [0.2987, 0.8749, 0.3115, 0.8912]}, {"w": "Closest", "b": [0.3151, 0.8749, 0.361, 0.8912]}, {"w": "Fit", "b": [0.3646, 0.8749, 0.3821, 0.8912]}, {"w": "to", "b": [0.3857, 0.8749, 0.3986, 0.8912]}, {"w": "Systems", "b": [0.4022, 0.8749, 0.4533, 0.8912]}, {"w": "of", "b": [0.4569, 0.8749, 0.4697, 0.8912]}, {"w": "Points", "b": [0.4733, 0.8749, 0.5131, 0.8912]}, {"w": "in", "b": [0.5167, 0.8749, 0.5296, 0.8912]}, {"w": "Space,”", "b": [0.5332, 0.8749, 0.5773, 0.8912]}, {"w": "K.", "b": [0.5809, 0.8749, 0.5952, 0.8912]}, {"w": "Pearson", "b": [0.5988, 0.8749, 0.6494, 0.8912]}, {"w": "(1901).", "b": [0.653, 0.8749, 0.6981, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "PCA", "words": [{"w": "PCA", "b": [0.1428, 0.0753, 0.1903, 0.1095]}]}, {"id": "b_2", "type": "paragraph", "text": "Principal Component Analysis (PCA) is by far the most popular dimensionality reduc‐ tion algorithm. First it identifies the hyperplane that lies closest to the data, and then it projects the data onto it, just like in Figure 8-2.", "words": [{"w": "Principal", "b": [0.1429, 0.1162, 0.2171, 0.1378]}, {"w": "Component", "b": [0.2219, 0.1162, 0.3168, 0.1378]}, {"w": "Analysis", "b": [0.3215, 0.1162, 0.39, 0.1378]}, {"w": "(PCA)", "b": [0.3947, 0.1164, 0.4491, 0.1378]}, {"w": "is", "b": [0.4539, 0.1164, 0.4671, 0.1378]}, {"w": "by", "b": [0.4719, 0.1164, 0.492, 0.1378]}, {"w": "far", "b": [0.4967, 0.1164, 0.5198, 0.1378]}, {"w": "the", "b": [0.5245, 0.1164, 0.5508, 0.1378]}, {"w": "most", "b": [0.5556, 0.1164, 0.5972, 0.1378]}, {"w": "popular", "b": [0.602, 0.1164, 0.6676, 0.1378]}, {"w": "dimensionality", "b": [0.6724, 0.1164, 0.7974, 0.1378]}, {"w": "reduc‐", "b": [0.8022, 0.1164, 0.857, 0.1378]}, {"w": "tion", "b": [0.1429, 0.1355, 0.1768, 0.1569]}, {"w": "algorithm.", "b": [0.1824, 0.1355, 0.2698, 0.1569]}, {"w": "First", "b": [0.2754, 0.1355, 0.3138, 0.1569]}, {"w": "it", "b": [0.3194, 0.1355, 0.3313, 0.1569]}, {"w": "identifies", "b": [0.337, 0.1355, 0.4136, 0.1569]}, {"w": "the", "b": [0.4192, 0.1355, 0.4455, 0.1569]}, {"w": "hyperplane", "b": [0.4512, 0.1355, 0.5444, 0.1569]}, {"w": "that", "b": [0.5501, 0.1355, 0.5827, 0.1569]}, {"w": "lies", "b": [0.5883, 0.1355, 0.6156, 0.1569]}, {"w": "closest", "b": [0.6212, 0.1355, 0.6765, 0.1569]}, {"w": "to", "b": [0.6821, 0.1355, 0.6991, 0.1569]}, {"w": "the", "b": [0.7047, 0.1355, 0.731, 0.1569]}, {"w": "data,", "b": [0.7366, 0.1355, 0.7766, 0.1569]}, {"w": "and", "b": [0.7822, 0.1355, 0.8138, 0.1569]}, {"w": "then", "b": [0.8194, 0.1355, 0.8571, 0.1569]}, {"w": "it", "b": [0.1428, 0.1545, 0.1548, 0.1759]}, {"w": "projects", "b": [0.1595, 0.1545, 0.2258, 0.1759]}, {"w": "the", "b": [0.2305, 0.1545, 0.2568, 0.1759]}, {"w": "data", "b": [0.2616, 0.1545, 0.2968, 0.1759]}, {"w": "onto", "b": [0.3016, 0.1545, 0.3402, 0.1759]}, {"w": "it,", "b": [0.3449, 0.1545, 0.3616, 0.1759]}, {"w": "just", "b": [0.3663, 0.1545, 0.3967, 0.1759]}, {"w": "like", "b": [0.4015, 0.1545, 0.4315, 0.1759]}, {"w": "in", "b": [0.4362, 0.1545, 0.4532, 0.1759]}, {"w": "Figure", "b": [0.4579, 0.1545, 0.5119, 0.1759]}, {"w": "8-2.", "b": [0.5167, 0.1545, 0.5488, 0.1759]}]}, {"id": "b_3", "type": "paragraph", "text": "Preserving the Variance", "words": [{"w": "Preserving", "b": [0.1428, 0.1887, 0.2527, 0.2173]}, {"w": "the", "b": [0.2576, 0.1887, 0.2925, 0.2173]}, {"w": "Variance", "b": [0.2974, 0.1887, 0.3866, 0.2173]}]}, {"id": "b_4", "type": "paragraph", "text": "Before you can project the training set onto a lower-dimensional hyperplane, you first need to choose the right hyperplane. For example, a simple 2D dataset is repre‐ sented on the left of Figure 8-7, along with three different axes (i.e., one-dimensional hyperplanes). On the right is the result of the projection of the dataset onto each of these axes. As you can see, the projection onto the solid line preserves the maximum variance, while the projection onto the dotted line preserves very little variance, and the projection onto the dashed line preserves an intermediate amount of variance.", "words": [{"w": "Before", "b": [0.1429, 0.2232, 0.1978, 0.2446]}, {"w": "you", "b": [0.2059, 0.2232, 0.2372, 0.2446]}, {"w": "can", "b": [0.2453, 0.2232, 0.2747, 0.2446]}, {"w": "project", "b": [0.2828, 0.2232, 0.3415, 0.2446]}, {"w": "the", "b": [0.3496, 0.2232, 0.376, 0.2446]}, {"w": "training", "b": [0.3841, 0.2232, 0.4511, 0.2446]}, {"w": "set", "b": [0.4592, 0.2232, 0.4821, 0.2446]}, {"w": "onto", "b": [0.4902, 0.2232, 0.5288, 0.2446]}, {"w": "a", "b": [0.537, 0.2232, 0.5461, 0.2446]}, {"w": "lower-dimensional", "b": [0.5543, 0.2232, 0.7115, 0.2446]}, {"w": "hyperplane,", "b": [0.7197, 0.2232, 0.8177, 0.2446]}, {"w": "you", "b": [0.8259, 0.2232, 0.8571, 0.2446]}, {"w": "first", "b": [0.1429, 0.2422, 0.1763, 0.2636]}, {"w": "need", "b": [0.1825, 0.2422, 0.2226, 0.2636]}, {"w": "to", "b": [0.2287, 0.2422, 0.2457, 0.2636]}, {"w": "choose", "b": [0.2518, 0.2422, 0.3095, 0.2636]}, {"w": "the", "b": [0.3157, 0.2422, 0.342, 0.2636]}, {"w": "right", "b": [0.3482, 0.2422, 0.3883, 0.2636]}, {"w": "hyperplane.", "b": [0.3944, 0.2422, 0.4925, 0.2636]}, {"w": "For", "b": [0.4986, 0.2422, 0.5276, 0.2636]}, {"w": "example,", "b": [0.5338, 0.2422, 0.608, 0.2636]}, {"w": "a", "b": [0.6142, 0.2422, 0.6233, 0.2636]}, {"w": "simple", "b": [0.6295, 0.2422, 0.6844, 0.2636]}, {"w": "2D", "b": [0.6906, 0.2422, 0.7159, 0.2636]}, {"w": "dataset", "b": [0.722, 0.2422, 0.7801, 0.2636]}, {"w": "is", "b": [0.7863, 0.2422, 0.7995, 0.2636]}, {"w": "repre‐", "b": [0.8056, 0.2422, 0.8571, 0.2636]}, {"w": "sented", "b": [0.1428, 0.2613, 0.1966, 0.2827]}, {"w": "on", "b": [0.202, 0.2613, 0.2241, 0.2827]}, {"w": "the", "b": [0.2295, 0.2613, 0.2559, 0.2827]}, {"w": "left", "b": [0.2614, 0.2613, 0.288, 0.2827]}, {"w": "of", "b": [0.2935, 0.2613, 0.3103, 0.2827]}, {"w": "Figure", "b": [0.3157, 0.2613, 0.3697, 0.2827]}, {"w": "8-7,", "b": [0.3752, 0.2613, 0.4074, 0.2827]}, {"w": "along", "b": [0.4129, 0.2613, 0.4591, 0.2827]}, {"w": "with", "b": [0.4645, 0.2613, 0.5019, 0.2827]}, {"w": "three", "b": [0.5074, 0.2613, 0.5503, 0.2827]}, {"w": "different", "b": [0.5558, 0.2613, 0.6275, 0.2827]}, {"w": "axes", "b": [0.6329, 0.2613, 0.6684, 0.2827]}, {"w": "(i.e.,", "b": [0.6739, 0.2613, 0.7098, 0.2827]}, {"w": "one-dimensional", "b": [0.7153, 0.2613, 0.8571, 0.2827]}, {"w": "hyperplanes).", "b": [0.1429, 0.2803, 0.2558, 0.3017]}, {"w": "On", "b": [0.2623, 0.2803, 0.2892, 0.3017]}, {"w": "the", "b": [0.2957, 0.2803, 0.3221, 0.3017]}, {"w": "right", "b": [0.3286, 0.2803, 0.3687, 0.3017]}, {"w": "is", "b": [0.3752, 0.2803, 0.3884, 0.3017]}, {"w": "the", "b": [0.3949, 0.2803, 0.4213, 0.3017]}, {"w": "result", "b": [0.4278, 0.2803, 0.4747, 0.3017]}, {"w": "of", "b": [0.4812, 0.2803, 0.498, 0.3017]}, {"w": "the", "b": [0.5045, 0.2803, 0.5308, 0.3017]}, {"w": "projection", "b": [0.5373, 0.2803, 0.6236, 0.3017]}, {"w": "of", "b": [0.6301, 0.2803, 0.6469, 0.3017]}, {"w": "the", "b": [0.6534, 0.2803, 0.6797, 0.3017]}, {"w": "dataset", "b": [0.6862, 0.2803, 0.7443, 0.3017]}, {"w": "onto", "b": [0.7508, 0.2803, 0.7894, 0.3017]}, {"w": "each", "b": [0.7959, 0.2803, 0.8339, 0.3017]}, {"w": "of", "b": [0.8404, 0.2803, 0.8571, 0.3017]}, {"w": "these", "b": [0.1429, 0.2994, 0.1857, 0.3208]}, {"w": "axes.", "b": [0.1913, 0.2994, 0.2315, 0.3208]}, {"w": "As", "b": [0.2371, 0.2994, 0.2592, 0.3208]}, {"w": "you", "b": [0.2648, 0.2994, 0.296, 0.3208]}, {"w": "can", "b": [0.3016, 0.2994, 0.331, 0.3208]}, {"w": "see,", "b": [0.3366, 0.2994, 0.3667, 0.3208]}, {"w": "the", "b": [0.3723, 0.2994, 0.3987, 0.3208]}, {"w": "projection", "b": [0.4043, 0.2994, 0.4905, 0.3208]}, {"w": "onto", "b": [0.4961, 0.2994, 0.5347, 0.3208]}, {"w": "the", "b": [0.5403, 0.2994, 0.5666, 0.3208]}, {"w": "solid", "b": [0.5723, 0.2994, 0.6124, 0.3208]}, {"w": "line", "b": [0.618, 0.2994, 0.6491, 0.3208]}, {"w": "preserves", "b": [0.6547, 0.2994, 0.7332, 0.3208]}, {"w": "the", "b": [0.7388, 0.2994, 0.7651, 0.3208]}, {"w": "maximum", "b": [0.7707, 0.2994, 0.8571, 0.3208]}, {"w": "variance,", "b": [0.1429, 0.3184, 0.2179, 0.3398]}, {"w": "while", "b": [0.2239, 0.3184, 0.269, 0.3398]}, {"w": "the", "b": [0.275, 0.3184, 0.3014, 0.3398]}, {"w": "projection", "b": [0.3074, 0.3184, 0.3936, 0.3398]}, {"w": "onto", "b": [0.3996, 0.3184, 0.4382, 0.3398]}, {"w": "the", "b": [0.4443, 0.3184, 0.4706, 0.3398]}, {"w": "dotted", "b": [0.4766, 0.3184, 0.5308, 0.3398]}, {"w": "line", "b": [0.5368, 0.3184, 0.5679, 0.3398]}, {"w": "preserves", "b": [0.5739, 0.3184, 0.6524, 0.3398]}, {"w": "very", "b": [0.6584, 0.3184, 0.6948, 0.3398]}, {"w": "little", "b": [0.7008, 0.3184, 0.7385, 0.3398]}, {"w": "variance,", "b": [0.7445, 0.3184, 0.8196, 0.3398]}, {"w": "and", "b": [0.8256, 0.3184, 0.8571, 0.3398]}, {"w": "the", "b": [0.1429, 0.3375, 0.1692, 0.3589]}, {"w": "projection", "b": [0.1739, 0.3375, 0.2602, 0.3589]}, {"w": "onto", "b": [0.2649, 0.3375, 0.3035, 0.3589]}, {"w": "the", "b": [0.3082, 0.3375, 0.3346, 0.3589]}, {"w": "dashed", "b": [0.3393, 0.3375, 0.3981, 0.3589]}, {"w": "line", "b": [0.4028, 0.3375, 0.4339, 0.3589]}, {"w": "preserves", "b": [0.4386, 0.3375, 0.5171, 0.3589]}, {"w": "an", "b": [0.5218, 0.3375, 0.5424, 0.3589]}, {"w": "intermediate", "b": [0.5471, 0.3375, 0.6531, 0.3589]}, {"w": "amount", "b": [0.6578, 0.3375, 0.7231, 0.3589]}, {"w": "of", "b": [0.7278, 0.3375, 0.7446, 0.3589]}, {"w": "variance.", "b": [0.7493, 0.3375, 0.8244, 0.3589]}]}, {"id": "b_5", "type": "equation", "text": "Figure 8-7. Selecting the subspace onto which to project", "words": [{"w": "Figure", "b": [0.1429, 0.6336, 0.1943, 0.6552]}, {"w": "8-7.", "b": [0.1991, 0.6336, 0.2308, 0.6552]}, {"w": "Selecting", "b": [0.2356, 0.6336, 0.306, 0.6552]}, {"w": "the", "b": [0.3108, 0.6336, 0.3358, 0.6552]}, {"w": "subspace", "b": [0.3406, 0.6336, 0.4113, 0.6552]}, {"w": "onto", "b": [0.4161, 0.6336, 0.4522, 0.6552]}, {"w": "which", "b": [0.457, 0.6336, 0.5052, 0.6552]}, {"w": "to", "b": [0.5099, 0.6336, 0.5259, 0.6552]}, {"w": "project", "b": [0.5307, 0.6336, 0.5856, 0.6552]}]}, {"id": "b_6", "type": "paragraph", "text": "It seems reasonable to select the axis that preserves the maximum amount of var‐ iance, as it will most likely lose less information than the other projections. Another way to justify this choice is that it is the axis that minimizes the mean squared dis‐ tance between the original dataset and its projection onto that axis. This is the rather simple idea behind PCA.4", "words": [{"w": "It", "b": [0.1429, 0.671, 0.1555, 0.6924]}, {"w": "seems", "b": [0.1633, 0.671, 0.2134, 0.6924]}, {"w": "reasonable", "b": [0.2211, 0.671, 0.3104, 0.6924]}, {"w": "to", "b": [0.3182, 0.671, 0.3352, 0.6924]}, {"w": "select", "b": [0.3429, 0.671, 0.3887, 0.6924]}, {"w": "the", "b": [0.3965, 0.671, 0.4229, 0.6924]}, {"w": "axis", "b": [0.4306, 0.671, 0.4629, 0.6924]}, {"w": "that", "b": [0.4706, 0.671, 0.5032, 0.6924]}, {"w": "preserves", "b": [0.511, 0.671, 0.5895, 0.6924]}, {"w": "the", "b": [0.5973, 0.671, 0.6236, 0.6924]}, {"w": "maximum", "b": [0.6314, 0.671, 0.7178, 0.6924]}, {"w": "amount", "b": [0.7256, 0.671, 0.7908, 0.6924]}, {"w": "of", "b": [0.7986, 0.671, 0.8154, 0.6924]}, {"w": "var‐", "b": [0.8232, 0.671, 0.8572, 0.6924]}, {"w": "iance,", "b": [0.1429, 0.69, 0.1914, 0.7115]}, {"w": "as", "b": [0.1975, 0.69, 0.2143, 0.7115]}, {"w": "it", "b": [0.2203, 0.69, 0.2323, 0.7115]}, {"w": "will", "b": [0.2383, 0.69, 0.2687, 0.7115]}, {"w": "most", "b": [0.2748, 0.69, 0.3165, 0.7115]}, {"w": "likely", "b": [0.3225, 0.69, 0.3674, 0.7115]}, {"w": "lose", "b": [0.3735, 0.69, 0.4059, 0.7115]}, {"w": "less", "b": [0.4119, 0.69, 0.4413, 0.7115]}, {"w": "information", "b": [0.4474, 0.69, 0.5487, 0.7115]}, {"w": "than", "b": [0.5547, 0.69, 0.5928, 0.7115]}, {"w": "the", "b": [0.5988, 0.69, 0.6252, 0.7115]}, {"w": "other", "b": [0.6312, 0.69, 0.6759, 0.7115]}, {"w": "projections.", "b": [0.682, 0.69, 0.7806, 0.7115]}, {"w": "Another", "b": [0.7867, 0.69, 0.8571, 0.7115]}, {"w": "way", "b": [0.1429, 0.7091, 0.1755, 0.7305]}, {"w": "to", "b": [0.1822, 0.7091, 0.1992, 0.7305]}, {"w": "justify", "b": [0.2059, 0.7091, 0.258, 0.7305]}, {"w": "this", "b": [0.2647, 0.7091, 0.2955, 0.7305]}, {"w": "choice", "b": [0.3022, 0.7091, 0.356, 0.7305]}, {"w": "is", "b": [0.3628, 0.7091, 0.376, 0.7305]}, {"w": "that", "b": [0.3827, 0.7091, 0.4153, 0.7305]}, {"w": "it", "b": [0.4221, 0.7091, 0.434, 0.7305]}, {"w": "is", "b": [0.4408, 0.7091, 0.454, 0.7305]}, {"w": "the", "b": [0.4607, 0.7091, 0.4871, 0.7305]}, {"w": "axis", "b": [0.4938, 0.7091, 0.526, 0.7305]}, {"w": "that", "b": [0.5328, 0.7091, 0.5654, 0.7305]}, {"w": "minimizes", "b": [0.5721, 0.7091, 0.6596, 0.7305]}, {"w": "the", "b": [0.6664, 0.7091, 0.6927, 0.7305]}, {"w": "mean", "b": [0.6995, 0.7091, 0.7459, 0.7305]}, {"w": "squared", "b": [0.7527, 0.7091, 0.8187, 0.7305]}, {"w": "dis‐", "b": [0.8255, 0.7091, 0.8571, 0.7305]}, {"w": "tance", "b": [0.1428, 0.7281, 0.1874, 0.7495]}, {"w": "between", "b": [0.193, 0.7281, 0.2622, 0.7495]}, {"w": "the", "b": [0.2678, 0.7281, 0.2941, 0.7495]}, {"w": "original", "b": [0.2997, 0.7281, 0.3648, 0.7495]}, {"w": "dataset", "b": [0.3703, 0.7281, 0.4284, 0.7495]}, {"w": "and", "b": [0.434, 0.7281, 0.4656, 0.7495]}, {"w": "its", "b": [0.4712, 0.7281, 0.4907, 0.7495]}, {"w": "projection", "b": [0.4963, 0.7281, 0.5826, 0.7495]}, {"w": "onto", "b": [0.5882, 0.7281, 0.6268, 0.7495]}, {"w": "that", "b": [0.6323, 0.7281, 0.6649, 0.7495]}, {"w": "axis.", "b": [0.6705, 0.7281, 0.7075, 0.7495]}, {"w": "This", "b": [0.7131, 0.7281, 0.7503, 0.7495]}, {"w": "is", "b": [0.7559, 0.7281, 0.7691, 0.7495]}, {"w": "the", "b": [0.7747, 0.7281, 0.801, 0.7495]}, {"w": "rather", "b": [0.8066, 0.7281, 0.8571, 0.7495]}, {"w": "simple", "b": [0.1429, 0.7472, 0.1978, 0.7686]}, {"w": "idea", "b": [0.2025, 0.7472, 0.2371, 0.7686]}, {"w": "behind", "b": [0.2418, 0.7472, 0.3004, 0.7686]}, {"w": "PCA.4", "b": [0.3051, 0.7472, 0.3555, 0.7686]}]}, {"id": "b_7", "type": "paragraph", "text": "222 | Chapter 8: Dimensionality Reduction", "words": [{"w": "222", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "8:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Dimensionality", "b": [0.2673, 0.9225, 0.3562, 0.9388]}, {"w": "Reduction", "b": [0.359, 0.9225, 0.4186, 0.9388]}]}]}, {"page": 249, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Principal Components", "words": [{"w": "Principal", "b": [0.1429, 0.0763, 0.2333, 0.1049]}, {"w": "Components", "b": [0.2383, 0.0763, 0.3678, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "PCA identifies the axis that accounts for the largest amount of variance in the train‐ ing set. In Figure 8-7, it is the solid line. It also finds a second axis, orthogonal to the first one, that accounts for the largest amount of remaining variance. In this 2D example there is no choice: it is the dotted line. If it were a higher-dimensional data‐ set, PCA would also find a third axis, orthogonal to both previous axes, and a fourth, a fifth, and so on—as many axes as the number of dimensions in the dataset.", "words": [{"w": "PCA", "b": [0.1429, 0.1108, 0.1828, 0.1322]}, {"w": "identifies", "b": [0.1889, 0.1108, 0.2655, 0.1322]}, {"w": "the", "b": [0.2715, 0.1108, 0.2978, 0.1322]}, {"w": "axis", "b": [0.3038, 0.1108, 0.3361, 0.1322]}, {"w": "that", "b": [0.3421, 0.1108, 0.3746, 0.1322]}, {"w": "accounts", "b": [0.3807, 0.1108, 0.4541, 0.1322]}, {"w": "for", "b": [0.4601, 0.1108, 0.4847, 0.1322]}, {"w": "the", "b": [0.4907, 0.1108, 0.517, 0.1322]}, {"w": "largest", "b": [0.523, 0.1108, 0.5778, 0.1322]}, {"w": "amount", "b": [0.5838, 0.1108, 0.649, 0.1322]}, {"w": "of", "b": [0.655, 0.1108, 0.6718, 0.1322]}, {"w": "variance", "b": [0.6779, 0.1108, 0.7482, 0.1322]}, {"w": "in", "b": [0.7542, 0.1108, 0.7712, 0.1322]}, {"w": "the", "b": [0.7772, 0.1108, 0.8035, 0.1322]}, {"w": "train‐", "b": [0.8095, 0.1108, 0.8571, 0.1322]}, {"w": "ing", "b": [0.1429, 0.1298, 0.1696, 0.1512]}, {"w": "set.", "b": [0.1752, 0.1298, 0.2028, 0.1512]}, {"w": "In", "b": [0.2083, 0.1298, 0.2268, 0.1512]}, {"w": "Figure", "b": [0.2324, 0.1298, 0.2864, 0.1512]}, {"w": "8-7,", "b": [0.292, 0.1298, 0.3241, 0.1512]}, {"w": "it", "b": [0.3297, 0.1298, 0.3417, 0.1512]}, {"w": "is", "b": [0.3472, 0.1298, 0.3605, 0.1512]}, {"w": "the", "b": [0.366, 0.1298, 0.3924, 0.1512]}, {"w": "solid", "b": [0.3979, 0.1298, 0.4381, 0.1512]}, {"w": "line.", "b": [0.4436, 0.1298, 0.4795, 0.1512]}, {"w": "It", "b": [0.485, 0.1298, 0.4977, 0.1512]}, {"w": "also", "b": [0.5033, 0.1298, 0.536, 0.1512]}, {"w": "finds", "b": [0.5415, 0.1298, 0.5833, 0.1512]}, {"w": "a", "b": [0.5889, 0.1298, 0.598, 0.1512]}, {"w": "second", "b": [0.6036, 0.1298, 0.6619, 0.1512]}, {"w": "axis,", "b": [0.6675, 0.1298, 0.7045, 0.1512]}, {"w": "orthogonal", "b": [0.71, 0.1298, 0.8027, 0.1512]}, {"w": "to", "b": [0.8083, 0.1298, 0.8252, 0.1512]}, {"w": "the", "b": [0.8308, 0.1298, 0.8571, 0.1512]}, {"w": "first", "b": [0.1428, 0.1489, 0.1763, 0.1703]}, {"w": "one,", "b": [0.1852, 0.1489, 0.2208, 0.1703]}, {"w": "that", "b": [0.2297, 0.1489, 0.2623, 0.1703]}, {"w": "accounts", "b": [0.2712, 0.1489, 0.3446, 0.1703]}, {"w": "for", "b": [0.3535, 0.1489, 0.378, 0.1703]}, {"w": "the", "b": [0.3869, 0.1489, 0.4132, 0.1703]}, {"w": "largest", "b": [0.4221, 0.1489, 0.4769, 0.1703]}, {"w": "amount", "b": [0.4857, 0.1489, 0.551, 0.1703]}, {"w": "of", "b": [0.5599, 0.1489, 0.5767, 0.1703]}, {"w": "remaining", "b": [0.5855, 0.1489, 0.672, 0.1703]}, {"w": "variance.", "b": [0.6809, 0.1489, 0.756, 0.1703]}, {"w": "In", "b": [0.7649, 0.1489, 0.7834, 0.1703]}, {"w": "this", "b": [0.7922, 0.1489, 0.8229, 0.1703]}, {"w": "2D", "b": [0.8318, 0.1489, 0.8571, 0.1703]}, {"w": "example", "b": [0.1429, 0.1679, 0.2124, 0.1893]}, {"w": "there", "b": [0.2181, 0.1679, 0.261, 0.1893]}, {"w": "is", "b": [0.2667, 0.1679, 0.2799, 0.1893]}, {"w": "no", "b": [0.2856, 0.1679, 0.3076, 0.1893]}, {"w": "choice:", "b": [0.3133, 0.1679, 0.3718, 0.1893]}, {"w": "it", "b": [0.3775, 0.1679, 0.3894, 0.1893]}, {"w": "is", "b": [0.3951, 0.1679, 0.4083, 0.1893]}, {"w": "the", "b": [0.414, 0.1679, 0.4403, 0.1893]}, {"w": "dotted", "b": [0.446, 0.1679, 0.5002, 0.1893]}, {"w": "line.", "b": [0.5059, 0.1679, 0.5417, 0.1893]}, {"w": "If", "b": [0.5474, 0.1679, 0.5607, 0.1893]}, {"w": "it", "b": [0.5664, 0.1679, 0.5783, 0.1893]}, {"w": "were", "b": [0.584, 0.1679, 0.6237, 0.1893]}, {"w": "a", "b": [0.6293, 0.1679, 0.6385, 0.1893]}, {"w": "higher-dimensional", "b": [0.6442, 0.1679, 0.8088, 0.1893]}, {"w": "data‐", "b": [0.8145, 0.1679, 0.8572, 0.1893]}, {"w": "set,", "b": [0.1429, 0.187, 0.1705, 0.2084]}, {"w": "PCA", "b": [0.1758, 0.187, 0.2158, 0.2084]}, {"w": "would", "b": [0.2212, 0.187, 0.2734, 0.2084]}, {"w": "also", "b": [0.2788, 0.187, 0.3115, 0.2084]}, {"w": "find", "b": [0.3169, 0.187, 0.351, 0.2084]}, {"w": "a", "b": [0.3564, 0.187, 0.3655, 0.2084]}, {"w": "third", "b": [0.3709, 0.187, 0.4127, 0.2084]}, {"w": "axis,", "b": [0.4181, 0.187, 0.455, 0.2084]}, {"w": "orthogonal", "b": [0.4604, 0.187, 0.5531, 0.2084]}, {"w": "to", "b": [0.5584, 0.187, 0.5754, 0.2084]}, {"w": "both", "b": [0.5808, 0.187, 0.6195, 0.2084]}, {"w": "previous", "b": [0.6248, 0.187, 0.6969, 0.2084]}, {"w": "axes,", "b": [0.7023, 0.187, 0.7425, 0.2084]}, {"w": "and", "b": [0.7479, 0.187, 0.7794, 0.2084]}, {"w": "a", "b": [0.7848, 0.187, 0.794, 0.2084]}, {"w": "fourth,", "b": [0.7993, 0.187, 0.8571, 0.2084]}, {"w": "a", "b": [0.1429, 0.206, 0.152, 0.2274]}, {"w": "fifth,", "b": [0.1567, 0.206, 0.1969, 0.2274]}, {"w": "and", "b": [0.2016, 0.206, 0.2331, 0.2274]}, {"w": "so", "b": [0.2379, 0.206, 0.2561, 0.2274]}, {"w": "on—as", "b": [0.2609, 0.206, 0.3189, 0.2274]}, {"w": "many", "b": [0.3236, 0.206, 0.3703, 0.2274]}, {"w": "axes", "b": [0.375, 0.206, 0.4105, 0.2274]}, {"w": "as", "b": [0.4152, 0.206, 0.432, 0.2274]}, {"w": "the", "b": [0.4368, 0.206, 0.4631, 0.2274]}, {"w": "number", "b": [0.4678, 0.206, 0.5341, 0.2274]}, {"w": "of", "b": [0.5389, 0.206, 0.5556, 0.2274]}, {"w": "dimensions", "b": [0.5604, 0.206, 0.6572, 0.2274]}, {"w": "in", "b": [0.6619, 0.206, 0.6789, 0.2274]}, {"w": "the", "b": [0.6836, 0.206, 0.7099, 0.2274]}, {"w": "dataset.", "b": [0.7147, 0.206, 0.7775, 0.2274]}]}, {"id": "b_2", "type": "paragraph", "text": "The unit vector that defines the ith axis is called the ith principal component (PC). In Figure 8-7, the 1st PC is c1 and the 2nd PC is c2. In Figure 8-2 the first two PCs are represented by the orthogonal arrows in the plane, and the third PC would be orthogonal to the plane (pointing up or down).", "words": [{"w": "The", "b": [0.1429, 0.2341, 0.1757, 0.2555]}, {"w": "unit", "b": [0.1823, 0.2341, 0.2167, 0.2555]}, {"w": "vector", "b": [0.2233, 0.2341, 0.2753, 0.2555]}, {"w": "that", "b": [0.2819, 0.2341, 0.3145, 0.2555]}, {"w": "defines", "b": [0.3211, 0.2341, 0.3806, 0.2555]}, {"w": "the", "b": [0.3872, 0.2341, 0.4135, 0.2555]}, {"w": "ith", "b": [0.4201, 0.2341, 0.4362, 0.2555]}, {"w": "axis", "b": [0.4428, 0.2341, 0.475, 0.2555]}, {"w": "is", "b": [0.4816, 0.2341, 0.4948, 0.2555]}, {"w": "called", "b": [0.5014, 0.2341, 0.5498, 0.2555]}, {"w": "the", "b": [0.5564, 0.2341, 0.5827, 0.2555]}, {"w": "ith", "b": [0.5893, 0.2341, 0.6054, 0.2555]}, {"w": "principal", "b": [0.612, 0.2339, 0.6847, 0.2555]}, {"w": "component", "b": [0.6913, 0.2339, 0.7807, 0.2555]}, {"w": "(PC).", "b": [0.7873, 0.2341, 0.832, 0.2555]}, {"w": "In", "b": [0.8386, 0.2341, 0.8571, 0.2555]}, {"w": "Figure", "b": [0.1429, 0.2532, 0.1969, 0.2746]}, {"w": "8-7,", "b": [0.2039, 0.2532, 0.236, 0.2746]}, {"w": "the", "b": [0.243, 0.2532, 0.2693, 0.2746]}, {"w": "1st", "b": [0.2763, 0.2532, 0.2947, 0.2746]}, {"w": "PC", "b": [0.3017, 0.2532, 0.3273, 0.2746]}, {"w": "is", "b": [0.3343, 0.2532, 0.3475, 0.2746]}, {"w": "c1", "b": [0.3545, 0.2526, 0.3695, 0.2755]}, {"w": "and", "b": [0.3765, 0.2532, 0.408, 0.2746]}, {"w": "the", "b": [0.415, 0.2532, 0.4414, 0.2746]}, {"w": "2nd", "b": [0.4483, 0.2532, 0.4718, 0.2746]}, {"w": "PC", "b": [0.4788, 0.2532, 0.5043, 0.2746]}, {"w": "is", "b": [0.5113, 0.2532, 0.5246, 0.2746]}, {"w": "c2.", "b": [0.5315, 0.2526, 0.5513, 0.2755]}, {"w": "In", "b": [0.5583, 0.2532, 0.5768, 0.2746]}, {"w": "Figure", "b": [0.5838, 0.2532, 0.6378, 0.2746]}, {"w": "8-2", "b": [0.6448, 0.2532, 0.6722, 0.2746]}, {"w": "the", "b": [0.6792, 0.2532, 0.7055, 0.2746]}, {"w": "first", "b": [0.7125, 0.2532, 0.746, 0.2746]}, {"w": "two", "b": [0.753, 0.2532, 0.7842, 0.2746]}, {"w": "PCs", "b": [0.7912, 0.2532, 0.8244, 0.2746]}, {"w": "are", "b": [0.8314, 0.2532, 0.8571, 0.2746]}, {"w": "represented", "b": [0.1428, 0.2722, 0.2406, 0.2936]}, {"w": "by", "b": [0.2506, 0.2722, 0.2708, 0.2936]}, {"w": "the", "b": [0.2807, 0.2722, 0.3071, 0.2936]}, {"w": "orthogonal", "b": [0.317, 0.2722, 0.4097, 0.2936]}, {"w": "arrows", "b": [0.4197, 0.2722, 0.4768, 0.2936]}, {"w": "in", "b": [0.4868, 0.2722, 0.5038, 0.2936]}, {"w": "the", "b": [0.5137, 0.2722, 0.5401, 0.2936]}, {"w": "plane,", "b": [0.55, 0.2722, 0.6004, 0.2936]}, {"w": "and", "b": [0.6103, 0.2722, 0.6419, 0.2936]}, {"w": "the", "b": [0.6519, 0.2722, 0.6782, 0.2936]}, {"w": "third", "b": [0.6882, 0.2722, 0.73, 0.2936]}, {"w": "PC", "b": [0.7399, 0.2722, 0.7655, 0.2936]}, {"w": "would", "b": [0.7755, 0.2722, 0.8277, 0.2936]}, {"w": "be", "b": [0.8377, 0.2722, 0.8571, 0.2936]}, {"w": "orthogonal", "b": [0.1429, 0.2913, 0.2355, 0.3127]}, {"w": "to", "b": [0.2402, 0.2913, 0.2572, 0.3127]}, {"w": "the", "b": [0.2619, 0.2913, 0.2883, 0.3127]}, {"w": "plane", "b": [0.293, 0.2913, 0.3386, 0.3127]}, {"w": "(pointing", "b": [0.3433, 0.2913, 0.4217, 0.3127]}, {"w": "up", "b": [0.4265, 0.2913, 0.4484, 0.3127]}, {"w": "or", "b": [0.4532, 0.2913, 0.4715, 0.3127]}, {"w": "down).", "b": [0.4763, 0.2913, 0.5355, 0.3127]}]}, {"id": "b_3", "type": "paragraph", "text": "The direction of the principal components is not stable: if you per‐ turb the training set slightly and run PCA again, some of the new PCs may point in the opposite direction of the original PCs. How‐ ever, they will generally still lie on the same axes. In some cases, a pair of PCs may even rotate or swap, but the plane they define will generally remain the same.", "words": [{"w": "The", "b": [0.2714, 0.3332, 0.3014, 0.3528]}, {"w": "direction", "b": [0.3064, 0.3332, 0.3759, 0.3528]}, {"w": "of", "b": [0.3809, 0.3332, 0.3962, 0.3528]}, {"w": "the", "b": [0.4012, 0.3332, 0.4253, 0.3528]}, {"w": "principal", "b": [0.4303, 0.3332, 0.4992, 0.3528]}, {"w": "components", "b": [0.5042, 0.3332, 0.5983, 0.3528]}, {"w": "is", "b": [0.6033, 0.3332, 0.6154, 0.3528]}, {"w": "not", "b": [0.6204, 0.3332, 0.6464, 0.3528]}, {"w": "stable:", "b": [0.6514, 0.3332, 0.6995, 0.3528]}, {"w": "if", "b": [0.7045, 0.3332, 0.7152, 0.3528]}, {"w": "you", "b": [0.7202, 0.3332, 0.7488, 0.3528]}, {"w": "per‐", "b": [0.7538, 0.3332, 0.7857, 0.3528]}, {"w": "turb", "b": [0.2714, 0.3506, 0.3041, 0.3702]}, {"w": "the", "b": [0.31, 0.3506, 0.334, 0.3702]}, {"w": "training", "b": [0.3399, 0.3506, 0.4011, 0.3702]}, {"w": "set", "b": [0.407, 0.3506, 0.4279, 0.3702]}, {"w": "slightly", "b": [0.4338, 0.3506, 0.4888, 0.3702]}, {"w": "and", "b": [0.4947, 0.3506, 0.5235, 0.3702]}, {"w": "run", "b": [0.5294, 0.3506, 0.557, 0.3702]}, {"w": "PCA", "b": [0.5629, 0.3506, 0.5994, 0.3702]}, {"w": "again,", "b": [0.6053, 0.3506, 0.6508, 0.3702]}, {"w": "some", "b": [0.6567, 0.3506, 0.6971, 0.3702]}, {"w": "of", "b": [0.703, 0.3506, 0.7183, 0.3702]}, {"w": "the", "b": [0.7242, 0.3506, 0.7483, 0.3702]}, {"w": "new", "b": [0.7542, 0.3506, 0.7857, 0.3702]}, {"w": "PCs", "b": [0.2714, 0.3681, 0.3018, 0.3876]}, {"w": "may", "b": [0.3072, 0.3681, 0.3395, 0.3876]}, {"w": "point", "b": [0.3449, 0.3681, 0.3856, 0.3876]}, {"w": "in", "b": [0.391, 0.3681, 0.4065, 0.3876]}, {"w": "the", "b": [0.4119, 0.3681, 0.4359, 0.3876]}, {"w": "opposite", "b": [0.4413, 0.3681, 0.5067, 0.3876]}, {"w": "direction", "b": [0.5121, 0.3681, 0.5815, 0.3876]}, {"w": "of", "b": [0.5869, 0.3681, 0.6022, 0.3876]}, {"w": "the", "b": [0.6076, 0.3681, 0.6317, 0.3876]}, {"w": "original", "b": [0.6371, 0.3681, 0.6966, 0.3876]}, {"w": "PCs.", "b": [0.702, 0.3681, 0.7367, 0.3876]}, {"w": "How‐", "b": [0.7421, 0.3681, 0.7857, 0.3876]}, {"w": "ever,", "b": [0.2714, 0.3855, 0.3066, 0.405]}, {"w": "they", "b": [0.3124, 0.3855, 0.3452, 0.405]}, {"w": "will", "b": [0.351, 0.3855, 0.3788, 0.405]}, {"w": "generally", "b": [0.3846, 0.3855, 0.4539, 0.405]}, {"w": "still", "b": [0.4597, 0.3855, 0.4872, 0.405]}, {"w": "lie", "b": [0.493, 0.3855, 0.511, 0.405]}, {"w": "on", "b": [0.5168, 0.3855, 0.5369, 0.405]}, {"w": "the", "b": [0.5427, 0.3855, 0.5668, 0.405]}, {"w": "same", "b": [0.5725, 0.3855, 0.6116, 0.405]}, {"w": "axes.", "b": [0.6173, 0.3855, 0.6541, 0.405]}, {"w": "In", "b": [0.6599, 0.3855, 0.6768, 0.405]}, {"w": "some", "b": [0.6826, 0.3855, 0.723, 0.405]}, {"w": "cases,", "b": [0.7288, 0.3855, 0.7716, 0.405]}, {"w": "a", "b": [0.7774, 0.3855, 0.7857, 0.405]}, {"w": "pair", "b": [0.2714, 0.4029, 0.3019, 0.4225]}, {"w": "of", "b": [0.3071, 0.4029, 0.3225, 0.4225]}, {"w": "PCs", "b": [0.3277, 0.4029, 0.3581, 0.4225]}, {"w": "may", "b": [0.3633, 0.4029, 0.3957, 0.4225]}, {"w": "even", "b": [0.4009, 0.4029, 0.4363, 0.4225]}, {"w": "rotate", "b": [0.4415, 0.4029, 0.486, 0.4225]}, {"w": "or", "b": [0.4912, 0.4029, 0.508, 0.4225]}, {"w": "swap,", "b": [0.5132, 0.4029, 0.5551, 0.4225]}, {"w": "but", "b": [0.5603, 0.4029, 0.5859, 0.4225]}, {"w": "the", "b": [0.5911, 0.4029, 0.6152, 0.4225]}, {"w": "plane", "b": [0.6204, 0.4029, 0.6621, 0.4225]}, {"w": "they", "b": [0.6673, 0.4029, 0.7001, 0.4225]}, {"w": "define", "b": [0.7053, 0.4029, 0.7527, 0.4225]}, {"w": "will", "b": [0.7579, 0.4029, 0.7857, 0.4225]}, {"w": "generally", "b": [0.2714, 0.4203, 0.3408, 0.4399]}, {"w": "remain", "b": [0.3451, 0.4203, 0.3997, 0.4399]}, {"w": "the", "b": [0.404, 0.4203, 0.4281, 0.4399]}, {"w": "same.", "b": [0.4324, 0.4203, 0.4758, 0.4399]}]}, {"id": "b_4", "type": "paragraph", "text": "So how can you find the principal components of a training set? Luckily, there is a standard matrix factorization technique called Singular Value Decomposition (SVD) that can decompose the training set matrix X into the matrix multiplication of three matrices U Σ VT, where V contains all the principal components that we are looking for, as shown in Equation 8-1.", "words": [{"w": "So", "b": [0.1429, 0.4602, 0.1634, 0.4816]}, {"w": "how", "b": [0.1704, 0.4602, 0.2064, 0.4816]}, {"w": "can", "b": [0.2134, 0.4602, 0.2427, 0.4816]}, {"w": "you", "b": [0.2497, 0.4602, 0.281, 0.4816]}, {"w": "find", "b": [0.288, 0.4602, 0.3221, 0.4816]}, {"w": "the", "b": [0.3291, 0.4602, 0.3554, 0.4816]}, {"w": "principal", "b": [0.3624, 0.4602, 0.4378, 0.4816]}, {"w": "components", "b": [0.4448, 0.4602, 0.5477, 0.4816]}, {"w": "of", "b": [0.5547, 0.4602, 0.5714, 0.4816]}, {"w": "a", "b": [0.5784, 0.4602, 0.5876, 0.4816]}, {"w": "training", "b": [0.5946, 0.4602, 0.6615, 0.4816]}, {"w": "set?", "b": [0.6685, 0.4602, 0.6993, 0.4816]}, {"w": "Luckily,", "b": [0.7062, 0.4602, 0.7709, 0.4816]}, {"w": "there", "b": [0.7779, 0.4602, 0.8208, 0.4816]}, {"w": "is", "b": [0.8278, 0.4602, 0.841, 0.4816]}, {"w": "a", "b": [0.848, 0.4602, 0.8571, 0.4816]}, {"w": "standard", "b": [0.1429, 0.4792, 0.2163, 0.5006]}, {"w": "matrix", "b": [0.2236, 0.4792, 0.2789, 0.5006]}, {"w": "factorization", "b": [0.2863, 0.4792, 0.3922, 0.5006]}, {"w": "technique", "b": [0.3995, 0.4792, 0.4822, 0.5006]}, {"w": "called", "b": [0.4895, 0.4792, 0.5379, 0.5006]}, {"w": "Singular", "b": [0.5452, 0.479, 0.6134, 0.5006]}, {"w": "Value", "b": [0.6208, 0.479, 0.6672, 0.5006]}, {"w": "Decomposition", "b": [0.6746, 0.479, 0.7955, 0.5006]}, {"w": "(SVD)", "b": [0.8029, 0.4792, 0.8571, 0.5006]}, {"w": "that", "b": [0.1429, 0.4983, 0.1755, 0.5197]}, {"w": "can", "b": [0.1816, 0.4983, 0.2109, 0.5197]}, {"w": "decompose", "b": [0.217, 0.4983, 0.311, 0.5197]}, {"w": "the", "b": [0.3171, 0.4983, 0.3434, 0.5197]}, {"w": "training", "b": [0.3495, 0.4983, 0.4165, 0.5197]}, {"w": "set", "b": [0.4226, 0.4983, 0.4454, 0.5197]}, {"w": "matrix", "b": [0.4515, 0.4983, 0.5069, 0.5197]}, {"w": "X", "b": [0.513, 0.4977, 0.5274, 0.5197]}, {"w": "into", "b": [0.5335, 0.4983, 0.5671, 0.5197]}, {"w": "the", "b": [0.5732, 0.4983, 0.5995, 0.5197]}, {"w": "matrix", "b": [0.6056, 0.4983, 0.6609, 0.5197]}, {"w": "multiplication", "b": [0.667, 0.4983, 0.7852, 0.5197]}, {"w": "of", "b": [0.7913, 0.4983, 0.8081, 0.5197]}, {"w": "three", "b": [0.8142, 0.4983, 0.8572, 0.5197]}, {"w": "matrices", "b": [0.1429, 0.5173, 0.2137, 0.5387]}, {"w": "U", "b": [0.2196, 0.5168, 0.2348, 0.5387]}, {"w": "Σ", "b": [0.2407, 0.5173, 0.2532, 0.5387]}, {"w": "VT,", "b": [0.2591, 0.5168, 0.2862, 0.5387]}, {"w": "where", "b": [0.2922, 0.5173, 0.343, 0.5387]}, {"w": "V", "b": [0.349, 0.5168, 0.3638, 0.5387]}, {"w": "contains", "b": [0.3697, 0.5173, 0.4403, 0.5387]}, {"w": "all", "b": [0.4462, 0.5173, 0.4659, 0.5387]}, {"w": "the", "b": [0.4719, 0.5173, 0.4982, 0.5387]}, {"w": "principal", "b": [0.5041, 0.5173, 0.5795, 0.5387]}, {"w": "components", "b": [0.5854, 0.5173, 0.6883, 0.5387]}, {"w": "that", "b": [0.6943, 0.5173, 0.7269, 0.5387]}, {"w": "we", "b": [0.7328, 0.5173, 0.7559, 0.5387]}, {"w": "are", "b": [0.7619, 0.5173, 0.7876, 0.5387]}, {"w": "looking", "b": [0.7936, 0.5173, 0.8571, 0.5387]}, {"w": "for,", "b": [0.1429, 0.5364, 0.1708, 0.5578]}, {"w": "as", "b": [0.1755, 0.5364, 0.1923, 0.5578]}, {"w": "shown", "b": [0.1971, 0.5364, 0.2521, 0.5578]}, {"w": "in", "b": [0.2569, 0.5364, 0.2738, 0.5578]}, {"w": "Equation", "b": [0.2786, 0.5364, 0.3548, 0.5578]}, {"w": "8-1.", "b": [0.3595, 0.5364, 0.3917, 0.5578]}]}, {"id": "b_5", "type": "equation", "text": "Equation 8-1. Principal components matrix", "words": [{"w": "Equation", "b": [0.1726, 0.5759, 0.2473, 0.5975]}, {"w": "8-1.", "b": [0.2521, 0.5759, 0.2838, 0.5975]}, {"w": "Principal", "b": [0.2886, 0.5759, 0.3629, 0.5975]}, {"w": "components", "b": [0.3676, 0.5759, 0.464, 0.5975]}, {"w": "matrix", "b": [0.4688, 0.5759, 0.5244, 0.5975]}]}, {"id": "b_6", "type": "equation", "text": "V =", "words": [{"w": "V", "b": [0.1726, 0.6278, 0.1867, 0.6487]}, {"w": "=", "b": [0.1922, 0.6283, 0.2037, 0.6487]}]}, {"id": "b_7", "type": "paragraph", "text": "∣ ∣ ∣ c1 c2 ⋯cn", "words": [{"w": "∣", "b": [0.2212, 0.6078, 0.2273, 0.6229]}, {"w": "∣", "b": [0.2462, 0.6078, 0.2523, 0.6229]}, {"w": "∣", "b": [0.3003, 0.6078, 0.3064, 0.6229]}, {"w": "c1", "b": [0.2161, 0.6259, 0.2324, 0.6511]}, {"w": "c2", "b": [0.2411, 0.6259, 0.2574, 0.6511]}, {"w": "⋯cn", "b": [0.2661, 0.6259, 0.312, 0.6511]}]}, {"id": "b_8", "type": "paragraph", "text": "∣ ∣ ∣", "words": [{"w": "∣", "b": [0.2212, 0.6567, 0.2273, 0.6718]}, {"w": "∣", "b": [0.2462, 0.6567, 0.2523, 0.6718]}, {"w": "∣", "b": [0.3003, 0.6567, 0.3064, 0.6718]}]}, {"id": "b_9", "type": "paragraph", "text": "The following Python code uses NumPy’s svd() function to obtain all the principal components of the training set, then extracts the first two PCs:", "words": [{"w": "The", "b": [0.1429, 0.6928, 0.1757, 0.7142]}, {"w": "following", "b": [0.1823, 0.6928, 0.2613, 0.7142]}, {"w": "Python", "b": [0.268, 0.6928, 0.3287, 0.7142]}, {"w": "code", "b": [0.3354, 0.6928, 0.3747, 0.7142]}, {"w": "uses", "b": [0.3813, 0.6928, 0.4165, 0.7142]}, {"w": "NumPy’s", "b": [0.4232, 0.6928, 0.4977, 0.7142]}, {"w": "svd()", "b": [0.5043, 0.696, 0.5538, 0.7111]}, {"w": "function", "b": [0.5605, 0.6928, 0.6319, 0.7142]}, {"w": "to", "b": [0.6385, 0.6928, 0.6555, 0.7142]}, {"w": "obtain", "b": [0.6621, 0.6928, 0.7158, 0.7142]}, {"w": "all", "b": [0.7225, 0.6928, 0.7422, 0.7142]}, {"w": "the", "b": [0.7488, 0.6928, 0.7751, 0.7142]}, {"w": "principal", "b": [0.7818, 0.6928, 0.8572, 0.7142]}, {"w": "components", "b": [0.1429, 0.7119, 0.2458, 0.7333]}, {"w": "of", "b": [0.2505, 0.7119, 0.2673, 0.7333]}, {"w": "the", "b": [0.272, 0.7119, 0.2983, 0.7333]}, {"w": "training", "b": [0.3031, 0.7119, 0.37, 0.7333]}, {"w": "set,", "b": [0.3747, 0.7119, 0.4023, 0.7333]}, {"w": "then", "b": [0.4071, 0.7119, 0.4448, 0.7333]}, {"w": "extracts", "b": [0.4495, 0.7119, 0.5143, 0.7333]}, {"w": "the", "b": [0.519, 0.7119, 0.5453, 0.7333]}, {"w": "first", "b": [0.55, 0.7119, 0.5835, 0.7333]}, {"w": "two", "b": [0.5883, 0.7119, 0.6195, 0.7333]}, {"w": "PCs:", "b": [0.6242, 0.7119, 0.6622, 0.7333]}]}, {"id": "b_10", "type": "paragraph", "text": "X_centered = X - X.mean(axis=0) U, s, Vt = np.linalg.svd(X_centered) c1 = Vt.T[:, 0] c2 = Vt.T[:, 1]", "words": [{"w": "X_centered", "b": [0.1766, 0.7438, 0.2609, 0.7567]}, {"w": "=", "b": [0.2693, 0.7438, 0.2778, 0.7567]}, {"w": "X", "b": [0.2862, 0.7438, 0.2946, 0.7567]}, {"w": "-", "b": [0.3031, 0.7438, 0.3115, 0.7567]}, {"w": "X.mean(axis=0)", "b": [0.3199, 0.7438, 0.438, 0.7567]}, {"w": "U,", "b": [0.1766, 0.7593, 0.1934, 0.7721]}, {"w": "s,", "b": [0.2019, 0.7593, 0.2187, 0.7721]}, {"w": "Vt", "b": [0.2272, 0.7593, 0.244, 0.7721]}, {"w": "=", "b": [0.2525, 0.7593, 0.2609, 0.7721]}, {"w": "np.linalg.svd(X_centered)", "b": [0.2693, 0.7593, 0.4802, 0.7721]}, {"w": "c1", "b": [0.1766, 0.7747, 0.1934, 0.7875]}, {"w": "=", "b": [0.2019, 0.7747, 0.2103, 0.7875]}, {"w": "Vt.T[:,", "b": [0.2187, 0.7747, 0.2778, 0.7875]}, {"w": "0]", "b": [0.2862, 0.7747, 0.3031, 0.7875]}, {"w": "c2", "b": [0.1766, 0.7901, 0.1934, 0.803]}, {"w": "=", "b": [0.2019, 0.7901, 0.2103, 0.803]}, {"w": "Vt.T[:,", "b": [0.2187, 0.7901, 0.2778, 0.803]}, {"w": "1]", "b": [0.2862, 0.7901, 0.3031, 0.803]}]}, {"id": "b_11", "type": "paragraph", "text": "PCA | 223", "words": [{"w": "PCA", "b": [0.7732, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "223", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 250, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "PCA assumes that the dataset is centered around the origin. As we will see, Scikit-Learn’s PCA classes take care of centering the data for you. However, if you implement PCA yourself (as in the pre‐ ceding example), or if you use other libraries, don’t forget to center the data first.", "words": [{"w": "PCA", "b": [0.2714, 0.0793, 0.308, 0.0989]}, {"w": "assumes", "b": [0.3133, 0.0793, 0.3764, 0.0989]}, {"w": "that", "b": [0.3817, 0.0793, 0.4115, 0.0989]}, {"w": "the", "b": [0.4168, 0.0793, 0.4409, 0.0989]}, {"w": "dataset", "b": [0.4462, 0.0793, 0.4993, 0.0989]}, {"w": "is", "b": [0.5046, 0.0793, 0.5167, 0.0989]}, {"w": "centered", "b": [0.5221, 0.0793, 0.5874, 0.0989]}, {"w": "around", "b": [0.5927, 0.0793, 0.6484, 0.0989]}, {"w": "the", "b": [0.6537, 0.0793, 0.6778, 0.0989]}, {"w": "origin.", "b": [0.6831, 0.0793, 0.7338, 0.0989]}, {"w": "As", "b": [0.7391, 0.0793, 0.7593, 0.0989]}, {"w": "we", "b": [0.7646, 0.0793, 0.7857, 0.0989]}, {"w": "will", "b": [0.2714, 0.0967, 0.2992, 0.1163]}, {"w": "see,", "b": [0.3056, 0.0967, 0.3331, 0.1163]}, {"w": "Scikit-Learn’s", "b": [0.3396, 0.0967, 0.4409, 0.1163]}, {"w": "PCA", "b": [0.4474, 0.0967, 0.4839, 0.1163]}, {"w": "classes", "b": [0.4903, 0.0967, 0.5406, 0.1163]}, {"w": "take", "b": [0.5471, 0.0967, 0.5788, 0.1163]}, {"w": "care", "b": [0.5852, 0.0967, 0.6168, 0.1163]}, {"w": "of", "b": [0.6232, 0.0967, 0.6385, 0.1163]}, {"w": "centering", "b": [0.645, 0.0967, 0.7166, 0.1163]}, {"w": "the", "b": [0.723, 0.0967, 0.7471, 0.1163]}, {"w": "data", "b": [0.7535, 0.0967, 0.7857, 0.1163]}, {"w": "for", "b": [0.2714, 0.1141, 0.2938, 0.1337]}, {"w": "you.", "b": [0.3005, 0.1141, 0.3334, 0.1337]}, {"w": "However,", "b": [0.3401, 0.1141, 0.4122, 0.1337]}, {"w": "if", "b": [0.4189, 0.1141, 0.4296, 0.1337]}, {"w": "you", "b": [0.4363, 0.1141, 0.4649, 0.1337]}, {"w": "implement", "b": [0.4716, 0.1141, 0.5544, 0.1337]}, {"w": "PCA", "b": [0.5611, 0.1141, 0.5976, 0.1337]}, {"w": "yourself", "b": [0.6043, 0.1141, 0.6655, 0.1337]}, {"w": "(as", "b": [0.6722, 0.1141, 0.6941, 0.1337]}, {"w": "in", "b": [0.7008, 0.1141, 0.7163, 0.1337]}, {"w": "the", "b": [0.723, 0.1141, 0.7471, 0.1337]}, {"w": "pre‐", "b": [0.7538, 0.1141, 0.7857, 0.1337]}, {"w": "ceding", "b": [0.2714, 0.1315, 0.3221, 0.1511]}, {"w": "example),", "b": [0.327, 0.1315, 0.4015, 0.1511]}, {"w": "or", "b": [0.4065, 0.1315, 0.4232, 0.1511]}, {"w": "if", "b": [0.4282, 0.1315, 0.4389, 0.1511]}, {"w": "you", "b": [0.4439, 0.1315, 0.4724, 0.1511]}, {"w": "use", "b": [0.4774, 0.1315, 0.5026, 0.1511]}, {"w": "other", "b": [0.5075, 0.1315, 0.5484, 0.1511]}, {"w": "libraries,", "b": [0.5533, 0.1315, 0.62, 0.1511]}, {"w": "don’t", "b": [0.6249, 0.1315, 0.6629, 0.1511]}, {"w": "forget", "b": [0.6679, 0.1315, 0.7131, 0.1511]}, {"w": "to", "b": [0.7181, 0.1315, 0.7336, 0.1511]}, {"w": "center", "b": [0.7385, 0.1315, 0.7857, 0.1511]}, {"w": "the", "b": [0.2714, 0.1489, 0.2955, 0.1685]}, {"w": "data", "b": [0.2998, 0.1489, 0.332, 0.1685]}, {"w": "first.", "b": [0.3364, 0.1489, 0.3713, 0.1685]}]}, {"id": "b_1", "type": "paragraph", "text": "Projecting Down to d Dimensions", "words": [{"w": "Projecting", "b": [0.1429, 0.1861, 0.2486, 0.2146]}, {"w": "Down", "b": [0.2535, 0.1861, 0.3132, 0.2146]}, {"w": "to", "b": [0.3182, 0.1861, 0.34, 0.2146]}, {"w": "d", "b": [0.3449, 0.1861, 0.3576, 0.2146]}, {"w": "Dimensions", "b": [0.3626, 0.1861, 0.4821, 0.2146]}]}, {"id": "b_2", "type": "paragraph", "text": "Once you have identified all the principal components, you can reduce the dimen‐ sionality of the dataset down to d dimensions by projecting it onto the hyperplane defined by the first d principal components. Selecting this hyperplane ensures that the projection will preserve as much variance as possible. For example, in Figure 8-2 the 3D dataset is projected down to the 2D plane defined by the first two principal com‐ ponents, preserving a large part of the dataset’s variance. As a result, the 2D projec‐ tion looks very much like the original 3D dataset.", "words": [{"w": "Once", "b": [0.1429, 0.2205, 0.1875, 0.2419]}, {"w": "you", "b": [0.1947, 0.2205, 0.2259, 0.2419]}, {"w": "have", "b": [0.2331, 0.2205, 0.2715, 0.2419]}, {"w": "identified", "b": [0.2787, 0.2205, 0.3587, 0.2419]}, {"w": "all", "b": [0.3659, 0.2205, 0.3856, 0.2419]}, {"w": "the", "b": [0.3928, 0.2205, 0.4191, 0.2419]}, {"w": "principal", "b": [0.4264, 0.2205, 0.5017, 0.2419]}, {"w": "components,", "b": [0.5089, 0.2205, 0.6166, 0.2419]}, {"w": "you", "b": [0.6238, 0.2205, 0.655, 0.2419]}, {"w": "can", "b": [0.6622, 0.2205, 0.6916, 0.2419]}, {"w": "reduce", "b": [0.6988, 0.2205, 0.7551, 0.2419]}, {"w": "the", "b": [0.7623, 0.2205, 0.7886, 0.2419]}, {"w": "dimen‐", "b": [0.7958, 0.2205, 0.8571, 0.2419]}, {"w": "sionality", "b": [0.1428, 0.2396, 0.214, 0.261]}, {"w": "of", "b": [0.2213, 0.2396, 0.2381, 0.261]}, {"w": "the", "b": [0.2454, 0.2396, 0.2717, 0.261]}, {"w": "dataset", "b": [0.279, 0.2396, 0.3371, 0.261]}, {"w": "down", "b": [0.3443, 0.2396, 0.3916, 0.261]}, {"w": "to", "b": [0.3989, 0.2396, 0.4159, 0.261]}, {"w": "d", "b": [0.4232, 0.2394, 0.4337, 0.261]}, {"w": "dimensions", "b": [0.441, 0.2396, 0.5378, 0.261]}, {"w": "by", "b": [0.5451, 0.2396, 0.5652, 0.261]}, {"w": "projecting", "b": [0.5725, 0.2396, 0.6579, 0.261]}, {"w": "it", "b": [0.6651, 0.2396, 0.6771, 0.261]}, {"w": "onto", "b": [0.6844, 0.2396, 0.723, 0.261]}, {"w": "the", "b": [0.7302, 0.2396, 0.7566, 0.261]}, {"w": "hyperplane", "b": [0.7638, 0.2396, 0.8571, 0.261]}, {"w": "defined", "b": [0.1429, 0.2586, 0.2057, 0.28]}, {"w": "by", "b": [0.2104, 0.2586, 0.2306, 0.28]}, {"w": "the", "b": [0.2353, 0.2586, 0.2617, 0.28]}, {"w": "first", "b": [0.2664, 0.2586, 0.2999, 0.28]}, {"w": "d", "b": [0.3047, 0.2584, 0.3153, 0.28]}, {"w": "principal", "b": [0.32, 0.2586, 0.3954, 0.28]}, {"w": "components.", "b": [0.4001, 0.2586, 0.5077, 0.28]}, {"w": "Selecting", "b": [0.5125, 0.2586, 0.5872, 0.28]}, {"w": "this", "b": [0.5919, 0.2586, 0.6227, 0.28]}, {"w": "hyperplane", "b": [0.6274, 0.2586, 0.7207, 0.28]}, {"w": "ensures", "b": [0.7254, 0.2586, 0.7886, 0.28]}, {"w": "that", "b": [0.7933, 0.2586, 0.8259, 0.28]}, {"w": "the", "b": [0.8306, 0.2586, 0.857, 0.28]}, {"w": "projection", "b": [0.1429, 0.2777, 0.2291, 0.2991]}, {"w": "will", "b": [0.2349, 0.2777, 0.2653, 0.2991]}, {"w": "preserve", "b": [0.2711, 0.2777, 0.3419, 0.2991]}, {"w": "as", "b": [0.3477, 0.2777, 0.3645, 0.2991]}, {"w": "much", "b": [0.3703, 0.2777, 0.418, 0.2991]}, {"w": "variance", "b": [0.4238, 0.2777, 0.4941, 0.2991]}, {"w": "as", "b": [0.4999, 0.2777, 0.5167, 0.2991]}, {"w": "possible.", "b": [0.5225, 0.2777, 0.5944, 0.2991]}, {"w": "For", "b": [0.6002, 0.2777, 0.6291, 0.2991]}, {"w": "example,", "b": [0.6349, 0.2777, 0.7092, 0.2991]}, {"w": "in", "b": [0.715, 0.2777, 0.732, 0.2991]}, {"w": "Figure", "b": [0.7378, 0.2777, 0.7918, 0.2991]}, {"w": "8-2", "b": [0.7976, 0.2777, 0.825, 0.2991]}, {"w": "the", "b": [0.8308, 0.2777, 0.8571, 0.2991]}, {"w": "3D", "b": [0.1429, 0.2967, 0.1682, 0.3181]}, {"w": "dataset", "b": [0.1738, 0.2967, 0.2319, 0.3181]}, {"w": "is", "b": [0.2375, 0.2967, 0.2507, 0.3181]}, {"w": "projected", "b": [0.2564, 0.2967, 0.3348, 0.3181]}, {"w": "down", "b": [0.3405, 0.2967, 0.3878, 0.3181]}, {"w": "to", "b": [0.3934, 0.2967, 0.4104, 0.3181]}, {"w": "the", "b": [0.416, 0.2967, 0.4423, 0.3181]}, {"w": "2D", "b": [0.4479, 0.2967, 0.4733, 0.3181]}, {"w": "plane", "b": [0.4789, 0.2967, 0.5245, 0.3181]}, {"w": "defined", "b": [0.5301, 0.2967, 0.5929, 0.3181]}, {"w": "by", "b": [0.5986, 0.2967, 0.6187, 0.3181]}, {"w": "the", "b": [0.6243, 0.2967, 0.6507, 0.3181]}, {"w": "first", "b": [0.6563, 0.2967, 0.6898, 0.3181]}, {"w": "two", "b": [0.6954, 0.2967, 0.7266, 0.3181]}, {"w": "principal", "b": [0.7323, 0.2967, 0.8076, 0.3181]}, {"w": "com‐", "b": [0.8132, 0.2967, 0.8571, 0.3181]}, {"w": "ponents,", "b": [0.1429, 0.3158, 0.2144, 0.3372]}, {"w": "preserving", "b": [0.2208, 0.3158, 0.3095, 0.3372]}, {"w": "a", "b": [0.3159, 0.3158, 0.3251, 0.3372]}, {"w": "large", "b": [0.3315, 0.3158, 0.3722, 0.3372]}, {"w": "part", "b": [0.3786, 0.3158, 0.4128, 0.3372]}, {"w": "of", "b": [0.4192, 0.3158, 0.436, 0.3372]}, {"w": "the", "b": [0.4424, 0.3158, 0.4687, 0.3372]}, {"w": "dataset’s", "b": [0.4752, 0.3158, 0.543, 0.3372]}, {"w": "variance.", "b": [0.5494, 0.3158, 0.6245, 0.3372]}, {"w": "As", "b": [0.6309, 0.3158, 0.6529, 0.3372]}, {"w": "a", "b": [0.6593, 0.3158, 0.6685, 0.3372]}, {"w": "result,", "b": [0.6749, 0.3158, 0.7266, 0.3372]}, {"w": "the", "b": [0.733, 0.3158, 0.7593, 0.3372]}, {"w": "2D", "b": [0.7657, 0.3158, 0.791, 0.3372]}, {"w": "projec‐", "b": [0.7974, 0.3158, 0.8571, 0.3372]}, {"w": "tion", "b": [0.1429, 0.3348, 0.1768, 0.3562]}, {"w": "looks", "b": [0.1816, 0.3348, 0.2261, 0.3562]}, {"w": "very", "b": [0.2308, 0.3348, 0.2672, 0.3562]}, {"w": "much", "b": [0.2719, 0.3348, 0.3196, 0.3562]}, {"w": "like", "b": [0.3243, 0.3348, 0.3543, 0.3562]}, {"w": "the", "b": [0.3591, 0.3348, 0.3854, 0.3562]}, {"w": "original", "b": [0.3901, 0.3348, 0.4552, 0.3562]}, {"w": "3D", "b": [0.4599, 0.3348, 0.4853, 0.3562]}, {"w": "dataset.", "b": [0.49, 0.3348, 0.5528, 0.3562]}]}, {"id": "b_3", "type": "paragraph", "text": "To project the training set onto the hyperplane, you can simply compute the matrix multiplication of the training set matrix X by the matrix Wd, defined as the matrix containing the first d principal components (i.e., the matrix composed of the first d columns of V), as shown in Equation 8-2.", "words": [{"w": "To", "b": [0.1429, 0.3629, 0.1643, 0.3843]}, {"w": "project", "b": [0.1708, 0.3629, 0.2294, 0.3843]}, {"w": "the", "b": [0.2358, 0.3629, 0.2622, 0.3843]}, {"w": "training", "b": [0.2686, 0.3629, 0.3356, 0.3843]}, {"w": "set", "b": [0.342, 0.3629, 0.3649, 0.3843]}, {"w": "onto", "b": [0.3713, 0.3629, 0.4099, 0.3843]}, {"w": "the", "b": [0.4164, 0.3629, 0.4427, 0.3843]}, {"w": "hyperplane,", "b": [0.4492, 0.3629, 0.5472, 0.3843]}, {"w": "you", "b": [0.5537, 0.3629, 0.5849, 0.3843]}, {"w": "can", "b": [0.5914, 0.3629, 0.6207, 0.3843]}, {"w": "simply", "b": [0.6272, 0.3629, 0.6828, 0.3843]}, {"w": "compute", "b": [0.6893, 0.3629, 0.7626, 0.3843]}, {"w": "the", "b": [0.769, 0.3629, 0.7954, 0.3843]}, {"w": "matrix", "b": [0.8018, 0.3629, 0.8572, 0.3843]}, {"w": "multiplication", "b": [0.1429, 0.382, 0.2611, 0.4034]}, {"w": "of", "b": [0.2681, 0.382, 0.2849, 0.4034]}, {"w": "the", "b": [0.292, 0.382, 0.3183, 0.4034]}, {"w": "training", "b": [0.3254, 0.382, 0.3923, 0.4034]}, {"w": "set", "b": [0.3994, 0.382, 0.4222, 0.4034]}, {"w": "matrix", "b": [0.4293, 0.382, 0.4846, 0.4034]}, {"w": "X", "b": [0.4917, 0.3814, 0.5061, 0.4034]}, {"w": "by", "b": [0.5132, 0.382, 0.5333, 0.4034]}, {"w": "the", "b": [0.5404, 0.382, 0.5667, 0.4034]}, {"w": "matrix", "b": [0.5738, 0.382, 0.6291, 0.4034]}, {"w": "Wd,", "b": [0.6361, 0.3814, 0.6676, 0.4043]}, {"w": "defined", "b": [0.6747, 0.382, 0.7375, 0.4034]}, {"w": "as", "b": [0.7446, 0.382, 0.7614, 0.4034]}, {"w": "the", "b": [0.7684, 0.382, 0.7948, 0.4034]}, {"w": "matrix", "b": [0.8018, 0.382, 0.8571, 0.4034]}, {"w": "containing", "b": [0.1429, 0.401, 0.2325, 0.4224]}, {"w": "the", "b": [0.2391, 0.401, 0.2655, 0.4224]}, {"w": "first", "b": [0.2721, 0.401, 0.3056, 0.4224]}, {"w": "d", "b": [0.3122, 0.4008, 0.3228, 0.4224]}, {"w": "principal", "b": [0.3294, 0.401, 0.4047, 0.4224]}, {"w": "components", "b": [0.4114, 0.401, 0.5143, 0.4224]}, {"w": "(i.e.,", "b": [0.5209, 0.401, 0.5568, 0.4224]}, {"w": "the", "b": [0.5634, 0.401, 0.5897, 0.4224]}, {"w": "matrix", "b": [0.5964, 0.401, 0.6517, 0.4224]}, {"w": "composed", "b": [0.6583, 0.401, 0.7435, 0.4224]}, {"w": "of", "b": [0.7501, 0.401, 0.7669, 0.4224]}, {"w": "the", "b": [0.7735, 0.401, 0.7998, 0.4224]}, {"w": "first", "b": [0.8065, 0.401, 0.8399, 0.4224]}, {"w": "d", "b": [0.8466, 0.4008, 0.8571, 0.4224]}, {"w": "columns", "b": [0.1428, 0.4201, 0.2147, 0.4415]}, {"w": "of", "b": [0.2195, 0.4201, 0.2362, 0.4415]}, {"w": "V),", "b": [0.241, 0.4195, 0.2677, 0.4415]}, {"w": "as", "b": [0.2725, 0.4201, 0.2893, 0.4415]}, {"w": "shown", "b": [0.294, 0.4201, 0.3491, 0.4415]}, {"w": "in", "b": [0.3538, 0.4201, 0.3708, 0.4415]}, {"w": "Equation", "b": [0.3755, 0.4201, 0.4517, 0.4415]}, {"w": "8-2.", "b": [0.4565, 0.4201, 0.4886, 0.4415]}]}, {"id": "b_4", "type": "equation", "text": "Equation 8-2. Projecting the training set down to d dimensions", "words": [{"w": "Equation", "b": [0.1726, 0.4596, 0.2473, 0.4812]}, {"w": "8-2.", "b": [0.2521, 0.4596, 0.2838, 0.4812]}, {"w": "Projecting", "b": [0.2886, 0.4596, 0.3698, 0.4812]}, {"w": "the", "b": [0.3746, 0.4596, 0.3996, 0.4812]}, {"w": "training", "b": [0.4044, 0.4596, 0.4689, 0.4812]}, {"w": "set", "b": [0.4736, 0.4596, 0.4953, 0.4812]}, {"w": "down", "b": [0.5001, 0.4596, 0.5454, 0.4812]}, {"w": "to", "b": [0.5502, 0.4596, 0.5661, 0.4812]}, {"w": "d", "b": [0.5709, 0.4596, 0.5815, 0.4812]}, {"w": "dimensions", "b": [0.5863, 0.4596, 0.6778, 0.4812]}]}, {"id": "b_5", "type": "equation", "text": "Xd‐proj = XWd", "words": [{"w": "Xd‐proj", "b": [0.1726, 0.4871, 0.2267, 0.5122]}, {"w": "=", "b": [0.2322, 0.4876, 0.2437, 0.508]}, {"w": "XWd", "b": [0.2492, 0.4871, 0.2904, 0.5122]}]}, {"id": "b_6", "type": "paragraph", "text": "The following Python code projects the training set onto the plane defined by the first two principal components:", "words": [{"w": "The", "b": [0.1429, 0.5313, 0.1757, 0.5527]}, {"w": "following", "b": [0.1804, 0.5313, 0.2594, 0.5527]}, {"w": "Python", "b": [0.2641, 0.5313, 0.3249, 0.5527]}, {"w": "code", "b": [0.3296, 0.5313, 0.3689, 0.5527]}, {"w": "projects", "b": [0.3737, 0.5313, 0.4399, 0.5527]}, {"w": "the", "b": [0.4447, 0.5313, 0.471, 0.5527]}, {"w": "training", "b": [0.4757, 0.5313, 0.5427, 0.5527]}, {"w": "set", "b": [0.5474, 0.5313, 0.5702, 0.5527]}, {"w": "onto", "b": [0.575, 0.5313, 0.6136, 0.5527]}, {"w": "the", "b": [0.6183, 0.5313, 0.6446, 0.5527]}, {"w": "plane", "b": [0.6494, 0.5313, 0.6949, 0.5527]}, {"w": "defined", "b": [0.6997, 0.5313, 0.7625, 0.5527]}, {"w": "by", "b": [0.7673, 0.5313, 0.7874, 0.5527]}, {"w": "the", "b": [0.7921, 0.5313, 0.8185, 0.5527]}, {"w": "first", "b": [0.8232, 0.5313, 0.8567, 0.5527]}, {"w": "two", "b": [0.1429, 0.5503, 0.1741, 0.5718]}, {"w": "principal", "b": [0.1788, 0.5503, 0.2542, 0.5718]}, {"w": "components:", "b": [0.2589, 0.5503, 0.3666, 0.5718]}]}, {"id": "b_7", "type": "equation", "text": "W2 = Vt.T[:, :2] X2D = X_centered.dot(W2)", "words": [{"w": "W2", "b": [0.1766, 0.5823, 0.1935, 0.5952]}, {"w": "=", "b": [0.2019, 0.5823, 0.2103, 0.5952]}, {"w": "Vt.T[:,", "b": [0.2188, 0.5823, 0.2778, 0.5952]}, {"w": ":2]", "b": [0.2862, 0.5823, 0.3115, 0.5952]}, {"w": "X2D", "b": [0.1766, 0.5977, 0.2019, 0.6106]}, {"w": "=", "b": [0.2103, 0.5977, 0.2188, 0.6106]}, {"w": "X_centered.dot(W2)", "b": [0.2272, 0.5977, 0.379, 0.6106]}]}, {"id": "b_8", "type": "paragraph", "text": "There you have it! You now know how to reduce the dimensionality of any dataset down to any number of dimensions, while preserving as much variance as possible.", "words": [{"w": "There", "b": [0.1429, 0.6184, 0.1923, 0.6398]}, {"w": "you", "b": [0.1992, 0.6184, 0.2305, 0.6398]}, {"w": "have", "b": [0.2374, 0.6184, 0.2758, 0.6398]}, {"w": "it!", "b": [0.2827, 0.6184, 0.3004, 0.6398]}, {"w": "You", "b": [0.3073, 0.6184, 0.3397, 0.6398]}, {"w": "now", "b": [0.3466, 0.6184, 0.3829, 0.6398]}, {"w": "know", "b": [0.3898, 0.6184, 0.4365, 0.6398]}, {"w": "how", "b": [0.4434, 0.6184, 0.4794, 0.6398]}, {"w": "to", "b": [0.4864, 0.6184, 0.5033, 0.6398]}, {"w": "reduce", "b": [0.5103, 0.6184, 0.5666, 0.6398]}, {"w": "the", "b": [0.5735, 0.6184, 0.5998, 0.6398]}, {"w": "dimensionality", "b": [0.6068, 0.6184, 0.7318, 0.6398]}, {"w": "of", "b": [0.7388, 0.6184, 0.7556, 0.6398]}, {"w": "any", "b": [0.7625, 0.6184, 0.7921, 0.6398]}, {"w": "dataset", "b": [0.799, 0.6184, 0.8572, 0.6398]}, {"w": "down", "b": [0.1429, 0.6374, 0.1902, 0.6588]}, {"w": "to", "b": [0.1949, 0.6374, 0.2119, 0.6588]}, {"w": "any", "b": [0.2166, 0.6374, 0.2462, 0.6588]}, {"w": "number", "b": [0.2509, 0.6374, 0.3172, 0.6588]}, {"w": "of", "b": [0.322, 0.6374, 0.3388, 0.6588]}, {"w": "dimensions,", "b": [0.3435, 0.6374, 0.445, 0.6588]}, {"w": "while", "b": [0.4498, 0.6374, 0.4949, 0.6588]}, {"w": "preserving", "b": [0.4996, 0.6374, 0.5883, 0.6588]}, {"w": "as", "b": [0.593, 0.6374, 0.6098, 0.6588]}, {"w": "much", "b": [0.6145, 0.6374, 0.6622, 0.6588]}, {"w": "variance", "b": [0.6669, 0.6374, 0.7373, 0.6588]}, {"w": "as", "b": [0.742, 0.6374, 0.7588, 0.6588]}, {"w": "possible.", "b": [0.7635, 0.6374, 0.8354, 0.6588]}]}, {"id": "b_9", "type": "equation", "text": "Using Scikit-Learn", "words": [{"w": "Using", "b": [0.1428, 0.6716, 0.2008, 0.7002]}, {"w": "Scikit-Learn", "b": [0.2058, 0.6716, 0.3279, 0.7002]}]}, {"id": "b_10", "type": "paragraph", "text": "Scikit-Learn’s PCA class implements PCA using SVD decomposition just like we did before. The following code applies PCA to reduce the dimensionality of the dataset down to two dimensions (note that it automatically takes care of centering the data):", "words": [{"w": "Scikit-Learn’s", "b": [0.1429, 0.707, 0.2537, 0.7284]}, {"w": "PCA", "b": [0.2606, 0.7101, 0.2903, 0.7252]}, {"w": "class", "b": [0.2972, 0.707, 0.3358, 0.7284]}, {"w": "implements", "b": [0.3427, 0.707, 0.4409, 0.7284]}, {"w": "PCA", "b": [0.4478, 0.707, 0.4877, 0.7284]}, {"w": "using", "b": [0.4946, 0.707, 0.5401, 0.7284]}, {"w": "SVD", "b": [0.547, 0.707, 0.5868, 0.7284]}, {"w": "decomposition", "b": [0.5937, 0.707, 0.7184, 0.7284]}, {"w": "just", "b": [0.7253, 0.707, 0.7557, 0.7284]}, {"w": "like", "b": [0.7626, 0.707, 0.7926, 0.7284]}, {"w": "we", "b": [0.7995, 0.707, 0.8227, 0.7284]}, {"w": "did", "b": [0.8296, 0.707, 0.8571, 0.7284]}, {"w": "before.", "b": [0.1429, 0.726, 0.2004, 0.7474]}, {"w": "The", "b": [0.2072, 0.726, 0.2401, 0.7474]}, {"w": "following", "b": [0.2469, 0.726, 0.3259, 0.7474]}, {"w": "code", "b": [0.3327, 0.726, 0.372, 0.7474]}, {"w": "applies", "b": [0.3788, 0.726, 0.4367, 0.7474]}, {"w": "PCA", "b": [0.4435, 0.726, 0.4835, 0.7474]}, {"w": "to", "b": [0.4903, 0.726, 0.5073, 0.7474]}, {"w": "reduce", "b": [0.5141, 0.726, 0.5704, 0.7474]}, {"w": "the", "b": [0.5773, 0.726, 0.6036, 0.7474]}, {"w": "dimensionality", "b": [0.6104, 0.726, 0.7355, 0.7474]}, {"w": "of", "b": [0.7423, 0.726, 0.7591, 0.7474]}, {"w": "the", "b": [0.7659, 0.726, 0.7922, 0.7474]}, {"w": "dataset", "b": [0.799, 0.726, 0.8572, 0.7474]}, {"w": "down", "b": [0.1429, 0.7451, 0.1902, 0.7665]}, {"w": "to", "b": [0.1949, 0.7451, 0.2119, 0.7665]}, {"w": "two", "b": [0.2166, 0.7451, 0.2478, 0.7665]}, {"w": "dimensions", "b": [0.2526, 0.7451, 0.3494, 0.7665]}, {"w": "(note", "b": [0.3541, 0.7451, 0.3985, 0.7665]}, {"w": "that", "b": [0.4033, 0.7451, 0.4358, 0.7665]}, {"w": "it", "b": [0.4406, 0.7451, 0.4525, 0.7665]}, {"w": "automatically", "b": [0.4572, 0.7451, 0.5698, 0.7665]}, {"w": "takes", "b": [0.5746, 0.7451, 0.6169, 0.7665]}, {"w": "care", "b": [0.6216, 0.7451, 0.6562, 0.7665]}, {"w": "of", "b": [0.6609, 0.7451, 0.6777, 0.7665]}, {"w": "centering", "b": [0.6824, 0.7451, 0.7608, 0.7665]}, {"w": "the", "b": [0.7655, 0.7451, 0.7918, 0.7665]}, {"w": "data):", "b": [0.7965, 0.7451, 0.8438, 0.7665]}]}, {"id": "b_11", "type": "paragraph", "text": "from sklearn.decomposition import PCA", "words": [{"w": "from", "b": [0.1766, 0.777, 0.2103, 0.7899]}, {"w": "sklearn.decomposition", "b": [0.2188, 0.777, 0.3958, 0.7899]}, {"w": "import", "b": [0.4043, 0.777, 0.4549, 0.7899]}, {"w": "PCA", "b": [0.4633, 0.777, 0.4886, 0.7899]}]}, {"id": "b_12", "type": "equation", "text": "pca = PCA(n_components = 2) X2D = pca.fit_transform(X)", "words": [{"w": "pca", "b": [0.1766, 0.8079, 0.2019, 0.8207]}, {"w": "=", "b": [0.2103, 0.8079, 0.2188, 0.8207]}, {"w": "PCA(n_components", "b": [0.2272, 0.8079, 0.3621, 0.8207]}, {"w": "=", "b": [0.3705, 0.8079, 0.379, 0.8207]}, {"w": "2)", "b": [0.3874, 0.8079, 0.4043, 0.8207]}, {"w": "X2D", "b": [0.1766, 0.8233, 0.2019, 0.8361]}, {"w": "=", "b": [0.2103, 0.8233, 0.2188, 0.8361]}, {"w": "pca.fit_transform(X)", "b": [0.2272, 0.8233, 0.3958, 0.8361]}]}, {"id": "b_13", "type": "paragraph", "text": "After fitting the PCA transformer to the dataset, you can access the principal compo‐ nents using the components_ variable (note that it contains the PCs as horizontal vec‐", "words": [{"w": "After", "b": [0.1429, 0.8448, 0.1864, 0.8662]}, {"w": "fitting", "b": [0.1924, 0.8448, 0.2436, 0.8662]}, {"w": "the", "b": [0.2497, 0.8448, 0.276, 0.8662]}, {"w": "PCA", "b": [0.282, 0.848, 0.3117, 0.8631]}, {"w": "transformer", "b": [0.3178, 0.8448, 0.4182, 0.8662]}, {"w": "to", "b": [0.4243, 0.8448, 0.4413, 0.8662]}, {"w": "the", "b": [0.4473, 0.8448, 0.4736, 0.8662]}, {"w": "dataset,", "b": [0.4797, 0.8448, 0.5425, 0.8662]}, {"w": "you", "b": [0.5486, 0.8448, 0.5799, 0.8662]}, {"w": "can", "b": [0.5859, 0.8448, 0.6153, 0.8662]}, {"w": "access", "b": [0.6213, 0.8448, 0.6722, 0.8662]}, {"w": "the", "b": [0.6783, 0.8448, 0.7046, 0.8662]}, {"w": "principal", "b": [0.7107, 0.8448, 0.786, 0.8662]}, {"w": "compo‐", "b": [0.7921, 0.8448, 0.8571, 0.8662]}, {"w": "nents", "b": [0.1429, 0.8648, 0.1881, 0.8862]}, {"w": "using", "b": [0.1931, 0.8648, 0.2386, 0.8862]}, {"w": "the", "b": [0.2436, 0.8648, 0.27, 0.8862]}, {"w": "components_", "b": [0.275, 0.868, 0.3839, 0.883]}, {"w": "variable", "b": [0.3889, 0.8648, 0.4549, 0.8862]}, {"w": "(note", "b": [0.4599, 0.8648, 0.5044, 0.8862]}, {"w": "that", "b": [0.5094, 0.8648, 0.542, 0.8862]}, {"w": "it", "b": [0.5471, 0.8648, 0.559, 0.8862]}, {"w": "contains", "b": [0.564, 0.8648, 0.6346, 0.8862]}, {"w": "the", "b": [0.6397, 0.8648, 0.666, 0.8862]}, {"w": "PCs", "b": [0.671, 0.8648, 0.7043, 0.8862]}, {"w": "as", "b": [0.7093, 0.8648, 0.7261, 0.8862]}, {"w": "horizontal", "b": [0.7312, 0.8648, 0.8174, 0.8862]}, {"w": "vec‐", "b": [0.8224, 0.8648, 0.8571, 0.8862]}]}, {"id": "b_14", "type": "paragraph", "text": "224 | Chapter 8: Dimensionality Reduction", "words": [{"w": "224", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "8:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Dimensionality", "b": [0.2673, 0.9225, 0.3562, 0.9388]}, {"w": "Reduction", "b": [0.359, 0.9225, 0.4186, 0.9388]}]}]}, {"page": 251, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "tors, so, for example, the first principal component is equal to pca.components_.T[:, 0]).", "words": [{"w": "tors,", "b": [0.1429, 0.08, 0.18, 0.1014]}, {"w": "so,", "b": [0.1847, 0.08, 0.2071, 0.1014]}, {"w": "for", "b": [0.2118, 0.08, 0.2364, 0.1014]}, {"w": "example,", "b": [0.2411, 0.08, 0.3154, 0.1014]}, {"w": "the", "b": [0.3201, 0.08, 0.3464, 0.1014]}, {"w": "first", "b": [0.3512, 0.08, 0.3846, 0.1014]}, {"w": "principal", "b": [0.3894, 0.08, 0.4647, 0.1014]}, {"w": "component", "b": [0.4695, 0.08, 0.5647, 0.1014]}, {"w": "is", "b": [0.5694, 0.08, 0.5827, 0.1014]}, {"w": "equal", "b": [0.5874, 0.08, 0.6324, 0.1014]}, {"w": "to", "b": [0.6371, 0.08, 0.6541, 0.1014]}, {"w": "pca.components_.T[:,", "b": [0.6592, 0.0831, 0.8571, 0.0982]}, {"w": "0]).", "b": [0.1429, 0.0999, 0.1746, 0.1213]}]}, {"id": "b_1", "type": "paragraph", "text": "Explained Variance Ratio", "words": [{"w": "Explained", "b": [0.1429, 0.1341, 0.2441, 0.1626]}, {"w": "Variance", "b": [0.249, 0.1341, 0.3382, 0.1626]}, {"w": "Ratio", "b": [0.3431, 0.1341, 0.3976, 0.1626]}]}, {"id": "b_2", "type": "paragraph", "text": "Another very useful piece of information is the explained variance ratio of each prin‐ cipal component, available via the explained_variance_ratio_ variable. It indicates the proportion of the dataset’s variance that lies along the axis of each principal com‐ ponent. For example, let’s look at the explained variance ratios of the first two compo‐ nents of the 3D dataset represented in Figure 8-2:", "words": [{"w": "Another", "b": [0.1428, 0.1685, 0.2133, 0.19]}, {"w": "very", "b": [0.2189, 0.1685, 0.2553, 0.19]}, {"w": "useful", "b": [0.2609, 0.1685, 0.3109, 0.19]}, {"w": "piece", "b": [0.3165, 0.1685, 0.3595, 0.19]}, {"w": "of", "b": [0.3651, 0.1685, 0.3819, 0.19]}, {"w": "information", "b": [0.3875, 0.1685, 0.4888, 0.19]}, {"w": "is", "b": [0.4944, 0.1685, 0.5076, 0.19]}, {"w": "the", "b": [0.5132, 0.1685, 0.5395, 0.19]}, {"w": "explained", "b": [0.5451, 0.1683, 0.6233, 0.19]}, {"w": "variance", "b": [0.6289, 0.1683, 0.6984, 0.19]}, {"w": "ratio", "b": [0.704, 0.1683, 0.7426, 0.19]}, {"w": "of", "b": [0.7482, 0.1685, 0.765, 0.19]}, {"w": "each", "b": [0.7706, 0.1685, 0.8085, 0.19]}, {"w": "prin‐", "b": [0.8141, 0.1685, 0.8571, 0.19]}, {"w": "cipal", "b": [0.1429, 0.1885, 0.1826, 0.2099]}, {"w": "component,", "b": [0.1884, 0.1885, 0.2884, 0.2099]}, {"w": "available", "b": [0.2943, 0.1885, 0.3666, 0.2099]}, {"w": "via", "b": [0.3724, 0.1885, 0.3968, 0.2099]}, {"w": "the", "b": [0.4027, 0.1885, 0.429, 0.2099]}, {"w": "explained_variance_ratio_", "b": [0.4348, 0.1917, 0.6822, 0.2068]}, {"w": "variable.", "b": [0.6881, 0.1885, 0.7588, 0.2099]}, {"w": "It", "b": [0.7647, 0.1885, 0.7773, 0.2099]}, {"w": "indicates", "b": [0.7832, 0.1885, 0.8571, 0.2099]}, {"w": "the", "b": [0.1429, 0.2075, 0.1692, 0.229]}, {"w": "proportion", "b": [0.1746, 0.2075, 0.2671, 0.229]}, {"w": "of", "b": [0.2725, 0.2075, 0.2893, 0.229]}, {"w": "the", "b": [0.2947, 0.2075, 0.321, 0.229]}, {"w": "dataset’s", "b": [0.3264, 0.2075, 0.3942, 0.229]}, {"w": "variance", "b": [0.3996, 0.2075, 0.4699, 0.229]}, {"w": "that", "b": [0.4753, 0.2075, 0.5079, 0.229]}, {"w": "lies", "b": [0.5133, 0.2075, 0.5407, 0.229]}, {"w": "along", "b": [0.5461, 0.2075, 0.5922, 0.229]}, {"w": "the", "b": [0.5976, 0.2075, 0.624, 0.229]}, {"w": "axis", "b": [0.6294, 0.2075, 0.6616, 0.229]}, {"w": "of", "b": [0.667, 0.2075, 0.6838, 0.229]}, {"w": "each", "b": [0.6891, 0.2075, 0.7271, 0.229]}, {"w": "principal", "b": [0.7325, 0.2075, 0.8078, 0.229]}, {"w": "com‐", "b": [0.8132, 0.2075, 0.8571, 0.229]}, {"w": "ponent.", "b": [0.1428, 0.2266, 0.2067, 0.248]}, {"w": "For", "b": [0.2116, 0.2266, 0.2406, 0.248]}, {"w": "example,", "b": [0.2454, 0.2266, 0.3197, 0.248]}, {"w": "let’s", "b": [0.3245, 0.2266, 0.3548, 0.248]}, {"w": "look", "b": [0.3596, 0.2266, 0.3965, 0.248]}, {"w": "at", "b": [0.4013, 0.2266, 0.4164, 0.248]}, {"w": "the", "b": [0.4213, 0.2266, 0.4476, 0.248]}, {"w": "explained", "b": [0.4524, 0.2266, 0.5333, 0.248]}, {"w": "variance", "b": [0.5381, 0.2266, 0.6085, 0.248]}, {"w": "ratios", "b": [0.6133, 0.2266, 0.66, 0.248]}, {"w": "of", "b": [0.6648, 0.2266, 0.6816, 0.248]}, {"w": "the", "b": [0.6865, 0.2266, 0.7128, 0.248]}, {"w": "first", "b": [0.7177, 0.2266, 0.7511, 0.248]}, {"w": "two", "b": [0.756, 0.2266, 0.7872, 0.248]}, {"w": "compo‐", "b": [0.7921, 0.2266, 0.8571, 0.248]}, {"w": "nents", "b": [0.1429, 0.2456, 0.1881, 0.267]}, {"w": "of", "b": [0.1928, 0.2456, 0.2096, 0.267]}, {"w": "the", "b": [0.2144, 0.2456, 0.2407, 0.267]}, {"w": "3D", "b": [0.2454, 0.2456, 0.2707, 0.267]}, {"w": "dataset", "b": [0.2755, 0.2456, 0.3336, 0.267]}, {"w": "represented", "b": [0.3383, 0.2456, 0.4361, 0.267]}, {"w": "in", "b": [0.4408, 0.2456, 0.4578, 0.267]}, {"w": "Figure", "b": [0.4625, 0.2456, 0.5165, 0.267]}, {"w": "8-2:", "b": [0.5213, 0.2456, 0.5534, 0.267]}]}, {"id": "b_3", "type": "equation", "text": ">>> pca.explained_variance_ratio_ array([0.84248607, 0.14631839])", "words": [{"w": ">>>", "b": [0.1766, 0.2776, 0.2019, 0.2905]}, {"w": "pca.explained_variance_ratio_", "b": [0.2103, 0.2776, 0.4549, 0.2905]}, {"w": "array([0.84248607,", "b": [0.1766, 0.293, 0.3284, 0.3059]}, {"w": "0.14631839])", "b": [0.3368, 0.293, 0.438, 0.3059]}]}, {"id": "b_4", "type": "paragraph", "text": "This tells you that 84.2% of the dataset’s variance lies along the first axis, and 14.6% lies along the second axis. This leaves less than 1.2% for the third axis, so it is reason‐ able to assume that it probably carries little information.", "words": [{"w": "This", "b": [0.1429, 0.3137, 0.1801, 0.3351]}, {"w": "tells", "b": [0.1864, 0.3137, 0.2198, 0.3351]}, {"w": "you", "b": [0.2262, 0.3137, 0.2575, 0.3351]}, {"w": "that", "b": [0.2638, 0.3137, 0.2964, 0.3351]}, {"w": "84.2%", "b": [0.3028, 0.3137, 0.3533, 0.3351]}, {"w": "of", "b": [0.3597, 0.3137, 0.3765, 0.3351]}, {"w": "the", "b": [0.3829, 0.3137, 0.4092, 0.3351]}, {"w": "dataset’s", "b": [0.4156, 0.3137, 0.4834, 0.3351]}, {"w": "variance", "b": [0.4898, 0.3137, 0.5601, 0.3351]}, {"w": "lies", "b": [0.5665, 0.3137, 0.5939, 0.3351]}, {"w": "along", "b": [0.6002, 0.3137, 0.6464, 0.3351]}, {"w": "the", "b": [0.6528, 0.3137, 0.6791, 0.3351]}, {"w": "first", "b": [0.6855, 0.3137, 0.719, 0.3351]}, {"w": "axis,", "b": [0.7254, 0.3137, 0.7623, 0.3351]}, {"w": "and", "b": [0.7687, 0.3137, 0.8003, 0.3351]}, {"w": "14.6%", "b": [0.8066, 0.3137, 0.8571, 0.3351]}, {"w": "lies", "b": [0.1428, 0.3327, 0.1702, 0.3541]}, {"w": "along", "b": [0.1754, 0.3327, 0.2216, 0.3541]}, {"w": "the", "b": [0.2269, 0.3327, 0.2532, 0.3541]}, {"w": "second", "b": [0.2584, 0.3327, 0.3168, 0.3541]}, {"w": "axis.", "b": [0.322, 0.3327, 0.359, 0.3541]}, {"w": "This", "b": [0.3642, 0.3327, 0.4014, 0.3541]}, {"w": "leaves", "b": [0.4067, 0.3327, 0.4557, 0.3541]}, {"w": "less", "b": [0.4609, 0.3327, 0.4904, 0.3541]}, {"w": "than", "b": [0.4956, 0.3327, 0.5336, 0.3541]}, {"w": "1.2%", "b": [0.5389, 0.3327, 0.5794, 0.3541]}, {"w": "for", "b": [0.5846, 0.3327, 0.6091, 0.3541]}, {"w": "the", "b": [0.6144, 0.3327, 0.6407, 0.3541]}, {"w": "third", "b": [0.6459, 0.3327, 0.6877, 0.3541]}, {"w": "axis,", "b": [0.693, 0.3327, 0.7299, 0.3541]}, {"w": "so", "b": [0.7352, 0.3327, 0.7534, 0.3541]}, {"w": "it", "b": [0.7587, 0.3327, 0.7706, 0.3541]}, {"w": "is", "b": [0.7759, 0.3327, 0.7891, 0.3541]}, {"w": "reason‐", "b": [0.7943, 0.3327, 0.8571, 0.3541]}, {"w": "able", "b": [0.1429, 0.3518, 0.1767, 0.3732]}, {"w": "to", "b": [0.1814, 0.3518, 0.1984, 0.3732]}, {"w": "assume", "b": [0.2032, 0.3518, 0.2646, 0.3732]}, {"w": "that", "b": [0.2693, 0.3518, 0.3019, 0.3732]}, {"w": "it", "b": [0.3066, 0.3518, 0.3186, 0.3732]}, {"w": "probably", "b": [0.3233, 0.3518, 0.3977, 0.3732]}, {"w": "carries", "b": [0.4024, 0.3518, 0.4579, 0.3732]}, {"w": "little", "b": [0.4627, 0.3518, 0.5003, 0.3732]}, {"w": "information.", "b": [0.5051, 0.3518, 0.6111, 0.3732]}]}, {"id": "b_5", "type": "paragraph", "text": "Choosing the Right Number of Dimensions", "words": [{"w": "Choosing", "b": [0.1428, 0.3859, 0.2371, 0.4145]}, {"w": "the", "b": [0.242, 0.3859, 0.2769, 0.4145]}, {"w": "Right", "b": [0.2818, 0.3859, 0.3379, 0.4145]}, {"w": "Number", "b": [0.3428, 0.3859, 0.4263, 0.4145]}, {"w": "of", "b": [0.4312, 0.3859, 0.4522, 0.4145]}, {"w": "Dimensions", "b": [0.4571, 0.3859, 0.5767, 0.4145]}]}, {"id": "b_6", "type": "paragraph", "text": "Instead of arbitrarily choosing the number of dimensions to reduce down to, it is generally preferable to choose the number of dimensions that add up to a sufficiently large portion of the variance (e.g., 95%). Unless, of course, you are reducing dimen‐ sionality for data visualization—in that case you will generally want to reduce the dimensionality down to 2 or 3.", "words": [{"w": "Instead", "b": [0.1429, 0.4204, 0.2044, 0.4418]}, {"w": "of", "b": [0.2123, 0.4204, 0.2291, 0.4418]}, {"w": "arbitrarily", "b": [0.237, 0.4204, 0.3214, 0.4418]}, {"w": "choosing", "b": [0.3293, 0.4204, 0.4049, 0.4418]}, {"w": "the", "b": [0.4128, 0.4204, 0.4391, 0.4418]}, {"w": "number", "b": [0.4471, 0.4204, 0.5133, 0.4418]}, {"w": "of", "b": [0.5213, 0.4204, 0.5381, 0.4418]}, {"w": "dimensions", "b": [0.546, 0.4204, 0.6428, 0.4418]}, {"w": "to", "b": [0.6507, 0.4204, 0.6677, 0.4418]}, {"w": "reduce", "b": [0.6756, 0.4204, 0.7319, 0.4418]}, {"w": "down", "b": [0.7398, 0.4204, 0.7871, 0.4418]}, {"w": "to,", "b": [0.795, 0.4204, 0.8161, 0.4418]}, {"w": "it", "b": [0.8241, 0.4204, 0.836, 0.4418]}, {"w": "is", "b": [0.8439, 0.4204, 0.8571, 0.4418]}, {"w": "generally", "b": [0.1429, 0.4395, 0.2187, 0.4609]}, {"w": "preferable", "b": [0.224, 0.4395, 0.3081, 0.4609]}, {"w": "to", "b": [0.3135, 0.4395, 0.3305, 0.4609]}, {"w": "choose", "b": [0.3358, 0.4395, 0.3935, 0.4609]}, {"w": "the", "b": [0.3989, 0.4395, 0.4252, 0.4609]}, {"w": "number", "b": [0.4306, 0.4395, 0.4968, 0.4609]}, {"w": "of", "b": [0.5022, 0.4395, 0.519, 0.4609]}, {"w": "dimensions", "b": [0.5243, 0.4395, 0.6211, 0.4609]}, {"w": "that", "b": [0.6265, 0.4395, 0.6591, 0.4609]}, {"w": "add", "b": [0.6644, 0.4395, 0.6956, 0.4609]}, {"w": "up", "b": [0.7009, 0.4395, 0.7229, 0.4609]}, {"w": "to", "b": [0.7282, 0.4395, 0.7452, 0.4609]}, {"w": "a", "b": [0.7506, 0.4395, 0.7597, 0.4609]}, {"w": "sufficiently", "b": [0.7651, 0.4395, 0.8571, 0.4609]}, {"w": "large", "b": [0.1428, 0.4585, 0.1836, 0.4799]}, {"w": "portion", "b": [0.1898, 0.4585, 0.253, 0.4799]}, {"w": "of", "b": [0.2592, 0.4585, 0.276, 0.4799]}, {"w": "the", "b": [0.2822, 0.4585, 0.3085, 0.4799]}, {"w": "variance", "b": [0.3147, 0.4585, 0.385, 0.4799]}, {"w": "(e.g.,", "b": [0.3912, 0.4585, 0.4312, 0.4799]}, {"w": "95%).", "b": [0.4374, 0.4585, 0.4851, 0.4799]}, {"w": "Unless,", "b": [0.4913, 0.4585, 0.5513, 0.4799]}, {"w": "of", "b": [0.5575, 0.4585, 0.5743, 0.4799]}, {"w": "course,", "b": [0.5805, 0.4585, 0.6399, 0.4799]}, {"w": "you", "b": [0.6461, 0.4585, 0.6774, 0.4799]}, {"w": "are", "b": [0.6835, 0.4585, 0.7093, 0.4799]}, {"w": "reducing", "b": [0.7155, 0.4585, 0.7896, 0.4799]}, {"w": "dimen‐", "b": [0.7958, 0.4585, 0.8571, 0.4799]}, {"w": "sionality", "b": [0.1428, 0.4775, 0.214, 0.499]}, {"w": "for", "b": [0.2221, 0.4775, 0.2466, 0.499]}, {"w": "data", "b": [0.2547, 0.4775, 0.2899, 0.499]}, {"w": "visualization—in", "b": [0.298, 0.4775, 0.4396, 0.499]}, {"w": "that", "b": [0.4476, 0.4775, 0.4802, 0.499]}, {"w": "case", "b": [0.4883, 0.4775, 0.5228, 0.499]}, {"w": "you", "b": [0.5308, 0.4775, 0.5621, 0.499]}, {"w": "will", "b": [0.5702, 0.4775, 0.6005, 0.499]}, {"w": "generally", "b": [0.6086, 0.4775, 0.6845, 0.499]}, {"w": "want", "b": [0.6925, 0.4775, 0.7333, 0.499]}, {"w": "to", "b": [0.7414, 0.4775, 0.7583, 0.499]}, {"w": "reduce", "b": [0.7664, 0.4775, 0.8227, 0.499]}, {"w": "the", "b": [0.8308, 0.4775, 0.8571, 0.499]}, {"w": "dimensionality", "b": [0.1429, 0.4966, 0.2679, 0.518]}, {"w": "down", "b": [0.2727, 0.4966, 0.3199, 0.518]}, {"w": "to", "b": [0.3247, 0.4966, 0.3417, 0.518]}, {"w": "2", "b": [0.3464, 0.4966, 0.3564, 0.518]}, {"w": "or", "b": [0.3611, 0.4966, 0.3795, 0.518]}, {"w": "3.", "b": [0.3842, 0.4966, 0.3989, 0.518]}]}, {"id": "b_7", "type": "paragraph", "text": "The following code computes PCA without reducing dimensionality, then computes the minimum number of dimensions required to preserve 95% of the training set’s variance:", "words": [{"w": "The", "b": [0.1429, 0.5247, 0.1757, 0.5461]}, {"w": "following", "b": [0.1819, 0.5247, 0.2608, 0.5461]}, {"w": "code", "b": [0.267, 0.5247, 0.3063, 0.5461]}, {"w": "computes", "b": [0.3125, 0.5247, 0.3935, 0.5461]}, {"w": "PCA", "b": [0.3997, 0.5247, 0.4396, 0.5461]}, {"w": "without", "b": [0.4458, 0.5247, 0.5112, 0.5461]}, {"w": "reducing", "b": [0.5174, 0.5247, 0.5916, 0.5461]}, {"w": "dimensionality,", "b": [0.5978, 0.5247, 0.7261, 0.5461]}, {"w": "then", "b": [0.7323, 0.5247, 0.77, 0.5461]}, {"w": "computes", "b": [0.7762, 0.5247, 0.8571, 0.5461]}, {"w": "the", "b": [0.1429, 0.5438, 0.1692, 0.5652]}, {"w": "minimum", "b": [0.1764, 0.5438, 0.2608, 0.5652]}, {"w": "number", "b": [0.2679, 0.5438, 0.3342, 0.5652]}, {"w": "of", "b": [0.3414, 0.5438, 0.3582, 0.5652]}, {"w": "dimensions", "b": [0.3653, 0.5438, 0.4621, 0.5652]}, {"w": "required", "b": [0.4693, 0.5438, 0.5408, 0.5652]}, {"w": "to", "b": [0.5479, 0.5438, 0.5649, 0.5652]}, {"w": "preserve", "b": [0.5721, 0.5438, 0.6429, 0.5652]}, {"w": "95%", "b": [0.6501, 0.5438, 0.6858, 0.5652]}, {"w": "of", "b": [0.693, 0.5438, 0.7098, 0.5652]}, {"w": "the", "b": [0.7169, 0.5438, 0.7433, 0.5652]}, {"w": "training", "b": [0.7504, 0.5438, 0.8174, 0.5652]}, {"w": "set’s", "b": [0.8245, 0.5438, 0.8571, 0.5652]}, {"w": "variance:", "b": [0.1428, 0.5628, 0.2179, 0.5842]}]}, {"id": "b_8", "type": "paragraph", "text": "pca = PCA() pca.fit(X_train) cumsum = np.cumsum(pca.explained_variance_ratio_) d = np.argmax(cumsum >= 0.95) + 1", "words": [{"w": "pca", "b": [0.1766, 0.5948, 0.2019, 0.6076]}, {"w": "=", "b": [0.2103, 0.5948, 0.2188, 0.6076]}, {"w": "PCA()", "b": [0.2272, 0.5948, 0.2693, 0.6076]}, {"w": "pca.fit(X_train)", "b": [0.1766, 0.6102, 0.3115, 0.6231]}, {"w": "cumsum", "b": [0.1766, 0.6256, 0.2272, 0.6385]}, {"w": "=", "b": [0.2356, 0.6256, 0.2441, 0.6385]}, {"w": "np.cumsum(pca.explained_variance_ratio_)", "b": [0.2525, 0.6256, 0.5898, 0.6385]}, {"w": "d", "b": [0.1766, 0.641, 0.185, 0.6539]}, {"w": "=", "b": [0.1935, 0.641, 0.2019, 0.6539]}, {"w": "np.argmax(cumsum", "b": [0.2103, 0.641, 0.3452, 0.6539]}, {"w": ">=", "b": [0.3537, 0.641, 0.3705, 0.6539]}, {"w": "0.95)", "b": [0.379, 0.641, 0.4211, 0.6539]}, {"w": "+", "b": [0.4296, 0.641, 0.438, 0.6539]}, {"w": "1", "b": [0.4464, 0.641, 0.4549, 0.6539]}]}, {"id": "b_9", "type": "paragraph", "text": "You could then set n_components=d and run PCA again. However, there is a much better option: instead of specifying the number of principal components you want to preserve, you can set n_components to be a float between 0.0 and 1.0, indicating the ratio of variance you wish to preserve:", "words": [{"w": "You", "b": [0.1429, 0.6626, 0.1752, 0.684]}, {"w": "could", "b": [0.1824, 0.6626, 0.2291, 0.684]}, {"w": "then", "b": [0.2363, 0.6626, 0.274, 0.684]}, {"w": "set", "b": [0.2811, 0.6626, 0.304, 0.684]}, {"w": "n_components=d", "b": [0.3111, 0.6658, 0.4497, 0.6808]}, {"w": "and", "b": [0.4568, 0.6626, 0.4883, 0.684]}, {"w": "run", "b": [0.4955, 0.6626, 0.5256, 0.684]}, {"w": "PCA", "b": [0.5328, 0.6626, 0.5728, 0.684]}, {"w": "again.", "b": [0.5799, 0.6626, 0.6297, 0.684]}, {"w": "However,", "b": [0.6368, 0.6626, 0.7157, 0.684]}, {"w": "there", "b": [0.7228, 0.6626, 0.7657, 0.684]}, {"w": "is", "b": [0.7728, 0.6626, 0.7861, 0.684]}, {"w": "a", "b": [0.7932, 0.6626, 0.8023, 0.684]}, {"w": "much", "b": [0.8095, 0.6626, 0.8571, 0.684]}, {"w": "better", "b": [0.1429, 0.6816, 0.1916, 0.703]}, {"w": "option:", "b": [0.1972, 0.6816, 0.2574, 0.703]}, {"w": "instead", "b": [0.263, 0.6816, 0.323, 0.703]}, {"w": "of", "b": [0.3286, 0.6816, 0.3454, 0.703]}, {"w": "specifying", "b": [0.351, 0.6816, 0.4356, 0.703]}, {"w": "the", "b": [0.4413, 0.6816, 0.4676, 0.703]}, {"w": "number", "b": [0.4732, 0.6816, 0.5395, 0.703]}, {"w": "of", "b": [0.5451, 0.6816, 0.5619, 0.703]}, {"w": "principal", "b": [0.5675, 0.6816, 0.6428, 0.703]}, {"w": "components", "b": [0.6484, 0.6816, 0.7513, 0.703]}, {"w": "you", "b": [0.7569, 0.6816, 0.7882, 0.703]}, {"w": "want", "b": [0.7938, 0.6816, 0.8346, 0.703]}, {"w": "to", "b": [0.8402, 0.6816, 0.8571, 0.703]}, {"w": "preserve,", "b": [0.1429, 0.7016, 0.2184, 0.723]}, {"w": "you", "b": [0.224, 0.7016, 0.2553, 0.723]}, {"w": "can", "b": [0.2609, 0.7016, 0.2902, 0.723]}, {"w": "set", "b": [0.2958, 0.7016, 0.3187, 0.723]}, {"w": "n_components", "b": [0.3243, 0.7047, 0.443, 0.7198]}, {"w": "to", "b": [0.4486, 0.7016, 0.4656, 0.723]}, {"w": "be", "b": [0.4712, 0.7016, 0.4907, 0.723]}, {"w": "a", "b": [0.4963, 0.7016, 0.5054, 0.723]}, {"w": "float", "b": [0.511, 0.7016, 0.5482, 0.723]}, {"w": "between", "b": [0.5538, 0.7016, 0.6229, 0.723]}, {"w": "0.0", "b": [0.6285, 0.7047, 0.6582, 0.7198]}, {"w": "and", "b": [0.6638, 0.7016, 0.6954, 0.723]}, {"w": "1.0,", "b": [0.701, 0.7016, 0.7354, 0.723]}, {"w": "indicating", "b": [0.741, 0.7016, 0.8252, 0.723]}, {"w": "the", "b": [0.8308, 0.7016, 0.8571, 0.723]}, {"w": "ratio", "b": [0.1428, 0.7206, 0.1819, 0.742]}, {"w": "of", "b": [0.1866, 0.7206, 0.2034, 0.742]}, {"w": "variance", "b": [0.2081, 0.7206, 0.2785, 0.742]}, {"w": "you", "b": [0.2832, 0.7206, 0.3144, 0.742]}, {"w": "wish", "b": [0.3192, 0.7206, 0.3578, 0.742]}, {"w": "to", "b": [0.3625, 0.7206, 0.3795, 0.742]}, {"w": "preserve:", "b": [0.3842, 0.7206, 0.4598, 0.742]}]}, {"id": "b_10", "type": "equation", "text": "pca = PCA(n_components=0.95) X_reduced = pca.fit_transform(X_train)", "words": [{"w": "pca", "b": [0.1766, 0.7526, 0.2019, 0.7654]}, {"w": "=", "b": [0.2103, 0.7526, 0.2188, 0.7654]}, {"w": "PCA(n_components=0.95)", "b": [0.2272, 0.7526, 0.4127, 0.7654]}, {"w": "X_reduced", "b": [0.1766, 0.768, 0.2525, 0.7809]}, {"w": "=", "b": [0.2609, 0.768, 0.2693, 0.7809]}, {"w": "pca.fit_transform(X_train)", "b": [0.2778, 0.768, 0.497, 0.7809]}]}, {"id": "b_11", "type": "paragraph", "text": "Yet another option is to plot the explained variance as a function of the number of dimensions (simply plot cumsum; see Figure 8-8). There will usually be an elbow in the curve, where the explained variance stops growing fast. You can think of this as the intrinsic dimensionality of the dataset. In this case, you can see that reducing the", "words": [{"w": "Yet", "b": [0.1429, 0.7886, 0.1687, 0.81]}, {"w": "another", "b": [0.1756, 0.7886, 0.2408, 0.81]}, {"w": "option", "b": [0.2477, 0.7886, 0.3032, 0.81]}, {"w": "is", "b": [0.3101, 0.7886, 0.3233, 0.81]}, {"w": "to", "b": [0.3302, 0.7886, 0.3472, 0.81]}, {"w": "plot", "b": [0.3541, 0.7886, 0.3873, 0.81]}, {"w": "the", "b": [0.3941, 0.7886, 0.4205, 0.81]}, {"w": "explained", "b": [0.4274, 0.7886, 0.5082, 0.81]}, {"w": "variance", "b": [0.5151, 0.7886, 0.5854, 0.81]}, {"w": "as", "b": [0.5923, 0.7886, 0.6091, 0.81]}, {"w": "a", "b": [0.616, 0.7886, 0.6251, 0.81]}, {"w": "function", "b": [0.632, 0.7886, 0.7034, 0.81]}, {"w": "of", "b": [0.7103, 0.7886, 0.7271, 0.81]}, {"w": "the", "b": [0.734, 0.7886, 0.7603, 0.81]}, {"w": "number", "b": [0.7672, 0.7886, 0.8335, 0.81]}, {"w": "of", "b": [0.8404, 0.7886, 0.8571, 0.81]}, {"w": "dimensions", "b": [0.1429, 0.8086, 0.2396, 0.83]}, {"w": "(simply", "b": [0.2444, 0.8086, 0.3072, 0.83]}, {"w": "plot", "b": [0.312, 0.8086, 0.3451, 0.83]}, {"w": "cumsum;", "b": [0.35, 0.8086, 0.4141, 0.83]}, {"w": "see", "b": [0.4188, 0.8086, 0.4442, 0.83]}, {"w": "Figure", "b": [0.449, 0.8086, 0.503, 0.83]}, {"w": "8-8).", "b": [0.5078, 0.8086, 0.5472, 0.83]}, {"w": "There", "b": [0.5519, 0.8086, 0.6013, 0.83]}, {"w": "will", "b": [0.6061, 0.8086, 0.6365, 0.83]}, {"w": "usually", "b": [0.6412, 0.8086, 0.7002, 0.83]}, {"w": "be", "b": [0.7049, 0.8086, 0.7244, 0.83]}, {"w": "an", "b": [0.7291, 0.8086, 0.7496, 0.83]}, {"w": "elbow", "b": [0.7544, 0.8086, 0.804, 0.83]}, {"w": "in", "b": [0.8087, 0.8086, 0.8257, 0.83]}, {"w": "the", "b": [0.8304, 0.8086, 0.8567, 0.83]}, {"w": "curve,", "b": [0.1428, 0.8276, 0.1943, 0.849]}, {"w": "where", "b": [0.2008, 0.8276, 0.2516, 0.849]}, {"w": "the", "b": [0.2581, 0.8276, 0.2845, 0.849]}, {"w": "explained", "b": [0.291, 0.8276, 0.3718, 0.849]}, {"w": "variance", "b": [0.3783, 0.8276, 0.4486, 0.849]}, {"w": "stops", "b": [0.4551, 0.8276, 0.4983, 0.849]}, {"w": "growing", "b": [0.5048, 0.8276, 0.5739, 0.849]}, {"w": "fast.", "b": [0.5804, 0.8276, 0.6145, 0.849]}, {"w": "You", "b": [0.621, 0.8276, 0.6534, 0.849]}, {"w": "can", "b": [0.6599, 0.8276, 0.6892, 0.849]}, {"w": "think", "b": [0.6957, 0.8276, 0.7405, 0.849]}, {"w": "of", "b": [0.747, 0.8276, 0.7638, 0.849]}, {"w": "this", "b": [0.7703, 0.8276, 0.801, 0.849]}, {"w": "as", "b": [0.8075, 0.8276, 0.8243, 0.849]}, {"w": "the", "b": [0.8308, 0.8276, 0.8571, 0.849]}, {"w": "intrinsic", "b": [0.1429, 0.8467, 0.2125, 0.8681]}, {"w": "dimensionality", "b": [0.2207, 0.8467, 0.3458, 0.8681]}, {"w": "of", "b": [0.3539, 0.8467, 0.3707, 0.8681]}, {"w": "the", "b": [0.3789, 0.8467, 0.4052, 0.8681]}, {"w": "dataset.", "b": [0.4134, 0.8467, 0.4762, 0.8681]}, {"w": "In", "b": [0.4844, 0.8467, 0.5029, 0.8681]}, {"w": "this", "b": [0.511, 0.8467, 0.5418, 0.8681]}, {"w": "case,", "b": [0.5499, 0.8467, 0.5891, 0.8681]}, {"w": "you", "b": [0.5973, 0.8467, 0.6285, 0.8681]}, {"w": "can", "b": [0.6367, 0.8467, 0.666, 0.8681]}, {"w": "see", "b": [0.6742, 0.8467, 0.6996, 0.8681]}, {"w": "that", "b": [0.7077, 0.8467, 0.7403, 0.8681]}, {"w": "reducing", "b": [0.7485, 0.8467, 0.8227, 0.8681]}, {"w": "the", "b": [0.8308, 0.8467, 0.8571, 0.8681]}]}, {"id": "b_12", "type": "paragraph", "text": "PCA | 225", "words": [{"w": "PCA", "b": [0.7733, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "225", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 252, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "dimensionality down to about 100 dimensions wouldn’t lose too much explained var‐ iance.", "words": [{"w": "dimensionality", "b": [0.1429, 0.0791, 0.2679, 0.1005]}, {"w": "down", "b": [0.273, 0.0791, 0.3203, 0.1005]}, {"w": "to", "b": [0.3253, 0.0791, 0.3423, 0.1005]}, {"w": "about", "b": [0.3474, 0.0791, 0.3952, 0.1005]}, {"w": "100", "b": [0.4002, 0.0791, 0.4302, 0.1005]}, {"w": "dimensions", "b": [0.4353, 0.0791, 0.5321, 0.1005]}, {"w": "wouldn’t", "b": [0.5371, 0.0791, 0.6094, 0.1005]}, {"w": "lose", "b": [0.6144, 0.0791, 0.6468, 0.1005]}, {"w": "too", "b": [0.6519, 0.0791, 0.6795, 0.1005]}, {"w": "much", "b": [0.6846, 0.0791, 0.7322, 0.1005]}, {"w": "explained", "b": [0.7373, 0.0791, 0.8181, 0.1005]}, {"w": "var‐", "b": [0.8232, 0.0791, 0.8571, 0.1005]}, {"w": "iance.", "b": [0.1429, 0.0981, 0.1914, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "Figure 8-8. Explained variance as a function of the number of dimensions", "words": [{"w": "Figure", "b": [0.1429, 0.3568, 0.1943, 0.3784]}, {"w": "8-8.", "b": [0.1991, 0.3568, 0.2308, 0.3784]}, {"w": "Explained", "b": [0.2356, 0.3568, 0.3174, 0.3784]}, {"w": "variance", "b": [0.3222, 0.3568, 0.3917, 0.3784]}, {"w": "as", "b": [0.3965, 0.3568, 0.4137, 0.3784]}, {"w": "a", "b": [0.4185, 0.3568, 0.4287, 0.3784]}, {"w": "function", "b": [0.4334, 0.3568, 0.5015, 0.3784]}, {"w": "of", "b": [0.5063, 0.3568, 0.5215, 0.3784]}, {"w": "the", "b": [0.5263, 0.3568, 0.5513, 0.3784]}, {"w": "number", "b": [0.5561, 0.3568, 0.6197, 0.3784]}, {"w": "of", "b": [0.6245, 0.3568, 0.6397, 0.3784]}, {"w": "dimensions", "b": [0.6444, 0.3568, 0.7359, 0.3784]}]}, {"id": "b_2", "type": "paragraph", "text": "PCA for Compression", "words": [{"w": "PCA", "b": [0.1429, 0.3914, 0.1824, 0.42]}, {"w": "for", "b": [0.1874, 0.3914, 0.2169, 0.42]}, {"w": "Compression", "b": [0.2218, 0.3914, 0.3534, 0.42]}]}, {"id": "b_3", "type": "paragraph", "text": "Obviously after dimensionality reduction, the training set takes up much less space. For example, try applying PCA to the MNIST dataset while preserving 95% of its var‐ iance. You should find that each instance will have just over 150 features, instead of the original 784 features. So while most of the variance is preserved, the dataset is now less than 20% of its original size! This is a reasonable compression ratio, and you can see how this can speed up a classification algorithm (such as an SVM classifier) tremendously.", "words": [{"w": "Obviously", "b": [0.1429, 0.4259, 0.2284, 0.4473]}, {"w": "after", "b": [0.2349, 0.4259, 0.2732, 0.4473]}, {"w": "dimensionality", "b": [0.2797, 0.4259, 0.4047, 0.4473]}, {"w": "reduction,", "b": [0.4113, 0.4259, 0.4974, 0.4473]}, {"w": "the", "b": [0.5039, 0.4259, 0.5303, 0.4473]}, {"w": "training", "b": [0.5368, 0.4259, 0.6037, 0.4473]}, {"w": "set", "b": [0.6102, 0.4259, 0.6331, 0.4473]}, {"w": "takes", "b": [0.6396, 0.4259, 0.6819, 0.4473]}, {"w": "up", "b": [0.6884, 0.4259, 0.7104, 0.4473]}, {"w": "much", "b": [0.7169, 0.4259, 0.7646, 0.4473]}, {"w": "less", "b": [0.7711, 0.4259, 0.8005, 0.4473]}, {"w": "space.", "b": [0.807, 0.4259, 0.8572, 0.4473]}, {"w": "For", "b": [0.1429, 0.4449, 0.1718, 0.4663]}, {"w": "example,", "b": [0.1768, 0.4449, 0.2511, 0.4663]}, {"w": "try", "b": [0.2561, 0.4449, 0.2803, 0.4663]}, {"w": "applying", "b": [0.2853, 0.4449, 0.3574, 0.4663]}, {"w": "PCA", "b": [0.3624, 0.4449, 0.4024, 0.4663]}, {"w": "to", "b": [0.4073, 0.4449, 0.4243, 0.4663]}, {"w": "the", "b": [0.4293, 0.4449, 0.4556, 0.4663]}, {"w": "MNIST", "b": [0.4606, 0.4449, 0.5244, 0.4663]}, {"w": "dataset", "b": [0.5294, 0.4449, 0.5875, 0.4663]}, {"w": "while", "b": [0.5925, 0.4449, 0.6376, 0.4663]}, {"w": "preserving", "b": [0.6425, 0.4449, 0.7312, 0.4663]}, {"w": "95%", "b": [0.7362, 0.4449, 0.7719, 0.4663]}, {"w": "of", "b": [0.7769, 0.4449, 0.7937, 0.4663]}, {"w": "its", "b": [0.7987, 0.4449, 0.8182, 0.4663]}, {"w": "var‐", "b": [0.8232, 0.4449, 0.8571, 0.4663]}, {"w": "iance.", "b": [0.1429, 0.464, 0.1914, 0.4854]}, {"w": "You", "b": [0.1978, 0.464, 0.2302, 0.4854]}, {"w": "should", "b": [0.2366, 0.464, 0.2933, 0.4854]}, {"w": "find", "b": [0.2997, 0.464, 0.3339, 0.4854]}, {"w": "that", "b": [0.3403, 0.464, 0.3729, 0.4854]}, {"w": "each", "b": [0.3793, 0.464, 0.4172, 0.4854]}, {"w": "instance", "b": [0.4236, 0.464, 0.4928, 0.4854]}, {"w": "will", "b": [0.4992, 0.464, 0.5296, 0.4854]}, {"w": "have", "b": [0.5361, 0.464, 0.5745, 0.4854]}, {"w": "just", "b": [0.5809, 0.464, 0.6113, 0.4854]}, {"w": "over", "b": [0.6177, 0.464, 0.6545, 0.4854]}, {"w": "150", "b": [0.661, 0.464, 0.691, 0.4854]}, {"w": "features,", "b": [0.6974, 0.464, 0.7675, 0.4854]}, {"w": "instead", "b": [0.774, 0.464, 0.8339, 0.4854]}, {"w": "of", "b": [0.8403, 0.464, 0.8571, 0.4854]}, {"w": "the", "b": [0.1428, 0.483, 0.1692, 0.5044]}, {"w": "original", "b": [0.1766, 0.483, 0.2417, 0.5044]}, {"w": "784", "b": [0.2492, 0.483, 0.2792, 0.5044]}, {"w": "features.", "b": [0.2867, 0.483, 0.3568, 0.5044]}, {"w": "So", "b": [0.3643, 0.483, 0.3848, 0.5044]}, {"w": "while", "b": [0.3923, 0.483, 0.4374, 0.5044]}, {"w": "most", "b": [0.4448, 0.483, 0.4865, 0.5044]}, {"w": "of", "b": [0.494, 0.483, 0.5108, 0.5044]}, {"w": "the", "b": [0.5182, 0.483, 0.5446, 0.5044]}, {"w": "variance", "b": [0.552, 0.483, 0.6223, 0.5044]}, {"w": "is", "b": [0.6298, 0.483, 0.643, 0.5044]}, {"w": "preserved,", "b": [0.6505, 0.483, 0.7371, 0.5044]}, {"w": "the", "b": [0.7445, 0.483, 0.7709, 0.5044]}, {"w": "dataset", "b": [0.7783, 0.483, 0.8364, 0.5044]}, {"w": "is", "b": [0.8439, 0.483, 0.8571, 0.5044]}, {"w": "now", "b": [0.1429, 0.5021, 0.1792, 0.5235]}, {"w": "less", "b": [0.1842, 0.5021, 0.2136, 0.5235]}, {"w": "than", "b": [0.2186, 0.5021, 0.2567, 0.5235]}, {"w": "20%", "b": [0.2617, 0.5021, 0.2974, 0.5235]}, {"w": "of", "b": [0.3025, 0.5021, 0.3193, 0.5235]}, {"w": "its", "b": [0.3243, 0.5021, 0.3439, 0.5235]}, {"w": "original", "b": [0.3489, 0.5021, 0.414, 0.5235]}, {"w": "size!", "b": [0.419, 0.5021, 0.4556, 0.5235]}, {"w": "This", "b": [0.4606, 0.5021, 0.4978, 0.5235]}, {"w": "is", "b": [0.5029, 0.5021, 0.5161, 0.5235]}, {"w": "a", "b": [0.5211, 0.5021, 0.5303, 0.5235]}, {"w": "reasonable", "b": [0.5353, 0.5021, 0.6245, 0.5235]}, {"w": "compression", "b": [0.6296, 0.5021, 0.7361, 0.5235]}, {"w": "ratio,", "b": [0.7411, 0.5021, 0.7843, 0.5235]}, {"w": "and", "b": [0.7893, 0.5021, 0.8209, 0.5235]}, {"w": "you", "b": [0.8259, 0.5021, 0.8571, 0.5235]}, {"w": "can", "b": [0.1429, 0.5211, 0.1722, 0.5425]}, {"w": "see", "b": [0.1786, 0.5211, 0.2039, 0.5425]}, {"w": "how", "b": [0.2103, 0.5211, 0.2463, 0.5425]}, {"w": "this", "b": [0.2527, 0.5211, 0.2834, 0.5425]}, {"w": "can", "b": [0.2898, 0.5211, 0.3191, 0.5425]}, {"w": "speed", "b": [0.3255, 0.5211, 0.3728, 0.5425]}, {"w": "up", "b": [0.3791, 0.5211, 0.4011, 0.5425]}, {"w": "a", "b": [0.4075, 0.5211, 0.4166, 0.5425]}, {"w": "classification", "b": [0.423, 0.5211, 0.5304, 0.5425]}, {"w": "algorithm", "b": [0.5367, 0.5211, 0.6194, 0.5425]}, {"w": "(such", "b": [0.6258, 0.5211, 0.6716, 0.5425]}, {"w": "as", "b": [0.678, 0.5211, 0.6948, 0.5425]}, {"w": "an", "b": [0.7011, 0.5211, 0.7217, 0.5425]}, {"w": "SVM", "b": [0.728, 0.5211, 0.7711, 0.5425]}, {"w": "classifier)", "b": [0.7775, 0.5211, 0.8571, 0.5425]}, {"w": "tremendously.", "b": [0.1429, 0.5402, 0.2615, 0.5616]}]}, {"id": "b_4", "type": "paragraph", "text": "It is also possible to decompress the reduced dataset back to 784 dimensions by applying the inverse transformation of the PCA projection. Of course this won’t give you back the original data, since the projection lost a bit of information (within the 5% variance that was dropped), but it will likely be quite close to the original data. The mean squared distance between the original data and the reconstructed data (compressed and then decompressed) is called the reconstruction error. For example, the following code compresses the MNIST dataset down to 154 dimensions, then uses the inverse_transform() method to decompress it back to 784 dimensions. Figure 8-9 shows a few digits from the original training set (on the left), and the cor‐ responding digits after compression and decompression. You can see that there is a slight image quality loss, but the digits are still mostly intact.", "words": [{"w": "It", "b": [0.1429, 0.5683, 0.1555, 0.5897]}, {"w": "is", "b": [0.1646, 0.5683, 0.1778, 0.5897]}, {"w": "also", "b": [0.1869, 0.5683, 0.2196, 0.5897]}, {"w": "possible", "b": [0.2287, 0.5683, 0.2958, 0.5897]}, {"w": "to", "b": [0.3049, 0.5683, 0.3219, 0.5897]}, {"w": "decompress", "b": [0.331, 0.5683, 0.4298, 0.5897]}, {"w": "the", "b": [0.4389, 0.5683, 0.4652, 0.5897]}, {"w": "reduced", "b": [0.4743, 0.5683, 0.5416, 0.5897]}, {"w": "dataset", "b": [0.5507, 0.5683, 0.6088, 0.5897]}, {"w": "back", "b": [0.6179, 0.5683, 0.6568, 0.5897]}, {"w": "to", "b": [0.6659, 0.5683, 0.6829, 0.5897]}, {"w": "784", "b": [0.692, 0.5683, 0.722, 0.5897]}, {"w": "dimensions", "b": [0.7311, 0.5683, 0.8279, 0.5897]}, {"w": "by", "b": [0.837, 0.5683, 0.8571, 0.5897]}, {"w": "applying", "b": [0.1429, 0.5873, 0.215, 0.6087]}, {"w": "the", "b": [0.2208, 0.5873, 0.2472, 0.6087]}, {"w": "inverse", "b": [0.253, 0.5873, 0.3123, 0.6087]}, {"w": "transformation", "b": [0.3181, 0.5873, 0.4447, 0.6087]}, {"w": "of", "b": [0.4505, 0.5873, 0.4673, 0.6087]}, {"w": "the", "b": [0.4731, 0.5873, 0.4995, 0.6087]}, {"w": "PCA", "b": [0.5053, 0.5873, 0.5453, 0.6087]}, {"w": "projection.", "b": [0.5511, 0.5873, 0.6421, 0.6087]}, {"w": "Of", "b": [0.6479, 0.5873, 0.6697, 0.6087]}, {"w": "course", "b": [0.6755, 0.5873, 0.7302, 0.6087]}, {"w": "this", "b": [0.7361, 0.5873, 0.7668, 0.6087]}, {"w": "won’t", "b": [0.7726, 0.5873, 0.8175, 0.6087]}, {"w": "give", "b": [0.8233, 0.5873, 0.8572, 0.6087]}, {"w": "you", "b": [0.1429, 0.6064, 0.1741, 0.6278]}, {"w": "back", "b": [0.1806, 0.6064, 0.2194, 0.6278]}, {"w": "the", "b": [0.2259, 0.6064, 0.2522, 0.6278]}, {"w": "original", "b": [0.2587, 0.6064, 0.3238, 0.6278]}, {"w": "data,", "b": [0.3302, 0.6064, 0.3702, 0.6278]}, {"w": "since", "b": [0.3767, 0.6064, 0.419, 0.6278]}, {"w": "the", "b": [0.4254, 0.6064, 0.4518, 0.6278]}, {"w": "projection", "b": [0.4582, 0.6064, 0.5445, 0.6278]}, {"w": "lost", "b": [0.5509, 0.6064, 0.5808, 0.6278]}, {"w": "a", "b": [0.5873, 0.6064, 0.5964, 0.6278]}, {"w": "bit", "b": [0.6029, 0.6064, 0.6254, 0.6278]}, {"w": "of", "b": [0.6319, 0.6064, 0.6486, 0.6278]}, {"w": "information", "b": [0.6551, 0.6064, 0.7564, 0.6278]}, {"w": "(within", "b": [0.7628, 0.6064, 0.8244, 0.6278]}, {"w": "the", "b": [0.8308, 0.6064, 0.8571, 0.6278]}, {"w": "5%", "b": [0.1429, 0.6254, 0.1686, 0.6468]}, {"w": "variance", "b": [0.1756, 0.6254, 0.2459, 0.6468]}, {"w": "that", "b": [0.2529, 0.6254, 0.2855, 0.6468]}, {"w": "was", "b": [0.2925, 0.6254, 0.3235, 0.6468]}, {"w": "dropped),", "b": [0.3305, 0.6254, 0.4135, 0.6468]}, {"w": "but", "b": [0.4205, 0.6254, 0.4485, 0.6468]}, {"w": "it", "b": [0.4555, 0.6254, 0.4674, 0.6468]}, {"w": "will", "b": [0.4744, 0.6254, 0.5048, 0.6468]}, {"w": "likely", "b": [0.5118, 0.6254, 0.5567, 0.6468]}, {"w": "be", "b": [0.5637, 0.6254, 0.5831, 0.6468]}, {"w": "quite", "b": [0.5901, 0.6254, 0.6326, 0.6468]}, {"w": "close", "b": [0.6396, 0.6254, 0.6808, 0.6468]}, {"w": "to", "b": [0.6878, 0.6254, 0.7048, 0.6468]}, {"w": "the", "b": [0.7117, 0.6254, 0.7381, 0.6468]}, {"w": "original", "b": [0.7451, 0.6254, 0.8102, 0.6468]}, {"w": "data.", "b": [0.8171, 0.6254, 0.8571, 0.6468]}, {"w": "The", "b": [0.1428, 0.6445, 0.1757, 0.6659]}, {"w": "mean", "b": [0.1844, 0.6445, 0.2309, 0.6659]}, {"w": "squared", "b": [0.2396, 0.6445, 0.3057, 0.6659]}, {"w": "distance", "b": [0.3144, 0.6445, 0.3832, 0.6659]}, {"w": "between", "b": [0.3919, 0.6445, 0.4611, 0.6659]}, {"w": "the", "b": [0.4698, 0.6445, 0.4961, 0.6659]}, {"w": "original", "b": [0.5048, 0.6445, 0.5699, 0.6659]}, {"w": "data", "b": [0.5786, 0.6445, 0.6139, 0.6659]}, {"w": "and", "b": [0.6226, 0.6445, 0.6542, 0.6659]}, {"w": "the", "b": [0.6629, 0.6445, 0.6892, 0.6659]}, {"w": "reconstructed", "b": [0.6979, 0.6445, 0.8132, 0.6659]}, {"w": "data", "b": [0.8219, 0.6445, 0.8571, 0.6659]}, {"w": "(compressed", "b": [0.1429, 0.6635, 0.2488, 0.6849]}, {"w": "and", "b": [0.2549, 0.6635, 0.2864, 0.6849]}, {"w": "then", "b": [0.2924, 0.6635, 0.3302, 0.6849]}, {"w": "decompressed)", "b": [0.3362, 0.6635, 0.462, 0.6849]}, {"w": "is", "b": [0.4681, 0.6635, 0.4813, 0.6849]}, {"w": "called", "b": [0.4873, 0.6635, 0.5357, 0.6849]}, {"w": "the", "b": [0.5417, 0.6635, 0.5681, 0.6849]}, {"w": "reconstruction", "b": [0.5741, 0.6633, 0.6904, 0.6849]}, {"w": "error.", "b": [0.6965, 0.6633, 0.7418, 0.6849]}, {"w": "For", "b": [0.7478, 0.6635, 0.7768, 0.6849]}, {"w": "example,", "b": [0.7829, 0.6635, 0.8571, 0.6849]}, {"w": "the", "b": [0.1429, 0.6826, 0.1692, 0.704]}, {"w": "following", "b": [0.1739, 0.6826, 0.2529, 0.704]}, {"w": "code", "b": [0.2576, 0.6826, 0.2969, 0.704]}, {"w": "compresses", "b": [0.3016, 0.6826, 0.397, 0.704]}, {"w": "the", "b": [0.4018, 0.6826, 0.4281, 0.704]}, {"w": "MNIST", "b": [0.4328, 0.6826, 0.4967, 0.704]}, {"w": "dataset", "b": [0.5014, 0.6826, 0.5595, 0.704]}, {"w": "down", "b": [0.5643, 0.6826, 0.6115, 0.704]}, {"w": "to", "b": [0.6163, 0.6826, 0.6333, 0.704]}, {"w": "154", "b": [0.638, 0.6826, 0.668, 0.704]}, {"w": "dimensions,", "b": [0.6727, 0.6826, 0.7743, 0.704]}, {"w": "then", "b": [0.779, 0.6826, 0.8167, 0.704]}, {"w": "uses", "b": [0.8214, 0.6826, 0.8567, 0.704]}, {"w": "the", "b": [0.1429, 0.7025, 0.1692, 0.7239]}, {"w": "inverse_transform()", "b": [0.1825, 0.7057, 0.3705, 0.7208]}, {"w": "method", "b": [0.3838, 0.7025, 0.4489, 0.7239]}, {"w": "to", "b": [0.4622, 0.7025, 0.4792, 0.7239]}, {"w": "decompress", "b": [0.4925, 0.7025, 0.5912, 0.7239]}, {"w": "it", "b": [0.6045, 0.7025, 0.6165, 0.7239]}, {"w": "back", "b": [0.6298, 0.7025, 0.6687, 0.7239]}, {"w": "to", "b": [0.682, 0.7025, 0.699, 0.7239]}, {"w": "784", "b": [0.7123, 0.7025, 0.7423, 0.7239]}, {"w": "dimensions.", "b": [0.7556, 0.7025, 0.8571, 0.7239]}, {"w": "Figure", "b": [0.1429, 0.7215, 0.1969, 0.743]}, {"w": "8-9", "b": [0.2023, 0.7215, 0.2298, 0.743]}, {"w": "shows", "b": [0.2352, 0.7215, 0.2866, 0.743]}, {"w": "a", "b": [0.292, 0.7215, 0.3012, 0.743]}, {"w": "few", "b": [0.3067, 0.7215, 0.336, 0.743]}, {"w": "digits", "b": [0.3415, 0.7215, 0.3874, 0.743]}, {"w": "from", "b": [0.3929, 0.7215, 0.4344, 0.743]}, {"w": "the", "b": [0.4399, 0.7215, 0.4663, 0.743]}, {"w": "original", "b": [0.4717, 0.7215, 0.5368, 0.743]}, {"w": "training", "b": [0.5423, 0.7215, 0.6093, 0.743]}, {"w": "set", "b": [0.6147, 0.7215, 0.6376, 0.743]}, {"w": "(on", "b": [0.6431, 0.7215, 0.6723, 0.743]}, {"w": "the", "b": [0.6778, 0.7215, 0.7041, 0.743]}, {"w": "left),", "b": [0.7096, 0.7215, 0.7482, 0.743]}, {"w": "and", "b": [0.7537, 0.7215, 0.7852, 0.743]}, {"w": "the", "b": [0.7907, 0.7215, 0.8171, 0.743]}, {"w": "cor‐", "b": [0.8226, 0.7215, 0.8571, 0.743]}, {"w": "responding", "b": [0.1429, 0.7406, 0.2378, 0.762]}, {"w": "digits", "b": [0.2445, 0.7406, 0.2904, 0.762]}, {"w": "after", "b": [0.2972, 0.7406, 0.3355, 0.762]}, {"w": "compression", "b": [0.3422, 0.7406, 0.4487, 0.762]}, {"w": "and", "b": [0.4555, 0.7406, 0.487, 0.762]}, {"w": "decompression.", "b": [0.4938, 0.7406, 0.6249, 0.762]}, {"w": "You", "b": [0.6316, 0.7406, 0.664, 0.762]}, {"w": "can", "b": [0.6708, 0.7406, 0.7001, 0.762]}, {"w": "see", "b": [0.7069, 0.7406, 0.7322, 0.762]}, {"w": "that", "b": [0.739, 0.7406, 0.7716, 0.762]}, {"w": "there", "b": [0.7783, 0.7406, 0.8213, 0.762]}, {"w": "is", "b": [0.828, 0.7406, 0.8412, 0.762]}, {"w": "a", "b": [0.848, 0.7406, 0.8572, 0.762]}, {"w": "slight", "b": [0.1429, 0.7596, 0.1882, 0.7811]}, {"w": "image", "b": [0.1929, 0.7596, 0.2433, 0.7811]}, {"w": "quality", "b": [0.248, 0.7596, 0.3057, 0.7811]}, {"w": "loss,", "b": [0.3104, 0.7596, 0.3463, 0.7811]}, {"w": "but", "b": [0.3511, 0.7596, 0.3791, 0.7811]}, {"w": "the", "b": [0.3838, 0.7596, 0.4101, 0.7811]}, {"w": "digits", "b": [0.4149, 0.7596, 0.4608, 0.7811]}, {"w": "are", "b": [0.4655, 0.7596, 0.4912, 0.7811]}, {"w": "still", "b": [0.496, 0.7596, 0.5261, 0.7811]}, {"w": "mostly", "b": [0.5308, 0.7596, 0.5873, 0.7811]}, {"w": "intact.", "b": [0.5921, 0.7596, 0.6441, 0.7811]}]}, {"id": "b_5", "type": "paragraph", "text": "pca = PCA(n_components = 154) X_reduced = pca.fit_transform(X_train) X_recovered = pca.inverse_transform(X_reduced)", "words": [{"w": "pca", "b": [0.1766, 0.7916, 0.2019, 0.8045]}, {"w": "=", "b": [0.2103, 0.7916, 0.2187, 0.8045]}, {"w": "PCA(n_components", "b": [0.2272, 0.7916, 0.3621, 0.8045]}, {"w": "=", "b": [0.3705, 0.7916, 0.379, 0.8045]}, {"w": "154)", "b": [0.3874, 0.7916, 0.4211, 0.8045]}, {"w": "X_reduced", "b": [0.1766, 0.807, 0.2525, 0.8199]}, {"w": "=", "b": [0.2609, 0.807, 0.2693, 0.8199]}, {"w": "pca.fit_transform(X_train)", "b": [0.2778, 0.807, 0.497, 0.8199]}, {"w": "X_recovered", "b": [0.1766, 0.8225, 0.2693, 0.8353]}, {"w": "=", "b": [0.2778, 0.8225, 0.2862, 0.8353]}, {"w": "pca.inverse_transform(X_reduced)", "b": [0.2946, 0.8225, 0.5645, 0.8353]}]}, {"id": "b_6", "type": "paragraph", "text": "226 | Chapter 8: Dimensionality Reduction", "words": [{"w": "226", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "8:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Dimensionality", "b": [0.2673, 0.9225, 0.3562, 0.9388]}, {"w": "Reduction", "b": [0.359, 0.9225, 0.4186, 0.9388]}]}]}, {"page": 253, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 8-9. MNIST compression preserving 95% of the variance", "words": [{"w": "Figure", "b": [0.1429, 0.32, 0.1943, 0.3416]}, {"w": "8-9.", "b": [0.1991, 0.32, 0.2308, 0.3416]}, {"w": "MNIST", "b": [0.2356, 0.32, 0.2974, 0.3416]}, {"w": "compression", "b": [0.3022, 0.32, 0.4008, 0.3416]}, {"w": "preserving", "b": [0.4056, 0.32, 0.4889, 0.3416]}, {"w": "95%", "b": [0.4937, 0.32, 0.5292, 0.3416]}, {"w": "of", "b": [0.534, 0.32, 0.5492, 0.3416]}, {"w": "the", "b": [0.554, 0.32, 0.579, 0.3416]}, {"w": "variance", "b": [0.5838, 0.32, 0.6533, 0.3416]}]}, {"id": "b_1", "type": "equation", "text": "The equation of the inverse transformation is shown in Equation 8-3.", "words": [{"w": "The", "b": [0.1429, 0.3574, 0.1757, 0.3788]}, {"w": "equation", "b": [0.1804, 0.3574, 0.2537, 0.3788]}, {"w": "of", "b": [0.2584, 0.3574, 0.2752, 0.3788]}, {"w": "the", "b": [0.2799, 0.3574, 0.3063, 0.3788]}, {"w": "inverse", "b": [0.311, 0.3574, 0.3702, 0.3788]}, {"w": "transformation", "b": [0.375, 0.3574, 0.5015, 0.3788]}, {"w": "is", "b": [0.5063, 0.3574, 0.5195, 0.3788]}, {"w": "shown", "b": [0.5242, 0.3574, 0.5793, 0.3788]}, {"w": "in", "b": [0.584, 0.3574, 0.601, 0.3788]}, {"w": "Equation", "b": [0.6057, 0.3574, 0.682, 0.3788]}, {"w": "8-3.", "b": [0.6867, 0.3574, 0.7189, 0.3788]}]}, {"id": "b_2", "type": "paragraph", "text": "Equation 8-3. PCA inverse transformation, back to the original number of dimensions", "words": [{"w": "Equation", "b": [0.1726, 0.3969, 0.2473, 0.4186]}, {"w": "8-3.", "b": [0.2521, 0.3969, 0.2838, 0.4186]}, {"w": "PCA", "b": [0.2886, 0.3969, 0.3272, 0.4186]}, {"w": "inverse", "b": [0.3319, 0.3969, 0.3884, 0.4186]}, {"w": "transformation,", "b": [0.3932, 0.3969, 0.5207, 0.4186]}, {"w": "back", "b": [0.5255, 0.3969, 0.5631, 0.4186]}, {"w": "to", "b": [0.5679, 0.3969, 0.5839, 0.4186]}, {"w": "the", "b": [0.5886, 0.3969, 0.6137, 0.4186]}, {"w": "original", "b": [0.6184, 0.3969, 0.6817, 0.4186]}, {"w": "number", "b": [0.6865, 0.3969, 0.7501, 0.4186]}, {"w": "of", "b": [0.7548, 0.3969, 0.77, 0.4186]}, {"w": "dimensions", "b": [0.1726, 0.412, 0.2641, 0.4336]}]}, {"id": "b_3", "type": "equation", "text": "Xrecovered = Xd‐projWd", "words": [{"w": "Xrecovered", "b": [0.1726, 0.444, 0.2489, 0.4692]}, {"w": "=", "b": [0.2544, 0.4445, 0.2659, 0.4649]}, {"w": "Xd‐projWd", "b": [0.2715, 0.444, 0.353, 0.4692]}]}, {"id": "b_5", "type": "paragraph", "text": "Randomized PCA", "words": [{"w": "Randomized", "b": [0.1428, 0.4855, 0.2717, 0.5141]}, {"w": "PCA", "b": [0.2767, 0.4855, 0.3162, 0.5141]}]}, {"id": "b_6", "type": "paragraph", "text": "If you set the svd_solver hyperparameter to \"randomized\", Scikit-Learn uses a sto‐ chastic algorithm called Randomized PCA that quickly finds an approximation of the first d principal components. Its computational complexity is O(m × d2) + O(d3), instead of O(m × n2) + O(n3) for the full SVD approach, so it is dramatically faster than full SVD when d is much smaller than n:", "words": [{"w": "If", "b": [0.1429, 0.5209, 0.1561, 0.5423]}, {"w": "you", "b": [0.1624, 0.5209, 0.1937, 0.5423]}, {"w": "set", "b": [0.1999, 0.5209, 0.2228, 0.5423]}, {"w": "the", "b": [0.229, 0.5209, 0.2554, 0.5423]}, {"w": "svd_solver", "b": [0.2616, 0.524, 0.3606, 0.5391]}, {"w": "hyperparameter", "b": [0.3669, 0.5209, 0.5004, 0.5423]}, {"w": "to", "b": [0.5066, 0.5209, 0.5236, 0.5423]}, {"w": "\"randomized\",", "b": [0.5299, 0.5209, 0.6534, 0.5423]}, {"w": "Scikit-Learn", "b": [0.6597, 0.5209, 0.7619, 0.5423]}, {"w": "uses", "b": [0.7682, 0.5209, 0.8034, 0.5423]}, {"w": "a", "b": [0.8097, 0.5209, 0.8188, 0.5423]}, {"w": "sto‐", "b": [0.8251, 0.5209, 0.8571, 0.5423]}, {"w": "chastic", "b": [0.1429, 0.5399, 0.2003, 0.5613]}, {"w": "algorithm", "b": [0.2059, 0.5399, 0.2885, 0.5613]}, {"w": "called", "b": [0.2941, 0.5399, 0.3425, 0.5613]}, {"w": "Randomized", "b": [0.348, 0.5397, 0.4506, 0.5613]}, {"w": "PCA", "b": [0.4562, 0.5397, 0.4948, 0.5613]}, {"w": "that", "b": [0.5004, 0.5399, 0.533, 0.5613]}, {"w": "quickly", "b": [0.5385, 0.5399, 0.5998, 0.5613]}, {"w": "finds", "b": [0.6053, 0.5399, 0.6471, 0.5613]}, {"w": "an", "b": [0.6527, 0.5399, 0.6732, 0.5613]}, {"w": "approximation", "b": [0.6788, 0.5399, 0.8029, 0.5613]}, {"w": "of", "b": [0.8085, 0.5399, 0.8253, 0.5613]}, {"w": "the", "b": [0.8308, 0.5399, 0.8571, 0.5613]}, {"w": "first", "b": [0.1429, 0.559, 0.1763, 0.5804]}, {"w": "d", "b": [0.1849, 0.5588, 0.1955, 0.5804]}, {"w": "principal", "b": [0.2041, 0.559, 0.2794, 0.5804]}, {"w": "components.", "b": [0.288, 0.559, 0.3956, 0.5804]}, {"w": "Its", "b": [0.4042, 0.559, 0.4245, 0.5804]}, {"w": "computational", "b": [0.4331, 0.559, 0.5546, 0.5804]}, {"w": "complexity", "b": [0.5632, 0.559, 0.6557, 0.5804]}, {"w": "is", "b": [0.6642, 0.559, 0.6775, 0.5804]}, {"w": "O(m", "b": [0.686, 0.5588, 0.7244, 0.5804]}, {"w": "×", "b": [0.733, 0.559, 0.7451, 0.5804]}, {"w": "d2)", "b": [0.7536, 0.5588, 0.7774, 0.5804]}, {"w": "+", "b": [0.786, 0.559, 0.7981, 0.5804]}, {"w": "O(d3),", "b": [0.8066, 0.5588, 0.8571, 0.5804]}, {"w": "instead", "b": [0.1429, 0.578, 0.2028, 0.5994]}, {"w": "of", "b": [0.2097, 0.578, 0.2265, 0.5994]}, {"w": "O(m", "b": [0.2334, 0.5778, 0.2718, 0.5994]}, {"w": "×", "b": [0.2787, 0.578, 0.2907, 0.5994]}, {"w": "n2)", "b": [0.2976, 0.5778, 0.3219, 0.5994]}, {"w": "+", "b": [0.3288, 0.578, 0.3409, 0.5994]}, {"w": "O(n3)", "b": [0.3478, 0.5778, 0.394, 0.5994]}, {"w": "for", "b": [0.4009, 0.578, 0.4254, 0.5994]}, {"w": "the", "b": [0.4323, 0.578, 0.4586, 0.5994]}, {"w": "full", "b": [0.4655, 0.578, 0.4933, 0.5994]}, {"w": "SVD", "b": [0.5002, 0.578, 0.54, 0.5994]}, {"w": "approach,", "b": [0.5469, 0.578, 0.6297, 0.5994]}, {"w": "so", "b": [0.6366, 0.578, 0.6548, 0.5994]}, {"w": "it", "b": [0.6617, 0.578, 0.6737, 0.5994]}, {"w": "is", "b": [0.6806, 0.578, 0.6938, 0.5994]}, {"w": "dramatically", "b": [0.7007, 0.578, 0.8044, 0.5994]}, {"w": "faster", "b": [0.8112, 0.578, 0.8571, 0.5994]}, {"w": "than", "b": [0.1429, 0.5971, 0.1809, 0.6185]}, {"w": "full", "b": [0.1856, 0.5971, 0.2134, 0.6185]}, {"w": "SVD", "b": [0.2181, 0.5971, 0.2579, 0.6185]}, {"w": "when", "b": [0.2627, 0.5971, 0.3083, 0.6185]}, {"w": "d", "b": [0.313, 0.5968, 0.3236, 0.6185]}, {"w": "is", "b": [0.3284, 0.5971, 0.3416, 0.6185]}, {"w": "much", "b": [0.3463, 0.5971, 0.394, 0.6185]}, {"w": "smaller", "b": [0.3987, 0.5971, 0.4597, 0.6185]}, {"w": "than", "b": [0.4644, 0.5971, 0.5024, 0.6185]}, {"w": "n:", "b": [0.5072, 0.5968, 0.523, 0.6185]}]}, {"id": "b_7", "type": "paragraph", "text": "rnd_pca = PCA(n_components=154, svd_solver=\"randomized\") X_reduced = rnd_pca.fit_transform(X_train)", "words": [{"w": "rnd_pca", "b": [0.1766, 0.629, 0.2356, 0.6419]}, {"w": "=", "b": [0.244, 0.629, 0.2525, 0.6419]}, {"w": "PCA(n_components=154,", "b": [0.2609, 0.629, 0.438, 0.6419]}, {"w": "svd_solver=\"randomized\")", "b": [0.4464, 0.629, 0.6488, 0.6419]}, {"w": "X_reduced", "b": [0.1766, 0.6444, 0.2525, 0.6573]}, {"w": "=", "b": [0.2609, 0.6444, 0.2693, 0.6573]}, {"w": "rnd_pca.fit_transform(X_train)", "b": [0.2778, 0.6444, 0.5308, 0.6573]}]}, {"id": "b_8", "type": "paragraph", "text": "By default, svd_solver is actually set to \"auto\": Scikit-Learn automatically uses the randomized PCA algorithm if m or n is greater than 500 and d is less than 80% of m or n, or else it uses the full SVD approach. If you want to force Scikit-Learn to use full SVD, you can set the svd_solver hyperparameter to \"full\".", "words": [{"w": "By", "b": [0.1429, 0.666, 0.1647, 0.6874]}, {"w": "default,", "b": [0.1713, 0.666, 0.2335, 0.6874]}, {"w": "svd_solver", "b": [0.2402, 0.6692, 0.3391, 0.6842]}, {"w": "is", "b": [0.3458, 0.666, 0.359, 0.6874]}, {"w": "actually", "b": [0.3656, 0.666, 0.4303, 0.6874]}, {"w": "set", "b": [0.4369, 0.666, 0.4598, 0.6874]}, {"w": "to", "b": [0.4664, 0.666, 0.4834, 0.6874]}, {"w": "\"auto\":", "b": [0.49, 0.666, 0.5541, 0.6874]}, {"w": "Scikit-Learn", "b": [0.5608, 0.666, 0.6631, 0.6874]}, {"w": "automatically", "b": [0.6697, 0.666, 0.7823, 0.6874]}, {"w": "uses", "b": [0.789, 0.666, 0.8242, 0.6874]}, {"w": "the", "b": [0.8308, 0.666, 0.8571, 0.6874]}, {"w": "randomized", "b": [0.1429, 0.685, 0.244, 0.7064]}, {"w": "PCA", "b": [0.2497, 0.685, 0.2896, 0.7064]}, {"w": "algorithm", "b": [0.2953, 0.685, 0.378, 0.7064]}, {"w": "if", "b": [0.3836, 0.685, 0.3954, 0.7064]}, {"w": "m", "b": [0.401, 0.6848, 0.4174, 0.7064]}, {"w": "or", "b": [0.4231, 0.685, 0.4414, 0.7064]}, {"w": "n", "b": [0.4471, 0.6848, 0.4582, 0.7064]}, {"w": "is", "b": [0.4638, 0.685, 0.4771, 0.7064]}, {"w": "greater", "b": [0.4827, 0.685, 0.5408, 0.7064]}, {"w": "than", "b": [0.5464, 0.685, 0.5844, 0.7064]}, {"w": "500", "b": [0.5901, 0.685, 0.6201, 0.7064]}, {"w": "and", "b": [0.6258, 0.685, 0.6573, 0.7064]}, {"w": "d", "b": [0.663, 0.6848, 0.6736, 0.7064]}, {"w": "is", "b": [0.6792, 0.685, 0.6925, 0.7064]}, {"w": "less", "b": [0.6981, 0.685, 0.7275, 0.7064]}, {"w": "than", "b": [0.7332, 0.685, 0.7712, 0.7064]}, {"w": "80%", "b": [0.7769, 0.685, 0.8126, 0.7064]}, {"w": "of", "b": [0.8183, 0.685, 0.8351, 0.7064]}, {"w": "m", "b": [0.8407, 0.6848, 0.8571, 0.7064]}, {"w": "or", "b": [0.1429, 0.7041, 0.1612, 0.7255]}, {"w": "n,", "b": [0.1661, 0.7039, 0.182, 0.7255]}, {"w": "or", "b": [0.1869, 0.7041, 0.2052, 0.7255]}, {"w": "else", "b": [0.2101, 0.7041, 0.2407, 0.7255]}, {"w": "it", "b": [0.2456, 0.7041, 0.2576, 0.7255]}, {"w": "uses", "b": [0.2625, 0.7041, 0.2977, 0.7255]}, {"w": "the", "b": [0.3026, 0.7041, 0.3289, 0.7255]}, {"w": "full", "b": [0.3338, 0.7041, 0.3616, 0.7255]}, {"w": "SVD", "b": [0.3665, 0.7041, 0.4063, 0.7255]}, {"w": "approach.", "b": [0.4112, 0.7041, 0.494, 0.7255]}, {"w": "If", "b": [0.4989, 0.7041, 0.5122, 0.7255]}, {"w": "you", "b": [0.5171, 0.7041, 0.5483, 0.7255]}, {"w": "want", "b": [0.5532, 0.7041, 0.594, 0.7255]}, {"w": "to", "b": [0.5989, 0.7041, 0.6159, 0.7255]}, {"w": "force", "b": [0.6208, 0.7041, 0.6629, 0.7255]}, {"w": "Scikit-Learn", "b": [0.6678, 0.7041, 0.7701, 0.7255]}, {"w": "to", "b": [0.775, 0.7041, 0.792, 0.7255]}, {"w": "use", "b": [0.7969, 0.7041, 0.8245, 0.7255]}, {"w": "full", "b": [0.8294, 0.7041, 0.8572, 0.7255]}, {"w": "SVD,", "b": [0.1429, 0.724, 0.1866, 0.7454]}, {"w": "you", "b": [0.1913, 0.724, 0.2226, 0.7454]}, {"w": "can", "b": [0.2273, 0.724, 0.2567, 0.7454]}, {"w": "set", "b": [0.2614, 0.724, 0.2843, 0.7454]}, {"w": "the", "b": [0.289, 0.724, 0.3153, 0.7454]}, {"w": "svd_solver", "b": [0.32, 0.7272, 0.419, 0.7423]}, {"w": "hyperparameter", "b": [0.4237, 0.724, 0.5572, 0.7454]}, {"w": "to", "b": [0.562, 0.724, 0.5789, 0.7454]}, {"w": "\"full\".", "b": [0.5837, 0.724, 0.6478, 0.7454]}]}, {"id": "b_9", "type": "paragraph", "text": "Incremental PCA", "words": [{"w": "Incremental", "b": [0.1429, 0.7582, 0.2684, 0.7868]}, {"w": "PCA", "b": [0.2734, 0.7582, 0.3129, 0.7868]}]}, {"id": "b_10", "type": "paragraph", "text": "One problem with the preceding implementations of PCA is that they require the whole training set to fit in memory in order for the algorithm to run. Fortunately, Incremental PCA (IPCA) algorithms have been developed: you can split the training set into mini-batches and feed an IPCA algorithm one mini-batch at a time. This is", "words": [{"w": "One", "b": [0.1429, 0.7927, 0.1787, 0.8141]}, {"w": "problem", "b": [0.1866, 0.7927, 0.2576, 0.8141]}, {"w": "with", "b": [0.2655, 0.7927, 0.3028, 0.8141]}, {"w": "the", "b": [0.3107, 0.7927, 0.337, 0.8141]}, {"w": "preceding", "b": [0.3449, 0.7927, 0.4278, 0.8141]}, {"w": "implementations", "b": [0.4357, 0.7927, 0.5766, 0.8141]}, {"w": "of", "b": [0.5845, 0.7927, 0.6013, 0.8141]}, {"w": "PCA", "b": [0.6092, 0.7927, 0.6492, 0.8141]}, {"w": "is", "b": [0.6571, 0.7927, 0.6703, 0.8141]}, {"w": "that", "b": [0.6782, 0.7927, 0.7108, 0.8141]}, {"w": "they", "b": [0.7187, 0.7927, 0.7546, 0.8141]}, {"w": "require", "b": [0.7625, 0.7927, 0.8229, 0.8141]}, {"w": "the", "b": [0.8308, 0.7927, 0.8571, 0.8141]}, {"w": "whole", "b": [0.1429, 0.8117, 0.193, 0.8331]}, {"w": "training", "b": [0.2003, 0.8117, 0.2673, 0.8331]}, {"w": "set", "b": [0.2746, 0.8117, 0.2975, 0.8331]}, {"w": "to", "b": [0.3048, 0.8117, 0.3218, 0.8331]}, {"w": "fit", "b": [0.3291, 0.8117, 0.3472, 0.8331]}, {"w": "in", "b": [0.3545, 0.8117, 0.3715, 0.8331]}, {"w": "memory", "b": [0.3789, 0.8117, 0.4504, 0.8331]}, {"w": "in", "b": [0.4577, 0.8117, 0.4747, 0.8331]}, {"w": "order", "b": [0.482, 0.8117, 0.5279, 0.8331]}, {"w": "for", "b": [0.5353, 0.8117, 0.5598, 0.8331]}, {"w": "the", "b": [0.5671, 0.8117, 0.5935, 0.8331]}, {"w": "algorithm", "b": [0.6008, 0.8117, 0.6834, 0.8331]}, {"w": "to", "b": [0.6908, 0.8117, 0.7077, 0.8331]}, {"w": "run.", "b": [0.7151, 0.8117, 0.75, 0.8331]}, {"w": "Fortunately,", "b": [0.7573, 0.8117, 0.8572, 0.8331]}, {"w": "Incremental", "b": [0.1429, 0.8306, 0.24, 0.8522]}, {"w": "PCA", "b": [0.2464, 0.8306, 0.285, 0.8522]}, {"w": "(IPCA)", "b": [0.2913, 0.8308, 0.3528, 0.8522]}, {"w": "algorithms", "b": [0.3591, 0.8308, 0.4493, 0.8522]}, {"w": "have", "b": [0.4556, 0.8308, 0.494, 0.8522]}, {"w": "been", "b": [0.5003, 0.8308, 0.54, 0.8522]}, {"w": "developed:", "b": [0.5463, 0.8308, 0.6361, 0.8522]}, {"w": "you", "b": [0.6424, 0.8308, 0.6736, 0.8522]}, {"w": "can", "b": [0.6799, 0.8308, 0.7092, 0.8522]}, {"w": "split", "b": [0.7155, 0.8308, 0.7513, 0.8522]}, {"w": "the", "b": [0.7576, 0.8308, 0.7839, 0.8522]}, {"w": "training", "b": [0.7902, 0.8308, 0.8571, 0.8522]}, {"w": "set", "b": [0.1429, 0.8498, 0.1657, 0.8712]}, {"w": "into", "b": [0.1722, 0.8498, 0.2058, 0.8712]}, {"w": "mini-batches", "b": [0.2123, 0.8498, 0.3215, 0.8712]}, {"w": "and", "b": [0.328, 0.8498, 0.3595, 0.8712]}, {"w": "feed", "b": [0.366, 0.8498, 0.4009, 0.8712]}, {"w": "an", "b": [0.4074, 0.8498, 0.428, 0.8712]}, {"w": "IPCA", "b": [0.4345, 0.8498, 0.4816, 0.8712]}, {"w": "algorithm", "b": [0.4881, 0.8498, 0.5707, 0.8712]}, {"w": "one", "b": [0.5772, 0.8498, 0.6081, 0.8712]}, {"w": "mini-batch", "b": [0.6146, 0.8498, 0.7073, 0.8712]}, {"w": "at", "b": [0.7138, 0.8498, 0.7289, 0.8712]}, {"w": "a", "b": [0.7354, 0.8498, 0.7446, 0.8712]}, {"w": "time.", "b": [0.7511, 0.8498, 0.7937, 0.8712]}, {"w": "This", "b": [0.8002, 0.8498, 0.8374, 0.8712]}, {"w": "is", "b": [0.8439, 0.8498, 0.8571, 0.8712]}]}, {"id": "b_11", "type": "paragraph", "text": "PCA | 227", "words": [{"w": "PCA", "b": [0.7732, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "227", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 254, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "5 Scikit-Learn uses the algorithm described in “Incremental Learning for Robust Visual Tracking,” D. Ross et al. (2007).", "words": [{"w": "5", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Scikit-Learn", "b": [0.1587, 0.8598, 0.2367, 0.8761]}, {"w": "uses", "b": [0.2403, 0.8598, 0.2671, 0.8761]}, {"w": "the", "b": [0.2707, 0.8598, 0.2908, 0.8761]}, {"w": "algorithm", "b": [0.2944, 0.8598, 0.3573, 0.8761]}, {"w": "described", "b": [0.3609, 0.8598, 0.4219, 0.8761]}, {"w": "in", "b": [0.4255, 0.8598, 0.4385, 0.8761]}, {"w": "“Incremental", "b": [0.4421, 0.8598, 0.5258, 0.8761]}, {"w": "Learning", "b": [0.5294, 0.8598, 0.5866, 0.8761]}, {"w": "for", "b": [0.5902, 0.8598, 0.6089, 0.8761]}, {"w": "Robust", "b": [0.6125, 0.8598, 0.6576, 0.8761]}, {"w": "Visual", "b": [0.6612, 0.8598, 0.7012, 0.8761]}, {"w": "Tracking,”", "b": [0.7048, 0.8598, 0.7689, 0.8761]}, {"w": "D.", "b": [0.7725, 0.8598, 0.7871, 0.8761]}, {"w": "Ross", "b": [0.7907, 0.8598, 0.8203, 0.8761]}, {"w": "et", "b": [0.8239, 0.8598, 0.8355, 0.8761]}, {"w": "al.", "b": [0.8391, 0.8598, 0.8537, 0.8761]}, {"w": "(2007).", "b": [0.1587, 0.8749, 0.2038, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "useful for large training sets, and also to apply PCA online (i.e., on the fly, as new instances arrive).", "words": [{"w": "useful", "b": [0.1429, 0.0791, 0.1929, 0.1005]}, {"w": "for", "b": [0.2002, 0.0791, 0.2248, 0.1005]}, {"w": "large", "b": [0.2321, 0.0791, 0.2728, 0.1005]}, {"w": "training", "b": [0.2802, 0.0791, 0.3471, 0.1005]}, {"w": "sets,", "b": [0.3544, 0.0791, 0.3897, 0.1005]}, {"w": "and", "b": [0.397, 0.0791, 0.4286, 0.1005]}, {"w": "also", "b": [0.4359, 0.0791, 0.4686, 0.1005]}, {"w": "to", "b": [0.4759, 0.0791, 0.4929, 0.1005]}, {"w": "apply", "b": [0.5002, 0.0791, 0.5456, 0.1005]}, {"w": "PCA", "b": [0.5529, 0.0791, 0.5929, 0.1005]}, {"w": "online", "b": [0.6003, 0.0791, 0.6534, 0.1005]}, {"w": "(i.e.,", "b": [0.6607, 0.0791, 0.6966, 0.1005]}, {"w": "on", "b": [0.7039, 0.0791, 0.726, 0.1005]}, {"w": "the", "b": [0.7333, 0.0791, 0.7596, 0.1005]}, {"w": "fly,", "b": [0.7669, 0.0791, 0.7912, 0.1005]}, {"w": "as", "b": [0.7985, 0.0791, 0.8153, 0.1005]}, {"w": "new", "b": [0.8226, 0.0791, 0.8571, 0.1005]}, {"w": "instances", "b": [0.1429, 0.0981, 0.2197, 0.1195]}, {"w": "arrive).", "b": [0.2244, 0.0981, 0.2851, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "The following code splits the MNIST dataset into 100 mini-batches (using NumPy’s array_split() function) and feeds them to Scikit-Learn’s IncrementalPCA class5 to reduce the dimensionality of the MNIST dataset down to 154 dimensions (just like before). Note that you must call the partial_fit() method with each mini-batch rather than the fit() method with the whole training set:", "words": [{"w": "The", "b": [0.1429, 0.1262, 0.1757, 0.1476]}, {"w": "following", "b": [0.1822, 0.1262, 0.2612, 0.1476]}, {"w": "code", "b": [0.2677, 0.1262, 0.307, 0.1476]}, {"w": "splits", "b": [0.3135, 0.1262, 0.3569, 0.1476]}, {"w": "the", "b": [0.3634, 0.1262, 0.3897, 0.1476]}, {"w": "MNIST", "b": [0.3963, 0.1262, 0.4601, 0.1476]}, {"w": "dataset", "b": [0.4666, 0.1262, 0.5247, 0.1476]}, {"w": "into", "b": [0.5313, 0.1262, 0.5648, 0.1476]}, {"w": "100", "b": [0.5713, 0.1262, 0.6013, 0.1476]}, {"w": "mini-batches", "b": [0.6078, 0.1262, 0.717, 0.1476]}, {"w": "(using", "b": [0.7235, 0.1262, 0.7762, 0.1476]}, {"w": "NumPy’s", "b": [0.7827, 0.1262, 0.8572, 0.1476]}, {"w": "array_split()", "b": [0.1429, 0.1494, 0.2715, 0.1644]}, {"w": "function)", "b": [0.2777, 0.1462, 0.3563, 0.1676]}, {"w": "and", "b": [0.3625, 0.1462, 0.394, 0.1676]}, {"w": "feeds", "b": [0.4002, 0.1462, 0.4427, 0.1676]}, {"w": "them", "b": [0.4489, 0.1462, 0.4923, 0.1676]}, {"w": "to", "b": [0.4985, 0.1462, 0.5155, 0.1676]}, {"w": "Scikit-Learn’s", "b": [0.5217, 0.1462, 0.6326, 0.1676]}, {"w": "IncrementalPCA", "b": [0.6388, 0.1494, 0.7773, 0.1644]}, {"w": "class5", "b": [0.7835, 0.1462, 0.8278, 0.1676]}, {"w": "to", "b": [0.834, 0.1462, 0.851, 0.1676]}, {"w": "reduce", "b": [0.1429, 0.1652, 0.1992, 0.1866]}, {"w": "the", "b": [0.2061, 0.1652, 0.2324, 0.1866]}, {"w": "dimensionality", "b": [0.2393, 0.1652, 0.3644, 0.1866]}, {"w": "of", "b": [0.3713, 0.1652, 0.388, 0.1866]}, {"w": "the", "b": [0.3949, 0.1652, 0.4213, 0.1866]}, {"w": "MNIST", "b": [0.4282, 0.1652, 0.4921, 0.1866]}, {"w": "dataset", "b": [0.4989, 0.1652, 0.5571, 0.1866]}, {"w": "down", "b": [0.5639, 0.1652, 0.6112, 0.1866]}, {"w": "to", "b": [0.6181, 0.1652, 0.6351, 0.1866]}, {"w": "154", "b": [0.642, 0.1652, 0.672, 0.1866]}, {"w": "dimensions", "b": [0.6789, 0.1652, 0.7757, 0.1866]}, {"w": "(just", "b": [0.7826, 0.1652, 0.8202, 0.1866]}, {"w": "like", "b": [0.8271, 0.1652, 0.8571, 0.1866]}, {"w": "before).", "b": [0.1429, 0.1852, 0.2076, 0.2066]}, {"w": "Note", "b": [0.2155, 0.1852, 0.2563, 0.2066]}, {"w": "that", "b": [0.2642, 0.1852, 0.2968, 0.2066]}, {"w": "you", "b": [0.3046, 0.1852, 0.3359, 0.2066]}, {"w": "must", "b": [0.3438, 0.1852, 0.3855, 0.2066]}, {"w": "call", "b": [0.3934, 0.1852, 0.4219, 0.2066]}, {"w": "the", "b": [0.4298, 0.1852, 0.4561, 0.2066]}, {"w": "partial_fit()", "b": [0.464, 0.1883, 0.5926, 0.2034]}, {"w": "method", "b": [0.6005, 0.1852, 0.6655, 0.2066]}, {"w": "with", "b": [0.6734, 0.1852, 0.7108, 0.2066]}, {"w": "each", "b": [0.7186, 0.1852, 0.7566, 0.2066]}, {"w": "mini-batch", "b": [0.7645, 0.1852, 0.8571, 0.2066]}, {"w": "rather", "b": [0.1429, 0.2051, 0.1934, 0.2265]}, {"w": "than", "b": [0.1981, 0.2051, 0.2362, 0.2265]}, {"w": "the", "b": [0.2409, 0.2051, 0.2672, 0.2265]}, {"w": "fit()", "b": [0.2719, 0.2083, 0.3214, 0.2234]}, {"w": "method", "b": [0.3262, 0.2051, 0.3912, 0.2265]}, {"w": "with", "b": [0.3959, 0.2051, 0.4332, 0.2265]}, {"w": "the", "b": [0.438, 0.2051, 0.4643, 0.2265]}, {"w": "whole", "b": [0.469, 0.2051, 0.5192, 0.2265]}, {"w": "training", "b": [0.5239, 0.2051, 0.5908, 0.2265]}, {"w": "set:", "b": [0.5956, 0.2051, 0.6232, 0.2265]}]}, {"id": "b_3", "type": "paragraph", "text": "from sklearn.decomposition import IncrementalPCA", "words": [{"w": "from", "b": [0.1766, 0.2371, 0.2103, 0.2499]}, {"w": "sklearn.decomposition", "b": [0.2188, 0.2371, 0.3958, 0.2499]}, {"w": "import", "b": [0.4043, 0.2371, 0.4549, 0.2499]}, {"w": "IncrementalPCA", "b": [0.4633, 0.2371, 0.5814, 0.2499]}]}, {"id": "b_4", "type": "paragraph", "text": "n_batches = 100 inc_pca = IncrementalPCA(n_components=154) for X_batch in np.array_split(X_train, n_batches): inc_pca.partial_fit(X_batch)", "words": [{"w": "n_batches", "b": [0.1766, 0.2679, 0.2525, 0.2808]}, {"w": "=", "b": [0.2609, 0.2679, 0.2693, 0.2808]}, {"w": "100", "b": [0.2778, 0.2679, 0.3031, 0.2808]}, {"w": "inc_pca", "b": [0.1766, 0.2833, 0.2356, 0.2962]}, {"w": "=", "b": [0.2441, 0.2833, 0.2525, 0.2962]}, {"w": "IncrementalPCA(n_components=154)", "b": [0.2609, 0.2833, 0.5308, 0.2962]}, {"w": "for", "b": [0.1766, 0.2988, 0.2019, 0.3116]}, {"w": "X_batch", "b": [0.2103, 0.2988, 0.2693, 0.3116]}, {"w": "in", "b": [0.2778, 0.2988, 0.2946, 0.3116]}, {"w": "np.array_split(X_train,", "b": [0.3031, 0.2988, 0.497, 0.3116]}, {"w": "n_batches):", "b": [0.5055, 0.2988, 0.5982, 0.3116]}, {"w": "inc_pca.partial_fit(X_batch)", "b": [0.2103, 0.3142, 0.4464, 0.327]}]}, {"id": "b_5", "type": "equation", "text": "X_reduced = inc_pca.transform(X_train)", "words": [{"w": "X_reduced", "b": [0.1766, 0.345, 0.2525, 0.3579]}, {"w": "=", "b": [0.2609, 0.345, 0.2693, 0.3579]}, {"w": "inc_pca.transform(X_train)", "b": [0.2778, 0.345, 0.497, 0.3579]}]}, {"id": "b_6", "type": "paragraph", "text": "Alternatively, you can use NumPy’s memmap class, which allows you to manipulate a large array stored in a binary file on disk as if it were entirely in memory; the class loads only the data it needs in memory, when it needs it. Since the IncrementalPCA class uses only a small part of the array at any given time, the memory usage remains under control. This makes it possible to call the usual fit() method, as you can see in the following code:", "words": [{"w": "Alternatively,", "b": [0.1429, 0.3665, 0.2541, 0.388]}, {"w": "you", "b": [0.261, 0.3665, 0.2923, 0.388]}, {"w": "can", "b": [0.2992, 0.3665, 0.3285, 0.388]}, {"w": "use", "b": [0.3354, 0.3665, 0.363, 0.388]}, {"w": "NumPy’s", "b": [0.3699, 0.3665, 0.4444, 0.388]}, {"w": "memmap", "b": [0.4513, 0.3697, 0.5106, 0.3848]}, {"w": "class,", "b": [0.5175, 0.3665, 0.5608, 0.388]}, {"w": "which", "b": [0.5677, 0.3665, 0.6186, 0.388]}, {"w": "allows", "b": [0.6255, 0.3665, 0.6778, 0.388]}, {"w": "you", "b": [0.6847, 0.3665, 0.7159, 0.388]}, {"w": "to", "b": [0.7228, 0.3665, 0.7398, 0.388]}, {"w": "manipulate", "b": [0.7467, 0.3665, 0.8411, 0.388]}, {"w": "a", "b": [0.848, 0.3665, 0.8571, 0.388]}, {"w": "large", "b": [0.1429, 0.3856, 0.1836, 0.407]}, {"w": "array", "b": [0.1903, 0.3856, 0.2332, 0.407]}, {"w": "stored", "b": [0.2398, 0.3856, 0.2921, 0.407]}, {"w": "in", "b": [0.2987, 0.3856, 0.3157, 0.407]}, {"w": "a", "b": [0.3223, 0.3856, 0.3315, 0.407]}, {"w": "binary", "b": [0.3381, 0.3856, 0.3927, 0.407]}, {"w": "file", "b": [0.3994, 0.3856, 0.4253, 0.407]}, {"w": "on", "b": [0.4319, 0.3856, 0.4539, 0.407]}, {"w": "disk", "b": [0.4606, 0.3856, 0.4952, 0.407]}, {"w": "as", "b": [0.5018, 0.3856, 0.5186, 0.407]}, {"w": "if", "b": [0.5252, 0.3856, 0.537, 0.407]}, {"w": "it", "b": [0.5436, 0.3856, 0.5556, 0.407]}, {"w": "were", "b": [0.5622, 0.3856, 0.6019, 0.407]}, {"w": "entirely", "b": [0.6086, 0.3856, 0.6718, 0.407]}, {"w": "in", "b": [0.6785, 0.3856, 0.6954, 0.407]}, {"w": "memory;", "b": [0.7021, 0.3856, 0.779, 0.407]}, {"w": "the", "b": [0.7856, 0.3856, 0.812, 0.407]}, {"w": "class", "b": [0.8186, 0.3856, 0.8571, 0.407]}, {"w": "loads", "b": [0.1428, 0.4055, 0.1865, 0.427]}, {"w": "only", "b": [0.1929, 0.4055, 0.2298, 0.427]}, {"w": "the", "b": [0.2362, 0.4055, 0.2625, 0.427]}, {"w": "data", "b": [0.2689, 0.4055, 0.3041, 0.427]}, {"w": "it", "b": [0.3105, 0.4055, 0.3224, 0.427]}, {"w": "needs", "b": [0.3288, 0.4055, 0.3766, 0.427]}, {"w": "in", "b": [0.383, 0.4055, 0.3999, 0.427]}, {"w": "memory,", "b": [0.4063, 0.4055, 0.481, 0.427]}, {"w": "when", "b": [0.4874, 0.4055, 0.5331, 0.427]}, {"w": "it", "b": [0.5395, 0.4055, 0.5514, 0.427]}, {"w": "needs", "b": [0.5578, 0.4055, 0.6055, 0.427]}, {"w": "it.", "b": [0.6119, 0.4055, 0.6286, 0.427]}, {"w": "Since", "b": [0.635, 0.4055, 0.6795, 0.427]}, {"w": "the", "b": [0.6859, 0.4055, 0.7122, 0.427]}, {"w": "IncrementalPCA", "b": [0.7186, 0.4087, 0.8571, 0.4238]}, {"w": "class", "b": [0.1429, 0.4246, 0.1814, 0.446]}, {"w": "uses", "b": [0.1867, 0.4246, 0.2219, 0.446]}, {"w": "only", "b": [0.2273, 0.4246, 0.2642, 0.446]}, {"w": "a", "b": [0.2695, 0.4246, 0.2787, 0.446]}, {"w": "small", "b": [0.284, 0.4246, 0.3284, 0.446]}, {"w": "part", "b": [0.3338, 0.4246, 0.3679, 0.446]}, {"w": "of", "b": [0.3733, 0.4246, 0.3901, 0.446]}, {"w": "the", "b": [0.3954, 0.4246, 0.4217, 0.446]}, {"w": "array", "b": [0.4271, 0.4246, 0.47, 0.446]}, {"w": "at", "b": [0.4754, 0.4246, 0.4905, 0.446]}, {"w": "any", "b": [0.4959, 0.4246, 0.5255, 0.446]}, {"w": "given", "b": [0.5308, 0.4246, 0.5761, 0.446]}, {"w": "time,", "b": [0.5814, 0.4246, 0.624, 0.446]}, {"w": "the", "b": [0.6294, 0.4246, 0.6557, 0.446]}, {"w": "memory", "b": [0.6611, 0.4246, 0.7326, 0.446]}, {"w": "usage", "b": [0.7379, 0.4246, 0.7844, 0.446]}, {"w": "remains", "b": [0.7897, 0.4246, 0.8571, 0.446]}, {"w": "under", "b": [0.1429, 0.4445, 0.1929, 0.4659]}, {"w": "control.", "b": [0.199, 0.4445, 0.2642, 0.4659]}, {"w": "This", "b": [0.2703, 0.4445, 0.3075, 0.4659]}, {"w": "makes", "b": [0.3136, 0.4445, 0.3667, 0.4659]}, {"w": "it", "b": [0.3728, 0.4445, 0.3847, 0.4659]}, {"w": "possible", "b": [0.3908, 0.4445, 0.458, 0.4659]}, {"w": "to", "b": [0.4641, 0.4445, 0.4811, 0.4659]}, {"w": "call", "b": [0.4872, 0.4445, 0.5157, 0.4659]}, {"w": "the", "b": [0.5218, 0.4445, 0.5481, 0.4659]}, {"w": "usual", "b": [0.5542, 0.4445, 0.5984, 0.4659]}, {"w": "fit()", "b": [0.6046, 0.4477, 0.654, 0.4628]}, {"w": "method,", "b": [0.6602, 0.4445, 0.7299, 0.4659]}, {"w": "as", "b": [0.736, 0.4445, 0.7528, 0.4659]}, {"w": "you", "b": [0.7589, 0.4445, 0.7902, 0.4659]}, {"w": "can", "b": [0.7963, 0.4445, 0.8257, 0.4659]}, {"w": "see", "b": [0.8318, 0.4445, 0.8571, 0.4659]}, {"w": "in", "b": [0.1429, 0.4636, 0.1598, 0.485]}, {"w": "the", "b": [0.1646, 0.4636, 0.1909, 0.485]}, {"w": "following", "b": [0.1956, 0.4636, 0.2746, 0.485]}, {"w": "code:", "b": [0.2793, 0.4636, 0.3234, 0.485]}]}, {"id": "b_7", "type": "equation", "text": "X_mm = np.memmap(filename, dtype=\"float32\", mode=\"readonly\", shape=(m, n))", "words": [{"w": "X_mm", "b": [0.1766, 0.4956, 0.2103, 0.5084]}, {"w": "=", "b": [0.2188, 0.4956, 0.2272, 0.5084]}, {"w": "np.memmap(filename,", "b": [0.2356, 0.4956, 0.3958, 0.5084]}, {"w": "dtype=\"float32\",", "b": [0.4043, 0.4956, 0.5392, 0.5084]}, {"w": "mode=\"readonly\",", "b": [0.5476, 0.4956, 0.6825, 0.5084]}, {"w": "shape=(m,", "b": [0.691, 0.4956, 0.7669, 0.5084]}, {"w": "n))", "b": [0.7753, 0.4956, 0.8006, 0.5084]}]}, {"id": "b_8", "type": "paragraph", "text": "batch_size = m // n_batches inc_pca = IncrementalPCA(n_components=154, batch_size=batch_size) inc_pca.fit(X_mm)", "words": [{"w": "batch_size", "b": [0.1766, 0.5264, 0.2609, 0.5392]}, {"w": "=", "b": [0.2693, 0.5264, 0.2778, 0.5392]}, {"w": "m", "b": [0.2862, 0.5264, 0.2946, 0.5392]}, {"w": "//", "b": [0.3031, 0.5264, 0.3199, 0.5392]}, {"w": "n_batches", "b": [0.3284, 0.5264, 0.4043, 0.5392]}, {"w": "inc_pca", "b": [0.1766, 0.5418, 0.2356, 0.5547]}, {"w": "=", "b": [0.2441, 0.5418, 0.2525, 0.5547]}, {"w": "IncrementalPCA(n_components=154,", "b": [0.2609, 0.5418, 0.5308, 0.5547]}, {"w": "batch_size=batch_size)", "b": [0.5392, 0.5418, 0.7247, 0.5547]}, {"w": "inc_pca.fit(X_mm)", "b": [0.1766, 0.5572, 0.3199, 0.5701]}]}, {"id": "b_9", "type": "paragraph", "text": "Kernel PCA", "words": [{"w": "Kernel", "b": [0.1429, 0.5842, 0.2232, 0.6184]}, {"w": "PCA", "b": [0.2291, 0.5842, 0.2765, 0.6184]}]}, {"id": "b_10", "type": "paragraph", "text": "In Chapter 5 we discussed the kernel trick, a mathematical technique that implicitly maps instances into a very high-dimensional space (called the feature space), enabling nonlinear classification and regression with Support Vector Machines. Recall that a linear decision boundary in the high-dimensional feature space corresponds to a complex nonlinear decision boundary in the original space.", "words": [{"w": "In", "b": [0.1429, 0.6253, 0.1614, 0.6467]}, {"w": "Chapter", "b": [0.1677, 0.6253, 0.2353, 0.6467]}, {"w": "5", "b": [0.2417, 0.6253, 0.2517, 0.6467]}, {"w": "we", "b": [0.258, 0.6253, 0.2812, 0.6467]}, {"w": "discussed", "b": [0.2875, 0.6253, 0.3668, 0.6467]}, {"w": "the", "b": [0.3731, 0.6253, 0.3995, 0.6467]}, {"w": "kernel", "b": [0.4058, 0.6253, 0.4583, 0.6467]}, {"w": "trick,", "b": [0.4646, 0.6253, 0.5082, 0.6467]}, {"w": "a", "b": [0.5146, 0.6253, 0.5237, 0.6467]}, {"w": "mathematical", "b": [0.5301, 0.6253, 0.6432, 0.6467]}, {"w": "technique", "b": [0.6495, 0.6253, 0.7322, 0.6467]}, {"w": "that", "b": [0.7386, 0.6253, 0.7712, 0.6467]}, {"w": "implicitly", "b": [0.7775, 0.6253, 0.8571, 0.6467]}, {"w": "maps", "b": [0.1429, 0.6444, 0.1872, 0.6658]}, {"w": "instances", "b": [0.1922, 0.6444, 0.2691, 0.6658]}, {"w": "into", "b": [0.2741, 0.6444, 0.3076, 0.6658]}, {"w": "a", "b": [0.3126, 0.6444, 0.3218, 0.6658]}, {"w": "very", "b": [0.3268, 0.6444, 0.3632, 0.6658]}, {"w": "high-dimensional", "b": [0.3682, 0.6444, 0.5168, 0.6658]}, {"w": "space", "b": [0.5218, 0.6444, 0.5671, 0.6658]}, {"w": "(called", "b": [0.5722, 0.6444, 0.6277, 0.6658]}, {"w": "the", "b": [0.6327, 0.6444, 0.6591, 0.6658]}, {"w": "feature", "b": [0.6641, 0.6442, 0.7201, 0.6658]}, {"w": "space),", "b": [0.7248, 0.6442, 0.7801, 0.6658]}, {"w": "enabling", "b": [0.7849, 0.6444, 0.8569, 0.6658]}, {"w": "nonlinear", "b": [0.1429, 0.6634, 0.2243, 0.6848]}, {"w": "classification", "b": [0.2313, 0.6634, 0.3387, 0.6848]}, {"w": "and", "b": [0.3458, 0.6634, 0.3773, 0.6848]}, {"w": "regression", "b": [0.3844, 0.6634, 0.4702, 0.6848]}, {"w": "with", "b": [0.4773, 0.6634, 0.5146, 0.6848]}, {"w": "Support", "b": [0.5217, 0.6634, 0.5892, 0.6848]}, {"w": "Vector", "b": [0.5963, 0.6634, 0.6513, 0.6848]}, {"w": "Machines.", "b": [0.6584, 0.6634, 0.7439, 0.6848]}, {"w": "Recall", "b": [0.751, 0.6634, 0.8012, 0.6848]}, {"w": "that", "b": [0.8083, 0.6634, 0.8409, 0.6848]}, {"w": "a", "b": [0.848, 0.6634, 0.8571, 0.6848]}, {"w": "linear", "b": [0.1428, 0.6825, 0.1908, 0.7039]}, {"w": "decision", "b": [0.1999, 0.6825, 0.2694, 0.7039]}, {"w": "boundary", "b": [0.2785, 0.6825, 0.3602, 0.7039]}, {"w": "in", "b": [0.3693, 0.6825, 0.3863, 0.7039]}, {"w": "the", "b": [0.3954, 0.6825, 0.4217, 0.7039]}, {"w": "high-dimensional", "b": [0.4308, 0.6825, 0.5794, 0.7039]}, {"w": "feature", "b": [0.5885, 0.6825, 0.6463, 0.7039]}, {"w": "space", "b": [0.6554, 0.6825, 0.7007, 0.7039]}, {"w": "corresponds", "b": [0.7098, 0.6825, 0.8128, 0.7039]}, {"w": "to", "b": [0.8219, 0.6825, 0.8389, 0.7039]}, {"w": "a", "b": [0.848, 0.6825, 0.8571, 0.7039]}, {"w": "complex", "b": [0.1429, 0.7015, 0.2138, 0.7229]}, {"w": "nonlinear", "b": [0.2186, 0.7015, 0.3, 0.7229]}, {"w": "decision", "b": [0.3047, 0.7015, 0.3742, 0.7229]}, {"w": "boundary", "b": [0.3789, 0.7015, 0.4606, 0.7229]}, {"w": "in", "b": [0.4654, 0.7015, 0.4823, 0.7229]}, {"w": "the", "b": [0.4871, 0.7015, 0.5134, 0.7229]}, {"w": "original", "b": [0.5181, 0.7013, 0.5814, 0.7229]}, {"w": "space.", "b": [0.5862, 0.7013, 0.634, 0.7229]}]}, {"id": "b_11", "type": "paragraph", "text": "It turns out that the same trick can be applied to PCA, making it possible to perform complex nonlinear projections for dimensionality reduction. This is called Kernel", "words": [{"w": "It", "b": [0.1429, 0.7296, 0.1555, 0.7511]}, {"w": "turns", "b": [0.1611, 0.7296, 0.2052, 0.7511]}, {"w": "out", "b": [0.2108, 0.7296, 0.2388, 0.7511]}, {"w": "that", "b": [0.2444, 0.7296, 0.277, 0.7511]}, {"w": "the", "b": [0.2825, 0.7296, 0.3089, 0.7511]}, {"w": "same", "b": [0.3144, 0.7296, 0.3571, 0.7511]}, {"w": "trick", "b": [0.3627, 0.7296, 0.4015, 0.7511]}, {"w": "can", "b": [0.407, 0.7296, 0.4364, 0.7511]}, {"w": "be", "b": [0.4419, 0.7296, 0.4614, 0.7511]}, {"w": "applied", "b": [0.4669, 0.7296, 0.5282, 0.7511]}, {"w": "to", "b": [0.5338, 0.7296, 0.5507, 0.7511]}, {"w": "PCA,", "b": [0.5563, 0.7296, 0.601, 0.7511]}, {"w": "making", "b": [0.6066, 0.7296, 0.6698, 0.7511]}, {"w": "it", "b": [0.6754, 0.7296, 0.6873, 0.7511]}, {"w": "possible", "b": [0.6929, 0.7296, 0.76, 0.7511]}, {"w": "to", "b": [0.7655, 0.7296, 0.7825, 0.7511]}, {"w": "perform", "b": [0.7881, 0.7296, 0.8571, 0.7511]}, {"w": "complex", "b": [0.1429, 0.7487, 0.2138, 0.7701]}, {"w": "nonlinear", "b": [0.2227, 0.7487, 0.3041, 0.7701]}, {"w": "projections", "b": [0.313, 0.7487, 0.4069, 0.7701]}, {"w": "for", "b": [0.4158, 0.7487, 0.4403, 0.7701]}, {"w": "dimensionality", "b": [0.4493, 0.7487, 0.5743, 0.7701]}, {"w": "reduction.", "b": [0.5832, 0.7487, 0.6694, 0.7701]}, {"w": "This", "b": [0.6783, 0.7487, 0.7155, 0.7701]}, {"w": "is", "b": [0.7244, 0.7487, 0.7376, 0.7701]}, {"w": "called", "b": [0.7465, 0.7487, 0.7949, 0.7701]}, {"w": "Kernel", "b": [0.8038, 0.7485, 0.8571, 0.7701]}]}, {"id": "b_12", "type": "paragraph", "text": "228 | Chapter 8: Dimensionality Reduction", "words": [{"w": "228", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "8:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Dimensionality", "b": [0.2673, 0.9225, 0.3562, 0.9388]}, {"w": "Reduction", "b": [0.359, 0.9225, 0.4186, 0.9388]}]}]}, {"page": 255, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 “Kernel Principal Component Analysis,” B. Schölkopf, A. Smola, K. Müller (1999).", "words": [{"w": "6", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Kernel", "b": [0.1587, 0.8749, 0.2074, 0.8912]}, {"w": "Principal", "b": [0.211, 0.8749, 0.2691, 0.8912]}, {"w": "Component", "b": [0.2727, 0.8749, 0.3491, 0.8912]}, {"w": "Analysis,”", "b": [0.3527, 0.8749, 0.4143, 0.8912]}, {"w": "B.", "b": [0.4179, 0.8749, 0.4306, 0.8912]}, {"w": "Schölkopf,", "b": [0.4342, 0.8749, 0.5016, 0.8912]}, {"w": "A.", "b": [0.5052, 0.8749, 0.5198, 0.8912]}, {"w": "Smola,", "b": [0.5234, 0.8749, 0.5666, 0.8912]}, {"w": "K.", "b": [0.5702, 0.8749, 0.5845, 0.8912]}, {"w": "Müller", "b": [0.5881, 0.8749, 0.6309, 0.8912]}, {"w": "(1999).", "b": [0.6345, 0.8749, 0.6795, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "PCA (kPCA).6 It is often good at preserving clusters of instances after projection, or sometimes even unrolling datasets that lie close to a twisted manifold.", "words": [{"w": "PCA", "b": [0.1429, 0.0789, 0.1815, 0.1005]}, {"w": "(kPCA).6", "b": [0.1877, 0.0791, 0.2629, 0.1005]}, {"w": "It", "b": [0.2691, 0.0791, 0.2817, 0.1005]}, {"w": "is", "b": [0.2879, 0.0791, 0.3012, 0.1005]}, {"w": "often", "b": [0.3074, 0.0791, 0.3508, 0.1005]}, {"w": "good", "b": [0.357, 0.0791, 0.399, 0.1005]}, {"w": "at", "b": [0.4052, 0.0791, 0.4203, 0.1005]}, {"w": "preserving", "b": [0.4265, 0.0791, 0.5153, 0.1005]}, {"w": "clusters", "b": [0.5215, 0.0791, 0.5848, 0.1005]}, {"w": "of", "b": [0.5911, 0.0791, 0.6079, 0.1005]}, {"w": "instances", "b": [0.6141, 0.0791, 0.6909, 0.1005]}, {"w": "after", "b": [0.6971, 0.0791, 0.7354, 0.1005]}, {"w": "projection,", "b": [0.7416, 0.0791, 0.8326, 0.1005]}, {"w": "or", "b": [0.8388, 0.0791, 0.8571, 0.1005]}, {"w": "sometimes", "b": [0.1429, 0.0981, 0.2326, 0.1195]}, {"w": "even", "b": [0.2373, 0.0981, 0.276, 0.1195]}, {"w": "unrolling", "b": [0.2808, 0.0981, 0.3588, 0.1195]}, {"w": "datasets", "b": [0.3636, 0.0981, 0.4293, 0.1195]}, {"w": "that", "b": [0.4341, 0.0981, 0.4666, 0.1195]}, {"w": "lie", "b": [0.4714, 0.0981, 0.4911, 0.1195]}, {"w": "close", "b": [0.4958, 0.0981, 0.537, 0.1195]}, {"w": "to", "b": [0.5417, 0.0981, 0.5587, 0.1195]}, {"w": "a", "b": [0.5635, 0.0981, 0.5726, 0.1195]}, {"w": "twisted", "b": [0.5773, 0.0981, 0.6374, 0.1195]}, {"w": "manifold.", "b": [0.6421, 0.0981, 0.7231, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "For example, the following code uses Scikit-Learn’s KernelPCA class to perform kPCA with an RBF kernel (see Chapter 5 for more details about the RBF kernel and the other kernels):", "words": [{"w": "For", "b": [0.1429, 0.1271, 0.1718, 0.1485]}, {"w": "example,", "b": [0.177, 0.1271, 0.2513, 0.1485]}, {"w": "the", "b": [0.2564, 0.1271, 0.2827, 0.1485]}, {"w": "following", "b": [0.2878, 0.1271, 0.3668, 0.1485]}, {"w": "code", "b": [0.3719, 0.1271, 0.4112, 0.1485]}, {"w": "uses", "b": [0.4163, 0.1271, 0.4516, 0.1485]}, {"w": "Scikit-Learn’s", "b": [0.4567, 0.1271, 0.5676, 0.1485]}, {"w": "KernelPCA", "b": [0.5727, 0.1303, 0.6617, 0.1454]}, {"w": "class", "b": [0.6669, 0.1271, 0.7054, 0.1485]}, {"w": "to", "b": [0.7105, 0.1271, 0.7275, 0.1485]}, {"w": "perform", "b": [0.7326, 0.1271, 0.8017, 0.1485]}, {"w": "kPCA", "b": [0.8068, 0.1271, 0.8571, 0.1485]}, {"w": "with", "b": [0.1429, 0.1462, 0.1802, 0.1676]}, {"w": "an", "b": [0.1878, 0.1462, 0.2084, 0.1676]}, {"w": "RBF", "b": [0.216, 0.1462, 0.2522, 0.1676]}, {"w": "kernel", "b": [0.2598, 0.1462, 0.3123, 0.1676]}, {"w": "(see", "b": [0.3199, 0.1462, 0.3524, 0.1676]}, {"w": "Chapter", "b": [0.3601, 0.1462, 0.4276, 0.1676]}, {"w": "5", "b": [0.4353, 0.1462, 0.4453, 0.1676]}, {"w": "for", "b": [0.4529, 0.1462, 0.4774, 0.1676]}, {"w": "more", "b": [0.485, 0.1462, 0.5293, 0.1676]}, {"w": "details", "b": [0.5369, 0.1462, 0.5908, 0.1676]}, {"w": "about", "b": [0.5984, 0.1462, 0.6462, 0.1676]}, {"w": "the", "b": [0.6538, 0.1462, 0.6801, 0.1676]}, {"w": "RBF", "b": [0.6878, 0.1462, 0.724, 0.1676]}, {"w": "kernel", "b": [0.7316, 0.1462, 0.784, 0.1676]}, {"w": "and", "b": [0.7917, 0.1462, 0.8232, 0.1676]}, {"w": "the", "b": [0.8308, 0.1462, 0.8571, 0.1676]}, {"w": "other", "b": [0.1429, 0.1652, 0.1875, 0.1866]}, {"w": "kernels):", "b": [0.1923, 0.1652, 0.2643, 0.1866]}]}, {"id": "b_3", "type": "paragraph", "text": "from sklearn.decomposition import KernelPCA", "words": [{"w": "from", "b": [0.1766, 0.1972, 0.2103, 0.21]}, {"w": "sklearn.decomposition", "b": [0.2187, 0.1972, 0.3958, 0.21]}, {"w": "import", "b": [0.4043, 0.1972, 0.4549, 0.21]}, {"w": "KernelPCA", "b": [0.4633, 0.1972, 0.5392, 0.21]}]}, {"id": "b_4", "type": "paragraph", "text": "rbf_pca = KernelPCA(n_components = 2, kernel=\"rbf\", gamma=0.04) X_reduced = rbf_pca.fit_transform(X)", "words": [{"w": "rbf_pca", "b": [0.1766, 0.228, 0.2356, 0.2409]}, {"w": "=", "b": [0.244, 0.228, 0.2525, 0.2409]}, {"w": "KernelPCA(n_components", "b": [0.2609, 0.228, 0.4464, 0.2409]}, {"w": "=", "b": [0.4549, 0.228, 0.4633, 0.2409]}, {"w": "2,", "b": [0.4717, 0.228, 0.4886, 0.2409]}, {"w": "kernel=\"rbf\",", "b": [0.497, 0.228, 0.6066, 0.2409]}, {"w": "gamma=0.04)", "b": [0.6151, 0.228, 0.7078, 0.2409]}, {"w": "X_reduced", "b": [0.1766, 0.2435, 0.2525, 0.2563]}, {"w": "=", "b": [0.2609, 0.2435, 0.2693, 0.2563]}, {"w": "rbf_pca.fit_transform(X)", "b": [0.2778, 0.2435, 0.4802, 0.2563]}]}, {"id": "b_5", "type": "paragraph", "text": "Figure 8-10 shows the Swiss roll, reduced to two dimensions using a linear kernel (equivalent to simply using the PCA class), an RBF kernel, and a sigmoid kernel (Logistic).", "words": [{"w": "Figure", "b": [0.1429, 0.2641, 0.1969, 0.2855]}, {"w": "8-10", "b": [0.2045, 0.2641, 0.2419, 0.2855]}, {"w": "shows", "b": [0.2495, 0.2641, 0.3009, 0.2855]}, {"w": "the", "b": [0.3085, 0.2641, 0.3348, 0.2855]}, {"w": "Swiss", "b": [0.3425, 0.2641, 0.3875, 0.2855]}, {"w": "roll,", "b": [0.3951, 0.2641, 0.4288, 0.2855]}, {"w": "reduced", "b": [0.4364, 0.2641, 0.5037, 0.2855]}, {"w": "to", "b": [0.5113, 0.2641, 0.5283, 0.2855]}, {"w": "two", "b": [0.5359, 0.2641, 0.5672, 0.2855]}, {"w": "dimensions", "b": [0.5748, 0.2641, 0.6716, 0.2855]}, {"w": "using", "b": [0.6793, 0.2641, 0.7247, 0.2855]}, {"w": "a", "b": [0.7323, 0.2641, 0.7415, 0.2855]}, {"w": "linear", "b": [0.7491, 0.2641, 0.7971, 0.2855]}, {"w": "kernel", "b": [0.8047, 0.2641, 0.8571, 0.2855]}, {"w": "(equivalent", "b": [0.1429, 0.284, 0.2365, 0.3054]}, {"w": "to", "b": [0.2458, 0.284, 0.2628, 0.3054]}, {"w": "simply", "b": [0.2722, 0.284, 0.3278, 0.3054]}, {"w": "using", "b": [0.3372, 0.284, 0.3826, 0.3054]}, {"w": "the", "b": [0.392, 0.284, 0.4183, 0.3054]}, {"w": "PCA", "b": [0.4277, 0.2872, 0.4574, 0.3023]}, {"w": "class),", "b": [0.4668, 0.284, 0.5173, 0.3054]}, {"w": "an", "b": [0.5266, 0.284, 0.5472, 0.3054]}, {"w": "RBF", "b": [0.5565, 0.284, 0.5927, 0.3054]}, {"w": "kernel,", "b": [0.6021, 0.284, 0.6593, 0.3054]}, {"w": "and", "b": [0.6687, 0.284, 0.7002, 0.3054]}, {"w": "a", "b": [0.7096, 0.284, 0.7187, 0.3054]}, {"w": "sigmoid", "b": [0.7281, 0.284, 0.7953, 0.3054]}, {"w": "kernel", "b": [0.8047, 0.284, 0.8571, 0.3054]}, {"w": "(Logistic).", "b": [0.1428, 0.3031, 0.2276, 0.3245]}]}, {"id": "b_6", "type": "equation", "text": "Figure 8-10. Swiss roll reduced to 2D using kPCA with various kernels", "words": [{"w": "Figure", "b": [0.1429, 0.5333, 0.1943, 0.5549]}, {"w": "8-10.", "b": [0.1991, 0.5333, 0.2407, 0.5549]}, {"w": "Swiss", "b": [0.2455, 0.5333, 0.2885, 0.5549]}, {"w": "roll", "b": [0.2933, 0.5333, 0.3204, 0.5549]}, {"w": "reduced", "b": [0.3251, 0.5333, 0.3885, 0.5549]}, {"w": "to", "b": [0.3933, 0.5333, 0.4093, 0.5549]}, {"w": "2D", "b": [0.414, 0.5333, 0.4387, 0.5549]}, {"w": "using", "b": [0.4435, 0.5333, 0.4865, 0.5549]}, {"w": "kPCA", "b": [0.4912, 0.5333, 0.5396, 0.5549]}, {"w": "with", "b": [0.5444, 0.5333, 0.5809, 0.5549]}, {"w": "various", "b": [0.5857, 0.5333, 0.646, 0.5549]}, {"w": "kernels", "b": [0.6507, 0.5333, 0.7078, 0.5549]}]}, {"id": "b_7", "type": "paragraph", "text": "Selecting a Kernel and Tuning Hyperparameters", "words": [{"w": "Selecting", "b": [0.1429, 0.5679, 0.238, 0.5965]}, {"w": "a", "b": [0.2429, 0.5679, 0.2553, 0.5965]}, {"w": "Kernel", "b": [0.2603, 0.5679, 0.3272, 0.5965]}, {"w": "and", "b": [0.3321, 0.5679, 0.3714, 0.5965]}, {"w": "Tuning", "b": [0.3763, 0.5679, 0.4484, 0.5965]}, {"w": "Hyperparameters", "b": [0.4533, 0.5679, 0.6333, 0.5965]}]}, {"id": "b_8", "type": "paragraph", "text": "As kPCA is an unsupervised learning algorithm, there is no obvious performance measure to help you select the best kernel and hyperparameter values. However, dimensionality reduction is often a preparation step for a supervised learning task (e.g., classification), so you can simply use grid search to select the kernel and hyper‐ parameters that lead to the best performance on that task. For example, the following code creates a two-step pipeline, first reducing dimensionality to two dimensions using kPCA, then applying Logistic Regression for classification. Then it uses Grid SearchCV to find the best kernel and gamma value for kPCA in order to get the best classification accuracy at the end of the pipeline:", "words": [{"w": "As", "b": [0.1429, 0.6024, 0.1649, 0.6238]}, {"w": "kPCA", "b": [0.1729, 0.6024, 0.2233, 0.6238]}, {"w": "is", "b": [0.2313, 0.6024, 0.2445, 0.6238]}, {"w": "an", "b": [0.2526, 0.6024, 0.2731, 0.6238]}, {"w": "unsupervised", "b": [0.2811, 0.6024, 0.3931, 0.6238]}, {"w": "learning", "b": [0.4012, 0.6024, 0.4703, 0.6238]}, {"w": "algorithm,", "b": [0.4783, 0.6024, 0.5657, 0.6238]}, {"w": "there", "b": [0.5738, 0.6024, 0.6167, 0.6238]}, {"w": "is", "b": [0.6247, 0.6024, 0.638, 0.6238]}, {"w": "no", "b": [0.646, 0.6024, 0.668, 0.6238]}, {"w": "obvious", "b": [0.676, 0.6024, 0.7418, 0.6238]}, {"w": "performance", "b": [0.7499, 0.6024, 0.8571, 0.6238]}, {"w": "measure", "b": [0.1429, 0.6215, 0.2132, 0.6429]}, {"w": "to", "b": [0.2224, 0.6215, 0.2394, 0.6429]}, {"w": "help", "b": [0.2486, 0.6215, 0.2848, 0.6429]}, {"w": "you", "b": [0.294, 0.6215, 0.3252, 0.6429]}, {"w": "select", "b": [0.3344, 0.6215, 0.3802, 0.6429]}, {"w": "the", "b": [0.3894, 0.6215, 0.4158, 0.6429]}, {"w": "best", "b": [0.425, 0.6215, 0.4584, 0.6429]}, {"w": "kernel", "b": [0.4676, 0.6215, 0.52, 0.6429]}, {"w": "and", "b": [0.5293, 0.6215, 0.5608, 0.6429]}, {"w": "hyperparameter", "b": [0.57, 0.6215, 0.7035, 0.6429]}, {"w": "values.", "b": [0.7127, 0.6215, 0.7691, 0.6429]}, {"w": "However,", "b": [0.7783, 0.6215, 0.8571, 0.6429]}, {"w": "dimensionality", "b": [0.1428, 0.6405, 0.2679, 0.6619]}, {"w": "reduction", "b": [0.2756, 0.6405, 0.357, 0.6619]}, {"w": "is", "b": [0.3647, 0.6405, 0.3779, 0.6619]}, {"w": "often", "b": [0.3856, 0.6405, 0.429, 0.6619]}, {"w": "a", "b": [0.4367, 0.6405, 0.4458, 0.6619]}, {"w": "preparation", "b": [0.4535, 0.6405, 0.5515, 0.6619]}, {"w": "step", "b": [0.5592, 0.6405, 0.5929, 0.6619]}, {"w": "for", "b": [0.6006, 0.6405, 0.6251, 0.6619]}, {"w": "a", "b": [0.6328, 0.6405, 0.642, 0.6619]}, {"w": "supervised", "b": [0.6496, 0.6405, 0.7392, 0.6619]}, {"w": "learning", "b": [0.7469, 0.6405, 0.816, 0.6619]}, {"w": "task", "b": [0.8237, 0.6405, 0.8571, 0.6619]}, {"w": "(e.g.,", "b": [0.1429, 0.6595, 0.1829, 0.681]}, {"w": "classification),", "b": [0.1884, 0.6595, 0.3078, 0.681]}, {"w": "so", "b": [0.3133, 0.6595, 0.3316, 0.681]}, {"w": "you", "b": [0.3371, 0.6595, 0.3683, 0.681]}, {"w": "can", "b": [0.3738, 0.6595, 0.4032, 0.681]}, {"w": "simply", "b": [0.4087, 0.6595, 0.4644, 0.681]}, {"w": "use", "b": [0.4699, 0.6595, 0.4974, 0.681]}, {"w": "grid", "b": [0.503, 0.6595, 0.537, 0.681]}, {"w": "search", "b": [0.5425, 0.6595, 0.5958, 0.681]}, {"w": "to", "b": [0.6014, 0.6595, 0.6183, 0.681]}, {"w": "select", "b": [0.6239, 0.6595, 0.6696, 0.681]}, {"w": "the", "b": [0.6752, 0.6595, 0.7015, 0.681]}, {"w": "kernel", "b": [0.707, 0.6595, 0.7595, 0.681]}, {"w": "and", "b": [0.765, 0.6595, 0.7965, 0.681]}, {"w": "hyper‐", "b": [0.802, 0.6595, 0.8571, 0.681]}, {"w": "parameters", "b": [0.1429, 0.6786, 0.2363, 0.7]}, {"w": "that", "b": [0.2416, 0.6786, 0.2742, 0.7]}, {"w": "lead", "b": [0.2794, 0.6786, 0.3137, 0.7]}, {"w": "to", "b": [0.319, 0.6786, 0.3359, 0.7]}, {"w": "the", "b": [0.3412, 0.6786, 0.3676, 0.7]}, {"w": "best", "b": [0.3728, 0.6786, 0.4063, 0.7]}, {"w": "performance", "b": [0.4115, 0.6786, 0.5188, 0.7]}, {"w": "on", "b": [0.5241, 0.6786, 0.5461, 0.7]}, {"w": "that", "b": [0.5514, 0.6786, 0.584, 0.7]}, {"w": "task.", "b": [0.5893, 0.6786, 0.6275, 0.7]}, {"w": "For", "b": [0.6328, 0.6786, 0.6617, 0.7]}, {"w": "example,", "b": [0.667, 0.6786, 0.7413, 0.7]}, {"w": "the", "b": [0.7466, 0.6786, 0.7729, 0.7]}, {"w": "following", "b": [0.7782, 0.6786, 0.8571, 0.7]}, {"w": "code", "b": [0.1429, 0.6976, 0.1821, 0.7191]}, {"w": "creates", "b": [0.1908, 0.6976, 0.2478, 0.7191]}, {"w": "a", "b": [0.2565, 0.6976, 0.2656, 0.7191]}, {"w": "two-step", "b": [0.2743, 0.6976, 0.3467, 0.7191]}, {"w": "pipeline,", "b": [0.3553, 0.6976, 0.4275, 0.7191]}, {"w": "first", "b": [0.4361, 0.6976, 0.4696, 0.7191]}, {"w": "reducing", "b": [0.4783, 0.6976, 0.5524, 0.7191]}, {"w": "dimensionality", "b": [0.5611, 0.6976, 0.6862, 0.7191]}, {"w": "to", "b": [0.6948, 0.6976, 0.7118, 0.7191]}, {"w": "two", "b": [0.7204, 0.6976, 0.7517, 0.7191]}, {"w": "dimensions", "b": [0.7603, 0.6976, 0.8571, 0.7191]}, {"w": "using", "b": [0.1429, 0.7176, 0.1883, 0.739]}, {"w": "kPCA,", "b": [0.1954, 0.7176, 0.2504, 0.739]}, {"w": "then", "b": [0.2575, 0.7176, 0.2952, 0.739]}, {"w": "applying", "b": [0.3022, 0.7176, 0.3744, 0.739]}, {"w": "Logistic", "b": [0.3814, 0.7176, 0.447, 0.739]}, {"w": "Regression", "b": [0.454, 0.7176, 0.5451, 0.739]}, {"w": "for", "b": [0.5521, 0.7176, 0.5766, 0.739]}, {"w": "classification.", "b": [0.5837, 0.7176, 0.6958, 0.739]}, {"w": "Then", "b": [0.7029, 0.7176, 0.7471, 0.739]}, {"w": "it", "b": [0.7541, 0.7176, 0.7661, 0.739]}, {"w": "uses", "b": [0.7731, 0.7176, 0.8083, 0.739]}, {"w": "Grid", "b": [0.8154, 0.7208, 0.855, 0.7359]}, {"w": "SearchCV", "b": [0.1429, 0.7407, 0.222, 0.7558]}, {"w": "to", "b": [0.2279, 0.7375, 0.2449, 0.7589]}, {"w": "find", "b": [0.2508, 0.7375, 0.285, 0.7589]}, {"w": "the", "b": [0.2909, 0.7375, 0.3172, 0.7589]}, {"w": "best", "b": [0.3232, 0.7375, 0.3566, 0.7589]}, {"w": "kernel", "b": [0.3625, 0.7375, 0.4149, 0.7589]}, {"w": "and", "b": [0.4209, 0.7375, 0.4524, 0.7589]}, {"w": "gamma", "b": [0.4583, 0.7375, 0.5205, 0.7589]}, {"w": "value", "b": [0.5264, 0.7375, 0.5704, 0.7589]}, {"w": "for", "b": [0.5763, 0.7375, 0.6008, 0.7589]}, {"w": "kPCA", "b": [0.6067, 0.7375, 0.657, 0.7589]}, {"w": "in", "b": [0.663, 0.7375, 0.6799, 0.7589]}, {"w": "order", "b": [0.6858, 0.7375, 0.7318, 0.7589]}, {"w": "to", "b": [0.7377, 0.7375, 0.7547, 0.7589]}, {"w": "get", "b": [0.7606, 0.7375, 0.7856, 0.7589]}, {"w": "the", "b": [0.7915, 0.7375, 0.8178, 0.7589]}, {"w": "best", "b": [0.8237, 0.7375, 0.8572, 0.7589]}, {"w": "classification", "b": [0.1429, 0.7566, 0.2502, 0.778]}, {"w": "accuracy", "b": [0.255, 0.7566, 0.328, 0.778]}, {"w": "at", "b": [0.3328, 0.7566, 0.3479, 0.778]}, {"w": "the", "b": [0.3526, 0.7566, 0.3789, 0.778]}, {"w": "end", "b": [0.3837, 0.7566, 0.4149, 0.778]}, {"w": "of", "b": [0.4197, 0.7566, 0.4364, 0.778]}, {"w": "the", "b": [0.4412, 0.7566, 0.4675, 0.778]}, {"w": "pipeline:", "b": [0.4722, 0.7566, 0.5444, 0.778]}]}, {"id": "b_9", "type": "paragraph", "text": "from sklearn.model_selection import GridSearchCV from sklearn.linear_model import LogisticRegression from sklearn.pipeline import Pipeline", "words": [{"w": "from", "b": [0.1766, 0.7886, 0.2103, 0.8014]}, {"w": "sklearn.model_selection", "b": [0.2187, 0.7886, 0.4127, 0.8014]}, {"w": "import", "b": [0.4211, 0.7886, 0.4717, 0.8014]}, {"w": "GridSearchCV", "b": [0.4802, 0.7886, 0.5813, 0.8014]}, {"w": "from", "b": [0.1766, 0.804, 0.2103, 0.8168]}, {"w": "sklearn.linear_model", "b": [0.2187, 0.804, 0.3874, 0.8168]}, {"w": "import", "b": [0.3958, 0.804, 0.4464, 0.8168]}, {"w": "LogisticRegression", "b": [0.4549, 0.804, 0.6066, 0.8168]}, {"w": "from", "b": [0.1766, 0.8194, 0.2103, 0.8322]}, {"w": "sklearn.pipeline", "b": [0.2187, 0.8194, 0.3537, 0.8322]}, {"w": "import", "b": [0.3621, 0.8194, 0.4127, 0.8322]}, {"w": "Pipeline", "b": [0.4211, 0.8194, 0.4886, 0.8322]}]}, {"id": "b_10", "type": "paragraph", "text": "Kernel PCA | 229", "words": [{"w": "Kernel", "b": [0.7322, 0.9225, 0.7704, 0.9388]}, {"w": "PCA", "b": [0.7732, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "229", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 256, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "clf = Pipeline([ (\"kpca\", KernelPCA(n_components=2)), (\"log_reg\", LogisticRegression()) ])", "words": [{"w": "clf", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "=", "b": [0.2103, 0.0983, 0.2188, 0.1112]}, {"w": "Pipeline([", "b": [0.2272, 0.0983, 0.3115, 0.1112]}, {"w": "(\"kpca\",", "b": [0.244, 0.1138, 0.3115, 0.1266]}, {"w": "KernelPCA(n_components=2)),", "b": [0.3199, 0.1138, 0.5476, 0.1266]}, {"w": "(\"log_reg\",", "b": [0.244, 0.1292, 0.3368, 0.142]}, {"w": "LogisticRegression())", "b": [0.3452, 0.1292, 0.5223, 0.142]}, {"w": "])", "b": [0.2103, 0.1446, 0.2272, 0.1574]}]}, {"id": "b_1", "type": "paragraph", "text": "param_grid = [{ \"kpca__gamma\": np.linspace(0.03, 0.05, 10), \"kpca__kernel\": [\"rbf\", \"sigmoid\"] }]", "words": [{"w": "param_grid", "b": [0.1766, 0.1754, 0.2609, 0.1883]}, {"w": "=", "b": [0.2693, 0.1754, 0.2778, 0.1883]}, {"w": "[{", "b": [0.2862, 0.1754, 0.3031, 0.1883]}, {"w": "\"kpca__gamma\":", "b": [0.244, 0.1909, 0.3621, 0.2037]}, {"w": "np.linspace(0.03,", "b": [0.3705, 0.1909, 0.5139, 0.2037]}, {"w": "0.05,", "b": [0.5223, 0.1909, 0.5645, 0.2037]}, {"w": "10),", "b": [0.5729, 0.1909, 0.6066, 0.2037]}, {"w": "\"kpca__kernel\":", "b": [0.244, 0.2063, 0.3705, 0.2191]}, {"w": "[\"rbf\",", "b": [0.379, 0.2063, 0.438, 0.2191]}, {"w": "\"sigmoid\"]", "b": [0.4464, 0.2063, 0.5308, 0.2191]}, {"w": "}]", "b": [0.2103, 0.2217, 0.2272, 0.2345]}]}, {"id": "b_2", "type": "equation", "text": "grid_search = GridSearchCV(clf, param_grid, cv=3) grid_search.fit(X, y)", "words": [{"w": "grid_search", "b": [0.1766, 0.2525, 0.2693, 0.2654]}, {"w": "=", "b": [0.2778, 0.2525, 0.2862, 0.2654]}, {"w": "GridSearchCV(clf,", "b": [0.2946, 0.2525, 0.438, 0.2654]}, {"w": "param_grid,", "b": [0.4464, 0.2525, 0.5392, 0.2654]}, {"w": "cv=3)", "b": [0.5476, 0.2525, 0.5898, 0.2654]}, {"w": "grid_search.fit(X,", "b": [0.1766, 0.268, 0.3284, 0.2808]}, {"w": "y)", "b": [0.3368, 0.268, 0.3537, 0.2808]}]}, {"id": "b_3", "type": "paragraph", "text": "The best kernel and hyperparameters are then available through the best_params_ variable:", "words": [{"w": "The", "b": [0.1429, 0.2895, 0.1757, 0.3109]}, {"w": "best", "b": [0.1831, 0.2895, 0.2166, 0.3109]}, {"w": "kernel", "b": [0.224, 0.2895, 0.2764, 0.3109]}, {"w": "and", "b": [0.2839, 0.2895, 0.3154, 0.3109]}, {"w": "hyperparameters", "b": [0.3228, 0.2895, 0.464, 0.3109]}, {"w": "are", "b": [0.4714, 0.2895, 0.4971, 0.3109]}, {"w": "then", "b": [0.5046, 0.2895, 0.5423, 0.3109]}, {"w": "available", "b": [0.5497, 0.2895, 0.622, 0.3109]}, {"w": "through", "b": [0.6294, 0.2895, 0.6972, 0.3109]}, {"w": "the", "b": [0.7046, 0.2895, 0.731, 0.3109]}, {"w": "best_params_", "b": [0.7384, 0.2927, 0.8571, 0.3077]}, {"w": "variable:", "b": [0.1429, 0.3085, 0.2136, 0.3299]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> print(grid_search.best_params_) {'kpca__gamma': 0.043333333333333335, 'kpca__kernel': 'rbf'}", "words": [{"w": ">>>", "b": [0.1766, 0.3405, 0.2019, 0.3534]}, {"w": "print(grid_search.best_params_)", "b": [0.2103, 0.3405, 0.4717, 0.3534]}, {"w": "{'kpca__gamma':", "b": [0.1766, 0.3559, 0.3031, 0.3688]}, {"w": "0.043333333333333335,", "b": [0.3115, 0.3559, 0.4886, 0.3688]}, {"w": "'kpca__kernel':", "b": [0.497, 0.3559, 0.6235, 0.3688]}, {"w": "'rbf'}", "b": [0.6319, 0.3559, 0.6825, 0.3688]}]}, {"id": "b_5", "type": "paragraph", "text": "Another approach, this time entirely unsupervised, is to select the kernel and hyper‐ parameters that yield the lowest reconstruction error. However, reconstruction is not as easy as with linear PCA. Here’s why. Figure 8-11 shows the original Swiss roll 3D dataset (top left), and the resulting 2D dataset after kPCA is applied using an RBF kernel (top right). Thanks to the kernel trick, this is mathematically equivalent to mapping the training set to an infinite-dimensional feature space (bottom right) using the feature map φ, then projecting the transformed training set down to 2D using linear PCA. Notice that if we could invert the linear PCA step for a given instance in the reduced space, the reconstructed point would lie in feature space, not in the original space (e.g., like the one represented by an x in the diagram). Since the feature space is infinite-dimensional, we cannot compute the reconstructed point, and therefore we cannot compute the true reconstruction error. Fortunately, it is pos‐ sible to find a point in the original space that would map close to the reconstructed point. This is called the reconstruction pre-image. Once you have this pre-image, you can measure its squared distance to the original instance. You can then select the ker‐ nel and hyperparameters that minimize this reconstruction pre-image error.", "words": [{"w": "Another", "b": [0.1429, 0.3766, 0.2133, 0.398]}, {"w": "approach,", "b": [0.2193, 0.3766, 0.302, 0.398]}, {"w": "this", "b": [0.308, 0.3766, 0.3387, 0.398]}, {"w": "time", "b": [0.3446, 0.3766, 0.3824, 0.398]}, {"w": "entirely", "b": [0.3884, 0.3766, 0.4516, 0.398]}, {"w": "unsupervised,", "b": [0.4575, 0.3766, 0.5742, 0.398]}, {"w": "is", "b": [0.5802, 0.3766, 0.5934, 0.398]}, {"w": "to", "b": [0.5993, 0.3766, 0.6163, 0.398]}, {"w": "select", "b": [0.6222, 0.3766, 0.668, 0.398]}, {"w": "the", "b": [0.6739, 0.3766, 0.7003, 0.398]}, {"w": "kernel", "b": [0.7062, 0.3766, 0.7586, 0.398]}, {"w": "and", "b": [0.7646, 0.3766, 0.7961, 0.398]}, {"w": "hyper‐", "b": [0.802, 0.3766, 0.8571, 0.398]}, {"w": "parameters", "b": [0.1429, 0.3956, 0.2363, 0.417]}, {"w": "that", "b": [0.2419, 0.3956, 0.2745, 0.417]}, {"w": "yield", "b": [0.2801, 0.3956, 0.3204, 0.417]}, {"w": "the", "b": [0.326, 0.3956, 0.3523, 0.417]}, {"w": "lowest", "b": [0.3579, 0.3956, 0.4109, 0.417]}, {"w": "reconstruction", "b": [0.4166, 0.3956, 0.5395, 0.417]}, {"w": "error.", "b": [0.5451, 0.3956, 0.5913, 0.417]}, {"w": "However,", "b": [0.5969, 0.3956, 0.6757, 0.417]}, {"w": "reconstruction", "b": [0.6813, 0.3956, 0.8043, 0.417]}, {"w": "is", "b": [0.8099, 0.3956, 0.8231, 0.417]}, {"w": "not", "b": [0.8288, 0.3956, 0.8571, 0.417]}, {"w": "as", "b": [0.1429, 0.4147, 0.1597, 0.4361]}, {"w": "easy", "b": [0.1659, 0.4147, 0.2012, 0.4361]}, {"w": "as", "b": [0.2075, 0.4147, 0.2242, 0.4361]}, {"w": "with", "b": [0.2305, 0.4147, 0.2679, 0.4361]}, {"w": "linear", "b": [0.2742, 0.4147, 0.3221, 0.4361]}, {"w": "PCA.", "b": [0.3284, 0.4147, 0.3732, 0.4361]}, {"w": "Here’s", "b": [0.3795, 0.4147, 0.4294, 0.4361]}, {"w": "why.", "b": [0.4357, 0.4147, 0.4734, 0.4361]}, {"w": "Figure", "b": [0.4797, 0.4147, 0.5337, 0.4361]}, {"w": "8-11", "b": [0.54, 0.4147, 0.5774, 0.4361]}, {"w": "shows", "b": [0.5837, 0.4147, 0.635, 0.4361]}, {"w": "the", "b": [0.6413, 0.4147, 0.6677, 0.4361]}, {"w": "original", "b": [0.674, 0.4147, 0.739, 0.4361]}, {"w": "Swiss", "b": [0.7453, 0.4147, 0.7904, 0.4361]}, {"w": "roll", "b": [0.7967, 0.4147, 0.8255, 0.4361]}, {"w": "3D", "b": [0.8318, 0.4147, 0.8572, 0.4361]}, {"w": "dataset", "b": [0.1429, 0.4337, 0.201, 0.4551]}, {"w": "(top", "b": [0.2083, 0.4337, 0.2434, 0.4551]}, {"w": "left),", "b": [0.2507, 0.4337, 0.2893, 0.4551]}, {"w": "and", "b": [0.2966, 0.4337, 0.3281, 0.4551]}, {"w": "the", "b": [0.3354, 0.4337, 0.3618, 0.4551]}, {"w": "resulting", "b": [0.3691, 0.4337, 0.4427, 0.4551]}, {"w": "2D", "b": [0.45, 0.4337, 0.4753, 0.4551]}, {"w": "dataset", "b": [0.4826, 0.4337, 0.5407, 0.4551]}, {"w": "after", "b": [0.548, 0.4337, 0.5863, 0.4551]}, {"w": "kPCA", "b": [0.5936, 0.4337, 0.6439, 0.4551]}, {"w": "is", "b": [0.6512, 0.4337, 0.6644, 0.4551]}, {"w": "applied", "b": [0.6718, 0.4337, 0.733, 0.4551]}, {"w": "using", "b": [0.7403, 0.4337, 0.7858, 0.4551]}, {"w": "an", "b": [0.7931, 0.4337, 0.8136, 0.4551]}, {"w": "RBF", "b": [0.8209, 0.4337, 0.8571, 0.4551]}, {"w": "kernel", "b": [0.1429, 0.4527, 0.1953, 0.4742]}, {"w": "(top", "b": [0.2034, 0.4527, 0.2385, 0.4742]}, {"w": "right).", "b": [0.2467, 0.4527, 0.2988, 0.4742]}, {"w": "Thanks", "b": [0.3069, 0.4527, 0.3694, 0.4742]}, {"w": "to", "b": [0.3775, 0.4527, 0.3945, 0.4742]}, {"w": "the", "b": [0.4026, 0.4527, 0.429, 0.4742]}, {"w": "kernel", "b": [0.4371, 0.4527, 0.4895, 0.4742]}, {"w": "trick,", "b": [0.4976, 0.4527, 0.5412, 0.4742]}, {"w": "this", "b": [0.5493, 0.4527, 0.58, 0.4742]}, {"w": "is", "b": [0.5882, 0.4527, 0.6014, 0.4742]}, {"w": "mathematically", "b": [0.6095, 0.4527, 0.7375, 0.4742]}, {"w": "equivalent", "b": [0.7456, 0.4527, 0.832, 0.4742]}, {"w": "to", "b": [0.8402, 0.4527, 0.8571, 0.4742]}, {"w": "mapping", "b": [0.1428, 0.4718, 0.2172, 0.4932]}, {"w": "the", "b": [0.2267, 0.4718, 0.2531, 0.4932]}, {"w": "training", "b": [0.2626, 0.4718, 0.3295, 0.4932]}, {"w": "set", "b": [0.339, 0.4718, 0.3619, 0.4932]}, {"w": "to", "b": [0.3714, 0.4718, 0.3884, 0.4932]}, {"w": "an", "b": [0.3979, 0.4718, 0.4184, 0.4932]}, {"w": "infinite-dimensional", "b": [0.4279, 0.4718, 0.5998, 0.4932]}, {"w": "feature", "b": [0.6093, 0.4718, 0.6671, 0.4932]}, {"w": "space", "b": [0.6766, 0.4718, 0.722, 0.4932]}, {"w": "(bottom", "b": [0.7315, 0.4718, 0.8003, 0.4932]}, {"w": "right)", "b": [0.8098, 0.4718, 0.8571, 0.4932]}, {"w": "using", "b": [0.1429, 0.4908, 0.1883, 0.5123]}, {"w": "the", "b": [0.196, 0.4908, 0.2224, 0.5123]}, {"w": "feature", "b": [0.2301, 0.4906, 0.2861, 0.5123]}, {"w": "map", "b": [0.2939, 0.4906, 0.3303, 0.5123]}, {"w": "φ,", "b": [0.338, 0.4908, 0.355, 0.5123]}, {"w": "then", "b": [0.3627, 0.4908, 0.4004, 0.5123]}, {"w": "projecting", "b": [0.4082, 0.4908, 0.4935, 0.5123]}, {"w": "the", "b": [0.5013, 0.4908, 0.5276, 0.5123]}, {"w": "transformed", "b": [0.5354, 0.4908, 0.6391, 0.5123]}, {"w": "training", "b": [0.6468, 0.4908, 0.7137, 0.5123]}, {"w": "set", "b": [0.7215, 0.4908, 0.7443, 0.5123]}, {"w": "down", "b": [0.7521, 0.4908, 0.7994, 0.5123]}, {"w": "to", "b": [0.8071, 0.4908, 0.8241, 0.5123]}, {"w": "2D", "b": [0.8318, 0.4908, 0.8571, 0.5123]}, {"w": "using", "b": [0.1429, 0.5099, 0.1883, 0.5313]}, {"w": "linear", "b": [0.197, 0.5099, 0.245, 0.5313]}, {"w": "PCA.", "b": [0.2537, 0.5099, 0.2984, 0.5313]}, {"w": "Notice", "b": [0.3071, 0.5099, 0.3623, 0.5313]}, {"w": "that", "b": [0.371, 0.5099, 0.4036, 0.5313]}, {"w": "if", "b": [0.4123, 0.5099, 0.4241, 0.5313]}, {"w": "we", "b": [0.4328, 0.5099, 0.4559, 0.5313]}, {"w": "could", "b": [0.4646, 0.5099, 0.5114, 0.5313]}, {"w": "invert", "b": [0.5201, 0.5099, 0.5692, 0.5313]}, {"w": "the", "b": [0.5779, 0.5099, 0.6042, 0.5313]}, {"w": "linear", "b": [0.613, 0.5099, 0.6609, 0.5313]}, {"w": "PCA", "b": [0.6696, 0.5099, 0.7096, 0.5313]}, {"w": "step", "b": [0.7183, 0.5099, 0.7521, 0.5313]}, {"w": "for", "b": [0.7608, 0.5099, 0.7853, 0.5313]}, {"w": "a", "b": [0.7941, 0.5099, 0.8032, 0.5313]}, {"w": "given", "b": [0.8119, 0.5099, 0.8571, 0.5313]}, {"w": "instance", "b": [0.1429, 0.5289, 0.212, 0.5504]}, {"w": "in", "b": [0.2177, 0.5289, 0.2346, 0.5504]}, {"w": "the", "b": [0.2403, 0.5289, 0.2666, 0.5504]}, {"w": "reduced", "b": [0.2722, 0.5289, 0.3395, 0.5504]}, {"w": "space,", "b": [0.3452, 0.5289, 0.3953, 0.5504]}, {"w": "the", "b": [0.4009, 0.5289, 0.4272, 0.5504]}, {"w": "reconstructed", "b": [0.4329, 0.5289, 0.5481, 0.5504]}, {"w": "point", "b": [0.5537, 0.5289, 0.5982, 0.5504]}, {"w": "would", "b": [0.6038, 0.5289, 0.6561, 0.5504]}, {"w": "lie", "b": [0.6617, 0.5289, 0.6814, 0.5504]}, {"w": "in", "b": [0.687, 0.5289, 0.704, 0.5504]}, {"w": "feature", "b": [0.7096, 0.5289, 0.7674, 0.5504]}, {"w": "space,", "b": [0.773, 0.5289, 0.8231, 0.5504]}, {"w": "not", "b": [0.8288, 0.5289, 0.8571, 0.5504]}, {"w": "in", "b": [0.1429, 0.548, 0.1598, 0.5694]}, {"w": "the", "b": [0.1654, 0.548, 0.1918, 0.5694]}, {"w": "original", "b": [0.1973, 0.548, 0.2624, 0.5694]}, {"w": "space", "b": [0.268, 0.548, 0.3134, 0.5694]}, {"w": "(e.g.,", "b": [0.319, 0.548, 0.359, 0.5694]}, {"w": "like", "b": [0.3646, 0.548, 0.3947, 0.5694]}, {"w": "the", "b": [0.4002, 0.548, 0.4266, 0.5694]}, {"w": "one", "b": [0.4322, 0.548, 0.463, 0.5694]}, {"w": "represented", "b": [0.4686, 0.548, 0.5664, 0.5694]}, {"w": "by", "b": [0.572, 0.548, 0.5921, 0.5694]}, {"w": "an", "b": [0.5977, 0.548, 0.6183, 0.5694]}, {"w": "x", "b": [0.6239, 0.548, 0.6337, 0.5694]}, {"w": "in", "b": [0.6393, 0.548, 0.6563, 0.5694]}, {"w": "the", "b": [0.6618, 0.548, 0.6882, 0.5694]}, {"w": "diagram).", "b": [0.6938, 0.548, 0.7751, 0.5694]}, {"w": "Since", "b": [0.7807, 0.548, 0.8252, 0.5694]}, {"w": "the", "b": [0.8308, 0.548, 0.8572, 0.5694]}, {"w": "feature", "b": [0.1429, 0.567, 0.2006, 0.5884]}, {"w": "space", "b": [0.2091, 0.567, 0.2545, 0.5884]}, {"w": "is", "b": [0.263, 0.567, 0.2762, 0.5884]}, {"w": "infinite-dimensional,", "b": [0.2847, 0.567, 0.4613, 0.5884]}, {"w": "we", "b": [0.4698, 0.567, 0.4929, 0.5884]}, {"w": "cannot", "b": [0.5014, 0.567, 0.5591, 0.5884]}, {"w": "compute", "b": [0.5676, 0.567, 0.6409, 0.5884]}, {"w": "the", "b": [0.6494, 0.567, 0.6757, 0.5884]}, {"w": "reconstructed", "b": [0.6842, 0.567, 0.7994, 0.5884]}, {"w": "point,", "b": [0.8079, 0.567, 0.8571, 0.5884]}, {"w": "and", "b": [0.1429, 0.5861, 0.1744, 0.6075]}, {"w": "therefore", "b": [0.1795, 0.5861, 0.2558, 0.6075]}, {"w": "we", "b": [0.2609, 0.5861, 0.284, 0.6075]}, {"w": "cannot", "b": [0.2891, 0.5861, 0.3469, 0.6075]}, {"w": "compute", "b": [0.352, 0.5861, 0.4253, 0.6075]}, {"w": "the", "b": [0.4304, 0.5861, 0.4567, 0.6075]}, {"w": "true", "b": [0.4618, 0.5861, 0.4958, 0.6075]}, {"w": "reconstruction", "b": [0.5009, 0.5861, 0.6239, 0.6075]}, {"w": "error.", "b": [0.629, 0.5861, 0.6751, 0.6075]}, {"w": "Fortunately,", "b": [0.6802, 0.5861, 0.78, 0.6075]}, {"w": "it", "b": [0.7852, 0.5861, 0.7971, 0.6075]}, {"w": "is", "b": [0.8022, 0.5861, 0.8154, 0.6075]}, {"w": "pos‐", "b": [0.8205, 0.5861, 0.8571, 0.6075]}, {"w": "sible", "b": [0.1428, 0.6051, 0.1808, 0.6265]}, {"w": "to", "b": [0.1872, 0.6051, 0.2042, 0.6265]}, {"w": "find", "b": [0.2106, 0.6051, 0.2448, 0.6265]}, {"w": "a", "b": [0.2512, 0.6051, 0.2604, 0.6265]}, {"w": "point", "b": [0.2668, 0.6051, 0.3113, 0.6265]}, {"w": "in", "b": [0.3177, 0.6051, 0.3347, 0.6265]}, {"w": "the", "b": [0.3411, 0.6051, 0.3675, 0.6265]}, {"w": "original", "b": [0.3739, 0.6051, 0.439, 0.6265]}, {"w": "space", "b": [0.4454, 0.6051, 0.4908, 0.6265]}, {"w": "that", "b": [0.4972, 0.6051, 0.5298, 0.6265]}, {"w": "would", "b": [0.5362, 0.6051, 0.5885, 0.6265]}, {"w": "map", "b": [0.5949, 0.6051, 0.6316, 0.6265]}, {"w": "close", "b": [0.6381, 0.6051, 0.6793, 0.6265]}, {"w": "to", "b": [0.6857, 0.6051, 0.7027, 0.6265]}, {"w": "the", "b": [0.7091, 0.6051, 0.7355, 0.6265]}, {"w": "reconstructed", "b": [0.7419, 0.6051, 0.8571, 0.6265]}, {"w": "point.", "b": [0.1429, 0.6242, 0.1921, 0.6456]}, {"w": "This", "b": [0.1975, 0.6242, 0.2347, 0.6456]}, {"w": "is", "b": [0.2401, 0.6242, 0.2533, 0.6456]}, {"w": "called", "b": [0.2587, 0.6242, 0.3071, 0.6456]}, {"w": "the", "b": [0.3125, 0.6242, 0.3388, 0.6456]}, {"w": "reconstruction", "b": [0.3442, 0.6242, 0.4672, 0.6456]}, {"w": "pre-image.", "b": [0.4726, 0.624, 0.5584, 0.6456]}, {"w": "Once", "b": [0.5638, 0.6242, 0.6085, 0.6456]}, {"w": "you", "b": [0.6139, 0.6242, 0.6451, 0.6456]}, {"w": "have", "b": [0.6505, 0.6242, 0.6889, 0.6456]}, {"w": "this", "b": [0.6943, 0.6242, 0.725, 0.6456]}, {"w": "pre-image,", "b": [0.7304, 0.6242, 0.8205, 0.6456]}, {"w": "you", "b": [0.8259, 0.6242, 0.8571, 0.6456]}, {"w": "can", "b": [0.1429, 0.6432, 0.1722, 0.6646]}, {"w": "measure", "b": [0.1773, 0.6432, 0.2477, 0.6646]}, {"w": "its", "b": [0.2528, 0.6432, 0.2724, 0.6646]}, {"w": "squared", "b": [0.2775, 0.6432, 0.3436, 0.6646]}, {"w": "distance", "b": [0.3488, 0.6432, 0.4176, 0.6646]}, {"w": "to", "b": [0.4227, 0.6432, 0.4397, 0.6646]}, {"w": "the", "b": [0.4448, 0.6432, 0.4711, 0.6646]}, {"w": "original", "b": [0.4763, 0.6432, 0.5414, 0.6646]}, {"w": "instance.", "b": [0.5465, 0.6432, 0.6204, 0.6646]}, {"w": "You", "b": [0.6256, 0.6432, 0.6579, 0.6646]}, {"w": "can", "b": [0.6631, 0.6432, 0.6924, 0.6646]}, {"w": "then", "b": [0.6975, 0.6432, 0.7353, 0.6646]}, {"w": "select", "b": [0.7404, 0.6432, 0.7862, 0.6646]}, {"w": "the", "b": [0.7913, 0.6432, 0.8177, 0.6646]}, {"w": "ker‐", "b": [0.8228, 0.6432, 0.8571, 0.6646]}, {"w": "nel", "b": [0.1429, 0.6623, 0.1684, 0.6837]}, {"w": "and", "b": [0.1731, 0.6623, 0.2047, 0.6837]}, {"w": "hyperparameters", "b": [0.2094, 0.6623, 0.3505, 0.6837]}, {"w": "that", "b": [0.3553, 0.6623, 0.3878, 0.6837]}, {"w": "minimize", "b": [0.3926, 0.6623, 0.4724, 0.6837]}, {"w": "this", "b": [0.4772, 0.6623, 0.5079, 0.6837]}, {"w": "reconstruction", "b": [0.5126, 0.6623, 0.6356, 0.6837]}, {"w": "pre-image", "b": [0.6403, 0.6623, 0.7256, 0.6837]}, {"w": "error.", "b": [0.7304, 0.6623, 0.7765, 0.6837]}]}, {"id": "b_6", "type": "paragraph", "text": "230 | Chapter 8: Dimensionality Reduction", "words": [{"w": "230", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "8:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Dimensionality", "b": [0.2673, 0.9225, 0.3562, 0.9388]}, {"w": "Reduction", "b": [0.359, 0.9225, 0.4186, 0.9388]}]}]}, {"page": 257, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "7 Scikit-Learn uses the algorithm based on Kernel Ridge Regression described in Gokhan H. Bakır, Jason Weston, and Bernhard Scholkopf, “Learning to Find Pre-images” (Tubingen, Germany: Max Planck Institute for Biological Cybernetics, 2004).", "words": [{"w": "7", "b": [0.1451, 0.8462, 0.1518, 0.8604]}, {"w": "Scikit-Learn", "b": [0.1587, 0.8447, 0.2367, 0.861]}, {"w": "uses", "b": [0.2403, 0.8447, 0.2671, 0.861]}, {"w": "the", "b": [0.2707, 0.8447, 0.2908, 0.861]}, {"w": "algorithm", "b": [0.2944, 0.8447, 0.3573, 0.861]}, {"w": "based", "b": [0.3609, 0.8447, 0.3969, 0.861]}, {"w": "on", "b": [0.4005, 0.8447, 0.4173, 0.861]}, {"w": "Kernel", "b": [0.4209, 0.8447, 0.4633, 0.861]}, {"w": "Ridge", "b": [0.4669, 0.8447, 0.5036, 0.861]}, {"w": "Regression", "b": [0.5072, 0.8447, 0.5765, 0.861]}, {"w": "described", "b": [0.5801, 0.8447, 0.6411, 0.861]}, {"w": "in", "b": [0.6447, 0.8447, 0.6577, 0.861]}, {"w": "Gokhan", "b": [0.6613, 0.8447, 0.7127, 0.861]}, {"w": "H.", "b": [0.7163, 0.8447, 0.7321, 0.861]}, {"w": "Bakır,", "b": [0.7357, 0.8447, 0.7726, 0.861]}, {"w": "Jason", "b": [0.7762, 0.8447, 0.8106, 0.861]}, {"w": "Weston,", "b": [0.1587, 0.8598, 0.2104, 0.8761]}, {"w": "and", "b": [0.214, 0.8598, 0.238, 0.8761]}, {"w": "Bernhard", "b": [0.2417, 0.8598, 0.3023, 0.8761]}, {"w": "Scholkopf,", "b": [0.3059, 0.8598, 0.3734, 0.8761]}, {"w": "“Learning", "b": [0.377, 0.8598, 0.4405, 0.8761]}, {"w": "to", "b": [0.4441, 0.8598, 0.457, 0.8761]}, {"w": "Find", "b": [0.4606, 0.8598, 0.4903, 0.8761]}, {"w": "Pre-images”", "b": [0.4939, 0.8598, 0.5711, 0.8761]}, {"w": "(Tubingen,", "b": [0.5747, 0.8598, 0.6443, 0.8761]}, {"w": "Germany:", "b": [0.648, 0.8598, 0.7116, 0.8761]}, {"w": "Max", "b": [0.7152, 0.8598, 0.7436, 0.8761]}, {"w": "Planck", "b": [0.7472, 0.8598, 0.7903, 0.8761]}, {"w": "Institute", "b": [0.794, 0.8598, 0.8478, 0.8761]}, {"w": "for", "b": [0.1587, 0.8749, 0.1774, 0.8912]}, {"w": "Biological", "b": [0.181, 0.8749, 0.2442, 0.8912]}, {"w": "Cybernetics,", "b": [0.2478, 0.8749, 0.327, 0.8912]}, {"w": "2004).", "b": [0.3306, 0.8749, 0.3702, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 8-11. Kernel PCA and the reconstruction pre-image error", "words": [{"w": "Figure", "b": [0.1429, 0.5214, 0.1943, 0.543]}, {"w": "8-11.", "b": [0.1991, 0.5214, 0.2407, 0.543]}, {"w": "Kernel", "b": [0.2455, 0.5214, 0.2988, 0.543]}, {"w": "PCA", "b": [0.3036, 0.5214, 0.3422, 0.543]}, {"w": "and", "b": [0.347, 0.5214, 0.3784, 0.543]}, {"w": "the", "b": [0.3831, 0.5214, 0.4082, 0.543]}, {"w": "reconstruction", "b": [0.413, 0.5214, 0.5292, 0.543]}, {"w": "pre-image", "b": [0.534, 0.5214, 0.6151, 0.543]}, {"w": "error", "b": [0.6199, 0.5214, 0.6604, 0.543]}]}, {"id": "b_2", "type": "paragraph", "text": "You may be wondering how to perform this reconstruction. One solution is to train a supervised regression model, with the projected instances as the training set and the original instances as the targets. Scikit-Learn will do this automatically if you set fit_inverse_transform=True, as shown in the following code:7", "words": [{"w": "You", "b": [0.1429, 0.5588, 0.1752, 0.5802]}, {"w": "may", "b": [0.1804, 0.5588, 0.2157, 0.5802]}, {"w": "be", "b": [0.2209, 0.5588, 0.2403, 0.5802]}, {"w": "wondering", "b": [0.2455, 0.5588, 0.3361, 0.5802]}, {"w": "how", "b": [0.3412, 0.5588, 0.3772, 0.5802]}, {"w": "to", "b": [0.3824, 0.5588, 0.3994, 0.5802]}, {"w": "perform", "b": [0.4045, 0.5588, 0.4736, 0.5802]}, {"w": "this", "b": [0.4787, 0.5588, 0.5095, 0.5802]}, {"w": "reconstruction.", "b": [0.5146, 0.5588, 0.6423, 0.5802]}, {"w": "One", "b": [0.6475, 0.5588, 0.6833, 0.5802]}, {"w": "solution", "b": [0.6884, 0.5588, 0.757, 0.5802]}, {"w": "is", "b": [0.7621, 0.5588, 0.7754, 0.5802]}, {"w": "to", "b": [0.7805, 0.5588, 0.7975, 0.5802]}, {"w": "train", "b": [0.8026, 0.5588, 0.8428, 0.5802]}, {"w": "a", "b": [0.848, 0.5588, 0.8571, 0.5802]}, {"w": "supervised", "b": [0.1429, 0.5778, 0.2324, 0.5992]}, {"w": "regression", "b": [0.2384, 0.5778, 0.3242, 0.5992]}, {"w": "model,", "b": [0.3302, 0.5778, 0.3877, 0.5992]}, {"w": "with", "b": [0.3937, 0.5778, 0.431, 0.5992]}, {"w": "the", "b": [0.437, 0.5778, 0.4633, 0.5992]}, {"w": "projected", "b": [0.4693, 0.5778, 0.5478, 0.5992]}, {"w": "instances", "b": [0.5537, 0.5778, 0.6306, 0.5992]}, {"w": "as", "b": [0.6365, 0.5778, 0.6533, 0.5992]}, {"w": "the", "b": [0.6593, 0.5778, 0.6856, 0.5992]}, {"w": "training", "b": [0.6916, 0.5778, 0.7585, 0.5992]}, {"w": "set", "b": [0.7645, 0.5778, 0.7873, 0.5992]}, {"w": "and", "b": [0.7933, 0.5778, 0.8249, 0.5992]}, {"w": "the", "b": [0.8308, 0.5778, 0.8572, 0.5992]}, {"w": "original", "b": [0.1429, 0.5969, 0.2079, 0.6183]}, {"w": "instances", "b": [0.2167, 0.5969, 0.2935, 0.6183]}, {"w": "as", "b": [0.3023, 0.5969, 0.3191, 0.6183]}, {"w": "the", "b": [0.3279, 0.5969, 0.3542, 0.6183]}, {"w": "targets.", "b": [0.363, 0.5969, 0.4235, 0.6183]}, {"w": "Scikit-Learn", "b": [0.4323, 0.5969, 0.5346, 0.6183]}, {"w": "will", "b": [0.5434, 0.5969, 0.5738, 0.6183]}, {"w": "do", "b": [0.5825, 0.5969, 0.6042, 0.6183]}, {"w": "this", "b": [0.6129, 0.5969, 0.6436, 0.6183]}, {"w": "automatically", "b": [0.6524, 0.5969, 0.765, 0.6183]}, {"w": "if", "b": [0.7738, 0.5969, 0.7855, 0.6183]}, {"w": "you", "b": [0.7943, 0.5969, 0.8255, 0.6183]}, {"w": "set", "b": [0.8343, 0.5969, 0.8571, 0.6183]}, {"w": "fit_inverse_transform=True,", "b": [0.1429, 0.6168, 0.4049, 0.6382]}, {"w": "as", "b": [0.4096, 0.6168, 0.4264, 0.6382]}, {"w": "shown", "b": [0.4312, 0.6168, 0.4862, 0.6382]}, {"w": "in", "b": [0.491, 0.6168, 0.5079, 0.6382]}, {"w": "the", "b": [0.5127, 0.6168, 0.539, 0.6382]}, {"w": "following", "b": [0.5437, 0.6168, 0.6227, 0.6382]}, {"w": "code:7", "b": [0.6274, 0.6168, 0.6772, 0.6382]}]}, {"id": "b_3", "type": "paragraph", "text": "rbf_pca = KernelPCA(n_components = 2, kernel=\"rbf\", gamma=0.0433, fit_inverse_transform=True) X_reduced = rbf_pca.fit_transform(X) X_preimage = rbf_pca.inverse_transform(X_reduced)", "words": [{"w": "rbf_pca", "b": [0.1766, 0.6488, 0.2356, 0.6616]}, {"w": "=", "b": [0.244, 0.6488, 0.2525, 0.6616]}, {"w": "KernelPCA(n_components", "b": [0.2609, 0.6488, 0.4464, 0.6616]}, {"w": "=", "b": [0.4549, 0.6488, 0.4633, 0.6616]}, {"w": "2,", "b": [0.4717, 0.6488, 0.4886, 0.6616]}, {"w": "kernel=\"rbf\",", "b": [0.497, 0.6488, 0.6066, 0.6616]}, {"w": "gamma=0.0433,", "b": [0.6151, 0.6488, 0.7247, 0.6616]}, {"w": "fit_inverse_transform=True)", "b": [0.3452, 0.6642, 0.5729, 0.6771]}, {"w": "X_reduced", "b": [0.1766, 0.6796, 0.2525, 0.6925]}, {"w": "=", "b": [0.2609, 0.6796, 0.2693, 0.6925]}, {"w": "rbf_pca.fit_transform(X)", "b": [0.2778, 0.6796, 0.4802, 0.6925]}, {"w": "X_preimage", "b": [0.1766, 0.6951, 0.2609, 0.7079]}, {"w": "=", "b": [0.2693, 0.6951, 0.2778, 0.7079]}, {"w": "rbf_pca.inverse_transform(X_reduced)", "b": [0.2862, 0.6951, 0.5898, 0.7079]}]}, {"id": "b_4", "type": "paragraph", "text": "By default, fit_inverse_transform=False and KernelPCA has no inverse_transform() method. This method only gets created when you set fit_inverse_transform=True.", "words": [{"w": "By", "b": [0.2714, 0.7303, 0.2914, 0.7499]}, {"w": "default,", "b": [0.2976, 0.7303, 0.3544, 0.7499]}, {"w": "fit_inverse_transform=False", "b": [0.3607, 0.7332, 0.6049, 0.747]}, {"w": "and", "b": [0.6112, 0.7303, 0.64, 0.7499]}, {"w": "KernelPCA", "b": [0.6462, 0.7332, 0.7276, 0.747]}, {"w": "has", "b": [0.7339, 0.7303, 0.7594, 0.7499]}, {"w": "no", "b": [0.7656, 0.7303, 0.7857, 0.7499]}, {"w": "inverse_transform()", "b": [0.2714, 0.7515, 0.4433, 0.7653]}, {"w": "method.", "b": [0.4544, 0.7486, 0.5182, 0.7681]}, {"w": "This", "b": [0.5293, 0.7486, 0.5633, 0.7681]}, {"w": "method", "b": [0.5744, 0.7486, 0.6338, 0.7681]}, {"w": "only", "b": [0.6449, 0.7486, 0.6786, 0.7681]}, {"w": "gets", "b": [0.6897, 0.7486, 0.7195, 0.7681]}, {"w": "created", "b": [0.7305, 0.7486, 0.7857, 0.7681]}, {"w": "when", "b": [0.2714, 0.7668, 0.3132, 0.7864]}, {"w": "you", "b": [0.3175, 0.7668, 0.346, 0.7864]}, {"w": "set", "b": [0.3504, 0.7668, 0.3713, 0.7864]}, {"w": "fit_inverse_transform=True.", "b": [0.3756, 0.7668, 0.6152, 0.7864]}]}, {"id": "b_5", "type": "paragraph", "text": "Kernel PCA | 231", "words": [{"w": "Kernel", "b": [0.7322, 0.9225, 0.7704, 0.9388]}, {"w": "PCA", "b": [0.7733, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "231", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 258, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "8 “Nonlinear Dimensionality Reduction by Locally Linear Embedding,” S. Roweis, L. Saul (2000).", "words": [{"w": "8", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Nonlinear", "b": [0.1587, 0.8749, 0.2298, 0.8912]}, {"w": "Dimensionality", "b": [0.2334, 0.8749, 0.332, 0.8912]}, {"w": "Reduction", "b": [0.3356, 0.8749, 0.4016, 0.8912]}, {"w": "by", "b": [0.4052, 0.8749, 0.4205, 0.8912]}, {"w": "Locally", "b": [0.4241, 0.8749, 0.4697, 0.8912]}, {"w": "Linear", "b": [0.4733, 0.8749, 0.5144, 0.8912]}, {"w": "Embedding,”", "b": [0.518, 0.8749, 0.5998, 0.8912]}, {"w": "S.", "b": [0.6034, 0.8749, 0.6145, 0.8912]}, {"w": "Roweis,", "b": [0.6181, 0.8749, 0.6674, 0.8912]}, {"w": "L.", "b": [0.671, 0.8749, 0.6832, 0.8912]}, {"w": "Saul", "b": [0.6868, 0.8749, 0.7134, 0.8912]}, {"w": "(2000).", "b": [0.717, 0.8749, 0.7621, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "You can then compute the reconstruction pre-image error:", "words": [{"w": "You", "b": [0.1429, 0.0791, 0.1752, 0.1005]}, {"w": "can", "b": [0.1799, 0.0791, 0.2093, 0.1005]}, {"w": "then", "b": [0.214, 0.0791, 0.2517, 0.1005]}, {"w": "compute", "b": [0.2565, 0.0791, 0.3298, 0.1005]}, {"w": "the", "b": [0.3345, 0.0791, 0.3608, 0.1005]}, {"w": "reconstruction", "b": [0.3656, 0.0791, 0.4885, 0.1005]}, {"w": "pre-image", "b": [0.4933, 0.0791, 0.5786, 0.1005]}, {"w": "error:", "b": [0.5833, 0.0791, 0.6312, 0.1005]}]}, {"id": "b_2", "type": "paragraph", "text": ">>> from sklearn.metrics import mean_squared_error >>> mean_squared_error(X, X_preimage) 32.786308795766132", "words": [{"w": ">>>", "b": [0.1766, 0.111, 0.2019, 0.1239]}, {"w": "from", "b": [0.2103, 0.111, 0.2441, 0.1239]}, {"w": "sklearn.metrics", "b": [0.2525, 0.111, 0.379, 0.1239]}, {"w": "import", "b": [0.3874, 0.111, 0.438, 0.1239]}, {"w": "mean_squared_error", "b": [0.4464, 0.111, 0.5982, 0.1239]}, {"w": ">>>", "b": [0.1766, 0.1265, 0.2019, 0.1393]}, {"w": "mean_squared_error(X,", "b": [0.2103, 0.1265, 0.3874, 0.1393]}, {"w": "X_preimage)", "b": [0.3958, 0.1265, 0.4886, 0.1393]}, {"w": "32.786308795766132", "b": [0.1766, 0.1419, 0.3284, 0.1547]}]}, {"id": "b_3", "type": "paragraph", "text": "Now you can use grid search with cross-validation to find the kernel and hyperpara‐ meters that minimize this pre-image reconstruction error.", "words": [{"w": "Now", "b": [0.1429, 0.1625, 0.1827, 0.1839]}, {"w": "you", "b": [0.1885, 0.1625, 0.2197, 0.1839]}, {"w": "can", "b": [0.2255, 0.1625, 0.2548, 0.1839]}, {"w": "use", "b": [0.2606, 0.1625, 0.2881, 0.1839]}, {"w": "grid", "b": [0.2939, 0.1625, 0.328, 0.1839]}, {"w": "search", "b": [0.3337, 0.1625, 0.387, 0.1839]}, {"w": "with", "b": [0.3928, 0.1625, 0.4301, 0.1839]}, {"w": "cross-validation", "b": [0.4359, 0.1625, 0.5691, 0.1839]}, {"w": "to", "b": [0.5749, 0.1625, 0.5918, 0.1839]}, {"w": "find", "b": [0.5976, 0.1625, 0.6317, 0.1839]}, {"w": "the", "b": [0.6375, 0.1625, 0.6638, 0.1839]}, {"w": "kernel", "b": [0.6696, 0.1625, 0.722, 0.1839]}, {"w": "and", "b": [0.7278, 0.1625, 0.7593, 0.1839]}, {"w": "hyperpara‐", "b": [0.7651, 0.1625, 0.8571, 0.1839]}, {"w": "meters", "b": [0.1429, 0.1816, 0.1994, 0.203]}, {"w": "that", "b": [0.2041, 0.1816, 0.2367, 0.203]}, {"w": "minimize", "b": [0.2414, 0.1816, 0.3213, 0.203]}, {"w": "this", "b": [0.326, 0.1816, 0.3567, 0.203]}, {"w": "pre-image", "b": [0.3614, 0.1816, 0.4467, 0.203]}, {"w": "reconstruction", "b": [0.4515, 0.1816, 0.5745, 0.203]}, {"w": "error.", "b": [0.5792, 0.1816, 0.6253, 0.203]}]}, {"id": "b_4", "type": "paragraph", "text": "LLE", "words": [{"w": "LLE", "b": [0.1429, 0.216, 0.1843, 0.2502]}]}, {"id": "b_5", "type": "paragraph", "text": "Locally Linear Embedding (LLE)8 is another very powerful nonlinear dimensionality reduction (NLDR) technique. It is a Manifold Learning technique that does not rely on projections like the previous algorithms. In a nutshell, LLE works by first measur‐ ing how each training instance linearly relates to its closest neighbors (c.n.), and then looking for a low-dimensional representation of the training set where these local relationships are best preserved (more details shortly). This makes it particularly good at unrolling twisted manifolds, especially when there is not too much noise.", "words": [{"w": "Locally", "b": [0.1429, 0.2569, 0.2007, 0.2786]}, {"w": "Linear", "b": [0.2084, 0.2569, 0.2611, 0.2786]}, {"w": "Embedding", "b": [0.2689, 0.2569, 0.3603, 0.2786]}, {"w": "(LLE)8", "b": [0.368, 0.2571, 0.4224, 0.2786]}, {"w": "is", "b": [0.4301, 0.2571, 0.4433, 0.2786]}, {"w": "another", "b": [0.451, 0.2571, 0.5163, 0.2786]}, {"w": "very", "b": [0.524, 0.2571, 0.5604, 0.2786]}, {"w": "powerful", "b": [0.5681, 0.2571, 0.643, 0.2786]}, {"w": "nonlinear", "b": [0.6507, 0.2569, 0.7291, 0.2786]}, {"w": "dimensionality", "b": [0.7369, 0.2569, 0.8571, 0.2786]}, {"w": "reduction", "b": [0.1429, 0.276, 0.2202, 0.2976]}, {"w": "(NLDR)", "b": [0.2268, 0.2762, 0.2961, 0.2976]}, {"w": "technique.", "b": [0.3028, 0.2762, 0.3902, 0.2976]}, {"w": "It", "b": [0.3968, 0.2762, 0.4095, 0.2976]}, {"w": "is", "b": [0.4161, 0.2762, 0.4293, 0.2976]}, {"w": "a", "b": [0.436, 0.2762, 0.4451, 0.2976]}, {"w": "Manifold", "b": [0.4517, 0.2762, 0.5291, 0.2976]}, {"w": "Learning", "b": [0.5358, 0.2762, 0.6108, 0.2976]}, {"w": "technique", "b": [0.6175, 0.2762, 0.7001, 0.2976]}, {"w": "that", "b": [0.7068, 0.2762, 0.7394, 0.2976]}, {"w": "does", "b": [0.746, 0.2762, 0.7841, 0.2976]}, {"w": "not", "b": [0.7907, 0.2762, 0.8191, 0.2976]}, {"w": "rely", "b": [0.8257, 0.2762, 0.8572, 0.2976]}, {"w": "on", "b": [0.1429, 0.2952, 0.1649, 0.3166]}, {"w": "projections", "b": [0.1702, 0.2952, 0.264, 0.3166]}, {"w": "like", "b": [0.2693, 0.2952, 0.2993, 0.3166]}, {"w": "the", "b": [0.3046, 0.2952, 0.3309, 0.3166]}, {"w": "previous", "b": [0.3362, 0.2952, 0.4083, 0.3166]}, {"w": "algorithms.", "b": [0.4136, 0.2952, 0.5086, 0.3166]}, {"w": "In", "b": [0.5139, 0.2952, 0.5324, 0.3166]}, {"w": "a", "b": [0.5376, 0.2952, 0.5468, 0.3166]}, {"w": "nutshell,", "b": [0.5521, 0.2952, 0.6234, 0.3166]}, {"w": "LLE", "b": [0.6287, 0.2952, 0.6629, 0.3166]}, {"w": "works", "b": [0.6682, 0.2952, 0.7188, 0.3166]}, {"w": "by", "b": [0.7241, 0.2952, 0.7442, 0.3166]}, {"w": "first", "b": [0.7495, 0.2952, 0.783, 0.3166]}, {"w": "measur‐", "b": [0.7882, 0.2952, 0.8571, 0.3166]}, {"w": "ing", "b": [0.1429, 0.3143, 0.1696, 0.3357]}, {"w": "how", "b": [0.1748, 0.3143, 0.2108, 0.3357]}, {"w": "each", "b": [0.2161, 0.3143, 0.254, 0.3357]}, {"w": "training", "b": [0.2592, 0.3143, 0.3262, 0.3357]}, {"w": "instance", "b": [0.3314, 0.3143, 0.4006, 0.3357]}, {"w": "linearly", "b": [0.4058, 0.3143, 0.4686, 0.3357]}, {"w": "relates", "b": [0.4739, 0.3143, 0.5273, 0.3357]}, {"w": "to", "b": [0.5326, 0.3143, 0.5495, 0.3357]}, {"w": "its", "b": [0.5548, 0.3143, 0.5743, 0.3357]}, {"w": "closest", "b": [0.5796, 0.3143, 0.6348, 0.3357]}, {"w": "neighbors", "b": [0.64, 0.3143, 0.7233, 0.3357]}, {"w": "(c.n.),", "b": [0.7285, 0.3143, 0.7774, 0.3357]}, {"w": "and", "b": [0.7826, 0.3143, 0.8142, 0.3357]}, {"w": "then", "b": [0.8194, 0.3143, 0.8571, 0.3357]}, {"w": "looking", "b": [0.1428, 0.3333, 0.2064, 0.3547]}, {"w": "for", "b": [0.2146, 0.3333, 0.2391, 0.3547]}, {"w": "a", "b": [0.2472, 0.3333, 0.2564, 0.3547]}, {"w": "low-dimensional", "b": [0.2645, 0.3333, 0.4057, 0.3547]}, {"w": "representation", "b": [0.4138, 0.3333, 0.5344, 0.3547]}, {"w": "of", "b": [0.5426, 0.3333, 0.5594, 0.3547]}, {"w": "the", "b": [0.5675, 0.3333, 0.5939, 0.3547]}, {"w": "training", "b": [0.602, 0.3333, 0.6689, 0.3547]}, {"w": "set", "b": [0.6771, 0.3333, 0.6999, 0.3547]}, {"w": "where", "b": [0.7081, 0.3333, 0.7589, 0.3547]}, {"w": "these", "b": [0.767, 0.3333, 0.8099, 0.3547]}, {"w": "local", "b": [0.818, 0.3333, 0.8571, 0.3547]}, {"w": "relationships", "b": [0.1429, 0.3524, 0.2503, 0.3738]}, {"w": "are", "b": [0.2595, 0.3524, 0.2852, 0.3738]}, {"w": "best", "b": [0.2944, 0.3524, 0.3278, 0.3738]}, {"w": "preserved", "b": [0.3369, 0.3524, 0.4188, 0.3738]}, {"w": "(more", "b": [0.4279, 0.3524, 0.4794, 0.3738]}, {"w": "details", "b": [0.4885, 0.3524, 0.5424, 0.3738]}, {"w": "shortly).", "b": [0.5515, 0.3524, 0.6218, 0.3738]}, {"w": "This", "b": [0.6309, 0.3524, 0.6682, 0.3738]}, {"w": "makes", "b": [0.6773, 0.3524, 0.7303, 0.3738]}, {"w": "it", "b": [0.7395, 0.3524, 0.7514, 0.3738]}, {"w": "particularly", "b": [0.7606, 0.3524, 0.8571, 0.3738]}, {"w": "good", "b": [0.1429, 0.3714, 0.1849, 0.3928]}, {"w": "at", "b": [0.1896, 0.3714, 0.2047, 0.3928]}, {"w": "unrolling", "b": [0.2094, 0.3714, 0.2875, 0.3928]}, {"w": "twisted", "b": [0.2922, 0.3714, 0.3523, 0.3928]}, {"w": "manifolds,", "b": [0.357, 0.3714, 0.4457, 0.3928]}, {"w": "especially", "b": [0.4504, 0.3714, 0.5303, 0.3928]}, {"w": "when", "b": [0.535, 0.3714, 0.5807, 0.3928]}, {"w": "there", "b": [0.5854, 0.3714, 0.6283, 0.3928]}, {"w": "is", "b": [0.6331, 0.3714, 0.6463, 0.3928]}, {"w": "not", "b": [0.651, 0.3714, 0.6794, 0.3928]}, {"w": "too", "b": [0.6841, 0.3714, 0.7117, 0.3928]}, {"w": "much", "b": [0.7165, 0.3714, 0.7641, 0.3928]}, {"w": "noise.", "b": [0.7689, 0.3714, 0.8177, 0.3928]}]}, {"id": "b_6", "type": "paragraph", "text": "For example, the following code uses Scikit-Learn’s LocallyLinearEmbedding class to unroll the Swiss roll. The resulting 2D dataset is shown in Figure 8-12. As you can see, the Swiss roll is completely unrolled and the distances between instances are locally well preserved. However, distances are not preserved on a larger scale: the left part of the unrolled Swiss roll is stretched, while the right part is squeezed. Neverthe‐ less, LLE did a pretty good job at modeling the manifold.", "words": [{"w": "For", "b": [0.1429, 0.4004, 0.1718, 0.4219]}, {"w": "example,", "b": [0.1771, 0.4004, 0.2514, 0.4219]}, {"w": "the", "b": [0.2566, 0.4004, 0.2829, 0.4219]}, {"w": "following", "b": [0.2882, 0.4004, 0.3671, 0.4219]}, {"w": "code", "b": [0.3724, 0.4004, 0.4117, 0.4219]}, {"w": "uses", "b": [0.4169, 0.4004, 0.4521, 0.4219]}, {"w": "Scikit-Learn’s", "b": [0.4573, 0.4004, 0.5682, 0.4219]}, {"w": "LocallyLinearEmbedding", "b": [0.5735, 0.4036, 0.7912, 0.4187]}, {"w": "class", "b": [0.7964, 0.4004, 0.8349, 0.4219]}, {"w": "to", "b": [0.8402, 0.4004, 0.8572, 0.4219]}, {"w": "unroll", "b": [0.1429, 0.4195, 0.1942, 0.4409]}, {"w": "the", "b": [0.2011, 0.4195, 0.2275, 0.4409]}, {"w": "Swiss", "b": [0.2344, 0.4195, 0.2794, 0.4409]}, {"w": "roll.", "b": [0.2864, 0.4195, 0.32, 0.4409]}, {"w": "The", "b": [0.3269, 0.4195, 0.3598, 0.4409]}, {"w": "resulting", "b": [0.3667, 0.4195, 0.4403, 0.4409]}, {"w": "2D", "b": [0.4473, 0.4195, 0.4726, 0.4409]}, {"w": "dataset", "b": [0.4795, 0.4195, 0.5376, 0.4409]}, {"w": "is", "b": [0.5446, 0.4195, 0.5578, 0.4409]}, {"w": "shown", "b": [0.5647, 0.4195, 0.6198, 0.4409]}, {"w": "in", "b": [0.6267, 0.4195, 0.6437, 0.4409]}, {"w": "Figure", "b": [0.6506, 0.4195, 0.7046, 0.4409]}, {"w": "8-12.", "b": [0.7115, 0.4195, 0.7537, 0.4409]}, {"w": "As", "b": [0.7606, 0.4195, 0.7827, 0.4409]}, {"w": "you", "b": [0.7896, 0.4195, 0.8209, 0.4409]}, {"w": "can", "b": [0.8278, 0.4195, 0.8571, 0.4409]}, {"w": "see,", "b": [0.1429, 0.4385, 0.173, 0.46]}, {"w": "the", "b": [0.1815, 0.4385, 0.2078, 0.46]}, {"w": "Swiss", "b": [0.2163, 0.4385, 0.2614, 0.46]}, {"w": "roll", "b": [0.2699, 0.4385, 0.2988, 0.46]}, {"w": "is", "b": [0.3073, 0.4385, 0.3205, 0.46]}, {"w": "completely", "b": [0.329, 0.4385, 0.4202, 0.46]}, {"w": "unrolled", "b": [0.4288, 0.4385, 0.5, 0.46]}, {"w": "and", "b": [0.5085, 0.4385, 0.54, 0.46]}, {"w": "the", "b": [0.5486, 0.4385, 0.5749, 0.46]}, {"w": "distances", "b": [0.5834, 0.4385, 0.6598, 0.46]}, {"w": "between", "b": [0.6684, 0.4385, 0.7375, 0.46]}, {"w": "instances", "b": [0.7461, 0.4385, 0.8229, 0.46]}, {"w": "are", "b": [0.8314, 0.4385, 0.8571, 0.46]}, {"w": "locally", "b": [0.1429, 0.4576, 0.1968, 0.479]}, {"w": "well", "b": [0.2023, 0.4576, 0.236, 0.479]}, {"w": "preserved.", "b": [0.2415, 0.4576, 0.3281, 0.479]}, {"w": "However,", "b": [0.3336, 0.4576, 0.4125, 0.479]}, {"w": "distances", "b": [0.418, 0.4576, 0.4944, 0.479]}, {"w": "are", "b": [0.4999, 0.4576, 0.5257, 0.479]}, {"w": "not", "b": [0.5312, 0.4576, 0.5596, 0.479]}, {"w": "preserved", "b": [0.5651, 0.4576, 0.6469, 0.479]}, {"w": "on", "b": [0.6524, 0.4576, 0.6745, 0.479]}, {"w": "a", "b": [0.68, 0.4576, 0.6891, 0.479]}, {"w": "larger", "b": [0.6946, 0.4576, 0.7431, 0.479]}, {"w": "scale:", "b": [0.7486, 0.4576, 0.7931, 0.479]}, {"w": "the", "b": [0.7986, 0.4576, 0.825, 0.479]}, {"w": "left", "b": [0.8305, 0.4576, 0.8571, 0.479]}, {"w": "part", "b": [0.1429, 0.4766, 0.177, 0.498]}, {"w": "of", "b": [0.1823, 0.4766, 0.1991, 0.498]}, {"w": "the", "b": [0.2044, 0.4766, 0.2307, 0.498]}, {"w": "unrolled", "b": [0.236, 0.4766, 0.3072, 0.498]}, {"w": "Swiss", "b": [0.3125, 0.4766, 0.3575, 0.498]}, {"w": "roll", "b": [0.3628, 0.4766, 0.3917, 0.498]}, {"w": "is", "b": [0.397, 0.4766, 0.4102, 0.498]}, {"w": "stretched,", "b": [0.4155, 0.4766, 0.497, 0.498]}, {"w": "while", "b": [0.5023, 0.4766, 0.5474, 0.498]}, {"w": "the", "b": [0.5527, 0.4766, 0.579, 0.498]}, {"w": "right", "b": [0.5843, 0.4766, 0.6244, 0.498]}, {"w": "part", "b": [0.6297, 0.4766, 0.6639, 0.498]}, {"w": "is", "b": [0.6691, 0.4766, 0.6824, 0.498]}, {"w": "squeezed.", "b": [0.6877, 0.4766, 0.7681, 0.498]}, {"w": "Neverthe‐", "b": [0.7734, 0.4766, 0.8572, 0.498]}, {"w": "less,", "b": [0.1429, 0.4957, 0.177, 0.5171]}, {"w": "LLE", "b": [0.1818, 0.4957, 0.216, 0.5171]}, {"w": "did", "b": [0.2207, 0.4957, 0.2483, 0.5171]}, {"w": "a", "b": [0.253, 0.4957, 0.2622, 0.5171]}, {"w": "pretty", "b": [0.2669, 0.4957, 0.3167, 0.5171]}, {"w": "good", "b": [0.3214, 0.4957, 0.3634, 0.5171]}, {"w": "job", "b": [0.3682, 0.4957, 0.3947, 0.5171]}, {"w": "at", "b": [0.3994, 0.4957, 0.4145, 0.5171]}, {"w": "modeling", "b": [0.4193, 0.4957, 0.4988, 0.5171]}, {"w": "the", "b": [0.5035, 0.4957, 0.5299, 0.5171]}, {"w": "manifold.", "b": [0.5346, 0.4957, 0.6156, 0.5171]}]}, {"id": "b_7", "type": "paragraph", "text": "from sklearn.manifold import LocallyLinearEmbedding", "words": [{"w": "from", "b": [0.1766, 0.5277, 0.2103, 0.5405]}, {"w": "sklearn.manifold", "b": [0.2188, 0.5277, 0.3537, 0.5405]}, {"w": "import", "b": [0.3621, 0.5277, 0.4127, 0.5405]}, {"w": "LocallyLinearEmbedding", "b": [0.4211, 0.5277, 0.6066, 0.5405]}]}, {"id": "b_8", "type": "paragraph", "text": "lle = LocallyLinearEmbedding(n_components=2, n_neighbors=10) X_reduced = lle.fit_transform(X)", "words": [{"w": "lle", "b": [0.1766, 0.5585, 0.2019, 0.5713]}, {"w": "=", "b": [0.2103, 0.5585, 0.2188, 0.5713]}, {"w": "LocallyLinearEmbedding(n_components=2,", "b": [0.2272, 0.5585, 0.5476, 0.5713]}, {"w": "n_neighbors=10)", "b": [0.5561, 0.5585, 0.6825, 0.5713]}, {"w": "X_reduced", "b": [0.1766, 0.5739, 0.2525, 0.5868]}, {"w": "=", "b": [0.2609, 0.5739, 0.2693, 0.5868]}, {"w": "lle.fit_transform(X)", "b": [0.2778, 0.5739, 0.4464, 0.5868]}]}, {"id": "b_9", "type": "paragraph", "text": "232 | Chapter 8: Dimensionality Reduction", "words": [{"w": "232", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "8:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Dimensionality", "b": [0.2673, 0.9225, 0.3562, 0.9388]}, {"w": "Reduction", "b": [0.359, 0.9225, 0.4186, 0.9388]}]}]}, {"page": 259, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 8-12. Unrolled Swiss roll using LLE", "words": [{"w": "Figure", "b": [0.1429, 0.4262, 0.1943, 0.4478]}, {"w": "8-12.", "b": [0.1991, 0.4262, 0.2407, 0.4478]}, {"w": "Unrolled", "b": [0.2455, 0.4262, 0.316, 0.4478]}, {"w": "Swiss", "b": [0.3207, 0.4262, 0.3638, 0.4478]}, {"w": "roll", "b": [0.3685, 0.4262, 0.3956, 0.4478]}, {"w": "using", "b": [0.4004, 0.4262, 0.4434, 0.4478]}, {"w": "LLE", "b": [0.4481, 0.4262, 0.4819, 0.4478]}]}, {"id": "b_1", "type": "paragraph", "text": "Here’s how LLE works: first, for each training instance x(i), the algorithm identifies its k closest neighbors (in the preceding code k = 10), then tries to reconstruct x(i) as a linear function of these neighbors. More specifically, it finds the weights wi,j such that the squared distance between x(i) and ∑j = 1", "words": [{"w": "Here’s", "b": [0.1429, 0.4636, 0.1928, 0.485]}, {"w": "how", "b": [0.1982, 0.4636, 0.2342, 0.485]}, {"w": "LLE", "b": [0.2396, 0.4636, 0.2738, 0.485]}, {"w": "works:", "b": [0.2792, 0.4636, 0.3346, 0.485]}, {"w": "first,", "b": [0.3399, 0.4636, 0.3782, 0.485]}, {"w": "for", "b": [0.3835, 0.4636, 0.4081, 0.485]}, {"w": "each", "b": [0.4134, 0.4636, 0.4514, 0.485]}, {"w": "training", "b": [0.4567, 0.4636, 0.5237, 0.485]}, {"w": "instance", "b": [0.5291, 0.4636, 0.5982, 0.485]}, {"w": "x(i),", "b": [0.6036, 0.4631, 0.6305, 0.485]}, {"w": "the", "b": [0.6358, 0.4636, 0.6622, 0.485]}, {"w": "algorithm", "b": [0.6675, 0.4636, 0.7502, 0.485]}, {"w": "identifies", "b": [0.7556, 0.4636, 0.8322, 0.485]}, {"w": "its", "b": [0.8376, 0.4636, 0.8571, 0.485]}, {"w": "k", "b": [0.1429, 0.4825, 0.1526, 0.5041]}, {"w": "closest", "b": [0.1592, 0.4827, 0.2144, 0.5041]}, {"w": "neighbors", "b": [0.221, 0.4827, 0.3043, 0.5041]}, {"w": "(in", "b": [0.3109, 0.4827, 0.335, 0.5041]}, {"w": "the", "b": [0.3416, 0.4827, 0.368, 0.5041]}, {"w": "preceding", "b": [0.3745, 0.4827, 0.4574, 0.5041]}, {"w": "code", "b": [0.464, 0.4827, 0.5033, 0.5041]}, {"w": "k", "b": [0.5099, 0.4825, 0.5196, 0.5041]}, {"w": "=", "b": [0.5262, 0.4827, 0.5383, 0.5041]}, {"w": "10),", "b": [0.5449, 0.4827, 0.5768, 0.5041]}, {"w": "then", "b": [0.5834, 0.4827, 0.6211, 0.5041]}, {"w": "tries", "b": [0.6277, 0.4827, 0.6639, 0.5041]}, {"w": "to", "b": [0.6704, 0.4827, 0.6874, 0.5041]}, {"w": "reconstruct", "b": [0.694, 0.4827, 0.7894, 0.5041]}, {"w": "x(i)", "b": [0.7959, 0.4821, 0.8181, 0.5041]}, {"w": "as", "b": [0.8246, 0.4827, 0.8414, 0.5041]}, {"w": "a", "b": [0.848, 0.4827, 0.8571, 0.5041]}, {"w": "linear", "b": [0.1429, 0.5017, 0.1908, 0.5231]}, {"w": "function", "b": [0.1962, 0.5017, 0.2676, 0.5231]}, {"w": "of", "b": [0.2729, 0.5017, 0.2897, 0.5231]}, {"w": "these", "b": [0.295, 0.5017, 0.3378, 0.5231]}, {"w": "neighbors.", "b": [0.3431, 0.5017, 0.4312, 0.5231]}, {"w": "More", "b": [0.4365, 0.5017, 0.4817, 0.5231]}, {"w": "specifically,", "b": [0.487, 0.5017, 0.5819, 0.5231]}, {"w": "it", "b": [0.5872, 0.5017, 0.5991, 0.5231]}, {"w": "finds", "b": [0.6044, 0.5017, 0.6462, 0.5231]}, {"w": "the", "b": [0.6515, 0.5017, 0.6779, 0.5231]}, {"w": "weights", "b": [0.6832, 0.5017, 0.7464, 0.5231]}, {"w": "wi,j", "b": [0.7517, 0.5015, 0.7753, 0.524]}, {"w": "such", "b": [0.7806, 0.5017, 0.8192, 0.5231]}, {"w": "that", "b": [0.824, 0.5017, 0.8566, 0.5231]}, {"w": "the", "b": [0.1428, 0.5233, 0.1692, 0.5447]}, {"w": "squared", "b": [0.1739, 0.5233, 0.24, 0.5447]}, {"w": "distance", "b": [0.2447, 0.5233, 0.3135, 0.5447]}, {"w": "between", "b": [0.3182, 0.5233, 0.3874, 0.5447]}, {"w": "x(i)", "b": [0.3923, 0.5228, 0.4144, 0.5447]}, {"w": "and", "b": [0.4192, 0.5233, 0.4507, 0.5447]}, {"w": "∑j", "b": [0.4554, 0.5233, 0.4725, 0.5486]}, {"w": "=", "b": [0.4769, 0.5323, 0.4861, 0.5486]}, {"w": "1", "b": [0.4905, 0.5323, 0.4981, 0.5486]}]}, {"id": "b_2", "type": "paragraph", "text": "m wi, jx j is as small as possible, assuming wi,j = 0 if x(j) is not one of the k closest neighbors of x(i). Thus the first step of LLE is the constrained optimization problem described in Equation 8-4, where W is the weight matrix containing all the weights wi,j. The second constraint simply normalizes the weights for each training instance x(i).", "words": [{"w": "m", "b": [0.4666, 0.52, 0.4791, 0.5365]}, {"w": "wi,", "b": [0.5004, 0.5231, 0.5223, 0.5486]}, {"w": "jx", "b": [0.5266, 0.5228, 0.5408, 0.5486]}, {"w": "j", "b": [0.5481, 0.52, 0.5523, 0.5365]}, {"w": "is", "b": [0.5626, 0.5233, 0.5758, 0.5447]}, {"w": "as", "b": [0.5805, 0.5233, 0.5973, 0.5447]}, {"w": "small", "b": [0.6021, 0.5233, 0.6464, 0.5447]}, {"w": "as", "b": [0.6512, 0.5233, 0.668, 0.5447]}, {"w": "possible,", "b": [0.6727, 0.5233, 0.7446, 0.5447]}, {"w": "assuming", "b": [0.7493, 0.5233, 0.8286, 0.5447]}, {"w": "wi,j", "b": [0.8335, 0.5231, 0.8571, 0.5456]}, {"w": "=", "b": [0.1429, 0.5449, 0.1549, 0.5664]}, {"w": "0", "b": [0.1609, 0.5449, 0.1709, 0.5664]}, {"w": "if", "b": [0.1768, 0.5449, 0.1885, 0.5664]}, {"w": "x(j)", "b": [0.1945, 0.5444, 0.2165, 0.5664]}, {"w": "is", "b": [0.2224, 0.5449, 0.2356, 0.5664]}, {"w": "not", "b": [0.2416, 0.5449, 0.2699, 0.5664]}, {"w": "one", "b": [0.2759, 0.5449, 0.3067, 0.5664]}, {"w": "of", "b": [0.3127, 0.5449, 0.3294, 0.5664]}, {"w": "the", "b": [0.3354, 0.5449, 0.3617, 0.5664]}, {"w": "k", "b": [0.3676, 0.5447, 0.3774, 0.5664]}, {"w": "closest", "b": [0.3833, 0.5449, 0.4386, 0.5664]}, {"w": "neighbors", "b": [0.4445, 0.5449, 0.5278, 0.5664]}, {"w": "of", "b": [0.5337, 0.5449, 0.5505, 0.5664]}, {"w": "x(i).", "b": [0.5564, 0.5444, 0.5833, 0.5664]}, {"w": "Thus", "b": [0.5892, 0.5449, 0.6315, 0.5664]}, {"w": "the", "b": [0.6374, 0.5449, 0.6637, 0.5664]}, {"w": "first", "b": [0.6697, 0.5449, 0.7031, 0.5664]}, {"w": "step", "b": [0.7091, 0.5449, 0.7428, 0.5664]}, {"w": "of", "b": [0.7488, 0.5449, 0.7656, 0.5664]}, {"w": "LLE", "b": [0.7715, 0.5449, 0.8057, 0.5664]}, {"w": "is", "b": [0.8116, 0.5449, 0.8249, 0.5664]}, {"w": "the", "b": [0.8308, 0.5449, 0.8571, 0.5664]}, {"w": "constrained", "b": [0.1429, 0.564, 0.2414, 0.5854]}, {"w": "optimization", "b": [0.2473, 0.564, 0.3549, 0.5854]}, {"w": "problem", "b": [0.3609, 0.564, 0.4319, 0.5854]}, {"w": "described", "b": [0.4378, 0.564, 0.5179, 0.5854]}, {"w": "in", "b": [0.5239, 0.564, 0.5408, 0.5854]}, {"w": "Equation", "b": [0.5468, 0.564, 0.623, 0.5854]}, {"w": "8-4,", "b": [0.629, 0.564, 0.6611, 0.5854]}, {"w": "where", "b": [0.6671, 0.564, 0.7179, 0.5854]}, {"w": "W", "b": [0.7238, 0.5634, 0.7442, 0.5854]}, {"w": "is", "b": [0.7502, 0.564, 0.7634, 0.5854]}, {"w": "the", "b": [0.7693, 0.564, 0.7957, 0.5854]}, {"w": "weight", "b": [0.8016, 0.564, 0.8572, 0.5854]}, {"w": "matrix", "b": [0.1429, 0.583, 0.1982, 0.6045]}, {"w": "containing", "b": [0.2056, 0.583, 0.2953, 0.6045]}, {"w": "all", "b": [0.3027, 0.583, 0.3224, 0.6045]}, {"w": "the", "b": [0.3298, 0.583, 0.3562, 0.6045]}, {"w": "weights", "b": [0.3636, 0.583, 0.4268, 0.6045]}, {"w": "wi,j.", "b": [0.4342, 0.5828, 0.4626, 0.6053]}, {"w": "The", "b": [0.4701, 0.583, 0.5029, 0.6045]}, {"w": "second", "b": [0.5104, 0.583, 0.5687, 0.6045]}, {"w": "constraint", "b": [0.5761, 0.583, 0.6608, 0.6045]}, {"w": "simply", "b": [0.6682, 0.583, 0.7239, 0.6045]}, {"w": "normalizes", "b": [0.7313, 0.583, 0.8234, 0.6045]}, {"w": "the", "b": [0.8308, 0.583, 0.8571, 0.6045]}, {"w": "weights", "b": [0.1429, 0.6021, 0.206, 0.6235]}, {"w": "for", "b": [0.2108, 0.6021, 0.2353, 0.6235]}, {"w": "each", "b": [0.24, 0.6021, 0.278, 0.6235]}, {"w": "training", "b": [0.2827, 0.6021, 0.3496, 0.6235]}, {"w": "instance", "b": [0.3544, 0.6021, 0.4235, 0.6235]}, {"w": "x(i).", "b": [0.4283, 0.6015, 0.4551, 0.6235]}]}, {"id": "b_3", "type": "paragraph", "text": "LLE | 233", "words": [{"w": "LLE", "b": [0.7761, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "233", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 260, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Equation 8-4. LLE step 1: linearly modeling local relationships", "words": [{"w": "Equation", "b": [0.1726, 0.0769, 0.2473, 0.0985]}, {"w": "8-4.", "b": [0.2521, 0.0769, 0.2838, 0.0985]}, {"w": "LLE", "b": [0.2886, 0.0769, 0.3224, 0.0985]}, {"w": "step", "b": [0.3271, 0.0769, 0.3585, 0.0985]}, {"w": "1:", "b": [0.3633, 0.0769, 0.3781, 0.0985]}, {"w": "linearly", "b": [0.3829, 0.0769, 0.4438, 0.0985]}, {"w": "modeling", "b": [0.4486, 0.0769, 0.5229, 0.0985]}, {"w": "local", "b": [0.5277, 0.0769, 0.5655, 0.0985]}, {"w": "relationships", "b": [0.5703, 0.0769, 0.6724, 0.0985]}]}, {"id": "b_1", "type": "equation", "text": "W = argmin", "words": [{"w": "W", "b": [0.1813, 0.1212, 0.2007, 0.1422]}, {"w": "=", "b": [0.2062, 0.1218, 0.2178, 0.1422]}, {"w": "argmin", "b": [0.2288, 0.1218, 0.2866, 0.1422]}]}, {"id": "b_2", "type": "equation", "text": "W ∑ i = 1", "words": [{"w": "W", "b": [0.2499, 0.137, 0.2654, 0.1537]}, {"w": "∑", "b": [0.3006, 0.117, 0.3157, 0.1458]}, {"w": "i", "b": [0.2932, 0.1365, 0.2975, 0.1529]}, {"w": "=", "b": [0.3019, 0.1366, 0.3111, 0.1529]}, {"w": "1", "b": [0.3155, 0.1366, 0.3231, 0.1529]}]}, {"id": "b_4", "type": "paragraph", "text": "x i −∑", "words": [{"w": "x", "b": [0.3322, 0.1212, 0.3418, 0.1422]}, {"w": "i", "b": [0.3474, 0.1179, 0.3517, 0.1343]}, {"w": "−∑", "b": [0.3616, 0.117, 0.4019, 0.1458]}]}, {"id": "b_5", "type": "equation", "text": "j = 1", "words": [{"w": "j", "b": [0.3803, 0.1365, 0.3845, 0.1529]}, {"w": "=", "b": [0.3889, 0.1366, 0.3981, 0.1529]}, {"w": "1", "b": [0.4025, 0.1366, 0.4101, 0.1529]}]}, {"id": "b_7", "type": "paragraph", "text": "wi, jx j", "words": [{"w": "wi,", "b": [0.4123, 0.1216, 0.4336, 0.1464]}, {"w": "jx", "b": [0.4378, 0.1212, 0.4516, 0.1464]}, {"w": "j", "b": [0.4589, 0.1179, 0.4631, 0.1343]}]}, {"id": "b_9", "type": "paragraph", "text": "subject to", "words": [{"w": "subject", "b": [0.1813, 0.1831, 0.2372, 0.2035]}, {"w": "to", "b": [0.2451, 0.1831, 0.2613, 0.2035]}]}, {"id": "b_10", "type": "equation", "text": "wi, j = 0 if x j is not one of the k c.n. of x i", "words": [{"w": "wi,", "b": [0.2761, 0.1597, 0.2973, 0.1845]}, {"w": "j", "b": [0.3016, 0.1681, 0.3058, 0.1845]}, {"w": "=", "b": [0.3113, 0.1599, 0.3228, 0.1803]}, {"w": "0", "b": [0.3283, 0.1599, 0.3379, 0.1803]}, {"w": "if", "b": [0.3803, 0.1599, 0.3914, 0.1803]}, {"w": "x", "b": [0.401, 0.1593, 0.4106, 0.1803]}, {"w": "j", "b": [0.4178, 0.156, 0.4221, 0.1724]}, {"w": "is", "b": [0.4355, 0.1599, 0.4481, 0.1803]}, {"w": "not", "b": [0.456, 0.1599, 0.483, 0.1803]}, {"w": "one", "b": [0.491, 0.1599, 0.5204, 0.1803]}, {"w": "of", "b": [0.5283, 0.1599, 0.5443, 0.1803]}, {"w": "the", "b": [0.5539, 0.1599, 0.579, 0.1803]}, {"w": "k", "b": [0.5869, 0.1597, 0.5962, 0.1803]}, {"w": "c.n.", "b": [0.6042, 0.1599, 0.6325, 0.1803]}, {"w": "of", "b": [0.6404, 0.1599, 0.6564, 0.1803]}, {"w": "x", "b": [0.666, 0.1593, 0.6755, 0.1803]}, {"w": "i", "b": [0.6811, 0.156, 0.6855, 0.1724]}]}, {"id": "b_11", "type": "equation", "text": "∑ j = 1", "words": [{"w": "∑", "b": [0.2843, 0.195, 0.2994, 0.2238]}, {"w": "j", "b": [0.2777, 0.2145, 0.2819, 0.2309]}, {"w": "=", "b": [0.2863, 0.2146, 0.2955, 0.2309]}, {"w": "1", "b": [0.3, 0.2146, 0.3076, 0.2309]}]}, {"id": "b_13", "type": "equation", "text": "wi, j = 1 for i = 1, 2, ⋯, m", "words": [{"w": "wi,", "b": [0.3098, 0.1996, 0.331, 0.2244]}, {"w": "j", "b": [0.3353, 0.208, 0.3395, 0.2244]}, {"w": "=", "b": [0.345, 0.1998, 0.3565, 0.2202]}, {"w": "1", "b": [0.3621, 0.1998, 0.3716, 0.2202]}, {"w": "for", "b": [0.3803, 0.1998, 0.4036, 0.2202]}, {"w": "i", "b": [0.4116, 0.1996, 0.417, 0.2202]}, {"w": "=", "b": [0.4225, 0.1998, 0.434, 0.2202]}, {"w": "1,", "b": [0.4395, 0.1998, 0.4535, 0.2202]}, {"w": "2,", "b": [0.4569, 0.1998, 0.4709, 0.2202]}, {"w": "⋯,", "b": [0.4742, 0.1998, 0.4986, 0.2202]}, {"w": "m", "b": [0.5019, 0.1996, 0.5175, 0.2202]}]}, {"id": "b_14", "type": "paragraph", "text": "After this step, the weight matrix W (containing the weights wi, j) encodes the local linear relationships between the training instances. Now the second step is to map the training instances into a d-dimensional space (where d < n) while preserving these local relationships as much as possible. If z(i) is the image of x(i) in this d-dimensional space, then we want the squared distance between z(i) and ∑j = 1", "words": [{"w": "After", "b": [0.1429, 0.2523, 0.1864, 0.2737]}, {"w": "this", "b": [0.1931, 0.2523, 0.2238, 0.2737]}, {"w": "step,", "b": [0.2306, 0.2523, 0.2685, 0.2737]}, {"w": "the", "b": [0.2753, 0.2523, 0.3016, 0.2737]}, {"w": "weight", "b": [0.3084, 0.2523, 0.3639, 0.2737]}, {"w": "matrix", "b": [0.3707, 0.2523, 0.426, 0.2737]}, {"w": "W", "b": [0.4328, 0.2517, 0.4532, 0.2737]}, {"w": "(containing", "b": [0.4599, 0.2523, 0.5568, 0.2737]}, {"w": "the", "b": [0.5635, 0.2523, 0.5899, 0.2737]}, {"w": "weights", "b": [0.5966, 0.2523, 0.6598, 0.2737]}, {"w": "wi,", "b": [0.6666, 0.2521, 0.6885, 0.2775]}, {"w": "j)", "b": [0.6928, 0.2523, 0.7042, 0.2775]}, {"w": "encodes", "b": [0.711, 0.2523, 0.7782, 0.2737]}, {"w": "the", "b": [0.7849, 0.2523, 0.8113, 0.2737]}, {"w": "local", "b": [0.818, 0.2523, 0.8571, 0.2737]}, {"w": "linear", "b": [0.1429, 0.2739, 0.1908, 0.2953]}, {"w": "relationships", "b": [0.1957, 0.2739, 0.3032, 0.2953]}, {"w": "between", "b": [0.308, 0.2739, 0.3772, 0.2953]}, {"w": "the", "b": [0.3821, 0.2739, 0.4084, 0.2953]}, {"w": "training", "b": [0.4133, 0.2739, 0.4802, 0.2953]}, {"w": "instances.", "b": [0.4851, 0.2739, 0.5667, 0.2953]}, {"w": "Now", "b": [0.5715, 0.2739, 0.6114, 0.2953]}, {"w": "the", "b": [0.6162, 0.2739, 0.6426, 0.2953]}, {"w": "second", "b": [0.6474, 0.2739, 0.7058, 0.2953]}, {"w": "step", "b": [0.7106, 0.2739, 0.7444, 0.2953]}, {"w": "is", "b": [0.7493, 0.2739, 0.7625, 0.2953]}, {"w": "to", "b": [0.7674, 0.2739, 0.7843, 0.2953]}, {"w": "map", "b": [0.7892, 0.2739, 0.8259, 0.2953]}, {"w": "the", "b": [0.8308, 0.2739, 0.8571, 0.2953]}, {"w": "training", "b": [0.1429, 0.293, 0.2098, 0.3144]}, {"w": "instances", "b": [0.217, 0.293, 0.2938, 0.3144]}, {"w": "into", "b": [0.3009, 0.293, 0.3345, 0.3144]}, {"w": "a", "b": [0.3417, 0.293, 0.3508, 0.3144]}, {"w": "d-dimensional", "b": [0.3579, 0.2927, 0.4795, 0.3144]}, {"w": "space", "b": [0.4867, 0.293, 0.532, 0.3144]}, {"w": "(where", "b": [0.5392, 0.293, 0.5972, 0.3144]}, {"w": "d", "b": [0.6044, 0.2927, 0.615, 0.3144]}, {"w": "<", "b": [0.6221, 0.293, 0.6336, 0.3144]}, {"w": "n)", "b": [0.6408, 0.2927, 0.6591, 0.3144]}, {"w": "while", "b": [0.6662, 0.293, 0.7113, 0.3144]}, {"w": "preserving", "b": [0.7185, 0.293, 0.8072, 0.3144]}, {"w": "these", "b": [0.8143, 0.293, 0.8572, 0.3144]}, {"w": "local", "b": [0.1429, 0.312, 0.182, 0.3334]}, {"w": "relationships", "b": [0.1874, 0.312, 0.2949, 0.3334]}, {"w": "as", "b": [0.3004, 0.312, 0.3172, 0.3334]}, {"w": "much", "b": [0.3226, 0.312, 0.3703, 0.3334]}, {"w": "as", "b": [0.3758, 0.312, 0.3925, 0.3334]}, {"w": "possible.", "b": [0.398, 0.312, 0.4699, 0.3334]}, {"w": "If", "b": [0.4753, 0.312, 0.4886, 0.3334]}, {"w": "z(i)", "b": [0.4941, 0.3114, 0.5154, 0.3334]}, {"w": "is", "b": [0.5208, 0.312, 0.5341, 0.3334]}, {"w": "the", "b": [0.5395, 0.312, 0.5659, 0.3334]}, {"w": "image", "b": [0.5713, 0.312, 0.6217, 0.3334]}, {"w": "of", "b": [0.6272, 0.312, 0.644, 0.3334]}, {"w": "x(i)", "b": [0.6494, 0.3114, 0.6715, 0.3334]}, {"w": "in", "b": [0.677, 0.312, 0.694, 0.3334]}, {"w": "this", "b": [0.6994, 0.312, 0.7301, 0.3334]}, {"w": "d-dimensional", "b": [0.7356, 0.3118, 0.8571, 0.3334]}, {"w": "space,", "b": [0.1429, 0.3336, 0.193, 0.355]}, {"w": "then", "b": [0.1987, 0.3336, 0.2364, 0.355]}, {"w": "we", "b": [0.2422, 0.3336, 0.2653, 0.355]}, {"w": "want", "b": [0.271, 0.3336, 0.3118, 0.355]}, {"w": "the", "b": [0.3175, 0.3336, 0.3439, 0.355]}, {"w": "squared", "b": [0.3496, 0.3336, 0.4157, 0.355]}, {"w": "distance", "b": [0.4214, 0.3336, 0.4902, 0.355]}, {"w": "between", "b": [0.4959, 0.3336, 0.5651, 0.355]}, {"w": "z(i)", "b": [0.5708, 0.3331, 0.5922, 0.355]}, {"w": "and", "b": [0.5979, 0.3336, 0.6294, 0.355]}, {"w": "∑j", "b": [0.6352, 0.3336, 0.6522, 0.3589]}, {"w": "=", "b": [0.6566, 0.3425, 0.6658, 0.3589]}, {"w": "1", "b": [0.6702, 0.3425, 0.6778, 0.3589]}]}, {"id": "b_15", "type": "paragraph", "text": "m wi, jz j to be as small as possible. This idea leads to the unconstrained optimization problem described in Equation 8-5. It looks very similar to the first step, but instead of keeping the instan‐ ces fixed and finding the optimal weights, we are doing the reverse: keeping the weights fixed and finding the optimal position of the instances’ images in the low- dimensional space. Note that Z is the matrix containing all z(i).", "words": [{"w": "m", "b": [0.6463, 0.3303, 0.6588, 0.3468]}, {"w": "wi,", "b": [0.6801, 0.3334, 0.702, 0.3589]}, {"w": "jz", "b": [0.7063, 0.3331, 0.7198, 0.3589]}, {"w": "j", "b": [0.7269, 0.3303, 0.7311, 0.3468]}, {"w": "to", "b": [0.7423, 0.3336, 0.7593, 0.355]}, {"w": "be", "b": [0.7651, 0.3336, 0.7845, 0.355]}, {"w": "as", "b": [0.7902, 0.3336, 0.807, 0.355]}, {"w": "small", "b": [0.8127, 0.3336, 0.8571, 0.355]}, {"w": "as", "b": [0.1429, 0.3552, 0.1597, 0.3766]}, {"w": "possible.", "b": [0.1662, 0.3552, 0.2381, 0.3766]}, {"w": "This", "b": [0.2446, 0.3552, 0.2818, 0.3766]}, {"w": "idea", "b": [0.2884, 0.3552, 0.3229, 0.3766]}, {"w": "leads", "b": [0.3295, 0.3552, 0.3714, 0.3766]}, {"w": "to", "b": [0.3779, 0.3552, 0.3949, 0.3766]}, {"w": "the", "b": [0.4015, 0.3552, 0.4278, 0.3766]}, {"w": "unconstrained", "b": [0.4343, 0.3552, 0.5553, 0.3766]}, {"w": "optimization", "b": [0.5619, 0.3552, 0.6695, 0.3766]}, {"w": "problem", "b": [0.676, 0.3552, 0.747, 0.3766]}, {"w": "described", "b": [0.7536, 0.3552, 0.8336, 0.3766]}, {"w": "in", "b": [0.8402, 0.3552, 0.8572, 0.3766]}, {"w": "Equation", "b": [0.1429, 0.3743, 0.2191, 0.3957]}, {"w": "8-5.", "b": [0.2247, 0.3743, 0.2569, 0.3957]}, {"w": "It", "b": [0.2625, 0.3743, 0.2751, 0.3957]}, {"w": "looks", "b": [0.2807, 0.3743, 0.3252, 0.3957]}, {"w": "very", "b": [0.3308, 0.3743, 0.3672, 0.3957]}, {"w": "similar", "b": [0.3728, 0.3743, 0.4308, 0.3957]}, {"w": "to", "b": [0.4364, 0.3743, 0.4534, 0.3957]}, {"w": "the", "b": [0.459, 0.3743, 0.4853, 0.3957]}, {"w": "first", "b": [0.4909, 0.3743, 0.5244, 0.3957]}, {"w": "step,", "b": [0.53, 0.3743, 0.5679, 0.3957]}, {"w": "but", "b": [0.5735, 0.3743, 0.6015, 0.3957]}, {"w": "instead", "b": [0.6071, 0.3743, 0.667, 0.3957]}, {"w": "of", "b": [0.6726, 0.3743, 0.6894, 0.3957]}, {"w": "keeping", "b": [0.695, 0.3743, 0.7607, 0.3957]}, {"w": "the", "b": [0.7663, 0.3743, 0.7926, 0.3957]}, {"w": "instan‐", "b": [0.7982, 0.3743, 0.8571, 0.3957]}, {"w": "ces", "b": [0.1429, 0.3933, 0.1682, 0.4147]}, {"w": "fixed", "b": [0.1771, 0.3933, 0.2185, 0.4147]}, {"w": "and", "b": [0.2275, 0.3933, 0.259, 0.4147]}, {"w": "finding", "b": [0.268, 0.3933, 0.3289, 0.4147]}, {"w": "the", "b": [0.3378, 0.3933, 0.3641, 0.4147]}, {"w": "optimal", "b": [0.3731, 0.3933, 0.438, 0.4147]}, {"w": "weights,", "b": [0.447, 0.3933, 0.5149, 0.4147]}, {"w": "we", "b": [0.5239, 0.3933, 0.547, 0.4147]}, {"w": "are", "b": [0.5559, 0.3933, 0.5817, 0.4147]}, {"w": "doing", "b": [0.5906, 0.3933, 0.639, 0.4147]}, {"w": "the", "b": [0.6479, 0.3933, 0.6742, 0.4147]}, {"w": "reverse:", "b": [0.6832, 0.3933, 0.7472, 0.4147]}, {"w": "keeping", "b": [0.7562, 0.3933, 0.8219, 0.4147]}, {"w": "the", "b": [0.8308, 0.3933, 0.8571, 0.4147]}, {"w": "weights", "b": [0.1428, 0.4124, 0.206, 0.4338]}, {"w": "fixed", "b": [0.2133, 0.4124, 0.2547, 0.4338]}, {"w": "and", "b": [0.262, 0.4124, 0.2936, 0.4338]}, {"w": "finding", "b": [0.3008, 0.4124, 0.3617, 0.4338]}, {"w": "the", "b": [0.369, 0.4124, 0.3953, 0.4338]}, {"w": "optimal", "b": [0.4026, 0.4124, 0.4675, 0.4338]}, {"w": "position", "b": [0.4748, 0.4124, 0.5435, 0.4338]}, {"w": "of", "b": [0.5508, 0.4124, 0.5676, 0.4338]}, {"w": "the", "b": [0.5749, 0.4124, 0.6012, 0.4338]}, {"w": "instances’", "b": [0.6085, 0.4124, 0.6891, 0.4338]}, {"w": "images", "b": [0.6964, 0.4124, 0.7544, 0.4338]}, {"w": "in", "b": [0.7617, 0.4124, 0.7787, 0.4338]}, {"w": "the", "b": [0.7859, 0.4124, 0.8123, 0.4338]}, {"w": "low-", "b": [0.8196, 0.4124, 0.8571, 0.4338]}, {"w": "dimensional", "b": [0.1429, 0.4314, 0.2464, 0.4528]}, {"w": "space.", "b": [0.2512, 0.4314, 0.3013, 0.4528]}, {"w": "Note", "b": [0.306, 0.4314, 0.3468, 0.4528]}, {"w": "that", "b": [0.3515, 0.4314, 0.3841, 0.4528]}, {"w": "Z", "b": [0.3888, 0.4309, 0.4017, 0.4528]}, {"w": "is", "b": [0.4065, 0.4314, 0.4197, 0.4528]}, {"w": "the", "b": [0.4244, 0.4314, 0.4508, 0.4528]}, {"w": "matrix", "b": [0.4555, 0.4314, 0.5108, 0.4528]}, {"w": "containing", "b": [0.5155, 0.4314, 0.6052, 0.4528]}, {"w": "all", "b": [0.6099, 0.4314, 0.6296, 0.4528]}, {"w": "z(i).", "b": [0.6343, 0.4309, 0.6604, 0.4528]}]}, {"id": "b_16", "type": "paragraph", "text": "Equation 8-5. LLE step 2: reducing dimensionality while preserving relationships", "words": [{"w": "Equation", "b": [0.1726, 0.471, 0.2473, 0.4926]}, {"w": "8-5.", "b": [0.2521, 0.471, 0.2838, 0.4926]}, {"w": "LLE", "b": [0.2886, 0.471, 0.3224, 0.4926]}, {"w": "step", "b": [0.3271, 0.471, 0.3585, 0.4926]}, {"w": "2:", "b": [0.3633, 0.471, 0.3781, 0.4926]}, {"w": "reducing", "b": [0.3829, 0.471, 0.4526, 0.4926]}, {"w": "dimensionality", "b": [0.4574, 0.471, 0.5776, 0.4926]}, {"w": "while", "b": [0.5824, 0.471, 0.6256, 0.4926]}, {"w": "preserving", "b": [0.6304, 0.471, 0.7137, 0.4926]}, {"w": "relationships", "b": [0.7185, 0.471, 0.8206, 0.4926]}]}, {"id": "b_17", "type": "equation", "text": "Z = argmin", "words": [{"w": "Z", "b": [0.1726, 0.5153, 0.1849, 0.5362]}, {"w": "=", "b": [0.1904, 0.5159, 0.2019, 0.5362]}, {"w": "argmin", "b": [0.2129, 0.5159, 0.2707, 0.5362]}]}, {"id": "b_18", "type": "equation", "text": "Z ∑ i = 1", "words": [{"w": "Z", "b": [0.2369, 0.5311, 0.2467, 0.5478]}, {"w": "∑", "b": [0.2848, 0.5111, 0.2999, 0.5399]}, {"w": "i", "b": [0.2773, 0.5305, 0.2817, 0.547]}, {"w": "=", "b": [0.2861, 0.5307, 0.2953, 0.547]}, {"w": "1", "b": [0.2997, 0.5307, 0.3073, 0.547]}]}, {"id": "b_20", "type": "paragraph", "text": "z i −∑", "words": [{"w": "z", "b": [0.3164, 0.5153, 0.3252, 0.5362]}, {"w": "i", "b": [0.3307, 0.512, 0.335, 0.5284]}, {"w": "−∑", "b": [0.3449, 0.5111, 0.3852, 0.5399]}]}, {"id": "b_21", "type": "equation", "text": "j = 1", "words": [{"w": "j", "b": [0.3636, 0.5305, 0.3678, 0.547]}, {"w": "=", "b": [0.3722, 0.5307, 0.3814, 0.547]}, {"w": "1", "b": [0.3858, 0.5307, 0.3934, 0.547]}]}, {"id": "b_23", "type": "paragraph", "text": "wi, jz j", "words": [{"w": "wi,", "b": [0.3956, 0.5157, 0.4169, 0.5405]}, {"w": "jz", "b": [0.4212, 0.5153, 0.4342, 0.5405]}, {"w": "j", "b": [0.4413, 0.512, 0.4455, 0.5284]}]}, {"id": "b_25", "type": "paragraph", "text": "Scikit-Learn’s LLE implementation has the following computational complexity: O(m log(m)n log(k)) for finding the k nearest neighbors, O(mnk3) for optimizing the weights, and O(dm2) for constructing the low-dimensional representations. Unfortu‐ nately, the m2 in the last term makes this algorithm scale poorly to very large datasets.", "words": [{"w": "Scikit-Learn’s", "b": [0.1429, 0.5669, 0.2538, 0.5883]}, {"w": "LLE", "b": [0.2656, 0.5669, 0.2999, 0.5883]}, {"w": "implementation", "b": [0.3118, 0.5669, 0.445, 0.5883]}, {"w": "has", "b": [0.4569, 0.5669, 0.4849, 0.5883]}, {"w": "the", "b": [0.4967, 0.5669, 0.5231, 0.5883]}, {"w": "following", "b": [0.535, 0.5669, 0.6139, 0.5883]}, {"w": "computational", "b": [0.6258, 0.5669, 0.7474, 0.5883]}, {"w": "complexity:", "b": [0.7593, 0.5669, 0.8571, 0.5883]}, {"w": "O(m", "b": [0.1428, 0.5857, 0.1812, 0.6073]}, {"w": "log(m)n", "b": [0.1868, 0.5857, 0.2544, 0.6073]}, {"w": "log(k))", "b": [0.26, 0.5857, 0.317, 0.6073]}, {"w": "for", "b": [0.3227, 0.5859, 0.3472, 0.6073]}, {"w": "finding", "b": [0.3528, 0.5859, 0.4137, 0.6073]}, {"w": "the", "b": [0.4193, 0.5859, 0.4456, 0.6073]}, {"w": "k", "b": [0.4513, 0.5857, 0.461, 0.6073]}, {"w": "nearest", "b": [0.4667, 0.5859, 0.5266, 0.6073]}, {"w": "neighbors,", "b": [0.5323, 0.5859, 0.6203, 0.6073]}, {"w": "O(mnk3)", "b": [0.6259, 0.5857, 0.6978, 0.6073]}, {"w": "for", "b": [0.7035, 0.5859, 0.728, 0.6073]}, {"w": "optimizing", "b": [0.7336, 0.5859, 0.8252, 0.6073]}, {"w": "the", "b": [0.8308, 0.5859, 0.8571, 0.6073]}, {"w": "weights,", "b": [0.1429, 0.605, 0.2108, 0.6264]}, {"w": "and", "b": [0.2167, 0.605, 0.2482, 0.6264]}, {"w": "O(dm2)", "b": [0.2541, 0.6048, 0.316, 0.6264]}, {"w": "for", "b": [0.3219, 0.605, 0.3464, 0.6264]}, {"w": "constructing", "b": [0.3523, 0.605, 0.4578, 0.6264]}, {"w": "the", "b": [0.4637, 0.605, 0.4901, 0.6264]}, {"w": "low-dimensional", "b": [0.496, 0.605, 0.6371, 0.6264]}, {"w": "representations.", "b": [0.643, 0.605, 0.7761, 0.6264]}, {"w": "Unfortu‐", "b": [0.782, 0.605, 0.8571, 0.6264]}, {"w": "nately,", "b": [0.1428, 0.624, 0.1963, 0.6454]}, {"w": "the", "b": [0.201, 0.624, 0.2273, 0.6454]}, {"w": "m2", "b": [0.2321, 0.6238, 0.2545, 0.6454]}, {"w": "in", "b": [0.2592, 0.624, 0.2762, 0.6454]}, {"w": "the", "b": [0.2809, 0.624, 0.3072, 0.6454]}, {"w": "last", "b": [0.312, 0.624, 0.3404, 0.6454]}, {"w": "term", "b": [0.3451, 0.624, 0.3851, 0.6454]}, {"w": "makes", "b": [0.3898, 0.624, 0.4429, 0.6454]}, {"w": "this", "b": [0.4476, 0.624, 0.4783, 0.6454]}, {"w": "algorithm", "b": [0.483, 0.624, 0.5657, 0.6454]}, {"w": "scale", "b": [0.5704, 0.624, 0.6102, 0.6454]}, {"w": "poorly", "b": [0.6149, 0.624, 0.6696, 0.6454]}, {"w": "to", "b": [0.6743, 0.624, 0.6913, 0.6454]}, {"w": "very", "b": [0.696, 0.624, 0.7324, 0.6454]}, {"w": "large", "b": [0.7372, 0.624, 0.7779, 0.6454]}, {"w": "datasets.", "b": [0.7827, 0.624, 0.8532, 0.6454]}]}, {"id": "b_26", "type": "paragraph", "text": "Other Dimensionality Reduction Techniques", "words": [{"w": "Other", "b": [0.1429, 0.6584, 0.2124, 0.6927]}, {"w": "Dimensionality", "b": [0.2183, 0.6584, 0.4053, 0.6927]}, {"w": "Reduction", "b": [0.4112, 0.6584, 0.5365, 0.6927]}, {"w": "Techniques", "b": [0.5424, 0.6584, 0.6817, 0.6927]}]}, {"id": "b_27", "type": "paragraph", "text": "There are many other dimensionality reduction techniques, several of which are available in Scikit-Learn. Here are some of the most popular:", "words": [{"w": "There", "b": [0.1429, 0.6996, 0.1923, 0.721]}, {"w": "are", "b": [0.2018, 0.6996, 0.2276, 0.721]}, {"w": "many", "b": [0.2371, 0.6996, 0.2838, 0.721]}, {"w": "other", "b": [0.2934, 0.6996, 0.3381, 0.721]}, {"w": "dimensionality", "b": [0.3476, 0.6996, 0.4727, 0.721]}, {"w": "reduction", "b": [0.4822, 0.6996, 0.5637, 0.721]}, {"w": "techniques,", "b": [0.5732, 0.6996, 0.6683, 0.721]}, {"w": "several", "b": [0.6779, 0.6996, 0.735, 0.721]}, {"w": "of", "b": [0.7446, 0.6996, 0.7614, 0.721]}, {"w": "which", "b": [0.7709, 0.6996, 0.8218, 0.721]}, {"w": "are", "b": [0.8314, 0.6996, 0.8571, 0.721]}, {"w": "available", "b": [0.1429, 0.7186, 0.2151, 0.7401]}, {"w": "in", "b": [0.2199, 0.7186, 0.2368, 0.7401]}, {"w": "Scikit-Learn.", "b": [0.2416, 0.7186, 0.3486, 0.7401]}, {"w": "Here", "b": [0.3533, 0.7186, 0.3942, 0.7401]}, {"w": "are", "b": [0.3989, 0.7186, 0.4247, 0.7401]}, {"w": "some", "b": [0.4294, 0.7186, 0.4736, 0.7401]}, {"w": "of", "b": [0.4783, 0.7186, 0.4951, 0.7401]}, {"w": "the", "b": [0.4998, 0.7186, 0.5262, 0.7401]}, {"w": "most", "b": [0.5309, 0.7186, 0.5726, 0.7401]}, {"w": "popular:", "b": [0.5773, 0.7186, 0.6482, 0.7401]}]}, {"id": "b_28", "type": "paragraph", "text": "• Multidimensional Scaling (MDS) reduces dimensionality while trying to preserve the distances between the instances (see Figure 8-13).", "words": [{"w": "•", "b": [0.16, 0.7528, 0.1682, 0.7742]}, {"w": "Multidimensional", "b": [0.1786, 0.7526, 0.3234, 0.7742]}, {"w": "Scaling", "b": [0.3291, 0.7526, 0.3867, 0.7742]}, {"w": "(MDS)", "b": [0.3923, 0.7528, 0.4505, 0.7742]}, {"w": "reduces", "b": [0.4561, 0.7528, 0.52, 0.7742]}, {"w": "dimensionality", "b": [0.5257, 0.7528, 0.6507, 0.7742]}, {"w": "while", "b": [0.6564, 0.7528, 0.7015, 0.7742]}, {"w": "trying", "b": [0.7071, 0.7528, 0.7581, 0.7742]}, {"w": "to", "b": [0.7637, 0.7528, 0.7807, 0.7742]}, {"w": "preserve", "b": [0.7863, 0.7528, 0.8571, 0.7742]}, {"w": "the", "b": [0.1786, 0.7719, 0.2049, 0.7933]}, {"w": "distances", "b": [0.2096, 0.7719, 0.2861, 0.7933]}, {"w": "between", "b": [0.2908, 0.7719, 0.36, 0.7933]}, {"w": "the", "b": [0.3647, 0.7719, 0.391, 0.7933]}, {"w": "instances", "b": [0.3958, 0.7719, 0.4726, 0.7933]}, {"w": "(see", "b": [0.4773, 0.7719, 0.5099, 0.7933]}, {"w": "Figure", "b": [0.5146, 0.7719, 0.5686, 0.7933]}, {"w": "8-13).", "b": [0.5733, 0.7719, 0.6227, 0.7933]}]}, {"id": "b_29", "type": "paragraph", "text": "234 | Chapter 8: Dimensionality Reduction", "words": [{"w": "234", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "8:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Dimensionality", "b": [0.2673, 0.9225, 0.3562, 0.9388]}, {"w": "Reduction", "b": [0.359, 0.9225, 0.4186, 0.9388]}]}]}, {"page": 261, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "9 The geodesic distance between two nodes in a graph is the number of nodes on the shortest path between these nodes.", "words": [{"w": "9", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "The", "b": [0.1587, 0.8598, 0.1837, 0.8761]}, {"w": "geodesic", "b": [0.1873, 0.8598, 0.2415, 0.8761]}, {"w": "distance", "b": [0.2451, 0.8598, 0.2976, 0.8761]}, {"w": "between", "b": [0.3012, 0.8598, 0.3539, 0.8761]}, {"w": "two", "b": [0.3575, 0.8598, 0.3813, 0.8761]}, {"w": "nodes", "b": [0.3849, 0.8598, 0.4226, 0.8761]}, {"w": "in", "b": [0.4262, 0.8598, 0.4391, 0.8761]}, {"w": "a", "b": [0.4427, 0.8598, 0.4497, 0.8761]}, {"w": "graph", "b": [0.4533, 0.8598, 0.4901, 0.8761]}, {"w": "is", "b": [0.4937, 0.8598, 0.5038, 0.8761]}, {"w": "the", "b": [0.5074, 0.8598, 0.5274, 0.8761]}, {"w": "number", "b": [0.531, 0.8598, 0.5816, 0.8761]}, {"w": "of", "b": [0.5852, 0.8598, 0.598, 0.8761]}, {"w": "nodes", "b": [0.6016, 0.8598, 0.6393, 0.8761]}, {"w": "on", "b": [0.6429, 0.8598, 0.6597, 0.8761]}, {"w": "the", "b": [0.6633, 0.8598, 0.6833, 0.8761]}, {"w": "shortest", "b": [0.6869, 0.8598, 0.7375, 0.8761]}, {"w": "path", "b": [0.7411, 0.8598, 0.7694, 0.8761]}, {"w": "between", "b": [0.773, 0.8598, 0.8257, 0.8761]}, {"w": "these", "b": [0.1587, 0.8749, 0.1914, 0.8912]}, {"w": "nodes.", "b": [0.195, 0.8749, 0.2363, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "• Isomap creates a graph by connecting each instance to its nearest neighbors, then reduces dimensionality while trying to preserve the geodesic distances9 between the instances.", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "Isomap", "b": [0.1786, 0.0789, 0.2381, 0.1005]}, {"w": "creates", "b": [0.2433, 0.0791, 0.3003, 0.1005]}, {"w": "a", "b": [0.3054, 0.0791, 0.3146, 0.1005]}, {"w": "graph", "b": [0.3197, 0.0791, 0.368, 0.1005]}, {"w": "by", "b": [0.3732, 0.0791, 0.3933, 0.1005]}, {"w": "connecting", "b": [0.3985, 0.0791, 0.4915, 0.1005]}, {"w": "each", "b": [0.4967, 0.0791, 0.5346, 0.1005]}, {"w": "instance", "b": [0.5398, 0.0791, 0.609, 0.1005]}, {"w": "to", "b": [0.6141, 0.0791, 0.6311, 0.1005]}, {"w": "its", "b": [0.6363, 0.0791, 0.6559, 0.1005]}, {"w": "nearest", "b": [0.661, 0.0791, 0.721, 0.1005]}, {"w": "neighbors,", "b": [0.7262, 0.0791, 0.8142, 0.1005]}, {"w": "then", "b": [0.8194, 0.0791, 0.8571, 0.1005]}, {"w": "reduces", "b": [0.1786, 0.0981, 0.2425, 0.1195]}, {"w": "dimensionality", "b": [0.2498, 0.0981, 0.3749, 0.1195]}, {"w": "while", "b": [0.3822, 0.0981, 0.4273, 0.1195]}, {"w": "trying", "b": [0.4346, 0.0981, 0.4856, 0.1195]}, {"w": "to", "b": [0.4929, 0.0981, 0.5099, 0.1195]}, {"w": "preserve", "b": [0.5172, 0.0981, 0.588, 0.1195]}, {"w": "the", "b": [0.5954, 0.0981, 0.6217, 0.1195]}, {"w": "geodesic", "b": [0.629, 0.0979, 0.6947, 0.1195]}, {"w": "distances9", "b": [0.7021, 0.0979, 0.7807, 0.1195]}, {"w": "between", "b": [0.788, 0.0981, 0.8571, 0.1195]}, {"w": "the", "b": [0.1786, 0.1172, 0.2049, 0.1386]}, {"w": "instances.", "b": [0.2096, 0.1172, 0.2912, 0.1386]}]}, {"id": "b_2", "type": "paragraph", "text": "• t-Distributed Stochastic Neighbor Embedding (t-SNE) reduces dimensionality while trying to keep similar instances close and dissimilar instances apart. It is mostly used for visualization, in particular to visualize clusters of instances in high-dimensional space (e.g., to visualize the MNIST images in 2D).", "words": [{"w": "•", "b": [0.16, 0.1423, 0.1681, 0.1637]}, {"w": "t-Distributed", "b": [0.1786, 0.142, 0.2845, 0.1637]}, {"w": "Stochastic", "b": [0.2965, 0.142, 0.377, 0.1637]}, {"w": "Neighbor", "b": [0.389, 0.142, 0.4632, 0.1637]}, {"w": "Embedding", "b": [0.4753, 0.142, 0.5666, 0.1637]}, {"w": "(t-SNE)", "b": [0.5787, 0.1423, 0.6441, 0.1637]}, {"w": "reduces", "b": [0.6561, 0.1423, 0.72, 0.1637]}, {"w": "dimensionality", "b": [0.7321, 0.1423, 0.8571, 0.1637]}, {"w": "while", "b": [0.1786, 0.1613, 0.2237, 0.1827]}, {"w": "trying", "b": [0.2309, 0.1613, 0.2819, 0.1827]}, {"w": "to", "b": [0.289, 0.1613, 0.306, 0.1827]}, {"w": "keep", "b": [0.3132, 0.1613, 0.3522, 0.1827]}, {"w": "similar", "b": [0.3594, 0.1613, 0.4174, 0.1827]}, {"w": "instances", "b": [0.4246, 0.1613, 0.5014, 0.1827]}, {"w": "close", "b": [0.5086, 0.1613, 0.5498, 0.1827]}, {"w": "and", "b": [0.557, 0.1613, 0.5886, 0.1827]}, {"w": "dissimilar", "b": [0.5958, 0.1613, 0.678, 0.1827]}, {"w": "instances", "b": [0.6852, 0.1613, 0.762, 0.1827]}, {"w": "apart.", "b": [0.7692, 0.1613, 0.8169, 0.1827]}, {"w": "It", "b": [0.8241, 0.1613, 0.8367, 0.1827]}, {"w": "is", "b": [0.8439, 0.1613, 0.8571, 0.1827]}, {"w": "mostly", "b": [0.1786, 0.1803, 0.2351, 0.2018]}, {"w": "used", "b": [0.243, 0.1803, 0.2816, 0.2018]}, {"w": "for", "b": [0.2896, 0.1803, 0.3141, 0.2018]}, {"w": "visualization,", "b": [0.3221, 0.1803, 0.4322, 0.2018]}, {"w": "in", "b": [0.4402, 0.1803, 0.4571, 0.2018]}, {"w": "particular", "b": [0.4651, 0.1803, 0.5469, 0.2018]}, {"w": "to", "b": [0.5548, 0.1803, 0.5718, 0.2018]}, {"w": "visualize", "b": [0.5798, 0.1803, 0.6513, 0.2018]}, {"w": "clusters", "b": [0.6593, 0.1803, 0.7226, 0.2018]}, {"w": "of", "b": [0.7306, 0.1803, 0.7474, 0.2018]}, {"w": "instances", "b": [0.7554, 0.1803, 0.8322, 0.2018]}, {"w": "in", "b": [0.8402, 0.1803, 0.8571, 0.2018]}, {"w": "high-dimensional", "b": [0.1786, 0.1994, 0.3271, 0.2208]}, {"w": "space", "b": [0.3319, 0.1994, 0.3772, 0.2208]}, {"w": "(e.g.,", "b": [0.382, 0.1994, 0.422, 0.2208]}, {"w": "to", "b": [0.4268, 0.1994, 0.4437, 0.2208]}, {"w": "visualize", "b": [0.4485, 0.1994, 0.52, 0.2208]}, {"w": "the", "b": [0.5247, 0.1994, 0.5511, 0.2208]}, {"w": "MNIST", "b": [0.5558, 0.1994, 0.6197, 0.2208]}, {"w": "images", "b": [0.6244, 0.1994, 0.6824, 0.2208]}, {"w": "in", "b": [0.6872, 0.1994, 0.7042, 0.2208]}, {"w": "2D).", "b": [0.7089, 0.1994, 0.7462, 0.2208]}]}, {"id": "b_3", "type": "paragraph", "text": "• Linear Discriminant Analysis (LDA) is actually a classification algorithm, but dur‐ ing training it learns the most discriminative axes between the classes, and these axes can then be used to define a hyperplane onto which to project the data. The benefit is that the projection will keep classes as far apart as possible, so LDA is a good technique to reduce dimensionality before running another classification algorithm such as an SVM classifier.", "words": [{"w": "•", "b": [0.16, 0.2245, 0.1682, 0.2459]}, {"w": "Linear", "b": [0.1786, 0.2243, 0.2313, 0.2459]}, {"w": "Discriminant", "b": [0.236, 0.2243, 0.3442, 0.2459]}, {"w": "Analysis", "b": [0.349, 0.2243, 0.4174, 0.2459]}, {"w": "(LDA)", "b": [0.4222, 0.2245, 0.4768, 0.2459]}, {"w": "is", "b": [0.4815, 0.2245, 0.4948, 0.2459]}, {"w": "actually", "b": [0.4996, 0.2245, 0.5642, 0.2459]}, {"w": "a", "b": [0.5689, 0.2245, 0.5781, 0.2459]}, {"w": "classification", "b": [0.5828, 0.2245, 0.6902, 0.2459]}, {"w": "algorithm,", "b": [0.6949, 0.2245, 0.7823, 0.2459]}, {"w": "but", "b": [0.787, 0.2245, 0.815, 0.2459]}, {"w": "dur‐", "b": [0.8198, 0.2245, 0.857, 0.2459]}, {"w": "ing", "b": [0.1786, 0.2435, 0.2053, 0.2649]}, {"w": "training", "b": [0.2111, 0.2435, 0.2781, 0.2649]}, {"w": "it", "b": [0.2839, 0.2435, 0.2959, 0.2649]}, {"w": "learns", "b": [0.3017, 0.2435, 0.3518, 0.2649]}, {"w": "the", "b": [0.3576, 0.2435, 0.3839, 0.2649]}, {"w": "most", "b": [0.3898, 0.2435, 0.4315, 0.2649]}, {"w": "discriminative", "b": [0.4373, 0.2435, 0.5569, 0.2649]}, {"w": "axes", "b": [0.5628, 0.2435, 0.5982, 0.2649]}, {"w": "between", "b": [0.6041, 0.2435, 0.6733, 0.2649]}, {"w": "the", "b": [0.6791, 0.2435, 0.7054, 0.2649]}, {"w": "classes,", "b": [0.7113, 0.2435, 0.7711, 0.2649]}, {"w": "and", "b": [0.7769, 0.2435, 0.8085, 0.2649]}, {"w": "these", "b": [0.8143, 0.2435, 0.8571, 0.2649]}, {"w": "axes", "b": [0.1786, 0.2626, 0.2141, 0.284]}, {"w": "can", "b": [0.2195, 0.2626, 0.2489, 0.284]}, {"w": "then", "b": [0.2544, 0.2626, 0.2921, 0.284]}, {"w": "be", "b": [0.2976, 0.2626, 0.3171, 0.284]}, {"w": "used", "b": [0.3226, 0.2626, 0.3611, 0.284]}, {"w": "to", "b": [0.3666, 0.2626, 0.3836, 0.284]}, {"w": "define", "b": [0.3891, 0.2626, 0.4409, 0.284]}, {"w": "a", "b": [0.4464, 0.2626, 0.4556, 0.284]}, {"w": "hyperplane", "b": [0.4611, 0.2626, 0.5544, 0.284]}, {"w": "onto", "b": [0.5599, 0.2626, 0.5985, 0.284]}, {"w": "which", "b": [0.604, 0.2626, 0.6549, 0.284]}, {"w": "to", "b": [0.6604, 0.2626, 0.6774, 0.284]}, {"w": "project", "b": [0.6829, 0.2626, 0.7415, 0.284]}, {"w": "the", "b": [0.747, 0.2626, 0.7733, 0.284]}, {"w": "data.", "b": [0.7788, 0.2626, 0.8188, 0.284]}, {"w": "The", "b": [0.8243, 0.2626, 0.8571, 0.284]}, {"w": "benefit", "b": [0.1786, 0.2816, 0.2364, 0.303]}, {"w": "is", "b": [0.2417, 0.2816, 0.2549, 0.303]}, {"w": "that", "b": [0.2603, 0.2816, 0.2929, 0.303]}, {"w": "the", "b": [0.2983, 0.2816, 0.3246, 0.303]}, {"w": "projection", "b": [0.33, 0.2816, 0.4162, 0.303]}, {"w": "will", "b": [0.4215, 0.2816, 0.4519, 0.303]}, {"w": "keep", "b": [0.4573, 0.2816, 0.4963, 0.303]}, {"w": "classes", "b": [0.5016, 0.2816, 0.5567, 0.303]}, {"w": "as", "b": [0.562, 0.2816, 0.5788, 0.303]}, {"w": "far", "b": [0.5842, 0.2816, 0.6072, 0.303]}, {"w": "apart", "b": [0.6126, 0.2816, 0.6555, 0.303]}, {"w": "as", "b": [0.6608, 0.2816, 0.6776, 0.303]}, {"w": "possible,", "b": [0.683, 0.2816, 0.7549, 0.303]}, {"w": "so", "b": [0.7602, 0.2816, 0.7785, 0.303]}, {"w": "LDA", "b": [0.7839, 0.2816, 0.824, 0.303]}, {"w": "is", "b": [0.8294, 0.2816, 0.8426, 0.303]}, {"w": "a", "b": [0.848, 0.2816, 0.8571, 0.303]}, {"w": "good", "b": [0.1786, 0.3007, 0.2206, 0.3221]}, {"w": "technique", "b": [0.2283, 0.3007, 0.311, 0.3221]}, {"w": "to", "b": [0.3187, 0.3007, 0.3357, 0.3221]}, {"w": "reduce", "b": [0.3434, 0.3007, 0.3997, 0.3221]}, {"w": "dimensionality", "b": [0.4075, 0.3007, 0.5325, 0.3221]}, {"w": "before", "b": [0.5402, 0.3007, 0.5931, 0.3221]}, {"w": "running", "b": [0.6008, 0.3007, 0.6691, 0.3221]}, {"w": "another", "b": [0.6768, 0.3007, 0.742, 0.3221]}, {"w": "classification", "b": [0.7498, 0.3007, 0.8571, 0.3221]}, {"w": "algorithm", "b": [0.1786, 0.3197, 0.2612, 0.3411]}, {"w": "such", "b": [0.266, 0.3197, 0.3046, 0.3411]}, {"w": "as", "b": [0.3093, 0.3197, 0.3261, 0.3411]}, {"w": "an", "b": [0.3309, 0.3197, 0.3514, 0.3411]}, {"w": "SVM", "b": [0.3561, 0.3197, 0.3992, 0.3411]}, {"w": "classifier.", "b": [0.4039, 0.3197, 0.4798, 0.3411]}]}, {"id": "b_4", "type": "equation", "text": "Figure 8-13. Reducing the Swiss roll to 2D using various techniques", "words": [{"w": "Figure", "b": [0.1429, 0.5551, 0.1943, 0.5767]}, {"w": "8-13.", "b": [0.1991, 0.5551, 0.2407, 0.5767]}, {"w": "Reducing", "b": [0.2455, 0.5551, 0.3204, 0.5767]}, {"w": "the", "b": [0.3252, 0.5551, 0.3502, 0.5767]}, {"w": "Swiss", "b": [0.355, 0.5551, 0.398, 0.5767]}, {"w": "roll", "b": [0.4028, 0.5551, 0.4299, 0.5767]}, {"w": "to", "b": [0.4346, 0.5551, 0.4506, 0.5767]}, {"w": "2D", "b": [0.4554, 0.5551, 0.4801, 0.5767]}, {"w": "using", "b": [0.4848, 0.5551, 0.5278, 0.5767]}, {"w": "various", "b": [0.5326, 0.5551, 0.5929, 0.5767]}, {"w": "techniques", "b": [0.5977, 0.5551, 0.6824, 0.5767]}]}, {"id": "b_5", "type": "paragraph", "text": "Exercises", "words": [{"w": "Exercises", "b": [0.1429, 0.5897, 0.2533, 0.624]}]}, {"id": "b_6", "type": "paragraph", "text": "1. What are the main motivations for reducing a dataset’s dimensionality? What are the main drawbacks?", "words": [{"w": "1.", "b": [0.1534, 0.6369, 0.1682, 0.6584]}, {"w": "What", "b": [0.1786, 0.6369, 0.225, 0.6584]}, {"w": "are", "b": [0.2301, 0.6369, 0.2559, 0.6584]}, {"w": "the", "b": [0.261, 0.6369, 0.2873, 0.6584]}, {"w": "main", "b": [0.2925, 0.6369, 0.3357, 0.6584]}, {"w": "motivations", "b": [0.3408, 0.6369, 0.4404, 0.6584]}, {"w": "for", "b": [0.4455, 0.6369, 0.47, 0.6584]}, {"w": "reducing", "b": [0.4752, 0.6369, 0.5494, 0.6584]}, {"w": "a", "b": [0.5545, 0.6369, 0.5636, 0.6584]}, {"w": "dataset’s", "b": [0.5688, 0.6369, 0.6366, 0.6584]}, {"w": "dimensionality?", "b": [0.6417, 0.6369, 0.7747, 0.6584]}, {"w": "What", "b": [0.7798, 0.6369, 0.8263, 0.6584]}, {"w": "are", "b": [0.8314, 0.6369, 0.8571, 0.6584]}, {"w": "the", "b": [0.1786, 0.656, 0.2049, 0.6774]}, {"w": "main", "b": [0.2096, 0.656, 0.2528, 0.6774]}, {"w": "drawbacks?", "b": [0.2576, 0.656, 0.3537, 0.6774]}]}, {"id": "b_7", "type": "paragraph", "text": "2. What is the curse of dimensionality?", "words": [{"w": "2.", "b": [0.1534, 0.6811, 0.1682, 0.7025]}, {"w": "What", "b": [0.1786, 0.6811, 0.225, 0.7025]}, {"w": "is", "b": [0.2298, 0.6811, 0.243, 0.7025]}, {"w": "the", "b": [0.2477, 0.6811, 0.274, 0.7025]}, {"w": "curse", "b": [0.2788, 0.6811, 0.3229, 0.7025]}, {"w": "of", "b": [0.3276, 0.6811, 0.3444, 0.7025]}, {"w": "dimensionality?", "b": [0.3491, 0.6811, 0.4821, 0.7025]}]}, {"id": "b_8", "type": "paragraph", "text": "3. Once a dataset’s dimensionality has been reduced, is it possible to reverse the operation? If so, how? If not, why?", "words": [{"w": "3.", "b": [0.1534, 0.7062, 0.1682, 0.7276]}, {"w": "Once", "b": [0.1786, 0.7062, 0.2232, 0.7276]}, {"w": "a", "b": [0.2313, 0.7062, 0.2404, 0.7276]}, {"w": "dataset’s", "b": [0.2486, 0.7062, 0.3164, 0.7276]}, {"w": "dimensionality", "b": [0.3245, 0.7062, 0.4496, 0.7276]}, {"w": "has", "b": [0.4577, 0.7062, 0.4856, 0.7276]}, {"w": "been", "b": [0.4937, 0.7062, 0.5334, 0.7276]}, {"w": "reduced,", "b": [0.5415, 0.7062, 0.6136, 0.7276]}, {"w": "is", "b": [0.6217, 0.7062, 0.6349, 0.7276]}, {"w": "it", "b": [0.643, 0.7062, 0.655, 0.7276]}, {"w": "possible", "b": [0.6631, 0.7062, 0.7302, 0.7276]}, {"w": "to", "b": [0.7383, 0.7062, 0.7553, 0.7276]}, {"w": "reverse", "b": [0.7634, 0.7062, 0.8227, 0.7276]}, {"w": "the", "b": [0.8308, 0.7062, 0.8571, 0.7276]}, {"w": "operation?", "b": [0.1786, 0.7252, 0.2673, 0.7466]}, {"w": "If", "b": [0.272, 0.7252, 0.2853, 0.7466]}, {"w": "so,", "b": [0.29, 0.7252, 0.3124, 0.7466]}, {"w": "how?", "b": [0.3172, 0.7252, 0.3611, 0.7466]}, {"w": "If", "b": [0.3658, 0.7252, 0.3791, 0.7466]}, {"w": "not,", "b": [0.3838, 0.7252, 0.4169, 0.7466]}, {"w": "why?", "b": [0.4217, 0.7252, 0.4641, 0.7466]}]}, {"id": "b_9", "type": "paragraph", "text": "4. Can PCA be used to reduce the dimensionality of a highly nonlinear dataset?", "words": [{"w": "4.", "b": [0.1534, 0.7503, 0.1682, 0.7717]}, {"w": "Can", "b": [0.1786, 0.7503, 0.213, 0.7717]}, {"w": "PCA", "b": [0.2177, 0.7503, 0.2577, 0.7717]}, {"w": "be", "b": [0.2624, 0.7503, 0.2818, 0.7717]}, {"w": "used", "b": [0.2866, 0.7503, 0.3251, 0.7717]}, {"w": "to", "b": [0.3299, 0.7503, 0.3468, 0.7717]}, {"w": "reduce", "b": [0.3516, 0.7503, 0.4079, 0.7717]}, {"w": "the", "b": [0.4126, 0.7503, 0.4389, 0.7717]}, {"w": "dimensionality", "b": [0.4437, 0.7503, 0.5687, 0.7717]}, {"w": "of", "b": [0.5735, 0.7503, 0.5903, 0.7717]}, {"w": "a", "b": [0.595, 0.7503, 0.6041, 0.7717]}, {"w": "highly", "b": [0.6089, 0.7503, 0.6613, 0.7717]}, {"w": "nonlinear", "b": [0.666, 0.7503, 0.7474, 0.7717]}, {"w": "dataset?", "b": [0.7521, 0.7503, 0.8181, 0.7717]}]}, {"id": "b_10", "type": "paragraph", "text": "5. Suppose you perform PCA on a 1,000-dimensional dataset, setting the explained variance ratio to 95%. How many dimensions will the resulting dataset have?", "words": [{"w": "5.", "b": [0.1534, 0.7754, 0.1682, 0.7968]}, {"w": "Suppose", "b": [0.1786, 0.7754, 0.2485, 0.7968]}, {"w": "you", "b": [0.254, 0.7754, 0.2853, 0.7968]}, {"w": "perform", "b": [0.2908, 0.7754, 0.3599, 0.7968]}, {"w": "PCA", "b": [0.3654, 0.7754, 0.4054, 0.7968]}, {"w": "on", "b": [0.411, 0.7754, 0.433, 0.7968]}, {"w": "a", "b": [0.4385, 0.7754, 0.4477, 0.7968]}, {"w": "1,000-dimensional", "b": [0.4532, 0.7754, 0.609, 0.7968]}, {"w": "dataset,", "b": [0.6145, 0.7754, 0.6774, 0.7968]}, {"w": "setting", "b": [0.6829, 0.7754, 0.7389, 0.7968]}, {"w": "the", "b": [0.7444, 0.7754, 0.7707, 0.7968]}, {"w": "explained", "b": [0.7763, 0.7754, 0.8571, 0.7968]}, {"w": "variance", "b": [0.1786, 0.7945, 0.2489, 0.8159]}, {"w": "ratio", "b": [0.2536, 0.7945, 0.2927, 0.8159]}, {"w": "to", "b": [0.2974, 0.7945, 0.3144, 0.8159]}, {"w": "95%.", "b": [0.3191, 0.7945, 0.3596, 0.8159]}, {"w": "How", "b": [0.3643, 0.7945, 0.4047, 0.8159]}, {"w": "many", "b": [0.4094, 0.7945, 0.4561, 0.8159]}, {"w": "dimensions", "b": [0.4608, 0.7945, 0.5576, 0.8159]}, {"w": "will", "b": [0.5623, 0.7945, 0.5927, 0.8159]}, {"w": "the", "b": [0.5974, 0.7945, 0.6238, 0.8159]}, {"w": "resulting", "b": [0.6285, 0.7945, 0.7022, 0.8159]}, {"w": "dataset", "b": [0.7069, 0.7945, 0.765, 0.8159]}, {"w": "have?", "b": [0.7697, 0.7945, 0.816, 0.8159]}]}, {"id": "b_11", "type": "paragraph", "text": "Exercises | 235", "words": [{"w": "Exercises", "b": [0.7433, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "235", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 262, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6. In what cases would you use vanilla PCA, Incremental PCA, Randomized PCA, or Kernel PCA?", "words": [{"w": "6.", "b": [0.1534, 0.0791, 0.1682, 0.1005]}, {"w": "In", "b": [0.1786, 0.0791, 0.1971, 0.1005]}, {"w": "what", "b": [0.2033, 0.0791, 0.2438, 0.1005]}, {"w": "cases", "b": [0.25, 0.0791, 0.2921, 0.1005]}, {"w": "would", "b": [0.2983, 0.0791, 0.3506, 0.1005]}, {"w": "you", "b": [0.3568, 0.0791, 0.388, 0.1005]}, {"w": "use", "b": [0.3943, 0.0791, 0.4218, 0.1005]}, {"w": "vanilla", "b": [0.4281, 0.0791, 0.4835, 0.1005]}, {"w": "PCA,", "b": [0.4897, 0.0791, 0.5345, 0.1005]}, {"w": "Incremental", "b": [0.5407, 0.0791, 0.6423, 0.1005]}, {"w": "PCA,", "b": [0.6485, 0.0791, 0.6932, 0.1005]}, {"w": "Randomized", "b": [0.6995, 0.0791, 0.8062, 0.1005]}, {"w": "PCA,", "b": [0.8124, 0.0791, 0.8571, 0.1005]}, {"w": "or", "b": [0.1786, 0.0981, 0.1969, 0.1195]}, {"w": "Kernel", "b": [0.2017, 0.0981, 0.2573, 0.1195]}, {"w": "PCA?", "b": [0.262, 0.0981, 0.3099, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "7. How can you evaluate the performance of a dimensionality reduction algorithm on your dataset?", "words": [{"w": "7.", "b": [0.1534, 0.1232, 0.1682, 0.1446]}, {"w": "How", "b": [0.1786, 0.1232, 0.2189, 0.1446]}, {"w": "can", "b": [0.225, 0.1232, 0.2544, 0.1446]}, {"w": "you", "b": [0.2605, 0.1232, 0.2917, 0.1446]}, {"w": "evaluate", "b": [0.2978, 0.1232, 0.3657, 0.1446]}, {"w": "the", "b": [0.3718, 0.1232, 0.3982, 0.1446]}, {"w": "performance", "b": [0.4043, 0.1232, 0.5116, 0.1446]}, {"w": "of", "b": [0.5177, 0.1232, 0.5345, 0.1446]}, {"w": "a", "b": [0.5406, 0.1232, 0.5497, 0.1446]}, {"w": "dimensionality", "b": [0.5558, 0.1232, 0.6809, 0.1446]}, {"w": "reduction", "b": [0.687, 0.1232, 0.7684, 0.1446]}, {"w": "algorithm", "b": [0.7745, 0.1232, 0.8571, 0.1446]}, {"w": "on", "b": [0.1786, 0.1423, 0.2006, 0.1637]}, {"w": "your", "b": [0.2053, 0.1423, 0.2443, 0.1637]}, {"w": "dataset?", "b": [0.249, 0.1423, 0.315, 0.1637]}]}, {"id": "b_2", "type": "paragraph", "text": "8. Does it make any sense to chain two different dimensionality reduction algo‐ rithms?", "words": [{"w": "8.", "b": [0.1534, 0.1673, 0.1682, 0.1888]}, {"w": "Does", "b": [0.1786, 0.1673, 0.221, 0.1888]}, {"w": "it", "b": [0.2292, 0.1673, 0.2411, 0.1888]}, {"w": "make", "b": [0.2493, 0.1673, 0.2947, 0.1888]}, {"w": "any", "b": [0.3029, 0.1673, 0.3325, 0.1888]}, {"w": "sense", "b": [0.3407, 0.1673, 0.3851, 0.1888]}, {"w": "to", "b": [0.3933, 0.1673, 0.4103, 0.1888]}, {"w": "chain", "b": [0.4185, 0.1673, 0.4645, 0.1888]}, {"w": "two", "b": [0.4727, 0.1673, 0.504, 0.1888]}, {"w": "different", "b": [0.5122, 0.1673, 0.5839, 0.1888]}, {"w": "dimensionality", "b": [0.5921, 0.1673, 0.7171, 0.1888]}, {"w": "reduction", "b": [0.7253, 0.1673, 0.8067, 0.1888]}, {"w": "algo‐", "b": [0.8149, 0.1673, 0.8571, 0.1888]}, {"w": "rithms?", "b": [0.1786, 0.1864, 0.242, 0.2078]}]}, {"id": "b_3", "type": "paragraph", "text": "9. Load the MNIST dataset (introduced in Chapter 3) and split it into a training set and a test set (take the first 60,000 instances for training, and the remaining 10,000 for testing). Train a Random Forest classifier on the dataset and time how long it takes, then evaluate the resulting model on the test set. Next, use PCA to reduce the dataset’s dimensionality, with an explained variance ratio of 95%. Train a new Random Forest classifier on the reduced dataset and see how long it takes. Was training much faster? Next evaluate the classifier on the test set: how does it compare to the previous classifier?", "words": [{"w": "9.", "b": [0.1534, 0.2115, 0.1682, 0.2329]}, {"w": "Load", "b": [0.1786, 0.2115, 0.2205, 0.2329]}, {"w": "the", "b": [0.2259, 0.2115, 0.2523, 0.2329]}, {"w": "MNIST", "b": [0.2577, 0.2115, 0.3215, 0.2329]}, {"w": "dataset", "b": [0.3269, 0.2115, 0.385, 0.2329]}, {"w": "(introduced", "b": [0.3904, 0.2115, 0.4897, 0.2329]}, {"w": "in", "b": [0.4951, 0.2115, 0.512, 0.2329]}, {"w": "Chapter", "b": [0.5174, 0.2115, 0.585, 0.2329]}, {"w": "3)", "b": [0.5897, 0.2115, 0.6076, 0.2329]}, {"w": "and", "b": [0.613, 0.2115, 0.6446, 0.2329]}, {"w": "split", "b": [0.65, 0.2115, 0.6857, 0.2329]}, {"w": "it", "b": [0.6911, 0.2115, 0.7031, 0.2329]}, {"w": "into", "b": [0.7085, 0.2115, 0.742, 0.2329]}, {"w": "a", "b": [0.7474, 0.2115, 0.7566, 0.2329]}, {"w": "training", "b": [0.762, 0.2115, 0.8289, 0.2329]}, {"w": "set", "b": [0.8343, 0.2115, 0.8571, 0.2329]}, {"w": "and", "b": [0.1786, 0.2305, 0.2101, 0.2519]}, {"w": "a", "b": [0.2187, 0.2305, 0.2279, 0.2519]}, {"w": "test", "b": [0.2365, 0.2305, 0.2657, 0.2519]}, {"w": "set", "b": [0.2743, 0.2305, 0.2972, 0.2519]}, {"w": "(take", "b": [0.3058, 0.2305, 0.3477, 0.2519]}, {"w": "the", "b": [0.3563, 0.2305, 0.3826, 0.2519]}, {"w": "first", "b": [0.3912, 0.2305, 0.4247, 0.2519]}, {"w": "60,000", "b": [0.4333, 0.2305, 0.4881, 0.2519]}, {"w": "instances", "b": [0.4967, 0.2305, 0.5735, 0.2519]}, {"w": "for", "b": [0.5821, 0.2305, 0.6066, 0.2519]}, {"w": "training,", "b": [0.6152, 0.2305, 0.6869, 0.2519]}, {"w": "and", "b": [0.6955, 0.2305, 0.7271, 0.2519]}, {"w": "the", "b": [0.7357, 0.2305, 0.762, 0.2519]}, {"w": "remaining", "b": [0.7706, 0.2305, 0.8571, 0.2519]}, {"w": "10,000", "b": [0.1786, 0.2496, 0.2333, 0.271]}, {"w": "for", "b": [0.2386, 0.2496, 0.2631, 0.271]}, {"w": "testing).", "b": [0.2684, 0.2496, 0.3363, 0.271]}, {"w": "Train", "b": [0.3416, 0.2496, 0.3865, 0.271]}, {"w": "a", "b": [0.3918, 0.2496, 0.401, 0.271]}, {"w": "Random", "b": [0.4062, 0.2496, 0.4788, 0.271]}, {"w": "Forest", "b": [0.4841, 0.2496, 0.5359, 0.271]}, {"w": "classifier", "b": [0.5412, 0.2496, 0.6136, 0.271]}, {"w": "on", "b": [0.6189, 0.2496, 0.6409, 0.271]}, {"w": "the", "b": [0.6462, 0.2496, 0.6725, 0.271]}, {"w": "dataset", "b": [0.6778, 0.2496, 0.7359, 0.271]}, {"w": "and", "b": [0.7412, 0.2496, 0.7727, 0.271]}, {"w": "time", "b": [0.778, 0.2496, 0.8158, 0.271]}, {"w": "how", "b": [0.8211, 0.2496, 0.8571, 0.271]}, {"w": "long", "b": [0.1786, 0.2686, 0.2156, 0.29]}, {"w": "it", "b": [0.2216, 0.2686, 0.2335, 0.29]}, {"w": "takes,", "b": [0.2395, 0.2686, 0.2866, 0.29]}, {"w": "then", "b": [0.2926, 0.2686, 0.3303, 0.29]}, {"w": "evaluate", "b": [0.3363, 0.2686, 0.4042, 0.29]}, {"w": "the", "b": [0.4102, 0.2686, 0.4365, 0.29]}, {"w": "resulting", "b": [0.4425, 0.2686, 0.5161, 0.29]}, {"w": "model", "b": [0.5221, 0.2686, 0.5749, 0.29]}, {"w": "on", "b": [0.5809, 0.2686, 0.6029, 0.29]}, {"w": "the", "b": [0.6089, 0.2686, 0.6352, 0.29]}, {"w": "test", "b": [0.6412, 0.2686, 0.6704, 0.29]}, {"w": "set.", "b": [0.6764, 0.2686, 0.704, 0.29]}, {"w": "Next,", "b": [0.7099, 0.2686, 0.7547, 0.29]}, {"w": "use", "b": [0.7607, 0.2686, 0.7882, 0.29]}, {"w": "PCA", "b": [0.7942, 0.2686, 0.8342, 0.29]}, {"w": "to", "b": [0.8402, 0.2686, 0.8571, 0.29]}, {"w": "reduce", "b": [0.1786, 0.2877, 0.2349, 0.3091]}, {"w": "the", "b": [0.2443, 0.2877, 0.2707, 0.3091]}, {"w": "dataset’s", "b": [0.2801, 0.2877, 0.348, 0.3091]}, {"w": "dimensionality,", "b": [0.3574, 0.2877, 0.4857, 0.3091]}, {"w": "with", "b": [0.4951, 0.2877, 0.5325, 0.3091]}, {"w": "an", "b": [0.5419, 0.2877, 0.5624, 0.3091]}, {"w": "explained", "b": [0.5719, 0.2877, 0.6527, 0.3091]}, {"w": "variance", "b": [0.6622, 0.2877, 0.7325, 0.3091]}, {"w": "ratio", "b": [0.7419, 0.2877, 0.781, 0.3091]}, {"w": "of", "b": [0.7904, 0.2877, 0.8072, 0.3091]}, {"w": "95%.", "b": [0.8167, 0.2877, 0.8572, 0.3091]}, {"w": "Train", "b": [0.1786, 0.3067, 0.2235, 0.3281]}, {"w": "a", "b": [0.2291, 0.3067, 0.2382, 0.3281]}, {"w": "new", "b": [0.2438, 0.3067, 0.2783, 0.3281]}, {"w": "Random", "b": [0.2838, 0.3067, 0.3564, 0.3281]}, {"w": "Forest", "b": [0.3619, 0.3067, 0.4137, 0.3281]}, {"w": "classifier", "b": [0.4192, 0.3067, 0.4917, 0.3281]}, {"w": "on", "b": [0.4972, 0.3067, 0.5192, 0.3281]}, {"w": "the", "b": [0.5248, 0.3067, 0.5511, 0.3281]}, {"w": "reduced", "b": [0.5566, 0.3067, 0.6239, 0.3281]}, {"w": "dataset", "b": [0.6295, 0.3067, 0.6876, 0.3281]}, {"w": "and", "b": [0.6931, 0.3067, 0.7247, 0.3281]}, {"w": "see", "b": [0.7302, 0.3067, 0.7555, 0.3281]}, {"w": "how", "b": [0.7611, 0.3067, 0.7971, 0.3281]}, {"w": "long", "b": [0.8026, 0.3067, 0.8397, 0.3281]}, {"w": "it", "b": [0.8452, 0.3067, 0.8571, 0.3281]}, {"w": "takes.", "b": [0.1786, 0.3258, 0.2257, 0.3472]}, {"w": "Was", "b": [0.2318, 0.3258, 0.2668, 0.3472]}, {"w": "training", "b": [0.273, 0.3258, 0.3399, 0.3472]}, {"w": "much", "b": [0.3461, 0.3258, 0.3937, 0.3472]}, {"w": "faster?", "b": [0.3999, 0.3258, 0.4537, 0.3472]}, {"w": "Next", "b": [0.4599, 0.3258, 0.4999, 0.3472]}, {"w": "evaluate", "b": [0.506, 0.3258, 0.574, 0.3472]}, {"w": "the", "b": [0.5802, 0.3258, 0.6065, 0.3472]}, {"w": "classifier", "b": [0.6127, 0.3258, 0.6851, 0.3472]}, {"w": "on", "b": [0.6913, 0.3258, 0.7133, 0.3472]}, {"w": "the", "b": [0.7195, 0.3258, 0.7458, 0.3472]}, {"w": "test", "b": [0.752, 0.3258, 0.7812, 0.3472]}, {"w": "set:", "b": [0.7874, 0.3258, 0.815, 0.3472]}, {"w": "how", "b": [0.8211, 0.3258, 0.8571, 0.3472]}, {"w": "does", "b": [0.1786, 0.3448, 0.2167, 0.3662]}, {"w": "it", "b": [0.2214, 0.3448, 0.2334, 0.3662]}, {"w": "compare", "b": [0.2381, 0.3448, 0.3108, 0.3662]}, {"w": "to", "b": [0.3156, 0.3448, 0.3325, 0.3662]}, {"w": "the", "b": [0.3373, 0.3448, 0.3636, 0.3662]}, {"w": "previous", "b": [0.3683, 0.3448, 0.4404, 0.3662]}, {"w": "classifier?", "b": [0.4451, 0.3448, 0.5255, 0.3662]}]}, {"id": "b_4", "type": "paragraph", "text": "10. Use t-SNE to reduce the MNIST dataset down to two dimensions and plot the result using Matplotlib. You can use a scatterplot using 10 different colors to rep‐ resent each image’s target class. Alternatively, you can write colored digits at the location of each instance, or even plot scaled-down versions of the digit images themselves (if you plot all digits, the visualization will be too cluttered, so you should either draw a random sample or plot an instance only if no other instance has already been plotted at a close distance). You should get a nice visualization with well-separated clusters of digits. Try using other dimensionality reduction algorithms such as PCA, LLE, or MDS and compare the resulting visualizations.", "words": [{"w": "10.", "b": [0.1434, 0.3699, 0.1682, 0.3913]}, {"w": "Use", "b": [0.1786, 0.3699, 0.2093, 0.3913]}, {"w": "t-SNE", "b": [0.2164, 0.3699, 0.2673, 0.3913]}, {"w": "to", "b": [0.2744, 0.3699, 0.2914, 0.3913]}, {"w": "reduce", "b": [0.2984, 0.3699, 0.3548, 0.3913]}, {"w": "the", "b": [0.3618, 0.3699, 0.3882, 0.3913]}, {"w": "MNIST", "b": [0.3952, 0.3699, 0.4591, 0.3913]}, {"w": "dataset", "b": [0.4662, 0.3699, 0.5243, 0.3913]}, {"w": "down", "b": [0.5314, 0.3699, 0.5786, 0.3913]}, {"w": "to", "b": [0.5857, 0.3699, 0.6027, 0.3913]}, {"w": "two", "b": [0.6098, 0.3699, 0.641, 0.3913]}, {"w": "dimensions", "b": [0.6481, 0.3699, 0.7449, 0.3913]}, {"w": "and", "b": [0.752, 0.3699, 0.7835, 0.3913]}, {"w": "plot", "b": [0.7906, 0.3699, 0.8237, 0.3913]}, {"w": "the", "b": [0.8308, 0.3699, 0.8571, 0.3913]}, {"w": "result", "b": [0.1786, 0.389, 0.2255, 0.4104]}, {"w": "using", "b": [0.2307, 0.389, 0.2762, 0.4104]}, {"w": "Matplotlib.", "b": [0.2814, 0.389, 0.3735, 0.4104]}, {"w": "You", "b": [0.3788, 0.389, 0.4111, 0.4104]}, {"w": "can", "b": [0.4164, 0.389, 0.4457, 0.4104]}, {"w": "use", "b": [0.451, 0.389, 0.4785, 0.4104]}, {"w": "a", "b": [0.4838, 0.389, 0.4929, 0.4104]}, {"w": "scatterplot", "b": [0.4982, 0.389, 0.5859, 0.4104]}, {"w": "using", "b": [0.5911, 0.389, 0.6366, 0.4104]}, {"w": "10", "b": [0.6418, 0.389, 0.6618, 0.4104]}, {"w": "different", "b": [0.6671, 0.389, 0.7388, 0.4104]}, {"w": "colors", "b": [0.744, 0.389, 0.7947, 0.4104]}, {"w": "to", "b": [0.8, 0.389, 0.817, 0.4104]}, {"w": "rep‐", "b": [0.8222, 0.389, 0.8571, 0.4104]}, {"w": "resent", "b": [0.1786, 0.408, 0.229, 0.4294]}, {"w": "each", "b": [0.2352, 0.408, 0.2731, 0.4294]}, {"w": "image’s", "b": [0.2793, 0.408, 0.3388, 0.4294]}, {"w": "target", "b": [0.345, 0.408, 0.3932, 0.4294]}, {"w": "class.", "b": [0.3994, 0.408, 0.4427, 0.4294]}, {"w": "Alternatively,", "b": [0.4489, 0.408, 0.5601, 0.4294]}, {"w": "you", "b": [0.5663, 0.408, 0.5976, 0.4294]}, {"w": "can", "b": [0.6038, 0.408, 0.6331, 0.4294]}, {"w": "write", "b": [0.6393, 0.408, 0.6821, 0.4294]}, {"w": "colored", "b": [0.6883, 0.408, 0.7512, 0.4294]}, {"w": "digits", "b": [0.7574, 0.408, 0.8033, 0.4294]}, {"w": "at", "b": [0.8095, 0.408, 0.8246, 0.4294]}, {"w": "the", "b": [0.8308, 0.408, 0.8571, 0.4294]}, {"w": "location", "b": [0.1786, 0.4271, 0.246, 0.4485]}, {"w": "of", "b": [0.2525, 0.4271, 0.2693, 0.4485]}, {"w": "each", "b": [0.2758, 0.4271, 0.3138, 0.4485]}, {"w": "instance,", "b": [0.3203, 0.4271, 0.3942, 0.4485]}, {"w": "or", "b": [0.4007, 0.4271, 0.4191, 0.4485]}, {"w": "even", "b": [0.4256, 0.4271, 0.4643, 0.4485]}, {"w": "plot", "b": [0.4709, 0.4271, 0.504, 0.4485]}, {"w": "scaled-down", "b": [0.5106, 0.4271, 0.616, 0.4485]}, {"w": "versions", "b": [0.6225, 0.4271, 0.6916, 0.4485]}, {"w": "of", "b": [0.6982, 0.4271, 0.7149, 0.4485]}, {"w": "the", "b": [0.7215, 0.4271, 0.7478, 0.4485]}, {"w": "digit", "b": [0.7543, 0.4271, 0.7926, 0.4485]}, {"w": "images", "b": [0.7991, 0.4271, 0.8571, 0.4485]}, {"w": "themselves", "b": [0.1786, 0.4461, 0.2699, 0.4675]}, {"w": "(if", "b": [0.2773, 0.4461, 0.2962, 0.4675]}, {"w": "you", "b": [0.3036, 0.4461, 0.3348, 0.4675]}, {"w": "plot", "b": [0.3422, 0.4461, 0.3754, 0.4675]}, {"w": "all", "b": [0.3827, 0.4461, 0.4024, 0.4675]}, {"w": "digits,", "b": [0.4098, 0.4461, 0.4605, 0.4675]}, {"w": "the", "b": [0.4678, 0.4461, 0.4942, 0.4675]}, {"w": "visualization", "b": [0.5015, 0.4461, 0.6069, 0.4675]}, {"w": "will", "b": [0.6143, 0.4461, 0.6447, 0.4675]}, {"w": "be", "b": [0.6521, 0.4461, 0.6715, 0.4675]}, {"w": "too", "b": [0.6789, 0.4461, 0.7065, 0.4675]}, {"w": "cluttered,", "b": [0.7139, 0.4461, 0.7929, 0.4675]}, {"w": "so", "b": [0.8003, 0.4461, 0.8185, 0.4675]}, {"w": "you", "b": [0.8259, 0.4461, 0.8572, 0.4675]}, {"w": "should", "b": [0.1786, 0.4652, 0.2353, 0.4866]}, {"w": "either", "b": [0.2404, 0.4652, 0.2889, 0.4866]}, {"w": "draw", "b": [0.294, 0.4652, 0.3357, 0.4866]}, {"w": "a", "b": [0.3408, 0.4652, 0.35, 0.4866]}, {"w": "random", "b": [0.3551, 0.4652, 0.422, 0.4866]}, {"w": "sample", "b": [0.4271, 0.4652, 0.4856, 0.4866]}, {"w": "or", "b": [0.4907, 0.4652, 0.509, 0.4866]}, {"w": "plot", "b": [0.5141, 0.4652, 0.5473, 0.4866]}, {"w": "an", "b": [0.5524, 0.4652, 0.5729, 0.4866]}, {"w": "instance", "b": [0.578, 0.4652, 0.6472, 0.4866]}, {"w": "only", "b": [0.6523, 0.4652, 0.6891, 0.4866]}, {"w": "if", "b": [0.6942, 0.4652, 0.706, 0.4866]}, {"w": "no", "b": [0.7111, 0.4652, 0.7331, 0.4866]}, {"w": "other", "b": [0.7382, 0.4652, 0.7829, 0.4866]}, {"w": "instance", "b": [0.788, 0.4652, 0.8571, 0.4866]}, {"w": "has", "b": [0.1786, 0.4842, 0.2065, 0.5056]}, {"w": "already", "b": [0.2128, 0.4842, 0.2735, 0.5056]}, {"w": "been", "b": [0.2797, 0.4842, 0.3194, 0.5056]}, {"w": "plotted", "b": [0.3257, 0.4842, 0.3851, 0.5056]}, {"w": "at", "b": [0.3913, 0.4842, 0.4064, 0.5056]}, {"w": "a", "b": [0.4127, 0.4842, 0.4218, 0.5056]}, {"w": "close", "b": [0.4281, 0.4842, 0.4693, 0.5056]}, {"w": "distance).", "b": [0.4756, 0.4842, 0.5563, 0.5056]}, {"w": "You", "b": [0.5626, 0.4842, 0.5949, 0.5056]}, {"w": "should", "b": [0.6012, 0.4842, 0.6579, 0.5056]}, {"w": "get", "b": [0.6642, 0.4842, 0.6892, 0.5056]}, {"w": "a", "b": [0.6954, 0.4842, 0.7046, 0.5056]}, {"w": "nice", "b": [0.7108, 0.4842, 0.7455, 0.5056]}, {"w": "visualization", "b": [0.7518, 0.4842, 0.8571, 0.5056]}, {"w": "with", "b": [0.1786, 0.5032, 0.2159, 0.5247]}, {"w": "well-separated", "b": [0.2231, 0.5032, 0.3434, 0.5247]}, {"w": "clusters", "b": [0.3506, 0.5032, 0.4139, 0.5247]}, {"w": "of", "b": [0.4211, 0.5032, 0.4379, 0.5247]}, {"w": "digits.", "b": [0.445, 0.5032, 0.4957, 0.5247]}, {"w": "Try", "b": [0.5029, 0.5032, 0.5319, 0.5247]}, {"w": "using", "b": [0.5391, 0.5032, 0.5845, 0.5247]}, {"w": "other", "b": [0.5916, 0.5032, 0.6363, 0.5247]}, {"w": "dimensionality", "b": [0.6435, 0.5032, 0.7686, 0.5247]}, {"w": "reduction", "b": [0.7757, 0.5032, 0.8571, 0.5247]}, {"w": "algorithms", "b": [0.1786, 0.5223, 0.2689, 0.5437]}, {"w": "such", "b": [0.2736, 0.5223, 0.3122, 0.5437]}, {"w": "as", "b": [0.317, 0.5223, 0.3338, 0.5437]}, {"w": "PCA,", "b": [0.3385, 0.5223, 0.3832, 0.5437]}, {"w": "LLE,", "b": [0.3879, 0.5223, 0.4269, 0.5437]}, {"w": "or", "b": [0.4317, 0.5223, 0.45, 0.5437]}, {"w": "MDS", "b": [0.4548, 0.5223, 0.4985, 0.5437]}, {"w": "and", "b": [0.5032, 0.5223, 0.5348, 0.5437]}, {"w": "compare", "b": [0.5395, 0.5223, 0.6123, 0.5437]}, {"w": "the", "b": [0.617, 0.5223, 0.6433, 0.5437]}, {"w": "resulting", "b": [0.6481, 0.5223, 0.7217, 0.5437]}, {"w": "visualizations.", "b": [0.7264, 0.5223, 0.8442, 0.5437]}]}, {"id": "b_5", "type": "paragraph", "text": "Solutions to these exercises are available in ???.", "words": [{"w": "Solutions", "b": [0.1429, 0.5565, 0.2213, 0.5779]}, {"w": "to", "b": [0.226, 0.5565, 0.243, 0.5779]}, {"w": "these", "b": [0.2477, 0.5565, 0.2906, 0.5779]}, {"w": "exercises", "b": [0.2953, 0.5565, 0.3691, 0.5779]}, {"w": "are", "b": [0.3738, 0.5565, 0.3996, 0.5779]}, {"w": "available", "b": [0.4043, 0.5565, 0.4766, 0.5779]}, {"w": "in", "b": [0.4813, 0.5565, 0.4983, 0.5779]}, {"w": "???.", "b": [0.503, 0.5565, 0.5314, 0.5779]}]}, {"id": "b_6", "type": "paragraph", "text": "236 | Chapter 8: Dimensionality Reduction", "words": [{"w": "236", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "8:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Dimensionality", "b": [0.2673, 0.9225, 0.3562, 0.9388]}, {"w": "Reduction", "b": [0.359, 0.9225, 0.4186, 0.9388]}]}]}, {"page": 263, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "CHAPTER 9 Unsupervised Learning Techniques", "words": [{"w": "CHAPTER", "b": [0.7398, 0.1146, 0.8383, 0.1451]}, {"w": "9", "b": [0.8435, 0.1146, 0.8571, 0.1451]}, {"w": "Unsupervised", "b": [0.2866, 0.1478, 0.5093, 0.1935]}, {"w": "Learning", "b": [0.5172, 0.1478, 0.6635, 0.1935]}, {"w": "Techniques", "b": [0.6714, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_1", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 9 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.3643, 0.3102, 0.3839]}, {"w": "Early", "b": [0.3165, 0.3643, 0.3563, 0.3839]}, {"w": "Release", "b": [0.3626, 0.3643, 0.4189, 0.3839]}, {"w": "ebooks,", "b": [0.4251, 0.3643, 0.4831, 0.3839]}, {"w": "you", "b": [0.4894, 0.3643, 0.518, 0.3839]}, {"w": "get", "b": [0.5243, 0.3643, 0.5471, 0.3839]}, {"w": "books", "b": [0.5534, 0.3643, 0.5989, 0.3839]}, {"w": "in", "b": [0.6052, 0.3643, 0.6207, 0.3839]}, {"w": "their", "b": [0.627, 0.3643, 0.6632, 0.3839]}, {"w": "earliest", "b": [0.6695, 0.3643, 0.7239, 0.3839]}, {"w": "form—", "b": [0.7301, 0.3643, 0.7857, 0.3839]}, {"w": "the", "b": [0.2714, 0.3818, 0.2955, 0.4013]}, {"w": "author’s", "b": [0.3012, 0.3818, 0.3615, 0.4013]}, {"w": "raw", "b": [0.3672, 0.3818, 0.3954, 0.4013]}, {"w": "and", "b": [0.4011, 0.3818, 0.4299, 0.4013]}, {"w": "unedited", "b": [0.4357, 0.3818, 0.5034, 0.4013]}, {"w": "content", "b": [0.5091, 0.3818, 0.5667, 0.4013]}, {"w": "as", "b": [0.5725, 0.3818, 0.5878, 0.4013]}, {"w": "he", "b": [0.5936, 0.3818, 0.6118, 0.4013]}, {"w": "or", "b": [0.6175, 0.3818, 0.6343, 0.4013]}, {"w": "she", "b": [0.6401, 0.3818, 0.6653, 0.4013]}, {"w": "writes—so", "b": [0.671, 0.3818, 0.7514, 0.4013]}, {"w": "you", "b": [0.7571, 0.3818, 0.7857, 0.4013]}, {"w": "can", "b": [0.2714, 0.3992, 0.2982, 0.4188]}, {"w": "take", "b": [0.306, 0.3992, 0.3377, 0.4188]}, {"w": "advantage", "b": [0.3455, 0.3992, 0.4223, 0.4188]}, {"w": "of", "b": [0.4301, 0.3992, 0.4454, 0.4188]}, {"w": "these", "b": [0.4532, 0.3992, 0.4923, 0.4188]}, {"w": "technologies", "b": [0.5001, 0.3992, 0.596, 0.4188]}, {"w": "long", "b": [0.6038, 0.3992, 0.6376, 0.4188]}, {"w": "before", "b": [0.6454, 0.3992, 0.6937, 0.4188]}, {"w": "the", "b": [0.7014, 0.3992, 0.7255, 0.4188]}, {"w": "official", "b": [0.7333, 0.3992, 0.7857, 0.4188]}, {"w": "release", "b": [0.2714, 0.4166, 0.3229, 0.4362]}, {"w": "of", "b": [0.3292, 0.4166, 0.3445, 0.4362]}, {"w": "these", "b": [0.3507, 0.4166, 0.3899, 0.4362]}, {"w": "titles.", "b": [0.3961, 0.4166, 0.4371, 0.4362]}, {"w": "The", "b": [0.4433, 0.4166, 0.4733, 0.4362]}, {"w": "following", "b": [0.4795, 0.4166, 0.5517, 0.4362]}, {"w": "will", "b": [0.558, 0.4166, 0.5857, 0.4362]}, {"w": "be", "b": [0.592, 0.4166, 0.6097, 0.4362]}, {"w": "Chapter", "b": [0.616, 0.4166, 0.6777, 0.4362]}, {"w": "9", "b": [0.684, 0.4166, 0.6931, 0.4362]}, {"w": "in", "b": [0.6993, 0.4166, 0.7149, 0.4362]}, {"w": "the", "b": [0.7211, 0.4166, 0.7452, 0.4362]}, {"w": "final", "b": [0.7514, 0.4166, 0.7857, 0.4362]}, {"w": "release", "b": [0.2714, 0.434, 0.3229, 0.4536]}, {"w": "of", "b": [0.3273, 0.434, 0.3426, 0.4536]}, {"w": "the", "b": [0.3469, 0.434, 0.371, 0.4536]}, {"w": "book.", "b": [0.3753, 0.434, 0.4182, 0.4536]}]}, {"id": "b_2", "type": "paragraph", "text": "Although most of the applications of Machine Learning today are based on super‐ vised learning (and as a result, this is where most of the investments go to), the vast majority of the available data is actually unlabeled: we have the input features X, but we do not have the labels y. Yann LeCun famously said that “if intelligence was a cake, unsupervised learning would be the cake, supervised learning would be the icing on the cake, and reinforcement learning would be the cherry on the cake”. In other words, there is a huge potential in unsupervised learning that we have only barely started to sink our teeth into.", "words": [{"w": "Although", "b": [0.1429, 0.4739, 0.2226, 0.4953]}, {"w": "most", "b": [0.23, 0.4739, 0.2717, 0.4953]}, {"w": "of", "b": [0.2791, 0.4739, 0.2959, 0.4953]}, {"w": "the", "b": [0.3034, 0.4739, 0.3297, 0.4953]}, {"w": "applications", "b": [0.3371, 0.4739, 0.4377, 0.4953]}, {"w": "of", "b": [0.4452, 0.4739, 0.462, 0.4953]}, {"w": "Machine", "b": [0.4694, 0.4739, 0.5425, 0.4953]}, {"w": "Learning", "b": [0.55, 0.4739, 0.625, 0.4953]}, {"w": "today", "b": [0.6325, 0.4739, 0.6788, 0.4953]}, {"w": "are", "b": [0.6862, 0.4739, 0.7119, 0.4953]}, {"w": "based", "b": [0.7194, 0.4739, 0.7666, 0.4953]}, {"w": "on", "b": [0.7741, 0.4739, 0.7961, 0.4953]}, {"w": "super‐", "b": [0.8035, 0.4739, 0.8571, 0.4953]}, {"w": "vised", "b": [0.1428, 0.4929, 0.1856, 0.5143]}, {"w": "learning", "b": [0.1917, 0.4929, 0.2608, 0.5143]}, {"w": "(and", "b": [0.267, 0.4929, 0.3057, 0.5143]}, {"w": "as", "b": [0.3119, 0.4929, 0.3286, 0.5143]}, {"w": "a", "b": [0.3348, 0.4929, 0.3439, 0.5143]}, {"w": "result,", "b": [0.3501, 0.4929, 0.4017, 0.5143]}, {"w": "this", "b": [0.4079, 0.4929, 0.4386, 0.5143]}, {"w": "is", "b": [0.4447, 0.4929, 0.4579, 0.5143]}, {"w": "where", "b": [0.4641, 0.4929, 0.5149, 0.5143]}, {"w": "most", "b": [0.521, 0.4929, 0.5627, 0.5143]}, {"w": "of", "b": [0.5689, 0.4929, 0.5856, 0.5143]}, {"w": "the", "b": [0.5918, 0.4929, 0.6181, 0.5143]}, {"w": "investments", "b": [0.6242, 0.4929, 0.7242, 0.5143]}, {"w": "go", "b": [0.7303, 0.4929, 0.7507, 0.5143]}, {"w": "to),", "b": [0.7568, 0.4929, 0.7857, 0.5143]}, {"w": "the", "b": [0.7919, 0.4929, 0.8182, 0.5143]}, {"w": "vast", "b": [0.8243, 0.4929, 0.8571, 0.5143]}, {"w": "majority", "b": [0.1429, 0.512, 0.2139, 0.5334]}, {"w": "of", "b": [0.2198, 0.512, 0.2366, 0.5334]}, {"w": "the", "b": [0.2425, 0.512, 0.2689, 0.5334]}, {"w": "available", "b": [0.2748, 0.512, 0.3471, 0.5334]}, {"w": "data", "b": [0.353, 0.512, 0.3883, 0.5334]}, {"w": "is", "b": [0.3942, 0.512, 0.4075, 0.5334]}, {"w": "actually", "b": [0.4134, 0.512, 0.478, 0.5334]}, {"w": "unlabeled:", "b": [0.484, 0.512, 0.5702, 0.5334]}, {"w": "we", "b": [0.5761, 0.512, 0.5992, 0.5334]}, {"w": "have", "b": [0.6052, 0.512, 0.6436, 0.5334]}, {"w": "the", "b": [0.6495, 0.512, 0.6759, 0.5334]}, {"w": "input", "b": [0.6818, 0.512, 0.7267, 0.5334]}, {"w": "features", "b": [0.7327, 0.512, 0.7981, 0.5334]}, {"w": "X,", "b": [0.804, 0.5114, 0.8232, 0.5334]}, {"w": "but", "b": [0.8291, 0.512, 0.8571, 0.5334]}, {"w": "we", "b": [0.1429, 0.531, 0.166, 0.5524]}, {"w": "do", "b": [0.1707, 0.531, 0.1923, 0.5524]}, {"w": "not", "b": [0.1971, 0.531, 0.2254, 0.5524]}, {"w": "have", "b": [0.2302, 0.531, 0.2686, 0.5524]}, {"w": "the", "b": [0.2733, 0.531, 0.2996, 0.5524]}, {"w": "labels", "b": [0.3044, 0.531, 0.3511, 0.5524]}, {"w": "y.", "b": [0.3562, 0.5305, 0.3706, 0.5524]}, {"w": "Yann", "b": [0.3753, 0.531, 0.4181, 0.5524]}, {"w": "LeCun", "b": [0.4228, 0.531, 0.4792, 0.5524]}, {"w": "famously", "b": [0.4839, 0.531, 0.5605, 0.5524]}, {"w": "said", "b": [0.5652, 0.531, 0.5986, 0.5524]}, {"w": "that", "b": [0.6033, 0.531, 0.6359, 0.5524]}, {"w": "“if", "b": [0.6406, 0.531, 0.66, 0.5524]}, {"w": "intelligence", "b": [0.6647, 0.531, 0.7603, 0.5524]}, {"w": "was", "b": [0.765, 0.531, 0.7961, 0.5524]}, {"w": "a", "b": [0.8008, 0.531, 0.81, 0.5524]}, {"w": "cake,", "b": [0.8147, 0.531, 0.8566, 0.5524]}, {"w": "unsupervised", "b": [0.1429, 0.5501, 0.2549, 0.5715]}, {"w": "learning", "b": [0.261, 0.5501, 0.3301, 0.5715]}, {"w": "would", "b": [0.3362, 0.5501, 0.3885, 0.5715]}, {"w": "be", "b": [0.3946, 0.5501, 0.414, 0.5715]}, {"w": "the", "b": [0.4201, 0.5501, 0.4465, 0.5715]}, {"w": "cake,", "b": [0.4526, 0.5501, 0.4945, 0.5715]}, {"w": "supervised", "b": [0.5006, 0.5501, 0.5901, 0.5715]}, {"w": "learning", "b": [0.5963, 0.5501, 0.6654, 0.5715]}, {"w": "would", "b": [0.6715, 0.5501, 0.7237, 0.5715]}, {"w": "be", "b": [0.7299, 0.5501, 0.7493, 0.5715]}, {"w": "the", "b": [0.7554, 0.5501, 0.7818, 0.5715]}, {"w": "icing", "b": [0.7879, 0.5501, 0.829, 0.5715]}, {"w": "on", "b": [0.8351, 0.5501, 0.8571, 0.5715]}, {"w": "the", "b": [0.1429, 0.5691, 0.1692, 0.5905]}, {"w": "cake,", "b": [0.1782, 0.5691, 0.2201, 0.5905]}, {"w": "and", "b": [0.229, 0.5691, 0.2606, 0.5905]}, {"w": "reinforcement", "b": [0.2696, 0.5691, 0.3886, 0.5905]}, {"w": "learning", "b": [0.3976, 0.5691, 0.4667, 0.5905]}, {"w": "would", "b": [0.4757, 0.5691, 0.5279, 0.5905]}, {"w": "be", "b": [0.5369, 0.5691, 0.5563, 0.5905]}, {"w": "the", "b": [0.5653, 0.5691, 0.5916, 0.5905]}, {"w": "cherry", "b": [0.6006, 0.5691, 0.655, 0.5905]}, {"w": "on", "b": [0.664, 0.5691, 0.686, 0.5905]}, {"w": "the", "b": [0.695, 0.5691, 0.7213, 0.5905]}, {"w": "cake”.", "b": [0.7303, 0.5691, 0.776, 0.5905]}, {"w": "In", "b": [0.785, 0.5691, 0.8035, 0.5905]}, {"w": "other", "b": [0.8125, 0.5691, 0.8571, 0.5905]}, {"w": "words,", "b": [0.1429, 0.5882, 0.1989, 0.6096]}, {"w": "there", "b": [0.2064, 0.5882, 0.2494, 0.6096]}, {"w": "is", "b": [0.2569, 0.5882, 0.2702, 0.6096]}, {"w": "a", "b": [0.2777, 0.5882, 0.2869, 0.6096]}, {"w": "huge", "b": [0.2944, 0.5882, 0.3348, 0.6096]}, {"w": "potential", "b": [0.3424, 0.5882, 0.4165, 0.6096]}, {"w": "in", "b": [0.424, 0.5882, 0.441, 0.6096]}, {"w": "unsupervised", "b": [0.4486, 0.5882, 0.5606, 0.6096]}, {"w": "learning", "b": [0.5681, 0.5882, 0.6373, 0.6096]}, {"w": "that", "b": [0.6448, 0.5882, 0.6774, 0.6096]}, {"w": "we", "b": [0.685, 0.5882, 0.7081, 0.6096]}, {"w": "have", "b": [0.7156, 0.5882, 0.754, 0.6096]}, {"w": "only", "b": [0.7616, 0.5882, 0.7984, 0.6096]}, {"w": "barely", "b": [0.806, 0.5882, 0.8572, 0.6096]}, {"w": "started", "b": [0.1429, 0.6072, 0.1999, 0.6286]}, {"w": "to", "b": [0.2047, 0.6072, 0.2217, 0.6286]}, {"w": "sink", "b": [0.2264, 0.6072, 0.2613, 0.6286]}, {"w": "our", "b": [0.2661, 0.6072, 0.2955, 0.6286]}, {"w": "teeth", "b": [0.3002, 0.6072, 0.3418, 0.6286]}, {"w": "into.", "b": [0.3465, 0.6072, 0.3842, 0.6286]}]}, {"id": "b_3", "type": "paragraph", "text": "For example, say you want to create a system that will take a few pictures of each item on a manufacturing production line and detect which items are defective. You can fairly easily create a system that will take pictures automatically, and this might give you thousands of pictures every day. You can then build a reasonably large dataset in just a few weeks. But wait, there are no labels! If you want to train a regular binary classifier that will predict whether an item is defective or not, you will need to label every single picture as “defective” or “normal”. This will generally require human experts to sit down and manually go through all the pictures. This is a long, costly and tedious task, so it will usually only be done on a small subset of the available pic‐ tures. As a result, the labeled dataset will be quite small, and the classifier’s perfor‐ mance will be disappointing. Moreover, every time the company makes any change to its products, the whole process will need to be started over from scratch. Wouldn’t it", "words": [{"w": "For", "b": [0.1429, 0.6353, 0.1718, 0.6567]}, {"w": "example,", "b": [0.1768, 0.6353, 0.2511, 0.6567]}, {"w": "say", "b": [0.2561, 0.6353, 0.2821, 0.6567]}, {"w": "you", "b": [0.2871, 0.6353, 0.3183, 0.6567]}, {"w": "want", "b": [0.3233, 0.6353, 0.3641, 0.6567]}, {"w": "to", "b": [0.3691, 0.6353, 0.386, 0.6567]}, {"w": "create", "b": [0.391, 0.6353, 0.4404, 0.6567]}, {"w": "a", "b": [0.4454, 0.6353, 0.4545, 0.6567]}, {"w": "system", "b": [0.4595, 0.6353, 0.5166, 0.6567]}, {"w": "that", "b": [0.5216, 0.6353, 0.5542, 0.6567]}, {"w": "will", "b": [0.5592, 0.6353, 0.5896, 0.6567]}, {"w": "take", "b": [0.5946, 0.6353, 0.6293, 0.6567]}, {"w": "a", "b": [0.6342, 0.6353, 0.6434, 0.6567]}, {"w": "few", "b": [0.6484, 0.6353, 0.6777, 0.6567]}, {"w": "pictures", "b": [0.6826, 0.6353, 0.7496, 0.6567]}, {"w": "of", "b": [0.7546, 0.6353, 0.7714, 0.6567]}, {"w": "each", "b": [0.7764, 0.6353, 0.8143, 0.6567]}, {"w": "item", "b": [0.8193, 0.6353, 0.8571, 0.6567]}, {"w": "on", "b": [0.1429, 0.6544, 0.1649, 0.6758]}, {"w": "a", "b": [0.1723, 0.6544, 0.1815, 0.6758]}, {"w": "manufacturing", "b": [0.1889, 0.6544, 0.3131, 0.6758]}, {"w": "production", "b": [0.3206, 0.6544, 0.4147, 0.6758]}, {"w": "line", "b": [0.4221, 0.6544, 0.4532, 0.6758]}, {"w": "and", "b": [0.4606, 0.6544, 0.4922, 0.6758]}, {"w": "detect", "b": [0.4996, 0.6544, 0.5498, 0.6758]}, {"w": "which", "b": [0.5573, 0.6544, 0.6082, 0.6758]}, {"w": "items", "b": [0.6156, 0.6544, 0.6611, 0.6758]}, {"w": "are", "b": [0.6685, 0.6544, 0.6943, 0.6758]}, {"w": "defective.", "b": [0.7017, 0.6544, 0.7806, 0.6758]}, {"w": "You", "b": [0.788, 0.6544, 0.8204, 0.6758]}, {"w": "can", "b": [0.8278, 0.6544, 0.8571, 0.6758]}, {"w": "fairly", "b": [0.1428, 0.6734, 0.1863, 0.6948]}, {"w": "easily", "b": [0.1927, 0.6734, 0.2388, 0.6948]}, {"w": "create", "b": [0.2452, 0.6734, 0.2945, 0.6948]}, {"w": "a", "b": [0.3009, 0.6734, 0.3101, 0.6948]}, {"w": "system", "b": [0.3164, 0.6734, 0.3736, 0.6948]}, {"w": "that", "b": [0.38, 0.6734, 0.4125, 0.6948]}, {"w": "will", "b": [0.4189, 0.6734, 0.4493, 0.6948]}, {"w": "take", "b": [0.4557, 0.6734, 0.4904, 0.6948]}, {"w": "pictures", "b": [0.4968, 0.6734, 0.5638, 0.6948]}, {"w": "automatically,", "b": [0.5702, 0.6734, 0.686, 0.6948]}, {"w": "and", "b": [0.6924, 0.6734, 0.7239, 0.6948]}, {"w": "this", "b": [0.7303, 0.6734, 0.761, 0.6948]}, {"w": "might", "b": [0.7674, 0.6734, 0.8169, 0.6948]}, {"w": "give", "b": [0.8233, 0.6734, 0.8571, 0.6948]}, {"w": "you", "b": [0.1429, 0.6925, 0.1741, 0.7139]}, {"w": "thousands", "b": [0.1797, 0.6925, 0.2657, 0.7139]}, {"w": "of", "b": [0.2712, 0.6925, 0.288, 0.7139]}, {"w": "pictures", "b": [0.2935, 0.6925, 0.3605, 0.7139]}, {"w": "every", "b": [0.366, 0.6925, 0.4113, 0.7139]}, {"w": "day.", "b": [0.4168, 0.6925, 0.4494, 0.7139]}, {"w": "You", "b": [0.4549, 0.6925, 0.4873, 0.7139]}, {"w": "can", "b": [0.4928, 0.6925, 0.5222, 0.7139]}, {"w": "then", "b": [0.5277, 0.6925, 0.5655, 0.7139]}, {"w": "build", "b": [0.571, 0.6925, 0.6145, 0.7139]}, {"w": "a", "b": [0.62, 0.6925, 0.6292, 0.7139]}, {"w": "reasonably", "b": [0.6347, 0.6925, 0.7247, 0.7139]}, {"w": "large", "b": [0.7302, 0.6925, 0.771, 0.7139]}, {"w": "dataset", "b": [0.7765, 0.6925, 0.8346, 0.7139]}, {"w": "in", "b": [0.8402, 0.6925, 0.8571, 0.7139]}, {"w": "just", "b": [0.1429, 0.7115, 0.1733, 0.7329]}, {"w": "a", "b": [0.1798, 0.7115, 0.189, 0.7329]}, {"w": "few", "b": [0.1956, 0.7115, 0.2249, 0.7329]}, {"w": "weeks.", "b": [0.2315, 0.7115, 0.2862, 0.7329]}, {"w": "But", "b": [0.2928, 0.7115, 0.3224, 0.7329]}, {"w": "wait,", "b": [0.329, 0.7115, 0.3691, 0.7329]}, {"w": "there", "b": [0.3757, 0.7115, 0.4186, 0.7329]}, {"w": "are", "b": [0.4252, 0.7115, 0.4509, 0.7329]}, {"w": "no", "b": [0.4575, 0.7115, 0.4795, 0.7329]}, {"w": "labels!", "b": [0.4861, 0.7115, 0.5387, 0.7329]}, {"w": "If", "b": [0.5452, 0.7115, 0.5585, 0.7329]}, {"w": "you", "b": [0.5651, 0.7115, 0.5964, 0.7329]}, {"w": "want", "b": [0.6029, 0.7115, 0.6437, 0.7329]}, {"w": "to", "b": [0.6503, 0.7115, 0.6673, 0.7329]}, {"w": "train", "b": [0.6739, 0.7115, 0.7141, 0.7329]}, {"w": "a", "b": [0.7207, 0.7115, 0.7298, 0.7329]}, {"w": "regular", "b": [0.7364, 0.7115, 0.796, 0.7329]}, {"w": "binary", "b": [0.8025, 0.7115, 0.8571, 0.7329]}, {"w": "classifier", "b": [0.1429, 0.7306, 0.2153, 0.752]}, {"w": "that", "b": [0.2217, 0.7306, 0.2543, 0.752]}, {"w": "will", "b": [0.2607, 0.7306, 0.2911, 0.752]}, {"w": "predict", "b": [0.2975, 0.7306, 0.3568, 0.752]}, {"w": "whether", "b": [0.3632, 0.7306, 0.4315, 0.752]}, {"w": "an", "b": [0.4379, 0.7306, 0.4584, 0.752]}, {"w": "item", "b": [0.4649, 0.7306, 0.5027, 0.752]}, {"w": "is", "b": [0.5091, 0.7306, 0.5224, 0.752]}, {"w": "defective", "b": [0.5288, 0.7306, 0.6029, 0.752]}, {"w": "or", "b": [0.6093, 0.7306, 0.6277, 0.752]}, {"w": "not,", "b": [0.6341, 0.7306, 0.6672, 0.752]}, {"w": "you", "b": [0.6736, 0.7306, 0.7049, 0.752]}, {"w": "will", "b": [0.7113, 0.7306, 0.7417, 0.752]}, {"w": "need", "b": [0.7481, 0.7306, 0.7882, 0.752]}, {"w": "to", "b": [0.7946, 0.7306, 0.8116, 0.752]}, {"w": "label", "b": [0.818, 0.7306, 0.8571, 0.752]}, {"w": "every", "b": [0.1429, 0.7496, 0.1881, 0.771]}, {"w": "single", "b": [0.1969, 0.7496, 0.2454, 0.771]}, {"w": "picture", "b": [0.2542, 0.7496, 0.3135, 0.771]}, {"w": "as", "b": [0.3223, 0.7496, 0.3391, 0.771]}, {"w": "“defective”", "b": [0.3479, 0.7496, 0.4358, 0.771]}, {"w": "or", "b": [0.4446, 0.7496, 0.4629, 0.771]}, {"w": "“normal”.", "b": [0.4717, 0.7496, 0.5498, 0.771]}, {"w": "This", "b": [0.5586, 0.7496, 0.5959, 0.771]}, {"w": "will", "b": [0.6047, 0.7496, 0.6351, 0.771]}, {"w": "generally", "b": [0.6439, 0.7496, 0.7197, 0.771]}, {"w": "require", "b": [0.7285, 0.7496, 0.789, 0.771]}, {"w": "human", "b": [0.7978, 0.7496, 0.8572, 0.771]}, {"w": "experts", "b": [0.1429, 0.7687, 0.203, 0.7901]}, {"w": "to", "b": [0.2101, 0.7687, 0.2271, 0.7901]}, {"w": "sit", "b": [0.2341, 0.7687, 0.2537, 0.7901]}, {"w": "down", "b": [0.2607, 0.7687, 0.308, 0.7901]}, {"w": "and", "b": [0.3151, 0.7687, 0.3466, 0.7901]}, {"w": "manually", "b": [0.3537, 0.7687, 0.4312, 0.7901]}, {"w": "go", "b": [0.4382, 0.7687, 0.4586, 0.7901]}, {"w": "through", "b": [0.4656, 0.7687, 0.5334, 0.7901]}, {"w": "all", "b": [0.5405, 0.7687, 0.5602, 0.7901]}, {"w": "the", "b": [0.5672, 0.7687, 0.5935, 0.7901]}, {"w": "pictures.", "b": [0.6006, 0.7687, 0.6723, 0.7901]}, {"w": "This", "b": [0.6793, 0.7687, 0.7165, 0.7901]}, {"w": "is", "b": [0.7236, 0.7687, 0.7368, 0.7901]}, {"w": "a", "b": [0.7439, 0.7687, 0.753, 0.7901]}, {"w": "long,", "b": [0.76, 0.7687, 0.8018, 0.7901]}, {"w": "costly", "b": [0.8089, 0.7687, 0.8571, 0.7901]}, {"w": "and", "b": [0.1429, 0.7877, 0.1744, 0.8091]}, {"w": "tedious", "b": [0.1797, 0.7877, 0.2408, 0.8091]}, {"w": "task,", "b": [0.2461, 0.7877, 0.2843, 0.8091]}, {"w": "so", "b": [0.2896, 0.7877, 0.3079, 0.8091]}, {"w": "it", "b": [0.3131, 0.7877, 0.3251, 0.8091]}, {"w": "will", "b": [0.3304, 0.7877, 0.3608, 0.8091]}, {"w": "usually", "b": [0.366, 0.7877, 0.4251, 0.8091]}, {"w": "only", "b": [0.4303, 0.7877, 0.4672, 0.8091]}, {"w": "be", "b": [0.4725, 0.7877, 0.4919, 0.8091]}, {"w": "done", "b": [0.4972, 0.7877, 0.5391, 0.8091]}, {"w": "on", "b": [0.5443, 0.7877, 0.5664, 0.8091]}, {"w": "a", "b": [0.5716, 0.7877, 0.5808, 0.8091]}, {"w": "small", "b": [0.5861, 0.7877, 0.6305, 0.8091]}, {"w": "subset", "b": [0.6357, 0.7877, 0.6879, 0.8091]}, {"w": "of", "b": [0.6932, 0.7877, 0.71, 0.8091]}, {"w": "the", "b": [0.7152, 0.7877, 0.7416, 0.8091]}, {"w": "available", "b": [0.7469, 0.7877, 0.8191, 0.8091]}, {"w": "pic‐", "b": [0.8244, 0.7877, 0.8571, 0.8091]}, {"w": "tures.", "b": [0.1428, 0.8068, 0.1892, 0.8282]}, {"w": "As", "b": [0.1964, 0.8068, 0.2184, 0.8282]}, {"w": "a", "b": [0.2256, 0.8068, 0.2347, 0.8282]}, {"w": "result,", "b": [0.2419, 0.8068, 0.2935, 0.8282]}, {"w": "the", "b": [0.3007, 0.8068, 0.327, 0.8282]}, {"w": "labeled", "b": [0.3342, 0.8068, 0.3932, 0.8282]}, {"w": "dataset", "b": [0.4003, 0.8068, 0.4584, 0.8282]}, {"w": "will", "b": [0.4656, 0.8068, 0.496, 0.8282]}, {"w": "be", "b": [0.5031, 0.8068, 0.5225, 0.8282]}, {"w": "quite", "b": [0.5297, 0.8068, 0.5722, 0.8282]}, {"w": "small,", "b": [0.5793, 0.8068, 0.6285, 0.8282]}, {"w": "and", "b": [0.6356, 0.8068, 0.6672, 0.8282]}, {"w": "the", "b": [0.6743, 0.8068, 0.7007, 0.8282]}, {"w": "classifier’s", "b": [0.7078, 0.8068, 0.7905, 0.8282]}, {"w": "perfor‐", "b": [0.7977, 0.8068, 0.8571, 0.8282]}, {"w": "mance", "b": [0.1429, 0.8258, 0.1981, 0.8472]}, {"w": "will", "b": [0.2031, 0.8258, 0.2334, 0.8472]}, {"w": "be", "b": [0.2384, 0.8258, 0.2578, 0.8472]}, {"w": "disappointing.", "b": [0.2627, 0.8258, 0.3826, 0.8472]}, {"w": "Moreover,", "b": [0.3875, 0.8258, 0.473, 0.8472]}, {"w": "every", "b": [0.4779, 0.8258, 0.5232, 0.8472]}, {"w": "time", "b": [0.5281, 0.8258, 0.5659, 0.8472]}, {"w": "the", "b": [0.5709, 0.8258, 0.5972, 0.8472]}, {"w": "company", "b": [0.6021, 0.8258, 0.6788, 0.8472]}, {"w": "makes", "b": [0.6837, 0.8258, 0.7367, 0.8472]}, {"w": "any", "b": [0.7416, 0.8258, 0.7713, 0.8472]}, {"w": "change", "b": [0.7762, 0.8258, 0.8353, 0.8472]}, {"w": "to", "b": [0.8402, 0.8258, 0.8571, 0.8472]}, {"w": "its", "b": [0.1429, 0.8448, 0.1624, 0.8663]}, {"w": "products,", "b": [0.1683, 0.8448, 0.2472, 0.8663]}, {"w": "the", "b": [0.2531, 0.8448, 0.2795, 0.8663]}, {"w": "whole", "b": [0.2854, 0.8448, 0.3355, 0.8663]}, {"w": "process", "b": [0.3414, 0.8448, 0.4036, 0.8663]}, {"w": "will", "b": [0.4095, 0.8448, 0.4399, 0.8663]}, {"w": "need", "b": [0.4458, 0.8448, 0.4859, 0.8663]}, {"w": "to", "b": [0.4918, 0.8448, 0.5088, 0.8663]}, {"w": "be", "b": [0.5147, 0.8448, 0.5342, 0.8663]}, {"w": "started", "b": [0.5401, 0.8448, 0.5971, 0.8663]}, {"w": "over", "b": [0.603, 0.8448, 0.6399, 0.8663]}, {"w": "from", "b": [0.6458, 0.8448, 0.6874, 0.8663]}, {"w": "scratch.", "b": [0.6933, 0.8448, 0.7573, 0.8663]}, {"w": "Wouldn’t", "b": [0.7632, 0.8448, 0.8393, 0.8663]}, {"w": "it", "b": [0.8452, 0.8448, 0.8571, 0.8663]}]}, {"id": "b_4", "type": "paragraph", "text": "237", "words": [{"w": "237", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 264, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "be great if the algorithm could just exploit the unlabeled data without needing humans to label every picture? Enter unsupervised learning.", "words": [{"w": "be", "b": [0.1429, 0.0791, 0.1623, 0.1005]}, {"w": "great", "b": [0.1725, 0.0791, 0.214, 0.1005]}, {"w": "if", "b": [0.2242, 0.0791, 0.236, 0.1005]}, {"w": "the", "b": [0.2462, 0.0791, 0.2725, 0.1005]}, {"w": "algorithm", "b": [0.2828, 0.0791, 0.3654, 0.1005]}, {"w": "could", "b": [0.3756, 0.0791, 0.4224, 0.1005]}, {"w": "just", "b": [0.4327, 0.0791, 0.4631, 0.1005]}, {"w": "exploit", "b": [0.4733, 0.0791, 0.5307, 0.1005]}, {"w": "the", "b": [0.541, 0.0791, 0.5673, 0.1005]}, {"w": "unlabeled", "b": [0.5775, 0.0791, 0.659, 0.1005]}, {"w": "data", "b": [0.6692, 0.0791, 0.7045, 0.1005]}, {"w": "without", "b": [0.7147, 0.0791, 0.7801, 0.1005]}, {"w": "needing", "b": [0.7903, 0.0791, 0.8571, 0.1005]}, {"w": "humans", "b": [0.1429, 0.0981, 0.2099, 0.1195]}, {"w": "to", "b": [0.2146, 0.0981, 0.2316, 0.1195]}, {"w": "label", "b": [0.2363, 0.0981, 0.2755, 0.1195]}, {"w": "every", "b": [0.2802, 0.0981, 0.3254, 0.1195]}, {"w": "picture?", "b": [0.3302, 0.0981, 0.3974, 0.1195]}, {"w": "Enter", "b": [0.4021, 0.0981, 0.4479, 0.1195]}, {"w": "unsupervised", "b": [0.4526, 0.0981, 0.5646, 0.1195]}, {"w": "learning.", "b": [0.5693, 0.0981, 0.6432, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "In Chapter 8, we looked at the most common unsupervised learning task: dimension‐ ality reduction. In this chapter, we will look at a few more unsupervised learning tasks and algorithms:", "words": [{"w": "In", "b": [0.1429, 0.1262, 0.1614, 0.1476]}, {"w": "Chapter", "b": [0.1663, 0.1262, 0.2339, 0.1476]}, {"w": "8,", "b": [0.2386, 0.1262, 0.2535, 0.1476]}, {"w": "we", "b": [0.2584, 0.1262, 0.2816, 0.1476]}, {"w": "looked", "b": [0.2865, 0.1262, 0.3432, 0.1476]}, {"w": "at", "b": [0.3481, 0.1262, 0.3632, 0.1476]}, {"w": "the", "b": [0.3681, 0.1262, 0.3945, 0.1476]}, {"w": "most", "b": [0.3994, 0.1262, 0.4411, 0.1476]}, {"w": "common", "b": [0.446, 0.1262, 0.5216, 0.1476]}, {"w": "unsupervised", "b": [0.5265, 0.1262, 0.6385, 0.1476]}, {"w": "learning", "b": [0.6434, 0.1262, 0.7125, 0.1476]}, {"w": "task:", "b": [0.7174, 0.1262, 0.7557, 0.1476]}, {"w": "dimension‐", "b": [0.7606, 0.1262, 0.8571, 0.1476]}, {"w": "ality", "b": [0.1429, 0.1453, 0.1788, 0.1667]}, {"w": "reduction.", "b": [0.1835, 0.1453, 0.2697, 0.1667]}, {"w": "In", "b": [0.2744, 0.1453, 0.2929, 0.1667]}, {"w": "this", "b": [0.2976, 0.1453, 0.3283, 0.1667]}, {"w": "chapter,", "b": [0.3331, 0.1453, 0.3991, 0.1667]}, {"w": "we", "b": [0.4038, 0.1453, 0.4269, 0.1667]}, {"w": "will", "b": [0.4316, 0.1453, 0.462, 0.1667]}, {"w": "look", "b": [0.4668, 0.1453, 0.5036, 0.1667]}, {"w": "at", "b": [0.5083, 0.1453, 0.5235, 0.1667]}, {"w": "a", "b": [0.5282, 0.1453, 0.5373, 0.1667]}, {"w": "few", "b": [0.5421, 0.1453, 0.5713, 0.1667]}, {"w": "more", "b": [0.5761, 0.1453, 0.6203, 0.1667]}, {"w": "unsupervised", "b": [0.6251, 0.1453, 0.7371, 0.1667]}, {"w": "learning", "b": [0.7418, 0.1453, 0.8109, 0.1667]}, {"w": "tasks", "b": [0.8157, 0.1453, 0.8568, 0.1667]}, {"w": "and", "b": [0.1429, 0.1643, 0.1744, 0.1857]}, {"w": "algorithms:", "b": [0.1791, 0.1643, 0.2742, 0.1857]}]}, {"id": "b_2", "type": "paragraph", "text": "• Clustering: the goal is to group similar instances together into clusters. This is a great tool for data analysis, customer segmentation, recommender systems, search engines, image segmentation, semi-supervised learning, dimensionality reduction, and more.", "words": [{"w": "•", "b": [0.16, 0.1985, 0.1682, 0.2199]}, {"w": "Clustering:", "b": [0.1786, 0.1983, 0.2668, 0.2199]}, {"w": "the", "b": [0.2735, 0.1985, 0.2998, 0.2199]}, {"w": "goal", "b": [0.3065, 0.1985, 0.3413, 0.2199]}, {"w": "is", "b": [0.3479, 0.1985, 0.3612, 0.2199]}, {"w": "to", "b": [0.3678, 0.1985, 0.3848, 0.2199]}, {"w": "group", "b": [0.3915, 0.1985, 0.4416, 0.2199]}, {"w": "similar", "b": [0.4483, 0.1985, 0.5063, 0.2199]}, {"w": "instances", "b": [0.513, 0.1985, 0.5898, 0.2199]}, {"w": "together", "b": [0.5965, 0.1985, 0.6661, 0.2199]}, {"w": "into", "b": [0.6728, 0.1985, 0.7064, 0.2199]}, {"w": "clusters.", "b": [0.7131, 0.1983, 0.7775, 0.2199]}, {"w": "This", "b": [0.7842, 0.1985, 0.8214, 0.2199]}, {"w": "is", "b": [0.8281, 0.1985, 0.8413, 0.2199]}, {"w": "a", "b": [0.848, 0.1985, 0.8571, 0.2199]}, {"w": "great", "b": [0.1786, 0.2175, 0.22, 0.2389]}, {"w": "tool", "b": [0.2315, 0.2175, 0.2644, 0.2389]}, {"w": "for", "b": [0.2758, 0.2175, 0.3003, 0.2389]}, {"w": "data", "b": [0.3118, 0.2175, 0.3471, 0.2389]}, {"w": "analysis,", "b": [0.3585, 0.2175, 0.4287, 0.2389]}, {"w": "customer", "b": [0.4401, 0.2175, 0.5183, 0.2389]}, {"w": "segmentation,", "b": [0.5297, 0.2175, 0.6467, 0.2389]}, {"w": "recommender", "b": [0.6582, 0.2175, 0.7762, 0.2389]}, {"w": "systems,", "b": [0.7876, 0.2175, 0.8571, 0.2389]}, {"w": "search", "b": [0.1786, 0.2366, 0.2319, 0.258]}, {"w": "engines,", "b": [0.241, 0.2366, 0.3092, 0.258]}, {"w": "image", "b": [0.3183, 0.2366, 0.3687, 0.258]}, {"w": "segmentation,", "b": [0.3778, 0.2366, 0.4948, 0.258]}, {"w": "semi-supervised", "b": [0.5039, 0.2366, 0.64, 0.258]}, {"w": "learning,", "b": [0.6491, 0.2366, 0.723, 0.258]}, {"w": "dimensionality", "b": [0.7321, 0.2366, 0.8571, 0.258]}, {"w": "reduction,", "b": [0.1786, 0.2556, 0.2647, 0.277]}, {"w": "and", "b": [0.2695, 0.2556, 0.301, 0.277]}, {"w": "more.", "b": [0.3057, 0.2556, 0.3548, 0.277]}]}, {"id": "b_3", "type": "paragraph", "text": "• Anomaly detection: the objective is to learn what “normal” data looks like, and use this to detect abnormal instances, such as defective items on a production line or a new trend in a time series.", "words": [{"w": "•", "b": [0.16, 0.2807, 0.1682, 0.3021]}, {"w": "Anomaly", "b": [0.1786, 0.2805, 0.2532, 0.3021]}, {"w": "detection:", "b": [0.2607, 0.2805, 0.339, 0.3021]}, {"w": "the", "b": [0.3464, 0.2807, 0.3727, 0.3021]}, {"w": "objective", "b": [0.3801, 0.2807, 0.4548, 0.3021]}, {"w": "is", "b": [0.4622, 0.2807, 0.4754, 0.3021]}, {"w": "to", "b": [0.4828, 0.2807, 0.4998, 0.3021]}, {"w": "learn", "b": [0.5071, 0.2807, 0.5495, 0.3021]}, {"w": "what", "b": [0.5569, 0.2807, 0.5974, 0.3021]}, {"w": "“normal”", "b": [0.6048, 0.2807, 0.6815, 0.3021]}, {"w": "data", "b": [0.6889, 0.2807, 0.7241, 0.3021]}, {"w": "looks", "b": [0.7315, 0.2807, 0.776, 0.3021]}, {"w": "like,", "b": [0.7834, 0.2807, 0.8182, 0.3021]}, {"w": "and", "b": [0.8256, 0.2807, 0.8571, 0.3021]}, {"w": "use", "b": [0.1786, 0.2998, 0.2061, 0.3212]}, {"w": "this", "b": [0.2137, 0.2998, 0.2444, 0.3212]}, {"w": "to", "b": [0.2519, 0.2998, 0.2689, 0.3212]}, {"w": "detect", "b": [0.2764, 0.2998, 0.3266, 0.3212]}, {"w": "abnormal", "b": [0.3341, 0.2998, 0.4151, 0.3212]}, {"w": "instances,", "b": [0.4226, 0.2998, 0.5042, 0.3212]}, {"w": "such", "b": [0.5117, 0.2998, 0.5503, 0.3212]}, {"w": "as", "b": [0.5579, 0.2998, 0.5747, 0.3212]}, {"w": "defective", "b": [0.5822, 0.2998, 0.6563, 0.3212]}, {"w": "items", "b": [0.6638, 0.2998, 0.7093, 0.3212]}, {"w": "on", "b": [0.7168, 0.2998, 0.7389, 0.3212]}, {"w": "a", "b": [0.7464, 0.2998, 0.7555, 0.3212]}, {"w": "production", "b": [0.763, 0.2998, 0.8571, 0.3212]}, {"w": "line", "b": [0.1786, 0.3188, 0.2097, 0.3402]}, {"w": "or", "b": [0.2144, 0.3188, 0.2328, 0.3402]}, {"w": "a", "b": [0.2375, 0.3188, 0.2466, 0.3402]}, {"w": "new", "b": [0.2514, 0.3188, 0.2859, 0.3402]}, {"w": "trend", "b": [0.2906, 0.3188, 0.3359, 0.3402]}, {"w": "in", "b": [0.3407, 0.3188, 0.3576, 0.3402]}, {"w": "a", "b": [0.3624, 0.3188, 0.3715, 0.3402]}, {"w": "time", "b": [0.3763, 0.3188, 0.4141, 0.3402]}, {"w": "series.", "b": [0.4188, 0.3188, 0.4699, 0.3402]}]}, {"id": "b_4", "type": "paragraph", "text": "• Density estimation: this is the task of estimating the probability density function (PDF) of the random process that generated the dataset. This is commonly used for anomaly detection: instances located in very low-density regions are likely to be anomalies. It is also useful for data analysis and visualization.", "words": [{"w": "•", "b": [0.16, 0.3439, 0.1682, 0.3653]}, {"w": "Density", "b": [0.1786, 0.3437, 0.2407, 0.3653]}, {"w": "estimation:", "b": [0.2479, 0.3437, 0.3377, 0.3653]}, {"w": "this", "b": [0.3449, 0.3439, 0.3756, 0.3653]}, {"w": "is", "b": [0.3827, 0.3439, 0.3959, 0.3653]}, {"w": "the", "b": [0.4031, 0.3439, 0.4294, 0.3653]}, {"w": "task", "b": [0.4366, 0.3439, 0.47, 0.3653]}, {"w": "of", "b": [0.4772, 0.3439, 0.494, 0.3653]}, {"w": "estimating", "b": [0.5011, 0.3439, 0.5884, 0.3653]}, {"w": "the", "b": [0.5956, 0.3439, 0.6219, 0.3653]}, {"w": "probability", "b": [0.6291, 0.3437, 0.7169, 0.3653]}, {"w": "density", "b": [0.7241, 0.3437, 0.7818, 0.3653]}, {"w": "function", "b": [0.789, 0.3437, 0.8571, 0.3653]}, {"w": "(PDF)", "b": [0.1786, 0.363, 0.2311, 0.3844]}, {"w": "of", "b": [0.237, 0.363, 0.2538, 0.3844]}, {"w": "the", "b": [0.2597, 0.363, 0.286, 0.3844]}, {"w": "random", "b": [0.2919, 0.363, 0.3589, 0.3844]}, {"w": "process", "b": [0.3648, 0.363, 0.427, 0.3844]}, {"w": "that", "b": [0.433, 0.363, 0.4656, 0.3844]}, {"w": "generated", "b": [0.4715, 0.363, 0.553, 0.3844]}, {"w": "the", "b": [0.5589, 0.363, 0.5853, 0.3844]}, {"w": "dataset.", "b": [0.5912, 0.363, 0.654, 0.3844]}, {"w": "This", "b": [0.66, 0.363, 0.6972, 0.3844]}, {"w": "is", "b": [0.7031, 0.363, 0.7163, 0.3844]}, {"w": "commonly", "b": [0.7222, 0.363, 0.8127, 0.3844]}, {"w": "used", "b": [0.8186, 0.363, 0.8571, 0.3844]}, {"w": "for", "b": [0.1786, 0.382, 0.2031, 0.4034]}, {"w": "anomaly", "b": [0.2087, 0.382, 0.2809, 0.4034]}, {"w": "detection:", "b": [0.2866, 0.382, 0.3692, 0.4034]}, {"w": "instances", "b": [0.3748, 0.382, 0.4517, 0.4034]}, {"w": "located", "b": [0.4573, 0.382, 0.517, 0.4034]}, {"w": "in", "b": [0.5227, 0.382, 0.5396, 0.4034]}, {"w": "very", "b": [0.5453, 0.382, 0.5817, 0.4034]}, {"w": "low-density", "b": [0.5874, 0.382, 0.6853, 0.4034]}, {"w": "regions", "b": [0.691, 0.382, 0.7526, 0.4034]}, {"w": "are", "b": [0.7582, 0.382, 0.784, 0.4034]}, {"w": "likely", "b": [0.7896, 0.382, 0.8345, 0.4034]}, {"w": "to", "b": [0.8402, 0.382, 0.8571, 0.4034]}, {"w": "be", "b": [0.1786, 0.4011, 0.198, 0.4225]}, {"w": "anomalies.", "b": [0.2027, 0.4011, 0.2922, 0.4225]}, {"w": "It", "b": [0.2969, 0.4011, 0.3096, 0.4225]}, {"w": "is", "b": [0.3143, 0.4011, 0.3275, 0.4225]}, {"w": "also", "b": [0.3323, 0.4011, 0.365, 0.4225]}, {"w": "useful", "b": [0.3697, 0.4011, 0.4198, 0.4225]}, {"w": "for", "b": [0.4245, 0.4011, 0.449, 0.4225]}, {"w": "data", "b": [0.4537, 0.4011, 0.489, 0.4225]}, {"w": "analysis", "b": [0.4937, 0.4011, 0.5591, 0.4225]}, {"w": "and", "b": [0.5638, 0.4011, 0.5954, 0.4225]}, {"w": "visualization.", "b": [0.6001, 0.4011, 0.7103, 0.4225]}]}, {"id": "b_5", "type": "paragraph", "text": "Ready for some cake? We will start with clustering, using K-Means and DBSCAN, and then we will discuss Gaussian mixture models and see how they can be used for density estimation, clustering, and anomaly detection.", "words": [{"w": "Ready", "b": [0.1429, 0.4352, 0.1944, 0.4566]}, {"w": "for", "b": [0.2019, 0.4352, 0.2264, 0.4566]}, {"w": "some", "b": [0.234, 0.4352, 0.2781, 0.4566]}, {"w": "cake?", "b": [0.2857, 0.4352, 0.3307, 0.4566]}, {"w": "We", "b": [0.3382, 0.4352, 0.3653, 0.4566]}, {"w": "will", "b": [0.3728, 0.4352, 0.4032, 0.4566]}, {"w": "start", "b": [0.4108, 0.4352, 0.448, 0.4566]}, {"w": "with", "b": [0.4555, 0.4352, 0.4929, 0.4566]}, {"w": "clustering,", "b": [0.5004, 0.4352, 0.5876, 0.4566]}, {"w": "using", "b": [0.5951, 0.4352, 0.6406, 0.4566]}, {"w": "K-Means", "b": [0.6481, 0.4352, 0.7246, 0.4566]}, {"w": "and", "b": [0.7322, 0.4352, 0.7637, 0.4566]}, {"w": "DBSCAN,", "b": [0.7712, 0.4352, 0.8571, 0.4566]}, {"w": "and", "b": [0.1429, 0.4543, 0.1744, 0.4757]}, {"w": "then", "b": [0.1803, 0.4543, 0.218, 0.4757]}, {"w": "we", "b": [0.2239, 0.4543, 0.247, 0.4757]}, {"w": "will", "b": [0.2529, 0.4543, 0.2833, 0.4757]}, {"w": "discuss", "b": [0.2892, 0.4543, 0.3486, 0.4757]}, {"w": "Gaussian", "b": [0.3545, 0.4543, 0.4306, 0.4757]}, {"w": "mixture", "b": [0.4365, 0.4543, 0.503, 0.4757]}, {"w": "models", "b": [0.5089, 0.4543, 0.5693, 0.4757]}, {"w": "and", "b": [0.5752, 0.4543, 0.6068, 0.4757]}, {"w": "see", "b": [0.6127, 0.4543, 0.638, 0.4757]}, {"w": "how", "b": [0.6439, 0.4543, 0.6799, 0.4757]}, {"w": "they", "b": [0.6858, 0.4543, 0.7217, 0.4757]}, {"w": "can", "b": [0.7276, 0.4543, 0.757, 0.4757]}, {"w": "be", "b": [0.7628, 0.4543, 0.7823, 0.4757]}, {"w": "used", "b": [0.7882, 0.4543, 0.8267, 0.4757]}, {"w": "for", "b": [0.8326, 0.4543, 0.8571, 0.4757]}, {"w": "density", "b": [0.1429, 0.4733, 0.2032, 0.4947]}, {"w": "estimation,", "b": [0.208, 0.4733, 0.3009, 0.4947]}, {"w": "clustering,", "b": [0.3057, 0.4733, 0.3929, 0.4947]}, {"w": "and", "b": [0.3976, 0.4733, 0.4291, 0.4947]}, {"w": "anomaly", "b": [0.4339, 0.4733, 0.5061, 0.4947]}, {"w": "detection.", "b": [0.5108, 0.4733, 0.5934, 0.4947]}]}, {"id": "b_6", "type": "paragraph", "text": "Clustering", "words": [{"w": "Clustering", "b": [0.1428, 0.5077, 0.2685, 0.542]}]}, {"id": "b_7", "type": "paragraph", "text": "As you enjoy a hike in the mountains, you stumble upon a plant you have never seen before. You look around and you notice a few more. They are not perfectly identical, yet they are sufficiently similar for you to know that they most likely belong to the same species (or at least the same genus). You may need a botanist to tell you what species that is, but you certainly don’t need an expert to identify groups of similar- looking objects. This is called clustering: it is the task of identifying similar instances and assigning them to clusters, i.e., groups of similar instances.", "words": [{"w": "As", "b": [0.1429, 0.5489, 0.1649, 0.5703]}, {"w": "you", "b": [0.1703, 0.5489, 0.2015, 0.5703]}, {"w": "enjoy", "b": [0.2069, 0.5489, 0.2523, 0.5703]}, {"w": "a", "b": [0.2576, 0.5489, 0.2668, 0.5703]}, {"w": "hike", "b": [0.2721, 0.5489, 0.308, 0.5703]}, {"w": "in", "b": [0.3134, 0.5489, 0.3304, 0.5703]}, {"w": "the", "b": [0.3357, 0.5489, 0.3621, 0.5703]}, {"w": "mountains,", "b": [0.3674, 0.5489, 0.4621, 0.5703]}, {"w": "you", "b": [0.4674, 0.5489, 0.4987, 0.5703]}, {"w": "stumble", "b": [0.504, 0.5489, 0.5709, 0.5703]}, {"w": "upon", "b": [0.5762, 0.5489, 0.6202, 0.5703]}, {"w": "a", "b": [0.6256, 0.5489, 0.6348, 0.5703]}, {"w": "plant", "b": [0.6401, 0.5489, 0.6828, 0.5703]}, {"w": "you", "b": [0.6882, 0.5489, 0.7194, 0.5703]}, {"w": "have", "b": [0.7248, 0.5489, 0.7632, 0.5703]}, {"w": "never", "b": [0.7685, 0.5489, 0.815, 0.5703]}, {"w": "seen", "b": [0.8204, 0.5489, 0.8571, 0.5703]}, {"w": "before.", "b": [0.1429, 0.568, 0.2004, 0.5894]}, {"w": "You", "b": [0.2061, 0.568, 0.2384, 0.5894]}, {"w": "look", "b": [0.2441, 0.568, 0.281, 0.5894]}, {"w": "around", "b": [0.2866, 0.568, 0.3476, 0.5894]}, {"w": "and", "b": [0.3532, 0.568, 0.3848, 0.5894]}, {"w": "you", "b": [0.3904, 0.568, 0.4217, 0.5894]}, {"w": "notice", "b": [0.4274, 0.568, 0.479, 0.5894]}, {"w": "a", "b": [0.4847, 0.568, 0.4938, 0.5894]}, {"w": "few", "b": [0.4995, 0.568, 0.5288, 0.5894]}, {"w": "more.", "b": [0.5344, 0.568, 0.5834, 0.5894]}, {"w": "They", "b": [0.5891, 0.568, 0.6315, 0.5894]}, {"w": "are", "b": [0.6372, 0.568, 0.6629, 0.5894]}, {"w": "not", "b": [0.6686, 0.568, 0.6969, 0.5894]}, {"w": "perfectly", "b": [0.7026, 0.568, 0.7751, 0.5894]}, {"w": "identical,", "b": [0.7808, 0.568, 0.8571, 0.5894]}, {"w": "yet", "b": [0.1429, 0.587, 0.1676, 0.6084]}, {"w": "they", "b": [0.1745, 0.587, 0.2104, 0.6084]}, {"w": "are", "b": [0.2173, 0.587, 0.2431, 0.6084]}, {"w": "sufficiently", "b": [0.25, 0.587, 0.342, 0.6084]}, {"w": "similar", "b": [0.349, 0.587, 0.407, 0.6084]}, {"w": "for", "b": [0.4139, 0.587, 0.4384, 0.6084]}, {"w": "you", "b": [0.4453, 0.587, 0.4766, 0.6084]}, {"w": "to", "b": [0.4835, 0.587, 0.5004, 0.6084]}, {"w": "know", "b": [0.5073, 0.587, 0.554, 0.6084]}, {"w": "that", "b": [0.5609, 0.587, 0.5935, 0.6084]}, {"w": "they", "b": [0.6004, 0.587, 0.6363, 0.6084]}, {"w": "most", "b": [0.6432, 0.587, 0.6849, 0.6084]}, {"w": "likely", "b": [0.6918, 0.587, 0.7366, 0.6084]}, {"w": "belong", "b": [0.7435, 0.587, 0.8, 0.6084]}, {"w": "to", "b": [0.8069, 0.587, 0.8239, 0.6084]}, {"w": "the", "b": [0.8308, 0.587, 0.8572, 0.6084]}, {"w": "same", "b": [0.1429, 0.606, 0.1856, 0.6275]}, {"w": "species", "b": [0.1922, 0.606, 0.2506, 0.6275]}, {"w": "(or", "b": [0.2572, 0.606, 0.2828, 0.6275]}, {"w": "at", "b": [0.2895, 0.606, 0.3046, 0.6275]}, {"w": "least", "b": [0.3113, 0.606, 0.3485, 0.6275]}, {"w": "the", "b": [0.3552, 0.606, 0.3815, 0.6275]}, {"w": "same", "b": [0.3882, 0.606, 0.4309, 0.6275]}, {"w": "genus).", "b": [0.4376, 0.606, 0.4979, 0.6275]}, {"w": "You", "b": [0.5046, 0.606, 0.5369, 0.6275]}, {"w": "may", "b": [0.5436, 0.606, 0.579, 0.6275]}, {"w": "need", "b": [0.5857, 0.606, 0.6258, 0.6275]}, {"w": "a", "b": [0.6324, 0.606, 0.6416, 0.6275]}, {"w": "botanist", "b": [0.6483, 0.606, 0.716, 0.6275]}, {"w": "to", "b": [0.7226, 0.606, 0.7396, 0.6275]}, {"w": "tell", "b": [0.7463, 0.606, 0.772, 0.6275]}, {"w": "you", "b": [0.7787, 0.606, 0.81, 0.6275]}, {"w": "what", "b": [0.8166, 0.606, 0.8571, 0.6275]}, {"w": "species", "b": [0.1429, 0.6251, 0.2012, 0.6465]}, {"w": "that", "b": [0.2081, 0.6251, 0.2407, 0.6465]}, {"w": "is,", "b": [0.2477, 0.6251, 0.2657, 0.6465]}, {"w": "but", "b": [0.2727, 0.6251, 0.3007, 0.6465]}, {"w": "you", "b": [0.3077, 0.6251, 0.3389, 0.6465]}, {"w": "certainly", "b": [0.3459, 0.6251, 0.4186, 0.6465]}, {"w": "don’t", "b": [0.4256, 0.6251, 0.4672, 0.6465]}, {"w": "need", "b": [0.4742, 0.6251, 0.5143, 0.6465]}, {"w": "an", "b": [0.5213, 0.6251, 0.5418, 0.6465]}, {"w": "expert", "b": [0.5488, 0.6251, 0.6013, 0.6465]}, {"w": "to", "b": [0.6083, 0.6251, 0.6253, 0.6465]}, {"w": "identify", "b": [0.6323, 0.6251, 0.6967, 0.6465]}, {"w": "groups", "b": [0.7037, 0.6251, 0.7614, 0.6465]}, {"w": "of", "b": [0.7684, 0.6251, 0.7852, 0.6465]}, {"w": "similar-", "b": [0.7922, 0.6251, 0.8571, 0.6465]}, {"w": "looking", "b": [0.1428, 0.6441, 0.2064, 0.6656]}, {"w": "objects.", "b": [0.2125, 0.6441, 0.2754, 0.6656]}, {"w": "This", "b": [0.2815, 0.6441, 0.3187, 0.6656]}, {"w": "is", "b": [0.3247, 0.6441, 0.3379, 0.6656]}, {"w": "called", "b": [0.344, 0.6441, 0.3923, 0.6656]}, {"w": "clustering:", "b": [0.3984, 0.6439, 0.481, 0.6656]}, {"w": "it", "b": [0.4871, 0.6441, 0.499, 0.6656]}, {"w": "is", "b": [0.5051, 0.6441, 0.5183, 0.6656]}, {"w": "the", "b": [0.5243, 0.6441, 0.5506, 0.6656]}, {"w": "task", "b": [0.5567, 0.6441, 0.5902, 0.6656]}, {"w": "of", "b": [0.5962, 0.6441, 0.613, 0.6656]}, {"w": "identifying", "b": [0.619, 0.6441, 0.7102, 0.6656]}, {"w": "similar", "b": [0.7162, 0.6441, 0.7743, 0.6656]}, {"w": "instances", "b": [0.7803, 0.6441, 0.8571, 0.6656]}, {"w": "and", "b": [0.1429, 0.6632, 0.1744, 0.6846]}, {"w": "assigning", "b": [0.1791, 0.6632, 0.257, 0.6846]}, {"w": "them", "b": [0.2618, 0.6632, 0.3052, 0.6846]}, {"w": "to", "b": [0.3099, 0.6632, 0.3269, 0.6846]}, {"w": "clusters,", "b": [0.3316, 0.663, 0.3961, 0.6846]}, {"w": "i.e.,", "b": [0.4008, 0.6632, 0.4295, 0.6846]}, {"w": "groups", "b": [0.4342, 0.6632, 0.4919, 0.6846]}, {"w": "of", "b": [0.4967, 0.6632, 0.5134, 0.6846]}, {"w": "similar", "b": [0.5182, 0.6632, 0.5762, 0.6846]}, {"w": "instances.", "b": [0.5809, 0.6632, 0.6625, 0.6846]}]}, {"id": "b_8", "type": "paragraph", "text": "Just like in classification, each instance gets assigned to a group. However, this is an unsupervised task. Consider Figure 9-1: on the left is the iris dataset (introduced in Chapter 4), where each instance’s species (i.e., its class) is represented with a different marker. It is a labeled dataset, for which classification algorithms such as Logistic Regression, SVMs or Random Forest classifiers are well suited. On the right is the same dataset, but without the labels, so you cannot use a classification algorithm any‐ more. This is where clustering algorithms step in: many of them can easily detect the top left cluster. It is also quite easy to see with our own eyes, but it is not so obvious that the lower right cluster is actually composed of two distinct sub-clusters. That said, the dataset actually has two additional features (sepal length and width), not", "words": [{"w": "Just", "b": [0.1429, 0.6913, 0.1741, 0.7127]}, {"w": "like", "b": [0.1805, 0.6913, 0.2105, 0.7127]}, {"w": "in", "b": [0.2169, 0.6913, 0.2339, 0.7127]}, {"w": "classification,", "b": [0.2403, 0.6913, 0.3524, 0.7127]}, {"w": "each", "b": [0.3588, 0.6913, 0.3968, 0.7127]}, {"w": "instance", "b": [0.4031, 0.6913, 0.4723, 0.7127]}, {"w": "gets", "b": [0.4787, 0.6913, 0.5113, 0.7127]}, {"w": "assigned", "b": [0.5177, 0.6913, 0.5887, 0.7127]}, {"w": "to", "b": [0.5951, 0.6913, 0.6121, 0.7127]}, {"w": "a", "b": [0.6185, 0.6913, 0.6276, 0.7127]}, {"w": "group.", "b": [0.634, 0.6913, 0.6883, 0.7127]}, {"w": "However,", "b": [0.6946, 0.6913, 0.7735, 0.7127]}, {"w": "this", "b": [0.7799, 0.6913, 0.8106, 0.7127]}, {"w": "is", "b": [0.817, 0.6913, 0.8302, 0.7127]}, {"w": "an", "b": [0.8366, 0.6913, 0.8571, 0.7127]}, {"w": "unsupervised", "b": [0.1429, 0.7104, 0.2549, 0.7318]}, {"w": "task.", "b": [0.2615, 0.7104, 0.2997, 0.7318]}, {"w": "Consider", "b": [0.3063, 0.7104, 0.383, 0.7318]}, {"w": "Figure", "b": [0.3896, 0.7104, 0.4436, 0.7318]}, {"w": "9-1:", "b": [0.4502, 0.7104, 0.4823, 0.7318]}, {"w": "on", "b": [0.4889, 0.7104, 0.511, 0.7318]}, {"w": "the", "b": [0.5176, 0.7104, 0.5439, 0.7318]}, {"w": "left", "b": [0.5505, 0.7104, 0.5771, 0.7318]}, {"w": "is", "b": [0.5837, 0.7104, 0.597, 0.7318]}, {"w": "the", "b": [0.6036, 0.7104, 0.6299, 0.7318]}, {"w": "iris", "b": [0.6365, 0.7104, 0.663, 0.7318]}, {"w": "dataset", "b": [0.6696, 0.7104, 0.7277, 0.7318]}, {"w": "(introduced", "b": [0.7343, 0.7104, 0.8336, 0.7318]}, {"w": "in", "b": [0.8402, 0.7104, 0.8571, 0.7318]}, {"w": "Chapter", "b": [0.1429, 0.7294, 0.2104, 0.7508]}, {"w": "4),", "b": [0.2152, 0.7294, 0.2377, 0.7508]}, {"w": "where", "b": [0.243, 0.7294, 0.2938, 0.7508]}, {"w": "each", "b": [0.2991, 0.7294, 0.3371, 0.7508]}, {"w": "instance’s", "b": [0.3424, 0.7294, 0.4207, 0.7508]}, {"w": "species", "b": [0.426, 0.7294, 0.4843, 0.7508]}, {"w": "(i.e.,", "b": [0.4896, 0.7294, 0.5255, 0.7508]}, {"w": "its", "b": [0.5308, 0.7294, 0.5504, 0.7508]}, {"w": "class)", "b": [0.5557, 0.7294, 0.6014, 0.7508]}, {"w": "is", "b": [0.6067, 0.7294, 0.62, 0.7508]}, {"w": "represented", "b": [0.6253, 0.7294, 0.723, 0.7508]}, {"w": "with", "b": [0.7284, 0.7294, 0.7657, 0.7508]}, {"w": "a", "b": [0.771, 0.7294, 0.7801, 0.7508]}, {"w": "different", "b": [0.7854, 0.7294, 0.8571, 0.7508]}, {"w": "marker.", "b": [0.1429, 0.7485, 0.2071, 0.7699]}, {"w": "It", "b": [0.2154, 0.7485, 0.228, 0.7699]}, {"w": "is", "b": [0.2363, 0.7485, 0.2495, 0.7699]}, {"w": "a", "b": [0.2578, 0.7485, 0.2669, 0.7699]}, {"w": "labeled", "b": [0.2752, 0.7485, 0.3342, 0.7699]}, {"w": "dataset,", "b": [0.3424, 0.7485, 0.4053, 0.7699]}, {"w": "for", "b": [0.4135, 0.7485, 0.438, 0.7699]}, {"w": "which", "b": [0.4463, 0.7485, 0.4972, 0.7699]}, {"w": "classification", "b": [0.5055, 0.7485, 0.6128, 0.7699]}, {"w": "algorithms", "b": [0.6211, 0.7485, 0.7114, 0.7699]}, {"w": "such", "b": [0.7196, 0.7485, 0.7583, 0.7699]}, {"w": "as", "b": [0.7665, 0.7485, 0.7833, 0.7699]}, {"w": "Logistic", "b": [0.7916, 0.7485, 0.8571, 0.7699]}, {"w": "Regression,", "b": [0.1428, 0.7675, 0.2386, 0.7889]}, {"w": "SVMs", "b": [0.2461, 0.7675, 0.2968, 0.7889]}, {"w": "or", "b": [0.3043, 0.7675, 0.3227, 0.7889]}, {"w": "Random", "b": [0.3302, 0.7675, 0.4027, 0.7889]}, {"w": "Forest", "b": [0.4102, 0.7675, 0.462, 0.7889]}, {"w": "classifiers", "b": [0.4695, 0.7675, 0.5496, 0.7889]}, {"w": "are", "b": [0.5571, 0.7675, 0.5828, 0.7889]}, {"w": "well", "b": [0.5903, 0.7675, 0.624, 0.7889]}, {"w": "suited.", "b": [0.6315, 0.7675, 0.6867, 0.7889]}, {"w": "On", "b": [0.6942, 0.7675, 0.7211, 0.7889]}, {"w": "the", "b": [0.7286, 0.7675, 0.755, 0.7889]}, {"w": "right", "b": [0.7625, 0.7675, 0.8026, 0.7889]}, {"w": "is", "b": [0.8101, 0.7675, 0.8233, 0.7889]}, {"w": "the", "b": [0.8308, 0.7675, 0.8571, 0.7889]}, {"w": "same", "b": [0.1429, 0.7865, 0.1856, 0.808]}, {"w": "dataset,", "b": [0.1907, 0.7865, 0.2535, 0.808]}, {"w": "but", "b": [0.2587, 0.7865, 0.2867, 0.808]}, {"w": "without", "b": [0.2918, 0.7865, 0.3571, 0.808]}, {"w": "the", "b": [0.3623, 0.7865, 0.3886, 0.808]}, {"w": "labels,", "b": [0.3937, 0.7865, 0.4452, 0.808]}, {"w": "so", "b": [0.4503, 0.7865, 0.4686, 0.808]}, {"w": "you", "b": [0.4737, 0.7865, 0.505, 0.808]}, {"w": "cannot", "b": [0.5101, 0.7865, 0.5678, 0.808]}, {"w": "use", "b": [0.5729, 0.7865, 0.6005, 0.808]}, {"w": "a", "b": [0.6056, 0.7865, 0.6147, 0.808]}, {"w": "classification", "b": [0.6199, 0.7865, 0.7272, 0.808]}, {"w": "algorithm", "b": [0.7323, 0.7865, 0.815, 0.808]}, {"w": "any‐", "b": [0.8201, 0.7865, 0.8571, 0.808]}, {"w": "more.", "b": [0.1429, 0.8056, 0.1919, 0.827]}, {"w": "This", "b": [0.1974, 0.8056, 0.2346, 0.827]}, {"w": "is", "b": [0.2401, 0.8056, 0.2533, 0.827]}, {"w": "where", "b": [0.2588, 0.8056, 0.3096, 0.827]}, {"w": "clustering", "b": [0.3151, 0.8056, 0.3976, 0.827]}, {"w": "algorithms", "b": [0.4031, 0.8056, 0.4934, 0.827]}, {"w": "step", "b": [0.4989, 0.8056, 0.5326, 0.827]}, {"w": "in:", "b": [0.5381, 0.8056, 0.5598, 0.827]}, {"w": "many", "b": [0.5653, 0.8056, 0.612, 0.827]}, {"w": "of", "b": [0.6175, 0.8056, 0.6343, 0.827]}, {"w": "them", "b": [0.6398, 0.8056, 0.6832, 0.827]}, {"w": "can", "b": [0.6887, 0.8056, 0.718, 0.827]}, {"w": "easily", "b": [0.7235, 0.8056, 0.7696, 0.827]}, {"w": "detect", "b": [0.7751, 0.8056, 0.8253, 0.827]}, {"w": "the", "b": [0.8308, 0.8056, 0.8571, 0.827]}, {"w": "top", "b": [0.1429, 0.8246, 0.1707, 0.8461]}, {"w": "left", "b": [0.1767, 0.8246, 0.2034, 0.8461]}, {"w": "cluster.", "b": [0.2094, 0.8246, 0.2685, 0.8461]}, {"w": "It", "b": [0.2745, 0.8246, 0.2872, 0.8461]}, {"w": "is", "b": [0.2931, 0.8246, 0.3064, 0.8461]}, {"w": "also", "b": [0.3124, 0.8246, 0.345, 0.8461]}, {"w": "quite", "b": [0.351, 0.8246, 0.3935, 0.8461]}, {"w": "easy", "b": [0.3995, 0.8246, 0.4347, 0.8461]}, {"w": "to", "b": [0.4407, 0.8246, 0.4577, 0.8461]}, {"w": "see", "b": [0.4637, 0.8246, 0.489, 0.8461]}, {"w": "with", "b": [0.495, 0.8246, 0.5323, 0.8461]}, {"w": "our", "b": [0.5383, 0.8246, 0.5677, 0.8461]}, {"w": "own", "b": [0.5737, 0.8246, 0.61, 0.8461]}, {"w": "eyes,", "b": [0.616, 0.8246, 0.6557, 0.8461]}, {"w": "but", "b": [0.6616, 0.8246, 0.6896, 0.8461]}, {"w": "it", "b": [0.6956, 0.8246, 0.7076, 0.8461]}, {"w": "is", "b": [0.7135, 0.8246, 0.7268, 0.8461]}, {"w": "not", "b": [0.7328, 0.8246, 0.7611, 0.8461]}, {"w": "so", "b": [0.7671, 0.8246, 0.7854, 0.8461]}, {"w": "obvious", "b": [0.7914, 0.8246, 0.8571, 0.8461]}, {"w": "that", "b": [0.1429, 0.8437, 0.1754, 0.8651]}, {"w": "the", "b": [0.1834, 0.8437, 0.2097, 0.8651]}, {"w": "lower", "b": [0.2176, 0.8437, 0.2644, 0.8651]}, {"w": "right", "b": [0.2723, 0.8437, 0.3124, 0.8651]}, {"w": "cluster", "b": [0.3204, 0.8437, 0.3761, 0.8651]}, {"w": "is", "b": [0.384, 0.8437, 0.3972, 0.8651]}, {"w": "actually", "b": [0.4052, 0.8437, 0.4698, 0.8651]}, {"w": "composed", "b": [0.4777, 0.8437, 0.5629, 0.8651]}, {"w": "of", "b": [0.5708, 0.8437, 0.5876, 0.8651]}, {"w": "two", "b": [0.5955, 0.8437, 0.6267, 0.8651]}, {"w": "distinct", "b": [0.6347, 0.8437, 0.6974, 0.8651]}, {"w": "sub-clusters.", "b": [0.7053, 0.8437, 0.8101, 0.8651]}, {"w": "That", "b": [0.8181, 0.8437, 0.8572, 0.8651]}, {"w": "said,", "b": [0.1429, 0.8627, 0.181, 0.8841]}, {"w": "the", "b": [0.1889, 0.8627, 0.2153, 0.8841]}, {"w": "dataset", "b": [0.2232, 0.8627, 0.2813, 0.8841]}, {"w": "actually", "b": [0.2893, 0.8627, 0.3539, 0.8841]}, {"w": "has", "b": [0.3619, 0.8627, 0.3898, 0.8841]}, {"w": "two", "b": [0.3977, 0.8627, 0.429, 0.8841]}, {"w": "additional", "b": [0.4369, 0.8627, 0.522, 0.8841]}, {"w": "features", "b": [0.53, 0.8627, 0.5954, 0.8841]}, {"w": "(sepal", "b": [0.6033, 0.8627, 0.6524, 0.8841]}, {"w": "length", "b": [0.6603, 0.8627, 0.7131, 0.8841]}, {"w": "and", "b": [0.721, 0.8627, 0.7526, 0.8841]}, {"w": "width),", "b": [0.7605, 0.8627, 0.8208, 0.8841]}, {"w": "not", "b": [0.8288, 0.8627, 0.8571, 0.8841]}]}, {"id": "b_9", "type": "paragraph", "text": "238 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "238", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 265, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "represented here, and clustering algorithms can make good use of all features, so in fact they identify the three clusters fairly well (e.g., using a Gaussian mixture model, only 5 instances out of 150 are assigned to the wrong cluster).", "words": [{"w": "represented", "b": [0.1429, 0.0791, 0.2406, 0.1005]}, {"w": "here,", "b": [0.2472, 0.0791, 0.2885, 0.1005]}, {"w": "and", "b": [0.295, 0.0791, 0.3265, 0.1005]}, {"w": "clustering", "b": [0.333, 0.0791, 0.4155, 0.1005]}, {"w": "algorithms", "b": [0.422, 0.0791, 0.5123, 0.1005]}, {"w": "can", "b": [0.5188, 0.0791, 0.5482, 0.1005]}, {"w": "make", "b": [0.5547, 0.0791, 0.6001, 0.1005]}, {"w": "good", "b": [0.6066, 0.0791, 0.6486, 0.1005]}, {"w": "use", "b": [0.6551, 0.0791, 0.6827, 0.1005]}, {"w": "of", "b": [0.6892, 0.0791, 0.706, 0.1005]}, {"w": "all", "b": [0.7125, 0.0791, 0.7322, 0.1005]}, {"w": "features,", "b": [0.7387, 0.0791, 0.8089, 0.1005]}, {"w": "so", "b": [0.8154, 0.0791, 0.8336, 0.1005]}, {"w": "in", "b": [0.8402, 0.0791, 0.8571, 0.1005]}, {"w": "fact", "b": [0.1429, 0.0981, 0.1733, 0.1195]}, {"w": "they", "b": [0.1794, 0.0981, 0.2153, 0.1195]}, {"w": "identify", "b": [0.2214, 0.0981, 0.2858, 0.1195]}, {"w": "the", "b": [0.2919, 0.0981, 0.3182, 0.1195]}, {"w": "three", "b": [0.3243, 0.0981, 0.3672, 0.1195]}, {"w": "clusters", "b": [0.3733, 0.0981, 0.4367, 0.1195]}, {"w": "fairly", "b": [0.4427, 0.0981, 0.4862, 0.1195]}, {"w": "well", "b": [0.4922, 0.0981, 0.5259, 0.1195]}, {"w": "(e.g.,", "b": [0.532, 0.0981, 0.572, 0.1195]}, {"w": "using", "b": [0.5781, 0.0981, 0.6236, 0.1195]}, {"w": "a", "b": [0.6296, 0.0981, 0.6388, 0.1195]}, {"w": "Gaussian", "b": [0.6448, 0.0981, 0.721, 0.1195]}, {"w": "mixture", "b": [0.727, 0.0981, 0.7935, 0.1195]}, {"w": "model,", "b": [0.7996, 0.0981, 0.8571, 0.1195]}, {"w": "only", "b": [0.1429, 0.1172, 0.1797, 0.1386]}, {"w": "5", "b": [0.1844, 0.1172, 0.1944, 0.1386]}, {"w": "instances", "b": [0.1992, 0.1172, 0.276, 0.1386]}, {"w": "out", "b": [0.2807, 0.1172, 0.3088, 0.1386]}, {"w": "of", "b": [0.3135, 0.1172, 0.3303, 0.1386]}, {"w": "150", "b": [0.335, 0.1172, 0.365, 0.1386]}, {"w": "are", "b": [0.3698, 0.1172, 0.3955, 0.1386]}, {"w": "assigned", "b": [0.4002, 0.1172, 0.4712, 0.1386]}, {"w": "to", "b": [0.476, 0.1172, 0.4929, 0.1386]}, {"w": "the", "b": [0.4977, 0.1172, 0.524, 0.1386]}, {"w": "wrong", "b": [0.5287, 0.1172, 0.5825, 0.1386]}, {"w": "cluster).", "b": [0.5872, 0.1172, 0.6549, 0.1386]}]}, {"id": "b_1", "type": "equation", "text": "Figure 9-1. Classification (left) versus clustering (right)", "words": [{"w": "Figure", "b": [0.1429, 0.3053, 0.1943, 0.3269]}, {"w": "9-1.", "b": [0.1991, 0.3053, 0.2308, 0.3269]}, {"w": "Classification", "b": [0.2356, 0.3053, 0.3461, 0.3269]}, {"w": "(left)", "b": [0.3509, 0.3053, 0.3902, 0.3269]}, {"w": "versus", "b": [0.395, 0.3053, 0.4451, 0.3269]}, {"w": "clustering", "b": [0.4499, 0.3053, 0.5278, 0.3269]}, {"w": "(right)", "b": [0.5326, 0.3053, 0.5852, 0.3269]}]}, {"id": "b_2", "type": "paragraph", "text": "Clustering is used in a wide variety of applications, including:", "words": [{"w": "Clustering", "b": [0.1429, 0.3427, 0.2304, 0.3641]}, {"w": "is", "b": [0.2351, 0.3427, 0.2483, 0.3641]}, {"w": "used", "b": [0.2531, 0.3427, 0.2916, 0.3641]}, {"w": "in", "b": [0.2963, 0.3427, 0.3133, 0.3641]}, {"w": "a", "b": [0.3181, 0.3427, 0.3272, 0.3641]}, {"w": "wide", "b": [0.3319, 0.3427, 0.3716, 0.3641]}, {"w": "variety", "b": [0.3764, 0.3427, 0.4332, 0.3641]}, {"w": "of", "b": [0.438, 0.3427, 0.4548, 0.3641]}, {"w": "applications,", "b": [0.4595, 0.3427, 0.5648, 0.3641]}, {"w": "including:", "b": [0.5696, 0.3427, 0.6542, 0.3641]}]}, {"id": "b_3", "type": "paragraph", "text": "• For customer segmentation: you can cluster your customers based on their pur‐ chases, their activity on your website, and so on. This is useful to understand who your customers are and what they need, so you can adapt your products and marketing campaigns to each segment. For example, this can be useful in recom‐ mender systems to suggest content that other users in the same cluster enjoyed.", "words": [{"w": "•", "b": [0.16, 0.3769, 0.1682, 0.3983]}, {"w": "For", "b": [0.1786, 0.3769, 0.2075, 0.3983]}, {"w": "customer", "b": [0.2137, 0.3769, 0.2918, 0.3983]}, {"w": "segmentation:", "b": [0.2979, 0.3769, 0.4149, 0.3983]}, {"w": "you", "b": [0.421, 0.3769, 0.4523, 0.3983]}, {"w": "can", "b": [0.4584, 0.3769, 0.4878, 0.3983]}, {"w": "cluster", "b": [0.4939, 0.3769, 0.5496, 0.3983]}, {"w": "your", "b": [0.5557, 0.3769, 0.5947, 0.3983]}, {"w": "customers", "b": [0.6008, 0.3769, 0.6866, 0.3983]}, {"w": "based", "b": [0.6927, 0.3769, 0.74, 0.3983]}, {"w": "on", "b": [0.7461, 0.3769, 0.7681, 0.3983]}, {"w": "their", "b": [0.7742, 0.3769, 0.8139, 0.3983]}, {"w": "pur‐", "b": [0.82, 0.3769, 0.8571, 0.3983]}, {"w": "chases,", "b": [0.1786, 0.3959, 0.2366, 0.4173]}, {"w": "their", "b": [0.2413, 0.3959, 0.2809, 0.4173]}, {"w": "activity", "b": [0.2857, 0.3959, 0.3467, 0.4173]}, {"w": "on", "b": [0.3514, 0.3959, 0.3734, 0.4173]}, {"w": "your", "b": [0.3782, 0.3959, 0.4172, 0.4173]}, {"w": "website,", "b": [0.4219, 0.3959, 0.4888, 0.4173]}, {"w": "and", "b": [0.4935, 0.3959, 0.5251, 0.4173]}, {"w": "so", "b": [0.5298, 0.3959, 0.5481, 0.4173]}, {"w": "on.", "b": [0.5528, 0.3959, 0.5796, 0.4173]}, {"w": "This", "b": [0.5843, 0.3959, 0.6215, 0.4173]}, {"w": "is", "b": [0.6262, 0.3959, 0.6394, 0.4173]}, {"w": "useful", "b": [0.6442, 0.3959, 0.6942, 0.4173]}, {"w": "to", "b": [0.699, 0.3959, 0.7159, 0.4173]}, {"w": "understand", "b": [0.7207, 0.3959, 0.8163, 0.4173]}, {"w": "who", "b": [0.821, 0.3959, 0.857, 0.4173]}, {"w": "your", "b": [0.1786, 0.415, 0.2176, 0.4364]}, {"w": "customers", "b": [0.2257, 0.415, 0.3115, 0.4364]}, {"w": "are", "b": [0.3196, 0.415, 0.3453, 0.4364]}, {"w": "and", "b": [0.3534, 0.415, 0.385, 0.4364]}, {"w": "what", "b": [0.3931, 0.415, 0.4336, 0.4364]}, {"w": "they", "b": [0.4417, 0.415, 0.4776, 0.4364]}, {"w": "need,", "b": [0.4857, 0.415, 0.5306, 0.4364]}, {"w": "so", "b": [0.5387, 0.415, 0.557, 0.4364]}, {"w": "you", "b": [0.5651, 0.415, 0.5964, 0.4364]}, {"w": "can", "b": [0.6045, 0.415, 0.6338, 0.4364]}, {"w": "adapt", "b": [0.6419, 0.415, 0.6881, 0.4364]}, {"w": "your", "b": [0.6962, 0.415, 0.7352, 0.4364]}, {"w": "products", "b": [0.7433, 0.415, 0.8175, 0.4364]}, {"w": "and", "b": [0.8256, 0.415, 0.8571, 0.4364]}, {"w": "marketing", "b": [0.1786, 0.434, 0.2648, 0.4554]}, {"w": "campaigns", "b": [0.2704, 0.434, 0.3595, 0.4554]}, {"w": "to", "b": [0.3652, 0.434, 0.3822, 0.4554]}, {"w": "each", "b": [0.3878, 0.434, 0.4258, 0.4554]}, {"w": "segment.", "b": [0.4315, 0.434, 0.5057, 0.4554]}, {"w": "For", "b": [0.5114, 0.434, 0.5404, 0.4554]}, {"w": "example,", "b": [0.5461, 0.434, 0.6203, 0.4554]}, {"w": "this", "b": [0.626, 0.434, 0.6567, 0.4554]}, {"w": "can", "b": [0.6624, 0.434, 0.6918, 0.4554]}, {"w": "be", "b": [0.6974, 0.434, 0.7169, 0.4554]}, {"w": "useful", "b": [0.7226, 0.434, 0.7726, 0.4554]}, {"w": "in", "b": [0.7783, 0.434, 0.7953, 0.4554]}, {"w": "recom‐", "b": [0.8009, 0.4338, 0.8571, 0.4554]}, {"w": "mender", "b": [0.1786, 0.4529, 0.2406, 0.4745]}, {"w": "systems", "b": [0.2453, 0.4529, 0.3061, 0.4745]}, {"w": "to", "b": [0.3109, 0.4531, 0.3278, 0.4745]}, {"w": "suggest", "b": [0.3326, 0.4531, 0.3936, 0.4745]}, {"w": "content", "b": [0.3984, 0.4531, 0.4614, 0.4745]}, {"w": "that", "b": [0.4661, 0.4531, 0.4987, 0.4745]}, {"w": "other", "b": [0.5034, 0.4531, 0.5481, 0.4745]}, {"w": "users", "b": [0.5528, 0.4531, 0.5958, 0.4745]}, {"w": "in", "b": [0.6005, 0.4531, 0.6175, 0.4745]}, {"w": "the", "b": [0.6222, 0.4531, 0.6485, 0.4745]}, {"w": "same", "b": [0.6533, 0.4531, 0.696, 0.4745]}, {"w": "cluster", "b": [0.7007, 0.4531, 0.7564, 0.4745]}, {"w": "enjoyed.", "b": [0.7612, 0.4531, 0.8311, 0.4745]}]}, {"id": "b_4", "type": "paragraph", "text": "• For data analysis: when analyzing a new dataset, it is often useful to first discover clusters of similar instances, as it is often easier to analyze clusters separately.", "words": [{"w": "•", "b": [0.16, 0.4782, 0.1682, 0.4996]}, {"w": "For", "b": [0.1786, 0.4782, 0.2075, 0.4996]}, {"w": "data", "b": [0.2128, 0.4782, 0.248, 0.4996]}, {"w": "analysis:", "b": [0.2532, 0.4782, 0.3234, 0.4996]}, {"w": "when", "b": [0.3286, 0.4782, 0.3742, 0.4996]}, {"w": "analyzing", "b": [0.3795, 0.4782, 0.4595, 0.4996]}, {"w": "a", "b": [0.4647, 0.4782, 0.4738, 0.4996]}, {"w": "new", "b": [0.479, 0.4782, 0.5136, 0.4996]}, {"w": "dataset,", "b": [0.5188, 0.4782, 0.5816, 0.4996]}, {"w": "it", "b": [0.5869, 0.4782, 0.5988, 0.4996]}, {"w": "is", "b": [0.604, 0.4782, 0.6172, 0.4996]}, {"w": "often", "b": [0.6225, 0.4782, 0.6658, 0.4996]}, {"w": "useful", "b": [0.6711, 0.4782, 0.7211, 0.4996]}, {"w": "to", "b": [0.7263, 0.4782, 0.7433, 0.4996]}, {"w": "first", "b": [0.7485, 0.4782, 0.782, 0.4996]}, {"w": "discover", "b": [0.7872, 0.4782, 0.8571, 0.4996]}, {"w": "clusters", "b": [0.1786, 0.4972, 0.2419, 0.5186]}, {"w": "of", "b": [0.2467, 0.4972, 0.2635, 0.5186]}, {"w": "similar", "b": [0.2682, 0.4972, 0.3262, 0.5186]}, {"w": "instances,", "b": [0.3309, 0.4972, 0.4125, 0.5186]}, {"w": "as", "b": [0.4173, 0.4972, 0.4341, 0.5186]}, {"w": "it", "b": [0.4388, 0.4972, 0.4507, 0.5186]}, {"w": "is", "b": [0.4554, 0.4972, 0.4687, 0.5186]}, {"w": "often", "b": [0.4734, 0.4972, 0.5168, 0.5186]}, {"w": "easier", "b": [0.5215, 0.4972, 0.5693, 0.5186]}, {"w": "to", "b": [0.5741, 0.4972, 0.5911, 0.5186]}, {"w": "analyze", "b": [0.5958, 0.4972, 0.6579, 0.5186]}, {"w": "clusters", "b": [0.6626, 0.4972, 0.726, 0.5186]}, {"w": "separately.", "b": [0.7307, 0.4972, 0.8171, 0.5186]}]}, {"id": "b_5", "type": "paragraph", "text": "• As a dimensionality reduction technique: once a dataset has been clustered, it is usually possible to measure each instance’s affinity with each cluster (affinity is any measure of how well an instance fits into a cluster). Each instance’s feature vector x can then be replaced with the vector of its cluster affinities. If there are k clusters, then this vector is k dimensional. This is typically much lower dimen‐ sional than the original feature vector, but it can preserve enough information for further processing.", "words": [{"w": "•", "b": [0.16, 0.5223, 0.1682, 0.5437]}, {"w": "As", "b": [0.1786, 0.5223, 0.2006, 0.5437]}, {"w": "a", "b": [0.2067, 0.5223, 0.2159, 0.5437]}, {"w": "dimensionality", "b": [0.222, 0.5223, 0.3471, 0.5437]}, {"w": "reduction", "b": [0.3532, 0.5223, 0.4346, 0.5437]}, {"w": "technique:", "b": [0.4407, 0.5223, 0.5281, 0.5437]}, {"w": "once", "b": [0.5343, 0.5223, 0.574, 0.5437]}, {"w": "a", "b": [0.5801, 0.5223, 0.5892, 0.5437]}, {"w": "dataset", "b": [0.5953, 0.5223, 0.6534, 0.5437]}, {"w": "has", "b": [0.6596, 0.5223, 0.6875, 0.5437]}, {"w": "been", "b": [0.6936, 0.5223, 0.7333, 0.5437]}, {"w": "clustered,", "b": [0.7394, 0.5223, 0.8197, 0.5437]}, {"w": "it", "b": [0.8259, 0.5223, 0.8378, 0.5437]}, {"w": "is", "b": [0.8439, 0.5223, 0.8571, 0.5437]}, {"w": "usually", "b": [0.1786, 0.5414, 0.2376, 0.5628]}, {"w": "possible", "b": [0.2447, 0.5414, 0.3118, 0.5628]}, {"w": "to", "b": [0.319, 0.5414, 0.336, 0.5628]}, {"w": "measure", "b": [0.3431, 0.5414, 0.4134, 0.5628]}, {"w": "each", "b": [0.4206, 0.5414, 0.4585, 0.5628]}, {"w": "instance’s", "b": [0.4656, 0.5414, 0.5439, 0.5628]}, {"w": "affinity", "b": [0.551, 0.5411, 0.6101, 0.5628]}, {"w": "with", "b": [0.6172, 0.5414, 0.6546, 0.5628]}, {"w": "each", "b": [0.6617, 0.5414, 0.6996, 0.5628]}, {"w": "cluster", "b": [0.7068, 0.5414, 0.7625, 0.5628]}, {"w": "(affinity", "b": [0.7696, 0.5414, 0.8368, 0.5628]}, {"w": "is", "b": [0.8439, 0.5414, 0.8571, 0.5628]}, {"w": "any", "b": [0.1786, 0.5604, 0.2082, 0.5818]}, {"w": "measure", "b": [0.2151, 0.5604, 0.2854, 0.5818]}, {"w": "of", "b": [0.2923, 0.5604, 0.3091, 0.5818]}, {"w": "how", "b": [0.3159, 0.5604, 0.352, 0.5818]}, {"w": "well", "b": [0.3588, 0.5604, 0.3925, 0.5818]}, {"w": "an", "b": [0.3994, 0.5604, 0.4199, 0.5818]}, {"w": "instance", "b": [0.4268, 0.5604, 0.4959, 0.5818]}, {"w": "fits", "b": [0.5028, 0.5604, 0.5286, 0.5818]}, {"w": "into", "b": [0.5354, 0.5604, 0.569, 0.5818]}, {"w": "a", "b": [0.5759, 0.5604, 0.585, 0.5818]}, {"w": "cluster).", "b": [0.5919, 0.5604, 0.6596, 0.5818]}, {"w": "Each", "b": [0.6664, 0.5604, 0.7073, 0.5818]}, {"w": "instance’s", "b": [0.7142, 0.5604, 0.7925, 0.5818]}, {"w": "feature", "b": [0.7994, 0.5604, 0.8571, 0.5818]}, {"w": "vector", "b": [0.1786, 0.5795, 0.2306, 0.6009]}, {"w": "x", "b": [0.2358, 0.5789, 0.2458, 0.6009]}, {"w": "can", "b": [0.251, 0.5795, 0.2803, 0.6009]}, {"w": "then", "b": [0.2855, 0.5795, 0.3232, 0.6009]}, {"w": "be", "b": [0.3284, 0.5795, 0.3478, 0.6009]}, {"w": "replaced", "b": [0.353, 0.5795, 0.4236, 0.6009]}, {"w": "with", "b": [0.4287, 0.5795, 0.4661, 0.6009]}, {"w": "the", "b": [0.4712, 0.5795, 0.4976, 0.6009]}, {"w": "vector", "b": [0.5027, 0.5795, 0.5548, 0.6009]}, {"w": "of", "b": [0.5599, 0.5795, 0.5767, 0.6009]}, {"w": "its", "b": [0.5819, 0.5795, 0.6015, 0.6009]}, {"w": "cluster", "b": [0.6066, 0.5795, 0.6624, 0.6009]}, {"w": "affinities.", "b": [0.6675, 0.5795, 0.7448, 0.6009]}, {"w": "If", "b": [0.7499, 0.5795, 0.7632, 0.6009]}, {"w": "there", "b": [0.7684, 0.5795, 0.8113, 0.6009]}, {"w": "are", "b": [0.8165, 0.5795, 0.8422, 0.6009]}, {"w": "k", "b": [0.8473, 0.5792, 0.8571, 0.6009]}, {"w": "clusters,", "b": [0.1786, 0.5985, 0.2467, 0.6199]}, {"w": "then", "b": [0.2535, 0.5985, 0.2913, 0.6199]}, {"w": "this", "b": [0.2981, 0.5985, 0.3288, 0.6199]}, {"w": "vector", "b": [0.3356, 0.5985, 0.3877, 0.6199]}, {"w": "is", "b": [0.3945, 0.5985, 0.4077, 0.6199]}, {"w": "k", "b": [0.4146, 0.5983, 0.4244, 0.6199]}, {"w": "dimensional.", "b": [0.4312, 0.5985, 0.5395, 0.6199]}, {"w": "This", "b": [0.5463, 0.5985, 0.5835, 0.6199]}, {"w": "is", "b": [0.5904, 0.5985, 0.6036, 0.6199]}, {"w": "typically", "b": [0.6104, 0.5985, 0.6809, 0.6199]}, {"w": "much", "b": [0.6878, 0.5985, 0.7354, 0.6199]}, {"w": "lower", "b": [0.7423, 0.5985, 0.789, 0.6199]}, {"w": "dimen‐", "b": [0.7958, 0.5985, 0.8571, 0.6199]}, {"w": "sional", "b": [0.1786, 0.6175, 0.2282, 0.639]}, {"w": "than", "b": [0.233, 0.6175, 0.271, 0.639]}, {"w": "the", "b": [0.2758, 0.6175, 0.3022, 0.639]}, {"w": "original", "b": [0.307, 0.6175, 0.372, 0.639]}, {"w": "feature", "b": [0.3768, 0.6175, 0.4346, 0.639]}, {"w": "vector,", "b": [0.4394, 0.6175, 0.4949, 0.639]}, {"w": "but", "b": [0.4997, 0.6175, 0.5277, 0.639]}, {"w": "it", "b": [0.5324, 0.6175, 0.5444, 0.639]}, {"w": "can", "b": [0.5492, 0.6175, 0.5785, 0.639]}, {"w": "preserve", "b": [0.5833, 0.6175, 0.6542, 0.639]}, {"w": "enough", "b": [0.6589, 0.6175, 0.7218, 0.639]}, {"w": "information", "b": [0.7266, 0.6175, 0.8278, 0.639]}, {"w": "for", "b": [0.8326, 0.6175, 0.8571, 0.639]}, {"w": "further", "b": [0.1786, 0.6366, 0.2376, 0.658]}, {"w": "processing.", "b": [0.2423, 0.6366, 0.336, 0.658]}]}, {"id": "b_6", "type": "paragraph", "text": "• For anomaly detection (also called outlier detection): any instance that has a low affinity to all the clusters is likely to be an anomaly. For example, if you have clus‐ tered the users of your website based on their behavior, you can detect users with unusual behavior, such as an unusual number of requests per second, and so on. Anomaly detection is particularly useful in detecting defects in manufacturing, or for fraud detection.", "words": [{"w": "•", "b": [0.16, 0.6617, 0.1681, 0.6831]}, {"w": "For", "b": [0.1786, 0.6617, 0.2075, 0.6831]}, {"w": "anomaly", "b": [0.2142, 0.6615, 0.2849, 0.6831]}, {"w": "detection", "b": [0.2916, 0.6615, 0.3652, 0.6831]}, {"w": "(also", "b": [0.3718, 0.6617, 0.4117, 0.6831]}, {"w": "called", "b": [0.4184, 0.6617, 0.4667, 0.6831]}, {"w": "outlier", "b": [0.4733, 0.6615, 0.5264, 0.6831]}, {"w": "detection):", "b": [0.5331, 0.6615, 0.6187, 0.6831]}, {"w": "any", "b": [0.6253, 0.6617, 0.6549, 0.6831]}, {"w": "instance", "b": [0.6616, 0.6617, 0.7308, 0.6831]}, {"w": "that", "b": [0.7374, 0.6617, 0.77, 0.6831]}, {"w": "has", "b": [0.7766, 0.6617, 0.8045, 0.6831]}, {"w": "a", "b": [0.8112, 0.6617, 0.8203, 0.6831]}, {"w": "low", "b": [0.827, 0.6617, 0.8571, 0.6831]}, {"w": "affinity", "b": [0.1786, 0.6807, 0.2385, 0.7021]}, {"w": "to", "b": [0.2433, 0.6807, 0.2603, 0.7021]}, {"w": "all", "b": [0.2651, 0.6807, 0.2848, 0.7021]}, {"w": "the", "b": [0.2896, 0.6807, 0.3159, 0.7021]}, {"w": "clusters", "b": [0.3207, 0.6807, 0.3841, 0.7021]}, {"w": "is", "b": [0.3889, 0.6807, 0.4022, 0.7021]}, {"w": "likely", "b": [0.407, 0.6807, 0.4518, 0.7021]}, {"w": "to", "b": [0.4566, 0.6807, 0.4736, 0.7021]}, {"w": "be", "b": [0.4784, 0.6807, 0.4979, 0.7021]}, {"w": "an", "b": [0.5027, 0.6807, 0.5232, 0.7021]}, {"w": "anomaly.", "b": [0.528, 0.6807, 0.6034, 0.7021]}, {"w": "For", "b": [0.6083, 0.6807, 0.6372, 0.7021]}, {"w": "example,", "b": [0.642, 0.6807, 0.7163, 0.7021]}, {"w": "if", "b": [0.7211, 0.6807, 0.7329, 0.7021]}, {"w": "you", "b": [0.7377, 0.6807, 0.7689, 0.7021]}, {"w": "have", "b": [0.7737, 0.6807, 0.8121, 0.7021]}, {"w": "clus‐", "b": [0.8169, 0.6807, 0.8571, 0.7021]}, {"w": "tered", "b": [0.1786, 0.6998, 0.2214, 0.7212]}, {"w": "the", "b": [0.2265, 0.6998, 0.2528, 0.7212]}, {"w": "users", "b": [0.258, 0.6998, 0.3009, 0.7212]}, {"w": "of", "b": [0.3061, 0.6998, 0.3229, 0.7212]}, {"w": "your", "b": [0.3281, 0.6998, 0.367, 0.7212]}, {"w": "website", "b": [0.3722, 0.6998, 0.4343, 0.7212]}, {"w": "based", "b": [0.4395, 0.6998, 0.4867, 0.7212]}, {"w": "on", "b": [0.4919, 0.6998, 0.5139, 0.7212]}, {"w": "their", "b": [0.5191, 0.6998, 0.5587, 0.7212]}, {"w": "behavior,", "b": [0.5639, 0.6998, 0.6402, 0.7212]}, {"w": "you", "b": [0.6454, 0.6998, 0.6766, 0.7212]}, {"w": "can", "b": [0.6818, 0.6998, 0.7112, 0.7212]}, {"w": "detect", "b": [0.7163, 0.6998, 0.7665, 0.7212]}, {"w": "users", "b": [0.7717, 0.6998, 0.8146, 0.7212]}, {"w": "with", "b": [0.8198, 0.6998, 0.8571, 0.7212]}, {"w": "unusual", "b": [0.1786, 0.7188, 0.2448, 0.7402]}, {"w": "behavior,", "b": [0.2506, 0.7188, 0.3269, 0.7402]}, {"w": "such", "b": [0.3327, 0.7188, 0.3713, 0.7402]}, {"w": "as", "b": [0.3771, 0.7188, 0.3939, 0.7402]}, {"w": "an", "b": [0.3996, 0.7188, 0.4201, 0.7402]}, {"w": "unusual", "b": [0.4259, 0.7188, 0.4921, 0.7402]}, {"w": "number", "b": [0.4979, 0.7188, 0.5642, 0.7402]}, {"w": "of", "b": [0.5699, 0.7188, 0.5867, 0.7402]}, {"w": "requests", "b": [0.5925, 0.7188, 0.6612, 0.7402]}, {"w": "per", "b": [0.667, 0.7188, 0.6945, 0.7402]}, {"w": "second,", "b": [0.7002, 0.7188, 0.7633, 0.7402]}, {"w": "and", "b": [0.7691, 0.7188, 0.8006, 0.7402]}, {"w": "so", "b": [0.8064, 0.7188, 0.8246, 0.7402]}, {"w": "on.", "b": [0.8304, 0.7188, 0.8571, 0.7402]}, {"w": "Anomaly", "b": [0.1786, 0.7379, 0.256, 0.7593]}, {"w": "detection", "b": [0.2608, 0.7379, 0.3386, 0.7593]}, {"w": "is", "b": [0.3433, 0.7379, 0.3566, 0.7593]}, {"w": "particularly", "b": [0.3613, 0.7379, 0.4579, 0.7593]}, {"w": "useful", "b": [0.4626, 0.7379, 0.5127, 0.7593]}, {"w": "in", "b": [0.5174, 0.7379, 0.5344, 0.7593]}, {"w": "detecting", "b": [0.5391, 0.7379, 0.6161, 0.7593]}, {"w": "defects", "b": [0.6208, 0.7379, 0.6785, 0.7593]}, {"w": "in", "b": [0.6832, 0.7379, 0.7002, 0.7593]}, {"w": "manufacturing,", "b": [0.7049, 0.7379, 0.8339, 0.7593]}, {"w": "or", "b": [0.8387, 0.7379, 0.857, 0.7593]}, {"w": "for", "b": [0.1786, 0.7569, 0.2031, 0.7783]}, {"w": "fraud", "b": [0.2078, 0.7567, 0.2524, 0.7783]}, {"w": "detection.", "b": [0.2571, 0.7567, 0.3355, 0.7783]}]}, {"id": "b_7", "type": "paragraph", "text": "• For semi-supervised learning: if you only have a few labels, you could perform clustering and propagate the labels to all the instances in the same cluster. This can greatly increase the amount of labels available for a subsequent supervised learning algorithm, and thus improve its performance.", "words": [{"w": "•", "b": [0.16, 0.782, 0.1681, 0.8034]}, {"w": "For", "b": [0.1786, 0.782, 0.2075, 0.8034]}, {"w": "semi-supervised", "b": [0.2146, 0.782, 0.3507, 0.8034]}, {"w": "learning:", "b": [0.3577, 0.782, 0.4316, 0.8034]}, {"w": "if", "b": [0.4386, 0.782, 0.4503, 0.8034]}, {"w": "you", "b": [0.4574, 0.782, 0.4886, 0.8034]}, {"w": "only", "b": [0.4956, 0.782, 0.5325, 0.8034]}, {"w": "have", "b": [0.5395, 0.782, 0.5779, 0.8034]}, {"w": "a", "b": [0.5849, 0.782, 0.5941, 0.8034]}, {"w": "few", "b": [0.6011, 0.782, 0.6304, 0.8034]}, {"w": "labels,", "b": [0.6374, 0.782, 0.689, 0.8034]}, {"w": "you", "b": [0.696, 0.782, 0.7272, 0.8034]}, {"w": "could", "b": [0.7343, 0.782, 0.781, 0.8034]}, {"w": "perform", "b": [0.7881, 0.782, 0.8571, 0.8034]}, {"w": "clustering", "b": [0.1786, 0.8011, 0.261, 0.8225]}, {"w": "and", "b": [0.2677, 0.8011, 0.2992, 0.8225]}, {"w": "propagate", "b": [0.3058, 0.8011, 0.3889, 0.8225]}, {"w": "the", "b": [0.3955, 0.8011, 0.4218, 0.8225]}, {"w": "labels", "b": [0.4285, 0.8011, 0.4752, 0.8225]}, {"w": "to", "b": [0.4819, 0.8011, 0.4989, 0.8225]}, {"w": "all", "b": [0.5055, 0.8011, 0.5252, 0.8225]}, {"w": "the", "b": [0.5318, 0.8011, 0.5581, 0.8225]}, {"w": "instances", "b": [0.5648, 0.8011, 0.6416, 0.8225]}, {"w": "in", "b": [0.6482, 0.8011, 0.6652, 0.8225]}, {"w": "the", "b": [0.6718, 0.8011, 0.6982, 0.8225]}, {"w": "same", "b": [0.7048, 0.8011, 0.7475, 0.8225]}, {"w": "cluster.", "b": [0.7541, 0.8011, 0.8133, 0.8225]}, {"w": "This", "b": [0.8199, 0.8011, 0.8571, 0.8225]}, {"w": "can", "b": [0.1786, 0.8201, 0.2079, 0.8415]}, {"w": "greatly", "b": [0.2152, 0.8201, 0.2715, 0.8415]}, {"w": "increase", "b": [0.2788, 0.8201, 0.3469, 0.8415]}, {"w": "the", "b": [0.3542, 0.8201, 0.3805, 0.8415]}, {"w": "amount", "b": [0.3878, 0.8201, 0.4531, 0.8415]}, {"w": "of", "b": [0.4604, 0.8201, 0.4772, 0.8415]}, {"w": "labels", "b": [0.4845, 0.8201, 0.5313, 0.8415]}, {"w": "available", "b": [0.5386, 0.8201, 0.6109, 0.8415]}, {"w": "for", "b": [0.6182, 0.8201, 0.6428, 0.8415]}, {"w": "a", "b": [0.6501, 0.8201, 0.6592, 0.8415]}, {"w": "subsequent", "b": [0.6666, 0.8201, 0.7603, 0.8415]}, {"w": "supervised", "b": [0.7676, 0.8201, 0.8571, 0.8415]}, {"w": "learning", "b": [0.1786, 0.8392, 0.2477, 0.8606]}, {"w": "algorithm,", "b": [0.2524, 0.8392, 0.3398, 0.8606]}, {"w": "and", "b": [0.3446, 0.8392, 0.3761, 0.8606]}, {"w": "thus", "b": [0.3808, 0.8392, 0.4166, 0.8606]}, {"w": "improve", "b": [0.4213, 0.8392, 0.4914, 0.8606]}, {"w": "its", "b": [0.4961, 0.8392, 0.5157, 0.8606]}, {"w": "performance.", "b": [0.5204, 0.8392, 0.6324, 0.8606]}]}, {"id": "b_8", "type": "paragraph", "text": "Clustering | 239", "words": [{"w": "Clustering", "b": [0.736, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "239", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 266, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 “Least square quantization in PCM,” Stuart P. Lloyd. (1982).", "words": [{"w": "1", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Least", "b": [0.1587, 0.8749, 0.198, 0.8912]}, {"w": "square", "b": [0.2016, 0.8749, 0.2435, 0.8912]}, {"w": "quantization", "b": [0.2471, 0.8749, 0.3273, 0.8912]}, {"w": "in", "b": [0.3309, 0.8749, 0.3439, 0.8912]}, {"w": "PCM,”", "b": [0.3475, 0.8749, 0.3889, 0.8912]}, {"w": "Stuart", "b": [0.3925, 0.8749, 0.431, 0.8912]}, {"w": "P.", "b": [0.4346, 0.8749, 0.445, 0.8912]}, {"w": "Lloyd.", "b": [0.4486, 0.8749, 0.4885, 0.8912]}, {"w": "(1982).", "b": [0.4921, 0.8749, 0.5372, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "• For search engines: for example, some search engines let you search for images that are similar to a reference image. To build such a system, you would first apply a clustering algorithm to all the images in your database: similar images would end up in the same cluster. Then when a user provides a reference image, all you need to do is to find this image’s cluster using the trained clustering model, and you can then simply return all the images from this cluster.", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "For", "b": [0.1786, 0.0791, 0.2075, 0.1005]}, {"w": "search", "b": [0.2143, 0.0791, 0.2676, 0.1005]}, {"w": "engines:", "b": [0.2743, 0.0791, 0.3425, 0.1005]}, {"w": "for", "b": [0.3493, 0.0791, 0.3738, 0.1005]}, {"w": "example,", "b": [0.3805, 0.0791, 0.4548, 0.1005]}, {"w": "some", "b": [0.4615, 0.0791, 0.5057, 0.1005]}, {"w": "search", "b": [0.5124, 0.0791, 0.5657, 0.1005]}, {"w": "engines", "b": [0.5724, 0.0791, 0.6359, 0.1005]}, {"w": "let", "b": [0.6426, 0.0791, 0.6631, 0.1005]}, {"w": "you", "b": [0.6698, 0.0791, 0.7011, 0.1005]}, {"w": "search", "b": [0.7078, 0.0791, 0.7611, 0.1005]}, {"w": "for", "b": [0.7679, 0.0791, 0.7924, 0.1005]}, {"w": "images", "b": [0.7991, 0.0791, 0.8571, 0.1005]}, {"w": "that", "b": [0.1786, 0.0981, 0.2112, 0.1195]}, {"w": "are", "b": [0.2192, 0.0981, 0.2449, 0.1195]}, {"w": "similar", "b": [0.2529, 0.0981, 0.3109, 0.1195]}, {"w": "to", "b": [0.3189, 0.0981, 0.3359, 0.1195]}, {"w": "a", "b": [0.3439, 0.0981, 0.3531, 0.1195]}, {"w": "reference", "b": [0.3611, 0.0981, 0.4383, 0.1195]}, {"w": "image.", "b": [0.4463, 0.0981, 0.5015, 0.1195]}, {"w": "To", "b": [0.5095, 0.0981, 0.5309, 0.1195]}, {"w": "build", "b": [0.539, 0.0981, 0.5825, 0.1195]}, {"w": "such", "b": [0.5905, 0.0981, 0.6291, 0.1195]}, {"w": "a", "b": [0.6371, 0.0981, 0.6463, 0.1195]}, {"w": "system,", "b": [0.6543, 0.0981, 0.7162, 0.1195]}, {"w": "you", "b": [0.7242, 0.0981, 0.7554, 0.1195]}, {"w": "would", "b": [0.7634, 0.0981, 0.8157, 0.1195]}, {"w": "first", "b": [0.8237, 0.0981, 0.8571, 0.1195]}, {"w": "apply", "b": [0.1786, 0.1172, 0.224, 0.1386]}, {"w": "a", "b": [0.2314, 0.1172, 0.2406, 0.1386]}, {"w": "clustering", "b": [0.2481, 0.1172, 0.3305, 0.1386]}, {"w": "algorithm", "b": [0.338, 0.1172, 0.4206, 0.1386]}, {"w": "to", "b": [0.4281, 0.1172, 0.4451, 0.1386]}, {"w": "all", "b": [0.4525, 0.1172, 0.4722, 0.1386]}, {"w": "the", "b": [0.4797, 0.1172, 0.506, 0.1386]}, {"w": "images", "b": [0.5135, 0.1172, 0.5715, 0.1386]}, {"w": "in", "b": [0.579, 0.1172, 0.596, 0.1386]}, {"w": "your", "b": [0.6035, 0.1172, 0.6424, 0.1386]}, {"w": "database:", "b": [0.6499, 0.1172, 0.7261, 0.1386]}, {"w": "similar", "b": [0.7336, 0.1172, 0.7916, 0.1386]}, {"w": "images", "b": [0.7991, 0.1172, 0.8571, 0.1386]}, {"w": "would", "b": [0.1786, 0.1362, 0.2308, 0.1576]}, {"w": "end", "b": [0.2365, 0.1362, 0.2678, 0.1576]}, {"w": "up", "b": [0.2735, 0.1362, 0.2955, 0.1576]}, {"w": "in", "b": [0.3012, 0.1362, 0.3182, 0.1576]}, {"w": "the", "b": [0.3239, 0.1362, 0.3502, 0.1576]}, {"w": "same", "b": [0.3559, 0.1362, 0.3986, 0.1576]}, {"w": "cluster.", "b": [0.4044, 0.1362, 0.4635, 0.1576]}, {"w": "Then", "b": [0.4693, 0.1362, 0.5135, 0.1576]}, {"w": "when", "b": [0.5192, 0.1362, 0.5648, 0.1576]}, {"w": "a", "b": [0.5706, 0.1362, 0.5797, 0.1576]}, {"w": "user", "b": [0.5854, 0.1362, 0.6207, 0.1576]}, {"w": "provides", "b": [0.6264, 0.1362, 0.6984, 0.1576]}, {"w": "a", "b": [0.7042, 0.1362, 0.7133, 0.1576]}, {"w": "reference", "b": [0.719, 0.1362, 0.7963, 0.1576]}, {"w": "image,", "b": [0.802, 0.1362, 0.8571, 0.1576]}, {"w": "all", "b": [0.1786, 0.1553, 0.1983, 0.1767]}, {"w": "you", "b": [0.2071, 0.1553, 0.2384, 0.1767]}, {"w": "need", "b": [0.2473, 0.1553, 0.2874, 0.1767]}, {"w": "to", "b": [0.2963, 0.1553, 0.3132, 0.1767]}, {"w": "do", "b": [0.3221, 0.1553, 0.3438, 0.1767]}, {"w": "is", "b": [0.3526, 0.1553, 0.3659, 0.1767]}, {"w": "to", "b": [0.3747, 0.1553, 0.3917, 0.1767]}, {"w": "find", "b": [0.4006, 0.1553, 0.4348, 0.1767]}, {"w": "this", "b": [0.4436, 0.1553, 0.4743, 0.1767]}, {"w": "image’s", "b": [0.4832, 0.1553, 0.5427, 0.1767]}, {"w": "cluster", "b": [0.5516, 0.1553, 0.6073, 0.1767]}, {"w": "using", "b": [0.6162, 0.1553, 0.6617, 0.1767]}, {"w": "the", "b": [0.6705, 0.1553, 0.6969, 0.1767]}, {"w": "trained", "b": [0.7057, 0.1553, 0.7658, 0.1767]}, {"w": "clustering", "b": [0.7747, 0.1553, 0.8572, 0.1767]}, {"w": "model,", "b": [0.1786, 0.1743, 0.2361, 0.1957]}, {"w": "and", "b": [0.2409, 0.1743, 0.2724, 0.1957]}, {"w": "you", "b": [0.2771, 0.1743, 0.3084, 0.1957]}, {"w": "can", "b": [0.3131, 0.1743, 0.3425, 0.1957]}, {"w": "then", "b": [0.3472, 0.1743, 0.3849, 0.1957]}, {"w": "simply", "b": [0.3897, 0.1743, 0.4453, 0.1957]}, {"w": "return", "b": [0.45, 0.1743, 0.5032, 0.1957]}, {"w": "all", "b": [0.5079, 0.1743, 0.5276, 0.1957]}, {"w": "the", "b": [0.5323, 0.1743, 0.5586, 0.1957]}, {"w": "images", "b": [0.5634, 0.1743, 0.6214, 0.1957]}, {"w": "from", "b": [0.6261, 0.1743, 0.6677, 0.1957]}, {"w": "this", "b": [0.6724, 0.1743, 0.7032, 0.1957]}, {"w": "cluster.", "b": [0.7079, 0.1743, 0.767, 0.1957]}]}, {"id": "b_2", "type": "paragraph", "text": "• To segment an image: by clustering pixels according to their color, then replacing each pixel’s color with the mean color of its cluster, it is possible to reduce the number of different colors in the image considerably. This technique is used in many object detection and tracking systems, as it makes it easier to detect the contour of each object.", "words": [{"w": "•", "b": [0.16, 0.1994, 0.1682, 0.2208]}, {"w": "To", "b": [0.1786, 0.1994, 0.2, 0.2208]}, {"w": "segment", "b": [0.205, 0.1994, 0.2745, 0.2208]}, {"w": "an", "b": [0.2795, 0.1994, 0.3001, 0.2208]}, {"w": "image:", "b": [0.3051, 0.1994, 0.3602, 0.2208]}, {"w": "by", "b": [0.3652, 0.1994, 0.3854, 0.2208]}, {"w": "clustering", "b": [0.3904, 0.1994, 0.4728, 0.2208]}, {"w": "pixels", "b": [0.4778, 0.1994, 0.5259, 0.2208]}, {"w": "according", "b": [0.5309, 0.1994, 0.6138, 0.2208]}, {"w": "to", "b": [0.6188, 0.1994, 0.6358, 0.2208]}, {"w": "their", "b": [0.6408, 0.1994, 0.6804, 0.2208]}, {"w": "color,", "b": [0.6854, 0.1994, 0.7319, 0.2208]}, {"w": "then", "b": [0.7369, 0.1994, 0.7747, 0.2208]}, {"w": "replacing", "b": [0.7797, 0.1994, 0.8571, 0.2208]}, {"w": "each", "b": [0.1786, 0.2184, 0.2165, 0.2399]}, {"w": "pixel’s", "b": [0.2236, 0.2184, 0.2739, 0.2399]}, {"w": "color", "b": [0.281, 0.2184, 0.324, 0.2399]}, {"w": "with", "b": [0.3311, 0.2184, 0.3685, 0.2399]}, {"w": "the", "b": [0.3756, 0.2184, 0.4019, 0.2399]}, {"w": "mean", "b": [0.409, 0.2184, 0.4555, 0.2399]}, {"w": "color", "b": [0.4626, 0.2184, 0.5057, 0.2399]}, {"w": "of", "b": [0.5128, 0.2184, 0.5296, 0.2399]}, {"w": "its", "b": [0.5367, 0.2184, 0.5563, 0.2399]}, {"w": "cluster,", "b": [0.5634, 0.2184, 0.6226, 0.2399]}, {"w": "it", "b": [0.6297, 0.2184, 0.6416, 0.2399]}, {"w": "is", "b": [0.6487, 0.2184, 0.6619, 0.2399]}, {"w": "possible", "b": [0.6691, 0.2184, 0.7362, 0.2399]}, {"w": "to", "b": [0.7433, 0.2184, 0.7603, 0.2399]}, {"w": "reduce", "b": [0.7674, 0.2184, 0.8237, 0.2399]}, {"w": "the", "b": [0.8308, 0.2184, 0.8571, 0.2399]}, {"w": "number", "b": [0.1786, 0.2375, 0.2449, 0.2589]}, {"w": "of", "b": [0.2516, 0.2375, 0.2684, 0.2589]}, {"w": "different", "b": [0.2752, 0.2375, 0.3469, 0.2589]}, {"w": "colors", "b": [0.3537, 0.2375, 0.4044, 0.2589]}, {"w": "in", "b": [0.4111, 0.2375, 0.4281, 0.2589]}, {"w": "the", "b": [0.4349, 0.2375, 0.4612, 0.2589]}, {"w": "image", "b": [0.468, 0.2375, 0.5184, 0.2589]}, {"w": "considerably.", "b": [0.5252, 0.2375, 0.6346, 0.2589]}, {"w": "This", "b": [0.6414, 0.2375, 0.6786, 0.2589]}, {"w": "technique", "b": [0.6854, 0.2375, 0.768, 0.2589]}, {"w": "is", "b": [0.7748, 0.2375, 0.788, 0.2589]}, {"w": "used", "b": [0.7948, 0.2375, 0.8334, 0.2589]}, {"w": "in", "b": [0.8402, 0.2375, 0.8571, 0.2589]}, {"w": "many", "b": [0.1786, 0.2565, 0.2253, 0.2779]}, {"w": "object", "b": [0.2328, 0.2565, 0.2834, 0.2779]}, {"w": "detection", "b": [0.2909, 0.2565, 0.3688, 0.2779]}, {"w": "and", "b": [0.3763, 0.2565, 0.4079, 0.2779]}, {"w": "tracking", "b": [0.4154, 0.2565, 0.4845, 0.2779]}, {"w": "systems,", "b": [0.4921, 0.2565, 0.5616, 0.2779]}, {"w": "as", "b": [0.5692, 0.2565, 0.586, 0.2779]}, {"w": "it", "b": [0.5935, 0.2565, 0.6055, 0.2779]}, {"w": "makes", "b": [0.613, 0.2565, 0.6661, 0.2779]}, {"w": "it", "b": [0.6736, 0.2565, 0.6856, 0.2779]}, {"w": "easier", "b": [0.6931, 0.2565, 0.7409, 0.2779]}, {"w": "to", "b": [0.7485, 0.2565, 0.7655, 0.2779]}, {"w": "detect", "b": [0.773, 0.2565, 0.8233, 0.2779]}, {"w": "the", "b": [0.8308, 0.2565, 0.8571, 0.2779]}, {"w": "contour", "b": [0.1786, 0.2756, 0.2448, 0.297]}, {"w": "of", "b": [0.2495, 0.2756, 0.2663, 0.297]}, {"w": "each", "b": [0.271, 0.2756, 0.309, 0.297]}, {"w": "object.", "b": [0.3137, 0.2756, 0.369, 0.297]}]}, {"id": "b_3", "type": "paragraph", "text": "There is no universal definition of what a cluster is: it really depends on the context, and different algorithms will capture different kinds of clusters. For example, some algorithms look for instances centered around a particular point, called a centroid. Others look for continuous regions of densely packed instances: these clusters can take on any shape. Some algorithms are hierarchical, looking for clusters of clusters. And the list goes on.", "words": [{"w": "There", "b": [0.1429, 0.3097, 0.1923, 0.3312]}, {"w": "is", "b": [0.1981, 0.3097, 0.2114, 0.3312]}, {"w": "no", "b": [0.2173, 0.3097, 0.2393, 0.3312]}, {"w": "universal", "b": [0.2452, 0.3097, 0.3215, 0.3312]}, {"w": "definition", "b": [0.3274, 0.3097, 0.4099, 0.3312]}, {"w": "of", "b": [0.4158, 0.3097, 0.4326, 0.3312]}, {"w": "what", "b": [0.4385, 0.3097, 0.479, 0.3312]}, {"w": "a", "b": [0.4849, 0.3097, 0.494, 0.3312]}, {"w": "cluster", "b": [0.4999, 0.3097, 0.5556, 0.3312]}, {"w": "is:", "b": [0.5615, 0.3097, 0.5795, 0.3312]}, {"w": "it", "b": [0.5854, 0.3097, 0.5973, 0.3312]}, {"w": "really", "b": [0.6032, 0.3097, 0.649, 0.3312]}, {"w": "depends", "b": [0.6549, 0.3097, 0.7246, 0.3312]}, {"w": "on", "b": [0.7304, 0.3097, 0.7525, 0.3312]}, {"w": "the", "b": [0.7583, 0.3097, 0.7847, 0.3312]}, {"w": "context,", "b": [0.7906, 0.3097, 0.8571, 0.3312]}, {"w": "and", "b": [0.1429, 0.3288, 0.1744, 0.3502]}, {"w": "different", "b": [0.1815, 0.3288, 0.2532, 0.3502]}, {"w": "algorithms", "b": [0.2603, 0.3288, 0.3506, 0.3502]}, {"w": "will", "b": [0.3576, 0.3288, 0.388, 0.3502]}, {"w": "capture", "b": [0.3951, 0.3288, 0.4576, 0.3502]}, {"w": "different", "b": [0.4647, 0.3288, 0.5364, 0.3502]}, {"w": "kinds", "b": [0.5434, 0.3288, 0.5894, 0.3502]}, {"w": "of", "b": [0.5965, 0.3288, 0.6133, 0.3502]}, {"w": "clusters.", "b": [0.6203, 0.3288, 0.6885, 0.3502]}, {"w": "For", "b": [0.6955, 0.3288, 0.7245, 0.3502]}, {"w": "example,", "b": [0.7316, 0.3288, 0.8059, 0.3502]}, {"w": "some", "b": [0.813, 0.3288, 0.8572, 0.3502]}, {"w": "algorithms", "b": [0.1429, 0.3478, 0.2332, 0.3693]}, {"w": "look", "b": [0.2409, 0.3478, 0.2777, 0.3693]}, {"w": "for", "b": [0.2855, 0.3478, 0.31, 0.3693]}, {"w": "instances", "b": [0.3177, 0.3478, 0.3945, 0.3693]}, {"w": "centered", "b": [0.4023, 0.3478, 0.4737, 0.3693]}, {"w": "around", "b": [0.4815, 0.3478, 0.5424, 0.3693]}, {"w": "a", "b": [0.5501, 0.3478, 0.5593, 0.3693]}, {"w": "particular", "b": [0.567, 0.3478, 0.6488, 0.3693]}, {"w": "point,", "b": [0.6565, 0.3478, 0.7057, 0.3693]}, {"w": "called", "b": [0.7135, 0.3478, 0.7618, 0.3693]}, {"w": "a", "b": [0.7695, 0.3478, 0.7787, 0.3693]}, {"w": "centroid.", "b": [0.7864, 0.3476, 0.8571, 0.3693]}, {"w": "Others", "b": [0.1429, 0.3669, 0.2001, 0.3883]}, {"w": "look", "b": [0.2078, 0.3669, 0.2447, 0.3883]}, {"w": "for", "b": [0.2524, 0.3669, 0.2769, 0.3883]}, {"w": "continuous", "b": [0.2846, 0.3669, 0.3784, 0.3883]}, {"w": "regions", "b": [0.3861, 0.3669, 0.4477, 0.3883]}, {"w": "of", "b": [0.4554, 0.3669, 0.4721, 0.3883]}, {"w": "densely", "b": [0.4798, 0.3669, 0.5424, 0.3883]}, {"w": "packed", "b": [0.5501, 0.3669, 0.6092, 0.3883]}, {"w": "instances:", "b": [0.6169, 0.3669, 0.6985, 0.3883]}, {"w": "these", "b": [0.7062, 0.3669, 0.749, 0.3883]}, {"w": "clusters", "b": [0.7567, 0.3669, 0.8201, 0.3883]}, {"w": "can", "b": [0.8278, 0.3669, 0.8571, 0.3883]}, {"w": "take", "b": [0.1428, 0.3859, 0.1775, 0.4074]}, {"w": "on", "b": [0.1837, 0.3859, 0.2057, 0.4074]}, {"w": "any", "b": [0.2118, 0.3859, 0.2414, 0.4074]}, {"w": "shape.", "b": [0.2475, 0.3859, 0.2996, 0.4074]}, {"w": "Some", "b": [0.3057, 0.3859, 0.3521, 0.4074]}, {"w": "algorithms", "b": [0.3582, 0.3859, 0.4485, 0.4074]}, {"w": "are", "b": [0.4546, 0.3859, 0.4804, 0.4074]}, {"w": "hierarchical,", "b": [0.4865, 0.3859, 0.5901, 0.4074]}, {"w": "looking", "b": [0.5963, 0.3859, 0.6599, 0.4074]}, {"w": "for", "b": [0.666, 0.3859, 0.6905, 0.4074]}, {"w": "clusters", "b": [0.6966, 0.3859, 0.76, 0.4074]}, {"w": "of", "b": [0.7661, 0.3859, 0.7829, 0.4074]}, {"w": "clusters.", "b": [0.789, 0.3859, 0.8571, 0.4074]}, {"w": "And", "b": [0.1429, 0.405, 0.1797, 0.4264]}, {"w": "the", "b": [0.1844, 0.405, 0.2107, 0.4264]}, {"w": "list", "b": [0.2154, 0.405, 0.2403, 0.4264]}, {"w": "goes", "b": [0.245, 0.405, 0.2819, 0.4264]}, {"w": "on.", "b": [0.2866, 0.405, 0.3134, 0.4264]}]}, {"id": "b_4", "type": "paragraph", "text": "In this section, we will look at two popular clustering algorithms: K-Means and DBSCAN, and we will show some of their applications, such as non-linear dimen‐ sionality reduction, semi-supervised learning and anomaly detection.", "words": [{"w": "In", "b": [0.1429, 0.4331, 0.1614, 0.4545]}, {"w": "this", "b": [0.1708, 0.4331, 0.2015, 0.4545]}, {"w": "section,", "b": [0.2109, 0.4331, 0.2749, 0.4545]}, {"w": "we", "b": [0.2844, 0.4331, 0.3075, 0.4545]}, {"w": "will", "b": [0.3169, 0.4331, 0.3473, 0.4545]}, {"w": "look", "b": [0.3567, 0.4331, 0.3936, 0.4545]}, {"w": "at", "b": [0.403, 0.4331, 0.4181, 0.4545]}, {"w": "two", "b": [0.4276, 0.4331, 0.4588, 0.4545]}, {"w": "popular", "b": [0.4682, 0.4331, 0.5339, 0.4545]}, {"w": "clustering", "b": [0.5433, 0.4331, 0.6258, 0.4545]}, {"w": "algorithms:", "b": [0.6352, 0.4331, 0.7303, 0.4545]}, {"w": "K-Means", "b": [0.7397, 0.4331, 0.8162, 0.4545]}, {"w": "and", "b": [0.8256, 0.4331, 0.8571, 0.4545]}, {"w": "DBSCAN,", "b": [0.1429, 0.4522, 0.2288, 0.4736]}, {"w": "and", "b": [0.2361, 0.4522, 0.2677, 0.4736]}, {"w": "we", "b": [0.275, 0.4522, 0.2981, 0.4736]}, {"w": "will", "b": [0.3055, 0.4522, 0.3359, 0.4736]}, {"w": "show", "b": [0.3432, 0.4522, 0.3869, 0.4736]}, {"w": "some", "b": [0.3942, 0.4522, 0.4384, 0.4736]}, {"w": "of", "b": [0.4457, 0.4522, 0.4625, 0.4736]}, {"w": "their", "b": [0.4699, 0.4522, 0.5095, 0.4736]}, {"w": "applications,", "b": [0.5169, 0.4522, 0.6222, 0.4736]}, {"w": "such", "b": [0.6296, 0.4522, 0.6682, 0.4736]}, {"w": "as", "b": [0.6755, 0.4522, 0.6923, 0.4736]}, {"w": "non-linear", "b": [0.6997, 0.4522, 0.7885, 0.4736]}, {"w": "dimen‐", "b": [0.7958, 0.4522, 0.8571, 0.4736]}, {"w": "sionality", "b": [0.1429, 0.4712, 0.214, 0.4926]}, {"w": "reduction,", "b": [0.2187, 0.4712, 0.3049, 0.4926]}, {"w": "semi-supervised", "b": [0.3096, 0.4712, 0.4457, 0.4926]}, {"w": "learning", "b": [0.4505, 0.4712, 0.5196, 0.4926]}, {"w": "and", "b": [0.5243, 0.4712, 0.5559, 0.4926]}, {"w": "anomaly", "b": [0.5606, 0.4712, 0.6328, 0.4926]}, {"w": "detection.", "b": [0.6375, 0.4712, 0.7201, 0.4926]}]}, {"id": "b_5", "type": "equation", "text": "K-Means", "words": [{"w": "K-Means", "b": [0.1429, 0.5054, 0.2322, 0.5339]}]}, {"id": "b_6", "type": "paragraph", "text": "Consider the unlabeled dataset represented in Figure 9-2: you can clearly see 5 blobs of instances. The K-Means algorithm is a simple algorithm capable of clustering this kind of dataset very quickly and efficiently, often in just a few iterations. It was pro‐ posed by Stuart Lloyd at the Bell Labs in 1957 as a technique for pulse-code modula‐ tion, but it was only published outside of the company in 1982, in a paper titled “Least square quantization in PCM”.1 By then, in 1965, Edward W. Forgy had pub‐ lished virtually the same algorithm, so K-Means is sometimes referred to as Lloyd- Forgy.", "words": [{"w": "Consider", "b": [0.1428, 0.5398, 0.2195, 0.5613]}, {"w": "the", "b": [0.2253, 0.5398, 0.2517, 0.5613]}, {"w": "unlabeled", "b": [0.2575, 0.5398, 0.3389, 0.5613]}, {"w": "dataset", "b": [0.3447, 0.5398, 0.4028, 0.5613]}, {"w": "represented", "b": [0.4086, 0.5398, 0.5064, 0.5613]}, {"w": "in", "b": [0.5122, 0.5398, 0.5292, 0.5613]}, {"w": "Figure", "b": [0.535, 0.5398, 0.589, 0.5613]}, {"w": "9-2:", "b": [0.5948, 0.5398, 0.627, 0.5613]}, {"w": "you", "b": [0.6328, 0.5398, 0.664, 0.5613]}, {"w": "can", "b": [0.6698, 0.5398, 0.6992, 0.5613]}, {"w": "clearly", "b": [0.705, 0.5398, 0.7597, 0.5613]}, {"w": "see", "b": [0.7655, 0.5398, 0.7908, 0.5613]}, {"w": "5", "b": [0.7966, 0.5398, 0.8066, 0.5613]}, {"w": "blobs", "b": [0.8124, 0.5398, 0.8571, 0.5613]}, {"w": "of", "b": [0.1429, 0.5589, 0.1597, 0.5803]}, {"w": "instances.", "b": [0.1656, 0.5589, 0.2472, 0.5803]}, {"w": "The", "b": [0.2532, 0.5589, 0.286, 0.5803]}, {"w": "K-Means", "b": [0.292, 0.5589, 0.3685, 0.5803]}, {"w": "algorithm", "b": [0.3745, 0.5589, 0.4571, 0.5803]}, {"w": "is", "b": [0.4631, 0.5589, 0.4763, 0.5803]}, {"w": "a", "b": [0.4823, 0.5589, 0.4914, 0.5803]}, {"w": "simple", "b": [0.4974, 0.5589, 0.5523, 0.5803]}, {"w": "algorithm", "b": [0.5583, 0.5589, 0.641, 0.5803]}, {"w": "capable", "b": [0.6469, 0.5589, 0.7093, 0.5803]}, {"w": "of", "b": [0.7152, 0.5589, 0.732, 0.5803]}, {"w": "clustering", "b": [0.738, 0.5589, 0.8205, 0.5803]}, {"w": "this", "b": [0.8264, 0.5589, 0.8571, 0.5803]}, {"w": "kind", "b": [0.1429, 0.5779, 0.1812, 0.5994]}, {"w": "of", "b": [0.1874, 0.5779, 0.2042, 0.5994]}, {"w": "dataset", "b": [0.2104, 0.5779, 0.2685, 0.5994]}, {"w": "very", "b": [0.2747, 0.5779, 0.3111, 0.5994]}, {"w": "quickly", "b": [0.3173, 0.5779, 0.3786, 0.5994]}, {"w": "and", "b": [0.3848, 0.5779, 0.4163, 0.5994]}, {"w": "efficiently,", "b": [0.4226, 0.5779, 0.508, 0.5994]}, {"w": "often", "b": [0.5142, 0.5779, 0.5576, 0.5994]}, {"w": "in", "b": [0.5638, 0.5779, 0.5808, 0.5994]}, {"w": "just", "b": [0.587, 0.5779, 0.6174, 0.5994]}, {"w": "a", "b": [0.6236, 0.5779, 0.6328, 0.5994]}, {"w": "few", "b": [0.639, 0.5779, 0.6683, 0.5994]}, {"w": "iterations.", "b": [0.6745, 0.5779, 0.7581, 0.5994]}, {"w": "It", "b": [0.7643, 0.5779, 0.777, 0.5994]}, {"w": "was", "b": [0.7832, 0.5779, 0.8142, 0.5994]}, {"w": "pro‐", "b": [0.8205, 0.5779, 0.8571, 0.5994]}, {"w": "posed", "b": [0.1428, 0.597, 0.1919, 0.6184]}, {"w": "by", "b": [0.1974, 0.597, 0.2175, 0.6184]}, {"w": "Stuart", "b": [0.2231, 0.597, 0.2736, 0.6184]}, {"w": "Lloyd", "b": [0.2791, 0.597, 0.3268, 0.6184]}, {"w": "at", "b": [0.3323, 0.597, 0.3474, 0.6184]}, {"w": "the", "b": [0.3529, 0.597, 0.3792, 0.6184]}, {"w": "Bell", "b": [0.3847, 0.597, 0.4168, 0.6184]}, {"w": "Labs", "b": [0.4223, 0.597, 0.4609, 0.6184]}, {"w": "in", "b": [0.4664, 0.597, 0.4834, 0.6184]}, {"w": "1957", "b": [0.4889, 0.597, 0.5289, 0.6184]}, {"w": "as", "b": [0.5344, 0.597, 0.5512, 0.6184]}, {"w": "a", "b": [0.5567, 0.597, 0.5658, 0.6184]}, {"w": "technique", "b": [0.5714, 0.597, 0.654, 0.6184]}, {"w": "for", "b": [0.6596, 0.597, 0.6841, 0.6184]}, {"w": "pulse-code", "b": [0.6896, 0.597, 0.78, 0.6184]}, {"w": "modula‐", "b": [0.7856, 0.597, 0.8571, 0.6184]}, {"w": "tion,", "b": [0.1429, 0.616, 0.1816, 0.6374]}, {"w": "but", "b": [0.19, 0.616, 0.218, 0.6374]}, {"w": "it", "b": [0.2264, 0.616, 0.2384, 0.6374]}, {"w": "was", "b": [0.2468, 0.616, 0.2778, 0.6374]}, {"w": "only", "b": [0.2863, 0.616, 0.3231, 0.6374]}, {"w": "published", "b": [0.3315, 0.616, 0.4136, 0.6374]}, {"w": "outside", "b": [0.422, 0.616, 0.4831, 0.6374]}, {"w": "of", "b": [0.4916, 0.616, 0.5083, 0.6374]}, {"w": "the", "b": [0.5168, 0.616, 0.5431, 0.6374]}, {"w": "company", "b": [0.5515, 0.616, 0.6282, 0.6374]}, {"w": "in", "b": [0.6366, 0.616, 0.6536, 0.6374]}, {"w": "1982,", "b": [0.662, 0.616, 0.7067, 0.6374]}, {"w": "in", "b": [0.7152, 0.616, 0.7322, 0.6374]}, {"w": "a", "b": [0.7406, 0.616, 0.7497, 0.6374]}, {"w": "paper", "b": [0.7581, 0.616, 0.8053, 0.6374]}, {"w": "titled", "b": [0.8137, 0.616, 0.8571, 0.6374]}, {"w": "“Least", "b": [0.1429, 0.6351, 0.1944, 0.6565]}, {"w": "square", "b": [0.2013, 0.6351, 0.2564, 0.6565]}, {"w": "quantization", "b": [0.2633, 0.6351, 0.3685, 0.6565]}, {"w": "in", "b": [0.3754, 0.6351, 0.3924, 0.6565]}, {"w": "PCM”.1", "b": [0.3993, 0.6351, 0.4619, 0.6565]}, {"w": "By", "b": [0.4688, 0.6351, 0.4906, 0.6565]}, {"w": "then,", "b": [0.4975, 0.6351, 0.54, 0.6565]}, {"w": "in", "b": [0.5469, 0.6351, 0.5639, 0.6565]}, {"w": "1965,", "b": [0.5708, 0.6351, 0.6156, 0.6565]}, {"w": "Edward", "b": [0.6225, 0.6351, 0.6875, 0.6565]}, {"w": "W.", "b": [0.6944, 0.6351, 0.7164, 0.6565]}, {"w": "Forgy", "b": [0.7233, 0.6351, 0.7721, 0.6565]}, {"w": "had", "b": [0.779, 0.6351, 0.8103, 0.6565]}, {"w": "pub‐", "b": [0.8172, 0.6351, 0.8571, 0.6565]}, {"w": "lished", "b": [0.1429, 0.6541, 0.1923, 0.6755]}, {"w": "virtually", "b": [0.1994, 0.6541, 0.2691, 0.6755]}, {"w": "the", "b": [0.2762, 0.6541, 0.3025, 0.6755]}, {"w": "same", "b": [0.3096, 0.6541, 0.3523, 0.6755]}, {"w": "algorithm,", "b": [0.3594, 0.6541, 0.4468, 0.6755]}, {"w": "so", "b": [0.4539, 0.6541, 0.4722, 0.6755]}, {"w": "K-Means", "b": [0.4793, 0.6541, 0.5558, 0.6755]}, {"w": "is", "b": [0.5629, 0.6541, 0.5761, 0.6755]}, {"w": "sometimes", "b": [0.5833, 0.6541, 0.6729, 0.6755]}, {"w": "referred", "b": [0.68, 0.6541, 0.747, 0.6755]}, {"w": "to", "b": [0.7541, 0.6541, 0.771, 0.6755]}, {"w": "as", "b": [0.7782, 0.6541, 0.7949, 0.6755]}, {"w": "Lloyd-", "b": [0.8021, 0.6541, 0.8571, 0.6755]}, {"w": "Forgy.", "b": [0.1428, 0.6732, 0.1949, 0.6946]}]}, {"id": "b_7", "type": "paragraph", "text": "240 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "240", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 267, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 9-2. An unlabeled dataset composed of five blobs of instances", "words": [{"w": "Figure", "b": [0.1429, 0.2811, 0.1943, 0.3027]}, {"w": "9-2.", "b": [0.1991, 0.2811, 0.2308, 0.3027]}, {"w": "An", "b": [0.2356, 0.2811, 0.2605, 0.3027]}, {"w": "unlabeled", "b": [0.2653, 0.2811, 0.3438, 0.3027]}, {"w": "dataset", "b": [0.3485, 0.2811, 0.4069, 0.3027]}, {"w": "composed", "b": [0.4116, 0.2811, 0.4907, 0.3027]}, {"w": "of", "b": [0.4954, 0.2811, 0.5106, 0.3027]}, {"w": "five", "b": [0.5154, 0.2811, 0.5441, 0.3027]}, {"w": "blobs", "b": [0.5489, 0.2811, 0.5905, 0.3027]}, {"w": "of", "b": [0.5952, 0.2811, 0.6104, 0.3027]}, {"w": "instances", "b": [0.6152, 0.2811, 0.6885, 0.3027]}]}, {"id": "b_1", "type": "paragraph", "text": "Let’s train a K-Means clusterer on this dataset. It will try to find each blob’s center and assign each instance to the closest blob:", "words": [{"w": "Let’s", "b": [0.1429, 0.3185, 0.179, 0.3399]}, {"w": "train", "b": [0.184, 0.3185, 0.2242, 0.3399]}, {"w": "a", "b": [0.2291, 0.3185, 0.2383, 0.3399]}, {"w": "K-Means", "b": [0.2432, 0.3185, 0.3197, 0.3399]}, {"w": "clusterer", "b": [0.3246, 0.3185, 0.3969, 0.3399]}, {"w": "on", "b": [0.4019, 0.3185, 0.4239, 0.3399]}, {"w": "this", "b": [0.4288, 0.3185, 0.4596, 0.3399]}, {"w": "dataset.", "b": [0.4645, 0.3185, 0.5273, 0.3399]}, {"w": "It", "b": [0.5323, 0.3185, 0.5449, 0.3399]}, {"w": "will", "b": [0.5499, 0.3185, 0.5803, 0.3399]}, {"w": "try", "b": [0.5852, 0.3185, 0.6094, 0.3399]}, {"w": "to", "b": [0.6144, 0.3185, 0.6314, 0.3399]}, {"w": "find", "b": [0.6363, 0.3185, 0.6705, 0.3399]}, {"w": "each", "b": [0.6754, 0.3185, 0.7133, 0.3399]}, {"w": "blob’s", "b": [0.7183, 0.3185, 0.7641, 0.3399]}, {"w": "center", "b": [0.7691, 0.3185, 0.8207, 0.3399]}, {"w": "and", "b": [0.8256, 0.3185, 0.8571, 0.3399]}, {"w": "assign", "b": [0.1429, 0.3376, 0.194, 0.359]}, {"w": "each", "b": [0.1987, 0.3376, 0.2367, 0.359]}, {"w": "instance", "b": [0.2414, 0.3376, 0.3106, 0.359]}, {"w": "to", "b": [0.3153, 0.3376, 0.3323, 0.359]}, {"w": "the", "b": [0.337, 0.3376, 0.3634, 0.359]}, {"w": "closest", "b": [0.3681, 0.3376, 0.4233, 0.359]}, {"w": "blob:", "b": [0.428, 0.3376, 0.4699, 0.359]}]}, {"id": "b_2", "type": "paragraph", "text": "from sklearn.cluster import KMeans k = 5 kmeans = KMeans(n_clusters=k) y_pred = kmeans.fit_predict(X)", "words": [{"w": "from", "b": [0.1766, 0.3695, 0.2103, 0.3824]}, {"w": "sklearn.cluster", "b": [0.2187, 0.3695, 0.3452, 0.3824]}, {"w": "import", "b": [0.3537, 0.3695, 0.4043, 0.3824]}, {"w": "KMeans", "b": [0.4127, 0.3695, 0.4633, 0.3824]}, {"w": "k", "b": [0.1766, 0.385, 0.185, 0.3978]}, {"w": "=", "b": [0.1934, 0.385, 0.2019, 0.3978]}, {"w": "5", "b": [0.2103, 0.385, 0.2187, 0.3978]}, {"w": "kmeans", "b": [0.1766, 0.4004, 0.2272, 0.4132]}, {"w": "=", "b": [0.2356, 0.4004, 0.244, 0.4132]}, {"w": "KMeans(n_clusters=k)", "b": [0.2525, 0.4004, 0.4211, 0.4132]}, {"w": "y_pred", "b": [0.1766, 0.4158, 0.2272, 0.4287]}, {"w": "=", "b": [0.2356, 0.4158, 0.244, 0.4287]}, {"w": "kmeans.fit_predict(X)", "b": [0.2525, 0.4158, 0.4296, 0.4287]}]}, {"id": "b_3", "type": "paragraph", "text": "Note that you have to specify the number of clusters k that the algorithm must find. In this example, it is pretty obvious from looking at the data that k should be set to 5, but in general it is not that easy. We will discuss this shortly.", "words": [{"w": "Note", "b": [0.1429, 0.4364, 0.1836, 0.4579]}, {"w": "that", "b": [0.1898, 0.4364, 0.2223, 0.4579]}, {"w": "you", "b": [0.2284, 0.4364, 0.2597, 0.4579]}, {"w": "have", "b": [0.2658, 0.4364, 0.3042, 0.4579]}, {"w": "to", "b": [0.3103, 0.4364, 0.3273, 0.4579]}, {"w": "specify", "b": [0.3334, 0.4364, 0.3913, 0.4579]}, {"w": "the", "b": [0.3974, 0.4364, 0.4237, 0.4579]}, {"w": "number", "b": [0.4298, 0.4364, 0.4961, 0.4579]}, {"w": "of", "b": [0.5022, 0.4364, 0.519, 0.4579]}, {"w": "clusters", "b": [0.5251, 0.4364, 0.5885, 0.4579]}, {"w": "k", "b": [0.5946, 0.4362, 0.6044, 0.4579]}, {"w": "that", "b": [0.6105, 0.4364, 0.6431, 0.4579]}, {"w": "the", "b": [0.6492, 0.4364, 0.6755, 0.4579]}, {"w": "algorithm", "b": [0.6817, 0.4364, 0.7643, 0.4579]}, {"w": "must", "b": [0.7704, 0.4364, 0.8121, 0.4579]}, {"w": "find.", "b": [0.8182, 0.4364, 0.8571, 0.4579]}, {"w": "In", "b": [0.1429, 0.4555, 0.1614, 0.4769]}, {"w": "this", "b": [0.1667, 0.4555, 0.1974, 0.4769]}, {"w": "example,", "b": [0.2026, 0.4555, 0.2769, 0.4769]}, {"w": "it", "b": [0.2822, 0.4555, 0.2942, 0.4769]}, {"w": "is", "b": [0.2994, 0.4555, 0.3127, 0.4769]}, {"w": "pretty", "b": [0.318, 0.4555, 0.3677, 0.4769]}, {"w": "obvious", "b": [0.373, 0.4555, 0.4388, 0.4769]}, {"w": "from", "b": [0.4441, 0.4555, 0.4856, 0.4769]}, {"w": "looking", "b": [0.4909, 0.4555, 0.5545, 0.4769]}, {"w": "at", "b": [0.5598, 0.4555, 0.5749, 0.4769]}, {"w": "the", "b": [0.5802, 0.4555, 0.6065, 0.4769]}, {"w": "data", "b": [0.6118, 0.4555, 0.647, 0.4769]}, {"w": "that", "b": [0.6523, 0.4555, 0.6849, 0.4769]}, {"w": "k", "b": [0.6902, 0.4553, 0.7, 0.4769]}, {"w": "should", "b": [0.7053, 0.4555, 0.762, 0.4769]}, {"w": "be", "b": [0.7673, 0.4555, 0.7867, 0.4769]}, {"w": "set", "b": [0.792, 0.4555, 0.8148, 0.4769]}, {"w": "to", "b": [0.8201, 0.4555, 0.8371, 0.4769]}, {"w": "5,", "b": [0.8424, 0.4555, 0.8571, 0.4769]}, {"w": "but", "b": [0.1428, 0.4745, 0.1708, 0.4959]}, {"w": "in", "b": [0.1756, 0.4745, 0.1926, 0.4959]}, {"w": "general", "b": [0.1973, 0.4745, 0.2583, 0.4959]}, {"w": "it", "b": [0.263, 0.4745, 0.275, 0.4959]}, {"w": "is", "b": [0.2797, 0.4745, 0.2929, 0.4959]}, {"w": "not", "b": [0.2976, 0.4745, 0.326, 0.4959]}, {"w": "that", "b": [0.3307, 0.4745, 0.3633, 0.4959]}, {"w": "easy.", "b": [0.3681, 0.4745, 0.4065, 0.4959]}, {"w": "We", "b": [0.4112, 0.4745, 0.4383, 0.4959]}, {"w": "will", "b": [0.443, 0.4745, 0.4734, 0.4959]}, {"w": "discuss", "b": [0.4781, 0.4745, 0.5375, 0.4959]}, {"w": "this", "b": [0.5423, 0.4745, 0.573, 0.4959]}, {"w": "shortly.", "b": [0.5777, 0.4745, 0.6392, 0.4959]}]}, {"id": "b_4", "type": "paragraph", "text": "Each instance was assigned to one of the 5 clusters. In the context of clustering, an instance’s label is the index of the cluster that this instance gets assigned to by the algorithm: this is not to be confused with the class labels in classification (remember that clustering is an unsupervised learning task). The KMeans instance preserves a copy of the labels of the instances it was trained on, available via the labels_ instance variable:", "words": [{"w": "Each", "b": [0.1428, 0.5027, 0.1838, 0.5241]}, {"w": "instance", "b": [0.1906, 0.5027, 0.2597, 0.5241]}, {"w": "was", "b": [0.2665, 0.5027, 0.2976, 0.5241]}, {"w": "assigned", "b": [0.3044, 0.5027, 0.3754, 0.5241]}, {"w": "to", "b": [0.3822, 0.5027, 0.3992, 0.5241]}, {"w": "one", "b": [0.4059, 0.5027, 0.4368, 0.5241]}, {"w": "of", "b": [0.4436, 0.5027, 0.4604, 0.5241]}, {"w": "the", "b": [0.4672, 0.5027, 0.4935, 0.5241]}, {"w": "5", "b": [0.5003, 0.5027, 0.5103, 0.5241]}, {"w": "clusters.", "b": [0.5171, 0.5027, 0.5852, 0.5241]}, {"w": "In", "b": [0.592, 0.5027, 0.6105, 0.5241]}, {"w": "the", "b": [0.6173, 0.5027, 0.6436, 0.5241]}, {"w": "context", "b": [0.6504, 0.5027, 0.7122, 0.5241]}, {"w": "of", "b": [0.719, 0.5027, 0.7358, 0.5241]}, {"w": "clustering,", "b": [0.7426, 0.5027, 0.8298, 0.5241]}, {"w": "an", "b": [0.8366, 0.5027, 0.8571, 0.5241]}, {"w": "instance’s", "b": [0.1429, 0.5217, 0.2212, 0.5431]}, {"w": "label", "b": [0.2287, 0.5215, 0.2668, 0.5431]}, {"w": "is", "b": [0.2743, 0.5217, 0.2876, 0.5431]}, {"w": "the", "b": [0.2951, 0.5217, 0.3215, 0.5431]}, {"w": "index", "b": [0.329, 0.5217, 0.3757, 0.5431]}, {"w": "of", "b": [0.3832, 0.5217, 0.4, 0.5431]}, {"w": "the", "b": [0.4076, 0.5217, 0.4339, 0.5431]}, {"w": "cluster", "b": [0.4415, 0.5217, 0.4972, 0.5431]}, {"w": "that", "b": [0.5047, 0.5217, 0.5373, 0.5431]}, {"w": "this", "b": [0.5449, 0.5217, 0.5756, 0.5431]}, {"w": "instance", "b": [0.5831, 0.5217, 0.6523, 0.5431]}, {"w": "gets", "b": [0.6599, 0.5217, 0.6925, 0.5431]}, {"w": "assigned", "b": [0.7, 0.5217, 0.771, 0.5431]}, {"w": "to", "b": [0.7786, 0.5217, 0.7956, 0.5431]}, {"w": "by", "b": [0.8031, 0.5217, 0.8233, 0.5431]}, {"w": "the", "b": [0.8308, 0.5217, 0.8571, 0.5431]}, {"w": "algorithm:", "b": [0.1429, 0.5407, 0.2303, 0.5622]}, {"w": "this", "b": [0.2361, 0.5407, 0.2668, 0.5622]}, {"w": "is", "b": [0.2726, 0.5407, 0.2858, 0.5622]}, {"w": "not", "b": [0.2916, 0.5407, 0.32, 0.5622]}, {"w": "to", "b": [0.3258, 0.5407, 0.3427, 0.5622]}, {"w": "be", "b": [0.3485, 0.5407, 0.368, 0.5622]}, {"w": "confused", "b": [0.3738, 0.5407, 0.4493, 0.5622]}, {"w": "with", "b": [0.4551, 0.5407, 0.4925, 0.5622]}, {"w": "the", "b": [0.4982, 0.5407, 0.5246, 0.5622]}, {"w": "class", "b": [0.5304, 0.5407, 0.5689, 0.5622]}, {"w": "labels", "b": [0.5747, 0.5407, 0.6215, 0.5622]}, {"w": "in", "b": [0.6273, 0.5407, 0.6442, 0.5622]}, {"w": "classification", "b": [0.65, 0.5407, 0.7574, 0.5622]}, {"w": "(remember", "b": [0.7632, 0.5407, 0.8571, 0.5622]}, {"w": "that", "b": [0.1429, 0.5607, 0.1754, 0.5821]}, {"w": "clustering", "b": [0.1836, 0.5607, 0.2661, 0.5821]}, {"w": "is", "b": [0.2742, 0.5607, 0.2875, 0.5821]}, {"w": "an", "b": [0.2956, 0.5607, 0.3162, 0.5821]}, {"w": "unsupervised", "b": [0.3244, 0.5607, 0.4364, 0.5821]}, {"w": "learning", "b": [0.4445, 0.5607, 0.5136, 0.5821]}, {"w": "task).", "b": [0.5218, 0.5607, 0.5673, 0.5821]}, {"w": "The", "b": [0.5754, 0.5607, 0.6083, 0.5821]}, {"w": "KMeans", "b": [0.6164, 0.5639, 0.6758, 0.579]}, {"w": "instance", "b": [0.684, 0.5607, 0.7532, 0.5821]}, {"w": "preserves", "b": [0.7613, 0.5607, 0.8398, 0.5821]}, {"w": "a", "b": [0.848, 0.5607, 0.8571, 0.5821]}, {"w": "copy", "b": [0.1429, 0.5806, 0.1828, 0.602]}, {"w": "of", "b": [0.1877, 0.5806, 0.2045, 0.602]}, {"w": "the", "b": [0.2093, 0.5806, 0.2357, 0.602]}, {"w": "labels", "b": [0.2406, 0.5806, 0.2873, 0.602]}, {"w": "of", "b": [0.2922, 0.5806, 0.309, 0.602]}, {"w": "the", "b": [0.3139, 0.5806, 0.3402, 0.602]}, {"w": "instances", "b": [0.3451, 0.5806, 0.4219, 0.602]}, {"w": "it", "b": [0.4268, 0.5806, 0.4388, 0.602]}, {"w": "was", "b": [0.4436, 0.5806, 0.4747, 0.602]}, {"w": "trained", "b": [0.4796, 0.5806, 0.5396, 0.602]}, {"w": "on,", "b": [0.5445, 0.5806, 0.5713, 0.602]}, {"w": "available", "b": [0.5762, 0.5806, 0.6485, 0.602]}, {"w": "via", "b": [0.6533, 0.5806, 0.6777, 0.602]}, {"w": "the", "b": [0.6826, 0.5806, 0.7089, 0.602]}, {"w": "labels_", "b": [0.7138, 0.5838, 0.7831, 0.5989]}, {"w": "instance", "b": [0.788, 0.5806, 0.8571, 0.602]}, {"w": "variable:", "b": [0.1429, 0.5997, 0.2136, 0.6211]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> y_pred array([4, 0, 1, ..., 2, 1, 0], dtype=int32) >>> y_pred is kmeans.labels_ True", "words": [{"w": ">>>", "b": [0.1766, 0.6317, 0.2019, 0.6445]}, {"w": "y_pred", "b": [0.2103, 0.6317, 0.2609, 0.6445]}, {"w": "array([4,", "b": [0.1766, 0.6471, 0.2525, 0.6599]}, {"w": "0,", "b": [0.2609, 0.6471, 0.2778, 0.6599]}, {"w": "1,", "b": [0.2862, 0.6471, 0.3031, 0.6599]}, {"w": "...,", "b": [0.3115, 0.6471, 0.3452, 0.6599]}, {"w": "2,", "b": [0.3537, 0.6471, 0.3705, 0.6599]}, {"w": "1,", "b": [0.379, 0.6471, 0.3958, 0.6599]}, {"w": "0],", "b": [0.4043, 0.6471, 0.4296, 0.6599]}, {"w": "dtype=int32)", "b": [0.438, 0.6471, 0.5392, 0.6599]}, {"w": ">>>", "b": [0.1766, 0.6625, 0.2019, 0.6753]}, {"w": "y_pred", "b": [0.2103, 0.6625, 0.2609, 0.6753]}, {"w": "is", "b": [0.2694, 0.6625, 0.2862, 0.6753]}, {"w": "kmeans.labels_", "b": [0.2947, 0.6625, 0.4127, 0.6753]}, {"w": "True", "b": [0.1766, 0.6779, 0.2103, 0.6908]}]}, {"id": "b_6", "type": "paragraph", "text": "We can also take a look at the 5 centroids that the algorithm found:", "words": [{"w": "We", "b": [0.1429, 0.6986, 0.1699, 0.72]}, {"w": "can", "b": [0.1747, 0.6986, 0.204, 0.72]}, {"w": "also", "b": [0.2087, 0.6986, 0.2414, 0.72]}, {"w": "take", "b": [0.2462, 0.6986, 0.2808, 0.72]}, {"w": "a", "b": [0.2856, 0.6986, 0.2947, 0.72]}, {"w": "look", "b": [0.2995, 0.6986, 0.3363, 0.72]}, {"w": "at", "b": [0.341, 0.6986, 0.3561, 0.72]}, {"w": "the", "b": [0.3609, 0.6986, 0.3872, 0.72]}, {"w": "5", "b": [0.3919, 0.6986, 0.4019, 0.72]}, {"w": "centroids", "b": [0.4067, 0.6986, 0.4843, 0.72]}, {"w": "that", "b": [0.489, 0.6986, 0.5216, 0.72]}, {"w": "the", "b": [0.5263, 0.6986, 0.5526, 0.72]}, {"w": "algorithm", "b": [0.5574, 0.6986, 0.64, 0.72]}, {"w": "found:", "b": [0.6447, 0.6986, 0.6997, 0.72]}]}, {"id": "b_7", "type": "paragraph", "text": ">>> kmeans.cluster_centers_ array([[-2.80389616, 1.80117999], [ 0.20876306, 2.25551336], [-2.79290307, 2.79641063], [-1.46679593, 2.28585348], [-2.80037642, 1.30082566]])", "words": [{"w": ">>>", "b": [0.1766, 0.7305, 0.2019, 0.7434]}, {"w": "kmeans.cluster_centers_", "b": [0.2103, 0.7305, 0.4043, 0.7434]}, {"w": "array([[-2.80389616,", "b": [0.1766, 0.7459, 0.3452, 0.7588]}, {"w": "1.80117999],", "b": [0.3621, 0.7459, 0.4633, 0.7588]}, {"w": "[", "b": [0.2356, 0.7614, 0.244, 0.7742]}, {"w": "0.20876306,", "b": [0.2525, 0.7614, 0.3452, 0.7742]}, {"w": "2.25551336],", "b": [0.3621, 0.7614, 0.4633, 0.7742]}, {"w": "[-2.79290307,", "b": [0.2356, 0.7768, 0.3452, 0.7896]}, {"w": "2.79641063],", "b": [0.3621, 0.7768, 0.4633, 0.7896]}, {"w": "[-1.46679593,", "b": [0.2356, 0.7922, 0.3452, 0.8051]}, {"w": "2.28585348],", "b": [0.3621, 0.7922, 0.4633, 0.8051]}, {"w": "[-2.80037642,", "b": [0.2356, 0.8076, 0.3452, 0.8205]}, {"w": "1.30082566]])", "b": [0.3621, 0.8076, 0.4717, 0.8205]}]}, {"id": "b_8", "type": "paragraph", "text": "Of course, you can easily assign new instances to the cluster whose centroid is closest:", "words": [{"w": "Of", "b": [0.1429, 0.8283, 0.1646, 0.8497]}, {"w": "course,", "b": [0.1693, 0.8283, 0.2288, 0.8497]}, {"w": "you", "b": [0.2335, 0.8283, 0.2648, 0.8497]}, {"w": "can", "b": [0.2695, 0.8283, 0.2989, 0.8497]}, {"w": "easily", "b": [0.3036, 0.8283, 0.3496, 0.8497]}, {"w": "assign", "b": [0.3544, 0.8283, 0.4055, 0.8497]}, {"w": "new", "b": [0.4103, 0.8283, 0.4448, 0.8497]}, {"w": "instances", "b": [0.4495, 0.8283, 0.5264, 0.8497]}, {"w": "to", "b": [0.5311, 0.8283, 0.5481, 0.8497]}, {"w": "the", "b": [0.5528, 0.8283, 0.5791, 0.8497]}, {"w": "cluster", "b": [0.5839, 0.8283, 0.6396, 0.8497]}, {"w": "whose", "b": [0.6443, 0.8283, 0.6968, 0.8497]}, {"w": "centroid", "b": [0.7016, 0.8283, 0.7715, 0.8497]}, {"w": "is", "b": [0.7762, 0.8283, 0.7895, 0.8497]}, {"w": "closest:", "b": [0.7942, 0.8283, 0.8542, 0.8497]}]}, {"id": "b_9", "type": "paragraph", "text": "Clustering | 241", "words": [{"w": "Clustering", "b": [0.736, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "241", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 268, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": ">>> X_new = np.array([[0, 2], [3, 2], [-3, 3], [-3, 2.5]]) >>> kmeans.predict(X_new) array([1, 1, 2, 2], dtype=int32)", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "X_new", "b": [0.2103, 0.0829, 0.2525, 0.0958]}, {"w": "=", "b": [0.2609, 0.0829, 0.2693, 0.0958]}, {"w": "np.array([[0,", "b": [0.2778, 0.0829, 0.3874, 0.0958]}, {"w": "2],", "b": [0.3958, 0.0829, 0.4211, 0.0958]}, {"w": "[3,", "b": [0.4296, 0.0829, 0.4549, 0.0958]}, {"w": "2],", "b": [0.4633, 0.0829, 0.4886, 0.0958]}, {"w": "[-3,", "b": [0.497, 0.0829, 0.5308, 0.0958]}, {"w": "3],", "b": [0.5392, 0.0829, 0.5645, 0.0958]}, {"w": "[-3,", "b": [0.5729, 0.0829, 0.6066, 0.0958]}, {"w": "2.5]])", "b": [0.6151, 0.0829, 0.6657, 0.0958]}, {"w": ">>>", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "kmeans.predict(X_new)", "b": [0.2103, 0.0983, 0.3874, 0.1112]}, {"w": "array([1,", "b": [0.1766, 0.1138, 0.2525, 0.1266]}, {"w": "1,", "b": [0.2609, 0.1138, 0.2778, 0.1266]}, {"w": "2,", "b": [0.2862, 0.1138, 0.3031, 0.1266]}, {"w": "2],", "b": [0.3115, 0.1138, 0.3368, 0.1266]}, {"w": "dtype=int32)", "b": [0.3452, 0.1138, 0.4464, 0.1266]}]}, {"id": "b_1", "type": "paragraph", "text": "If you plot the cluster’s decision boundaries, you get a Voronoi tessellation (see Figure 9-3, where each centroid is represented with an X):", "words": [{"w": "If", "b": [0.1429, 0.1344, 0.1561, 0.1558]}, {"w": "you", "b": [0.1659, 0.1344, 0.1971, 0.1558]}, {"w": "plot", "b": [0.2068, 0.1344, 0.24, 0.1558]}, {"w": "the", "b": [0.2497, 0.1344, 0.276, 0.1558]}, {"w": "cluster’s", "b": [0.2858, 0.1344, 0.3518, 0.1558]}, {"w": "decision", "b": [0.3615, 0.1344, 0.431, 0.1558]}, {"w": "boundaries,", "b": [0.4407, 0.1344, 0.5391, 0.1558]}, {"w": "you", "b": [0.5488, 0.1344, 0.5801, 0.1558]}, {"w": "get", "b": [0.5898, 0.1344, 0.6148, 0.1558]}, {"w": "a", "b": [0.6245, 0.1344, 0.6336, 0.1558]}, {"w": "Voronoi", "b": [0.6433, 0.1344, 0.7125, 0.1558]}, {"w": "tessellation", "b": [0.7223, 0.1344, 0.8149, 0.1558]}, {"w": "(see", "b": [0.8246, 0.1344, 0.8572, 0.1558]}, {"w": "Figure", "b": [0.1429, 0.1534, 0.1969, 0.1749]}, {"w": "9-3,", "b": [0.2016, 0.1534, 0.2338, 0.1749]}, {"w": "where", "b": [0.2385, 0.1534, 0.2893, 0.1749]}, {"w": "each", "b": [0.294, 0.1534, 0.332, 0.1749]}, {"w": "centroid", "b": [0.3367, 0.1534, 0.4067, 0.1749]}, {"w": "is", "b": [0.4114, 0.1534, 0.4246, 0.1749]}, {"w": "represented", "b": [0.4294, 0.1534, 0.5272, 0.1749]}, {"w": "with", "b": [0.5319, 0.1534, 0.5692, 0.1749]}, {"w": "an", "b": [0.5739, 0.1534, 0.5945, 0.1749]}, {"w": "X):", "b": [0.5992, 0.1534, 0.6248, 0.1749]}]}, {"id": "b_2", "type": "equation", "text": "Figure 9-3. K-Means decision boundaries (Voronoi tessellation)", "words": [{"w": "Figure", "b": [0.1429, 0.3836, 0.1943, 0.4052]}, {"w": "9-3.", "b": [0.1991, 0.3836, 0.2308, 0.4052]}, {"w": "K-Means", "b": [0.2356, 0.3836, 0.3099, 0.4052]}, {"w": "decision", "b": [0.3147, 0.3836, 0.3802, 0.4052]}, {"w": "boundaries", "b": [0.385, 0.3836, 0.4754, 0.4052]}, {"w": "(Voronoi", "b": [0.4802, 0.3836, 0.5518, 0.4052]}, {"w": "tessellation)", "b": [0.5566, 0.3836, 0.6522, 0.4052]}]}, {"id": "b_3", "type": "paragraph", "text": "The vast majority of the instances were clearly assigned to the appropriate cluster, but a few instances were probably mislabeled (especially near the boundary between the top left cluster and the central cluster). Indeed, the K-Means algorithm does not behave very well when the blobs have very different diameters since all it cares about when assigning an instance to a cluster is the distance to the centroid.", "words": [{"w": "The", "b": [0.1429, 0.421, 0.1757, 0.4424]}, {"w": "vast", "b": [0.1807, 0.421, 0.2135, 0.4424]}, {"w": "majority", "b": [0.2184, 0.421, 0.2894, 0.4424]}, {"w": "of", "b": [0.2944, 0.421, 0.3112, 0.4424]}, {"w": "the", "b": [0.3162, 0.421, 0.3425, 0.4424]}, {"w": "instances", "b": [0.3475, 0.421, 0.4243, 0.4424]}, {"w": "were", "b": [0.4293, 0.421, 0.469, 0.4424]}, {"w": "clearly", "b": [0.474, 0.421, 0.5286, 0.4424]}, {"w": "assigned", "b": [0.5336, 0.421, 0.6046, 0.4424]}, {"w": "to", "b": [0.6096, 0.421, 0.6266, 0.4424]}, {"w": "the", "b": [0.6316, 0.421, 0.6579, 0.4424]}, {"w": "appropriate", "b": [0.6629, 0.421, 0.76, 0.4424]}, {"w": "cluster,", "b": [0.765, 0.421, 0.8242, 0.4424]}, {"w": "but", "b": [0.8291, 0.421, 0.8571, 0.4424]}, {"w": "a", "b": [0.1429, 0.4401, 0.152, 0.4615]}, {"w": "few", "b": [0.1582, 0.4401, 0.1875, 0.4615]}, {"w": "instances", "b": [0.1936, 0.4401, 0.2705, 0.4615]}, {"w": "were", "b": [0.2766, 0.4401, 0.3163, 0.4615]}, {"w": "probably", "b": [0.3225, 0.4401, 0.3969, 0.4615]}, {"w": "mislabeled", "b": [0.4031, 0.4401, 0.4924, 0.4615]}, {"w": "(especially", "b": [0.4985, 0.4401, 0.5856, 0.4615]}, {"w": "near", "b": [0.5918, 0.4401, 0.6289, 0.4615]}, {"w": "the", "b": [0.6351, 0.4401, 0.6614, 0.4615]}, {"w": "boundary", "b": [0.6676, 0.4401, 0.7493, 0.4615]}, {"w": "between", "b": [0.7555, 0.4401, 0.8246, 0.4615]}, {"w": "the", "b": [0.8308, 0.4401, 0.8571, 0.4615]}, {"w": "top", "b": [0.1428, 0.4591, 0.1707, 0.4805]}, {"w": "left", "b": [0.1796, 0.4591, 0.2063, 0.4805]}, {"w": "cluster", "b": [0.2151, 0.4591, 0.2708, 0.4805]}, {"w": "and", "b": [0.2797, 0.4591, 0.3112, 0.4805]}, {"w": "the", "b": [0.3201, 0.4591, 0.3464, 0.4805]}, {"w": "central", "b": [0.3553, 0.4591, 0.4125, 0.4805]}, {"w": "cluster).", "b": [0.4213, 0.4591, 0.489, 0.4805]}, {"w": "Indeed,", "b": [0.4979, 0.4591, 0.5608, 0.4805]}, {"w": "the", "b": [0.5697, 0.4591, 0.596, 0.4805]}, {"w": "K-Means", "b": [0.6049, 0.4591, 0.6814, 0.4805]}, {"w": "algorithm", "b": [0.6903, 0.4591, 0.7729, 0.4805]}, {"w": "does", "b": [0.7818, 0.4591, 0.8199, 0.4805]}, {"w": "not", "b": [0.8288, 0.4591, 0.8571, 0.4805]}, {"w": "behave", "b": [0.1429, 0.4782, 0.2007, 0.4996]}, {"w": "very", "b": [0.2062, 0.4782, 0.2426, 0.4996]}, {"w": "well", "b": [0.2481, 0.4782, 0.2818, 0.4996]}, {"w": "when", "b": [0.2873, 0.4782, 0.3329, 0.4996]}, {"w": "the", "b": [0.3384, 0.4782, 0.3648, 0.4996]}, {"w": "blobs", "b": [0.3703, 0.4782, 0.415, 0.4996]}, {"w": "have", "b": [0.4205, 0.4782, 0.4589, 0.4996]}, {"w": "very", "b": [0.4644, 0.4782, 0.5008, 0.4996]}, {"w": "different", "b": [0.5063, 0.4782, 0.578, 0.4996]}, {"w": "diameters", "b": [0.5835, 0.4782, 0.6657, 0.4996]}, {"w": "since", "b": [0.6712, 0.4782, 0.7135, 0.4996]}, {"w": "all", "b": [0.719, 0.4782, 0.7387, 0.4996]}, {"w": "it", "b": [0.7442, 0.4782, 0.7562, 0.4996]}, {"w": "cares", "b": [0.7617, 0.4782, 0.8039, 0.4996]}, {"w": "about", "b": [0.8094, 0.4782, 0.8571, 0.4996]}, {"w": "when", "b": [0.1429, 0.4972, 0.1885, 0.5186]}, {"w": "assigning", "b": [0.1932, 0.4972, 0.2711, 0.5186]}, {"w": "an", "b": [0.2759, 0.4972, 0.2964, 0.5186]}, {"w": "instance", "b": [0.3011, 0.4972, 0.3703, 0.5186]}, {"w": "to", "b": [0.375, 0.4972, 0.392, 0.5186]}, {"w": "a", "b": [0.3968, 0.4972, 0.4059, 0.5186]}, {"w": "cluster", "b": [0.4106, 0.4972, 0.4664, 0.5186]}, {"w": "is", "b": [0.4711, 0.4972, 0.4843, 0.5186]}, {"w": "the", "b": [0.489, 0.4972, 0.5154, 0.5186]}, {"w": "distance", "b": [0.5201, 0.4972, 0.5889, 0.5186]}, {"w": "to", "b": [0.5936, 0.4972, 0.6106, 0.5186]}, {"w": "the", "b": [0.6153, 0.4972, 0.6417, 0.5186]}, {"w": "centroid.", "b": [0.6464, 0.4972, 0.7211, 0.5186]}]}, {"id": "b_4", "type": "paragraph", "text": "Instead of assigning each instance to a single cluster, which is called hard clustering, it can be useful to just give each instance a score per cluster: this is called soft clustering. For example, the score can be the distance between the instance and the centroid, or conversely it can be a similarity score (or affinity) such as the Gaussian Radial Basis Function (introduced in Chapter 5). In the KMeans class, the transform() method measures the distance from each instance to every centroid:", "words": [{"w": "Instead", "b": [0.1429, 0.5253, 0.2044, 0.5467]}, {"w": "of", "b": [0.2095, 0.5253, 0.2263, 0.5467]}, {"w": "assigning", "b": [0.2314, 0.5253, 0.3093, 0.5467]}, {"w": "each", "b": [0.3144, 0.5253, 0.3524, 0.5467]}, {"w": "instance", "b": [0.3575, 0.5253, 0.4267, 0.5467]}, {"w": "to", "b": [0.4318, 0.5253, 0.4488, 0.5467]}, {"w": "a", "b": [0.4539, 0.5253, 0.4631, 0.5467]}, {"w": "single", "b": [0.4682, 0.5253, 0.5167, 0.5467]}, {"w": "cluster,", "b": [0.5218, 0.5253, 0.581, 0.5467]}, {"w": "which", "b": [0.5861, 0.5253, 0.6371, 0.5467]}, {"w": "is", "b": [0.6422, 0.5253, 0.6554, 0.5467]}, {"w": "called", "b": [0.6605, 0.5253, 0.7089, 0.5467]}, {"w": "hard", "b": [0.714, 0.5251, 0.7522, 0.5467]}, {"w": "clustering,", "b": [0.757, 0.5251, 0.8401, 0.5467]}, {"w": "it", "b": [0.8448, 0.5253, 0.8567, 0.5467]}, {"w": "can", "b": [0.1429, 0.5444, 0.1722, 0.5658]}, {"w": "be", "b": [0.1774, 0.5444, 0.1968, 0.5658]}, {"w": "useful", "b": [0.2019, 0.5444, 0.252, 0.5658]}, {"w": "to", "b": [0.2571, 0.5444, 0.2741, 0.5658]}, {"w": "just", "b": [0.2792, 0.5444, 0.3096, 0.5658]}, {"w": "give", "b": [0.3148, 0.5444, 0.3486, 0.5658]}, {"w": "each", "b": [0.3537, 0.5444, 0.3917, 0.5658]}, {"w": "instance", "b": [0.3968, 0.5444, 0.466, 0.5658]}, {"w": "a", "b": [0.4711, 0.5444, 0.4803, 0.5658]}, {"w": "score", "b": [0.4854, 0.5444, 0.5291, 0.5658]}, {"w": "per", "b": [0.5342, 0.5444, 0.5617, 0.5658]}, {"w": "cluster:", "b": [0.5668, 0.5444, 0.6278, 0.5658]}, {"w": "this", "b": [0.633, 0.5444, 0.6637, 0.5658]}, {"w": "is", "b": [0.6688, 0.5444, 0.682, 0.5658]}, {"w": "called", "b": [0.6872, 0.5444, 0.7355, 0.5658]}, {"w": "soft", "b": [0.7407, 0.5442, 0.7693, 0.5658]}, {"w": "clustering.", "b": [0.7741, 0.5442, 0.8571, 0.5658]}, {"w": "For", "b": [0.1429, 0.5634, 0.1718, 0.5848]}, {"w": "example,", "b": [0.1777, 0.5634, 0.252, 0.5848]}, {"w": "the", "b": [0.2578, 0.5634, 0.2841, 0.5848]}, {"w": "score", "b": [0.2899, 0.5634, 0.3336, 0.5848]}, {"w": "can", "b": [0.3394, 0.5634, 0.3688, 0.5848]}, {"w": "be", "b": [0.3746, 0.5634, 0.394, 0.5848]}, {"w": "the", "b": [0.3998, 0.5634, 0.4262, 0.5848]}, {"w": "distance", "b": [0.432, 0.5634, 0.5008, 0.5848]}, {"w": "between", "b": [0.5066, 0.5634, 0.5758, 0.5848]}, {"w": "the", "b": [0.5816, 0.5634, 0.6079, 0.5848]}, {"w": "instance", "b": [0.6137, 0.5634, 0.6829, 0.5848]}, {"w": "and", "b": [0.6888, 0.5634, 0.7203, 0.5848]}, {"w": "the", "b": [0.7261, 0.5634, 0.7525, 0.5848]}, {"w": "centroid,", "b": [0.7583, 0.5634, 0.833, 0.5848]}, {"w": "or", "b": [0.8388, 0.5634, 0.8572, 0.5848]}, {"w": "conversely", "b": [0.1429, 0.5825, 0.2308, 0.6039]}, {"w": "it", "b": [0.237, 0.5825, 0.2489, 0.6039]}, {"w": "can", "b": [0.2551, 0.5825, 0.2845, 0.6039]}, {"w": "be", "b": [0.2907, 0.5825, 0.3101, 0.6039]}, {"w": "a", "b": [0.3163, 0.5825, 0.3255, 0.6039]}, {"w": "similarity", "b": [0.3317, 0.5825, 0.4112, 0.6039]}, {"w": "score", "b": [0.4174, 0.5825, 0.4611, 0.6039]}, {"w": "(or", "b": [0.4673, 0.5825, 0.4929, 0.6039]}, {"w": "affinity)", "b": [0.4991, 0.5825, 0.5663, 0.6039]}, {"w": "such", "b": [0.5725, 0.5825, 0.6111, 0.6039]}, {"w": "as", "b": [0.6173, 0.5825, 0.6341, 0.6039]}, {"w": "the", "b": [0.6403, 0.5825, 0.6667, 0.6039]}, {"w": "Gaussian", "b": [0.6729, 0.5825, 0.749, 0.6039]}, {"w": "Radial", "b": [0.7552, 0.5825, 0.8087, 0.6039]}, {"w": "Basis", "b": [0.8149, 0.5825, 0.8571, 0.6039]}, {"w": "Function", "b": [0.1429, 0.6024, 0.2187, 0.6238]}, {"w": "(introduced", "b": [0.2264, 0.6024, 0.3256, 0.6238]}, {"w": "in", "b": [0.3334, 0.6024, 0.3504, 0.6238]}, {"w": "Chapter", "b": [0.3581, 0.6024, 0.4257, 0.6238]}, {"w": "5).", "b": [0.4334, 0.6024, 0.4554, 0.6238]}, {"w": "In", "b": [0.4631, 0.6024, 0.4816, 0.6238]}, {"w": "the", "b": [0.4893, 0.6024, 0.5156, 0.6238]}, {"w": "KMeans", "b": [0.5234, 0.6056, 0.5827, 0.6207]}, {"w": "class,", "b": [0.5905, 0.6024, 0.6337, 0.6238]}, {"w": "the", "b": [0.6415, 0.6024, 0.6678, 0.6238]}, {"w": "transform()", "b": [0.6755, 0.6056, 0.7844, 0.6207]}, {"w": "method", "b": [0.7921, 0.6024, 0.8571, 0.6238]}, {"w": "measures", "b": [0.1428, 0.6215, 0.2209, 0.6429]}, {"w": "the", "b": [0.2256, 0.6215, 0.2519, 0.6429]}, {"w": "distance", "b": [0.2566, 0.6215, 0.3254, 0.6429]}, {"w": "from", "b": [0.3302, 0.6215, 0.3717, 0.6429]}, {"w": "each", "b": [0.3765, 0.6215, 0.4144, 0.6429]}, {"w": "instance", "b": [0.4191, 0.6215, 0.4883, 0.6429]}, {"w": "to", "b": [0.4931, 0.6215, 0.51, 0.6429]}, {"w": "every", "b": [0.5148, 0.6215, 0.56, 0.6429]}, {"w": "centroid:", "b": [0.5647, 0.6215, 0.6395, 0.6429]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> kmeans.transform(X_new) array([[2.81093633, 0.32995317, 2.9042344 , 1.49439034, 2.88633901], [5.80730058, 2.80290755, 5.84739223, 4.4759332 , 5.84236351], [1.21475352, 3.29399768, 0.29040966, 1.69136631, 1.71086031], [0.72581411, 3.21806371, 0.36159148, 1.54808703, 1.21567622]])", "words": [{"w": ">>>", "b": [0.1766, 0.6534, 0.2019, 0.6663]}, {"w": "kmeans.transform(X_new)", "b": [0.2103, 0.6534, 0.4043, 0.6663]}, {"w": "array([[2.81093633,", "b": [0.1766, 0.6689, 0.3368, 0.6817]}, {"w": "0.32995317,", "b": [0.3452, 0.6689, 0.438, 0.6817]}, {"w": "2.9042344", "b": [0.4464, 0.6689, 0.5223, 0.6817]}, {"w": ",", "b": [0.5308, 0.6689, 0.5392, 0.6817]}, {"w": "1.49439034,", "b": [0.5476, 0.6689, 0.6404, 0.6817]}, {"w": "2.88633901],", "b": [0.6488, 0.6689, 0.75, 0.6817]}, {"w": "[5.80730058,", "b": [0.2356, 0.6843, 0.3368, 0.6971]}, {"w": "2.80290755,", "b": [0.3452, 0.6843, 0.438, 0.6971]}, {"w": "5.84739223,", "b": [0.4464, 0.6843, 0.5392, 0.6971]}, {"w": "4.4759332", "b": [0.5476, 0.6843, 0.6235, 0.6971]}, {"w": ",", "b": [0.6319, 0.6843, 0.6404, 0.6971]}, {"w": "5.84236351],", "b": [0.6488, 0.6843, 0.75, 0.6971]}, {"w": "[1.21475352,", "b": [0.2356, 0.6997, 0.3368, 0.7125]}, {"w": "3.29399768,", "b": [0.3452, 0.6997, 0.438, 0.7125]}, {"w": "0.29040966,", "b": [0.4464, 0.6997, 0.5392, 0.7125]}, {"w": "1.69136631,", "b": [0.5476, 0.6997, 0.6404, 0.7125]}, {"w": "1.71086031],", "b": [0.6488, 0.6997, 0.75, 0.7125]}, {"w": "[0.72581411,", "b": [0.2356, 0.7151, 0.3368, 0.728]}, {"w": "3.21806371,", "b": [0.3452, 0.7151, 0.438, 0.728]}, {"w": "0.36159148,", "b": [0.4464, 0.7151, 0.5392, 0.728]}, {"w": "1.54808703,", "b": [0.5476, 0.7151, 0.6404, 0.728]}, {"w": "1.21567622]])", "b": [0.6488, 0.7151, 0.7584, 0.728]}]}, {"id": "b_6", "type": "paragraph", "text": "In this example, the first instance in X_new is located at a distance of 2.81 from the first centroid, 0.33 from the second centroid, 2.90 from the third centroid, 1.49 from the fourth centroid and 2.87 from the fifth centroid. If you have a high-dimensional dataset and you transform it this way, you end up with a k-dimensional dataset: this can be a very efficient non-linear dimensionality reduction technique.", "words": [{"w": "In", "b": [0.1429, 0.7366, 0.1614, 0.7581]}, {"w": "this", "b": [0.1682, 0.7366, 0.1989, 0.7581]}, {"w": "example,", "b": [0.2058, 0.7366, 0.2801, 0.7581]}, {"w": "the", "b": [0.287, 0.7366, 0.3133, 0.7581]}, {"w": "first", "b": [0.3202, 0.7366, 0.3536, 0.7581]}, {"w": "instance", "b": [0.3605, 0.7366, 0.4297, 0.7581]}, {"w": "in", "b": [0.4366, 0.7366, 0.4536, 0.7581]}, {"w": "X_new", "b": [0.4604, 0.7398, 0.5099, 0.7549]}, {"w": "is", "b": [0.5168, 0.7366, 0.53, 0.7581]}, {"w": "located", "b": [0.5369, 0.7366, 0.5965, 0.7581]}, {"w": "at", "b": [0.6034, 0.7366, 0.6185, 0.7581]}, {"w": "a", "b": [0.6254, 0.7366, 0.6345, 0.7581]}, {"w": "distance", "b": [0.6414, 0.7366, 0.7102, 0.7581]}, {"w": "of", "b": [0.7171, 0.7366, 0.7339, 0.7581]}, {"w": "2.81", "b": [0.7407, 0.7366, 0.7755, 0.7581]}, {"w": "from", "b": [0.7824, 0.7366, 0.8239, 0.7581]}, {"w": "the", "b": [0.8308, 0.7366, 0.8571, 0.7581]}, {"w": "first", "b": [0.1429, 0.7557, 0.1763, 0.7771]}, {"w": "centroid,", "b": [0.1821, 0.7557, 0.2568, 0.7771]}, {"w": "0.33", "b": [0.2626, 0.7557, 0.2973, 0.7771]}, {"w": "from", "b": [0.3031, 0.7557, 0.3447, 0.7771]}, {"w": "the", "b": [0.3504, 0.7557, 0.3768, 0.7771]}, {"w": "second", "b": [0.3825, 0.7557, 0.4409, 0.7771]}, {"w": "centroid,", "b": [0.4466, 0.7557, 0.5213, 0.7771]}, {"w": "2.90", "b": [0.5271, 0.7557, 0.5618, 0.7771]}, {"w": "from", "b": [0.5676, 0.7557, 0.6092, 0.7771]}, {"w": "the", "b": [0.6149, 0.7557, 0.6413, 0.7771]}, {"w": "third", "b": [0.647, 0.7557, 0.6888, 0.7771]}, {"w": "centroid,", "b": [0.6946, 0.7557, 0.7693, 0.7771]}, {"w": "1.49", "b": [0.7751, 0.7557, 0.8098, 0.7771]}, {"w": "from", "b": [0.8156, 0.7557, 0.8572, 0.7771]}, {"w": "the", "b": [0.1429, 0.7747, 0.1692, 0.7962]}, {"w": "fourth", "b": [0.1753, 0.7747, 0.2284, 0.7962]}, {"w": "centroid", "b": [0.2346, 0.7747, 0.3045, 0.7962]}, {"w": "and", "b": [0.3107, 0.7747, 0.3422, 0.7962]}, {"w": "2.87", "b": [0.3484, 0.7747, 0.3831, 0.7962]}, {"w": "from", "b": [0.3893, 0.7747, 0.4309, 0.7962]}, {"w": "the", "b": [0.437, 0.7747, 0.4633, 0.7962]}, {"w": "fifth", "b": [0.4695, 0.7747, 0.5049, 0.7962]}, {"w": "centroid.", "b": [0.511, 0.7747, 0.5858, 0.7962]}, {"w": "If", "b": [0.5919, 0.7747, 0.6052, 0.7962]}, {"w": "you", "b": [0.6113, 0.7747, 0.6426, 0.7962]}, {"w": "have", "b": [0.6487, 0.7747, 0.6871, 0.7962]}, {"w": "a", "b": [0.6933, 0.7747, 0.7024, 0.7962]}, {"w": "high-dimensional", "b": [0.7086, 0.7747, 0.8571, 0.7962]}, {"w": "dataset", "b": [0.1429, 0.7938, 0.201, 0.8152]}, {"w": "and", "b": [0.2071, 0.7938, 0.2386, 0.8152]}, {"w": "you", "b": [0.2448, 0.7938, 0.276, 0.8152]}, {"w": "transform", "b": [0.2821, 0.7938, 0.366, 0.8152]}, {"w": "it", "b": [0.3721, 0.7938, 0.384, 0.8152]}, {"w": "this", "b": [0.3902, 0.7938, 0.4209, 0.8152]}, {"w": "way,", "b": [0.427, 0.7938, 0.4628, 0.8152]}, {"w": "you", "b": [0.469, 0.7938, 0.5002, 0.8152]}, {"w": "end", "b": [0.5063, 0.7938, 0.5376, 0.8152]}, {"w": "up", "b": [0.5437, 0.7938, 0.5657, 0.8152]}, {"w": "with", "b": [0.5718, 0.7938, 0.6092, 0.8152]}, {"w": "a", "b": [0.6153, 0.7938, 0.6244, 0.8152]}, {"w": "k-dimensional", "b": [0.6306, 0.7936, 0.7513, 0.8152]}, {"w": "dataset:", "b": [0.7575, 0.7938, 0.8203, 0.8152]}, {"w": "this", "b": [0.8264, 0.7938, 0.8571, 0.8152]}, {"w": "can", "b": [0.1429, 0.8128, 0.1722, 0.8342]}, {"w": "be", "b": [0.1769, 0.8128, 0.1964, 0.8342]}, {"w": "a", "b": [0.2011, 0.8128, 0.2102, 0.8342]}, {"w": "very", "b": [0.215, 0.8128, 0.2514, 0.8342]}, {"w": "efficient", "b": [0.2561, 0.8128, 0.3235, 0.8342]}, {"w": "non-linear", "b": [0.3282, 0.8128, 0.417, 0.8342]}, {"w": "dimensionality", "b": [0.4217, 0.8128, 0.5468, 0.8342]}, {"w": "reduction", "b": [0.5515, 0.8128, 0.633, 0.8342]}, {"w": "technique.", "b": [0.6377, 0.8128, 0.7251, 0.8342]}]}, {"id": "b_7", "type": "paragraph", "text": "242 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "242", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 269, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "2 This can be proven by pointing out that the mean squared distance between the instances and their closest centroid can only go down at each step.", "words": [{"w": "2", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "This", "b": [0.1587, 0.8598, 0.1871, 0.8761]}, {"w": "can", "b": [0.1907, 0.8598, 0.213, 0.8761]}, {"w": "be", "b": [0.2167, 0.8598, 0.2315, 0.8761]}, {"w": "proven", "b": [0.2351, 0.8598, 0.2801, 0.8761]}, {"w": "by", "b": [0.2837, 0.8598, 0.2991, 0.8761]}, {"w": "pointing", "b": [0.3027, 0.8598, 0.357, 0.8761]}, {"w": "out", "b": [0.3606, 0.8598, 0.3819, 0.8761]}, {"w": "that", "b": [0.3855, 0.8598, 0.4103, 0.8761]}, {"w": "the", "b": [0.414, 0.8598, 0.434, 0.8761]}, {"w": "mean", "b": [0.4376, 0.8598, 0.473, 0.8761]}, {"w": "squared", "b": [0.4766, 0.8598, 0.527, 0.8761]}, {"w": "distance", "b": [0.5306, 0.8598, 0.583, 0.8761]}, {"w": "between", "b": [0.5866, 0.8598, 0.6393, 0.8761]}, {"w": "the", "b": [0.6429, 0.8598, 0.663, 0.8761]}, {"w": "instances", "b": [0.6666, 0.8598, 0.7251, 0.8761]}, {"w": "and", "b": [0.7287, 0.8598, 0.7527, 0.8761]}, {"w": "their", "b": [0.7563, 0.8598, 0.7865, 0.8761]}, {"w": "closest", "b": [0.7901, 0.8598, 0.8322, 0.8761]}, {"w": "centroid", "b": [0.1587, 0.8749, 0.212, 0.8912]}, {"w": "can", "b": [0.2156, 0.8749, 0.238, 0.8912]}, {"w": "only", "b": [0.2416, 0.8749, 0.2697, 0.8912]}, {"w": "go", "b": [0.2733, 0.8749, 0.2888, 0.8912]}, {"w": "down", "b": [0.2924, 0.8749, 0.3284, 0.8912]}, {"w": "at", "b": [0.332, 0.8749, 0.3436, 0.8912]}, {"w": "each", "b": [0.3472, 0.8749, 0.3761, 0.8912]}, {"w": "step.", "b": [0.3797, 0.8749, 0.4086, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "The K-Means Algorithm", "words": [{"w": "The", "b": [0.1429, 0.0777, 0.1705, 0.0987]}, {"w": "K-Means", "b": [0.1741, 0.0777, 0.2396, 0.0987]}, {"w": "Algorithm", "b": [0.2432, 0.0777, 0.3199, 0.0987]}]}, {"id": "b_2", "type": "paragraph", "text": "So how does the algorithm work? Well it is really quite simple. Suppose you were given the centroids: you could easily label all the instances in the dataset by assigning each of them to the cluster whose centroid is closest. Conversely, if you were given all the instance labels, you could easily locate all the centroids by computing the mean of the instances for each cluster. But you are given neither the labels nor the centroids, so how can you proceed? Well, just start by placing the centroids randomly (e.g., by picking k instances at random and using their locations as centroids). Then label the instances, update the centroids, label the instances, update the centroids, and so on until the centroids stop moving. The algorithm is guaranteed to converge in a finite number of steps (usually quite small), it will not oscillate forever2. You can see the algorithm in action in Figure 9-4: the centroids are initialized randomly (top left), then the instances are labeled (top right), then the centroids are updated (center left), the instances are relabeled (center right), and so on. As you can see, in just 3 itera‐ tions the algorithm has reached a clustering that seems close to optimal.", "words": [{"w": "So", "b": [0.1429, 0.1044, 0.1634, 0.1258]}, {"w": "how", "b": [0.1711, 0.1044, 0.2071, 0.1258]}, {"w": "does", "b": [0.2148, 0.1044, 0.253, 0.1258]}, {"w": "the", "b": [0.2607, 0.1044, 0.287, 0.1258]}, {"w": "algorithm", "b": [0.2947, 0.1044, 0.3774, 0.1258]}, {"w": "work?", "b": [0.3851, 0.1044, 0.436, 0.1258]}, {"w": "Well", "b": [0.4437, 0.1044, 0.4813, 0.1258]}, {"w": "it", "b": [0.489, 0.1044, 0.501, 0.1258]}, {"w": "is", "b": [0.5087, 0.1044, 0.5219, 0.1258]}, {"w": "really", "b": [0.5296, 0.1044, 0.5755, 0.1258]}, {"w": "quite", "b": [0.5832, 0.1044, 0.6257, 0.1258]}, {"w": "simple.", "b": [0.6334, 0.1044, 0.6931, 0.1258]}, {"w": "Suppose", "b": [0.7008, 0.1044, 0.7707, 0.1258]}, {"w": "you", "b": [0.7785, 0.1044, 0.8097, 0.1258]}, {"w": "were", "b": [0.8174, 0.1044, 0.8571, 0.1258]}, {"w": "given", "b": [0.1429, 0.1234, 0.1881, 0.1448]}, {"w": "the", "b": [0.1934, 0.1234, 0.2198, 0.1448]}, {"w": "centroids:", "b": [0.2251, 0.1234, 0.3075, 0.1448]}, {"w": "you", "b": [0.3128, 0.1234, 0.3441, 0.1448]}, {"w": "could", "b": [0.3494, 0.1234, 0.3962, 0.1448]}, {"w": "easily", "b": [0.4015, 0.1234, 0.4476, 0.1448]}, {"w": "label", "b": [0.4529, 0.1234, 0.4921, 0.1448]}, {"w": "all", "b": [0.4974, 0.1234, 0.5171, 0.1448]}, {"w": "the", "b": [0.5224, 0.1234, 0.5488, 0.1448]}, {"w": "instances", "b": [0.5541, 0.1234, 0.631, 0.1448]}, {"w": "in", "b": [0.6363, 0.1234, 0.6533, 0.1448]}, {"w": "the", "b": [0.6586, 0.1234, 0.685, 0.1448]}, {"w": "dataset", "b": [0.6903, 0.1234, 0.7484, 0.1448]}, {"w": "by", "b": [0.7538, 0.1234, 0.7739, 0.1448]}, {"w": "assigning", "b": [0.7792, 0.1234, 0.8571, 0.1448]}, {"w": "each", "b": [0.1429, 0.1425, 0.1808, 0.1639]}, {"w": "of", "b": [0.186, 0.1425, 0.2028, 0.1639]}, {"w": "them", "b": [0.2079, 0.1425, 0.2513, 0.1639]}, {"w": "to", "b": [0.2565, 0.1425, 0.2735, 0.1639]}, {"w": "the", "b": [0.2787, 0.1425, 0.305, 0.1639]}, {"w": "cluster", "b": [0.3102, 0.1425, 0.3659, 0.1639]}, {"w": "whose", "b": [0.3711, 0.1425, 0.4236, 0.1639]}, {"w": "centroid", "b": [0.4288, 0.1425, 0.4987, 0.1639]}, {"w": "is", "b": [0.5039, 0.1425, 0.5171, 0.1639]}, {"w": "closest.", "b": [0.5223, 0.1425, 0.5823, 0.1639]}, {"w": "Conversely,", "b": [0.5874, 0.1425, 0.6836, 0.1639]}, {"w": "if", "b": [0.6888, 0.1425, 0.7006, 0.1639]}, {"w": "you", "b": [0.7057, 0.1425, 0.737, 0.1639]}, {"w": "were", "b": [0.7422, 0.1425, 0.7819, 0.1639]}, {"w": "given", "b": [0.787, 0.1425, 0.8323, 0.1639]}, {"w": "all", "b": [0.8374, 0.1425, 0.8571, 0.1639]}, {"w": "the", "b": [0.1429, 0.1615, 0.1692, 0.1829]}, {"w": "instance", "b": [0.1742, 0.1615, 0.2434, 0.1829]}, {"w": "labels,", "b": [0.2484, 0.1615, 0.2999, 0.1829]}, {"w": "you", "b": [0.3049, 0.1615, 0.3362, 0.1829]}, {"w": "could", "b": [0.3411, 0.1615, 0.3879, 0.1829]}, {"w": "easily", "b": [0.3929, 0.1615, 0.439, 0.1829]}, {"w": "locate", "b": [0.444, 0.1615, 0.4926, 0.1829]}, {"w": "all", "b": [0.4976, 0.1615, 0.5173, 0.1829]}, {"w": "the", "b": [0.5223, 0.1615, 0.5487, 0.1829]}, {"w": "centroids", "b": [0.5537, 0.1615, 0.6313, 0.1829]}, {"w": "by", "b": [0.6363, 0.1615, 0.6564, 0.1829]}, {"w": "computing", "b": [0.6614, 0.1615, 0.7526, 0.1829]}, {"w": "the", "b": [0.7576, 0.1615, 0.7839, 0.1829]}, {"w": "mean", "b": [0.7889, 0.1615, 0.8354, 0.1829]}, {"w": "of", "b": [0.8404, 0.1615, 0.8572, 0.1829]}, {"w": "the", "b": [0.1429, 0.1805, 0.1692, 0.202]}, {"w": "instances", "b": [0.1753, 0.1805, 0.2522, 0.202]}, {"w": "for", "b": [0.2583, 0.1805, 0.2829, 0.202]}, {"w": "each", "b": [0.289, 0.1805, 0.327, 0.202]}, {"w": "cluster.", "b": [0.3331, 0.1805, 0.3923, 0.202]}, {"w": "But", "b": [0.3984, 0.1805, 0.4281, 0.202]}, {"w": "you", "b": [0.4343, 0.1805, 0.4655, 0.202]}, {"w": "are", "b": [0.4717, 0.1805, 0.4974, 0.202]}, {"w": "given", "b": [0.5035, 0.1805, 0.5488, 0.202]}, {"w": "neither", "b": [0.5549, 0.1805, 0.6148, 0.202]}, {"w": "the", "b": [0.621, 0.1805, 0.6473, 0.202]}, {"w": "labels", "b": [0.6535, 0.1805, 0.7002, 0.202]}, {"w": "nor", "b": [0.7064, 0.1805, 0.7361, 0.202]}, {"w": "the", "b": [0.7423, 0.1805, 0.7686, 0.202]}, {"w": "centroids,", "b": [0.7748, 0.1805, 0.8571, 0.202]}, {"w": "so", "b": [0.1429, 0.1996, 0.1611, 0.221]}, {"w": "how", "b": [0.1674, 0.1996, 0.2034, 0.221]}, {"w": "can", "b": [0.2097, 0.1996, 0.239, 0.221]}, {"w": "you", "b": [0.2453, 0.1996, 0.2766, 0.221]}, {"w": "proceed?", "b": [0.2828, 0.1996, 0.3575, 0.221]}, {"w": "Well,", "b": [0.3638, 0.1996, 0.4061, 0.221]}, {"w": "just", "b": [0.4124, 0.1996, 0.4428, 0.221]}, {"w": "start", "b": [0.4491, 0.1996, 0.4863, 0.221]}, {"w": "by", "b": [0.4926, 0.1996, 0.5127, 0.221]}, {"w": "placing", "b": [0.519, 0.1996, 0.5799, 0.221]}, {"w": "the", "b": [0.5861, 0.1996, 0.6125, 0.221]}, {"w": "centroids", "b": [0.6187, 0.1996, 0.6963, 0.221]}, {"w": "randomly", "b": [0.7026, 0.1996, 0.7844, 0.221]}, {"w": "(e.g.,", "b": [0.7907, 0.1996, 0.8307, 0.221]}, {"w": "by", "b": [0.837, 0.1996, 0.8571, 0.221]}, {"w": "picking", "b": [0.1428, 0.2186, 0.2052, 0.2401]}, {"w": "k", "b": [0.211, 0.2184, 0.2208, 0.2401]}, {"w": "instances", "b": [0.2266, 0.2186, 0.3035, 0.2401]}, {"w": "at", "b": [0.3093, 0.2186, 0.3244, 0.2401]}, {"w": "random", "b": [0.3302, 0.2186, 0.3971, 0.2401]}, {"w": "and", "b": [0.4029, 0.2186, 0.4345, 0.2401]}, {"w": "using", "b": [0.4403, 0.2186, 0.4857, 0.2401]}, {"w": "their", "b": [0.4915, 0.2186, 0.5312, 0.2401]}, {"w": "locations", "b": [0.537, 0.2186, 0.6121, 0.2401]}, {"w": "as", "b": [0.6179, 0.2186, 0.6347, 0.2401]}, {"w": "centroids).", "b": [0.6405, 0.2186, 0.73, 0.2401]}, {"w": "Then", "b": [0.7358, 0.2186, 0.7801, 0.2401]}, {"w": "label", "b": [0.7859, 0.2186, 0.825, 0.2401]}, {"w": "the", "b": [0.8308, 0.2186, 0.8571, 0.2401]}, {"w": "instances,", "b": [0.1429, 0.2377, 0.2244, 0.2591]}, {"w": "update", "b": [0.2313, 0.2377, 0.2883, 0.2591]}, {"w": "the", "b": [0.2951, 0.2377, 0.3215, 0.2591]}, {"w": "centroids,", "b": [0.3284, 0.2377, 0.4107, 0.2591]}, {"w": "label", "b": [0.4176, 0.2377, 0.4567, 0.2591]}, {"w": "the", "b": [0.4636, 0.2377, 0.4899, 0.2591]}, {"w": "instances,", "b": [0.4968, 0.2377, 0.5784, 0.2591]}, {"w": "update", "b": [0.5853, 0.2377, 0.6422, 0.2591]}, {"w": "the", "b": [0.6491, 0.2377, 0.6754, 0.2591]}, {"w": "centroids,", "b": [0.6823, 0.2377, 0.7647, 0.2591]}, {"w": "and", "b": [0.7716, 0.2377, 0.8031, 0.2591]}, {"w": "so", "b": [0.81, 0.2377, 0.8282, 0.2591]}, {"w": "on", "b": [0.8351, 0.2377, 0.8571, 0.2591]}, {"w": "until", "b": [0.1429, 0.2567, 0.1821, 0.2781]}, {"w": "the", "b": [0.1885, 0.2567, 0.2148, 0.2781]}, {"w": "centroids", "b": [0.2212, 0.2567, 0.2988, 0.2781]}, {"w": "stop", "b": [0.3052, 0.2567, 0.3407, 0.2781]}, {"w": "moving.", "b": [0.3471, 0.2567, 0.4159, 0.2781]}, {"w": "The", "b": [0.4223, 0.2567, 0.4551, 0.2781]}, {"w": "algorithm", "b": [0.4615, 0.2567, 0.5442, 0.2781]}, {"w": "is", "b": [0.5505, 0.2567, 0.5638, 0.2781]}, {"w": "guaranteed", "b": [0.5701, 0.2567, 0.663, 0.2781]}, {"w": "to", "b": [0.6694, 0.2567, 0.6864, 0.2781]}, {"w": "converge", "b": [0.6928, 0.2567, 0.768, 0.2781]}, {"w": "in", "b": [0.7743, 0.2567, 0.7913, 0.2781]}, {"w": "a", "b": [0.7977, 0.2567, 0.8068, 0.2781]}, {"w": "finite", "b": [0.8132, 0.2567, 0.8571, 0.2781]}, {"w": "number", "b": [0.1429, 0.2758, 0.2091, 0.2972]}, {"w": "of", "b": [0.2165, 0.2758, 0.2333, 0.2972]}, {"w": "steps", "b": [0.2407, 0.2758, 0.2821, 0.2972]}, {"w": "(usually", "b": [0.2895, 0.2758, 0.3557, 0.2972]}, {"w": "quite", "b": [0.3631, 0.2758, 0.4056, 0.2972]}, {"w": "small),", "b": [0.413, 0.2758, 0.4693, 0.2972]}, {"w": "it", "b": [0.4767, 0.2758, 0.4887, 0.2972]}, {"w": "will", "b": [0.4961, 0.2758, 0.5264, 0.2972]}, {"w": "not", "b": [0.5338, 0.2758, 0.5622, 0.2972]}, {"w": "oscillate", "b": [0.5696, 0.2758, 0.6368, 0.2972]}, {"w": "forever2.", "b": [0.6441, 0.2758, 0.7142, 0.2972]}, {"w": "You", "b": [0.7216, 0.2758, 0.754, 0.2972]}, {"w": "can", "b": [0.7613, 0.2758, 0.7907, 0.2972]}, {"w": "see", "b": [0.7981, 0.2758, 0.8234, 0.2972]}, {"w": "the", "b": [0.8308, 0.2758, 0.8571, 0.2972]}, {"w": "algorithm", "b": [0.1429, 0.2948, 0.2255, 0.3162]}, {"w": "in", "b": [0.2331, 0.2948, 0.2501, 0.3162]}, {"w": "action", "b": [0.2577, 0.2948, 0.3096, 0.3162]}, {"w": "in", "b": [0.3172, 0.2948, 0.3342, 0.3162]}, {"w": "Figure", "b": [0.3418, 0.2948, 0.3958, 0.3162]}, {"w": "9-4:", "b": [0.4034, 0.2948, 0.4356, 0.3162]}, {"w": "the", "b": [0.4432, 0.2948, 0.4695, 0.3162]}, {"w": "centroids", "b": [0.4772, 0.2948, 0.5548, 0.3162]}, {"w": "are", "b": [0.5624, 0.2948, 0.5881, 0.3162]}, {"w": "initialized", "b": [0.5957, 0.2948, 0.6788, 0.3162]}, {"w": "randomly", "b": [0.6864, 0.2948, 0.7682, 0.3162]}, {"w": "(top", "b": [0.7758, 0.2948, 0.8109, 0.3162]}, {"w": "left),", "b": [0.8185, 0.2948, 0.8571, 0.3162]}, {"w": "then", "b": [0.1429, 0.3139, 0.1806, 0.3353]}, {"w": "the", "b": [0.1859, 0.3139, 0.2122, 0.3353]}, {"w": "instances", "b": [0.2175, 0.3139, 0.2943, 0.3353]}, {"w": "are", "b": [0.2996, 0.3139, 0.3253, 0.3353]}, {"w": "labeled", "b": [0.3306, 0.3139, 0.3896, 0.3353]}, {"w": "(top", "b": [0.3949, 0.3139, 0.43, 0.3353]}, {"w": "right),", "b": [0.4353, 0.3139, 0.4874, 0.3353]}, {"w": "then", "b": [0.4927, 0.3139, 0.5304, 0.3353]}, {"w": "the", "b": [0.5357, 0.3139, 0.562, 0.3353]}, {"w": "centroids", "b": [0.5673, 0.3139, 0.6449, 0.3353]}, {"w": "are", "b": [0.6502, 0.3139, 0.6759, 0.3353]}, {"w": "updated", "b": [0.6812, 0.3139, 0.7491, 0.3353]}, {"w": "(center", "b": [0.7544, 0.3139, 0.8132, 0.3353]}, {"w": "left),", "b": [0.8185, 0.3139, 0.8571, 0.3353]}, {"w": "the", "b": [0.1429, 0.3329, 0.1692, 0.3543]}, {"w": "instances", "b": [0.1759, 0.3329, 0.2527, 0.3543]}, {"w": "are", "b": [0.2594, 0.3329, 0.2852, 0.3543]}, {"w": "relabeled", "b": [0.2918, 0.3329, 0.3674, 0.3543]}, {"w": "(center", "b": [0.3741, 0.3329, 0.4329, 0.3543]}, {"w": "right),", "b": [0.4396, 0.3329, 0.4917, 0.3543]}, {"w": "and", "b": [0.4984, 0.3329, 0.53, 0.3543]}, {"w": "so", "b": [0.5366, 0.3329, 0.5549, 0.3543]}, {"w": "on.", "b": [0.5616, 0.3329, 0.5884, 0.3543]}, {"w": "As", "b": [0.5951, 0.3329, 0.6171, 0.3543]}, {"w": "you", "b": [0.6238, 0.3329, 0.6551, 0.3543]}, {"w": "can", "b": [0.6618, 0.3329, 0.6911, 0.3543]}, {"w": "see,", "b": [0.6978, 0.3329, 0.7279, 0.3543]}, {"w": "in", "b": [0.7346, 0.3329, 0.7516, 0.3543]}, {"w": "just", "b": [0.7583, 0.3329, 0.7887, 0.3543]}, {"w": "3", "b": [0.7954, 0.3329, 0.8054, 0.3543]}, {"w": "itera‐", "b": [0.8121, 0.3329, 0.8572, 0.3543]}, {"w": "tions", "b": [0.1429, 0.352, 0.1845, 0.3734]}, {"w": "the", "b": [0.1892, 0.352, 0.2155, 0.3734]}, {"w": "algorithm", "b": [0.2203, 0.352, 0.3029, 0.3734]}, {"w": "has", "b": [0.3076, 0.352, 0.3355, 0.3734]}, {"w": "reached", "b": [0.3403, 0.352, 0.4058, 0.3734]}, {"w": "a", "b": [0.4105, 0.352, 0.4197, 0.3734]}, {"w": "clustering", "b": [0.4244, 0.352, 0.5069, 0.3734]}, {"w": "that", "b": [0.5116, 0.352, 0.5442, 0.3734]}, {"w": "seems", "b": [0.5489, 0.352, 0.599, 0.3734]}, {"w": "close", "b": [0.6037, 0.352, 0.6449, 0.3734]}, {"w": "to", "b": [0.6496, 0.352, 0.6666, 0.3734]}, {"w": "optimal.", "b": [0.6713, 0.352, 0.741, 0.3734]}]}, {"id": "b_3", "type": "equation", "text": "Figure 9-4. The K-Means algorithm", "words": [{"w": "Figure", "b": [0.1429, 0.7043, 0.1943, 0.726]}, {"w": "9-4.", "b": [0.1991, 0.7043, 0.2308, 0.726]}, {"w": "The", "b": [0.2356, 0.7043, 0.2654, 0.726]}, {"w": "K-Means", "b": [0.2702, 0.7043, 0.3446, 0.726]}, {"w": "algorithm", "b": [0.3493, 0.7043, 0.4287, 0.726]}]}, {"id": "b_4", "type": "paragraph", "text": "Clustering | 243", "words": [{"w": "Clustering", "b": [0.736, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "243", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 270, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "The computational complexity of the algorithm is generally linear with regards to the number of instances m, the number of clusters k and the number of dimensions n. However, this is only true when the data has a clustering structure. If it does not, then in the worst case scenario the complexity can increase exponentially with the number of instances. In practice, however, this rarely happens, and K-Means is generally one of the fastest clustering algorithms.", "words": [{"w": "The", "b": [0.2714, 0.0793, 0.3014, 0.0989]}, {"w": "computational", "b": [0.3075, 0.0793, 0.4186, 0.0989]}, {"w": "complexity", "b": [0.4246, 0.0793, 0.5092, 0.0989]}, {"w": "of", "b": [0.5152, 0.0793, 0.5306, 0.0989]}, {"w": "the", "b": [0.5366, 0.0793, 0.5607, 0.0989]}, {"w": "algorithm", "b": [0.5667, 0.0793, 0.6423, 0.0989]}, {"w": "is", "b": [0.6483, 0.0793, 0.6604, 0.0989]}, {"w": "generally", "b": [0.6665, 0.0793, 0.7358, 0.0989]}, {"w": "linear", "b": [0.7418, 0.0793, 0.7857, 0.0989]}, {"w": "with", "b": [0.2714, 0.0967, 0.3055, 0.1163]}, {"w": "regards", "b": [0.311, 0.0967, 0.3676, 0.1163]}, {"w": "to", "b": [0.3731, 0.0967, 0.3886, 0.1163]}, {"w": "the", "b": [0.3941, 0.0967, 0.4182, 0.1163]}, {"w": "number", "b": [0.4237, 0.0967, 0.4843, 0.1163]}, {"w": "of", "b": [0.4898, 0.0967, 0.5052, 0.1163]}, {"w": "instances", "b": [0.5107, 0.0967, 0.5809, 0.1163]}, {"w": "m,", "b": [0.5864, 0.0965, 0.6057, 0.1163]}, {"w": "the", "b": [0.6112, 0.0967, 0.6353, 0.1163]}, {"w": "number", "b": [0.6408, 0.0967, 0.7014, 0.1163]}, {"w": "of", "b": [0.7069, 0.0967, 0.7223, 0.1163]}, {"w": "clusters", "b": [0.7278, 0.0967, 0.7857, 0.1163]}, {"w": "k", "b": [0.2714, 0.1139, 0.2804, 0.1337]}, {"w": "and", "b": [0.2849, 0.1141, 0.3138, 0.1337]}, {"w": "the", "b": [0.3183, 0.1141, 0.3424, 0.1337]}, {"w": "number", "b": [0.347, 0.1141, 0.4076, 0.1337]}, {"w": "of", "b": [0.4121, 0.1141, 0.4275, 0.1337]}, {"w": "dimensions", "b": [0.432, 0.1141, 0.5205, 0.1337]}, {"w": "n.", "b": [0.5251, 0.1139, 0.5396, 0.1337]}, {"w": "However,", "b": [0.5441, 0.1141, 0.6162, 0.1337]}, {"w": "this", "b": [0.6208, 0.1141, 0.6489, 0.1337]}, {"w": "is", "b": [0.6534, 0.1141, 0.6655, 0.1337]}, {"w": "only", "b": [0.6701, 0.1141, 0.7038, 0.1337]}, {"w": "true", "b": [0.7083, 0.1141, 0.7394, 0.1337]}, {"w": "when", "b": [0.744, 0.1141, 0.7857, 0.1337]}, {"w": "the", "b": [0.2714, 0.1315, 0.2955, 0.1511]}, {"w": "data", "b": [0.3009, 0.1315, 0.3331, 0.1511]}, {"w": "has", "b": [0.3385, 0.1315, 0.3641, 0.1511]}, {"w": "a", "b": [0.3695, 0.1315, 0.3778, 0.1511]}, {"w": "clustering", "b": [0.3832, 0.1315, 0.4586, 0.1511]}, {"w": "structure.", "b": [0.464, 0.1315, 0.5375, 0.1511]}, {"w": "If", "b": [0.5429, 0.1315, 0.555, 0.1511]}, {"w": "it", "b": [0.5605, 0.1315, 0.5714, 0.1511]}, {"w": "does", "b": [0.5768, 0.1315, 0.6116, 0.1511]}, {"w": "not,", "b": [0.6171, 0.1315, 0.6473, 0.1511]}, {"w": "then", "b": [0.6528, 0.1315, 0.6872, 0.1511]}, {"w": "in", "b": [0.6927, 0.1315, 0.7082, 0.1511]}, {"w": "the", "b": [0.7136, 0.1315, 0.7377, 0.1511]}, {"w": "worst", "b": [0.7431, 0.1315, 0.7857, 0.1511]}, {"w": "case", "b": [0.2714, 0.1489, 0.3029, 0.1685]}, {"w": "scenario", "b": [0.3104, 0.1489, 0.3742, 0.1685]}, {"w": "the", "b": [0.3817, 0.1489, 0.4058, 0.1685]}, {"w": "complexity", "b": [0.4133, 0.1489, 0.4979, 0.1685]}, {"w": "can", "b": [0.5054, 0.1489, 0.5322, 0.1685]}, {"w": "increase", "b": [0.5398, 0.1489, 0.6019, 0.1685]}, {"w": "exponentially", "b": [0.6095, 0.1489, 0.7125, 0.1685]}, {"w": "with", "b": [0.72, 0.1489, 0.7541, 0.1685]}, {"w": "the", "b": [0.7616, 0.1489, 0.7857, 0.1685]}, {"w": "number", "b": [0.2714, 0.1664, 0.332, 0.1859]}, {"w": "of", "b": [0.337, 0.1664, 0.3523, 0.1859]}, {"w": "instances.", "b": [0.3573, 0.1664, 0.4319, 0.1859]}, {"w": "In", "b": [0.4369, 0.1664, 0.4538, 0.1859]}, {"w": "practice,", "b": [0.4588, 0.1664, 0.5236, 0.1859]}, {"w": "however,", "b": [0.5286, 0.1664, 0.5968, 0.1859]}, {"w": "this", "b": [0.6017, 0.1664, 0.6298, 0.1859]}, {"w": "rarely", "b": [0.6348, 0.1664, 0.6789, 0.1859]}, {"w": "happens,", "b": [0.6839, 0.1664, 0.7519, 0.1859]}, {"w": "and", "b": [0.7569, 0.1664, 0.7857, 0.1859]}, {"w": "K-Means", "b": [0.2714, 0.1838, 0.3413, 0.2033]}, {"w": "is", "b": [0.3457, 0.1838, 0.3578, 0.2033]}, {"w": "generally", "b": [0.3621, 0.1838, 0.4314, 0.2033]}, {"w": "one", "b": [0.4357, 0.1838, 0.464, 0.2033]}, {"w": "of", "b": [0.4683, 0.1838, 0.4837, 0.2033]}, {"w": "the", "b": [0.488, 0.1838, 0.5121, 0.2033]}, {"w": "fastest", "b": [0.5164, 0.1838, 0.5641, 0.2033]}, {"w": "clustering", "b": [0.5684, 0.1838, 0.6438, 0.2033]}, {"w": "algorithms.", "b": [0.6481, 0.1838, 0.735, 0.2033]}]}, {"id": "b_1", "type": "paragraph", "text": "Unfortunately, although the algorithm is guaranteed to converge, it may not converge to the right solution (i.e., it may converge to a local optimum): this depends on the centroid initialization. For example, Figure 9-5 shows two sub-optimal solutions that the algorithm can converge to if you are not lucky with the random initialization step:", "words": [{"w": "Unfortunately,", "b": [0.1429, 0.2236, 0.264, 0.2451]}, {"w": "although", "b": [0.2691, 0.2236, 0.3436, 0.2451]}, {"w": "the", "b": [0.3486, 0.2236, 0.375, 0.2451]}, {"w": "algorithm", "b": [0.38, 0.2236, 0.4627, 0.2451]}, {"w": "is", "b": [0.4677, 0.2236, 0.481, 0.2451]}, {"w": "guaranteed", "b": [0.486, 0.2236, 0.5789, 0.2451]}, {"w": "to", "b": [0.584, 0.2236, 0.601, 0.2451]}, {"w": "converge,", "b": [0.606, 0.2236, 0.686, 0.2451]}, {"w": "it", "b": [0.6911, 0.2236, 0.703, 0.2451]}, {"w": "may", "b": [0.7081, 0.2236, 0.7434, 0.2451]}, {"w": "not", "b": [0.7485, 0.2236, 0.7769, 0.2451]}, {"w": "converge", "b": [0.782, 0.2236, 0.8571, 0.2451]}, {"w": "to", "b": [0.1429, 0.2427, 0.1598, 0.2641]}, {"w": "the", "b": [0.1665, 0.2427, 0.1928, 0.2641]}, {"w": "right", "b": [0.1995, 0.2427, 0.2396, 0.2641]}, {"w": "solution", "b": [0.2462, 0.2427, 0.3148, 0.2641]}, {"w": "(i.e.,", "b": [0.3214, 0.2427, 0.3573, 0.2641]}, {"w": "it", "b": [0.364, 0.2427, 0.3759, 0.2641]}, {"w": "may", "b": [0.3826, 0.2427, 0.418, 0.2641]}, {"w": "converge", "b": [0.4246, 0.2427, 0.4998, 0.2641]}, {"w": "to", "b": [0.5064, 0.2427, 0.5234, 0.2641]}, {"w": "a", "b": [0.5301, 0.2427, 0.5392, 0.2641]}, {"w": "local", "b": [0.5458, 0.2427, 0.585, 0.2641]}, {"w": "optimum):", "b": [0.5916, 0.2427, 0.6818, 0.2641]}, {"w": "this", "b": [0.6885, 0.2427, 0.7192, 0.2641]}, {"w": "depends", "b": [0.7258, 0.2427, 0.7955, 0.2641]}, {"w": "on", "b": [0.8021, 0.2427, 0.8242, 0.2641]}, {"w": "the", "b": [0.8308, 0.2427, 0.8571, 0.2641]}, {"w": "centroid", "b": [0.1428, 0.2617, 0.2128, 0.2831]}, {"w": "initialization.", "b": [0.2184, 0.2617, 0.3291, 0.2831]}, {"w": "For", "b": [0.3347, 0.2617, 0.3637, 0.2831]}, {"w": "example,", "b": [0.3693, 0.2617, 0.4436, 0.2831]}, {"w": "Figure", "b": [0.4491, 0.2617, 0.5031, 0.2831]}, {"w": "9-5", "b": [0.5087, 0.2617, 0.5362, 0.2831]}, {"w": "shows", "b": [0.5417, 0.2617, 0.5931, 0.2831]}, {"w": "two", "b": [0.5987, 0.2617, 0.6299, 0.2831]}, {"w": "sub-optimal", "b": [0.6355, 0.2617, 0.7372, 0.2831]}, {"w": "solutions", "b": [0.7427, 0.2617, 0.819, 0.2831]}, {"w": "that", "b": [0.8245, 0.2617, 0.8571, 0.2831]}, {"w": "the", "b": [0.1429, 0.2808, 0.1692, 0.3022]}, {"w": "algorithm", "b": [0.1739, 0.2808, 0.2566, 0.3022]}, {"w": "can", "b": [0.2613, 0.2808, 0.2907, 0.3022]}, {"w": "converge", "b": [0.2954, 0.2808, 0.3706, 0.3022]}, {"w": "to", "b": [0.3753, 0.2808, 0.3923, 0.3022]}, {"w": "if", "b": [0.397, 0.2808, 0.4088, 0.3022]}, {"w": "you", "b": [0.4135, 0.2808, 0.4447, 0.3022]}, {"w": "are", "b": [0.4495, 0.2808, 0.4752, 0.3022]}, {"w": "not", "b": [0.4799, 0.2808, 0.5083, 0.3022]}, {"w": "lucky", "b": [0.513, 0.2808, 0.5581, 0.3022]}, {"w": "with", "b": [0.5628, 0.2808, 0.6001, 0.3022]}, {"w": "the", "b": [0.6049, 0.2808, 0.6312, 0.3022]}, {"w": "random", "b": [0.6359, 0.2808, 0.7029, 0.3022]}, {"w": "initialization", "b": [0.7076, 0.2808, 0.8136, 0.3022]}, {"w": "step:", "b": [0.8183, 0.2808, 0.8568, 0.3022]}]}, {"id": "b_2", "type": "equation", "text": "Figure 9-5. Sub-optimal solutions due to unlucky centroid initializations", "words": [{"w": "Figure", "b": [0.1429, 0.4453, 0.1943, 0.4669]}, {"w": "9-5.", "b": [0.1991, 0.4453, 0.2308, 0.4669]}, {"w": "Sub-optimal", "b": [0.2356, 0.4453, 0.3355, 0.4669]}, {"w": "solutions", "b": [0.3402, 0.4453, 0.4121, 0.4669]}, {"w": "due", "b": [0.4169, 0.4453, 0.4466, 0.4669]}, {"w": "to", "b": [0.4513, 0.4453, 0.4673, 0.4669]}, {"w": "unlucky", "b": [0.4721, 0.4453, 0.5362, 0.4669]}, {"w": "centroid", "b": [0.5409, 0.4453, 0.6069, 0.4669]}, {"w": "initializations", "b": [0.6117, 0.4453, 0.7236, 0.4669]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s look at a few ways you can mitigate this risk by improving the centroid initializa‐ tion.", "words": [{"w": "Let’s", "b": [0.1429, 0.4826, 0.179, 0.5041]}, {"w": "look", "b": [0.1839, 0.4826, 0.2207, 0.5041]}, {"w": "at", "b": [0.2255, 0.4826, 0.2406, 0.5041]}, {"w": "a", "b": [0.2455, 0.4826, 0.2546, 0.5041]}, {"w": "few", "b": [0.2594, 0.4826, 0.2887, 0.5041]}, {"w": "ways", "b": [0.2936, 0.4826, 0.3338, 0.5041]}, {"w": "you", "b": [0.3386, 0.4826, 0.3699, 0.5041]}, {"w": "can", "b": [0.3747, 0.4826, 0.4041, 0.5041]}, {"w": "mitigate", "b": [0.4089, 0.4826, 0.4772, 0.5041]}, {"w": "this", "b": [0.482, 0.4826, 0.5127, 0.5041]}, {"w": "risk", "b": [0.5176, 0.4826, 0.5489, 0.5041]}, {"w": "by", "b": [0.5537, 0.4826, 0.5738, 0.5041]}, {"w": "improving", "b": [0.5787, 0.4826, 0.6666, 0.5041]}, {"w": "the", "b": [0.6714, 0.4826, 0.6977, 0.5041]}, {"w": "centroid", "b": [0.7025, 0.4826, 0.7725, 0.5041]}, {"w": "initializa‐", "b": [0.7773, 0.4826, 0.8571, 0.5041]}, {"w": "tion.", "b": [0.1429, 0.5017, 0.1816, 0.5231]}]}, {"id": "b_4", "type": "paragraph", "text": "Centroid Initialization Methods", "words": [{"w": "Centroid", "b": [0.1428, 0.539, 0.2073, 0.5599]}, {"w": "Initialization", "b": [0.211, 0.539, 0.308, 0.5599]}, {"w": "Methods", "b": [0.3117, 0.539, 0.3776, 0.5599]}]}, {"id": "b_5", "type": "paragraph", "text": "If you happen to know approximately where the centroids should be (e.g., if you ran another clustering algorithm earlier), then you can set the init hyperparameter to a NumPy array containing the list of centroids, and set n_init to 1:", "words": [{"w": "If", "b": [0.1429, 0.5656, 0.1561, 0.587]}, {"w": "you", "b": [0.162, 0.5656, 0.1932, 0.587]}, {"w": "happen", "b": [0.1991, 0.5656, 0.261, 0.587]}, {"w": "to", "b": [0.2668, 0.5656, 0.2838, 0.587]}, {"w": "know", "b": [0.2897, 0.5656, 0.3363, 0.587]}, {"w": "approximately", "b": [0.3421, 0.5656, 0.4623, 0.587]}, {"w": "where", "b": [0.4682, 0.5656, 0.519, 0.587]}, {"w": "the", "b": [0.5248, 0.5656, 0.5512, 0.587]}, {"w": "centroids", "b": [0.557, 0.5656, 0.6346, 0.587]}, {"w": "should", "b": [0.6405, 0.5656, 0.6972, 0.587]}, {"w": "be", "b": [0.703, 0.5656, 0.7225, 0.587]}, {"w": "(e.g.,", "b": [0.7283, 0.5656, 0.7684, 0.587]}, {"w": "if", "b": [0.7742, 0.5656, 0.7859, 0.587]}, {"w": "you", "b": [0.7918, 0.5656, 0.823, 0.587]}, {"w": "ran", "b": [0.8289, 0.5656, 0.8571, 0.587]}, {"w": "another", "b": [0.1429, 0.5856, 0.2081, 0.607]}, {"w": "clustering", "b": [0.2141, 0.5856, 0.2965, 0.607]}, {"w": "algorithm", "b": [0.3026, 0.5856, 0.3852, 0.607]}, {"w": "earlier),", "b": [0.3912, 0.5856, 0.4563, 0.607]}, {"w": "then", "b": [0.4623, 0.5856, 0.5001, 0.607]}, {"w": "you", "b": [0.5061, 0.5856, 0.5373, 0.607]}, {"w": "can", "b": [0.5433, 0.5856, 0.5727, 0.607]}, {"w": "set", "b": [0.5787, 0.5856, 0.6016, 0.607]}, {"w": "the", "b": [0.6076, 0.5856, 0.6339, 0.607]}, {"w": "init", "b": [0.6399, 0.5888, 0.6795, 0.6038]}, {"w": "hyperparameter", "b": [0.6855, 0.5856, 0.819, 0.607]}, {"w": "to", "b": [0.825, 0.5856, 0.842, 0.607]}, {"w": "a", "b": [0.848, 0.5856, 0.8571, 0.607]}, {"w": "NumPy", "b": [0.1429, 0.6055, 0.207, 0.6269]}, {"w": "array", "b": [0.2118, 0.6055, 0.2547, 0.6269]}, {"w": "containing", "b": [0.2594, 0.6055, 0.3491, 0.6269]}, {"w": "the", "b": [0.3538, 0.6055, 0.3801, 0.6269]}, {"w": "list", "b": [0.3849, 0.6055, 0.4097, 0.6269]}, {"w": "of", "b": [0.4145, 0.6055, 0.4312, 0.6269]}, {"w": "centroids,", "b": [0.436, 0.6055, 0.5183, 0.6269]}, {"w": "and", "b": [0.5231, 0.6055, 0.5546, 0.6269]}, {"w": "set", "b": [0.5593, 0.6055, 0.5822, 0.6269]}, {"w": "n_init", "b": [0.5869, 0.6087, 0.6463, 0.6238]}, {"w": "to", "b": [0.651, 0.6055, 0.668, 0.6269]}, {"w": "1:", "b": [0.6727, 0.6055, 0.6875, 0.6269]}]}, {"id": "b_6", "type": "paragraph", "text": "good_init = np.array([[-3, 3], [-3, 2], [-3, 1], [-1, 2], [0, 2]]) kmeans = KMeans(n_clusters=5, init=good_init, n_init=1)", "words": [{"w": "good_init", "b": [0.1766, 0.6375, 0.2525, 0.6503]}, {"w": "=", "b": [0.2609, 0.6375, 0.2694, 0.6503]}, {"w": "np.array([[-3,", "b": [0.2778, 0.6375, 0.3958, 0.6503]}, {"w": "3],", "b": [0.4043, 0.6375, 0.4296, 0.6503]}, {"w": "[-3,", "b": [0.438, 0.6375, 0.4717, 0.6503]}, {"w": "2],", "b": [0.4802, 0.6375, 0.5055, 0.6503]}, {"w": "[-3,", "b": [0.5139, 0.6375, 0.5476, 0.6503]}, {"w": "1],", "b": [0.5561, 0.6375, 0.5814, 0.6503]}, {"w": "[-1,", "b": [0.5898, 0.6375, 0.6235, 0.6503]}, {"w": "2],", "b": [0.6319, 0.6375, 0.6572, 0.6503]}, {"w": "[0,", "b": [0.6657, 0.6375, 0.691, 0.6503]}, {"w": "2]])", "b": [0.6994, 0.6375, 0.7331, 0.6503]}, {"w": "kmeans", "b": [0.1766, 0.6529, 0.2272, 0.6658]}, {"w": "=", "b": [0.2356, 0.6529, 0.2441, 0.6658]}, {"w": "KMeans(n_clusters=5,", "b": [0.2525, 0.6529, 0.4211, 0.6658]}, {"w": "init=good_init,", "b": [0.4296, 0.6529, 0.5561, 0.6658]}, {"w": "n_init=1)", "b": [0.5645, 0.6529, 0.6404, 0.6658]}]}, {"id": "b_7", "type": "paragraph", "text": "Another solution is to run the algorithm multiple times with different random initial‐ izations and keep the best solution. This is controlled by the n_init hyperparameter: by default, it is equal to 10, which means that the whole algorithm described earlier actually runs 10 times when you call fit(), and Scikit-Learn keeps the best solution. But how exactly does it know which solution is the best? Well of course it uses a per‐ formance metric! It is called the model’s inertia: this is the mean squared distance between each instance and its closest centroid. It is roughly equal to 223.3 for the model on the left of Figure 9-5, 237.5 for the model on the right of Figure 9-5, and 211.6 for the model in Figure 9-3. The KMeans class runs the algorithm n_init times and keeps the model with the lowest inertia: in this example, the model in Figure 9-3 will be selected (unless we are very unlucky with n_init consecutive random initiali‐", "words": [{"w": "Another", "b": [0.1429, 0.6735, 0.2133, 0.695]}, {"w": "solution", "b": [0.2182, 0.6735, 0.2867, 0.695]}, {"w": "is", "b": [0.2916, 0.6735, 0.3048, 0.695]}, {"w": "to", "b": [0.3096, 0.6735, 0.3266, 0.695]}, {"w": "run", "b": [0.3315, 0.6735, 0.3617, 0.695]}, {"w": "the", "b": [0.3665, 0.6735, 0.3928, 0.695]}, {"w": "algorithm", "b": [0.3977, 0.6735, 0.4803, 0.695]}, {"w": "multiple", "b": [0.4851, 0.6735, 0.5551, 0.695]}, {"w": "times", "b": [0.56, 0.6735, 0.6055, 0.695]}, {"w": "with", "b": [0.6103, 0.6735, 0.6476, 0.695]}, {"w": "different", "b": [0.6525, 0.6735, 0.7242, 0.695]}, {"w": "random", "b": [0.729, 0.6735, 0.796, 0.695]}, {"w": "initial‐", "b": [0.8008, 0.6735, 0.8571, 0.695]}, {"w": "izations", "b": [0.1429, 0.6935, 0.2075, 0.7149]}, {"w": "and", "b": [0.213, 0.6935, 0.2445, 0.7149]}, {"w": "keep", "b": [0.25, 0.6935, 0.2889, 0.7149]}, {"w": "the", "b": [0.2944, 0.6935, 0.3207, 0.7149]}, {"w": "best", "b": [0.3262, 0.6935, 0.3596, 0.7149]}, {"w": "solution.", "b": [0.3651, 0.6935, 0.4384, 0.7149]}, {"w": "This", "b": [0.4438, 0.6935, 0.4811, 0.7149]}, {"w": "is", "b": [0.4865, 0.6935, 0.4997, 0.7149]}, {"w": "controlled", "b": [0.5052, 0.6935, 0.5907, 0.7149]}, {"w": "by", "b": [0.5962, 0.6935, 0.6163, 0.7149]}, {"w": "the", "b": [0.6218, 0.6935, 0.6481, 0.7149]}, {"w": "n_init", "b": [0.6536, 0.6967, 0.7129, 0.7118]}, {"w": "hyperparameter:", "b": [0.7184, 0.6935, 0.8571, 0.7149]}, {"w": "by", "b": [0.1429, 0.7125, 0.163, 0.734]}, {"w": "default,", "b": [0.1694, 0.7125, 0.2316, 0.734]}, {"w": "it", "b": [0.2381, 0.7125, 0.25, 0.734]}, {"w": "is", "b": [0.2564, 0.7125, 0.2697, 0.734]}, {"w": "equal", "b": [0.2761, 0.7125, 0.3211, 0.734]}, {"w": "to", "b": [0.3275, 0.7125, 0.3445, 0.734]}, {"w": "10,", "b": [0.3509, 0.7125, 0.3757, 0.734]}, {"w": "which", "b": [0.3821, 0.7125, 0.433, 0.734]}, {"w": "means", "b": [0.4395, 0.7125, 0.4936, 0.734]}, {"w": "that", "b": [0.5, 0.7125, 0.5326, 0.734]}, {"w": "the", "b": [0.539, 0.7125, 0.5654, 0.734]}, {"w": "whole", "b": [0.5718, 0.7125, 0.622, 0.734]}, {"w": "algorithm", "b": [0.6284, 0.7125, 0.711, 0.734]}, {"w": "described", "b": [0.7175, 0.7125, 0.7975, 0.734]}, {"w": "earlier", "b": [0.804, 0.7125, 0.8571, 0.734]}, {"w": "actually", "b": [0.1429, 0.7325, 0.2075, 0.7539]}, {"w": "runs", "b": [0.2131, 0.7325, 0.251, 0.7539]}, {"w": "10", "b": [0.2566, 0.7325, 0.2766, 0.7539]}, {"w": "times", "b": [0.2822, 0.7325, 0.3277, 0.7539]}, {"w": "when", "b": [0.3333, 0.7325, 0.379, 0.7539]}, {"w": "you", "b": [0.3846, 0.7325, 0.4159, 0.7539]}, {"w": "call", "b": [0.4215, 0.7325, 0.45, 0.7539]}, {"w": "fit(),", "b": [0.4556, 0.7325, 0.5099, 0.7539]}, {"w": "and", "b": [0.5155, 0.7325, 0.547, 0.7539]}, {"w": "Scikit-Learn", "b": [0.5527, 0.7325, 0.6549, 0.7539]}, {"w": "keeps", "b": [0.6606, 0.7325, 0.7072, 0.7539]}, {"w": "the", "b": [0.7128, 0.7325, 0.7391, 0.7539]}, {"w": "best", "b": [0.7448, 0.7325, 0.7782, 0.7539]}, {"w": "solution.", "b": [0.7838, 0.7325, 0.8572, 0.7539]}, {"w": "But", "b": [0.1429, 0.7515, 0.1725, 0.7729]}, {"w": "how", "b": [0.178, 0.7515, 0.214, 0.7729]}, {"w": "exactly", "b": [0.2195, 0.7515, 0.2774, 0.7729]}, {"w": "does", "b": [0.2829, 0.7515, 0.321, 0.7729]}, {"w": "it", "b": [0.3265, 0.7515, 0.3384, 0.7729]}, {"w": "know", "b": [0.3439, 0.7515, 0.3905, 0.7729]}, {"w": "which", "b": [0.396, 0.7515, 0.4469, 0.7729]}, {"w": "solution", "b": [0.4524, 0.7515, 0.521, 0.7729]}, {"w": "is", "b": [0.5265, 0.7515, 0.5397, 0.7729]}, {"w": "the", "b": [0.5452, 0.7515, 0.5715, 0.7729]}, {"w": "best?", "b": [0.577, 0.7515, 0.6184, 0.7729]}, {"w": "Well", "b": [0.6239, 0.7515, 0.6615, 0.7729]}, {"w": "of", "b": [0.667, 0.7515, 0.6837, 0.7729]}, {"w": "course", "b": [0.6892, 0.7515, 0.744, 0.7729]}, {"w": "it", "b": [0.7495, 0.7515, 0.7614, 0.7729]}, {"w": "uses", "b": [0.7669, 0.7515, 0.8021, 0.7729]}, {"w": "a", "b": [0.8076, 0.7515, 0.8167, 0.7729]}, {"w": "per‐", "b": [0.8222, 0.7515, 0.8571, 0.7729]}, {"w": "formance", "b": [0.1429, 0.7706, 0.2226, 0.792]}, {"w": "metric!", "b": [0.2303, 0.7706, 0.2905, 0.792]}, {"w": "It", "b": [0.2982, 0.7706, 0.3108, 0.792]}, {"w": "is", "b": [0.3185, 0.7706, 0.3318, 0.792]}, {"w": "called", "b": [0.3395, 0.7706, 0.3878, 0.792]}, {"w": "the", "b": [0.3955, 0.7706, 0.4219, 0.792]}, {"w": "model’s", "b": [0.4296, 0.7706, 0.4921, 0.792]}, {"w": "inertia:", "b": [0.4998, 0.7704, 0.5593, 0.792]}, {"w": "this", "b": [0.567, 0.7706, 0.5977, 0.792]}, {"w": "is", "b": [0.6054, 0.7706, 0.6187, 0.792]}, {"w": "the", "b": [0.6264, 0.7706, 0.6527, 0.792]}, {"w": "mean", "b": [0.6604, 0.7706, 0.7069, 0.792]}, {"w": "squared", "b": [0.7146, 0.7706, 0.7806, 0.792]}, {"w": "distance", "b": [0.7883, 0.7706, 0.8571, 0.792]}, {"w": "between", "b": [0.1429, 0.7896, 0.212, 0.811]}, {"w": "each", "b": [0.2198, 0.7896, 0.2577, 0.811]}, {"w": "instance", "b": [0.2655, 0.7896, 0.3346, 0.811]}, {"w": "and", "b": [0.3424, 0.7896, 0.3739, 0.811]}, {"w": "its", "b": [0.3817, 0.7896, 0.4013, 0.811]}, {"w": "closest", "b": [0.409, 0.7896, 0.4642, 0.811]}, {"w": "centroid.", "b": [0.4719, 0.7896, 0.5467, 0.811]}, {"w": "It", "b": [0.5544, 0.7896, 0.567, 0.811]}, {"w": "is", "b": [0.5748, 0.7896, 0.588, 0.811]}, {"w": "roughly", "b": [0.5958, 0.7896, 0.6609, 0.811]}, {"w": "equal", "b": [0.6686, 0.7896, 0.7136, 0.811]}, {"w": "to", "b": [0.7213, 0.7896, 0.7383, 0.811]}, {"w": "223.3", "b": [0.7461, 0.7896, 0.7908, 0.811]}, {"w": "for", "b": [0.7986, 0.7896, 0.8231, 0.811]}, {"w": "the", "b": [0.8308, 0.7896, 0.8572, 0.811]}, {"w": "model", "b": [0.1429, 0.8087, 0.1957, 0.8301]}, {"w": "on", "b": [0.2023, 0.8087, 0.2243, 0.8301]}, {"w": "the", "b": [0.2309, 0.8087, 0.2572, 0.8301]}, {"w": "left", "b": [0.2638, 0.8087, 0.2905, 0.8301]}, {"w": "of", "b": [0.2971, 0.8087, 0.3138, 0.8301]}, {"w": "Figure", "b": [0.3204, 0.8087, 0.3744, 0.8301]}, {"w": "9-5,", "b": [0.381, 0.8087, 0.4132, 0.8301]}, {"w": "237.5", "b": [0.4198, 0.8087, 0.4645, 0.8301]}, {"w": "for", "b": [0.4711, 0.8087, 0.4957, 0.8301]}, {"w": "the", "b": [0.5023, 0.8087, 0.5286, 0.8301]}, {"w": "model", "b": [0.5352, 0.8087, 0.588, 0.8301]}, {"w": "on", "b": [0.5946, 0.8087, 0.6166, 0.8301]}, {"w": "the", "b": [0.6232, 0.8087, 0.6495, 0.8301]}, {"w": "right", "b": [0.6561, 0.8087, 0.6963, 0.8301]}, {"w": "of", "b": [0.7029, 0.8087, 0.7197, 0.8301]}, {"w": "Figure", "b": [0.7263, 0.8087, 0.7803, 0.8301]}, {"w": "9-5,", "b": [0.7868, 0.8087, 0.819, 0.8301]}, {"w": "and", "b": [0.8256, 0.8087, 0.8571, 0.8301]}, {"w": "211.6", "b": [0.1429, 0.8286, 0.1876, 0.85]}, {"w": "for", "b": [0.1933, 0.8286, 0.2179, 0.85]}, {"w": "the", "b": [0.2236, 0.8286, 0.2499, 0.85]}, {"w": "model", "b": [0.2557, 0.8286, 0.3085, 0.85]}, {"w": "in", "b": [0.3142, 0.8286, 0.3312, 0.85]}, {"w": "Figure", "b": [0.3369, 0.8286, 0.3909, 0.85]}, {"w": "9-3.", "b": [0.3967, 0.8286, 0.4288, 0.85]}, {"w": "The", "b": [0.4346, 0.8286, 0.4674, 0.85]}, {"w": "KMeans", "b": [0.4731, 0.8318, 0.5325, 0.8469]}, {"w": "class", "b": [0.5383, 0.8286, 0.5768, 0.85]}, {"w": "runs", "b": [0.5825, 0.8286, 0.6203, 0.85]}, {"w": "the", "b": [0.6261, 0.8286, 0.6524, 0.85]}, {"w": "algorithm", "b": [0.6581, 0.8286, 0.7408, 0.85]}, {"w": "n_init", "b": [0.7465, 0.8318, 0.8059, 0.8469]}, {"w": "times", "b": [0.8116, 0.8286, 0.8571, 0.85]}, {"w": "and", "b": [0.1428, 0.8477, 0.1744, 0.8691]}, {"w": "keeps", "b": [0.1798, 0.8477, 0.2264, 0.8691]}, {"w": "the", "b": [0.2318, 0.8477, 0.2582, 0.8691]}, {"w": "model", "b": [0.2636, 0.8477, 0.3164, 0.8691]}, {"w": "with", "b": [0.3218, 0.8477, 0.3592, 0.8691]}, {"w": "the", "b": [0.3646, 0.8477, 0.3909, 0.8691]}, {"w": "lowest", "b": [0.3964, 0.8477, 0.4494, 0.8691]}, {"w": "inertia:", "b": [0.4548, 0.8477, 0.5142, 0.8691]}, {"w": "in", "b": [0.5196, 0.8477, 0.5366, 0.8691]}, {"w": "this", "b": [0.542, 0.8477, 0.5727, 0.8691]}, {"w": "example,", "b": [0.5782, 0.8477, 0.6525, 0.8691]}, {"w": "the", "b": [0.6579, 0.8477, 0.6842, 0.8691]}, {"w": "model", "b": [0.6896, 0.8477, 0.7425, 0.8691]}, {"w": "in", "b": [0.7479, 0.8477, 0.7649, 0.8691]}, {"w": "Figure", "b": [0.7703, 0.8477, 0.8243, 0.8691]}, {"w": "9-3", "b": [0.8297, 0.8477, 0.8571, 0.8691]}, {"w": "will", "b": [0.1429, 0.8676, 0.1733, 0.889]}, {"w": "be", "b": [0.1786, 0.8676, 0.198, 0.889]}, {"w": "selected", "b": [0.2033, 0.8676, 0.269, 0.889]}, {"w": "(unless", "b": [0.2743, 0.8676, 0.3334, 0.889]}, {"w": "we", "b": [0.3387, 0.8676, 0.3618, 0.889]}, {"w": "are", "b": [0.3671, 0.8676, 0.3928, 0.889]}, {"w": "very", "b": [0.3982, 0.8676, 0.4345, 0.889]}, {"w": "unlucky", "b": [0.4399, 0.8676, 0.5074, 0.889]}, {"w": "with", "b": [0.5127, 0.8676, 0.55, 0.889]}, {"w": "n_init", "b": [0.5553, 0.8708, 0.6147, 0.8859]}, {"w": "consecutive", "b": [0.62, 0.8676, 0.7177, 0.889]}, {"w": "random", "b": [0.723, 0.8676, 0.7899, 0.889]}, {"w": "initiali‐", "b": [0.7952, 0.8676, 0.8572, 0.889]}]}, {"id": "b_8", "type": "paragraph", "text": "244 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "244", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 271, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "3 “k-means\\++: The advantages of careful seeding,” David Arthur and Sergei Vassilvitskii (2006).", "words": [{"w": "3", "b": [0.1451, 0.8568, 0.1518, 0.871]}, {"w": "“k-means\\++:", "b": [0.1587, 0.8553, 0.2471, 0.8716]}, {"w": "The", "b": [0.2507, 0.8553, 0.2757, 0.8716]}, {"w": "advantages", "b": [0.2793, 0.8553, 0.3492, 0.8716]}, {"w": "of", "b": [0.3528, 0.8553, 0.3656, 0.8716]}, {"w": "careful", "b": [0.3692, 0.8553, 0.4127, 0.8716]}, {"w": "seeding,”", "b": [0.4163, 0.8553, 0.4721, 0.8716]}, {"w": "David", "b": [0.4757, 0.8553, 0.514, 0.8716]}, {"w": "Arthur", "b": [0.5177, 0.8553, 0.5618, 0.8716]}, {"w": "and", "b": [0.5654, 0.8553, 0.5895, 0.8716]}, {"w": "Sergei", "b": [0.5931, 0.8553, 0.6317, 0.8716]}, {"w": "Vassilvitskii", "b": [0.6353, 0.8553, 0.7104, 0.8716]}, {"w": "(2006).", "b": [0.714, 0.8553, 0.7591, 0.8716]}]}, {"id": "b_1", "type": "equation", "text": "4 “Using the Triangle Inequality to Accelerate k-Means,” Charles Elkan (2003).", "words": [{"w": "4", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Using", "b": [0.1587, 0.8749, 0.2021, 0.8912]}, {"w": "the", "b": [0.2057, 0.8749, 0.2257, 0.8912]}, {"w": "Triangle", "b": [0.2293, 0.8749, 0.2818, 0.8912]}, {"w": "Inequality", "b": [0.2854, 0.8749, 0.3502, 0.8912]}, {"w": "to", "b": [0.3538, 0.8749, 0.3667, 0.8912]}, {"w": "Accelerate", "b": [0.3703, 0.8749, 0.4359, 0.8912]}, {"w": "k-Means,”", "b": [0.4395, 0.8749, 0.5028, 0.8912]}, {"w": "Charles", "b": [0.5064, 0.8749, 0.5549, 0.8912]}, {"w": "Elkan", "b": [0.5585, 0.8749, 0.595, 0.8912]}, {"w": "(2003).", "b": [0.5987, 0.8749, 0.6437, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "zations). If you are curious, a model’s inertia is accessible via the inertia_ instance variable:", "words": [{"w": "zations).", "b": [0.1429, 0.08, 0.2139, 0.1014]}, {"w": "If", "b": [0.2205, 0.08, 0.2338, 0.1014]}, {"w": "you", "b": [0.2404, 0.08, 0.2716, 0.1014]}, {"w": "are", "b": [0.2782, 0.08, 0.304, 0.1014]}, {"w": "curious,", "b": [0.3106, 0.08, 0.3778, 0.1014]}, {"w": "a", "b": [0.3844, 0.08, 0.3936, 0.1014]}, {"w": "model’s", "b": [0.4002, 0.08, 0.4628, 0.1014]}, {"w": "inertia", "b": [0.4694, 0.08, 0.524, 0.1014]}, {"w": "is", "b": [0.5306, 0.08, 0.5439, 0.1014]}, {"w": "accessible", "b": [0.5505, 0.08, 0.6317, 0.1014]}, {"w": "via", "b": [0.6383, 0.08, 0.6626, 0.1014]}, {"w": "the", "b": [0.6692, 0.08, 0.6956, 0.1014]}, {"w": "inertia_", "b": [0.7022, 0.0831, 0.7814, 0.0982]}, {"w": "instance", "b": [0.788, 0.08, 0.8571, 0.1014]}, {"w": "variable:", "b": [0.1429, 0.099, 0.2136, 0.1204]}]}, {"id": "b_3", "type": "equation", "text": ">>> kmeans.inertia_ 211.59853725816856", "words": [{"w": ">>>", "b": [0.1766, 0.131, 0.2019, 0.1438]}, {"w": "kmeans.inertia_", "b": [0.2103, 0.131, 0.3368, 0.1438]}, {"w": "211.59853725816856", "b": [0.1766, 0.1464, 0.3284, 0.1592]}]}, {"id": "b_4", "type": "paragraph", "text": "The score() method returns the negative inertia. Why negative? Well, it is because a predictor’s score() method must always respect the \"great is better\" rule.", "words": [{"w": "The", "b": [0.1429, 0.1679, 0.1757, 0.1893]}, {"w": "score()", "b": [0.1813, 0.1711, 0.2506, 0.1862]}, {"w": "method", "b": [0.2561, 0.1679, 0.3212, 0.1893]}, {"w": "returns", "b": [0.3268, 0.1679, 0.3875, 0.1893]}, {"w": "the", "b": [0.3931, 0.1679, 0.4195, 0.1893]}, {"w": "negative", "b": [0.4251, 0.1679, 0.4942, 0.1893]}, {"w": "inertia.", "b": [0.4998, 0.1679, 0.5592, 0.1893]}, {"w": "Why", "b": [0.5648, 0.1679, 0.6053, 0.1893]}, {"w": "negative?", "b": [0.6109, 0.1679, 0.6879, 0.1893]}, {"w": "Well,", "b": [0.6935, 0.1679, 0.7359, 0.1893]}, {"w": "it", "b": [0.7415, 0.1679, 0.7534, 0.1893]}, {"w": "is", "b": [0.759, 0.1679, 0.7722, 0.1893]}, {"w": "because", "b": [0.7778, 0.1679, 0.8424, 0.1893]}, {"w": "a", "b": [0.848, 0.1679, 0.8571, 0.1893]}, {"w": "predictor’s", "b": [0.1428, 0.1879, 0.2308, 0.2093]}, {"w": "score()", "b": [0.2355, 0.1911, 0.3048, 0.2061]}, {"w": "method", "b": [0.3095, 0.1879, 0.3745, 0.2093]}, {"w": "must", "b": [0.3792, 0.1879, 0.421, 0.2093]}, {"w": "always", "b": [0.4257, 0.1879, 0.4804, 0.2093]}, {"w": "respect", "b": [0.4851, 0.1879, 0.5443, 0.2093]}, {"w": "the", "b": [0.549, 0.1879, 0.5753, 0.2093]}, {"w": "\"great", "b": [0.5801, 0.1877, 0.6271, 0.2093]}, {"w": "is", "b": [0.6319, 0.1877, 0.6447, 0.2093]}, {"w": "better\"", "b": [0.6495, 0.1877, 0.7029, 0.2093]}, {"w": "rule.", "b": [0.7076, 0.1879, 0.7453, 0.2093]}]}, {"id": "b_5", "type": "equation", "text": ">>> kmeans.score(X) -211.59853725816856", "words": [{"w": ">>>", "b": [0.1766, 0.2198, 0.2019, 0.2327]}, {"w": "kmeans.score(X)", "b": [0.2103, 0.2198, 0.3368, 0.2327]}, {"w": "-211.59853725816856", "b": [0.1766, 0.2353, 0.3368, 0.2481]}]}, {"id": "b_6", "type": "paragraph", "text": "An important improvement to the K-Means algorithm, called K-Means+\\+, was pro‐ posed in a 2006 paper by David Arthur and Sergei Vassilvitskii:3 they introduced a smarter initialization step that tends to select centroids that are distant from one another, and this makes the K-Means algorithm much less likely to converge to a sub- optimal solution. They showed that the additional computation required for the smarter initialization step is well worth it since it makes it possible to drastically reduce the number of times the algorithm needs to be run to find the optimal solu‐ tion. Here is the K-Means++ initialization algorithm:", "words": [{"w": "An", "b": [0.1429, 0.2559, 0.1686, 0.2773]}, {"w": "important", "b": [0.1742, 0.2559, 0.2586, 0.2773]}, {"w": "improvement", "b": [0.2642, 0.2559, 0.3775, 0.2773]}, {"w": "to", "b": [0.383, 0.2559, 0.4, 0.2773]}, {"w": "the", "b": [0.4056, 0.2559, 0.4319, 0.2773]}, {"w": "K-Means", "b": [0.4375, 0.2559, 0.514, 0.2773]}, {"w": "algorithm,", "b": [0.5196, 0.2559, 0.607, 0.2773]}, {"w": "called", "b": [0.6125, 0.2559, 0.6609, 0.2773]}, {"w": "K-Means+\\+,", "b": [0.6665, 0.2557, 0.7782, 0.2773]}, {"w": "was", "b": [0.7838, 0.2559, 0.8149, 0.2773]}, {"w": "pro‐", "b": [0.8205, 0.2559, 0.8571, 0.2773]}, {"w": "posed", "b": [0.1429, 0.2749, 0.1919, 0.2964]}, {"w": "in", "b": [0.1992, 0.2749, 0.2162, 0.2964]}, {"w": "a", "b": [0.2235, 0.2749, 0.2327, 0.2964]}, {"w": "2006", "b": [0.24, 0.2749, 0.28, 0.2964]}, {"w": "paper", "b": [0.2873, 0.2749, 0.3345, 0.2964]}, {"w": "by", "b": [0.3418, 0.2749, 0.362, 0.2964]}, {"w": "David", "b": [0.3693, 0.2749, 0.4196, 0.2964]}, {"w": "Arthur", "b": [0.4269, 0.2749, 0.4849, 0.2964]}, {"w": "and", "b": [0.4922, 0.2749, 0.5238, 0.2964]}, {"w": "Sergei", "b": [0.5311, 0.2749, 0.5817, 0.2964]}, {"w": "Vassilvitskii:3", "b": [0.5891, 0.2749, 0.6981, 0.2964]}, {"w": "they", "b": [0.7054, 0.2749, 0.7413, 0.2964]}, {"w": "introduced", "b": [0.7487, 0.2749, 0.8407, 0.2964]}, {"w": "a", "b": [0.848, 0.2749, 0.8571, 0.2964]}, {"w": "smarter", "b": [0.1429, 0.294, 0.2074, 0.3154]}, {"w": "initialization", "b": [0.216, 0.294, 0.322, 0.3154]}, {"w": "step", "b": [0.3307, 0.294, 0.3644, 0.3154]}, {"w": "that", "b": [0.3731, 0.294, 0.4057, 0.3154]}, {"w": "tends", "b": [0.4143, 0.294, 0.4596, 0.3154]}, {"w": "to", "b": [0.4683, 0.294, 0.4852, 0.3154]}, {"w": "select", "b": [0.4939, 0.294, 0.5397, 0.3154]}, {"w": "centroids", "b": [0.5484, 0.294, 0.626, 0.3154]}, {"w": "that", "b": [0.6346, 0.294, 0.6672, 0.3154]}, {"w": "are", "b": [0.6759, 0.294, 0.7016, 0.3154]}, {"w": "distant", "b": [0.7103, 0.294, 0.7673, 0.3154]}, {"w": "from", "b": [0.776, 0.294, 0.8176, 0.3154]}, {"w": "one", "b": [0.8263, 0.294, 0.8571, 0.3154]}, {"w": "another,", "b": [0.1429, 0.313, 0.2115, 0.3345]}, {"w": "and", "b": [0.2164, 0.313, 0.2479, 0.3345]}, {"w": "this", "b": [0.2528, 0.313, 0.2835, 0.3345]}, {"w": "makes", "b": [0.2883, 0.313, 0.3414, 0.3345]}, {"w": "the", "b": [0.3462, 0.313, 0.3726, 0.3345]}, {"w": "K-Means", "b": [0.3774, 0.313, 0.4539, 0.3345]}, {"w": "algorithm", "b": [0.4588, 0.313, 0.5414, 0.3345]}, {"w": "much", "b": [0.5462, 0.313, 0.5939, 0.3345]}, {"w": "less", "b": [0.5988, 0.313, 0.6282, 0.3345]}, {"w": "likely", "b": [0.633, 0.313, 0.6779, 0.3345]}, {"w": "to", "b": [0.6828, 0.313, 0.6997, 0.3345]}, {"w": "converge", "b": [0.7046, 0.313, 0.7798, 0.3345]}, {"w": "to", "b": [0.7846, 0.313, 0.8016, 0.3345]}, {"w": "a", "b": [0.8064, 0.313, 0.8156, 0.3345]}, {"w": "sub-", "b": [0.8204, 0.313, 0.8572, 0.3345]}, {"w": "optimal", "b": [0.1429, 0.3321, 0.2078, 0.3535]}, {"w": "solution.", "b": [0.2175, 0.3321, 0.2908, 0.3535]}, {"w": "They", "b": [0.3005, 0.3321, 0.3428, 0.3535]}, {"w": "showed", "b": [0.3525, 0.3321, 0.416, 0.3535]}, {"w": "that", "b": [0.4257, 0.3321, 0.4583, 0.3535]}, {"w": "the", "b": [0.4679, 0.3321, 0.4943, 0.3535]}, {"w": "additional", "b": [0.5039, 0.3321, 0.589, 0.3535]}, {"w": "computation", "b": [0.5987, 0.3321, 0.7058, 0.3535]}, {"w": "required", "b": [0.7155, 0.3321, 0.787, 0.3535]}, {"w": "for", "b": [0.7966, 0.3321, 0.8212, 0.3535]}, {"w": "the", "b": [0.8308, 0.3321, 0.8571, 0.3535]}, {"w": "smarter", "b": [0.1429, 0.3511, 0.2074, 0.3726]}, {"w": "initialization", "b": [0.216, 0.3511, 0.322, 0.3726]}, {"w": "step", "b": [0.3306, 0.3511, 0.3644, 0.3726]}, {"w": "is", "b": [0.373, 0.3511, 0.3862, 0.3726]}, {"w": "well", "b": [0.3949, 0.3511, 0.4285, 0.3726]}, {"w": "worth", "b": [0.4372, 0.3511, 0.4873, 0.3726]}, {"w": "it", "b": [0.4959, 0.3511, 0.5079, 0.3726]}, {"w": "since", "b": [0.5165, 0.3511, 0.5588, 0.3726]}, {"w": "it", "b": [0.5674, 0.3511, 0.5794, 0.3726]}, {"w": "makes", "b": [0.588, 0.3511, 0.641, 0.3726]}, {"w": "it", "b": [0.6497, 0.3511, 0.6616, 0.3726]}, {"w": "possible", "b": [0.6702, 0.3511, 0.7374, 0.3726]}, {"w": "to", "b": [0.746, 0.3511, 0.763, 0.3726]}, {"w": "drastically", "b": [0.7716, 0.3511, 0.8571, 0.3726]}, {"w": "reduce", "b": [0.1429, 0.3702, 0.1992, 0.3916]}, {"w": "the", "b": [0.2055, 0.3702, 0.2319, 0.3916]}, {"w": "number", "b": [0.2382, 0.3702, 0.3045, 0.3916]}, {"w": "of", "b": [0.3109, 0.3702, 0.3277, 0.3916]}, {"w": "times", "b": [0.334, 0.3702, 0.3795, 0.3916]}, {"w": "the", "b": [0.3859, 0.3702, 0.4122, 0.3916]}, {"w": "algorithm", "b": [0.4185, 0.3702, 0.5012, 0.3916]}, {"w": "needs", "b": [0.5075, 0.3702, 0.5553, 0.3916]}, {"w": "to", "b": [0.5616, 0.3702, 0.5786, 0.3916]}, {"w": "be", "b": [0.585, 0.3702, 0.6044, 0.3916]}, {"w": "run", "b": [0.6108, 0.3702, 0.641, 0.3916]}, {"w": "to", "b": [0.6473, 0.3702, 0.6643, 0.3916]}, {"w": "find", "b": [0.6706, 0.3702, 0.7048, 0.3916]}, {"w": "the", "b": [0.7111, 0.3702, 0.7375, 0.3916]}, {"w": "optimal", "b": [0.7438, 0.3702, 0.8088, 0.3916]}, {"w": "solu‐", "b": [0.8151, 0.3702, 0.8572, 0.3916]}, {"w": "tion.", "b": [0.1429, 0.3892, 0.1816, 0.4106]}, {"w": "Here", "b": [0.1863, 0.3892, 0.2272, 0.4106]}, {"w": "is", "b": [0.2319, 0.3892, 0.2451, 0.4106]}, {"w": "the", "b": [0.2499, 0.3892, 0.2762, 0.4106]}, {"w": "K-Means++", "b": [0.2809, 0.3892, 0.3816, 0.4106]}, {"w": "initialization", "b": [0.3863, 0.3892, 0.4923, 0.4106]}, {"w": "algorithm:", "b": [0.497, 0.3892, 0.5844, 0.4106]}]}, {"id": "b_7", "type": "paragraph", "text": "• Take one centroid c(1), chosen uniformly at random from the dataset.", "words": [{"w": "•", "b": [0.16, 0.4234, 0.1682, 0.4448]}, {"w": "Take", "b": [0.1786, 0.4234, 0.2178, 0.4448]}, {"w": "one", "b": [0.2226, 0.4234, 0.2534, 0.4448]}, {"w": "centroid", "b": [0.2582, 0.4234, 0.3281, 0.4448]}, {"w": "c(1),", "b": [0.3329, 0.4228, 0.361, 0.4448]}, {"w": "chosen", "b": [0.3658, 0.4234, 0.4242, 0.4448]}, {"w": "uniformly", "b": [0.429, 0.4234, 0.5134, 0.4448]}, {"w": "at", "b": [0.5182, 0.4234, 0.5333, 0.4448]}, {"w": "random", "b": [0.538, 0.4234, 0.6049, 0.4448]}, {"w": "from", "b": [0.6097, 0.4234, 0.6513, 0.4448]}, {"w": "the", "b": [0.656, 0.4234, 0.6823, 0.4448]}, {"w": "dataset.", "b": [0.687, 0.4234, 0.7499, 0.4448]}]}, {"id": "b_8", "type": "paragraph", "text": "• Take a new centroid c(i), choosing an instance x(i) with probability: D �i 2", "words": [{"w": "•", "b": [0.16, 0.4553, 0.1682, 0.4767]}, {"w": "Take", "b": [0.1786, 0.4553, 0.2178, 0.4767]}, {"w": "a", "b": [0.2282, 0.4553, 0.2374, 0.4767]}, {"w": "new", "b": [0.2478, 0.4553, 0.2823, 0.4767]}, {"w": "centroid", "b": [0.2927, 0.4553, 0.3627, 0.4767]}, {"w": "c(i),", "b": [0.3731, 0.4547, 0.3987, 0.4767]}, {"w": "choosing", "b": [0.4091, 0.4553, 0.4847, 0.4767]}, {"w": "an", "b": [0.4951, 0.4553, 0.5156, 0.4767]}, {"w": "instance", "b": [0.5261, 0.4553, 0.5952, 0.4767]}, {"w": "x(i)", "b": [0.6057, 0.4547, 0.6278, 0.4767]}, {"w": "with", "b": [0.6382, 0.4553, 0.6755, 0.4767]}, {"w": "probability:", "b": [0.6859, 0.4553, 0.7832, 0.4767]}, {"w": "D", "b": [0.7937, 0.4551, 0.8084, 0.4767]}, {"w": "�i", "b": [0.8156, 0.451, 0.8368, 0.4744]}, {"w": "2", "b": [0.8495, 0.4479, 0.8571, 0.4642]}]}, {"id": "b_9", "type": "equation", "text": "∑j = 1", "words": [{"w": "∑j", "b": [0.1786, 0.4821, 0.1956, 0.5073]}, {"w": "=", "b": [0.2, 0.491, 0.2092, 0.5073]}, {"w": "1", "b": [0.2136, 0.491, 0.2212, 0.5073]}]}, {"id": "b_10", "type": "paragraph", "text": "m D �j 2 where D(x(i)) is the distance between the instance x(i) and the closest centroid that was already chosen. This probability distribution ensures that instances further away from already chosen centroids are much more likely be selected as centroids.", "words": [{"w": "m", "b": [0.1897, 0.4787, 0.2022, 0.4952]}, {"w": "D", "b": [0.2235, 0.4818, 0.2383, 0.5035]}, {"w": "�j", "b": [0.2455, 0.4778, 0.2682, 0.5012]}, {"w": "2", "b": [0.2809, 0.4747, 0.2885, 0.491]}, {"w": "where", "b": [0.2933, 0.4821, 0.3442, 0.5035]}, {"w": "D(x(i))", "b": [0.3489, 0.4815, 0.4008, 0.5035]}, {"w": "is", "b": [0.4055, 0.4821, 0.4188, 0.5035]}, {"w": "the", "b": [0.4235, 0.4821, 0.4498, 0.5035]}, {"w": "distance", "b": [0.4546, 0.4821, 0.5233, 0.5035]}, {"w": "between", "b": [0.5281, 0.4821, 0.5972, 0.5035]}, {"w": "the", "b": [0.602, 0.4821, 0.6283, 0.5035]}, {"w": "instance", "b": [0.633, 0.4821, 0.7022, 0.5035]}, {"w": "x(i)", "b": [0.7075, 0.4815, 0.7296, 0.5035]}, {"w": "and", "b": [0.7344, 0.4821, 0.766, 0.5035]}, {"w": "the", "b": [0.7707, 0.4821, 0.797, 0.5035]}, {"w": "closest", "b": [0.8018, 0.4821, 0.857, 0.5035]}, {"w": "centroid", "b": [0.1786, 0.5037, 0.2485, 0.5251]}, {"w": "that", "b": [0.2593, 0.5037, 0.2918, 0.5251]}, {"w": "was", "b": [0.3026, 0.5037, 0.3336, 0.5251]}, {"w": "already", "b": [0.3444, 0.5037, 0.4051, 0.5251]}, {"w": "chosen.", "b": [0.4158, 0.5037, 0.479, 0.5251]}, {"w": "This", "b": [0.4898, 0.5037, 0.527, 0.5251]}, {"w": "probability", "b": [0.5377, 0.5037, 0.6297, 0.5251]}, {"w": "distribution", "b": [0.6404, 0.5037, 0.7399, 0.5251]}, {"w": "ensures", "b": [0.7506, 0.5037, 0.8138, 0.5251]}, {"w": "that", "b": [0.8246, 0.5037, 0.8571, 0.5251]}, {"w": "instances", "b": [0.1786, 0.5227, 0.2554, 0.5441]}, {"w": "further", "b": [0.2628, 0.5227, 0.3218, 0.5441]}, {"w": "away", "b": [0.3292, 0.5227, 0.3705, 0.5441]}, {"w": "from", "b": [0.3779, 0.5227, 0.4195, 0.5441]}, {"w": "already", "b": [0.4268, 0.5227, 0.4876, 0.5441]}, {"w": "chosen", "b": [0.4949, 0.5227, 0.5534, 0.5441]}, {"w": "centroids", "b": [0.5607, 0.5227, 0.6383, 0.5441]}, {"w": "are", "b": [0.6457, 0.5227, 0.6714, 0.5441]}, {"w": "much", "b": [0.6788, 0.5227, 0.7265, 0.5441]}, {"w": "more", "b": [0.7338, 0.5227, 0.7781, 0.5441]}, {"w": "likely", "b": [0.7855, 0.5227, 0.8303, 0.5441]}, {"w": "be", "b": [0.8377, 0.5227, 0.8571, 0.5441]}, {"w": "selected", "b": [0.1786, 0.5418, 0.2442, 0.5632]}, {"w": "as", "b": [0.2489, 0.5418, 0.2657, 0.5632]}, {"w": "centroids.", "b": [0.2705, 0.5418, 0.3528, 0.5632]}]}, {"id": "b_11", "type": "paragraph", "text": "• Repeat the previous step until all k centroids have been chosen.", "words": [{"w": "•", "b": [0.16, 0.5669, 0.1682, 0.5883]}, {"w": "Repeat", "b": [0.1786, 0.5669, 0.2352, 0.5883]}, {"w": "the", "b": [0.24, 0.5669, 0.2663, 0.5883]}, {"w": "previous", "b": [0.271, 0.5669, 0.3431, 0.5883]}, {"w": "step", "b": [0.3478, 0.5669, 0.3816, 0.5883]}, {"w": "until", "b": [0.3863, 0.5669, 0.4256, 0.5883]}, {"w": "all", "b": [0.4303, 0.5669, 0.45, 0.5883]}, {"w": "k", "b": [0.4547, 0.5667, 0.4645, 0.5883]}, {"w": "centroids", "b": [0.4693, 0.5669, 0.5469, 0.5883]}, {"w": "have", "b": [0.5516, 0.5669, 0.59, 0.5883]}, {"w": "been", "b": [0.5947, 0.5669, 0.6344, 0.5883]}, {"w": "chosen.", "b": [0.6391, 0.5669, 0.7023, 0.5883]}]}, {"id": "b_12", "type": "paragraph", "text": "The KMeans class actually uses this initialization method by default. If you want to force it to use the original method (i.e., picking k instances randomly to define the initial centroids), then you can set the init hyperparameter to \"random\". You will rarely need to do this.", "words": [{"w": "The", "b": [0.1429, 0.6019, 0.1757, 0.6233]}, {"w": "KMeans", "b": [0.1832, 0.6051, 0.2426, 0.6202]}, {"w": "class", "b": [0.2501, 0.6019, 0.2886, 0.6233]}, {"w": "actually", "b": [0.2961, 0.6019, 0.3607, 0.6233]}, {"w": "uses", "b": [0.3682, 0.6019, 0.4034, 0.6233]}, {"w": "this", "b": [0.4109, 0.6019, 0.4416, 0.6233]}, {"w": "initialization", "b": [0.4491, 0.6019, 0.555, 0.6233]}, {"w": "method", "b": [0.5625, 0.6019, 0.6276, 0.6233]}, {"w": "by", "b": [0.6351, 0.6019, 0.6552, 0.6233]}, {"w": "default.", "b": [0.6627, 0.6019, 0.7249, 0.6233]}, {"w": "If", "b": [0.7324, 0.6019, 0.7457, 0.6233]}, {"w": "you", "b": [0.7532, 0.6019, 0.7844, 0.6233]}, {"w": "want", "b": [0.7919, 0.6019, 0.8327, 0.6233]}, {"w": "to", "b": [0.8402, 0.6019, 0.8571, 0.6233]}, {"w": "force", "b": [0.1429, 0.621, 0.185, 0.6424]}, {"w": "it", "b": [0.192, 0.621, 0.2039, 0.6424]}, {"w": "to", "b": [0.2109, 0.621, 0.2279, 0.6424]}, {"w": "use", "b": [0.2348, 0.621, 0.2624, 0.6424]}, {"w": "the", "b": [0.2693, 0.621, 0.2957, 0.6424]}, {"w": "original", "b": [0.3026, 0.621, 0.3677, 0.6424]}, {"w": "method", "b": [0.3746, 0.621, 0.4397, 0.6424]}, {"w": "(i.e.,", "b": [0.4466, 0.621, 0.4825, 0.6424]}, {"w": "picking", "b": [0.4895, 0.621, 0.5518, 0.6424]}, {"w": "k", "b": [0.5588, 0.6208, 0.5686, 0.6424]}, {"w": "instances", "b": [0.5755, 0.621, 0.6524, 0.6424]}, {"w": "randomly", "b": [0.6593, 0.621, 0.7411, 0.6424]}, {"w": "to", "b": [0.7481, 0.621, 0.765, 0.6424]}, {"w": "define", "b": [0.772, 0.621, 0.8239, 0.6424]}, {"w": "the", "b": [0.8308, 0.621, 0.8571, 0.6424]}, {"w": "initial", "b": [0.1429, 0.6409, 0.1918, 0.6623]}, {"w": "centroids),", "b": [0.1994, 0.6409, 0.289, 0.6623]}, {"w": "then", "b": [0.2966, 0.6409, 0.3343, 0.6623]}, {"w": "you", "b": [0.342, 0.6409, 0.3732, 0.6623]}, {"w": "can", "b": [0.3808, 0.6409, 0.4102, 0.6623]}, {"w": "set", "b": [0.4178, 0.6409, 0.4407, 0.6623]}, {"w": "the", "b": [0.4483, 0.6409, 0.4746, 0.6623]}, {"w": "init", "b": [0.4823, 0.6441, 0.5219, 0.6592]}, {"w": "hyperparameter", "b": [0.5295, 0.6409, 0.663, 0.6623]}, {"w": "to", "b": [0.6706, 0.6409, 0.6876, 0.6623]}, {"w": "\"random\".", "b": [0.6952, 0.6409, 0.7791, 0.6623]}, {"w": "You", "b": [0.7868, 0.6409, 0.8191, 0.6623]}, {"w": "will", "b": [0.8268, 0.6409, 0.8572, 0.6623]}, {"w": "rarely", "b": [0.1429, 0.66, 0.1912, 0.6814]}, {"w": "need", "b": [0.1959, 0.66, 0.236, 0.6814]}, {"w": "to", "b": [0.2407, 0.66, 0.2577, 0.6814]}, {"w": "do", "b": [0.2624, 0.66, 0.284, 0.6814]}, {"w": "this.", "b": [0.2888, 0.66, 0.3242, 0.6814]}]}, {"id": "b_13", "type": "equation", "text": "Accelerated K-Means and Mini-batch K-Means", "words": [{"w": "Accelerated", "b": [0.1429, 0.6973, 0.2311, 0.7182]}, {"w": "K-Means", "b": [0.2347, 0.6973, 0.3002, 0.7182]}, {"w": "and", "b": [0.3038, 0.6973, 0.3326, 0.7182]}, {"w": "Mini-batch", "b": [0.3362, 0.6973, 0.4184, 0.7182]}, {"w": "K-Means", "b": [0.4221, 0.6973, 0.4875, 0.7182]}]}, {"id": "b_14", "type": "paragraph", "text": "Another important improvement to the K-Means algorithm was proposed in a 2003 paper by Charles Elkan.4 It considerably accelerates the algorithm by avoiding many unnecessary distance calculations: this is achieved by exploiting the triangle inequal‐", "words": [{"w": "Another", "b": [0.1429, 0.7239, 0.2133, 0.7453]}, {"w": "important", "b": [0.2195, 0.7239, 0.3039, 0.7453]}, {"w": "improvement", "b": [0.3101, 0.7239, 0.4234, 0.7453]}, {"w": "to", "b": [0.4296, 0.7239, 0.4466, 0.7453]}, {"w": "the", "b": [0.4528, 0.7239, 0.4791, 0.7453]}, {"w": "K-Means", "b": [0.4853, 0.7239, 0.5618, 0.7453]}, {"w": "algorithm", "b": [0.568, 0.7239, 0.6506, 0.7453]}, {"w": "was", "b": [0.6568, 0.7239, 0.6879, 0.7453]}, {"w": "proposed", "b": [0.6941, 0.7239, 0.7724, 0.7453]}, {"w": "in", "b": [0.7786, 0.7239, 0.7956, 0.7453]}, {"w": "a", "b": [0.8018, 0.7239, 0.8109, 0.7453]}, {"w": "2003", "b": [0.8171, 0.7239, 0.8571, 0.7453]}, {"w": "paper", "b": [0.1428, 0.7429, 0.19, 0.7644]}, {"w": "by", "b": [0.1963, 0.7429, 0.2164, 0.7644]}, {"w": "Charles", "b": [0.2227, 0.7429, 0.2863, 0.7644]}, {"w": "Elkan.4", "b": [0.2925, 0.7429, 0.351, 0.7644]}, {"w": "It", "b": [0.3573, 0.7429, 0.3699, 0.7644]}, {"w": "considerably", "b": [0.3762, 0.7429, 0.4824, 0.7644]}, {"w": "accelerates", "b": [0.4886, 0.7429, 0.5777, 0.7644]}, {"w": "the", "b": [0.584, 0.7429, 0.6103, 0.7644]}, {"w": "algorithm", "b": [0.6165, 0.7429, 0.6992, 0.7644]}, {"w": "by", "b": [0.7054, 0.7429, 0.7256, 0.7644]}, {"w": "avoiding", "b": [0.7318, 0.7429, 0.8042, 0.7644]}, {"w": "many", "b": [0.8105, 0.7429, 0.8571, 0.7644]}, {"w": "unnecessary", "b": [0.1429, 0.762, 0.2456, 0.7834]}, {"w": "distance", "b": [0.2514, 0.762, 0.3202, 0.7834]}, {"w": "calculations:", "b": [0.326, 0.762, 0.4295, 0.7834]}, {"w": "this", "b": [0.4353, 0.762, 0.466, 0.7834]}, {"w": "is", "b": [0.4718, 0.762, 0.4851, 0.7834]}, {"w": "achieved", "b": [0.4909, 0.762, 0.5639, 0.7834]}, {"w": "by", "b": [0.5697, 0.762, 0.5899, 0.7834]}, {"w": "exploiting", "b": [0.5957, 0.762, 0.6799, 0.7834]}, {"w": "the", "b": [0.6857, 0.762, 0.712, 0.7834]}, {"w": "triangle", "b": [0.7179, 0.762, 0.7819, 0.7834]}, {"w": "inequal‐", "b": [0.7878, 0.762, 0.8571, 0.7834]}]}, {"id": "b_15", "type": "paragraph", "text": "Clustering | 245", "words": [{"w": "Clustering", "b": [0.736, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "245", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 272, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "5 The triangle inequality is AC ≤ AB + BC where A, B and C are three points, and AB, AC and BC are the distances between these points.", "words": [{"w": "5", "b": [0.1451, 0.8416, 0.1518, 0.8559]}, {"w": "The", "b": [0.1587, 0.8401, 0.1837, 0.8565]}, {"w": "triangle", "b": [0.1873, 0.8401, 0.2362, 0.8565]}, {"w": "inequality", "b": [0.2398, 0.8401, 0.3034, 0.8565]}, {"w": "is", "b": [0.307, 0.8401, 0.317, 0.8565]}, {"w": "AC", "b": [0.3207, 0.8401, 0.3417, 0.8565]}, {"w": "≤", "b": [0.3453, 0.8401, 0.3545, 0.8565]}, {"w": "AB", "b": [0.3581, 0.8401, 0.3784, 0.8565]}, {"w": "+", "b": [0.382, 0.8401, 0.3912, 0.8565]}, {"w": "BC", "b": [0.3948, 0.8401, 0.415, 0.8565]}, {"w": "where", "b": [0.4187, 0.8401, 0.4574, 0.8565]}, {"w": "A,", "b": [0.461, 0.8401, 0.4756, 0.8565]}, {"w": "B", "b": [0.4792, 0.8401, 0.4885, 0.8565]}, {"w": "and", "b": [0.4921, 0.8401, 0.5161, 0.8565]}, {"w": "C", "b": [0.5197, 0.8401, 0.5303, 0.8565]}, {"w": "are", "b": [0.5339, 0.8401, 0.5535, 0.8565]}, {"w": "three", "b": [0.5571, 0.8401, 0.5898, 0.8565]}, {"w": "points,", "b": [0.5934, 0.8401, 0.6367, 0.8565]}, {"w": "and", "b": [0.6403, 0.8401, 0.6644, 0.8565]}, {"w": "AB,", "b": [0.668, 0.8401, 0.6916, 0.8565]}, {"w": "AC", "b": [0.6952, 0.8401, 0.7163, 0.8565]}, {"w": "and", "b": [0.7199, 0.8401, 0.744, 0.8565]}, {"w": "BC", "b": [0.7476, 0.8401, 0.7678, 0.8565]}, {"w": "are", "b": [0.7714, 0.8401, 0.791, 0.8565]}, {"w": "the", "b": [0.7946, 0.8401, 0.8146, 0.8565]}, {"w": "distances", "b": [0.1587, 0.8553, 0.217, 0.8716]}, {"w": "between", "b": [0.2206, 0.8553, 0.2733, 0.8716]}, {"w": "these", "b": [0.2769, 0.8553, 0.3095, 0.8716]}, {"w": "points.", "b": [0.3131, 0.8553, 0.3564, 0.8716]}]}, {"id": "b_1", "type": "equation", "text": "6 “Web-Scale K-Means Clustering,” David Sculley (2010).", "words": [{"w": "6", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Web-Scale", "b": [0.1587, 0.8749, 0.2313, 0.8912]}, {"w": "K-Means", "b": [0.235, 0.8749, 0.2932, 0.8912]}, {"w": "Clustering,”", "b": [0.2968, 0.8749, 0.3713, 0.8912]}, {"w": "David", "b": [0.3749, 0.8749, 0.4132, 0.8912]}, {"w": "Sculley", "b": [0.4168, 0.8749, 0.4616, 0.8912]}, {"w": "(2010).", "b": [0.4652, 0.8749, 0.5103, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "ity (i.e., the straight line is always the shortest5) and by keeping track of lower and upper bounds for distances between instances and centroids. This is the algorithm used by default by the KMeans class (but you can force it to use the original algorithm by setting the algorithm hyperparameter to \"full\", although you probably will never need to).", "words": [{"w": "ity", "b": [0.1429, 0.0791, 0.1644, 0.1005]}, {"w": "(i.e.,", "b": [0.1715, 0.0791, 0.2074, 0.1005]}, {"w": "the", "b": [0.2146, 0.0791, 0.241, 0.1005]}, {"w": "straight", "b": [0.2482, 0.0791, 0.3114, 0.1005]}, {"w": "line", "b": [0.3186, 0.0791, 0.3497, 0.1005]}, {"w": "is", "b": [0.3569, 0.0791, 0.3702, 0.1005]}, {"w": "always", "b": [0.3773, 0.0791, 0.432, 0.1005]}, {"w": "the", "b": [0.4392, 0.0791, 0.4655, 0.1005]}, {"w": "shortest5)", "b": [0.4727, 0.0791, 0.552, 0.1005]}, {"w": "and", "b": [0.5592, 0.0791, 0.5907, 0.1005]}, {"w": "by", "b": [0.5979, 0.0791, 0.618, 0.1005]}, {"w": "keeping", "b": [0.6252, 0.0791, 0.6909, 0.1005]}, {"w": "track", "b": [0.6981, 0.0791, 0.7405, 0.1005]}, {"w": "of", "b": [0.7477, 0.0791, 0.7645, 0.1005]}, {"w": "lower", "b": [0.7717, 0.0791, 0.8184, 0.1005]}, {"w": "and", "b": [0.8256, 0.0791, 0.8571, 0.1005]}, {"w": "upper", "b": [0.1429, 0.0981, 0.1923, 0.1195]}, {"w": "bounds", "b": [0.1998, 0.0981, 0.2621, 0.1195]}, {"w": "for", "b": [0.2696, 0.0981, 0.2941, 0.1195]}, {"w": "distances", "b": [0.3016, 0.0981, 0.378, 0.1195]}, {"w": "between", "b": [0.3855, 0.0981, 0.4547, 0.1195]}, {"w": "instances", "b": [0.4621, 0.0981, 0.539, 0.1195]}, {"w": "and", "b": [0.5465, 0.0981, 0.578, 0.1195]}, {"w": "centroids.", "b": [0.5855, 0.0981, 0.6678, 0.1195]}, {"w": "This", "b": [0.6753, 0.0981, 0.7125, 0.1195]}, {"w": "is", "b": [0.72, 0.0981, 0.7332, 0.1195]}, {"w": "the", "b": [0.7407, 0.0981, 0.767, 0.1195]}, {"w": "algorithm", "b": [0.7745, 0.0981, 0.8571, 0.1195]}, {"w": "used", "b": [0.1429, 0.1181, 0.1814, 0.1395]}, {"w": "by", "b": [0.1868, 0.1181, 0.2069, 0.1395]}, {"w": "default", "b": [0.2122, 0.1181, 0.2697, 0.1395]}, {"w": "by", "b": [0.275, 0.1181, 0.2952, 0.1395]}, {"w": "the", "b": [0.3005, 0.1181, 0.3268, 0.1395]}, {"w": "KMeans", "b": [0.3321, 0.1212, 0.3915, 0.1363]}, {"w": "class", "b": [0.3968, 0.1181, 0.4353, 0.1395]}, {"w": "(but", "b": [0.4407, 0.1181, 0.4759, 0.1395]}, {"w": "you", "b": [0.4812, 0.1181, 0.5125, 0.1395]}, {"w": "can", "b": [0.5178, 0.1181, 0.5471, 0.1395]}, {"w": "force", "b": [0.5525, 0.1181, 0.5946, 0.1395]}, {"w": "it", "b": [0.6, 0.1181, 0.6119, 0.1395]}, {"w": "to", "b": [0.6172, 0.1181, 0.6342, 0.1395]}, {"w": "use", "b": [0.6395, 0.1181, 0.6671, 0.1395]}, {"w": "the", "b": [0.6724, 0.1181, 0.6988, 0.1395]}, {"w": "original", "b": [0.7041, 0.1181, 0.7692, 0.1395]}, {"w": "algorithm", "b": [0.7745, 0.1181, 0.8571, 0.1395]}, {"w": "by", "b": [0.1428, 0.138, 0.163, 0.1594]}, {"w": "setting", "b": [0.1728, 0.138, 0.2287, 0.1594]}, {"w": "the", "b": [0.2385, 0.138, 0.2648, 0.1594]}, {"w": "algorithm", "b": [0.2746, 0.1412, 0.3636, 0.1563]}, {"w": "hyperparameter", "b": [0.3734, 0.138, 0.5069, 0.1594]}, {"w": "to", "b": [0.5167, 0.138, 0.5336, 0.1594]}, {"w": "\"full\",", "b": [0.5434, 0.138, 0.6075, 0.1594]}, {"w": "although", "b": [0.6173, 0.138, 0.6918, 0.1594]}, {"w": "you", "b": [0.7015, 0.138, 0.7328, 0.1594]}, {"w": "probably", "b": [0.7426, 0.138, 0.817, 0.1594]}, {"w": "will", "b": [0.8267, 0.138, 0.8571, 0.1594]}, {"w": "never", "b": [0.1429, 0.157, 0.1893, 0.1785]}, {"w": "need", "b": [0.1941, 0.157, 0.2342, 0.1785]}, {"w": "to).", "b": [0.2389, 0.157, 0.2678, 0.1785]}]}, {"id": "b_3", "type": "paragraph", "text": "Yet another important variant of the K-Means algorithm was proposed in a 2010 paper by David Sculley.6 Instead of using the full dataset at each iteration, the algo‐ rithm is capable of using mini-batches, moving the centroids just slightly at each iter‐ ation. This speeds up the algorithm typically by a factor of 3 or 4 and makes it possible to cluster huge datasets that do not fit in memory. Scikit-Learn implements this algorithm in the MiniBatchKMeans class. You can just use this class like the KMeans class:", "words": [{"w": "Yet", "b": [0.1429, 0.1852, 0.1687, 0.2066]}, {"w": "another", "b": [0.1773, 0.1852, 0.2425, 0.2066]}, {"w": "important", "b": [0.251, 0.1852, 0.3354, 0.2066]}, {"w": "variant", "b": [0.344, 0.1852, 0.4026, 0.2066]}, {"w": "of", "b": [0.4111, 0.1852, 0.4279, 0.2066]}, {"w": "the", "b": [0.4364, 0.1852, 0.4628, 0.2066]}, {"w": "K-Means", "b": [0.4713, 0.1852, 0.5478, 0.2066]}, {"w": "algorithm", "b": [0.5563, 0.1852, 0.639, 0.2066]}, {"w": "was", "b": [0.6475, 0.1852, 0.6786, 0.2066]}, {"w": "proposed", "b": [0.6871, 0.1852, 0.7654, 0.2066]}, {"w": "in", "b": [0.774, 0.1852, 0.7909, 0.2066]}, {"w": "a", "b": [0.7995, 0.1852, 0.8086, 0.2066]}, {"w": "2010", "b": [0.8172, 0.1852, 0.8572, 0.2066]}, {"w": "paper", "b": [0.1429, 0.2042, 0.19, 0.2256]}, {"w": "by", "b": [0.1968, 0.2042, 0.217, 0.2256]}, {"w": "David", "b": [0.2238, 0.2042, 0.2741, 0.2256]}, {"w": "Sculley.6", "b": [0.2809, 0.2042, 0.3486, 0.2256]}, {"w": "Instead", "b": [0.3554, 0.2042, 0.4169, 0.2256]}, {"w": "of", "b": [0.4237, 0.2042, 0.4405, 0.2256]}, {"w": "using", "b": [0.4474, 0.2042, 0.4928, 0.2256]}, {"w": "the", "b": [0.4996, 0.2042, 0.526, 0.2256]}, {"w": "full", "b": [0.5328, 0.2042, 0.5605, 0.2256]}, {"w": "dataset", "b": [0.5674, 0.2042, 0.6255, 0.2256]}, {"w": "at", "b": [0.6323, 0.2042, 0.6474, 0.2256]}, {"w": "each", "b": [0.6542, 0.2042, 0.6922, 0.2256]}, {"w": "iteration,", "b": [0.699, 0.2042, 0.775, 0.2256]}, {"w": "the", "b": [0.7818, 0.2042, 0.8081, 0.2256]}, {"w": "algo‐", "b": [0.8149, 0.2042, 0.8571, 0.2256]}, {"w": "rithm", "b": [0.1429, 0.2233, 0.1907, 0.2447]}, {"w": "is", "b": [0.1959, 0.2233, 0.2091, 0.2447]}, {"w": "capable", "b": [0.2143, 0.2233, 0.2766, 0.2447]}, {"w": "of", "b": [0.2818, 0.2233, 0.2986, 0.2447]}, {"w": "using", "b": [0.3037, 0.2233, 0.3492, 0.2447]}, {"w": "mini-batches,", "b": [0.3543, 0.2233, 0.4683, 0.2447]}, {"w": "moving", "b": [0.4734, 0.2233, 0.5375, 0.2447]}, {"w": "the", "b": [0.5427, 0.2233, 0.569, 0.2447]}, {"w": "centroids", "b": [0.5742, 0.2233, 0.6518, 0.2447]}, {"w": "just", "b": [0.6569, 0.2233, 0.6873, 0.2447]}, {"w": "slightly", "b": [0.6925, 0.2233, 0.7527, 0.2447]}, {"w": "at", "b": [0.7578, 0.2233, 0.7729, 0.2447]}, {"w": "each", "b": [0.7781, 0.2233, 0.816, 0.2447]}, {"w": "iter‐", "b": [0.8212, 0.2233, 0.8571, 0.2447]}, {"w": "ation.", "b": [0.1428, 0.2423, 0.1903, 0.2637]}, {"w": "This", "b": [0.1993, 0.2423, 0.2365, 0.2637]}, {"w": "speeds", "b": [0.2454, 0.2423, 0.3004, 0.2637]}, {"w": "up", "b": [0.3093, 0.2423, 0.3313, 0.2637]}, {"w": "the", "b": [0.3403, 0.2423, 0.3666, 0.2637]}, {"w": "algorithm", "b": [0.3756, 0.2423, 0.4582, 0.2637]}, {"w": "typically", "b": [0.4672, 0.2423, 0.5377, 0.2637]}, {"w": "by", "b": [0.5466, 0.2423, 0.5668, 0.2637]}, {"w": "a", "b": [0.5758, 0.2423, 0.5849, 0.2637]}, {"w": "factor", "b": [0.5939, 0.2423, 0.6427, 0.2637]}, {"w": "of", "b": [0.6517, 0.2423, 0.6685, 0.2637]}, {"w": "3", "b": [0.6774, 0.2423, 0.6874, 0.2637]}, {"w": "or", "b": [0.6964, 0.2423, 0.7147, 0.2637]}, {"w": "4", "b": [0.7237, 0.2423, 0.7337, 0.2637]}, {"w": "and", "b": [0.7427, 0.2423, 0.7742, 0.2637]}, {"w": "makes", "b": [0.7832, 0.2423, 0.8362, 0.2637]}, {"w": "it", "b": [0.8452, 0.2423, 0.8571, 0.2637]}, {"w": "possible", "b": [0.1429, 0.2614, 0.21, 0.2828]}, {"w": "to", "b": [0.2163, 0.2614, 0.2333, 0.2828]}, {"w": "cluster", "b": [0.2395, 0.2614, 0.2953, 0.2828]}, {"w": "huge", "b": [0.3015, 0.2614, 0.3419, 0.2828]}, {"w": "datasets", "b": [0.3482, 0.2614, 0.414, 0.2828]}, {"w": "that", "b": [0.4203, 0.2614, 0.4528, 0.2828]}, {"w": "do", "b": [0.4591, 0.2614, 0.4808, 0.2828]}, {"w": "not", "b": [0.487, 0.2614, 0.5154, 0.2828]}, {"w": "fit", "b": [0.5217, 0.2614, 0.5398, 0.2828]}, {"w": "in", "b": [0.5461, 0.2614, 0.5631, 0.2828]}, {"w": "memory.", "b": [0.5694, 0.2614, 0.6441, 0.2828]}, {"w": "Scikit-Learn", "b": [0.6504, 0.2614, 0.7527, 0.2828]}, {"w": "implements", "b": [0.7589, 0.2614, 0.8571, 0.2828]}, {"w": "this", "b": [0.1429, 0.2813, 0.1736, 0.3027]}, {"w": "algorithm", "b": [0.1828, 0.2813, 0.2655, 0.3027]}, {"w": "in", "b": [0.2748, 0.2813, 0.2918, 0.3027]}, {"w": "the", "b": [0.301, 0.2813, 0.3274, 0.3027]}, {"w": "MiniBatchKMeans", "b": [0.3366, 0.2845, 0.4851, 0.2996]}, {"w": "class.", "b": [0.4944, 0.2813, 0.5376, 0.3027]}, {"w": "You", "b": [0.5469, 0.2813, 0.5793, 0.3027]}, {"w": "can", "b": [0.5885, 0.2813, 0.6179, 0.3027]}, {"w": "just", "b": [0.6272, 0.2813, 0.6576, 0.3027]}, {"w": "use", "b": [0.6669, 0.2813, 0.6944, 0.3027]}, {"w": "this", "b": [0.7037, 0.2813, 0.7344, 0.3027]}, {"w": "class", "b": [0.7437, 0.2813, 0.7822, 0.3027]}, {"w": "like", "b": [0.7915, 0.2813, 0.8215, 0.3027]}, {"w": "the", "b": [0.8308, 0.2813, 0.8571, 0.3027]}, {"w": "KMeans", "b": [0.1429, 0.3044, 0.2022, 0.3195]}, {"w": "class:", "b": [0.207, 0.3012, 0.2502, 0.3227]}]}, {"id": "b_4", "type": "paragraph", "text": "from sklearn.cluster import MiniBatchKMeans", "words": [{"w": "from", "b": [0.1766, 0.3332, 0.2103, 0.3461]}, {"w": "sklearn.cluster", "b": [0.2187, 0.3332, 0.3452, 0.3461]}, {"w": "import", "b": [0.3537, 0.3332, 0.4043, 0.3461]}, {"w": "MiniBatchKMeans", "b": [0.4127, 0.3332, 0.5392, 0.3461]}]}, {"id": "b_5", "type": "equation", "text": "minibatch_kmeans = MiniBatchKMeans(n_clusters=5) minibatch_kmeans.fit(X)", "words": [{"w": "minibatch_kmeans", "b": [0.1766, 0.3641, 0.3115, 0.3769]}, {"w": "=", "b": [0.3199, 0.3641, 0.3284, 0.3769]}, {"w": "MiniBatchKMeans(n_clusters=5)", "b": [0.3368, 0.3641, 0.5813, 0.3769]}, {"w": "minibatch_kmeans.fit(X)", "b": [0.1766, 0.3795, 0.3705, 0.3923]}]}, {"id": "b_6", "type": "paragraph", "text": "If the dataset does not fit in memory, the simplest option is to use the memmap class, as we did for incremental PCA in Chapter 8. Alternatively, you can pass one mini-batch at a time to the partial_fit() method, but this will require much more work, since you will need to perform multiple initializations and select the best one yourself (see the notebook for an example).", "words": [{"w": "If", "b": [0.1429, 0.401, 0.1561, 0.4224]}, {"w": "the", "b": [0.1612, 0.401, 0.1875, 0.4224]}, {"w": "dataset", "b": [0.1926, 0.401, 0.2507, 0.4224]}, {"w": "does", "b": [0.2557, 0.401, 0.2939, 0.4224]}, {"w": "not", "b": [0.2989, 0.401, 0.3273, 0.4224]}, {"w": "fit", "b": [0.3324, 0.401, 0.3505, 0.4224]}, {"w": "in", "b": [0.3555, 0.401, 0.3725, 0.4224]}, {"w": "memory,", "b": [0.3776, 0.401, 0.4523, 0.4224]}, {"w": "the", "b": [0.4573, 0.401, 0.4837, 0.4224]}, {"w": "simplest", "b": [0.4887, 0.401, 0.5577, 0.4224]}, {"w": "option", "b": [0.5627, 0.401, 0.6182, 0.4224]}, {"w": "is", "b": [0.6233, 0.401, 0.6365, 0.4224]}, {"w": "to", "b": [0.6416, 0.401, 0.6585, 0.4224]}, {"w": "use", "b": [0.6636, 0.401, 0.6912, 0.4224]}, {"w": "the", "b": [0.6962, 0.401, 0.7225, 0.4224]}, {"w": "memmap", "b": [0.7276, 0.4042, 0.787, 0.4193]}, {"w": "class,", "b": [0.792, 0.401, 0.8353, 0.4224]}, {"w": "as", "b": [0.84, 0.401, 0.8568, 0.4224]}, {"w": "we", "b": [0.1429, 0.4201, 0.166, 0.4415]}, {"w": "did", "b": [0.1713, 0.4201, 0.1989, 0.4415]}, {"w": "for", "b": [0.2042, 0.4201, 0.2287, 0.4415]}, {"w": "incremental", "b": [0.234, 0.4201, 0.3341, 0.4415]}, {"w": "PCA", "b": [0.3394, 0.4201, 0.3793, 0.4415]}, {"w": "in", "b": [0.3846, 0.4201, 0.4016, 0.4415]}, {"w": "Chapter", "b": [0.4069, 0.4201, 0.4745, 0.4415]}, {"w": "8.", "b": [0.4792, 0.4201, 0.4946, 0.4415]}, {"w": "Alternatively,", "b": [0.4999, 0.4201, 0.6111, 0.4415]}, {"w": "you", "b": [0.6164, 0.4201, 0.6477, 0.4415]}, {"w": "can", "b": [0.653, 0.4201, 0.6823, 0.4415]}, {"w": "pass", "b": [0.6876, 0.4201, 0.723, 0.4415]}, {"w": "one", "b": [0.7283, 0.4201, 0.7592, 0.4415]}, {"w": "mini-batch", "b": [0.7645, 0.4201, 0.8571, 0.4415]}, {"w": "at", "b": [0.1429, 0.44, 0.158, 0.4614]}, {"w": "a", "b": [0.1636, 0.44, 0.1727, 0.4614]}, {"w": "time", "b": [0.1784, 0.44, 0.2162, 0.4614]}, {"w": "to", "b": [0.2219, 0.44, 0.2389, 0.4614]}, {"w": "the", "b": [0.2445, 0.44, 0.2708, 0.4614]}, {"w": "partial_fit()", "b": [0.2765, 0.4432, 0.4051, 0.4583]}, {"w": "method,", "b": [0.4108, 0.44, 0.4805, 0.4614]}, {"w": "but", "b": [0.4862, 0.44, 0.5142, 0.4614]}, {"w": "this", "b": [0.5198, 0.44, 0.5505, 0.4614]}, {"w": "will", "b": [0.5562, 0.44, 0.5865, 0.4614]}, {"w": "require", "b": [0.5922, 0.44, 0.6526, 0.4614]}, {"w": "much", "b": [0.6583, 0.44, 0.706, 0.4614]}, {"w": "more", "b": [0.7116, 0.44, 0.7559, 0.4614]}, {"w": "work,", "b": [0.7615, 0.44, 0.8092, 0.4614]}, {"w": "since", "b": [0.8149, 0.44, 0.8571, 0.4614]}, {"w": "you", "b": [0.1429, 0.459, 0.1741, 0.4805]}, {"w": "will", "b": [0.1799, 0.459, 0.2103, 0.4805]}, {"w": "need", "b": [0.2161, 0.459, 0.2562, 0.4805]}, {"w": "to", "b": [0.262, 0.459, 0.279, 0.4805]}, {"w": "perform", "b": [0.2848, 0.459, 0.3539, 0.4805]}, {"w": "multiple", "b": [0.3597, 0.459, 0.4297, 0.4805]}, {"w": "initializations", "b": [0.4355, 0.459, 0.5491, 0.4805]}, {"w": "and", "b": [0.5549, 0.459, 0.5864, 0.4805]}, {"w": "select", "b": [0.5922, 0.459, 0.638, 0.4805]}, {"w": "the", "b": [0.6438, 0.459, 0.6701, 0.4805]}, {"w": "best", "b": [0.6759, 0.459, 0.7094, 0.4805]}, {"w": "one", "b": [0.7152, 0.459, 0.7461, 0.4805]}, {"w": "yourself", "b": [0.7519, 0.459, 0.8188, 0.4805]}, {"w": "(see", "b": [0.8246, 0.459, 0.8571, 0.4805]}, {"w": "the", "b": [0.1429, 0.4781, 0.1692, 0.4995]}, {"w": "notebook", "b": [0.1739, 0.4781, 0.2533, 0.4995]}, {"w": "for", "b": [0.2581, 0.4781, 0.2826, 0.4995]}, {"w": "an", "b": [0.2873, 0.4781, 0.3078, 0.4995]}, {"w": "example).", "b": [0.3126, 0.4781, 0.3941, 0.4995]}]}, {"id": "b_7", "type": "paragraph", "text": "Although the Mini-batch K-Means algorithm is much faster than the regular K- Means algorithm, its inertia is generally slightly worse, especially as the number of clusters increases. You can see this in Figure 9-6: the plot on the left compares the inertias of Mini-batch K-Means and regular K-Means models trained on the previous dataset using various numbers of clusters k. The difference between the two curves remains fairly constant, but this difference becomes more and more significant as k increases, since the inertia becomes smaller and smaller. However, in the plot on the right, you can see that Mini-batch K-Means is much faster than regular K-Means, and this difference increases with k.", "words": [{"w": "Although", "b": [0.1429, 0.5062, 0.2226, 0.5276]}, {"w": "the", "b": [0.2319, 0.5062, 0.2583, 0.5276]}, {"w": "Mini-batch", "b": [0.2676, 0.5062, 0.3618, 0.5276]}, {"w": "K-Means", "b": [0.3711, 0.5062, 0.4476, 0.5276]}, {"w": "algorithm", "b": [0.457, 0.5062, 0.5396, 0.5276]}, {"w": "is", "b": [0.5489, 0.5062, 0.5622, 0.5276]}, {"w": "much", "b": [0.5715, 0.5062, 0.6192, 0.5276]}, {"w": "faster", "b": [0.6285, 0.5062, 0.6744, 0.5276]}, {"w": "than", "b": [0.6838, 0.5062, 0.7218, 0.5276]}, {"w": "the", "b": [0.7311, 0.5062, 0.7575, 0.5276]}, {"w": "regular", "b": [0.7668, 0.5062, 0.8264, 0.5276]}, {"w": "K-", "b": [0.8357, 0.5062, 0.8572, 0.5276]}, {"w": "Means", "b": [0.1429, 0.5253, 0.1979, 0.5467]}, {"w": "algorithm,", "b": [0.2053, 0.5253, 0.2927, 0.5467]}, {"w": "its", "b": [0.3, 0.5253, 0.3196, 0.5467]}, {"w": "inertia", "b": [0.327, 0.5253, 0.3816, 0.5467]}, {"w": "is", "b": [0.389, 0.5253, 0.4022, 0.5467]}, {"w": "generally", "b": [0.4096, 0.5253, 0.4854, 0.5467]}, {"w": "slightly", "b": [0.4928, 0.5253, 0.553, 0.5467]}, {"w": "worse,", "b": [0.5603, 0.5253, 0.6142, 0.5467]}, {"w": "especially", "b": [0.6216, 0.5253, 0.7015, 0.5467]}, {"w": "as", "b": [0.7088, 0.5253, 0.7256, 0.5467]}, {"w": "the", "b": [0.733, 0.5253, 0.7593, 0.5467]}, {"w": "number", "b": [0.7667, 0.5253, 0.833, 0.5467]}, {"w": "of", "b": [0.8404, 0.5253, 0.8571, 0.5467]}, {"w": "clusters", "b": [0.1429, 0.5443, 0.2062, 0.5657]}, {"w": "increases.", "b": [0.2135, 0.5443, 0.2939, 0.5657]}, {"w": "You", "b": [0.3011, 0.5443, 0.3334, 0.5657]}, {"w": "can", "b": [0.3407, 0.5443, 0.37, 0.5657]}, {"w": "see", "b": [0.3772, 0.5443, 0.4026, 0.5657]}, {"w": "this", "b": [0.4098, 0.5443, 0.4405, 0.5657]}, {"w": "in", "b": [0.4478, 0.5443, 0.4647, 0.5657]}, {"w": "Figure", "b": [0.472, 0.5443, 0.526, 0.5657]}, {"w": "9-6:", "b": [0.5332, 0.5443, 0.5653, 0.5657]}, {"w": "the", "b": [0.5726, 0.5443, 0.5989, 0.5657]}, {"w": "plot", "b": [0.6061, 0.5443, 0.6393, 0.5657]}, {"w": "on", "b": [0.6465, 0.5443, 0.6685, 0.5657]}, {"w": "the", "b": [0.6758, 0.5443, 0.7021, 0.5657]}, {"w": "left", "b": [0.7093, 0.5443, 0.736, 0.5657]}, {"w": "compares", "b": [0.7432, 0.5443, 0.8236, 0.5657]}, {"w": "the", "b": [0.8308, 0.5443, 0.8571, 0.5657]}, {"w": "inertias", "b": [0.1428, 0.5634, 0.2051, 0.5848]}, {"w": "of", "b": [0.2102, 0.5634, 0.227, 0.5848]}, {"w": "Mini-batch", "b": [0.2321, 0.5634, 0.3263, 0.5848]}, {"w": "K-Means", "b": [0.3314, 0.5634, 0.4079, 0.5848]}, {"w": "and", "b": [0.413, 0.5634, 0.4445, 0.5848]}, {"w": "regular", "b": [0.4496, 0.5634, 0.5091, 0.5848]}, {"w": "K-Means", "b": [0.5142, 0.5634, 0.5907, 0.5848]}, {"w": "models", "b": [0.5958, 0.5634, 0.6563, 0.5848]}, {"w": "trained", "b": [0.6614, 0.5634, 0.7214, 0.5848]}, {"w": "on", "b": [0.7265, 0.5634, 0.7486, 0.5848]}, {"w": "the", "b": [0.7536, 0.5634, 0.78, 0.5848]}, {"w": "previous", "b": [0.7851, 0.5634, 0.8571, 0.5848]}, {"w": "dataset", "b": [0.1429, 0.5824, 0.201, 0.6038]}, {"w": "using", "b": [0.2079, 0.5824, 0.2533, 0.6038]}, {"w": "various", "b": [0.2603, 0.5824, 0.3217, 0.6038]}, {"w": "numbers", "b": [0.3287, 0.5824, 0.4026, 0.6038]}, {"w": "of", "b": [0.4095, 0.5824, 0.4263, 0.6038]}, {"w": "clusters", "b": [0.4333, 0.5824, 0.4967, 0.6038]}, {"w": "k.", "b": [0.5036, 0.5822, 0.5181, 0.6038]}, {"w": "The", "b": [0.5251, 0.5824, 0.5579, 0.6038]}, {"w": "difference", "b": [0.5649, 0.5824, 0.6483, 0.6038]}, {"w": "between", "b": [0.6552, 0.5824, 0.7244, 0.6038]}, {"w": "the", "b": [0.7313, 0.5824, 0.7577, 0.6038]}, {"w": "two", "b": [0.7646, 0.5824, 0.7959, 0.6038]}, {"w": "curves", "b": [0.8028, 0.5824, 0.8571, 0.6038]}, {"w": "remains", "b": [0.1429, 0.6014, 0.2103, 0.6229]}, {"w": "fairly", "b": [0.2169, 0.6014, 0.2603, 0.6229]}, {"w": "constant,", "b": [0.2669, 0.6014, 0.343, 0.6229]}, {"w": "but", "b": [0.3496, 0.6014, 0.3776, 0.6229]}, {"w": "this", "b": [0.3842, 0.6014, 0.4149, 0.6229]}, {"w": "difference", "b": [0.4215, 0.6014, 0.5049, 0.6229]}, {"w": "becomes", "b": [0.5115, 0.6014, 0.5839, 0.6229]}, {"w": "more", "b": [0.5905, 0.6014, 0.6348, 0.6229]}, {"w": "and", "b": [0.6414, 0.6014, 0.6729, 0.6229]}, {"w": "more", "b": [0.6795, 0.6014, 0.7238, 0.6229]}, {"w": "significant", "b": [0.7304, 0.6014, 0.8174, 0.6229]}, {"w": "as", "b": [0.824, 0.6014, 0.8408, 0.6229]}, {"w": "k", "b": [0.8474, 0.6012, 0.8571, 0.6229]}, {"w": "increases,", "b": [0.1429, 0.6205, 0.2233, 0.6419]}, {"w": "since", "b": [0.2292, 0.6205, 0.2715, 0.6419]}, {"w": "the", "b": [0.2775, 0.6205, 0.3038, 0.6419]}, {"w": "inertia", "b": [0.3098, 0.6205, 0.3644, 0.6419]}, {"w": "becomes", "b": [0.3704, 0.6205, 0.4428, 0.6419]}, {"w": "smaller", "b": [0.4488, 0.6205, 0.5098, 0.6419]}, {"w": "and", "b": [0.5157, 0.6205, 0.5473, 0.6419]}, {"w": "smaller.", "b": [0.5532, 0.6205, 0.6177, 0.6419]}, {"w": "However,", "b": [0.6236, 0.6205, 0.7025, 0.6419]}, {"w": "in", "b": [0.7084, 0.6205, 0.7254, 0.6419]}, {"w": "the", "b": [0.7314, 0.6205, 0.7577, 0.6419]}, {"w": "plot", "b": [0.7637, 0.6205, 0.7969, 0.6419]}, {"w": "on", "b": [0.8028, 0.6205, 0.8248, 0.6419]}, {"w": "the", "b": [0.8308, 0.6205, 0.8571, 0.6419]}, {"w": "right,", "b": [0.1429, 0.6395, 0.1878, 0.661]}, {"w": "you", "b": [0.1926, 0.6395, 0.2239, 0.661]}, {"w": "can", "b": [0.2287, 0.6395, 0.2581, 0.661]}, {"w": "see", "b": [0.2629, 0.6395, 0.2883, 0.661]}, {"w": "that", "b": [0.2931, 0.6395, 0.3257, 0.661]}, {"w": "Mini-batch", "b": [0.3305, 0.6395, 0.4247, 0.661]}, {"w": "K-Means", "b": [0.4296, 0.6395, 0.5061, 0.661]}, {"w": "is", "b": [0.5109, 0.6395, 0.5241, 0.661]}, {"w": "much", "b": [0.529, 0.6395, 0.5767, 0.661]}, {"w": "faster", "b": [0.5815, 0.6395, 0.6274, 0.661]}, {"w": "than", "b": [0.6323, 0.6395, 0.6703, 0.661]}, {"w": "regular", "b": [0.6751, 0.6395, 0.7347, 0.661]}, {"w": "K-Means,", "b": [0.7395, 0.6395, 0.8208, 0.661]}, {"w": "and", "b": [0.8256, 0.6395, 0.8572, 0.661]}, {"w": "this", "b": [0.1429, 0.6586, 0.1736, 0.68]}, {"w": "difference", "b": [0.1783, 0.6586, 0.2617, 0.68]}, {"w": "increases", "b": [0.2664, 0.6586, 0.3421, 0.68]}, {"w": "with", "b": [0.3468, 0.6586, 0.3842, 0.68]}, {"w": "k.", "b": [0.3889, 0.6584, 0.4034, 0.68]}]}, {"id": "b_8", "type": "paragraph", "text": "246 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "246", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 273, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Figure 9-6. Mini-batch K-Means vs K-Means: worse inertia as k increases (left) but much faster (right)", "words": [{"w": "Figure", "b": [0.1429, 0.244, 0.1943, 0.2657]}, {"w": "9-6.", "b": [0.1991, 0.244, 0.2308, 0.2657]}, {"w": "Mini-batch", "b": [0.2356, 0.244, 0.3264, 0.2657]}, {"w": "K-Means", "b": [0.3311, 0.244, 0.4055, 0.2657]}, {"w": "vs", "b": [0.4103, 0.244, 0.4266, 0.2657]}, {"w": "K-Means:", "b": [0.4314, 0.244, 0.5106, 0.2657]}, {"w": "worse", "b": [0.5154, 0.244, 0.5618, 0.2657]}, {"w": "inertia", "b": [0.5666, 0.244, 0.6213, 0.2657]}, {"w": "as", "b": [0.6261, 0.244, 0.6433, 0.2657]}, {"w": "k", "b": [0.6481, 0.244, 0.6579, 0.2657]}, {"w": "increases", "b": [0.6627, 0.244, 0.7349, 0.2657]}, {"w": "(left)", "b": [0.7397, 0.244, 0.779, 0.2657]}, {"w": "but", "b": [0.7838, 0.244, 0.8109, 0.2657]}, {"w": "much", "b": [0.1429, 0.2631, 0.1883, 0.2847]}, {"w": "faster", "b": [0.193, 0.2631, 0.2376, 0.2847]}, {"w": "(right)", "b": [0.2424, 0.2631, 0.295, 0.2847]}]}, {"id": "b_1", "type": "paragraph", "text": "Finding the Optimal Number of Clusters", "words": [{"w": "Finding", "b": [0.1429, 0.3006, 0.2002, 0.3216]}, {"w": "the", "b": [0.2038, 0.3006, 0.2294, 0.3216]}, {"w": "Optimal", "b": [0.233, 0.3006, 0.2935, 0.3216]}, {"w": "Number", "b": [0.2972, 0.3006, 0.3583, 0.3216]}, {"w": "of", "b": [0.3619, 0.3006, 0.3773, 0.3216]}, {"w": "Clusters", "b": [0.3809, 0.3006, 0.4404, 0.3216]}]}, {"id": "b_2", "type": "paragraph", "text": "So far, we have set the number of clusters k to 5 because it was obvious by looking at the data that this is the correct number of clusters. But in general, it will not be so easy to know how to set k, and the result might be quite bad if you set it to the wrong value. For example, as you can see in Figure 9-7, setting k to 3 or 8 results in fairly bad models:", "words": [{"w": "So", "b": [0.1429, 0.3272, 0.1634, 0.3486]}, {"w": "far,", "b": [0.169, 0.3272, 0.1955, 0.3486]}, {"w": "we", "b": [0.2011, 0.3272, 0.2242, 0.3486]}, {"w": "have", "b": [0.2298, 0.3272, 0.2682, 0.3486]}, {"w": "set", "b": [0.2738, 0.3272, 0.2967, 0.3486]}, {"w": "the", "b": [0.3023, 0.3272, 0.3287, 0.3486]}, {"w": "number", "b": [0.3343, 0.3272, 0.4006, 0.3486]}, {"w": "of", "b": [0.4062, 0.3272, 0.423, 0.3486]}, {"w": "clusters", "b": [0.4286, 0.3272, 0.492, 0.3486]}, {"w": "k", "b": [0.4976, 0.327, 0.5074, 0.3486]}, {"w": "to", "b": [0.513, 0.3272, 0.53, 0.3486]}, {"w": "5", "b": [0.5356, 0.3272, 0.5456, 0.3486]}, {"w": "because", "b": [0.5512, 0.3272, 0.6158, 0.3486]}, {"w": "it", "b": [0.6214, 0.3272, 0.6334, 0.3486]}, {"w": "was", "b": [0.639, 0.3272, 0.67, 0.3486]}, {"w": "obvious", "b": [0.6757, 0.3272, 0.7414, 0.3486]}, {"w": "by", "b": [0.7471, 0.3272, 0.7672, 0.3486]}, {"w": "looking", "b": [0.7728, 0.3272, 0.8364, 0.3486]}, {"w": "at", "b": [0.842, 0.3272, 0.8571, 0.3486]}, {"w": "the", "b": [0.1429, 0.3463, 0.1692, 0.3677]}, {"w": "data", "b": [0.1762, 0.3463, 0.2114, 0.3677]}, {"w": "that", "b": [0.2184, 0.3463, 0.251, 0.3677]}, {"w": "this", "b": [0.258, 0.3463, 0.2887, 0.3677]}, {"w": "is", "b": [0.2957, 0.3463, 0.309, 0.3677]}, {"w": "the", "b": [0.3159, 0.3463, 0.3423, 0.3677]}, {"w": "correct", "b": [0.3493, 0.3463, 0.4082, 0.3677]}, {"w": "number", "b": [0.4152, 0.3463, 0.4815, 0.3677]}, {"w": "of", "b": [0.4885, 0.3463, 0.5053, 0.3677]}, {"w": "clusters.", "b": [0.5123, 0.3463, 0.5804, 0.3677]}, {"w": "But", "b": [0.5874, 0.3463, 0.617, 0.3677]}, {"w": "in", "b": [0.624, 0.3463, 0.641, 0.3677]}, {"w": "general,", "b": [0.648, 0.3463, 0.7138, 0.3677]}, {"w": "it", "b": [0.7208, 0.3463, 0.7327, 0.3677]}, {"w": "will", "b": [0.7397, 0.3463, 0.7701, 0.3677]}, {"w": "not", "b": [0.7771, 0.3463, 0.8055, 0.3677]}, {"w": "be", "b": [0.8125, 0.3463, 0.8319, 0.3677]}, {"w": "so", "b": [0.8389, 0.3463, 0.8572, 0.3677]}, {"w": "easy", "b": [0.1429, 0.3653, 0.1781, 0.3867]}, {"w": "to", "b": [0.1832, 0.3653, 0.2002, 0.3867]}, {"w": "know", "b": [0.2054, 0.3653, 0.252, 0.3867]}, {"w": "how", "b": [0.2572, 0.3653, 0.2932, 0.3867]}, {"w": "to", "b": [0.2983, 0.3653, 0.3153, 0.3867]}, {"w": "set", "b": [0.3205, 0.3653, 0.3433, 0.3867]}, {"w": "k,", "b": [0.3485, 0.3651, 0.3631, 0.3867]}, {"w": "and", "b": [0.3682, 0.3653, 0.3998, 0.3867]}, {"w": "the", "b": [0.4049, 0.3653, 0.4313, 0.3867]}, {"w": "result", "b": [0.4364, 0.3653, 0.4833, 0.3867]}, {"w": "might", "b": [0.4885, 0.3653, 0.538, 0.3867]}, {"w": "be", "b": [0.5431, 0.3653, 0.5626, 0.3867]}, {"w": "quite", "b": [0.5677, 0.3653, 0.6102, 0.3867]}, {"w": "bad", "b": [0.6154, 0.3653, 0.6461, 0.3867]}, {"w": "if", "b": [0.6513, 0.3653, 0.663, 0.3867]}, {"w": "you", "b": [0.6682, 0.3653, 0.6995, 0.3867]}, {"w": "set", "b": [0.7046, 0.3653, 0.7275, 0.3867]}, {"w": "it", "b": [0.7326, 0.3653, 0.7446, 0.3867]}, {"w": "to", "b": [0.7497, 0.3653, 0.7667, 0.3867]}, {"w": "the", "b": [0.7719, 0.3653, 0.7982, 0.3867]}, {"w": "wrong", "b": [0.8034, 0.3653, 0.8571, 0.3867]}, {"w": "value.", "b": [0.1429, 0.3844, 0.1916, 0.4058]}, {"w": "For", "b": [0.1983, 0.3844, 0.2272, 0.4058]}, {"w": "example,", "b": [0.2339, 0.3844, 0.3082, 0.4058]}, {"w": "as", "b": [0.3149, 0.3844, 0.3317, 0.4058]}, {"w": "you", "b": [0.3384, 0.3844, 0.3696, 0.4058]}, {"w": "can", "b": [0.3763, 0.3844, 0.4057, 0.4058]}, {"w": "see", "b": [0.4124, 0.3844, 0.4377, 0.4058]}, {"w": "in", "b": [0.4444, 0.3844, 0.4614, 0.4058]}, {"w": "Figure", "b": [0.4681, 0.3844, 0.5221, 0.4058]}, {"w": "9-7,", "b": [0.5287, 0.3844, 0.5609, 0.4058]}, {"w": "setting", "b": [0.5676, 0.3844, 0.6235, 0.4058]}, {"w": "k", "b": [0.6302, 0.3842, 0.64, 0.4058]}, {"w": "to", "b": [0.6467, 0.3844, 0.6637, 0.4058]}, {"w": "3", "b": [0.6704, 0.3844, 0.6804, 0.4058]}, {"w": "or", "b": [0.687, 0.3844, 0.7054, 0.4058]}, {"w": "8", "b": [0.7121, 0.3844, 0.7221, 0.4058]}, {"w": "results", "b": [0.7288, 0.3844, 0.7833, 0.4058]}, {"w": "in", "b": [0.79, 0.3844, 0.807, 0.4058]}, {"w": "fairly", "b": [0.8137, 0.3844, 0.8571, 0.4058]}, {"w": "bad", "b": [0.1428, 0.4034, 0.1736, 0.4248]}, {"w": "models:", "b": [0.1783, 0.4034, 0.2435, 0.4248]}]}, {"id": "b_3", "type": "equation", "text": "Figure 9-7. Bad choices for the number of clusters", "words": [{"w": "Figure", "b": [0.1428, 0.5658, 0.1943, 0.5875]}, {"w": "9-7.", "b": [0.1991, 0.5658, 0.2308, 0.5875]}, {"w": "Bad", "b": [0.2356, 0.5658, 0.2683, 0.5875]}, {"w": "choices", "b": [0.2731, 0.5658, 0.3295, 0.5875]}, {"w": "for", "b": [0.3343, 0.5658, 0.3569, 0.5875]}, {"w": "the", "b": [0.3617, 0.5658, 0.3867, 0.5875]}, {"w": "number", "b": [0.3915, 0.5658, 0.4551, 0.5875]}, {"w": "of", "b": [0.4598, 0.5658, 0.4751, 0.5875]}, {"w": "clusters", "b": [0.4798, 0.5658, 0.5395, 0.5875]}]}, {"id": "b_4", "type": "paragraph", "text": "You might be thinking that we could just pick the model with the lowest inertia, right? Unfortunately, it is not that simple. The inertia for k=3 is 653.2, which is much higher than for k=5 (which was 211.6), but with k=8, the inertia is just 119.1. The inertia is not a good performance metric when trying to choose k since it keeps get‐ ting lower as we increase k. Indeed, the more clusters there are, the closer each instance will be to its closest centroid, and therefore the lower the inertia will be. Let’s plot the inertia as a function of k (see Figure 9-8):", "words": [{"w": "You", "b": [0.1428, 0.6032, 0.1752, 0.6246]}, {"w": "might", "b": [0.1836, 0.6032, 0.2331, 0.6246]}, {"w": "be", "b": [0.2415, 0.6032, 0.2609, 0.6246]}, {"w": "thinking", "b": [0.2694, 0.6032, 0.3409, 0.6246]}, {"w": "that", "b": [0.3493, 0.6032, 0.3819, 0.6246]}, {"w": "we", "b": [0.3903, 0.6032, 0.4134, 0.6246]}, {"w": "could", "b": [0.4218, 0.6032, 0.4686, 0.6246]}, {"w": "just", "b": [0.477, 0.6032, 0.5074, 0.6246]}, {"w": "pick", "b": [0.5158, 0.6032, 0.5514, 0.6246]}, {"w": "the", "b": [0.5599, 0.6032, 0.5862, 0.6246]}, {"w": "model", "b": [0.5946, 0.6032, 0.6474, 0.6246]}, {"w": "with", "b": [0.6558, 0.6032, 0.6932, 0.6246]}, {"w": "the", "b": [0.7016, 0.6032, 0.7279, 0.6246]}, {"w": "lowest", "b": [0.7363, 0.6032, 0.7893, 0.6246]}, {"w": "inertia,", "b": [0.7977, 0.6032, 0.8571, 0.6246]}, {"w": "right?", "b": [0.1429, 0.6223, 0.1909, 0.6437]}, {"w": "Unfortunately,", "b": [0.1963, 0.6223, 0.3175, 0.6437]}, {"w": "it", "b": [0.3229, 0.6223, 0.3348, 0.6437]}, {"w": "is", "b": [0.3402, 0.6223, 0.3534, 0.6437]}, {"w": "not", "b": [0.3588, 0.6223, 0.3872, 0.6437]}, {"w": "that", "b": [0.3926, 0.6223, 0.4252, 0.6437]}, {"w": "simple.", "b": [0.4305, 0.6223, 0.4902, 0.6437]}, {"w": "The", "b": [0.4956, 0.6223, 0.5285, 0.6437]}, {"w": "inertia", "b": [0.5338, 0.6223, 0.5885, 0.6437]}, {"w": "for", "b": [0.5939, 0.6223, 0.6184, 0.6437]}, {"w": "k=3", "b": [0.6238, 0.6221, 0.6557, 0.6437]}, {"w": "is", "b": [0.6611, 0.6223, 0.6743, 0.6437]}, {"w": "653.2,", "b": [0.6797, 0.6223, 0.7292, 0.6437]}, {"w": "which", "b": [0.7346, 0.6223, 0.7855, 0.6437]}, {"w": "is", "b": [0.7909, 0.6223, 0.8041, 0.6437]}, {"w": "much", "b": [0.8095, 0.6223, 0.8571, 0.6437]}, {"w": "higher", "b": [0.1429, 0.6413, 0.197, 0.6627]}, {"w": "than", "b": [0.2044, 0.6413, 0.2424, 0.6627]}, {"w": "for", "b": [0.2498, 0.6413, 0.2744, 0.6627]}, {"w": "k=5", "b": [0.2817, 0.6411, 0.3136, 0.6627]}, {"w": "(which", "b": [0.321, 0.6413, 0.3791, 0.6627]}, {"w": "was", "b": [0.3865, 0.6413, 0.4176, 0.6627]}, {"w": "211.6),", "b": [0.425, 0.6413, 0.4817, 0.6627]}, {"w": "but", "b": [0.4891, 0.6413, 0.5171, 0.6627]}, {"w": "with", "b": [0.5245, 0.6413, 0.5618, 0.6627]}, {"w": "k=8,", "b": [0.5692, 0.6411, 0.6058, 0.6627]}, {"w": "the", "b": [0.6132, 0.6413, 0.6396, 0.6627]}, {"w": "inertia", "b": [0.647, 0.6413, 0.7016, 0.6627]}, {"w": "is", "b": [0.709, 0.6413, 0.7222, 0.6627]}, {"w": "just", "b": [0.7296, 0.6413, 0.76, 0.6627]}, {"w": "119.1.", "b": [0.7674, 0.6413, 0.8169, 0.6627]}, {"w": "The", "b": [0.8243, 0.6413, 0.8571, 0.6627]}, {"w": "inertia", "b": [0.1429, 0.6604, 0.1975, 0.6818]}, {"w": "is", "b": [0.2036, 0.6604, 0.2168, 0.6818]}, {"w": "not", "b": [0.2228, 0.6604, 0.2512, 0.6818]}, {"w": "a", "b": [0.2573, 0.6604, 0.2664, 0.6818]}, {"w": "good", "b": [0.2725, 0.6604, 0.3145, 0.6818]}, {"w": "performance", "b": [0.3206, 0.6604, 0.4278, 0.6818]}, {"w": "metric", "b": [0.4339, 0.6604, 0.4883, 0.6818]}, {"w": "when", "b": [0.4944, 0.6604, 0.54, 0.6818]}, {"w": "trying", "b": [0.5461, 0.6604, 0.597, 0.6818]}, {"w": "to", "b": [0.6031, 0.6604, 0.6201, 0.6818]}, {"w": "choose", "b": [0.6261, 0.6604, 0.6838, 0.6818]}, {"w": "k", "b": [0.6899, 0.6602, 0.6997, 0.6818]}, {"w": "since", "b": [0.7057, 0.6604, 0.748, 0.6818]}, {"w": "it", "b": [0.7541, 0.6604, 0.766, 0.6818]}, {"w": "keeps", "b": [0.7721, 0.6604, 0.8187, 0.6818]}, {"w": "get‐", "b": [0.8248, 0.6604, 0.8571, 0.6818]}, {"w": "ting", "b": [0.1429, 0.6794, 0.176, 0.7008]}, {"w": "lower", "b": [0.1851, 0.6794, 0.2319, 0.7008]}, {"w": "as", "b": [0.241, 0.6794, 0.2578, 0.7008]}, {"w": "we", "b": [0.267, 0.6794, 0.2901, 0.7008]}, {"w": "increase", "b": [0.2993, 0.6794, 0.3673, 0.7008]}, {"w": "k.", "b": [0.3765, 0.6792, 0.391, 0.7008]}, {"w": "Indeed,", "b": [0.4002, 0.6794, 0.4632, 0.7008]}, {"w": "the", "b": [0.4724, 0.6794, 0.4987, 0.7008]}, {"w": "more", "b": [0.5079, 0.6794, 0.5521, 0.7008]}, {"w": "clusters", "b": [0.5613, 0.6794, 0.6247, 0.7008]}, {"w": "there", "b": [0.6339, 0.6794, 0.6768, 0.7008]}, {"w": "are,", "b": [0.6859, 0.6794, 0.7164, 0.7008]}, {"w": "the", "b": [0.7256, 0.6794, 0.7519, 0.7008]}, {"w": "closer", "b": [0.7611, 0.6794, 0.81, 0.7008]}, {"w": "each", "b": [0.8192, 0.6794, 0.8572, 0.7008]}, {"w": "instance", "b": [0.1429, 0.6985, 0.212, 0.7199]}, {"w": "will", "b": [0.2171, 0.6985, 0.2475, 0.7199]}, {"w": "be", "b": [0.2526, 0.6985, 0.272, 0.7199]}, {"w": "to", "b": [0.2771, 0.6985, 0.2941, 0.7199]}, {"w": "its", "b": [0.2992, 0.6985, 0.3187, 0.7199]}, {"w": "closest", "b": [0.3238, 0.6985, 0.379, 0.7199]}, {"w": "centroid,", "b": [0.3841, 0.6985, 0.4588, 0.7199]}, {"w": "and", "b": [0.4639, 0.6985, 0.4954, 0.7199]}, {"w": "therefore", "b": [0.5005, 0.6985, 0.5768, 0.7199]}, {"w": "the", "b": [0.5819, 0.6985, 0.6082, 0.7199]}, {"w": "lower", "b": [0.6133, 0.6985, 0.66, 0.7199]}, {"w": "the", "b": [0.6651, 0.6985, 0.6914, 0.7199]}, {"w": "inertia", "b": [0.6965, 0.6985, 0.7512, 0.7199]}, {"w": "will", "b": [0.7562, 0.6985, 0.7866, 0.7199]}, {"w": "be.", "b": [0.7917, 0.6985, 0.8159, 0.7199]}, {"w": "Let’s", "b": [0.821, 0.6985, 0.8571, 0.7199]}, {"w": "plot", "b": [0.1429, 0.7175, 0.176, 0.7389]}, {"w": "the", "b": [0.1808, 0.7175, 0.2071, 0.7389]}, {"w": "inertia", "b": [0.2118, 0.7175, 0.2665, 0.7389]}, {"w": "as", "b": [0.2712, 0.7175, 0.288, 0.7389]}, {"w": "a", "b": [0.2927, 0.7175, 0.3019, 0.7389]}, {"w": "function", "b": [0.3066, 0.7175, 0.378, 0.7389]}, {"w": "of", "b": [0.3827, 0.7175, 0.3995, 0.7389]}, {"w": "k", "b": [0.4042, 0.7173, 0.414, 0.7389]}, {"w": "(see", "b": [0.4188, 0.7175, 0.4513, 0.7389]}, {"w": "Figure", "b": [0.456, 0.7175, 0.51, 0.7389]}, {"w": "9-8):", "b": [0.5148, 0.7175, 0.5541, 0.7389]}]}, {"id": "b_5", "type": "paragraph", "text": "Clustering | 247", "words": [{"w": "Clustering", "b": [0.736, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "247", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 274, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 9-8. Selecting the number of clusters k using the “elbow rule”", "words": [{"w": "Figure", "b": [0.1429, 0.2546, 0.1943, 0.2762]}, {"w": "9-8.", "b": [0.1991, 0.2546, 0.2308, 0.2762]}, {"w": "Selecting", "b": [0.2356, 0.2546, 0.306, 0.2762]}, {"w": "the", "b": [0.3108, 0.2546, 0.3358, 0.2762]}, {"w": "number", "b": [0.3406, 0.2546, 0.4041, 0.2762]}, {"w": "of", "b": [0.4089, 0.2546, 0.4241, 0.2762]}, {"w": "clusters", "b": [0.4289, 0.2546, 0.4886, 0.2762]}, {"w": "k", "b": [0.4934, 0.2546, 0.5032, 0.2762]}, {"w": "using", "b": [0.5079, 0.2546, 0.5509, 0.2762]}, {"w": "the", "b": [0.5557, 0.2546, 0.5807, 0.2762]}, {"w": "“elbow", "b": [0.5855, 0.2546, 0.6382, 0.2762]}, {"w": "rule”", "b": [0.643, 0.2546, 0.682, 0.2762]}]}, {"id": "b_1", "type": "paragraph", "text": "As you can see, the inertia drops very quickly as we increase k up to 4, but then it decreases much more slowly as we keep increasing k. This curve has roughly the shape of an arm, and there is an “elbow” at k=4 so if we did not know better, it would be a good choice: any lower value would be dramatic, while any higher value would not help much, and we might just be splitting perfectly good clusters in half for no good reason.", "words": [{"w": "As", "b": [0.1429, 0.292, 0.1649, 0.3134]}, {"w": "you", "b": [0.1719, 0.292, 0.2031, 0.3134]}, {"w": "can", "b": [0.2101, 0.292, 0.2395, 0.3134]}, {"w": "see,", "b": [0.2465, 0.292, 0.2766, 0.3134]}, {"w": "the", "b": [0.2836, 0.292, 0.3099, 0.3134]}, {"w": "inertia", "b": [0.3169, 0.292, 0.3715, 0.3134]}, {"w": "drops", "b": [0.3785, 0.292, 0.4265, 0.3134]}, {"w": "very", "b": [0.4335, 0.292, 0.4698, 0.3134]}, {"w": "quickly", "b": [0.4768, 0.292, 0.5381, 0.3134]}, {"w": "as", "b": [0.5451, 0.292, 0.5619, 0.3134]}, {"w": "we", "b": [0.5689, 0.292, 0.592, 0.3134]}, {"w": "increase", "b": [0.599, 0.292, 0.667, 0.3134]}, {"w": "k", "b": [0.674, 0.2918, 0.6838, 0.3134]}, {"w": "up", "b": [0.6908, 0.292, 0.7128, 0.3134]}, {"w": "to", "b": [0.7198, 0.292, 0.7368, 0.3134]}, {"w": "4,", "b": [0.7437, 0.292, 0.7585, 0.3134]}, {"w": "but", "b": [0.7655, 0.292, 0.7935, 0.3134]}, {"w": "then", "b": [0.8005, 0.292, 0.8382, 0.3134]}, {"w": "it", "b": [0.8452, 0.292, 0.8571, 0.3134]}, {"w": "decreases", "b": [0.1429, 0.3111, 0.2214, 0.3325]}, {"w": "much", "b": [0.2297, 0.3111, 0.2774, 0.3325]}, {"w": "more", "b": [0.2858, 0.3111, 0.33, 0.3325]}, {"w": "slowly", "b": [0.3384, 0.3111, 0.391, 0.3325]}, {"w": "as", "b": [0.3994, 0.3111, 0.4162, 0.3325]}, {"w": "we", "b": [0.4245, 0.3111, 0.4476, 0.3325]}, {"w": "keep", "b": [0.456, 0.3111, 0.495, 0.3325]}, {"w": "increasing", "b": [0.5033, 0.3111, 0.5892, 0.3325]}, {"w": "k.", "b": [0.5976, 0.3109, 0.6121, 0.3325]}, {"w": "This", "b": [0.6204, 0.3111, 0.6577, 0.3325]}, {"w": "curve", "b": [0.666, 0.3111, 0.7127, 0.3325]}, {"w": "has", "b": [0.7211, 0.3111, 0.749, 0.3325]}, {"w": "roughly", "b": [0.7573, 0.3111, 0.8225, 0.3325]}, {"w": "the", "b": [0.8308, 0.3111, 0.8571, 0.3325]}, {"w": "shape", "b": [0.1429, 0.3301, 0.1902, 0.3515]}, {"w": "of", "b": [0.1954, 0.3301, 0.2122, 0.3515]}, {"w": "an", "b": [0.2174, 0.3301, 0.2379, 0.3515]}, {"w": "arm,", "b": [0.2432, 0.3301, 0.2818, 0.3515]}, {"w": "and", "b": [0.2871, 0.3301, 0.3186, 0.3515]}, {"w": "there", "b": [0.3238, 0.3301, 0.3667, 0.3515]}, {"w": "is", "b": [0.372, 0.3301, 0.3852, 0.3515]}, {"w": "an", "b": [0.3904, 0.3301, 0.4109, 0.3515]}, {"w": "“elbow”", "b": [0.4162, 0.3301, 0.4807, 0.3515]}, {"w": "at", "b": [0.4859, 0.3301, 0.501, 0.3515]}, {"w": "k=4", "b": [0.5062, 0.3299, 0.5381, 0.3515]}, {"w": "so", "b": [0.5433, 0.3301, 0.5616, 0.3515]}, {"w": "if", "b": [0.5668, 0.3301, 0.5786, 0.3515]}, {"w": "we", "b": [0.5838, 0.3301, 0.6069, 0.3515]}, {"w": "did", "b": [0.6121, 0.3301, 0.6397, 0.3515]}, {"w": "not", "b": [0.6449, 0.3301, 0.6733, 0.3515]}, {"w": "know", "b": [0.6785, 0.3301, 0.7252, 0.3515]}, {"w": "better,", "b": [0.7304, 0.3301, 0.7825, 0.3515]}, {"w": "it", "b": [0.7878, 0.3301, 0.7997, 0.3515]}, {"w": "would", "b": [0.8049, 0.3301, 0.8572, 0.3515]}, {"w": "be", "b": [0.1429, 0.3492, 0.1623, 0.3706]}, {"w": "a", "b": [0.1686, 0.3492, 0.1778, 0.3706]}, {"w": "good", "b": [0.1841, 0.3492, 0.2261, 0.3706]}, {"w": "choice:", "b": [0.2325, 0.3492, 0.291, 0.3706]}, {"w": "any", "b": [0.2974, 0.3492, 0.327, 0.3706]}, {"w": "lower", "b": [0.3334, 0.3492, 0.3801, 0.3706]}, {"w": "value", "b": [0.3865, 0.3492, 0.4304, 0.3706]}, {"w": "would", "b": [0.4368, 0.3492, 0.489, 0.3706]}, {"w": "be", "b": [0.4953, 0.3492, 0.5148, 0.3706]}, {"w": "dramatic,", "b": [0.5211, 0.3492, 0.6003, 0.3706]}, {"w": "while", "b": [0.6067, 0.3492, 0.6518, 0.3706]}, {"w": "any", "b": [0.6581, 0.3492, 0.6877, 0.3706]}, {"w": "higher", "b": [0.6941, 0.3492, 0.7482, 0.3706]}, {"w": "value", "b": [0.7546, 0.3492, 0.7986, 0.3706]}, {"w": "would", "b": [0.8049, 0.3492, 0.8571, 0.3706]}, {"w": "not", "b": [0.1429, 0.3682, 0.1712, 0.3896]}, {"w": "help", "b": [0.178, 0.3682, 0.2142, 0.3896]}, {"w": "much,", "b": [0.2209, 0.3682, 0.2733, 0.3896]}, {"w": "and", "b": [0.2801, 0.3682, 0.3116, 0.3896]}, {"w": "we", "b": [0.3184, 0.3682, 0.3415, 0.3896]}, {"w": "might", "b": [0.3483, 0.3682, 0.3977, 0.3896]}, {"w": "just", "b": [0.4045, 0.3682, 0.4349, 0.3896]}, {"w": "be", "b": [0.4417, 0.3682, 0.4611, 0.3896]}, {"w": "splitting", "b": [0.4679, 0.3682, 0.5367, 0.3896]}, {"w": "perfectly", "b": [0.5435, 0.3682, 0.616, 0.3896]}, {"w": "good", "b": [0.6227, 0.3682, 0.6647, 0.3896]}, {"w": "clusters", "b": [0.6715, 0.3682, 0.7349, 0.3896]}, {"w": "in", "b": [0.7416, 0.3682, 0.7586, 0.3896]}, {"w": "half", "b": [0.7654, 0.3682, 0.7971, 0.3896]}, {"w": "for", "b": [0.8038, 0.3682, 0.8284, 0.3896]}, {"w": "no", "b": [0.8351, 0.3682, 0.8571, 0.3896]}, {"w": "good", "b": [0.1428, 0.3873, 0.1848, 0.4087]}, {"w": "reason.", "b": [0.1896, 0.3873, 0.2497, 0.4087]}]}, {"id": "b_2", "type": "paragraph", "text": "This technique for choosing the best value for the number of clusters is rather coarse. A more precise approach (but also more computationally expensive) is to use the sil‐ houette score, which is the mean silhouette coefficient over all the instances. An instan‐ ce’s silhouette coefficient is equal to (b – a) / max(a, b) where a is the mean distance to the other instances in the same cluster (it is the mean intra-cluster distance), and b is the mean nearest-cluster distance, that is the mean distance to the instances of the next closest cluster (defined as the one that minimizes b, excluding the instance’s own cluster). The silhouette coefficient can vary between -1 and +1: a coefficient close to +1 means that the instance is well inside its own cluster and far from other clusters, while a coefficient close to 0 means that it is close to a cluster boundary, and finally a coefficient close to -1 means that the instance may have been assigned to the wrong cluster. To compute the silhouette score, you can use Scikit-Learn’s silhou ette_score() function, giving it all the instances in the dataset, and the labels they were assigned:", "words": [{"w": "This", "b": [0.1428, 0.4154, 0.1801, 0.4368]}, {"w": "technique", "b": [0.1852, 0.4154, 0.2679, 0.4368]}, {"w": "for", "b": [0.273, 0.4154, 0.2975, 0.4368]}, {"w": "choosing", "b": [0.3027, 0.4154, 0.3782, 0.4368]}, {"w": "the", "b": [0.3834, 0.4154, 0.4097, 0.4368]}, {"w": "best", "b": [0.4148, 0.4154, 0.4483, 0.4368]}, {"w": "value", "b": [0.4534, 0.4154, 0.4974, 0.4368]}, {"w": "for", "b": [0.5025, 0.4154, 0.5271, 0.4368]}, {"w": "the", "b": [0.5322, 0.4154, 0.5585, 0.4368]}, {"w": "number", "b": [0.5637, 0.4154, 0.63, 0.4368]}, {"w": "of", "b": [0.6351, 0.4154, 0.6519, 0.4368]}, {"w": "clusters", "b": [0.657, 0.4154, 0.7204, 0.4368]}, {"w": "is", "b": [0.7255, 0.4154, 0.7388, 0.4368]}, {"w": "rather", "b": [0.7439, 0.4154, 0.7944, 0.4368]}, {"w": "coarse.", "b": [0.7996, 0.4154, 0.8571, 0.4368]}, {"w": "A", "b": [0.1429, 0.4344, 0.1573, 0.4558]}, {"w": "more", "b": [0.1629, 0.4344, 0.2072, 0.4558]}, {"w": "precise", "b": [0.2128, 0.4344, 0.2712, 0.4558]}, {"w": "approach", "b": [0.2768, 0.4344, 0.3548, 0.4558]}, {"w": "(but", "b": [0.3605, 0.4344, 0.3957, 0.4558]}, {"w": "also", "b": [0.4013, 0.4344, 0.434, 0.4558]}, {"w": "more", "b": [0.4396, 0.4344, 0.4839, 0.4558]}, {"w": "computationally", "b": [0.4895, 0.4344, 0.6259, 0.4558]}, {"w": "expensive)", "b": [0.6316, 0.4344, 0.7203, 0.4558]}, {"w": "is", "b": [0.726, 0.4344, 0.7392, 0.4558]}, {"w": "to", "b": [0.7448, 0.4344, 0.7618, 0.4558]}, {"w": "use", "b": [0.7675, 0.4344, 0.795, 0.4558]}, {"w": "the", "b": [0.8006, 0.4344, 0.827, 0.4558]}, {"w": "sil‐", "b": [0.8326, 0.4342, 0.8571, 0.4558]}, {"w": "houette", "b": [0.1429, 0.4533, 0.2031, 0.4749]}, {"w": "score,", "b": [0.2078, 0.4533, 0.2528, 0.4749]}, {"w": "which", "b": [0.2576, 0.4535, 0.3086, 0.4749]}, {"w": "is", "b": [0.3134, 0.4535, 0.3267, 0.4749]}, {"w": "the", "b": [0.3315, 0.4535, 0.3579, 0.4749]}, {"w": "mean", "b": [0.3628, 0.4535, 0.4092, 0.4749]}, {"w": "silhouette", "b": [0.4141, 0.4533, 0.4918, 0.4749]}, {"w": "coefficient", "b": [0.4967, 0.4533, 0.5787, 0.4749]}, {"w": "over", "b": [0.5836, 0.4535, 0.6204, 0.4749]}, {"w": "all", "b": [0.6253, 0.4535, 0.645, 0.4749]}, {"w": "the", "b": [0.6499, 0.4535, 0.6762, 0.4749]}, {"w": "instances.", "b": [0.6811, 0.4535, 0.7627, 0.4749]}, {"w": "An", "b": [0.7675, 0.4535, 0.7933, 0.4749]}, {"w": "instan‐", "b": [0.7982, 0.4535, 0.8571, 0.4749]}, {"w": "ce’s", "b": [0.1429, 0.4725, 0.1696, 0.4939]}, {"w": "silhouette", "b": [0.1755, 0.4725, 0.2572, 0.4939]}, {"w": "coefficient", "b": [0.2631, 0.4725, 0.3499, 0.4939]}, {"w": "is", "b": [0.3558, 0.4725, 0.369, 0.4939]}, {"w": "equal", "b": [0.3749, 0.4725, 0.4199, 0.4939]}, {"w": "to", "b": [0.4258, 0.4725, 0.4427, 0.4939]}, {"w": "(b", "b": [0.4486, 0.4723, 0.4659, 0.4939]}, {"w": "–", "b": [0.4718, 0.4725, 0.4827, 0.4939]}, {"w": "a)", "b": [0.4885, 0.4723, 0.506, 0.4939]}, {"w": "/", "b": [0.5118, 0.4725, 0.5187, 0.4939]}, {"w": "max(a,", "b": [0.5246, 0.4723, 0.5828, 0.4939]}, {"w": "b)", "b": [0.5887, 0.4723, 0.606, 0.4939]}, {"w": "where", "b": [0.6119, 0.4725, 0.6627, 0.4939]}, {"w": "a", "b": [0.6686, 0.4723, 0.6788, 0.4939]}, {"w": "is", "b": [0.6847, 0.4725, 0.6979, 0.4939]}, {"w": "the", "b": [0.7038, 0.4725, 0.7301, 0.4939]}, {"w": "mean", "b": [0.736, 0.4725, 0.7825, 0.4939]}, {"w": "distance", "b": [0.7883, 0.4725, 0.8571, 0.4939]}, {"w": "to", "b": [0.1429, 0.4916, 0.1598, 0.513]}, {"w": "the", "b": [0.165, 0.4916, 0.1913, 0.513]}, {"w": "other", "b": [0.1965, 0.4916, 0.2412, 0.513]}, {"w": "instances", "b": [0.2463, 0.4916, 0.3231, 0.513]}, {"w": "in", "b": [0.3283, 0.4916, 0.3453, 0.513]}, {"w": "the", "b": [0.3504, 0.4916, 0.3767, 0.513]}, {"w": "same", "b": [0.3819, 0.4916, 0.4246, 0.513]}, {"w": "cluster", "b": [0.4297, 0.4916, 0.4855, 0.513]}, {"w": "(it", "b": [0.4906, 0.4916, 0.5097, 0.513]}, {"w": "is", "b": [0.5149, 0.4916, 0.5281, 0.513]}, {"w": "the", "b": [0.5333, 0.4916, 0.5596, 0.513]}, {"w": "mean", "b": [0.5647, 0.4916, 0.6112, 0.513]}, {"w": "intra-cluster", "b": [0.6163, 0.4916, 0.7193, 0.513]}, {"w": "distance),", "b": [0.7244, 0.4916, 0.8052, 0.513]}, {"w": "and", "b": [0.8103, 0.4916, 0.8419, 0.513]}, {"w": "b", "b": [0.847, 0.4914, 0.8572, 0.513]}, {"w": "is", "b": [0.1429, 0.5106, 0.1561, 0.532]}, {"w": "the", "b": [0.1619, 0.5106, 0.1882, 0.532]}, {"w": "mean", "b": [0.194, 0.5106, 0.2404, 0.532]}, {"w": "nearest-cluster", "b": [0.2462, 0.5106, 0.3693, 0.532]}, {"w": "distance,", "b": [0.3751, 0.5106, 0.4487, 0.532]}, {"w": "that", "b": [0.4545, 0.5106, 0.487, 0.532]}, {"w": "is", "b": [0.4928, 0.5106, 0.506, 0.532]}, {"w": "the", "b": [0.5118, 0.5106, 0.5382, 0.532]}, {"w": "mean", "b": [0.5439, 0.5106, 0.5904, 0.532]}, {"w": "distance", "b": [0.5962, 0.5106, 0.665, 0.532]}, {"w": "to", "b": [0.6708, 0.5106, 0.6877, 0.532]}, {"w": "the", "b": [0.6935, 0.5106, 0.7198, 0.532]}, {"w": "instances", "b": [0.7256, 0.5106, 0.8025, 0.532]}, {"w": "of", "b": [0.8082, 0.5106, 0.825, 0.532]}, {"w": "the", "b": [0.8308, 0.5106, 0.8571, 0.532]}, {"w": "next", "b": [0.1429, 0.5297, 0.1793, 0.5511]}, {"w": "closest", "b": [0.1843, 0.5297, 0.2395, 0.5511]}, {"w": "cluster", "b": [0.2446, 0.5297, 0.3003, 0.5511]}, {"w": "(defined", "b": [0.3053, 0.5297, 0.3754, 0.5511]}, {"w": "as", "b": [0.3804, 0.5297, 0.3972, 0.5511]}, {"w": "the", "b": [0.4022, 0.5297, 0.4286, 0.5511]}, {"w": "one", "b": [0.4336, 0.5297, 0.4645, 0.5511]}, {"w": "that", "b": [0.4695, 0.5297, 0.5021, 0.5511]}, {"w": "minimizes", "b": [0.5071, 0.5297, 0.5946, 0.5511]}, {"w": "b,", "b": [0.5997, 0.5294, 0.6145, 0.5511]}, {"w": "excluding", "b": [0.6196, 0.5297, 0.7011, 0.5511]}, {"w": "the", "b": [0.7062, 0.5297, 0.7325, 0.5511]}, {"w": "instance’s", "b": [0.7375, 0.5297, 0.8158, 0.5511]}, {"w": "own", "b": [0.8208, 0.5297, 0.8571, 0.5511]}, {"w": "cluster).", "b": [0.1428, 0.5487, 0.2105, 0.5701]}, {"w": "The", "b": [0.2167, 0.5487, 0.2495, 0.5701]}, {"w": "silhouette", "b": [0.2557, 0.5487, 0.3374, 0.5701]}, {"w": "coefficient", "b": [0.3436, 0.5487, 0.4304, 0.5701]}, {"w": "can", "b": [0.4365, 0.5487, 0.4659, 0.5701]}, {"w": "vary", "b": [0.4721, 0.5487, 0.5088, 0.5701]}, {"w": "between", "b": [0.5149, 0.5487, 0.5841, 0.5701]}, {"w": "-1", "b": [0.5902, 0.5487, 0.6077, 0.5701]}, {"w": "and", "b": [0.6138, 0.5487, 0.6454, 0.5701]}, {"w": "+1:", "b": [0.6515, 0.5487, 0.6783, 0.5701]}, {"w": "a", "b": [0.6845, 0.5487, 0.6937, 0.5701]}, {"w": "coefficient", "b": [0.6998, 0.5487, 0.7866, 0.5701]}, {"w": "close", "b": [0.7928, 0.5487, 0.834, 0.5701]}, {"w": "to", "b": [0.8402, 0.5487, 0.8571, 0.5701]}, {"w": "+1", "b": [0.1429, 0.5677, 0.1649, 0.5892]}, {"w": "means", "b": [0.1711, 0.5677, 0.2252, 0.5892]}, {"w": "that", "b": [0.2314, 0.5677, 0.264, 0.5892]}, {"w": "the", "b": [0.2701, 0.5677, 0.2965, 0.5892]}, {"w": "instance", "b": [0.3026, 0.5677, 0.3718, 0.5892]}, {"w": "is", "b": [0.378, 0.5677, 0.3912, 0.5892]}, {"w": "well", "b": [0.3974, 0.5677, 0.431, 0.5892]}, {"w": "inside", "b": [0.4372, 0.5677, 0.4873, 0.5892]}, {"w": "its", "b": [0.4934, 0.5677, 0.513, 0.5892]}, {"w": "own", "b": [0.5192, 0.5677, 0.5555, 0.5892]}, {"w": "cluster", "b": [0.5616, 0.5677, 0.6174, 0.5892]}, {"w": "and", "b": [0.6235, 0.5677, 0.6551, 0.5892]}, {"w": "far", "b": [0.6612, 0.5677, 0.6843, 0.5892]}, {"w": "from", "b": [0.6904, 0.5677, 0.732, 0.5892]}, {"w": "other", "b": [0.7382, 0.5677, 0.7829, 0.5892]}, {"w": "clusters,", "b": [0.789, 0.5677, 0.8571, 0.5892]}, {"w": "while", "b": [0.1429, 0.5868, 0.188, 0.6082]}, {"w": "a", "b": [0.1934, 0.5868, 0.2025, 0.6082]}, {"w": "coefficient", "b": [0.2079, 0.5868, 0.2948, 0.6082]}, {"w": "close", "b": [0.3002, 0.5868, 0.3414, 0.6082]}, {"w": "to", "b": [0.3468, 0.5868, 0.3638, 0.6082]}, {"w": "0", "b": [0.3692, 0.5868, 0.3792, 0.6082]}, {"w": "means", "b": [0.3846, 0.5868, 0.4387, 0.6082]}, {"w": "that", "b": [0.4441, 0.5868, 0.4767, 0.6082]}, {"w": "it", "b": [0.4821, 0.5868, 0.4941, 0.6082]}, {"w": "is", "b": [0.4995, 0.5868, 0.5127, 0.6082]}, {"w": "close", "b": [0.5181, 0.5868, 0.5593, 0.6082]}, {"w": "to", "b": [0.5648, 0.5868, 0.5817, 0.6082]}, {"w": "a", "b": [0.5872, 0.5868, 0.5963, 0.6082]}, {"w": "cluster", "b": [0.6017, 0.5868, 0.6575, 0.6082]}, {"w": "boundary,", "b": [0.6629, 0.5868, 0.7478, 0.6082]}, {"w": "and", "b": [0.7532, 0.5868, 0.7848, 0.6082]}, {"w": "finally", "b": [0.7902, 0.5868, 0.8426, 0.6082]}, {"w": "a", "b": [0.848, 0.5868, 0.8571, 0.6082]}, {"w": "coefficient", "b": [0.1428, 0.6058, 0.2297, 0.6273]}, {"w": "close", "b": [0.236, 0.6058, 0.2772, 0.6273]}, {"w": "to", "b": [0.2835, 0.6058, 0.3004, 0.6273]}, {"w": "-1", "b": [0.3067, 0.6058, 0.3241, 0.6273]}, {"w": "means", "b": [0.3304, 0.6058, 0.3845, 0.6273]}, {"w": "that", "b": [0.3908, 0.6058, 0.4234, 0.6273]}, {"w": "the", "b": [0.4297, 0.6058, 0.456, 0.6273]}, {"w": "instance", "b": [0.4623, 0.6058, 0.5315, 0.6273]}, {"w": "may", "b": [0.5378, 0.6058, 0.5732, 0.6273]}, {"w": "have", "b": [0.5795, 0.6058, 0.6179, 0.6273]}, {"w": "been", "b": [0.6242, 0.6058, 0.6639, 0.6273]}, {"w": "assigned", "b": [0.6702, 0.6058, 0.7412, 0.6273]}, {"w": "to", "b": [0.7475, 0.6058, 0.7644, 0.6273]}, {"w": "the", "b": [0.7707, 0.6058, 0.7971, 0.6273]}, {"w": "wrong", "b": [0.8034, 0.6058, 0.8571, 0.6273]}, {"w": "cluster.", "b": [0.1428, 0.6258, 0.202, 0.6472]}, {"w": "To", "b": [0.2157, 0.6258, 0.2371, 0.6472]}, {"w": "compute", "b": [0.2508, 0.6258, 0.3241, 0.6472]}, {"w": "the", "b": [0.3378, 0.6258, 0.3642, 0.6472]}, {"w": "silhouette", "b": [0.3779, 0.6258, 0.4596, 0.6472]}, {"w": "score,", "b": [0.4733, 0.6258, 0.5217, 0.6472]}, {"w": "you", "b": [0.5354, 0.6258, 0.5666, 0.6472]}, {"w": "can", "b": [0.5803, 0.6258, 0.6097, 0.6472]}, {"w": "use", "b": [0.6234, 0.6258, 0.6509, 0.6472]}, {"w": "Scikit-Learn’s", "b": [0.6646, 0.6258, 0.7755, 0.6472]}, {"w": "silhou", "b": [0.7893, 0.629, 0.8486, 0.6441]}, {"w": "ette_score()", "b": [0.1429, 0.6489, 0.2616, 0.664]}, {"w": "function,", "b": [0.2682, 0.6457, 0.3444, 0.6671]}, {"w": "giving", "b": [0.351, 0.6457, 0.4027, 0.6671]}, {"w": "it", "b": [0.4094, 0.6457, 0.4213, 0.6671]}, {"w": "all", "b": [0.4279, 0.6457, 0.4476, 0.6671]}, {"w": "the", "b": [0.4542, 0.6457, 0.4806, 0.6671]}, {"w": "instances", "b": [0.4872, 0.6457, 0.564, 0.6671]}, {"w": "in", "b": [0.5707, 0.6457, 0.5876, 0.6671]}, {"w": "the", "b": [0.5943, 0.6457, 0.6206, 0.6671]}, {"w": "dataset,", "b": [0.6272, 0.6457, 0.6901, 0.6671]}, {"w": "and", "b": [0.6967, 0.6457, 0.7283, 0.6671]}, {"w": "the", "b": [0.7349, 0.6457, 0.7612, 0.6671]}, {"w": "labels", "b": [0.7679, 0.6457, 0.8146, 0.6671]}, {"w": "they", "b": [0.8213, 0.6457, 0.8571, 0.6671]}, {"w": "were", "b": [0.1429, 0.6648, 0.1826, 0.6862]}, {"w": "assigned:", "b": [0.1873, 0.6648, 0.2631, 0.6862]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> from sklearn.metrics import silhouette_score >>> silhouette_score(X, kmeans.labels_) 0.655517642572828", "words": [{"w": ">>>", "b": [0.1766, 0.6968, 0.2019, 0.7096]}, {"w": "from", "b": [0.2103, 0.6968, 0.244, 0.7096]}, {"w": "sklearn.metrics", "b": [0.2525, 0.6968, 0.379, 0.7096]}, {"w": "import", "b": [0.3874, 0.6968, 0.438, 0.7096]}, {"w": "silhouette_score", "b": [0.4464, 0.6968, 0.5813, 0.7096]}, {"w": ">>>", "b": [0.1766, 0.7122, 0.2019, 0.725]}, {"w": "silhouette_score(X,", "b": [0.2103, 0.7122, 0.3705, 0.725]}, {"w": "kmeans.labels_)", "b": [0.379, 0.7122, 0.5054, 0.725]}, {"w": "0.655517642572828", "b": [0.1766, 0.7276, 0.3199, 0.7404]}]}, {"id": "b_4", "type": "paragraph", "text": "Let’s compare the silhouette scores for different numbers of clusters (see Figure 9-9):", "words": [{"w": "Let’s", "b": [0.1429, 0.7482, 0.179, 0.7696]}, {"w": "compare", "b": [0.1837, 0.7482, 0.2565, 0.7696]}, {"w": "the", "b": [0.2612, 0.7482, 0.2876, 0.7696]}, {"w": "silhouette", "b": [0.2923, 0.7482, 0.374, 0.7696]}, {"w": "scores", "b": [0.3787, 0.7482, 0.4301, 0.7696]}, {"w": "for", "b": [0.4348, 0.7482, 0.4593, 0.7696]}, {"w": "different", "b": [0.464, 0.7482, 0.5357, 0.7696]}, {"w": "numbers", "b": [0.5405, 0.7482, 0.6144, 0.7696]}, {"w": "of", "b": [0.6191, 0.7482, 0.6359, 0.7696]}, {"w": "clusters", "b": [0.6407, 0.7482, 0.704, 0.7696]}, {"w": "(see", "b": [0.7088, 0.7482, 0.7413, 0.7696]}, {"w": "Figure", "b": [0.7461, 0.7482, 0.8001, 0.7696]}, {"w": "9-9):", "b": [0.8048, 0.7482, 0.8442, 0.7696]}]}, {"id": "b_5", "type": "paragraph", "text": "248 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "248", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 275, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 9-9. Selecting the number of clusters k using the silhouette score", "words": [{"w": "Figure", "b": [0.1429, 0.2312, 0.1943, 0.2528]}, {"w": "9-9.", "b": [0.1991, 0.2312, 0.2308, 0.2528]}, {"w": "Selecting", "b": [0.2356, 0.2312, 0.306, 0.2528]}, {"w": "the", "b": [0.3108, 0.2312, 0.3358, 0.2528]}, {"w": "number", "b": [0.3406, 0.2312, 0.4041, 0.2528]}, {"w": "of", "b": [0.4089, 0.2312, 0.4241, 0.2528]}, {"w": "clusters", "b": [0.4289, 0.2312, 0.4886, 0.2528]}, {"w": "k", "b": [0.4934, 0.2312, 0.5032, 0.2528]}, {"w": "using", "b": [0.5079, 0.2312, 0.5509, 0.2528]}, {"w": "the", "b": [0.5557, 0.2312, 0.5807, 0.2528]}, {"w": "silhouette", "b": [0.5855, 0.2312, 0.6632, 0.2528]}, {"w": "score", "b": [0.668, 0.2312, 0.708, 0.2528]}]}, {"id": "b_1", "type": "paragraph", "text": "As you can see, this visualization is much richer than the previous one: in particular, although it confirms that k=4 is a very good choice, it also underlines the fact that k=5 is quite good as well, and much better than k=6 or 7. This was not visible when comparing inertias.", "words": [{"w": "As", "b": [0.1429, 0.2686, 0.1649, 0.29]}, {"w": "you", "b": [0.1706, 0.2686, 0.2019, 0.29]}, {"w": "can", "b": [0.2076, 0.2686, 0.237, 0.29]}, {"w": "see,", "b": [0.2428, 0.2686, 0.2729, 0.29]}, {"w": "this", "b": [0.2786, 0.2686, 0.3093, 0.29]}, {"w": "visualization", "b": [0.3151, 0.2686, 0.4205, 0.29]}, {"w": "is", "b": [0.4262, 0.2686, 0.4394, 0.29]}, {"w": "much", "b": [0.4452, 0.2686, 0.4929, 0.29]}, {"w": "richer", "b": [0.4986, 0.2686, 0.5484, 0.29]}, {"w": "than", "b": [0.5542, 0.2686, 0.5922, 0.29]}, {"w": "the", "b": [0.598, 0.2686, 0.6243, 0.29]}, {"w": "previous", "b": [0.63, 0.2686, 0.7021, 0.29]}, {"w": "one:", "b": [0.7079, 0.2686, 0.7435, 0.29]}, {"w": "in", "b": [0.7492, 0.2686, 0.7662, 0.29]}, {"w": "particular,", "b": [0.772, 0.2686, 0.8571, 0.29]}, {"w": "although", "b": [0.1429, 0.2876, 0.2173, 0.309]}, {"w": "it", "b": [0.2244, 0.2876, 0.2363, 0.309]}, {"w": "confirms", "b": [0.2434, 0.2876, 0.3184, 0.309]}, {"w": "that", "b": [0.3255, 0.2876, 0.3581, 0.309]}, {"w": "k=4", "b": [0.3652, 0.2874, 0.3971, 0.309]}, {"w": "is", "b": [0.4041, 0.2876, 0.4174, 0.309]}, {"w": "a", "b": [0.4245, 0.2876, 0.4336, 0.309]}, {"w": "very", "b": [0.4407, 0.2876, 0.4771, 0.309]}, {"w": "good", "b": [0.4842, 0.2876, 0.5262, 0.309]}, {"w": "choice,", "b": [0.5333, 0.2876, 0.5918, 0.309]}, {"w": "it", "b": [0.5989, 0.2876, 0.6108, 0.309]}, {"w": "also", "b": [0.6179, 0.2876, 0.6506, 0.309]}, {"w": "underlines", "b": [0.6577, 0.2876, 0.7465, 0.309]}, {"w": "the", "b": [0.7536, 0.2876, 0.7799, 0.309]}, {"w": "fact", "b": [0.787, 0.2876, 0.8175, 0.309]}, {"w": "that", "b": [0.8246, 0.2876, 0.8571, 0.309]}, {"w": "k=5", "b": [0.1429, 0.3065, 0.1747, 0.3281]}, {"w": "is", "b": [0.1808, 0.3067, 0.194, 0.3281]}, {"w": "quite", "b": [0.2001, 0.3067, 0.2426, 0.3281]}, {"w": "good", "b": [0.2487, 0.3067, 0.2907, 0.3281]}, {"w": "as", "b": [0.2967, 0.3067, 0.3135, 0.3281]}, {"w": "well,", "b": [0.3196, 0.3067, 0.358, 0.3281]}, {"w": "and", "b": [0.3641, 0.3067, 0.3956, 0.3281]}, {"w": "much", "b": [0.4017, 0.3067, 0.4493, 0.3281]}, {"w": "better", "b": [0.4554, 0.3067, 0.5041, 0.3281]}, {"w": "than", "b": [0.5102, 0.3067, 0.5482, 0.3281]}, {"w": "k=6", "b": [0.5543, 0.3065, 0.5861, 0.3281]}, {"w": "or", "b": [0.5922, 0.3067, 0.6106, 0.3281]}, {"w": "7.", "b": [0.6166, 0.3067, 0.6314, 0.3281]}, {"w": "This", "b": [0.6374, 0.3067, 0.6746, 0.3281]}, {"w": "was", "b": [0.6807, 0.3067, 0.7118, 0.3281]}, {"w": "not", "b": [0.7178, 0.3067, 0.7462, 0.3281]}, {"w": "visible", "b": [0.7523, 0.3067, 0.8054, 0.3281]}, {"w": "when", "b": [0.8115, 0.3067, 0.8572, 0.3281]}, {"w": "comparing", "b": [0.1429, 0.3257, 0.2335, 0.3471]}, {"w": "inertias.", "b": [0.2382, 0.3257, 0.3053, 0.3471]}]}, {"id": "b_2", "type": "paragraph", "text": "An even more informative visualization is obtained when you plot every instance’s silhouette coefficient, sorted by the cluster they are assigned to and by the value of the coefficient. This is called a silhouette diagram (see Figure 9-10):", "words": [{"w": "An", "b": [0.1429, 0.3538, 0.1687, 0.3753]}, {"w": "even", "b": [0.1761, 0.3538, 0.2149, 0.3753]}, {"w": "more", "b": [0.2223, 0.3538, 0.2666, 0.3753]}, {"w": "informative", "b": [0.274, 0.3538, 0.3718, 0.3753]}, {"w": "visualization", "b": [0.3792, 0.3538, 0.4846, 0.3753]}, {"w": "is", "b": [0.4921, 0.3538, 0.5053, 0.3753]}, {"w": "obtained", "b": [0.5127, 0.3538, 0.5863, 0.3753]}, {"w": "when", "b": [0.5937, 0.3538, 0.6394, 0.3753]}, {"w": "you", "b": [0.6468, 0.3538, 0.6781, 0.3753]}, {"w": "plot", "b": [0.6855, 0.3538, 0.7187, 0.3753]}, {"w": "every", "b": [0.7262, 0.3538, 0.7714, 0.3753]}, {"w": "instance’s", "b": [0.7789, 0.3538, 0.8571, 0.3753]}, {"w": "silhouette", "b": [0.1429, 0.3729, 0.2246, 0.3943]}, {"w": "coefficient,", "b": [0.2294, 0.3729, 0.3209, 0.3943]}, {"w": "sorted", "b": [0.3257, 0.3729, 0.3779, 0.3943]}, {"w": "by", "b": [0.3827, 0.3729, 0.4029, 0.3943]}, {"w": "the", "b": [0.4077, 0.3729, 0.434, 0.3943]}, {"w": "cluster", "b": [0.4388, 0.3729, 0.4945, 0.3943]}, {"w": "they", "b": [0.4993, 0.3729, 0.5352, 0.3943]}, {"w": "are", "b": [0.54, 0.3729, 0.5657, 0.3943]}, {"w": "assigned", "b": [0.5705, 0.3729, 0.6415, 0.3943]}, {"w": "to", "b": [0.6463, 0.3729, 0.6633, 0.3943]}, {"w": "and", "b": [0.6681, 0.3729, 0.6996, 0.3943]}, {"w": "by", "b": [0.7044, 0.3729, 0.7245, 0.3943]}, {"w": "the", "b": [0.7293, 0.3729, 0.7557, 0.3943]}, {"w": "value", "b": [0.7605, 0.3729, 0.8044, 0.3943]}, {"w": "of", "b": [0.8092, 0.3729, 0.826, 0.3943]}, {"w": "the", "b": [0.8308, 0.3729, 0.8571, 0.3943]}, {"w": "coefficient.", "b": [0.1428, 0.3919, 0.2344, 0.4133]}, {"w": "This", "b": [0.2391, 0.3919, 0.2763, 0.4133]}, {"w": "is", "b": [0.2811, 0.3919, 0.2943, 0.4133]}, {"w": "called", "b": [0.299, 0.3919, 0.3474, 0.4133]}, {"w": "a", "b": [0.3521, 0.3919, 0.3613, 0.4133]}, {"w": "silhouette", "b": [0.366, 0.3917, 0.4437, 0.4133]}, {"w": "diagram", "b": [0.4485, 0.3917, 0.5166, 0.4133]}, {"w": "(see", "b": [0.5213, 0.3919, 0.5539, 0.4133]}, {"w": "Figure", "b": [0.5586, 0.3919, 0.6126, 0.4133]}, {"w": "9-10):", "b": [0.6174, 0.3919, 0.6667, 0.4133]}]}, {"id": "b_3", "type": "paragraph", "text": "Figure 9-10. Silouhette analysis: comparing the silhouette diagrams for various values of k", "words": [{"w": "Figure", "b": [0.1428, 0.7503, 0.1943, 0.7719]}, {"w": "9-10.", "b": [0.1991, 0.7503, 0.2407, 0.7719]}, {"w": "Silouhette", "b": [0.2455, 0.7503, 0.3258, 0.7719]}, {"w": "analysis:", "b": [0.3306, 0.7503, 0.4, 0.7719]}, {"w": "comparing", "b": [0.4048, 0.7503, 0.4909, 0.7719]}, {"w": "the", "b": [0.4957, 0.7503, 0.5207, 0.7719]}, {"w": "silhouette", "b": [0.5255, 0.7503, 0.6032, 0.7719]}, {"w": "diagrams", "b": [0.608, 0.7503, 0.6832, 0.7719]}, {"w": "for", "b": [0.6879, 0.7503, 0.7106, 0.7719]}, {"w": "various", "b": [0.7153, 0.7503, 0.7757, 0.7719]}, {"w": "values", "b": [0.7804, 0.7503, 0.8308, 0.7719]}, {"w": "of", "b": [0.8355, 0.7503, 0.8507, 0.7719]}, {"w": "k", "b": [0.1428, 0.7693, 0.1526, 0.791]}]}, {"id": "b_4", "type": "paragraph", "text": "The vertical dashed lines represent the silhouette score for each number of clusters. When most of the instances in a cluster have a lower coefficient than this score (i.e., if many of the instances stop short of the dashed line, ending to the left of it), then the cluster is rather bad since this means its instances are much too close to other clus‐", "words": [{"w": "The", "b": [0.1428, 0.8067, 0.1757, 0.8281]}, {"w": "vertical", "b": [0.1823, 0.8067, 0.2437, 0.8281]}, {"w": "dashed", "b": [0.2503, 0.8067, 0.309, 0.8281]}, {"w": "lines", "b": [0.3156, 0.8067, 0.3544, 0.8281]}, {"w": "represent", "b": [0.361, 0.8067, 0.4389, 0.8281]}, {"w": "the", "b": [0.4455, 0.8067, 0.4719, 0.8281]}, {"w": "silhouette", "b": [0.4785, 0.8067, 0.5602, 0.8281]}, {"w": "score", "b": [0.5668, 0.8067, 0.6105, 0.8281]}, {"w": "for", "b": [0.6171, 0.8067, 0.6416, 0.8281]}, {"w": "each", "b": [0.6482, 0.8067, 0.6861, 0.8281]}, {"w": "number", "b": [0.6927, 0.8067, 0.759, 0.8281]}, {"w": "of", "b": [0.7656, 0.8067, 0.7824, 0.8281]}, {"w": "clusters.", "b": [0.789, 0.8067, 0.8571, 0.8281]}, {"w": "When", "b": [0.1429, 0.8258, 0.1945, 0.8472]}, {"w": "most", "b": [0.1993, 0.8258, 0.241, 0.8472]}, {"w": "of", "b": [0.2459, 0.8258, 0.2627, 0.8472]}, {"w": "the", "b": [0.2676, 0.8258, 0.2939, 0.8472]}, {"w": "instances", "b": [0.2988, 0.8258, 0.3756, 0.8472]}, {"w": "in", "b": [0.3805, 0.8258, 0.3975, 0.8472]}, {"w": "a", "b": [0.4024, 0.8258, 0.4115, 0.8472]}, {"w": "cluster", "b": [0.4164, 0.8258, 0.4721, 0.8472]}, {"w": "have", "b": [0.477, 0.8258, 0.5154, 0.8472]}, {"w": "a", "b": [0.5203, 0.8258, 0.5294, 0.8472]}, {"w": "lower", "b": [0.5343, 0.8258, 0.581, 0.8472]}, {"w": "coefficient", "b": [0.5859, 0.8258, 0.6727, 0.8472]}, {"w": "than", "b": [0.6776, 0.8258, 0.7156, 0.8472]}, {"w": "this", "b": [0.7205, 0.8258, 0.7512, 0.8472]}, {"w": "score", "b": [0.7561, 0.8258, 0.7997, 0.8472]}, {"w": "(i.e.,", "b": [0.8046, 0.8258, 0.8405, 0.8472]}, {"w": "if", "b": [0.8454, 0.8258, 0.8571, 0.8472]}, {"w": "many", "b": [0.1429, 0.8448, 0.1895, 0.8662]}, {"w": "of", "b": [0.1953, 0.8448, 0.2121, 0.8662]}, {"w": "the", "b": [0.2179, 0.8448, 0.2442, 0.8662]}, {"w": "instances", "b": [0.25, 0.8448, 0.3268, 0.8662]}, {"w": "stop", "b": [0.3326, 0.8448, 0.3681, 0.8662]}, {"w": "short", "b": [0.3739, 0.8448, 0.4174, 0.8662]}, {"w": "of", "b": [0.4232, 0.8448, 0.44, 0.8662]}, {"w": "the", "b": [0.4457, 0.8448, 0.4721, 0.8662]}, {"w": "dashed", "b": [0.4779, 0.8448, 0.5366, 0.8662]}, {"w": "line,", "b": [0.5424, 0.8448, 0.5783, 0.8662]}, {"w": "ending", "b": [0.584, 0.8448, 0.642, 0.8662]}, {"w": "to", "b": [0.6478, 0.8448, 0.6648, 0.8662]}, {"w": "the", "b": [0.6705, 0.8448, 0.6969, 0.8662]}, {"w": "left", "b": [0.7026, 0.8448, 0.7293, 0.8662]}, {"w": "of", "b": [0.7351, 0.8448, 0.7519, 0.8662]}, {"w": "it),", "b": [0.7576, 0.8448, 0.7815, 0.8662]}, {"w": "then", "b": [0.7873, 0.8448, 0.825, 0.8662]}, {"w": "the", "b": [0.8308, 0.8448, 0.8571, 0.8662]}, {"w": "cluster", "b": [0.1429, 0.8639, 0.1986, 0.8853]}, {"w": "is", "b": [0.205, 0.8639, 0.2182, 0.8853]}, {"w": "rather", "b": [0.2247, 0.8639, 0.2752, 0.8853]}, {"w": "bad", "b": [0.2816, 0.8639, 0.3124, 0.8853]}, {"w": "since", "b": [0.3188, 0.8639, 0.3611, 0.8853]}, {"w": "this", "b": [0.3675, 0.8639, 0.3982, 0.8853]}, {"w": "means", "b": [0.4047, 0.8639, 0.4588, 0.8853]}, {"w": "its", "b": [0.4652, 0.8639, 0.4848, 0.8853]}, {"w": "instances", "b": [0.4912, 0.8639, 0.568, 0.8853]}, {"w": "are", "b": [0.5745, 0.8639, 0.6002, 0.8853]}, {"w": "much", "b": [0.6066, 0.8639, 0.6543, 0.8853]}, {"w": "too", "b": [0.6607, 0.8639, 0.6883, 0.8853]}, {"w": "close", "b": [0.6948, 0.8639, 0.736, 0.8853]}, {"w": "to", "b": [0.7424, 0.8639, 0.7594, 0.8853]}, {"w": "other", "b": [0.7658, 0.8639, 0.8105, 0.8853]}, {"w": "clus‐", "b": [0.8169, 0.8639, 0.8571, 0.8853]}]}, {"id": "b_5", "type": "paragraph", "text": "Clustering | 249", "words": [{"w": "Clustering", "b": [0.736, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "249", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 276, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "ters. We can see that when k=3 and when k=6, we get bad clusters. But when k=4 or k=5, the clusters look pretty good – most instances extend beyond the dashed line, to the right and closer to 1.0. When k=4, the cluster at index 1 (the third from the top), is rather big, while when k=5, all clusters have similar sizes, so even though the over‐ all silhouette score from k=4 is slightly greater than for k=5, it seems like a good idea to use k=5 to get clusters of similar sizes.", "words": [{"w": "ters.", "b": [0.1429, 0.0791, 0.1782, 0.1005]}, {"w": "We", "b": [0.1841, 0.0791, 0.2112, 0.1005]}, {"w": "can", "b": [0.2171, 0.0791, 0.2465, 0.1005]}, {"w": "see", "b": [0.2524, 0.0791, 0.2777, 0.1005]}, {"w": "that", "b": [0.2837, 0.0791, 0.3163, 0.1005]}, {"w": "when", "b": [0.3222, 0.0791, 0.3678, 0.1005]}, {"w": "k=3", "b": [0.3738, 0.0789, 0.4056, 0.1005]}, {"w": "and", "b": [0.4116, 0.0791, 0.4431, 0.1005]}, {"w": "when", "b": [0.449, 0.0791, 0.4947, 0.1005]}, {"w": "k=6,", "b": [0.5006, 0.0789, 0.5372, 0.1005]}, {"w": "we", "b": [0.5432, 0.0791, 0.5663, 0.1005]}, {"w": "get", "b": [0.5722, 0.0791, 0.5972, 0.1005]}, {"w": "bad", "b": [0.6031, 0.0791, 0.6338, 0.1005]}, {"w": "clusters.", "b": [0.6398, 0.0791, 0.7079, 0.1005]}, {"w": "But", "b": [0.7138, 0.0791, 0.7435, 0.1005]}, {"w": "when", "b": [0.7494, 0.0791, 0.7951, 0.1005]}, {"w": "k=4", "b": [0.801, 0.0789, 0.8329, 0.1005]}, {"w": "or", "b": [0.8388, 0.0791, 0.8571, 0.1005]}, {"w": "k=5,", "b": [0.1429, 0.0979, 0.1795, 0.1195]}, {"w": "the", "b": [0.1847, 0.0981, 0.2111, 0.1195]}, {"w": "clusters", "b": [0.2163, 0.0981, 0.2797, 0.1195]}, {"w": "look", "b": [0.285, 0.0981, 0.3218, 0.1195]}, {"w": "pretty", "b": [0.3271, 0.0981, 0.3769, 0.1195]}, {"w": "good", "b": [0.3821, 0.0981, 0.4241, 0.1195]}, {"w": "–", "b": [0.4294, 0.0981, 0.4402, 0.1195]}, {"w": "most", "b": [0.4455, 0.0981, 0.4872, 0.1195]}, {"w": "instances", "b": [0.4925, 0.0981, 0.5693, 0.1195]}, {"w": "extend", "b": [0.5746, 0.0981, 0.6308, 0.1195]}, {"w": "beyond", "b": [0.6361, 0.0981, 0.6981, 0.1195]}, {"w": "the", "b": [0.7034, 0.0981, 0.7297, 0.1195]}, {"w": "dashed", "b": [0.735, 0.0981, 0.7938, 0.1195]}, {"w": "line,", "b": [0.799, 0.0981, 0.8349, 0.1195]}, {"w": "to", "b": [0.8402, 0.0981, 0.8571, 0.1195]}, {"w": "the", "b": [0.1429, 0.1172, 0.1692, 0.1386]}, {"w": "right", "b": [0.1748, 0.1172, 0.215, 0.1386]}, {"w": "and", "b": [0.2206, 0.1172, 0.2521, 0.1386]}, {"w": "closer", "b": [0.2578, 0.1172, 0.3067, 0.1386]}, {"w": "to", "b": [0.3123, 0.1172, 0.3293, 0.1386]}, {"w": "1.0.", "b": [0.3349, 0.1172, 0.3644, 0.1386]}, {"w": "When", "b": [0.3701, 0.1172, 0.4217, 0.1386]}, {"w": "k=4,", "b": [0.4273, 0.117, 0.4639, 0.1386]}, {"w": "the", "b": [0.4696, 0.1172, 0.4959, 0.1386]}, {"w": "cluster", "b": [0.5015, 0.1172, 0.5573, 0.1386]}, {"w": "at", "b": [0.5629, 0.1172, 0.578, 0.1386]}, {"w": "index", "b": [0.5836, 0.1172, 0.6303, 0.1386]}, {"w": "1", "b": [0.6359, 0.1172, 0.6459, 0.1386]}, {"w": "(the", "b": [0.6515, 0.1172, 0.6851, 0.1386]}, {"w": "third", "b": [0.6907, 0.1172, 0.7325, 0.1386]}, {"w": "from", "b": [0.7381, 0.1172, 0.7797, 0.1386]}, {"w": "the", "b": [0.7853, 0.1172, 0.8117, 0.1386]}, {"w": "top),", "b": [0.8173, 0.1172, 0.8572, 0.1386]}, {"w": "is", "b": [0.1429, 0.1362, 0.1561, 0.1576]}, {"w": "rather", "b": [0.1616, 0.1362, 0.2121, 0.1576]}, {"w": "big,", "b": [0.2176, 0.1362, 0.2482, 0.1576]}, {"w": "while", "b": [0.2537, 0.1362, 0.2988, 0.1576]}, {"w": "when", "b": [0.3043, 0.1362, 0.3499, 0.1576]}, {"w": "k=5,", "b": [0.3554, 0.136, 0.392, 0.1576]}, {"w": "all", "b": [0.3975, 0.1362, 0.4172, 0.1576]}, {"w": "clusters", "b": [0.4227, 0.1362, 0.486, 0.1576]}, {"w": "have", "b": [0.4915, 0.1362, 0.5299, 0.1576]}, {"w": "similar", "b": [0.5354, 0.1362, 0.5934, 0.1576]}, {"w": "sizes,", "b": [0.5989, 0.1362, 0.6421, 0.1576]}, {"w": "so", "b": [0.6476, 0.1362, 0.6659, 0.1576]}, {"w": "even", "b": [0.6713, 0.1362, 0.7101, 0.1576]}, {"w": "though", "b": [0.7156, 0.1362, 0.7756, 0.1576]}, {"w": "the", "b": [0.7811, 0.1362, 0.8074, 0.1576]}, {"w": "over‐", "b": [0.8129, 0.1362, 0.8571, 0.1576]}, {"w": "all", "b": [0.1429, 0.1553, 0.1625, 0.1767]}, {"w": "silhouette", "b": [0.168, 0.1553, 0.2497, 0.1767]}, {"w": "score", "b": [0.2552, 0.1553, 0.2989, 0.1767]}, {"w": "from", "b": [0.3043, 0.1553, 0.3459, 0.1767]}, {"w": "k=4", "b": [0.3514, 0.155, 0.3832, 0.1767]}, {"w": "is", "b": [0.3887, 0.1553, 0.4019, 0.1767]}, {"w": "slightly", "b": [0.4074, 0.1553, 0.4676, 0.1767]}, {"w": "greater", "b": [0.473, 0.1553, 0.531, 0.1767]}, {"w": "than", "b": [0.5365, 0.1553, 0.5745, 0.1767]}, {"w": "for", "b": [0.58, 0.1553, 0.6045, 0.1767]}, {"w": "k=5,", "b": [0.61, 0.155, 0.6466, 0.1767]}, {"w": "it", "b": [0.6521, 0.1553, 0.664, 0.1767]}, {"w": "seems", "b": [0.6695, 0.1553, 0.7195, 0.1767]}, {"w": "like", "b": [0.725, 0.1553, 0.755, 0.1767]}, {"w": "a", "b": [0.7605, 0.1553, 0.7696, 0.1767]}, {"w": "good", "b": [0.7751, 0.1553, 0.8171, 0.1767]}, {"w": "idea", "b": [0.8226, 0.1553, 0.8571, 0.1767]}, {"w": "to", "b": [0.1428, 0.1743, 0.1598, 0.1957]}, {"w": "use", "b": [0.1646, 0.1743, 0.1921, 0.1957]}, {"w": "k=5", "b": [0.1968, 0.1741, 0.2287, 0.1957]}, {"w": "to", "b": [0.2335, 0.1743, 0.2504, 0.1957]}, {"w": "get", "b": [0.2552, 0.1743, 0.2801, 0.1957]}, {"w": "clusters", "b": [0.2848, 0.1743, 0.3482, 0.1957]}, {"w": "of", "b": [0.353, 0.1743, 0.3697, 0.1957]}, {"w": "similar", "b": [0.3745, 0.1743, 0.4325, 0.1957]}, {"w": "sizes.", "b": [0.4372, 0.1743, 0.4805, 0.1957]}]}, {"id": "b_1", "type": "equation", "text": "Limits of K-Means", "words": [{"w": "Limits", "b": [0.1429, 0.2085, 0.2061, 0.237]}, {"w": "of", "b": [0.211, 0.2085, 0.232, 0.237]}, {"w": "K-Means", "b": [0.237, 0.2085, 0.3263, 0.237]}]}, {"id": "b_2", "type": "paragraph", "text": "Despite its many merits, most notably being fast and scalable, K-Means is not perfect. As we saw, it is necessary to run the algorithm several times to avoid sub-optimal sol‐ utions, plus you need to specify the number of clusters, which can be quite a hassle. Moreover, K-Means does not behave very well when the clusters have varying sizes, different densities, or non-spherical shapes. For example, Figure 9-11 shows how K- Means clusters a dataset containing three ellipsoidal clusters of different dimensions, densities and orientations:", "words": [{"w": "Despite", "b": [0.1429, 0.2429, 0.2064, 0.2644]}, {"w": "its", "b": [0.2114, 0.2429, 0.231, 0.2644]}, {"w": "many", "b": [0.2359, 0.2429, 0.2826, 0.2644]}, {"w": "merits,", "b": [0.2876, 0.2429, 0.3456, 0.2644]}, {"w": "most", "b": [0.3506, 0.2429, 0.3923, 0.2644]}, {"w": "notably", "b": [0.3973, 0.2429, 0.4602, 0.2644]}, {"w": "being", "b": [0.4652, 0.2429, 0.5114, 0.2644]}, {"w": "fast", "b": [0.5163, 0.2429, 0.5457, 0.2644]}, {"w": "and", "b": [0.5506, 0.2429, 0.5822, 0.2644]}, {"w": "scalable,", "b": [0.5872, 0.2429, 0.6567, 0.2644]}, {"w": "K-Means", "b": [0.6616, 0.2429, 0.7381, 0.2644]}, {"w": "is", "b": [0.7431, 0.2429, 0.7564, 0.2644]}, {"w": "not", "b": [0.7613, 0.2429, 0.7897, 0.2644]}, {"w": "perfect.", "b": [0.7947, 0.2429, 0.8571, 0.2644]}, {"w": "As", "b": [0.1429, 0.262, 0.1649, 0.2834]}, {"w": "we", "b": [0.1699, 0.262, 0.1931, 0.2834]}, {"w": "saw,", "b": [0.1981, 0.262, 0.232, 0.2834]}, {"w": "it", "b": [0.2371, 0.262, 0.249, 0.2834]}, {"w": "is", "b": [0.2541, 0.262, 0.2673, 0.2834]}, {"w": "necessary", "b": [0.2724, 0.262, 0.3526, 0.2834]}, {"w": "to", "b": [0.3577, 0.262, 0.3746, 0.2834]}, {"w": "run", "b": [0.3797, 0.262, 0.4099, 0.2834]}, {"w": "the", "b": [0.4149, 0.262, 0.4413, 0.2834]}, {"w": "algorithm", "b": [0.4463, 0.262, 0.529, 0.2834]}, {"w": "several", "b": [0.534, 0.262, 0.5912, 0.2834]}, {"w": "times", "b": [0.5962, 0.262, 0.6417, 0.2834]}, {"w": "to", "b": [0.6468, 0.262, 0.6637, 0.2834]}, {"w": "avoid", "b": [0.6688, 0.262, 0.7144, 0.2834]}, {"w": "sub-optimal", "b": [0.7195, 0.262, 0.8211, 0.2834]}, {"w": "sol‐", "b": [0.8262, 0.262, 0.8571, 0.2834]}, {"w": "utions,", "b": [0.1429, 0.281, 0.2003, 0.3025]}, {"w": "plus", "b": [0.2064, 0.281, 0.2413, 0.3025]}, {"w": "you", "b": [0.2475, 0.281, 0.2787, 0.3025]}, {"w": "need", "b": [0.2849, 0.281, 0.325, 0.3025]}, {"w": "to", "b": [0.3312, 0.281, 0.3481, 0.3025]}, {"w": "specify", "b": [0.3543, 0.281, 0.4122, 0.3025]}, {"w": "the", "b": [0.4184, 0.281, 0.4447, 0.3025]}, {"w": "number", "b": [0.4509, 0.281, 0.5171, 0.3025]}, {"w": "of", "b": [0.5233, 0.281, 0.5401, 0.3025]}, {"w": "clusters,", "b": [0.5463, 0.281, 0.6144, 0.3025]}, {"w": "which", "b": [0.6205, 0.281, 0.6715, 0.3025]}, {"w": "can", "b": [0.6776, 0.281, 0.707, 0.3025]}, {"w": "be", "b": [0.7131, 0.281, 0.7326, 0.3025]}, {"w": "quite", "b": [0.7387, 0.281, 0.7812, 0.3025]}, {"w": "a", "b": [0.7874, 0.281, 0.7965, 0.3025]}, {"w": "hassle.", "b": [0.8027, 0.281, 0.8571, 0.3025]}, {"w": "Moreover,", "b": [0.1429, 0.3001, 0.2284, 0.3215]}, {"w": "K-Means", "b": [0.2348, 0.3001, 0.3113, 0.3215]}, {"w": "does", "b": [0.3178, 0.3001, 0.3559, 0.3215]}, {"w": "not", "b": [0.3624, 0.3001, 0.3908, 0.3215]}, {"w": "behave", "b": [0.3972, 0.3001, 0.455, 0.3215]}, {"w": "very", "b": [0.4615, 0.3001, 0.4979, 0.3215]}, {"w": "well", "b": [0.5044, 0.3001, 0.538, 0.3215]}, {"w": "when", "b": [0.5445, 0.3001, 0.5901, 0.3215]}, {"w": "the", "b": [0.5966, 0.3001, 0.6229, 0.3215]}, {"w": "clusters", "b": [0.6294, 0.3001, 0.6927, 0.3215]}, {"w": "have", "b": [0.6992, 0.3001, 0.7376, 0.3215]}, {"w": "varying", "b": [0.744, 0.3001, 0.8075, 0.3215]}, {"w": "sizes,", "b": [0.8139, 0.3001, 0.8572, 0.3215]}, {"w": "different", "b": [0.1429, 0.3191, 0.2146, 0.3405]}, {"w": "densities,", "b": [0.2207, 0.3191, 0.2984, 0.3405]}, {"w": "or", "b": [0.3045, 0.3191, 0.3229, 0.3405]}, {"w": "non-spherical", "b": [0.329, 0.3191, 0.4449, 0.3405]}, {"w": "shapes.", "b": [0.451, 0.3191, 0.5107, 0.3405]}, {"w": "For", "b": [0.5169, 0.3191, 0.5459, 0.3405]}, {"w": "example,", "b": [0.552, 0.3191, 0.6263, 0.3405]}, {"w": "Figure", "b": [0.6324, 0.3191, 0.6864, 0.3405]}, {"w": "9-11", "b": [0.6926, 0.3191, 0.73, 0.3405]}, {"w": "shows", "b": [0.7361, 0.3191, 0.7874, 0.3405]}, {"w": "how", "b": [0.7936, 0.3191, 0.8296, 0.3405]}, {"w": "K-", "b": [0.8357, 0.3191, 0.8571, 0.3405]}, {"w": "Means", "b": [0.1429, 0.3382, 0.1979, 0.3596]}, {"w": "clusters", "b": [0.2037, 0.3382, 0.267, 0.3596]}, {"w": "a", "b": [0.2728, 0.3382, 0.2819, 0.3596]}, {"w": "dataset", "b": [0.2877, 0.3382, 0.3458, 0.3596]}, {"w": "containing", "b": [0.3515, 0.3382, 0.4412, 0.3596]}, {"w": "three", "b": [0.4469, 0.3382, 0.4898, 0.3596]}, {"w": "ellipsoidal", "b": [0.4956, 0.3382, 0.5807, 0.3596]}, {"w": "clusters", "b": [0.5865, 0.3382, 0.6499, 0.3596]}, {"w": "of", "b": [0.6556, 0.3382, 0.6724, 0.3596]}, {"w": "different", "b": [0.6781, 0.3382, 0.7499, 0.3596]}, {"w": "dimensions,", "b": [0.7556, 0.3382, 0.8571, 0.3596]}, {"w": "densities", "b": [0.1429, 0.3572, 0.2158, 0.3786]}, {"w": "and", "b": [0.2205, 0.3572, 0.2521, 0.3786]}, {"w": "orientations:", "b": [0.2568, 0.3572, 0.362, 0.3786]}]}, {"id": "b_3", "type": "equation", "text": "Figure 9-11. K-Means fails to cluster these ellipsoidal blobs properly", "words": [{"w": "Figure", "b": [0.1429, 0.5202, 0.1943, 0.5418]}, {"w": "9-11.", "b": [0.1991, 0.5202, 0.2407, 0.5418]}, {"w": "K-Means", "b": [0.2455, 0.5202, 0.3199, 0.5418]}, {"w": "fails", "b": [0.3247, 0.5202, 0.3578, 0.5418]}, {"w": "to", "b": [0.3626, 0.5202, 0.3786, 0.5418]}, {"w": "cluster", "b": [0.3834, 0.5202, 0.4361, 0.5418]}, {"w": "these", "b": [0.4409, 0.5202, 0.4812, 0.5418]}, {"w": "ellipsoidal", "b": [0.486, 0.5202, 0.5674, 0.5418]}, {"w": "blobs", "b": [0.5722, 0.5202, 0.6137, 0.5418]}, {"w": "properly", "b": [0.6185, 0.5202, 0.6852, 0.5418]}]}, {"id": "b_4", "type": "paragraph", "text": "As you can see, neither of these solutions are any good. The solution on the left is better, but it still chops off 25% of the middle cluster and assigns it to the cluster on the right. The solution on the right is just terrible, even though its inertia is lower. So depending on the data, different clustering algorithms may perform better. For exam‐ ple, on these types of elliptical clusters, Gaussian mixture models work great.", "words": [{"w": "As", "b": [0.1429, 0.5576, 0.1649, 0.579]}, {"w": "you", "b": [0.172, 0.5576, 0.2033, 0.579]}, {"w": "can", "b": [0.2104, 0.5576, 0.2398, 0.579]}, {"w": "see,", "b": [0.2469, 0.5576, 0.277, 0.579]}, {"w": "neither", "b": [0.2841, 0.5576, 0.344, 0.579]}, {"w": "of", "b": [0.3512, 0.5576, 0.368, 0.579]}, {"w": "these", "b": [0.3751, 0.5576, 0.4179, 0.579]}, {"w": "solutions", "b": [0.425, 0.5576, 0.5013, 0.579]}, {"w": "are", "b": [0.5084, 0.5576, 0.5341, 0.579]}, {"w": "any", "b": [0.5412, 0.5576, 0.5709, 0.579]}, {"w": "good.", "b": [0.578, 0.5576, 0.6247, 0.579]}, {"w": "The", "b": [0.6319, 0.5576, 0.6647, 0.579]}, {"w": "solution", "b": [0.6718, 0.5576, 0.7404, 0.579]}, {"w": "on", "b": [0.7475, 0.5576, 0.7696, 0.579]}, {"w": "the", "b": [0.7767, 0.5576, 0.803, 0.579]}, {"w": "left", "b": [0.8101, 0.5576, 0.8368, 0.579]}, {"w": "is", "b": [0.8439, 0.5576, 0.8572, 0.579]}, {"w": "better,", "b": [0.1429, 0.5766, 0.195, 0.5981]}, {"w": "but", "b": [0.2011, 0.5766, 0.2291, 0.5981]}, {"w": "it", "b": [0.2352, 0.5766, 0.2471, 0.5981]}, {"w": "still", "b": [0.2532, 0.5766, 0.2833, 0.5981]}, {"w": "chops", "b": [0.2894, 0.5766, 0.3385, 0.5981]}, {"w": "off", "b": [0.3446, 0.5766, 0.3675, 0.5981]}, {"w": "25%", "b": [0.3736, 0.5766, 0.4094, 0.5981]}, {"w": "of", "b": [0.4154, 0.5766, 0.4322, 0.5981]}, {"w": "the", "b": [0.4383, 0.5766, 0.4646, 0.5981]}, {"w": "middle", "b": [0.4707, 0.5766, 0.5295, 0.5981]}, {"w": "cluster", "b": [0.5356, 0.5766, 0.5913, 0.5981]}, {"w": "and", "b": [0.5974, 0.5766, 0.6289, 0.5981]}, {"w": "assigns", "b": [0.635, 0.5766, 0.6938, 0.5981]}, {"w": "it", "b": [0.6999, 0.5766, 0.7118, 0.5981]}, {"w": "to", "b": [0.7179, 0.5766, 0.7348, 0.5981]}, {"w": "the", "b": [0.7409, 0.5766, 0.7673, 0.5981]}, {"w": "cluster", "b": [0.7733, 0.5766, 0.8291, 0.5981]}, {"w": "on", "b": [0.8351, 0.5766, 0.8571, 0.5981]}, {"w": "the", "b": [0.1429, 0.5957, 0.1692, 0.6171]}, {"w": "right.", "b": [0.1746, 0.5957, 0.2195, 0.6171]}, {"w": "The", "b": [0.2249, 0.5957, 0.2578, 0.6171]}, {"w": "solution", "b": [0.2632, 0.5957, 0.3318, 0.6171]}, {"w": "on", "b": [0.3372, 0.5957, 0.3592, 0.6171]}, {"w": "the", "b": [0.3647, 0.5957, 0.391, 0.6171]}, {"w": "right", "b": [0.3964, 0.5957, 0.4366, 0.6171]}, {"w": "is", "b": [0.442, 0.5957, 0.4552, 0.6171]}, {"w": "just", "b": [0.4607, 0.5957, 0.4911, 0.6171]}, {"w": "terrible,", "b": [0.4965, 0.5957, 0.5622, 0.6171]}, {"w": "even", "b": [0.5676, 0.5957, 0.6064, 0.6171]}, {"w": "though", "b": [0.6118, 0.5957, 0.6718, 0.6171]}, {"w": "its", "b": [0.6773, 0.5957, 0.6969, 0.6171]}, {"w": "inertia", "b": [0.7023, 0.5957, 0.7569, 0.6171]}, {"w": "is", "b": [0.7624, 0.5957, 0.7756, 0.6171]}, {"w": "lower.", "b": [0.781, 0.5957, 0.8312, 0.6171]}, {"w": "So", "b": [0.8366, 0.5957, 0.8571, 0.6171]}, {"w": "depending", "b": [0.1428, 0.6147, 0.2316, 0.6362]}, {"w": "on", "b": [0.2366, 0.6147, 0.2586, 0.6362]}, {"w": "the", "b": [0.2636, 0.6147, 0.2899, 0.6362]}, {"w": "data,", "b": [0.2949, 0.6147, 0.3349, 0.6362]}, {"w": "different", "b": [0.3399, 0.6147, 0.4116, 0.6362]}, {"w": "clustering", "b": [0.4166, 0.6147, 0.499, 0.6362]}, {"w": "algorithms", "b": [0.504, 0.6147, 0.5943, 0.6362]}, {"w": "may", "b": [0.5993, 0.6147, 0.6347, 0.6362]}, {"w": "perform", "b": [0.6397, 0.6147, 0.7087, 0.6362]}, {"w": "better.", "b": [0.7137, 0.6147, 0.7659, 0.6362]}, {"w": "For", "b": [0.7709, 0.6147, 0.7998, 0.6362]}, {"w": "exam‐", "b": [0.8048, 0.6147, 0.8571, 0.6362]}, {"w": "ple,", "b": [0.1429, 0.6338, 0.1727, 0.6552]}, {"w": "on", "b": [0.1774, 0.6338, 0.1994, 0.6552]}, {"w": "these", "b": [0.2041, 0.6338, 0.247, 0.6552]}, {"w": "types", "b": [0.2517, 0.6338, 0.295, 0.6552]}, {"w": "of", "b": [0.2998, 0.6338, 0.3166, 0.6552]}, {"w": "elliptical", "b": [0.3213, 0.6338, 0.3923, 0.6552]}, {"w": "clusters,", "b": [0.3971, 0.6338, 0.4652, 0.6552]}, {"w": "Gaussian", "b": [0.4699, 0.6338, 0.5461, 0.6552]}, {"w": "mixture", "b": [0.5508, 0.6338, 0.6173, 0.6552]}, {"w": "models", "b": [0.622, 0.6338, 0.6824, 0.6552]}, {"w": "work", "b": [0.6872, 0.6338, 0.7301, 0.6552]}, {"w": "great.", "b": [0.7349, 0.6338, 0.7811, 0.6552]}]}, {"id": "b_5", "type": "paragraph", "text": "It is important to scale the input features before you run K-Means, or else the clusters may be very stretched, and K-Means will per‐ form poorly. Scaling the features does not guarantee that all the clusters will be nice and spherical, but it generally improves things.", "words": [{"w": "It", "b": [0.2714, 0.6757, 0.283, 0.6953]}, {"w": "is", "b": [0.2882, 0.6757, 0.3003, 0.6953]}, {"w": "important", "b": [0.3056, 0.6757, 0.3828, 0.6953]}, {"w": "to", "b": [0.388, 0.6757, 0.4035, 0.6953]}, {"w": "scale", "b": [0.4088, 0.6757, 0.4451, 0.6953]}, {"w": "the", "b": [0.4504, 0.6757, 0.4745, 0.6953]}, {"w": "input", "b": [0.4798, 0.6757, 0.5208, 0.6953]}, {"w": "features", "b": [0.5261, 0.6757, 0.5859, 0.6953]}, {"w": "before", "b": [0.5912, 0.6757, 0.6395, 0.6953]}, {"w": "you", "b": [0.6447, 0.6757, 0.6733, 0.6953]}, {"w": "run", "b": [0.6786, 0.6757, 0.7062, 0.6953]}, {"w": "K-Means,", "b": [0.7114, 0.6757, 0.7857, 0.6953]}, {"w": "or", "b": [0.2714, 0.6931, 0.2882, 0.7127]}, {"w": "else", "b": [0.2947, 0.6931, 0.3227, 0.7127]}, {"w": "the", "b": [0.3291, 0.6931, 0.3532, 0.7127]}, {"w": "clusters", "b": [0.3597, 0.6931, 0.4176, 0.7127]}, {"w": "may", "b": [0.4241, 0.6931, 0.4564, 0.7127]}, {"w": "be", "b": [0.4629, 0.6931, 0.4807, 0.7127]}, {"w": "very", "b": [0.4871, 0.6931, 0.5204, 0.7127]}, {"w": "stretched,", "b": [0.5269, 0.6931, 0.6014, 0.7127]}, {"w": "and", "b": [0.6078, 0.6931, 0.6367, 0.7127]}, {"w": "K-Means", "b": [0.6431, 0.6931, 0.7131, 0.7127]}, {"w": "will", "b": [0.7195, 0.6931, 0.7473, 0.7127]}, {"w": "per‐", "b": [0.7538, 0.6931, 0.7857, 0.7127]}, {"w": "form", "b": [0.2714, 0.7106, 0.3094, 0.7301]}, {"w": "poorly.", "b": [0.3172, 0.7106, 0.3701, 0.7301]}, {"w": "Scaling", "b": [0.3779, 0.7106, 0.4326, 0.7301]}, {"w": "the", "b": [0.4403, 0.7106, 0.4644, 0.7301]}, {"w": "features", "b": [0.4721, 0.7106, 0.5319, 0.7301]}, {"w": "does", "b": [0.5396, 0.7106, 0.5745, 0.7301]}, {"w": "not", "b": [0.5822, 0.7106, 0.6081, 0.7301]}, {"w": "guarantee", "b": [0.6158, 0.7106, 0.6907, 0.7301]}, {"w": "that", "b": [0.6984, 0.7106, 0.7282, 0.7301]}, {"w": "all", "b": [0.7359, 0.7106, 0.7539, 0.7301]}, {"w": "the", "b": [0.7616, 0.7106, 0.7857, 0.7301]}, {"w": "clusters", "b": [0.2714, 0.728, 0.3294, 0.7476]}, {"w": "will", "b": [0.3337, 0.728, 0.3615, 0.7476]}, {"w": "be", "b": [0.3658, 0.728, 0.3836, 0.7476]}, {"w": "nice", "b": [0.3879, 0.728, 0.4196, 0.7476]}, {"w": "and", "b": [0.4239, 0.728, 0.4527, 0.7476]}, {"w": "spherical,", "b": [0.4571, 0.728, 0.53, 0.7476]}, {"w": "but", "b": [0.5344, 0.728, 0.56, 0.7476]}, {"w": "it", "b": [0.5643, 0.728, 0.5752, 0.7476]}, {"w": "generally", "b": [0.5795, 0.728, 0.6489, 0.7476]}, {"w": "improves", "b": [0.6532, 0.728, 0.7242, 0.7476]}, {"w": "things.", "b": [0.7285, 0.728, 0.7803, 0.7476]}]}, {"id": "b_6", "type": "paragraph", "text": "Now let’s look at a few ways we can benefit from clustering. We will use K-Means, but feel free to experiment with other clustering algorithms.", "words": [{"w": "Now", "b": [0.1429, 0.7744, 0.1827, 0.7958]}, {"w": "let’s", "b": [0.1877, 0.7744, 0.218, 0.7958]}, {"w": "look", "b": [0.223, 0.7744, 0.2598, 0.7958]}, {"w": "at", "b": [0.2648, 0.7744, 0.2799, 0.7958]}, {"w": "a", "b": [0.285, 0.7744, 0.2941, 0.7958]}, {"w": "few", "b": [0.2991, 0.7744, 0.3284, 0.7958]}, {"w": "ways", "b": [0.3334, 0.7744, 0.3737, 0.7958]}, {"w": "we", "b": [0.3787, 0.7744, 0.4018, 0.7958]}, {"w": "can", "b": [0.4068, 0.7744, 0.4362, 0.7958]}, {"w": "benefit", "b": [0.4412, 0.7744, 0.499, 0.7958]}, {"w": "from", "b": [0.504, 0.7744, 0.5456, 0.7958]}, {"w": "clustering.", "b": [0.5506, 0.7744, 0.6378, 0.7958]}, {"w": "We", "b": [0.6428, 0.7744, 0.6699, 0.7958]}, {"w": "will", "b": [0.6749, 0.7744, 0.7053, 0.7958]}, {"w": "use", "b": [0.7103, 0.7744, 0.7379, 0.7958]}, {"w": "K-Means,", "b": [0.7429, 0.7744, 0.8241, 0.7958]}, {"w": "but", "b": [0.8291, 0.7744, 0.8571, 0.7958]}, {"w": "feel", "b": [0.1429, 0.7934, 0.172, 0.8148]}, {"w": "free", "b": [0.1767, 0.7934, 0.2083, 0.8148]}, {"w": "to", "b": [0.2131, 0.7934, 0.23, 0.8148]}, {"w": "experiment", "b": [0.2348, 0.7934, 0.3298, 0.8148]}, {"w": "with", "b": [0.3345, 0.7934, 0.3719, 0.8148]}, {"w": "other", "b": [0.3766, 0.7934, 0.4213, 0.8148]}, {"w": "clustering", "b": [0.426, 0.7934, 0.5085, 0.8148]}, {"w": "algorithms.", "b": [0.5132, 0.7934, 0.6082, 0.8148]}]}, {"id": "b_7", "type": "paragraph", "text": "250 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "250", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 277, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Using clustering for image segmentation", "words": [{"w": "Using", "b": [0.1429, 0.0763, 0.2008, 0.1049]}, {"w": "clustering", "b": [0.2058, 0.0763, 0.3083, 0.1049]}, {"w": "for", "b": [0.3132, 0.0763, 0.3427, 0.1049]}, {"w": "image", "b": [0.3477, 0.0763, 0.4125, 0.1049]}, {"w": "segmentation", "b": [0.4175, 0.0763, 0.5622, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "Image segmentation is the task of partitioning an image into multiple segments. In semantic segmentation, all pixels that are part of the same object type get assigned to the same segment. For example, in a self-driving car’s vision system, all pixels that are part of a pedestrian’s image might be assigned to the “pedestrian” segment (there would just be one segment containing all the pedestrians). In instance segmentation, all pixels that are part of the same individual object are assigned to the same segment. In this case there would be a different segment for each pedestrian. The state of the art in semantic or instance segmentation today is achieved using complex architec‐ tures based on convolutional neural networks (see Chapter 14). Here, we are going to do something much simpler: color segmentation. We will simply assign pixels to the same segment if they have a similar color. In some applications, this may be sufficient, for example if you want to analyze satellite images to measure how much total forest area there is in a region, color segmentation may be just fine.", "words": [{"w": "Image", "b": [0.1428, 0.1106, 0.1922, 0.1322]}, {"w": "segmentation", "b": [0.1999, 0.1106, 0.3077, 0.1322]}, {"w": "is", "b": [0.3153, 0.1108, 0.3286, 0.1322]}, {"w": "the", "b": [0.3362, 0.1108, 0.3626, 0.1322]}, {"w": "task", "b": [0.3702, 0.1108, 0.4037, 0.1322]}, {"w": "of", "b": [0.4114, 0.1108, 0.4282, 0.1322]}, {"w": "partitioning", "b": [0.4358, 0.1108, 0.5362, 0.1322]}, {"w": "an", "b": [0.5439, 0.1108, 0.5644, 0.1322]}, {"w": "image", "b": [0.5721, 0.1108, 0.6225, 0.1322]}, {"w": "into", "b": [0.6302, 0.1108, 0.6637, 0.1322]}, {"w": "multiple", "b": [0.6714, 0.1108, 0.7414, 0.1322]}, {"w": "segments.", "b": [0.7491, 0.1108, 0.831, 0.1322]}, {"w": "In", "b": [0.8386, 0.1108, 0.8571, 0.1322]}, {"w": "semantic", "b": [0.1429, 0.1296, 0.2148, 0.1512]}, {"w": "segmentation,", "b": [0.2209, 0.1296, 0.3334, 0.1512]}, {"w": "all", "b": [0.3394, 0.1298, 0.3591, 0.1512]}, {"w": "pixels", "b": [0.3651, 0.1298, 0.4132, 0.1512]}, {"w": "that", "b": [0.4193, 0.1298, 0.4518, 0.1512]}, {"w": "are", "b": [0.4579, 0.1298, 0.4836, 0.1512]}, {"w": "part", "b": [0.4897, 0.1298, 0.5238, 0.1512]}, {"w": "of", "b": [0.5298, 0.1298, 0.5466, 0.1512]}, {"w": "the", "b": [0.5527, 0.1298, 0.579, 0.1512]}, {"w": "same", "b": [0.585, 0.1298, 0.6277, 0.1512]}, {"w": "object", "b": [0.6338, 0.1298, 0.6843, 0.1512]}, {"w": "type", "b": [0.6904, 0.1298, 0.7261, 0.1512]}, {"w": "get", "b": [0.7321, 0.1298, 0.7571, 0.1512]}, {"w": "assigned", "b": [0.7631, 0.1298, 0.8341, 0.1512]}, {"w": "to", "b": [0.8402, 0.1298, 0.8571, 0.1512]}, {"w": "the", "b": [0.1429, 0.1489, 0.1692, 0.1703]}, {"w": "same", "b": [0.1743, 0.1489, 0.217, 0.1703]}, {"w": "segment.", "b": [0.2221, 0.1489, 0.2963, 0.1703]}, {"w": "For", "b": [0.3014, 0.1489, 0.3304, 0.1703]}, {"w": "example,", "b": [0.3355, 0.1489, 0.4097, 0.1703]}, {"w": "in", "b": [0.4148, 0.1489, 0.4318, 0.1703]}, {"w": "a", "b": [0.4369, 0.1489, 0.446, 0.1703]}, {"w": "self-driving", "b": [0.4511, 0.1489, 0.5471, 0.1703]}, {"w": "car’s", "b": [0.5522, 0.1489, 0.5882, 0.1703]}, {"w": "vision", "b": [0.5933, 0.1489, 0.6438, 0.1703]}, {"w": "system,", "b": [0.6489, 0.1489, 0.7107, 0.1703]}, {"w": "all", "b": [0.7158, 0.1489, 0.7355, 0.1703]}, {"w": "pixels", "b": [0.7406, 0.1489, 0.7887, 0.1703]}, {"w": "that", "b": [0.7938, 0.1489, 0.8263, 0.1703]}, {"w": "are", "b": [0.8314, 0.1489, 0.8571, 0.1703]}, {"w": "part", "b": [0.1429, 0.1679, 0.177, 0.1893]}, {"w": "of", "b": [0.1856, 0.1679, 0.2024, 0.1893]}, {"w": "a", "b": [0.211, 0.1679, 0.2201, 0.1893]}, {"w": "pedestrian’s", "b": [0.2287, 0.1679, 0.3248, 0.1893]}, {"w": "image", "b": [0.3334, 0.1679, 0.3838, 0.1893]}, {"w": "might", "b": [0.3924, 0.1679, 0.4419, 0.1893]}, {"w": "be", "b": [0.4505, 0.1679, 0.4699, 0.1893]}, {"w": "assigned", "b": [0.4785, 0.1679, 0.5495, 0.1893]}, {"w": "to", "b": [0.5581, 0.1679, 0.5751, 0.1893]}, {"w": "the", "b": [0.5837, 0.1679, 0.61, 0.1893]}, {"w": "“pedestrian”", "b": [0.6186, 0.1679, 0.7203, 0.1893]}, {"w": "segment", "b": [0.7289, 0.1679, 0.7984, 0.1893]}, {"w": "(there", "b": [0.807, 0.1679, 0.8571, 0.1893]}, {"w": "would", "b": [0.1429, 0.187, 0.1951, 0.2084]}, {"w": "just", "b": [0.2016, 0.187, 0.232, 0.2084]}, {"w": "be", "b": [0.2385, 0.187, 0.2579, 0.2084]}, {"w": "one", "b": [0.2645, 0.187, 0.2953, 0.2084]}, {"w": "segment", "b": [0.3018, 0.187, 0.3714, 0.2084]}, {"w": "containing", "b": [0.3779, 0.187, 0.4675, 0.2084]}, {"w": "all", "b": [0.474, 0.187, 0.4937, 0.2084]}, {"w": "the", "b": [0.5002, 0.187, 0.5266, 0.2084]}, {"w": "pedestrians).", "b": [0.5331, 0.187, 0.6401, 0.2084]}, {"w": "In", "b": [0.6467, 0.187, 0.6652, 0.2084]}, {"w": "instance", "b": [0.6717, 0.1868, 0.7381, 0.2084]}, {"w": "segmentation,", "b": [0.7447, 0.1868, 0.8572, 0.2084]}, {"w": "all", "b": [0.1429, 0.206, 0.1625, 0.2274]}, {"w": "pixels", "b": [0.1676, 0.206, 0.2157, 0.2274]}, {"w": "that", "b": [0.2207, 0.206, 0.2533, 0.2274]}, {"w": "are", "b": [0.2583, 0.206, 0.284, 0.2274]}, {"w": "part", "b": [0.2891, 0.206, 0.3232, 0.2274]}, {"w": "of", "b": [0.3282, 0.206, 0.345, 0.2274]}, {"w": "the", "b": [0.35, 0.206, 0.3764, 0.2274]}, {"w": "same", "b": [0.3814, 0.206, 0.4241, 0.2274]}, {"w": "individual", "b": [0.4291, 0.206, 0.5144, 0.2274]}, {"w": "object", "b": [0.5194, 0.206, 0.57, 0.2274]}, {"w": "are", "b": [0.575, 0.206, 0.6007, 0.2274]}, {"w": "assigned", "b": [0.6057, 0.206, 0.6768, 0.2274]}, {"w": "to", "b": [0.6818, 0.206, 0.6988, 0.2274]}, {"w": "the", "b": [0.7038, 0.206, 0.7301, 0.2274]}, {"w": "same", "b": [0.7351, 0.206, 0.7779, 0.2274]}, {"w": "segment.", "b": [0.7829, 0.206, 0.8571, 0.2274]}, {"w": "In", "b": [0.1429, 0.2251, 0.1614, 0.2465]}, {"w": "this", "b": [0.1678, 0.2251, 0.1985, 0.2465]}, {"w": "case", "b": [0.205, 0.2251, 0.2395, 0.2465]}, {"w": "there", "b": [0.2459, 0.2251, 0.2888, 0.2465]}, {"w": "would", "b": [0.2953, 0.2251, 0.3475, 0.2465]}, {"w": "be", "b": [0.354, 0.2251, 0.3735, 0.2465]}, {"w": "a", "b": [0.3799, 0.2251, 0.3891, 0.2465]}, {"w": "different", "b": [0.3955, 0.2251, 0.4673, 0.2465]}, {"w": "segment", "b": [0.4737, 0.2251, 0.5432, 0.2465]}, {"w": "for", "b": [0.5497, 0.2251, 0.5742, 0.2465]}, {"w": "each", "b": [0.5807, 0.2251, 0.6186, 0.2465]}, {"w": "pedestrian.", "b": [0.6251, 0.2251, 0.7173, 0.2465]}, {"w": "The", "b": [0.7238, 0.2251, 0.7566, 0.2465]}, {"w": "state", "b": [0.7631, 0.2251, 0.8011, 0.2465]}, {"w": "of", "b": [0.8075, 0.2251, 0.8243, 0.2465]}, {"w": "the", "b": [0.8308, 0.2251, 0.8571, 0.2465]}, {"w": "art", "b": [0.1428, 0.2441, 0.1661, 0.2655]}, {"w": "in", "b": [0.1731, 0.2441, 0.1901, 0.2655]}, {"w": "semantic", "b": [0.1971, 0.2441, 0.2715, 0.2655]}, {"w": "or", "b": [0.2785, 0.2441, 0.2969, 0.2655]}, {"w": "instance", "b": [0.3039, 0.2441, 0.3731, 0.2655]}, {"w": "segmentation", "b": [0.3801, 0.2441, 0.4923, 0.2655]}, {"w": "today", "b": [0.4993, 0.2441, 0.5456, 0.2655]}, {"w": "is", "b": [0.5526, 0.2441, 0.5658, 0.2655]}, {"w": "achieved", "b": [0.5729, 0.2441, 0.6459, 0.2655]}, {"w": "using", "b": [0.6529, 0.2441, 0.6983, 0.2655]}, {"w": "complex", "b": [0.7053, 0.2441, 0.7763, 0.2655]}, {"w": "architec‐", "b": [0.7833, 0.2441, 0.8571, 0.2655]}, {"w": "tures", "b": [0.1429, 0.2632, 0.1845, 0.2846]}, {"w": "based", "b": [0.1896, 0.2632, 0.2369, 0.2846]}, {"w": "on", "b": [0.242, 0.2632, 0.264, 0.2846]}, {"w": "convolutional", "b": [0.2692, 0.2632, 0.3845, 0.2846]}, {"w": "neural", "b": [0.3896, 0.2632, 0.4431, 0.2846]}, {"w": "networks", "b": [0.4482, 0.2632, 0.5254, 0.2846]}, {"w": "(see", "b": [0.5306, 0.2632, 0.5631, 0.2846]}, {"w": "Chapter", "b": [0.5682, 0.2632, 0.6358, 0.2846]}, {"w": "14).", "b": [0.6406, 0.2632, 0.6729, 0.2846]}, {"w": "Here,", "b": [0.678, 0.2632, 0.7237, 0.2846]}, {"w": "we", "b": [0.7288, 0.2632, 0.7519, 0.2846]}, {"w": "are", "b": [0.7571, 0.2632, 0.7828, 0.2846]}, {"w": "going", "b": [0.7879, 0.2632, 0.835, 0.2846]}, {"w": "to", "b": [0.8402, 0.2632, 0.8571, 0.2846]}, {"w": "do", "b": [0.1429, 0.2822, 0.1645, 0.3036]}, {"w": "something", "b": [0.1712, 0.2822, 0.2596, 0.3036]}, {"w": "much", "b": [0.2663, 0.2822, 0.314, 0.3036]}, {"w": "simpler:", "b": [0.3207, 0.2822, 0.3886, 0.3036]}, {"w": "color", "b": [0.3954, 0.282, 0.4351, 0.3036]}, {"w": "segmentation.", "b": [0.4419, 0.282, 0.5543, 0.3036]}, {"w": "We", "b": [0.5611, 0.2822, 0.5881, 0.3036]}, {"w": "will", "b": [0.5949, 0.2822, 0.6253, 0.3036]}, {"w": "simply", "b": [0.632, 0.2822, 0.6876, 0.3036]}, {"w": "assign", "b": [0.6944, 0.2822, 0.7455, 0.3036]}, {"w": "pixels", "b": [0.7523, 0.2822, 0.8004, 0.3036]}, {"w": "to", "b": [0.8071, 0.2822, 0.8241, 0.3036]}, {"w": "the", "b": [0.8308, 0.2822, 0.8571, 0.3036]}, {"w": "same", "b": [0.1429, 0.3013, 0.1856, 0.3227]}, {"w": "segment", "b": [0.1903, 0.3013, 0.2598, 0.3227]}, {"w": "if", "b": [0.2646, 0.3013, 0.2763, 0.3227]}, {"w": "they", "b": [0.281, 0.3013, 0.3169, 0.3227]}, {"w": "have", "b": [0.3217, 0.3013, 0.3601, 0.3227]}, {"w": "a", "b": [0.3648, 0.3013, 0.3739, 0.3227]}, {"w": "similar", "b": [0.3787, 0.3013, 0.4367, 0.3227]}, {"w": "color.", "b": [0.4414, 0.3013, 0.4879, 0.3227]}, {"w": "In", "b": [0.4926, 0.3013, 0.5111, 0.3227]}, {"w": "some", "b": [0.5159, 0.3013, 0.5601, 0.3227]}, {"w": "applications,", "b": [0.5648, 0.3013, 0.6701, 0.3227]}, {"w": "this", "b": [0.6749, 0.3013, 0.7056, 0.3227]}, {"w": "may", "b": [0.7103, 0.3013, 0.7457, 0.3227]}, {"w": "be", "b": [0.7504, 0.3013, 0.7699, 0.3227]}, {"w": "sufficient,", "b": [0.7746, 0.3013, 0.8566, 0.3227]}, {"w": "for", "b": [0.1429, 0.3203, 0.1674, 0.3417]}, {"w": "example", "b": [0.1731, 0.3203, 0.2427, 0.3417]}, {"w": "if", "b": [0.2484, 0.3203, 0.2601, 0.3417]}, {"w": "you", "b": [0.2659, 0.3203, 0.2971, 0.3417]}, {"w": "want", "b": [0.3028, 0.3203, 0.3436, 0.3417]}, {"w": "to", "b": [0.3494, 0.3203, 0.3663, 0.3417]}, {"w": "analyze", "b": [0.3721, 0.3203, 0.4342, 0.3417]}, {"w": "satellite", "b": [0.4399, 0.3203, 0.5029, 0.3417]}, {"w": "images", "b": [0.5086, 0.3203, 0.5666, 0.3417]}, {"w": "to", "b": [0.5724, 0.3203, 0.5893, 0.3417]}, {"w": "measure", "b": [0.5951, 0.3203, 0.6654, 0.3417]}, {"w": "how", "b": [0.6711, 0.3203, 0.7072, 0.3417]}, {"w": "much", "b": [0.7129, 0.3203, 0.7606, 0.3417]}, {"w": "total", "b": [0.7663, 0.3203, 0.804, 0.3417]}, {"w": "forest", "b": [0.8098, 0.3203, 0.8572, 0.3417]}, {"w": "area", "b": [0.1429, 0.3394, 0.1777, 0.3608]}, {"w": "there", "b": [0.1825, 0.3394, 0.2254, 0.3608]}, {"w": "is", "b": [0.2301, 0.3394, 0.2433, 0.3608]}, {"w": "in", "b": [0.2481, 0.3394, 0.265, 0.3608]}, {"w": "a", "b": [0.2698, 0.3394, 0.2789, 0.3608]}, {"w": "region,", "b": [0.2837, 0.3394, 0.3423, 0.3608]}, {"w": "color", "b": [0.3471, 0.3394, 0.3901, 0.3608]}, {"w": "segmentation", "b": [0.3949, 0.3394, 0.5071, 0.3608]}, {"w": "may", "b": [0.5118, 0.3394, 0.5472, 0.3608]}, {"w": "be", "b": [0.5519, 0.3394, 0.5714, 0.3608]}, {"w": "just", "b": [0.5761, 0.3394, 0.6065, 0.3608]}, {"w": "fine.", "b": [0.6112, 0.3394, 0.648, 0.3608]}]}, {"id": "b_2", "type": "paragraph", "text": "First, let’s load the image (see the upper left image in Figure 9-12) using Matplotlib’s imread() function:", "words": [{"w": "First,", "b": [0.1429, 0.3675, 0.1859, 0.3889]}, {"w": "let’s", "b": [0.192, 0.3675, 0.2222, 0.3889]}, {"w": "load", "b": [0.2283, 0.3675, 0.2644, 0.3889]}, {"w": "the", "b": [0.2704, 0.3675, 0.2968, 0.3889]}, {"w": "image", "b": [0.3028, 0.3675, 0.3532, 0.3889]}, {"w": "(see", "b": [0.3593, 0.3675, 0.3919, 0.3889]}, {"w": "the", "b": [0.3979, 0.3675, 0.4243, 0.3889]}, {"w": "upper", "b": [0.4304, 0.3675, 0.4798, 0.3889]}, {"w": "left", "b": [0.4859, 0.3675, 0.5126, 0.3889]}, {"w": "image", "b": [0.5186, 0.3675, 0.569, 0.3889]}, {"w": "in", "b": [0.5751, 0.3675, 0.5921, 0.3889]}, {"w": "Figure", "b": [0.5982, 0.3675, 0.6522, 0.3889]}, {"w": "9-12)", "b": [0.6582, 0.3675, 0.7029, 0.3889]}, {"w": "using", "b": [0.7089, 0.3675, 0.7544, 0.3889]}, {"w": "Matplotlib’s", "b": [0.7604, 0.3675, 0.8571, 0.3889]}, {"w": "imread()", "b": [0.1429, 0.3906, 0.222, 0.4057]}, {"w": "function:", "b": [0.2268, 0.3874, 0.3029, 0.4088]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> from matplotlib.image import imread # you could also use `imageio.imread()` >>> image = imread(os.path.join(\"images\",\"clustering\",\"ladybug.png\")) >>> image.shape (533, 800, 3)", "words": [{"w": ">>>", "b": [0.1766, 0.4194, 0.2019, 0.4322]}, {"w": "from", "b": [0.2103, 0.4194, 0.244, 0.4322]}, {"w": "matplotlib.image", "b": [0.2525, 0.4194, 0.3874, 0.4322]}, {"w": "import", "b": [0.3958, 0.4194, 0.4464, 0.4322]}, {"w": "imread", "b": [0.4549, 0.4194, 0.5055, 0.4322]}, {"w": "#", "b": [0.5223, 0.4194, 0.5308, 0.4322]}, {"w": "you", "b": [0.5392, 0.4194, 0.5645, 0.4322]}, {"w": "could", "b": [0.5729, 0.4194, 0.6151, 0.4322]}, {"w": "also", "b": [0.6235, 0.4194, 0.6572, 0.4322]}, {"w": "use", "b": [0.6657, 0.4194, 0.691, 0.4322]}, {"w": "`imageio.imread()`", "b": [0.6994, 0.4194, 0.8512, 0.4322]}, {"w": ">>>", "b": [0.1766, 0.4348, 0.2019, 0.4477]}, {"w": "image", "b": [0.2103, 0.4348, 0.2525, 0.4477]}, {"w": "=", "b": [0.2609, 0.4348, 0.2693, 0.4477]}, {"w": "imread(os.path.join(\"images\",\"clustering\",\"ladybug.png\"))", "b": [0.2778, 0.4348, 0.7584, 0.4477]}, {"w": ">>>", "b": [0.1766, 0.4502, 0.2019, 0.4631]}, {"w": "image.shape", "b": [0.2103, 0.4502, 0.3031, 0.4631]}, {"w": "(533,", "b": [0.1766, 0.4656, 0.2187, 0.4785]}, {"w": "800,", "b": [0.2272, 0.4656, 0.2609, 0.4785]}, {"w": "3)", "b": [0.2693, 0.4656, 0.2862, 0.4785]}]}, {"id": "b_4", "type": "paragraph", "text": "The image is represented as a 3D array: the first dimension’s size is the height, the second is the width, and the third is the number of color channels, in this case red, green and blue (RGB). In other words, for each pixel there is a 3D vector containing the intensities of red, green and blue, each between 0.0 and 1.0 (or between 0 and 255 if you use imageio.imread()). Some images may have less channels, such as gray‐ scale images (one channel), or more channels, such as images with an additional alpha channel for transparency, or satellite images which often contain channels for many light frequencies (e.g., infrared). The following code reshapes the array to get a long list of RGB colors, then it clusters these colors using K-Means. For example, it may identify a color cluster for all shades of green. Next, for each color (e.g., dark green), it looks for the mean color of the pixel’s color cluster. For example, all shades of green may be replaced with the same light green color (assuming the mean color of the green cluster is light green). Finally it reshapes this long list of colors to get the same shape as the original image. And we’re done!", "words": [{"w": "The", "b": [0.1429, 0.4863, 0.1757, 0.5077]}, {"w": "image", "b": [0.183, 0.4863, 0.2334, 0.5077]}, {"w": "is", "b": [0.2406, 0.4863, 0.2538, 0.5077]}, {"w": "represented", "b": [0.2611, 0.4863, 0.3589, 0.5077]}, {"w": "as", "b": [0.3662, 0.4863, 0.383, 0.5077]}, {"w": "a", "b": [0.3902, 0.4863, 0.3994, 0.5077]}, {"w": "3D", "b": [0.4066, 0.4863, 0.432, 0.5077]}, {"w": "array:", "b": [0.4392, 0.4863, 0.4876, 0.5077]}, {"w": "the", "b": [0.4948, 0.4863, 0.5212, 0.5077]}, {"w": "first", "b": [0.5284, 0.4863, 0.5619, 0.5077]}, {"w": "dimension’s", "b": [0.5692, 0.4863, 0.6669, 0.5077]}, {"w": "size", "b": [0.6742, 0.4863, 0.705, 0.5077]}, {"w": "is", "b": [0.7123, 0.4863, 0.7255, 0.5077]}, {"w": "the", "b": [0.7328, 0.4863, 0.7591, 0.5077]}, {"w": "height,", "b": [0.7664, 0.4863, 0.8235, 0.5077]}, {"w": "the", "b": [0.8308, 0.4863, 0.8571, 0.5077]}, {"w": "second", "b": [0.1428, 0.5053, 0.2012, 0.5267]}, {"w": "is", "b": [0.2077, 0.5053, 0.221, 0.5267]}, {"w": "the", "b": [0.2275, 0.5053, 0.2539, 0.5267]}, {"w": "width,", "b": [0.2604, 0.5053, 0.3135, 0.5267]}, {"w": "and", "b": [0.3201, 0.5053, 0.3516, 0.5267]}, {"w": "the", "b": [0.3582, 0.5053, 0.3845, 0.5267]}, {"w": "third", "b": [0.3911, 0.5053, 0.4329, 0.5267]}, {"w": "is", "b": [0.4395, 0.5053, 0.4527, 0.5267]}, {"w": "the", "b": [0.4593, 0.5053, 0.4856, 0.5267]}, {"w": "number", "b": [0.4922, 0.5053, 0.5584, 0.5267]}, {"w": "of", "b": [0.565, 0.5053, 0.5818, 0.5267]}, {"w": "color", "b": [0.5884, 0.5053, 0.6314, 0.5267]}, {"w": "channels,", "b": [0.638, 0.5053, 0.7164, 0.5267]}, {"w": "in", "b": [0.723, 0.5053, 0.7399, 0.5267]}, {"w": "this", "b": [0.7465, 0.5053, 0.7772, 0.5267]}, {"w": "case", "b": [0.7838, 0.5053, 0.8182, 0.5267]}, {"w": "red,", "b": [0.8248, 0.5053, 0.8571, 0.5267]}, {"w": "green", "b": [0.1429, 0.5244, 0.1894, 0.5458]}, {"w": "and", "b": [0.1952, 0.5244, 0.2268, 0.5458]}, {"w": "blue", "b": [0.2326, 0.5244, 0.2683, 0.5458]}, {"w": "(RGB).", "b": [0.2741, 0.5244, 0.3334, 0.5458]}, {"w": "In", "b": [0.3391, 0.5244, 0.3576, 0.5458]}, {"w": "other", "b": [0.3634, 0.5244, 0.4081, 0.5458]}, {"w": "words,", "b": [0.4139, 0.5244, 0.4699, 0.5458]}, {"w": "for", "b": [0.4757, 0.5244, 0.5002, 0.5458]}, {"w": "each", "b": [0.506, 0.5244, 0.5439, 0.5458]}, {"w": "pixel", "b": [0.5497, 0.5244, 0.5902, 0.5458]}, {"w": "there", "b": [0.596, 0.5244, 0.6389, 0.5458]}, {"w": "is", "b": [0.6447, 0.5244, 0.6579, 0.5458]}, {"w": "a", "b": [0.6637, 0.5244, 0.6728, 0.5458]}, {"w": "3D", "b": [0.6786, 0.5244, 0.7039, 0.5458]}, {"w": "vector", "b": [0.7097, 0.5244, 0.7617, 0.5458]}, {"w": "containing", "b": [0.7675, 0.5244, 0.8572, 0.5458]}, {"w": "the", "b": [0.1429, 0.5434, 0.1692, 0.5648]}, {"w": "intensities", "b": [0.1742, 0.5434, 0.2591, 0.5648]}, {"w": "of", "b": [0.2642, 0.5434, 0.281, 0.5648]}, {"w": "red,", "b": [0.286, 0.5434, 0.3183, 0.5648]}, {"w": "green", "b": [0.3234, 0.5434, 0.37, 0.5648]}, {"w": "and", "b": [0.375, 0.5434, 0.4066, 0.5648]}, {"w": "blue,", "b": [0.4116, 0.5434, 0.4522, 0.5648]}, {"w": "each", "b": [0.4572, 0.5434, 0.4952, 0.5648]}, {"w": "between", "b": [0.5002, 0.5434, 0.5694, 0.5648]}, {"w": "0.0", "b": [0.5744, 0.5434, 0.5992, 0.5648]}, {"w": "and", "b": [0.6042, 0.5434, 0.6358, 0.5648]}, {"w": "1.0", "b": [0.6408, 0.5434, 0.6656, 0.5648]}, {"w": "(or", "b": [0.6706, 0.5434, 0.6962, 0.5648]}, {"w": "between", "b": [0.7013, 0.5434, 0.7704, 0.5648]}, {"w": "0", "b": [0.7755, 0.5434, 0.7855, 0.5648]}, {"w": "and", "b": [0.7905, 0.5434, 0.8221, 0.5648]}, {"w": "255", "b": [0.8271, 0.5434, 0.8571, 0.5648]}, {"w": "if", "b": [0.1429, 0.5634, 0.1546, 0.5848]}, {"w": "you", "b": [0.162, 0.5634, 0.1932, 0.5848]}, {"w": "use", "b": [0.2006, 0.5634, 0.2282, 0.5848]}, {"w": "imageio.imread()).", "b": [0.2356, 0.5634, 0.4059, 0.5848]}, {"w": "Some", "b": [0.4133, 0.5634, 0.4597, 0.5848]}, {"w": "images", "b": [0.4671, 0.5634, 0.5251, 0.5848]}, {"w": "may", "b": [0.5325, 0.5634, 0.5679, 0.5848]}, {"w": "have", "b": [0.5753, 0.5634, 0.6137, 0.5848]}, {"w": "less", "b": [0.6211, 0.5634, 0.6505, 0.5848]}, {"w": "channels,", "b": [0.6579, 0.5634, 0.7363, 0.5848]}, {"w": "such", "b": [0.7437, 0.5634, 0.7823, 0.5848]}, {"w": "as", "b": [0.7897, 0.5634, 0.8065, 0.5848]}, {"w": "gray‐", "b": [0.8139, 0.5634, 0.8571, 0.5848]}, {"w": "scale", "b": [0.1429, 0.5824, 0.1826, 0.6038]}, {"w": "images", "b": [0.1912, 0.5824, 0.2492, 0.6038]}, {"w": "(one", "b": [0.2578, 0.5824, 0.2959, 0.6038]}, {"w": "channel),", "b": [0.3045, 0.5824, 0.3824, 0.6038]}, {"w": "or", "b": [0.391, 0.5824, 0.4094, 0.6038]}, {"w": "more", "b": [0.4179, 0.5824, 0.4622, 0.6038]}, {"w": "channels,", "b": [0.4708, 0.5824, 0.5492, 0.6038]}, {"w": "such", "b": [0.5578, 0.5824, 0.5964, 0.6038]}, {"w": "as", "b": [0.605, 0.5824, 0.6218, 0.6038]}, {"w": "images", "b": [0.6304, 0.5824, 0.6884, 0.6038]}, {"w": "with", "b": [0.697, 0.5824, 0.7343, 0.6038]}, {"w": "an", "b": [0.7429, 0.5824, 0.7635, 0.6038]}, {"w": "additional", "b": [0.772, 0.5824, 0.8572, 0.6038]}, {"w": "alpha", "b": [0.1429, 0.6013, 0.1884, 0.6229]}, {"w": "channel", "b": [0.1953, 0.6013, 0.2582, 0.6229]}, {"w": "for", "b": [0.265, 0.6015, 0.2895, 0.6229]}, {"w": "transparency,", "b": [0.2963, 0.6015, 0.4082, 0.6229]}, {"w": "or", "b": [0.415, 0.6015, 0.4333, 0.6229]}, {"w": "satellite", "b": [0.4401, 0.6015, 0.503, 0.6229]}, {"w": "images", "b": [0.5098, 0.6015, 0.5679, 0.6229]}, {"w": "which", "b": [0.5746, 0.6015, 0.6256, 0.6229]}, {"w": "often", "b": [0.6323, 0.6015, 0.6757, 0.6229]}, {"w": "contain", "b": [0.6825, 0.6015, 0.7454, 0.6229]}, {"w": "channels", "b": [0.7522, 0.6015, 0.8258, 0.6229]}, {"w": "for", "b": [0.8326, 0.6015, 0.8571, 0.6229]}, {"w": "many", "b": [0.1429, 0.6205, 0.1895, 0.6419]}, {"w": "light", "b": [0.1951, 0.6205, 0.2327, 0.6419]}, {"w": "frequencies", "b": [0.2383, 0.6205, 0.3339, 0.6419]}, {"w": "(e.g.,", "b": [0.3394, 0.6205, 0.3794, 0.6419]}, {"w": "infrared).", "b": [0.385, 0.6205, 0.4645, 0.6419]}, {"w": "The", "b": [0.47, 0.6205, 0.5029, 0.6419]}, {"w": "following", "b": [0.5084, 0.6205, 0.5874, 0.6419]}, {"w": "code", "b": [0.5929, 0.6205, 0.6322, 0.6419]}, {"w": "reshapes", "b": [0.6377, 0.6205, 0.7092, 0.6419]}, {"w": "the", "b": [0.7147, 0.6205, 0.7411, 0.6419]}, {"w": "array", "b": [0.7466, 0.6205, 0.7895, 0.6419]}, {"w": "to", "b": [0.795, 0.6205, 0.812, 0.6419]}, {"w": "get", "b": [0.8175, 0.6205, 0.8425, 0.6419]}, {"w": "a", "b": [0.848, 0.6205, 0.8571, 0.6419]}, {"w": "long", "b": [0.1429, 0.6396, 0.1799, 0.661]}, {"w": "list", "b": [0.1864, 0.6396, 0.2113, 0.661]}, {"w": "of", "b": [0.2178, 0.6396, 0.2346, 0.661]}, {"w": "RGB", "b": [0.2412, 0.6396, 0.2812, 0.661]}, {"w": "colors,", "b": [0.2878, 0.6396, 0.3432, 0.661]}, {"w": "then", "b": [0.3498, 0.6396, 0.3875, 0.661]}, {"w": "it", "b": [0.3941, 0.6396, 0.406, 0.661]}, {"w": "clusters", "b": [0.4125, 0.6396, 0.4759, 0.661]}, {"w": "these", "b": [0.4825, 0.6396, 0.5253, 0.661]}, {"w": "colors", "b": [0.5318, 0.6396, 0.5825, 0.661]}, {"w": "using", "b": [0.5891, 0.6396, 0.6345, 0.661]}, {"w": "K-Means.", "b": [0.6411, 0.6396, 0.7223, 0.661]}, {"w": "For", "b": [0.7288, 0.6396, 0.7578, 0.661]}, {"w": "example,", "b": [0.7644, 0.6396, 0.8387, 0.661]}, {"w": "it", "b": [0.8452, 0.6396, 0.8571, 0.661]}, {"w": "may", "b": [0.1429, 0.6586, 0.1783, 0.68]}, {"w": "identify", "b": [0.1856, 0.6586, 0.2501, 0.68]}, {"w": "a", "b": [0.2574, 0.6586, 0.2666, 0.68]}, {"w": "color", "b": [0.2739, 0.6586, 0.317, 0.68]}, {"w": "cluster", "b": [0.3243, 0.6586, 0.38, 0.68]}, {"w": "for", "b": [0.3874, 0.6586, 0.4119, 0.68]}, {"w": "all", "b": [0.4193, 0.6586, 0.4389, 0.68]}, {"w": "shades", "b": [0.4463, 0.6586, 0.5017, 0.68]}, {"w": "of", "b": [0.5091, 0.6586, 0.5258, 0.68]}, {"w": "green.", "b": [0.5332, 0.6586, 0.5845, 0.68]}, {"w": "Next,", "b": [0.5919, 0.6586, 0.6366, 0.68]}, {"w": "for", "b": [0.644, 0.6586, 0.6685, 0.68]}, {"w": "each", "b": [0.6758, 0.6586, 0.7138, 0.68]}, {"w": "color", "b": [0.7211, 0.6586, 0.7642, 0.68]}, {"w": "(e.g.,", "b": [0.7715, 0.6586, 0.8116, 0.68]}, {"w": "dark", "b": [0.8189, 0.6586, 0.8572, 0.68]}, {"w": "green),", "b": [0.1429, 0.6777, 0.2014, 0.6991]}, {"w": "it", "b": [0.2071, 0.6777, 0.219, 0.6991]}, {"w": "looks", "b": [0.2247, 0.6777, 0.2692, 0.6991]}, {"w": "for", "b": [0.2748, 0.6777, 0.2994, 0.6991]}, {"w": "the", "b": [0.305, 0.6777, 0.3314, 0.6991]}, {"w": "mean", "b": [0.337, 0.6777, 0.3835, 0.6991]}, {"w": "color", "b": [0.3891, 0.6777, 0.4322, 0.6991]}, {"w": "of", "b": [0.4379, 0.6777, 0.4547, 0.6991]}, {"w": "the", "b": [0.4603, 0.6777, 0.4867, 0.6991]}, {"w": "pixel’s", "b": [0.4923, 0.6777, 0.5426, 0.6991]}, {"w": "color", "b": [0.5482, 0.6777, 0.5913, 0.6991]}, {"w": "cluster.", "b": [0.5969, 0.6777, 0.6561, 0.6991]}, {"w": "For", "b": [0.6618, 0.6777, 0.6908, 0.6991]}, {"w": "example,", "b": [0.6964, 0.6777, 0.7707, 0.6991]}, {"w": "all", "b": [0.7764, 0.6777, 0.7961, 0.6991]}, {"w": "shades", "b": [0.8017, 0.6777, 0.8571, 0.6991]}, {"w": "of", "b": [0.1429, 0.6967, 0.1596, 0.7181]}, {"w": "green", "b": [0.1645, 0.6967, 0.2111, 0.7181]}, {"w": "may", "b": [0.2159, 0.6967, 0.2513, 0.7181]}, {"w": "be", "b": [0.2562, 0.6967, 0.2756, 0.7181]}, {"w": "replaced", "b": [0.2804, 0.6967, 0.351, 0.7181]}, {"w": "with", "b": [0.3559, 0.6967, 0.3932, 0.7181]}, {"w": "the", "b": [0.398, 0.6967, 0.4244, 0.7181]}, {"w": "same", "b": [0.4292, 0.6967, 0.4719, 0.7181]}, {"w": "light", "b": [0.4768, 0.6967, 0.5144, 0.7181]}, {"w": "green", "b": [0.5193, 0.6967, 0.5659, 0.7181]}, {"w": "color", "b": [0.5707, 0.6967, 0.6138, 0.7181]}, {"w": "(assuming", "b": [0.6186, 0.6967, 0.7051, 0.7181]}, {"w": "the", "b": [0.71, 0.6967, 0.7363, 0.7181]}, {"w": "mean", "b": [0.7411, 0.6967, 0.7876, 0.7181]}, {"w": "color", "b": [0.7924, 0.6967, 0.8355, 0.7181]}, {"w": "of", "b": [0.8403, 0.6967, 0.8571, 0.7181]}, {"w": "the", "b": [0.1429, 0.7157, 0.1692, 0.7372]}, {"w": "green", "b": [0.1759, 0.7157, 0.2225, 0.7372]}, {"w": "cluster", "b": [0.2292, 0.7157, 0.2849, 0.7372]}, {"w": "is", "b": [0.2916, 0.7157, 0.3048, 0.7372]}, {"w": "light", "b": [0.3115, 0.7157, 0.3492, 0.7372]}, {"w": "green).", "b": [0.3559, 0.7157, 0.4144, 0.7372]}, {"w": "Finally", "b": [0.4211, 0.7157, 0.4784, 0.7372]}, {"w": "it", "b": [0.4851, 0.7157, 0.497, 0.7372]}, {"w": "reshapes", "b": [0.5037, 0.7157, 0.5752, 0.7372]}, {"w": "this", "b": [0.5819, 0.7157, 0.6126, 0.7372]}, {"w": "long", "b": [0.6193, 0.7157, 0.6564, 0.7372]}, {"w": "list", "b": [0.6631, 0.7157, 0.6879, 0.7372]}, {"w": "of", "b": [0.6946, 0.7157, 0.7114, 0.7372]}, {"w": "colors", "b": [0.7181, 0.7157, 0.7688, 0.7372]}, {"w": "to", "b": [0.7755, 0.7157, 0.7925, 0.7372]}, {"w": "get", "b": [0.7992, 0.7157, 0.8241, 0.7372]}, {"w": "the", "b": [0.8308, 0.7157, 0.8572, 0.7372]}, {"w": "same", "b": [0.1429, 0.7348, 0.1856, 0.7562]}, {"w": "shape", "b": [0.1903, 0.7348, 0.2376, 0.7562]}, {"w": "as", "b": [0.2423, 0.7348, 0.2591, 0.7562]}, {"w": "the", "b": [0.2638, 0.7348, 0.2902, 0.7562]}, {"w": "original", "b": [0.2949, 0.7348, 0.36, 0.7562]}, {"w": "image.", "b": [0.3647, 0.7348, 0.4199, 0.7562]}, {"w": "And", "b": [0.4246, 0.7348, 0.4614, 0.7562]}, {"w": "we’re", "b": [0.4661, 0.7348, 0.5082, 0.7562]}, {"w": "done!", "b": [0.5129, 0.7348, 0.5605, 0.7562]}]}, {"id": "b_5", "type": "paragraph", "text": "X = image.reshape(-1, 3) kmeans = KMeans(n_clusters=8).fit(X) segmented_img = kmeans.cluster_centers_[kmeans.labels_] segmented_img = segmented_img.reshape(image.shape)", "words": [{"w": "X", "b": [0.1766, 0.7668, 0.185, 0.7796]}, {"w": "=", "b": [0.1935, 0.7668, 0.2019, 0.7796]}, {"w": "image.reshape(-1,", "b": [0.2103, 0.7668, 0.3537, 0.7796]}, {"w": "3)", "b": [0.3621, 0.7668, 0.379, 0.7796]}, {"w": "kmeans", "b": [0.1766, 0.7822, 0.2272, 0.795]}, {"w": "=", "b": [0.2356, 0.7822, 0.2441, 0.795]}, {"w": "KMeans(n_clusters=8).fit(X)", "b": [0.2525, 0.7822, 0.4802, 0.795]}, {"w": "segmented_img", "b": [0.1766, 0.7976, 0.2862, 0.8105]}, {"w": "=", "b": [0.2946, 0.7976, 0.3031, 0.8105]}, {"w": "kmeans.cluster_centers_[kmeans.labels_]", "b": [0.3115, 0.7976, 0.6404, 0.8105]}, {"w": "segmented_img", "b": [0.1766, 0.813, 0.2862, 0.8259]}, {"w": "=", "b": [0.2946, 0.813, 0.3031, 0.8259]}, {"w": "segmented_img.reshape(image.shape)", "b": [0.3115, 0.813, 0.5982, 0.8259]}]}, {"id": "b_6", "type": "paragraph", "text": "This outputs the image shown in the upper right of Figure 9-12. You can experiment with various numbers of clusters, as shown in the figure. When you use less than 8 clusters, notice that the ladybug’s flashy red color fails to get a cluster of its own: it", "words": [{"w": "This", "b": [0.1429, 0.8337, 0.1801, 0.8551]}, {"w": "outputs", "b": [0.1857, 0.8337, 0.2497, 0.8551]}, {"w": "the", "b": [0.2553, 0.8337, 0.2817, 0.8551]}, {"w": "image", "b": [0.2873, 0.8337, 0.3377, 0.8551]}, {"w": "shown", "b": [0.3433, 0.8337, 0.3983, 0.8551]}, {"w": "in", "b": [0.404, 0.8337, 0.4209, 0.8551]}, {"w": "the", "b": [0.4266, 0.8337, 0.4529, 0.8551]}, {"w": "upper", "b": [0.4585, 0.8337, 0.508, 0.8551]}, {"w": "right", "b": [0.5136, 0.8337, 0.5537, 0.8551]}, {"w": "of", "b": [0.5594, 0.8337, 0.5762, 0.8551]}, {"w": "Figure", "b": [0.5818, 0.8337, 0.6358, 0.8551]}, {"w": "9-12.", "b": [0.6414, 0.8337, 0.6836, 0.8551]}, {"w": "You", "b": [0.6892, 0.8337, 0.7215, 0.8551]}, {"w": "can", "b": [0.7271, 0.8337, 0.7565, 0.8551]}, {"w": "experiment", "b": [0.7621, 0.8337, 0.8572, 0.8551]}, {"w": "with", "b": [0.1429, 0.8527, 0.1802, 0.8741]}, {"w": "various", "b": [0.1868, 0.8527, 0.2483, 0.8741]}, {"w": "numbers", "b": [0.2549, 0.8527, 0.3289, 0.8741]}, {"w": "of", "b": [0.3355, 0.8527, 0.3523, 0.8741]}, {"w": "clusters,", "b": [0.359, 0.8527, 0.4271, 0.8741]}, {"w": "as", "b": [0.4337, 0.8527, 0.4505, 0.8741]}, {"w": "shown", "b": [0.4572, 0.8527, 0.5122, 0.8741]}, {"w": "in", "b": [0.5189, 0.8527, 0.5359, 0.8741]}, {"w": "the", "b": [0.5425, 0.8527, 0.5688, 0.8741]}, {"w": "figure.", "b": [0.5755, 0.8527, 0.6294, 0.8741]}, {"w": "When", "b": [0.636, 0.8527, 0.6876, 0.8741]}, {"w": "you", "b": [0.6943, 0.8527, 0.7255, 0.8741]}, {"w": "use", "b": [0.7322, 0.8527, 0.7598, 0.8741]}, {"w": "less", "b": [0.7664, 0.8527, 0.7958, 0.8741]}, {"w": "than", "b": [0.8025, 0.8527, 0.8405, 0.8741]}, {"w": "8", "b": [0.8471, 0.8527, 0.8571, 0.8741]}, {"w": "clusters,", "b": [0.1429, 0.8718, 0.211, 0.8932]}, {"w": "notice", "b": [0.2179, 0.8718, 0.2695, 0.8932]}, {"w": "that", "b": [0.2764, 0.8718, 0.309, 0.8932]}, {"w": "the", "b": [0.3159, 0.8718, 0.3422, 0.8932]}, {"w": "ladybug’s", "b": [0.3491, 0.8718, 0.4254, 0.8932]}, {"w": "flashy", "b": [0.4323, 0.8718, 0.4807, 0.8932]}, {"w": "red", "b": [0.4876, 0.8718, 0.5152, 0.8932]}, {"w": "color", "b": [0.5221, 0.8718, 0.5651, 0.8932]}, {"w": "fails", "b": [0.572, 0.8718, 0.6058, 0.8932]}, {"w": "to", "b": [0.6127, 0.8718, 0.6297, 0.8932]}, {"w": "get", "b": [0.6366, 0.8718, 0.6616, 0.8932]}, {"w": "a", "b": [0.6685, 0.8718, 0.6776, 0.8932]}, {"w": "cluster", "b": [0.6845, 0.8718, 0.7402, 0.8932]}, {"w": "of", "b": [0.7471, 0.8718, 0.7639, 0.8932]}, {"w": "its", "b": [0.7708, 0.8718, 0.7904, 0.8932]}, {"w": "own:", "b": [0.7973, 0.8718, 0.8383, 0.8932]}, {"w": "it", "b": [0.8452, 0.8718, 0.8571, 0.8932]}]}, {"id": "b_7", "type": "paragraph", "text": "Clustering | 251", "words": [{"w": "Clustering", "b": [0.736, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "251", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 278, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "gets merged with colors from the environment. This is due to the fact that the lady‐ bug is quite small, much smaller than the rest of the image, so even though its color is flashy, K-Means fails to dedicate a cluster to it: as mentioned earlier, K-Means prefers clusters of similar sizes.", "words": [{"w": "gets", "b": [0.1429, 0.0791, 0.1755, 0.1005]}, {"w": "merged", "b": [0.1817, 0.0791, 0.2449, 0.1005]}, {"w": "with", "b": [0.2511, 0.0791, 0.2885, 0.1005]}, {"w": "colors", "b": [0.2947, 0.0791, 0.3454, 0.1005]}, {"w": "from", "b": [0.3516, 0.0791, 0.3932, 0.1005]}, {"w": "the", "b": [0.3994, 0.0791, 0.4258, 0.1005]}, {"w": "environment.", "b": [0.432, 0.0791, 0.5447, 0.1005]}, {"w": "This", "b": [0.551, 0.0791, 0.5882, 0.1005]}, {"w": "is", "b": [0.5944, 0.0791, 0.6076, 0.1005]}, {"w": "due", "b": [0.6138, 0.0791, 0.6447, 0.1005]}, {"w": "to", "b": [0.651, 0.0791, 0.6679, 0.1005]}, {"w": "the", "b": [0.6742, 0.0791, 0.7005, 0.1005]}, {"w": "fact", "b": [0.7067, 0.0791, 0.7372, 0.1005]}, {"w": "that", "b": [0.7434, 0.0791, 0.776, 0.1005]}, {"w": "the", "b": [0.7822, 0.0791, 0.8085, 0.1005]}, {"w": "lady‐", "b": [0.8147, 0.0791, 0.8571, 0.1005]}, {"w": "bug", "b": [0.1429, 0.0981, 0.1742, 0.1195]}, {"w": "is", "b": [0.1791, 0.0981, 0.1924, 0.1195]}, {"w": "quite", "b": [0.1973, 0.0981, 0.2398, 0.1195]}, {"w": "small,", "b": [0.2447, 0.0981, 0.2938, 0.1195]}, {"w": "much", "b": [0.2987, 0.0981, 0.3464, 0.1195]}, {"w": "smaller", "b": [0.3513, 0.0981, 0.4122, 0.1195]}, {"w": "than", "b": [0.4171, 0.0981, 0.4552, 0.1195]}, {"w": "the", "b": [0.4601, 0.0981, 0.4864, 0.1195]}, {"w": "rest", "b": [0.4913, 0.0981, 0.5219, 0.1195]}, {"w": "of", "b": [0.5268, 0.0981, 0.5436, 0.1195]}, {"w": "the", "b": [0.5485, 0.0981, 0.5748, 0.1195]}, {"w": "image,", "b": [0.5797, 0.0981, 0.6348, 0.1195]}, {"w": "so", "b": [0.6397, 0.0981, 0.658, 0.1195]}, {"w": "even", "b": [0.6629, 0.0981, 0.7016, 0.1195]}, {"w": "though", "b": [0.7065, 0.0981, 0.7666, 0.1195]}, {"w": "its", "b": [0.7715, 0.0981, 0.7911, 0.1195]}, {"w": "color", "b": [0.7959, 0.0981, 0.839, 0.1195]}, {"w": "is", "b": [0.8439, 0.0981, 0.8571, 0.1195]}, {"w": "flashy,", "b": [0.1429, 0.1172, 0.1945, 0.1386]}, {"w": "K-Means", "b": [0.1998, 0.1172, 0.2763, 0.1386]}, {"w": "fails", "b": [0.2817, 0.1172, 0.3155, 0.1386]}, {"w": "to", "b": [0.3208, 0.1172, 0.3378, 0.1386]}, {"w": "dedicate", "b": [0.3431, 0.1172, 0.4123, 0.1386]}, {"w": "a", "b": [0.4176, 0.1172, 0.4267, 0.1386]}, {"w": "cluster", "b": [0.4321, 0.1172, 0.4878, 0.1386]}, {"w": "to", "b": [0.4931, 0.1172, 0.5101, 0.1386]}, {"w": "it:", "b": [0.5154, 0.1172, 0.5321, 0.1386]}, {"w": "as", "b": [0.5374, 0.1172, 0.5542, 0.1386]}, {"w": "mentioned", "b": [0.5595, 0.1172, 0.6502, 0.1386]}, {"w": "earlier,", "b": [0.6555, 0.1172, 0.7121, 0.1386]}, {"w": "K-Means", "b": [0.7174, 0.1172, 0.7939, 0.1386]}, {"w": "prefers", "b": [0.7993, 0.1172, 0.8572, 0.1386]}, {"w": "clusters", "b": [0.1429, 0.1362, 0.2062, 0.1576]}, {"w": "of", "b": [0.211, 0.1362, 0.2278, 0.1576]}, {"w": "similar", "b": [0.2325, 0.1362, 0.2905, 0.1576]}, {"w": "sizes.", "b": [0.2952, 0.1362, 0.3385, 0.1576]}]}, {"id": "b_1", "type": "paragraph", "text": "Figure 9-12. Image segmentation using K-Means with various numbers of color clusters", "words": [{"w": "Figure", "b": [0.1429, 0.3759, 0.1943, 0.3976]}, {"w": "9-12.", "b": [0.1991, 0.3759, 0.2407, 0.3976]}, {"w": "Image", "b": [0.2455, 0.3759, 0.2949, 0.3976]}, {"w": "segmentation", "b": [0.2997, 0.3759, 0.4074, 0.3976]}, {"w": "using", "b": [0.4122, 0.3759, 0.4551, 0.3976]}, {"w": "K-Means", "b": [0.4599, 0.3759, 0.5343, 0.3976]}, {"w": "with", "b": [0.539, 0.3759, 0.5755, 0.3976]}, {"w": "various", "b": [0.5803, 0.3759, 0.6406, 0.3976]}, {"w": "numbers", "b": [0.6454, 0.3759, 0.7159, 0.3976]}, {"w": "of", "b": [0.7207, 0.3759, 0.7359, 0.3976]}, {"w": "color", "b": [0.7407, 0.3759, 0.7804, 0.3976]}, {"w": "clusters", "b": [0.7851, 0.3759, 0.8448, 0.3976]}]}, {"id": "b_2", "type": "paragraph", "text": "That was not too hard, was it? Now let’s look at another application of clustering: pre‐ processing.", "words": [{"w": "That", "b": [0.1429, 0.4133, 0.1819, 0.4348]}, {"w": "was", "b": [0.1869, 0.4133, 0.218, 0.4348]}, {"w": "not", "b": [0.2229, 0.4133, 0.2513, 0.4348]}, {"w": "too", "b": [0.2563, 0.4133, 0.2839, 0.4348]}, {"w": "hard,", "b": [0.2888, 0.4133, 0.3326, 0.4348]}, {"w": "was", "b": [0.3375, 0.4133, 0.3686, 0.4348]}, {"w": "it?", "b": [0.3735, 0.4133, 0.3934, 0.4348]}, {"w": "Now", "b": [0.3983, 0.4133, 0.4382, 0.4348]}, {"w": "let’s", "b": [0.4431, 0.4133, 0.4734, 0.4348]}, {"w": "look", "b": [0.4783, 0.4133, 0.5152, 0.4348]}, {"w": "at", "b": [0.5201, 0.4133, 0.5353, 0.4348]}, {"w": "another", "b": [0.5402, 0.4133, 0.6054, 0.4348]}, {"w": "application", "b": [0.6104, 0.4133, 0.7034, 0.4348]}, {"w": "of", "b": [0.7083, 0.4133, 0.7251, 0.4348]}, {"w": "clustering:", "b": [0.7301, 0.4133, 0.8173, 0.4348]}, {"w": "pre‐", "b": [0.8222, 0.4133, 0.8571, 0.4348]}, {"w": "processing.", "b": [0.1429, 0.4324, 0.2366, 0.4538]}]}, {"id": "b_3", "type": "paragraph", "text": "Using Clustering for Preprocessing", "words": [{"w": "Using", "b": [0.1429, 0.4666, 0.2008, 0.4951]}, {"w": "Clustering", "b": [0.2058, 0.4666, 0.3105, 0.4951]}, {"w": "for", "b": [0.3155, 0.4666, 0.345, 0.4951]}, {"w": "Preprocessing", "b": [0.3499, 0.4666, 0.4936, 0.4951]}]}, {"id": "b_4", "type": "paragraph", "text": "Clustering can be an efficient approach to dimensionality reduction, in particular as a preprocessing step before a supervised learning algorithm. For example, let’s tackle the digits dataset which is a simple MNIST-like dataset containing 1,797 grayscale 8×8 images representing digits 0 to 9. First, let’s load the dataset:", "words": [{"w": "Clustering", "b": [0.1428, 0.501, 0.2303, 0.5224]}, {"w": "can", "b": [0.2353, 0.501, 0.2646, 0.5224]}, {"w": "be", "b": [0.2696, 0.501, 0.289, 0.5224]}, {"w": "an", "b": [0.2939, 0.501, 0.3145, 0.5224]}, {"w": "efficient", "b": [0.3194, 0.501, 0.3868, 0.5224]}, {"w": "approach", "b": [0.3917, 0.501, 0.4697, 0.5224]}, {"w": "to", "b": [0.4747, 0.501, 0.4916, 0.5224]}, {"w": "dimensionality", "b": [0.4966, 0.501, 0.6216, 0.5224]}, {"w": "reduction,", "b": [0.6266, 0.501, 0.7127, 0.5224]}, {"w": "in", "b": [0.7177, 0.501, 0.7346, 0.5224]}, {"w": "particular", "b": [0.7396, 0.501, 0.8213, 0.5224]}, {"w": "as", "b": [0.8263, 0.501, 0.8431, 0.5224]}, {"w": "a", "b": [0.848, 0.501, 0.8571, 0.5224]}, {"w": "preprocessing", "b": [0.1429, 0.5201, 0.2593, 0.5415]}, {"w": "step", "b": [0.2667, 0.5201, 0.3005, 0.5415]}, {"w": "before", "b": [0.3078, 0.5201, 0.3607, 0.5415]}, {"w": "a", "b": [0.368, 0.5201, 0.3772, 0.5415]}, {"w": "supervised", "b": [0.3846, 0.5201, 0.4741, 0.5415]}, {"w": "learning", "b": [0.4815, 0.5201, 0.5506, 0.5415]}, {"w": "algorithm.", "b": [0.558, 0.5201, 0.6454, 0.5415]}, {"w": "For", "b": [0.6527, 0.5201, 0.6817, 0.5415]}, {"w": "example,", "b": [0.6891, 0.5201, 0.7634, 0.5415]}, {"w": "let’s", "b": [0.7708, 0.5201, 0.801, 0.5415]}, {"w": "tackle", "b": [0.8084, 0.5201, 0.8571, 0.5415]}, {"w": "the", "b": [0.1429, 0.5391, 0.1692, 0.5605]}, {"w": "digits", "b": [0.174, 0.5389, 0.2175, 0.5605]}, {"w": "dataset", "b": [0.2222, 0.5389, 0.2805, 0.5605]}, {"w": "which", "b": [0.2854, 0.5391, 0.3363, 0.5605]}, {"w": "is", "b": [0.3411, 0.5391, 0.3543, 0.5605]}, {"w": "a", "b": [0.359, 0.5391, 0.3682, 0.5605]}, {"w": "simple", "b": [0.3729, 0.5391, 0.4278, 0.5605]}, {"w": "MNIST-like", "b": [0.4326, 0.5391, 0.5327, 0.5605]}, {"w": "dataset", "b": [0.5375, 0.5391, 0.5956, 0.5605]}, {"w": "containing", "b": [0.6003, 0.5391, 0.6899, 0.5605]}, {"w": "1,797", "b": [0.6947, 0.5391, 0.7394, 0.5605]}, {"w": "grayscale", "b": [0.7441, 0.5391, 0.8197, 0.5605]}, {"w": "8×8", "b": [0.8244, 0.5391, 0.8565, 0.5605]}, {"w": "images", "b": [0.1429, 0.5582, 0.2009, 0.5796]}, {"w": "representing", "b": [0.2056, 0.5582, 0.3103, 0.5796]}, {"w": "digits", "b": [0.315, 0.5582, 0.3609, 0.5796]}, {"w": "0", "b": [0.3657, 0.5582, 0.3757, 0.5796]}, {"w": "to", "b": [0.3804, 0.5582, 0.3974, 0.5796]}, {"w": "9.", "b": [0.4021, 0.5582, 0.4169, 0.5796]}, {"w": "First,", "b": [0.4216, 0.5582, 0.4647, 0.5796]}, {"w": "let’s", "b": [0.4694, 0.5582, 0.4996, 0.5796]}, {"w": "load", "b": [0.5044, 0.5582, 0.5404, 0.5796]}, {"w": "the", "b": [0.5451, 0.5582, 0.5715, 0.5796]}, {"w": "dataset:", "b": [0.5762, 0.5582, 0.639, 0.5796]}]}, {"id": "b_5", "type": "equation", "text": "from sklearn.datasets import load_digits", "words": [{"w": "from", "b": [0.1766, 0.5902, 0.2103, 0.603]}, {"w": "sklearn.datasets", "b": [0.2187, 0.5902, 0.3537, 0.603]}, {"w": "import", "b": [0.3621, 0.5902, 0.4127, 0.603]}, {"w": "load_digits", "b": [0.4211, 0.5902, 0.5139, 0.603]}]}, {"id": "b_6", "type": "equation", "text": "X_digits, y_digits = load_digits(return_X_y=True)", "words": [{"w": "X_digits,", "b": [0.1766, 0.621, 0.2525, 0.6338]}, {"w": "y_digits", "b": [0.2609, 0.621, 0.3284, 0.6338]}, {"w": "=", "b": [0.3368, 0.621, 0.3452, 0.6338]}, {"w": "load_digits(return_X_y=True)", "b": [0.3537, 0.621, 0.5898, 0.6338]}]}, {"id": "b_7", "type": "paragraph", "text": "Now, let’s split it into a training set and a test set:", "words": [{"w": "Now,", "b": [0.1429, 0.6416, 0.1859, 0.663]}, {"w": "let’s", "b": [0.1907, 0.6416, 0.2209, 0.663]}, {"w": "split", "b": [0.2256, 0.6416, 0.2614, 0.663]}, {"w": "it", "b": [0.2661, 0.6416, 0.2781, 0.663]}, {"w": "into", "b": [0.2828, 0.6416, 0.3164, 0.663]}, {"w": "a", "b": [0.3211, 0.6416, 0.3302, 0.663]}, {"w": "training", "b": [0.335, 0.6416, 0.4019, 0.663]}, {"w": "set", "b": [0.4066, 0.6416, 0.4295, 0.663]}, {"w": "and", "b": [0.4342, 0.6416, 0.4658, 0.663]}, {"w": "a", "b": [0.4705, 0.6416, 0.4796, 0.663]}, {"w": "test", "b": [0.4844, 0.6416, 0.5136, 0.663]}, {"w": "set:", "b": [0.5183, 0.6416, 0.5459, 0.663]}]}, {"id": "b_8", "type": "equation", "text": "from sklearn.model_selection import train_test_split", "words": [{"w": "from", "b": [0.1766, 0.6736, 0.2103, 0.6864]}, {"w": "sklearn.model_selection", "b": [0.2188, 0.6736, 0.4127, 0.6864]}, {"w": "import", "b": [0.4211, 0.6736, 0.4717, 0.6864]}, {"w": "train_test_split", "b": [0.4802, 0.6736, 0.6151, 0.6864]}]}, {"id": "b_9", "type": "equation", "text": "X_train, X_test, y_train, y_test = train_test_split(X_digits, y_digits)", "words": [{"w": "X_train,", "b": [0.1766, 0.7044, 0.2441, 0.7173]}, {"w": "X_test,", "b": [0.2525, 0.7044, 0.3115, 0.7173]}, {"w": "y_train,", "b": [0.3199, 0.7044, 0.3874, 0.7173]}, {"w": "y_test", "b": [0.3958, 0.7044, 0.4464, 0.7173]}, {"w": "=", "b": [0.4549, 0.7044, 0.4633, 0.7173]}, {"w": "train_test_split(X_digits,", "b": [0.4717, 0.7044, 0.691, 0.7173]}, {"w": "y_digits)", "b": [0.6994, 0.7044, 0.7753, 0.7173]}]}, {"id": "b_10", "type": "paragraph", "text": "Next, let’s fit a Logistic Regression model:", "words": [{"w": "Next,", "b": [0.1429, 0.7251, 0.1876, 0.7465]}, {"w": "let’s", "b": [0.1923, 0.7251, 0.2226, 0.7465]}, {"w": "fit", "b": [0.2273, 0.7251, 0.2454, 0.7465]}, {"w": "a", "b": [0.2501, 0.7251, 0.2593, 0.7465]}, {"w": "Logistic", "b": [0.264, 0.7251, 0.3296, 0.7465]}, {"w": "Regression", "b": [0.3343, 0.7251, 0.4253, 0.7465]}, {"w": "model:", "b": [0.4301, 0.7251, 0.4876, 0.7465]}]}, {"id": "b_11", "type": "equation", "text": "from sklearn.linear_model import LogisticRegression", "words": [{"w": "from", "b": [0.1766, 0.757, 0.2103, 0.7699]}, {"w": "sklearn.linear_model", "b": [0.2188, 0.757, 0.3874, 0.7699]}, {"w": "import", "b": [0.3958, 0.757, 0.4464, 0.7699]}, {"w": "LogisticRegression", "b": [0.4549, 0.757, 0.6067, 0.7699]}]}, {"id": "b_12", "type": "equation", "text": "log_reg = LogisticRegression(random_state=42) log_reg.fit(X_train, y_train)", "words": [{"w": "log_reg", "b": [0.1766, 0.7879, 0.2356, 0.8007]}, {"w": "=", "b": [0.2441, 0.7879, 0.2525, 0.8007]}, {"w": "LogisticRegression(random_state=42)", "b": [0.2609, 0.7879, 0.5561, 0.8007]}, {"w": "log_reg.fit(X_train,", "b": [0.1766, 0.8033, 0.3452, 0.8162]}, {"w": "y_train)", "b": [0.3537, 0.8033, 0.4211, 0.8162]}]}, {"id": "b_13", "type": "paragraph", "text": "Let’s evaluate its accuracy on the test set:", "words": [{"w": "Let’s", "b": [0.1429, 0.8239, 0.179, 0.8453]}, {"w": "evaluate", "b": [0.1838, 0.8239, 0.2517, 0.8453]}, {"w": "its", "b": [0.2564, 0.8239, 0.276, 0.8453]}, {"w": "accuracy", "b": [0.2807, 0.8239, 0.3538, 0.8453]}, {"w": "on", "b": [0.3586, 0.8239, 0.3806, 0.8453]}, {"w": "the", "b": [0.3853, 0.8239, 0.4116, 0.8453]}, {"w": "test", "b": [0.4164, 0.8239, 0.4456, 0.8453]}, {"w": "set:", "b": [0.4503, 0.8239, 0.4779, 0.8453]}]}, {"id": "b_14", "type": "equation", "text": ">>> log_reg.score(X_test, y_test) 0.9666666666666667", "words": [{"w": ">>>", "b": [0.1766, 0.8559, 0.2019, 0.8688]}, {"w": "log_reg.score(X_test,", "b": [0.2103, 0.8559, 0.3874, 0.8688]}, {"w": "y_test)", "b": [0.3958, 0.8559, 0.4549, 0.8688]}, {"w": "0.9666666666666667", "b": [0.1766, 0.8713, 0.3284, 0.8842]}]}, {"id": "b_15", "type": "paragraph", "text": "252 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "252", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 279, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Okay, that’s our baseline: 96.7% accuracy. Let’s see if we can do better by using K- Means as a preprocessing step. We will create a pipeline that will first cluster the training set into 50 clusters and replace the images with their distances to these 50 clusters, then apply a logistic regression model.", "words": [{"w": "Okay,", "b": [0.1429, 0.0791, 0.1903, 0.1005]}, {"w": "that’s", "b": [0.1979, 0.0791, 0.2402, 0.1005]}, {"w": "our", "b": [0.2477, 0.0791, 0.2771, 0.1005]}, {"w": "baseline:", "b": [0.2847, 0.0791, 0.3568, 0.1005]}, {"w": "96.7%", "b": [0.3643, 0.0791, 0.4148, 0.1005]}, {"w": "accuracy.", "b": [0.4223, 0.0791, 0.4986, 0.1005]}, {"w": "Let’s", "b": [0.5062, 0.0791, 0.5424, 0.1005]}, {"w": "see", "b": [0.5499, 0.0791, 0.5752, 0.1005]}, {"w": "if", "b": [0.5828, 0.0791, 0.5945, 0.1005]}, {"w": "we", "b": [0.6021, 0.0791, 0.6252, 0.1005]}, {"w": "can", "b": [0.6327, 0.0791, 0.6621, 0.1005]}, {"w": "do", "b": [0.6696, 0.0791, 0.6912, 0.1005]}, {"w": "better", "b": [0.6988, 0.0791, 0.7475, 0.1005]}, {"w": "by", "b": [0.755, 0.0791, 0.7752, 0.1005]}, {"w": "using", "b": [0.7827, 0.0791, 0.8282, 0.1005]}, {"w": "K-", "b": [0.8357, 0.0791, 0.8571, 0.1005]}, {"w": "Means", "b": [0.1429, 0.0981, 0.1979, 0.1195]}, {"w": "as", "b": [0.2063, 0.0981, 0.2231, 0.1195]}, {"w": "a", "b": [0.2314, 0.0981, 0.2406, 0.1195]}, {"w": "preprocessing", "b": [0.2489, 0.0981, 0.3654, 0.1195]}, {"w": "step.", "b": [0.3738, 0.0981, 0.4117, 0.1195]}, {"w": "We", "b": [0.42, 0.0981, 0.4471, 0.1195]}, {"w": "will", "b": [0.4555, 0.0981, 0.4859, 0.1195]}, {"w": "create", "b": [0.4942, 0.0981, 0.5436, 0.1195]}, {"w": "a", "b": [0.5519, 0.0981, 0.5611, 0.1195]}, {"w": "pipeline", "b": [0.5694, 0.0981, 0.6368, 0.1195]}, {"w": "that", "b": [0.6452, 0.0981, 0.6778, 0.1195]}, {"w": "will", "b": [0.6861, 0.0981, 0.7165, 0.1195]}, {"w": "first", "b": [0.7249, 0.0981, 0.7584, 0.1195]}, {"w": "cluster", "b": [0.7667, 0.0981, 0.8224, 0.1195]}, {"w": "the", "b": [0.8308, 0.0981, 0.8571, 0.1195]}, {"w": "training", "b": [0.1429, 0.1172, 0.2098, 0.1386]}, {"w": "set", "b": [0.2169, 0.1172, 0.2397, 0.1386]}, {"w": "into", "b": [0.2468, 0.1172, 0.2803, 0.1386]}, {"w": "50", "b": [0.2874, 0.1172, 0.3074, 0.1386]}, {"w": "clusters", "b": [0.3145, 0.1172, 0.3778, 0.1386]}, {"w": "and", "b": [0.3849, 0.1172, 0.4164, 0.1386]}, {"w": "replace", "b": [0.4235, 0.1172, 0.4831, 0.1386]}, {"w": "the", "b": [0.4901, 0.1172, 0.5165, 0.1386]}, {"w": "images", "b": [0.5235, 0.1172, 0.5816, 0.1386]}, {"w": "with", "b": [0.5886, 0.1172, 0.626, 0.1386]}, {"w": "their", "b": [0.633, 0.1172, 0.6727, 0.1386]}, {"w": "distances", "b": [0.6797, 0.1172, 0.7562, 0.1386]}, {"w": "to", "b": [0.7632, 0.1172, 0.7802, 0.1386]}, {"w": "these", "b": [0.7873, 0.1172, 0.8301, 0.1386]}, {"w": "50", "b": [0.8372, 0.1172, 0.8572, 0.1386]}, {"w": "clusters,", "b": [0.1429, 0.1362, 0.211, 0.1576]}, {"w": "then", "b": [0.2157, 0.1362, 0.2534, 0.1576]}, {"w": "apply", "b": [0.2582, 0.1362, 0.3036, 0.1576]}, {"w": "a", "b": [0.3083, 0.1362, 0.3175, 0.1576]}, {"w": "logistic", "b": [0.3222, 0.1362, 0.3818, 0.1576]}, {"w": "regression", "b": [0.3865, 0.1362, 0.4724, 0.1576]}, {"w": "model.", "b": [0.4771, 0.1362, 0.5347, 0.1576]}]}, {"id": "b_1", "type": "paragraph", "text": "Although it is tempting to define the number of clusters to 10, since there are 10 different digits, it is unlikely to perform well, because there are several different ways to write each digit.", "words": [{"w": "Although", "b": [0.2714, 0.1781, 0.3443, 0.1977]}, {"w": "it", "b": [0.3525, 0.1781, 0.3634, 0.1977]}, {"w": "is", "b": [0.3716, 0.1781, 0.3837, 0.1977]}, {"w": "tempting", "b": [0.3918, 0.1781, 0.4612, 0.1977]}, {"w": "to", "b": [0.4694, 0.1781, 0.4849, 0.1977]}, {"w": "define", "b": [0.4931, 0.1781, 0.5405, 0.1977]}, {"w": "the", "b": [0.5487, 0.1781, 0.5728, 0.1977]}, {"w": "number", "b": [0.5809, 0.1781, 0.6416, 0.1977]}, {"w": "of", "b": [0.6497, 0.1781, 0.6651, 0.1977]}, {"w": "clusters", "b": [0.6733, 0.1781, 0.7312, 0.1977]}, {"w": "to", "b": [0.7394, 0.1781, 0.7549, 0.1977]}, {"w": "10,", "b": [0.7631, 0.1781, 0.7857, 0.1977]}, {"w": "since", "b": [0.2714, 0.1956, 0.3101, 0.2151]}, {"w": "there", "b": [0.3177, 0.1956, 0.357, 0.2151]}, {"w": "are", "b": [0.3647, 0.1956, 0.3882, 0.2151]}, {"w": "10", "b": [0.3958, 0.1956, 0.4141, 0.2151]}, {"w": "different", "b": [0.4218, 0.1956, 0.4874, 0.2151]}, {"w": "digits,", "b": [0.495, 0.1956, 0.5413, 0.2151]}, {"w": "it", "b": [0.549, 0.1956, 0.5599, 0.2151]}, {"w": "is", "b": [0.5676, 0.1956, 0.5797, 0.2151]}, {"w": "unlikely", "b": [0.5874, 0.1956, 0.6489, 0.2151]}, {"w": "to", "b": [0.6566, 0.1956, 0.6721, 0.2151]}, {"w": "perform", "b": [0.6798, 0.1956, 0.7429, 0.2151]}, {"w": "well,", "b": [0.7506, 0.1956, 0.7857, 0.2151]}, {"w": "because", "b": [0.2714, 0.213, 0.3304, 0.2326]}, {"w": "there", "b": [0.3348, 0.213, 0.374, 0.2326]}, {"w": "are", "b": [0.3783, 0.213, 0.4019, 0.2326]}, {"w": "several", "b": [0.4062, 0.213, 0.4584, 0.2326]}, {"w": "different", "b": [0.4627, 0.213, 0.5283, 0.2326]}, {"w": "ways", "b": [0.5326, 0.213, 0.5694, 0.2326]}, {"w": "to", "b": [0.5738, 0.213, 0.5893, 0.2326]}, {"w": "write", "b": [0.5936, 0.213, 0.6327, 0.2326]}, {"w": "each", "b": [0.6371, 0.213, 0.6717, 0.2326]}, {"w": "digit.", "b": [0.6761, 0.213, 0.7154, 0.2326]}]}, {"id": "b_2", "type": "paragraph", "text": "from sklearn.pipeline import Pipeline", "words": [{"w": "from", "b": [0.1766, 0.2807, 0.2103, 0.2935]}, {"w": "sklearn.pipeline", "b": [0.2188, 0.2807, 0.3537, 0.2935]}, {"w": "import", "b": [0.3621, 0.2807, 0.4127, 0.2935]}, {"w": "Pipeline", "b": [0.4211, 0.2807, 0.4886, 0.2935]}]}, {"id": "b_3", "type": "paragraph", "text": "pipeline = Pipeline([ (\"kmeans\", KMeans(n_clusters=50)), (\"log_reg\", LogisticRegression()), ]) pipeline.fit(X_train, y_train)", "words": [{"w": "pipeline", "b": [0.1766, 0.3115, 0.2441, 0.3243]}, {"w": "=", "b": [0.2525, 0.3115, 0.2609, 0.3243]}, {"w": "Pipeline([", "b": [0.2693, 0.3115, 0.3537, 0.3243]}, {"w": "(\"kmeans\",", "b": [0.2103, 0.3269, 0.2946, 0.3398]}, {"w": "KMeans(n_clusters=50)),", "b": [0.3031, 0.3269, 0.497, 0.3398]}, {"w": "(\"log_reg\",", "b": [0.2103, 0.3423, 0.3031, 0.3552]}, {"w": "LogisticRegression()),", "b": [0.3115, 0.3423, 0.497, 0.3552]}, {"w": "])", "b": [0.1766, 0.3577, 0.1935, 0.3706]}, {"w": "pipeline.fit(X_train,", "b": [0.1766, 0.3732, 0.3537, 0.386]}, {"w": "y_train)", "b": [0.3621, 0.3732, 0.4296, 0.386]}]}, {"id": "b_4", "type": "paragraph", "text": "Now let’s evaluate this classification pipeline:", "words": [{"w": "Now", "b": [0.1429, 0.3938, 0.1827, 0.4152]}, {"w": "let’s", "b": [0.1874, 0.3938, 0.2177, 0.4152]}, {"w": "evaluate", "b": [0.2224, 0.3938, 0.2903, 0.4152]}, {"w": "this", "b": [0.2951, 0.3938, 0.3258, 0.4152]}, {"w": "classification", "b": [0.3305, 0.3938, 0.4379, 0.4152]}, {"w": "pipeline:", "b": [0.4426, 0.3938, 0.5147, 0.4152]}]}, {"id": "b_5", "type": "equation", "text": ">>> pipeline.score(X_test, y_test) 0.9822222222222222", "words": [{"w": ">>>", "b": [0.1766, 0.4258, 0.2019, 0.4386]}, {"w": "pipeline.score(X_test,", "b": [0.2103, 0.4258, 0.3958, 0.4386]}, {"w": "y_test)", "b": [0.4043, 0.4258, 0.4633, 0.4386]}, {"w": "0.9822222222222222", "b": [0.1766, 0.4412, 0.3284, 0.454]}]}, {"id": "b_6", "type": "paragraph", "text": "How about that? We almost divided the error rate by a factor of 2!", "words": [{"w": "How", "b": [0.1429, 0.4618, 0.1832, 0.4832]}, {"w": "about", "b": [0.1879, 0.4618, 0.2357, 0.4832]}, {"w": "that?", "b": [0.2404, 0.4618, 0.2809, 0.4832]}, {"w": "We", "b": [0.2856, 0.4618, 0.3127, 0.4832]}, {"w": "almost", "b": [0.3174, 0.4618, 0.3735, 0.4832]}, {"w": "divided", "b": [0.3782, 0.4618, 0.4409, 0.4832]}, {"w": "the", "b": [0.4456, 0.4618, 0.472, 0.4832]}, {"w": "error", "b": [0.4767, 0.4618, 0.5194, 0.4832]}, {"w": "rate", "b": [0.5241, 0.4618, 0.5558, 0.4832]}, {"w": "by", "b": [0.5605, 0.4618, 0.5807, 0.4832]}, {"w": "a", "b": [0.5854, 0.4618, 0.5945, 0.4832]}, {"w": "factor", "b": [0.5993, 0.4618, 0.6481, 0.4832]}, {"w": "of", "b": [0.6528, 0.4618, 0.6696, 0.4832]}, {"w": "2!", "b": [0.6744, 0.4618, 0.6901, 0.4832]}]}, {"id": "b_7", "type": "paragraph", "text": "But we chose the number of clusters k completely arbitrarily, we can surely do better. Since K-Means is just a preprocessing step in a classification pipeline, finding a good value for k is much simpler than earlier: there’s no need to perform silhouette analysis or minimize the inertia, the best value of k is simply the one that results in the best classification performance during cross-validation. Let’s use GridSearchCV to find the optimal number of clusters:", "words": [{"w": "But", "b": [0.1429, 0.4899, 0.1725, 0.5114]}, {"w": "we", "b": [0.178, 0.4899, 0.2011, 0.5114]}, {"w": "chose", "b": [0.2066, 0.4899, 0.2537, 0.5114]}, {"w": "the", "b": [0.2591, 0.4899, 0.2855, 0.5114]}, {"w": "number", "b": [0.2909, 0.4899, 0.3572, 0.5114]}, {"w": "of", "b": [0.3627, 0.4899, 0.3795, 0.5114]}, {"w": "clusters", "b": [0.385, 0.4899, 0.4483, 0.5114]}, {"w": "k", "b": [0.4538, 0.4897, 0.4636, 0.5114]}, {"w": "completely", "b": [0.4691, 0.4899, 0.5603, 0.5114]}, {"w": "arbitrarily,", "b": [0.5657, 0.4899, 0.6534, 0.5114]}, {"w": "we", "b": [0.6589, 0.4899, 0.682, 0.5114]}, {"w": "can", "b": [0.6875, 0.4899, 0.7168, 0.5114]}, {"w": "surely", "b": [0.7223, 0.4899, 0.7724, 0.5114]}, {"w": "do", "b": [0.7779, 0.4899, 0.7995, 0.5114]}, {"w": "better.", "b": [0.805, 0.4899, 0.8571, 0.5114]}, {"w": "Since", "b": [0.1428, 0.509, 0.1874, 0.5304]}, {"w": "K-Means", "b": [0.193, 0.509, 0.2695, 0.5304]}, {"w": "is", "b": [0.275, 0.509, 0.2883, 0.5304]}, {"w": "just", "b": [0.2939, 0.509, 0.3243, 0.5304]}, {"w": "a", "b": [0.3298, 0.509, 0.339, 0.5304]}, {"w": "preprocessing", "b": [0.3446, 0.509, 0.461, 0.5304]}, {"w": "step", "b": [0.4666, 0.509, 0.5004, 0.5304]}, {"w": "in", "b": [0.506, 0.509, 0.523, 0.5304]}, {"w": "a", "b": [0.5285, 0.509, 0.5377, 0.5304]}, {"w": "classification", "b": [0.5433, 0.509, 0.6506, 0.5304]}, {"w": "pipeline,", "b": [0.6562, 0.509, 0.7284, 0.5304]}, {"w": "finding", "b": [0.7339, 0.509, 0.7948, 0.5304]}, {"w": "a", "b": [0.8004, 0.509, 0.8095, 0.5304]}, {"w": "good", "b": [0.8151, 0.509, 0.8571, 0.5304]}, {"w": "value", "b": [0.1429, 0.528, 0.1868, 0.5495]}, {"w": "for", "b": [0.1916, 0.528, 0.2161, 0.5495]}, {"w": "k", "b": [0.2212, 0.5278, 0.231, 0.5495]}, {"w": "is", "b": [0.2359, 0.528, 0.2491, 0.5495]}, {"w": "much", "b": [0.254, 0.528, 0.3017, 0.5495]}, {"w": "simpler", "b": [0.3066, 0.528, 0.3692, 0.5495]}, {"w": "than", "b": [0.3741, 0.528, 0.4122, 0.5495]}, {"w": "earlier:", "b": [0.4171, 0.528, 0.4755, 0.5495]}, {"w": "there’s", "b": [0.4804, 0.528, 0.5324, 0.5495]}, {"w": "no", "b": [0.5373, 0.528, 0.5593, 0.5495]}, {"w": "need", "b": [0.5642, 0.528, 0.6043, 0.5495]}, {"w": "to", "b": [0.6092, 0.528, 0.6262, 0.5495]}, {"w": "perform", "b": [0.6311, 0.528, 0.7002, 0.5495]}, {"w": "silhouette", "b": [0.7051, 0.528, 0.7868, 0.5495]}, {"w": "analysis", "b": [0.7917, 0.528, 0.8571, 0.5495]}, {"w": "or", "b": [0.1429, 0.5471, 0.1612, 0.5685]}, {"w": "minimize", "b": [0.1677, 0.5471, 0.2476, 0.5685]}, {"w": "the", "b": [0.254, 0.5471, 0.2804, 0.5685]}, {"w": "inertia,", "b": [0.2868, 0.5471, 0.3462, 0.5685]}, {"w": "the", "b": [0.3527, 0.5471, 0.379, 0.5685]}, {"w": "best", "b": [0.3855, 0.5471, 0.4189, 0.5685]}, {"w": "value", "b": [0.4254, 0.5471, 0.4694, 0.5685]}, {"w": "of", "b": [0.4759, 0.5471, 0.4927, 0.5685]}, {"w": "k", "b": [0.4991, 0.5469, 0.5089, 0.5685]}, {"w": "is", "b": [0.5154, 0.5471, 0.5286, 0.5685]}, {"w": "simply", "b": [0.5351, 0.5471, 0.5907, 0.5685]}, {"w": "the", "b": [0.5972, 0.5471, 0.6235, 0.5685]}, {"w": "one", "b": [0.63, 0.5471, 0.6609, 0.5685]}, {"w": "that", "b": [0.6674, 0.5471, 0.6999, 0.5685]}, {"w": "results", "b": [0.7064, 0.5471, 0.761, 0.5685]}, {"w": "in", "b": [0.7674, 0.5471, 0.7844, 0.5685]}, {"w": "the", "b": [0.7909, 0.5471, 0.8172, 0.5685]}, {"w": "best", "b": [0.8237, 0.5471, 0.8571, 0.5685]}, {"w": "classification", "b": [0.1429, 0.567, 0.2502, 0.5884]}, {"w": "performance", "b": [0.2553, 0.567, 0.3626, 0.5884]}, {"w": "during", "b": [0.3676, 0.567, 0.4241, 0.5884]}, {"w": "cross-validation.", "b": [0.4291, 0.567, 0.5671, 0.5884]}, {"w": "Let’s", "b": [0.5721, 0.567, 0.6083, 0.5884]}, {"w": "use", "b": [0.6133, 0.567, 0.6409, 0.5884]}, {"w": "GridSearchCV", "b": [0.6459, 0.5702, 0.7646, 0.5853]}, {"w": "to", "b": [0.7696, 0.567, 0.7866, 0.5884]}, {"w": "find", "b": [0.7913, 0.567, 0.8255, 0.5884]}, {"w": "the", "b": [0.8302, 0.567, 0.8566, 0.5884]}, {"w": "optimal", "b": [0.1429, 0.5861, 0.2078, 0.6075]}, {"w": "number", "b": [0.2126, 0.5861, 0.2788, 0.6075]}, {"w": "of", "b": [0.2836, 0.5861, 0.3004, 0.6075]}, {"w": "clusters:", "b": [0.3051, 0.5861, 0.3732, 0.6075]}]}, {"id": "b_8", "type": "equation", "text": "from sklearn.model_selection import GridSearchCV", "words": [{"w": "from", "b": [0.1766, 0.6181, 0.2103, 0.6309]}, {"w": "sklearn.model_selection", "b": [0.2188, 0.6181, 0.4127, 0.6309]}, {"w": "import", "b": [0.4211, 0.6181, 0.4717, 0.6309]}, {"w": "GridSearchCV", "b": [0.4802, 0.6181, 0.5814, 0.6309]}]}, {"id": "b_9", "type": "paragraph", "text": "param_grid = dict(kmeans__n_clusters=range(2, 100)) grid_clf = GridSearchCV(pipeline, param_grid, cv=3, verbose=2) grid_clf.fit(X_train, y_train)", "words": [{"w": "param_grid", "b": [0.1766, 0.6489, 0.2609, 0.6617]}, {"w": "=", "b": [0.2693, 0.6489, 0.2778, 0.6617]}, {"w": "dict(kmeans__n_clusters=range(2,", "b": [0.2862, 0.6489, 0.5561, 0.6617]}, {"w": "100))", "b": [0.5645, 0.6489, 0.6067, 0.6617]}, {"w": "grid_clf", "b": [0.1766, 0.6643, 0.2441, 0.6772]}, {"w": "=", "b": [0.2525, 0.6643, 0.2609, 0.6772]}, {"w": "GridSearchCV(pipeline,", "b": [0.2693, 0.6643, 0.4549, 0.6772]}, {"w": "param_grid,", "b": [0.4633, 0.6643, 0.5561, 0.6772]}, {"w": "cv=3,", "b": [0.5645, 0.6643, 0.6067, 0.6772]}, {"w": "verbose=2)", "b": [0.6151, 0.6643, 0.6994, 0.6772]}, {"w": "grid_clf.fit(X_train,", "b": [0.1766, 0.6797, 0.3537, 0.6926]}, {"w": "y_train)", "b": [0.3621, 0.6797, 0.4296, 0.6926]}]}, {"id": "b_10", "type": "paragraph", "text": "Let’s look at best value for k, and the performance of the resulting pipeline:", "words": [{"w": "Let’s", "b": [0.1429, 0.7004, 0.179, 0.7218]}, {"w": "look", "b": [0.1838, 0.7004, 0.2206, 0.7218]}, {"w": "at", "b": [0.2253, 0.7004, 0.2404, 0.7218]}, {"w": "best", "b": [0.2452, 0.7004, 0.2786, 0.7218]}, {"w": "value", "b": [0.2833, 0.7004, 0.3273, 0.7218]}, {"w": "for", "b": [0.332, 0.7004, 0.3566, 0.7218]}, {"w": "k,", "b": [0.3613, 0.7002, 0.3758, 0.7218]}, {"w": "and", "b": [0.3806, 0.7004, 0.4121, 0.7218]}, {"w": "the", "b": [0.4168, 0.7004, 0.4432, 0.7218]}, {"w": "performance", "b": [0.4479, 0.7004, 0.5552, 0.7218]}, {"w": "of", "b": [0.5599, 0.7004, 0.5767, 0.7218]}, {"w": "the", "b": [0.5814, 0.7004, 0.6078, 0.7218]}, {"w": "resulting", "b": [0.6125, 0.7004, 0.6862, 0.7218]}, {"w": "pipeline:", "b": [0.6909, 0.7004, 0.763, 0.7218]}]}, {"id": "b_11", "type": "paragraph", "text": ">>> grid_clf.best_params_ {'kmeans__n_clusters': 90} >>> grid_clf.score(X_test, y_test) 0.9844444444444445", "words": [{"w": ">>>", "b": [0.1766, 0.7323, 0.2019, 0.7452]}, {"w": "grid_clf.best_params_", "b": [0.2103, 0.7323, 0.3874, 0.7452]}, {"w": "{'kmeans__n_clusters':", "b": [0.1766, 0.7478, 0.3621, 0.7606]}, {"w": "90}", "b": [0.3705, 0.7478, 0.3958, 0.7606]}, {"w": ">>>", "b": [0.1766, 0.7632, 0.2019, 0.776]}, {"w": "grid_clf.score(X_test,", "b": [0.2103, 0.7632, 0.3958, 0.776]}, {"w": "y_test)", "b": [0.4043, 0.7632, 0.4633, 0.776]}, {"w": "0.9844444444444445", "b": [0.1766, 0.7786, 0.3284, 0.7914]}]}, {"id": "b_12", "type": "paragraph", "text": "With k=90 clusters, we get a small accuracy boost, reaching 98.4% accuracy on the test set. Cool!", "words": [{"w": "With", "b": [0.1429, 0.7992, 0.1853, 0.8206]}, {"w": "k=90", "b": [0.1924, 0.799, 0.2343, 0.8206]}, {"w": "clusters,", "b": [0.2414, 0.7992, 0.3095, 0.8206]}, {"w": "we", "b": [0.3166, 0.7992, 0.3397, 0.8206]}, {"w": "get", "b": [0.3468, 0.7992, 0.3718, 0.8206]}, {"w": "a", "b": [0.3788, 0.7992, 0.388, 0.8206]}, {"w": "small", "b": [0.3951, 0.7992, 0.4395, 0.8206]}, {"w": "accuracy", "b": [0.4466, 0.7992, 0.5197, 0.8206]}, {"w": "boost,", "b": [0.5268, 0.7992, 0.5773, 0.8206]}, {"w": "reaching", "b": [0.5844, 0.7992, 0.6568, 0.8206]}, {"w": "98.4%", "b": [0.6639, 0.7992, 0.7144, 0.8206]}, {"w": "accuracy", "b": [0.7215, 0.7992, 0.7946, 0.8206]}, {"w": "on", "b": [0.8017, 0.7992, 0.8237, 0.8206]}, {"w": "the", "b": [0.8308, 0.7992, 0.8571, 0.8206]}, {"w": "test", "b": [0.1429, 0.8183, 0.1721, 0.8397]}, {"w": "set.", "b": [0.1768, 0.8183, 0.2044, 0.8397]}, {"w": "Cool!", "b": [0.2091, 0.8183, 0.2553, 0.8397]}]}, {"id": "b_13", "type": "paragraph", "text": "Clustering | 253", "words": [{"w": "Clustering", "b": [0.736, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "253", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 280, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Using Clustering for Semi-Supervised Learning", "words": [{"w": "Using", "b": [0.1429, 0.0763, 0.2008, 0.1049]}, {"w": "Clustering", "b": [0.2058, 0.0763, 0.3105, 0.1049]}, {"w": "for", "b": [0.3155, 0.0763, 0.345, 0.1049]}, {"w": "Semi-Supervised", "b": [0.3499, 0.0763, 0.5222, 0.1049]}, {"w": "Learning", "b": [0.5271, 0.0763, 0.6186, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "Another use case for clustering is in semi-supervised learning, when we have plenty of unlabeled instances and very few labeled instances. Let’s train a logistic regression model on a sample of 50 labeled instances from the digits dataset:", "words": [{"w": "Another", "b": [0.1429, 0.1108, 0.2133, 0.1322]}, {"w": "use", "b": [0.2196, 0.1108, 0.2472, 0.1322]}, {"w": "case", "b": [0.2535, 0.1108, 0.2879, 0.1322]}, {"w": "for", "b": [0.2942, 0.1108, 0.3188, 0.1322]}, {"w": "clustering", "b": [0.3251, 0.1108, 0.4075, 0.1322]}, {"w": "is", "b": [0.4138, 0.1108, 0.427, 0.1322]}, {"w": "in", "b": [0.4333, 0.1108, 0.4503, 0.1322]}, {"w": "semi-supervised", "b": [0.4566, 0.1108, 0.5927, 0.1322]}, {"w": "learning,", "b": [0.599, 0.1108, 0.6729, 0.1322]}, {"w": "when", "b": [0.6792, 0.1108, 0.7248, 0.1322]}, {"w": "we", "b": [0.7311, 0.1108, 0.7542, 0.1322]}, {"w": "have", "b": [0.7605, 0.1108, 0.7989, 0.1322]}, {"w": "plenty", "b": [0.8052, 0.1108, 0.8572, 0.1322]}, {"w": "of", "b": [0.1429, 0.1298, 0.1597, 0.1512]}, {"w": "unlabeled", "b": [0.1655, 0.1298, 0.247, 0.1512]}, {"w": "instances", "b": [0.2528, 0.1298, 0.3297, 0.1512]}, {"w": "and", "b": [0.3355, 0.1298, 0.3671, 0.1512]}, {"w": "very", "b": [0.373, 0.1298, 0.4094, 0.1512]}, {"w": "few", "b": [0.4152, 0.1298, 0.4445, 0.1512]}, {"w": "labeled", "b": [0.4504, 0.1298, 0.5094, 0.1512]}, {"w": "instances.", "b": [0.5152, 0.1298, 0.5968, 0.1512]}, {"w": "Let’s", "b": [0.6027, 0.1298, 0.6389, 0.1512]}, {"w": "train", "b": [0.6447, 0.1298, 0.6849, 0.1512]}, {"w": "a", "b": [0.6908, 0.1298, 0.7, 0.1512]}, {"w": "logistic", "b": [0.7058, 0.1298, 0.7655, 0.1512]}, {"w": "regression", "b": [0.7713, 0.1298, 0.8571, 0.1512]}, {"w": "model", "b": [0.1429, 0.1489, 0.1957, 0.1703]}, {"w": "on", "b": [0.2004, 0.1489, 0.2224, 0.1703]}, {"w": "a", "b": [0.2271, 0.1489, 0.2363, 0.1703]}, {"w": "sample", "b": [0.241, 0.1489, 0.2995, 0.1703]}, {"w": "of", "b": [0.3043, 0.1489, 0.321, 0.1703]}, {"w": "50", "b": [0.3258, 0.1489, 0.3458, 0.1703]}, {"w": "labeled", "b": [0.3505, 0.1489, 0.4095, 0.1703]}, {"w": "instances", "b": [0.4142, 0.1489, 0.491, 0.1703]}, {"w": "from", "b": [0.4958, 0.1489, 0.5374, 0.1703]}, {"w": "the", "b": [0.5421, 0.1489, 0.5684, 0.1703]}, {"w": "digits", "b": [0.5731, 0.1489, 0.6191, 0.1703]}, {"w": "dataset:", "b": [0.6238, 0.1489, 0.6866, 0.1703]}]}, {"id": "b_2", "type": "paragraph", "text": "n_labeled = 50 log_reg = LogisticRegression() log_reg.fit(X_train[:n_labeled], y_train[:n_labeled])", "words": [{"w": "n_labeled", "b": [0.1766, 0.1808, 0.2525, 0.1937]}, {"w": "=", "b": [0.2609, 0.1808, 0.2693, 0.1937]}, {"w": "50", "b": [0.2778, 0.1808, 0.2946, 0.1937]}, {"w": "log_reg", "b": [0.1766, 0.1963, 0.2356, 0.2091]}, {"w": "=", "b": [0.244, 0.1963, 0.2525, 0.2091]}, {"w": "LogisticRegression()", "b": [0.2609, 0.1963, 0.4296, 0.2091]}, {"w": "log_reg.fit(X_train[:n_labeled],", "b": [0.1766, 0.2117, 0.4464, 0.2245]}, {"w": "y_train[:n_labeled])", "b": [0.4549, 0.2117, 0.6235, 0.2245]}]}, {"id": "b_3", "type": "paragraph", "text": "What is the performance of this model on the test set?", "words": [{"w": "What", "b": [0.1429, 0.2323, 0.1893, 0.2537]}, {"w": "is", "b": [0.194, 0.2323, 0.2073, 0.2537]}, {"w": "the", "b": [0.212, 0.2323, 0.2383, 0.2537]}, {"w": "performance", "b": [0.2431, 0.2323, 0.3504, 0.2537]}, {"w": "of", "b": [0.3551, 0.2323, 0.3719, 0.2537]}, {"w": "this", "b": [0.3766, 0.2323, 0.4073, 0.2537]}, {"w": "model", "b": [0.412, 0.2323, 0.4649, 0.2537]}, {"w": "on", "b": [0.4696, 0.2323, 0.4916, 0.2537]}, {"w": "the", "b": [0.4963, 0.2323, 0.5227, 0.2537]}, {"w": "test", "b": [0.5274, 0.2323, 0.5566, 0.2537]}, {"w": "set?", "b": [0.5613, 0.2323, 0.5921, 0.2537]}]}, {"id": "b_4", "type": "equation", "text": ">>> log_reg.score(X_test, y_test) 0.8266666666666667", "words": [{"w": ">>>", "b": [0.1766, 0.2643, 0.2019, 0.2771]}, {"w": "log_reg.score(X_test,", "b": [0.2103, 0.2643, 0.3874, 0.2771]}, {"w": "y_test)", "b": [0.3958, 0.2643, 0.4549, 0.2771]}, {"w": "0.8266666666666667", "b": [0.1766, 0.2797, 0.3284, 0.2926]}]}, {"id": "b_5", "type": "paragraph", "text": "The accuracy is just 82.7%: it should come as no surprise that this is much lower than earlier, when we trained the model on the full training set. Let’s see how we can do better. First, let’s cluster the training set into 50 clusters, then for each cluster let’s find the image closest to the centroid. We will call these images the representative images:", "words": [{"w": "The", "b": [0.1428, 0.3003, 0.1757, 0.3218]}, {"w": "accuracy", "b": [0.1807, 0.3003, 0.2538, 0.3218]}, {"w": "is", "b": [0.2588, 0.3003, 0.2721, 0.3218]}, {"w": "just", "b": [0.2771, 0.3003, 0.3075, 0.3218]}, {"w": "82.7%:", "b": [0.3125, 0.3003, 0.3678, 0.3218]}, {"w": "it", "b": [0.3728, 0.3003, 0.3847, 0.3218]}, {"w": "should", "b": [0.3898, 0.3003, 0.4465, 0.3218]}, {"w": "come", "b": [0.4515, 0.3003, 0.4969, 0.3218]}, {"w": "as", "b": [0.5019, 0.3003, 0.5187, 0.3218]}, {"w": "no", "b": [0.5238, 0.3003, 0.5458, 0.3218]}, {"w": "surprise", "b": [0.5508, 0.3003, 0.618, 0.3218]}, {"w": "that", "b": [0.623, 0.3003, 0.6556, 0.3218]}, {"w": "this", "b": [0.6606, 0.3003, 0.6913, 0.3218]}, {"w": "is", "b": [0.6964, 0.3003, 0.7096, 0.3218]}, {"w": "much", "b": [0.7146, 0.3003, 0.7623, 0.3218]}, {"w": "lower", "b": [0.7673, 0.3003, 0.8141, 0.3218]}, {"w": "than", "b": [0.8191, 0.3003, 0.8571, 0.3218]}, {"w": "earlier,", "b": [0.1429, 0.3194, 0.1995, 0.3408]}, {"w": "when", "b": [0.2062, 0.3194, 0.2518, 0.3408]}, {"w": "we", "b": [0.2585, 0.3194, 0.2817, 0.3408]}, {"w": "trained", "b": [0.2884, 0.3194, 0.3484, 0.3408]}, {"w": "the", "b": [0.3551, 0.3194, 0.3815, 0.3408]}, {"w": "model", "b": [0.3882, 0.3194, 0.441, 0.3408]}, {"w": "on", "b": [0.4477, 0.3194, 0.4697, 0.3408]}, {"w": "the", "b": [0.4765, 0.3194, 0.5028, 0.3408]}, {"w": "full", "b": [0.5095, 0.3194, 0.5373, 0.3408]}, {"w": "training", "b": [0.544, 0.3194, 0.6109, 0.3408]}, {"w": "set.", "b": [0.6176, 0.3194, 0.6452, 0.3408]}, {"w": "Let’s", "b": [0.6519, 0.3194, 0.6881, 0.3408]}, {"w": "see", "b": [0.6948, 0.3194, 0.7202, 0.3408]}, {"w": "how", "b": [0.7269, 0.3194, 0.7629, 0.3408]}, {"w": "we", "b": [0.7696, 0.3194, 0.7927, 0.3408]}, {"w": "can", "b": [0.7995, 0.3194, 0.8288, 0.3408]}, {"w": "do", "b": [0.8355, 0.3194, 0.8571, 0.3408]}, {"w": "better.", "b": [0.1429, 0.3384, 0.195, 0.3599]}, {"w": "First,", "b": [0.2, 0.3384, 0.2431, 0.3599]}, {"w": "let’s", "b": [0.2481, 0.3384, 0.2783, 0.3599]}, {"w": "cluster", "b": [0.2833, 0.3384, 0.3391, 0.3599]}, {"w": "the", "b": [0.3441, 0.3384, 0.3704, 0.3599]}, {"w": "training", "b": [0.3754, 0.3384, 0.4423, 0.3599]}, {"w": "set", "b": [0.4473, 0.3384, 0.4702, 0.3599]}, {"w": "into", "b": [0.4752, 0.3384, 0.5087, 0.3599]}, {"w": "50", "b": [0.5137, 0.3384, 0.5337, 0.3599]}, {"w": "clusters,", "b": [0.5387, 0.3384, 0.6069, 0.3599]}, {"w": "then", "b": [0.6119, 0.3384, 0.6496, 0.3599]}, {"w": "for", "b": [0.6546, 0.3384, 0.6791, 0.3599]}, {"w": "each", "b": [0.6841, 0.3384, 0.722, 0.3599]}, {"w": "cluster", "b": [0.727, 0.3384, 0.7828, 0.3599]}, {"w": "let’s", "b": [0.7878, 0.3384, 0.818, 0.3599]}, {"w": "find", "b": [0.823, 0.3384, 0.8571, 0.3599]}, {"w": "the", "b": [0.1429, 0.3575, 0.1692, 0.3789]}, {"w": "image", "b": [0.1739, 0.3575, 0.2243, 0.3789]}, {"w": "closest", "b": [0.229, 0.3575, 0.2842, 0.3789]}, {"w": "to", "b": [0.289, 0.3575, 0.306, 0.3789]}, {"w": "the", "b": [0.3107, 0.3575, 0.337, 0.3789]}, {"w": "centroid.", "b": [0.3417, 0.3575, 0.4165, 0.3789]}, {"w": "We", "b": [0.4212, 0.3575, 0.4482, 0.3789]}, {"w": "will", "b": [0.453, 0.3575, 0.4834, 0.3789]}, {"w": "call", "b": [0.4881, 0.3575, 0.5166, 0.3789]}, {"w": "these", "b": [0.5213, 0.3575, 0.5642, 0.3789]}, {"w": "images", "b": [0.5689, 0.3575, 0.6269, 0.3789]}, {"w": "the", "b": [0.6317, 0.3575, 0.658, 0.3789]}, {"w": "representative", "b": [0.6627, 0.3575, 0.7799, 0.3789]}, {"w": "images:", "b": [0.7846, 0.3575, 0.8474, 0.3789]}]}, {"id": "b_6", "type": "paragraph", "text": "k = 50 kmeans = KMeans(n_clusters=k) X_digits_dist = kmeans.fit_transform(X_train) representative_digit_idx = np.argmin(X_digits_dist, axis=0) X_representative_digits = X_train[representative_digit_idx]", "words": [{"w": "k", "b": [0.1766, 0.3895, 0.185, 0.4023]}, {"w": "=", "b": [0.1934, 0.3895, 0.2019, 0.4023]}, {"w": "50", "b": [0.2103, 0.3895, 0.2272, 0.4023]}, {"w": "kmeans", "b": [0.1766, 0.4049, 0.2272, 0.4177]}, {"w": "=", "b": [0.2356, 0.4049, 0.244, 0.4177]}, {"w": "KMeans(n_clusters=k)", "b": [0.2525, 0.4049, 0.4211, 0.4177]}, {"w": "X_digits_dist", "b": [0.1766, 0.4203, 0.2862, 0.4332]}, {"w": "=", "b": [0.2946, 0.4203, 0.3031, 0.4332]}, {"w": "kmeans.fit_transform(X_train)", "b": [0.3115, 0.4203, 0.556, 0.4332]}, {"w": "representative_digit_idx", "b": [0.1766, 0.4357, 0.379, 0.4486]}, {"w": "=", "b": [0.3874, 0.4357, 0.3958, 0.4486]}, {"w": "np.argmin(X_digits_dist,", "b": [0.4043, 0.4357, 0.6066, 0.4486]}, {"w": "axis=0)", "b": [0.6151, 0.4357, 0.6741, 0.4486]}, {"w": "X_representative_digits", "b": [0.1766, 0.4511, 0.3705, 0.464]}, {"w": "=", "b": [0.379, 0.4511, 0.3874, 0.464]}, {"w": "X_train[representative_digit_idx]", "b": [0.3958, 0.4511, 0.6741, 0.464]}]}, {"id": "b_7", "type": "equation", "text": "Figure 9-13 shows these 50 representative images:", "words": [{"w": "Figure", "b": [0.1429, 0.4718, 0.1969, 0.4932]}, {"w": "9-13", "b": [0.2016, 0.4718, 0.239, 0.4932]}, {"w": "shows", "b": [0.2437, 0.4718, 0.295, 0.4932]}, {"w": "these", "b": [0.2998, 0.4718, 0.3426, 0.4932]}, {"w": "50", "b": [0.3473, 0.4718, 0.3673, 0.4932]}, {"w": "representative", "b": [0.3721, 0.4718, 0.4892, 0.4932]}, {"w": "images:", "b": [0.4939, 0.4718, 0.5567, 0.4932]}]}, {"id": "b_8", "type": "equation", "text": "Figure 9-13. Fifty representative digit images (one per cluster)", "words": [{"w": "Figure", "b": [0.1428, 0.6193, 0.1943, 0.6409]}, {"w": "9-13.", "b": [0.1991, 0.6193, 0.2407, 0.6409]}, {"w": "Fifty", "b": [0.2455, 0.6193, 0.2832, 0.6409]}, {"w": "representative", "b": [0.288, 0.6193, 0.3999, 0.6409]}, {"w": "digit", "b": [0.4046, 0.6193, 0.4411, 0.6409]}, {"w": "images", "b": [0.4459, 0.6193, 0.5013, 0.6409]}, {"w": "(one", "b": [0.5061, 0.6193, 0.542, 0.6409]}, {"w": "per", "b": [0.5468, 0.6193, 0.5728, 0.6409]}, {"w": "cluster)", "b": [0.5776, 0.6193, 0.6373, 0.6409]}]}, {"id": "b_9", "type": "paragraph", "text": "Now let’s look at each image and manually label it:", "words": [{"w": "Now", "b": [0.1428, 0.6567, 0.1827, 0.6781]}, {"w": "let’s", "b": [0.1874, 0.6567, 0.2177, 0.6781]}, {"w": "look", "b": [0.2224, 0.6567, 0.2592, 0.6781]}, {"w": "at", "b": [0.264, 0.6567, 0.2791, 0.6781]}, {"w": "each", "b": [0.2838, 0.6567, 0.3217, 0.6781]}, {"w": "image", "b": [0.3265, 0.6567, 0.3769, 0.6781]}, {"w": "and", "b": [0.3816, 0.6567, 0.4131, 0.6781]}, {"w": "manually", "b": [0.4179, 0.6567, 0.4954, 0.6781]}, {"w": "label", "b": [0.5001, 0.6567, 0.5392, 0.6781]}, {"w": "it:", "b": [0.544, 0.6567, 0.5607, 0.6781]}]}, {"id": "b_10", "type": "equation", "text": "y_representative_digits = np.array([4, 8, 0, 6, 8, 3, ..., 7, 6, 2, 3, 1, 1])", "words": [{"w": "y_representative_digits", "b": [0.1766, 0.6886, 0.3705, 0.7015]}, {"w": "=", "b": [0.379, 0.6886, 0.3874, 0.7015]}, {"w": "np.array([4,", "b": [0.3958, 0.6886, 0.497, 0.7015]}, {"w": "8,", "b": [0.5055, 0.6886, 0.5223, 0.7015]}, {"w": "0,", "b": [0.5308, 0.6886, 0.5476, 0.7015]}, {"w": "6,", "b": [0.5561, 0.6886, 0.5729, 0.7015]}, {"w": "8,", "b": [0.5814, 0.6886, 0.5982, 0.7015]}, {"w": "3,", "b": [0.6067, 0.6886, 0.6235, 0.7015]}, {"w": "...,", "b": [0.632, 0.6886, 0.6657, 0.7015]}, {"w": "7,", "b": [0.6741, 0.6886, 0.691, 0.7015]}, {"w": "6,", "b": [0.6994, 0.6886, 0.7163, 0.7015]}, {"w": "2,", "b": [0.7247, 0.6886, 0.7416, 0.7015]}, {"w": "3,", "b": [0.75, 0.6886, 0.7669, 0.7015]}, {"w": "1,", "b": [0.7753, 0.6886, 0.7922, 0.7015]}, {"w": "1])", "b": [0.8006, 0.6886, 0.8259, 0.7015]}]}, {"id": "b_11", "type": "paragraph", "text": "Now we have a dataset with just 50 labeled instances, but instead of being completely random instances, each of them is a representative image of its cluster. Let’s see if the performance is any better:", "words": [{"w": "Now", "b": [0.1429, 0.7093, 0.1827, 0.7307]}, {"w": "we", "b": [0.1881, 0.7093, 0.2112, 0.7307]}, {"w": "have", "b": [0.2166, 0.7093, 0.255, 0.7307]}, {"w": "a", "b": [0.2604, 0.7093, 0.2695, 0.7307]}, {"w": "dataset", "b": [0.2749, 0.7093, 0.333, 0.7307]}, {"w": "with", "b": [0.3384, 0.7093, 0.3757, 0.7307]}, {"w": "just", "b": [0.3811, 0.7093, 0.4115, 0.7307]}, {"w": "50", "b": [0.4168, 0.7093, 0.4368, 0.7307]}, {"w": "labeled", "b": [0.4422, 0.7093, 0.5012, 0.7307]}, {"w": "instances,", "b": [0.5066, 0.7093, 0.5881, 0.7307]}, {"w": "but", "b": [0.5935, 0.7093, 0.6215, 0.7307]}, {"w": "instead", "b": [0.6269, 0.7093, 0.6869, 0.7307]}, {"w": "of", "b": [0.6922, 0.7093, 0.709, 0.7307]}, {"w": "being", "b": [0.7144, 0.7093, 0.7606, 0.7307]}, {"w": "completely", "b": [0.766, 0.7093, 0.8571, 0.7307]}, {"w": "random", "b": [0.1429, 0.7283, 0.2098, 0.7497]}, {"w": "instances,", "b": [0.2153, 0.7283, 0.2969, 0.7497]}, {"w": "each", "b": [0.3024, 0.7283, 0.3403, 0.7497]}, {"w": "of", "b": [0.3458, 0.7283, 0.3626, 0.7497]}, {"w": "them", "b": [0.3681, 0.7283, 0.4115, 0.7497]}, {"w": "is", "b": [0.417, 0.7283, 0.4303, 0.7497]}, {"w": "a", "b": [0.4358, 0.7283, 0.4449, 0.7497]}, {"w": "representative", "b": [0.4504, 0.7283, 0.5676, 0.7497]}, {"w": "image", "b": [0.5731, 0.7283, 0.6235, 0.7497]}, {"w": "of", "b": [0.629, 0.7283, 0.6458, 0.7497]}, {"w": "its", "b": [0.6513, 0.7283, 0.6708, 0.7497]}, {"w": "cluster.", "b": [0.6763, 0.7283, 0.7355, 0.7497]}, {"w": "Let’s", "b": [0.741, 0.7283, 0.7772, 0.7497]}, {"w": "see", "b": [0.7827, 0.7283, 0.808, 0.7497]}, {"w": "if", "b": [0.8135, 0.7283, 0.8253, 0.7497]}, {"w": "the", "b": [0.8308, 0.7283, 0.8571, 0.7497]}, {"w": "performance", "b": [0.1429, 0.7474, 0.2502, 0.7688]}, {"w": "is", "b": [0.2549, 0.7474, 0.2681, 0.7688]}, {"w": "any", "b": [0.2728, 0.7474, 0.3025, 0.7688]}, {"w": "better:", "b": [0.3072, 0.7474, 0.3612, 0.7688]}]}, {"id": "b_12", "type": "paragraph", "text": ">>> log_reg = LogisticRegression() >>> log_reg.fit(X_representative_digits, y_representative_digits) >>> log_reg.score(X_test, y_test) 0.9244444444444444", "words": [{"w": ">>>", "b": [0.1766, 0.7793, 0.2019, 0.7922]}, {"w": "log_reg", "b": [0.2103, 0.7793, 0.2693, 0.7922]}, {"w": "=", "b": [0.2778, 0.7793, 0.2862, 0.7922]}, {"w": "LogisticRegression()", "b": [0.2946, 0.7793, 0.4633, 0.7922]}, {"w": ">>>", "b": [0.1766, 0.7948, 0.2019, 0.8076]}, {"w": "log_reg.fit(X_representative_digits,", "b": [0.2103, 0.7948, 0.5139, 0.8076]}, {"w": "y_representative_digits)", "b": [0.5223, 0.7948, 0.7247, 0.8076]}, {"w": ">>>", "b": [0.1766, 0.8102, 0.2019, 0.823]}, {"w": "log_reg.score(X_test,", "b": [0.2103, 0.8102, 0.3874, 0.823]}, {"w": "y_test)", "b": [0.3958, 0.8102, 0.4549, 0.823]}, {"w": "0.9244444444444444", "b": [0.1766, 0.8256, 0.3284, 0.8385]}]}, {"id": "b_13", "type": "paragraph", "text": "Wow! We jumped from 82.7% accuracy to 92.4%, although we are still only training the model on 50 instances. Since it is often costly and painful to label instances, espe‐", "words": [{"w": "Wow!", "b": [0.1429, 0.8462, 0.1917, 0.8677]}, {"w": "We", "b": [0.1979, 0.8462, 0.2249, 0.8677]}, {"w": "jumped", "b": [0.2311, 0.8462, 0.2949, 0.8677]}, {"w": "from", "b": [0.301, 0.8462, 0.3426, 0.8677]}, {"w": "82.7%", "b": [0.3488, 0.8462, 0.3993, 0.8677]}, {"w": "accuracy", "b": [0.4054, 0.8462, 0.4785, 0.8677]}, {"w": "to", "b": [0.4847, 0.8462, 0.5016, 0.8677]}, {"w": "92.4%,", "b": [0.5078, 0.8462, 0.563, 0.8677]}, {"w": "although", "b": [0.5692, 0.8462, 0.6436, 0.8677]}, {"w": "we", "b": [0.6498, 0.8462, 0.6729, 0.8677]}, {"w": "are", "b": [0.6791, 0.8462, 0.7048, 0.8677]}, {"w": "still", "b": [0.7109, 0.8462, 0.7411, 0.8677]}, {"w": "only", "b": [0.7472, 0.8462, 0.7841, 0.8677]}, {"w": "training", "b": [0.7902, 0.8462, 0.8571, 0.8677]}, {"w": "the", "b": [0.1428, 0.8653, 0.1692, 0.8867]}, {"w": "model", "b": [0.1744, 0.8653, 0.2272, 0.8867]}, {"w": "on", "b": [0.2324, 0.8653, 0.2544, 0.8867]}, {"w": "50", "b": [0.2596, 0.8653, 0.2796, 0.8867]}, {"w": "instances.", "b": [0.2847, 0.8653, 0.3663, 0.8867]}, {"w": "Since", "b": [0.3715, 0.8653, 0.416, 0.8867]}, {"w": "it", "b": [0.4212, 0.8653, 0.4331, 0.8867]}, {"w": "is", "b": [0.4383, 0.8653, 0.4516, 0.8867]}, {"w": "often", "b": [0.4567, 0.8653, 0.5001, 0.8867]}, {"w": "costly", "b": [0.5053, 0.8653, 0.5536, 0.8867]}, {"w": "and", "b": [0.5588, 0.8653, 0.5903, 0.8867]}, {"w": "painful", "b": [0.5955, 0.8653, 0.655, 0.8867]}, {"w": "to", "b": [0.6602, 0.8653, 0.6772, 0.8867]}, {"w": "label", "b": [0.6824, 0.8653, 0.7215, 0.8867]}, {"w": "instances,", "b": [0.7267, 0.8653, 0.8083, 0.8867]}, {"w": "espe‐", "b": [0.8134, 0.8653, 0.8571, 0.8867]}]}, {"id": "b_14", "type": "paragraph", "text": "254 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "254", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4708, 0.9388]}]}]}, {"page": 281, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "cially when it has to be done manually by experts, it is a good idea to label representa‐ tive instances rather than just random instances.", "words": [{"w": "cially", "b": [0.1429, 0.0791, 0.1865, 0.1005]}, {"w": "when", "b": [0.1914, 0.0791, 0.237, 0.1005]}, {"w": "it", "b": [0.2419, 0.0791, 0.2538, 0.1005]}, {"w": "has", "b": [0.2587, 0.0791, 0.2866, 0.1005]}, {"w": "to", "b": [0.2915, 0.0791, 0.3085, 0.1005]}, {"w": "be", "b": [0.3133, 0.0791, 0.3328, 0.1005]}, {"w": "done", "b": [0.3376, 0.0791, 0.3795, 0.1005]}, {"w": "manually", "b": [0.3844, 0.0791, 0.4619, 0.1005]}, {"w": "by", "b": [0.4668, 0.0791, 0.4869, 0.1005]}, {"w": "experts,", "b": [0.4918, 0.0791, 0.5567, 0.1005]}, {"w": "it", "b": [0.5616, 0.0791, 0.5735, 0.1005]}, {"w": "is", "b": [0.5784, 0.0791, 0.5916, 0.1005]}, {"w": "a", "b": [0.5965, 0.0791, 0.6056, 0.1005]}, {"w": "good", "b": [0.6105, 0.0791, 0.6525, 0.1005]}, {"w": "idea", "b": [0.6574, 0.0791, 0.6919, 0.1005]}, {"w": "to", "b": [0.6968, 0.0791, 0.7138, 0.1005]}, {"w": "label", "b": [0.7187, 0.0791, 0.7578, 0.1005]}, {"w": "representa‐", "b": [0.7626, 0.0791, 0.8571, 0.1005]}, {"w": "tive", "b": [0.1429, 0.0981, 0.1733, 0.1195]}, {"w": "instances", "b": [0.178, 0.0981, 0.2549, 0.1195]}, {"w": "rather", "b": [0.2596, 0.0981, 0.3101, 0.1195]}, {"w": "than", "b": [0.3149, 0.0981, 0.3529, 0.1195]}, {"w": "just", "b": [0.3576, 0.0981, 0.388, 0.1195]}, {"w": "random", "b": [0.3927, 0.0981, 0.4597, 0.1195]}, {"w": "instances.", "b": [0.4644, 0.0981, 0.546, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "But perhaps we can go one step further: what if we propagated the labels to all the other instances in the same cluster? This is called label propagation:", "words": [{"w": "But", "b": [0.1429, 0.1262, 0.1725, 0.1476]}, {"w": "perhaps", "b": [0.1795, 0.1262, 0.2454, 0.1476]}, {"w": "we", "b": [0.2524, 0.1262, 0.2755, 0.1476]}, {"w": "can", "b": [0.2825, 0.1262, 0.3118, 0.1476]}, {"w": "go", "b": [0.3188, 0.1262, 0.3392, 0.1476]}, {"w": "one", "b": [0.3461, 0.1262, 0.377, 0.1476]}, {"w": "step", "b": [0.384, 0.1262, 0.4177, 0.1476]}, {"w": "further:", "b": [0.4247, 0.1262, 0.489, 0.1476]}, {"w": "what", "b": [0.4959, 0.1262, 0.5364, 0.1476]}, {"w": "if", "b": [0.5434, 0.1262, 0.5551, 0.1476]}, {"w": "we", "b": [0.5621, 0.1262, 0.5852, 0.1476]}, {"w": "propagated", "b": [0.5922, 0.1262, 0.6862, 0.1476]}, {"w": "the", "b": [0.6932, 0.1262, 0.7195, 0.1476]}, {"w": "labels", "b": [0.7265, 0.1262, 0.7733, 0.1476]}, {"w": "to", "b": [0.7802, 0.1262, 0.7972, 0.1476]}, {"w": "all", "b": [0.8042, 0.1262, 0.8238, 0.1476]}, {"w": "the", "b": [0.8308, 0.1262, 0.8571, 0.1476]}, {"w": "other", "b": [0.1429, 0.1453, 0.1876, 0.1667]}, {"w": "instances", "b": [0.1923, 0.1453, 0.2691, 0.1667]}, {"w": "in", "b": [0.2738, 0.1453, 0.2908, 0.1667]}, {"w": "the", "b": [0.2956, 0.1453, 0.3219, 0.1667]}, {"w": "same", "b": [0.3266, 0.1453, 0.3693, 0.1667]}, {"w": "cluster?", "b": [0.3741, 0.1453, 0.4377, 0.1667]}, {"w": "This", "b": [0.4424, 0.1453, 0.4796, 0.1667]}, {"w": "is", "b": [0.4843, 0.1453, 0.4976, 0.1667]}, {"w": "called", "b": [0.5023, 0.1453, 0.5507, 0.1667]}, {"w": "label", "b": [0.5554, 0.1451, 0.5935, 0.1667]}, {"w": "propagation:", "b": [0.5982, 0.1451, 0.7006, 0.1667]}]}, {"id": "b_2", "type": "paragraph", "text": "y_train_propagated = np.empty(len(X_train), dtype=np.int32) for i in range(k): y_train_propagated[kmeans.labels_==i] = y_representative_digits[i]", "words": [{"w": "y_train_propagated", "b": [0.1766, 0.1772, 0.3284, 0.1901]}, {"w": "=", "b": [0.3368, 0.1772, 0.3452, 0.1901]}, {"w": "np.empty(len(X_train),", "b": [0.3537, 0.1772, 0.5392, 0.1901]}, {"w": "dtype=np.int32)", "b": [0.5476, 0.1772, 0.6741, 0.1901]}, {"w": "for", "b": [0.1766, 0.1927, 0.2019, 0.2055]}, {"w": "i", "b": [0.2103, 0.1927, 0.2188, 0.2055]}, {"w": "in", "b": [0.2272, 0.1927, 0.2441, 0.2055]}, {"w": "range(k):", "b": [0.2525, 0.1927, 0.3284, 0.2055]}, {"w": "y_train_propagated[kmeans.labels_==i]", "b": [0.2103, 0.2081, 0.5223, 0.2209]}, {"w": "=", "b": [0.5308, 0.2081, 0.5392, 0.2209]}, {"w": "y_representative_digits[i]", "b": [0.5476, 0.2081, 0.7669, 0.2209]}]}, {"id": "b_3", "type": "paragraph", "text": "Now let’s train the model again and look at its performance:", "words": [{"w": "Now", "b": [0.1429, 0.2287, 0.1827, 0.2501]}, {"w": "let’s", "b": [0.1875, 0.2287, 0.2177, 0.2501]}, {"w": "train", "b": [0.2224, 0.2287, 0.2626, 0.2501]}, {"w": "the", "b": [0.2673, 0.2287, 0.2937, 0.2501]}, {"w": "model", "b": [0.2984, 0.2287, 0.3512, 0.2501]}, {"w": "again", "b": [0.356, 0.2287, 0.401, 0.2501]}, {"w": "and", "b": [0.4057, 0.2287, 0.4372, 0.2501]}, {"w": "look", "b": [0.442, 0.2287, 0.4788, 0.2501]}, {"w": "at", "b": [0.4836, 0.2287, 0.4987, 0.2501]}, {"w": "its", "b": [0.5034, 0.2287, 0.523, 0.2501]}, {"w": "performance:", "b": [0.5277, 0.2287, 0.6397, 0.2501]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> log_reg = LogisticRegression() >>> log_reg.fit(X_train, y_train_propagated) >>> log_reg.score(X_test, y_test) 0.9288888888888889", "words": [{"w": ">>>", "b": [0.1766, 0.2607, 0.2019, 0.2735]}, {"w": "log_reg", "b": [0.2103, 0.2607, 0.2694, 0.2735]}, {"w": "=", "b": [0.2778, 0.2607, 0.2862, 0.2735]}, {"w": "LogisticRegression()", "b": [0.2946, 0.2607, 0.4633, 0.2735]}, {"w": ">>>", "b": [0.1766, 0.2761, 0.2019, 0.289]}, {"w": "log_reg.fit(X_train,", "b": [0.2103, 0.2761, 0.379, 0.289]}, {"w": "y_train_propagated)", "b": [0.3874, 0.2761, 0.5476, 0.289]}, {"w": ">>>", "b": [0.1766, 0.2915, 0.2019, 0.3044]}, {"w": "log_reg.score(X_test,", "b": [0.2103, 0.2915, 0.3874, 0.3044]}, {"w": "y_test)", "b": [0.3958, 0.2915, 0.4549, 0.3044]}, {"w": "0.9288888888888889", "b": [0.1766, 0.307, 0.3284, 0.3198]}]}, {"id": "b_5", "type": "paragraph", "text": "We got a tiny little accuracy boost. Better than nothing, but not astounding. The problem is that we propagated each representative instance’s label to all the instances in the same cluster, including the instances located close to the cluster boundaries, which are more likely to be mislabeled. Let’s see what happens if we only propagate the labels to the 20% of the instances that are closest to the centroids:", "words": [{"w": "We", "b": [0.1429, 0.3276, 0.1699, 0.349]}, {"w": "got", "b": [0.1784, 0.3276, 0.2051, 0.349]}, {"w": "a", "b": [0.2136, 0.3276, 0.2227, 0.349]}, {"w": "tiny", "b": [0.2311, 0.3276, 0.2636, 0.349]}, {"w": "little", "b": [0.272, 0.3276, 0.3097, 0.349]}, {"w": "accuracy", "b": [0.3182, 0.3276, 0.3912, 0.349]}, {"w": "boost.", "b": [0.3997, 0.3276, 0.4503, 0.349]}, {"w": "Better", "b": [0.4587, 0.3276, 0.5095, 0.349]}, {"w": "than", "b": [0.518, 0.3276, 0.556, 0.349]}, {"w": "nothing,", "b": [0.5644, 0.3276, 0.6354, 0.349]}, {"w": "but", "b": [0.6439, 0.3276, 0.6719, 0.349]}, {"w": "not", "b": [0.6803, 0.3276, 0.7087, 0.349]}, {"w": "astounding.", "b": [0.7172, 0.3276, 0.8159, 0.349]}, {"w": "The", "b": [0.8243, 0.3276, 0.8571, 0.349]}, {"w": "problem", "b": [0.1429, 0.3466, 0.2139, 0.368]}, {"w": "is", "b": [0.2196, 0.3466, 0.2328, 0.368]}, {"w": "that", "b": [0.2384, 0.3466, 0.271, 0.368]}, {"w": "we", "b": [0.2767, 0.3466, 0.2998, 0.368]}, {"w": "propagated", "b": [0.3055, 0.3466, 0.3995, 0.368]}, {"w": "each", "b": [0.4052, 0.3466, 0.4431, 0.368]}, {"w": "representative", "b": [0.4488, 0.3466, 0.5659, 0.368]}, {"w": "instance’s", "b": [0.5716, 0.3466, 0.6499, 0.368]}, {"w": "label", "b": [0.6555, 0.3466, 0.6947, 0.368]}, {"w": "to", "b": [0.7003, 0.3466, 0.7173, 0.368]}, {"w": "all", "b": [0.723, 0.3466, 0.7426, 0.368]}, {"w": "the", "b": [0.7483, 0.3466, 0.7746, 0.368]}, {"w": "instances", "b": [0.7803, 0.3466, 0.8571, 0.368]}, {"w": "in", "b": [0.1429, 0.3657, 0.1598, 0.3871]}, {"w": "the", "b": [0.1672, 0.3657, 0.1935, 0.3871]}, {"w": "same", "b": [0.2008, 0.3657, 0.2435, 0.3871]}, {"w": "cluster,", "b": [0.2508, 0.3657, 0.31, 0.3871]}, {"w": "including", "b": [0.3173, 0.3657, 0.3972, 0.3871]}, {"w": "the", "b": [0.4045, 0.3657, 0.4308, 0.3871]}, {"w": "instances", "b": [0.4381, 0.3657, 0.515, 0.3871]}, {"w": "located", "b": [0.5223, 0.3657, 0.582, 0.3871]}, {"w": "close", "b": [0.5893, 0.3657, 0.6305, 0.3871]}, {"w": "to", "b": [0.6378, 0.3657, 0.6548, 0.3871]}, {"w": "the", "b": [0.6621, 0.3657, 0.6884, 0.3871]}, {"w": "cluster", "b": [0.6957, 0.3657, 0.7515, 0.3871]}, {"w": "boundaries,", "b": [0.7588, 0.3657, 0.8572, 0.3871]}, {"w": "which", "b": [0.1429, 0.3847, 0.1938, 0.4061]}, {"w": "are", "b": [0.2003, 0.3847, 0.2261, 0.4061]}, {"w": "more", "b": [0.2326, 0.3847, 0.2769, 0.4061]}, {"w": "likely", "b": [0.2834, 0.3847, 0.3283, 0.4061]}, {"w": "to", "b": [0.3348, 0.3847, 0.3518, 0.4061]}, {"w": "be", "b": [0.3584, 0.3847, 0.3778, 0.4061]}, {"w": "mislabeled.", "b": [0.3844, 0.3847, 0.4784, 0.4061]}, {"w": "Let’s", "b": [0.4849, 0.3847, 0.5211, 0.4061]}, {"w": "see", "b": [0.5276, 0.3847, 0.553, 0.4061]}, {"w": "what", "b": [0.5595, 0.3847, 0.6, 0.4061]}, {"w": "happens", "b": [0.6066, 0.3847, 0.6762, 0.4061]}, {"w": "if", "b": [0.6827, 0.3847, 0.6945, 0.4061]}, {"w": "we", "b": [0.701, 0.3847, 0.7242, 0.4061]}, {"w": "only", "b": [0.7307, 0.3847, 0.7676, 0.4061]}, {"w": "propagate", "b": [0.7741, 0.3847, 0.8571, 0.4061]}, {"w": "the", "b": [0.1429, 0.4038, 0.1692, 0.4252]}, {"w": "labels", "b": [0.1739, 0.4038, 0.2207, 0.4252]}, {"w": "to", "b": [0.2254, 0.4038, 0.2424, 0.4252]}, {"w": "the", "b": [0.2471, 0.4038, 0.2735, 0.4252]}, {"w": "20%", "b": [0.2782, 0.4038, 0.3139, 0.4252]}, {"w": "of", "b": [0.3187, 0.4038, 0.3355, 0.4252]}, {"w": "the", "b": [0.3402, 0.4038, 0.3665, 0.4252]}, {"w": "instances", "b": [0.3713, 0.4038, 0.4481, 0.4252]}, {"w": "that", "b": [0.4528, 0.4038, 0.4854, 0.4252]}, {"w": "are", "b": [0.4901, 0.4038, 0.5159, 0.4252]}, {"w": "closest", "b": [0.5206, 0.4038, 0.5758, 0.4252]}, {"w": "to", "b": [0.5805, 0.4038, 0.5975, 0.4252]}, {"w": "the", "b": [0.6022, 0.4038, 0.6286, 0.4252]}, {"w": "centroids:", "b": [0.6333, 0.4038, 0.7156, 0.4252]}]}, {"id": "b_6", "type": "equation", "text": "percentile_closest = 20", "words": [{"w": "percentile_closest", "b": [0.1766, 0.4358, 0.3284, 0.4486]}, {"w": "=", "b": [0.3368, 0.4358, 0.3452, 0.4486]}, {"w": "20", "b": [0.3537, 0.4358, 0.3705, 0.4486]}]}, {"id": "b_7", "type": "paragraph", "text": "X_cluster_dist = X_digits_dist[np.arange(len(X_train)), kmeans.labels_] for i in range(k): in_cluster = (kmeans.labels_ == i) cluster_dist = X_cluster_dist[in_cluster] cutoff_distance = np.percentile(cluster_dist, percentile_closest) above_cutoff = (X_cluster_dist > cutoff_distance) X_cluster_dist[in_cluster & above_cutoff] = -1", "words": [{"w": "X_cluster_dist", "b": [0.1766, 0.4666, 0.2946, 0.4794]}, {"w": "=", "b": [0.3031, 0.4666, 0.3115, 0.4794]}, {"w": "X_digits_dist[np.arange(len(X_train)),", "b": [0.3199, 0.4666, 0.6404, 0.4794]}, {"w": "kmeans.labels_]", "b": [0.6488, 0.4666, 0.7753, 0.4794]}, {"w": "for", "b": [0.1766, 0.482, 0.2019, 0.4949]}, {"w": "i", "b": [0.2103, 0.482, 0.2188, 0.4949]}, {"w": "in", "b": [0.2272, 0.482, 0.244, 0.4949]}, {"w": "range(k):", "b": [0.2525, 0.482, 0.3284, 0.4949]}, {"w": "in_cluster", "b": [0.2103, 0.4974, 0.2946, 0.5103]}, {"w": "=", "b": [0.3031, 0.4974, 0.3115, 0.5103]}, {"w": "(kmeans.labels_", "b": [0.3199, 0.4974, 0.4464, 0.5103]}, {"w": "==", "b": [0.4549, 0.4974, 0.4717, 0.5103]}, {"w": "i)", "b": [0.4802, 0.4974, 0.497, 0.5103]}, {"w": "cluster_dist", "b": [0.2103, 0.5128, 0.3115, 0.5257]}, {"w": "=", "b": [0.3199, 0.5128, 0.3284, 0.5257]}, {"w": "X_cluster_dist[in_cluster]", "b": [0.3368, 0.5128, 0.5561, 0.5257]}, {"w": "cutoff_distance", "b": [0.2103, 0.5283, 0.3368, 0.5411]}, {"w": "=", "b": [0.3452, 0.5283, 0.3537, 0.5411]}, {"w": "np.percentile(cluster_dist,", "b": [0.3621, 0.5283, 0.5898, 0.5411]}, {"w": "percentile_closest)", "b": [0.5982, 0.5283, 0.7584, 0.5411]}, {"w": "above_cutoff", "b": [0.2103, 0.5437, 0.3115, 0.5565]}, {"w": "=", "b": [0.3199, 0.5437, 0.3284, 0.5565]}, {"w": "(X_cluster_dist", "b": [0.3368, 0.5437, 0.4633, 0.5565]}, {"w": ">", "b": [0.4717, 0.5437, 0.4802, 0.5565]}, {"w": "cutoff_distance)", "b": [0.4886, 0.5437, 0.6235, 0.5565]}, {"w": "X_cluster_dist[in_cluster", "b": [0.2103, 0.5591, 0.4211, 0.572]}, {"w": "&", "b": [0.4296, 0.5591, 0.438, 0.572]}, {"w": "above_cutoff]", "b": [0.4464, 0.5591, 0.5561, 0.572]}, {"w": "=", "b": [0.5645, 0.5591, 0.5729, 0.572]}, {"w": "-1", "b": [0.5814, 0.5591, 0.5982, 0.572]}]}, {"id": "b_8", "type": "paragraph", "text": "partially_propagated = (X_cluster_dist != -1) X_train_partially_propagated = X_train[partially_propagated] y_train_partially_propagated = y_train_propagated[partially_propagated]", "words": [{"w": "partially_propagated", "b": [0.1766, 0.5899, 0.3452, 0.6028]}, {"w": "=", "b": [0.3537, 0.5899, 0.3621, 0.6028]}, {"w": "(X_cluster_dist", "b": [0.3705, 0.5899, 0.497, 0.6028]}, {"w": "!=", "b": [0.5055, 0.5899, 0.5223, 0.6028]}, {"w": "-1)", "b": [0.5308, 0.5899, 0.5561, 0.6028]}, {"w": "X_train_partially_propagated", "b": [0.1766, 0.6054, 0.4127, 0.6182]}, {"w": "=", "b": [0.4211, 0.6054, 0.4296, 0.6182]}, {"w": "X_train[partially_propagated]", "b": [0.438, 0.6054, 0.6825, 0.6182]}, {"w": "y_train_partially_propagated", "b": [0.1766, 0.6208, 0.4127, 0.6336]}, {"w": "=", "b": [0.4211, 0.6208, 0.4296, 0.6336]}, {"w": "y_train_propagated[partially_propagated]", "b": [0.438, 0.6208, 0.7753, 0.6336]}]}, {"id": "b_9", "type": "paragraph", "text": "Now let’s train the model again on this partially propagated dataset:", "words": [{"w": "Now", "b": [0.1429, 0.6414, 0.1827, 0.6628]}, {"w": "let’s", "b": [0.1874, 0.6414, 0.2177, 0.6628]}, {"w": "train", "b": [0.2224, 0.6414, 0.2626, 0.6628]}, {"w": "the", "b": [0.2673, 0.6414, 0.2937, 0.6628]}, {"w": "model", "b": [0.2984, 0.6414, 0.3512, 0.6628]}, {"w": "again", "b": [0.3559, 0.6414, 0.401, 0.6628]}, {"w": "on", "b": [0.4057, 0.6414, 0.4277, 0.6628]}, {"w": "this", "b": [0.4324, 0.6414, 0.4632, 0.6628]}, {"w": "partially", "b": [0.4679, 0.6414, 0.5369, 0.6628]}, {"w": "propagated", "b": [0.5416, 0.6414, 0.6356, 0.6628]}, {"w": "dataset:", "b": [0.6404, 0.6414, 0.7032, 0.6628]}]}, {"id": "b_10", "type": "paragraph", "text": ">>> log_reg = LogisticRegression() >>> log_reg.fit(X_train_partially_propagated, y_train_partially_propagated) >>> log_reg.score(X_test, y_test) 0.9422222222222222", "words": [{"w": ">>>", "b": [0.1766, 0.6734, 0.2019, 0.6862]}, {"w": "log_reg", "b": [0.2103, 0.6734, 0.2693, 0.6862]}, {"w": "=", "b": [0.2778, 0.6734, 0.2862, 0.6862]}, {"w": "LogisticRegression()", "b": [0.2946, 0.6734, 0.4633, 0.6862]}, {"w": ">>>", "b": [0.1766, 0.6888, 0.2019, 0.7017]}, {"w": "log_reg.fit(X_train_partially_propagated,", "b": [0.2103, 0.6888, 0.5561, 0.7017]}, {"w": "y_train_partially_propagated)", "b": [0.5645, 0.6888, 0.809, 0.7017]}, {"w": ">>>", "b": [0.1766, 0.7042, 0.2019, 0.7171]}, {"w": "log_reg.score(X_test,", "b": [0.2103, 0.7042, 0.3874, 0.7171]}, {"w": "y_test)", "b": [0.3958, 0.7042, 0.4549, 0.7171]}, {"w": "0.9422222222222222", "b": [0.1766, 0.7197, 0.3284, 0.7325]}]}, {"id": "b_11", "type": "paragraph", "text": "Nice! With just 50 labeled instances (only 5 examples per class on average!), we got 94.2% performance, which is pretty close to the performance of logistic regression on the fully labeled digits dataset (which was 96.7%). This is because the propagated labels are actually pretty good, their accuracy is very close to 99%:", "words": [{"w": "Nice!", "b": [0.1429, 0.7403, 0.1869, 0.7617]}, {"w": "With", "b": [0.1935, 0.7403, 0.2359, 0.7617]}, {"w": "just", "b": [0.2425, 0.7403, 0.2729, 0.7617]}, {"w": "50", "b": [0.2794, 0.7403, 0.2994, 0.7617]}, {"w": "labeled", "b": [0.306, 0.7403, 0.365, 0.7617]}, {"w": "instances", "b": [0.3716, 0.7403, 0.4484, 0.7617]}, {"w": "(only", "b": [0.455, 0.7403, 0.499, 0.7617]}, {"w": "5", "b": [0.5056, 0.7403, 0.5156, 0.7617]}, {"w": "examples", "b": [0.5222, 0.7403, 0.5994, 0.7617]}, {"w": "per", "b": [0.6059, 0.7403, 0.6334, 0.7617]}, {"w": "class", "b": [0.64, 0.7403, 0.6785, 0.7617]}, {"w": "on", "b": [0.6851, 0.7403, 0.7071, 0.7617]}, {"w": "average!),", "b": [0.7137, 0.7403, 0.7941, 0.7617]}, {"w": "we", "b": [0.8007, 0.7403, 0.8238, 0.7617]}, {"w": "got", "b": [0.8304, 0.7403, 0.8571, 0.7617]}, {"w": "94.2%", "b": [0.1429, 0.7593, 0.1934, 0.7807]}, {"w": "performance,", "b": [0.1985, 0.7593, 0.3106, 0.7807]}, {"w": "which", "b": [0.3157, 0.7593, 0.3666, 0.7807]}, {"w": "is", "b": [0.3718, 0.7593, 0.385, 0.7807]}, {"w": "pretty", "b": [0.3901, 0.7593, 0.4399, 0.7807]}, {"w": "close", "b": [0.4451, 0.7593, 0.4863, 0.7807]}, {"w": "to", "b": [0.4914, 0.7593, 0.5084, 0.7807]}, {"w": "the", "b": [0.5135, 0.7593, 0.5399, 0.7807]}, {"w": "performance", "b": [0.545, 0.7593, 0.6523, 0.7807]}, {"w": "of", "b": [0.6575, 0.7593, 0.6743, 0.7807]}, {"w": "logistic", "b": [0.6794, 0.7593, 0.739, 0.7807]}, {"w": "regression", "b": [0.7442, 0.7593, 0.83, 0.7807]}, {"w": "on", "b": [0.8351, 0.7593, 0.8572, 0.7807]}, {"w": "the", "b": [0.1429, 0.7784, 0.1692, 0.7998]}, {"w": "fully", "b": [0.1776, 0.7784, 0.2149, 0.7998]}, {"w": "labeled", "b": [0.2233, 0.7784, 0.2823, 0.7998]}, {"w": "digits", "b": [0.2907, 0.7784, 0.3366, 0.7998]}, {"w": "dataset", "b": [0.345, 0.7784, 0.4031, 0.7998]}, {"w": "(which", "b": [0.4114, 0.7784, 0.4696, 0.7998]}, {"w": "was", "b": [0.478, 0.7784, 0.509, 0.7998]}, {"w": "96.7%).", "b": [0.5174, 0.7784, 0.5799, 0.7998]}, {"w": "This", "b": [0.5882, 0.7784, 0.6254, 0.7998]}, {"w": "is", "b": [0.6338, 0.7784, 0.6471, 0.7998]}, {"w": "because", "b": [0.6554, 0.7784, 0.72, 0.7998]}, {"w": "the", "b": [0.7284, 0.7784, 0.7547, 0.7998]}, {"w": "propagated", "b": [0.7631, 0.7784, 0.8571, 0.7998]}, {"w": "labels", "b": [0.1429, 0.7974, 0.1896, 0.8188]}, {"w": "are", "b": [0.1944, 0.7974, 0.2201, 0.8188]}, {"w": "actually", "b": [0.2248, 0.7974, 0.2894, 0.8188]}, {"w": "pretty", "b": [0.2942, 0.7974, 0.3439, 0.8188]}, {"w": "good,", "b": [0.3487, 0.7974, 0.3954, 0.8188]}, {"w": "their", "b": [0.4001, 0.7974, 0.4398, 0.8188]}, {"w": "accuracy", "b": [0.4445, 0.7974, 0.5176, 0.8188]}, {"w": "is", "b": [0.5223, 0.7974, 0.5356, 0.8188]}, {"w": "very", "b": [0.5403, 0.7974, 0.5767, 0.8188]}, {"w": "close", "b": [0.5814, 0.7974, 0.6226, 0.8188]}, {"w": "to", "b": [0.6274, 0.7974, 0.6443, 0.8188]}, {"w": "99%:", "b": [0.6491, 0.7974, 0.6896, 0.8188]}]}, {"id": "b_12", "type": "paragraph", "text": "Clustering | 255", "words": [{"w": "Clustering", "b": [0.736, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "255", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 282, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": ">>> np.mean(y_train_partially_propagated == y_train[partially_propagated]) 0.9896907216494846", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "np.mean(y_train_partially_propagated", "b": [0.2103, 0.0829, 0.5139, 0.0958]}, {"w": "==", "b": [0.5223, 0.0829, 0.5392, 0.0958]}, {"w": "y_train[partially_propagated])", "b": [0.5476, 0.0829, 0.8006, 0.0958]}, {"w": "0.9896907216494846", "b": [0.1766, 0.0983, 0.3284, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "Active Learning", "words": [{"w": "Active", "b": [0.4241, 0.138, 0.4842, 0.1652]}, {"w": "Learning", "b": [0.4889, 0.138, 0.5759, 0.1652]}]}, {"id": "b_2", "type": "paragraph", "text": "To continue improving your model and your training set, the next step could be to do a few rounds of active learning: this is when a human expert interacts with the learn‐ ing algorithm, providing labels when the algorithm needs them. There are many dif‐ ferent strategies for active learning, but one of the most common ones is called uncertainty sampling:", "words": [{"w": "To", "b": [0.1592, 0.1697, 0.1796, 0.1901]}, {"w": "continue", "b": [0.1844, 0.1697, 0.2542, 0.1901]}, {"w": "improving", "b": [0.2589, 0.1697, 0.3427, 0.1901]}, {"w": "your", "b": [0.3474, 0.1697, 0.3845, 0.1901]}, {"w": "model", "b": [0.3893, 0.1697, 0.4396, 0.1901]}, {"w": "and", "b": [0.4443, 0.1697, 0.4744, 0.1901]}, {"w": "your", "b": [0.4791, 0.1697, 0.5162, 0.1901]}, {"w": "training", "b": [0.521, 0.1697, 0.5847, 0.1901]}, {"w": "set,", "b": [0.5895, 0.1697, 0.6158, 0.1901]}, {"w": "the", "b": [0.6205, 0.1697, 0.6456, 0.1901]}, {"w": "next", "b": [0.6503, 0.1697, 0.685, 0.1901]}, {"w": "step", "b": [0.6898, 0.1697, 0.722, 0.1901]}, {"w": "could", "b": [0.7267, 0.1697, 0.7712, 0.1901]}, {"w": "be", "b": [0.776, 0.1697, 0.7945, 0.1901]}, {"w": "to", "b": [0.7993, 0.1697, 0.8154, 0.1901]}, {"w": "do", "b": [0.8202, 0.1697, 0.8408, 0.1901]}, {"w": "a", "b": [0.1592, 0.1879, 0.1679, 0.2083]}, {"w": "few", "b": [0.1734, 0.1879, 0.2013, 0.2083]}, {"w": "rounds", "b": [0.2068, 0.1879, 0.2635, 0.2083]}, {"w": "of", "b": [0.2689, 0.1879, 0.2849, 0.2083]}, {"w": "active", "b": [0.2904, 0.1877, 0.3354, 0.2083]}, {"w": "learning:", "b": [0.341, 0.1877, 0.409, 0.2083]}, {"w": "this", "b": [0.4145, 0.1879, 0.4438, 0.2083]}, {"w": "is", "b": [0.4493, 0.1879, 0.4619, 0.2083]}, {"w": "when", "b": [0.4674, 0.1879, 0.5108, 0.2083]}, {"w": "a", "b": [0.5163, 0.1879, 0.525, 0.2083]}, {"w": "human", "b": [0.5305, 0.1879, 0.5871, 0.2083]}, {"w": "expert", "b": [0.5926, 0.1879, 0.6426, 0.2083]}, {"w": "interacts", "b": [0.6481, 0.1879, 0.7162, 0.2083]}, {"w": "with", "b": [0.7217, 0.1879, 0.7573, 0.2083]}, {"w": "the", "b": [0.7628, 0.1879, 0.7878, 0.2083]}, {"w": "learn‐", "b": [0.7933, 0.1879, 0.8408, 0.2083]}, {"w": "ing", "b": [0.1592, 0.206, 0.1847, 0.2264]}, {"w": "algorithm,", "b": [0.1902, 0.206, 0.2735, 0.2264]}, {"w": "providing", "b": [0.279, 0.206, 0.3573, 0.2264]}, {"w": "labels", "b": [0.3629, 0.206, 0.4074, 0.2264]}, {"w": "when", "b": [0.413, 0.206, 0.4565, 0.2264]}, {"w": "the", "b": [0.462, 0.206, 0.4871, 0.2264]}, {"w": "algorithm", "b": [0.4926, 0.206, 0.5714, 0.2264]}, {"w": "needs", "b": [0.5769, 0.206, 0.6224, 0.2264]}, {"w": "them.", "b": [0.6279, 0.206, 0.6738, 0.2264]}, {"w": "There", "b": [0.6794, 0.206, 0.7264, 0.2264]}, {"w": "are", "b": [0.732, 0.206, 0.7565, 0.2264]}, {"w": "many", "b": [0.762, 0.206, 0.8065, 0.2264]}, {"w": "dif‐", "b": [0.812, 0.206, 0.8408, 0.2264]}, {"w": "ferent", "b": [0.1592, 0.2242, 0.2059, 0.2446]}, {"w": "strategies", "b": [0.2149, 0.2242, 0.2887, 0.2446]}, {"w": "for", "b": [0.2977, 0.2242, 0.3211, 0.2446]}, {"w": "active", "b": [0.3301, 0.2242, 0.3762, 0.2446]}, {"w": "learning,", "b": [0.3852, 0.2242, 0.4555, 0.2446]}, {"w": "but", "b": [0.4645, 0.2242, 0.4912, 0.2446]}, {"w": "one", "b": [0.5002, 0.2242, 0.5296, 0.2446]}, {"w": "of", "b": [0.5386, 0.2242, 0.5546, 0.2446]}, {"w": "the", "b": [0.5636, 0.2242, 0.5887, 0.2446]}, {"w": "most", "b": [0.5977, 0.2242, 0.6374, 0.2446]}, {"w": "common", "b": [0.6464, 0.2242, 0.7184, 0.2446]}, {"w": "ones", "b": [0.7274, 0.2242, 0.7641, 0.2446]}, {"w": "is", "b": [0.7731, 0.2242, 0.7857, 0.2446]}, {"w": "called", "b": [0.7947, 0.2242, 0.8408, 0.2446]}, {"w": "uncertainty", "b": [0.1592, 0.2421, 0.2484, 0.2627]}, {"w": "sampling:", "b": [0.253, 0.2421, 0.3268, 0.2627]}]}, {"id": "b_3", "type": "paragraph", "text": "• The model is trained on the labeled instances gathered so far, and this model is used to make predictions on all the unlabeled instances.", "words": [{"w": "•", "b": [0.1773, 0.2756, 0.185, 0.2959]}, {"w": "The", "b": [0.1949, 0.2756, 0.2262, 0.2959]}, {"w": "model", "b": [0.2323, 0.2756, 0.2826, 0.2959]}, {"w": "is", "b": [0.2887, 0.2756, 0.3013, 0.2959]}, {"w": "trained", "b": [0.3074, 0.2756, 0.3646, 0.2959]}, {"w": "on", "b": [0.3707, 0.2756, 0.3917, 0.2959]}, {"w": "the", "b": [0.3977, 0.2756, 0.4228, 0.2959]}, {"w": "labeled", "b": [0.4289, 0.2756, 0.4851, 0.2959]}, {"w": "instances", "b": [0.4912, 0.2756, 0.5644, 0.2959]}, {"w": "gathered", "b": [0.5704, 0.2756, 0.6394, 0.2959]}, {"w": "so", "b": [0.6455, 0.2756, 0.6629, 0.2959]}, {"w": "far,", "b": [0.669, 0.2756, 0.6942, 0.2959]}, {"w": "and", "b": [0.7003, 0.2756, 0.7304, 0.2959]}, {"w": "this", "b": [0.7364, 0.2756, 0.7657, 0.2959]}, {"w": "model", "b": [0.7718, 0.2756, 0.8221, 0.2959]}, {"w": "is", "b": [0.8282, 0.2756, 0.8408, 0.2959]}, {"w": "used", "b": [0.1949, 0.2937, 0.2317, 0.3141]}, {"w": "to", "b": [0.2362, 0.2937, 0.2523, 0.3141]}, {"w": "make", "b": [0.2568, 0.2937, 0.3001, 0.3141]}, {"w": "predictions", "b": [0.3046, 0.2937, 0.3946, 0.3141]}, {"w": "on", "b": [0.3991, 0.2937, 0.4201, 0.3141]}, {"w": "all", "b": [0.4246, 0.2937, 0.4433, 0.3141]}, {"w": "the", "b": [0.4478, 0.2937, 0.4729, 0.3141]}, {"w": "unlabeled", "b": [0.4774, 0.2937, 0.555, 0.3141]}, {"w": "instances.", "b": [0.5595, 0.2937, 0.6372, 0.3141]}]}, {"id": "b_4", "type": "paragraph", "text": "• The instances for which the model is most uncertain (i.e., when its estimated probability is lowest) must be labeled by the expert.", "words": [{"w": "•", "b": [0.1773, 0.3179, 0.185, 0.3383]}, {"w": "The", "b": [0.1949, 0.3179, 0.2262, 0.3383]}, {"w": "instances", "b": [0.2339, 0.3179, 0.3071, 0.3383]}, {"w": "for", "b": [0.3148, 0.3179, 0.3381, 0.3383]}, {"w": "which", "b": [0.3458, 0.3179, 0.3943, 0.3383]}, {"w": "the", "b": [0.402, 0.3179, 0.4271, 0.3383]}, {"w": "model", "b": [0.4348, 0.3179, 0.4851, 0.3383]}, {"w": "is", "b": [0.4928, 0.3179, 0.5054, 0.3383]}, {"w": "most", "b": [0.5131, 0.3179, 0.5528, 0.3383]}, {"w": "uncertain", "b": [0.5605, 0.3179, 0.637, 0.3383]}, {"w": "(i.e.,", "b": [0.6447, 0.3179, 0.6789, 0.3383]}, {"w": "when", "b": [0.6866, 0.3179, 0.7301, 0.3383]}, {"w": "its", "b": [0.7378, 0.3179, 0.7564, 0.3383]}, {"w": "estimated", "b": [0.7641, 0.3179, 0.8408, 0.3383]}, {"w": "probability", "b": [0.1949, 0.336, 0.2825, 0.3564]}, {"w": "is", "b": [0.287, 0.336, 0.2996, 0.3564]}, {"w": "lowest)", "b": [0.3041, 0.336, 0.3615, 0.3564]}, {"w": "must", "b": [0.366, 0.336, 0.4057, 0.3564]}, {"w": "be", "b": [0.4102, 0.336, 0.4287, 0.3564]}, {"w": "labeled", "b": [0.4332, 0.336, 0.4894, 0.3564]}, {"w": "by", "b": [0.4939, 0.336, 0.5131, 0.3564]}, {"w": "the", "b": [0.5176, 0.336, 0.5427, 0.3564]}, {"w": "expert.", "b": [0.5472, 0.336, 0.6017, 0.3564]}]}, {"id": "b_5", "type": "paragraph", "text": "• Then you just iterate this process again and again, until the performance improvement stops being worth the labeling effort.", "words": [{"w": "•", "b": [0.1773, 0.3602, 0.185, 0.3806]}, {"w": "Then", "b": [0.1949, 0.3602, 0.2371, 0.3806]}, {"w": "you", "b": [0.2481, 0.3602, 0.2779, 0.3806]}, {"w": "just", "b": [0.2889, 0.3602, 0.3179, 0.3806]}, {"w": "iterate", "b": [0.3289, 0.3602, 0.3789, 0.3806]}, {"w": "this", "b": [0.3899, 0.3602, 0.4192, 0.3806]}, {"w": "process", "b": [0.4302, 0.3602, 0.4895, 0.3806]}, {"w": "again", "b": [0.5006, 0.3602, 0.5434, 0.3806]}, {"w": "and", "b": [0.5545, 0.3602, 0.5845, 0.3806]}, {"w": "again,", "b": [0.5956, 0.3602, 0.643, 0.3806]}, {"w": "until", "b": [0.654, 0.3602, 0.6914, 0.3806]}, {"w": "the", "b": [0.7025, 0.3602, 0.7275, 0.3806]}, {"w": "performance", "b": [0.7386, 0.3602, 0.8408, 0.3806]}, {"w": "improvement", "b": [0.1949, 0.3784, 0.3028, 0.3987]}, {"w": "stops", "b": [0.3073, 0.3784, 0.3485, 0.3987]}, {"w": "being", "b": [0.353, 0.3784, 0.3969, 0.3987]}, {"w": "worth", "b": [0.4014, 0.3784, 0.4492, 0.3987]}, {"w": "the", "b": [0.4537, 0.3784, 0.4788, 0.3987]}, {"w": "labeling", "b": [0.4833, 0.3784, 0.546, 0.3987]}, {"w": "effort.", "b": [0.5505, 0.3784, 0.5987, 0.3987]}]}, {"id": "b_6", "type": "paragraph", "text": "Other strategies include labeling the instances that would result in the largest model change, or the largest drop in the model’s validation error, or the instances that differ‐ ent models disagree on (e.g., an SVM, a Random Forest, and so on).", "words": [{"w": "Other", "b": [0.1592, 0.4116, 0.2065, 0.432]}, {"w": "strategies", "b": [0.2124, 0.4116, 0.2863, 0.432]}, {"w": "include", "b": [0.2922, 0.4116, 0.3512, 0.432]}, {"w": "labeling", "b": [0.3572, 0.4116, 0.4199, 0.432]}, {"w": "the", "b": [0.4258, 0.4116, 0.4509, 0.432]}, {"w": "instances", "b": [0.4569, 0.4116, 0.53, 0.432]}, {"w": "that", "b": [0.536, 0.4116, 0.567, 0.432]}, {"w": "would", "b": [0.5729, 0.4116, 0.6227, 0.432]}, {"w": "result", "b": [0.6286, 0.4116, 0.6733, 0.432]}, {"w": "in", "b": [0.6793, 0.4116, 0.6954, 0.432]}, {"w": "the", "b": [0.7014, 0.4116, 0.7264, 0.432]}, {"w": "largest", "b": [0.7324, 0.4116, 0.7845, 0.432]}, {"w": "model", "b": [0.7905, 0.4116, 0.8408, 0.432]}, {"w": "change,", "b": [0.1592, 0.4298, 0.22, 0.4501]}, {"w": "or", "b": [0.2248, 0.4298, 0.2422, 0.4501]}, {"w": "the", "b": [0.247, 0.4298, 0.2721, 0.4501]}, {"w": "largest", "b": [0.2768, 0.4298, 0.3289, 0.4501]}, {"w": "drop", "b": [0.3337, 0.4298, 0.372, 0.4501]}, {"w": "in", "b": [0.3768, 0.4298, 0.393, 0.4501]}, {"w": "the", "b": [0.3977, 0.4298, 0.4228, 0.4501]}, {"w": "model’s", "b": [0.4275, 0.4298, 0.4871, 0.4501]}, {"w": "validation", "b": [0.4919, 0.4298, 0.5713, 0.4501]}, {"w": "error,", "b": [0.576, 0.4298, 0.6199, 0.4501]}, {"w": "or", "b": [0.6246, 0.4298, 0.6421, 0.4501]}, {"w": "the", "b": [0.6469, 0.4298, 0.6719, 0.4501]}, {"w": "instances", "b": [0.6767, 0.4298, 0.7499, 0.4501]}, {"w": "that", "b": [0.7546, 0.4298, 0.7856, 0.4501]}, {"w": "differ‐", "b": [0.7904, 0.4298, 0.8408, 0.4501]}, {"w": "ent", "b": [0.1592, 0.4479, 0.1842, 0.4683]}, {"w": "models", "b": [0.1887, 0.4479, 0.2463, 0.4683]}, {"w": "disagree", "b": [0.2508, 0.4479, 0.3161, 0.4683]}, {"w": "on", "b": [0.3206, 0.4479, 0.3415, 0.4683]}, {"w": "(e.g.,", "b": [0.3461, 0.4479, 0.3842, 0.4683]}, {"w": "an", "b": [0.3887, 0.4479, 0.4083, 0.4683]}, {"w": "SVM,", "b": [0.4128, 0.4479, 0.4583, 0.4683]}, {"w": "a", "b": [0.4628, 0.4479, 0.4715, 0.4683]}, {"w": "Random", "b": [0.4761, 0.4479, 0.5451, 0.4683]}, {"w": "Forest,", "b": [0.5496, 0.4479, 0.6035, 0.4683]}, {"w": "and", "b": [0.608, 0.4479, 0.6381, 0.4683]}, {"w": "so", "b": [0.6426, 0.4479, 0.66, 0.4683]}, {"w": "on).", "b": [0.6645, 0.4479, 0.6968, 0.4683]}]}, {"id": "b_7", "type": "paragraph", "text": "Before we move on to Gaussian mixture models, let’s take a look at DBSCAN, another popular clustering algorithm that illustrates a very different approach based on local density estimation. This approach allows the algorithm to identify clusters of arbitrary shapes.", "words": [{"w": "Before", "b": [0.1429, 0.498, 0.1978, 0.5194]}, {"w": "we", "b": [0.2079, 0.498, 0.231, 0.5194]}, {"w": "move", "b": [0.2411, 0.498, 0.2873, 0.5194]}, {"w": "on", "b": [0.2974, 0.498, 0.3194, 0.5194]}, {"w": "to", "b": [0.3295, 0.498, 0.3465, 0.5194]}, {"w": "Gaussian", "b": [0.3566, 0.498, 0.4327, 0.5194]}, {"w": "mixture", "b": [0.4428, 0.498, 0.5093, 0.5194]}, {"w": "models,", "b": [0.5194, 0.498, 0.5846, 0.5194]}, {"w": "let’s", "b": [0.5947, 0.498, 0.6249, 0.5194]}, {"w": "take", "b": [0.635, 0.498, 0.6697, 0.5194]}, {"w": "a", "b": [0.6798, 0.498, 0.689, 0.5194]}, {"w": "look", "b": [0.6991, 0.498, 0.7359, 0.5194]}, {"w": "at", "b": [0.746, 0.498, 0.7611, 0.5194]}, {"w": "DBSCAN,", "b": [0.7712, 0.498, 0.8572, 0.5194]}, {"w": "another", "b": [0.1429, 0.5171, 0.2081, 0.5385]}, {"w": "popular", "b": [0.2144, 0.5171, 0.28, 0.5385]}, {"w": "clustering", "b": [0.2863, 0.5171, 0.3688, 0.5385]}, {"w": "algorithm", "b": [0.375, 0.5171, 0.4577, 0.5385]}, {"w": "that", "b": [0.4639, 0.5171, 0.4965, 0.5385]}, {"w": "illustrates", "b": [0.5028, 0.5171, 0.5833, 0.5385]}, {"w": "a", "b": [0.5896, 0.5171, 0.5987, 0.5385]}, {"w": "very", "b": [0.605, 0.5171, 0.6414, 0.5385]}, {"w": "different", "b": [0.6477, 0.5171, 0.7194, 0.5385]}, {"w": "approach", "b": [0.7256, 0.5171, 0.8036, 0.5385]}, {"w": "based", "b": [0.8099, 0.5171, 0.8571, 0.5385]}, {"w": "on", "b": [0.1429, 0.5361, 0.1649, 0.5575]}, {"w": "local", "b": [0.17, 0.5361, 0.2091, 0.5575]}, {"w": "density", "b": [0.2143, 0.5361, 0.2747, 0.5575]}, {"w": "estimation.", "b": [0.2798, 0.5361, 0.3728, 0.5575]}, {"w": "This", "b": [0.3779, 0.5361, 0.4151, 0.5575]}, {"w": "approach", "b": [0.4203, 0.5361, 0.4983, 0.5575]}, {"w": "allows", "b": [0.5035, 0.5361, 0.5557, 0.5575]}, {"w": "the", "b": [0.5608, 0.5361, 0.5872, 0.5575]}, {"w": "algorithm", "b": [0.5923, 0.5361, 0.675, 0.5575]}, {"w": "to", "b": [0.6801, 0.5361, 0.6971, 0.5575]}, {"w": "identify", "b": [0.7022, 0.5361, 0.7667, 0.5575]}, {"w": "clusters", "b": [0.7718, 0.5361, 0.8352, 0.5575]}, {"w": "of", "b": [0.8403, 0.5361, 0.8571, 0.5575]}, {"w": "arbitrary", "b": [0.1428, 0.5552, 0.217, 0.5766]}, {"w": "shapes.", "b": [0.2217, 0.5552, 0.2814, 0.5766]}]}, {"id": "b_8", "type": "paragraph", "text": "DBSCAN", "words": [{"w": "DBSCAN", "b": [0.1428, 0.5894, 0.2251, 0.6179]}]}, {"id": "b_9", "type": "paragraph", "text": "This algorithm defines clusters as continuous regions of high density. It is actually quite simple:", "words": [{"w": "This", "b": [0.1428, 0.6238, 0.1801, 0.6452]}, {"w": "algorithm", "b": [0.1876, 0.6238, 0.2703, 0.6452]}, {"w": "defines", "b": [0.2779, 0.6238, 0.3374, 0.6452]}, {"w": "clusters", "b": [0.3449, 0.6238, 0.4083, 0.6452]}, {"w": "as", "b": [0.4159, 0.6238, 0.4327, 0.6452]}, {"w": "continuous", "b": [0.4403, 0.6238, 0.534, 0.6452]}, {"w": "regions", "b": [0.5416, 0.6238, 0.6032, 0.6452]}, {"w": "of", "b": [0.6108, 0.6238, 0.6275, 0.6452]}, {"w": "high", "b": [0.6351, 0.6238, 0.6727, 0.6452]}, {"w": "density.", "b": [0.6803, 0.6238, 0.7439, 0.6452]}, {"w": "It", "b": [0.7515, 0.6238, 0.7641, 0.6452]}, {"w": "is", "b": [0.7717, 0.6238, 0.7849, 0.6452]}, {"w": "actually", "b": [0.7925, 0.6238, 0.8571, 0.6452]}, {"w": "quite", "b": [0.1429, 0.6429, 0.1854, 0.6643]}, {"w": "simple:", "b": [0.1901, 0.6429, 0.2498, 0.6643]}]}, {"id": "b_10", "type": "paragraph", "text": "• For each instance, the algorithm counts how many instances are located within a small distance ε (epsilon) from it. This region is called the instance’s ε- neighborhood.", "words": [{"w": "•", "b": [0.16, 0.677, 0.1682, 0.6984]}, {"w": "For", "b": [0.1786, 0.677, 0.2075, 0.6984]}, {"w": "each", "b": [0.2129, 0.677, 0.2509, 0.6984]}, {"w": "instance,", "b": [0.2563, 0.677, 0.3302, 0.6984]}, {"w": "the", "b": [0.3356, 0.677, 0.362, 0.6984]}, {"w": "algorithm", "b": [0.3674, 0.677, 0.45, 0.6984]}, {"w": "counts", "b": [0.4554, 0.677, 0.5109, 0.6984]}, {"w": "how", "b": [0.5163, 0.677, 0.5523, 0.6984]}, {"w": "many", "b": [0.5577, 0.677, 0.6044, 0.6984]}, {"w": "instances", "b": [0.6098, 0.677, 0.6867, 0.6984]}, {"w": "are", "b": [0.6921, 0.677, 0.7178, 0.6984]}, {"w": "located", "b": [0.7232, 0.677, 0.7829, 0.6984]}, {"w": "within", "b": [0.7883, 0.677, 0.8426, 0.6984]}, {"w": "a", "b": [0.848, 0.677, 0.8571, 0.6984]}, {"w": "small", "b": [0.1786, 0.6961, 0.223, 0.7175]}, {"w": "distance", "b": [0.2356, 0.6961, 0.3044, 0.7175]}, {"w": "ε", "b": [0.317, 0.6961, 0.3254, 0.7175]}, {"w": "(epsilon)", "b": [0.3381, 0.6961, 0.4128, 0.7175]}, {"w": "from", "b": [0.4254, 0.6961, 0.467, 0.7175]}, {"w": "it.", "b": [0.4796, 0.6961, 0.4963, 0.7175]}, {"w": "This", "b": [0.509, 0.6961, 0.5462, 0.7175]}, {"w": "region", "b": [0.5588, 0.6961, 0.6127, 0.7175]}, {"w": "is", "b": [0.6254, 0.6961, 0.6386, 0.7175]}, {"w": "called", "b": [0.6513, 0.6961, 0.6996, 0.7175]}, {"w": "the", "b": [0.7122, 0.6961, 0.7386, 0.7175]}, {"w": "instance’s", "b": [0.7512, 0.6961, 0.8295, 0.7175]}, {"w": "ε-", "b": [0.8421, 0.6959, 0.8571, 0.7175]}, {"w": "neighborhood.", "b": [0.1786, 0.7149, 0.2947, 0.7365]}]}, {"id": "b_11", "type": "paragraph", "text": "• If an instance has at least min_samples instances in its ε-neighborhood (includ‐ ing itself), then it is considered a core instance. In other words, core instances are those that are located in dense regions.", "words": [{"w": "•", "b": [0.16, 0.7411, 0.1682, 0.7625]}, {"w": "If", "b": [0.1786, 0.7411, 0.1918, 0.7625]}, {"w": "an", "b": [0.1982, 0.7411, 0.2188, 0.7625]}, {"w": "instance", "b": [0.2252, 0.7411, 0.2944, 0.7625]}, {"w": "has", "b": [0.3008, 0.7411, 0.3287, 0.7625]}, {"w": "at", "b": [0.3351, 0.7411, 0.3502, 0.7625]}, {"w": "least", "b": [0.3566, 0.7411, 0.3939, 0.7625]}, {"w": "min_samples", "b": [0.4003, 0.7443, 0.5091, 0.7594]}, {"w": "instances", "b": [0.5155, 0.7411, 0.5924, 0.7625]}, {"w": "in", "b": [0.5988, 0.7411, 0.6158, 0.7625]}, {"w": "its", "b": [0.6222, 0.7411, 0.6417, 0.7625]}, {"w": "ε-neighborhood", "b": [0.6481, 0.7411, 0.783, 0.7625]}, {"w": "(includ‐", "b": [0.7894, 0.7411, 0.8571, 0.7625]}, {"w": "ing", "b": [0.1786, 0.7602, 0.2053, 0.7816]}, {"w": "itself),", "b": [0.2105, 0.7602, 0.264, 0.7816]}, {"w": "then", "b": [0.2692, 0.7602, 0.3069, 0.7816]}, {"w": "it", "b": [0.3121, 0.7602, 0.324, 0.7816]}, {"w": "is", "b": [0.3292, 0.7602, 0.3425, 0.7816]}, {"w": "considered", "b": [0.3477, 0.7602, 0.4392, 0.7816]}, {"w": "a", "b": [0.4444, 0.7602, 0.4535, 0.7816]}, {"w": "core", "b": [0.4587, 0.76, 0.4917, 0.7816]}, {"w": "instance.", "b": [0.4965, 0.76, 0.5681, 0.7816]}, {"w": "In", "b": [0.5733, 0.7602, 0.5918, 0.7816]}, {"w": "other", "b": [0.597, 0.7602, 0.6417, 0.7816]}, {"w": "words,", "b": [0.6469, 0.7602, 0.703, 0.7816]}, {"w": "core", "b": [0.7082, 0.7602, 0.7442, 0.7816]}, {"w": "instances", "b": [0.7494, 0.7602, 0.8262, 0.7816]}, {"w": "are", "b": [0.8314, 0.7602, 0.8572, 0.7816]}, {"w": "those", "b": [0.1786, 0.7792, 0.2232, 0.8006]}, {"w": "that", "b": [0.2279, 0.7792, 0.2605, 0.8006]}, {"w": "are", "b": [0.2652, 0.7792, 0.2909, 0.8006]}, {"w": "located", "b": [0.2957, 0.7792, 0.3553, 0.8006]}, {"w": "in", "b": [0.3601, 0.7792, 0.377, 0.8006]}, {"w": "dense", "b": [0.3818, 0.7792, 0.4295, 0.8006]}, {"w": "regions.", "b": [0.4343, 0.7792, 0.5006, 0.8006]}]}, {"id": "b_12", "type": "paragraph", "text": "• All instances in the neighborhood of a core instance belong to the same cluster. This may include other core instances, therefore a long sequence of neighboring core instances forms a single cluster.", "words": [{"w": "•", "b": [0.16, 0.8043, 0.1682, 0.8257]}, {"w": "All", "b": [0.1786, 0.8043, 0.2035, 0.8257]}, {"w": "instances", "b": [0.2098, 0.8043, 0.2866, 0.8257]}, {"w": "in", "b": [0.2929, 0.8043, 0.3099, 0.8257]}, {"w": "the", "b": [0.3162, 0.8043, 0.3425, 0.8257]}, {"w": "neighborhood", "b": [0.3488, 0.8043, 0.4678, 0.8257]}, {"w": "of", "b": [0.4741, 0.8043, 0.4909, 0.8257]}, {"w": "a", "b": [0.4971, 0.8043, 0.5063, 0.8257]}, {"w": "core", "b": [0.5126, 0.8043, 0.5486, 0.8257]}, {"w": "instance", "b": [0.5549, 0.8043, 0.6241, 0.8257]}, {"w": "belong", "b": [0.6303, 0.8043, 0.6868, 0.8257]}, {"w": "to", "b": [0.6931, 0.8043, 0.7101, 0.8257]}, {"w": "the", "b": [0.7164, 0.8043, 0.7427, 0.8257]}, {"w": "same", "b": [0.749, 0.8043, 0.7917, 0.8257]}, {"w": "cluster.", "b": [0.798, 0.8043, 0.8571, 0.8257]}, {"w": "This", "b": [0.1786, 0.8234, 0.2158, 0.8448]}, {"w": "may", "b": [0.2216, 0.8234, 0.257, 0.8448]}, {"w": "include", "b": [0.2628, 0.8234, 0.3248, 0.8448]}, {"w": "other", "b": [0.3306, 0.8234, 0.3753, 0.8448]}, {"w": "core", "b": [0.3811, 0.8234, 0.4171, 0.8448]}, {"w": "instances,", "b": [0.4229, 0.8234, 0.5045, 0.8448]}, {"w": "therefore", "b": [0.5103, 0.8234, 0.5866, 0.8448]}, {"w": "a", "b": [0.5924, 0.8234, 0.6016, 0.8448]}, {"w": "long", "b": [0.6074, 0.8234, 0.6444, 0.8448]}, {"w": "sequence", "b": [0.6502, 0.8234, 0.7264, 0.8448]}, {"w": "of", "b": [0.7322, 0.8234, 0.749, 0.8448]}, {"w": "neighboring", "b": [0.7548, 0.8234, 0.8571, 0.8448]}, {"w": "core", "b": [0.1786, 0.8424, 0.2146, 0.8638]}, {"w": "instances", "b": [0.2193, 0.8424, 0.2961, 0.8638]}, {"w": "forms", "b": [0.3009, 0.8424, 0.3501, 0.8638]}, {"w": "a", "b": [0.3548, 0.8424, 0.364, 0.8638]}, {"w": "single", "b": [0.3687, 0.8424, 0.4172, 0.8638]}, {"w": "cluster.", "b": [0.4219, 0.8424, 0.4811, 0.8638]}]}, {"id": "b_13", "type": "paragraph", "text": "256 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "256", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 283, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• Any instance that is not a core instance and does not have one in its neighbor‐ hood is considered an anomaly.", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "Any", "b": [0.1786, 0.0791, 0.2134, 0.1005]}, {"w": "instance", "b": [0.22, 0.0791, 0.2892, 0.1005]}, {"w": "that", "b": [0.2958, 0.0791, 0.3284, 0.1005]}, {"w": "is", "b": [0.335, 0.0791, 0.3482, 0.1005]}, {"w": "not", "b": [0.3548, 0.0791, 0.3832, 0.1005]}, {"w": "a", "b": [0.3898, 0.0791, 0.399, 0.1005]}, {"w": "core", "b": [0.4056, 0.0791, 0.4416, 0.1005]}, {"w": "instance", "b": [0.4482, 0.0791, 0.5174, 0.1005]}, {"w": "and", "b": [0.524, 0.0791, 0.5555, 0.1005]}, {"w": "does", "b": [0.5621, 0.0791, 0.6003, 0.1005]}, {"w": "not", "b": [0.6069, 0.0791, 0.6352, 0.1005]}, {"w": "have", "b": [0.6418, 0.0791, 0.6802, 0.1005]}, {"w": "one", "b": [0.6868, 0.0791, 0.7177, 0.1005]}, {"w": "in", "b": [0.7243, 0.0791, 0.7413, 0.1005]}, {"w": "its", "b": [0.7479, 0.0791, 0.7675, 0.1005]}, {"w": "neighbor‐", "b": [0.7741, 0.0791, 0.8571, 0.1005]}, {"w": "hood", "b": [0.1786, 0.0981, 0.2219, 0.1195]}, {"w": "is", "b": [0.2267, 0.0981, 0.2399, 0.1195]}, {"w": "considered", "b": [0.2446, 0.0981, 0.3361, 0.1195]}, {"w": "an", "b": [0.3409, 0.0981, 0.3614, 0.1195]}, {"w": "anomaly.", "b": [0.3661, 0.0981, 0.4416, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "This algorithm works well if all the clusters are dense enough, and they are well sepa‐ rated by low-density regions. The DBSCAN class in Scikit-Learn is as simple to use as you might expect. Let’s test it on the moons dataset, introduced in Chapter 5:", "words": [{"w": "This", "b": [0.1429, 0.1323, 0.1801, 0.1537]}, {"w": "algorithm", "b": [0.1852, 0.1323, 0.2679, 0.1537]}, {"w": "works", "b": [0.273, 0.1323, 0.3236, 0.1537]}, {"w": "well", "b": [0.3288, 0.1323, 0.3624, 0.1537]}, {"w": "if", "b": [0.3676, 0.1323, 0.3793, 0.1537]}, {"w": "all", "b": [0.3845, 0.1323, 0.4041, 0.1537]}, {"w": "the", "b": [0.4093, 0.1323, 0.4356, 0.1537]}, {"w": "clusters", "b": [0.4408, 0.1323, 0.5041, 0.1537]}, {"w": "are", "b": [0.5093, 0.1323, 0.535, 0.1537]}, {"w": "dense", "b": [0.5402, 0.1323, 0.5879, 0.1537]}, {"w": "enough,", "b": [0.5931, 0.1323, 0.6606, 0.1537]}, {"w": "and", "b": [0.6658, 0.1323, 0.6973, 0.1537]}, {"w": "they", "b": [0.7024, 0.1323, 0.7383, 0.1537]}, {"w": "are", "b": [0.7435, 0.1323, 0.7692, 0.1537]}, {"w": "well", "b": [0.7744, 0.1323, 0.808, 0.1537]}, {"w": "sepa‐", "b": [0.8132, 0.1323, 0.8572, 0.1537]}, {"w": "rated", "b": [0.1429, 0.1522, 0.1855, 0.1736]}, {"w": "by", "b": [0.192, 0.1522, 0.2122, 0.1736]}, {"w": "low-density", "b": [0.2187, 0.1522, 0.3167, 0.1736]}, {"w": "regions.", "b": [0.3231, 0.1522, 0.3895, 0.1736]}, {"w": "The", "b": [0.396, 0.1522, 0.4288, 0.1736]}, {"w": "DBSCAN", "b": [0.4353, 0.1554, 0.4947, 0.1705]}, {"w": "class", "b": [0.5011, 0.1522, 0.5397, 0.1736]}, {"w": "in", "b": [0.5462, 0.1522, 0.5631, 0.1736]}, {"w": "Scikit-Learn", "b": [0.5696, 0.1522, 0.6719, 0.1736]}, {"w": "is", "b": [0.6784, 0.1522, 0.6916, 0.1736]}, {"w": "as", "b": [0.6981, 0.1522, 0.7149, 0.1736]}, {"w": "simple", "b": [0.7214, 0.1522, 0.7763, 0.1736]}, {"w": "to", "b": [0.7828, 0.1522, 0.7998, 0.1736]}, {"w": "use", "b": [0.8063, 0.1522, 0.8339, 0.1736]}, {"w": "as", "b": [0.8404, 0.1522, 0.8571, 0.1736]}, {"w": "you", "b": [0.1429, 0.1713, 0.1741, 0.1927]}, {"w": "might", "b": [0.1788, 0.1713, 0.2283, 0.1927]}, {"w": "expect.", "b": [0.233, 0.1713, 0.2914, 0.1927]}, {"w": "Let’s", "b": [0.2961, 0.1713, 0.3323, 0.1927]}, {"w": "test", "b": [0.337, 0.1713, 0.3663, 0.1927]}, {"w": "it", "b": [0.371, 0.1713, 0.3829, 0.1927]}, {"w": "on", "b": [0.3876, 0.1713, 0.4097, 0.1927]}, {"w": "the", "b": [0.4144, 0.1713, 0.4407, 0.1927]}, {"w": "moons", "b": [0.4455, 0.1713, 0.5028, 0.1927]}, {"w": "dataset,", "b": [0.5075, 0.1713, 0.5704, 0.1927]}, {"w": "introduced", "b": [0.5751, 0.1713, 0.6671, 0.1927]}, {"w": "in", "b": [0.6719, 0.1713, 0.6889, 0.1927]}, {"w": "Chapter", "b": [0.6936, 0.1713, 0.7612, 0.1927]}, {"w": "5:", "b": [0.7659, 0.1713, 0.7806, 0.1927]}]}, {"id": "b_2", "type": "equation", "text": "from sklearn.cluster import DBSCAN from sklearn.datasets import make_moons", "words": [{"w": "from", "b": [0.1766, 0.2032, 0.2103, 0.2161]}, {"w": "sklearn.cluster", "b": [0.2188, 0.2032, 0.3452, 0.2161]}, {"w": "import", "b": [0.3537, 0.2032, 0.4043, 0.2161]}, {"w": "DBSCAN", "b": [0.4127, 0.2032, 0.4633, 0.2161]}, {"w": "from", "b": [0.1766, 0.2187, 0.2103, 0.2315]}, {"w": "sklearn.datasets", "b": [0.2188, 0.2187, 0.3537, 0.2315]}, {"w": "import", "b": [0.3621, 0.2187, 0.4127, 0.2315]}, {"w": "make_moons", "b": [0.4211, 0.2187, 0.5055, 0.2315]}]}, {"id": "b_3", "type": "paragraph", "text": "X, y = make_moons(n_samples=1000, noise=0.05) dbscan = DBSCAN(eps=0.05, min_samples=5) dbscan.fit(X)", "words": [{"w": "X,", "b": [0.1766, 0.2495, 0.1935, 0.2623]}, {"w": "y", "b": [0.2019, 0.2495, 0.2103, 0.2623]}, {"w": "=", "b": [0.2188, 0.2495, 0.2272, 0.2623]}, {"w": "make_moons(n_samples=1000,", "b": [0.2356, 0.2495, 0.4549, 0.2623]}, {"w": "noise=0.05)", "b": [0.4633, 0.2495, 0.5561, 0.2623]}, {"w": "dbscan", "b": [0.1766, 0.2649, 0.2272, 0.2778]}, {"w": "=", "b": [0.2356, 0.2649, 0.244, 0.2778]}, {"w": "DBSCAN(eps=0.05,", "b": [0.2525, 0.2649, 0.3874, 0.2778]}, {"w": "min_samples=5)", "b": [0.3958, 0.2649, 0.5139, 0.2778]}, {"w": "dbscan.fit(X)", "b": [0.1766, 0.2803, 0.2862, 0.2932]}]}, {"id": "b_4", "type": "paragraph", "text": "The labels of all the instances are now available in the labels_ instance variable:", "words": [{"w": "The", "b": [0.1429, 0.3019, 0.1757, 0.3233]}, {"w": "labels", "b": [0.1804, 0.3019, 0.2272, 0.3233]}, {"w": "of", "b": [0.2319, 0.3019, 0.2487, 0.3233]}, {"w": "all", "b": [0.2534, 0.3019, 0.2731, 0.3233]}, {"w": "the", "b": [0.2779, 0.3019, 0.3042, 0.3233]}, {"w": "instances", "b": [0.3089, 0.3019, 0.3858, 0.3233]}, {"w": "are", "b": [0.3905, 0.3019, 0.4162, 0.3233]}, {"w": "now", "b": [0.4209, 0.3019, 0.4572, 0.3233]}, {"w": "available", "b": [0.462, 0.3019, 0.5342, 0.3233]}, {"w": "in", "b": [0.539, 0.3019, 0.5559, 0.3233]}, {"w": "the", "b": [0.5607, 0.3019, 0.587, 0.3233]}, {"w": "labels_", "b": [0.5917, 0.3051, 0.661, 0.3201]}, {"w": "instance", "b": [0.6657, 0.3019, 0.7349, 0.3233]}, {"w": "variable:", "b": [0.7396, 0.3019, 0.8104, 0.3233]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> dbscan.labels_ array([ 0, 2, -1, -1, 1, 0, 0, 0, ..., 3, 2, 3, 3, 4, 2, 6, 3])", "words": [{"w": ">>>", "b": [0.1766, 0.3338, 0.2019, 0.3467]}, {"w": "dbscan.labels_", "b": [0.2103, 0.3338, 0.3284, 0.3467]}, {"w": "array([", "b": [0.1766, 0.3493, 0.2356, 0.3621]}, {"w": "0,", "b": [0.244, 0.3493, 0.2609, 0.3621]}, {"w": "2,", "b": [0.2778, 0.3493, 0.2946, 0.3621]}, {"w": "-1,", "b": [0.3031, 0.3493, 0.3284, 0.3621]}, {"w": "-1,", "b": [0.3368, 0.3493, 0.3621, 0.3621]}, {"w": "1,", "b": [0.379, 0.3493, 0.3958, 0.3621]}, {"w": "0,", "b": [0.4127, 0.3493, 0.4296, 0.3621]}, {"w": "0,", "b": [0.4464, 0.3493, 0.4633, 0.3621]}, {"w": "0,", "b": [0.4802, 0.3493, 0.497, 0.3621]}, {"w": "...,", "b": [0.5055, 0.3493, 0.5392, 0.3621]}, {"w": "3,", "b": [0.556, 0.3493, 0.5729, 0.3621]}, {"w": "2,", "b": [0.5898, 0.3493, 0.6066, 0.3621]}, {"w": "3,", "b": [0.6235, 0.3493, 0.6404, 0.3621]}, {"w": "3,", "b": [0.6572, 0.3493, 0.6741, 0.3621]}, {"w": "4,", "b": [0.691, 0.3493, 0.7078, 0.3621]}, {"w": "2,", "b": [0.7247, 0.3493, 0.7416, 0.3621]}, {"w": "6,", "b": [0.7584, 0.3493, 0.7753, 0.3621]}, {"w": "3])", "b": [0.7922, 0.3493, 0.8175, 0.3621]}]}, {"id": "b_6", "type": "paragraph", "text": "Notice that some instances have a cluster index equal to -1: this means that they are considered as anomalies by the algorithm. The indices of the core instances are avail‐ able in the core_sample_indices_ instance variable, and the core instances them‐ selves are available in the components_ instance variable:", "words": [{"w": "Notice", "b": [0.1429, 0.3699, 0.198, 0.3913]}, {"w": "that", "b": [0.2042, 0.3699, 0.2368, 0.3913]}, {"w": "some", "b": [0.2429, 0.3699, 0.2871, 0.3913]}, {"w": "instances", "b": [0.2933, 0.3699, 0.3701, 0.3913]}, {"w": "have", "b": [0.3763, 0.3699, 0.4147, 0.3913]}, {"w": "a", "b": [0.4208, 0.3699, 0.43, 0.3913]}, {"w": "cluster", "b": [0.4362, 0.3699, 0.4919, 0.3913]}, {"w": "index", "b": [0.498, 0.3699, 0.5447, 0.3913]}, {"w": "equal", "b": [0.5509, 0.3699, 0.5958, 0.3913]}, {"w": "to", "b": [0.602, 0.3699, 0.619, 0.3913]}, {"w": "-1:", "b": [0.6251, 0.3699, 0.6473, 0.3913]}, {"w": "this", "b": [0.6535, 0.3699, 0.6842, 0.3913]}, {"w": "means", "b": [0.6903, 0.3699, 0.7444, 0.3913]}, {"w": "that", "b": [0.7506, 0.3699, 0.7832, 0.3913]}, {"w": "they", "b": [0.7894, 0.3699, 0.8252, 0.3913]}, {"w": "are", "b": [0.8314, 0.3699, 0.8571, 0.3913]}, {"w": "considered", "b": [0.1428, 0.3889, 0.2343, 0.4104]}, {"w": "as", "b": [0.2396, 0.3889, 0.2564, 0.4104]}, {"w": "anomalies", "b": [0.2616, 0.3889, 0.3464, 0.4104]}, {"w": "by", "b": [0.3516, 0.3889, 0.3717, 0.4104]}, {"w": "the", "b": [0.377, 0.3889, 0.4033, 0.4104]}, {"w": "algorithm.", "b": [0.4086, 0.3889, 0.496, 0.4104]}, {"w": "The", "b": [0.5012, 0.3889, 0.534, 0.4104]}, {"w": "indices", "b": [0.5393, 0.3889, 0.5981, 0.4104]}, {"w": "of", "b": [0.6034, 0.3889, 0.6202, 0.4104]}, {"w": "the", "b": [0.6254, 0.3889, 0.6518, 0.4104]}, {"w": "core", "b": [0.657, 0.3889, 0.693, 0.4104]}, {"w": "instances", "b": [0.6983, 0.3889, 0.7751, 0.4104]}, {"w": "are", "b": [0.7803, 0.3889, 0.8061, 0.4104]}, {"w": "avail‐", "b": [0.8113, 0.3889, 0.8571, 0.4104]}, {"w": "able", "b": [0.1429, 0.4089, 0.1767, 0.4303]}, {"w": "in", "b": [0.1845, 0.4089, 0.2015, 0.4303]}, {"w": "the", "b": [0.2092, 0.4089, 0.2356, 0.4303]}, {"w": "core_sample_indices_", "b": [0.2434, 0.4121, 0.4413, 0.4271]}, {"w": "instance", "b": [0.4491, 0.4089, 0.5182, 0.4303]}, {"w": "variable,", "b": [0.526, 0.4089, 0.5967, 0.4303]}, {"w": "and", "b": [0.6045, 0.4089, 0.636, 0.4303]}, {"w": "the", "b": [0.6438, 0.4089, 0.6702, 0.4303]}, {"w": "core", "b": [0.6779, 0.4089, 0.714, 0.4303]}, {"w": "instances", "b": [0.7217, 0.4089, 0.7986, 0.4303]}, {"w": "them‐", "b": [0.8063, 0.4089, 0.8571, 0.4303]}, {"w": "selves", "b": [0.1429, 0.4288, 0.1908, 0.4502]}, {"w": "are", "b": [0.1955, 0.4288, 0.2212, 0.4502]}, {"w": "available", "b": [0.226, 0.4288, 0.2982, 0.4502]}, {"w": "in", "b": [0.303, 0.4288, 0.3199, 0.4502]}, {"w": "the", "b": [0.3247, 0.4288, 0.351, 0.4502]}, {"w": "components_", "b": [0.3557, 0.432, 0.4646, 0.4471]}, {"w": "instance", "b": [0.4693, 0.4288, 0.5385, 0.4502]}, {"w": "variable:", "b": [0.5432, 0.4288, 0.6139, 0.4502]}]}, {"id": "b_7", "type": "paragraph", "text": ">>> len(dbscan.core_sample_indices_) 808 >>> dbscan.core_sample_indices_ array([ 0, 4, 5, 6, 7, 8, 10, 11, ..., 992, 993, 995, 997, 998, 999]) >>> dbscan.components_ array([[-0.02137124, 0.40618608], [-0.84192557, 0.53058695], ... [-0.94355873, 0.3278936 ], [ 0.79419406, 0.60777171]])", "words": [{"w": ">>>", "b": [0.1766, 0.4608, 0.2019, 0.4737]}, {"w": "len(dbscan.core_sample_indices_)", "b": [0.2103, 0.4608, 0.4802, 0.4737]}, {"w": "808", "b": [0.1766, 0.4762, 0.2019, 0.4891]}, {"w": ">>>", "b": [0.1766, 0.4916, 0.2019, 0.5045]}, {"w": "dbscan.core_sample_indices_", "b": [0.2103, 0.4916, 0.438, 0.5045]}, {"w": "array([", "b": [0.1766, 0.5071, 0.2356, 0.5199]}, {"w": "0,", "b": [0.2441, 0.5071, 0.2609, 0.5199]}, {"w": "4,", "b": [0.2778, 0.5071, 0.2947, 0.5199]}, {"w": "5,", "b": [0.3115, 0.5071, 0.3284, 0.5199]}, {"w": "6,", "b": [0.3452, 0.5071, 0.3621, 0.5199]}, {"w": "7,", "b": [0.379, 0.5071, 0.3958, 0.5199]}, {"w": "8,", "b": [0.4127, 0.5071, 0.4296, 0.5199]}, {"w": "10,", "b": [0.438, 0.5071, 0.4633, 0.5199]}, {"w": "11,", "b": [0.4717, 0.5071, 0.497, 0.5199]}, {"w": "...,", "b": [0.5055, 0.5071, 0.5392, 0.5199]}, {"w": "992,", "b": [0.5476, 0.5071, 0.5814, 0.5199]}, {"w": "993,", "b": [0.5898, 0.5071, 0.6235, 0.5199]}, {"w": "995,", "b": [0.632, 0.5071, 0.6657, 0.5199]}, {"w": "997,", "b": [0.6741, 0.5071, 0.7078, 0.5199]}, {"w": "998,", "b": [0.7163, 0.5071, 0.75, 0.5199]}, {"w": "999])", "b": [0.7584, 0.5071, 0.8006, 0.5199]}, {"w": ">>>", "b": [0.1766, 0.5225, 0.2019, 0.5353]}, {"w": "dbscan.components_", "b": [0.2103, 0.5225, 0.3621, 0.5353]}, {"w": "array([[-0.02137124,", "b": [0.1766, 0.5379, 0.3452, 0.5508]}, {"w": "0.40618608],", "b": [0.3621, 0.5379, 0.4633, 0.5508]}, {"w": "[-0.84192557,", "b": [0.2356, 0.5533, 0.3452, 0.5662]}, {"w": "0.53058695],", "b": [0.3621, 0.5533, 0.4633, 0.5662]}, {"w": "...", "b": [0.3284, 0.5687, 0.3537, 0.5816]}, {"w": "[-0.94355873,", "b": [0.2356, 0.5842, 0.3452, 0.597]}, {"w": "0.3278936", "b": [0.3621, 0.5842, 0.438, 0.597]}, {"w": "],", "b": [0.4464, 0.5842, 0.4633, 0.597]}, {"w": "[", "b": [0.2356, 0.5996, 0.2441, 0.6124]}, {"w": "0.79419406,", "b": [0.2525, 0.5996, 0.3452, 0.6124]}, {"w": "0.60777171]])", "b": [0.3621, 0.5996, 0.4717, 0.6124]}]}, {"id": "b_8", "type": "paragraph", "text": "This clustering is represented in the left plot of Figure 9-14. As you can see, it identi‐ fied quite a lot of anomalies, plus 7 different clusters. How disappointing! Fortunately, if we widen each instance’s neighborhood by increasing eps to 0.2, we get the cluster‐ ing on the right, which looks perfect. Let’s continue with this model.", "words": [{"w": "This", "b": [0.1429, 0.6202, 0.1801, 0.6416]}, {"w": "clustering", "b": [0.1855, 0.6202, 0.268, 0.6416]}, {"w": "is", "b": [0.2734, 0.6202, 0.2866, 0.6416]}, {"w": "represented", "b": [0.2921, 0.6202, 0.3899, 0.6416]}, {"w": "in", "b": [0.3953, 0.6202, 0.4123, 0.6416]}, {"w": "the", "b": [0.4177, 0.6202, 0.4441, 0.6416]}, {"w": "left", "b": [0.4495, 0.6202, 0.4761, 0.6416]}, {"w": "plot", "b": [0.4816, 0.6202, 0.5148, 0.6416]}, {"w": "of", "b": [0.5202, 0.6202, 0.537, 0.6416]}, {"w": "Figure", "b": [0.5424, 0.6202, 0.5964, 0.6416]}, {"w": "9-14.", "b": [0.6019, 0.6202, 0.644, 0.6416]}, {"w": "As", "b": [0.6495, 0.6202, 0.6715, 0.6416]}, {"w": "you", "b": [0.6769, 0.6202, 0.7082, 0.6416]}, {"w": "can", "b": [0.7136, 0.6202, 0.743, 0.6416]}, {"w": "see,", "b": [0.7484, 0.6202, 0.7785, 0.6416]}, {"w": "it", "b": [0.784, 0.6202, 0.7959, 0.6416]}, {"w": "identi‐", "b": [0.8014, 0.6202, 0.8571, 0.6416]}, {"w": "fied", "b": [0.1429, 0.6393, 0.1745, 0.6607]}, {"w": "quite", "b": [0.1792, 0.6393, 0.2217, 0.6607]}, {"w": "a", "b": [0.2264, 0.6393, 0.2356, 0.6607]}, {"w": "lot", "b": [0.2403, 0.6393, 0.2625, 0.6607]}, {"w": "of", "b": [0.2673, 0.6393, 0.2841, 0.6607]}, {"w": "anomalies,", "b": [0.2888, 0.6393, 0.3783, 0.6607]}, {"w": "plus", "b": [0.383, 0.6393, 0.4179, 0.6607]}, {"w": "7", "b": [0.4226, 0.6393, 0.4326, 0.6607]}, {"w": "different", "b": [0.4374, 0.6393, 0.5091, 0.6607]}, {"w": "clusters.", "b": [0.5138, 0.6393, 0.5819, 0.6607]}, {"w": "How", "b": [0.5866, 0.6393, 0.627, 0.6607]}, {"w": "disappointing!", "b": [0.6317, 0.6393, 0.7526, 0.6607]}, {"w": "Fortunately,", "b": [0.7573, 0.6393, 0.8571, 0.6607]}, {"w": "if", "b": [0.1429, 0.6592, 0.1546, 0.6806]}, {"w": "we", "b": [0.1598, 0.6592, 0.183, 0.6806]}, {"w": "widen", "b": [0.1882, 0.6592, 0.2393, 0.6806]}, {"w": "each", "b": [0.2445, 0.6592, 0.2825, 0.6806]}, {"w": "instance’s", "b": [0.2877, 0.6592, 0.366, 0.6806]}, {"w": "neighborhood", "b": [0.3712, 0.6592, 0.4903, 0.6806]}, {"w": "by", "b": [0.4955, 0.6592, 0.5156, 0.6806]}, {"w": "increasing", "b": [0.5209, 0.6592, 0.6068, 0.6806]}, {"w": "eps", "b": [0.612, 0.6624, 0.6417, 0.6775]}, {"w": "to", "b": [0.6469, 0.6592, 0.6639, 0.6806]}, {"w": "0.2,", "b": [0.6691, 0.6592, 0.6986, 0.6806]}, {"w": "we", "b": [0.7039, 0.6592, 0.727, 0.6806]}, {"w": "get", "b": [0.7322, 0.6592, 0.7572, 0.6806]}, {"w": "the", "b": [0.7624, 0.6592, 0.7888, 0.6806]}, {"w": "cluster‐", "b": [0.794, 0.6592, 0.8571, 0.6806]}, {"w": "ing", "b": [0.1429, 0.6783, 0.1696, 0.6997]}, {"w": "on", "b": [0.1743, 0.6783, 0.1963, 0.6997]}, {"w": "the", "b": [0.2011, 0.6783, 0.2274, 0.6997]}, {"w": "right,", "b": [0.2321, 0.6783, 0.277, 0.6997]}, {"w": "which", "b": [0.2818, 0.6783, 0.3327, 0.6997]}, {"w": "looks", "b": [0.3374, 0.6783, 0.3819, 0.6997]}, {"w": "perfect.", "b": [0.3866, 0.6783, 0.4491, 0.6997]}, {"w": "Let’s", "b": [0.4538, 0.6783, 0.49, 0.6997]}, {"w": "continue", "b": [0.4947, 0.6783, 0.568, 0.6997]}, {"w": "with", "b": [0.5727, 0.6783, 0.6101, 0.6997]}, {"w": "this", "b": [0.6148, 0.6783, 0.6455, 0.6997]}, {"w": "model.", "b": [0.6502, 0.6783, 0.7078, 0.6997]}]}, {"id": "b_9", "type": "equation", "text": "Figure 9-14. DBSCAN clustering using two different neighborhood radiuses", "words": [{"w": "Figure", "b": [0.1429, 0.8542, 0.1943, 0.8758]}, {"w": "9-14.", "b": [0.1991, 0.8542, 0.2407, 0.8758]}, {"w": "DBSCAN", "b": [0.2455, 0.8542, 0.3236, 0.8758]}, {"w": "clustering", "b": [0.3283, 0.8542, 0.4063, 0.8758]}, {"w": "using", "b": [0.4111, 0.8542, 0.454, 0.8758]}, {"w": "two", "b": [0.4588, 0.8542, 0.4889, 0.8758]}, {"w": "different", "b": [0.4936, 0.8542, 0.5627, 0.8758]}, {"w": "neighborhood", "b": [0.5675, 0.8542, 0.6788, 0.8758]}, {"w": "radiuses", "b": [0.6836, 0.8542, 0.7501, 0.8758]}]}, {"id": "b_10", "type": "paragraph", "text": "Clustering | 257", "words": [{"w": "Clustering", "b": [0.736, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "257", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 284, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Somewhat surprisingly, the DBSCAN class does not have a predict() method, although it has a fit_predict() method. In other words, it cannot predict which cluster a new instance belongs to. The rationale for this decision is that several classi‐ fication algorithms could make sense here, and it is easy enough to train one, for example a KNeighborsClassifier:", "words": [{"w": "Somewhat", "b": [0.1429, 0.08, 0.2298, 0.1014]}, {"w": "surprisingly,", "b": [0.2403, 0.08, 0.3434, 0.1014]}, {"w": "the", "b": [0.354, 0.08, 0.3803, 0.1014]}, {"w": "DBSCAN", "b": [0.3908, 0.08, 0.472, 0.1014]}, {"w": "class", "b": [0.4825, 0.08, 0.521, 0.1014]}, {"w": "does", "b": [0.5316, 0.08, 0.5697, 0.1014]}, {"w": "not", "b": [0.5802, 0.08, 0.6086, 0.1014]}, {"w": "have", "b": [0.6192, 0.08, 0.6576, 0.1014]}, {"w": "a", "b": [0.6681, 0.08, 0.6772, 0.1014]}, {"w": "predict()", "b": [0.6878, 0.0831, 0.7768, 0.0982]}, {"w": "method,", "b": [0.7874, 0.08, 0.8571, 0.1014]}, {"w": "although", "b": [0.1429, 0.0999, 0.2173, 0.1213]}, {"w": "it", "b": [0.2251, 0.0999, 0.237, 0.1213]}, {"w": "has", "b": [0.2448, 0.0999, 0.2727, 0.1213]}, {"w": "a", "b": [0.2805, 0.0999, 0.2897, 0.1213]}, {"w": "fit_predict()", "b": [0.2974, 0.1031, 0.4261, 0.1182]}, {"w": "method.", "b": [0.4339, 0.0999, 0.5036, 0.1213]}, {"w": "In", "b": [0.5114, 0.0999, 0.5299, 0.1213]}, {"w": "other", "b": [0.5377, 0.0999, 0.5824, 0.1213]}, {"w": "words,", "b": [0.5902, 0.0999, 0.6462, 0.1213]}, {"w": "it", "b": [0.654, 0.0999, 0.6659, 0.1213]}, {"w": "cannot", "b": [0.6737, 0.0999, 0.7314, 0.1213]}, {"w": "predict", "b": [0.7392, 0.0999, 0.7984, 0.1213]}, {"w": "which", "b": [0.8062, 0.0999, 0.8571, 0.1213]}, {"w": "cluster", "b": [0.1429, 0.119, 0.1986, 0.1404]}, {"w": "a", "b": [0.2039, 0.119, 0.2131, 0.1404]}, {"w": "new", "b": [0.2184, 0.119, 0.2529, 0.1404]}, {"w": "instance", "b": [0.2583, 0.119, 0.3275, 0.1404]}, {"w": "belongs", "b": [0.3328, 0.119, 0.3969, 0.1404]}, {"w": "to.", "b": [0.4023, 0.119, 0.4234, 0.1404]}, {"w": "The", "b": [0.4287, 0.119, 0.4615, 0.1404]}, {"w": "rationale", "b": [0.4669, 0.119, 0.5406, 0.1404]}, {"w": "for", "b": [0.5459, 0.119, 0.5704, 0.1404]}, {"w": "this", "b": [0.5758, 0.119, 0.6065, 0.1404]}, {"w": "decision", "b": [0.6118, 0.119, 0.6813, 0.1404]}, {"w": "is", "b": [0.6867, 0.119, 0.6999, 0.1404]}, {"w": "that", "b": [0.7052, 0.119, 0.7378, 0.1404]}, {"w": "several", "b": [0.7431, 0.119, 0.8003, 0.1404]}, {"w": "classi‐", "b": [0.8056, 0.119, 0.8572, 0.1404]}, {"w": "fication", "b": [0.1429, 0.138, 0.2061, 0.1594]}, {"w": "algorithms", "b": [0.214, 0.138, 0.3043, 0.1594]}, {"w": "could", "b": [0.3122, 0.138, 0.359, 0.1594]}, {"w": "make", "b": [0.3669, 0.138, 0.4123, 0.1594]}, {"w": "sense", "b": [0.4202, 0.138, 0.4646, 0.1594]}, {"w": "here,", "b": [0.4726, 0.138, 0.5139, 0.1594]}, {"w": "and", "b": [0.5218, 0.138, 0.5533, 0.1594]}, {"w": "it", "b": [0.5612, 0.138, 0.5732, 0.1594]}, {"w": "is", "b": [0.5811, 0.138, 0.5943, 0.1594]}, {"w": "easy", "b": [0.6022, 0.138, 0.6374, 0.1594]}, {"w": "enough", "b": [0.6453, 0.138, 0.7082, 0.1594]}, {"w": "to", "b": [0.7161, 0.138, 0.7331, 0.1594]}, {"w": "train", "b": [0.741, 0.138, 0.7812, 0.1594]}, {"w": "one,", "b": [0.7891, 0.138, 0.8247, 0.1594]}, {"w": "for", "b": [0.8326, 0.138, 0.8571, 0.1594]}, {"w": "example", "b": [0.1429, 0.1579, 0.2124, 0.1794]}, {"w": "a", "b": [0.2171, 0.1579, 0.2263, 0.1794]}, {"w": "KNeighborsClassifier:", "b": [0.231, 0.1579, 0.4337, 0.1794]}]}, {"id": "b_1", "type": "paragraph", "text": "from sklearn.neighbors import KNeighborsClassifier", "words": [{"w": "from", "b": [0.1766, 0.1899, 0.2103, 0.2028]}, {"w": "sklearn.neighbors", "b": [0.2188, 0.1899, 0.3621, 0.2028]}, {"w": "import", "b": [0.3705, 0.1899, 0.4211, 0.2028]}, {"w": "KNeighborsClassifier", "b": [0.4296, 0.1899, 0.5982, 0.2028]}]}, {"id": "b_2", "type": "paragraph", "text": "knn = KNeighborsClassifier(n_neighbors=50) knn.fit(dbscan.components_, dbscan.labels_[dbscan.core_sample_indices_])", "words": [{"w": "knn", "b": [0.1766, 0.2208, 0.2019, 0.2336]}, {"w": "=", "b": [0.2103, 0.2208, 0.2188, 0.2336]}, {"w": "KNeighborsClassifier(n_neighbors=50)", "b": [0.2272, 0.2208, 0.5308, 0.2336]}, {"w": "knn.fit(dbscan.components_,", "b": [0.1766, 0.2362, 0.4043, 0.249]}, {"w": "dbscan.labels_[dbscan.core_sample_indices_])", "b": [0.4127, 0.2362, 0.7837, 0.249]}]}, {"id": "b_3", "type": "paragraph", "text": "Now, given a few new instances, we can predict which cluster they most likely belong to, and even estimate a probability for each cluster. Note that we only trained them on the core instances, but we could also have chosen to train them on all the instances, or all but the anomalies: this choice depends on the final task.", "words": [{"w": "Now,", "b": [0.1429, 0.2568, 0.1859, 0.2782]}, {"w": "given", "b": [0.1912, 0.2568, 0.2365, 0.2782]}, {"w": "a", "b": [0.2418, 0.2568, 0.2509, 0.2782]}, {"w": "few", "b": [0.2562, 0.2568, 0.2855, 0.2782]}, {"w": "new", "b": [0.2908, 0.2568, 0.3253, 0.2782]}, {"w": "instances,", "b": [0.3306, 0.2568, 0.4122, 0.2782]}, {"w": "we", "b": [0.4175, 0.2568, 0.4406, 0.2782]}, {"w": "can", "b": [0.4459, 0.2568, 0.4753, 0.2782]}, {"w": "predict", "b": [0.4805, 0.2568, 0.5398, 0.2782]}, {"w": "which", "b": [0.5451, 0.2568, 0.596, 0.2782]}, {"w": "cluster", "b": [0.6013, 0.2568, 0.657, 0.2782]}, {"w": "they", "b": [0.6623, 0.2568, 0.6982, 0.2782]}, {"w": "most", "b": [0.7035, 0.2568, 0.7452, 0.2782]}, {"w": "likely", "b": [0.7505, 0.2568, 0.7954, 0.2782]}, {"w": "belong", "b": [0.8007, 0.2568, 0.8571, 0.2782]}, {"w": "to,", "b": [0.1429, 0.2759, 0.164, 0.2973]}, {"w": "and", "b": [0.1688, 0.2759, 0.2003, 0.2973]}, {"w": "even", "b": [0.2051, 0.2759, 0.2439, 0.2973]}, {"w": "estimate", "b": [0.2486, 0.2759, 0.3181, 0.2973]}, {"w": "a", "b": [0.3229, 0.2759, 0.332, 0.2973]}, {"w": "probability", "b": [0.3368, 0.2759, 0.4288, 0.2973]}, {"w": "for", "b": [0.4336, 0.2759, 0.4581, 0.2973]}, {"w": "each", "b": [0.4629, 0.2759, 0.5008, 0.2973]}, {"w": "cluster.", "b": [0.5056, 0.2759, 0.5648, 0.2973]}, {"w": "Note", "b": [0.5696, 0.2759, 0.6104, 0.2973]}, {"w": "that", "b": [0.6151, 0.2759, 0.6477, 0.2973]}, {"w": "we", "b": [0.6525, 0.2759, 0.6756, 0.2973]}, {"w": "only", "b": [0.6804, 0.2759, 0.7173, 0.2973]}, {"w": "trained", "b": [0.7221, 0.2759, 0.7821, 0.2973]}, {"w": "them", "b": [0.7869, 0.2759, 0.8303, 0.2973]}, {"w": "on", "b": [0.8351, 0.2759, 0.8571, 0.2973]}, {"w": "the", "b": [0.1428, 0.2949, 0.1692, 0.3163]}, {"w": "core", "b": [0.1754, 0.2949, 0.2114, 0.3163]}, {"w": "instances,", "b": [0.2176, 0.2949, 0.2991, 0.3163]}, {"w": "but", "b": [0.3053, 0.2949, 0.3333, 0.3163]}, {"w": "we", "b": [0.3395, 0.2949, 0.3626, 0.3163]}, {"w": "could", "b": [0.3688, 0.2949, 0.4156, 0.3163]}, {"w": "also", "b": [0.4218, 0.2949, 0.4545, 0.3163]}, {"w": "have", "b": [0.4606, 0.2949, 0.499, 0.3163]}, {"w": "chosen", "b": [0.5052, 0.2949, 0.5637, 0.3163]}, {"w": "to", "b": [0.5698, 0.2949, 0.5868, 0.3163]}, {"w": "train", "b": [0.593, 0.2949, 0.6332, 0.3163]}, {"w": "them", "b": [0.6394, 0.2949, 0.6828, 0.3163]}, {"w": "on", "b": [0.689, 0.2949, 0.711, 0.3163]}, {"w": "all", "b": [0.7172, 0.2949, 0.7369, 0.3163]}, {"w": "the", "b": [0.743, 0.2949, 0.7694, 0.3163]}, {"w": "instances,", "b": [0.7756, 0.2949, 0.8571, 0.3163]}, {"w": "or", "b": [0.1429, 0.314, 0.1612, 0.3354]}, {"w": "all", "b": [0.1659, 0.314, 0.1856, 0.3354]}, {"w": "but", "b": [0.1904, 0.314, 0.2184, 0.3354]}, {"w": "the", "b": [0.2231, 0.314, 0.2494, 0.3354]}, {"w": "anomalies:", "b": [0.2542, 0.314, 0.3436, 0.3354]}, {"w": "this", "b": [0.3484, 0.314, 0.3791, 0.3354]}, {"w": "choice", "b": [0.3838, 0.314, 0.4376, 0.3354]}, {"w": "depends", "b": [0.4423, 0.314, 0.512, 0.3354]}, {"w": "on", "b": [0.5167, 0.314, 0.5388, 0.3354]}, {"w": "the", "b": [0.5435, 0.314, 0.5698, 0.3354]}, {"w": "final", "b": [0.5746, 0.314, 0.6121, 0.3354]}, {"w": "task.", "b": [0.6168, 0.314, 0.6551, 0.3354]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> X_new = np.array([[-0.5, 0], [0, 0.5], [1, -0.1], [2, 1]]) >>> knn.predict(X_new) array([1, 0, 1, 0]) >>> knn.predict_proba(X_new) array([[0.18, 0.82], [1. , 0. ], [0.12, 0.88], [1. , 0. ]])", "words": [{"w": ">>>", "b": [0.1766, 0.3459, 0.2019, 0.3588]}, {"w": "X_new", "b": [0.2103, 0.3459, 0.2525, 0.3588]}, {"w": "=", "b": [0.2609, 0.3459, 0.2694, 0.3588]}, {"w": "np.array([[-0.5,", "b": [0.2778, 0.3459, 0.4127, 0.3588]}, {"w": "0],", "b": [0.4211, 0.3459, 0.4464, 0.3588]}, {"w": "[0,", "b": [0.4549, 0.3459, 0.4802, 0.3588]}, {"w": "0.5],", "b": [0.4886, 0.3459, 0.5308, 0.3588]}, {"w": "[1,", "b": [0.5392, 0.3459, 0.5645, 0.3588]}, {"w": "-0.1],", "b": [0.5729, 0.3459, 0.6235, 0.3588]}, {"w": "[2,", "b": [0.632, 0.3459, 0.6572, 0.3588]}, {"w": "1]])", "b": [0.6657, 0.3459, 0.6994, 0.3588]}, {"w": ">>>", "b": [0.1766, 0.3613, 0.2019, 0.3742]}, {"w": "knn.predict(X_new)", "b": [0.2103, 0.3613, 0.3621, 0.3742]}, {"w": "array([1,", "b": [0.1766, 0.3768, 0.2525, 0.3896]}, {"w": "0,", "b": [0.2609, 0.3768, 0.2778, 0.3896]}, {"w": "1,", "b": [0.2862, 0.3768, 0.3031, 0.3896]}, {"w": "0])", "b": [0.3115, 0.3768, 0.3368, 0.3896]}, {"w": ">>>", "b": [0.1766, 0.3922, 0.2019, 0.405]}, {"w": "knn.predict_proba(X_new)", "b": [0.2103, 0.3922, 0.4127, 0.405]}, {"w": "array([[0.18,", "b": [0.1766, 0.4076, 0.2862, 0.4205]}, {"w": "0.82],", "b": [0.2946, 0.4076, 0.3452, 0.4205]}, {"w": "[1.", "b": [0.2356, 0.423, 0.2609, 0.4359]}, {"w": ",", "b": [0.2778, 0.423, 0.2862, 0.4359]}, {"w": "0.", "b": [0.2946, 0.423, 0.3115, 0.4359]}, {"w": "],", "b": [0.3284, 0.423, 0.3452, 0.4359]}, {"w": "[0.12,", "b": [0.2356, 0.4384, 0.2862, 0.4513]}, {"w": "0.88],", "b": [0.2946, 0.4384, 0.3452, 0.4513]}, {"w": "[1.", "b": [0.2356, 0.4539, 0.2609, 0.4667]}, {"w": ",", "b": [0.2778, 0.4539, 0.2862, 0.4667]}, {"w": "0.", "b": [0.2946, 0.4539, 0.3115, 0.4667]}, {"w": "]])", "b": [0.3284, 0.4539, 0.3537, 0.4667]}]}, {"id": "b_5", "type": "paragraph", "text": "The decision boundary is represented on Figure 9-15 (the crosses represent the 4 instances in X_new). Notice that since there is no anomaly in the KNN’s training set, the classifier always chooses a cluster, even when that cluster is far away. However, it is fairly straightforward to introduce a maximum distance, in which case the two instances that are far away from both clusters are classified as anomalies. To do this, we can use the kneighbors() method of the KNeighborsClassifier: given a set of instances, it returns the distances and the indices of the k nearest neighbors in the training set (two matrices, each with k columns):", "words": [{"w": "The", "b": [0.1429, 0.4745, 0.1757, 0.4959]}, {"w": "decision", "b": [0.1839, 0.4745, 0.2534, 0.4959]}, {"w": "boundary", "b": [0.2617, 0.4745, 0.3434, 0.4959]}, {"w": "is", "b": [0.3517, 0.4745, 0.3649, 0.4959]}, {"w": "represented", "b": [0.3731, 0.4745, 0.4709, 0.4959]}, {"w": "on", "b": [0.4792, 0.4745, 0.5012, 0.4959]}, {"w": "Figure", "b": [0.5095, 0.4745, 0.5635, 0.4959]}, {"w": "9-15", "b": [0.5717, 0.4745, 0.6091, 0.4959]}, {"w": "(the", "b": [0.6174, 0.4745, 0.6509, 0.4959]}, {"w": "crosses", "b": [0.6592, 0.4745, 0.7181, 0.4959]}, {"w": "represent", "b": [0.7264, 0.4745, 0.8043, 0.4959]}, {"w": "the", "b": [0.8126, 0.4745, 0.8389, 0.4959]}, {"w": "4", "b": [0.8472, 0.4745, 0.8572, 0.4959]}, {"w": "instances", "b": [0.1429, 0.4944, 0.2197, 0.5159]}, {"w": "in", "b": [0.2258, 0.4944, 0.2428, 0.5159]}, {"w": "X_new).", "b": [0.2489, 0.4944, 0.3103, 0.5159]}, {"w": "Notice", "b": [0.3164, 0.4944, 0.3716, 0.5159]}, {"w": "that", "b": [0.3777, 0.4944, 0.4103, 0.5159]}, {"w": "since", "b": [0.4164, 0.4944, 0.4587, 0.5159]}, {"w": "there", "b": [0.4648, 0.4944, 0.5077, 0.5159]}, {"w": "is", "b": [0.5138, 0.4944, 0.527, 0.5159]}, {"w": "no", "b": [0.5331, 0.4944, 0.5552, 0.5159]}, {"w": "anomaly", "b": [0.5613, 0.4944, 0.6335, 0.5159]}, {"w": "in", "b": [0.6396, 0.4944, 0.6566, 0.5159]}, {"w": "the", "b": [0.6627, 0.4944, 0.689, 0.5159]}, {"w": "KNN’s", "b": [0.6951, 0.4944, 0.7504, 0.5159]}, {"w": "training", "b": [0.7565, 0.4944, 0.8234, 0.5159]}, {"w": "set,", "b": [0.8295, 0.4944, 0.8571, 0.5159]}, {"w": "the", "b": [0.1429, 0.5135, 0.1692, 0.5349]}, {"w": "classifier", "b": [0.1751, 0.5135, 0.2475, 0.5349]}, {"w": "always", "b": [0.2535, 0.5135, 0.3081, 0.5349]}, {"w": "chooses", "b": [0.314, 0.5135, 0.3794, 0.5349]}, {"w": "a", "b": [0.3853, 0.5135, 0.3944, 0.5349]}, {"w": "cluster,", "b": [0.4004, 0.5135, 0.4595, 0.5349]}, {"w": "even", "b": [0.4654, 0.5135, 0.5042, 0.5349]}, {"w": "when", "b": [0.5101, 0.5135, 0.5557, 0.5349]}, {"w": "that", "b": [0.5617, 0.5135, 0.5942, 0.5349]}, {"w": "cluster", "b": [0.6002, 0.5135, 0.6559, 0.5349]}, {"w": "is", "b": [0.6618, 0.5135, 0.675, 0.5349]}, {"w": "far", "b": [0.681, 0.5135, 0.704, 0.5349]}, {"w": "away.", "b": [0.7099, 0.5135, 0.7545, 0.5349]}, {"w": "However,", "b": [0.7604, 0.5135, 0.8393, 0.5349]}, {"w": "it", "b": [0.8452, 0.5135, 0.8571, 0.5349]}, {"w": "is", "b": [0.1429, 0.5325, 0.1561, 0.5539]}, {"w": "fairly", "b": [0.1644, 0.5325, 0.2079, 0.5539]}, {"w": "straightforward", "b": [0.2162, 0.5325, 0.3468, 0.5539]}, {"w": "to", "b": [0.3551, 0.5325, 0.3721, 0.5539]}, {"w": "introduce", "b": [0.3804, 0.5325, 0.4614, 0.5539]}, {"w": "a", "b": [0.4698, 0.5325, 0.4789, 0.5539]}, {"w": "maximum", "b": [0.4873, 0.5325, 0.5737, 0.5539]}, {"w": "distance,", "b": [0.582, 0.5325, 0.6556, 0.5539]}, {"w": "in", "b": [0.6639, 0.5325, 0.6809, 0.5539]}, {"w": "which", "b": [0.6892, 0.5325, 0.7401, 0.5539]}, {"w": "case", "b": [0.7484, 0.5325, 0.7829, 0.5539]}, {"w": "the", "b": [0.7912, 0.5325, 0.8176, 0.5539]}, {"w": "two", "b": [0.8259, 0.5325, 0.8572, 0.5539]}, {"w": "instances", "b": [0.1429, 0.5516, 0.2197, 0.573]}, {"w": "that", "b": [0.2258, 0.5516, 0.2583, 0.573]}, {"w": "are", "b": [0.2644, 0.5516, 0.2901, 0.573]}, {"w": "far", "b": [0.2962, 0.5516, 0.3192, 0.573]}, {"w": "away", "b": [0.3253, 0.5516, 0.3667, 0.573]}, {"w": "from", "b": [0.3727, 0.5516, 0.4143, 0.573]}, {"w": "both", "b": [0.4204, 0.5516, 0.4591, 0.573]}, {"w": "clusters", "b": [0.4651, 0.5516, 0.5285, 0.573]}, {"w": "are", "b": [0.5346, 0.5516, 0.5603, 0.573]}, {"w": "classified", "b": [0.5663, 0.5516, 0.6421, 0.573]}, {"w": "as", "b": [0.6481, 0.5516, 0.6649, 0.573]}, {"w": "anomalies.", "b": [0.671, 0.5516, 0.7604, 0.573]}, {"w": "To", "b": [0.7665, 0.5516, 0.7879, 0.573]}, {"w": "do", "b": [0.794, 0.5516, 0.8156, 0.573]}, {"w": "this,", "b": [0.8217, 0.5516, 0.8571, 0.573]}, {"w": "we", "b": [0.1429, 0.5715, 0.166, 0.5929]}, {"w": "can", "b": [0.173, 0.5715, 0.2024, 0.5929]}, {"w": "use", "b": [0.2094, 0.5715, 0.237, 0.5929]}, {"w": "the", "b": [0.244, 0.5715, 0.2703, 0.5929]}, {"w": "kneighbors()", "b": [0.2773, 0.5747, 0.3961, 0.5898]}, {"w": "method", "b": [0.4031, 0.5715, 0.4681, 0.5929]}, {"w": "of", "b": [0.4752, 0.5715, 0.492, 0.5929]}, {"w": "the", "b": [0.499, 0.5715, 0.5253, 0.5929]}, {"w": "KNeighborsClassifier:", "b": [0.5323, 0.5715, 0.735, 0.5929]}, {"w": "given", "b": [0.742, 0.5715, 0.7873, 0.5929]}, {"w": "a", "b": [0.7943, 0.5715, 0.8034, 0.5929]}, {"w": "set", "b": [0.8105, 0.5715, 0.8333, 0.5929]}, {"w": "of", "b": [0.8404, 0.5715, 0.8571, 0.5929]}, {"w": "instances,", "b": [0.1429, 0.5906, 0.2244, 0.612]}, {"w": "it", "b": [0.2316, 0.5906, 0.2436, 0.612]}, {"w": "returns", "b": [0.2508, 0.5906, 0.3116, 0.612]}, {"w": "the", "b": [0.3188, 0.5906, 0.3451, 0.612]}, {"w": "distances", "b": [0.3523, 0.5906, 0.4288, 0.612]}, {"w": "and", "b": [0.436, 0.5906, 0.4675, 0.612]}, {"w": "the", "b": [0.4747, 0.5906, 0.5011, 0.612]}, {"w": "indices", "b": [0.5083, 0.5906, 0.5672, 0.612]}, {"w": "of", "b": [0.5744, 0.5906, 0.5912, 0.612]}, {"w": "the", "b": [0.5984, 0.5906, 0.6247, 0.612]}, {"w": "k", "b": [0.6319, 0.5904, 0.6417, 0.612]}, {"w": "nearest", "b": [0.6489, 0.5906, 0.7089, 0.612]}, {"w": "neighbors", "b": [0.7161, 0.5906, 0.7994, 0.612]}, {"w": "in", "b": [0.8066, 0.5906, 0.8236, 0.612]}, {"w": "the", "b": [0.8308, 0.5906, 0.8571, 0.612]}, {"w": "training", "b": [0.1429, 0.6096, 0.2098, 0.631]}, {"w": "set", "b": [0.2145, 0.6096, 0.2374, 0.631]}, {"w": "(two", "b": [0.2421, 0.6096, 0.2806, 0.631]}, {"w": "matrices,", "b": [0.2853, 0.6096, 0.3608, 0.631]}, {"w": "each", "b": [0.3656, 0.6096, 0.4035, 0.631]}, {"w": "with", "b": [0.4082, 0.6096, 0.4456, 0.631]}, {"w": "k", "b": [0.4503, 0.6094, 0.4601, 0.631]}, {"w": "columns):", "b": [0.4648, 0.6096, 0.5487, 0.631]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> y_dist, y_pred_idx = knn.kneighbors(X_new, n_neighbors=1) >>> y_pred = dbscan.labels_[dbscan.core_sample_indices_][y_pred_idx] >>> y_pred[y_dist > 0.2] = -1 >>> y_pred.ravel() array([-1, 0, 1, -1])", "words": [{"w": ">>>", "b": [0.1766, 0.6416, 0.2019, 0.6544]}, {"w": "y_dist,", "b": [0.2103, 0.6416, 0.2694, 0.6544]}, {"w": "y_pred_idx", "b": [0.2778, 0.6416, 0.3621, 0.6544]}, {"w": "=", "b": [0.3705, 0.6416, 0.379, 0.6544]}, {"w": "knn.kneighbors(X_new,", "b": [0.3874, 0.6416, 0.5645, 0.6544]}, {"w": "n_neighbors=1)", "b": [0.5729, 0.6416, 0.691, 0.6544]}, {"w": ">>>", "b": [0.1766, 0.657, 0.2019, 0.6699]}, {"w": "y_pred", "b": [0.2103, 0.657, 0.2609, 0.6699]}, {"w": "=", "b": [0.2694, 0.657, 0.2778, 0.6699]}, {"w": "dbscan.labels_[dbscan.core_sample_indices_][y_pred_idx]", "b": [0.2862, 0.657, 0.75, 0.6699]}, {"w": ">>>", "b": [0.1766, 0.6724, 0.2019, 0.6853]}, {"w": "y_pred[y_dist", "b": [0.2103, 0.6724, 0.32, 0.6853]}, {"w": ">", "b": [0.3284, 0.6724, 0.3368, 0.6853]}, {"w": "0.2]", "b": [0.3453, 0.6724, 0.379, 0.6853]}, {"w": "=", "b": [0.3874, 0.6724, 0.3958, 0.6853]}, {"w": "-1", "b": [0.4043, 0.6724, 0.4211, 0.6853]}, {"w": ">>>", "b": [0.1766, 0.6879, 0.2019, 0.7007]}, {"w": "y_pred.ravel()", "b": [0.2103, 0.6879, 0.3284, 0.7007]}, {"w": "array([-1,", "b": [0.1766, 0.7033, 0.2609, 0.7161]}, {"w": "0,", "b": [0.2778, 0.7033, 0.2947, 0.7161]}, {"w": "1,", "b": [0.3115, 0.7033, 0.3284, 0.7161]}, {"w": "-1])", "b": [0.3368, 0.7033, 0.3705, 0.7161]}]}, {"id": "b_7", "type": "paragraph", "text": "258 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "258", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 285, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 9-15. cluster_classification_diagram", "words": [{"w": "Figure", "b": [0.1429, 0.2774, 0.1943, 0.299]}, {"w": "9-15.", "b": [0.1991, 0.2774, 0.2407, 0.299]}, {"w": "cluster_classification_diagram", "b": [0.2455, 0.2774, 0.4947, 0.299]}]}, {"id": "b_1", "type": "paragraph", "text": "In short, DBSCAN is a very simple yet powerful algorithm, capable of identifying any number of clusters, of any shape, it is robust to outliers, and it has just two hyper‐ parameters (eps and min_samples). However, if the density varies significantly across the clusters, it can be impossible for it to capture all the clusters properly. Moreover, its computational complexity is roughly O(m log m), making it pretty close to linear with regards to the number of instances. However, Scikit-Learn’s implementation can require up to O(m2) memory if eps is large.", "words": [{"w": "In", "b": [0.1429, 0.3148, 0.1614, 0.3362]}, {"w": "short,", "b": [0.1664, 0.3148, 0.2146, 0.3362]}, {"w": "DBSCAN", "b": [0.2197, 0.3148, 0.3009, 0.3362]}, {"w": "is", "b": [0.3059, 0.3148, 0.3191, 0.3362]}, {"w": "a", "b": [0.3242, 0.3148, 0.3333, 0.3362]}, {"w": "very", "b": [0.3384, 0.3148, 0.3748, 0.3362]}, {"w": "simple", "b": [0.3798, 0.3148, 0.4348, 0.3362]}, {"w": "yet", "b": [0.4398, 0.3148, 0.4646, 0.3362]}, {"w": "powerful", "b": [0.4697, 0.3148, 0.5445, 0.3362]}, {"w": "algorithm,", "b": [0.5496, 0.3148, 0.637, 0.3362]}, {"w": "capable", "b": [0.642, 0.3148, 0.7044, 0.3362]}, {"w": "of", "b": [0.7094, 0.3148, 0.7262, 0.3362]}, {"w": "identifying", "b": [0.7313, 0.3148, 0.8225, 0.3362]}, {"w": "any", "b": [0.8275, 0.3148, 0.8571, 0.3362]}, {"w": "number", "b": [0.1429, 0.3338, 0.2091, 0.3552]}, {"w": "of", "b": [0.2162, 0.3338, 0.233, 0.3552]}, {"w": "clusters,", "b": [0.24, 0.3338, 0.3081, 0.3552]}, {"w": "of", "b": [0.3151, 0.3338, 0.3319, 0.3552]}, {"w": "any", "b": [0.339, 0.3338, 0.3686, 0.3552]}, {"w": "shape,", "b": [0.3756, 0.3338, 0.4277, 0.3552]}, {"w": "it", "b": [0.4347, 0.3338, 0.4466, 0.3552]}, {"w": "is", "b": [0.4536, 0.3338, 0.4669, 0.3552]}, {"w": "robust", "b": [0.4739, 0.3338, 0.5279, 0.3552]}, {"w": "to", "b": [0.5349, 0.3338, 0.5519, 0.3552]}, {"w": "outliers,", "b": [0.5589, 0.3338, 0.6268, 0.3552]}, {"w": "and", "b": [0.6338, 0.3338, 0.6654, 0.3552]}, {"w": "it", "b": [0.6724, 0.3338, 0.6843, 0.3552]}, {"w": "has", "b": [0.6914, 0.3338, 0.7193, 0.3552]}, {"w": "just", "b": [0.7263, 0.3338, 0.7567, 0.3552]}, {"w": "two", "b": [0.7637, 0.3338, 0.795, 0.3552]}, {"w": "hyper‐", "b": [0.802, 0.3338, 0.8571, 0.3552]}, {"w": "parameters", "b": [0.1429, 0.3538, 0.2363, 0.3752]}, {"w": "(eps", "b": [0.241, 0.3538, 0.2784, 0.3752]}, {"w": "and", "b": [0.2836, 0.3538, 0.3152, 0.3752]}, {"w": "min_samples).", "b": [0.3204, 0.3538, 0.4412, 0.3752]}, {"w": "However,", "b": [0.4464, 0.3538, 0.5253, 0.3752]}, {"w": "if", "b": [0.5305, 0.3538, 0.5423, 0.3752]}, {"w": "the", "b": [0.5475, 0.3538, 0.5738, 0.3752]}, {"w": "density", "b": [0.579, 0.3538, 0.6394, 0.3752]}, {"w": "varies", "b": [0.6446, 0.3538, 0.6932, 0.3752]}, {"w": "significantly", "b": [0.6985, 0.3538, 0.8003, 0.3752]}, {"w": "across", "b": [0.8055, 0.3538, 0.8571, 0.3752]}, {"w": "the", "b": [0.1429, 0.3728, 0.1692, 0.3942]}, {"w": "clusters,", "b": [0.1752, 0.3728, 0.2433, 0.3942]}, {"w": "it", "b": [0.2493, 0.3728, 0.2613, 0.3942]}, {"w": "can", "b": [0.2673, 0.3728, 0.2966, 0.3942]}, {"w": "be", "b": [0.3026, 0.3728, 0.3221, 0.3942]}, {"w": "impossible", "b": [0.3281, 0.3728, 0.4174, 0.3942]}, {"w": "for", "b": [0.4234, 0.3728, 0.448, 0.3942]}, {"w": "it", "b": [0.454, 0.3728, 0.4659, 0.3942]}, {"w": "to", "b": [0.4719, 0.3728, 0.4889, 0.3942]}, {"w": "capture", "b": [0.4949, 0.3728, 0.5574, 0.3942]}, {"w": "all", "b": [0.5634, 0.3728, 0.5831, 0.3942]}, {"w": "the", "b": [0.5891, 0.3728, 0.6154, 0.3942]}, {"w": "clusters", "b": [0.6214, 0.3728, 0.6848, 0.3942]}, {"w": "properly.", "b": [0.6908, 0.3728, 0.7656, 0.3942]}, {"w": "Moreover,", "b": [0.7716, 0.3728, 0.8571, 0.3942]}, {"w": "its", "b": [0.1429, 0.3919, 0.1624, 0.4133]}, {"w": "computational", "b": [0.1684, 0.3919, 0.29, 0.4133]}, {"w": "complexity", "b": [0.296, 0.3919, 0.3885, 0.4133]}, {"w": "is", "b": [0.3945, 0.3919, 0.4077, 0.4133]}, {"w": "roughly", "b": [0.4137, 0.3919, 0.4788, 0.4133]}, {"w": "O(m", "b": [0.4848, 0.3916, 0.524, 0.4133]}, {"w": "log", "b": [0.53, 0.3919, 0.5556, 0.4133]}, {"w": "m),", "b": [0.5616, 0.3916, 0.59, 0.4133]}, {"w": "making", "b": [0.596, 0.3919, 0.6593, 0.4133]}, {"w": "it", "b": [0.6653, 0.3919, 0.6772, 0.4133]}, {"w": "pretty", "b": [0.6832, 0.3919, 0.733, 0.4133]}, {"w": "close", "b": [0.739, 0.3919, 0.7802, 0.4133]}, {"w": "to", "b": [0.7862, 0.3919, 0.8032, 0.4133]}, {"w": "linear", "b": [0.8092, 0.3919, 0.8571, 0.4133]}, {"w": "with", "b": [0.1429, 0.4109, 0.1802, 0.4323]}, {"w": "regards", "b": [0.1857, 0.4109, 0.2475, 0.4323]}, {"w": "to", "b": [0.253, 0.4109, 0.27, 0.4323]}, {"w": "the", "b": [0.2755, 0.4109, 0.3018, 0.4323]}, {"w": "number", "b": [0.3073, 0.4109, 0.3736, 0.4323]}, {"w": "of", "b": [0.379, 0.4109, 0.3958, 0.4323]}, {"w": "instances.", "b": [0.4013, 0.4109, 0.4829, 0.4323]}, {"w": "However,", "b": [0.4884, 0.4109, 0.5672, 0.4323]}, {"w": "Scikit-Learn’s", "b": [0.5727, 0.4109, 0.6836, 0.4323]}, {"w": "implementation", "b": [0.6891, 0.4109, 0.8223, 0.4323]}, {"w": "can", "b": [0.8278, 0.4109, 0.8572, 0.4323]}, {"w": "require", "b": [0.1429, 0.4308, 0.2033, 0.4523]}, {"w": "up", "b": [0.208, 0.4308, 0.23, 0.4523]}, {"w": "to", "b": [0.2348, 0.4308, 0.2517, 0.4523]}, {"w": "O(m2)", "b": [0.2565, 0.4306, 0.3088, 0.4523]}, {"w": "memory", "b": [0.3136, 0.4308, 0.3851, 0.4523]}, {"w": "if", "b": [0.3898, 0.4308, 0.4015, 0.4523]}, {"w": "eps", "b": [0.4063, 0.434, 0.436, 0.4491]}, {"w": "is", "b": [0.4407, 0.4308, 0.4539, 0.4523]}, {"w": "large.", "b": [0.4587, 0.4308, 0.5042, 0.4523]}]}, {"id": "b_2", "type": "paragraph", "text": "Other Clustering Algorithms", "words": [{"w": "Other", "b": [0.1428, 0.465, 0.2008, 0.4936]}, {"w": "Clustering", "b": [0.2057, 0.465, 0.3105, 0.4936]}, {"w": "Algorithms", "b": [0.3154, 0.465, 0.4297, 0.4936]}]}, {"id": "b_3", "type": "paragraph", "text": "Scikit-Learn implements several more clustering algorithms that you should take a look at. We cannot cover them all in detail here, but here is a brief overview:", "words": [{"w": "Scikit-Learn", "b": [0.1429, 0.4995, 0.2452, 0.5209]}, {"w": "implements", "b": [0.2527, 0.4995, 0.3509, 0.5209]}, {"w": "several", "b": [0.3584, 0.4995, 0.4155, 0.5209]}, {"w": "more", "b": [0.4231, 0.4995, 0.4673, 0.5209]}, {"w": "clustering", "b": [0.4749, 0.4995, 0.5573, 0.5209]}, {"w": "algorithms", "b": [0.5648, 0.4995, 0.6551, 0.5209]}, {"w": "that", "b": [0.6627, 0.4995, 0.6952, 0.5209]}, {"w": "you", "b": [0.7028, 0.4995, 0.734, 0.5209]}, {"w": "should", "b": [0.7415, 0.4995, 0.7983, 0.5209]}, {"w": "take", "b": [0.8058, 0.4995, 0.8405, 0.5209]}, {"w": "a", "b": [0.848, 0.4995, 0.8571, 0.5209]}, {"w": "look", "b": [0.1429, 0.5185, 0.1797, 0.54]}, {"w": "at.", "b": [0.1844, 0.5185, 0.2043, 0.54]}, {"w": "We", "b": [0.209, 0.5185, 0.2361, 0.54]}, {"w": "cannot", "b": [0.2408, 0.5185, 0.2985, 0.54]}, {"w": "cover", "b": [0.3033, 0.5185, 0.3489, 0.54]}, {"w": "them", "b": [0.3537, 0.5185, 0.3971, 0.54]}, {"w": "all", "b": [0.4018, 0.5185, 0.4215, 0.54]}, {"w": "in", "b": [0.4262, 0.5185, 0.4432, 0.54]}, {"w": "detail", "b": [0.4479, 0.5185, 0.4941, 0.54]}, {"w": "here,", "b": [0.4989, 0.5185, 0.5402, 0.54]}, {"w": "but", "b": [0.5449, 0.5185, 0.5729, 0.54]}, {"w": "here", "b": [0.5776, 0.5185, 0.6142, 0.54]}, {"w": "is", "b": [0.6189, 0.5185, 0.6321, 0.54]}, {"w": "a", "b": [0.6369, 0.5185, 0.646, 0.54]}, {"w": "brief", "b": [0.6507, 0.5185, 0.6897, 0.54]}, {"w": "overview:", "b": [0.6944, 0.5185, 0.7756, 0.54]}]}, {"id": "b_4", "type": "paragraph", "text": "• Agglomerative clustering: a hierarchy of clusters is built from the bottom up. Think of many tiny bubbles floating on water and gradually attaching to each other until there’s just one big group of bubbles. Similarly, at each iteration agglomerative clustering connects the nearest pair of clusters (starting with indi‐ vidual instances). If you draw a tree with a branch for every pair of clusters that merged, you get a binary tree of clusters, where the leaves are the individual instances. This approach scales very well to large numbers of instances or clus‐ ters, it can capture clusters of various shapes, it produces a flexible and informa‐ tive cluster tree instead of forcing you to choose a particular cluster scale, and it can be used with any pairwise distance. It can scale nicely to large numbers of instances if you provide a connectivity matrix. This is a sparse m by m matrix that indicates which pairs of instances are neighbors (e.g., returned by sklearn.neighbors.kneighbors_graph()). Without a connectivity matrix, the algorithm does not scale well to large datasets.", "words": [{"w": "•", "b": [0.16, 0.5527, 0.1682, 0.5741]}, {"w": "Agglomerative", "b": [0.1786, 0.5525, 0.2956, 0.5741]}, {"w": "clustering:", "b": [0.305, 0.5525, 0.3877, 0.5741]}, {"w": "a", "b": [0.397, 0.5527, 0.4062, 0.5741]}, {"w": "hierarchy", "b": [0.4155, 0.5527, 0.4947, 0.5741]}, {"w": "of", "b": [0.504, 0.5527, 0.5208, 0.5741]}, {"w": "clusters", "b": [0.5301, 0.5527, 0.5935, 0.5741]}, {"w": "is", "b": [0.6028, 0.5527, 0.616, 0.5741]}, {"w": "built", "b": [0.6254, 0.5527, 0.6642, 0.5741]}, {"w": "from", "b": [0.6735, 0.5527, 0.7151, 0.5741]}, {"w": "the", "b": [0.7244, 0.5527, 0.7508, 0.5741]}, {"w": "bottom", "b": [0.7601, 0.5527, 0.8217, 0.5741]}, {"w": "up.", "b": [0.831, 0.5527, 0.8571, 0.5741]}, {"w": "Think", "b": [0.1786, 0.5718, 0.2299, 0.5932]}, {"w": "of", "b": [0.2376, 0.5718, 0.2544, 0.5932]}, {"w": "many", "b": [0.2622, 0.5718, 0.3089, 0.5932]}, {"w": "tiny", "b": [0.3167, 0.5718, 0.3491, 0.5932]}, {"w": "bubbles", "b": [0.3568, 0.5718, 0.4214, 0.5932]}, {"w": "floating", "b": [0.4292, 0.5718, 0.4931, 0.5932]}, {"w": "on", "b": [0.5009, 0.5718, 0.5229, 0.5932]}, {"w": "water", "b": [0.5307, 0.5718, 0.5766, 0.5932]}, {"w": "and", "b": [0.5844, 0.5718, 0.6159, 0.5932]}, {"w": "gradually", "b": [0.6237, 0.5718, 0.7016, 0.5932]}, {"w": "attaching", "b": [0.7094, 0.5718, 0.7867, 0.5932]}, {"w": "to", "b": [0.7945, 0.5718, 0.8114, 0.5932]}, {"w": "each", "b": [0.8192, 0.5718, 0.8571, 0.5932]}, {"w": "other", "b": [0.1786, 0.5908, 0.2232, 0.6122]}, {"w": "until", "b": [0.233, 0.5908, 0.2722, 0.6122]}, {"w": "there’s", "b": [0.282, 0.5908, 0.334, 0.6122]}, {"w": "just", "b": [0.3437, 0.5908, 0.3741, 0.6122]}, {"w": "one", "b": [0.3838, 0.5908, 0.4147, 0.6122]}, {"w": "big", "b": [0.4244, 0.5908, 0.4503, 0.6122]}, {"w": "group", "b": [0.46, 0.5908, 0.5101, 0.6122]}, {"w": "of", "b": [0.5198, 0.5908, 0.5366, 0.6122]}, {"w": "bubbles.", "b": [0.5463, 0.5908, 0.6157, 0.6122]}, {"w": "Similarly,", "b": [0.6254, 0.5908, 0.7037, 0.6122]}, {"w": "at", "b": [0.7134, 0.5908, 0.7285, 0.6122]}, {"w": "each", "b": [0.7382, 0.5908, 0.7762, 0.6122]}, {"w": "iteration", "b": [0.7859, 0.5908, 0.8571, 0.6122]}, {"w": "agglomerative", "b": [0.1786, 0.6098, 0.2959, 0.6313]}, {"w": "clustering", "b": [0.3015, 0.6098, 0.384, 0.6313]}, {"w": "connects", "b": [0.3895, 0.6098, 0.4634, 0.6313]}, {"w": "the", "b": [0.469, 0.6098, 0.4953, 0.6313]}, {"w": "nearest", "b": [0.5008, 0.6098, 0.5608, 0.6313]}, {"w": "pair", "b": [0.5664, 0.6098, 0.5997, 0.6313]}, {"w": "of", "b": [0.6053, 0.6098, 0.6221, 0.6313]}, {"w": "clusters", "b": [0.6276, 0.6098, 0.691, 0.6313]}, {"w": "(starting", "b": [0.6966, 0.6098, 0.7677, 0.6313]}, {"w": "with", "b": [0.7733, 0.6098, 0.8106, 0.6313]}, {"w": "indi‐", "b": [0.8162, 0.6098, 0.8571, 0.6313]}, {"w": "vidual", "b": [0.1786, 0.6289, 0.2303, 0.6503]}, {"w": "instances).", "b": [0.2363, 0.6289, 0.3251, 0.6503]}, {"w": "If", "b": [0.331, 0.6289, 0.3443, 0.6503]}, {"w": "you", "b": [0.3503, 0.6289, 0.3815, 0.6503]}, {"w": "draw", "b": [0.3875, 0.6289, 0.4293, 0.6503]}, {"w": "a", "b": [0.4353, 0.6289, 0.4444, 0.6503]}, {"w": "tree", "b": [0.4504, 0.6289, 0.4822, 0.6503]}, {"w": "with", "b": [0.4882, 0.6289, 0.5255, 0.6503]}, {"w": "a", "b": [0.5315, 0.6289, 0.5406, 0.6503]}, {"w": "branch", "b": [0.5466, 0.6289, 0.6054, 0.6503]}, {"w": "for", "b": [0.6114, 0.6289, 0.6359, 0.6503]}, {"w": "every", "b": [0.6419, 0.6289, 0.6871, 0.6503]}, {"w": "pair", "b": [0.6931, 0.6289, 0.7265, 0.6503]}, {"w": "of", "b": [0.7324, 0.6289, 0.7492, 0.6503]}, {"w": "clusters", "b": [0.7552, 0.6289, 0.8186, 0.6503]}, {"w": "that", "b": [0.8246, 0.6289, 0.8572, 0.6503]}, {"w": "merged,", "b": [0.1786, 0.6479, 0.2466, 0.6694]}, {"w": "you", "b": [0.2551, 0.6479, 0.2863, 0.6694]}, {"w": "get", "b": [0.2948, 0.6479, 0.3198, 0.6694]}, {"w": "a", "b": [0.3282, 0.6479, 0.3374, 0.6694]}, {"w": "binary", "b": [0.3459, 0.6479, 0.4005, 0.6694]}, {"w": "tree", "b": [0.409, 0.6479, 0.4408, 0.6694]}, {"w": "of", "b": [0.4493, 0.6479, 0.466, 0.6694]}, {"w": "clusters,", "b": [0.4745, 0.6479, 0.5427, 0.6694]}, {"w": "where", "b": [0.5511, 0.6479, 0.602, 0.6694]}, {"w": "the", "b": [0.6105, 0.6479, 0.6368, 0.6694]}, {"w": "leaves", "b": [0.6453, 0.6479, 0.6943, 0.6694]}, {"w": "are", "b": [0.7028, 0.6479, 0.7286, 0.6694]}, {"w": "the", "b": [0.737, 0.6479, 0.7634, 0.6694]}, {"w": "individual", "b": [0.7719, 0.6479, 0.8571, 0.6694]}, {"w": "instances.", "b": [0.1786, 0.667, 0.2602, 0.6884]}, {"w": "This", "b": [0.2669, 0.667, 0.3041, 0.6884]}, {"w": "approach", "b": [0.3108, 0.667, 0.3888, 0.6884]}, {"w": "scales", "b": [0.3955, 0.667, 0.4429, 0.6884]}, {"w": "very", "b": [0.4496, 0.667, 0.486, 0.6884]}, {"w": "well", "b": [0.4927, 0.667, 0.5264, 0.6884]}, {"w": "to", "b": [0.5331, 0.667, 0.55, 0.6884]}, {"w": "large", "b": [0.5567, 0.667, 0.5975, 0.6884]}, {"w": "numbers", "b": [0.6042, 0.667, 0.6781, 0.6884]}, {"w": "of", "b": [0.6848, 0.667, 0.7016, 0.6884]}, {"w": "instances", "b": [0.7083, 0.667, 0.7852, 0.6884]}, {"w": "or", "b": [0.7919, 0.667, 0.8102, 0.6884]}, {"w": "clus‐", "b": [0.8169, 0.667, 0.8571, 0.6884]}, {"w": "ters,", "b": [0.1786, 0.686, 0.2139, 0.7075]}, {"w": "it", "b": [0.2195, 0.686, 0.2315, 0.7075]}, {"w": "can", "b": [0.2371, 0.686, 0.2665, 0.7075]}, {"w": "capture", "b": [0.2721, 0.686, 0.3346, 0.7075]}, {"w": "clusters", "b": [0.3402, 0.686, 0.4036, 0.7075]}, {"w": "of", "b": [0.4093, 0.686, 0.4261, 0.7075]}, {"w": "various", "b": [0.4317, 0.686, 0.4931, 0.7075]}, {"w": "shapes,", "b": [0.4988, 0.686, 0.5585, 0.7075]}, {"w": "it", "b": [0.5641, 0.686, 0.576, 0.7075]}, {"w": "produces", "b": [0.5817, 0.686, 0.6583, 0.7075]}, {"w": "a", "b": [0.664, 0.686, 0.6731, 0.7075]}, {"w": "flexible", "b": [0.6788, 0.686, 0.7392, 0.7075]}, {"w": "and", "b": [0.7448, 0.686, 0.7764, 0.7075]}, {"w": "informa‐", "b": [0.782, 0.686, 0.8571, 0.7075]}, {"w": "tive", "b": [0.1786, 0.7051, 0.209, 0.7265]}, {"w": "cluster", "b": [0.215, 0.7051, 0.2707, 0.7265]}, {"w": "tree", "b": [0.2766, 0.7051, 0.3084, 0.7265]}, {"w": "instead", "b": [0.3144, 0.7051, 0.3744, 0.7265]}, {"w": "of", "b": [0.3803, 0.7051, 0.3971, 0.7265]}, {"w": "forcing", "b": [0.403, 0.7051, 0.4631, 0.7265]}, {"w": "you", "b": [0.4691, 0.7051, 0.5003, 0.7265]}, {"w": "to", "b": [0.5063, 0.7051, 0.5232, 0.7265]}, {"w": "choose", "b": [0.5292, 0.7051, 0.5869, 0.7265]}, {"w": "a", "b": [0.5928, 0.7051, 0.602, 0.7265]}, {"w": "particular", "b": [0.6079, 0.7051, 0.6897, 0.7265]}, {"w": "cluster", "b": [0.6956, 0.7051, 0.7513, 0.7265]}, {"w": "scale,", "b": [0.7573, 0.7051, 0.8018, 0.7265]}, {"w": "and", "b": [0.8077, 0.7051, 0.8393, 0.7265]}, {"w": "it", "b": [0.8452, 0.7051, 0.8571, 0.7265]}, {"w": "can", "b": [0.1786, 0.7241, 0.2079, 0.7455]}, {"w": "be", "b": [0.2151, 0.7241, 0.2345, 0.7455]}, {"w": "used", "b": [0.2417, 0.7241, 0.2803, 0.7455]}, {"w": "with", "b": [0.2875, 0.7241, 0.3248, 0.7455]}, {"w": "any", "b": [0.332, 0.7241, 0.3617, 0.7455]}, {"w": "pairwise", "b": [0.3688, 0.7241, 0.4392, 0.7455]}, {"w": "distance.", "b": [0.4464, 0.7241, 0.5199, 0.7455]}, {"w": "It", "b": [0.5271, 0.7241, 0.5398, 0.7455]}, {"w": "can", "b": [0.5469, 0.7241, 0.5763, 0.7455]}, {"w": "scale", "b": [0.5835, 0.7241, 0.6232, 0.7455]}, {"w": "nicely", "b": [0.6304, 0.7241, 0.6799, 0.7455]}, {"w": "to", "b": [0.6871, 0.7241, 0.7041, 0.7455]}, {"w": "large", "b": [0.7113, 0.7241, 0.752, 0.7455]}, {"w": "numbers", "b": [0.7592, 0.7241, 0.8331, 0.7455]}, {"w": "of", "b": [0.8403, 0.7241, 0.8571, 0.7455]}, {"w": "instances", "b": [0.1786, 0.7432, 0.2554, 0.7646]}, {"w": "if", "b": [0.2627, 0.7432, 0.2745, 0.7646]}, {"w": "you", "b": [0.2818, 0.7432, 0.313, 0.7646]}, {"w": "provide", "b": [0.3204, 0.7432, 0.3847, 0.7646]}, {"w": "a", "b": [0.392, 0.7432, 0.4012, 0.7646]}, {"w": "connectivity", "b": [0.4085, 0.7432, 0.5115, 0.7646]}, {"w": "matrix.", "b": [0.5188, 0.7432, 0.5788, 0.7646]}, {"w": "This", "b": [0.5862, 0.7432, 0.6234, 0.7646]}, {"w": "is", "b": [0.6307, 0.7432, 0.6439, 0.7646]}, {"w": "a", "b": [0.6512, 0.7432, 0.6604, 0.7646]}, {"w": "sparse", "b": [0.6677, 0.7432, 0.7196, 0.7646]}, {"w": "m", "b": [0.7269, 0.743, 0.7433, 0.7646]}, {"w": "by", "b": [0.7507, 0.7432, 0.7708, 0.7646]}, {"w": "m", "b": [0.7781, 0.743, 0.7945, 0.7646]}, {"w": "matrix", "b": [0.8018, 0.7432, 0.8571, 0.7646]}, {"w": "that", "b": [0.1786, 0.7622, 0.2112, 0.7836]}, {"w": "indicates", "b": [0.2256, 0.7622, 0.2996, 0.7836]}, {"w": "which", "b": [0.314, 0.7622, 0.3649, 0.7836]}, {"w": "pairs", "b": [0.3793, 0.7622, 0.4204, 0.7836]}, {"w": "of", "b": [0.4348, 0.7622, 0.4516, 0.7836]}, {"w": "instances", "b": [0.466, 0.7622, 0.5428, 0.7836]}, {"w": "are", "b": [0.5572, 0.7622, 0.583, 0.7836]}, {"w": "neighbors", "b": [0.5974, 0.7622, 0.6807, 0.7836]}, {"w": "(e.g.,", "b": [0.6951, 0.7622, 0.7352, 0.7836]}, {"w": "returned", "b": [0.7496, 0.7622, 0.8226, 0.7836]}, {"w": "by", "b": [0.837, 0.7622, 0.8572, 0.7836]}, {"w": "sklearn.neighbors.kneighbors_graph()).", "b": [0.1786, 0.7822, 0.5468, 0.8036]}, {"w": "Without", "b": [0.5551, 0.7822, 0.6255, 0.8036]}, {"w": "a", "b": [0.6338, 0.7822, 0.643, 0.8036]}, {"w": "connectivity", "b": [0.6512, 0.7822, 0.7542, 0.8036]}, {"w": "matrix,", "b": [0.7625, 0.7822, 0.8225, 0.8036]}, {"w": "the", "b": [0.8308, 0.7822, 0.8571, 0.8036]}, {"w": "algorithm", "b": [0.1786, 0.8012, 0.2612, 0.8226]}, {"w": "does", "b": [0.2659, 0.8012, 0.3041, 0.8226]}, {"w": "not", "b": [0.3088, 0.8012, 0.3372, 0.8226]}, {"w": "scale", "b": [0.3419, 0.8012, 0.3816, 0.8226]}, {"w": "well", "b": [0.3864, 0.8012, 0.42, 0.8226]}, {"w": "to", "b": [0.4247, 0.8012, 0.4417, 0.8226]}, {"w": "large", "b": [0.4465, 0.8012, 0.4872, 0.8226]}, {"w": "datasets.", "b": [0.4919, 0.8012, 0.5624, 0.8226]}]}, {"id": "b_5", "type": "paragraph", "text": "• Birch: this algorithm was designed specifically for very large datasets, and it can be faster than batch K-Means, with similar results, as long as the number of fea‐ tures is not too large (<20). It builds a tree structure during training containing", "words": [{"w": "•", "b": [0.16, 0.8263, 0.1682, 0.8477]}, {"w": "Birch:", "b": [0.1786, 0.8261, 0.226, 0.8477]}, {"w": "this", "b": [0.2324, 0.8263, 0.2631, 0.8477]}, {"w": "algorithm", "b": [0.2694, 0.8263, 0.3521, 0.8477]}, {"w": "was", "b": [0.3584, 0.8263, 0.3895, 0.8477]}, {"w": "designed", "b": [0.3958, 0.8263, 0.4699, 0.8477]}, {"w": "specifically", "b": [0.4762, 0.8263, 0.5678, 0.8477]}, {"w": "for", "b": [0.5742, 0.8263, 0.5987, 0.8477]}, {"w": "very", "b": [0.605, 0.8263, 0.6414, 0.8477]}, {"w": "large", "b": [0.6477, 0.8263, 0.6885, 0.8477]}, {"w": "datasets,", "b": [0.6948, 0.8263, 0.7653, 0.8477]}, {"w": "and", "b": [0.7716, 0.8263, 0.8032, 0.8477]}, {"w": "it", "b": [0.8095, 0.8263, 0.8215, 0.8477]}, {"w": "can", "b": [0.8278, 0.8263, 0.8571, 0.8477]}, {"w": "be", "b": [0.1786, 0.8454, 0.198, 0.8668]}, {"w": "faster", "b": [0.2039, 0.8454, 0.2498, 0.8668]}, {"w": "than", "b": [0.2556, 0.8454, 0.2937, 0.8668]}, {"w": "batch", "b": [0.2995, 0.8454, 0.3451, 0.8668]}, {"w": "K-Means,", "b": [0.351, 0.8454, 0.4322, 0.8668]}, {"w": "with", "b": [0.4381, 0.8454, 0.4754, 0.8668]}, {"w": "similar", "b": [0.4813, 0.8454, 0.5393, 0.8668]}, {"w": "results,", "b": [0.5452, 0.8454, 0.6045, 0.8668]}, {"w": "as", "b": [0.6104, 0.8454, 0.6271, 0.8668]}, {"w": "long", "b": [0.633, 0.8454, 0.6701, 0.8668]}, {"w": "as", "b": [0.6759, 0.8454, 0.6927, 0.8668]}, {"w": "the", "b": [0.6986, 0.8454, 0.7249, 0.8668]}, {"w": "number", "b": [0.7308, 0.8454, 0.797, 0.8668]}, {"w": "of", "b": [0.8029, 0.8454, 0.8197, 0.8668]}, {"w": "fea‐", "b": [0.8256, 0.8454, 0.8571, 0.8668]}, {"w": "tures", "b": [0.1786, 0.8644, 0.2202, 0.8858]}, {"w": "is", "b": [0.2266, 0.8644, 0.2398, 0.8858]}, {"w": "not", "b": [0.2462, 0.8644, 0.2746, 0.8858]}, {"w": "too", "b": [0.2809, 0.8644, 0.3085, 0.8858]}, {"w": "large", "b": [0.3149, 0.8644, 0.3557, 0.8858]}, {"w": "(<20).", "b": [0.362, 0.8644, 0.4127, 0.8858]}, {"w": "It", "b": [0.4191, 0.8644, 0.4317, 0.8858]}, {"w": "builds", "b": [0.4381, 0.8644, 0.4892, 0.8858]}, {"w": "a", "b": [0.4956, 0.8644, 0.5048, 0.8858]}, {"w": "tree", "b": [0.5111, 0.8644, 0.5429, 0.8858]}, {"w": "structure", "b": [0.5493, 0.8644, 0.6249, 0.8858]}, {"w": "during", "b": [0.6313, 0.8644, 0.6878, 0.8858]}, {"w": "training", "b": [0.6942, 0.8644, 0.7611, 0.8858]}, {"w": "containing", "b": [0.7675, 0.8644, 0.8571, 0.8858]}]}, {"id": "b_6", "type": "paragraph", "text": "Clustering | 259", "words": [{"w": "Clustering", "b": [0.736, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "259", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 286, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "just enough information to quickly assign each new instance to a cluster, without having to store all the instances in the tree: this allows it to use limited memory, while handle huge datasets.", "words": [{"w": "just", "b": [0.1786, 0.0791, 0.209, 0.1005]}, {"w": "enough", "b": [0.2142, 0.0791, 0.277, 0.1005]}, {"w": "information", "b": [0.2822, 0.0791, 0.3834, 0.1005]}, {"w": "to", "b": [0.3886, 0.0791, 0.4056, 0.1005]}, {"w": "quickly", "b": [0.4108, 0.0791, 0.4721, 0.1005]}, {"w": "assign", "b": [0.4773, 0.0791, 0.5284, 0.1005]}, {"w": "each", "b": [0.5336, 0.0791, 0.5716, 0.1005]}, {"w": "new", "b": [0.5768, 0.0791, 0.6113, 0.1005]}, {"w": "instance", "b": [0.6165, 0.0791, 0.6857, 0.1005]}, {"w": "to", "b": [0.6909, 0.0791, 0.7079, 0.1005]}, {"w": "a", "b": [0.7131, 0.0791, 0.7222, 0.1005]}, {"w": "cluster,", "b": [0.7274, 0.0791, 0.7866, 0.1005]}, {"w": "without", "b": [0.7918, 0.0791, 0.8571, 0.1005]}, {"w": "having", "b": [0.1786, 0.0981, 0.2348, 0.1195]}, {"w": "to", "b": [0.2407, 0.0981, 0.2577, 0.1195]}, {"w": "store", "b": [0.2635, 0.0981, 0.3047, 0.1195]}, {"w": "all", "b": [0.3105, 0.0981, 0.3302, 0.1195]}, {"w": "the", "b": [0.3361, 0.0981, 0.3624, 0.1195]}, {"w": "instances", "b": [0.3682, 0.0981, 0.4451, 0.1195]}, {"w": "in", "b": [0.4509, 0.0981, 0.4679, 0.1195]}, {"w": "the", "b": [0.4737, 0.0981, 0.5001, 0.1195]}, {"w": "tree:", "b": [0.5059, 0.0981, 0.5424, 0.1195]}, {"w": "this", "b": [0.5483, 0.0981, 0.579, 0.1195]}, {"w": "allows", "b": [0.5848, 0.0981, 0.637, 0.1195]}, {"w": "it", "b": [0.6429, 0.0981, 0.6548, 0.1195]}, {"w": "to", "b": [0.6607, 0.0981, 0.6776, 0.1195]}, {"w": "use", "b": [0.6835, 0.0981, 0.711, 0.1195]}, {"w": "limited", "b": [0.7169, 0.0981, 0.7766, 0.1195]}, {"w": "memory,", "b": [0.7824, 0.0981, 0.8571, 0.1195]}, {"w": "while", "b": [0.1786, 0.1172, 0.2237, 0.1386]}, {"w": "handle", "b": [0.2284, 0.1172, 0.2852, 0.1386]}, {"w": "huge", "b": [0.2899, 0.1172, 0.3303, 0.1386]}, {"w": "datasets.", "b": [0.335, 0.1172, 0.4055, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "• Mean-shift: this algorithm starts by placing a circle centered on each instance, then for each circle it computes the mean of all the instances located within it, and it shifts the circle so that it is centered on the mean. Next, it iterates this mean-shift step until all the circles stop moving (i.e., until each of them is cen‐ tered on the mean of the instances it contains). This algorithm shifts the circles in the direction of higher density, until each of them has found a local density maximum. Finally, all the instances whose circles have settled in the same place (or close enough) are assigned to the same cluster. This has some of the same fea‐ tures as DBSCAN, in particular it can find any number of clusters of any shape, it has just one hyperparameter (the radius of the circles, called the bandwidth) and it relies on local density estimation. However, it tends to chop clusters into pieces when they have internal density variations. Unfortunately, its computational complexity is O(m2), so it is not suited for large datasets.", "words": [{"w": "•", "b": [0.16, 0.1423, 0.1682, 0.1637]}, {"w": "Mean-shift:", "b": [0.1786, 0.142, 0.2733, 0.1637]}, {"w": "this", "b": [0.281, 0.1423, 0.3118, 0.1637]}, {"w": "algorithm", "b": [0.3195, 0.1423, 0.4021, 0.1637]}, {"w": "starts", "b": [0.4099, 0.1423, 0.4547, 0.1637]}, {"w": "by", "b": [0.4625, 0.1423, 0.4826, 0.1637]}, {"w": "placing", "b": [0.4903, 0.1423, 0.5512, 0.1637]}, {"w": "a", "b": [0.5589, 0.1423, 0.5681, 0.1637]}, {"w": "circle", "b": [0.5758, 0.1423, 0.6209, 0.1637]}, {"w": "centered", "b": [0.6286, 0.1423, 0.7001, 0.1637]}, {"w": "on", "b": [0.7078, 0.1423, 0.7298, 0.1637]}, {"w": "each", "b": [0.7375, 0.1423, 0.7755, 0.1637]}, {"w": "instance,", "b": [0.7832, 0.1423, 0.8571, 0.1637]}, {"w": "then", "b": [0.1786, 0.1613, 0.2163, 0.1827]}, {"w": "for", "b": [0.2233, 0.1613, 0.2478, 0.1827]}, {"w": "each", "b": [0.2547, 0.1613, 0.2927, 0.1827]}, {"w": "circle", "b": [0.2996, 0.1613, 0.3447, 0.1827]}, {"w": "it", "b": [0.3516, 0.1613, 0.3636, 0.1827]}, {"w": "computes", "b": [0.3705, 0.1613, 0.4515, 0.1827]}, {"w": "the", "b": [0.4584, 0.1613, 0.4848, 0.1827]}, {"w": "mean", "b": [0.4917, 0.1613, 0.5382, 0.1827]}, {"w": "of", "b": [0.5451, 0.1613, 0.5619, 0.1827]}, {"w": "all", "b": [0.5689, 0.1613, 0.5885, 0.1827]}, {"w": "the", "b": [0.5955, 0.1613, 0.6218, 0.1827]}, {"w": "instances", "b": [0.6288, 0.1613, 0.7056, 0.1827]}, {"w": "located", "b": [0.7126, 0.1613, 0.7722, 0.1827]}, {"w": "within", "b": [0.7792, 0.1613, 0.8335, 0.1827]}, {"w": "it,", "b": [0.8405, 0.1613, 0.8571, 0.1827]}, {"w": "and", "b": [0.1786, 0.1803, 0.2101, 0.2018]}, {"w": "it", "b": [0.2179, 0.1803, 0.2298, 0.2018]}, {"w": "shifts", "b": [0.2376, 0.1803, 0.2821, 0.2018]}, {"w": "the", "b": [0.2899, 0.1803, 0.3163, 0.2018]}, {"w": "circle", "b": [0.324, 0.1803, 0.3691, 0.2018]}, {"w": "so", "b": [0.3769, 0.1803, 0.3952, 0.2018]}, {"w": "that", "b": [0.403, 0.1803, 0.4355, 0.2018]}, {"w": "it", "b": [0.4433, 0.1803, 0.4553, 0.2018]}, {"w": "is", "b": [0.4631, 0.1803, 0.4763, 0.2018]}, {"w": "centered", "b": [0.4841, 0.1803, 0.5555, 0.2018]}, {"w": "on", "b": [0.5633, 0.1803, 0.5853, 0.2018]}, {"w": "the", "b": [0.5931, 0.1803, 0.6195, 0.2018]}, {"w": "mean.", "b": [0.6273, 0.1803, 0.6785, 0.2018]}, {"w": "Next,", "b": [0.6862, 0.1803, 0.731, 0.2018]}, {"w": "it", "b": [0.7388, 0.1803, 0.7507, 0.2018]}, {"w": "iterates", "b": [0.7585, 0.1803, 0.8186, 0.2018]}, {"w": "this", "b": [0.8264, 0.1803, 0.8571, 0.2018]}, {"w": "mean-shift", "b": [0.1786, 0.1994, 0.2693, 0.2208]}, {"w": "step", "b": [0.276, 0.1994, 0.3098, 0.2208]}, {"w": "until", "b": [0.3164, 0.1994, 0.3557, 0.2208]}, {"w": "all", "b": [0.3624, 0.1994, 0.3821, 0.2208]}, {"w": "the", "b": [0.3887, 0.1994, 0.4151, 0.2208]}, {"w": "circles", "b": [0.4218, 0.1994, 0.4745, 0.2208]}, {"w": "stop", "b": [0.4811, 0.1994, 0.5167, 0.2208]}, {"w": "moving", "b": [0.5234, 0.1994, 0.5874, 0.2208]}, {"w": "(i.e.,", "b": [0.5941, 0.1994, 0.63, 0.2208]}, {"w": "until", "b": [0.6367, 0.1994, 0.6759, 0.2208]}, {"w": "each", "b": [0.6826, 0.1994, 0.7205, 0.2208]}, {"w": "of", "b": [0.7272, 0.1994, 0.744, 0.2208]}, {"w": "them", "b": [0.7507, 0.1994, 0.7941, 0.2208]}, {"w": "is", "b": [0.8008, 0.1994, 0.814, 0.2208]}, {"w": "cen‐", "b": [0.8207, 0.1994, 0.8571, 0.2208]}, {"w": "tered", "b": [0.1786, 0.2184, 0.2214, 0.2399]}, {"w": "on", "b": [0.2278, 0.2184, 0.2498, 0.2399]}, {"w": "the", "b": [0.2562, 0.2184, 0.2825, 0.2399]}, {"w": "mean", "b": [0.2889, 0.2184, 0.3354, 0.2399]}, {"w": "of", "b": [0.3418, 0.2184, 0.3586, 0.2399]}, {"w": "the", "b": [0.365, 0.2184, 0.3913, 0.2399]}, {"w": "instances", "b": [0.3977, 0.2184, 0.4745, 0.2399]}, {"w": "it", "b": [0.4809, 0.2184, 0.4928, 0.2399]}, {"w": "contains).", "b": [0.4992, 0.2184, 0.5818, 0.2399]}, {"w": "This", "b": [0.5882, 0.2184, 0.6254, 0.2399]}, {"w": "algorithm", "b": [0.6318, 0.2184, 0.7144, 0.2399]}, {"w": "shifts", "b": [0.7208, 0.2184, 0.7653, 0.2399]}, {"w": "the", "b": [0.7717, 0.2184, 0.798, 0.2399]}, {"w": "circles", "b": [0.8044, 0.2184, 0.8572, 0.2399]}, {"w": "in", "b": [0.1786, 0.2375, 0.1955, 0.2589]}, {"w": "the", "b": [0.2027, 0.2375, 0.2291, 0.2589]}, {"w": "direction", "b": [0.2362, 0.2375, 0.3122, 0.2589]}, {"w": "of", "b": [0.3194, 0.2375, 0.3361, 0.2589]}, {"w": "higher", "b": [0.3433, 0.2375, 0.3975, 0.2589]}, {"w": "density,", "b": [0.4047, 0.2375, 0.4683, 0.2589]}, {"w": "until", "b": [0.4755, 0.2375, 0.5147, 0.2589]}, {"w": "each", "b": [0.5219, 0.2375, 0.5599, 0.2589]}, {"w": "of", "b": [0.567, 0.2375, 0.5838, 0.2589]}, {"w": "them", "b": [0.591, 0.2375, 0.6344, 0.2589]}, {"w": "has", "b": [0.6416, 0.2375, 0.6695, 0.2589]}, {"w": "found", "b": [0.6767, 0.2375, 0.7269, 0.2589]}, {"w": "a", "b": [0.7341, 0.2375, 0.7433, 0.2589]}, {"w": "local", "b": [0.7504, 0.2375, 0.7896, 0.2589]}, {"w": "density", "b": [0.7967, 0.2375, 0.8571, 0.2589]}, {"w": "maximum.", "b": [0.1786, 0.2565, 0.2697, 0.2779]}, {"w": "Finally,", "b": [0.2762, 0.2565, 0.3366, 0.2779]}, {"w": "all", "b": [0.3431, 0.2565, 0.3628, 0.2779]}, {"w": "the", "b": [0.3692, 0.2565, 0.3955, 0.2779]}, {"w": "instances", "b": [0.4019, 0.2565, 0.4788, 0.2779]}, {"w": "whose", "b": [0.4852, 0.2565, 0.5377, 0.2779]}, {"w": "circles", "b": [0.5441, 0.2565, 0.5969, 0.2779]}, {"w": "have", "b": [0.6033, 0.2565, 0.6417, 0.2779]}, {"w": "settled", "b": [0.6481, 0.2565, 0.7024, 0.2779]}, {"w": "in", "b": [0.7089, 0.2565, 0.7258, 0.2779]}, {"w": "the", "b": [0.7323, 0.2565, 0.7586, 0.2779]}, {"w": "same", "b": [0.765, 0.2565, 0.8077, 0.2779]}, {"w": "place", "b": [0.8141, 0.2565, 0.8571, 0.2779]}, {"w": "(or", "b": [0.1786, 0.2756, 0.2041, 0.297]}, {"w": "close", "b": [0.209, 0.2756, 0.2502, 0.297]}, {"w": "enough)", "b": [0.2551, 0.2756, 0.3251, 0.297]}, {"w": "are", "b": [0.33, 0.2756, 0.3557, 0.297]}, {"w": "assigned", "b": [0.3606, 0.2756, 0.4316, 0.297]}, {"w": "to", "b": [0.4365, 0.2756, 0.4535, 0.297]}, {"w": "the", "b": [0.4583, 0.2756, 0.4847, 0.297]}, {"w": "same", "b": [0.4895, 0.2756, 0.5322, 0.297]}, {"w": "cluster.", "b": [0.5371, 0.2756, 0.5963, 0.297]}, {"w": "This", "b": [0.6012, 0.2756, 0.6384, 0.297]}, {"w": "has", "b": [0.6432, 0.2756, 0.6712, 0.297]}, {"w": "some", "b": [0.676, 0.2756, 0.7202, 0.297]}, {"w": "of", "b": [0.7251, 0.2756, 0.7419, 0.297]}, {"w": "the", "b": [0.7468, 0.2756, 0.7731, 0.297]}, {"w": "same", "b": [0.778, 0.2756, 0.8207, 0.297]}, {"w": "fea‐", "b": [0.8256, 0.2756, 0.8571, 0.297]}, {"w": "tures", "b": [0.1786, 0.2946, 0.2202, 0.316]}, {"w": "as", "b": [0.2251, 0.2946, 0.2419, 0.316]}, {"w": "DBSCAN,", "b": [0.2468, 0.2946, 0.3327, 0.316]}, {"w": "in", "b": [0.3376, 0.2946, 0.3546, 0.316]}, {"w": "particular", "b": [0.3595, 0.2946, 0.4413, 0.316]}, {"w": "it", "b": [0.4462, 0.2946, 0.4581, 0.316]}, {"w": "can", "b": [0.463, 0.2946, 0.4924, 0.316]}, {"w": "find", "b": [0.4973, 0.2946, 0.5314, 0.316]}, {"w": "any", "b": [0.5363, 0.2946, 0.566, 0.316]}, {"w": "number", "b": [0.5709, 0.2946, 0.6372, 0.316]}, {"w": "of", "b": [0.6421, 0.2946, 0.6589, 0.316]}, {"w": "clusters", "b": [0.6638, 0.2946, 0.7271, 0.316]}, {"w": "of", "b": [0.732, 0.2946, 0.7488, 0.316]}, {"w": "any", "b": [0.7537, 0.2946, 0.7834, 0.316]}, {"w": "shape,", "b": [0.7883, 0.2946, 0.8403, 0.316]}, {"w": "it", "b": [0.8452, 0.2946, 0.8571, 0.316]}, {"w": "has", "b": [0.1786, 0.3137, 0.2065, 0.3351]}, {"w": "just", "b": [0.212, 0.3137, 0.2423, 0.3351]}, {"w": "one", "b": [0.2478, 0.3137, 0.2787, 0.3351]}, {"w": "hyperparameter", "b": [0.2842, 0.3137, 0.4177, 0.3351]}, {"w": "(the", "b": [0.4231, 0.3137, 0.4567, 0.3351]}, {"w": "radius", "b": [0.4622, 0.3137, 0.5143, 0.3351]}, {"w": "of", "b": [0.5198, 0.3137, 0.5366, 0.3351]}, {"w": "the", "b": [0.5421, 0.3137, 0.5684, 0.3351]}, {"w": "circles,", "b": [0.5739, 0.3137, 0.6313, 0.3351]}, {"w": "called", "b": [0.6368, 0.3137, 0.6852, 0.3351]}, {"w": "the", "b": [0.6906, 0.3137, 0.717, 0.3351]}, {"w": "bandwidth)", "b": [0.7225, 0.3137, 0.8201, 0.3351]}, {"w": "and", "b": [0.8256, 0.3137, 0.8571, 0.3351]}, {"w": "it", "b": [0.1786, 0.3327, 0.1905, 0.3541]}, {"w": "relies", "b": [0.1956, 0.3327, 0.2395, 0.3541]}, {"w": "on", "b": [0.2446, 0.3327, 0.2666, 0.3541]}, {"w": "local", "b": [0.2717, 0.3327, 0.3108, 0.3541]}, {"w": "density", "b": [0.3159, 0.3327, 0.3763, 0.3541]}, {"w": "estimation.", "b": [0.3814, 0.3327, 0.4744, 0.3541]}, {"w": "However,", "b": [0.4795, 0.3327, 0.5583, 0.3541]}, {"w": "it", "b": [0.5634, 0.3327, 0.5753, 0.3541]}, {"w": "tends", "b": [0.5804, 0.3327, 0.6257, 0.3541]}, {"w": "to", "b": [0.6307, 0.3327, 0.6477, 0.3541]}, {"w": "chop", "b": [0.6528, 0.3327, 0.6943, 0.3541]}, {"w": "clusters", "b": [0.6994, 0.3327, 0.7627, 0.3541]}, {"w": "into", "b": [0.7678, 0.3327, 0.8014, 0.3541]}, {"w": "pieces", "b": [0.8065, 0.3327, 0.8571, 0.3541]}, {"w": "when", "b": [0.1786, 0.3518, 0.2242, 0.3732]}, {"w": "they", "b": [0.2346, 0.3518, 0.2705, 0.3732]}, {"w": "have", "b": [0.281, 0.3518, 0.3194, 0.3732]}, {"w": "internal", "b": [0.3298, 0.3518, 0.3951, 0.3732]}, {"w": "density", "b": [0.4055, 0.3518, 0.4659, 0.3732]}, {"w": "variations.", "b": [0.4763, 0.3518, 0.5636, 0.3732]}, {"w": "Unfortunately,", "b": [0.574, 0.3518, 0.6952, 0.3732]}, {"w": "its", "b": [0.7056, 0.3518, 0.7252, 0.3732]}, {"w": "computational", "b": [0.7356, 0.3518, 0.8572, 0.3732]}, {"w": "complexity", "b": [0.1786, 0.3708, 0.271, 0.3922]}, {"w": "is", "b": [0.2758, 0.3708, 0.289, 0.3922]}, {"w": "O(m2),", "b": [0.2937, 0.3706, 0.3509, 0.3922]}, {"w": "so", "b": [0.3556, 0.3708, 0.3739, 0.3922]}, {"w": "it", "b": [0.3786, 0.3708, 0.3905, 0.3922]}, {"w": "is", "b": [0.3953, 0.3708, 0.4085, 0.3922]}, {"w": "not", "b": [0.4132, 0.3708, 0.4416, 0.3922]}, {"w": "suited", "b": [0.4463, 0.3708, 0.4968, 0.3922]}, {"w": "for", "b": [0.5015, 0.3708, 0.5261, 0.3922]}, {"w": "large", "b": [0.5308, 0.3708, 0.5715, 0.3922]}, {"w": "datasets.", "b": [0.5763, 0.3708, 0.6468, 0.3922]}]}, {"id": "b_2", "type": "paragraph", "text": "• Affinity propagation: this algorithm uses a voting system, where instances vote for similar instances to be their representatives, and once the algorithm converges, each representative and its voters form a cluster. This algorithm can detect any number of clusters of different sizes. Unfortunately, this algorithm has a compu‐ tational complexity of O(m2), so it is not suited for large datasets.", "words": [{"w": "•", "b": [0.16, 0.3959, 0.1682, 0.4173]}, {"w": "Affinity", "b": [0.1786, 0.3957, 0.2413, 0.4173]}, {"w": "propagation:", "b": [0.246, 0.3957, 0.3485, 0.4173]}, {"w": "this", "b": [0.3533, 0.3959, 0.384, 0.4173]}, {"w": "algorithm", "b": [0.3888, 0.3959, 0.4715, 0.4173]}, {"w": "uses", "b": [0.4763, 0.3959, 0.5115, 0.4173]}, {"w": "a", "b": [0.5163, 0.3959, 0.5254, 0.4173]}, {"w": "voting", "b": [0.5302, 0.3959, 0.5836, 0.4173]}, {"w": "system,", "b": [0.5884, 0.3959, 0.6503, 0.4173]}, {"w": "where", "b": [0.6551, 0.3959, 0.7059, 0.4173]}, {"w": "instances", "b": [0.7107, 0.3959, 0.7875, 0.4173]}, {"w": "vote", "b": [0.7923, 0.3959, 0.8278, 0.4173]}, {"w": "for", "b": [0.8326, 0.3959, 0.8571, 0.4173]}, {"w": "similar", "b": [0.1786, 0.415, 0.2366, 0.4364]}, {"w": "instances", "b": [0.2436, 0.415, 0.3205, 0.4364]}, {"w": "to", "b": [0.3275, 0.415, 0.3445, 0.4364]}, {"w": "be", "b": [0.3515, 0.415, 0.3709, 0.4364]}, {"w": "their", "b": [0.378, 0.415, 0.4176, 0.4364]}, {"w": "representatives,", "b": [0.4247, 0.415, 0.5542, 0.4364]}, {"w": "and", "b": [0.5612, 0.415, 0.5927, 0.4364]}, {"w": "once", "b": [0.5998, 0.415, 0.6395, 0.4364]}, {"w": "the", "b": [0.6465, 0.415, 0.6728, 0.4364]}, {"w": "algorithm", "b": [0.6799, 0.415, 0.7625, 0.4364]}, {"w": "converges,", "b": [0.7696, 0.415, 0.8571, 0.4364]}, {"w": "each", "b": [0.1786, 0.434, 0.2165, 0.4554]}, {"w": "representative", "b": [0.2234, 0.434, 0.3405, 0.4554]}, {"w": "and", "b": [0.3474, 0.434, 0.3789, 0.4554]}, {"w": "its", "b": [0.3858, 0.434, 0.4054, 0.4554]}, {"w": "voters", "b": [0.4123, 0.434, 0.4631, 0.4554]}, {"w": "form", "b": [0.47, 0.434, 0.5116, 0.4554]}, {"w": "a", "b": [0.5185, 0.434, 0.5276, 0.4554]}, {"w": "cluster.", "b": [0.5345, 0.434, 0.5937, 0.4554]}, {"w": "This", "b": [0.6006, 0.434, 0.6378, 0.4554]}, {"w": "algorithm", "b": [0.6446, 0.434, 0.7273, 0.4554]}, {"w": "can", "b": [0.7342, 0.434, 0.7635, 0.4554]}, {"w": "detect", "b": [0.7704, 0.434, 0.8206, 0.4554]}, {"w": "any", "b": [0.8275, 0.434, 0.8571, 0.4554]}, {"w": "number", "b": [0.1786, 0.4531, 0.2449, 0.4745]}, {"w": "of", "b": [0.2506, 0.4531, 0.2674, 0.4745]}, {"w": "clusters", "b": [0.2732, 0.4531, 0.3365, 0.4745]}, {"w": "of", "b": [0.3423, 0.4531, 0.3591, 0.4745]}, {"w": "different", "b": [0.3648, 0.4531, 0.4365, 0.4745]}, {"w": "sizes.", "b": [0.4423, 0.4531, 0.4855, 0.4745]}, {"w": "Unfortunately,", "b": [0.4913, 0.4531, 0.6125, 0.4745]}, {"w": "this", "b": [0.6182, 0.4531, 0.6489, 0.4745]}, {"w": "algorithm", "b": [0.6547, 0.4531, 0.7373, 0.4745]}, {"w": "has", "b": [0.7431, 0.4531, 0.771, 0.4745]}, {"w": "a", "b": [0.7768, 0.4531, 0.7859, 0.4745]}, {"w": "compu‐", "b": [0.7917, 0.4531, 0.8572, 0.4745]}, {"w": "tational", "b": [0.1786, 0.4721, 0.242, 0.4935]}, {"w": "complexity", "b": [0.2468, 0.4721, 0.3393, 0.4935]}, {"w": "of", "b": [0.344, 0.4721, 0.3608, 0.4935]}, {"w": "O(m2),", "b": [0.3655, 0.4719, 0.4226, 0.4935]}, {"w": "so", "b": [0.4274, 0.4721, 0.4456, 0.4935]}, {"w": "it", "b": [0.4504, 0.4721, 0.4623, 0.4935]}, {"w": "is", "b": [0.467, 0.4721, 0.4803, 0.4935]}, {"w": "not", "b": [0.485, 0.4721, 0.5134, 0.4935]}, {"w": "suited", "b": [0.5181, 0.4721, 0.5686, 0.4935]}, {"w": "for", "b": [0.5733, 0.4721, 0.5978, 0.4935]}, {"w": "large", "b": [0.6026, 0.4721, 0.6433, 0.4935]}, {"w": "datasets.", "b": [0.648, 0.4721, 0.7185, 0.4935]}]}, {"id": "b_3", "type": "paragraph", "text": "• Spectral clustering: this algorithm takes a similarity matrix between the instances and creates a low-dimensional embedding from it (i.e., it reduces its dimension‐ ality), then it uses another clustering algorithm in this low-dimensional space (Scikit-Learn’s implementation uses K-Means). Spectral clustering can capture complex cluster structures, and it can also be used to cut graphs (e.g., to identify clusters of friends on a social network), however it does not scale well to large number of instances, and it does not behave well when the clusters have very dif‐ ferent sizes.", "words": [{"w": "•", "b": [0.16, 0.4972, 0.1682, 0.5186]}, {"w": "Spectral", "b": [0.1786, 0.497, 0.2429, 0.5186]}, {"w": "clustering:", "b": [0.2489, 0.497, 0.3316, 0.5186]}, {"w": "this", "b": [0.3375, 0.4972, 0.3683, 0.5186]}, {"w": "algorithm", "b": [0.3742, 0.4972, 0.4568, 0.5186]}, {"w": "takes", "b": [0.4628, 0.4972, 0.5051, 0.5186]}, {"w": "a", "b": [0.5111, 0.4972, 0.5202, 0.5186]}, {"w": "similarity", "b": [0.5262, 0.4972, 0.6057, 0.5186]}, {"w": "matrix", "b": [0.6116, 0.4972, 0.667, 0.5186]}, {"w": "between", "b": [0.6729, 0.4972, 0.7421, 0.5186]}, {"w": "the", "b": [0.748, 0.4972, 0.7744, 0.5186]}, {"w": "instances", "b": [0.7803, 0.4972, 0.8571, 0.5186]}, {"w": "and", "b": [0.1786, 0.5163, 0.2101, 0.5377]}, {"w": "creates", "b": [0.216, 0.5163, 0.273, 0.5377]}, {"w": "a", "b": [0.2788, 0.5163, 0.2879, 0.5377]}, {"w": "low-dimensional", "b": [0.2938, 0.5163, 0.4349, 0.5377]}, {"w": "embedding", "b": [0.4408, 0.5163, 0.5348, 0.5377]}, {"w": "from", "b": [0.5407, 0.5163, 0.5823, 0.5377]}, {"w": "it", "b": [0.5881, 0.5163, 0.6, 0.5377]}, {"w": "(i.e.,", "b": [0.6059, 0.5163, 0.6418, 0.5377]}, {"w": "it", "b": [0.6476, 0.5163, 0.6595, 0.5377]}, {"w": "reduces", "b": [0.6654, 0.5163, 0.7293, 0.5377]}, {"w": "its", "b": [0.7352, 0.5163, 0.7547, 0.5377]}, {"w": "dimension‐", "b": [0.7606, 0.5163, 0.8571, 0.5377]}, {"w": "ality),", "b": [0.1786, 0.5353, 0.2264, 0.5567]}, {"w": "then", "b": [0.2346, 0.5353, 0.2723, 0.5567]}, {"w": "it", "b": [0.2804, 0.5353, 0.2924, 0.5567]}, {"w": "uses", "b": [0.3005, 0.5353, 0.3357, 0.5567]}, {"w": "another", "b": [0.3438, 0.5353, 0.4091, 0.5567]}, {"w": "clustering", "b": [0.4172, 0.5353, 0.4996, 0.5567]}, {"w": "algorithm", "b": [0.5078, 0.5353, 0.5904, 0.5567]}, {"w": "in", "b": [0.5985, 0.5353, 0.6155, 0.5567]}, {"w": "this", "b": [0.6236, 0.5353, 0.6544, 0.5567]}, {"w": "low-dimensional", "b": [0.6625, 0.5353, 0.8036, 0.5567]}, {"w": "space", "b": [0.8118, 0.5353, 0.8571, 0.5567]}, {"w": "(Scikit-Learn’s", "b": [0.1786, 0.5543, 0.2967, 0.5758]}, {"w": "implementation", "b": [0.3056, 0.5543, 0.4388, 0.5758]}, {"w": "uses", "b": [0.4477, 0.5543, 0.4829, 0.5758]}, {"w": "K-Means).", "b": [0.4918, 0.5543, 0.5803, 0.5758]}, {"w": "Spectral", "b": [0.5892, 0.5543, 0.6562, 0.5758]}, {"w": "clustering", "b": [0.6651, 0.5543, 0.7475, 0.5758]}, {"w": "can", "b": [0.7564, 0.5543, 0.7858, 0.5758]}, {"w": "capture", "b": [0.7947, 0.5543, 0.8571, 0.5758]}, {"w": "complex", "b": [0.1786, 0.5734, 0.2496, 0.5948]}, {"w": "cluster", "b": [0.2553, 0.5734, 0.311, 0.5948]}, {"w": "structures,", "b": [0.3167, 0.5734, 0.4047, 0.5948]}, {"w": "and", "b": [0.4104, 0.5734, 0.4419, 0.5948]}, {"w": "it", "b": [0.4476, 0.5734, 0.4595, 0.5948]}, {"w": "can", "b": [0.4652, 0.5734, 0.4946, 0.5948]}, {"w": "also", "b": [0.5003, 0.5734, 0.533, 0.5948]}, {"w": "be", "b": [0.5387, 0.5734, 0.5581, 0.5948]}, {"w": "used", "b": [0.5638, 0.5734, 0.6024, 0.5948]}, {"w": "to", "b": [0.6081, 0.5734, 0.625, 0.5948]}, {"w": "cut", "b": [0.6307, 0.5734, 0.657, 0.5948]}, {"w": "graphs", "b": [0.6627, 0.5734, 0.7186, 0.5948]}, {"w": "(e.g.,", "b": [0.7243, 0.5734, 0.7643, 0.5948]}, {"w": "to", "b": [0.77, 0.5734, 0.787, 0.5948]}, {"w": "identify", "b": [0.7927, 0.5734, 0.8572, 0.5948]}, {"w": "clusters", "b": [0.1786, 0.5924, 0.2419, 0.6139]}, {"w": "of", "b": [0.2491, 0.5924, 0.2658, 0.6139]}, {"w": "friends", "b": [0.273, 0.5924, 0.3313, 0.6139]}, {"w": "on", "b": [0.3385, 0.5924, 0.3605, 0.6139]}, {"w": "a", "b": [0.3676, 0.5924, 0.3767, 0.6139]}, {"w": "social", "b": [0.3838, 0.5924, 0.4309, 0.6139]}, {"w": "network),", "b": [0.438, 0.5924, 0.5196, 0.6139]}, {"w": "however", "b": [0.5267, 0.5924, 0.5978, 0.6139]}, {"w": "it", "b": [0.6049, 0.5924, 0.6168, 0.6139]}, {"w": "does", "b": [0.6239, 0.5924, 0.6621, 0.6139]}, {"w": "not", "b": [0.6692, 0.5924, 0.6976, 0.6139]}, {"w": "scale", "b": [0.7047, 0.5924, 0.7444, 0.6139]}, {"w": "well", "b": [0.7515, 0.5924, 0.7852, 0.6139]}, {"w": "to", "b": [0.7923, 0.5924, 0.8093, 0.6139]}, {"w": "large", "b": [0.8164, 0.5924, 0.8571, 0.6139]}, {"w": "number", "b": [0.1786, 0.6115, 0.2449, 0.6329]}, {"w": "of", "b": [0.25, 0.6115, 0.2668, 0.6329]}, {"w": "instances,", "b": [0.272, 0.6115, 0.3535, 0.6329]}, {"w": "and", "b": [0.3587, 0.6115, 0.3902, 0.6329]}, {"w": "it", "b": [0.3954, 0.6115, 0.4073, 0.6329]}, {"w": "does", "b": [0.4125, 0.6115, 0.4506, 0.6329]}, {"w": "not", "b": [0.4558, 0.6115, 0.4841, 0.6329]}, {"w": "behave", "b": [0.4893, 0.6115, 0.5471, 0.6329]}, {"w": "well", "b": [0.5523, 0.6115, 0.5859, 0.6329]}, {"w": "when", "b": [0.5911, 0.6115, 0.6367, 0.6329]}, {"w": "the", "b": [0.6419, 0.6115, 0.6682, 0.6329]}, {"w": "clusters", "b": [0.6734, 0.6115, 0.7367, 0.6329]}, {"w": "have", "b": [0.7419, 0.6115, 0.7803, 0.6329]}, {"w": "very", "b": [0.7854, 0.6115, 0.8218, 0.6329]}, {"w": "dif‐", "b": [0.827, 0.6115, 0.8571, 0.6329]}, {"w": "ferent", "b": [0.1786, 0.6305, 0.2275, 0.6519]}, {"w": "sizes.", "b": [0.2323, 0.6305, 0.2755, 0.6519]}]}, {"id": "b_4", "type": "paragraph", "text": "Now let’s dive into Gaussian mixture models, which can be used for density estima‐ tion, clustering and anomaly detection.", "words": [{"w": "Now", "b": [0.1429, 0.6647, 0.1827, 0.6861]}, {"w": "let’s", "b": [0.1891, 0.6647, 0.2193, 0.6861]}, {"w": "dive", "b": [0.2256, 0.6647, 0.2607, 0.6861]}, {"w": "into", "b": [0.2671, 0.6647, 0.3006, 0.6861]}, {"w": "Gaussian", "b": [0.307, 0.6647, 0.3831, 0.6861]}, {"w": "mixture", "b": [0.3894, 0.6647, 0.4559, 0.6861]}, {"w": "models,", "b": [0.4623, 0.6647, 0.5275, 0.6861]}, {"w": "which", "b": [0.5338, 0.6647, 0.5847, 0.6861]}, {"w": "can", "b": [0.5911, 0.6647, 0.6204, 0.6861]}, {"w": "be", "b": [0.6268, 0.6647, 0.6462, 0.6861]}, {"w": "used", "b": [0.6526, 0.6647, 0.6911, 0.6861]}, {"w": "for", "b": [0.6975, 0.6647, 0.722, 0.6861]}, {"w": "density", "b": [0.7283, 0.6647, 0.7887, 0.6861]}, {"w": "estima‐", "b": [0.7951, 0.6647, 0.8571, 0.6861]}, {"w": "tion,", "b": [0.1429, 0.6837, 0.1816, 0.7052]}, {"w": "clustering", "b": [0.1863, 0.6837, 0.2687, 0.7052]}, {"w": "and", "b": [0.2735, 0.6837, 0.305, 0.7052]}, {"w": "anomaly", "b": [0.3097, 0.6837, 0.382, 0.7052]}, {"w": "detection.", "b": [0.3867, 0.6837, 0.4693, 0.7052]}]}, {"id": "b_5", "type": "paragraph", "text": "Gaussian Mixtures", "words": [{"w": "Gaussian", "b": [0.1429, 0.7182, 0.2529, 0.7524]}, {"w": "Mixtures", "b": [0.2588, 0.7182, 0.3671, 0.7524]}]}, {"id": "b_6", "type": "paragraph", "text": "A Gaussian mixture model (GMM) is a probabilistic model that assumes that the instances were generated from a mixture of several Gaussian distributions whose parameters are unknown. All the instances generated from a single Gaussian distri‐ bution form a cluster that typically looks like an ellipsoid. Each cluster can have a dif‐ ferent ellipsoidal shape, size, density and orientation, just like in Figure 9-11. When you observe an instance, you know it was generated from one of the Gaussian distri‐", "words": [{"w": "A", "b": [0.1429, 0.7593, 0.1573, 0.7807]}, {"w": "Gaussian", "b": [0.1659, 0.7591, 0.2414, 0.7807]}, {"w": "mixture", "b": [0.2501, 0.7591, 0.3143, 0.7807]}, {"w": "model", "b": [0.323, 0.7591, 0.3727, 0.7807]}, {"w": "(GMM)", "b": [0.3813, 0.7593, 0.4477, 0.7807]}, {"w": "is", "b": [0.4564, 0.7593, 0.4696, 0.7807]}, {"w": "a", "b": [0.4783, 0.7593, 0.4874, 0.7807]}, {"w": "probabilistic", "b": [0.4961, 0.7593, 0.6005, 0.7807]}, {"w": "model", "b": [0.6092, 0.7593, 0.662, 0.7807]}, {"w": "that", "b": [0.6706, 0.7593, 0.7032, 0.7807]}, {"w": "assumes", "b": [0.7119, 0.7593, 0.7809, 0.7807]}, {"w": "that", "b": [0.7896, 0.7593, 0.8222, 0.7807]}, {"w": "the", "b": [0.8308, 0.7593, 0.8571, 0.7807]}, {"w": "instances", "b": [0.1429, 0.7784, 0.2197, 0.7998]}, {"w": "were", "b": [0.2286, 0.7784, 0.2683, 0.7998]}, {"w": "generated", "b": [0.2772, 0.7784, 0.3588, 0.7998]}, {"w": "from", "b": [0.3677, 0.7784, 0.4093, 0.7998]}, {"w": "a", "b": [0.4182, 0.7784, 0.4274, 0.7998]}, {"w": "mixture", "b": [0.4363, 0.7784, 0.5028, 0.7998]}, {"w": "of", "b": [0.5117, 0.7784, 0.5285, 0.7998]}, {"w": "several", "b": [0.5374, 0.7784, 0.5946, 0.7998]}, {"w": "Gaussian", "b": [0.6035, 0.7784, 0.6796, 0.7998]}, {"w": "distributions", "b": [0.6885, 0.7784, 0.7957, 0.7998]}, {"w": "whose", "b": [0.8046, 0.7784, 0.8571, 0.7998]}, {"w": "parameters", "b": [0.1429, 0.7974, 0.2363, 0.8188]}, {"w": "are", "b": [0.243, 0.7974, 0.2687, 0.8188]}, {"w": "unknown.", "b": [0.2754, 0.7974, 0.3606, 0.8188]}, {"w": "All", "b": [0.3673, 0.7974, 0.3923, 0.8188]}, {"w": "the", "b": [0.399, 0.7974, 0.4253, 0.8188]}, {"w": "instances", "b": [0.432, 0.7974, 0.5088, 0.8188]}, {"w": "generated", "b": [0.5155, 0.7974, 0.597, 0.8188]}, {"w": "from", "b": [0.6037, 0.7974, 0.6453, 0.8188]}, {"w": "a", "b": [0.652, 0.7974, 0.6611, 0.8188]}, {"w": "single", "b": [0.6678, 0.7974, 0.7163, 0.8188]}, {"w": "Gaussian", "b": [0.723, 0.7974, 0.7991, 0.8188]}, {"w": "distri‐", "b": [0.8058, 0.7974, 0.8572, 0.8188]}, {"w": "bution", "b": [0.1429, 0.8165, 0.1985, 0.8379]}, {"w": "form", "b": [0.2035, 0.8165, 0.245, 0.8379]}, {"w": "a", "b": [0.25, 0.8165, 0.2592, 0.8379]}, {"w": "cluster", "b": [0.2642, 0.8165, 0.3199, 0.8379]}, {"w": "that", "b": [0.3249, 0.8165, 0.3575, 0.8379]}, {"w": "typically", "b": [0.3625, 0.8165, 0.4329, 0.8379]}, {"w": "looks", "b": [0.4379, 0.8165, 0.4824, 0.8379]}, {"w": "like", "b": [0.4874, 0.8165, 0.5175, 0.8379]}, {"w": "an", "b": [0.5225, 0.8165, 0.543, 0.8379]}, {"w": "ellipsoid.", "b": [0.548, 0.8165, 0.6235, 0.8379]}, {"w": "Each", "b": [0.6285, 0.8165, 0.6694, 0.8379]}, {"w": "cluster", "b": [0.6744, 0.8165, 0.7301, 0.8379]}, {"w": "can", "b": [0.7351, 0.8165, 0.7645, 0.8379]}, {"w": "have", "b": [0.7695, 0.8165, 0.8078, 0.8379]}, {"w": "a", "b": [0.8128, 0.8165, 0.822, 0.8379]}, {"w": "dif‐", "b": [0.827, 0.8165, 0.8571, 0.8379]}, {"w": "ferent", "b": [0.1429, 0.8355, 0.1918, 0.8569]}, {"w": "ellipsoidal", "b": [0.1983, 0.8355, 0.2835, 0.8569]}, {"w": "shape,", "b": [0.2899, 0.8355, 0.342, 0.8569]}, {"w": "size,", "b": [0.3485, 0.8355, 0.3841, 0.8569]}, {"w": "density", "b": [0.3905, 0.8355, 0.4509, 0.8569]}, {"w": "and", "b": [0.4574, 0.8355, 0.489, 0.8569]}, {"w": "orientation,", "b": [0.4954, 0.8355, 0.593, 0.8569]}, {"w": "just", "b": [0.5995, 0.8355, 0.6299, 0.8569]}, {"w": "like", "b": [0.6364, 0.8355, 0.6665, 0.8569]}, {"w": "in", "b": [0.6729, 0.8355, 0.6899, 0.8569]}, {"w": "Figure", "b": [0.6964, 0.8355, 0.7504, 0.8569]}, {"w": "9-11.", "b": [0.7569, 0.8355, 0.7991, 0.8569]}, {"w": "When", "b": [0.8055, 0.8355, 0.8571, 0.8569]}, {"w": "you", "b": [0.1428, 0.8546, 0.1741, 0.876]}, {"w": "observe", "b": [0.1797, 0.8546, 0.2443, 0.876]}, {"w": "an", "b": [0.2499, 0.8546, 0.2704, 0.876]}, {"w": "instance,", "b": [0.276, 0.8546, 0.35, 0.876]}, {"w": "you", "b": [0.3556, 0.8546, 0.3868, 0.876]}, {"w": "know", "b": [0.3924, 0.8546, 0.4391, 0.876]}, {"w": "it", "b": [0.4447, 0.8546, 0.4566, 0.876]}, {"w": "was", "b": [0.4622, 0.8546, 0.4933, 0.876]}, {"w": "generated", "b": [0.4989, 0.8546, 0.5804, 0.876]}, {"w": "from", "b": [0.586, 0.8546, 0.6276, 0.876]}, {"w": "one", "b": [0.6332, 0.8546, 0.6641, 0.876]}, {"w": "of", "b": [0.6697, 0.8546, 0.6865, 0.876]}, {"w": "the", "b": [0.6921, 0.8546, 0.7185, 0.876]}, {"w": "Gaussian", "b": [0.7241, 0.8546, 0.8002, 0.876]}, {"w": "distri‐", "b": [0.8058, 0.8546, 0.8571, 0.876]}]}, {"id": "b_7", "type": "paragraph", "text": "260 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "260", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 287, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "7 Phi (ϕ or φ) is the 21st letter of the Greek alphabet.", "words": [{"w": "7", "b": [0.1451, 0.8416, 0.1518, 0.8559]}, {"w": "Phi", "b": [0.1587, 0.8401, 0.1804, 0.8565]}, {"w": "(ϕ", "b": [0.184, 0.8401, 0.1987, 0.8565]}, {"w": "or", "b": [0.2023, 0.8401, 0.2163, 0.8565]}, {"w": "φ)", "b": [0.2199, 0.8401, 0.2347, 0.8565]}, {"w": "is", "b": [0.2383, 0.8401, 0.2484, 0.8565]}, {"w": "the", "b": [0.252, 0.8401, 0.2721, 0.8565]}, {"w": "21st", "b": [0.2757, 0.8387, 0.2993, 0.8565]}, {"w": "letter", "b": [0.3029, 0.8401, 0.336, 0.8565]}, {"w": "of", "b": [0.3396, 0.8401, 0.3524, 0.8565]}, {"w": "the", "b": [0.356, 0.8401, 0.3761, 0.8565]}, {"w": "Greek", "b": [0.3797, 0.8401, 0.4183, 0.8565]}, {"w": "alphabet.", "b": [0.4219, 0.8401, 0.4799, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "8 Most of these notations are standard, but a few additional notations were taken from the Wikipedia article on plate notation.", "words": [{"w": "8", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Most", "b": [0.1587, 0.8598, 0.1912, 0.8761]}, {"w": "of", "b": [0.1948, 0.8598, 0.2076, 0.8761]}, {"w": "these", "b": [0.2112, 0.8598, 0.2439, 0.8761]}, {"w": "notations", "b": [0.2475, 0.8598, 0.3074, 0.8761]}, {"w": "are", "b": [0.311, 0.8598, 0.3307, 0.8761]}, {"w": "standard,", "b": [0.3343, 0.8598, 0.3938, 0.8761]}, {"w": "but", "b": [0.3974, 0.8598, 0.4187, 0.8761]}, {"w": "a", "b": [0.4223, 0.8598, 0.4293, 0.8761]}, {"w": "few", "b": [0.4329, 0.8598, 0.4552, 0.8761]}, {"w": "additional", "b": [0.4588, 0.8598, 0.5237, 0.8761]}, {"w": "notations", "b": [0.5273, 0.8598, 0.5873, 0.8761]}, {"w": "were", "b": [0.5909, 0.8598, 0.6211, 0.8761]}, {"w": "taken", "b": [0.6247, 0.8598, 0.6598, 0.8761]}, {"w": "from", "b": [0.6634, 0.8598, 0.6951, 0.8761]}, {"w": "the", "b": [0.6987, 0.8598, 0.7188, 0.8761]}, {"w": "Wikipedia", "b": [0.7224, 0.8598, 0.7882, 0.8761]}, {"w": "article", "b": [0.7918, 0.8598, 0.8312, 0.8761]}, {"w": "on", "b": [0.8348, 0.8598, 0.8516, 0.8761]}, {"w": "plate", "b": [0.1587, 0.8749, 0.1893, 0.8912]}, {"w": "notation.", "b": [0.1929, 0.8749, 0.2507, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "butions, but you are not told which one, and you do not know what the parameters of these distributions are.", "words": [{"w": "butions,", "b": [0.1429, 0.0791, 0.2109, 0.1005]}, {"w": "but", "b": [0.2157, 0.0791, 0.2437, 0.1005]}, {"w": "you", "b": [0.2484, 0.0791, 0.2797, 0.1005]}, {"w": "are", "b": [0.2845, 0.0791, 0.3102, 0.1005]}, {"w": "not", "b": [0.315, 0.0791, 0.3434, 0.1005]}, {"w": "told", "b": [0.3482, 0.0791, 0.3814, 0.1005]}, {"w": "which", "b": [0.3862, 0.0791, 0.4371, 0.1005]}, {"w": "one,", "b": [0.4419, 0.0791, 0.4775, 0.1005]}, {"w": "and", "b": [0.4823, 0.0791, 0.5139, 0.1005]}, {"w": "you", "b": [0.5187, 0.0791, 0.5499, 0.1005]}, {"w": "do", "b": [0.5547, 0.0791, 0.5763, 0.1005]}, {"w": "not", "b": [0.5811, 0.0791, 0.6095, 0.1005]}, {"w": "know", "b": [0.6143, 0.0791, 0.6609, 0.1005]}, {"w": "what", "b": [0.6657, 0.0791, 0.7062, 0.1005]}, {"w": "the", "b": [0.711, 0.0791, 0.7373, 0.1005]}, {"w": "parameters", "b": [0.7421, 0.0791, 0.8356, 0.1005]}, {"w": "of", "b": [0.8404, 0.0791, 0.8572, 0.1005]}, {"w": "these", "b": [0.1429, 0.0981, 0.1857, 0.1195]}, {"w": "distributions", "b": [0.1904, 0.0981, 0.2976, 0.1195]}, {"w": "are.", "b": [0.3023, 0.0981, 0.3328, 0.1195]}]}, {"id": "b_3", "type": "paragraph", "text": "There are several GMM variants: in the simplest variant, implemented in the Gaus sianMixture class, you must know in advance the number k of Gaussian distribu‐ tions. The dataset X is assumed to have been generated through the following probabilistic process:", "words": [{"w": "There", "b": [0.1429, 0.1271, 0.1923, 0.1485]}, {"w": "are", "b": [0.1996, 0.1271, 0.2253, 0.1485]}, {"w": "several", "b": [0.2326, 0.1271, 0.2898, 0.1485]}, {"w": "GMM", "b": [0.2971, 0.1271, 0.3491, 0.1485]}, {"w": "variants:", "b": [0.3564, 0.1271, 0.4274, 0.1485]}, {"w": "in", "b": [0.4347, 0.1271, 0.4517, 0.1485]}, {"w": "the", "b": [0.459, 0.1271, 0.4853, 0.1485]}, {"w": "simplest", "b": [0.4926, 0.1271, 0.5615, 0.1485]}, {"w": "variant,", "b": [0.5688, 0.1271, 0.6322, 0.1485]}, {"w": "implemented", "b": [0.6395, 0.1271, 0.7499, 0.1485]}, {"w": "in", "b": [0.7572, 0.1271, 0.7742, 0.1485]}, {"w": "the", "b": [0.7815, 0.1271, 0.8078, 0.1485]}, {"w": "Gaus", "b": [0.8151, 0.1303, 0.8547, 0.1454]}, {"w": "sianMixture", "b": [0.1429, 0.1503, 0.2517, 0.1653]}, {"w": "class,", "b": [0.2591, 0.1471, 0.3024, 0.1685]}, {"w": "you", "b": [0.3099, 0.1471, 0.3411, 0.1685]}, {"w": "must", "b": [0.3486, 0.1471, 0.3903, 0.1685]}, {"w": "know", "b": [0.3977, 0.1471, 0.4443, 0.1685]}, {"w": "in", "b": [0.4518, 0.1471, 0.4688, 0.1685]}, {"w": "advance", "b": [0.4762, 0.1471, 0.5442, 0.1685]}, {"w": "the", "b": [0.5516, 0.1471, 0.578, 0.1685]}, {"w": "number", "b": [0.5854, 0.1471, 0.6517, 0.1685]}, {"w": "k", "b": [0.6592, 0.1469, 0.6689, 0.1685]}, {"w": "of", "b": [0.6764, 0.1471, 0.6932, 0.1685]}, {"w": "Gaussian", "b": [0.7006, 0.1471, 0.7767, 0.1685]}, {"w": "distribu‐", "b": [0.7842, 0.1471, 0.8571, 0.1685]}, {"w": "tions.", "b": [0.1428, 0.1661, 0.1892, 0.1875]}, {"w": "The", "b": [0.1998, 0.1661, 0.2326, 0.1875]}, {"w": "dataset", "b": [0.2432, 0.1661, 0.3013, 0.1875]}, {"w": "X", "b": [0.312, 0.1656, 0.3264, 0.1875]}, {"w": "is", "b": [0.337, 0.1661, 0.3502, 0.1875]}, {"w": "assumed", "b": [0.3608, 0.1661, 0.4332, 0.1875]}, {"w": "to", "b": [0.4438, 0.1661, 0.4608, 0.1875]}, {"w": "have", "b": [0.4714, 0.1661, 0.5098, 0.1875]}, {"w": "been", "b": [0.5204, 0.1661, 0.5601, 0.1875]}, {"w": "generated", "b": [0.5707, 0.1661, 0.6523, 0.1875]}, {"w": "through", "b": [0.6629, 0.1661, 0.7306, 0.1875]}, {"w": "the", "b": [0.7412, 0.1661, 0.7676, 0.1875]}, {"w": "following", "b": [0.7782, 0.1661, 0.8571, 0.1875]}, {"w": "probabilistic", "b": [0.1429, 0.1852, 0.2473, 0.2066]}, {"w": "process:", "b": [0.252, 0.1852, 0.319, 0.2066]}]}, {"id": "b_4", "type": "paragraph", "text": "• For each instance, a cluster is picked randomly among k clusters. The probability of choosing the jth cluster is defined by the cluster’s weight ϕ(j).7 The index of the cluster chosen for the ith instance is noted z(i).", "words": [{"w": "•", "b": [0.16, 0.2193, 0.1682, 0.2407]}, {"w": "For", "b": [0.1786, 0.2193, 0.2075, 0.2407]}, {"w": "each", "b": [0.2127, 0.2193, 0.2506, 0.2407]}, {"w": "instance,", "b": [0.2558, 0.2193, 0.3297, 0.2407]}, {"w": "a", "b": [0.3348, 0.2193, 0.344, 0.2407]}, {"w": "cluster", "b": [0.3491, 0.2193, 0.4048, 0.2407]}, {"w": "is", "b": [0.41, 0.2193, 0.4232, 0.2407]}, {"w": "picked", "b": [0.4284, 0.2193, 0.4839, 0.2407]}, {"w": "randomly", "b": [0.489, 0.2193, 0.5708, 0.2407]}, {"w": "among", "b": [0.5759, 0.2193, 0.6339, 0.2407]}, {"w": "k", "b": [0.639, 0.2191, 0.6488, 0.2407]}, {"w": "clusters.", "b": [0.654, 0.2193, 0.7221, 0.2407]}, {"w": "The", "b": [0.7272, 0.2193, 0.7601, 0.2407]}, {"w": "probability", "b": [0.7652, 0.2193, 0.8571, 0.2407]}, {"w": "of", "b": [0.1786, 0.2384, 0.1954, 0.2598]}, {"w": "choosing", "b": [0.2012, 0.2384, 0.2767, 0.2598]}, {"w": "the", "b": [0.2826, 0.2384, 0.3089, 0.2598]}, {"w": "jth", "b": [0.3147, 0.2382, 0.3307, 0.2598]}, {"w": "cluster", "b": [0.3366, 0.2384, 0.3923, 0.2598]}, {"w": "is", "b": [0.3981, 0.2384, 0.4113, 0.2598]}, {"w": "defined", "b": [0.4172, 0.2384, 0.48, 0.2598]}, {"w": "by", "b": [0.4858, 0.2384, 0.506, 0.2598]}, {"w": "the", "b": [0.5118, 0.2384, 0.5381, 0.2598]}, {"w": "cluster’s", "b": [0.544, 0.2384, 0.61, 0.2598]}, {"w": "weight", "b": [0.6158, 0.2384, 0.6714, 0.2598]}, {"w": "ϕ(j).7", "b": [0.6772, 0.2382, 0.7112, 0.2598]}, {"w": "The", "b": [0.7171, 0.2384, 0.7499, 0.2598]}, {"w": "index", "b": [0.7557, 0.2384, 0.8024, 0.2598]}, {"w": "of", "b": [0.8082, 0.2384, 0.825, 0.2598]}, {"w": "the", "b": [0.8308, 0.2384, 0.8571, 0.2598]}, {"w": "cluster", "b": [0.1786, 0.2574, 0.2343, 0.2788]}, {"w": "chosen", "b": [0.239, 0.2574, 0.2975, 0.2788]}, {"w": "for", "b": [0.3022, 0.2574, 0.3267, 0.2788]}, {"w": "the", "b": [0.3315, 0.2574, 0.3578, 0.2788]}, {"w": "ith", "b": [0.3625, 0.2572, 0.3787, 0.2788]}, {"w": "instance", "b": [0.3834, 0.2574, 0.4526, 0.2788]}, {"w": "is", "b": [0.4574, 0.2574, 0.4706, 0.2788]}, {"w": "noted", "b": [0.4753, 0.2574, 0.5235, 0.2788]}, {"w": "z(i).", "b": [0.5283, 0.2572, 0.5538, 0.2788]}]}, {"id": "b_5", "type": "paragraph", "text": "• If z(i)=j, meaning the ith instance has been assigned to the jth cluster, the location x(i) of this instance is sampled randomly from the Gaussian distribution with mean μ(j) and covariance matrix Σ(j). This is noted �i ∼�μ j , Σ j .", "words": [{"w": "•", "b": [0.16, 0.2825, 0.1682, 0.3039]}, {"w": "If", "b": [0.1786, 0.2825, 0.1918, 0.3039]}, {"w": "z(i)=j,", "b": [0.198, 0.2823, 0.2412, 0.3039]}, {"w": "meaning", "b": [0.2473, 0.2825, 0.3205, 0.3039]}, {"w": "the", "b": [0.3267, 0.2825, 0.353, 0.3039]}, {"w": "ith", "b": [0.3592, 0.2823, 0.3754, 0.3039]}, {"w": "instance", "b": [0.3815, 0.2825, 0.4507, 0.3039]}, {"w": "has", "b": [0.4569, 0.2825, 0.4848, 0.3039]}, {"w": "been", "b": [0.491, 0.2825, 0.5307, 0.3039]}, {"w": "assigned", "b": [0.5368, 0.2825, 0.6079, 0.3039]}, {"w": "to", "b": [0.614, 0.2825, 0.631, 0.3039]}, {"w": "the", "b": [0.6372, 0.2825, 0.6635, 0.3039]}, {"w": "jth", "b": [0.6697, 0.2823, 0.6857, 0.3039]}, {"w": "cluster,", "b": [0.6919, 0.2825, 0.751, 0.3039]}, {"w": "the", "b": [0.7572, 0.2825, 0.7836, 0.3039]}, {"w": "location", "b": [0.7897, 0.2825, 0.8571, 0.3039]}, {"w": "x(i)", "b": [0.1786, 0.301, 0.2007, 0.323]}, {"w": "of", "b": [0.2093, 0.3016, 0.2261, 0.323]}, {"w": "this", "b": [0.2346, 0.3016, 0.2653, 0.323]}, {"w": "instance", "b": [0.2739, 0.3016, 0.3431, 0.323]}, {"w": "is", "b": [0.3517, 0.3016, 0.3649, 0.323]}, {"w": "sampled", "b": [0.3735, 0.3016, 0.443, 0.323]}, {"w": "randomly", "b": [0.4516, 0.3016, 0.5334, 0.323]}, {"w": "from", "b": [0.5419, 0.3016, 0.5835, 0.323]}, {"w": "the", "b": [0.5921, 0.3016, 0.6184, 0.323]}, {"w": "Gaussian", "b": [0.627, 0.3016, 0.7032, 0.323]}, {"w": "distribution", "b": [0.7117, 0.3016, 0.8112, 0.323]}, {"w": "with", "b": [0.8198, 0.3016, 0.8571, 0.323]}, {"w": "mean", "b": [0.1786, 0.3241, 0.225, 0.3455]}, {"w": "μ(j)", "b": [0.2297, 0.3235, 0.2529, 0.3455]}, {"w": "and", "b": [0.2577, 0.3241, 0.2892, 0.3455]}, {"w": "covariance", "b": [0.2939, 0.3241, 0.3837, 0.3455]}, {"w": "matrix", "b": [0.3884, 0.3241, 0.4437, 0.3455]}, {"w": "Σ(j).", "b": [0.4485, 0.3235, 0.4779, 0.3455]}, {"w": "This", "b": [0.4827, 0.3241, 0.5199, 0.3455]}, {"w": "is", "b": [0.5246, 0.3241, 0.5378, 0.3455]}, {"w": "noted", "b": [0.5426, 0.3241, 0.5908, 0.3455]}, {"w": "�i", "b": [0.5955, 0.3199, 0.6167, 0.3432]}, {"w": "∼�μ", "b": [0.628, 0.3239, 0.6905, 0.3455]}, {"w": "j", "b": [0.6976, 0.3208, 0.7018, 0.3372]}, {"w": ",", "b": [0.7073, 0.3241, 0.712, 0.3455]}, {"w": "Σ", "b": [0.7155, 0.3239, 0.7276, 0.3455]}, {"w": "j", "b": [0.7347, 0.3208, 0.7389, 0.3372]}, {"w": ".", "b": [0.7516, 0.3241, 0.7563, 0.3455]}]}, {"id": "b_6", "type": "paragraph", "text": "This generative process can be represented as a graphical model (see Figure 9-16). This is a graph which represents the structure of the conditional dependencies between random variables.", "words": [{"w": "This", "b": [0.1429, 0.3606, 0.1801, 0.382]}, {"w": "generative", "b": [0.1881, 0.3606, 0.2738, 0.382]}, {"w": "process", "b": [0.2819, 0.3606, 0.3441, 0.382]}, {"w": "can", "b": [0.3521, 0.3606, 0.3814, 0.382]}, {"w": "be", "b": [0.3894, 0.3606, 0.4089, 0.382]}, {"w": "represented", "b": [0.4169, 0.3606, 0.5147, 0.382]}, {"w": "as", "b": [0.5227, 0.3606, 0.5395, 0.382]}, {"w": "a", "b": [0.5475, 0.3606, 0.5566, 0.382]}, {"w": "graphical", "b": [0.5646, 0.3604, 0.6395, 0.382]}, {"w": "model", "b": [0.6476, 0.3604, 0.6972, 0.382]}, {"w": "(see", "b": [0.7052, 0.3606, 0.7378, 0.382]}, {"w": "Figure", "b": [0.7458, 0.3606, 0.7998, 0.382]}, {"w": "9-16).", "b": [0.8078, 0.3606, 0.8571, 0.382]}, {"w": "This", "b": [0.1429, 0.3797, 0.1801, 0.4011]}, {"w": "is", "b": [0.1906, 0.3797, 0.2038, 0.4011]}, {"w": "a", "b": [0.2144, 0.3797, 0.2235, 0.4011]}, {"w": "graph", "b": [0.2341, 0.3797, 0.2823, 0.4011]}, {"w": "which", "b": [0.2929, 0.3797, 0.3438, 0.4011]}, {"w": "represents", "b": [0.3543, 0.3797, 0.4399, 0.4011]}, {"w": "the", "b": [0.4504, 0.3797, 0.4768, 0.4011]}, {"w": "structure", "b": [0.4873, 0.3797, 0.5629, 0.4011]}, {"w": "of", "b": [0.5734, 0.3797, 0.5902, 0.4011]}, {"w": "the", "b": [0.6008, 0.3797, 0.6271, 0.4011]}, {"w": "conditional", "b": [0.6376, 0.3797, 0.7334, 0.4011]}, {"w": "dependencies", "b": [0.744, 0.3797, 0.8571, 0.4011]}, {"w": "between", "b": [0.1429, 0.3987, 0.212, 0.4201]}, {"w": "random", "b": [0.2167, 0.3987, 0.2837, 0.4201]}, {"w": "variables.", "b": [0.2884, 0.3987, 0.3668, 0.4201]}]}, {"id": "b_7", "type": "equation", "text": "Figure 9-16. Gaussian mixture model", "words": [{"w": "Figure", "b": [0.1429, 0.6499, 0.1943, 0.6715]}, {"w": "9-16.", "b": [0.1991, 0.6499, 0.2407, 0.6715]}, {"w": "Gaussian", "b": [0.2455, 0.6499, 0.321, 0.6715]}, {"w": "mixture", "b": [0.3258, 0.6499, 0.39, 0.6715]}, {"w": "model", "b": [0.3947, 0.6499, 0.4444, 0.6715]}]}, {"id": "b_8", "type": "paragraph", "text": "Here is how to interpret it:8", "words": [{"w": "Here", "b": [0.1429, 0.6873, 0.1837, 0.7087]}, {"w": "is", "b": [0.1885, 0.6873, 0.2017, 0.7087]}, {"w": "how", "b": [0.2064, 0.6873, 0.2424, 0.7087]}, {"w": "to", "b": [0.2472, 0.6873, 0.2641, 0.7087]}, {"w": "interpret", "b": [0.2689, 0.6873, 0.3422, 0.7087]}, {"w": "it:8", "b": [0.347, 0.6873, 0.3694, 0.7087]}]}, {"id": "b_9", "type": "paragraph", "text": "• The circles represent random variables.", "words": [{"w": "•", "b": [0.16, 0.7214, 0.1682, 0.7428]}, {"w": "The", "b": [0.1786, 0.7214, 0.2114, 0.7428]}, {"w": "circles", "b": [0.2161, 0.7214, 0.2688, 0.7428]}, {"w": "represent", "b": [0.2736, 0.7214, 0.3515, 0.7428]}, {"w": "random", "b": [0.3562, 0.7214, 0.4232, 0.7428]}, {"w": "variables.", "b": [0.4279, 0.7214, 0.5063, 0.7428]}]}, {"id": "b_10", "type": "paragraph", "text": "• The squares represent fixed values (i.e., parameters of the model).", "words": [{"w": "•", "b": [0.16, 0.7465, 0.1682, 0.7679]}, {"w": "The", "b": [0.1786, 0.7465, 0.2114, 0.7679]}, {"w": "squares", "b": [0.2161, 0.7465, 0.2789, 0.7679]}, {"w": "represent", "b": [0.2836, 0.7465, 0.3615, 0.7679]}, {"w": "fixed", "b": [0.3663, 0.7465, 0.4077, 0.7679]}, {"w": "values", "b": [0.4124, 0.7465, 0.464, 0.7679]}, {"w": "(i.e.,", "b": [0.4688, 0.7465, 0.5047, 0.7679]}, {"w": "parameters", "b": [0.5094, 0.7465, 0.6028, 0.7679]}, {"w": "of", "b": [0.6076, 0.7465, 0.6244, 0.7679]}, {"w": "the", "b": [0.6291, 0.7465, 0.6554, 0.7679]}, {"w": "model).", "b": [0.6601, 0.7465, 0.7249, 0.7679]}]}, {"id": "b_11", "type": "paragraph", "text": "Gaussian Mixtures | 261", "words": [{"w": "Gaussian", "b": [0.6892, 0.9225, 0.7415, 0.9388]}, {"w": "Mixtures", "b": [0.7443, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "261", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 288, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• The large rectangles are called plates: they indicate that their content is repeated several times.", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "The", "b": [0.1786, 0.0791, 0.2114, 0.1005]}, {"w": "large", "b": [0.2176, 0.0791, 0.2583, 0.1005]}, {"w": "rectangles", "b": [0.2645, 0.0791, 0.3483, 0.1005]}, {"w": "are", "b": [0.3545, 0.0791, 0.3802, 0.1005]}, {"w": "called", "b": [0.3864, 0.0791, 0.4348, 0.1005]}, {"w": "plates:", "b": [0.441, 0.0789, 0.4919, 0.1005]}, {"w": "they", "b": [0.498, 0.0791, 0.5339, 0.1005]}, {"w": "indicate", "b": [0.5401, 0.0791, 0.6065, 0.1005]}, {"w": "that", "b": [0.6126, 0.0791, 0.6452, 0.1005]}, {"w": "their", "b": [0.6514, 0.0791, 0.691, 0.1005]}, {"w": "content", "b": [0.6972, 0.0791, 0.7602, 0.1005]}, {"w": "is", "b": [0.7664, 0.0791, 0.7796, 0.1005]}, {"w": "repeated", "b": [0.7858, 0.0791, 0.8571, 0.1005]}, {"w": "several", "b": [0.1786, 0.0981, 0.2357, 0.1195]}, {"w": "times.", "b": [0.2404, 0.0981, 0.2907, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "• The number indicated at the bottom right hand side of each plate indicates how many times its content is repeated, so there are m random variables z(i) (from z(1)", "words": [{"w": "•", "b": [0.16, 0.1232, 0.1682, 0.1446]}, {"w": "The", "b": [0.1786, 0.1232, 0.2114, 0.1446]}, {"w": "number", "b": [0.2174, 0.1232, 0.2837, 0.1446]}, {"w": "indicated", "b": [0.2897, 0.1232, 0.3671, 0.1446]}, {"w": "at", "b": [0.3731, 0.1232, 0.3882, 0.1446]}, {"w": "the", "b": [0.3942, 0.1232, 0.4206, 0.1446]}, {"w": "bottom", "b": [0.4266, 0.1232, 0.4882, 0.1446]}, {"w": "right", "b": [0.4942, 0.1232, 0.5343, 0.1446]}, {"w": "hand", "b": [0.5404, 0.1232, 0.583, 0.1446]}, {"w": "side", "b": [0.5891, 0.1232, 0.6221, 0.1446]}, {"w": "of", "b": [0.6282, 0.1232, 0.645, 0.1446]}, {"w": "each", "b": [0.651, 0.1232, 0.6889, 0.1446]}, {"w": "plate", "b": [0.6949, 0.1232, 0.7351, 0.1446]}, {"w": "indicates", "b": [0.7411, 0.1232, 0.8151, 0.1446]}, {"w": "how", "b": [0.8211, 0.1232, 0.8571, 0.1446]}, {"w": "many", "b": [0.1786, 0.1423, 0.2253, 0.1637]}, {"w": "times", "b": [0.2308, 0.1423, 0.2763, 0.1637]}, {"w": "its", "b": [0.2819, 0.1423, 0.3014, 0.1637]}, {"w": "content", "b": [0.307, 0.1423, 0.37, 0.1637]}, {"w": "is", "b": [0.3755, 0.1423, 0.3888, 0.1637]}, {"w": "repeated,", "b": [0.3943, 0.1423, 0.4704, 0.1637]}, {"w": "so", "b": [0.4759, 0.1423, 0.4942, 0.1637]}, {"w": "there", "b": [0.4998, 0.1423, 0.5427, 0.1637]}, {"w": "are", "b": [0.5482, 0.1423, 0.574, 0.1637]}, {"w": "m", "b": [0.5795, 0.142, 0.5959, 0.1637]}, {"w": "random", "b": [0.6015, 0.1423, 0.6684, 0.1637]}, {"w": "variables", "b": [0.674, 0.1423, 0.7476, 0.1637]}, {"w": "z(i)", "b": [0.7531, 0.142, 0.7739, 0.1637]}, {"w": "(from", "b": [0.7794, 0.1423, 0.8282, 0.1637]}, {"w": "z(1)", "b": [0.8338, 0.142, 0.8571, 0.1637]}]}, {"id": "b_2", "type": "paragraph", "text": "to z(m)) and m random variables x(i), and k means μ(j) and k covariance matrices Σ(j), but just one weight vector ϕ (containing all the weights ϕ(1) to ϕ(k)).", "words": [{"w": "to", "b": [0.1786, 0.1613, 0.1955, 0.1827]}, {"w": "z(m))", "b": [0.2021, 0.1611, 0.2365, 0.1827]}, {"w": "and", "b": [0.243, 0.1613, 0.2746, 0.1827]}, {"w": "m", "b": [0.2811, 0.1611, 0.2975, 0.1827]}, {"w": "random", "b": [0.304, 0.1613, 0.371, 0.1827]}, {"w": "variables", "b": [0.3775, 0.1613, 0.4511, 0.1827]}, {"w": "x(i),", "b": [0.4576, 0.1607, 0.4845, 0.1827]}, {"w": "and", "b": [0.491, 0.1613, 0.5225, 0.1827]}, {"w": "k", "b": [0.529, 0.1611, 0.5388, 0.1827]}, {"w": "means", "b": [0.5454, 0.1613, 0.5995, 0.1827]}, {"w": "μ(j)", "b": [0.606, 0.1607, 0.6292, 0.1827]}, {"w": "and", "b": [0.6357, 0.1613, 0.6672, 0.1827]}, {"w": "k", "b": [0.6738, 0.1611, 0.6836, 0.1827]}, {"w": "covariance", "b": [0.6901, 0.1613, 0.7798, 0.1827]}, {"w": "matrices", "b": [0.7864, 0.1613, 0.8571, 0.1827]}, {"w": "Σ(j),", "b": [0.1786, 0.1798, 0.2081, 0.2018]}, {"w": "but", "b": [0.2128, 0.1803, 0.2408, 0.2018]}, {"w": "just", "b": [0.2455, 0.1803, 0.2759, 0.2018]}, {"w": "one", "b": [0.2806, 0.1803, 0.3115, 0.2018]}, {"w": "weight", "b": [0.3162, 0.1803, 0.3718, 0.2018]}, {"w": "vector", "b": [0.3765, 0.1803, 0.4285, 0.2018]}, {"w": "ϕ", "b": [0.4333, 0.1798, 0.4458, 0.2018]}, {"w": "(containing", "b": [0.4506, 0.1803, 0.5474, 0.2018]}, {"w": "all", "b": [0.5522, 0.1803, 0.5718, 0.2018]}, {"w": "the", "b": [0.5766, 0.1803, 0.6029, 0.2018]}, {"w": "weights", "b": [0.6076, 0.1803, 0.6708, 0.2018]}, {"w": "ϕ(1)", "b": [0.6756, 0.1801, 0.7018, 0.2018]}, {"w": "to", "b": [0.7066, 0.1803, 0.7235, 0.2018]}, {"w": "ϕ(k)).", "b": [0.7283, 0.1801, 0.7664, 0.2018]}]}, {"id": "b_3", "type": "paragraph", "text": "• Each variable z(i) is drawn from the categorical distribution with weights ϕ. Each variable x(i) is drawn from the normal distribution with the mean and covariance matrix defined by its cluster z(i).", "words": [{"w": "•", "b": [0.16, 0.2054, 0.1681, 0.2269]}, {"w": "Each", "b": [0.1786, 0.2054, 0.2195, 0.2269]}, {"w": "variable", "b": [0.2258, 0.2054, 0.2917, 0.2269]}, {"w": "z(i)", "b": [0.298, 0.2052, 0.3188, 0.2269]}, {"w": "is", "b": [0.3251, 0.2054, 0.3384, 0.2269]}, {"w": "drawn", "b": [0.3447, 0.2054, 0.3978, 0.2269]}, {"w": "from", "b": [0.4041, 0.2054, 0.4457, 0.2269]}, {"w": "the", "b": [0.452, 0.2054, 0.4784, 0.2269]}, {"w": "categorical", "b": [0.4847, 0.2052, 0.5713, 0.2269]}, {"w": "distribution", "b": [0.5776, 0.2052, 0.6731, 0.2269]}, {"w": "with", "b": [0.6795, 0.2054, 0.7168, 0.2269]}, {"w": "weights", "b": [0.7231, 0.2054, 0.7863, 0.2269]}, {"w": "ϕ.", "b": [0.7926, 0.2049, 0.8099, 0.2269]}, {"w": "Each", "b": [0.8162, 0.2054, 0.8571, 0.2269]}, {"w": "variable", "b": [0.1786, 0.2245, 0.2445, 0.2459]}, {"w": "x(i)", "b": [0.2499, 0.2239, 0.272, 0.2459]}, {"w": "is", "b": [0.2773, 0.2245, 0.2905, 0.2459]}, {"w": "drawn", "b": [0.2959, 0.2245, 0.349, 0.2459]}, {"w": "from", "b": [0.3544, 0.2245, 0.396, 0.2459]}, {"w": "the", "b": [0.4013, 0.2245, 0.4276, 0.2459]}, {"w": "normal", "b": [0.433, 0.2245, 0.4942, 0.2459]}, {"w": "distribution", "b": [0.4995, 0.2245, 0.599, 0.2459]}, {"w": "with", "b": [0.6044, 0.2245, 0.6417, 0.2459]}, {"w": "the", "b": [0.647, 0.2245, 0.6734, 0.2459]}, {"w": "mean", "b": [0.6787, 0.2245, 0.7252, 0.2459]}, {"w": "and", "b": [0.7305, 0.2245, 0.762, 0.2459]}, {"w": "covariance", "b": [0.7674, 0.2245, 0.8571, 0.2459]}, {"w": "matrix", "b": [0.1786, 0.2435, 0.2339, 0.2649]}, {"w": "defined", "b": [0.2386, 0.2435, 0.3015, 0.2649]}, {"w": "by", "b": [0.3062, 0.2435, 0.3263, 0.2649]}, {"w": "its", "b": [0.3311, 0.2435, 0.3507, 0.2649]}, {"w": "cluster", "b": [0.3554, 0.2435, 0.4111, 0.2649]}, {"w": "z(i).", "b": [0.4158, 0.2433, 0.4414, 0.2649]}]}, {"id": "b_4", "type": "paragraph", "text": "• The solid arrows represent conditional dependencies. For example, the probabil‐ ity distribution for each random variable z(i) depends on the weight vector ϕ. Note that when an arrow crosses a plate boundary, it means that it applies to all the repetitions of that plate, so for example the weight vector ϕ conditions the probability distributions of all the random variables x(1) to x(m).", "words": [{"w": "•", "b": [0.16, 0.2686, 0.1682, 0.29]}, {"w": "The", "b": [0.1786, 0.2686, 0.2114, 0.29]}, {"w": "solid", "b": [0.2169, 0.2686, 0.257, 0.29]}, {"w": "arrows", "b": [0.2625, 0.2686, 0.3196, 0.29]}, {"w": "represent", "b": [0.3251, 0.2686, 0.4031, 0.29]}, {"w": "conditional", "b": [0.4085, 0.2686, 0.5043, 0.29]}, {"w": "dependencies.", "b": [0.5098, 0.2686, 0.6277, 0.29]}, {"w": "For", "b": [0.6332, 0.2686, 0.6622, 0.29]}, {"w": "example,", "b": [0.6677, 0.2686, 0.742, 0.29]}, {"w": "the", "b": [0.7475, 0.2686, 0.7738, 0.29]}, {"w": "probabil‐", "b": [0.7793, 0.2686, 0.8571, 0.29]}, {"w": "ity", "b": [0.1786, 0.2877, 0.2001, 0.3091]}, {"w": "distribution", "b": [0.2083, 0.2877, 0.3078, 0.3091]}, {"w": "for", "b": [0.316, 0.2877, 0.3405, 0.3091]}, {"w": "each", "b": [0.3487, 0.2877, 0.3867, 0.3091]}, {"w": "random", "b": [0.3949, 0.2877, 0.4618, 0.3091]}, {"w": "variable", "b": [0.47, 0.2877, 0.536, 0.3091]}, {"w": "z(i)", "b": [0.5442, 0.2875, 0.565, 0.3091]}, {"w": "depends", "b": [0.5732, 0.2877, 0.6428, 0.3091]}, {"w": "on", "b": [0.6511, 0.2877, 0.6731, 0.3091]}, {"w": "the", "b": [0.6813, 0.2877, 0.7076, 0.3091]}, {"w": "weight", "b": [0.7158, 0.2877, 0.7714, 0.3091]}, {"w": "vector", "b": [0.7796, 0.2877, 0.8316, 0.3091]}, {"w": "ϕ.", "b": [0.8398, 0.2871, 0.8571, 0.3091]}, {"w": "Note", "b": [0.1786, 0.3067, 0.2194, 0.3281]}, {"w": "that", "b": [0.2254, 0.3067, 0.258, 0.3281]}, {"w": "when", "b": [0.2641, 0.3067, 0.3097, 0.3281]}, {"w": "an", "b": [0.3158, 0.3067, 0.3364, 0.3281]}, {"w": "arrow", "b": [0.3424, 0.3067, 0.3919, 0.3281]}, {"w": "crosses", "b": [0.398, 0.3067, 0.457, 0.3281]}, {"w": "a", "b": [0.463, 0.3067, 0.4722, 0.3281]}, {"w": "plate", "b": [0.4783, 0.3067, 0.5184, 0.3281]}, {"w": "boundary,", "b": [0.5245, 0.3067, 0.6094, 0.3281]}, {"w": "it", "b": [0.6155, 0.3067, 0.6274, 0.3281]}, {"w": "means", "b": [0.6335, 0.3067, 0.6876, 0.3281]}, {"w": "that", "b": [0.6937, 0.3067, 0.7263, 0.3281]}, {"w": "it", "b": [0.7324, 0.3067, 0.7443, 0.3281]}, {"w": "applies", "b": [0.7504, 0.3067, 0.8083, 0.3281]}, {"w": "to", "b": [0.8144, 0.3067, 0.8314, 0.3281]}, {"w": "all", "b": [0.8374, 0.3067, 0.8571, 0.3281]}, {"w": "the", "b": [0.1786, 0.3258, 0.2049, 0.3472]}, {"w": "repetitions", "b": [0.2121, 0.3258, 0.302, 0.3472]}, {"w": "of", "b": [0.3092, 0.3258, 0.326, 0.3472]}, {"w": "that", "b": [0.3333, 0.3258, 0.3658, 0.3472]}, {"w": "plate,", "b": [0.3731, 0.3258, 0.418, 0.3472]}, {"w": "so", "b": [0.4252, 0.3258, 0.4435, 0.3472]}, {"w": "for", "b": [0.4507, 0.3258, 0.4752, 0.3472]}, {"w": "example", "b": [0.4824, 0.3258, 0.552, 0.3472]}, {"w": "the", "b": [0.5592, 0.3258, 0.5855, 0.3472]}, {"w": "weight", "b": [0.5927, 0.3258, 0.6483, 0.3472]}, {"w": "vector", "b": [0.6555, 0.3258, 0.7075, 0.3472]}, {"w": "ϕ", "b": [0.7148, 0.3252, 0.7273, 0.3472]}, {"w": "conditions", "b": [0.7346, 0.3258, 0.8236, 0.3472]}, {"w": "the", "b": [0.8308, 0.3258, 0.8571, 0.3472]}, {"w": "probability", "b": [0.1786, 0.3448, 0.2705, 0.3662]}, {"w": "distributions", "b": [0.2752, 0.3448, 0.3824, 0.3662]}, {"w": "of", "b": [0.3871, 0.3448, 0.4039, 0.3662]}, {"w": "all", "b": [0.4086, 0.3448, 0.4283, 0.3662]}, {"w": "the", "b": [0.4331, 0.3448, 0.4594, 0.3662]}, {"w": "random", "b": [0.4641, 0.3448, 0.5311, 0.3662]}, {"w": "variables", "b": [0.5358, 0.3448, 0.6094, 0.3662]}, {"w": "x(1)", "b": [0.6141, 0.3443, 0.6388, 0.3662]}, {"w": "to", "b": [0.6435, 0.3448, 0.6605, 0.3662]}, {"w": "x(m).", "b": [0.6653, 0.3443, 0.6985, 0.3662]}]}, {"id": "b_5", "type": "paragraph", "text": "• The squiggly arrow from z(i) to x(i) represents a switch: depending on the value of z(i), the instance x(i) will be sampled from a different Gaussian distribution. For example, if z(i)=j, then �i ∼�μ j , Σ j .", "words": [{"w": "•", "b": [0.16, 0.3699, 0.1681, 0.3913]}, {"w": "The", "b": [0.1786, 0.3699, 0.2114, 0.3913]}, {"w": "squiggly", "b": [0.2167, 0.3699, 0.286, 0.3913]}, {"w": "arrow", "b": [0.2913, 0.3699, 0.3408, 0.3913]}, {"w": "from", "b": [0.3461, 0.3699, 0.3877, 0.3913]}, {"w": "z(i)", "b": [0.393, 0.3697, 0.4138, 0.3913]}, {"w": "to", "b": [0.4191, 0.3699, 0.4361, 0.3913]}, {"w": "x(i)", "b": [0.4414, 0.3694, 0.4635, 0.3913]}, {"w": "represents", "b": [0.4688, 0.3699, 0.5544, 0.3913]}, {"w": "a", "b": [0.5597, 0.3699, 0.5689, 0.3913]}, {"w": "switch:", "b": [0.5742, 0.3699, 0.6327, 0.3913]}, {"w": "depending", "b": [0.638, 0.3699, 0.7268, 0.3913]}, {"w": "on", "b": [0.7321, 0.3699, 0.7541, 0.3913]}, {"w": "the", "b": [0.7594, 0.3699, 0.7858, 0.3913]}, {"w": "value", "b": [0.7911, 0.3699, 0.835, 0.3913]}, {"w": "of", "b": [0.8404, 0.3699, 0.8571, 0.3913]}, {"w": "z(i),", "b": [0.1786, 0.3888, 0.2041, 0.4104]}, {"w": "the", "b": [0.2111, 0.389, 0.2375, 0.4104]}, {"w": "instance", "b": [0.2445, 0.389, 0.3137, 0.4104]}, {"w": "x(i)", "b": [0.3207, 0.3884, 0.3428, 0.4104]}, {"w": "will", "b": [0.3498, 0.389, 0.3802, 0.4104]}, {"w": "be", "b": [0.3872, 0.389, 0.4067, 0.4104]}, {"w": "sampled", "b": [0.4137, 0.389, 0.4832, 0.4104]}, {"w": "from", "b": [0.4902, 0.389, 0.5318, 0.4104]}, {"w": "a", "b": [0.5388, 0.389, 0.548, 0.4104]}, {"w": "different", "b": [0.555, 0.389, 0.6267, 0.4104]}, {"w": "Gaussian", "b": [0.6337, 0.389, 0.7099, 0.4104]}, {"w": "distribution.", "b": [0.7169, 0.389, 0.8211, 0.4104]}, {"w": "For", "b": [0.8282, 0.389, 0.8571, 0.4104]}, {"w": "example,", "b": [0.1786, 0.4115, 0.2529, 0.4329]}, {"w": "if", "b": [0.2576, 0.4115, 0.2693, 0.4329]}, {"w": "z(i)=j,", "b": [0.2741, 0.4113, 0.3172, 0.4329]}, {"w": "then", "b": [0.322, 0.4115, 0.3597, 0.4329]}, {"w": "�i", "b": [0.3644, 0.4073, 0.3856, 0.4306]}, {"w": "∼�μ", "b": [0.3969, 0.4113, 0.4593, 0.4329]}, {"w": "j", "b": [0.4665, 0.4082, 0.4707, 0.4246]}, {"w": ",", "b": [0.4762, 0.4115, 0.4809, 0.4329]}, {"w": "Σ", "b": [0.4844, 0.4113, 0.4964, 0.4329]}, {"w": "j", "b": [0.5035, 0.4082, 0.5078, 0.4246]}, {"w": ".", "b": [0.5205, 0.4115, 0.5252, 0.4329]}]}, {"id": "b_6", "type": "paragraph", "text": "• Shaded nodes indicate that the value is known, so in this case only the random variables x(i) have known values: they are called observed variables. The unknown random variables z(i) are called latent variables.", "words": [{"w": "•", "b": [0.16, 0.4389, 0.1682, 0.4604]}, {"w": "Shaded", "b": [0.1786, 0.4389, 0.2396, 0.4604]}, {"w": "nodes", "b": [0.2462, 0.4389, 0.2957, 0.4604]}, {"w": "indicate", "b": [0.3023, 0.4389, 0.3686, 0.4604]}, {"w": "that", "b": [0.3752, 0.4389, 0.4078, 0.4604]}, {"w": "the", "b": [0.4144, 0.4389, 0.4407, 0.4604]}, {"w": "value", "b": [0.4473, 0.4389, 0.4913, 0.4604]}, {"w": "is", "b": [0.4979, 0.4389, 0.5111, 0.4604]}, {"w": "known,", "b": [0.5177, 0.4389, 0.5804, 0.4604]}, {"w": "so", "b": [0.587, 0.4389, 0.6053, 0.4604]}, {"w": "in", "b": [0.6119, 0.4389, 0.6289, 0.4604]}, {"w": "this", "b": [0.6355, 0.4389, 0.6662, 0.4604]}, {"w": "case", "b": [0.6728, 0.4389, 0.7072, 0.4604]}, {"w": "only", "b": [0.7138, 0.4389, 0.7507, 0.4604]}, {"w": "the", "b": [0.7573, 0.4389, 0.7836, 0.4604]}, {"w": "random", "b": [0.7902, 0.4389, 0.8571, 0.4604]}, {"w": "variables", "b": [0.1786, 0.458, 0.2522, 0.4794]}, {"w": "x(i)", "b": [0.2575, 0.4574, 0.2796, 0.4794]}, {"w": "have", "b": [0.2849, 0.458, 0.3233, 0.4794]}, {"w": "known", "b": [0.3286, 0.458, 0.3866, 0.4794]}, {"w": "values:", "b": [0.392, 0.458, 0.4483, 0.4794]}, {"w": "they", "b": [0.4537, 0.458, 0.4896, 0.4794]}, {"w": "are", "b": [0.4949, 0.458, 0.5206, 0.4794]}, {"w": "called", "b": [0.5259, 0.458, 0.5743, 0.4794]}, {"w": "observed", "b": [0.5796, 0.4578, 0.6506, 0.4794]}, {"w": "variables.", "b": [0.6554, 0.4578, 0.7332, 0.4794]}, {"w": "The", "b": [0.7385, 0.458, 0.7713, 0.4794]}, {"w": "unknown", "b": [0.7767, 0.458, 0.8571, 0.4794]}, {"w": "random", "b": [0.1786, 0.477, 0.2455, 0.4985]}, {"w": "variables", "b": [0.2503, 0.477, 0.3239, 0.4985]}, {"w": "z(i)", "b": [0.3286, 0.4768, 0.3494, 0.4985]}, {"w": "are", "b": [0.3541, 0.477, 0.3798, 0.4985]}, {"w": "called", "b": [0.3846, 0.477, 0.4329, 0.4985]}, {"w": "latent", "b": [0.4376, 0.4768, 0.484, 0.4985]}, {"w": "variables.", "b": [0.4888, 0.4768, 0.566, 0.4985]}]}, {"id": "b_7", "type": "paragraph", "text": "So what can you do with such a model? Well, given the dataset X, you typically want to start by estimating the weights ϕ and all the distribution parameters μ(1) to μ(k) and Σ(1) to Σ(k). Scikit-Learn’s GaussianMixture class makes this trivial:", "words": [{"w": "So", "b": [0.1428, 0.5112, 0.1633, 0.5326]}, {"w": "what", "b": [0.1691, 0.5112, 0.2096, 0.5326]}, {"w": "can", "b": [0.2153, 0.5112, 0.2446, 0.5326]}, {"w": "you", "b": [0.2504, 0.5112, 0.2816, 0.5326]}, {"w": "do", "b": [0.2873, 0.5112, 0.309, 0.5326]}, {"w": "with", "b": [0.3147, 0.5112, 0.352, 0.5326]}, {"w": "such", "b": [0.3577, 0.5112, 0.3964, 0.5326]}, {"w": "a", "b": [0.4021, 0.5112, 0.4112, 0.5326]}, {"w": "model?", "b": [0.417, 0.5112, 0.4777, 0.5326]}, {"w": "Well,", "b": [0.4834, 0.5112, 0.5257, 0.5326]}, {"w": "given", "b": [0.5315, 0.5112, 0.5767, 0.5326]}, {"w": "the", "b": [0.5824, 0.5112, 0.6087, 0.5326]}, {"w": "dataset", "b": [0.6145, 0.5112, 0.6726, 0.5326]}, {"w": "X,", "b": [0.6783, 0.5107, 0.6975, 0.5326]}, {"w": "you", "b": [0.7032, 0.5112, 0.7344, 0.5326]}, {"w": "typically", "b": [0.7402, 0.5112, 0.8106, 0.5326]}, {"w": "want", "b": [0.8164, 0.5112, 0.8571, 0.5326]}, {"w": "to", "b": [0.1429, 0.5303, 0.1598, 0.5517]}, {"w": "start", "b": [0.1652, 0.5303, 0.2024, 0.5517]}, {"w": "by", "b": [0.2077, 0.5303, 0.2279, 0.5517]}, {"w": "estimating", "b": [0.2332, 0.5303, 0.3205, 0.5517]}, {"w": "the", "b": [0.3259, 0.5303, 0.3522, 0.5517]}, {"w": "weights", "b": [0.3575, 0.5303, 0.4207, 0.5517]}, {"w": "ϕ", "b": [0.426, 0.5297, 0.4386, 0.5517]}, {"w": "and", "b": [0.4439, 0.5303, 0.4755, 0.5517]}, {"w": "all", "b": [0.4808, 0.5303, 0.5005, 0.5517]}, {"w": "the", "b": [0.5058, 0.5303, 0.5321, 0.5517]}, {"w": "distribution", "b": [0.5375, 0.5303, 0.637, 0.5517]}, {"w": "parameters", "b": [0.6423, 0.5303, 0.7357, 0.5517]}, {"w": "μ(1)", "b": [0.741, 0.5297, 0.7669, 0.5517]}, {"w": "to", "b": [0.7722, 0.5303, 0.7892, 0.5517]}, {"w": "μ(k)", "b": [0.7945, 0.5297, 0.8203, 0.5517]}, {"w": "and", "b": [0.8256, 0.5303, 0.8572, 0.5517]}, {"w": "Σ(1)", "b": [0.1429, 0.5496, 0.1703, 0.5716]}, {"w": "to", "b": [0.175, 0.5502, 0.192, 0.5716]}, {"w": "Σ(k).", "b": [0.1967, 0.5496, 0.2287, 0.5716]}, {"w": "Scikit-Learn’s", "b": [0.2335, 0.5502, 0.3443, 0.5716]}, {"w": "GaussianMixture", "b": [0.3491, 0.5534, 0.4975, 0.5685]}, {"w": "class", "b": [0.5022, 0.5502, 0.5408, 0.5716]}, {"w": "makes", "b": [0.5455, 0.5502, 0.5985, 0.5716]}, {"w": "this", "b": [0.6033, 0.5502, 0.634, 0.5716]}, {"w": "trivial:", "b": [0.6387, 0.5502, 0.6928, 0.5716]}]}, {"id": "b_8", "type": "paragraph", "text": "from sklearn.mixture import GaussianMixture", "words": [{"w": "from", "b": [0.1766, 0.5822, 0.2103, 0.595]}, {"w": "sklearn.mixture", "b": [0.2188, 0.5822, 0.3452, 0.595]}, {"w": "import", "b": [0.3537, 0.5822, 0.4043, 0.595]}, {"w": "GaussianMixture", "b": [0.4127, 0.5822, 0.5392, 0.595]}]}, {"id": "b_9", "type": "equation", "text": "gm = GaussianMixture(n_components=3, n_init=10) gm.fit(X)", "words": [{"w": "gm", "b": [0.1766, 0.613, 0.1935, 0.6259]}, {"w": "=", "b": [0.2019, 0.613, 0.2103, 0.6259]}, {"w": "GaussianMixture(n_components=3,", "b": [0.2188, 0.613, 0.4802, 0.6259]}, {"w": "n_init=10)", "b": [0.4886, 0.613, 0.5729, 0.6259]}, {"w": "gm.fit(X)", "b": [0.1766, 0.6284, 0.2525, 0.6413]}]}, {"id": "b_10", "type": "paragraph", "text": "Let’s look at the parameters that the algorithm estimated:", "words": [{"w": "Let’s", "b": [0.1429, 0.6491, 0.179, 0.6705]}, {"w": "look", "b": [0.1838, 0.6491, 0.2206, 0.6705]}, {"w": "at", "b": [0.2253, 0.6491, 0.2404, 0.6705]}, {"w": "the", "b": [0.2452, 0.6491, 0.2715, 0.6705]}, {"w": "parameters", "b": [0.2762, 0.6491, 0.3697, 0.6705]}, {"w": "that", "b": [0.3744, 0.6491, 0.407, 0.6705]}, {"w": "the", "b": [0.4117, 0.6491, 0.438, 0.6705]}, {"w": "algorithm", "b": [0.4428, 0.6491, 0.5254, 0.6705]}, {"w": "estimated:", "b": [0.5301, 0.6491, 0.6154, 0.6705]}]}, {"id": "b_11", "type": "paragraph", "text": ">>> gm.weights_ array([0.20965228, 0.4000662 , 0.39028152]) >>> gm.means_ array([[ 3.39909717, 1.05933727], [-1.40763984, 1.42710194], [ 0.05135313, 0.07524095]]) >>> gm.covariances_ array([[[ 1.14807234, -0.03270354], [-0.03270354, 0.95496237]],", "words": [{"w": ">>>", "b": [0.1766, 0.681, 0.2019, 0.6939]}, {"w": "gm.weights_", "b": [0.2103, 0.681, 0.3031, 0.6939]}, {"w": "array([0.20965228,", "b": [0.1766, 0.6965, 0.3284, 0.7093]}, {"w": "0.4000662", "b": [0.3368, 0.6965, 0.4127, 0.7093]}, {"w": ",", "b": [0.4211, 0.6965, 0.4296, 0.7093]}, {"w": "0.39028152])", "b": [0.438, 0.6965, 0.5392, 0.7093]}, {"w": ">>>", "b": [0.1766, 0.7119, 0.2019, 0.7247]}, {"w": "gm.means_", "b": [0.2103, 0.7119, 0.2862, 0.7247]}, {"w": "array([[", "b": [0.1766, 0.7273, 0.244, 0.7401]}, {"w": "3.39909717,", "b": [0.2525, 0.7273, 0.3452, 0.7401]}, {"w": "1.05933727],", "b": [0.3621, 0.7273, 0.4633, 0.7401]}, {"w": "[-1.40763984,", "b": [0.2356, 0.7427, 0.3452, 0.7556]}, {"w": "1.42710194],", "b": [0.3621, 0.7427, 0.4633, 0.7556]}, {"w": "[", "b": [0.2356, 0.7581, 0.244, 0.771]}, {"w": "0.05135313,", "b": [0.2525, 0.7581, 0.3452, 0.771]}, {"w": "0.07524095]])", "b": [0.3621, 0.7581, 0.4717, 0.771]}, {"w": ">>>", "b": [0.1766, 0.7736, 0.2019, 0.7864]}, {"w": "gm.covariances_", "b": [0.2103, 0.7736, 0.3368, 0.7864]}, {"w": "array([[[", "b": [0.1766, 0.789, 0.2525, 0.8018]}, {"w": "1.14807234,", "b": [0.2609, 0.789, 0.3537, 0.8018]}, {"w": "-0.03270354],", "b": [0.3621, 0.789, 0.4717, 0.8018]}, {"w": "[-0.03270354,", "b": [0.244, 0.8044, 0.3537, 0.8172]}, {"w": "0.95496237]],", "b": [0.3705, 0.8044, 0.4802, 0.8172]}]}, {"id": "b_12", "type": "paragraph", "text": "[[ 0.63478101, 0.72969804], [ 0.72969804, 1.1609872 ]],", "words": [{"w": "[[", "b": [0.2356, 0.8352, 0.2525, 0.8481]}, {"w": "0.63478101,", "b": [0.2609, 0.8352, 0.3537, 0.8481]}, {"w": "0.72969804],", "b": [0.3705, 0.8352, 0.4717, 0.8481]}, {"w": "[", "b": [0.244, 0.8507, 0.2525, 0.8635]}, {"w": "0.72969804,", "b": [0.2609, 0.8507, 0.3537, 0.8635]}, {"w": "1.1609872", "b": [0.3705, 0.8507, 0.4464, 0.8635]}, {"w": "]],", "b": [0.4549, 0.8507, 0.4802, 0.8635]}]}, {"id": "b_13", "type": "paragraph", "text": "262 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "262", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 289, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "[[ 0.68809572, 0.79608475], [ 0.79608475, 1.21234145]]])", "words": [{"w": "[[", "b": [0.2356, 0.0829, 0.2525, 0.0958]}, {"w": "0.68809572,", "b": [0.2609, 0.0829, 0.3537, 0.0958]}, {"w": "0.79608475],", "b": [0.3705, 0.0829, 0.4717, 0.0958]}, {"w": "[", "b": [0.244, 0.0983, 0.2525, 0.1112]}, {"w": "0.79608475,", "b": [0.2609, 0.0983, 0.3537, 0.1112]}, {"w": "1.21234145]]])", "b": [0.3705, 0.0983, 0.4886, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "Great, it worked fine! Indeed, the weights that were used to generate the data were 0.2, 0.4 and 0.4, and similarly, the means and covariance matrices were very close to those found by the algorithm. But how? This class relies on the Expectation- Maximization (EM) algorithm, which has many similarities with the K-Means algo‐ rithm: it also initializes the cluster parameters randomly, then it repeats two steps until convergence, first assigning instances to clusters (this is called the expectation step) then updating the clusters (this is called the maximization step). Sounds famil‐ iar? Indeed, in the context of clustering you can think of EM as a generalization of K- Means which not only finds the cluster centers (μ(1) to μ(k)), but also their size, shape and orientation (Σ(1) to Σ(k)), as well as their relative weights (ϕ(1) to ϕ(k)). Unlike K- Means, EM uses soft cluster assignments rather than hard assignments: for each instance during the expectation step, the algorithm estimates the probability that it belongs to each cluster (based on the current cluster parameters). Then, during the maximization step, each cluster is updated using all the instances in the dataset, with each instance weighted by the estimated probability that it belongs to that cluster. These probabilities are called the responsibilities of the clusters for the instances. Dur‐ ing the maximization step, each cluster’s update will mostly be impacted by the instances it is most responsible for.", "words": [{"w": "Great,", "b": [0.1429, 0.119, 0.1942, 0.1404]}, {"w": "it", "b": [0.2012, 0.119, 0.2132, 0.1404]}, {"w": "worked", "b": [0.2202, 0.119, 0.283, 0.1404]}, {"w": "fine!", "b": [0.29, 0.119, 0.3278, 0.1404]}, {"w": "Indeed,", "b": [0.3348, 0.119, 0.3977, 0.1404]}, {"w": "the", "b": [0.4048, 0.119, 0.4311, 0.1404]}, {"w": "weights", "b": [0.4381, 0.119, 0.5013, 0.1404]}, {"w": "that", "b": [0.5083, 0.119, 0.5409, 0.1404]}, {"w": "were", "b": [0.5479, 0.119, 0.5876, 0.1404]}, {"w": "used", "b": [0.5947, 0.119, 0.6332, 0.1404]}, {"w": "to", "b": [0.6402, 0.119, 0.6572, 0.1404]}, {"w": "generate", "b": [0.6642, 0.119, 0.7348, 0.1404]}, {"w": "the", "b": [0.7418, 0.119, 0.7681, 0.1404]}, {"w": "data", "b": [0.7752, 0.119, 0.8104, 0.1404]}, {"w": "were", "b": [0.8174, 0.119, 0.8571, 0.1404]}, {"w": "0.2,", "b": [0.1429, 0.138, 0.1724, 0.1594]}, {"w": "0.4", "b": [0.1784, 0.138, 0.2031, 0.1594]}, {"w": "and", "b": [0.2092, 0.138, 0.2407, 0.1594]}, {"w": "0.4,", "b": [0.2468, 0.138, 0.2763, 0.1594]}, {"w": "and", "b": [0.2823, 0.138, 0.3138, 0.1594]}, {"w": "similarly,", "b": [0.3199, 0.138, 0.396, 0.1594]}, {"w": "the", "b": [0.402, 0.138, 0.4283, 0.1594]}, {"w": "means", "b": [0.4344, 0.138, 0.4885, 0.1594]}, {"w": "and", "b": [0.4945, 0.138, 0.5261, 0.1594]}, {"w": "covariance", "b": [0.5321, 0.138, 0.6219, 0.1594]}, {"w": "matrices", "b": [0.6279, 0.138, 0.6987, 0.1594]}, {"w": "were", "b": [0.7047, 0.138, 0.7444, 0.1594]}, {"w": "very", "b": [0.7505, 0.138, 0.7869, 0.1594]}, {"w": "close", "b": [0.7929, 0.138, 0.8341, 0.1594]}, {"w": "to", "b": [0.8402, 0.138, 0.8571, 0.1594]}, {"w": "those", "b": [0.1429, 0.1571, 0.1875, 0.1785]}, {"w": "found", "b": [0.1992, 0.1571, 0.2494, 0.1785]}, {"w": "by", "b": [0.2611, 0.1571, 0.2813, 0.1785]}, {"w": "the", "b": [0.293, 0.1571, 0.3193, 0.1785]}, {"w": "algorithm.", "b": [0.331, 0.1571, 0.4184, 0.1785]}, {"w": "But", "b": [0.4301, 0.1571, 0.4598, 0.1785]}, {"w": "how?", "b": [0.4715, 0.1571, 0.5154, 0.1785]}, {"w": "This", "b": [0.5271, 0.1571, 0.5643, 0.1785]}, {"w": "class", "b": [0.576, 0.1571, 0.6145, 0.1785]}, {"w": "relies", "b": [0.6262, 0.1571, 0.6702, 0.1785]}, {"w": "on", "b": [0.6819, 0.1571, 0.7039, 0.1785]}, {"w": "the", "b": [0.7156, 0.1571, 0.7419, 0.1785]}, {"w": "Expectation-", "b": [0.7536, 0.1569, 0.8571, 0.1785]}, {"w": "Maximization", "b": [0.1429, 0.1759, 0.2587, 0.1975]}, {"w": "(EM)", "b": [0.2653, 0.1761, 0.3101, 0.1975]}, {"w": "algorithm,", "b": [0.3168, 0.1761, 0.4042, 0.1975]}, {"w": "which", "b": [0.4108, 0.1761, 0.4617, 0.1975]}, {"w": "has", "b": [0.4683, 0.1761, 0.4963, 0.1975]}, {"w": "many", "b": [0.5029, 0.1761, 0.5496, 0.1975]}, {"w": "similarities", "b": [0.5562, 0.1761, 0.6483, 0.1975]}, {"w": "with", "b": [0.6549, 0.1761, 0.6922, 0.1975]}, {"w": "the", "b": [0.6988, 0.1761, 0.7252, 0.1975]}, {"w": "K-Means", "b": [0.7318, 0.1761, 0.8083, 0.1975]}, {"w": "algo‐", "b": [0.8149, 0.1761, 0.8571, 0.1975]}, {"w": "rithm:", "b": [0.1429, 0.1952, 0.1955, 0.2166]}, {"w": "it", "b": [0.2034, 0.1952, 0.2153, 0.2166]}, {"w": "also", "b": [0.2233, 0.1952, 0.256, 0.2166]}, {"w": "initializes", "b": [0.2639, 0.1952, 0.3437, 0.2166]}, {"w": "the", "b": [0.3516, 0.1952, 0.378, 0.2166]}, {"w": "cluster", "b": [0.3859, 0.1952, 0.4416, 0.2166]}, {"w": "parameters", "b": [0.4496, 0.1952, 0.543, 0.2166]}, {"w": "randomly,", "b": [0.551, 0.1952, 0.636, 0.2166]}, {"w": "then", "b": [0.6439, 0.1952, 0.6817, 0.2166]}, {"w": "it", "b": [0.6896, 0.1952, 0.7015, 0.2166]}, {"w": "repeats", "b": [0.7095, 0.1952, 0.7686, 0.2166]}, {"w": "two", "b": [0.7765, 0.1952, 0.8078, 0.2166]}, {"w": "steps", "b": [0.8157, 0.1952, 0.8571, 0.2166]}, {"w": "until", "b": [0.1429, 0.2142, 0.1821, 0.2356]}, {"w": "convergence,", "b": [0.1893, 0.2142, 0.2983, 0.2356]}, {"w": "first", "b": [0.3054, 0.2142, 0.3389, 0.2356]}, {"w": "assigning", "b": [0.3461, 0.2142, 0.424, 0.2356]}, {"w": "instances", "b": [0.4311, 0.2142, 0.508, 0.2356]}, {"w": "to", "b": [0.5151, 0.2142, 0.5321, 0.2356]}, {"w": "clusters", "b": [0.5393, 0.2142, 0.6026, 0.2356]}, {"w": "(this", "b": [0.6098, 0.2142, 0.6477, 0.2356]}, {"w": "is", "b": [0.6549, 0.2142, 0.6681, 0.2356]}, {"w": "called", "b": [0.6752, 0.2142, 0.7236, 0.2356]}, {"w": "the", "b": [0.7308, 0.2142, 0.7571, 0.2356]}, {"w": "expectation", "b": [0.7642, 0.214, 0.8571, 0.2356]}, {"w": "step)", "b": [0.1428, 0.233, 0.1814, 0.2547]}, {"w": "then", "b": [0.1879, 0.2333, 0.2256, 0.2547]}, {"w": "updating", "b": [0.2321, 0.2333, 0.3069, 0.2547]}, {"w": "the", "b": [0.3134, 0.2333, 0.3397, 0.2547]}, {"w": "clusters", "b": [0.3462, 0.2333, 0.4095, 0.2547]}, {"w": "(this", "b": [0.416, 0.2333, 0.4539, 0.2547]}, {"w": "is", "b": [0.4604, 0.2333, 0.4736, 0.2547]}, {"w": "called", "b": [0.4801, 0.2333, 0.5284, 0.2547]}, {"w": "the", "b": [0.5349, 0.2333, 0.5612, 0.2547]}, {"w": "maximization", "b": [0.5677, 0.233, 0.6821, 0.2547]}, {"w": "step).", "b": [0.6886, 0.233, 0.732, 0.2547]}, {"w": "Sounds", "b": [0.7384, 0.2333, 0.8, 0.2547]}, {"w": "famil‐", "b": [0.8065, 0.2333, 0.8571, 0.2547]}, {"w": "iar?", "b": [0.1429, 0.2523, 0.1732, 0.2737]}, {"w": "Indeed,", "b": [0.1783, 0.2523, 0.2413, 0.2737]}, {"w": "in", "b": [0.2464, 0.2523, 0.2634, 0.2737]}, {"w": "the", "b": [0.2685, 0.2523, 0.2948, 0.2737]}, {"w": "context", "b": [0.2999, 0.2523, 0.3618, 0.2737]}, {"w": "of", "b": [0.3669, 0.2523, 0.3837, 0.2737]}, {"w": "clustering", "b": [0.3888, 0.2523, 0.4712, 0.2737]}, {"w": "you", "b": [0.4764, 0.2523, 0.5076, 0.2737]}, {"w": "can", "b": [0.5127, 0.2523, 0.5421, 0.2737]}, {"w": "think", "b": [0.5472, 0.2523, 0.592, 0.2737]}, {"w": "of", "b": [0.5971, 0.2523, 0.6139, 0.2737]}, {"w": "EM", "b": [0.619, 0.2523, 0.6494, 0.2737]}, {"w": "as", "b": [0.6545, 0.2523, 0.6713, 0.2737]}, {"w": "a", "b": [0.6764, 0.2523, 0.6855, 0.2737]}, {"w": "generalization", "b": [0.6907, 0.2523, 0.8087, 0.2737]}, {"w": "of", "b": [0.8138, 0.2523, 0.8306, 0.2737]}, {"w": "K-", "b": [0.8357, 0.2523, 0.8571, 0.2737]}, {"w": "Means", "b": [0.1429, 0.2714, 0.1979, 0.2928]}, {"w": "which", "b": [0.2039, 0.2714, 0.2548, 0.2928]}, {"w": "not", "b": [0.2607, 0.2714, 0.2891, 0.2928]}, {"w": "only", "b": [0.295, 0.2714, 0.3319, 0.2928]}, {"w": "finds", "b": [0.3378, 0.2714, 0.3796, 0.2928]}, {"w": "the", "b": [0.3855, 0.2714, 0.4119, 0.2928]}, {"w": "cluster", "b": [0.4178, 0.2714, 0.4735, 0.2928]}, {"w": "centers", "b": [0.4795, 0.2714, 0.5387, 0.2928]}, {"w": "(μ(1)", "b": [0.5447, 0.2708, 0.5777, 0.2928]}, {"w": "to", "b": [0.5837, 0.2714, 0.6006, 0.2928]}, {"w": "μ(k)),", "b": [0.6066, 0.2708, 0.6443, 0.2928]}, {"w": "but", "b": [0.6502, 0.2714, 0.6782, 0.2928]}, {"w": "also", "b": [0.6841, 0.2714, 0.7168, 0.2928]}, {"w": "their", "b": [0.7228, 0.2714, 0.7624, 0.2928]}, {"w": "size,", "b": [0.7683, 0.2714, 0.8039, 0.2928]}, {"w": "shape", "b": [0.8099, 0.2714, 0.8571, 0.2928]}, {"w": "and", "b": [0.1429, 0.2904, 0.1744, 0.3118]}, {"w": "orientation", "b": [0.1812, 0.2904, 0.2741, 0.3118]}, {"w": "(Σ(1)", "b": [0.2809, 0.2898, 0.3155, 0.3118]}, {"w": "to", "b": [0.3223, 0.2904, 0.3393, 0.3118]}, {"w": "Σ(k)),", "b": [0.3461, 0.2898, 0.3853, 0.3118]}, {"w": "as", "b": [0.3921, 0.2904, 0.4089, 0.3118]}, {"w": "well", "b": [0.4157, 0.2904, 0.4494, 0.3118]}, {"w": "as", "b": [0.4562, 0.2904, 0.473, 0.3118]}, {"w": "their", "b": [0.4798, 0.2904, 0.5194, 0.3118]}, {"w": "relative", "b": [0.5262, 0.2904, 0.5873, 0.3118]}, {"w": "weights", "b": [0.5941, 0.2904, 0.6572, 0.3118]}, {"w": "(ϕ(1)", "b": [0.6641, 0.2902, 0.6975, 0.3118]}, {"w": "to", "b": [0.7043, 0.2904, 0.7213, 0.3118]}, {"w": "ϕ(k)).", "b": [0.7281, 0.2902, 0.7662, 0.3118]}, {"w": "Unlike", "b": [0.773, 0.2904, 0.8289, 0.3118]}, {"w": "K-", "b": [0.8357, 0.2904, 0.8572, 0.3118]}, {"w": "Means,", "b": [0.1429, 0.3094, 0.2027, 0.3309]}, {"w": "EM", "b": [0.2121, 0.3094, 0.2425, 0.3309]}, {"w": "uses", "b": [0.2519, 0.3094, 0.2871, 0.3309]}, {"w": "soft", "b": [0.2965, 0.3094, 0.3273, 0.3309]}, {"w": "cluster", "b": [0.3367, 0.3094, 0.3924, 0.3309]}, {"w": "assignments", "b": [0.4018, 0.3094, 0.5039, 0.3309]}, {"w": "rather", "b": [0.5133, 0.3094, 0.5638, 0.3309]}, {"w": "than", "b": [0.5732, 0.3094, 0.6112, 0.3309]}, {"w": "hard", "b": [0.6207, 0.3094, 0.6597, 0.3309]}, {"w": "assignments:", "b": [0.6691, 0.3094, 0.7759, 0.3309]}, {"w": "for", "b": [0.7853, 0.3094, 0.8098, 0.3309]}, {"w": "each", "b": [0.8192, 0.3094, 0.8571, 0.3309]}, {"w": "instance", "b": [0.1429, 0.3285, 0.212, 0.3499]}, {"w": "during", "b": [0.2192, 0.3285, 0.2758, 0.3499]}, {"w": "the", "b": [0.2829, 0.3285, 0.3093, 0.3499]}, {"w": "expectation", "b": [0.3165, 0.3285, 0.4128, 0.3499]}, {"w": "step,", "b": [0.42, 0.3285, 0.4579, 0.3499]}, {"w": "the", "b": [0.4651, 0.3285, 0.4914, 0.3499]}, {"w": "algorithm", "b": [0.4986, 0.3285, 0.5813, 0.3499]}, {"w": "estimates", "b": [0.5885, 0.3285, 0.6656, 0.3499]}, {"w": "the", "b": [0.6728, 0.3285, 0.6991, 0.3499]}, {"w": "probability", "b": [0.7063, 0.3285, 0.7982, 0.3499]}, {"w": "that", "b": [0.8054, 0.3285, 0.838, 0.3499]}, {"w": "it", "b": [0.8452, 0.3285, 0.8571, 0.3499]}, {"w": "belongs", "b": [0.1429, 0.3475, 0.207, 0.369]}, {"w": "to", "b": [0.2138, 0.3475, 0.2308, 0.369]}, {"w": "each", "b": [0.2377, 0.3475, 0.2756, 0.369]}, {"w": "cluster", "b": [0.2825, 0.3475, 0.3382, 0.369]}, {"w": "(based", "b": [0.345, 0.3475, 0.3995, 0.369]}, {"w": "on", "b": [0.4063, 0.3475, 0.4284, 0.369]}, {"w": "the", "b": [0.4352, 0.3475, 0.4615, 0.369]}, {"w": "current", "b": [0.4684, 0.3475, 0.5299, 0.369]}, {"w": "cluster", "b": [0.5368, 0.3475, 0.5925, 0.369]}, {"w": "parameters).", "b": [0.5994, 0.3475, 0.7048, 0.369]}, {"w": "Then,", "b": [0.7116, 0.3475, 0.7606, 0.369]}, {"w": "during", "b": [0.7674, 0.3475, 0.824, 0.369]}, {"w": "the", "b": [0.8308, 0.3475, 0.8572, 0.369]}, {"w": "maximization", "b": [0.1429, 0.3666, 0.2586, 0.388]}, {"w": "step,", "b": [0.2642, 0.3666, 0.3022, 0.388]}, {"w": "each", "b": [0.3078, 0.3666, 0.3457, 0.388]}, {"w": "cluster", "b": [0.3514, 0.3666, 0.4071, 0.388]}, {"w": "is", "b": [0.4128, 0.3666, 0.426, 0.388]}, {"w": "updated", "b": [0.4317, 0.3666, 0.4996, 0.388]}, {"w": "using", "b": [0.5052, 0.3666, 0.5507, 0.388]}, {"w": "all", "b": [0.5563, 0.3664, 0.5766, 0.388]}, {"w": "the", "b": [0.5822, 0.3666, 0.6086, 0.388]}, {"w": "instances", "b": [0.6142, 0.3666, 0.691, 0.388]}, {"w": "in", "b": [0.6967, 0.3666, 0.7137, 0.388]}, {"w": "the", "b": [0.7193, 0.3666, 0.7457, 0.388]}, {"w": "dataset,", "b": [0.7513, 0.3666, 0.8142, 0.388]}, {"w": "with", "b": [0.8198, 0.3666, 0.8571, 0.388]}, {"w": "each", "b": [0.1429, 0.3856, 0.1808, 0.407]}, {"w": "instance", "b": [0.1888, 0.3856, 0.2579, 0.407]}, {"w": "weighted", "b": [0.2659, 0.3856, 0.3413, 0.407]}, {"w": "by", "b": [0.3493, 0.3856, 0.3694, 0.407]}, {"w": "the", "b": [0.3774, 0.3856, 0.4037, 0.407]}, {"w": "estimated", "b": [0.4117, 0.3856, 0.4921, 0.407]}, {"w": "probability", "b": [0.5001, 0.3856, 0.592, 0.407]}, {"w": "that", "b": [0.6, 0.3856, 0.6326, 0.407]}, {"w": "it", "b": [0.6405, 0.3856, 0.6524, 0.407]}, {"w": "belongs", "b": [0.6604, 0.3856, 0.7245, 0.407]}, {"w": "to", "b": [0.7325, 0.3856, 0.7495, 0.407]}, {"w": "that", "b": [0.7574, 0.3856, 0.79, 0.407]}, {"w": "cluster.", "b": [0.798, 0.3856, 0.8571, 0.407]}, {"w": "These", "b": [0.1429, 0.4047, 0.1922, 0.4261]}, {"w": "probabilities", "b": [0.1973, 0.4047, 0.3018, 0.4261]}, {"w": "are", "b": [0.3069, 0.4047, 0.3326, 0.4261]}, {"w": "called", "b": [0.3378, 0.4047, 0.3861, 0.4261]}, {"w": "the", "b": [0.3913, 0.4047, 0.4176, 0.4261]}, {"w": "responsibilities", "b": [0.4228, 0.4045, 0.5407, 0.4261]}, {"w": "of", "b": [0.5459, 0.4047, 0.5626, 0.4261]}, {"w": "the", "b": [0.5678, 0.4047, 0.5941, 0.4261]}, {"w": "clusters", "b": [0.5993, 0.4047, 0.6626, 0.4261]}, {"w": "for", "b": [0.6678, 0.4047, 0.6923, 0.4261]}, {"w": "the", "b": [0.6974, 0.4047, 0.7238, 0.4261]}, {"w": "instances.", "b": [0.7289, 0.4047, 0.8105, 0.4261]}, {"w": "Dur‐", "b": [0.8156, 0.4047, 0.8571, 0.4261]}, {"w": "ing", "b": [0.1429, 0.4237, 0.1696, 0.4451]}, {"w": "the", "b": [0.1793, 0.4237, 0.2056, 0.4451]}, {"w": "maximization", "b": [0.2153, 0.4237, 0.3311, 0.4451]}, {"w": "step,", "b": [0.3408, 0.4237, 0.3787, 0.4451]}, {"w": "each", "b": [0.3884, 0.4237, 0.4263, 0.4451]}, {"w": "cluster’s", "b": [0.436, 0.4237, 0.5021, 0.4451]}, {"w": "update", "b": [0.5118, 0.4237, 0.5687, 0.4451]}, {"w": "will", "b": [0.5784, 0.4237, 0.6088, 0.4451]}, {"w": "mostly", "b": [0.6185, 0.4237, 0.6751, 0.4451]}, {"w": "be", "b": [0.6848, 0.4237, 0.7042, 0.4451]}, {"w": "impacted", "b": [0.7139, 0.4237, 0.7912, 0.4451]}, {"w": "by", "b": [0.801, 0.4237, 0.8211, 0.4451]}, {"w": "the", "b": [0.8308, 0.4237, 0.8571, 0.4451]}, {"w": "instances", "b": [0.1429, 0.4428, 0.2197, 0.4642]}, {"w": "it", "b": [0.2244, 0.4428, 0.2364, 0.4642]}, {"w": "is", "b": [0.2411, 0.4428, 0.2543, 0.4642]}, {"w": "most", "b": [0.2591, 0.4428, 0.3007, 0.4642]}, {"w": "responsible", "b": [0.3055, 0.4428, 0.4006, 0.4642]}, {"w": "for.", "b": [0.4053, 0.4428, 0.4333, 0.4642]}]}, {"id": "b_2", "type": "paragraph", "text": "Unfortunately, just like K-Means, EM can end up converging to poor solutions, so it needs to be run several times, keeping only the best solution. This is why we set n_init to 10. Be careful: by default n_init is only set to 1.", "words": [{"w": "Unfortunately,", "b": [0.2714, 0.4847, 0.3822, 0.5043]}, {"w": "just", "b": [0.39, 0.4847, 0.4178, 0.5043]}, {"w": "like", "b": [0.4256, 0.4847, 0.453, 0.5043]}, {"w": "K-Means,", "b": [0.4608, 0.4847, 0.5351, 0.5043]}, {"w": "EM", "b": [0.5429, 0.4847, 0.5707, 0.5043]}, {"w": "can", "b": [0.5785, 0.4847, 0.6053, 0.5043]}, {"w": "end", "b": [0.6131, 0.4847, 0.6417, 0.5043]}, {"w": "up", "b": [0.6494, 0.4847, 0.6695, 0.5043]}, {"w": "converging", "b": [0.6773, 0.4847, 0.7624, 0.5043]}, {"w": "to", "b": [0.7702, 0.4847, 0.7857, 0.5043]}, {"w": "poor", "b": [0.2714, 0.5021, 0.3079, 0.5217]}, {"w": "solutions,", "b": [0.3125, 0.5021, 0.3865, 0.5217]}, {"w": "so", "b": [0.3912, 0.5021, 0.4079, 0.5217]}, {"w": "it", "b": [0.4125, 0.5021, 0.4234, 0.5217]}, {"w": "needs", "b": [0.4281, 0.5021, 0.4717, 0.5217]}, {"w": "to", "b": [0.4764, 0.5021, 0.4919, 0.5217]}, {"w": "be", "b": [0.4965, 0.5021, 0.5143, 0.5217]}, {"w": "run", "b": [0.5189, 0.5021, 0.5465, 0.5217]}, {"w": "several", "b": [0.5512, 0.5021, 0.6034, 0.5217]}, {"w": "times,", "b": [0.608, 0.5021, 0.654, 0.5217]}, {"w": "keeping", "b": [0.6586, 0.5021, 0.7187, 0.5217]}, {"w": "only", "b": [0.7233, 0.5021, 0.757, 0.5217]}, {"w": "the", "b": [0.7616, 0.5021, 0.7857, 0.5217]}, {"w": "best", "b": [0.2714, 0.5204, 0.302, 0.54]}, {"w": "solution.", "b": [0.3064, 0.5204, 0.3734, 0.54]}, {"w": "This", "b": [0.3779, 0.5204, 0.4119, 0.54]}, {"w": "is", "b": [0.4163, 0.5204, 0.4284, 0.54]}, {"w": "why", "b": [0.4328, 0.5204, 0.4643, 0.54]}, {"w": "we", "b": [0.4688, 0.5204, 0.4899, 0.54]}, {"w": "set", "b": [0.4943, 0.5204, 0.5152, 0.54]}, {"w": "n_init", "b": [0.5196, 0.5233, 0.5739, 0.5371]}, {"w": "to", "b": [0.5783, 0.5204, 0.5939, 0.54]}, {"w": "10.", "b": [0.5982, 0.5204, 0.6208, 0.54]}, {"w": "Be", "b": [0.6251, 0.5204, 0.6448, 0.54]}, {"w": "careful:", "b": [0.6491, 0.5204, 0.7056, 0.54]}, {"w": "by", "b": [0.71, 0.5204, 0.7284, 0.54]}, {"w": "default", "b": [0.7327, 0.5204, 0.7852, 0.54]}, {"w": "n_init", "b": [0.2714, 0.5415, 0.3257, 0.5553]}, {"w": "is", "b": [0.33, 0.5386, 0.3421, 0.5582]}, {"w": "only", "b": [0.3464, 0.5386, 0.3801, 0.5582]}, {"w": "set", "b": [0.3845, 0.5386, 0.4053, 0.5582]}, {"w": "to", "b": [0.4097, 0.5386, 0.4252, 0.5582]}, {"w": "1.", "b": [0.4295, 0.5386, 0.443, 0.5582]}]}, {"id": "b_3", "type": "paragraph", "text": "You can check whether or not the algorithm converged and how many iterations it took:", "words": [{"w": "You", "b": [0.1429, 0.5834, 0.1752, 0.6048]}, {"w": "can", "b": [0.1821, 0.5834, 0.2114, 0.6048]}, {"w": "check", "b": [0.2183, 0.5834, 0.2663, 0.6048]}, {"w": "whether", "b": [0.2731, 0.5834, 0.3414, 0.6048]}, {"w": "or", "b": [0.3483, 0.5834, 0.3667, 0.6048]}, {"w": "not", "b": [0.3735, 0.5834, 0.4019, 0.6048]}, {"w": "the", "b": [0.4088, 0.5834, 0.4351, 0.6048]}, {"w": "algorithm", "b": [0.442, 0.5834, 0.5246, 0.6048]}, {"w": "converged", "b": [0.5315, 0.5834, 0.6177, 0.6048]}, {"w": "and", "b": [0.6246, 0.5834, 0.6561, 0.6048]}, {"w": "how", "b": [0.663, 0.5834, 0.699, 0.6048]}, {"w": "many", "b": [0.7059, 0.5834, 0.7526, 0.6048]}, {"w": "iterations", "b": [0.7595, 0.5834, 0.8383, 0.6048]}, {"w": "it", "b": [0.8452, 0.5834, 0.8571, 0.6048]}, {"w": "took:", "b": [0.1429, 0.6024, 0.1855, 0.6238]}]}, {"id": "b_4", "type": "equation", "text": ">>> gm.converged_ True >>> gm.n_iter_ 3", "words": [{"w": ">>>", "b": [0.1766, 0.6344, 0.2019, 0.6472]}, {"w": "gm.converged_", "b": [0.2103, 0.6344, 0.3199, 0.6472]}, {"w": "True", "b": [0.1766, 0.6498, 0.2103, 0.6627]}, {"w": ">>>", "b": [0.1766, 0.6652, 0.2019, 0.6781]}, {"w": "gm.n_iter_", "b": [0.2103, 0.6652, 0.2946, 0.6781]}, {"w": "3", "b": [0.1766, 0.6807, 0.185, 0.6935]}]}, {"id": "b_5", "type": "paragraph", "text": "Okay, now that you have an estimate of the location, size, shape, orientation and rela‐ tive weight of each cluster, the model can easily assign each instance to the most likely cluster (hard clustering) or estimate the probability that it belongs to a particular cluster (soft clustering). For this, just use the predict() method for hard clustering, or the predict_proba() method for soft clustering:", "words": [{"w": "Okay,", "b": [0.1429, 0.7013, 0.1903, 0.7227]}, {"w": "now", "b": [0.1955, 0.7013, 0.2318, 0.7227]}, {"w": "that", "b": [0.237, 0.7013, 0.2696, 0.7227]}, {"w": "you", "b": [0.2747, 0.7013, 0.306, 0.7227]}, {"w": "have", "b": [0.3112, 0.7013, 0.3496, 0.7227]}, {"w": "an", "b": [0.3548, 0.7013, 0.3753, 0.7227]}, {"w": "estimate", "b": [0.3805, 0.7013, 0.4499, 0.7227]}, {"w": "of", "b": [0.4551, 0.7013, 0.4719, 0.7227]}, {"w": "the", "b": [0.4771, 0.7013, 0.5034, 0.7227]}, {"w": "location,", "b": [0.5086, 0.7013, 0.5808, 0.7227]}, {"w": "size,", "b": [0.586, 0.7013, 0.6215, 0.7227]}, {"w": "shape,", "b": [0.6267, 0.7013, 0.6788, 0.7227]}, {"w": "orientation", "b": [0.684, 0.7013, 0.7768, 0.7227]}, {"w": "and", "b": [0.782, 0.7013, 0.8135, 0.7227]}, {"w": "rela‐", "b": [0.8187, 0.7013, 0.8571, 0.7227]}, {"w": "tive", "b": [0.1429, 0.7203, 0.1733, 0.7417]}, {"w": "weight", "b": [0.1781, 0.7203, 0.2336, 0.7417]}, {"w": "of", "b": [0.2384, 0.7203, 0.2552, 0.7417]}, {"w": "each", "b": [0.26, 0.7203, 0.2979, 0.7417]}, {"w": "cluster,", "b": [0.3027, 0.7203, 0.3619, 0.7417]}, {"w": "the", "b": [0.3666, 0.7203, 0.393, 0.7417]}, {"w": "model", "b": [0.3977, 0.7203, 0.4506, 0.7417]}, {"w": "can", "b": [0.4553, 0.7203, 0.4847, 0.7417]}, {"w": "easily", "b": [0.4895, 0.7203, 0.5355, 0.7417]}, {"w": "assign", "b": [0.5403, 0.7203, 0.5915, 0.7417]}, {"w": "each", "b": [0.5963, 0.7203, 0.6342, 0.7417]}, {"w": "instance", "b": [0.639, 0.7203, 0.7082, 0.7417]}, {"w": "to", "b": [0.7129, 0.7203, 0.7299, 0.7417]}, {"w": "the", "b": [0.7347, 0.7203, 0.761, 0.7417]}, {"w": "most", "b": [0.7658, 0.7203, 0.8075, 0.7417]}, {"w": "likely", "b": [0.8123, 0.7203, 0.8572, 0.7417]}, {"w": "cluster", "b": [0.1429, 0.7394, 0.1986, 0.7608]}, {"w": "(hard", "b": [0.2069, 0.7394, 0.2531, 0.7608]}, {"w": "clustering)", "b": [0.2615, 0.7394, 0.3511, 0.7608]}, {"w": "or", "b": [0.3595, 0.7394, 0.3778, 0.7608]}, {"w": "estimate", "b": [0.3862, 0.7394, 0.4556, 0.7608]}, {"w": "the", "b": [0.464, 0.7394, 0.4903, 0.7608]}, {"w": "probability", "b": [0.4986, 0.7394, 0.5906, 0.7608]}, {"w": "that", "b": [0.5989, 0.7394, 0.6315, 0.7608]}, {"w": "it", "b": [0.6398, 0.7394, 0.6518, 0.7608]}, {"w": "belongs", "b": [0.6601, 0.7394, 0.7243, 0.7608]}, {"w": "to", "b": [0.7326, 0.7394, 0.7496, 0.7608]}, {"w": "a", "b": [0.7579, 0.7394, 0.7671, 0.7608]}, {"w": "particular", "b": [0.7754, 0.7394, 0.8571, 0.7608]}, {"w": "cluster", "b": [0.1429, 0.7593, 0.1986, 0.7807]}, {"w": "(soft", "b": [0.2046, 0.7593, 0.2426, 0.7807]}, {"w": "clustering).", "b": [0.2487, 0.7593, 0.3431, 0.7807]}, {"w": "For", "b": [0.3491, 0.7593, 0.3781, 0.7807]}, {"w": "this,", "b": [0.3842, 0.7593, 0.4196, 0.7807]}, {"w": "just", "b": [0.4257, 0.7593, 0.4561, 0.7807]}, {"w": "use", "b": [0.4621, 0.7593, 0.4897, 0.7807]}, {"w": "the", "b": [0.4957, 0.7593, 0.5221, 0.7807]}, {"w": "predict()", "b": [0.5281, 0.7625, 0.6172, 0.7776]}, {"w": "method", "b": [0.6232, 0.7593, 0.6883, 0.7807]}, {"w": "for", "b": [0.6943, 0.7593, 0.7188, 0.7807]}, {"w": "hard", "b": [0.7249, 0.7593, 0.7639, 0.7807]}, {"w": "clustering,", "b": [0.7699, 0.7593, 0.8571, 0.7807]}, {"w": "or", "b": [0.1429, 0.7793, 0.1612, 0.8007]}, {"w": "the", "b": [0.166, 0.7793, 0.1923, 0.8007]}, {"w": "predict_proba()", "b": [0.197, 0.7825, 0.3455, 0.7975]}, {"w": "method", "b": [0.3502, 0.7793, 0.4152, 0.8007]}, {"w": "for", "b": [0.4199, 0.7793, 0.4445, 0.8007]}, {"w": "soft", "b": [0.4492, 0.7793, 0.48, 0.8007]}, {"w": "clustering:", "b": [0.4847, 0.7793, 0.5719, 0.8007]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> gm.predict(X) array([2, 2, 1, ..., 0, 0, 0]) >>> gm.predict_proba(X) array([[2.32389467e-02, 6.77397850e-07, 9.76760376e-01], [1.64685609e-02, 6.75361303e-04, 9.82856078e-01],", "words": [{"w": ">>>", "b": [0.1766, 0.8112, 0.2019, 0.8241]}, {"w": "gm.predict(X)", "b": [0.2103, 0.8112, 0.3199, 0.8241]}, {"w": "array([2,", "b": [0.1766, 0.8267, 0.2525, 0.8395]}, {"w": "2,", "b": [0.2609, 0.8267, 0.2778, 0.8395]}, {"w": "1,", "b": [0.2862, 0.8267, 0.3031, 0.8395]}, {"w": "...,", "b": [0.3115, 0.8267, 0.3452, 0.8395]}, {"w": "0,", "b": [0.3537, 0.8267, 0.3705, 0.8395]}, {"w": "0,", "b": [0.379, 0.8267, 0.3958, 0.8395]}, {"w": "0])", "b": [0.4043, 0.8267, 0.4296, 0.8395]}, {"w": ">>>", "b": [0.1766, 0.8421, 0.2019, 0.8549]}, {"w": "gm.predict_proba(X)", "b": [0.2103, 0.8421, 0.3705, 0.8549]}, {"w": "array([[2.32389467e-02,", "b": [0.1766, 0.8575, 0.3705, 0.8704]}, {"w": "6.77397850e-07,", "b": [0.379, 0.8575, 0.5055, 0.8704]}, {"w": "9.76760376e-01],", "b": [0.5139, 0.8575, 0.6488, 0.8704]}, {"w": "[1.64685609e-02,", "b": [0.2356, 0.8729, 0.3705, 0.8858]}, {"w": "6.75361303e-04,", "b": [0.379, 0.8729, 0.5055, 0.8858]}, {"w": "9.82856078e-01],", "b": [0.5139, 0.8729, 0.6488, 0.8858]}]}, {"id": "b_7", "type": "paragraph", "text": "Gaussian Mixtures | 263", "words": [{"w": "Gaussian", "b": [0.6892, 0.9225, 0.7415, 0.9388]}, {"w": "Mixtures", "b": [0.7443, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "263", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 290, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "[2.01535333e-06, 9.99923053e-01, 7.49319577e-05], ..., [9.99999571e-01, 2.13946075e-26, 4.28788333e-07], [1.00000000e+00, 1.46454409e-41, 5.12459171e-16], [1.00000000e+00, 8.02006365e-41, 2.27626238e-15]])", "words": [{"w": "[2.01535333e-06,", "b": [0.2356, 0.0829, 0.3705, 0.0958]}, {"w": "9.99923053e-01,", "b": [0.379, 0.0829, 0.5055, 0.0958]}, {"w": "7.49319577e-05],", "b": [0.5139, 0.0829, 0.6488, 0.0958]}, {"w": "...,", "b": [0.2356, 0.0983, 0.2693, 0.1112]}, {"w": "[9.99999571e-01,", "b": [0.2356, 0.1138, 0.3705, 0.1266]}, {"w": "2.13946075e-26,", "b": [0.379, 0.1138, 0.5055, 0.1266]}, {"w": "4.28788333e-07],", "b": [0.5139, 0.1138, 0.6488, 0.1266]}, {"w": "[1.00000000e+00,", "b": [0.2356, 0.1292, 0.3705, 0.142]}, {"w": "1.46454409e-41,", "b": [0.379, 0.1292, 0.5055, 0.142]}, {"w": "5.12459171e-16],", "b": [0.5139, 0.1292, 0.6488, 0.142]}, {"w": "[1.00000000e+00,", "b": [0.2356, 0.1446, 0.3705, 0.1574]}, {"w": "8.02006365e-41,", "b": [0.379, 0.1446, 0.5055, 0.1574]}, {"w": "2.27626238e-15]])", "b": [0.5139, 0.1446, 0.6572, 0.1574]}]}, {"id": "b_1", "type": "paragraph", "text": "It is a generative model, meaning you can actually sample new instances from it (note that they are ordered by cluster index):", "words": [{"w": "It", "b": [0.1429, 0.1652, 0.1555, 0.1866]}, {"w": "is", "b": [0.1609, 0.1652, 0.1742, 0.1866]}, {"w": "a", "b": [0.1796, 0.1652, 0.1888, 0.1866]}, {"w": "generative", "b": [0.1942, 0.165, 0.2767, 0.1866]}, {"w": "model,", "b": [0.2822, 0.165, 0.3366, 0.1866]}, {"w": "meaning", "b": [0.342, 0.1652, 0.4152, 0.1866]}, {"w": "you", "b": [0.4206, 0.1652, 0.4519, 0.1866]}, {"w": "can", "b": [0.4573, 0.1652, 0.4867, 0.1866]}, {"w": "actually", "b": [0.4921, 0.1652, 0.5567, 0.1866]}, {"w": "sample", "b": [0.5622, 0.1652, 0.6207, 0.1866]}, {"w": "new", "b": [0.6261, 0.1652, 0.6606, 0.1866]}, {"w": "instances", "b": [0.6661, 0.1652, 0.7429, 0.1866]}, {"w": "from", "b": [0.7483, 0.1652, 0.7899, 0.1866]}, {"w": "it", "b": [0.7953, 0.1652, 0.8073, 0.1866]}, {"w": "(note", "b": [0.8127, 0.1652, 0.8572, 0.1866]}, {"w": "that", "b": [0.1429, 0.1843, 0.1754, 0.2057]}, {"w": "they", "b": [0.1802, 0.1843, 0.2161, 0.2057]}, {"w": "are", "b": [0.2208, 0.1843, 0.2465, 0.2057]}, {"w": "ordered", "b": [0.2513, 0.1843, 0.317, 0.2057]}, {"w": "by", "b": [0.3218, 0.1843, 0.3419, 0.2057]}, {"w": "cluster", "b": [0.3467, 0.1843, 0.4024, 0.2057]}, {"w": "index):", "b": [0.4071, 0.1843, 0.4657, 0.2057]}]}, {"id": "b_2", "type": "paragraph", "text": ">>> X_new, y_new = gm.sample(6) >>> X_new array([[ 2.95400315, 2.63680992], [-1.16654575, 1.62792705], [-1.39477712, -1.48511338], [ 0.27221525, 0.690366 ], [ 0.54095936, 0.48591934], [ 0.38064009, -0.56240465]])", "words": [{"w": ">>>", "b": [0.1766, 0.2163, 0.2019, 0.2291]}, {"w": "X_new,", "b": [0.2103, 0.2163, 0.2609, 0.2291]}, {"w": "y_new", "b": [0.2693, 0.2163, 0.3115, 0.2291]}, {"w": "=", "b": [0.3199, 0.2163, 0.3284, 0.2291]}, {"w": "gm.sample(6)", "b": [0.3368, 0.2163, 0.438, 0.2291]}, {"w": ">>>", "b": [0.1766, 0.2317, 0.2019, 0.2445]}, {"w": "X_new", "b": [0.2103, 0.2317, 0.2525, 0.2445]}, {"w": "array([[", "b": [0.1766, 0.2471, 0.244, 0.2599]}, {"w": "2.95400315,", "b": [0.2525, 0.2471, 0.3452, 0.2599]}, {"w": "2.63680992],", "b": [0.3621, 0.2471, 0.4633, 0.2599]}, {"w": "[-1.16654575,", "b": [0.2356, 0.2625, 0.3452, 0.2754]}, {"w": "1.62792705],", "b": [0.3621, 0.2625, 0.4633, 0.2754]}, {"w": "[-1.39477712,", "b": [0.2356, 0.2779, 0.3452, 0.2908]}, {"w": "-1.48511338],", "b": [0.3537, 0.2779, 0.4633, 0.2908]}, {"w": "[", "b": [0.2356, 0.2933, 0.244, 0.3062]}, {"w": "0.27221525,", "b": [0.2525, 0.2933, 0.3452, 0.3062]}, {"w": "0.690366", "b": [0.3621, 0.2933, 0.4296, 0.3062]}, {"w": "],", "b": [0.4464, 0.2933, 0.4633, 0.3062]}, {"w": "[", "b": [0.2356, 0.3088, 0.244, 0.3216]}, {"w": "0.54095936,", "b": [0.2525, 0.3088, 0.3452, 0.3216]}, {"w": "0.48591934],", "b": [0.3621, 0.3088, 0.4633, 0.3216]}, {"w": "[", "b": [0.2356, 0.3242, 0.244, 0.337]}, {"w": "0.38064009,", "b": [0.2525, 0.3242, 0.3452, 0.337]}, {"w": "-0.56240465]])", "b": [0.3537, 0.3242, 0.4717, 0.337]}]}, {"id": "b_3", "type": "equation", "text": ">>> y_new array([0, 1, 2, 2, 2, 2])", "words": [{"w": ">>>", "b": [0.1766, 0.355, 0.2019, 0.3679]}, {"w": "y_new", "b": [0.2103, 0.355, 0.2525, 0.3679]}, {"w": "array([0,", "b": [0.1766, 0.3704, 0.2525, 0.3833]}, {"w": "1,", "b": [0.2609, 0.3704, 0.2778, 0.3833]}, {"w": "2,", "b": [0.2862, 0.3704, 0.3031, 0.3833]}, {"w": "2,", "b": [0.3115, 0.3704, 0.3284, 0.3833]}, {"w": "2,", "b": [0.3368, 0.3704, 0.3537, 0.3833]}, {"w": "2])", "b": [0.3621, 0.3704, 0.3874, 0.3833]}]}, {"id": "b_4", "type": "paragraph", "text": "It is also possible to estimate the density of the model at any given location. This is achieved using the score_samples() method: for each instance it is given, this method estimates the log of the probability density function (PDF) at that location. The greater the score, the higher the density:", "words": [{"w": "It", "b": [0.1429, 0.3911, 0.1555, 0.4125]}, {"w": "is", "b": [0.1622, 0.3911, 0.1754, 0.4125]}, {"w": "also", "b": [0.1821, 0.3911, 0.2148, 0.4125]}, {"w": "possible", "b": [0.2215, 0.3911, 0.2886, 0.4125]}, {"w": "to", "b": [0.2953, 0.3911, 0.3123, 0.4125]}, {"w": "estimate", "b": [0.3189, 0.3911, 0.3884, 0.4125]}, {"w": "the", "b": [0.3951, 0.3911, 0.4214, 0.4125]}, {"w": "density", "b": [0.4281, 0.3911, 0.4885, 0.4125]}, {"w": "of", "b": [0.4952, 0.3911, 0.512, 0.4125]}, {"w": "the", "b": [0.5187, 0.3911, 0.545, 0.4125]}, {"w": "model", "b": [0.5517, 0.3911, 0.6045, 0.4125]}, {"w": "at", "b": [0.6112, 0.3911, 0.6263, 0.4125]}, {"w": "any", "b": [0.633, 0.3911, 0.6626, 0.4125]}, {"w": "given", "b": [0.6693, 0.3911, 0.7145, 0.4125]}, {"w": "location.", "b": [0.7212, 0.3911, 0.7933, 0.4125]}, {"w": "This", "b": [0.8, 0.3911, 0.8372, 0.4125]}, {"w": "is", "b": [0.8439, 0.3911, 0.8571, 0.4125]}, {"w": "achieved", "b": [0.1429, 0.411, 0.2159, 0.4324]}, {"w": "using", "b": [0.2262, 0.411, 0.2717, 0.4324]}, {"w": "the", "b": [0.282, 0.411, 0.3083, 0.4324]}, {"w": "score_samples()", "b": [0.3187, 0.4142, 0.4671, 0.4293]}, {"w": "method:", "b": [0.4775, 0.411, 0.5472, 0.4324]}, {"w": "for", "b": [0.5576, 0.411, 0.5821, 0.4324]}, {"w": "each", "b": [0.5924, 0.411, 0.6304, 0.4324]}, {"w": "instance", "b": [0.6407, 0.411, 0.7099, 0.4324]}, {"w": "it", "b": [0.7202, 0.411, 0.7322, 0.4324]}, {"w": "is", "b": [0.7425, 0.411, 0.7558, 0.4324]}, {"w": "given,", "b": [0.7661, 0.411, 0.8161, 0.4324]}, {"w": "this", "b": [0.8264, 0.411, 0.8571, 0.4324]}, {"w": "method", "b": [0.1429, 0.4301, 0.2079, 0.4515]}, {"w": "estimates", "b": [0.2155, 0.4301, 0.2926, 0.4515]}, {"w": "the", "b": [0.3001, 0.4301, 0.3265, 0.4515]}, {"w": "log", "b": [0.3341, 0.4301, 0.3597, 0.4515]}, {"w": "of", "b": [0.3673, 0.4301, 0.3841, 0.4515]}, {"w": "the", "b": [0.3917, 0.4301, 0.418, 0.4515]}, {"w": "probability", "b": [0.4256, 0.4299, 0.5134, 0.4515]}, {"w": "density", "b": [0.5211, 0.4299, 0.5788, 0.4515]}, {"w": "function", "b": [0.5864, 0.4299, 0.6545, 0.4515]}, {"w": "(PDF)", "b": [0.6621, 0.4301, 0.7146, 0.4515]}, {"w": "at", "b": [0.7221, 0.4301, 0.7372, 0.4515]}, {"w": "that", "b": [0.7448, 0.4301, 0.7774, 0.4515]}, {"w": "location.", "b": [0.785, 0.4301, 0.8572, 0.4515]}, {"w": "The", "b": [0.1429, 0.4491, 0.1757, 0.4705]}, {"w": "greater", "b": [0.1804, 0.4491, 0.2384, 0.4705]}, {"w": "the", "b": [0.2432, 0.4491, 0.2695, 0.4705]}, {"w": "score,", "b": [0.2742, 0.4491, 0.3227, 0.4705]}, {"w": "the", "b": [0.3274, 0.4491, 0.3537, 0.4705]}, {"w": "higher", "b": [0.3584, 0.4491, 0.4126, 0.4705]}, {"w": "the", "b": [0.4173, 0.4491, 0.4437, 0.4705]}, {"w": "density:", "b": [0.4484, 0.4491, 0.5142, 0.4705]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> gm.score_samples(X) array([-2.60782346, -3.57106041, -3.33003479, ..., -3.51352783, -4.39802535, -3.80743859])", "words": [{"w": ">>>", "b": [0.1766, 0.4811, 0.2019, 0.4939]}, {"w": "gm.score_samples(X)", "b": [0.2103, 0.4811, 0.3705, 0.4939]}, {"w": "array([-2.60782346,", "b": [0.1766, 0.4965, 0.3368, 0.5094]}, {"w": "-3.57106041,", "b": [0.3452, 0.4965, 0.4464, 0.5094]}, {"w": "-3.33003479,", "b": [0.4549, 0.4965, 0.5561, 0.5094]}, {"w": "...,", "b": [0.5645, 0.4965, 0.5982, 0.5094]}, {"w": "-3.51352783,", "b": [0.6066, 0.4965, 0.7078, 0.5094]}, {"w": "-4.39802535,", "b": [0.2356, 0.5119, 0.3368, 0.5248]}, {"w": "-3.80743859])", "b": [0.3452, 0.5119, 0.4549, 0.5248]}]}, {"id": "b_6", "type": "paragraph", "text": "If you compute the exponential of these scores, you get the value of the PDF at the location of the given instances. These are not probabilities, but probability densities: they can take on any positive value, not just between 0 and 1. To estimate the proba‐ bility that an instance will fall within a particular region, you would have to integrate the PDF over that region (if you do so over the entire space of possible instance loca‐ tions, the result will be 1).", "words": [{"w": "If", "b": [0.1429, 0.5326, 0.1561, 0.554]}, {"w": "you", "b": [0.1629, 0.5326, 0.1941, 0.554]}, {"w": "compute", "b": [0.2008, 0.5326, 0.2741, 0.554]}, {"w": "the", "b": [0.2808, 0.5326, 0.3072, 0.554]}, {"w": "exponential", "b": [0.3139, 0.5326, 0.4117, 0.554]}, {"w": "of", "b": [0.4184, 0.5326, 0.4352, 0.554]}, {"w": "these", "b": [0.4419, 0.5326, 0.4848, 0.554]}, {"w": "scores,", "b": [0.4915, 0.5326, 0.5475, 0.554]}, {"w": "you", "b": [0.5543, 0.5326, 0.5855, 0.554]}, {"w": "get", "b": [0.5922, 0.5326, 0.6172, 0.554]}, {"w": "the", "b": [0.6239, 0.5326, 0.6502, 0.554]}, {"w": "value", "b": [0.657, 0.5326, 0.7009, 0.554]}, {"w": "of", "b": [0.7077, 0.5326, 0.7244, 0.554]}, {"w": "the", "b": [0.7312, 0.5326, 0.7575, 0.554]}, {"w": "PDF", "b": [0.7642, 0.5326, 0.8023, 0.554]}, {"w": "at", "b": [0.809, 0.5326, 0.8241, 0.554]}, {"w": "the", "b": [0.8308, 0.5326, 0.8571, 0.554]}, {"w": "location", "b": [0.1429, 0.5516, 0.2103, 0.573]}, {"w": "of", "b": [0.2168, 0.5516, 0.2336, 0.573]}, {"w": "the", "b": [0.2402, 0.5516, 0.2665, 0.573]}, {"w": "given", "b": [0.273, 0.5516, 0.3183, 0.573]}, {"w": "instances.", "b": [0.3248, 0.5516, 0.4064, 0.573]}, {"w": "These", "b": [0.4129, 0.5516, 0.4623, 0.573]}, {"w": "are", "b": [0.4688, 0.5516, 0.4945, 0.573]}, {"w": "not", "b": [0.5011, 0.5514, 0.5279, 0.573]}, {"w": "probabilities,", "b": [0.5345, 0.5516, 0.6437, 0.573]}, {"w": "but", "b": [0.6502, 0.5516, 0.6782, 0.573]}, {"w": "probability", "b": [0.6848, 0.5516, 0.7767, 0.573]}, {"w": "densities:", "b": [0.7833, 0.5514, 0.8571, 0.573]}, {"w": "they", "b": [0.1429, 0.5707, 0.1787, 0.5921]}, {"w": "can", "b": [0.1844, 0.5707, 0.2138, 0.5921]}, {"w": "take", "b": [0.2195, 0.5707, 0.2541, 0.5921]}, {"w": "on", "b": [0.2598, 0.5707, 0.2819, 0.5921]}, {"w": "any", "b": [0.2875, 0.5707, 0.3172, 0.5921]}, {"w": "positive", "b": [0.3228, 0.5707, 0.388, 0.5921]}, {"w": "value,", "b": [0.3937, 0.5707, 0.4425, 0.5921]}, {"w": "not", "b": [0.4481, 0.5707, 0.4765, 0.5921]}, {"w": "just", "b": [0.4822, 0.5707, 0.5126, 0.5921]}, {"w": "between", "b": [0.5183, 0.5707, 0.5874, 0.5921]}, {"w": "0", "b": [0.5931, 0.5707, 0.6031, 0.5921]}, {"w": "and", "b": [0.6088, 0.5707, 0.6403, 0.5921]}, {"w": "1.", "b": [0.646, 0.5707, 0.6608, 0.5921]}, {"w": "To", "b": [0.6664, 0.5707, 0.6879, 0.5921]}, {"w": "estimate", "b": [0.6936, 0.5707, 0.763, 0.5921]}, {"w": "the", "b": [0.7687, 0.5707, 0.795, 0.5921]}, {"w": "proba‐", "b": [0.8007, 0.5707, 0.8571, 0.5921]}, {"w": "bility", "b": [0.1429, 0.5897, 0.1858, 0.6111]}, {"w": "that", "b": [0.1913, 0.5897, 0.2239, 0.6111]}, {"w": "an", "b": [0.2294, 0.5897, 0.2499, 0.6111]}, {"w": "instance", "b": [0.2554, 0.5897, 0.3246, 0.6111]}, {"w": "will", "b": [0.3301, 0.5897, 0.3605, 0.6111]}, {"w": "fall", "b": [0.3659, 0.5897, 0.3918, 0.6111]}, {"w": "within", "b": [0.3973, 0.5897, 0.4516, 0.6111]}, {"w": "a", "b": [0.4571, 0.5897, 0.4662, 0.6111]}, {"w": "particular", "b": [0.4717, 0.5897, 0.5535, 0.6111]}, {"w": "region,", "b": [0.5589, 0.5897, 0.6176, 0.6111]}, {"w": "you", "b": [0.6231, 0.5897, 0.6544, 0.6111]}, {"w": "would", "b": [0.6599, 0.5897, 0.7121, 0.6111]}, {"w": "have", "b": [0.7176, 0.5897, 0.756, 0.6111]}, {"w": "to", "b": [0.7615, 0.5897, 0.7784, 0.6111]}, {"w": "integrate", "b": [0.7839, 0.5897, 0.8572, 0.6111]}, {"w": "the", "b": [0.1429, 0.6088, 0.1692, 0.6302]}, {"w": "PDF", "b": [0.1745, 0.6088, 0.2126, 0.6302]}, {"w": "over", "b": [0.2179, 0.6088, 0.2547, 0.6302]}, {"w": "that", "b": [0.2601, 0.6088, 0.2926, 0.6302]}, {"w": "region", "b": [0.298, 0.6088, 0.3519, 0.6302]}, {"w": "(if", "b": [0.3572, 0.6088, 0.3762, 0.6302]}, {"w": "you", "b": [0.3815, 0.6088, 0.4128, 0.6302]}, {"w": "do", "b": [0.4181, 0.6088, 0.4397, 0.6302]}, {"w": "so", "b": [0.445, 0.6088, 0.4633, 0.6302]}, {"w": "over", "b": [0.4686, 0.6088, 0.5055, 0.6302]}, {"w": "the", "b": [0.5108, 0.6088, 0.5371, 0.6302]}, {"w": "entire", "b": [0.5424, 0.6088, 0.5908, 0.6302]}, {"w": "space", "b": [0.5961, 0.6088, 0.6415, 0.6302]}, {"w": "of", "b": [0.6468, 0.6088, 0.6636, 0.6302]}, {"w": "possible", "b": [0.6689, 0.6088, 0.736, 0.6302]}, {"w": "instance", "b": [0.7414, 0.6088, 0.8106, 0.6302]}, {"w": "loca‐", "b": [0.8159, 0.6088, 0.8571, 0.6302]}, {"w": "tions,", "b": [0.1429, 0.6278, 0.1892, 0.6492]}, {"w": "the", "b": [0.1939, 0.6278, 0.2203, 0.6492]}, {"w": "result", "b": [0.225, 0.6278, 0.2719, 0.6492]}, {"w": "will", "b": [0.2766, 0.6278, 0.307, 0.6492]}, {"w": "be", "b": [0.3118, 0.6278, 0.3312, 0.6492]}, {"w": "1).", "b": [0.3359, 0.6278, 0.3579, 0.6492]}]}, {"id": "b_7", "type": "paragraph", "text": "Figure 9-17 shows the cluster means, the decision boundaries (dashed lines), and the density contours of this model:", "words": [{"w": "Figure", "b": [0.1429, 0.6559, 0.1969, 0.6773]}, {"w": "9-17", "b": [0.2024, 0.6559, 0.2398, 0.6773]}, {"w": "shows", "b": [0.2454, 0.6559, 0.2967, 0.6773]}, {"w": "the", "b": [0.3022, 0.6559, 0.3286, 0.6773]}, {"w": "cluster", "b": [0.3341, 0.6559, 0.3899, 0.6773]}, {"w": "means,", "b": [0.3954, 0.6559, 0.4543, 0.6773]}, {"w": "the", "b": [0.4598, 0.6559, 0.4861, 0.6773]}, {"w": "decision", "b": [0.4917, 0.6559, 0.5612, 0.6773]}, {"w": "boundaries", "b": [0.5667, 0.6559, 0.6604, 0.6773]}, {"w": "(dashed", "b": [0.6659, 0.6559, 0.7319, 0.6773]}, {"w": "lines),", "b": [0.7375, 0.6559, 0.7882, 0.6773]}, {"w": "and", "b": [0.7937, 0.6559, 0.8253, 0.6773]}, {"w": "the", "b": [0.8308, 0.6559, 0.8571, 0.6773]}, {"w": "density", "b": [0.1428, 0.675, 0.2032, 0.6964]}, {"w": "contours", "b": [0.208, 0.675, 0.2818, 0.6964]}, {"w": "of", "b": [0.2866, 0.675, 0.3033, 0.6964]}, {"w": "this", "b": [0.3081, 0.675, 0.3388, 0.6964]}, {"w": "model:", "b": [0.3435, 0.675, 0.4011, 0.6964]}]}, {"id": "b_8", "type": "paragraph", "text": "264 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "264", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 291, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Figure 9-17. Cluster means, decision boundaries and density contours of a trained Gaus‐ sian mixture model", "words": [{"w": "Figure", "b": [0.1429, 0.2817, 0.1943, 0.3033]}, {"w": "9-17.", "b": [0.1991, 0.2817, 0.2407, 0.3033]}, {"w": "Cluster", "b": [0.2455, 0.2817, 0.3038, 0.3033]}, {"w": "means,", "b": [0.3086, 0.2817, 0.3659, 0.3033]}, {"w": "decision", "b": [0.3707, 0.2817, 0.4362, 0.3033]}, {"w": "boundaries", "b": [0.441, 0.2817, 0.5313, 0.3033]}, {"w": "and", "b": [0.5361, 0.2817, 0.5675, 0.3033]}, {"w": "density", "b": [0.5723, 0.2817, 0.63, 0.3033]}, {"w": "contours", "b": [0.6348, 0.2817, 0.704, 0.3033]}, {"w": "of", "b": [0.7087, 0.2817, 0.7239, 0.3033]}, {"w": "a", "b": [0.7287, 0.2817, 0.7389, 0.3033]}, {"w": "trained", "b": [0.7437, 0.2817, 0.8021, 0.3033]}, {"w": "Gaus‐", "b": [0.8069, 0.2817, 0.8562, 0.3033]}, {"w": "sian", "b": [0.1429, 0.3008, 0.1762, 0.3224]}, {"w": "mixture", "b": [0.181, 0.3008, 0.2452, 0.3224]}, {"w": "model", "b": [0.25, 0.3008, 0.2996, 0.3224]}]}, {"id": "b_1", "type": "paragraph", "text": "Nice! The algorithm clearly found an excellent solution. Of course, we made its task easy by actually generating the data using a set of 2D Gaussian distributions (unfortu‐ nately, real life data is not always so Gaussian and low-dimensional), and we also gave the algorithm the correct number of clusters. When there are many dimensions, or many clusters, or few instances, EM can struggle to converge to the optimal solution. You might need to reduce the difficulty of the task by limiting the number of parame‐ ters that the algorithm has to learn: one way to do this is to limit the range of shapes and orientations that the clusters can have. This can be achieved by imposing con‐ straints on the covariance matrices. To do this, just set the covariance_type hyper‐ parameter to one of the following values:", "words": [{"w": "Nice!", "b": [0.1429, 0.3381, 0.1869, 0.3596]}, {"w": "The", "b": [0.193, 0.3381, 0.2258, 0.3596]}, {"w": "algorithm", "b": [0.232, 0.3381, 0.3146, 0.3596]}, {"w": "clearly", "b": [0.3207, 0.3381, 0.3754, 0.3596]}, {"w": "found", "b": [0.3815, 0.3381, 0.4317, 0.3596]}, {"w": "an", "b": [0.4378, 0.3381, 0.4584, 0.3596]}, {"w": "excellent", "b": [0.4645, 0.3381, 0.5376, 0.3596]}, {"w": "solution.", "b": [0.5437, 0.3381, 0.617, 0.3596]}, {"w": "Of", "b": [0.6231, 0.3381, 0.6449, 0.3596]}, {"w": "course,", "b": [0.651, 0.3381, 0.7104, 0.3596]}, {"w": "we", "b": [0.7166, 0.3381, 0.7397, 0.3596]}, {"w": "made", "b": [0.7458, 0.3381, 0.7919, 0.3596]}, {"w": "its", "b": [0.798, 0.3381, 0.8176, 0.3596]}, {"w": "task", "b": [0.8237, 0.3381, 0.8571, 0.3596]}, {"w": "easy", "b": [0.1429, 0.3572, 0.1781, 0.3786]}, {"w": "by", "b": [0.1829, 0.3572, 0.203, 0.3786]}, {"w": "actually", "b": [0.2078, 0.3572, 0.2724, 0.3786]}, {"w": "generating", "b": [0.2772, 0.3572, 0.3657, 0.3786]}, {"w": "the", "b": [0.3705, 0.3572, 0.3968, 0.3786]}, {"w": "data", "b": [0.4016, 0.3572, 0.4369, 0.3786]}, {"w": "using", "b": [0.4417, 0.3572, 0.4871, 0.3786]}, {"w": "a", "b": [0.4919, 0.3572, 0.5011, 0.3786]}, {"w": "set", "b": [0.5059, 0.3572, 0.5287, 0.3786]}, {"w": "of", "b": [0.5335, 0.3572, 0.5503, 0.3786]}, {"w": "2D", "b": [0.5551, 0.3572, 0.5804, 0.3786]}, {"w": "Gaussian", "b": [0.5852, 0.3572, 0.6614, 0.3786]}, {"w": "distributions", "b": [0.6662, 0.3572, 0.7733, 0.3786]}, {"w": "(unfortu‐", "b": [0.7781, 0.3572, 0.8571, 0.3786]}, {"w": "nately,", "b": [0.1429, 0.3762, 0.1963, 0.3977]}, {"w": "real", "b": [0.2012, 0.3762, 0.2322, 0.3977]}, {"w": "life", "b": [0.2371, 0.3762, 0.263, 0.3977]}, {"w": "data", "b": [0.268, 0.3762, 0.3032, 0.3977]}, {"w": "is", "b": [0.3081, 0.3762, 0.3214, 0.3977]}, {"w": "not", "b": [0.3263, 0.3762, 0.3547, 0.3977]}, {"w": "always", "b": [0.3596, 0.3762, 0.4143, 0.3977]}, {"w": "so", "b": [0.4192, 0.3762, 0.4375, 0.3977]}, {"w": "Gaussian", "b": [0.4424, 0.3762, 0.5185, 0.3977]}, {"w": "and", "b": [0.5235, 0.3762, 0.555, 0.3977]}, {"w": "low-dimensional),", "b": [0.5599, 0.3762, 0.713, 0.3977]}, {"w": "and", "b": [0.718, 0.3762, 0.7495, 0.3977]}, {"w": "we", "b": [0.7545, 0.3762, 0.7776, 0.3977]}, {"w": "also", "b": [0.7825, 0.3762, 0.8152, 0.3977]}, {"w": "gave", "b": [0.8201, 0.3762, 0.8572, 0.3977]}, {"w": "the", "b": [0.1429, 0.3953, 0.1692, 0.4167]}, {"w": "algorithm", "b": [0.176, 0.3953, 0.2587, 0.4167]}, {"w": "the", "b": [0.2655, 0.3953, 0.2918, 0.4167]}, {"w": "correct", "b": [0.2987, 0.3953, 0.3576, 0.4167]}, {"w": "number", "b": [0.3644, 0.3953, 0.4307, 0.4167]}, {"w": "of", "b": [0.4376, 0.3953, 0.4543, 0.4167]}, {"w": "clusters.", "b": [0.4612, 0.3953, 0.5293, 0.4167]}, {"w": "When", "b": [0.5361, 0.3953, 0.5877, 0.4167]}, {"w": "there", "b": [0.5946, 0.3953, 0.6375, 0.4167]}, {"w": "are", "b": [0.6443, 0.3953, 0.6701, 0.4167]}, {"w": "many", "b": [0.6769, 0.3953, 0.7236, 0.4167]}, {"w": "dimensions,", "b": [0.7304, 0.3953, 0.832, 0.4167]}, {"w": "or", "b": [0.8388, 0.3953, 0.8571, 0.4167]}, {"w": "many", "b": [0.1429, 0.4143, 0.1895, 0.4358]}, {"w": "clusters,", "b": [0.195, 0.4143, 0.2631, 0.4358]}, {"w": "or", "b": [0.2685, 0.4143, 0.2868, 0.4358]}, {"w": "few", "b": [0.2923, 0.4143, 0.3215, 0.4358]}, {"w": "instances,", "b": [0.327, 0.4143, 0.4085, 0.4358]}, {"w": "EM", "b": [0.4139, 0.4143, 0.4443, 0.4358]}, {"w": "can", "b": [0.4498, 0.4143, 0.4791, 0.4358]}, {"w": "struggle", "b": [0.4845, 0.4143, 0.5509, 0.4358]}, {"w": "to", "b": [0.5563, 0.4143, 0.5733, 0.4358]}, {"w": "converge", "b": [0.5787, 0.4143, 0.6539, 0.4358]}, {"w": "to", "b": [0.6593, 0.4143, 0.6763, 0.4358]}, {"w": "the", "b": [0.6817, 0.4143, 0.708, 0.4358]}, {"w": "optimal", "b": [0.7135, 0.4143, 0.7784, 0.4358]}, {"w": "solution.", "b": [0.7838, 0.4143, 0.8571, 0.4358]}, {"w": "You", "b": [0.1428, 0.4334, 0.1752, 0.4548]}, {"w": "might", "b": [0.1801, 0.4334, 0.2296, 0.4548]}, {"w": "need", "b": [0.2346, 0.4334, 0.2747, 0.4548]}, {"w": "to", "b": [0.2796, 0.4334, 0.2966, 0.4548]}, {"w": "reduce", "b": [0.3015, 0.4334, 0.3578, 0.4548]}, {"w": "the", "b": [0.3628, 0.4334, 0.3891, 0.4548]}, {"w": "difficulty", "b": [0.3941, 0.4334, 0.4696, 0.4548]}, {"w": "of", "b": [0.4746, 0.4334, 0.4914, 0.4548]}, {"w": "the", "b": [0.4963, 0.4334, 0.5226, 0.4548]}, {"w": "task", "b": [0.5276, 0.4334, 0.5611, 0.4548]}, {"w": "by", "b": [0.566, 0.4334, 0.5861, 0.4548]}, {"w": "limiting", "b": [0.5911, 0.4334, 0.6577, 0.4548]}, {"w": "the", "b": [0.6626, 0.4334, 0.689, 0.4548]}, {"w": "number", "b": [0.6939, 0.4334, 0.7602, 0.4548]}, {"w": "of", "b": [0.7651, 0.4334, 0.7819, 0.4548]}, {"w": "parame‐", "b": [0.7869, 0.4334, 0.8571, 0.4548]}, {"w": "ters", "b": [0.1429, 0.4524, 0.1734, 0.4738]}, {"w": "that", "b": [0.1791, 0.4524, 0.2117, 0.4738]}, {"w": "the", "b": [0.2174, 0.4524, 0.2437, 0.4738]}, {"w": "algorithm", "b": [0.2494, 0.4524, 0.3321, 0.4738]}, {"w": "has", "b": [0.3377, 0.4524, 0.3657, 0.4738]}, {"w": "to", "b": [0.3713, 0.4524, 0.3883, 0.4738]}, {"w": "learn:", "b": [0.394, 0.4524, 0.4412, 0.4738]}, {"w": "one", "b": [0.4468, 0.4524, 0.4777, 0.4738]}, {"w": "way", "b": [0.4834, 0.4524, 0.516, 0.4738]}, {"w": "to", "b": [0.5217, 0.4524, 0.5387, 0.4738]}, {"w": "do", "b": [0.5443, 0.4524, 0.566, 0.4738]}, {"w": "this", "b": [0.5717, 0.4524, 0.6024, 0.4738]}, {"w": "is", "b": [0.608, 0.4524, 0.6213, 0.4738]}, {"w": "to", "b": [0.627, 0.4524, 0.6439, 0.4738]}, {"w": "limit", "b": [0.6496, 0.4524, 0.6895, 0.4738]}, {"w": "the", "b": [0.6952, 0.4524, 0.7215, 0.4738]}, {"w": "range", "b": [0.7272, 0.4524, 0.7741, 0.4738]}, {"w": "of", "b": [0.7797, 0.4524, 0.7965, 0.4738]}, {"w": "shapes", "b": [0.8022, 0.4524, 0.8571, 0.4738]}, {"w": "and", "b": [0.1429, 0.4715, 0.1744, 0.4929]}, {"w": "orientations", "b": [0.1815, 0.4715, 0.282, 0.4929]}, {"w": "that", "b": [0.289, 0.4715, 0.3216, 0.4929]}, {"w": "the", "b": [0.3287, 0.4715, 0.355, 0.4929]}, {"w": "clusters", "b": [0.3621, 0.4715, 0.4255, 0.4929]}, {"w": "can", "b": [0.4325, 0.4715, 0.4619, 0.4929]}, {"w": "have.", "b": [0.4689, 0.4715, 0.5121, 0.4929]}, {"w": "This", "b": [0.5192, 0.4715, 0.5564, 0.4929]}, {"w": "can", "b": [0.5634, 0.4715, 0.5928, 0.4929]}, {"w": "be", "b": [0.5999, 0.4715, 0.6193, 0.4929]}, {"w": "achieved", "b": [0.6264, 0.4715, 0.6994, 0.4929]}, {"w": "by", "b": [0.7064, 0.4715, 0.7266, 0.4929]}, {"w": "imposing", "b": [0.7337, 0.4715, 0.8118, 0.4929]}, {"w": "con‐", "b": [0.8189, 0.4715, 0.8571, 0.4929]}, {"w": "straints", "b": [0.1429, 0.4914, 0.2043, 0.5128]}, {"w": "on", "b": [0.2108, 0.4914, 0.2328, 0.5128]}, {"w": "the", "b": [0.2392, 0.4914, 0.2656, 0.5128]}, {"w": "covariance", "b": [0.272, 0.4914, 0.3618, 0.5128]}, {"w": "matrices.", "b": [0.3683, 0.4914, 0.4438, 0.5128]}, {"w": "To", "b": [0.4503, 0.4914, 0.4717, 0.5128]}, {"w": "do", "b": [0.4782, 0.4914, 0.4998, 0.5128]}, {"w": "this,", "b": [0.5062, 0.4914, 0.5417, 0.5128]}, {"w": "just", "b": [0.5482, 0.4914, 0.5785, 0.5128]}, {"w": "set", "b": [0.585, 0.4914, 0.6079, 0.5128]}, {"w": "the", "b": [0.6143, 0.4914, 0.6407, 0.5128]}, {"w": "covariance_type", "b": [0.6471, 0.4946, 0.7956, 0.5097]}, {"w": "hyper‐", "b": [0.802, 0.4914, 0.8571, 0.5128]}, {"w": "parameter", "b": [0.1429, 0.5105, 0.2287, 0.5319]}, {"w": "to", "b": [0.2334, 0.5105, 0.2504, 0.5319]}, {"w": "one", "b": [0.2551, 0.5105, 0.286, 0.5319]}, {"w": "of", "b": [0.2907, 0.5105, 0.3075, 0.5319]}, {"w": "the", "b": [0.3122, 0.5105, 0.3386, 0.5319]}, {"w": "following", "b": [0.3433, 0.5105, 0.4222, 0.5319]}, {"w": "values:", "b": [0.427, 0.5105, 0.4833, 0.5319]}]}, {"id": "b_2", "type": "paragraph", "text": "• \"spherical\": all clusters must be spherical, but they can have different diameters (i.e., different variances).", "words": [{"w": "•", "b": [0.16, 0.5455, 0.1682, 0.5669]}, {"w": "\"spherical\":", "b": [0.1786, 0.5455, 0.2922, 0.5669]}, {"w": "all", "b": [0.2972, 0.5455, 0.3169, 0.5669]}, {"w": "clusters", "b": [0.3219, 0.5455, 0.3853, 0.5669]}, {"w": "must", "b": [0.3903, 0.5455, 0.4321, 0.5669]}, {"w": "be", "b": [0.4371, 0.5455, 0.4565, 0.5669]}, {"w": "spherical,", "b": [0.4616, 0.5455, 0.5414, 0.5669]}, {"w": "but", "b": [0.5464, 0.5455, 0.5744, 0.5669]}, {"w": "they", "b": [0.5795, 0.5455, 0.6153, 0.5669]}, {"w": "can", "b": [0.6204, 0.5455, 0.6497, 0.5669]}, {"w": "have", "b": [0.6548, 0.5455, 0.6932, 0.5669]}, {"w": "different", "b": [0.6982, 0.5455, 0.7699, 0.5669]}, {"w": "diameters", "b": [0.7749, 0.5455, 0.8572, 0.5669]}, {"w": "(i.e.,", "b": [0.1786, 0.5646, 0.2145, 0.586]}, {"w": "different", "b": [0.2192, 0.5646, 0.2909, 0.586]}, {"w": "variances).", "b": [0.2956, 0.5646, 0.3855, 0.586]}]}, {"id": "b_3", "type": "paragraph", "text": "• \"diag\": clusters can take on any ellipsoidal shape of any size, but the ellipsoid’s axes must be parallel to the coordinate axes (i.e., the covariance matrices must be diagonal).", "words": [{"w": "•", "b": [0.16, 0.5906, 0.1682, 0.612]}, {"w": "\"diag\":", "b": [0.1786, 0.5906, 0.2427, 0.612]}, {"w": "clusters", "b": [0.2493, 0.5906, 0.3127, 0.612]}, {"w": "can", "b": [0.3193, 0.5906, 0.3487, 0.612]}, {"w": "take", "b": [0.3553, 0.5906, 0.39, 0.612]}, {"w": "on", "b": [0.3966, 0.5906, 0.4186, 0.612]}, {"w": "any", "b": [0.4252, 0.5906, 0.4549, 0.612]}, {"w": "ellipsoidal", "b": [0.4615, 0.5906, 0.5467, 0.612]}, {"w": "shape", "b": [0.5533, 0.5906, 0.6006, 0.612]}, {"w": "of", "b": [0.6072, 0.5906, 0.624, 0.612]}, {"w": "any", "b": [0.6306, 0.5906, 0.6602, 0.612]}, {"w": "size,", "b": [0.6669, 0.5906, 0.7024, 0.612]}, {"w": "but", "b": [0.7091, 0.5906, 0.7371, 0.612]}, {"w": "the", "b": [0.7437, 0.5906, 0.77, 0.612]}, {"w": "ellipsoid’s", "b": [0.7766, 0.5906, 0.8572, 0.612]}, {"w": "axes", "b": [0.1786, 0.6096, 0.214, 0.631]}, {"w": "must", "b": [0.2193, 0.6096, 0.261, 0.631]}, {"w": "be", "b": [0.2662, 0.6096, 0.2857, 0.631]}, {"w": "parallel", "b": [0.2909, 0.6096, 0.3525, 0.631]}, {"w": "to", "b": [0.3577, 0.6096, 0.3747, 0.631]}, {"w": "the", "b": [0.3799, 0.6096, 0.4062, 0.631]}, {"w": "coordinate", "b": [0.4115, 0.6096, 0.5012, 0.631]}, {"w": "axes", "b": [0.5064, 0.6096, 0.5419, 0.631]}, {"w": "(i.e.,", "b": [0.5471, 0.6096, 0.583, 0.631]}, {"w": "the", "b": [0.5882, 0.6096, 0.6146, 0.631]}, {"w": "covariance", "b": [0.6198, 0.6096, 0.7095, 0.631]}, {"w": "matrices", "b": [0.7147, 0.6096, 0.7855, 0.631]}, {"w": "must", "b": [0.7908, 0.6096, 0.8325, 0.631]}, {"w": "be", "b": [0.8377, 0.6096, 0.8571, 0.631]}, {"w": "diagonal).", "b": [0.1786, 0.6287, 0.2625, 0.6501]}]}, {"id": "b_4", "type": "paragraph", "text": "• \"tied\": all clusters must have the same ellipsoidal shape, size and orientation (i.e., all clusters share the same covariance matrix).", "words": [{"w": "•", "b": [0.16, 0.6547, 0.1681, 0.6761]}, {"w": "\"tied\":", "b": [0.1786, 0.6547, 0.2427, 0.6761]}, {"w": "all", "b": [0.2509, 0.6547, 0.2706, 0.6761]}, {"w": "clusters", "b": [0.2787, 0.6547, 0.3421, 0.6761]}, {"w": "must", "b": [0.3503, 0.6547, 0.392, 0.6761]}, {"w": "have", "b": [0.4001, 0.6547, 0.4385, 0.6761]}, {"w": "the", "b": [0.4467, 0.6547, 0.473, 0.6761]}, {"w": "same", "b": [0.4812, 0.6547, 0.5239, 0.6761]}, {"w": "ellipsoidal", "b": [0.5321, 0.6547, 0.6172, 0.6761]}, {"w": "shape,", "b": [0.6254, 0.6547, 0.6774, 0.6761]}, {"w": "size", "b": [0.6856, 0.6547, 0.7164, 0.6761]}, {"w": "and", "b": [0.7246, 0.6547, 0.7561, 0.6761]}, {"w": "orientation", "b": [0.7643, 0.6547, 0.8572, 0.6761]}, {"w": "(i.e.,", "b": [0.1786, 0.6737, 0.2145, 0.6951]}, {"w": "all", "b": [0.2192, 0.6737, 0.2389, 0.6951]}, {"w": "clusters", "b": [0.2436, 0.6737, 0.307, 0.6951]}, {"w": "share", "b": [0.3117, 0.6737, 0.3562, 0.6951]}, {"w": "the", "b": [0.3609, 0.6737, 0.3873, 0.6951]}, {"w": "same", "b": [0.392, 0.6737, 0.4347, 0.6951]}, {"w": "covariance", "b": [0.4394, 0.6737, 0.5292, 0.6951]}, {"w": "matrix).", "b": [0.5339, 0.6737, 0.6012, 0.6951]}]}, {"id": "b_5", "type": "paragraph", "text": "By default, covariance_type is equal to \"full\", which means that each cluster can take on any shape, size and orientation (it has its own unconstrained covariance matrix). Figure 9-18 plots the solutions found by the EM algorithm when cova riance_type is set to \"tied\" or \"spherical“.", "words": [{"w": "By", "b": [0.1429, 0.7088, 0.1647, 0.7302]}, {"w": "default,", "b": [0.1715, 0.7088, 0.2337, 0.7302]}, {"w": "covariance_type", "b": [0.2405, 0.712, 0.389, 0.727]}, {"w": "is", "b": [0.3958, 0.7088, 0.409, 0.7302]}, {"w": "equal", "b": [0.4158, 0.7088, 0.4608, 0.7302]}, {"w": "to", "b": [0.4676, 0.7088, 0.4846, 0.7302]}, {"w": "\"full\",", "b": [0.4915, 0.7088, 0.5556, 0.7302]}, {"w": "which", "b": [0.5624, 0.7088, 0.6133, 0.7302]}, {"w": "means", "b": [0.6201, 0.7088, 0.6742, 0.7302]}, {"w": "that", "b": [0.6811, 0.7088, 0.7137, 0.7302]}, {"w": "each", "b": [0.7205, 0.7088, 0.7584, 0.7302]}, {"w": "cluster", "b": [0.7652, 0.7088, 0.821, 0.7302]}, {"w": "can", "b": [0.8278, 0.7088, 0.8571, 0.7302]}, {"w": "take", "b": [0.1429, 0.7278, 0.1775, 0.7492]}, {"w": "on", "b": [0.1865, 0.7278, 0.2085, 0.7492]}, {"w": "any", "b": [0.2174, 0.7278, 0.247, 0.7492]}, {"w": "shape,", "b": [0.2559, 0.7278, 0.308, 0.7492]}, {"w": "size", "b": [0.3169, 0.7278, 0.3477, 0.7492]}, {"w": "and", "b": [0.3566, 0.7278, 0.3882, 0.7492]}, {"w": "orientation", "b": [0.3971, 0.7278, 0.49, 0.7492]}, {"w": "(it", "b": [0.4989, 0.7278, 0.518, 0.7492]}, {"w": "has", "b": [0.5269, 0.7278, 0.5549, 0.7492]}, {"w": "its", "b": [0.5638, 0.7278, 0.5833, 0.7492]}, {"w": "own", "b": [0.5923, 0.7278, 0.6286, 0.7492]}, {"w": "unconstrained", "b": [0.6375, 0.7278, 0.7585, 0.7492]}, {"w": "covariance", "b": [0.7674, 0.7278, 0.8571, 0.7492]}, {"w": "matrix).", "b": [0.1428, 0.7478, 0.2101, 0.7692]}, {"w": "Figure", "b": [0.2195, 0.7478, 0.2735, 0.7692]}, {"w": "9-18", "b": [0.2829, 0.7478, 0.3203, 0.7692]}, {"w": "plots", "b": [0.3297, 0.7478, 0.3706, 0.7692]}, {"w": "the", "b": [0.38, 0.7478, 0.4063, 0.7692]}, {"w": "solutions", "b": [0.4157, 0.7478, 0.4919, 0.7692]}, {"w": "found", "b": [0.5013, 0.7478, 0.5515, 0.7692]}, {"w": "by", "b": [0.5609, 0.7478, 0.5811, 0.7692]}, {"w": "the", "b": [0.5905, 0.7478, 0.6168, 0.7692]}, {"w": "EM", "b": [0.6262, 0.7478, 0.6566, 0.7692]}, {"w": "algorithm", "b": [0.666, 0.7478, 0.7487, 0.7692]}, {"w": "when", "b": [0.7581, 0.7478, 0.8037, 0.7692]}, {"w": "cova", "b": [0.8131, 0.7509, 0.8527, 0.766]}, {"w": "riance_type", "b": [0.1428, 0.7709, 0.2517, 0.786]}, {"w": "is", "b": [0.2564, 0.7677, 0.2697, 0.7891]}, {"w": "set", "b": [0.2744, 0.7677, 0.2972, 0.7891]}, {"w": "to", "b": [0.302, 0.7677, 0.319, 0.7891]}, {"w": "\"tied\"", "b": [0.3237, 0.7709, 0.3831, 0.786]}, {"w": "or", "b": [0.3878, 0.7677, 0.4061, 0.7891]}, {"w": "\"spherical“.", "b": [0.4109, 0.7677, 0.5173, 0.7891]}]}, {"id": "b_6", "type": "paragraph", "text": "Gaussian Mixtures | 265", "words": [{"w": "Gaussian", "b": [0.6892, 0.9225, 0.7415, 0.9388]}, {"w": "Mixtures", "b": [0.7443, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "265", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 292, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 9-18. covariance_type_diagram", "words": [{"w": "Figure", "b": [0.1429, 0.2622, 0.1943, 0.2838]}, {"w": "9-18.", "b": [0.1991, 0.2622, 0.2407, 0.2838]}, {"w": "covariance_type_diagram", "b": [0.2455, 0.2622, 0.4556, 0.2838]}]}, {"id": "b_1", "type": "paragraph", "text": "The computational complexity of training a GaussianMixture model depends on the number of instances m, the number of dimensions n, the number of clusters k, and the constraints on the covariance matrices. If covariance_type is \"spherical or \"diag\", it is O(kmn), assuming the data has a clustering structure. If cova riance_type is \"tied\" or \"full\", it is O(kmn2 + kn3), so it will not scale to large numbers of features.", "words": [{"w": "The", "b": [0.2714, 0.3051, 0.3014, 0.3247]}, {"w": "computational", "b": [0.3128, 0.3051, 0.4239, 0.3247]}, {"w": "complexity", "b": [0.4352, 0.3051, 0.5198, 0.3247]}, {"w": "of", "b": [0.5311, 0.3051, 0.5465, 0.3247]}, {"w": "training", "b": [0.5578, 0.3051, 0.619, 0.3247]}, {"w": "a", "b": [0.6303, 0.3051, 0.6387, 0.3247]}, {"w": "GaussianMixture", "b": [0.65, 0.308, 0.7857, 0.3218]}, {"w": "model", "b": [0.2714, 0.3226, 0.3197, 0.3421]}, {"w": "depends", "b": [0.329, 0.3226, 0.3926, 0.3421]}, {"w": "on", "b": [0.4019, 0.3226, 0.422, 0.3421]}, {"w": "the", "b": [0.4313, 0.3226, 0.4554, 0.3421]}, {"w": "number", "b": [0.4646, 0.3226, 0.5252, 0.3421]}, {"w": "of", "b": [0.5345, 0.3226, 0.5498, 0.3421]}, {"w": "instances", "b": [0.5591, 0.3226, 0.6293, 0.3421]}, {"w": "m,", "b": [0.6386, 0.3224, 0.6579, 0.3421]}, {"w": "the", "b": [0.6672, 0.3226, 0.6913, 0.3421]}, {"w": "number", "b": [0.7005, 0.3226, 0.7611, 0.3421]}, {"w": "of", "b": [0.7704, 0.3226, 0.7857, 0.3421]}, {"w": "dimensions", "b": [0.2714, 0.34, 0.3599, 0.3595]}, {"w": "n,", "b": [0.3652, 0.3398, 0.3797, 0.3595]}, {"w": "the", "b": [0.385, 0.34, 0.4091, 0.3595]}, {"w": "number", "b": [0.4144, 0.34, 0.475, 0.3595]}, {"w": "of", "b": [0.4804, 0.34, 0.4957, 0.3595]}, {"w": "clusters", "b": [0.501, 0.34, 0.559, 0.3595]}, {"w": "k,", "b": [0.5643, 0.3398, 0.5776, 0.3595]}, {"w": "and", "b": [0.5829, 0.34, 0.6118, 0.3595]}, {"w": "the", "b": [0.6171, 0.34, 0.6412, 0.3595]}, {"w": "constraints", "b": [0.6465, 0.34, 0.7309, 0.3595]}, {"w": "on", "b": [0.7362, 0.34, 0.7563, 0.3595]}, {"w": "the", "b": [0.7616, 0.34, 0.7857, 0.3595]}, {"w": "covariance", "b": [0.2714, 0.3582, 0.3535, 0.3778]}, {"w": "matrices.", "b": [0.3588, 0.3582, 0.4279, 0.3778]}, {"w": "If", "b": [0.4332, 0.3582, 0.4453, 0.3778]}, {"w": "covariance_type", "b": [0.4507, 0.3611, 0.5864, 0.3749]}, {"w": "is", "b": [0.5917, 0.3582, 0.6038, 0.3778]}, {"w": "\"spherical", "b": [0.6092, 0.3611, 0.6996, 0.3749]}, {"w": "or", "b": [0.705, 0.3582, 0.7218, 0.3778]}, {"w": "\"diag\",", "b": [0.7271, 0.3582, 0.7857, 0.3778]}, {"w": "it", "b": [0.2714, 0.3764, 0.2823, 0.396]}, {"w": "is", "b": [0.2882, 0.3764, 0.3003, 0.396]}, {"w": "O(kmn),", "b": [0.3062, 0.3763, 0.3714, 0.396]}, {"w": "assuming", "b": [0.3773, 0.3764, 0.4498, 0.396]}, {"w": "the", "b": [0.4557, 0.3764, 0.4797, 0.396]}, {"w": "data", "b": [0.4856, 0.3764, 0.5178, 0.396]}, {"w": "has", "b": [0.5237, 0.3764, 0.5493, 0.396]}, {"w": "a", "b": [0.5551, 0.3764, 0.5635, 0.396]}, {"w": "clustering", "b": [0.5694, 0.3764, 0.6448, 0.396]}, {"w": "structure.", "b": [0.6507, 0.3764, 0.7241, 0.396]}, {"w": "If", "b": [0.73, 0.3764, 0.7422, 0.396]}, {"w": "cova", "b": [0.748, 0.3793, 0.7842, 0.3931]}, {"w": "riance_type", "b": [0.2714, 0.3976, 0.3709, 0.4114]}, {"w": "is", "b": [0.3757, 0.3947, 0.3878, 0.4143]}, {"w": "\"tied\"", "b": [0.3925, 0.3976, 0.4468, 0.4114]}, {"w": "or", "b": [0.4515, 0.3947, 0.4683, 0.4143]}, {"w": "\"full\",", "b": [0.4731, 0.3947, 0.5317, 0.4143]}, {"w": "it", "b": [0.5364, 0.3947, 0.5474, 0.4143]}, {"w": "is", "b": [0.5521, 0.3947, 0.5642, 0.4143]}, {"w": "O(kmn2", "b": [0.5689, 0.3945, 0.6292, 0.4143]}, {"w": "+", "b": [0.6339, 0.3947, 0.645, 0.4143]}, {"w": "kn3),", "b": [0.6497, 0.3945, 0.6854, 0.4143]}, {"w": "so", "b": [0.6901, 0.3947, 0.7068, 0.4143]}, {"w": "it", "b": [0.7116, 0.3947, 0.7225, 0.4143]}, {"w": "will", "b": [0.7272, 0.3947, 0.755, 0.4143]}, {"w": "not", "b": [0.7598, 0.3947, 0.7857, 0.4143]}, {"w": "scale", "b": [0.2714, 0.4121, 0.3077, 0.4317]}, {"w": "to", "b": [0.3121, 0.4121, 0.3276, 0.4317]}, {"w": "large", "b": [0.3319, 0.4121, 0.3692, 0.4317]}, {"w": "numbers", "b": [0.3735, 0.4121, 0.4411, 0.4317]}, {"w": "of", "b": [0.4454, 0.4121, 0.4608, 0.4317]}, {"w": "features.", "b": [0.4651, 0.4121, 0.5292, 0.4317]}]}, {"id": "b_2", "type": "paragraph", "text": "Gaussian mixture models can also be used for anomaly detection. Let’s see how.", "words": [{"w": "Gaussian", "b": [0.1429, 0.452, 0.219, 0.4734]}, {"w": "mixture", "b": [0.2237, 0.452, 0.2902, 0.4734]}, {"w": "models", "b": [0.2949, 0.452, 0.3554, 0.4734]}, {"w": "can", "b": [0.3601, 0.452, 0.3895, 0.4734]}, {"w": "also", "b": [0.3942, 0.452, 0.4269, 0.4734]}, {"w": "be", "b": [0.4316, 0.452, 0.451, 0.4734]}, {"w": "used", "b": [0.4558, 0.452, 0.4943, 0.4734]}, {"w": "for", "b": [0.4991, 0.452, 0.5236, 0.4734]}, {"w": "anomaly", "b": [0.5283, 0.452, 0.6005, 0.4734]}, {"w": "detection.", "b": [0.6053, 0.452, 0.6878, 0.4734]}, {"w": "Let’s", "b": [0.6926, 0.452, 0.7287, 0.4734]}, {"w": "see", "b": [0.7335, 0.452, 0.7588, 0.4734]}, {"w": "how.", "b": [0.7635, 0.452, 0.8028, 0.4734]}]}, {"id": "b_3", "type": "paragraph", "text": "Anomaly Detection using Gaussian Mixtures", "words": [{"w": "Anomaly", "b": [0.1429, 0.4861, 0.2343, 0.5147]}, {"w": "Detection", "b": [0.2392, 0.4861, 0.3391, 0.5147]}, {"w": "using", "b": [0.344, 0.4861, 0.4004, 0.5147]}, {"w": "Gaussian", "b": [0.4053, 0.4861, 0.497, 0.5147]}, {"w": "Mixtures", "b": [0.5019, 0.4861, 0.5922, 0.5147]}]}, {"id": "b_4", "type": "paragraph", "text": "Anomaly detection (also called outlier detection) is the task of detecting instances that deviate strongly from the norm. These instances are of course called anomalies or outliers, while the normal instances are called inliers. Anomaly detection is very use‐ ful in a wide variety of applications, for example in fraud detection, or for detecting defective products in manufacturing, or to remove outliers from a dataset before training another model, which can significantly improve the performance of the resulting model.", "words": [{"w": "Anomaly", "b": [0.1429, 0.5204, 0.2175, 0.542]}, {"w": "detection", "b": [0.2232, 0.5204, 0.2968, 0.542]}, {"w": "(also", "b": [0.3024, 0.5206, 0.3423, 0.542]}, {"w": "called", "b": [0.348, 0.5206, 0.3963, 0.542]}, {"w": "outlier", "b": [0.4019, 0.5204, 0.455, 0.542]}, {"w": "detection)", "b": [0.4607, 0.5204, 0.5415, 0.542]}, {"w": "is", "b": [0.5471, 0.5206, 0.5604, 0.542]}, {"w": "the", "b": [0.566, 0.5206, 0.5923, 0.542]}, {"w": "task", "b": [0.598, 0.5206, 0.6314, 0.542]}, {"w": "of", "b": [0.6371, 0.5206, 0.6539, 0.542]}, {"w": "detecting", "b": [0.6595, 0.5206, 0.7365, 0.542]}, {"w": "instances", "b": [0.7421, 0.5206, 0.8189, 0.542]}, {"w": "that", "b": [0.8246, 0.5206, 0.8571, 0.542]}, {"w": "deviate", "b": [0.1428, 0.5397, 0.2019, 0.5611]}, {"w": "strongly", "b": [0.2098, 0.5397, 0.2781, 0.5611]}, {"w": "from", "b": [0.2861, 0.5397, 0.3276, 0.5611]}, {"w": "the", "b": [0.3356, 0.5397, 0.3619, 0.5611]}, {"w": "norm.", "b": [0.3698, 0.5397, 0.4214, 0.5611]}, {"w": "These", "b": [0.4293, 0.5397, 0.4786, 0.5611]}, {"w": "instances", "b": [0.4865, 0.5397, 0.5634, 0.5611]}, {"w": "are", "b": [0.5713, 0.5397, 0.597, 0.5611]}, {"w": "of", "b": [0.6049, 0.5397, 0.6217, 0.5611]}, {"w": "course", "b": [0.6296, 0.5397, 0.6843, 0.5611]}, {"w": "called", "b": [0.6923, 0.5397, 0.7406, 0.5611]}, {"w": "anomalies", "b": [0.7485, 0.5394, 0.8309, 0.5611]}, {"w": "or", "b": [0.8388, 0.5397, 0.8571, 0.5611]}, {"w": "outliers,", "b": [0.1429, 0.5585, 0.2076, 0.5801]}, {"w": "while", "b": [0.2136, 0.5587, 0.2587, 0.5801]}, {"w": "the", "b": [0.2647, 0.5587, 0.291, 0.5801]}, {"w": "normal", "b": [0.297, 0.5587, 0.3582, 0.5801]}, {"w": "instances", "b": [0.3642, 0.5587, 0.441, 0.5801]}, {"w": "are", "b": [0.447, 0.5587, 0.4727, 0.5801]}, {"w": "called", "b": [0.4786, 0.5587, 0.527, 0.5801]}, {"w": "inliers.", "b": [0.533, 0.5585, 0.5874, 0.5801]}, {"w": "Anomaly", "b": [0.5934, 0.5587, 0.6709, 0.5801]}, {"w": "detection", "b": [0.6768, 0.5587, 0.7547, 0.5801]}, {"w": "is", "b": [0.7606, 0.5587, 0.7738, 0.5801]}, {"w": "very", "b": [0.7798, 0.5587, 0.8162, 0.5801]}, {"w": "use‐", "b": [0.8222, 0.5587, 0.8572, 0.5801]}, {"w": "ful", "b": [0.1429, 0.5777, 0.1654, 0.5992]}, {"w": "in", "b": [0.1717, 0.5777, 0.1887, 0.5992]}, {"w": "a", "b": [0.195, 0.5777, 0.2042, 0.5992]}, {"w": "wide", "b": [0.2105, 0.5777, 0.2502, 0.5992]}, {"w": "variety", "b": [0.2566, 0.5777, 0.3134, 0.5992]}, {"w": "of", "b": [0.3198, 0.5777, 0.3366, 0.5992]}, {"w": "applications,", "b": [0.3429, 0.5777, 0.4483, 0.5992]}, {"w": "for", "b": [0.4546, 0.5777, 0.4791, 0.5992]}, {"w": "example", "b": [0.4855, 0.5777, 0.555, 0.5992]}, {"w": "in", "b": [0.5613, 0.5777, 0.5783, 0.5992]}, {"w": "fraud", "b": [0.5847, 0.5777, 0.6294, 0.5992]}, {"w": "detection,", "b": [0.6357, 0.5777, 0.7183, 0.5992]}, {"w": "or", "b": [0.7246, 0.5777, 0.743, 0.5992]}, {"w": "for", "b": [0.7493, 0.5777, 0.7738, 0.5992]}, {"w": "detecting", "b": [0.7802, 0.5777, 0.8571, 0.5992]}, {"w": "defective", "b": [0.1429, 0.5968, 0.217, 0.6182]}, {"w": "products", "b": [0.2258, 0.5968, 0.3, 0.6182]}, {"w": "in", "b": [0.3088, 0.5968, 0.3258, 0.6182]}, {"w": "manufacturing,", "b": [0.3346, 0.5968, 0.4636, 0.6182]}, {"w": "or", "b": [0.4724, 0.5968, 0.4908, 0.6182]}, {"w": "to", "b": [0.4996, 0.5968, 0.5166, 0.6182]}, {"w": "remove", "b": [0.5254, 0.5968, 0.5882, 0.6182]}, {"w": "outliers", "b": [0.597, 0.5968, 0.6602, 0.6182]}, {"w": "from", "b": [0.669, 0.5968, 0.7106, 0.6182]}, {"w": "a", "b": [0.7194, 0.5968, 0.7286, 0.6182]}, {"w": "dataset", "b": [0.7374, 0.5968, 0.7955, 0.6182]}, {"w": "before", "b": [0.8043, 0.5968, 0.8571, 0.6182]}, {"w": "training", "b": [0.1429, 0.6158, 0.2098, 0.6373]}, {"w": "another", "b": [0.2194, 0.6158, 0.2846, 0.6373]}, {"w": "model,", "b": [0.2942, 0.6158, 0.3517, 0.6373]}, {"w": "which", "b": [0.3613, 0.6158, 0.4122, 0.6373]}, {"w": "can", "b": [0.4218, 0.6158, 0.4511, 0.6373]}, {"w": "significantly", "b": [0.4607, 0.6158, 0.5626, 0.6373]}, {"w": "improve", "b": [0.5721, 0.6158, 0.6421, 0.6373]}, {"w": "the", "b": [0.6517, 0.6158, 0.678, 0.6373]}, {"w": "performance", "b": [0.6876, 0.6158, 0.7949, 0.6373]}, {"w": "of", "b": [0.8045, 0.6158, 0.8213, 0.6373]}, {"w": "the", "b": [0.8308, 0.6158, 0.8572, 0.6373]}, {"w": "resulting", "b": [0.1429, 0.6349, 0.2165, 0.6563]}, {"w": "model.", "b": [0.2212, 0.6349, 0.2788, 0.6563]}]}, {"id": "b_5", "type": "paragraph", "text": "Using a Gaussian mixture model for anomaly detection is quite simple: any instance located in a low-density region can be considered an anomaly. You must define what density threshold you want to use. For example, in a manufacturing company that tries to detect defective products, the ratio of defective products is usually well- known. Say it is equal to 4%, then you can set the density threshold to be the value that results in having 4% of the instances located in areas below that threshold den‐ sity. If you notice that you get too many false positives (i.e., perfectly good products that are flagged as defective), you can lower the threshold. Conversely, if you have too many false negatives (i.e., defective products that the system does not flag as defec‐ tive), you can increase the threshold. This is the usual precision/recall tradeoff (see Chapter 3). Here is how you would identify the outliers using the 4th percentile low‐", "words": [{"w": "Using", "b": [0.1429, 0.663, 0.1915, 0.6844]}, {"w": "a", "b": [0.1975, 0.663, 0.2066, 0.6844]}, {"w": "Gaussian", "b": [0.2127, 0.663, 0.2888, 0.6844]}, {"w": "mixture", "b": [0.2948, 0.663, 0.3613, 0.6844]}, {"w": "model", "b": [0.3673, 0.663, 0.4201, 0.6844]}, {"w": "for", "b": [0.4262, 0.663, 0.4507, 0.6844]}, {"w": "anomaly", "b": [0.4567, 0.663, 0.5289, 0.6844]}, {"w": "detection", "b": [0.5349, 0.663, 0.6128, 0.6844]}, {"w": "is", "b": [0.6188, 0.663, 0.632, 0.6844]}, {"w": "quite", "b": [0.6381, 0.663, 0.6806, 0.6844]}, {"w": "simple:", "b": [0.6866, 0.663, 0.7463, 0.6844]}, {"w": "any", "b": [0.7523, 0.663, 0.7819, 0.6844]}, {"w": "instance", "b": [0.788, 0.663, 0.8571, 0.6844]}, {"w": "located", "b": [0.1429, 0.6821, 0.2025, 0.7035]}, {"w": "in", "b": [0.2082, 0.6821, 0.2252, 0.7035]}, {"w": "a", "b": [0.2309, 0.6821, 0.24, 0.7035]}, {"w": "low-density", "b": [0.2457, 0.6821, 0.3437, 0.7035]}, {"w": "region", "b": [0.3494, 0.6821, 0.4033, 0.7035]}, {"w": "can", "b": [0.409, 0.6821, 0.4383, 0.7035]}, {"w": "be", "b": [0.444, 0.6821, 0.4634, 0.7035]}, {"w": "considered", "b": [0.4691, 0.6821, 0.5606, 0.7035]}, {"w": "an", "b": [0.5663, 0.6821, 0.5869, 0.7035]}, {"w": "anomaly.", "b": [0.5925, 0.6821, 0.668, 0.7035]}, {"w": "You", "b": [0.6737, 0.6821, 0.706, 0.7035]}, {"w": "must", "b": [0.7117, 0.6821, 0.7534, 0.7035]}, {"w": "define", "b": [0.7591, 0.6821, 0.811, 0.7035]}, {"w": "what", "b": [0.8166, 0.6821, 0.8571, 0.7035]}, {"w": "density", "b": [0.1429, 0.7011, 0.2032, 0.7225]}, {"w": "threshold", "b": [0.2107, 0.7011, 0.2905, 0.7225]}, {"w": "you", "b": [0.298, 0.7011, 0.3292, 0.7225]}, {"w": "want", "b": [0.3367, 0.7011, 0.3775, 0.7225]}, {"w": "to", "b": [0.385, 0.7011, 0.402, 0.7225]}, {"w": "use.", "b": [0.4095, 0.7011, 0.4418, 0.7225]}, {"w": "For", "b": [0.4493, 0.7011, 0.4782, 0.7225]}, {"w": "example,", "b": [0.4857, 0.7011, 0.56, 0.7225]}, {"w": "in", "b": [0.5675, 0.7011, 0.5845, 0.7225]}, {"w": "a", "b": [0.592, 0.7011, 0.6011, 0.7225]}, {"w": "manufacturing", "b": [0.6086, 0.7011, 0.7329, 0.7225]}, {"w": "company", "b": [0.7404, 0.7011, 0.8171, 0.7225]}, {"w": "that", "b": [0.8246, 0.7011, 0.8571, 0.7225]}, {"w": "tries", "b": [0.1429, 0.7202, 0.179, 0.7416]}, {"w": "to", "b": [0.1885, 0.7202, 0.2055, 0.7416]}, {"w": "detect", "b": [0.215, 0.7202, 0.2653, 0.7416]}, {"w": "defective", "b": [0.2748, 0.7202, 0.3489, 0.7416]}, {"w": "products,", "b": [0.3584, 0.7202, 0.4373, 0.7416]}, {"w": "the", "b": [0.4468, 0.7202, 0.4731, 0.7416]}, {"w": "ratio", "b": [0.4827, 0.7202, 0.5217, 0.7416]}, {"w": "of", "b": [0.5312, 0.7202, 0.548, 0.7416]}, {"w": "defective", "b": [0.5575, 0.7202, 0.6316, 0.7416]}, {"w": "products", "b": [0.6411, 0.7202, 0.7153, 0.7416]}, {"w": "is", "b": [0.7248, 0.7202, 0.738, 0.7416]}, {"w": "usually", "b": [0.7475, 0.7202, 0.8066, 0.7416]}, {"w": "well-", "b": [0.8161, 0.7202, 0.8572, 0.7416]}, {"w": "known.", "b": [0.1429, 0.7392, 0.2056, 0.7606]}, {"w": "Say", "b": [0.2122, 0.7392, 0.2404, 0.7606]}, {"w": "it", "b": [0.2469, 0.7392, 0.2589, 0.7606]}, {"w": "is", "b": [0.2654, 0.7392, 0.2786, 0.7606]}, {"w": "equal", "b": [0.2852, 0.7392, 0.3302, 0.7606]}, {"w": "to", "b": [0.3367, 0.7392, 0.3537, 0.7606]}, {"w": "4%,", "b": [0.3602, 0.7392, 0.3907, 0.7606]}, {"w": "then", "b": [0.3973, 0.7392, 0.435, 0.7606]}, {"w": "you", "b": [0.4416, 0.7392, 0.4728, 0.7606]}, {"w": "can", "b": [0.4794, 0.7392, 0.5087, 0.7606]}, {"w": "set", "b": [0.5153, 0.7392, 0.5381, 0.7606]}, {"w": "the", "b": [0.5447, 0.7392, 0.571, 0.7606]}, {"w": "density", "b": [0.5776, 0.7392, 0.6379, 0.7606]}, {"w": "threshold", "b": [0.6445, 0.7392, 0.7242, 0.7606]}, {"w": "to", "b": [0.7308, 0.7392, 0.7478, 0.7606]}, {"w": "be", "b": [0.7543, 0.7392, 0.7737, 0.7606]}, {"w": "the", "b": [0.7803, 0.7392, 0.8066, 0.7606]}, {"w": "value", "b": [0.8132, 0.7392, 0.8571, 0.7606]}, {"w": "that", "b": [0.1429, 0.7582, 0.1754, 0.7797]}, {"w": "results", "b": [0.1818, 0.7582, 0.2363, 0.7797]}, {"w": "in", "b": [0.2426, 0.7582, 0.2596, 0.7797]}, {"w": "having", "b": [0.2659, 0.7582, 0.3222, 0.7797]}, {"w": "4%", "b": [0.3285, 0.7582, 0.3543, 0.7797]}, {"w": "of", "b": [0.3606, 0.7582, 0.3774, 0.7797]}, {"w": "the", "b": [0.3837, 0.7582, 0.41, 0.7797]}, {"w": "instances", "b": [0.4163, 0.7582, 0.4932, 0.7797]}, {"w": "located", "b": [0.4995, 0.7582, 0.5592, 0.7797]}, {"w": "in", "b": [0.5655, 0.7582, 0.5825, 0.7797]}, {"w": "areas", "b": [0.5888, 0.7582, 0.6313, 0.7797]}, {"w": "below", "b": [0.6376, 0.7582, 0.6872, 0.7797]}, {"w": "that", "b": [0.6935, 0.7582, 0.7261, 0.7797]}, {"w": "threshold", "b": [0.7324, 0.7582, 0.8122, 0.7797]}, {"w": "den‐", "b": [0.8185, 0.7582, 0.8571, 0.7797]}, {"w": "sity.", "b": [0.1429, 0.7773, 0.1752, 0.7987]}, {"w": "If", "b": [0.1815, 0.7773, 0.1948, 0.7987]}, {"w": "you", "b": [0.2011, 0.7773, 0.2324, 0.7987]}, {"w": "notice", "b": [0.2387, 0.7773, 0.2903, 0.7987]}, {"w": "that", "b": [0.2966, 0.7773, 0.3292, 0.7987]}, {"w": "you", "b": [0.3355, 0.7773, 0.3667, 0.7987]}, {"w": "get", "b": [0.373, 0.7773, 0.398, 0.7987]}, {"w": "too", "b": [0.4043, 0.7773, 0.4319, 0.7987]}, {"w": "many", "b": [0.4382, 0.7773, 0.4849, 0.7987]}, {"w": "false", "b": [0.4912, 0.7773, 0.5282, 0.7987]}, {"w": "positives", "b": [0.5345, 0.7773, 0.6074, 0.7987]}, {"w": "(i.e.,", "b": [0.6137, 0.7773, 0.6496, 0.7987]}, {"w": "perfectly", "b": [0.6559, 0.7773, 0.7284, 0.7987]}, {"w": "good", "b": [0.7347, 0.7773, 0.7767, 0.7987]}, {"w": "products", "b": [0.783, 0.7773, 0.8572, 0.7987]}, {"w": "that", "b": [0.1429, 0.7963, 0.1754, 0.8178]}, {"w": "are", "b": [0.1804, 0.7963, 0.2062, 0.8178]}, {"w": "flagged", "b": [0.2111, 0.7963, 0.2711, 0.8178]}, {"w": "as", "b": [0.2761, 0.7963, 0.2929, 0.8178]}, {"w": "defective),", "b": [0.2978, 0.7963, 0.3839, 0.8178]}, {"w": "you", "b": [0.3889, 0.7963, 0.4202, 0.8178]}, {"w": "can", "b": [0.4252, 0.7963, 0.4545, 0.8178]}, {"w": "lower", "b": [0.4595, 0.7963, 0.5062, 0.8178]}, {"w": "the", "b": [0.5112, 0.7963, 0.5376, 0.8178]}, {"w": "threshold.", "b": [0.5426, 0.7963, 0.627, 0.8178]}, {"w": "Conversely,", "b": [0.632, 0.7963, 0.7282, 0.8178]}, {"w": "if", "b": [0.7332, 0.7963, 0.7449, 0.8178]}, {"w": "you", "b": [0.7499, 0.7963, 0.7812, 0.8178]}, {"w": "have", "b": [0.7862, 0.7963, 0.8246, 0.8178]}, {"w": "too", "b": [0.8295, 0.7963, 0.8571, 0.8178]}, {"w": "many", "b": [0.1429, 0.8154, 0.1895, 0.8368]}, {"w": "false", "b": [0.1964, 0.8154, 0.2335, 0.8368]}, {"w": "negatives", "b": [0.2403, 0.8154, 0.3171, 0.8368]}, {"w": "(i.e.,", "b": [0.3239, 0.8154, 0.3598, 0.8368]}, {"w": "defective", "b": [0.3667, 0.8154, 0.4408, 0.8368]}, {"w": "products", "b": [0.4476, 0.8154, 0.5218, 0.8368]}, {"w": "that", "b": [0.5286, 0.8154, 0.5612, 0.8368]}, {"w": "the", "b": [0.568, 0.8154, 0.5943, 0.8368]}, {"w": "system", "b": [0.6012, 0.8154, 0.6583, 0.8368]}, {"w": "does", "b": [0.6651, 0.8154, 0.7032, 0.8368]}, {"w": "not", "b": [0.7101, 0.8154, 0.7384, 0.8368]}, {"w": "flag", "b": [0.7453, 0.8154, 0.7756, 0.8368]}, {"w": "as", "b": [0.7824, 0.8154, 0.7992, 0.8368]}, {"w": "defec‐", "b": [0.806, 0.8154, 0.8571, 0.8368]}, {"w": "tive),", "b": [0.1429, 0.8344, 0.1852, 0.8558]}, {"w": "you", "b": [0.1922, 0.8344, 0.2235, 0.8558]}, {"w": "can", "b": [0.2305, 0.8344, 0.2598, 0.8558]}, {"w": "increase", "b": [0.2668, 0.8344, 0.3348, 0.8558]}, {"w": "the", "b": [0.3418, 0.8344, 0.3681, 0.8558]}, {"w": "threshold.", "b": [0.3751, 0.8344, 0.4596, 0.8558]}, {"w": "This", "b": [0.4666, 0.8344, 0.5038, 0.8558]}, {"w": "is", "b": [0.5108, 0.8344, 0.524, 0.8558]}, {"w": "the", "b": [0.531, 0.8344, 0.5573, 0.8558]}, {"w": "usual", "b": [0.5643, 0.8344, 0.6085, 0.8558]}, {"w": "precision/recall", "b": [0.6154, 0.8344, 0.7446, 0.8558]}, {"w": "tradeoff", "b": [0.7516, 0.8344, 0.8176, 0.8558]}, {"w": "(see", "b": [0.8246, 0.8344, 0.8571, 0.8558]}, {"w": "Chapter", "b": [0.1429, 0.8535, 0.2104, 0.8749]}, {"w": "3).", "b": [0.216, 0.8535, 0.238, 0.8749]}, {"w": "Here", "b": [0.2436, 0.8535, 0.2844, 0.8749]}, {"w": "is", "b": [0.29, 0.8535, 0.3033, 0.8749]}, {"w": "how", "b": [0.3088, 0.8535, 0.3449, 0.8749]}, {"w": "you", "b": [0.3504, 0.8535, 0.3817, 0.8749]}, {"w": "would", "b": [0.3873, 0.8535, 0.4395, 0.8749]}, {"w": "identify", "b": [0.4451, 0.8535, 0.5096, 0.8749]}, {"w": "the", "b": [0.5151, 0.8535, 0.5415, 0.8749]}, {"w": "outliers", "b": [0.547, 0.8535, 0.6102, 0.8749]}, {"w": "using", "b": [0.6158, 0.8535, 0.6612, 0.8749]}, {"w": "the", "b": [0.6668, 0.8535, 0.6931, 0.8749]}, {"w": "4th", "b": [0.6987, 0.8535, 0.7262, 0.8749]}, {"w": "percentile", "b": [0.7318, 0.8535, 0.814, 0.8749]}, {"w": "low‐", "b": [0.8196, 0.8535, 0.8572, 0.8749]}]}, {"id": "b_6", "type": "paragraph", "text": "266 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "266", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 293, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "est density as the threshold (i.e., approximately 4% of the instances will be flagged as anomalies):", "words": [{"w": "est", "b": [0.1429, 0.0791, 0.1657, 0.1005]}, {"w": "density", "b": [0.1714, 0.0791, 0.2318, 0.1005]}, {"w": "as", "b": [0.2375, 0.0791, 0.2543, 0.1005]}, {"w": "the", "b": [0.26, 0.0791, 0.2863, 0.1005]}, {"w": "threshold", "b": [0.292, 0.0791, 0.3718, 0.1005]}, {"w": "(i.e.,", "b": [0.3775, 0.0791, 0.4134, 0.1005]}, {"w": "approximately", "b": [0.4191, 0.0791, 0.5393, 0.1005]}, {"w": "4%", "b": [0.545, 0.0791, 0.5707, 0.1005]}, {"w": "of", "b": [0.5764, 0.0791, 0.5932, 0.1005]}, {"w": "the", "b": [0.5989, 0.0791, 0.6252, 0.1005]}, {"w": "instances", "b": [0.6309, 0.0791, 0.7078, 0.1005]}, {"w": "will", "b": [0.7135, 0.0791, 0.7439, 0.1005]}, {"w": "be", "b": [0.7496, 0.0791, 0.769, 0.1005]}, {"w": "flagged", "b": [0.7747, 0.0791, 0.8347, 0.1005]}, {"w": "as", "b": [0.8404, 0.0791, 0.8571, 0.1005]}, {"w": "anomalies):", "b": [0.1429, 0.0981, 0.2395, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "densities = gm.score_samples(X) density_threshold = np.percentile(densities, 4) anomalies = X[densities < density_threshold]", "words": [{"w": "densities", "b": [0.1766, 0.1301, 0.2525, 0.1429]}, {"w": "=", "b": [0.2609, 0.1301, 0.2693, 0.1429]}, {"w": "gm.score_samples(X)", "b": [0.2778, 0.1301, 0.438, 0.1429]}, {"w": "density_threshold", "b": [0.1766, 0.1455, 0.3199, 0.1584]}, {"w": "=", "b": [0.3284, 0.1455, 0.3368, 0.1584]}, {"w": "np.percentile(densities,", "b": [0.3452, 0.1455, 0.5476, 0.1584]}, {"w": "4)", "b": [0.556, 0.1455, 0.5729, 0.1584]}, {"w": "anomalies", "b": [0.1766, 0.1609, 0.2525, 0.1738]}, {"w": "=", "b": [0.2609, 0.1609, 0.2693, 0.1738]}, {"w": "X[densities", "b": [0.2778, 0.1609, 0.3705, 0.1738]}, {"w": "<", "b": [0.379, 0.1609, 0.3874, 0.1738]}, {"w": "density_threshold]", "b": [0.3958, 0.1609, 0.5476, 0.1738]}]}, {"id": "b_2", "type": "equation", "text": "These anomalies are represented as stars on Figure 9-19:", "words": [{"w": "These", "b": [0.1429, 0.1816, 0.1922, 0.203]}, {"w": "anomalies", "b": [0.1969, 0.1816, 0.2817, 0.203]}, {"w": "are", "b": [0.2864, 0.1816, 0.3121, 0.203]}, {"w": "represented", "b": [0.3168, 0.1816, 0.4146, 0.203]}, {"w": "as", "b": [0.4194, 0.1816, 0.4362, 0.203]}, {"w": "stars", "b": [0.4409, 0.1816, 0.4794, 0.203]}, {"w": "on", "b": [0.4841, 0.1816, 0.5062, 0.203]}, {"w": "Figure", "b": [0.5109, 0.1816, 0.5649, 0.203]}, {"w": "9-19:", "b": [0.5696, 0.1816, 0.6118, 0.203]}]}, {"id": "b_3", "type": "equation", "text": "Figure 9-19. Anomaly detection using a Gaussian mixture model", "words": [{"w": "Figure", "b": [0.1429, 0.4123, 0.1943, 0.4339]}, {"w": "9-19.", "b": [0.1991, 0.4123, 0.2407, 0.4339]}, {"w": "Anomaly", "b": [0.2455, 0.4123, 0.3202, 0.4339]}, {"w": "detection", "b": [0.3249, 0.4123, 0.3986, 0.4339]}, {"w": "using", "b": [0.4033, 0.4123, 0.4463, 0.4339]}, {"w": "a", "b": [0.4511, 0.4123, 0.4613, 0.4339]}, {"w": "Gaussian", "b": [0.4661, 0.4123, 0.5416, 0.4339]}, {"w": "mixture", "b": [0.5463, 0.4123, 0.6105, 0.4339]}, {"w": "model", "b": [0.6153, 0.4123, 0.6649, 0.4339]}]}, {"id": "b_4", "type": "paragraph", "text": "A closely related task is novelty detection: it differs from anomaly detection in that the algorithm is assumed to be trained on a “clean” dataset, uncontaminated by outliers, whereas anomaly detection does not make this assumption. Indeed, outlier detection is often precisely used to clean up a dataset.", "words": [{"w": "A", "b": [0.1429, 0.4497, 0.1573, 0.4711]}, {"w": "closely", "b": [0.1623, 0.4497, 0.2184, 0.4711]}, {"w": "related", "b": [0.2235, 0.4497, 0.2803, 0.4711]}, {"w": "task", "b": [0.2854, 0.4497, 0.3188, 0.4711]}, {"w": "is", "b": [0.3239, 0.4497, 0.3371, 0.4711]}, {"w": "novelty", "b": [0.3422, 0.4495, 0.4004, 0.4711]}, {"w": "detection:", "b": [0.4052, 0.4495, 0.4839, 0.4711]}, {"w": "it", "b": [0.489, 0.4497, 0.5009, 0.4711]}, {"w": "differs", "b": [0.506, 0.4497, 0.5591, 0.4711]}, {"w": "from", "b": [0.5642, 0.4497, 0.6058, 0.4711]}, {"w": "anomaly", "b": [0.6109, 0.4497, 0.6831, 0.4711]}, {"w": "detection", "b": [0.6882, 0.4497, 0.766, 0.4711]}, {"w": "in", "b": [0.7711, 0.4497, 0.7881, 0.4711]}, {"w": "that", "b": [0.7932, 0.4497, 0.8257, 0.4711]}, {"w": "the", "b": [0.8308, 0.4497, 0.8572, 0.4711]}, {"w": "algorithm", "b": [0.1429, 0.4688, 0.2255, 0.4902]}, {"w": "is", "b": [0.2316, 0.4688, 0.2449, 0.4902]}, {"w": "assumed", "b": [0.251, 0.4688, 0.3234, 0.4902]}, {"w": "to", "b": [0.3295, 0.4688, 0.3465, 0.4902]}, {"w": "be", "b": [0.3526, 0.4688, 0.372, 0.4902]}, {"w": "trained", "b": [0.3781, 0.4688, 0.4382, 0.4902]}, {"w": "on", "b": [0.4443, 0.4688, 0.4663, 0.4902]}, {"w": "a", "b": [0.4725, 0.4688, 0.4816, 0.4902]}, {"w": "“clean”", "b": [0.4877, 0.4688, 0.5444, 0.4902]}, {"w": "dataset,", "b": [0.5505, 0.4688, 0.6134, 0.4902]}, {"w": "uncontaminated", "b": [0.6195, 0.4688, 0.7569, 0.4902]}, {"w": "by", "b": [0.763, 0.4688, 0.7832, 0.4902]}, {"w": "outliers,", "b": [0.7893, 0.4688, 0.8571, 0.4902]}, {"w": "whereas", "b": [0.1429, 0.4878, 0.2105, 0.5092]}, {"w": "anomaly", "b": [0.2161, 0.4878, 0.2883, 0.5092]}, {"w": "detection", "b": [0.2939, 0.4878, 0.3717, 0.5092]}, {"w": "does", "b": [0.3773, 0.4878, 0.4154, 0.5092]}, {"w": "not", "b": [0.421, 0.4878, 0.4494, 0.5092]}, {"w": "make", "b": [0.455, 0.4878, 0.5004, 0.5092]}, {"w": "this", "b": [0.506, 0.4878, 0.5367, 0.5092]}, {"w": "assumption.", "b": [0.5423, 0.4878, 0.6441, 0.5092]}, {"w": "Indeed,", "b": [0.6497, 0.4878, 0.7126, 0.5092]}, {"w": "outlier", "b": [0.7182, 0.4878, 0.7737, 0.5092]}, {"w": "detection", "b": [0.7793, 0.4878, 0.8571, 0.5092]}, {"w": "is", "b": [0.1428, 0.5069, 0.1561, 0.5283]}, {"w": "often", "b": [0.1608, 0.5069, 0.2042, 0.5283]}, {"w": "precisely", "b": [0.2089, 0.5069, 0.2822, 0.5283]}, {"w": "used", "b": [0.2869, 0.5069, 0.3255, 0.5283]}, {"w": "to", "b": [0.3302, 0.5069, 0.3472, 0.5283]}, {"w": "clean", "b": [0.3519, 0.5069, 0.3954, 0.5283]}, {"w": "up", "b": [0.4001, 0.5069, 0.4221, 0.5283]}, {"w": "a", "b": [0.4268, 0.5069, 0.436, 0.5283]}, {"w": "dataset.", "b": [0.4407, 0.5069, 0.5035, 0.5283]}]}, {"id": "b_5", "type": "paragraph", "text": "Gaussian mixture models try to fit all the data, including the outli‐ ers, so if you have too many of them, this will bias the model’s view of “normality”: some outliers may wrongly be considered as nor‐ mal. If this happens, you can try to fit the model once, use it to detect and remove the most extreme outliers, then fit the model again on the cleaned up dataset. Another approach is to use robust covariance estimation methods (see the EllipticEnvelope class).", "words": [{"w": "Gaussian", "b": [0.2714, 0.5488, 0.341, 0.5684]}, {"w": "mixture", "b": [0.3461, 0.5488, 0.4069, 0.5684]}, {"w": "models", "b": [0.412, 0.5488, 0.4673, 0.5684]}, {"w": "try", "b": [0.4724, 0.5488, 0.4946, 0.5684]}, {"w": "to", "b": [0.4997, 0.5488, 0.5152, 0.5684]}, {"w": "fit", "b": [0.5204, 0.5488, 0.5369, 0.5684]}, {"w": "all", "b": [0.542, 0.5488, 0.56, 0.5684]}, {"w": "the", "b": [0.5651, 0.5488, 0.5892, 0.5684]}, {"w": "data,", "b": [0.5943, 0.5488, 0.6309, 0.5684]}, {"w": "including", "b": [0.636, 0.5488, 0.709, 0.5684]}, {"w": "the", "b": [0.7142, 0.5488, 0.7382, 0.5684]}, {"w": "outli‐", "b": [0.7434, 0.5488, 0.7857, 0.5684]}, {"w": "ers,", "b": [0.2714, 0.5662, 0.2979, 0.5858]}, {"w": "so", "b": [0.3027, 0.5662, 0.3194, 0.5858]}, {"w": "if", "b": [0.3242, 0.5662, 0.3349, 0.5858]}, {"w": "you", "b": [0.3397, 0.5662, 0.3683, 0.5858]}, {"w": "have", "b": [0.3731, 0.5662, 0.4082, 0.5858]}, {"w": "too", "b": [0.413, 0.5662, 0.4382, 0.5858]}, {"w": "many", "b": [0.443, 0.5662, 0.4857, 0.5858]}, {"w": "of", "b": [0.4905, 0.5662, 0.5058, 0.5858]}, {"w": "them,", "b": [0.5106, 0.5662, 0.5546, 0.5858]}, {"w": "this", "b": [0.5594, 0.5662, 0.5875, 0.5858]}, {"w": "will", "b": [0.5923, 0.5662, 0.6201, 0.5858]}, {"w": "bias", "b": [0.6248, 0.5662, 0.655, 0.5858]}, {"w": "the", "b": [0.6598, 0.5662, 0.6838, 0.5858]}, {"w": "model’s", "b": [0.6886, 0.5662, 0.7459, 0.5858]}, {"w": "view", "b": [0.7506, 0.5662, 0.7857, 0.5858]}, {"w": "of", "b": [0.2714, 0.5836, 0.2868, 0.6032]}, {"w": "“normality”:", "b": [0.2935, 0.5836, 0.3881, 0.6032]}, {"w": "some", "b": [0.3948, 0.5836, 0.4352, 0.6032]}, {"w": "outliers", "b": [0.4419, 0.5836, 0.4996, 0.6032]}, {"w": "may", "b": [0.5063, 0.5836, 0.5387, 0.6032]}, {"w": "wrongly", "b": [0.5454, 0.5836, 0.6081, 0.6032]}, {"w": "be", "b": [0.6148, 0.5836, 0.6326, 0.6032]}, {"w": "considered", "b": [0.6393, 0.5836, 0.723, 0.6032]}, {"w": "as", "b": [0.7297, 0.5836, 0.745, 0.6032]}, {"w": "nor‐", "b": [0.7517, 0.5836, 0.7857, 0.6032]}, {"w": "mal.", "b": [0.2714, 0.601, 0.3045, 0.6206]}, {"w": "If", "b": [0.3116, 0.601, 0.3237, 0.6206]}, {"w": "this", "b": [0.3308, 0.601, 0.3588, 0.6206]}, {"w": "happens,", "b": [0.3659, 0.601, 0.4339, 0.6206]}, {"w": "you", "b": [0.4409, 0.601, 0.4695, 0.6206]}, {"w": "can", "b": [0.4765, 0.601, 0.5034, 0.6206]}, {"w": "try", "b": [0.5104, 0.601, 0.5326, 0.6206]}, {"w": "to", "b": [0.5397, 0.601, 0.5552, 0.6206]}, {"w": "fit", "b": [0.5622, 0.601, 0.5788, 0.6206]}, {"w": "the", "b": [0.5858, 0.601, 0.6099, 0.6206]}, {"w": "model", "b": [0.617, 0.601, 0.6652, 0.6206]}, {"w": "once,", "b": [0.6723, 0.601, 0.7129, 0.6206]}, {"w": "use", "b": [0.72, 0.601, 0.7452, 0.6206]}, {"w": "it", "b": [0.7522, 0.601, 0.7631, 0.6206]}, {"w": "to", "b": [0.7702, 0.601, 0.7857, 0.6206]}, {"w": "detect", "b": [0.2714, 0.6185, 0.3173, 0.638]}, {"w": "and", "b": [0.3246, 0.6185, 0.3534, 0.638]}, {"w": "remove", "b": [0.3607, 0.6185, 0.4181, 0.638]}, {"w": "the", "b": [0.4254, 0.6185, 0.4495, 0.638]}, {"w": "most", "b": [0.4567, 0.6185, 0.4948, 0.638]}, {"w": "extreme", "b": [0.5021, 0.6185, 0.5639, 0.638]}, {"w": "outliers,", "b": [0.5711, 0.6185, 0.6332, 0.638]}, {"w": "then", "b": [0.6405, 0.6185, 0.675, 0.638]}, {"w": "fit", "b": [0.6822, 0.6185, 0.6988, 0.638]}, {"w": "the", "b": [0.7061, 0.6185, 0.7301, 0.638]}, {"w": "model", "b": [0.7374, 0.6185, 0.7857, 0.638]}, {"w": "again", "b": [0.2714, 0.6359, 0.3126, 0.6555]}, {"w": "on", "b": [0.3176, 0.6359, 0.3377, 0.6555]}, {"w": "the", "b": [0.3428, 0.6359, 0.3669, 0.6555]}, {"w": "cleaned", "b": [0.3719, 0.6359, 0.4298, 0.6555]}, {"w": "up", "b": [0.4349, 0.6359, 0.455, 0.6555]}, {"w": "dataset.", "b": [0.46, 0.6359, 0.5175, 0.6555]}, {"w": "Another", "b": [0.5225, 0.6359, 0.587, 0.6555]}, {"w": "approach", "b": [0.592, 0.6359, 0.6633, 0.6555]}, {"w": "is", "b": [0.6684, 0.6359, 0.6805, 0.6555]}, {"w": "to", "b": [0.6855, 0.6359, 0.701, 0.6555]}, {"w": "use", "b": [0.7061, 0.6359, 0.7313, 0.6555]}, {"w": "robust", "b": [0.7363, 0.6359, 0.7857, 0.6555]}, {"w": "covariance", "b": [0.2714, 0.6541, 0.3535, 0.6737]}, {"w": "estimation", "b": [0.3578, 0.6541, 0.4384, 0.6737]}, {"w": "methods", "b": [0.4428, 0.6541, 0.5092, 0.6737]}, {"w": "(see", "b": [0.5135, 0.6541, 0.5433, 0.6737]}, {"w": "the", "b": [0.5476, 0.6541, 0.5717, 0.6737]}, {"w": "EllipticEnvelope", "b": [0.576, 0.657, 0.7208, 0.6708]}, {"w": "class).", "b": [0.7251, 0.6541, 0.7713, 0.6737]}]}, {"id": "b_6", "type": "paragraph", "text": "Just like K-Means, the GaussianMixture algorithm requires you to specify the num‐ ber of clusters. So how can you find it?", "words": [{"w": "Just", "b": [0.1429, 0.6949, 0.1741, 0.7163]}, {"w": "like", "b": [0.1802, 0.6949, 0.2103, 0.7163]}, {"w": "K-Means,", "b": [0.2164, 0.6949, 0.2976, 0.7163]}, {"w": "the", "b": [0.3037, 0.6949, 0.3301, 0.7163]}, {"w": "GaussianMixture", "b": [0.3362, 0.6981, 0.4846, 0.7131]}, {"w": "algorithm", "b": [0.4907, 0.6949, 0.5734, 0.7163]}, {"w": "requires", "b": [0.5795, 0.6949, 0.6476, 0.7163]}, {"w": "you", "b": [0.6537, 0.6949, 0.6849, 0.7163]}, {"w": "to", "b": [0.6911, 0.6949, 0.708, 0.7163]}, {"w": "specify", "b": [0.7142, 0.6949, 0.772, 0.7163]}, {"w": "the", "b": [0.7782, 0.6949, 0.8045, 0.7163]}, {"w": "num‐", "b": [0.8106, 0.6949, 0.8571, 0.7163]}, {"w": "ber", "b": [0.1429, 0.7139, 0.17, 0.7353]}, {"w": "of", "b": [0.1747, 0.7139, 0.1915, 0.7353]}, {"w": "clusters.", "b": [0.1963, 0.7139, 0.2644, 0.7353]}, {"w": "So", "b": [0.2691, 0.7139, 0.2896, 0.7353]}, {"w": "how", "b": [0.2944, 0.7139, 0.3304, 0.7353]}, {"w": "can", "b": [0.3351, 0.7139, 0.3645, 0.7353]}, {"w": "you", "b": [0.3692, 0.7139, 0.4004, 0.7353]}, {"w": "find", "b": [0.4052, 0.7139, 0.4393, 0.7353]}, {"w": "it?", "b": [0.444, 0.7139, 0.4639, 0.7353]}]}, {"id": "b_7", "type": "paragraph", "text": "Selecting the Number of Clusters", "words": [{"w": "Selecting", "b": [0.1429, 0.7481, 0.238, 0.7767]}, {"w": "the", "b": [0.2429, 0.7481, 0.2778, 0.7767]}, {"w": "Number", "b": [0.2827, 0.7481, 0.3662, 0.7767]}, {"w": "of", "b": [0.3711, 0.7481, 0.3921, 0.7767]}, {"w": "Clusters", "b": [0.397, 0.7481, 0.4781, 0.7767]}]}, {"id": "b_8", "type": "paragraph", "text": "With K-Means, you could use the inertia or the silhouette score to select the appro‐ priate number of clusters, but with Gaussian mixtures, it is not possible to use these metrics because they are not reliable when the clusters are not spherical or have dif‐ ferent sizes. Instead, you can try to find the model that minimizes a theoretical infor‐", "words": [{"w": "With", "b": [0.1429, 0.7826, 0.1853, 0.804]}, {"w": "K-Means,", "b": [0.1916, 0.7826, 0.2729, 0.804]}, {"w": "you", "b": [0.2792, 0.7826, 0.3104, 0.804]}, {"w": "could", "b": [0.3168, 0.7826, 0.3635, 0.804]}, {"w": "use", "b": [0.3699, 0.7826, 0.3974, 0.804]}, {"w": "the", "b": [0.4037, 0.7826, 0.4301, 0.804]}, {"w": "inertia", "b": [0.4364, 0.7826, 0.491, 0.804]}, {"w": "or", "b": [0.4974, 0.7826, 0.5157, 0.804]}, {"w": "the", "b": [0.522, 0.7826, 0.5484, 0.804]}, {"w": "silhouette", "b": [0.5547, 0.7826, 0.6364, 0.804]}, {"w": "score", "b": [0.6427, 0.7826, 0.6864, 0.804]}, {"w": "to", "b": [0.6927, 0.7826, 0.7097, 0.804]}, {"w": "select", "b": [0.716, 0.7826, 0.7618, 0.804]}, {"w": "the", "b": [0.7681, 0.7826, 0.7945, 0.804]}, {"w": "appro‐", "b": [0.8008, 0.7826, 0.8571, 0.804]}, {"w": "priate", "b": [0.1429, 0.8016, 0.191, 0.823]}, {"w": "number", "b": [0.1972, 0.8016, 0.2635, 0.823]}, {"w": "of", "b": [0.2697, 0.8016, 0.2865, 0.823]}, {"w": "clusters,", "b": [0.2927, 0.8016, 0.3608, 0.823]}, {"w": "but", "b": [0.367, 0.8016, 0.395, 0.823]}, {"w": "with", "b": [0.4011, 0.8016, 0.4385, 0.823]}, {"w": "Gaussian", "b": [0.4447, 0.8016, 0.5208, 0.823]}, {"w": "mixtures,", "b": [0.527, 0.8016, 0.6058, 0.823]}, {"w": "it", "b": [0.612, 0.8016, 0.624, 0.823]}, {"w": "is", "b": [0.6301, 0.8016, 0.6434, 0.823]}, {"w": "not", "b": [0.6495, 0.8016, 0.6779, 0.823]}, {"w": "possible", "b": [0.6841, 0.8016, 0.7512, 0.823]}, {"w": "to", "b": [0.7574, 0.8016, 0.7744, 0.823]}, {"w": "use", "b": [0.7806, 0.8016, 0.8081, 0.823]}, {"w": "these", "b": [0.8143, 0.8016, 0.8571, 0.823]}, {"w": "metrics", "b": [0.1428, 0.8207, 0.2049, 0.8421]}, {"w": "because", "b": [0.211, 0.8207, 0.2755, 0.8421]}, {"w": "they", "b": [0.2816, 0.8207, 0.3175, 0.8421]}, {"w": "are", "b": [0.3235, 0.8207, 0.3493, 0.8421]}, {"w": "not", "b": [0.3553, 0.8207, 0.3837, 0.8421]}, {"w": "reliable", "b": [0.3898, 0.8207, 0.4511, 0.8421]}, {"w": "when", "b": [0.4571, 0.8207, 0.5028, 0.8421]}, {"w": "the", "b": [0.5089, 0.8207, 0.5352, 0.8421]}, {"w": "clusters", "b": [0.5413, 0.8207, 0.6046, 0.8421]}, {"w": "are", "b": [0.6107, 0.8207, 0.6364, 0.8421]}, {"w": "not", "b": [0.6425, 0.8207, 0.6709, 0.8421]}, {"w": "spherical", "b": [0.6769, 0.8207, 0.752, 0.8421]}, {"w": "or", "b": [0.7581, 0.8207, 0.7764, 0.8421]}, {"w": "have", "b": [0.7825, 0.8207, 0.8209, 0.8421]}, {"w": "dif‐", "b": [0.827, 0.8207, 0.8571, 0.8421]}, {"w": "ferent", "b": [0.1429, 0.8397, 0.1918, 0.8611]}, {"w": "sizes.", "b": [0.1976, 0.8397, 0.2408, 0.8611]}, {"w": "Instead,", "b": [0.2466, 0.8397, 0.3128, 0.8611]}, {"w": "you", "b": [0.3186, 0.8397, 0.3499, 0.8611]}, {"w": "can", "b": [0.3556, 0.8397, 0.385, 0.8611]}, {"w": "try", "b": [0.3908, 0.8397, 0.415, 0.8611]}, {"w": "to", "b": [0.4208, 0.8397, 0.4378, 0.8611]}, {"w": "find", "b": [0.4435, 0.8397, 0.4777, 0.8611]}, {"w": "the", "b": [0.4835, 0.8397, 0.5098, 0.8611]}, {"w": "model", "b": [0.5156, 0.8397, 0.5684, 0.8611]}, {"w": "that", "b": [0.5742, 0.8397, 0.6067, 0.8611]}, {"w": "minimizes", "b": [0.6125, 0.8397, 0.7, 0.8611]}, {"w": "a", "b": [0.7058, 0.8397, 0.715, 0.8611]}, {"w": "theoretical", "b": [0.7207, 0.8395, 0.8054, 0.8611]}, {"w": "infor‐", "b": [0.8113, 0.8395, 0.8571, 0.8611]}]}, {"id": "b_9", "type": "paragraph", "text": "Gaussian Mixtures | 267", "words": [{"w": "Gaussian", "b": [0.6892, 0.9225, 0.7415, 0.9388]}, {"w": "Mixtures", "b": [0.7443, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "267", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 294, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "mation criterion such as the Bayesian information criterion (BIC) or the Akaike information criterion (AIC), defined in Equation 9-1.", "words": [{"w": "mation", "b": [0.1429, 0.0789, 0.2013, 0.1005]}, {"w": "criterion", "b": [0.2118, 0.0789, 0.2816, 0.1005]}, {"w": "such", "b": [0.2921, 0.0791, 0.3307, 0.1005]}, {"w": "as", "b": [0.3412, 0.0791, 0.358, 0.1005]}, {"w": "the", "b": [0.3684, 0.0791, 0.3947, 0.1005]}, {"w": "Bayesian", "b": [0.4052, 0.0789, 0.4777, 0.1005]}, {"w": "information", "b": [0.4882, 0.0789, 0.5858, 0.1005]}, {"w": "criterion", "b": [0.5963, 0.0789, 0.6661, 0.1005]}, {"w": "(BIC)", "b": [0.6765, 0.0791, 0.7242, 0.1005]}, {"w": "or", "b": [0.7346, 0.0791, 0.753, 0.1005]}, {"w": "the", "b": [0.7634, 0.0791, 0.7898, 0.1005]}, {"w": "Akaike", "b": [0.8002, 0.0789, 0.8571, 0.1005]}, {"w": "information", "b": [0.1429, 0.0979, 0.2405, 0.1195]}, {"w": "criterion", "b": [0.2452, 0.0979, 0.315, 0.1195]}, {"w": "(AIC),", "b": [0.3197, 0.0981, 0.3742, 0.1195]}, {"w": "defined", "b": [0.379, 0.0981, 0.4418, 0.1195]}, {"w": "in", "b": [0.4466, 0.0981, 0.4635, 0.1195]}, {"w": "Equation", "b": [0.4683, 0.0981, 0.5445, 0.1195]}, {"w": "9-1.", "b": [0.5492, 0.0981, 0.5814, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "Equation 9-1. Bayesian information criterion (BIC) and Akaike information criterion (AIC)", "words": [{"w": "Equation", "b": [0.1726, 0.1376, 0.2473, 0.1593]}, {"w": "9-1.", "b": [0.2521, 0.1376, 0.2838, 0.1593]}, {"w": "Bayesian", "b": [0.2886, 0.1376, 0.3611, 0.1593]}, {"w": "information", "b": [0.3659, 0.1376, 0.4635, 0.1593]}, {"w": "criterion", "b": [0.4682, 0.1376, 0.538, 0.1593]}, {"w": "(BIC)", "b": [0.5428, 0.1376, 0.5889, 0.1593]}, {"w": "and", "b": [0.5937, 0.1376, 0.6251, 0.1593]}, {"w": "Akaike", "b": [0.6299, 0.1376, 0.6868, 0.1593]}, {"w": "information", "b": [0.6915, 0.1376, 0.7891, 0.1593]}, {"w": "criterion", "b": [0.1726, 0.1527, 0.2424, 0.1743]}, {"w": "(AIC)", "b": [0.2472, 0.1527, 0.2951, 0.1743]}]}, {"id": "b_2", "type": "equation", "text": "BIC = log m p −2 log L", "words": [{"w": "BIC", "b": [0.1747, 0.1842, 0.2062, 0.2048]}, {"w": "=", "b": [0.2118, 0.1844, 0.2233, 0.2048]}, {"w": "log", "b": [0.2497, 0.1844, 0.2741, 0.2048]}, {"w": "m", "b": [0.2864, 0.1842, 0.3021, 0.2048]}, {"w": "p", "b": [0.3103, 0.1842, 0.32, 0.2048]}, {"w": "−2", "b": [0.3244, 0.1844, 0.3498, 0.2048]}, {"w": "log", "b": [0.3553, 0.1844, 0.3798, 0.2048]}, {"w": "L", "b": [0.3921, 0.1842, 0.4027, 0.2048]}]}, {"id": "b_3", "type": "equation", "text": "AIC = 2p −2 log L", "words": [{"w": "AIC", "b": [0.173, 0.2133, 0.2062, 0.2339]}, {"w": "=", "b": [0.2118, 0.2135, 0.2233, 0.2339]}, {"w": "2p", "b": [0.2441, 0.2133, 0.2647, 0.2339]}, {"w": "−2", "b": [0.2691, 0.2135, 0.2945, 0.2339]}, {"w": "log", "b": [0.3001, 0.2135, 0.3245, 0.2339]}, {"w": "L", "b": [0.3369, 0.2133, 0.3474, 0.2339]}]}, {"id": "b_4", "type": "paragraph", "text": "• m is the number of instances, as always.", "words": [{"w": "•", "b": [0.16, 0.2625, 0.1681, 0.2839]}, {"w": "m", "b": [0.1786, 0.2623, 0.195, 0.2839]}, {"w": "is", "b": [0.1997, 0.2625, 0.2129, 0.2839]}, {"w": "the", "b": [0.2176, 0.2625, 0.244, 0.2839]}, {"w": "number", "b": [0.2487, 0.2625, 0.315, 0.2839]}, {"w": "of", "b": [0.3197, 0.2625, 0.3365, 0.2839]}, {"w": "instances,", "b": [0.3413, 0.2625, 0.4228, 0.2839]}, {"w": "as", "b": [0.4276, 0.2625, 0.4444, 0.2839]}, {"w": "always.", "b": [0.4491, 0.2625, 0.5085, 0.2839]}]}, {"id": "b_5", "type": "paragraph", "text": "• p is the number of parameters learned by the model.", "words": [{"w": "•", "b": [0.16, 0.2876, 0.1682, 0.309]}, {"w": "p", "b": [0.1786, 0.2874, 0.1887, 0.309]}, {"w": "is", "b": [0.1934, 0.2876, 0.2066, 0.309]}, {"w": "the", "b": [0.2114, 0.2876, 0.2377, 0.309]}, {"w": "number", "b": [0.2424, 0.2876, 0.3087, 0.309]}, {"w": "of", "b": [0.3135, 0.2876, 0.3303, 0.309]}, {"w": "parameters", "b": [0.335, 0.2876, 0.4284, 0.309]}, {"w": "learned", "b": [0.4331, 0.2876, 0.4954, 0.309]}, {"w": "by", "b": [0.5001, 0.2876, 0.5203, 0.309]}, {"w": "the", "b": [0.525, 0.2876, 0.5513, 0.309]}, {"w": "model.", "b": [0.5561, 0.2876, 0.6136, 0.309]}]}, {"id": "b_6", "type": "paragraph", "text": "• L is the maximized value of the likelihood function of the model.", "words": [{"w": "•", "b": [0.16, 0.315, 0.1682, 0.3364]}, {"w": "L", "b": [0.1786, 0.3148, 0.1897, 0.3364]}, {"w": "is", "b": [0.1951, 0.315, 0.2083, 0.3364]}, {"w": "the", "b": [0.213, 0.315, 0.2394, 0.3364]}, {"w": "maximized", "b": [0.2441, 0.315, 0.337, 0.3364]}, {"w": "value", "b": [0.3417, 0.315, 0.3857, 0.3364]}, {"w": "of", "b": [0.3904, 0.315, 0.4072, 0.3364]}, {"w": "the", "b": [0.4119, 0.315, 0.4383, 0.3364]}, {"w": "likelihood", "b": [0.443, 0.3148, 0.5221, 0.3364]}, {"w": "function", "b": [0.5269, 0.3148, 0.595, 0.3364]}, {"w": "of", "b": [0.5998, 0.315, 0.6165, 0.3364]}, {"w": "the", "b": [0.6213, 0.315, 0.6476, 0.3364]}, {"w": "model.", "b": [0.6523, 0.315, 0.7099, 0.3364]}]}, {"id": "b_7", "type": "paragraph", "text": "Both the BIC and the AIC penalize models that have more parameters to learn (e.g., more clusters), and reward models that fit the data well. They often end up selecting the same model, but when they differ, the model selected by the BIC tends to be sim‐ pler (fewer parameters) than the one selected by the AIC, but it does not fit the data quite as well (this is especially true for larger datasets).", "words": [{"w": "Both", "b": [0.1429, 0.3491, 0.1836, 0.3705]}, {"w": "the", "b": [0.1896, 0.3491, 0.2159, 0.3705]}, {"w": "BIC", "b": [0.2219, 0.3491, 0.2551, 0.3705]}, {"w": "and", "b": [0.261, 0.3491, 0.2926, 0.3705]}, {"w": "the", "b": [0.2985, 0.3491, 0.3249, 0.3705]}, {"w": "AIC", "b": [0.3308, 0.3491, 0.3662, 0.3705]}, {"w": "penalize", "b": [0.3721, 0.3491, 0.4409, 0.3705]}, {"w": "models", "b": [0.4469, 0.3491, 0.5073, 0.3705]}, {"w": "that", "b": [0.5133, 0.3491, 0.5459, 0.3705]}, {"w": "have", "b": [0.5518, 0.3491, 0.5902, 0.3705]}, {"w": "more", "b": [0.5962, 0.3491, 0.6404, 0.3705]}, {"w": "parameters", "b": [0.6464, 0.3491, 0.7398, 0.3705]}, {"w": "to", "b": [0.7458, 0.3491, 0.7628, 0.3705]}, {"w": "learn", "b": [0.7687, 0.3491, 0.8111, 0.3705]}, {"w": "(e.g.,", "b": [0.8171, 0.3491, 0.8571, 0.3705]}, {"w": "more", "b": [0.1429, 0.3682, 0.1871, 0.3896]}, {"w": "clusters),", "b": [0.193, 0.3682, 0.2683, 0.3896]}, {"w": "and", "b": [0.2741, 0.3682, 0.3057, 0.3896]}, {"w": "reward", "b": [0.3115, 0.3682, 0.3702, 0.3896]}, {"w": "models", "b": [0.3761, 0.3682, 0.4365, 0.3896]}, {"w": "that", "b": [0.4424, 0.3682, 0.475, 0.3896]}, {"w": "fit", "b": [0.4808, 0.3682, 0.4989, 0.3896]}, {"w": "the", "b": [0.5047, 0.3682, 0.5311, 0.3896]}, {"w": "data", "b": [0.5369, 0.3682, 0.5722, 0.3896]}, {"w": "well.", "b": [0.578, 0.3682, 0.6164, 0.3896]}, {"w": "They", "b": [0.6222, 0.3682, 0.6646, 0.3896]}, {"w": "often", "b": [0.6705, 0.3682, 0.7139, 0.3896]}, {"w": "end", "b": [0.7197, 0.3682, 0.751, 0.3896]}, {"w": "up", "b": [0.7568, 0.3682, 0.7788, 0.3896]}, {"w": "selecting", "b": [0.7846, 0.3682, 0.8571, 0.3896]}, {"w": "the", "b": [0.1429, 0.3872, 0.1692, 0.4086]}, {"w": "same", "b": [0.1745, 0.3872, 0.2172, 0.4086]}, {"w": "model,", "b": [0.2226, 0.3872, 0.2801, 0.4086]}, {"w": "but", "b": [0.2855, 0.3872, 0.3135, 0.4086]}, {"w": "when", "b": [0.3188, 0.3872, 0.3645, 0.4086]}, {"w": "they", "b": [0.3698, 0.3872, 0.4057, 0.4086]}, {"w": "differ,", "b": [0.411, 0.3872, 0.46, 0.4086]}, {"w": "the", "b": [0.4653, 0.3872, 0.4916, 0.4086]}, {"w": "model", "b": [0.497, 0.3872, 0.5498, 0.4086]}, {"w": "selected", "b": [0.5551, 0.3872, 0.6208, 0.4086]}, {"w": "by", "b": [0.6261, 0.3872, 0.6462, 0.4086]}, {"w": "the", "b": [0.6516, 0.3872, 0.6779, 0.4086]}, {"w": "BIC", "b": [0.6832, 0.3872, 0.7164, 0.4086]}, {"w": "tends", "b": [0.7218, 0.3872, 0.767, 0.4086]}, {"w": "to", "b": [0.7724, 0.3872, 0.7893, 0.4086]}, {"w": "be", "b": [0.7947, 0.3872, 0.8141, 0.4086]}, {"w": "sim‐", "b": [0.8194, 0.3872, 0.8572, 0.4086]}, {"w": "pler", "b": [0.1429, 0.4063, 0.1756, 0.4277]}, {"w": "(fewer", "b": [0.1815, 0.4063, 0.2346, 0.4277]}, {"w": "parameters)", "b": [0.2405, 0.4063, 0.3411, 0.4277]}, {"w": "than", "b": [0.347, 0.4063, 0.385, 0.4277]}, {"w": "the", "b": [0.3909, 0.4063, 0.4173, 0.4277]}, {"w": "one", "b": [0.4232, 0.4063, 0.454, 0.4277]}, {"w": "selected", "b": [0.4599, 0.4063, 0.5256, 0.4277]}, {"w": "by", "b": [0.5314, 0.4063, 0.5516, 0.4277]}, {"w": "the", "b": [0.5575, 0.4063, 0.5838, 0.4277]}, {"w": "AIC,", "b": [0.5897, 0.4063, 0.6298, 0.4277]}, {"w": "but", "b": [0.6357, 0.4063, 0.6637, 0.4277]}, {"w": "it", "b": [0.6696, 0.4063, 0.6815, 0.4277]}, {"w": "does", "b": [0.6874, 0.4063, 0.7255, 0.4277]}, {"w": "not", "b": [0.7314, 0.4063, 0.7598, 0.4277]}, {"w": "fit", "b": [0.7657, 0.4063, 0.7838, 0.4277]}, {"w": "the", "b": [0.7897, 0.4063, 0.816, 0.4277]}, {"w": "data", "b": [0.8219, 0.4063, 0.8571, 0.4277]}, {"w": "quite", "b": [0.1429, 0.4253, 0.1854, 0.4467]}, {"w": "as", "b": [0.1901, 0.4253, 0.2069, 0.4467]}, {"w": "well", "b": [0.2116, 0.4253, 0.2453, 0.4467]}, {"w": "(this", "b": [0.25, 0.4253, 0.2879, 0.4467]}, {"w": "is", "b": [0.2926, 0.4253, 0.3059, 0.4467]}, {"w": "especially", "b": [0.3106, 0.4253, 0.3905, 0.4467]}, {"w": "true", "b": [0.3953, 0.4253, 0.4293, 0.4467]}, {"w": "for", "b": [0.434, 0.4253, 0.4585, 0.4467]}, {"w": "larger", "b": [0.4632, 0.4253, 0.5117, 0.4467]}, {"w": "datasets).", "b": [0.5164, 0.4253, 0.5941, 0.4467]}]}, {"id": "b_8", "type": "paragraph", "text": "Likelihood function", "words": [{"w": "Likelihood", "b": [0.4052, 0.4725, 0.5077, 0.4997]}, {"w": "function", "b": [0.5124, 0.4725, 0.5948, 0.4997]}]}, {"id": "b_9", "type": "paragraph", "text": "The terms “probability” and “likelihood” are often used interchangeably in the English language, but they have very different meanings in statistics: given a statistical model with some parameters θ, the word “probability” is used to describe how plausi‐ ble a future outcome x is (knowing the parameter values θ), while the word “likeli‐ hood” is used to describe how plausible a particular set of parameter values θ are, after the outcome x is known.", "words": [{"w": "The", "b": [0.1592, 0.5042, 0.1905, 0.5246]}, {"w": "terms", "b": [0.2011, 0.5042, 0.2465, 0.5246]}, {"w": "“probability”", "b": [0.2571, 0.5042, 0.3598, 0.5246]}, {"w": "and", "b": [0.3704, 0.5042, 0.4004, 0.5246]}, {"w": "“likelihood”", "b": [0.411, 0.5042, 0.5066, 0.5246]}, {"w": "are", "b": [0.5172, 0.5042, 0.5417, 0.5246]}, {"w": "often", "b": [0.5523, 0.5042, 0.5936, 0.5246]}, {"w": "used", "b": [0.6042, 0.5042, 0.6409, 0.5246]}, {"w": "interchangeably", "b": [0.6515, 0.5042, 0.7783, 0.5246]}, {"w": "in", "b": [0.7889, 0.5042, 0.8051, 0.5246]}, {"w": "the", "b": [0.8157, 0.5042, 0.8408, 0.5246]}, {"w": "English", "b": [0.1592, 0.5223, 0.2188, 0.5427]}, {"w": "language,", "b": [0.2235, 0.5223, 0.2988, 0.5427]}, {"w": "but", "b": [0.3035, 0.5223, 0.3301, 0.5427]}, {"w": "they", "b": [0.3348, 0.5223, 0.3689, 0.5427]}, {"w": "have", "b": [0.3736, 0.5223, 0.4101, 0.5427]}, {"w": "very", "b": [0.4148, 0.5223, 0.4494, 0.5427]}, {"w": "different", "b": [0.4541, 0.5223, 0.5224, 0.5427]}, {"w": "meanings", "b": [0.527, 0.5223, 0.604, 0.5427]}, {"w": "in", "b": [0.6086, 0.5223, 0.6248, 0.5427]}, {"w": "statistics:", "b": [0.6294, 0.5223, 0.7013, 0.5427]}, {"w": "given", "b": [0.7059, 0.5223, 0.749, 0.5427]}, {"w": "a", "b": [0.7536, 0.5223, 0.7623, 0.5427]}, {"w": "statistical", "b": [0.767, 0.5223, 0.8408, 0.5427]}, {"w": "model", "b": [0.1592, 0.5405, 0.2095, 0.5609]}, {"w": "with", "b": [0.2142, 0.5405, 0.2498, 0.5609]}, {"w": "some", "b": [0.2545, 0.5405, 0.2966, 0.5609]}, {"w": "parameters", "b": [0.3013, 0.5405, 0.3903, 0.5609]}, {"w": "θ,", "b": [0.395, 0.54, 0.4096, 0.5609]}, {"w": "the", "b": [0.4143, 0.5405, 0.4394, 0.5609]}, {"w": "word", "b": [0.4441, 0.5405, 0.4856, 0.5609]}, {"w": "“probability”", "b": [0.4903, 0.5405, 0.593, 0.5609]}, {"w": "is", "b": [0.5977, 0.5405, 0.6103, 0.5609]}, {"w": "used", "b": [0.615, 0.5405, 0.6518, 0.5609]}, {"w": "to", "b": [0.6565, 0.5405, 0.6726, 0.5609]}, {"w": "describe", "b": [0.6773, 0.5405, 0.7431, 0.5609]}, {"w": "how", "b": [0.7478, 0.5405, 0.7821, 0.5609]}, {"w": "plausi‐", "b": [0.7868, 0.5405, 0.8408, 0.5609]}, {"w": "ble", "b": [0.1592, 0.5586, 0.1828, 0.579]}, {"w": "a", "b": [0.1892, 0.5586, 0.198, 0.579]}, {"w": "future", "b": [0.2044, 0.5586, 0.2532, 0.579]}, {"w": "outcome", "b": [0.2597, 0.5586, 0.3296, 0.579]}, {"w": "x", "b": [0.3361, 0.5581, 0.3457, 0.579]}, {"w": "is", "b": [0.3521, 0.5586, 0.3647, 0.579]}, {"w": "(knowing", "b": [0.3712, 0.5586, 0.448, 0.579]}, {"w": "the", "b": [0.4544, 0.5586, 0.4795, 0.579]}, {"w": "parameter", "b": [0.486, 0.5586, 0.5677, 0.579]}, {"w": "values", "b": [0.5742, 0.5586, 0.6234, 0.579]}, {"w": "θ),", "b": [0.6299, 0.5581, 0.6513, 0.579]}, {"w": "while", "b": [0.6578, 0.5586, 0.7008, 0.579]}, {"w": "the", "b": [0.7073, 0.5586, 0.7323, 0.579]}, {"w": "word", "b": [0.7388, 0.5586, 0.7804, 0.579]}, {"w": "“likeli‐", "b": [0.7869, 0.5586, 0.8408, 0.579]}, {"w": "hood”", "b": [0.1592, 0.5768, 0.208, 0.5972]}, {"w": "is", "b": [0.2153, 0.5768, 0.2279, 0.5972]}, {"w": "used", "b": [0.2352, 0.5768, 0.2719, 0.5972]}, {"w": "to", "b": [0.2793, 0.5768, 0.2954, 0.5972]}, {"w": "describe", "b": [0.3028, 0.5768, 0.3685, 0.5972]}, {"w": "how", "b": [0.3758, 0.5768, 0.4102, 0.5972]}, {"w": "plausible", "b": [0.4175, 0.5768, 0.4879, 0.5972]}, {"w": "a", "b": [0.4952, 0.5768, 0.5039, 0.5972]}, {"w": "particular", "b": [0.5112, 0.5768, 0.5891, 0.5972]}, {"w": "set", "b": [0.5964, 0.5768, 0.6182, 0.5972]}, {"w": "of", "b": [0.6255, 0.5768, 0.6415, 0.5972]}, {"w": "parameter", "b": [0.6488, 0.5768, 0.7305, 0.5972]}, {"w": "values", "b": [0.7378, 0.5768, 0.787, 0.5972]}, {"w": "θ", "b": [0.7943, 0.5762, 0.8044, 0.5972]}, {"w": "are,", "b": [0.8117, 0.5768, 0.8408, 0.5972]}, {"w": "after", "b": [0.1592, 0.5949, 0.1957, 0.6153]}, {"w": "the", "b": [0.2002, 0.5949, 0.2252, 0.6153]}, {"w": "outcome", "b": [0.2297, 0.5949, 0.2996, 0.6153]}, {"w": "x", "b": [0.3041, 0.5944, 0.3137, 0.6153]}, {"w": "is", "b": [0.3182, 0.5949, 0.3308, 0.6153]}, {"w": "known.", "b": [0.3353, 0.5949, 0.3951, 0.6153]}]}, {"id": "b_10", "type": "paragraph", "text": "Consider a one-dimensional mixture model of two Gaussian distributions centered at -4 and +1. For simplicity, this toy model has a single parameter θ that controls the standard deviations of both distributions. The top left contour plot in Figure 9-20 shows the entire model f(x; θ) as a function of both x and θ. To estimate the probabil‐ ity distribution of a future outcome x, you need to set the model parameter θ. For example, if you set it to θ=1.3 (the horizontal line), you get the probability density function f(x; θ=1.3) shown in the lower left plot. Say you want to estimate the proba‐ bility that x will fall between -2 and +2, you must calculate the integral of the PDF on this range (i.e., the surface of the shaded region). On the other hand, if you have observed a single instance x=2.5 (the vertical line in the upper left plot), you get the likelihood function noted ℒ(θ|x=2.5)=f(x=2.5; θ) represented in the upper right plot.", "words": [{"w": "Consider", "b": [0.1592, 0.6221, 0.2323, 0.6425]}, {"w": "a", "b": [0.2371, 0.6221, 0.2458, 0.6425]}, {"w": "one-dimensional", "b": [0.2506, 0.6221, 0.3857, 0.6425]}, {"w": "mixture", "b": [0.3906, 0.6221, 0.4539, 0.6425]}, {"w": "model", "b": [0.4587, 0.6221, 0.509, 0.6425]}, {"w": "of", "b": [0.5139, 0.6221, 0.5299, 0.6425]}, {"w": "two", "b": [0.5347, 0.6221, 0.5644, 0.6425]}, {"w": "Gaussian", "b": [0.5693, 0.6221, 0.6418, 0.6425]}, {"w": "distributions", "b": [0.6466, 0.6221, 0.7487, 0.6425]}, {"w": "centered", "b": [0.7535, 0.6221, 0.8216, 0.6425]}, {"w": "at", "b": [0.8264, 0.6221, 0.8408, 0.6425]}, {"w": "-4", "b": [0.1592, 0.6403, 0.1758, 0.6607]}, {"w": "and", "b": [0.1826, 0.6403, 0.2127, 0.6607]}, {"w": "+1.", "b": [0.2195, 0.6403, 0.245, 0.6607]}, {"w": "For", "b": [0.2518, 0.6403, 0.2794, 0.6607]}, {"w": "simplicity,", "b": [0.2863, 0.6403, 0.3674, 0.6607]}, {"w": "this", "b": [0.3742, 0.6403, 0.4035, 0.6607]}, {"w": "toy", "b": [0.4103, 0.6403, 0.4356, 0.6607]}, {"w": "model", "b": [0.4424, 0.6403, 0.4927, 0.6607]}, {"w": "has", "b": [0.4995, 0.6403, 0.5261, 0.6607]}, {"w": "a", "b": [0.5329, 0.6403, 0.5416, 0.6607]}, {"w": "single", "b": [0.5484, 0.6403, 0.5946, 0.6607]}, {"w": "parameter", "b": [0.6014, 0.6403, 0.6831, 0.6607]}, {"w": "θ", "b": [0.6899, 0.6401, 0.6994, 0.6607]}, {"w": "that", "b": [0.7062, 0.6403, 0.7372, 0.6607]}, {"w": "controls", "b": [0.7441, 0.6403, 0.8089, 0.6607]}, {"w": "the", "b": [0.8157, 0.6403, 0.8408, 0.6607]}, {"w": "standard", "b": [0.1592, 0.6584, 0.2291, 0.6788]}, {"w": "deviations", "b": [0.2366, 0.6584, 0.318, 0.6788]}, {"w": "of", "b": [0.3255, 0.6584, 0.3415, 0.6788]}, {"w": "both", "b": [0.3489, 0.6584, 0.3858, 0.6788]}, {"w": "distributions.", "b": [0.3933, 0.6584, 0.4998, 0.6788]}, {"w": "The", "b": [0.5073, 0.6584, 0.5386, 0.6788]}, {"w": "top", "b": [0.5461, 0.6584, 0.5726, 0.6788]}, {"w": "left", "b": [0.5801, 0.6584, 0.6055, 0.6788]}, {"w": "contour", "b": [0.613, 0.6584, 0.676, 0.6788]}, {"w": "plot", "b": [0.6835, 0.6584, 0.7151, 0.6788]}, {"w": "in", "b": [0.7226, 0.6584, 0.7387, 0.6788]}, {"w": "Figure", "b": [0.7462, 0.6584, 0.7977, 0.6788]}, {"w": "9-20", "b": [0.8051, 0.6584, 0.8408, 0.6788]}, {"w": "shows", "b": [0.1592, 0.6765, 0.2081, 0.6969]}, {"w": "the", "b": [0.213, 0.6765, 0.2381, 0.6969]}, {"w": "entire", "b": [0.2431, 0.6765, 0.2891, 0.6969]}, {"w": "model", "b": [0.2941, 0.6765, 0.3444, 0.6969]}, {"w": "f(x;", "b": [0.3493, 0.6763, 0.3755, 0.6969]}, {"w": "θ)", "b": [0.3804, 0.6763, 0.3967, 0.6969]}, {"w": "as", "b": [0.4017, 0.6765, 0.4177, 0.6969]}, {"w": "a", "b": [0.4226, 0.6765, 0.4313, 0.6969]}, {"w": "function", "b": [0.4363, 0.6765, 0.5043, 0.6969]}, {"w": "of", "b": [0.5092, 0.6765, 0.5252, 0.6969]}, {"w": "both", "b": [0.5301, 0.6765, 0.567, 0.6969]}, {"w": "x", "b": [0.5719, 0.6763, 0.5813, 0.6969]}, {"w": "and", "b": [0.5862, 0.6765, 0.6163, 0.6969]}, {"w": "θ.", "b": [0.6212, 0.6763, 0.6352, 0.6969]}, {"w": "To", "b": [0.6402, 0.6765, 0.6606, 0.6969]}, {"w": "estimate", "b": [0.6655, 0.6765, 0.7317, 0.6969]}, {"w": "the", "b": [0.7366, 0.6765, 0.7617, 0.6969]}, {"w": "probabil‐", "b": [0.7666, 0.6765, 0.8408, 0.6969]}, {"w": "ity", "b": [0.1592, 0.6947, 0.1797, 0.7151]}, {"w": "distribution", "b": [0.1867, 0.6947, 0.2814, 0.7151]}, {"w": "of", "b": [0.2884, 0.6947, 0.3044, 0.7151]}, {"w": "a", "b": [0.3113, 0.6947, 0.3201, 0.7151]}, {"w": "future", "b": [0.327, 0.6947, 0.3758, 0.7151]}, {"w": "outcome", "b": [0.3828, 0.6947, 0.4527, 0.7151]}, {"w": "x,", "b": [0.4596, 0.6945, 0.4735, 0.7151]}, {"w": "you", "b": [0.4805, 0.6947, 0.5103, 0.7151]}, {"w": "need", "b": [0.5172, 0.6947, 0.5554, 0.7151]}, {"w": "to", "b": [0.5624, 0.6947, 0.5786, 0.7151]}, {"w": "set", "b": [0.5855, 0.6947, 0.6073, 0.7151]}, {"w": "the", "b": [0.6142, 0.6947, 0.6393, 0.7151]}, {"w": "model", "b": [0.6463, 0.6947, 0.6966, 0.7151]}, {"w": "parameter", "b": [0.7035, 0.6947, 0.7853, 0.7151]}, {"w": "θ.", "b": [0.7922, 0.6945, 0.8062, 0.7151]}, {"w": "For", "b": [0.8132, 0.6947, 0.8408, 0.7151]}, {"w": "example,", "b": [0.1592, 0.7128, 0.23, 0.7332]}, {"w": "if", "b": [0.2369, 0.7128, 0.2481, 0.7332]}, {"w": "you", "b": [0.2551, 0.7128, 0.2848, 0.7332]}, {"w": "set", "b": [0.2918, 0.7128, 0.3135, 0.7332]}, {"w": "it", "b": [0.3205, 0.7128, 0.3318, 0.7332]}, {"w": "to", "b": [0.3388, 0.7128, 0.355, 0.7332]}, {"w": "θ=1.3", "b": [0.3619, 0.7126, 0.4065, 0.7332]}, {"w": "(the", "b": [0.4134, 0.7128, 0.4453, 0.7332]}, {"w": "horizontal", "b": [0.4523, 0.7128, 0.5344, 0.7332]}, {"w": "line),", "b": [0.5413, 0.7128, 0.5823, 0.7332]}, {"w": "you", "b": [0.5893, 0.7128, 0.6191, 0.7332]}, {"w": "get", "b": [0.626, 0.7128, 0.6498, 0.7332]}, {"w": "the", "b": [0.6567, 0.7128, 0.6818, 0.7332]}, {"w": "probability", "b": [0.6887, 0.7128, 0.7763, 0.7332]}, {"w": "density", "b": [0.7832, 0.7128, 0.8408, 0.7332]}, {"w": "function", "b": [0.1592, 0.731, 0.2272, 0.7514]}, {"w": "f(x;", "b": [0.2325, 0.7308, 0.2587, 0.7514]}, {"w": "θ=1.3)", "b": [0.264, 0.7308, 0.3154, 0.7514]}, {"w": "shown", "b": [0.3207, 0.731, 0.3732, 0.7514]}, {"w": "in", "b": [0.3785, 0.731, 0.3946, 0.7514]}, {"w": "the", "b": [0.4, 0.731, 0.425, 0.7514]}, {"w": "lower", "b": [0.4303, 0.731, 0.4749, 0.7514]}, {"w": "left", "b": [0.4802, 0.731, 0.5056, 0.7514]}, {"w": "plot.", "b": [0.5109, 0.731, 0.547, 0.7514]}, {"w": "Say", "b": [0.5523, 0.731, 0.5792, 0.7514]}, {"w": "you", "b": [0.5845, 0.731, 0.6142, 0.7514]}, {"w": "want", "b": [0.6196, 0.731, 0.6584, 0.7514]}, {"w": "to", "b": [0.6637, 0.731, 0.6799, 0.7514]}, {"w": "estimate", "b": [0.6852, 0.731, 0.7513, 0.7514]}, {"w": "the", "b": [0.7566, 0.731, 0.7817, 0.7514]}, {"w": "proba‐", "b": [0.787, 0.731, 0.8408, 0.7514]}, {"w": "bility", "b": [0.1592, 0.7491, 0.2001, 0.7695]}, {"w": "that", "b": [0.2052, 0.7491, 0.2362, 0.7695]}, {"w": "x", "b": [0.2413, 0.7489, 0.2507, 0.7695]}, {"w": "will", "b": [0.2558, 0.7491, 0.2847, 0.7695]}, {"w": "fall", "b": [0.2898, 0.7491, 0.3144, 0.7695]}, {"w": "between", "b": [0.3195, 0.7491, 0.3853, 0.7695]}, {"w": "-2", "b": [0.3904, 0.7491, 0.407, 0.7695]}, {"w": "and", "b": [0.4121, 0.7491, 0.4421, 0.7695]}, {"w": "+2,", "b": [0.4472, 0.7491, 0.4727, 0.7695]}, {"w": "you", "b": [0.4778, 0.7491, 0.5076, 0.7695]}, {"w": "must", "b": [0.5126, 0.7491, 0.5524, 0.7695]}, {"w": "calculate", "b": [0.5574, 0.7491, 0.6263, 0.7695]}, {"w": "the", "b": [0.6314, 0.7491, 0.6565, 0.7695]}, {"w": "integral", "b": [0.6615, 0.7491, 0.7222, 0.7695]}, {"w": "of", "b": [0.7273, 0.7491, 0.7433, 0.7695]}, {"w": "the", "b": [0.7483, 0.7491, 0.7734, 0.7695]}, {"w": "PDF", "b": [0.7785, 0.7491, 0.8147, 0.7695]}, {"w": "on", "b": [0.8198, 0.7491, 0.8408, 0.7695]}, {"w": "this", "b": [0.1592, 0.7672, 0.1885, 0.7876]}, {"w": "range", "b": [0.1962, 0.7672, 0.2409, 0.7876]}, {"w": "(i.e.,", "b": [0.2486, 0.7672, 0.2828, 0.7876]}, {"w": "the", "b": [0.2905, 0.7672, 0.3156, 0.7876]}, {"w": "surface", "b": [0.3233, 0.7672, 0.3799, 0.7876]}, {"w": "of", "b": [0.3876, 0.7672, 0.4036, 0.7876]}, {"w": "the", "b": [0.4114, 0.7672, 0.4364, 0.7876]}, {"w": "shaded", "b": [0.4442, 0.7672, 0.5002, 0.7876]}, {"w": "region).", "b": [0.5079, 0.7672, 0.5706, 0.7876]}, {"w": "On", "b": [0.5784, 0.7672, 0.6041, 0.7876]}, {"w": "the", "b": [0.6118, 0.7672, 0.6369, 0.7876]}, {"w": "other", "b": [0.6446, 0.7672, 0.6872, 0.7876]}, {"w": "hand,", "b": [0.6949, 0.7672, 0.7401, 0.7876]}, {"w": "if", "b": [0.7478, 0.7672, 0.759, 0.7876]}, {"w": "you", "b": [0.7667, 0.7672, 0.7965, 0.7876]}, {"w": "have", "b": [0.8042, 0.7672, 0.8408, 0.7876]}, {"w": "observed", "b": [0.1592, 0.7854, 0.2312, 0.8058]}, {"w": "a", "b": [0.2371, 0.7854, 0.2458, 0.8058]}, {"w": "single", "b": [0.2517, 0.7854, 0.2979, 0.8058]}, {"w": "instance", "b": [0.3039, 0.7854, 0.3698, 0.8058]}, {"w": "x=2.5", "b": [0.3757, 0.7852, 0.4202, 0.8058]}, {"w": "(the", "b": [0.4261, 0.7854, 0.458, 0.8058]}, {"w": "vertical", "b": [0.464, 0.7854, 0.5224, 0.8058]}, {"w": "line", "b": [0.5284, 0.7854, 0.558, 0.8058]}, {"w": "in", "b": [0.5639, 0.7854, 0.5801, 0.8058]}, {"w": "the", "b": [0.586, 0.7854, 0.6111, 0.8058]}, {"w": "upper", "b": [0.617, 0.7854, 0.6642, 0.8058]}, {"w": "left", "b": [0.6701, 0.7854, 0.6955, 0.8058]}, {"w": "plot),", "b": [0.7014, 0.7854, 0.7444, 0.8058]}, {"w": "you", "b": [0.7503, 0.7854, 0.7801, 0.8058]}, {"w": "get", "b": [0.786, 0.7854, 0.8098, 0.8058]}, {"w": "the", "b": [0.8157, 0.7854, 0.8408, 0.8058]}, {"w": "likelihood", "b": [0.1592, 0.8035, 0.2395, 0.8239]}, {"w": "function", "b": [0.244, 0.8035, 0.312, 0.8239]}, {"w": "noted", "b": [0.3165, 0.8035, 0.3624, 0.8239]}, {"w": "ℒ(θ|x=2.5)=f(x=2.5;", "b": [0.3669, 0.8033, 0.53, 0.8239]}, {"w": "θ)", "b": [0.5345, 0.8033, 0.5508, 0.8239]}, {"w": "represented", "b": [0.5553, 0.8035, 0.6484, 0.8239]}, {"w": "in", "b": [0.6529, 0.8035, 0.6691, 0.8239]}, {"w": "the", "b": [0.6736, 0.8035, 0.6987, 0.8239]}, {"w": "upper", "b": [0.7032, 0.8035, 0.7503, 0.8239]}, {"w": "right", "b": [0.7548, 0.8035, 0.7931, 0.8239]}, {"w": "plot.", "b": [0.7976, 0.8035, 0.8337, 0.8239]}]}, {"id": "b_11", "type": "paragraph", "text": "In short, the PDF is a function of x (with θ fixed) while the likelihood function is a function of θ (with x fixed). It is important to understand that the likelihood function is not a probability distribution: if you integrate a probability distribution over all", "words": [{"w": "In", "b": [0.1592, 0.8307, 0.1768, 0.8511]}, {"w": "short,", "b": [0.1831, 0.8307, 0.229, 0.8511]}, {"w": "the", "b": [0.2353, 0.8307, 0.2603, 0.8511]}, {"w": "PDF", "b": [0.2666, 0.8307, 0.3028, 0.8511]}, {"w": "is", "b": [0.3091, 0.8307, 0.3217, 0.8511]}, {"w": "a", "b": [0.3279, 0.8307, 0.3366, 0.8511]}, {"w": "function", "b": [0.3429, 0.8307, 0.4109, 0.8511]}, {"w": "of", "b": [0.4171, 0.8307, 0.4331, 0.8511]}, {"w": "x", "b": [0.4394, 0.8305, 0.4488, 0.8511]}, {"w": "(with", "b": [0.455, 0.8307, 0.4974, 0.8511]}, {"w": "θ", "b": [0.5037, 0.8305, 0.5131, 0.8511]}, {"w": "fixed)", "b": [0.5194, 0.8307, 0.5657, 0.8511]}, {"w": "while", "b": [0.5719, 0.8307, 0.6149, 0.8511]}, {"w": "the", "b": [0.6211, 0.8307, 0.6462, 0.8511]}, {"w": "likelihood", "b": [0.6525, 0.8307, 0.7327, 0.8511]}, {"w": "function", "b": [0.739, 0.8307, 0.807, 0.8511]}, {"w": "is", "b": [0.8132, 0.8307, 0.8258, 0.8511]}, {"w": "a", "b": [0.8321, 0.8307, 0.8408, 0.8511]}, {"w": "function", "b": [0.1592, 0.8489, 0.2272, 0.8693]}, {"w": "of", "b": [0.2321, 0.8489, 0.2481, 0.8693]}, {"w": "θ", "b": [0.2531, 0.8487, 0.2625, 0.8693]}, {"w": "(with", "b": [0.2674, 0.8489, 0.3099, 0.8693]}, {"w": "x", "b": [0.3148, 0.8487, 0.3242, 0.8693]}, {"w": "fixed).", "b": [0.3291, 0.8489, 0.3799, 0.8693]}, {"w": "It", "b": [0.3849, 0.8489, 0.3969, 0.8693]}, {"w": "is", "b": [0.4018, 0.8489, 0.4144, 0.8693]}, {"w": "important", "b": [0.4193, 0.8489, 0.4997, 0.8693]}, {"w": "to", "b": [0.5046, 0.8489, 0.5208, 0.8693]}, {"w": "understand", "b": [0.5257, 0.8489, 0.6167, 0.8693]}, {"w": "that", "b": [0.6217, 0.8489, 0.6527, 0.8693]}, {"w": "the", "b": [0.6576, 0.8489, 0.6827, 0.8693]}, {"w": "likelihood", "b": [0.6876, 0.8489, 0.7679, 0.8693]}, {"w": "function", "b": [0.7728, 0.8489, 0.8408, 0.8693]}, {"w": "is", "b": [0.1592, 0.867, 0.1718, 0.8874]}, {"w": "not", "b": [0.1795, 0.8668, 0.2051, 0.8874]}, {"w": "a", "b": [0.2128, 0.867, 0.2215, 0.8874]}, {"w": "probability", "b": [0.2292, 0.867, 0.3167, 0.8874]}, {"w": "distribution:", "b": [0.3244, 0.867, 0.4237, 0.8874]}, {"w": "if", "b": [0.4314, 0.867, 0.4426, 0.8874]}, {"w": "you", "b": [0.4503, 0.867, 0.48, 0.8874]}, {"w": "integrate", "b": [0.4877, 0.867, 0.5575, 0.8874]}, {"w": "a", "b": [0.5652, 0.867, 0.5739, 0.8874]}, {"w": "probability", "b": [0.5816, 0.867, 0.6691, 0.8874]}, {"w": "distribution", "b": [0.6768, 0.867, 0.7716, 0.8874]}, {"w": "over", "b": [0.7792, 0.867, 0.8143, 0.8874]}, {"w": "all", "b": [0.822, 0.867, 0.8408, 0.8874]}]}, {"id": "b_12", "type": "paragraph", "text": "268 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "268", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4708, 0.9388]}]}]}, {"page": 295, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "possible values of x, you always get 1, but if you integrate the likelihood function over all possible values of θ, the result can be any positive value.", "words": [{"w": "possible", "b": [0.1592, 0.0792, 0.2232, 0.0996]}, {"w": "values", "b": [0.228, 0.0792, 0.2772, 0.0996]}, {"w": "of", "b": [0.2821, 0.0792, 0.2981, 0.0996]}, {"w": "x,", "b": [0.3029, 0.079, 0.3168, 0.0996]}, {"w": "you", "b": [0.3217, 0.0792, 0.3515, 0.0996]}, {"w": "always", "b": [0.3564, 0.0792, 0.4084, 0.0996]}, {"w": "get", "b": [0.4133, 0.0792, 0.4371, 0.0996]}, {"w": "1,", "b": [0.4419, 0.0792, 0.456, 0.0996]}, {"w": "but", "b": [0.4609, 0.0792, 0.4875, 0.0996]}, {"w": "if", "b": [0.4924, 0.0792, 0.5036, 0.0996]}, {"w": "you", "b": [0.5085, 0.0792, 0.5382, 0.0996]}, {"w": "integrate", "b": [0.5431, 0.0792, 0.6128, 0.0996]}, {"w": "the", "b": [0.6177, 0.0792, 0.6428, 0.0996]}, {"w": "likelihood", "b": [0.6477, 0.0792, 0.7279, 0.0996]}, {"w": "function", "b": [0.7328, 0.0792, 0.8008, 0.0996]}, {"w": "over", "b": [0.8057, 0.0792, 0.8408, 0.0996]}, {"w": "all", "b": [0.1592, 0.0973, 0.178, 0.1177]}, {"w": "possible", "b": [0.1825, 0.0973, 0.2464, 0.1177]}, {"w": "values", "b": [0.2509, 0.0973, 0.3001, 0.1177]}, {"w": "of", "b": [0.3046, 0.0973, 0.3206, 0.1177]}, {"w": "θ,", "b": [0.3251, 0.0971, 0.3391, 0.1177]}, {"w": "the", "b": [0.3436, 0.0973, 0.3687, 0.1177]}, {"w": "result", "b": [0.3732, 0.0973, 0.4178, 0.1177]}, {"w": "can", "b": [0.4223, 0.0973, 0.4503, 0.1177]}, {"w": "be", "b": [0.4548, 0.0973, 0.4733, 0.1177]}, {"w": "any", "b": [0.4778, 0.0973, 0.506, 0.1177]}, {"w": "positive", "b": [0.5105, 0.0973, 0.5726, 0.1177]}, {"w": "value.", "b": [0.5771, 0.0973, 0.6236, 0.1177]}]}, {"id": "b_1", "type": "paragraph", "text": "Figure 9-20. A model’s parametric function (top left), and some derived functions: a PDF (lower left), a likelihood function (top right) and a log likelihood function (lower right)", "words": [{"w": "Figure", "b": [0.1592, 0.3426, 0.2082, 0.3632]}, {"w": "9-20.", "b": [0.2128, 0.3426, 0.2524, 0.3632]}, {"w": "A", "b": [0.257, 0.3426, 0.2702, 0.3632]}, {"w": "model’s", "b": [0.2747, 0.3426, 0.3306, 0.3632]}, {"w": "parametric", "b": [0.3351, 0.3426, 0.4199, 0.3632]}, {"w": "function", "b": [0.4245, 0.3426, 0.4893, 0.3632]}, {"w": "(top", "b": [0.4939, 0.3426, 0.5253, 0.3632]}, {"w": "left),", "b": [0.5298, 0.3426, 0.5652, 0.3632]}, {"w": "and", "b": [0.5697, 0.3426, 0.5996, 0.3632]}, {"w": "some", "b": [0.6042, 0.3426, 0.6435, 0.3632]}, {"w": "derived", "b": [0.648, 0.3426, 0.7052, 0.3632]}, {"w": "functions:", "b": [0.7097, 0.3426, 0.786, 0.3632]}, {"w": "a", "b": [0.7905, 0.3426, 0.8002, 0.3632]}, {"w": "PDF", "b": [0.8048, 0.3426, 0.8398, 0.3632]}, {"w": "(lower", "b": [0.1592, 0.3608, 0.2083, 0.3814]}, {"w": "left),", "b": [0.2128, 0.3608, 0.2482, 0.3814]}, {"w": "a", "b": [0.2528, 0.3608, 0.2625, 0.3814]}, {"w": "likelihood", "b": [0.267, 0.3608, 0.3424, 0.3814]}, {"w": "function", "b": [0.3469, 0.3608, 0.4118, 0.3814]}, {"w": "(top", "b": [0.4163, 0.3608, 0.4477, 0.3814]}, {"w": "right)", "b": [0.4523, 0.3608, 0.4957, 0.3814]}, {"w": "and", "b": [0.5002, 0.3608, 0.5301, 0.3814]}, {"w": "a", "b": [0.5347, 0.3608, 0.5444, 0.3814]}, {"w": "log", "b": [0.5489, 0.3608, 0.5714, 0.3814]}, {"w": "likelihood", "b": [0.576, 0.3608, 0.6514, 0.3814]}, {"w": "function", "b": [0.6559, 0.3608, 0.7208, 0.3814]}, {"w": "(lower", "b": [0.7253, 0.3608, 0.7744, 0.3814]}, {"w": "right)", "b": [0.7789, 0.3608, 0.8223, 0.3814]}]}, {"id": "b_2", "type": "paragraph", "text": "Given a dataset X, a common task is to try to estimate the most likely values for the model parameters. To do this, you must find the values that maximize the likelihood function, given X. In this example, if you have observed a single instance x=2.5, the maximum likelihood estimate (MLE) of θ is θ=1.5. If a prior probability distribution g over θ exists, it is possible to take it into account by maximizing ℒ(θ|x)g(θ) rather than just maximizing ℒ(θ|x). This is called maximum a-posteriori (MAP) estimation. Since MAP constrains the parameter values, you can think of it as a regularized ver‐ sion of MLE.", "words": [{"w": "Given", "b": [0.1592, 0.3973, 0.2072, 0.4177]}, {"w": "a", "b": [0.213, 0.3973, 0.2218, 0.4177]}, {"w": "dataset", "b": [0.2276, 0.3973, 0.2829, 0.4177]}, {"w": "X,", "b": [0.2888, 0.3967, 0.3071, 0.4177]}, {"w": "a", "b": [0.3129, 0.3973, 0.3216, 0.4177]}, {"w": "common", "b": [0.3275, 0.3973, 0.3994, 0.4177]}, {"w": "task", "b": [0.4053, 0.3973, 0.4372, 0.4177]}, {"w": "is", "b": [0.443, 0.3973, 0.4556, 0.4177]}, {"w": "to", "b": [0.4615, 0.3973, 0.4776, 0.4177]}, {"w": "try", "b": [0.4835, 0.3973, 0.5066, 0.4177]}, {"w": "to", "b": [0.5124, 0.3973, 0.5286, 0.4177]}, {"w": "estimate", "b": [0.5344, 0.3973, 0.6006, 0.4177]}, {"w": "the", "b": [0.6064, 0.3973, 0.6315, 0.4177]}, {"w": "most", "b": [0.6374, 0.3973, 0.6771, 0.4177]}, {"w": "likely", "b": [0.6829, 0.3973, 0.7256, 0.4177]}, {"w": "values", "b": [0.7315, 0.3973, 0.7807, 0.4177]}, {"w": "for", "b": [0.7865, 0.3973, 0.8098, 0.4177]}, {"w": "the", "b": [0.8157, 0.3973, 0.8408, 0.4177]}, {"w": "model", "b": [0.1592, 0.4154, 0.2095, 0.4358]}, {"w": "parameters.", "b": [0.2151, 0.4154, 0.3086, 0.4358]}, {"w": "To", "b": [0.3142, 0.4154, 0.3346, 0.4358]}, {"w": "do", "b": [0.3401, 0.4154, 0.3607, 0.4358]}, {"w": "this,", "b": [0.3663, 0.4154, 0.4001, 0.4358]}, {"w": "you", "b": [0.4056, 0.4154, 0.4354, 0.4358]}, {"w": "must", "b": [0.441, 0.4154, 0.4807, 0.4358]}, {"w": "find", "b": [0.4863, 0.4154, 0.5188, 0.4358]}, {"w": "the", "b": [0.5244, 0.4154, 0.5494, 0.4358]}, {"w": "values", "b": [0.555, 0.4154, 0.6042, 0.4358]}, {"w": "that", "b": [0.6097, 0.4154, 0.6408, 0.4358]}, {"w": "maximize", "b": [0.6463, 0.4154, 0.7243, 0.4358]}, {"w": "the", "b": [0.7299, 0.4154, 0.755, 0.4358]}, {"w": "likelihood", "b": [0.7605, 0.4154, 0.8408, 0.4358]}, {"w": "function,", "b": [0.1592, 0.4335, 0.2317, 0.4539]}, {"w": "given", "b": [0.2379, 0.4335, 0.2809, 0.4539]}, {"w": "X.", "b": [0.2871, 0.433, 0.3053, 0.4539]}, {"w": "In", "b": [0.3115, 0.4335, 0.3291, 0.4539]}, {"w": "this", "b": [0.3352, 0.4335, 0.3645, 0.4539]}, {"w": "example,", "b": [0.3706, 0.4335, 0.4413, 0.4539]}, {"w": "if", "b": [0.4475, 0.4335, 0.4586, 0.4539]}, {"w": "you", "b": [0.4648, 0.4335, 0.4945, 0.4539]}, {"w": "have", "b": [0.5007, 0.4335, 0.5372, 0.4539]}, {"w": "observed", "b": [0.5433, 0.4335, 0.6153, 0.4539]}, {"w": "a", "b": [0.6214, 0.4335, 0.6301, 0.4539]}, {"w": "single", "b": [0.6363, 0.4335, 0.6824, 0.4539]}, {"w": "instance", "b": [0.6886, 0.4335, 0.7545, 0.4539]}, {"w": "x=2.5,", "b": [0.7606, 0.4333, 0.8096, 0.4539]}, {"w": "the", "b": [0.8157, 0.4335, 0.8408, 0.4539]}, {"w": "maximum", "b": [0.1592, 0.4546, 0.2402, 0.4751]}, {"w": "likelihood", "b": [0.2453, 0.4546, 0.3207, 0.4751]}, {"w": "estimate", "b": [0.3259, 0.4546, 0.3898, 0.4751]}, {"w": "(MLE)", "b": [0.3949, 0.4547, 0.4482, 0.4751]}, {"w": "of", "b": [0.4533, 0.4547, 0.4693, 0.4751]}, {"w": "θ", "b": [0.4744, 0.4546, 0.4839, 0.4751]}, {"w": "is", "b": [0.489, 0.4547, 0.5016, 0.4751]}, {"w": "θ=1.5.", "b": [0.5067, 0.4546, 0.5576, 0.4751]}, {"w": "If", "b": [0.5627, 0.4547, 0.5753, 0.4751]}, {"w": "a", "b": [0.5804, 0.4547, 0.5891, 0.4751]}, {"w": "prior", "b": [0.5942, 0.4547, 0.6348, 0.4751]}, {"w": "probability", "b": [0.6399, 0.4547, 0.7275, 0.4751]}, {"w": "distribution", "b": [0.7326, 0.4547, 0.8273, 0.4751]}, {"w": "g", "b": [0.8324, 0.4546, 0.8408, 0.4751]}, {"w": "over", "b": [0.1592, 0.4729, 0.1943, 0.4933]}, {"w": "θ", "b": [0.2012, 0.4727, 0.2106, 0.4933]}, {"w": "exists,", "b": [0.2175, 0.4729, 0.2658, 0.4933]}, {"w": "it", "b": [0.2726, 0.4729, 0.284, 0.4933]}, {"w": "is", "b": [0.2909, 0.4729, 0.3035, 0.4933]}, {"w": "possible", "b": [0.3103, 0.4729, 0.3743, 0.4933]}, {"w": "to", "b": [0.3811, 0.4729, 0.3973, 0.4933]}, {"w": "take", "b": [0.4042, 0.4729, 0.4372, 0.4933]}, {"w": "it", "b": [0.4441, 0.4729, 0.4554, 0.4933]}, {"w": "into", "b": [0.4623, 0.4729, 0.4942, 0.4933]}, {"w": "account", "b": [0.5011, 0.4729, 0.5638, 0.4933]}, {"w": "by", "b": [0.5707, 0.4729, 0.5898, 0.4933]}, {"w": "maximizing", "b": [0.5967, 0.4729, 0.6917, 0.4933]}, {"w": "ℒ(θ|x)g(θ)", "b": [0.6986, 0.4727, 0.7858, 0.4933]}, {"w": "rather", "b": [0.7926, 0.4729, 0.8408, 0.4933]}, {"w": "than", "b": [0.1592, 0.491, 0.1954, 0.5114]}, {"w": "just", "b": [0.2002, 0.491, 0.2291, 0.5114]}, {"w": "maximizing", "b": [0.2339, 0.491, 0.3289, 0.5114]}, {"w": "ℒ(θ|x).", "b": [0.3336, 0.4908, 0.3929, 0.5114]}, {"w": "This", "b": [0.3976, 0.491, 0.433, 0.5114]}, {"w": "is", "b": [0.4378, 0.491, 0.4504, 0.5114]}, {"w": "called", "b": [0.4551, 0.491, 0.5012, 0.5114]}, {"w": "maximum", "b": [0.5059, 0.491, 0.5882, 0.5114]}, {"w": "a-posteriori", "b": [0.5929, 0.491, 0.6865, 0.5114]}, {"w": "(MAP)", "b": [0.6912, 0.491, 0.7475, 0.5114]}, {"w": "estimation.", "b": [0.7522, 0.491, 0.8408, 0.5114]}, {"w": "Since", "b": [0.1592, 0.5092, 0.2016, 0.5296]}, {"w": "MAP", "b": [0.2074, 0.5092, 0.2499, 0.5296]}, {"w": "constrains", "b": [0.2556, 0.5092, 0.3379, 0.5296]}, {"w": "the", "b": [0.3436, 0.5092, 0.3687, 0.5296]}, {"w": "parameter", "b": [0.3744, 0.5092, 0.4561, 0.5296]}, {"w": "values,", "b": [0.4618, 0.5092, 0.5155, 0.5296]}, {"w": "you", "b": [0.5212, 0.5092, 0.551, 0.5296]}, {"w": "can", "b": [0.5567, 0.5092, 0.5847, 0.5296]}, {"w": "think", "b": [0.5904, 0.5092, 0.6331, 0.5296]}, {"w": "of", "b": [0.6388, 0.5092, 0.6548, 0.5296]}, {"w": "it", "b": [0.6605, 0.5092, 0.6719, 0.5296]}, {"w": "as", "b": [0.6776, 0.5092, 0.6936, 0.5296]}, {"w": "a", "b": [0.6993, 0.5092, 0.708, 0.5296]}, {"w": "regularized", "b": [0.7137, 0.5092, 0.803, 0.5296]}, {"w": "ver‐", "b": [0.8087, 0.5092, 0.8408, 0.5296]}, {"w": "sion", "b": [0.1592, 0.5273, 0.1928, 0.5477]}, {"w": "of", "b": [0.1973, 0.5273, 0.2133, 0.5477]}, {"w": "MLE.", "b": [0.2178, 0.5273, 0.262, 0.5477]}]}, {"id": "b_3", "type": "paragraph", "text": "Notice that it is equivalent to maximize the likelihood function or to maximize its logarithm (represented in the lower right hand side of Figure 9-20): indeed, the loga‐ rithm is a strictly increasing function, so if θ maximizes the log likelihood, it also maximizes the likelihood. It turns out that it is generally easier to maximize the log likelihood. For example, if you observed several independent instances x(1) to x(m), you would need to find the value of θ that maximizes the product of the individual likeli‐ hood functions. But it is equivalent, and much simpler, to maximize the sum (not the product) of the log likelihood functions, thanks to the magic of the logarithm which converts products into sums: log(ab)=log(a)+log(b).", "words": [{"w": "Notice", "b": [0.1592, 0.5545, 0.2118, 0.5749]}, {"w": "that", "b": [0.219, 0.5545, 0.25, 0.5749]}, {"w": "it", "b": [0.2573, 0.5545, 0.2686, 0.5749]}, {"w": "is", "b": [0.2759, 0.5545, 0.2885, 0.5749]}, {"w": "equivalent", "b": [0.2957, 0.5545, 0.378, 0.5749]}, {"w": "to", "b": [0.3852, 0.5545, 0.4014, 0.5749]}, {"w": "maximize", "b": [0.4086, 0.5545, 0.4866, 0.5749]}, {"w": "the", "b": [0.4938, 0.5545, 0.5189, 0.5749]}, {"w": "likelihood", "b": [0.5261, 0.5545, 0.6064, 0.5749]}, {"w": "function", "b": [0.6136, 0.5545, 0.6816, 0.5749]}, {"w": "or", "b": [0.6888, 0.5545, 0.7063, 0.5749]}, {"w": "to", "b": [0.7135, 0.5545, 0.7297, 0.5749]}, {"w": "maximize", "b": [0.7369, 0.5545, 0.8149, 0.5749]}, {"w": "its", "b": [0.8221, 0.5545, 0.8408, 0.5749]}, {"w": "logarithm", "b": [0.1592, 0.5727, 0.2379, 0.5931]}, {"w": "(represented", "b": [0.2432, 0.5727, 0.3432, 0.5931]}, {"w": "in", "b": [0.3485, 0.5727, 0.3646, 0.5931]}, {"w": "the", "b": [0.3699, 0.5727, 0.395, 0.5931]}, {"w": "lower", "b": [0.4003, 0.5727, 0.4448, 0.5931]}, {"w": "right", "b": [0.45, 0.5727, 0.4883, 0.5931]}, {"w": "hand", "b": [0.4935, 0.5727, 0.5342, 0.5931]}, {"w": "side", "b": [0.5394, 0.5727, 0.571, 0.5931]}, {"w": "of", "b": [0.5762, 0.5727, 0.5922, 0.5931]}, {"w": "Figure", "b": [0.5975, 0.5727, 0.6489, 0.5931]}, {"w": "9-20):", "b": [0.6542, 0.5727, 0.7012, 0.5931]}, {"w": "indeed,", "b": [0.7065, 0.5727, 0.765, 0.5931]}, {"w": "the", "b": [0.7702, 0.5727, 0.7953, 0.5931]}, {"w": "loga‐", "b": [0.8006, 0.5727, 0.8408, 0.5931]}, {"w": "rithm", "b": [0.1592, 0.5908, 0.2048, 0.6112]}, {"w": "is", "b": [0.2124, 0.5908, 0.225, 0.6112]}, {"w": "a", "b": [0.2325, 0.5908, 0.2412, 0.6112]}, {"w": "strictly", "b": [0.2488, 0.5908, 0.3033, 0.6112]}, {"w": "increasing", "b": [0.3109, 0.5908, 0.3927, 0.6112]}, {"w": "function,", "b": [0.4002, 0.5908, 0.4728, 0.6112]}, {"w": "so", "b": [0.4803, 0.5908, 0.4977, 0.6112]}, {"w": "if", "b": [0.5053, 0.5908, 0.5164, 0.6112]}, {"w": "θ", "b": [0.524, 0.5906, 0.5335, 0.6112]}, {"w": "maximizes", "b": [0.541, 0.5908, 0.6263, 0.6112]}, {"w": "the", "b": [0.6338, 0.5908, 0.6589, 0.6112]}, {"w": "log", "b": [0.6664, 0.5908, 0.6909, 0.6112]}, {"w": "likelihood,", "b": [0.6984, 0.5908, 0.7832, 0.6112]}, {"w": "it", "b": [0.7907, 0.5908, 0.8021, 0.6112]}, {"w": "also", "b": [0.8097, 0.5908, 0.8408, 0.6112]}, {"w": "maximizes", "b": [0.1592, 0.6089, 0.2445, 0.6293]}, {"w": "the", "b": [0.2509, 0.6089, 0.2759, 0.6293]}, {"w": "likelihood.", "b": [0.2823, 0.6089, 0.3671, 0.6293]}, {"w": "It", "b": [0.3735, 0.6089, 0.3855, 0.6293]}, {"w": "turns", "b": [0.3919, 0.6089, 0.434, 0.6293]}, {"w": "out", "b": [0.4403, 0.6089, 0.467, 0.6293]}, {"w": "that", "b": [0.4734, 0.6089, 0.5044, 0.6293]}, {"w": "it", "b": [0.5108, 0.6089, 0.5222, 0.6293]}, {"w": "is", "b": [0.5286, 0.6089, 0.5411, 0.6293]}, {"w": "generally", "b": [0.5475, 0.6089, 0.6197, 0.6293]}, {"w": "easier", "b": [0.6261, 0.6089, 0.6716, 0.6293]}, {"w": "to", "b": [0.678, 0.6089, 0.6942, 0.6293]}, {"w": "maximize", "b": [0.7006, 0.6089, 0.7785, 0.6293]}, {"w": "the", "b": [0.7849, 0.6089, 0.81, 0.6293]}, {"w": "log", "b": [0.8164, 0.6089, 0.8408, 0.6293]}, {"w": "likelihood.", "b": [0.1592, 0.6271, 0.244, 0.6475]}, {"w": "For", "b": [0.2486, 0.6271, 0.2762, 0.6475]}, {"w": "example,", "b": [0.2808, 0.6271, 0.3516, 0.6475]}, {"w": "if", "b": [0.3562, 0.6271, 0.3674, 0.6475]}, {"w": "you", "b": [0.372, 0.6271, 0.4018, 0.6475]}, {"w": "observed", "b": [0.4064, 0.6271, 0.4783, 0.6475]}, {"w": "several", "b": [0.4829, 0.6271, 0.5374, 0.6475]}, {"w": "independent", "b": [0.542, 0.6271, 0.6422, 0.6475]}, {"w": "instances", "b": [0.6468, 0.6271, 0.72, 0.6475]}, {"w": "x(1)", "b": [0.7246, 0.6269, 0.7486, 0.6475]}, {"w": "to", "b": [0.7532, 0.6271, 0.7694, 0.6475]}, {"w": "x(m),", "b": [0.774, 0.6269, 0.8064, 0.6475]}, {"w": "you", "b": [0.8109, 0.6271, 0.8407, 0.6475]}, {"w": "would", "b": [0.1592, 0.6452, 0.209, 0.6656]}, {"w": "need", "b": [0.2143, 0.6452, 0.2525, 0.6656]}, {"w": "to", "b": [0.2578, 0.6452, 0.2739, 0.6656]}, {"w": "find", "b": [0.2792, 0.6452, 0.3118, 0.6656]}, {"w": "the", "b": [0.3171, 0.6452, 0.3421, 0.6656]}, {"w": "value", "b": [0.3474, 0.6452, 0.3893, 0.6656]}, {"w": "of", "b": [0.3946, 0.6452, 0.4106, 0.6656]}, {"w": "θ", "b": [0.4159, 0.645, 0.4254, 0.6656]}, {"w": "that", "b": [0.4307, 0.6452, 0.4617, 0.6656]}, {"w": "maximizes", "b": [0.467, 0.6452, 0.5523, 0.6656]}, {"w": "the", "b": [0.5576, 0.6452, 0.5826, 0.6656]}, {"w": "product", "b": [0.5879, 0.6452, 0.6513, 0.6656]}, {"w": "of", "b": [0.6566, 0.6452, 0.6726, 0.6656]}, {"w": "the", "b": [0.6779, 0.6452, 0.7029, 0.6656]}, {"w": "individual", "b": [0.7082, 0.6452, 0.7895, 0.6656]}, {"w": "likeli‐", "b": [0.7948, 0.6452, 0.8408, 0.6656]}, {"w": "hood", "b": [0.1592, 0.6634, 0.2005, 0.6838]}, {"w": "functions.", "b": [0.2056, 0.6634, 0.2854, 0.6838]}, {"w": "But", "b": [0.2904, 0.6634, 0.3187, 0.6838]}, {"w": "it", "b": [0.3237, 0.6634, 0.3351, 0.6838]}, {"w": "is", "b": [0.3402, 0.6634, 0.3528, 0.6838]}, {"w": "equivalent,", "b": [0.3578, 0.6634, 0.4446, 0.6838]}, {"w": "and", "b": [0.4497, 0.6634, 0.4797, 0.6838]}, {"w": "much", "b": [0.4848, 0.6634, 0.5302, 0.6838]}, {"w": "simpler,", "b": [0.5352, 0.6634, 0.5982, 0.6838]}, {"w": "to", "b": [0.6032, 0.6634, 0.6194, 0.6838]}, {"w": "maximize", "b": [0.6245, 0.6634, 0.7024, 0.6838]}, {"w": "the", "b": [0.7075, 0.6634, 0.7326, 0.6838]}, {"w": "sum", "b": [0.7376, 0.6634, 0.7717, 0.6838]}, {"w": "(not", "b": [0.7768, 0.6634, 0.8106, 0.6838]}, {"w": "the", "b": [0.8157, 0.6634, 0.8408, 0.6838]}, {"w": "product)", "b": [0.1592, 0.6815, 0.2294, 0.7019]}, {"w": "of", "b": [0.2352, 0.6815, 0.2512, 0.7019]}, {"w": "the", "b": [0.257, 0.6815, 0.282, 0.7019]}, {"w": "log", "b": [0.2878, 0.6815, 0.3122, 0.7019]}, {"w": "likelihood", "b": [0.318, 0.6815, 0.3982, 0.7019]}, {"w": "functions,", "b": [0.404, 0.6815, 0.4838, 0.7019]}, {"w": "thanks", "b": [0.4896, 0.6815, 0.5429, 0.7019]}, {"w": "to", "b": [0.5487, 0.6815, 0.5649, 0.7019]}, {"w": "the", "b": [0.5706, 0.6815, 0.5957, 0.7019]}, {"w": "magic", "b": [0.6015, 0.6815, 0.6494, 0.7019]}, {"w": "of", "b": [0.6552, 0.6815, 0.6712, 0.7019]}, {"w": "the", "b": [0.677, 0.6815, 0.702, 0.7019]}, {"w": "logarithm", "b": [0.7078, 0.6815, 0.7865, 0.7019]}, {"w": "which", "b": [0.7923, 0.6815, 0.8408, 0.7019]}, {"w": "converts", "b": [0.1592, 0.6996, 0.2264, 0.72]}, {"w": "products", "b": [0.231, 0.6996, 0.3016, 0.72]}, {"w": "into", "b": [0.3061, 0.6996, 0.338, 0.72]}, {"w": "sums:", "b": [0.3425, 0.6996, 0.3884, 0.72]}, {"w": "log(ab)=log(a)+log(b).", "b": [0.3929, 0.6994, 0.5732, 0.72]}]}, {"id": "b_4", "type": "paragraph", "text": "Once you have estimated θ, the value of θ that maximizes the likelihood function, then you are ready to compute L = ℒθ, �. This is the value which is used to com‐ pute the AIC and BIC: you can think of it as a measure of how well the model fits the data.", "words": [{"w": "Once", "b": [0.1592, 0.7299, 0.2017, 0.7503]}, {"w": "you", "b": [0.2089, 0.7299, 0.2387, 0.7503]}, {"w": "have", "b": [0.2459, 0.7299, 0.2825, 0.7503]}, {"w": "estimated", "b": [0.2897, 0.7299, 0.3663, 0.7503]}, {"w": "θ,", "b": [0.3735, 0.7297, 0.3893, 0.7503]}, {"w": "the", "b": [0.3965, 0.7299, 0.4216, 0.7503]}, {"w": "value", "b": [0.4288, 0.7299, 0.4707, 0.7503]}, {"w": "of", "b": [0.4779, 0.7299, 0.4939, 0.7503]}, {"w": "θ", "b": [0.5011, 0.7297, 0.5106, 0.7503]}, {"w": "that", "b": [0.5178, 0.7299, 0.5488, 0.7503]}, {"w": "maximizes", "b": [0.556, 0.7299, 0.6413, 0.7503]}, {"w": "the", "b": [0.6485, 0.7299, 0.6736, 0.7503]}, {"w": "likelihood", "b": [0.6808, 0.7299, 0.761, 0.7503]}, {"w": "function,", "b": [0.7683, 0.7299, 0.8408, 0.7503]}, {"w": "then", "b": [0.1592, 0.7511, 0.1952, 0.7715]}, {"w": "you", "b": [0.201, 0.7511, 0.2308, 0.7715]}, {"w": "are", "b": [0.2367, 0.7511, 0.2612, 0.7715]}, {"w": "ready", "b": [0.267, 0.7511, 0.3111, 0.7715]}, {"w": "to", "b": [0.317, 0.7511, 0.3332, 0.7715]}, {"w": "compute", "b": [0.339, 0.7511, 0.4088, 0.7715]}, {"w": "L", "b": [0.4147, 0.7509, 0.4253, 0.7715]}, {"w": "=", "b": [0.4315, 0.7511, 0.443, 0.7715]}, {"w": "ℒθ,", "b": [0.4485, 0.7509, 0.488, 0.7715]}, {"w": "�.", "b": [0.4913, 0.7511, 0.5171, 0.7715]}, {"w": "This", "b": [0.523, 0.7511, 0.5584, 0.7715]}, {"w": "is", "b": [0.5643, 0.7511, 0.5769, 0.7715]}, {"w": "the", "b": [0.5828, 0.7511, 0.6079, 0.7715]}, {"w": "value", "b": [0.6137, 0.7511, 0.6556, 0.7715]}, {"w": "which", "b": [0.6615, 0.7511, 0.71, 0.7715]}, {"w": "is", "b": [0.7158, 0.7511, 0.7284, 0.7715]}, {"w": "used", "b": [0.7343, 0.7511, 0.771, 0.7715]}, {"w": "to", "b": [0.7769, 0.7511, 0.7931, 0.7715]}, {"w": "com‐", "b": [0.799, 0.7511, 0.8408, 0.7715]}, {"w": "pute", "b": [0.1592, 0.7706, 0.1946, 0.791]}, {"w": "the", "b": [0.1996, 0.7706, 0.2247, 0.791]}, {"w": "AIC", "b": [0.2297, 0.7706, 0.2633, 0.791]}, {"w": "and", "b": [0.2683, 0.7706, 0.2983, 0.791]}, {"w": "BIC:", "b": [0.3033, 0.7706, 0.3395, 0.791]}, {"w": "you", "b": [0.3444, 0.7706, 0.3742, 0.791]}, {"w": "can", "b": [0.3792, 0.7706, 0.4071, 0.791]}, {"w": "think", "b": [0.4121, 0.7706, 0.4547, 0.791]}, {"w": "of", "b": [0.4597, 0.7706, 0.4757, 0.791]}, {"w": "it", "b": [0.4807, 0.7706, 0.492, 0.791]}, {"w": "as", "b": [0.497, 0.7706, 0.513, 0.791]}, {"w": "a", "b": [0.518, 0.7706, 0.5267, 0.791]}, {"w": "measure", "b": [0.5317, 0.7706, 0.5987, 0.791]}, {"w": "of", "b": [0.6036, 0.7706, 0.6196, 0.791]}, {"w": "how", "b": [0.6246, 0.7706, 0.6589, 0.791]}, {"w": "well", "b": [0.6639, 0.7706, 0.6959, 0.791]}, {"w": "the", "b": [0.7009, 0.7706, 0.726, 0.791]}, {"w": "model", "b": [0.7309, 0.7706, 0.7812, 0.791]}, {"w": "fits", "b": [0.7862, 0.7706, 0.8107, 0.791]}, {"w": "the", "b": [0.8157, 0.7706, 0.8408, 0.791]}, {"w": "data.", "b": [0.1592, 0.7888, 0.1973, 0.8091]}]}, {"id": "b_5", "type": "paragraph", "text": "To compute the BIC and AIC, just call the bic() or aic() methods:", "words": [{"w": "To", "b": [0.1429, 0.8398, 0.1643, 0.8612]}, {"w": "compute", "b": [0.169, 0.8398, 0.2423, 0.8612]}, {"w": "the", "b": [0.2471, 0.8398, 0.2734, 0.8612]}, {"w": "BIC", "b": [0.2781, 0.8398, 0.3113, 0.8612]}, {"w": "and", "b": [0.3161, 0.8398, 0.3476, 0.8612]}, {"w": "AIC,", "b": [0.3523, 0.8398, 0.3924, 0.8612]}, {"w": "just", "b": [0.3972, 0.8398, 0.4276, 0.8612]}, {"w": "call", "b": [0.4323, 0.8398, 0.4608, 0.8612]}, {"w": "the", "b": [0.4655, 0.8398, 0.4918, 0.8612]}, {"w": "bic()", "b": [0.4966, 0.843, 0.546, 0.8581]}, {"w": "or", "b": [0.5508, 0.8398, 0.5691, 0.8612]}, {"w": "aic()", "b": [0.5738, 0.843, 0.6233, 0.8581]}, {"w": "methods:", "b": [0.6281, 0.8398, 0.7055, 0.8612]}]}, {"id": "b_6", "type": "paragraph", "text": "Gaussian Mixtures | 269", "words": [{"w": "Gaussian", "b": [0.6892, 0.9225, 0.7415, 0.9388]}, {"w": "Mixtures", "b": [0.7443, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "269", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 296, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": ">>> gm.bic(X) 8189.74345832983 >>> gm.aic(X) 8102.518178214792", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "gm.bic(X)", "b": [0.2103, 0.0829, 0.2862, 0.0958]}, {"w": "8189.74345832983", "b": [0.1766, 0.0983, 0.3115, 0.1112]}, {"w": ">>>", "b": [0.1766, 0.1138, 0.2019, 0.1266]}, {"w": "gm.aic(X)", "b": [0.2103, 0.1138, 0.2862, 0.1266]}, {"w": "8102.518178214792", "b": [0.1766, 0.1292, 0.3199, 0.142]}]}, {"id": "b_1", "type": "paragraph", "text": "Figure 9-21 shows the BIC for different numbers of clusters k. As you can see, both the BIC and the AIC are lowest when k=3, so it is most likely the best choice. Note that we could also search for the best value for the covariance_type hyperparameter. For example, if it is \"spherical\" rather than \"full\", then the model has much fewer parameters to learn, but it does not fit the data as well.", "words": [{"w": "Figure", "b": [0.1429, 0.1498, 0.1969, 0.1712]}, {"w": "9-21", "b": [0.2032, 0.1498, 0.2407, 0.1712]}, {"w": "shows", "b": [0.247, 0.1498, 0.2983, 0.1712]}, {"w": "the", "b": [0.3047, 0.1498, 0.3311, 0.1712]}, {"w": "BIC", "b": [0.3374, 0.1498, 0.3706, 0.1712]}, {"w": "for", "b": [0.377, 0.1498, 0.4015, 0.1712]}, {"w": "different", "b": [0.4079, 0.1498, 0.4796, 0.1712]}, {"w": "numbers", "b": [0.486, 0.1498, 0.56, 0.1712]}, {"w": "of", "b": [0.5663, 0.1498, 0.5831, 0.1712]}, {"w": "clusters", "b": [0.5895, 0.1498, 0.6529, 0.1712]}, {"w": "k.", "b": [0.6593, 0.1496, 0.6738, 0.1712]}, {"w": "As", "b": [0.6802, 0.1498, 0.7022, 0.1712]}, {"w": "you", "b": [0.7086, 0.1498, 0.7399, 0.1712]}, {"w": "can", "b": [0.7462, 0.1498, 0.7756, 0.1712]}, {"w": "see,", "b": [0.782, 0.1498, 0.8121, 0.1712]}, {"w": "both", "b": [0.8185, 0.1498, 0.8571, 0.1712]}, {"w": "the", "b": [0.1429, 0.1689, 0.1692, 0.1903]}, {"w": "BIC", "b": [0.1757, 0.1689, 0.2089, 0.1903]}, {"w": "and", "b": [0.2155, 0.1689, 0.247, 0.1903]}, {"w": "the", "b": [0.2536, 0.1689, 0.2799, 0.1903]}, {"w": "AIC", "b": [0.2865, 0.1689, 0.3218, 0.1903]}, {"w": "are", "b": [0.3284, 0.1689, 0.3541, 0.1903]}, {"w": "lowest", "b": [0.3607, 0.1689, 0.4137, 0.1903]}, {"w": "when", "b": [0.4202, 0.1689, 0.4659, 0.1903]}, {"w": "k=3,", "b": [0.4724, 0.1687, 0.5091, 0.1903]}, {"w": "so", "b": [0.5156, 0.1689, 0.5339, 0.1903]}, {"w": "it", "b": [0.5404, 0.1689, 0.5524, 0.1903]}, {"w": "is", "b": [0.5589, 0.1689, 0.5721, 0.1903]}, {"w": "most", "b": [0.5787, 0.1689, 0.6204, 0.1903]}, {"w": "likely", "b": [0.6269, 0.1689, 0.6718, 0.1903]}, {"w": "the", "b": [0.6784, 0.1689, 0.7047, 0.1903]}, {"w": "best", "b": [0.7112, 0.1689, 0.7447, 0.1903]}, {"w": "choice.", "b": [0.7512, 0.1689, 0.8098, 0.1903]}, {"w": "Note", "b": [0.8163, 0.1689, 0.8571, 0.1903]}, {"w": "that", "b": [0.1429, 0.1888, 0.1754, 0.2102]}, {"w": "we", "b": [0.1806, 0.1888, 0.2037, 0.2102]}, {"w": "could", "b": [0.2088, 0.1888, 0.2556, 0.2102]}, {"w": "also", "b": [0.2607, 0.1888, 0.2934, 0.2102]}, {"w": "search", "b": [0.2985, 0.1888, 0.3518, 0.2102]}, {"w": "for", "b": [0.3569, 0.1888, 0.3814, 0.2102]}, {"w": "the", "b": [0.3865, 0.1888, 0.4129, 0.2102]}, {"w": "best", "b": [0.418, 0.1888, 0.4514, 0.2102]}, {"w": "value", "b": [0.4565, 0.1888, 0.5005, 0.2102]}, {"w": "for", "b": [0.5056, 0.1888, 0.5301, 0.2102]}, {"w": "the", "b": [0.5352, 0.1888, 0.5616, 0.2102]}, {"w": "covariance_type", "b": [0.5667, 0.192, 0.7151, 0.2071]}, {"w": "hyperparameter.", "b": [0.7202, 0.1888, 0.8571, 0.2102]}, {"w": "For", "b": [0.1429, 0.2087, 0.1718, 0.2302]}, {"w": "example,", "b": [0.1771, 0.2087, 0.2514, 0.2302]}, {"w": "if", "b": [0.2567, 0.2087, 0.2685, 0.2302]}, {"w": "it", "b": [0.2738, 0.2087, 0.2857, 0.2302]}, {"w": "is", "b": [0.291, 0.2087, 0.3042, 0.2302]}, {"w": "\"spherical\"", "b": [0.3096, 0.2119, 0.4184, 0.227]}, {"w": "rather", "b": [0.4237, 0.2087, 0.4743, 0.2302]}, {"w": "than", "b": [0.4796, 0.2087, 0.5176, 0.2302]}, {"w": "\"full\",", "b": [0.5229, 0.2087, 0.587, 0.2302]}, {"w": "then", "b": [0.5923, 0.2087, 0.63, 0.2302]}, {"w": "the", "b": [0.6353, 0.2087, 0.6617, 0.2302]}, {"w": "model", "b": [0.667, 0.2087, 0.7198, 0.2302]}, {"w": "has", "b": [0.7251, 0.2087, 0.753, 0.2302]}, {"w": "much", "b": [0.7583, 0.2087, 0.806, 0.2302]}, {"w": "fewer", "b": [0.8113, 0.2087, 0.8572, 0.2302]}, {"w": "parameters", "b": [0.1429, 0.2278, 0.2363, 0.2492]}, {"w": "to", "b": [0.241, 0.2278, 0.258, 0.2492]}, {"w": "learn,", "b": [0.2627, 0.2278, 0.3099, 0.2492]}, {"w": "but", "b": [0.3146, 0.2278, 0.3426, 0.2492]}, {"w": "it", "b": [0.3473, 0.2278, 0.3593, 0.2492]}, {"w": "does", "b": [0.364, 0.2278, 0.4021, 0.2492]}, {"w": "not", "b": [0.4069, 0.2278, 0.4352, 0.2492]}, {"w": "fit", "b": [0.44, 0.2278, 0.4581, 0.2492]}, {"w": "the", "b": [0.4628, 0.2278, 0.4891, 0.2492]}, {"w": "data", "b": [0.4939, 0.2278, 0.5291, 0.2492]}, {"w": "as", "b": [0.5338, 0.2278, 0.5506, 0.2492]}, {"w": "well.", "b": [0.5554, 0.2278, 0.5938, 0.2492]}]}, {"id": "b_2", "type": "equation", "text": "Figure 9-21. AIC and BIC for different numbers of clusters k", "words": [{"w": "Figure", "b": [0.1429, 0.4063, 0.1943, 0.4279]}, {"w": "9-21.", "b": [0.1991, 0.4063, 0.2407, 0.4279]}, {"w": "AIC", "b": [0.2455, 0.4063, 0.2794, 0.4279]}, {"w": "and", "b": [0.2842, 0.4063, 0.3156, 0.4279]}, {"w": "BIC", "b": [0.3204, 0.4063, 0.3525, 0.4279]}, {"w": "for", "b": [0.3573, 0.4063, 0.38, 0.4279]}, {"w": "different", "b": [0.3847, 0.4063, 0.4538, 0.4279]}, {"w": "numbers", "b": [0.4586, 0.4063, 0.5291, 0.4279]}, {"w": "of", "b": [0.5339, 0.4063, 0.5491, 0.4279]}, {"w": "clusters", "b": [0.5539, 0.4063, 0.6136, 0.4279]}, {"w": "k", "b": [0.6183, 0.4063, 0.6281, 0.4279]}]}, {"id": "b_3", "type": "paragraph", "text": "Bayesian Gaussian Mixture Models", "words": [{"w": "Bayesian", "b": [0.1429, 0.4409, 0.2354, 0.4695]}, {"w": "Gaussian", "b": [0.2403, 0.4409, 0.332, 0.4695]}, {"w": "Mixture", "b": [0.337, 0.4409, 0.4176, 0.4695]}, {"w": "Models", "b": [0.4225, 0.4409, 0.4966, 0.4695]}]}, {"id": "b_4", "type": "paragraph", "text": "Rather than manually searching for the optimal number of clusters, it is possible to use instead the BayesianGaussianMixture class which is capable of giving weights equal (or close) to zero to unnecessary clusters. Just set the number of clusters n_com ponents to a value that you have good reason to believe is greater than the optimal number of clusters (this assumes some minimal knowledge about the problem at hand), and the algorithm will eliminate the unnecessary clusters automatically. For example, let’s set the number of clusters to 10 and see what happens:", "words": [{"w": "Rather", "b": [0.1429, 0.4754, 0.199, 0.4968]}, {"w": "than", "b": [0.2056, 0.4754, 0.2436, 0.4968]}, {"w": "manually", "b": [0.2503, 0.4754, 0.3278, 0.4968]}, {"w": "searching", "b": [0.3344, 0.4754, 0.4145, 0.4968]}, {"w": "for", "b": [0.4211, 0.4754, 0.4456, 0.4968]}, {"w": "the", "b": [0.4523, 0.4754, 0.4786, 0.4968]}, {"w": "optimal", "b": [0.4852, 0.4754, 0.5502, 0.4968]}, {"w": "number", "b": [0.5568, 0.4754, 0.6231, 0.4968]}, {"w": "of", "b": [0.6298, 0.4754, 0.6466, 0.4968]}, {"w": "clusters,", "b": [0.6532, 0.4754, 0.7213, 0.4968]}, {"w": "it", "b": [0.728, 0.4754, 0.7399, 0.4968]}, {"w": "is", "b": [0.7465, 0.4754, 0.7598, 0.4968]}, {"w": "possible", "b": [0.7664, 0.4754, 0.8335, 0.4968]}, {"w": "to", "b": [0.8402, 0.4754, 0.8571, 0.4968]}, {"w": "use", "b": [0.1429, 0.4953, 0.1704, 0.5167]}, {"w": "instead", "b": [0.178, 0.4953, 0.238, 0.5167]}, {"w": "the", "b": [0.2456, 0.4953, 0.272, 0.5167]}, {"w": "BayesianGaussianMixture", "b": [0.2796, 0.4985, 0.5072, 0.5136]}, {"w": "class", "b": [0.5148, 0.4953, 0.5533, 0.5167]}, {"w": "which", "b": [0.5609, 0.4953, 0.6118, 0.5167]}, {"w": "is", "b": [0.6195, 0.4953, 0.6327, 0.5167]}, {"w": "capable", "b": [0.6403, 0.4953, 0.7026, 0.5167]}, {"w": "of", "b": [0.7102, 0.4953, 0.727, 0.5167]}, {"w": "giving", "b": [0.7346, 0.4953, 0.7864, 0.5167]}, {"w": "weights", "b": [0.794, 0.4953, 0.8572, 0.5167]}, {"w": "equal", "b": [0.1429, 0.5153, 0.1878, 0.5367]}, {"w": "(or", "b": [0.1934, 0.5153, 0.2189, 0.5367]}, {"w": "close)", "b": [0.2245, 0.5153, 0.2729, 0.5367]}, {"w": "to", "b": [0.2784, 0.5153, 0.2954, 0.5367]}, {"w": "zero", "b": [0.3009, 0.5153, 0.3369, 0.5367]}, {"w": "to", "b": [0.3424, 0.5153, 0.3594, 0.5367]}, {"w": "unnecessary", "b": [0.3649, 0.5153, 0.4676, 0.5367]}, {"w": "clusters.", "b": [0.4732, 0.5153, 0.5413, 0.5367]}, {"w": "Just", "b": [0.5468, 0.5153, 0.5781, 0.5367]}, {"w": "set", "b": [0.5836, 0.5153, 0.6065, 0.5367]}, {"w": "the", "b": [0.612, 0.5153, 0.6383, 0.5367]}, {"w": "number", "b": [0.6439, 0.5153, 0.7101, 0.5367]}, {"w": "of", "b": [0.7157, 0.5153, 0.7325, 0.5367]}, {"w": "clusters", "b": [0.738, 0.5153, 0.8014, 0.5367]}, {"w": "n_com", "b": [0.8069, 0.5185, 0.8564, 0.5335]}, {"w": "ponents", "b": [0.1429, 0.5384, 0.2121, 0.5535]}, {"w": "to", "b": [0.2188, 0.5352, 0.2358, 0.5566]}, {"w": "a", "b": [0.2424, 0.5352, 0.2516, 0.5566]}, {"w": "value", "b": [0.2583, 0.5352, 0.3022, 0.5566]}, {"w": "that", "b": [0.3089, 0.5352, 0.3415, 0.5566]}, {"w": "you", "b": [0.3482, 0.5352, 0.3794, 0.5566]}, {"w": "have", "b": [0.3861, 0.5352, 0.4245, 0.5566]}, {"w": "good", "b": [0.4312, 0.5352, 0.4732, 0.5566]}, {"w": "reason", "b": [0.4798, 0.5352, 0.5352, 0.5566]}, {"w": "to", "b": [0.5419, 0.5352, 0.5589, 0.5566]}, {"w": "believe", "b": [0.5656, 0.5352, 0.6232, 0.5566]}, {"w": "is", "b": [0.6299, 0.5352, 0.6431, 0.5566]}, {"w": "greater", "b": [0.6498, 0.5352, 0.7078, 0.5566]}, {"w": "than", "b": [0.7145, 0.5352, 0.7525, 0.5566]}, {"w": "the", "b": [0.7592, 0.5352, 0.7855, 0.5566]}, {"w": "optimal", "b": [0.7922, 0.5352, 0.8571, 0.5566]}, {"w": "number", "b": [0.1428, 0.5543, 0.2091, 0.5757]}, {"w": "of", "b": [0.2178, 0.5543, 0.2346, 0.5757]}, {"w": "clusters", "b": [0.2432, 0.5543, 0.3066, 0.5757]}, {"w": "(this", "b": [0.3152, 0.5543, 0.3531, 0.5757]}, {"w": "assumes", "b": [0.3618, 0.5543, 0.4308, 0.5757]}, {"w": "some", "b": [0.4394, 0.5543, 0.4836, 0.5757]}, {"w": "minimal", "b": [0.4923, 0.5543, 0.5634, 0.5757]}, {"w": "knowledge", "b": [0.572, 0.5543, 0.6624, 0.5757]}, {"w": "about", "b": [0.671, 0.5543, 0.7188, 0.5757]}, {"w": "the", "b": [0.7274, 0.5543, 0.7537, 0.5757]}, {"w": "problem", "b": [0.7624, 0.5543, 0.8334, 0.5757]}, {"w": "at", "b": [0.842, 0.5543, 0.8571, 0.5757]}, {"w": "hand),", "b": [0.1429, 0.5733, 0.1975, 0.5947]}, {"w": "and", "b": [0.2049, 0.5733, 0.2364, 0.5947]}, {"w": "the", "b": [0.2438, 0.5733, 0.2701, 0.5947]}, {"w": "algorithm", "b": [0.2775, 0.5733, 0.3601, 0.5947]}, {"w": "will", "b": [0.3675, 0.5733, 0.3979, 0.5947]}, {"w": "eliminate", "b": [0.4053, 0.5733, 0.483, 0.5947]}, {"w": "the", "b": [0.4904, 0.5733, 0.5167, 0.5947]}, {"w": "unnecessary", "b": [0.5241, 0.5733, 0.6268, 0.5947]}, {"w": "clusters", "b": [0.6342, 0.5733, 0.6976, 0.5947]}, {"w": "automatically.", "b": [0.705, 0.5733, 0.8208, 0.5947]}, {"w": "For", "b": [0.8282, 0.5733, 0.8571, 0.5947]}, {"w": "example,", "b": [0.1429, 0.5924, 0.2171, 0.6138]}, {"w": "let’s", "b": [0.2219, 0.5924, 0.2521, 0.6138]}, {"w": "set", "b": [0.2568, 0.5924, 0.2797, 0.6138]}, {"w": "the", "b": [0.2844, 0.5924, 0.3108, 0.6138]}, {"w": "number", "b": [0.3155, 0.5924, 0.3818, 0.6138]}, {"w": "of", "b": [0.3865, 0.5924, 0.4033, 0.6138]}, {"w": "clusters", "b": [0.408, 0.5924, 0.4714, 0.6138]}, {"w": "to", "b": [0.4761, 0.5924, 0.4931, 0.6138]}, {"w": "10", "b": [0.4978, 0.5924, 0.5178, 0.6138]}, {"w": "and", "b": [0.5226, 0.5924, 0.5541, 0.6138]}, {"w": "see", "b": [0.5588, 0.5924, 0.5842, 0.6138]}, {"w": "what", "b": [0.5889, 0.5924, 0.6294, 0.6138]}, {"w": "happens:", "b": [0.6341, 0.5924, 0.7085, 0.6138]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> from sklearn.mixture import BayesianGaussianMixture >>> bgm = BayesianGaussianMixture(n_components=10, n_init=10, random_state=42) >>> bgm.fit(X) >>> np.round(bgm.weights_, 2) array([0.4 , 0.21, 0.4 , 0. , 0. , 0. , 0. , 0. , 0. , 0. ])", "words": [{"w": ">>>", "b": [0.1766, 0.6243, 0.2019, 0.6372]}, {"w": "from", "b": [0.2103, 0.6243, 0.2441, 0.6372]}, {"w": "sklearn.mixture", "b": [0.2525, 0.6243, 0.379, 0.6372]}, {"w": "import", "b": [0.3874, 0.6243, 0.438, 0.6372]}, {"w": "BayesianGaussianMixture", "b": [0.4464, 0.6243, 0.6404, 0.6372]}, {"w": ">>>", "b": [0.1766, 0.6398, 0.2019, 0.6526]}, {"w": "bgm", "b": [0.2103, 0.6398, 0.2356, 0.6526]}, {"w": "=", "b": [0.2441, 0.6398, 0.2525, 0.6526]}, {"w": "BayesianGaussianMixture(n_components=10,", "b": [0.2609, 0.6398, 0.5982, 0.6526]}, {"w": "n_init=10,", "b": [0.6067, 0.6398, 0.691, 0.6526]}, {"w": "random_state=42)", "b": [0.6994, 0.6398, 0.8343, 0.6526]}, {"w": ">>>", "b": [0.1766, 0.6552, 0.2019, 0.668]}, {"w": "bgm.fit(X)", "b": [0.2103, 0.6552, 0.2946, 0.668]}, {"w": ">>>", "b": [0.1766, 0.6706, 0.2019, 0.6834]}, {"w": "np.round(bgm.weights_,", "b": [0.2103, 0.6706, 0.3958, 0.6834]}, {"w": "2)", "b": [0.4043, 0.6706, 0.4211, 0.6834]}, {"w": "array([0.4", "b": [0.1766, 0.686, 0.2609, 0.6989]}, {"w": ",", "b": [0.2694, 0.686, 0.2778, 0.6989]}, {"w": "0.21,", "b": [0.2862, 0.686, 0.3284, 0.6989]}, {"w": "0.4", "b": [0.3368, 0.686, 0.3621, 0.6989]}, {"w": ",", "b": [0.3705, 0.686, 0.379, 0.6989]}, {"w": "0.", "b": [0.3874, 0.686, 0.4043, 0.6989]}, {"w": ",", "b": [0.4211, 0.686, 0.4296, 0.6989]}, {"w": "0.", "b": [0.438, 0.686, 0.4549, 0.6989]}, {"w": ",", "b": [0.4717, 0.686, 0.4802, 0.6989]}, {"w": "0.", "b": [0.4886, 0.686, 0.5055, 0.6989]}, {"w": ",", "b": [0.5223, 0.686, 0.5308, 0.6989]}, {"w": "0.", "b": [0.5392, 0.686, 0.5561, 0.6989]}, {"w": ",", "b": [0.5729, 0.686, 0.5814, 0.6989]}, {"w": "0.", "b": [0.5898, 0.686, 0.6067, 0.6989]}, {"w": ",", "b": [0.6235, 0.686, 0.632, 0.6989]}, {"w": "0.", "b": [0.6404, 0.686, 0.6572, 0.6989]}, {"w": ",", "b": [0.6741, 0.686, 0.6825, 0.6989]}, {"w": "0.", "b": [0.691, 0.686, 0.7078, 0.6989]}, {"w": "])", "b": [0.7247, 0.686, 0.7416, 0.6989]}]}, {"id": "b_6", "type": "paragraph", "text": "Perfect: the algorithm automatically detected that only 3 clusters are needed, and the resulting clusters are almost identical to the ones in Figure 9-17.", "words": [{"w": "Perfect:", "b": [0.1429, 0.7066, 0.2054, 0.7281]}, {"w": "the", "b": [0.2112, 0.7066, 0.2375, 0.7281]}, {"w": "algorithm", "b": [0.2433, 0.7066, 0.3259, 0.7281]}, {"w": "automatically", "b": [0.3317, 0.7066, 0.4443, 0.7281]}, {"w": "detected", "b": [0.45, 0.7066, 0.5201, 0.7281]}, {"w": "that", "b": [0.5258, 0.7066, 0.5584, 0.7281]}, {"w": "only", "b": [0.5642, 0.7066, 0.601, 0.7281]}, {"w": "3", "b": [0.6068, 0.7066, 0.6168, 0.7281]}, {"w": "clusters", "b": [0.6225, 0.7066, 0.6859, 0.7281]}, {"w": "are", "b": [0.6916, 0.7066, 0.7173, 0.7281]}, {"w": "needed,", "b": [0.7231, 0.7066, 0.7878, 0.7281]}, {"w": "and", "b": [0.7935, 0.7066, 0.8251, 0.7281]}, {"w": "the", "b": [0.8308, 0.7066, 0.8572, 0.7281]}, {"w": "resulting", "b": [0.1429, 0.7257, 0.2165, 0.7471]}, {"w": "clusters", "b": [0.2212, 0.7257, 0.2846, 0.7471]}, {"w": "are", "b": [0.2893, 0.7257, 0.3151, 0.7471]}, {"w": "almost", "b": [0.3198, 0.7257, 0.3759, 0.7471]}, {"w": "identical", "b": [0.3806, 0.7257, 0.4522, 0.7471]}, {"w": "to", "b": [0.457, 0.7257, 0.4739, 0.7471]}, {"w": "the", "b": [0.4787, 0.7257, 0.505, 0.7471]}, {"w": "ones", "b": [0.5097, 0.7257, 0.5483, 0.7471]}, {"w": "in", "b": [0.553, 0.7257, 0.57, 0.7471]}, {"w": "Figure", "b": [0.5747, 0.7257, 0.6287, 0.7471]}, {"w": "9-17.", "b": [0.6334, 0.7257, 0.6756, 0.7471]}]}, {"id": "b_7", "type": "paragraph", "text": "In this model, the cluster parameters (including the weights, means and covariance matrices) are not treated as fixed model parameters anymore, but as latent random variables, like the cluster assignments (see Figure 9-22). So z now includes both the cluster parameters and the cluster assignments.", "words": [{"w": "In", "b": [0.1429, 0.7538, 0.1614, 0.7752]}, {"w": "this", "b": [0.1682, 0.7538, 0.1989, 0.7752]}, {"w": "model,", "b": [0.2058, 0.7538, 0.2633, 0.7752]}, {"w": "the", "b": [0.2702, 0.7538, 0.2965, 0.7752]}, {"w": "cluster", "b": [0.3033, 0.7538, 0.3591, 0.7752]}, {"w": "parameters", "b": [0.3659, 0.7538, 0.4594, 0.7752]}, {"w": "(including", "b": [0.4662, 0.7538, 0.5533, 0.7752]}, {"w": "the", "b": [0.5601, 0.7538, 0.5864, 0.7752]}, {"w": "weights,", "b": [0.5933, 0.7538, 0.6612, 0.7752]}, {"w": "means", "b": [0.6681, 0.7538, 0.7222, 0.7752]}, {"w": "and", "b": [0.729, 0.7538, 0.7606, 0.7752]}, {"w": "covariance", "b": [0.7674, 0.7538, 0.8571, 0.7752]}, {"w": "matrices)", "b": [0.1429, 0.7729, 0.2209, 0.7943]}, {"w": "are", "b": [0.2278, 0.7729, 0.2535, 0.7943]}, {"w": "not", "b": [0.2604, 0.7729, 0.2888, 0.7943]}, {"w": "treated", "b": [0.2957, 0.7729, 0.3536, 0.7943]}, {"w": "as", "b": [0.3605, 0.7729, 0.3773, 0.7943]}, {"w": "fixed", "b": [0.3842, 0.7729, 0.4256, 0.7943]}, {"w": "model", "b": [0.4325, 0.7729, 0.4853, 0.7943]}, {"w": "parameters", "b": [0.4922, 0.7729, 0.5857, 0.7943]}, {"w": "anymore,", "b": [0.5926, 0.7729, 0.6712, 0.7943]}, {"w": "but", "b": [0.6781, 0.7729, 0.7061, 0.7943]}, {"w": "as", "b": [0.713, 0.7729, 0.7298, 0.7943]}, {"w": "latent", "b": [0.7367, 0.7729, 0.7833, 0.7943]}, {"w": "random", "b": [0.7902, 0.7729, 0.8571, 0.7943]}, {"w": "variables,", "b": [0.1428, 0.7919, 0.2212, 0.8133]}, {"w": "like", "b": [0.2277, 0.7919, 0.2578, 0.8133]}, {"w": "the", "b": [0.2643, 0.7919, 0.2907, 0.8133]}, {"w": "cluster", "b": [0.2972, 0.7919, 0.3529, 0.8133]}, {"w": "assignments", "b": [0.3595, 0.7919, 0.4616, 0.8133]}, {"w": "(see", "b": [0.4681, 0.7919, 0.5007, 0.8133]}, {"w": "Figure", "b": [0.5072, 0.7919, 0.5612, 0.8133]}, {"w": "9-22).", "b": [0.5678, 0.7919, 0.6172, 0.8133]}, {"w": "So", "b": [0.6237, 0.7919, 0.6442, 0.8133]}, {"w": "z", "b": [0.6507, 0.7913, 0.66, 0.8133]}, {"w": "now", "b": [0.6666, 0.7919, 0.7029, 0.8133]}, {"w": "includes", "b": [0.7094, 0.7919, 0.779, 0.8133]}, {"w": "both", "b": [0.7856, 0.7919, 0.8243, 0.8133]}, {"w": "the", "b": [0.8308, 0.7919, 0.8571, 0.8133]}, {"w": "cluster", "b": [0.1429, 0.811, 0.1986, 0.8324]}, {"w": "parameters", "b": [0.2033, 0.811, 0.2968, 0.8324]}, {"w": "and", "b": [0.3015, 0.811, 0.333, 0.8324]}, {"w": "the", "b": [0.3378, 0.811, 0.3641, 0.8324]}, {"w": "cluster", "b": [0.3688, 0.811, 0.4246, 0.8324]}, {"w": "assignments.", "b": [0.4293, 0.811, 0.5361, 0.8324]}]}, {"id": "b_8", "type": "paragraph", "text": "270 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "270", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2645, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 297, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 9-22. Bayesian Gaussian mixture model", "words": [{"w": "Figure", "b": [0.1429, 0.307, 0.1943, 0.3286]}, {"w": "9-22.", "b": [0.1991, 0.307, 0.2407, 0.3286]}, {"w": "Bayesian", "b": [0.2455, 0.307, 0.318, 0.3286]}, {"w": "Gaussian", "b": [0.3228, 0.307, 0.3983, 0.3286]}, {"w": "mixture", "b": [0.4031, 0.307, 0.4673, 0.3286]}, {"w": "model", "b": [0.472, 0.307, 0.5217, 0.3286]}]}, {"id": "b_1", "type": "paragraph", "text": "Prior knowledge about the latent variables z can be encoded in a probability distribu‐ tion p(z) called the prior. For example, we may have a prior belief that the clusters are likely to be few (low concentration), or conversely, that they are more likely to be plentiful (high concentration). This can be adjusted using the weight_concentra tion_prior hyperparameter. Setting it to 0.01 or 1000 gives very different clusterings (see Figure 9-23). However, the more data we have, the less the priors matter. In fact, to plot diagrams with such large differences, you must use very strong priors and lit‐ tle data.", "words": [{"w": "Prior", "b": [0.1429, 0.3443, 0.1863, 0.3658]}, {"w": "knowledge", "b": [0.1914, 0.3443, 0.2817, 0.3658]}, {"w": "about", "b": [0.2869, 0.3443, 0.3346, 0.3658]}, {"w": "the", "b": [0.3398, 0.3443, 0.3661, 0.3658]}, {"w": "latent", "b": [0.3712, 0.3443, 0.4178, 0.3658]}, {"w": "variables", "b": [0.4229, 0.3443, 0.4965, 0.3658]}, {"w": "z", "b": [0.5016, 0.3438, 0.5109, 0.3658]}, {"w": "can", "b": [0.516, 0.3443, 0.5454, 0.3658]}, {"w": "be", "b": [0.5505, 0.3443, 0.57, 0.3658]}, {"w": "encoded", "b": [0.5751, 0.3443, 0.6456, 0.3658]}, {"w": "in", "b": [0.6507, 0.3443, 0.6677, 0.3658]}, {"w": "a", "b": [0.6729, 0.3443, 0.682, 0.3658]}, {"w": "probability", "b": [0.6871, 0.3443, 0.7791, 0.3658]}, {"w": "distribu‐", "b": [0.7842, 0.3443, 0.8571, 0.3658]}, {"w": "tion", "b": [0.1429, 0.3634, 0.1768, 0.3848]}, {"w": "p(z)", "b": [0.1819, 0.3628, 0.2157, 0.3848]}, {"w": "called", "b": [0.2208, 0.3634, 0.2691, 0.3848]}, {"w": "the", "b": [0.2742, 0.3634, 0.3006, 0.3848]}, {"w": "prior.", "b": [0.3056, 0.3632, 0.3509, 0.3848]}, {"w": "For", "b": [0.356, 0.3634, 0.385, 0.3848]}, {"w": "example,", "b": [0.3901, 0.3634, 0.4644, 0.3848]}, {"w": "we", "b": [0.4694, 0.3634, 0.4926, 0.3848]}, {"w": "may", "b": [0.4976, 0.3634, 0.533, 0.3848]}, {"w": "have", "b": [0.5381, 0.3634, 0.5765, 0.3848]}, {"w": "a", "b": [0.5816, 0.3634, 0.5907, 0.3848]}, {"w": "prior", "b": [0.5958, 0.3634, 0.6384, 0.3848]}, {"w": "belief", "b": [0.6435, 0.3634, 0.6888, 0.3848]}, {"w": "that", "b": [0.6939, 0.3634, 0.7265, 0.3848]}, {"w": "the", "b": [0.7315, 0.3634, 0.7579, 0.3848]}, {"w": "clusters", "b": [0.763, 0.3634, 0.8263, 0.3848]}, {"w": "are", "b": [0.8314, 0.3634, 0.8571, 0.3848]}, {"w": "likely", "b": [0.1428, 0.3824, 0.1877, 0.4039]}, {"w": "to", "b": [0.1955, 0.3824, 0.2125, 0.4039]}, {"w": "be", "b": [0.2202, 0.3824, 0.2397, 0.4039]}, {"w": "few", "b": [0.2475, 0.3824, 0.2767, 0.4039]}, {"w": "(low", "b": [0.2845, 0.3824, 0.3219, 0.4039]}, {"w": "concentration),", "b": [0.3297, 0.3824, 0.4579, 0.4039]}, {"w": "or", "b": [0.4657, 0.3824, 0.484, 0.4039]}, {"w": "conversely,", "b": [0.4918, 0.3824, 0.583, 0.4039]}, {"w": "that", "b": [0.5907, 0.3824, 0.6233, 0.4039]}, {"w": "they", "b": [0.6311, 0.3824, 0.667, 0.4039]}, {"w": "are", "b": [0.6748, 0.3824, 0.7005, 0.4039]}, {"w": "more", "b": [0.7083, 0.3824, 0.7525, 0.4039]}, {"w": "likely", "b": [0.7603, 0.3824, 0.8052, 0.4039]}, {"w": "to", "b": [0.8129, 0.3824, 0.8299, 0.4039]}, {"w": "be", "b": [0.8377, 0.3824, 0.8571, 0.4039]}, {"w": "plentiful", "b": [0.1429, 0.4024, 0.2133, 0.4238]}, {"w": "(high", "b": [0.2223, 0.4024, 0.2671, 0.4238]}, {"w": "concentration).", "b": [0.276, 0.4024, 0.4042, 0.4238]}, {"w": "This", "b": [0.4131, 0.4024, 0.4504, 0.4238]}, {"w": "can", "b": [0.4593, 0.4024, 0.4886, 0.4238]}, {"w": "be", "b": [0.4975, 0.4024, 0.517, 0.4238]}, {"w": "adjusted", "b": [0.5259, 0.4024, 0.5963, 0.4238]}, {"w": "using", "b": [0.6052, 0.4024, 0.6507, 0.4238]}, {"w": "the", "b": [0.6596, 0.4024, 0.6859, 0.4238]}, {"w": "weight_concentra", "b": [0.6948, 0.4056, 0.8532, 0.4206]}, {"w": "tion_prior", "b": [0.1429, 0.4255, 0.2418, 0.4406]}, {"w": "hyperparameter.", "b": [0.2471, 0.4223, 0.3841, 0.4437]}, {"w": "Setting", "b": [0.3894, 0.4223, 0.4476, 0.4437]}, {"w": "it", "b": [0.4529, 0.4223, 0.4648, 0.4437]}, {"w": "to", "b": [0.4701, 0.4223, 0.4871, 0.4437]}, {"w": "0.01", "b": [0.4924, 0.4223, 0.5272, 0.4437]}, {"w": "or", "b": [0.5325, 0.4223, 0.5509, 0.4437]}, {"w": "1000", "b": [0.5562, 0.4223, 0.5962, 0.4437]}, {"w": "gives", "b": [0.6015, 0.4223, 0.643, 0.4437]}, {"w": "very", "b": [0.6483, 0.4223, 0.6847, 0.4437]}, {"w": "different", "b": [0.69, 0.4223, 0.7617, 0.4437]}, {"w": "clusterings", "b": [0.767, 0.4223, 0.8571, 0.4437]}, {"w": "(see", "b": [0.1429, 0.4414, 0.1754, 0.4628]}, {"w": "Figure", "b": [0.1809, 0.4414, 0.2349, 0.4628]}, {"w": "9-23).", "b": [0.2405, 0.4414, 0.2898, 0.4628]}, {"w": "However,", "b": [0.2953, 0.4414, 0.3742, 0.4628]}, {"w": "the", "b": [0.3797, 0.4414, 0.4061, 0.4628]}, {"w": "more", "b": [0.4116, 0.4414, 0.4558, 0.4628]}, {"w": "data", "b": [0.4614, 0.4414, 0.4966, 0.4628]}, {"w": "we", "b": [0.5021, 0.4414, 0.5253, 0.4628]}, {"w": "have,", "b": [0.5308, 0.4414, 0.5739, 0.4628]}, {"w": "the", "b": [0.5794, 0.4414, 0.6058, 0.4628]}, {"w": "less", "b": [0.6113, 0.4414, 0.6407, 0.4628]}, {"w": "the", "b": [0.6462, 0.4414, 0.6726, 0.4628]}, {"w": "priors", "b": [0.6781, 0.4414, 0.7283, 0.4628]}, {"w": "matter.", "b": [0.7338, 0.4414, 0.7924, 0.4628]}, {"w": "In", "b": [0.7979, 0.4414, 0.8164, 0.4628]}, {"w": "fact,", "b": [0.8219, 0.4414, 0.8571, 0.4628]}, {"w": "to", "b": [0.1429, 0.4604, 0.1598, 0.4818]}, {"w": "plot", "b": [0.1654, 0.4604, 0.1986, 0.4818]}, {"w": "diagrams", "b": [0.2041, 0.4604, 0.2812, 0.4818]}, {"w": "with", "b": [0.2867, 0.4604, 0.3241, 0.4818]}, {"w": "such", "b": [0.3296, 0.4604, 0.3683, 0.4818]}, {"w": "large", "b": [0.3738, 0.4604, 0.4146, 0.4818]}, {"w": "differences,", "b": [0.4201, 0.4604, 0.5159, 0.4818]}, {"w": "you", "b": [0.5215, 0.4604, 0.5527, 0.4818]}, {"w": "must", "b": [0.5583, 0.4604, 0.6, 0.4818]}, {"w": "use", "b": [0.6055, 0.4604, 0.6331, 0.4818]}, {"w": "very", "b": [0.6387, 0.4604, 0.6751, 0.4818]}, {"w": "strong", "b": [0.6806, 0.4604, 0.7341, 0.4818]}, {"w": "priors", "b": [0.7397, 0.4604, 0.7899, 0.4818]}, {"w": "and", "b": [0.7954, 0.4604, 0.827, 0.4818]}, {"w": "lit‐", "b": [0.8325, 0.4604, 0.8572, 0.4818]}, {"w": "tle", "b": [0.1429, 0.4795, 0.1633, 0.5009]}, {"w": "data.", "b": [0.1681, 0.4795, 0.2081, 0.5009]}]}, {"id": "b_2", "type": "equation", "text": "Figure 9-23. Using different concentration priors", "words": [{"w": "Figure", "b": [0.1429, 0.6933, 0.1943, 0.715]}, {"w": "9-23.", "b": [0.1991, 0.6933, 0.2407, 0.715]}, {"w": "Using", "b": [0.2455, 0.6933, 0.2912, 0.715]}, {"w": "different", "b": [0.296, 0.6933, 0.3651, 0.715]}, {"w": "concentration", "b": [0.3698, 0.6933, 0.4806, 0.715]}, {"w": "priors", "b": [0.4854, 0.6933, 0.5329, 0.715]}]}, {"id": "b_3", "type": "paragraph", "text": "The fact that you see only 3 regions in the right plot although there are 4 centroids is not a bug: the weight of the top-right cluster is much larger than the weight of the lower-right cluster, so the prob‐ ability that any given point in this region belongs to the top-right cluster is greater than the probability that it belongs to the lower- right cluster, even near the lower-right cluster.", "words": [{"w": "The", "b": [0.2714, 0.7355, 0.3014, 0.7551]}, {"w": "fact", "b": [0.3062, 0.7355, 0.3341, 0.7551]}, {"w": "that", "b": [0.3388, 0.7355, 0.3686, 0.7551]}, {"w": "you", "b": [0.3733, 0.7355, 0.4019, 0.7551]}, {"w": "see", "b": [0.4067, 0.7355, 0.4299, 0.7551]}, {"w": "only", "b": [0.4346, 0.7355, 0.4683, 0.7551]}, {"w": "3", "b": [0.4731, 0.7355, 0.4822, 0.7551]}, {"w": "regions", "b": [0.487, 0.7355, 0.5433, 0.7551]}, {"w": "in", "b": [0.548, 0.7355, 0.5635, 0.7551]}, {"w": "the", "b": [0.5683, 0.7355, 0.5924, 0.7551]}, {"w": "right", "b": [0.5971, 0.7355, 0.6338, 0.7551]}, {"w": "plot", "b": [0.6386, 0.7355, 0.6689, 0.7551]}, {"w": "although", "b": [0.6737, 0.7355, 0.7417, 0.7551]}, {"w": "there", "b": [0.7465, 0.7355, 0.7857, 0.7551]}, {"w": "are", "b": [0.2714, 0.7529, 0.2949, 0.7725]}, {"w": "4", "b": [0.3015, 0.7529, 0.3106, 0.7725]}, {"w": "centroids", "b": [0.3171, 0.7529, 0.3881, 0.7725]}, {"w": "is", "b": [0.3946, 0.7529, 0.4067, 0.7725]}, {"w": "not", "b": [0.4133, 0.7529, 0.4392, 0.7725]}, {"w": "a", "b": [0.4457, 0.7529, 0.4541, 0.7725]}, {"w": "bug:", "b": [0.4606, 0.7529, 0.4937, 0.7725]}, {"w": "the", "b": [0.5002, 0.7529, 0.5243, 0.7725]}, {"w": "weight", "b": [0.5308, 0.7529, 0.5816, 0.7725]}, {"w": "of", "b": [0.5881, 0.7529, 0.6035, 0.7725]}, {"w": "the", "b": [0.61, 0.7529, 0.6341, 0.7725]}, {"w": "top-right", "b": [0.6406, 0.7529, 0.7096, 0.7725]}, {"w": "cluster", "b": [0.7161, 0.7529, 0.7671, 0.7725]}, {"w": "is", "b": [0.7736, 0.7529, 0.7857, 0.7725]}, {"w": "much", "b": [0.2714, 0.7703, 0.315, 0.7899]}, {"w": "larger", "b": [0.3199, 0.7703, 0.3642, 0.7899]}, {"w": "than", "b": [0.369, 0.7703, 0.4038, 0.7899]}, {"w": "the", "b": [0.4087, 0.7703, 0.4327, 0.7899]}, {"w": "weight", "b": [0.4376, 0.7703, 0.4884, 0.7899]}, {"w": "of", "b": [0.4933, 0.7703, 0.5086, 0.7899]}, {"w": "the", "b": [0.5135, 0.7703, 0.5375, 0.7899]}, {"w": "lower-right", "b": [0.5424, 0.7703, 0.6282, 0.7899]}, {"w": "cluster,", "b": [0.633, 0.7703, 0.6871, 0.7899]}, {"w": "so", "b": [0.692, 0.7703, 0.7087, 0.7899]}, {"w": "the", "b": [0.7136, 0.7703, 0.7376, 0.7899]}, {"w": "prob‐", "b": [0.7425, 0.7703, 0.7857, 0.7899]}, {"w": "ability", "b": [0.2714, 0.7877, 0.319, 0.8073]}, {"w": "that", "b": [0.3252, 0.7877, 0.355, 0.8073]}, {"w": "any", "b": [0.3611, 0.7877, 0.3882, 0.8073]}, {"w": "given", "b": [0.3944, 0.7877, 0.4357, 0.8073]}, {"w": "point", "b": [0.4419, 0.7877, 0.4825, 0.8073]}, {"w": "in", "b": [0.4887, 0.7877, 0.5042, 0.8073]}, {"w": "this", "b": [0.5104, 0.7877, 0.5384, 0.8073]}, {"w": "region", "b": [0.5446, 0.7877, 0.5939, 0.8073]}, {"w": "belongs", "b": [0.6001, 0.7877, 0.6587, 0.8073]}, {"w": "to", "b": [0.6648, 0.7877, 0.6804, 0.8073]}, {"w": "the", "b": [0.6865, 0.7877, 0.7106, 0.8073]}, {"w": "top-right", "b": [0.7167, 0.7877, 0.7857, 0.8073]}, {"w": "cluster", "b": [0.2714, 0.8052, 0.3224, 0.8247]}, {"w": "is", "b": [0.3285, 0.8052, 0.3406, 0.8247]}, {"w": "greater", "b": [0.3467, 0.8052, 0.3998, 0.8247]}, {"w": "than", "b": [0.4059, 0.8052, 0.4406, 0.8247]}, {"w": "the", "b": [0.4468, 0.8052, 0.4708, 0.8247]}, {"w": "probability", "b": [0.4769, 0.8052, 0.561, 0.8247]}, {"w": "that", "b": [0.5671, 0.8052, 0.5969, 0.8247]}, {"w": "it", "b": [0.603, 0.8052, 0.6139, 0.8247]}, {"w": "belongs", "b": [0.6201, 0.8052, 0.6787, 0.8247]}, {"w": "to", "b": [0.6848, 0.8052, 0.7003, 0.8247]}, {"w": "the", "b": [0.7065, 0.8052, 0.7305, 0.8247]}, {"w": "lower-", "b": [0.7367, 0.8052, 0.7857, 0.8247]}, {"w": "right", "b": [0.2714, 0.8226, 0.3081, 0.8421]}, {"w": "cluster,", "b": [0.3124, 0.8226, 0.3665, 0.8421]}, {"w": "even", "b": [0.3709, 0.8226, 0.4063, 0.8421]}, {"w": "near", "b": [0.4106, 0.8226, 0.4446, 0.8421]}, {"w": "the", "b": [0.4489, 0.8226, 0.473, 0.8421]}, {"w": "lower-right", "b": [0.4773, 0.8226, 0.5631, 0.8421]}, {"w": "cluster.", "b": [0.5674, 0.8226, 0.6215, 0.8421]}]}, {"id": "b_4", "type": "paragraph", "text": "Gaussian Mixtures | 271", "words": [{"w": "Gaussian", "b": [0.6892, 0.9225, 0.7415, 0.9388]}, {"w": "Mixtures", "b": [0.7443, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "271", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 298, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Bayes’ theorem (Equation 9-2) tells us how to update the probability distribution over the latent variables after we observe some data X. It computes the posterior distribu‐ tion p(z|X), which is the conditional probability of z given X.", "words": [{"w": "Bayes’", "b": [0.1429, 0.0791, 0.1937, 0.1005]}, {"w": "theorem", "b": [0.1985, 0.0791, 0.2691, 0.1005]}, {"w": "(Equation", "b": [0.2738, 0.0791, 0.3575, 0.1005]}, {"w": "9-2)", "b": [0.3622, 0.0791, 0.3969, 0.1005]}, {"w": "tells", "b": [0.4018, 0.0791, 0.4352, 0.1005]}, {"w": "us", "b": [0.44, 0.0791, 0.4587, 0.1005]}, {"w": "how", "b": [0.4636, 0.0791, 0.4996, 0.1005]}, {"w": "to", "b": [0.5044, 0.0791, 0.5214, 0.1005]}, {"w": "update", "b": [0.5262, 0.0791, 0.5832, 0.1005]}, {"w": "the", "b": [0.588, 0.0791, 0.6143, 0.1005]}, {"w": "probability", "b": [0.6192, 0.0791, 0.7111, 0.1005]}, {"w": "distribution", "b": [0.716, 0.0791, 0.8155, 0.1005]}, {"w": "over", "b": [0.8203, 0.0791, 0.8571, 0.1005]}, {"w": "the", "b": [0.1429, 0.0981, 0.1692, 0.1195]}, {"w": "latent", "b": [0.1752, 0.0981, 0.2218, 0.1195]}, {"w": "variables", "b": [0.2279, 0.0981, 0.3015, 0.1195]}, {"w": "after", "b": [0.3075, 0.0981, 0.3458, 0.1195]}, {"w": "we", "b": [0.3518, 0.0981, 0.375, 0.1195]}, {"w": "observe", "b": [0.381, 0.0981, 0.4456, 0.1195]}, {"w": "some", "b": [0.4516, 0.0981, 0.4958, 0.1195]}, {"w": "data", "b": [0.5018, 0.0981, 0.5371, 0.1195]}, {"w": "X.", "b": [0.5432, 0.0976, 0.5623, 0.1195]}, {"w": "It", "b": [0.5684, 0.0981, 0.581, 0.1195]}, {"w": "computes", "b": [0.5871, 0.0981, 0.668, 0.1195]}, {"w": "the", "b": [0.6741, 0.0981, 0.7004, 0.1195]}, {"w": "posterior", "b": [0.7065, 0.0979, 0.7781, 0.1195]}, {"w": "distribu‐", "b": [0.7842, 0.0981, 0.8571, 0.1195]}, {"w": "tion", "b": [0.1429, 0.1172, 0.1768, 0.1386]}, {"w": "p(z|X),", "b": [0.1815, 0.1166, 0.24, 0.1386]}, {"w": "which", "b": [0.2447, 0.1172, 0.2957, 0.1386]}, {"w": "is", "b": [0.3004, 0.1172, 0.3136, 0.1386]}, {"w": "the", "b": [0.3184, 0.1172, 0.3447, 0.1386]}, {"w": "conditional", "b": [0.3494, 0.1172, 0.4452, 0.1386]}, {"w": "probability", "b": [0.4499, 0.1172, 0.5419, 0.1386]}, {"w": "of", "b": [0.5466, 0.1172, 0.5634, 0.1386]}, {"w": "z", "b": [0.5681, 0.1166, 0.5774, 0.1386]}, {"w": "given", "b": [0.5821, 0.1172, 0.6273, 0.1386]}, {"w": "X.", "b": [0.6321, 0.1166, 0.6513, 0.1386]}]}, {"id": "b_1", "type": "equation", "text": "Equation 9-2. Bayes’ theorem", "words": [{"w": "Equation", "b": [0.1726, 0.1567, 0.2473, 0.1783]}, {"w": "9-2.", "b": [0.2521, 0.1567, 0.2838, 0.1783]}, {"w": "Bayes’", "b": [0.2886, 0.1567, 0.3382, 0.1783]}, {"w": "theorem", "b": [0.343, 0.1567, 0.4094, 0.1783]}]}, {"id": "b_2", "type": "equation", "text": "p z X = Posterior = Likelihood×Prior", "words": [{"w": "p", "b": [0.174, 0.1933, 0.1837, 0.2139]}, {"w": "z", "b": [0.1905, 0.193, 0.1993, 0.2139]}, {"w": "X", "b": [0.209, 0.193, 0.2227, 0.2139]}, {"w": "=", "b": [0.2351, 0.1935, 0.2466, 0.2139]}, {"w": "Posterior", "b": [0.2521, 0.1935, 0.3253, 0.2139]}, {"w": "=", "b": [0.3309, 0.1935, 0.3424, 0.2139]}, {"w": "Likelihood×Prior", "b": [0.3545, 0.1847, 0.4932, 0.2051]}]}, {"id": "b_3", "type": "equation", "text": "Evidence = p X z p z", "words": [{"w": "Evidence", "b": [0.3877, 0.2023, 0.46, 0.2227]}, {"w": "=", "b": [0.5054, 0.1935, 0.5169, 0.2139]}, {"w": "p", "b": [0.526, 0.1845, 0.5356, 0.2051]}, {"w": "X", "b": [0.5425, 0.1841, 0.5562, 0.2051]}, {"w": "z", "b": [0.5659, 0.1841, 0.5747, 0.2051]}, {"w": "p", "b": [0.5863, 0.1845, 0.5959, 0.2051]}, {"w": "z", "b": [0.6028, 0.1841, 0.6116, 0.2051]}]}, {"id": "b_4", "type": "paragraph", "text": "p X", "words": [{"w": "p", "b": [0.5537, 0.2021, 0.5633, 0.2227]}, {"w": "X", "b": [0.5702, 0.2018, 0.5839, 0.2227]}]}, {"id": "b_5", "type": "paragraph", "text": "Unfortunately, in a Gaussian mixture model (and many other problems), the denomi‐ nator p(x) is intractable, as it requires integrating over all the possible values of z (Equation 9-3). This means considering all possible combinations of cluster parame‐ ters and cluster assignments.", "words": [{"w": "Unfortunately,", "b": [0.1429, 0.2415, 0.264, 0.2629]}, {"w": "in", "b": [0.2688, 0.2415, 0.2858, 0.2629]}, {"w": "a", "b": [0.2905, 0.2415, 0.2996, 0.2629]}, {"w": "Gaussian", "b": [0.3044, 0.2415, 0.3805, 0.2629]}, {"w": "mixture", "b": [0.3852, 0.2415, 0.4517, 0.2629]}, {"w": "model", "b": [0.4564, 0.2415, 0.5092, 0.2629]}, {"w": "(and", "b": [0.514, 0.2415, 0.5527, 0.2629]}, {"w": "many", "b": [0.5574, 0.2415, 0.6041, 0.2629]}, {"w": "other", "b": [0.6089, 0.2415, 0.6535, 0.2629]}, {"w": "problems),", "b": [0.6583, 0.2415, 0.7489, 0.2629]}, {"w": "the", "b": [0.7536, 0.2415, 0.78, 0.2629]}, {"w": "denomi‐", "b": [0.7847, 0.2415, 0.8566, 0.2629]}, {"w": "nator", "b": [0.1429, 0.2605, 0.1877, 0.2819]}, {"w": "p(x)", "b": [0.1957, 0.26, 0.2303, 0.2819]}, {"w": "is", "b": [0.2384, 0.2605, 0.2516, 0.2819]}, {"w": "intractable,", "b": [0.2596, 0.2605, 0.3532, 0.2819]}, {"w": "as", "b": [0.3612, 0.2605, 0.378, 0.2819]}, {"w": "it", "b": [0.386, 0.2605, 0.398, 0.2819]}, {"w": "requires", "b": [0.406, 0.2605, 0.4741, 0.2819]}, {"w": "integrating", "b": [0.4821, 0.2605, 0.5732, 0.2819]}, {"w": "over", "b": [0.5813, 0.2605, 0.6181, 0.2819]}, {"w": "all", "b": [0.6262, 0.2605, 0.6458, 0.2819]}, {"w": "the", "b": [0.6539, 0.2605, 0.6802, 0.2819]}, {"w": "possible", "b": [0.6882, 0.2605, 0.7554, 0.2819]}, {"w": "values", "b": [0.7634, 0.2605, 0.815, 0.2819]}, {"w": "of", "b": [0.823, 0.2605, 0.8398, 0.2819]}, {"w": "z", "b": [0.8479, 0.26, 0.8571, 0.2819]}, {"w": "(Equation", "b": [0.1428, 0.2796, 0.2263, 0.301]}, {"w": "9-3).", "b": [0.2321, 0.2796, 0.2715, 0.301]}, {"w": "This", "b": [0.2772, 0.2796, 0.3144, 0.301]}, {"w": "means", "b": [0.3202, 0.2796, 0.3743, 0.301]}, {"w": "considering", "b": [0.3801, 0.2796, 0.4785, 0.301]}, {"w": "all", "b": [0.4842, 0.2796, 0.5039, 0.301]}, {"w": "possible", "b": [0.5097, 0.2796, 0.5768, 0.301]}, {"w": "combinations", "b": [0.5826, 0.2796, 0.697, 0.301]}, {"w": "of", "b": [0.7028, 0.2796, 0.7196, 0.301]}, {"w": "cluster", "b": [0.7254, 0.2796, 0.7811, 0.301]}, {"w": "parame‐", "b": [0.7869, 0.2796, 0.8571, 0.301]}, {"w": "ters", "b": [0.1429, 0.2986, 0.1734, 0.32]}, {"w": "and", "b": [0.1782, 0.2986, 0.2097, 0.32]}, {"w": "cluster", "b": [0.2144, 0.2986, 0.2702, 0.32]}, {"w": "assignments.", "b": [0.2749, 0.2986, 0.3817, 0.32]}]}, {"id": "b_6", "type": "equation", "text": "Equation 9-3. The evidence p(X) is often intractable", "words": [{"w": "Equation", "b": [0.1726, 0.3382, 0.2473, 0.3598]}, {"w": "9-3.", "b": [0.2521, 0.3382, 0.2838, 0.3598]}, {"w": "The", "b": [0.2886, 0.3382, 0.3184, 0.3598]}, {"w": "evidence", "b": [0.3232, 0.3382, 0.3927, 0.3598]}, {"w": "p(X)", "b": [0.3975, 0.3377, 0.4349, 0.3598]}, {"w": "is", "b": [0.4397, 0.3382, 0.4525, 0.3598]}, {"w": "often", "b": [0.4573, 0.3382, 0.4983, 0.3598]}, {"w": "intractable", "b": [0.5031, 0.3382, 0.5899, 0.3598]}]}, {"id": "b_7", "type": "equation", "text": "p X =∫p X z p z dz", "words": [{"w": "p", "b": [0.174, 0.3755, 0.1837, 0.3961]}, {"w": "X", "b": [0.1905, 0.3752, 0.2043, 0.3961]}, {"w": "=∫p", "b": [0.2166, 0.3642, 0.2607, 0.405]}, {"w": "X", "b": [0.2675, 0.3752, 0.2813, 0.3961]}, {"w": "z", "b": [0.2909, 0.3752, 0.2997, 0.3961]}, {"w": "p", "b": [0.308, 0.3755, 0.3176, 0.3961]}, {"w": "z", "b": [0.3245, 0.3752, 0.3333, 0.3961]}, {"w": "dz", "b": [0.3402, 0.3752, 0.3594, 0.3961]}]}, {"id": "b_8", "type": "paragraph", "text": "This is one of the central problems in Bayesian statistics, and there are several approaches to solving it. One of them is variational inference, which picks a family of distributions q(z; λ) with its own variational parameters λ (lambda), then it optimizes these parameters to make q(z) a good approximation of p(z|X). This is achieved by finding the value of λ that minimizes the KL divergence from q(z) to p(z|X), noted DKL(q‖p). The KL divergence equation is shown in (see Equation 9-4), and it can be rewritten as the log of the evidence (log p(X)) minus the evidence lower bound (ELBO). Since the log of the evidence does not depend on q, it is a constant term, so minimizing the KL divergence just requires maximizing the ELBO.", "words": [{"w": "This", "b": [0.1429, 0.4244, 0.1801, 0.4458]}, {"w": "is", "b": [0.1901, 0.4244, 0.2034, 0.4458]}, {"w": "one", "b": [0.2134, 0.4244, 0.2443, 0.4458]}, {"w": "of", "b": [0.2544, 0.4244, 0.2712, 0.4458]}, {"w": "the", "b": [0.2813, 0.4244, 0.3076, 0.4458]}, {"w": "central", "b": [0.3177, 0.4244, 0.3748, 0.4458]}, {"w": "problems", "b": [0.3849, 0.4244, 0.4636, 0.4458]}, {"w": "in", "b": [0.4737, 0.4244, 0.4907, 0.4458]}, {"w": "Bayesian", "b": [0.5007, 0.4244, 0.5739, 0.4458]}, {"w": "statistics,", "b": [0.584, 0.4244, 0.6595, 0.4458]}, {"w": "and", "b": [0.6696, 0.4244, 0.7011, 0.4458]}, {"w": "there", "b": [0.7112, 0.4244, 0.7541, 0.4458]}, {"w": "are", "b": [0.7642, 0.4244, 0.7899, 0.4458]}, {"w": "several", "b": [0.8, 0.4244, 0.8571, 0.4458]}, {"w": "approaches", "b": [0.1428, 0.4435, 0.2374, 0.4649]}, {"w": "to", "b": [0.2428, 0.4435, 0.2598, 0.4649]}, {"w": "solving", "b": [0.2653, 0.4435, 0.3252, 0.4649]}, {"w": "it.", "b": [0.3307, 0.4435, 0.3474, 0.4649]}, {"w": "One", "b": [0.3529, 0.4435, 0.3887, 0.4649]}, {"w": "of", "b": [0.3942, 0.4435, 0.411, 0.4649]}, {"w": "them", "b": [0.4164, 0.4435, 0.4598, 0.4649]}, {"w": "is", "b": [0.4653, 0.4435, 0.4786, 0.4649]}, {"w": "variational", "b": [0.484, 0.4433, 0.5738, 0.4649]}, {"w": "inference,", "b": [0.5793, 0.4433, 0.6568, 0.4649]}, {"w": "which", "b": [0.6623, 0.4435, 0.7132, 0.4649]}, {"w": "picks", "b": [0.7187, 0.4435, 0.762, 0.4649]}, {"w": "a", "b": [0.7674, 0.4435, 0.7766, 0.4649]}, {"w": "family", "b": [0.7821, 0.4435, 0.8349, 0.4649]}, {"w": "of", "b": [0.8403, 0.4435, 0.8571, 0.4649]}, {"w": "distributions", "b": [0.1429, 0.4625, 0.25, 0.4839]}, {"w": "q(z;", "b": [0.2551, 0.462, 0.2864, 0.4839]}, {"w": "λ)", "b": [0.2915, 0.462, 0.3094, 0.4839]}, {"w": "with", "b": [0.3145, 0.4625, 0.3518, 0.4839]}, {"w": "its", "b": [0.357, 0.4625, 0.3765, 0.4839]}, {"w": "own", "b": [0.3816, 0.4625, 0.4179, 0.4839]}, {"w": "variational", "b": [0.423, 0.4623, 0.5128, 0.4839]}, {"w": "parameters", "b": [0.5176, 0.4623, 0.6081, 0.4839]}, {"w": "λ", "b": [0.6136, 0.462, 0.6243, 0.4839]}, {"w": "(lambda),", "b": [0.6294, 0.4625, 0.7108, 0.4839]}, {"w": "then", "b": [0.7159, 0.4625, 0.7536, 0.4839]}, {"w": "it", "b": [0.7587, 0.4625, 0.7707, 0.4839]}, {"w": "optimizes", "b": [0.7758, 0.4625, 0.8571, 0.4839]}, {"w": "these", "b": [0.1429, 0.4816, 0.1857, 0.503]}, {"w": "parameters", "b": [0.1924, 0.4816, 0.2859, 0.503]}, {"w": "to", "b": [0.2926, 0.4816, 0.3096, 0.503]}, {"w": "make", "b": [0.3163, 0.4816, 0.3617, 0.503]}, {"w": "q(z)", "b": [0.3685, 0.481, 0.4023, 0.503]}, {"w": "a", "b": [0.409, 0.4816, 0.4182, 0.503]}, {"w": "good", "b": [0.4249, 0.4816, 0.4669, 0.503]}, {"w": "approximation", "b": [0.4737, 0.4816, 0.5978, 0.503]}, {"w": "of", "b": [0.6045, 0.4816, 0.6213, 0.503]}, {"w": "p(z|X).", "b": [0.6281, 0.481, 0.6865, 0.503]}, {"w": "This", "b": [0.6933, 0.4816, 0.7305, 0.503]}, {"w": "is", "b": [0.7372, 0.4816, 0.7505, 0.503]}, {"w": "achieved", "b": [0.7572, 0.4816, 0.8302, 0.503]}, {"w": "by", "b": [0.837, 0.4816, 0.8571, 0.503]}, {"w": "finding", "b": [0.1428, 0.5006, 0.2037, 0.522]}, {"w": "the", "b": [0.2105, 0.5006, 0.2368, 0.522]}, {"w": "value", "b": [0.2435, 0.5006, 0.2875, 0.522]}, {"w": "of", "b": [0.2943, 0.5006, 0.3111, 0.522]}, {"w": "λ", "b": [0.3178, 0.5001, 0.3285, 0.522]}, {"w": "that", "b": [0.3352, 0.5006, 0.3678, 0.522]}, {"w": "minimizes", "b": [0.3746, 0.5006, 0.4621, 0.522]}, {"w": "the", "b": [0.4688, 0.5006, 0.4952, 0.522]}, {"w": "KL", "b": [0.5019, 0.5006, 0.5271, 0.522]}, {"w": "divergence", "b": [0.5339, 0.5006, 0.6244, 0.522]}, {"w": "from", "b": [0.6311, 0.5006, 0.6727, 0.522]}, {"w": "q(z)", "b": [0.6794, 0.5001, 0.7132, 0.522]}, {"w": "to", "b": [0.72, 0.5006, 0.7369, 0.522]}, {"w": "p(z|X),", "b": [0.7437, 0.5001, 0.8022, 0.522]}, {"w": "noted", "b": [0.8089, 0.5006, 0.8571, 0.522]}, {"w": "DKL(q‖p).", "b": [0.1429, 0.5195, 0.2207, 0.542]}, {"w": "The", "b": [0.2271, 0.5197, 0.2599, 0.5411]}, {"w": "KL", "b": [0.2662, 0.5197, 0.2915, 0.5411]}, {"w": "divergence", "b": [0.2978, 0.5197, 0.3883, 0.5411]}, {"w": "equation", "b": [0.3946, 0.5197, 0.4679, 0.5411]}, {"w": "is", "b": [0.4743, 0.5197, 0.4875, 0.5411]}, {"w": "shown", "b": [0.4938, 0.5197, 0.5489, 0.5411]}, {"w": "in", "b": [0.5553, 0.5197, 0.5722, 0.5411]}, {"w": "(see", "b": [0.5786, 0.5197, 0.6111, 0.5411]}, {"w": "Equation", "b": [0.6175, 0.5197, 0.6937, 0.5411]}, {"w": "9-4),", "b": [0.7001, 0.5197, 0.7395, 0.5411]}, {"w": "and", "b": [0.7458, 0.5197, 0.7774, 0.5411]}, {"w": "it", "b": [0.7837, 0.5197, 0.7956, 0.5411]}, {"w": "can", "b": [0.802, 0.5197, 0.8313, 0.5411]}, {"w": "be", "b": [0.8377, 0.5197, 0.8571, 0.5411]}, {"w": "rewritten", "b": [0.1429, 0.5387, 0.22, 0.5601]}, {"w": "as", "b": [0.2299, 0.5387, 0.2467, 0.5601]}, {"w": "the", "b": [0.2565, 0.5387, 0.2829, 0.5601]}, {"w": "log", "b": [0.2928, 0.5387, 0.3184, 0.5601]}, {"w": "of", "b": [0.3283, 0.5387, 0.3451, 0.5601]}, {"w": "the", "b": [0.355, 0.5387, 0.3813, 0.5601]}, {"w": "evidence", "b": [0.3912, 0.5387, 0.4642, 0.5601]}, {"w": "(log", "b": [0.4741, 0.5387, 0.5069, 0.5601]}, {"w": "p(X))", "b": [0.5168, 0.5382, 0.563, 0.5601]}, {"w": "minus", "b": [0.5729, 0.5387, 0.6252, 0.5601]}, {"w": "the", "b": [0.6351, 0.5387, 0.6615, 0.5601]}, {"w": "evidence", "b": [0.6713, 0.5385, 0.7409, 0.5601]}, {"w": "lower", "b": [0.7508, 0.5385, 0.7952, 0.5601]}, {"w": "bound", "b": [0.8052, 0.5385, 0.8571, 0.5601]}, {"w": "(ELBO).", "b": [0.1429, 0.5578, 0.2133, 0.5792]}, {"w": "Since", "b": [0.219, 0.5578, 0.2635, 0.5792]}, {"w": "the", "b": [0.2692, 0.5578, 0.2956, 0.5792]}, {"w": "log", "b": [0.3013, 0.5578, 0.3269, 0.5792]}, {"w": "of", "b": [0.3327, 0.5578, 0.3495, 0.5792]}, {"w": "the", "b": [0.3552, 0.5578, 0.3815, 0.5792]}, {"w": "evidence", "b": [0.3872, 0.5578, 0.4602, 0.5792]}, {"w": "does", "b": [0.4659, 0.5578, 0.5041, 0.5792]}, {"w": "not", "b": [0.5098, 0.5578, 0.5382, 0.5792]}, {"w": "depend", "b": [0.5439, 0.5578, 0.6059, 0.5792]}, {"w": "on", "b": [0.6116, 0.5578, 0.6336, 0.5792]}, {"w": "q,", "b": [0.6393, 0.5575, 0.6542, 0.5792]}, {"w": "it", "b": [0.6599, 0.5578, 0.6718, 0.5792]}, {"w": "is", "b": [0.6775, 0.5578, 0.6908, 0.5792]}, {"w": "a", "b": [0.6965, 0.5578, 0.7056, 0.5792]}, {"w": "constant", "b": [0.7114, 0.5578, 0.7827, 0.5792]}, {"w": "term,", "b": [0.7884, 0.5578, 0.8332, 0.5792]}, {"w": "so", "b": [0.8389, 0.5578, 0.8571, 0.5792]}, {"w": "minimizing", "b": [0.1428, 0.5768, 0.2406, 0.5982]}, {"w": "the", "b": [0.2453, 0.5768, 0.2717, 0.5982]}, {"w": "KL", "b": [0.2764, 0.5768, 0.3016, 0.5982]}, {"w": "divergence", "b": [0.3063, 0.5768, 0.3968, 0.5982]}, {"w": "just", "b": [0.4016, 0.5768, 0.432, 0.5982]}, {"w": "requires", "b": [0.4367, 0.5768, 0.5048, 0.5982]}, {"w": "maximizing", "b": [0.5095, 0.5768, 0.6093, 0.5982]}, {"w": "the", "b": [0.614, 0.5768, 0.6403, 0.5982]}, {"w": "ELBO.", "b": [0.6451, 0.5768, 0.7002, 0.5982]}]}, {"id": "b_9", "type": "equation", "text": "Equation 9-4. KL divergence from q(z) to p(z|X)", "words": [{"w": "Equation", "b": [0.1726, 0.6163, 0.2473, 0.638]}, {"w": "9-4.", "b": [0.2521, 0.6163, 0.2838, 0.638]}, {"w": "KL", "b": [0.2886, 0.6163, 0.3132, 0.638]}, {"w": "divergence", "b": [0.318, 0.6163, 0.4029, 0.638]}, {"w": "from", "b": [0.4077, 0.6163, 0.4467, 0.638]}, {"w": "q(z)", "b": [0.4515, 0.6159, 0.4842, 0.638]}, {"w": "to", "b": [0.4889, 0.6163, 0.5049, 0.638]}, {"w": "p(z|X)", "b": [0.5097, 0.6159, 0.5608, 0.638]}]}, {"id": "b_10", "type": "equation", "text": "DKL q ∥p = �q log q z p z X = �q log q z −log p z X", "words": [{"w": "DKL", "b": [0.1726, 0.6529, 0.2063, 0.6778]}, {"w": "q", "b": [0.2131, 0.6529, 0.2227, 0.6735]}, {"w": "∥p", "b": [0.2283, 0.6529, 0.2547, 0.6735]}, {"w": "=", "b": [0.2671, 0.6531, 0.2786, 0.6735]}, {"w": "�q", "b": [0.2906, 0.6562, 0.3122, 0.6769]}, {"w": "log", "b": [0.3246, 0.6531, 0.349, 0.6735]}, {"w": "q", "b": [0.3724, 0.6441, 0.382, 0.6647]}, {"w": "z", "b": [0.3889, 0.6438, 0.3977, 0.6647]}, {"w": "p", "b": [0.3581, 0.6618, 0.3677, 0.6823]}, {"w": "z", "b": [0.3746, 0.6614, 0.3834, 0.6823]}, {"w": "X", "b": [0.3997, 0.6614, 0.4134, 0.6823]}, {"w": "=", "b": [0.2671, 0.6846, 0.2786, 0.7049]}, {"w": "�q", "b": [0.2906, 0.6876, 0.3122, 0.7084]}, {"w": "log", "b": [0.3246, 0.6846, 0.349, 0.7049]}, {"w": "q", "b": [0.3545, 0.6844, 0.3641, 0.7049]}, {"w": "z", "b": [0.3709, 0.684, 0.3798, 0.7049]}, {"w": "−log", "b": [0.3911, 0.6846, 0.4369, 0.7049]}, {"w": "p", "b": [0.4438, 0.6844, 0.4534, 0.7049]}, {"w": "z", "b": [0.4603, 0.684, 0.4691, 0.7049]}, {"w": "X", "b": [0.4854, 0.684, 0.4991, 0.7049]}]}, {"id": "b_11", "type": "equation", "text": "= �q log q z −log p z, X", "words": [{"w": "=", "b": [0.2671, 0.7188, 0.2786, 0.7392]}, {"w": "�q", "b": [0.2906, 0.7219, 0.3122, 0.7426]}, {"w": "log", "b": [0.3246, 0.7188, 0.349, 0.7392]}, {"w": "q", "b": [0.3545, 0.7186, 0.3641, 0.7392]}, {"w": "z", "b": [0.3709, 0.7182, 0.3798, 0.7392]}, {"w": "−log", "b": [0.3911, 0.7188, 0.4369, 0.7392]}, {"w": "p", "b": [0.446, 0.7098, 0.4556, 0.7304]}, {"w": "z,", "b": [0.4625, 0.7094, 0.4759, 0.7304]}, {"w": "X", "b": [0.4792, 0.7094, 0.4929, 0.7304]}]}, {"id": "b_12", "type": "equation", "text": "p X = �q log q z −log p z, X + log p X", "words": [{"w": "p", "b": [0.4543, 0.7274, 0.464, 0.748]}, {"w": "X", "b": [0.4708, 0.7271, 0.4846, 0.748]}, {"w": "=", "b": [0.2671, 0.7502, 0.2786, 0.7706]}, {"w": "�q", "b": [0.2906, 0.7533, 0.3122, 0.774]}, {"w": "log", "b": [0.3246, 0.7502, 0.349, 0.7706]}, {"w": "q", "b": [0.3545, 0.75, 0.3641, 0.7706]}, {"w": "z", "b": [0.3709, 0.7497, 0.3798, 0.7706]}, {"w": "−log", "b": [0.3911, 0.7502, 0.4369, 0.7706]}, {"w": "p", "b": [0.4438, 0.75, 0.4534, 0.7706]}, {"w": "z,", "b": [0.4603, 0.7497, 0.4737, 0.7706]}, {"w": "X", "b": [0.477, 0.7497, 0.4907, 0.7706]}, {"w": "+", "b": [0.502, 0.7502, 0.5135, 0.7706]}, {"w": "log", "b": [0.5234, 0.7502, 0.5478, 0.7706]}, {"w": "p", "b": [0.5548, 0.75, 0.5644, 0.7706]}, {"w": "X", "b": [0.5713, 0.7497, 0.585, 0.7706]}]}, {"id": "b_13", "type": "equation", "text": "= �q log q z −�q log p z, X + �q log p X", "words": [{"w": "=", "b": [0.2671, 0.7765, 0.2786, 0.7969]}, {"w": "�q", "b": [0.2906, 0.7796, 0.3122, 0.8003]}, {"w": "log", "b": [0.3246, 0.7765, 0.349, 0.7969]}, {"w": "q", "b": [0.3545, 0.7763, 0.3641, 0.7969]}, {"w": "z", "b": [0.3709, 0.7759, 0.3798, 0.7969]}, {"w": "−�q", "b": [0.3979, 0.7765, 0.4354, 0.8003]}, {"w": "log", "b": [0.4478, 0.7765, 0.4722, 0.7969]}, {"w": "p", "b": [0.4791, 0.7763, 0.4887, 0.7969]}, {"w": "z,", "b": [0.4956, 0.7759, 0.5089, 0.7969]}, {"w": "X", "b": [0.5122, 0.7759, 0.526, 0.7969]}, {"w": "+", "b": [0.5441, 0.7765, 0.5556, 0.7969]}, {"w": "�q", "b": [0.56, 0.7796, 0.5816, 0.8003]}, {"w": "log", "b": [0.594, 0.7765, 0.6184, 0.7969]}, {"w": "p", "b": [0.6253, 0.7763, 0.6349, 0.7969]}, {"w": "X", "b": [0.6418, 0.7759, 0.6555, 0.7969]}]}, {"id": "b_14", "type": "equation", "text": "= �q log p X −�q log p z, X −�q log q z", "words": [{"w": "=", "b": [0.2671, 0.8053, 0.2786, 0.8257]}, {"w": "�q", "b": [0.2906, 0.8084, 0.3122, 0.8291]}, {"w": "log", "b": [0.3245, 0.8053, 0.349, 0.8257]}, {"w": "p", "b": [0.3592, 0.8051, 0.3688, 0.8257]}, {"w": "X", "b": [0.3757, 0.8047, 0.3894, 0.8257]}, {"w": "−�q", "b": [0.4076, 0.8053, 0.4519, 0.8291]}, {"w": "log", "b": [0.4643, 0.8053, 0.4887, 0.8257]}, {"w": "p", "b": [0.4989, 0.8051, 0.5085, 0.8257]}, {"w": "z,", "b": [0.5154, 0.8047, 0.5288, 0.8257]}, {"w": "X", "b": [0.5321, 0.8047, 0.5458, 0.8257]}, {"w": "−�q", "b": [0.5639, 0.8053, 0.6014, 0.8291]}, {"w": "log", "b": [0.6138, 0.8053, 0.6382, 0.8257]}, {"w": "q", "b": [0.647, 0.8051, 0.6566, 0.8257]}, {"w": "z", "b": [0.6635, 0.8047, 0.6723, 0.8257]}]}, {"id": "b_15", "type": "equation", "text": "= log p X −ELBO where ELBO = �q log p z, X −�q log q z", "words": [{"w": "=", "b": [0.2671, 0.8307, 0.2786, 0.8511]}, {"w": "log", "b": [0.2961, 0.8307, 0.3205, 0.8511]}, {"w": "p", "b": [0.3308, 0.8305, 0.3404, 0.8511]}, {"w": "X", "b": [0.3473, 0.8301, 0.361, 0.8511]}, {"w": "−ELBO", "b": [0.3723, 0.8307, 0.4366, 0.8511]}, {"w": "where", "b": [0.2873, 0.8533, 0.3357, 0.8737]}, {"w": "ELBO", "b": [0.3437, 0.8533, 0.3921, 0.8737]}, {"w": "=", "b": [0.3976, 0.8533, 0.4091, 0.8737]}, {"w": "�q", "b": [0.4146, 0.8564, 0.4362, 0.8771]}, {"w": "log", "b": [0.4486, 0.8533, 0.473, 0.8737]}, {"w": "p", "b": [0.4832, 0.8531, 0.4928, 0.8737]}, {"w": "z,", "b": [0.4997, 0.8527, 0.513, 0.8737]}, {"w": "X", "b": [0.5164, 0.8527, 0.5301, 0.8737]}, {"w": "−�q", "b": [0.5482, 0.8533, 0.5857, 0.8771]}, {"w": "log", "b": [0.5981, 0.8533, 0.6225, 0.8737]}, {"w": "q", "b": [0.6313, 0.8531, 0.6409, 0.8737]}, {"w": "z", "b": [0.6478, 0.8527, 0.6566, 0.8737]}]}, {"id": "b_16", "type": "paragraph", "text": "272 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "272", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 299, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "In practice, there are different techniques to maximize the ELBO. In mean field varia‐ tional inference, it is necessary to pick the family of distributions q(z; λ) and the prior p(z) very carefully to ensure that the equation for the ELBO simplifies to a form that can actually be computed. Unfortunately, there is no general way to do this, it depends on the task and requires some mathematical skills. For example, the distribu‐ tions and lower bound equations used in Scikit-Learn’s BayesianGaussianMixture class are presented in the documentation. From these equations it is possible to derive update equations for the cluster parameters and assignment variables: these are then used very much like in the Expectation-Maximization algorithm. In fact, the compu‐ tational complexity of the BayesianGaussianMixture class is similar to that of the GaussianMixture class (but generally significantly slower). A simpler approach to maximizing the ELBO is called black box stochastic variational inference (BBSVI): at each iteration, a few samples are drawn from q and they are used to estimate the gra‐ dients of the ELBO with regards to the variational parameters λ, which are then used in a gradient ascent step. This approach makes it possible to use Bayesian inference with any kind of model (provided it is differentiable), even deep neural networks: this is called Bayesian deep learning.", "words": [{"w": "In", "b": [0.1429, 0.0791, 0.1614, 0.1005]}, {"w": "practice,", "b": [0.1664, 0.0791, 0.2373, 0.1005]}, {"w": "there", "b": [0.2423, 0.0791, 0.2852, 0.1005]}, {"w": "are", "b": [0.2902, 0.0791, 0.3159, 0.1005]}, {"w": "different", "b": [0.3209, 0.0791, 0.3926, 0.1005]}, {"w": "techniques", "b": [0.3976, 0.0791, 0.488, 0.1005]}, {"w": "to", "b": [0.493, 0.0791, 0.5099, 0.1005]}, {"w": "maximize", "b": [0.5149, 0.0791, 0.5968, 0.1005]}, {"w": "the", "b": [0.6018, 0.0791, 0.6281, 0.1005]}, {"w": "ELBO.", "b": [0.6331, 0.0791, 0.6883, 0.1005]}, {"w": "In", "b": [0.6933, 0.0791, 0.7118, 0.1005]}, {"w": "mean", "b": [0.7168, 0.0789, 0.7622, 0.1005]}, {"w": "field", "b": [0.7673, 0.0789, 0.8024, 0.1005]}, {"w": "varia‐", "b": [0.8072, 0.0789, 0.8569, 0.1005]}, {"w": "tional", "b": [0.1429, 0.0979, 0.1904, 0.1195]}, {"w": "inference,", "b": [0.1951, 0.0979, 0.2731, 0.1195]}, {"w": "it", "b": [0.2783, 0.0981, 0.2903, 0.1195]}, {"w": "is", "b": [0.2955, 0.0981, 0.3087, 0.1195]}, {"w": "necessary", "b": [0.314, 0.0981, 0.3942, 0.1195]}, {"w": "to", "b": [0.3995, 0.0981, 0.4164, 0.1195]}, {"w": "pick", "b": [0.4217, 0.0981, 0.4573, 0.1195]}, {"w": "the", "b": [0.4626, 0.0981, 0.4889, 0.1195]}, {"w": "family", "b": [0.4941, 0.0981, 0.5469, 0.1195]}, {"w": "of", "b": [0.5521, 0.0981, 0.5689, 0.1195]}, {"w": "distributions", "b": [0.5742, 0.0981, 0.6813, 0.1195]}, {"w": "q(z;", "b": [0.6866, 0.0976, 0.7179, 0.1195]}, {"w": "λ)", "b": [0.7231, 0.0976, 0.741, 0.1195]}, {"w": "and", "b": [0.7462, 0.0981, 0.7778, 0.1195]}, {"w": "the", "b": [0.783, 0.0981, 0.8093, 0.1195]}, {"w": "prior", "b": [0.8146, 0.0981, 0.8571, 0.1195]}, {"w": "p(z)", "b": [0.1429, 0.117, 0.1761, 0.1386]}, {"w": "very", "b": [0.1818, 0.1172, 0.2182, 0.1386]}, {"w": "carefully", "b": [0.2239, 0.1172, 0.2958, 0.1386]}, {"w": "to", "b": [0.3015, 0.1172, 0.3185, 0.1386]}, {"w": "ensure", "b": [0.3242, 0.1172, 0.3798, 0.1386]}, {"w": "that", "b": [0.3855, 0.1172, 0.4181, 0.1386]}, {"w": "the", "b": [0.4238, 0.1172, 0.4501, 0.1386]}, {"w": "equation", "b": [0.4558, 0.1172, 0.5291, 0.1386]}, {"w": "for", "b": [0.5348, 0.1172, 0.5593, 0.1386]}, {"w": "the", "b": [0.5651, 0.1172, 0.5914, 0.1386]}, {"w": "ELBO", "b": [0.5971, 0.1172, 0.6484, 0.1386]}, {"w": "simplifies", "b": [0.6541, 0.1172, 0.734, 0.1386]}, {"w": "to", "b": [0.7397, 0.1172, 0.7567, 0.1386]}, {"w": "a", "b": [0.7624, 0.1172, 0.7716, 0.1386]}, {"w": "form", "b": [0.7773, 0.1172, 0.8189, 0.1386]}, {"w": "that", "b": [0.8246, 0.1172, 0.8572, 0.1386]}, {"w": "can", "b": [0.1429, 0.1362, 0.1722, 0.1576]}, {"w": "actually", "b": [0.1824, 0.1362, 0.2471, 0.1576]}, {"w": "be", "b": [0.2573, 0.1362, 0.2767, 0.1576]}, {"w": "computed.", "b": [0.2869, 0.1362, 0.376, 0.1576]}, {"w": "Unfortunately,", "b": [0.3862, 0.1362, 0.5074, 0.1576]}, {"w": "there", "b": [0.5176, 0.1362, 0.5605, 0.1576]}, {"w": "is", "b": [0.5707, 0.1362, 0.584, 0.1576]}, {"w": "no", "b": [0.5942, 0.1362, 0.6162, 0.1576]}, {"w": "general", "b": [0.6264, 0.1362, 0.6874, 0.1576]}, {"w": "way", "b": [0.6977, 0.1362, 0.7303, 0.1576]}, {"w": "to", "b": [0.7405, 0.1362, 0.7575, 0.1576]}, {"w": "do", "b": [0.7677, 0.1362, 0.7893, 0.1576]}, {"w": "this,", "b": [0.7995, 0.1362, 0.835, 0.1576]}, {"w": "it", "b": [0.8452, 0.1362, 0.8571, 0.1576]}, {"w": "depends", "b": [0.1429, 0.1553, 0.2125, 0.1767]}, {"w": "on", "b": [0.2173, 0.1553, 0.2393, 0.1767]}, {"w": "the", "b": [0.244, 0.1553, 0.2703, 0.1767]}, {"w": "task", "b": [0.2751, 0.1553, 0.3085, 0.1767]}, {"w": "and", "b": [0.3133, 0.1553, 0.3448, 0.1767]}, {"w": "requires", "b": [0.3495, 0.1553, 0.4176, 0.1767]}, {"w": "some", "b": [0.4224, 0.1553, 0.4666, 0.1767]}, {"w": "mathematical", "b": [0.4713, 0.1553, 0.5844, 0.1767]}, {"w": "skills.", "b": [0.5891, 0.1553, 0.6356, 0.1767]}, {"w": "For", "b": [0.6404, 0.1553, 0.6694, 0.1767]}, {"w": "example,", "b": [0.6741, 0.1553, 0.7484, 0.1767]}, {"w": "the", "b": [0.7531, 0.1553, 0.7794, 0.1767]}, {"w": "distribu‐", "b": [0.7842, 0.1553, 0.8571, 0.1767]}, {"w": "tions", "b": [0.1429, 0.1752, 0.1845, 0.1966]}, {"w": "and", "b": [0.1926, 0.1752, 0.2241, 0.1966]}, {"w": "lower", "b": [0.2322, 0.1752, 0.2789, 0.1966]}, {"w": "bound", "b": [0.287, 0.1752, 0.3417, 0.1966]}, {"w": "equations", "b": [0.3498, 0.1752, 0.4307, 0.1966]}, {"w": "used", "b": [0.4388, 0.1752, 0.4774, 0.1966]}, {"w": "in", "b": [0.4855, 0.1752, 0.5025, 0.1966]}, {"w": "Scikit-Learn’s", "b": [0.5105, 0.1752, 0.6214, 0.1966]}, {"w": "BayesianGaussianMixture", "b": [0.6295, 0.1784, 0.8571, 0.1935]}, {"w": "class", "b": [0.1429, 0.1942, 0.1814, 0.2157]}, {"w": "are", "b": [0.1861, 0.1942, 0.2118, 0.2157]}, {"w": "presented", "b": [0.2166, 0.1942, 0.2978, 0.2157]}, {"w": "in", "b": [0.3025, 0.1942, 0.3195, 0.2157]}, {"w": "the", "b": [0.3242, 0.1942, 0.3505, 0.2157]}, {"w": "documentation.", "b": [0.3555, 0.1942, 0.4878, 0.2157]}, {"w": "From", "b": [0.4925, 0.1942, 0.5389, 0.2157]}, {"w": "these", "b": [0.5437, 0.1942, 0.5865, 0.2157]}, {"w": "equations", "b": [0.5912, 0.1942, 0.6721, 0.2157]}, {"w": "it", "b": [0.6769, 0.1942, 0.6888, 0.2157]}, {"w": "is", "b": [0.6935, 0.1942, 0.7068, 0.2157]}, {"w": "possible", "b": [0.7115, 0.1942, 0.7786, 0.2157]}, {"w": "to", "b": [0.7834, 0.1942, 0.8003, 0.2157]}, {"w": "derive", "b": [0.8051, 0.1942, 0.8567, 0.2157]}, {"w": "update", "b": [0.1429, 0.2133, 0.1998, 0.2347]}, {"w": "equations", "b": [0.2058, 0.2133, 0.2867, 0.2347]}, {"w": "for", "b": [0.2927, 0.2133, 0.3172, 0.2347]}, {"w": "the", "b": [0.3232, 0.2133, 0.3495, 0.2347]}, {"w": "cluster", "b": [0.3555, 0.2133, 0.4112, 0.2347]}, {"w": "parameters", "b": [0.4172, 0.2133, 0.5106, 0.2347]}, {"w": "and", "b": [0.5166, 0.2133, 0.5482, 0.2347]}, {"w": "assignment", "b": [0.5541, 0.2133, 0.6486, 0.2347]}, {"w": "variables:", "b": [0.6545, 0.2133, 0.7329, 0.2347]}, {"w": "these", "b": [0.7389, 0.2133, 0.7817, 0.2347]}, {"w": "are", "b": [0.7877, 0.2133, 0.8134, 0.2347]}, {"w": "then", "b": [0.8194, 0.2133, 0.8571, 0.2347]}, {"w": "used", "b": [0.1429, 0.2323, 0.1814, 0.2538]}, {"w": "very", "b": [0.187, 0.2323, 0.2234, 0.2538]}, {"w": "much", "b": [0.2291, 0.2323, 0.2767, 0.2538]}, {"w": "like", "b": [0.2823, 0.2323, 0.3124, 0.2538]}, {"w": "in", "b": [0.318, 0.2323, 0.335, 0.2538]}, {"w": "the", "b": [0.3406, 0.2323, 0.3669, 0.2538]}, {"w": "Expectation-Maximization", "b": [0.3725, 0.2323, 0.5961, 0.2538]}, {"w": "algorithm.", "b": [0.6017, 0.2323, 0.6891, 0.2538]}, {"w": "In", "b": [0.6948, 0.2323, 0.7133, 0.2538]}, {"w": "fact,", "b": [0.7189, 0.2323, 0.7541, 0.2538]}, {"w": "the", "b": [0.7597, 0.2323, 0.786, 0.2538]}, {"w": "compu‐", "b": [0.7917, 0.2323, 0.8572, 0.2538]}, {"w": "tational", "b": [0.1429, 0.2523, 0.2063, 0.2737]}, {"w": "complexity", "b": [0.2141, 0.2523, 0.3066, 0.2737]}, {"w": "of", "b": [0.3143, 0.2523, 0.3311, 0.2737]}, {"w": "the", "b": [0.3388, 0.2523, 0.3652, 0.2737]}, {"w": "BayesianGaussianMixture", "b": [0.3729, 0.2555, 0.6005, 0.2705]}, {"w": "class", "b": [0.6082, 0.2523, 0.6468, 0.2737]}, {"w": "is", "b": [0.6545, 0.2523, 0.6677, 0.2737]}, {"w": "similar", "b": [0.6755, 0.2523, 0.7335, 0.2737]}, {"w": "to", "b": [0.7412, 0.2523, 0.7582, 0.2737]}, {"w": "that", "b": [0.766, 0.2523, 0.7985, 0.2737]}, {"w": "of", "b": [0.8063, 0.2523, 0.8231, 0.2737]}, {"w": "the", "b": [0.8308, 0.2523, 0.8571, 0.2737]}, {"w": "GaussianMixture", "b": [0.1429, 0.2754, 0.2913, 0.2905]}, {"w": "class", "b": [0.2997, 0.2722, 0.3383, 0.2936]}, {"w": "(but", "b": [0.3467, 0.2722, 0.3819, 0.2936]}, {"w": "generally", "b": [0.3904, 0.2722, 0.4662, 0.2936]}, {"w": "significantly", "b": [0.4746, 0.2722, 0.5765, 0.2936]}, {"w": "slower).", "b": [0.5849, 0.2722, 0.6513, 0.2936]}, {"w": "A", "b": [0.6597, 0.2722, 0.6741, 0.2936]}, {"w": "simpler", "b": [0.6826, 0.2722, 0.7453, 0.2936]}, {"w": "approach", "b": [0.7537, 0.2722, 0.8317, 0.2936]}, {"w": "to", "b": [0.8402, 0.2722, 0.8572, 0.2936]}, {"w": "maximizing", "b": [0.1429, 0.2913, 0.2426, 0.3127]}, {"w": "the", "b": [0.2492, 0.2913, 0.2756, 0.3127]}, {"w": "ELBO", "b": [0.2822, 0.2913, 0.3334, 0.3127]}, {"w": "is", "b": [0.34, 0.2913, 0.3533, 0.3127]}, {"w": "called", "b": [0.3599, 0.2913, 0.4082, 0.3127]}, {"w": "black", "b": [0.4148, 0.2911, 0.4574, 0.3127]}, {"w": "box", "b": [0.4641, 0.2911, 0.4934, 0.3127]}, {"w": "stochastic", "b": [0.5, 0.2911, 0.5777, 0.3127]}, {"w": "variational", "b": [0.5844, 0.2911, 0.6742, 0.3127]}, {"w": "inference", "b": [0.6808, 0.2911, 0.7535, 0.3127]}, {"w": "(BBSVI):", "b": [0.7601, 0.2913, 0.8354, 0.3127]}, {"w": "at", "b": [0.842, 0.2913, 0.8571, 0.3127]}, {"w": "each", "b": [0.1429, 0.3103, 0.1808, 0.3317]}, {"w": "iteration,", "b": [0.1862, 0.3103, 0.2622, 0.3317]}, {"w": "a", "b": [0.2676, 0.3103, 0.2768, 0.3317]}, {"w": "few", "b": [0.2822, 0.3103, 0.3115, 0.3317]}, {"w": "samples", "b": [0.3169, 0.3103, 0.383, 0.3317]}, {"w": "are", "b": [0.3884, 0.3103, 0.4142, 0.3317]}, {"w": "drawn", "b": [0.4196, 0.3103, 0.4728, 0.3317]}, {"w": "from", "b": [0.4782, 0.3103, 0.5198, 0.3317]}, {"w": "q", "b": [0.5252, 0.3101, 0.5353, 0.3317]}, {"w": "and", "b": [0.5407, 0.3103, 0.5722, 0.3317]}, {"w": "they", "b": [0.5776, 0.3103, 0.6135, 0.3317]}, {"w": "are", "b": [0.6189, 0.3103, 0.6447, 0.3317]}, {"w": "used", "b": [0.6501, 0.3103, 0.6887, 0.3317]}, {"w": "to", "b": [0.6941, 0.3103, 0.7111, 0.3317]}, {"w": "estimate", "b": [0.7165, 0.3103, 0.7859, 0.3317]}, {"w": "the", "b": [0.7913, 0.3103, 0.8177, 0.3317]}, {"w": "gra‐", "b": [0.8231, 0.3103, 0.8571, 0.3317]}, {"w": "dients", "b": [0.1429, 0.3294, 0.1933, 0.3508]}, {"w": "of", "b": [0.1987, 0.3294, 0.2155, 0.3508]}, {"w": "the", "b": [0.2209, 0.3294, 0.2473, 0.3508]}, {"w": "ELBO", "b": [0.2527, 0.3294, 0.304, 0.3508]}, {"w": "with", "b": [0.3094, 0.3294, 0.3467, 0.3508]}, {"w": "regards", "b": [0.3522, 0.3294, 0.414, 0.3508]}, {"w": "to", "b": [0.4194, 0.3294, 0.4364, 0.3508]}, {"w": "the", "b": [0.4418, 0.3294, 0.4682, 0.3508]}, {"w": "variational", "b": [0.4736, 0.3294, 0.5628, 0.3508]}, {"w": "parameters", "b": [0.5682, 0.3294, 0.6617, 0.3508]}, {"w": "λ,", "b": [0.6671, 0.3288, 0.6825, 0.3508]}, {"w": "which", "b": [0.6879, 0.3294, 0.7389, 0.3508]}, {"w": "are", "b": [0.7443, 0.3294, 0.77, 0.3508]}, {"w": "then", "b": [0.7754, 0.3294, 0.8132, 0.3508]}, {"w": "used", "b": [0.8186, 0.3294, 0.8572, 0.3508]}, {"w": "in", "b": [0.1429, 0.3484, 0.1598, 0.3698]}, {"w": "a", "b": [0.1665, 0.3484, 0.1756, 0.3698]}, {"w": "gradient", "b": [0.1823, 0.3484, 0.2517, 0.3698]}, {"w": "ascent", "b": [0.2583, 0.3484, 0.3101, 0.3698]}, {"w": "step.", "b": [0.3168, 0.3484, 0.3547, 0.3698]}, {"w": "This", "b": [0.3613, 0.3484, 0.3985, 0.3698]}, {"w": "approach", "b": [0.4052, 0.3484, 0.4832, 0.3698]}, {"w": "makes", "b": [0.4898, 0.3484, 0.5429, 0.3698]}, {"w": "it", "b": [0.5495, 0.3484, 0.5614, 0.3698]}, {"w": "possible", "b": [0.5681, 0.3484, 0.6352, 0.3698]}, {"w": "to", "b": [0.6418, 0.3484, 0.6588, 0.3698]}, {"w": "use", "b": [0.6655, 0.3484, 0.693, 0.3698]}, {"w": "Bayesian", "b": [0.6997, 0.3484, 0.7729, 0.3698]}, {"w": "inference", "b": [0.7795, 0.3484, 0.8571, 0.3698]}, {"w": "with", "b": [0.1429, 0.3675, 0.1802, 0.3889]}, {"w": "any", "b": [0.1851, 0.3675, 0.2147, 0.3889]}, {"w": "kind", "b": [0.2197, 0.3675, 0.258, 0.3889]}, {"w": "of", "b": [0.2629, 0.3675, 0.2797, 0.3889]}, {"w": "model", "b": [0.2846, 0.3675, 0.3374, 0.3889]}, {"w": "(provided", "b": [0.3424, 0.3675, 0.4249, 0.3889]}, {"w": "it", "b": [0.4299, 0.3675, 0.4418, 0.3889]}, {"w": "is", "b": [0.4467, 0.3675, 0.46, 0.3889]}, {"w": "differentiable),", "b": [0.4649, 0.3675, 0.588, 0.3889]}, {"w": "even", "b": [0.5929, 0.3675, 0.6317, 0.3889]}, {"w": "deep", "b": [0.6366, 0.3675, 0.6762, 0.3889]}, {"w": "neural", "b": [0.6812, 0.3675, 0.7346, 0.3889]}, {"w": "networks:", "b": [0.7395, 0.3675, 0.8215, 0.3889]}, {"w": "this", "b": [0.8264, 0.3675, 0.8571, 0.3889]}, {"w": "is", "b": [0.1428, 0.3865, 0.1561, 0.4079]}, {"w": "called", "b": [0.1608, 0.3865, 0.2092, 0.4079]}, {"w": "Bayesian", "b": [0.2139, 0.3865, 0.2871, 0.4079]}, {"w": "deep", "b": [0.2918, 0.3865, 0.3315, 0.4079]}, {"w": "learning.", "b": [0.3362, 0.3865, 0.4101, 0.4079]}]}, {"id": "b_1", "type": "paragraph", "text": "If you want to dive deeper into Bayesian statistics, check out the Bayesian Data Analysis book by Andrew Gelman, John Carlin, Hal Stern, David Dunson, Aki Vehtari, and Donald Rubin.", "words": [{"w": "If", "b": [0.2714, 0.4285, 0.2835, 0.448]}, {"w": "you", "b": [0.2906, 0.4285, 0.3191, 0.448]}, {"w": "want", "b": [0.3261, 0.4285, 0.3634, 0.448]}, {"w": "to", "b": [0.3704, 0.4285, 0.386, 0.448]}, {"w": "dive", "b": [0.393, 0.4285, 0.425, 0.448]}, {"w": "deeper", "b": [0.4321, 0.4285, 0.4835, 0.448]}, {"w": "into", "b": [0.4905, 0.4285, 0.5212, 0.448]}, {"w": "Bayesian", "b": [0.5282, 0.4285, 0.5951, 0.448]}, {"w": "statistics,", "b": [0.6021, 0.4285, 0.6711, 0.448]}, {"w": "check", "b": [0.6781, 0.4285, 0.722, 0.448]}, {"w": "out", "b": [0.729, 0.4285, 0.7546, 0.448]}, {"w": "the", "b": [0.7616, 0.4285, 0.7857, 0.448]}, {"w": "Bayesian", "b": [0.2714, 0.4457, 0.3377, 0.4654]}, {"w": "Data", "b": [0.343, 0.4457, 0.3806, 0.4654]}, {"w": "Analysis", "b": [0.3859, 0.4457, 0.4484, 0.4654]}, {"w": "book", "b": [0.4537, 0.4459, 0.4923, 0.4654]}, {"w": "by", "b": [0.4975, 0.4459, 0.516, 0.4654]}, {"w": "Andrew", "b": [0.5212, 0.4459, 0.5831, 0.4654]}, {"w": "Gelman,", "b": [0.5884, 0.4459, 0.6536, 0.4654]}, {"w": "John", "b": [0.6589, 0.4459, 0.6951, 0.4654]}, {"w": "Carlin,", "b": [0.7003, 0.4459, 0.7531, 0.4654]}, {"w": "Hal", "b": [0.7584, 0.4459, 0.7857, 0.4654]}, {"w": "Stern,", "b": [0.2714, 0.4633, 0.3162, 0.4829]}, {"w": "David", "b": [0.3205, 0.4633, 0.3665, 0.4829]}, {"w": "Dunson,", "b": [0.3708, 0.4633, 0.4368, 0.4829]}, {"w": "Aki", "b": [0.4411, 0.4633, 0.4689, 0.4829]}, {"w": "Vehtari,", "b": [0.4732, 0.4633, 0.5333, 0.4829]}, {"w": "and", "b": [0.5376, 0.4633, 0.5665, 0.4829]}, {"w": "Donald", "b": [0.5708, 0.4633, 0.6282, 0.4829]}, {"w": "Rubin.", "b": [0.6325, 0.4633, 0.6836, 0.4829]}]}, {"id": "b_2", "type": "paragraph", "text": "Gaussian mixture models work great on clusters with ellipsoidal shapes, but if you try to fit a dataset with different shapes, you may have bad surprises. For example, let’s see what happens if we use a Bayesian Gaussian mixture model to cluster the moons dataset (see Figure 9-24):", "words": [{"w": "Gaussian", "b": [0.1429, 0.5271, 0.219, 0.5485]}, {"w": "mixture", "b": [0.2239, 0.5271, 0.2904, 0.5485]}, {"w": "models", "b": [0.2953, 0.5271, 0.3558, 0.5485]}, {"w": "work", "b": [0.3607, 0.5271, 0.4036, 0.5485]}, {"w": "great", "b": [0.4086, 0.5271, 0.45, 0.5485]}, {"w": "on", "b": [0.4549, 0.5271, 0.4769, 0.5485]}, {"w": "clusters", "b": [0.4819, 0.5271, 0.5452, 0.5485]}, {"w": "with", "b": [0.5502, 0.5271, 0.5875, 0.5485]}, {"w": "ellipsoidal", "b": [0.5924, 0.5271, 0.6776, 0.5485]}, {"w": "shapes,", "b": [0.6825, 0.5271, 0.7422, 0.5485]}, {"w": "but", "b": [0.7471, 0.5271, 0.7751, 0.5485]}, {"w": "if", "b": [0.78, 0.5271, 0.7918, 0.5485]}, {"w": "you", "b": [0.7967, 0.5271, 0.828, 0.5485]}, {"w": "try", "b": [0.8329, 0.5271, 0.8571, 0.5485]}, {"w": "to", "b": [0.1429, 0.5462, 0.1598, 0.5676]}, {"w": "fit", "b": [0.1666, 0.5462, 0.1847, 0.5676]}, {"w": "a", "b": [0.1914, 0.5462, 0.2006, 0.5676]}, {"w": "dataset", "b": [0.2073, 0.5462, 0.2654, 0.5676]}, {"w": "with", "b": [0.2722, 0.5462, 0.3095, 0.5676]}, {"w": "different", "b": [0.3162, 0.5462, 0.388, 0.5676]}, {"w": "shapes,", "b": [0.3947, 0.5462, 0.4544, 0.5676]}, {"w": "you", "b": [0.4611, 0.5462, 0.4924, 0.5676]}, {"w": "may", "b": [0.4991, 0.5462, 0.5345, 0.5676]}, {"w": "have", "b": [0.5413, 0.5462, 0.5797, 0.5676]}, {"w": "bad", "b": [0.5864, 0.5462, 0.6171, 0.5676]}, {"w": "surprises.", "b": [0.6239, 0.5462, 0.7034, 0.5676]}, {"w": "For", "b": [0.7102, 0.5462, 0.7391, 0.5676]}, {"w": "example,", "b": [0.7459, 0.5462, 0.8202, 0.5676]}, {"w": "let’s", "b": [0.8269, 0.5462, 0.8572, 0.5676]}, {"w": "see", "b": [0.1429, 0.5652, 0.1682, 0.5866]}, {"w": "what", "b": [0.1741, 0.5652, 0.2146, 0.5866]}, {"w": "happens", "b": [0.2205, 0.5652, 0.2901, 0.5866]}, {"w": "if", "b": [0.2959, 0.5652, 0.3077, 0.5866]}, {"w": "we", "b": [0.3136, 0.5652, 0.3367, 0.5866]}, {"w": "use", "b": [0.3426, 0.5652, 0.3701, 0.5866]}, {"w": "a", "b": [0.376, 0.5652, 0.3851, 0.5866]}, {"w": "Bayesian", "b": [0.391, 0.5652, 0.4642, 0.5866]}, {"w": "Gaussian", "b": [0.4701, 0.5652, 0.5462, 0.5866]}, {"w": "mixture", "b": [0.5521, 0.5652, 0.6186, 0.5866]}, {"w": "model", "b": [0.6244, 0.5652, 0.6773, 0.5866]}, {"w": "to", "b": [0.6831, 0.5652, 0.7001, 0.5866]}, {"w": "cluster", "b": [0.706, 0.5652, 0.7617, 0.5866]}, {"w": "the", "b": [0.7676, 0.5652, 0.7939, 0.5866]}, {"w": "moons", "b": [0.7998, 0.5652, 0.8571, 0.5866]}, {"w": "dataset", "b": [0.1429, 0.5842, 0.201, 0.6057]}, {"w": "(see", "b": [0.2057, 0.5842, 0.2383, 0.6057]}, {"w": "Figure", "b": [0.243, 0.5842, 0.297, 0.6057]}, {"w": "9-24):", "b": [0.3017, 0.5842, 0.3511, 0.6057]}]}, {"id": "b_3", "type": "equation", "text": "Figure 9-24. moons_vs_bgm_diagram", "words": [{"w": "Figure", "b": [0.1429, 0.7584, 0.1943, 0.78]}, {"w": "9-24.", "b": [0.1991, 0.7584, 0.2407, 0.78]}, {"w": "moons_vs_bgm_diagram", "b": [0.2455, 0.7584, 0.4503, 0.78]}]}, {"id": "b_4", "type": "paragraph", "text": "Oops, the algorithm desperately searched for ellipsoids, so it found 8 different clus‐ ters instead of 2. The density estimation is not too bad, so this model could perhaps be used for anomaly detection, but it failed to identify the two moons. Let’s now look at a few clustering algorithms capable of dealing with arbitrarily shaped clusters.", "words": [{"w": "Oops,", "b": [0.1429, 0.7958, 0.1924, 0.8172]}, {"w": "the", "b": [0.1989, 0.7958, 0.2253, 0.8172]}, {"w": "algorithm", "b": [0.2318, 0.7958, 0.3145, 0.8172]}, {"w": "desperately", "b": [0.321, 0.7958, 0.4148, 0.8172]}, {"w": "searched", "b": [0.4214, 0.7958, 0.4946, 0.8172]}, {"w": "for", "b": [0.5011, 0.7958, 0.5256, 0.8172]}, {"w": "ellipsoids,", "b": [0.5322, 0.7958, 0.6154, 0.8172]}, {"w": "so", "b": [0.6219, 0.7958, 0.6402, 0.8172]}, {"w": "it", "b": [0.6468, 0.7958, 0.6587, 0.8172]}, {"w": "found", "b": [0.6653, 0.7958, 0.7155, 0.8172]}, {"w": "8", "b": [0.7221, 0.7958, 0.7321, 0.8172]}, {"w": "different", "b": [0.7387, 0.7958, 0.8104, 0.8172]}, {"w": "clus‐", "b": [0.8169, 0.7958, 0.8571, 0.8172]}, {"w": "ters", "b": [0.1428, 0.8149, 0.1734, 0.8363]}, {"w": "instead", "b": [0.1795, 0.8149, 0.2395, 0.8363]}, {"w": "of", "b": [0.2456, 0.8149, 0.2624, 0.8363]}, {"w": "2.", "b": [0.2685, 0.8149, 0.2833, 0.8363]}, {"w": "The", "b": [0.2894, 0.8149, 0.3222, 0.8363]}, {"w": "density", "b": [0.3283, 0.8149, 0.3887, 0.8363]}, {"w": "estimation", "b": [0.3948, 0.8149, 0.483, 0.8363]}, {"w": "is", "b": [0.4891, 0.8149, 0.5023, 0.8363]}, {"w": "not", "b": [0.5084, 0.8149, 0.5368, 0.8363]}, {"w": "too", "b": [0.5429, 0.8149, 0.5705, 0.8363]}, {"w": "bad,", "b": [0.5766, 0.8149, 0.6121, 0.8363]}, {"w": "so", "b": [0.6182, 0.8149, 0.6365, 0.8363]}, {"w": "this", "b": [0.6426, 0.8149, 0.6733, 0.8363]}, {"w": "model", "b": [0.6794, 0.8149, 0.7322, 0.8363]}, {"w": "could", "b": [0.7383, 0.8149, 0.7851, 0.8363]}, {"w": "perhaps", "b": [0.7912, 0.8149, 0.8571, 0.8363]}, {"w": "be", "b": [0.1429, 0.8339, 0.1623, 0.8553]}, {"w": "used", "b": [0.1677, 0.8339, 0.2062, 0.8553]}, {"w": "for", "b": [0.2116, 0.8339, 0.2361, 0.8553]}, {"w": "anomaly", "b": [0.2415, 0.8339, 0.3137, 0.8553]}, {"w": "detection,", "b": [0.3191, 0.8339, 0.4017, 0.8553]}, {"w": "but", "b": [0.407, 0.8339, 0.435, 0.8553]}, {"w": "it", "b": [0.4404, 0.8339, 0.4523, 0.8553]}, {"w": "failed", "b": [0.4577, 0.8339, 0.5037, 0.8553]}, {"w": "to", "b": [0.5091, 0.8339, 0.5261, 0.8553]}, {"w": "identify", "b": [0.5315, 0.8339, 0.5959, 0.8553]}, {"w": "the", "b": [0.6013, 0.8339, 0.6276, 0.8553]}, {"w": "two", "b": [0.633, 0.8339, 0.6642, 0.8553]}, {"w": "moons.", "b": [0.6696, 0.8339, 0.7317, 0.8553]}, {"w": "Let’s", "b": [0.7371, 0.8339, 0.7733, 0.8553]}, {"w": "now", "b": [0.7786, 0.8339, 0.8149, 0.8553]}, {"w": "look", "b": [0.8203, 0.8339, 0.8571, 0.8553]}, {"w": "at", "b": [0.1429, 0.853, 0.158, 0.8744]}, {"w": "a", "b": [0.1627, 0.853, 0.1718, 0.8744]}, {"w": "few", "b": [0.1766, 0.853, 0.2059, 0.8744]}, {"w": "clustering", "b": [0.2106, 0.853, 0.293, 0.8744]}, {"w": "algorithms", "b": [0.2978, 0.853, 0.3881, 0.8744]}, {"w": "capable", "b": [0.3928, 0.853, 0.4551, 0.8744]}, {"w": "of", "b": [0.4599, 0.853, 0.4766, 0.8744]}, {"w": "dealing", "b": [0.4814, 0.853, 0.5424, 0.8744]}, {"w": "with", "b": [0.5471, 0.853, 0.5844, 0.8744]}, {"w": "arbitrarily", "b": [0.5892, 0.853, 0.6736, 0.8744]}, {"w": "shaped", "b": [0.6783, 0.853, 0.7366, 0.8744]}, {"w": "clusters.", "b": [0.7413, 0.853, 0.8095, 0.8744]}]}, {"id": "b_5", "type": "paragraph", "text": "Gaussian Mixtures | 273", "words": [{"w": "Gaussian", "b": [0.6892, 0.9225, 0.7415, 0.9388]}, {"w": "Mixtures", "b": [0.7443, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "273", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 300, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Other Anomaly Detection and Novelty Detection Algorithms", "words": [{"w": "Other", "b": [0.1429, 0.0763, 0.2008, 0.1049]}, {"w": "Anomaly", "b": [0.2057, 0.0763, 0.2971, 0.1049]}, {"w": "Detection", "b": [0.3021, 0.0763, 0.402, 0.1049]}, {"w": "and", "b": [0.4069, 0.0763, 0.4462, 0.1049]}, {"w": "Novelty", "b": [0.4511, 0.0763, 0.5305, 0.1049]}, {"w": "Detection", "b": [0.5354, 0.0763, 0.6353, 0.1049]}, {"w": "Algorithms", "b": [0.6403, 0.0763, 0.7545, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "Scikit-Learn also implements a few algorithms dedicated to anomaly detection or novelty detection:", "words": [{"w": "Scikit-Learn", "b": [0.1429, 0.1108, 0.2451, 0.1322]}, {"w": "also", "b": [0.2538, 0.1108, 0.2865, 0.1322]}, {"w": "implements", "b": [0.2952, 0.1108, 0.3934, 0.1322]}, {"w": "a", "b": [0.4021, 0.1108, 0.4112, 0.1322]}, {"w": "few", "b": [0.4199, 0.1108, 0.4492, 0.1322]}, {"w": "algorithms", "b": [0.4579, 0.1108, 0.5482, 0.1322]}, {"w": "dedicated", "b": [0.5568, 0.1108, 0.637, 0.1322]}, {"w": "to", "b": [0.6457, 0.1108, 0.6627, 0.1322]}, {"w": "anomaly", "b": [0.6714, 0.1108, 0.7436, 0.1322]}, {"w": "detection", "b": [0.7523, 0.1108, 0.8301, 0.1322]}, {"w": "or", "b": [0.8388, 0.1108, 0.8571, 0.1322]}, {"w": "novelty", "b": [0.1429, 0.1298, 0.2046, 0.1512]}, {"w": "detection:", "b": [0.2093, 0.1298, 0.2919, 0.1512]}]}, {"id": "b_2", "type": "paragraph", "text": "• Fast-MCD (minimum covariance determinant), implemented by the EllipticEn velope class: this algorithm is useful for outlier detection, in particular to cleanup a dataset. It assumes that the normal instances (inliers) are generated from a single Gaussian distribution (not a mixture), but it also assumes that the dataset is contaminated with outliers that were not generated from this Gaussian distribution. When it estimates the parameters of the Gaussian distribution (i.e., the shape of the elliptic envelope around the inliers), it is careful to ignore the instances that are most likely outliers. This gives a better estimation of the elliptic envelope, and thus makes it better at identifying the outliers.", "words": [{"w": "•", "b": [0.16, 0.1649, 0.1682, 0.1863]}, {"w": "Fast-MCD", "b": [0.1786, 0.1647, 0.2652, 0.1863]}, {"w": "(minimum", "b": [0.2707, 0.1649, 0.3623, 0.1863]}, {"w": "covariance", "b": [0.3678, 0.1649, 0.4576, 0.1863]}, {"w": "determinant),", "b": [0.4631, 0.1649, 0.5784, 0.1863]}, {"w": "implemented", "b": [0.5839, 0.1649, 0.6944, 0.1863]}, {"w": "by", "b": [0.6999, 0.1649, 0.72, 0.1863]}, {"w": "the", "b": [0.7256, 0.1649, 0.7519, 0.1863]}, {"w": "EllipticEn", "b": [0.7574, 0.1681, 0.8564, 0.1832]}, {"w": "velope", "b": [0.1786, 0.188, 0.2379, 0.2031]}, {"w": "class:", "b": [0.2489, 0.1848, 0.2922, 0.2062]}, {"w": "this", "b": [0.3032, 0.1848, 0.3339, 0.2062]}, {"w": "algorithm", "b": [0.3449, 0.1848, 0.4276, 0.2062]}, {"w": "is", "b": [0.4386, 0.1848, 0.4518, 0.2062]}, {"w": "useful", "b": [0.4628, 0.1848, 0.5129, 0.2062]}, {"w": "for", "b": [0.5239, 0.1848, 0.5484, 0.2062]}, {"w": "outlier", "b": [0.5594, 0.1848, 0.6149, 0.2062]}, {"w": "detection,", "b": [0.6259, 0.1848, 0.7084, 0.2062]}, {"w": "in", "b": [0.7194, 0.1848, 0.7364, 0.2062]}, {"w": "particular", "b": [0.7474, 0.1848, 0.8292, 0.2062]}, {"w": "to", "b": [0.8402, 0.1848, 0.8571, 0.2062]}, {"w": "cleanup", "b": [0.1786, 0.2039, 0.2436, 0.2253]}, {"w": "a", "b": [0.2517, 0.2039, 0.2609, 0.2253]}, {"w": "dataset.", "b": [0.269, 0.2039, 0.3318, 0.2253]}, {"w": "It", "b": [0.3399, 0.2039, 0.3526, 0.2253]}, {"w": "assumes", "b": [0.3607, 0.2039, 0.4297, 0.2253]}, {"w": "that", "b": [0.4378, 0.2039, 0.4704, 0.2253]}, {"w": "the", "b": [0.4785, 0.2039, 0.5048, 0.2253]}, {"w": "normal", "b": [0.5129, 0.2039, 0.5742, 0.2253]}, {"w": "instances", "b": [0.5823, 0.2039, 0.6591, 0.2253]}, {"w": "(inliers)", "b": [0.6672, 0.2039, 0.7337, 0.2253]}, {"w": "are", "b": [0.7418, 0.2039, 0.7675, 0.2253]}, {"w": "generated", "b": [0.7756, 0.2039, 0.8571, 0.2253]}, {"w": "from", "b": [0.1786, 0.2229, 0.2202, 0.2443]}, {"w": "a", "b": [0.2263, 0.2229, 0.2355, 0.2443]}, {"w": "single", "b": [0.2416, 0.2229, 0.2901, 0.2443]}, {"w": "Gaussian", "b": [0.2962, 0.2229, 0.3724, 0.2443]}, {"w": "distribution", "b": [0.3785, 0.2229, 0.478, 0.2443]}, {"w": "(not", "b": [0.4842, 0.2229, 0.5198, 0.2443]}, {"w": "a", "b": [0.5259, 0.2229, 0.5351, 0.2443]}, {"w": "mixture),", "b": [0.5412, 0.2229, 0.6196, 0.2443]}, {"w": "but", "b": [0.6258, 0.2229, 0.6538, 0.2443]}, {"w": "it", "b": [0.6599, 0.2229, 0.6719, 0.2443]}, {"w": "also", "b": [0.678, 0.2229, 0.7107, 0.2443]}, {"w": "assumes", "b": [0.7169, 0.2229, 0.7859, 0.2443]}, {"w": "that", "b": [0.7921, 0.2229, 0.8247, 0.2443]}, {"w": "the", "b": [0.8308, 0.2229, 0.8571, 0.2443]}, {"w": "dataset", "b": [0.1786, 0.242, 0.2367, 0.2634]}, {"w": "is", "b": [0.2422, 0.242, 0.2555, 0.2634]}, {"w": "contaminated", "b": [0.261, 0.242, 0.376, 0.2634]}, {"w": "with", "b": [0.3815, 0.242, 0.4189, 0.2634]}, {"w": "outliers", "b": [0.4244, 0.242, 0.4876, 0.2634]}, {"w": "that", "b": [0.4931, 0.242, 0.5257, 0.2634]}, {"w": "were", "b": [0.5313, 0.242, 0.571, 0.2634]}, {"w": "not", "b": [0.5766, 0.242, 0.6049, 0.2634]}, {"w": "generated", "b": [0.6105, 0.242, 0.692, 0.2634]}, {"w": "from", "b": [0.6976, 0.242, 0.7392, 0.2634]}, {"w": "this", "b": [0.7448, 0.242, 0.7755, 0.2634]}, {"w": "Gaussian", "b": [0.781, 0.242, 0.8572, 0.2634]}, {"w": "distribution.", "b": [0.1786, 0.261, 0.2828, 0.2824]}, {"w": "When", "b": [0.2887, 0.261, 0.3403, 0.2824]}, {"w": "it", "b": [0.3463, 0.261, 0.3582, 0.2824]}, {"w": "estimates", "b": [0.3641, 0.261, 0.4412, 0.2824]}, {"w": "the", "b": [0.4472, 0.261, 0.4735, 0.2824]}, {"w": "parameters", "b": [0.4794, 0.261, 0.5729, 0.2824]}, {"w": "of", "b": [0.5788, 0.261, 0.5956, 0.2824]}, {"w": "the", "b": [0.6015, 0.261, 0.6278, 0.2824]}, {"w": "Gaussian", "b": [0.6338, 0.261, 0.7099, 0.2824]}, {"w": "distribution", "b": [0.7158, 0.261, 0.8153, 0.2824]}, {"w": "(i.e.,", "b": [0.8212, 0.261, 0.8571, 0.2824]}, {"w": "the", "b": [0.1786, 0.2801, 0.2049, 0.3015]}, {"w": "shape", "b": [0.2121, 0.2801, 0.2594, 0.3015]}, {"w": "of", "b": [0.2666, 0.2801, 0.2833, 0.3015]}, {"w": "the", "b": [0.2905, 0.2801, 0.3169, 0.3015]}, {"w": "elliptic", "b": [0.324, 0.2801, 0.3807, 0.3015]}, {"w": "envelope", "b": [0.3879, 0.2801, 0.4618, 0.3015]}, {"w": "around", "b": [0.469, 0.2801, 0.5299, 0.3015]}, {"w": "the", "b": [0.5371, 0.2801, 0.5634, 0.3015]}, {"w": "inliers),", "b": [0.5706, 0.2801, 0.6346, 0.3015]}, {"w": "it", "b": [0.6418, 0.2801, 0.6537, 0.3015]}, {"w": "is", "b": [0.6609, 0.2801, 0.6742, 0.3015]}, {"w": "careful", "b": [0.6813, 0.2801, 0.7384, 0.3015]}, {"w": "to", "b": [0.7455, 0.2801, 0.7625, 0.3015]}, {"w": "ignore", "b": [0.7697, 0.2801, 0.8236, 0.3015]}, {"w": "the", "b": [0.8308, 0.2801, 0.8571, 0.3015]}, {"w": "instances", "b": [0.1786, 0.2991, 0.2554, 0.3205]}, {"w": "that", "b": [0.2604, 0.2991, 0.2929, 0.3205]}, {"w": "are", "b": [0.2979, 0.2991, 0.3236, 0.3205]}, {"w": "most", "b": [0.3286, 0.2991, 0.3703, 0.3205]}, {"w": "likely", "b": [0.3752, 0.2991, 0.4201, 0.3205]}, {"w": "outliers.", "b": [0.4251, 0.2991, 0.4929, 0.3205]}, {"w": "This", "b": [0.4979, 0.2991, 0.5351, 0.3205]}, {"w": "gives", "b": [0.5401, 0.2991, 0.5815, 0.3205]}, {"w": "a", "b": [0.5865, 0.2991, 0.5956, 0.3205]}, {"w": "better", "b": [0.6006, 0.2991, 0.6493, 0.3205]}, {"w": "estimation", "b": [0.6543, 0.2991, 0.7425, 0.3205]}, {"w": "of", "b": [0.7475, 0.2991, 0.7642, 0.3205]}, {"w": "the", "b": [0.7692, 0.2991, 0.7955, 0.3205]}, {"w": "elliptic", "b": [0.8005, 0.2991, 0.8571, 0.3205]}, {"w": "envelope,", "b": [0.1786, 0.3182, 0.2573, 0.3396]}, {"w": "and", "b": [0.262, 0.3182, 0.2935, 0.3396]}, {"w": "thus", "b": [0.2983, 0.3182, 0.3341, 0.3396]}, {"w": "makes", "b": [0.3388, 0.3182, 0.3918, 0.3396]}, {"w": "it", "b": [0.3966, 0.3182, 0.4085, 0.3396]}, {"w": "better", "b": [0.4132, 0.3182, 0.4619, 0.3396]}, {"w": "at", "b": [0.4667, 0.3182, 0.4818, 0.3396]}, {"w": "identifying", "b": [0.4865, 0.3182, 0.5777, 0.3396]}, {"w": "the", "b": [0.5824, 0.3182, 0.6088, 0.3396]}, {"w": "outliers.", "b": [0.6135, 0.3182, 0.6814, 0.3396]}]}, {"id": "b_3", "type": "paragraph", "text": "• Isolation forest: this is an efficient algorithm for outlier detection, especially in high-dimensional datasets. The algorithm builds a Random Forest in which each Decision Tree is grown randomly: at each node, it picks a feature randomly, then it picks a random threshold value (between the min and max value) to split the dataset in two. The dataset gradually gets chopped into pieces this way, until all instances end up isolated from the other instances. An anomaly is usually far from other instances, so on average (across all the Decision Trees) it tends to get isolated in less steps than normal instances.", "words": [{"w": "•", "b": [0.16, 0.3433, 0.1682, 0.3647]}, {"w": "Isolation", "b": [0.1786, 0.3431, 0.249, 0.3647]}, {"w": "forest:", "b": [0.2569, 0.3431, 0.3053, 0.3647]}, {"w": "this", "b": [0.313, 0.3433, 0.3438, 0.3647]}, {"w": "is", "b": [0.3515, 0.3433, 0.3648, 0.3647]}, {"w": "an", "b": [0.3726, 0.3433, 0.3931, 0.3647]}, {"w": "efficient", "b": [0.4009, 0.3433, 0.4683, 0.3647]}, {"w": "algorithm", "b": [0.4761, 0.3433, 0.5587, 0.3647]}, {"w": "for", "b": [0.5665, 0.3433, 0.591, 0.3647]}, {"w": "outlier", "b": [0.5988, 0.3433, 0.6543, 0.3647]}, {"w": "detection,", "b": [0.6621, 0.3433, 0.7447, 0.3647]}, {"w": "especially", "b": [0.7525, 0.3433, 0.8324, 0.3647]}, {"w": "in", "b": [0.8402, 0.3433, 0.8571, 0.3647]}, {"w": "high-dimensional", "b": [0.1786, 0.3623, 0.3271, 0.3837]}, {"w": "datasets.", "b": [0.3325, 0.3623, 0.403, 0.3837]}, {"w": "The", "b": [0.4083, 0.3623, 0.4412, 0.3837]}, {"w": "algorithm", "b": [0.4465, 0.3623, 0.5292, 0.3837]}, {"w": "builds", "b": [0.5345, 0.3623, 0.5857, 0.3837]}, {"w": "a", "b": [0.591, 0.3623, 0.6002, 0.3837]}, {"w": "Random", "b": [0.6055, 0.3623, 0.6781, 0.3837]}, {"w": "Forest", "b": [0.6834, 0.3623, 0.7353, 0.3837]}, {"w": "in", "b": [0.7406, 0.3623, 0.7576, 0.3837]}, {"w": "which", "b": [0.7629, 0.3623, 0.8139, 0.3837]}, {"w": "each", "b": [0.8192, 0.3623, 0.8571, 0.3837]}, {"w": "Decision", "b": [0.1786, 0.3814, 0.2524, 0.4028]}, {"w": "Tree", "b": [0.2577, 0.3814, 0.2943, 0.4028]}, {"w": "is", "b": [0.2996, 0.3814, 0.3129, 0.4028]}, {"w": "grown", "b": [0.3182, 0.3814, 0.372, 0.4028]}, {"w": "randomly:", "b": [0.3773, 0.3814, 0.4645, 0.4028]}, {"w": "at", "b": [0.4698, 0.3814, 0.4849, 0.4028]}, {"w": "each", "b": [0.4903, 0.3814, 0.5282, 0.4028]}, {"w": "node,", "b": [0.5336, 0.3814, 0.5802, 0.4028]}, {"w": "it", "b": [0.5855, 0.3814, 0.5975, 0.4028]}, {"w": "picks", "b": [0.6028, 0.3814, 0.6461, 0.4028]}, {"w": "a", "b": [0.6514, 0.3814, 0.6606, 0.4028]}, {"w": "feature", "b": [0.6659, 0.3814, 0.7237, 0.4028]}, {"w": "randomly,", "b": [0.729, 0.3814, 0.8141, 0.4028]}, {"w": "then", "b": [0.8194, 0.3814, 0.8571, 0.4028]}, {"w": "it", "b": [0.1786, 0.4004, 0.1905, 0.4218]}, {"w": "picks", "b": [0.1969, 0.4004, 0.2402, 0.4218]}, {"w": "a", "b": [0.2465, 0.4004, 0.2556, 0.4218]}, {"w": "random", "b": [0.262, 0.4004, 0.329, 0.4218]}, {"w": "threshold", "b": [0.3353, 0.4004, 0.415, 0.4218]}, {"w": "value", "b": [0.4214, 0.4004, 0.4654, 0.4218]}, {"w": "(between", "b": [0.4717, 0.4004, 0.5481, 0.4218]}, {"w": "the", "b": [0.5545, 0.4004, 0.5808, 0.4218]}, {"w": "min", "b": [0.5871, 0.4004, 0.6212, 0.4218]}, {"w": "and", "b": [0.6275, 0.4004, 0.6591, 0.4218]}, {"w": "max", "b": [0.6654, 0.4004, 0.7015, 0.4218]}, {"w": "value)", "b": [0.7078, 0.4004, 0.759, 0.4218]}, {"w": "to", "b": [0.7654, 0.4004, 0.7823, 0.4218]}, {"w": "split", "b": [0.7887, 0.4004, 0.8245, 0.4218]}, {"w": "the", "b": [0.8308, 0.4004, 0.8571, 0.4218]}, {"w": "dataset", "b": [0.1786, 0.4195, 0.2367, 0.4409]}, {"w": "in", "b": [0.2432, 0.4195, 0.2602, 0.4409]}, {"w": "two.", "b": [0.2667, 0.4195, 0.3021, 0.4409]}, {"w": "The", "b": [0.3086, 0.4195, 0.3414, 0.4409]}, {"w": "dataset", "b": [0.3479, 0.4195, 0.406, 0.4409]}, {"w": "gradually", "b": [0.4125, 0.4195, 0.4905, 0.4409]}, {"w": "gets", "b": [0.497, 0.4195, 0.5296, 0.4409]}, {"w": "chopped", "b": [0.5361, 0.4195, 0.6084, 0.4409]}, {"w": "into", "b": [0.6149, 0.4195, 0.6484, 0.4409]}, {"w": "pieces", "b": [0.6549, 0.4195, 0.7056, 0.4409]}, {"w": "this", "b": [0.7121, 0.4195, 0.7428, 0.4409]}, {"w": "way,", "b": [0.7493, 0.4195, 0.7852, 0.4409]}, {"w": "until", "b": [0.7917, 0.4195, 0.831, 0.4409]}, {"w": "all", "b": [0.8375, 0.4195, 0.8572, 0.4409]}, {"w": "instances", "b": [0.1786, 0.4385, 0.2554, 0.4599]}, {"w": "end", "b": [0.2635, 0.4385, 0.2947, 0.4599]}, {"w": "up", "b": [0.3028, 0.4385, 0.3248, 0.4599]}, {"w": "isolated", "b": [0.3329, 0.4385, 0.397, 0.4599]}, {"w": "from", "b": [0.405, 0.4385, 0.4466, 0.4599]}, {"w": "the", "b": [0.4547, 0.4385, 0.481, 0.4599]}, {"w": "other", "b": [0.4891, 0.4385, 0.5338, 0.4599]}, {"w": "instances.", "b": [0.5419, 0.4385, 0.6235, 0.4599]}, {"w": "An", "b": [0.6315, 0.4385, 0.6573, 0.4599]}, {"w": "anomaly", "b": [0.6654, 0.4385, 0.7376, 0.4599]}, {"w": "is", "b": [0.7457, 0.4385, 0.7589, 0.4599]}, {"w": "usually", "b": [0.767, 0.4385, 0.826, 0.4599]}, {"w": "far", "b": [0.8341, 0.4385, 0.8571, 0.4599]}, {"w": "from", "b": [0.1786, 0.4575, 0.2202, 0.479]}, {"w": "other", "b": [0.2258, 0.4575, 0.2705, 0.479]}, {"w": "instances,", "b": [0.2761, 0.4575, 0.3576, 0.479]}, {"w": "so", "b": [0.3633, 0.4575, 0.3815, 0.479]}, {"w": "on", "b": [0.3871, 0.4575, 0.4091, 0.479]}, {"w": "average", "b": [0.4148, 0.4575, 0.4775, 0.479]}, {"w": "(across", "b": [0.4831, 0.4575, 0.5419, 0.479]}, {"w": "all", "b": [0.5475, 0.4575, 0.5672, 0.479]}, {"w": "the", "b": [0.5728, 0.4575, 0.5992, 0.479]}, {"w": "Decision", "b": [0.6048, 0.4575, 0.6786, 0.479]}, {"w": "Trees)", "b": [0.6842, 0.4575, 0.7356, 0.479]}, {"w": "it", "b": [0.7412, 0.4575, 0.7531, 0.479]}, {"w": "tends", "b": [0.7587, 0.4575, 0.804, 0.479]}, {"w": "to", "b": [0.8096, 0.4575, 0.8266, 0.479]}, {"w": "get", "b": [0.8322, 0.4575, 0.8571, 0.479]}, {"w": "isolated", "b": [0.1786, 0.4766, 0.2426, 0.498]}, {"w": "in", "b": [0.2474, 0.4766, 0.2644, 0.498]}, {"w": "less", "b": [0.2691, 0.4766, 0.2985, 0.498]}, {"w": "steps", "b": [0.3032, 0.4766, 0.3446, 0.498]}, {"w": "than", "b": [0.3494, 0.4766, 0.3874, 0.498]}, {"w": "normal", "b": [0.3921, 0.4766, 0.4534, 0.498]}, {"w": "instances.", "b": [0.4581, 0.4766, 0.5397, 0.498]}]}, {"id": "b_4", "type": "paragraph", "text": "• Local outlier factor (LOF): this algorithm is also good for outlier detection. It compares the density of instances around a given instance to the density around its neighbors. An anomaly is often more isolated than its k nearest neighbors.", "words": [{"w": "•", "b": [0.16, 0.5017, 0.1682, 0.5231]}, {"w": "Local", "b": [0.1786, 0.5015, 0.2224, 0.5231]}, {"w": "outlier", "b": [0.2309, 0.5015, 0.284, 0.5231]}, {"w": "factor", "b": [0.2924, 0.5015, 0.3394, 0.5231]}, {"w": "(LOF):", "b": [0.3478, 0.5017, 0.4048, 0.5231]}, {"w": "this", "b": [0.4132, 0.5017, 0.4439, 0.5231]}, {"w": "algorithm", "b": [0.4523, 0.5017, 0.535, 0.5231]}, {"w": "is", "b": [0.5434, 0.5017, 0.5566, 0.5231]}, {"w": "also", "b": [0.5651, 0.5017, 0.5978, 0.5231]}, {"w": "good", "b": [0.6062, 0.5017, 0.6482, 0.5231]}, {"w": "for", "b": [0.6566, 0.5017, 0.6811, 0.5231]}, {"w": "outlier", "b": [0.6896, 0.5017, 0.745, 0.5231]}, {"w": "detection.", "b": [0.7535, 0.5017, 0.8361, 0.5231]}, {"w": "It", "b": [0.8445, 0.5017, 0.8571, 0.5231]}, {"w": "compares", "b": [0.1786, 0.5207, 0.259, 0.5421]}, {"w": "the", "b": [0.2647, 0.5207, 0.291, 0.5421]}, {"w": "density", "b": [0.2967, 0.5207, 0.3571, 0.5421]}, {"w": "of", "b": [0.3629, 0.5207, 0.3796, 0.5421]}, {"w": "instances", "b": [0.3854, 0.5207, 0.4622, 0.5421]}, {"w": "around", "b": [0.4679, 0.5207, 0.5289, 0.5421]}, {"w": "a", "b": [0.5346, 0.5207, 0.5437, 0.5421]}, {"w": "given", "b": [0.5495, 0.5207, 0.5947, 0.5421]}, {"w": "instance", "b": [0.6004, 0.5207, 0.6696, 0.5421]}, {"w": "to", "b": [0.6753, 0.5207, 0.6923, 0.5421]}, {"w": "the", "b": [0.698, 0.5207, 0.7244, 0.5421]}, {"w": "density", "b": [0.7301, 0.5207, 0.7905, 0.5421]}, {"w": "around", "b": [0.7962, 0.5207, 0.8571, 0.5421]}, {"w": "its", "b": [0.1786, 0.5398, 0.1981, 0.5612]}, {"w": "neighbors.", "b": [0.2029, 0.5398, 0.2909, 0.5612]}, {"w": "An", "b": [0.2956, 0.5398, 0.3214, 0.5612]}, {"w": "anomaly", "b": [0.3262, 0.5398, 0.3984, 0.5612]}, {"w": "is", "b": [0.4031, 0.5398, 0.4163, 0.5612]}, {"w": "often", "b": [0.4211, 0.5398, 0.4645, 0.5612]}, {"w": "more", "b": [0.4692, 0.5398, 0.5135, 0.5612]}, {"w": "isolated", "b": [0.5182, 0.5398, 0.5823, 0.5612]}, {"w": "than", "b": [0.587, 0.5398, 0.625, 0.5612]}, {"w": "its", "b": [0.6297, 0.5398, 0.6493, 0.5612]}, {"w": "k", "b": [0.6541, 0.5396, 0.6639, 0.5612]}, {"w": "nearest", "b": [0.6686, 0.5398, 0.7286, 0.5612]}, {"w": "neighbors.", "b": [0.7333, 0.5398, 0.8213, 0.5612]}]}, {"id": "b_5", "type": "paragraph", "text": "• One-class SVM: this algorithm is better suited for novelty detection. Recall that a kernelized SVM classifier separates two classes by first (implicitly) mapping all the instances to a high-dimensional space, then separating the two classes using a linear SVM classifier within this high-dimensional space (see Chapter 5). Since we just have one class of instances, the one-class SVM algorithm instead tries to separate the instances in high-dimensional space from the origin. In the original space, this will correspond to finding a small region that encompasses all the instances. If a new instance does not fall within this region, it is an anomaly. There are a few hyperparameters to tweak: the usual ones for a kernelized SVM, plus a margin hyperparameter that corresponds to the probability of a new instance being mistakenly considered as novel, when it is in fact normal. It works great, especially with high-dimensional datasets, but just like all SVMs, it does not scale to large datasets.", "words": [{"w": "•", "b": [0.16, 0.5649, 0.1682, 0.5863]}, {"w": "One-class", "b": [0.1786, 0.5647, 0.2565, 0.5863]}, {"w": "SVM:", "b": [0.2621, 0.5647, 0.3089, 0.5863]}, {"w": "this", "b": [0.3145, 0.5649, 0.3452, 0.5863]}, {"w": "algorithm", "b": [0.3508, 0.5649, 0.4335, 0.5863]}, {"w": "is", "b": [0.4391, 0.5649, 0.4523, 0.5863]}, {"w": "better", "b": [0.4579, 0.5649, 0.5066, 0.5863]}, {"w": "suited", "b": [0.5122, 0.5649, 0.5627, 0.5863]}, {"w": "for", "b": [0.5683, 0.5649, 0.5928, 0.5863]}, {"w": "novelty", "b": [0.5984, 0.5649, 0.6601, 0.5863]}, {"w": "detection.", "b": [0.6657, 0.5649, 0.7483, 0.5863]}, {"w": "Recall", "b": [0.7539, 0.5649, 0.8042, 0.5863]}, {"w": "that", "b": [0.8098, 0.5649, 0.8424, 0.5863]}, {"w": "a", "b": [0.848, 0.5649, 0.8571, 0.5863]}, {"w": "kernelized", "b": [0.1786, 0.5839, 0.2652, 0.6053]}, {"w": "SVM", "b": [0.2725, 0.5839, 0.3155, 0.6053]}, {"w": "classifier", "b": [0.3228, 0.5839, 0.3952, 0.6053]}, {"w": "separates", "b": [0.4025, 0.5839, 0.4784, 0.6053]}, {"w": "two", "b": [0.4856, 0.5839, 0.5169, 0.6053]}, {"w": "classes", "b": [0.5241, 0.5839, 0.5792, 0.6053]}, {"w": "by", "b": [0.5864, 0.5839, 0.6066, 0.6053]}, {"w": "first", "b": [0.6138, 0.5839, 0.6473, 0.6053]}, {"w": "(implicitly)", "b": [0.6546, 0.5839, 0.7486, 0.6053]}, {"w": "mapping", "b": [0.7558, 0.5839, 0.8302, 0.6053]}, {"w": "all", "b": [0.8375, 0.5839, 0.8571, 0.6053]}, {"w": "the", "b": [0.1786, 0.603, 0.2049, 0.6244]}, {"w": "instances", "b": [0.2099, 0.603, 0.2867, 0.6244]}, {"w": "to", "b": [0.2917, 0.603, 0.3086, 0.6244]}, {"w": "a", "b": [0.3136, 0.603, 0.3227, 0.6244]}, {"w": "high-dimensional", "b": [0.3277, 0.603, 0.4763, 0.6244]}, {"w": "space,", "b": [0.4812, 0.603, 0.5314, 0.6244]}, {"w": "then", "b": [0.5363, 0.603, 0.574, 0.6244]}, {"w": "separating", "b": [0.579, 0.603, 0.6651, 0.6244]}, {"w": "the", "b": [0.6701, 0.603, 0.6964, 0.6244]}, {"w": "two", "b": [0.7014, 0.603, 0.7326, 0.6244]}, {"w": "classes", "b": [0.7376, 0.603, 0.7926, 0.6244]}, {"w": "using", "b": [0.7976, 0.603, 0.843, 0.6244]}, {"w": "a", "b": [0.848, 0.603, 0.8571, 0.6244]}, {"w": "linear", "b": [0.1786, 0.622, 0.2266, 0.6434]}, {"w": "SVM", "b": [0.2335, 0.622, 0.2766, 0.6434]}, {"w": "classifier", "b": [0.2835, 0.622, 0.356, 0.6434]}, {"w": "within", "b": [0.3629, 0.622, 0.4172, 0.6434]}, {"w": "this", "b": [0.4242, 0.622, 0.4549, 0.6434]}, {"w": "high-dimensional", "b": [0.4618, 0.622, 0.6104, 0.6434]}, {"w": "space", "b": [0.6173, 0.622, 0.6627, 0.6434]}, {"w": "(see", "b": [0.6697, 0.622, 0.7022, 0.6434]}, {"w": "Chapter", "b": [0.7092, 0.622, 0.7768, 0.6434]}, {"w": "5).", "b": [0.7837, 0.622, 0.8057, 0.6434]}, {"w": "Since", "b": [0.8126, 0.622, 0.8571, 0.6434]}, {"w": "we", "b": [0.1786, 0.6411, 0.2017, 0.6625]}, {"w": "just", "b": [0.2076, 0.6411, 0.238, 0.6625]}, {"w": "have", "b": [0.2439, 0.6411, 0.2823, 0.6625]}, {"w": "one", "b": [0.2882, 0.6411, 0.3191, 0.6625]}, {"w": "class", "b": [0.325, 0.6411, 0.3635, 0.6625]}, {"w": "of", "b": [0.3695, 0.6411, 0.3863, 0.6625]}, {"w": "instances,", "b": [0.3922, 0.6411, 0.4738, 0.6625]}, {"w": "the", "b": [0.4797, 0.6411, 0.506, 0.6625]}, {"w": "one-class", "b": [0.5119, 0.6411, 0.5887, 0.6625]}, {"w": "SVM", "b": [0.5946, 0.6411, 0.6377, 0.6625]}, {"w": "algorithm", "b": [0.6436, 0.6411, 0.7263, 0.6625]}, {"w": "instead", "b": [0.7322, 0.6411, 0.7922, 0.6625]}, {"w": "tries", "b": [0.7981, 0.6411, 0.8343, 0.6625]}, {"w": "to", "b": [0.8402, 0.6411, 0.8572, 0.6625]}, {"w": "separate", "b": [0.1786, 0.6601, 0.2468, 0.6815]}, {"w": "the", "b": [0.2525, 0.6601, 0.2789, 0.6815]}, {"w": "instances", "b": [0.2846, 0.6601, 0.3614, 0.6815]}, {"w": "in", "b": [0.3672, 0.6601, 0.3841, 0.6815]}, {"w": "high-dimensional", "b": [0.3899, 0.6601, 0.5384, 0.6815]}, {"w": "space", "b": [0.5442, 0.6601, 0.5895, 0.6815]}, {"w": "from", "b": [0.5953, 0.6601, 0.6368, 0.6815]}, {"w": "the", "b": [0.6426, 0.6601, 0.6689, 0.6815]}, {"w": "origin.", "b": [0.6746, 0.6601, 0.73, 0.6815]}, {"w": "In", "b": [0.7358, 0.6601, 0.7543, 0.6815]}, {"w": "the", "b": [0.76, 0.6601, 0.7863, 0.6815]}, {"w": "original", "b": [0.7921, 0.6601, 0.8571, 0.6815]}, {"w": "space,", "b": [0.1786, 0.6792, 0.2287, 0.7006]}, {"w": "this", "b": [0.237, 0.6792, 0.2677, 0.7006]}, {"w": "will", "b": [0.2761, 0.6792, 0.3064, 0.7006]}, {"w": "correspond", "b": [0.3148, 0.6792, 0.4101, 0.7006]}, {"w": "to", "b": [0.4184, 0.6792, 0.4354, 0.7006]}, {"w": "finding", "b": [0.4437, 0.6792, 0.5046, 0.7006]}, {"w": "a", "b": [0.5129, 0.6792, 0.5221, 0.7006]}, {"w": "small", "b": [0.5304, 0.6792, 0.5748, 0.7006]}, {"w": "region", "b": [0.5831, 0.6792, 0.637, 0.7006]}, {"w": "that", "b": [0.6454, 0.6792, 0.678, 0.7006]}, {"w": "encompasses", "b": [0.6863, 0.6792, 0.7945, 0.7006]}, {"w": "all", "b": [0.8028, 0.6792, 0.8225, 0.7006]}, {"w": "the", "b": [0.8308, 0.6792, 0.8571, 0.7006]}, {"w": "instances.", "b": [0.1786, 0.6982, 0.2601, 0.7196]}, {"w": "If", "b": [0.2683, 0.6982, 0.2815, 0.7196]}, {"w": "a", "b": [0.2897, 0.6982, 0.2988, 0.7196]}, {"w": "new", "b": [0.3069, 0.6982, 0.3414, 0.7196]}, {"w": "instance", "b": [0.3496, 0.6982, 0.4187, 0.7196]}, {"w": "does", "b": [0.4269, 0.6982, 0.465, 0.7196]}, {"w": "not", "b": [0.4731, 0.6982, 0.5015, 0.7196]}, {"w": "fall", "b": [0.5096, 0.6982, 0.5355, 0.7196]}, {"w": "within", "b": [0.5436, 0.6982, 0.5979, 0.7196]}, {"w": "this", "b": [0.606, 0.6982, 0.6367, 0.7196]}, {"w": "region,", "b": [0.6448, 0.6982, 0.7035, 0.7196]}, {"w": "it", "b": [0.7116, 0.6982, 0.7236, 0.7196]}, {"w": "is", "b": [0.7317, 0.6982, 0.7449, 0.7196]}, {"w": "an", "b": [0.753, 0.6982, 0.7736, 0.7196]}, {"w": "anomaly.", "b": [0.7817, 0.6982, 0.8571, 0.7196]}, {"w": "There", "b": [0.1786, 0.7173, 0.228, 0.7387]}, {"w": "are", "b": [0.2338, 0.7173, 0.2596, 0.7387]}, {"w": "a", "b": [0.2654, 0.7173, 0.2746, 0.7387]}, {"w": "few", "b": [0.2804, 0.7173, 0.3097, 0.7387]}, {"w": "hyperparameters", "b": [0.3155, 0.7173, 0.4567, 0.7387]}, {"w": "to", "b": [0.4625, 0.7173, 0.4795, 0.7387]}, {"w": "tweak:", "b": [0.4854, 0.7173, 0.5391, 0.7387]}, {"w": "the", "b": [0.5449, 0.7173, 0.5712, 0.7387]}, {"w": "usual", "b": [0.5771, 0.7173, 0.6213, 0.7387]}, {"w": "ones", "b": [0.6271, 0.7173, 0.6656, 0.7387]}, {"w": "for", "b": [0.6715, 0.7173, 0.696, 0.7387]}, {"w": "a", "b": [0.7019, 0.7173, 0.711, 0.7387]}, {"w": "kernelized", "b": [0.7168, 0.7173, 0.8035, 0.7387]}, {"w": "SVM,", "b": [0.8093, 0.7173, 0.8571, 0.7387]}, {"w": "plus", "b": [0.1786, 0.7363, 0.2135, 0.7577]}, {"w": "a", "b": [0.2234, 0.7363, 0.2325, 0.7577]}, {"w": "margin", "b": [0.2424, 0.7363, 0.3031, 0.7577]}, {"w": "hyperparameter", "b": [0.313, 0.7363, 0.4465, 0.7577]}, {"w": "that", "b": [0.4564, 0.7363, 0.489, 0.7577]}, {"w": "corresponds", "b": [0.4989, 0.7363, 0.6019, 0.7577]}, {"w": "to", "b": [0.6118, 0.7363, 0.6288, 0.7577]}, {"w": "the", "b": [0.6387, 0.7363, 0.6651, 0.7577]}, {"w": "probability", "b": [0.675, 0.7363, 0.7669, 0.7577]}, {"w": "of", "b": [0.7768, 0.7363, 0.7936, 0.7577]}, {"w": "a", "b": [0.8035, 0.7363, 0.8127, 0.7577]}, {"w": "new", "b": [0.8226, 0.7363, 0.8571, 0.7577]}, {"w": "instance", "b": [0.1786, 0.7554, 0.2478, 0.7768]}, {"w": "being", "b": [0.2528, 0.7554, 0.299, 0.7768]}, {"w": "mistakenly", "b": [0.304, 0.7554, 0.3952, 0.7768]}, {"w": "considered", "b": [0.4003, 0.7554, 0.4918, 0.7768]}, {"w": "as", "b": [0.4968, 0.7554, 0.5136, 0.7768]}, {"w": "novel,", "b": [0.5187, 0.7554, 0.5692, 0.7768]}, {"w": "when", "b": [0.5743, 0.7554, 0.6199, 0.7768]}, {"w": "it", "b": [0.625, 0.7554, 0.6369, 0.7768]}, {"w": "is", "b": [0.642, 0.7554, 0.6552, 0.7768]}, {"w": "in", "b": [0.6602, 0.7554, 0.6772, 0.7768]}, {"w": "fact", "b": [0.6823, 0.7554, 0.7128, 0.7768]}, {"w": "normal.", "b": [0.7178, 0.7554, 0.7838, 0.7768]}, {"w": "It", "b": [0.7888, 0.7554, 0.8015, 0.7768]}, {"w": "works", "b": [0.8065, 0.7554, 0.8571, 0.7768]}, {"w": "great,", "b": [0.1786, 0.7744, 0.2248, 0.7958]}, {"w": "especially", "b": [0.2323, 0.7744, 0.3122, 0.7958]}, {"w": "with", "b": [0.3197, 0.7744, 0.357, 0.7958]}, {"w": "high-dimensional", "b": [0.3645, 0.7744, 0.5131, 0.7958]}, {"w": "datasets,", "b": [0.5205, 0.7744, 0.591, 0.7958]}, {"w": "but", "b": [0.5985, 0.7744, 0.6265, 0.7958]}, {"w": "just", "b": [0.634, 0.7744, 0.6644, 0.7958]}, {"w": "like", "b": [0.6719, 0.7744, 0.702, 0.7958]}, {"w": "all", "b": [0.7094, 0.7744, 0.7291, 0.7958]}, {"w": "SVMs,", "b": [0.7366, 0.7744, 0.7921, 0.7958]}, {"w": "it", "b": [0.7996, 0.7744, 0.8115, 0.7958]}, {"w": "does", "b": [0.819, 0.7744, 0.8572, 0.7958]}, {"w": "not", "b": [0.1786, 0.7935, 0.2069, 0.8149]}, {"w": "scale", "b": [0.2117, 0.7935, 0.2514, 0.8149]}, {"w": "to", "b": [0.2561, 0.7935, 0.2731, 0.8149]}, {"w": "large", "b": [0.2778, 0.7935, 0.3186, 0.8149]}, {"w": "datasets.", "b": [0.3233, 0.7935, 0.3938, 0.8149]}]}, {"id": "b_6", "type": "paragraph", "text": "274 | Chapter 9: Unsupervised Learning Techniques", "words": [{"w": "274", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "9:", "b": [0.2533, 0.9225, 0.2644, 0.9388]}, {"w": "Unsupervised", "b": [0.2673, 0.9225, 0.3467, 0.9388]}, {"w": "Learning", "b": [0.3495, 0.9225, 0.4018, 0.9388]}, {"w": "Techniques", "b": [0.4046, 0.9225, 0.4709, 0.9388]}]}]}, {"page": 301, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "PART II Neural Networks and Deep Learning", "words": [{"w": "PART", "b": [0.7705, 0.1147, 0.8342, 0.149]}, {"w": "II", "b": [0.8402, 0.1147, 0.8571, 0.149]}, {"w": "Neural", "b": [0.1908, 0.1513, 0.3144, 0.2027]}, {"w": "Networks", "b": [0.3233, 0.1513, 0.5003, 0.2027]}, {"w": "and", "b": [0.5092, 0.1513, 0.5799, 0.2027]}, {"w": "Deep", "b": [0.5888, 0.1513, 0.6835, 0.2027]}, {"w": "Learning", "b": [0.6924, 0.1513, 0.8571, 0.2027]}]}]}, {"page": 302, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": []}, {"page": 303, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 You can get the best of both worlds by being open to biological inspirations without being afraid to create biologically unrealistic models, as long as they work well.", "words": [{"w": "1", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "You", "b": [0.1587, 0.8598, 0.1834, 0.8761]}, {"w": "can", "b": [0.187, 0.8598, 0.2093, 0.8761]}, {"w": "get", "b": [0.213, 0.8598, 0.232, 0.8761]}, {"w": "the", "b": [0.2356, 0.8598, 0.2556, 0.8761]}, {"w": "best", "b": [0.2592, 0.8598, 0.2847, 0.8761]}, {"w": "of", "b": [0.2883, 0.8598, 0.3011, 0.8761]}, {"w": "both", "b": [0.3047, 0.8598, 0.3342, 0.8761]}, {"w": "worlds", "b": [0.3378, 0.8598, 0.3809, 0.8761]}, {"w": "by", "b": [0.3845, 0.8598, 0.3998, 0.8761]}, {"w": "being", "b": [0.4034, 0.8598, 0.4386, 0.8761]}, {"w": "open", "b": [0.4422, 0.8598, 0.474, 0.8761]}, {"w": "to", "b": [0.4777, 0.8598, 0.4906, 0.8761]}, {"w": "biological", "b": [0.4942, 0.8598, 0.5561, 0.8761]}, {"w": "inspirations", "b": [0.5597, 0.8598, 0.6353, 0.8761]}, {"w": "without", "b": [0.6389, 0.8598, 0.6887, 0.8761]}, {"w": "being", "b": [0.6923, 0.8598, 0.7275, 0.8761]}, {"w": "afraid", "b": [0.7311, 0.8598, 0.7682, 0.8761]}, {"w": "to", "b": [0.7718, 0.8598, 0.7848, 0.8761]}, {"w": "create", "b": [0.7884, 0.8598, 0.826, 0.8761]}, {"w": "biologically", "b": [0.1587, 0.8749, 0.2319, 0.8912]}, {"w": "unrealistic", "b": [0.2355, 0.8749, 0.3022, 0.8912]}, {"w": "models,", "b": [0.3058, 0.8749, 0.3554, 0.8912]}, {"w": "as", "b": [0.359, 0.8749, 0.3718, 0.8912]}, {"w": "long", "b": [0.3754, 0.8749, 0.4037, 0.8912]}, {"w": "as", "b": [0.4073, 0.8749, 0.4201, 0.8912]}, {"w": "they", "b": [0.4237, 0.8749, 0.451, 0.8912]}, {"w": "work", "b": [0.4546, 0.8749, 0.4873, 0.8912]}, {"w": "well.", "b": [0.491, 0.8749, 0.5202, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "CHAPTER 10 Introduction to Artificial Neural Networks", "words": [{"w": "CHAPTER", "b": [0.7262, 0.1146, 0.8247, 0.1451]}, {"w": "10", "b": [0.8299, 0.1146, 0.8572, 0.1451]}, {"w": "Introduction", "b": [0.1772, 0.1478, 0.3838, 0.1935]}, {"w": "to", "b": [0.3917, 0.1478, 0.4266, 0.1935]}, {"w": "Artificial", "b": [0.4345, 0.1478, 0.5742, 0.1935]}, {"w": "Neural", "b": [0.5821, 0.1478, 0.6919, 0.1935]}, {"w": "Networks", "b": [0.6998, 0.1478, 0.8572, 0.1935]}]}, {"id": "b_2", "type": "paragraph", "text": "with Keras", "words": [{"w": "with", "b": [0.6829, 0.184, 0.7589, 0.2297]}, {"w": "Keras", "b": [0.7668, 0.184, 0.8572, 0.2297]}]}, {"id": "b_3", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 10 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.4006, 0.3102, 0.4201]}, {"w": "Early", "b": [0.3165, 0.4006, 0.3563, 0.4201]}, {"w": "Release", "b": [0.3626, 0.4006, 0.4189, 0.4201]}, {"w": "ebooks,", "b": [0.4251, 0.4006, 0.4831, 0.4201]}, {"w": "you", "b": [0.4894, 0.4006, 0.518, 0.4201]}, {"w": "get", "b": [0.5243, 0.4006, 0.5471, 0.4201]}, {"w": "books", "b": [0.5534, 0.4006, 0.5989, 0.4201]}, {"w": "in", "b": [0.6052, 0.4006, 0.6207, 0.4201]}, {"w": "their", "b": [0.627, 0.4006, 0.6632, 0.4201]}, {"w": "earliest", "b": [0.6695, 0.4006, 0.7238, 0.4201]}, {"w": "form—", "b": [0.7301, 0.4006, 0.7857, 0.4201]}, {"w": "the", "b": [0.2714, 0.418, 0.2955, 0.4376]}, {"w": "author’s", "b": [0.3012, 0.418, 0.3615, 0.4376]}, {"w": "raw", "b": [0.3672, 0.418, 0.3954, 0.4376]}, {"w": "and", "b": [0.4011, 0.418, 0.4299, 0.4376]}, {"w": "unedited", "b": [0.4357, 0.418, 0.5034, 0.4376]}, {"w": "content", "b": [0.5091, 0.418, 0.5667, 0.4376]}, {"w": "as", "b": [0.5725, 0.418, 0.5878, 0.4376]}, {"w": "he", "b": [0.5935, 0.418, 0.6118, 0.4376]}, {"w": "or", "b": [0.6175, 0.418, 0.6343, 0.4376]}, {"w": "she", "b": [0.64, 0.418, 0.6653, 0.4376]}, {"w": "writes—so", "b": [0.671, 0.418, 0.7514, 0.4376]}, {"w": "you", "b": [0.7571, 0.418, 0.7857, 0.4376]}, {"w": "can", "b": [0.2714, 0.4354, 0.2982, 0.455]}, {"w": "take", "b": [0.306, 0.4354, 0.3377, 0.455]}, {"w": "advantage", "b": [0.3455, 0.4354, 0.4223, 0.455]}, {"w": "of", "b": [0.4301, 0.4354, 0.4454, 0.455]}, {"w": "these", "b": [0.4532, 0.4354, 0.4923, 0.455]}, {"w": "technologies", "b": [0.5001, 0.4354, 0.596, 0.455]}, {"w": "long", "b": [0.6038, 0.4354, 0.6376, 0.455]}, {"w": "before", "b": [0.6454, 0.4354, 0.6937, 0.455]}, {"w": "the", "b": [0.7014, 0.4354, 0.7255, 0.455]}, {"w": "official", "b": [0.7333, 0.4354, 0.7857, 0.455]}, {"w": "release", "b": [0.2714, 0.4528, 0.3229, 0.4724]}, {"w": "of", "b": [0.3284, 0.4528, 0.3437, 0.4724]}, {"w": "these", "b": [0.3492, 0.4528, 0.3884, 0.4724]}, {"w": "titles.", "b": [0.3938, 0.4528, 0.4348, 0.4724]}, {"w": "The", "b": [0.4403, 0.4528, 0.4703, 0.4724]}, {"w": "following", "b": [0.4757, 0.4528, 0.5479, 0.4724]}, {"w": "will", "b": [0.5534, 0.4528, 0.5812, 0.4724]}, {"w": "be", "b": [0.5866, 0.4528, 0.6044, 0.4724]}, {"w": "Chapter", "b": [0.6099, 0.4528, 0.6716, 0.4724]}, {"w": "10", "b": [0.6771, 0.4528, 0.6954, 0.4724]}, {"w": "in", "b": [0.7009, 0.4528, 0.7164, 0.4724]}, {"w": "the", "b": [0.7218, 0.4528, 0.7459, 0.4724]}, {"w": "final", "b": [0.7514, 0.4528, 0.7857, 0.4724]}, {"w": "release", "b": [0.2714, 0.4702, 0.3229, 0.4898]}, {"w": "of", "b": [0.3273, 0.4702, 0.3426, 0.4898]}, {"w": "the", "b": [0.3469, 0.4702, 0.371, 0.4898]}, {"w": "book.", "b": [0.3753, 0.4702, 0.4182, 0.4898]}]}, {"id": "b_4", "type": "paragraph", "text": "Birds inspired us to fly, burdock plants inspired velcro, and countless more inven‐ tions were inspired by nature. It seems only logical, then, to look at the brain’s archi‐ tecture for inspiration on how to build an intelligent machine. This is the key idea that sparked artificial neural networks (ANNs). However, although planes were inspired by birds, they don’t have to flap their wings. Similarly, ANNs have gradually become quite different from their biological cousins. Some researchers even argue that we should drop the biological analogy altogether (e.g., by saying “units” rather than “neurons”), lest we restrict our creativity to biologically plausible systems.1", "words": [{"w": "Birds", "b": [0.1429, 0.5101, 0.1871, 0.5315]}, {"w": "inspired", "b": [0.1946, 0.5101, 0.2633, 0.5315]}, {"w": "us", "b": [0.2708, 0.5101, 0.2895, 0.5315]}, {"w": "to", "b": [0.297, 0.5101, 0.314, 0.5315]}, {"w": "fly,", "b": [0.3216, 0.5101, 0.3458, 0.5315]}, {"w": "burdock", "b": [0.3533, 0.5101, 0.4234, 0.5315]}, {"w": "plants", "b": [0.431, 0.5101, 0.4813, 0.5315]}, {"w": "inspired", "b": [0.4888, 0.5101, 0.5575, 0.5315]}, {"w": "velcro,", "b": [0.5651, 0.5101, 0.6201, 0.5315]}, {"w": "and", "b": [0.6277, 0.5101, 0.6592, 0.5315]}, {"w": "countless", "b": [0.6667, 0.5101, 0.744, 0.5315]}, {"w": "more", "b": [0.7515, 0.5101, 0.7958, 0.5315]}, {"w": "inven‐", "b": [0.8033, 0.5101, 0.8571, 0.5315]}, {"w": "tions", "b": [0.1429, 0.5291, 0.1845, 0.5506]}, {"w": "were", "b": [0.1902, 0.5291, 0.2299, 0.5506]}, {"w": "inspired", "b": [0.2356, 0.5291, 0.3043, 0.5506]}, {"w": "by", "b": [0.3101, 0.5291, 0.3302, 0.5506]}, {"w": "nature.", "b": [0.3359, 0.5291, 0.3948, 0.5506]}, {"w": "It", "b": [0.4005, 0.5291, 0.4132, 0.5506]}, {"w": "seems", "b": [0.4189, 0.5291, 0.469, 0.5506]}, {"w": "only", "b": [0.4747, 0.5291, 0.5116, 0.5506]}, {"w": "logical,", "b": [0.5173, 0.5291, 0.5765, 0.5506]}, {"w": "then,", "b": [0.5822, 0.5291, 0.6247, 0.5506]}, {"w": "to", "b": [0.6304, 0.5291, 0.6474, 0.5506]}, {"w": "look", "b": [0.6531, 0.5291, 0.69, 0.5506]}, {"w": "at", "b": [0.6957, 0.5291, 0.7108, 0.5506]}, {"w": "the", "b": [0.7165, 0.5291, 0.7429, 0.5506]}, {"w": "brain’s", "b": [0.7486, 0.5291, 0.8016, 0.5506]}, {"w": "archi‐", "b": [0.8073, 0.5291, 0.8572, 0.5506]}, {"w": "tecture", "b": [0.1429, 0.5482, 0.2009, 0.5696]}, {"w": "for", "b": [0.2081, 0.5482, 0.2326, 0.5696]}, {"w": "inspiration", "b": [0.2397, 0.5482, 0.3313, 0.5696]}, {"w": "on", "b": [0.3385, 0.5482, 0.3605, 0.5696]}, {"w": "how", "b": [0.3677, 0.5482, 0.4037, 0.5696]}, {"w": "to", "b": [0.4109, 0.5482, 0.4278, 0.5696]}, {"w": "build", "b": [0.435, 0.5482, 0.4785, 0.5696]}, {"w": "an", "b": [0.4857, 0.5482, 0.5062, 0.5696]}, {"w": "intelligent", "b": [0.5134, 0.5482, 0.5973, 0.5696]}, {"w": "machine.", "b": [0.6045, 0.5482, 0.6812, 0.5696]}, {"w": "This", "b": [0.6884, 0.5482, 0.7256, 0.5696]}, {"w": "is", "b": [0.7327, 0.5482, 0.746, 0.5696]}, {"w": "the", "b": [0.7531, 0.5482, 0.7795, 0.5696]}, {"w": "key", "b": [0.7866, 0.5482, 0.8154, 0.5696]}, {"w": "idea", "b": [0.8226, 0.5482, 0.8571, 0.5696]}, {"w": "that", "b": [0.1429, 0.5672, 0.1754, 0.5886]}, {"w": "sparked", "b": [0.1868, 0.5672, 0.2524, 0.5886]}, {"w": "artificial", "b": [0.2638, 0.567, 0.3338, 0.5886]}, {"w": "neural", "b": [0.3452, 0.567, 0.3977, 0.5886]}, {"w": "networks", "b": [0.4092, 0.567, 0.4824, 0.5886]}, {"w": "(ANNs).", "b": [0.4938, 0.5672, 0.5654, 0.5886]}, {"w": "However,", "b": [0.5768, 0.5672, 0.6556, 0.5886]}, {"w": "although", "b": [0.667, 0.5672, 0.7415, 0.5886]}, {"w": "planes", "b": [0.7528, 0.5672, 0.8061, 0.5886]}, {"w": "were", "b": [0.8174, 0.5672, 0.8571, 0.5886]}, {"w": "inspired", "b": [0.1428, 0.5863, 0.2116, 0.6077]}, {"w": "by", "b": [0.2173, 0.5863, 0.2374, 0.6077]}, {"w": "birds,", "b": [0.2431, 0.5863, 0.2904, 0.6077]}, {"w": "they", "b": [0.2961, 0.5863, 0.332, 0.6077]}, {"w": "don’t", "b": [0.3377, 0.5863, 0.3793, 0.6077]}, {"w": "have", "b": [0.385, 0.5863, 0.4234, 0.6077]}, {"w": "to", "b": [0.4291, 0.5863, 0.446, 0.6077]}, {"w": "flap", "b": [0.4517, 0.5863, 0.4828, 0.6077]}, {"w": "their", "b": [0.4885, 0.5863, 0.5282, 0.6077]}, {"w": "wings.", "b": [0.5339, 0.5863, 0.5873, 0.6077]}, {"w": "Similarly,", "b": [0.593, 0.5863, 0.6713, 0.6077]}, {"w": "ANNs", "b": [0.677, 0.5863, 0.7294, 0.6077]}, {"w": "have", "b": [0.7351, 0.5863, 0.7735, 0.6077]}, {"w": "gradually", "b": [0.7792, 0.5863, 0.8571, 0.6077]}, {"w": "become", "b": [0.1429, 0.6053, 0.2077, 0.6267]}, {"w": "quite", "b": [0.2156, 0.6053, 0.2581, 0.6267]}, {"w": "different", "b": [0.266, 0.6053, 0.3378, 0.6267]}, {"w": "from", "b": [0.3457, 0.6053, 0.3873, 0.6267]}, {"w": "their", "b": [0.3952, 0.6053, 0.4349, 0.6267]}, {"w": "biological", "b": [0.4428, 0.6053, 0.5241, 0.6267]}, {"w": "cousins.", "b": [0.532, 0.6053, 0.5995, 0.6267]}, {"w": "Some", "b": [0.6075, 0.6053, 0.6539, 0.6267]}, {"w": "researchers", "b": [0.6618, 0.6053, 0.756, 0.6267]}, {"w": "even", "b": [0.7639, 0.6053, 0.8027, 0.6267]}, {"w": "argue", "b": [0.8106, 0.6053, 0.8571, 0.6267]}, {"w": "that", "b": [0.1429, 0.6244, 0.1754, 0.6458]}, {"w": "we", "b": [0.1824, 0.6244, 0.2056, 0.6458]}, {"w": "should", "b": [0.2126, 0.6244, 0.2693, 0.6458]}, {"w": "drop", "b": [0.2763, 0.6244, 0.3166, 0.6458]}, {"w": "the", "b": [0.3236, 0.6244, 0.3499, 0.6458]}, {"w": "biological", "b": [0.3569, 0.6244, 0.4381, 0.6458]}, {"w": "analogy", "b": [0.4451, 0.6244, 0.5105, 0.6458]}, {"w": "altogether", "b": [0.5175, 0.6244, 0.6016, 0.6458]}, {"w": "(e.g.,", "b": [0.6086, 0.6244, 0.6487, 0.6458]}, {"w": "by", "b": [0.6557, 0.6244, 0.6758, 0.6458]}, {"w": "saying", "b": [0.6828, 0.6244, 0.7355, 0.6458]}, {"w": "“units”", "b": [0.7425, 0.6244, 0.7996, 0.6458]}, {"w": "rather", "b": [0.8066, 0.6244, 0.8571, 0.6458]}, {"w": "than", "b": [0.1429, 0.6434, 0.1809, 0.6648]}, {"w": "“neurons”),", "b": [0.1856, 0.6434, 0.2814, 0.6648]}, {"w": "lest", "b": [0.2861, 0.6434, 0.3143, 0.6648]}, {"w": "we", "b": [0.319, 0.6434, 0.3421, 0.6648]}, {"w": "restrict", "b": [0.3469, 0.6434, 0.4059, 0.6648]}, {"w": "our", "b": [0.4106, 0.6434, 0.4401, 0.6648]}, {"w": "creativity", "b": [0.4448, 0.6434, 0.522, 0.6648]}, {"w": "to", "b": [0.5267, 0.6434, 0.5437, 0.6648]}, {"w": "biologically", "b": [0.5485, 0.6434, 0.6445, 0.6648]}, {"w": "plausible", "b": [0.6493, 0.6434, 0.7232, 0.6648]}, {"w": "systems.1", "b": [0.7279, 0.6434, 0.8032, 0.6648]}]}, {"id": "b_5", "type": "paragraph", "text": "ANNs are at the very core of Deep Learning. They are versatile, powerful, and scala‐ ble, making them ideal to tackle large and highly complex Machine Learning tasks, such as classifying billions of images (e.g., Google Images), powering speech recogni‐ tion services (e.g., Apple’s Siri), recommending the best videos to watch to hundreds of millions of users every day (e.g., YouTube), or learning to beat the world champion at the game of Go by playing millions of games against itself (DeepMind’s Alpha‐ Zero).", "words": [{"w": "ANNs", "b": [0.1428, 0.6715, 0.1953, 0.693]}, {"w": "are", "b": [0.2011, 0.6715, 0.2268, 0.693]}, {"w": "at", "b": [0.2327, 0.6715, 0.2478, 0.693]}, {"w": "the", "b": [0.2536, 0.6715, 0.2799, 0.693]}, {"w": "very", "b": [0.2857, 0.6715, 0.3221, 0.693]}, {"w": "core", "b": [0.328, 0.6715, 0.364, 0.693]}, {"w": "of", "b": [0.3698, 0.6715, 0.3866, 0.693]}, {"w": "Deep", "b": [0.3924, 0.6715, 0.4364, 0.693]}, {"w": "Learning.", "b": [0.4422, 0.6715, 0.522, 0.693]}, {"w": "They", "b": [0.5278, 0.6715, 0.5702, 0.693]}, {"w": "are", "b": [0.576, 0.6715, 0.6018, 0.693]}, {"w": "versatile,", "b": [0.6076, 0.6715, 0.681, 0.693]}, {"w": "powerful,", "b": [0.6869, 0.6715, 0.7665, 0.693]}, {"w": "and", "b": [0.7723, 0.6715, 0.8039, 0.693]}, {"w": "scala‐", "b": [0.8097, 0.6715, 0.8571, 0.693]}, {"w": "ble,", "b": [0.1429, 0.6906, 0.1723, 0.712]}, {"w": "making", "b": [0.1792, 0.6906, 0.2425, 0.712]}, {"w": "them", "b": [0.2494, 0.6906, 0.2928, 0.712]}, {"w": "ideal", "b": [0.2997, 0.6906, 0.3395, 0.712]}, {"w": "to", "b": [0.3464, 0.6906, 0.3634, 0.712]}, {"w": "tackle", "b": [0.3703, 0.6906, 0.4191, 0.712]}, {"w": "large", "b": [0.426, 0.6906, 0.4667, 0.712]}, {"w": "and", "b": [0.4736, 0.6906, 0.5052, 0.712]}, {"w": "highly", "b": [0.5121, 0.6906, 0.5645, 0.712]}, {"w": "complex", "b": [0.5714, 0.6906, 0.6424, 0.712]}, {"w": "Machine", "b": [0.6493, 0.6906, 0.7224, 0.712]}, {"w": "Learning", "b": [0.7293, 0.6906, 0.8044, 0.712]}, {"w": "tasks,", "b": [0.8113, 0.6906, 0.8571, 0.712]}, {"w": "such", "b": [0.1429, 0.7096, 0.1815, 0.7311]}, {"w": "as", "b": [0.1868, 0.7096, 0.2036, 0.7311]}, {"w": "classifying", "b": [0.2088, 0.7096, 0.2958, 0.7311]}, {"w": "billions", "b": [0.301, 0.7096, 0.363, 0.7311]}, {"w": "of", "b": [0.3683, 0.7096, 0.3851, 0.7311]}, {"w": "images", "b": [0.3903, 0.7096, 0.4484, 0.7311]}, {"w": "(e.g.,", "b": [0.4537, 0.7096, 0.4937, 0.7311]}, {"w": "Google", "b": [0.499, 0.7096, 0.559, 0.7311]}, {"w": "Images),", "b": [0.5643, 0.7096, 0.6358, 0.7311]}, {"w": "powering", "b": [0.6411, 0.7096, 0.7202, 0.7311]}, {"w": "speech", "b": [0.7255, 0.7096, 0.7817, 0.7311]}, {"w": "recogni‐", "b": [0.787, 0.7096, 0.8571, 0.7311]}, {"w": "tion", "b": [0.1429, 0.7287, 0.1768, 0.7501]}, {"w": "services", "b": [0.1828, 0.7287, 0.2482, 0.7501]}, {"w": "(e.g.,", "b": [0.2541, 0.7287, 0.2942, 0.7501]}, {"w": "Apple’s", "b": [0.3002, 0.7287, 0.3588, 0.7501]}, {"w": "Siri),", "b": [0.3647, 0.7287, 0.4055, 0.7501]}, {"w": "recommending", "b": [0.4114, 0.7287, 0.5395, 0.7501]}, {"w": "the", "b": [0.5455, 0.7287, 0.5718, 0.7501]}, {"w": "best", "b": [0.5778, 0.7287, 0.6113, 0.7501]}, {"w": "videos", "b": [0.6172, 0.7287, 0.6706, 0.7501]}, {"w": "to", "b": [0.6765, 0.7287, 0.6935, 0.7501]}, {"w": "watch", "b": [0.6995, 0.7287, 0.7488, 0.7501]}, {"w": "to", "b": [0.7548, 0.7287, 0.7718, 0.7501]}, {"w": "hundreds", "b": [0.7777, 0.7287, 0.8571, 0.7501]}, {"w": "of", "b": [0.1429, 0.7477, 0.1597, 0.7691]}, {"w": "millions", "b": [0.1647, 0.7477, 0.2331, 0.7691]}, {"w": "of", "b": [0.2382, 0.7477, 0.255, 0.7691]}, {"w": "users", "b": [0.26, 0.7477, 0.3029, 0.7691]}, {"w": "every", "b": [0.308, 0.7477, 0.3532, 0.7691]}, {"w": "day", "b": [0.3583, 0.7477, 0.3876, 0.7691]}, {"w": "(e.g.,", "b": [0.3926, 0.7477, 0.4327, 0.7691]}, {"w": "YouTube),", "b": [0.4377, 0.7477, 0.5234, 0.7691]}, {"w": "or", "b": [0.5284, 0.7477, 0.5468, 0.7691]}, {"w": "learning", "b": [0.5518, 0.7477, 0.6209, 0.7691]}, {"w": "to", "b": [0.626, 0.7477, 0.643, 0.7691]}, {"w": "beat", "b": [0.648, 0.7477, 0.6825, 0.7691]}, {"w": "the", "b": [0.6876, 0.7477, 0.7139, 0.7691]}, {"w": "world", "b": [0.7189, 0.7477, 0.7678, 0.7691]}, {"w": "champion", "b": [0.7729, 0.7477, 0.8572, 0.7691]}, {"w": "at", "b": [0.1429, 0.7668, 0.158, 0.7882]}, {"w": "the", "b": [0.1659, 0.7668, 0.1923, 0.7882]}, {"w": "game", "b": [0.2002, 0.7668, 0.245, 0.7882]}, {"w": "of", "b": [0.253, 0.7668, 0.2698, 0.7882]}, {"w": "Go", "b": [0.2777, 0.7666, 0.3018, 0.7882]}, {"w": "by", "b": [0.3098, 0.7668, 0.3299, 0.7882]}, {"w": "playing", "b": [0.3379, 0.7668, 0.3991, 0.7882]}, {"w": "millions", "b": [0.4071, 0.7668, 0.4755, 0.7882]}, {"w": "of", "b": [0.4835, 0.7668, 0.5003, 0.7882]}, {"w": "games", "b": [0.5082, 0.7668, 0.5607, 0.7882]}, {"w": "against", "b": [0.5686, 0.7668, 0.6277, 0.7882]}, {"w": "itself", "b": [0.6356, 0.7668, 0.6755, 0.7882]}, {"w": "(DeepMind’s", "b": [0.6835, 0.7668, 0.7909, 0.7882]}, {"w": "Alpha‐", "b": [0.7989, 0.7668, 0.8571, 0.7882]}, {"w": "Zero).", "b": [0.1429, 0.7858, 0.1946, 0.8072]}]}, {"id": "b_6", "type": "paragraph", "text": "277", "words": [{"w": "277", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 304, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "2 “A Logical Calculus of Ideas Immanent in Nervous Activity,” W. McCulloch and W. Pitts (1943).", "words": [{"w": "2", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“A", "b": [0.1587, 0.8749, 0.1736, 0.8912]}, {"w": "Logical", "b": [0.1772, 0.8749, 0.2233, 0.8912]}, {"w": "Calculus", "b": [0.2269, 0.8749, 0.2818, 0.8912]}, {"w": "of", "b": [0.2854, 0.8749, 0.2982, 0.8912]}, {"w": "Ideas", "b": [0.3018, 0.8749, 0.3347, 0.8912]}, {"w": "Immanent", "b": [0.3383, 0.8749, 0.4054, 0.8912]}, {"w": "in", "b": [0.409, 0.8749, 0.4219, 0.8912]}, {"w": "Nervous", "b": [0.4255, 0.8749, 0.4797, 0.8912]}, {"w": "Activity,”", "b": [0.4833, 0.8749, 0.54, 0.8912]}, {"w": "W.", "b": [0.5437, 0.8749, 0.5604, 0.8912]}, {"w": "McCulloch", "b": [0.564, 0.8749, 0.6347, 0.8912]}, {"w": "and", "b": [0.6383, 0.8749, 0.6624, 0.8912]}, {"w": "W.", "b": [0.666, 0.8749, 0.6827, 0.8912]}, {"w": "Pitts", "b": [0.6863, 0.8749, 0.715, 0.8912]}, {"w": "(1943).", "b": [0.7186, 0.8749, 0.7637, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "In the first part of this chapter, we will introduce artificial neural networks, starting with a quick tour of the very first ANN architectures, leading up to Multi-Layer Per‐ ceptrons (MLPs) which are heavily used today (other architectures will be explored in the next chapters). In the second part, we will look at how to implement neural net‐ works using the popular Keras API. This is a beautifully designed and simple high- level API for building, training, evaluating and running neural networks. But don’t be fooled by its simplicity: it is expressive and flexible enough to let you build a wide variety of neural network architectures. In fact, it will probably be sufficient for most of your use cases. Moreover, should you ever need extra flexibility, you can always write custom Keras components using its lower-level API, as we will see in Chap‐ ter 12.", "words": [{"w": "In", "b": [0.1429, 0.0791, 0.1614, 0.1005]}, {"w": "the", "b": [0.1679, 0.0791, 0.1942, 0.1005]}, {"w": "first", "b": [0.2008, 0.0791, 0.2343, 0.1005]}, {"w": "part", "b": [0.2408, 0.0791, 0.2749, 0.1005]}, {"w": "of", "b": [0.2815, 0.0791, 0.2983, 0.1005]}, {"w": "this", "b": [0.3048, 0.0791, 0.3355, 0.1005]}, {"w": "chapter,", "b": [0.3421, 0.0791, 0.4081, 0.1005]}, {"w": "we", "b": [0.4146, 0.0791, 0.4377, 0.1005]}, {"w": "will", "b": [0.4443, 0.0791, 0.4747, 0.1005]}, {"w": "introduce", "b": [0.4812, 0.0791, 0.5622, 0.1005]}, {"w": "artificial", "b": [0.5688, 0.0791, 0.6381, 0.1005]}, {"w": "neural", "b": [0.6447, 0.0791, 0.6981, 0.1005]}, {"w": "networks,", "b": [0.7047, 0.0791, 0.7866, 0.1005]}, {"w": "starting", "b": [0.7932, 0.0791, 0.8571, 0.1005]}, {"w": "with", "b": [0.1429, 0.0981, 0.1802, 0.1195]}, {"w": "a", "b": [0.1861, 0.0981, 0.1952, 0.1195]}, {"w": "quick", "b": [0.2011, 0.0981, 0.2475, 0.1195]}, {"w": "tour", "b": [0.2534, 0.0981, 0.2891, 0.1195]}, {"w": "of", "b": [0.295, 0.0981, 0.3118, 0.1195]}, {"w": "the", "b": [0.3176, 0.0981, 0.344, 0.1195]}, {"w": "very", "b": [0.3498, 0.0981, 0.3862, 0.1195]}, {"w": "first", "b": [0.3921, 0.0981, 0.4256, 0.1195]}, {"w": "ANN", "b": [0.4314, 0.0981, 0.4768, 0.1195]}, {"w": "architectures,", "b": [0.4827, 0.0981, 0.5955, 0.1195]}, {"w": "leading", "b": [0.6013, 0.0981, 0.6623, 0.1195]}, {"w": "up", "b": [0.6682, 0.0981, 0.6902, 0.1195]}, {"w": "to", "b": [0.696, 0.0981, 0.713, 0.1195]}, {"w": "Multi-Layer", "b": [0.7189, 0.0979, 0.8173, 0.1195]}, {"w": "Per‐", "b": [0.8232, 0.0979, 0.8571, 0.1195]}, {"w": "ceptrons", "b": [0.1428, 0.117, 0.2099, 0.1386]}, {"w": "(MLPs)", "b": [0.2153, 0.1172, 0.2782, 0.1386]}, {"w": "which", "b": [0.2836, 0.1172, 0.3345, 0.1386]}, {"w": "are", "b": [0.3398, 0.1172, 0.3656, 0.1386]}, {"w": "heavily", "b": [0.3709, 0.1172, 0.4297, 0.1386]}, {"w": "used", "b": [0.435, 0.1172, 0.4736, 0.1386]}, {"w": "today", "b": [0.479, 0.1172, 0.5253, 0.1386]}, {"w": "(other", "b": [0.5306, 0.1172, 0.5825, 0.1386]}, {"w": "architectures", "b": [0.5878, 0.1172, 0.6959, 0.1386]}, {"w": "will", "b": [0.7012, 0.1172, 0.7316, 0.1386]}, {"w": "be", "b": [0.737, 0.1172, 0.7564, 0.1386]}, {"w": "explored", "b": [0.7617, 0.1172, 0.8348, 0.1386]}, {"w": "in", "b": [0.8402, 0.1172, 0.8571, 0.1386]}, {"w": "the", "b": [0.1429, 0.1362, 0.1692, 0.1576]}, {"w": "next", "b": [0.1752, 0.1362, 0.2117, 0.1576]}, {"w": "chapters).", "b": [0.2177, 0.1362, 0.2999, 0.1576]}, {"w": "In", "b": [0.3059, 0.1362, 0.3244, 0.1576]}, {"w": "the", "b": [0.3305, 0.1362, 0.3568, 0.1576]}, {"w": "second", "b": [0.3629, 0.1362, 0.4212, 0.1576]}, {"w": "part,", "b": [0.4273, 0.1362, 0.4661, 0.1576]}, {"w": "we", "b": [0.4722, 0.1362, 0.4953, 0.1576]}, {"w": "will", "b": [0.5014, 0.1362, 0.5318, 0.1576]}, {"w": "look", "b": [0.5378, 0.1362, 0.5747, 0.1576]}, {"w": "at", "b": [0.5807, 0.1362, 0.5958, 0.1576]}, {"w": "how", "b": [0.6019, 0.1362, 0.6379, 0.1576]}, {"w": "to", "b": [0.644, 0.1362, 0.6609, 0.1576]}, {"w": "implement", "b": [0.667, 0.1362, 0.7576, 0.1576]}, {"w": "neural", "b": [0.7636, 0.1362, 0.8171, 0.1576]}, {"w": "net‐", "b": [0.8231, 0.1362, 0.8571, 0.1576]}, {"w": "works", "b": [0.1428, 0.1553, 0.1935, 0.1767]}, {"w": "using", "b": [0.2002, 0.1553, 0.2456, 0.1767]}, {"w": "the", "b": [0.2524, 0.1553, 0.2787, 0.1767]}, {"w": "popular", "b": [0.2855, 0.1553, 0.3511, 0.1767]}, {"w": "Keras", "b": [0.3579, 0.1553, 0.4048, 0.1767]}, {"w": "API.", "b": [0.4115, 0.1553, 0.4495, 0.1767]}, {"w": "This", "b": [0.4562, 0.1553, 0.4935, 0.1767]}, {"w": "is", "b": [0.5002, 0.1553, 0.5134, 0.1767]}, {"w": "a", "b": [0.5202, 0.1553, 0.5293, 0.1767]}, {"w": "beautifully", "b": [0.5361, 0.1553, 0.6246, 0.1767]}, {"w": "designed", "b": [0.6313, 0.1553, 0.7054, 0.1767]}, {"w": "and", "b": [0.7122, 0.1553, 0.7437, 0.1767]}, {"w": "simple", "b": [0.7504, 0.1553, 0.8054, 0.1767]}, {"w": "high-", "b": [0.8121, 0.1553, 0.8571, 0.1767]}, {"w": "level", "b": [0.1429, 0.1743, 0.1808, 0.1957]}, {"w": "API", "b": [0.1858, 0.1743, 0.219, 0.1957]}, {"w": "for", "b": [0.224, 0.1743, 0.2485, 0.1957]}, {"w": "building,", "b": [0.2536, 0.1743, 0.3285, 0.1957]}, {"w": "training,", "b": [0.3335, 0.1743, 0.4052, 0.1957]}, {"w": "evaluating", "b": [0.4103, 0.1743, 0.4961, 0.1957]}, {"w": "and", "b": [0.5011, 0.1743, 0.5326, 0.1957]}, {"w": "running", "b": [0.5376, 0.1743, 0.6059, 0.1957]}, {"w": "neural", "b": [0.611, 0.1743, 0.6644, 0.1957]}, {"w": "networks.", "b": [0.6694, 0.1743, 0.7514, 0.1957]}, {"w": "But", "b": [0.7564, 0.1743, 0.7861, 0.1957]}, {"w": "don’t", "b": [0.7911, 0.1743, 0.8327, 0.1957]}, {"w": "be", "b": [0.8377, 0.1743, 0.8571, 0.1957]}, {"w": "fooled", "b": [0.1429, 0.1933, 0.1954, 0.2148]}, {"w": "by", "b": [0.2026, 0.1933, 0.2227, 0.2148]}, {"w": "its", "b": [0.23, 0.1933, 0.2495, 0.2148]}, {"w": "simplicity:", "b": [0.2567, 0.1933, 0.3441, 0.2148]}, {"w": "it", "b": [0.3513, 0.1933, 0.3633, 0.2148]}, {"w": "is", "b": [0.3705, 0.1933, 0.3837, 0.2148]}, {"w": "expressive", "b": [0.3909, 0.1933, 0.4765, 0.2148]}, {"w": "and", "b": [0.4837, 0.1933, 0.5152, 0.2148]}, {"w": "flexible", "b": [0.5224, 0.1933, 0.5828, 0.2148]}, {"w": "enough", "b": [0.59, 0.1933, 0.6528, 0.2148]}, {"w": "to", "b": [0.6601, 0.1933, 0.677, 0.2148]}, {"w": "let", "b": [0.6842, 0.1933, 0.7047, 0.2148]}, {"w": "you", "b": [0.7119, 0.1933, 0.7432, 0.2148]}, {"w": "build", "b": [0.7504, 0.1933, 0.7939, 0.2148]}, {"w": "a", "b": [0.8011, 0.1933, 0.8102, 0.2148]}, {"w": "wide", "b": [0.8174, 0.1933, 0.8571, 0.2148]}, {"w": "variety", "b": [0.1429, 0.2124, 0.1997, 0.2338]}, {"w": "of", "b": [0.2052, 0.2124, 0.222, 0.2338]}, {"w": "neural", "b": [0.2275, 0.2124, 0.281, 0.2338]}, {"w": "network", "b": [0.2865, 0.2124, 0.356, 0.2338]}, {"w": "architectures.", "b": [0.3615, 0.2124, 0.4743, 0.2338]}, {"w": "In", "b": [0.4798, 0.2124, 0.4983, 0.2338]}, {"w": "fact,", "b": [0.5038, 0.2124, 0.539, 0.2338]}, {"w": "it", "b": [0.5445, 0.2124, 0.5565, 0.2338]}, {"w": "will", "b": [0.562, 0.2124, 0.5924, 0.2338]}, {"w": "probably", "b": [0.5979, 0.2124, 0.6723, 0.2338]}, {"w": "be", "b": [0.6778, 0.2124, 0.6972, 0.2338]}, {"w": "sufficient", "b": [0.7027, 0.2124, 0.7799, 0.2338]}, {"w": "for", "b": [0.7854, 0.2124, 0.81, 0.2338]}, {"w": "most", "b": [0.8154, 0.2124, 0.8571, 0.2338]}, {"w": "of", "b": [0.1429, 0.2314, 0.1597, 0.2529]}, {"w": "your", "b": [0.1671, 0.2314, 0.206, 0.2529]}, {"w": "use", "b": [0.2135, 0.2314, 0.241, 0.2529]}, {"w": "cases.", "b": [0.2484, 0.2314, 0.2953, 0.2529]}, {"w": "Moreover,", "b": [0.3027, 0.2314, 0.3882, 0.2529]}, {"w": "should", "b": [0.3956, 0.2314, 0.4524, 0.2529]}, {"w": "you", "b": [0.4598, 0.2314, 0.491, 0.2529]}, {"w": "ever", "b": [0.4984, 0.2314, 0.5335, 0.2529]}, {"w": "need", "b": [0.5409, 0.2314, 0.581, 0.2529]}, {"w": "extra", "b": [0.5884, 0.2314, 0.6304, 0.2529]}, {"w": "flexibility,", "b": [0.6378, 0.2314, 0.7196, 0.2529]}, {"w": "you", "b": [0.7271, 0.2314, 0.7583, 0.2529]}, {"w": "can", "b": [0.7657, 0.2314, 0.7951, 0.2529]}, {"w": "always", "b": [0.8025, 0.2314, 0.8572, 0.2529]}, {"w": "write", "b": [0.1429, 0.2505, 0.1857, 0.2719]}, {"w": "custom", "b": [0.1934, 0.2505, 0.255, 0.2719]}, {"w": "Keras", "b": [0.2627, 0.2505, 0.3096, 0.2719]}, {"w": "components", "b": [0.3174, 0.2505, 0.4203, 0.2719]}, {"w": "using", "b": [0.428, 0.2505, 0.4735, 0.2719]}, {"w": "its", "b": [0.4812, 0.2505, 0.5008, 0.2719]}, {"w": "lower-level", "b": [0.5086, 0.2505, 0.6001, 0.2719]}, {"w": "API,", "b": [0.6079, 0.2505, 0.6459, 0.2719]}, {"w": "as", "b": [0.6536, 0.2505, 0.6704, 0.2719]}, {"w": "we", "b": [0.6782, 0.2505, 0.7013, 0.2719]}, {"w": "will", "b": [0.7091, 0.2505, 0.7395, 0.2719]}, {"w": "see", "b": [0.7472, 0.2505, 0.7726, 0.2719]}, {"w": "in", "b": [0.7803, 0.2505, 0.7973, 0.2719]}, {"w": "Chap‐", "b": [0.8051, 0.2505, 0.8571, 0.2719]}, {"w": "ter", "b": [0.1429, 0.2695, 0.1658, 0.291]}, {"w": "12.", "b": [0.1705, 0.2695, 0.1953, 0.291]}]}, {"id": "b_2", "type": "paragraph", "text": "But first, let’s go back in time to see how artificial neural networks came to be!", "words": [{"w": "But", "b": [0.1429, 0.2977, 0.1725, 0.3191]}, {"w": "first,", "b": [0.1773, 0.2977, 0.2155, 0.3191]}, {"w": "let’s", "b": [0.2202, 0.2977, 0.2504, 0.3191]}, {"w": "go", "b": [0.2552, 0.2977, 0.2755, 0.3191]}, {"w": "back", "b": [0.2803, 0.2977, 0.3191, 0.3191]}, {"w": "in", "b": [0.3239, 0.2977, 0.3409, 0.3191]}, {"w": "time", "b": [0.3456, 0.2977, 0.3834, 0.3191]}, {"w": "to", "b": [0.3882, 0.2977, 0.4051, 0.3191]}, {"w": "see", "b": [0.4099, 0.2977, 0.4352, 0.3191]}, {"w": "how", "b": [0.44, 0.2977, 0.476, 0.3191]}, {"w": "artificial", "b": [0.4807, 0.2977, 0.5501, 0.3191]}, {"w": "neural", "b": [0.5548, 0.2977, 0.6083, 0.3191]}, {"w": "networks", "b": [0.613, 0.2977, 0.6902, 0.3191]}, {"w": "came", "b": [0.6949, 0.2977, 0.7388, 0.3191]}, {"w": "to", "b": [0.7435, 0.2977, 0.7605, 0.3191]}, {"w": "be!", "b": [0.7653, 0.2977, 0.7904, 0.3191]}]}, {"id": "b_3", "type": "paragraph", "text": "From Biological to Artificial Neurons", "words": [{"w": "From", "b": [0.1428, 0.3321, 0.2069, 0.3663]}, {"w": "Biological", "b": [0.2129, 0.3321, 0.3344, 0.3663]}, {"w": "to", "b": [0.3403, 0.3321, 0.3664, 0.3663]}, {"w": "Artificial", "b": [0.3724, 0.3321, 0.4772, 0.3663]}, {"w": "Neurons", "b": [0.4831, 0.3321, 0.586, 0.3663]}]}, {"id": "b_4", "type": "paragraph", "text": "Surprisingly, ANNs have been around for quite a while: they were first introduced back in 1943 by the neurophysiologist Warren McCulloch and the mathematician Walter Pitts. In their landmark paper,2 “A Logical Calculus of Ideas Immanent in Nervous Activity,” McCulloch and Pitts presented a simplified computational model of how biological neurons might work together in animal brains to perform complex computations using propositional logic. This was the first artificial neural network architecture. Since then many other architectures have been invented, as we will see.", "words": [{"w": "Surprisingly,", "b": [0.1429, 0.3732, 0.2482, 0.3947]}, {"w": "ANNs", "b": [0.2557, 0.3732, 0.3082, 0.3947]}, {"w": "have", "b": [0.3157, 0.3732, 0.3541, 0.3947]}, {"w": "been", "b": [0.3616, 0.3732, 0.4013, 0.3947]}, {"w": "around", "b": [0.4088, 0.3732, 0.4698, 0.3947]}, {"w": "for", "b": [0.4773, 0.3732, 0.5018, 0.3947]}, {"w": "quite", "b": [0.5094, 0.3732, 0.5519, 0.3947]}, {"w": "a", "b": [0.5594, 0.3732, 0.5685, 0.3947]}, {"w": "while:", "b": [0.5761, 0.3732, 0.6259, 0.3947]}, {"w": "they", "b": [0.6334, 0.3732, 0.6693, 0.3947]}, {"w": "were", "b": [0.6769, 0.3732, 0.7166, 0.3947]}, {"w": "first", "b": [0.7241, 0.3732, 0.7576, 0.3947]}, {"w": "introduced", "b": [0.7651, 0.3732, 0.8571, 0.3947]}, {"w": "back", "b": [0.1429, 0.3923, 0.1817, 0.4137]}, {"w": "in", "b": [0.1901, 0.3923, 0.2071, 0.4137]}, {"w": "1943", "b": [0.2154, 0.3923, 0.2554, 0.4137]}, {"w": "by", "b": [0.2638, 0.3923, 0.2839, 0.4137]}, {"w": "the", "b": [0.2923, 0.3923, 0.3186, 0.4137]}, {"w": "neurophysiologist", "b": [0.3269, 0.3923, 0.4768, 0.4137]}, {"w": "Warren", "b": [0.4852, 0.3923, 0.5482, 0.4137]}, {"w": "McCulloch", "b": [0.5565, 0.3923, 0.6494, 0.4137]}, {"w": "and", "b": [0.6577, 0.3923, 0.6893, 0.4137]}, {"w": "the", "b": [0.6976, 0.3923, 0.724, 0.4137]}, {"w": "mathematician", "b": [0.7323, 0.3923, 0.8572, 0.4137]}, {"w": "Walter", "b": [0.1429, 0.4113, 0.1984, 0.4327]}, {"w": "Pitts.", "b": [0.2069, 0.4113, 0.2493, 0.4327]}, {"w": "In", "b": [0.2579, 0.4113, 0.2764, 0.4327]}, {"w": "their", "b": [0.2849, 0.4113, 0.3245, 0.4327]}, {"w": "landmark", "b": [0.3331, 0.4113, 0.4142, 0.4327]}, {"w": "paper,2", "b": [0.4227, 0.4113, 0.4803, 0.4327]}, {"w": "“A", "b": [0.4889, 0.4113, 0.5084, 0.4327]}, {"w": "Logical", "b": [0.517, 0.4113, 0.5774, 0.4327]}, {"w": "Calculus", "b": [0.5859, 0.4113, 0.658, 0.4327]}, {"w": "of", "b": [0.6666, 0.4113, 0.6834, 0.4327]}, {"w": "Ideas", "b": [0.6919, 0.4113, 0.7351, 0.4327]}, {"w": "Immanent", "b": [0.7437, 0.4113, 0.8316, 0.4327]}, {"w": "in", "b": [0.8402, 0.4113, 0.8571, 0.4327]}, {"w": "Nervous", "b": [0.1429, 0.4304, 0.214, 0.4518]}, {"w": "Activity,”", "b": [0.2205, 0.4304, 0.295, 0.4518]}, {"w": "McCulloch", "b": [0.3015, 0.4304, 0.3943, 0.4518]}, {"w": "and", "b": [0.4008, 0.4304, 0.4324, 0.4518]}, {"w": "Pitts", "b": [0.4389, 0.4304, 0.4766, 0.4518]}, {"w": "presented", "b": [0.4831, 0.4304, 0.5643, 0.4518]}, {"w": "a", "b": [0.5708, 0.4304, 0.5799, 0.4518]}, {"w": "simplified", "b": [0.5865, 0.4304, 0.6697, 0.4518]}, {"w": "computational", "b": [0.6763, 0.4304, 0.7978, 0.4518]}, {"w": "model", "b": [0.8043, 0.4304, 0.8571, 0.4518]}, {"w": "of", "b": [0.1428, 0.4494, 0.1596, 0.4708]}, {"w": "how", "b": [0.1651, 0.4494, 0.2011, 0.4708]}, {"w": "biological", "b": [0.2066, 0.4494, 0.2879, 0.4708]}, {"w": "neurons", "b": [0.2933, 0.4494, 0.3621, 0.4708]}, {"w": "might", "b": [0.3675, 0.4494, 0.417, 0.4708]}, {"w": "work", "b": [0.4225, 0.4494, 0.4654, 0.4708]}, {"w": "together", "b": [0.4709, 0.4494, 0.5406, 0.4708]}, {"w": "in", "b": [0.546, 0.4494, 0.563, 0.4708]}, {"w": "animal", "b": [0.5685, 0.4494, 0.6261, 0.4708]}, {"w": "brains", "b": [0.6316, 0.4494, 0.6837, 0.4708]}, {"w": "to", "b": [0.6891, 0.4494, 0.7061, 0.4708]}, {"w": "perform", "b": [0.7116, 0.4494, 0.7807, 0.4708]}, {"w": "complex", "b": [0.7862, 0.4494, 0.8571, 0.4708]}, {"w": "computations", "b": [0.1429, 0.4685, 0.2577, 0.4899]}, {"w": "using", "b": [0.2662, 0.4685, 0.3116, 0.4899]}, {"w": "propositional", "b": [0.3202, 0.4683, 0.4263, 0.4899]}, {"w": "logic.", "b": [0.4349, 0.4683, 0.477, 0.4899]}, {"w": "This", "b": [0.4855, 0.4685, 0.5227, 0.4899]}, {"w": "was", "b": [0.5312, 0.4685, 0.5623, 0.4899]}, {"w": "the", "b": [0.5708, 0.4685, 0.5972, 0.4899]}, {"w": "first", "b": [0.6057, 0.4685, 0.6392, 0.4899]}, {"w": "artificial", "b": [0.6477, 0.4685, 0.7171, 0.4899]}, {"w": "neural", "b": [0.7256, 0.4685, 0.7791, 0.4899]}, {"w": "network", "b": [0.7876, 0.4685, 0.8571, 0.4899]}, {"w": "architecture.", "b": [0.1429, 0.4875, 0.248, 0.5089]}, {"w": "Since", "b": [0.2528, 0.4875, 0.2973, 0.5089]}, {"w": "then", "b": [0.302, 0.4875, 0.3397, 0.5089]}, {"w": "many", "b": [0.3445, 0.4875, 0.3911, 0.5089]}, {"w": "other", "b": [0.3959, 0.4875, 0.4406, 0.5089]}, {"w": "architectures", "b": [0.4453, 0.4875, 0.5534, 0.5089]}, {"w": "have", "b": [0.5581, 0.4875, 0.5965, 0.5089]}, {"w": "been", "b": [0.6012, 0.4875, 0.6409, 0.5089]}, {"w": "invented,", "b": [0.6456, 0.4875, 0.7226, 0.5089]}, {"w": "as", "b": [0.7273, 0.4875, 0.7441, 0.5089]}, {"w": "we", "b": [0.7488, 0.4875, 0.772, 0.5089]}, {"w": "will", "b": [0.7767, 0.4875, 0.8071, 0.5089]}, {"w": "see.", "b": [0.8118, 0.4875, 0.8419, 0.5089]}]}, {"id": "b_5", "type": "paragraph", "text": "The early successes of ANNs until the 1960s led to the widespread belief that we would soon be conversing with truly intelligent machines. When it became clear that this promise would go unfulfilled (at least for quite a while), funding flew elsewhere and ANNs entered a long winter. In the early 1980s there was a revival of interest in connectionism (the study of neural networks), as new architectures were invented and better training techniques were developed. But progress was slow, and by the 1990s other powerful Machine Learning techniques were invented, such as Support Vector Machines (see Chapter 5). These techniques seemed to offer better results and stron‐ ger theoretical foundations than ANNs, so once again the study of neural networks entered a long winter.", "words": [{"w": "The", "b": [0.1429, 0.5156, 0.1757, 0.5371]}, {"w": "early", "b": [0.184, 0.5156, 0.2246, 0.5371]}, {"w": "successes", "b": [0.233, 0.5156, 0.3099, 0.5371]}, {"w": "of", "b": [0.3183, 0.5156, 0.3351, 0.5371]}, {"w": "ANNs", "b": [0.3434, 0.5156, 0.3959, 0.5371]}, {"w": "until", "b": [0.4042, 0.5156, 0.4435, 0.5371]}, {"w": "the", "b": [0.4519, 0.5156, 0.4782, 0.5371]}, {"w": "1960s", "b": [0.4866, 0.5156, 0.5342, 0.5371]}, {"w": "led", "b": [0.5426, 0.5156, 0.5677, 0.5371]}, {"w": "to", "b": [0.576, 0.5156, 0.593, 0.5371]}, {"w": "the", "b": [0.6014, 0.5156, 0.6277, 0.5371]}, {"w": "widespread", "b": [0.6361, 0.5156, 0.7311, 0.5371]}, {"w": "belief", "b": [0.7394, 0.5156, 0.7847, 0.5371]}, {"w": "that", "b": [0.7931, 0.5156, 0.8257, 0.5371]}, {"w": "we", "b": [0.834, 0.5156, 0.8571, 0.5371]}, {"w": "would", "b": [0.1429, 0.5347, 0.1951, 0.5561]}, {"w": "soon", "b": [0.2006, 0.5347, 0.2409, 0.5561]}, {"w": "be", "b": [0.2465, 0.5347, 0.2659, 0.5561]}, {"w": "conversing", "b": [0.2714, 0.5347, 0.3624, 0.5561]}, {"w": "with", "b": [0.368, 0.5347, 0.4053, 0.5561]}, {"w": "truly", "b": [0.4108, 0.5347, 0.4508, 0.5561]}, {"w": "intelligent", "b": [0.4564, 0.5347, 0.5402, 0.5561]}, {"w": "machines.", "b": [0.5458, 0.5347, 0.6302, 0.5561]}, {"w": "When", "b": [0.6357, 0.5347, 0.6873, 0.5561]}, {"w": "it", "b": [0.6929, 0.5347, 0.7048, 0.5561]}, {"w": "became", "b": [0.7103, 0.5347, 0.7736, 0.5561]}, {"w": "clear", "b": [0.7792, 0.5347, 0.819, 0.5561]}, {"w": "that", "b": [0.8246, 0.5347, 0.8571, 0.5561]}, {"w": "this", "b": [0.1429, 0.5537, 0.1736, 0.5752]}, {"w": "promise", "b": [0.1797, 0.5537, 0.2482, 0.5752]}, {"w": "would", "b": [0.2543, 0.5537, 0.3066, 0.5752]}, {"w": "go", "b": [0.3127, 0.5537, 0.3331, 0.5752]}, {"w": "unfulfilled", "b": [0.3393, 0.5537, 0.4264, 0.5752]}, {"w": "(at", "b": [0.4326, 0.5537, 0.4549, 0.5752]}, {"w": "least", "b": [0.4611, 0.5537, 0.4983, 0.5752]}, {"w": "for", "b": [0.5045, 0.5537, 0.529, 0.5752]}, {"w": "quite", "b": [0.5352, 0.5537, 0.5777, 0.5752]}, {"w": "a", "b": [0.5839, 0.5537, 0.593, 0.5752]}, {"w": "while),", "b": [0.5992, 0.5537, 0.6563, 0.5752]}, {"w": "funding", "b": [0.6624, 0.5537, 0.7288, 0.5752]}, {"w": "flew", "b": [0.735, 0.5537, 0.7695, 0.5752]}, {"w": "elsewhere", "b": [0.7757, 0.5537, 0.8572, 0.5752]}, {"w": "and", "b": [0.1429, 0.5728, 0.1744, 0.5942]}, {"w": "ANNs", "b": [0.1801, 0.5728, 0.2325, 0.5942]}, {"w": "entered", "b": [0.2381, 0.5728, 0.3008, 0.5942]}, {"w": "a", "b": [0.3064, 0.5728, 0.3156, 0.5942]}, {"w": "long", "b": [0.3212, 0.5728, 0.3583, 0.5942]}, {"w": "winter.", "b": [0.3639, 0.5728, 0.4212, 0.5942]}, {"w": "In", "b": [0.4268, 0.5728, 0.4453, 0.5942]}, {"w": "the", "b": [0.451, 0.5728, 0.4773, 0.5942]}, {"w": "early", "b": [0.4829, 0.5728, 0.5235, 0.5942]}, {"w": "1980s", "b": [0.5292, 0.5728, 0.5768, 0.5942]}, {"w": "there", "b": [0.5824, 0.5728, 0.6254, 0.5942]}, {"w": "was", "b": [0.631, 0.5728, 0.6621, 0.5942]}, {"w": "a", "b": [0.6677, 0.5728, 0.6769, 0.5942]}, {"w": "revival", "b": [0.6825, 0.5728, 0.7384, 0.5942]}, {"w": "of", "b": [0.744, 0.5728, 0.7608, 0.5942]}, {"w": "interest", "b": [0.7665, 0.5728, 0.8289, 0.5942]}, {"w": "in", "b": [0.8345, 0.5728, 0.8515, 0.5942]}, {"w": "connectionism", "b": [0.1429, 0.5916, 0.2593, 0.6132]}, {"w": "(the", "b": [0.2644, 0.5918, 0.298, 0.6132]}, {"w": "study", "b": [0.3031, 0.5918, 0.3487, 0.6132]}, {"w": "of", "b": [0.3538, 0.5918, 0.3706, 0.6132]}, {"w": "neural", "b": [0.3758, 0.5918, 0.4292, 0.6132]}, {"w": "networks),", "b": [0.4344, 0.5918, 0.5235, 0.6132]}, {"w": "as", "b": [0.5287, 0.5918, 0.5455, 0.6132]}, {"w": "new", "b": [0.5506, 0.5918, 0.5851, 0.6132]}, {"w": "architectures", "b": [0.5902, 0.5918, 0.6983, 0.6132]}, {"w": "were", "b": [0.7034, 0.5918, 0.7431, 0.6132]}, {"w": "invented", "b": [0.7483, 0.5918, 0.8205, 0.6132]}, {"w": "and", "b": [0.8256, 0.5918, 0.8572, 0.6132]}, {"w": "better", "b": [0.1429, 0.6109, 0.1916, 0.6323]}, {"w": "training", "b": [0.1983, 0.6109, 0.2652, 0.6323]}, {"w": "techniques", "b": [0.2719, 0.6109, 0.3623, 0.6323]}, {"w": "were", "b": [0.369, 0.6109, 0.4087, 0.6323]}, {"w": "developed.", "b": [0.4154, 0.6109, 0.5052, 0.6323]}, {"w": "But", "b": [0.5119, 0.6109, 0.5415, 0.6323]}, {"w": "progress", "b": [0.5482, 0.6109, 0.6191, 0.6323]}, {"w": "was", "b": [0.6258, 0.6109, 0.6569, 0.6323]}, {"w": "slow,", "b": [0.6636, 0.6109, 0.7047, 0.6323]}, {"w": "and", "b": [0.7114, 0.6109, 0.7429, 0.6323]}, {"w": "by", "b": [0.7496, 0.6109, 0.7698, 0.6323]}, {"w": "the", "b": [0.7765, 0.6109, 0.8028, 0.6323]}, {"w": "1990s", "b": [0.8095, 0.6109, 0.8571, 0.6323]}, {"w": "other", "b": [0.1429, 0.6299, 0.1875, 0.6513]}, {"w": "powerful", "b": [0.1937, 0.6299, 0.2686, 0.6513]}, {"w": "Machine", "b": [0.2748, 0.6299, 0.3479, 0.6513]}, {"w": "Learning", "b": [0.354, 0.6299, 0.4291, 0.6513]}, {"w": "techniques", "b": [0.4353, 0.6299, 0.5256, 0.6513]}, {"w": "were", "b": [0.5318, 0.6299, 0.5715, 0.6513]}, {"w": "invented,", "b": [0.5776, 0.6299, 0.6546, 0.6513]}, {"w": "such", "b": [0.6607, 0.6299, 0.6994, 0.6513]}, {"w": "as", "b": [0.7056, 0.6299, 0.7223, 0.6513]}, {"w": "Support", "b": [0.7285, 0.6299, 0.796, 0.6513]}, {"w": "Vector", "b": [0.8021, 0.6299, 0.8571, 0.6513]}, {"w": "Machines", "b": [0.1429, 0.649, 0.2236, 0.6704]}, {"w": "(see", "b": [0.2292, 0.649, 0.2618, 0.6704]}, {"w": "Chapter", "b": [0.2673, 0.649, 0.3349, 0.6704]}, {"w": "5).", "b": [0.3405, 0.649, 0.3625, 0.6704]}, {"w": "These", "b": [0.368, 0.649, 0.4174, 0.6704]}, {"w": "techniques", "b": [0.423, 0.649, 0.5133, 0.6704]}, {"w": "seemed", "b": [0.5189, 0.649, 0.5811, 0.6704]}, {"w": "to", "b": [0.5867, 0.649, 0.6037, 0.6704]}, {"w": "offer", "b": [0.6093, 0.649, 0.6488, 0.6704]}, {"w": "better", "b": [0.6544, 0.649, 0.7031, 0.6704]}, {"w": "results", "b": [0.7087, 0.649, 0.7633, 0.6704]}, {"w": "and", "b": [0.7688, 0.649, 0.8004, 0.6704]}, {"w": "stron‐", "b": [0.806, 0.649, 0.8571, 0.6704]}, {"w": "ger", "b": [0.1429, 0.668, 0.1692, 0.6894]}, {"w": "theoretical", "b": [0.176, 0.668, 0.2647, 0.6894]}, {"w": "foundations", "b": [0.2714, 0.668, 0.372, 0.6894]}, {"w": "than", "b": [0.3788, 0.668, 0.4168, 0.6894]}, {"w": "ANNs,", "b": [0.4235, 0.668, 0.4807, 0.6894]}, {"w": "so", "b": [0.4875, 0.668, 0.5058, 0.6894]}, {"w": "once", "b": [0.5125, 0.668, 0.5522, 0.6894]}, {"w": "again", "b": [0.5589, 0.668, 0.604, 0.6894]}, {"w": "the", "b": [0.6107, 0.668, 0.6371, 0.6894]}, {"w": "study", "b": [0.6438, 0.668, 0.6894, 0.6894]}, {"w": "of", "b": [0.6962, 0.668, 0.713, 0.6894]}, {"w": "neural", "b": [0.7197, 0.668, 0.7732, 0.6894]}, {"w": "networks", "b": [0.7799, 0.668, 0.8572, 0.6894]}, {"w": "entered", "b": [0.1429, 0.6871, 0.2055, 0.7085]}, {"w": "a", "b": [0.2102, 0.6871, 0.2194, 0.7085]}, {"w": "long", "b": [0.2241, 0.6871, 0.2612, 0.7085]}, {"w": "winter.", "b": [0.2659, 0.6871, 0.3231, 0.7085]}]}, {"id": "b_6", "type": "paragraph", "text": "Finally, we are now witnessing yet another wave of interest in ANNs. Will this wave die out like the previous ones did? Well, there are a few good reasons to believe that this wave is different and that it will have a much more profound impact on our lives:", "words": [{"w": "Finally,", "b": [0.1429, 0.7152, 0.2033, 0.7366]}, {"w": "we", "b": [0.2096, 0.7152, 0.2327, 0.7366]}, {"w": "are", "b": [0.239, 0.7152, 0.2647, 0.7366]}, {"w": "now", "b": [0.271, 0.7152, 0.3072, 0.7366]}, {"w": "witnessing", "b": [0.3135, 0.7152, 0.402, 0.7366]}, {"w": "yet", "b": [0.4082, 0.7152, 0.433, 0.7366]}, {"w": "another", "b": [0.4393, 0.7152, 0.5045, 0.7366]}, {"w": "wave", "b": [0.5107, 0.7152, 0.5523, 0.7366]}, {"w": "of", "b": [0.5585, 0.7152, 0.5753, 0.7366]}, {"w": "interest", "b": [0.5816, 0.7152, 0.644, 0.7366]}, {"w": "in", "b": [0.6502, 0.7152, 0.6672, 0.7366]}, {"w": "ANNs.", "b": [0.6734, 0.7152, 0.7306, 0.7366]}, {"w": "Will", "b": [0.7369, 0.7152, 0.7724, 0.7366]}, {"w": "this", "b": [0.7786, 0.7152, 0.8094, 0.7366]}, {"w": "wave", "b": [0.8156, 0.7152, 0.8571, 0.7366]}, {"w": "die", "b": [0.1429, 0.7342, 0.1683, 0.7557]}, {"w": "out", "b": [0.1743, 0.7342, 0.2024, 0.7557]}, {"w": "like", "b": [0.2084, 0.7342, 0.2385, 0.7557]}, {"w": "the", "b": [0.2445, 0.7342, 0.2708, 0.7557]}, {"w": "previous", "b": [0.2769, 0.7342, 0.3489, 0.7557]}, {"w": "ones", "b": [0.355, 0.7342, 0.3935, 0.7557]}, {"w": "did?", "b": [0.3995, 0.7342, 0.435, 0.7557]}, {"w": "Well,", "b": [0.4411, 0.7342, 0.4834, 0.7557]}, {"w": "there", "b": [0.4895, 0.7342, 0.5324, 0.7557]}, {"w": "are", "b": [0.5384, 0.7342, 0.5642, 0.7557]}, {"w": "a", "b": [0.5702, 0.7342, 0.5793, 0.7557]}, {"w": "few", "b": [0.5854, 0.7342, 0.6147, 0.7557]}, {"w": "good", "b": [0.6207, 0.7342, 0.6627, 0.7557]}, {"w": "reasons", "b": [0.6688, 0.7342, 0.7318, 0.7557]}, {"w": "to", "b": [0.7378, 0.7342, 0.7548, 0.7557]}, {"w": "believe", "b": [0.7609, 0.7342, 0.8185, 0.7557]}, {"w": "that", "b": [0.8246, 0.7342, 0.8571, 0.7557]}, {"w": "this", "b": [0.1429, 0.7533, 0.1736, 0.7747]}, {"w": "wave", "b": [0.1783, 0.7533, 0.2198, 0.7747]}, {"w": "is", "b": [0.2246, 0.7533, 0.2378, 0.7747]}, {"w": "different", "b": [0.2425, 0.7533, 0.3142, 0.7747]}, {"w": "and", "b": [0.319, 0.7533, 0.3505, 0.7747]}, {"w": "that", "b": [0.3552, 0.7533, 0.3878, 0.7747]}, {"w": "it", "b": [0.3926, 0.7533, 0.4045, 0.7747]}, {"w": "will", "b": [0.4092, 0.7533, 0.4396, 0.7747]}, {"w": "have", "b": [0.4443, 0.7533, 0.4827, 0.7747]}, {"w": "a", "b": [0.4875, 0.7533, 0.4966, 0.7747]}, {"w": "much", "b": [0.5013, 0.7533, 0.549, 0.7747]}, {"w": "more", "b": [0.5537, 0.7533, 0.598, 0.7747]}, {"w": "profound", "b": [0.6027, 0.7533, 0.6823, 0.7747]}, {"w": "impact", "b": [0.687, 0.7533, 0.7445, 0.7747]}, {"w": "on", "b": [0.7492, 0.7533, 0.7712, 0.7747]}, {"w": "our", "b": [0.776, 0.7533, 0.8054, 0.7747]}, {"w": "lives:", "b": [0.8101, 0.7533, 0.8518, 0.7747]}]}, {"id": "b_7", "type": "paragraph", "text": "278 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "278", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4163, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4583, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 305, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• There is now a huge quantity of data available to train neural networks, and ANNs frequently outperform other ML techniques on very large and complex problems.", "words": [{"w": "•", "b": [0.16, 0.0851, 0.1682, 0.1065]}, {"w": "There", "b": [0.1786, 0.0851, 0.228, 0.1065]}, {"w": "is", "b": [0.2366, 0.0851, 0.2498, 0.1065]}, {"w": "now", "b": [0.2584, 0.0851, 0.2947, 0.1065]}, {"w": "a", "b": [0.3033, 0.0851, 0.3125, 0.1065]}, {"w": "huge", "b": [0.3211, 0.0851, 0.3615, 0.1065]}, {"w": "quantity", "b": [0.3701, 0.0851, 0.4398, 0.1065]}, {"w": "of", "b": [0.4484, 0.0851, 0.4652, 0.1065]}, {"w": "data", "b": [0.4738, 0.0851, 0.5091, 0.1065]}, {"w": "available", "b": [0.5177, 0.0851, 0.5899, 0.1065]}, {"w": "to", "b": [0.5986, 0.0851, 0.6155, 0.1065]}, {"w": "train", "b": [0.6241, 0.0851, 0.6643, 0.1065]}, {"w": "neural", "b": [0.673, 0.0851, 0.7264, 0.1065]}, {"w": "networks,", "b": [0.735, 0.0851, 0.817, 0.1065]}, {"w": "and", "b": [0.8256, 0.0851, 0.8571, 0.1065]}, {"w": "ANNs", "b": [0.1786, 0.1042, 0.231, 0.1256]}, {"w": "frequently", "b": [0.2387, 0.1042, 0.3242, 0.1256]}, {"w": "outperform", "b": [0.3319, 0.1042, 0.429, 0.1256]}, {"w": "other", "b": [0.4367, 0.1042, 0.4814, 0.1256]}, {"w": "ML", "b": [0.4891, 0.1042, 0.5189, 0.1256]}, {"w": "techniques", "b": [0.5266, 0.1042, 0.6169, 0.1256]}, {"w": "on", "b": [0.6246, 0.1042, 0.6467, 0.1256]}, {"w": "very", "b": [0.6544, 0.1042, 0.6908, 0.1256]}, {"w": "large", "b": [0.6985, 0.1042, 0.7392, 0.1256]}, {"w": "and", "b": [0.7469, 0.1042, 0.7785, 0.1256]}, {"w": "complex", "b": [0.7862, 0.1042, 0.8571, 0.1256]}, {"w": "problems.", "b": [0.1786, 0.1232, 0.262, 0.1446]}]}, {"id": "b_1", "type": "paragraph", "text": "• The tremendous increase in computing power since the 1990s now makes it pos‐ sible to train large neural networks in a reasonable amount of time. This is in part due to Moore’s Law, but also thanks to the gaming industry, which has pro‐ duced powerful GPU cards by the millions.", "words": [{"w": "•", "b": [0.16, 0.1483, 0.1682, 0.1697]}, {"w": "The", "b": [0.1786, 0.1483, 0.2114, 0.1697]}, {"w": "tremendous", "b": [0.2166, 0.1483, 0.3172, 0.1697]}, {"w": "increase", "b": [0.3224, 0.1483, 0.3904, 0.1697]}, {"w": "in", "b": [0.3956, 0.1483, 0.4126, 0.1697]}, {"w": "computing", "b": [0.4178, 0.1483, 0.509, 0.1697]}, {"w": "power", "b": [0.5142, 0.1483, 0.5666, 0.1697]}, {"w": "since", "b": [0.5718, 0.1483, 0.6141, 0.1697]}, {"w": "the", "b": [0.6193, 0.1483, 0.6456, 0.1697]}, {"w": "1990s", "b": [0.6508, 0.1483, 0.6984, 0.1697]}, {"w": "now", "b": [0.7037, 0.1483, 0.7399, 0.1697]}, {"w": "makes", "b": [0.7451, 0.1483, 0.7982, 0.1697]}, {"w": "it", "b": [0.8034, 0.1483, 0.8153, 0.1697]}, {"w": "pos‐", "b": [0.8205, 0.1483, 0.8571, 0.1697]}, {"w": "sible", "b": [0.1786, 0.1673, 0.2165, 0.1888]}, {"w": "to", "b": [0.224, 0.1673, 0.241, 0.1888]}, {"w": "train", "b": [0.2484, 0.1673, 0.2886, 0.1888]}, {"w": "large", "b": [0.2961, 0.1673, 0.3369, 0.1888]}, {"w": "neural", "b": [0.3443, 0.1673, 0.3978, 0.1888]}, {"w": "networks", "b": [0.4053, 0.1673, 0.4825, 0.1888]}, {"w": "in", "b": [0.4899, 0.1673, 0.5069, 0.1888]}, {"w": "a", "b": [0.5144, 0.1673, 0.5235, 0.1888]}, {"w": "reasonable", "b": [0.531, 0.1673, 0.6203, 0.1888]}, {"w": "amount", "b": [0.6277, 0.1673, 0.693, 0.1888]}, {"w": "of", "b": [0.7004, 0.1673, 0.7172, 0.1888]}, {"w": "time.", "b": [0.7247, 0.1673, 0.7673, 0.1888]}, {"w": "This", "b": [0.7748, 0.1673, 0.812, 0.1888]}, {"w": "is", "b": [0.8195, 0.1673, 0.8327, 0.1888]}, {"w": "in", "b": [0.8402, 0.1673, 0.8571, 0.1888]}, {"w": "part", "b": [0.1786, 0.1864, 0.2127, 0.2078]}, {"w": "due", "b": [0.2185, 0.1864, 0.2495, 0.2078]}, {"w": "to", "b": [0.2553, 0.1864, 0.2723, 0.2078]}, {"w": "Moore’s", "b": [0.2781, 0.1864, 0.3431, 0.2078]}, {"w": "Law,", "b": [0.3489, 0.1864, 0.3864, 0.2078]}, {"w": "but", "b": [0.3922, 0.1864, 0.4202, 0.2078]}, {"w": "also", "b": [0.4261, 0.1864, 0.4588, 0.2078]}, {"w": "thanks", "b": [0.4646, 0.1864, 0.5206, 0.2078]}, {"w": "to", "b": [0.5264, 0.1864, 0.5434, 0.2078]}, {"w": "the", "b": [0.5492, 0.1864, 0.5756, 0.2078]}, {"w": "gaming", "b": [0.5814, 0.1864, 0.6441, 0.2078]}, {"w": "industry,", "b": [0.6499, 0.1864, 0.7241, 0.2078]}, {"w": "which", "b": [0.7299, 0.1864, 0.7809, 0.2078]}, {"w": "has", "b": [0.7867, 0.1864, 0.8146, 0.2078]}, {"w": "pro‐", "b": [0.8204, 0.1864, 0.8571, 0.2078]}, {"w": "duced", "b": [0.1786, 0.2054, 0.2293, 0.2269]}, {"w": "powerful", "b": [0.234, 0.2054, 0.3089, 0.2269]}, {"w": "GPU", "b": [0.3137, 0.2054, 0.3556, 0.2269]}, {"w": "cards", "b": [0.3603, 0.2054, 0.4047, 0.2269]}, {"w": "by", "b": [0.4094, 0.2054, 0.4296, 0.2269]}, {"w": "the", "b": [0.4343, 0.2054, 0.4606, 0.2269]}, {"w": "millions.", "b": [0.4653, 0.2054, 0.5385, 0.2269]}]}, {"id": "b_2", "type": "paragraph", "text": "• The training algorithms have been improved. To be fair they are only slightly dif‐ ferent from the ones used in the 1990s, but these relatively small tweaks have a huge positive impact.", "words": [{"w": "•", "b": [0.16, 0.2305, 0.1682, 0.2519]}, {"w": "The", "b": [0.1786, 0.2305, 0.2114, 0.2519]}, {"w": "training", "b": [0.2165, 0.2305, 0.2834, 0.2519]}, {"w": "algorithms", "b": [0.2885, 0.2305, 0.3788, 0.2519]}, {"w": "have", "b": [0.3839, 0.2305, 0.4223, 0.2519]}, {"w": "been", "b": [0.4274, 0.2305, 0.4671, 0.2519]}, {"w": "improved.", "b": [0.4722, 0.2305, 0.558, 0.2519]}, {"w": "To", "b": [0.5631, 0.2305, 0.5845, 0.2519]}, {"w": "be", "b": [0.5896, 0.2305, 0.6091, 0.2519]}, {"w": "fair", "b": [0.6142, 0.2305, 0.6428, 0.2519]}, {"w": "they", "b": [0.6479, 0.2305, 0.6838, 0.2519]}, {"w": "are", "b": [0.6889, 0.2305, 0.7146, 0.2519]}, {"w": "only", "b": [0.7197, 0.2305, 0.7566, 0.2519]}, {"w": "slightly", "b": [0.7617, 0.2305, 0.8219, 0.2519]}, {"w": "dif‐", "b": [0.827, 0.2305, 0.8571, 0.2519]}, {"w": "ferent", "b": [0.1786, 0.2496, 0.2275, 0.271]}, {"w": "from", "b": [0.2342, 0.2496, 0.2758, 0.271]}, {"w": "the", "b": [0.2825, 0.2496, 0.3088, 0.271]}, {"w": "ones", "b": [0.3155, 0.2496, 0.354, 0.271]}, {"w": "used", "b": [0.3607, 0.2496, 0.3993, 0.271]}, {"w": "in", "b": [0.406, 0.2496, 0.423, 0.271]}, {"w": "the", "b": [0.4296, 0.2496, 0.456, 0.271]}, {"w": "1990s,", "b": [0.4627, 0.2496, 0.5151, 0.271]}, {"w": "but", "b": [0.5218, 0.2496, 0.5498, 0.271]}, {"w": "these", "b": [0.5564, 0.2496, 0.5993, 0.271]}, {"w": "relatively", "b": [0.606, 0.2496, 0.6818, 0.271]}, {"w": "small", "b": [0.6885, 0.2496, 0.7329, 0.271]}, {"w": "tweaks", "b": [0.7396, 0.2496, 0.7962, 0.271]}, {"w": "have", "b": [0.8029, 0.2496, 0.8413, 0.271]}, {"w": "a", "b": [0.848, 0.2496, 0.8571, 0.271]}, {"w": "huge", "b": [0.1786, 0.2686, 0.219, 0.29]}, {"w": "positive", "b": [0.2237, 0.2686, 0.2889, 0.29]}, {"w": "impact.", "b": [0.2936, 0.2686, 0.3559, 0.29]}]}, {"id": "b_3", "type": "paragraph", "text": "• Some theoretical limitations of ANNs have turned out to be benign in practice. For example, many people thought that ANN training algorithms were doomed because they were likely to get stuck in local optima, but it turns out that this is rather rare in practice (or when it is the case, they are usually fairly close to the global optimum).", "words": [{"w": "•", "b": [0.16, 0.2937, 0.1682, 0.3151]}, {"w": "Some", "b": [0.1786, 0.2937, 0.225, 0.3151]}, {"w": "theoretical", "b": [0.2316, 0.2937, 0.3203, 0.3151]}, {"w": "limitations", "b": [0.3269, 0.2937, 0.4171, 0.3151]}, {"w": "of", "b": [0.4237, 0.2937, 0.4405, 0.3151]}, {"w": "ANNs", "b": [0.4471, 0.2937, 0.4995, 0.3151]}, {"w": "have", "b": [0.5062, 0.2937, 0.5445, 0.3151]}, {"w": "turned", "b": [0.5512, 0.2937, 0.6075, 0.3151]}, {"w": "out", "b": [0.6142, 0.2937, 0.6422, 0.3151]}, {"w": "to", "b": [0.6488, 0.2937, 0.6658, 0.3151]}, {"w": "be", "b": [0.6724, 0.2937, 0.6918, 0.3151]}, {"w": "benign", "b": [0.6984, 0.2937, 0.756, 0.3151]}, {"w": "in", "b": [0.7626, 0.2937, 0.7796, 0.3151]}, {"w": "practice.", "b": [0.7862, 0.2937, 0.8571, 0.3151]}, {"w": "For", "b": [0.1786, 0.3128, 0.2076, 0.3342]}, {"w": "example,", "b": [0.2139, 0.3128, 0.2882, 0.3342]}, {"w": "many", "b": [0.2945, 0.3128, 0.3412, 0.3342]}, {"w": "people", "b": [0.3475, 0.3128, 0.4029, 0.3342]}, {"w": "thought", "b": [0.4092, 0.3128, 0.4752, 0.3342]}, {"w": "that", "b": [0.4815, 0.3128, 0.5141, 0.3342]}, {"w": "ANN", "b": [0.5204, 0.3128, 0.5658, 0.3342]}, {"w": "training", "b": [0.5721, 0.3128, 0.639, 0.3342]}, {"w": "algorithms", "b": [0.6454, 0.3128, 0.7356, 0.3342]}, {"w": "were", "b": [0.742, 0.3128, 0.7817, 0.3342]}, {"w": "doomed", "b": [0.788, 0.3128, 0.8571, 0.3342]}, {"w": "because", "b": [0.1786, 0.3318, 0.2431, 0.3532]}, {"w": "they", "b": [0.2493, 0.3318, 0.2852, 0.3532]}, {"w": "were", "b": [0.2913, 0.3318, 0.331, 0.3532]}, {"w": "likely", "b": [0.3371, 0.3318, 0.382, 0.3532]}, {"w": "to", "b": [0.3881, 0.3318, 0.4051, 0.3532]}, {"w": "get", "b": [0.4113, 0.3318, 0.4362, 0.3532]}, {"w": "stuck", "b": [0.4423, 0.3318, 0.4866, 0.3532]}, {"w": "in", "b": [0.4927, 0.3318, 0.5097, 0.3532]}, {"w": "local", "b": [0.5158, 0.3318, 0.5549, 0.3532]}, {"w": "optima,", "b": [0.5611, 0.3318, 0.6255, 0.3532]}, {"w": "but", "b": [0.6316, 0.3318, 0.6596, 0.3532]}, {"w": "it", "b": [0.6658, 0.3318, 0.6777, 0.3532]}, {"w": "turns", "b": [0.6838, 0.3318, 0.728, 0.3532]}, {"w": "out", "b": [0.7342, 0.3318, 0.7622, 0.3532]}, {"w": "that", "b": [0.7683, 0.3318, 0.8009, 0.3532]}, {"w": "this", "b": [0.8071, 0.3318, 0.8378, 0.3532]}, {"w": "is", "b": [0.8439, 0.3318, 0.8571, 0.3532]}, {"w": "rather", "b": [0.1786, 0.3509, 0.2291, 0.3723]}, {"w": "rare", "b": [0.2354, 0.3509, 0.2689, 0.3723]}, {"w": "in", "b": [0.2752, 0.3509, 0.2922, 0.3723]}, {"w": "practice", "b": [0.2985, 0.3509, 0.3647, 0.3723]}, {"w": "(or", "b": [0.371, 0.3509, 0.3965, 0.3723]}, {"w": "when", "b": [0.4028, 0.3509, 0.4485, 0.3723]}, {"w": "it", "b": [0.4548, 0.3509, 0.4667, 0.3723]}, {"w": "is", "b": [0.473, 0.3509, 0.4863, 0.3723]}, {"w": "the", "b": [0.4926, 0.3509, 0.5189, 0.3723]}, {"w": "case,", "b": [0.5252, 0.3509, 0.5644, 0.3723]}, {"w": "they", "b": [0.5707, 0.3509, 0.6066, 0.3723]}, {"w": "are", "b": [0.6129, 0.3509, 0.6386, 0.3723]}, {"w": "usually", "b": [0.6449, 0.3509, 0.704, 0.3723]}, {"w": "fairly", "b": [0.7103, 0.3509, 0.7537, 0.3723]}, {"w": "close", "b": [0.76, 0.3509, 0.8012, 0.3723]}, {"w": "to", "b": [0.8075, 0.3509, 0.8245, 0.3723]}, {"w": "the", "b": [0.8308, 0.3509, 0.8571, 0.3723]}, {"w": "global", "b": [0.1786, 0.3699, 0.2292, 0.3913]}, {"w": "optimum).", "b": [0.234, 0.3699, 0.3242, 0.3913]}]}, {"id": "b_4", "type": "paragraph", "text": "• ANNs seem to have entered a virtuous circle of funding and progress. Amazing products based on ANNs regularly make the headline news, which pulls more and more attention and funding toward them, resulting in more and more pro‐ gress, and even more amazing products.", "words": [{"w": "•", "b": [0.16, 0.395, 0.1681, 0.4164]}, {"w": "ANNs", "b": [0.1786, 0.395, 0.231, 0.4164]}, {"w": "seem", "b": [0.2373, 0.395, 0.2797, 0.4164]}, {"w": "to", "b": [0.286, 0.395, 0.303, 0.4164]}, {"w": "have", "b": [0.3092, 0.395, 0.3476, 0.4164]}, {"w": "entered", "b": [0.3539, 0.395, 0.4166, 0.4164]}, {"w": "a", "b": [0.4228, 0.395, 0.432, 0.4164]}, {"w": "virtuous", "b": [0.4383, 0.395, 0.508, 0.4164]}, {"w": "circle", "b": [0.5143, 0.395, 0.5593, 0.4164]}, {"w": "of", "b": [0.5656, 0.395, 0.5824, 0.4164]}, {"w": "funding", "b": [0.5887, 0.395, 0.655, 0.4164]}, {"w": "and", "b": [0.6613, 0.395, 0.6928, 0.4164]}, {"w": "progress.", "b": [0.6991, 0.395, 0.7748, 0.4164]}, {"w": "Amazing", "b": [0.7811, 0.395, 0.8571, 0.4164]}, {"w": "products", "b": [0.1786, 0.4141, 0.2527, 0.4355]}, {"w": "based", "b": [0.2603, 0.4141, 0.3075, 0.4355]}, {"w": "on", "b": [0.3151, 0.4141, 0.3371, 0.4355]}, {"w": "ANNs", "b": [0.3446, 0.4141, 0.3971, 0.4355]}, {"w": "regularly", "b": [0.4046, 0.4141, 0.479, 0.4355]}, {"w": "make", "b": [0.4866, 0.4141, 0.532, 0.4355]}, {"w": "the", "b": [0.5395, 0.4141, 0.5659, 0.4355]}, {"w": "headline", "b": [0.5734, 0.4141, 0.6446, 0.4355]}, {"w": "news,", "b": [0.6522, 0.4141, 0.6991, 0.4355]}, {"w": "which", "b": [0.7067, 0.4141, 0.7576, 0.4355]}, {"w": "pulls", "b": [0.7652, 0.4141, 0.8053, 0.4355]}, {"w": "more", "b": [0.8129, 0.4141, 0.8571, 0.4355]}, {"w": "and", "b": [0.1786, 0.4331, 0.2101, 0.4545]}, {"w": "more", "b": [0.2163, 0.4331, 0.2606, 0.4545]}, {"w": "attention", "b": [0.2669, 0.4331, 0.3421, 0.4545]}, {"w": "and", "b": [0.3484, 0.4331, 0.3799, 0.4545]}, {"w": "funding", "b": [0.3862, 0.4331, 0.4525, 0.4545]}, {"w": "toward", "b": [0.4588, 0.4331, 0.5179, 0.4545]}, {"w": "them,", "b": [0.5241, 0.4331, 0.5723, 0.4545]}, {"w": "resulting", "b": [0.5785, 0.4331, 0.6522, 0.4545]}, {"w": "in", "b": [0.6584, 0.4331, 0.6754, 0.4545]}, {"w": "more", "b": [0.6816, 0.4331, 0.7259, 0.4545]}, {"w": "and", "b": [0.7321, 0.4331, 0.7637, 0.4545]}, {"w": "more", "b": [0.7699, 0.4331, 0.8142, 0.4545]}, {"w": "pro‐", "b": [0.8204, 0.4331, 0.8571, 0.4545]}, {"w": "gress,", "b": [0.1786, 0.4522, 0.2249, 0.4736]}, {"w": "and", "b": [0.2297, 0.4522, 0.2612, 0.4736]}, {"w": "even", "b": [0.2659, 0.4522, 0.3047, 0.4736]}, {"w": "more", "b": [0.3094, 0.4522, 0.3537, 0.4736]}, {"w": "amazing", "b": [0.3584, 0.4522, 0.4293, 0.4736]}, {"w": "products.", "b": [0.434, 0.4522, 0.5129, 0.4736]}]}, {"id": "b_5", "type": "paragraph", "text": "Biological Neurons", "words": [{"w": "Biological", "b": [0.1429, 0.5015, 0.2441, 0.53]}, {"w": "Neurons", "b": [0.2491, 0.5015, 0.3348, 0.53]}]}, {"id": "b_6", "type": "paragraph", "text": "Before we discuss artificial neurons, let’s take a quick look at a biological neuron (rep‐ resented in Figure 10-1). It is an unusual-looking cell mostly found in animal cerebral cortexes (e.g., your brain), composed of a cell body containing the nucleus and most of the cell’s complex components, and many branching extensions called dendrites, plus one very long extension called the axon. The axon’s length may be just a few times longer than the cell body, or up to tens of thousands of times longer. Near its extremity the axon splits off into many branches called telodendria, and at the tip of these branches are minuscule structures called synaptic terminals (or simply synap‐ ses), which are connected to the dendrites (or directly to the cell body) of other neu‐ rons. Biological neurons receive short electrical impulses called signals from other neurons via these synapses. When a neuron receives a sufficient number of signals from other neurons within a few milliseconds, it fires its own signals.", "words": [{"w": "Before", "b": [0.1429, 0.5359, 0.1978, 0.5573]}, {"w": "we", "b": [0.2026, 0.5359, 0.2257, 0.5573]}, {"w": "discuss", "b": [0.2306, 0.5359, 0.29, 0.5573]}, {"w": "artificial", "b": [0.2948, 0.5359, 0.3642, 0.5573]}, {"w": "neurons,", "b": [0.3691, 0.5359, 0.4425, 0.5573]}, {"w": "let’s", "b": [0.4474, 0.5359, 0.4776, 0.5573]}, {"w": "take", "b": [0.4825, 0.5359, 0.5172, 0.5573]}, {"w": "a", "b": [0.522, 0.5359, 0.5312, 0.5573]}, {"w": "quick", "b": [0.536, 0.5359, 0.5825, 0.5573]}, {"w": "look", "b": [0.5873, 0.5359, 0.6242, 0.5573]}, {"w": "at", "b": [0.629, 0.5359, 0.6441, 0.5573]}, {"w": "a", "b": [0.649, 0.5359, 0.6581, 0.5573]}, {"w": "biological", "b": [0.663, 0.5359, 0.7442, 0.5573]}, {"w": "neuron", "b": [0.7491, 0.5359, 0.8102, 0.5573]}, {"w": "(rep‐", "b": [0.815, 0.5359, 0.8571, 0.5573]}, {"w": "resented", "b": [0.1429, 0.555, 0.2131, 0.5764]}, {"w": "in", "b": [0.2179, 0.555, 0.2349, 0.5764]}, {"w": "Figure", "b": [0.2399, 0.555, 0.2939, 0.5764]}, {"w": "10-1).", "b": [0.2986, 0.555, 0.3481, 0.5764]}, {"w": "It", "b": [0.353, 0.555, 0.3657, 0.5764]}, {"w": "is", "b": [0.3705, 0.555, 0.3838, 0.5764]}, {"w": "an", "b": [0.3887, 0.555, 0.4092, 0.5764]}, {"w": "unusual-looking", "b": [0.4141, 0.555, 0.5513, 0.5764]}, {"w": "cell", "b": [0.5562, 0.555, 0.5844, 0.5764]}, {"w": "mostly", "b": [0.5893, 0.555, 0.6458, 0.5764]}, {"w": "found", "b": [0.6507, 0.555, 0.7009, 0.5764]}, {"w": "in", "b": [0.7058, 0.555, 0.7228, 0.5764]}, {"w": "animal", "b": [0.7277, 0.555, 0.7853, 0.5764]}, {"w": "cerebral", "b": [0.7902, 0.555, 0.8571, 0.5764]}, {"w": "cortexes", "b": [0.1429, 0.574, 0.2116, 0.5954]}, {"w": "(e.g.,", "b": [0.2178, 0.574, 0.2578, 0.5954]}, {"w": "your", "b": [0.2641, 0.574, 0.303, 0.5954]}, {"w": "brain),", "b": [0.3092, 0.574, 0.3656, 0.5954]}, {"w": "composed", "b": [0.3719, 0.574, 0.457, 0.5954]}, {"w": "of", "b": [0.4632, 0.574, 0.48, 0.5954]}, {"w": "a", "b": [0.4862, 0.574, 0.4954, 0.5954]}, {"w": "cell", "b": [0.5016, 0.5738, 0.5277, 0.5954]}, {"w": "body", "b": [0.5339, 0.5738, 0.5731, 0.5954]}, {"w": "containing", "b": [0.5794, 0.574, 0.669, 0.5954]}, {"w": "the", "b": [0.6752, 0.574, 0.7016, 0.5954]}, {"w": "nucleus", "b": [0.7078, 0.574, 0.7715, 0.5954]}, {"w": "and", "b": [0.7777, 0.574, 0.8092, 0.5954]}, {"w": "most", "b": [0.8154, 0.574, 0.8571, 0.5954]}, {"w": "of", "b": [0.1429, 0.5931, 0.1597, 0.6145]}, {"w": "the", "b": [0.1671, 0.5931, 0.1935, 0.6145]}, {"w": "cell’s", "b": [0.201, 0.5931, 0.2389, 0.6145]}, {"w": "complex", "b": [0.2464, 0.5931, 0.3174, 0.6145]}, {"w": "components,", "b": [0.3249, 0.5931, 0.4325, 0.6145]}, {"w": "and", "b": [0.44, 0.5931, 0.4716, 0.6145]}, {"w": "many", "b": [0.479, 0.5931, 0.5257, 0.6145]}, {"w": "branching", "b": [0.5332, 0.5931, 0.6187, 0.6145]}, {"w": "extensions", "b": [0.6262, 0.5931, 0.7144, 0.6145]}, {"w": "called", "b": [0.7219, 0.5931, 0.7703, 0.6145]}, {"w": "dendrites,", "b": [0.7777, 0.5929, 0.8572, 0.6145]}, {"w": "plus", "b": [0.1429, 0.6121, 0.1778, 0.6335]}, {"w": "one", "b": [0.1855, 0.6121, 0.2163, 0.6335]}, {"w": "very", "b": [0.224, 0.6121, 0.2604, 0.6335]}, {"w": "long", "b": [0.2681, 0.6121, 0.3052, 0.6335]}, {"w": "extension", "b": [0.3128, 0.6121, 0.3934, 0.6335]}, {"w": "called", "b": [0.4011, 0.6121, 0.4494, 0.6335]}, {"w": "the", "b": [0.4571, 0.6121, 0.4835, 0.6335]}, {"w": "axon.", "b": [0.4912, 0.6119, 0.5367, 0.6335]}, {"w": "The", "b": [0.5444, 0.6121, 0.5773, 0.6335]}, {"w": "axon’s", "b": [0.585, 0.6121, 0.6346, 0.6335]}, {"w": "length", "b": [0.6423, 0.6121, 0.695, 0.6335]}, {"w": "may", "b": [0.7027, 0.6121, 0.7381, 0.6335]}, {"w": "be", "b": [0.7458, 0.6121, 0.7652, 0.6335]}, {"w": "just", "b": [0.7729, 0.6121, 0.8033, 0.6335]}, {"w": "a", "b": [0.811, 0.6121, 0.8202, 0.6335]}, {"w": "few", "b": [0.8279, 0.6121, 0.8571, 0.6335]}, {"w": "times", "b": [0.1429, 0.6312, 0.1884, 0.6526]}, {"w": "longer", "b": [0.1948, 0.6312, 0.2485, 0.6526]}, {"w": "than", "b": [0.2549, 0.6312, 0.293, 0.6526]}, {"w": "the", "b": [0.2994, 0.6312, 0.3258, 0.6526]}, {"w": "cell", "b": [0.3322, 0.6312, 0.3604, 0.6526]}, {"w": "body,", "b": [0.3669, 0.6312, 0.4119, 0.6526]}, {"w": "or", "b": [0.4184, 0.6312, 0.4368, 0.6526]}, {"w": "up", "b": [0.4432, 0.6312, 0.4652, 0.6526]}, {"w": "to", "b": [0.4717, 0.6312, 0.4887, 0.6526]}, {"w": "tens", "b": [0.4951, 0.6312, 0.5294, 0.6526]}, {"w": "of", "b": [0.5359, 0.6312, 0.5527, 0.6526]}, {"w": "thousands", "b": [0.5591, 0.6312, 0.6451, 0.6526]}, {"w": "of", "b": [0.6516, 0.6312, 0.6684, 0.6526]}, {"w": "times", "b": [0.6749, 0.6312, 0.7204, 0.6526]}, {"w": "longer.", "b": [0.7269, 0.6312, 0.7839, 0.6526]}, {"w": "Near", "b": [0.7904, 0.6312, 0.8311, 0.6526]}, {"w": "its", "b": [0.8376, 0.6312, 0.8571, 0.6526]}, {"w": "extremity", "b": [0.1428, 0.6502, 0.223, 0.6716]}, {"w": "the", "b": [0.2292, 0.6502, 0.2555, 0.6716]}, {"w": "axon", "b": [0.2617, 0.6502, 0.3027, 0.6716]}, {"w": "splits", "b": [0.3089, 0.6502, 0.3523, 0.6716]}, {"w": "off", "b": [0.3585, 0.6502, 0.3814, 0.6716]}, {"w": "into", "b": [0.3876, 0.6502, 0.4212, 0.6716]}, {"w": "many", "b": [0.4273, 0.6502, 0.474, 0.6716]}, {"w": "branches", "b": [0.4802, 0.6502, 0.5555, 0.6716]}, {"w": "called", "b": [0.5617, 0.6502, 0.61, 0.6716]}, {"w": "telodendria,", "b": [0.6162, 0.65, 0.7136, 0.6716]}, {"w": "and", "b": [0.7198, 0.6502, 0.7514, 0.6716]}, {"w": "at", "b": [0.7575, 0.6502, 0.7726, 0.6716]}, {"w": "the", "b": [0.7788, 0.6502, 0.8051, 0.6716]}, {"w": "tip", "b": [0.8113, 0.6502, 0.8342, 0.6716]}, {"w": "of", "b": [0.8403, 0.6502, 0.8571, 0.6716]}, {"w": "these", "b": [0.1429, 0.6692, 0.1857, 0.6907]}, {"w": "branches", "b": [0.193, 0.6692, 0.2683, 0.6907]}, {"w": "are", "b": [0.2756, 0.6692, 0.3013, 0.6907]}, {"w": "minuscule", "b": [0.3086, 0.6692, 0.395, 0.6907]}, {"w": "structures", "b": [0.4023, 0.6692, 0.4855, 0.6907]}, {"w": "called", "b": [0.4928, 0.6692, 0.5412, 0.6907]}, {"w": "synaptic", "b": [0.5485, 0.669, 0.6154, 0.6907]}, {"w": "terminals", "b": [0.6227, 0.669, 0.6997, 0.6907]}, {"w": "(or", "b": [0.707, 0.6692, 0.7326, 0.6907]}, {"w": "simply", "b": [0.7399, 0.6692, 0.7955, 0.6907]}, {"w": "synap‐", "b": [0.8028, 0.669, 0.8571, 0.6907]}, {"w": "ses),", "b": [0.1429, 0.6881, 0.1771, 0.7097]}, {"w": "which", "b": [0.1828, 0.6883, 0.2337, 0.7097]}, {"w": "are", "b": [0.2395, 0.6883, 0.2652, 0.7097]}, {"w": "connected", "b": [0.271, 0.6883, 0.3571, 0.7097]}, {"w": "to", "b": [0.3628, 0.6883, 0.3798, 0.7097]}, {"w": "the", "b": [0.3855, 0.6883, 0.4119, 0.7097]}, {"w": "dendrites", "b": [0.4176, 0.6883, 0.496, 0.7097]}, {"w": "(or", "b": [0.5018, 0.6883, 0.5273, 0.7097]}, {"w": "directly", "b": [0.5331, 0.6883, 0.5962, 0.7097]}, {"w": "to", "b": [0.602, 0.6883, 0.619, 0.7097]}, {"w": "the", "b": [0.6247, 0.6883, 0.651, 0.7097]}, {"w": "cell", "b": [0.6568, 0.6883, 0.685, 0.7097]}, {"w": "body)", "b": [0.6907, 0.6883, 0.7397, 0.7097]}, {"w": "of", "b": [0.7454, 0.6883, 0.7622, 0.7097]}, {"w": "other", "b": [0.768, 0.6883, 0.8127, 0.7097]}, {"w": "neu‐", "b": [0.8184, 0.6883, 0.8571, 0.7097]}, {"w": "rons.", "b": [0.1429, 0.7073, 0.185, 0.7288]}, {"w": "Biological", "b": [0.1931, 0.7073, 0.2761, 0.7288]}, {"w": "neurons", "b": [0.2842, 0.7073, 0.3529, 0.7288]}, {"w": "receive", "b": [0.361, 0.7073, 0.4194, 0.7288]}, {"w": "short", "b": [0.4275, 0.7073, 0.471, 0.7288]}, {"w": "electrical", "b": [0.4791, 0.7073, 0.5538, 0.7288]}, {"w": "impulses", "b": [0.5619, 0.7073, 0.6356, 0.7288]}, {"w": "called", "b": [0.6437, 0.7073, 0.6921, 0.7288]}, {"w": "signals", "b": [0.7002, 0.7071, 0.7546, 0.7288]}, {"w": "from", "b": [0.7627, 0.7073, 0.8043, 0.7288]}, {"w": "other", "b": [0.8124, 0.7073, 0.8571, 0.7288]}, {"w": "neurons", "b": [0.1429, 0.7264, 0.2116, 0.7478]}, {"w": "via", "b": [0.2189, 0.7264, 0.2432, 0.7478]}, {"w": "these", "b": [0.2505, 0.7264, 0.2934, 0.7478]}, {"w": "synapses.", "b": [0.3007, 0.7264, 0.3778, 0.7478]}, {"w": "When", "b": [0.3851, 0.7264, 0.4367, 0.7478]}, {"w": "a", "b": [0.444, 0.7264, 0.4532, 0.7478]}, {"w": "neuron", "b": [0.4605, 0.7264, 0.5215, 0.7478]}, {"w": "receives", "b": [0.5288, 0.7264, 0.5948, 0.7478]}, {"w": "a", "b": [0.6021, 0.7264, 0.6112, 0.7478]}, {"w": "sufficient", "b": [0.6185, 0.7264, 0.6958, 0.7478]}, {"w": "number", "b": [0.703, 0.7264, 0.7693, 0.7478]}, {"w": "of", "b": [0.7766, 0.7264, 0.7934, 0.7478]}, {"w": "signals", "b": [0.8007, 0.7264, 0.8572, 0.7478]}, {"w": "from", "b": [0.1429, 0.7454, 0.1844, 0.7669]}, {"w": "other", "b": [0.1892, 0.7454, 0.2339, 0.7669]}, {"w": "neurons", "b": [0.2386, 0.7454, 0.3073, 0.7669]}, {"w": "within", "b": [0.312, 0.7454, 0.3663, 0.7669]}, {"w": "a", "b": [0.3711, 0.7454, 0.3802, 0.7669]}, {"w": "few", "b": [0.3849, 0.7454, 0.4142, 0.7669]}, {"w": "milliseconds,", "b": [0.419, 0.7454, 0.5285, 0.7669]}, {"w": "it", "b": [0.5332, 0.7454, 0.5451, 0.7669]}, {"w": "fires", "b": [0.5499, 0.7454, 0.5858, 0.7669]}, {"w": "its", "b": [0.5906, 0.7454, 0.6102, 0.7669]}, {"w": "own", "b": [0.6149, 0.7454, 0.6512, 0.7669]}, {"w": "signals.", "b": [0.6559, 0.7454, 0.7171, 0.7669]}]}, {"id": "b_7", "type": "paragraph", "text": "From Biological to Artificial Neurons | 279", "words": [{"w": "From", "b": [0.585, 0.9225, 0.6155, 0.9388]}, {"w": "Biological", "b": [0.6183, 0.9225, 0.6761, 0.9388]}, {"w": "to", "b": [0.6789, 0.9225, 0.6914, 0.9388]}, {"w": "Artificial", "b": [0.6942, 0.9225, 0.7441, 0.9388]}, {"w": "Neurons", "b": [0.7469, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "279", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 306, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "3 Image by Bruce Blaus (Creative Commons 3.0). Reproduced from https://en.wikipedia.org/wiki/Neuron.", "words": [{"w": "3", "b": [0.1451, 0.822, 0.1518, 0.8363]}, {"w": "Image", "b": [0.1587, 0.8205, 0.1983, 0.8368]}, {"w": "by", "b": [0.2019, 0.8205, 0.2172, 0.8368]}, {"w": "Bruce", "b": [0.2208, 0.8205, 0.258, 0.8368]}, {"w": "Blaus", "b": [0.2616, 0.8205, 0.2958, 0.8368]}, {"w": "(Creative", "b": [0.2994, 0.8205, 0.358, 0.8368]}, {"w": "Commons", "b": [0.3616, 0.8205, 0.4288, 0.8368]}, {"w": "3.0).", "b": [0.4324, 0.8205, 0.4604, 0.8368]}, {"w": "Reproduced", "b": [0.464, 0.8205, 0.5416, 0.8368]}, {"w": "from", "b": [0.5452, 0.8205, 0.5768, 0.8368]}, {"w": "https://en.wikipedia.org/wiki/Neuron.", "b": [0.5804, 0.8203, 0.8141, 0.8368]}]}, {"id": "b_1", "type": "paragraph", "text": "4 In the context of Machine Learning, the phrase “neural networks” generally refers to ANNs, not BNNs.", "words": [{"w": "4", "b": [0.1451, 0.8416, 0.1518, 0.8559]}, {"w": "In", "b": [0.1587, 0.8401, 0.1728, 0.8565]}, {"w": "the", "b": [0.1764, 0.8401, 0.1965, 0.8565]}, {"w": "context", "b": [0.2001, 0.8401, 0.2472, 0.8565]}, {"w": "of", "b": [0.2508, 0.8401, 0.2636, 0.8565]}, {"w": "Machine", "b": [0.2672, 0.8401, 0.3229, 0.8565]}, {"w": "Learning,", "b": [0.3265, 0.8401, 0.3873, 0.8565]}, {"w": "the", "b": [0.3909, 0.8401, 0.411, 0.8565]}, {"w": "phrase", "b": [0.4146, 0.8401, 0.4568, 0.8565]}, {"w": "“neural", "b": [0.4604, 0.8401, 0.507, 0.8565]}, {"w": "networks”", "b": [0.5106, 0.8401, 0.5751, 0.8565]}, {"w": "generally", "b": [0.5787, 0.8401, 0.6365, 0.8565]}, {"w": "refers", "b": [0.6401, 0.8401, 0.6759, 0.8565]}, {"w": "to", "b": [0.6795, 0.8401, 0.6924, 0.8565]}, {"w": "ANNs,", "b": [0.696, 0.8401, 0.7396, 0.8565]}, {"w": "not", "b": [0.7432, 0.8401, 0.7648, 0.8565]}, {"w": "BNNs.", "b": [0.7684, 0.8401, 0.8104, 0.8565]}]}, {"id": "b_2", "type": "paragraph", "text": "5 Drawing of a cortical lamination by S. Ramon y Cajal (public domain). Reproduced from https://en.wikipe dia.org/wiki/Cerebral_cortex.", "words": [{"w": "5", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Drawing", "b": [0.1587, 0.8598, 0.2142, 0.8761]}, {"w": "of", "b": [0.2178, 0.8598, 0.2306, 0.8761]}, {"w": "a", "b": [0.2342, 0.8598, 0.2412, 0.8761]}, {"w": "cortical", "b": [0.2448, 0.8598, 0.2923, 0.8761]}, {"w": "lamination", "b": [0.2959, 0.8598, 0.3653, 0.8761]}, {"w": "by", "b": [0.3689, 0.8598, 0.3843, 0.8761]}, {"w": "S.", "b": [0.3879, 0.8598, 0.399, 0.8761]}, {"w": "Ramon", "b": [0.4026, 0.8598, 0.4495, 0.8761]}, {"w": "y", "b": [0.4531, 0.8598, 0.4604, 0.8761]}, {"w": "Cajal", "b": [0.464, 0.8598, 0.4963, 0.8761]}, {"w": "(public", "b": [0.4999, 0.8598, 0.5452, 0.8761]}, {"w": "domain).", "b": [0.5488, 0.8598, 0.6073, 0.8761]}, {"w": "Reproduced", "b": [0.6109, 0.8598, 0.6884, 0.8761]}, {"w": "from", "b": [0.692, 0.8598, 0.7237, 0.8761]}, {"w": "https://en.wikipe", "b": [0.7273, 0.8596, 0.8307, 0.8761]}, {"w": "dia.org/wiki/Cerebral_cortex.", "b": [0.1587, 0.8748, 0.341, 0.8912]}]}, {"id": "b_3", "type": "equation", "text": "Figure 10-1. Biological neuron3", "words": [{"w": "Figure", "b": [0.1429, 0.3481, 0.1943, 0.3697]}, {"w": "10-1.", "b": [0.1991, 0.3481, 0.2407, 0.3697]}, {"w": "Biological", "b": [0.2455, 0.3481, 0.3248, 0.3697]}, {"w": "neuron3", "b": [0.3295, 0.3481, 0.3932, 0.3697]}]}, {"id": "b_4", "type": "paragraph", "text": "Thus, individual biological neurons seem to behave in a rather simple way, but they are organized in a vast network of billions of neurons, each neuron typically connec‐ ted to thousands of other neurons. Highly complex computations can be performed by a vast network of fairly simple neurons, much like a complex anthill can emerge from the combined efforts of simple ants. The architecture of biological neural net‐ works (BNN)4 is still the subject of active research, but some parts of the brain have been mapped, and it seems that neurons are often organized in consecutive layers, as shown in Figure 10-2.", "words": [{"w": "Thus,", "b": [0.1429, 0.3855, 0.1899, 0.4069]}, {"w": "individual", "b": [0.1963, 0.3855, 0.2816, 0.4069]}, {"w": "biological", "b": [0.288, 0.3855, 0.3693, 0.4069]}, {"w": "neurons", "b": [0.3757, 0.3855, 0.4444, 0.4069]}, {"w": "seem", "b": [0.4508, 0.3855, 0.4932, 0.4069]}, {"w": "to", "b": [0.4997, 0.3855, 0.5166, 0.4069]}, {"w": "behave", "b": [0.523, 0.3855, 0.5809, 0.4069]}, {"w": "in", "b": [0.5873, 0.3855, 0.6043, 0.4069]}, {"w": "a", "b": [0.6107, 0.3855, 0.6198, 0.4069]}, {"w": "rather", "b": [0.6263, 0.3855, 0.6768, 0.4069]}, {"w": "simple", "b": [0.6832, 0.3855, 0.7382, 0.4069]}, {"w": "way,", "b": [0.7446, 0.3855, 0.7804, 0.4069]}, {"w": "but", "b": [0.7868, 0.3855, 0.8148, 0.4069]}, {"w": "they", "b": [0.8213, 0.3855, 0.8572, 0.4069]}, {"w": "are", "b": [0.1429, 0.4045, 0.1686, 0.426]}, {"w": "organized", "b": [0.1741, 0.4045, 0.2569, 0.426]}, {"w": "in", "b": [0.2624, 0.4045, 0.2794, 0.426]}, {"w": "a", "b": [0.2849, 0.4045, 0.294, 0.426]}, {"w": "vast", "b": [0.2995, 0.4045, 0.3323, 0.426]}, {"w": "network", "b": [0.3378, 0.4045, 0.4074, 0.426]}, {"w": "of", "b": [0.4129, 0.4045, 0.4297, 0.426]}, {"w": "billions", "b": [0.4352, 0.4045, 0.4971, 0.426]}, {"w": "of", "b": [0.5026, 0.4045, 0.5194, 0.426]}, {"w": "neurons,", "b": [0.5249, 0.4045, 0.5984, 0.426]}, {"w": "each", "b": [0.6039, 0.4045, 0.6418, 0.426]}, {"w": "neuron", "b": [0.6473, 0.4045, 0.7084, 0.426]}, {"w": "typically", "b": [0.7139, 0.4045, 0.7843, 0.426]}, {"w": "connec‐", "b": [0.7898, 0.4045, 0.8571, 0.426]}, {"w": "ted", "b": [0.1429, 0.4236, 0.1691, 0.445]}, {"w": "to", "b": [0.1754, 0.4236, 0.1924, 0.445]}, {"w": "thousands", "b": [0.1987, 0.4236, 0.2847, 0.445]}, {"w": "of", "b": [0.291, 0.4236, 0.3078, 0.445]}, {"w": "other", "b": [0.3141, 0.4236, 0.3588, 0.445]}, {"w": "neurons.", "b": [0.3651, 0.4236, 0.4385, 0.445]}, {"w": "Highly", "b": [0.4448, 0.4236, 0.5021, 0.445]}, {"w": "complex", "b": [0.5084, 0.4236, 0.5794, 0.445]}, {"w": "computations", "b": [0.5857, 0.4236, 0.7005, 0.445]}, {"w": "can", "b": [0.7068, 0.4236, 0.7361, 0.445]}, {"w": "be", "b": [0.7425, 0.4236, 0.7619, 0.445]}, {"w": "performed", "b": [0.7682, 0.4236, 0.8571, 0.445]}, {"w": "by", "b": [0.1428, 0.4426, 0.163, 0.464]}, {"w": "a", "b": [0.1696, 0.4426, 0.1787, 0.464]}, {"w": "vast", "b": [0.1853, 0.4426, 0.2181, 0.464]}, {"w": "network", "b": [0.2246, 0.4426, 0.2942, 0.464]}, {"w": "of", "b": [0.3008, 0.4426, 0.3176, 0.464]}, {"w": "fairly", "b": [0.3241, 0.4426, 0.3676, 0.464]}, {"w": "simple", "b": [0.3742, 0.4426, 0.4291, 0.464]}, {"w": "neurons,", "b": [0.4357, 0.4426, 0.5091, 0.464]}, {"w": "much", "b": [0.5157, 0.4426, 0.5634, 0.464]}, {"w": "like", "b": [0.5699, 0.4426, 0.6, 0.464]}, {"w": "a", "b": [0.6065, 0.4426, 0.6157, 0.464]}, {"w": "complex", "b": [0.6222, 0.4426, 0.6932, 0.464]}, {"w": "anthill", "b": [0.6998, 0.4426, 0.7535, 0.464]}, {"w": "can", "b": [0.7601, 0.4426, 0.7895, 0.464]}, {"w": "emerge", "b": [0.796, 0.4426, 0.8571, 0.464]}, {"w": "from", "b": [0.1429, 0.4617, 0.1844, 0.4831]}, {"w": "the", "b": [0.1911, 0.4617, 0.2174, 0.4831]}, {"w": "combined", "b": [0.224, 0.4617, 0.3079, 0.4831]}, {"w": "efforts", "b": [0.3146, 0.4617, 0.3681, 0.4831]}, {"w": "of", "b": [0.3747, 0.4617, 0.3915, 0.4831]}, {"w": "simple", "b": [0.3982, 0.4617, 0.4531, 0.4831]}, {"w": "ants.", "b": [0.4597, 0.4617, 0.4986, 0.4831]}, {"w": "The", "b": [0.5052, 0.4617, 0.5381, 0.4831]}, {"w": "architecture", "b": [0.5447, 0.4617, 0.6451, 0.4831]}, {"w": "of", "b": [0.6517, 0.4617, 0.6685, 0.4831]}, {"w": "biological", "b": [0.6752, 0.4617, 0.7564, 0.4831]}, {"w": "neural", "b": [0.763, 0.4617, 0.8165, 0.4831]}, {"w": "net‐", "b": [0.8231, 0.4617, 0.8571, 0.4831]}, {"w": "works", "b": [0.1429, 0.4807, 0.1935, 0.5021]}, {"w": "(BNN)4", "b": [0.1996, 0.4807, 0.263, 0.5021]}, {"w": "is", "b": [0.2691, 0.4807, 0.2823, 0.5021]}, {"w": "still", "b": [0.2885, 0.4807, 0.3186, 0.5021]}, {"w": "the", "b": [0.3248, 0.4807, 0.3511, 0.5021]}, {"w": "subject", "b": [0.3572, 0.4807, 0.4159, 0.5021]}, {"w": "of", "b": [0.422, 0.4807, 0.4388, 0.5021]}, {"w": "active", "b": [0.445, 0.4807, 0.4934, 0.5021]}, {"w": "research,", "b": [0.4995, 0.4807, 0.5742, 0.5021]}, {"w": "but", "b": [0.5803, 0.4807, 0.6083, 0.5021]}, {"w": "some", "b": [0.6145, 0.4807, 0.6586, 0.5021]}, {"w": "parts", "b": [0.6648, 0.4807, 0.7066, 0.5021]}, {"w": "of", "b": [0.7127, 0.4807, 0.7295, 0.5021]}, {"w": "the", "b": [0.7357, 0.4807, 0.762, 0.5021]}, {"w": "brain", "b": [0.7682, 0.4807, 0.8126, 0.5021]}, {"w": "have", "b": [0.8187, 0.4807, 0.8571, 0.5021]}, {"w": "been", "b": [0.1429, 0.4998, 0.1825, 0.5212]}, {"w": "mapped,", "b": [0.1877, 0.4998, 0.2599, 0.5212]}, {"w": "and", "b": [0.265, 0.4998, 0.2966, 0.5212]}, {"w": "it", "b": [0.3017, 0.4998, 0.3136, 0.5212]}, {"w": "seems", "b": [0.3187, 0.4998, 0.3688, 0.5212]}, {"w": "that", "b": [0.3739, 0.4998, 0.4065, 0.5212]}, {"w": "neurons", "b": [0.4116, 0.4998, 0.4803, 0.5212]}, {"w": "are", "b": [0.4854, 0.4998, 0.5111, 0.5212]}, {"w": "often", "b": [0.5162, 0.4998, 0.5596, 0.5212]}, {"w": "organized", "b": [0.5647, 0.4998, 0.6476, 0.5212]}, {"w": "in", "b": [0.6527, 0.4998, 0.6697, 0.5212]}, {"w": "consecutive", "b": [0.6748, 0.4998, 0.7724, 0.5212]}, {"w": "layers,", "b": [0.7775, 0.4998, 0.8301, 0.5212]}, {"w": "as", "b": [0.8352, 0.4998, 0.852, 0.5212]}, {"w": "shown", "b": [0.1429, 0.5188, 0.1979, 0.5402]}, {"w": "in", "b": [0.2027, 0.5188, 0.2196, 0.5402]}, {"w": "Figure", "b": [0.2244, 0.5188, 0.2784, 0.5402]}, {"w": "10-2.", "b": [0.2831, 0.5188, 0.3253, 0.5402]}]}, {"id": "b_5", "type": "equation", "text": "Figure 10-2. Multiple layers in a biological neural network (human cortex)5", "words": [{"w": "Figure", "b": [0.1429, 0.7365, 0.1943, 0.7581]}, {"w": "10-2.", "b": [0.1991, 0.7365, 0.2407, 0.7581]}, {"w": "Multiple", "b": [0.2455, 0.7365, 0.3141, 0.7581]}, {"w": "layers", "b": [0.3189, 0.7365, 0.3657, 0.7581]}, {"w": "in", "b": [0.3705, 0.7365, 0.387, 0.7581]}, {"w": "a", "b": [0.3918, 0.7365, 0.402, 0.7581]}, {"w": "biological", "b": [0.4068, 0.7365, 0.4842, 0.7581]}, {"w": "neural", "b": [0.489, 0.7365, 0.5415, 0.7581]}, {"w": "network", "b": [0.5463, 0.7365, 0.6125, 0.7581]}, {"w": "(human", "b": [0.6173, 0.7365, 0.6826, 0.7581]}, {"w": "cortex)5", "b": [0.6874, 0.7365, 0.7498, 0.7581]}]}, {"id": "b_6", "type": "paragraph", "text": "280 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "280", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 307, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Logical Computations with Neurons", "words": [{"w": "Logical", "b": [0.1429, 0.0763, 0.2155, 0.1049]}, {"w": "Computations", "b": [0.2205, 0.0763, 0.3652, 0.1049]}, {"w": "with", "b": [0.3702, 0.0763, 0.4177, 0.1049]}, {"w": "Neurons", "b": [0.4226, 0.0763, 0.5084, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "Warren McCulloch and Walter Pitts proposed a very simple model of the biological neuron, which later became known as an artificial neuron: it has one or more binary (on/off) inputs and one binary output. The artificial neuron simply activates its out‐ put when more than a certain number of its inputs are active. McCulloch and Pitts showed that even with such a simplified model it is possible to build a network of artificial neurons that computes any logical proposition you want. For example, let’s build a few ANNs that perform various logical computations (see Figure 10-3), assuming that a neuron is activated when at least two of its inputs are active.", "words": [{"w": "Warren", "b": [0.1429, 0.1108, 0.2059, 0.1322]}, {"w": "McCulloch", "b": [0.2124, 0.1108, 0.3052, 0.1322]}, {"w": "and", "b": [0.3117, 0.1108, 0.3432, 0.1322]}, {"w": "Walter", "b": [0.3497, 0.1108, 0.4052, 0.1322]}, {"w": "Pitts", "b": [0.4117, 0.1108, 0.4494, 0.1322]}, {"w": "proposed", "b": [0.4558, 0.1108, 0.5342, 0.1322]}, {"w": "a", "b": [0.5406, 0.1108, 0.5498, 0.1322]}, {"w": "very", "b": [0.5563, 0.1108, 0.5926, 0.1322]}, {"w": "simple", "b": [0.5991, 0.1108, 0.6541, 0.1322]}, {"w": "model", "b": [0.6605, 0.1108, 0.7133, 0.1322]}, {"w": "of", "b": [0.7198, 0.1108, 0.7366, 0.1322]}, {"w": "the", "b": [0.7431, 0.1108, 0.7694, 0.1322]}, {"w": "biological", "b": [0.7759, 0.1108, 0.8571, 0.1322]}, {"w": "neuron,", "b": [0.1429, 0.1298, 0.2087, 0.1512]}, {"w": "which", "b": [0.2145, 0.1298, 0.2654, 0.1512]}, {"w": "later", "b": [0.2712, 0.1298, 0.3081, 0.1512]}, {"w": "became", "b": [0.3139, 0.1298, 0.3772, 0.1512]}, {"w": "known", "b": [0.383, 0.1298, 0.4411, 0.1512]}, {"w": "as", "b": [0.4469, 0.1298, 0.4637, 0.1512]}, {"w": "an", "b": [0.4695, 0.1298, 0.49, 0.1512]}, {"w": "artificial", "b": [0.4958, 0.1296, 0.5658, 0.1512]}, {"w": "neuron:", "b": [0.5717, 0.1296, 0.6344, 0.1512]}, {"w": "it", "b": [0.6402, 0.1298, 0.6521, 0.1512]}, {"w": "has", "b": [0.6579, 0.1298, 0.6858, 0.1512]}, {"w": "one", "b": [0.6916, 0.1298, 0.7225, 0.1512]}, {"w": "or", "b": [0.7283, 0.1298, 0.7467, 0.1512]}, {"w": "more", "b": [0.7525, 0.1298, 0.7967, 0.1512]}, {"w": "binary", "b": [0.8025, 0.1298, 0.8571, 0.1512]}, {"w": "(on/off)", "b": [0.1429, 0.1489, 0.2108, 0.1703]}, {"w": "inputs", "b": [0.2166, 0.1489, 0.2692, 0.1703]}, {"w": "and", "b": [0.2751, 0.1489, 0.3066, 0.1703]}, {"w": "one", "b": [0.3125, 0.1489, 0.3434, 0.1703]}, {"w": "binary", "b": [0.3493, 0.1489, 0.4039, 0.1703]}, {"w": "output.", "b": [0.4097, 0.1489, 0.4709, 0.1703]}, {"w": "The", "b": [0.4768, 0.1489, 0.5096, 0.1703]}, {"w": "artificial", "b": [0.5155, 0.1489, 0.5848, 0.1703]}, {"w": "neuron", "b": [0.5907, 0.1489, 0.6518, 0.1703]}, {"w": "simply", "b": [0.6577, 0.1489, 0.7133, 0.1703]}, {"w": "activates", "b": [0.7192, 0.1489, 0.7903, 0.1703]}, {"w": "its", "b": [0.7962, 0.1489, 0.8158, 0.1703]}, {"w": "out‐", "b": [0.8217, 0.1489, 0.8571, 0.1703]}, {"w": "put", "b": [0.1429, 0.1679, 0.1712, 0.1893]}, {"w": "when", "b": [0.178, 0.1679, 0.2236, 0.1893]}, {"w": "more", "b": [0.2304, 0.1679, 0.2747, 0.1893]}, {"w": "than", "b": [0.2814, 0.1679, 0.3195, 0.1893]}, {"w": "a", "b": [0.3262, 0.1679, 0.3354, 0.1893]}, {"w": "certain", "b": [0.3421, 0.1679, 0.4, 0.1893]}, {"w": "number", "b": [0.4068, 0.1679, 0.4731, 0.1893]}, {"w": "of", "b": [0.4799, 0.1679, 0.4967, 0.1893]}, {"w": "its", "b": [0.5034, 0.1679, 0.523, 0.1893]}, {"w": "inputs", "b": [0.5298, 0.1679, 0.5823, 0.1893]}, {"w": "are", "b": [0.5891, 0.1679, 0.6148, 0.1893]}, {"w": "active.", "b": [0.6216, 0.1679, 0.6748, 0.1893]}, {"w": "McCulloch", "b": [0.6815, 0.1679, 0.7744, 0.1893]}, {"w": "and", "b": [0.7812, 0.1679, 0.8127, 0.1893]}, {"w": "Pitts", "b": [0.8195, 0.1679, 0.8572, 0.1893]}, {"w": "showed", "b": [0.1429, 0.187, 0.2064, 0.2084]}, {"w": "that", "b": [0.2137, 0.187, 0.2463, 0.2084]}, {"w": "even", "b": [0.2536, 0.187, 0.2924, 0.2084]}, {"w": "with", "b": [0.2997, 0.187, 0.337, 0.2084]}, {"w": "such", "b": [0.3444, 0.187, 0.383, 0.2084]}, {"w": "a", "b": [0.3903, 0.187, 0.3995, 0.2084]}, {"w": "simplified", "b": [0.4068, 0.187, 0.4901, 0.2084]}, {"w": "model", "b": [0.4974, 0.187, 0.5502, 0.2084]}, {"w": "it", "b": [0.5576, 0.187, 0.5695, 0.2084]}, {"w": "is", "b": [0.5768, 0.187, 0.5901, 0.2084]}, {"w": "possible", "b": [0.5974, 0.187, 0.6645, 0.2084]}, {"w": "to", "b": [0.6718, 0.187, 0.6888, 0.2084]}, {"w": "build", "b": [0.6962, 0.187, 0.7397, 0.2084]}, {"w": "a", "b": [0.747, 0.187, 0.7561, 0.2084]}, {"w": "network", "b": [0.7635, 0.187, 0.833, 0.2084]}, {"w": "of", "b": [0.8404, 0.187, 0.8571, 0.2084]}, {"w": "artificial", "b": [0.1429, 0.206, 0.2122, 0.2274]}, {"w": "neurons", "b": [0.2186, 0.206, 0.2873, 0.2274]}, {"w": "that", "b": [0.2937, 0.206, 0.3263, 0.2274]}, {"w": "computes", "b": [0.3327, 0.206, 0.4136, 0.2274]}, {"w": "any", "b": [0.42, 0.206, 0.4497, 0.2274]}, {"w": "logical", "b": [0.456, 0.206, 0.5105, 0.2274]}, {"w": "proposition", "b": [0.5169, 0.206, 0.6149, 0.2274]}, {"w": "you", "b": [0.6213, 0.206, 0.6525, 0.2274]}, {"w": "want.", "b": [0.6589, 0.206, 0.7045, 0.2274]}, {"w": "For", "b": [0.7109, 0.206, 0.7398, 0.2274]}, {"w": "example,", "b": [0.7462, 0.206, 0.8205, 0.2274]}, {"w": "let’s", "b": [0.8269, 0.206, 0.8571, 0.2274]}, {"w": "build", "b": [0.1428, 0.2251, 0.1863, 0.2465]}, {"w": "a", "b": [0.1965, 0.2251, 0.2056, 0.2465]}, {"w": "few", "b": [0.2158, 0.2251, 0.2451, 0.2465]}, {"w": "ANNs", "b": [0.2552, 0.2251, 0.3077, 0.2465]}, {"w": "that", "b": [0.3178, 0.2251, 0.3504, 0.2465]}, {"w": "perform", "b": [0.3605, 0.2251, 0.4296, 0.2465]}, {"w": "various", "b": [0.4398, 0.2251, 0.5012, 0.2465]}, {"w": "logical", "b": [0.5114, 0.2251, 0.5658, 0.2465]}, {"w": "computations", "b": [0.576, 0.2251, 0.6908, 0.2465]}, {"w": "(see", "b": [0.7009, 0.2251, 0.7335, 0.2465]}, {"w": "Figure", "b": [0.7436, 0.2251, 0.7976, 0.2465]}, {"w": "10-3),", "b": [0.8078, 0.2251, 0.8571, 0.2465]}, {"w": "assuming", "b": [0.1429, 0.2441, 0.2222, 0.2655]}, {"w": "that", "b": [0.2269, 0.2441, 0.2595, 0.2655]}, {"w": "a", "b": [0.2642, 0.2441, 0.2733, 0.2655]}, {"w": "neuron", "b": [0.2781, 0.2441, 0.3391, 0.2655]}, {"w": "is", "b": [0.3439, 0.2441, 0.3571, 0.2655]}, {"w": "activated", "b": [0.3618, 0.2441, 0.4363, 0.2655]}, {"w": "when", "b": [0.4411, 0.2441, 0.4867, 0.2655]}, {"w": "at", "b": [0.4914, 0.2441, 0.5065, 0.2655]}, {"w": "least", "b": [0.5113, 0.2441, 0.5485, 0.2655]}, {"w": "two", "b": [0.5533, 0.2441, 0.5845, 0.2655]}, {"w": "of", "b": [0.5892, 0.2441, 0.606, 0.2655]}, {"w": "its", "b": [0.6108, 0.2441, 0.6303, 0.2655]}, {"w": "inputs", "b": [0.6351, 0.2441, 0.6876, 0.2655]}, {"w": "are", "b": [0.6924, 0.2441, 0.7181, 0.2655]}, {"w": "active.", "b": [0.7228, 0.2441, 0.776, 0.2655]}]}, {"id": "b_2", "type": "equation", "text": "Figure 10-3. ANNs performing simple logical computations", "words": [{"w": "Figure", "b": [0.1429, 0.4414, 0.1943, 0.463]}, {"w": "10-3.", "b": [0.1991, 0.4414, 0.2407, 0.463]}, {"w": "ANNs", "b": [0.2455, 0.4414, 0.2951, 0.463]}, {"w": "performing", "b": [0.2999, 0.4414, 0.3902, 0.463]}, {"w": "simple", "b": [0.395, 0.4414, 0.4467, 0.463]}, {"w": "logical", "b": [0.4514, 0.4414, 0.5038, 0.463]}, {"w": "computations", "b": [0.5085, 0.4414, 0.6182, 0.463]}]}, {"id": "b_3", "type": "paragraph", "text": "• The first network on the left is simply the identity function: if neuron A is activa‐ ted, then neuron C gets activated as well (since it receives two input signals from neuron A), but if neuron A is off, then neuron C is off as well.", "words": [{"w": "•", "b": [0.16, 0.4848, 0.1682, 0.5062]}, {"w": "The", "b": [0.1786, 0.4848, 0.2114, 0.5062]}, {"w": "first", "b": [0.2164, 0.4848, 0.2499, 0.5062]}, {"w": "network", "b": [0.2549, 0.4848, 0.3245, 0.5062]}, {"w": "on", "b": [0.3295, 0.4848, 0.3516, 0.5062]}, {"w": "the", "b": [0.3566, 0.4848, 0.3829, 0.5062]}, {"w": "left", "b": [0.388, 0.4848, 0.4146, 0.5062]}, {"w": "is", "b": [0.4196, 0.4848, 0.4329, 0.5062]}, {"w": "simply", "b": [0.4379, 0.4848, 0.4936, 0.5062]}, {"w": "the", "b": [0.4986, 0.4848, 0.5249, 0.5062]}, {"w": "identity", "b": [0.53, 0.4848, 0.5942, 0.5062]}, {"w": "function:", "b": [0.5993, 0.4848, 0.6754, 0.5062]}, {"w": "if", "b": [0.6805, 0.4848, 0.6922, 0.5062]}, {"w": "neuron", "b": [0.6972, 0.4848, 0.7583, 0.5062]}, {"w": "A", "b": [0.7633, 0.4848, 0.7777, 0.5062]}, {"w": "is", "b": [0.7828, 0.4848, 0.796, 0.5062]}, {"w": "activa‐", "b": [0.801, 0.4848, 0.8571, 0.5062]}, {"w": "ted,", "b": [0.1786, 0.5039, 0.2095, 0.5253]}, {"w": "then", "b": [0.2149, 0.5039, 0.2527, 0.5253]}, {"w": "neuron", "b": [0.2581, 0.5039, 0.3192, 0.5253]}, {"w": "C", "b": [0.3246, 0.5039, 0.3384, 0.5253]}, {"w": "gets", "b": [0.3438, 0.5039, 0.3764, 0.5253]}, {"w": "activated", "b": [0.3819, 0.5039, 0.4564, 0.5253]}, {"w": "as", "b": [0.4618, 0.5039, 0.4786, 0.5253]}, {"w": "well", "b": [0.484, 0.5039, 0.5176, 0.5253]}, {"w": "(since", "b": [0.5231, 0.5039, 0.5726, 0.5253]}, {"w": "it", "b": [0.578, 0.5039, 0.5899, 0.5253]}, {"w": "receives", "b": [0.5953, 0.5039, 0.6613, 0.5253]}, {"w": "two", "b": [0.6667, 0.5039, 0.698, 0.5253]}, {"w": "input", "b": [0.7034, 0.5039, 0.7483, 0.5253]}, {"w": "signals", "b": [0.7537, 0.5039, 0.8101, 0.5253]}, {"w": "from", "b": [0.8156, 0.5039, 0.8571, 0.5253]}, {"w": "neuron", "b": [0.1786, 0.5229, 0.2396, 0.5443]}, {"w": "A),", "b": [0.2444, 0.5229, 0.2707, 0.5443]}, {"w": "but", "b": [0.2754, 0.5229, 0.3034, 0.5443]}, {"w": "if", "b": [0.3082, 0.5229, 0.3199, 0.5443]}, {"w": "neuron", "b": [0.3246, 0.5229, 0.3857, 0.5443]}, {"w": "A", "b": [0.3904, 0.5229, 0.4048, 0.5443]}, {"w": "is", "b": [0.4096, 0.5229, 0.4228, 0.5443]}, {"w": "off,", "b": [0.4275, 0.5229, 0.4552, 0.5443]}, {"w": "then", "b": [0.46, 0.5229, 0.4977, 0.5443]}, {"w": "neuron", "b": [0.5024, 0.5229, 0.5635, 0.5443]}, {"w": "C", "b": [0.5682, 0.5229, 0.5821, 0.5443]}, {"w": "is", "b": [0.5868, 0.5229, 0.6, 0.5443]}, {"w": "off", "b": [0.6047, 0.5229, 0.6277, 0.5443]}, {"w": "as", "b": [0.6324, 0.5229, 0.6492, 0.5443]}, {"w": "well.", "b": [0.654, 0.5229, 0.6924, 0.5443]}]}, {"id": "b_4", "type": "paragraph", "text": "• The second network performs a logical AND: neuron C is activated only when both neurons A and B are activated (a single input signal is not enough to acti‐ vate neuron C).", "words": [{"w": "•", "b": [0.16, 0.548, 0.1682, 0.5694]}, {"w": "The", "b": [0.1786, 0.548, 0.2114, 0.5694]}, {"w": "second", "b": [0.2183, 0.548, 0.2766, 0.5694]}, {"w": "network", "b": [0.2835, 0.548, 0.353, 0.5694]}, {"w": "performs", "b": [0.3599, 0.548, 0.4366, 0.5694]}, {"w": "a", "b": [0.4435, 0.548, 0.4526, 0.5694]}, {"w": "logical", "b": [0.4595, 0.548, 0.514, 0.5694]}, {"w": "AND:", "b": [0.5208, 0.548, 0.5708, 0.5694]}, {"w": "neuron", "b": [0.5776, 0.548, 0.6387, 0.5694]}, {"w": "C", "b": [0.6456, 0.548, 0.6594, 0.5694]}, {"w": "is", "b": [0.6663, 0.548, 0.6795, 0.5694]}, {"w": "activated", "b": [0.6864, 0.548, 0.7609, 0.5694]}, {"w": "only", "b": [0.7678, 0.548, 0.8046, 0.5694]}, {"w": "when", "b": [0.8115, 0.548, 0.8571, 0.5694]}, {"w": "both", "b": [0.1786, 0.5671, 0.2173, 0.5885]}, {"w": "neurons", "b": [0.2236, 0.5671, 0.2923, 0.5885]}, {"w": "A", "b": [0.2987, 0.5671, 0.3131, 0.5885]}, {"w": "and", "b": [0.3195, 0.5671, 0.351, 0.5885]}, {"w": "B", "b": [0.3574, 0.5671, 0.3696, 0.5885]}, {"w": "are", "b": [0.376, 0.5671, 0.4017, 0.5885]}, {"w": "activated", "b": [0.4081, 0.5671, 0.4826, 0.5885]}, {"w": "(a", "b": [0.4889, 0.5671, 0.5053, 0.5885]}, {"w": "single", "b": [0.5117, 0.5671, 0.5602, 0.5885]}, {"w": "input", "b": [0.5665, 0.5671, 0.6115, 0.5885]}, {"w": "signal", "b": [0.6178, 0.5671, 0.6666, 0.5885]}, {"w": "is", "b": [0.673, 0.5671, 0.6862, 0.5885]}, {"w": "not", "b": [0.6926, 0.5671, 0.7209, 0.5885]}, {"w": "enough", "b": [0.7273, 0.5671, 0.7901, 0.5885]}, {"w": "to", "b": [0.7965, 0.5671, 0.8135, 0.5885]}, {"w": "acti‐", "b": [0.8198, 0.5671, 0.8571, 0.5885]}, {"w": "vate", "b": [0.1786, 0.5861, 0.2122, 0.6075]}, {"w": "neuron", "b": [0.2169, 0.5861, 0.278, 0.6075]}, {"w": "C).", "b": [0.2827, 0.5861, 0.3085, 0.6075]}]}, {"id": "b_5", "type": "paragraph", "text": "• The third network performs a logical OR: neuron C gets activated if either neu‐ ron A or neuron B is activated (or both).", "words": [{"w": "•", "b": [0.16, 0.6112, 0.1682, 0.6326]}, {"w": "The", "b": [0.1786, 0.6112, 0.2114, 0.6326]}, {"w": "third", "b": [0.2175, 0.6112, 0.2593, 0.6326]}, {"w": "network", "b": [0.2655, 0.6112, 0.335, 0.6326]}, {"w": "performs", "b": [0.3412, 0.6112, 0.4179, 0.6326]}, {"w": "a", "b": [0.424, 0.6112, 0.4332, 0.6326]}, {"w": "logical", "b": [0.4393, 0.6112, 0.4938, 0.6326]}, {"w": "OR:", "b": [0.4999, 0.6112, 0.5332, 0.6326]}, {"w": "neuron", "b": [0.5393, 0.6112, 0.6004, 0.6326]}, {"w": "C", "b": [0.6065, 0.6112, 0.6204, 0.6326]}, {"w": "gets", "b": [0.6265, 0.6112, 0.6591, 0.6326]}, {"w": "activated", "b": [0.6652, 0.6112, 0.7397, 0.6326]}, {"w": "if", "b": [0.7459, 0.6112, 0.7576, 0.6326]}, {"w": "either", "b": [0.7638, 0.6112, 0.8123, 0.6326]}, {"w": "neu‐", "b": [0.8184, 0.6112, 0.8571, 0.6326]}, {"w": "ron", "b": [0.1786, 0.6303, 0.2083, 0.6517]}, {"w": "A", "b": [0.2131, 0.6303, 0.2274, 0.6517]}, {"w": "or", "b": [0.2322, 0.6303, 0.2505, 0.6517]}, {"w": "neuron", "b": [0.2553, 0.6303, 0.3163, 0.6517]}, {"w": "B", "b": [0.3211, 0.6303, 0.3333, 0.6517]}, {"w": "is", "b": [0.338, 0.6303, 0.3513, 0.6517]}, {"w": "activated", "b": [0.356, 0.6303, 0.4305, 0.6517]}, {"w": "(or", "b": [0.4352, 0.6303, 0.4608, 0.6517]}, {"w": "both).", "b": [0.4655, 0.6303, 0.5162, 0.6517]}]}, {"id": "b_6", "type": "paragraph", "text": "• Finally, if we suppose that an input connection can inhibit the neuron’s activity (which is the case with biological neurons), then the fourth network computes a slightly more complex logical proposition: neuron C is activated only if neuron A is active and if neuron B is off. If neuron A is active all the time, then you get a logical NOT: neuron C is active when neuron B is off, and vice versa.", "words": [{"w": "•", "b": [0.16, 0.6553, 0.1682, 0.6768]}, {"w": "Finally,", "b": [0.1786, 0.6553, 0.239, 0.6768]}, {"w": "if", "b": [0.2458, 0.6553, 0.2575, 0.6768]}, {"w": "we", "b": [0.2643, 0.6553, 0.2874, 0.6768]}, {"w": "suppose", "b": [0.2942, 0.6553, 0.3618, 0.6768]}, {"w": "that", "b": [0.3686, 0.6553, 0.4012, 0.6768]}, {"w": "an", "b": [0.4079, 0.6553, 0.4285, 0.6768]}, {"w": "input", "b": [0.4352, 0.6553, 0.4802, 0.6768]}, {"w": "connection", "b": [0.4869, 0.6553, 0.5808, 0.6768]}, {"w": "can", "b": [0.5875, 0.6553, 0.6169, 0.6768]}, {"w": "inhibit", "b": [0.6236, 0.6553, 0.6798, 0.6768]}, {"w": "the", "b": [0.6866, 0.6553, 0.7129, 0.6768]}, {"w": "neuron’s", "b": [0.7197, 0.6553, 0.7893, 0.6768]}, {"w": "activity", "b": [0.7961, 0.6553, 0.8571, 0.6768]}, {"w": "(which", "b": [0.1786, 0.6744, 0.2367, 0.6958]}, {"w": "is", "b": [0.2426, 0.6744, 0.2558, 0.6958]}, {"w": "the", "b": [0.2617, 0.6744, 0.288, 0.6958]}, {"w": "case", "b": [0.2939, 0.6744, 0.3283, 0.6958]}, {"w": "with", "b": [0.3342, 0.6744, 0.3715, 0.6958]}, {"w": "biological", "b": [0.3774, 0.6744, 0.4586, 0.6958]}, {"w": "neurons),", "b": [0.4645, 0.6744, 0.5452, 0.6958]}, {"w": "then", "b": [0.551, 0.6744, 0.5888, 0.6958]}, {"w": "the", "b": [0.5946, 0.6744, 0.621, 0.6958]}, {"w": "fourth", "b": [0.6268, 0.6744, 0.6799, 0.6958]}, {"w": "network", "b": [0.6858, 0.6744, 0.7553, 0.6958]}, {"w": "computes", "b": [0.7612, 0.6744, 0.8421, 0.6958]}, {"w": "a", "b": [0.848, 0.6744, 0.8571, 0.6958]}, {"w": "slightly", "b": [0.1786, 0.6934, 0.2387, 0.7149]}, {"w": "more", "b": [0.2437, 0.6934, 0.2879, 0.7149]}, {"w": "complex", "b": [0.2929, 0.6934, 0.3639, 0.7149]}, {"w": "logical", "b": [0.3688, 0.6934, 0.4232, 0.7149]}, {"w": "proposition:", "b": [0.4282, 0.6934, 0.5309, 0.7149]}, {"w": "neuron", "b": [0.5359, 0.6934, 0.5969, 0.7149]}, {"w": "C", "b": [0.6019, 0.6934, 0.6157, 0.7149]}, {"w": "is", "b": [0.6207, 0.6934, 0.6339, 0.7149]}, {"w": "activated", "b": [0.6388, 0.6934, 0.7133, 0.7149]}, {"w": "only", "b": [0.7183, 0.6934, 0.7551, 0.7149]}, {"w": "if", "b": [0.7601, 0.6934, 0.7718, 0.7149]}, {"w": "neuron", "b": [0.7767, 0.6934, 0.8378, 0.7149]}, {"w": "A", "b": [0.8427, 0.6934, 0.8571, 0.7149]}, {"w": "is", "b": [0.1786, 0.7125, 0.1918, 0.7339]}, {"w": "active", "b": [0.198, 0.7125, 0.2464, 0.7339]}, {"w": "and", "b": [0.2525, 0.7125, 0.2841, 0.7339]}, {"w": "if", "b": [0.2903, 0.7125, 0.302, 0.7339]}, {"w": "neuron", "b": [0.3082, 0.7125, 0.3693, 0.7339]}, {"w": "B", "b": [0.3754, 0.7125, 0.3877, 0.7339]}, {"w": "is", "b": [0.3939, 0.7125, 0.4071, 0.7339]}, {"w": "off.", "b": [0.4133, 0.7125, 0.441, 0.7339]}, {"w": "If", "b": [0.4471, 0.7125, 0.4604, 0.7339]}, {"w": "neuron", "b": [0.4666, 0.7125, 0.5277, 0.7339]}, {"w": "A", "b": [0.5338, 0.7125, 0.5482, 0.7339]}, {"w": "is", "b": [0.5544, 0.7125, 0.5676, 0.7339]}, {"w": "active", "b": [0.5738, 0.7125, 0.6222, 0.7339]}, {"w": "all", "b": [0.6284, 0.7125, 0.6481, 0.7339]}, {"w": "the", "b": [0.6542, 0.7125, 0.6806, 0.7339]}, {"w": "time,", "b": [0.6868, 0.7125, 0.7294, 0.7339]}, {"w": "then", "b": [0.7355, 0.7125, 0.7733, 0.7339]}, {"w": "you", "b": [0.7794, 0.7125, 0.8107, 0.7339]}, {"w": "get", "b": [0.8169, 0.7125, 0.8418, 0.7339]}, {"w": "a", "b": [0.848, 0.7125, 0.8571, 0.7339]}, {"w": "logical", "b": [0.1786, 0.7315, 0.233, 0.7529]}, {"w": "NOT:", "b": [0.2378, 0.7315, 0.2857, 0.7529]}, {"w": "neuron", "b": [0.2905, 0.7315, 0.3515, 0.7529]}, {"w": "C", "b": [0.3563, 0.7315, 0.3701, 0.7529]}, {"w": "is", "b": [0.3749, 0.7315, 0.3881, 0.7529]}, {"w": "active", "b": [0.3928, 0.7315, 0.4412, 0.7529]}, {"w": "when", "b": [0.4459, 0.7315, 0.4916, 0.7529]}, {"w": "neuron", "b": [0.4963, 0.7315, 0.5574, 0.7529]}, {"w": "B", "b": [0.5621, 0.7315, 0.5744, 0.7529]}, {"w": "is", "b": [0.5791, 0.7315, 0.5923, 0.7529]}, {"w": "off,", "b": [0.597, 0.7315, 0.6247, 0.7529]}, {"w": "and", "b": [0.6295, 0.7315, 0.661, 0.7529]}, {"w": "vice", "b": [0.6657, 0.7315, 0.6986, 0.7529]}, {"w": "versa.", "b": [0.7034, 0.7315, 0.7511, 0.7529]}]}, {"id": "b_7", "type": "paragraph", "text": "You can easily imagine how these networks can be combined to compute complex logical expressions (see the exercises at the end of the chapter).", "words": [{"w": "You", "b": [0.1429, 0.7657, 0.1752, 0.7871]}, {"w": "can", "b": [0.1826, 0.7657, 0.212, 0.7871]}, {"w": "easily", "b": [0.2194, 0.7657, 0.2655, 0.7871]}, {"w": "imagine", "b": [0.2729, 0.7657, 0.3403, 0.7871]}, {"w": "how", "b": [0.3477, 0.7657, 0.3837, 0.7871]}, {"w": "these", "b": [0.3912, 0.7657, 0.434, 0.7871]}, {"w": "networks", "b": [0.4414, 0.7657, 0.5186, 0.7871]}, {"w": "can", "b": [0.526, 0.7657, 0.5554, 0.7871]}, {"w": "be", "b": [0.5628, 0.7657, 0.5823, 0.7871]}, {"w": "combined", "b": [0.5897, 0.7657, 0.6736, 0.7871]}, {"w": "to", "b": [0.681, 0.7657, 0.698, 0.7871]}, {"w": "compute", "b": [0.7054, 0.7657, 0.7787, 0.7871]}, {"w": "complex", "b": [0.7862, 0.7657, 0.8571, 0.7871]}, {"w": "logical", "b": [0.1429, 0.7847, 0.1973, 0.8062]}, {"w": "expressions", "b": [0.2021, 0.7847, 0.2988, 0.8062]}, {"w": "(see", "b": [0.3035, 0.7847, 0.3361, 0.8062]}, {"w": "the", "b": [0.3408, 0.7847, 0.3671, 0.8062]}, {"w": "exercises", "b": [0.3719, 0.7847, 0.4457, 0.8062]}, {"w": "at", "b": [0.4504, 0.7847, 0.4655, 0.8062]}, {"w": "the", "b": [0.4702, 0.7847, 0.4966, 0.8062]}, {"w": "end", "b": [0.5013, 0.7847, 0.5326, 0.8062]}, {"w": "of", "b": [0.5373, 0.7847, 0.5541, 0.8062]}, {"w": "the", "b": [0.5588, 0.7847, 0.5851, 0.8062]}, {"w": "chapter).", "b": [0.5899, 0.7847, 0.6644, 0.8062]}]}, {"id": "b_8", "type": "paragraph", "text": "The Perceptron", "words": [{"w": "The", "b": [0.1429, 0.8189, 0.1805, 0.8475]}, {"w": "Perceptron", "b": [0.1855, 0.8189, 0.2992, 0.8475]}]}, {"id": "b_9", "type": "paragraph", "text": "The Perceptron is one of the simplest ANN architectures, invented in 1957 by Frank Rosenblatt. It is based on a slightly different artificial neuron (see Figure 10-4) called", "words": [{"w": "The", "b": [0.1429, 0.8534, 0.1757, 0.8748]}, {"w": "Perceptron", "b": [0.182, 0.8532, 0.2686, 0.8748]}, {"w": "is", "b": [0.2749, 0.8534, 0.2881, 0.8748]}, {"w": "one", "b": [0.2944, 0.8534, 0.3253, 0.8748]}, {"w": "of", "b": [0.3315, 0.8534, 0.3483, 0.8748]}, {"w": "the", "b": [0.3546, 0.8534, 0.3809, 0.8748]}, {"w": "simplest", "b": [0.3872, 0.8534, 0.4561, 0.8748]}, {"w": "ANN", "b": [0.4624, 0.8534, 0.5078, 0.8748]}, {"w": "architectures,", "b": [0.514, 0.8534, 0.6268, 0.8748]}, {"w": "invented", "b": [0.6331, 0.8534, 0.7053, 0.8748]}, {"w": "in", "b": [0.7116, 0.8534, 0.7286, 0.8748]}, {"w": "1957", "b": [0.7348, 0.8534, 0.7748, 0.8748]}, {"w": "by", "b": [0.7811, 0.8534, 0.8013, 0.8748]}, {"w": "Frank", "b": [0.8075, 0.8534, 0.8571, 0.8748]}, {"w": "Rosenblatt.", "b": [0.1429, 0.8724, 0.2364, 0.8939]}, {"w": "It", "b": [0.2417, 0.8724, 0.2544, 0.8939]}, {"w": "is", "b": [0.2597, 0.8724, 0.2729, 0.8939]}, {"w": "based", "b": [0.2782, 0.8724, 0.3255, 0.8939]}, {"w": "on", "b": [0.3308, 0.8724, 0.3528, 0.8939]}, {"w": "a", "b": [0.3582, 0.8724, 0.3673, 0.8939]}, {"w": "slightly", "b": [0.3726, 0.8724, 0.4328, 0.8939]}, {"w": "different", "b": [0.4381, 0.8724, 0.5098, 0.8939]}, {"w": "artificial", "b": [0.5152, 0.8724, 0.5845, 0.8939]}, {"w": "neuron", "b": [0.5899, 0.8724, 0.6509, 0.8939]}, {"w": "(see", "b": [0.6563, 0.8724, 0.6888, 0.8939]}, {"w": "Figure", "b": [0.6942, 0.8724, 0.7482, 0.8939]}, {"w": "10-4)", "b": [0.7529, 0.8724, 0.7981, 0.8939]}, {"w": "called", "b": [0.8035, 0.8724, 0.8518, 0.8939]}]}, {"id": "b_10", "type": "paragraph", "text": "From Biological to Artificial Neurons | 281", "words": [{"w": "From", "b": [0.585, 0.9225, 0.6155, 0.9388]}, {"w": "Biological", "b": [0.6183, 0.9225, 0.6761, 0.9388]}, {"w": "to", "b": [0.6789, 0.9225, 0.6914, 0.9388]}, {"w": "Artificial", "b": [0.6942, 0.9225, 0.7441, 0.9388]}, {"w": "Neurons", "b": [0.7469, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "281", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 308, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 The name Perceptron is sometimes used to mean a tiny network with a single TLU.", "words": [{"w": "6", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "The", "b": [0.1587, 0.8749, 0.1837, 0.8912]}, {"w": "name", "b": [0.1873, 0.8749, 0.2227, 0.8912]}, {"w": "Perceptron", "b": [0.2263, 0.8748, 0.2924, 0.8912]}, {"w": "is", "b": [0.296, 0.8749, 0.3061, 0.8912]}, {"w": "sometimes", "b": [0.3097, 0.8749, 0.378, 0.8912]}, {"w": "used", "b": [0.3816, 0.8749, 0.411, 0.8912]}, {"w": "to", "b": [0.4146, 0.8749, 0.4275, 0.8912]}, {"w": "mean", "b": [0.4311, 0.8749, 0.4665, 0.8912]}, {"w": "a", "b": [0.4701, 0.8749, 0.4771, 0.8912]}, {"w": "tiny", "b": [0.4807, 0.8749, 0.5054, 0.8912]}, {"w": "network", "b": [0.509, 0.8749, 0.562, 0.8912]}, {"w": "with", "b": [0.5656, 0.8749, 0.594, 0.8912]}, {"w": "a", "b": [0.5977, 0.8749, 0.6046, 0.8912]}, {"w": "single", "b": [0.6082, 0.8749, 0.6452, 0.8912]}, {"w": "TLU.", "b": [0.6488, 0.8749, 0.6806, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "a threshold logic unit (TLU), or sometimes a linear threshold unit (LTU): the inputs and output are now numbers (instead of binary on/off values) and each input con‐ nection is associated with a weight. The TLU computes a weighted sum of its inputs (z = w1 x1 + w2 x2 + ⋯ + wn xn = xT w), then applies a step function to that sum and outputs the result: hw(x) = step(z), where z = xT w.", "words": [{"w": "a", "b": [0.1429, 0.0791, 0.152, 0.1005]}, {"w": "threshold", "b": [0.1592, 0.0789, 0.2337, 0.1005]}, {"w": "logic", "b": [0.2409, 0.0789, 0.2783, 0.1005]}, {"w": "unit", "b": [0.2855, 0.0789, 0.3189, 0.1005]}, {"w": "(TLU),", "b": [0.3261, 0.0791, 0.3839, 0.1005]}, {"w": "or", "b": [0.3911, 0.0791, 0.4095, 0.1005]}, {"w": "sometimes", "b": [0.4167, 0.0791, 0.5064, 0.1005]}, {"w": "a", "b": [0.5136, 0.0791, 0.5228, 0.1005]}, {"w": "linear", "b": [0.53, 0.0789, 0.577, 0.1005]}, {"w": "threshold", "b": [0.5843, 0.0789, 0.6587, 0.1005]}, {"w": "unit", "b": [0.666, 0.0789, 0.6993, 0.1005]}, {"w": "(LTU):", "b": [0.7065, 0.0791, 0.7638, 0.1005]}, {"w": "the", "b": [0.771, 0.0791, 0.7973, 0.1005]}, {"w": "inputs", "b": [0.8046, 0.0791, 0.8571, 0.1005]}, {"w": "and", "b": [0.1429, 0.0981, 0.1744, 0.1195]}, {"w": "output", "b": [0.1812, 0.0981, 0.2376, 0.1195]}, {"w": "are", "b": [0.2444, 0.0981, 0.2701, 0.1195]}, {"w": "now", "b": [0.2769, 0.0981, 0.3132, 0.1195]}, {"w": "numbers", "b": [0.32, 0.0981, 0.394, 0.1195]}, {"w": "(instead", "b": [0.4008, 0.0981, 0.4679, 0.1195]}, {"w": "of", "b": [0.4747, 0.0981, 0.4915, 0.1195]}, {"w": "binary", "b": [0.4983, 0.0981, 0.553, 0.1195]}, {"w": "on/off", "b": [0.5598, 0.0981, 0.6116, 0.1195]}, {"w": "values)", "b": [0.6184, 0.0981, 0.6773, 0.1195]}, {"w": "and", "b": [0.6841, 0.0981, 0.7156, 0.1195]}, {"w": "each", "b": [0.7224, 0.0981, 0.7604, 0.1195]}, {"w": "input", "b": [0.7672, 0.0981, 0.8121, 0.1195]}, {"w": "con‐", "b": [0.8189, 0.0981, 0.8571, 0.1195]}, {"w": "nection", "b": [0.1429, 0.1172, 0.2059, 0.1386]}, {"w": "is", "b": [0.212, 0.1172, 0.2252, 0.1386]}, {"w": "associated", "b": [0.2313, 0.1172, 0.3157, 0.1386]}, {"w": "with", "b": [0.3218, 0.1172, 0.3591, 0.1386]}, {"w": "a", "b": [0.3652, 0.1172, 0.3744, 0.1386]}, {"w": "weight.", "b": [0.3805, 0.1172, 0.4408, 0.1386]}, {"w": "The", "b": [0.4468, 0.1172, 0.4797, 0.1386]}, {"w": "TLU", "b": [0.4858, 0.1172, 0.5243, 0.1386]}, {"w": "computes", "b": [0.5304, 0.1172, 0.6114, 0.1386]}, {"w": "a", "b": [0.6175, 0.1172, 0.6266, 0.1386]}, {"w": "weighted", "b": [0.6327, 0.1172, 0.7081, 0.1386]}, {"w": "sum", "b": [0.7142, 0.1172, 0.7499, 0.1386]}, {"w": "of", "b": [0.756, 0.1172, 0.7728, 0.1386]}, {"w": "its", "b": [0.7789, 0.1172, 0.7985, 0.1386]}, {"w": "inputs", "b": [0.8046, 0.1172, 0.8572, 0.1386]}, {"w": "(z", "b": [0.1429, 0.136, 0.1588, 0.1576]}, {"w": "=", "b": [0.165, 0.1362, 0.1771, 0.1576]}, {"w": "w1", "b": [0.1833, 0.136, 0.2033, 0.1585]}, {"w": "x1", "b": [0.2095, 0.136, 0.2254, 0.1585]}, {"w": "+", "b": [0.2316, 0.1362, 0.2437, 0.1576]}, {"w": "w2", "b": [0.2499, 0.136, 0.2699, 0.1585]}, {"w": "x2", "b": [0.2761, 0.136, 0.292, 0.1585]}, {"w": "+", "b": [0.2982, 0.1362, 0.3103, 0.1576]}, {"w": "⋯", "b": [0.3165, 0.1394, 0.3374, 0.1553]}, {"w": "+", "b": [0.3436, 0.1362, 0.3557, 0.1576]}, {"w": "wn", "b": [0.3619, 0.136, 0.3825, 0.1585]}, {"w": "xn", "b": [0.3888, 0.136, 0.4053, 0.1585]}, {"w": "=", "b": [0.4115, 0.1362, 0.4236, 0.1576]}, {"w": "xT", "b": [0.4298, 0.1356, 0.4474, 0.1576]}, {"w": "w),", "b": [0.4536, 0.1356, 0.4798, 0.1576]}, {"w": "then", "b": [0.4861, 0.1362, 0.5238, 0.1576]}, {"w": "applies", "b": [0.53, 0.1362, 0.588, 0.1576]}, {"w": "a", "b": [0.5942, 0.1362, 0.6033, 0.1576]}, {"w": "step", "b": [0.6096, 0.136, 0.641, 0.1576]}, {"w": "function", "b": [0.6472, 0.136, 0.7153, 0.1576]}, {"w": "to", "b": [0.7216, 0.1362, 0.7385, 0.1576]}, {"w": "that", "b": [0.7448, 0.1362, 0.7774, 0.1576]}, {"w": "sum", "b": [0.7836, 0.1362, 0.8194, 0.1576]}, {"w": "and", "b": [0.8256, 0.1362, 0.8571, 0.1576]}, {"w": "outputs", "b": [0.1429, 0.1553, 0.2069, 0.1767]}, {"w": "the", "b": [0.2116, 0.1553, 0.2379, 0.1767]}, {"w": "result:", "b": [0.2427, 0.1553, 0.2943, 0.1767]}, {"w": "hw(x)", "b": [0.2991, 0.1547, 0.3427, 0.1776]}, {"w": "=", "b": [0.3474, 0.1553, 0.3595, 0.1767]}, {"w": "step(z),", "b": [0.3642, 0.155, 0.4259, 0.1767]}, {"w": "where", "b": [0.4306, 0.1553, 0.4815, 0.1767]}, {"w": "z", "b": [0.4862, 0.155, 0.4949, 0.1767]}, {"w": "=", "b": [0.4996, 0.1553, 0.5117, 0.1767]}, {"w": "xT", "b": [0.5164, 0.1547, 0.534, 0.1767]}, {"w": "w.", "b": [0.5387, 0.1547, 0.5577, 0.1767]}]}, {"id": "b_2", "type": "equation", "text": "Figure 10-4. Threshold logic unit", "words": [{"w": "Figure", "b": [0.1428, 0.3696, 0.1943, 0.3912]}, {"w": "10-4.", "b": [0.1991, 0.3696, 0.2407, 0.3912]}, {"w": "Threshold", "b": [0.2455, 0.3696, 0.3262, 0.3912]}, {"w": "logic", "b": [0.331, 0.3696, 0.3683, 0.3912]}, {"w": "unit", "b": [0.3731, 0.3696, 0.4064, 0.3912]}]}, {"id": "b_3", "type": "paragraph", "text": "The most common step function used in Perceptrons is the Heaviside step function (see Equation 10-1). Sometimes the sign function is used instead.", "words": [{"w": "The", "b": [0.1428, 0.4069, 0.1757, 0.4284]}, {"w": "most", "b": [0.1828, 0.4069, 0.2245, 0.4284]}, {"w": "common", "b": [0.2315, 0.4069, 0.3071, 0.4284]}, {"w": "step", "b": [0.3142, 0.4069, 0.348, 0.4284]}, {"w": "function", "b": [0.3551, 0.4069, 0.4265, 0.4284]}, {"w": "used", "b": [0.4335, 0.4069, 0.4721, 0.4284]}, {"w": "in", "b": [0.4792, 0.4069, 0.4962, 0.4284]}, {"w": "Perceptrons", "b": [0.5033, 0.4069, 0.6032, 0.4284]}, {"w": "is", "b": [0.6103, 0.4069, 0.6235, 0.4284]}, {"w": "the", "b": [0.6306, 0.4069, 0.657, 0.4284]}, {"w": "Heaviside", "b": [0.664, 0.4067, 0.7434, 0.4284]}, {"w": "step", "b": [0.7505, 0.4067, 0.7819, 0.4284]}, {"w": "function", "b": [0.789, 0.4067, 0.8571, 0.4284]}, {"w": "(see", "b": [0.1429, 0.426, 0.1754, 0.4474]}, {"w": "Equation", "b": [0.1802, 0.426, 0.2564, 0.4474]}, {"w": "10-1).", "b": [0.2611, 0.426, 0.3105, 0.4474]}, {"w": "Sometimes", "b": [0.3152, 0.426, 0.4072, 0.4474]}, {"w": "the", "b": [0.4119, 0.426, 0.4382, 0.4474]}, {"w": "sign", "b": [0.4429, 0.426, 0.4773, 0.4474]}, {"w": "function", "b": [0.4821, 0.426, 0.5534, 0.4474]}, {"w": "is", "b": [0.5582, 0.426, 0.5714, 0.4474]}, {"w": "used", "b": [0.5761, 0.426, 0.6147, 0.4474]}, {"w": "instead.", "b": [0.6194, 0.426, 0.6842, 0.4474]}]}, {"id": "b_4", "type": "equation", "text": "Equation 10-1. Common step functions used in Perceptrons", "words": [{"w": "Equation", "b": [0.1726, 0.4655, 0.2473, 0.4871]}, {"w": "10-1.", "b": [0.2521, 0.4655, 0.2937, 0.4871]}, {"w": "Common", "b": [0.2985, 0.4655, 0.3743, 0.4871]}, {"w": "step", "b": [0.3791, 0.4655, 0.4105, 0.4871]}, {"w": "functions", "b": [0.4152, 0.4655, 0.4904, 0.4871]}, {"w": "used", "b": [0.4951, 0.4655, 0.5322, 0.4871]}, {"w": "in", "b": [0.537, 0.4655, 0.5535, 0.4871]}, {"w": "Perceptrons", "b": [0.5582, 0.4655, 0.6519, 0.4871]}]}, {"id": "b_5", "type": "equation", "text": "heaviside z = 0 if z < 0", "words": [{"w": "heaviside", "b": [0.1726, 0.5152, 0.2464, 0.5356]}, {"w": "z", "b": [0.2587, 0.515, 0.267, 0.5356]}, {"w": "=", "b": [0.2798, 0.5152, 0.2913, 0.5356]}, {"w": "0", "b": [0.3037, 0.5044, 0.3132, 0.5248]}, {"w": "if", "b": [0.3219, 0.5044, 0.3331, 0.5248]}, {"w": "z", "b": [0.3427, 0.5042, 0.351, 0.5248]}, {"w": "<", "b": [0.3569, 0.5044, 0.3678, 0.5248]}, {"w": "0", "b": [0.3733, 0.5044, 0.3829, 0.5248]}]}, {"id": "b_6", "type": "equation", "text": "1 if z ≥0 sgn z =", "words": [{"w": "1", "b": [0.3037, 0.5261, 0.3132, 0.5465]}, {"w": "if", "b": [0.3219, 0.5261, 0.3331, 0.5465]}, {"w": "z", "b": [0.3427, 0.5259, 0.351, 0.5465]}, {"w": "≥0", "b": [0.3569, 0.5261, 0.3834, 0.5465]}, {"w": "sgn", "b": [0.4373, 0.5152, 0.4647, 0.5356]}, {"w": "z", "b": [0.4771, 0.515, 0.4854, 0.5356]}, {"w": "=", "b": [0.4981, 0.5152, 0.5096, 0.5356]}]}, {"id": "b_7", "type": "equation", "text": "−1 if z < 0 0 if z = 0 +1 if z > 0", "words": [{"w": "−1", "b": [0.522, 0.4935, 0.5442, 0.5139]}, {"w": "if", "b": [0.5529, 0.4935, 0.564, 0.5139]}, {"w": "z", "b": [0.5736, 0.4933, 0.5819, 0.5139]}, {"w": "<", "b": [0.5878, 0.4935, 0.5987, 0.5139]}, {"w": "0", "b": [0.6043, 0.4935, 0.6138, 0.5139]}, {"w": "0", "b": [0.522, 0.5152, 0.5315, 0.5356]}, {"w": "if", "b": [0.5529, 0.5152, 0.564, 0.5356]}, {"w": "z", "b": [0.5736, 0.515, 0.5819, 0.5356]}, {"w": "=", "b": [0.5878, 0.5152, 0.5993, 0.5356]}, {"w": "0", "b": [0.6048, 0.5152, 0.6143, 0.5356]}, {"w": "+1", "b": [0.522, 0.537, 0.5442, 0.5574]}, {"w": "if", "b": [0.5529, 0.537, 0.564, 0.5574]}, {"w": "z", "b": [0.5736, 0.5368, 0.5819, 0.5574]}, {"w": ">", "b": [0.5878, 0.537, 0.5987, 0.5574]}, {"w": "0", "b": [0.6043, 0.537, 0.6138, 0.5574]}]}, {"id": "b_8", "type": "paragraph", "text": "A single TLU can be used for simple linear binary classification. It computes a linear combination of the inputs and if the result exceeds a threshold, it outputs the positive class or else outputs the negative class (just like a Logistic Regression classifier or a linear SVM). For example, you could use a single TLU to classify iris flowers based on the petal length and width (also adding an extra bias feature x0 = 1, just like we did in previous chapters). Training a TLU in this case means finding the right values for w0, w1, and w2 (the training algorithm is discussed shortly).", "words": [{"w": "A", "b": [0.1429, 0.5762, 0.1573, 0.5976]}, {"w": "single", "b": [0.163, 0.5762, 0.2115, 0.5976]}, {"w": "TLU", "b": [0.2173, 0.5762, 0.2558, 0.5976]}, {"w": "can", "b": [0.2616, 0.5762, 0.2909, 0.5976]}, {"w": "be", "b": [0.2967, 0.5762, 0.3161, 0.5976]}, {"w": "used", "b": [0.3219, 0.5762, 0.3605, 0.5976]}, {"w": "for", "b": [0.3662, 0.5762, 0.3907, 0.5976]}, {"w": "simple", "b": [0.3965, 0.5762, 0.4514, 0.5976]}, {"w": "linear", "b": [0.4572, 0.5762, 0.5052, 0.5976]}, {"w": "binary", "b": [0.5109, 0.5762, 0.5655, 0.5976]}, {"w": "classification.", "b": [0.5713, 0.5762, 0.6834, 0.5976]}, {"w": "It", "b": [0.6892, 0.5762, 0.7018, 0.5976]}, {"w": "computes", "b": [0.7076, 0.5762, 0.7885, 0.5976]}, {"w": "a", "b": [0.7943, 0.5762, 0.8034, 0.5976]}, {"w": "linear", "b": [0.8092, 0.5762, 0.8571, 0.5976]}, {"w": "combination", "b": [0.1429, 0.5952, 0.2496, 0.6166]}, {"w": "of", "b": [0.2546, 0.5952, 0.2714, 0.6166]}, {"w": "the", "b": [0.2765, 0.5952, 0.3028, 0.6166]}, {"w": "inputs", "b": [0.3078, 0.5952, 0.3604, 0.6166]}, {"w": "and", "b": [0.3654, 0.5952, 0.3969, 0.6166]}, {"w": "if", "b": [0.402, 0.5952, 0.4137, 0.6166]}, {"w": "the", "b": [0.4187, 0.5952, 0.4451, 0.6166]}, {"w": "result", "b": [0.4501, 0.5952, 0.497, 0.6166]}, {"w": "exceeds", "b": [0.502, 0.5952, 0.5659, 0.6166]}, {"w": "a", "b": [0.5709, 0.5952, 0.5801, 0.6166]}, {"w": "threshold,", "b": [0.5851, 0.5952, 0.6696, 0.6166]}, {"w": "it", "b": [0.6746, 0.5952, 0.6865, 0.6166]}, {"w": "outputs", "b": [0.6915, 0.5952, 0.7556, 0.6166]}, {"w": "the", "b": [0.7606, 0.5952, 0.7869, 0.6166]}, {"w": "positive", "b": [0.7919, 0.5952, 0.8571, 0.6166]}, {"w": "class", "b": [0.1428, 0.6143, 0.1814, 0.6357]}, {"w": "or", "b": [0.1882, 0.6143, 0.2065, 0.6357]}, {"w": "else", "b": [0.2134, 0.6143, 0.244, 0.6357]}, {"w": "outputs", "b": [0.2508, 0.6143, 0.3148, 0.6357]}, {"w": "the", "b": [0.3216, 0.6143, 0.348, 0.6357]}, {"w": "negative", "b": [0.3548, 0.6143, 0.424, 0.6357]}, {"w": "class", "b": [0.4308, 0.6143, 0.4693, 0.6357]}, {"w": "(just", "b": [0.4761, 0.6143, 0.5137, 0.6357]}, {"w": "like", "b": [0.5205, 0.6143, 0.5506, 0.6357]}, {"w": "a", "b": [0.5574, 0.6143, 0.5665, 0.6357]}, {"w": "Logistic", "b": [0.5734, 0.6143, 0.6389, 0.6357]}, {"w": "Regression", "b": [0.6457, 0.6143, 0.7368, 0.6357]}, {"w": "classifier", "b": [0.7436, 0.6143, 0.816, 0.6357]}, {"w": "or", "b": [0.8228, 0.6143, 0.8412, 0.6357]}, {"w": "a", "b": [0.848, 0.6143, 0.8571, 0.6357]}, {"w": "linear", "b": [0.1429, 0.6333, 0.1908, 0.6547]}, {"w": "SVM).", "b": [0.1957, 0.6333, 0.2507, 0.6547]}, {"w": "For", "b": [0.2556, 0.6333, 0.2846, 0.6547]}, {"w": "example,", "b": [0.2894, 0.6333, 0.3637, 0.6547]}, {"w": "you", "b": [0.3685, 0.6333, 0.3998, 0.6547]}, {"w": "could", "b": [0.4046, 0.6333, 0.4514, 0.6547]}, {"w": "use", "b": [0.4562, 0.6333, 0.4838, 0.6547]}, {"w": "a", "b": [0.4887, 0.6333, 0.4978, 0.6547]}, {"w": "single", "b": [0.5026, 0.6333, 0.5511, 0.6547]}, {"w": "TLU", "b": [0.556, 0.6333, 0.5946, 0.6547]}, {"w": "to", "b": [0.5994, 0.6333, 0.6164, 0.6547]}, {"w": "classify", "b": [0.6212, 0.6333, 0.6814, 0.6547]}, {"w": "iris", "b": [0.6863, 0.6333, 0.7128, 0.6547]}, {"w": "flowers", "b": [0.7176, 0.6333, 0.7782, 0.6547]}, {"w": "based", "b": [0.7831, 0.6333, 0.8303, 0.6547]}, {"w": "on", "b": [0.8351, 0.6333, 0.8571, 0.6547]}, {"w": "the", "b": [0.1429, 0.6524, 0.1692, 0.6738]}, {"w": "petal", "b": [0.1744, 0.6524, 0.2149, 0.6738]}, {"w": "length", "b": [0.2201, 0.6524, 0.2728, 0.6738]}, {"w": "and", "b": [0.278, 0.6524, 0.3095, 0.6738]}, {"w": "width", "b": [0.3147, 0.6524, 0.363, 0.6738]}, {"w": "(also", "b": [0.3682, 0.6524, 0.4081, 0.6738]}, {"w": "adding", "b": [0.4133, 0.6524, 0.4711, 0.6738]}, {"w": "an", "b": [0.4763, 0.6524, 0.4968, 0.6738]}, {"w": "extra", "b": [0.502, 0.6524, 0.5439, 0.6738]}, {"w": "bias", "b": [0.5491, 0.6524, 0.5821, 0.6738]}, {"w": "feature", "b": [0.5872, 0.6524, 0.645, 0.6738]}, {"w": "x0", "b": [0.6502, 0.6521, 0.666, 0.6747]}, {"w": "=", "b": [0.6712, 0.6524, 0.6833, 0.6738]}, {"w": "1,", "b": [0.6884, 0.6524, 0.7032, 0.6738]}, {"w": "just", "b": [0.7083, 0.6524, 0.7387, 0.6738]}, {"w": "like", "b": [0.7439, 0.6524, 0.774, 0.6738]}, {"w": "we", "b": [0.7791, 0.6524, 0.8022, 0.6738]}, {"w": "did", "b": [0.8074, 0.6524, 0.835, 0.6738]}, {"w": "in", "b": [0.8402, 0.6524, 0.8571, 0.6738]}, {"w": "previous", "b": [0.1429, 0.6714, 0.2149, 0.6928]}, {"w": "chapters).", "b": [0.2204, 0.6714, 0.3025, 0.6928]}, {"w": "Training", "b": [0.3079, 0.6714, 0.3797, 0.6928]}, {"w": "a", "b": [0.3851, 0.6714, 0.3942, 0.6928]}, {"w": "TLU", "b": [0.3997, 0.6714, 0.4383, 0.6928]}, {"w": "in", "b": [0.4437, 0.6714, 0.4607, 0.6928]}, {"w": "this", "b": [0.4661, 0.6714, 0.4968, 0.6928]}, {"w": "case", "b": [0.5023, 0.6714, 0.5367, 0.6928]}, {"w": "means", "b": [0.5422, 0.6714, 0.5963, 0.6928]}, {"w": "finding", "b": [0.6017, 0.6714, 0.6626, 0.6928]}, {"w": "the", "b": [0.668, 0.6714, 0.6944, 0.6928]}, {"w": "right", "b": [0.6998, 0.6714, 0.74, 0.6928]}, {"w": "values", "b": [0.7454, 0.6714, 0.797, 0.6928]}, {"w": "for", "b": [0.8025, 0.6714, 0.827, 0.6928]}, {"w": "w0,", "b": [0.8324, 0.6712, 0.8571, 0.6937]}, {"w": "w1,", "b": [0.1429, 0.6902, 0.1676, 0.7127]}, {"w": "and", "b": [0.1723, 0.6904, 0.2038, 0.7119]}, {"w": "w2", "b": [0.2086, 0.6902, 0.2285, 0.7127]}, {"w": "(the", "b": [0.2333, 0.6904, 0.2668, 0.7119]}, {"w": "training", "b": [0.2715, 0.6904, 0.3385, 0.7119]}, {"w": "algorithm", "b": [0.3432, 0.6904, 0.4258, 0.7119]}, {"w": "is", "b": [0.4306, 0.6904, 0.4438, 0.7119]}, {"w": "discussed", "b": [0.4485, 0.6904, 0.5278, 0.7119]}, {"w": "shortly).", "b": [0.5325, 0.6904, 0.6028, 0.7119]}]}, {"id": "b_9", "type": "paragraph", "text": "A Perceptron is simply composed of a single layer of TLUs,6 with each TLU connected to all the inputs. When all the neurons in a layer are connected to every neuron in the previous layer (i.e., its input neurons), it is called a fully connected layer or a dense layer. To represent the fact that each input is sent to every TLU, it is common to draw special passthrough neurons called input neurons: they just output whatever input they are fed. All the input neurons form the input layer. Moreover, an extra bias fea‐", "words": [{"w": "A", "b": [0.1429, 0.7186, 0.1573, 0.74]}, {"w": "Perceptron", "b": [0.162, 0.7186, 0.2543, 0.74]}, {"w": "is", "b": [0.259, 0.7186, 0.2723, 0.74]}, {"w": "simply", "b": [0.277, 0.7186, 0.3326, 0.74]}, {"w": "composed", "b": [0.3374, 0.7186, 0.4225, 0.74]}, {"w": "of", "b": [0.4273, 0.7186, 0.444, 0.74]}, {"w": "a", "b": [0.4488, 0.7186, 0.4579, 0.74]}, {"w": "single", "b": [0.4626, 0.7186, 0.5111, 0.74]}, {"w": "layer", "b": [0.5159, 0.7186, 0.5561, 0.74]}, {"w": "of", "b": [0.5608, 0.7186, 0.5776, 0.74]}, {"w": "TLUs,6", "b": [0.5823, 0.7186, 0.6382, 0.74]}, {"w": "with", "b": [0.6429, 0.7186, 0.6803, 0.74]}, {"w": "each", "b": [0.685, 0.7186, 0.7229, 0.74]}, {"w": "TLU", "b": [0.7277, 0.7186, 0.7662, 0.74]}, {"w": "connected", "b": [0.771, 0.7186, 0.8571, 0.74]}, {"w": "to", "b": [0.1429, 0.7376, 0.1598, 0.759]}, {"w": "all", "b": [0.1647, 0.7376, 0.1844, 0.759]}, {"w": "the", "b": [0.1893, 0.7376, 0.2156, 0.759]}, {"w": "inputs.", "b": [0.2205, 0.7376, 0.2778, 0.759]}, {"w": "When", "b": [0.2827, 0.7376, 0.3343, 0.759]}, {"w": "all", "b": [0.3392, 0.7376, 0.3589, 0.759]}, {"w": "the", "b": [0.3637, 0.7376, 0.3901, 0.759]}, {"w": "neurons", "b": [0.3949, 0.7376, 0.4636, 0.759]}, {"w": "in", "b": [0.4685, 0.7376, 0.4855, 0.759]}, {"w": "a", "b": [0.4904, 0.7376, 0.4995, 0.759]}, {"w": "layer", "b": [0.5044, 0.7376, 0.5446, 0.759]}, {"w": "are", "b": [0.5495, 0.7376, 0.5752, 0.759]}, {"w": "connected", "b": [0.5801, 0.7376, 0.6662, 0.759]}, {"w": "to", "b": [0.671, 0.7376, 0.688, 0.759]}, {"w": "every", "b": [0.6929, 0.7376, 0.7382, 0.759]}, {"w": "neuron", "b": [0.743, 0.7376, 0.8041, 0.759]}, {"w": "in", "b": [0.809, 0.7376, 0.8259, 0.759]}, {"w": "the", "b": [0.8308, 0.7376, 0.8572, 0.759]}, {"w": "previous", "b": [0.1429, 0.7567, 0.2149, 0.7781]}, {"w": "layer", "b": [0.2222, 0.7567, 0.2624, 0.7781]}, {"w": "(i.e.,", "b": [0.2697, 0.7567, 0.3056, 0.7781]}, {"w": "its", "b": [0.3128, 0.7567, 0.3324, 0.7781]}, {"w": "input", "b": [0.3397, 0.7567, 0.3846, 0.7781]}, {"w": "neurons),", "b": [0.3919, 0.7567, 0.4726, 0.7781]}, {"w": "it", "b": [0.4799, 0.7567, 0.4918, 0.7781]}, {"w": "is", "b": [0.4991, 0.7567, 0.5123, 0.7781]}, {"w": "called", "b": [0.5196, 0.7567, 0.5679, 0.7781]}, {"w": "a", "b": [0.5752, 0.7567, 0.5844, 0.7781]}, {"w": "fully", "b": [0.5916, 0.7565, 0.6276, 0.7781]}, {"w": "connected", "b": [0.6349, 0.7565, 0.7152, 0.7781]}, {"w": "layer", "b": [0.7226, 0.7565, 0.7625, 0.7781]}, {"w": "or", "b": [0.7698, 0.7567, 0.7881, 0.7781]}, {"w": "a", "b": [0.7954, 0.7567, 0.8045, 0.7781]}, {"w": "dense", "b": [0.8118, 0.7565, 0.8571, 0.7781]}, {"w": "layer.", "b": [0.1429, 0.7755, 0.1875, 0.7971]}, {"w": "To", "b": [0.1927, 0.7757, 0.2141, 0.7971]}, {"w": "represent", "b": [0.2192, 0.7757, 0.2972, 0.7971]}, {"w": "the", "b": [0.3023, 0.7757, 0.3287, 0.7971]}, {"w": "fact", "b": [0.3338, 0.7757, 0.3643, 0.7971]}, {"w": "that", "b": [0.3694, 0.7757, 0.402, 0.7971]}, {"w": "each", "b": [0.4072, 0.7757, 0.4451, 0.7971]}, {"w": "input", "b": [0.4502, 0.7757, 0.4951, 0.7971]}, {"w": "is", "b": [0.5003, 0.7757, 0.5135, 0.7971]}, {"w": "sent", "b": [0.5187, 0.7757, 0.5525, 0.7971]}, {"w": "to", "b": [0.5577, 0.7757, 0.5746, 0.7971]}, {"w": "every", "b": [0.5798, 0.7757, 0.625, 0.7971]}, {"w": "TLU,", "b": [0.6302, 0.7757, 0.6719, 0.7971]}, {"w": "it", "b": [0.6771, 0.7757, 0.689, 0.7971]}, {"w": "is", "b": [0.6941, 0.7757, 0.7074, 0.7971]}, {"w": "common", "b": [0.7125, 0.7757, 0.7881, 0.7971]}, {"w": "to", "b": [0.7932, 0.7757, 0.8102, 0.7971]}, {"w": "draw", "b": [0.8154, 0.7757, 0.8571, 0.7971]}, {"w": "special", "b": [0.1428, 0.7948, 0.1991, 0.8162]}, {"w": "passthrough", "b": [0.2072, 0.7948, 0.3104, 0.8162]}, {"w": "neurons", "b": [0.3185, 0.7948, 0.3872, 0.8162]}, {"w": "called", "b": [0.3954, 0.7948, 0.4437, 0.8162]}, {"w": "input", "b": [0.4519, 0.7945, 0.4952, 0.8162]}, {"w": "neurons:", "b": [0.5034, 0.7945, 0.5732, 0.8162]}, {"w": "they", "b": [0.5813, 0.7948, 0.6172, 0.8162]}, {"w": "just", "b": [0.6254, 0.7948, 0.6558, 0.8162]}, {"w": "output", "b": [0.6639, 0.7948, 0.7203, 0.8162]}, {"w": "whatever", "b": [0.7285, 0.7948, 0.8041, 0.8162]}, {"w": "input", "b": [0.8122, 0.7948, 0.8571, 0.8162]}, {"w": "they", "b": [0.1429, 0.8138, 0.1788, 0.8352]}, {"w": "are", "b": [0.1847, 0.8138, 0.2104, 0.8352]}, {"w": "fed.", "b": [0.2163, 0.8138, 0.2471, 0.8352]}, {"w": "All", "b": [0.253, 0.8138, 0.2779, 0.8352]}, {"w": "the", "b": [0.2838, 0.8138, 0.3101, 0.8352]}, {"w": "input", "b": [0.316, 0.8138, 0.361, 0.8352]}, {"w": "neurons", "b": [0.3669, 0.8138, 0.4356, 0.8352]}, {"w": "form", "b": [0.4415, 0.8138, 0.4831, 0.8352]}, {"w": "the", "b": [0.489, 0.8138, 0.5153, 0.8352]}, {"w": "input", "b": [0.5212, 0.8136, 0.5645, 0.8352]}, {"w": "layer.", "b": [0.5704, 0.8136, 0.6151, 0.8352]}, {"w": "Moreover,", "b": [0.621, 0.8138, 0.7065, 0.8352]}, {"w": "an", "b": [0.7124, 0.8138, 0.733, 0.8352]}, {"w": "extra", "b": [0.7389, 0.8138, 0.7808, 0.8352]}, {"w": "bias", "b": [0.7867, 0.8138, 0.8197, 0.8352]}, {"w": "fea‐", "b": [0.8256, 0.8138, 0.8571, 0.8352]}]}, {"id": "b_10", "type": "paragraph", "text": "282 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "282", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4163, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4583, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 309, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "ture is generally added (x0 = 1): it is typically represented using a special type of neu‐ ron called a bias neuron, which just outputs 1 all the time. A Perceptron with two inputs and three outputs is represented in Figure 10-5. This Perceptron can classify instances simultaneously into three different binary classes, which makes it a multi‐ output classifier.", "words": [{"w": "ture", "b": [0.1429, 0.0791, 0.1769, 0.1005]}, {"w": "is", "b": [0.1823, 0.0791, 0.1956, 0.1005]}, {"w": "generally", "b": [0.201, 0.0791, 0.2769, 0.1005]}, {"w": "added", "b": [0.2824, 0.0791, 0.3334, 0.1005]}, {"w": "(x0", "b": [0.3388, 0.0789, 0.3619, 0.1014]}, {"w": "=", "b": [0.3674, 0.0791, 0.3795, 0.1005]}, {"w": "1):", "b": [0.3849, 0.0791, 0.4069, 0.1005]}, {"w": "it", "b": [0.4124, 0.0791, 0.4243, 0.1005]}, {"w": "is", "b": [0.4298, 0.0791, 0.443, 0.1005]}, {"w": "typically", "b": [0.4485, 0.0791, 0.519, 0.1005]}, {"w": "represented", "b": [0.5245, 0.0791, 0.6222, 0.1005]}, {"w": "using", "b": [0.6277, 0.0791, 0.6732, 0.1005]}, {"w": "a", "b": [0.6786, 0.0791, 0.6878, 0.1005]}, {"w": "special", "b": [0.6933, 0.0791, 0.7495, 0.1005]}, {"w": "type", "b": [0.755, 0.0791, 0.7907, 0.1005]}, {"w": "of", "b": [0.7961, 0.0791, 0.8129, 0.1005]}, {"w": "neu‐", "b": [0.8184, 0.0791, 0.8571, 0.1005]}, {"w": "ron", "b": [0.1429, 0.0981, 0.1726, 0.1195]}, {"w": "called", "b": [0.1801, 0.0981, 0.2284, 0.1195]}, {"w": "a", "b": [0.2359, 0.0981, 0.2451, 0.1195]}, {"w": "bias", "b": [0.2525, 0.0979, 0.2853, 0.1195]}, {"w": "neuron,", "b": [0.2928, 0.0979, 0.3556, 0.1195]}, {"w": "which", "b": [0.3631, 0.0981, 0.414, 0.1195]}, {"w": "just", "b": [0.4214, 0.0981, 0.4518, 0.1195]}, {"w": "outputs", "b": [0.4593, 0.0981, 0.5233, 0.1195]}, {"w": "1", "b": [0.5308, 0.0981, 0.5408, 0.1195]}, {"w": "all", "b": [0.5483, 0.0981, 0.568, 0.1195]}, {"w": "the", "b": [0.5755, 0.0981, 0.6018, 0.1195]}, {"w": "time.", "b": [0.6093, 0.0981, 0.6519, 0.1195]}, {"w": "A", "b": [0.6594, 0.0981, 0.6738, 0.1195]}, {"w": "Perceptron", "b": [0.6813, 0.0981, 0.7736, 0.1195]}, {"w": "with", "b": [0.7811, 0.0981, 0.8184, 0.1195]}, {"w": "two", "b": [0.8259, 0.0981, 0.8571, 0.1195]}, {"w": "inputs", "b": [0.1429, 0.1172, 0.1954, 0.1386]}, {"w": "and", "b": [0.2021, 0.1172, 0.2336, 0.1386]}, {"w": "three", "b": [0.2403, 0.1172, 0.2832, 0.1386]}, {"w": "outputs", "b": [0.2899, 0.1172, 0.3539, 0.1386]}, {"w": "is", "b": [0.3606, 0.1172, 0.3738, 0.1386]}, {"w": "represented", "b": [0.3805, 0.1172, 0.4783, 0.1386]}, {"w": "in", "b": [0.4849, 0.1172, 0.5019, 0.1386]}, {"w": "Figure", "b": [0.5086, 0.1172, 0.5626, 0.1386]}, {"w": "10-5.", "b": [0.5692, 0.1172, 0.6114, 0.1386]}, {"w": "This", "b": [0.6181, 0.1172, 0.6553, 0.1386]}, {"w": "Perceptron", "b": [0.6619, 0.1172, 0.7543, 0.1386]}, {"w": "can", "b": [0.7609, 0.1172, 0.7903, 0.1386]}, {"w": "classify", "b": [0.797, 0.1172, 0.8572, 0.1386]}, {"w": "instances", "b": [0.1429, 0.1362, 0.2197, 0.1576]}, {"w": "simultaneously", "b": [0.2262, 0.1362, 0.3523, 0.1576]}, {"w": "into", "b": [0.3588, 0.1362, 0.3924, 0.1576]}, {"w": "three", "b": [0.3989, 0.1362, 0.4418, 0.1576]}, {"w": "different", "b": [0.4483, 0.1362, 0.52, 0.1576]}, {"w": "binary", "b": [0.5265, 0.1362, 0.5811, 0.1576]}, {"w": "classes,", "b": [0.5875, 0.1362, 0.6473, 0.1576]}, {"w": "which", "b": [0.6538, 0.1362, 0.7047, 0.1576]}, {"w": "makes", "b": [0.7112, 0.1362, 0.7643, 0.1576]}, {"w": "it", "b": [0.7707, 0.1362, 0.7827, 0.1576]}, {"w": "a", "b": [0.7892, 0.1362, 0.7983, 0.1576]}, {"w": "multi‐", "b": [0.8048, 0.1362, 0.8571, 0.1576]}, {"w": "output", "b": [0.1429, 0.1553, 0.1992, 0.1767]}, {"w": "classifier.", "b": [0.204, 0.1553, 0.2798, 0.1767]}]}, {"id": "b_1", "type": "equation", "text": "Figure 10-5. Perceptron diagram", "words": [{"w": "Figure", "b": [0.1429, 0.3933, 0.1943, 0.4149]}, {"w": "10-5.", "b": [0.1991, 0.3933, 0.2407, 0.4149]}, {"w": "Perceptron", "b": [0.2455, 0.3933, 0.3322, 0.4149]}, {"w": "diagram", "b": [0.3369, 0.3933, 0.4051, 0.4149]}]}, {"id": "b_2", "type": "paragraph", "text": "Thanks to the magic of linear algebra, it is possible to efficiently compute the outputs of a layer of artificial neurons for several instances at once, by using Equation 10-2:", "words": [{"w": "Thanks", "b": [0.1429, 0.4306, 0.2054, 0.4521]}, {"w": "to", "b": [0.2106, 0.4306, 0.2275, 0.4521]}, {"w": "the", "b": [0.2328, 0.4306, 0.2591, 0.4521]}, {"w": "magic", "b": [0.2643, 0.4306, 0.3147, 0.4521]}, {"w": "of", "b": [0.3199, 0.4306, 0.3367, 0.4521]}, {"w": "linear", "b": [0.3419, 0.4306, 0.3899, 0.4521]}, {"w": "algebra,", "b": [0.3951, 0.4306, 0.4603, 0.4521]}, {"w": "it", "b": [0.4655, 0.4306, 0.4775, 0.4521]}, {"w": "is", "b": [0.4827, 0.4306, 0.4959, 0.4521]}, {"w": "possible", "b": [0.5011, 0.4306, 0.5682, 0.4521]}, {"w": "to", "b": [0.5735, 0.4306, 0.5904, 0.4521]}, {"w": "efficiently", "b": [0.5956, 0.4306, 0.6779, 0.4521]}, {"w": "compute", "b": [0.6831, 0.4306, 0.7564, 0.4521]}, {"w": "the", "b": [0.7616, 0.4306, 0.7879, 0.4521]}, {"w": "outputs", "b": [0.7931, 0.4306, 0.8571, 0.4521]}, {"w": "of", "b": [0.1428, 0.4497, 0.1596, 0.4711]}, {"w": "a", "b": [0.1644, 0.4497, 0.1735, 0.4711]}, {"w": "layer", "b": [0.1782, 0.4497, 0.2184, 0.4711]}, {"w": "of", "b": [0.2232, 0.4497, 0.24, 0.4711]}, {"w": "artificial", "b": [0.2447, 0.4497, 0.3141, 0.4711]}, {"w": "neurons", "b": [0.3188, 0.4497, 0.3875, 0.4711]}, {"w": "for", "b": [0.3922, 0.4497, 0.4167, 0.4711]}, {"w": "several", "b": [0.4215, 0.4497, 0.4786, 0.4711]}, {"w": "instances", "b": [0.4833, 0.4497, 0.5602, 0.4711]}, {"w": "at", "b": [0.5649, 0.4497, 0.58, 0.4711]}, {"w": "once,", "b": [0.5847, 0.4497, 0.6292, 0.4711]}, {"w": "by", "b": [0.6339, 0.4497, 0.6541, 0.4711]}, {"w": "using", "b": [0.6588, 0.4497, 0.7042, 0.4711]}, {"w": "Equation", "b": [0.709, 0.4497, 0.7852, 0.4711]}, {"w": "10-2:", "b": [0.7899, 0.4497, 0.8321, 0.4711]}]}, {"id": "b_3", "type": "equation", "text": "Equation 10-2. Computing the outputs of a fully connected layer", "words": [{"w": "Equation", "b": [0.1726, 0.4892, 0.2473, 0.5108]}, {"w": "10-2.", "b": [0.2521, 0.4892, 0.2937, 0.5108]}, {"w": "Computing", "b": [0.2985, 0.4892, 0.3893, 0.5108]}, {"w": "the", "b": [0.3941, 0.4892, 0.4192, 0.5108]}, {"w": "outputs", "b": [0.4239, 0.4892, 0.4849, 0.5108]}, {"w": "of", "b": [0.4896, 0.4892, 0.5048, 0.5108]}, {"w": "a", "b": [0.5096, 0.4892, 0.5198, 0.5108]}, {"w": "fully", "b": [0.5246, 0.4892, 0.5606, 0.5108]}, {"w": "connected", "b": [0.5653, 0.4892, 0.6456, 0.5108]}, {"w": "layer", "b": [0.6504, 0.4892, 0.6903, 0.5108]}]}, {"id": "b_4", "type": "equation", "text": "hW, b X = ϕ XW + b", "words": [{"w": "hW,", "b": [0.1726, 0.517, 0.2019, 0.5419]}, {"w": "b", "b": [0.2046, 0.5251, 0.213, 0.5419]}, {"w": "X", "b": [0.2199, 0.5167, 0.2336, 0.5376]}, {"w": "=", "b": [0.246, 0.5172, 0.2575, 0.5376]}, {"w": "ϕ", "b": [0.2631, 0.517, 0.2741, 0.5376]}, {"w": "XW", "b": [0.281, 0.5167, 0.3142, 0.5376]}, {"w": "+", "b": [0.3186, 0.5172, 0.3301, 0.5376]}, {"w": "b", "b": [0.3345, 0.5167, 0.3451, 0.5376]}]}, {"id": "b_5", "type": "paragraph", "text": "• As always, X represents the matrix of input features. It has one row per instance, one column per feature.", "words": [{"w": "•", "b": [0.16, 0.567, 0.1682, 0.5884]}, {"w": "As", "b": [0.1786, 0.567, 0.2006, 0.5884]}, {"w": "always,", "b": [0.2062, 0.567, 0.2656, 0.5884]}, {"w": "X", "b": [0.2712, 0.5664, 0.2856, 0.5884]}, {"w": "represents", "b": [0.2912, 0.567, 0.3768, 0.5884]}, {"w": "the", "b": [0.3824, 0.567, 0.4087, 0.5884]}, {"w": "matrix", "b": [0.4143, 0.567, 0.4696, 0.5884]}, {"w": "of", "b": [0.4751, 0.567, 0.4919, 0.5884]}, {"w": "input", "b": [0.4975, 0.567, 0.5424, 0.5884]}, {"w": "features.", "b": [0.548, 0.567, 0.6182, 0.5884]}, {"w": "It", "b": [0.6238, 0.567, 0.6364, 0.5884]}, {"w": "has", "b": [0.642, 0.567, 0.6699, 0.5884]}, {"w": "one", "b": [0.6755, 0.567, 0.7063, 0.5884]}, {"w": "row", "b": [0.7119, 0.567, 0.7445, 0.5884]}, {"w": "per", "b": [0.7501, 0.567, 0.7776, 0.5884]}, {"w": "instance,", "b": [0.7832, 0.567, 0.8571, 0.5884]}, {"w": "one", "b": [0.1786, 0.586, 0.2094, 0.6074]}, {"w": "column", "b": [0.2142, 0.586, 0.2784, 0.6074]}, {"w": "per", "b": [0.2831, 0.586, 0.3106, 0.6074]}, {"w": "feature.", "b": [0.3154, 0.586, 0.3779, 0.6074]}]}, {"id": "b_6", "type": "paragraph", "text": "• The weight matrix W contains all the connection weights except for the ones from the bias neuron. It has one row per input neuron and one column per artifi‐ cial neuron in the layer.", "words": [{"w": "•", "b": [0.16, 0.6111, 0.1682, 0.6325]}, {"w": "The", "b": [0.1786, 0.6111, 0.2114, 0.6325]}, {"w": "weight", "b": [0.2196, 0.6111, 0.2751, 0.6325]}, {"w": "matrix", "b": [0.2833, 0.6111, 0.3386, 0.6325]}, {"w": "W", "b": [0.3467, 0.6106, 0.3671, 0.6325]}, {"w": "contains", "b": [0.3753, 0.6111, 0.4458, 0.6325]}, {"w": "all", "b": [0.454, 0.6111, 0.4737, 0.6325]}, {"w": "the", "b": [0.4818, 0.6111, 0.5082, 0.6325]}, {"w": "connection", "b": [0.5163, 0.6111, 0.6102, 0.6325]}, {"w": "weights", "b": [0.6183, 0.6111, 0.6815, 0.6325]}, {"w": "except", "b": [0.6897, 0.6111, 0.7433, 0.6325]}, {"w": "for", "b": [0.7515, 0.6111, 0.776, 0.6325]}, {"w": "the", "b": [0.7841, 0.6111, 0.8105, 0.6325]}, {"w": "ones", "b": [0.8186, 0.6111, 0.8571, 0.6325]}, {"w": "from", "b": [0.1786, 0.6302, 0.2202, 0.6516]}, {"w": "the", "b": [0.225, 0.6302, 0.2513, 0.6516]}, {"w": "bias", "b": [0.2561, 0.6302, 0.2891, 0.6516]}, {"w": "neuron.", "b": [0.2939, 0.6302, 0.3597, 0.6516]}, {"w": "It", "b": [0.3645, 0.6302, 0.3772, 0.6516]}, {"w": "has", "b": [0.382, 0.6302, 0.4099, 0.6516]}, {"w": "one", "b": [0.4147, 0.6302, 0.4456, 0.6516]}, {"w": "row", "b": [0.4504, 0.6302, 0.483, 0.6516]}, {"w": "per", "b": [0.4878, 0.6302, 0.5153, 0.6516]}, {"w": "input", "b": [0.5202, 0.6302, 0.5651, 0.6516]}, {"w": "neuron", "b": [0.5699, 0.6302, 0.6309, 0.6516]}, {"w": "and", "b": [0.6358, 0.6302, 0.6673, 0.6516]}, {"w": "one", "b": [0.6721, 0.6302, 0.703, 0.6516]}, {"w": "column", "b": [0.7078, 0.6302, 0.772, 0.6516]}, {"w": "per", "b": [0.7769, 0.6302, 0.8044, 0.6516]}, {"w": "artifi‐", "b": [0.8092, 0.6302, 0.8571, 0.6516]}, {"w": "cial", "b": [0.1786, 0.6492, 0.2074, 0.6706]}, {"w": "neuron", "b": [0.2121, 0.6492, 0.2732, 0.6706]}, {"w": "in", "b": [0.2779, 0.6492, 0.2949, 0.6706]}, {"w": "the", "b": [0.2996, 0.6492, 0.3259, 0.6706]}, {"w": "layer.", "b": [0.3307, 0.6492, 0.3743, 0.6706]}]}, {"id": "b_7", "type": "paragraph", "text": "• The bias vector b contains all the connection weights between the bias neuron and the artificial neurons. It has one bias term per artificial neuron.", "words": [{"w": "•", "b": [0.16, 0.6743, 0.1682, 0.6957]}, {"w": "The", "b": [0.1786, 0.6743, 0.2114, 0.6957]}, {"w": "bias", "b": [0.2186, 0.6743, 0.2516, 0.6957]}, {"w": "vector", "b": [0.2588, 0.6743, 0.3108, 0.6957]}, {"w": "b", "b": [0.318, 0.6737, 0.3291, 0.6957]}, {"w": "contains", "b": [0.3363, 0.6743, 0.4069, 0.6957]}, {"w": "all", "b": [0.4141, 0.6743, 0.4338, 0.6957]}, {"w": "the", "b": [0.441, 0.6743, 0.4673, 0.6957]}, {"w": "connection", "b": [0.4745, 0.6743, 0.5684, 0.6957]}, {"w": "weights", "b": [0.5756, 0.6743, 0.6388, 0.6957]}, {"w": "between", "b": [0.646, 0.6743, 0.7152, 0.6957]}, {"w": "the", "b": [0.7224, 0.6743, 0.7487, 0.6957]}, {"w": "bias", "b": [0.7559, 0.6743, 0.7889, 0.6957]}, {"w": "neuron", "b": [0.7961, 0.6743, 0.8571, 0.6957]}, {"w": "and", "b": [0.1786, 0.6933, 0.2101, 0.7148]}, {"w": "the", "b": [0.2148, 0.6933, 0.2412, 0.7148]}, {"w": "artificial", "b": [0.2459, 0.6933, 0.3153, 0.7148]}, {"w": "neurons.", "b": [0.32, 0.6933, 0.3935, 0.7148]}, {"w": "It", "b": [0.3982, 0.6933, 0.4108, 0.7148]}, {"w": "has", "b": [0.4156, 0.6933, 0.4435, 0.7148]}, {"w": "one", "b": [0.4482, 0.6933, 0.4791, 0.7148]}, {"w": "bias", "b": [0.4838, 0.6933, 0.5168, 0.7148]}, {"w": "term", "b": [0.5215, 0.6933, 0.5615, 0.7148]}, {"w": "per", "b": [0.5662, 0.6933, 0.5937, 0.7148]}, {"w": "artificial", "b": [0.5985, 0.6933, 0.6678, 0.7148]}, {"w": "neuron.", "b": [0.6726, 0.6933, 0.7384, 0.7148]}]}, {"id": "b_8", "type": "paragraph", "text": "• The function ϕ is called the activation function: when the artificial neurons are TLUs, it is a step function (but we will discuss other activation functions shortly).", "words": [{"w": "•", "b": [0.16, 0.7184, 0.1682, 0.7399]}, {"w": "The", "b": [0.1786, 0.7184, 0.2114, 0.7399]}, {"w": "function", "b": [0.2185, 0.7184, 0.2899, 0.7399]}, {"w": "ϕ", "b": [0.297, 0.7182, 0.3086, 0.7399]}, {"w": "is", "b": [0.3157, 0.7184, 0.3289, 0.7399]}, {"w": "called", "b": [0.336, 0.7184, 0.3843, 0.7399]}, {"w": "the", "b": [0.3914, 0.7184, 0.4177, 0.7399]}, {"w": "activation", "b": [0.4248, 0.7182, 0.506, 0.7399]}, {"w": "function:", "b": [0.5131, 0.7182, 0.5859, 0.7399]}, {"w": "when", "b": [0.593, 0.7184, 0.6387, 0.7399]}, {"w": "the", "b": [0.6458, 0.7184, 0.6721, 0.7399]}, {"w": "artificial", "b": [0.6792, 0.7184, 0.7485, 0.7399]}, {"w": "neurons", "b": [0.7556, 0.7184, 0.8243, 0.7399]}, {"w": "are", "b": [0.8314, 0.7184, 0.8571, 0.7399]}, {"w": "TLUs,", "b": [0.1786, 0.7375, 0.2284, 0.7589]}, {"w": "it", "b": [0.2332, 0.7375, 0.2451, 0.7589]}, {"w": "is", "b": [0.2498, 0.7375, 0.2631, 0.7589]}, {"w": "a", "b": [0.2678, 0.7375, 0.2769, 0.7589]}, {"w": "step", "b": [0.2817, 0.7375, 0.3154, 0.7589]}, {"w": "function", "b": [0.3202, 0.7375, 0.3916, 0.7589]}, {"w": "(but", "b": [0.3963, 0.7375, 0.4315, 0.7589]}, {"w": "we", "b": [0.4362, 0.7375, 0.4594, 0.7589]}, {"w": "will", "b": [0.4641, 0.7375, 0.4945, 0.7589]}, {"w": "discuss", "b": [0.4992, 0.7375, 0.5586, 0.7589]}, {"w": "other", "b": [0.5633, 0.7375, 0.608, 0.7589]}, {"w": "activation", "b": [0.6127, 0.7375, 0.695, 0.7589]}, {"w": "functions", "b": [0.6997, 0.7375, 0.7788, 0.7589]}, {"w": "shortly).", "b": [0.7835, 0.7375, 0.8538, 0.7589]}]}, {"id": "b_9", "type": "paragraph", "text": "So how is a Perceptron trained? The Perceptron training algorithm proposed by Frank Rosenblatt was largely inspired by Hebb’s rule. In his book The Organization of Behavior, published in 1949, Donald Hebb suggested that when a biological neuron often triggers another neuron, the connection between these two neurons grows stronger. This idea was later summarized by Siegrid Löwel in this catchy phrase: “Cells that fire together, wire together.” This rule later became known as Hebb’s rule", "words": [{"w": "So", "b": [0.1429, 0.7717, 0.1634, 0.7931]}, {"w": "how", "b": [0.1726, 0.7717, 0.2086, 0.7931]}, {"w": "is", "b": [0.2179, 0.7717, 0.2311, 0.7931]}, {"w": "a", "b": [0.2404, 0.7717, 0.2495, 0.7931]}, {"w": "Perceptron", "b": [0.2588, 0.7717, 0.3511, 0.7931]}, {"w": "trained?", "b": [0.3604, 0.7717, 0.4284, 0.7931]}, {"w": "The", "b": [0.4376, 0.7717, 0.4704, 0.7931]}, {"w": "Perceptron", "b": [0.4797, 0.7717, 0.572, 0.7931]}, {"w": "training", "b": [0.5813, 0.7717, 0.6482, 0.7931]}, {"w": "algorithm", "b": [0.6575, 0.7717, 0.7402, 0.7931]}, {"w": "proposed", "b": [0.7494, 0.7717, 0.8277, 0.7931]}, {"w": "by", "b": [0.837, 0.7717, 0.8571, 0.7931]}, {"w": "Frank", "b": [0.1429, 0.7907, 0.1925, 0.8121]}, {"w": "Rosenblatt", "b": [0.1982, 0.7907, 0.287, 0.8121]}, {"w": "was", "b": [0.2927, 0.7907, 0.3237, 0.8121]}, {"w": "largely", "b": [0.3295, 0.7907, 0.385, 0.8121]}, {"w": "inspired", "b": [0.3908, 0.7907, 0.4595, 0.8121]}, {"w": "by", "b": [0.4652, 0.7907, 0.4853, 0.8121]}, {"w": "Hebb’s", "b": [0.491, 0.7905, 0.5416, 0.8121]}, {"w": "rule.", "b": [0.5474, 0.7905, 0.5844, 0.8121]}, {"w": "In", "b": [0.5901, 0.7907, 0.6086, 0.8121]}, {"w": "his", "b": [0.6143, 0.7907, 0.6386, 0.8121]}, {"w": "book", "b": [0.6443, 0.7907, 0.6865, 0.8121]}, {"w": "The", "b": [0.6922, 0.7905, 0.7221, 0.8121]}, {"w": "Organization", "b": [0.7278, 0.7905, 0.8362, 0.8121]}, {"w": "of", "b": [0.8419, 0.7905, 0.8572, 0.8121]}, {"w": "Behavior,", "b": [0.1429, 0.8095, 0.2204, 0.8312]}, {"w": "published", "b": [0.2271, 0.8097, 0.3091, 0.8312]}, {"w": "in", "b": [0.3159, 0.8097, 0.3329, 0.8312]}, {"w": "1949,", "b": [0.3396, 0.8097, 0.3844, 0.8312]}, {"w": "Donald", "b": [0.3911, 0.8097, 0.4539, 0.8312]}, {"w": "Hebb", "b": [0.4606, 0.8097, 0.5061, 0.8312]}, {"w": "suggested", "b": [0.5128, 0.8097, 0.5937, 0.8312]}, {"w": "that", "b": [0.6005, 0.8097, 0.6331, 0.8312]}, {"w": "when", "b": [0.6398, 0.8097, 0.6854, 0.8312]}, {"w": "a", "b": [0.6922, 0.8097, 0.7013, 0.8312]}, {"w": "biological", "b": [0.7081, 0.8097, 0.7893, 0.8312]}, {"w": "neuron", "b": [0.7961, 0.8097, 0.8571, 0.8312]}, {"w": "often", "b": [0.1429, 0.8288, 0.1862, 0.8502]}, {"w": "triggers", "b": [0.1957, 0.8288, 0.2591, 0.8502]}, {"w": "another", "b": [0.2685, 0.8288, 0.3337, 0.8502]}, {"w": "neuron,", "b": [0.3432, 0.8288, 0.409, 0.8502]}, {"w": "the", "b": [0.4184, 0.8288, 0.4447, 0.8502]}, {"w": "connection", "b": [0.4542, 0.8288, 0.548, 0.8502]}, {"w": "between", "b": [0.5574, 0.8288, 0.6266, 0.8502]}, {"w": "these", "b": [0.636, 0.8288, 0.6789, 0.8502]}, {"w": "two", "b": [0.6883, 0.8288, 0.7196, 0.8502]}, {"w": "neurons", "b": [0.729, 0.8288, 0.7977, 0.8502]}, {"w": "grows", "b": [0.8071, 0.8288, 0.8571, 0.8502]}, {"w": "stronger.", "b": [0.1428, 0.8478, 0.2164, 0.8693]}, {"w": "This", "b": [0.2253, 0.8478, 0.2625, 0.8693]}, {"w": "idea", "b": [0.2715, 0.8478, 0.3061, 0.8693]}, {"w": "was", "b": [0.315, 0.8478, 0.3461, 0.8693]}, {"w": "later", "b": [0.3551, 0.8478, 0.392, 0.8693]}, {"w": "summarized", "b": [0.401, 0.8478, 0.5049, 0.8693]}, {"w": "by", "b": [0.5138, 0.8478, 0.534, 0.8693]}, {"w": "Siegrid", "b": [0.5429, 0.8478, 0.6013, 0.8693]}, {"w": "Löwel", "b": [0.6103, 0.8478, 0.6605, 0.8693]}, {"w": "in", "b": [0.6695, 0.8478, 0.6864, 0.8693]}, {"w": "this", "b": [0.6954, 0.8478, 0.7261, 0.8693]}, {"w": "catchy", "b": [0.7351, 0.8478, 0.788, 0.8693]}, {"w": "phrase:", "b": [0.797, 0.8478, 0.8571, 0.8693]}, {"w": "“Cells", "b": [0.1429, 0.8669, 0.1913, 0.8883]}, {"w": "that", "b": [0.1973, 0.8669, 0.2299, 0.8883]}, {"w": "fire", "b": [0.236, 0.8669, 0.2643, 0.8883]}, {"w": "together,", "b": [0.2703, 0.8669, 0.3434, 0.8883]}, {"w": "wire", "b": [0.3494, 0.8669, 0.3859, 0.8883]}, {"w": "together.”", "b": [0.3919, 0.8669, 0.4705, 0.8883]}, {"w": "This", "b": [0.4765, 0.8669, 0.5137, 0.8883]}, {"w": "rule", "b": [0.5197, 0.8669, 0.5527, 0.8883]}, {"w": "later", "b": [0.5587, 0.8669, 0.5957, 0.8883]}, {"w": "became", "b": [0.6017, 0.8669, 0.665, 0.8883]}, {"w": "known", "b": [0.671, 0.8669, 0.7291, 0.8883]}, {"w": "as", "b": [0.7351, 0.8669, 0.7519, 0.8883]}, {"w": "Hebb’s", "b": [0.7579, 0.8669, 0.8122, 0.8883]}, {"w": "rule", "b": [0.8182, 0.8669, 0.8511, 0.8883]}]}, {"id": "b_10", "type": "paragraph", "text": "From Biological to Artificial Neurons | 283", "words": [{"w": "From", "b": [0.585, 0.9225, 0.6155, 0.9388]}, {"w": "Biological", "b": [0.6183, 0.9225, 0.6761, 0.9388]}, {"w": "to", "b": [0.679, 0.9225, 0.6914, 0.9388]}, {"w": "Artificial", "b": [0.6942, 0.9225, 0.7441, 0.9388]}, {"w": "Neurons", "b": [0.7469, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "283", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 310, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "7 Note that this solution is generally not unique: in general when the data are linearly separable, there is an infinity of hyperplanes that can separate them.", "words": [{"w": "7", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Note", "b": [0.1587, 0.8598, 0.1898, 0.8761]}, {"w": "that", "b": [0.1934, 0.8598, 0.2182, 0.8761]}, {"w": "this", "b": [0.2218, 0.8598, 0.2452, 0.8761]}, {"w": "solution", "b": [0.2488, 0.8598, 0.3011, 0.8761]}, {"w": "is", "b": [0.3047, 0.8598, 0.3148, 0.8761]}, {"w": "generally", "b": [0.3184, 0.8598, 0.3761, 0.8761]}, {"w": "not", "b": [0.3797, 0.8598, 0.4014, 0.8761]}, {"w": "unique:", "b": [0.405, 0.8598, 0.4532, 0.8761]}, {"w": "in", "b": [0.4568, 0.8598, 0.4698, 0.8761]}, {"w": "general", "b": [0.4734, 0.8598, 0.5199, 0.8761]}, {"w": "when", "b": [0.5235, 0.8598, 0.5582, 0.8761]}, {"w": "the", "b": [0.5618, 0.8598, 0.5819, 0.8761]}, {"w": "data", "b": [0.5855, 0.8598, 0.6124, 0.8761]}, {"w": "are", "b": [0.616, 0.8598, 0.6356, 0.8761]}, {"w": "linearly", "b": [0.6392, 0.8598, 0.687, 0.8761]}, {"w": "separable,", "b": [0.6906, 0.8598, 0.7538, 0.8761]}, {"w": "there", "b": [0.7574, 0.8598, 0.7901, 0.8761]}, {"w": "is", "b": [0.7937, 0.8598, 0.8038, 0.8761]}, {"w": "an", "b": [0.8074, 0.8598, 0.823, 0.8761]}, {"w": "infinity", "b": [0.1587, 0.8749, 0.2057, 0.8912]}, {"w": "of", "b": [0.2093, 0.8749, 0.2221, 0.8912]}, {"w": "hyperplanes", "b": [0.2257, 0.8749, 0.3026, 0.8912]}, {"w": "that", "b": [0.3062, 0.8749, 0.331, 0.8912]}, {"w": "can", "b": [0.3346, 0.8749, 0.357, 0.8912]}, {"w": "separate", "b": [0.3606, 0.8749, 0.4126, 0.8912]}, {"w": "them.", "b": [0.4162, 0.8749, 0.4529, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "(or Hebbian learning); that is, the connection weight between two neurons is increased whenever they have the same output. Perceptrons are trained using a var‐ iant of this rule that takes into account the error made by the network; it reinforces connections that help reduce the error. More specifically, the Perceptron is fed one training instance at a time, and for each instance it makes its predictions. For every output neuron that produced a wrong prediction, it reinforces the connection weights from the inputs that would have contributed to the correct prediction. The rule is shown in Equation 10-3.", "words": [{"w": "(or", "b": [0.1429, 0.0791, 0.1684, 0.1005]}, {"w": "Hebbian", "b": [0.1804, 0.0789, 0.2495, 0.1005]}, {"w": "learning);", "b": [0.2616, 0.0789, 0.3402, 0.1005]}, {"w": "that", "b": [0.3523, 0.0791, 0.3849, 0.1005]}, {"w": "is,", "b": [0.3969, 0.0791, 0.4149, 0.1005]}, {"w": "the", "b": [0.4269, 0.0791, 0.4532, 0.1005]}, {"w": "connection", "b": [0.4652, 0.0791, 0.5591, 0.1005]}, {"w": "weight", "b": [0.5711, 0.0791, 0.6267, 0.1005]}, {"w": "between", "b": [0.6387, 0.0791, 0.7079, 0.1005]}, {"w": "two", "b": [0.7199, 0.0791, 0.7511, 0.1005]}, {"w": "neurons", "b": [0.7632, 0.0791, 0.8319, 0.1005]}, {"w": "is", "b": [0.8439, 0.0791, 0.8571, 0.1005]}, {"w": "increased", "b": [0.1429, 0.0981, 0.2219, 0.1195]}, {"w": "whenever", "b": [0.2282, 0.0981, 0.3089, 0.1195]}, {"w": "they", "b": [0.3152, 0.0981, 0.3511, 0.1195]}, {"w": "have", "b": [0.3575, 0.0981, 0.3959, 0.1195]}, {"w": "the", "b": [0.4022, 0.0981, 0.4285, 0.1195]}, {"w": "same", "b": [0.4348, 0.0981, 0.4775, 0.1195]}, {"w": "output.", "b": [0.4838, 0.0981, 0.545, 0.1195]}, {"w": "Perceptrons", "b": [0.5513, 0.0981, 0.6513, 0.1195]}, {"w": "are", "b": [0.6576, 0.0981, 0.6833, 0.1195]}, {"w": "trained", "b": [0.6896, 0.0981, 0.7497, 0.1195]}, {"w": "using", "b": [0.756, 0.0981, 0.8014, 0.1195]}, {"w": "a", "b": [0.8078, 0.0981, 0.8169, 0.1195]}, {"w": "var‐", "b": [0.8232, 0.0981, 0.8572, 0.1195]}, {"w": "iant", "b": [0.1429, 0.1172, 0.1749, 0.1386]}, {"w": "of", "b": [0.1814, 0.1172, 0.1982, 0.1386]}, {"w": "this", "b": [0.2046, 0.1172, 0.2353, 0.1386]}, {"w": "rule", "b": [0.2417, 0.1172, 0.2746, 0.1386]}, {"w": "that", "b": [0.281, 0.1172, 0.3136, 0.1386]}, {"w": "takes", "b": [0.32, 0.1172, 0.3624, 0.1386]}, {"w": "into", "b": [0.3688, 0.1172, 0.4024, 0.1386]}, {"w": "account", "b": [0.4088, 0.1172, 0.4746, 0.1386]}, {"w": "the", "b": [0.481, 0.1172, 0.5073, 0.1386]}, {"w": "error", "b": [0.5138, 0.1172, 0.5564, 0.1386]}, {"w": "made", "b": [0.5629, 0.1172, 0.6089, 0.1386]}, {"w": "by", "b": [0.6153, 0.1172, 0.6355, 0.1386]}, {"w": "the", "b": [0.6419, 0.1172, 0.6682, 0.1386]}, {"w": "network;", "b": [0.6747, 0.1172, 0.749, 0.1386]}, {"w": "it", "b": [0.7554, 0.1172, 0.7673, 0.1386]}, {"w": "reinforces", "b": [0.7738, 0.1172, 0.8571, 0.1386]}, {"w": "connections", "b": [0.1429, 0.1362, 0.2444, 0.1576]}, {"w": "that", "b": [0.2516, 0.1362, 0.2841, 0.1576]}, {"w": "help", "b": [0.2913, 0.1362, 0.3275, 0.1576]}, {"w": "reduce", "b": [0.3347, 0.1362, 0.391, 0.1576]}, {"w": "the", "b": [0.3982, 0.1362, 0.4246, 0.1576]}, {"w": "error.", "b": [0.4318, 0.1362, 0.4779, 0.1576]}, {"w": "More", "b": [0.4851, 0.1362, 0.5303, 0.1576]}, {"w": "specifically,", "b": [0.5375, 0.1362, 0.6323, 0.1576]}, {"w": "the", "b": [0.6395, 0.1362, 0.6659, 0.1576]}, {"w": "Perceptron", "b": [0.6731, 0.1362, 0.7654, 0.1576]}, {"w": "is", "b": [0.7726, 0.1362, 0.7858, 0.1576]}, {"w": "fed", "b": [0.793, 0.1362, 0.8191, 0.1576]}, {"w": "one", "b": [0.8263, 0.1362, 0.8571, 0.1576]}, {"w": "training", "b": [0.1428, 0.1553, 0.2098, 0.1767]}, {"w": "instance", "b": [0.2162, 0.1553, 0.2854, 0.1767]}, {"w": "at", "b": [0.2918, 0.1553, 0.3069, 0.1767]}, {"w": "a", "b": [0.3134, 0.1553, 0.3225, 0.1767]}, {"w": "time,", "b": [0.329, 0.1553, 0.3716, 0.1767]}, {"w": "and", "b": [0.378, 0.1553, 0.4095, 0.1767]}, {"w": "for", "b": [0.416, 0.1553, 0.4405, 0.1767]}, {"w": "each", "b": [0.4469, 0.1553, 0.4849, 0.1767]}, {"w": "instance", "b": [0.4913, 0.1553, 0.5605, 0.1767]}, {"w": "it", "b": [0.5669, 0.1553, 0.5789, 0.1767]}, {"w": "makes", "b": [0.5853, 0.1553, 0.6383, 0.1767]}, {"w": "its", "b": [0.6448, 0.1553, 0.6644, 0.1767]}, {"w": "predictions.", "b": [0.6708, 0.1553, 0.77, 0.1767]}, {"w": "For", "b": [0.7765, 0.1553, 0.8055, 0.1767]}, {"w": "every", "b": [0.8119, 0.1553, 0.8571, 0.1767]}, {"w": "output", "b": [0.1429, 0.1743, 0.1992, 0.1957]}, {"w": "neuron", "b": [0.2107, 0.1743, 0.2717, 0.1957]}, {"w": "that", "b": [0.2831, 0.1743, 0.3157, 0.1957]}, {"w": "produced", "b": [0.3272, 0.1743, 0.4072, 0.1957]}, {"w": "a", "b": [0.4186, 0.1743, 0.4277, 0.1957]}, {"w": "wrong", "b": [0.4391, 0.1743, 0.4929, 0.1957]}, {"w": "prediction,", "b": [0.5043, 0.1743, 0.5959, 0.1957]}, {"w": "it", "b": [0.6074, 0.1743, 0.6193, 0.1957]}, {"w": "reinforces", "b": [0.6307, 0.1743, 0.7141, 0.1957]}, {"w": "the", "b": [0.7255, 0.1743, 0.7519, 0.1957]}, {"w": "connection", "b": [0.7633, 0.1743, 0.8571, 0.1957]}, {"w": "weights", "b": [0.1429, 0.1933, 0.206, 0.2148]}, {"w": "from", "b": [0.2129, 0.1933, 0.2545, 0.2148]}, {"w": "the", "b": [0.2614, 0.1933, 0.2878, 0.2148]}, {"w": "inputs", "b": [0.2947, 0.1933, 0.3472, 0.2148]}, {"w": "that", "b": [0.3541, 0.1933, 0.3867, 0.2148]}, {"w": "would", "b": [0.3936, 0.1933, 0.4458, 0.2148]}, {"w": "have", "b": [0.4527, 0.1933, 0.4911, 0.2148]}, {"w": "contributed", "b": [0.498, 0.1933, 0.596, 0.2148]}, {"w": "to", "b": [0.6029, 0.1933, 0.6199, 0.2148]}, {"w": "the", "b": [0.6268, 0.1933, 0.6531, 0.2148]}, {"w": "correct", "b": [0.66, 0.1933, 0.7189, 0.2148]}, {"w": "prediction.", "b": [0.7258, 0.1933, 0.8174, 0.2148]}, {"w": "The", "b": [0.8243, 0.1933, 0.8571, 0.2148]}, {"w": "rule", "b": [0.1429, 0.2124, 0.1758, 0.2338]}, {"w": "is", "b": [0.1805, 0.2124, 0.1937, 0.2338]}, {"w": "shown", "b": [0.1985, 0.2124, 0.2535, 0.2338]}, {"w": "in", "b": [0.2582, 0.2124, 0.2752, 0.2338]}, {"w": "Equation", "b": [0.28, 0.2124, 0.3562, 0.2338]}, {"w": "10-3.", "b": [0.3609, 0.2124, 0.4031, 0.2338]}]}, {"id": "b_2", "type": "equation", "text": "Equation 10-3. Perceptron learning rule (weight update)", "words": [{"w": "Equation", "b": [0.1726, 0.2519, 0.2473, 0.2735]}, {"w": "10-3.", "b": [0.2521, 0.2519, 0.2937, 0.2735]}, {"w": "Perceptron", "b": [0.2985, 0.2519, 0.3852, 0.2735]}, {"w": "learning", "b": [0.3899, 0.2519, 0.4566, 0.2735]}, {"w": "rule", "b": [0.4614, 0.2519, 0.4937, 0.2735]}, {"w": "(weight", "b": [0.4984, 0.2519, 0.5585, 0.2735]}, {"w": "update)", "b": [0.5633, 0.2519, 0.6259, 0.2735]}]}, {"id": "b_3", "type": "paragraph", "text": "wi, j", "words": [{"w": "wi,", "b": [0.1726, 0.2842, 0.1939, 0.3091]}, {"w": "j", "b": [0.1981, 0.2926, 0.2024, 0.3091]}]}, {"id": "b_4", "type": "equation", "text": "next step = wi, j + η yj −y j xi", "words": [{"w": "next", "b": [0.2079, 0.2807, 0.2356, 0.297]}, {"w": "step", "b": [0.2435, 0.2807, 0.2693, 0.297]}, {"w": "=", "b": [0.2803, 0.2844, 0.2918, 0.3048]}, {"w": "wi,", "b": [0.2973, 0.2842, 0.3185, 0.3091]}, {"w": "j", "b": [0.3228, 0.2926, 0.327, 0.3091]}, {"w": "+", "b": [0.3314, 0.2844, 0.3429, 0.3048]}, {"w": "η", "b": [0.3474, 0.2842, 0.3575, 0.3048]}, {"w": "yj", "b": [0.3654, 0.2842, 0.3801, 0.3091]}, {"w": "−y", "b": [0.3845, 0.2842, 0.4103, 0.3048]}, {"w": "j", "b": [0.4133, 0.2926, 0.4175, 0.3091]}, {"w": "xi", "b": [0.4244, 0.2842, 0.4381, 0.3091]}]}, {"id": "b_5", "type": "paragraph", "text": "• wi, j is the connection weight between the ith input neuron and the jth output neu‐ ron.", "words": [{"w": "•", "b": [0.16, 0.3342, 0.1681, 0.3556]}, {"w": "wi,", "b": [0.1786, 0.334, 0.1988, 0.3565]}, {"w": "j", "b": [0.202, 0.3435, 0.2054, 0.3565]}, {"w": "is", "b": [0.2108, 0.3342, 0.224, 0.3556]}, {"w": "the", "b": [0.2295, 0.3342, 0.2558, 0.3556]}, {"w": "connection", "b": [0.2613, 0.3342, 0.3551, 0.3556]}, {"w": "weight", "b": [0.3605, 0.3342, 0.4161, 0.3556]}, {"w": "between", "b": [0.4215, 0.3342, 0.4907, 0.3556]}, {"w": "the", "b": [0.4961, 0.3342, 0.5225, 0.3556]}, {"w": "ith", "b": [0.5279, 0.334, 0.5441, 0.3556]}, {"w": "input", "b": [0.5495, 0.3342, 0.5944, 0.3556]}, {"w": "neuron", "b": [0.5999, 0.3342, 0.6609, 0.3556]}, {"w": "and", "b": [0.6664, 0.3342, 0.6979, 0.3556]}, {"w": "the", "b": [0.7034, 0.3342, 0.7297, 0.3556]}, {"w": "jth", "b": [0.7351, 0.334, 0.7512, 0.3556]}, {"w": "output", "b": [0.7566, 0.3342, 0.813, 0.3556]}, {"w": "neu‐", "b": [0.8184, 0.3342, 0.8571, 0.3556]}, {"w": "ron.", "b": [0.1786, 0.3532, 0.2131, 0.3747]}]}, {"id": "b_6", "type": "paragraph", "text": "• xi is the ith input value of the current training instance.", "words": [{"w": "•", "b": [0.16, 0.3783, 0.1682, 0.3998]}, {"w": "xi", "b": [0.1786, 0.3781, 0.1918, 0.4006]}, {"w": "is", "b": [0.1966, 0.3783, 0.2098, 0.3998]}, {"w": "the", "b": [0.2145, 0.3783, 0.2409, 0.3998]}, {"w": "ith", "b": [0.2456, 0.3781, 0.2618, 0.3998]}, {"w": "input", "b": [0.2665, 0.3783, 0.3114, 0.3998]}, {"w": "value", "b": [0.3161, 0.3783, 0.3601, 0.3998]}, {"w": "of", "b": [0.3648, 0.3783, 0.3816, 0.3998]}, {"w": "the", "b": [0.3864, 0.3783, 0.4127, 0.3998]}, {"w": "current", "b": [0.4174, 0.3783, 0.479, 0.3998]}, {"w": "training", "b": [0.4837, 0.3783, 0.5506, 0.3998]}, {"w": "instance.", "b": [0.5554, 0.3783, 0.6293, 0.3998]}]}, {"id": "b_7", "type": "paragraph", "text": "• y j is the output of the jth output neuron for the current training instance.", "words": [{"w": "•", "b": [0.16, 0.4034, 0.1682, 0.4249]}, {"w": "y", "b": [0.1798, 0.4032, 0.189, 0.4249]}, {"w": "j", "b": [0.192, 0.4122, 0.1962, 0.4287]}, {"w": "is", "b": [0.2009, 0.4034, 0.2142, 0.4249]}, {"w": "the", "b": [0.2189, 0.4034, 0.2452, 0.4249]}, {"w": "output", "b": [0.25, 0.4034, 0.3063, 0.4249]}, {"w": "of", "b": [0.3111, 0.4034, 0.3279, 0.4249]}, {"w": "the", "b": [0.3326, 0.4034, 0.3589, 0.4249]}, {"w": "jth", "b": [0.3636, 0.4032, 0.3797, 0.4249]}, {"w": "output", "b": [0.3844, 0.4034, 0.4408, 0.4249]}, {"w": "neuron", "b": [0.4455, 0.4034, 0.5066, 0.4249]}, {"w": "for", "b": [0.5113, 0.4034, 0.5358, 0.4249]}, {"w": "the", "b": [0.5405, 0.4034, 0.5669, 0.4249]}, {"w": "current", "b": [0.5716, 0.4034, 0.6331, 0.4249]}, {"w": "training", "b": [0.6379, 0.4034, 0.7048, 0.4249]}, {"w": "instance.", "b": [0.7095, 0.4034, 0.7835, 0.4249]}]}, {"id": "b_8", "type": "paragraph", "text": "• yj is the target output of the jth output neuron for the current training instance.", "words": [{"w": "•", "b": [0.16, 0.4311, 0.1682, 0.4525]}, {"w": "yj", "b": [0.1786, 0.4309, 0.1911, 0.4534]}, {"w": "is", "b": [0.1958, 0.4311, 0.2091, 0.4525]}, {"w": "the", "b": [0.2138, 0.4311, 0.2401, 0.4525]}, {"w": "target", "b": [0.2448, 0.4311, 0.293, 0.4525]}, {"w": "output", "b": [0.2978, 0.4311, 0.3541, 0.4525]}, {"w": "of", "b": [0.3589, 0.4311, 0.3757, 0.4525]}, {"w": "the", "b": [0.3804, 0.4311, 0.4067, 0.4525]}, {"w": "jth", "b": [0.4115, 0.4309, 0.4275, 0.4525]}, {"w": "output", "b": [0.4322, 0.4311, 0.4886, 0.4525]}, {"w": "neuron", "b": [0.4933, 0.4311, 0.5544, 0.4525]}, {"w": "for", "b": [0.5591, 0.4311, 0.5836, 0.4525]}, {"w": "the", "b": [0.5884, 0.4311, 0.6147, 0.4525]}, {"w": "current", "b": [0.6194, 0.4311, 0.681, 0.4525]}, {"w": "training", "b": [0.6857, 0.4311, 0.7526, 0.4525]}, {"w": "instance.", "b": [0.7574, 0.4311, 0.8313, 0.4525]}]}, {"id": "b_9", "type": "paragraph", "text": "• η is the learning rate.", "words": [{"w": "•", "b": [0.16, 0.4562, 0.1682, 0.4776]}, {"w": "η", "b": [0.1786, 0.456, 0.1892, 0.4776]}, {"w": "is", "b": [0.1939, 0.4562, 0.2071, 0.4776]}, {"w": "the", "b": [0.2119, 0.4562, 0.2382, 0.4776]}, {"w": "learning", "b": [0.2429, 0.4562, 0.312, 0.4776]}, {"w": "rate.", "b": [0.3168, 0.4562, 0.3532, 0.4776]}]}, {"id": "b_10", "type": "paragraph", "text": "The decision boundary of each output neuron is linear, so Perceptrons are incapable of learning complex patterns (just like Logistic Regression classifiers). However, if the training instances are linearly separable, Rosenblatt demonstrated that this algorithm would converge to a solution.7 This is called the Perceptron convergence theorem.", "words": [{"w": "The", "b": [0.1429, 0.4904, 0.1757, 0.5118]}, {"w": "decision", "b": [0.1815, 0.4904, 0.251, 0.5118]}, {"w": "boundary", "b": [0.2569, 0.4904, 0.3386, 0.5118]}, {"w": "of", "b": [0.3444, 0.4904, 0.3612, 0.5118]}, {"w": "each", "b": [0.3671, 0.4904, 0.405, 0.5118]}, {"w": "output", "b": [0.4109, 0.4904, 0.4672, 0.5118]}, {"w": "neuron", "b": [0.4731, 0.4904, 0.5341, 0.5118]}, {"w": "is", "b": [0.54, 0.4904, 0.5532, 0.5118]}, {"w": "linear,", "b": [0.5591, 0.4904, 0.6105, 0.5118]}, {"w": "so", "b": [0.6163, 0.4904, 0.6346, 0.5118]}, {"w": "Perceptrons", "b": [0.6404, 0.4904, 0.7404, 0.5118]}, {"w": "are", "b": [0.7463, 0.4904, 0.772, 0.5118]}, {"w": "incapable", "b": [0.7778, 0.4904, 0.8571, 0.5118]}, {"w": "of", "b": [0.1429, 0.5094, 0.1596, 0.5308]}, {"w": "learning", "b": [0.1648, 0.5094, 0.2339, 0.5308]}, {"w": "complex", "b": [0.239, 0.5094, 0.31, 0.5308]}, {"w": "patterns", "b": [0.3151, 0.5094, 0.3831, 0.5308]}, {"w": "(just", "b": [0.3882, 0.5094, 0.4258, 0.5308]}, {"w": "like", "b": [0.4309, 0.5094, 0.4609, 0.5308]}, {"w": "Logistic", "b": [0.466, 0.5094, 0.5316, 0.5308]}, {"w": "Regression", "b": [0.5367, 0.5094, 0.6277, 0.5308]}, {"w": "classifiers).", "b": [0.6328, 0.5094, 0.7249, 0.5308]}, {"w": "However,", "b": [0.73, 0.5094, 0.8088, 0.5308]}, {"w": "if", "b": [0.8139, 0.5094, 0.8257, 0.5308]}, {"w": "the", "b": [0.8308, 0.5094, 0.8571, 0.5308]}, {"w": "training", "b": [0.1429, 0.5285, 0.2098, 0.5499]}, {"w": "instances", "b": [0.2152, 0.5285, 0.2921, 0.5499]}, {"w": "are", "b": [0.2975, 0.5285, 0.3232, 0.5499]}, {"w": "linearly", "b": [0.3286, 0.5285, 0.3914, 0.5499]}, {"w": "separable,", "b": [0.3968, 0.5285, 0.4797, 0.5499]}, {"w": "Rosenblatt", "b": [0.4852, 0.5285, 0.5739, 0.5499]}, {"w": "demonstrated", "b": [0.5793, 0.5285, 0.695, 0.5499]}, {"w": "that", "b": [0.7004, 0.5285, 0.733, 0.5499]}, {"w": "this", "b": [0.7384, 0.5285, 0.7691, 0.5499]}, {"w": "algorithm", "b": [0.7745, 0.5285, 0.8572, 0.5499]}, {"w": "would", "b": [0.1429, 0.5475, 0.1951, 0.5689]}, {"w": "converge", "b": [0.1998, 0.5475, 0.275, 0.5689]}, {"w": "to", "b": [0.2797, 0.5475, 0.2967, 0.5689]}, {"w": "a", "b": [0.3014, 0.5475, 0.3106, 0.5689]}, {"w": "solution.7", "b": [0.3153, 0.5475, 0.3943, 0.5689]}, {"w": "This", "b": [0.3991, 0.5475, 0.4363, 0.5689]}, {"w": "is", "b": [0.441, 0.5475, 0.4542, 0.5689]}, {"w": "called", "b": [0.459, 0.5475, 0.5073, 0.5689]}, {"w": "the", "b": [0.5121, 0.5475, 0.5384, 0.5689]}, {"w": "Perceptron", "b": [0.5431, 0.5473, 0.6298, 0.5689]}, {"w": "convergence", "b": [0.6346, 0.5473, 0.7317, 0.5689]}, {"w": "theorem.", "b": [0.7365, 0.5473, 0.8077, 0.5689]}]}, {"id": "b_11", "type": "paragraph", "text": "Scikit-Learn provides a Perceptron class that implements a single TLU network. It can be used pretty much as you would expect—for example, on the iris dataset (intro‐ duced in Chapter 4):", "words": [{"w": "Scikit-Learn", "b": [0.1429, 0.5765, 0.2452, 0.5979]}, {"w": "provides", "b": [0.2524, 0.5765, 0.3244, 0.5979]}, {"w": "a", "b": [0.3316, 0.5765, 0.3407, 0.5979]}, {"w": "Perceptron", "b": [0.348, 0.5797, 0.4469, 0.5948]}, {"w": "class", "b": [0.4541, 0.5765, 0.4927, 0.5979]}, {"w": "that", "b": [0.4999, 0.5765, 0.5325, 0.5979]}, {"w": "implements", "b": [0.5397, 0.5765, 0.6379, 0.5979]}, {"w": "a", "b": [0.6451, 0.5765, 0.6543, 0.5979]}, {"w": "single", "b": [0.6615, 0.5765, 0.71, 0.5979]}, {"w": "TLU", "b": [0.7172, 0.5765, 0.7558, 0.5979]}, {"w": "network.", "b": [0.763, 0.5765, 0.8373, 0.5979]}, {"w": "It", "b": [0.8445, 0.5765, 0.8572, 0.5979]}, {"w": "can", "b": [0.1429, 0.5956, 0.1722, 0.617]}, {"w": "be", "b": [0.1771, 0.5956, 0.1966, 0.617]}, {"w": "used", "b": [0.2015, 0.5956, 0.24, 0.617]}, {"w": "pretty", "b": [0.2449, 0.5956, 0.2947, 0.617]}, {"w": "much", "b": [0.2996, 0.5956, 0.3473, 0.617]}, {"w": "as", "b": [0.3522, 0.5956, 0.369, 0.617]}, {"w": "you", "b": [0.3739, 0.5956, 0.4051, 0.617]}, {"w": "would", "b": [0.41, 0.5956, 0.4623, 0.617]}, {"w": "expect—for", "b": [0.4672, 0.5956, 0.5645, 0.617]}, {"w": "example,", "b": [0.5694, 0.5956, 0.6437, 0.617]}, {"w": "on", "b": [0.6486, 0.5956, 0.6706, 0.617]}, {"w": "the", "b": [0.6755, 0.5956, 0.7019, 0.617]}, {"w": "iris", "b": [0.7068, 0.5956, 0.7333, 0.617]}, {"w": "dataset", "b": [0.7382, 0.5956, 0.7963, 0.617]}, {"w": "(intro‐", "b": [0.8012, 0.5956, 0.8571, 0.617]}, {"w": "duced", "b": [0.1429, 0.6146, 0.1936, 0.636]}, {"w": "in", "b": [0.1983, 0.6146, 0.2153, 0.636]}, {"w": "Chapter", "b": [0.22, 0.6146, 0.2876, 0.636]}, {"w": "4):", "b": [0.2923, 0.6146, 0.3143, 0.636]}]}, {"id": "b_12", "type": "paragraph", "text": "import numpy as np from sklearn.datasets import load_iris from sklearn.linear_model import Perceptron", "words": [{"w": "import", "b": [0.1766, 0.6466, 0.2272, 0.6594]}, {"w": "numpy", "b": [0.2356, 0.6466, 0.2778, 0.6594]}, {"w": "as", "b": [0.2862, 0.6466, 0.3031, 0.6594]}, {"w": "np", "b": [0.3115, 0.6466, 0.3284, 0.6594]}, {"w": "from", "b": [0.1766, 0.662, 0.2103, 0.6749]}, {"w": "sklearn.datasets", "b": [0.2188, 0.662, 0.3537, 0.6749]}, {"w": "import", "b": [0.3621, 0.662, 0.4127, 0.6749]}, {"w": "load_iris", "b": [0.4211, 0.662, 0.497, 0.6749]}, {"w": "from", "b": [0.1766, 0.6774, 0.2103, 0.6903]}, {"w": "sklearn.linear_model", "b": [0.2188, 0.6774, 0.3874, 0.6903]}, {"w": "import", "b": [0.3958, 0.6774, 0.4464, 0.6903]}, {"w": "Perceptron", "b": [0.4549, 0.6774, 0.5392, 0.6903]}]}, {"id": "b_13", "type": "paragraph", "text": "iris = load_iris() X = iris.data[:, (2, 3)] # petal length, petal width y = (iris.target == 0).astype(np.int) # Iris Setosa?", "words": [{"w": "iris", "b": [0.1766, 0.7083, 0.2103, 0.7211]}, {"w": "=", "b": [0.2188, 0.7083, 0.2272, 0.7211]}, {"w": "load_iris()", "b": [0.2356, 0.7083, 0.3284, 0.7211]}, {"w": "X", "b": [0.1766, 0.7237, 0.185, 0.7365]}, {"w": "=", "b": [0.1935, 0.7237, 0.2019, 0.7365]}, {"w": "iris.data[:,", "b": [0.2103, 0.7237, 0.3115, 0.7365]}, {"w": "(2,", "b": [0.3199, 0.7237, 0.3452, 0.7365]}, {"w": "3)]", "b": [0.3537, 0.7237, 0.379, 0.7365]}, {"w": "#", "b": [0.3958, 0.7237, 0.4043, 0.7365]}, {"w": "petal", "b": [0.4127, 0.7237, 0.4549, 0.7365]}, {"w": "length,", "b": [0.4633, 0.7237, 0.5223, 0.7365]}, {"w": "petal", "b": [0.5308, 0.7237, 0.5729, 0.7365]}, {"w": "width", "b": [0.5814, 0.7237, 0.6235, 0.7365]}, {"w": "y", "b": [0.1766, 0.7391, 0.185, 0.752]}, {"w": "=", "b": [0.1935, 0.7391, 0.2019, 0.752]}, {"w": "(iris.target", "b": [0.2103, 0.7391, 0.3115, 0.752]}, {"w": "==", "b": [0.3199, 0.7391, 0.3368, 0.752]}, {"w": "0).astype(np.int)", "b": [0.3452, 0.7391, 0.4886, 0.752]}, {"w": "#", "b": [0.5055, 0.7391, 0.5139, 0.752]}, {"w": "Iris", "b": [0.5223, 0.7391, 0.5561, 0.752]}, {"w": "Setosa?", "b": [0.5645, 0.7391, 0.6235, 0.752]}]}, {"id": "b_14", "type": "equation", "text": "per_clf = Perceptron() per_clf.fit(X, y)", "words": [{"w": "per_clf", "b": [0.1766, 0.7699, 0.2356, 0.7828]}, {"w": "=", "b": [0.2441, 0.7699, 0.2525, 0.7828]}, {"w": "Perceptron()", "b": [0.2609, 0.7699, 0.3621, 0.7828]}, {"w": "per_clf.fit(X,", "b": [0.1766, 0.7854, 0.2946, 0.7982]}, {"w": "y)", "b": [0.3031, 0.7854, 0.3199, 0.7982]}]}, {"id": "b_15", "type": "paragraph", "text": "284 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "284", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2745, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3635, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 311, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "y_pred = per_clf.predict([[2, 0.5]])", "words": [{"w": "y_pred", "b": [0.1766, 0.0983, 0.2272, 0.1112]}, {"w": "=", "b": [0.2356, 0.0983, 0.244, 0.1112]}, {"w": "per_clf.predict([[2,", "b": [0.2525, 0.0983, 0.4211, 0.1112]}, {"w": "0.5]])", "b": [0.4296, 0.0983, 0.4802, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "You may have noticed the fact that the Perceptron learning algorithm strongly resem‐ bles Stochastic Gradient Descent. In fact, Scikit-Learn’s Perceptron class is equivalent to using an SGDClassifier with the following hyperparameters: loss=\"perceptron\", learning_rate=\"constant\", eta0=1 (the learning rate), and penalty=None (no regu‐ larization).", "words": [{"w": "You", "b": [0.1429, 0.119, 0.1752, 0.1404]}, {"w": "may", "b": [0.1802, 0.119, 0.2156, 0.1404]}, {"w": "have", "b": [0.2206, 0.119, 0.259, 0.1404]}, {"w": "noticed", "b": [0.264, 0.119, 0.3266, 0.1404]}, {"w": "the", "b": [0.3316, 0.119, 0.3579, 0.1404]}, {"w": "fact", "b": [0.3629, 0.119, 0.3934, 0.1404]}, {"w": "that", "b": [0.3983, 0.119, 0.4309, 0.1404]}, {"w": "the", "b": [0.4359, 0.119, 0.4622, 0.1404]}, {"w": "Perceptron", "b": [0.4672, 0.119, 0.5596, 0.1404]}, {"w": "learning", "b": [0.5645, 0.119, 0.6337, 0.1404]}, {"w": "algorithm", "b": [0.6386, 0.119, 0.7213, 0.1404]}, {"w": "strongly", "b": [0.7263, 0.119, 0.7946, 0.1404]}, {"w": "resem‐", "b": [0.7996, 0.119, 0.8572, 0.1404]}, {"w": "bles", "b": [0.1429, 0.1389, 0.1752, 0.1603]}, {"w": "Stochastic", "b": [0.1802, 0.1389, 0.2645, 0.1603]}, {"w": "Gradient", "b": [0.2695, 0.1389, 0.344, 0.1603]}, {"w": "Descent.", "b": [0.349, 0.1389, 0.4206, 0.1603]}, {"w": "In", "b": [0.4256, 0.1389, 0.4441, 0.1603]}, {"w": "fact,", "b": [0.449, 0.1389, 0.4843, 0.1603]}, {"w": "Scikit-Learn’s", "b": [0.4892, 0.1389, 0.6001, 0.1603]}, {"w": "Perceptron", "b": [0.6051, 0.1421, 0.7041, 0.1572]}, {"w": "class", "b": [0.709, 0.1389, 0.7476, 0.1603]}, {"w": "is", "b": [0.7523, 0.1389, 0.7655, 0.1603]}, {"w": "equivalent", "b": [0.7702, 0.1389, 0.8567, 0.1603]}, {"w": "to", "b": [0.1429, 0.1589, 0.1598, 0.1803]}, {"w": "using", "b": [0.165, 0.1589, 0.2104, 0.1803]}, {"w": "an", "b": [0.2156, 0.1589, 0.2361, 0.1803]}, {"w": "SGDClassifier", "b": [0.2413, 0.162, 0.3699, 0.1771]}, {"w": "with", "b": [0.375, 0.1589, 0.4124, 0.1803]}, {"w": "the", "b": [0.4175, 0.1589, 0.4439, 0.1803]}, {"w": "following", "b": [0.449, 0.1589, 0.528, 0.1803]}, {"w": "hyperparameters:", "b": [0.5331, 0.1589, 0.679, 0.1803]}, {"w": "loss=\"perceptron\",", "b": [0.6842, 0.1589, 0.8571, 0.1803]}, {"w": "learning_rate=\"constant\",", "b": [0.1429, 0.1788, 0.3851, 0.2002]}, {"w": "eta0=1", "b": [0.3904, 0.182, 0.4497, 0.1971]}, {"w": "(the", "b": [0.455, 0.1788, 0.4885, 0.2002]}, {"w": "learning", "b": [0.4938, 0.1788, 0.5629, 0.2002]}, {"w": "rate),", "b": [0.5682, 0.1788, 0.6118, 0.2002]}, {"w": "and", "b": [0.6171, 0.1788, 0.6486, 0.2002]}, {"w": "penalty=None", "b": [0.6539, 0.182, 0.7726, 0.1971]}, {"w": "(no", "b": [0.7779, 0.1788, 0.8071, 0.2002]}, {"w": "regu‐", "b": [0.8118, 0.1788, 0.8566, 0.2002]}, {"w": "larization).", "b": [0.1429, 0.1979, 0.234, 0.2193]}]}, {"id": "b_2", "type": "paragraph", "text": "Note that contrary to Logistic Regression classifiers, Perceptrons do not output a class probability; rather, they just make predictions based on a hard threshold. This is one of the good reasons to prefer Logistic Regression over Perceptrons.", "words": [{"w": "Note", "b": [0.1429, 0.226, 0.1836, 0.2474]}, {"w": "that", "b": [0.1884, 0.226, 0.221, 0.2474]}, {"w": "contrary", "b": [0.2257, 0.226, 0.2973, 0.2474]}, {"w": "to", "b": [0.302, 0.226, 0.319, 0.2474]}, {"w": "Logistic", "b": [0.3237, 0.226, 0.3893, 0.2474]}, {"w": "Regression", "b": [0.394, 0.226, 0.485, 0.2474]}, {"w": "classifiers,", "b": [0.4897, 0.226, 0.5746, 0.2474]}, {"w": "Perceptrons", "b": [0.5793, 0.226, 0.6793, 0.2474]}, {"w": "do", "b": [0.684, 0.226, 0.7056, 0.2474]}, {"w": "not", "b": [0.7104, 0.226, 0.7387, 0.2474]}, {"w": "output", "b": [0.7435, 0.226, 0.7999, 0.2474]}, {"w": "a", "b": [0.8046, 0.226, 0.8137, 0.2474]}, {"w": "class", "b": [0.8185, 0.226, 0.857, 0.2474]}, {"w": "probability;", "b": [0.1429, 0.245, 0.2402, 0.2664]}, {"w": "rather,", "b": [0.2458, 0.245, 0.2998, 0.2664]}, {"w": "they", "b": [0.3055, 0.245, 0.3414, 0.2664]}, {"w": "just", "b": [0.347, 0.245, 0.3774, 0.2664]}, {"w": "make", "b": [0.3831, 0.245, 0.4285, 0.2664]}, {"w": "predictions", "b": [0.4342, 0.245, 0.5287, 0.2664]}, {"w": "based", "b": [0.5343, 0.245, 0.5815, 0.2664]}, {"w": "on", "b": [0.5872, 0.245, 0.6092, 0.2664]}, {"w": "a", "b": [0.6149, 0.245, 0.624, 0.2664]}, {"w": "hard", "b": [0.6297, 0.245, 0.6687, 0.2664]}, {"w": "threshold.", "b": [0.6744, 0.245, 0.7588, 0.2664]}, {"w": "This", "b": [0.7645, 0.245, 0.8017, 0.2664]}, {"w": "is", "b": [0.8074, 0.245, 0.8206, 0.2664]}, {"w": "one", "b": [0.8263, 0.245, 0.8571, 0.2664]}, {"w": "of", "b": [0.1429, 0.2641, 0.1597, 0.2855]}, {"w": "the", "b": [0.1644, 0.2641, 0.1907, 0.2855]}, {"w": "good", "b": [0.1954, 0.2641, 0.2374, 0.2855]}, {"w": "reasons", "b": [0.2422, 0.2641, 0.3052, 0.2855]}, {"w": "to", "b": [0.3099, 0.2641, 0.3269, 0.2855]}, {"w": "prefer", "b": [0.3317, 0.2641, 0.3819, 0.2855]}, {"w": "Logistic", "b": [0.3866, 0.2641, 0.4522, 0.2855]}, {"w": "Regression", "b": [0.4569, 0.2641, 0.5479, 0.2855]}, {"w": "over", "b": [0.5527, 0.2641, 0.5895, 0.2855]}, {"w": "Perceptrons.", "b": [0.5943, 0.2641, 0.699, 0.2855]}]}, {"id": "b_3", "type": "paragraph", "text": "In their 1969 monograph titled Perceptrons, Marvin Minsky and Seymour Papert highlighted a number of serious weaknesses of Perceptrons, in particular the fact that they are incapable of solving some trivial problems (e.g., the Exclusive OR (XOR) classification problem; see the left side of Figure 10-6). Of course this is true of any other linear classification model as well (such as Logistic Regression classifiers), but researchers had expected much more from Perceptrons, and their disappointment was great, and many researchers dropped neural networks altogether in favor of higher-level problems such as logic, problem solving, and search.", "words": [{"w": "In", "b": [0.1429, 0.2922, 0.1614, 0.3136]}, {"w": "their", "b": [0.1704, 0.2922, 0.2101, 0.3136]}, {"w": "1969", "b": [0.2192, 0.2922, 0.2592, 0.3136]}, {"w": "monograph", "b": [0.2682, 0.2922, 0.3662, 0.3136]}, {"w": "titled", "b": [0.3753, 0.2922, 0.4187, 0.3136]}, {"w": "Perceptrons,", "b": [0.4278, 0.292, 0.5262, 0.3136]}, {"w": "Marvin", "b": [0.5353, 0.2922, 0.5976, 0.3136]}, {"w": "Minsky", "b": [0.6067, 0.2922, 0.6697, 0.3136]}, {"w": "and", "b": [0.6788, 0.2922, 0.7104, 0.3136]}, {"w": "Seymour", "b": [0.7194, 0.2922, 0.7942, 0.3136]}, {"w": "Papert", "b": [0.8033, 0.2922, 0.8572, 0.3136]}, {"w": "highlighted", "b": [0.1429, 0.3112, 0.238, 0.3326]}, {"w": "a", "b": [0.2433, 0.3112, 0.2524, 0.3326]}, {"w": "number", "b": [0.2577, 0.3112, 0.324, 0.3326]}, {"w": "of", "b": [0.3293, 0.3112, 0.3461, 0.3326]}, {"w": "serious", "b": [0.3514, 0.3112, 0.4105, 0.3326]}, {"w": "weaknesses", "b": [0.4158, 0.3112, 0.5105, 0.3326]}, {"w": "of", "b": [0.5158, 0.3112, 0.5325, 0.3326]}, {"w": "Perceptrons,", "b": [0.5378, 0.3112, 0.6426, 0.3326]}, {"w": "in", "b": [0.6479, 0.3112, 0.6648, 0.3326]}, {"w": "particular", "b": [0.6701, 0.3112, 0.7519, 0.3326]}, {"w": "the", "b": [0.7572, 0.3112, 0.7835, 0.3326]}, {"w": "fact", "b": [0.7888, 0.3112, 0.8193, 0.3326]}, {"w": "that", "b": [0.8246, 0.3112, 0.8571, 0.3326]}, {"w": "they", "b": [0.1429, 0.3303, 0.1787, 0.3517]}, {"w": "are", "b": [0.1871, 0.3303, 0.2128, 0.3517]}, {"w": "incapable", "b": [0.2211, 0.3303, 0.3004, 0.3517]}, {"w": "of", "b": [0.3087, 0.3303, 0.3255, 0.3517]}, {"w": "solving", "b": [0.3338, 0.3303, 0.3937, 0.3517]}, {"w": "some", "b": [0.402, 0.3303, 0.4462, 0.3517]}, {"w": "trivial", "b": [0.4545, 0.3303, 0.5038, 0.3517]}, {"w": "problems", "b": [0.5121, 0.3303, 0.5908, 0.3517]}, {"w": "(e.g.,", "b": [0.5991, 0.3303, 0.6392, 0.3517]}, {"w": "the", "b": [0.6475, 0.3303, 0.6738, 0.3517]}, {"w": "Exclusive", "b": [0.6821, 0.3301, 0.7576, 0.3517]}, {"w": "OR", "b": [0.766, 0.3301, 0.7929, 0.3517]}, {"w": "(XOR)", "b": [0.8012, 0.3303, 0.8571, 0.3517]}, {"w": "classification", "b": [0.1428, 0.3493, 0.2502, 0.3707]}, {"w": "problem;", "b": [0.2568, 0.3493, 0.3326, 0.3707]}, {"w": "see", "b": [0.3392, 0.3493, 0.3645, 0.3707]}, {"w": "the", "b": [0.3711, 0.3493, 0.3974, 0.3707]}, {"w": "left", "b": [0.404, 0.3493, 0.4307, 0.3707]}, {"w": "side", "b": [0.4373, 0.3493, 0.4703, 0.3707]}, {"w": "of", "b": [0.4769, 0.3493, 0.4937, 0.3707]}, {"w": "Figure", "b": [0.5003, 0.3493, 0.5543, 0.3707]}, {"w": "10-6).", "b": [0.5609, 0.3493, 0.6103, 0.3707]}, {"w": "Of", "b": [0.6168, 0.3493, 0.6386, 0.3707]}, {"w": "course", "b": [0.6451, 0.3493, 0.6999, 0.3707]}, {"w": "this", "b": [0.7065, 0.3493, 0.7372, 0.3707]}, {"w": "is", "b": [0.7437, 0.3493, 0.757, 0.3707]}, {"w": "true", "b": [0.7636, 0.3493, 0.7976, 0.3707]}, {"w": "of", "b": [0.8041, 0.3493, 0.8209, 0.3707]}, {"w": "any", "b": [0.8275, 0.3493, 0.8571, 0.3707]}, {"w": "other", "b": [0.1429, 0.3684, 0.1876, 0.3898]}, {"w": "linear", "b": [0.1941, 0.3684, 0.242, 0.3898]}, {"w": "classification", "b": [0.2486, 0.3684, 0.3559, 0.3898]}, {"w": "model", "b": [0.3625, 0.3684, 0.4153, 0.3898]}, {"w": "as", "b": [0.4218, 0.3684, 0.4386, 0.3898]}, {"w": "well", "b": [0.4451, 0.3684, 0.4788, 0.3898]}, {"w": "(such", "b": [0.4853, 0.3684, 0.5311, 0.3898]}, {"w": "as", "b": [0.5377, 0.3684, 0.5545, 0.3898]}, {"w": "Logistic", "b": [0.561, 0.3684, 0.6265, 0.3898]}, {"w": "Regression", "b": [0.6331, 0.3684, 0.7241, 0.3898]}, {"w": "classifiers),", "b": [0.7306, 0.3684, 0.8226, 0.3898]}, {"w": "but", "b": [0.8291, 0.3684, 0.8571, 0.3898]}, {"w": "researchers", "b": [0.1429, 0.3874, 0.237, 0.4088]}, {"w": "had", "b": [0.2452, 0.3874, 0.2765, 0.4088]}, {"w": "expected", "b": [0.2848, 0.3874, 0.3583, 0.4088]}, {"w": "much", "b": [0.3665, 0.3874, 0.4142, 0.4088]}, {"w": "more", "b": [0.4224, 0.3874, 0.4667, 0.4088]}, {"w": "from", "b": [0.475, 0.3874, 0.5165, 0.4088]}, {"w": "Perceptrons,", "b": [0.5248, 0.3874, 0.6295, 0.4088]}, {"w": "and", "b": [0.6378, 0.3874, 0.6693, 0.4088]}, {"w": "their", "b": [0.6776, 0.3874, 0.7172, 0.4088]}, {"w": "disappointment", "b": [0.7255, 0.3874, 0.8571, 0.4088]}, {"w": "was", "b": [0.1429, 0.4065, 0.1739, 0.4279]}, {"w": "great,", "b": [0.1832, 0.4065, 0.2294, 0.4279]}, {"w": "and", "b": [0.2387, 0.4065, 0.2702, 0.4279]}, {"w": "many", "b": [0.2795, 0.4065, 0.3262, 0.4279]}, {"w": "researchers", "b": [0.3355, 0.4065, 0.4296, 0.4279]}, {"w": "dropped", "b": [0.4389, 0.4065, 0.51, 0.4279]}, {"w": "neural", "b": [0.5192, 0.4065, 0.5727, 0.4279]}, {"w": "networks", "b": [0.582, 0.4065, 0.6592, 0.4279]}, {"w": "altogether", "b": [0.6685, 0.4065, 0.7526, 0.4279]}, {"w": "in", "b": [0.7618, 0.4065, 0.7788, 0.4279]}, {"w": "favor", "b": [0.7881, 0.4065, 0.8311, 0.4279]}, {"w": "of", "b": [0.8403, 0.4065, 0.8571, 0.4279]}, {"w": "higher-level", "b": [0.1429, 0.4255, 0.2418, 0.4469]}, {"w": "problems", "b": [0.2466, 0.4255, 0.3253, 0.4469]}, {"w": "such", "b": [0.33, 0.4255, 0.3686, 0.4469]}, {"w": "as", "b": [0.3734, 0.4255, 0.3902, 0.4469]}, {"w": "logic,", "b": [0.3949, 0.4255, 0.4397, 0.4469]}, {"w": "problem", "b": [0.4444, 0.4255, 0.5155, 0.4469]}, {"w": "solving,", "b": [0.5202, 0.4255, 0.5848, 0.4469]}, {"w": "and", "b": [0.5896, 0.4255, 0.6211, 0.4469]}, {"w": "search.", "b": [0.6258, 0.4255, 0.6839, 0.4469]}]}, {"id": "b_4", "type": "paragraph", "text": "However, it turns out that some of the limitations of Perceptrons can be eliminated by stacking multiple Perceptrons. The resulting ANN is called a Multi-Layer Perceptron (MLP). In particular, an MLP can solve the XOR problem, as you can verify by com‐ puting the output of the MLP represented on the right of Figure 10-6: with inputs (0, 0) or (1, 1) the network outputs 0, and with inputs (0, 1) or (1, 0) it outputs 1. All connections have a weight equal to 1, except the four connections where the weight is shown. Try verifying that this network indeed solves the XOR problem!", "words": [{"w": "However,", "b": [0.1429, 0.4536, 0.2217, 0.475]}, {"w": "it", "b": [0.2265, 0.4536, 0.2384, 0.475]}, {"w": "turns", "b": [0.2431, 0.4536, 0.2873, 0.475]}, {"w": "out", "b": [0.292, 0.4536, 0.3201, 0.475]}, {"w": "that", "b": [0.3248, 0.4536, 0.3574, 0.475]}, {"w": "some", "b": [0.3621, 0.4536, 0.4063, 0.475]}, {"w": "of", "b": [0.411, 0.4536, 0.4278, 0.475]}, {"w": "the", "b": [0.4326, 0.4536, 0.4589, 0.475]}, {"w": "limitations", "b": [0.4636, 0.4536, 0.5538, 0.475]}, {"w": "of", "b": [0.5586, 0.4536, 0.5753, 0.475]}, {"w": "Perceptrons", "b": [0.5801, 0.4536, 0.6801, 0.475]}, {"w": "can", "b": [0.6848, 0.4536, 0.7141, 0.475]}, {"w": "be", "b": [0.7189, 0.4536, 0.7383, 0.475]}, {"w": "eliminated", "b": [0.743, 0.4536, 0.8317, 0.475]}, {"w": "by", "b": [0.8365, 0.4536, 0.8566, 0.475]}, {"w": "stacking", "b": [0.1429, 0.4727, 0.2119, 0.4941]}, {"w": "multiple", "b": [0.2182, 0.4727, 0.2882, 0.4941]}, {"w": "Perceptrons.", "b": [0.2944, 0.4727, 0.3992, 0.4941]}, {"w": "The", "b": [0.4055, 0.4727, 0.4383, 0.4941]}, {"w": "resulting", "b": [0.4446, 0.4727, 0.5182, 0.4941]}, {"w": "ANN", "b": [0.5245, 0.4727, 0.5699, 0.4941]}, {"w": "is", "b": [0.5762, 0.4727, 0.5894, 0.4941]}, {"w": "called", "b": [0.5957, 0.4727, 0.6441, 0.4941]}, {"w": "a", "b": [0.6503, 0.4727, 0.6595, 0.4941]}, {"w": "Multi-Layer", "b": [0.6658, 0.4725, 0.7642, 0.4941]}, {"w": "Perceptron", "b": [0.7705, 0.4725, 0.8572, 0.4941]}, {"w": "(MLP).", "b": [0.1429, 0.4917, 0.2035, 0.5131]}, {"w": "In", "b": [0.2091, 0.4917, 0.2276, 0.5131]}, {"w": "particular,", "b": [0.2332, 0.4917, 0.3184, 0.5131]}, {"w": "an", "b": [0.3239, 0.4917, 0.3445, 0.5131]}, {"w": "MLP", "b": [0.35, 0.4917, 0.3915, 0.5131]}, {"w": "can", "b": [0.3971, 0.4917, 0.4265, 0.5131]}, {"w": "solve", "b": [0.432, 0.4917, 0.4741, 0.5131]}, {"w": "the", "b": [0.4796, 0.4917, 0.506, 0.5131]}, {"w": "XOR", "b": [0.5115, 0.4917, 0.553, 0.5131]}, {"w": "problem,", "b": [0.5586, 0.4917, 0.6344, 0.5131]}, {"w": "as", "b": [0.6399, 0.4917, 0.6567, 0.5131]}, {"w": "you", "b": [0.6623, 0.4917, 0.6936, 0.5131]}, {"w": "can", "b": [0.6991, 0.4917, 0.7285, 0.5131]}, {"w": "verify", "b": [0.7341, 0.4917, 0.7819, 0.5131]}, {"w": "by", "b": [0.7875, 0.4917, 0.8077, 0.5131]}, {"w": "com‐", "b": [0.8132, 0.4917, 0.8571, 0.5131]}, {"w": "puting", "b": [0.1429, 0.5108, 0.1979, 0.5322]}, {"w": "the", "b": [0.2033, 0.5108, 0.2296, 0.5322]}, {"w": "output", "b": [0.235, 0.5108, 0.2914, 0.5322]}, {"w": "of", "b": [0.2968, 0.5108, 0.3136, 0.5322]}, {"w": "the", "b": [0.319, 0.5108, 0.3453, 0.5322]}, {"w": "MLP", "b": [0.3507, 0.5108, 0.3922, 0.5322]}, {"w": "represented", "b": [0.3976, 0.5108, 0.4954, 0.5322]}, {"w": "on", "b": [0.5007, 0.5108, 0.5228, 0.5322]}, {"w": "the", "b": [0.5281, 0.5108, 0.5545, 0.5322]}, {"w": "right", "b": [0.5599, 0.5108, 0.6, 0.5322]}, {"w": "of", "b": [0.6054, 0.5108, 0.6222, 0.5322]}, {"w": "Figure", "b": [0.6276, 0.5108, 0.6816, 0.5322]}, {"w": "10-6:", "b": [0.6863, 0.5108, 0.7291, 0.5322]}, {"w": "with", "b": [0.7345, 0.5108, 0.7719, 0.5322]}, {"w": "inputs", "b": [0.7772, 0.5108, 0.8298, 0.5322]}, {"w": "(0,", "b": [0.8352, 0.5108, 0.8572, 0.5322]}, {"w": "0)", "b": [0.1429, 0.5298, 0.1601, 0.5512]}, {"w": "or", "b": [0.167, 0.5298, 0.1853, 0.5512]}, {"w": "(1,", "b": [0.1922, 0.5298, 0.2142, 0.5512]}, {"w": "1)", "b": [0.2211, 0.5298, 0.2383, 0.5512]}, {"w": "the", "b": [0.2452, 0.5298, 0.2715, 0.5512]}, {"w": "network", "b": [0.2784, 0.5298, 0.348, 0.5512]}, {"w": "outputs", "b": [0.3549, 0.5298, 0.4189, 0.5512]}, {"w": "0,", "b": [0.4258, 0.5298, 0.4406, 0.5512]}, {"w": "and", "b": [0.4475, 0.5298, 0.479, 0.5512]}, {"w": "with", "b": [0.4859, 0.5298, 0.5232, 0.5512]}, {"w": "inputs", "b": [0.5301, 0.5298, 0.5827, 0.5512]}, {"w": "(0,", "b": [0.5896, 0.5298, 0.6116, 0.5512]}, {"w": "1)", "b": [0.6185, 0.5298, 0.6357, 0.5512]}, {"w": "or", "b": [0.6426, 0.5298, 0.6609, 0.5512]}, {"w": "(1,", "b": [0.6678, 0.5298, 0.6898, 0.5512]}, {"w": "0)", "b": [0.6967, 0.5298, 0.7139, 0.5512]}, {"w": "it", "b": [0.7208, 0.5298, 0.7327, 0.5512]}, {"w": "outputs", "b": [0.7396, 0.5298, 0.8037, 0.5512]}, {"w": "1.", "b": [0.8106, 0.5298, 0.8253, 0.5512]}, {"w": "All", "b": [0.8322, 0.5298, 0.8571, 0.5512]}, {"w": "connections", "b": [0.1429, 0.5489, 0.2444, 0.5703]}, {"w": "have", "b": [0.2494, 0.5489, 0.2878, 0.5703]}, {"w": "a", "b": [0.2928, 0.5489, 0.3019, 0.5703]}, {"w": "weight", "b": [0.3069, 0.5489, 0.3624, 0.5703]}, {"w": "equal", "b": [0.3674, 0.5489, 0.4124, 0.5703]}, {"w": "to", "b": [0.4174, 0.5489, 0.4344, 0.5703]}, {"w": "1,", "b": [0.4394, 0.5489, 0.4542, 0.5703]}, {"w": "except", "b": [0.4592, 0.5489, 0.5128, 0.5703]}, {"w": "the", "b": [0.5178, 0.5489, 0.5441, 0.5703]}, {"w": "four", "b": [0.5491, 0.5489, 0.5847, 0.5703]}, {"w": "connections", "b": [0.5897, 0.5489, 0.6912, 0.5703]}, {"w": "where", "b": [0.6962, 0.5489, 0.747, 0.5703]}, {"w": "the", "b": [0.752, 0.5489, 0.7784, 0.5703]}, {"w": "weight", "b": [0.7834, 0.5489, 0.8389, 0.5703]}, {"w": "is", "b": [0.8439, 0.5489, 0.8571, 0.5703]}, {"w": "shown.", "b": [0.1428, 0.5679, 0.2027, 0.5893]}, {"w": "Try", "b": [0.2074, 0.5679, 0.2364, 0.5893]}, {"w": "verifying", "b": [0.2411, 0.5679, 0.3158, 0.5893]}, {"w": "that", "b": [0.3205, 0.5679, 0.3531, 0.5893]}, {"w": "this", "b": [0.3578, 0.5679, 0.3885, 0.5893]}, {"w": "network", "b": [0.3932, 0.5679, 0.4628, 0.5893]}, {"w": "indeed", "b": [0.4675, 0.5679, 0.5242, 0.5893]}, {"w": "solves", "b": [0.529, 0.5679, 0.5786, 0.5893]}, {"w": "the", "b": [0.5834, 0.5679, 0.6097, 0.5893]}, {"w": "XOR", "b": [0.6144, 0.5679, 0.6559, 0.5893]}, {"w": "problem!", "b": [0.6606, 0.5679, 0.7374, 0.5893]}]}, {"id": "b_5", "type": "equation", "text": "Figure 10-6. XOR classification problem and an MLP that solves it", "words": [{"w": "Figure", "b": [0.1428, 0.8166, 0.1943, 0.8382]}, {"w": "10-6.", "b": [0.1991, 0.8166, 0.2407, 0.8382]}, {"w": "XOR", "b": [0.2455, 0.8166, 0.285, 0.8382]}, {"w": "classification", "b": [0.2898, 0.8166, 0.3951, 0.8382]}, {"w": "problem", "b": [0.3998, 0.8166, 0.4663, 0.8382]}, {"w": "and", "b": [0.471, 0.8166, 0.5024, 0.8382]}, {"w": "an", "b": [0.5072, 0.8166, 0.5282, 0.8382]}, {"w": "MLP", "b": [0.5329, 0.8166, 0.5738, 0.8382]}, {"w": "that", "b": [0.5786, 0.8166, 0.6114, 0.8382]}, {"w": "solves", "b": [0.6162, 0.8166, 0.6622, 0.8382]}, {"w": "it", "b": [0.6669, 0.8166, 0.6787, 0.8382]}]}, {"id": "b_6", "type": "paragraph", "text": "From Biological to Artificial Neurons | 285", "words": [{"w": "From", "b": [0.585, 0.9225, 0.6155, 0.9388]}, {"w": "Biological", "b": [0.6183, 0.9225, 0.6761, 0.9388]}, {"w": "to", "b": [0.679, 0.9225, 0.6914, 0.9388]}, {"w": "Artificial", "b": [0.6942, 0.9225, 0.7441, 0.9388]}, {"w": "Neurons", "b": [0.7469, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "285", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 312, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "8 In the 1990s, an ANN with more than two hidden layers was considered deep. Nowadays, it is common to see ANNs with dozens of layers, or even hundreds, so the definition of “deep” is quite fuzzy.", "words": [{"w": "8", "b": [0.1451, 0.8416, 0.1518, 0.8559]}, {"w": "In", "b": [0.1587, 0.8401, 0.1728, 0.8565]}, {"w": "the", "b": [0.1764, 0.8401, 0.1965, 0.8565]}, {"w": "1990s,", "b": [0.2001, 0.8401, 0.24, 0.8565]}, {"w": "an", "b": [0.2436, 0.8401, 0.2593, 0.8565]}, {"w": "ANN", "b": [0.2629, 0.8401, 0.2974, 0.8565]}, {"w": "with", "b": [0.301, 0.8401, 0.3295, 0.8565]}, {"w": "more", "b": [0.3331, 0.8401, 0.3668, 0.8565]}, {"w": "than", "b": [0.3704, 0.8401, 0.3994, 0.8565]}, {"w": "two", "b": [0.403, 0.8401, 0.4268, 0.8565]}, {"w": "hidden", "b": [0.4304, 0.8401, 0.4753, 0.8565]}, {"w": "layers", "b": [0.4789, 0.8401, 0.5154, 0.8565]}, {"w": "was", "b": [0.519, 0.8401, 0.5426, 0.8565]}, {"w": "considered", "b": [0.5462, 0.8401, 0.616, 0.8565]}, {"w": "deep.", "b": [0.6196, 0.8401, 0.6529, 0.8565]}, {"w": "Nowadays,", "b": [0.6565, 0.8401, 0.7256, 0.8565]}, {"w": "it", "b": [0.7292, 0.8401, 0.7383, 0.8565]}, {"w": "is", "b": [0.7419, 0.8401, 0.752, 0.8565]}, {"w": "common", "b": [0.7556, 0.8401, 0.8132, 0.8565]}, {"w": "to", "b": [0.8168, 0.8401, 0.8297, 0.8565]}, {"w": "see", "b": [0.8333, 0.8401, 0.8527, 0.8565]}, {"w": "ANNs", "b": [0.1587, 0.8553, 0.1987, 0.8716]}, {"w": "with", "b": [0.2023, 0.8553, 0.2307, 0.8716]}, {"w": "dozens", "b": [0.2343, 0.8553, 0.2787, 0.8716]}, {"w": "of", "b": [0.2823, 0.8553, 0.2951, 0.8716]}, {"w": "layers,", "b": [0.2987, 0.8553, 0.3388, 0.8716]}, {"w": "or", "b": [0.3424, 0.8553, 0.3564, 0.8716]}, {"w": "even", "b": [0.36, 0.8553, 0.3895, 0.8716]}, {"w": "hundreds,", "b": [0.3931, 0.8553, 0.4572, 0.8716]}, {"w": "so", "b": [0.4608, 0.8553, 0.4748, 0.8716]}, {"w": "the", "b": [0.4784, 0.8553, 0.4984, 0.8716]}, {"w": "definition", "b": [0.502, 0.8553, 0.5649, 0.8716]}, {"w": "of", "b": [0.5685, 0.8553, 0.5813, 0.8716]}, {"w": "“deep”", "b": [0.5849, 0.8553, 0.6253, 0.8716]}, {"w": "is", "b": [0.6289, 0.8553, 0.639, 0.8716]}, {"w": "quite", "b": [0.6426, 0.8553, 0.675, 0.8716]}, {"w": "fuzzy.", "b": [0.6786, 0.8553, 0.7148, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "9 “Learning Internal Representations by Error Propagation,” D. Rumelhart, G. Hinton, R. Williams (1986).", "words": [{"w": "9", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Learning", "b": [0.1587, 0.8749, 0.2222, 0.8912]}, {"w": "Internal", "b": [0.2258, 0.8749, 0.2768, 0.8912]}, {"w": "Representations", "b": [0.2804, 0.8749, 0.3821, 0.8912]}, {"w": "by", "b": [0.3857, 0.8749, 0.401, 0.8912]}, {"w": "Error", "b": [0.4047, 0.8749, 0.4394, 0.8912]}, {"w": "Propagation,”", "b": [0.443, 0.8749, 0.529, 0.8912]}, {"w": "D.", "b": [0.5326, 0.8749, 0.5473, 0.8912]}, {"w": "Rumelhart,", "b": [0.5509, 0.8749, 0.6224, 0.8912]}, {"w": "G.", "b": [0.626, 0.8749, 0.6409, 0.8912]}, {"w": "Hinton,", "b": [0.6445, 0.8749, 0.6946, 0.8912]}, {"w": "R.", "b": [0.6982, 0.8749, 0.7117, 0.8912]}, {"w": "Williams", "b": [0.7153, 0.8749, 0.7723, 0.8912]}, {"w": "(1986).", "b": [0.776, 0.8749, 0.821, 0.8912]}]}, {"id": "b_2", "type": "equation", "text": "Multi-Layer Perceptron and Backpropagation", "words": [{"w": "Multi-Layer", "b": [0.1429, 0.0763, 0.2622, 0.1049]}, {"w": "Perceptron", "b": [0.2671, 0.0763, 0.3808, 0.1049]}, {"w": "and", "b": [0.3858, 0.0763, 0.425, 0.1049]}, {"w": "Backpropagation", "b": [0.43, 0.0763, 0.6062, 0.1049]}]}, {"id": "b_3", "type": "paragraph", "text": "An MLP is composed of one (passthrough) input layer, one or more layers of TLUs, called hidden layers, and one final layer of TLUs called the output layer (see Figure 10-7). The layers close to the input layer are usually called the lower layers, and the ones close to the outputs are usually called the upper layers. Every layer except the output layer includes a bias neuron and is fully connected to the next layer.", "words": [{"w": "An", "b": [0.1429, 0.1108, 0.1686, 0.1322]}, {"w": "MLP", "b": [0.1749, 0.1108, 0.2164, 0.1322]}, {"w": "is", "b": [0.2226, 0.1108, 0.2359, 0.1322]}, {"w": "composed", "b": [0.2421, 0.1108, 0.3273, 0.1322]}, {"w": "of", "b": [0.3335, 0.1108, 0.3503, 0.1322]}, {"w": "one", "b": [0.3565, 0.1108, 0.3874, 0.1322]}, {"w": "(passthrough)", "b": [0.3937, 0.1108, 0.5112, 0.1322]}, {"w": "input", "b": [0.5174, 0.1106, 0.5607, 0.1322]}, {"w": "layer,", "b": [0.567, 0.1106, 0.6117, 0.1322]}, {"w": "one", "b": [0.6179, 0.1108, 0.6488, 0.1322]}, {"w": "or", "b": [0.6551, 0.1108, 0.6734, 0.1322]}, {"w": "more", "b": [0.6797, 0.1108, 0.7239, 0.1322]}, {"w": "layers", "b": [0.7302, 0.1108, 0.778, 0.1322]}, {"w": "of", "b": [0.7842, 0.1108, 0.801, 0.1322]}, {"w": "TLUs,", "b": [0.8073, 0.1108, 0.8571, 0.1322]}, {"w": "called", "b": [0.1428, 0.1298, 0.1912, 0.1512]}, {"w": "hidden", "b": [0.2031, 0.1296, 0.2594, 0.1512]}, {"w": "layers,", "b": [0.2714, 0.1296, 0.323, 0.1512]}, {"w": "and", "b": [0.3349, 0.1298, 0.3664, 0.1512]}, {"w": "one", "b": [0.3783, 0.1298, 0.4092, 0.1512]}, {"w": "final", "b": [0.4211, 0.1298, 0.4587, 0.1512]}, {"w": "layer", "b": [0.4706, 0.1298, 0.5108, 0.1512]}, {"w": "of", "b": [0.5227, 0.1298, 0.5395, 0.1512]}, {"w": "TLUs", "b": [0.5514, 0.1298, 0.5965, 0.1512]}, {"w": "called", "b": [0.6084, 0.1298, 0.6567, 0.1512]}, {"w": "the", "b": [0.6686, 0.1298, 0.695, 0.1512]}, {"w": "output", "b": [0.7069, 0.1296, 0.7608, 0.1512]}, {"w": "layer", "b": [0.7727, 0.1296, 0.8127, 0.1512]}, {"w": "(see", "b": [0.8246, 0.1298, 0.8571, 0.1512]}, {"w": "Figure", "b": [0.1429, 0.1489, 0.1969, 0.1703]}, {"w": "10-7).", "b": [0.2041, 0.1489, 0.2535, 0.1703]}, {"w": "The", "b": [0.2608, 0.1489, 0.2936, 0.1703]}, {"w": "layers", "b": [0.3009, 0.1489, 0.3487, 0.1703]}, {"w": "close", "b": [0.356, 0.1489, 0.3972, 0.1703]}, {"w": "to", "b": [0.4045, 0.1489, 0.4215, 0.1703]}, {"w": "the", "b": [0.4287, 0.1489, 0.4551, 0.1703]}, {"w": "input", "b": [0.4623, 0.1489, 0.5073, 0.1703]}, {"w": "layer", "b": [0.5145, 0.1489, 0.5547, 0.1703]}, {"w": "are", "b": [0.562, 0.1489, 0.5877, 0.1703]}, {"w": "usually", "b": [0.595, 0.1489, 0.654, 0.1703]}, {"w": "called", "b": [0.6613, 0.1489, 0.7097, 0.1703]}, {"w": "the", "b": [0.7169, 0.1489, 0.7433, 0.1703]}, {"w": "lower", "b": [0.7505, 0.1489, 0.7973, 0.1703]}, {"w": "layers,", "b": [0.8046, 0.1489, 0.8571, 0.1703]}, {"w": "and", "b": [0.1429, 0.1679, 0.1744, 0.1893]}, {"w": "the", "b": [0.183, 0.1679, 0.2093, 0.1893]}, {"w": "ones", "b": [0.2179, 0.1679, 0.2564, 0.1893]}, {"w": "close", "b": [0.2649, 0.1679, 0.3061, 0.1893]}, {"w": "to", "b": [0.3147, 0.1679, 0.3317, 0.1893]}, {"w": "the", "b": [0.3402, 0.1679, 0.3666, 0.1893]}, {"w": "outputs", "b": [0.3751, 0.1679, 0.4392, 0.1893]}, {"w": "are", "b": [0.4477, 0.1679, 0.4734, 0.1893]}, {"w": "usually", "b": [0.482, 0.1679, 0.541, 0.1893]}, {"w": "called", "b": [0.5496, 0.1679, 0.5979, 0.1893]}, {"w": "the", "b": [0.6065, 0.1679, 0.6328, 0.1893]}, {"w": "upper", "b": [0.6414, 0.1679, 0.6909, 0.1893]}, {"w": "layers.", "b": [0.6994, 0.1679, 0.752, 0.1893]}, {"w": "Every", "b": [0.7606, 0.1679, 0.8084, 0.1893]}, {"w": "layer", "b": [0.817, 0.1679, 0.8571, 0.1893]}, {"w": "except", "b": [0.1429, 0.187, 0.1965, 0.2084]}, {"w": "the", "b": [0.2012, 0.187, 0.2275, 0.2084]}, {"w": "output", "b": [0.2323, 0.187, 0.2886, 0.2084]}, {"w": "layer", "b": [0.2934, 0.187, 0.3336, 0.2084]}, {"w": "includes", "b": [0.3383, 0.187, 0.4079, 0.2084]}, {"w": "a", "b": [0.4126, 0.187, 0.4218, 0.2084]}, {"w": "bias", "b": [0.4265, 0.187, 0.4595, 0.2084]}, {"w": "neuron", "b": [0.4642, 0.187, 0.5253, 0.2084]}, {"w": "and", "b": [0.53, 0.187, 0.5615, 0.2084]}, {"w": "is", "b": [0.5663, 0.187, 0.5795, 0.2084]}, {"w": "fully", "b": [0.5842, 0.187, 0.6216, 0.2084]}, {"w": "connected", "b": [0.6263, 0.187, 0.7124, 0.2084]}, {"w": "to", "b": [0.7171, 0.187, 0.7341, 0.2084]}, {"w": "the", "b": [0.7388, 0.187, 0.7652, 0.2084]}, {"w": "next", "b": [0.7699, 0.187, 0.8063, 0.2084]}, {"w": "layer.", "b": [0.8111, 0.187, 0.8547, 0.2084]}]}, {"id": "b_4", "type": "equation", "text": "Figure 10-7. Multi-Layer Perceptron", "words": [{"w": "Figure", "b": [0.1429, 0.4697, 0.1943, 0.4913]}, {"w": "10-7.", "b": [0.1991, 0.4697, 0.2407, 0.4913]}, {"w": "Multi-Layer", "b": [0.2455, 0.4697, 0.3439, 0.4913]}, {"w": "Perceptron", "b": [0.3486, 0.4697, 0.4353, 0.4913]}]}, {"id": "b_5", "type": "paragraph", "text": "The signal flows only in one direction (from the inputs to the out‐ puts), so this architecture is an example of a feedforward neural net‐ work (FNN).", "words": [{"w": "The", "b": [0.2714, 0.5119, 0.3014, 0.5314]}, {"w": "signal", "b": [0.3067, 0.5119, 0.3514, 0.5314]}, {"w": "flows", "b": [0.3567, 0.5119, 0.3969, 0.5314]}, {"w": "only", "b": [0.4022, 0.5119, 0.4359, 0.5314]}, {"w": "in", "b": [0.4412, 0.5119, 0.4567, 0.5314]}, {"w": "one", "b": [0.4621, 0.5119, 0.4903, 0.5314]}, {"w": "direction", "b": [0.4956, 0.5119, 0.565, 0.5314]}, {"w": "(from", "b": [0.5704, 0.5119, 0.615, 0.5314]}, {"w": "the", "b": [0.6203, 0.5119, 0.6444, 0.5314]}, {"w": "inputs", "b": [0.6497, 0.5119, 0.6977, 0.5314]}, {"w": "to", "b": [0.7031, 0.5119, 0.7186, 0.5314]}, {"w": "the", "b": [0.7239, 0.5119, 0.748, 0.5314]}, {"w": "out‐", "b": [0.7533, 0.5119, 0.7857, 0.5314]}, {"w": "puts),", "b": [0.2714, 0.5293, 0.3152, 0.5489]}, {"w": "so", "b": [0.3197, 0.5293, 0.3364, 0.5489]}, {"w": "this", "b": [0.3409, 0.5293, 0.369, 0.5489]}, {"w": "architecture", "b": [0.3735, 0.5293, 0.4653, 0.5489]}, {"w": "is", "b": [0.4698, 0.5293, 0.4819, 0.5489]}, {"w": "an", "b": [0.4864, 0.5293, 0.5052, 0.5489]}, {"w": "example", "b": [0.5097, 0.5293, 0.5732, 0.5489]}, {"w": "of", "b": [0.5777, 0.5293, 0.5931, 0.5489]}, {"w": "a", "b": [0.5974, 0.5293, 0.6058, 0.5489]}, {"w": "feedforward", "b": [0.6104, 0.5291, 0.699, 0.5489]}, {"w": "neural", "b": [0.7033, 0.5291, 0.7513, 0.5489]}, {"w": "net‐", "b": [0.7557, 0.5291, 0.7854, 0.5489]}, {"w": "work", "b": [0.2714, 0.5465, 0.3086, 0.5663]}, {"w": "(FNN).", "b": [0.313, 0.5467, 0.3689, 0.5663]}]}, {"id": "b_6", "type": "paragraph", "text": "When an ANN contains a deep stack of hidden layers8, it is called a deep neural net‐ work (DNN). The field of Deep Learning studies DNNs, and more generally models containing deep stacks of computations. However, many people talk about Deep Learning whenever neural networks are involved (even shallow ones).", "words": [{"w": "When", "b": [0.1429, 0.6105, 0.1945, 0.6319]}, {"w": "an", "b": [0.2005, 0.6105, 0.221, 0.6319]}, {"w": "ANN", "b": [0.227, 0.6105, 0.2724, 0.6319]}, {"w": "contains", "b": [0.2784, 0.6105, 0.349, 0.6319]}, {"w": "a", "b": [0.355, 0.6105, 0.3641, 0.6319]}, {"w": "deep", "b": [0.3702, 0.6105, 0.4098, 0.6319]}, {"w": "stack", "b": [0.4158, 0.6105, 0.4581, 0.6319]}, {"w": "of", "b": [0.4641, 0.6105, 0.4809, 0.6319]}, {"w": "hidden", "b": [0.4869, 0.6105, 0.5459, 0.6319]}, {"w": "layers8,", "b": [0.5519, 0.6105, 0.6102, 0.6319]}, {"w": "it", "b": [0.6162, 0.6105, 0.6282, 0.6319]}, {"w": "is", "b": [0.6342, 0.6105, 0.6474, 0.6319]}, {"w": "called", "b": [0.6534, 0.6105, 0.7018, 0.6319]}, {"w": "a", "b": [0.7078, 0.6105, 0.7169, 0.6319]}, {"w": "deep", "b": [0.723, 0.6103, 0.76, 0.6319]}, {"w": "neural", "b": [0.7661, 0.6103, 0.8186, 0.6319]}, {"w": "net‐", "b": [0.8247, 0.6103, 0.8571, 0.6319]}, {"w": "work", "b": [0.1429, 0.6293, 0.1836, 0.651]}, {"w": "(DNN).", "b": [0.1898, 0.6296, 0.2552, 0.651]}, {"w": "The", "b": [0.2614, 0.6296, 0.2942, 0.651]}, {"w": "field", "b": [0.3004, 0.6296, 0.3373, 0.651]}, {"w": "of", "b": [0.3435, 0.6296, 0.3603, 0.651]}, {"w": "Deep", "b": [0.3665, 0.6296, 0.4104, 0.651]}, {"w": "Learning", "b": [0.4166, 0.6296, 0.4916, 0.651]}, {"w": "studies", "b": [0.4978, 0.6296, 0.556, 0.651]}, {"w": "DNNs,", "b": [0.5622, 0.6296, 0.6203, 0.651]}, {"w": "and", "b": [0.6265, 0.6296, 0.658, 0.651]}, {"w": "more", "b": [0.6642, 0.6296, 0.7085, 0.651]}, {"w": "generally", "b": [0.7147, 0.6296, 0.7905, 0.651]}, {"w": "models", "b": [0.7967, 0.6296, 0.8571, 0.651]}, {"w": "containing", "b": [0.1428, 0.6486, 0.2325, 0.67]}, {"w": "deep", "b": [0.242, 0.6486, 0.2816, 0.67]}, {"w": "stacks", "b": [0.2911, 0.6486, 0.341, 0.67]}, {"w": "of", "b": [0.3505, 0.6486, 0.3673, 0.67]}, {"w": "computations.", "b": [0.3768, 0.6486, 0.4964, 0.67]}, {"w": "However,", "b": [0.5059, 0.6486, 0.5847, 0.67]}, {"w": "many", "b": [0.5942, 0.6486, 0.6409, 0.67]}, {"w": "people", "b": [0.6504, 0.6486, 0.7058, 0.67]}, {"w": "talk", "b": [0.7153, 0.6486, 0.7464, 0.67]}, {"w": "about", "b": [0.7559, 0.6486, 0.8037, 0.67]}, {"w": "Deep", "b": [0.8132, 0.6486, 0.8571, 0.67]}, {"w": "Learning", "b": [0.1429, 0.6677, 0.2179, 0.6891]}, {"w": "whenever", "b": [0.2227, 0.6677, 0.3034, 0.6891]}, {"w": "neural", "b": [0.3081, 0.6677, 0.3616, 0.6891]}, {"w": "networks", "b": [0.3663, 0.6677, 0.4435, 0.6891]}, {"w": "are", "b": [0.4482, 0.6677, 0.474, 0.6891]}, {"w": "involved", "b": [0.4787, 0.6677, 0.5502, 0.6891]}, {"w": "(even", "b": [0.555, 0.6677, 0.6009, 0.6891]}, {"w": "shallow", "b": [0.6057, 0.6677, 0.669, 0.6891]}, {"w": "ones).", "b": [0.6737, 0.6677, 0.7242, 0.6891]}]}, {"id": "b_7", "type": "paragraph", "text": "For many years researchers struggled to find a way to train MLPs, without success. But in 1986, David Rumelhart, Geoffrey Hinton and Ronald Williams published a groundbreaking paper9 introducing the backpropagation training algorithm, which is still used today. In short, it is simply Gradient Descent (introduced in Chapter 4)", "words": [{"w": "For", "b": [0.1429, 0.6958, 0.1718, 0.7172]}, {"w": "many", "b": [0.1788, 0.6958, 0.2255, 0.7172]}, {"w": "years", "b": [0.2324, 0.6958, 0.2753, 0.7172]}, {"w": "researchers", "b": [0.2823, 0.6958, 0.3764, 0.7172]}, {"w": "struggled", "b": [0.3833, 0.6958, 0.4608, 0.7172]}, {"w": "to", "b": [0.4677, 0.6958, 0.4847, 0.7172]}, {"w": "find", "b": [0.4916, 0.6958, 0.5257, 0.7172]}, {"w": "a", "b": [0.5327, 0.6958, 0.5418, 0.7172]}, {"w": "way", "b": [0.5488, 0.6958, 0.5814, 0.7172]}, {"w": "to", "b": [0.5883, 0.6958, 0.6053, 0.7172]}, {"w": "train", "b": [0.6122, 0.6958, 0.6524, 0.7172]}, {"w": "MLPs,", "b": [0.6594, 0.6958, 0.7127, 0.7172]}, {"w": "without", "b": [0.7196, 0.6958, 0.785, 0.7172]}, {"w": "success.", "b": [0.7919, 0.6958, 0.8572, 0.7172]}, {"w": "But", "b": [0.1429, 0.7148, 0.1725, 0.7362]}, {"w": "in", "b": [0.1804, 0.7148, 0.1974, 0.7362]}, {"w": "1986,", "b": [0.2053, 0.7148, 0.2501, 0.7362]}, {"w": "David", "b": [0.258, 0.7148, 0.3083, 0.7362]}, {"w": "Rumelhart,", "b": [0.3162, 0.7148, 0.41, 0.7362]}, {"w": "Geoffrey", "b": [0.4179, 0.7148, 0.4908, 0.7362]}, {"w": "Hinton", "b": [0.4987, 0.7148, 0.5596, 0.7362]}, {"w": "and", "b": [0.5675, 0.7148, 0.599, 0.7362]}, {"w": "Ronald", "b": [0.6069, 0.7148, 0.6673, 0.7362]}, {"w": "Williams", "b": [0.6752, 0.7148, 0.7502, 0.7362]}, {"w": "published", "b": [0.7581, 0.7148, 0.8401, 0.7362]}, {"w": "a", "b": [0.848, 0.7148, 0.8571, 0.7362]}, {"w": "groundbreaking", "b": [0.1429, 0.7339, 0.2778, 0.7553]}, {"w": "paper9", "b": [0.2838, 0.7339, 0.3367, 0.7553]}, {"w": "introducing", "b": [0.3426, 0.7339, 0.4415, 0.7553]}, {"w": "the", "b": [0.4475, 0.7339, 0.4738, 0.7553]}, {"w": "backpropagation", "b": [0.4798, 0.7337, 0.6148, 0.7553]}, {"w": "training", "b": [0.6208, 0.7339, 0.6877, 0.7553]}, {"w": "algorithm,", "b": [0.6937, 0.7339, 0.7811, 0.7553]}, {"w": "which", "b": [0.787, 0.7339, 0.8379, 0.7553]}, {"w": "is", "b": [0.8439, 0.7339, 0.8572, 0.7553]}, {"w": "still", "b": [0.1429, 0.7529, 0.173, 0.7743]}, {"w": "used", "b": [0.1811, 0.7529, 0.2197, 0.7743]}, {"w": "today.", "b": [0.2279, 0.7529, 0.2774, 0.7743]}, {"w": "In", "b": [0.2856, 0.7529, 0.3041, 0.7743]}, {"w": "short,", "b": [0.3122, 0.7529, 0.3605, 0.7743]}, {"w": "it", "b": [0.3686, 0.7529, 0.3806, 0.7743]}, {"w": "is", "b": [0.3887, 0.7529, 0.402, 0.7743]}, {"w": "simply", "b": [0.4101, 0.7529, 0.4658, 0.7743]}, {"w": "Gradient", "b": [0.4739, 0.7529, 0.5485, 0.7743]}, {"w": "Descent", "b": [0.5567, 0.7529, 0.6235, 0.7743]}, {"w": "(introduced", "b": [0.6317, 0.7529, 0.7309, 0.7743]}, {"w": "in", "b": [0.739, 0.7529, 0.756, 0.7743]}, {"w": "Chapter", "b": [0.7642, 0.7529, 0.8318, 0.7743]}, {"w": "4)", "b": [0.8399, 0.7529, 0.8571, 0.7743]}]}, {"id": "b_8", "type": "paragraph", "text": "286 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "286", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 313, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "10 This technique was actually independently invented several times by various researchers in different fields, starting with P. Werbos in 1974.", "words": [{"w": "10", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "This", "b": [0.1587, 0.8598, 0.1871, 0.8761]}, {"w": "technique", "b": [0.1907, 0.8598, 0.2537, 0.8761]}, {"w": "was", "b": [0.2573, 0.8598, 0.281, 0.8761]}, {"w": "actually", "b": [0.2846, 0.8598, 0.3338, 0.8761]}, {"w": "independently", "b": [0.3374, 0.8598, 0.4289, 0.8761]}, {"w": "invented", "b": [0.4325, 0.8598, 0.4875, 0.8761]}, {"w": "several", "b": [0.4911, 0.8598, 0.5346, 0.8761]}, {"w": "times", "b": [0.5382, 0.8598, 0.5729, 0.8761]}, {"w": "by", "b": [0.5765, 0.8598, 0.5918, 0.8761]}, {"w": "various", "b": [0.5954, 0.8598, 0.6423, 0.8761]}, {"w": "researchers", "b": [0.6459, 0.8598, 0.7176, 0.8761]}, {"w": "in", "b": [0.7212, 0.8598, 0.7341, 0.8761]}, {"w": "different", "b": [0.7377, 0.8598, 0.7923, 0.8761]}, {"w": "fields,", "b": [0.796, 0.8598, 0.8335, 0.8761]}, {"w": "starting", "b": [0.1587, 0.8749, 0.2075, 0.8912]}, {"w": "with", "b": [0.2111, 0.8749, 0.2395, 0.8912]}, {"w": "P.", "b": [0.2431, 0.8749, 0.2535, 0.8912]}, {"w": "Werbos", "b": [0.2571, 0.8749, 0.3056, 0.8912]}, {"w": "in", "b": [0.3092, 0.8749, 0.3221, 0.8912]}, {"w": "1974.", "b": [0.3257, 0.8749, 0.3598, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "using an efficient technique for computing the gradients automatically10: in just two passes through the network (one forward, one backward), the backpropagation algo‐ rithm is able to compute the gradient of the network’s error with regards to every sin‐ gle model parameter. In other words, it can find out how each connection weight and each bias term should be tweaked in order to reduce the error. Once it has these gra‐ dients, it just performs a regular Gradient Descent step, and the whole process is repeated until the network converges to the solution.", "words": [{"w": "using", "b": [0.1429, 0.0791, 0.1883, 0.1005]}, {"w": "an", "b": [0.1948, 0.0791, 0.2154, 0.1005]}, {"w": "efficient", "b": [0.2219, 0.0791, 0.2893, 0.1005]}, {"w": "technique", "b": [0.2958, 0.0791, 0.3785, 0.1005]}, {"w": "for", "b": [0.385, 0.0791, 0.4095, 0.1005]}, {"w": "computing", "b": [0.416, 0.0791, 0.5072, 0.1005]}, {"w": "the", "b": [0.5137, 0.0791, 0.5401, 0.1005]}, {"w": "gradients", "b": [0.5466, 0.0791, 0.6236, 0.1005]}, {"w": "automatically10:", "b": [0.6302, 0.0791, 0.7589, 0.1005]}, {"w": "in", "b": [0.7655, 0.0791, 0.7824, 0.1005]}, {"w": "just", "b": [0.789, 0.0791, 0.8194, 0.1005]}, {"w": "two", "b": [0.8259, 0.0791, 0.8571, 0.1005]}, {"w": "passes", "b": [0.1429, 0.0981, 0.1947, 0.1195]}, {"w": "through", "b": [0.2003, 0.0981, 0.268, 0.1195]}, {"w": "the", "b": [0.2736, 0.0981, 0.2999, 0.1195]}, {"w": "network", "b": [0.3055, 0.0981, 0.3751, 0.1195]}, {"w": "(one", "b": [0.3806, 0.0981, 0.4187, 0.1195]}, {"w": "forward,", "b": [0.4243, 0.0981, 0.4963, 0.1195]}, {"w": "one", "b": [0.5018, 0.0981, 0.5327, 0.1195]}, {"w": "backward),", "b": [0.5383, 0.0981, 0.6312, 0.1195]}, {"w": "the", "b": [0.6368, 0.0981, 0.6631, 0.1195]}, {"w": "backpropagation", "b": [0.6687, 0.0981, 0.8094, 0.1195]}, {"w": "algo‐", "b": [0.8149, 0.0981, 0.8571, 0.1195]}, {"w": "rithm", "b": [0.1429, 0.1172, 0.1907, 0.1386]}, {"w": "is", "b": [0.1957, 0.1172, 0.209, 0.1386]}, {"w": "able", "b": [0.214, 0.1172, 0.2478, 0.1386]}, {"w": "to", "b": [0.2528, 0.1172, 0.2698, 0.1386]}, {"w": "compute", "b": [0.2748, 0.1172, 0.3481, 0.1386]}, {"w": "the", "b": [0.3531, 0.1172, 0.3794, 0.1386]}, {"w": "gradient", "b": [0.3844, 0.1172, 0.4538, 0.1386]}, {"w": "of", "b": [0.4588, 0.1172, 0.4756, 0.1386]}, {"w": "the", "b": [0.4806, 0.1172, 0.507, 0.1386]}, {"w": "network’s", "b": [0.512, 0.1172, 0.591, 0.1386]}, {"w": "error", "b": [0.596, 0.1172, 0.6387, 0.1386]}, {"w": "with", "b": [0.6437, 0.1172, 0.681, 0.1386]}, {"w": "regards", "b": [0.686, 0.1172, 0.7479, 0.1386]}, {"w": "to", "b": [0.7529, 0.1172, 0.7699, 0.1386]}, {"w": "every", "b": [0.7749, 0.1172, 0.8201, 0.1386]}, {"w": "sin‐", "b": [0.8251, 0.1172, 0.8572, 0.1386]}, {"w": "gle", "b": [0.1429, 0.1362, 0.1667, 0.1576]}, {"w": "model", "b": [0.1718, 0.1362, 0.2246, 0.1576]}, {"w": "parameter.", "b": [0.2297, 0.1362, 0.3189, 0.1576]}, {"w": "In", "b": [0.3239, 0.1362, 0.3424, 0.1576]}, {"w": "other", "b": [0.3475, 0.1362, 0.3922, 0.1576]}, {"w": "words,", "b": [0.3972, 0.1362, 0.4533, 0.1576]}, {"w": "it", "b": [0.4583, 0.1362, 0.4703, 0.1576]}, {"w": "can", "b": [0.4753, 0.1362, 0.5047, 0.1576]}, {"w": "find", "b": [0.5097, 0.1362, 0.5439, 0.1576]}, {"w": "out", "b": [0.5489, 0.1362, 0.577, 0.1576]}, {"w": "how", "b": [0.582, 0.1362, 0.618, 0.1576]}, {"w": "each", "b": [0.6231, 0.1362, 0.661, 0.1576]}, {"w": "connection", "b": [0.6661, 0.1362, 0.7599, 0.1576]}, {"w": "weight", "b": [0.765, 0.1362, 0.8205, 0.1576]}, {"w": "and", "b": [0.8256, 0.1362, 0.8571, 0.1576]}, {"w": "each", "b": [0.1429, 0.1553, 0.1808, 0.1767]}, {"w": "bias", "b": [0.1863, 0.1553, 0.2193, 0.1767]}, {"w": "term", "b": [0.2248, 0.1553, 0.2648, 0.1767]}, {"w": "should", "b": [0.2703, 0.1553, 0.3271, 0.1767]}, {"w": "be", "b": [0.3326, 0.1553, 0.352, 0.1767]}, {"w": "tweaked", "b": [0.3575, 0.1553, 0.4264, 0.1767]}, {"w": "in", "b": [0.4319, 0.1553, 0.4489, 0.1767]}, {"w": "order", "b": [0.4544, 0.1553, 0.5003, 0.1767]}, {"w": "to", "b": [0.5059, 0.1553, 0.5228, 0.1767]}, {"w": "reduce", "b": [0.5284, 0.1553, 0.5847, 0.1767]}, {"w": "the", "b": [0.5902, 0.1553, 0.6165, 0.1767]}, {"w": "error.", "b": [0.6221, 0.1553, 0.6682, 0.1767]}, {"w": "Once", "b": [0.6737, 0.1553, 0.7183, 0.1767]}, {"w": "it", "b": [0.7238, 0.1553, 0.7358, 0.1767]}, {"w": "has", "b": [0.7413, 0.1553, 0.7692, 0.1767]}, {"w": "these", "b": [0.7747, 0.1553, 0.8176, 0.1767]}, {"w": "gra‐", "b": [0.8231, 0.1553, 0.8571, 0.1767]}, {"w": "dients,", "b": [0.1428, 0.1743, 0.198, 0.1957]}, {"w": "it", "b": [0.2064, 0.1743, 0.2183, 0.1957]}, {"w": "just", "b": [0.2267, 0.1743, 0.2571, 0.1957]}, {"w": "performs", "b": [0.2654, 0.1743, 0.3421, 0.1957]}, {"w": "a", "b": [0.3505, 0.1743, 0.3596, 0.1957]}, {"w": "regular", "b": [0.368, 0.1743, 0.4275, 0.1957]}, {"w": "Gradient", "b": [0.4359, 0.1743, 0.5105, 0.1957]}, {"w": "Descent", "b": [0.5188, 0.1743, 0.5856, 0.1957]}, {"w": "step,", "b": [0.594, 0.1743, 0.6319, 0.1957]}, {"w": "and", "b": [0.6403, 0.1743, 0.6718, 0.1957]}, {"w": "the", "b": [0.6801, 0.1743, 0.7065, 0.1957]}, {"w": "whole", "b": [0.7148, 0.1743, 0.765, 0.1957]}, {"w": "process", "b": [0.7733, 0.1743, 0.8356, 0.1957]}, {"w": "is", "b": [0.8439, 0.1743, 0.8571, 0.1957]}, {"w": "repeated", "b": [0.1429, 0.1933, 0.2142, 0.2148]}, {"w": "until", "b": [0.2189, 0.1933, 0.2582, 0.2148]}, {"w": "the", "b": [0.2629, 0.1933, 0.2892, 0.2148]}, {"w": "network", "b": [0.294, 0.1933, 0.3635, 0.2148]}, {"w": "converges", "b": [0.3683, 0.1933, 0.4511, 0.2148]}, {"w": "to", "b": [0.4558, 0.1933, 0.4728, 0.2148]}, {"w": "the", "b": [0.4775, 0.1933, 0.5039, 0.2148]}, {"w": "solution.", "b": [0.5086, 0.1933, 0.5819, 0.2148]}]}, {"id": "b_2", "type": "paragraph", "text": "Automatically computing gradients is called automatic differentia‐ tion, or autodiff. There are various autodiff techniques, with differ‐ ent pros and cons. The one used by backpropagation is called reverse-mode autodiff. It is fast and precise, and is well suited when the function to differentiate has many variables (e.g., connection weights) and few outputs (e.g., one loss). If you want to learn more about autodiff, check out ???.", "words": [{"w": "Automatically", "b": [0.2714, 0.2353, 0.3787, 0.2549]}, {"w": "computing", "b": [0.385, 0.2353, 0.4684, 0.2549]}, {"w": "gradients", "b": [0.4746, 0.2353, 0.5451, 0.2549]}, {"w": "is", "b": [0.5513, 0.2353, 0.5634, 0.2549]}, {"w": "called", "b": [0.5697, 0.2353, 0.6139, 0.2549]}, {"w": "automatic", "b": [0.6202, 0.2351, 0.6954, 0.2549]}, {"w": "differentia‐", "b": [0.7017, 0.2351, 0.7857, 0.2549]}, {"w": "tion,", "b": [0.2714, 0.2525, 0.3059, 0.2723]}, {"w": "or", "b": [0.3109, 0.2527, 0.3277, 0.2723]}, {"w": "autodiff.", "b": [0.3327, 0.2525, 0.3963, 0.2723]}, {"w": "There", "b": [0.4013, 0.2527, 0.4465, 0.2723]}, {"w": "are", "b": [0.4515, 0.2527, 0.475, 0.2723]}, {"w": "various", "b": [0.48, 0.2527, 0.5362, 0.2723]}, {"w": "autodiff", "b": [0.5412, 0.2527, 0.6013, 0.2723]}, {"w": "techniques,", "b": [0.6063, 0.2527, 0.6932, 0.2723]}, {"w": "with", "b": [0.6982, 0.2527, 0.7323, 0.2723]}, {"w": "differ‐", "b": [0.7373, 0.2527, 0.7857, 0.2723]}, {"w": "ent", "b": [0.2714, 0.2701, 0.2954, 0.2897]}, {"w": "pros", "b": [0.3045, 0.2701, 0.3383, 0.2897]}, {"w": "and", "b": [0.3474, 0.2701, 0.3762, 0.2897]}, {"w": "cons.", "b": [0.3854, 0.2701, 0.4249, 0.2897]}, {"w": "The", "b": [0.434, 0.2701, 0.4641, 0.2897]}, {"w": "one", "b": [0.4732, 0.2701, 0.5014, 0.2897]}, {"w": "used", "b": [0.5106, 0.2701, 0.5458, 0.2897]}, {"w": "by", "b": [0.555, 0.2701, 0.5734, 0.2897]}, {"w": "backpropagation", "b": [0.5825, 0.2701, 0.7111, 0.2897]}, {"w": "is", "b": [0.7203, 0.2701, 0.7324, 0.2897]}, {"w": "called", "b": [0.7415, 0.2701, 0.7857, 0.2897]}, {"w": "reverse-mode", "b": [0.2714, 0.2873, 0.3701, 0.3071]}, {"w": "autodiff.", "b": [0.3751, 0.2873, 0.4387, 0.3071]}, {"w": "It", "b": [0.4438, 0.2875, 0.4553, 0.3071]}, {"w": "is", "b": [0.4604, 0.2875, 0.4725, 0.3071]}, {"w": "fast", "b": [0.4775, 0.2875, 0.5043, 0.3071]}, {"w": "and", "b": [0.5093, 0.2875, 0.5382, 0.3071]}, {"w": "precise,", "b": [0.5432, 0.2875, 0.6009, 0.3071]}, {"w": "and", "b": [0.606, 0.2875, 0.6348, 0.3071]}, {"w": "is", "b": [0.6398, 0.2875, 0.6519, 0.3071]}, {"w": "well", "b": [0.657, 0.2875, 0.6877, 0.3071]}, {"w": "suited", "b": [0.6928, 0.2875, 0.739, 0.3071]}, {"w": "when", "b": [0.744, 0.2875, 0.7857, 0.3071]}, {"w": "the", "b": [0.2714, 0.305, 0.2955, 0.3245]}, {"w": "function", "b": [0.3029, 0.305, 0.3681, 0.3245]}, {"w": "to", "b": [0.3755, 0.305, 0.391, 0.3245]}, {"w": "differentiate", "b": [0.3984, 0.305, 0.491, 0.3245]}, {"w": "has", "b": [0.4983, 0.305, 0.5238, 0.3245]}, {"w": "many", "b": [0.5312, 0.305, 0.5739, 0.3245]}, {"w": "variables", "b": [0.5813, 0.305, 0.6486, 0.3245]}, {"w": "(e.g.,", "b": [0.6559, 0.305, 0.6925, 0.3245]}, {"w": "connection", "b": [0.6999, 0.305, 0.7857, 0.3245]}, {"w": "weights)", "b": [0.2714, 0.3224, 0.3358, 0.3419]}, {"w": "and", "b": [0.3407, 0.3224, 0.3695, 0.3419]}, {"w": "few", "b": [0.3744, 0.3224, 0.4012, 0.3419]}, {"w": "outputs", "b": [0.4061, 0.3224, 0.4646, 0.3419]}, {"w": "(e.g.,", "b": [0.4695, 0.3224, 0.5061, 0.3419]}, {"w": "one", "b": [0.511, 0.3224, 0.5393, 0.3419]}, {"w": "loss).", "b": [0.5442, 0.3224, 0.5836, 0.3419]}, {"w": "If", "b": [0.5885, 0.3224, 0.6006, 0.3419]}, {"w": "you", "b": [0.6055, 0.3224, 0.6341, 0.3419]}, {"w": "want", "b": [0.639, 0.3224, 0.6763, 0.3419]}, {"w": "to", "b": [0.6812, 0.3224, 0.6967, 0.3419]}, {"w": "learn", "b": [0.7016, 0.3224, 0.7403, 0.3419]}, {"w": "more", "b": [0.7452, 0.3224, 0.7857, 0.3419]}, {"w": "about", "b": [0.2714, 0.3398, 0.3151, 0.3594]}, {"w": "autodiff,", "b": [0.3194, 0.3398, 0.3838, 0.3594]}, {"w": "check", "b": [0.3882, 0.3398, 0.432, 0.3594]}, {"w": "out", "b": [0.4363, 0.3398, 0.4619, 0.3594]}, {"w": "???.", "b": [0.4663, 0.3398, 0.4923, 0.3594]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s run through this algorithm in a bit more detail:", "words": [{"w": "Let’s", "b": [0.1429, 0.3797, 0.179, 0.4011]}, {"w": "run", "b": [0.1837, 0.3797, 0.2139, 0.4011]}, {"w": "through", "b": [0.2187, 0.3797, 0.2864, 0.4011]}, {"w": "this", "b": [0.2912, 0.3797, 0.3219, 0.4011]}, {"w": "algorithm", "b": [0.3266, 0.3797, 0.4092, 0.4011]}, {"w": "in", "b": [0.414, 0.3797, 0.431, 0.4011]}, {"w": "a", "b": [0.4357, 0.3797, 0.4448, 0.4011]}, {"w": "bit", "b": [0.4496, 0.3797, 0.4721, 0.4011]}, {"w": "more", "b": [0.4768, 0.3797, 0.5211, 0.4011]}, {"w": "detail:", "b": [0.5258, 0.3797, 0.5768, 0.4011]}]}, {"id": "b_4", "type": "paragraph", "text": "• It handles one mini-batch at a time (for example containing 32 instances each), and it goes through the full training set multiple times. Each pass is called an epoch, as we saw in Chapter 4.", "words": [{"w": "•", "b": [0.16, 0.4138, 0.1682, 0.4352]}, {"w": "It", "b": [0.1786, 0.4138, 0.1912, 0.4352]}, {"w": "handles", "b": [0.1977, 0.4138, 0.2622, 0.4352]}, {"w": "one", "b": [0.2687, 0.4138, 0.2996, 0.4352]}, {"w": "mini-batch", "b": [0.3061, 0.4138, 0.3987, 0.4352]}, {"w": "at", "b": [0.4053, 0.4138, 0.4204, 0.4352]}, {"w": "a", "b": [0.4269, 0.4138, 0.436, 0.4352]}, {"w": "time", "b": [0.4425, 0.4138, 0.4804, 0.4352]}, {"w": "(for", "b": [0.4869, 0.4138, 0.5186, 0.4352]}, {"w": "example", "b": [0.5252, 0.4138, 0.5947, 0.4352]}, {"w": "containing", "b": [0.6012, 0.4138, 0.6909, 0.4352]}, {"w": "32", "b": [0.6974, 0.4138, 0.7174, 0.4352]}, {"w": "instances", "b": [0.7239, 0.4138, 0.8007, 0.4352]}, {"w": "each),", "b": [0.8072, 0.4138, 0.8571, 0.4352]}, {"w": "and", "b": [0.1786, 0.4329, 0.2101, 0.4543]}, {"w": "it", "b": [0.2178, 0.4329, 0.2298, 0.4543]}, {"w": "goes", "b": [0.2375, 0.4329, 0.2743, 0.4543]}, {"w": "through", "b": [0.2821, 0.4329, 0.3498, 0.4543]}, {"w": "the", "b": [0.3575, 0.4329, 0.3839, 0.4543]}, {"w": "full", "b": [0.3916, 0.4329, 0.4193, 0.4543]}, {"w": "training", "b": [0.4271, 0.4329, 0.494, 0.4543]}, {"w": "set", "b": [0.5017, 0.4329, 0.5246, 0.4543]}, {"w": "multiple", "b": [0.5323, 0.4329, 0.6022, 0.4543]}, {"w": "times.", "b": [0.61, 0.4329, 0.6602, 0.4543]}, {"w": "Each", "b": [0.6679, 0.4329, 0.7088, 0.4543]}, {"w": "pass", "b": [0.7165, 0.4329, 0.7519, 0.4543]}, {"w": "is", "b": [0.7596, 0.4329, 0.7728, 0.4543]}, {"w": "called", "b": [0.7805, 0.4329, 0.8289, 0.4543]}, {"w": "an", "b": [0.8366, 0.4329, 0.8571, 0.4543]}, {"w": "epoch,", "b": [0.1786, 0.4517, 0.2297, 0.4733]}, {"w": "as", "b": [0.2344, 0.4519, 0.2512, 0.4733]}, {"w": "we", "b": [0.2559, 0.4519, 0.279, 0.4733]}, {"w": "saw", "b": [0.2838, 0.4519, 0.3145, 0.4733]}, {"w": "in", "b": [0.3192, 0.4519, 0.3362, 0.4733]}, {"w": "Chapter", "b": [0.3409, 0.4519, 0.4085, 0.4733]}, {"w": "4.", "b": [0.4132, 0.4519, 0.428, 0.4733]}]}, {"id": "b_5", "type": "paragraph", "text": "• Each mini-batch is passed to the network’s input layer, which just sends it to the first hidden layer. The algorithm then computes the output of all the neurons in this layer (for every instance in the mini-batch). The result is passed on to the next layer, its output is computed and passed to the next layer, and so on until we get the output of the last layer, the output layer. This is the forward pass: it is exactly like making predictions, except all intermediate results are preserved since they are needed for the backward pass.", "words": [{"w": "•", "b": [0.16, 0.477, 0.1682, 0.4984]}, {"w": "Each", "b": [0.1786, 0.477, 0.2195, 0.4984]}, {"w": "mini-batch", "b": [0.2254, 0.477, 0.318, 0.4984]}, {"w": "is", "b": [0.3239, 0.477, 0.3372, 0.4984]}, {"w": "passed", "b": [0.3431, 0.477, 0.3983, 0.4984]}, {"w": "to", "b": [0.4042, 0.477, 0.4212, 0.4984]}, {"w": "the", "b": [0.4271, 0.477, 0.4534, 0.4984]}, {"w": "network’s", "b": [0.4593, 0.477, 0.5383, 0.4984]}, {"w": "input", "b": [0.5442, 0.477, 0.5891, 0.4984]}, {"w": "layer,", "b": [0.595, 0.477, 0.6386, 0.4984]}, {"w": "which", "b": [0.6445, 0.477, 0.6955, 0.4984]}, {"w": "just", "b": [0.7014, 0.477, 0.7318, 0.4984]}, {"w": "sends", "b": [0.7377, 0.477, 0.7842, 0.4984]}, {"w": "it", "b": [0.7901, 0.477, 0.802, 0.4984]}, {"w": "to", "b": [0.8079, 0.477, 0.8249, 0.4984]}, {"w": "the", "b": [0.8308, 0.477, 0.8571, 0.4984]}, {"w": "first", "b": [0.1786, 0.4961, 0.2121, 0.5175]}, {"w": "hidden", "b": [0.218, 0.4961, 0.2769, 0.5175]}, {"w": "layer.", "b": [0.2829, 0.4961, 0.3265, 0.5175]}, {"w": "The", "b": [0.3324, 0.4961, 0.3653, 0.5175]}, {"w": "algorithm", "b": [0.3712, 0.4961, 0.4539, 0.5175]}, {"w": "then", "b": [0.4598, 0.4961, 0.4975, 0.5175]}, {"w": "computes", "b": [0.5035, 0.4961, 0.5844, 0.5175]}, {"w": "the", "b": [0.5903, 0.4961, 0.6167, 0.5175]}, {"w": "output", "b": [0.6226, 0.4961, 0.679, 0.5175]}, {"w": "of", "b": [0.6849, 0.4961, 0.7017, 0.5175]}, {"w": "all", "b": [0.7076, 0.4961, 0.7273, 0.5175]}, {"w": "the", "b": [0.7333, 0.4961, 0.7596, 0.5175]}, {"w": "neurons", "b": [0.7655, 0.4961, 0.8342, 0.5175]}, {"w": "in", "b": [0.8402, 0.4961, 0.8571, 0.5175]}, {"w": "this", "b": [0.1786, 0.5151, 0.2093, 0.5365]}, {"w": "layer", "b": [0.2164, 0.5151, 0.2566, 0.5365]}, {"w": "(for", "b": [0.2638, 0.5151, 0.2955, 0.5365]}, {"w": "every", "b": [0.3026, 0.5151, 0.3479, 0.5365]}, {"w": "instance", "b": [0.355, 0.5151, 0.4242, 0.5365]}, {"w": "in", "b": [0.4314, 0.5151, 0.4483, 0.5365]}, {"w": "the", "b": [0.4555, 0.5151, 0.4818, 0.5365]}, {"w": "mini-batch).", "b": [0.489, 0.5151, 0.5936, 0.5365]}, {"w": "The", "b": [0.6007, 0.5151, 0.6336, 0.5365]}, {"w": "result", "b": [0.6407, 0.5151, 0.6876, 0.5365]}, {"w": "is", "b": [0.6948, 0.5151, 0.708, 0.5365]}, {"w": "passed", "b": [0.7152, 0.5151, 0.7704, 0.5365]}, {"w": "on", "b": [0.7775, 0.5151, 0.7995, 0.5365]}, {"w": "to", "b": [0.8067, 0.5151, 0.8237, 0.5365]}, {"w": "the", "b": [0.8308, 0.5151, 0.8571, 0.5365]}, {"w": "next", "b": [0.1786, 0.5341, 0.215, 0.5556]}, {"w": "layer,", "b": [0.2201, 0.5341, 0.2637, 0.5556]}, {"w": "its", "b": [0.2687, 0.5341, 0.2883, 0.5556]}, {"w": "output", "b": [0.2933, 0.5341, 0.3497, 0.5556]}, {"w": "is", "b": [0.3548, 0.5341, 0.368, 0.5556]}, {"w": "computed", "b": [0.373, 0.5341, 0.4573, 0.5556]}, {"w": "and", "b": [0.4624, 0.5341, 0.4939, 0.5556]}, {"w": "passed", "b": [0.499, 0.5341, 0.5542, 0.5556]}, {"w": "to", "b": [0.5592, 0.5341, 0.5762, 0.5556]}, {"w": "the", "b": [0.5812, 0.5341, 0.6076, 0.5556]}, {"w": "next", "b": [0.6126, 0.5341, 0.649, 0.5556]}, {"w": "layer,", "b": [0.6541, 0.5341, 0.6977, 0.5556]}, {"w": "and", "b": [0.7027, 0.5341, 0.7343, 0.5556]}, {"w": "so", "b": [0.7393, 0.5341, 0.7576, 0.5556]}, {"w": "on", "b": [0.7626, 0.5341, 0.7847, 0.5556]}, {"w": "until", "b": [0.7897, 0.5341, 0.829, 0.5556]}, {"w": "we", "b": [0.834, 0.5341, 0.8571, 0.5556]}, {"w": "get", "b": [0.1786, 0.5532, 0.2035, 0.5746]}, {"w": "the", "b": [0.2113, 0.5532, 0.2376, 0.5746]}, {"w": "output", "b": [0.2454, 0.5532, 0.3017, 0.5746]}, {"w": "of", "b": [0.3095, 0.5532, 0.3263, 0.5746]}, {"w": "the", "b": [0.334, 0.5532, 0.3604, 0.5746]}, {"w": "last", "b": [0.3681, 0.5532, 0.3965, 0.5746]}, {"w": "layer,", "b": [0.4043, 0.5532, 0.4479, 0.5746]}, {"w": "the", "b": [0.4556, 0.5532, 0.482, 0.5746]}, {"w": "output", "b": [0.4897, 0.5532, 0.5461, 0.5746]}, {"w": "layer.", "b": [0.5539, 0.5532, 0.5975, 0.5746]}, {"w": "This", "b": [0.6052, 0.5532, 0.6424, 0.5746]}, {"w": "is", "b": [0.6502, 0.5532, 0.6634, 0.5746]}, {"w": "the", "b": [0.6712, 0.5532, 0.6975, 0.5746]}, {"w": "forward", "b": [0.7052, 0.553, 0.7699, 0.5746]}, {"w": "pass:", "b": [0.7777, 0.553, 0.8165, 0.5746]}, {"w": "it", "b": [0.8242, 0.5532, 0.8362, 0.5746]}, {"w": "is", "b": [0.8439, 0.5532, 0.8572, 0.5746]}, {"w": "exactly", "b": [0.1786, 0.5722, 0.2364, 0.5937]}, {"w": "like", "b": [0.246, 0.5722, 0.2761, 0.5937]}, {"w": "making", "b": [0.2857, 0.5722, 0.349, 0.5937]}, {"w": "predictions,", "b": [0.3586, 0.5722, 0.4579, 0.5937]}, {"w": "except", "b": [0.4675, 0.5722, 0.5211, 0.5937]}, {"w": "all", "b": [0.5308, 0.5722, 0.5505, 0.5937]}, {"w": "intermediate", "b": [0.5601, 0.5722, 0.6661, 0.5937]}, {"w": "results", "b": [0.6757, 0.5722, 0.7303, 0.5937]}, {"w": "are", "b": [0.7399, 0.5722, 0.7657, 0.5937]}, {"w": "preserved", "b": [0.7753, 0.5722, 0.8571, 0.5937]}, {"w": "since", "b": [0.1786, 0.5913, 0.2209, 0.6127]}, {"w": "they", "b": [0.2256, 0.5913, 0.2615, 0.6127]}, {"w": "are", "b": [0.2662, 0.5913, 0.292, 0.6127]}, {"w": "needed", "b": [0.2967, 0.5913, 0.3566, 0.6127]}, {"w": "for", "b": [0.3614, 0.5913, 0.3859, 0.6127]}, {"w": "the", "b": [0.3906, 0.5913, 0.417, 0.6127]}, {"w": "backward", "b": [0.4217, 0.5913, 0.5027, 0.6127]}, {"w": "pass.", "b": [0.5074, 0.5913, 0.5475, 0.6127]}]}, {"id": "b_6", "type": "paragraph", "text": "• Next, the algorithm measures the network’s output error (i.e., it uses a loss func‐ tion that compares the desired output and the actual output of the network, and returns some measure of the error).", "words": [{"w": "•", "b": [0.16, 0.6164, 0.1681, 0.6378]}, {"w": "Next,", "b": [0.1786, 0.6164, 0.2233, 0.6378]}, {"w": "the", "b": [0.229, 0.6164, 0.2554, 0.6378]}, {"w": "algorithm", "b": [0.2611, 0.6164, 0.3437, 0.6378]}, {"w": "measures", "b": [0.3494, 0.6164, 0.4274, 0.6378]}, {"w": "the", "b": [0.4331, 0.6164, 0.4595, 0.6378]}, {"w": "network’s", "b": [0.4652, 0.6164, 0.5442, 0.6378]}, {"w": "output", "b": [0.5499, 0.6164, 0.6063, 0.6378]}, {"w": "error", "b": [0.612, 0.6164, 0.6547, 0.6378]}, {"w": "(i.e.,", "b": [0.6604, 0.6164, 0.6963, 0.6378]}, {"w": "it", "b": [0.702, 0.6164, 0.7139, 0.6378]}, {"w": "uses", "b": [0.7196, 0.6164, 0.7548, 0.6378]}, {"w": "a", "b": [0.7605, 0.6164, 0.7697, 0.6378]}, {"w": "loss", "b": [0.7754, 0.6164, 0.8066, 0.6378]}, {"w": "func‐", "b": [0.8123, 0.6164, 0.8571, 0.6378]}, {"w": "tion", "b": [0.1786, 0.6354, 0.2125, 0.6568]}, {"w": "that", "b": [0.2183, 0.6354, 0.2509, 0.6568]}, {"w": "compares", "b": [0.2567, 0.6354, 0.3371, 0.6568]}, {"w": "the", "b": [0.3429, 0.6354, 0.3692, 0.6568]}, {"w": "desired", "b": [0.375, 0.6354, 0.4357, 0.6568]}, {"w": "output", "b": [0.4414, 0.6354, 0.4978, 0.6568]}, {"w": "and", "b": [0.5036, 0.6354, 0.5352, 0.6568]}, {"w": "the", "b": [0.5409, 0.6354, 0.5673, 0.6568]}, {"w": "actual", "b": [0.5731, 0.6354, 0.6229, 0.6568]}, {"w": "output", "b": [0.6286, 0.6354, 0.685, 0.6568]}, {"w": "of", "b": [0.6908, 0.6354, 0.7076, 0.6568]}, {"w": "the", "b": [0.7134, 0.6354, 0.7397, 0.6568]}, {"w": "network,", "b": [0.7455, 0.6354, 0.8198, 0.6568]}, {"w": "and", "b": [0.8256, 0.6354, 0.8571, 0.6568]}, {"w": "returns", "b": [0.1786, 0.6545, 0.2393, 0.6759]}, {"w": "some", "b": [0.2441, 0.6545, 0.2883, 0.6759]}, {"w": "measure", "b": [0.293, 0.6545, 0.3633, 0.6759]}, {"w": "of", "b": [0.3681, 0.6545, 0.3849, 0.6759]}, {"w": "the", "b": [0.3896, 0.6545, 0.4159, 0.6759]}, {"w": "error).", "b": [0.4206, 0.6545, 0.4753, 0.6759]}]}, {"id": "b_7", "type": "paragraph", "text": "• Then it computes how much each output connection contributed to the error. This is done analytically by simply applying the chain rule (perhaps the most fun‐ damental rule in calculus), which makes this step fast and precise.", "words": [{"w": "•", "b": [0.16, 0.6796, 0.1682, 0.701]}, {"w": "Then", "b": [0.1786, 0.6796, 0.2228, 0.701]}, {"w": "it", "b": [0.2303, 0.6796, 0.2422, 0.701]}, {"w": "computes", "b": [0.2497, 0.6796, 0.3306, 0.701]}, {"w": "how", "b": [0.3381, 0.6796, 0.3741, 0.701]}, {"w": "much", "b": [0.3816, 0.6796, 0.4293, 0.701]}, {"w": "each", "b": [0.4367, 0.6796, 0.4747, 0.701]}, {"w": "output", "b": [0.4822, 0.6796, 0.5385, 0.701]}, {"w": "connection", "b": [0.546, 0.6796, 0.6399, 0.701]}, {"w": "contributed", "b": [0.6473, 0.6796, 0.7453, 0.701]}, {"w": "to", "b": [0.7528, 0.6796, 0.7697, 0.701]}, {"w": "the", "b": [0.7772, 0.6796, 0.8036, 0.701]}, {"w": "error.", "b": [0.811, 0.6796, 0.8571, 0.701]}, {"w": "This", "b": [0.1786, 0.6986, 0.2158, 0.72]}, {"w": "is", "b": [0.2207, 0.6986, 0.2339, 0.72]}, {"w": "done", "b": [0.2388, 0.6986, 0.2806, 0.72]}, {"w": "analytically", "b": [0.2855, 0.6986, 0.38, 0.72]}, {"w": "by", "b": [0.3849, 0.6986, 0.4051, 0.72]}, {"w": "simply", "b": [0.4099, 0.6986, 0.4656, 0.72]}, {"w": "applying", "b": [0.4705, 0.6986, 0.5426, 0.72]}, {"w": "the", "b": [0.5475, 0.6986, 0.5738, 0.72]}, {"w": "chain", "b": [0.5787, 0.6984, 0.6233, 0.72]}, {"w": "rule", "b": [0.628, 0.6984, 0.6603, 0.72]}, {"w": "(perhaps", "b": [0.6653, 0.6986, 0.7385, 0.72]}, {"w": "the", "b": [0.7432, 0.6986, 0.7695, 0.72]}, {"w": "most", "b": [0.7742, 0.6986, 0.8159, 0.72]}, {"w": "fun‐", "b": [0.8207, 0.6986, 0.8567, 0.72]}, {"w": "damental", "b": [0.1786, 0.7177, 0.2564, 0.7391]}, {"w": "rule", "b": [0.2611, 0.7177, 0.2941, 0.7391]}, {"w": "in", "b": [0.2988, 0.7177, 0.3158, 0.7391]}, {"w": "calculus),", "b": [0.3205, 0.7177, 0.3995, 0.7391]}, {"w": "which", "b": [0.4043, 0.7177, 0.4552, 0.7391]}, {"w": "makes", "b": [0.4599, 0.7177, 0.513, 0.7391]}, {"w": "this", "b": [0.5177, 0.7177, 0.5484, 0.7391]}, {"w": "step", "b": [0.5531, 0.7177, 0.5869, 0.7391]}, {"w": "fast", "b": [0.5916, 0.7177, 0.6209, 0.7391]}, {"w": "and", "b": [0.6257, 0.7177, 0.6572, 0.7391]}, {"w": "precise.", "b": [0.6619, 0.7177, 0.7251, 0.7391]}]}, {"id": "b_8", "type": "paragraph", "text": "• The algorithm then measures how much of these error contributions came from each connection in the layer below, again using the chain rule—and so on until the algorithm reaches the input layer. As we explained earlier, this reverse pass efficiently measures the error gradient across all the connection weights in the", "words": [{"w": "•", "b": [0.16, 0.7428, 0.1681, 0.7642]}, {"w": "The", "b": [0.1786, 0.7428, 0.2114, 0.7642]}, {"w": "algorithm", "b": [0.2171, 0.7428, 0.2997, 0.7642]}, {"w": "then", "b": [0.3054, 0.7428, 0.3432, 0.7642]}, {"w": "measures", "b": [0.3488, 0.7428, 0.4268, 0.7642]}, {"w": "how", "b": [0.4325, 0.7428, 0.4685, 0.7642]}, {"w": "much", "b": [0.4742, 0.7428, 0.5219, 0.7642]}, {"w": "of", "b": [0.5276, 0.7428, 0.5444, 0.7642]}, {"w": "these", "b": [0.5501, 0.7428, 0.5929, 0.7642]}, {"w": "error", "b": [0.5986, 0.7428, 0.6413, 0.7642]}, {"w": "contributions", "b": [0.6469, 0.7428, 0.7603, 0.7642]}, {"w": "came", "b": [0.766, 0.7428, 0.8099, 0.7642]}, {"w": "from", "b": [0.8156, 0.7428, 0.8571, 0.7642]}, {"w": "each", "b": [0.1786, 0.7618, 0.2165, 0.7832]}, {"w": "connection", "b": [0.223, 0.7618, 0.3169, 0.7832]}, {"w": "in", "b": [0.3233, 0.7618, 0.3403, 0.7832]}, {"w": "the", "b": [0.3468, 0.7618, 0.3731, 0.7832]}, {"w": "layer", "b": [0.3796, 0.7618, 0.4198, 0.7832]}, {"w": "below,", "b": [0.4263, 0.7618, 0.4791, 0.7832]}, {"w": "again", "b": [0.4856, 0.7618, 0.5307, 0.7832]}, {"w": "using", "b": [0.5371, 0.7618, 0.5826, 0.7832]}, {"w": "the", "b": [0.5891, 0.7618, 0.6154, 0.7832]}, {"w": "chain", "b": [0.6219, 0.7618, 0.668, 0.7832]}, {"w": "rule—and", "b": [0.6744, 0.7618, 0.7581, 0.7832]}, {"w": "so", "b": [0.7646, 0.7618, 0.7829, 0.7832]}, {"w": "on", "b": [0.7894, 0.7618, 0.8114, 0.7832]}, {"w": "until", "b": [0.8179, 0.7618, 0.8571, 0.7832]}, {"w": "the", "b": [0.1786, 0.7809, 0.2049, 0.8023]}, {"w": "algorithm", "b": [0.2119, 0.7809, 0.2946, 0.8023]}, {"w": "reaches", "b": [0.3016, 0.7809, 0.3638, 0.8023]}, {"w": "the", "b": [0.3708, 0.7809, 0.3972, 0.8023]}, {"w": "input", "b": [0.4042, 0.7809, 0.4491, 0.8023]}, {"w": "layer.", "b": [0.4562, 0.7809, 0.4998, 0.8023]}, {"w": "As", "b": [0.5069, 0.7809, 0.5289, 0.8023]}, {"w": "we", "b": [0.5359, 0.7809, 0.5591, 0.8023]}, {"w": "explained", "b": [0.5661, 0.7809, 0.647, 0.8023]}, {"w": "earlier,", "b": [0.654, 0.7809, 0.7106, 0.8023]}, {"w": "this", "b": [0.7177, 0.7809, 0.7484, 0.8023]}, {"w": "reverse", "b": [0.7554, 0.7809, 0.8147, 0.8023]}, {"w": "pass", "b": [0.8218, 0.7809, 0.8571, 0.8023]}, {"w": "efficiently", "b": [0.1786, 0.7999, 0.2608, 0.8213]}, {"w": "measures", "b": [0.2682, 0.7999, 0.3462, 0.8213]}, {"w": "the", "b": [0.3537, 0.7999, 0.38, 0.8213]}, {"w": "error", "b": [0.3875, 0.7999, 0.4301, 0.8213]}, {"w": "gradient", "b": [0.4376, 0.7999, 0.507, 0.8213]}, {"w": "across", "b": [0.5145, 0.7999, 0.5661, 0.8213]}, {"w": "all", "b": [0.5735, 0.7999, 0.5932, 0.8213]}, {"w": "the", "b": [0.6006, 0.7999, 0.627, 0.8213]}, {"w": "connection", "b": [0.6344, 0.7999, 0.7283, 0.8213]}, {"w": "weights", "b": [0.7357, 0.7999, 0.7989, 0.8213]}, {"w": "in", "b": [0.8064, 0.7999, 0.8234, 0.8213]}, {"w": "the", "b": [0.8308, 0.7999, 0.8571, 0.8213]}]}, {"id": "b_9", "type": "paragraph", "text": "From Biological to Artificial Neurons | 287", "words": [{"w": "From", "b": [0.585, 0.9225, 0.6155, 0.9388]}, {"w": "Biological", "b": [0.6183, 0.9225, 0.6761, 0.9388]}, {"w": "to", "b": [0.6789, 0.9225, 0.6914, 0.9388]}, {"w": "Artificial", "b": [0.6942, 0.9225, 0.7441, 0.9388]}, {"w": "Neurons", "b": [0.7469, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "287", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 314, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "network by propagating the error gradient backward through the network (hence the name of the algorithm).", "words": [{"w": "network", "b": [0.1786, 0.0791, 0.2481, 0.1005]}, {"w": "by", "b": [0.253, 0.0791, 0.2731, 0.1005]}, {"w": "propagating", "b": [0.278, 0.0791, 0.3789, 0.1005]}, {"w": "the", "b": [0.3838, 0.0791, 0.4101, 0.1005]}, {"w": "error", "b": [0.415, 0.0791, 0.4576, 0.1005]}, {"w": "gradient", "b": [0.4625, 0.0791, 0.5319, 0.1005]}, {"w": "backward", "b": [0.5368, 0.0791, 0.6178, 0.1005]}, {"w": "through", "b": [0.6226, 0.0791, 0.6904, 0.1005]}, {"w": "the", "b": [0.6953, 0.0791, 0.7216, 0.1005]}, {"w": "network", "b": [0.7265, 0.0791, 0.796, 0.1005]}, {"w": "(hence", "b": [0.8009, 0.0791, 0.8571, 0.1005]}, {"w": "the", "b": [0.1786, 0.0981, 0.2049, 0.1195]}, {"w": "name", "b": [0.2096, 0.0981, 0.2561, 0.1195]}, {"w": "of", "b": [0.2608, 0.0981, 0.2776, 0.1195]}, {"w": "the", "b": [0.2823, 0.0981, 0.3087, 0.1195]}, {"w": "algorithm).", "b": [0.3134, 0.0981, 0.408, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "• Finally, the algorithm performs a Gradient Descent step to tweak all the connec‐ tion weights in the network, using the error gradients it just computed.", "words": [{"w": "•", "b": [0.16, 0.1232, 0.1682, 0.1446]}, {"w": "Finally,", "b": [0.1786, 0.1232, 0.239, 0.1446]}, {"w": "the", "b": [0.2448, 0.1232, 0.2711, 0.1446]}, {"w": "algorithm", "b": [0.2768, 0.1232, 0.3595, 0.1446]}, {"w": "performs", "b": [0.3652, 0.1232, 0.442, 0.1446]}, {"w": "a", "b": [0.4477, 0.1232, 0.4568, 0.1446]}, {"w": "Gradient", "b": [0.4626, 0.1232, 0.5371, 0.1446]}, {"w": "Descent", "b": [0.5429, 0.1232, 0.6097, 0.1446]}, {"w": "step", "b": [0.6154, 0.1232, 0.6492, 0.1446]}, {"w": "to", "b": [0.6549, 0.1232, 0.6719, 0.1446]}, {"w": "tweak", "b": [0.6776, 0.1232, 0.7266, 0.1446]}, {"w": "all", "b": [0.7323, 0.1232, 0.752, 0.1446]}, {"w": "the", "b": [0.7578, 0.1232, 0.7841, 0.1446]}, {"w": "connec‐", "b": [0.7898, 0.1232, 0.8571, 0.1446]}, {"w": "tion", "b": [0.1786, 0.1423, 0.2125, 0.1637]}, {"w": "weights", "b": [0.2173, 0.1423, 0.2804, 0.1637]}, {"w": "in", "b": [0.2852, 0.1423, 0.3022, 0.1637]}, {"w": "the", "b": [0.3069, 0.1423, 0.3332, 0.1637]}, {"w": "network,", "b": [0.3379, 0.1423, 0.4123, 0.1637]}, {"w": "using", "b": [0.417, 0.1423, 0.4624, 0.1637]}, {"w": "the", "b": [0.4672, 0.1423, 0.4935, 0.1637]}, {"w": "error", "b": [0.4982, 0.1423, 0.5409, 0.1637]}, {"w": "gradients", "b": [0.5456, 0.1423, 0.6227, 0.1637]}, {"w": "it", "b": [0.6274, 0.1423, 0.6393, 0.1637]}, {"w": "just", "b": [0.6441, 0.1423, 0.6745, 0.1637]}, {"w": "computed.", "b": [0.6792, 0.1423, 0.7682, 0.1637]}]}, {"id": "b_2", "type": "paragraph", "text": "This algorithm is so important, it’s worth summarizing it again: for each training instance the backpropagation algorithm first makes a prediction (forward pass), measures the error, then goes through each layer in reverse to measure the error con‐ tribution from each connection (reverse pass), and finally slightly tweaks the connec‐ tion weights to reduce the error (Gradient Descent step).", "words": [{"w": "This", "b": [0.1429, 0.1764, 0.1801, 0.1978]}, {"w": "algorithm", "b": [0.1884, 0.1764, 0.2711, 0.1978]}, {"w": "is", "b": [0.2794, 0.1764, 0.2926, 0.1978]}, {"w": "so", "b": [0.301, 0.1764, 0.3193, 0.1978]}, {"w": "important,", "b": [0.3276, 0.1764, 0.4167, 0.1978]}, {"w": "it’s", "b": [0.4251, 0.1764, 0.4468, 0.1978]}, {"w": "worth", "b": [0.4551, 0.1764, 0.5052, 0.1978]}, {"w": "summarizing", "b": [0.5136, 0.1764, 0.6243, 0.1978]}, {"w": "it", "b": [0.6327, 0.1764, 0.6446, 0.1978]}, {"w": "again:", "b": [0.653, 0.1764, 0.7027, 0.1978]}, {"w": "for", "b": [0.7111, 0.1764, 0.7356, 0.1978]}, {"w": "each", "b": [0.7439, 0.1764, 0.7819, 0.1978]}, {"w": "training", "b": [0.7902, 0.1764, 0.8572, 0.1978]}, {"w": "instance", "b": [0.1429, 0.1955, 0.212, 0.2169]}, {"w": "the", "b": [0.2222, 0.1955, 0.2485, 0.2169]}, {"w": "backpropagation", "b": [0.2586, 0.1955, 0.3993, 0.2169]}, {"w": "algorithm", "b": [0.4094, 0.1955, 0.4921, 0.2169]}, {"w": "first", "b": [0.5022, 0.1955, 0.5357, 0.2169]}, {"w": "makes", "b": [0.5458, 0.1955, 0.5988, 0.2169]}, {"w": "a", "b": [0.609, 0.1955, 0.6181, 0.2169]}, {"w": "prediction", "b": [0.6282, 0.1955, 0.7151, 0.2169]}, {"w": "(forward", "b": [0.7252, 0.1955, 0.7997, 0.2169]}, {"w": "pass),", "b": [0.8098, 0.1955, 0.8571, 0.2169]}, {"w": "measures", "b": [0.1429, 0.2145, 0.2209, 0.2359]}, {"w": "the", "b": [0.226, 0.2145, 0.2524, 0.2359]}, {"w": "error,", "b": [0.2575, 0.2145, 0.3036, 0.2359]}, {"w": "then", "b": [0.3088, 0.2145, 0.3466, 0.2359]}, {"w": "goes", "b": [0.3517, 0.2145, 0.3886, 0.2359]}, {"w": "through", "b": [0.3938, 0.2145, 0.4616, 0.2359]}, {"w": "each", "b": [0.4667, 0.2145, 0.5047, 0.2359]}, {"w": "layer", "b": [0.5098, 0.2145, 0.55, 0.2359]}, {"w": "in", "b": [0.5552, 0.2145, 0.5722, 0.2359]}, {"w": "reverse", "b": [0.5774, 0.2145, 0.6367, 0.2359]}, {"w": "to", "b": [0.6418, 0.2145, 0.6588, 0.2359]}, {"w": "measure", "b": [0.664, 0.2145, 0.7344, 0.2359]}, {"w": "the", "b": [0.7395, 0.2145, 0.7659, 0.2359]}, {"w": "error", "b": [0.771, 0.2145, 0.8137, 0.2359]}, {"w": "con‐", "b": [0.8189, 0.2145, 0.8571, 0.2359]}, {"w": "tribution", "b": [0.1428, 0.2336, 0.2181, 0.255]}, {"w": "from", "b": [0.2233, 0.2336, 0.2649, 0.255]}, {"w": "each", "b": [0.2701, 0.2336, 0.3081, 0.255]}, {"w": "connection", "b": [0.3133, 0.2336, 0.4072, 0.255]}, {"w": "(reverse", "b": [0.4124, 0.2336, 0.4789, 0.255]}, {"w": "pass),", "b": [0.4841, 0.2336, 0.5314, 0.255]}, {"w": "and", "b": [0.5367, 0.2336, 0.5682, 0.255]}, {"w": "finally", "b": [0.5734, 0.2336, 0.6258, 0.255]}, {"w": "slightly", "b": [0.631, 0.2336, 0.6912, 0.255]}, {"w": "tweaks", "b": [0.6964, 0.2336, 0.753, 0.255]}, {"w": "the", "b": [0.7583, 0.2336, 0.7846, 0.255]}, {"w": "connec‐", "b": [0.7898, 0.2336, 0.8571, 0.255]}, {"w": "tion", "b": [0.1429, 0.2526, 0.1768, 0.274]}, {"w": "weights", "b": [0.1816, 0.2526, 0.2447, 0.274]}, {"w": "to", "b": [0.2495, 0.2526, 0.2664, 0.274]}, {"w": "reduce", "b": [0.2712, 0.2526, 0.3275, 0.274]}, {"w": "the", "b": [0.3322, 0.2526, 0.3586, 0.274]}, {"w": "error", "b": [0.3633, 0.2526, 0.4059, 0.274]}, {"w": "(Gradient", "b": [0.4107, 0.2526, 0.4924, 0.274]}, {"w": "Descent", "b": [0.4972, 0.2526, 0.564, 0.274]}, {"w": "step).", "b": [0.5687, 0.2526, 0.6145, 0.274]}]}, {"id": "b_3", "type": "paragraph", "text": "It is important to initialize all the hidden layers’ connection weights randomly, or else training will fail. For example, if you initialize all weights and biases to zero, then all neurons in a given layer will be perfectly identical, and thus backpropagation will affect them in exactly the same way, so they will remain identical. In other words, despite having hundreds of neurons per layer, your model will act as if it had only one neuron per layer: it won’t be too smart. If instead you randomly initialize the weights, you break the symme‐ try and allow backpropagation to train a diverse team of neurons.", "words": [{"w": "It", "b": [0.2714, 0.2945, 0.283, 0.3141]}, {"w": "is", "b": [0.2875, 0.2945, 0.2996, 0.3141]}, {"w": "important", "b": [0.3041, 0.2945, 0.3813, 0.3141]}, {"w": "to", "b": [0.3858, 0.2945, 0.4013, 0.3141]}, {"w": "initialize", "b": [0.4058, 0.2945, 0.4718, 0.3141]}, {"w": "all", "b": [0.4763, 0.2945, 0.4943, 0.3141]}, {"w": "the", "b": [0.4988, 0.2945, 0.5229, 0.3141]}, {"w": "hidden", "b": [0.5274, 0.2945, 0.5813, 0.3141]}, {"w": "layers’", "b": [0.5859, 0.2945, 0.6331, 0.3141]}, {"w": "connection", "b": [0.6376, 0.2945, 0.7234, 0.3141]}, {"w": "weights", "b": [0.7279, 0.2945, 0.7857, 0.3141]}, {"w": "randomly,", "b": [0.2714, 0.312, 0.3491, 0.3315]}, {"w": "or", "b": [0.3543, 0.312, 0.3711, 0.3315]}, {"w": "else", "b": [0.3763, 0.312, 0.4043, 0.3315]}, {"w": "training", "b": [0.4094, 0.312, 0.4706, 0.3315]}, {"w": "will", "b": [0.4758, 0.312, 0.5036, 0.3315]}, {"w": "fail.", "b": [0.5088, 0.312, 0.537, 0.3315]}, {"w": "For", "b": [0.5422, 0.312, 0.5687, 0.3315]}, {"w": "example,", "b": [0.5739, 0.312, 0.6418, 0.3315]}, {"w": "if", "b": [0.647, 0.312, 0.6577, 0.3315]}, {"w": "you", "b": [0.6629, 0.312, 0.6914, 0.3315]}, {"w": "initialize", "b": [0.6966, 0.312, 0.7625, 0.3315]}, {"w": "all", "b": [0.7677, 0.312, 0.7857, 0.3315]}, {"w": "weights", "b": [0.2714, 0.3294, 0.3292, 0.349]}, {"w": "and", "b": [0.3344, 0.3294, 0.3632, 0.349]}, {"w": "biases", "b": [0.3684, 0.3294, 0.4136, 0.349]}, {"w": "to", "b": [0.4188, 0.3294, 0.4343, 0.349]}, {"w": "zero,", "b": [0.4395, 0.3294, 0.4762, 0.349]}, {"w": "then", "b": [0.4814, 0.3294, 0.5159, 0.349]}, {"w": "all", "b": [0.521, 0.3294, 0.539, 0.349]}, {"w": "neurons", "b": [0.5442, 0.3294, 0.607, 0.349]}, {"w": "in", "b": [0.6122, 0.3294, 0.6278, 0.349]}, {"w": "a", "b": [0.6329, 0.3294, 0.6413, 0.349]}, {"w": "given", "b": [0.6465, 0.3294, 0.6878, 0.349]}, {"w": "layer", "b": [0.693, 0.3294, 0.7298, 0.349]}, {"w": "will", "b": [0.735, 0.3294, 0.7627, 0.349]}, {"w": "be", "b": [0.7679, 0.3294, 0.7857, 0.349]}, {"w": "perfectly", "b": [0.2714, 0.3468, 0.3377, 0.3664]}, {"w": "identical,", "b": [0.3456, 0.3468, 0.4154, 0.3664]}, {"w": "and", "b": [0.4234, 0.3468, 0.4522, 0.3664]}, {"w": "thus", "b": [0.4601, 0.3468, 0.4929, 0.3664]}, {"w": "backpropagation", "b": [0.5008, 0.3468, 0.6294, 0.3664]}, {"w": "will", "b": [0.6373, 0.3468, 0.6651, 0.3664]}, {"w": "affect", "b": [0.6731, 0.3468, 0.7147, 0.3664]}, {"w": "them", "b": [0.7226, 0.3468, 0.7623, 0.3664]}, {"w": "in", "b": [0.7702, 0.3468, 0.7857, 0.3664]}, {"w": "exactly", "b": [0.2714, 0.3642, 0.3243, 0.3838]}, {"w": "the", "b": [0.3293, 0.3642, 0.3533, 0.3838]}, {"w": "same", "b": [0.3583, 0.3642, 0.3974, 0.3838]}, {"w": "way,", "b": [0.4023, 0.3642, 0.4351, 0.3838]}, {"w": "so", "b": [0.4401, 0.3642, 0.4568, 0.3838]}, {"w": "they", "b": [0.4618, 0.3642, 0.4946, 0.3838]}, {"w": "will", "b": [0.4996, 0.3642, 0.5274, 0.3838]}, {"w": "remain", "b": [0.5323, 0.3642, 0.587, 0.3838]}, {"w": "identical.", "b": [0.592, 0.3642, 0.6618, 0.3838]}, {"w": "In", "b": [0.6668, 0.3642, 0.6837, 0.3838]}, {"w": "other", "b": [0.6887, 0.3642, 0.7295, 0.3838]}, {"w": "words,", "b": [0.7345, 0.3642, 0.7857, 0.3838]}, {"w": "despite", "b": [0.2714, 0.3816, 0.3255, 0.4012]}, {"w": "having", "b": [0.3314, 0.3816, 0.3829, 0.4012]}, {"w": "hundreds", "b": [0.3888, 0.3816, 0.4614, 0.4012]}, {"w": "of", "b": [0.4673, 0.3816, 0.4826, 0.4012]}, {"w": "neurons", "b": [0.4885, 0.3816, 0.5514, 0.4012]}, {"w": "per", "b": [0.5573, 0.3816, 0.5824, 0.4012]}, {"w": "layer,", "b": [0.5883, 0.3816, 0.6282, 0.4012]}, {"w": "your", "b": [0.6341, 0.3816, 0.6697, 0.4012]}, {"w": "model", "b": [0.6756, 0.3816, 0.7239, 0.4012]}, {"w": "will", "b": [0.7298, 0.3816, 0.7576, 0.4012]}, {"w": "act", "b": [0.7635, 0.3816, 0.7857, 0.4012]}, {"w": "as", "b": [0.2714, 0.399, 0.2868, 0.4186]}, {"w": "if", "b": [0.2945, 0.399, 0.3053, 0.4186]}, {"w": "it", "b": [0.3131, 0.399, 0.324, 0.4186]}, {"w": "had", "b": [0.3318, 0.399, 0.3604, 0.4186]}, {"w": "only", "b": [0.3682, 0.399, 0.4018, 0.4186]}, {"w": "one", "b": [0.4096, 0.399, 0.4379, 0.4186]}, {"w": "neuron", "b": [0.4456, 0.399, 0.5015, 0.4186]}, {"w": "per", "b": [0.5093, 0.399, 0.5344, 0.4186]}, {"w": "layer:", "b": [0.5422, 0.399, 0.5837, 0.4186]}, {"w": "it", "b": [0.5915, 0.399, 0.6024, 0.4186]}, {"w": "won’t", "b": [0.6102, 0.399, 0.6513, 0.4186]}, {"w": "be", "b": [0.659, 0.399, 0.6768, 0.4186]}, {"w": "too", "b": [0.6846, 0.399, 0.7098, 0.4186]}, {"w": "smart.", "b": [0.7176, 0.399, 0.7658, 0.4186]}, {"w": "If", "b": [0.7736, 0.399, 0.7857, 0.4186]}, {"w": "instead", "b": [0.2714, 0.4165, 0.3262, 0.436]}, {"w": "you", "b": [0.3321, 0.4165, 0.3607, 0.436]}, {"w": "randomly", "b": [0.3665, 0.4165, 0.4413, 0.436]}, {"w": "initialize", "b": [0.4472, 0.4165, 0.5131, 0.436]}, {"w": "the", "b": [0.519, 0.4165, 0.543, 0.436]}, {"w": "weights,", "b": [0.5489, 0.4165, 0.611, 0.436]}, {"w": "you", "b": [0.6169, 0.4165, 0.6455, 0.436]}, {"w": "break", "b": [0.6513, 0.4163, 0.6926, 0.436]}, {"w": "the", "b": [0.6985, 0.4163, 0.7214, 0.436]}, {"w": "symme‐", "b": [0.7273, 0.4163, 0.7857, 0.436]}, {"w": "try", "b": [0.2714, 0.4337, 0.2929, 0.4534]}, {"w": "and", "b": [0.2972, 0.4339, 0.326, 0.4534]}, {"w": "allow", "b": [0.3303, 0.4339, 0.3711, 0.4534]}, {"w": "backpropagation", "b": [0.3754, 0.4339, 0.504, 0.4534]}, {"w": "to", "b": [0.5084, 0.4339, 0.5239, 0.4534]}, {"w": "train", "b": [0.5282, 0.4339, 0.565, 0.4534]}, {"w": "a", "b": [0.5693, 0.4339, 0.5777, 0.4534]}, {"w": "diverse", "b": [0.582, 0.4339, 0.6362, 0.4534]}, {"w": "team", "b": [0.6405, 0.4339, 0.6784, 0.4534]}, {"w": "of", "b": [0.6827, 0.4339, 0.6981, 0.4534]}, {"w": "neurons.", "b": [0.7024, 0.4339, 0.7696, 0.4534]}]}, {"id": "b_4", "type": "paragraph", "text": "In order for this algorithm to work properly, the authors made a key change to the MLP’s architecture: they replaced the step function with the logistic function, σ(z) = 1 / (1 + exp(–z)). This was essential because the step function contains only flat seg‐ ments, so there is no gradient to work with (Gradient Descent cannot move on a flat surface), while the logistic function has a well-defined nonzero derivative every‐ where, allowing Gradient Descent to make some progress at every step. In fact, the backpropagation algorithm works well with many other activation functions, not just the logistic function. Two other popular activation functions are:", "words": [{"w": "In", "b": [0.1429, 0.4737, 0.1614, 0.4952]}, {"w": "order", "b": [0.1681, 0.4737, 0.214, 0.4952]}, {"w": "for", "b": [0.2208, 0.4737, 0.2453, 0.4952]}, {"w": "this", "b": [0.2521, 0.4737, 0.2828, 0.4952]}, {"w": "algorithm", "b": [0.2895, 0.4737, 0.3722, 0.4952]}, {"w": "to", "b": [0.3789, 0.4737, 0.3959, 0.4952]}, {"w": "work", "b": [0.4026, 0.4737, 0.4456, 0.4952]}, {"w": "properly,", "b": [0.4523, 0.4737, 0.5272, 0.4952]}, {"w": "the", "b": [0.5339, 0.4737, 0.5603, 0.4952]}, {"w": "authors", "b": [0.567, 0.4737, 0.6303, 0.4952]}, {"w": "made", "b": [0.637, 0.4737, 0.6831, 0.4952]}, {"w": "a", "b": [0.6899, 0.4737, 0.699, 0.4952]}, {"w": "key", "b": [0.7057, 0.4737, 0.7345, 0.4952]}, {"w": "change", "b": [0.7412, 0.4737, 0.8003, 0.4952]}, {"w": "to", "b": [0.8071, 0.4737, 0.8241, 0.4952]}, {"w": "the", "b": [0.8308, 0.4737, 0.8571, 0.4952]}, {"w": "MLP’s", "b": [0.1429, 0.4928, 0.1947, 0.5142]}, {"w": "architecture:", "b": [0.2009, 0.4928, 0.3061, 0.5142]}, {"w": "they", "b": [0.3123, 0.4928, 0.3482, 0.5142]}, {"w": "replaced", "b": [0.3544, 0.4928, 0.425, 0.5142]}, {"w": "the", "b": [0.4312, 0.4928, 0.4576, 0.5142]}, {"w": "step", "b": [0.4638, 0.4928, 0.4976, 0.5142]}, {"w": "function", "b": [0.5038, 0.4928, 0.5752, 0.5142]}, {"w": "with", "b": [0.5814, 0.4928, 0.6188, 0.5142]}, {"w": "the", "b": [0.625, 0.4928, 0.6513, 0.5142]}, {"w": "logistic", "b": [0.6576, 0.4928, 0.7172, 0.5142]}, {"w": "function,", "b": [0.7234, 0.4928, 0.7996, 0.5142]}, {"w": "σ(z)", "b": [0.8058, 0.4926, 0.8388, 0.5142]}, {"w": "=", "b": [0.8451, 0.4928, 0.8572, 0.5142]}, {"w": "1", "b": [0.1429, 0.5118, 0.1529, 0.5332]}, {"w": "/", "b": [0.1589, 0.5118, 0.1658, 0.5332]}, {"w": "(1", "b": [0.1718, 0.5118, 0.189, 0.5332]}, {"w": "+", "b": [0.195, 0.5118, 0.2071, 0.5332]}, {"w": "exp(–z)).", "b": [0.2131, 0.5116, 0.2886, 0.5332]}, {"w": "This", "b": [0.2947, 0.5118, 0.3319, 0.5332]}, {"w": "was", "b": [0.3379, 0.5118, 0.3689, 0.5332]}, {"w": "essential", "b": [0.375, 0.5118, 0.4453, 0.5332]}, {"w": "because", "b": [0.4513, 0.5118, 0.5159, 0.5332]}, {"w": "the", "b": [0.5219, 0.5118, 0.5482, 0.5332]}, {"w": "step", "b": [0.5543, 0.5118, 0.588, 0.5332]}, {"w": "function", "b": [0.5941, 0.5118, 0.6655, 0.5332]}, {"w": "contains", "b": [0.6715, 0.5118, 0.742, 0.5332]}, {"w": "only", "b": [0.748, 0.5118, 0.7849, 0.5332]}, {"w": "flat", "b": [0.7909, 0.5118, 0.8175, 0.5332]}, {"w": "seg‐", "b": [0.8235, 0.5118, 0.8571, 0.5332]}, {"w": "ments,", "b": [0.1429, 0.5309, 0.1985, 0.5523]}, {"w": "so", "b": [0.2042, 0.5309, 0.2225, 0.5523]}, {"w": "there", "b": [0.2282, 0.5309, 0.2711, 0.5523]}, {"w": "is", "b": [0.2768, 0.5309, 0.29, 0.5523]}, {"w": "no", "b": [0.2957, 0.5309, 0.3177, 0.5523]}, {"w": "gradient", "b": [0.3234, 0.5309, 0.3928, 0.5523]}, {"w": "to", "b": [0.3985, 0.5309, 0.4155, 0.5523]}, {"w": "work", "b": [0.4211, 0.5309, 0.4641, 0.5523]}, {"w": "with", "b": [0.4698, 0.5309, 0.5071, 0.5523]}, {"w": "(Gradient", "b": [0.5128, 0.5309, 0.5946, 0.5523]}, {"w": "Descent", "b": [0.6003, 0.5309, 0.6671, 0.5523]}, {"w": "cannot", "b": [0.6728, 0.5309, 0.7305, 0.5523]}, {"w": "move", "b": [0.7362, 0.5309, 0.7824, 0.5523]}, {"w": "on", "b": [0.7881, 0.5309, 0.8101, 0.5523]}, {"w": "a", "b": [0.8158, 0.5309, 0.8249, 0.5523]}, {"w": "flat", "b": [0.8306, 0.5309, 0.8571, 0.5523]}, {"w": "surface),", "b": [0.1428, 0.5499, 0.2142, 0.5713]}, {"w": "while", "b": [0.2238, 0.5499, 0.2689, 0.5713]}, {"w": "the", "b": [0.2784, 0.5499, 0.3047, 0.5713]}, {"w": "logistic", "b": [0.3143, 0.5499, 0.3739, 0.5713]}, {"w": "function", "b": [0.3835, 0.5499, 0.4548, 0.5713]}, {"w": "has", "b": [0.4644, 0.5499, 0.4923, 0.5713]}, {"w": "a", "b": [0.5018, 0.5499, 0.511, 0.5713]}, {"w": "well-defined", "b": [0.5205, 0.5499, 0.6245, 0.5713]}, {"w": "nonzero", "b": [0.634, 0.5499, 0.7034, 0.5713]}, {"w": "derivative", "b": [0.7129, 0.5499, 0.7949, 0.5713]}, {"w": "every‐", "b": [0.8045, 0.5499, 0.8571, 0.5713]}, {"w": "where,", "b": [0.1429, 0.569, 0.1984, 0.5904]}, {"w": "allowing", "b": [0.2054, 0.569, 0.2767, 0.5904]}, {"w": "Gradient", "b": [0.2836, 0.569, 0.3582, 0.5904]}, {"w": "Descent", "b": [0.3651, 0.569, 0.432, 0.5904]}, {"w": "to", "b": [0.4389, 0.569, 0.4559, 0.5904]}, {"w": "make", "b": [0.4628, 0.569, 0.5082, 0.5904]}, {"w": "some", "b": [0.5152, 0.569, 0.5593, 0.5904]}, {"w": "progress", "b": [0.5663, 0.569, 0.6372, 0.5904]}, {"w": "at", "b": [0.6441, 0.569, 0.6592, 0.5904]}, {"w": "every", "b": [0.6662, 0.569, 0.7114, 0.5904]}, {"w": "step.", "b": [0.7184, 0.569, 0.7563, 0.5904]}, {"w": "In", "b": [0.7632, 0.569, 0.7817, 0.5904]}, {"w": "fact,", "b": [0.7886, 0.569, 0.8239, 0.5904]}, {"w": "the", "b": [0.8308, 0.569, 0.8571, 0.5904]}, {"w": "backpropagation", "b": [0.1429, 0.588, 0.2835, 0.6094]}, {"w": "algorithm", "b": [0.2893, 0.588, 0.372, 0.6094]}, {"w": "works", "b": [0.3778, 0.588, 0.4284, 0.6094]}, {"w": "well", "b": [0.4342, 0.588, 0.4679, 0.6094]}, {"w": "with", "b": [0.4737, 0.588, 0.511, 0.6094]}, {"w": "many", "b": [0.5169, 0.588, 0.5635, 0.6094]}, {"w": "other", "b": [0.5694, 0.588, 0.614, 0.6094]}, {"w": "activation", "b": [0.6199, 0.5878, 0.701, 0.6094]}, {"w": "functions,", "b": [0.7069, 0.5878, 0.7867, 0.6094]}, {"w": "not", "b": [0.7926, 0.588, 0.8209, 0.6094]}, {"w": "just", "b": [0.8267, 0.588, 0.8571, 0.6094]}, {"w": "the", "b": [0.1429, 0.6071, 0.1692, 0.6285]}, {"w": "logistic", "b": [0.1739, 0.6071, 0.2335, 0.6285]}, {"w": "function.", "b": [0.2383, 0.6071, 0.3144, 0.6285]}, {"w": "Two", "b": [0.3191, 0.6071, 0.3554, 0.6285]}, {"w": "other", "b": [0.3601, 0.6071, 0.4048, 0.6285]}, {"w": "popular", "b": [0.4095, 0.6071, 0.4752, 0.6285]}, {"w": "activation", "b": [0.4799, 0.6071, 0.5622, 0.6285]}, {"w": "functions", "b": [0.5669, 0.6071, 0.6459, 0.6285]}, {"w": "are:", "b": [0.6507, 0.6071, 0.6811, 0.6285]}]}, {"id": "b_5", "type": "equation", "text": "The hyperbolic tangent function tanh(z) = 2σ(2z) – 1", "words": [{"w": "The", "b": [0.1429, 0.6365, 0.1727, 0.6581]}, {"w": "hyperbolic", "b": [0.1775, 0.6365, 0.261, 0.6581]}, {"w": "tangent", "b": [0.2658, 0.6365, 0.3267, 0.6581]}, {"w": "function", "b": [0.3315, 0.6365, 0.3996, 0.6581]}, {"w": "tanh(z)", "b": [0.4044, 0.6365, 0.4647, 0.6581]}, {"w": "=", "b": [0.4695, 0.6365, 0.4819, 0.6581]}, {"w": "2σ(2z)", "b": [0.4866, 0.6365, 0.5391, 0.6581]}, {"w": "–", "b": [0.5439, 0.6365, 0.5543, 0.6581]}, {"w": "1", "b": [0.5591, 0.6365, 0.569, 0.6581]}]}, {"id": "b_6", "type": "paragraph", "text": "Just like the logistic function it is S-shaped, continuous, and differentiable, but its output value ranges from –1 to 1 (instead of 0 to 1 in the case of the logistic func‐ tion), which tends to make each layer’s output more or less centered around 0 at the beginning of training. This often helps speed up convergence.", "words": [{"w": "Just", "b": [0.1786, 0.6558, 0.2098, 0.6772]}, {"w": "like", "b": [0.2149, 0.6558, 0.2449, 0.6772]}, {"w": "the", "b": [0.25, 0.6558, 0.2764, 0.6772]}, {"w": "logistic", "b": [0.2814, 0.6558, 0.3411, 0.6772]}, {"w": "function", "b": [0.3461, 0.6558, 0.4175, 0.6772]}, {"w": "it", "b": [0.4226, 0.6558, 0.4345, 0.6772]}, {"w": "is", "b": [0.4396, 0.6558, 0.4528, 0.6772]}, {"w": "S-shaped,", "b": [0.4579, 0.6558, 0.5382, 0.6772]}, {"w": "continuous,", "b": [0.5433, 0.6558, 0.6418, 0.6772]}, {"w": "and", "b": [0.6469, 0.6558, 0.6785, 0.6772]}, {"w": "differentiable,", "b": [0.6835, 0.6558, 0.7994, 0.6772]}, {"w": "but", "b": [0.8045, 0.6558, 0.8325, 0.6772]}, {"w": "its", "b": [0.8376, 0.6558, 0.8572, 0.6772]}, {"w": "output", "b": [0.1786, 0.6748, 0.2349, 0.6962]}, {"w": "value", "b": [0.2398, 0.6748, 0.2838, 0.6962]}, {"w": "ranges", "b": [0.2887, 0.6748, 0.3432, 0.6962]}, {"w": "from", "b": [0.3481, 0.6748, 0.3897, 0.6962]}, {"w": "–1", "b": [0.3946, 0.6748, 0.4154, 0.6962]}, {"w": "to", "b": [0.4203, 0.6748, 0.4373, 0.6962]}, {"w": "1", "b": [0.4422, 0.6748, 0.4522, 0.6962]}, {"w": "(instead", "b": [0.457, 0.6748, 0.5242, 0.6962]}, {"w": "of", "b": [0.5291, 0.6748, 0.5459, 0.6962]}, {"w": "0", "b": [0.5508, 0.6748, 0.5608, 0.6962]}, {"w": "to", "b": [0.5657, 0.6748, 0.5827, 0.6962]}, {"w": "1", "b": [0.5876, 0.6748, 0.5976, 0.6962]}, {"w": "in", "b": [0.6024, 0.6748, 0.6194, 0.6962]}, {"w": "the", "b": [0.6243, 0.6748, 0.6506, 0.6962]}, {"w": "case", "b": [0.6555, 0.6748, 0.69, 0.6962]}, {"w": "of", "b": [0.6949, 0.6748, 0.7117, 0.6962]}, {"w": "the", "b": [0.7166, 0.6748, 0.7429, 0.6962]}, {"w": "logistic", "b": [0.7478, 0.6748, 0.8074, 0.6962]}, {"w": "func‐", "b": [0.8123, 0.6748, 0.8571, 0.6962]}, {"w": "tion),", "b": [0.1786, 0.6938, 0.2245, 0.7153]}, {"w": "which", "b": [0.2302, 0.6938, 0.2811, 0.7153]}, {"w": "tends", "b": [0.2868, 0.6938, 0.3321, 0.7153]}, {"w": "to", "b": [0.3377, 0.6938, 0.3547, 0.7153]}, {"w": "make", "b": [0.3604, 0.6938, 0.4058, 0.7153]}, {"w": "each", "b": [0.4115, 0.6938, 0.4495, 0.7153]}, {"w": "layer’s", "b": [0.4551, 0.6938, 0.5056, 0.7153]}, {"w": "output", "b": [0.5113, 0.6938, 0.5677, 0.7153]}, {"w": "more", "b": [0.5734, 0.6938, 0.6177, 0.7153]}, {"w": "or", "b": [0.6234, 0.6938, 0.6417, 0.7153]}, {"w": "less", "b": [0.6474, 0.6938, 0.6768, 0.7153]}, {"w": "centered", "b": [0.6825, 0.6938, 0.754, 0.7153]}, {"w": "around", "b": [0.7597, 0.6938, 0.8207, 0.7153]}, {"w": "0", "b": [0.8263, 0.6938, 0.8363, 0.7153]}, {"w": "at", "b": [0.842, 0.6938, 0.8571, 0.7153]}, {"w": "the", "b": [0.1786, 0.7129, 0.2049, 0.7343]}, {"w": "beginning", "b": [0.2096, 0.7129, 0.2939, 0.7343]}, {"w": "of", "b": [0.2986, 0.7129, 0.3154, 0.7343]}, {"w": "training.", "b": [0.3202, 0.7129, 0.3919, 0.7343]}, {"w": "This", "b": [0.3966, 0.7129, 0.4338, 0.7343]}, {"w": "often", "b": [0.4385, 0.7129, 0.4819, 0.7343]}, {"w": "helps", "b": [0.4866, 0.7129, 0.5305, 0.7343]}, {"w": "speed", "b": [0.5352, 0.7129, 0.5825, 0.7343]}, {"w": "up", "b": [0.5872, 0.7129, 0.6092, 0.7343]}, {"w": "convergence.", "b": [0.6139, 0.7129, 0.7229, 0.7343]}]}, {"id": "b_7", "type": "equation", "text": "The Rectified Linear Unit function: ReLU(z) = max(0, z)", "words": [{"w": "The", "b": [0.1429, 0.7423, 0.1727, 0.7639]}, {"w": "Rectified", "b": [0.1775, 0.7423, 0.2483, 0.7639]}, {"w": "Linear", "b": [0.2531, 0.7423, 0.3058, 0.7639]}, {"w": "Unit", "b": [0.3105, 0.7423, 0.347, 0.7639]}, {"w": "function:", "b": [0.3518, 0.7423, 0.4248, 0.7639]}, {"w": "ReLU(z)", "b": [0.4295, 0.7423, 0.498, 0.7639]}, {"w": "=", "b": [0.5028, 0.7423, 0.5152, 0.7639]}, {"w": "max(0,", "b": [0.5199, 0.7423, 0.5781, 0.7639]}, {"w": "z)", "b": [0.5829, 0.7423, 0.5985, 0.7639]}]}, {"id": "b_8", "type": "paragraph", "text": "It is continuous but unfortunately not differentiable at z = 0 (the slope changes abruptly, which can make Gradient Descent bounce around), and its derivative is 0 for z < 0. However, in practice it works very well and has the advantage of being", "words": [{"w": "It", "b": [0.1786, 0.7616, 0.1912, 0.783]}, {"w": "is", "b": [0.1979, 0.7616, 0.2112, 0.783]}, {"w": "continuous", "b": [0.2179, 0.7616, 0.3116, 0.783]}, {"w": "but", "b": [0.3184, 0.7616, 0.3464, 0.783]}, {"w": "unfortunately", "b": [0.3531, 0.7616, 0.4677, 0.783]}, {"w": "not", "b": [0.4744, 0.7616, 0.5028, 0.783]}, {"w": "differentiable", "b": [0.5095, 0.7616, 0.6206, 0.783]}, {"w": "at", "b": [0.6273, 0.7616, 0.6424, 0.783]}, {"w": "z", "b": [0.6492, 0.7614, 0.6579, 0.783]}, {"w": "=", "b": [0.6646, 0.7616, 0.6767, 0.783]}, {"w": "0", "b": [0.6834, 0.7616, 0.6934, 0.783]}, {"w": "(the", "b": [0.7001, 0.7616, 0.7337, 0.783]}, {"w": "slope", "b": [0.7404, 0.7616, 0.7837, 0.783]}, {"w": "changes", "b": [0.7904, 0.7616, 0.8571, 0.783]}, {"w": "abruptly,", "b": [0.1786, 0.7806, 0.2524, 0.802]}, {"w": "which", "b": [0.2576, 0.7806, 0.3085, 0.802]}, {"w": "can", "b": [0.3137, 0.7806, 0.3431, 0.802]}, {"w": "make", "b": [0.3483, 0.7806, 0.3937, 0.802]}, {"w": "Gradient", "b": [0.3988, 0.7806, 0.4734, 0.802]}, {"w": "Descent", "b": [0.4786, 0.7806, 0.5454, 0.802]}, {"w": "bounce", "b": [0.5506, 0.7806, 0.6119, 0.802]}, {"w": "around),", "b": [0.6171, 0.7806, 0.69, 0.802]}, {"w": "and", "b": [0.6952, 0.7806, 0.7268, 0.802]}, {"w": "its", "b": [0.732, 0.7806, 0.7515, 0.802]}, {"w": "derivative", "b": [0.7567, 0.7806, 0.8387, 0.802]}, {"w": "is", "b": [0.8439, 0.7806, 0.8571, 0.802]}, {"w": "0", "b": [0.1786, 0.7997, 0.1886, 0.8211]}, {"w": "for", "b": [0.1933, 0.7997, 0.2178, 0.8211]}, {"w": "z", "b": [0.2227, 0.7995, 0.2314, 0.8211]}, {"w": "<", "b": [0.2362, 0.7997, 0.2477, 0.8211]}, {"w": "0.", "b": [0.2525, 0.7997, 0.2673, 0.8211]}, {"w": "However,", "b": [0.2721, 0.7997, 0.3509, 0.8211]}, {"w": "in", "b": [0.3557, 0.7997, 0.3727, 0.8211]}, {"w": "practice", "b": [0.3775, 0.7997, 0.4437, 0.8211]}, {"w": "it", "b": [0.4485, 0.7997, 0.4605, 0.8211]}, {"w": "works", "b": [0.4653, 0.7997, 0.5159, 0.8211]}, {"w": "very", "b": [0.5207, 0.7997, 0.5571, 0.8211]}, {"w": "well", "b": [0.5619, 0.7997, 0.5955, 0.8211]}, {"w": "and", "b": [0.6003, 0.7997, 0.6319, 0.8211]}, {"w": "has", "b": [0.6367, 0.7997, 0.6646, 0.8211]}, {"w": "the", "b": [0.6694, 0.7997, 0.6957, 0.8211]}, {"w": "advantage", "b": [0.7005, 0.7997, 0.7846, 0.8211]}, {"w": "of", "b": [0.7894, 0.7997, 0.8062, 0.8211]}, {"w": "being", "b": [0.811, 0.7997, 0.8571, 0.8211]}]}, {"id": "b_9", "type": "paragraph", "text": "288 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "288", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 315, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "11 Biological neurons seem to implement a roughly sigmoid (S-shaped) activation function, so researchers stuck to sigmoid functions for a very long time. But it turns out that ReLU generally works better in ANNs. This is one of the cases where the biological analogy was misleading.", "words": [{"w": "11", "b": [0.1385, 0.8462, 0.1518, 0.8604]}, {"w": "Biological", "b": [0.1587, 0.8447, 0.2219, 0.861]}, {"w": "neurons", "b": [0.2255, 0.8447, 0.2779, 0.861]}, {"w": "seem", "b": [0.2815, 0.8447, 0.3138, 0.861]}, {"w": "to", "b": [0.3174, 0.8447, 0.3303, 0.861]}, {"w": "implement", "b": [0.3339, 0.8447, 0.4029, 0.861]}, {"w": "a", "b": [0.4065, 0.8447, 0.4135, 0.861]}, {"w": "roughly", "b": [0.4171, 0.8447, 0.4667, 0.861]}, {"w": "sigmoid", "b": [0.4703, 0.8447, 0.5216, 0.861]}, {"w": "(S-shaped)", "b": [0.5252, 0.8447, 0.5937, 0.861]}, {"w": "activation", "b": [0.5973, 0.8447, 0.66, 0.861]}, {"w": "function,", "b": [0.6636, 0.8447, 0.7216, 0.861]}, {"w": "so", "b": [0.7252, 0.8447, 0.7391, 0.861]}, {"w": "researchers", "b": [0.7427, 0.8447, 0.8145, 0.861]}, {"w": "stuck", "b": [0.8181, 0.8447, 0.8517, 0.861]}, {"w": "to", "b": [0.1587, 0.8598, 0.1717, 0.8761]}, {"w": "sigmoid", "b": [0.1753, 0.8598, 0.2265, 0.8761]}, {"w": "functions", "b": [0.2301, 0.8598, 0.2903, 0.8761]}, {"w": "for", "b": [0.2939, 0.8598, 0.3126, 0.8761]}, {"w": "a", "b": [0.3162, 0.8598, 0.3232, 0.8761]}, {"w": "very", "b": [0.3268, 0.8598, 0.3545, 0.8761]}, {"w": "long", "b": [0.3581, 0.8598, 0.3863, 0.8761]}, {"w": "time.", "b": [0.39, 0.8598, 0.4224, 0.8761]}, {"w": "But", "b": [0.426, 0.8598, 0.4486, 0.8761]}, {"w": "it", "b": [0.4522, 0.8598, 0.4613, 0.8761]}, {"w": "turns", "b": [0.4649, 0.8598, 0.4986, 0.8761]}, {"w": "out", "b": [0.5022, 0.8598, 0.5236, 0.8761]}, {"w": "that", "b": [0.5272, 0.8598, 0.552, 0.8761]}, {"w": "ReLU", "b": [0.5556, 0.8598, 0.5918, 0.8761]}, {"w": "generally", "b": [0.5954, 0.8598, 0.6532, 0.8761]}, {"w": "works", "b": [0.6568, 0.8598, 0.6953, 0.8761]}, {"w": "better", "b": [0.6989, 0.8598, 0.736, 0.8761]}, {"w": "in", "b": [0.7397, 0.8598, 0.7526, 0.8761]}, {"w": "ANNs.", "b": [0.7562, 0.8598, 0.7998, 0.8761]}, {"w": "This", "b": [0.8034, 0.8598, 0.8317, 0.8761]}, {"w": "is", "b": [0.8353, 0.8598, 0.8454, 0.8761]}, {"w": "one", "b": [0.1587, 0.8749, 0.1823, 0.8912]}, {"w": "of", "b": [0.1859, 0.8749, 0.1987, 0.8912]}, {"w": "the", "b": [0.2023, 0.8749, 0.2223, 0.8912]}, {"w": "cases", "b": [0.2259, 0.8749, 0.258, 0.8912]}, {"w": "where", "b": [0.2616, 0.8749, 0.3003, 0.8912]}, {"w": "the", "b": [0.3039, 0.8749, 0.324, 0.8912]}, {"w": "biological", "b": [0.3276, 0.8749, 0.3895, 0.8912]}, {"w": "analogy", "b": [0.3931, 0.8749, 0.4429, 0.8912]}, {"w": "was", "b": [0.4465, 0.8749, 0.4702, 0.8912]}, {"w": "misleading.", "b": [0.4738, 0.8749, 0.547, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "fast to compute11. Most importantly, the fact that it does not have a maximum output value also helps reduce some issues during Gradient Descent (we will come back to this in Chapter 11).", "words": [{"w": "fast", "b": [0.1786, 0.0791, 0.2079, 0.1005]}, {"w": "to", "b": [0.2153, 0.0791, 0.2322, 0.1005]}, {"w": "compute11.", "b": [0.2396, 0.0791, 0.3291, 0.1005]}, {"w": "Most", "b": [0.3365, 0.0791, 0.3791, 0.1005]}, {"w": "importantly,", "b": [0.3865, 0.0791, 0.4889, 0.1005]}, {"w": "the", "b": [0.4963, 0.0791, 0.5226, 0.1005]}, {"w": "fact", "b": [0.53, 0.0791, 0.5605, 0.1005]}, {"w": "that", "b": [0.5679, 0.0791, 0.6005, 0.1005]}, {"w": "it", "b": [0.6078, 0.0791, 0.6198, 0.1005]}, {"w": "does", "b": [0.6272, 0.0791, 0.6653, 0.1005]}, {"w": "not", "b": [0.6727, 0.0791, 0.701, 0.1005]}, {"w": "have", "b": [0.7084, 0.0791, 0.7468, 0.1005]}, {"w": "a", "b": [0.7542, 0.0791, 0.7633, 0.1005]}, {"w": "maximum", "b": [0.7707, 0.0791, 0.8571, 0.1005]}, {"w": "output", "b": [0.1786, 0.0981, 0.235, 0.1195]}, {"w": "value", "b": [0.2435, 0.0981, 0.2875, 0.1195]}, {"w": "also", "b": [0.296, 0.0981, 0.3287, 0.1195]}, {"w": "helps", "b": [0.3373, 0.0981, 0.3811, 0.1195]}, {"w": "reduce", "b": [0.3897, 0.0981, 0.446, 0.1195]}, {"w": "some", "b": [0.4545, 0.0981, 0.4987, 0.1195]}, {"w": "issues", "b": [0.5073, 0.0981, 0.5557, 0.1195]}, {"w": "during", "b": [0.5643, 0.0981, 0.6208, 0.1195]}, {"w": "Gradient", "b": [0.6293, 0.0981, 0.7039, 0.1195]}, {"w": "Descent", "b": [0.7125, 0.0981, 0.7793, 0.1195]}, {"w": "(we", "b": [0.7879, 0.0981, 0.8182, 0.1195]}, {"w": "will", "b": [0.8268, 0.0981, 0.8571, 0.1195]}, {"w": "come", "b": [0.1786, 0.1172, 0.2239, 0.1386]}, {"w": "back", "b": [0.2286, 0.1172, 0.2675, 0.1386]}, {"w": "to", "b": [0.2723, 0.1172, 0.2892, 0.1386]}, {"w": "this", "b": [0.294, 0.1172, 0.3247, 0.1386]}, {"w": "in", "b": [0.3294, 0.1172, 0.3464, 0.1386]}, {"w": "Chapter", "b": [0.3511, 0.1172, 0.4187, 0.1386]}, {"w": "11).", "b": [0.4234, 0.1172, 0.4554, 0.1386]}]}, {"id": "b_2", "type": "paragraph", "text": "These popular activation functions and their derivatives are represented in Figure 10-8. But wait! Why do we need activation functions in the first place? Well, if you chain several linear transformations, all you get is a linear transformation. For example, say f(x) = 2 x + 3 and g(x) = 5 x - 1, then chaining these two linear functions gives you another linear function: f(g(x)) = 2(5 x - 1) + 3 = 10 x + 1. So if you don’t have some non-linearity between layers, then even a deep stack of layers is equivalent to a single layer: you cannot solve very complex problems with that.", "words": [{"w": "These", "b": [0.1429, 0.1453, 0.1922, 0.1667]}, {"w": "popular", "b": [0.2074, 0.1453, 0.273, 0.1667]}, {"w": "activation", "b": [0.2882, 0.1453, 0.3705, 0.1667]}, {"w": "functions", "b": [0.3857, 0.1453, 0.4647, 0.1667]}, {"w": "and", "b": [0.4799, 0.1453, 0.5114, 0.1667]}, {"w": "their", "b": [0.5266, 0.1453, 0.5663, 0.1667]}, {"w": "derivatives", "b": [0.5814, 0.1453, 0.6711, 0.1667]}, {"w": "are", "b": [0.6863, 0.1453, 0.712, 0.1667]}, {"w": "represented", "b": [0.7272, 0.1453, 0.825, 0.1667]}, {"w": "in", "b": [0.8402, 0.1453, 0.8571, 0.1667]}, {"w": "Figure", "b": [0.1428, 0.1643, 0.1968, 0.1857]}, {"w": "10-8.", "b": [0.2016, 0.1643, 0.2443, 0.1857]}, {"w": "But", "b": [0.2496, 0.1643, 0.2792, 0.1857]}, {"w": "wait!", "b": [0.2845, 0.1643, 0.3256, 0.1857]}, {"w": "Why", "b": [0.3309, 0.1643, 0.3713, 0.1857]}, {"w": "do", "b": [0.3766, 0.1643, 0.3982, 0.1857]}, {"w": "we", "b": [0.4034, 0.1643, 0.4266, 0.1857]}, {"w": "need", "b": [0.4318, 0.1643, 0.4719, 0.1857]}, {"w": "activation", "b": [0.4772, 0.1643, 0.5595, 0.1857]}, {"w": "functions", "b": [0.5647, 0.1643, 0.6438, 0.1857]}, {"w": "in", "b": [0.649, 0.1643, 0.666, 0.1857]}, {"w": "the", "b": [0.6713, 0.1643, 0.6976, 0.1857]}, {"w": "first", "b": [0.7029, 0.1643, 0.7363, 0.1857]}, {"w": "place?", "b": [0.7416, 0.1643, 0.7925, 0.1857]}, {"w": "Well,", "b": [0.7978, 0.1643, 0.8401, 0.1857]}, {"w": "if", "b": [0.8454, 0.1643, 0.8571, 0.1857]}, {"w": "you", "b": [0.1428, 0.1834, 0.1741, 0.2048]}, {"w": "chain", "b": [0.1813, 0.1834, 0.2274, 0.2048]}, {"w": "several", "b": [0.2346, 0.1834, 0.2917, 0.2048]}, {"w": "linear", "b": [0.2989, 0.1834, 0.3469, 0.2048]}, {"w": "transformations,", "b": [0.3541, 0.1834, 0.493, 0.2048]}, {"w": "all", "b": [0.5002, 0.1834, 0.5199, 0.2048]}, {"w": "you", "b": [0.5271, 0.1834, 0.5584, 0.2048]}, {"w": "get", "b": [0.5656, 0.1834, 0.5905, 0.2048]}, {"w": "is", "b": [0.5977, 0.1834, 0.6109, 0.2048]}, {"w": "a", "b": [0.6181, 0.1834, 0.6273, 0.2048]}, {"w": "linear", "b": [0.6345, 0.1834, 0.6825, 0.2048]}, {"w": "transformation.", "b": [0.6896, 0.1834, 0.821, 0.2048]}, {"w": "For", "b": [0.8282, 0.1834, 0.8571, 0.2048]}, {"w": "example,", "b": [0.1429, 0.2024, 0.2172, 0.2238]}, {"w": "say", "b": [0.2219, 0.2024, 0.2479, 0.2238]}, {"w": "f(x)", "b": [0.2526, 0.2022, 0.2834, 0.2238]}, {"w": "=", "b": [0.2881, 0.2024, 0.3002, 0.2238]}, {"w": "2", "b": [0.3049, 0.2024, 0.3149, 0.2238]}, {"w": "x", "b": [0.3202, 0.2022, 0.3301, 0.2238]}, {"w": "+", "b": [0.335, 0.2024, 0.3471, 0.2238]}, {"w": "3", "b": [0.3518, 0.2024, 0.3618, 0.2238]}, {"w": "and", "b": [0.3665, 0.2024, 0.3981, 0.2238]}, {"w": "g(x)", "b": [0.4028, 0.2022, 0.4374, 0.2238]}, {"w": "=", "b": [0.4421, 0.2024, 0.4542, 0.2238]}, {"w": "5", "b": [0.4589, 0.2024, 0.4689, 0.2238]}, {"w": "x", "b": [0.4742, 0.2022, 0.4841, 0.2238]}, {"w": "-", "b": [0.4889, 0.2024, 0.4964, 0.2238]}, {"w": "1,", "b": [0.5013, 0.2024, 0.516, 0.2238]}, {"w": "then", "b": [0.5209, 0.2024, 0.5587, 0.2238]}, {"w": "chaining", "b": [0.5636, 0.2024, 0.6364, 0.2238]}, {"w": "these", "b": [0.6413, 0.2024, 0.6841, 0.2238]}, {"w": "two", "b": [0.689, 0.2024, 0.7203, 0.2238]}, {"w": "linear", "b": [0.7252, 0.2024, 0.7732, 0.2238]}, {"w": "functions", "b": [0.7781, 0.2024, 0.8571, 0.2238]}, {"w": "gives", "b": [0.1429, 0.2215, 0.1843, 0.2429]}, {"w": "you", "b": [0.1904, 0.2215, 0.2217, 0.2429]}, {"w": "another", "b": [0.2278, 0.2215, 0.293, 0.2429]}, {"w": "linear", "b": [0.2991, 0.2215, 0.3471, 0.2429]}, {"w": "function:", "b": [0.3532, 0.2215, 0.4293, 0.2429]}, {"w": "f(g(x))", "b": [0.4354, 0.2213, 0.49, 0.2429]}, {"w": "=", "b": [0.4961, 0.2215, 0.5082, 0.2429]}, {"w": "2(5", "b": [0.5143, 0.2215, 0.5415, 0.2429]}, {"w": "x", "b": [0.5476, 0.2213, 0.5574, 0.2429]}, {"w": "-", "b": [0.5635, 0.2215, 0.5709, 0.2429]}, {"w": "1)", "b": [0.577, 0.2215, 0.5942, 0.2429]}, {"w": "+", "b": [0.6003, 0.2215, 0.6124, 0.2429]}, {"w": "3", "b": [0.6185, 0.2215, 0.6285, 0.2429]}, {"w": "=", "b": [0.6346, 0.2215, 0.6466, 0.2429]}, {"w": "10", "b": [0.6527, 0.2215, 0.6727, 0.2429]}, {"w": "x", "b": [0.6788, 0.2213, 0.6887, 0.2429]}, {"w": "+", "b": [0.6948, 0.2215, 0.7068, 0.2429]}, {"w": "1.", "b": [0.7129, 0.2215, 0.7277, 0.2429]}, {"w": "So", "b": [0.7338, 0.2215, 0.7543, 0.2429]}, {"w": "if", "b": [0.7604, 0.2215, 0.7721, 0.2429]}, {"w": "you", "b": [0.7782, 0.2215, 0.8095, 0.2429]}, {"w": "don’t", "b": [0.8155, 0.2215, 0.8571, 0.2429]}, {"w": "have", "b": [0.1429, 0.2405, 0.1813, 0.2619]}, {"w": "some", "b": [0.1865, 0.2405, 0.2307, 0.2619]}, {"w": "non-linearity", "b": [0.2359, 0.2405, 0.3462, 0.2619]}, {"w": "between", "b": [0.3514, 0.2405, 0.4206, 0.2619]}, {"w": "layers,", "b": [0.4258, 0.2405, 0.4784, 0.2619]}, {"w": "then", "b": [0.4836, 0.2405, 0.5213, 0.2619]}, {"w": "even", "b": [0.5265, 0.2405, 0.5653, 0.2619]}, {"w": "a", "b": [0.5705, 0.2405, 0.5796, 0.2619]}, {"w": "deep", "b": [0.5849, 0.2405, 0.6245, 0.2619]}, {"w": "stack", "b": [0.6297, 0.2405, 0.672, 0.2619]}, {"w": "of", "b": [0.6772, 0.2405, 0.694, 0.2619]}, {"w": "layers", "b": [0.6992, 0.2405, 0.7471, 0.2619]}, {"w": "is", "b": [0.7523, 0.2405, 0.7655, 0.2619]}, {"w": "equivalent", "b": [0.7707, 0.2405, 0.8571, 0.2619]}, {"w": "to", "b": [0.1428, 0.2596, 0.1598, 0.281]}, {"w": "a", "b": [0.1646, 0.2596, 0.1737, 0.281]}, {"w": "single", "b": [0.1784, 0.2596, 0.2269, 0.281]}, {"w": "layer:", "b": [0.2317, 0.2596, 0.2771, 0.281]}, {"w": "you", "b": [0.2818, 0.2596, 0.3131, 0.281]}, {"w": "cannot", "b": [0.3178, 0.2596, 0.3755, 0.281]}, {"w": "solve", "b": [0.3803, 0.2596, 0.4223, 0.281]}, {"w": "very", "b": [0.427, 0.2596, 0.4634, 0.281]}, {"w": "complex", "b": [0.4682, 0.2596, 0.5391, 0.281]}, {"w": "problems", "b": [0.5439, 0.2596, 0.6226, 0.281]}, {"w": "with", "b": [0.6273, 0.2596, 0.6646, 0.281]}, {"w": "that.", "b": [0.6693, 0.2596, 0.7067, 0.281]}]}, {"id": "b_3", "type": "equation", "text": "Figure 10-8. Activation functions and their derivatives", "words": [{"w": "Figure", "b": [0.1429, 0.4887, 0.1943, 0.5103]}, {"w": "10-8.", "b": [0.1991, 0.4887, 0.2407, 0.5103]}, {"w": "Activation", "b": [0.2455, 0.4887, 0.3304, 0.5103]}, {"w": "functions", "b": [0.3352, 0.4887, 0.4103, 0.5103]}, {"w": "and", "b": [0.4151, 0.4887, 0.4465, 0.5103]}, {"w": "their", "b": [0.4512, 0.4887, 0.4893, 0.5103]}, {"w": "derivatives", "b": [0.4941, 0.4887, 0.5811, 0.5103]}]}, {"id": "b_4", "type": "paragraph", "text": "Okay! So now you know where neural nets came from, what their architecture is and how to compute their outputs, and you also learned about the backpropagation algo‐ rithm. But what exactly can you do with them?", "words": [{"w": "Okay!", "b": [0.1429, 0.5261, 0.1928, 0.5475]}, {"w": "So", "b": [0.1982, 0.5261, 0.2187, 0.5475]}, {"w": "now", "b": [0.2241, 0.5261, 0.2604, 0.5475]}, {"w": "you", "b": [0.2658, 0.5261, 0.2971, 0.5475]}, {"w": "know", "b": [0.3025, 0.5261, 0.3491, 0.5475]}, {"w": "where", "b": [0.3545, 0.5261, 0.4053, 0.5475]}, {"w": "neural", "b": [0.4107, 0.5261, 0.4642, 0.5475]}, {"w": "nets", "b": [0.4696, 0.5261, 0.5038, 0.5475]}, {"w": "came", "b": [0.5092, 0.5261, 0.5531, 0.5475]}, {"w": "from,", "b": [0.5585, 0.5261, 0.6048, 0.5475]}, {"w": "what", "b": [0.6102, 0.5261, 0.6507, 0.5475]}, {"w": "their", "b": [0.6561, 0.5261, 0.6958, 0.5475]}, {"w": "architecture", "b": [0.7012, 0.5261, 0.8016, 0.5475]}, {"w": "is", "b": [0.807, 0.5261, 0.8202, 0.5475]}, {"w": "and", "b": [0.8256, 0.5261, 0.8571, 0.5475]}, {"w": "how", "b": [0.1429, 0.5451, 0.1789, 0.5665]}, {"w": "to", "b": [0.1843, 0.5451, 0.2013, 0.5665]}, {"w": "compute", "b": [0.2067, 0.5451, 0.28, 0.5665]}, {"w": "their", "b": [0.2854, 0.5451, 0.325, 0.5665]}, {"w": "outputs,", "b": [0.3304, 0.5451, 0.3992, 0.5665]}, {"w": "and", "b": [0.4046, 0.5451, 0.4361, 0.5665]}, {"w": "you", "b": [0.4415, 0.5451, 0.4728, 0.5665]}, {"w": "also", "b": [0.4782, 0.5451, 0.5109, 0.5665]}, {"w": "learned", "b": [0.5163, 0.5451, 0.5785, 0.5665]}, {"w": "about", "b": [0.584, 0.5451, 0.6317, 0.5665]}, {"w": "the", "b": [0.6371, 0.5451, 0.6635, 0.5665]}, {"w": "backpropagation", "b": [0.6689, 0.5451, 0.8095, 0.5665]}, {"w": "algo‐", "b": [0.8149, 0.5451, 0.8572, 0.5665]}, {"w": "rithm.", "b": [0.1429, 0.5642, 0.1955, 0.5856]}, {"w": "But", "b": [0.2002, 0.5642, 0.2299, 0.5856]}, {"w": "what", "b": [0.2346, 0.5642, 0.2751, 0.5856]}, {"w": "exactly", "b": [0.2798, 0.5642, 0.3377, 0.5856]}, {"w": "can", "b": [0.3424, 0.5642, 0.3717, 0.5856]}, {"w": "you", "b": [0.3765, 0.5642, 0.4077, 0.5856]}, {"w": "do", "b": [0.4124, 0.5642, 0.4341, 0.5856]}, {"w": "with", "b": [0.4388, 0.5642, 0.4761, 0.5856]}, {"w": "them?", "b": [0.4809, 0.5642, 0.5322, 0.5856]}]}, {"id": "b_5", "type": "paragraph", "text": "Regression MLPs", "words": [{"w": "Regression", "b": [0.1428, 0.5983, 0.2553, 0.6269]}, {"w": "MLPs", "b": [0.2602, 0.5983, 0.3142, 0.6269]}]}, {"id": "b_6", "type": "paragraph", "text": "First, MLPs can be used for regression tasks. If you want to predict a single value (e.g., the price of a house given many of its features), then you just need a single output neuron: its output is the predicted value. For multivariate regression (i.e., to predict multiple values at once), you need one output neuron per output dimension. For example, to locate the center of an object on an image, you need to predict 2D coordi‐ nates, so you need two output neurons. If you also want to place a bounding box around the object, then you need two more numbers: the width and the height of the object. So you end up with 4 output neurons.", "words": [{"w": "First,", "b": [0.1429, 0.6328, 0.1859, 0.6542]}, {"w": "MLPs", "b": [0.1907, 0.6328, 0.2392, 0.6542]}, {"w": "can", "b": [0.244, 0.6328, 0.2733, 0.6542]}, {"w": "be", "b": [0.2781, 0.6328, 0.2975, 0.6542]}, {"w": "used", "b": [0.3022, 0.6328, 0.3408, 0.6542]}, {"w": "for", "b": [0.3455, 0.6328, 0.37, 0.6542]}, {"w": "regression", "b": [0.3748, 0.6328, 0.4606, 0.6542]}, {"w": "tasks.", "b": [0.4653, 0.6328, 0.5112, 0.6542]}, {"w": "If", "b": [0.5159, 0.6328, 0.5292, 0.6542]}, {"w": "you", "b": [0.5339, 0.6328, 0.5652, 0.6542]}, {"w": "want", "b": [0.5699, 0.6328, 0.6107, 0.6542]}, {"w": "to", "b": [0.6154, 0.6328, 0.6324, 0.6542]}, {"w": "predict", "b": [0.6371, 0.6328, 0.6963, 0.6542]}, {"w": "a", "b": [0.7011, 0.6328, 0.7102, 0.6542]}, {"w": "single", "b": [0.7149, 0.6328, 0.7634, 0.6542]}, {"w": "value", "b": [0.7682, 0.6328, 0.8122, 0.6542]}, {"w": "(e.g.,", "b": [0.8169, 0.6328, 0.8569, 0.6542]}, {"w": "the", "b": [0.1429, 0.6519, 0.1692, 0.6733]}, {"w": "price", "b": [0.1762, 0.6519, 0.2181, 0.6733]}, {"w": "of", "b": [0.225, 0.6519, 0.2418, 0.6733]}, {"w": "a", "b": [0.2488, 0.6519, 0.258, 0.6733]}, {"w": "house", "b": [0.2649, 0.6519, 0.3143, 0.6733]}, {"w": "given", "b": [0.3212, 0.6519, 0.3665, 0.6733]}, {"w": "many", "b": [0.3734, 0.6519, 0.4201, 0.6733]}, {"w": "of", "b": [0.4271, 0.6519, 0.4439, 0.6733]}, {"w": "its", "b": [0.4509, 0.6519, 0.4705, 0.6733]}, {"w": "features),", "b": [0.4774, 0.6519, 0.5548, 0.6733]}, {"w": "then", "b": [0.5618, 0.6519, 0.5995, 0.6733]}, {"w": "you", "b": [0.6065, 0.6519, 0.6377, 0.6733]}, {"w": "just", "b": [0.6447, 0.6519, 0.6751, 0.6733]}, {"w": "need", "b": [0.6821, 0.6519, 0.7222, 0.6733]}, {"w": "a", "b": [0.7292, 0.6519, 0.7383, 0.6733]}, {"w": "single", "b": [0.7453, 0.6519, 0.7938, 0.6733]}, {"w": "output", "b": [0.8008, 0.6519, 0.8572, 0.6733]}, {"w": "neuron:", "b": [0.1429, 0.6709, 0.2087, 0.6923]}, {"w": "its", "b": [0.2151, 0.6709, 0.2347, 0.6923]}, {"w": "output", "b": [0.2411, 0.6709, 0.2975, 0.6923]}, {"w": "is", "b": [0.3039, 0.6709, 0.3172, 0.6923]}, {"w": "the", "b": [0.3236, 0.6709, 0.3499, 0.6923]}, {"w": "predicted", "b": [0.3564, 0.6709, 0.4355, 0.6923]}, {"w": "value.", "b": [0.4419, 0.6709, 0.4906, 0.6923]}, {"w": "For", "b": [0.4971, 0.6709, 0.526, 0.6923]}, {"w": "multivariate", "b": [0.5325, 0.6709, 0.6335, 0.6923]}, {"w": "regression", "b": [0.6399, 0.6709, 0.7257, 0.6923]}, {"w": "(i.e.,", "b": [0.7322, 0.6709, 0.768, 0.6923]}, {"w": "to", "b": [0.7745, 0.6709, 0.7915, 0.6923]}, {"w": "predict", "b": [0.7979, 0.6709, 0.8571, 0.6923]}, {"w": "multiple", "b": [0.1429, 0.69, 0.2128, 0.7114]}, {"w": "values", "b": [0.2211, 0.69, 0.2727, 0.7114]}, {"w": "at", "b": [0.281, 0.69, 0.2961, 0.7114]}, {"w": "once),", "b": [0.3044, 0.69, 0.3561, 0.7114]}, {"w": "you", "b": [0.3644, 0.69, 0.3956, 0.7114]}, {"w": "need", "b": [0.4039, 0.69, 0.444, 0.7114]}, {"w": "one", "b": [0.4523, 0.69, 0.4832, 0.7114]}, {"w": "output", "b": [0.4915, 0.69, 0.5479, 0.7114]}, {"w": "neuron", "b": [0.5562, 0.69, 0.6172, 0.7114]}, {"w": "per", "b": [0.6255, 0.69, 0.653, 0.7114]}, {"w": "output", "b": [0.6613, 0.69, 0.7177, 0.7114]}, {"w": "dimension.", "b": [0.726, 0.69, 0.8199, 0.7114]}, {"w": "For", "b": [0.8282, 0.69, 0.8571, 0.7114]}, {"w": "example,", "b": [0.1429, 0.709, 0.2172, 0.7304]}, {"w": "to", "b": [0.2219, 0.709, 0.2389, 0.7304]}, {"w": "locate", "b": [0.2436, 0.709, 0.2923, 0.7304]}, {"w": "the", "b": [0.297, 0.709, 0.3233, 0.7304]}, {"w": "center", "b": [0.3281, 0.709, 0.3797, 0.7304]}, {"w": "of", "b": [0.3844, 0.709, 0.4012, 0.7304]}, {"w": "an", "b": [0.4059, 0.709, 0.4265, 0.7304]}, {"w": "object", "b": [0.4312, 0.709, 0.4817, 0.7304]}, {"w": "on", "b": [0.4865, 0.709, 0.5085, 0.7304]}, {"w": "an", "b": [0.5132, 0.709, 0.5338, 0.7304]}, {"w": "image,", "b": [0.5385, 0.709, 0.5936, 0.7304]}, {"w": "you", "b": [0.5984, 0.709, 0.6296, 0.7304]}, {"w": "need", "b": [0.6343, 0.709, 0.6745, 0.7304]}, {"w": "to", "b": [0.6792, 0.709, 0.6962, 0.7304]}, {"w": "predict", "b": [0.7009, 0.709, 0.7601, 0.7304]}, {"w": "2D", "b": [0.7649, 0.709, 0.7902, 0.7304]}, {"w": "coordi‐", "b": [0.7949, 0.709, 0.8567, 0.7304]}, {"w": "nates,", "b": [0.1429, 0.728, 0.1906, 0.7495]}, {"w": "so", "b": [0.1984, 0.728, 0.2166, 0.7495]}, {"w": "you", "b": [0.2244, 0.728, 0.2556, 0.7495]}, {"w": "need", "b": [0.2634, 0.728, 0.3035, 0.7495]}, {"w": "two", "b": [0.3113, 0.728, 0.3425, 0.7495]}, {"w": "output", "b": [0.3503, 0.728, 0.4066, 0.7495]}, {"w": "neurons.", "b": [0.4144, 0.728, 0.4878, 0.7495]}, {"w": "If", "b": [0.4956, 0.728, 0.5089, 0.7495]}, {"w": "you", "b": [0.5166, 0.728, 0.5479, 0.7495]}, {"w": "also", "b": [0.5556, 0.728, 0.5883, 0.7495]}, {"w": "want", "b": [0.5961, 0.728, 0.6368, 0.7495]}, {"w": "to", "b": [0.6446, 0.728, 0.6616, 0.7495]}, {"w": "place", "b": [0.6693, 0.728, 0.7123, 0.7495]}, {"w": "a", "b": [0.7201, 0.728, 0.7292, 0.7495]}, {"w": "bounding", "b": [0.737, 0.728, 0.8184, 0.7495]}, {"w": "box", "b": [0.8261, 0.728, 0.8572, 0.7495]}, {"w": "around", "b": [0.1429, 0.7471, 0.2038, 0.7685]}, {"w": "the", "b": [0.2092, 0.7471, 0.2355, 0.7685]}, {"w": "object,", "b": [0.2409, 0.7471, 0.2962, 0.7685]}, {"w": "then", "b": [0.3015, 0.7471, 0.3393, 0.7685]}, {"w": "you", "b": [0.3446, 0.7471, 0.3759, 0.7685]}, {"w": "need", "b": [0.3812, 0.7471, 0.4213, 0.7685]}, {"w": "two", "b": [0.4267, 0.7471, 0.4579, 0.7685]}, {"w": "more", "b": [0.4633, 0.7471, 0.5076, 0.7685]}, {"w": "numbers:", "b": [0.5129, 0.7471, 0.5916, 0.7685]}, {"w": "the", "b": [0.597, 0.7471, 0.6233, 0.7685]}, {"w": "width", "b": [0.6286, 0.7471, 0.677, 0.7685]}, {"w": "and", "b": [0.6823, 0.7471, 0.7139, 0.7685]}, {"w": "the", "b": [0.7192, 0.7471, 0.7456, 0.7685]}, {"w": "height", "b": [0.7509, 0.7471, 0.8033, 0.7685]}, {"w": "of", "b": [0.8087, 0.7471, 0.8255, 0.7685]}, {"w": "the", "b": [0.8308, 0.7471, 0.8571, 0.7685]}, {"w": "object.", "b": [0.1429, 0.7661, 0.1982, 0.7876]}, {"w": "So", "b": [0.2029, 0.7661, 0.2234, 0.7876]}, {"w": "you", "b": [0.2281, 0.7661, 0.2594, 0.7876]}, {"w": "end", "b": [0.2641, 0.7661, 0.2954, 0.7876]}, {"w": "up", "b": [0.3001, 0.7661, 0.3221, 0.7876]}, {"w": "with", "b": [0.3268, 0.7661, 0.3641, 0.7876]}, {"w": "4", "b": [0.3689, 0.7661, 0.3789, 0.7876]}, {"w": "output", "b": [0.3836, 0.7661, 0.44, 0.7876]}, {"w": "neurons.", "b": [0.4447, 0.7661, 0.5181, 0.7876]}]}, {"id": "b_7", "type": "paragraph", "text": "From Biological to Artificial Neurons | 289", "words": [{"w": "From", "b": [0.585, 0.9225, 0.6155, 0.9388]}, {"w": "Biological", "b": [0.6183, 0.9225, 0.6761, 0.9388]}, {"w": "to", "b": [0.679, 0.9225, 0.6914, 0.9388]}, {"w": "Artificial", "b": [0.6942, 0.9225, 0.7441, 0.9388]}, {"w": "Neurons", "b": [0.7469, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "289", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 316, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "In general, when building an MLP for regression, you do not want to use any activa‐ tion function for the output neurons, so they are free to output any range of values. However, if you want to guarantee that the output will always be positive, then you can use the ReLU activation function, or the softplus activation function in the output layer. Finally, if you want to guarantee that the predictions will fall within a given range of values, then you can use the logistic function or the hyperbolic tangent, and scale the labels to the appropriate range: 0 to 1 for the logistic function, or –1 to 1 for the hyperbolic tangent.", "words": [{"w": "In", "b": [0.1429, 0.0791, 0.1614, 0.1005]}, {"w": "general,", "b": [0.167, 0.0791, 0.2328, 0.1005]}, {"w": "when", "b": [0.2384, 0.0791, 0.2841, 0.1005]}, {"w": "building", "b": [0.2897, 0.0791, 0.3599, 0.1005]}, {"w": "an", "b": [0.3656, 0.0791, 0.3861, 0.1005]}, {"w": "MLP", "b": [0.3918, 0.0791, 0.4333, 0.1005]}, {"w": "for", "b": [0.4389, 0.0791, 0.4634, 0.1005]}, {"w": "regression,", "b": [0.4691, 0.0791, 0.5597, 0.1005]}, {"w": "you", "b": [0.5653, 0.0791, 0.5966, 0.1005]}, {"w": "do", "b": [0.6022, 0.0791, 0.6238, 0.1005]}, {"w": "not", "b": [0.6295, 0.0791, 0.6579, 0.1005]}, {"w": "want", "b": [0.6635, 0.0791, 0.7043, 0.1005]}, {"w": "to", "b": [0.7099, 0.0791, 0.7269, 0.1005]}, {"w": "use", "b": [0.7326, 0.0791, 0.7601, 0.1005]}, {"w": "any", "b": [0.7658, 0.0791, 0.7954, 0.1005]}, {"w": "activa‐", "b": [0.801, 0.0791, 0.8571, 0.1005]}, {"w": "tion", "b": [0.1429, 0.0981, 0.1768, 0.1195]}, {"w": "function", "b": [0.1831, 0.0981, 0.2545, 0.1195]}, {"w": "for", "b": [0.2607, 0.0981, 0.2852, 0.1195]}, {"w": "the", "b": [0.2915, 0.0981, 0.3178, 0.1195]}, {"w": "output", "b": [0.3241, 0.0981, 0.3804, 0.1195]}, {"w": "neurons,", "b": [0.3867, 0.0981, 0.4601, 0.1195]}, {"w": "so", "b": [0.4664, 0.0981, 0.4847, 0.1195]}, {"w": "they", "b": [0.4909, 0.0981, 0.5268, 0.1195]}, {"w": "are", "b": [0.533, 0.0981, 0.5588, 0.1195]}, {"w": "free", "b": [0.565, 0.0981, 0.5966, 0.1195]}, {"w": "to", "b": [0.6029, 0.0981, 0.6199, 0.1195]}, {"w": "output", "b": [0.6261, 0.0981, 0.6825, 0.1195]}, {"w": "any", "b": [0.6887, 0.0981, 0.7184, 0.1195]}, {"w": "range", "b": [0.7246, 0.0981, 0.7715, 0.1195]}, {"w": "of", "b": [0.7777, 0.0981, 0.7945, 0.1195]}, {"w": "values.", "b": [0.8008, 0.0981, 0.8571, 0.1195]}, {"w": "However,", "b": [0.1429, 0.1172, 0.2217, 0.1386]}, {"w": "if", "b": [0.2284, 0.1172, 0.2402, 0.1386]}, {"w": "you", "b": [0.2469, 0.1172, 0.2782, 0.1386]}, {"w": "want", "b": [0.2849, 0.1172, 0.3256, 0.1386]}, {"w": "to", "b": [0.3324, 0.1172, 0.3493, 0.1386]}, {"w": "guarantee", "b": [0.3561, 0.1172, 0.438, 0.1386]}, {"w": "that", "b": [0.4447, 0.1172, 0.4773, 0.1386]}, {"w": "the", "b": [0.484, 0.1172, 0.5103, 0.1386]}, {"w": "output", "b": [0.517, 0.1172, 0.5734, 0.1386]}, {"w": "will", "b": [0.5801, 0.1172, 0.6105, 0.1386]}, {"w": "always", "b": [0.6172, 0.1172, 0.6719, 0.1386]}, {"w": "be", "b": [0.6786, 0.1172, 0.6981, 0.1386]}, {"w": "positive,", "b": [0.7048, 0.1172, 0.7747, 0.1386]}, {"w": "then", "b": [0.7815, 0.1172, 0.8192, 0.1386]}, {"w": "you", "b": [0.8259, 0.1172, 0.8572, 0.1386]}, {"w": "can", "b": [0.1429, 0.1362, 0.1722, 0.1576]}, {"w": "use", "b": [0.1772, 0.1362, 0.2048, 0.1576]}, {"w": "the", "b": [0.2098, 0.1362, 0.2361, 0.1576]}, {"w": "ReLU", "b": [0.2411, 0.1362, 0.2886, 0.1576]}, {"w": "activation", "b": [0.2936, 0.1362, 0.3759, 0.1576]}, {"w": "function,", "b": [0.3809, 0.1362, 0.457, 0.1576]}, {"w": "or", "b": [0.462, 0.1362, 0.4804, 0.1576]}, {"w": "the", "b": [0.4854, 0.1362, 0.5117, 0.1576]}, {"w": "softplus", "b": [0.5167, 0.136, 0.5788, 0.1576]}, {"w": "activation", "b": [0.5838, 0.1362, 0.666, 0.1576]}, {"w": "function", "b": [0.671, 0.1362, 0.7424, 0.1576]}, {"w": "in", "b": [0.7474, 0.1362, 0.7644, 0.1576]}, {"w": "the", "b": [0.7694, 0.1362, 0.7958, 0.1576]}, {"w": "output", "b": [0.8008, 0.1362, 0.8571, 0.1576]}, {"w": "layer.", "b": [0.1429, 0.1553, 0.1865, 0.1767]}, {"w": "Finally,", "b": [0.1943, 0.1553, 0.2548, 0.1767]}, {"w": "if", "b": [0.2626, 0.1553, 0.2743, 0.1767]}, {"w": "you", "b": [0.2821, 0.1553, 0.3134, 0.1767]}, {"w": "want", "b": [0.3212, 0.1553, 0.3619, 0.1767]}, {"w": "to", "b": [0.3697, 0.1553, 0.3867, 0.1767]}, {"w": "guarantee", "b": [0.3945, 0.1553, 0.4764, 0.1767]}, {"w": "that", "b": [0.4842, 0.1553, 0.5168, 0.1767]}, {"w": "the", "b": [0.5246, 0.1553, 0.5509, 0.1767]}, {"w": "predictions", "b": [0.5587, 0.1553, 0.6532, 0.1767]}, {"w": "will", "b": [0.661, 0.1553, 0.6914, 0.1767]}, {"w": "fall", "b": [0.6992, 0.1553, 0.7251, 0.1767]}, {"w": "within", "b": [0.7329, 0.1553, 0.7872, 0.1767]}, {"w": "a", "b": [0.795, 0.1553, 0.8041, 0.1767]}, {"w": "given", "b": [0.8119, 0.1553, 0.8571, 0.1767]}, {"w": "range", "b": [0.1429, 0.1743, 0.1897, 0.1957]}, {"w": "of", "b": [0.1954, 0.1743, 0.2121, 0.1957]}, {"w": "values,", "b": [0.2178, 0.1743, 0.2741, 0.1957]}, {"w": "then", "b": [0.2797, 0.1743, 0.3175, 0.1957]}, {"w": "you", "b": [0.3231, 0.1743, 0.3543, 0.1957]}, {"w": "can", "b": [0.36, 0.1743, 0.3893, 0.1957]}, {"w": "use", "b": [0.3949, 0.1743, 0.4225, 0.1957]}, {"w": "the", "b": [0.4281, 0.1743, 0.4544, 0.1957]}, {"w": "logistic", "b": [0.46, 0.1743, 0.5197, 0.1957]}, {"w": "function", "b": [0.5253, 0.1743, 0.5967, 0.1957]}, {"w": "or", "b": [0.6023, 0.1743, 0.6206, 0.1957]}, {"w": "the", "b": [0.6263, 0.1743, 0.6526, 0.1957]}, {"w": "hyperbolic", "b": [0.6582, 0.1743, 0.7468, 0.1957]}, {"w": "tangent,", "b": [0.7524, 0.1743, 0.82, 0.1957]}, {"w": "and", "b": [0.8256, 0.1743, 0.8572, 0.1957]}, {"w": "scale", "b": [0.1429, 0.1933, 0.1826, 0.2148]}, {"w": "the", "b": [0.1879, 0.1933, 0.2142, 0.2148]}, {"w": "labels", "b": [0.2195, 0.1933, 0.2663, 0.2148]}, {"w": "to", "b": [0.2715, 0.1933, 0.2885, 0.2148]}, {"w": "the", "b": [0.2938, 0.1933, 0.3201, 0.2148]}, {"w": "appropriate", "b": [0.3254, 0.1933, 0.4225, 0.2148]}, {"w": "range:", "b": [0.4278, 0.1933, 0.4795, 0.2148]}, {"w": "0", "b": [0.4847, 0.1933, 0.4947, 0.2148]}, {"w": "to", "b": [0.5, 0.1933, 0.517, 0.2148]}, {"w": "1", "b": [0.5223, 0.1933, 0.5323, 0.2148]}, {"w": "for", "b": [0.5376, 0.1933, 0.5621, 0.2148]}, {"w": "the", "b": [0.5674, 0.1933, 0.5937, 0.2148]}, {"w": "logistic", "b": [0.599, 0.1933, 0.6586, 0.2148]}, {"w": "function,", "b": [0.6639, 0.1933, 0.74, 0.2148]}, {"w": "or", "b": [0.7453, 0.1933, 0.7637, 0.2148]}, {"w": "–1", "b": [0.769, 0.1933, 0.7898, 0.2148]}, {"w": "to", "b": [0.7951, 0.1933, 0.8121, 0.2148]}, {"w": "1", "b": [0.8173, 0.1933, 0.8273, 0.2148]}, {"w": "for", "b": [0.8326, 0.1933, 0.8571, 0.2148]}, {"w": "the", "b": [0.1429, 0.2124, 0.1692, 0.2338]}, {"w": "hyperbolic", "b": [0.1739, 0.2124, 0.2625, 0.2338]}, {"w": "tangent.", "b": [0.2672, 0.2124, 0.3348, 0.2338]}]}, {"id": "b_1", "type": "paragraph", "text": "The loss function to use during training is typically the mean squared error, but if you have a lot of outliers in the training set, you may prefer to use the mean absolute error instead. Alternatively, you can use the Huber loss, which is a combination of both.", "words": [{"w": "The", "b": [0.1429, 0.2405, 0.1757, 0.2619]}, {"w": "loss", "b": [0.1804, 0.2405, 0.2116, 0.2619]}, {"w": "function", "b": [0.2163, 0.2405, 0.2877, 0.2619]}, {"w": "to", "b": [0.2925, 0.2405, 0.3094, 0.2619]}, {"w": "use", "b": [0.3142, 0.2405, 0.3417, 0.2619]}, {"w": "during", "b": [0.3465, 0.2405, 0.403, 0.2619]}, {"w": "training", "b": [0.4077, 0.2405, 0.4746, 0.2619]}, {"w": "is", "b": [0.4794, 0.2405, 0.4926, 0.2619]}, {"w": "typically", "b": [0.4973, 0.2405, 0.5678, 0.2619]}, {"w": "the", "b": [0.5725, 0.2405, 0.5989, 0.2619]}, {"w": "mean", "b": [0.6036, 0.2405, 0.6501, 0.2619]}, {"w": "squared", "b": [0.6548, 0.2405, 0.7209, 0.2619]}, {"w": "error,", "b": [0.7256, 0.2405, 0.7717, 0.2619]}, {"w": "but", "b": [0.7764, 0.2405, 0.8044, 0.2619]}, {"w": "if", "b": [0.8092, 0.2405, 0.8209, 0.2619]}, {"w": "you", "b": [0.8256, 0.2405, 0.8569, 0.2619]}, {"w": "have", "b": [0.1429, 0.2596, 0.1813, 0.281]}, {"w": "a", "b": [0.1889, 0.2596, 0.1981, 0.281]}, {"w": "lot", "b": [0.2058, 0.2596, 0.228, 0.281]}, {"w": "of", "b": [0.2357, 0.2596, 0.2525, 0.281]}, {"w": "outliers", "b": [0.2602, 0.2596, 0.3233, 0.281]}, {"w": "in", "b": [0.331, 0.2596, 0.348, 0.281]}, {"w": "the", "b": [0.3556, 0.2596, 0.382, 0.281]}, {"w": "training", "b": [0.3897, 0.2596, 0.4566, 0.281]}, {"w": "set,", "b": [0.4643, 0.2596, 0.4919, 0.281]}, {"w": "you", "b": [0.4996, 0.2596, 0.5308, 0.281]}, {"w": "may", "b": [0.5385, 0.2596, 0.5739, 0.281]}, {"w": "prefer", "b": [0.5816, 0.2596, 0.6318, 0.281]}, {"w": "to", "b": [0.6395, 0.2596, 0.6565, 0.281]}, {"w": "use", "b": [0.6642, 0.2596, 0.6918, 0.281]}, {"w": "the", "b": [0.6994, 0.2596, 0.7258, 0.281]}, {"w": "mean", "b": [0.7335, 0.2596, 0.7799, 0.281]}, {"w": "absolute", "b": [0.7876, 0.2596, 0.8571, 0.281]}, {"w": "error", "b": [0.1428, 0.2786, 0.1855, 0.3]}, {"w": "instead.", "b": [0.1928, 0.2786, 0.2576, 0.3]}, {"w": "Alternatively,", "b": [0.2649, 0.2786, 0.3761, 0.3]}, {"w": "you", "b": [0.3834, 0.2786, 0.4147, 0.3]}, {"w": "can", "b": [0.422, 0.2786, 0.4513, 0.3]}, {"w": "use", "b": [0.4586, 0.2786, 0.4862, 0.3]}, {"w": "the", "b": [0.4935, 0.2786, 0.5198, 0.3]}, {"w": "Huber", "b": [0.5271, 0.2786, 0.5805, 0.3]}, {"w": "loss,", "b": [0.5878, 0.2786, 0.6238, 0.3]}, {"w": "which", "b": [0.6311, 0.2786, 0.682, 0.3]}, {"w": "is", "b": [0.6893, 0.2786, 0.7025, 0.3]}, {"w": "a", "b": [0.7098, 0.2786, 0.719, 0.3]}, {"w": "combination", "b": [0.7263, 0.2786, 0.833, 0.3]}, {"w": "of", "b": [0.8403, 0.2786, 0.8571, 0.3]}, {"w": "both.", "b": [0.1429, 0.2977, 0.1863, 0.3191]}]}, {"id": "b_2", "type": "paragraph", "text": "The Huber loss is quadratic when the error is smaller than a thres‐ hold δ (typically 1), but linear when the error is larger than δ. This makes it less sensitive to outliers than the mean squared error, and it is often more precise and converges faster than the mean abso‐ lute error.", "words": [{"w": "The", "b": [0.2714, 0.3396, 0.3014, 0.3592]}, {"w": "Huber", "b": [0.3066, 0.3396, 0.3554, 0.3592]}, {"w": "loss", "b": [0.3605, 0.3396, 0.3891, 0.3592]}, {"w": "is", "b": [0.3942, 0.3396, 0.4063, 0.3592]}, {"w": "quadratic", "b": [0.4115, 0.3396, 0.4838, 0.3592]}, {"w": "when", "b": [0.4889, 0.3396, 0.5307, 0.3592]}, {"w": "the", "b": [0.5358, 0.3396, 0.5599, 0.3592]}, {"w": "error", "b": [0.565, 0.3396, 0.604, 0.3592]}, {"w": "is", "b": [0.6092, 0.3396, 0.6213, 0.3592]}, {"w": "smaller", "b": [0.6265, 0.3396, 0.6822, 0.3592]}, {"w": "than", "b": [0.6874, 0.3396, 0.7221, 0.3592]}, {"w": "a", "b": [0.7273, 0.3396, 0.7356, 0.3592]}, {"w": "thres‐", "b": [0.7408, 0.3396, 0.7857, 0.3592]}, {"w": "hold", "b": [0.2714, 0.357, 0.3062, 0.3766]}, {"w": "δ", "b": [0.3112, 0.357, 0.3207, 0.3766]}, {"w": "(typically", "b": [0.3257, 0.357, 0.3968, 0.3766]}, {"w": "1),", "b": [0.4018, 0.357, 0.4219, 0.3766]}, {"w": "but", "b": [0.4269, 0.357, 0.4525, 0.3766]}, {"w": "linear", "b": [0.4576, 0.357, 0.5015, 0.3766]}, {"w": "when", "b": [0.5065, 0.357, 0.5483, 0.3766]}, {"w": "the", "b": [0.5533, 0.357, 0.5774, 0.3766]}, {"w": "error", "b": [0.5824, 0.357, 0.6214, 0.3766]}, {"w": "is", "b": [0.6265, 0.357, 0.6386, 0.3766]}, {"w": "larger", "b": [0.6436, 0.357, 0.688, 0.3766]}, {"w": "than", "b": [0.693, 0.357, 0.7278, 0.3766]}, {"w": "δ.", "b": [0.7328, 0.357, 0.7466, 0.3766]}, {"w": "This", "b": [0.7517, 0.357, 0.7857, 0.3766]}, {"w": "makes", "b": [0.2714, 0.3744, 0.3199, 0.394]}, {"w": "it", "b": [0.325, 0.3744, 0.336, 0.394]}, {"w": "less", "b": [0.3411, 0.3744, 0.368, 0.394]}, {"w": "sensitive", "b": [0.3732, 0.3744, 0.4386, 0.394]}, {"w": "to", "b": [0.4437, 0.3744, 0.4592, 0.394]}, {"w": "outliers", "b": [0.4644, 0.3744, 0.5221, 0.394]}, {"w": "than", "b": [0.5273, 0.3744, 0.562, 0.394]}, {"w": "the", "b": [0.5672, 0.3744, 0.5912, 0.394]}, {"w": "mean", "b": [0.5964, 0.3744, 0.6389, 0.394]}, {"w": "squared", "b": [0.644, 0.3744, 0.7044, 0.394]}, {"w": "error,", "b": [0.7096, 0.3744, 0.7517, 0.394]}, {"w": "and", "b": [0.7569, 0.3744, 0.7857, 0.394]}, {"w": "it", "b": [0.2714, 0.3918, 0.2823, 0.4114]}, {"w": "is", "b": [0.2885, 0.3918, 0.3006, 0.4114]}, {"w": "often", "b": [0.3069, 0.3918, 0.3465, 0.4114]}, {"w": "more", "b": [0.3527, 0.3918, 0.3932, 0.4114]}, {"w": "precise", "b": [0.3994, 0.3918, 0.4528, 0.4114]}, {"w": "and", "b": [0.459, 0.3918, 0.4879, 0.4114]}, {"w": "converges", "b": [0.4941, 0.3918, 0.5698, 0.4114]}, {"w": "faster", "b": [0.576, 0.3918, 0.618, 0.4114]}, {"w": "than", "b": [0.6242, 0.3918, 0.659, 0.4114]}, {"w": "the", "b": [0.6652, 0.3918, 0.6893, 0.4114]}, {"w": "mean", "b": [0.6955, 0.3918, 0.738, 0.4114]}, {"w": "abso‐", "b": [0.7442, 0.3918, 0.7857, 0.4114]}, {"w": "lute", "b": [0.2714, 0.4093, 0.3002, 0.4288]}, {"w": "error.", "b": [0.3046, 0.4093, 0.3467, 0.4288]}]}, {"id": "b_3", "type": "equation", "text": "Table 10-1 summarizes the typical architecture of a regression MLP.", "words": [{"w": "Table", "b": [0.1428, 0.4491, 0.1876, 0.4705]}, {"w": "10-1", "b": [0.1924, 0.4491, 0.2298, 0.4705]}, {"w": "summarizes", "b": [0.2345, 0.4491, 0.3351, 0.4705]}, {"w": "the", "b": [0.3398, 0.4491, 0.3661, 0.4705]}, {"w": "typical", "b": [0.3708, 0.4491, 0.4265, 0.4705]}, {"w": "architecture", "b": [0.4312, 0.4491, 0.5316, 0.4705]}, {"w": "of", "b": [0.5364, 0.4491, 0.5532, 0.4705]}, {"w": "a", "b": [0.5579, 0.4491, 0.567, 0.4705]}, {"w": "regression", "b": [0.5718, 0.4491, 0.6576, 0.4705]}, {"w": "MLP.", "b": [0.6623, 0.4491, 0.7057, 0.4705]}]}, {"id": "b_4", "type": "equation", "text": "Table 10-1. Typical Regression MLP Architecture", "words": [{"w": "Table", "b": [0.1429, 0.487, 0.1844, 0.5076]}, {"w": "10-1.", "b": [0.189, 0.487, 0.2287, 0.5076]}, {"w": "Typical", "b": [0.2332, 0.487, 0.2893, 0.5076]}, {"w": "Regression", "b": [0.2939, 0.487, 0.3746, 0.5076]}, {"w": "MLP", "b": [0.3791, 0.487, 0.418, 0.5076]}, {"w": "Architecture", "b": [0.4226, 0.487, 0.5173, 0.5076]}]}, {"id": "b_5", "type": "paragraph", "text": "Hyperparameter Typical Value # input neurons One per input feature (e.g., 28 x 28 = 784 for MNIST)", "words": [{"w": "Hyperparameter", "b": [0.15, 0.5155, 0.2472, 0.5318]}, {"w": "Typical", "b": [0.3128, 0.5155, 0.3537, 0.5318]}, {"w": "Value", "b": [0.3572, 0.5155, 0.3905, 0.5318]}, {"w": "#", "b": [0.15, 0.5359, 0.1569, 0.552]}, {"w": "input", "b": [0.1603, 0.5359, 0.1896, 0.552]}, {"w": "neurons", "b": [0.193, 0.5359, 0.2375, 0.552]}, {"w": "One", "b": [0.3128, 0.5359, 0.3344, 0.552]}, {"w": "per", "b": [0.3378, 0.5359, 0.3559, 0.552]}, {"w": "input", "b": [0.3593, 0.5359, 0.3886, 0.552]}, {"w": "feature", "b": [0.392, 0.5359, 0.4316, 0.552]}, {"w": "(e.g.,", "b": [0.435, 0.5359, 0.4635, 0.552]}, {"w": "28", "b": [0.4669, 0.5359, 0.4807, 0.552]}, {"w": "x", "b": [0.4841, 0.5359, 0.4901, 0.552]}, {"w": "28", "b": [0.4935, 0.5359, 0.5073, 0.552]}, {"w": "=", "b": [0.5107, 0.5359, 0.5213, 0.552]}, {"w": "784", "b": [0.5247, 0.5359, 0.5454, 0.552]}, {"w": "for", "b": [0.5487, 0.5359, 0.5641, 0.552]}, {"w": "MNIST)", "b": [0.5675, 0.5359, 0.6073, 0.552]}]}, {"id": "b_6", "type": "paragraph", "text": "# hidden layers Depends on the problem. Typically 1 to 5.", "words": [{"w": "#", "b": [0.15, 0.5569, 0.1569, 0.573]}, {"w": "hidden", "b": [0.1603, 0.5569, 0.1988, 0.573]}, {"w": "layers", "b": [0.2021, 0.5569, 0.2343, 0.573]}, {"w": "Depends", "b": [0.3128, 0.5569, 0.3603, 0.573]}, {"w": "on", "b": [0.3637, 0.5569, 0.3778, 0.573]}, {"w": "the", "b": [0.3812, 0.5569, 0.3994, 0.573]}, {"w": "problem.", "b": [0.4029, 0.5569, 0.4528, 0.573]}, {"w": "Typically", "b": [0.4562, 0.5569, 0.504, 0.573]}, {"w": "1", "b": [0.5074, 0.5569, 0.5143, 0.573]}, {"w": "to", "b": [0.5177, 0.5569, 0.5291, 0.573]}, {"w": "5.", "b": [0.5325, 0.5569, 0.5428, 0.573]}]}, {"id": "b_7", "type": "paragraph", "text": "# neurons per hidden layer Depends on the problem. Typically 10 to 100.", "words": [{"w": "#", "b": [0.15, 0.5779, 0.1569, 0.594]}, {"w": "neurons", "b": [0.1603, 0.5779, 0.2048, 0.594]}, {"w": "per", "b": [0.2081, 0.5779, 0.2262, 0.594]}, {"w": "hidden", "b": [0.2296, 0.5779, 0.2681, 0.594]}, {"w": "layer", "b": [0.2715, 0.5779, 0.2985, 0.594]}, {"w": "Depends", "b": [0.3128, 0.5779, 0.3603, 0.594]}, {"w": "on", "b": [0.3637, 0.5779, 0.3778, 0.594]}, {"w": "the", "b": [0.3812, 0.5779, 0.3994, 0.594]}, {"w": "problem.", "b": [0.4029, 0.5779, 0.4528, 0.594]}, {"w": "Typically", "b": [0.4562, 0.5779, 0.504, 0.594]}, {"w": "10", "b": [0.5074, 0.5779, 0.5211, 0.594]}, {"w": "to", "b": [0.5245, 0.5779, 0.5359, 0.594]}, {"w": "100.", "b": [0.5393, 0.5779, 0.5634, 0.594]}]}, {"id": "b_8", "type": "paragraph", "text": "# output neurons 1 per prediction dimension", "words": [{"w": "#", "b": [0.15, 0.5989, 0.1569, 0.615]}, {"w": "output", "b": [0.1603, 0.5989, 0.1976, 0.615]}, {"w": "neurons", "b": [0.201, 0.5989, 0.2454, 0.615]}, {"w": "1", "b": [0.3128, 0.5989, 0.3196, 0.615]}, {"w": "per", "b": [0.323, 0.5989, 0.3411, 0.615]}, {"w": "prediction", "b": [0.3445, 0.5989, 0.4002, 0.615]}, {"w": "dimension", "b": [0.4036, 0.5989, 0.4613, 0.615]}]}, {"id": "b_9", "type": "paragraph", "text": "Hidden activation ReLU (or SELU, see Chapter 11)", "words": [{"w": "Hidden", "b": [0.15, 0.6199, 0.1895, 0.6361]}, {"w": "activation", "b": [0.1929, 0.6199, 0.2473, 0.6361]}, {"w": "ReLU", "b": [0.3128, 0.6199, 0.3409, 0.6361]}, {"w": "(or", "b": [0.3442, 0.6199, 0.36, 0.6361]}, {"w": "SELU,", "b": [0.3634, 0.6199, 0.394, 0.6361]}, {"w": "see", "b": [0.3974, 0.6199, 0.4155, 0.6361]}, {"w": "Chapter", "b": [0.4189, 0.6199, 0.4619, 0.6361]}, {"w": "11)", "b": [0.4653, 0.6199, 0.4835, 0.6361]}]}, {"id": "b_10", "type": "paragraph", "text": "Output activation None or ReLU/Softplus (if positive outputs) or Logistic/Tanh (if bounded outputs)", "words": [{"w": "Output", "b": [0.15, 0.6409, 0.1884, 0.6571]}, {"w": "activation", "b": [0.1918, 0.6409, 0.2461, 0.6571]}, {"w": "None", "b": [0.3128, 0.6409, 0.3416, 0.6571]}, {"w": "or", "b": [0.345, 0.6409, 0.3563, 0.6571]}, {"w": "ReLU/Softplus", "b": [0.3597, 0.6409, 0.4375, 0.6571]}, {"w": "(if", "b": [0.4409, 0.6409, 0.4528, 0.6571]}, {"w": "positive", "b": [0.4562, 0.6409, 0.4991, 0.6571]}, {"w": "outputs)", "b": [0.5025, 0.6409, 0.5495, 0.6571]}, {"w": "or", "b": [0.5529, 0.6409, 0.5641, 0.6571]}, {"w": "Logistic/Tanh", "b": [0.5675, 0.6409, 0.6416, 0.6571]}, {"w": "(if", "b": [0.645, 0.6409, 0.6569, 0.6571]}, {"w": "bounded", "b": [0.6603, 0.6409, 0.7093, 0.6571]}, {"w": "outputs)", "b": [0.7127, 0.6409, 0.7597, 0.6571]}]}, {"id": "b_11", "type": "equation", "text": "Loss function MSE or MAE/Huber (if outliers)", "words": [{"w": "Loss", "b": [0.15, 0.662, 0.1733, 0.6781]}, {"w": "function", "b": [0.1767, 0.662, 0.2224, 0.6781]}, {"w": "MSE", "b": [0.3128, 0.662, 0.3362, 0.6781]}, {"w": "or", "b": [0.3396, 0.662, 0.3509, 0.6781]}, {"w": "MAE/Huber", "b": [0.3543, 0.662, 0.4175, 0.6781]}, {"w": "(if", "b": [0.4209, 0.662, 0.4328, 0.6781]}, {"w": "outliers)", "b": [0.4362, 0.662, 0.482, 0.6781]}]}, {"id": "b_12", "type": "paragraph", "text": "Classification MLPs", "words": [{"w": "Classification", "b": [0.1428, 0.6957, 0.2778, 0.7243]}, {"w": "MLPs", "b": [0.2827, 0.6957, 0.3367, 0.7243]}]}, {"id": "b_13", "type": "paragraph", "text": "MLPs can also be used for classification tasks. For a binary classification problem, you just need a single output neuron using the logistic activation function: the output will be a number between 0 and 1, which you can interpret as the estimated probabil‐ ity of the positive class. Obviously, the estimated probability of the negative class is equal to one minus that number.", "words": [{"w": "MLPs", "b": [0.1429, 0.7302, 0.1914, 0.7516]}, {"w": "can", "b": [0.1991, 0.7302, 0.2284, 0.7516]}, {"w": "also", "b": [0.2361, 0.7302, 0.2688, 0.7516]}, {"w": "be", "b": [0.2765, 0.7302, 0.2959, 0.7516]}, {"w": "used", "b": [0.3036, 0.7302, 0.3421, 0.7516]}, {"w": "for", "b": [0.3498, 0.7302, 0.3743, 0.7516]}, {"w": "classification", "b": [0.382, 0.7302, 0.4894, 0.7516]}, {"w": "tasks.", "b": [0.497, 0.7302, 0.5429, 0.7516]}, {"w": "For", "b": [0.5506, 0.7302, 0.5796, 0.7516]}, {"w": "a", "b": [0.5872, 0.7302, 0.5964, 0.7516]}, {"w": "binary", "b": [0.604, 0.7302, 0.6586, 0.7516]}, {"w": "classification", "b": [0.6663, 0.7302, 0.7737, 0.7516]}, {"w": "problem,", "b": [0.7814, 0.7302, 0.8571, 0.7516]}, {"w": "you", "b": [0.1429, 0.7493, 0.1741, 0.7707]}, {"w": "just", "b": [0.1791, 0.7493, 0.2095, 0.7707]}, {"w": "need", "b": [0.2145, 0.7493, 0.2546, 0.7707]}, {"w": "a", "b": [0.2596, 0.7493, 0.2687, 0.7707]}, {"w": "single", "b": [0.2737, 0.7493, 0.3222, 0.7707]}, {"w": "output", "b": [0.3272, 0.7493, 0.3836, 0.7707]}, {"w": "neuron", "b": [0.3886, 0.7493, 0.4497, 0.7707]}, {"w": "using", "b": [0.4547, 0.7493, 0.5001, 0.7707]}, {"w": "the", "b": [0.5051, 0.7493, 0.5314, 0.7707]}, {"w": "logistic", "b": [0.5364, 0.7493, 0.5961, 0.7707]}, {"w": "activation", "b": [0.601, 0.7493, 0.6833, 0.7707]}, {"w": "function:", "b": [0.6883, 0.7493, 0.7644, 0.7707]}, {"w": "the", "b": [0.7694, 0.7493, 0.7958, 0.7707]}, {"w": "output", "b": [0.8008, 0.7493, 0.8571, 0.7707]}, {"w": "will", "b": [0.1429, 0.7683, 0.1732, 0.7897]}, {"w": "be", "b": [0.1784, 0.7683, 0.1978, 0.7897]}, {"w": "a", "b": [0.203, 0.7683, 0.2121, 0.7897]}, {"w": "number", "b": [0.2173, 0.7683, 0.2836, 0.7897]}, {"w": "between", "b": [0.2887, 0.7683, 0.3579, 0.7897]}, {"w": "0", "b": [0.363, 0.7683, 0.373, 0.7897]}, {"w": "and", "b": [0.3782, 0.7683, 0.4097, 0.7897]}, {"w": "1,", "b": [0.4149, 0.7683, 0.4296, 0.7897]}, {"w": "which", "b": [0.4348, 0.7683, 0.4857, 0.7897]}, {"w": "you", "b": [0.4908, 0.7683, 0.5221, 0.7897]}, {"w": "can", "b": [0.5272, 0.7683, 0.5566, 0.7897]}, {"w": "interpret", "b": [0.5617, 0.7683, 0.6351, 0.7897]}, {"w": "as", "b": [0.6403, 0.7683, 0.657, 0.7897]}, {"w": "the", "b": [0.6622, 0.7683, 0.6885, 0.7897]}, {"w": "estimated", "b": [0.6937, 0.7683, 0.7741, 0.7897]}, {"w": "probabil‐", "b": [0.7793, 0.7683, 0.8571, 0.7897]}, {"w": "ity", "b": [0.1429, 0.7873, 0.1644, 0.8088]}, {"w": "of", "b": [0.1713, 0.7873, 0.1881, 0.8088]}, {"w": "the", "b": [0.1949, 0.7873, 0.2213, 0.8088]}, {"w": "positive", "b": [0.2282, 0.7873, 0.2934, 0.8088]}, {"w": "class.", "b": [0.3003, 0.7873, 0.3435, 0.8088]}, {"w": "Obviously,", "b": [0.3504, 0.7873, 0.4392, 0.8088]}, {"w": "the", "b": [0.4461, 0.7873, 0.4724, 0.8088]}, {"w": "estimated", "b": [0.4793, 0.7873, 0.5598, 0.8088]}, {"w": "probability", "b": [0.5667, 0.7873, 0.6586, 0.8088]}, {"w": "of", "b": [0.6655, 0.7873, 0.6823, 0.8088]}, {"w": "the", "b": [0.6892, 0.7873, 0.7155, 0.8088]}, {"w": "negative", "b": [0.7224, 0.7873, 0.7916, 0.8088]}, {"w": "class", "b": [0.7985, 0.7873, 0.837, 0.8088]}, {"w": "is", "b": [0.8439, 0.7873, 0.8572, 0.8088]}, {"w": "equal", "b": [0.1429, 0.8064, 0.1878, 0.8278]}, {"w": "to", "b": [0.1926, 0.8064, 0.2095, 0.8278]}, {"w": "one", "b": [0.2143, 0.8064, 0.2452, 0.8278]}, {"w": "minus", "b": [0.2499, 0.8064, 0.3022, 0.8278]}, {"w": "that", "b": [0.307, 0.8064, 0.3395, 0.8278]}, {"w": "number.", "b": [0.3443, 0.8064, 0.414, 0.8278]}]}, {"id": "b_14", "type": "paragraph", "text": "MLPs can also easily handle multilabel binary classification tasks (see Chapter 3). For example, you could have an email classification system that predicts whether each incoming email is ham or spam, and simultaneously predicts whether it is an urgent", "words": [{"w": "MLPs", "b": [0.1429, 0.8345, 0.1914, 0.8559]}, {"w": "can", "b": [0.1966, 0.8345, 0.226, 0.8559]}, {"w": "also", "b": [0.2312, 0.8345, 0.2639, 0.8559]}, {"w": "easily", "b": [0.2691, 0.8345, 0.3152, 0.8559]}, {"w": "handle", "b": [0.3204, 0.8345, 0.3772, 0.8559]}, {"w": "multilabel", "b": [0.3824, 0.8345, 0.4665, 0.8559]}, {"w": "binary", "b": [0.4717, 0.8345, 0.5263, 0.8559]}, {"w": "classification", "b": [0.5315, 0.8345, 0.6389, 0.8559]}, {"w": "tasks", "b": [0.6441, 0.8345, 0.6852, 0.8559]}, {"w": "(see", "b": [0.6904, 0.8345, 0.723, 0.8559]}, {"w": "Chapter", "b": [0.7282, 0.8345, 0.7958, 0.8559]}, {"w": "3).", "b": [0.8005, 0.8345, 0.8229, 0.8559]}, {"w": "For", "b": [0.8277, 0.8345, 0.8567, 0.8559]}, {"w": "example,", "b": [0.1429, 0.8536, 0.2172, 0.875]}, {"w": "you", "b": [0.2251, 0.8536, 0.2563, 0.875]}, {"w": "could", "b": [0.2642, 0.8536, 0.311, 0.875]}, {"w": "have", "b": [0.3189, 0.8536, 0.3573, 0.875]}, {"w": "an", "b": [0.3652, 0.8536, 0.3857, 0.875]}, {"w": "email", "b": [0.3936, 0.8536, 0.4395, 0.875]}, {"w": "classification", "b": [0.4474, 0.8536, 0.5548, 0.875]}, {"w": "system", "b": [0.5627, 0.8536, 0.6198, 0.875]}, {"w": "that", "b": [0.6277, 0.8536, 0.6603, 0.875]}, {"w": "predicts", "b": [0.6682, 0.8536, 0.7351, 0.875]}, {"w": "whether", "b": [0.743, 0.8536, 0.8113, 0.875]}, {"w": "each", "b": [0.8192, 0.8536, 0.8571, 0.875]}, {"w": "incoming", "b": [0.1429, 0.8726, 0.2231, 0.894]}, {"w": "email", "b": [0.2289, 0.8726, 0.2749, 0.894]}, {"w": "is", "b": [0.2807, 0.8726, 0.294, 0.894]}, {"w": "ham", "b": [0.2998, 0.8726, 0.3372, 0.894]}, {"w": "or", "b": [0.343, 0.8726, 0.3614, 0.894]}, {"w": "spam,", "b": [0.3673, 0.8726, 0.4168, 0.894]}, {"w": "and", "b": [0.4227, 0.8726, 0.4542, 0.894]}, {"w": "simultaneously", "b": [0.4601, 0.8726, 0.5862, 0.894]}, {"w": "predicts", "b": [0.5921, 0.8726, 0.659, 0.894]}, {"w": "whether", "b": [0.6649, 0.8726, 0.7332, 0.894]}, {"w": "it", "b": [0.7391, 0.8726, 0.751, 0.894]}, {"w": "is", "b": [0.7569, 0.8726, 0.7701, 0.894]}, {"w": "an", "b": [0.776, 0.8726, 0.7965, 0.894]}, {"w": "urgent", "b": [0.8024, 0.8726, 0.8571, 0.894]}]}, {"id": "b_15", "type": "paragraph", "text": "290 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "290", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 317, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "or non-urgent email. In this case, you would need two output neurons, both using the logistic activation function: the first would output the probability that the email is spam and the second would output the probability that it is urgent. More generally, you would dedicate one output neuron for each positive class. Note that the output probabilities do not necessarily add up to one. This lets the model output any combi‐ nation of labels: you can have non-urgent ham, urgent ham, non-urgent spam, and perhaps even urgent spam (although that would probably be an error).", "words": [{"w": "or", "b": [0.1429, 0.0791, 0.1612, 0.1005]}, {"w": "non-urgent", "b": [0.1683, 0.0791, 0.2639, 0.1005]}, {"w": "email.", "b": [0.271, 0.0791, 0.3217, 0.1005]}, {"w": "In", "b": [0.3288, 0.0791, 0.3473, 0.1005]}, {"w": "this", "b": [0.3544, 0.0791, 0.3851, 0.1005]}, {"w": "case,", "b": [0.3922, 0.0791, 0.4314, 0.1005]}, {"w": "you", "b": [0.4386, 0.0791, 0.4698, 0.1005]}, {"w": "would", "b": [0.4769, 0.0791, 0.5292, 0.1005]}, {"w": "need", "b": [0.5363, 0.0791, 0.5764, 0.1005]}, {"w": "two", "b": [0.5835, 0.0791, 0.6147, 0.1005]}, {"w": "output", "b": [0.6218, 0.0791, 0.6782, 0.1005]}, {"w": "neurons,", "b": [0.6853, 0.0791, 0.7588, 0.1005]}, {"w": "both", "b": [0.7659, 0.0791, 0.8046, 0.1005]}, {"w": "using", "b": [0.8117, 0.0791, 0.8571, 0.1005]}, {"w": "the", "b": [0.1429, 0.0981, 0.1692, 0.1195]}, {"w": "logistic", "b": [0.1742, 0.0981, 0.2338, 0.1195]}, {"w": "activation", "b": [0.2388, 0.0981, 0.3211, 0.1195]}, {"w": "function:", "b": [0.3261, 0.0981, 0.4022, 0.1195]}, {"w": "the", "b": [0.4073, 0.0981, 0.4336, 0.1195]}, {"w": "first", "b": [0.4386, 0.0981, 0.4721, 0.1195]}, {"w": "would", "b": [0.4771, 0.0981, 0.5293, 0.1195]}, {"w": "output", "b": [0.5343, 0.0981, 0.5907, 0.1195]}, {"w": "the", "b": [0.5957, 0.0981, 0.6221, 0.1195]}, {"w": "probability", "b": [0.6271, 0.0981, 0.719, 0.1195]}, {"w": "that", "b": [0.724, 0.0981, 0.7566, 0.1195]}, {"w": "the", "b": [0.7616, 0.0981, 0.788, 0.1195]}, {"w": "email", "b": [0.793, 0.0981, 0.8389, 0.1195]}, {"w": "is", "b": [0.8439, 0.0981, 0.8571, 0.1195]}, {"w": "spam", "b": [0.1429, 0.1172, 0.1876, 0.1386]}, {"w": "and", "b": [0.1942, 0.1172, 0.2257, 0.1386]}, {"w": "the", "b": [0.2322, 0.1172, 0.2586, 0.1386]}, {"w": "second", "b": [0.2651, 0.1172, 0.3234, 0.1386]}, {"w": "would", "b": [0.33, 0.1172, 0.3822, 0.1386]}, {"w": "output", "b": [0.3887, 0.1172, 0.4451, 0.1386]}, {"w": "the", "b": [0.4516, 0.1172, 0.478, 0.1386]}, {"w": "probability", "b": [0.4845, 0.1172, 0.5764, 0.1386]}, {"w": "that", "b": [0.583, 0.1172, 0.6155, 0.1386]}, {"w": "it", "b": [0.6221, 0.1172, 0.634, 0.1386]}, {"w": "is", "b": [0.6405, 0.1172, 0.6538, 0.1386]}, {"w": "urgent.", "b": [0.6603, 0.1172, 0.7198, 0.1386]}, {"w": "More", "b": [0.7263, 0.1172, 0.7716, 0.1386]}, {"w": "generally,", "b": [0.7781, 0.1172, 0.8572, 0.1386]}, {"w": "you", "b": [0.1429, 0.1362, 0.1741, 0.1576]}, {"w": "would", "b": [0.1807, 0.1362, 0.233, 0.1576]}, {"w": "dedicate", "b": [0.2396, 0.1362, 0.3088, 0.1576]}, {"w": "one", "b": [0.3155, 0.1362, 0.3463, 0.1576]}, {"w": "output", "b": [0.353, 0.1362, 0.4093, 0.1576]}, {"w": "neuron", "b": [0.416, 0.1362, 0.477, 0.1576]}, {"w": "for", "b": [0.4837, 0.1362, 0.5082, 0.1576]}, {"w": "each", "b": [0.5148, 0.1362, 0.5528, 0.1576]}, {"w": "positive", "b": [0.5594, 0.1362, 0.6246, 0.1576]}, {"w": "class.", "b": [0.6312, 0.1362, 0.6745, 0.1576]}, {"w": "Note", "b": [0.6812, 0.1362, 0.7219, 0.1576]}, {"w": "that", "b": [0.7286, 0.1362, 0.7612, 0.1576]}, {"w": "the", "b": [0.7678, 0.1362, 0.7941, 0.1576]}, {"w": "output", "b": [0.8008, 0.1362, 0.8571, 0.1576]}, {"w": "probabilities", "b": [0.1429, 0.1553, 0.2473, 0.1767]}, {"w": "do", "b": [0.2525, 0.1553, 0.2742, 0.1767]}, {"w": "not", "b": [0.2794, 0.1553, 0.3077, 0.1767]}, {"w": "necessarily", "b": [0.313, 0.1553, 0.4035, 0.1767]}, {"w": "add", "b": [0.4087, 0.1553, 0.4398, 0.1767]}, {"w": "up", "b": [0.445, 0.1553, 0.467, 0.1767]}, {"w": "to", "b": [0.4722, 0.1553, 0.4892, 0.1767]}, {"w": "one.", "b": [0.4944, 0.1553, 0.5301, 0.1767]}, {"w": "This", "b": [0.5353, 0.1553, 0.5725, 0.1767]}, {"w": "lets", "b": [0.5777, 0.1553, 0.6058, 0.1767]}, {"w": "the", "b": [0.611, 0.1553, 0.6374, 0.1767]}, {"w": "model", "b": [0.6426, 0.1553, 0.6954, 0.1767]}, {"w": "output", "b": [0.7006, 0.1553, 0.757, 0.1767]}, {"w": "any", "b": [0.7622, 0.1553, 0.7918, 0.1767]}, {"w": "combi‐", "b": [0.7971, 0.1553, 0.8571, 0.1767]}, {"w": "nation", "b": [0.1428, 0.1743, 0.197, 0.1957]}, {"w": "of", "b": [0.2038, 0.1743, 0.2206, 0.1957]}, {"w": "labels:", "b": [0.2274, 0.1743, 0.2789, 0.1957]}, {"w": "you", "b": [0.2857, 0.1743, 0.3169, 0.1957]}, {"w": "can", "b": [0.3238, 0.1743, 0.3531, 0.1957]}, {"w": "have", "b": [0.3599, 0.1743, 0.3983, 0.1957]}, {"w": "non-urgent", "b": [0.4051, 0.1743, 0.5007, 0.1957]}, {"w": "ham,", "b": [0.5075, 0.1743, 0.5496, 0.1957]}, {"w": "urgent", "b": [0.5564, 0.1743, 0.6112, 0.1957]}, {"w": "ham,", "b": [0.618, 0.1743, 0.6601, 0.1957]}, {"w": "non-urgent", "b": [0.6669, 0.1743, 0.7625, 0.1957]}, {"w": "spam,", "b": [0.7693, 0.1743, 0.8188, 0.1957]}, {"w": "and", "b": [0.8256, 0.1743, 0.8571, 0.1957]}, {"w": "perhaps", "b": [0.1429, 0.1933, 0.2088, 0.2148]}, {"w": "even", "b": [0.2135, 0.1933, 0.2523, 0.2148]}, {"w": "urgent", "b": [0.257, 0.1933, 0.3118, 0.2148]}, {"w": "spam", "b": [0.3165, 0.1933, 0.3613, 0.2148]}, {"w": "(although", "b": [0.366, 0.1933, 0.4477, 0.2148]}, {"w": "that", "b": [0.4524, 0.1933, 0.485, 0.2148]}, {"w": "would", "b": [0.4897, 0.1933, 0.5419, 0.2148]}, {"w": "probably", "b": [0.5467, 0.1933, 0.6211, 0.2148]}, {"w": "be", "b": [0.6258, 0.1933, 0.6452, 0.2148]}, {"w": "an", "b": [0.65, 0.1933, 0.6705, 0.2148]}, {"w": "error).", "b": [0.6752, 0.1933, 0.7299, 0.2148]}]}, {"id": "b_1", "type": "paragraph", "text": "If each instance can belong only to a single class, out of 3 or more possible classes (e.g., classes 0 through 9 for digit image classification), then you need to have one output neuron per class, and you should use the softmax activation function for the whole output layer (see Figure 10-9). The softmax function (introduced in Chapter 4) will ensure that all the estimated probabilities are between 0 and 1 and that they add up to one (which is required if the classes are exclusive). This is called multiclass clas‐ sification.", "words": [{"w": "If", "b": [0.1429, 0.2215, 0.1561, 0.2429]}, {"w": "each", "b": [0.1632, 0.2215, 0.2012, 0.2429]}, {"w": "instance", "b": [0.2083, 0.2215, 0.2775, 0.2429]}, {"w": "can", "b": [0.2846, 0.2215, 0.3139, 0.2429]}, {"w": "belong", "b": [0.321, 0.2215, 0.3775, 0.2429]}, {"w": "only", "b": [0.3846, 0.2215, 0.4215, 0.2429]}, {"w": "to", "b": [0.4286, 0.2215, 0.4456, 0.2429]}, {"w": "a", "b": [0.4527, 0.2215, 0.4618, 0.2429]}, {"w": "single", "b": [0.4689, 0.2215, 0.5174, 0.2429]}, {"w": "class,", "b": [0.5245, 0.2215, 0.5678, 0.2429]}, {"w": "out", "b": [0.5749, 0.2215, 0.6029, 0.2429]}, {"w": "of", "b": [0.6101, 0.2215, 0.6268, 0.2429]}, {"w": "3", "b": [0.634, 0.2215, 0.644, 0.2429]}, {"w": "or", "b": [0.6511, 0.2215, 0.6694, 0.2429]}, {"w": "more", "b": [0.6765, 0.2215, 0.7208, 0.2429]}, {"w": "possible", "b": [0.7279, 0.2215, 0.795, 0.2429]}, {"w": "classes", "b": [0.8021, 0.2215, 0.8571, 0.2429]}, {"w": "(e.g.,", "b": [0.1429, 0.2405, 0.1829, 0.2619]}, {"w": "classes", "b": [0.1903, 0.2405, 0.2453, 0.2619]}, {"w": "0", "b": [0.2527, 0.2405, 0.2627, 0.2619]}, {"w": "through", "b": [0.2701, 0.2405, 0.3379, 0.2619]}, {"w": "9", "b": [0.3453, 0.2405, 0.3553, 0.2619]}, {"w": "for", "b": [0.3627, 0.2405, 0.3872, 0.2619]}, {"w": "digit", "b": [0.3946, 0.2405, 0.4329, 0.2619]}, {"w": "image", "b": [0.4403, 0.2405, 0.4907, 0.2619]}, {"w": "classification),", "b": [0.4981, 0.2405, 0.6174, 0.2619]}, {"w": "then", "b": [0.6248, 0.2405, 0.6625, 0.2619]}, {"w": "you", "b": [0.6699, 0.2405, 0.7012, 0.2619]}, {"w": "need", "b": [0.7086, 0.2405, 0.7487, 0.2619]}, {"w": "to", "b": [0.7561, 0.2405, 0.7731, 0.2619]}, {"w": "have", "b": [0.7805, 0.2405, 0.8189, 0.2619]}, {"w": "one", "b": [0.8263, 0.2405, 0.8571, 0.2619]}, {"w": "output", "b": [0.1429, 0.2596, 0.1992, 0.281]}, {"w": "neuron", "b": [0.2056, 0.2596, 0.2667, 0.281]}, {"w": "per", "b": [0.2731, 0.2596, 0.3006, 0.281]}, {"w": "class,", "b": [0.307, 0.2596, 0.3502, 0.281]}, {"w": "and", "b": [0.3566, 0.2596, 0.3882, 0.281]}, {"w": "you", "b": [0.3946, 0.2596, 0.4258, 0.281]}, {"w": "should", "b": [0.4322, 0.2596, 0.4889, 0.281]}, {"w": "use", "b": [0.4953, 0.2596, 0.5229, 0.281]}, {"w": "the", "b": [0.5293, 0.2596, 0.5556, 0.281]}, {"w": "softmax", "b": [0.562, 0.2594, 0.6271, 0.281]}, {"w": "activation", "b": [0.6335, 0.2596, 0.7157, 0.281]}, {"w": "function", "b": [0.7221, 0.2596, 0.7935, 0.281]}, {"w": "for", "b": [0.7999, 0.2596, 0.8244, 0.281]}, {"w": "the", "b": [0.8308, 0.2596, 0.8571, 0.281]}, {"w": "whole", "b": [0.1429, 0.2786, 0.193, 0.3]}, {"w": "output", "b": [0.198, 0.2786, 0.2544, 0.3]}, {"w": "layer", "b": [0.2593, 0.2786, 0.2995, 0.3]}, {"w": "(see", "b": [0.3045, 0.2786, 0.337, 0.3]}, {"w": "Figure", "b": [0.342, 0.2786, 0.396, 0.3]}, {"w": "10-9).", "b": [0.4007, 0.2786, 0.4503, 0.3]}, {"w": "The", "b": [0.4553, 0.2786, 0.4881, 0.3]}, {"w": "softmax", "b": [0.4931, 0.2786, 0.5599, 0.3]}, {"w": "function", "b": [0.5649, 0.2786, 0.6363, 0.3]}, {"w": "(introduced", "b": [0.6413, 0.2786, 0.7405, 0.3]}, {"w": "in", "b": [0.7454, 0.2786, 0.7624, 0.3]}, {"w": "Chapter", "b": [0.7674, 0.2786, 0.835, 0.3]}, {"w": "4)", "b": [0.8397, 0.2786, 0.8571, 0.3]}, {"w": "will", "b": [0.1428, 0.2977, 0.1732, 0.3191]}, {"w": "ensure", "b": [0.1791, 0.2977, 0.2346, 0.3191]}, {"w": "that", "b": [0.2404, 0.2977, 0.273, 0.3191]}, {"w": "all", "b": [0.2788, 0.2977, 0.2985, 0.3191]}, {"w": "the", "b": [0.3043, 0.2977, 0.3307, 0.3191]}, {"w": "estimated", "b": [0.3365, 0.2977, 0.4169, 0.3191]}, {"w": "probabilities", "b": [0.4227, 0.2977, 0.5272, 0.3191]}, {"w": "are", "b": [0.533, 0.2977, 0.5587, 0.3191]}, {"w": "between", "b": [0.5646, 0.2977, 0.6337, 0.3191]}, {"w": "0", "b": [0.6395, 0.2977, 0.6495, 0.3191]}, {"w": "and", "b": [0.6554, 0.2977, 0.6869, 0.3191]}, {"w": "1", "b": [0.6927, 0.2977, 0.7027, 0.3191]}, {"w": "and", "b": [0.7085, 0.2977, 0.7401, 0.3191]}, {"w": "that", "b": [0.7459, 0.2977, 0.7785, 0.3191]}, {"w": "they", "b": [0.7843, 0.2977, 0.8202, 0.3191]}, {"w": "add", "b": [0.826, 0.2977, 0.8571, 0.3191]}, {"w": "up", "b": [0.1429, 0.3167, 0.1648, 0.3381]}, {"w": "to", "b": [0.1698, 0.3167, 0.1868, 0.3381]}, {"w": "one", "b": [0.1918, 0.3167, 0.2227, 0.3381]}, {"w": "(which", "b": [0.2276, 0.3167, 0.2858, 0.3381]}, {"w": "is", "b": [0.2908, 0.3167, 0.304, 0.3381]}, {"w": "required", "b": [0.309, 0.3167, 0.3804, 0.3381]}, {"w": "if", "b": [0.3854, 0.3167, 0.3972, 0.3381]}, {"w": "the", "b": [0.4021, 0.3167, 0.4285, 0.3381]}, {"w": "classes", "b": [0.4335, 0.3167, 0.4885, 0.3381]}, {"w": "are", "b": [0.4935, 0.3167, 0.5192, 0.3381]}, {"w": "exclusive).", "b": [0.5242, 0.3167, 0.6117, 0.3381]}, {"w": "This", "b": [0.6167, 0.3167, 0.6539, 0.3381]}, {"w": "is", "b": [0.6589, 0.3167, 0.6721, 0.3381]}, {"w": "called", "b": [0.6771, 0.3167, 0.7254, 0.3381]}, {"w": "multiclass", "b": [0.7304, 0.3167, 0.8139, 0.3381]}, {"w": "clas‐", "b": [0.8189, 0.3167, 0.8571, 0.3381]}, {"w": "sification.", "b": [0.1429, 0.3357, 0.2241, 0.3572]}]}, {"id": "b_2", "type": "equation", "text": "Figure 10-9. A modern MLP (including ReLU and softmax) for classification", "words": [{"w": "Figure", "b": [0.1429, 0.6537, 0.1943, 0.6753]}, {"w": "10-9.", "b": [0.1991, 0.6537, 0.2407, 0.6753]}, {"w": "A", "b": [0.2455, 0.6537, 0.2593, 0.6753]}, {"w": "modern", "b": [0.2641, 0.6537, 0.3278, 0.6753]}, {"w": "MLP", "b": [0.3326, 0.6537, 0.3734, 0.6753]}, {"w": "(including", "b": [0.3782, 0.6537, 0.4605, 0.6753]}, {"w": "ReLU", "b": [0.4653, 0.6537, 0.5111, 0.6753]}, {"w": "and", "b": [0.5158, 0.6537, 0.5472, 0.6753]}, {"w": "softmax)", "b": [0.552, 0.6537, 0.624, 0.6753]}, {"w": "for", "b": [0.6288, 0.6537, 0.6514, 0.6753]}, {"w": "classification", "b": [0.6562, 0.6537, 0.7615, 0.6753]}]}, {"id": "b_3", "type": "paragraph", "text": "Regarding the loss function, since we are predicting probability distributions, the cross-entropy (also called the log loss, see Chapter 4) is generally a good choice.", "words": [{"w": "Regarding", "b": [0.1429, 0.6911, 0.229, 0.7125]}, {"w": "the", "b": [0.2377, 0.6911, 0.2641, 0.7125]}, {"w": "loss", "b": [0.2728, 0.6911, 0.304, 0.7125]}, {"w": "function,", "b": [0.3127, 0.6911, 0.3888, 0.7125]}, {"w": "since", "b": [0.3975, 0.6911, 0.4398, 0.7125]}, {"w": "we", "b": [0.4486, 0.6911, 0.4717, 0.7125]}, {"w": "are", "b": [0.4804, 0.6911, 0.5061, 0.7125]}, {"w": "predicting", "b": [0.5148, 0.6911, 0.6008, 0.7125]}, {"w": "probability", "b": [0.6095, 0.6911, 0.7015, 0.7125]}, {"w": "distributions,", "b": [0.7102, 0.6911, 0.8221, 0.7125]}, {"w": "the", "b": [0.8308, 0.6911, 0.8571, 0.7125]}, {"w": "cross-entropy", "b": [0.1429, 0.7102, 0.2578, 0.7316]}, {"w": "(also", "b": [0.2625, 0.7102, 0.3024, 0.7316]}, {"w": "called", "b": [0.3071, 0.7102, 0.3555, 0.7316]}, {"w": "the", "b": [0.3602, 0.7102, 0.3865, 0.7316]}, {"w": "log", "b": [0.3913, 0.7102, 0.4169, 0.7316]}, {"w": "loss,", "b": [0.4216, 0.7102, 0.4576, 0.7316]}, {"w": "see", "b": [0.4623, 0.7102, 0.4877, 0.7316]}, {"w": "Chapter", "b": [0.4924, 0.7102, 0.56, 0.7316]}, {"w": "4)", "b": [0.5647, 0.7102, 0.5819, 0.7316]}, {"w": "is", "b": [0.5866, 0.7102, 0.5999, 0.7316]}, {"w": "generally", "b": [0.6046, 0.7102, 0.6804, 0.7316]}, {"w": "a", "b": [0.6852, 0.7102, 0.6943, 0.7316]}, {"w": "good", "b": [0.699, 0.7102, 0.741, 0.7316]}, {"w": "choice.", "b": [0.7458, 0.7102, 0.8043, 0.7316]}]}, {"id": "b_4", "type": "equation", "text": "Table 10-2 summarizes the typical architecture of a classification MLP.", "words": [{"w": "Table", "b": [0.1429, 0.7383, 0.1876, 0.7597]}, {"w": "10-2", "b": [0.1924, 0.7383, 0.2298, 0.7597]}, {"w": "summarizes", "b": [0.2345, 0.7383, 0.3351, 0.7597]}, {"w": "the", "b": [0.3398, 0.7383, 0.3661, 0.7597]}, {"w": "typical", "b": [0.3709, 0.7383, 0.4265, 0.7597]}, {"w": "architecture", "b": [0.4312, 0.7383, 0.5316, 0.7597]}, {"w": "of", "b": [0.5364, 0.7383, 0.5532, 0.7597]}, {"w": "a", "b": [0.5579, 0.7383, 0.567, 0.7597]}, {"w": "classification", "b": [0.5718, 0.7383, 0.6791, 0.7597]}, {"w": "MLP.", "b": [0.6839, 0.7383, 0.7272, 0.7597]}]}, {"id": "b_5", "type": "equation", "text": "Table 10-2. Typical Classification MLP Architecture", "words": [{"w": "Table", "b": [0.1429, 0.7762, 0.1844, 0.7967]}, {"w": "10-2.", "b": [0.189, 0.7762, 0.2287, 0.7967]}, {"w": "Typical", "b": [0.2332, 0.7762, 0.2893, 0.7967]}, {"w": "Classification", "b": [0.2939, 0.7762, 0.3992, 0.7967]}, {"w": "MLP", "b": [0.4037, 0.7762, 0.4426, 0.7967]}, {"w": "Architecture", "b": [0.4472, 0.7762, 0.5419, 0.7967]}]}, {"id": "b_6", "type": "paragraph", "text": "Hyperparameter Binary classification Multilabel binary classification Multiclass classification Input and hidden layers Same as regression Same as regression Same as regression", "words": [{"w": "Hyperparameter", "b": [0.15, 0.8047, 0.2472, 0.821]}, {"w": "Binary", "b": [0.2956, 0.8047, 0.3336, 0.821]}, {"w": "classification", "b": [0.337, 0.8047, 0.4127, 0.821]}, {"w": "Multilabel", "b": [0.427, 0.8047, 0.4875, 0.821]}, {"w": "binary", "b": [0.4909, 0.8047, 0.5284, 0.821]}, {"w": "classification", "b": [0.5319, 0.8047, 0.6076, 0.821]}, {"w": "Multiclass", "b": [0.6219, 0.8047, 0.6805, 0.821]}, {"w": "classification", "b": [0.6839, 0.8047, 0.7597, 0.821]}, {"w": "Input", "b": [0.15, 0.825, 0.1796, 0.8412]}, {"w": "and", "b": [0.183, 0.825, 0.2038, 0.8412]}, {"w": "hidden", "b": [0.2072, 0.825, 0.2457, 0.8412]}, {"w": "layers", "b": [0.2491, 0.825, 0.2813, 0.8412]}, {"w": "Same", "b": [0.2956, 0.825, 0.3261, 0.8412]}, {"w": "as", "b": [0.3294, 0.825, 0.3411, 0.8412]}, {"w": "regression", "b": [0.3445, 0.825, 0.4011, 0.8412]}, {"w": "Same", "b": [0.427, 0.825, 0.4575, 0.8412]}, {"w": "as", "b": [0.4609, 0.825, 0.4726, 0.8412]}, {"w": "regression", "b": [0.476, 0.825, 0.5326, 0.8412]}, {"w": "Same", "b": [0.6219, 0.825, 0.6524, 0.8412]}, {"w": "as", "b": [0.6558, 0.825, 0.6674, 0.8412]}, {"w": "regression", "b": [0.6708, 0.825, 0.7275, 0.8412]}]}, {"id": "b_7", "type": "paragraph", "text": "# output neurons 1 1 per label 1 per class", "words": [{"w": "#", "b": [0.15, 0.846, 0.1569, 0.8622]}, {"w": "output", "b": [0.1603, 0.846, 0.1976, 0.8622]}, {"w": "neurons", "b": [0.201, 0.846, 0.2454, 0.8622]}, {"w": "1", "b": [0.2956, 0.846, 0.3024, 0.8622]}, {"w": "1", "b": [0.427, 0.846, 0.4339, 0.8622]}, {"w": "per", "b": [0.4373, 0.846, 0.4553, 0.8622]}, {"w": "label", "b": [0.4588, 0.846, 0.4857, 0.8622]}, {"w": "1", "b": [0.6219, 0.846, 0.6287, 0.8622]}, {"w": "per", "b": [0.6321, 0.846, 0.6502, 0.8622]}, {"w": "class", "b": [0.6536, 0.846, 0.6792, 0.8622]}]}, {"id": "b_8", "type": "paragraph", "text": "Output layer activation Logistic Logistic Softmax", "words": [{"w": "Output", "b": [0.15, 0.8671, 0.1884, 0.8832]}, {"w": "layer", "b": [0.1918, 0.8671, 0.2188, 0.8832]}, {"w": "activation", "b": [0.2222, 0.8671, 0.2766, 0.8832]}, {"w": "Logistic", "b": [0.2956, 0.8671, 0.3373, 0.8832]}, {"w": "Logistic", "b": [0.427, 0.8671, 0.4688, 0.8832]}, {"w": "Softmax", "b": [0.6219, 0.8671, 0.6674, 0.8832]}]}, {"id": "b_9", "type": "paragraph", "text": "From Biological to Artificial Neurons | 291", "words": [{"w": "From", "b": [0.585, 0.9225, 0.6155, 0.9388]}, {"w": "Biological", "b": [0.6183, 0.9225, 0.6761, 0.9388]}, {"w": "to", "b": [0.6789, 0.9225, 0.6914, 0.9388]}, {"w": "Artificial", "b": [0.6942, 0.9225, 0.7441, 0.9388]}, {"w": "Neurons", "b": [0.7469, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "291", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 318, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "12 Project ONEIROS (Open-ended Neuro-Electronic Intelligent Robot Operating System).", "words": [{"w": "12", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "Project", "b": [0.1587, 0.8749, 0.204, 0.8912]}, {"w": "ONEIROS", "b": [0.2076, 0.8749, 0.2749, 0.8912]}, {"w": "(Open-ended", "b": [0.2785, 0.8749, 0.3642, 0.8912]}, {"w": "Neuro-Electronic", "b": [0.3678, 0.8749, 0.479, 0.8912]}, {"w": "Intelligent", "b": [0.4826, 0.8749, 0.5477, 0.8912]}, {"w": "Robot", "b": [0.5513, 0.8749, 0.5902, 0.8912]}, {"w": "Operating", "b": [0.5938, 0.8749, 0.6585, 0.8912]}, {"w": "System).", "b": [0.6621, 0.8749, 0.7164, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Hyperparameter Binary classification Multilabel binary classification Multiclass classification Loss function Cross-Entropy Cross-Entropy Cross-Entropy", "words": [{"w": "Hyperparameter", "b": [0.15, 0.0833, 0.2472, 0.0996]}, {"w": "Binary", "b": [0.2956, 0.0833, 0.3336, 0.0996]}, {"w": "classification", "b": [0.337, 0.0833, 0.4127, 0.0996]}, {"w": "Multilabel", "b": [0.427, 0.0833, 0.4875, 0.0996]}, {"w": "binary", "b": [0.4909, 0.0833, 0.5284, 0.0996]}, {"w": "classification", "b": [0.5319, 0.0833, 0.6076, 0.0996]}, {"w": "Multiclass", "b": [0.6219, 0.0833, 0.6805, 0.0996]}, {"w": "classification", "b": [0.6839, 0.0833, 0.7597, 0.0996]}, {"w": "Loss", "b": [0.15, 0.1037, 0.1733, 0.1198]}, {"w": "function", "b": [0.1767, 0.1037, 0.2224, 0.1198]}, {"w": "Cross-Entropy", "b": [0.2956, 0.1037, 0.3715, 0.1198]}, {"w": "Cross-Entropy", "b": [0.427, 0.1037, 0.503, 0.1198]}, {"w": "Cross-Entropy", "b": [0.6219, 0.1037, 0.6978, 0.1198]}]}, {"id": "b_2", "type": "paragraph", "text": "Before we go on, I recommend you go through exercise 1, at the end of this chapter. You will play with various neural network architectures and visualize their outputs using the TensorFlow Play‐ ground. This will be very useful to better understand MLPs, for example the effects of all the hyperparameters (number of layers and neurons, activation functions, and more).", "words": [{"w": "Before", "b": [0.2714, 0.1442, 0.3216, 0.1638]}, {"w": "we", "b": [0.3282, 0.1442, 0.3494, 0.1638]}, {"w": "go", "b": [0.356, 0.1442, 0.3746, 0.1638]}, {"w": "on,", "b": [0.3813, 0.1442, 0.4058, 0.1638]}, {"w": "I", "b": [0.4124, 0.1442, 0.4189, 0.1638]}, {"w": "recommend", "b": [0.4255, 0.1442, 0.5182, 0.1638]}, {"w": "you", "b": [0.5249, 0.1442, 0.5534, 0.1638]}, {"w": "go", "b": [0.5601, 0.1442, 0.5787, 0.1638]}, {"w": "through", "b": [0.5853, 0.1442, 0.6473, 0.1638]}, {"w": "exercise", "b": [0.6539, 0.1442, 0.7144, 0.1638]}, {"w": "1,", "b": [0.7211, 0.1442, 0.7346, 0.1638]}, {"w": "at", "b": [0.7412, 0.1442, 0.755, 0.1638]}, {"w": "the", "b": [0.7616, 0.1442, 0.7857, 0.1638]}, {"w": "end", "b": [0.2714, 0.1616, 0.3, 0.1812]}, {"w": "of", "b": [0.309, 0.1616, 0.3244, 0.1812]}, {"w": "this", "b": [0.3334, 0.1616, 0.3615, 0.1812]}, {"w": "chapter.", "b": [0.3705, 0.1616, 0.4308, 0.1812]}, {"w": "You", "b": [0.4398, 0.1616, 0.4694, 0.1812]}, {"w": "will", "b": [0.4784, 0.1616, 0.5062, 0.1812]}, {"w": "play", "b": [0.5153, 0.1616, 0.5468, 0.1812]}, {"w": "with", "b": [0.5559, 0.1616, 0.59, 0.1812]}, {"w": "various", "b": [0.599, 0.1616, 0.6552, 0.1812]}, {"w": "neural", "b": [0.6642, 0.1616, 0.7131, 0.1812]}, {"w": "network", "b": [0.7221, 0.1616, 0.7857, 0.1812]}, {"w": "architectures", "b": [0.2714, 0.179, 0.3702, 0.1986]}, {"w": "and", "b": [0.3747, 0.179, 0.4036, 0.1986]}, {"w": "visualize", "b": [0.4081, 0.179, 0.4735, 0.1986]}, {"w": "their", "b": [0.4781, 0.179, 0.5143, 0.1986]}, {"w": "outputs", "b": [0.5189, 0.179, 0.5774, 0.1986]}, {"w": "using", "b": [0.5819, 0.179, 0.6235, 0.1986]}, {"w": "the", "b": [0.628, 0.179, 0.6521, 0.1986]}, {"w": "TensorFlow", "b": [0.6566, 0.1789, 0.7423, 0.1986]}, {"w": "Play‐", "b": [0.7467, 0.1789, 0.7855, 0.1986]}, {"w": "ground.", "b": [0.2714, 0.1963, 0.3288, 0.216]}, {"w": "This", "b": [0.3368, 0.1965, 0.3708, 0.216]}, {"w": "will", "b": [0.3788, 0.1965, 0.4066, 0.216]}, {"w": "be", "b": [0.4145, 0.1965, 0.4323, 0.216]}, {"w": "very", "b": [0.4403, 0.1965, 0.4735, 0.216]}, {"w": "useful", "b": [0.4815, 0.1965, 0.5273, 0.216]}, {"w": "to", "b": [0.5352, 0.1965, 0.5508, 0.216]}, {"w": "better", "b": [0.5587, 0.1965, 0.6033, 0.216]}, {"w": "understand", "b": [0.6112, 0.1965, 0.6986, 0.216]}, {"w": "MLPs,", "b": [0.7066, 0.1965, 0.7553, 0.216]}, {"w": "for", "b": [0.7633, 0.1965, 0.7857, 0.216]}, {"w": "example", "b": [0.2714, 0.2139, 0.335, 0.2334]}, {"w": "the", "b": [0.3423, 0.2139, 0.3663, 0.2334]}, {"w": "effects", "b": [0.3736, 0.2139, 0.422, 0.2334]}, {"w": "of", "b": [0.4292, 0.2139, 0.4446, 0.2334]}, {"w": "all", "b": [0.4519, 0.2139, 0.4699, 0.2334]}, {"w": "the", "b": [0.4772, 0.2139, 0.5012, 0.2334]}, {"w": "hyperparameters", "b": [0.5085, 0.2139, 0.6376, 0.2334]}, {"w": "(number", "b": [0.6449, 0.2139, 0.7121, 0.2334]}, {"w": "of", "b": [0.7193, 0.2139, 0.7347, 0.2334]}, {"w": "layers", "b": [0.742, 0.2139, 0.7857, 0.2334]}, {"w": "and", "b": [0.2714, 0.2313, 0.3002, 0.2509]}, {"w": "neurons,", "b": [0.3046, 0.2313, 0.3717, 0.2509]}, {"w": "activation", "b": [0.3761, 0.2313, 0.4513, 0.2509]}, {"w": "functions,", "b": [0.4556, 0.2313, 0.5322, 0.2509]}, {"w": "and", "b": [0.5365, 0.2313, 0.5654, 0.2509]}, {"w": "more).", "b": [0.5697, 0.2313, 0.6211, 0.2509]}]}, {"id": "b_3", "type": "paragraph", "text": "Now you have all the concepts you need to start implementing MLPs with Keras!", "words": [{"w": "Now", "b": [0.1429, 0.2712, 0.1827, 0.2926]}, {"w": "you", "b": [0.1874, 0.2712, 0.2187, 0.2926]}, {"w": "have", "b": [0.2234, 0.2712, 0.2618, 0.2926]}, {"w": "all", "b": [0.2665, 0.2712, 0.2862, 0.2926]}, {"w": "the", "b": [0.291, 0.2712, 0.3173, 0.2926]}, {"w": "concepts", "b": [0.322, 0.2712, 0.3954, 0.2926]}, {"w": "you", "b": [0.4002, 0.2712, 0.4314, 0.2926]}, {"w": "need", "b": [0.4361, 0.2712, 0.4763, 0.2926]}, {"w": "to", "b": [0.481, 0.2712, 0.498, 0.2926]}, {"w": "start", "b": [0.5027, 0.2712, 0.5399, 0.2926]}, {"w": "implementing", "b": [0.5446, 0.2712, 0.6619, 0.2926]}, {"w": "MLPs", "b": [0.6667, 0.2712, 0.7152, 0.2926]}, {"w": "with", "b": [0.72, 0.2712, 0.7573, 0.2926]}, {"w": "Keras!", "b": [0.762, 0.2712, 0.8147, 0.2926]}]}, {"id": "b_4", "type": "paragraph", "text": "Implementing MLPs with Keras", "words": [{"w": "Implementing", "b": [0.1429, 0.3056, 0.3208, 0.3398]}, {"w": "MLPs", "b": [0.3267, 0.3056, 0.3914, 0.3398]}, {"w": "with", "b": [0.3973, 0.3056, 0.4543, 0.3398]}, {"w": "Keras", "b": [0.4603, 0.3056, 0.528, 0.3398]}]}, {"id": "b_5", "type": "paragraph", "text": "Keras is a high-level Deep Learning API that allows you to easily build, train, evaluate and execute all sorts of neural networks. Its documentation (or specification) is avail‐ able at https://keras.io. The reference implementation is simply called Keras as well, so to avoid any confusion we will call it keras-team (since it is available at https:// github.com/keras-team/keras). It was developed by François Chollet as part of a research project12 and released as an open source project in March 2015. It quickly gained popularity owing to its ease-of-use, flexibility and beautiful design. To per‐ form the heavy computations required by neural networks, keras-team relies on a computation backend. At the present, you can choose from three popular open source deep learning libraries: TensorFlow, Microsoft Cognitive Toolkit (CNTK) or Theano.", "words": [{"w": "Keras", "b": [0.1428, 0.3467, 0.1897, 0.3682]}, {"w": "is", "b": [0.1947, 0.3467, 0.2079, 0.3682]}, {"w": "a", "b": [0.2129, 0.3467, 0.2221, 0.3682]}, {"w": "high-level", "b": [0.227, 0.3467, 0.3099, 0.3682]}, {"w": "Deep", "b": [0.3149, 0.3467, 0.3588, 0.3682]}, {"w": "Learning", "b": [0.3638, 0.3467, 0.4389, 0.3682]}, {"w": "API", "b": [0.4439, 0.3467, 0.4771, 0.3682]}, {"w": "that", "b": [0.4821, 0.3467, 0.5146, 0.3682]}, {"w": "allows", "b": [0.5196, 0.3467, 0.5719, 0.3682]}, {"w": "you", "b": [0.5768, 0.3467, 0.6081, 0.3682]}, {"w": "to", "b": [0.613, 0.3467, 0.63, 0.3682]}, {"w": "easily", "b": [0.635, 0.3467, 0.6811, 0.3682]}, {"w": "build,", "b": [0.686, 0.3467, 0.7343, 0.3682]}, {"w": "train,", "b": [0.7393, 0.3467, 0.7842, 0.3682]}, {"w": "evaluate", "b": [0.7892, 0.3467, 0.8571, 0.3682]}, {"w": "and", "b": [0.1429, 0.3658, 0.1744, 0.3872]}, {"w": "execute", "b": [0.1797, 0.3658, 0.2423, 0.3872]}, {"w": "all", "b": [0.2476, 0.3658, 0.2673, 0.3872]}, {"w": "sorts", "b": [0.2726, 0.3658, 0.3126, 0.3872]}, {"w": "of", "b": [0.3179, 0.3658, 0.3347, 0.3872]}, {"w": "neural", "b": [0.34, 0.3658, 0.3934, 0.3872]}, {"w": "networks.", "b": [0.3987, 0.3658, 0.4807, 0.3872]}, {"w": "Its", "b": [0.486, 0.3658, 0.5063, 0.3872]}, {"w": "documentation", "b": [0.5116, 0.3658, 0.6391, 0.3872]}, {"w": "(or", "b": [0.6443, 0.3658, 0.6699, 0.3872]}, {"w": "specification)", "b": [0.6752, 0.3658, 0.7875, 0.3872]}, {"w": "is", "b": [0.7928, 0.3658, 0.806, 0.3872]}, {"w": "avail‐", "b": [0.8113, 0.3658, 0.8571, 0.3872]}, {"w": "able", "b": [0.1429, 0.3848, 0.1767, 0.4062]}, {"w": "at", "b": [0.1814, 0.3848, 0.1965, 0.4062]}, {"w": "https://keras.io.", "b": [0.2016, 0.3846, 0.3274, 0.4062]}, {"w": "The", "b": [0.3323, 0.3848, 0.3651, 0.4062]}, {"w": "reference", "b": [0.37, 0.3848, 0.4472, 0.4062]}, {"w": "implementation", "b": [0.4521, 0.3848, 0.5854, 0.4062]}, {"w": "is", "b": [0.5903, 0.3848, 0.6035, 0.4062]}, {"w": "simply", "b": [0.6084, 0.3848, 0.664, 0.4062]}, {"w": "called", "b": [0.6689, 0.3848, 0.7172, 0.4062]}, {"w": "Keras", "b": [0.7221, 0.3848, 0.769, 0.4062]}, {"w": "as", "b": [0.7739, 0.3848, 0.7907, 0.4062]}, {"w": "well,", "b": [0.7956, 0.3848, 0.834, 0.4062]}, {"w": "so", "b": [0.8389, 0.3848, 0.8572, 0.4062]}, {"w": "to", "b": [0.1429, 0.4039, 0.1598, 0.4253]}, {"w": "avoid", "b": [0.1693, 0.4039, 0.2149, 0.4253]}, {"w": "any", "b": [0.2243, 0.4039, 0.2539, 0.4253]}, {"w": "confusion", "b": [0.2634, 0.4039, 0.3467, 0.4253]}, {"w": "we", "b": [0.3561, 0.4039, 0.3792, 0.4253]}, {"w": "will", "b": [0.3886, 0.4039, 0.419, 0.4253]}, {"w": "call", "b": [0.4284, 0.4039, 0.4569, 0.4253]}, {"w": "it", "b": [0.4664, 0.4039, 0.4783, 0.4253]}, {"w": "keras-team", "b": [0.4877, 0.4039, 0.5803, 0.4253]}, {"w": "(since", "b": [0.5897, 0.4039, 0.6392, 0.4253]}, {"w": "it", "b": [0.6486, 0.4039, 0.6605, 0.4253]}, {"w": "is", "b": [0.67, 0.4039, 0.6832, 0.4253]}, {"w": "available", "b": [0.6926, 0.4039, 0.7649, 0.4253]}, {"w": "at", "b": [0.7743, 0.4039, 0.7894, 0.4253]}, {"w": "https://", "b": [0.7988, 0.4037, 0.8571, 0.4253]}, {"w": "github.com/keras-team/keras).", "b": [0.1429, 0.4227, 0.3903, 0.4443]}, {"w": "It", "b": [0.4011, 0.4229, 0.4137, 0.4443]}, {"w": "was", "b": [0.4245, 0.4229, 0.4556, 0.4443]}, {"w": "developed", "b": [0.4664, 0.4229, 0.5514, 0.4443]}, {"w": "by", "b": [0.5622, 0.4229, 0.5823, 0.4443]}, {"w": "François", "b": [0.5931, 0.4229, 0.665, 0.4443]}, {"w": "Chollet", "b": [0.6758, 0.4229, 0.7371, 0.4443]}, {"w": "as", "b": [0.7479, 0.4229, 0.7647, 0.4443]}, {"w": "part", "b": [0.7755, 0.4229, 0.8096, 0.4443]}, {"w": "of", "b": [0.8204, 0.4229, 0.8372, 0.4443]}, {"w": "a", "b": [0.848, 0.4229, 0.8571, 0.4443]}, {"w": "research", "b": [0.1428, 0.442, 0.2127, 0.4634]}, {"w": "project12", "b": [0.2198, 0.442, 0.2899, 0.4634]}, {"w": "and", "b": [0.297, 0.442, 0.3285, 0.4634]}, {"w": "released", "b": [0.3356, 0.442, 0.403, 0.4634]}, {"w": "as", "b": [0.4101, 0.442, 0.4269, 0.4634]}, {"w": "an", "b": [0.434, 0.442, 0.4545, 0.4634]}, {"w": "open", "b": [0.4616, 0.442, 0.5034, 0.4634]}, {"w": "source", "b": [0.5105, 0.442, 0.5653, 0.4634]}, {"w": "project", "b": [0.5724, 0.442, 0.631, 0.4634]}, {"w": "in", "b": [0.6381, 0.442, 0.6551, 0.4634]}, {"w": "March", "b": [0.6622, 0.442, 0.7172, 0.4634]}, {"w": "2015.", "b": [0.7243, 0.442, 0.769, 0.4634]}, {"w": "It", "b": [0.7761, 0.442, 0.7888, 0.4634]}, {"w": "quickly", "b": [0.7959, 0.442, 0.8571, 0.4634]}, {"w": "gained", "b": [0.1429, 0.461, 0.1986, 0.4824]}, {"w": "popularity", "b": [0.2064, 0.461, 0.2935, 0.4824]}, {"w": "owing", "b": [0.3013, 0.461, 0.3529, 0.4824]}, {"w": "to", "b": [0.3607, 0.461, 0.3777, 0.4824]}, {"w": "its", "b": [0.3855, 0.461, 0.405, 0.4824]}, {"w": "ease-of-use,", "b": [0.4128, 0.461, 0.5113, 0.4824]}, {"w": "flexibility", "b": [0.519, 0.461, 0.5977, 0.4824]}, {"w": "and", "b": [0.6055, 0.461, 0.637, 0.4824]}, {"w": "beautiful", "b": [0.6448, 0.461, 0.7185, 0.4824]}, {"w": "design.", "b": [0.7263, 0.461, 0.7852, 0.4824]}, {"w": "To", "b": [0.793, 0.461, 0.8144, 0.4824]}, {"w": "per‐", "b": [0.8222, 0.461, 0.8571, 0.4824]}, {"w": "form", "b": [0.1428, 0.4801, 0.1844, 0.5015]}, {"w": "the", "b": [0.1925, 0.4801, 0.2189, 0.5015]}, {"w": "heavy", "b": [0.2269, 0.4801, 0.2749, 0.5015]}, {"w": "computations", "b": [0.283, 0.4801, 0.3978, 0.5015]}, {"w": "required", "b": [0.4059, 0.4801, 0.4773, 0.5015]}, {"w": "by", "b": [0.4854, 0.4801, 0.5056, 0.5015]}, {"w": "neural", "b": [0.5136, 0.4801, 0.5671, 0.5015]}, {"w": "networks,", "b": [0.5752, 0.4801, 0.6571, 0.5015]}, {"w": "keras-team", "b": [0.6652, 0.4801, 0.7578, 0.5015]}, {"w": "relies", "b": [0.7659, 0.4801, 0.8098, 0.5015]}, {"w": "on", "b": [0.8179, 0.4801, 0.8399, 0.5015]}, {"w": "a", "b": [0.848, 0.4801, 0.8571, 0.5015]}, {"w": "computation", "b": [0.1429, 0.4991, 0.25, 0.5205]}, {"w": "backend.", "b": [0.26, 0.4991, 0.3349, 0.5205]}, {"w": "At", "b": [0.3448, 0.4991, 0.3647, 0.5205]}, {"w": "the", "b": [0.3747, 0.4991, 0.401, 0.5205]}, {"w": "present,", "b": [0.411, 0.4991, 0.4771, 0.5205]}, {"w": "you", "b": [0.4871, 0.4991, 0.5183, 0.5205]}, {"w": "can", "b": [0.5283, 0.4991, 0.5576, 0.5205]}, {"w": "choose", "b": [0.5676, 0.4991, 0.6253, 0.5205]}, {"w": "from", "b": [0.6353, 0.4991, 0.6769, 0.5205]}, {"w": "three", "b": [0.6868, 0.4991, 0.7297, 0.5205]}, {"w": "popular", "b": [0.7397, 0.4991, 0.8054, 0.5205]}, {"w": "open", "b": [0.8154, 0.4991, 0.8571, 0.5205]}, {"w": "source", "b": [0.1429, 0.5182, 0.1976, 0.5396]}, {"w": "deep", "b": [0.2047, 0.5182, 0.2443, 0.5396]}, {"w": "learning", "b": [0.2515, 0.5182, 0.3206, 0.5396]}, {"w": "libraries:", "b": [0.3277, 0.5182, 0.4006, 0.5396]}, {"w": "TensorFlow,", "b": [0.4077, 0.5182, 0.5092, 0.5396]}, {"w": "Microsoft", "b": [0.5163, 0.5182, 0.5984, 0.5396]}, {"w": "Cognitive", "b": [0.6055, 0.5182, 0.6872, 0.5396]}, {"w": "Toolkit", "b": [0.6943, 0.5182, 0.7539, 0.5396]}, {"w": "(CNTK)", "b": [0.761, 0.5182, 0.8317, 0.5396]}, {"w": "or", "b": [0.8388, 0.5182, 0.8571, 0.5396]}, {"w": "Theano.", "b": [0.1429, 0.5372, 0.211, 0.5586]}]}, {"id": "b_6", "type": "paragraph", "text": "Moreover, since late 2016, other implementations have been released. You can now run Keras on Apache MXNet, Apple’s Core ML, Javascript or Typescript (to run Keras code in a web browser), or PlaidML (which can run on all sorts of GPU devices, not just Nvidia). Moreover, TensorFlow itself now comes bundled with its own Keras implementation called tf.keras. It only supports TensorFlow as the backend, but it has the advantage of offering some very useful extra features (see Figure 10-10): for example, it supports TensorFlow’s Data API which makes it quite easy to load and preprocess data efficiently. For this reason, we will use tf.keras in this book. However, in this chapter we will not use any of the TensorFlow-specific features, so the code should run fine on other Keras implementations as well (at least in Python), with only minor modifications, such as changing the imports.", "words": [{"w": "Moreover,", "b": [0.1429, 0.5653, 0.2284, 0.5867]}, {"w": "since", "b": [0.2355, 0.5653, 0.2778, 0.5867]}, {"w": "late", "b": [0.285, 0.5653, 0.3142, 0.5867]}, {"w": "2016,", "b": [0.3214, 0.5653, 0.3661, 0.5867]}, {"w": "other", "b": [0.3733, 0.5653, 0.4179, 0.5867]}, {"w": "implementations", "b": [0.4251, 0.5653, 0.566, 0.5867]}, {"w": "have", "b": [0.5732, 0.5653, 0.6116, 0.5867]}, {"w": "been", "b": [0.6187, 0.5653, 0.6584, 0.5867]}, {"w": "released.", "b": [0.6656, 0.5653, 0.7377, 0.5867]}, {"w": "You", "b": [0.7448, 0.5653, 0.7772, 0.5867]}, {"w": "can", "b": [0.7843, 0.5653, 0.8137, 0.5867]}, {"w": "now", "b": [0.8208, 0.5653, 0.8571, 0.5867]}, {"w": "run", "b": [0.1429, 0.5844, 0.1731, 0.6058]}, {"w": "Keras", "b": [0.1779, 0.5844, 0.2248, 0.6058]}, {"w": "on", "b": [0.2297, 0.5844, 0.2517, 0.6058]}, {"w": "Apache", "b": [0.2566, 0.5844, 0.319, 0.6058]}, {"w": "MXNet,", "b": [0.3238, 0.5844, 0.3909, 0.6058]}, {"w": "Apple’s", "b": [0.3958, 0.5844, 0.4544, 0.6058]}, {"w": "Core", "b": [0.4593, 0.5844, 0.5003, 0.6058]}, {"w": "ML,", "b": [0.5052, 0.5844, 0.5397, 0.6058]}, {"w": "Javascript", "b": [0.5446, 0.5844, 0.6255, 0.6058]}, {"w": "or", "b": [0.6303, 0.5844, 0.6487, 0.6058]}, {"w": "Typescript", "b": [0.6536, 0.5844, 0.7413, 0.6058]}, {"w": "(to", "b": [0.7461, 0.5844, 0.7703, 0.6058]}, {"w": "run", "b": [0.7752, 0.5844, 0.8054, 0.6058]}, {"w": "Keras", "b": [0.8103, 0.5844, 0.8572, 0.6058]}, {"w": "code", "b": [0.1429, 0.6034, 0.1822, 0.6248]}, {"w": "in", "b": [0.188, 0.6034, 0.205, 0.6248]}, {"w": "a", "b": [0.2108, 0.6034, 0.2199, 0.6248]}, {"w": "web", "b": [0.2258, 0.6034, 0.2595, 0.6248]}, {"w": "browser),", "b": [0.2653, 0.6034, 0.3447, 0.6248]}, {"w": "or", "b": [0.3505, 0.6034, 0.3689, 0.6248]}, {"w": "PlaidML", "b": [0.3747, 0.6034, 0.4472, 0.6248]}, {"w": "(which", "b": [0.453, 0.6034, 0.5112, 0.6248]}, {"w": "can", "b": [0.517, 0.6034, 0.5463, 0.6248]}, {"w": "run", "b": [0.5522, 0.6034, 0.5824, 0.6248]}, {"w": "on", "b": [0.5882, 0.6034, 0.6102, 0.6248]}, {"w": "all", "b": [0.616, 0.6034, 0.6357, 0.6248]}, {"w": "sorts", "b": [0.6416, 0.6034, 0.6816, 0.6248]}, {"w": "of", "b": [0.6874, 0.6034, 0.7042, 0.6248]}, {"w": "GPU", "b": [0.71, 0.6034, 0.752, 0.6248]}, {"w": "devices,", "b": [0.7578, 0.6034, 0.8229, 0.6248]}, {"w": "not", "b": [0.8288, 0.6034, 0.8571, 0.6248]}, {"w": "just", "b": [0.1429, 0.6225, 0.1732, 0.6439]}, {"w": "Nvidia).", "b": [0.1818, 0.6225, 0.2496, 0.6439]}, {"w": "Moreover,", "b": [0.2581, 0.6225, 0.3436, 0.6439]}, {"w": "TensorFlow", "b": [0.3522, 0.6225, 0.4504, 0.6439]}, {"w": "itself", "b": [0.4589, 0.6225, 0.4988, 0.6439]}, {"w": "now", "b": [0.5074, 0.6225, 0.5436, 0.6439]}, {"w": "comes", "b": [0.5522, 0.6225, 0.6052, 0.6439]}, {"w": "bundled", "b": [0.6137, 0.6225, 0.6829, 0.6439]}, {"w": "with", "b": [0.6914, 0.6225, 0.7288, 0.6439]}, {"w": "its", "b": [0.7373, 0.6225, 0.7569, 0.6439]}, {"w": "own", "b": [0.7654, 0.6225, 0.8017, 0.6439]}, {"w": "Keras", "b": [0.8102, 0.6225, 0.8571, 0.6439]}, {"w": "implementation", "b": [0.1428, 0.6415, 0.2761, 0.6629]}, {"w": "called", "b": [0.2812, 0.6415, 0.3295, 0.6629]}, {"w": "tf.keras.", "b": [0.3345, 0.6415, 0.4003, 0.6629]}, {"w": "It", "b": [0.4053, 0.6415, 0.418, 0.6629]}, {"w": "only", "b": [0.423, 0.6415, 0.4598, 0.6629]}, {"w": "supports", "b": [0.4649, 0.6415, 0.5378, 0.6629]}, {"w": "TensorFlow", "b": [0.5428, 0.6415, 0.6411, 0.6629]}, {"w": "as", "b": [0.6461, 0.6415, 0.6629, 0.6629]}, {"w": "the", "b": [0.6679, 0.6415, 0.6943, 0.6629]}, {"w": "backend,", "b": [0.6993, 0.6415, 0.7742, 0.6629]}, {"w": "but", "b": [0.7792, 0.6415, 0.8072, 0.6629]}, {"w": "it", "b": [0.8122, 0.6415, 0.8242, 0.6629]}, {"w": "has", "b": [0.8292, 0.6415, 0.8571, 0.6629]}, {"w": "the", "b": [0.1429, 0.6606, 0.1692, 0.682]}, {"w": "advantage", "b": [0.1786, 0.6606, 0.2626, 0.682]}, {"w": "of", "b": [0.272, 0.6606, 0.2888, 0.682]}, {"w": "offering", "b": [0.2981, 0.6606, 0.3644, 0.682]}, {"w": "some", "b": [0.3738, 0.6606, 0.418, 0.682]}, {"w": "very", "b": [0.4273, 0.6606, 0.4637, 0.682]}, {"w": "useful", "b": [0.4731, 0.6606, 0.5232, 0.682]}, {"w": "extra", "b": [0.5325, 0.6606, 0.5744, 0.682]}, {"w": "features", "b": [0.5838, 0.6606, 0.6492, 0.682]}, {"w": "(see", "b": [0.6586, 0.6606, 0.6911, 0.682]}, {"w": "Figure", "b": [0.7005, 0.6606, 0.7545, 0.682]}, {"w": "10-10):", "b": [0.7639, 0.6606, 0.8233, 0.682]}, {"w": "for", "b": [0.8326, 0.6606, 0.8571, 0.682]}, {"w": "example,", "b": [0.1429, 0.6796, 0.2171, 0.701]}, {"w": "it", "b": [0.2245, 0.6796, 0.2364, 0.701]}, {"w": "supports", "b": [0.2438, 0.6796, 0.3167, 0.701]}, {"w": "TensorFlow’s", "b": [0.3241, 0.6796, 0.4326, 0.701]}, {"w": "Data", "b": [0.44, 0.6796, 0.4795, 0.701]}, {"w": "API", "b": [0.4869, 0.6796, 0.5201, 0.701]}, {"w": "which", "b": [0.5275, 0.6796, 0.5784, 0.701]}, {"w": "makes", "b": [0.5858, 0.6796, 0.6388, 0.701]}, {"w": "it", "b": [0.6461, 0.6796, 0.6581, 0.701]}, {"w": "quite", "b": [0.6654, 0.6796, 0.7079, 0.701]}, {"w": "easy", "b": [0.7153, 0.6796, 0.7505, 0.701]}, {"w": "to", "b": [0.7579, 0.6796, 0.7748, 0.701]}, {"w": "load", "b": [0.7822, 0.6796, 0.8182, 0.701]}, {"w": "and", "b": [0.8256, 0.6796, 0.8571, 0.701]}, {"w": "preprocess", "b": [0.1429, 0.6987, 0.2326, 0.7201]}, {"w": "data", "b": [0.2379, 0.6987, 0.2731, 0.7201]}, {"w": "efficiently.", "b": [0.2784, 0.6987, 0.3638, 0.7201]}, {"w": "For", "b": [0.3691, 0.6987, 0.3981, 0.7201]}, {"w": "this", "b": [0.4033, 0.6987, 0.434, 0.7201]}, {"w": "reason,", "b": [0.4393, 0.6987, 0.4995, 0.7201]}, {"w": "we", "b": [0.5047, 0.6987, 0.5278, 0.7201]}, {"w": "will", "b": [0.5331, 0.6987, 0.5635, 0.7201]}, {"w": "use", "b": [0.5688, 0.6987, 0.5963, 0.7201]}, {"w": "tf.keras", "b": [0.6016, 0.6987, 0.6626, 0.7201]}, {"w": "in", "b": [0.6679, 0.6987, 0.6848, 0.7201]}, {"w": "this", "b": [0.6901, 0.6987, 0.7208, 0.7201]}, {"w": "book.", "b": [0.7261, 0.6987, 0.773, 0.7201]}, {"w": "However,", "b": [0.7783, 0.6987, 0.8571, 0.7201]}, {"w": "in", "b": [0.1429, 0.7177, 0.1598, 0.7391]}, {"w": "this", "b": [0.167, 0.7177, 0.1977, 0.7391]}, {"w": "chapter", "b": [0.2048, 0.7177, 0.2673, 0.7391]}, {"w": "we", "b": [0.2745, 0.7177, 0.2976, 0.7391]}, {"w": "will", "b": [0.3047, 0.7177, 0.3351, 0.7391]}, {"w": "not", "b": [0.3422, 0.7177, 0.3706, 0.7391]}, {"w": "use", "b": [0.3777, 0.7177, 0.4053, 0.7391]}, {"w": "any", "b": [0.4124, 0.7177, 0.4421, 0.7391]}, {"w": "of", "b": [0.4492, 0.7177, 0.466, 0.7391]}, {"w": "the", "b": [0.4731, 0.7177, 0.4994, 0.7391]}, {"w": "TensorFlow-specific", "b": [0.5065, 0.7177, 0.6746, 0.7391]}, {"w": "features,", "b": [0.6817, 0.7177, 0.7519, 0.7391]}, {"w": "so", "b": [0.759, 0.7177, 0.7773, 0.7391]}, {"w": "the", "b": [0.7844, 0.7177, 0.8107, 0.7391]}, {"w": "code", "b": [0.8179, 0.7177, 0.8572, 0.7391]}, {"w": "should", "b": [0.1429, 0.7368, 0.1996, 0.7582]}, {"w": "run", "b": [0.2043, 0.7368, 0.2345, 0.7582]}, {"w": "fine", "b": [0.2392, 0.7368, 0.2712, 0.7582]}, {"w": "on", "b": [0.276, 0.7368, 0.298, 0.7582]}, {"w": "other", "b": [0.3027, 0.7368, 0.3474, 0.7582]}, {"w": "Keras", "b": [0.3521, 0.7368, 0.399, 0.7582]}, {"w": "implementations", "b": [0.4038, 0.7368, 0.5447, 0.7582]}, {"w": "as", "b": [0.5494, 0.7368, 0.5662, 0.7582]}, {"w": "well", "b": [0.5709, 0.7368, 0.6046, 0.7582]}, {"w": "(at", "b": [0.6093, 0.7368, 0.6316, 0.7582]}, {"w": "least", "b": [0.6364, 0.7368, 0.6736, 0.7582]}, {"w": "in", "b": [0.6784, 0.7368, 0.6953, 0.7582]}, {"w": "Python),", "b": [0.7001, 0.7368, 0.7728, 0.7582]}, {"w": "with", "b": [0.7775, 0.7368, 0.8149, 0.7582]}, {"w": "only", "b": [0.8196, 0.7368, 0.8565, 0.7582]}, {"w": "minor", "b": [0.1429, 0.7558, 0.1953, 0.7772]}, {"w": "modifications,", "b": [0.2, 0.7558, 0.3199, 0.7772]}, {"w": "such", "b": [0.3247, 0.7558, 0.3633, 0.7772]}, {"w": "as", "b": [0.368, 0.7558, 0.3848, 0.7772]}, {"w": "changing", "b": [0.3895, 0.7558, 0.4665, 0.7772]}, {"w": "the", "b": [0.4712, 0.7558, 0.4976, 0.7772]}, {"w": "imports.", "b": [0.5023, 0.7558, 0.5726, 0.7772]}]}, {"id": "b_7", "type": "paragraph", "text": "292 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "292", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 319, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 10-10. Two Keras implementations: keras-team (left) and tf.keras (right)", "words": [{"w": "Figure", "b": [0.1429, 0.2979, 0.1943, 0.3195]}, {"w": "10-10.", "b": [0.1991, 0.2979, 0.2507, 0.3195]}, {"w": "Two", "b": [0.2554, 0.2979, 0.2901, 0.3195]}, {"w": "Keras", "b": [0.2948, 0.2979, 0.3407, 0.3195]}, {"w": "implementations:", "b": [0.3455, 0.2979, 0.4858, 0.3195]}, {"w": "keras-team", "b": [0.4906, 0.2979, 0.5807, 0.3195]}, {"w": "(left)", "b": [0.5854, 0.2979, 0.6248, 0.3195]}, {"w": "and", "b": [0.6295, 0.2979, 0.6609, 0.3195]}, {"w": "tf.keras", "b": [0.6657, 0.2979, 0.7246, 0.3195]}, {"w": "(right)", "b": [0.7294, 0.2979, 0.782, 0.3195]}]}, {"id": "b_1", "type": "paragraph", "text": "As tf.keras is bundled with TensorFlow, let’s install TensorFlow!", "words": [{"w": "As", "b": [0.1429, 0.3353, 0.1649, 0.3567]}, {"w": "tf.keras", "b": [0.1696, 0.3353, 0.2306, 0.3567]}, {"w": "is", "b": [0.2353, 0.3353, 0.2486, 0.3567]}, {"w": "bundled", "b": [0.2533, 0.3353, 0.3225, 0.3567]}, {"w": "with", "b": [0.3272, 0.3353, 0.3645, 0.3567]}, {"w": "TensorFlow,", "b": [0.3693, 0.3353, 0.4707, 0.3567]}, {"w": "let’s", "b": [0.4755, 0.3353, 0.5057, 0.3567]}, {"w": "install", "b": [0.5104, 0.3353, 0.5611, 0.3567]}, {"w": "TensorFlow!", "b": [0.5658, 0.3353, 0.6698, 0.3567]}]}, {"id": "b_2", "type": "paragraph", "text": "Installing TensorFlow 2", "words": [{"w": "Installing", "b": [0.1429, 0.3695, 0.2409, 0.3981]}, {"w": "TensorFlow", "b": [0.2459, 0.3695, 0.3641, 0.3981]}, {"w": "2", "b": [0.3691, 0.3695, 0.3819, 0.3981]}]}, {"id": "b_3", "type": "paragraph", "text": "Assuming you installed Jupyter and Scikit-Learn by following the installation instruc‐ tions in Chapter 2, you can simply use pip to install TensorFlow. If you created an isolated environment using virtualenv, you first need to activate it:", "words": [{"w": "Assuming", "b": [0.1429, 0.404, 0.2274, 0.4254]}, {"w": "you", "b": [0.2323, 0.404, 0.2635, 0.4254]}, {"w": "installed", "b": [0.2684, 0.404, 0.3389, 0.4254]}, {"w": "Jupyter", "b": [0.3438, 0.404, 0.4044, 0.4254]}, {"w": "and", "b": [0.4093, 0.404, 0.4408, 0.4254]}, {"w": "Scikit-Learn", "b": [0.4457, 0.404, 0.548, 0.4254]}, {"w": "by", "b": [0.5529, 0.404, 0.573, 0.4254]}, {"w": "following", "b": [0.5779, 0.404, 0.6568, 0.4254]}, {"w": "the", "b": [0.6617, 0.404, 0.688, 0.4254]}, {"w": "installation", "b": [0.6929, 0.404, 0.7863, 0.4254]}, {"w": "instruc‐", "b": [0.7911, 0.404, 0.8571, 0.4254]}, {"w": "tions", "b": [0.1429, 0.423, 0.1845, 0.4444]}, {"w": "in", "b": [0.1916, 0.423, 0.2086, 0.4444]}, {"w": "Chapter", "b": [0.2158, 0.423, 0.2834, 0.4444]}, {"w": "2,", "b": [0.2905, 0.423, 0.3053, 0.4444]}, {"w": "you", "b": [0.3125, 0.423, 0.3437, 0.4444]}, {"w": "can", "b": [0.3509, 0.423, 0.3802, 0.4444]}, {"w": "simply", "b": [0.3874, 0.423, 0.4431, 0.4444]}, {"w": "use", "b": [0.4502, 0.423, 0.4778, 0.4444]}, {"w": "pip", "b": [0.485, 0.423, 0.5124, 0.4444]}, {"w": "to", "b": [0.5196, 0.423, 0.5365, 0.4444]}, {"w": "install", "b": [0.5437, 0.423, 0.5944, 0.4444]}, {"w": "TensorFlow.", "b": [0.6015, 0.423, 0.703, 0.4444]}, {"w": "If", "b": [0.7102, 0.423, 0.7235, 0.4444]}, {"w": "you", "b": [0.7306, 0.423, 0.7619, 0.4444]}, {"w": "created", "b": [0.7691, 0.423, 0.8294, 0.4444]}, {"w": "an", "b": [0.8366, 0.423, 0.8571, 0.4444]}, {"w": "isolated", "b": [0.1429, 0.4421, 0.2069, 0.4635]}, {"w": "environment", "b": [0.2117, 0.4421, 0.3197, 0.4635]}, {"w": "using", "b": [0.3244, 0.4421, 0.3699, 0.4635]}, {"w": "virtualenv,", "b": [0.3746, 0.4421, 0.462, 0.4635]}, {"w": "you", "b": [0.4668, 0.4421, 0.498, 0.4635]}, {"w": "first", "b": [0.5027, 0.4421, 0.5362, 0.4635]}, {"w": "need", "b": [0.5409, 0.4421, 0.5811, 0.4635]}, {"w": "to", "b": [0.5858, 0.4421, 0.6028, 0.4635]}, {"w": "activate", "b": [0.6075, 0.4421, 0.671, 0.4635]}, {"w": "it:", "b": [0.6757, 0.4421, 0.6924, 0.4635]}]}, {"id": "b_4", "type": "paragraph", "text": "$ cd $ML_PATH # Your ML working directory (e.g., $HOME/ml) $ source env/bin/activate # on Linux or MacOSX $ .\\env\\Scripts\\activate # on Windows", "words": [{"w": "$", "b": [0.1766, 0.474, 0.185, 0.4869]}, {"w": "cd", "b": [0.1935, 0.474, 0.2103, 0.4869]}, {"w": "$ML_PATH", "b": [0.2188, 0.474, 0.2862, 0.4869]}, {"w": "#", "b": [0.4043, 0.474, 0.4127, 0.4869]}, {"w": "Your", "b": [0.4211, 0.474, 0.4549, 0.4869]}, {"w": "ML", "b": [0.4633, 0.474, 0.4802, 0.4869]}, {"w": "working", "b": [0.4886, 0.474, 0.5476, 0.4869]}, {"w": "directory", "b": [0.5561, 0.474, 0.6319, 0.4869]}, {"w": "(e.g.,", "b": [0.6404, 0.474, 0.691, 0.4869]}, {"w": "$HOME/ml)", "b": [0.6994, 0.474, 0.7753, 0.4869]}, {"w": "$", "b": [0.1766, 0.4894, 0.185, 0.5023]}, {"w": "source", "b": [0.1935, 0.4894, 0.244, 0.5023]}, {"w": "env/bin/activate", "b": [0.2525, 0.4894, 0.3874, 0.5023]}, {"w": "#", "b": [0.4043, 0.4894, 0.4127, 0.5023]}, {"w": "on", "b": [0.4211, 0.4894, 0.438, 0.5023]}, {"w": "Linux", "b": [0.4464, 0.4894, 0.4886, 0.5023]}, {"w": "or", "b": [0.497, 0.4894, 0.5139, 0.5023]}, {"w": "MacOSX", "b": [0.5223, 0.4894, 0.5729, 0.5023]}, {"w": "$", "b": [0.1766, 0.5049, 0.185, 0.5177]}, {"w": ".\\env\\Scripts\\activate", "b": [0.1935, 0.5049, 0.379, 0.5177]}, {"w": "#", "b": [0.4043, 0.5049, 0.4127, 0.5177]}, {"w": "on", "b": [0.4211, 0.5049, 0.438, 0.5177]}, {"w": "Windows", "b": [0.4464, 0.5049, 0.5055, 0.5177]}]}, {"id": "b_5", "type": "paragraph", "text": "Next, install TensorFlow 2 (if you are not using a virtualenv, you will need adminis‐ trator rights, or to add the --user option):", "words": [{"w": "Next,", "b": [0.1429, 0.5255, 0.1876, 0.5469]}, {"w": "install", "b": [0.1939, 0.5255, 0.2445, 0.5469]}, {"w": "TensorFlow", "b": [0.2508, 0.5255, 0.349, 0.5469]}, {"w": "2", "b": [0.3553, 0.5255, 0.3653, 0.5469]}, {"w": "(if", "b": [0.3716, 0.5255, 0.3905, 0.5469]}, {"w": "you", "b": [0.3968, 0.5255, 0.4281, 0.5469]}, {"w": "are", "b": [0.4343, 0.5255, 0.46, 0.5469]}, {"w": "not", "b": [0.4663, 0.5255, 0.4947, 0.5469]}, {"w": "using", "b": [0.5009, 0.5255, 0.5464, 0.5469]}, {"w": "a", "b": [0.5527, 0.5255, 0.5618, 0.5469]}, {"w": "virtualenv,", "b": [0.5681, 0.5255, 0.6555, 0.5469]}, {"w": "you", "b": [0.6618, 0.5255, 0.693, 0.5469]}, {"w": "will", "b": [0.6993, 0.5255, 0.7297, 0.5469]}, {"w": "need", "b": [0.7359, 0.5255, 0.776, 0.5469]}, {"w": "adminis‐", "b": [0.7823, 0.5255, 0.8571, 0.5469]}, {"w": "trator", "b": [0.1428, 0.5454, 0.1904, 0.5669]}, {"w": "rights,", "b": [0.1951, 0.5454, 0.2477, 0.5669]}, {"w": "or", "b": [0.2524, 0.5454, 0.2707, 0.5669]}, {"w": "to", "b": [0.2755, 0.5454, 0.2925, 0.5669]}, {"w": "add", "b": [0.2972, 0.5454, 0.3283, 0.5669]}, {"w": "the", "b": [0.3331, 0.5454, 0.3594, 0.5669]}, {"w": "--user", "b": [0.3641, 0.5486, 0.4235, 0.5637]}, {"w": "option):", "b": [0.4282, 0.5454, 0.4957, 0.5669]}]}, {"id": "b_6", "type": "equation", "text": "$ python3 -m pip install --upgrade tensorflow", "words": [{"w": "$", "b": [0.1766, 0.5774, 0.185, 0.5903]}, {"w": "python3", "b": [0.1935, 0.5774, 0.2525, 0.5903]}, {"w": "-m", "b": [0.2609, 0.5774, 0.2778, 0.5903]}, {"w": "pip", "b": [0.2862, 0.5774, 0.3115, 0.5903]}, {"w": "install", "b": [0.3199, 0.5774, 0.379, 0.5903]}, {"w": "--upgrade", "b": [0.3874, 0.5774, 0.4633, 0.5903]}, {"w": "tensorflow", "b": [0.4717, 0.5774, 0.5561, 0.5903]}]}, {"id": "b_7", "type": "paragraph", "text": "For GPU support, you need to install tensorflow-gpu instead of tensorflow, and there are other libraries to install. See https:// tensorflow.org/install/gpu for more details.", "words": [{"w": "For", "b": [0.2714, 0.6127, 0.2979, 0.6323]}, {"w": "GPU", "b": [0.3047, 0.6127, 0.3431, 0.6323]}, {"w": "support,", "b": [0.3499, 0.6127, 0.4139, 0.6323]}, {"w": "you", "b": [0.4208, 0.6127, 0.4493, 0.6323]}, {"w": "need", "b": [0.4562, 0.6127, 0.4928, 0.6323]}, {"w": "to", "b": [0.4997, 0.6127, 0.5152, 0.6323]}, {"w": "install", "b": [0.522, 0.6127, 0.5684, 0.6323]}, {"w": "tensorflow-gpu", "b": [0.5752, 0.6156, 0.7019, 0.6294]}, {"w": "instead", "b": [0.7087, 0.6127, 0.7635, 0.6323]}, {"w": "of", "b": [0.7704, 0.6127, 0.7857, 0.6323]}, {"w": "tensorflow,", "b": [0.2714, 0.6309, 0.3662, 0.6505]}, {"w": "and", "b": [0.3751, 0.6309, 0.4039, 0.6505]}, {"w": "there", "b": [0.4127, 0.6309, 0.452, 0.6505]}, {"w": "are", "b": [0.4608, 0.6309, 0.4843, 0.6505]}, {"w": "other", "b": [0.4932, 0.6309, 0.534, 0.6505]}, {"w": "libraries", "b": [0.5428, 0.6309, 0.6051, 0.6505]}, {"w": "to", "b": [0.614, 0.6309, 0.6295, 0.6505]}, {"w": "install.", "b": [0.6383, 0.6309, 0.689, 0.6505]}, {"w": "See", "b": [0.6978, 0.6309, 0.723, 0.6505]}, {"w": "https://", "b": [0.7319, 0.6307, 0.7857, 0.6505]}, {"w": "tensorflow.org/install/gpu", "b": [0.2714, 0.6482, 0.4636, 0.6679]}, {"w": "for", "b": [0.4679, 0.6483, 0.4903, 0.6679]}, {"w": "more", "b": [0.4946, 0.6483, 0.5351, 0.6679]}, {"w": "details.", "b": [0.5394, 0.6483, 0.593, 0.6679]}]}, {"id": "b_8", "type": "paragraph", "text": "To test your installation, open a Python shell or a Jupyter notebook, then import Ten‐ sorFlow and tf.keras, and print their versions:", "words": [{"w": "To", "b": [0.1428, 0.7105, 0.1643, 0.7319]}, {"w": "test", "b": [0.1693, 0.7105, 0.1985, 0.7319]}, {"w": "your", "b": [0.2035, 0.7105, 0.2425, 0.7319]}, {"w": "installation,", "b": [0.2475, 0.7105, 0.3456, 0.7319]}, {"w": "open", "b": [0.3507, 0.7105, 0.3925, 0.7319]}, {"w": "a", "b": [0.3975, 0.7105, 0.4066, 0.7319]}, {"w": "Python", "b": [0.4116, 0.7105, 0.4724, 0.7319]}, {"w": "shell", "b": [0.4774, 0.7105, 0.5156, 0.7319]}, {"w": "or", "b": [0.5206, 0.7105, 0.539, 0.7319]}, {"w": "a", "b": [0.544, 0.7105, 0.5531, 0.7319]}, {"w": "Jupyter", "b": [0.5582, 0.7105, 0.6188, 0.7319]}, {"w": "notebook,", "b": [0.6239, 0.7105, 0.708, 0.7319]}, {"w": "then", "b": [0.713, 0.7105, 0.7507, 0.7319]}, {"w": "import", "b": [0.7558, 0.7105, 0.8136, 0.7319]}, {"w": "Ten‐", "b": [0.8187, 0.7105, 0.8571, 0.7319]}, {"w": "sorFlow", "b": [0.1429, 0.7296, 0.21, 0.751]}, {"w": "and", "b": [0.2148, 0.7296, 0.2463, 0.751]}, {"w": "tf.keras,", "b": [0.251, 0.7296, 0.3168, 0.751]}, {"w": "and", "b": [0.3215, 0.7296, 0.353, 0.751]}, {"w": "print", "b": [0.3578, 0.7296, 0.3994, 0.751]}, {"w": "their", "b": [0.4041, 0.7296, 0.4437, 0.751]}, {"w": "versions:", "b": [0.4485, 0.7296, 0.5223, 0.751]}]}, {"id": "b_9", "type": "paragraph", "text": ">>> import tensorflow as tf >>> from tensorflow import keras >>> tf.__version__ '2.0.0' >>> keras.__version__ '2.2.4-tf'", "words": [{"w": ">>>", "b": [0.1766, 0.7615, 0.2019, 0.7744]}, {"w": "import", "b": [0.2103, 0.7615, 0.2609, 0.7744]}, {"w": "tensorflow", "b": [0.2693, 0.7615, 0.3537, 0.7744]}, {"w": "as", "b": [0.3621, 0.7615, 0.379, 0.7744]}, {"w": "tf", "b": [0.3874, 0.7615, 0.4043, 0.7744]}, {"w": ">>>", "b": [0.1766, 0.777, 0.2019, 0.7898]}, {"w": "from", "b": [0.2103, 0.777, 0.2441, 0.7898]}, {"w": "tensorflow", "b": [0.2525, 0.777, 0.3368, 0.7898]}, {"w": "import", "b": [0.3452, 0.777, 0.3958, 0.7898]}, {"w": "keras", "b": [0.4043, 0.777, 0.4464, 0.7898]}, {"w": ">>>", "b": [0.1766, 0.7924, 0.2019, 0.8052]}, {"w": "tf.__version__", "b": [0.2103, 0.7924, 0.3284, 0.8052]}, {"w": "'2.0.0'", "b": [0.1766, 0.8078, 0.2356, 0.8207]}, {"w": ">>>", "b": [0.1766, 0.8232, 0.2019, 0.8361]}, {"w": "keras.__version__", "b": [0.2103, 0.8232, 0.3537, 0.8361]}, {"w": "'2.2.4-tf'", "b": [0.1766, 0.8386, 0.2609, 0.8515]}]}, {"id": "b_10", "type": "paragraph", "text": "Implementing MLPs with Keras | 293", "words": [{"w": "Implementing", "b": [0.6126, 0.9225, 0.6972, 0.9388]}, {"w": "MLPs", "b": [0.7001, 0.9225, 0.7308, 0.9388]}, {"w": "with", "b": [0.7336, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "293", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 320, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "The second version is the version of the Keras API implemented by tf.keras. Note that it ends with -tf, highlighting the fact that tf.keras implements the Keras API, plus some extra TensorFlow-specific features.", "words": [{"w": "The", "b": [0.1429, 0.0791, 0.1757, 0.1005]}, {"w": "second", "b": [0.1805, 0.0791, 0.2389, 0.1005]}, {"w": "version", "b": [0.2437, 0.0791, 0.3052, 0.1005]}, {"w": "is", "b": [0.31, 0.0791, 0.3232, 0.1005]}, {"w": "the", "b": [0.3281, 0.0791, 0.3544, 0.1005]}, {"w": "version", "b": [0.3592, 0.0791, 0.4207, 0.1005]}, {"w": "of", "b": [0.4256, 0.0791, 0.4423, 0.1005]}, {"w": "the", "b": [0.4472, 0.0791, 0.4735, 0.1005]}, {"w": "Keras", "b": [0.4783, 0.0791, 0.5252, 0.1005]}, {"w": "API", "b": [0.5301, 0.0791, 0.5633, 0.1005]}, {"w": "implemented", "b": [0.5681, 0.0791, 0.6786, 0.1005]}, {"w": "by", "b": [0.6834, 0.0791, 0.7035, 0.1005]}, {"w": "tf.keras.", "b": [0.7084, 0.0791, 0.7741, 0.1005]}, {"w": "Note", "b": [0.7789, 0.0791, 0.8197, 0.1005]}, {"w": "that", "b": [0.8246, 0.0791, 0.8571, 0.1005]}, {"w": "it", "b": [0.1429, 0.099, 0.1548, 0.1204]}, {"w": "ends", "b": [0.1621, 0.099, 0.201, 0.1204]}, {"w": "with", "b": [0.2083, 0.099, 0.2456, 0.1204]}, {"w": "-tf,", "b": [0.2529, 0.099, 0.2874, 0.1204]}, {"w": "highlighting", "b": [0.2947, 0.099, 0.3967, 0.1204]}, {"w": "the", "b": [0.404, 0.099, 0.4303, 0.1204]}, {"w": "fact", "b": [0.4376, 0.099, 0.4681, 0.1204]}, {"w": "that", "b": [0.4754, 0.099, 0.508, 0.1204]}, {"w": "tf.keras", "b": [0.5153, 0.099, 0.5763, 0.1204]}, {"w": "implements", "b": [0.5836, 0.099, 0.6818, 0.1204]}, {"w": "the", "b": [0.6891, 0.099, 0.7154, 0.1204]}, {"w": "Keras", "b": [0.7228, 0.099, 0.7696, 0.1204]}, {"w": "API,", "b": [0.777, 0.099, 0.8149, 0.1204]}, {"w": "plus", "b": [0.8222, 0.099, 0.8571, 0.1204]}, {"w": "some", "b": [0.1429, 0.1181, 0.1871, 0.1395]}, {"w": "extra", "b": [0.1918, 0.1181, 0.2337, 0.1395]}, {"w": "TensorFlow-specific", "b": [0.2384, 0.1181, 0.4065, 0.1395]}, {"w": "features.", "b": [0.4112, 0.1181, 0.4814, 0.1395]}]}, {"id": "b_1", "type": "paragraph", "text": "Now let’s use tf.keras! Let’s start by building a simple image classifier.", "words": [{"w": "Now", "b": [0.1429, 0.1462, 0.1827, 0.1676]}, {"w": "let’s", "b": [0.1874, 0.1462, 0.2177, 0.1676]}, {"w": "use", "b": [0.2224, 0.1462, 0.25, 0.1676]}, {"w": "tf.keras!", "b": [0.2547, 0.1462, 0.3214, 0.1676]}, {"w": "Let’s", "b": [0.3262, 0.1462, 0.3623, 0.1676]}, {"w": "start", "b": [0.3671, 0.1462, 0.4043, 0.1676]}, {"w": "by", "b": [0.409, 0.1462, 0.4292, 0.1676]}, {"w": "building", "b": [0.4339, 0.1462, 0.5041, 0.1676]}, {"w": "a", "b": [0.5088, 0.1462, 0.518, 0.1676]}, {"w": "simple", "b": [0.5227, 0.1462, 0.5777, 0.1676]}, {"w": "image", "b": [0.5824, 0.1462, 0.6328, 0.1676]}, {"w": "classifier.", "b": [0.6375, 0.1462, 0.7134, 0.1676]}]}, {"id": "b_2", "type": "paragraph", "text": "Building an Image Classifier Using the Sequential API", "words": [{"w": "Building", "b": [0.1429, 0.1804, 0.23, 0.2089]}, {"w": "an", "b": [0.2349, 0.1804, 0.2609, 0.2089]}, {"w": "Image", "b": [0.2659, 0.1804, 0.3314, 0.2089]}, {"w": "Classifier", "b": [0.3363, 0.1804, 0.4282, 0.2089]}, {"w": "Using", "b": [0.4331, 0.1804, 0.4911, 0.2089]}, {"w": "the", "b": [0.496, 0.1804, 0.5309, 0.2089]}, {"w": "Sequential", "b": [0.5359, 0.1804, 0.647, 0.2089]}, {"w": "API", "b": [0.6519, 0.1804, 0.6865, 0.2089]}]}, {"id": "b_3", "type": "paragraph", "text": "First, we need to load a dataset. We will tackle Fashion MNIST, which is a drop-in replacement of MNIST (introduced in Chapter 3). It has the exact same format as MNIST (70,000 grayscale images of 28×28 pixels each, with 10 classes), but the images represent fashion items rather than handwritten digits, so each class is more diverse and the problem turns out to be significantly more challenging than MNIST. For example, a simple linear model reaches about 92% accuracy on MNIST, but only about 83% on Fashion MNIST.", "words": [{"w": "First,", "b": [0.1429, 0.2148, 0.1859, 0.2362]}, {"w": "we", "b": [0.1932, 0.2148, 0.2163, 0.2362]}, {"w": "need", "b": [0.2235, 0.2148, 0.2636, 0.2362]}, {"w": "to", "b": [0.2708, 0.2148, 0.2878, 0.2362]}, {"w": "load", "b": [0.295, 0.2148, 0.3311, 0.2362]}, {"w": "a", "b": [0.3383, 0.2148, 0.3474, 0.2362]}, {"w": "dataset.", "b": [0.3547, 0.2148, 0.4175, 0.2362]}, {"w": "We", "b": [0.4247, 0.2148, 0.4518, 0.2362]}, {"w": "will", "b": [0.459, 0.2148, 0.4894, 0.2362]}, {"w": "tackle", "b": [0.4966, 0.2148, 0.5454, 0.2362]}, {"w": "Fashion", "b": [0.5526, 0.2146, 0.6165, 0.2362]}, {"w": "MNIST,", "b": [0.6237, 0.2146, 0.6903, 0.2362]}, {"w": "which", "b": [0.6975, 0.2148, 0.7484, 0.2362]}, {"w": "is", "b": [0.7557, 0.2148, 0.7689, 0.2362]}, {"w": "a", "b": [0.7761, 0.2148, 0.7853, 0.2362]}, {"w": "drop-in", "b": [0.7925, 0.2148, 0.8571, 0.2362]}, {"w": "replacement", "b": [0.1428, 0.2339, 0.2457, 0.2553]}, {"w": "of", "b": [0.2533, 0.2339, 0.2701, 0.2553]}, {"w": "MNIST", "b": [0.2777, 0.2339, 0.3416, 0.2553]}, {"w": "(introduced", "b": [0.3492, 0.2339, 0.4484, 0.2553]}, {"w": "in", "b": [0.456, 0.2339, 0.473, 0.2553]}, {"w": "Chapter", "b": [0.4806, 0.2339, 0.5482, 0.2553]}, {"w": "3).", "b": [0.5558, 0.2339, 0.5778, 0.2553]}, {"w": "It", "b": [0.5854, 0.2339, 0.598, 0.2553]}, {"w": "has", "b": [0.6056, 0.2339, 0.6336, 0.2553]}, {"w": "the", "b": [0.6412, 0.2339, 0.6675, 0.2553]}, {"w": "exact", "b": [0.6751, 0.2339, 0.7181, 0.2553]}, {"w": "same", "b": [0.7257, 0.2339, 0.7684, 0.2553]}, {"w": "format", "b": [0.776, 0.2339, 0.8327, 0.2553]}, {"w": "as", "b": [0.8403, 0.2339, 0.8571, 0.2553]}, {"w": "MNIST", "b": [0.1429, 0.2529, 0.2067, 0.2743]}, {"w": "(70,000", "b": [0.2165, 0.2529, 0.2784, 0.2743]}, {"w": "grayscale", "b": [0.2881, 0.2529, 0.3637, 0.2743]}, {"w": "images", "b": [0.3734, 0.2529, 0.4314, 0.2743]}, {"w": "of", "b": [0.4411, 0.2529, 0.4579, 0.2743]}, {"w": "28×28", "b": [0.4676, 0.2529, 0.5197, 0.2743]}, {"w": "pixels", "b": [0.5294, 0.2529, 0.5775, 0.2743]}, {"w": "each,", "b": [0.5872, 0.2529, 0.6299, 0.2743]}, {"w": "with", "b": [0.6396, 0.2529, 0.677, 0.2743]}, {"w": "10", "b": [0.6867, 0.2529, 0.7067, 0.2743]}, {"w": "classes),", "b": [0.7164, 0.2529, 0.7834, 0.2743]}, {"w": "but", "b": [0.7931, 0.2529, 0.8211, 0.2743]}, {"w": "the", "b": [0.8308, 0.2529, 0.8571, 0.2743]}, {"w": "images", "b": [0.1429, 0.272, 0.2009, 0.2934]}, {"w": "represent", "b": [0.2073, 0.272, 0.2852, 0.2934]}, {"w": "fashion", "b": [0.2916, 0.272, 0.3533, 0.2934]}, {"w": "items", "b": [0.3596, 0.272, 0.4051, 0.2934]}, {"w": "rather", "b": [0.4115, 0.272, 0.462, 0.2934]}, {"w": "than", "b": [0.4684, 0.272, 0.5064, 0.2934]}, {"w": "handwritten", "b": [0.5128, 0.272, 0.616, 0.2934]}, {"w": "digits,", "b": [0.6224, 0.272, 0.6731, 0.2934]}, {"w": "so", "b": [0.6794, 0.272, 0.6977, 0.2934]}, {"w": "each", "b": [0.7041, 0.272, 0.742, 0.2934]}, {"w": "class", "b": [0.7484, 0.272, 0.7869, 0.2934]}, {"w": "is", "b": [0.7933, 0.272, 0.8065, 0.2934]}, {"w": "more", "b": [0.8129, 0.272, 0.8571, 0.2934]}, {"w": "diverse", "b": [0.1429, 0.291, 0.2022, 0.3124]}, {"w": "and", "b": [0.208, 0.291, 0.2396, 0.3124]}, {"w": "the", "b": [0.2454, 0.291, 0.2718, 0.3124]}, {"w": "problem", "b": [0.2776, 0.291, 0.3487, 0.3124]}, {"w": "turns", "b": [0.3545, 0.291, 0.3987, 0.3124]}, {"w": "out", "b": [0.4046, 0.291, 0.4326, 0.3124]}, {"w": "to", "b": [0.4385, 0.291, 0.4555, 0.3124]}, {"w": "be", "b": [0.4613, 0.291, 0.4808, 0.3124]}, {"w": "significantly", "b": [0.4866, 0.291, 0.5885, 0.3124]}, {"w": "more", "b": [0.5943, 0.291, 0.6386, 0.3124]}, {"w": "challenging", "b": [0.6445, 0.291, 0.7408, 0.3124]}, {"w": "than", "b": [0.7467, 0.291, 0.7847, 0.3124]}, {"w": "MNIST.", "b": [0.7906, 0.291, 0.8571, 0.3124]}, {"w": "For", "b": [0.1429, 0.3101, 0.1718, 0.3315]}, {"w": "example,", "b": [0.1775, 0.3101, 0.2518, 0.3315]}, {"w": "a", "b": [0.2575, 0.3101, 0.2667, 0.3315]}, {"w": "simple", "b": [0.2723, 0.3101, 0.3273, 0.3315]}, {"w": "linear", "b": [0.333, 0.3101, 0.3809, 0.3315]}, {"w": "model", "b": [0.3866, 0.3101, 0.4394, 0.3315]}, {"w": "reaches", "b": [0.4451, 0.3101, 0.5073, 0.3315]}, {"w": "about", "b": [0.513, 0.3101, 0.5608, 0.3315]}, {"w": "92%", "b": [0.5664, 0.3101, 0.6022, 0.3315]}, {"w": "accuracy", "b": [0.6079, 0.3101, 0.681, 0.3315]}, {"w": "on", "b": [0.6867, 0.3101, 0.7087, 0.3315]}, {"w": "MNIST,", "b": [0.7144, 0.3101, 0.7809, 0.3315]}, {"w": "but", "b": [0.7866, 0.3101, 0.8146, 0.3315]}, {"w": "only", "b": [0.8203, 0.3101, 0.8572, 0.3315]}, {"w": "about", "b": [0.1429, 0.3291, 0.1906, 0.3505]}, {"w": "83%", "b": [0.1954, 0.3291, 0.2311, 0.3505]}, {"w": "on", "b": [0.2358, 0.3291, 0.2579, 0.3505]}, {"w": "Fashion", "b": [0.2626, 0.3291, 0.3287, 0.3505]}, {"w": "MNIST.", "b": [0.3334, 0.3291, 0.4, 0.3505]}]}, {"id": "b_4", "type": "paragraph", "text": "Using Keras to Load the Dataset", "words": [{"w": "Using", "b": [0.1429, 0.3664, 0.1854, 0.3874]}, {"w": "Keras", "b": [0.189, 0.3664, 0.2304, 0.3874]}, {"w": "to", "b": [0.234, 0.3664, 0.25, 0.3874]}, {"w": "Load", "b": [0.2536, 0.3664, 0.2902, 0.3874]}, {"w": "the", "b": [0.2938, 0.3664, 0.3194, 0.3874]}, {"w": "Dataset", "b": [0.323, 0.3664, 0.3812, 0.3874]}]}, {"id": "b_5", "type": "paragraph", "text": "Keras provides some utility functions to fetch and load common datasets, including MNIST, Fashion MNIST, the original California housing dataset, and more. Let’s load Fashion MNIST:", "words": [{"w": "Keras", "b": [0.1429, 0.393, 0.1898, 0.4144]}, {"w": "provides", "b": [0.1962, 0.393, 0.2682, 0.4144]}, {"w": "some", "b": [0.2746, 0.393, 0.3188, 0.4144]}, {"w": "utility", "b": [0.3252, 0.393, 0.375, 0.4144]}, {"w": "functions", "b": [0.3814, 0.393, 0.4604, 0.4144]}, {"w": "to", "b": [0.4668, 0.393, 0.4838, 0.4144]}, {"w": "fetch", "b": [0.4902, 0.393, 0.5315, 0.4144]}, {"w": "and", "b": [0.538, 0.393, 0.5695, 0.4144]}, {"w": "load", "b": [0.5759, 0.393, 0.612, 0.4144]}, {"w": "common", "b": [0.6184, 0.393, 0.694, 0.4144]}, {"w": "datasets,", "b": [0.7004, 0.393, 0.7709, 0.4144]}, {"w": "including", "b": [0.7773, 0.393, 0.8571, 0.4144]}, {"w": "MNIST,", "b": [0.1429, 0.4121, 0.2094, 0.4335]}, {"w": "Fashion", "b": [0.2145, 0.4121, 0.2807, 0.4335]}, {"w": "MNIST,", "b": [0.2858, 0.4121, 0.3523, 0.4335]}, {"w": "the", "b": [0.3575, 0.4121, 0.3838, 0.4335]}, {"w": "original", "b": [0.3889, 0.4121, 0.454, 0.4335]}, {"w": "California", "b": [0.4591, 0.4121, 0.5436, 0.4335]}, {"w": "housing", "b": [0.5487, 0.4121, 0.6159, 0.4335]}, {"w": "dataset,", "b": [0.621, 0.4121, 0.6839, 0.4335]}, {"w": "and", "b": [0.689, 0.4121, 0.7206, 0.4335]}, {"w": "more.", "b": [0.7257, 0.4121, 0.7747, 0.4335]}, {"w": "Let’s", "b": [0.7798, 0.4121, 0.816, 0.4335]}, {"w": "load", "b": [0.8211, 0.4121, 0.8571, 0.4335]}, {"w": "Fashion", "b": [0.1428, 0.4311, 0.209, 0.4525]}, {"w": "MNIST:", "b": [0.2137, 0.4311, 0.2817, 0.4525]}]}, {"id": "b_6", "type": "paragraph", "text": "fashion_mnist = keras.datasets.fashion_mnist (X_train_full, y_train_full), (X_test, y_test) = fashion_mnist.load_data()", "words": [{"w": "fashion_mnist", "b": [0.1766, 0.4631, 0.2862, 0.476]}, {"w": "=", "b": [0.2946, 0.4631, 0.3031, 0.476]}, {"w": "keras.datasets.fashion_mnist", "b": [0.3115, 0.4631, 0.5476, 0.476]}, {"w": "(X_train_full,", "b": [0.1766, 0.4785, 0.2946, 0.4914]}, {"w": "y_train_full),", "b": [0.3031, 0.4785, 0.4211, 0.4914]}, {"w": "(X_test,", "b": [0.4296, 0.4785, 0.497, 0.4914]}, {"w": "y_test)", "b": [0.5055, 0.4785, 0.5645, 0.4914]}, {"w": "=", "b": [0.5729, 0.4785, 0.5814, 0.4914]}, {"w": "fashion_mnist.load_data()", "b": [0.5898, 0.4785, 0.8006, 0.4914]}]}, {"id": "b_7", "type": "paragraph", "text": "When loading MNIST or Fashion MNIST using Keras rather than Scikit-Learn, one important difference is that every image is represented as a 28×28 array rather than a 1D array of size 784. Moreover, the pixel intensities are represented as integers (from 0 to 255) rather than floats (from 0.0 to 255.0). Here is the shape and data type of the training set:", "words": [{"w": "When", "b": [0.1428, 0.4992, 0.1945, 0.5206]}, {"w": "loading", "b": [0.2007, 0.4992, 0.2635, 0.5206]}, {"w": "MNIST", "b": [0.2697, 0.4992, 0.3336, 0.5206]}, {"w": "or", "b": [0.3399, 0.4992, 0.3582, 0.5206]}, {"w": "Fashion", "b": [0.3645, 0.4992, 0.4306, 0.5206]}, {"w": "MNIST", "b": [0.4369, 0.4992, 0.5008, 0.5206]}, {"w": "using", "b": [0.507, 0.4992, 0.5525, 0.5206]}, {"w": "Keras", "b": [0.5587, 0.4992, 0.6056, 0.5206]}, {"w": "rather", "b": [0.6119, 0.4992, 0.6624, 0.5206]}, {"w": "than", "b": [0.6687, 0.4992, 0.7067, 0.5206]}, {"w": "Scikit-Learn,", "b": [0.713, 0.4992, 0.82, 0.5206]}, {"w": "one", "b": [0.8263, 0.4992, 0.8571, 0.5206]}, {"w": "important", "b": [0.1429, 0.5182, 0.2272, 0.5396]}, {"w": "difference", "b": [0.2326, 0.5182, 0.316, 0.5396]}, {"w": "is", "b": [0.3214, 0.5182, 0.3346, 0.5396]}, {"w": "that", "b": [0.34, 0.5182, 0.3726, 0.5396]}, {"w": "every", "b": [0.378, 0.5182, 0.4232, 0.5396]}, {"w": "image", "b": [0.4286, 0.5182, 0.479, 0.5396]}, {"w": "is", "b": [0.4844, 0.5182, 0.4976, 0.5396]}, {"w": "represented", "b": [0.503, 0.5182, 0.6008, 0.5396]}, {"w": "as", "b": [0.6062, 0.5182, 0.623, 0.5396]}, {"w": "a", "b": [0.6284, 0.5182, 0.6375, 0.5396]}, {"w": "28×28", "b": [0.6429, 0.5182, 0.695, 0.5396]}, {"w": "array", "b": [0.7004, 0.5182, 0.7433, 0.5396]}, {"w": "rather", "b": [0.7487, 0.5182, 0.7992, 0.5396]}, {"w": "than", "b": [0.8046, 0.5182, 0.8426, 0.5396]}, {"w": "a", "b": [0.848, 0.5182, 0.8571, 0.5396]}, {"w": "1D", "b": [0.1429, 0.5373, 0.1682, 0.5587]}, {"w": "array", "b": [0.1737, 0.5373, 0.2166, 0.5587]}, {"w": "of", "b": [0.2221, 0.5373, 0.2389, 0.5587]}, {"w": "size", "b": [0.2444, 0.5373, 0.2753, 0.5587]}, {"w": "784.", "b": [0.2808, 0.5373, 0.3155, 0.5587]}, {"w": "Moreover,", "b": [0.321, 0.5373, 0.4065, 0.5587]}, {"w": "the", "b": [0.4121, 0.5373, 0.4384, 0.5587]}, {"w": "pixel", "b": [0.4439, 0.5373, 0.4844, 0.5587]}, {"w": "intensities", "b": [0.4899, 0.5373, 0.5747, 0.5587]}, {"w": "are", "b": [0.5802, 0.5373, 0.606, 0.5587]}, {"w": "represented", "b": [0.6115, 0.5373, 0.7093, 0.5587]}, {"w": "as", "b": [0.7148, 0.5373, 0.7316, 0.5587]}, {"w": "integers", "b": [0.7371, 0.5373, 0.8028, 0.5587]}, {"w": "(from", "b": [0.8084, 0.5373, 0.8571, 0.5587]}, {"w": "0", "b": [0.1429, 0.5563, 0.1529, 0.5777]}, {"w": "to", "b": [0.1582, 0.5563, 0.1752, 0.5777]}, {"w": "255)", "b": [0.1805, 0.5563, 0.2177, 0.5777]}, {"w": "rather", "b": [0.2231, 0.5563, 0.2736, 0.5777]}, {"w": "than", "b": [0.279, 0.5563, 0.317, 0.5777]}, {"w": "floats", "b": [0.3223, 0.5563, 0.3671, 0.5777]}, {"w": "(from", "b": [0.3725, 0.5563, 0.4213, 0.5777]}, {"w": "0.0", "b": [0.4266, 0.5563, 0.4514, 0.5777]}, {"w": "to", "b": [0.4567, 0.5563, 0.4737, 0.5777]}, {"w": "255.0).", "b": [0.479, 0.5563, 0.5357, 0.5777]}, {"w": "Here", "b": [0.5411, 0.5563, 0.5819, 0.5777]}, {"w": "is", "b": [0.5873, 0.5563, 0.6005, 0.5777]}, {"w": "the", "b": [0.6059, 0.5563, 0.6322, 0.5777]}, {"w": "shape", "b": [0.6375, 0.5563, 0.6848, 0.5777]}, {"w": "and", "b": [0.6902, 0.5563, 0.7217, 0.5777]}, {"w": "data", "b": [0.727, 0.5563, 0.7623, 0.5777]}, {"w": "type", "b": [0.7676, 0.5563, 0.8033, 0.5777]}, {"w": "of", "b": [0.8087, 0.5563, 0.8255, 0.5777]}, {"w": "the", "b": [0.8308, 0.5563, 0.8571, 0.5777]}, {"w": "training", "b": [0.1429, 0.5753, 0.2098, 0.5968]}, {"w": "set:", "b": [0.2145, 0.5753, 0.2421, 0.5968]}]}, {"id": "b_8", "type": "equation", "text": ">>> X_train_full.shape (60000, 28, 28) >>> X_train_full.dtype dtype('uint8')", "words": [{"w": ">>>", "b": [0.1766, 0.6073, 0.2019, 0.6202]}, {"w": "X_train_full.shape", "b": [0.2103, 0.6073, 0.3621, 0.6202]}, {"w": "(60000,", "b": [0.1766, 0.6227, 0.2356, 0.6356]}, {"w": "28,", "b": [0.244, 0.6227, 0.2693, 0.6356]}, {"w": "28)", "b": [0.2778, 0.6227, 0.3031, 0.6356]}, {"w": ">>>", "b": [0.1766, 0.6382, 0.2019, 0.651]}, {"w": "X_train_full.dtype", "b": [0.2103, 0.6382, 0.3621, 0.651]}, {"w": "dtype('uint8')", "b": [0.1766, 0.6536, 0.2946, 0.6664]}]}, {"id": "b_9", "type": "paragraph", "text": "Note that the dataset is already split into a training set and a test set, but there is no validation set, so let’s create one. Moreover, since we are going to train the neural net‐ work using Gradient Descent, we must scale the input features. For simplicity, we just scale the pixel intensities down to the 0-1 range by dividing them by 255.0 (this also converts them to floats):", "words": [{"w": "Note", "b": [0.1428, 0.6742, 0.1836, 0.6956]}, {"w": "that", "b": [0.1898, 0.6742, 0.2224, 0.6956]}, {"w": "the", "b": [0.2285, 0.6742, 0.2548, 0.6956]}, {"w": "dataset", "b": [0.261, 0.6742, 0.3191, 0.6956]}, {"w": "is", "b": [0.3252, 0.6742, 0.3385, 0.6956]}, {"w": "already", "b": [0.3446, 0.6742, 0.4053, 0.6956]}, {"w": "split", "b": [0.4115, 0.6742, 0.4472, 0.6956]}, {"w": "into", "b": [0.4534, 0.6742, 0.4869, 0.6956]}, {"w": "a", "b": [0.4931, 0.6742, 0.5022, 0.6956]}, {"w": "training", "b": [0.5084, 0.6742, 0.5753, 0.6956]}, {"w": "set", "b": [0.5815, 0.6742, 0.6043, 0.6956]}, {"w": "and", "b": [0.6105, 0.6742, 0.642, 0.6956]}, {"w": "a", "b": [0.6481, 0.6742, 0.6573, 0.6956]}, {"w": "test", "b": [0.6634, 0.6742, 0.6926, 0.6956]}, {"w": "set,", "b": [0.6988, 0.6742, 0.7264, 0.6956]}, {"w": "but", "b": [0.7325, 0.6742, 0.7605, 0.6956]}, {"w": "there", "b": [0.7667, 0.6742, 0.8096, 0.6956]}, {"w": "is", "b": [0.8157, 0.6742, 0.829, 0.6956]}, {"w": "no", "b": [0.8351, 0.6742, 0.8571, 0.6956]}, {"w": "validation", "b": [0.1429, 0.6933, 0.2262, 0.7147]}, {"w": "set,", "b": [0.2312, 0.6933, 0.2588, 0.7147]}, {"w": "so", "b": [0.2638, 0.6933, 0.2821, 0.7147]}, {"w": "let’s", "b": [0.2871, 0.6933, 0.3173, 0.7147]}, {"w": "create", "b": [0.3223, 0.6933, 0.3717, 0.7147]}, {"w": "one.", "b": [0.3767, 0.6933, 0.4123, 0.7147]}, {"w": "Moreover,", "b": [0.4173, 0.6933, 0.5029, 0.7147]}, {"w": "since", "b": [0.5079, 0.6933, 0.5501, 0.7147]}, {"w": "we", "b": [0.5552, 0.6933, 0.5783, 0.7147]}, {"w": "are", "b": [0.5833, 0.6933, 0.609, 0.7147]}, {"w": "going", "b": [0.614, 0.6933, 0.6611, 0.7147]}, {"w": "to", "b": [0.6661, 0.6933, 0.6831, 0.7147]}, {"w": "train", "b": [0.6881, 0.6933, 0.7283, 0.7147]}, {"w": "the", "b": [0.7333, 0.6933, 0.7597, 0.7147]}, {"w": "neural", "b": [0.7647, 0.6933, 0.8181, 0.7147]}, {"w": "net‐", "b": [0.8231, 0.6933, 0.8571, 0.7147]}, {"w": "work", "b": [0.1429, 0.7123, 0.1858, 0.7337]}, {"w": "using", "b": [0.1909, 0.7123, 0.2363, 0.7337]}, {"w": "Gradient", "b": [0.2414, 0.7123, 0.316, 0.7337]}, {"w": "Descent,", "b": [0.3211, 0.7123, 0.3926, 0.7337]}, {"w": "we", "b": [0.3977, 0.7123, 0.4208, 0.7337]}, {"w": "must", "b": [0.4259, 0.7123, 0.4677, 0.7337]}, {"w": "scale", "b": [0.4727, 0.7123, 0.5125, 0.7337]}, {"w": "the", "b": [0.5175, 0.7123, 0.5439, 0.7337]}, {"w": "input", "b": [0.549, 0.7123, 0.5939, 0.7337]}, {"w": "features.", "b": [0.5989, 0.7123, 0.6691, 0.7337]}, {"w": "For", "b": [0.6742, 0.7123, 0.7032, 0.7337]}, {"w": "simplicity,", "b": [0.7083, 0.7123, 0.7935, 0.7337]}, {"w": "we", "b": [0.7985, 0.7123, 0.8217, 0.7337]}, {"w": "just", "b": [0.8267, 0.7123, 0.8571, 0.7337]}, {"w": "scale", "b": [0.1429, 0.7314, 0.1826, 0.7528]}, {"w": "the", "b": [0.1885, 0.7314, 0.2149, 0.7528]}, {"w": "pixel", "b": [0.2208, 0.7314, 0.2613, 0.7528]}, {"w": "intensities", "b": [0.2673, 0.7314, 0.3521, 0.7528]}, {"w": "down", "b": [0.3581, 0.7314, 0.4054, 0.7528]}, {"w": "to", "b": [0.4113, 0.7314, 0.4283, 0.7528]}, {"w": "the", "b": [0.4343, 0.7314, 0.4606, 0.7528]}, {"w": "0-1", "b": [0.4666, 0.7314, 0.494, 0.7528]}, {"w": "range", "b": [0.4999, 0.7314, 0.5468, 0.7528]}, {"w": "by", "b": [0.5528, 0.7314, 0.5729, 0.7528]}, {"w": "dividing", "b": [0.5789, 0.7314, 0.6484, 0.7528]}, {"w": "them", "b": [0.6544, 0.7314, 0.6978, 0.7528]}, {"w": "by", "b": [0.7037, 0.7314, 0.7239, 0.7528]}, {"w": "255.0", "b": [0.7299, 0.7314, 0.7746, 0.7528]}, {"w": "(this", "b": [0.7806, 0.7314, 0.8185, 0.7528]}, {"w": "also", "b": [0.8244, 0.7314, 0.8571, 0.7528]}, {"w": "converts", "b": [0.1429, 0.7504, 0.2134, 0.7718]}, {"w": "them", "b": [0.2182, 0.7504, 0.2616, 0.7718]}, {"w": "to", "b": [0.2663, 0.7504, 0.2833, 0.7718]}, {"w": "floats):", "b": [0.288, 0.7504, 0.3448, 0.7718]}]}, {"id": "b_10", "type": "paragraph", "text": "X_valid, X_train = X_train_full[:5000] / 255.0, X_train_full[5000:] / 255.0 y_valid, y_train = y_train_full[:5000], y_train_full[5000:]", "words": [{"w": "X_valid,", "b": [0.1766, 0.7824, 0.244, 0.7952]}, {"w": "X_train", "b": [0.2525, 0.7824, 0.3115, 0.7952]}, {"w": "=", "b": [0.3199, 0.7824, 0.3284, 0.7952]}, {"w": "X_train_full[:5000]", "b": [0.3368, 0.7824, 0.497, 0.7952]}, {"w": "/", "b": [0.5055, 0.7824, 0.5139, 0.7952]}, {"w": "255.0,", "b": [0.5223, 0.7824, 0.5729, 0.7952]}, {"w": "X_train_full[5000:]", "b": [0.5813, 0.7824, 0.7416, 0.7952]}, {"w": "/", "b": [0.75, 0.7824, 0.7584, 0.7952]}, {"w": "255.0", "b": [0.7669, 0.7824, 0.809, 0.7952]}, {"w": "y_valid,", "b": [0.1766, 0.7978, 0.244, 0.8106]}, {"w": "y_train", "b": [0.2525, 0.7978, 0.3115, 0.8106]}, {"w": "=", "b": [0.3199, 0.7978, 0.3284, 0.8106]}, {"w": "y_train_full[:5000],", "b": [0.3368, 0.7978, 0.5055, 0.8106]}, {"w": "y_train_full[5000:]", "b": [0.5139, 0.7978, 0.6741, 0.8106]}]}, {"id": "b_11", "type": "paragraph", "text": "With MNIST, when the label is equal to 5, it means that the image represents the handwritten digit 5. Easy. However, for Fashion MNIST, we need the list of class names to know what we are dealing with:", "words": [{"w": "With", "b": [0.1429, 0.8184, 0.1853, 0.8398]}, {"w": "MNIST,", "b": [0.1931, 0.8184, 0.2597, 0.8398]}, {"w": "when", "b": [0.2675, 0.8184, 0.3131, 0.8398]}, {"w": "the", "b": [0.3209, 0.8184, 0.3472, 0.8398]}, {"w": "label", "b": [0.355, 0.8184, 0.3942, 0.8398]}, {"w": "is", "b": [0.402, 0.8184, 0.4152, 0.8398]}, {"w": "equal", "b": [0.423, 0.8184, 0.468, 0.8398]}, {"w": "to", "b": [0.4758, 0.8184, 0.4927, 0.8398]}, {"w": "5,", "b": [0.5005, 0.8184, 0.5153, 0.8398]}, {"w": "it", "b": [0.5231, 0.8184, 0.535, 0.8398]}, {"w": "means", "b": [0.5428, 0.8184, 0.5969, 0.8398]}, {"w": "that", "b": [0.6047, 0.8184, 0.6373, 0.8398]}, {"w": "the", "b": [0.6451, 0.8184, 0.6714, 0.8398]}, {"w": "image", "b": [0.6792, 0.8184, 0.7296, 0.8398]}, {"w": "represents", "b": [0.7374, 0.8184, 0.823, 0.8398]}, {"w": "the", "b": [0.8308, 0.8184, 0.8571, 0.8398]}, {"w": "handwritten", "b": [0.1429, 0.8375, 0.2461, 0.8589]}, {"w": "digit", "b": [0.2546, 0.8375, 0.2929, 0.8589]}, {"w": "5.", "b": [0.3014, 0.8375, 0.3161, 0.8589]}, {"w": "Easy.", "b": [0.3247, 0.8375, 0.3661, 0.8589]}, {"w": "However,", "b": [0.3746, 0.8375, 0.4535, 0.8589]}, {"w": "for", "b": [0.462, 0.8375, 0.4865, 0.8589]}, {"w": "Fashion", "b": [0.495, 0.8375, 0.5612, 0.8589]}, {"w": "MNIST,", "b": [0.5697, 0.8375, 0.6362, 0.8589]}, {"w": "we", "b": [0.6448, 0.8375, 0.6679, 0.8589]}, {"w": "need", "b": [0.6764, 0.8375, 0.7165, 0.8589]}, {"w": "the", "b": [0.7251, 0.8375, 0.7514, 0.8589]}, {"w": "list", "b": [0.7599, 0.8375, 0.7848, 0.8589]}, {"w": "of", "b": [0.7933, 0.8375, 0.8101, 0.8589]}, {"w": "class", "b": [0.8186, 0.8375, 0.8571, 0.8589]}, {"w": "names", "b": [0.1429, 0.8565, 0.197, 0.8779]}, {"w": "to", "b": [0.2017, 0.8565, 0.2187, 0.8779]}, {"w": "know", "b": [0.2234, 0.8565, 0.27, 0.8779]}, {"w": "what", "b": [0.2748, 0.8565, 0.3153, 0.8779]}, {"w": "we", "b": [0.32, 0.8565, 0.3431, 0.8779]}, {"w": "are", "b": [0.3478, 0.8565, 0.3736, 0.8779]}, {"w": "dealing", "b": [0.3783, 0.8565, 0.4393, 0.8779]}, {"w": "with:", "b": [0.444, 0.8565, 0.4861, 0.8779]}]}, {"id": "b_12", "type": "paragraph", "text": "294 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "294", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4163, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4583, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 321, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "class_names = [\"T-shirt/top\", \"Trouser\", \"Pullover\", \"Dress\", \"Coat\", \"Sandal\", \"Shirt\", \"Sneaker\", \"Bag\", \"Ankle boot\"]", "words": [{"w": "class_names", "b": [0.1766, 0.0829, 0.2693, 0.0958]}, {"w": "=", "b": [0.2778, 0.0829, 0.2862, 0.0958]}, {"w": "[\"T-shirt/top\",", "b": [0.2946, 0.0829, 0.4211, 0.0958]}, {"w": "\"Trouser\",", "b": [0.4296, 0.0829, 0.5139, 0.0958]}, {"w": "\"Pullover\",", "b": [0.5223, 0.0829, 0.6151, 0.0958]}, {"w": "\"Dress\",", "b": [0.6235, 0.0829, 0.691, 0.0958]}, {"w": "\"Coat\",", "b": [0.6994, 0.0829, 0.7584, 0.0958]}, {"w": "\"Sandal\",", "b": [0.3031, 0.0983, 0.379, 0.1112]}, {"w": "\"Shirt\",", "b": [0.3874, 0.0983, 0.4549, 0.1112]}, {"w": "\"Sneaker\",", "b": [0.4633, 0.0983, 0.5476, 0.1112]}, {"w": "\"Bag\",", "b": [0.5561, 0.0983, 0.6066, 0.1112]}, {"w": "\"Ankle", "b": [0.6151, 0.0983, 0.6657, 0.1112]}, {"w": "boot\"]", "b": [0.6741, 0.0983, 0.7247, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "For example, the first image in the training set represents a coat:", "words": [{"w": "For", "b": [0.1428, 0.119, 0.1718, 0.1404]}, {"w": "example,", "b": [0.1766, 0.119, 0.2508, 0.1404]}, {"w": "the", "b": [0.2556, 0.119, 0.2819, 0.1404]}, {"w": "first", "b": [0.2866, 0.119, 0.3201, 0.1404]}, {"w": "image", "b": [0.3248, 0.119, 0.3752, 0.1404]}, {"w": "in", "b": [0.38, 0.119, 0.397, 0.1404]}, {"w": "the", "b": [0.4017, 0.119, 0.428, 0.1404]}, {"w": "training", "b": [0.4327, 0.119, 0.4997, 0.1404]}, {"w": "set", "b": [0.5044, 0.119, 0.5273, 0.1404]}, {"w": "represents", "b": [0.532, 0.119, 0.6176, 0.1404]}, {"w": "a", "b": [0.6223, 0.119, 0.6315, 0.1404]}, {"w": "coat:", "b": [0.6362, 0.119, 0.6755, 0.1404]}]}, {"id": "b_2", "type": "equation", "text": ">>> class_names[y_train[0]] 'Coat'", "words": [{"w": ">>>", "b": [0.1766, 0.1509, 0.2019, 0.1638]}, {"w": "class_names[y_train[0]]", "b": [0.2103, 0.1509, 0.4043, 0.1638]}, {"w": "'Coat'", "b": [0.1766, 0.1664, 0.2272, 0.1792]}]}, {"id": "b_3", "type": "equation", "text": "Figure 10-11 shows a few samples from the Fashion MNIST dataset:", "words": [{"w": "Figure", "b": [0.1429, 0.187, 0.1969, 0.2084]}, {"w": "10-11", "b": [0.2016, 0.187, 0.249, 0.2084]}, {"w": "shows", "b": [0.2537, 0.187, 0.305, 0.2084]}, {"w": "a", "b": [0.3098, 0.187, 0.3189, 0.2084]}, {"w": "few", "b": [0.3236, 0.187, 0.3529, 0.2084]}, {"w": "samples", "b": [0.3577, 0.187, 0.4238, 0.2084]}, {"w": "from", "b": [0.4285, 0.187, 0.4701, 0.2084]}, {"w": "the", "b": [0.4749, 0.187, 0.5012, 0.2084]}, {"w": "Fashion", "b": [0.5059, 0.187, 0.572, 0.2084]}, {"w": "MNIST", "b": [0.5768, 0.187, 0.6406, 0.2084]}, {"w": "dataset:", "b": [0.6454, 0.187, 0.7082, 0.2084]}]}, {"id": "b_4", "type": "equation", "text": "Figure 10-11. Samples from Fashion MNIST", "words": [{"w": "Figure", "b": [0.1428, 0.3947, 0.1943, 0.4164]}, {"w": "10-11.", "b": [0.1991, 0.3947, 0.2507, 0.4164]}, {"w": "Samples", "b": [0.2554, 0.3947, 0.3215, 0.4164]}, {"w": "from", "b": [0.3262, 0.3947, 0.3652, 0.4164]}, {"w": "Fashion", "b": [0.37, 0.3947, 0.4338, 0.4164]}, {"w": "MNIST", "b": [0.4386, 0.3947, 0.5005, 0.4164]}]}, {"id": "b_5", "type": "paragraph", "text": "Creating the Model Using the Sequential API", "words": [{"w": "Creating", "b": [0.1429, 0.4323, 0.207, 0.4532]}, {"w": "the", "b": [0.2107, 0.4323, 0.2362, 0.4532]}, {"w": "Model", "b": [0.2398, 0.4323, 0.2871, 0.4532]}, {"w": "Using", "b": [0.2907, 0.4323, 0.3332, 0.4532]}, {"w": "the", "b": [0.3368, 0.4323, 0.3624, 0.4532]}, {"w": "Sequential", "b": [0.366, 0.4323, 0.4474, 0.4532]}, {"w": "API", "b": [0.451, 0.4323, 0.4764, 0.4532]}]}, {"id": "b_6", "type": "paragraph", "text": "Now let’s build the neural network! Here is a classification MLP with two hidden lay‐ ers:", "words": [{"w": "Now", "b": [0.1429, 0.4589, 0.1827, 0.4803]}, {"w": "let’s", "b": [0.1881, 0.4589, 0.2183, 0.4803]}, {"w": "build", "b": [0.2236, 0.4589, 0.2671, 0.4803]}, {"w": "the", "b": [0.2725, 0.4589, 0.2988, 0.4803]}, {"w": "neural", "b": [0.3042, 0.4589, 0.3576, 0.4803]}, {"w": "network!", "b": [0.363, 0.4589, 0.4383, 0.4803]}, {"w": "Here", "b": [0.4436, 0.4589, 0.4845, 0.4803]}, {"w": "is", "b": [0.4899, 0.4589, 0.5031, 0.4803]}, {"w": "a", "b": [0.5084, 0.4589, 0.5176, 0.4803]}, {"w": "classification", "b": [0.5229, 0.4589, 0.6303, 0.4803]}, {"w": "MLP", "b": [0.6357, 0.4589, 0.6772, 0.4803]}, {"w": "with", "b": [0.6825, 0.4589, 0.7199, 0.4803]}, {"w": "two", "b": [0.7252, 0.4589, 0.7565, 0.4803]}, {"w": "hidden", "b": [0.7618, 0.4589, 0.8208, 0.4803]}, {"w": "lay‐", "b": [0.8261, 0.4589, 0.8571, 0.4803]}, {"w": "ers:", "b": [0.1429, 0.4779, 0.1718, 0.4993]}]}, {"id": "b_7", "type": "paragraph", "text": "model = keras.models.Sequential() model.add(keras.layers.Flatten(input_shape=[28, 28])) model.add(keras.layers.Dense(300, activation=\"relu\")) model.add(keras.layers.Dense(100, activation=\"relu\")) model.add(keras.layers.Dense(10, activation=\"softmax\"))", "words": [{"w": "model", "b": [0.1766, 0.5099, 0.2187, 0.5228]}, {"w": "=", "b": [0.2272, 0.5099, 0.2356, 0.5228]}, {"w": "keras.models.Sequential()", "b": [0.244, 0.5099, 0.4549, 0.5228]}, {"w": "model.add(keras.layers.Flatten(input_shape=[28,", "b": [0.1766, 0.5253, 0.5729, 0.5382]}, {"w": "28]))", "b": [0.5813, 0.5253, 0.6235, 0.5382]}, {"w": "model.add(keras.layers.Dense(300,", "b": [0.1766, 0.5407, 0.4549, 0.5536]}, {"w": "activation=\"relu\"))", "b": [0.4633, 0.5407, 0.6235, 0.5536]}, {"w": "model.add(keras.layers.Dense(100,", "b": [0.1766, 0.5562, 0.4549, 0.569]}, {"w": "activation=\"relu\"))", "b": [0.4633, 0.5562, 0.6235, 0.569]}, {"w": "model.add(keras.layers.Dense(10,", "b": [0.1766, 0.5716, 0.4464, 0.5844]}, {"w": "activation=\"softmax\"))", "b": [0.4549, 0.5716, 0.6404, 0.5844]}]}, {"id": "b_8", "type": "paragraph", "text": "Let’s go through this code line by line:", "words": [{"w": "Let’s", "b": [0.1429, 0.5922, 0.179, 0.6136]}, {"w": "go", "b": [0.1838, 0.5922, 0.2041, 0.6136]}, {"w": "through", "b": [0.2089, 0.5922, 0.2766, 0.6136]}, {"w": "this", "b": [0.2814, 0.5922, 0.3121, 0.6136]}, {"w": "code", "b": [0.3168, 0.5922, 0.3561, 0.6136]}, {"w": "line", "b": [0.3608, 0.5922, 0.3919, 0.6136]}, {"w": "by", "b": [0.3966, 0.5922, 0.4168, 0.6136]}, {"w": "line:", "b": [0.4215, 0.5922, 0.4574, 0.6136]}]}, {"id": "b_9", "type": "paragraph", "text": "• The first line creates a Sequential model. This is the simplest kind of Keras model, for neural networks that are just composed of a single stack of layers, con‐ nected sequentially. This is called the sequential API.", "words": [{"w": "•", "b": [0.16, 0.6273, 0.1682, 0.6487]}, {"w": "The", "b": [0.1786, 0.6273, 0.2114, 0.6487]}, {"w": "first", "b": [0.2199, 0.6273, 0.2534, 0.6487]}, {"w": "line", "b": [0.2619, 0.6273, 0.293, 0.6487]}, {"w": "creates", "b": [0.3015, 0.6273, 0.3585, 0.6487]}, {"w": "a", "b": [0.3671, 0.6273, 0.3762, 0.6487]}, {"w": "Sequential", "b": [0.3847, 0.6305, 0.4837, 0.6455]}, {"w": "model.", "b": [0.4922, 0.6273, 0.5498, 0.6487]}, {"w": "This", "b": [0.5583, 0.6273, 0.5955, 0.6487]}, {"w": "is", "b": [0.604, 0.6273, 0.6173, 0.6487]}, {"w": "the", "b": [0.6258, 0.6273, 0.6521, 0.6487]}, {"w": "simplest", "b": [0.6606, 0.6273, 0.7296, 0.6487]}, {"w": "kind", "b": [0.7381, 0.6273, 0.7764, 0.6487]}, {"w": "of", "b": [0.7849, 0.6273, 0.8017, 0.6487]}, {"w": "Keras", "b": [0.8102, 0.6273, 0.8571, 0.6487]}, {"w": "model,", "b": [0.1786, 0.6463, 0.2361, 0.6677]}, {"w": "for", "b": [0.241, 0.6463, 0.2655, 0.6677]}, {"w": "neural", "b": [0.2703, 0.6463, 0.3238, 0.6677]}, {"w": "networks", "b": [0.3286, 0.6463, 0.4058, 0.6677]}, {"w": "that", "b": [0.4106, 0.6463, 0.4432, 0.6677]}, {"w": "are", "b": [0.4481, 0.6463, 0.4738, 0.6677]}, {"w": "just", "b": [0.4786, 0.6463, 0.509, 0.6677]}, {"w": "composed", "b": [0.5138, 0.6463, 0.599, 0.6677]}, {"w": "of", "b": [0.6038, 0.6463, 0.6206, 0.6677]}, {"w": "a", "b": [0.6254, 0.6463, 0.6346, 0.6677]}, {"w": "single", "b": [0.6394, 0.6463, 0.6879, 0.6677]}, {"w": "stack", "b": [0.6927, 0.6463, 0.735, 0.6677]}, {"w": "of", "b": [0.7399, 0.6463, 0.7567, 0.6677]}, {"w": "layers,", "b": [0.7615, 0.6463, 0.8141, 0.6677]}, {"w": "con‐", "b": [0.8189, 0.6463, 0.8571, 0.6677]}, {"w": "nected", "b": [0.1786, 0.6654, 0.2338, 0.6868]}, {"w": "sequentially.", "b": [0.2386, 0.6654, 0.341, 0.6868]}, {"w": "This", "b": [0.3458, 0.6654, 0.383, 0.6868]}, {"w": "is", "b": [0.3877, 0.6654, 0.4009, 0.6868]}, {"w": "called", "b": [0.4057, 0.6654, 0.454, 0.6868]}, {"w": "the", "b": [0.4588, 0.6654, 0.4851, 0.6868]}, {"w": "sequential", "b": [0.4898, 0.6654, 0.5742, 0.6868]}, {"w": "API.", "b": [0.579, 0.6654, 0.6169, 0.6868]}]}, {"id": "b_10", "type": "paragraph", "text": "• Next, we build the first layer and add it to the model. It is a Flatten layer whose role is simply to convert each input image into a 1D array: if it receives input data X, it computes X.reshape(-1, 1). This layer does not have any parameters, it is just there to do some simple preprocessing. Since it is the first layer in the model, you should specify the input_shape: this does not include the batch size, only the shape of the instances. Alternatively, you could add a keras.layers.InputLayer as the first layer, setting shape=[28,28].", "words": [{"w": "•", "b": [0.16, 0.6914, 0.1682, 0.7128]}, {"w": "Next,", "b": [0.1786, 0.6914, 0.2233, 0.7128]}, {"w": "we", "b": [0.2289, 0.6914, 0.252, 0.7128]}, {"w": "build", "b": [0.2576, 0.6914, 0.3011, 0.7128]}, {"w": "the", "b": [0.3067, 0.6914, 0.333, 0.7128]}, {"w": "first", "b": [0.3386, 0.6914, 0.372, 0.7128]}, {"w": "layer", "b": [0.3776, 0.6914, 0.4178, 0.7128]}, {"w": "and", "b": [0.4234, 0.6914, 0.4549, 0.7128]}, {"w": "add", "b": [0.4605, 0.6914, 0.4916, 0.7128]}, {"w": "it", "b": [0.4972, 0.6914, 0.5091, 0.7128]}, {"w": "to", "b": [0.5147, 0.6914, 0.5317, 0.7128]}, {"w": "the", "b": [0.5372, 0.6914, 0.5636, 0.7128]}, {"w": "model.", "b": [0.5692, 0.6914, 0.6267, 0.7128]}, {"w": "It", "b": [0.6323, 0.6914, 0.6449, 0.7128]}, {"w": "is", "b": [0.6505, 0.6914, 0.6637, 0.7128]}, {"w": "a", "b": [0.6693, 0.6914, 0.6784, 0.7128]}, {"w": "Flatten", "b": [0.684, 0.6945, 0.7533, 0.7096]}, {"w": "layer", "b": [0.7589, 0.6914, 0.799, 0.7128]}, {"w": "whose", "b": [0.8046, 0.6914, 0.8571, 0.7128]}, {"w": "role", "b": [0.1786, 0.7104, 0.2111, 0.7318]}, {"w": "is", "b": [0.2159, 0.7104, 0.2291, 0.7318]}, {"w": "simply", "b": [0.234, 0.7104, 0.2897, 0.7318]}, {"w": "to", "b": [0.2945, 0.7104, 0.3115, 0.7318]}, {"w": "convert", "b": [0.3164, 0.7104, 0.3793, 0.7318]}, {"w": "each", "b": [0.3842, 0.7104, 0.4221, 0.7318]}, {"w": "input", "b": [0.427, 0.7104, 0.4719, 0.7318]}, {"w": "image", "b": [0.4768, 0.7104, 0.5272, 0.7318]}, {"w": "into", "b": [0.532, 0.7104, 0.5656, 0.7318]}, {"w": "a", "b": [0.5705, 0.7104, 0.5796, 0.7318]}, {"w": "1D", "b": [0.5845, 0.7104, 0.6098, 0.7318]}, {"w": "array:", "b": [0.6146, 0.7104, 0.663, 0.7318]}, {"w": "if", "b": [0.6678, 0.7104, 0.6796, 0.7318]}, {"w": "it", "b": [0.6845, 0.7104, 0.6964, 0.7318]}, {"w": "receives", "b": [0.7013, 0.7104, 0.7672, 0.7318]}, {"w": "input", "b": [0.7721, 0.7104, 0.817, 0.7318]}, {"w": "data", "b": [0.8219, 0.7104, 0.8571, 0.7318]}, {"w": "X,", "b": [0.1786, 0.7304, 0.1932, 0.7518]}, {"w": "it", "b": [0.1992, 0.7304, 0.2111, 0.7518]}, {"w": "computes", "b": [0.2171, 0.7304, 0.298, 0.7518]}, {"w": "X.reshape(-1,", "b": [0.304, 0.7335, 0.4326, 0.7486]}, {"w": "1).", "b": [0.4437, 0.7304, 0.4682, 0.7518]}, {"w": "This", "b": [0.4742, 0.7304, 0.5114, 0.7518]}, {"w": "layer", "b": [0.5174, 0.7304, 0.5575, 0.7518]}, {"w": "does", "b": [0.5635, 0.7304, 0.6016, 0.7518]}, {"w": "not", "b": [0.6076, 0.7304, 0.636, 0.7518]}, {"w": "have", "b": [0.6419, 0.7304, 0.6803, 0.7518]}, {"w": "any", "b": [0.6863, 0.7304, 0.7159, 0.7518]}, {"w": "parameters,", "b": [0.7219, 0.7304, 0.8201, 0.7518]}, {"w": "it", "b": [0.826, 0.7304, 0.838, 0.7518]}, {"w": "is", "b": [0.8439, 0.7304, 0.8571, 0.7518]}, {"w": "just", "b": [0.1786, 0.7494, 0.209, 0.7708]}, {"w": "there", "b": [0.214, 0.7494, 0.2569, 0.7708]}, {"w": "to", "b": [0.262, 0.7494, 0.279, 0.7708]}, {"w": "do", "b": [0.284, 0.7494, 0.3056, 0.7708]}, {"w": "some", "b": [0.3107, 0.7494, 0.3549, 0.7708]}, {"w": "simple", "b": [0.3599, 0.7494, 0.4149, 0.7708]}, {"w": "preprocessing.", "b": [0.4199, 0.7494, 0.5411, 0.7708]}, {"w": "Since", "b": [0.5462, 0.7494, 0.5907, 0.7708]}, {"w": "it", "b": [0.5958, 0.7494, 0.6077, 0.7708]}, {"w": "is", "b": [0.6127, 0.7494, 0.626, 0.7708]}, {"w": "the", "b": [0.631, 0.7494, 0.6574, 0.7708]}, {"w": "first", "b": [0.6624, 0.7494, 0.6959, 0.7708]}, {"w": "layer", "b": [0.7009, 0.7494, 0.7411, 0.7708]}, {"w": "in", "b": [0.7462, 0.7494, 0.7632, 0.7708]}, {"w": "the", "b": [0.7682, 0.7494, 0.7945, 0.7708]}, {"w": "model,", "b": [0.7996, 0.7494, 0.8571, 0.7708]}, {"w": "you", "b": [0.1786, 0.7694, 0.2098, 0.7908]}, {"w": "should", "b": [0.2145, 0.7694, 0.2713, 0.7908]}, {"w": "specify", "b": [0.276, 0.7694, 0.3339, 0.7908]}, {"w": "the", "b": [0.3386, 0.7694, 0.365, 0.7908]}, {"w": "input_shape:", "b": [0.3701, 0.7694, 0.4837, 0.7908]}, {"w": "this", "b": [0.4885, 0.7694, 0.5193, 0.7908]}, {"w": "does", "b": [0.5241, 0.7694, 0.5622, 0.7908]}, {"w": "not", "b": [0.567, 0.7694, 0.5954, 0.7908]}, {"w": "include", "b": [0.6003, 0.7694, 0.6622, 0.7908]}, {"w": "the", "b": [0.6671, 0.7694, 0.6934, 0.7908]}, {"w": "batch", "b": [0.6982, 0.7694, 0.7439, 0.7908]}, {"w": "size,", "b": [0.7487, 0.7694, 0.7843, 0.7908]}, {"w": "only", "b": [0.7891, 0.7694, 0.826, 0.7908]}, {"w": "the", "b": [0.8308, 0.7694, 0.8571, 0.7908]}, {"w": "shape", "b": [0.1786, 0.7893, 0.2259, 0.8107]}, {"w": "of", "b": [0.2314, 0.7893, 0.2481, 0.8107]}, {"w": "the", "b": [0.2536, 0.7893, 0.28, 0.8107]}, {"w": "instances.", "b": [0.2855, 0.7893, 0.367, 0.8107]}, {"w": "Alternatively,", "b": [0.3725, 0.7893, 0.4838, 0.8107]}, {"w": "you", "b": [0.4893, 0.7893, 0.5205, 0.8107]}, {"w": "could", "b": [0.526, 0.7893, 0.5728, 0.8107]}, {"w": "add", "b": [0.5783, 0.7893, 0.6094, 0.8107]}, {"w": "a", "b": [0.6149, 0.7893, 0.624, 0.8107]}, {"w": "keras.layers.InputLayer", "b": [0.6295, 0.7925, 0.8571, 0.8076]}, {"w": "as", "b": [0.1786, 0.8092, 0.1954, 0.8307]}, {"w": "the", "b": [0.2001, 0.8092, 0.2264, 0.8307]}, {"w": "first", "b": [0.2312, 0.8092, 0.2646, 0.8307]}, {"w": "layer,", "b": [0.2694, 0.8092, 0.313, 0.8307]}, {"w": "setting", "b": [0.3177, 0.8092, 0.3737, 0.8307]}, {"w": "shape=[28,28].", "b": [0.3784, 0.8092, 0.5118, 0.8307]}]}, {"id": "b_11", "type": "paragraph", "text": "• Next we add a Dense hidden layer with 300 neurons. It will use the ReLU activa‐ tion function. Each Dense layer manages its own weight matrix, containing all the connection weights between the neurons and their inputs. It also manages a vec‐", "words": [{"w": "•", "b": [0.16, 0.8352, 0.1681, 0.8566]}, {"w": "Next", "b": [0.1786, 0.8352, 0.2186, 0.8566]}, {"w": "we", "b": [0.2242, 0.8352, 0.2474, 0.8566]}, {"w": "add", "b": [0.2531, 0.8352, 0.2842, 0.8566]}, {"w": "a", "b": [0.2899, 0.8352, 0.299, 0.8566]}, {"w": "Dense", "b": [0.3047, 0.8384, 0.3542, 0.8535]}, {"w": "hidden", "b": [0.3599, 0.8352, 0.4188, 0.8566]}, {"w": "layer", "b": [0.4245, 0.8352, 0.4647, 0.8566]}, {"w": "with", "b": [0.4704, 0.8352, 0.5077, 0.8566]}, {"w": "300", "b": [0.5134, 0.8352, 0.5434, 0.8566]}, {"w": "neurons.", "b": [0.5491, 0.8352, 0.6225, 0.8566]}, {"w": "It", "b": [0.6282, 0.8352, 0.6408, 0.8566]}, {"w": "will", "b": [0.6465, 0.8352, 0.6769, 0.8566]}, {"w": "use", "b": [0.6826, 0.8352, 0.7102, 0.8566]}, {"w": "the", "b": [0.7158, 0.8352, 0.7422, 0.8566]}, {"w": "ReLU", "b": [0.7479, 0.8352, 0.7954, 0.8566]}, {"w": "activa‐", "b": [0.801, 0.8352, 0.8571, 0.8566]}, {"w": "tion", "b": [0.1786, 0.8552, 0.2125, 0.8766]}, {"w": "function.", "b": [0.2173, 0.8552, 0.2934, 0.8766]}, {"w": "Each", "b": [0.2981, 0.8552, 0.3391, 0.8766]}, {"w": "Dense", "b": [0.344, 0.8584, 0.3935, 0.8734]}, {"w": "layer", "b": [0.3983, 0.8552, 0.4385, 0.8766]}, {"w": "manages", "b": [0.4432, 0.8552, 0.5162, 0.8766]}, {"w": "its", "b": [0.521, 0.8552, 0.5405, 0.8766]}, {"w": "own", "b": [0.5453, 0.8552, 0.5816, 0.8766]}, {"w": "weight", "b": [0.5863, 0.8552, 0.6418, 0.8766]}, {"w": "matrix,", "b": [0.6466, 0.8552, 0.7066, 0.8766]}, {"w": "containing", "b": [0.7114, 0.8552, 0.801, 0.8766]}, {"w": "all", "b": [0.8057, 0.8552, 0.8254, 0.8766]}, {"w": "the", "b": [0.8301, 0.8552, 0.8565, 0.8766]}, {"w": "connection", "b": [0.1786, 0.8742, 0.2724, 0.8956]}, {"w": "weights", "b": [0.278, 0.8742, 0.3412, 0.8956]}, {"w": "between", "b": [0.3467, 0.8742, 0.4159, 0.8956]}, {"w": "the", "b": [0.4214, 0.8742, 0.4478, 0.8956]}, {"w": "neurons", "b": [0.4533, 0.8742, 0.522, 0.8956]}, {"w": "and", "b": [0.5276, 0.8742, 0.5591, 0.8956]}, {"w": "their", "b": [0.5647, 0.8742, 0.6043, 0.8956]}, {"w": "inputs.", "b": [0.6099, 0.8742, 0.6672, 0.8956]}, {"w": "It", "b": [0.6727, 0.8742, 0.6854, 0.8956]}, {"w": "also", "b": [0.6909, 0.8742, 0.7236, 0.8956]}, {"w": "manages", "b": [0.7292, 0.8742, 0.8022, 0.8956]}, {"w": "a", "b": [0.8077, 0.8742, 0.8169, 0.8956]}, {"w": "vec‐", "b": [0.8224, 0.8742, 0.8571, 0.8956]}]}, {"id": "b_12", "type": "paragraph", "text": "Implementing MLPs with Keras | 295", "words": [{"w": "Implementing", "b": [0.6126, 0.9225, 0.6972, 0.9388]}, {"w": "MLPs", "b": [0.7001, 0.9225, 0.7308, 0.9388]}, {"w": "with", "b": [0.7337, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "295", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 322, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "tor of bias terms (one per neuron). When it receives some input data, it computes Equation 10-2.", "words": [{"w": "tor", "b": [0.1786, 0.0791, 0.2033, 0.1005]}, {"w": "of", "b": [0.208, 0.0791, 0.2248, 0.1005]}, {"w": "bias", "b": [0.2295, 0.0791, 0.2625, 0.1005]}, {"w": "terms", "b": [0.2672, 0.0791, 0.3149, 0.1005]}, {"w": "(one", "b": [0.3196, 0.0791, 0.3577, 0.1005]}, {"w": "per", "b": [0.3624, 0.0791, 0.3899, 0.1005]}, {"w": "neuron).", "b": [0.3946, 0.0791, 0.4676, 0.1005]}, {"w": "When", "b": [0.4724, 0.0791, 0.524, 0.1005]}, {"w": "it", "b": [0.5287, 0.0791, 0.5406, 0.1005]}, {"w": "receives", "b": [0.5454, 0.0791, 0.6114, 0.1005]}, {"w": "some", "b": [0.6161, 0.0791, 0.6603, 0.1005]}, {"w": "input", "b": [0.665, 0.0791, 0.7099, 0.1005]}, {"w": "data,", "b": [0.7146, 0.0791, 0.7546, 0.1005]}, {"w": "it", "b": [0.7594, 0.0791, 0.7713, 0.1005]}, {"w": "computes", "b": [0.776, 0.0791, 0.857, 0.1005]}, {"w": "Equation", "b": [0.1786, 0.0981, 0.2548, 0.1195]}, {"w": "10-2.", "b": [0.2595, 0.0981, 0.3017, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "• Next we add a second Dense hidden layer with 100 neurons, also using the ReLU activation function.", "words": [{"w": "•", "b": [0.16, 0.1241, 0.1682, 0.1455]}, {"w": "Next", "b": [0.1786, 0.1241, 0.2186, 0.1455]}, {"w": "we", "b": [0.224, 0.1241, 0.2471, 0.1455]}, {"w": "add", "b": [0.2525, 0.1241, 0.2836, 0.1455]}, {"w": "a", "b": [0.289, 0.1241, 0.2981, 0.1455]}, {"w": "second", "b": [0.3035, 0.1241, 0.3619, 0.1455]}, {"w": "Dense", "b": [0.3673, 0.1273, 0.4167, 0.1424]}, {"w": "hidden", "b": [0.4221, 0.1241, 0.4811, 0.1455]}, {"w": "layer", "b": [0.4865, 0.1241, 0.5267, 0.1455]}, {"w": "with", "b": [0.5321, 0.1241, 0.5694, 0.1455]}, {"w": "100", "b": [0.5748, 0.1241, 0.6048, 0.1455]}, {"w": "neurons,", "b": [0.6102, 0.1241, 0.6836, 0.1455]}, {"w": "also", "b": [0.689, 0.1241, 0.7217, 0.1455]}, {"w": "using", "b": [0.7271, 0.1241, 0.7725, 0.1455]}, {"w": "the", "b": [0.7779, 0.1241, 0.8043, 0.1455]}, {"w": "ReLU", "b": [0.8096, 0.1241, 0.8571, 0.1455]}, {"w": "activation", "b": [0.1786, 0.1431, 0.2608, 0.1646]}, {"w": "function.", "b": [0.2656, 0.1431, 0.3417, 0.1646]}]}, {"id": "b_2", "type": "paragraph", "text": "• Finally, we add a Dense output layer with 10 neurons (one per class), using the softmax activation function (because the classes are exclusive).", "words": [{"w": "•", "b": [0.16, 0.1691, 0.1681, 0.1906]}, {"w": "Finally,", "b": [0.1786, 0.1691, 0.239, 0.1906]}, {"w": "we", "b": [0.2458, 0.1691, 0.2689, 0.1906]}, {"w": "add", "b": [0.2757, 0.1691, 0.3069, 0.1906]}, {"w": "a", "b": [0.3136, 0.1691, 0.3228, 0.1906]}, {"w": "Dense", "b": [0.3295, 0.1723, 0.379, 0.1874]}, {"w": "output", "b": [0.3858, 0.1691, 0.4422, 0.1906]}, {"w": "layer", "b": [0.4489, 0.1691, 0.4891, 0.1906]}, {"w": "with", "b": [0.4959, 0.1691, 0.5332, 0.1906]}, {"w": "10", "b": [0.54, 0.1691, 0.56, 0.1906]}, {"w": "neurons", "b": [0.5668, 0.1691, 0.6355, 0.1906]}, {"w": "(one", "b": [0.6422, 0.1691, 0.6803, 0.1906]}, {"w": "per", "b": [0.6871, 0.1691, 0.7146, 0.1906]}, {"w": "class),", "b": [0.7213, 0.1691, 0.7718, 0.1906]}, {"w": "using", "b": [0.7786, 0.1691, 0.824, 0.1906]}, {"w": "the", "b": [0.8308, 0.1691, 0.8571, 0.1906]}, {"w": "softmax", "b": [0.1786, 0.1882, 0.2454, 0.2096]}, {"w": "activation", "b": [0.2501, 0.1882, 0.3324, 0.2096]}, {"w": "function", "b": [0.3371, 0.1882, 0.4085, 0.2096]}, {"w": "(because", "b": [0.4132, 0.1882, 0.485, 0.2096]}, {"w": "the", "b": [0.4897, 0.1882, 0.5161, 0.2096]}, {"w": "classes", "b": [0.5208, 0.1882, 0.5758, 0.2096]}, {"w": "are", "b": [0.5806, 0.1882, 0.6063, 0.2096]}, {"w": "exclusive).", "b": [0.611, 0.1882, 0.6985, 0.2096]}]}, {"id": "b_3", "type": "paragraph", "text": "Specifying activation=\"relu\" is equivalent to activa tion=keras.activations.relu. Other activation functions are available in the keras.activations package, we will use many of them in this book. See https://keras.io/activations/ for the full list.", "words": [{"w": "Specifying", "b": [0.2714, 0.2461, 0.3508, 0.2656]}, {"w": "activation=\"relu\"", "b": [0.3717, 0.249, 0.5255, 0.2628]}, {"w": "is", "b": [0.5464, 0.2461, 0.5585, 0.2656]}, {"w": "equivalent", "b": [0.5794, 0.2461, 0.6584, 0.2656]}, {"w": "to", "b": [0.6793, 0.2461, 0.6948, 0.2656]}, {"w": "activa", "b": [0.7157, 0.249, 0.77, 0.2628]}, {"w": "tion=keras.activations.relu.", "b": [0.2714, 0.2643, 0.52, 0.2839]}, {"w": "Other", "b": [0.5324, 0.2643, 0.5777, 0.2839]}, {"w": "activation", "b": [0.5901, 0.2643, 0.6653, 0.2839]}, {"w": "functions", "b": [0.6776, 0.2643, 0.7499, 0.2839]}, {"w": "are", "b": [0.7622, 0.2643, 0.7857, 0.2839]}, {"w": "available", "b": [0.2714, 0.2825, 0.3375, 0.3021]}, {"w": "in", "b": [0.3438, 0.2825, 0.3593, 0.3021]}, {"w": "the", "b": [0.3657, 0.2825, 0.3898, 0.3021]}, {"w": "keras.activations", "b": [0.3961, 0.2854, 0.5499, 0.2992]}, {"w": "package,", "b": [0.5563, 0.2825, 0.6218, 0.3021]}, {"w": "we", "b": [0.6282, 0.2825, 0.6493, 0.3021]}, {"w": "will", "b": [0.6556, 0.2825, 0.6834, 0.3021]}, {"w": "use", "b": [0.6898, 0.2825, 0.715, 0.3021]}, {"w": "many", "b": [0.7213, 0.2825, 0.764, 0.3021]}, {"w": "of", "b": [0.7704, 0.2825, 0.7857, 0.3021]}, {"w": "them", "b": [0.2714, 0.3, 0.3111, 0.3195]}, {"w": "in", "b": [0.3154, 0.3, 0.3309, 0.3195]}, {"w": "this", "b": [0.3352, 0.3, 0.3633, 0.3195]}, {"w": "book.", "b": [0.3676, 0.3, 0.4105, 0.3195]}, {"w": "See", "b": [0.4149, 0.3, 0.4401, 0.3195]}, {"w": "https://keras.io/activations/", "b": [0.4444, 0.2998, 0.648, 0.3195]}, {"w": "for", "b": [0.6523, 0.3, 0.6747, 0.3195]}, {"w": "the", "b": [0.679, 0.3, 0.7031, 0.3195]}, {"w": "full", "b": [0.7074, 0.3, 0.7328, 0.3195]}, {"w": "list.", "b": [0.7371, 0.3, 0.7642, 0.3195]}]}, {"id": "b_4", "type": "paragraph", "text": "Instead of adding the layers one by one as we just did, you can pass a list of layers when creating the Sequential model:", "words": [{"w": "Instead", "b": [0.1428, 0.3439, 0.2043, 0.3653]}, {"w": "of", "b": [0.2113, 0.3439, 0.2281, 0.3653]}, {"w": "adding", "b": [0.235, 0.3439, 0.2929, 0.3653]}, {"w": "the", "b": [0.2998, 0.3439, 0.3262, 0.3653]}, {"w": "layers", "b": [0.3331, 0.3439, 0.3809, 0.3653]}, {"w": "one", "b": [0.3879, 0.3439, 0.4187, 0.3653]}, {"w": "by", "b": [0.4257, 0.3439, 0.4458, 0.3653]}, {"w": "one", "b": [0.4527, 0.3439, 0.4836, 0.3653]}, {"w": "as", "b": [0.4906, 0.3439, 0.5073, 0.3653]}, {"w": "we", "b": [0.5143, 0.3439, 0.5374, 0.3653]}, {"w": "just", "b": [0.5443, 0.3439, 0.5747, 0.3653]}, {"w": "did,", "b": [0.5817, 0.3439, 0.614, 0.3653]}, {"w": "you", "b": [0.6209, 0.3439, 0.6522, 0.3653]}, {"w": "can", "b": [0.6591, 0.3439, 0.6885, 0.3653]}, {"w": "pass", "b": [0.6954, 0.3439, 0.7308, 0.3653]}, {"w": "a", "b": [0.7377, 0.3439, 0.7468, 0.3653]}, {"w": "list", "b": [0.7538, 0.3439, 0.7786, 0.3653]}, {"w": "of", "b": [0.7856, 0.3439, 0.8024, 0.3653]}, {"w": "layers", "b": [0.8093, 0.3439, 0.8571, 0.3653]}, {"w": "when", "b": [0.1429, 0.3638, 0.1885, 0.3853]}, {"w": "creating", "b": [0.1932, 0.3638, 0.2605, 0.3853]}, {"w": "the", "b": [0.2652, 0.3638, 0.2915, 0.3853]}, {"w": "Sequential", "b": [0.2963, 0.367, 0.3952, 0.3821]}, {"w": "model:", "b": [0.3999, 0.3638, 0.4575, 0.3853]}]}, {"id": "b_5", "type": "paragraph", "text": "model = keras.models.Sequential([ keras.layers.Flatten(input_shape=[28, 28]), keras.layers.Dense(300, activation=\"relu\"), keras.layers.Dense(100, activation=\"relu\"), keras.layers.Dense(10, activation=\"softmax\") ])", "words": [{"w": "model", "b": [0.1766, 0.3958, 0.2188, 0.4087]}, {"w": "=", "b": [0.2272, 0.3958, 0.2356, 0.4087]}, {"w": "keras.models.Sequential([", "b": [0.244, 0.3958, 0.4549, 0.4087]}, {"w": "keras.layers.Flatten(input_shape=[28,", "b": [0.2103, 0.4112, 0.5223, 0.4241]}, {"w": "28]),", "b": [0.5308, 0.4112, 0.5729, 0.4241]}, {"w": "keras.layers.Dense(300,", "b": [0.2103, 0.4267, 0.4043, 0.4395]}, {"w": "activation=\"relu\"),", "b": [0.4127, 0.4267, 0.5729, 0.4395]}, {"w": "keras.layers.Dense(100,", "b": [0.2103, 0.4421, 0.4043, 0.4549]}, {"w": "activation=\"relu\"),", "b": [0.4127, 0.4421, 0.5729, 0.4549]}, {"w": "keras.layers.Dense(10,", "b": [0.2103, 0.4575, 0.3958, 0.4703]}, {"w": "activation=\"softmax\")", "b": [0.4043, 0.4575, 0.5813, 0.4703]}, {"w": "])", "b": [0.1766, 0.4729, 0.1935, 0.4858]}]}, {"id": "b_6", "type": "paragraph", "text": "Using Code Examples From keras.io", "words": [{"w": "Using", "b": [0.3285, 0.5126, 0.3836, 0.5398]}, {"w": "Code", "b": [0.3883, 0.5126, 0.4364, 0.5398]}, {"w": "Examples", "b": [0.4411, 0.5126, 0.5343, 0.5398]}, {"w": "From", "b": [0.539, 0.5126, 0.5898, 0.5398]}, {"w": "keras.io", "b": [0.5945, 0.5126, 0.6715, 0.5398]}]}, {"id": "b_7", "type": "paragraph", "text": "Code examples documented on keras.io will work fine with tf.keras, but you need to change the imports. For example, consider this keras.io code:", "words": [{"w": "Code", "b": [0.1592, 0.5443, 0.2014, 0.5647]}, {"w": "examples", "b": [0.2072, 0.5443, 0.2807, 0.5647]}, {"w": "documented", "b": [0.2864, 0.5443, 0.386, 0.5647]}, {"w": "on", "b": [0.3917, 0.5443, 0.4127, 0.5647]}, {"w": "keras.io", "b": [0.4184, 0.5443, 0.48, 0.5647]}, {"w": "will", "b": [0.4857, 0.5443, 0.5147, 0.5647]}, {"w": "work", "b": [0.5204, 0.5443, 0.5613, 0.5647]}, {"w": "fine", "b": [0.567, 0.5443, 0.5975, 0.5647]}, {"w": "with", "b": [0.6032, 0.5443, 0.6388, 0.5647]}, {"w": "tf.keras,", "b": [0.6445, 0.5443, 0.7071, 0.5647]}, {"w": "but", "b": [0.7128, 0.5443, 0.7395, 0.5647]}, {"w": "you", "b": [0.7452, 0.5443, 0.775, 0.5647]}, {"w": "need", "b": [0.7807, 0.5443, 0.8189, 0.5647]}, {"w": "to", "b": [0.8246, 0.5443, 0.8408, 0.5647]}, {"w": "change", "b": [0.1592, 0.5624, 0.2155, 0.5828]}, {"w": "the", "b": [0.22, 0.5624, 0.2451, 0.5828]}, {"w": "imports.", "b": [0.2496, 0.5624, 0.3165, 0.5828]}, {"w": "For", "b": [0.321, 0.5624, 0.3486, 0.5828]}, {"w": "example,", "b": [0.3531, 0.5624, 0.4239, 0.5828]}, {"w": "consider", "b": [0.4284, 0.5624, 0.4966, 0.5828]}, {"w": "this", "b": [0.5011, 0.5624, 0.5303, 0.5828]}, {"w": "keras.io", "b": [0.5349, 0.5624, 0.5964, 0.5828]}, {"w": "code:", "b": [0.6009, 0.5624, 0.6429, 0.5828]}]}, {"id": "b_8", "type": "equation", "text": "from keras.layers import Dense output_layer = Dense(10)", "words": [{"w": "from", "b": [0.193, 0.5934, 0.2267, 0.6062]}, {"w": "keras.layers", "b": [0.2351, 0.5934, 0.3363, 0.6062]}, {"w": "import", "b": [0.3447, 0.5934, 0.3953, 0.6062]}, {"w": "Dense", "b": [0.4038, 0.5934, 0.4459, 0.6062]}, {"w": "output_layer", "b": [0.193, 0.6088, 0.2942, 0.6217]}, {"w": "=", "b": [0.3026, 0.6088, 0.311, 0.6217]}, {"w": "Dense(10)", "b": [0.3194, 0.6088, 0.3953, 0.6217]}]}, {"id": "b_9", "type": "paragraph", "text": "You must change the imports like this:", "words": [{"w": "You", "b": [0.1592, 0.6296, 0.19, 0.65]}, {"w": "must", "b": [0.1945, 0.6296, 0.2343, 0.65]}, {"w": "change", "b": [0.2388, 0.6296, 0.2951, 0.65]}, {"w": "the", "b": [0.2996, 0.6296, 0.3246, 0.65]}, {"w": "imports", "b": [0.3292, 0.6296, 0.3916, 0.65]}, {"w": "like", "b": [0.3961, 0.6296, 0.4247, 0.65]}, {"w": "this:", "b": [0.4292, 0.6296, 0.4629, 0.65]}]}, {"id": "b_10", "type": "equation", "text": "from tensorflow.keras.layers import Dense output_layer = Dense(10)", "words": [{"w": "from", "b": [0.193, 0.6605, 0.2267, 0.6734]}, {"w": "tensorflow.keras.layers", "b": [0.2351, 0.6605, 0.4291, 0.6734]}, {"w": "import", "b": [0.4375, 0.6605, 0.4881, 0.6734]}, {"w": "Dense", "b": [0.4965, 0.6605, 0.5387, 0.6734]}, {"w": "output_layer", "b": [0.193, 0.6759, 0.2942, 0.6888]}, {"w": "=", "b": [0.3026, 0.6759, 0.311, 0.6888]}, {"w": "Dense(10)", "b": [0.3195, 0.6759, 0.3953, 0.6888]}]}, {"id": "b_11", "type": "paragraph", "text": "Or simply use full paths, if you prefer:", "words": [{"w": "Or", "b": [0.1592, 0.6967, 0.1814, 0.7171]}, {"w": "simply", "b": [0.1859, 0.6967, 0.2389, 0.7171]}, {"w": "use", "b": [0.2434, 0.6967, 0.2697, 0.7171]}, {"w": "full", "b": [0.2742, 0.6967, 0.3006, 0.7171]}, {"w": "paths,", "b": [0.3051, 0.6967, 0.3523, 0.7171]}, {"w": "if", "b": [0.3568, 0.6967, 0.368, 0.7171]}, {"w": "you", "b": [0.3725, 0.6967, 0.4023, 0.7171]}, {"w": "prefer:", "b": [0.4068, 0.6967, 0.4596, 0.7171]}]}, {"id": "b_12", "type": "equation", "text": "from tensorflow import keras output_layer = keras.layers.Dense(10)", "words": [{"w": "from", "b": [0.193, 0.7276, 0.2267, 0.7405]}, {"w": "tensorflow", "b": [0.2351, 0.7276, 0.3194, 0.7405]}, {"w": "import", "b": [0.3279, 0.7276, 0.3785, 0.7405]}, {"w": "keras", "b": [0.3869, 0.7276, 0.4291, 0.7405]}, {"w": "output_layer", "b": [0.193, 0.7431, 0.2942, 0.7559]}, {"w": "=", "b": [0.3026, 0.7431, 0.311, 0.7559]}, {"w": "keras.layers.Dense(10)", "b": [0.3194, 0.7431, 0.505, 0.7559]}]}, {"id": "b_13", "type": "paragraph", "text": "This is more verbose, but I use this approach in this book so you can easily see which packages to use, and to avoid confusion between standard classes and custom classes. In production code, I use the previous approach, as do most people.", "words": [{"w": "This", "b": [0.1592, 0.7638, 0.1947, 0.7842]}, {"w": "is", "b": [0.1997, 0.7638, 0.2123, 0.7842]}, {"w": "more", "b": [0.2173, 0.7638, 0.2595, 0.7842]}, {"w": "verbose,", "b": [0.2645, 0.7638, 0.3299, 0.7842]}, {"w": "but", "b": [0.335, 0.7638, 0.3616, 0.7842]}, {"w": "I", "b": [0.3667, 0.7638, 0.3734, 0.7842]}, {"w": "use", "b": [0.3785, 0.7638, 0.4047, 0.7842]}, {"w": "this", "b": [0.4097, 0.7638, 0.439, 0.7842]}, {"w": "approach", "b": [0.444, 0.7638, 0.5183, 0.7842]}, {"w": "in", "b": [0.5233, 0.7638, 0.5395, 0.7842]}, {"w": "this", "b": [0.5445, 0.7638, 0.5738, 0.7842]}, {"w": "book", "b": [0.5788, 0.7638, 0.619, 0.7842]}, {"w": "so", "b": [0.624, 0.7638, 0.6414, 0.7842]}, {"w": "you", "b": [0.6464, 0.7638, 0.6762, 0.7842]}, {"w": "can", "b": [0.6812, 0.7638, 0.7092, 0.7842]}, {"w": "easily", "b": [0.7142, 0.7638, 0.7581, 0.7842]}, {"w": "see", "b": [0.7631, 0.7638, 0.7873, 0.7842]}, {"w": "which", "b": [0.7923, 0.7638, 0.8408, 0.7842]}, {"w": "packages", "b": [0.1592, 0.7819, 0.2303, 0.8023]}, {"w": "to", "b": [0.2353, 0.7819, 0.2515, 0.8023]}, {"w": "use,", "b": [0.2566, 0.7819, 0.2874, 0.8023]}, {"w": "and", "b": [0.2924, 0.7819, 0.3225, 0.8023]}, {"w": "to", "b": [0.3275, 0.7819, 0.3437, 0.8023]}, {"w": "avoid", "b": [0.3488, 0.7819, 0.3922, 0.8023]}, {"w": "confusion", "b": [0.3973, 0.7819, 0.4766, 0.8023]}, {"w": "between", "b": [0.4817, 0.7819, 0.5475, 0.8023]}, {"w": "standard", "b": [0.5526, 0.7819, 0.6225, 0.8023]}, {"w": "classes", "b": [0.6276, 0.7819, 0.68, 0.8023]}, {"w": "and", "b": [0.6851, 0.7819, 0.7151, 0.8023]}, {"w": "custom", "b": [0.7202, 0.7819, 0.7788, 0.8023]}, {"w": "classes.", "b": [0.7839, 0.7819, 0.8408, 0.8023]}, {"w": "In", "b": [0.1592, 0.8001, 0.1768, 0.8205]}, {"w": "production", "b": [0.1814, 0.8001, 0.271, 0.8205]}, {"w": "code,", "b": [0.2755, 0.8001, 0.3174, 0.8205]}, {"w": "I", "b": [0.3219, 0.8001, 0.3287, 0.8205]}, {"w": "use", "b": [0.3332, 0.8001, 0.3594, 0.8205]}, {"w": "the", "b": [0.364, 0.8001, 0.389, 0.8205]}, {"w": "previous", "b": [0.3935, 0.8001, 0.4622, 0.8205]}, {"w": "approach,", "b": [0.4667, 0.8001, 0.5455, 0.8205]}, {"w": "as", "b": [0.55, 0.8001, 0.566, 0.8205]}, {"w": "do", "b": [0.5705, 0.8001, 0.5911, 0.8205]}, {"w": "most", "b": [0.5956, 0.8001, 0.6353, 0.8205]}, {"w": "people.", "b": [0.6398, 0.8001, 0.6971, 0.8205]}]}, {"id": "b_14", "type": "paragraph", "text": "296 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "296", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4163, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4583, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 323, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "13 You can also generate an image of your model using keras.utils.plot_model().", "words": [{"w": "13", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "You", "b": [0.1587, 0.8749, 0.1834, 0.8912]}, {"w": "can", "b": [0.187, 0.8749, 0.2093, 0.8912]}, {"w": "also", "b": [0.213, 0.8749, 0.2379, 0.8912]}, {"w": "generate", "b": [0.2415, 0.8749, 0.2952, 0.8912]}, {"w": "an", "b": [0.2988, 0.8749, 0.3145, 0.8912]}, {"w": "image", "b": [0.3181, 0.8749, 0.3565, 0.8912]}, {"w": "of", "b": [0.3601, 0.8749, 0.3729, 0.8912]}, {"w": "your", "b": [0.3765, 0.8749, 0.4062, 0.8912]}, {"w": "model", "b": [0.4098, 0.8749, 0.45, 0.8912]}, {"w": "using", "b": [0.4536, 0.8749, 0.4882, 0.8912]}, {"w": "keras.utils.plot_model().", "b": [0.4918, 0.8749, 0.6764, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "The model’s summary() method displays all the model’s layers13, including each layer’s name (which is automatically generated unless you set it when creating the layer), its output shape (None means the batch size can be anything), and its number of parame‐ ters. The summary ends with the total number of parameters, including trainable and non-trainable parameters. Here we only have trainable parameters (we will see exam‐ ples of non-trainable parameters in Chapter 11):", "words": [{"w": "The", "b": [0.1429, 0.08, 0.1757, 0.1014]}, {"w": "model’s", "b": [0.1809, 0.08, 0.2435, 0.1014]}, {"w": "summary()", "b": [0.2487, 0.0831, 0.3378, 0.0982]}, {"w": "method", "b": [0.343, 0.08, 0.408, 0.1014]}, {"w": "displays", "b": [0.4133, 0.08, 0.4797, 0.1014]}, {"w": "all", "b": [0.4849, 0.08, 0.5046, 0.1014]}, {"w": "the", "b": [0.5098, 0.08, 0.5361, 0.1014]}, {"w": "model’s", "b": [0.5414, 0.08, 0.6039, 0.1014]}, {"w": "layers13,", "b": [0.6092, 0.08, 0.6732, 0.1014]}, {"w": "including", "b": [0.6784, 0.08, 0.7583, 0.1014]}, {"w": "each", "b": [0.7635, 0.08, 0.8014, 0.1014]}, {"w": "layer’s", "b": [0.8066, 0.08, 0.8571, 0.1014]}, {"w": "name", "b": [0.1429, 0.099, 0.1893, 0.1204]}, {"w": "(which", "b": [0.195, 0.099, 0.2531, 0.1204]}, {"w": "is", "b": [0.2587, 0.099, 0.272, 0.1204]}, {"w": "automatically", "b": [0.2776, 0.099, 0.3902, 0.1204]}, {"w": "generated", "b": [0.3959, 0.099, 0.4774, 0.1204]}, {"w": "unless", "b": [0.4831, 0.099, 0.5349, 0.1204]}, {"w": "you", "b": [0.5406, 0.099, 0.5718, 0.1204]}, {"w": "set", "b": [0.5775, 0.099, 0.6004, 0.1204]}, {"w": "it", "b": [0.606, 0.099, 0.6179, 0.1204]}, {"w": "when", "b": [0.6236, 0.099, 0.6692, 0.1204]}, {"w": "creating", "b": [0.6749, 0.099, 0.7421, 0.1204]}, {"w": "the", "b": [0.7478, 0.099, 0.7741, 0.1204]}, {"w": "layer),", "b": [0.7798, 0.099, 0.8319, 0.1204]}, {"w": "its", "b": [0.8376, 0.099, 0.8571, 0.1204]}, {"w": "output", "b": [0.1428, 0.119, 0.1992, 0.1404]}, {"w": "shape", "b": [0.204, 0.119, 0.2512, 0.1404]}, {"w": "(None", "b": [0.256, 0.119, 0.303, 0.1404]}, {"w": "means", "b": [0.3079, 0.119, 0.362, 0.1404]}, {"w": "the", "b": [0.3668, 0.119, 0.3931, 0.1404]}, {"w": "batch", "b": [0.398, 0.119, 0.4436, 0.1404]}, {"w": "size", "b": [0.4485, 0.119, 0.4793, 0.1404]}, {"w": "can", "b": [0.4841, 0.119, 0.5135, 0.1404]}, {"w": "be", "b": [0.5183, 0.119, 0.5378, 0.1404]}, {"w": "anything),", "b": [0.5426, 0.119, 0.6284, 0.1404]}, {"w": "and", "b": [0.6333, 0.119, 0.6648, 0.1404]}, {"w": "its", "b": [0.6697, 0.119, 0.6892, 0.1404]}, {"w": "number", "b": [0.6941, 0.119, 0.7604, 0.1404]}, {"w": "of", "b": [0.7652, 0.119, 0.782, 0.1404]}, {"w": "parame‐", "b": [0.7869, 0.119, 0.8571, 0.1404]}, {"w": "ters.", "b": [0.1429, 0.138, 0.1782, 0.1594]}, {"w": "The", "b": [0.1831, 0.138, 0.216, 0.1594]}, {"w": "summary", "b": [0.2209, 0.138, 0.3008, 0.1594]}, {"w": "ends", "b": [0.3057, 0.138, 0.3446, 0.1594]}, {"w": "with", "b": [0.3495, 0.138, 0.3869, 0.1594]}, {"w": "the", "b": [0.3918, 0.138, 0.4181, 0.1594]}, {"w": "total", "b": [0.4231, 0.138, 0.4608, 0.1594]}, {"w": "number", "b": [0.4658, 0.138, 0.532, 0.1594]}, {"w": "of", "b": [0.537, 0.138, 0.5538, 0.1594]}, {"w": "parameters,", "b": [0.5587, 0.138, 0.6569, 0.1594]}, {"w": "including", "b": [0.6618, 0.138, 0.7417, 0.1594]}, {"w": "trainable", "b": [0.7466, 0.138, 0.8207, 0.1594]}, {"w": "and", "b": [0.8256, 0.138, 0.8572, 0.1594]}, {"w": "non-trainable", "b": [0.1429, 0.157, 0.2578, 0.1785]}, {"w": "parameters.", "b": [0.2629, 0.157, 0.361, 0.1785]}, {"w": "Here", "b": [0.3661, 0.157, 0.407, 0.1785]}, {"w": "we", "b": [0.4121, 0.157, 0.4352, 0.1785]}, {"w": "only", "b": [0.4403, 0.157, 0.4772, 0.1785]}, {"w": "have", "b": [0.4823, 0.157, 0.5207, 0.1785]}, {"w": "trainable", "b": [0.5258, 0.157, 0.5998, 0.1785]}, {"w": "parameters", "b": [0.6049, 0.157, 0.6984, 0.1785]}, {"w": "(we", "b": [0.7035, 0.157, 0.7338, 0.1785]}, {"w": "will", "b": [0.7389, 0.157, 0.7693, 0.1785]}, {"w": "see", "b": [0.7744, 0.157, 0.7997, 0.1785]}, {"w": "exam‐", "b": [0.8048, 0.157, 0.8571, 0.1785]}, {"w": "ples", "b": [0.1429, 0.1761, 0.1755, 0.1975]}, {"w": "of", "b": [0.1803, 0.1761, 0.1971, 0.1975]}, {"w": "non-trainable", "b": [0.2018, 0.1761, 0.3167, 0.1975]}, {"w": "parameters", "b": [0.3214, 0.1761, 0.4149, 0.1975]}, {"w": "in", "b": [0.4196, 0.1761, 0.4366, 0.1975]}, {"w": "Chapter", "b": [0.4413, 0.1761, 0.5089, 0.1975]}, {"w": "11):", "b": [0.5136, 0.1761, 0.5456, 0.1975]}]}, {"id": "b_2", "type": "paragraph", "text": ">>> model.summary() _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= flatten_1 (Flatten) (None, 784) 0 _________________________________________________________________ dense_3 (Dense) (None, 300) 235500 _________________________________________________________________ dense_4 (Dense) (None, 100) 30100 _________________________________________________________________ dense_5 (Dense) (None, 10) 1010 ================================================================= Total params: 266,610 Trainable params: 266,610 Non-trainable params: 0", "words": [{"w": ">>>", "b": [0.1766, 0.2081, 0.2019, 0.2209]}, {"w": "model.summary()", "b": [0.2103, 0.2081, 0.3368, 0.2209]}, {"w": "_________________________________________________________________", "b": [0.1766, 0.2235, 0.7247, 0.2363]}, {"w": "Layer", "b": [0.1766, 0.2389, 0.2188, 0.2518]}, {"w": "(type)", "b": [0.2272, 0.2389, 0.2778, 0.2518]}, {"w": "Output", "b": [0.4211, 0.2389, 0.4717, 0.2518]}, {"w": "Shape", "b": [0.4802, 0.2389, 0.5223, 0.2518]}, {"w": "Param", "b": [0.6404, 0.2389, 0.6825, 0.2518]}, {"w": "#", "b": [0.691, 0.2389, 0.6994, 0.2518]}, {"w": "=================================================================", "b": [0.1766, 0.2543, 0.7247, 0.2672]}, {"w": "flatten_1", "b": [0.1766, 0.2697, 0.2525, 0.2826]}, {"w": "(Flatten)", "b": [0.2609, 0.2697, 0.3368, 0.2826]}, {"w": "(None,", "b": [0.4211, 0.2697, 0.4717, 0.2826]}, {"w": "784)", "b": [0.4802, 0.2697, 0.5139, 0.2826]}, {"w": "0", "b": [0.6404, 0.2697, 0.6488, 0.2826]}, {"w": "_________________________________________________________________", "b": [0.1766, 0.2852, 0.7247, 0.298]}, {"w": "dense_3", "b": [0.1766, 0.3006, 0.2356, 0.3134]}, {"w": "(Dense)", "b": [0.2441, 0.3006, 0.3031, 0.3134]}, {"w": "(None,", "b": [0.4211, 0.3006, 0.4717, 0.3134]}, {"w": "300)", "b": [0.4802, 0.3006, 0.5139, 0.3134]}, {"w": "235500", "b": [0.6404, 0.3006, 0.691, 0.3134]}, {"w": "_________________________________________________________________", "b": [0.1766, 0.316, 0.7247, 0.3289]}, {"w": "dense_4", "b": [0.1766, 0.3314, 0.2356, 0.3443]}, {"w": "(Dense)", "b": [0.2441, 0.3314, 0.3031, 0.3443]}, {"w": "(None,", "b": [0.4211, 0.3314, 0.4717, 0.3443]}, {"w": "100)", "b": [0.4802, 0.3314, 0.5139, 0.3443]}, {"w": "30100", "b": [0.6404, 0.3314, 0.6825, 0.3443]}, {"w": "_________________________________________________________________", "b": [0.1766, 0.3468, 0.7247, 0.3597]}, {"w": "dense_5", "b": [0.1766, 0.3623, 0.2356, 0.3751]}, {"w": "(Dense)", "b": [0.2441, 0.3623, 0.3031, 0.3751]}, {"w": "(None,", "b": [0.4211, 0.3623, 0.4717, 0.3751]}, {"w": "10)", "b": [0.4802, 0.3623, 0.5055, 0.3751]}, {"w": "1010", "b": [0.6404, 0.3623, 0.6741, 0.3751]}, {"w": "=================================================================", "b": [0.1766, 0.3777, 0.7247, 0.3905]}, {"w": "Total", "b": [0.1766, 0.3931, 0.2188, 0.406]}, {"w": "params:", "b": [0.2272, 0.3931, 0.2862, 0.406]}, {"w": "266,610", "b": [0.2946, 0.3931, 0.3537, 0.406]}, {"w": "Trainable", "b": [0.1766, 0.4085, 0.2525, 0.4214]}, {"w": "params:", "b": [0.2609, 0.4085, 0.3199, 0.4214]}, {"w": "266,610", "b": [0.3284, 0.4085, 0.3874, 0.4214]}, {"w": "Non-trainable", "b": [0.1766, 0.4239, 0.2862, 0.4368]}, {"w": "params:", "b": [0.2946, 0.4239, 0.3537, 0.4368]}, {"w": "0", "b": [0.3621, 0.4239, 0.3705, 0.4368]}]}, {"id": "b_3", "type": "paragraph", "text": "Note that Dense layers often have a lot of parameters. For example, the first hidden layer has 784 × 300 connection weights, plus 300 bias terms, which adds up to 235,500 parameters! This gives the model quite a lot of flexibility to fit the training data, but it also means that the model runs the risk of overfitting, especially when you do not have a lot of training data. We will come back to this later.", "words": [{"w": "Note", "b": [0.1429, 0.4455, 0.1836, 0.4669]}, {"w": "that", "b": [0.1904, 0.4455, 0.223, 0.4669]}, {"w": "Dense", "b": [0.2297, 0.4487, 0.2792, 0.4637]}, {"w": "layers", "b": [0.286, 0.4455, 0.3338, 0.4669]}, {"w": "often", "b": [0.3406, 0.4455, 0.384, 0.4669]}, {"w": "have", "b": [0.3907, 0.4455, 0.4291, 0.4669]}, {"w": "a", "b": [0.4359, 0.4455, 0.445, 0.4669]}, {"w": "lot", "b": [0.4518, 0.4453, 0.4728, 0.4669]}, {"w": "of", "b": [0.4796, 0.4455, 0.4964, 0.4669]}, {"w": "parameters.", "b": [0.5031, 0.4455, 0.6013, 0.4669]}, {"w": "For", "b": [0.6081, 0.4455, 0.637, 0.4669]}, {"w": "example,", "b": [0.6438, 0.4455, 0.7181, 0.4669]}, {"w": "the", "b": [0.7249, 0.4455, 0.7512, 0.4669]}, {"w": "first", "b": [0.7579, 0.4455, 0.7914, 0.4669]}, {"w": "hidden", "b": [0.7982, 0.4455, 0.8571, 0.4669]}, {"w": "layer", "b": [0.1429, 0.4645, 0.1831, 0.4859]}, {"w": "has", "b": [0.1926, 0.4645, 0.2205, 0.4859]}, {"w": "784", "b": [0.23, 0.4645, 0.26, 0.4859]}, {"w": "×", "b": [0.2696, 0.4645, 0.2816, 0.4859]}, {"w": "300", "b": [0.2912, 0.4645, 0.3212, 0.4859]}, {"w": "connection", "b": [0.3307, 0.4645, 0.4245, 0.4859]}, {"w": "weights,", "b": [0.4341, 0.4645, 0.502, 0.4859]}, {"w": "plus", "b": [0.5115, 0.4645, 0.5464, 0.4859]}, {"w": "300", "b": [0.556, 0.4645, 0.586, 0.4859]}, {"w": "bias", "b": [0.5955, 0.4645, 0.6285, 0.4859]}, {"w": "terms,", "b": [0.638, 0.4645, 0.6904, 0.4859]}, {"w": "which", "b": [0.6999, 0.4645, 0.7508, 0.4859]}, {"w": "adds", "b": [0.7603, 0.4645, 0.7991, 0.4859]}, {"w": "up", "b": [0.8087, 0.4645, 0.8306, 0.4859]}, {"w": "to", "b": [0.8402, 0.4645, 0.8572, 0.4859]}, {"w": "235,500", "b": [0.1429, 0.4836, 0.2076, 0.505]}, {"w": "parameters!", "b": [0.2144, 0.4836, 0.3136, 0.505]}, {"w": "This", "b": [0.3203, 0.4836, 0.3576, 0.505]}, {"w": "gives", "b": [0.3643, 0.4836, 0.4058, 0.505]}, {"w": "the", "b": [0.4126, 0.4836, 0.4389, 0.505]}, {"w": "model", "b": [0.4457, 0.4836, 0.4985, 0.505]}, {"w": "quite", "b": [0.5053, 0.4836, 0.5478, 0.505]}, {"w": "a", "b": [0.5545, 0.4836, 0.5637, 0.505]}, {"w": "lot", "b": [0.5705, 0.4836, 0.5927, 0.505]}, {"w": "of", "b": [0.5995, 0.4836, 0.6163, 0.505]}, {"w": "flexibility", "b": [0.6231, 0.4836, 0.7017, 0.505]}, {"w": "to", "b": [0.7085, 0.4836, 0.7255, 0.505]}, {"w": "fit", "b": [0.7322, 0.4836, 0.7503, 0.505]}, {"w": "the", "b": [0.7571, 0.4836, 0.7834, 0.505]}, {"w": "training", "b": [0.7902, 0.4836, 0.8571, 0.505]}, {"w": "data,", "b": [0.1429, 0.5026, 0.1829, 0.524]}, {"w": "but", "b": [0.1878, 0.5026, 0.2158, 0.524]}, {"w": "it", "b": [0.2207, 0.5026, 0.2327, 0.524]}, {"w": "also", "b": [0.2376, 0.5026, 0.2703, 0.524]}, {"w": "means", "b": [0.2752, 0.5026, 0.3293, 0.524]}, {"w": "that", "b": [0.3342, 0.5026, 0.3668, 0.524]}, {"w": "the", "b": [0.3718, 0.5026, 0.3981, 0.524]}, {"w": "model", "b": [0.403, 0.5026, 0.4558, 0.524]}, {"w": "runs", "b": [0.4608, 0.5026, 0.4986, 0.524]}, {"w": "the", "b": [0.5035, 0.5026, 0.5299, 0.524]}, {"w": "risk", "b": [0.5348, 0.5026, 0.5661, 0.524]}, {"w": "of", "b": [0.571, 0.5026, 0.5878, 0.524]}, {"w": "overfitting,", "b": [0.5927, 0.5026, 0.6855, 0.524]}, {"w": "especially", "b": [0.6905, 0.5026, 0.7704, 0.524]}, {"w": "when", "b": [0.7753, 0.5026, 0.821, 0.524]}, {"w": "you", "b": [0.8259, 0.5026, 0.8571, 0.524]}, {"w": "do", "b": [0.1428, 0.5217, 0.1645, 0.5431]}, {"w": "not", "b": [0.1692, 0.5217, 0.1976, 0.5431]}, {"w": "have", "b": [0.2023, 0.5217, 0.2407, 0.5431]}, {"w": "a", "b": [0.2454, 0.5217, 0.2546, 0.5431]}, {"w": "lot", "b": [0.2593, 0.5217, 0.2816, 0.5431]}, {"w": "of", "b": [0.2863, 0.5217, 0.3031, 0.5431]}, {"w": "training", "b": [0.3078, 0.5217, 0.3747, 0.5431]}, {"w": "data.", "b": [0.3795, 0.5217, 0.4195, 0.5431]}, {"w": "We", "b": [0.4242, 0.5217, 0.4513, 0.5431]}, {"w": "will", "b": [0.456, 0.5217, 0.4864, 0.5431]}, {"w": "come", "b": [0.4911, 0.5217, 0.5365, 0.5431]}, {"w": "back", "b": [0.5412, 0.5217, 0.5801, 0.5431]}, {"w": "to", "b": [0.5848, 0.5217, 0.6018, 0.5431]}, {"w": "this", "b": [0.6065, 0.5217, 0.6372, 0.5431]}, {"w": "later.", "b": [0.642, 0.5217, 0.6823, 0.5431]}]}, {"id": "b_4", "type": "paragraph", "text": "You can easily get a model’s list of layers, to fetch a layer by its index, or you can fetch it by name:", "words": [{"w": "You", "b": [0.1428, 0.5498, 0.1752, 0.5712]}, {"w": "can", "b": [0.1803, 0.5498, 0.2096, 0.5712]}, {"w": "easily", "b": [0.2147, 0.5498, 0.2608, 0.5712]}, {"w": "get", "b": [0.2659, 0.5498, 0.2908, 0.5712]}, {"w": "a", "b": [0.2959, 0.5498, 0.3051, 0.5712]}, {"w": "model’s", "b": [0.3101, 0.5498, 0.3727, 0.5712]}, {"w": "list", "b": [0.3778, 0.5498, 0.4027, 0.5712]}, {"w": "of", "b": [0.4077, 0.5498, 0.4245, 0.5712]}, {"w": "layers,", "b": [0.4296, 0.5498, 0.4822, 0.5712]}, {"w": "to", "b": [0.4873, 0.5498, 0.5043, 0.5712]}, {"w": "fetch", "b": [0.5093, 0.5498, 0.5506, 0.5712]}, {"w": "a", "b": [0.5557, 0.5498, 0.5649, 0.5712]}, {"w": "layer", "b": [0.57, 0.5498, 0.6101, 0.5712]}, {"w": "by", "b": [0.6152, 0.5498, 0.6354, 0.5712]}, {"w": "its", "b": [0.6405, 0.5498, 0.66, 0.5712]}, {"w": "index,", "b": [0.6651, 0.5498, 0.7165, 0.5712]}, {"w": "or", "b": [0.7216, 0.5498, 0.74, 0.5712]}, {"w": "you", "b": [0.7451, 0.5498, 0.7763, 0.5712]}, {"w": "can", "b": [0.7814, 0.5498, 0.8107, 0.5712]}, {"w": "fetch", "b": [0.8158, 0.5498, 0.8571, 0.5712]}, {"w": "it", "b": [0.1429, 0.5688, 0.1548, 0.5902]}, {"w": "by", "b": [0.1595, 0.5688, 0.1797, 0.5902]}, {"w": "name:", "b": [0.1844, 0.5688, 0.2356, 0.5902]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> model.layers [, , , ] >>> model.layers[1].name 'dense_3' >>> model.get_layer('dense_3').name 'dense_3'", "words": [{"w": ">>>", "b": [0.1766, 0.6008, 0.2019, 0.6137]}, {"w": "model.layers", "b": [0.2103, 0.6008, 0.3115, 0.6137]}, {"w": "[,", "b": [0.5898, 0.6162, 0.6994, 0.6291]}, {"w": ",", "b": [0.5729, 0.6316, 0.6825, 0.6445]}, {"w": ",", "b": [0.5729, 0.6471, 0.6825, 0.6599]}, {"w": "]", "b": [0.5729, 0.6625, 0.6825, 0.6753]}, {"w": ">>>", "b": [0.1766, 0.6779, 0.2019, 0.6907]}, {"w": "model.layers[1].name", "b": [0.2103, 0.6779, 0.379, 0.6907]}, {"w": "'dense_3'", "b": [0.1766, 0.6933, 0.2525, 0.7062]}, {"w": ">>>", "b": [0.1766, 0.7087, 0.2019, 0.7216]}, {"w": "model.get_layer('dense_3').name", "b": [0.2103, 0.7087, 0.4717, 0.7216]}, {"w": "'dense_3'", "b": [0.1766, 0.7242, 0.2525, 0.737]}]}, {"id": "b_6", "type": "paragraph", "text": "All the parameters of a layer can be accessed using its get_weights() and set_weights() method. For a Dense layer, this includes both the connection weights and the bias terms:", "words": [{"w": "All", "b": [0.1429, 0.7457, 0.1678, 0.7671]}, {"w": "the", "b": [0.181, 0.7457, 0.2073, 0.7671]}, {"w": "parameters", "b": [0.2206, 0.7457, 0.314, 0.7671]}, {"w": "of", "b": [0.3272, 0.7457, 0.344, 0.7671]}, {"w": "a", "b": [0.3572, 0.7457, 0.3664, 0.7671]}, {"w": "layer", "b": [0.3796, 0.7457, 0.4198, 0.7671]}, {"w": "can", "b": [0.433, 0.7457, 0.4624, 0.7671]}, {"w": "be", "b": [0.4756, 0.7457, 0.495, 0.7671]}, {"w": "accessed", "b": [0.5083, 0.7457, 0.579, 0.7671]}, {"w": "using", "b": [0.5923, 0.7457, 0.6377, 0.7671]}, {"w": "its", "b": [0.6509, 0.7457, 0.6705, 0.7671]}, {"w": "get_weights()", "b": [0.6837, 0.7489, 0.8124, 0.7639]}, {"w": "and", "b": [0.8256, 0.7457, 0.8571, 0.7671]}, {"w": "set_weights()", "b": [0.1429, 0.7688, 0.2715, 0.7839]}, {"w": "method.", "b": [0.2772, 0.7656, 0.3469, 0.787]}, {"w": "For", "b": [0.3526, 0.7656, 0.3816, 0.787]}, {"w": "a", "b": [0.3872, 0.7656, 0.3964, 0.787]}, {"w": "Dense", "b": [0.402, 0.7688, 0.4515, 0.7839]}, {"w": "layer,", "b": [0.4572, 0.7656, 0.5008, 0.787]}, {"w": "this", "b": [0.5065, 0.7656, 0.5372, 0.787]}, {"w": "includes", "b": [0.5428, 0.7656, 0.6124, 0.787]}, {"w": "both", "b": [0.6181, 0.7656, 0.6568, 0.787]}, {"w": "the", "b": [0.6625, 0.7656, 0.6888, 0.787]}, {"w": "connection", "b": [0.6944, 0.7656, 0.7883, 0.787]}, {"w": "weights", "b": [0.794, 0.7656, 0.8571, 0.787]}, {"w": "and", "b": [0.1429, 0.7847, 0.1744, 0.8061]}, {"w": "the", "b": [0.1791, 0.7847, 0.2055, 0.8061]}, {"w": "bias", "b": [0.2102, 0.7847, 0.2431, 0.8061]}, {"w": "terms:", "b": [0.2479, 0.7847, 0.3003, 0.8061]}]}, {"id": "b_7", "type": "paragraph", "text": "Implementing MLPs with Keras | 297", "words": [{"w": "Implementing", "b": [0.6126, 0.9225, 0.6972, 0.9388]}, {"w": "MLPs", "b": [0.7001, 0.9225, 0.7308, 0.9388]}, {"w": "with", "b": [0.7336, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "297", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 324, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": ">>> weights, biases = hidden1.get_weights() >>> weights array([[ 0.03854964, -0.04054524, 0.00599282, ..., 0.02566582, 0.01032123, 0.06914985], ..., [ 0.02632413, -0.05105981, -0.00332005, ..., 0.04175945, 0.0443138 , -0.05558084]], dtype=float32) >>> weights.shape (784, 300) >>> biases array([0., 0., 0., 0., 0., 0., 0., 0., 0., ..., 0., 0., 0.], dtype=float32) >>> biases.shape (300,)", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "weights,", "b": [0.2103, 0.0829, 0.2778, 0.0958]}, {"w": "biases", "b": [0.2862, 0.0829, 0.3368, 0.0958]}, {"w": "=", "b": [0.3452, 0.0829, 0.3537, 0.0958]}, {"w": "hidden1.get_weights()", "b": [0.3621, 0.0829, 0.5392, 0.0958]}, {"w": ">>>", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "weights", "b": [0.2103, 0.0983, 0.2693, 0.1112]}, {"w": "array([[", "b": [0.1766, 0.1138, 0.244, 0.1266]}, {"w": "0.03854964,", "b": [0.2525, 0.1138, 0.3452, 0.1266]}, {"w": "-0.04054524,", "b": [0.3537, 0.1138, 0.4549, 0.1266]}, {"w": "0.00599282,", "b": [0.4717, 0.1138, 0.5645, 0.1266]}, {"w": "...,", "b": [0.5729, 0.1138, 0.6066, 0.1266]}, {"w": "0.02566582,", "b": [0.6235, 0.1138, 0.7163, 0.1266]}, {"w": "0.01032123,", "b": [0.2525, 0.1292, 0.3452, 0.142]}, {"w": "0.06914985],", "b": [0.3621, 0.1292, 0.4633, 0.142]}, {"w": "...,", "b": [0.2356, 0.1446, 0.2693, 0.1574]}, {"w": "[", "b": [0.2356, 0.16, 0.244, 0.1729]}, {"w": "0.02632413,", "b": [0.2525, 0.16, 0.3452, 0.1729]}, {"w": "-0.05105981,", "b": [0.3537, 0.16, 0.4549, 0.1729]}, {"w": "-0.00332005,", "b": [0.4633, 0.16, 0.5645, 0.1729]}, {"w": "...,", "b": [0.5729, 0.16, 0.6066, 0.1729]}, {"w": "0.04175945,", "b": [0.6235, 0.16, 0.7163, 0.1729]}, {"w": "0.0443138", "b": [0.2525, 0.1754, 0.3284, 0.1883]}, {"w": ",", "b": [0.3368, 0.1754, 0.3452, 0.1883]}, {"w": "-0.05558084]],", "b": [0.3537, 0.1754, 0.4717, 0.1883]}, {"w": "dtype=float32)", "b": [0.4802, 0.1754, 0.5982, 0.1883]}, {"w": ">>>", "b": [0.1766, 0.1909, 0.2019, 0.2037]}, {"w": "weights.shape", "b": [0.2103, 0.1909, 0.3199, 0.2037]}, {"w": "(784,", "b": [0.1766, 0.2063, 0.2188, 0.2191]}, {"w": "300)", "b": [0.2272, 0.2063, 0.2609, 0.2191]}, {"w": ">>>", "b": [0.1766, 0.2217, 0.2019, 0.2345]}, {"w": "biases", "b": [0.2103, 0.2217, 0.2609, 0.2345]}, {"w": "array([0.,", "b": [0.1766, 0.2371, 0.2609, 0.25]}, {"w": "0.,", "b": [0.2693, 0.2371, 0.2946, 0.25]}, {"w": "0.,", "b": [0.3031, 0.2371, 0.3284, 0.25]}, {"w": "0.,", "b": [0.3368, 0.2371, 0.3621, 0.25]}, {"w": "0.,", "b": [0.3705, 0.2371, 0.3958, 0.25]}, {"w": "0.,", "b": [0.4043, 0.2371, 0.4296, 0.25]}, {"w": "0.,", "b": [0.438, 0.2371, 0.4633, 0.25]}, {"w": "0.,", "b": [0.4717, 0.2371, 0.497, 0.25]}, {"w": "0.,", "b": [0.5055, 0.2371, 0.5308, 0.25]}, {"w": "...,", "b": [0.5392, 0.2371, 0.5729, 0.25]}, {"w": "0.,", "b": [0.5898, 0.2371, 0.6151, 0.25]}, {"w": "0.,", "b": [0.6235, 0.2371, 0.6488, 0.25]}, {"w": "0.],", "b": [0.6572, 0.2371, 0.691, 0.25]}, {"w": "dtype=float32)", "b": [0.6994, 0.2371, 0.8175, 0.25]}, {"w": ">>>", "b": [0.1766, 0.2525, 0.2019, 0.2654]}, {"w": "biases.shape", "b": [0.2103, 0.2525, 0.3115, 0.2654]}, {"w": "(300,)", "b": [0.1766, 0.268, 0.2272, 0.2808]}]}, {"id": "b_1", "type": "paragraph", "text": "Notice that the Dense layer initialized the connection weights randomly (which is needed to break symmetry, as we discussed earlier), and the biases were just initial‐ ized to zeros, which is fine. If you ever want to use a different initialization method, you can set kernel_initializer (kernel is another name for the matrix of connec‐ tion weights) or bias_initializer when creating the layer. We will discuss initializ‐ ers further in Chapter 11, but if you want the full list, see https://keras.io/initializers/.", "words": [{"w": "Notice", "b": [0.1428, 0.2895, 0.198, 0.3109]}, {"w": "that", "b": [0.2063, 0.2895, 0.2389, 0.3109]}, {"w": "the", "b": [0.2471, 0.2895, 0.2735, 0.3109]}, {"w": "Dense", "b": [0.2817, 0.2927, 0.3312, 0.3077]}, {"w": "layer", "b": [0.3395, 0.2895, 0.3797, 0.3109]}, {"w": "initialized", "b": [0.3879, 0.2895, 0.471, 0.3109]}, {"w": "the", "b": [0.4793, 0.2895, 0.5056, 0.3109]}, {"w": "connection", "b": [0.5139, 0.2895, 0.6078, 0.3109]}, {"w": "weights", "b": [0.616, 0.2895, 0.6792, 0.3109]}, {"w": "randomly", "b": [0.6875, 0.2895, 0.7693, 0.3109]}, {"w": "(which", "b": [0.7775, 0.2895, 0.8356, 0.3109]}, {"w": "is", "b": [0.8439, 0.2895, 0.8571, 0.3109]}, {"w": "needed", "b": [0.1429, 0.3085, 0.2028, 0.3299]}, {"w": "to", "b": [0.2094, 0.3085, 0.2263, 0.3299]}, {"w": "break", "b": [0.2329, 0.3085, 0.2795, 0.3299]}, {"w": "symmetry,", "b": [0.2861, 0.3085, 0.3737, 0.3299]}, {"w": "as", "b": [0.3803, 0.3085, 0.3971, 0.3299]}, {"w": "we", "b": [0.4036, 0.3085, 0.4267, 0.3299]}, {"w": "discussed", "b": [0.4332, 0.3085, 0.5125, 0.3299]}, {"w": "earlier),", "b": [0.519, 0.3085, 0.5842, 0.3299]}, {"w": "and", "b": [0.5907, 0.3085, 0.6222, 0.3299]}, {"w": "the", "b": [0.6288, 0.3085, 0.6551, 0.3299]}, {"w": "biases", "b": [0.6616, 0.3085, 0.7111, 0.3299]}, {"w": "were", "b": [0.7176, 0.3085, 0.7573, 0.3299]}, {"w": "just", "b": [0.7639, 0.3085, 0.7943, 0.3299]}, {"w": "initial‐", "b": [0.8008, 0.3085, 0.8571, 0.3299]}, {"w": "ized", "b": [0.1429, 0.3276, 0.177, 0.349]}, {"w": "to", "b": [0.1832, 0.3276, 0.2002, 0.349]}, {"w": "zeros,", "b": [0.2063, 0.3276, 0.2547, 0.349]}, {"w": "which", "b": [0.2609, 0.3276, 0.3118, 0.349]}, {"w": "is", "b": [0.3179, 0.3276, 0.3312, 0.349]}, {"w": "fine.", "b": [0.3373, 0.3276, 0.3741, 0.349]}, {"w": "If", "b": [0.3802, 0.3276, 0.3935, 0.349]}, {"w": "you", "b": [0.3997, 0.3276, 0.4309, 0.349]}, {"w": "ever", "b": [0.4371, 0.3276, 0.4721, 0.349]}, {"w": "want", "b": [0.4783, 0.3276, 0.5191, 0.349]}, {"w": "to", "b": [0.5252, 0.3276, 0.5422, 0.349]}, {"w": "use", "b": [0.5484, 0.3276, 0.5759, 0.349]}, {"w": "a", "b": [0.5821, 0.3276, 0.5912, 0.349]}, {"w": "different", "b": [0.5974, 0.3276, 0.6691, 0.349]}, {"w": "initialization", "b": [0.6753, 0.3276, 0.7812, 0.349]}, {"w": "method,", "b": [0.7874, 0.3276, 0.8571, 0.349]}, {"w": "you", "b": [0.1429, 0.3475, 0.1741, 0.3689]}, {"w": "can", "b": [0.1808, 0.3475, 0.2102, 0.3689]}, {"w": "set", "b": [0.2169, 0.3475, 0.2397, 0.3689]}, {"w": "kernel_initializer", "b": [0.2464, 0.3507, 0.4245, 0.3658]}, {"w": "(kernel", "b": [0.4312, 0.3473, 0.4884, 0.3689]}, {"w": "is", "b": [0.4951, 0.3475, 0.5083, 0.3689]}, {"w": "another", "b": [0.515, 0.3475, 0.5802, 0.3689]}, {"w": "name", "b": [0.5869, 0.3475, 0.6334, 0.3689]}, {"w": "for", "b": [0.6401, 0.3475, 0.6646, 0.3689]}, {"w": "the", "b": [0.6713, 0.3475, 0.6976, 0.3689]}, {"w": "matrix", "b": [0.7043, 0.3475, 0.7596, 0.3689]}, {"w": "of", "b": [0.7663, 0.3475, 0.7831, 0.3689]}, {"w": "connec‐", "b": [0.7898, 0.3475, 0.8571, 0.3689]}, {"w": "tion", "b": [0.1429, 0.3675, 0.1768, 0.3889]}, {"w": "weights)", "b": [0.1825, 0.3675, 0.2529, 0.3889]}, {"w": "or", "b": [0.2587, 0.3675, 0.277, 0.3889]}, {"w": "bias_initializer", "b": [0.2827, 0.3706, 0.441, 0.3857]}, {"w": "when", "b": [0.4468, 0.3675, 0.4924, 0.3889]}, {"w": "creating", "b": [0.4981, 0.3675, 0.5654, 0.3889]}, {"w": "the", "b": [0.5711, 0.3675, 0.5974, 0.3889]}, {"w": "layer.", "b": [0.6031, 0.3675, 0.6467, 0.3889]}, {"w": "We", "b": [0.6525, 0.3675, 0.6795, 0.3889]}, {"w": "will", "b": [0.6852, 0.3675, 0.7156, 0.3889]}, {"w": "discuss", "b": [0.7214, 0.3675, 0.7807, 0.3889]}, {"w": "initializ‐", "b": [0.7865, 0.3675, 0.8571, 0.3889]}, {"w": "ers", "b": [0.1429, 0.3865, 0.1671, 0.4079]}, {"w": "further", "b": [0.1718, 0.3865, 0.2308, 0.4079]}, {"w": "in", "b": [0.2356, 0.3865, 0.2525, 0.4079]}, {"w": "Chapter", "b": [0.2573, 0.3865, 0.3249, 0.4079]}, {"w": "11,", "b": [0.3296, 0.3865, 0.3543, 0.4079]}, {"w": "but", "b": [0.3591, 0.3865, 0.3871, 0.4079]}, {"w": "if", "b": [0.3918, 0.3865, 0.4035, 0.4079]}, {"w": "you", "b": [0.4083, 0.3865, 0.4395, 0.4079]}, {"w": "want", "b": [0.4443, 0.3865, 0.485, 0.4079]}, {"w": "the", "b": [0.4898, 0.3865, 0.5161, 0.4079]}, {"w": "full", "b": [0.5208, 0.3865, 0.5486, 0.4079]}, {"w": "list,", "b": [0.5533, 0.3865, 0.5829, 0.4079]}, {"w": "see", "b": [0.5877, 0.3865, 0.613, 0.4079]}, {"w": "https://keras.io/initializers/.", "b": [0.6177, 0.3863, 0.8425, 0.4079]}]}, {"id": "b_2", "type": "paragraph", "text": "The shape of the weight matrix depends on the number of inputs. This is why it is recommended to specify the input_shape when creating the first layer in a Sequential model. However, if you do not specify the input shape, it’s okay: Keras will simply wait until it knows the input shape before it actually builds the model. This will happen either when you feed it actual data (e.g., during training), or when you call its build() method. Until the model is really built, the layers will not have any weights, and you will not be able to do certain things (such as print the model summary or save the model), so if you know the input shape when creating the model, it is best to specify it.", "words": [{"w": "The", "b": [0.2714, 0.4285, 0.3014, 0.448]}, {"w": "shape", "b": [0.3072, 0.4285, 0.3505, 0.448]}, {"w": "of", "b": [0.3563, 0.4285, 0.3717, 0.448]}, {"w": "the", "b": [0.3775, 0.4285, 0.4015, 0.448]}, {"w": "weight", "b": [0.4074, 0.4285, 0.4581, 0.448]}, {"w": "matrix", "b": [0.464, 0.4285, 0.5145, 0.448]}, {"w": "depends", "b": [0.5204, 0.4285, 0.584, 0.448]}, {"w": "on", "b": [0.5899, 0.4285, 0.61, 0.448]}, {"w": "the", "b": [0.6158, 0.4285, 0.6399, 0.448]}, {"w": "number", "b": [0.6457, 0.4285, 0.7063, 0.448]}, {"w": "of", "b": [0.7121, 0.4285, 0.7275, 0.448]}, {"w": "inputs.", "b": [0.7333, 0.4285, 0.7857, 0.448]}, {"w": "This", "b": [0.2714, 0.4467, 0.3054, 0.4663]}, {"w": "is", "b": [0.3123, 0.4467, 0.3244, 0.4663]}, {"w": "why", "b": [0.3313, 0.4467, 0.3628, 0.4663]}, {"w": "it", "b": [0.3697, 0.4467, 0.3807, 0.4663]}, {"w": "is", "b": [0.3876, 0.4467, 0.3997, 0.4663]}, {"w": "recommended", "b": [0.4066, 0.4467, 0.5174, 0.4663]}, {"w": "to", "b": [0.5243, 0.4467, 0.5398, 0.4663]}, {"w": "specify", "b": [0.5467, 0.4467, 0.5997, 0.4663]}, {"w": "the", "b": [0.6066, 0.4467, 0.6307, 0.4663]}, {"w": "input_shape", "b": [0.6376, 0.4496, 0.7371, 0.4634]}, {"w": "when", "b": [0.744, 0.4467, 0.7857, 0.4663]}, {"w": "creating", "b": [0.2714, 0.4649, 0.3329, 0.4845]}, {"w": "the", "b": [0.3386, 0.4649, 0.3627, 0.4845]}, {"w": "first", "b": [0.3684, 0.4649, 0.3991, 0.4845]}, {"w": "layer", "b": [0.4048, 0.4649, 0.4416, 0.4845]}, {"w": "in", "b": [0.4473, 0.4649, 0.4628, 0.4845]}, {"w": "a", "b": [0.4686, 0.4649, 0.4769, 0.4845]}, {"w": "Sequential", "b": [0.4827, 0.4678, 0.5732, 0.4816]}, {"w": "model.", "b": [0.5789, 0.4649, 0.6315, 0.4845]}, {"w": "However,", "b": [0.6373, 0.4649, 0.7094, 0.4845]}, {"w": "if", "b": [0.7151, 0.4649, 0.7259, 0.4845]}, {"w": "you", "b": [0.7316, 0.4649, 0.7602, 0.4845]}, {"w": "do", "b": [0.7659, 0.4649, 0.7857, 0.4845]}, {"w": "not", "b": [0.2714, 0.4823, 0.2974, 0.5019]}, {"w": "specify", "b": [0.3025, 0.4823, 0.3554, 0.5019]}, {"w": "the", "b": [0.3605, 0.4823, 0.3846, 0.5019]}, {"w": "input", "b": [0.3897, 0.4823, 0.4308, 0.5019]}, {"w": "shape,", "b": [0.4359, 0.4823, 0.4835, 0.5019]}, {"w": "it’s", "b": [0.4886, 0.4823, 0.5084, 0.5019]}, {"w": "okay:", "b": [0.5135, 0.4823, 0.5544, 0.5019]}, {"w": "Keras", "b": [0.5595, 0.4823, 0.6023, 0.5019]}, {"w": "will", "b": [0.6075, 0.4823, 0.6353, 0.5019]}, {"w": "simply", "b": [0.6404, 0.4823, 0.6912, 0.5019]}, {"w": "wait", "b": [0.6964, 0.4823, 0.7287, 0.5019]}, {"w": "until", "b": [0.7338, 0.4823, 0.7697, 0.5019]}, {"w": "it", "b": [0.7748, 0.4823, 0.7857, 0.5019]}, {"w": "knows", "b": [0.2714, 0.4998, 0.321, 0.5193]}, {"w": "the", "b": [0.3258, 0.4998, 0.3499, 0.5193]}, {"w": "input", "b": [0.3547, 0.4998, 0.3958, 0.5193]}, {"w": "shape", "b": [0.4006, 0.4998, 0.4438, 0.5193]}, {"w": "before", "b": [0.4486, 0.4998, 0.4969, 0.5193]}, {"w": "it", "b": [0.5017, 0.4998, 0.5126, 0.5193]}, {"w": "actually", "b": [0.5174, 0.4998, 0.5765, 0.5193]}, {"w": "builds", "b": [0.5813, 0.4998, 0.628, 0.5193]}, {"w": "the", "b": [0.6328, 0.4998, 0.6569, 0.5193]}, {"w": "model.", "b": [0.6617, 0.4998, 0.7143, 0.5193]}, {"w": "This", "b": [0.7191, 0.4998, 0.7531, 0.5193]}, {"w": "will", "b": [0.7579, 0.4998, 0.7857, 0.5193]}, {"w": "happen", "b": [0.2714, 0.5172, 0.3281, 0.5367]}, {"w": "either", "b": [0.3343, 0.5172, 0.3786, 0.5367]}, {"w": "when", "b": [0.3848, 0.5172, 0.4265, 0.5367]}, {"w": "you", "b": [0.4327, 0.5172, 0.4613, 0.5367]}, {"w": "feed", "b": [0.4675, 0.5172, 0.4994, 0.5367]}, {"w": "it", "b": [0.5056, 0.5172, 0.5165, 0.5367]}, {"w": "actual", "b": [0.5227, 0.5172, 0.5682, 0.5367]}, {"w": "data", "b": [0.5744, 0.5172, 0.6067, 0.5367]}, {"w": "(e.g.,", "b": [0.6129, 0.5172, 0.6495, 0.5367]}, {"w": "during", "b": [0.6557, 0.5172, 0.7074, 0.5367]}, {"w": "training),", "b": [0.7136, 0.5172, 0.7857, 0.5367]}, {"w": "or", "b": [0.2714, 0.5354, 0.2882, 0.555]}, {"w": "when", "b": [0.2964, 0.5354, 0.3382, 0.555]}, {"w": "you", "b": [0.3464, 0.5354, 0.375, 0.555]}, {"w": "call", "b": [0.3833, 0.5354, 0.4093, 0.555]}, {"w": "its", "b": [0.4176, 0.5354, 0.4355, 0.555]}, {"w": "build()", "b": [0.4437, 0.5383, 0.5071, 0.5521]}, {"w": "method.", "b": [0.5153, 0.5354, 0.5791, 0.555]}, {"w": "Until", "b": [0.5874, 0.5354, 0.6263, 0.555]}, {"w": "the", "b": [0.6346, 0.5354, 0.6587, 0.555]}, {"w": "model", "b": [0.6669, 0.5354, 0.7152, 0.555]}, {"w": "is", "b": [0.7235, 0.5354, 0.7356, 0.555]}, {"w": "really", "b": [0.7438, 0.5354, 0.7857, 0.555]}, {"w": "built,", "b": [0.2714, 0.5528, 0.3113, 0.5724]}, {"w": "the", "b": [0.3166, 0.5528, 0.3406, 0.5724]}, {"w": "layers", "b": [0.3459, 0.5528, 0.3897, 0.5724]}, {"w": "will", "b": [0.3949, 0.5528, 0.4227, 0.5724]}, {"w": "not", "b": [0.428, 0.5528, 0.454, 0.5724]}, {"w": "have", "b": [0.4593, 0.5528, 0.4944, 0.5724]}, {"w": "any", "b": [0.4996, 0.5528, 0.5267, 0.5724]}, {"w": "weights,", "b": [0.532, 0.5528, 0.5941, 0.5724]}, {"w": "and", "b": [0.5994, 0.5528, 0.6283, 0.5724]}, {"w": "you", "b": [0.6335, 0.5528, 0.6621, 0.5724]}, {"w": "will", "b": [0.6674, 0.5528, 0.6952, 0.5724]}, {"w": "not", "b": [0.7005, 0.5528, 0.7264, 0.5724]}, {"w": "be", "b": [0.7317, 0.5528, 0.7495, 0.5724]}, {"w": "able", "b": [0.7548, 0.5528, 0.7857, 0.5724]}, {"w": "to", "b": [0.2714, 0.5702, 0.2869, 0.5898]}, {"w": "do", "b": [0.2924, 0.5702, 0.3121, 0.5898]}, {"w": "certain", "b": [0.3176, 0.5702, 0.3705, 0.5898]}, {"w": "things", "b": [0.3759, 0.5702, 0.4233, 0.5898]}, {"w": "(such", "b": [0.4288, 0.5702, 0.4707, 0.5898]}, {"w": "as", "b": [0.4761, 0.5702, 0.4915, 0.5898]}, {"w": "print", "b": [0.4969, 0.5702, 0.5349, 0.5898]}, {"w": "the", "b": [0.5404, 0.5702, 0.5644, 0.5898]}, {"w": "model", "b": [0.5699, 0.5702, 0.6182, 0.5898]}, {"w": "summary", "b": [0.6236, 0.5702, 0.6966, 0.5898]}, {"w": "or", "b": [0.7021, 0.5702, 0.7188, 0.5898]}, {"w": "save", "b": [0.7243, 0.5702, 0.7562, 0.5898]}, {"w": "the", "b": [0.7616, 0.5702, 0.7857, 0.5898]}, {"w": "model),", "b": [0.2714, 0.5877, 0.3306, 0.6072]}, {"w": "so", "b": [0.3354, 0.5877, 0.3521, 0.6072]}, {"w": "if", "b": [0.3569, 0.5877, 0.3676, 0.6072]}, {"w": "you", "b": [0.3724, 0.5877, 0.401, 0.6072]}, {"w": "know", "b": [0.4057, 0.5877, 0.4484, 0.6072]}, {"w": "the", "b": [0.4531, 0.5877, 0.4772, 0.6072]}, {"w": "input", "b": [0.482, 0.5877, 0.523, 0.6072]}, {"w": "shape", "b": [0.5278, 0.5877, 0.5711, 0.6072]}, {"w": "when", "b": [0.5758, 0.5877, 0.6176, 0.6072]}, {"w": "creating", "b": [0.6223, 0.5877, 0.6838, 0.6072]}, {"w": "the", "b": [0.6886, 0.5877, 0.7126, 0.6072]}, {"w": "model,", "b": [0.7174, 0.5877, 0.77, 0.6072]}, {"w": "it", "b": [0.7748, 0.5877, 0.7857, 0.6072]}, {"w": "is", "b": [0.2714, 0.6051, 0.2835, 0.6246]}, {"w": "best", "b": [0.2878, 0.6051, 0.3184, 0.6246]}, {"w": "to", "b": [0.3227, 0.6051, 0.3383, 0.6246]}, {"w": "specify", "b": [0.3426, 0.6051, 0.3955, 0.6246]}, {"w": "it.", "b": [0.3998, 0.6051, 0.4151, 0.6246]}]}, {"id": "b_3", "type": "paragraph", "text": "Compiling the Model", "words": [{"w": "Compiling", "b": [0.1429, 0.6436, 0.2197, 0.6645]}, {"w": "the", "b": [0.2234, 0.6436, 0.2489, 0.6645]}, {"w": "Model", "b": [0.2525, 0.6436, 0.2998, 0.6645]}]}, {"id": "b_4", "type": "paragraph", "text": "After a model is created, you must call its compile() method to specify the loss func‐ tion and the optimizer to use. Optionally, you can also specify a list of extra metrics to compute during training and evaluation:", "words": [{"w": "After", "b": [0.1428, 0.6711, 0.1863, 0.6925]}, {"w": "a", "b": [0.1916, 0.6711, 0.2007, 0.6925]}, {"w": "model", "b": [0.2059, 0.6711, 0.2587, 0.6925]}, {"w": "is", "b": [0.2639, 0.6711, 0.2772, 0.6925]}, {"w": "created,", "b": [0.2824, 0.6711, 0.3475, 0.6925]}, {"w": "you", "b": [0.3527, 0.6711, 0.3839, 0.6925]}, {"w": "must", "b": [0.3891, 0.6711, 0.4309, 0.6925]}, {"w": "call", "b": [0.4361, 0.6711, 0.4646, 0.6925]}, {"w": "its", "b": [0.4698, 0.6711, 0.4894, 0.6925]}, {"w": "compile()", "b": [0.4946, 0.6743, 0.5836, 0.6894]}, {"w": "method", "b": [0.5888, 0.6711, 0.6539, 0.6925]}, {"w": "to", "b": [0.6591, 0.6711, 0.676, 0.6925]}, {"w": "specify", "b": [0.6812, 0.6711, 0.7391, 0.6925]}, {"w": "the", "b": [0.7443, 0.6711, 0.7707, 0.6925]}, {"w": "loss", "b": [0.7759, 0.6711, 0.8071, 0.6925]}, {"w": "func‐", "b": [0.8123, 0.6711, 0.8571, 0.6925]}, {"w": "tion", "b": [0.1429, 0.6902, 0.1768, 0.7116]}, {"w": "and", "b": [0.1816, 0.6902, 0.2131, 0.7116]}, {"w": "the", "b": [0.2178, 0.6902, 0.2442, 0.7116]}, {"w": "optimizer", "b": [0.2489, 0.6902, 0.3303, 0.7116]}, {"w": "to", "b": [0.3351, 0.6902, 0.3521, 0.7116]}, {"w": "use.", "b": [0.3568, 0.6902, 0.3891, 0.7116]}, {"w": "Optionally,", "b": [0.3938, 0.6902, 0.4867, 0.7116]}, {"w": "you", "b": [0.4915, 0.6902, 0.5227, 0.7116]}, {"w": "can", "b": [0.5274, 0.6902, 0.5568, 0.7116]}, {"w": "also", "b": [0.5615, 0.6902, 0.5942, 0.7116]}, {"w": "specify", "b": [0.5989, 0.6902, 0.6568, 0.7116]}, {"w": "a", "b": [0.6616, 0.6902, 0.6707, 0.7116]}, {"w": "list", "b": [0.6754, 0.6902, 0.7003, 0.7116]}, {"w": "of", "b": [0.705, 0.6902, 0.7218, 0.7116]}, {"w": "extra", "b": [0.7266, 0.6902, 0.7685, 0.7116]}, {"w": "metrics", "b": [0.7732, 0.6902, 0.8352, 0.7116]}, {"w": "to", "b": [0.84, 0.6902, 0.8569, 0.7116]}, {"w": "compute", "b": [0.1429, 0.7092, 0.2162, 0.7306]}, {"w": "during", "b": [0.2209, 0.7092, 0.2774, 0.7306]}, {"w": "training", "b": [0.2821, 0.7092, 0.3491, 0.7306]}, {"w": "and", "b": [0.3538, 0.7092, 0.3853, 0.7306]}, {"w": "evaluation:", "b": [0.3901, 0.7092, 0.4815, 0.7306]}]}, {"id": "b_5", "type": "paragraph", "text": "model.compile(loss=\"sparse_categorical_crossentropy\", optimizer=\"sgd\", metrics=[\"accuracy\"])", "words": [{"w": "model.compile(loss=\"sparse_categorical_crossentropy\",", "b": [0.1766, 0.7412, 0.6235, 0.754]}, {"w": "optimizer=\"sgd\",", "b": [0.2946, 0.7566, 0.4296, 0.7695]}, {"w": "metrics=[\"accuracy\"])", "b": [0.2946, 0.772, 0.4717, 0.7849]}]}, {"id": "b_6", "type": "paragraph", "text": "298 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "298", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 325, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Using loss=\"sparse_categorical_crossentropy\" is equivalent to loss=keras.losses.sparse_categorical_crossentropy. Simi‐ larly, optimizer=\"sgd\" is equivalent to optimizer=keras.optimiz ers.SGD() and metrics=[\"accuracy\"] is equivalent to metrics=[keras.metrics.sparse_categorical_accuracy] (when using this loss). We will use many other losses, optimizers and met‐ rics in this book, but for the full lists see https://keras.io/losses/, https://keras.io/optimizers/ and https://keras.io/metrics/.", "words": [{"w": "Using", "b": [0.2714, 0.0801, 0.3158, 0.0997]}, {"w": "loss=\"sparse_categorical_crossentropy\"", "b": [0.3207, 0.083, 0.6645, 0.0968]}, {"w": "is", "b": [0.6694, 0.0801, 0.6815, 0.0997]}, {"w": "equivalent", "b": [0.6863, 0.0801, 0.7653, 0.0997]}, {"w": "to", "b": [0.7702, 0.0801, 0.7857, 0.0997]}, {"w": "loss=keras.losses.sparse_categorical_crossentropy.", "b": [0.2714, 0.0983, 0.7191, 0.1179]}, {"w": "Simi‐", "b": [0.7441, 0.0983, 0.7857, 0.1179]}, {"w": "larly,", "b": [0.2714, 0.1166, 0.3082, 0.1361]}, {"w": "optimizer=\"sgd\"", "b": [0.3134, 0.1195, 0.4491, 0.1333]}, {"w": "is", "b": [0.4544, 0.1166, 0.4665, 0.1361]}, {"w": "equivalent", "b": [0.4717, 0.1166, 0.5507, 0.1361]}, {"w": "to", "b": [0.556, 0.1166, 0.5715, 0.1361]}, {"w": "optimizer=keras.optimiz", "b": [0.5767, 0.1195, 0.7848, 0.1333]}, {"w": "ers.SGD()", "b": [0.2714, 0.1377, 0.3528, 0.1515]}, {"w": "and", "b": [0.3761, 0.1348, 0.405, 0.1544]}, {"w": "metrics=[\"accuracy\"]", "b": [0.4283, 0.1377, 0.6092, 0.1515]}, {"w": "is", "b": [0.6325, 0.1348, 0.6446, 0.1544]}, {"w": "equivalent", "b": [0.6679, 0.1348, 0.7469, 0.1544]}, {"w": "to", "b": [0.7702, 0.1348, 0.7857, 0.1544]}, {"w": "metrics=[keras.metrics.sparse_categorical_accuracy]", "b": [0.2714, 0.156, 0.7328, 0.1697]}, {"w": "(when", "b": [0.7374, 0.153, 0.7857, 0.1726]}, {"w": "using", "b": [0.2714, 0.1705, 0.3129, 0.19]}, {"w": "this", "b": [0.3174, 0.1705, 0.3455, 0.19]}, {"w": "loss).", "b": [0.35, 0.1705, 0.3895, 0.19]}, {"w": "We", "b": [0.3939, 0.1705, 0.4187, 0.19]}, {"w": "will", "b": [0.4232, 0.1705, 0.451, 0.19]}, {"w": "use", "b": [0.4555, 0.1705, 0.4807, 0.19]}, {"w": "many", "b": [0.4852, 0.1705, 0.5278, 0.19]}, {"w": "other", "b": [0.5323, 0.1705, 0.5732, 0.19]}, {"w": "losses,", "b": [0.5777, 0.1705, 0.6256, 0.19]}, {"w": "optimizers", "b": [0.6301, 0.1705, 0.7116, 0.19]}, {"w": "and", "b": [0.7161, 0.1705, 0.7449, 0.19]}, {"w": "met‐", "b": [0.7494, 0.1705, 0.7857, 0.19]}, {"w": "rics", "b": [0.2714, 0.1879, 0.2986, 0.2074]}, {"w": "in", "b": [0.3069, 0.1879, 0.3224, 0.2074]}, {"w": "this", "b": [0.3307, 0.1879, 0.3588, 0.2074]}, {"w": "book,", "b": [0.3671, 0.1879, 0.41, 0.2074]}, {"w": "but", "b": [0.4183, 0.1879, 0.4439, 0.2074]}, {"w": "for", "b": [0.4521, 0.1879, 0.4746, 0.2074]}, {"w": "the", "b": [0.4828, 0.1879, 0.5069, 0.2074]}, {"w": "full", "b": [0.5152, 0.1879, 0.5406, 0.2074]}, {"w": "lists", "b": [0.5489, 0.1879, 0.5786, 0.2074]}, {"w": "see", "b": [0.5869, 0.1879, 0.6101, 0.2074]}, {"w": "https://keras.io/losses/,", "b": [0.6183, 0.1877, 0.7857, 0.2074]}, {"w": "https://keras.io/optimizers/", "b": [0.2714, 0.2051, 0.4716, 0.2249]}, {"w": "and", "b": [0.4759, 0.2053, 0.5048, 0.2249]}, {"w": "https://keras.io/metrics/.", "b": [0.5091, 0.2051, 0.6903, 0.2249]}]}, {"id": "b_1", "type": "paragraph", "text": "This requires some explanation. First, we use the \"sparse_categorical_crossen tropy\" loss because we have sparse labels (i.e., for each instance there is just a target class index, from 0 to 9 in this case), and the classes are exclusive. If instead we had one target probability per class for each instance (such as one-hot vectors, e.g. [0., 0., 0., 1., 0., 0., 0., 0., 0., 0.] to represent class 3), then we would need to use the \"categorical_crossentropy\" loss instead. If we were doing binary classi‐ fication (with one or more binary labels), then we would use the \"sigmoid\" (i.e., logistic) activation function in the output layer instead of the \"softmax\" activation function, and we would use the \"binary_crossentropy\" loss.", "words": [{"w": "This", "b": [0.1429, 0.2461, 0.1801, 0.2675]}, {"w": "requires", "b": [0.1889, 0.2461, 0.257, 0.2675]}, {"w": "some", "b": [0.2658, 0.2461, 0.31, 0.2675]}, {"w": "explanation.", "b": [0.3189, 0.2461, 0.4217, 0.2675]}, {"w": "First,", "b": [0.4306, 0.2461, 0.4737, 0.2675]}, {"w": "we", "b": [0.4825, 0.2461, 0.5056, 0.2675]}, {"w": "use", "b": [0.5145, 0.2461, 0.542, 0.2675]}, {"w": "the", "b": [0.5509, 0.2461, 0.5772, 0.2675]}, {"w": "\"sparse_categorical_crossen", "b": [0.586, 0.2492, 0.8532, 0.2643]}, {"w": "tropy\"", "b": [0.1429, 0.2692, 0.2022, 0.2843]}, {"w": "loss", "b": [0.2081, 0.266, 0.2393, 0.2874]}, {"w": "because", "b": [0.2451, 0.266, 0.3096, 0.2874]}, {"w": "we", "b": [0.3155, 0.266, 0.3386, 0.2874]}, {"w": "have", "b": [0.3444, 0.266, 0.3828, 0.2874]}, {"w": "sparse", "b": [0.3887, 0.266, 0.4406, 0.2874]}, {"w": "labels", "b": [0.4464, 0.266, 0.4932, 0.2874]}, {"w": "(i.e.,", "b": [0.499, 0.266, 0.5349, 0.2874]}, {"w": "for", "b": [0.5408, 0.266, 0.5653, 0.2874]}, {"w": "each", "b": [0.5711, 0.266, 0.6091, 0.2874]}, {"w": "instance", "b": [0.6149, 0.266, 0.6841, 0.2874]}, {"w": "there", "b": [0.6899, 0.266, 0.7328, 0.2874]}, {"w": "is", "b": [0.7387, 0.266, 0.7519, 0.2874]}, {"w": "just", "b": [0.7577, 0.266, 0.7881, 0.2874]}, {"w": "a", "b": [0.794, 0.266, 0.8031, 0.2874]}, {"w": "target", "b": [0.809, 0.266, 0.8571, 0.2874]}, {"w": "class", "b": [0.1428, 0.285, 0.1814, 0.3065]}, {"w": "index,", "b": [0.1876, 0.285, 0.239, 0.3065]}, {"w": "from", "b": [0.2452, 0.285, 0.2867, 0.3065]}, {"w": "0", "b": [0.2929, 0.285, 0.3029, 0.3065]}, {"w": "to", "b": [0.3091, 0.285, 0.3261, 0.3065]}, {"w": "9", "b": [0.3323, 0.285, 0.3423, 0.3065]}, {"w": "in", "b": [0.3484, 0.285, 0.3654, 0.3065]}, {"w": "this", "b": [0.3716, 0.285, 0.4023, 0.3065]}, {"w": "case),", "b": [0.4085, 0.285, 0.4549, 0.3065]}, {"w": "and", "b": [0.4611, 0.285, 0.4926, 0.3065]}, {"w": "the", "b": [0.4988, 0.285, 0.5252, 0.3065]}, {"w": "classes", "b": [0.5313, 0.285, 0.5864, 0.3065]}, {"w": "are", "b": [0.5925, 0.285, 0.6183, 0.3065]}, {"w": "exclusive.", "b": [0.6244, 0.285, 0.7048, 0.3065]}, {"w": "If", "b": [0.7109, 0.285, 0.7242, 0.3065]}, {"w": "instead", "b": [0.7304, 0.285, 0.7904, 0.3065]}, {"w": "we", "b": [0.7966, 0.285, 0.8197, 0.3065]}, {"w": "had", "b": [0.8259, 0.285, 0.8571, 0.3065]}, {"w": "one", "b": [0.1429, 0.305, 0.1737, 0.3264]}, {"w": "target", "b": [0.1802, 0.305, 0.2284, 0.3264]}, {"w": "probability", "b": [0.2349, 0.305, 0.3269, 0.3264]}, {"w": "per", "b": [0.3334, 0.305, 0.3609, 0.3264]}, {"w": "class", "b": [0.3674, 0.305, 0.4059, 0.3264]}, {"w": "for", "b": [0.4124, 0.305, 0.4369, 0.3264]}, {"w": "each", "b": [0.4434, 0.305, 0.4813, 0.3264]}, {"w": "instance", "b": [0.4878, 0.305, 0.557, 0.3264]}, {"w": "(such", "b": [0.5635, 0.305, 0.6094, 0.3264]}, {"w": "as", "b": [0.6159, 0.305, 0.6327, 0.3264]}, {"w": "one-hot", "b": [0.6392, 0.305, 0.7056, 0.3264]}, {"w": "vectors,", "b": [0.712, 0.305, 0.7765, 0.3264]}, {"w": "e.g.", "b": [0.783, 0.305, 0.8111, 0.3264]}, {"w": "[0.,", "b": [0.8176, 0.3082, 0.8571, 0.3233]}, {"w": "0.,", "b": [0.1428, 0.3281, 0.1725, 0.3432]}, {"w": "0.,", "b": [0.1837, 0.3281, 0.2134, 0.3432]}, {"w": "1.,", "b": [0.2246, 0.3281, 0.2543, 0.3432]}, {"w": "0.,", "b": [0.2655, 0.3281, 0.2952, 0.3432]}, {"w": "0.,", "b": [0.3064, 0.3281, 0.3361, 0.3432]}, {"w": "0.,", "b": [0.3473, 0.3281, 0.377, 0.3432]}, {"w": "0.,", "b": [0.3882, 0.3281, 0.4179, 0.3432]}, {"w": "0.,", "b": [0.4291, 0.3281, 0.4588, 0.3432]}, {"w": "0.]", "b": [0.47, 0.3281, 0.4997, 0.3432]}, {"w": "to", "b": [0.5058, 0.3249, 0.5228, 0.3463]}, {"w": "represent", "b": [0.5289, 0.3249, 0.6068, 0.3463]}, {"w": "class", "b": [0.6129, 0.3249, 0.6514, 0.3463]}, {"w": "3),", "b": [0.6576, 0.3249, 0.6795, 0.3463]}, {"w": "then", "b": [0.6856, 0.3249, 0.7234, 0.3463]}, {"w": "we", "b": [0.7295, 0.3249, 0.7526, 0.3463]}, {"w": "would", "b": [0.7587, 0.3249, 0.8109, 0.3463]}, {"w": "need", "b": [0.817, 0.3249, 0.8571, 0.3463]}, {"w": "to", "b": [0.1429, 0.3449, 0.1598, 0.3663]}, {"w": "use", "b": [0.1653, 0.3449, 0.1928, 0.3663]}, {"w": "the", "b": [0.1982, 0.3449, 0.2246, 0.3663]}, {"w": "\"categorical_crossentropy\"", "b": [0.23, 0.3481, 0.4873, 0.3631]}, {"w": "loss", "b": [0.4927, 0.3449, 0.5239, 0.3663]}, {"w": "instead.", "b": [0.5293, 0.3449, 0.594, 0.3663]}, {"w": "If", "b": [0.5995, 0.3449, 0.6127, 0.3663]}, {"w": "we", "b": [0.6182, 0.3449, 0.6413, 0.3663]}, {"w": "were", "b": [0.6467, 0.3449, 0.6864, 0.3663]}, {"w": "doing", "b": [0.6918, 0.3449, 0.7402, 0.3663]}, {"w": "binary", "b": [0.7456, 0.3449, 0.8002, 0.3663]}, {"w": "classi‐", "b": [0.8056, 0.3449, 0.8571, 0.3663]}, {"w": "fication", "b": [0.1429, 0.3648, 0.2061, 0.3862]}, {"w": "(with", "b": [0.2144, 0.3648, 0.2589, 0.3862]}, {"w": "one", "b": [0.2672, 0.3648, 0.2981, 0.3862]}, {"w": "or", "b": [0.3064, 0.3648, 0.3247, 0.3862]}, {"w": "more", "b": [0.333, 0.3648, 0.3773, 0.3862]}, {"w": "binary", "b": [0.3856, 0.3648, 0.4402, 0.3862]}, {"w": "labels),", "b": [0.4485, 0.3648, 0.5072, 0.3862]}, {"w": "then", "b": [0.5155, 0.3648, 0.5532, 0.3862]}, {"w": "we", "b": [0.5615, 0.3648, 0.5846, 0.3862]}, {"w": "would", "b": [0.5929, 0.3648, 0.6451, 0.3862]}, {"w": "use", "b": [0.6534, 0.3648, 0.681, 0.3862]}, {"w": "the", "b": [0.6893, 0.3648, 0.7156, 0.3862]}, {"w": "\"sigmoid\"", "b": [0.7239, 0.368, 0.813, 0.3831]}, {"w": "(i.e.,", "b": [0.8212, 0.3648, 0.8571, 0.3862]}, {"w": "logistic)", "b": [0.1428, 0.3848, 0.2097, 0.4062]}, {"w": "activation", "b": [0.2169, 0.3848, 0.2992, 0.4062]}, {"w": "function", "b": [0.3064, 0.3848, 0.3778, 0.4062]}, {"w": "in", "b": [0.385, 0.3848, 0.402, 0.4062]}, {"w": "the", "b": [0.4092, 0.3848, 0.4356, 0.4062]}, {"w": "output", "b": [0.4428, 0.3848, 0.4992, 0.4062]}, {"w": "layer", "b": [0.5064, 0.3848, 0.5466, 0.4062]}, {"w": "instead", "b": [0.5538, 0.3848, 0.6138, 0.4062]}, {"w": "of", "b": [0.621, 0.3848, 0.6378, 0.4062]}, {"w": "the", "b": [0.645, 0.3848, 0.6714, 0.4062]}, {"w": "\"softmax\"", "b": [0.6786, 0.388, 0.7677, 0.403]}, {"w": "activation", "b": [0.7749, 0.3848, 0.8571, 0.4062]}, {"w": "function,", "b": [0.1429, 0.4047, 0.219, 0.4261]}, {"w": "and", "b": [0.2237, 0.4047, 0.2553, 0.4261]}, {"w": "we", "b": [0.26, 0.4047, 0.2831, 0.4261]}, {"w": "would", "b": [0.2879, 0.4047, 0.3401, 0.4261]}, {"w": "use", "b": [0.3448, 0.4047, 0.3724, 0.4261]}, {"w": "the", "b": [0.3771, 0.4047, 0.4034, 0.4261]}, {"w": "\"binary_crossentropy\"", "b": [0.4082, 0.4079, 0.616, 0.423]}, {"w": "loss.", "b": [0.6207, 0.4047, 0.6567, 0.4261]}]}, {"id": "b_2", "type": "paragraph", "text": "If you want to convert sparse labels (i.e., class indices) to one-hot vector labels, you can use the keras.utils.to_categorical() function. To go the other way round, you can just use the np.arg max() function with axis=1.", "words": [{"w": "If", "b": [0.2714, 0.4467, 0.2835, 0.4662]}, {"w": "you", "b": [0.2898, 0.4467, 0.3183, 0.4662]}, {"w": "want", "b": [0.3245, 0.4467, 0.3618, 0.4662]}, {"w": "to", "b": [0.368, 0.4467, 0.3836, 0.4662]}, {"w": "convert", "b": [0.3898, 0.4467, 0.4473, 0.4662]}, {"w": "sparse", "b": [0.4535, 0.4467, 0.501, 0.4662]}, {"w": "labels", "b": [0.5072, 0.4467, 0.55, 0.4662]}, {"w": "(i.e.,", "b": [0.5562, 0.4467, 0.589, 0.4662]}, {"w": "class", "b": [0.5952, 0.4467, 0.6304, 0.4662]}, {"w": "indices)", "b": [0.6366, 0.4467, 0.6971, 0.4662]}, {"w": "to", "b": [0.7033, 0.4467, 0.7188, 0.4662]}, {"w": "one-hot", "b": [0.725, 0.4467, 0.7857, 0.4662]}, {"w": "vector", "b": [0.2714, 0.4649, 0.319, 0.4845]}, {"w": "labels,", "b": [0.3292, 0.4649, 0.3763, 0.4845]}, {"w": "you", "b": [0.3866, 0.4649, 0.4152, 0.4845]}, {"w": "can", "b": [0.4254, 0.4649, 0.4523, 0.4845]}, {"w": "use", "b": [0.4626, 0.4649, 0.4878, 0.4845]}, {"w": "the", "b": [0.498, 0.4649, 0.5221, 0.4845]}, {"w": "keras.utils.to_categorical()", "b": [0.5324, 0.4678, 0.7857, 0.4816]}, {"w": "function.", "b": [0.2714, 0.4831, 0.341, 0.5027]}, {"w": "To", "b": [0.347, 0.4831, 0.3666, 0.5027]}, {"w": "go", "b": [0.3726, 0.4831, 0.3912, 0.5027]}, {"w": "the", "b": [0.3972, 0.4831, 0.4212, 0.5027]}, {"w": "other", "b": [0.4272, 0.4831, 0.4681, 0.5027]}, {"w": "way", "b": [0.474, 0.4831, 0.5038, 0.5027]}, {"w": "round,", "b": [0.5098, 0.4831, 0.5615, 0.5027]}, {"w": "you", "b": [0.5675, 0.4831, 0.5961, 0.5027]}, {"w": "can", "b": [0.6021, 0.4831, 0.6289, 0.5027]}, {"w": "just", "b": [0.6349, 0.4831, 0.6627, 0.5027]}, {"w": "use", "b": [0.6686, 0.4831, 0.6938, 0.5027]}, {"w": "the", "b": [0.6998, 0.4831, 0.7239, 0.5027]}, {"w": "np.arg", "b": [0.7299, 0.486, 0.7842, 0.4998]}, {"w": "max()", "b": [0.2714, 0.5043, 0.3166, 0.5181]}, {"w": "function", "b": [0.321, 0.5014, 0.3862, 0.5209]}, {"w": "with", "b": [0.3906, 0.5014, 0.4247, 0.5209]}, {"w": "axis=1.", "b": [0.429, 0.5014, 0.4877, 0.5209]}]}, {"id": "b_3", "type": "paragraph", "text": "Secondly, regarding the optimizer, \"sgd\" simply means that we will train the model using simple Stochastic Gradient Descent. In other words, Keras will perform the backpropagation algorithm described earlier (i.e., reverse-mode autodiff + Gradient Descent). We will discuss more efficient optimizers in Chapter 11 (they improve the Gradient Descent part, not the autodiff).", "words": [{"w": "Secondly,", "b": [0.1429, 0.5462, 0.2215, 0.5676]}, {"w": "regarding", "b": [0.2281, 0.5462, 0.309, 0.5676]}, {"w": "the", "b": [0.3156, 0.5462, 0.3419, 0.5676]}, {"w": "optimizer,", "b": [0.3485, 0.5462, 0.4334, 0.5676]}, {"w": "\"sgd\"", "b": [0.4399, 0.5494, 0.4894, 0.5645]}, {"w": "simply", "b": [0.496, 0.5462, 0.5516, 0.5676]}, {"w": "means", "b": [0.5582, 0.5462, 0.6123, 0.5676]}, {"w": "that", "b": [0.6189, 0.5462, 0.6514, 0.5676]}, {"w": "we", "b": [0.658, 0.5462, 0.6811, 0.5676]}, {"w": "will", "b": [0.6877, 0.5462, 0.7181, 0.5676]}, {"w": "train", "b": [0.7247, 0.5462, 0.7649, 0.5676]}, {"w": "the", "b": [0.7714, 0.5462, 0.7978, 0.5676]}, {"w": "model", "b": [0.8043, 0.5462, 0.8572, 0.5676]}, {"w": "using", "b": [0.1429, 0.5652, 0.1883, 0.5867]}, {"w": "simple", "b": [0.1966, 0.5652, 0.2516, 0.5867]}, {"w": "Stochastic", "b": [0.2599, 0.5652, 0.3442, 0.5867]}, {"w": "Gradient", "b": [0.3525, 0.5652, 0.4271, 0.5867]}, {"w": "Descent.", "b": [0.4354, 0.5652, 0.507, 0.5867]}, {"w": "In", "b": [0.5153, 0.5652, 0.5338, 0.5867]}, {"w": "other", "b": [0.5421, 0.5652, 0.5868, 0.5867]}, {"w": "words,", "b": [0.5951, 0.5652, 0.6512, 0.5867]}, {"w": "Keras", "b": [0.6595, 0.5652, 0.7064, 0.5867]}, {"w": "will", "b": [0.7147, 0.5652, 0.7451, 0.5867]}, {"w": "perform", "b": [0.7534, 0.5652, 0.8225, 0.5867]}, {"w": "the", "b": [0.8308, 0.5652, 0.8571, 0.5867]}, {"w": "backpropagation", "b": [0.1429, 0.5843, 0.2835, 0.6057]}, {"w": "algorithm", "b": [0.2904, 0.5843, 0.3731, 0.6057]}, {"w": "described", "b": [0.38, 0.5843, 0.46, 0.6057]}, {"w": "earlier", "b": [0.4669, 0.5843, 0.5201, 0.6057]}, {"w": "(i.e.,", "b": [0.527, 0.5843, 0.5629, 0.6057]}, {"w": "reverse-mode", "b": [0.5698, 0.5843, 0.6841, 0.6057]}, {"w": "autodiff", "b": [0.691, 0.5843, 0.7567, 0.6057]}, {"w": "+", "b": [0.7636, 0.5843, 0.7757, 0.6057]}, {"w": "Gradient", "b": [0.7826, 0.5843, 0.8571, 0.6057]}, {"w": "Descent).", "b": [0.1428, 0.6033, 0.2216, 0.6248]}, {"w": "We", "b": [0.2278, 0.6033, 0.2549, 0.6248]}, {"w": "will", "b": [0.261, 0.6033, 0.2914, 0.6248]}, {"w": "discuss", "b": [0.2976, 0.6033, 0.357, 0.6248]}, {"w": "more", "b": [0.3631, 0.6033, 0.4074, 0.6248]}, {"w": "efficient", "b": [0.4135, 0.6033, 0.4809, 0.6248]}, {"w": "optimizers", "b": [0.4871, 0.6033, 0.5762, 0.6248]}, {"w": "in", "b": [0.5823, 0.6033, 0.5993, 0.6248]}, {"w": "Chapter", "b": [0.6055, 0.6033, 0.6731, 0.6248]}, {"w": "11", "b": [0.6792, 0.6033, 0.6992, 0.6248]}, {"w": "(they", "b": [0.7054, 0.6033, 0.7485, 0.6248]}, {"w": "improve", "b": [0.7546, 0.6033, 0.8246, 0.6248]}, {"w": "the", "b": [0.8308, 0.6033, 0.8571, 0.6248]}, {"w": "Gradient", "b": [0.1429, 0.6224, 0.2174, 0.6438]}, {"w": "Descent", "b": [0.2222, 0.6224, 0.289, 0.6438]}, {"w": "part,", "b": [0.2937, 0.6224, 0.3326, 0.6438]}, {"w": "not", "b": [0.3373, 0.6224, 0.3657, 0.6438]}, {"w": "the", "b": [0.3704, 0.6224, 0.3968, 0.6438]}, {"w": "autodiff).", "b": [0.4015, 0.6224, 0.4808, 0.6438]}]}, {"id": "b_4", "type": "paragraph", "text": "Finally, since this is a classifier, it’s useful to measure its \"accuracy\" during training and evaluation.", "words": [{"w": "Finally,", "b": [0.1429, 0.6514, 0.2033, 0.6728]}, {"w": "since", "b": [0.2096, 0.6514, 0.2519, 0.6728]}, {"w": "this", "b": [0.2582, 0.6514, 0.2889, 0.6728]}, {"w": "is", "b": [0.2951, 0.6514, 0.3084, 0.6728]}, {"w": "a", "b": [0.3146, 0.6514, 0.3238, 0.6728]}, {"w": "classifier,", "b": [0.3301, 0.6514, 0.4059, 0.6728]}, {"w": "it’s", "b": [0.4122, 0.6514, 0.4339, 0.6728]}, {"w": "useful", "b": [0.4401, 0.6514, 0.4902, 0.6728]}, {"w": "to", "b": [0.4965, 0.6514, 0.5135, 0.6728]}, {"w": "measure", "b": [0.5197, 0.6514, 0.5901, 0.6728]}, {"w": "its", "b": [0.5963, 0.6514, 0.6159, 0.6728]}, {"w": "\"accuracy\"", "b": [0.6222, 0.6546, 0.7212, 0.6697]}, {"w": "during", "b": [0.7274, 0.6514, 0.7839, 0.6728]}, {"w": "training", "b": [0.7902, 0.6514, 0.8571, 0.6728]}, {"w": "and", "b": [0.1429, 0.6705, 0.1744, 0.6919]}, {"w": "evaluation.", "b": [0.1791, 0.6705, 0.2706, 0.6919]}]}, {"id": "b_5", "type": "paragraph", "text": "Training and Evaluating the Model", "words": [{"w": "Training", "b": [0.1429, 0.7078, 0.2059, 0.7287]}, {"w": "and", "b": [0.2095, 0.7078, 0.2383, 0.7287]}, {"w": "Evaluating", "b": [0.2419, 0.7078, 0.3229, 0.7287]}, {"w": "the", "b": [0.3265, 0.7078, 0.3521, 0.7287]}, {"w": "Model", "b": [0.3557, 0.7078, 0.4029, 0.7287]}]}, {"id": "b_6", "type": "paragraph", "text": "Now the model is ready to be trained. For this we simply need to call its fit() method. We pass it the input features (X_train) and the target classes (y_train), as well as the number of epochs to train (or else it would default to just 1, which would definitely not be enough to converge to a good solution). We also pass a validation set (this is optional): Keras will measure the loss and the extra metrics on this set at the end of each epoch, which is very useful to see how well the model really performs: if the performance on the training set is much better than on the validation set, your", "words": [{"w": "Now", "b": [0.1429, 0.7353, 0.1827, 0.7567]}, {"w": "the", "b": [0.1916, 0.7353, 0.2179, 0.7567]}, {"w": "model", "b": [0.2267, 0.7353, 0.2795, 0.7567]}, {"w": "is", "b": [0.2884, 0.7353, 0.3016, 0.7567]}, {"w": "ready", "b": [0.3105, 0.7353, 0.3567, 0.7567]}, {"w": "to", "b": [0.3656, 0.7353, 0.3826, 0.7567]}, {"w": "be", "b": [0.3914, 0.7353, 0.4108, 0.7567]}, {"w": "trained.", "b": [0.4197, 0.7353, 0.4845, 0.7567]}, {"w": "For", "b": [0.4933, 0.7353, 0.5223, 0.7567]}, {"w": "this", "b": [0.5311, 0.7353, 0.5619, 0.7567]}, {"w": "we", "b": [0.5707, 0.7353, 0.5938, 0.7567]}, {"w": "simply", "b": [0.6027, 0.7353, 0.6583, 0.7567]}, {"w": "need", "b": [0.6671, 0.7353, 0.7073, 0.7567]}, {"w": "to", "b": [0.7161, 0.7353, 0.7331, 0.7567]}, {"w": "call", "b": [0.7419, 0.7353, 0.7704, 0.7567]}, {"w": "its", "b": [0.7792, 0.7353, 0.7988, 0.7567]}, {"w": "fit()", "b": [0.8077, 0.7385, 0.8571, 0.7535]}, {"w": "method.", "b": [0.1429, 0.7552, 0.2126, 0.7766]}, {"w": "We", "b": [0.2191, 0.7552, 0.2461, 0.7766]}, {"w": "pass", "b": [0.2525, 0.7552, 0.2879, 0.7766]}, {"w": "it", "b": [0.2943, 0.7552, 0.3063, 0.7766]}, {"w": "the", "b": [0.3127, 0.7552, 0.339, 0.7766]}, {"w": "input", "b": [0.3454, 0.7552, 0.3903, 0.7766]}, {"w": "features", "b": [0.3968, 0.7552, 0.4622, 0.7766]}, {"w": "(X_train)", "b": [0.4686, 0.7552, 0.5523, 0.7766]}, {"w": "and", "b": [0.5587, 0.7552, 0.5903, 0.7766]}, {"w": "the", "b": [0.5967, 0.7552, 0.623, 0.7766]}, {"w": "target", "b": [0.6294, 0.7552, 0.6776, 0.7766]}, {"w": "classes", "b": [0.6841, 0.7552, 0.7391, 0.7766]}, {"w": "(y_train),", "b": [0.7455, 0.7552, 0.8339, 0.7766]}, {"w": "as", "b": [0.8404, 0.7552, 0.8571, 0.7766]}, {"w": "well", "b": [0.1429, 0.7743, 0.1765, 0.7957]}, {"w": "as", "b": [0.1822, 0.7743, 0.199, 0.7957]}, {"w": "the", "b": [0.2046, 0.7743, 0.231, 0.7957]}, {"w": "number", "b": [0.2366, 0.7743, 0.3029, 0.7957]}, {"w": "of", "b": [0.3086, 0.7743, 0.3254, 0.7957]}, {"w": "epochs", "b": [0.331, 0.7743, 0.389, 0.7957]}, {"w": "to", "b": [0.3946, 0.7743, 0.4116, 0.7957]}, {"w": "train", "b": [0.4173, 0.7743, 0.4575, 0.7957]}, {"w": "(or", "b": [0.4631, 0.7743, 0.4887, 0.7957]}, {"w": "else", "b": [0.4944, 0.7743, 0.525, 0.7957]}, {"w": "it", "b": [0.5306, 0.7743, 0.5426, 0.7957]}, {"w": "would", "b": [0.5482, 0.7743, 0.6005, 0.7957]}, {"w": "default", "b": [0.6061, 0.7743, 0.6636, 0.7957]}, {"w": "to", "b": [0.6692, 0.7743, 0.6862, 0.7957]}, {"w": "just", "b": [0.6919, 0.7743, 0.7223, 0.7957]}, {"w": "1,", "b": [0.7279, 0.7743, 0.7427, 0.7957]}, {"w": "which", "b": [0.7483, 0.7743, 0.7993, 0.7957]}, {"w": "would", "b": [0.8049, 0.7743, 0.8571, 0.7957]}, {"w": "definitely", "b": [0.1428, 0.7933, 0.2215, 0.8147]}, {"w": "not", "b": [0.2264, 0.7933, 0.2548, 0.8147]}, {"w": "be", "b": [0.2597, 0.7933, 0.2791, 0.8147]}, {"w": "enough", "b": [0.284, 0.7933, 0.3469, 0.8147]}, {"w": "to", "b": [0.3518, 0.7933, 0.3687, 0.8147]}, {"w": "converge", "b": [0.3737, 0.7933, 0.4489, 0.8147]}, {"w": "to", "b": [0.4538, 0.7933, 0.4708, 0.8147]}, {"w": "a", "b": [0.4757, 0.7933, 0.4848, 0.8147]}, {"w": "good", "b": [0.4897, 0.7933, 0.5317, 0.8147]}, {"w": "solution).", "b": [0.5367, 0.7933, 0.6172, 0.8147]}, {"w": "We", "b": [0.6221, 0.7933, 0.6492, 0.8147]}, {"w": "also", "b": [0.6541, 0.7933, 0.6868, 0.8147]}, {"w": "pass", "b": [0.6917, 0.7933, 0.727, 0.8147]}, {"w": "a", "b": [0.7319, 0.7933, 0.7411, 0.8147]}, {"w": "validation", "b": [0.746, 0.7933, 0.8294, 0.8147]}, {"w": "set", "b": [0.8343, 0.7933, 0.8571, 0.8147]}, {"w": "(this", "b": [0.1429, 0.8124, 0.1808, 0.8338]}, {"w": "is", "b": [0.1869, 0.8124, 0.2001, 0.8338]}, {"w": "optional):", "b": [0.2062, 0.8124, 0.288, 0.8338]}, {"w": "Keras", "b": [0.2941, 0.8124, 0.341, 0.8338]}, {"w": "will", "b": [0.3471, 0.8124, 0.3775, 0.8338]}, {"w": "measure", "b": [0.3836, 0.8124, 0.4539, 0.8338]}, {"w": "the", "b": [0.46, 0.8124, 0.4863, 0.8338]}, {"w": "loss", "b": [0.4924, 0.8124, 0.5236, 0.8338]}, {"w": "and", "b": [0.5297, 0.8124, 0.5612, 0.8338]}, {"w": "the", "b": [0.5673, 0.8124, 0.5936, 0.8338]}, {"w": "extra", "b": [0.5997, 0.8124, 0.6416, 0.8338]}, {"w": "metrics", "b": [0.6477, 0.8124, 0.7097, 0.8338]}, {"w": "on", "b": [0.7158, 0.8124, 0.7378, 0.8338]}, {"w": "this", "b": [0.7439, 0.8124, 0.7746, 0.8338]}, {"w": "set", "b": [0.7807, 0.8124, 0.8036, 0.8338]}, {"w": "at", "b": [0.8096, 0.8124, 0.8247, 0.8338]}, {"w": "the", "b": [0.8308, 0.8124, 0.8572, 0.8338]}, {"w": "end", "b": [0.1429, 0.8314, 0.1741, 0.8528]}, {"w": "of", "b": [0.1799, 0.8314, 0.1967, 0.8528]}, {"w": "each", "b": [0.2024, 0.8314, 0.2404, 0.8528]}, {"w": "epoch,", "b": [0.2462, 0.8314, 0.3012, 0.8528]}, {"w": "which", "b": [0.307, 0.8314, 0.3579, 0.8528]}, {"w": "is", "b": [0.3637, 0.8314, 0.3769, 0.8528]}, {"w": "very", "b": [0.3827, 0.8314, 0.4191, 0.8528]}, {"w": "useful", "b": [0.4249, 0.8314, 0.4749, 0.8528]}, {"w": "to", "b": [0.4807, 0.8314, 0.4977, 0.8528]}, {"w": "see", "b": [0.5035, 0.8314, 0.5288, 0.8528]}, {"w": "how", "b": [0.5346, 0.8314, 0.5706, 0.8528]}, {"w": "well", "b": [0.5764, 0.8314, 0.6101, 0.8528]}, {"w": "the", "b": [0.6158, 0.8314, 0.6422, 0.8528]}, {"w": "model", "b": [0.6479, 0.8314, 0.7008, 0.8528]}, {"w": "really", "b": [0.7065, 0.8314, 0.7524, 0.8528]}, {"w": "performs:", "b": [0.7581, 0.8314, 0.8396, 0.8528]}, {"w": "if", "b": [0.8454, 0.8314, 0.8571, 0.8528]}, {"w": "the", "b": [0.1429, 0.8505, 0.1692, 0.8719]}, {"w": "performance", "b": [0.1761, 0.8505, 0.2834, 0.8719]}, {"w": "on", "b": [0.2903, 0.8505, 0.3123, 0.8719]}, {"w": "the", "b": [0.3192, 0.8505, 0.3455, 0.8719]}, {"w": "training", "b": [0.3524, 0.8505, 0.4194, 0.8719]}, {"w": "set", "b": [0.4263, 0.8505, 0.4491, 0.8719]}, {"w": "is", "b": [0.456, 0.8505, 0.4692, 0.8719]}, {"w": "much", "b": [0.4761, 0.8505, 0.5238, 0.8719]}, {"w": "better", "b": [0.5307, 0.8505, 0.5794, 0.8719]}, {"w": "than", "b": [0.5863, 0.8505, 0.6244, 0.8719]}, {"w": "on", "b": [0.6313, 0.8505, 0.6533, 0.8719]}, {"w": "the", "b": [0.6602, 0.8505, 0.6865, 0.8719]}, {"w": "validation", "b": [0.6934, 0.8505, 0.7768, 0.8719]}, {"w": "set,", "b": [0.7837, 0.8505, 0.8113, 0.8719]}, {"w": "your", "b": [0.8182, 0.8505, 0.8571, 0.8719]}]}, {"id": "b_7", "type": "paragraph", "text": "Implementing MLPs with Keras | 299", "words": [{"w": "Implementing", "b": [0.6126, 0.9225, 0.6972, 0.9388]}, {"w": "MLPs", "b": [0.7, 0.9225, 0.7308, 0.9388]}, {"w": "with", "b": [0.7336, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "299", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 326, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "model is probably overfitting the training set (or there is a bug, such as a data mis‐ match between the training set and the validation set):", "words": [{"w": "model", "b": [0.1429, 0.0791, 0.1957, 0.1005]}, {"w": "is", "b": [0.2022, 0.0791, 0.2155, 0.1005]}, {"w": "probably", "b": [0.222, 0.0791, 0.2965, 0.1005]}, {"w": "overfitting", "b": [0.303, 0.0791, 0.3911, 0.1005]}, {"w": "the", "b": [0.3976, 0.0791, 0.424, 0.1005]}, {"w": "training", "b": [0.4305, 0.0791, 0.4975, 0.1005]}, {"w": "set", "b": [0.504, 0.0791, 0.5269, 0.1005]}, {"w": "(or", "b": [0.5335, 0.0791, 0.559, 0.1005]}, {"w": "there", "b": [0.5656, 0.0791, 0.6085, 0.1005]}, {"w": "is", "b": [0.6151, 0.0791, 0.6283, 0.1005]}, {"w": "a", "b": [0.6349, 0.0791, 0.644, 0.1005]}, {"w": "bug,", "b": [0.6506, 0.0791, 0.6868, 0.1005]}, {"w": "such", "b": [0.6933, 0.0791, 0.732, 0.1005]}, {"w": "as", "b": [0.7385, 0.0791, 0.7553, 0.1005]}, {"w": "a", "b": [0.7619, 0.0791, 0.771, 0.1005]}, {"w": "data", "b": [0.7776, 0.0791, 0.8129, 0.1005]}, {"w": "mis‐", "b": [0.8194, 0.0791, 0.8571, 0.1005]}, {"w": "match", "b": [0.1429, 0.0981, 0.195, 0.1195]}, {"w": "between", "b": [0.1997, 0.0981, 0.2689, 0.1195]}, {"w": "the", "b": [0.2736, 0.0981, 0.2999, 0.1195]}, {"w": "training", "b": [0.3046, 0.0981, 0.3716, 0.1195]}, {"w": "set", "b": [0.3763, 0.0981, 0.3992, 0.1195]}, {"w": "and", "b": [0.4039, 0.0981, 0.4354, 0.1195]}, {"w": "the", "b": [0.4402, 0.0981, 0.4665, 0.1195]}, {"w": "validation", "b": [0.4712, 0.0981, 0.5546, 0.1195]}, {"w": "set):", "b": [0.5593, 0.0981, 0.5941, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> history = model.fit(X_train, y_train, epochs=30, ... validation_data=(X_valid, y_valid)) ... Train on 55000 samples, validate on 5000 samples Epoch 1/30 55000/55000 [==========] - 3s 55us/sample - loss: 1.4948 - acc: 0.5757 - val_loss: 1.0042 - val_acc: 0.7166 Epoch 2/30 55000/55000 [==========] - 3s 55us/sample - loss: 0.8690 - acc: 0.7318 - val_loss: 0.7549 - val_acc: 0.7616 [...] Epoch 50/50 55000/55000 [==========] - 4s 72us/sample - loss: 0.3607 - acc: 0.8752 - val_loss: 0.3706 - val_acc: 0.8728", "words": [{"w": ">>>", "b": [0.1766, 0.1301, 0.2019, 0.1429]}, {"w": "history", "b": [0.2103, 0.1301, 0.2694, 0.1429]}, {"w": "=", "b": [0.2778, 0.1301, 0.2862, 0.1429]}, {"w": "model.fit(X_train,", "b": [0.2946, 0.1301, 0.4464, 0.1429]}, {"w": "y_train,", "b": [0.4549, 0.1301, 0.5223, 0.1429]}, {"w": "epochs=30,", "b": [0.5308, 0.1301, 0.6151, 0.1429]}, {"w": "...", "b": [0.1766, 0.1455, 0.2019, 0.1584]}, {"w": "validation_data=(X_valid,", "b": [0.379, 0.1455, 0.5898, 0.1584]}, {"w": "y_valid))", "b": [0.5982, 0.1455, 0.6741, 0.1584]}, {"w": "...", "b": [0.1766, 0.1609, 0.2019, 0.1738]}, {"w": "Train", "b": [0.1766, 0.1763, 0.2188, 0.1892]}, {"w": "on", "b": [0.2272, 0.1763, 0.2441, 0.1892]}, {"w": "55000", "b": [0.2525, 0.1763, 0.2946, 0.1892]}, {"w": "samples,", "b": [0.3031, 0.1763, 0.3705, 0.1892]}, {"w": "validate", "b": [0.379, 0.1763, 0.4464, 0.1892]}, {"w": "on", "b": [0.4549, 0.1763, 0.4717, 0.1892]}, {"w": "5000", "b": [0.4802, 0.1763, 0.5139, 0.1892]}, {"w": "samples", "b": [0.5223, 0.1763, 0.5814, 0.1892]}, {"w": "Epoch", "b": [0.1766, 0.1918, 0.2188, 0.2046]}, {"w": "1/30", "b": [0.2272, 0.1918, 0.2609, 0.2046]}, {"w": "55000/55000", "b": [0.1766, 0.2072, 0.2694, 0.22]}, {"w": "[==========]", "b": [0.2778, 0.2072, 0.379, 0.22]}, {"w": "-", "b": [0.3874, 0.2072, 0.3958, 0.22]}, {"w": "3s", "b": [0.4043, 0.2072, 0.4211, 0.22]}, {"w": "55us/sample", "b": [0.4296, 0.2072, 0.5223, 0.22]}, {"w": "-", "b": [0.5308, 0.2072, 0.5392, 0.22]}, {"w": "loss:", "b": [0.5476, 0.2072, 0.5898, 0.22]}, {"w": "1.4948", "b": [0.5982, 0.2072, 0.6488, 0.22]}, {"w": "-", "b": [0.691, 0.2072, 0.6994, 0.22]}, {"w": "acc:", "b": [0.7078, 0.2072, 0.7416, 0.22]}, {"w": "0.5757", "b": [0.75, 0.2072, 0.8006, 0.22]}, {"w": "-", "b": [0.5308, 0.2226, 0.5392, 0.2354]}, {"w": "val_loss:", "b": [0.5476, 0.2226, 0.6235, 0.2354]}, {"w": "1.0042", "b": [0.632, 0.2226, 0.6825, 0.2354]}, {"w": "-", "b": [0.691, 0.2226, 0.6994, 0.2354]}, {"w": "val_acc:", "b": [0.7078, 0.2226, 0.7753, 0.2354]}, {"w": "0.7166", "b": [0.7837, 0.2226, 0.8343, 0.2354]}, {"w": "Epoch", "b": [0.1766, 0.238, 0.2188, 0.2509]}, {"w": "2/30", "b": [0.2272, 0.238, 0.2609, 0.2509]}, {"w": "55000/55000", "b": [0.1766, 0.2534, 0.2694, 0.2663]}, {"w": "[==========]", "b": [0.2778, 0.2534, 0.379, 0.2663]}, {"w": "-", "b": [0.3874, 0.2534, 0.3958, 0.2663]}, {"w": "3s", "b": [0.4043, 0.2534, 0.4211, 0.2663]}, {"w": "55us/sample", "b": [0.4296, 0.2534, 0.5223, 0.2663]}, {"w": "-", "b": [0.5308, 0.2534, 0.5392, 0.2663]}, {"w": "loss:", "b": [0.5476, 0.2534, 0.5898, 0.2663]}, {"w": "0.8690", "b": [0.5982, 0.2534, 0.6488, 0.2663]}, {"w": "-", "b": [0.691, 0.2534, 0.6994, 0.2663]}, {"w": "acc:", "b": [0.7078, 0.2534, 0.7416, 0.2663]}, {"w": "0.7318", "b": [0.75, 0.2534, 0.8006, 0.2663]}, {"w": "-", "b": [0.5308, 0.2689, 0.5392, 0.2817]}, {"w": "val_loss:", "b": [0.5476, 0.2689, 0.6235, 0.2817]}, {"w": "0.7549", "b": [0.632, 0.2689, 0.6825, 0.2817]}, {"w": "-", "b": [0.691, 0.2689, 0.6994, 0.2817]}, {"w": "val_acc:", "b": [0.7078, 0.2689, 0.7753, 0.2817]}, {"w": "0.7616", "b": [0.7837, 0.2689, 0.8343, 0.2817]}, {"w": "[...]", "b": [0.1766, 0.2843, 0.2188, 0.2971]}, {"w": "Epoch", "b": [0.1766, 0.2997, 0.2188, 0.3125]}, {"w": "50/50", "b": [0.2272, 0.2997, 0.2694, 0.3125]}, {"w": "55000/55000", "b": [0.1766, 0.3151, 0.2694, 0.328]}, {"w": "[==========]", "b": [0.2778, 0.3151, 0.379, 0.328]}, {"w": "-", "b": [0.3874, 0.3151, 0.3958, 0.328]}, {"w": "4s", "b": [0.4043, 0.3151, 0.4211, 0.328]}, {"w": "72us/sample", "b": [0.4296, 0.3151, 0.5223, 0.328]}, {"w": "-", "b": [0.5308, 0.3151, 0.5392, 0.328]}, {"w": "loss:", "b": [0.5476, 0.3151, 0.5898, 0.328]}, {"w": "0.3607", "b": [0.5982, 0.3151, 0.6488, 0.328]}, {"w": "-", "b": [0.691, 0.3151, 0.6994, 0.328]}, {"w": "acc:", "b": [0.7078, 0.3151, 0.7416, 0.328]}, {"w": "0.8752", "b": [0.75, 0.3151, 0.8006, 0.328]}, {"w": "-", "b": [0.5308, 0.3305, 0.5392, 0.3434]}, {"w": "val_loss:", "b": [0.5476, 0.3305, 0.6235, 0.3434]}, {"w": "0.3706", "b": [0.632, 0.3305, 0.6825, 0.3434]}, {"w": "-", "b": [0.691, 0.3305, 0.6994, 0.3434]}, {"w": "val_acc:", "b": [0.7078, 0.3305, 0.7753, 0.3434]}, {"w": "0.8728", "b": [0.7837, 0.3305, 0.8343, 0.3434]}]}, {"id": "b_2", "type": "paragraph", "text": "And that’s it! The neural network is trained. At each epoch during training, Keras dis‐ plays the number of instances processed so far (along with a progress bar), the mean training time per sample, the loss and accuracy (or any other extra metrics you asked for), both on the training set and the validation set. You can see that the training loss went down, which is a good sign, and the validation accuracy reached 87.28% after 50 epochs, not too far from the training accuracy, so there does not seem to be much overfitting going on.", "words": [{"w": "And", "b": [0.1429, 0.3512, 0.1796, 0.3726]}, {"w": "that’s", "b": [0.1845, 0.3512, 0.2269, 0.3726]}, {"w": "it!", "b": [0.2318, 0.3512, 0.2495, 0.3726]}, {"w": "The", "b": [0.2544, 0.3512, 0.2872, 0.3726]}, {"w": "neural", "b": [0.2921, 0.3512, 0.3456, 0.3726]}, {"w": "network", "b": [0.3505, 0.3512, 0.42, 0.3726]}, {"w": "is", "b": [0.4249, 0.3512, 0.4382, 0.3726]}, {"w": "trained.", "b": [0.4431, 0.3512, 0.5079, 0.3726]}, {"w": "At", "b": [0.5128, 0.3512, 0.5327, 0.3726]}, {"w": "each", "b": [0.5376, 0.3512, 0.5755, 0.3726]}, {"w": "epoch", "b": [0.5804, 0.3512, 0.6308, 0.3726]}, {"w": "during", "b": [0.6357, 0.3512, 0.6922, 0.3726]}, {"w": "training,", "b": [0.6971, 0.3512, 0.7688, 0.3726]}, {"w": "Keras", "b": [0.7737, 0.3512, 0.8206, 0.3726]}, {"w": "dis‐", "b": [0.8255, 0.3512, 0.8571, 0.3726]}, {"w": "plays", "b": [0.1429, 0.3702, 0.185, 0.3916]}, {"w": "the", "b": [0.1907, 0.3702, 0.217, 0.3916]}, {"w": "number", "b": [0.2227, 0.3702, 0.289, 0.3916]}, {"w": "of", "b": [0.2947, 0.3702, 0.3115, 0.3916]}, {"w": "instances", "b": [0.3172, 0.3702, 0.394, 0.3916]}, {"w": "processed", "b": [0.3997, 0.3702, 0.4818, 0.3916]}, {"w": "so", "b": [0.4874, 0.3702, 0.5057, 0.3916]}, {"w": "far", "b": [0.5114, 0.3702, 0.5344, 0.3916]}, {"w": "(along", "b": [0.5401, 0.3702, 0.5935, 0.3916]}, {"w": "with", "b": [0.5992, 0.3702, 0.6365, 0.3916]}, {"w": "a", "b": [0.6422, 0.3702, 0.6513, 0.3916]}, {"w": "progress", "b": [0.657, 0.3702, 0.7279, 0.3916]}, {"w": "bar),", "b": [0.7336, 0.3702, 0.773, 0.3916]}, {"w": "the", "b": [0.7787, 0.3702, 0.805, 0.3916]}, {"w": "mean", "b": [0.8107, 0.3702, 0.8572, 0.3916]}, {"w": "training", "b": [0.1429, 0.3893, 0.2098, 0.4107]}, {"w": "time", "b": [0.2151, 0.3893, 0.253, 0.4107]}, {"w": "per", "b": [0.2583, 0.3893, 0.2858, 0.4107]}, {"w": "sample,", "b": [0.2911, 0.3893, 0.3544, 0.4107]}, {"w": "the", "b": [0.3597, 0.3893, 0.386, 0.4107]}, {"w": "loss", "b": [0.3914, 0.3893, 0.4225, 0.4107]}, {"w": "and", "b": [0.4279, 0.3893, 0.4594, 0.4107]}, {"w": "accuracy", "b": [0.4647, 0.3893, 0.5378, 0.4107]}, {"w": "(or", "b": [0.5431, 0.3893, 0.5687, 0.4107]}, {"w": "any", "b": [0.574, 0.3893, 0.6037, 0.4107]}, {"w": "other", "b": [0.609, 0.3893, 0.6537, 0.4107]}, {"w": "extra", "b": [0.659, 0.3893, 0.7009, 0.4107]}, {"w": "metrics", "b": [0.7062, 0.3893, 0.7683, 0.4107]}, {"w": "you", "b": [0.7736, 0.3893, 0.8048, 0.4107]}, {"w": "asked", "b": [0.8102, 0.3893, 0.8571, 0.4107]}, {"w": "for),", "b": [0.1429, 0.4083, 0.1793, 0.4297]}, {"w": "both", "b": [0.1848, 0.4083, 0.2235, 0.4297]}, {"w": "on", "b": [0.229, 0.4083, 0.251, 0.4297]}, {"w": "the", "b": [0.2565, 0.4083, 0.2829, 0.4297]}, {"w": "training", "b": [0.2884, 0.4083, 0.3553, 0.4297]}, {"w": "set", "b": [0.3608, 0.4083, 0.3837, 0.4297]}, {"w": "and", "b": [0.3892, 0.4083, 0.4207, 0.4297]}, {"w": "the", "b": [0.4262, 0.4083, 0.4526, 0.4297]}, {"w": "validation", "b": [0.4581, 0.4083, 0.5414, 0.4297]}, {"w": "set.", "b": [0.5469, 0.4083, 0.5745, 0.4297]}, {"w": "You", "b": [0.58, 0.4083, 0.6124, 0.4297]}, {"w": "can", "b": [0.6179, 0.4083, 0.6472, 0.4297]}, {"w": "see", "b": [0.6527, 0.4083, 0.6781, 0.4297]}, {"w": "that", "b": [0.6836, 0.4083, 0.7162, 0.4297]}, {"w": "the", "b": [0.7217, 0.4083, 0.748, 0.4297]}, {"w": "training", "b": [0.7535, 0.4083, 0.8205, 0.4297]}, {"w": "loss", "b": [0.826, 0.4083, 0.8571, 0.4297]}, {"w": "went", "b": [0.1428, 0.4274, 0.1833, 0.4488]}, {"w": "down,", "b": [0.1882, 0.4274, 0.2403, 0.4488]}, {"w": "which", "b": [0.2452, 0.4274, 0.2961, 0.4488]}, {"w": "is", "b": [0.301, 0.4274, 0.3143, 0.4488]}, {"w": "a", "b": [0.3192, 0.4274, 0.3283, 0.4488]}, {"w": "good", "b": [0.3332, 0.4274, 0.3752, 0.4488]}, {"w": "sign,", "b": [0.3801, 0.4274, 0.4193, 0.4488]}, {"w": "and", "b": [0.4242, 0.4274, 0.4557, 0.4488]}, {"w": "the", "b": [0.4606, 0.4274, 0.487, 0.4488]}, {"w": "validation", "b": [0.4919, 0.4274, 0.5752, 0.4488]}, {"w": "accuracy", "b": [0.5801, 0.4274, 0.6532, 0.4488]}, {"w": "reached", "b": [0.6581, 0.4274, 0.7236, 0.4488]}, {"w": "87.28%", "b": [0.7286, 0.4274, 0.7891, 0.4488]}, {"w": "after", "b": [0.794, 0.4274, 0.8322, 0.4488]}, {"w": "50", "b": [0.8371, 0.4274, 0.8571, 0.4488]}, {"w": "epochs,", "b": [0.1429, 0.4464, 0.2056, 0.4678]}, {"w": "not", "b": [0.2127, 0.4464, 0.2411, 0.4678]}, {"w": "too", "b": [0.2483, 0.4464, 0.2759, 0.4678]}, {"w": "far", "b": [0.283, 0.4464, 0.3061, 0.4678]}, {"w": "from", "b": [0.3132, 0.4464, 0.3548, 0.4678]}, {"w": "the", "b": [0.3619, 0.4464, 0.3883, 0.4678]}, {"w": "training", "b": [0.3954, 0.4464, 0.4623, 0.4678]}, {"w": "accuracy,", "b": [0.4695, 0.4464, 0.5458, 0.4678]}, {"w": "so", "b": [0.5529, 0.4464, 0.5712, 0.4678]}, {"w": "there", "b": [0.5784, 0.4464, 0.6213, 0.4678]}, {"w": "does", "b": [0.6284, 0.4464, 0.6665, 0.4678]}, {"w": "not", "b": [0.6737, 0.4464, 0.7021, 0.4678]}, {"w": "seem", "b": [0.7092, 0.4464, 0.7516, 0.4678]}, {"w": "to", "b": [0.7588, 0.4464, 0.7758, 0.4678]}, {"w": "be", "b": [0.7829, 0.4464, 0.8023, 0.4678]}, {"w": "much", "b": [0.8095, 0.4464, 0.8571, 0.4678]}, {"w": "overfitting", "b": [0.1429, 0.4655, 0.2309, 0.4869]}, {"w": "going", "b": [0.2356, 0.4655, 0.2827, 0.4869]}, {"w": "on.", "b": [0.2875, 0.4655, 0.3142, 0.4869]}]}, {"id": "b_3", "type": "paragraph", "text": "Instead of passing a validation set using the validation_data argument, you could instead set validation_split to the ratio of the training set that you want Keras to use for validation (e.g., 0.1).", "words": [{"w": "Instead", "b": [0.2714, 0.5082, 0.3276, 0.5278]}, {"w": "of", "b": [0.3375, 0.5082, 0.3529, 0.5278]}, {"w": "passing", "b": [0.3628, 0.5082, 0.4195, 0.5278]}, {"w": "a", "b": [0.4294, 0.5082, 0.4378, 0.5278]}, {"w": "validation", "b": [0.4477, 0.5082, 0.5239, 0.5278]}, {"w": "set", "b": [0.5338, 0.5082, 0.5547, 0.5278]}, {"w": "using", "b": [0.5646, 0.5082, 0.6061, 0.5278]}, {"w": "the", "b": [0.616, 0.5082, 0.6401, 0.5278]}, {"w": "validation_data", "b": [0.65, 0.5111, 0.7857, 0.5249]}, {"w": "argument,", "b": [0.2714, 0.5265, 0.3498, 0.546]}, {"w": "you", "b": [0.3557, 0.5265, 0.3843, 0.546]}, {"w": "could", "b": [0.3902, 0.5265, 0.433, 0.546]}, {"w": "instead", "b": [0.4389, 0.5265, 0.4938, 0.546]}, {"w": "set", "b": [0.4997, 0.5265, 0.5206, 0.546]}, {"w": "validation_split", "b": [0.5265, 0.5294, 0.6713, 0.5432]}, {"w": "to", "b": [0.6772, 0.5265, 0.6928, 0.546]}, {"w": "the", "b": [0.6987, 0.5265, 0.7228, 0.546]}, {"w": "ratio", "b": [0.7287, 0.5265, 0.7644, 0.546]}, {"w": "of", "b": [0.7704, 0.5265, 0.7857, 0.546]}, {"w": "the", "b": [0.2714, 0.5439, 0.2955, 0.5634]}, {"w": "training", "b": [0.2998, 0.5439, 0.361, 0.5634]}, {"w": "set", "b": [0.3653, 0.5439, 0.3862, 0.5634]}, {"w": "that", "b": [0.3906, 0.5439, 0.4203, 0.5634]}, {"w": "you", "b": [0.4247, 0.5439, 0.4532, 0.5634]}, {"w": "want", "b": [0.4576, 0.5439, 0.4948, 0.5634]}, {"w": "Keras", "b": [0.4992, 0.5439, 0.542, 0.5634]}, {"w": "to", "b": [0.5464, 0.5439, 0.5619, 0.5634]}, {"w": "use", "b": [0.5662, 0.5439, 0.5914, 0.5634]}, {"w": "for", "b": [0.5957, 0.5439, 0.6182, 0.5634]}, {"w": "validation", "b": [0.6225, 0.5439, 0.6987, 0.5634]}, {"w": "(e.g.,", "b": [0.703, 0.5439, 0.7396, 0.5634]}, {"w": "0.1).", "b": [0.744, 0.5439, 0.7775, 0.5634]}]}, {"id": "b_4", "type": "paragraph", "text": "If the training set was very skewed, with some classes being overrepresented and oth‐ ers underrepresented, it would be useful to set the class_weight argument when calling the fit() method, giving a larger weight to underrepresented classes, and a lower weight to overrepresented classes. These weights would be used by Keras when computing the loss. If you need per-instance weights instead, you can set the sam ple_weight argument (it supersedes class_weight). This could be useful for exam‐ ple if some instances were labeled by experts while others were labeled using a crowdsourcing platform: you might want to give more weight to the former. You can also provide sample weights (but not class weights) for the validation set by adding them as a third item in the validation_data tuple.", "words": [{"w": "If", "b": [0.1429, 0.606, 0.1561, 0.6275]}, {"w": "the", "b": [0.1613, 0.606, 0.1876, 0.6275]}, {"w": "training", "b": [0.1928, 0.606, 0.2598, 0.6275]}, {"w": "set", "b": [0.2649, 0.606, 0.2878, 0.6275]}, {"w": "was", "b": [0.293, 0.606, 0.324, 0.6275]}, {"w": "very", "b": [0.3292, 0.606, 0.3656, 0.6275]}, {"w": "skewed,", "b": [0.3708, 0.606, 0.4365, 0.6275]}, {"w": "with", "b": [0.4417, 0.606, 0.479, 0.6275]}, {"w": "some", "b": [0.4842, 0.606, 0.5284, 0.6275]}, {"w": "classes", "b": [0.5335, 0.606, 0.5886, 0.6275]}, {"w": "being", "b": [0.5937, 0.606, 0.6399, 0.6275]}, {"w": "overrepresented", "b": [0.6451, 0.606, 0.7797, 0.6275]}, {"w": "and", "b": [0.7849, 0.606, 0.8164, 0.6275]}, {"w": "oth‐", "b": [0.8216, 0.606, 0.8571, 0.6275]}, {"w": "ers", "b": [0.1429, 0.626, 0.1671, 0.6474]}, {"w": "underrepresented,", "b": [0.1755, 0.626, 0.3281, 0.6474]}, {"w": "it", "b": [0.3364, 0.626, 0.3484, 0.6474]}, {"w": "would", "b": [0.3568, 0.626, 0.409, 0.6474]}, {"w": "be", "b": [0.4174, 0.626, 0.4368, 0.6474]}, {"w": "useful", "b": [0.4452, 0.626, 0.4953, 0.6474]}, {"w": "to", "b": [0.5037, 0.626, 0.5207, 0.6474]}, {"w": "set", "b": [0.529, 0.626, 0.5519, 0.6474]}, {"w": "the", "b": [0.5603, 0.626, 0.5866, 0.6474]}, {"w": "class_weight", "b": [0.595, 0.6292, 0.7138, 0.6443]}, {"w": "argument", "b": [0.7221, 0.626, 0.8031, 0.6474]}, {"w": "when", "b": [0.8115, 0.626, 0.8571, 0.6474]}, {"w": "calling", "b": [0.1428, 0.6459, 0.1981, 0.6673]}, {"w": "the", "b": [0.205, 0.6459, 0.2314, 0.6673]}, {"w": "fit()", "b": [0.2383, 0.6491, 0.2878, 0.6642]}, {"w": "method,", "b": [0.2947, 0.6459, 0.3645, 0.6673]}, {"w": "giving", "b": [0.3714, 0.6459, 0.4231, 0.6673]}, {"w": "a", "b": [0.4301, 0.6459, 0.4392, 0.6673]}, {"w": "larger", "b": [0.4462, 0.6459, 0.4947, 0.6673]}, {"w": "weight", "b": [0.5016, 0.6459, 0.5571, 0.6673]}, {"w": "to", "b": [0.5641, 0.6459, 0.5811, 0.6673]}, {"w": "underrepresented", "b": [0.588, 0.6459, 0.7358, 0.6673]}, {"w": "classes,", "b": [0.7428, 0.6459, 0.8026, 0.6673]}, {"w": "and", "b": [0.8095, 0.6459, 0.841, 0.6673]}, {"w": "a", "b": [0.848, 0.6459, 0.8571, 0.6673]}, {"w": "lower", "b": [0.1429, 0.665, 0.1896, 0.6864]}, {"w": "weight", "b": [0.195, 0.665, 0.2506, 0.6864]}, {"w": "to", "b": [0.256, 0.665, 0.273, 0.6864]}, {"w": "overrepresented", "b": [0.2784, 0.665, 0.4131, 0.6864]}, {"w": "classes.", "b": [0.4185, 0.665, 0.4783, 0.6864]}, {"w": "These", "b": [0.4837, 0.665, 0.533, 0.6864]}, {"w": "weights", "b": [0.5385, 0.665, 0.6017, 0.6864]}, {"w": "would", "b": [0.6071, 0.665, 0.6593, 0.6864]}, {"w": "be", "b": [0.6647, 0.665, 0.6842, 0.6864]}, {"w": "used", "b": [0.6896, 0.665, 0.7282, 0.6864]}, {"w": "by", "b": [0.7336, 0.665, 0.7537, 0.6864]}, {"w": "Keras", "b": [0.7592, 0.665, 0.8061, 0.6864]}, {"w": "when", "b": [0.8115, 0.665, 0.8572, 0.6864]}, {"w": "computing", "b": [0.1429, 0.6849, 0.234, 0.7063]}, {"w": "the", "b": [0.2419, 0.6849, 0.2682, 0.7063]}, {"w": "loss.", "b": [0.2761, 0.6849, 0.312, 0.7063]}, {"w": "If", "b": [0.3199, 0.6849, 0.3332, 0.7063]}, {"w": "you", "b": [0.341, 0.6849, 0.3723, 0.7063]}, {"w": "need", "b": [0.3801, 0.6849, 0.4202, 0.7063]}, {"w": "per-instance", "b": [0.4281, 0.6849, 0.5317, 0.7063]}, {"w": "weights", "b": [0.5396, 0.6849, 0.6028, 0.7063]}, {"w": "instead,", "b": [0.6106, 0.6849, 0.6754, 0.7063]}, {"w": "you", "b": [0.6832, 0.6849, 0.7145, 0.7063]}, {"w": "can", "b": [0.7223, 0.6849, 0.7517, 0.7063]}, {"w": "set", "b": [0.7596, 0.6849, 0.7824, 0.7063]}, {"w": "the", "b": [0.7903, 0.6849, 0.8166, 0.7063]}, {"w": "sam", "b": [0.8245, 0.6881, 0.8542, 0.7032]}, {"w": "ple_weight", "b": [0.1429, 0.7081, 0.2418, 0.7231]}, {"w": "argument", "b": [0.2482, 0.7049, 0.3292, 0.7263]}, {"w": "(it", "b": [0.3356, 0.7049, 0.3547, 0.7263]}, {"w": "supersedes", "b": [0.3611, 0.7049, 0.4513, 0.7263]}, {"w": "class_weight).", "b": [0.4577, 0.7049, 0.5884, 0.7263]}, {"w": "This", "b": [0.5948, 0.7049, 0.632, 0.7263]}, {"w": "could", "b": [0.6384, 0.7049, 0.6852, 0.7263]}, {"w": "be", "b": [0.6916, 0.7049, 0.711, 0.7263]}, {"w": "useful", "b": [0.7174, 0.7049, 0.7675, 0.7263]}, {"w": "for", "b": [0.7739, 0.7049, 0.7984, 0.7263]}, {"w": "exam‐", "b": [0.8048, 0.7049, 0.8571, 0.7263]}, {"w": "ple", "b": [0.1428, 0.7239, 0.1679, 0.7453]}, {"w": "if", "b": [0.1776, 0.7239, 0.1894, 0.7453]}, {"w": "some", "b": [0.1991, 0.7239, 0.2433, 0.7453]}, {"w": "instances", "b": [0.2531, 0.7239, 0.3299, 0.7453]}, {"w": "were", "b": [0.3397, 0.7239, 0.3794, 0.7453]}, {"w": "labeled", "b": [0.3891, 0.7239, 0.4481, 0.7453]}, {"w": "by", "b": [0.4578, 0.7239, 0.478, 0.7453]}, {"w": "experts", "b": [0.4877, 0.7239, 0.5479, 0.7453]}, {"w": "while", "b": [0.5577, 0.7239, 0.6028, 0.7453]}, {"w": "others", "b": [0.6125, 0.7239, 0.6649, 0.7453]}, {"w": "were", "b": [0.6746, 0.7239, 0.7143, 0.7453]}, {"w": "labeled", "b": [0.7241, 0.7239, 0.7831, 0.7453]}, {"w": "using", "b": [0.7928, 0.7239, 0.8382, 0.7453]}, {"w": "a", "b": [0.848, 0.7239, 0.8571, 0.7453]}, {"w": "crowdsourcing", "b": [0.1429, 0.743, 0.2679, 0.7644]}, {"w": "platform:", "b": [0.2735, 0.743, 0.3511, 0.7644]}, {"w": "you", "b": [0.3567, 0.743, 0.388, 0.7644]}, {"w": "might", "b": [0.3936, 0.743, 0.4431, 0.7644]}, {"w": "want", "b": [0.4487, 0.743, 0.4894, 0.7644]}, {"w": "to", "b": [0.4951, 0.743, 0.512, 0.7644]}, {"w": "give", "b": [0.5176, 0.743, 0.5515, 0.7644]}, {"w": "more", "b": [0.5571, 0.743, 0.6013, 0.7644]}, {"w": "weight", "b": [0.607, 0.743, 0.6625, 0.7644]}, {"w": "to", "b": [0.6681, 0.743, 0.6851, 0.7644]}, {"w": "the", "b": [0.6907, 0.743, 0.717, 0.7644]}, {"w": "former.", "b": [0.7226, 0.743, 0.7842, 0.7644]}, {"w": "You", "b": [0.7898, 0.743, 0.8222, 0.7644]}, {"w": "can", "b": [0.8278, 0.743, 0.8571, 0.7644]}, {"w": "also", "b": [0.1429, 0.762, 0.1755, 0.7834]}, {"w": "provide", "b": [0.1823, 0.762, 0.2467, 0.7834]}, {"w": "sample", "b": [0.2534, 0.762, 0.3119, 0.7834]}, {"w": "weights", "b": [0.3187, 0.762, 0.3819, 0.7834]}, {"w": "(but", "b": [0.3887, 0.762, 0.4239, 0.7834]}, {"w": "not", "b": [0.4306, 0.762, 0.459, 0.7834]}, {"w": "class", "b": [0.4658, 0.762, 0.5043, 0.7834]}, {"w": "weights)", "b": [0.5111, 0.762, 0.5815, 0.7834]}, {"w": "for", "b": [0.5882, 0.762, 0.6127, 0.7834]}, {"w": "the", "b": [0.6195, 0.762, 0.6458, 0.7834]}, {"w": "validation", "b": [0.6526, 0.762, 0.736, 0.7834]}, {"w": "set", "b": [0.7427, 0.762, 0.7656, 0.7834]}, {"w": "by", "b": [0.7724, 0.762, 0.7925, 0.7834]}, {"w": "adding", "b": [0.7993, 0.762, 0.8571, 0.7834]}, {"w": "them", "b": [0.1428, 0.782, 0.1862, 0.8034]}, {"w": "as", "b": [0.191, 0.782, 0.2078, 0.8034]}, {"w": "a", "b": [0.2125, 0.782, 0.2216, 0.8034]}, {"w": "third", "b": [0.2264, 0.782, 0.2682, 0.8034]}, {"w": "item", "b": [0.2729, 0.782, 0.3107, 0.8034]}, {"w": "in", "b": [0.3155, 0.782, 0.3325, 0.8034]}, {"w": "the", "b": [0.3372, 0.782, 0.3635, 0.8034]}, {"w": "validation_data", "b": [0.3682, 0.7851, 0.5167, 0.8002]}, {"w": "tuple.", "b": [0.5214, 0.782, 0.5686, 0.8034]}]}, {"id": "b_5", "type": "paragraph", "text": "The fit() method returns a History object containing the training parameters (his tory.params), the list of epochs it went through (history.epoch), and most impor‐ tantly a dictionary (history.history) containing the loss and extra metrics it measured at the end of each epoch on the training set and on the validation set (if", "words": [{"w": "The", "b": [0.1429, 0.811, 0.1757, 0.8324]}, {"w": "fit()", "b": [0.1814, 0.8142, 0.2309, 0.8292]}, {"w": "method", "b": [0.2366, 0.811, 0.3016, 0.8324]}, {"w": "returns", "b": [0.3074, 0.811, 0.3681, 0.8324]}, {"w": "a", "b": [0.3739, 0.811, 0.383, 0.8324]}, {"w": "History", "b": [0.3887, 0.8142, 0.458, 0.8292]}, {"w": "object", "b": [0.4637, 0.811, 0.5143, 0.8324]}, {"w": "containing", "b": [0.52, 0.811, 0.6097, 0.8324]}, {"w": "the", "b": [0.6154, 0.811, 0.6417, 0.8324]}, {"w": "training", "b": [0.6475, 0.811, 0.7144, 0.8324]}, {"w": "parameters", "b": [0.7201, 0.811, 0.8136, 0.8324]}, {"w": "(his", "b": [0.8193, 0.811, 0.8562, 0.8324]}, {"w": "tory.params),", "b": [0.1429, 0.8309, 0.2637, 0.8523]}, {"w": "the", "b": [0.2698, 0.8309, 0.2961, 0.8523]}, {"w": "list", "b": [0.3022, 0.8309, 0.3271, 0.8523]}, {"w": "of", "b": [0.3332, 0.8309, 0.35, 0.8523]}, {"w": "epochs", "b": [0.3561, 0.8309, 0.4141, 0.8523]}, {"w": "it", "b": [0.4202, 0.8309, 0.4322, 0.8523]}, {"w": "went", "b": [0.4383, 0.8309, 0.4788, 0.8523]}, {"w": "through", "b": [0.4849, 0.8309, 0.5527, 0.8523]}, {"w": "(history.epoch),", "b": [0.5588, 0.8309, 0.7066, 0.8523]}, {"w": "and", "b": [0.7127, 0.8309, 0.7443, 0.8523]}, {"w": "most", "b": [0.7504, 0.8309, 0.7921, 0.8523]}, {"w": "impor‐", "b": [0.7982, 0.8309, 0.8571, 0.8523]}, {"w": "tantly", "b": [0.1429, 0.8509, 0.1905, 0.8723]}, {"w": "a", "b": [0.2019, 0.8509, 0.211, 0.8723]}, {"w": "dictionary", "b": [0.2224, 0.8509, 0.3088, 0.8723]}, {"w": "(history.history)", "b": [0.3202, 0.8509, 0.483, 0.8723]}, {"w": "containing", "b": [0.4944, 0.8509, 0.584, 0.8723]}, {"w": "the", "b": [0.5954, 0.8509, 0.6217, 0.8723]}, {"w": "loss", "b": [0.6331, 0.8509, 0.6643, 0.8723]}, {"w": "and", "b": [0.6756, 0.8509, 0.7072, 0.8723]}, {"w": "extra", "b": [0.7185, 0.8509, 0.7604, 0.8723]}, {"w": "metrics", "b": [0.7718, 0.8509, 0.8338, 0.8723]}, {"w": "it", "b": [0.8452, 0.8509, 0.8571, 0.8723]}, {"w": "measured", "b": [0.1429, 0.8699, 0.2242, 0.8913]}, {"w": "at", "b": [0.2312, 0.8699, 0.2463, 0.8913]}, {"w": "the", "b": [0.2533, 0.8699, 0.2797, 0.8913]}, {"w": "end", "b": [0.2867, 0.8699, 0.3179, 0.8913]}, {"w": "of", "b": [0.3249, 0.8699, 0.3417, 0.8913]}, {"w": "each", "b": [0.3487, 0.8699, 0.3866, 0.8913]}, {"w": "epoch", "b": [0.3936, 0.8699, 0.444, 0.8913]}, {"w": "on", "b": [0.451, 0.8699, 0.473, 0.8913]}, {"w": "the", "b": [0.48, 0.8699, 0.5063, 0.8913]}, {"w": "training", "b": [0.5133, 0.8699, 0.5802, 0.8913]}, {"w": "set", "b": [0.5872, 0.8699, 0.6101, 0.8913]}, {"w": "and", "b": [0.6171, 0.8699, 0.6486, 0.8913]}, {"w": "on", "b": [0.6556, 0.8699, 0.6777, 0.8913]}, {"w": "the", "b": [0.6847, 0.8699, 0.711, 0.8913]}, {"w": "validation", "b": [0.718, 0.8699, 0.8013, 0.8913]}, {"w": "set", "b": [0.8083, 0.8699, 0.8312, 0.8913]}, {"w": "(if", "b": [0.8382, 0.8699, 0.8572, 0.8913]}]}, {"id": "b_6", "type": "paragraph", "text": "300 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "300", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2745, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3635, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 327, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "any). If you create a Pandas DataFrame using this dictionary and call its plot() method, you get the learning curves shown in Figure 10-12:", "words": [{"w": "any).", "b": [0.1429, 0.08, 0.1844, 0.1014]}, {"w": "If", "b": [0.1933, 0.08, 0.2066, 0.1014]}, {"w": "you", "b": [0.2154, 0.08, 0.2467, 0.1014]}, {"w": "create", "b": [0.2555, 0.08, 0.3049, 0.1014]}, {"w": "a", "b": [0.3137, 0.08, 0.3229, 0.1014]}, {"w": "Pandas", "b": [0.3318, 0.08, 0.3914, 0.1014]}, {"w": "DataFrame", "b": [0.4002, 0.08, 0.4936, 0.1014]}, {"w": "using", "b": [0.5025, 0.08, 0.5479, 0.1014]}, {"w": "this", "b": [0.5567, 0.08, 0.5875, 0.1014]}, {"w": "dictionary", "b": [0.5963, 0.08, 0.6827, 0.1014]}, {"w": "and", "b": [0.6916, 0.08, 0.7231, 0.1014]}, {"w": "call", "b": [0.732, 0.08, 0.7605, 0.1014]}, {"w": "its", "b": [0.7693, 0.08, 0.7889, 0.1014]}, {"w": "plot()", "b": [0.7978, 0.0831, 0.8571, 0.0982]}, {"w": "method,", "b": [0.1429, 0.099, 0.2126, 0.1204]}, {"w": "you", "b": [0.2174, 0.099, 0.2486, 0.1204]}, {"w": "get", "b": [0.2533, 0.099, 0.2783, 0.1204]}, {"w": "the", "b": [0.283, 0.099, 0.3094, 0.1204]}, {"w": "learning", "b": [0.3141, 0.099, 0.3832, 0.1204]}, {"w": "curves", "b": [0.3879, 0.099, 0.4423, 0.1204]}, {"w": "shown", "b": [0.447, 0.099, 0.5021, 0.1204]}, {"w": "in", "b": [0.5068, 0.099, 0.5238, 0.1204]}, {"w": "Figure", "b": [0.5285, 0.099, 0.5825, 0.1204]}, {"w": "10-12:", "b": [0.5872, 0.099, 0.6394, 0.1204]}]}, {"id": "b_1", "type": "paragraph", "text": "import pandas as pd", "words": [{"w": "import", "b": [0.1766, 0.131, 0.2272, 0.1438]}, {"w": "pandas", "b": [0.2356, 0.131, 0.2862, 0.1438]}, {"w": "as", "b": [0.2946, 0.131, 0.3115, 0.1438]}, {"w": "pd", "b": [0.3199, 0.131, 0.3368, 0.1438]}]}, {"id": "b_2", "type": "paragraph", "text": "pd.DataFrame(history.history).plot(figsize=(8, 5)) plt.grid(True) plt.gca().set_ylim(0, 1) # set the vertical range to [0-1] plt.show()", "words": [{"w": "pd.DataFrame(history.history).plot(figsize=(8,", "b": [0.1766, 0.1618, 0.5645, 0.1747]}, {"w": "5))", "b": [0.5729, 0.1618, 0.5982, 0.1747]}, {"w": "plt.grid(True)", "b": [0.1766, 0.1772, 0.2946, 0.1901]}, {"w": "plt.gca().set_ylim(0,", "b": [0.1766, 0.1927, 0.3537, 0.2055]}, {"w": "1)", "b": [0.3621, 0.1927, 0.379, 0.2055]}, {"w": "#", "b": [0.3874, 0.1927, 0.3958, 0.2055]}, {"w": "set", "b": [0.4043, 0.1927, 0.4296, 0.2055]}, {"w": "the", "b": [0.438, 0.1927, 0.4633, 0.2055]}, {"w": "vertical", "b": [0.4717, 0.1927, 0.5392, 0.2055]}, {"w": "range", "b": [0.5476, 0.1927, 0.5898, 0.2055]}, {"w": "to", "b": [0.5982, 0.1927, 0.6151, 0.2055]}, {"w": "[0-1]", "b": [0.6235, 0.1927, 0.6657, 0.2055]}, {"w": "plt.show()", "b": [0.1766, 0.2081, 0.2609, 0.2209]}]}, {"id": "b_3", "type": "equation", "text": "Figure 10-12. Learning Curves", "words": [{"w": "Figure", "b": [0.1428, 0.5678, 0.1943, 0.5894]}, {"w": "10-12.", "b": [0.1991, 0.5678, 0.2507, 0.5894]}, {"w": "Learning", "b": [0.2554, 0.5678, 0.3282, 0.5894]}, {"w": "Curves", "b": [0.333, 0.5678, 0.3892, 0.5894]}]}, {"id": "b_4", "type": "paragraph", "text": "You can see that both the training and validation accuracy steadily increase during training, while the training and validation loss decrease. Good! Moreover, the valida‐ tion curves are quite close to the training curves, which means that there is not too much overfitting. In this particular case, the model performed better on the valida‐ tion set than on the training set at the beginning of training: this sometimes happens by chance (especially when the validation set is fairly small). However, the training set performance ends up beating the validation performance, as is generally the case when you train for long enough. You can tell that the model has not quite converged yet, as the validation loss is still going down, so you should probably continue train‐ ing. It’s as simple as calling the fit() method again, since Keras just continues train‐ ing where it left off (you should be able to reach close to 89% validation accuracy).", "words": [{"w": "You", "b": [0.1428, 0.6052, 0.1752, 0.6266]}, {"w": "can", "b": [0.1824, 0.6052, 0.2118, 0.6266]}, {"w": "see", "b": [0.219, 0.6052, 0.2444, 0.6266]}, {"w": "that", "b": [0.2516, 0.6052, 0.2842, 0.6266]}, {"w": "both", "b": [0.2914, 0.6052, 0.3301, 0.6266]}, {"w": "the", "b": [0.3373, 0.6052, 0.3637, 0.6266]}, {"w": "training", "b": [0.3709, 0.6052, 0.4378, 0.6266]}, {"w": "and", "b": [0.4451, 0.6052, 0.4766, 0.6266]}, {"w": "validation", "b": [0.4838, 0.6052, 0.5672, 0.6266]}, {"w": "accuracy", "b": [0.5744, 0.6052, 0.6475, 0.6266]}, {"w": "steadily", "b": [0.6547, 0.6052, 0.7181, 0.6266]}, {"w": "increase", "b": [0.7254, 0.6052, 0.7934, 0.6266]}, {"w": "during", "b": [0.8006, 0.6052, 0.8571, 0.6266]}, {"w": "training,", "b": [0.1429, 0.6243, 0.2146, 0.6457]}, {"w": "while", "b": [0.2201, 0.6243, 0.2652, 0.6457]}, {"w": "the", "b": [0.2707, 0.6243, 0.297, 0.6457]}, {"w": "training", "b": [0.3025, 0.6243, 0.3694, 0.6457]}, {"w": "and", "b": [0.3749, 0.6243, 0.4065, 0.6457]}, {"w": "validation", "b": [0.412, 0.6243, 0.4953, 0.6457]}, {"w": "loss", "b": [0.5008, 0.6243, 0.532, 0.6457]}, {"w": "decrease.", "b": [0.5375, 0.6243, 0.6132, 0.6457]}, {"w": "Good!", "b": [0.6187, 0.6243, 0.6716, 0.6457]}, {"w": "Moreover,", "b": [0.6771, 0.6243, 0.7626, 0.6457]}, {"w": "the", "b": [0.7681, 0.6243, 0.7944, 0.6457]}, {"w": "valida‐", "b": [0.7999, 0.6243, 0.8571, 0.6457]}, {"w": "tion", "b": [0.1429, 0.6433, 0.1768, 0.6647]}, {"w": "curves", "b": [0.1833, 0.6433, 0.2377, 0.6647]}, {"w": "are", "b": [0.2442, 0.6433, 0.2699, 0.6647]}, {"w": "quite", "b": [0.2764, 0.6433, 0.3189, 0.6647]}, {"w": "close", "b": [0.3254, 0.6433, 0.3666, 0.6647]}, {"w": "to", "b": [0.3731, 0.6433, 0.3901, 0.6647]}, {"w": "the", "b": [0.3966, 0.6433, 0.4229, 0.6647]}, {"w": "training", "b": [0.4294, 0.6433, 0.4963, 0.6647]}, {"w": "curves,", "b": [0.5028, 0.6433, 0.5619, 0.6647]}, {"w": "which", "b": [0.5684, 0.6433, 0.6193, 0.6647]}, {"w": "means", "b": [0.6258, 0.6433, 0.68, 0.6647]}, {"w": "that", "b": [0.6864, 0.6433, 0.719, 0.6647]}, {"w": "there", "b": [0.7255, 0.6433, 0.7684, 0.6647]}, {"w": "is", "b": [0.7749, 0.6433, 0.7882, 0.6647]}, {"w": "not", "b": [0.7947, 0.6433, 0.823, 0.6647]}, {"w": "too", "b": [0.8295, 0.6433, 0.8571, 0.6647]}, {"w": "much", "b": [0.1429, 0.6623, 0.1905, 0.6838]}, {"w": "overfitting.", "b": [0.1973, 0.6623, 0.2901, 0.6838]}, {"w": "In", "b": [0.2969, 0.6623, 0.3154, 0.6838]}, {"w": "this", "b": [0.3221, 0.6623, 0.3528, 0.6838]}, {"w": "particular", "b": [0.3596, 0.6623, 0.4414, 0.6838]}, {"w": "case,", "b": [0.4481, 0.6623, 0.4873, 0.6838]}, {"w": "the", "b": [0.4941, 0.6623, 0.5205, 0.6838]}, {"w": "model", "b": [0.5272, 0.6623, 0.58, 0.6838]}, {"w": "performed", "b": [0.5868, 0.6623, 0.6758, 0.6838]}, {"w": "better", "b": [0.6825, 0.6623, 0.7313, 0.6838]}, {"w": "on", "b": [0.738, 0.6623, 0.76, 0.6838]}, {"w": "the", "b": [0.7668, 0.6623, 0.7932, 0.6838]}, {"w": "valida‐", "b": [0.7999, 0.6623, 0.8571, 0.6838]}, {"w": "tion", "b": [0.1429, 0.6814, 0.1768, 0.7028]}, {"w": "set", "b": [0.1823, 0.6814, 0.2052, 0.7028]}, {"w": "than", "b": [0.2107, 0.6814, 0.2487, 0.7028]}, {"w": "on", "b": [0.2542, 0.6814, 0.2762, 0.7028]}, {"w": "the", "b": [0.2817, 0.6814, 0.3081, 0.7028]}, {"w": "training", "b": [0.3136, 0.6814, 0.3805, 0.7028]}, {"w": "set", "b": [0.386, 0.6814, 0.4089, 0.7028]}, {"w": "at", "b": [0.4144, 0.6814, 0.4295, 0.7028]}, {"w": "the", "b": [0.435, 0.6814, 0.4613, 0.7028]}, {"w": "beginning", "b": [0.4668, 0.6814, 0.5511, 0.7028]}, {"w": "of", "b": [0.5566, 0.6814, 0.5734, 0.7028]}, {"w": "training:", "b": [0.5789, 0.6814, 0.6506, 0.7028]}, {"w": "this", "b": [0.6561, 0.6814, 0.6868, 0.7028]}, {"w": "sometimes", "b": [0.6924, 0.6814, 0.782, 0.7028]}, {"w": "happens", "b": [0.7875, 0.6814, 0.8572, 0.7028]}, {"w": "by", "b": [0.1429, 0.7004, 0.163, 0.7219]}, {"w": "chance", "b": [0.1678, 0.7004, 0.226, 0.7219]}, {"w": "(especially", "b": [0.2308, 0.7004, 0.3179, 0.7219]}, {"w": "when", "b": [0.3227, 0.7004, 0.3684, 0.7219]}, {"w": "the", "b": [0.3732, 0.7004, 0.3995, 0.7219]}, {"w": "validation", "b": [0.4044, 0.7004, 0.4877, 0.7219]}, {"w": "set", "b": [0.4925, 0.7004, 0.5154, 0.7219]}, {"w": "is", "b": [0.5202, 0.7004, 0.5334, 0.7219]}, {"w": "fairly", "b": [0.5383, 0.7004, 0.5817, 0.7219]}, {"w": "small).", "b": [0.5865, 0.7004, 0.6429, 0.7219]}, {"w": "However,", "b": [0.6477, 0.7004, 0.7266, 0.7219]}, {"w": "the", "b": [0.7314, 0.7004, 0.7577, 0.7219]}, {"w": "training", "b": [0.7625, 0.7004, 0.8295, 0.7219]}, {"w": "set", "b": [0.8343, 0.7004, 0.8571, 0.7219]}, {"w": "performance", "b": [0.1429, 0.7195, 0.2501, 0.7409]}, {"w": "ends", "b": [0.2589, 0.7195, 0.2978, 0.7409]}, {"w": "up", "b": [0.3066, 0.7195, 0.3286, 0.7409]}, {"w": "beating", "b": [0.3373, 0.7195, 0.3986, 0.7409]}, {"w": "the", "b": [0.4074, 0.7195, 0.4337, 0.7409]}, {"w": "validation", "b": [0.4425, 0.7195, 0.5258, 0.7409]}, {"w": "performance,", "b": [0.5346, 0.7195, 0.6466, 0.7409]}, {"w": "as", "b": [0.6554, 0.7195, 0.6722, 0.7409]}, {"w": "is", "b": [0.681, 0.7195, 0.6942, 0.7409]}, {"w": "generally", "b": [0.703, 0.7195, 0.7788, 0.7409]}, {"w": "the", "b": [0.7876, 0.7195, 0.8139, 0.7409]}, {"w": "case", "b": [0.8227, 0.7195, 0.8571, 0.7409]}, {"w": "when", "b": [0.1428, 0.7385, 0.1885, 0.7599]}, {"w": "you", "b": [0.1941, 0.7385, 0.2253, 0.7599]}, {"w": "train", "b": [0.2309, 0.7385, 0.2711, 0.7599]}, {"w": "for", "b": [0.2767, 0.7385, 0.3013, 0.7599]}, {"w": "long", "b": [0.3068, 0.7385, 0.3439, 0.7599]}, {"w": "enough.", "b": [0.3495, 0.7385, 0.417, 0.7599]}, {"w": "You", "b": [0.4226, 0.7385, 0.455, 0.7599]}, {"w": "can", "b": [0.4606, 0.7385, 0.4899, 0.7599]}, {"w": "tell", "b": [0.4955, 0.7385, 0.5213, 0.7599]}, {"w": "that", "b": [0.5269, 0.7385, 0.5595, 0.7599]}, {"w": "the", "b": [0.565, 0.7385, 0.5914, 0.7599]}, {"w": "model", "b": [0.597, 0.7385, 0.6498, 0.7599]}, {"w": "has", "b": [0.6554, 0.7385, 0.6833, 0.7599]}, {"w": "not", "b": [0.6889, 0.7385, 0.7173, 0.7599]}, {"w": "quite", "b": [0.7229, 0.7385, 0.7654, 0.7599]}, {"w": "converged", "b": [0.7709, 0.7385, 0.8571, 0.7599]}, {"w": "yet,", "b": [0.1429, 0.7576, 0.1724, 0.779]}, {"w": "as", "b": [0.1783, 0.7576, 0.1951, 0.779]}, {"w": "the", "b": [0.201, 0.7576, 0.2274, 0.779]}, {"w": "validation", "b": [0.2333, 0.7576, 0.3167, 0.779]}, {"w": "loss", "b": [0.3226, 0.7576, 0.3538, 0.779]}, {"w": "is", "b": [0.3597, 0.7576, 0.3729, 0.779]}, {"w": "still", "b": [0.3789, 0.7576, 0.409, 0.779]}, {"w": "going", "b": [0.4149, 0.7576, 0.462, 0.779]}, {"w": "down,", "b": [0.4679, 0.7576, 0.52, 0.779]}, {"w": "so", "b": [0.5259, 0.7576, 0.5442, 0.779]}, {"w": "you", "b": [0.5501, 0.7576, 0.5814, 0.779]}, {"w": "should", "b": [0.5873, 0.7576, 0.644, 0.779]}, {"w": "probably", "b": [0.65, 0.7576, 0.7244, 0.779]}, {"w": "continue", "b": [0.7303, 0.7576, 0.8036, 0.779]}, {"w": "train‐", "b": [0.8095, 0.7576, 0.8571, 0.779]}, {"w": "ing.", "b": [0.1429, 0.7775, 0.1743, 0.7989]}, {"w": "It’s", "b": [0.1799, 0.7775, 0.2023, 0.7989]}, {"w": "as", "b": [0.2079, 0.7775, 0.2247, 0.7989]}, {"w": "simple", "b": [0.2302, 0.7775, 0.2852, 0.7989]}, {"w": "as", "b": [0.2907, 0.7775, 0.3075, 0.7989]}, {"w": "calling", "b": [0.3131, 0.7775, 0.3683, 0.7989]}, {"w": "the", "b": [0.3739, 0.7775, 0.4002, 0.7989]}, {"w": "fit()", "b": [0.4058, 0.7807, 0.4553, 0.7958]}, {"w": "method", "b": [0.4608, 0.7775, 0.5258, 0.7989]}, {"w": "again,", "b": [0.5314, 0.7775, 0.5812, 0.7989]}, {"w": "since", "b": [0.5867, 0.7775, 0.629, 0.7989]}, {"w": "Keras", "b": [0.6346, 0.7775, 0.6815, 0.7989]}, {"w": "just", "b": [0.6871, 0.7775, 0.7175, 0.7989]}, {"w": "continues", "b": [0.723, 0.7775, 0.804, 0.7989]}, {"w": "train‐", "b": [0.8095, 0.7775, 0.8571, 0.7989]}, {"w": "ing", "b": [0.1429, 0.7966, 0.1696, 0.818]}, {"w": "where", "b": [0.1743, 0.7966, 0.2251, 0.818]}, {"w": "it", "b": [0.2299, 0.7966, 0.2418, 0.818]}, {"w": "left", "b": [0.2465, 0.7966, 0.2732, 0.818]}, {"w": "off", "b": [0.2779, 0.7966, 0.3009, 0.818]}, {"w": "(you", "b": [0.3056, 0.7966, 0.3441, 0.818]}, {"w": "should", "b": [0.3488, 0.7966, 0.4055, 0.818]}, {"w": "be", "b": [0.4102, 0.7966, 0.4297, 0.818]}, {"w": "able", "b": [0.4344, 0.7966, 0.4683, 0.818]}, {"w": "to", "b": [0.473, 0.7966, 0.49, 0.818]}, {"w": "reach", "b": [0.4947, 0.7966, 0.5404, 0.818]}, {"w": "close", "b": [0.5451, 0.7966, 0.5863, 0.818]}, {"w": "to", "b": [0.591, 0.7966, 0.608, 0.818]}, {"w": "89%", "b": [0.6127, 0.7966, 0.6485, 0.818]}, {"w": "validation", "b": [0.6532, 0.7966, 0.7366, 0.818]}, {"w": "accuracy).", "b": [0.7413, 0.7966, 0.8264, 0.818]}]}, {"id": "b_5", "type": "paragraph", "text": "If you are not satisfied with the performance of your model, you should go back and tune the model’s hyperparameters, for example the number of layers, the number of neurons per layer, the types of activation functions we use for each hidden layer, the", "words": [{"w": "If", "b": [0.1429, 0.8247, 0.1561, 0.8461]}, {"w": "you", "b": [0.1618, 0.8247, 0.193, 0.8461]}, {"w": "are", "b": [0.1987, 0.8247, 0.2244, 0.8461]}, {"w": "not", "b": [0.2301, 0.8247, 0.2585, 0.8461]}, {"w": "satisfied", "b": [0.2641, 0.8247, 0.3317, 0.8461]}, {"w": "with", "b": [0.3374, 0.8247, 0.3747, 0.8461]}, {"w": "the", "b": [0.3804, 0.8247, 0.4067, 0.8461]}, {"w": "performance", "b": [0.4124, 0.8247, 0.5197, 0.8461]}, {"w": "of", "b": [0.5254, 0.8247, 0.5422, 0.8461]}, {"w": "your", "b": [0.5478, 0.8247, 0.5868, 0.8461]}, {"w": "model,", "b": [0.5925, 0.8247, 0.65, 0.8461]}, {"w": "you", "b": [0.6557, 0.8247, 0.6869, 0.8461]}, {"w": "should", "b": [0.6926, 0.8247, 0.7493, 0.8461]}, {"w": "go", "b": [0.755, 0.8247, 0.7754, 0.8461]}, {"w": "back", "b": [0.7811, 0.8247, 0.8199, 0.8461]}, {"w": "and", "b": [0.8256, 0.8247, 0.8571, 0.8461]}, {"w": "tune", "b": [0.1429, 0.8437, 0.1805, 0.8652]}, {"w": "the", "b": [0.1869, 0.8437, 0.2132, 0.8652]}, {"w": "model’s", "b": [0.2196, 0.8437, 0.2822, 0.8652]}, {"w": "hyperparameters,", "b": [0.2885, 0.8437, 0.4344, 0.8652]}, {"w": "for", "b": [0.4408, 0.8437, 0.4653, 0.8652]}, {"w": "example", "b": [0.4717, 0.8437, 0.5412, 0.8652]}, {"w": "the", "b": [0.5476, 0.8437, 0.5739, 0.8652]}, {"w": "number", "b": [0.5803, 0.8437, 0.6466, 0.8652]}, {"w": "of", "b": [0.6529, 0.8437, 0.6697, 0.8652]}, {"w": "layers,", "b": [0.6761, 0.8437, 0.7287, 0.8652]}, {"w": "the", "b": [0.735, 0.8437, 0.7613, 0.8652]}, {"w": "number", "b": [0.7677, 0.8437, 0.834, 0.8652]}, {"w": "of", "b": [0.8404, 0.8437, 0.8572, 0.8652]}, {"w": "neurons", "b": [0.1429, 0.8628, 0.2116, 0.8842]}, {"w": "per", "b": [0.2176, 0.8628, 0.2451, 0.8842]}, {"w": "layer,", "b": [0.2512, 0.8628, 0.2948, 0.8842]}, {"w": "the", "b": [0.3008, 0.8628, 0.3272, 0.8842]}, {"w": "types", "b": [0.3332, 0.8628, 0.3765, 0.8842]}, {"w": "of", "b": [0.3826, 0.8628, 0.3994, 0.8842]}, {"w": "activation", "b": [0.4054, 0.8628, 0.4877, 0.8842]}, {"w": "functions", "b": [0.4937, 0.8628, 0.5728, 0.8842]}, {"w": "we", "b": [0.5788, 0.8628, 0.6019, 0.8842]}, {"w": "use", "b": [0.608, 0.8628, 0.6355, 0.8842]}, {"w": "for", "b": [0.6416, 0.8628, 0.6661, 0.8842]}, {"w": "each", "b": [0.6722, 0.8628, 0.7101, 0.8842]}, {"w": "hidden", "b": [0.7161, 0.8628, 0.7751, 0.8842]}, {"w": "layer,", "b": [0.7811, 0.8628, 0.8248, 0.8842]}, {"w": "the", "b": [0.8308, 0.8628, 0.8571, 0.8842]}]}, {"id": "b_6", "type": "paragraph", "text": "Implementing MLPs with Keras | 301", "words": [{"w": "Implementing", "b": [0.6126, 0.9225, 0.6972, 0.9388]}, {"w": "MLPs", "b": [0.7001, 0.9225, 0.7308, 0.9388]}, {"w": "with", "b": [0.7336, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "301", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 328, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "number of training epochs, the batch size (it can be set in the fit() method using the batch_size argument, which defaults to 32). We will get back to hyperparameter tuning at the end of this chapter. Once you are satisfied with your model’s validation accuracy, you should evaluate it on the test set to estimate the generalization error before you deploy the model to production. You can easily do this using the evalu ate() method (it also supports several other arguments, such as batch_size or sam ple_weight, please check the documentation for more details):", "words": [{"w": "number", "b": [0.1429, 0.08, 0.2091, 0.1014]}, {"w": "of", "b": [0.214, 0.08, 0.2308, 0.1014]}, {"w": "training", "b": [0.2357, 0.08, 0.3027, 0.1014]}, {"w": "epochs,", "b": [0.3076, 0.08, 0.3703, 0.1014]}, {"w": "the", "b": [0.3752, 0.08, 0.4015, 0.1014]}, {"w": "batch", "b": [0.4064, 0.08, 0.4521, 0.1014]}, {"w": "size", "b": [0.457, 0.08, 0.4878, 0.1014]}, {"w": "(it", "b": [0.4927, 0.08, 0.5118, 0.1014]}, {"w": "can", "b": [0.5167, 0.08, 0.5461, 0.1014]}, {"w": "be", "b": [0.551, 0.08, 0.5704, 0.1014]}, {"w": "set", "b": [0.5753, 0.08, 0.5982, 0.1014]}, {"w": "in", "b": [0.6031, 0.08, 0.62, 0.1014]}, {"w": "the", "b": [0.6249, 0.08, 0.6513, 0.1014]}, {"w": "fit()", "b": [0.6562, 0.0831, 0.7057, 0.0982]}, {"w": "method", "b": [0.7106, 0.08, 0.7756, 0.1014]}, {"w": "using", "b": [0.7803, 0.08, 0.8257, 0.1014]}, {"w": "the", "b": [0.8305, 0.08, 0.8568, 0.1014]}, {"w": "batch_size", "b": [0.1429, 0.1031, 0.2418, 0.1182]}, {"w": "argument,", "b": [0.2503, 0.0999, 0.336, 0.1213]}, {"w": "which", "b": [0.3444, 0.0999, 0.3953, 0.1213]}, {"w": "defaults", "b": [0.4038, 0.0999, 0.4689, 0.1213]}, {"w": "to", "b": [0.4773, 0.0999, 0.4943, 0.1213]}, {"w": "32).", "b": [0.5027, 0.0999, 0.5347, 0.1213]}, {"w": "We", "b": [0.5432, 0.0999, 0.5702, 0.1213]}, {"w": "will", "b": [0.5787, 0.0999, 0.6091, 0.1213]}, {"w": "get", "b": [0.6175, 0.0999, 0.6425, 0.1213]}, {"w": "back", "b": [0.6509, 0.0999, 0.6898, 0.1213]}, {"w": "to", "b": [0.6982, 0.0999, 0.7152, 0.1213]}, {"w": "hyperparameter", "b": [0.7236, 0.0999, 0.8571, 0.1213]}, {"w": "tuning", "b": [0.1429, 0.119, 0.1984, 0.1404]}, {"w": "at", "b": [0.2042, 0.119, 0.2193, 0.1404]}, {"w": "the", "b": [0.2251, 0.119, 0.2514, 0.1404]}, {"w": "end", "b": [0.2572, 0.119, 0.2885, 0.1404]}, {"w": "of", "b": [0.2943, 0.119, 0.3111, 0.1404]}, {"w": "this", "b": [0.3169, 0.119, 0.3476, 0.1404]}, {"w": "chapter.", "b": [0.3534, 0.119, 0.4193, 0.1404]}, {"w": "Once", "b": [0.4251, 0.119, 0.4698, 0.1404]}, {"w": "you", "b": [0.4756, 0.119, 0.5068, 0.1404]}, {"w": "are", "b": [0.5126, 0.119, 0.5383, 0.1404]}, {"w": "satisfied", "b": [0.5441, 0.119, 0.6117, 0.1404]}, {"w": "with", "b": [0.6175, 0.119, 0.6548, 0.1404]}, {"w": "your", "b": [0.6606, 0.119, 0.6996, 0.1404]}, {"w": "model’s", "b": [0.7054, 0.119, 0.768, 0.1404]}, {"w": "validation", "b": [0.7738, 0.119, 0.8571, 0.1404]}, {"w": "accuracy,", "b": [0.1429, 0.138, 0.2192, 0.1594]}, {"w": "you", "b": [0.2266, 0.138, 0.2578, 0.1594]}, {"w": "should", "b": [0.2652, 0.138, 0.322, 0.1594]}, {"w": "evaluate", "b": [0.3294, 0.138, 0.3973, 0.1594]}, {"w": "it", "b": [0.4047, 0.138, 0.4166, 0.1594]}, {"w": "on", "b": [0.424, 0.138, 0.4461, 0.1594]}, {"w": "the", "b": [0.4535, 0.138, 0.4798, 0.1594]}, {"w": "test", "b": [0.4872, 0.138, 0.5164, 0.1594]}, {"w": "set", "b": [0.5238, 0.138, 0.5467, 0.1594]}, {"w": "to", "b": [0.5541, 0.138, 0.571, 0.1594]}, {"w": "estimate", "b": [0.5784, 0.138, 0.6479, 0.1594]}, {"w": "the", "b": [0.6553, 0.138, 0.6816, 0.1594]}, {"w": "generalization", "b": [0.689, 0.138, 0.8071, 0.1594]}, {"w": "error", "b": [0.8145, 0.138, 0.8572, 0.1594]}, {"w": "before", "b": [0.1429, 0.1579, 0.1957, 0.1794]}, {"w": "you", "b": [0.2025, 0.1579, 0.2338, 0.1794]}, {"w": "deploy", "b": [0.2406, 0.1579, 0.2968, 0.1794]}, {"w": "the", "b": [0.3037, 0.1579, 0.33, 0.1794]}, {"w": "model", "b": [0.3368, 0.1579, 0.3896, 0.1794]}, {"w": "to", "b": [0.3965, 0.1579, 0.4134, 0.1794]}, {"w": "production.", "b": [0.4203, 0.1579, 0.5191, 0.1794]}, {"w": "You", "b": [0.526, 0.1579, 0.5583, 0.1794]}, {"w": "can", "b": [0.5652, 0.1579, 0.5945, 0.1794]}, {"w": "easily", "b": [0.6013, 0.1579, 0.6474, 0.1794]}, {"w": "do", "b": [0.6542, 0.1579, 0.6759, 0.1794]}, {"w": "this", "b": [0.6827, 0.1579, 0.7134, 0.1794]}, {"w": "using", "b": [0.7202, 0.1579, 0.7657, 0.1794]}, {"w": "the", "b": [0.7725, 0.1579, 0.7988, 0.1794]}, {"w": "evalu", "b": [0.8057, 0.1611, 0.8551, 0.1762]}, {"w": "ate()", "b": [0.1429, 0.1811, 0.1923, 0.1961]}, {"w": "method", "b": [0.1987, 0.1779, 0.2637, 0.1993]}, {"w": "(it", "b": [0.27, 0.1779, 0.2892, 0.1993]}, {"w": "also", "b": [0.2955, 0.1779, 0.3282, 0.1993]}, {"w": "supports", "b": [0.3345, 0.1779, 0.4074, 0.1993]}, {"w": "several", "b": [0.4137, 0.1779, 0.4709, 0.1993]}, {"w": "other", "b": [0.4772, 0.1779, 0.5219, 0.1993]}, {"w": "arguments,", "b": [0.5282, 0.1779, 0.6216, 0.1993]}, {"w": "such", "b": [0.6279, 0.1779, 0.6665, 0.1993]}, {"w": "as", "b": [0.6729, 0.1779, 0.6897, 0.1993]}, {"w": "batch_size", "b": [0.696, 0.1811, 0.7949, 0.1961]}, {"w": "or", "b": [0.8013, 0.1779, 0.8196, 0.1993]}, {"w": "sam", "b": [0.8259, 0.1811, 0.8556, 0.1961]}, {"w": "ple_weight,", "b": [0.1429, 0.1978, 0.2466, 0.2192]}, {"w": "please", "b": [0.2513, 0.1978, 0.302, 0.2192]}, {"w": "check", "b": [0.3067, 0.1978, 0.3546, 0.2192]}, {"w": "the", "b": [0.3594, 0.1978, 0.3857, 0.2192]}, {"w": "documentation", "b": [0.3904, 0.1978, 0.5179, 0.2192]}, {"w": "for", "b": [0.5226, 0.1978, 0.5472, 0.2192]}, {"w": "more", "b": [0.5519, 0.1978, 0.5962, 0.2192]}, {"w": "details):", "b": [0.6009, 0.1978, 0.6667, 0.2192]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> model.evaluate(X_test, y_test) 8832/10000 [==========================] - ETA: 0s - loss: 0.4074 - acc: 0.8540 [0.40738476498126985, 0.854]", "words": [{"w": ">>>", "b": [0.1766, 0.2298, 0.2019, 0.2427]}, {"w": "model.evaluate(X_test,", "b": [0.2103, 0.2298, 0.3958, 0.2427]}, {"w": "y_test)", "b": [0.4043, 0.2298, 0.4633, 0.2427]}, {"w": "8832/10000", "b": [0.1766, 0.2452, 0.2609, 0.2581]}, {"w": "[==========================]", "b": [0.2694, 0.2452, 0.5055, 0.2581]}, {"w": "-", "b": [0.5139, 0.2452, 0.5223, 0.2581]}, {"w": "ETA:", "b": [0.5308, 0.2452, 0.5645, 0.2581]}, {"w": "0s", "b": [0.5729, 0.2452, 0.5898, 0.2581]}, {"w": "-", "b": [0.5982, 0.2452, 0.6067, 0.2581]}, {"w": "loss:", "b": [0.6151, 0.2452, 0.6572, 0.2581]}, {"w": "0.4074", "b": [0.6657, 0.2452, 0.7163, 0.2581]}, {"w": "-", "b": [0.7247, 0.2452, 0.7331, 0.2581]}, {"w": "acc:", "b": [0.7416, 0.2452, 0.7753, 0.2581]}, {"w": "0.8540", "b": [0.7837, 0.2452, 0.8343, 0.2581]}, {"w": "[0.40738476498126985,", "b": [0.1766, 0.2606, 0.3537, 0.2735]}, {"w": "0.854]", "b": [0.3621, 0.2606, 0.4127, 0.2735]}]}, {"id": "b_2", "type": "paragraph", "text": "As we saw in Chapter 2, it is common to get slightly lower performance on the test set than on the validation set, because the hyperparameters are tuned on the validation set, not the test set (however, in this example, we did not do any hyperparameter tun‐ ing, so the lower accuracy is just bad luck). Remember to resist the temptation to tweak the hyperparameters on the test set, or else your estimate of the generalization error will be too optimistic.", "words": [{"w": "As", "b": [0.1429, 0.2813, 0.1649, 0.3027]}, {"w": "we", "b": [0.1696, 0.2813, 0.1927, 0.3027]}, {"w": "saw", "b": [0.1975, 0.2813, 0.2282, 0.3027]}, {"w": "in", "b": [0.2329, 0.2813, 0.2499, 0.3027]}, {"w": "Chapter", "b": [0.2549, 0.2813, 0.3225, 0.3027]}, {"w": "2,", "b": [0.3272, 0.2813, 0.3421, 0.3027]}, {"w": "it", "b": [0.3469, 0.2813, 0.3588, 0.3027]}, {"w": "is", "b": [0.3636, 0.2813, 0.3769, 0.3027]}, {"w": "common", "b": [0.3817, 0.2813, 0.4573, 0.3027]}, {"w": "to", "b": [0.4621, 0.2813, 0.4791, 0.3027]}, {"w": "get", "b": [0.4839, 0.2813, 0.5088, 0.3027]}, {"w": "slightly", "b": [0.5136, 0.2813, 0.5738, 0.3027]}, {"w": "lower", "b": [0.5786, 0.2813, 0.6254, 0.3027]}, {"w": "performance", "b": [0.6302, 0.2813, 0.7375, 0.3027]}, {"w": "on", "b": [0.7423, 0.2813, 0.7643, 0.3027]}, {"w": "the", "b": [0.7691, 0.2813, 0.7955, 0.3027]}, {"w": "test", "b": [0.8003, 0.2813, 0.8295, 0.3027]}, {"w": "set", "b": [0.8343, 0.2813, 0.8571, 0.3027]}, {"w": "than", "b": [0.1428, 0.3003, 0.1809, 0.3217]}, {"w": "on", "b": [0.1874, 0.3003, 0.2095, 0.3217]}, {"w": "the", "b": [0.216, 0.3003, 0.2424, 0.3217]}, {"w": "validation", "b": [0.2489, 0.3003, 0.3323, 0.3217]}, {"w": "set,", "b": [0.3388, 0.3003, 0.3664, 0.3217]}, {"w": "because", "b": [0.373, 0.3003, 0.4376, 0.3217]}, {"w": "the", "b": [0.4441, 0.3003, 0.4705, 0.3217]}, {"w": "hyperparameters", "b": [0.477, 0.3003, 0.6182, 0.3217]}, {"w": "are", "b": [0.6248, 0.3003, 0.6505, 0.3217]}, {"w": "tuned", "b": [0.6571, 0.3003, 0.7057, 0.3217]}, {"w": "on", "b": [0.7123, 0.3003, 0.7343, 0.3217]}, {"w": "the", "b": [0.7409, 0.3003, 0.7672, 0.3217]}, {"w": "validation", "b": [0.7738, 0.3003, 0.8571, 0.3217]}, {"w": "set,", "b": [0.1429, 0.3194, 0.1705, 0.3408]}, {"w": "not", "b": [0.1755, 0.3194, 0.2039, 0.3408]}, {"w": "the", "b": [0.209, 0.3194, 0.2353, 0.3408]}, {"w": "test", "b": [0.2404, 0.3194, 0.2696, 0.3408]}, {"w": "set", "b": [0.2747, 0.3194, 0.2975, 0.3408]}, {"w": "(however,", "b": [0.3026, 0.3194, 0.3844, 0.3408]}, {"w": "in", "b": [0.3894, 0.3194, 0.4064, 0.3408]}, {"w": "this", "b": [0.4115, 0.3194, 0.4422, 0.3408]}, {"w": "example,", "b": [0.4473, 0.3194, 0.5216, 0.3408]}, {"w": "we", "b": [0.5266, 0.3194, 0.5498, 0.3408]}, {"w": "did", "b": [0.5548, 0.3194, 0.5824, 0.3408]}, {"w": "not", "b": [0.5875, 0.3194, 0.6159, 0.3408]}, {"w": "do", "b": [0.6209, 0.3194, 0.6426, 0.3408]}, {"w": "any", "b": [0.6476, 0.3194, 0.6773, 0.3408]}, {"w": "hyperparameter", "b": [0.6823, 0.3194, 0.8158, 0.3408]}, {"w": "tun‐", "b": [0.8209, 0.3194, 0.8571, 0.3408]}, {"w": "ing,", "b": [0.1429, 0.3384, 0.1743, 0.3598]}, {"w": "so", "b": [0.1821, 0.3384, 0.2004, 0.3598]}, {"w": "the", "b": [0.2081, 0.3384, 0.2345, 0.3598]}, {"w": "lower", "b": [0.2422, 0.3384, 0.289, 0.3598]}, {"w": "accuracy", "b": [0.2967, 0.3384, 0.3698, 0.3598]}, {"w": "is", "b": [0.3776, 0.3384, 0.3908, 0.3598]}, {"w": "just", "b": [0.3986, 0.3384, 0.429, 0.3598]}, {"w": "bad", "b": [0.4367, 0.3384, 0.4675, 0.3598]}, {"w": "luck).", "b": [0.4752, 0.3384, 0.5227, 0.3598]}, {"w": "Remember", "b": [0.5304, 0.3384, 0.6224, 0.3598]}, {"w": "to", "b": [0.6301, 0.3384, 0.6471, 0.3598]}, {"w": "resist", "b": [0.6549, 0.3384, 0.6987, 0.3598]}, {"w": "the", "b": [0.7064, 0.3384, 0.7328, 0.3598]}, {"w": "temptation", "b": [0.7405, 0.3384, 0.8324, 0.3598]}, {"w": "to", "b": [0.8402, 0.3384, 0.8571, 0.3598]}, {"w": "tweak", "b": [0.1429, 0.3575, 0.1918, 0.3789]}, {"w": "the", "b": [0.1975, 0.3575, 0.2238, 0.3789]}, {"w": "hyperparameters", "b": [0.2295, 0.3575, 0.3707, 0.3789]}, {"w": "on", "b": [0.3764, 0.3575, 0.3984, 0.3789]}, {"w": "the", "b": [0.4041, 0.3575, 0.4304, 0.3789]}, {"w": "test", "b": [0.4361, 0.3575, 0.4653, 0.3789]}, {"w": "set,", "b": [0.471, 0.3575, 0.4987, 0.3789]}, {"w": "or", "b": [0.5044, 0.3575, 0.5227, 0.3789]}, {"w": "else", "b": [0.5284, 0.3575, 0.559, 0.3789]}, {"w": "your", "b": [0.5647, 0.3575, 0.6037, 0.3789]}, {"w": "estimate", "b": [0.6094, 0.3575, 0.6789, 0.3789]}, {"w": "of", "b": [0.6846, 0.3575, 0.7014, 0.3789]}, {"w": "the", "b": [0.7071, 0.3575, 0.7334, 0.3789]}, {"w": "generalization", "b": [0.7391, 0.3575, 0.8571, 0.3789]}, {"w": "error", "b": [0.1429, 0.3765, 0.1855, 0.3979]}, {"w": "will", "b": [0.1903, 0.3765, 0.2207, 0.3979]}, {"w": "be", "b": [0.2254, 0.3765, 0.2448, 0.3979]}, {"w": "too", "b": [0.2496, 0.3765, 0.2772, 0.3979]}, {"w": "optimistic.", "b": [0.2819, 0.3765, 0.3712, 0.3979]}]}, {"id": "b_3", "type": "paragraph", "text": "Using the Model to Make Predictions", "words": [{"w": "Using", "b": [0.1428, 0.4138, 0.1853, 0.4348]}, {"w": "the", "b": [0.189, 0.4138, 0.2145, 0.4348]}, {"w": "Model", "b": [0.2181, 0.4138, 0.2654, 0.4348]}, {"w": "to", "b": [0.269, 0.4138, 0.285, 0.4348]}, {"w": "Make", "b": [0.2886, 0.4138, 0.3298, 0.4348]}, {"w": "Predictions", "b": [0.3334, 0.4138, 0.4179, 0.4348]}]}, {"id": "b_4", "type": "paragraph", "text": "Next, we can use the model’s predict() method to make predictions on new instan‐ ces. Since we don’t have actual new instances, we will just use the first 3 instances of the test set:", "words": [{"w": "Next,", "b": [0.1429, 0.4413, 0.1876, 0.4628]}, {"w": "we", "b": [0.1933, 0.4413, 0.2164, 0.4628]}, {"w": "can", "b": [0.2221, 0.4413, 0.2515, 0.4628]}, {"w": "use", "b": [0.2572, 0.4413, 0.2848, 0.4628]}, {"w": "the", "b": [0.2905, 0.4413, 0.3168, 0.4628]}, {"w": "model’s", "b": [0.3225, 0.4413, 0.3851, 0.4628]}, {"w": "predict()", "b": [0.3908, 0.4445, 0.4798, 0.4596]}, {"w": "method", "b": [0.4856, 0.4413, 0.5506, 0.4628]}, {"w": "to", "b": [0.5563, 0.4413, 0.5733, 0.4628]}, {"w": "make", "b": [0.579, 0.4413, 0.6244, 0.4628]}, {"w": "predictions", "b": [0.6301, 0.4413, 0.7246, 0.4628]}, {"w": "on", "b": [0.7303, 0.4413, 0.7523, 0.4628]}, {"w": "new", "b": [0.758, 0.4413, 0.7925, 0.4628]}, {"w": "instan‐", "b": [0.7982, 0.4413, 0.8571, 0.4628]}, {"w": "ces.", "b": [0.1429, 0.4604, 0.1729, 0.4818]}, {"w": "Since", "b": [0.1789, 0.4604, 0.2234, 0.4818]}, {"w": "we", "b": [0.2294, 0.4604, 0.2525, 0.4818]}, {"w": "don’t", "b": [0.2585, 0.4604, 0.3001, 0.4818]}, {"w": "have", "b": [0.3061, 0.4604, 0.3445, 0.4818]}, {"w": "actual", "b": [0.3505, 0.4604, 0.4003, 0.4818]}, {"w": "new", "b": [0.4063, 0.4604, 0.4408, 0.4818]}, {"w": "instances,", "b": [0.4468, 0.4604, 0.5284, 0.4818]}, {"w": "we", "b": [0.5343, 0.4604, 0.5575, 0.4818]}, {"w": "will", "b": [0.5635, 0.4604, 0.5938, 0.4818]}, {"w": "just", "b": [0.5998, 0.4604, 0.6302, 0.4818]}, {"w": "use", "b": [0.6362, 0.4604, 0.6638, 0.4818]}, {"w": "the", "b": [0.6698, 0.4604, 0.6961, 0.4818]}, {"w": "first", "b": [0.7021, 0.4604, 0.7356, 0.4818]}, {"w": "3", "b": [0.7415, 0.4604, 0.7515, 0.4818]}, {"w": "instances", "b": [0.7575, 0.4604, 0.8344, 0.4818]}, {"w": "of", "b": [0.8403, 0.4604, 0.8571, 0.4818]}, {"w": "the", "b": [0.1428, 0.4794, 0.1692, 0.5009]}, {"w": "test", "b": [0.1739, 0.4794, 0.2031, 0.5009]}, {"w": "set:", "b": [0.2078, 0.4794, 0.2355, 0.5009]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> X_new = X_test[:3] >>> y_proba = model.predict(X_new) >>> y_proba.round(2) array([[0. , 0. , 0. , 0. , 0. , 0.09, 0. , 0.12, 0. , 0.79], [0. , 0. , 0.94, 0. , 0.02, 0. , 0.04, 0. , 0. , 0. ], [0. , 1. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ]], dtype=float32)", "words": [{"w": ">>>", "b": [0.1766, 0.5114, 0.2019, 0.5243]}, {"w": "X_new", "b": [0.2103, 0.5114, 0.2525, 0.5243]}, {"w": "=", "b": [0.2609, 0.5114, 0.2694, 0.5243]}, {"w": "X_test[:3]", "b": [0.2778, 0.5114, 0.3621, 0.5243]}, {"w": ">>>", "b": [0.1766, 0.5268, 0.2019, 0.5397]}, {"w": "y_proba", "b": [0.2103, 0.5268, 0.2694, 0.5397]}, {"w": "=", "b": [0.2778, 0.5268, 0.2862, 0.5397]}, {"w": "model.predict(X_new)", "b": [0.2946, 0.5268, 0.4633, 0.5397]}, {"w": ">>>", "b": [0.1766, 0.5423, 0.2019, 0.5551]}, {"w": "y_proba.round(2)", "b": [0.2103, 0.5423, 0.3452, 0.5551]}, {"w": "array([[0.", "b": [0.1766, 0.5577, 0.2609, 0.5705]}, {"w": ",", "b": [0.2778, 0.5577, 0.2862, 0.5705]}, {"w": "0.", "b": [0.2946, 0.5577, 0.3115, 0.5705]}, {"w": ",", "b": [0.3284, 0.5577, 0.3368, 0.5705]}, {"w": "0.", "b": [0.3452, 0.5577, 0.3621, 0.5705]}, {"w": ",", "b": [0.379, 0.5577, 0.3874, 0.5705]}, {"w": "0.", "b": [0.3958, 0.5577, 0.4127, 0.5705]}, {"w": ",", "b": [0.4296, 0.5577, 0.438, 0.5705]}, {"w": "0.", "b": [0.4464, 0.5577, 0.4633, 0.5705]}, {"w": ",", "b": [0.4802, 0.5577, 0.4886, 0.5705]}, {"w": "0.09,", "b": [0.497, 0.5577, 0.5392, 0.5705]}, {"w": "0.", "b": [0.5476, 0.5577, 0.5645, 0.5705]}, {"w": ",", "b": [0.5814, 0.5577, 0.5898, 0.5705]}, {"w": "0.12,", "b": [0.5982, 0.5577, 0.6404, 0.5705]}, {"w": "0.", "b": [0.6488, 0.5577, 0.6657, 0.5705]}, {"w": ",", "b": [0.6825, 0.5577, 0.691, 0.5705]}, {"w": "0.79],", "b": [0.6994, 0.5577, 0.75, 0.5705]}, {"w": "[0.", "b": [0.2356, 0.5731, 0.2609, 0.5859]}, {"w": ",", "b": [0.2778, 0.5731, 0.2862, 0.5859]}, {"w": "0.", "b": [0.2946, 0.5731, 0.3115, 0.5859]}, {"w": ",", "b": [0.3284, 0.5731, 0.3368, 0.5859]}, {"w": "0.94,", "b": [0.3452, 0.5731, 0.3874, 0.5859]}, {"w": "0.", "b": [0.3958, 0.5731, 0.4127, 0.5859]}, {"w": ",", "b": [0.4296, 0.5731, 0.438, 0.5859]}, {"w": "0.02,", "b": [0.4464, 0.5731, 0.4886, 0.5859]}, {"w": "0.", "b": [0.497, 0.5731, 0.5139, 0.5859]}, {"w": ",", "b": [0.5308, 0.5731, 0.5392, 0.5859]}, {"w": "0.04,", "b": [0.5476, 0.5731, 0.5898, 0.5859]}, {"w": "0.", "b": [0.5982, 0.5731, 0.6151, 0.5859]}, {"w": ",", "b": [0.6319, 0.5731, 0.6404, 0.5859]}, {"w": "0.", "b": [0.6488, 0.5731, 0.6657, 0.5859]}, {"w": ",", "b": [0.6825, 0.5731, 0.691, 0.5859]}, {"w": "0.", "b": [0.6994, 0.5731, 0.7163, 0.5859]}, {"w": "],", "b": [0.7331, 0.5731, 0.75, 0.5859]}, {"w": "[0.", "b": [0.2356, 0.5885, 0.2609, 0.6014]}, {"w": ",", "b": [0.2778, 0.5885, 0.2862, 0.6014]}, {"w": "1.", "b": [0.2946, 0.5885, 0.3115, 0.6014]}, {"w": ",", "b": [0.3284, 0.5885, 0.3368, 0.6014]}, {"w": "0.", "b": [0.3452, 0.5885, 0.3621, 0.6014]}, {"w": ",", "b": [0.379, 0.5885, 0.3874, 0.6014]}, {"w": "0.", "b": [0.3958, 0.5885, 0.4127, 0.6014]}, {"w": ",", "b": [0.4296, 0.5885, 0.438, 0.6014]}, {"w": "0.", "b": [0.4464, 0.5885, 0.4633, 0.6014]}, {"w": ",", "b": [0.4802, 0.5885, 0.4886, 0.6014]}, {"w": "0.", "b": [0.497, 0.5885, 0.5139, 0.6014]}, {"w": ",", "b": [0.5308, 0.5885, 0.5392, 0.6014]}, {"w": "0.", "b": [0.5476, 0.5885, 0.5645, 0.6014]}, {"w": ",", "b": [0.5814, 0.5885, 0.5898, 0.6014]}, {"w": "0.", "b": [0.5982, 0.5885, 0.6151, 0.6014]}, {"w": ",", "b": [0.6319, 0.5885, 0.6404, 0.6014]}, {"w": "0.", "b": [0.6488, 0.5885, 0.6657, 0.6014]}, {"w": ",", "b": [0.6825, 0.5885, 0.691, 0.6014]}, {"w": "0.", "b": [0.6994, 0.5885, 0.7163, 0.6014]}, {"w": "]],", "b": [0.7331, 0.5885, 0.7584, 0.6014]}, {"w": "dtype=float32)", "b": [0.2272, 0.6039, 0.3452, 0.6168]}]}, {"id": "b_6", "type": "paragraph", "text": "As you can see, for each instance the model estimates one probability per class, from class 0 to class 9. For example, for the first image it estimates that the probability of class 9 (ankle boot) is 79%, the probability of class 7 (sneaker) is 12%, the probability of class 5 (sandal) is 9%, and the other classes are negligible. In other words, it “believes” it’s footwear, probably ankle boots, but it’s not entirely sure, it might be sneakers or sandals instead. If you only care about the class with the highest estima‐ ted probability (even if that probability is quite low) then you can use the pre dict_classes() method instead:", "words": [{"w": "As", "b": [0.1428, 0.6246, 0.1649, 0.646]}, {"w": "you", "b": [0.1705, 0.6246, 0.2017, 0.646]}, {"w": "can", "b": [0.2073, 0.6246, 0.2367, 0.646]}, {"w": "see,", "b": [0.2423, 0.6246, 0.2724, 0.646]}, {"w": "for", "b": [0.278, 0.6246, 0.3025, 0.646]}, {"w": "each", "b": [0.3081, 0.6246, 0.3461, 0.646]}, {"w": "instance", "b": [0.3517, 0.6246, 0.4209, 0.646]}, {"w": "the", "b": [0.4265, 0.6246, 0.4528, 0.646]}, {"w": "model", "b": [0.4584, 0.6246, 0.5112, 0.646]}, {"w": "estimates", "b": [0.5168, 0.6246, 0.5939, 0.646]}, {"w": "one", "b": [0.5995, 0.6246, 0.6304, 0.646]}, {"w": "probability", "b": [0.636, 0.6246, 0.728, 0.646]}, {"w": "per", "b": [0.7336, 0.6246, 0.7611, 0.646]}, {"w": "class,", "b": [0.7667, 0.6246, 0.8099, 0.646]}, {"w": "from", "b": [0.8155, 0.6246, 0.8571, 0.646]}, {"w": "class", "b": [0.1429, 0.6436, 0.1814, 0.665]}, {"w": "0", "b": [0.1877, 0.6436, 0.1977, 0.665]}, {"w": "to", "b": [0.204, 0.6436, 0.221, 0.665]}, {"w": "class", "b": [0.2273, 0.6436, 0.2658, 0.665]}, {"w": "9.", "b": [0.2721, 0.6436, 0.2868, 0.665]}, {"w": "For", "b": [0.2931, 0.6436, 0.3221, 0.665]}, {"w": "example,", "b": [0.3284, 0.6436, 0.4027, 0.665]}, {"w": "for", "b": [0.409, 0.6436, 0.4335, 0.665]}, {"w": "the", "b": [0.4398, 0.6436, 0.4662, 0.665]}, {"w": "first", "b": [0.4725, 0.6436, 0.506, 0.665]}, {"w": "image", "b": [0.5123, 0.6436, 0.5627, 0.665]}, {"w": "it", "b": [0.569, 0.6436, 0.5809, 0.665]}, {"w": "estimates", "b": [0.5872, 0.6436, 0.6643, 0.665]}, {"w": "that", "b": [0.6706, 0.6436, 0.7032, 0.665]}, {"w": "the", "b": [0.7095, 0.6436, 0.7358, 0.665]}, {"w": "probability", "b": [0.7421, 0.6436, 0.8341, 0.665]}, {"w": "of", "b": [0.8404, 0.6436, 0.8571, 0.665]}, {"w": "class", "b": [0.1429, 0.6627, 0.1814, 0.6841]}, {"w": "9", "b": [0.1867, 0.6627, 0.1967, 0.6841]}, {"w": "(ankle", "b": [0.2021, 0.6627, 0.2543, 0.6841]}, {"w": "boot)", "b": [0.2597, 0.6627, 0.3051, 0.6841]}, {"w": "is", "b": [0.3104, 0.6627, 0.3237, 0.6841]}, {"w": "79%,", "b": [0.329, 0.6627, 0.3695, 0.6841]}, {"w": "the", "b": [0.3749, 0.6627, 0.4012, 0.6841]}, {"w": "probability", "b": [0.4066, 0.6627, 0.4985, 0.6841]}, {"w": "of", "b": [0.5039, 0.6627, 0.5207, 0.6841]}, {"w": "class", "b": [0.5261, 0.6627, 0.5646, 0.6841]}, {"w": "7", "b": [0.5699, 0.6627, 0.5799, 0.6841]}, {"w": "(sneaker)", "b": [0.5853, 0.6627, 0.6637, 0.6841]}, {"w": "is", "b": [0.669, 0.6627, 0.6823, 0.6841]}, {"w": "12%,", "b": [0.6876, 0.6627, 0.7281, 0.6841]}, {"w": "the", "b": [0.7335, 0.6627, 0.7598, 0.6841]}, {"w": "probability", "b": [0.7652, 0.6627, 0.8571, 0.6841]}, {"w": "of", "b": [0.1429, 0.6817, 0.1596, 0.7031]}, {"w": "class", "b": [0.1688, 0.6817, 0.2073, 0.7031]}, {"w": "5", "b": [0.2164, 0.6817, 0.2264, 0.7031]}, {"w": "(sandal)", "b": [0.2356, 0.6817, 0.3036, 0.7031]}, {"w": "is", "b": [0.3127, 0.6817, 0.326, 0.7031]}, {"w": "9%,", "b": [0.3351, 0.6817, 0.3656, 0.7031]}, {"w": "and", "b": [0.3748, 0.6817, 0.4063, 0.7031]}, {"w": "the", "b": [0.4154, 0.6817, 0.4418, 0.7031]}, {"w": "other", "b": [0.4509, 0.6817, 0.4956, 0.7031]}, {"w": "classes", "b": [0.5047, 0.6817, 0.5598, 0.7031]}, {"w": "are", "b": [0.5689, 0.6817, 0.5946, 0.7031]}, {"w": "negligible.", "b": [0.6038, 0.6817, 0.6894, 0.7031]}, {"w": "In", "b": [0.6986, 0.6817, 0.7171, 0.7031]}, {"w": "other", "b": [0.7262, 0.6817, 0.7709, 0.7031]}, {"w": "words,", "b": [0.78, 0.6817, 0.8361, 0.7031]}, {"w": "it", "b": [0.8452, 0.6817, 0.8571, 0.7031]}, {"w": "“believes”", "b": [0.1429, 0.7008, 0.2239, 0.7222]}, {"w": "it’s", "b": [0.2318, 0.7008, 0.2535, 0.7222]}, {"w": "footwear,", "b": [0.2613, 0.7008, 0.3386, 0.7222]}, {"w": "probably", "b": [0.3464, 0.7008, 0.4208, 0.7222]}, {"w": "ankle", "b": [0.4287, 0.7008, 0.4737, 0.7222]}, {"w": "boots,", "b": [0.4815, 0.7008, 0.5321, 0.7222]}, {"w": "but", "b": [0.54, 0.7008, 0.568, 0.7222]}, {"w": "it’s", "b": [0.5758, 0.7008, 0.5975, 0.7222]}, {"w": "not", "b": [0.6054, 0.7008, 0.6338, 0.7222]}, {"w": "entirely", "b": [0.6416, 0.7008, 0.7048, 0.7222]}, {"w": "sure,", "b": [0.7127, 0.7008, 0.7527, 0.7222]}, {"w": "it", "b": [0.7606, 0.7008, 0.7725, 0.7222]}, {"w": "might", "b": [0.7804, 0.7008, 0.8299, 0.7222]}, {"w": "be", "b": [0.8377, 0.7008, 0.8572, 0.7222]}, {"w": "sneakers", "b": [0.1429, 0.7198, 0.2145, 0.7412]}, {"w": "or", "b": [0.2204, 0.7198, 0.2388, 0.7412]}, {"w": "sandals", "b": [0.2448, 0.7198, 0.306, 0.7412]}, {"w": "instead.", "b": [0.312, 0.7198, 0.3767, 0.7412]}, {"w": "If", "b": [0.3827, 0.7198, 0.396, 0.7412]}, {"w": "you", "b": [0.4019, 0.7198, 0.4332, 0.7412]}, {"w": "only", "b": [0.4392, 0.7198, 0.476, 0.7412]}, {"w": "care", "b": [0.482, 0.7198, 0.5165, 0.7412]}, {"w": "about", "b": [0.5225, 0.7198, 0.5703, 0.7412]}, {"w": "the", "b": [0.5763, 0.7198, 0.6026, 0.7412]}, {"w": "class", "b": [0.6086, 0.7198, 0.6471, 0.7412]}, {"w": "with", "b": [0.6531, 0.7198, 0.6904, 0.7412]}, {"w": "the", "b": [0.6964, 0.7198, 0.7227, 0.7412]}, {"w": "highest", "b": [0.7287, 0.7198, 0.7891, 0.7412]}, {"w": "estima‐", "b": [0.7951, 0.7198, 0.8571, 0.7412]}, {"w": "ted", "b": [0.1429, 0.7397, 0.1691, 0.7612]}, {"w": "probability", "b": [0.1787, 0.7397, 0.2706, 0.7612]}, {"w": "(even", "b": [0.2802, 0.7397, 0.3261, 0.7612]}, {"w": "if", "b": [0.3357, 0.7397, 0.3475, 0.7612]}, {"w": "that", "b": [0.3571, 0.7397, 0.3897, 0.7612]}, {"w": "probability", "b": [0.3992, 0.7397, 0.4912, 0.7612]}, {"w": "is", "b": [0.5008, 0.7397, 0.514, 0.7612]}, {"w": "quite", "b": [0.5236, 0.7397, 0.5661, 0.7612]}, {"w": "low)", "b": [0.5757, 0.7397, 0.6131, 0.7612]}, {"w": "then", "b": [0.6226, 0.7397, 0.6604, 0.7612]}, {"w": "you", "b": [0.67, 0.7397, 0.7012, 0.7612]}, {"w": "can", "b": [0.7108, 0.7397, 0.7402, 0.7612]}, {"w": "use", "b": [0.7498, 0.7397, 0.7773, 0.7612]}, {"w": "the", "b": [0.7869, 0.7397, 0.8132, 0.7612]}, {"w": "pre", "b": [0.8228, 0.7429, 0.8525, 0.758]}, {"w": "dict_classes()", "b": [0.1429, 0.7629, 0.2814, 0.778]}, {"w": "method", "b": [0.2861, 0.7597, 0.3511, 0.7811]}, {"w": "instead:", "b": [0.3559, 0.7597, 0.4206, 0.7811]}]}, {"id": "b_7", "type": "paragraph", "text": ">>> y_pred = model.predict_classes(X_new) >>> y_pred array([9, 2, 1]) >>> np.array(class_names)[y_pred] array(['Ankle boot', 'Pullover', 'Trouser'], dtype='>>", "b": [0.1766, 0.7917, 0.2019, 0.8045]}, {"w": "y_pred", "b": [0.2103, 0.7917, 0.2609, 0.8045]}, {"w": "=", "b": [0.2693, 0.7917, 0.2778, 0.8045]}, {"w": "model.predict_classes(X_new)", "b": [0.2862, 0.7917, 0.5223, 0.8045]}, {"w": ">>>", "b": [0.1766, 0.8071, 0.2019, 0.8199]}, {"w": "y_pred", "b": [0.2103, 0.8071, 0.2609, 0.8199]}, {"w": "array([9,", "b": [0.1766, 0.8225, 0.2525, 0.8354]}, {"w": "2,", "b": [0.2609, 0.8225, 0.2778, 0.8354]}, {"w": "1])", "b": [0.2862, 0.8225, 0.3115, 0.8354]}, {"w": ">>>", "b": [0.1766, 0.8379, 0.2019, 0.8508]}, {"w": "np.array(class_names)[y_pred]", "b": [0.2103, 0.8379, 0.4549, 0.8508]}, {"w": "array(['Ankle", "b": [0.1766, 0.8533, 0.2862, 0.8662]}, {"w": "boot',", "b": [0.2946, 0.8533, 0.3452, 0.8662]}, {"w": "'Pullover',", "b": [0.3537, 0.8533, 0.4464, 0.8662]}, {"w": "'Trouser'],", "b": [0.4549, 0.8533, 0.5476, 0.8662]}, {"w": "dtype='>> y_new = y_test[:3] >>> y_new array([9, 2, 1])", "words": [{"w": ">>>", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "y_new", "b": [0.2103, 0.0829, 0.2525, 0.0958]}, {"w": "=", "b": [0.2609, 0.0829, 0.2693, 0.0958]}, {"w": "y_test[:3]", "b": [0.2778, 0.0829, 0.3621, 0.0958]}, {"w": ">>>", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "y_new", "b": [0.2103, 0.0983, 0.2525, 0.1112]}, {"w": "array([9,", "b": [0.1766, 0.1138, 0.2525, 0.1266]}, {"w": "2,", "b": [0.2609, 0.1138, 0.2778, 0.1266]}, {"w": "1])", "b": [0.2862, 0.1138, 0.3115, 0.1266]}]}, {"id": "b_1", "type": "paragraph", "text": "Now you know how to build, train, evaluate and use a classification MLP using the Sequential API. But what about regression?", "words": [{"w": "Now", "b": [0.1429, 0.1344, 0.1827, 0.1558]}, {"w": "you", "b": [0.1894, 0.1344, 0.2206, 0.1558]}, {"w": "know", "b": [0.2273, 0.1344, 0.274, 0.1558]}, {"w": "how", "b": [0.2806, 0.1344, 0.3167, 0.1558]}, {"w": "to", "b": [0.3233, 0.1344, 0.3403, 0.1558]}, {"w": "build,", "b": [0.347, 0.1344, 0.3952, 0.1558]}, {"w": "train,", "b": [0.4019, 0.1344, 0.4469, 0.1558]}, {"w": "evaluate", "b": [0.4536, 0.1344, 0.5215, 0.1558]}, {"w": "and", "b": [0.5282, 0.1344, 0.5597, 0.1558]}, {"w": "use", "b": [0.5664, 0.1344, 0.594, 0.1558]}, {"w": "a", "b": [0.6006, 0.1344, 0.6098, 0.1558]}, {"w": "classification", "b": [0.6165, 0.1344, 0.7238, 0.1558]}, {"w": "MLP", "b": [0.7305, 0.1344, 0.772, 0.1558]}, {"w": "using", "b": [0.7787, 0.1344, 0.8241, 0.1558]}, {"w": "the", "b": [0.8308, 0.1344, 0.8571, 0.1558]}, {"w": "Sequential", "b": [0.1429, 0.1534, 0.2295, 0.1749]}, {"w": "API.", "b": [0.2342, 0.1534, 0.2722, 0.1749]}, {"w": "But", "b": [0.2769, 0.1534, 0.3066, 0.1749]}, {"w": "what", "b": [0.3113, 0.1534, 0.3518, 0.1749]}, {"w": "about", "b": [0.3566, 0.1534, 0.4043, 0.1749]}, {"w": "regression?", "b": [0.4091, 0.1534, 0.5028, 0.1749]}]}, {"id": "b_2", "type": "paragraph", "text": "Building a Regression MLP Using the Sequential API", "words": [{"w": "Building", "b": [0.1428, 0.1876, 0.23, 0.2162]}, {"w": "a", "b": [0.2349, 0.1876, 0.2473, 0.2162]}, {"w": "Regression", "b": [0.2523, 0.1876, 0.3647, 0.2162]}, {"w": "MLP", "b": [0.3697, 0.1876, 0.4139, 0.2162]}, {"w": "Using", "b": [0.4189, 0.1876, 0.4769, 0.2162]}, {"w": "the", "b": [0.4818, 0.1876, 0.5167, 0.2162]}, {"w": "Sequential", "b": [0.5216, 0.1876, 0.6327, 0.2162]}, {"w": "API", "b": [0.6377, 0.1876, 0.6722, 0.2162]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s switch to the California housing problem and tackle it using a regression neural network. For simplicity, we will use Scikit-Learn’s fetch_california_housing() function to load the data: this dataset is simpler than the one we used in Chapter 2, since it contains only numerical features (there is no ocean_proximity feature), and there is no missing value. After loading the data, we split it into a training set, a vali‐ dation set and a test set, and we scale all the features:", "words": [{"w": "Let’s", "b": [0.1429, 0.2221, 0.179, 0.2435]}, {"w": "switch", "b": [0.1846, 0.2221, 0.2384, 0.2435]}, {"w": "to", "b": [0.2439, 0.2221, 0.2609, 0.2435]}, {"w": "the", "b": [0.2665, 0.2221, 0.2928, 0.2435]}, {"w": "California", "b": [0.2983, 0.2221, 0.3828, 0.2435]}, {"w": "housing", "b": [0.3884, 0.2221, 0.4556, 0.2435]}, {"w": "problem", "b": [0.4611, 0.2221, 0.5322, 0.2435]}, {"w": "and", "b": [0.5377, 0.2221, 0.5693, 0.2435]}, {"w": "tackle", "b": [0.5748, 0.2221, 0.6236, 0.2435]}, {"w": "it", "b": [0.6291, 0.2221, 0.6411, 0.2435]}, {"w": "using", "b": [0.6466, 0.2221, 0.6921, 0.2435]}, {"w": "a", "b": [0.6976, 0.2221, 0.7068, 0.2435]}, {"w": "regression", "b": [0.7123, 0.2221, 0.7981, 0.2435]}, {"w": "neural", "b": [0.8037, 0.2221, 0.8571, 0.2435]}, {"w": "network.", "b": [0.1429, 0.242, 0.2172, 0.2634]}, {"w": "For", "b": [0.2281, 0.242, 0.2571, 0.2634]}, {"w": "simplicity,", "b": [0.268, 0.242, 0.3532, 0.2634]}, {"w": "we", "b": [0.3641, 0.242, 0.3873, 0.2634]}, {"w": "will", "b": [0.3982, 0.242, 0.4286, 0.2634]}, {"w": "use", "b": [0.4395, 0.242, 0.4671, 0.2634]}, {"w": "Scikit-Learn’s", "b": [0.478, 0.242, 0.5889, 0.2634]}, {"w": "fetch_california_housing()", "b": [0.5999, 0.2452, 0.8571, 0.2603]}, {"w": "function", "b": [0.1429, 0.2611, 0.2142, 0.2825]}, {"w": "to", "b": [0.2207, 0.2611, 0.2376, 0.2825]}, {"w": "load", "b": [0.2441, 0.2611, 0.2801, 0.2825]}, {"w": "the", "b": [0.2865, 0.2611, 0.3128, 0.2825]}, {"w": "data:", "b": [0.3193, 0.2611, 0.3593, 0.2825]}, {"w": "this", "b": [0.3657, 0.2611, 0.3964, 0.2825]}, {"w": "dataset", "b": [0.4028, 0.2611, 0.4609, 0.2825]}, {"w": "is", "b": [0.4673, 0.2611, 0.4805, 0.2825]}, {"w": "simpler", "b": [0.4869, 0.2611, 0.5496, 0.2825]}, {"w": "than", "b": [0.556, 0.2611, 0.594, 0.2825]}, {"w": "the", "b": [0.6005, 0.2611, 0.6268, 0.2825]}, {"w": "one", "b": [0.6332, 0.2611, 0.6641, 0.2825]}, {"w": "we", "b": [0.6705, 0.2611, 0.6936, 0.2825]}, {"w": "used", "b": [0.7, 0.2611, 0.7386, 0.2825]}, {"w": "in", "b": [0.745, 0.2611, 0.762, 0.2825]}, {"w": "Chapter", "b": [0.7684, 0.2611, 0.836, 0.2825]}, {"w": "2,", "b": [0.8424, 0.2611, 0.8571, 0.2825]}, {"w": "since", "b": [0.1429, 0.281, 0.1852, 0.3024]}, {"w": "it", "b": [0.1913, 0.281, 0.2032, 0.3024]}, {"w": "contains", "b": [0.2094, 0.281, 0.28, 0.3024]}, {"w": "only", "b": [0.2861, 0.281, 0.323, 0.3024]}, {"w": "numerical", "b": [0.3291, 0.281, 0.4136, 0.3024]}, {"w": "features", "b": [0.4198, 0.281, 0.4852, 0.3024]}, {"w": "(there", "b": [0.4913, 0.281, 0.5415, 0.3024]}, {"w": "is", "b": [0.5476, 0.281, 0.5608, 0.3024]}, {"w": "no", "b": [0.567, 0.281, 0.589, 0.3024]}, {"w": "ocean_proximity", "b": [0.5952, 0.2842, 0.7436, 0.2993]}, {"w": "feature),", "b": [0.7497, 0.281, 0.8195, 0.3024]}, {"w": "and", "b": [0.8256, 0.281, 0.8572, 0.3024]}, {"w": "there", "b": [0.1429, 0.3001, 0.1858, 0.3215]}, {"w": "is", "b": [0.1914, 0.3001, 0.2046, 0.3215]}, {"w": "no", "b": [0.2103, 0.3001, 0.2323, 0.3215]}, {"w": "missing", "b": [0.2379, 0.3001, 0.3026, 0.3215]}, {"w": "value.", "b": [0.3082, 0.3001, 0.357, 0.3215]}, {"w": "After", "b": [0.3626, 0.3001, 0.4061, 0.3215]}, {"w": "loading", "b": [0.4117, 0.3001, 0.4745, 0.3215]}, {"w": "the", "b": [0.4802, 0.3001, 0.5065, 0.3215]}, {"w": "data,", "b": [0.5121, 0.3001, 0.5521, 0.3215]}, {"w": "we", "b": [0.5578, 0.3001, 0.5809, 0.3215]}, {"w": "split", "b": [0.5865, 0.3001, 0.6223, 0.3215]}, {"w": "it", "b": [0.6279, 0.3001, 0.6399, 0.3215]}, {"w": "into", "b": [0.6455, 0.3001, 0.6791, 0.3215]}, {"w": "a", "b": [0.6847, 0.3001, 0.6938, 0.3215]}, {"w": "training", "b": [0.6995, 0.3001, 0.7664, 0.3215]}, {"w": "set,", "b": [0.7721, 0.3001, 0.7997, 0.3215]}, {"w": "a", "b": [0.8053, 0.3001, 0.8144, 0.3215]}, {"w": "vali‐", "b": [0.8201, 0.3001, 0.8571, 0.3215]}, {"w": "dation", "b": [0.1429, 0.3191, 0.1966, 0.3405]}, {"w": "set", "b": [0.2013, 0.3191, 0.2241, 0.3405]}, {"w": "and", "b": [0.2289, 0.3191, 0.2604, 0.3405]}, {"w": "a", "b": [0.2651, 0.3191, 0.2743, 0.3405]}, {"w": "test", "b": [0.279, 0.3191, 0.3082, 0.3405]}, {"w": "set,", "b": [0.313, 0.3191, 0.3406, 0.3405]}, {"w": "and", "b": [0.3453, 0.3191, 0.3768, 0.3405]}, {"w": "we", "b": [0.3816, 0.3191, 0.4047, 0.3405]}, {"w": "scale", "b": [0.4094, 0.3191, 0.4491, 0.3405]}, {"w": "all", "b": [0.4539, 0.3191, 0.4736, 0.3405]}, {"w": "the", "b": [0.4783, 0.3191, 0.5046, 0.3405]}, {"w": "features:", "b": [0.5094, 0.3191, 0.5795, 0.3405]}]}, {"id": "b_4", "type": "paragraph", "text": "from sklearn.datasets import fetch_california_housing from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler", "words": [{"w": "from", "b": [0.1766, 0.3511, 0.2103, 0.3639]}, {"w": "sklearn.datasets", "b": [0.2187, 0.3511, 0.3537, 0.3639]}, {"w": "import", "b": [0.3621, 0.3511, 0.4127, 0.3639]}, {"w": "fetch_california_housing", "b": [0.4211, 0.3511, 0.6235, 0.3639]}, {"w": "from", "b": [0.1766, 0.3665, 0.2103, 0.3794]}, {"w": "sklearn.model_selection", "b": [0.2187, 0.3665, 0.4127, 0.3794]}, {"w": "import", "b": [0.4211, 0.3665, 0.4717, 0.3794]}, {"w": "train_test_split", "b": [0.4802, 0.3665, 0.6151, 0.3794]}, {"w": "from", "b": [0.1766, 0.3819, 0.2103, 0.3948]}, {"w": "sklearn.preprocessing", "b": [0.2187, 0.3819, 0.3958, 0.3948]}, {"w": "import", "b": [0.4043, 0.3819, 0.4549, 0.3948]}, {"w": "StandardScaler", "b": [0.4633, 0.3819, 0.5813, 0.3948]}]}, {"id": "b_5", "type": "equation", "text": "housing = fetch_california_housing()", "words": [{"w": "housing", "b": [0.1766, 0.4128, 0.2356, 0.4256]}, {"w": "=", "b": [0.244, 0.4128, 0.2525, 0.4256]}, {"w": "fetch_california_housing()", "b": [0.2609, 0.4128, 0.4802, 0.4256]}]}, {"id": "b_6", "type": "paragraph", "text": "X_train_full, X_test, y_train_full, y_test = train_test_split( housing.data, housing.target) X_train, X_valid, y_train, y_valid = train_test_split( X_train_full, y_train_full)", "words": [{"w": "X_train_full,", "b": [0.1766, 0.4436, 0.2862, 0.4565]}, {"w": "X_test,", "b": [0.2946, 0.4436, 0.3537, 0.4565]}, {"w": "y_train_full,", "b": [0.3621, 0.4436, 0.4717, 0.4565]}, {"w": "y_test", "b": [0.4802, 0.4436, 0.5307, 0.4565]}, {"w": "=", "b": [0.5392, 0.4436, 0.5476, 0.4565]}, {"w": "train_test_split(", "b": [0.556, 0.4436, 0.6994, 0.4565]}, {"w": "housing.data,", "b": [0.2103, 0.459, 0.3199, 0.4719]}, {"w": "housing.target)", "b": [0.3284, 0.459, 0.4549, 0.4719]}, {"w": "X_train,", "b": [0.1766, 0.4744, 0.244, 0.4873]}, {"w": "X_valid,", "b": [0.2525, 0.4744, 0.3199, 0.4873]}, {"w": "y_train,", "b": [0.3284, 0.4744, 0.3958, 0.4873]}, {"w": "y_valid", "b": [0.4043, 0.4744, 0.4633, 0.4873]}, {"w": "=", "b": [0.4717, 0.4744, 0.4802, 0.4873]}, {"w": "train_test_split(", "b": [0.4886, 0.4744, 0.6319, 0.4873]}, {"w": "X_train_full,", "b": [0.2103, 0.4899, 0.3199, 0.5027]}, {"w": "y_train_full)", "b": [0.3284, 0.4899, 0.438, 0.5027]}]}, {"id": "b_7", "type": "paragraph", "text": "scaler = StandardScaler() X_train_scaled = scaler.fit_transform(X_train) X_valid_scaled = scaler.transform(X_valid) X_test_scaled = scaler.transform(X_test)", "words": [{"w": "scaler", "b": [0.1766, 0.5207, 0.2272, 0.5336]}, {"w": "=", "b": [0.2356, 0.5207, 0.244, 0.5336]}, {"w": "StandardScaler()", "b": [0.2525, 0.5207, 0.3874, 0.5336]}, {"w": "X_train_scaled", "b": [0.1766, 0.5361, 0.2946, 0.549]}, {"w": "=", "b": [0.3031, 0.5361, 0.3115, 0.549]}, {"w": "scaler.fit_transform(X_train)", "b": [0.3199, 0.5361, 0.5645, 0.549]}, {"w": "X_valid_scaled", "b": [0.1766, 0.5515, 0.2946, 0.5644]}, {"w": "=", "b": [0.3031, 0.5515, 0.3115, 0.5644]}, {"w": "scaler.transform(X_valid)", "b": [0.3199, 0.5515, 0.5307, 0.5644]}, {"w": "X_test_scaled", "b": [0.1766, 0.567, 0.2862, 0.5798]}, {"w": "=", "b": [0.2946, 0.567, 0.3031, 0.5798]}, {"w": "scaler.transform(X_test)", "b": [0.3115, 0.567, 0.5139, 0.5798]}]}, {"id": "b_8", "type": "paragraph", "text": "Building, training, evaluating and using a regression MLP using the Sequential API to make predictions is quite similar to what we did for classification. The main differ‐ ences are the fact that the output layer has a single neuron (since we only want to predict a single value) and uses no activation function, and the loss function is the mean squared error. Since the dataset is quite noisy, we just use a single hidden layer with fewer neurons than before, to avoid overfitting:", "words": [{"w": "Building,", "b": [0.1429, 0.5876, 0.2195, 0.609]}, {"w": "training,", "b": [0.2243, 0.5876, 0.296, 0.609]}, {"w": "evaluating", "b": [0.3009, 0.5876, 0.3867, 0.609]}, {"w": "and", "b": [0.3915, 0.5876, 0.4231, 0.609]}, {"w": "using", "b": [0.4279, 0.5876, 0.4733, 0.609]}, {"w": "a", "b": [0.4782, 0.5876, 0.4873, 0.609]}, {"w": "regression", "b": [0.4922, 0.5876, 0.578, 0.609]}, {"w": "MLP", "b": [0.5828, 0.5876, 0.6243, 0.609]}, {"w": "using", "b": [0.6292, 0.5876, 0.6746, 0.609]}, {"w": "the", "b": [0.6794, 0.5876, 0.7058, 0.609]}, {"w": "Sequential", "b": [0.7106, 0.5876, 0.7973, 0.609]}, {"w": "API", "b": [0.8021, 0.5876, 0.8353, 0.609]}, {"w": "to", "b": [0.8402, 0.5876, 0.8571, 0.609]}, {"w": "make", "b": [0.1429, 0.6066, 0.1883, 0.6281]}, {"w": "predictions", "b": [0.1949, 0.6066, 0.2894, 0.6281]}, {"w": "is", "b": [0.2961, 0.6066, 0.3093, 0.6281]}, {"w": "quite", "b": [0.316, 0.6066, 0.3585, 0.6281]}, {"w": "similar", "b": [0.3652, 0.6066, 0.4232, 0.6281]}, {"w": "to", "b": [0.4299, 0.6066, 0.4469, 0.6281]}, {"w": "what", "b": [0.4536, 0.6066, 0.4941, 0.6281]}, {"w": "we", "b": [0.5008, 0.6066, 0.5239, 0.6281]}, {"w": "did", "b": [0.5306, 0.6066, 0.5581, 0.6281]}, {"w": "for", "b": [0.5648, 0.6066, 0.5894, 0.6281]}, {"w": "classification.", "b": [0.596, 0.6066, 0.7082, 0.6281]}, {"w": "The", "b": [0.7148, 0.6066, 0.7477, 0.6281]}, {"w": "main", "b": [0.7544, 0.6066, 0.7975, 0.6281]}, {"w": "differ‐", "b": [0.8042, 0.6066, 0.8571, 0.6281]}, {"w": "ences", "b": [0.1429, 0.6257, 0.1884, 0.6471]}, {"w": "are", "b": [0.1957, 0.6257, 0.2214, 0.6471]}, {"w": "the", "b": [0.2287, 0.6257, 0.2551, 0.6471]}, {"w": "fact", "b": [0.2624, 0.6257, 0.2929, 0.6471]}, {"w": "that", "b": [0.3002, 0.6257, 0.3328, 0.6471]}, {"w": "the", "b": [0.3401, 0.6257, 0.3664, 0.6471]}, {"w": "output", "b": [0.3737, 0.6257, 0.4301, 0.6471]}, {"w": "layer", "b": [0.4374, 0.6257, 0.4776, 0.6471]}, {"w": "has", "b": [0.4849, 0.6257, 0.5128, 0.6471]}, {"w": "a", "b": [0.5201, 0.6257, 0.5292, 0.6471]}, {"w": "single", "b": [0.5365, 0.6257, 0.585, 0.6471]}, {"w": "neuron", "b": [0.5923, 0.6257, 0.6534, 0.6471]}, {"w": "(since", "b": [0.6607, 0.6257, 0.7102, 0.6471]}, {"w": "we", "b": [0.7175, 0.6257, 0.7406, 0.6471]}, {"w": "only", "b": [0.7479, 0.6257, 0.7848, 0.6471]}, {"w": "want", "b": [0.7921, 0.6257, 0.8329, 0.6471]}, {"w": "to", "b": [0.8402, 0.6257, 0.8571, 0.6471]}, {"w": "predict", "b": [0.1429, 0.6447, 0.2021, 0.6662]}, {"w": "a", "b": [0.2092, 0.6447, 0.2183, 0.6662]}, {"w": "single", "b": [0.2254, 0.6447, 0.2739, 0.6662]}, {"w": "value)", "b": [0.281, 0.6447, 0.3322, 0.6662]}, {"w": "and", "b": [0.3392, 0.6447, 0.3708, 0.6662]}, {"w": "uses", "b": [0.3779, 0.6447, 0.4131, 0.6662]}, {"w": "no", "b": [0.4201, 0.6447, 0.4422, 0.6662]}, {"w": "activation", "b": [0.4492, 0.6447, 0.5315, 0.6662]}, {"w": "function,", "b": [0.5386, 0.6447, 0.6147, 0.6662]}, {"w": "and", "b": [0.6218, 0.6447, 0.6533, 0.6662]}, {"w": "the", "b": [0.6604, 0.6447, 0.6867, 0.6662]}, {"w": "loss", "b": [0.6938, 0.6447, 0.725, 0.6662]}, {"w": "function", "b": [0.732, 0.6447, 0.8034, 0.6662]}, {"w": "is", "b": [0.8105, 0.6447, 0.8237, 0.6662]}, {"w": "the", "b": [0.8308, 0.6447, 0.8572, 0.6662]}, {"w": "mean", "b": [0.1429, 0.6638, 0.1893, 0.6852]}, {"w": "squared", "b": [0.195, 0.6638, 0.2611, 0.6852]}, {"w": "error.", "b": [0.2667, 0.6638, 0.3128, 0.6852]}, {"w": "Since", "b": [0.3185, 0.6638, 0.363, 0.6852]}, {"w": "the", "b": [0.3687, 0.6638, 0.395, 0.6852]}, {"w": "dataset", "b": [0.4007, 0.6638, 0.4588, 0.6852]}, {"w": "is", "b": [0.4645, 0.6638, 0.4777, 0.6852]}, {"w": "quite", "b": [0.4834, 0.6638, 0.5259, 0.6852]}, {"w": "noisy,", "b": [0.5315, 0.6638, 0.5796, 0.6852]}, {"w": "we", "b": [0.5853, 0.6638, 0.6084, 0.6852]}, {"w": "just", "b": [0.6141, 0.6638, 0.6444, 0.6852]}, {"w": "use", "b": [0.6501, 0.6638, 0.6777, 0.6852]}, {"w": "a", "b": [0.6833, 0.6638, 0.6925, 0.6852]}, {"w": "single", "b": [0.6982, 0.6638, 0.7467, 0.6852]}, {"w": "hidden", "b": [0.7523, 0.6638, 0.8113, 0.6852]}, {"w": "layer", "b": [0.817, 0.6638, 0.8571, 0.6852]}, {"w": "with", "b": [0.1429, 0.6828, 0.1802, 0.7042]}, {"w": "fewer", "b": [0.1849, 0.6828, 0.2308, 0.7042]}, {"w": "neurons", "b": [0.2355, 0.6828, 0.3042, 0.7042]}, {"w": "than", "b": [0.309, 0.6828, 0.347, 0.7042]}, {"w": "before,", "b": [0.3517, 0.6828, 0.4093, 0.7042]}, {"w": "to", "b": [0.414, 0.6828, 0.431, 0.7042]}, {"w": "avoid", "b": [0.4357, 0.6828, 0.4813, 0.7042]}, {"w": "overfitting:", "b": [0.4861, 0.6828, 0.5789, 0.7042]}]}, {"id": "b_9", "type": "paragraph", "text": "model = keras.models.Sequential([ keras.layers.Dense(30, activation=\"relu\", input_shape=X_train.shape[1:]), keras.layers.Dense(1) ]) model.compile(loss=\"mean_squared_error\", optimizer=\"sgd\") history = model.fit(X_train, y_train, epochs=20, validation_data=(X_valid, y_valid)) mse_test = model.evaluate(X_test, y_test) X_new = X_test[:3] # pretend these are new instances y_pred = model.predict(X_new)", "words": [{"w": "model", "b": [0.1766, 0.7148, 0.2188, 0.7277]}, {"w": "=", "b": [0.2272, 0.7148, 0.2356, 0.7277]}, {"w": "keras.models.Sequential([", "b": [0.244, 0.7148, 0.4549, 0.7277]}, {"w": "keras.layers.Dense(30,", "b": [0.2103, 0.7302, 0.3958, 0.7431]}, {"w": "activation=\"relu\",", "b": [0.4043, 0.7302, 0.5561, 0.7431]}, {"w": "input_shape=X_train.shape[1:]),", "b": [0.5645, 0.7302, 0.8259, 0.7431]}, {"w": "keras.layers.Dense(1)", "b": [0.2103, 0.7456, 0.3874, 0.7585]}, {"w": "])", "b": [0.1766, 0.7611, 0.1935, 0.7739]}, {"w": "model.compile(loss=\"mean_squared_error\",", "b": [0.1766, 0.7765, 0.5139, 0.7893]}, {"w": "optimizer=\"sgd\")", "b": [0.5223, 0.7765, 0.6572, 0.7893]}, {"w": "history", "b": [0.1766, 0.7919, 0.2356, 0.8048]}, {"w": "=", "b": [0.244, 0.7919, 0.2525, 0.8048]}, {"w": "model.fit(X_train,", "b": [0.2609, 0.7919, 0.4127, 0.8048]}, {"w": "y_train,", "b": [0.4211, 0.7919, 0.4886, 0.8048]}, {"w": "epochs=20,", "b": [0.497, 0.7919, 0.5814, 0.8048]}, {"w": "validation_data=(X_valid,", "b": [0.3452, 0.8073, 0.5561, 0.8202]}, {"w": "y_valid))", "b": [0.5645, 0.8073, 0.6404, 0.8202]}, {"w": "mse_test", "b": [0.1766, 0.8227, 0.244, 0.8356]}, {"w": "=", "b": [0.2525, 0.8227, 0.2609, 0.8356]}, {"w": "model.evaluate(X_test,", "b": [0.2693, 0.8227, 0.4549, 0.8356]}, {"w": "y_test)", "b": [0.4633, 0.8227, 0.5223, 0.8356]}, {"w": "X_new", "b": [0.1766, 0.8382, 0.2188, 0.851]}, {"w": "=", "b": [0.2272, 0.8382, 0.2356, 0.851]}, {"w": "X_test[:3]", "b": [0.244, 0.8382, 0.3284, 0.851]}, {"w": "#", "b": [0.3368, 0.8382, 0.3452, 0.851]}, {"w": "pretend", "b": [0.3537, 0.8382, 0.4127, 0.851]}, {"w": "these", "b": [0.4211, 0.8382, 0.4633, 0.851]}, {"w": "are", "b": [0.4717, 0.8382, 0.497, 0.851]}, {"w": "new", "b": [0.5055, 0.8382, 0.5308, 0.851]}, {"w": "instances", "b": [0.5392, 0.8382, 0.6151, 0.851]}, {"w": "y_pred", "b": [0.1766, 0.8536, 0.2272, 0.8664]}, {"w": "=", "b": [0.2356, 0.8536, 0.244, 0.8664]}, {"w": "model.predict(X_new)", "b": [0.2525, 0.8536, 0.4211, 0.8664]}]}, {"id": "b_10", "type": "paragraph", "text": "Implementing MLPs with Keras | 303", "words": [{"w": "Implementing", "b": [0.6126, 0.9225, 0.6972, 0.9388]}, {"w": "MLPs", "b": [0.7001, 0.9225, 0.7308, 0.9388]}, {"w": "with", "b": [0.7336, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "303", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 330, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "14 “Wide & Deep Learning for Recommender Systems,” Heng-Tze Cheng et al. (2016).", "words": [{"w": "14", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Wide", "b": [0.1587, 0.8749, 0.1992, 0.8912]}, {"w": "&", "b": [0.2028, 0.8749, 0.2141, 0.8912]}, {"w": "Deep", "b": [0.2177, 0.8749, 0.2512, 0.8912]}, {"w": "Learning", "b": [0.2548, 0.8749, 0.312, 0.8912]}, {"w": "for", "b": [0.3156, 0.8749, 0.3342, 0.8912]}, {"w": "Recommender", "b": [0.3378, 0.8749, 0.4317, 0.8912]}, {"w": "Systems,”", "b": [0.4353, 0.8749, 0.4941, 0.8912]}, {"w": "Heng-Tze", "b": [0.4977, 0.8749, 0.5601, 0.8912]}, {"w": "Cheng", "b": [0.5637, 0.8749, 0.6056, 0.8912]}, {"w": "et", "b": [0.6092, 0.8749, 0.6208, 0.8912]}, {"w": "al.", "b": [0.6244, 0.8749, 0.639, 0.8912]}, {"w": "(2016).", "b": [0.6426, 0.8749, 0.6877, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "As you can see, the Sequential API is quite easy to use. However, although sequential models are extremely common, it is sometimes useful to build neural networks with more complex topologies, or with multiple inputs or outputs. For this purpose, Keras offers the Functional API.", "words": [{"w": "As", "b": [0.1429, 0.0791, 0.1649, 0.1005]}, {"w": "you", "b": [0.1704, 0.0791, 0.2017, 0.1005]}, {"w": "can", "b": [0.2072, 0.0791, 0.2366, 0.1005]}, {"w": "see,", "b": [0.2421, 0.0791, 0.2722, 0.1005]}, {"w": "the", "b": [0.2777, 0.0791, 0.3041, 0.1005]}, {"w": "Sequential", "b": [0.3096, 0.0791, 0.3962, 0.1005]}, {"w": "API", "b": [0.4018, 0.0791, 0.435, 0.1005]}, {"w": "is", "b": [0.4405, 0.0791, 0.4537, 0.1005]}, {"w": "quite", "b": [0.4593, 0.0791, 0.5018, 0.1005]}, {"w": "easy", "b": [0.5073, 0.0791, 0.5425, 0.1005]}, {"w": "to", "b": [0.548, 0.0791, 0.565, 0.1005]}, {"w": "use.", "b": [0.5705, 0.0791, 0.6028, 0.1005]}, {"w": "However,", "b": [0.6084, 0.0791, 0.6872, 0.1005]}, {"w": "although", "b": [0.6927, 0.0791, 0.7672, 0.1005]}, {"w": "sequential", "b": [0.7727, 0.0791, 0.8572, 0.1005]}, {"w": "models", "b": [0.1429, 0.0981, 0.2033, 0.1195]}, {"w": "are", "b": [0.2093, 0.0981, 0.235, 0.1195]}, {"w": "extremely", "b": [0.241, 0.0981, 0.3234, 0.1195]}, {"w": "common,", "b": [0.3294, 0.0981, 0.4098, 0.1195]}, {"w": "it", "b": [0.4158, 0.0981, 0.4277, 0.1195]}, {"w": "is", "b": [0.4337, 0.0981, 0.4469, 0.1195]}, {"w": "sometimes", "b": [0.4529, 0.0981, 0.5426, 0.1195]}, {"w": "useful", "b": [0.5486, 0.0981, 0.5987, 0.1195]}, {"w": "to", "b": [0.6047, 0.0981, 0.6216, 0.1195]}, {"w": "build", "b": [0.6276, 0.0981, 0.6711, 0.1195]}, {"w": "neural", "b": [0.6771, 0.0981, 0.7306, 0.1195]}, {"w": "networks", "b": [0.7366, 0.0981, 0.8138, 0.1195]}, {"w": "with", "b": [0.8198, 0.0981, 0.8571, 0.1195]}, {"w": "more", "b": [0.1429, 0.1172, 0.1871, 0.1386]}, {"w": "complex", "b": [0.1924, 0.1172, 0.2634, 0.1386]}, {"w": "topologies,", "b": [0.2687, 0.1172, 0.3597, 0.1386]}, {"w": "or", "b": [0.365, 0.1172, 0.3834, 0.1386]}, {"w": "with", "b": [0.3887, 0.1172, 0.426, 0.1386]}, {"w": "multiple", "b": [0.4313, 0.1172, 0.5013, 0.1386]}, {"w": "inputs", "b": [0.5066, 0.1172, 0.5591, 0.1386]}, {"w": "or", "b": [0.5644, 0.1172, 0.5828, 0.1386]}, {"w": "outputs.", "b": [0.5881, 0.1172, 0.6569, 0.1386]}, {"w": "For", "b": [0.6622, 0.1172, 0.6911, 0.1386]}, {"w": "this", "b": [0.6964, 0.1172, 0.7271, 0.1386]}, {"w": "purpose,", "b": [0.7324, 0.1172, 0.8049, 0.1386]}, {"w": "Keras", "b": [0.8102, 0.1172, 0.8571, 0.1386]}, {"w": "offers", "b": [0.1428, 0.1362, 0.19, 0.1576]}, {"w": "the", "b": [0.1948, 0.1362, 0.2211, 0.1576]}, {"w": "Functional", "b": [0.2258, 0.1362, 0.3161, 0.1576]}, {"w": "API.", "b": [0.3208, 0.1362, 0.3588, 0.1576]}]}, {"id": "b_2", "type": "paragraph", "text": "Building Complex Models Using the Functional API", "words": [{"w": "Building", "b": [0.1429, 0.1704, 0.23, 0.1989]}, {"w": "Complex", "b": [0.2349, 0.1704, 0.324, 0.1989]}, {"w": "Models", "b": [0.329, 0.1704, 0.403, 0.1989]}, {"w": "Using", "b": [0.408, 0.1704, 0.466, 0.1989]}, {"w": "the", "b": [0.4709, 0.1704, 0.5058, 0.1989]}, {"w": "Functional", "b": [0.5107, 0.1704, 0.6198, 0.1989]}, {"w": "API", "b": [0.6247, 0.1704, 0.6593, 0.1989]}]}, {"id": "b_3", "type": "paragraph", "text": "One example of a non-sequential neural network is a Wide & Deep neural network. This neural network architecture was introduced in a 2016 paper by Heng-Tze Cheng et al.14. It connects all or part of the inputs directly to the output layer, as shown in Figure 10-13. This architecture makes it possible for the neural network to learn both deep patterns (using the deep path) and simple rules (through the short path). In contrast, a regular MLP forces all the data to flow through the full stack of layers, thus simple patterns in the data may end up being distorted by this sequence of transfor‐ mations.", "words": [{"w": "One", "b": [0.1429, 0.2048, 0.1787, 0.2263]}, {"w": "example", "b": [0.1851, 0.2048, 0.2547, 0.2263]}, {"w": "of", "b": [0.2611, 0.2048, 0.2779, 0.2263]}, {"w": "a", "b": [0.2844, 0.2048, 0.2935, 0.2263]}, {"w": "non-sequential", "b": [0.3, 0.2048, 0.4252, 0.2263]}, {"w": "neural", "b": [0.4317, 0.2048, 0.4852, 0.2263]}, {"w": "network", "b": [0.4916, 0.2048, 0.5612, 0.2263]}, {"w": "is", "b": [0.5676, 0.2048, 0.5809, 0.2263]}, {"w": "a", "b": [0.5873, 0.2048, 0.5965, 0.2263]}, {"w": "Wide", "b": [0.6029, 0.2046, 0.6461, 0.2263]}, {"w": "&", "b": [0.6526, 0.2046, 0.6685, 0.2263]}, {"w": "Deep", "b": [0.675, 0.2046, 0.7165, 0.2263]}, {"w": "neural", "b": [0.7229, 0.2048, 0.7764, 0.2263]}, {"w": "network.", "b": [0.7828, 0.2048, 0.8572, 0.2263]}, {"w": "This", "b": [0.1429, 0.2239, 0.1801, 0.2453]}, {"w": "neural", "b": [0.1851, 0.2239, 0.2385, 0.2453]}, {"w": "network", "b": [0.2436, 0.2239, 0.3131, 0.2453]}, {"w": "architecture", "b": [0.3182, 0.2239, 0.4186, 0.2453]}, {"w": "was", "b": [0.4236, 0.2239, 0.4547, 0.2453]}, {"w": "introduced", "b": [0.4597, 0.2239, 0.5517, 0.2453]}, {"w": "in", "b": [0.5567, 0.2239, 0.5737, 0.2453]}, {"w": "a", "b": [0.5787, 0.2239, 0.5879, 0.2453]}, {"w": "2016", "b": [0.5929, 0.2239, 0.6329, 0.2453]}, {"w": "paper", "b": [0.6376, 0.2239, 0.6848, 0.2453]}, {"w": "by", "b": [0.6901, 0.2239, 0.7102, 0.2453]}, {"w": "Heng-Tze", "b": [0.715, 0.2239, 0.7968, 0.2453]}, {"w": "Cheng", "b": [0.8016, 0.2239, 0.8566, 0.2453]}, {"w": "et", "b": [0.1428, 0.2429, 0.1581, 0.2644]}, {"w": "al.14.", "b": [0.1648, 0.2429, 0.2001, 0.2644]}, {"w": "It", "b": [0.2068, 0.2429, 0.2195, 0.2644]}, {"w": "connects", "b": [0.2262, 0.2429, 0.3001, 0.2644]}, {"w": "all", "b": [0.3068, 0.2429, 0.3265, 0.2644]}, {"w": "or", "b": [0.3332, 0.2429, 0.3515, 0.2644]}, {"w": "part", "b": [0.3582, 0.2429, 0.3924, 0.2644]}, {"w": "of", "b": [0.3991, 0.2429, 0.4159, 0.2644]}, {"w": "the", "b": [0.4226, 0.2429, 0.4489, 0.2644]}, {"w": "inputs", "b": [0.4556, 0.2429, 0.5082, 0.2644]}, {"w": "directly", "b": [0.5149, 0.2429, 0.5781, 0.2644]}, {"w": "to", "b": [0.5848, 0.2429, 0.6017, 0.2644]}, {"w": "the", "b": [0.6084, 0.2429, 0.6348, 0.2644]}, {"w": "output", "b": [0.6415, 0.2429, 0.6979, 0.2644]}, {"w": "layer,", "b": [0.7046, 0.2429, 0.7482, 0.2644]}, {"w": "as", "b": [0.7549, 0.2429, 0.7717, 0.2644]}, {"w": "shown", "b": [0.7784, 0.2429, 0.8335, 0.2644]}, {"w": "in", "b": [0.8402, 0.2429, 0.8571, 0.2644]}, {"w": "Figure", "b": [0.1429, 0.262, 0.1969, 0.2834]}, {"w": "10-13.", "b": [0.2016, 0.262, 0.2541, 0.2834]}, {"w": "This", "b": [0.2593, 0.262, 0.2965, 0.2834]}, {"w": "architecture", "b": [0.3016, 0.262, 0.402, 0.2834]}, {"w": "makes", "b": [0.4071, 0.262, 0.4601, 0.2834]}, {"w": "it", "b": [0.4653, 0.262, 0.4772, 0.2834]}, {"w": "possible", "b": [0.4823, 0.262, 0.5494, 0.2834]}, {"w": "for", "b": [0.5545, 0.262, 0.5791, 0.2834]}, {"w": "the", "b": [0.5842, 0.262, 0.6105, 0.2834]}, {"w": "neural", "b": [0.6156, 0.262, 0.6691, 0.2834]}, {"w": "network", "b": [0.6742, 0.262, 0.7438, 0.2834]}, {"w": "to", "b": [0.7489, 0.262, 0.7658, 0.2834]}, {"w": "learn", "b": [0.771, 0.262, 0.8134, 0.2834]}, {"w": "both", "b": [0.8185, 0.262, 0.8572, 0.2834]}, {"w": "deep", "b": [0.1429, 0.281, 0.1825, 0.3025]}, {"w": "patterns", "b": [0.1905, 0.281, 0.2585, 0.3025]}, {"w": "(using", "b": [0.2665, 0.281, 0.3192, 0.3025]}, {"w": "the", "b": [0.3272, 0.281, 0.3535, 0.3025]}, {"w": "deep", "b": [0.3615, 0.281, 0.4012, 0.3025]}, {"w": "path)", "b": [0.4092, 0.281, 0.4535, 0.3025]}, {"w": "and", "b": [0.4616, 0.281, 0.4931, 0.3025]}, {"w": "simple", "b": [0.5011, 0.281, 0.5561, 0.3025]}, {"w": "rules", "b": [0.5641, 0.281, 0.6046, 0.3025]}, {"w": "(through", "b": [0.6127, 0.281, 0.6876, 0.3025]}, {"w": "the", "b": [0.6957, 0.281, 0.722, 0.3025]}, {"w": "short", "b": [0.73, 0.281, 0.7735, 0.3025]}, {"w": "path).", "b": [0.7815, 0.281, 0.8306, 0.3025]}, {"w": "In", "b": [0.8386, 0.281, 0.8571, 0.3025]}, {"w": "contrast,", "b": [0.1429, 0.3001, 0.2153, 0.3215]}, {"w": "a", "b": [0.2201, 0.3001, 0.2293, 0.3215]}, {"w": "regular", "b": [0.2342, 0.3001, 0.2937, 0.3215]}, {"w": "MLP", "b": [0.2986, 0.3001, 0.3401, 0.3215]}, {"w": "forces", "b": [0.3449, 0.3001, 0.3948, 0.3215]}, {"w": "all", "b": [0.3996, 0.3001, 0.4193, 0.3215]}, {"w": "the", "b": [0.4242, 0.3001, 0.4505, 0.3215]}, {"w": "data", "b": [0.4554, 0.3001, 0.4907, 0.3215]}, {"w": "to", "b": [0.4955, 0.3001, 0.5125, 0.3215]}, {"w": "flow", "b": [0.5174, 0.3001, 0.5537, 0.3215]}, {"w": "through", "b": [0.5586, 0.3001, 0.6264, 0.3215]}, {"w": "the", "b": [0.6312, 0.3001, 0.6576, 0.3215]}, {"w": "full", "b": [0.6624, 0.3001, 0.6902, 0.3215]}, {"w": "stack", "b": [0.6951, 0.3001, 0.7374, 0.3215]}, {"w": "of", "b": [0.7422, 0.3001, 0.759, 0.3215]}, {"w": "layers,", "b": [0.7639, 0.3001, 0.8165, 0.3215]}, {"w": "thus", "b": [0.8213, 0.3001, 0.8571, 0.3215]}, {"w": "simple", "b": [0.1428, 0.3191, 0.1978, 0.3405]}, {"w": "patterns", "b": [0.2038, 0.3191, 0.2718, 0.3405]}, {"w": "in", "b": [0.2779, 0.3191, 0.2949, 0.3405]}, {"w": "the", "b": [0.301, 0.3191, 0.3273, 0.3405]}, {"w": "data", "b": [0.3333, 0.3191, 0.3686, 0.3405]}, {"w": "may", "b": [0.3747, 0.3191, 0.4101, 0.3405]}, {"w": "end", "b": [0.4161, 0.3191, 0.4474, 0.3405]}, {"w": "up", "b": [0.4534, 0.3191, 0.4754, 0.3405]}, {"w": "being", "b": [0.4815, 0.3191, 0.5276, 0.3405]}, {"w": "distorted", "b": [0.5337, 0.3191, 0.6088, 0.3405]}, {"w": "by", "b": [0.6149, 0.3191, 0.6351, 0.3405]}, {"w": "this", "b": [0.6411, 0.3191, 0.6718, 0.3405]}, {"w": "sequence", "b": [0.6779, 0.3191, 0.754, 0.3405]}, {"w": "of", "b": [0.7601, 0.3191, 0.7769, 0.3405]}, {"w": "transfor‐", "b": [0.7829, 0.3191, 0.8571, 0.3405]}, {"w": "mations.", "b": [0.1429, 0.3382, 0.215, 0.3596]}]}, {"id": "b_4", "type": "paragraph", "text": "304 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "304", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2745, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3635, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 331, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 10-13. Wide and Deep Neural Network", "words": [{"w": "Figure", "b": [0.1429, 0.5743, 0.1943, 0.5959]}, {"w": "10-13.", "b": [0.1991, 0.5743, 0.2507, 0.5959]}, {"w": "Wide", "b": [0.2554, 0.5743, 0.2986, 0.5959]}, {"w": "and", "b": [0.3034, 0.5743, 0.3348, 0.5959]}, {"w": "Deep", "b": [0.3395, 0.5743, 0.381, 0.5959]}, {"w": "Neural", "b": [0.3858, 0.5743, 0.4414, 0.5959]}, {"w": "Network", "b": [0.4462, 0.5743, 0.5156, 0.5959]}]}, {"id": "b_1", "type": "paragraph", "text": "Let’s build such a neural network to tackle the California housing problem:", "words": [{"w": "Let’s", "b": [0.1429, 0.6117, 0.179, 0.6331]}, {"w": "build", "b": [0.1838, 0.6117, 0.2273, 0.6331]}, {"w": "such", "b": [0.232, 0.6117, 0.2706, 0.6331]}, {"w": "a", "b": [0.2754, 0.6117, 0.2845, 0.6331]}, {"w": "neural", "b": [0.2892, 0.6117, 0.3427, 0.6331]}, {"w": "network", "b": [0.3474, 0.6117, 0.417, 0.6331]}, {"w": "to", "b": [0.4217, 0.6117, 0.4387, 0.6331]}, {"w": "tackle", "b": [0.4434, 0.6117, 0.4922, 0.6331]}, {"w": "the", "b": [0.4969, 0.6117, 0.5233, 0.6331]}, {"w": "California", "b": [0.528, 0.6117, 0.6125, 0.6331]}, {"w": "housing", "b": [0.6172, 0.6117, 0.6844, 0.6331]}, {"w": "problem:", "b": [0.6891, 0.6117, 0.7649, 0.6331]}]}, {"id": "b_2", "type": "paragraph", "text": "input = keras.layers.Input(shape=X_train.shape[1:]) hidden1 = keras.layers.Dense(30, activation=\"relu\")(input) hidden2 = keras.layers.Dense(30, activation=\"relu\")(hidden1) concat = keras.layers.Concatenate()[input, hidden2]) output = keras.layers.Dense(1)(concat) model = keras.models.Model(inputs=[input], outputs=[output])", "words": [{"w": "input", "b": [0.1766, 0.6436, 0.2187, 0.6565]}, {"w": "=", "b": [0.2272, 0.6436, 0.2356, 0.6565]}, {"w": "keras.layers.Input(shape=X_train.shape[1:])", "b": [0.244, 0.6436, 0.6066, 0.6565]}, {"w": "hidden1", "b": [0.1766, 0.6591, 0.2356, 0.6719]}, {"w": "=", "b": [0.244, 0.6591, 0.2525, 0.6719]}, {"w": "keras.layers.Dense(30,", "b": [0.2609, 0.6591, 0.4464, 0.6719]}, {"w": "activation=\"relu\")(input)", "b": [0.4549, 0.6591, 0.6657, 0.6719]}, {"w": "hidden2", "b": [0.1766, 0.6745, 0.2356, 0.6873]}, {"w": "=", "b": [0.244, 0.6745, 0.2525, 0.6873]}, {"w": "keras.layers.Dense(30,", "b": [0.2609, 0.6745, 0.4464, 0.6873]}, {"w": "activation=\"relu\")(hidden1)", "b": [0.4549, 0.6745, 0.6825, 0.6873]}, {"w": "concat", "b": [0.1766, 0.6899, 0.2272, 0.7028]}, {"w": "=", "b": [0.2356, 0.6899, 0.244, 0.7028]}, {"w": "keras.layers.Concatenate()[input,", "b": [0.2525, 0.6899, 0.5307, 0.7028]}, {"w": "hidden2])", "b": [0.5392, 0.6899, 0.6151, 0.7028]}, {"w": "output", "b": [0.1766, 0.7053, 0.2272, 0.7182]}, {"w": "=", "b": [0.2356, 0.7053, 0.244, 0.7182]}, {"w": "keras.layers.Dense(1)(concat)", "b": [0.2525, 0.7053, 0.497, 0.7182]}, {"w": "model", "b": [0.1766, 0.7207, 0.2187, 0.7336]}, {"w": "=", "b": [0.2272, 0.7207, 0.2356, 0.7336]}, {"w": "keras.models.Model(inputs=[input],", "b": [0.244, 0.7207, 0.5307, 0.7336]}, {"w": "outputs=[output])", "b": [0.5392, 0.7207, 0.6825, 0.7336]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s go through each line of this code:", "words": [{"w": "Let’s", "b": [0.1429, 0.7414, 0.179, 0.7628]}, {"w": "go", "b": [0.1838, 0.7414, 0.2041, 0.7628]}, {"w": "through", "b": [0.2089, 0.7414, 0.2766, 0.7628]}, {"w": "each", "b": [0.2814, 0.7414, 0.3193, 0.7628]}, {"w": "line", "b": [0.324, 0.7414, 0.3551, 0.7628]}, {"w": "of", "b": [0.3599, 0.7414, 0.3767, 0.7628]}, {"w": "this", "b": [0.3814, 0.7414, 0.4121, 0.7628]}, {"w": "code:", "b": [0.4168, 0.7414, 0.4609, 0.7628]}]}, {"id": "b_4", "type": "paragraph", "text": "• First, we need to create an Input object. This is needed because we may have multiple inputs, as we will see later.", "words": [{"w": "•", "b": [0.16, 0.7764, 0.1682, 0.7979]}, {"w": "First,", "b": [0.1786, 0.7764, 0.2216, 0.7979]}, {"w": "we", "b": [0.2294, 0.7764, 0.2525, 0.7979]}, {"w": "need", "b": [0.2603, 0.7764, 0.3004, 0.7979]}, {"w": "to", "b": [0.3082, 0.7764, 0.3252, 0.7979]}, {"w": "create", "b": [0.3329, 0.7764, 0.3823, 0.7979]}, {"w": "an", "b": [0.39, 0.7764, 0.4106, 0.7979]}, {"w": "Input", "b": [0.4183, 0.7796, 0.4678, 0.7947]}, {"w": "object.", "b": [0.4756, 0.7764, 0.5309, 0.7979]}, {"w": "This", "b": [0.5387, 0.7764, 0.5759, 0.7979]}, {"w": "is", "b": [0.5836, 0.7764, 0.5969, 0.7979]}, {"w": "needed", "b": [0.6046, 0.7764, 0.6646, 0.7979]}, {"w": "because", "b": [0.6724, 0.7764, 0.7369, 0.7979]}, {"w": "we", "b": [0.7447, 0.7764, 0.7678, 0.7979]}, {"w": "may", "b": [0.7756, 0.7764, 0.811, 0.7979]}, {"w": "have", "b": [0.8187, 0.7764, 0.8571, 0.7979]}, {"w": "multiple", "b": [0.1786, 0.7955, 0.2486, 0.8169]}, {"w": "inputs,", "b": [0.2533, 0.7955, 0.3106, 0.8169]}, {"w": "as", "b": [0.3153, 0.7955, 0.3321, 0.8169]}, {"w": "we", "b": [0.3368, 0.7955, 0.36, 0.8169]}, {"w": "will", "b": [0.3647, 0.7955, 0.3951, 0.8169]}, {"w": "see", "b": [0.3998, 0.7955, 0.4252, 0.8169]}, {"w": "later.", "b": [0.4299, 0.7955, 0.4703, 0.8169]}]}, {"id": "b_5", "type": "paragraph", "text": "• Next, we create a Dense layer with 30 neurons and using the ReLU activation function. As soon as it is created, notice that we call it like a function, passing it the input. This is why this is called the Functional API. Note that we are just tell‐", "words": [{"w": "•", "b": [0.16, 0.8215, 0.1682, 0.8429]}, {"w": "Next,", "b": [0.1786, 0.8215, 0.2233, 0.8429]}, {"w": "we", "b": [0.2313, 0.8215, 0.2544, 0.8429]}, {"w": "create", "b": [0.2624, 0.8215, 0.3117, 0.8429]}, {"w": "a", "b": [0.3197, 0.8215, 0.3288, 0.8429]}, {"w": "Dense", "b": [0.3368, 0.8247, 0.3862, 0.8397]}, {"w": "layer", "b": [0.3942, 0.8215, 0.4344, 0.8429]}, {"w": "with", "b": [0.4423, 0.8215, 0.4797, 0.8429]}, {"w": "30", "b": [0.4876, 0.8215, 0.5076, 0.8429]}, {"w": "neurons", "b": [0.5156, 0.8215, 0.5843, 0.8429]}, {"w": "and", "b": [0.5923, 0.8215, 0.6238, 0.8429]}, {"w": "using", "b": [0.6317, 0.8215, 0.6772, 0.8429]}, {"w": "the", "b": [0.6851, 0.8215, 0.7115, 0.8429]}, {"w": "ReLU", "b": [0.7194, 0.8215, 0.7669, 0.8429]}, {"w": "activation", "b": [0.7749, 0.8215, 0.8571, 0.8429]}, {"w": "function.", "b": [0.1786, 0.8405, 0.2547, 0.8619]}, {"w": "As", "b": [0.2607, 0.8405, 0.2828, 0.8619]}, {"w": "soon", "b": [0.2887, 0.8405, 0.329, 0.8619]}, {"w": "as", "b": [0.335, 0.8405, 0.3518, 0.8619]}, {"w": "it", "b": [0.3578, 0.8405, 0.3698, 0.8619]}, {"w": "is", "b": [0.3758, 0.8405, 0.389, 0.8619]}, {"w": "created,", "b": [0.395, 0.8405, 0.4601, 0.8619]}, {"w": "notice", "b": [0.4661, 0.8405, 0.5177, 0.8619]}, {"w": "that", "b": [0.5237, 0.8405, 0.5563, 0.8619]}, {"w": "we", "b": [0.5623, 0.8405, 0.5854, 0.8619]}, {"w": "call", "b": [0.5914, 0.8405, 0.6199, 0.8619]}, {"w": "it", "b": [0.6259, 0.8405, 0.6378, 0.8619]}, {"w": "like", "b": [0.6438, 0.8405, 0.6739, 0.8619]}, {"w": "a", "b": [0.6799, 0.8405, 0.689, 0.8619]}, {"w": "function,", "b": [0.695, 0.8405, 0.7711, 0.8619]}, {"w": "passing", "b": [0.7771, 0.8405, 0.8392, 0.8619]}, {"w": "it", "b": [0.8452, 0.8405, 0.8571, 0.8619]}, {"w": "the", "b": [0.1786, 0.8596, 0.2049, 0.881]}, {"w": "input.", "b": [0.2102, 0.8596, 0.2599, 0.881]}, {"w": "This", "b": [0.2652, 0.8596, 0.3024, 0.881]}, {"w": "is", "b": [0.3077, 0.8596, 0.3209, 0.881]}, {"w": "why", "b": [0.3263, 0.8596, 0.3607, 0.881]}, {"w": "this", "b": [0.366, 0.8596, 0.3968, 0.881]}, {"w": "is", "b": [0.4021, 0.8596, 0.4153, 0.881]}, {"w": "called", "b": [0.4206, 0.8596, 0.469, 0.881]}, {"w": "the", "b": [0.4743, 0.8596, 0.5006, 0.881]}, {"w": "Functional", "b": [0.5059, 0.8596, 0.5962, 0.881]}, {"w": "API.", "b": [0.6015, 0.8596, 0.6395, 0.881]}, {"w": "Note", "b": [0.6448, 0.8596, 0.6856, 0.881]}, {"w": "that", "b": [0.6909, 0.8596, 0.7235, 0.881]}, {"w": "we", "b": [0.7288, 0.8596, 0.7519, 0.881]}, {"w": "are", "b": [0.7572, 0.8596, 0.7829, 0.881]}, {"w": "just", "b": [0.7883, 0.8596, 0.8187, 0.881]}, {"w": "tell‐", "b": [0.824, 0.8596, 0.8571, 0.881]}]}, {"id": "b_6", "type": "paragraph", "text": "Implementing MLPs with Keras | 305", "words": [{"w": "Implementing", "b": [0.6126, 0.9225, 0.6972, 0.9388]}, {"w": "MLPs", "b": [0.7, 0.9225, 0.7308, 0.9388]}, {"w": "with", "b": [0.7336, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "305", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 332, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "ing Keras how it should connect the layers together, no actual data is being pro‐ cessed yet.", "words": [{"w": "ing", "b": [0.1786, 0.0791, 0.2053, 0.1005]}, {"w": "Keras", "b": [0.2113, 0.0791, 0.2582, 0.1005]}, {"w": "how", "b": [0.2641, 0.0791, 0.3002, 0.1005]}, {"w": "it", "b": [0.3061, 0.0791, 0.3181, 0.1005]}, {"w": "should", "b": [0.324, 0.0791, 0.3808, 0.1005]}, {"w": "connect", "b": [0.3867, 0.0791, 0.453, 0.1005]}, {"w": "the", "b": [0.459, 0.0791, 0.4853, 0.1005]}, {"w": "layers", "b": [0.4913, 0.0791, 0.5391, 0.1005]}, {"w": "together,", "b": [0.5451, 0.0791, 0.6182, 0.1005]}, {"w": "no", "b": [0.6241, 0.0791, 0.6462, 0.1005]}, {"w": "actual", "b": [0.6521, 0.0791, 0.7019, 0.1005]}, {"w": "data", "b": [0.7079, 0.0791, 0.7431, 0.1005]}, {"w": "is", "b": [0.7491, 0.0791, 0.7623, 0.1005]}, {"w": "being", "b": [0.7683, 0.0791, 0.8145, 0.1005]}, {"w": "pro‐", "b": [0.8204, 0.0791, 0.8571, 0.1005]}, {"w": "cessed", "b": [0.1786, 0.0981, 0.2314, 0.1195]}, {"w": "yet.", "b": [0.2361, 0.0981, 0.2656, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "• We then create a second hidden layer, and again we use it as a function. Note however that we pass it the output of the first hidden layer.", "words": [{"w": "•", "b": [0.16, 0.1232, 0.1682, 0.1446]}, {"w": "We", "b": [0.1786, 0.1232, 0.2056, 0.1446]}, {"w": "then", "b": [0.2131, 0.1232, 0.2508, 0.1446]}, {"w": "create", "b": [0.2583, 0.1232, 0.3077, 0.1446]}, {"w": "a", "b": [0.3152, 0.1232, 0.3243, 0.1446]}, {"w": "second", "b": [0.3318, 0.1232, 0.3901, 0.1446]}, {"w": "hidden", "b": [0.3976, 0.1232, 0.4566, 0.1446]}, {"w": "layer,", "b": [0.4641, 0.1232, 0.5077, 0.1446]}, {"w": "and", "b": [0.5152, 0.1232, 0.5467, 0.1446]}, {"w": "again", "b": [0.5542, 0.1232, 0.5992, 0.1446]}, {"w": "we", "b": [0.6067, 0.1232, 0.6298, 0.1446]}, {"w": "use", "b": [0.6373, 0.1232, 0.6649, 0.1446]}, {"w": "it", "b": [0.6724, 0.1232, 0.6843, 0.1446]}, {"w": "as", "b": [0.6918, 0.1232, 0.7086, 0.1446]}, {"w": "a", "b": [0.7161, 0.1232, 0.7252, 0.1446]}, {"w": "function.", "b": [0.7327, 0.1232, 0.8089, 0.1446]}, {"w": "Note", "b": [0.8163, 0.1232, 0.8571, 0.1446]}, {"w": "however", "b": [0.1786, 0.1423, 0.2497, 0.1637]}, {"w": "that", "b": [0.2544, 0.1423, 0.287, 0.1637]}, {"w": "we", "b": [0.2917, 0.1423, 0.3148, 0.1637]}, {"w": "pass", "b": [0.3196, 0.1423, 0.3549, 0.1637]}, {"w": "it", "b": [0.3597, 0.1423, 0.3716, 0.1637]}, {"w": "the", "b": [0.3763, 0.1423, 0.4027, 0.1637]}, {"w": "output", "b": [0.4074, 0.1423, 0.4638, 0.1637]}, {"w": "of", "b": [0.4685, 0.1423, 0.4853, 0.1637]}, {"w": "the", "b": [0.49, 0.1423, 0.5163, 0.1637]}, {"w": "first", "b": [0.5211, 0.1423, 0.5546, 0.1637]}, {"w": "hidden", "b": [0.5593, 0.1423, 0.6182, 0.1637]}, {"w": "layer.", "b": [0.623, 0.1423, 0.6666, 0.1637]}]}, {"id": "b_2", "type": "paragraph", "text": "• Next, we create a Concatenate() layer, and once again we immediately use it like a function, to concatenate the input and the output of the second hidden layer (you may prefer the keras.layers.concatenate() function, which creates a Con catenate layer and immediately calls it with the given inputs).", "words": [{"w": "•", "b": [0.16, 0.1682, 0.1682, 0.1897]}, {"w": "Next,", "b": [0.1786, 0.1682, 0.2233, 0.1897]}, {"w": "we", "b": [0.2285, 0.1682, 0.2516, 0.1897]}, {"w": "create", "b": [0.2568, 0.1682, 0.3061, 0.1897]}, {"w": "a", "b": [0.3113, 0.1682, 0.3204, 0.1897]}, {"w": "Concatenate()", "b": [0.3256, 0.1714, 0.4542, 0.1865]}, {"w": "layer,", "b": [0.4594, 0.1682, 0.503, 0.1897]}, {"w": "and", "b": [0.5082, 0.1682, 0.5397, 0.1897]}, {"w": "once", "b": [0.5449, 0.1682, 0.5846, 0.1897]}, {"w": "again", "b": [0.5897, 0.1682, 0.6347, 0.1897]}, {"w": "we", "b": [0.6399, 0.1682, 0.663, 0.1897]}, {"w": "immediately", "b": [0.6682, 0.1682, 0.7721, 0.1897]}, {"w": "use", "b": [0.7773, 0.1682, 0.8048, 0.1897]}, {"w": "it", "b": [0.81, 0.1682, 0.8219, 0.1897]}, {"w": "like", "b": [0.8271, 0.1682, 0.8571, 0.1897]}, {"w": "a", "b": [0.1786, 0.1873, 0.1877, 0.2087]}, {"w": "function,", "b": [0.1947, 0.1873, 0.2709, 0.2087]}, {"w": "to", "b": [0.2779, 0.1873, 0.2949, 0.2087]}, {"w": "concatenate", "b": [0.3019, 0.1873, 0.4009, 0.2087]}, {"w": "the", "b": [0.4079, 0.1873, 0.4342, 0.2087]}, {"w": "input", "b": [0.4412, 0.1873, 0.4862, 0.2087]}, {"w": "and", "b": [0.4932, 0.1873, 0.5247, 0.2087]}, {"w": "the", "b": [0.5317, 0.1873, 0.5581, 0.2087]}, {"w": "output", "b": [0.5651, 0.1873, 0.6215, 0.2087]}, {"w": "of", "b": [0.6285, 0.1873, 0.6453, 0.2087]}, {"w": "the", "b": [0.6523, 0.1873, 0.6786, 0.2087]}, {"w": "second", "b": [0.6856, 0.1873, 0.744, 0.2087]}, {"w": "hidden", "b": [0.751, 0.1873, 0.8099, 0.2087]}, {"w": "layer", "b": [0.817, 0.1873, 0.8572, 0.2087]}, {"w": "(you", "b": [0.1786, 0.2072, 0.217, 0.2286]}, {"w": "may", "b": [0.2223, 0.2072, 0.2577, 0.2286]}, {"w": "prefer", "b": [0.263, 0.2072, 0.3132, 0.2286]}, {"w": "the", "b": [0.3185, 0.2072, 0.3448, 0.2286]}, {"w": "keras.layers.concatenate()", "b": [0.3501, 0.2104, 0.6074, 0.2255]}, {"w": "function,", "b": [0.6127, 0.2072, 0.6888, 0.2286]}, {"w": "which", "b": [0.6941, 0.2072, 0.745, 0.2286]}, {"w": "creates", "b": [0.7503, 0.2072, 0.8073, 0.2286]}, {"w": "a", "b": [0.8125, 0.2072, 0.8217, 0.2286]}, {"w": "Con", "b": [0.8269, 0.2104, 0.8566, 0.2255]}, {"w": "catenate", "b": [0.1786, 0.2304, 0.2577, 0.2454]}, {"w": "layer", "b": [0.2625, 0.2272, 0.3026, 0.2486]}, {"w": "and", "b": [0.3074, 0.2272, 0.3389, 0.2486]}, {"w": "immediately", "b": [0.3436, 0.2272, 0.4476, 0.2486]}, {"w": "calls", "b": [0.4523, 0.2272, 0.4885, 0.2486]}, {"w": "it", "b": [0.4932, 0.2272, 0.5051, 0.2486]}, {"w": "with", "b": [0.5099, 0.2272, 0.5472, 0.2486]}, {"w": "the", "b": [0.5519, 0.2272, 0.5783, 0.2486]}, {"w": "given", "b": [0.583, 0.2272, 0.6282, 0.2486]}, {"w": "inputs).", "b": [0.6329, 0.2272, 0.6975, 0.2486]}]}, {"id": "b_3", "type": "paragraph", "text": "• Then we create the output layer, with a single neuron and no activation function, and we call it like a function, passing it the result of the concatenation.", "words": [{"w": "•", "b": [0.16, 0.2523, 0.1682, 0.2737]}, {"w": "Then", "b": [0.1786, 0.2523, 0.2228, 0.2737]}, {"w": "we", "b": [0.228, 0.2523, 0.2511, 0.2737]}, {"w": "create", "b": [0.2563, 0.2523, 0.3057, 0.2737]}, {"w": "the", "b": [0.3109, 0.2523, 0.3372, 0.2737]}, {"w": "output", "b": [0.3424, 0.2523, 0.3988, 0.2737]}, {"w": "layer,", "b": [0.404, 0.2523, 0.4476, 0.2737]}, {"w": "with", "b": [0.4528, 0.2523, 0.4901, 0.2737]}, {"w": "a", "b": [0.4953, 0.2523, 0.5044, 0.2737]}, {"w": "single", "b": [0.5096, 0.2523, 0.5581, 0.2737]}, {"w": "neuron", "b": [0.5633, 0.2523, 0.6244, 0.2737]}, {"w": "and", "b": [0.6296, 0.2523, 0.6611, 0.2737]}, {"w": "no", "b": [0.6663, 0.2523, 0.6884, 0.2737]}, {"w": "activation", "b": [0.6935, 0.2523, 0.7758, 0.2737]}, {"w": "function,", "b": [0.781, 0.2523, 0.8571, 0.2737]}, {"w": "and", "b": [0.1786, 0.2713, 0.2101, 0.2927]}, {"w": "we", "b": [0.2148, 0.2713, 0.238, 0.2927]}, {"w": "call", "b": [0.2427, 0.2713, 0.2712, 0.2927]}, {"w": "it", "b": [0.2759, 0.2713, 0.2879, 0.2927]}, {"w": "like", "b": [0.2926, 0.2713, 0.3226, 0.2927]}, {"w": "a", "b": [0.3274, 0.2713, 0.3365, 0.2927]}, {"w": "function,", "b": [0.3412, 0.2713, 0.4174, 0.2927]}, {"w": "passing", "b": [0.4221, 0.2713, 0.4842, 0.2927]}, {"w": "it", "b": [0.4889, 0.2713, 0.5009, 0.2927]}, {"w": "the", "b": [0.5056, 0.2713, 0.5319, 0.2927]}, {"w": "result", "b": [0.5367, 0.2713, 0.5836, 0.2927]}, {"w": "of", "b": [0.5883, 0.2713, 0.6051, 0.2927]}, {"w": "the", "b": [0.6098, 0.2713, 0.6362, 0.2927]}, {"w": "concatenation.", "b": [0.6409, 0.2713, 0.7633, 0.2927]}]}, {"id": "b_4", "type": "paragraph", "text": "• Lastly, we create a Keras Model, specifying which inputs and outputs to use.", "words": [{"w": "•", "b": [0.16, 0.2973, 0.1682, 0.3187]}, {"w": "Lastly,", "b": [0.1786, 0.2973, 0.231, 0.3187]}, {"w": "we", "b": [0.2357, 0.2973, 0.2588, 0.3187]}, {"w": "create", "b": [0.2636, 0.2973, 0.3129, 0.3187]}, {"w": "a", "b": [0.3176, 0.2973, 0.3268, 0.3187]}, {"w": "Keras", "b": [0.3315, 0.2973, 0.3784, 0.3187]}, {"w": "Model,", "b": [0.3831, 0.2973, 0.4374, 0.3187]}, {"w": "specifying", "b": [0.4421, 0.2973, 0.5267, 0.3187]}, {"w": "which", "b": [0.5315, 0.2973, 0.5824, 0.3187]}, {"w": "inputs", "b": [0.5871, 0.2973, 0.6397, 0.3187]}, {"w": "and", "b": [0.6444, 0.2973, 0.6759, 0.3187]}, {"w": "outputs", "b": [0.6807, 0.2973, 0.7447, 0.3187]}, {"w": "to", "b": [0.7494, 0.2973, 0.7664, 0.3187]}, {"w": "use.", "b": [0.7711, 0.2973, 0.8034, 0.3187]}]}, {"id": "b_5", "type": "paragraph", "text": "Once you have built the Keras model, everything is exactly like earlier, so no need to repeat it here: you must compile the model, train it, evaluate it and use it to make predictions.", "words": [{"w": "Once", "b": [0.1429, 0.3315, 0.1875, 0.3529]}, {"w": "you", "b": [0.1932, 0.3315, 0.2245, 0.3529]}, {"w": "have", "b": [0.2302, 0.3315, 0.2686, 0.3529]}, {"w": "built", "b": [0.2743, 0.3315, 0.3131, 0.3529]}, {"w": "the", "b": [0.3189, 0.3315, 0.3452, 0.3529]}, {"w": "Keras", "b": [0.3509, 0.3315, 0.3978, 0.3529]}, {"w": "model,", "b": [0.4035, 0.3315, 0.4611, 0.3529]}, {"w": "everything", "b": [0.4668, 0.3315, 0.5563, 0.3529]}, {"w": "is", "b": [0.562, 0.3315, 0.5752, 0.3529]}, {"w": "exactly", "b": [0.581, 0.3315, 0.6388, 0.3529]}, {"w": "like", "b": [0.6445, 0.3315, 0.6746, 0.3529]}, {"w": "earlier,", "b": [0.6803, 0.3315, 0.7369, 0.3529]}, {"w": "so", "b": [0.7426, 0.3315, 0.7609, 0.3529]}, {"w": "no", "b": [0.7666, 0.3315, 0.7886, 0.3529]}, {"w": "need", "b": [0.7943, 0.3315, 0.8344, 0.3529]}, {"w": "to", "b": [0.8402, 0.3315, 0.8571, 0.3529]}, {"w": "repeat", "b": [0.1429, 0.3505, 0.1943, 0.3719]}, {"w": "it", "b": [0.2015, 0.3505, 0.2135, 0.3719]}, {"w": "here:", "b": [0.2207, 0.3505, 0.262, 0.3719]}, {"w": "you", "b": [0.2693, 0.3505, 0.3005, 0.3719]}, {"w": "must", "b": [0.3078, 0.3505, 0.3495, 0.3719]}, {"w": "compile", "b": [0.3567, 0.3505, 0.4235, 0.3719]}, {"w": "the", "b": [0.4307, 0.3505, 0.457, 0.3719]}, {"w": "model,", "b": [0.4643, 0.3505, 0.5218, 0.3719]}, {"w": "train", "b": [0.5291, 0.3505, 0.5693, 0.3719]}, {"w": "it,", "b": [0.5765, 0.3505, 0.5932, 0.3719]}, {"w": "evaluate", "b": [0.6004, 0.3505, 0.6684, 0.3719]}, {"w": "it", "b": [0.6756, 0.3505, 0.6875, 0.3719]}, {"w": "and", "b": [0.6948, 0.3505, 0.7263, 0.3719]}, {"w": "use", "b": [0.7336, 0.3505, 0.7611, 0.3719]}, {"w": "it", "b": [0.7684, 0.3505, 0.7803, 0.3719]}, {"w": "to", "b": [0.7875, 0.3505, 0.8045, 0.3719]}, {"w": "make", "b": [0.8117, 0.3505, 0.8571, 0.3719]}, {"w": "predictions.", "b": [0.1429, 0.3696, 0.2421, 0.391]}]}, {"id": "b_6", "type": "paragraph", "text": "But what if you want to send a subset of the features through the wide path, and a different subset (possibly overlapping) through the deep path (see Figure 10-14)? In this case, one solution is to use multiple inputs. For example, suppose we want to send 5 features through the deep path (features 0 to 4), and 6 features through the wide path (features 2 to 7):", "words": [{"w": "But", "b": [0.1429, 0.3977, 0.1725, 0.4191]}, {"w": "what", "b": [0.1795, 0.3977, 0.22, 0.4191]}, {"w": "if", "b": [0.2269, 0.3977, 0.2387, 0.4191]}, {"w": "you", "b": [0.2457, 0.3977, 0.2769, 0.4191]}, {"w": "want", "b": [0.2839, 0.3977, 0.3246, 0.4191]}, {"w": "to", "b": [0.3316, 0.3977, 0.3486, 0.4191]}, {"w": "send", "b": [0.3555, 0.3977, 0.3944, 0.4191]}, {"w": "a", "b": [0.4014, 0.3977, 0.4105, 0.4191]}, {"w": "subset", "b": [0.4175, 0.3977, 0.4696, 0.4191]}, {"w": "of", "b": [0.4766, 0.3977, 0.4934, 0.4191]}, {"w": "the", "b": [0.5003, 0.3977, 0.5267, 0.4191]}, {"w": "features", "b": [0.5336, 0.3977, 0.599, 0.4191]}, {"w": "through", "b": [0.606, 0.3977, 0.6738, 0.4191]}, {"w": "the", "b": [0.6807, 0.3977, 0.707, 0.4191]}, {"w": "wide", "b": [0.714, 0.3977, 0.7537, 0.4191]}, {"w": "path,", "b": [0.7607, 0.3977, 0.8026, 0.4191]}, {"w": "and", "b": [0.8095, 0.3977, 0.8411, 0.4191]}, {"w": "a", "b": [0.848, 0.3977, 0.8572, 0.4191]}, {"w": "different", "b": [0.1429, 0.4167, 0.2146, 0.4381]}, {"w": "subset", "b": [0.221, 0.4167, 0.2731, 0.4381]}, {"w": "(possibly", "b": [0.2795, 0.4167, 0.3545, 0.4381]}, {"w": "overlapping)", "b": [0.3609, 0.4167, 0.4676, 0.4381]}, {"w": "through", "b": [0.474, 0.4167, 0.5417, 0.4381]}, {"w": "the", "b": [0.5481, 0.4167, 0.5745, 0.4381]}, {"w": "deep", "b": [0.5808, 0.4167, 0.6205, 0.4381]}, {"w": "path", "b": [0.6269, 0.4167, 0.664, 0.4381]}, {"w": "(see", "b": [0.6704, 0.4167, 0.703, 0.4381]}, {"w": "Figure", "b": [0.7093, 0.4167, 0.7633, 0.4381]}, {"w": "10-14)?", "b": [0.7697, 0.4167, 0.8323, 0.4381]}, {"w": "In", "b": [0.8386, 0.4167, 0.8571, 0.4381]}, {"w": "this", "b": [0.1429, 0.4358, 0.1736, 0.4572]}, {"w": "case,", "b": [0.1813, 0.4358, 0.2205, 0.4572]}, {"w": "one", "b": [0.2282, 0.4358, 0.2591, 0.4572]}, {"w": "solution", "b": [0.2668, 0.4358, 0.3354, 0.4572]}, {"w": "is", "b": [0.3431, 0.4358, 0.3563, 0.4572]}, {"w": "to", "b": [0.364, 0.4358, 0.381, 0.4572]}, {"w": "use", "b": [0.3887, 0.4358, 0.4163, 0.4572]}, {"w": "multiple", "b": [0.424, 0.4358, 0.494, 0.4572]}, {"w": "inputs.", "b": [0.5017, 0.4358, 0.559, 0.4572]}, {"w": "For", "b": [0.5667, 0.4358, 0.5957, 0.4572]}, {"w": "example,", "b": [0.6034, 0.4358, 0.6777, 0.4572]}, {"w": "suppose", "b": [0.6854, 0.4358, 0.7531, 0.4572]}, {"w": "we", "b": [0.7608, 0.4358, 0.784, 0.4572]}, {"w": "want", "b": [0.7917, 0.4358, 0.8324, 0.4572]}, {"w": "to", "b": [0.8402, 0.4358, 0.8571, 0.4572]}, {"w": "send", "b": [0.1429, 0.4548, 0.1817, 0.4762]}, {"w": "5", "b": [0.1888, 0.4548, 0.1988, 0.4762]}, {"w": "features", "b": [0.2059, 0.4548, 0.2714, 0.4762]}, {"w": "through", "b": [0.2785, 0.4548, 0.3462, 0.4762]}, {"w": "the", "b": [0.3533, 0.4548, 0.3797, 0.4762]}, {"w": "deep", "b": [0.3868, 0.4548, 0.4264, 0.4762]}, {"w": "path", "b": [0.4335, 0.4548, 0.4706, 0.4762]}, {"w": "(features", "b": [0.4777, 0.4548, 0.5504, 0.4762]}, {"w": "0", "b": [0.5574, 0.4548, 0.5674, 0.4762]}, {"w": "to", "b": [0.5745, 0.4548, 0.5915, 0.4762]}, {"w": "4),", "b": [0.5986, 0.4548, 0.6206, 0.4762]}, {"w": "and", "b": [0.6277, 0.4548, 0.6592, 0.4762]}, {"w": "6", "b": [0.6663, 0.4548, 0.6763, 0.4762]}, {"w": "features", "b": [0.6834, 0.4548, 0.7488, 0.4762]}, {"w": "through", "b": [0.7559, 0.4548, 0.8237, 0.4762]}, {"w": "the", "b": [0.8308, 0.4548, 0.8571, 0.4762]}, {"w": "wide", "b": [0.1429, 0.4739, 0.1826, 0.4953]}, {"w": "path", "b": [0.1873, 0.4739, 0.2244, 0.4953]}, {"w": "(features", "b": [0.2292, 0.4739, 0.3018, 0.4953]}, {"w": "2", "b": [0.3065, 0.4739, 0.3165, 0.4953]}, {"w": "to", "b": [0.3213, 0.4739, 0.3382, 0.4953]}, {"w": "7):", "b": [0.343, 0.4739, 0.3649, 0.4953]}]}, {"id": "b_7", "type": "paragraph", "text": "input_A = keras.layers.Input(shape=[5]) input_B = keras.layers.Input(shape=[6]) hidden1 = keras.layers.Dense(30, activation=\"relu\")(input_B) hidden2 = keras.layers.Dense(30, activation=\"relu\")(hidden1) concat = keras.layers.concatenate([input_A, hidden2]) output = keras.layers.Dense(1)(concat) model = keras.models.Model(inputs=[input_A, input_B], outputs=[output])", "words": [{"w": "input_A", "b": [0.1766, 0.5059, 0.2356, 0.5187]}, {"w": "=", "b": [0.2441, 0.5059, 0.2525, 0.5187]}, {"w": "keras.layers.Input(shape=[5])", "b": [0.2609, 0.5059, 0.5055, 0.5187]}, {"w": "input_B", "b": [0.1766, 0.5213, 0.2356, 0.5341]}, {"w": "=", "b": [0.2441, 0.5213, 0.2525, 0.5341]}, {"w": "keras.layers.Input(shape=[6])", "b": [0.2609, 0.5213, 0.5055, 0.5341]}, {"w": "hidden1", "b": [0.1766, 0.5367, 0.2356, 0.5495]}, {"w": "=", "b": [0.2441, 0.5367, 0.2525, 0.5495]}, {"w": "keras.layers.Dense(30,", "b": [0.2609, 0.5367, 0.4464, 0.5495]}, {"w": "activation=\"relu\")(input_B)", "b": [0.4549, 0.5367, 0.6825, 0.5495]}, {"w": "hidden2", "b": [0.1766, 0.5521, 0.2356, 0.565]}, {"w": "=", "b": [0.2441, 0.5521, 0.2525, 0.565]}, {"w": "keras.layers.Dense(30,", "b": [0.2609, 0.5521, 0.4464, 0.565]}, {"w": "activation=\"relu\")(hidden1)", "b": [0.4549, 0.5521, 0.6825, 0.565]}, {"w": "concat", "b": [0.1766, 0.5675, 0.2272, 0.5804]}, {"w": "=", "b": [0.2356, 0.5675, 0.2441, 0.5804]}, {"w": "keras.layers.concatenate([input_A,", "b": [0.2525, 0.5675, 0.5392, 0.5804]}, {"w": "hidden2])", "b": [0.5476, 0.5675, 0.6235, 0.5804]}, {"w": "output", "b": [0.1766, 0.583, 0.2272, 0.5958]}, {"w": "=", "b": [0.2356, 0.583, 0.2441, 0.5958]}, {"w": "keras.layers.Dense(1)(concat)", "b": [0.2525, 0.583, 0.497, 0.5958]}, {"w": "model", "b": [0.1766, 0.5984, 0.2188, 0.6112]}, {"w": "=", "b": [0.2272, 0.5984, 0.2356, 0.6112]}, {"w": "keras.models.Model(inputs=[input_A,", "b": [0.2441, 0.5984, 0.5392, 0.6112]}, {"w": "input_B],", "b": [0.5476, 0.5984, 0.6235, 0.6112]}, {"w": "outputs=[output])", "b": [0.632, 0.5984, 0.7753, 0.6112]}]}, {"id": "b_8", "type": "paragraph", "text": "306 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "306", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 333, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 10-14. Handling Multiple Inputs", "words": [{"w": "Figure", "b": [0.1429, 0.5661, 0.1943, 0.5877]}, {"w": "10-14.", "b": [0.1991, 0.5661, 0.2507, 0.5877]}, {"w": "Handling", "b": [0.2554, 0.5661, 0.3314, 0.5877]}, {"w": "Multiple", "b": [0.3362, 0.5661, 0.4048, 0.5877]}, {"w": "Inputs", "b": [0.4096, 0.5661, 0.4606, 0.5877]}]}, {"id": "b_1", "type": "paragraph", "text": "The code is self-explanatory. Note that we specified inputs=[input_A, input_B] when creating the model. Now we can compile the model as usual, but when we call the fit() method, instead of passing a single input matrix X_train, we must pass a pair of matrices (X_train_A, X_train_B): one per input. The same is true for X_valid, and also for X_test and X_new when you call evaluate() or predict():", "words": [{"w": "The", "b": [0.1429, 0.6044, 0.1757, 0.6258]}, {"w": "code", "b": [0.1845, 0.6044, 0.2238, 0.6258]}, {"w": "is", "b": [0.2325, 0.6044, 0.2458, 0.6258]}, {"w": "self-explanatory.", "b": [0.2545, 0.6044, 0.3921, 0.6258]}, {"w": "Note", "b": [0.4009, 0.6044, 0.4417, 0.6258]}, {"w": "that", "b": [0.4505, 0.6044, 0.4831, 0.6258]}, {"w": "we", "b": [0.4918, 0.6044, 0.515, 0.6258]}, {"w": "specified", "b": [0.5237, 0.6044, 0.5971, 0.6258]}, {"w": "inputs=[input_A,", "b": [0.6059, 0.6076, 0.7642, 0.6227]}, {"w": "input_B]", "b": [0.778, 0.6076, 0.8571, 0.6227]}, {"w": "when", "b": [0.1429, 0.6235, 0.1885, 0.6449]}, {"w": "creating", "b": [0.1944, 0.6235, 0.2616, 0.6449]}, {"w": "the", "b": [0.2675, 0.6235, 0.2938, 0.6449]}, {"w": "model.", "b": [0.2997, 0.6235, 0.3573, 0.6449]}, {"w": "Now", "b": [0.3632, 0.6235, 0.403, 0.6449]}, {"w": "we", "b": [0.4089, 0.6235, 0.432, 0.6449]}, {"w": "can", "b": [0.4379, 0.6235, 0.4673, 0.6449]}, {"w": "compile", "b": [0.4732, 0.6235, 0.5399, 0.6449]}, {"w": "the", "b": [0.5458, 0.6235, 0.5721, 0.6449]}, {"w": "model", "b": [0.578, 0.6235, 0.6308, 0.6449]}, {"w": "as", "b": [0.6367, 0.6235, 0.6535, 0.6449]}, {"w": "usual,", "b": [0.6594, 0.6235, 0.7083, 0.6449]}, {"w": "but", "b": [0.7142, 0.6235, 0.7422, 0.6449]}, {"w": "when", "b": [0.7481, 0.6235, 0.7937, 0.6449]}, {"w": "we", "b": [0.7996, 0.6235, 0.8227, 0.6449]}, {"w": "call", "b": [0.8286, 0.6235, 0.8571, 0.6449]}, {"w": "the", "b": [0.1429, 0.6434, 0.1692, 0.6648]}, {"w": "fit()", "b": [0.1755, 0.6466, 0.225, 0.6617]}, {"w": "method,", "b": [0.2313, 0.6434, 0.3011, 0.6648]}, {"w": "instead", "b": [0.3074, 0.6434, 0.3674, 0.6648]}, {"w": "of", "b": [0.3737, 0.6434, 0.3905, 0.6648]}, {"w": "passing", "b": [0.3969, 0.6434, 0.4589, 0.6648]}, {"w": "a", "b": [0.4653, 0.6434, 0.4744, 0.6648]}, {"w": "single", "b": [0.4807, 0.6434, 0.5292, 0.6648]}, {"w": "input", "b": [0.5356, 0.6434, 0.5805, 0.6648]}, {"w": "matrix", "b": [0.5868, 0.6434, 0.6421, 0.6648]}, {"w": "X_train,", "b": [0.6485, 0.6434, 0.7225, 0.6648]}, {"w": "we", "b": [0.7288, 0.6434, 0.7519, 0.6648]}, {"w": "must", "b": [0.7583, 0.6434, 0.8, 0.6648]}, {"w": "pass", "b": [0.8063, 0.6434, 0.8417, 0.6648]}, {"w": "a", "b": [0.848, 0.6434, 0.8572, 0.6648]}, {"w": "pair", "b": [0.1429, 0.6634, 0.1762, 0.6848]}, {"w": "of", "b": [0.1863, 0.6634, 0.2031, 0.6848]}, {"w": "matrices", "b": [0.2131, 0.6634, 0.2839, 0.6848]}, {"w": "(X_train_A,", "b": [0.294, 0.6665, 0.4028, 0.6816]}, {"w": "X_train_B):", "b": [0.4178, 0.6634, 0.5215, 0.6848]}, {"w": "one", "b": [0.5315, 0.6634, 0.5624, 0.6848]}, {"w": "per", "b": [0.5724, 0.6634, 0.5999, 0.6848]}, {"w": "input.", "b": [0.61, 0.6634, 0.6596, 0.6848]}, {"w": "The", "b": [0.6697, 0.6634, 0.7025, 0.6848]}, {"w": "same", "b": [0.7126, 0.6634, 0.7553, 0.6848]}, {"w": "is", "b": [0.7653, 0.6634, 0.7785, 0.6848]}, {"w": "true", "b": [0.7886, 0.6634, 0.8226, 0.6848]}, {"w": "for", "b": [0.8326, 0.6634, 0.8571, 0.6848]}, {"w": "X_valid,", "b": [0.1429, 0.6833, 0.2169, 0.7047]}, {"w": "and", "b": [0.2216, 0.6833, 0.2532, 0.7047]}, {"w": "also", "b": [0.2579, 0.6833, 0.2906, 0.7047]}, {"w": "for", "b": [0.2953, 0.6833, 0.3198, 0.7047]}, {"w": "X_test", "b": [0.3246, 0.6865, 0.3839, 0.7016]}, {"w": "and", "b": [0.3887, 0.6833, 0.4202, 0.7047]}, {"w": "X_new", "b": [0.4249, 0.6865, 0.4744, 0.7016]}, {"w": "when", "b": [0.4791, 0.6833, 0.5248, 0.7047]}, {"w": "you", "b": [0.5295, 0.6833, 0.5608, 0.7047]}, {"w": "call", "b": [0.5655, 0.6833, 0.594, 0.7047]}, {"w": "evaluate()", "b": [0.5987, 0.6865, 0.6977, 0.7016]}, {"w": "or", "b": [0.7024, 0.6833, 0.7208, 0.7047]}, {"w": "predict():", "b": [0.7255, 0.6833, 0.8193, 0.7047]}]}, {"id": "b_2", "type": "equation", "text": "model.compile(loss=\"mse\", optimizer=\"sgd\")", "words": [{"w": "model.compile(loss=\"mse\",", "b": [0.1766, 0.7153, 0.3874, 0.7281]}, {"w": "optimizer=\"sgd\")", "b": [0.3958, 0.7153, 0.5308, 0.7281]}]}, {"id": "b_3", "type": "paragraph", "text": "X_train_A, X_train_B = X_train[:, :5], X_train[:, 2:] X_valid_A, X_valid_B = X_valid[:, :5], X_valid[:, 2:] X_test_A, X_test_B = X_test[:, :5], X_test[:, 2:] X_new_A, X_new_B = X_test_A[:3], X_test_B[:3]", "words": [{"w": "X_train_A,", "b": [0.1766, 0.7461, 0.2609, 0.759]}, {"w": "X_train_B", "b": [0.2694, 0.7461, 0.3452, 0.759]}, {"w": "=", "b": [0.3537, 0.7461, 0.3621, 0.759]}, {"w": "X_train[:,", "b": [0.3705, 0.7461, 0.4549, 0.759]}, {"w": ":5],", "b": [0.4633, 0.7461, 0.497, 0.759]}, {"w": "X_train[:,", "b": [0.5055, 0.7461, 0.5898, 0.759]}, {"w": "2:]", "b": [0.5982, 0.7461, 0.6235, 0.759]}, {"w": "X_valid_A,", "b": [0.1766, 0.7615, 0.2609, 0.7744]}, {"w": "X_valid_B", "b": [0.2694, 0.7615, 0.3452, 0.7744]}, {"w": "=", "b": [0.3537, 0.7615, 0.3621, 0.7744]}, {"w": "X_valid[:,", "b": [0.3705, 0.7615, 0.4549, 0.7744]}, {"w": ":5],", "b": [0.4633, 0.7615, 0.497, 0.7744]}, {"w": "X_valid[:,", "b": [0.5055, 0.7615, 0.5898, 0.7744]}, {"w": "2:]", "b": [0.5982, 0.7615, 0.6235, 0.7744]}, {"w": "X_test_A,", "b": [0.1766, 0.777, 0.2525, 0.7898]}, {"w": "X_test_B", "b": [0.2609, 0.777, 0.3284, 0.7898]}, {"w": "=", "b": [0.3368, 0.777, 0.3452, 0.7898]}, {"w": "X_test[:,", "b": [0.3537, 0.777, 0.4296, 0.7898]}, {"w": ":5],", "b": [0.438, 0.777, 0.4717, 0.7898]}, {"w": "X_test[:,", "b": [0.4802, 0.777, 0.5561, 0.7898]}, {"w": "2:]", "b": [0.5645, 0.777, 0.5898, 0.7898]}, {"w": "X_new_A,", "b": [0.1766, 0.7924, 0.2441, 0.8052]}, {"w": "X_new_B", "b": [0.2525, 0.7924, 0.3115, 0.8052]}, {"w": "=", "b": [0.3199, 0.7924, 0.3284, 0.8052]}, {"w": "X_test_A[:3],", "b": [0.3368, 0.7924, 0.4464, 0.8052]}, {"w": "X_test_B[:3]", "b": [0.4549, 0.7924, 0.5561, 0.8052]}]}, {"id": "b_4", "type": "paragraph", "text": "history = model.fit((X_train_A, X_train_B), y_train, epochs=20, validation_data=((X_valid_A, X_valid_B), y_valid)) mse_test = model.evaluate((X_test_A, X_test_B), y_test) y_pred = model.predict((X_new_A, X_new_B))", "words": [{"w": "history", "b": [0.1766, 0.8232, 0.2356, 0.8361]}, {"w": "=", "b": [0.2441, 0.8232, 0.2525, 0.8361]}, {"w": "model.fit((X_train_A,", "b": [0.2609, 0.8232, 0.438, 0.8361]}, {"w": "X_train_B),", "b": [0.4464, 0.8232, 0.5392, 0.8361]}, {"w": "y_train,", "b": [0.5476, 0.8232, 0.6151, 0.8361]}, {"w": "epochs=20,", "b": [0.6235, 0.8232, 0.7078, 0.8361]}, {"w": "validation_data=((X_valid_A,", "b": [0.3452, 0.8386, 0.5814, 0.8515]}, {"w": "X_valid_B),", "b": [0.5898, 0.8386, 0.6825, 0.8515]}, {"w": "y_valid))", "b": [0.691, 0.8386, 0.7669, 0.8515]}, {"w": "mse_test", "b": [0.1766, 0.8541, 0.2441, 0.8669]}, {"w": "=", "b": [0.2525, 0.8541, 0.2609, 0.8669]}, {"w": "model.evaluate((X_test_A,", "b": [0.2694, 0.8541, 0.4802, 0.8669]}, {"w": "X_test_B),", "b": [0.4886, 0.8541, 0.5729, 0.8669]}, {"w": "y_test)", "b": [0.5814, 0.8541, 0.6404, 0.8669]}, {"w": "y_pred", "b": [0.1766, 0.8695, 0.2272, 0.8823]}, {"w": "=", "b": [0.2356, 0.8695, 0.2441, 0.8823]}, {"w": "model.predict((X_new_A,", "b": [0.2525, 0.8695, 0.4464, 0.8823]}, {"w": "X_new_B))", "b": [0.4549, 0.8695, 0.5308, 0.8823]}]}, {"id": "b_5", "type": "paragraph", "text": "Implementing MLPs with Keras | 307", "words": [{"w": "Implementing", "b": [0.6126, 0.9225, 0.6972, 0.9388]}, {"w": "MLPs", "b": [0.7001, 0.9225, 0.7308, 0.9388]}, {"w": "with", "b": [0.7337, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "307", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 334, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "There are also many use cases in which you may want to have multiple outputs:", "words": [{"w": "There", "b": [0.1429, 0.0791, 0.1923, 0.1005]}, {"w": "are", "b": [0.197, 0.0791, 0.2227, 0.1005]}, {"w": "also", "b": [0.2275, 0.0791, 0.2601, 0.1005]}, {"w": "many", "b": [0.2649, 0.0791, 0.3116, 0.1005]}, {"w": "use", "b": [0.3163, 0.0791, 0.3439, 0.1005]}, {"w": "cases", "b": [0.3486, 0.0791, 0.3907, 0.1005]}, {"w": "in", "b": [0.3954, 0.0791, 0.4124, 0.1005]}, {"w": "which", "b": [0.4171, 0.0791, 0.468, 0.1005]}, {"w": "you", "b": [0.4728, 0.0791, 0.504, 0.1005]}, {"w": "may", "b": [0.5088, 0.0791, 0.5441, 0.1005]}, {"w": "want", "b": [0.5489, 0.0791, 0.5896, 0.1005]}, {"w": "to", "b": [0.5944, 0.0791, 0.6114, 0.1005]}, {"w": "have", "b": [0.6161, 0.0791, 0.6545, 0.1005]}, {"w": "multiple", "b": [0.6592, 0.0791, 0.7292, 0.1005]}, {"w": "outputs:", "b": [0.7339, 0.0791, 0.8027, 0.1005]}]}, {"id": "b_1", "type": "paragraph", "text": "• The task may demand it, for example you may want to locate and classify the main object in a picture. This is both a regression task (finding the coordinates of the object’s center, as well as its width and height) and a classification task.", "words": [{"w": "•", "b": [0.16, 0.1132, 0.1682, 0.1346]}, {"w": "The", "b": [0.1786, 0.1132, 0.2114, 0.1346]}, {"w": "task", "b": [0.219, 0.1132, 0.2525, 0.1346]}, {"w": "may", "b": [0.2601, 0.1132, 0.2955, 0.1346]}, {"w": "demand", "b": [0.3031, 0.1132, 0.3716, 0.1346]}, {"w": "it,", "b": [0.3792, 0.1132, 0.3959, 0.1346]}, {"w": "for", "b": [0.4035, 0.1132, 0.428, 0.1346]}, {"w": "example", "b": [0.4356, 0.1132, 0.5051, 0.1346]}, {"w": "you", "b": [0.5127, 0.1132, 0.544, 0.1346]}, {"w": "may", "b": [0.5516, 0.1132, 0.587, 0.1346]}, {"w": "want", "b": [0.5946, 0.1132, 0.6354, 0.1346]}, {"w": "to", "b": [0.643, 0.1132, 0.66, 0.1346]}, {"w": "locate", "b": [0.6676, 0.1132, 0.7162, 0.1346]}, {"w": "and", "b": [0.7239, 0.1132, 0.7554, 0.1346]}, {"w": "classify", "b": [0.763, 0.1132, 0.8232, 0.1346]}, {"w": "the", "b": [0.8308, 0.1132, 0.8571, 0.1346]}, {"w": "main", "b": [0.1786, 0.1323, 0.2218, 0.1537]}, {"w": "object", "b": [0.2267, 0.1323, 0.2772, 0.1537]}, {"w": "in", "b": [0.2821, 0.1323, 0.2991, 0.1537]}, {"w": "a", "b": [0.304, 0.1323, 0.3131, 0.1537]}, {"w": "picture.", "b": [0.318, 0.1323, 0.3821, 0.1537]}, {"w": "This", "b": [0.387, 0.1323, 0.4242, 0.1537]}, {"w": "is", "b": [0.4291, 0.1323, 0.4423, 0.1537]}, {"w": "both", "b": [0.4472, 0.1323, 0.4859, 0.1537]}, {"w": "a", "b": [0.4908, 0.1323, 0.4999, 0.1537]}, {"w": "regression", "b": [0.5048, 0.1323, 0.5906, 0.1537]}, {"w": "task", "b": [0.5955, 0.1323, 0.629, 0.1537]}, {"w": "(finding", "b": [0.6339, 0.1323, 0.702, 0.1537]}, {"w": "the", "b": [0.7069, 0.1323, 0.7332, 0.1537]}, {"w": "coordinates", "b": [0.7381, 0.1323, 0.8355, 0.1537]}, {"w": "of", "b": [0.8404, 0.1323, 0.8571, 0.1537]}, {"w": "the", "b": [0.1786, 0.1513, 0.2049, 0.1727]}, {"w": "object’s", "b": [0.2096, 0.1513, 0.2699, 0.1727]}, {"w": "center,", "b": [0.2747, 0.1513, 0.3297, 0.1727]}, {"w": "as", "b": [0.3344, 0.1513, 0.3512, 0.1727]}, {"w": "well", "b": [0.356, 0.1513, 0.3896, 0.1727]}, {"w": "as", "b": [0.3944, 0.1513, 0.4111, 0.1727]}, {"w": "its", "b": [0.4159, 0.1513, 0.4355, 0.1727]}, {"w": "width", "b": [0.4402, 0.1513, 0.4885, 0.1727]}, {"w": "and", "b": [0.4933, 0.1513, 0.5248, 0.1727]}, {"w": "height)", "b": [0.5295, 0.1513, 0.5891, 0.1727]}, {"w": "and", "b": [0.5939, 0.1513, 0.6254, 0.1727]}, {"w": "a", "b": [0.6301, 0.1513, 0.6393, 0.1727]}, {"w": "classification", "b": [0.644, 0.1513, 0.7514, 0.1727]}, {"w": "task.", "b": [0.7561, 0.1513, 0.7943, 0.1727]}]}, {"id": "b_2", "type": "paragraph", "text": "• Similarly, you may have multiple independent tasks to perform based on the same data. Sure, you could train one neural network per task, but in many cases you will get better results on all tasks by training a single neural network with one output per task. This is because the neural network can learn features in the data that are useful across tasks.", "words": [{"w": "•", "b": [0.16, 0.1764, 0.1682, 0.1978]}, {"w": "Similarly,", "b": [0.1786, 0.1764, 0.2569, 0.1978]}, {"w": "you", "b": [0.2657, 0.1764, 0.297, 0.1978]}, {"w": "may", "b": [0.3058, 0.1764, 0.3412, 0.1978]}, {"w": "have", "b": [0.35, 0.1764, 0.3884, 0.1978]}, {"w": "multiple", "b": [0.3973, 0.1764, 0.4673, 0.1978]}, {"w": "independent", "b": [0.4761, 0.1764, 0.5813, 0.1978]}, {"w": "tasks", "b": [0.5902, 0.1764, 0.6313, 0.1978]}, {"w": "to", "b": [0.6401, 0.1764, 0.6571, 0.1978]}, {"w": "perform", "b": [0.6659, 0.1764, 0.735, 0.1978]}, {"w": "based", "b": [0.7439, 0.1764, 0.7911, 0.1978]}, {"w": "on", "b": [0.7999, 0.1764, 0.822, 0.1978]}, {"w": "the", "b": [0.8308, 0.1764, 0.8571, 0.1978]}, {"w": "same", "b": [0.1786, 0.1955, 0.2213, 0.2169]}, {"w": "data.", "b": [0.2271, 0.1955, 0.2671, 0.2169]}, {"w": "Sure,", "b": [0.273, 0.1955, 0.3153, 0.2169]}, {"w": "you", "b": [0.3211, 0.1955, 0.3524, 0.2169]}, {"w": "could", "b": [0.3582, 0.1955, 0.405, 0.2169]}, {"w": "train", "b": [0.4108, 0.1955, 0.4511, 0.2169]}, {"w": "one", "b": [0.4569, 0.1955, 0.4878, 0.2169]}, {"w": "neural", "b": [0.4936, 0.1955, 0.5471, 0.2169]}, {"w": "network", "b": [0.553, 0.1955, 0.6225, 0.2169]}, {"w": "per", "b": [0.6284, 0.1955, 0.6559, 0.2169]}, {"w": "task,", "b": [0.6617, 0.1955, 0.7, 0.2169]}, {"w": "but", "b": [0.7058, 0.1955, 0.7338, 0.2169]}, {"w": "in", "b": [0.7397, 0.1955, 0.7566, 0.2169]}, {"w": "many", "b": [0.7625, 0.1955, 0.8092, 0.2169]}, {"w": "cases", "b": [0.815, 0.1955, 0.8571, 0.2169]}, {"w": "you", "b": [0.1786, 0.2145, 0.2098, 0.2359]}, {"w": "will", "b": [0.217, 0.2145, 0.2474, 0.2359]}, {"w": "get", "b": [0.2546, 0.2145, 0.2796, 0.2359]}, {"w": "better", "b": [0.2868, 0.2145, 0.3355, 0.2359]}, {"w": "results", "b": [0.3427, 0.2145, 0.3972, 0.2359]}, {"w": "on", "b": [0.4044, 0.2145, 0.4265, 0.2359]}, {"w": "all", "b": [0.4337, 0.2145, 0.4533, 0.2359]}, {"w": "tasks", "b": [0.4605, 0.2145, 0.5017, 0.2359]}, {"w": "by", "b": [0.5089, 0.2145, 0.529, 0.2359]}, {"w": "training", "b": [0.5362, 0.2145, 0.6031, 0.2359]}, {"w": "a", "b": [0.6103, 0.2145, 0.6195, 0.2359]}, {"w": "single", "b": [0.6267, 0.2145, 0.6752, 0.2359]}, {"w": "neural", "b": [0.6824, 0.2145, 0.7358, 0.2359]}, {"w": "network", "b": [0.743, 0.2145, 0.8126, 0.2359]}, {"w": "with", "b": [0.8198, 0.2145, 0.8571, 0.2359]}, {"w": "one", "b": [0.1786, 0.2336, 0.2094, 0.255]}, {"w": "output", "b": [0.2152, 0.2336, 0.2716, 0.255]}, {"w": "per", "b": [0.2774, 0.2336, 0.3049, 0.255]}, {"w": "task.", "b": [0.3106, 0.2336, 0.3489, 0.255]}, {"w": "This", "b": [0.3546, 0.2336, 0.3918, 0.255]}, {"w": "is", "b": [0.3976, 0.2336, 0.4108, 0.255]}, {"w": "because", "b": [0.4166, 0.2336, 0.4812, 0.255]}, {"w": "the", "b": [0.4869, 0.2336, 0.5133, 0.255]}, {"w": "neural", "b": [0.519, 0.2336, 0.5725, 0.255]}, {"w": "network", "b": [0.5783, 0.2336, 0.6478, 0.255]}, {"w": "can", "b": [0.6536, 0.2336, 0.6829, 0.255]}, {"w": "learn", "b": [0.6887, 0.2336, 0.7311, 0.255]}, {"w": "features", "b": [0.7369, 0.2336, 0.8023, 0.255]}, {"w": "in", "b": [0.8081, 0.2336, 0.825, 0.255]}, {"w": "the", "b": [0.8308, 0.2336, 0.8571, 0.255]}, {"w": "data", "b": [0.1786, 0.2526, 0.2138, 0.274]}, {"w": "that", "b": [0.2186, 0.2526, 0.2511, 0.274]}, {"w": "are", "b": [0.2559, 0.2526, 0.2816, 0.274]}, {"w": "useful", "b": [0.2863, 0.2526, 0.3364, 0.274]}, {"w": "across", "b": [0.3411, 0.2526, 0.3927, 0.274]}, {"w": "tasks.", "b": [0.3975, 0.2526, 0.4433, 0.274]}]}, {"id": "b_3", "type": "paragraph", "text": "• Another use case is as a regularization technique (i.e., a training constraint whose objective is to reduce overfitting and thus improve the model’s ability to general‐ ize). For example, you may want to add some auxiliary outputs in a neural net‐ work architecture (see Figure 10-15) to ensure that the underlying part of the network learns something useful on its own, without relying on the rest of the network.", "words": [{"w": "•", "b": [0.16, 0.2777, 0.1681, 0.2991]}, {"w": "Another", "b": [0.1786, 0.2777, 0.249, 0.2991]}, {"w": "use", "b": [0.2539, 0.2777, 0.2815, 0.2991]}, {"w": "case", "b": [0.2864, 0.2777, 0.3208, 0.2991]}, {"w": "is", "b": [0.3257, 0.2777, 0.3389, 0.2991]}, {"w": "as", "b": [0.3438, 0.2777, 0.3606, 0.2991]}, {"w": "a", "b": [0.3655, 0.2777, 0.3746, 0.2991]}, {"w": "regularization", "b": [0.3795, 0.2777, 0.4961, 0.2991]}, {"w": "technique", "b": [0.5009, 0.2777, 0.5836, 0.2991]}, {"w": "(i.e.,", "b": [0.5885, 0.2777, 0.6244, 0.2991]}, {"w": "a", "b": [0.6293, 0.2777, 0.6384, 0.2991]}, {"w": "training", "b": [0.6433, 0.2777, 0.7102, 0.2991]}, {"w": "constraint", "b": [0.7151, 0.2777, 0.7997, 0.2991]}, {"w": "whose", "b": [0.8046, 0.2777, 0.8571, 0.2991]}, {"w": "objective", "b": [0.1786, 0.2967, 0.2532, 0.3182]}, {"w": "is", "b": [0.2587, 0.2967, 0.2719, 0.3182]}, {"w": "to", "b": [0.2774, 0.2967, 0.2944, 0.3182]}, {"w": "reduce", "b": [0.2998, 0.2967, 0.3561, 0.3182]}, {"w": "overfitting", "b": [0.3616, 0.2967, 0.4497, 0.3182]}, {"w": "and", "b": [0.4551, 0.2967, 0.4867, 0.3182]}, {"w": "thus", "b": [0.4921, 0.2967, 0.5279, 0.3182]}, {"w": "improve", "b": [0.5334, 0.2967, 0.6034, 0.3182]}, {"w": "the", "b": [0.6089, 0.2967, 0.6352, 0.3182]}, {"w": "model’s", "b": [0.6407, 0.2967, 0.7033, 0.3182]}, {"w": "ability", "b": [0.7087, 0.2967, 0.7608, 0.3182]}, {"w": "to", "b": [0.7663, 0.2967, 0.7833, 0.3182]}, {"w": "general‐", "b": [0.7887, 0.2967, 0.8571, 0.3182]}, {"w": "ize).", "b": [0.1786, 0.3158, 0.2137, 0.3372]}, {"w": "For", "b": [0.2201, 0.3158, 0.2491, 0.3372]}, {"w": "example,", "b": [0.2555, 0.3158, 0.3298, 0.3372]}, {"w": "you", "b": [0.3362, 0.3158, 0.3674, 0.3372]}, {"w": "may", "b": [0.3739, 0.3158, 0.4092, 0.3372]}, {"w": "want", "b": [0.4157, 0.3158, 0.4564, 0.3372]}, {"w": "to", "b": [0.4628, 0.3158, 0.4798, 0.3372]}, {"w": "add", "b": [0.4862, 0.3158, 0.5174, 0.3372]}, {"w": "some", "b": [0.5238, 0.3158, 0.568, 0.3372]}, {"w": "auxiliary", "b": [0.5744, 0.3158, 0.6475, 0.3372]}, {"w": "outputs", "b": [0.6539, 0.3158, 0.7179, 0.3372]}, {"w": "in", "b": [0.7243, 0.3158, 0.7413, 0.3372]}, {"w": "a", "b": [0.7477, 0.3158, 0.7568, 0.3372]}, {"w": "neural", "b": [0.7632, 0.3158, 0.8167, 0.3372]}, {"w": "net‐", "b": [0.8231, 0.3158, 0.8571, 0.3372]}, {"w": "work", "b": [0.1786, 0.3348, 0.2215, 0.3563]}, {"w": "architecture", "b": [0.2293, 0.3348, 0.3298, 0.3563]}, {"w": "(see", "b": [0.3376, 0.3348, 0.3701, 0.3563]}, {"w": "Figure", "b": [0.3779, 0.3348, 0.4319, 0.3563]}, {"w": "10-15)", "b": [0.4397, 0.3348, 0.4944, 0.3563]}, {"w": "to", "b": [0.5022, 0.3348, 0.5192, 0.3563]}, {"w": "ensure", "b": [0.527, 0.3348, 0.5825, 0.3563]}, {"w": "that", "b": [0.5903, 0.3348, 0.6229, 0.3563]}, {"w": "the", "b": [0.6307, 0.3348, 0.657, 0.3563]}, {"w": "underlying", "b": [0.6648, 0.3348, 0.7564, 0.3563]}, {"w": "part", "b": [0.7643, 0.3348, 0.7984, 0.3563]}, {"w": "of", "b": [0.8062, 0.3348, 0.823, 0.3563]}, {"w": "the", "b": [0.8308, 0.3348, 0.8571, 0.3563]}, {"w": "network", "b": [0.1786, 0.3539, 0.2481, 0.3753]}, {"w": "learns", "b": [0.2552, 0.3539, 0.3053, 0.3753]}, {"w": "something", "b": [0.3124, 0.3539, 0.4008, 0.3753]}, {"w": "useful", "b": [0.4079, 0.3539, 0.4579, 0.3753]}, {"w": "on", "b": [0.465, 0.3539, 0.4871, 0.3753]}, {"w": "its", "b": [0.4942, 0.3539, 0.5137, 0.3753]}, {"w": "own,", "b": [0.5208, 0.3539, 0.5619, 0.3753]}, {"w": "without", "b": [0.569, 0.3539, 0.6344, 0.3753]}, {"w": "relying", "b": [0.6415, 0.3539, 0.6996, 0.3753]}, {"w": "on", "b": [0.7067, 0.3539, 0.7287, 0.3753]}, {"w": "the", "b": [0.7358, 0.3539, 0.7621, 0.3753]}, {"w": "rest", "b": [0.7692, 0.3539, 0.7998, 0.3753]}, {"w": "of", "b": [0.8069, 0.3539, 0.8237, 0.3753]}, {"w": "the", "b": [0.8308, 0.3539, 0.8572, 0.3753]}, {"w": "network.", "b": [0.1786, 0.3729, 0.2529, 0.3944]}]}, {"id": "b_4", "type": "equation", "text": "Figure 10-15. Handling Multiple Outputs – Auxiliary Output for Regularization", "words": [{"w": "Figure", "b": [0.1429, 0.7702, 0.1943, 0.7919]}, {"w": "10-15.", "b": [0.1991, 0.7702, 0.2507, 0.7919]}, {"w": "Handling", "b": [0.2554, 0.7702, 0.3314, 0.7919]}, {"w": "Multiple", "b": [0.3362, 0.7702, 0.4048, 0.7919]}, {"w": "Outputs", "b": [0.4096, 0.7702, 0.4758, 0.7919]}, {"w": "–", "b": [0.4805, 0.7702, 0.491, 0.7919]}, {"w": "Auxiliary", "b": [0.4957, 0.7702, 0.5738, 0.7919]}, {"w": "Output", "b": [0.5785, 0.7702, 0.6377, 0.7919]}, {"w": "for", "b": [0.6425, 0.7702, 0.6651, 0.7919]}, {"w": "Regularization", "b": [0.6699, 0.7702, 0.7898, 0.7919]}]}, {"id": "b_5", "type": "paragraph", "text": "Adding extra outputs is quite easy: just connect them to the appropriate layers and add them to your model’s list of outputs. For example, the following code builds the network represented in Figure 10-15:", "words": [{"w": "Adding", "b": [0.1429, 0.8076, 0.2054, 0.829]}, {"w": "extra", "b": [0.2123, 0.8076, 0.2543, 0.829]}, {"w": "outputs", "b": [0.2611, 0.8076, 0.3252, 0.829]}, {"w": "is", "b": [0.3321, 0.8076, 0.3453, 0.829]}, {"w": "quite", "b": [0.3522, 0.8076, 0.3947, 0.829]}, {"w": "easy:", "b": [0.4016, 0.8076, 0.4422, 0.829]}, {"w": "just", "b": [0.4491, 0.8076, 0.4795, 0.829]}, {"w": "connect", "b": [0.4863, 0.8076, 0.5526, 0.829]}, {"w": "them", "b": [0.5595, 0.8076, 0.6029, 0.829]}, {"w": "to", "b": [0.6098, 0.8076, 0.6268, 0.829]}, {"w": "the", "b": [0.6336, 0.8076, 0.66, 0.829]}, {"w": "appropriate", "b": [0.6669, 0.8076, 0.764, 0.829]}, {"w": "layers", "b": [0.7709, 0.8076, 0.8187, 0.829]}, {"w": "and", "b": [0.8256, 0.8076, 0.8571, 0.829]}, {"w": "add", "b": [0.1429, 0.8267, 0.174, 0.8481]}, {"w": "them", "b": [0.1801, 0.8267, 0.2235, 0.8481]}, {"w": "to", "b": [0.2296, 0.8267, 0.2466, 0.8481]}, {"w": "your", "b": [0.2527, 0.8267, 0.2917, 0.8481]}, {"w": "model’s", "b": [0.2978, 0.8267, 0.3604, 0.8481]}, {"w": "list", "b": [0.3665, 0.8267, 0.3913, 0.8481]}, {"w": "of", "b": [0.3974, 0.8267, 0.4142, 0.8481]}, {"w": "outputs.", "b": [0.4203, 0.8267, 0.4891, 0.8481]}, {"w": "For", "b": [0.4952, 0.8267, 0.5242, 0.8481]}, {"w": "example,", "b": [0.5303, 0.8267, 0.6046, 0.8481]}, {"w": "the", "b": [0.6107, 0.8267, 0.637, 0.8481]}, {"w": "following", "b": [0.6431, 0.8267, 0.7221, 0.8481]}, {"w": "code", "b": [0.7282, 0.8267, 0.7675, 0.8481]}, {"w": "builds", "b": [0.7736, 0.8267, 0.8247, 0.8481]}, {"w": "the", "b": [0.8308, 0.8267, 0.8571, 0.8481]}, {"w": "network", "b": [0.1428, 0.8457, 0.2124, 0.8671]}, {"w": "represented", "b": [0.2171, 0.8457, 0.3149, 0.8671]}, {"w": "in", "b": [0.3197, 0.8457, 0.3366, 0.8671]}, {"w": "Figure", "b": [0.3414, 0.8457, 0.3954, 0.8671]}, {"w": "10-15:", "b": [0.4001, 0.8457, 0.4523, 0.8671]}]}, {"id": "b_6", "type": "paragraph", "text": "308 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "308", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 335, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "[...] # Same as above, up to the main output layer output = keras.layers.Dense(1)(concat) aux_output = keras.layers.Dense(1)(hidden2) model = keras.models.Model(inputs=[input_A, input_B], outputs=[output, aux_output])", "words": [{"w": "[...]", "b": [0.1766, 0.0829, 0.2188, 0.0958]}, {"w": "#", "b": [0.2272, 0.0829, 0.2356, 0.0958]}, {"w": "Same", "b": [0.244, 0.0829, 0.2778, 0.0958]}, {"w": "as", "b": [0.2862, 0.0829, 0.3031, 0.0958]}, {"w": "above,", "b": [0.3115, 0.0829, 0.3621, 0.0958]}, {"w": "up", "b": [0.3705, 0.0829, 0.3874, 0.0958]}, {"w": "to", "b": [0.3958, 0.0829, 0.4127, 0.0958]}, {"w": "the", "b": [0.4211, 0.0829, 0.4464, 0.0958]}, {"w": "main", "b": [0.4549, 0.0829, 0.4886, 0.0958]}, {"w": "output", "b": [0.497, 0.0829, 0.5476, 0.0958]}, {"w": "layer", "b": [0.5561, 0.0829, 0.5982, 0.0958]}, {"w": "output", "b": [0.1766, 0.0983, 0.2272, 0.1112]}, {"w": "=", "b": [0.2356, 0.0983, 0.244, 0.1112]}, {"w": "keras.layers.Dense(1)(concat)", "b": [0.2525, 0.0983, 0.497, 0.1112]}, {"w": "aux_output", "b": [0.1766, 0.1138, 0.2609, 0.1266]}, {"w": "=", "b": [0.2693, 0.1138, 0.2778, 0.1266]}, {"w": "keras.layers.Dense(1)(hidden2)", "b": [0.2862, 0.1138, 0.5392, 0.1266]}, {"w": "model", "b": [0.1766, 0.1292, 0.2188, 0.142]}, {"w": "=", "b": [0.2272, 0.1292, 0.2356, 0.142]}, {"w": "keras.models.Model(inputs=[input_A,", "b": [0.244, 0.1292, 0.5392, 0.142]}, {"w": "input_B],", "b": [0.5476, 0.1292, 0.6235, 0.142]}, {"w": "outputs=[output,", "b": [0.4043, 0.1446, 0.5392, 0.1574]}, {"w": "aux_output])", "b": [0.5476, 0.1446, 0.6488, 0.1574]}]}, {"id": "b_1", "type": "paragraph", "text": "Each output will need its own loss function, so when we compile the model we should pass a list of losses (if we pass a single loss, Keras will assume that the same loss must be used for all outputs). By default, Keras will compute all these losses and simply add them up to get the final loss used for training. However, we care much more about the main output than about the auxiliary output (as it is just used for reg‐ ularization), so we want to give the main output’s loss a much greater weight. Fortu‐ nately, it is possible to set all the loss weights when compiling the model:", "words": [{"w": "Each", "b": [0.1429, 0.1652, 0.1838, 0.1866]}, {"w": "output", "b": [0.1929, 0.1652, 0.2492, 0.1866]}, {"w": "will", "b": [0.2583, 0.1652, 0.2887, 0.1866]}, {"w": "need", "b": [0.2978, 0.1652, 0.3379, 0.1866]}, {"w": "its", "b": [0.347, 0.1652, 0.3666, 0.1866]}, {"w": "own", "b": [0.3757, 0.1652, 0.412, 0.1866]}, {"w": "loss", "b": [0.4211, 0.1652, 0.4522, 0.1866]}, {"w": "function,", "b": [0.4613, 0.1652, 0.5375, 0.1866]}, {"w": "so", "b": [0.5466, 0.1652, 0.5648, 0.1866]}, {"w": "when", "b": [0.5739, 0.1652, 0.6196, 0.1866]}, {"w": "we", "b": [0.6287, 0.1652, 0.6518, 0.1866]}, {"w": "compile", "b": [0.6609, 0.1652, 0.7276, 0.1866]}, {"w": "the", "b": [0.7367, 0.1652, 0.763, 0.1866]}, {"w": "model", "b": [0.7721, 0.1652, 0.8249, 0.1866]}, {"w": "we", "b": [0.834, 0.1652, 0.8571, 0.1866]}, {"w": "should", "b": [0.1429, 0.1843, 0.1996, 0.2057]}, {"w": "pass", "b": [0.2062, 0.1843, 0.2416, 0.2057]}, {"w": "a", "b": [0.2482, 0.1843, 0.2573, 0.2057]}, {"w": "list", "b": [0.2639, 0.1843, 0.2888, 0.2057]}, {"w": "of", "b": [0.2954, 0.1843, 0.3122, 0.2057]}, {"w": "losses", "b": [0.3188, 0.1843, 0.3665, 0.2057]}, {"w": "(if", "b": [0.3731, 0.1843, 0.392, 0.2057]}, {"w": "we", "b": [0.3987, 0.1843, 0.4218, 0.2057]}, {"w": "pass", "b": [0.4284, 0.1843, 0.4637, 0.2057]}, {"w": "a", "b": [0.4704, 0.1843, 0.4795, 0.2057]}, {"w": "single", "b": [0.4861, 0.1843, 0.5346, 0.2057]}, {"w": "loss,", "b": [0.5412, 0.1843, 0.5772, 0.2057]}, {"w": "Keras", "b": [0.5838, 0.1843, 0.6307, 0.2057]}, {"w": "will", "b": [0.6373, 0.1843, 0.6677, 0.2057]}, {"w": "assume", "b": [0.6743, 0.1843, 0.7357, 0.2057]}, {"w": "that", "b": [0.7423, 0.1843, 0.7749, 0.2057]}, {"w": "the", "b": [0.7815, 0.1843, 0.8078, 0.2057]}, {"w": "same", "b": [0.8144, 0.1843, 0.8572, 0.2057]}, {"w": "loss", "b": [0.1429, 0.2033, 0.174, 0.2247]}, {"w": "must", "b": [0.1798, 0.2033, 0.2216, 0.2247]}, {"w": "be", "b": [0.2274, 0.2033, 0.2468, 0.2247]}, {"w": "used", "b": [0.2526, 0.2033, 0.2911, 0.2247]}, {"w": "for", "b": [0.2969, 0.2033, 0.3215, 0.2247]}, {"w": "all", "b": [0.3272, 0.2033, 0.3469, 0.2247]}, {"w": "outputs).", "b": [0.3527, 0.2033, 0.4287, 0.2247]}, {"w": "By", "b": [0.4345, 0.2033, 0.4563, 0.2247]}, {"w": "default,", "b": [0.4621, 0.2033, 0.5243, 0.2247]}, {"w": "Keras", "b": [0.5301, 0.2033, 0.577, 0.2247]}, {"w": "will", "b": [0.5828, 0.2033, 0.6132, 0.2247]}, {"w": "compute", "b": [0.619, 0.2033, 0.6922, 0.2247]}, {"w": "all", "b": [0.698, 0.2033, 0.7177, 0.2247]}, {"w": "these", "b": [0.7235, 0.2033, 0.7663, 0.2247]}, {"w": "losses", "b": [0.7721, 0.2033, 0.8198, 0.2247]}, {"w": "and", "b": [0.8256, 0.2033, 0.8571, 0.2247]}, {"w": "simply", "b": [0.1429, 0.2224, 0.1985, 0.2438]}, {"w": "add", "b": [0.2056, 0.2224, 0.2367, 0.2438]}, {"w": "them", "b": [0.2438, 0.2224, 0.2872, 0.2438]}, {"w": "up", "b": [0.2943, 0.2224, 0.3162, 0.2438]}, {"w": "to", "b": [0.3233, 0.2224, 0.3403, 0.2438]}, {"w": "get", "b": [0.3474, 0.2224, 0.3723, 0.2438]}, {"w": "the", "b": [0.3794, 0.2224, 0.4057, 0.2438]}, {"w": "final", "b": [0.4128, 0.2224, 0.4504, 0.2438]}, {"w": "loss", "b": [0.4575, 0.2224, 0.4886, 0.2438]}, {"w": "used", "b": [0.4957, 0.2224, 0.5343, 0.2438]}, {"w": "for", "b": [0.5414, 0.2224, 0.5659, 0.2438]}, {"w": "training.", "b": [0.573, 0.2224, 0.6446, 0.2438]}, {"w": "However,", "b": [0.6517, 0.2224, 0.7306, 0.2438]}, {"w": "we", "b": [0.7377, 0.2224, 0.7608, 0.2438]}, {"w": "care", "b": [0.7679, 0.2224, 0.8024, 0.2438]}, {"w": "much", "b": [0.8095, 0.2224, 0.8571, 0.2438]}, {"w": "more", "b": [0.1428, 0.2414, 0.1871, 0.2628]}, {"w": "about", "b": [0.192, 0.2414, 0.2398, 0.2628]}, {"w": "the", "b": [0.2447, 0.2414, 0.271, 0.2628]}, {"w": "main", "b": [0.2759, 0.2414, 0.3191, 0.2628]}, {"w": "output", "b": [0.324, 0.2414, 0.3804, 0.2628]}, {"w": "than", "b": [0.3853, 0.2414, 0.4233, 0.2628]}, {"w": "about", "b": [0.4282, 0.2414, 0.476, 0.2628]}, {"w": "the", "b": [0.4808, 0.2414, 0.5072, 0.2628]}, {"w": "auxiliary", "b": [0.5121, 0.2414, 0.5852, 0.2628]}, {"w": "output", "b": [0.5901, 0.2414, 0.6465, 0.2628]}, {"w": "(as", "b": [0.6514, 0.2414, 0.6754, 0.2628]}, {"w": "it", "b": [0.6803, 0.2414, 0.6922, 0.2628]}, {"w": "is", "b": [0.6971, 0.2414, 0.7103, 0.2628]}, {"w": "just", "b": [0.7152, 0.2414, 0.7456, 0.2628]}, {"w": "used", "b": [0.7505, 0.2414, 0.7891, 0.2628]}, {"w": "for", "b": [0.794, 0.2414, 0.8185, 0.2628]}, {"w": "reg‐", "b": [0.8234, 0.2414, 0.8571, 0.2628]}, {"w": "ularization),", "b": [0.1429, 0.2605, 0.2451, 0.2819]}, {"w": "so", "b": [0.251, 0.2605, 0.2693, 0.2819]}, {"w": "we", "b": [0.2752, 0.2605, 0.2984, 0.2819]}, {"w": "want", "b": [0.3043, 0.2605, 0.3451, 0.2819]}, {"w": "to", "b": [0.351, 0.2605, 0.368, 0.2819]}, {"w": "give", "b": [0.374, 0.2605, 0.4078, 0.2819]}, {"w": "the", "b": [0.4138, 0.2605, 0.4401, 0.2819]}, {"w": "main", "b": [0.446, 0.2605, 0.4892, 0.2819]}, {"w": "output’s", "b": [0.4952, 0.2605, 0.5613, 0.2819]}, {"w": "loss", "b": [0.5673, 0.2605, 0.5985, 0.2819]}, {"w": "a", "b": [0.6044, 0.2605, 0.6135, 0.2819]}, {"w": "much", "b": [0.6195, 0.2605, 0.6672, 0.2819]}, {"w": "greater", "b": [0.6731, 0.2605, 0.7311, 0.2819]}, {"w": "weight.", "b": [0.7371, 0.2605, 0.7974, 0.2819]}, {"w": "Fortu‐", "b": [0.8033, 0.2605, 0.8571, 0.2819]}, {"w": "nately,", "b": [0.1429, 0.2795, 0.1963, 0.3009]}, {"w": "it", "b": [0.201, 0.2795, 0.2129, 0.3009]}, {"w": "is", "b": [0.2177, 0.2795, 0.2309, 0.3009]}, {"w": "possible", "b": [0.2356, 0.2795, 0.3028, 0.3009]}, {"w": "to", "b": [0.3075, 0.2795, 0.3245, 0.3009]}, {"w": "set", "b": [0.3292, 0.2795, 0.352, 0.3009]}, {"w": "all", "b": [0.3568, 0.2795, 0.3765, 0.3009]}, {"w": "the", "b": [0.3812, 0.2795, 0.4075, 0.3009]}, {"w": "loss", "b": [0.4123, 0.2795, 0.4434, 0.3009]}, {"w": "weights", "b": [0.4482, 0.2795, 0.5114, 0.3009]}, {"w": "when", "b": [0.5161, 0.2795, 0.5617, 0.3009]}, {"w": "compiling", "b": [0.5665, 0.2795, 0.6511, 0.3009]}, {"w": "the", "b": [0.6558, 0.2795, 0.6821, 0.3009]}, {"w": "model:", "b": [0.6869, 0.2795, 0.7444, 0.3009]}]}, {"id": "b_2", "type": "equation", "text": "model.compile(loss=[\"mse\", \"mse\"], loss_weights=[0.9, 0.1], optimizer=\"sgd\")", "words": [{"w": "model.compile(loss=[\"mse\",", "b": [0.1766, 0.3115, 0.3958, 0.3243]}, {"w": "\"mse\"],", "b": [0.4043, 0.3115, 0.4633, 0.3243]}, {"w": "loss_weights=[0.9,", "b": [0.4717, 0.3115, 0.6235, 0.3243]}, {"w": "0.1],", "b": [0.6319, 0.3115, 0.6741, 0.3243]}, {"w": "optimizer=\"sgd\")", "b": [0.6825, 0.3115, 0.8175, 0.3243]}]}, {"id": "b_3", "type": "paragraph", "text": "Now when we train the model, we need to provide some labels for each output. In this example, the main output and the auxiliary output should try to predict the same thing, so they should use the same labels. So instead of passing y_train, we just need to pass (y_train, y_train) (and the same goes for y_valid and y_test):", "words": [{"w": "Now", "b": [0.1429, 0.3321, 0.1827, 0.3535]}, {"w": "when", "b": [0.1896, 0.3321, 0.2353, 0.3535]}, {"w": "we", "b": [0.2422, 0.3321, 0.2653, 0.3535]}, {"w": "train", "b": [0.2723, 0.3321, 0.3125, 0.3535]}, {"w": "the", "b": [0.3194, 0.3321, 0.3457, 0.3535]}, {"w": "model,", "b": [0.3527, 0.3321, 0.4102, 0.3535]}, {"w": "we", "b": [0.4172, 0.3321, 0.4403, 0.3535]}, {"w": "need", "b": [0.4472, 0.3321, 0.4873, 0.3535]}, {"w": "to", "b": [0.4943, 0.3321, 0.5112, 0.3535]}, {"w": "provide", "b": [0.5182, 0.3321, 0.5825, 0.3535]}, {"w": "some", "b": [0.5895, 0.3321, 0.6336, 0.3535]}, {"w": "labels", "b": [0.6406, 0.3321, 0.6873, 0.3535]}, {"w": "for", "b": [0.6943, 0.3321, 0.7188, 0.3535]}, {"w": "each", "b": [0.7257, 0.3321, 0.7637, 0.3535]}, {"w": "output.", "b": [0.7706, 0.3321, 0.8317, 0.3535]}, {"w": "In", "b": [0.8386, 0.3321, 0.8571, 0.3535]}, {"w": "this", "b": [0.1429, 0.3512, 0.1736, 0.3726]}, {"w": "example,", "b": [0.1785, 0.3512, 0.2528, 0.3726]}, {"w": "the", "b": [0.2578, 0.3512, 0.2842, 0.3726]}, {"w": "main", "b": [0.2891, 0.3512, 0.3323, 0.3726]}, {"w": "output", "b": [0.3373, 0.3512, 0.3937, 0.3726]}, {"w": "and", "b": [0.3987, 0.3512, 0.4302, 0.3726]}, {"w": "the", "b": [0.4352, 0.3512, 0.4615, 0.3726]}, {"w": "auxiliary", "b": [0.4665, 0.3512, 0.5396, 0.3726]}, {"w": "output", "b": [0.5446, 0.3512, 0.601, 0.3726]}, {"w": "should", "b": [0.606, 0.3512, 0.6627, 0.3726]}, {"w": "try", "b": [0.6677, 0.3512, 0.6919, 0.3726]}, {"w": "to", "b": [0.6969, 0.3512, 0.7139, 0.3726]}, {"w": "predict", "b": [0.7189, 0.3512, 0.7781, 0.3726]}, {"w": "the", "b": [0.7831, 0.3512, 0.8094, 0.3726]}, {"w": "same", "b": [0.8144, 0.3512, 0.8571, 0.3726]}, {"w": "thing,", "b": [0.1428, 0.3711, 0.1918, 0.3925]}, {"w": "so", "b": [0.1971, 0.3711, 0.2154, 0.3925]}, {"w": "they", "b": [0.2207, 0.3711, 0.2565, 0.3925]}, {"w": "should", "b": [0.2618, 0.3711, 0.3186, 0.3925]}, {"w": "use", "b": [0.3239, 0.3711, 0.3514, 0.3925]}, {"w": "the", "b": [0.3567, 0.3711, 0.383, 0.3925]}, {"w": "same", "b": [0.3883, 0.3711, 0.431, 0.3925]}, {"w": "labels.", "b": [0.4363, 0.3711, 0.4878, 0.3925]}, {"w": "So", "b": [0.4931, 0.3711, 0.5136, 0.3925]}, {"w": "instead", "b": [0.5189, 0.3711, 0.5789, 0.3925]}, {"w": "of", "b": [0.5842, 0.3711, 0.601, 0.3925]}, {"w": "passing", "b": [0.6063, 0.3711, 0.6683, 0.3925]}, {"w": "y_train,", "b": [0.6736, 0.3711, 0.7477, 0.3925]}, {"w": "we", "b": [0.753, 0.3711, 0.7761, 0.3925]}, {"w": "just", "b": [0.7814, 0.3711, 0.8118, 0.3925]}, {"w": "need", "b": [0.817, 0.3711, 0.8572, 0.3925]}, {"w": "to", "b": [0.1429, 0.3911, 0.1598, 0.4125]}, {"w": "pass", "b": [0.1646, 0.3911, 0.1999, 0.4125]}, {"w": "(y_train,", "b": [0.2047, 0.3942, 0.2937, 0.4093]}, {"w": "y_train)", "b": [0.3036, 0.3942, 0.3828, 0.4093]}, {"w": "(and", "b": [0.3875, 0.3911, 0.4263, 0.4125]}, {"w": "the", "b": [0.431, 0.3911, 0.4573, 0.4125]}, {"w": "same", "b": [0.462, 0.3911, 0.5048, 0.4125]}, {"w": "goes", "b": [0.5095, 0.3911, 0.5464, 0.4125]}, {"w": "for", "b": [0.5511, 0.3911, 0.5756, 0.4125]}, {"w": "y_valid", "b": [0.5803, 0.3942, 0.6496, 0.4093]}, {"w": "and", "b": [0.6543, 0.3911, 0.6859, 0.4125]}, {"w": "y_test):", "b": [0.6906, 0.3911, 0.7619, 0.4125]}]}, {"id": "b_4", "type": "paragraph", "text": "history = model.fit( [X_train_A, X_train_B], [y_train, y_train], epochs=20, validation_data=([X_valid_A, X_valid_B], [y_valid, y_valid]))", "words": [{"w": "history", "b": [0.1766, 0.423, 0.2356, 0.4359]}, {"w": "=", "b": [0.2441, 0.423, 0.2525, 0.4359]}, {"w": "model.fit(", "b": [0.2609, 0.423, 0.3452, 0.4359]}, {"w": "[X_train_A,", "b": [0.2103, 0.4385, 0.3031, 0.4513]}, {"w": "X_train_B],", "b": [0.3115, 0.4385, 0.4043, 0.4513]}, {"w": "[y_train,", "b": [0.4127, 0.4385, 0.4886, 0.4513]}, {"w": "y_train],", "b": [0.497, 0.4385, 0.5729, 0.4513]}, {"w": "epochs=20,", "b": [0.5814, 0.4385, 0.6657, 0.4513]}, {"w": "validation_data=([X_valid_A,", "b": [0.2103, 0.4539, 0.4464, 0.4667]}, {"w": "X_valid_B],", "b": [0.4549, 0.4539, 0.5476, 0.4667]}, {"w": "[y_valid,", "b": [0.5561, 0.4539, 0.6319, 0.4667]}, {"w": "y_valid]))", "b": [0.6404, 0.4539, 0.7247, 0.4667]}]}, {"id": "b_5", "type": "paragraph", "text": "When we evaluate the model, Keras will return the total loss, as well as all the individ‐ ual losses:", "words": [{"w": "When", "b": [0.1429, 0.4745, 0.1945, 0.4959]}, {"w": "we", "b": [0.1993, 0.4745, 0.2224, 0.4959]}, {"w": "evaluate", "b": [0.2272, 0.4745, 0.2951, 0.4959]}, {"w": "the", "b": [0.2999, 0.4745, 0.3263, 0.4959]}, {"w": "model,", "b": [0.3311, 0.4745, 0.3886, 0.4959]}, {"w": "Keras", "b": [0.3934, 0.4745, 0.4403, 0.4959]}, {"w": "will", "b": [0.4451, 0.4745, 0.4755, 0.4959]}, {"w": "return", "b": [0.4803, 0.4745, 0.5334, 0.4959]}, {"w": "the", "b": [0.5382, 0.4745, 0.5646, 0.4959]}, {"w": "total", "b": [0.5694, 0.4745, 0.6071, 0.4959]}, {"w": "loss,", "b": [0.6119, 0.4745, 0.6479, 0.4959]}, {"w": "as", "b": [0.6527, 0.4745, 0.6694, 0.4959]}, {"w": "well", "b": [0.6742, 0.4745, 0.7079, 0.4959]}, {"w": "as", "b": [0.7127, 0.4745, 0.7295, 0.4959]}, {"w": "all", "b": [0.7343, 0.4745, 0.754, 0.4959]}, {"w": "the", "b": [0.7588, 0.4745, 0.7851, 0.4959]}, {"w": "individ‐", "b": [0.7899, 0.4745, 0.8571, 0.4959]}, {"w": "ual", "b": [0.1429, 0.4936, 0.1683, 0.515]}, {"w": "losses:", "b": [0.1731, 0.4936, 0.2255, 0.515]}]}, {"id": "b_6", "type": "paragraph", "text": "total_loss, main_loss, aux_loss = model.evaluate( [X_test_A, X_test_B], [y_test, y_test])", "words": [{"w": "total_loss,", "b": [0.1766, 0.5255, 0.2693, 0.5384]}, {"w": "main_loss,", "b": [0.2778, 0.5255, 0.3621, 0.5384]}, {"w": "aux_loss", "b": [0.3705, 0.5255, 0.438, 0.5384]}, {"w": "=", "b": [0.4464, 0.5255, 0.4549, 0.5384]}, {"w": "model.evaluate(", "b": [0.4633, 0.5255, 0.5898, 0.5384]}, {"w": "[X_test_A,", "b": [0.2103, 0.5409, 0.2946, 0.5538]}, {"w": "X_test_B],", "b": [0.3031, 0.5409, 0.3874, 0.5538]}, {"w": "[y_test,", "b": [0.3958, 0.5409, 0.4633, 0.5538]}, {"w": "y_test])", "b": [0.4717, 0.5409, 0.5392, 0.5538]}]}, {"id": "b_7", "type": "paragraph", "text": "Similarly, the predict() method will return predictions for each output:", "words": [{"w": "Similarly,", "b": [0.1429, 0.5625, 0.2212, 0.5839]}, {"w": "the", "b": [0.2259, 0.5625, 0.2522, 0.5839]}, {"w": "predict()", "b": [0.257, 0.5657, 0.346, 0.5807]}, {"w": "method", "b": [0.3507, 0.5625, 0.4158, 0.5839]}, {"w": "will", "b": [0.4205, 0.5625, 0.4509, 0.5839]}, {"w": "return", "b": [0.4556, 0.5625, 0.5087, 0.5839]}, {"w": "predictions", "b": [0.5135, 0.5625, 0.608, 0.5839]}, {"w": "for", "b": [0.6127, 0.5625, 0.6372, 0.5839]}, {"w": "each", "b": [0.642, 0.5625, 0.6799, 0.5839]}, {"w": "output:", "b": [0.6846, 0.5625, 0.7457, 0.5839]}]}, {"id": "b_8", "type": "equation", "text": "y_pred_main, y_pred_aux = model.predict([X_new_A, X_new_B])", "words": [{"w": "y_pred_main,", "b": [0.1766, 0.5945, 0.2778, 0.6073]}, {"w": "y_pred_aux", "b": [0.2862, 0.5945, 0.3705, 0.6073]}, {"w": "=", "b": [0.379, 0.5945, 0.3874, 0.6073]}, {"w": "model.predict([X_new_A,", "b": [0.3958, 0.5945, 0.5898, 0.6073]}, {"w": "X_new_B])", "b": [0.5982, 0.5945, 0.6741, 0.6073]}]}, {"id": "b_9", "type": "paragraph", "text": "As you can see, you can build any sort of architecture you want quite easily with the Functional API. Let’s look at one last way you can build Keras models.", "words": [{"w": "As", "b": [0.1429, 0.6151, 0.1649, 0.6365]}, {"w": "you", "b": [0.1708, 0.6151, 0.202, 0.6365]}, {"w": "can", "b": [0.2079, 0.6151, 0.2373, 0.6365]}, {"w": "see,", "b": [0.2431, 0.6151, 0.2732, 0.6365]}, {"w": "you", "b": [0.2791, 0.6151, 0.3104, 0.6365]}, {"w": "can", "b": [0.3162, 0.6151, 0.3456, 0.6365]}, {"w": "build", "b": [0.3515, 0.6151, 0.395, 0.6365]}, {"w": "any", "b": [0.4008, 0.6151, 0.4305, 0.6365]}, {"w": "sort", "b": [0.4363, 0.6151, 0.4687, 0.6365]}, {"w": "of", "b": [0.4746, 0.6151, 0.4914, 0.6365]}, {"w": "architecture", "b": [0.4972, 0.6151, 0.5976, 0.6365]}, {"w": "you", "b": [0.6035, 0.6151, 0.6348, 0.6365]}, {"w": "want", "b": [0.6406, 0.6151, 0.6814, 0.6365]}, {"w": "quite", "b": [0.6873, 0.6151, 0.7298, 0.6365]}, {"w": "easily", "b": [0.7357, 0.6151, 0.7817, 0.6365]}, {"w": "with", "b": [0.7876, 0.6151, 0.8249, 0.6365]}, {"w": "the", "b": [0.8308, 0.6151, 0.8571, 0.6365]}, {"w": "Functional", "b": [0.1429, 0.6341, 0.2331, 0.6555]}, {"w": "API.", "b": [0.2378, 0.6341, 0.2758, 0.6555]}, {"w": "Let’s", "b": [0.2805, 0.6341, 0.3167, 0.6555]}, {"w": "look", "b": [0.3214, 0.6341, 0.3583, 0.6555]}, {"w": "at", "b": [0.363, 0.6341, 0.3781, 0.6555]}, {"w": "one", "b": [0.3829, 0.6341, 0.4137, 0.6555]}, {"w": "last", "b": [0.4185, 0.6341, 0.4469, 0.6555]}, {"w": "way", "b": [0.4516, 0.6341, 0.4842, 0.6555]}, {"w": "you", "b": [0.4889, 0.6341, 0.5202, 0.6555]}, {"w": "can", "b": [0.5249, 0.6341, 0.5543, 0.6555]}, {"w": "build", "b": [0.559, 0.6341, 0.6025, 0.6555]}, {"w": "Keras", "b": [0.6072, 0.6341, 0.6541, 0.6555]}, {"w": "models.", "b": [0.6589, 0.6341, 0.7241, 0.6555]}]}, {"id": "b_10", "type": "paragraph", "text": "Building Dynamic Models Using the Subclassing API", "words": [{"w": "Building", "b": [0.1429, 0.6683, 0.23, 0.6969]}, {"w": "Dynamic", "b": [0.2349, 0.6683, 0.3238, 0.6969]}, {"w": "Models", "b": [0.3288, 0.6683, 0.4028, 0.6969]}, {"w": "Using", "b": [0.4078, 0.6683, 0.4658, 0.6969]}, {"w": "the", "b": [0.4707, 0.6683, 0.5056, 0.6969]}, {"w": "Subclassing", "b": [0.5105, 0.6683, 0.6304, 0.6969]}, {"w": "API", "b": [0.6353, 0.6683, 0.6699, 0.6969]}]}, {"id": "b_11", "type": "paragraph", "text": "Both the Sequential API and the Functional API are declarative: you start by declar‐ ing which layers you want to use and how they should be connected, and only then can you start feeding the model some data for training or inference. This has many advantages: the model can easily be saved, cloned, shared, its structure can be dis‐ played and analyzed, the framework can infer shapes and check types, so errors can be caught early (i.e., before any data ever goes through the model). It’s also fairly easy to debug, since the whole model is just a static graph of layers. But the flip side is just that: it’s static. Some models involve loops, varying shapes, conditional branching, and other dynamic behaviors. For such cases, or simply if you prefer a more impera‐ tive programming style, the Subclassing API is for you.", "words": [{"w": "Both", "b": [0.1429, 0.7028, 0.1836, 0.7242]}, {"w": "the", "b": [0.1897, 0.7028, 0.216, 0.7242]}, {"w": "Sequential", "b": [0.2221, 0.7028, 0.3087, 0.7242]}, {"w": "API", "b": [0.3147, 0.7028, 0.348, 0.7242]}, {"w": "and", "b": [0.354, 0.7028, 0.3856, 0.7242]}, {"w": "the", "b": [0.3916, 0.7028, 0.4179, 0.7242]}, {"w": "Functional", "b": [0.424, 0.7028, 0.5142, 0.7242]}, {"w": "API", "b": [0.5203, 0.7028, 0.5535, 0.7242]}, {"w": "are", "b": [0.5596, 0.7028, 0.5853, 0.7242]}, {"w": "declarative:", "b": [0.5913, 0.7028, 0.6861, 0.7242]}, {"w": "you", "b": [0.6921, 0.7028, 0.7234, 0.7242]}, {"w": "start", "b": [0.7294, 0.7028, 0.7667, 0.7242]}, {"w": "by", "b": [0.7727, 0.7028, 0.7929, 0.7242]}, {"w": "declar‐", "b": [0.7989, 0.7028, 0.8571, 0.7242]}, {"w": "ing", "b": [0.1428, 0.7218, 0.1696, 0.7432]}, {"w": "which", "b": [0.176, 0.7218, 0.2269, 0.7432]}, {"w": "layers", "b": [0.2332, 0.7218, 0.2811, 0.7432]}, {"w": "you", "b": [0.2875, 0.7218, 0.3187, 0.7432]}, {"w": "want", "b": [0.3251, 0.7218, 0.3659, 0.7432]}, {"w": "to", "b": [0.3722, 0.7218, 0.3892, 0.7432]}, {"w": "use", "b": [0.3956, 0.7218, 0.4231, 0.7432]}, {"w": "and", "b": [0.4295, 0.7218, 0.4611, 0.7432]}, {"w": "how", "b": [0.4674, 0.7218, 0.5035, 0.7432]}, {"w": "they", "b": [0.5098, 0.7218, 0.5457, 0.7432]}, {"w": "should", "b": [0.5521, 0.7218, 0.6088, 0.7432]}, {"w": "be", "b": [0.6152, 0.7218, 0.6347, 0.7432]}, {"w": "connected,", "b": [0.641, 0.7218, 0.7319, 0.7432]}, {"w": "and", "b": [0.7383, 0.7218, 0.7698, 0.7432]}, {"w": "only", "b": [0.7762, 0.7218, 0.813, 0.7432]}, {"w": "then", "b": [0.8194, 0.7218, 0.8571, 0.7432]}, {"w": "can", "b": [0.1429, 0.7409, 0.1722, 0.7623]}, {"w": "you", "b": [0.1788, 0.7409, 0.2101, 0.7623]}, {"w": "start", "b": [0.2166, 0.7409, 0.2539, 0.7623]}, {"w": "feeding", "b": [0.2605, 0.7409, 0.3221, 0.7623]}, {"w": "the", "b": [0.3287, 0.7409, 0.355, 0.7623]}, {"w": "model", "b": [0.3616, 0.7409, 0.4144, 0.7623]}, {"w": "some", "b": [0.421, 0.7409, 0.4652, 0.7623]}, {"w": "data", "b": [0.4718, 0.7409, 0.507, 0.7623]}, {"w": "for", "b": [0.5136, 0.7409, 0.5381, 0.7623]}, {"w": "training", "b": [0.5447, 0.7409, 0.6116, 0.7623]}, {"w": "or", "b": [0.6182, 0.7409, 0.6366, 0.7623]}, {"w": "inference.", "b": [0.6432, 0.7409, 0.7256, 0.7623]}, {"w": "This", "b": [0.7322, 0.7409, 0.7694, 0.7623]}, {"w": "has", "b": [0.776, 0.7409, 0.8039, 0.7623]}, {"w": "many", "b": [0.8105, 0.7409, 0.8571, 0.7623]}, {"w": "advantages:", "b": [0.1429, 0.7599, 0.2393, 0.7813]}, {"w": "the", "b": [0.2467, 0.7599, 0.2731, 0.7813]}, {"w": "model", "b": [0.2805, 0.7599, 0.3333, 0.7813]}, {"w": "can", "b": [0.3407, 0.7599, 0.3701, 0.7813]}, {"w": "easily", "b": [0.3775, 0.7599, 0.4236, 0.7813]}, {"w": "be", "b": [0.431, 0.7599, 0.4504, 0.7813]}, {"w": "saved,", "b": [0.4579, 0.7599, 0.5085, 0.7813]}, {"w": "cloned,", "b": [0.516, 0.7599, 0.5767, 0.7813]}, {"w": "shared,", "b": [0.5841, 0.7599, 0.6444, 0.7813]}, {"w": "its", "b": [0.6518, 0.7599, 0.6714, 0.7813]}, {"w": "structure", "b": [0.6788, 0.7599, 0.7544, 0.7813]}, {"w": "can", "b": [0.7618, 0.7599, 0.7912, 0.7813]}, {"w": "be", "b": [0.7986, 0.7599, 0.8181, 0.7813]}, {"w": "dis‐", "b": [0.8255, 0.7599, 0.8571, 0.7813]}, {"w": "played", "b": [0.1429, 0.779, 0.1972, 0.8004]}, {"w": "and", "b": [0.2036, 0.779, 0.2351, 0.8004]}, {"w": "analyzed,", "b": [0.2415, 0.779, 0.3194, 0.8004]}, {"w": "the", "b": [0.3257, 0.779, 0.3521, 0.8004]}, {"w": "framework", "b": [0.3584, 0.779, 0.4503, 0.8004]}, {"w": "can", "b": [0.4567, 0.779, 0.4861, 0.8004]}, {"w": "infer", "b": [0.4924, 0.779, 0.5322, 0.8004]}, {"w": "shapes", "b": [0.5385, 0.779, 0.5935, 0.8004]}, {"w": "and", "b": [0.5998, 0.779, 0.6314, 0.8004]}, {"w": "check", "b": [0.6377, 0.779, 0.6857, 0.8004]}, {"w": "types,", "b": [0.692, 0.779, 0.7401, 0.8004]}, {"w": "so", "b": [0.7465, 0.779, 0.7647, 0.8004]}, {"w": "errors", "b": [0.7711, 0.779, 0.8214, 0.8004]}, {"w": "can", "b": [0.8278, 0.779, 0.8571, 0.8004]}, {"w": "be", "b": [0.1429, 0.798, 0.1623, 0.8194]}, {"w": "caught", "b": [0.1677, 0.798, 0.2231, 0.8194]}, {"w": "early", "b": [0.2285, 0.798, 0.2691, 0.8194]}, {"w": "(i.e.,", "b": [0.2745, 0.798, 0.3104, 0.8194]}, {"w": "before", "b": [0.3157, 0.798, 0.3685, 0.8194]}, {"w": "any", "b": [0.3739, 0.798, 0.4035, 0.8194]}, {"w": "data", "b": [0.4089, 0.798, 0.4442, 0.8194]}, {"w": "ever", "b": [0.4496, 0.798, 0.4846, 0.8194]}, {"w": "goes", "b": [0.49, 0.798, 0.5269, 0.8194]}, {"w": "through", "b": [0.5323, 0.798, 0.6, 0.8194]}, {"w": "the", "b": [0.6054, 0.798, 0.6317, 0.8194]}, {"w": "model).", "b": [0.6371, 0.798, 0.7019, 0.8194]}, {"w": "It’s", "b": [0.7073, 0.798, 0.7297, 0.8194]}, {"w": "also", "b": [0.735, 0.798, 0.7677, 0.8194]}, {"w": "fairly", "b": [0.7731, 0.798, 0.8166, 0.8194]}, {"w": "easy", "b": [0.8219, 0.798, 0.8572, 0.8194]}, {"w": "to", "b": [0.1429, 0.8171, 0.1598, 0.8385]}, {"w": "debug,", "b": [0.1651, 0.8171, 0.2211, 0.8385]}, {"w": "since", "b": [0.2264, 0.8171, 0.2687, 0.8385]}, {"w": "the", "b": [0.274, 0.8171, 0.3003, 0.8385]}, {"w": "whole", "b": [0.3056, 0.8171, 0.3558, 0.8385]}, {"w": "model", "b": [0.361, 0.8171, 0.4139, 0.8385]}, {"w": "is", "b": [0.4191, 0.8171, 0.4324, 0.8385]}, {"w": "just", "b": [0.4377, 0.8171, 0.4681, 0.8385]}, {"w": "a", "b": [0.4733, 0.8171, 0.4825, 0.8385]}, {"w": "static", "b": [0.4878, 0.8171, 0.5313, 0.8385]}, {"w": "graph", "b": [0.5366, 0.8171, 0.5848, 0.8385]}, {"w": "of", "b": [0.5901, 0.8171, 0.6069, 0.8385]}, {"w": "layers.", "b": [0.6122, 0.8171, 0.6648, 0.8385]}, {"w": "But", "b": [0.6701, 0.8171, 0.6997, 0.8385]}, {"w": "the", "b": [0.705, 0.8171, 0.7314, 0.8385]}, {"w": "flip", "b": [0.7366, 0.8171, 0.7646, 0.8385]}, {"w": "side", "b": [0.7699, 0.8171, 0.8029, 0.8385]}, {"w": "is", "b": [0.8082, 0.8171, 0.8215, 0.8385]}, {"w": "just", "b": [0.8268, 0.8171, 0.8571, 0.8385]}, {"w": "that:", "b": [0.1429, 0.8361, 0.1802, 0.8575]}, {"w": "it’s", "b": [0.1882, 0.8361, 0.2099, 0.8575]}, {"w": "static.", "b": [0.218, 0.8361, 0.2662, 0.8575]}, {"w": "Some", "b": [0.2743, 0.8361, 0.3207, 0.8575]}, {"w": "models", "b": [0.3288, 0.8361, 0.3892, 0.8575]}, {"w": "involve", "b": [0.3973, 0.8361, 0.4578, 0.8575]}, {"w": "loops,", "b": [0.4659, 0.8361, 0.5157, 0.8575]}, {"w": "varying", "b": [0.5238, 0.8361, 0.5872, 0.8575]}, {"w": "shapes,", "b": [0.5953, 0.8361, 0.655, 0.8575]}, {"w": "conditional", "b": [0.663, 0.8361, 0.7588, 0.8575]}, {"w": "branching,", "b": [0.7669, 0.8361, 0.8571, 0.8575]}, {"w": "and", "b": [0.1428, 0.8552, 0.1744, 0.8766]}, {"w": "other", "b": [0.18, 0.8552, 0.2247, 0.8766]}, {"w": "dynamic", "b": [0.2303, 0.8552, 0.3029, 0.8766]}, {"w": "behaviors.", "b": [0.3085, 0.8552, 0.3938, 0.8766]}, {"w": "For", "b": [0.3994, 0.8552, 0.4284, 0.8766]}, {"w": "such", "b": [0.434, 0.8552, 0.4727, 0.8766]}, {"w": "cases,", "b": [0.4783, 0.8552, 0.5252, 0.8766]}, {"w": "or", "b": [0.5308, 0.8552, 0.5491, 0.8766]}, {"w": "simply", "b": [0.5548, 0.8552, 0.6104, 0.8766]}, {"w": "if", "b": [0.616, 0.8552, 0.6278, 0.8766]}, {"w": "you", "b": [0.6334, 0.8552, 0.6647, 0.8766]}, {"w": "prefer", "b": [0.6703, 0.8552, 0.7205, 0.8766]}, {"w": "a", "b": [0.7262, 0.8552, 0.7353, 0.8766]}, {"w": "more", "b": [0.7409, 0.8552, 0.7852, 0.8766]}, {"w": "impera‐", "b": [0.7908, 0.8552, 0.8571, 0.8766]}, {"w": "tive", "b": [0.1429, 0.8742, 0.1733, 0.8956]}, {"w": "programming", "b": [0.178, 0.8742, 0.2948, 0.8956]}, {"w": "style,", "b": [0.2995, 0.8742, 0.3419, 0.8956]}, {"w": "the", "b": [0.3467, 0.8742, 0.373, 0.8956]}, {"w": "Subclassing", "b": [0.3777, 0.8742, 0.4745, 0.8956]}, {"w": "API", "b": [0.4792, 0.8742, 0.5125, 0.8956]}, {"w": "is", "b": [0.5172, 0.8742, 0.5304, 0.8956]}, {"w": "for", "b": [0.5352, 0.8742, 0.5597, 0.8956]}, {"w": "you.", "b": [0.5644, 0.8742, 0.6004, 0.8956]}]}, {"id": "b_12", "type": "paragraph", "text": "Implementing MLPs with Keras | 309", "words": [{"w": "Implementing", "b": [0.6126, 0.9225, 0.6972, 0.9388]}, {"w": "MLPs", "b": [0.7, 0.9225, 0.7308, 0.9388]}, {"w": "with", "b": [0.7336, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "309", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 336, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "15 Keras models have an output attribute, so we cannot use that name for the main output layer, which is why we renamed it to main_output.", "words": [{"w": "15", "b": [0.1385, 0.8602, 0.1518, 0.8745]}, {"w": "Keras", "b": [0.1587, 0.8587, 0.1945, 0.8751]}, {"w": "models", "b": [0.1981, 0.8587, 0.2441, 0.8751]}, {"w": "have", "b": [0.2477, 0.8587, 0.277, 0.8751]}, {"w": "an", "b": [0.2806, 0.8587, 0.2962, 0.8751]}, {"w": "output", "b": [0.2998, 0.8612, 0.3451, 0.8727]}, {"w": "attribute,", "b": [0.3487, 0.8587, 0.4069, 0.8751]}, {"w": "so", "b": [0.4105, 0.8587, 0.4244, 0.8751]}, {"w": "we", "b": [0.428, 0.8587, 0.4456, 0.8751]}, {"w": "cannot", "b": [0.4492, 0.8587, 0.4932, 0.8751]}, {"w": "use", "b": [0.4968, 0.8587, 0.5178, 0.8751]}, {"w": "that", "b": [0.5214, 0.8587, 0.5462, 0.8751]}, {"w": "name", "b": [0.5498, 0.8587, 0.5852, 0.8751]}, {"w": "for", "b": [0.5888, 0.8587, 0.6075, 0.8751]}, {"w": "the", "b": [0.6111, 0.8587, 0.6312, 0.8751]}, {"w": "main", "b": [0.6348, 0.8587, 0.6677, 0.8751]}, {"w": "output", "b": [0.6713, 0.8587, 0.7143, 0.8751]}, {"w": "layer,", "b": [0.7179, 0.8587, 0.7511, 0.8751]}, {"w": "which", "b": [0.7547, 0.8587, 0.7935, 0.8751]}, {"w": "is", "b": [0.7971, 0.8587, 0.8072, 0.8751]}, {"w": "why", "b": [0.8108, 0.8587, 0.837, 0.8751]}, {"w": "we", "b": [0.1587, 0.8749, 0.1763, 0.8912]}, {"w": "renamed", "b": [0.18, 0.8749, 0.2364, 0.8912]}, {"w": "it", "b": [0.24, 0.8749, 0.2491, 0.8912]}, {"w": "to", "b": [0.2527, 0.8749, 0.2656, 0.8912]}, {"w": "main_output.", "b": [0.2692, 0.8749, 0.3558, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Simply subclass the Model class, create the layers you need in the constructor, and use them to perform the computations you want in the call() method. For example, cre‐ ating an instance of the following WideAndDeepModel class gives us an equivalent model to the one we just built with the Functional API. You can then compile it, eval‐ uate it and use it to make predictions, exactly like we just did.", "words": [{"w": "Simply", "b": [0.1429, 0.08, 0.2007, 0.1014]}, {"w": "subclass", "b": [0.2059, 0.08, 0.2737, 0.1014]}, {"w": "the", "b": [0.2788, 0.08, 0.3051, 0.1014]}, {"w": "Model", "b": [0.3102, 0.0831, 0.3597, 0.0982]}, {"w": "class,", "b": [0.3648, 0.08, 0.4081, 0.1014]}, {"w": "create", "b": [0.4132, 0.08, 0.4626, 0.1014]}, {"w": "the", "b": [0.4677, 0.08, 0.494, 0.1014]}, {"w": "layers", "b": [0.4991, 0.08, 0.547, 0.1014]}, {"w": "you", "b": [0.5521, 0.08, 0.5833, 0.1014]}, {"w": "need", "b": [0.5884, 0.08, 0.6286, 0.1014]}, {"w": "in", "b": [0.6337, 0.08, 0.6506, 0.1014]}, {"w": "the", "b": [0.6558, 0.08, 0.6821, 0.1014]}, {"w": "constructor,", "b": [0.6872, 0.08, 0.7878, 0.1014]}, {"w": "and", "b": [0.7929, 0.08, 0.8245, 0.1014]}, {"w": "use", "b": [0.8296, 0.08, 0.8571, 0.1014]}, {"w": "them", "b": [0.1428, 0.0999, 0.1862, 0.1213]}, {"w": "to", "b": [0.1911, 0.0999, 0.2081, 0.1213]}, {"w": "perform", "b": [0.2129, 0.0999, 0.282, 0.1213]}, {"w": "the", "b": [0.2869, 0.0999, 0.3132, 0.1213]}, {"w": "computations", "b": [0.3181, 0.0999, 0.4329, 0.1213]}, {"w": "you", "b": [0.4377, 0.0999, 0.469, 0.1213]}, {"w": "want", "b": [0.4738, 0.0999, 0.5146, 0.1213]}, {"w": "in", "b": [0.5194, 0.0999, 0.5364, 0.1213]}, {"w": "the", "b": [0.5413, 0.0999, 0.5676, 0.1213]}, {"w": "call()", "b": [0.5725, 0.1031, 0.6319, 0.1182]}, {"w": "method.", "b": [0.6367, 0.0999, 0.7065, 0.1213]}, {"w": "For", "b": [0.7112, 0.0999, 0.7402, 0.1213]}, {"w": "example,", "b": [0.7449, 0.0999, 0.8192, 0.1213]}, {"w": "cre‐", "b": [0.824, 0.0999, 0.8568, 0.1213]}, {"w": "ating", "b": [0.1429, 0.1198, 0.1847, 0.1413]}, {"w": "an", "b": [0.1935, 0.1198, 0.214, 0.1413]}, {"w": "instance", "b": [0.2228, 0.1198, 0.292, 0.1413]}, {"w": "of", "b": [0.3008, 0.1198, 0.3176, 0.1413]}, {"w": "the", "b": [0.3263, 0.1198, 0.3527, 0.1413]}, {"w": "following", "b": [0.3615, 0.1198, 0.4404, 0.1413]}, {"w": "WideAndDeepModel", "b": [0.4492, 0.123, 0.6075, 0.1381]}, {"w": "class", "b": [0.6163, 0.1198, 0.6549, 0.1413]}, {"w": "gives", "b": [0.6636, 0.1198, 0.7051, 0.1413]}, {"w": "us", "b": [0.7139, 0.1198, 0.7326, 0.1413]}, {"w": "an", "b": [0.7414, 0.1198, 0.7619, 0.1413]}, {"w": "equivalent", "b": [0.7707, 0.1198, 0.8571, 0.1413]}, {"w": "model", "b": [0.1429, 0.1389, 0.1957, 0.1603]}, {"w": "to", "b": [0.2007, 0.1389, 0.2176, 0.1603]}, {"w": "the", "b": [0.2226, 0.1389, 0.249, 0.1603]}, {"w": "one", "b": [0.254, 0.1389, 0.2848, 0.1603]}, {"w": "we", "b": [0.2898, 0.1389, 0.3129, 0.1603]}, {"w": "just", "b": [0.3179, 0.1389, 0.3483, 0.1603]}, {"w": "built", "b": [0.3533, 0.1389, 0.3922, 0.1603]}, {"w": "with", "b": [0.3972, 0.1389, 0.4345, 0.1603]}, {"w": "the", "b": [0.4395, 0.1389, 0.4658, 0.1603]}, {"w": "Functional", "b": [0.4708, 0.1389, 0.5611, 0.1603]}, {"w": "API.", "b": [0.5661, 0.1389, 0.604, 0.1603]}, {"w": "You", "b": [0.609, 0.1389, 0.6414, 0.1603]}, {"w": "can", "b": [0.6464, 0.1389, 0.6757, 0.1603]}, {"w": "then", "b": [0.6807, 0.1389, 0.7184, 0.1603]}, {"w": "compile", "b": [0.7234, 0.1389, 0.7902, 0.1603]}, {"w": "it,", "b": [0.7951, 0.1389, 0.8118, 0.1603]}, {"w": "eval‐", "b": [0.8168, 0.1389, 0.8572, 0.1603]}, {"w": "uate", "b": [0.1429, 0.1579, 0.1779, 0.1794]}, {"w": "it", "b": [0.1826, 0.1579, 0.1945, 0.1794]}, {"w": "and", "b": [0.1993, 0.1579, 0.2308, 0.1794]}, {"w": "use", "b": [0.2355, 0.1579, 0.2631, 0.1794]}, {"w": "it", "b": [0.2678, 0.1579, 0.2798, 0.1794]}, {"w": "to", "b": [0.2845, 0.1579, 0.3015, 0.1794]}, {"w": "make", "b": [0.3062, 0.1579, 0.3516, 0.1794]}, {"w": "predictions,", "b": [0.3563, 0.1579, 0.4556, 0.1794]}, {"w": "exactly", "b": [0.4603, 0.1579, 0.5182, 0.1794]}, {"w": "like", "b": [0.5229, 0.1579, 0.5529, 0.1794]}, {"w": "we", "b": [0.5577, 0.1579, 0.5808, 0.1794]}, {"w": "just", "b": [0.5855, 0.1579, 0.6159, 0.1794]}, {"w": "did.", "b": [0.6206, 0.1579, 0.653, 0.1794]}]}, {"id": "b_2", "type": "paragraph", "text": "class WideAndDeepModel(keras.models.Model): def __init__(self, units=30, activation=\"relu\", **kwargs): super().__init__(**kwargs) # handles standard args (e.g., name) self.hidden1 = keras.layers.Dense(units, activation=activation) self.hidden2 = keras.layers.Dense(units, activation=activation) self.main_output = keras.layers.Dense(1) self.aux_output = keras.layers.Dense(1)", "words": [{"w": "class", "b": [0.1766, 0.1899, 0.2188, 0.2028]}, {"w": "WideAndDeepModel(keras.models.Model):", "b": [0.2272, 0.1899, 0.5392, 0.2028]}, {"w": "def", "b": [0.2103, 0.2053, 0.2356, 0.2182]}, {"w": "__init__(self,", "b": [0.2441, 0.2053, 0.3621, 0.2182]}, {"w": "units=30,", "b": [0.3705, 0.2053, 0.4464, 0.2182]}, {"w": "activation=\"relu\",", "b": [0.4549, 0.2053, 0.6067, 0.2182]}, {"w": "**kwargs):", "b": [0.6151, 0.2053, 0.6994, 0.2182]}, {"w": "super().__init__(**kwargs)", "b": [0.2441, 0.2208, 0.4633, 0.2336]}, {"w": "#", "b": [0.4717, 0.2208, 0.4802, 0.2336]}, {"w": "handles", "b": [0.4886, 0.2208, 0.5476, 0.2336]}, {"w": "standard", "b": [0.5561, 0.2208, 0.6235, 0.2336]}, {"w": "args", "b": [0.632, 0.2208, 0.6657, 0.2336]}, {"w": "(e.g.,", "b": [0.6741, 0.2208, 0.7247, 0.2336]}, {"w": "name)", "b": [0.7331, 0.2208, 0.7753, 0.2336]}, {"w": "self.hidden1", "b": [0.2441, 0.2362, 0.3452, 0.249]}, {"w": "=", "b": [0.3537, 0.2362, 0.3621, 0.249]}, {"w": "keras.layers.Dense(units,", "b": [0.3705, 0.2362, 0.5814, 0.249]}, {"w": "activation=activation)", "b": [0.5898, 0.2362, 0.7753, 0.249]}, {"w": "self.hidden2", "b": [0.2441, 0.2516, 0.3452, 0.2644]}, {"w": "=", "b": [0.3537, 0.2516, 0.3621, 0.2644]}, {"w": "keras.layers.Dense(units,", "b": [0.3705, 0.2516, 0.5814, 0.2644]}, {"w": "activation=activation)", "b": [0.5898, 0.2516, 0.7753, 0.2644]}, {"w": "self.main_output", "b": [0.2441, 0.267, 0.379, 0.2799]}, {"w": "=", "b": [0.3874, 0.267, 0.3958, 0.2799]}, {"w": "keras.layers.Dense(1)", "b": [0.4043, 0.267, 0.5814, 0.2799]}, {"w": "self.aux_output", "b": [0.2441, 0.2824, 0.3705, 0.2953]}, {"w": "=", "b": [0.379, 0.2824, 0.3874, 0.2953]}, {"w": "keras.layers.Dense(1)", "b": [0.3958, 0.2824, 0.5729, 0.2953]}]}, {"id": "b_3", "type": "paragraph", "text": "def call(self, inputs): input_A, input_B = inputs hidden1 = self.hidden1(input_B) hidden2 = self.hidden2(hidden1) concat = keras.layers.concatenate([input_A, hidden2]) main_output = self.main_output(concat) aux_output = self.aux_output(hidden2) return main_output, aux_output", "words": [{"w": "def", "b": [0.2103, 0.3133, 0.2356, 0.3261]}, {"w": "call(self,", "b": [0.2441, 0.3133, 0.3284, 0.3261]}, {"w": "inputs):", "b": [0.3368, 0.3133, 0.4043, 0.3261]}, {"w": "input_A,", "b": [0.2441, 0.3287, 0.3115, 0.3415]}, {"w": "input_B", "b": [0.3199, 0.3287, 0.379, 0.3415]}, {"w": "=", "b": [0.3874, 0.3287, 0.3958, 0.3415]}, {"w": "inputs", "b": [0.4043, 0.3287, 0.4549, 0.3415]}, {"w": "hidden1", "b": [0.2441, 0.3441, 0.3031, 0.357]}, {"w": "=", "b": [0.3115, 0.3441, 0.3199, 0.357]}, {"w": "self.hidden1(input_B)", "b": [0.3284, 0.3441, 0.5055, 0.357]}, {"w": "hidden2", "b": [0.2441, 0.3595, 0.3031, 0.3724]}, {"w": "=", "b": [0.3115, 0.3595, 0.3199, 0.3724]}, {"w": "self.hidden2(hidden1)", "b": [0.3284, 0.3595, 0.5055, 0.3724]}, {"w": "concat", "b": [0.2441, 0.375, 0.2946, 0.3878]}, {"w": "=", "b": [0.3031, 0.375, 0.3115, 0.3878]}, {"w": "keras.layers.concatenate([input_A,", "b": [0.3199, 0.375, 0.6067, 0.3878]}, {"w": "hidden2])", "b": [0.6151, 0.375, 0.691, 0.3878]}, {"w": "main_output", "b": [0.2441, 0.3904, 0.3368, 0.4032]}, {"w": "=", "b": [0.3452, 0.3904, 0.3537, 0.4032]}, {"w": "self.main_output(concat)", "b": [0.3621, 0.3904, 0.5645, 0.4032]}, {"w": "aux_output", "b": [0.2441, 0.4058, 0.3284, 0.4186]}, {"w": "=", "b": [0.3368, 0.4058, 0.3452, 0.4186]}, {"w": "self.aux_output(hidden2)", "b": [0.3537, 0.4058, 0.5561, 0.4186]}, {"w": "return", "b": [0.2441, 0.4212, 0.2946, 0.4341]}, {"w": "main_output,", "b": [0.3031, 0.4212, 0.4043, 0.4341]}, {"w": "aux_output", "b": [0.4127, 0.4212, 0.497, 0.4341]}]}, {"id": "b_4", "type": "equation", "text": "model = WideAndDeepModel()", "words": [{"w": "model", "b": [0.1766, 0.452, 0.2188, 0.4649]}, {"w": "=", "b": [0.2272, 0.452, 0.2356, 0.4649]}, {"w": "WideAndDeepModel()", "b": [0.2441, 0.452, 0.3958, 0.4649]}]}, {"id": "b_5", "type": "paragraph", "text": "This example looks very much like the Functional API, except we do not need to cre‐ ate the inputs, we just use the input argument to the call() method, and we separate the creation of the layers15 in the constructor from their usage in the call() method. However, the big difference is that you can do pretty much anything you want in the call() method: for loops, if statements, low-level TensorFlow operations, your imagination is the limit (see Chapter 12)! This makes it a great API for researchers experimenting with new ideas.", "words": [{"w": "This", "b": [0.1429, 0.4727, 0.1801, 0.4941]}, {"w": "example", "b": [0.1853, 0.4727, 0.2548, 0.4941]}, {"w": "looks", "b": [0.26, 0.4727, 0.3045, 0.4941]}, {"w": "very", "b": [0.3097, 0.4727, 0.3461, 0.4941]}, {"w": "much", "b": [0.3512, 0.4727, 0.3989, 0.4941]}, {"w": "like", "b": [0.4041, 0.4727, 0.4341, 0.4941]}, {"w": "the", "b": [0.4393, 0.4727, 0.4656, 0.4941]}, {"w": "Functional", "b": [0.4708, 0.4727, 0.5611, 0.4941]}, {"w": "API,", "b": [0.5663, 0.4727, 0.6042, 0.4941]}, {"w": "except", "b": [0.6094, 0.4727, 0.663, 0.4941]}, {"w": "we", "b": [0.6682, 0.4727, 0.6913, 0.4941]}, {"w": "do", "b": [0.6965, 0.4727, 0.7182, 0.4941]}, {"w": "not", "b": [0.7233, 0.4727, 0.7517, 0.4941]}, {"w": "need", "b": [0.7569, 0.4727, 0.797, 0.4941]}, {"w": "to", "b": [0.8022, 0.4727, 0.8192, 0.4941]}, {"w": "cre‐", "b": [0.8243, 0.4727, 0.8571, 0.4941]}, {"w": "ate", "b": [0.1429, 0.4926, 0.1668, 0.514]}, {"w": "the", "b": [0.1717, 0.4926, 0.198, 0.514]}, {"w": "inputs,", "b": [0.2029, 0.4926, 0.2603, 0.514]}, {"w": "we", "b": [0.2652, 0.4926, 0.2883, 0.514]}, {"w": "just", "b": [0.2932, 0.4926, 0.3236, 0.514]}, {"w": "use", "b": [0.3285, 0.4926, 0.356, 0.514]}, {"w": "the", "b": [0.3609, 0.4926, 0.3873, 0.514]}, {"w": "input", "b": [0.3922, 0.4958, 0.4416, 0.5109]}, {"w": "argument", "b": [0.4465, 0.4926, 0.5275, 0.514]}, {"w": "to", "b": [0.5322, 0.4926, 0.5492, 0.514]}, {"w": "the", "b": [0.5539, 0.4926, 0.5803, 0.514]}, {"w": "call()", "b": [0.5855, 0.4958, 0.6449, 0.5109]}, {"w": "method,", "b": [0.6498, 0.4926, 0.7195, 0.514]}, {"w": "and", "b": [0.7243, 0.4926, 0.7558, 0.514]}, {"w": "we", "b": [0.7605, 0.4926, 0.7837, 0.514]}, {"w": "separate", "b": [0.7884, 0.4926, 0.8566, 0.514]}, {"w": "the", "b": [0.1429, 0.5126, 0.1692, 0.534]}, {"w": "creation", "b": [0.1747, 0.5126, 0.2428, 0.534]}, {"w": "of", "b": [0.2483, 0.5126, 0.2651, 0.534]}, {"w": "the", "b": [0.2706, 0.5126, 0.2969, 0.534]}, {"w": "layers15", "b": [0.3024, 0.5126, 0.3616, 0.534]}, {"w": "in", "b": [0.3671, 0.5126, 0.3841, 0.534]}, {"w": "the", "b": [0.3896, 0.5126, 0.4159, 0.534]}, {"w": "constructor", "b": [0.4214, 0.5126, 0.5186, 0.534]}, {"w": "from", "b": [0.5241, 0.5126, 0.5656, 0.534]}, {"w": "their", "b": [0.5711, 0.5126, 0.6108, 0.534]}, {"w": "usage", "b": [0.6163, 0.5126, 0.6627, 0.534]}, {"w": "in", "b": [0.6682, 0.5126, 0.6852, 0.534]}, {"w": "the", "b": [0.6907, 0.5126, 0.717, 0.534]}, {"w": "call()", "b": [0.7225, 0.5158, 0.7819, 0.5308]}, {"w": "method.", "b": [0.7874, 0.5126, 0.8571, 0.534]}, {"w": "However,", "b": [0.1429, 0.5316, 0.2217, 0.553]}, {"w": "the", "b": [0.2274, 0.5316, 0.2537, 0.553]}, {"w": "big", "b": [0.2594, 0.5316, 0.2853, 0.553]}, {"w": "difference", "b": [0.291, 0.5316, 0.3744, 0.553]}, {"w": "is", "b": [0.3801, 0.5316, 0.3933, 0.553]}, {"w": "that", "b": [0.399, 0.5316, 0.4316, 0.553]}, {"w": "you", "b": [0.4372, 0.5316, 0.4685, 0.553]}, {"w": "can", "b": [0.4742, 0.5316, 0.5035, 0.553]}, {"w": "do", "b": [0.5092, 0.5316, 0.5308, 0.553]}, {"w": "pretty", "b": [0.5365, 0.5316, 0.5863, 0.553]}, {"w": "much", "b": [0.5919, 0.5316, 0.6396, 0.553]}, {"w": "anything", "b": [0.6453, 0.5316, 0.7191, 0.553]}, {"w": "you", "b": [0.7248, 0.5316, 0.756, 0.553]}, {"w": "want", "b": [0.7617, 0.5316, 0.8025, 0.553]}, {"w": "in", "b": [0.8082, 0.5316, 0.8251, 0.553]}, {"w": "the", "b": [0.8308, 0.5316, 0.8571, 0.553]}, {"w": "call()", "b": [0.1429, 0.5547, 0.2022, 0.5698]}, {"w": "method:", "b": [0.2118, 0.5516, 0.2816, 0.573]}, {"w": "for", "b": [0.2912, 0.5547, 0.3209, 0.5698]}, {"w": "loops,", "b": [0.3304, 0.5516, 0.3803, 0.573]}, {"w": "if", "b": [0.3899, 0.5547, 0.4097, 0.5698]}, {"w": "statements,", "b": [0.4192, 0.5516, 0.5129, 0.573]}, {"w": "low-level", "b": [0.5225, 0.5516, 0.5979, 0.573]}, {"w": "TensorFlow", "b": [0.6075, 0.5516, 0.7058, 0.573]}, {"w": "operations,", "b": [0.7154, 0.5516, 0.8086, 0.573]}, {"w": "your", "b": [0.8182, 0.5516, 0.8571, 0.573]}, {"w": "imagination", "b": [0.1429, 0.5706, 0.2441, 0.592]}, {"w": "is", "b": [0.2509, 0.5706, 0.2642, 0.592]}, {"w": "the", "b": [0.271, 0.5706, 0.2973, 0.592]}, {"w": "limit", "b": [0.3042, 0.5706, 0.344, 0.592]}, {"w": "(see", "b": [0.3509, 0.5706, 0.3835, 0.592]}, {"w": "Chapter", "b": [0.3903, 0.5706, 0.4579, 0.592]}, {"w": "12)!", "b": [0.4647, 0.5706, 0.4977, 0.592]}, {"w": "This", "b": [0.5045, 0.5706, 0.5418, 0.592]}, {"w": "makes", "b": [0.5486, 0.5706, 0.6016, 0.592]}, {"w": "it", "b": [0.6085, 0.5706, 0.6204, 0.592]}, {"w": "a", "b": [0.6273, 0.5706, 0.6364, 0.592]}, {"w": "great", "b": [0.6433, 0.5706, 0.6847, 0.592]}, {"w": "API", "b": [0.6916, 0.5706, 0.7248, 0.592]}, {"w": "for", "b": [0.7316, 0.5706, 0.7562, 0.592]}, {"w": "researchers", "b": [0.763, 0.5706, 0.8571, 0.592]}, {"w": "experimenting", "b": [0.1429, 0.5897, 0.2646, 0.6111]}, {"w": "with", "b": [0.2694, 0.5897, 0.3067, 0.6111]}, {"w": "new", "b": [0.3114, 0.5897, 0.346, 0.6111]}, {"w": "ideas.", "b": [0.3507, 0.5897, 0.3977, 0.6111]}]}, {"id": "b_6", "type": "paragraph", "text": "However, this extra flexibility comes at a cost: your model’s architecture is hidden within the call() method, so Keras cannot easily inspect it, it cannot save or clone it, and when you call the summary() method, you only get a list of layers, without any information on how they are connected to each other. Moreover, Keras cannot check types and shapes ahead of time, and it is easier to make mistakes. So unless you really need that extra flexibility, you should probably stick to the Sequential API or the Functional API.", "words": [{"w": "However,", "b": [0.1429, 0.6178, 0.2217, 0.6392]}, {"w": "this", "b": [0.2296, 0.6178, 0.2603, 0.6392]}, {"w": "extra", "b": [0.2682, 0.6178, 0.3101, 0.6392]}, {"w": "flexibility", "b": [0.318, 0.6178, 0.3966, 0.6392]}, {"w": "comes", "b": [0.4045, 0.6178, 0.4575, 0.6392]}, {"w": "at", "b": [0.4654, 0.6178, 0.4805, 0.6392]}, {"w": "a", "b": [0.4884, 0.6178, 0.4975, 0.6392]}, {"w": "cost:", "b": [0.5054, 0.6178, 0.5436, 0.6392]}, {"w": "your", "b": [0.5515, 0.6178, 0.5904, 0.6392]}, {"w": "model’s", "b": [0.5983, 0.6178, 0.6609, 0.6392]}, {"w": "architecture", "b": [0.6688, 0.6178, 0.7692, 0.6392]}, {"w": "is", "b": [0.7771, 0.6178, 0.7903, 0.6392]}, {"w": "hidden", "b": [0.7982, 0.6178, 0.8572, 0.6392]}, {"w": "within", "b": [0.1429, 0.6377, 0.1972, 0.6591]}, {"w": "the", "b": [0.2019, 0.6377, 0.2282, 0.6591]}, {"w": "call()", "b": [0.2335, 0.6409, 0.2928, 0.656]}, {"w": "method,", "b": [0.2978, 0.6377, 0.3676, 0.6591]}, {"w": "so", "b": [0.3726, 0.6377, 0.3908, 0.6591]}, {"w": "Keras", "b": [0.3958, 0.6377, 0.4427, 0.6591]}, {"w": "cannot", "b": [0.4477, 0.6377, 0.5054, 0.6591]}, {"w": "easily", "b": [0.5104, 0.6377, 0.5565, 0.6591]}, {"w": "inspect", "b": [0.5614, 0.6377, 0.621, 0.6591]}, {"w": "it,", "b": [0.626, 0.6377, 0.6427, 0.6591]}, {"w": "it", "b": [0.6477, 0.6377, 0.6596, 0.6591]}, {"w": "cannot", "b": [0.6646, 0.6377, 0.7223, 0.6591]}, {"w": "save", "b": [0.7273, 0.6377, 0.7622, 0.6591]}, {"w": "or", "b": [0.7672, 0.6377, 0.7855, 0.6591]}, {"w": "clone", "b": [0.7905, 0.6377, 0.8355, 0.6591]}, {"w": "it,", "b": [0.8405, 0.6377, 0.8571, 0.6591]}, {"w": "and", "b": [0.1429, 0.6577, 0.1744, 0.6791]}, {"w": "when", "b": [0.1811, 0.6577, 0.2268, 0.6791]}, {"w": "you", "b": [0.2335, 0.6577, 0.2647, 0.6791]}, {"w": "call", "b": [0.2715, 0.6577, 0.3, 0.6791]}, {"w": "the", "b": [0.3067, 0.6577, 0.333, 0.6791]}, {"w": "summary()", "b": [0.3397, 0.6608, 0.4288, 0.6759]}, {"w": "method,", "b": [0.4355, 0.6577, 0.5053, 0.6791]}, {"w": "you", "b": [0.512, 0.6577, 0.5432, 0.6791]}, {"w": "only", "b": [0.55, 0.6577, 0.5868, 0.6791]}, {"w": "get", "b": [0.5935, 0.6577, 0.6185, 0.6791]}, {"w": "a", "b": [0.6252, 0.6577, 0.6343, 0.6791]}, {"w": "list", "b": [0.6411, 0.6577, 0.6659, 0.6791]}, {"w": "of", "b": [0.6726, 0.6577, 0.6894, 0.6791]}, {"w": "layers,", "b": [0.6961, 0.6577, 0.7487, 0.6791]}, {"w": "without", "b": [0.7554, 0.6577, 0.8208, 0.6791]}, {"w": "any", "b": [0.8275, 0.6577, 0.8572, 0.6791]}, {"w": "information", "b": [0.1429, 0.6767, 0.2441, 0.6981]}, {"w": "on", "b": [0.2496, 0.6767, 0.2717, 0.6981]}, {"w": "how", "b": [0.2772, 0.6767, 0.3132, 0.6981]}, {"w": "they", "b": [0.3187, 0.6767, 0.3546, 0.6981]}, {"w": "are", "b": [0.3601, 0.6767, 0.3858, 0.6981]}, {"w": "connected", "b": [0.3913, 0.6767, 0.4775, 0.6981]}, {"w": "to", "b": [0.483, 0.6767, 0.4999, 0.6981]}, {"w": "each", "b": [0.5055, 0.6767, 0.5434, 0.6981]}, {"w": "other.", "b": [0.5489, 0.6767, 0.597, 0.6981]}, {"w": "Moreover,", "b": [0.6025, 0.6767, 0.6881, 0.6981]}, {"w": "Keras", "b": [0.6936, 0.6767, 0.7405, 0.6981]}, {"w": "cannot", "b": [0.746, 0.6767, 0.8037, 0.6981]}, {"w": "check", "b": [0.8092, 0.6767, 0.8571, 0.6981]}, {"w": "types", "b": [0.1429, 0.6958, 0.1862, 0.7172]}, {"w": "and", "b": [0.1913, 0.6958, 0.2229, 0.7172]}, {"w": "shapes", "b": [0.228, 0.6958, 0.2829, 0.7172]}, {"w": "ahead", "b": [0.2881, 0.6958, 0.3373, 0.7172]}, {"w": "of", "b": [0.3425, 0.6958, 0.3593, 0.7172]}, {"w": "time,", "b": [0.3644, 0.6958, 0.407, 0.7172]}, {"w": "and", "b": [0.4121, 0.6958, 0.4437, 0.7172]}, {"w": "it", "b": [0.4488, 0.6958, 0.4607, 0.7172]}, {"w": "is", "b": [0.4659, 0.6958, 0.4791, 0.7172]}, {"w": "easier", "b": [0.4842, 0.6958, 0.532, 0.7172]}, {"w": "to", "b": [0.5372, 0.6958, 0.5541, 0.7172]}, {"w": "make", "b": [0.5593, 0.6958, 0.6047, 0.7172]}, {"w": "mistakes.", "b": [0.6098, 0.6958, 0.6872, 0.7172]}, {"w": "So", "b": [0.6923, 0.6958, 0.7128, 0.7172]}, {"w": "unless", "b": [0.7179, 0.6958, 0.7698, 0.7172]}, {"w": "you", "b": [0.7749, 0.6958, 0.8062, 0.7172]}, {"w": "really", "b": [0.8113, 0.6958, 0.8571, 0.7172]}, {"w": "need", "b": [0.1429, 0.7148, 0.183, 0.7362]}, {"w": "that", "b": [0.1913, 0.7148, 0.2239, 0.7362]}, {"w": "extra", "b": [0.2323, 0.7148, 0.2742, 0.7362]}, {"w": "flexibility,", "b": [0.2826, 0.7148, 0.3645, 0.7362]}, {"w": "you", "b": [0.3728, 0.7148, 0.4041, 0.7362]}, {"w": "should", "b": [0.4124, 0.7148, 0.4692, 0.7362]}, {"w": "probably", "b": [0.4775, 0.7148, 0.552, 0.7362]}, {"w": "stick", "b": [0.5603, 0.7148, 0.5991, 0.7362]}, {"w": "to", "b": [0.6074, 0.7148, 0.6244, 0.7362]}, {"w": "the", "b": [0.6328, 0.7148, 0.6591, 0.7362]}, {"w": "Sequential", "b": [0.6675, 0.7148, 0.7541, 0.7362]}, {"w": "API", "b": [0.7625, 0.7148, 0.7957, 0.7362]}, {"w": "or", "b": [0.8041, 0.7148, 0.8225, 0.7362]}, {"w": "the", "b": [0.8308, 0.7148, 0.8572, 0.7362]}, {"w": "Functional", "b": [0.1429, 0.7339, 0.2331, 0.7553]}, {"w": "API.", "b": [0.2378, 0.7339, 0.2758, 0.7553]}]}, {"id": "b_7", "type": "paragraph", "text": "310 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "310", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 337, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Keras models can be used just like regular layers, so you can easily compose them to build complex architectures.", "words": [{"w": "Keras", "b": [0.2714, 0.0793, 0.3143, 0.0989]}, {"w": "models", "b": [0.3196, 0.0793, 0.3749, 0.0989]}, {"w": "can", "b": [0.3803, 0.0793, 0.4071, 0.0989]}, {"w": "be", "b": [0.4125, 0.0793, 0.4302, 0.0989]}, {"w": "used", "b": [0.4356, 0.0793, 0.4709, 0.0989]}, {"w": "just", "b": [0.4762, 0.0793, 0.504, 0.0989]}, {"w": "like", "b": [0.5094, 0.0793, 0.5368, 0.0989]}, {"w": "regular", "b": [0.5422, 0.0793, 0.5966, 0.0989]}, {"w": "layers,", "b": [0.602, 0.0793, 0.6501, 0.0989]}, {"w": "so", "b": [0.6554, 0.0793, 0.6721, 0.0989]}, {"w": "you", "b": [0.6775, 0.0793, 0.706, 0.0989]}, {"w": "can", "b": [0.7114, 0.0793, 0.7382, 0.0989]}, {"w": "easily", "b": [0.7436, 0.0793, 0.7857, 0.0989]}, {"w": "compose", "b": [0.2714, 0.0967, 0.3392, 0.1163]}, {"w": "them", "b": [0.3435, 0.0967, 0.3832, 0.1163]}, {"w": "to", "b": [0.3875, 0.0967, 0.403, 0.1163]}, {"w": "build", "b": [0.4074, 0.0967, 0.4471, 0.1163]}, {"w": "complex", "b": [0.4515, 0.0967, 0.5164, 0.1163]}, {"w": "architectures.", "b": [0.5207, 0.0967, 0.6238, 0.1163]}]}, {"id": "b_1", "type": "paragraph", "text": "Now that you know how to build and train neural nets using Keras, you will want to save them!", "words": [{"w": "Now", "b": [0.1429, 0.1779, 0.1827, 0.1993]}, {"w": "that", "b": [0.1884, 0.1779, 0.221, 0.1993]}, {"w": "you", "b": [0.2267, 0.1779, 0.258, 0.1993]}, {"w": "know", "b": [0.2637, 0.1779, 0.3103, 0.1993]}, {"w": "how", "b": [0.316, 0.1779, 0.3521, 0.1993]}, {"w": "to", "b": [0.3578, 0.1779, 0.3748, 0.1993]}, {"w": "build", "b": [0.3805, 0.1779, 0.424, 0.1993]}, {"w": "and", "b": [0.4297, 0.1779, 0.4613, 0.1993]}, {"w": "train", "b": [0.467, 0.1779, 0.5072, 0.1993]}, {"w": "neural", "b": [0.5129, 0.1779, 0.5664, 0.1993]}, {"w": "nets", "b": [0.5721, 0.1779, 0.6063, 0.1993]}, {"w": "using", "b": [0.6121, 0.1779, 0.6575, 0.1993]}, {"w": "Keras,", "b": [0.6632, 0.1779, 0.7149, 0.1993]}, {"w": "you", "b": [0.7206, 0.1779, 0.7518, 0.1993]}, {"w": "will", "b": [0.7575, 0.1779, 0.7879, 0.1993]}, {"w": "want", "b": [0.7937, 0.1779, 0.8344, 0.1993]}, {"w": "to", "b": [0.8402, 0.1779, 0.8571, 0.1993]}, {"w": "save", "b": [0.1429, 0.197, 0.1778, 0.2184]}, {"w": "them!", "b": [0.1825, 0.197, 0.2317, 0.2184]}]}, {"id": "b_2", "type": "paragraph", "text": "Saving and Restoring a Model", "words": [{"w": "Saving", "b": [0.1429, 0.2312, 0.2121, 0.2597]}, {"w": "and", "b": [0.217, 0.2312, 0.2563, 0.2597]}, {"w": "Restoring", "b": [0.2613, 0.2312, 0.3607, 0.2597]}, {"w": "a", "b": [0.3656, 0.2312, 0.378, 0.2597]}, {"w": "Model", "b": [0.383, 0.2312, 0.4474, 0.2597]}]}, {"id": "b_3", "type": "paragraph", "text": "Saving a trained Keras model is as simple as it gets:", "words": [{"w": "Saving", "b": [0.1429, 0.2656, 0.1979, 0.287]}, {"w": "a", "b": [0.2026, 0.2656, 0.2118, 0.287]}, {"w": "trained", "b": [0.2165, 0.2656, 0.2765, 0.287]}, {"w": "Keras", "b": [0.2813, 0.2656, 0.3282, 0.287]}, {"w": "model", "b": [0.3329, 0.2656, 0.3857, 0.287]}, {"w": "is", "b": [0.3904, 0.2656, 0.4037, 0.287]}, {"w": "as", "b": [0.4084, 0.2656, 0.4252, 0.287]}, {"w": "simple", "b": [0.4299, 0.2656, 0.4849, 0.287]}, {"w": "as", "b": [0.4896, 0.2656, 0.5064, 0.287]}, {"w": "it", "b": [0.5111, 0.2656, 0.523, 0.287]}, {"w": "gets:", "b": [0.5278, 0.2656, 0.5651, 0.287]}]}, {"id": "b_4", "type": "equation", "text": "model.save(\"my_keras_model.h5\")", "words": [{"w": "model.save(\"my_keras_model.h5\")", "b": [0.1766, 0.2976, 0.438, 0.3104]}]}, {"id": "b_5", "type": "paragraph", "text": "Keras will save both the model’s architecture (including every layer’s hyperparame‐ ters) and the value of all the model parameters for every layer (e.g., connection weights and biases), using the HDF5 format. It also saves the optimizer (including its hyperparameters and any state it may have).", "words": [{"w": "Keras", "b": [0.1429, 0.3182, 0.1898, 0.3396]}, {"w": "will", "b": [0.1971, 0.3182, 0.2275, 0.3396]}, {"w": "save", "b": [0.2348, 0.3182, 0.2697, 0.3396]}, {"w": "both", "b": [0.277, 0.3182, 0.3157, 0.3396]}, {"w": "the", "b": [0.3231, 0.3182, 0.3494, 0.3396]}, {"w": "model’s", "b": [0.3567, 0.3182, 0.4193, 0.3396]}, {"w": "architecture", "b": [0.4266, 0.3182, 0.527, 0.3396]}, {"w": "(including", "b": [0.5344, 0.3182, 0.6214, 0.3396]}, {"w": "every", "b": [0.6288, 0.3182, 0.674, 0.3396]}, {"w": "layer’s", "b": [0.6813, 0.3182, 0.7318, 0.3396]}, {"w": "hyperparame‐", "b": [0.7392, 0.3182, 0.8571, 0.3396]}, {"w": "ters)", "b": [0.1428, 0.3373, 0.1806, 0.3587]}, {"w": "and", "b": [0.19, 0.3373, 0.2215, 0.3587]}, {"w": "the", "b": [0.2309, 0.3373, 0.2572, 0.3587]}, {"w": "value", "b": [0.2666, 0.3373, 0.3106, 0.3587]}, {"w": "of", "b": [0.3199, 0.3373, 0.3367, 0.3587]}, {"w": "all", "b": [0.3461, 0.3373, 0.3658, 0.3587]}, {"w": "the", "b": [0.3751, 0.3373, 0.4015, 0.3587]}, {"w": "model", "b": [0.4108, 0.3373, 0.4637, 0.3587]}, {"w": "parameters", "b": [0.473, 0.3373, 0.5665, 0.3587]}, {"w": "for", "b": [0.5758, 0.3373, 0.6003, 0.3587]}, {"w": "every", "b": [0.6097, 0.3373, 0.6549, 0.3587]}, {"w": "layer", "b": [0.6643, 0.3373, 0.7045, 0.3587]}, {"w": "(e.g.,", "b": [0.7139, 0.3373, 0.7539, 0.3587]}, {"w": "connection", "b": [0.7633, 0.3373, 0.8571, 0.3587]}, {"w": "weights", "b": [0.1429, 0.3563, 0.2061, 0.3777]}, {"w": "and", "b": [0.2115, 0.3563, 0.243, 0.3777]}, {"w": "biases),", "b": [0.2484, 0.3563, 0.3098, 0.3777]}, {"w": "using", "b": [0.3152, 0.3563, 0.3607, 0.3777]}, {"w": "the", "b": [0.3661, 0.3563, 0.3924, 0.3777]}, {"w": "HDF5", "b": [0.3978, 0.3563, 0.4501, 0.3777]}, {"w": "format.", "b": [0.4555, 0.3563, 0.517, 0.3777]}, {"w": "It", "b": [0.5224, 0.3563, 0.535, 0.3777]}, {"w": "also", "b": [0.5404, 0.3563, 0.5731, 0.3777]}, {"w": "saves", "b": [0.5785, 0.3563, 0.6211, 0.3777]}, {"w": "the", "b": [0.6265, 0.3563, 0.6528, 0.3777]}, {"w": "optimizer", "b": [0.6582, 0.3563, 0.7397, 0.3777]}, {"w": "(including", "b": [0.7451, 0.3563, 0.8322, 0.3777]}, {"w": "its", "b": [0.8376, 0.3563, 0.8571, 0.3777]}, {"w": "hyperparameters", "b": [0.1429, 0.3754, 0.284, 0.3968]}, {"w": "and", "b": [0.2887, 0.3754, 0.3203, 0.3968]}, {"w": "any", "b": [0.325, 0.3754, 0.3546, 0.3968]}, {"w": "state", "b": [0.3594, 0.3754, 0.3973, 0.3968]}, {"w": "it", "b": [0.402, 0.3754, 0.414, 0.3968]}, {"w": "may", "b": [0.4187, 0.3754, 0.4541, 0.3968]}, {"w": "have).", "b": [0.4588, 0.3754, 0.5092, 0.3968]}]}, {"id": "b_6", "type": "paragraph", "text": "You will typically have a script that trains a model and saves it, and one or more scripts (or web services) that load the model and use it to make predictions. Loading the model is just as easy:", "words": [{"w": "You", "b": [0.1429, 0.4035, 0.1752, 0.4249]}, {"w": "will", "b": [0.1832, 0.4035, 0.2136, 0.4249]}, {"w": "typically", "b": [0.2216, 0.4035, 0.2921, 0.4249]}, {"w": "have", "b": [0.3001, 0.4035, 0.3385, 0.4249]}, {"w": "a", "b": [0.3465, 0.4035, 0.3557, 0.4249]}, {"w": "script", "b": [0.3637, 0.4035, 0.4107, 0.4249]}, {"w": "that", "b": [0.4188, 0.4035, 0.4513, 0.4249]}, {"w": "trains", "b": [0.4594, 0.4035, 0.5072, 0.4249]}, {"w": "a", "b": [0.5152, 0.4035, 0.5244, 0.4249]}, {"w": "model", "b": [0.5324, 0.4035, 0.5852, 0.4249]}, {"w": "and", "b": [0.5932, 0.4035, 0.6248, 0.4249]}, {"w": "saves", "b": [0.6328, 0.4035, 0.6753, 0.4249]}, {"w": "it,", "b": [0.6834, 0.4035, 0.7, 0.4249]}, {"w": "and", "b": [0.7081, 0.4035, 0.7396, 0.4249]}, {"w": "one", "b": [0.7476, 0.4035, 0.7785, 0.4249]}, {"w": "or", "b": [0.7865, 0.4035, 0.8049, 0.4249]}, {"w": "more", "b": [0.8129, 0.4035, 0.8571, 0.4249]}, {"w": "scripts", "b": [0.1429, 0.4225, 0.1975, 0.4439]}, {"w": "(or", "b": [0.2032, 0.4225, 0.2287, 0.4439]}, {"w": "web", "b": [0.2343, 0.4225, 0.268, 0.4439]}, {"w": "services)", "b": [0.2737, 0.4225, 0.3462, 0.4439]}, {"w": "that", "b": [0.3518, 0.4225, 0.3844, 0.4439]}, {"w": "load", "b": [0.39, 0.4225, 0.4261, 0.4439]}, {"w": "the", "b": [0.4317, 0.4225, 0.458, 0.4439]}, {"w": "model", "b": [0.4637, 0.4225, 0.5165, 0.4439]}, {"w": "and", "b": [0.5221, 0.4225, 0.5536, 0.4439]}, {"w": "use", "b": [0.5592, 0.4225, 0.5868, 0.4439]}, {"w": "it", "b": [0.5924, 0.4225, 0.6043, 0.4439]}, {"w": "to", "b": [0.61, 0.4225, 0.6269, 0.4439]}, {"w": "make", "b": [0.6326, 0.4225, 0.678, 0.4439]}, {"w": "predictions.", "b": [0.6836, 0.4225, 0.7828, 0.4439]}, {"w": "Loading", "b": [0.7884, 0.4225, 0.8571, 0.4439]}, {"w": "the", "b": [0.1429, 0.4416, 0.1692, 0.463]}, {"w": "model", "b": [0.1739, 0.4416, 0.2267, 0.463]}, {"w": "is", "b": [0.2315, 0.4416, 0.2447, 0.463]}, {"w": "just", "b": [0.2494, 0.4416, 0.2798, 0.463]}, {"w": "as", "b": [0.2846, 0.4416, 0.3013, 0.463]}, {"w": "easy:", "b": [0.3061, 0.4416, 0.3467, 0.463]}]}, {"id": "b_7", "type": "equation", "text": "model = keras.models.load_model(\"my_keras_model.h5\")", "words": [{"w": "model", "b": [0.1766, 0.4736, 0.2188, 0.4864]}, {"w": "=", "b": [0.2272, 0.4736, 0.2356, 0.4864]}, {"w": "keras.models.load_model(\"my_keras_model.h5\")", "b": [0.2441, 0.4736, 0.6151, 0.4864]}]}, {"id": "b_8", "type": "paragraph", "text": "This will work when using the Sequential API or the Functional API, but unfortunately not when using Model subclassing. How‐ ever, you can use save_weights() and load_weights() to at least save and restore the model parameters (but you will need to save and restore everything else yourself).", "words": [{"w": "This", "b": [0.2714, 0.508, 0.3054, 0.5276]}, {"w": "will", "b": [0.3127, 0.508, 0.3405, 0.5276]}, {"w": "work", "b": [0.3478, 0.508, 0.3871, 0.5276]}, {"w": "when", "b": [0.3944, 0.508, 0.4361, 0.5276]}, {"w": "using", "b": [0.4434, 0.508, 0.4849, 0.5276]}, {"w": "the", "b": [0.4922, 0.508, 0.5163, 0.5276]}, {"w": "Sequential", "b": [0.5236, 0.508, 0.6028, 0.5276]}, {"w": "API", "b": [0.6101, 0.508, 0.6405, 0.5276]}, {"w": "or", "b": [0.6478, 0.508, 0.6645, 0.5276]}, {"w": "the", "b": [0.6718, 0.508, 0.6959, 0.5276]}, {"w": "Functional", "b": [0.7032, 0.508, 0.7857, 0.5276]}, {"w": "API,", "b": [0.2714, 0.5254, 0.3061, 0.545]}, {"w": "but", "b": [0.3132, 0.5254, 0.3388, 0.545]}, {"w": "unfortunately", "b": [0.3458, 0.5254, 0.4506, 0.545]}, {"w": "not", "b": [0.4576, 0.5254, 0.4836, 0.545]}, {"w": "when", "b": [0.4906, 0.5254, 0.5324, 0.545]}, {"w": "using", "b": [0.5394, 0.5254, 0.581, 0.545]}, {"w": "Model", "b": [0.588, 0.5254, 0.6372, 0.545]}, {"w": "subclassing.", "b": [0.6442, 0.5254, 0.735, 0.545]}, {"w": "How‐", "b": [0.7421, 0.5254, 0.7857, 0.545]}, {"w": "ever,", "b": [0.2714, 0.5437, 0.3066, 0.5632]}, {"w": "you", "b": [0.3125, 0.5437, 0.3411, 0.5632]}, {"w": "can", "b": [0.347, 0.5437, 0.3738, 0.5632]}, {"w": "use", "b": [0.3797, 0.5437, 0.4049, 0.5632]}, {"w": "save_weights()", "b": [0.4107, 0.5466, 0.5374, 0.5604]}, {"w": "and", "b": [0.5433, 0.5437, 0.5721, 0.5632]}, {"w": "load_weights()", "b": [0.578, 0.5466, 0.7047, 0.5604]}, {"w": "to", "b": [0.7106, 0.5437, 0.7261, 0.5632]}, {"w": "at", "b": [0.732, 0.5437, 0.7458, 0.5632]}, {"w": "least", "b": [0.7516, 0.5437, 0.7857, 0.5632]}, {"w": "save", "b": [0.2714, 0.5611, 0.3033, 0.5807]}, {"w": "and", "b": [0.3097, 0.5611, 0.3386, 0.5807]}, {"w": "restore", "b": [0.3449, 0.5611, 0.3978, 0.5807]}, {"w": "the", "b": [0.4042, 0.5611, 0.4282, 0.5807]}, {"w": "model", "b": [0.4346, 0.5611, 0.4829, 0.5807]}, {"w": "parameters", "b": [0.4893, 0.5611, 0.5747, 0.5807]}, {"w": "(but", "b": [0.5811, 0.5611, 0.6133, 0.5807]}, {"w": "you", "b": [0.6197, 0.5611, 0.6483, 0.5807]}, {"w": "will", "b": [0.6547, 0.5611, 0.6824, 0.5807]}, {"w": "need", "b": [0.6888, 0.5611, 0.7255, 0.5807]}, {"w": "to", "b": [0.7319, 0.5611, 0.7474, 0.5807]}, {"w": "save", "b": [0.7538, 0.5611, 0.7857, 0.5807]}, {"w": "and", "b": [0.2714, 0.5785, 0.3003, 0.5981]}, {"w": "restore", "b": [0.3046, 0.5785, 0.3574, 0.5981]}, {"w": "everything", "b": [0.3617, 0.5785, 0.4435, 0.5981]}, {"w": "else", "b": [0.4479, 0.5785, 0.4759, 0.5981]}, {"w": "yourself).", "b": [0.4802, 0.5785, 0.5538, 0.5981]}]}, {"id": "b_9", "type": "paragraph", "text": "But what if training lasts several hours? This is quite common, especially when train‐ ing on large datasets. In this case, you should not only save your model at the end of training, but also save checkpoints at regular intervals during training. But how can you tell the fit() method to save checkpoints? The answer is: using callbacks.", "words": [{"w": "But", "b": [0.1429, 0.6184, 0.1725, 0.6398]}, {"w": "what", "b": [0.1779, 0.6184, 0.2184, 0.6398]}, {"w": "if", "b": [0.2237, 0.6184, 0.2355, 0.6398]}, {"w": "training", "b": [0.2409, 0.6184, 0.3078, 0.6398]}, {"w": "lasts", "b": [0.3132, 0.6184, 0.3492, 0.6398]}, {"w": "several", "b": [0.3546, 0.6184, 0.4117, 0.6398]}, {"w": "hours?", "b": [0.4171, 0.6184, 0.4732, 0.6398]}, {"w": "This", "b": [0.4785, 0.6184, 0.5157, 0.6398]}, {"w": "is", "b": [0.5211, 0.6184, 0.5343, 0.6398]}, {"w": "quite", "b": [0.5397, 0.6184, 0.5822, 0.6398]}, {"w": "common,", "b": [0.5875, 0.6184, 0.6679, 0.6398]}, {"w": "especially", "b": [0.6732, 0.6184, 0.7532, 0.6398]}, {"w": "when", "b": [0.7585, 0.6184, 0.8042, 0.6398]}, {"w": "train‐", "b": [0.8095, 0.6184, 0.8571, 0.6398]}, {"w": "ing", "b": [0.1429, 0.6374, 0.1696, 0.6588]}, {"w": "on", "b": [0.1753, 0.6374, 0.1973, 0.6588]}, {"w": "large", "b": [0.203, 0.6374, 0.2437, 0.6588]}, {"w": "datasets.", "b": [0.2494, 0.6374, 0.3199, 0.6588]}, {"w": "In", "b": [0.3256, 0.6374, 0.3441, 0.6588]}, {"w": "this", "b": [0.3497, 0.6374, 0.3804, 0.6588]}, {"w": "case,", "b": [0.3861, 0.6374, 0.4253, 0.6588]}, {"w": "you", "b": [0.431, 0.6374, 0.4622, 0.6588]}, {"w": "should", "b": [0.4679, 0.6374, 0.5246, 0.6588]}, {"w": "not", "b": [0.5303, 0.6374, 0.5587, 0.6588]}, {"w": "only", "b": [0.5644, 0.6374, 0.6012, 0.6588]}, {"w": "save", "b": [0.6069, 0.6374, 0.6418, 0.6588]}, {"w": "your", "b": [0.6475, 0.6374, 0.6865, 0.6588]}, {"w": "model", "b": [0.6921, 0.6374, 0.745, 0.6588]}, {"w": "at", "b": [0.7506, 0.6374, 0.7657, 0.6588]}, {"w": "the", "b": [0.7714, 0.6374, 0.7977, 0.6588]}, {"w": "end", "b": [0.8034, 0.6374, 0.8347, 0.6588]}, {"w": "of", "b": [0.8403, 0.6374, 0.8571, 0.6588]}, {"w": "training,", "b": [0.1429, 0.6565, 0.2146, 0.6779]}, {"w": "but", "b": [0.221, 0.6565, 0.249, 0.6779]}, {"w": "also", "b": [0.2554, 0.6565, 0.2881, 0.6779]}, {"w": "save", "b": [0.2945, 0.6565, 0.3295, 0.6779]}, {"w": "checkpoints", "b": [0.3359, 0.6565, 0.436, 0.6779]}, {"w": "at", "b": [0.4424, 0.6565, 0.4575, 0.6779]}, {"w": "regular", "b": [0.4639, 0.6565, 0.5235, 0.6779]}, {"w": "intervals", "b": [0.5299, 0.6565, 0.6017, 0.6779]}, {"w": "during", "b": [0.6082, 0.6565, 0.6647, 0.6779]}, {"w": "training.", "b": [0.6711, 0.6565, 0.7428, 0.6779]}, {"w": "But", "b": [0.7492, 0.6565, 0.7789, 0.6779]}, {"w": "how", "b": [0.7853, 0.6565, 0.8214, 0.6779]}, {"w": "can", "b": [0.8278, 0.6565, 0.8572, 0.6779]}, {"w": "you", "b": [0.1429, 0.6764, 0.1741, 0.6978]}, {"w": "tell", "b": [0.1788, 0.6764, 0.2046, 0.6978]}, {"w": "the", "b": [0.2093, 0.6764, 0.2357, 0.6978]}, {"w": "fit()", "b": [0.2404, 0.6796, 0.2899, 0.6947]}, {"w": "method", "b": [0.2946, 0.6764, 0.3596, 0.6978]}, {"w": "to", "b": [0.3643, 0.6764, 0.3813, 0.6978]}, {"w": "save", "b": [0.386, 0.6764, 0.421, 0.6978]}, {"w": "checkpoints?", "b": [0.4257, 0.6764, 0.5337, 0.6978]}, {"w": "The", "b": [0.5384, 0.6764, 0.5712, 0.6978]}, {"w": "answer", "b": [0.5759, 0.6764, 0.635, 0.6978]}, {"w": "is:", "b": [0.6397, 0.6764, 0.6577, 0.6978]}, {"w": "using", "b": [0.6624, 0.6764, 0.7079, 0.6978]}, {"w": "callbacks.", "b": [0.7126, 0.6764, 0.7924, 0.6978]}]}, {"id": "b_10", "type": "paragraph", "text": "Using Callbacks", "words": [{"w": "Using", "b": [0.1428, 0.7106, 0.2008, 0.7392]}, {"w": "Callbacks", "b": [0.2058, 0.7106, 0.3005, 0.7392]}]}, {"id": "b_11", "type": "paragraph", "text": "The fit() method accepts a callbacks argument that lets you specify a list of objects that Keras will call during training at the start and end of training, at the start and end of each epoch and even before and after processing each batch. For example, the Mod elCheckpoint callback saves checkpoints of your model at regular intervals during training, by default at the end of each epoch:", "words": [{"w": "The", "b": [0.1429, 0.746, 0.1757, 0.7674]}, {"w": "fit()", "b": [0.1806, 0.7491, 0.2301, 0.7642]}, {"w": "method", "b": [0.2349, 0.746, 0.3, 0.7674]}, {"w": "accepts", "b": [0.3047, 0.746, 0.3652, 0.7674]}, {"w": "a", "b": [0.37, 0.746, 0.3791, 0.7674]}, {"w": "callbacks", "b": [0.3843, 0.7491, 0.4734, 0.7642]}, {"w": "argument", "b": [0.4782, 0.746, 0.5592, 0.7674]}, {"w": "that", "b": [0.5641, 0.746, 0.5967, 0.7674]}, {"w": "lets", "b": [0.6016, 0.746, 0.6297, 0.7674]}, {"w": "you", "b": [0.6346, 0.746, 0.6658, 0.7674]}, {"w": "specify", "b": [0.6707, 0.746, 0.7286, 0.7674]}, {"w": "a", "b": [0.7335, 0.746, 0.7426, 0.7674]}, {"w": "list", "b": [0.7475, 0.746, 0.7724, 0.7674]}, {"w": "of", "b": [0.7773, 0.746, 0.794, 0.7674]}, {"w": "objects", "b": [0.7989, 0.746, 0.8571, 0.7674]}, {"w": "that", "b": [0.1429, 0.765, 0.1754, 0.7864]}, {"w": "Keras", "b": [0.1802, 0.765, 0.2271, 0.7864]}, {"w": "will", "b": [0.2318, 0.765, 0.2622, 0.7864]}, {"w": "call", "b": [0.2669, 0.765, 0.2954, 0.7864]}, {"w": "during", "b": [0.3002, 0.765, 0.3567, 0.7864]}, {"w": "training", "b": [0.3614, 0.765, 0.4283, 0.7864]}, {"w": "at", "b": [0.4331, 0.765, 0.4482, 0.7864]}, {"w": "the", "b": [0.4529, 0.765, 0.4792, 0.7864]}, {"w": "start", "b": [0.484, 0.765, 0.5212, 0.7864]}, {"w": "and", "b": [0.5259, 0.765, 0.5575, 0.7864]}, {"w": "end", "b": [0.5622, 0.765, 0.5934, 0.7864]}, {"w": "of", "b": [0.5982, 0.765, 0.615, 0.7864]}, {"w": "training,", "b": [0.6197, 0.765, 0.6914, 0.7864]}, {"w": "at", "b": [0.6961, 0.765, 0.7112, 0.7864]}, {"w": "the", "b": [0.7159, 0.765, 0.7423, 0.7864]}, {"w": "start", "b": [0.747, 0.765, 0.7842, 0.7864]}, {"w": "and", "b": [0.789, 0.765, 0.8205, 0.7864]}, {"w": "end", "b": [0.8252, 0.765, 0.8565, 0.7864]}, {"w": "of", "b": [0.1429, 0.7849, 0.1597, 0.8064]}, {"w": "each", "b": [0.1653, 0.7849, 0.2032, 0.8064]}, {"w": "epoch", "b": [0.2089, 0.7849, 0.2592, 0.8064]}, {"w": "and", "b": [0.2648, 0.7849, 0.2964, 0.8064]}, {"w": "even", "b": [0.302, 0.7849, 0.3408, 0.8064]}, {"w": "before", "b": [0.3464, 0.7849, 0.3992, 0.8064]}, {"w": "and", "b": [0.4048, 0.7849, 0.4364, 0.8064]}, {"w": "after", "b": [0.442, 0.7849, 0.4803, 0.8064]}, {"w": "processing", "b": [0.4859, 0.7849, 0.5749, 0.8064]}, {"w": "each", "b": [0.5805, 0.7849, 0.6184, 0.8064]}, {"w": "batch.", "b": [0.6241, 0.7849, 0.6745, 0.8064]}, {"w": "For", "b": [0.6801, 0.7849, 0.7091, 0.8064]}, {"w": "example,", "b": [0.7147, 0.7849, 0.789, 0.8064]}, {"w": "the", "b": [0.7946, 0.7849, 0.821, 0.8064]}, {"w": "Mod", "b": [0.8266, 0.7881, 0.8563, 0.8032]}, {"w": "elCheckpoint", "b": [0.1429, 0.8081, 0.2616, 0.8231]}, {"w": "callback", "b": [0.269, 0.8049, 0.3364, 0.8263]}, {"w": "saves", "b": [0.3438, 0.8049, 0.3863, 0.8263]}, {"w": "checkpoints", "b": [0.3937, 0.8049, 0.4938, 0.8263]}, {"w": "of", "b": [0.5012, 0.8049, 0.518, 0.8263]}, {"w": "your", "b": [0.5254, 0.8049, 0.5644, 0.8263]}, {"w": "model", "b": [0.5718, 0.8049, 0.6246, 0.8263]}, {"w": "at", "b": [0.632, 0.8049, 0.6471, 0.8263]}, {"w": "regular", "b": [0.6545, 0.8049, 0.714, 0.8263]}, {"w": "intervals", "b": [0.7214, 0.8049, 0.7932, 0.8263]}, {"w": "during", "b": [0.8006, 0.8049, 0.8571, 0.8263]}, {"w": "training,", "b": [0.1429, 0.8239, 0.2145, 0.8453]}, {"w": "by", "b": [0.2193, 0.8239, 0.2394, 0.8453]}, {"w": "default", "b": [0.2441, 0.8239, 0.3016, 0.8453]}, {"w": "at", "b": [0.3063, 0.8239, 0.3214, 0.8453]}, {"w": "the", "b": [0.3262, 0.8239, 0.3525, 0.8453]}, {"w": "end", "b": [0.3572, 0.8239, 0.3885, 0.8453]}, {"w": "of", "b": [0.3932, 0.8239, 0.41, 0.8453]}, {"w": "each", "b": [0.4147, 0.8239, 0.4527, 0.8453]}, {"w": "epoch:", "b": [0.4574, 0.8239, 0.5125, 0.8453]}]}, {"id": "b_12", "type": "paragraph", "text": "Implementing MLPs with Keras | 311", "words": [{"w": "Implementing", "b": [0.6126, 0.9225, 0.6972, 0.9388]}, {"w": "MLPs", "b": [0.7001, 0.9225, 0.7308, 0.9388]}, {"w": "with", "b": [0.7336, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "311", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 338, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "[...] # build and compile the model checkpoint_cb = keras.callbacks.ModelCheckpoint(\"my_keras_model.h5\") history = model.fit(X_train, y_train, epochs=10, callbacks=[checkpoint_cb])", "words": [{"w": "[...]", "b": [0.1766, 0.0829, 0.2188, 0.0958]}, {"w": "#", "b": [0.2272, 0.0829, 0.2356, 0.0958]}, {"w": "build", "b": [0.244, 0.0829, 0.2862, 0.0958]}, {"w": "and", "b": [0.2946, 0.0829, 0.3199, 0.0958]}, {"w": "compile", "b": [0.3284, 0.0829, 0.3874, 0.0958]}, {"w": "the", "b": [0.3958, 0.0829, 0.4211, 0.0958]}, {"w": "model", "b": [0.4296, 0.0829, 0.4717, 0.0958]}, {"w": "checkpoint_cb", "b": [0.1766, 0.0983, 0.2862, 0.1112]}, {"w": "=", "b": [0.2946, 0.0983, 0.3031, 0.1112]}, {"w": "keras.callbacks.ModelCheckpoint(\"my_keras_model.h5\")", "b": [0.3115, 0.0983, 0.75, 0.1112]}, {"w": "history", "b": [0.1766, 0.1138, 0.2356, 0.1266]}, {"w": "=", "b": [0.244, 0.1138, 0.2525, 0.1266]}, {"w": "model.fit(X_train,", "b": [0.2609, 0.1138, 0.4127, 0.1266]}, {"w": "y_train,", "b": [0.4211, 0.1138, 0.4886, 0.1266]}, {"w": "epochs=10,", "b": [0.497, 0.1138, 0.5813, 0.1266]}, {"w": "callbacks=[checkpoint_cb])", "b": [0.5898, 0.1138, 0.809, 0.1266]}]}, {"id": "b_1", "type": "paragraph", "text": "Moreover, if you use a validation set during training, you can set save_best_only=True when creating the ModelCheckpoint. In this case, it will only save your model when its performance on the validation set is the best so far. This way, you do not need to worry about training for too long and overfitting the training set: simply restore the last model saved after training, and this will be the best model on the validation set. This is a simple way to implement early stopping (introduced in Chapter 4):", "words": [{"w": "Moreover,", "b": [0.1429, 0.1344, 0.2284, 0.1558]}, {"w": "if", "b": [0.2494, 0.1344, 0.2611, 0.1558]}, {"w": "you", "b": [0.2822, 0.1344, 0.3134, 0.1558]}, {"w": "use", "b": [0.3344, 0.1344, 0.362, 0.1558]}, {"w": "a", "b": [0.383, 0.1344, 0.3922, 0.1558]}, {"w": "validation", "b": [0.4132, 0.1344, 0.4965, 0.1558]}, {"w": "set", "b": [0.5175, 0.1344, 0.5404, 0.1558]}, {"w": "during", "b": [0.5614, 0.1344, 0.6179, 0.1558]}, {"w": "training,", "b": [0.639, 0.1344, 0.7106, 0.1558]}, {"w": "you", "b": [0.7317, 0.1344, 0.7629, 0.1558]}, {"w": "can", "b": [0.7839, 0.1344, 0.8133, 0.1558]}, {"w": "set", "b": [0.8343, 0.1344, 0.8571, 0.1558]}, {"w": "save_best_only=True", "b": [0.1429, 0.1575, 0.3309, 0.1726]}, {"w": "when", "b": [0.3375, 0.1543, 0.3832, 0.1757]}, {"w": "creating", "b": [0.3898, 0.1543, 0.457, 0.1757]}, {"w": "the", "b": [0.4636, 0.1543, 0.49, 0.1757]}, {"w": "ModelCheckpoint.", "b": [0.4966, 0.1543, 0.6498, 0.1757]}, {"w": "In", "b": [0.6564, 0.1543, 0.6749, 0.1757]}, {"w": "this", "b": [0.6815, 0.1543, 0.7122, 0.1757]}, {"w": "case,", "b": [0.7189, 0.1543, 0.7581, 0.1757]}, {"w": "it", "b": [0.7647, 0.1543, 0.7766, 0.1757]}, {"w": "will", "b": [0.7833, 0.1543, 0.8137, 0.1757]}, {"w": "only", "b": [0.8203, 0.1543, 0.8572, 0.1757]}, {"w": "save", "b": [0.1429, 0.1734, 0.1778, 0.1948]}, {"w": "your", "b": [0.1848, 0.1734, 0.2238, 0.1948]}, {"w": "model", "b": [0.2308, 0.1734, 0.2836, 0.1948]}, {"w": "when", "b": [0.2907, 0.1734, 0.3363, 0.1948]}, {"w": "its", "b": [0.3434, 0.1734, 0.3629, 0.1948]}, {"w": "performance", "b": [0.37, 0.1734, 0.4773, 0.1948]}, {"w": "on", "b": [0.4843, 0.1734, 0.5063, 0.1948]}, {"w": "the", "b": [0.5134, 0.1734, 0.5397, 0.1948]}, {"w": "validation", "b": [0.5467, 0.1734, 0.6301, 0.1948]}, {"w": "set", "b": [0.6371, 0.1734, 0.66, 0.1948]}, {"w": "is", "b": [0.667, 0.1734, 0.6802, 0.1948]}, {"w": "the", "b": [0.6873, 0.1734, 0.7136, 0.1948]}, {"w": "best", "b": [0.7206, 0.1734, 0.7541, 0.1948]}, {"w": "so", "b": [0.7611, 0.1734, 0.7794, 0.1948]}, {"w": "far.", "b": [0.7864, 0.1734, 0.8129, 0.1948]}, {"w": "This", "b": [0.8199, 0.1734, 0.8571, 0.1948]}, {"w": "way,", "b": [0.1429, 0.1924, 0.1787, 0.2138]}, {"w": "you", "b": [0.1835, 0.1924, 0.2148, 0.2138]}, {"w": "do", "b": [0.2197, 0.1924, 0.2413, 0.2138]}, {"w": "not", "b": [0.2461, 0.1924, 0.2745, 0.2138]}, {"w": "need", "b": [0.2794, 0.1924, 0.3195, 0.2138]}, {"w": "to", "b": [0.3243, 0.1924, 0.3413, 0.2138]}, {"w": "worry", "b": [0.3462, 0.1924, 0.3967, 0.2138]}, {"w": "about", "b": [0.4015, 0.1924, 0.4493, 0.2138]}, {"w": "training", "b": [0.4542, 0.1924, 0.5211, 0.2138]}, {"w": "for", "b": [0.526, 0.1924, 0.5505, 0.2138]}, {"w": "too", "b": [0.5553, 0.1924, 0.583, 0.2138]}, {"w": "long", "b": [0.5878, 0.1924, 0.6249, 0.2138]}, {"w": "and", "b": [0.6297, 0.1924, 0.6613, 0.2138]}, {"w": "overfitting", "b": [0.6661, 0.1924, 0.7542, 0.2138]}, {"w": "the", "b": [0.759, 0.1924, 0.7853, 0.2138]}, {"w": "training", "b": [0.7902, 0.1924, 0.8571, 0.2138]}, {"w": "set:", "b": [0.1428, 0.2115, 0.1705, 0.2329]}, {"w": "simply", "b": [0.1761, 0.2115, 0.2318, 0.2329]}, {"w": "restore", "b": [0.2375, 0.2115, 0.2952, 0.2329]}, {"w": "the", "b": [0.3009, 0.2115, 0.3273, 0.2329]}, {"w": "last", "b": [0.3329, 0.2115, 0.3613, 0.2329]}, {"w": "model", "b": [0.367, 0.2115, 0.4198, 0.2329]}, {"w": "saved", "b": [0.4255, 0.2115, 0.4714, 0.2329]}, {"w": "after", "b": [0.4771, 0.2115, 0.5154, 0.2329]}, {"w": "training,", "b": [0.521, 0.2115, 0.5927, 0.2329]}, {"w": "and", "b": [0.5984, 0.2115, 0.6299, 0.2329]}, {"w": "this", "b": [0.6356, 0.2115, 0.6663, 0.2329]}, {"w": "will", "b": [0.672, 0.2115, 0.7024, 0.2329]}, {"w": "be", "b": [0.7081, 0.2115, 0.7275, 0.2329]}, {"w": "the", "b": [0.7332, 0.2115, 0.7595, 0.2329]}, {"w": "best", "b": [0.7652, 0.2115, 0.7986, 0.2329]}, {"w": "model", "b": [0.8043, 0.2115, 0.8571, 0.2329]}, {"w": "on", "b": [0.1429, 0.2305, 0.1649, 0.2519]}, {"w": "the", "b": [0.1699, 0.2305, 0.1962, 0.2519]}, {"w": "validation", "b": [0.2013, 0.2305, 0.2846, 0.2519]}, {"w": "set.", "b": [0.2896, 0.2305, 0.3172, 0.2519]}, {"w": "This", "b": [0.3223, 0.2305, 0.3595, 0.2519]}, {"w": "is", "b": [0.3645, 0.2305, 0.3777, 0.2519]}, {"w": "a", "b": [0.3828, 0.2305, 0.3919, 0.2519]}, {"w": "simple", "b": [0.3969, 0.2305, 0.4519, 0.2519]}, {"w": "way", "b": [0.4569, 0.2305, 0.4895, 0.2519]}, {"w": "to", "b": [0.4945, 0.2305, 0.5115, 0.2519]}, {"w": "implement", "b": [0.5165, 0.2305, 0.6071, 0.2519]}, {"w": "early", "b": [0.6121, 0.2305, 0.6527, 0.2519]}, {"w": "stopping", "b": [0.6577, 0.2305, 0.7309, 0.2519]}, {"w": "(introduced", "b": [0.7359, 0.2305, 0.8351, 0.2519]}, {"w": "in", "b": [0.8402, 0.2305, 0.8571, 0.2519]}, {"w": "Chapter", "b": [0.1429, 0.2496, 0.2104, 0.271]}, {"w": "4):", "b": [0.2152, 0.2496, 0.2371, 0.271]}]}, {"id": "b_2", "type": "paragraph", "text": "checkpoint_cb = keras.callbacks.ModelCheckpoint(\"my_keras_model.h5\", save_best_only=True) history = model.fit(X_train, y_train, epochs=10, validation_data=(X_valid, y_valid), callbacks=[checkpoint_cb]) model = keras.models.load_model(\"my_keras_model.h5\") # rollback to best model", "words": [{"w": "checkpoint_cb", "b": [0.1766, 0.2815, 0.2862, 0.2944]}, {"w": "=", "b": [0.2946, 0.2815, 0.3031, 0.2944]}, {"w": "keras.callbacks.ModelCheckpoint(\"my_keras_model.h5\",", "b": [0.3115, 0.2815, 0.75, 0.2944]}, {"w": "save_best_only=True)", "b": [0.5813, 0.297, 0.75, 0.3098]}, {"w": "history", "b": [0.1766, 0.3124, 0.2356, 0.3252]}, {"w": "=", "b": [0.244, 0.3124, 0.2525, 0.3252]}, {"w": "model.fit(X_train,", "b": [0.2609, 0.3124, 0.4127, 0.3252]}, {"w": "y_train,", "b": [0.4211, 0.3124, 0.4886, 0.3252]}, {"w": "epochs=10,", "b": [0.497, 0.3124, 0.5813, 0.3252]}, {"w": "validation_data=(X_valid,", "b": [0.3452, 0.3278, 0.556, 0.3407]}, {"w": "y_valid),", "b": [0.5645, 0.3278, 0.6404, 0.3407]}, {"w": "callbacks=[checkpoint_cb])", "b": [0.3452, 0.3432, 0.5645, 0.3561]}, {"w": "model", "b": [0.1766, 0.3586, 0.2187, 0.3715]}, {"w": "=", "b": [0.2272, 0.3586, 0.2356, 0.3715]}, {"w": "keras.models.load_model(\"my_keras_model.h5\")", "b": [0.244, 0.3586, 0.6151, 0.3715]}, {"w": "#", "b": [0.6235, 0.3586, 0.6319, 0.3715]}, {"w": "rollback", "b": [0.6404, 0.3586, 0.7078, 0.3715]}, {"w": "to", "b": [0.7163, 0.3586, 0.7331, 0.3715]}, {"w": "best", "b": [0.7416, 0.3586, 0.7753, 0.3715]}, {"w": "model", "b": [0.7837, 0.3586, 0.8259, 0.3715]}]}, {"id": "b_3", "type": "paragraph", "text": "Another way to implement early stopping is to simply use the EarlyStopping call‐ back. It will interrupt training when it measures no progress on the validation set for a number of epochs (defined by the patience argument), and it will optionally roll back to the best model. You can combine both callbacks to both save checkpoints of your model (in case your computer crashes), and actually interrupt training early when there is no more progress (to avoid wasting time and resources):", "words": [{"w": "Another", "b": [0.1429, 0.3802, 0.2133, 0.4016]}, {"w": "way", "b": [0.2205, 0.3802, 0.2531, 0.4016]}, {"w": "to", "b": [0.2602, 0.3802, 0.2772, 0.4016]}, {"w": "implement", "b": [0.2843, 0.3802, 0.3749, 0.4016]}, {"w": "early", "b": [0.382, 0.3802, 0.4226, 0.4016]}, {"w": "stopping", "b": [0.4297, 0.3802, 0.5029, 0.4016]}, {"w": "is", "b": [0.51, 0.3802, 0.5233, 0.4016]}, {"w": "to", "b": [0.5304, 0.3802, 0.5474, 0.4016]}, {"w": "simply", "b": [0.5545, 0.3802, 0.6102, 0.4016]}, {"w": "use", "b": [0.6173, 0.3802, 0.6449, 0.4016]}, {"w": "the", "b": [0.652, 0.3802, 0.6783, 0.4016]}, {"w": "EarlyStopping", "b": [0.6855, 0.3834, 0.8141, 0.3984]}, {"w": "call‐", "b": [0.8212, 0.3802, 0.8572, 0.4016]}, {"w": "back.", "b": [0.1429, 0.3992, 0.1865, 0.4206]}, {"w": "It", "b": [0.192, 0.3992, 0.2047, 0.4206]}, {"w": "will", "b": [0.2102, 0.3992, 0.2406, 0.4206]}, {"w": "interrupt", "b": [0.2461, 0.3992, 0.3217, 0.4206]}, {"w": "training", "b": [0.3273, 0.3992, 0.3942, 0.4206]}, {"w": "when", "b": [0.3997, 0.3992, 0.4454, 0.4206]}, {"w": "it", "b": [0.4509, 0.3992, 0.4629, 0.4206]}, {"w": "measures", "b": [0.4684, 0.3992, 0.5464, 0.4206]}, {"w": "no", "b": [0.5519, 0.3992, 0.5739, 0.4206]}, {"w": "progress", "b": [0.5795, 0.3992, 0.6504, 0.4206]}, {"w": "on", "b": [0.6559, 0.3992, 0.6779, 0.4206]}, {"w": "the", "b": [0.6835, 0.3992, 0.7098, 0.4206]}, {"w": "validation", "b": [0.7153, 0.3992, 0.7987, 0.4206]}, {"w": "set", "b": [0.8042, 0.3992, 0.8271, 0.4206]}, {"w": "for", "b": [0.8326, 0.3992, 0.8571, 0.4206]}, {"w": "a", "b": [0.1429, 0.4192, 0.152, 0.4406]}, {"w": "number", "b": [0.1588, 0.4192, 0.2251, 0.4406]}, {"w": "of", "b": [0.2318, 0.4192, 0.2486, 0.4406]}, {"w": "epochs", "b": [0.2554, 0.4192, 0.3134, 0.4406]}, {"w": "(defined", "b": [0.3201, 0.4192, 0.3902, 0.4406]}, {"w": "by", "b": [0.3969, 0.4192, 0.4171, 0.4406]}, {"w": "the", "b": [0.4239, 0.4192, 0.4502, 0.4406]}, {"w": "patience", "b": [0.457, 0.4223, 0.5361, 0.4374]}, {"w": "argument),", "b": [0.5429, 0.4192, 0.6358, 0.4406]}, {"w": "and", "b": [0.6426, 0.4192, 0.6741, 0.4406]}, {"w": "it", "b": [0.6809, 0.4192, 0.6928, 0.4406]}, {"w": "will", "b": [0.6996, 0.4192, 0.73, 0.4406]}, {"w": "optionally", "b": [0.7367, 0.4192, 0.8215, 0.4406]}, {"w": "roll", "b": [0.8282, 0.4192, 0.8571, 0.4406]}, {"w": "back", "b": [0.1428, 0.4382, 0.1817, 0.4596]}, {"w": "to", "b": [0.1878, 0.4382, 0.2048, 0.4596]}, {"w": "the", "b": [0.2109, 0.4382, 0.2372, 0.4596]}, {"w": "best", "b": [0.2433, 0.4382, 0.2768, 0.4596]}, {"w": "model.", "b": [0.2829, 0.4382, 0.3404, 0.4596]}, {"w": "You", "b": [0.3465, 0.4382, 0.3789, 0.4596]}, {"w": "can", "b": [0.385, 0.4382, 0.4143, 0.4596]}, {"w": "combine", "b": [0.4204, 0.4382, 0.4933, 0.4596]}, {"w": "both", "b": [0.4994, 0.4382, 0.5381, 0.4596]}, {"w": "callbacks", "b": [0.5442, 0.4382, 0.6192, 0.4596]}, {"w": "to", "b": [0.6253, 0.4382, 0.6423, 0.4596]}, {"w": "both", "b": [0.6484, 0.4382, 0.6871, 0.4596]}, {"w": "save", "b": [0.6932, 0.4382, 0.7281, 0.4596]}, {"w": "checkpoints", "b": [0.7342, 0.4382, 0.8342, 0.4596]}, {"w": "of", "b": [0.8403, 0.4382, 0.8571, 0.4596]}, {"w": "your", "b": [0.1429, 0.4573, 0.1818, 0.4787]}, {"w": "model", "b": [0.1902, 0.4573, 0.243, 0.4787]}, {"w": "(in", "b": [0.2513, 0.4573, 0.2755, 0.4787]}, {"w": "case", "b": [0.2838, 0.4573, 0.3183, 0.4787]}, {"w": "your", "b": [0.3266, 0.4573, 0.3656, 0.4787]}, {"w": "computer", "b": [0.374, 0.4573, 0.455, 0.4787]}, {"w": "crashes),", "b": [0.4633, 0.4573, 0.5362, 0.4787]}, {"w": "and", "b": [0.5446, 0.4573, 0.5761, 0.4787]}, {"w": "actually", "b": [0.5844, 0.4573, 0.6491, 0.4787]}, {"w": "interrupt", "b": [0.6574, 0.4573, 0.733, 0.4787]}, {"w": "training", "b": [0.7413, 0.4573, 0.8083, 0.4787]}, {"w": "early", "b": [0.8166, 0.4573, 0.8571, 0.4787]}, {"w": "when", "b": [0.1429, 0.4763, 0.1885, 0.4977]}, {"w": "there", "b": [0.1932, 0.4763, 0.2361, 0.4977]}, {"w": "is", "b": [0.2409, 0.4763, 0.2541, 0.4977]}, {"w": "no", "b": [0.2588, 0.4763, 0.2809, 0.4977]}, {"w": "more", "b": [0.2856, 0.4763, 0.3299, 0.4977]}, {"w": "progress", "b": [0.3346, 0.4763, 0.4055, 0.4977]}, {"w": "(to", "b": [0.4102, 0.4763, 0.4344, 0.4977]}, {"w": "avoid", "b": [0.4391, 0.4763, 0.4848, 0.4977]}, {"w": "wasting", "b": [0.4895, 0.4763, 0.5536, 0.4977]}, {"w": "time", "b": [0.5584, 0.4763, 0.5962, 0.4977]}, {"w": "and", "b": [0.6009, 0.4763, 0.6325, 0.4977]}, {"w": "resources):", "b": [0.6372, 0.4763, 0.7281, 0.4977]}]}, {"id": "b_4", "type": "paragraph", "text": "early_stopping_cb = keras.callbacks.EarlyStopping(patience=10, restore_best_weights=True) history = model.fit(X_train, y_train, epochs=100, validation_data=(X_valid, y_valid), callbacks=[checkpoint_cb, early_stopping_cb])", "words": [{"w": "early_stopping_cb", "b": [0.1766, 0.5083, 0.3199, 0.5211]}, {"w": "=", "b": [0.3284, 0.5083, 0.3368, 0.5211]}, {"w": "keras.callbacks.EarlyStopping(patience=10,", "b": [0.3452, 0.5083, 0.6994, 0.5211]}, {"w": "restore_best_weights=True)", "b": [0.5982, 0.5237, 0.8175, 0.5366]}, {"w": "history", "b": [0.1766, 0.5391, 0.2356, 0.552]}, {"w": "=", "b": [0.2441, 0.5391, 0.2525, 0.552]}, {"w": "model.fit(X_train,", "b": [0.2609, 0.5391, 0.4127, 0.552]}, {"w": "y_train,", "b": [0.4211, 0.5391, 0.4886, 0.552]}, {"w": "epochs=100,", "b": [0.497, 0.5391, 0.5898, 0.552]}, {"w": "validation_data=(X_valid,", "b": [0.3452, 0.5545, 0.5561, 0.5674]}, {"w": "y_valid),", "b": [0.5645, 0.5545, 0.6404, 0.5674]}, {"w": "callbacks=[checkpoint_cb,", "b": [0.3452, 0.57, 0.5561, 0.5828]}, {"w": "early_stopping_cb])", "b": [0.5645, 0.57, 0.7247, 0.5828]}]}, {"id": "b_5", "type": "paragraph", "text": "The number of epochs can be set to a large value since training will stop automati‐ cally when there is no more progress. Moreover, there is no need to restore the best model saved in this case since the EarlyStopping callback will keep track of the best weights and restore them for us at the end of training.", "words": [{"w": "The", "b": [0.1429, 0.5906, 0.1757, 0.612]}, {"w": "number", "b": [0.1824, 0.5906, 0.2487, 0.612]}, {"w": "of", "b": [0.2554, 0.5906, 0.2722, 0.612]}, {"w": "epochs", "b": [0.2789, 0.5906, 0.3369, 0.612]}, {"w": "can", "b": [0.3436, 0.5906, 0.373, 0.612]}, {"w": "be", "b": [0.3797, 0.5906, 0.3991, 0.612]}, {"w": "set", "b": [0.4058, 0.5906, 0.4287, 0.612]}, {"w": "to", "b": [0.4354, 0.5906, 0.4524, 0.612]}, {"w": "a", "b": [0.4591, 0.5906, 0.4683, 0.612]}, {"w": "large", "b": [0.475, 0.5906, 0.5157, 0.612]}, {"w": "value", "b": [0.5224, 0.5906, 0.5664, 0.612]}, {"w": "since", "b": [0.5731, 0.5906, 0.6154, 0.612]}, {"w": "training", "b": [0.6222, 0.5906, 0.6891, 0.612]}, {"w": "will", "b": [0.6958, 0.5906, 0.7262, 0.612]}, {"w": "stop", "b": [0.7329, 0.5906, 0.7685, 0.612]}, {"w": "automati‐", "b": [0.7752, 0.5906, 0.8571, 0.612]}, {"w": "cally", "b": [0.1429, 0.6096, 0.1809, 0.6311]}, {"w": "when", "b": [0.1872, 0.6096, 0.2329, 0.6311]}, {"w": "there", "b": [0.2391, 0.6096, 0.282, 0.6311]}, {"w": "is", "b": [0.2883, 0.6096, 0.3016, 0.6311]}, {"w": "no", "b": [0.3078, 0.6096, 0.3299, 0.6311]}, {"w": "more", "b": [0.3361, 0.6096, 0.3804, 0.6311]}, {"w": "progress.", "b": [0.3867, 0.6096, 0.4623, 0.6311]}, {"w": "Moreover,", "b": [0.4686, 0.6096, 0.5541, 0.6311]}, {"w": "there", "b": [0.5604, 0.6096, 0.6033, 0.6311]}, {"w": "is", "b": [0.6096, 0.6096, 0.6228, 0.6311]}, {"w": "no", "b": [0.6291, 0.6096, 0.6511, 0.6311]}, {"w": "need", "b": [0.6574, 0.6096, 0.6975, 0.6311]}, {"w": "to", "b": [0.7038, 0.6096, 0.7208, 0.6311]}, {"w": "restore", "b": [0.727, 0.6096, 0.7848, 0.6311]}, {"w": "the", "b": [0.7911, 0.6096, 0.8174, 0.6311]}, {"w": "best", "b": [0.8237, 0.6096, 0.8572, 0.6311]}, {"w": "model", "b": [0.1429, 0.6296, 0.1957, 0.651]}, {"w": "saved", "b": [0.2014, 0.6296, 0.2473, 0.651]}, {"w": "in", "b": [0.2531, 0.6296, 0.2701, 0.651]}, {"w": "this", "b": [0.2758, 0.6296, 0.3065, 0.651]}, {"w": "case", "b": [0.3123, 0.6296, 0.3467, 0.651]}, {"w": "since", "b": [0.3525, 0.6296, 0.3948, 0.651]}, {"w": "the", "b": [0.4005, 0.6296, 0.4268, 0.651]}, {"w": "EarlyStopping", "b": [0.4326, 0.6328, 0.5612, 0.6478]}, {"w": "callback", "b": [0.567, 0.6296, 0.6344, 0.651]}, {"w": "will", "b": [0.6401, 0.6296, 0.6705, 0.651]}, {"w": "keep", "b": [0.6763, 0.6296, 0.7152, 0.651]}, {"w": "track", "b": [0.721, 0.6296, 0.7633, 0.651]}, {"w": "of", "b": [0.7691, 0.6296, 0.7859, 0.651]}, {"w": "the", "b": [0.7916, 0.6296, 0.818, 0.651]}, {"w": "best", "b": [0.8237, 0.6296, 0.8571, 0.651]}, {"w": "weights", "b": [0.1429, 0.6486, 0.206, 0.67]}, {"w": "and", "b": [0.2108, 0.6486, 0.2423, 0.67]}, {"w": "restore", "b": [0.247, 0.6486, 0.3048, 0.67]}, {"w": "them", "b": [0.3096, 0.6486, 0.353, 0.67]}, {"w": "for", "b": [0.3577, 0.6486, 0.3822, 0.67]}, {"w": "us", "b": [0.3869, 0.6486, 0.4056, 0.67]}, {"w": "at", "b": [0.4104, 0.6486, 0.4255, 0.67]}, {"w": "the", "b": [0.4302, 0.6486, 0.4565, 0.67]}, {"w": "end", "b": [0.4613, 0.6486, 0.4925, 0.67]}, {"w": "of", "b": [0.4973, 0.6486, 0.514, 0.67]}, {"w": "training.", "b": [0.5188, 0.6486, 0.5905, 0.67]}]}, {"id": "b_6", "type": "paragraph", "text": "There are many other callbacks available in the keras.callbacks package. See https://keras.io/callbacks/.", "words": [{"w": "There", "b": [0.2714, 0.6914, 0.3166, 0.711]}, {"w": "are", "b": [0.3231, 0.6914, 0.3466, 0.711]}, {"w": "many", "b": [0.3531, 0.6914, 0.3958, 0.711]}, {"w": "other", "b": [0.4023, 0.6914, 0.4432, 0.711]}, {"w": "callbacks", "b": [0.4497, 0.6914, 0.5183, 0.711]}, {"w": "available", "b": [0.5248, 0.6914, 0.5909, 0.711]}, {"w": "in", "b": [0.5974, 0.6914, 0.6129, 0.711]}, {"w": "the", "b": [0.6194, 0.6914, 0.6435, 0.711]}, {"w": "keras.callbacks", "b": [0.65, 0.6943, 0.7857, 0.7081]}, {"w": "package.", "b": [0.2714, 0.7088, 0.337, 0.7284]}, {"w": "See", "b": [0.3413, 0.7088, 0.3665, 0.7284]}, {"w": "https://keras.io/callbacks/.", "b": [0.3708, 0.7086, 0.5643, 0.7284]}]}, {"id": "b_7", "type": "paragraph", "text": "If you need extra control, you can easily write your own custom callbacks. For exam‐ ple, the following custom callback will display the ratio between the validation loss and the training loss during training (e.g., to detect overfitting):", "words": [{"w": "If", "b": [0.1428, 0.7892, 0.1561, 0.8106]}, {"w": "you", "b": [0.1615, 0.7892, 0.1927, 0.8106]}, {"w": "need", "b": [0.1981, 0.7892, 0.2382, 0.8106]}, {"w": "extra", "b": [0.2436, 0.7892, 0.2855, 0.8106]}, {"w": "control,", "b": [0.2909, 0.7892, 0.356, 0.8106]}, {"w": "you", "b": [0.3614, 0.7892, 0.3927, 0.8106]}, {"w": "can", "b": [0.398, 0.7892, 0.4274, 0.8106]}, {"w": "easily", "b": [0.4328, 0.7892, 0.4788, 0.8106]}, {"w": "write", "b": [0.4842, 0.7892, 0.527, 0.8106]}, {"w": "your", "b": [0.5324, 0.7892, 0.5714, 0.8106]}, {"w": "own", "b": [0.5767, 0.7892, 0.613, 0.8106]}, {"w": "custom", "b": [0.6184, 0.7892, 0.68, 0.8106]}, {"w": "callbacks.", "b": [0.6853, 0.7892, 0.7651, 0.8106]}, {"w": "For", "b": [0.7705, 0.7892, 0.7994, 0.8106]}, {"w": "exam‐", "b": [0.8048, 0.7892, 0.8571, 0.8106]}, {"w": "ple,", "b": [0.1429, 0.8083, 0.1727, 0.8297]}, {"w": "the", "b": [0.1798, 0.8083, 0.2061, 0.8297]}, {"w": "following", "b": [0.2133, 0.8083, 0.2922, 0.8297]}, {"w": "custom", "b": [0.2994, 0.8083, 0.3609, 0.8297]}, {"w": "callback", "b": [0.3681, 0.8083, 0.4355, 0.8297]}, {"w": "will", "b": [0.4426, 0.8083, 0.473, 0.8297]}, {"w": "display", "b": [0.4801, 0.8083, 0.5389, 0.8297]}, {"w": "the", "b": [0.546, 0.8083, 0.5724, 0.8297]}, {"w": "ratio", "b": [0.5795, 0.8083, 0.6185, 0.8297]}, {"w": "between", "b": [0.6257, 0.8083, 0.6948, 0.8297]}, {"w": "the", "b": [0.702, 0.8083, 0.7283, 0.8297]}, {"w": "validation", "b": [0.7355, 0.8083, 0.8188, 0.8297]}, {"w": "loss", "b": [0.826, 0.8083, 0.8571, 0.8297]}, {"w": "and", "b": [0.1429, 0.8273, 0.1744, 0.8487]}, {"w": "the", "b": [0.1791, 0.8273, 0.2055, 0.8487]}, {"w": "training", "b": [0.2102, 0.8273, 0.2771, 0.8487]}, {"w": "loss", "b": [0.2819, 0.8273, 0.313, 0.8487]}, {"w": "during", "b": [0.3178, 0.8273, 0.3743, 0.8487]}, {"w": "training", "b": [0.379, 0.8273, 0.446, 0.8487]}, {"w": "(e.g.,", "b": [0.4507, 0.8273, 0.4908, 0.8487]}, {"w": "to", "b": [0.4955, 0.8273, 0.5125, 0.8487]}, {"w": "detect", "b": [0.5172, 0.8273, 0.5674, 0.8487]}, {"w": "overfitting):", "b": [0.5721, 0.8273, 0.6721, 0.8487]}]}, {"id": "b_8", "type": "paragraph", "text": "312 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "312", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4163, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4583, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 339, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "class PrintValTrainRatioCallback(keras.callbacks.Callback): def on_epoch_end(self, epoch, logs): print(\"\\nval/train: {:.2f}\".format(logs[\"val_loss\"] / logs[\"loss\"]))", "words": [{"w": "class", "b": [0.1766, 0.0829, 0.2188, 0.0958]}, {"w": "PrintValTrainRatioCallback(keras.callbacks.Callback):", "b": [0.2272, 0.0829, 0.6741, 0.0958]}, {"w": "def", "b": [0.2103, 0.0983, 0.2356, 0.1112]}, {"w": "on_epoch_end(self,", "b": [0.244, 0.0983, 0.3958, 0.1112]}, {"w": "epoch,", "b": [0.4043, 0.0983, 0.4549, 0.1112]}, {"w": "logs):", "b": [0.4633, 0.0983, 0.5139, 0.1112]}, {"w": "print(\"\\nval/train:", "b": [0.244, 0.1138, 0.4043, 0.1266]}, {"w": "{:.2f}\".format(logs[\"val_loss\"]", "b": [0.4127, 0.1138, 0.6741, 0.1266]}, {"w": "/", "b": [0.6825, 0.1138, 0.691, 0.1266]}, {"w": "logs[\"loss\"]))", "b": [0.6994, 0.1138, 0.8175, 0.1266]}]}, {"id": "b_1", "type": "paragraph", "text": "As you might expect, you can implement on_train_begin(), on_train_end(), on_epoch_begin(), on_epoch_begin(), on_batch_end() and on_batch_end(). Moreover, callbacks can also be used during evaluation and predictions, should you ever need them (e.g., for debugging). In this case, you should implement on_test_begin(), on_test_end(), on_test_batch_begin(), or on_test_batch_end() (called by evaluate()), or on_predict_begin(), on_pre dict_end(), on_predict_batch_begin(), or on_predict_batch_end() (called by predict()).", "words": [{"w": "As", "b": [0.1429, 0.1353, 0.1649, 0.1567]}, {"w": "you", "b": [0.1768, 0.1353, 0.2081, 0.1567]}, {"w": "might", "b": [0.22, 0.1353, 0.2695, 0.1567]}, {"w": "expect,", "b": [0.2815, 0.1353, 0.3399, 0.1567]}, {"w": "you", "b": [0.3518, 0.1353, 0.3831, 0.1567]}, {"w": "can", "b": [0.395, 0.1353, 0.4244, 0.1567]}, {"w": "implement", "b": [0.4363, 0.1353, 0.5269, 0.1567]}, {"w": "on_train_begin(),", "b": [0.5388, 0.1353, 0.7019, 0.1567]}, {"w": "on_train_end(),", "b": [0.7139, 0.1353, 0.8571, 0.1567]}, {"w": "on_epoch_begin(),", "b": [0.1429, 0.1552, 0.3059, 0.1766]}, {"w": "on_epoch_begin(),", "b": [0.3246, 0.1552, 0.4877, 0.1766]}, {"w": "on_batch_end()", "b": [0.5064, 0.1584, 0.6449, 0.1735]}, {"w": "and", "b": [0.6636, 0.1552, 0.6952, 0.1766]}, {"w": "on_batch_end().", "b": [0.7139, 0.1552, 0.8571, 0.1766]}, {"w": "Moreover,", "b": [0.1429, 0.1743, 0.2284, 0.1957]}, {"w": "callbacks", "b": [0.2349, 0.1743, 0.3099, 0.1957]}, {"w": "can", "b": [0.3164, 0.1743, 0.3458, 0.1957]}, {"w": "also", "b": [0.3523, 0.1743, 0.385, 0.1957]}, {"w": "be", "b": [0.3915, 0.1743, 0.411, 0.1957]}, {"w": "used", "b": [0.4175, 0.1743, 0.456, 0.1957]}, {"w": "during", "b": [0.4626, 0.1743, 0.5191, 0.1957]}, {"w": "evaluation", "b": [0.5256, 0.1743, 0.6123, 0.1957]}, {"w": "and", "b": [0.6188, 0.1743, 0.6504, 0.1957]}, {"w": "predictions,", "b": [0.6569, 0.1743, 0.7561, 0.1957]}, {"w": "should", "b": [0.7626, 0.1743, 0.8194, 0.1957]}, {"w": "you", "b": [0.8259, 0.1743, 0.8571, 0.1957]}, {"w": "ever", "b": [0.1428, 0.1933, 0.1779, 0.2147]}, {"w": "need", "b": [0.1929, 0.1933, 0.233, 0.2147]}, {"w": "them", "b": [0.2479, 0.1933, 0.2913, 0.2147]}, {"w": "(e.g.,", "b": [0.3063, 0.1933, 0.3464, 0.2147]}, {"w": "for", "b": [0.3613, 0.1933, 0.3858, 0.2147]}, {"w": "debugging).", "b": [0.4008, 0.1933, 0.5005, 0.2147]}, {"w": "In", "b": [0.5154, 0.1933, 0.5339, 0.2147]}, {"w": "this", "b": [0.5489, 0.1933, 0.5796, 0.2147]}, {"w": "case,", "b": [0.5945, 0.1933, 0.6337, 0.2147]}, {"w": "you", "b": [0.6487, 0.1933, 0.6799, 0.2147]}, {"w": "should", "b": [0.6949, 0.1933, 0.7516, 0.2147]}, {"w": "implement", "b": [0.7666, 0.1933, 0.8571, 0.2147]}, {"w": "on_test_begin(),", "b": [0.1429, 0.2133, 0.296, 0.2347]}, {"w": "on_test_end(),", "b": [0.3616, 0.2133, 0.495, 0.2347]}, {"w": "on_test_batch_begin(),", "b": [0.5606, 0.2133, 0.7732, 0.2347]}, {"w": "or", "b": [0.8388, 0.2133, 0.8571, 0.2347]}, {"w": "on_test_batch_end()", "b": [0.1429, 0.2364, 0.3309, 0.2515]}, {"w": "(called", "b": [0.3429, 0.2332, 0.3985, 0.2546]}, {"w": "by", "b": [0.4105, 0.2332, 0.4306, 0.2546]}, {"w": "evaluate()),", "b": [0.4426, 0.2332, 0.5536, 0.2546]}, {"w": "or", "b": [0.5656, 0.2332, 0.5839, 0.2546]}, {"w": "on_predict_begin(),", "b": [0.5959, 0.2332, 0.7788, 0.2546]}, {"w": "on_pre", "b": [0.7908, 0.2364, 0.8502, 0.2515]}, {"w": "dict_end(),", "b": [0.1429, 0.2532, 0.2466, 0.2746]}, {"w": "on_predict_batch_begin(),", "b": [0.2579, 0.2532, 0.5001, 0.2746]}, {"w": "or", "b": [0.5114, 0.2532, 0.5298, 0.2746]}, {"w": "on_predict_batch_end()", "b": [0.5411, 0.2563, 0.7588, 0.2714]}, {"w": "(called", "b": [0.7701, 0.2532, 0.8257, 0.2746]}, {"w": "by", "b": [0.837, 0.2532, 0.8572, 0.2746]}, {"w": "predict()).", "b": [0.1428, 0.2731, 0.2439, 0.2945]}]}, {"id": "b_2", "type": "paragraph", "text": "Now let’s take a look at one more tool you should definitely have in your toolbox when using tf.keras: TensorBoard.", "words": [{"w": "Now", "b": [0.1428, 0.3012, 0.1827, 0.3226]}, {"w": "let’s", "b": [0.1904, 0.3012, 0.2206, 0.3226]}, {"w": "take", "b": [0.2283, 0.3012, 0.263, 0.3226]}, {"w": "a", "b": [0.2707, 0.3012, 0.2799, 0.3226]}, {"w": "look", "b": [0.2876, 0.3012, 0.3244, 0.3226]}, {"w": "at", "b": [0.3321, 0.3012, 0.3472, 0.3226]}, {"w": "one", "b": [0.3549, 0.3012, 0.3858, 0.3226]}, {"w": "more", "b": [0.3935, 0.3012, 0.4378, 0.3226]}, {"w": "tool", "b": [0.4455, 0.3012, 0.4784, 0.3226]}, {"w": "you", "b": [0.4861, 0.3012, 0.5173, 0.3226]}, {"w": "should", "b": [0.525, 0.3012, 0.5817, 0.3226]}, {"w": "definitely", "b": [0.5894, 0.3012, 0.6681, 0.3226]}, {"w": "have", "b": [0.6758, 0.3012, 0.7142, 0.3226]}, {"w": "in", "b": [0.7219, 0.3012, 0.7388, 0.3226]}, {"w": "your", "b": [0.7465, 0.3012, 0.7855, 0.3226]}, {"w": "toolbox", "b": [0.7932, 0.3012, 0.8571, 0.3226]}, {"w": "when", "b": [0.1429, 0.3203, 0.1885, 0.3417]}, {"w": "using", "b": [0.1932, 0.3203, 0.2387, 0.3417]}, {"w": "tf.keras:", "b": [0.2434, 0.3203, 0.3091, 0.3417]}, {"w": "TensorBoard.", "b": [0.3139, 0.3203, 0.4268, 0.3417]}]}, {"id": "b_3", "type": "paragraph", "text": "Visualization Using TensorBoard", "words": [{"w": "Visualization", "b": [0.1429, 0.3545, 0.276, 0.383]}, {"w": "Using", "b": [0.2809, 0.3545, 0.3389, 0.383]}, {"w": "TensorBoard", "b": [0.3439, 0.3545, 0.4738, 0.383]}]}, {"id": "b_4", "type": "paragraph", "text": "TensorBoard is a great interactive visualization tool that you can use to view the learning curves during training, compare learning curves between multiple runs, vis‐ ualize the computation graph, analyze training statistics, view images generated by your model, visualize complex multidimensional data projected down to 3D and automatically clustered for you, and more! This tool is installed automatically when you install TensorFlow, so you already have it!", "words": [{"w": "TensorBoard", "b": [0.1429, 0.3889, 0.2511, 0.4103]}, {"w": "is", "b": [0.2598, 0.3889, 0.2731, 0.4103]}, {"w": "a", "b": [0.2818, 0.3889, 0.2909, 0.4103]}, {"w": "great", "b": [0.2997, 0.3889, 0.3411, 0.4103]}, {"w": "interactive", "b": [0.3499, 0.3889, 0.4378, 0.4103]}, {"w": "visualization", "b": [0.4465, 0.3889, 0.5519, 0.4103]}, {"w": "tool", "b": [0.5607, 0.3889, 0.5935, 0.4103]}, {"w": "that", "b": [0.6023, 0.3889, 0.6349, 0.4103]}, {"w": "you", "b": [0.6436, 0.3889, 0.6749, 0.4103]}, {"w": "can", "b": [0.6836, 0.3889, 0.713, 0.4103]}, {"w": "use", "b": [0.7217, 0.3889, 0.7493, 0.4103]}, {"w": "to", "b": [0.758, 0.3889, 0.775, 0.4103]}, {"w": "view", "b": [0.7837, 0.3889, 0.8221, 0.4103]}, {"w": "the", "b": [0.8308, 0.3889, 0.8571, 0.4103]}, {"w": "learning", "b": [0.1429, 0.408, 0.212, 0.4294]}, {"w": "curves", "b": [0.2174, 0.408, 0.2718, 0.4294]}, {"w": "during", "b": [0.2772, 0.408, 0.3337, 0.4294]}, {"w": "training,", "b": [0.3392, 0.408, 0.4108, 0.4294]}, {"w": "compare", "b": [0.4163, 0.408, 0.489, 0.4294]}, {"w": "learning", "b": [0.4945, 0.408, 0.5636, 0.4294]}, {"w": "curves", "b": [0.569, 0.408, 0.6234, 0.4294]}, {"w": "between", "b": [0.6288, 0.408, 0.698, 0.4294]}, {"w": "multiple", "b": [0.7034, 0.408, 0.7734, 0.4294]}, {"w": "runs,", "b": [0.7788, 0.408, 0.8214, 0.4294]}, {"w": "vis‐", "b": [0.8268, 0.408, 0.8571, 0.4294]}, {"w": "ualize", "b": [0.1428, 0.427, 0.1915, 0.4484]}, {"w": "the", "b": [0.1992, 0.427, 0.2255, 0.4484]}, {"w": "computation", "b": [0.2331, 0.427, 0.3403, 0.4484]}, {"w": "graph,", "b": [0.3479, 0.427, 0.401, 0.4484]}, {"w": "analyze", "b": [0.4086, 0.427, 0.4707, 0.4484]}, {"w": "training", "b": [0.4784, 0.427, 0.5453, 0.4484]}, {"w": "statistics,", "b": [0.553, 0.427, 0.6285, 0.4484]}, {"w": "view", "b": [0.6361, 0.427, 0.6745, 0.4484]}, {"w": "images", "b": [0.6821, 0.427, 0.7401, 0.4484]}, {"w": "generated", "b": [0.7478, 0.427, 0.8293, 0.4484]}, {"w": "by", "b": [0.837, 0.427, 0.8571, 0.4484]}, {"w": "your", "b": [0.1429, 0.4461, 0.1818, 0.4675]}, {"w": "model,", "b": [0.191, 0.4461, 0.2486, 0.4675]}, {"w": "visualize", "b": [0.2578, 0.4461, 0.3293, 0.4675]}, {"w": "complex", "b": [0.3385, 0.4461, 0.4095, 0.4675]}, {"w": "multidimensional", "b": [0.4187, 0.4461, 0.5672, 0.4675]}, {"w": "data", "b": [0.5764, 0.4461, 0.6116, 0.4675]}, {"w": "projected", "b": [0.6208, 0.4461, 0.6993, 0.4675]}, {"w": "down", "b": [0.7085, 0.4461, 0.7558, 0.4675]}, {"w": "to", "b": [0.7649, 0.4461, 0.7819, 0.4675]}, {"w": "3D", "b": [0.7911, 0.4461, 0.8164, 0.4675]}, {"w": "and", "b": [0.8256, 0.4461, 0.8571, 0.4675]}, {"w": "automatically", "b": [0.1429, 0.4651, 0.2555, 0.4865]}, {"w": "clustered", "b": [0.262, 0.4651, 0.3376, 0.4865]}, {"w": "for", "b": [0.3441, 0.4651, 0.3686, 0.4865]}, {"w": "you,", "b": [0.3752, 0.4651, 0.4112, 0.4865]}, {"w": "and", "b": [0.4177, 0.4651, 0.4493, 0.4865]}, {"w": "more!", "b": [0.4558, 0.4651, 0.5058, 0.4865]}, {"w": "This", "b": [0.5124, 0.4651, 0.5496, 0.4865]}, {"w": "tool", "b": [0.5561, 0.4651, 0.589, 0.4865]}, {"w": "is", "b": [0.5955, 0.4651, 0.6088, 0.4865]}, {"w": "installed", "b": [0.6153, 0.4651, 0.6858, 0.4865]}, {"w": "automatically", "b": [0.6924, 0.4651, 0.805, 0.4865]}, {"w": "when", "b": [0.8115, 0.4651, 0.8571, 0.4865]}, {"w": "you", "b": [0.1429, 0.4842, 0.1741, 0.5056]}, {"w": "install", "b": [0.1788, 0.4842, 0.2295, 0.5056]}, {"w": "TensorFlow,", "b": [0.2342, 0.4842, 0.3357, 0.5056]}, {"w": "so", "b": [0.3404, 0.4842, 0.3587, 0.5056]}, {"w": "you", "b": [0.3634, 0.4842, 0.3947, 0.5056]}, {"w": "already", "b": [0.3994, 0.4842, 0.4601, 0.5056]}, {"w": "have", "b": [0.4649, 0.4842, 0.5032, 0.5056]}, {"w": "it!", "b": [0.508, 0.4842, 0.5257, 0.5056]}]}, {"id": "b_5", "type": "paragraph", "text": "To use it, you must modify your program so that it outputs the data you want to visu‐ alize to special binary log files called event files. Each binary data record is called a summary. The TensorBoard server will monitor the log directory, and it will automat‐ ically pick up the changes and update the visualizations: this allows you to visualize live data (with a short delay), such as the learning curves during training. In general, you want to point the TensorBoard server to a root log directory, and configure your program so that it writes to a different subdirectory every time it runs. This way, the same TensorBoard server instance will allow you to visualize and compare data from multiple runs of your program, without getting everything mixed up.", "words": [{"w": "To", "b": [0.1429, 0.5123, 0.1643, 0.5337]}, {"w": "use", "b": [0.1693, 0.5123, 0.1968, 0.5337]}, {"w": "it,", "b": [0.2018, 0.5123, 0.2185, 0.5337]}, {"w": "you", "b": [0.2235, 0.5123, 0.2547, 0.5337]}, {"w": "must", "b": [0.2597, 0.5123, 0.3014, 0.5337]}, {"w": "modify", "b": [0.3064, 0.5123, 0.3667, 0.5337]}, {"w": "your", "b": [0.3717, 0.5123, 0.4107, 0.5337]}, {"w": "program", "b": [0.4157, 0.5123, 0.4886, 0.5337]}, {"w": "so", "b": [0.4936, 0.5123, 0.5119, 0.5337]}, {"w": "that", "b": [0.5169, 0.5123, 0.5494, 0.5337]}, {"w": "it", "b": [0.5544, 0.5123, 0.5664, 0.5337]}, {"w": "outputs", "b": [0.5713, 0.5123, 0.6353, 0.5337]}, {"w": "the", "b": [0.6403, 0.5123, 0.6667, 0.5337]}, {"w": "data", "b": [0.6716, 0.5123, 0.7069, 0.5337]}, {"w": "you", "b": [0.7119, 0.5123, 0.7431, 0.5337]}, {"w": "want", "b": [0.7481, 0.5123, 0.7889, 0.5337]}, {"w": "to", "b": [0.7938, 0.5123, 0.8108, 0.5337]}, {"w": "visu‐", "b": [0.8158, 0.5123, 0.8571, 0.5337]}, {"w": "alize", "b": [0.1429, 0.5313, 0.1805, 0.5527]}, {"w": "to", "b": [0.1875, 0.5313, 0.2045, 0.5527]}, {"w": "special", "b": [0.2115, 0.5313, 0.2678, 0.5527]}, {"w": "binary", "b": [0.2748, 0.5313, 0.3294, 0.5527]}, {"w": "log", "b": [0.3365, 0.5313, 0.3621, 0.5527]}, {"w": "files", "b": [0.3692, 0.5313, 0.4027, 0.5527]}, {"w": "called", "b": [0.4097, 0.5313, 0.4581, 0.5527]}, {"w": "event", "b": [0.4651, 0.5311, 0.5081, 0.5527]}, {"w": "files.", "b": [0.5152, 0.5311, 0.5516, 0.5527]}, {"w": "Each", "b": [0.5586, 0.5313, 0.5995, 0.5527]}, {"w": "binary", "b": [0.6066, 0.5313, 0.6612, 0.5527]}, {"w": "data", "b": [0.6682, 0.5313, 0.7035, 0.5527]}, {"w": "record", "b": [0.7105, 0.5313, 0.7653, 0.5527]}, {"w": "is", "b": [0.7723, 0.5313, 0.7856, 0.5527]}, {"w": "called", "b": [0.7926, 0.5313, 0.841, 0.5527]}, {"w": "a", "b": [0.848, 0.5313, 0.8572, 0.5527]}, {"w": "summary.", "b": [0.1429, 0.5502, 0.2247, 0.5718]}, {"w": "The", "b": [0.2295, 0.5504, 0.2624, 0.5718]}, {"w": "TensorBoard", "b": [0.2672, 0.5504, 0.3754, 0.5718]}, {"w": "server", "b": [0.3803, 0.5504, 0.4314, 0.5718]}, {"w": "will", "b": [0.4362, 0.5504, 0.4666, 0.5718]}, {"w": "monitor", "b": [0.4715, 0.5504, 0.5408, 0.5718]}, {"w": "the", "b": [0.5457, 0.5504, 0.572, 0.5718]}, {"w": "log", "b": [0.5769, 0.5504, 0.6025, 0.5718]}, {"w": "directory,", "b": [0.6074, 0.5504, 0.6875, 0.5718]}, {"w": "and", "b": [0.6923, 0.5504, 0.7239, 0.5718]}, {"w": "it", "b": [0.7287, 0.5504, 0.7407, 0.5718]}, {"w": "will", "b": [0.7455, 0.5504, 0.7759, 0.5718]}, {"w": "automat‐", "b": [0.7808, 0.5504, 0.8571, 0.5718]}, {"w": "ically", "b": [0.1429, 0.5694, 0.1865, 0.5908]}, {"w": "pick", "b": [0.193, 0.5694, 0.2287, 0.5908]}, {"w": "up", "b": [0.2352, 0.5694, 0.2571, 0.5908]}, {"w": "the", "b": [0.2637, 0.5694, 0.29, 0.5908]}, {"w": "changes", "b": [0.2965, 0.5694, 0.3632, 0.5908]}, {"w": "and", "b": [0.3697, 0.5694, 0.4013, 0.5908]}, {"w": "update", "b": [0.4078, 0.5694, 0.4647, 0.5908]}, {"w": "the", "b": [0.4712, 0.5694, 0.4976, 0.5908]}, {"w": "visualizations:", "b": [0.5041, 0.5694, 0.6219, 0.5908]}, {"w": "this", "b": [0.6284, 0.5694, 0.6591, 0.5908]}, {"w": "allows", "b": [0.6656, 0.5694, 0.7178, 0.5908]}, {"w": "you", "b": [0.7243, 0.5694, 0.7556, 0.5908]}, {"w": "to", "b": [0.7621, 0.5694, 0.7791, 0.5908]}, {"w": "visualize", "b": [0.7856, 0.5694, 0.8571, 0.5908]}, {"w": "live", "b": [0.1428, 0.5885, 0.1722, 0.6099]}, {"w": "data", "b": [0.1779, 0.5885, 0.2131, 0.6099]}, {"w": "(with", "b": [0.2188, 0.5885, 0.2633, 0.6099]}, {"w": "a", "b": [0.269, 0.5885, 0.2782, 0.6099]}, {"w": "short", "b": [0.2838, 0.5885, 0.3273, 0.6099]}, {"w": "delay),", "b": [0.333, 0.5885, 0.3884, 0.6099]}, {"w": "such", "b": [0.3941, 0.5885, 0.4327, 0.6099]}, {"w": "as", "b": [0.4384, 0.5885, 0.4552, 0.6099]}, {"w": "the", "b": [0.4608, 0.5885, 0.4872, 0.6099]}, {"w": "learning", "b": [0.4928, 0.5885, 0.562, 0.6099]}, {"w": "curves", "b": [0.5676, 0.5885, 0.622, 0.6099]}, {"w": "during", "b": [0.6277, 0.5885, 0.6842, 0.6099]}, {"w": "training.", "b": [0.6899, 0.5885, 0.7615, 0.6099]}, {"w": "In", "b": [0.7672, 0.5885, 0.7857, 0.6099]}, {"w": "general,", "b": [0.7914, 0.5885, 0.8571, 0.6099]}, {"w": "you", "b": [0.1429, 0.6075, 0.1741, 0.6289]}, {"w": "want", "b": [0.1796, 0.6075, 0.2204, 0.6289]}, {"w": "to", "b": [0.226, 0.6075, 0.2429, 0.6289]}, {"w": "point", "b": [0.2485, 0.6075, 0.2929, 0.6289]}, {"w": "the", "b": [0.2985, 0.6075, 0.3248, 0.6289]}, {"w": "TensorBoard", "b": [0.3304, 0.6075, 0.4386, 0.6289]}, {"w": "server", "b": [0.4441, 0.6075, 0.4952, 0.6289]}, {"w": "to", "b": [0.5007, 0.6075, 0.5177, 0.6289]}, {"w": "a", "b": [0.5232, 0.6075, 0.5324, 0.6289]}, {"w": "root", "b": [0.5379, 0.6075, 0.5732, 0.6289]}, {"w": "log", "b": [0.5788, 0.6075, 0.6044, 0.6289]}, {"w": "directory,", "b": [0.61, 0.6075, 0.69, 0.6289]}, {"w": "and", "b": [0.6956, 0.6075, 0.7271, 0.6289]}, {"w": "configure", "b": [0.7327, 0.6075, 0.8126, 0.6289]}, {"w": "your", "b": [0.8182, 0.6075, 0.8572, 0.6289]}, {"w": "program", "b": [0.1429, 0.6266, 0.2158, 0.648]}, {"w": "so", "b": [0.2216, 0.6266, 0.2399, 0.648]}, {"w": "that", "b": [0.2457, 0.6266, 0.2783, 0.648]}, {"w": "it", "b": [0.2841, 0.6266, 0.296, 0.648]}, {"w": "writes", "b": [0.3018, 0.6266, 0.3523, 0.648]}, {"w": "to", "b": [0.3581, 0.6266, 0.3751, 0.648]}, {"w": "a", "b": [0.3809, 0.6266, 0.39, 0.648]}, {"w": "different", "b": [0.3958, 0.6266, 0.4675, 0.648]}, {"w": "subdirectory", "b": [0.4733, 0.6266, 0.5795, 0.648]}, {"w": "every", "b": [0.5853, 0.6266, 0.6305, 0.648]}, {"w": "time", "b": [0.6364, 0.6266, 0.6742, 0.648]}, {"w": "it", "b": [0.68, 0.6266, 0.692, 0.648]}, {"w": "runs.", "b": [0.6978, 0.6266, 0.7403, 0.648]}, {"w": "This", "b": [0.7462, 0.6266, 0.7834, 0.648]}, {"w": "way,", "b": [0.7892, 0.6266, 0.825, 0.648]}, {"w": "the", "b": [0.8308, 0.6266, 0.8571, 0.648]}, {"w": "same", "b": [0.1429, 0.6456, 0.1856, 0.667]}, {"w": "TensorBoard", "b": [0.1912, 0.6456, 0.2994, 0.667]}, {"w": "server", "b": [0.305, 0.6456, 0.3561, 0.667]}, {"w": "instance", "b": [0.3617, 0.6456, 0.4308, 0.667]}, {"w": "will", "b": [0.4364, 0.6456, 0.4668, 0.667]}, {"w": "allow", "b": [0.4724, 0.6456, 0.517, 0.667]}, {"w": "you", "b": [0.5226, 0.6456, 0.5539, 0.667]}, {"w": "to", "b": [0.5595, 0.6456, 0.5765, 0.667]}, {"w": "visualize", "b": [0.5821, 0.6456, 0.6536, 0.667]}, {"w": "and", "b": [0.6592, 0.6456, 0.6907, 0.667]}, {"w": "compare", "b": [0.6964, 0.6456, 0.7691, 0.667]}, {"w": "data", "b": [0.7747, 0.6456, 0.81, 0.667]}, {"w": "from", "b": [0.8156, 0.6456, 0.8571, 0.667]}, {"w": "multiple", "b": [0.1428, 0.6647, 0.2128, 0.6861]}, {"w": "runs", "b": [0.2176, 0.6647, 0.2554, 0.6861]}, {"w": "of", "b": [0.2601, 0.6647, 0.2769, 0.6861]}, {"w": "your", "b": [0.2816, 0.6647, 0.3206, 0.6861]}, {"w": "program,", "b": [0.3253, 0.6647, 0.4031, 0.6861]}, {"w": "without", "b": [0.4078, 0.6647, 0.4732, 0.6861]}, {"w": "getting", "b": [0.4779, 0.6647, 0.5359, 0.6861]}, {"w": "everything", "b": [0.5407, 0.6647, 0.6301, 0.6861]}, {"w": "mixed", "b": [0.6348, 0.6647, 0.6872, 0.6861]}, {"w": "up.", "b": [0.6919, 0.6647, 0.718, 0.6861]}]}, {"id": "b_6", "type": "paragraph", "text": "So let’s start by defining the root log directory we will use for our TensorBoard logs, plus a small function that will generate a subdirectory path based on the current date and time, so that it is different at every run. You may want to include extra informa‐ tion in the log directory name, such as hyperparameter values that you are testing, to make it easier to know what you are looking at in TensorBoard:", "words": [{"w": "So", "b": [0.1428, 0.6928, 0.1633, 0.7142]}, {"w": "let’s", "b": [0.1694, 0.6928, 0.1996, 0.7142]}, {"w": "start", "b": [0.2057, 0.6928, 0.2429, 0.7142]}, {"w": "by", "b": [0.249, 0.6928, 0.2691, 0.7142]}, {"w": "defining", "b": [0.2752, 0.6928, 0.3449, 0.7142]}, {"w": "the", "b": [0.351, 0.6928, 0.3773, 0.7142]}, {"w": "root", "b": [0.3834, 0.6928, 0.4187, 0.7142]}, {"w": "log", "b": [0.4248, 0.6928, 0.4505, 0.7142]}, {"w": "directory", "b": [0.4565, 0.6928, 0.5334, 0.7142]}, {"w": "we", "b": [0.5394, 0.6928, 0.5626, 0.7142]}, {"w": "will", "b": [0.5686, 0.6928, 0.599, 0.7142]}, {"w": "use", "b": [0.6051, 0.6928, 0.6327, 0.7142]}, {"w": "for", "b": [0.6387, 0.6928, 0.6632, 0.7142]}, {"w": "our", "b": [0.6693, 0.6928, 0.6987, 0.7142]}, {"w": "TensorBoard", "b": [0.7048, 0.6928, 0.813, 0.7142]}, {"w": "logs,", "b": [0.8191, 0.6928, 0.8571, 0.7142]}, {"w": "plus", "b": [0.1429, 0.7118, 0.1778, 0.7332]}, {"w": "a", "b": [0.1832, 0.7118, 0.1924, 0.7332]}, {"w": "small", "b": [0.1978, 0.7118, 0.2422, 0.7332]}, {"w": "function", "b": [0.2477, 0.7118, 0.3191, 0.7332]}, {"w": "that", "b": [0.3245, 0.7118, 0.3571, 0.7332]}, {"w": "will", "b": [0.3626, 0.7118, 0.393, 0.7332]}, {"w": "generate", "b": [0.3984, 0.7118, 0.469, 0.7332]}, {"w": "a", "b": [0.4744, 0.7118, 0.4836, 0.7332]}, {"w": "subdirectory", "b": [0.489, 0.7118, 0.5952, 0.7332]}, {"w": "path", "b": [0.6006, 0.7118, 0.6378, 0.7332]}, {"w": "based", "b": [0.6432, 0.7118, 0.6905, 0.7332]}, {"w": "on", "b": [0.6959, 0.7118, 0.7179, 0.7332]}, {"w": "the", "b": [0.7234, 0.7118, 0.7497, 0.7332]}, {"w": "current", "b": [0.7552, 0.7118, 0.8167, 0.7332]}, {"w": "date", "b": [0.8222, 0.7118, 0.8571, 0.7332]}, {"w": "and", "b": [0.1429, 0.7309, 0.1744, 0.7523]}, {"w": "time,", "b": [0.1802, 0.7309, 0.2228, 0.7523]}, {"w": "so", "b": [0.2286, 0.7309, 0.2468, 0.7523]}, {"w": "that", "b": [0.2526, 0.7309, 0.2852, 0.7523]}, {"w": "it", "b": [0.291, 0.7309, 0.3029, 0.7523]}, {"w": "is", "b": [0.3087, 0.7309, 0.322, 0.7523]}, {"w": "different", "b": [0.3277, 0.7309, 0.3995, 0.7523]}, {"w": "at", "b": [0.4052, 0.7309, 0.4203, 0.7523]}, {"w": "every", "b": [0.4261, 0.7309, 0.4714, 0.7523]}, {"w": "run.", "b": [0.4772, 0.7309, 0.5121, 0.7523]}, {"w": "You", "b": [0.5179, 0.7309, 0.5503, 0.7523]}, {"w": "may", "b": [0.556, 0.7309, 0.5914, 0.7523]}, {"w": "want", "b": [0.5972, 0.7309, 0.638, 0.7523]}, {"w": "to", "b": [0.6438, 0.7309, 0.6608, 0.7523]}, {"w": "include", "b": [0.6665, 0.7309, 0.7285, 0.7523]}, {"w": "extra", "b": [0.7343, 0.7309, 0.7762, 0.7523]}, {"w": "informa‐", "b": [0.782, 0.7309, 0.8571, 0.7523]}, {"w": "tion", "b": [0.1428, 0.7499, 0.1768, 0.7713]}, {"w": "in", "b": [0.1822, 0.7499, 0.1992, 0.7713]}, {"w": "the", "b": [0.2046, 0.7499, 0.2309, 0.7713]}, {"w": "log", "b": [0.2363, 0.7499, 0.2619, 0.7713]}, {"w": "directory", "b": [0.2673, 0.7499, 0.3442, 0.7713]}, {"w": "name,", "b": [0.3496, 0.7499, 0.4008, 0.7713]}, {"w": "such", "b": [0.4062, 0.7499, 0.4448, 0.7713]}, {"w": "as", "b": [0.4502, 0.7499, 0.467, 0.7713]}, {"w": "hyperparameter", "b": [0.4724, 0.7499, 0.6059, 0.7713]}, {"w": "values", "b": [0.6113, 0.7499, 0.6629, 0.7713]}, {"w": "that", "b": [0.6683, 0.7499, 0.7009, 0.7713]}, {"w": "you", "b": [0.7063, 0.7499, 0.7376, 0.7713]}, {"w": "are", "b": [0.743, 0.7499, 0.7687, 0.7713]}, {"w": "testing,", "b": [0.7741, 0.7499, 0.8348, 0.7713]}, {"w": "to", "b": [0.8402, 0.7499, 0.8571, 0.7713]}, {"w": "make", "b": [0.1429, 0.769, 0.1883, 0.7904]}, {"w": "it", "b": [0.193, 0.769, 0.2049, 0.7904]}, {"w": "easier", "b": [0.2097, 0.769, 0.2575, 0.7904]}, {"w": "to", "b": [0.2622, 0.769, 0.2792, 0.7904]}, {"w": "know", "b": [0.2839, 0.769, 0.3305, 0.7904]}, {"w": "what", "b": [0.3353, 0.769, 0.3758, 0.7904]}, {"w": "you", "b": [0.3805, 0.769, 0.4117, 0.7904]}, {"w": "are", "b": [0.4165, 0.769, 0.4422, 0.7904]}, {"w": "looking", "b": [0.4469, 0.769, 0.5105, 0.7904]}, {"w": "at", "b": [0.5152, 0.769, 0.5303, 0.7904]}, {"w": "in", "b": [0.5351, 0.769, 0.5521, 0.7904]}, {"w": "TensorBoard:", "b": [0.5568, 0.769, 0.6698, 0.7904]}]}, {"id": "b_7", "type": "equation", "text": "root_logdir = os.path.join(os.curdir, \"my_logs\")", "words": [{"w": "root_logdir", "b": [0.1766, 0.8009, 0.2694, 0.8138]}, {"w": "=", "b": [0.2778, 0.8009, 0.2862, 0.8138]}, {"w": "os.path.join(os.curdir,", "b": [0.2946, 0.8009, 0.4886, 0.8138]}, {"w": "\"my_logs\")", "b": [0.497, 0.8009, 0.5814, 0.8138]}]}, {"id": "b_8", "type": "paragraph", "text": "def get_run_logdir(): import time run_id = time.strftime(\"run_%Y_%m_%d-%H_%M_%S\") return os.path.join(root_logdir, run_id)", "words": [{"w": "def", "b": [0.1766, 0.8318, 0.2019, 0.8446]}, {"w": "get_run_logdir():", "b": [0.2103, 0.8318, 0.3537, 0.8446]}, {"w": "import", "b": [0.2103, 0.8472, 0.2609, 0.86]}, {"w": "time", "b": [0.2694, 0.8472, 0.3031, 0.86]}, {"w": "run_id", "b": [0.2103, 0.8626, 0.2609, 0.8755]}, {"w": "=", "b": [0.2694, 0.8626, 0.2778, 0.8755]}, {"w": "time.strftime(\"run_%Y_%m_%d-%H_%M_%S\")", "b": [0.2862, 0.8626, 0.6067, 0.8755]}, {"w": "return", "b": [0.2103, 0.878, 0.2609, 0.8909]}, {"w": "os.path.join(root_logdir,", "b": [0.2694, 0.878, 0.4802, 0.8909]}, {"w": "run_id)", "b": [0.4886, 0.878, 0.5476, 0.8909]}]}, {"id": "b_9", "type": "paragraph", "text": "Implementing MLPs with Keras | 313", "words": [{"w": "Implementing", "b": [0.6126, 0.9225, 0.6972, 0.9388]}, {"w": "MLPs", "b": [0.7001, 0.9225, 0.7308, 0.9388]}, {"w": "with", "b": [0.7336, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "313", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 340, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "run_logdir = get_run_logdir() # e.g., './my_logs/run_2019_01_16-11_28_43'", "words": [{"w": "run_logdir", "b": [0.1766, 0.0983, 0.2609, 0.1112]}, {"w": "=", "b": [0.2693, 0.0983, 0.2778, 0.1112]}, {"w": "get_run_logdir()", "b": [0.2862, 0.0983, 0.4211, 0.1112]}, {"w": "#", "b": [0.4296, 0.0983, 0.438, 0.1112]}, {"w": "e.g.,", "b": [0.4464, 0.0983, 0.4886, 0.1112]}, {"w": "'./my_logs/run_2019_01_16-11_28_43'", "b": [0.497, 0.0983, 0.7922, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "Next, the good news is that Keras provides a nice TensorBoard callback:", "words": [{"w": "Next,", "b": [0.1429, 0.1199, 0.1876, 0.1413]}, {"w": "the", "b": [0.1923, 0.1199, 0.2187, 0.1413]}, {"w": "good", "b": [0.2234, 0.1199, 0.2654, 0.1413]}, {"w": "news", "b": [0.2701, 0.1199, 0.3123, 0.1413]}, {"w": "is", "b": [0.317, 0.1199, 0.3302, 0.1413]}, {"w": "that", "b": [0.335, 0.1199, 0.3676, 0.1413]}, {"w": "Keras", "b": [0.3723, 0.1199, 0.4192, 0.1413]}, {"w": "provides", "b": [0.4239, 0.1199, 0.4959, 0.1413]}, {"w": "a", "b": [0.5006, 0.1199, 0.5098, 0.1413]}, {"w": "nice", "b": [0.5145, 0.1199, 0.5492, 0.1413]}, {"w": "TensorBoard", "b": [0.5539, 0.123, 0.6627, 0.1381]}, {"w": "callback:", "b": [0.6675, 0.1199, 0.7396, 0.1413]}]}, {"id": "b_2", "type": "paragraph", "text": "[...] # Build and compile your model tensorboard_cb = keras.callbacks.TensorBoard(run_logdir) history = model.fit(X_train, y_train, epochs=30, validation_data=(X_valid, y_valid), callbacks=[tensorboard_cb])", "words": [{"w": "[...]", "b": [0.1766, 0.1518, 0.2188, 0.1647]}, {"w": "#", "b": [0.2272, 0.1518, 0.2356, 0.1647]}, {"w": "Build", "b": [0.2441, 0.1518, 0.2862, 0.1647]}, {"w": "and", "b": [0.2946, 0.1518, 0.3199, 0.1647]}, {"w": "compile", "b": [0.3284, 0.1518, 0.3874, 0.1647]}, {"w": "your", "b": [0.3958, 0.1518, 0.4296, 0.1647]}, {"w": "model", "b": [0.438, 0.1518, 0.4802, 0.1647]}, {"w": "tensorboard_cb", "b": [0.1766, 0.1673, 0.2946, 0.1801]}, {"w": "=", "b": [0.3031, 0.1673, 0.3115, 0.1801]}, {"w": "keras.callbacks.TensorBoard(run_logdir)", "b": [0.3199, 0.1673, 0.6488, 0.1801]}, {"w": "history", "b": [0.1766, 0.1827, 0.2356, 0.1955]}, {"w": "=", "b": [0.2441, 0.1827, 0.2525, 0.1955]}, {"w": "model.fit(X_train,", "b": [0.2609, 0.1827, 0.4127, 0.1955]}, {"w": "y_train,", "b": [0.4211, 0.1827, 0.4886, 0.1955]}, {"w": "epochs=30,", "b": [0.497, 0.1827, 0.5814, 0.1955]}, {"w": "validation_data=(X_valid,", "b": [0.3452, 0.1981, 0.5561, 0.2109]}, {"w": "y_valid),", "b": [0.5645, 0.1981, 0.6404, 0.2109]}, {"w": "callbacks=[tensorboard_cb])", "b": [0.3452, 0.2135, 0.5729, 0.2264]}]}, {"id": "b_3", "type": "paragraph", "text": "And that’s all there is to it! It could hardly be easier to use. If you run this code, the TensorBoard callback will take care of creating the log directory for you (along with its parent directories if needed), and during training it will create event files and write summaries to them. After running the program a second time (perhaps changing some hyperparameter value), you will end up with a directory structure similar to this one:", "words": [{"w": "And", "b": [0.1429, 0.2342, 0.1797, 0.2556]}, {"w": "that’s", "b": [0.1859, 0.2342, 0.2283, 0.2556]}, {"w": "all", "b": [0.2345, 0.2342, 0.2542, 0.2556]}, {"w": "there", "b": [0.2605, 0.2342, 0.3034, 0.2556]}, {"w": "is", "b": [0.3097, 0.2342, 0.3229, 0.2556]}, {"w": "to", "b": [0.3292, 0.2342, 0.3461, 0.2556]}, {"w": "it!", "b": [0.3524, 0.2342, 0.3701, 0.2556]}, {"w": "It", "b": [0.3764, 0.2342, 0.389, 0.2556]}, {"w": "could", "b": [0.3953, 0.2342, 0.442, 0.2556]}, {"w": "hardly", "b": [0.4483, 0.2342, 0.5021, 0.2556]}, {"w": "be", "b": [0.5084, 0.2342, 0.5278, 0.2556]}, {"w": "easier", "b": [0.5341, 0.2342, 0.5819, 0.2556]}, {"w": "to", "b": [0.5882, 0.2342, 0.6052, 0.2556]}, {"w": "use.", "b": [0.6114, 0.2342, 0.6438, 0.2556]}, {"w": "If", "b": [0.65, 0.2342, 0.6633, 0.2556]}, {"w": "you", "b": [0.6696, 0.2342, 0.7008, 0.2556]}, {"w": "run", "b": [0.7071, 0.2342, 0.7373, 0.2556]}, {"w": "this", "b": [0.7435, 0.2342, 0.7742, 0.2556]}, {"w": "code,", "b": [0.7805, 0.2342, 0.8245, 0.2556]}, {"w": "the", "b": [0.8308, 0.2342, 0.8571, 0.2556]}, {"w": "TensorBoard", "b": [0.1429, 0.2573, 0.2517, 0.2724]}, {"w": "callback", "b": [0.2578, 0.2541, 0.3252, 0.2755]}, {"w": "will", "b": [0.3313, 0.2541, 0.3617, 0.2755]}, {"w": "take", "b": [0.3677, 0.2541, 0.4024, 0.2755]}, {"w": "care", "b": [0.4085, 0.2541, 0.4431, 0.2755]}, {"w": "of", "b": [0.4491, 0.2541, 0.4659, 0.2755]}, {"w": "creating", "b": [0.472, 0.2541, 0.5392, 0.2755]}, {"w": "the", "b": [0.5453, 0.2541, 0.5717, 0.2755]}, {"w": "log", "b": [0.5777, 0.2541, 0.6034, 0.2755]}, {"w": "directory", "b": [0.6095, 0.2541, 0.6863, 0.2755]}, {"w": "for", "b": [0.6924, 0.2541, 0.7169, 0.2755]}, {"w": "you", "b": [0.723, 0.2541, 0.7543, 0.2755]}, {"w": "(along", "b": [0.7603, 0.2541, 0.8137, 0.2755]}, {"w": "with", "b": [0.8198, 0.2541, 0.8572, 0.2755]}, {"w": "its", "b": [0.1429, 0.2731, 0.1624, 0.2946]}, {"w": "parent", "b": [0.1674, 0.2731, 0.2214, 0.2946]}, {"w": "directories", "b": [0.2263, 0.2731, 0.3151, 0.2946]}, {"w": "if", "b": [0.32, 0.2731, 0.3318, 0.2946]}, {"w": "needed),", "b": [0.3367, 0.2731, 0.4086, 0.2946]}, {"w": "and", "b": [0.4135, 0.2731, 0.4451, 0.2946]}, {"w": "during", "b": [0.45, 0.2731, 0.5065, 0.2946]}, {"w": "training", "b": [0.5115, 0.2731, 0.5784, 0.2946]}, {"w": "it", "b": [0.5833, 0.2731, 0.5953, 0.2946]}, {"w": "will", "b": [0.6002, 0.2731, 0.6306, 0.2946]}, {"w": "create", "b": [0.6355, 0.2731, 0.6849, 0.2946]}, {"w": "event", "b": [0.6898, 0.2731, 0.7345, 0.2946]}, {"w": "files", "b": [0.7394, 0.2731, 0.773, 0.2946]}, {"w": "and", "b": [0.7779, 0.2731, 0.8094, 0.2946]}, {"w": "write", "b": [0.8144, 0.2731, 0.8571, 0.2946]}, {"w": "summaries", "b": [0.1429, 0.2922, 0.2346, 0.3136]}, {"w": "to", "b": [0.2429, 0.2922, 0.2599, 0.3136]}, {"w": "them.", "b": [0.2681, 0.2922, 0.3163, 0.3136]}, {"w": "After", "b": [0.3245, 0.2922, 0.368, 0.3136]}, {"w": "running", "b": [0.3763, 0.2922, 0.4446, 0.3136]}, {"w": "the", "b": [0.4529, 0.2922, 0.4792, 0.3136]}, {"w": "program", "b": [0.4875, 0.2922, 0.5604, 0.3136]}, {"w": "a", "b": [0.5687, 0.2922, 0.5778, 0.3136]}, {"w": "second", "b": [0.5861, 0.2922, 0.6444, 0.3136]}, {"w": "time", "b": [0.6527, 0.2922, 0.6905, 0.3136]}, {"w": "(perhaps", "b": [0.6988, 0.2922, 0.7719, 0.3136]}, {"w": "changing", "b": [0.7802, 0.2922, 0.8571, 0.3136]}, {"w": "some", "b": [0.1428, 0.3112, 0.187, 0.3327]}, {"w": "hyperparameter", "b": [0.1947, 0.3112, 0.3282, 0.3327]}, {"w": "value),", "b": [0.3358, 0.3112, 0.3918, 0.3327]}, {"w": "you", "b": [0.3994, 0.3112, 0.4307, 0.3327]}, {"w": "will", "b": [0.4383, 0.3112, 0.4687, 0.3327]}, {"w": "end", "b": [0.4764, 0.3112, 0.5076, 0.3327]}, {"w": "up", "b": [0.5153, 0.3112, 0.5373, 0.3327]}, {"w": "with", "b": [0.5449, 0.3112, 0.5823, 0.3327]}, {"w": "a", "b": [0.5899, 0.3112, 0.5991, 0.3327]}, {"w": "directory", "b": [0.6067, 0.3112, 0.6836, 0.3327]}, {"w": "structure", "b": [0.6912, 0.3112, 0.7668, 0.3327]}, {"w": "similar", "b": [0.7745, 0.3112, 0.8325, 0.3327]}, {"w": "to", "b": [0.8402, 0.3112, 0.8571, 0.3327]}, {"w": "this", "b": [0.1429, 0.3303, 0.1736, 0.3517]}, {"w": "one:", "b": [0.1783, 0.3303, 0.2139, 0.3517]}]}, {"id": "b_4", "type": "paragraph", "text": "my_logs ├── run_2019_01_16-16_51_02 │ └── events.out.tfevents.1547628669.mycomputer.local.v2 └── run_2019_01_16-16_56_50 └── events.out.tfevents.1547629020.mycomputer.local.v2", "words": [{"w": "my_logs", "b": [0.1766, 0.3623, 0.2356, 0.3751]}, {"w": "├──", "b": [0.1766, 0.3777, 0.2019, 0.3905]}, {"w": "run_2019_01_16-16_51_02", "b": [0.2103, 0.3777, 0.4043, 0.3905]}, {"w": "│", "b": [0.1766, 0.3931, 0.185, 0.406]}, {"w": "└──", "b": [0.2103, 0.3931, 0.2356, 0.406]}, {"w": "events.out.tfevents.1547628669.mycomputer.local.v2", "b": [0.244, 0.3931, 0.6657, 0.406]}, {"w": "└──", "b": [0.1766, 0.4085, 0.2019, 0.4214]}, {"w": "run_2019_01_16-16_56_50", "b": [0.2103, 0.4085, 0.4043, 0.4214]}, {"w": "└──", "b": [0.2103, 0.4239, 0.2356, 0.4368]}, {"w": "events.out.tfevents.1547629020.mycomputer.local.v2", "b": [0.244, 0.4239, 0.6657, 0.4368]}]}, {"id": "b_5", "type": "paragraph", "text": "Next you need to start the TensorBoard server. If you installed TensorFlow within a virtualenv, you should activate it. Next, run the following command at the root of the project (or from anywhere else as long as you point to the appropriate log directory). If your shell cannot find the tensorboard script, then you must update your PATH environment variable so that it contains the directory in which the script was installed (alternatively, you can just replace tensorboard with python3 -m tensor board.main).", "words": [{"w": "Next", "b": [0.1429, 0.4446, 0.1829, 0.466]}, {"w": "you", "b": [0.1892, 0.4446, 0.2205, 0.466]}, {"w": "need", "b": [0.2269, 0.4446, 0.267, 0.466]}, {"w": "to", "b": [0.2733, 0.4446, 0.2903, 0.466]}, {"w": "start", "b": [0.2967, 0.4446, 0.3339, 0.466]}, {"w": "the", "b": [0.3403, 0.4446, 0.3666, 0.466]}, {"w": "TensorBoard", "b": [0.373, 0.4446, 0.4813, 0.466]}, {"w": "server.", "b": [0.4876, 0.4446, 0.5421, 0.466]}, {"w": "If", "b": [0.5485, 0.4446, 0.5618, 0.466]}, {"w": "you", "b": [0.5682, 0.4446, 0.5994, 0.466]}, {"w": "installed", "b": [0.6058, 0.4446, 0.6763, 0.466]}, {"w": "TensorFlow", "b": [0.6827, 0.4446, 0.7809, 0.466]}, {"w": "within", "b": [0.7873, 0.4446, 0.8416, 0.466]}, {"w": "a", "b": [0.848, 0.4446, 0.8571, 0.466]}, {"w": "virtualenv,", "b": [0.1429, 0.4636, 0.2303, 0.485]}, {"w": "you", "b": [0.2355, 0.4636, 0.2668, 0.485]}, {"w": "should", "b": [0.272, 0.4636, 0.3288, 0.485]}, {"w": "activate", "b": [0.334, 0.4636, 0.3975, 0.485]}, {"w": "it.", "b": [0.4028, 0.4636, 0.4194, 0.485]}, {"w": "Next,", "b": [0.4247, 0.4636, 0.4694, 0.485]}, {"w": "run", "b": [0.4747, 0.4636, 0.5049, 0.485]}, {"w": "the", "b": [0.5101, 0.4636, 0.5365, 0.485]}, {"w": "following", "b": [0.5417, 0.4636, 0.6207, 0.485]}, {"w": "command", "b": [0.6259, 0.4636, 0.711, 0.485]}, {"w": "at", "b": [0.7163, 0.4636, 0.7314, 0.485]}, {"w": "the", "b": [0.7366, 0.4636, 0.7629, 0.485]}, {"w": "root", "b": [0.7682, 0.4636, 0.8035, 0.485]}, {"w": "of", "b": [0.8088, 0.4636, 0.8256, 0.485]}, {"w": "the", "b": [0.8308, 0.4636, 0.8571, 0.485]}, {"w": "project", "b": [0.1428, 0.4827, 0.2015, 0.5041]}, {"w": "(or", "b": [0.2069, 0.4827, 0.2325, 0.5041]}, {"w": "from", "b": [0.2379, 0.4827, 0.2795, 0.5041]}, {"w": "anywhere", "b": [0.2849, 0.4827, 0.3654, 0.5041]}, {"w": "else", "b": [0.3708, 0.4827, 0.4015, 0.5041]}, {"w": "as", "b": [0.4069, 0.4827, 0.4237, 0.5041]}, {"w": "long", "b": [0.4291, 0.4827, 0.4662, 0.5041]}, {"w": "as", "b": [0.4716, 0.4827, 0.4884, 0.5041]}, {"w": "you", "b": [0.4939, 0.4827, 0.5251, 0.5041]}, {"w": "point", "b": [0.5306, 0.4827, 0.575, 0.5041]}, {"w": "to", "b": [0.5805, 0.4827, 0.5975, 0.5041]}, {"w": "the", "b": [0.6029, 0.4827, 0.6292, 0.5041]}, {"w": "appropriate", "b": [0.6347, 0.4827, 0.7318, 0.5041]}, {"w": "log", "b": [0.7372, 0.4827, 0.7629, 0.5041]}, {"w": "directory).", "b": [0.7683, 0.4827, 0.8571, 0.5041]}, {"w": "If", "b": [0.1429, 0.5026, 0.1561, 0.524]}, {"w": "your", "b": [0.1637, 0.5026, 0.2027, 0.524]}, {"w": "shell", "b": [0.2103, 0.5026, 0.2485, 0.524]}, {"w": "cannot", "b": [0.2561, 0.5026, 0.3138, 0.524]}, {"w": "find", "b": [0.3214, 0.5026, 0.3556, 0.524]}, {"w": "the", "b": [0.3632, 0.5026, 0.3895, 0.524]}, {"w": "tensorboard", "b": [0.3971, 0.5058, 0.5059, 0.5209]}, {"w": "script,", "b": [0.5135, 0.5026, 0.5653, 0.524]}, {"w": "then", "b": [0.5729, 0.5026, 0.6107, 0.524]}, {"w": "you", "b": [0.6183, 0.5026, 0.6495, 0.524]}, {"w": "must", "b": [0.6571, 0.5026, 0.6988, 0.524]}, {"w": "update", "b": [0.7064, 0.5026, 0.7634, 0.524]}, {"w": "your", "b": [0.771, 0.5026, 0.81, 0.524]}, {"w": "PATH", "b": [0.8176, 0.5058, 0.8572, 0.5209]}, {"w": "environment", "b": [0.1429, 0.5217, 0.2509, 0.5431]}, {"w": "variable", "b": [0.2618, 0.5217, 0.3278, 0.5431]}, {"w": "so", "b": [0.3387, 0.5217, 0.357, 0.5431]}, {"w": "that", "b": [0.368, 0.5217, 0.4006, 0.5431]}, {"w": "it", "b": [0.4115, 0.5217, 0.4234, 0.5431]}, {"w": "contains", "b": [0.4344, 0.5217, 0.505, 0.5431]}, {"w": "the", "b": [0.5159, 0.5217, 0.5422, 0.5431]}, {"w": "directory", "b": [0.5532, 0.5217, 0.63, 0.5431]}, {"w": "in", "b": [0.641, 0.5217, 0.658, 0.5431]}, {"w": "which", "b": [0.6689, 0.5217, 0.7198, 0.5431]}, {"w": "the", "b": [0.7308, 0.5217, 0.7571, 0.5431]}, {"w": "script", "b": [0.7681, 0.5217, 0.8151, 0.5431]}, {"w": "was", "b": [0.8261, 0.5217, 0.8571, 0.5431]}, {"w": "installed", "b": [0.1429, 0.5416, 0.2134, 0.563]}, {"w": "(alternatively,", "b": [0.2207, 0.5416, 0.3339, 0.563]}, {"w": "you", "b": [0.3412, 0.5416, 0.3724, 0.563]}, {"w": "can", "b": [0.3797, 0.5416, 0.409, 0.563]}, {"w": "just", "b": [0.4163, 0.5416, 0.4467, 0.563]}, {"w": "replace", "b": [0.454, 0.5416, 0.5136, 0.563]}, {"w": "tensorboard", "b": [0.5209, 0.5448, 0.6297, 0.5599]}, {"w": "with", "b": [0.637, 0.5416, 0.6743, 0.563]}, {"w": "python3", "b": [0.6816, 0.5448, 0.7509, 0.5599]}, {"w": "-m", "b": [0.7632, 0.5448, 0.783, 0.5599]}, {"w": "tensor", "b": [0.7953, 0.5448, 0.8547, 0.5599]}, {"w": "board.main).", "b": [0.1429, 0.5615, 0.2538, 0.583]}]}, {"id": "b_6", "type": "paragraph", "text": "$ tensorboard --logdir=./my_logs --port=6006 TensorBoard 2.0.0 at http://mycomputer.local:6006 (Press CTRL+C to quit)", "words": [{"w": "$", "b": [0.1766, 0.5935, 0.185, 0.6064]}, {"w": "tensorboard", "b": [0.1935, 0.5935, 0.2862, 0.6064]}, {"w": "--logdir=./my_logs", "b": [0.2946, 0.5935, 0.4464, 0.6064]}, {"w": "--port=6006", "b": [0.4549, 0.5935, 0.5476, 0.6064]}, {"w": "TensorBoard", "b": [0.1766, 0.6089, 0.2693, 0.6218]}, {"w": "2.0.0", "b": [0.2778, 0.6089, 0.3199, 0.6218]}, {"w": "at", "b": [0.3284, 0.6089, 0.3452, 0.6218]}, {"w": "http://mycomputer.local:6006", "b": [0.3537, 0.6089, 0.5898, 0.6218]}, {"w": "(Press", "b": [0.5982, 0.6089, 0.6488, 0.6218]}, {"w": "CTRL+C", "b": [0.6572, 0.6089, 0.7078, 0.6218]}, {"w": "to", "b": [0.7163, 0.6089, 0.7331, 0.6218]}, {"w": "quit)", "b": [0.7416, 0.6089, 0.7837, 0.6218]}]}, {"id": "b_7", "type": "paragraph", "text": "Finally, open up a web browser to http://localhost:6006. You should see TensorBoard’s web interface. Click on the SCALARS tab to view the learning curves (see Figure 10-16). Notice that the training loss went down nicely during both runs, but the second run went down much faster. Indeed, we used a larger learning rate by set‐ ting optimizer=keras.optimizers.SGD(lr=0.05) instead of optimizer=\"sgd\", which defaults to a learning rate of 0.001.", "words": [{"w": "Finally,", "b": [0.1429, 0.6296, 0.2033, 0.651]}, {"w": "open", "b": [0.2087, 0.6296, 0.2504, 0.651]}, {"w": "up", "b": [0.2558, 0.6296, 0.2777, 0.651]}, {"w": "a", "b": [0.2831, 0.6296, 0.2922, 0.651]}, {"w": "web", "b": [0.2975, 0.6296, 0.3312, 0.651]}, {"w": "browser", "b": [0.3365, 0.6296, 0.404, 0.651]}, {"w": "to", "b": [0.4093, 0.6296, 0.4263, 0.651]}, {"w": "http://localhost:6006.", "b": [0.4316, 0.6294, 0.6035, 0.651]}, {"w": "You", "b": [0.6088, 0.6296, 0.6411, 0.651]}, {"w": "should", "b": [0.6464, 0.6296, 0.7032, 0.651]}, {"w": "see", "b": [0.7085, 0.6296, 0.7338, 0.651]}, {"w": "TensorBoard’s", "b": [0.7391, 0.6296, 0.8571, 0.651]}, {"w": "web", "b": [0.1429, 0.6486, 0.1766, 0.67]}, {"w": "interface.", "b": [0.19, 0.6486, 0.2672, 0.67]}, {"w": "Click", "b": [0.2806, 0.6486, 0.3245, 0.67]}, {"w": "on", "b": [0.3379, 0.6486, 0.3599, 0.67]}, {"w": "the", "b": [0.3733, 0.6486, 0.3996, 0.67]}, {"w": "SCALARS", "b": [0.413, 0.6486, 0.4996, 0.67]}, {"w": "tab", "b": [0.513, 0.6486, 0.539, 0.67]}, {"w": "to", "b": [0.5524, 0.6486, 0.5694, 0.67]}, {"w": "view", "b": [0.5828, 0.6486, 0.6212, 0.67]}, {"w": "the", "b": [0.6346, 0.6486, 0.6609, 0.67]}, {"w": "learning", "b": [0.6743, 0.6486, 0.7434, 0.67]}, {"w": "curves", "b": [0.7568, 0.6486, 0.8112, 0.67]}, {"w": "(see", "b": [0.8246, 0.6486, 0.8571, 0.67]}, {"w": "Figure", "b": [0.1429, 0.6677, 0.1969, 0.6891]}, {"w": "10-16).", "b": [0.2035, 0.6677, 0.2628, 0.6891]}, {"w": "Notice", "b": [0.2694, 0.6677, 0.3246, 0.6891]}, {"w": "that", "b": [0.3312, 0.6677, 0.3638, 0.6891]}, {"w": "the", "b": [0.3704, 0.6677, 0.3967, 0.6891]}, {"w": "training", "b": [0.4033, 0.6677, 0.4702, 0.6891]}, {"w": "loss", "b": [0.4768, 0.6677, 0.508, 0.6891]}, {"w": "went", "b": [0.5146, 0.6677, 0.5551, 0.6891]}, {"w": "down", "b": [0.5617, 0.6677, 0.6089, 0.6891]}, {"w": "nicely", "b": [0.6155, 0.6677, 0.665, 0.6891]}, {"w": "during", "b": [0.6716, 0.6677, 0.7281, 0.6891]}, {"w": "both", "b": [0.7347, 0.6677, 0.7734, 0.6891]}, {"w": "runs,", "b": [0.78, 0.6677, 0.8226, 0.6891]}, {"w": "but", "b": [0.8292, 0.6677, 0.8572, 0.6891]}, {"w": "the", "b": [0.1429, 0.6867, 0.1692, 0.7081]}, {"w": "second", "b": [0.1746, 0.6867, 0.2329, 0.7081]}, {"w": "run", "b": [0.2383, 0.6867, 0.2685, 0.7081]}, {"w": "went", "b": [0.2739, 0.6867, 0.3144, 0.7081]}, {"w": "down", "b": [0.3198, 0.6867, 0.3671, 0.7081]}, {"w": "much", "b": [0.3725, 0.6867, 0.4202, 0.7081]}, {"w": "faster.", "b": [0.4256, 0.6867, 0.475, 0.7081]}, {"w": "Indeed,", "b": [0.4804, 0.6867, 0.5433, 0.7081]}, {"w": "we", "b": [0.5487, 0.6867, 0.5719, 0.7081]}, {"w": "used", "b": [0.5773, 0.6867, 0.6158, 0.7081]}, {"w": "a", "b": [0.6212, 0.6867, 0.6304, 0.7081]}, {"w": "larger", "b": [0.6358, 0.6867, 0.6843, 0.7081]}, {"w": "learning", "b": [0.6897, 0.6867, 0.7588, 0.7081]}, {"w": "rate", "b": [0.7642, 0.6867, 0.7959, 0.7081]}, {"w": "by", "b": [0.8013, 0.6867, 0.8215, 0.7081]}, {"w": "set‐", "b": [0.8269, 0.6867, 0.8571, 0.7081]}, {"w": "ting", "b": [0.1429, 0.7067, 0.1759, 0.7281]}, {"w": "optimizer=keras.optimizers.SGD(lr=0.05)", "b": [0.1923, 0.7098, 0.5782, 0.7249]}, {"w": "instead", "b": [0.5945, 0.7067, 0.6545, 0.7281]}, {"w": "of", "b": [0.6708, 0.7067, 0.6876, 0.7281]}, {"w": "optimizer=\"sgd\",", "b": [0.704, 0.7067, 0.8571, 0.7281]}, {"w": "which", "b": [0.1429, 0.7257, 0.1938, 0.7471]}, {"w": "defaults", "b": [0.1985, 0.7257, 0.2636, 0.7471]}, {"w": "to", "b": [0.2683, 0.7257, 0.2853, 0.7471]}, {"w": "a", "b": [0.2901, 0.7257, 0.2992, 0.7471]}, {"w": "learning", "b": [0.3039, 0.7257, 0.3731, 0.7471]}, {"w": "rate", "b": [0.3778, 0.7257, 0.4095, 0.7471]}, {"w": "of", "b": [0.4142, 0.7257, 0.431, 0.7471]}, {"w": "0.001.", "b": [0.4357, 0.7257, 0.4852, 0.7471]}]}, {"id": "b_8", "type": "paragraph", "text": "314 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "314", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4163, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4583, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 341, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 10-16. Visualizing Learning Curves with TensorBoard", "words": [{"w": "Figure", "b": [0.1429, 0.43, 0.1943, 0.4516]}, {"w": "10-16.", "b": [0.1991, 0.43, 0.2507, 0.4516]}, {"w": "Visualizing", "b": [0.2554, 0.43, 0.3463, 0.4516]}, {"w": "Learning", "b": [0.351, 0.43, 0.4238, 0.4516]}, {"w": "Curves", "b": [0.4286, 0.43, 0.4848, 0.4516]}, {"w": "with", "b": [0.4896, 0.43, 0.526, 0.4516]}, {"w": "TensorBoard", "b": [0.5308, 0.43, 0.6346, 0.4516]}]}, {"id": "b_1", "type": "paragraph", "text": "Unfortunately, at the time of writing, no other data is exported by the TensorBoard callback, but this issue will probably be fixed by the time you read these lines. In Ten‐ sorFlow 1, this callback exported the computation graph and many useful statistics: type help(keras.callbacks.TensorBoard) to see all the options.", "words": [{"w": "Unfortunately,", "b": [0.1429, 0.4683, 0.264, 0.4897]}, {"w": "at", "b": [0.2707, 0.4683, 0.2858, 0.4897]}, {"w": "the", "b": [0.2925, 0.4683, 0.3189, 0.4897]}, {"w": "time", "b": [0.3255, 0.4683, 0.3634, 0.4897]}, {"w": "of", "b": [0.3701, 0.4683, 0.3869, 0.4897]}, {"w": "writing,", "b": [0.3936, 0.4683, 0.459, 0.4897]}, {"w": "no", "b": [0.4657, 0.4683, 0.4877, 0.4897]}, {"w": "other", "b": [0.4944, 0.4683, 0.5391, 0.4897]}, {"w": "data", "b": [0.5457, 0.4683, 0.581, 0.4897]}, {"w": "is", "b": [0.5877, 0.4683, 0.6009, 0.4897]}, {"w": "exported", "b": [0.6076, 0.4683, 0.6818, 0.4897]}, {"w": "by", "b": [0.6884, 0.4683, 0.7086, 0.4897]}, {"w": "the", "b": [0.7153, 0.4683, 0.7416, 0.4897]}, {"w": "TensorBoard", "b": [0.7483, 0.4715, 0.8571, 0.4866]}, {"w": "callback,", "b": [0.1429, 0.4874, 0.215, 0.5088]}, {"w": "but", "b": [0.2201, 0.4874, 0.2481, 0.5088]}, {"w": "this", "b": [0.2531, 0.4874, 0.2839, 0.5088]}, {"w": "issue", "b": [0.2889, 0.4874, 0.3297, 0.5088]}, {"w": "will", "b": [0.3348, 0.4874, 0.3652, 0.5088]}, {"w": "probably", "b": [0.3703, 0.4874, 0.4447, 0.5088]}, {"w": "be", "b": [0.4498, 0.4874, 0.4692, 0.5088]}, {"w": "fixed", "b": [0.4743, 0.4874, 0.5158, 0.5088]}, {"w": "by", "b": [0.5208, 0.4874, 0.541, 0.5088]}, {"w": "the", "b": [0.5461, 0.4874, 0.5724, 0.5088]}, {"w": "time", "b": [0.5775, 0.4874, 0.6153, 0.5088]}, {"w": "you", "b": [0.6204, 0.4874, 0.6517, 0.5088]}, {"w": "read", "b": [0.6568, 0.4874, 0.6935, 0.5088]}, {"w": "these", "b": [0.6986, 0.4874, 0.7414, 0.5088]}, {"w": "lines.", "b": [0.7465, 0.4874, 0.79, 0.5088]}, {"w": "In", "b": [0.7951, 0.4874, 0.8136, 0.5088]}, {"w": "Ten‐", "b": [0.8187, 0.4874, 0.8571, 0.5088]}, {"w": "sorFlow", "b": [0.1429, 0.5064, 0.2101, 0.5278]}, {"w": "1,", "b": [0.2168, 0.5064, 0.2316, 0.5278]}, {"w": "this", "b": [0.2384, 0.5064, 0.2691, 0.5278]}, {"w": "callback", "b": [0.2759, 0.5064, 0.3432, 0.5278]}, {"w": "exported", "b": [0.35, 0.5064, 0.4242, 0.5278]}, {"w": "the", "b": [0.431, 0.5064, 0.4573, 0.5278]}, {"w": "computation", "b": [0.4641, 0.5064, 0.5712, 0.5278]}, {"w": "graph", "b": [0.578, 0.5064, 0.6263, 0.5278]}, {"w": "and", "b": [0.633, 0.5064, 0.6646, 0.5278]}, {"w": "many", "b": [0.6714, 0.5064, 0.7181, 0.5278]}, {"w": "useful", "b": [0.7248, 0.5064, 0.7749, 0.5278]}, {"w": "statistics:", "b": [0.7817, 0.5064, 0.8572, 0.5278]}, {"w": "type", "b": [0.1429, 0.5263, 0.1785, 0.5478]}, {"w": "help(keras.callbacks.TensorBoard)", "b": [0.1833, 0.5295, 0.5098, 0.5446]}, {"w": "to", "b": [0.5146, 0.5263, 0.5315, 0.5478]}, {"w": "see", "b": [0.5363, 0.5263, 0.5616, 0.5478]}, {"w": "all", "b": [0.5664, 0.5263, 0.586, 0.5478]}, {"w": "the", "b": [0.5908, 0.5263, 0.6171, 0.5478]}, {"w": "options.", "b": [0.6218, 0.5263, 0.6897, 0.5478]}]}, {"id": "b_2", "type": "paragraph", "text": "Let’s summarize what you learned so far in this chapter: we saw where neural nets came from, what an MLP is and how you can use it for classification and regression, how to build MLPs using tf.keras’s Sequential API, or more complex architectures using the Functional API or Model Subclassing, you learned how to save and restore a model, use callbacks for checkpointing, early stopping, and more, and finally how to use TensorBoard for visualization. You can already go ahead and use neural networks to tackle many problems! However, you may wonder how to choose the number of hidden layers, the number of neurons in the network, and all the other hyperparame‐ ters. Let’s look at this now.", "words": [{"w": "Let’s", "b": [0.1429, 0.5545, 0.179, 0.5759]}, {"w": "summarize", "b": [0.1863, 0.5545, 0.2792, 0.5759]}, {"w": "what", "b": [0.2865, 0.5545, 0.327, 0.5759]}, {"w": "you", "b": [0.3343, 0.5545, 0.3655, 0.5759]}, {"w": "learned", "b": [0.3728, 0.5545, 0.4351, 0.5759]}, {"w": "so", "b": [0.4424, 0.5545, 0.4606, 0.5759]}, {"w": "far", "b": [0.4679, 0.5545, 0.491, 0.5759]}, {"w": "in", "b": [0.4983, 0.5545, 0.5153, 0.5759]}, {"w": "this", "b": [0.5225, 0.5545, 0.5533, 0.5759]}, {"w": "chapter:", "b": [0.5605, 0.5545, 0.6283, 0.5759]}, {"w": "we", "b": [0.6356, 0.5545, 0.6587, 0.5759]}, {"w": "saw", "b": [0.666, 0.5545, 0.6967, 0.5759]}, {"w": "where", "b": [0.704, 0.5545, 0.7549, 0.5759]}, {"w": "neural", "b": [0.7621, 0.5545, 0.8156, 0.5759]}, {"w": "nets", "b": [0.8229, 0.5545, 0.8571, 0.5759]}, {"w": "came", "b": [0.1429, 0.5735, 0.1867, 0.5949]}, {"w": "from,", "b": [0.1925, 0.5735, 0.2388, 0.5949]}, {"w": "what", "b": [0.2446, 0.5735, 0.2851, 0.5949]}, {"w": "an", "b": [0.2909, 0.5735, 0.3114, 0.5949]}, {"w": "MLP", "b": [0.3172, 0.5735, 0.3587, 0.5949]}, {"w": "is", "b": [0.3645, 0.5735, 0.3777, 0.5949]}, {"w": "and", "b": [0.3835, 0.5735, 0.415, 0.5949]}, {"w": "how", "b": [0.4208, 0.5735, 0.4568, 0.5949]}, {"w": "you", "b": [0.4626, 0.5735, 0.4939, 0.5949]}, {"w": "can", "b": [0.4996, 0.5735, 0.529, 0.5949]}, {"w": "use", "b": [0.5348, 0.5735, 0.5623, 0.5949]}, {"w": "it", "b": [0.5681, 0.5735, 0.58, 0.5949]}, {"w": "for", "b": [0.5858, 0.5735, 0.6103, 0.5949]}, {"w": "classification", "b": [0.6161, 0.5735, 0.7235, 0.5949]}, {"w": "and", "b": [0.7293, 0.5735, 0.7608, 0.5949]}, {"w": "regression,", "b": [0.7666, 0.5735, 0.8571, 0.5949]}, {"w": "how", "b": [0.1428, 0.5926, 0.1789, 0.614]}, {"w": "to", "b": [0.1868, 0.5926, 0.2038, 0.614]}, {"w": "build", "b": [0.2117, 0.5926, 0.2552, 0.614]}, {"w": "MLPs", "b": [0.2631, 0.5926, 0.3117, 0.614]}, {"w": "using", "b": [0.3196, 0.5926, 0.365, 0.614]}, {"w": "tf.keras’s", "b": [0.3729, 0.5926, 0.4434, 0.614]}, {"w": "Sequential", "b": [0.4513, 0.5926, 0.5379, 0.614]}, {"w": "API,", "b": [0.5458, 0.5926, 0.5838, 0.614]}, {"w": "or", "b": [0.5917, 0.5926, 0.6101, 0.614]}, {"w": "more", "b": [0.618, 0.5926, 0.6623, 0.614]}, {"w": "complex", "b": [0.6702, 0.5926, 0.7412, 0.614]}, {"w": "architectures", "b": [0.7491, 0.5926, 0.8571, 0.614]}, {"w": "using", "b": [0.1429, 0.6125, 0.1883, 0.6339]}, {"w": "the", "b": [0.1933, 0.6125, 0.2196, 0.6339]}, {"w": "Functional", "b": [0.2246, 0.6125, 0.3149, 0.6339]}, {"w": "API", "b": [0.3198, 0.6125, 0.3531, 0.6339]}, {"w": "or", "b": [0.3581, 0.6125, 0.3764, 0.6339]}, {"w": "Model", "b": [0.3814, 0.6157, 0.4309, 0.6308]}, {"w": "Subclassing,", "b": [0.4358, 0.6125, 0.5374, 0.6339]}, {"w": "you", "b": [0.5424, 0.6125, 0.5736, 0.6339]}, {"w": "learned", "b": [0.5786, 0.6125, 0.6408, 0.6339]}, {"w": "how", "b": [0.6458, 0.6125, 0.6818, 0.6339]}, {"w": "to", "b": [0.6868, 0.6125, 0.7038, 0.6339]}, {"w": "save", "b": [0.7088, 0.6125, 0.7437, 0.6339]}, {"w": "and", "b": [0.7487, 0.6125, 0.7802, 0.6339]}, {"w": "restore", "b": [0.7852, 0.6125, 0.843, 0.6339]}, {"w": "a", "b": [0.848, 0.6125, 0.8571, 0.6339]}, {"w": "model,", "b": [0.1428, 0.6316, 0.2004, 0.653]}, {"w": "use", "b": [0.2062, 0.6316, 0.2338, 0.653]}, {"w": "callbacks", "b": [0.2396, 0.6316, 0.3146, 0.653]}, {"w": "for", "b": [0.3204, 0.6316, 0.3449, 0.653]}, {"w": "checkpointing,", "b": [0.3508, 0.6316, 0.4747, 0.653]}, {"w": "early", "b": [0.4805, 0.6316, 0.521, 0.653]}, {"w": "stopping,", "b": [0.5268, 0.6316, 0.6048, 0.653]}, {"w": "and", "b": [0.6106, 0.6316, 0.6421, 0.653]}, {"w": "more,", "b": [0.6479, 0.6316, 0.697, 0.653]}, {"w": "and", "b": [0.7028, 0.6316, 0.7343, 0.653]}, {"w": "finally", "b": [0.7401, 0.6316, 0.7925, 0.653]}, {"w": "how", "b": [0.7983, 0.6316, 0.8343, 0.653]}, {"w": "to", "b": [0.8402, 0.6316, 0.8571, 0.653]}, {"w": "use", "b": [0.1429, 0.6506, 0.1704, 0.672]}, {"w": "TensorBoard", "b": [0.1756, 0.6506, 0.2838, 0.672]}, {"w": "for", "b": [0.289, 0.6506, 0.3135, 0.672]}, {"w": "visualization.", "b": [0.3187, 0.6506, 0.4288, 0.672]}, {"w": "You", "b": [0.434, 0.6506, 0.4663, 0.672]}, {"w": "can", "b": [0.4715, 0.6506, 0.5009, 0.672]}, {"w": "already", "b": [0.506, 0.6506, 0.5667, 0.672]}, {"w": "go", "b": [0.5719, 0.6506, 0.5923, 0.672]}, {"w": "ahead", "b": [0.5974, 0.6506, 0.6467, 0.672]}, {"w": "and", "b": [0.6519, 0.6506, 0.6834, 0.672]}, {"w": "use", "b": [0.6886, 0.6506, 0.7162, 0.672]}, {"w": "neural", "b": [0.7213, 0.6506, 0.7748, 0.672]}, {"w": "networks", "b": [0.7799, 0.6506, 0.8572, 0.672]}, {"w": "to", "b": [0.1429, 0.6696, 0.1598, 0.6911]}, {"w": "tackle", "b": [0.1666, 0.6696, 0.2154, 0.6911]}, {"w": "many", "b": [0.2221, 0.6696, 0.2688, 0.6911]}, {"w": "problems!", "b": [0.2756, 0.6696, 0.36, 0.6911]}, {"w": "However,", "b": [0.3668, 0.6696, 0.4456, 0.6911]}, {"w": "you", "b": [0.4524, 0.6696, 0.4837, 0.6911]}, {"w": "may", "b": [0.4904, 0.6696, 0.5258, 0.6911]}, {"w": "wonder", "b": [0.5326, 0.6696, 0.5965, 0.6911]}, {"w": "how", "b": [0.6032, 0.6696, 0.6392, 0.6911]}, {"w": "to", "b": [0.646, 0.6696, 0.663, 0.6911]}, {"w": "choose", "b": [0.6697, 0.6696, 0.7274, 0.6911]}, {"w": "the", "b": [0.7342, 0.6696, 0.7605, 0.6911]}, {"w": "number", "b": [0.7673, 0.6696, 0.8336, 0.6911]}, {"w": "of", "b": [0.8404, 0.6696, 0.8571, 0.6911]}, {"w": "hidden", "b": [0.1429, 0.6887, 0.2018, 0.7101]}, {"w": "layers,", "b": [0.2069, 0.6887, 0.2595, 0.7101]}, {"w": "the", "b": [0.2647, 0.6887, 0.291, 0.7101]}, {"w": "number", "b": [0.2961, 0.6887, 0.3624, 0.7101]}, {"w": "of", "b": [0.3676, 0.6887, 0.3844, 0.7101]}, {"w": "neurons", "b": [0.3895, 0.6887, 0.4582, 0.7101]}, {"w": "in", "b": [0.4633, 0.6887, 0.4803, 0.7101]}, {"w": "the", "b": [0.4854, 0.6887, 0.5118, 0.7101]}, {"w": "network,", "b": [0.5169, 0.6887, 0.5912, 0.7101]}, {"w": "and", "b": [0.5964, 0.6887, 0.6279, 0.7101]}, {"w": "all", "b": [0.633, 0.6887, 0.6527, 0.7101]}, {"w": "the", "b": [0.6579, 0.6887, 0.6842, 0.7101]}, {"w": "other", "b": [0.6893, 0.6887, 0.734, 0.7101]}, {"w": "hyperparame‐", "b": [0.7392, 0.6887, 0.8571, 0.7101]}, {"w": "ters.", "b": [0.1428, 0.7077, 0.1782, 0.7292]}, {"w": "Let’s", "b": [0.1829, 0.7077, 0.2191, 0.7292]}, {"w": "look", "b": [0.2238, 0.7077, 0.2607, 0.7292]}, {"w": "at", "b": [0.2654, 0.7077, 0.2805, 0.7292]}, {"w": "this", "b": [0.2852, 0.7077, 0.3159, 0.7292]}, {"w": "now.", "b": [0.3207, 0.7077, 0.3602, 0.7292]}]}, {"id": "b_3", "type": "equation", "text": "Fine-Tuning Neural Network Hyperparameters", "words": [{"w": "Fine-Tuning", "b": [0.1429, 0.7421, 0.292, 0.7764]}, {"w": "Neural", "b": [0.298, 0.7421, 0.3803, 0.7764]}, {"w": "Network", "b": [0.3863, 0.7421, 0.4927, 0.7764]}, {"w": "Hyperparameters", "b": [0.4987, 0.7421, 0.7146, 0.7764]}]}, {"id": "b_4", "type": "paragraph", "text": "The flexibility of neural networks is also one of their main drawbacks: there are many hyperparameters to tweak. Not only can you use any imaginable network architec‐ ture, but even in a simple MLP you can change the number of layers, the number of neurons per layer, the type of activation function to use in each layer, the weight initi‐", "words": [{"w": "The", "b": [0.1429, 0.7833, 0.1757, 0.8047]}, {"w": "flexibility", "b": [0.1807, 0.7833, 0.2594, 0.8047]}, {"w": "of", "b": [0.2644, 0.7833, 0.2812, 0.8047]}, {"w": "neural", "b": [0.2863, 0.7833, 0.3397, 0.8047]}, {"w": "networks", "b": [0.3448, 0.7833, 0.422, 0.8047]}, {"w": "is", "b": [0.427, 0.7833, 0.4402, 0.8047]}, {"w": "also", "b": [0.4453, 0.7833, 0.478, 0.8047]}, {"w": "one", "b": [0.483, 0.7833, 0.5139, 0.8047]}, {"w": "of", "b": [0.5189, 0.7833, 0.5357, 0.8047]}, {"w": "their", "b": [0.5407, 0.7833, 0.5804, 0.8047]}, {"w": "main", "b": [0.5854, 0.7833, 0.6286, 0.8047]}, {"w": "drawbacks:", "b": [0.6337, 0.7833, 0.7267, 0.8047]}, {"w": "there", "b": [0.7317, 0.7833, 0.7747, 0.8047]}, {"w": "are", "b": [0.7797, 0.7833, 0.8054, 0.8047]}, {"w": "many", "b": [0.8105, 0.7833, 0.8572, 0.8047]}, {"w": "hyperparameters", "b": [0.1429, 0.8024, 0.284, 0.8238]}, {"w": "to", "b": [0.2913, 0.8024, 0.3083, 0.8238]}, {"w": "tweak.", "b": [0.3155, 0.8024, 0.3693, 0.8238]}, {"w": "Not", "b": [0.3765, 0.8024, 0.4085, 0.8238]}, {"w": "only", "b": [0.4158, 0.8024, 0.4526, 0.8238]}, {"w": "can", "b": [0.4599, 0.8024, 0.4892, 0.8238]}, {"w": "you", "b": [0.4965, 0.8024, 0.5278, 0.8238]}, {"w": "use", "b": [0.5351, 0.8024, 0.5626, 0.8238]}, {"w": "any", "b": [0.5699, 0.8024, 0.5995, 0.8238]}, {"w": "imaginable", "b": [0.6068, 0.8024, 0.6992, 0.8238]}, {"w": "network", "b": [0.7065, 0.8024, 0.776, 0.8238]}, {"w": "architec‐", "b": [0.7833, 0.8024, 0.8571, 0.8238]}, {"w": "ture,", "b": [0.1429, 0.8214, 0.1816, 0.8428]}, {"w": "but", "b": [0.1875, 0.8214, 0.2155, 0.8428]}, {"w": "even", "b": [0.2215, 0.8214, 0.2602, 0.8428]}, {"w": "in", "b": [0.2662, 0.8214, 0.2832, 0.8428]}, {"w": "a", "b": [0.2891, 0.8214, 0.2983, 0.8428]}, {"w": "simple", "b": [0.3042, 0.8214, 0.3591, 0.8428]}, {"w": "MLP", "b": [0.3651, 0.8214, 0.4066, 0.8428]}, {"w": "you", "b": [0.4125, 0.8214, 0.4438, 0.8428]}, {"w": "can", "b": [0.4497, 0.8214, 0.4791, 0.8428]}, {"w": "change", "b": [0.485, 0.8214, 0.5441, 0.8428]}, {"w": "the", "b": [0.5501, 0.8214, 0.5764, 0.8428]}, {"w": "number", "b": [0.5823, 0.8214, 0.6486, 0.8428]}, {"w": "of", "b": [0.6546, 0.8214, 0.6714, 0.8428]}, {"w": "layers,", "b": [0.6773, 0.8214, 0.7299, 0.8428]}, {"w": "the", "b": [0.7358, 0.8214, 0.7622, 0.8428]}, {"w": "number", "b": [0.7681, 0.8214, 0.8344, 0.8428]}, {"w": "of", "b": [0.8403, 0.8214, 0.8571, 0.8428]}, {"w": "neurons", "b": [0.1428, 0.8405, 0.2116, 0.8619]}, {"w": "per", "b": [0.2166, 0.8405, 0.2441, 0.8619]}, {"w": "layer,", "b": [0.2491, 0.8405, 0.2927, 0.8619]}, {"w": "the", "b": [0.2977, 0.8405, 0.324, 0.8619]}, {"w": "type", "b": [0.329, 0.8405, 0.3647, 0.8619]}, {"w": "of", "b": [0.3697, 0.8405, 0.3865, 0.8619]}, {"w": "activation", "b": [0.3915, 0.8405, 0.4738, 0.8619]}, {"w": "function", "b": [0.4788, 0.8405, 0.5502, 0.8619]}, {"w": "to", "b": [0.5552, 0.8405, 0.5722, 0.8619]}, {"w": "use", "b": [0.5772, 0.8405, 0.6048, 0.8619]}, {"w": "in", "b": [0.6098, 0.8405, 0.6267, 0.8619]}, {"w": "each", "b": [0.6317, 0.8405, 0.6697, 0.8619]}, {"w": "layer,", "b": [0.6747, 0.8405, 0.7183, 0.8619]}, {"w": "the", "b": [0.7233, 0.8405, 0.7497, 0.8619]}, {"w": "weight", "b": [0.7547, 0.8405, 0.8102, 0.8619]}, {"w": "initi‐", "b": [0.8152, 0.8405, 0.8571, 0.8619]}]}, {"id": "b_5", "type": "equation", "text": "Fine-Tuning Neural Network Hyperparameters | 315", "words": [{"w": "Fine-Tuning", "b": [0.5238, 0.9225, 0.5948, 0.9388]}, {"w": "Neural", "b": [0.5976, 0.9225, 0.6368, 0.9388]}, {"w": "Network", "b": [0.6396, 0.9225, 0.6903, 0.9388]}, {"w": "Hyperparameters", "b": [0.6931, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "315", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 342, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "alization logic, and much more. How do you know what combination of hyperpara‐ meters is the best for your task?", "words": [{"w": "alization", "b": [0.1429, 0.0791, 0.2143, 0.1005]}, {"w": "logic,", "b": [0.2205, 0.0791, 0.2653, 0.1005]}, {"w": "and", "b": [0.2714, 0.0791, 0.303, 0.1005]}, {"w": "much", "b": [0.3091, 0.0791, 0.3568, 0.1005]}, {"w": "more.", "b": [0.3629, 0.0791, 0.412, 0.1005]}, {"w": "How", "b": [0.4181, 0.0791, 0.4584, 0.1005]}, {"w": "do", "b": [0.4646, 0.0791, 0.4862, 0.1005]}, {"w": "you", "b": [0.4924, 0.0791, 0.5236, 0.1005]}, {"w": "know", "b": [0.5298, 0.0791, 0.5764, 0.1005]}, {"w": "what", "b": [0.5826, 0.0791, 0.6231, 0.1005]}, {"w": "combination", "b": [0.6292, 0.0791, 0.736, 0.1005]}, {"w": "of", "b": [0.7421, 0.0791, 0.7589, 0.1005]}, {"w": "hyperpara‐", "b": [0.7651, 0.0791, 0.8571, 0.1005]}, {"w": "meters", "b": [0.1429, 0.0981, 0.1994, 0.1195]}, {"w": "is", "b": [0.2041, 0.0981, 0.2173, 0.1195]}, {"w": "the", "b": [0.222, 0.0981, 0.2484, 0.1195]}, {"w": "best", "b": [0.2531, 0.0981, 0.2865, 0.1195]}, {"w": "for", "b": [0.2913, 0.0981, 0.3158, 0.1195]}, {"w": "your", "b": [0.3205, 0.0981, 0.3595, 0.1195]}, {"w": "task?", "b": [0.3642, 0.0981, 0.4056, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "One option is to simply try many combinations of hyperparameters and see which one works best on the validation set (or using K-fold cross-validation). For this, one approach is simply use GridSearchCV or RandomizedSearchCV to explore the hyper‐ parameter space, as we did in Chapter 2. For this, we need to wrap our Keras models in objects that mimic regular Scikit-Learn regressors. The first step is to create a func‐ tion that will build and compile a Keras model, given a set of hyperparameters:", "words": [{"w": "One", "b": [0.1429, 0.1262, 0.1787, 0.1476]}, {"w": "option", "b": [0.1858, 0.1262, 0.2413, 0.1476]}, {"w": "is", "b": [0.2485, 0.1262, 0.2617, 0.1476]}, {"w": "to", "b": [0.2689, 0.1262, 0.2859, 0.1476]}, {"w": "simply", "b": [0.293, 0.1262, 0.3487, 0.1476]}, {"w": "try", "b": [0.3559, 0.1262, 0.3801, 0.1476]}, {"w": "many", "b": [0.3873, 0.1262, 0.434, 0.1476]}, {"w": "combinations", "b": [0.4411, 0.1262, 0.5555, 0.1476]}, {"w": "of", "b": [0.5627, 0.1262, 0.5795, 0.1476]}, {"w": "hyperparameters", "b": [0.5867, 0.1262, 0.7278, 0.1476]}, {"w": "and", "b": [0.735, 0.1262, 0.7665, 0.1476]}, {"w": "see", "b": [0.7737, 0.1262, 0.7991, 0.1476]}, {"w": "which", "b": [0.8062, 0.1262, 0.8571, 0.1476]}, {"w": "one", "b": [0.1429, 0.1453, 0.1737, 0.1667]}, {"w": "works", "b": [0.1798, 0.1453, 0.2304, 0.1667]}, {"w": "best", "b": [0.2365, 0.1453, 0.2699, 0.1667]}, {"w": "on", "b": [0.276, 0.1453, 0.298, 0.1667]}, {"w": "the", "b": [0.3041, 0.1453, 0.3304, 0.1667]}, {"w": "validation", "b": [0.3364, 0.1453, 0.4198, 0.1667]}, {"w": "set", "b": [0.4259, 0.1453, 0.4487, 0.1667]}, {"w": "(or", "b": [0.4548, 0.1453, 0.4803, 0.1667]}, {"w": "using", "b": [0.4864, 0.1453, 0.5318, 0.1667]}, {"w": "K-fold", "b": [0.5379, 0.1453, 0.5924, 0.1667]}, {"w": "cross-validation).", "b": [0.5985, 0.1453, 0.7437, 0.1667]}, {"w": "For", "b": [0.7497, 0.1453, 0.7787, 0.1667]}, {"w": "this,", "b": [0.7848, 0.1453, 0.8202, 0.1667]}, {"w": "one", "b": [0.8263, 0.1453, 0.8572, 0.1667]}, {"w": "approach", "b": [0.1429, 0.1652, 0.2209, 0.1866]}, {"w": "is", "b": [0.2273, 0.1652, 0.2405, 0.1866]}, {"w": "simply", "b": [0.2469, 0.1652, 0.3026, 0.1866]}, {"w": "use", "b": [0.309, 0.1652, 0.3365, 0.1866]}, {"w": "GridSearchCV", "b": [0.3429, 0.1684, 0.4617, 0.1835]}, {"w": "or", "b": [0.4681, 0.1652, 0.4865, 0.1866]}, {"w": "RandomizedSearchCV", "b": [0.4929, 0.1684, 0.671, 0.1835]}, {"w": "to", "b": [0.6774, 0.1652, 0.6944, 0.1866]}, {"w": "explore", "b": [0.7008, 0.1652, 0.7629, 0.1866]}, {"w": "the", "b": [0.7693, 0.1652, 0.7956, 0.1866]}, {"w": "hyper‐", "b": [0.802, 0.1652, 0.8571, 0.1866]}, {"w": "parameter", "b": [0.1429, 0.1843, 0.2286, 0.2057]}, {"w": "space,", "b": [0.2342, 0.1843, 0.2843, 0.2057]}, {"w": "as", "b": [0.2898, 0.1843, 0.3066, 0.2057]}, {"w": "we", "b": [0.3122, 0.1843, 0.3353, 0.2057]}, {"w": "did", "b": [0.3408, 0.1843, 0.3684, 0.2057]}, {"w": "in", "b": [0.3739, 0.1843, 0.3909, 0.2057]}, {"w": "Chapter", "b": [0.3964, 0.1843, 0.464, 0.2057]}, {"w": "2.", "b": [0.4695, 0.1843, 0.4843, 0.2057]}, {"w": "For", "b": [0.4898, 0.1843, 0.5188, 0.2057]}, {"w": "this,", "b": [0.5243, 0.1843, 0.5598, 0.2057]}, {"w": "we", "b": [0.5653, 0.1843, 0.5884, 0.2057]}, {"w": "need", "b": [0.594, 0.1843, 0.6341, 0.2057]}, {"w": "to", "b": [0.6396, 0.1843, 0.6566, 0.2057]}, {"w": "wrap", "b": [0.6621, 0.1843, 0.7038, 0.2057]}, {"w": "our", "b": [0.7093, 0.1843, 0.7387, 0.2057]}, {"w": "Keras", "b": [0.7443, 0.1843, 0.7912, 0.2057]}, {"w": "models", "b": [0.7967, 0.1843, 0.8571, 0.2057]}, {"w": "in", "b": [0.1428, 0.2033, 0.1598, 0.2247]}, {"w": "objects", "b": [0.1647, 0.2033, 0.2229, 0.2247]}, {"w": "that", "b": [0.2277, 0.2033, 0.2603, 0.2247]}, {"w": "mimic", "b": [0.2652, 0.2033, 0.3193, 0.2247]}, {"w": "regular", "b": [0.3241, 0.2033, 0.3837, 0.2247]}, {"w": "Scikit-Learn", "b": [0.3885, 0.2033, 0.4908, 0.2247]}, {"w": "regressors.", "b": [0.4957, 0.2033, 0.5846, 0.2247]}, {"w": "The", "b": [0.5895, 0.2033, 0.6223, 0.2247]}, {"w": "first", "b": [0.6272, 0.2033, 0.6607, 0.2247]}, {"w": "step", "b": [0.6655, 0.2033, 0.6993, 0.2247]}, {"w": "is", "b": [0.7042, 0.2033, 0.7174, 0.2247]}, {"w": "to", "b": [0.7222, 0.2033, 0.7392, 0.2247]}, {"w": "create", "b": [0.7441, 0.2033, 0.7934, 0.2247]}, {"w": "a", "b": [0.7983, 0.2033, 0.8074, 0.2247]}, {"w": "func‐", "b": [0.8123, 0.2033, 0.8571, 0.2247]}, {"w": "tion", "b": [0.1429, 0.2224, 0.1768, 0.2438]}, {"w": "that", "b": [0.1816, 0.2224, 0.2141, 0.2438]}, {"w": "will", "b": [0.2189, 0.2224, 0.2493, 0.2438]}, {"w": "build", "b": [0.254, 0.2224, 0.2975, 0.2438]}, {"w": "and", "b": [0.3022, 0.2224, 0.3338, 0.2438]}, {"w": "compile", "b": [0.3385, 0.2224, 0.4052, 0.2438]}, {"w": "a", "b": [0.4099, 0.2224, 0.4191, 0.2438]}, {"w": "Keras", "b": [0.4238, 0.2224, 0.4707, 0.2438]}, {"w": "model,", "b": [0.4754, 0.2224, 0.533, 0.2438]}, {"w": "given", "b": [0.5377, 0.2224, 0.583, 0.2438]}, {"w": "a", "b": [0.5877, 0.2224, 0.5968, 0.2438]}, {"w": "set", "b": [0.6016, 0.2224, 0.6244, 0.2438]}, {"w": "of", "b": [0.6292, 0.2224, 0.6459, 0.2438]}, {"w": "hyperparameters:", "b": [0.6507, 0.2224, 0.7966, 0.2438]}]}, {"id": "b_2", "type": "paragraph", "text": "def build_model(n_hidden=1, n_neurons=30, learning_rate=3e-3, input_shape=[8]): model = keras.models.Sequential() options = {\"input_shape\": input_shape} for layer in range(n_hidden): model.add(keras.layers.Dense(n_neurons, activation=\"relu\", **options)) options = {} model.add(keras.layers.Dense(1, **options)) optimizer = keras.optimizers.SGD(learning_rate) model.compile(loss=\"mse\", optimizer=optimizer) return model", "words": [{"w": "def", "b": [0.1766, 0.2543, 0.2019, 0.2672]}, {"w": "build_model(n_hidden=1,", "b": [0.2103, 0.2543, 0.4043, 0.2672]}, {"w": "n_neurons=30,", "b": [0.4127, 0.2543, 0.5223, 0.2672]}, {"w": "learning_rate=3e-3,", "b": [0.5308, 0.2543, 0.691, 0.2672]}, {"w": "input_shape=[8]):", "b": [0.6994, 0.2543, 0.8428, 0.2672]}, {"w": "model", "b": [0.2103, 0.2698, 0.2525, 0.2826]}, {"w": "=", "b": [0.2609, 0.2698, 0.2694, 0.2826]}, {"w": "keras.models.Sequential()", "b": [0.2778, 0.2698, 0.4886, 0.2826]}, {"w": "options", "b": [0.2103, 0.2852, 0.2694, 0.298]}, {"w": "=", "b": [0.2778, 0.2852, 0.2862, 0.298]}, {"w": "{\"input_shape\":", "b": [0.2947, 0.2852, 0.4211, 0.298]}, {"w": "input_shape}", "b": [0.4296, 0.2852, 0.5308, 0.298]}, {"w": "for", "b": [0.2103, 0.3006, 0.2356, 0.3134]}, {"w": "layer", "b": [0.2441, 0.3006, 0.2862, 0.3134]}, {"w": "in", "b": [0.2947, 0.3006, 0.3115, 0.3134]}, {"w": "range(n_hidden):", "b": [0.3199, 0.3006, 0.4549, 0.3134]}, {"w": "model.add(keras.layers.Dense(n_neurons,", "b": [0.2441, 0.316, 0.5729, 0.3289]}, {"w": "activation=\"relu\",", "b": [0.5814, 0.316, 0.7331, 0.3289]}, {"w": "**options))", "b": [0.7416, 0.316, 0.8343, 0.3289]}, {"w": "options", "b": [0.2441, 0.3314, 0.3031, 0.3443]}, {"w": "=", "b": [0.3115, 0.3314, 0.3199, 0.3443]}, {"w": "{}", "b": [0.3284, 0.3314, 0.3452, 0.3443]}, {"w": "model.add(keras.layers.Dense(1,", "b": [0.2103, 0.3469, 0.4717, 0.3597]}, {"w": "**options))", "b": [0.4802, 0.3469, 0.5729, 0.3597]}, {"w": "optimizer", "b": [0.2103, 0.3623, 0.2862, 0.3751]}, {"w": "=", "b": [0.2947, 0.3623, 0.3031, 0.3751]}, {"w": "keras.optimizers.SGD(learning_rate)", "b": [0.3115, 0.3623, 0.6067, 0.3751]}, {"w": "model.compile(loss=\"mse\",", "b": [0.2103, 0.3777, 0.4211, 0.3905]}, {"w": "optimizer=optimizer)", "b": [0.4296, 0.3777, 0.5982, 0.3905]}, {"w": "return", "b": [0.2103, 0.3931, 0.2609, 0.406]}, {"w": "model", "b": [0.2694, 0.3931, 0.3115, 0.406]}]}, {"id": "b_3", "type": "paragraph", "text": "This function creates a simple Sequential model for univariate regression (only one output neuron), with the given input shape and the given number of hidden layers and neurons, and it compiles it using an SGD optimizer configured with the given learning rate. The options dict is used to ensure that the first layer is properly given the input shape (note that if n_hidden=0, the first layer will be the output layer). It is good practice to provide reasonable defaults to as many hyperparameters as you can, as Scikit-Learn does.", "words": [{"w": "This", "b": [0.1428, 0.4146, 0.1801, 0.4361]}, {"w": "function", "b": [0.1858, 0.4146, 0.2572, 0.4361]}, {"w": "creates", "b": [0.263, 0.4146, 0.32, 0.4361]}, {"w": "a", "b": [0.3258, 0.4146, 0.3349, 0.4361]}, {"w": "simple", "b": [0.3407, 0.4146, 0.3956, 0.4361]}, {"w": "Sequential", "b": [0.4014, 0.4178, 0.5003, 0.4329]}, {"w": "model", "b": [0.5061, 0.4146, 0.5589, 0.4361]}, {"w": "for", "b": [0.5647, 0.4146, 0.5892, 0.4361]}, {"w": "univariate", "b": [0.595, 0.4146, 0.6791, 0.4361]}, {"w": "regression", "b": [0.6848, 0.4146, 0.7707, 0.4361]}, {"w": "(only", "b": [0.7764, 0.4146, 0.8205, 0.4361]}, {"w": "one", "b": [0.8263, 0.4146, 0.8571, 0.4361]}, {"w": "output", "b": [0.1429, 0.4337, 0.1992, 0.4551]}, {"w": "neuron),", "b": [0.2062, 0.4337, 0.2792, 0.4551]}, {"w": "with", "b": [0.2862, 0.4337, 0.3236, 0.4551]}, {"w": "the", "b": [0.3305, 0.4337, 0.3569, 0.4551]}, {"w": "given", "b": [0.3639, 0.4337, 0.4091, 0.4551]}, {"w": "input", "b": [0.4161, 0.4337, 0.461, 0.4551]}, {"w": "shape", "b": [0.468, 0.4337, 0.5153, 0.4551]}, {"w": "and", "b": [0.5223, 0.4337, 0.5538, 0.4551]}, {"w": "the", "b": [0.5608, 0.4337, 0.5871, 0.4551]}, {"w": "given", "b": [0.5941, 0.4337, 0.6393, 0.4551]}, {"w": "number", "b": [0.6463, 0.4337, 0.7126, 0.4551]}, {"w": "of", "b": [0.7196, 0.4337, 0.7364, 0.4551]}, {"w": "hidden", "b": [0.7434, 0.4337, 0.8023, 0.4551]}, {"w": "layers", "b": [0.8093, 0.4337, 0.8572, 0.4551]}, {"w": "and", "b": [0.1429, 0.4536, 0.1744, 0.475]}, {"w": "neurons,", "b": [0.1823, 0.4536, 0.2557, 0.475]}, {"w": "and", "b": [0.2636, 0.4536, 0.2952, 0.475]}, {"w": "it", "b": [0.3031, 0.4536, 0.315, 0.475]}, {"w": "compiles", "b": [0.3229, 0.4536, 0.3973, 0.475]}, {"w": "it", "b": [0.4051, 0.4536, 0.4171, 0.475]}, {"w": "using", "b": [0.425, 0.4536, 0.4704, 0.475]}, {"w": "an", "b": [0.4783, 0.4536, 0.4988, 0.475]}, {"w": "SGD", "b": [0.5067, 0.4568, 0.5364, 0.4719]}, {"w": "optimizer", "b": [0.5443, 0.4536, 0.6257, 0.475]}, {"w": "configured", "b": [0.6336, 0.4536, 0.7246, 0.475]}, {"w": "with", "b": [0.7325, 0.4536, 0.7698, 0.475]}, {"w": "the", "b": [0.7777, 0.4536, 0.804, 0.475]}, {"w": "given", "b": [0.8119, 0.4536, 0.8571, 0.475]}, {"w": "learning", "b": [0.1429, 0.4736, 0.212, 0.495]}, {"w": "rate.", "b": [0.2178, 0.4736, 0.2543, 0.495]}, {"w": "The", "b": [0.2601, 0.4736, 0.293, 0.495]}, {"w": "options", "b": [0.2988, 0.4768, 0.3681, 0.4918]}, {"w": "dict", "b": [0.374, 0.4736, 0.4057, 0.495]}, {"w": "is", "b": [0.4116, 0.4736, 0.4248, 0.495]}, {"w": "used", "b": [0.4307, 0.4736, 0.4692, 0.495]}, {"w": "to", "b": [0.4751, 0.4736, 0.4921, 0.495]}, {"w": "ensure", "b": [0.4979, 0.4736, 0.5535, 0.495]}, {"w": "that", "b": [0.5593, 0.4736, 0.5919, 0.495]}, {"w": "the", "b": [0.5978, 0.4736, 0.6241, 0.495]}, {"w": "first", "b": [0.63, 0.4736, 0.6634, 0.495]}, {"w": "layer", "b": [0.6693, 0.4736, 0.7095, 0.495]}, {"w": "is", "b": [0.7154, 0.4736, 0.7286, 0.495]}, {"w": "properly", "b": [0.7344, 0.4736, 0.806, 0.495]}, {"w": "given", "b": [0.8119, 0.4736, 0.8571, 0.495]}, {"w": "the", "b": [0.1429, 0.4935, 0.1692, 0.5149]}, {"w": "input", "b": [0.175, 0.4935, 0.2199, 0.5149]}, {"w": "shape", "b": [0.2257, 0.4935, 0.273, 0.5149]}, {"w": "(note", "b": [0.2788, 0.4935, 0.3232, 0.5149]}, {"w": "that", "b": [0.329, 0.4935, 0.3616, 0.5149]}, {"w": "if", "b": [0.3674, 0.4935, 0.3791, 0.5149]}, {"w": "n_hidden=0,", "b": [0.3849, 0.4935, 0.4887, 0.5149]}, {"w": "the", "b": [0.4944, 0.4935, 0.5208, 0.5149]}, {"w": "first", "b": [0.5266, 0.4935, 0.5601, 0.5149]}, {"w": "layer", "b": [0.5658, 0.4935, 0.606, 0.5149]}, {"w": "will", "b": [0.6118, 0.4935, 0.6422, 0.5149]}, {"w": "be", "b": [0.648, 0.4935, 0.6675, 0.5149]}, {"w": "the", "b": [0.6732, 0.4935, 0.6996, 0.5149]}, {"w": "output", "b": [0.7054, 0.4935, 0.7617, 0.5149]}, {"w": "layer).", "b": [0.7675, 0.4935, 0.8197, 0.5149]}, {"w": "It", "b": [0.8255, 0.4935, 0.8381, 0.5149]}, {"w": "is", "b": [0.8439, 0.4935, 0.8572, 0.5149]}, {"w": "good", "b": [0.1429, 0.5126, 0.1849, 0.534]}, {"w": "practice", "b": [0.1904, 0.5126, 0.2566, 0.534]}, {"w": "to", "b": [0.2622, 0.5126, 0.2792, 0.534]}, {"w": "provide", "b": [0.2847, 0.5126, 0.3491, 0.534]}, {"w": "reasonable", "b": [0.3546, 0.5126, 0.4439, 0.534]}, {"w": "defaults", "b": [0.4494, 0.5126, 0.5145, 0.534]}, {"w": "to", "b": [0.5201, 0.5126, 0.5371, 0.534]}, {"w": "as", "b": [0.5426, 0.5126, 0.5594, 0.534]}, {"w": "many", "b": [0.565, 0.5126, 0.6116, 0.534]}, {"w": "hyperparameters", "b": [0.6172, 0.5126, 0.7583, 0.534]}, {"w": "as", "b": [0.7639, 0.5126, 0.7807, 0.534]}, {"w": "you", "b": [0.7862, 0.5126, 0.8175, 0.534]}, {"w": "can,", "b": [0.823, 0.5126, 0.8571, 0.534]}, {"w": "as", "b": [0.1429, 0.5316, 0.1596, 0.553]}, {"w": "Scikit-Learn", "b": [0.1644, 0.5316, 0.2667, 0.553]}, {"w": "does.", "b": [0.2714, 0.5316, 0.3143, 0.553]}]}, {"id": "b_4", "type": "equation", "text": "Next, let’s create a KerasRegressor based on this build_model() function:", "words": [{"w": "Next,", "b": [0.1429, 0.5606, 0.1876, 0.582]}, {"w": "let’s", "b": [0.1923, 0.5606, 0.2226, 0.582]}, {"w": "create", "b": [0.2273, 0.5606, 0.2766, 0.582]}, {"w": "a", "b": [0.2814, 0.5606, 0.2905, 0.582]}, {"w": "KerasRegressor", "b": [0.2953, 0.5638, 0.4338, 0.5789]}, {"w": "based", "b": [0.4385, 0.5606, 0.4858, 0.582]}, {"w": "on", "b": [0.4905, 0.5606, 0.5125, 0.582]}, {"w": "this", "b": [0.5172, 0.5606, 0.5479, 0.582]}, {"w": "build_model()", "b": [0.5527, 0.5638, 0.6813, 0.5789]}, {"w": "function:", "b": [0.686, 0.5606, 0.7622, 0.582]}]}, {"id": "b_5", "type": "equation", "text": "keras_reg = keras.wrappers.scikit_learn.KerasRegressor(build_model)", "words": [{"w": "keras_reg", "b": [0.1766, 0.5926, 0.2525, 0.6055]}, {"w": "=", "b": [0.2609, 0.5926, 0.2693, 0.6055]}, {"w": "keras.wrappers.scikit_learn.KerasRegressor(build_model)", "b": [0.2778, 0.5926, 0.7416, 0.6055]}]}, {"id": "b_6", "type": "paragraph", "text": "The KerasRegressor object is a thin wrapper around the Keras model built using build_model(). Since we did not specify any hyperparameter when creating it, it will just use the default hyperparameters we defined in build_model(). Now we can use this object like a regular Scikit-Learn regressor: we can train it using its fit() method, then evaluate it using its score() method, and use it to make predictions using its predict() method. Note that any extra parameter you pass to the fit() method will simply get passed to the underlying Keras model. Also note that the score will be the opposite of the MSE because Scikit-Learn wants scores, not losses (i.e., higher should be better).", "words": [{"w": "The", "b": [0.1429, 0.6141, 0.1757, 0.6356]}, {"w": "KerasRegressor", "b": [0.1836, 0.6173, 0.3222, 0.6324]}, {"w": "object", "b": [0.3301, 0.6141, 0.3806, 0.6356]}, {"w": "is", "b": [0.3886, 0.6141, 0.4018, 0.6356]}, {"w": "a", "b": [0.4097, 0.6141, 0.4189, 0.6356]}, {"w": "thin", "b": [0.4268, 0.6141, 0.4612, 0.6356]}, {"w": "wrapper", "b": [0.4692, 0.6141, 0.5383, 0.6356]}, {"w": "around", "b": [0.5462, 0.6141, 0.6072, 0.6356]}, {"w": "the", "b": [0.6151, 0.6141, 0.6415, 0.6356]}, {"w": "Keras", "b": [0.6494, 0.6141, 0.6963, 0.6356]}, {"w": "model", "b": [0.7042, 0.6141, 0.757, 0.6356]}, {"w": "built", "b": [0.7649, 0.6141, 0.8038, 0.6356]}, {"w": "using", "b": [0.8117, 0.6141, 0.8571, 0.6356]}, {"w": "build_model().", "b": [0.1429, 0.6341, 0.2763, 0.6555]}, {"w": "Since", "b": [0.2816, 0.6341, 0.3261, 0.6555]}, {"w": "we", "b": [0.3315, 0.6341, 0.3546, 0.6555]}, {"w": "did", "b": [0.36, 0.6341, 0.3876, 0.6555]}, {"w": "not", "b": [0.3929, 0.6341, 0.4213, 0.6555]}, {"w": "specify", "b": [0.4267, 0.6341, 0.4846, 0.6555]}, {"w": "any", "b": [0.4899, 0.6341, 0.5196, 0.6555]}, {"w": "hyperparameter", "b": [0.5249, 0.6341, 0.6584, 0.6555]}, {"w": "when", "b": [0.6638, 0.6341, 0.7094, 0.6555]}, {"w": "creating", "b": [0.7148, 0.6341, 0.782, 0.6555]}, {"w": "it,", "b": [0.7874, 0.6341, 0.8041, 0.6555]}, {"w": "it", "b": [0.8094, 0.6341, 0.8214, 0.6555]}, {"w": "will", "b": [0.8267, 0.6341, 0.8571, 0.6555]}, {"w": "just", "b": [0.1429, 0.654, 0.1732, 0.6754]}, {"w": "use", "b": [0.1795, 0.654, 0.2071, 0.6754]}, {"w": "the", "b": [0.2133, 0.654, 0.2397, 0.6754]}, {"w": "default", "b": [0.2459, 0.654, 0.3034, 0.6754]}, {"w": "hyperparameters", "b": [0.3097, 0.654, 0.4508, 0.6754]}, {"w": "we", "b": [0.4571, 0.654, 0.4802, 0.6754]}, {"w": "defined", "b": [0.4864, 0.654, 0.5493, 0.6754]}, {"w": "in", "b": [0.5556, 0.654, 0.5725, 0.6754]}, {"w": "build_model().", "b": [0.5788, 0.654, 0.7122, 0.6754]}, {"w": "Now", "b": [0.7185, 0.654, 0.7583, 0.6754]}, {"w": "we", "b": [0.7646, 0.654, 0.7877, 0.6754]}, {"w": "can", "b": [0.794, 0.654, 0.8233, 0.6754]}, {"w": "use", "b": [0.8296, 0.654, 0.8571, 0.6754]}, {"w": "this", "b": [0.1429, 0.674, 0.1736, 0.6954]}, {"w": "object", "b": [0.1837, 0.674, 0.2342, 0.6954]}, {"w": "like", "b": [0.2443, 0.674, 0.2743, 0.6954]}, {"w": "a", "b": [0.2844, 0.674, 0.2936, 0.6954]}, {"w": "regular", "b": [0.3037, 0.674, 0.3632, 0.6954]}, {"w": "Scikit-Learn", "b": [0.3733, 0.674, 0.4756, 0.6954]}, {"w": "regressor:", "b": [0.4856, 0.674, 0.5675, 0.6954]}, {"w": "we", "b": [0.5775, 0.674, 0.6007, 0.6954]}, {"w": "can", "b": [0.6107, 0.674, 0.6401, 0.6954]}, {"w": "train", "b": [0.6502, 0.674, 0.6904, 0.6954]}, {"w": "it", "b": [0.7005, 0.674, 0.7124, 0.6954]}, {"w": "using", "b": [0.7225, 0.674, 0.7679, 0.6954]}, {"w": "its", "b": [0.778, 0.674, 0.7976, 0.6954]}, {"w": "fit()", "b": [0.8077, 0.6772, 0.8571, 0.6922]}, {"w": "method,", "b": [0.1429, 0.6939, 0.2126, 0.7153]}, {"w": "then", "b": [0.2199, 0.6939, 0.2577, 0.7153]}, {"w": "evaluate", "b": [0.265, 0.6939, 0.3329, 0.7153]}, {"w": "it", "b": [0.3402, 0.6939, 0.3521, 0.7153]}, {"w": "using", "b": [0.3594, 0.6939, 0.4049, 0.7153]}, {"w": "its", "b": [0.4122, 0.6939, 0.4318, 0.7153]}, {"w": "score()", "b": [0.4391, 0.6971, 0.5083, 0.7122]}, {"w": "method,", "b": [0.5156, 0.6939, 0.5854, 0.7153]}, {"w": "and", "b": [0.5927, 0.6939, 0.6243, 0.7153]}, {"w": "use", "b": [0.6316, 0.6939, 0.6591, 0.7153]}, {"w": "it", "b": [0.6664, 0.6939, 0.6784, 0.7153]}, {"w": "to", "b": [0.6857, 0.6939, 0.7026, 0.7153]}, {"w": "make", "b": [0.71, 0.6939, 0.7553, 0.7153]}, {"w": "predictions", "b": [0.7627, 0.6939, 0.8572, 0.7153]}, {"w": "using", "b": [0.1429, 0.7139, 0.1883, 0.7353]}, {"w": "its", "b": [0.196, 0.7139, 0.2156, 0.7353]}, {"w": "predict()", "b": [0.2233, 0.717, 0.3124, 0.7321]}, {"w": "method.", "b": [0.3201, 0.7139, 0.3899, 0.7353]}, {"w": "Note", "b": [0.3976, 0.7139, 0.4384, 0.7353]}, {"w": "that", "b": [0.4461, 0.7139, 0.4787, 0.7353]}, {"w": "any", "b": [0.4864, 0.7139, 0.516, 0.7353]}, {"w": "extra", "b": [0.5237, 0.7139, 0.5657, 0.7353]}, {"w": "parameter", "b": [0.5734, 0.7139, 0.6592, 0.7353]}, {"w": "you", "b": [0.6669, 0.7139, 0.6981, 0.7353]}, {"w": "pass", "b": [0.7058, 0.7139, 0.7412, 0.7353]}, {"w": "to", "b": [0.7489, 0.7139, 0.7659, 0.7353]}, {"w": "the", "b": [0.7736, 0.7139, 0.7999, 0.7353]}, {"w": "fit()", "b": [0.8077, 0.717, 0.8571, 0.7321]}, {"w": "method", "b": [0.1429, 0.7329, 0.2079, 0.7543]}, {"w": "will", "b": [0.2163, 0.7329, 0.2467, 0.7543]}, {"w": "simply", "b": [0.2551, 0.7329, 0.3108, 0.7543]}, {"w": "get", "b": [0.3192, 0.7329, 0.3442, 0.7543]}, {"w": "passed", "b": [0.3526, 0.7329, 0.4078, 0.7543]}, {"w": "to", "b": [0.4162, 0.7329, 0.4332, 0.7543]}, {"w": "the", "b": [0.4416, 0.7329, 0.468, 0.7543]}, {"w": "underlying", "b": [0.4764, 0.7329, 0.568, 0.7543]}, {"w": "Keras", "b": [0.5764, 0.7329, 0.6233, 0.7543]}, {"w": "model.", "b": [0.6318, 0.7329, 0.6893, 0.7543]}, {"w": "Also", "b": [0.6978, 0.7329, 0.7357, 0.7543]}, {"w": "note", "b": [0.7441, 0.7329, 0.7814, 0.7543]}, {"w": "that", "b": [0.7898, 0.7329, 0.8224, 0.7543]}, {"w": "the", "b": [0.8308, 0.7329, 0.8571, 0.7543]}, {"w": "score", "b": [0.1429, 0.752, 0.1865, 0.7734]}, {"w": "will", "b": [0.1936, 0.752, 0.224, 0.7734]}, {"w": "be", "b": [0.2311, 0.752, 0.2505, 0.7734]}, {"w": "the", "b": [0.2576, 0.752, 0.284, 0.7734]}, {"w": "opposite", "b": [0.291, 0.752, 0.3626, 0.7734]}, {"w": "of", "b": [0.3697, 0.752, 0.3864, 0.7734]}, {"w": "the", "b": [0.3935, 0.752, 0.4199, 0.7734]}, {"w": "MSE", "b": [0.427, 0.752, 0.4672, 0.7734]}, {"w": "because", "b": [0.4743, 0.752, 0.5389, 0.7734]}, {"w": "Scikit-Learn", "b": [0.546, 0.752, 0.6483, 0.7734]}, {"w": "wants", "b": [0.6553, 0.752, 0.7038, 0.7734]}, {"w": "scores,", "b": [0.7109, 0.752, 0.7669, 0.7734]}, {"w": "not", "b": [0.774, 0.752, 0.8024, 0.7734]}, {"w": "losses", "b": [0.8095, 0.752, 0.8572, 0.7734]}, {"w": "(i.e.,", "b": [0.1429, 0.771, 0.1788, 0.7924]}, {"w": "higher", "b": [0.1835, 0.771, 0.2377, 0.7924]}, {"w": "should", "b": [0.2424, 0.771, 0.2991, 0.7924]}, {"w": "be", "b": [0.3038, 0.771, 0.3233, 0.7924]}, {"w": "better).", "b": [0.328, 0.771, 0.3887, 0.7924]}]}, {"id": "b_7", "type": "paragraph", "text": "keras_reg.fit(X_train, y_train, epochs=100, validation_data=(X_valid, y_valid), callbacks=[keras.callbacks.EarlyStopping(patience=10)]) mse_test = keras_reg.score(X_test, y_test) y_pred = keras_reg.predict(X_new)", "words": [{"w": "keras_reg.fit(X_train,", "b": [0.1766, 0.803, 0.3621, 0.8158]}, {"w": "y_train,", "b": [0.3705, 0.803, 0.438, 0.8158]}, {"w": "epochs=100,", "b": [0.4464, 0.803, 0.5392, 0.8158]}, {"w": "validation_data=(X_valid,", "b": [0.2946, 0.8184, 0.5054, 0.8312]}, {"w": "y_valid),", "b": [0.5139, 0.8184, 0.5898, 0.8312]}, {"w": "callbacks=[keras.callbacks.EarlyStopping(patience=10)])", "b": [0.2946, 0.8338, 0.7584, 0.8467]}, {"w": "mse_test", "b": [0.1766, 0.8492, 0.244, 0.8621]}, {"w": "=", "b": [0.2525, 0.8492, 0.2609, 0.8621]}, {"w": "keras_reg.score(X_test,", "b": [0.2693, 0.8492, 0.4633, 0.8621]}, {"w": "y_test)", "b": [0.4717, 0.8492, 0.5307, 0.8621]}, {"w": "y_pred", "b": [0.1766, 0.8647, 0.2272, 0.8775]}, {"w": "=", "b": [0.2356, 0.8647, 0.244, 0.8775]}, {"w": "keras_reg.predict(X_new)", "b": [0.2525, 0.8647, 0.4549, 0.8775]}]}, {"id": "b_8", "type": "paragraph", "text": "316 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "316", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 343, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "However, we do not actually want to train and evaluate a single model like this, we want to train hundreds of variants and see which one performs best on the validation set. Since there are many hyperparameters, it is preferable to use a randomized search rather than grid search (as we discussed in Chapter 2). Let’s try to explore the number of hidden layers, the number of neurons and the learning rate:", "words": [{"w": "However,", "b": [0.1429, 0.0791, 0.2217, 0.1005]}, {"w": "we", "b": [0.2285, 0.0791, 0.2516, 0.1005]}, {"w": "do", "b": [0.2583, 0.0791, 0.2799, 0.1005]}, {"w": "not", "b": [0.2867, 0.0791, 0.3151, 0.1005]}, {"w": "actually", "b": [0.3218, 0.0791, 0.3864, 0.1005]}, {"w": "want", "b": [0.3932, 0.0791, 0.434, 0.1005]}, {"w": "to", "b": [0.4407, 0.0791, 0.4577, 0.1005]}, {"w": "train", "b": [0.4644, 0.0791, 0.5046, 0.1005]}, {"w": "and", "b": [0.5114, 0.0791, 0.5429, 0.1005]}, {"w": "evaluate", "b": [0.5497, 0.0791, 0.6176, 0.1005]}, {"w": "a", "b": [0.6243, 0.0791, 0.6335, 0.1005]}, {"w": "single", "b": [0.6402, 0.0791, 0.6887, 0.1005]}, {"w": "model", "b": [0.6955, 0.0791, 0.7483, 0.1005]}, {"w": "like", "b": [0.755, 0.0791, 0.7851, 0.1005]}, {"w": "this,", "b": [0.7918, 0.0791, 0.8273, 0.1005]}, {"w": "we", "b": [0.834, 0.0791, 0.8571, 0.1005]}, {"w": "want", "b": [0.1429, 0.0981, 0.1836, 0.1195]}, {"w": "to", "b": [0.1889, 0.0981, 0.2058, 0.1195]}, {"w": "train", "b": [0.2111, 0.0981, 0.2513, 0.1195]}, {"w": "hundreds", "b": [0.2565, 0.0981, 0.3359, 0.1195]}, {"w": "of", "b": [0.3412, 0.0981, 0.358, 0.1195]}, {"w": "variants", "b": [0.3632, 0.0981, 0.4294, 0.1195]}, {"w": "and", "b": [0.4347, 0.0981, 0.4662, 0.1195]}, {"w": "see", "b": [0.4715, 0.0981, 0.4968, 0.1195]}, {"w": "which", "b": [0.5021, 0.0981, 0.553, 0.1195]}, {"w": "one", "b": [0.5582, 0.0981, 0.5891, 0.1195]}, {"w": "performs", "b": [0.5943, 0.0981, 0.671, 0.1195]}, {"w": "best", "b": [0.6763, 0.0981, 0.7097, 0.1195]}, {"w": "on", "b": [0.715, 0.0981, 0.737, 0.1195]}, {"w": "the", "b": [0.7422, 0.0981, 0.7685, 0.1195]}, {"w": "validation", "b": [0.7738, 0.0981, 0.8571, 0.1195]}, {"w": "set.", "b": [0.1429, 0.1172, 0.1705, 0.1386]}, {"w": "Since", "b": [0.1754, 0.1172, 0.2199, 0.1386]}, {"w": "there", "b": [0.2248, 0.1172, 0.2677, 0.1386]}, {"w": "are", "b": [0.2726, 0.1172, 0.2983, 0.1386]}, {"w": "many", "b": [0.3032, 0.1172, 0.3499, 0.1386]}, {"w": "hyperparameters,", "b": [0.3548, 0.1172, 0.5006, 0.1386]}, {"w": "it", "b": [0.5055, 0.1172, 0.5175, 0.1386]}, {"w": "is", "b": [0.5224, 0.1172, 0.5356, 0.1386]}, {"w": "preferable", "b": [0.5405, 0.1172, 0.6246, 0.1386]}, {"w": "to", "b": [0.6295, 0.1172, 0.6464, 0.1386]}, {"w": "use", "b": [0.6513, 0.1172, 0.6789, 0.1386]}, {"w": "a", "b": [0.6838, 0.1172, 0.6929, 0.1386]}, {"w": "randomized", "b": [0.6978, 0.1172, 0.799, 0.1386]}, {"w": "search", "b": [0.8038, 0.1172, 0.8572, 0.1386]}, {"w": "rather", "b": [0.1429, 0.1362, 0.1934, 0.1576]}, {"w": "than", "b": [0.1983, 0.1362, 0.2363, 0.1576]}, {"w": "grid", "b": [0.2412, 0.1362, 0.2753, 0.1576]}, {"w": "search", "b": [0.2802, 0.1362, 0.3335, 0.1576]}, {"w": "(as", "b": [0.3384, 0.1362, 0.3624, 0.1576]}, {"w": "we", "b": [0.3672, 0.1362, 0.3904, 0.1576]}, {"w": "discussed", "b": [0.3953, 0.1362, 0.4745, 0.1576]}, {"w": "in", "b": [0.4794, 0.1362, 0.4964, 0.1576]}, {"w": "Chapter", "b": [0.5013, 0.1362, 0.5689, 0.1576]}, {"w": "2).", "b": [0.5736, 0.1362, 0.5957, 0.1576]}, {"w": "Let’s", "b": [0.6006, 0.1362, 0.6368, 0.1576]}, {"w": "try", "b": [0.6417, 0.1362, 0.6659, 0.1576]}, {"w": "to", "b": [0.6708, 0.1362, 0.6878, 0.1576]}, {"w": "explore", "b": [0.6927, 0.1362, 0.7547, 0.1576]}, {"w": "the", "b": [0.7596, 0.1362, 0.786, 0.1576]}, {"w": "number", "b": [0.7909, 0.1362, 0.8572, 0.1576]}, {"w": "of", "b": [0.1429, 0.1553, 0.1597, 0.1767]}, {"w": "hidden", "b": [0.1644, 0.1553, 0.2233, 0.1767]}, {"w": "layers,", "b": [0.2281, 0.1553, 0.2807, 0.1767]}, {"w": "the", "b": [0.2854, 0.1553, 0.3117, 0.1767]}, {"w": "number", "b": [0.3164, 0.1553, 0.3827, 0.1767]}, {"w": "of", "b": [0.3875, 0.1553, 0.4043, 0.1767]}, {"w": "neurons", "b": [0.409, 0.1553, 0.4777, 0.1767]}, {"w": "and", "b": [0.4824, 0.1553, 0.514, 0.1767]}, {"w": "the", "b": [0.5187, 0.1553, 0.545, 0.1767]}, {"w": "learning", "b": [0.5498, 0.1553, 0.6189, 0.1767]}, {"w": "rate:", "b": [0.6236, 0.1553, 0.66, 0.1767]}]}, {"id": "b_1", "type": "paragraph", "text": "from scipy.stats import reciprocal from sklearn.model_selection import RandomizedSearchCV", "words": [{"w": "from", "b": [0.1766, 0.1872, 0.2103, 0.2001]}, {"w": "scipy.stats", "b": [0.2188, 0.1872, 0.3115, 0.2001]}, {"w": "import", "b": [0.3199, 0.1872, 0.3705, 0.2001]}, {"w": "reciprocal", "b": [0.379, 0.1872, 0.4633, 0.2001]}, {"w": "from", "b": [0.1766, 0.2026, 0.2103, 0.2155]}, {"w": "sklearn.model_selection", "b": [0.2188, 0.2026, 0.4127, 0.2155]}, {"w": "import", "b": [0.4211, 0.2026, 0.4717, 0.2155]}, {"w": "RandomizedSearchCV", "b": [0.4802, 0.2026, 0.632, 0.2155]}]}, {"id": "b_2", "type": "paragraph", "text": "param_distribs = { \"n_hidden\": [0, 1, 2, 3], \"n_neurons\": np.arange(1, 100), \"learning_rate\": reciprocal(3e-4, 3e-2), }", "words": [{"w": "param_distribs", "b": [0.1766, 0.2335, 0.2946, 0.2463]}, {"w": "=", "b": [0.3031, 0.2335, 0.3115, 0.2463]}, {"w": "{", "b": [0.3199, 0.2335, 0.3284, 0.2463]}, {"w": "\"n_hidden\":", "b": [0.2103, 0.2489, 0.3031, 0.2618]}, {"w": "[0,", "b": [0.3115, 0.2489, 0.3368, 0.2618]}, {"w": "1,", "b": [0.3452, 0.2489, 0.3621, 0.2618]}, {"w": "2,", "b": [0.3705, 0.2489, 0.3874, 0.2618]}, {"w": "3],", "b": [0.3958, 0.2489, 0.4211, 0.2618]}, {"w": "\"n_neurons\":", "b": [0.2103, 0.2643, 0.3115, 0.2772]}, {"w": "np.arange(1,", "b": [0.3199, 0.2643, 0.4211, 0.2772]}, {"w": "100),", "b": [0.4296, 0.2643, 0.4717, 0.2772]}, {"w": "\"learning_rate\":", "b": [0.2103, 0.2797, 0.3452, 0.2926]}, {"w": "reciprocal(3e-4,", "b": [0.3537, 0.2797, 0.4886, 0.2926]}, {"w": "3e-2),", "b": [0.497, 0.2797, 0.5476, 0.2926]}, {"w": "}", "b": [0.1766, 0.2952, 0.185, 0.308]}]}, {"id": "b_3", "type": "paragraph", "text": "rnd_search_cv = RandomizedSearchCV(keras_reg, param_distribs, n_iter=10, cv=3) rnd_search_cv.fit(X_train, y_train, epochs=100, validation_data=(X_valid, y_valid), callbacks=[keras.callbacks.EarlyStopping(patience=10)])", "words": [{"w": "rnd_search_cv", "b": [0.1766, 0.326, 0.2862, 0.3389]}, {"w": "=", "b": [0.2946, 0.326, 0.3031, 0.3389]}, {"w": "RandomizedSearchCV(keras_reg,", "b": [0.3115, 0.326, 0.5561, 0.3389]}, {"w": "param_distribs,", "b": [0.5645, 0.326, 0.691, 0.3389]}, {"w": "n_iter=10,", "b": [0.6994, 0.326, 0.7837, 0.3389]}, {"w": "cv=3)", "b": [0.7922, 0.326, 0.8343, 0.3389]}, {"w": "rnd_search_cv.fit(X_train,", "b": [0.1766, 0.3414, 0.3958, 0.3543]}, {"w": "y_train,", "b": [0.4043, 0.3414, 0.4717, 0.3543]}, {"w": "epochs=100,", "b": [0.4802, 0.3414, 0.5729, 0.3543]}, {"w": "validation_data=(X_valid,", "b": [0.3284, 0.3568, 0.5392, 0.3697]}, {"w": "y_valid),", "b": [0.5476, 0.3568, 0.6235, 0.3697]}, {"w": "callbacks=[keras.callbacks.EarlyStopping(patience=10)])", "b": [0.3284, 0.3723, 0.7922, 0.3851]}]}, {"id": "b_4", "type": "paragraph", "text": "As you can see, this is identical to what we did in Chapter 2, with the exception that we pass extra parameters to the fit() method: they simply get relayed to the under‐ lying Keras models. Note that RandomizedSearchCV uses K-fold cross-validation, so it does not use X_valid and y_valid. These are just used for early stopping.", "words": [{"w": "As", "b": [0.1429, 0.3929, 0.1649, 0.4143]}, {"w": "you", "b": [0.1708, 0.3929, 0.2021, 0.4143]}, {"w": "can", "b": [0.208, 0.3929, 0.2374, 0.4143]}, {"w": "see,", "b": [0.2433, 0.3929, 0.2734, 0.4143]}, {"w": "this", "b": [0.2794, 0.3929, 0.3101, 0.4143]}, {"w": "is", "b": [0.316, 0.3929, 0.3293, 0.4143]}, {"w": "identical", "b": [0.3352, 0.3929, 0.4068, 0.4143]}, {"w": "to", "b": [0.4127, 0.3929, 0.4297, 0.4143]}, {"w": "what", "b": [0.4357, 0.3929, 0.4762, 0.4143]}, {"w": "we", "b": [0.4821, 0.3929, 0.5052, 0.4143]}, {"w": "did", "b": [0.5112, 0.3929, 0.5388, 0.4143]}, {"w": "in", "b": [0.5447, 0.3929, 0.5617, 0.4143]}, {"w": "Chapter", "b": [0.5676, 0.3929, 0.6352, 0.4143]}, {"w": "2,", "b": [0.6411, 0.3929, 0.6559, 0.4143]}, {"w": "with", "b": [0.6618, 0.3929, 0.6992, 0.4143]}, {"w": "the", "b": [0.7051, 0.3929, 0.7314, 0.4143]}, {"w": "exception", "b": [0.7374, 0.3929, 0.8186, 0.4143]}, {"w": "that", "b": [0.8246, 0.3929, 0.8571, 0.4143]}, {"w": "we", "b": [0.1429, 0.4128, 0.166, 0.4343]}, {"w": "pass", "b": [0.1717, 0.4128, 0.2071, 0.4343]}, {"w": "extra", "b": [0.2128, 0.4128, 0.2548, 0.4343]}, {"w": "parameters", "b": [0.2605, 0.4128, 0.354, 0.4343]}, {"w": "to", "b": [0.3597, 0.4128, 0.3767, 0.4343]}, {"w": "the", "b": [0.3824, 0.4128, 0.4088, 0.4343]}, {"w": "fit()", "b": [0.4145, 0.416, 0.464, 0.4311]}, {"w": "method:", "b": [0.4698, 0.4128, 0.5395, 0.4343]}, {"w": "they", "b": [0.5453, 0.4128, 0.5812, 0.4343]}, {"w": "simply", "b": [0.5869, 0.4128, 0.6426, 0.4343]}, {"w": "get", "b": [0.6483, 0.4128, 0.6733, 0.4343]}, {"w": "relayed", "b": [0.6791, 0.4128, 0.7391, 0.4343]}, {"w": "to", "b": [0.7449, 0.4128, 0.7618, 0.4343]}, {"w": "the", "b": [0.7676, 0.4128, 0.7939, 0.4343]}, {"w": "under‐", "b": [0.7997, 0.4128, 0.8571, 0.4343]}, {"w": "lying", "b": [0.1429, 0.4328, 0.1844, 0.4542]}, {"w": "Keras", "b": [0.1896, 0.4328, 0.2364, 0.4542]}, {"w": "models.", "b": [0.2416, 0.4328, 0.3068, 0.4542]}, {"w": "Note", "b": [0.3119, 0.4328, 0.3527, 0.4542]}, {"w": "that", "b": [0.3578, 0.4328, 0.3904, 0.4542]}, {"w": "RandomizedSearchCV", "b": [0.3955, 0.436, 0.5736, 0.451]}, {"w": "uses", "b": [0.5788, 0.4328, 0.614, 0.4542]}, {"w": "K-fold", "b": [0.6191, 0.4328, 0.6736, 0.4542]}, {"w": "cross-validation,", "b": [0.6787, 0.4328, 0.8167, 0.4542]}, {"w": "so", "b": [0.8218, 0.4328, 0.8401, 0.4542]}, {"w": "it", "b": [0.8452, 0.4328, 0.8571, 0.4542]}, {"w": "does", "b": [0.1429, 0.4527, 0.181, 0.4741]}, {"w": "not", "b": [0.1857, 0.4527, 0.2141, 0.4741]}, {"w": "use", "b": [0.2188, 0.4527, 0.2464, 0.4741]}, {"w": "X_valid", "b": [0.2511, 0.4559, 0.3204, 0.471]}, {"w": "and", "b": [0.3251, 0.4527, 0.3567, 0.4741]}, {"w": "y_valid.", "b": [0.3614, 0.4527, 0.4354, 0.4741]}, {"w": "These", "b": [0.4401, 0.4527, 0.4895, 0.4741]}, {"w": "are", "b": [0.4942, 0.4527, 0.5199, 0.4741]}, {"w": "just", "b": [0.5247, 0.4527, 0.5551, 0.4741]}, {"w": "used", "b": [0.5598, 0.4527, 0.5983, 0.4741]}, {"w": "for", "b": [0.6031, 0.4527, 0.6276, 0.4741]}, {"w": "early", "b": [0.6323, 0.4527, 0.6729, 0.4741]}, {"w": "stopping.", "b": [0.6776, 0.4527, 0.7556, 0.4741]}]}, {"id": "b_5", "type": "paragraph", "text": "The exploration may last many hours depending on the hardware, the size of the dataset, the complexity of the model and the value of n_iter and cv. When it is over, you can access the best parameters found, the best score, and the trained Keras model like this:", "words": [{"w": "The", "b": [0.1429, 0.4808, 0.1757, 0.5023]}, {"w": "exploration", "b": [0.1838, 0.4808, 0.2798, 0.5023]}, {"w": "may", "b": [0.2879, 0.4808, 0.3233, 0.5023]}, {"w": "last", "b": [0.3314, 0.4808, 0.3598, 0.5023]}, {"w": "many", "b": [0.368, 0.4808, 0.4147, 0.5023]}, {"w": "hours", "b": [0.4228, 0.4808, 0.471, 0.5023]}, {"w": "depending", "b": [0.4791, 0.4808, 0.5679, 0.5023]}, {"w": "on", "b": [0.576, 0.4808, 0.598, 0.5023]}, {"w": "the", "b": [0.6061, 0.4808, 0.6325, 0.5023]}, {"w": "hardware,", "b": [0.6406, 0.4808, 0.7243, 0.5023]}, {"w": "the", "b": [0.7325, 0.4808, 0.7588, 0.5023]}, {"w": "size", "b": [0.7669, 0.4808, 0.7978, 0.5023]}, {"w": "of", "b": [0.8059, 0.4808, 0.8227, 0.5023]}, {"w": "the", "b": [0.8308, 0.4808, 0.8572, 0.5023]}, {"w": "dataset,", "b": [0.1429, 0.5008, 0.2057, 0.5222]}, {"w": "the", "b": [0.2111, 0.5008, 0.2374, 0.5222]}, {"w": "complexity", "b": [0.2427, 0.5008, 0.3352, 0.5222]}, {"w": "of", "b": [0.3406, 0.5008, 0.3574, 0.5222]}, {"w": "the", "b": [0.3627, 0.5008, 0.389, 0.5222]}, {"w": "model", "b": [0.3944, 0.5008, 0.4472, 0.5222]}, {"w": "and", "b": [0.4525, 0.5008, 0.4841, 0.5222]}, {"w": "the", "b": [0.4894, 0.5008, 0.5158, 0.5222]}, {"w": "value", "b": [0.5211, 0.5008, 0.5651, 0.5222]}, {"w": "of", "b": [0.5704, 0.5008, 0.5872, 0.5222]}, {"w": "n_iter", "b": [0.5926, 0.504, 0.6519, 0.5191]}, {"w": "and", "b": [0.6573, 0.5008, 0.6888, 0.5222]}, {"w": "cv.", "b": [0.6942, 0.5008, 0.7187, 0.5222]}, {"w": "When", "b": [0.7241, 0.5008, 0.7757, 0.5222]}, {"w": "it", "b": [0.781, 0.5008, 0.7929, 0.5222]}, {"w": "is", "b": [0.7983, 0.5008, 0.8115, 0.5222]}, {"w": "over,", "b": [0.8169, 0.5008, 0.8572, 0.5222]}, {"w": "you", "b": [0.1429, 0.5198, 0.1741, 0.5412]}, {"w": "can", "b": [0.179, 0.5198, 0.2084, 0.5412]}, {"w": "access", "b": [0.2133, 0.5198, 0.2642, 0.5412]}, {"w": "the", "b": [0.2691, 0.5198, 0.2954, 0.5412]}, {"w": "best", "b": [0.3003, 0.5198, 0.3338, 0.5412]}, {"w": "parameters", "b": [0.3387, 0.5198, 0.4321, 0.5412]}, {"w": "found,", "b": [0.437, 0.5198, 0.492, 0.5412]}, {"w": "the", "b": [0.497, 0.5198, 0.5233, 0.5412]}, {"w": "best", "b": [0.5282, 0.5198, 0.5616, 0.5412]}, {"w": "score,", "b": [0.5665, 0.5198, 0.615, 0.5412]}, {"w": "and", "b": [0.6199, 0.5198, 0.6514, 0.5412]}, {"w": "the", "b": [0.6563, 0.5198, 0.6826, 0.5412]}, {"w": "trained", "b": [0.6876, 0.5198, 0.7476, 0.5412]}, {"w": "Keras", "b": [0.7525, 0.5198, 0.7994, 0.5412]}, {"w": "model", "b": [0.8043, 0.5198, 0.8571, 0.5412]}, {"w": "like", "b": [0.1429, 0.5389, 0.1729, 0.5603]}, {"w": "this:", "b": [0.1776, 0.5389, 0.2131, 0.5603]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> rnd_search_cv.best_params_ {'learning_rate': 0.0033625641252688094, 'n_hidden': 2, 'n_neurons': 42} >>> rnd_search_cv.best_score_ -0.3189529188278931 >>> model = rnd_search_cv.best_estimator_.model", "words": [{"w": ">>>", "b": [0.1766, 0.5709, 0.2019, 0.5837]}, {"w": "rnd_search_cv.best_params_", "b": [0.2103, 0.5709, 0.4296, 0.5837]}, {"w": "{'learning_rate':", "b": [0.1766, 0.5863, 0.3199, 0.5991]}, {"w": "0.0033625641252688094,", "b": [0.3284, 0.5863, 0.5139, 0.5991]}, {"w": "'n_hidden':", "b": [0.5223, 0.5863, 0.6151, 0.5991]}, {"w": "2,", "b": [0.6235, 0.5863, 0.6404, 0.5991]}, {"w": "'n_neurons':", "b": [0.6488, 0.5863, 0.75, 0.5991]}, {"w": "42}", "b": [0.7584, 0.5863, 0.7837, 0.5991]}, {"w": ">>>", "b": [0.1766, 0.6017, 0.2019, 0.6145]}, {"w": "rnd_search_cv.best_score_", "b": [0.2103, 0.6017, 0.4211, 0.6145]}, {"w": "-0.3189529188278931", "b": [0.1766, 0.6171, 0.3368, 0.63]}, {"w": ">>>", "b": [0.1766, 0.6325, 0.2019, 0.6454]}, {"w": "model", "b": [0.2103, 0.6325, 0.2525, 0.6454]}, {"w": "=", "b": [0.2609, 0.6325, 0.2693, 0.6454]}, {"w": "rnd_search_cv.best_estimator_.model", "b": [0.2778, 0.6325, 0.5729, 0.6454]}]}, {"id": "b_7", "type": "paragraph", "text": "You can now save this model, evaluate it on the test set, and if you are satisfied with its performance, deploy it to production. Using randomized search is not too hard, and it works well for many fairly simple problems. However, when training is slow (e.g., for more complex problems with larger datasets), this approach will only explore a tiny portion of the hyperparameter space. You can partially alleviate this problem by assisting the search process manually: first run a quick random search using wide ranges of hyperparameter values, then run another search using smaller ranges of values centered on the best ones found during the first run, and so on. This will hopefully zoom in to a good set of hyperparameters. However, this is very time consuming, and probably not the best use of your time.", "words": [{"w": "You", "b": [0.1429, 0.6532, 0.1752, 0.6746]}, {"w": "can", "b": [0.1813, 0.6532, 0.2106, 0.6746]}, {"w": "now", "b": [0.2167, 0.6532, 0.253, 0.6746]}, {"w": "save", "b": [0.259, 0.6532, 0.2939, 0.6746]}, {"w": "this", "b": [0.3, 0.6532, 0.3307, 0.6746]}, {"w": "model,", "b": [0.3367, 0.6532, 0.3943, 0.6746]}, {"w": "evaluate", "b": [0.4003, 0.6532, 0.4683, 0.6746]}, {"w": "it", "b": [0.4743, 0.6532, 0.4863, 0.6746]}, {"w": "on", "b": [0.4923, 0.6532, 0.5143, 0.6746]}, {"w": "the", "b": [0.5204, 0.6532, 0.5467, 0.6746]}, {"w": "test", "b": [0.5528, 0.6532, 0.582, 0.6746]}, {"w": "set,", "b": [0.588, 0.6532, 0.6156, 0.6746]}, {"w": "and", "b": [0.6217, 0.6532, 0.6532, 0.6746]}, {"w": "if", "b": [0.6593, 0.6532, 0.671, 0.6746]}, {"w": "you", "b": [0.6771, 0.6532, 0.7083, 0.6746]}, {"w": "are", "b": [0.7144, 0.6532, 0.7401, 0.6746]}, {"w": "satisfied", "b": [0.7462, 0.6532, 0.8138, 0.6746]}, {"w": "with", "b": [0.8198, 0.6532, 0.8571, 0.6746]}, {"w": "its", "b": [0.1429, 0.6722, 0.1625, 0.6936]}, {"w": "performance,", "b": [0.1693, 0.6722, 0.2814, 0.6936]}, {"w": "deploy", "b": [0.2883, 0.6722, 0.3445, 0.6936]}, {"w": "it", "b": [0.3514, 0.6722, 0.3633, 0.6936]}, {"w": "to", "b": [0.3702, 0.6722, 0.3872, 0.6936]}, {"w": "production.", "b": [0.3941, 0.6722, 0.4929, 0.6936]}, {"w": "Using", "b": [0.4998, 0.6722, 0.5484, 0.6936]}, {"w": "randomized", "b": [0.5553, 0.6722, 0.6564, 0.6936]}, {"w": "search", "b": [0.6633, 0.6722, 0.7166, 0.6936]}, {"w": "is", "b": [0.7235, 0.6722, 0.7368, 0.6936]}, {"w": "not", "b": [0.7437, 0.6722, 0.772, 0.6936]}, {"w": "too", "b": [0.7789, 0.6722, 0.8065, 0.6936]}, {"w": "hard,", "b": [0.8134, 0.6722, 0.8572, 0.6936]}, {"w": "and", "b": [0.1429, 0.6913, 0.1744, 0.7127]}, {"w": "it", "b": [0.1814, 0.6913, 0.1933, 0.7127]}, {"w": "works", "b": [0.2003, 0.6913, 0.2509, 0.7127]}, {"w": "well", "b": [0.2579, 0.6913, 0.2916, 0.7127]}, {"w": "for", "b": [0.2986, 0.6913, 0.3231, 0.7127]}, {"w": "many", "b": [0.3301, 0.6913, 0.3768, 0.7127]}, {"w": "fairly", "b": [0.3838, 0.6913, 0.4273, 0.7127]}, {"w": "simple", "b": [0.4343, 0.6913, 0.4892, 0.7127]}, {"w": "problems.", "b": [0.4962, 0.6913, 0.5797, 0.7127]}, {"w": "However,", "b": [0.5867, 0.6913, 0.6655, 0.7127]}, {"w": "when", "b": [0.6725, 0.6913, 0.7182, 0.7127]}, {"w": "training", "b": [0.7252, 0.6913, 0.7921, 0.7127]}, {"w": "is", "b": [0.7991, 0.6913, 0.8123, 0.7127]}, {"w": "slow", "b": [0.8193, 0.6913, 0.8571, 0.7127]}, {"w": "(e.g.,", "b": [0.1429, 0.7103, 0.1829, 0.7317]}, {"w": "for", "b": [0.1935, 0.7103, 0.218, 0.7317]}, {"w": "more", "b": [0.2286, 0.7103, 0.2728, 0.7317]}, {"w": "complex", "b": [0.2834, 0.7103, 0.3544, 0.7317]}, {"w": "problems", "b": [0.365, 0.7103, 0.4437, 0.7317]}, {"w": "with", "b": [0.4542, 0.7103, 0.4916, 0.7317]}, {"w": "larger", "b": [0.5021, 0.7103, 0.5506, 0.7317]}, {"w": "datasets),", "b": [0.5612, 0.7103, 0.6389, 0.7317]}, {"w": "this", "b": [0.6495, 0.7103, 0.6802, 0.7317]}, {"w": "approach", "b": [0.6907, 0.7103, 0.7688, 0.7317]}, {"w": "will", "b": [0.7793, 0.7103, 0.8097, 0.7317]}, {"w": "only", "b": [0.8203, 0.7103, 0.8571, 0.7317]}, {"w": "explore", "b": [0.1429, 0.7294, 0.2049, 0.7508]}, {"w": "a", "b": [0.2126, 0.7294, 0.2217, 0.7508]}, {"w": "tiny", "b": [0.2293, 0.7294, 0.2618, 0.7508]}, {"w": "portion", "b": [0.2694, 0.7294, 0.3326, 0.7508]}, {"w": "of", "b": [0.3402, 0.7294, 0.357, 0.7508]}, {"w": "the", "b": [0.3647, 0.7294, 0.391, 0.7508]}, {"w": "hyperparameter", "b": [0.3986, 0.7294, 0.5321, 0.7508]}, {"w": "space.", "b": [0.5397, 0.7294, 0.5899, 0.7508]}, {"w": "You", "b": [0.5975, 0.7294, 0.6299, 0.7508]}, {"w": "can", "b": [0.6375, 0.7294, 0.6668, 0.7508]}, {"w": "partially", "b": [0.6745, 0.7294, 0.7434, 0.7508]}, {"w": "alleviate", "b": [0.7511, 0.7294, 0.8188, 0.7508]}, {"w": "this", "b": [0.8264, 0.7294, 0.8571, 0.7508]}, {"w": "problem", "b": [0.1429, 0.7484, 0.2139, 0.7698]}, {"w": "by", "b": [0.2212, 0.7484, 0.2414, 0.7698]}, {"w": "assisting", "b": [0.2487, 0.7484, 0.3195, 0.7698]}, {"w": "the", "b": [0.3268, 0.7484, 0.3531, 0.7698]}, {"w": "search", "b": [0.3605, 0.7484, 0.4138, 0.7698]}, {"w": "process", "b": [0.4211, 0.7484, 0.4834, 0.7698]}, {"w": "manually:", "b": [0.4907, 0.7484, 0.5736, 0.7698]}, {"w": "first", "b": [0.5809, 0.7484, 0.6144, 0.7698]}, {"w": "run", "b": [0.6218, 0.7484, 0.652, 0.7698]}, {"w": "a", "b": [0.6593, 0.7484, 0.6684, 0.7698]}, {"w": "quick", "b": [0.6758, 0.7484, 0.7222, 0.7698]}, {"w": "random", "b": [0.7295, 0.7484, 0.7965, 0.7698]}, {"w": "search", "b": [0.8038, 0.7484, 0.8572, 0.7698]}, {"w": "using", "b": [0.1429, 0.7675, 0.1883, 0.7889]}, {"w": "wide", "b": [0.1951, 0.7675, 0.2348, 0.7889]}, {"w": "ranges", "b": [0.2417, 0.7675, 0.2962, 0.7889]}, {"w": "of", "b": [0.303, 0.7675, 0.3198, 0.7889]}, {"w": "hyperparameter", "b": [0.3266, 0.7675, 0.4601, 0.7889]}, {"w": "values,", "b": [0.4669, 0.7675, 0.5233, 0.7889]}, {"w": "then", "b": [0.5301, 0.7675, 0.5679, 0.7889]}, {"w": "run", "b": [0.5747, 0.7675, 0.6049, 0.7889]}, {"w": "another", "b": [0.6117, 0.7675, 0.6769, 0.7889]}, {"w": "search", "b": [0.6838, 0.7675, 0.7371, 0.7889]}, {"w": "using", "b": [0.7439, 0.7675, 0.7893, 0.7889]}, {"w": "smaller", "b": [0.7962, 0.7675, 0.8571, 0.7889]}, {"w": "ranges", "b": [0.1429, 0.7865, 0.1974, 0.8079]}, {"w": "of", "b": [0.2026, 0.7865, 0.2194, 0.8079]}, {"w": "values", "b": [0.2247, 0.7865, 0.2763, 0.8079]}, {"w": "centered", "b": [0.2816, 0.7865, 0.353, 0.8079]}, {"w": "on", "b": [0.3583, 0.7865, 0.3803, 0.8079]}, {"w": "the", "b": [0.3856, 0.7865, 0.4119, 0.8079]}, {"w": "best", "b": [0.4172, 0.7865, 0.4506, 0.8079]}, {"w": "ones", "b": [0.4559, 0.7865, 0.4944, 0.8079]}, {"w": "found", "b": [0.4997, 0.7865, 0.5499, 0.8079]}, {"w": "during", "b": [0.5552, 0.7865, 0.6117, 0.8079]}, {"w": "the", "b": [0.617, 0.7865, 0.6433, 0.8079]}, {"w": "first", "b": [0.6486, 0.7865, 0.6821, 0.8079]}, {"w": "run,", "b": [0.6873, 0.7865, 0.7223, 0.8079]}, {"w": "and", "b": [0.7275, 0.7865, 0.7591, 0.8079]}, {"w": "so", "b": [0.7644, 0.7865, 0.7826, 0.8079]}, {"w": "on.", "b": [0.7879, 0.7865, 0.8147, 0.8079]}, {"w": "This", "b": [0.8199, 0.7865, 0.8571, 0.8079]}, {"w": "will", "b": [0.1429, 0.8056, 0.1733, 0.827]}, {"w": "hopefully", "b": [0.1797, 0.8056, 0.2586, 0.827]}, {"w": "zoom", "b": [0.265, 0.8056, 0.3121, 0.827]}, {"w": "in", "b": [0.3185, 0.8056, 0.3355, 0.827]}, {"w": "to", "b": [0.342, 0.8056, 0.3589, 0.827]}, {"w": "a", "b": [0.3654, 0.8056, 0.3745, 0.827]}, {"w": "good", "b": [0.381, 0.8056, 0.423, 0.827]}, {"w": "set", "b": [0.4294, 0.8056, 0.4523, 0.827]}, {"w": "of", "b": [0.4587, 0.8056, 0.4755, 0.827]}, {"w": "hyperparameters.", "b": [0.482, 0.8056, 0.6279, 0.827]}, {"w": "However,", "b": [0.6343, 0.8056, 0.7132, 0.827]}, {"w": "this", "b": [0.7196, 0.8056, 0.7503, 0.827]}, {"w": "is", "b": [0.7568, 0.8056, 0.77, 0.827]}, {"w": "very", "b": [0.7765, 0.8056, 0.8129, 0.827]}, {"w": "time", "b": [0.8193, 0.8056, 0.8572, 0.827]}, {"w": "consuming,", "b": [0.1429, 0.8246, 0.2409, 0.846]}, {"w": "and", "b": [0.2457, 0.8246, 0.2772, 0.846]}, {"w": "probably", "b": [0.2819, 0.8246, 0.3564, 0.846]}, {"w": "not", "b": [0.3611, 0.8246, 0.3895, 0.846]}, {"w": "the", "b": [0.3942, 0.8246, 0.4205, 0.846]}, {"w": "best", "b": [0.4253, 0.8246, 0.4587, 0.846]}, {"w": "use", "b": [0.4634, 0.8246, 0.491, 0.846]}, {"w": "of", "b": [0.4957, 0.8246, 0.5125, 0.846]}, {"w": "your", "b": [0.5172, 0.8246, 0.5562, 0.846]}, {"w": "time.", "b": [0.5609, 0.8246, 0.6036, 0.846]}]}, {"id": "b_8", "type": "paragraph", "text": "Fortunately, there are many techniques to explore a search space much more effi‐ ciently than randomly. Their core idea is simple: when a region of the space turns out", "words": [{"w": "Fortunately,", "b": [0.1429, 0.8527, 0.2427, 0.8741]}, {"w": "there", "b": [0.2507, 0.8527, 0.2936, 0.8741]}, {"w": "are", "b": [0.3016, 0.8527, 0.3273, 0.8741]}, {"w": "many", "b": [0.3353, 0.8527, 0.382, 0.8741]}, {"w": "techniques", "b": [0.3899, 0.8527, 0.4803, 0.8741]}, {"w": "to", "b": [0.4883, 0.8527, 0.5052, 0.8741]}, {"w": "explore", "b": [0.5132, 0.8527, 0.5753, 0.8741]}, {"w": "a", "b": [0.5833, 0.8527, 0.5924, 0.8741]}, {"w": "search", "b": [0.6004, 0.8527, 0.6537, 0.8741]}, {"w": "space", "b": [0.6617, 0.8527, 0.7071, 0.8741]}, {"w": "much", "b": [0.7151, 0.8527, 0.7627, 0.8741]}, {"w": "more", "b": [0.7707, 0.8527, 0.815, 0.8741]}, {"w": "effi‐", "b": [0.823, 0.8527, 0.8571, 0.8741]}, {"w": "ciently", "b": [0.1429, 0.8718, 0.1983, 0.8932]}, {"w": "than", "b": [0.2034, 0.8718, 0.2414, 0.8932]}, {"w": "randomly.", "b": [0.2465, 0.8718, 0.3316, 0.8932]}, {"w": "Their", "b": [0.3367, 0.8718, 0.3828, 0.8932]}, {"w": "core", "b": [0.3879, 0.8718, 0.424, 0.8932]}, {"w": "idea", "b": [0.4291, 0.8718, 0.4636, 0.8932]}, {"w": "is", "b": [0.4688, 0.8718, 0.482, 0.8932]}, {"w": "simple:", "b": [0.4871, 0.8718, 0.5468, 0.8932]}, {"w": "when", "b": [0.5519, 0.8718, 0.5975, 0.8932]}, {"w": "a", "b": [0.6027, 0.8718, 0.6118, 0.8932]}, {"w": "region", "b": [0.6169, 0.8718, 0.6709, 0.8932]}, {"w": "of", "b": [0.676, 0.8718, 0.6928, 0.8932]}, {"w": "the", "b": [0.6979, 0.8718, 0.7242, 0.8932]}, {"w": "space", "b": [0.7293, 0.8718, 0.7747, 0.8932]}, {"w": "turns", "b": [0.7798, 0.8718, 0.824, 0.8932]}, {"w": "out", "b": [0.8291, 0.8718, 0.8571, 0.8932]}]}, {"id": "b_9", "type": "equation", "text": "Fine-Tuning Neural Network Hyperparameters | 317", "words": [{"w": "Fine-Tuning", "b": [0.5239, 0.9225, 0.5948, 0.9388]}, {"w": "Neural", "b": [0.5976, 0.9225, 0.6368, 0.9388]}, {"w": "Network", "b": [0.6396, 0.9225, 0.6903, 0.9388]}, {"w": "Hyperparameters", "b": [0.6931, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "317", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 344, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "16 “Population Based Training of Neural Networks,” Max Jaderberg et al. (2017).", "words": [{"w": "16", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Population", "b": [0.1587, 0.8749, 0.2349, 0.8912]}, {"w": "Based", "b": [0.2385, 0.8749, 0.2757, 0.8912]}, {"w": "Training", "b": [0.2793, 0.8749, 0.334, 0.8912]}, {"w": "of", "b": [0.3376, 0.8749, 0.3504, 0.8912]}, {"w": "Neural", "b": [0.354, 0.8749, 0.3974, 0.8912]}, {"w": "Networks,”", "b": [0.401, 0.8749, 0.4703, 0.8912]}, {"w": "Max", "b": [0.474, 0.8749, 0.5023, 0.8912]}, {"w": "Jaderberg", "b": [0.5059, 0.8749, 0.5668, 0.8912]}, {"w": "et", "b": [0.5704, 0.8749, 0.582, 0.8912]}, {"w": "al.", "b": [0.5856, 0.8749, 0.6002, 0.8912]}, {"w": "(2017).", "b": [0.6038, 0.8749, 0.6489, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "to be good, it should be explored more. This takes care of the “zooming” process for you and leads to much better solutions in much less time. Here are a few Python libraries you can use to optimize hyperparameters:", "words": [{"w": "to", "b": [0.1429, 0.0791, 0.1598, 0.1005]}, {"w": "be", "b": [0.1657, 0.0791, 0.1851, 0.1005]}, {"w": "good,", "b": [0.1909, 0.0791, 0.2377, 0.1005]}, {"w": "it", "b": [0.2435, 0.0791, 0.2555, 0.1005]}, {"w": "should", "b": [0.2613, 0.0791, 0.318, 0.1005]}, {"w": "be", "b": [0.3238, 0.0791, 0.3433, 0.1005]}, {"w": "explored", "b": [0.3491, 0.0791, 0.4222, 0.1005]}, {"w": "more.", "b": [0.428, 0.0791, 0.477, 0.1005]}, {"w": "This", "b": [0.4829, 0.0791, 0.5201, 0.1005]}, {"w": "takes", "b": [0.5259, 0.0791, 0.5682, 0.1005]}, {"w": "care", "b": [0.5741, 0.0791, 0.6086, 0.1005]}, {"w": "of", "b": [0.6144, 0.0791, 0.6312, 0.1005]}, {"w": "the", "b": [0.6371, 0.0791, 0.6634, 0.1005]}, {"w": "“zooming”", "b": [0.6692, 0.0791, 0.7587, 0.1005]}, {"w": "process", "b": [0.7646, 0.0791, 0.8268, 0.1005]}, {"w": "for", "b": [0.8326, 0.0791, 0.8571, 0.1005]}, {"w": "you", "b": [0.1429, 0.0981, 0.1741, 0.1195]}, {"w": "and", "b": [0.1819, 0.0981, 0.2135, 0.1195]}, {"w": "leads", "b": [0.2213, 0.0981, 0.2632, 0.1195]}, {"w": "to", "b": [0.2711, 0.0981, 0.288, 0.1195]}, {"w": "much", "b": [0.2959, 0.0981, 0.3435, 0.1195]}, {"w": "better", "b": [0.3514, 0.0981, 0.4001, 0.1195]}, {"w": "solutions", "b": [0.4079, 0.0981, 0.4841, 0.1195]}, {"w": "in", "b": [0.492, 0.0981, 0.509, 0.1195]}, {"w": "much", "b": [0.5168, 0.0981, 0.5645, 0.1195]}, {"w": "less", "b": [0.5723, 0.0981, 0.6017, 0.1195]}, {"w": "time.", "b": [0.6095, 0.0981, 0.6521, 0.1195]}, {"w": "Here", "b": [0.66, 0.0981, 0.7008, 0.1195]}, {"w": "are", "b": [0.7087, 0.0981, 0.7344, 0.1195]}, {"w": "a", "b": [0.7422, 0.0981, 0.7514, 0.1195]}, {"w": "few", "b": [0.7592, 0.0981, 0.7885, 0.1195]}, {"w": "Python", "b": [0.7963, 0.0981, 0.8571, 0.1195]}, {"w": "libraries", "b": [0.1429, 0.1172, 0.211, 0.1386]}, {"w": "you", "b": [0.2157, 0.1172, 0.247, 0.1386]}, {"w": "can", "b": [0.2517, 0.1172, 0.2811, 0.1386]}, {"w": "use", "b": [0.2858, 0.1172, 0.3133, 0.1386]}, {"w": "to", "b": [0.3181, 0.1172, 0.3351, 0.1386]}, {"w": "optimize", "b": [0.3398, 0.1172, 0.4135, 0.1386]}, {"w": "hyperparameters:", "b": [0.4182, 0.1172, 0.5641, 0.1386]}]}, {"id": "b_2", "type": "paragraph", "text": "• Hyperopt: a popular Python library for optimizing over all sorts of complex search spaces (including real values such as the learning rate, or discrete values such as the number of layers).", "words": [{"w": "•", "b": [0.16, 0.1513, 0.1682, 0.1727]}, {"w": "Hyperopt:", "b": [0.1786, 0.1513, 0.2635, 0.1727]}, {"w": "a", "b": [0.2728, 0.1513, 0.2819, 0.1727]}, {"w": "popular", "b": [0.2911, 0.1513, 0.3568, 0.1727]}, {"w": "Python", "b": [0.366, 0.1513, 0.4268, 0.1727]}, {"w": "library", "b": [0.436, 0.1513, 0.4922, 0.1727]}, {"w": "for", "b": [0.5014, 0.1513, 0.5259, 0.1727]}, {"w": "optimizing", "b": [0.5352, 0.1513, 0.6268, 0.1727]}, {"w": "over", "b": [0.636, 0.1513, 0.6728, 0.1727]}, {"w": "all", "b": [0.682, 0.1513, 0.7017, 0.1727]}, {"w": "sorts", "b": [0.7109, 0.1513, 0.7509, 0.1727]}, {"w": "of", "b": [0.7602, 0.1513, 0.7769, 0.1727]}, {"w": "complex", "b": [0.7862, 0.1513, 0.8571, 0.1727]}, {"w": "search", "b": [0.1786, 0.1704, 0.2319, 0.1918]}, {"w": "spaces", "b": [0.2386, 0.1704, 0.2916, 0.1918]}, {"w": "(including", "b": [0.2983, 0.1704, 0.3854, 0.1918]}, {"w": "real", "b": [0.3921, 0.1704, 0.4231, 0.1918]}, {"w": "values", "b": [0.4298, 0.1704, 0.4814, 0.1918]}, {"w": "such", "b": [0.4881, 0.1704, 0.5267, 0.1918]}, {"w": "as", "b": [0.5334, 0.1704, 0.5502, 0.1918]}, {"w": "the", "b": [0.5569, 0.1704, 0.5833, 0.1918]}, {"w": "learning", "b": [0.59, 0.1704, 0.6591, 0.1918]}, {"w": "rate,", "b": [0.6658, 0.1704, 0.7022, 0.1918]}, {"w": "or", "b": [0.7089, 0.1704, 0.7273, 0.1918]}, {"w": "discrete", "b": [0.734, 0.1704, 0.7988, 0.1918]}, {"w": "values", "b": [0.8055, 0.1704, 0.8571, 0.1918]}, {"w": "such", "b": [0.1786, 0.1894, 0.2172, 0.2108]}, {"w": "as", "b": [0.2219, 0.1894, 0.2387, 0.2108]}, {"w": "the", "b": [0.2435, 0.1894, 0.2698, 0.2108]}, {"w": "number", "b": [0.2745, 0.1894, 0.3408, 0.2108]}, {"w": "of", "b": [0.3455, 0.1894, 0.3623, 0.2108]}, {"w": "layers).", "b": [0.3671, 0.1894, 0.4269, 0.2108]}]}, {"id": "b_3", "type": "paragraph", "text": "• Hyperas, kopt or Talos: optimizing hyperparameters for Keras model (the first two are based on Hyperopt).", "words": [{"w": "•", "b": [0.16, 0.2145, 0.1682, 0.2359]}, {"w": "Hyperas,", "b": [0.1786, 0.2145, 0.2524, 0.2359]}, {"w": "kopt", "b": [0.26, 0.2145, 0.2982, 0.2359]}, {"w": "or", "b": [0.3058, 0.2145, 0.3242, 0.2359]}, {"w": "Talos:", "b": [0.3317, 0.2145, 0.3801, 0.2359]}, {"w": "optimizing", "b": [0.3877, 0.2145, 0.4793, 0.2359]}, {"w": "hyperparameters", "b": [0.4869, 0.2145, 0.628, 0.2359]}, {"w": "for", "b": [0.6356, 0.2145, 0.6601, 0.2359]}, {"w": "Keras", "b": [0.6677, 0.2145, 0.7146, 0.2359]}, {"w": "model", "b": [0.7222, 0.2145, 0.775, 0.2359]}, {"w": "(the", "b": [0.7825, 0.2145, 0.8161, 0.2359]}, {"w": "first", "b": [0.8237, 0.2145, 0.8571, 0.2359]}, {"w": "two", "b": [0.1786, 0.2336, 0.2098, 0.255]}, {"w": "are", "b": [0.2146, 0.2336, 0.2403, 0.255]}, {"w": "based", "b": [0.245, 0.2336, 0.2922, 0.255]}, {"w": "on", "b": [0.297, 0.2336, 0.319, 0.255]}, {"w": "Hyperopt).", "b": [0.3237, 0.2336, 0.4159, 0.255]}]}, {"id": "b_4", "type": "paragraph", "text": "• Scikit-Optimize (skopt): a general-purpose optimization library. The Bayes SearchCV class performs Bayesian optimization using an interface similar to Grid SearchCV.", "words": [{"w": "•", "b": [0.16, 0.2595, 0.1682, 0.281]}, {"w": "Scikit-Optimize", "b": [0.1786, 0.2596, 0.3112, 0.281]}, {"w": "(skopt):", "b": [0.3226, 0.2596, 0.3876, 0.281]}, {"w": "a", "b": [0.3991, 0.2596, 0.4082, 0.281]}, {"w": "general-purpose", "b": [0.4196, 0.2596, 0.5558, 0.281]}, {"w": "optimization", "b": [0.5672, 0.2596, 0.6748, 0.281]}, {"w": "library.", "b": [0.6862, 0.2596, 0.7456, 0.281]}, {"w": "The", "b": [0.7571, 0.2596, 0.7899, 0.281]}, {"w": "Bayes", "b": [0.8013, 0.2627, 0.8508, 0.2778]}, {"w": "SearchCV", "b": [0.1786, 0.2827, 0.2577, 0.2978]}, {"w": "class", "b": [0.2627, 0.2795, 0.3013, 0.3009]}, {"w": "performs", "b": [0.3063, 0.2795, 0.383, 0.3009]}, {"w": "Bayesian", "b": [0.388, 0.2795, 0.4612, 0.3009]}, {"w": "optimization", "b": [0.4662, 0.2795, 0.5738, 0.3009]}, {"w": "using", "b": [0.5788, 0.2795, 0.6242, 0.3009]}, {"w": "an", "b": [0.6292, 0.2795, 0.6498, 0.3009]}, {"w": "interface", "b": [0.6548, 0.2795, 0.7273, 0.3009]}, {"w": "similar", "b": [0.7323, 0.2795, 0.7903, 0.3009]}, {"w": "to", "b": [0.7953, 0.2795, 0.8123, 0.3009]}, {"w": "Grid", "b": [0.8173, 0.2827, 0.8569, 0.2978]}, {"w": "SearchCV.", "b": [0.1786, 0.2994, 0.2625, 0.3209]}]}, {"id": "b_5", "type": "paragraph", "text": "• Spearmint: a Bayesian optimization library.", "words": [{"w": "•", "b": [0.16, 0.3245, 0.1682, 0.3459]}, {"w": "Spearmint:", "b": [0.1786, 0.3245, 0.2698, 0.3459]}, {"w": "a", "b": [0.2746, 0.3245, 0.2837, 0.3459]}, {"w": "Bayesian", "b": [0.2884, 0.3245, 0.3616, 0.3459]}, {"w": "optimization", "b": [0.3664, 0.3245, 0.474, 0.3459]}, {"w": "library.", "b": [0.4787, 0.3245, 0.5381, 0.3459]}]}, {"id": "b_6", "type": "paragraph", "text": "• Sklearn-Deap: a hyperparameter optimization library based on evolutionary algorithms, also with a GridSearchCV-like interface.", "words": [{"w": "•", "b": [0.16, 0.3496, 0.1682, 0.371]}, {"w": "Sklearn-Deap:", "b": [0.1786, 0.3496, 0.2972, 0.371]}, {"w": "a", "b": [0.3083, 0.3496, 0.3174, 0.371]}, {"w": "hyperparameter", "b": [0.3286, 0.3496, 0.4621, 0.371]}, {"w": "optimization", "b": [0.4732, 0.3496, 0.5808, 0.371]}, {"w": "library", "b": [0.5919, 0.3496, 0.6481, 0.371]}, {"w": "based", "b": [0.6592, 0.3496, 0.7064, 0.371]}, {"w": "on", "b": [0.7175, 0.3496, 0.7396, 0.371]}, {"w": "evolutionary", "b": [0.7507, 0.3496, 0.8571, 0.371]}, {"w": "algorithms,", "b": [0.1786, 0.3696, 0.2736, 0.391]}, {"w": "also", "b": [0.2783, 0.3696, 0.311, 0.391]}, {"w": "with", "b": [0.3158, 0.3696, 0.3531, 0.391]}, {"w": "a", "b": [0.3578, 0.3696, 0.367, 0.391]}, {"w": "GridSearchCV-like", "b": [0.3717, 0.3696, 0.5279, 0.391]}, {"w": "interface.", "b": [0.5326, 0.3696, 0.6099, 0.391]}]}, {"id": "b_7", "type": "paragraph", "text": "• And many more!", "words": [{"w": "•", "b": [0.16, 0.3947, 0.1682, 0.4161]}, {"w": "And", "b": [0.1786, 0.3947, 0.2154, 0.4161]}, {"w": "many", "b": [0.2201, 0.3947, 0.2668, 0.4161]}, {"w": "more!", "b": [0.2715, 0.3947, 0.3215, 0.4161]}]}, {"id": "b_8", "type": "paragraph", "text": "Moreover, many companies offer services for hyperparameter optimization. For example Google Cloud ML Engine has a hyperparameter tuning service. Other com‐ panies provide APIs for hyperparameter optimization, such as Arimo, SigOpt, Oscar and many more.", "words": [{"w": "Moreover,", "b": [0.1429, 0.4288, 0.2284, 0.4502]}, {"w": "many", "b": [0.2394, 0.4288, 0.2861, 0.4502]}, {"w": "companies", "b": [0.2971, 0.4288, 0.3868, 0.4502]}, {"w": "offer", "b": [0.3978, 0.4288, 0.4373, 0.4502]}, {"w": "services", "b": [0.4483, 0.4288, 0.5137, 0.4502]}, {"w": "for", "b": [0.5247, 0.4288, 0.5493, 0.4502]}, {"w": "hyperparameter", "b": [0.5603, 0.4288, 0.6938, 0.4502]}, {"w": "optimization.", "b": [0.7048, 0.4288, 0.8171, 0.4502]}, {"w": "For", "b": [0.8282, 0.4288, 0.8571, 0.4502]}, {"w": "example", "b": [0.1429, 0.4479, 0.2124, 0.4693]}, {"w": "Google", "b": [0.218, 0.4479, 0.2781, 0.4693]}, {"w": "Cloud", "b": [0.2837, 0.4479, 0.3355, 0.4693]}, {"w": "ML", "b": [0.3412, 0.4479, 0.371, 0.4693]}, {"w": "Engine", "b": [0.3766, 0.4479, 0.4354, 0.4693]}, {"w": "has", "b": [0.4411, 0.4479, 0.469, 0.4693]}, {"w": "a", "b": [0.4747, 0.4479, 0.4838, 0.4693]}, {"w": "hyperparameter", "b": [0.4895, 0.4479, 0.623, 0.4693]}, {"w": "tuning", "b": [0.6286, 0.4479, 0.6842, 0.4693]}, {"w": "service.", "b": [0.6898, 0.4479, 0.7523, 0.4693]}, {"w": "Other", "b": [0.7579, 0.4479, 0.8076, 0.4693]}, {"w": "com‐", "b": [0.8132, 0.4479, 0.8571, 0.4693]}, {"w": "panies", "b": [0.1429, 0.4669, 0.1964, 0.4883]}, {"w": "provide", "b": [0.2022, 0.4669, 0.2666, 0.4883]}, {"w": "APIs", "b": [0.2724, 0.4669, 0.3128, 0.4883]}, {"w": "for", "b": [0.3187, 0.4669, 0.3432, 0.4883]}, {"w": "hyperparameter", "b": [0.349, 0.4669, 0.4825, 0.4883]}, {"w": "optimization,", "b": [0.4884, 0.4669, 0.6007, 0.4883]}, {"w": "such", "b": [0.6065, 0.4669, 0.6452, 0.4883]}, {"w": "as", "b": [0.651, 0.4669, 0.6678, 0.4883]}, {"w": "Arimo,", "b": [0.6736, 0.4669, 0.7338, 0.4883]}, {"w": "SigOpt,", "b": [0.7396, 0.4669, 0.8024, 0.4883]}, {"w": "Oscar", "b": [0.8083, 0.4669, 0.8572, 0.4883]}, {"w": "and", "b": [0.1429, 0.486, 0.1744, 0.5074]}, {"w": "many", "b": [0.1791, 0.486, 0.2258, 0.5074]}, {"w": "more.", "b": [0.2305, 0.486, 0.2796, 0.5074]}]}, {"id": "b_9", "type": "paragraph", "text": "Hyperparameter tuning is still an active area of research. Evolutionary algorithms are making a comeback lately. For example, check out DeepMind’s excellent 2017 paper16, where they jointly optimize a population of models and their hyperparameters. Goo‐ gle also used an evolutionary approach, not just to search for hyperparameters, but also to look for the best neural network architecture for the problem. They call this AutoML, and it is already available as a cloud service. Perhaps the days of building neural networks manually will soon be over? Check out Google’s post on this topic. In fact, evolutionary algorithms have also been used successfully to train individual neu‐ ral networks, replacing the ubiquitous Gradient Descent! See this 2017 post by Uber where they introduce their Deep Neuroevolution technique.", "words": [{"w": "Hyperparameter", "b": [0.1429, 0.5141, 0.281, 0.5355]}, {"w": "tuning", "b": [0.2862, 0.5141, 0.3417, 0.5355]}, {"w": "is", "b": [0.3469, 0.5141, 0.3601, 0.5355]}, {"w": "still", "b": [0.3653, 0.5141, 0.3954, 0.5355]}, {"w": "an", "b": [0.4006, 0.5141, 0.4211, 0.5355]}, {"w": "active", "b": [0.4263, 0.5141, 0.4747, 0.5355]}, {"w": "area", "b": [0.4799, 0.5141, 0.5148, 0.5355]}, {"w": "of", "b": [0.52, 0.5141, 0.5367, 0.5355]}, {"w": "research.", "b": [0.5419, 0.5141, 0.6166, 0.5355]}, {"w": "Evolutionary", "b": [0.6217, 0.5141, 0.7308, 0.5355]}, {"w": "algorithms", "b": [0.7359, 0.5141, 0.8262, 0.5355]}, {"w": "are", "b": [0.8314, 0.5141, 0.8571, 0.5355]}, {"w": "making", "b": [0.1429, 0.5331, 0.2061, 0.5546]}, {"w": "a", "b": [0.2111, 0.5331, 0.2202, 0.5546]}, {"w": "comeback", "b": [0.2252, 0.5331, 0.3094, 0.5546]}, {"w": "lately.", "b": [0.3143, 0.5331, 0.3616, 0.5546]}, {"w": "For", "b": [0.3666, 0.5331, 0.3956, 0.5546]}, {"w": "example,", "b": [0.4005, 0.5331, 0.4748, 0.5546]}, {"w": "check", "b": [0.4797, 0.5331, 0.5277, 0.5546]}, {"w": "out", "b": [0.5326, 0.5331, 0.5607, 0.5546]}, {"w": "DeepMind’s", "b": [0.5656, 0.5331, 0.6659, 0.5546]}, {"w": "excellent", "b": [0.6708, 0.5331, 0.7439, 0.5546]}, {"w": "2017", "b": [0.7489, 0.5331, 0.7889, 0.5546]}, {"w": "paper16,", "b": [0.7936, 0.5331, 0.8571, 0.5546]}, {"w": "where", "b": [0.1429, 0.5522, 0.1937, 0.5736]}, {"w": "they", "b": [0.1993, 0.5522, 0.2352, 0.5736]}, {"w": "jointly", "b": [0.2408, 0.5522, 0.2945, 0.5736]}, {"w": "optimize", "b": [0.3001, 0.5522, 0.3738, 0.5736]}, {"w": "a", "b": [0.3794, 0.5522, 0.3886, 0.5736]}, {"w": "population", "b": [0.3942, 0.5522, 0.4857, 0.5736]}, {"w": "of", "b": [0.4913, 0.5522, 0.5081, 0.5736]}, {"w": "models", "b": [0.5137, 0.5522, 0.5741, 0.5736]}, {"w": "and", "b": [0.5797, 0.5522, 0.6113, 0.5736]}, {"w": "their", "b": [0.6169, 0.5522, 0.6565, 0.5736]}, {"w": "hyperparameters.", "b": [0.6621, 0.5522, 0.808, 0.5736]}, {"w": "Goo‐", "b": [0.8136, 0.5522, 0.8572, 0.5736]}, {"w": "gle", "b": [0.1429, 0.5712, 0.1667, 0.5926]}, {"w": "also", "b": [0.1736, 0.5712, 0.2063, 0.5926]}, {"w": "used", "b": [0.2131, 0.5712, 0.2516, 0.5926]}, {"w": "an", "b": [0.2585, 0.5712, 0.279, 0.5926]}, {"w": "evolutionary", "b": [0.2858, 0.5712, 0.3923, 0.5926]}, {"w": "approach,", "b": [0.3991, 0.5712, 0.4819, 0.5926]}, {"w": "not", "b": [0.4887, 0.5712, 0.5171, 0.5926]}, {"w": "just", "b": [0.5239, 0.5712, 0.5543, 0.5926]}, {"w": "to", "b": [0.5611, 0.5712, 0.5781, 0.5926]}, {"w": "search", "b": [0.5849, 0.5712, 0.6383, 0.5926]}, {"w": "for", "b": [0.6451, 0.5712, 0.6696, 0.5926]}, {"w": "hyperparameters,", "b": [0.6764, 0.5712, 0.8223, 0.5926]}, {"w": "but", "b": [0.8292, 0.5712, 0.8572, 0.5926]}, {"w": "also", "b": [0.1429, 0.5903, 0.1755, 0.6117]}, {"w": "to", "b": [0.1821, 0.5903, 0.1991, 0.6117]}, {"w": "look", "b": [0.2056, 0.5903, 0.2425, 0.6117]}, {"w": "for", "b": [0.249, 0.5903, 0.2736, 0.6117]}, {"w": "the", "b": [0.2801, 0.5903, 0.3065, 0.6117]}, {"w": "best", "b": [0.313, 0.5903, 0.3465, 0.6117]}, {"w": "neural", "b": [0.353, 0.5903, 0.4065, 0.6117]}, {"w": "network", "b": [0.413, 0.5903, 0.4826, 0.6117]}, {"w": "architecture", "b": [0.4891, 0.5903, 0.5896, 0.6117]}, {"w": "for", "b": [0.5961, 0.5903, 0.6206, 0.6117]}, {"w": "the", "b": [0.6272, 0.5903, 0.6535, 0.6117]}, {"w": "problem.", "b": [0.6601, 0.5903, 0.7359, 0.6117]}, {"w": "They", "b": [0.7424, 0.5903, 0.7848, 0.6117]}, {"w": "call", "b": [0.7914, 0.5903, 0.8199, 0.6117]}, {"w": "this", "b": [0.8264, 0.5903, 0.8571, 0.6117]}, {"w": "AutoML,", "b": [0.1429, 0.6091, 0.2176, 0.6307]}, {"w": "and", "b": [0.2246, 0.6093, 0.2561, 0.6307]}, {"w": "it", "b": [0.2631, 0.6093, 0.2751, 0.6307]}, {"w": "is", "b": [0.2821, 0.6093, 0.2953, 0.6307]}, {"w": "already", "b": [0.3024, 0.6093, 0.3631, 0.6307]}, {"w": "available", "b": [0.3701, 0.6093, 0.4424, 0.6307]}, {"w": "as", "b": [0.4494, 0.6093, 0.4662, 0.6307]}, {"w": "a", "b": [0.4732, 0.6093, 0.4823, 0.6307]}, {"w": "cloud", "b": [0.4893, 0.6093, 0.5361, 0.6307]}, {"w": "service.", "b": [0.5431, 0.6093, 0.6056, 0.6307]}, {"w": "Perhaps", "b": [0.6126, 0.6093, 0.6787, 0.6307]}, {"w": "the", "b": [0.6857, 0.6093, 0.7121, 0.6307]}, {"w": "days", "b": [0.7191, 0.6093, 0.7561, 0.6307]}, {"w": "of", "b": [0.7631, 0.6093, 0.7799, 0.6307]}, {"w": "building", "b": [0.7869, 0.6093, 0.8571, 0.6307]}, {"w": "neural", "b": [0.1429, 0.6284, 0.1963, 0.6498]}, {"w": "networks", "b": [0.2011, 0.6284, 0.2783, 0.6498]}, {"w": "manually", "b": [0.2831, 0.6284, 0.3607, 0.6498]}, {"w": "will", "b": [0.3655, 0.6284, 0.3959, 0.6498]}, {"w": "soon", "b": [0.4007, 0.6284, 0.441, 0.6498]}, {"w": "be", "b": [0.4458, 0.6284, 0.4652, 0.6498]}, {"w": "over?", "b": [0.47, 0.6284, 0.5148, 0.6498]}, {"w": "Check", "b": [0.5196, 0.6284, 0.5725, 0.6498]}, {"w": "out", "b": [0.5773, 0.6284, 0.6054, 0.6498]}, {"w": "Google’s", "b": [0.6102, 0.6284, 0.6793, 0.6498]}, {"w": "post", "b": [0.6841, 0.6284, 0.7197, 0.6498]}, {"w": "on", "b": [0.7245, 0.6284, 0.7465, 0.6498]}, {"w": "this", "b": [0.7512, 0.6284, 0.7819, 0.6498]}, {"w": "topic.", "b": [0.7866, 0.6284, 0.8337, 0.6498]}, {"w": "In", "b": [0.8384, 0.6284, 0.8569, 0.6498]}, {"w": "fact,", "b": [0.1429, 0.6474, 0.1781, 0.6688]}, {"w": "evolutionary", "b": [0.183, 0.6474, 0.2894, 0.6688]}, {"w": "algorithms", "b": [0.2944, 0.6474, 0.3846, 0.6688]}, {"w": "have", "b": [0.3896, 0.6474, 0.4279, 0.6688]}, {"w": "also", "b": [0.4329, 0.6474, 0.4655, 0.6688]}, {"w": "been", "b": [0.4704, 0.6474, 0.5101, 0.6688]}, {"w": "used", "b": [0.515, 0.6474, 0.5536, 0.6688]}, {"w": "successfully", "b": [0.5585, 0.6474, 0.6563, 0.6688]}, {"w": "to", "b": [0.6612, 0.6474, 0.6782, 0.6688]}, {"w": "train", "b": [0.6831, 0.6474, 0.7233, 0.6688]}, {"w": "individual", "b": [0.7282, 0.6474, 0.8135, 0.6688]}, {"w": "neu‐", "b": [0.8184, 0.6474, 0.8571, 0.6688]}, {"w": "ral", "b": [0.1429, 0.6665, 0.165, 0.6879]}, {"w": "networks,", "b": [0.1711, 0.6665, 0.253, 0.6879]}, {"w": "replacing", "b": [0.2591, 0.6665, 0.3365, 0.6879]}, {"w": "the", "b": [0.3426, 0.6665, 0.3689, 0.6879]}, {"w": "ubiquitous", "b": [0.3749, 0.6665, 0.4652, 0.6879]}, {"w": "Gradient", "b": [0.4712, 0.6665, 0.5458, 0.6879]}, {"w": "Descent!", "b": [0.5518, 0.6665, 0.6244, 0.6879]}, {"w": "See", "b": [0.6304, 0.6665, 0.658, 0.6879]}, {"w": "this", "b": [0.6641, 0.6665, 0.6948, 0.6879]}, {"w": "2017", "b": [0.7008, 0.6665, 0.7408, 0.6879]}, {"w": "post", "b": [0.7469, 0.6665, 0.7824, 0.6879]}, {"w": "by", "b": [0.7885, 0.6665, 0.8086, 0.6879]}, {"w": "Uber", "b": [0.8147, 0.6665, 0.8572, 0.6879]}, {"w": "where", "b": [0.1429, 0.6855, 0.1937, 0.7069]}, {"w": "they", "b": [0.1984, 0.6855, 0.2343, 0.7069]}, {"w": "introduce", "b": [0.239, 0.6855, 0.3201, 0.7069]}, {"w": "their", "b": [0.3248, 0.6855, 0.3644, 0.7069]}, {"w": "Deep", "b": [0.3692, 0.6853, 0.4107, 0.7069]}, {"w": "Neuroevolution", "b": [0.4154, 0.6853, 0.541, 0.7069]}, {"w": "technique.", "b": [0.5458, 0.6855, 0.6332, 0.7069]}]}, {"id": "b_10", "type": "paragraph", "text": "Despite all this exciting progress, and all these tools and services, it still helps to have an idea of what values are reasonable for each hyperparameter, so you can build a quick prototype, and restrict the search space. Here are a few guidelines for choosing the number of hidden layers and neurons in an MLP, and selecting good values for some of the main hyperparameters.", "words": [{"w": "Despite", "b": [0.1429, 0.7136, 0.2064, 0.7351]}, {"w": "all", "b": [0.2118, 0.7136, 0.2315, 0.7351]}, {"w": "this", "b": [0.2369, 0.7136, 0.2676, 0.7351]}, {"w": "exciting", "b": [0.273, 0.7136, 0.3392, 0.7351]}, {"w": "progress,", "b": [0.3446, 0.7136, 0.4202, 0.7351]}, {"w": "and", "b": [0.4256, 0.7136, 0.4572, 0.7351]}, {"w": "all", "b": [0.4626, 0.7136, 0.4822, 0.7351]}, {"w": "these", "b": [0.4876, 0.7136, 0.5305, 0.7351]}, {"w": "tools", "b": [0.5359, 0.7136, 0.5764, 0.7351]}, {"w": "and", "b": [0.5818, 0.7136, 0.6133, 0.7351]}, {"w": "services,", "b": [0.6188, 0.7136, 0.6889, 0.7351]}, {"w": "it", "b": [0.6943, 0.7136, 0.7062, 0.7351]}, {"w": "still", "b": [0.7116, 0.7136, 0.7417, 0.7351]}, {"w": "helps", "b": [0.7472, 0.7136, 0.791, 0.7351]}, {"w": "to", "b": [0.7964, 0.7136, 0.8133, 0.7351]}, {"w": "have", "b": [0.8188, 0.7136, 0.8571, 0.7351]}, {"w": "an", "b": [0.1429, 0.7327, 0.1634, 0.7541]}, {"w": "idea", "b": [0.1709, 0.7327, 0.2054, 0.7541]}, {"w": "of", "b": [0.2129, 0.7327, 0.2297, 0.7541]}, {"w": "what", "b": [0.2371, 0.7327, 0.2776, 0.7541]}, {"w": "values", "b": [0.2851, 0.7327, 0.3367, 0.7541]}, {"w": "are", "b": [0.3442, 0.7327, 0.3699, 0.7541]}, {"w": "reasonable", "b": [0.3773, 0.7327, 0.4666, 0.7541]}, {"w": "for", "b": [0.4741, 0.7327, 0.4986, 0.7541]}, {"w": "each", "b": [0.506, 0.7327, 0.544, 0.7541]}, {"w": "hyperparameter,", "b": [0.5514, 0.7327, 0.6884, 0.7541]}, {"w": "so", "b": [0.6958, 0.7327, 0.7141, 0.7541]}, {"w": "you", "b": [0.7215, 0.7327, 0.7528, 0.7541]}, {"w": "can", "b": [0.7602, 0.7327, 0.7896, 0.7541]}, {"w": "build", "b": [0.797, 0.7327, 0.8405, 0.7541]}, {"w": "a", "b": [0.848, 0.7327, 0.8571, 0.7541]}, {"w": "quick", "b": [0.1429, 0.7517, 0.1893, 0.7731]}, {"w": "prototype,", "b": [0.1947, 0.7517, 0.2814, 0.7731]}, {"w": "and", "b": [0.2869, 0.7517, 0.3184, 0.7731]}, {"w": "restrict", "b": [0.3238, 0.7517, 0.3829, 0.7731]}, {"w": "the", "b": [0.3883, 0.7517, 0.4147, 0.7731]}, {"w": "search", "b": [0.4201, 0.7517, 0.4734, 0.7731]}, {"w": "space.", "b": [0.4789, 0.7517, 0.529, 0.7731]}, {"w": "Here", "b": [0.5344, 0.7517, 0.5753, 0.7731]}, {"w": "are", "b": [0.5807, 0.7517, 0.6065, 0.7731]}, {"w": "a", "b": [0.6119, 0.7517, 0.621, 0.7731]}, {"w": "few", "b": [0.6265, 0.7517, 0.6558, 0.7731]}, {"w": "guidelines", "b": [0.6612, 0.7517, 0.7462, 0.7731]}, {"w": "for", "b": [0.7516, 0.7517, 0.7762, 0.7731]}, {"w": "choosing", "b": [0.7816, 0.7517, 0.8572, 0.7731]}, {"w": "the", "b": [0.1429, 0.7708, 0.1692, 0.7922]}, {"w": "number", "b": [0.176, 0.7708, 0.2423, 0.7922]}, {"w": "of", "b": [0.249, 0.7708, 0.2658, 0.7922]}, {"w": "hidden", "b": [0.2726, 0.7708, 0.3315, 0.7922]}, {"w": "layers", "b": [0.3383, 0.7708, 0.3861, 0.7922]}, {"w": "and", "b": [0.3929, 0.7708, 0.4245, 0.7922]}, {"w": "neurons", "b": [0.4312, 0.7708, 0.4999, 0.7922]}, {"w": "in", "b": [0.5067, 0.7708, 0.5237, 0.7922]}, {"w": "an", "b": [0.5304, 0.7708, 0.551, 0.7922]}, {"w": "MLP,", "b": [0.5578, 0.7708, 0.6011, 0.7922]}, {"w": "and", "b": [0.6079, 0.7708, 0.6394, 0.7922]}, {"w": "selecting", "b": [0.6462, 0.7708, 0.7187, 0.7922]}, {"w": "good", "b": [0.7255, 0.7708, 0.7675, 0.7922]}, {"w": "values", "b": [0.7742, 0.7708, 0.8259, 0.7922]}, {"w": "for", "b": [0.8326, 0.7708, 0.8571, 0.7922]}, {"w": "some", "b": [0.1429, 0.7898, 0.187, 0.8112]}, {"w": "of", "b": [0.1918, 0.7898, 0.2086, 0.8112]}, {"w": "the", "b": [0.2133, 0.7898, 0.2396, 0.8112]}, {"w": "main", "b": [0.2444, 0.7898, 0.2875, 0.8112]}, {"w": "hyperparameters.", "b": [0.2923, 0.7898, 0.4382, 0.8112]}]}, {"id": "b_11", "type": "paragraph", "text": "318 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "318", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4163, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4583, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 345, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Number of Hidden Layers", "words": [{"w": "Number", "b": [0.1429, 0.0763, 0.2263, 0.1049]}, {"w": "of", "b": [0.2312, 0.0763, 0.2522, 0.1049]}, {"w": "Hidden", "b": [0.2571, 0.0763, 0.3314, 0.1049]}, {"w": "Layers", "b": [0.3364, 0.0763, 0.4022, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "For many problems, you can just begin with a single hidden layer and you will get reasonable results. It has actually been shown that an MLP with just one hidden layer can model even the most complex functions provided it has enough neurons. For a long time, these facts convinced researchers that there was no need to investigate any deeper neural networks. But they overlooked the fact that deep networks have a much higher parameter efficiency than shallow ones: they can model complex functions using exponentially fewer neurons than shallow nets, allowing them to reach much better performance with the same amount of training data.", "words": [{"w": "For", "b": [0.1429, 0.1108, 0.1718, 0.1322]}, {"w": "many", "b": [0.1789, 0.1108, 0.2256, 0.1322]}, {"w": "problems,", "b": [0.2326, 0.1108, 0.3161, 0.1322]}, {"w": "you", "b": [0.3231, 0.1108, 0.3544, 0.1322]}, {"w": "can", "b": [0.3614, 0.1108, 0.3908, 0.1322]}, {"w": "just", "b": [0.3978, 0.1108, 0.4282, 0.1322]}, {"w": "begin", "b": [0.4353, 0.1108, 0.4814, 0.1322]}, {"w": "with", "b": [0.4885, 0.1108, 0.5258, 0.1322]}, {"w": "a", "b": [0.5329, 0.1108, 0.542, 0.1322]}, {"w": "single", "b": [0.549, 0.1108, 0.5975, 0.1322]}, {"w": "hidden", "b": [0.6046, 0.1108, 0.6636, 0.1322]}, {"w": "layer", "b": [0.6706, 0.1108, 0.7108, 0.1322]}, {"w": "and", "b": [0.7178, 0.1108, 0.7494, 0.1322]}, {"w": "you", "b": [0.7564, 0.1108, 0.7877, 0.1322]}, {"w": "will", "b": [0.7947, 0.1108, 0.8251, 0.1322]}, {"w": "get", "b": [0.8322, 0.1108, 0.8571, 0.1322]}, {"w": "reasonable", "b": [0.1428, 0.1298, 0.2321, 0.1512]}, {"w": "results.", "b": [0.2373, 0.1298, 0.2967, 0.1512]}, {"w": "It", "b": [0.3019, 0.1298, 0.3145, 0.1512]}, {"w": "has", "b": [0.3198, 0.1298, 0.3477, 0.1512]}, {"w": "actually", "b": [0.3529, 0.1298, 0.4176, 0.1512]}, {"w": "been", "b": [0.4228, 0.1298, 0.4625, 0.1512]}, {"w": "shown", "b": [0.4677, 0.1298, 0.5228, 0.1512]}, {"w": "that", "b": [0.5281, 0.1298, 0.5606, 0.1512]}, {"w": "an", "b": [0.5659, 0.1298, 0.5864, 0.1512]}, {"w": "MLP", "b": [0.5917, 0.1298, 0.6332, 0.1512]}, {"w": "with", "b": [0.6384, 0.1298, 0.6757, 0.1512]}, {"w": "just", "b": [0.681, 0.1298, 0.7114, 0.1512]}, {"w": "one", "b": [0.7166, 0.1298, 0.7475, 0.1512]}, {"w": "hidden", "b": [0.7527, 0.1298, 0.8117, 0.1512]}, {"w": "layer", "b": [0.8169, 0.1298, 0.8571, 0.1512]}, {"w": "can", "b": [0.1429, 0.1489, 0.1722, 0.1703]}, {"w": "model", "b": [0.1788, 0.1489, 0.2316, 0.1703]}, {"w": "even", "b": [0.2382, 0.1489, 0.277, 0.1703]}, {"w": "the", "b": [0.2836, 0.1489, 0.3099, 0.1703]}, {"w": "most", "b": [0.3165, 0.1489, 0.3582, 0.1703]}, {"w": "complex", "b": [0.3648, 0.1489, 0.4357, 0.1703]}, {"w": "functions", "b": [0.4423, 0.1489, 0.5214, 0.1703]}, {"w": "provided", "b": [0.528, 0.1489, 0.6033, 0.1703]}, {"w": "it", "b": [0.6099, 0.1489, 0.6219, 0.1703]}, {"w": "has", "b": [0.6285, 0.1489, 0.6564, 0.1703]}, {"w": "enough", "b": [0.663, 0.1489, 0.7258, 0.1703]}, {"w": "neurons.", "b": [0.7324, 0.1489, 0.8058, 0.1703]}, {"w": "For", "b": [0.8124, 0.1489, 0.8414, 0.1703]}, {"w": "a", "b": [0.848, 0.1489, 0.8571, 0.1703]}, {"w": "long", "b": [0.1429, 0.1679, 0.1799, 0.1893]}, {"w": "time,", "b": [0.1853, 0.1679, 0.2279, 0.1893]}, {"w": "these", "b": [0.2333, 0.1679, 0.2762, 0.1893]}, {"w": "facts", "b": [0.2816, 0.1679, 0.3197, 0.1893]}, {"w": "convinced", "b": [0.3251, 0.1679, 0.4107, 0.1893]}, {"w": "researchers", "b": [0.4162, 0.1679, 0.5103, 0.1893]}, {"w": "that", "b": [0.5157, 0.1679, 0.5483, 0.1893]}, {"w": "there", "b": [0.5537, 0.1679, 0.5966, 0.1893]}, {"w": "was", "b": [0.602, 0.1679, 0.6331, 0.1893]}, {"w": "no", "b": [0.6385, 0.1679, 0.6605, 0.1893]}, {"w": "need", "b": [0.6659, 0.1679, 0.706, 0.1893]}, {"w": "to", "b": [0.7114, 0.1679, 0.7284, 0.1893]}, {"w": "investigate", "b": [0.7338, 0.1679, 0.8221, 0.1893]}, {"w": "any", "b": [0.8275, 0.1679, 0.8571, 0.1893]}, {"w": "deeper", "b": [0.1428, 0.187, 0.1991, 0.2084]}, {"w": "neural", "b": [0.2038, 0.187, 0.2572, 0.2084]}, {"w": "networks.", "b": [0.262, 0.187, 0.3439, 0.2084]}, {"w": "But", "b": [0.3487, 0.187, 0.3783, 0.2084]}, {"w": "they", "b": [0.3831, 0.187, 0.419, 0.2084]}, {"w": "overlooked", "b": [0.4237, 0.187, 0.5172, 0.2084]}, {"w": "the", "b": [0.522, 0.187, 0.5483, 0.2084]}, {"w": "fact", "b": [0.553, 0.187, 0.5835, 0.2084]}, {"w": "that", "b": [0.5882, 0.187, 0.6208, 0.2084]}, {"w": "deep", "b": [0.6256, 0.187, 0.6652, 0.2084]}, {"w": "networks", "b": [0.6699, 0.187, 0.7471, 0.2084]}, {"w": "have", "b": [0.7518, 0.187, 0.7902, 0.2084]}, {"w": "a", "b": [0.795, 0.187, 0.8041, 0.2084]}, {"w": "much", "b": [0.8089, 0.187, 0.8565, 0.2084]}, {"w": "higher", "b": [0.1428, 0.206, 0.197, 0.2274]}, {"w": "parameter", "b": [0.2059, 0.2058, 0.2895, 0.2274]}, {"w": "efficiency", "b": [0.2984, 0.2058, 0.3734, 0.2274]}, {"w": "than", "b": [0.3823, 0.206, 0.4203, 0.2274]}, {"w": "shallow", "b": [0.4292, 0.206, 0.4926, 0.2274]}, {"w": "ones:", "b": [0.5014, 0.206, 0.5447, 0.2274]}, {"w": "they", "b": [0.5536, 0.206, 0.5895, 0.2274]}, {"w": "can", "b": [0.5983, 0.206, 0.6277, 0.2274]}, {"w": "model", "b": [0.6366, 0.206, 0.6894, 0.2274]}, {"w": "complex", "b": [0.6982, 0.206, 0.7692, 0.2274]}, {"w": "functions", "b": [0.7781, 0.206, 0.8571, 0.2274]}, {"w": "using", "b": [0.1429, 0.2251, 0.1883, 0.2465]}, {"w": "exponentially", "b": [0.1952, 0.2251, 0.3079, 0.2465]}, {"w": "fewer", "b": [0.3148, 0.2251, 0.3607, 0.2465]}, {"w": "neurons", "b": [0.3676, 0.2251, 0.4363, 0.2465]}, {"w": "than", "b": [0.4433, 0.2251, 0.4813, 0.2465]}, {"w": "shallow", "b": [0.4882, 0.2251, 0.5516, 0.2465]}, {"w": "nets,", "b": [0.5585, 0.2251, 0.5975, 0.2465]}, {"w": "allowing", "b": [0.6044, 0.2251, 0.6757, 0.2465]}, {"w": "them", "b": [0.6827, 0.2251, 0.7261, 0.2465]}, {"w": "to", "b": [0.733, 0.2251, 0.75, 0.2465]}, {"w": "reach", "b": [0.7569, 0.2251, 0.8026, 0.2465]}, {"w": "much", "b": [0.8095, 0.2251, 0.8572, 0.2465]}, {"w": "better", "b": [0.1429, 0.2441, 0.1916, 0.2655]}, {"w": "performance", "b": [0.1963, 0.2441, 0.3036, 0.2655]}, {"w": "with", "b": [0.3083, 0.2441, 0.3457, 0.2655]}, {"w": "the", "b": [0.3504, 0.2441, 0.3767, 0.2655]}, {"w": "same", "b": [0.3815, 0.2441, 0.4242, 0.2655]}, {"w": "amount", "b": [0.4289, 0.2441, 0.4942, 0.2655]}, {"w": "of", "b": [0.4989, 0.2441, 0.5157, 0.2655]}, {"w": "training", "b": [0.5204, 0.2441, 0.5873, 0.2655]}, {"w": "data.", "b": [0.5921, 0.2441, 0.6321, 0.2655]}]}, {"id": "b_2", "type": "paragraph", "text": "To understand why, suppose you are asked to draw a forest using some drawing soft‐ ware, but you are forbidden to use copy/paste. You would have to draw each tree individually, branch per branch, leaf per leaf. If you could instead draw one leaf, copy/paste it to draw a branch, then copy/paste that branch to create a tree, and finally copy/paste this tree to make a forest, you would be finished in no time. Real- world data is often structured in such a hierarchical way and Deep Neural Networks automatically take advantage of this fact: lower hidden layers model low-level struc‐ tures (e.g., line segments of various shapes and orientations), intermediate hidden layers combine these low-level structures to model intermediate-level structures (e.g., squares, circles), and the highest hidden layers and the output layer combine these intermediate structures to model high-level structures (e.g., faces).", "words": [{"w": "To", "b": [0.1429, 0.2722, 0.1643, 0.2936]}, {"w": "understand", "b": [0.1697, 0.2722, 0.2653, 0.2936]}, {"w": "why,", "b": [0.2708, 0.2722, 0.3085, 0.2936]}, {"w": "suppose", "b": [0.3139, 0.2722, 0.3816, 0.2936]}, {"w": "you", "b": [0.3871, 0.2722, 0.4183, 0.2936]}, {"w": "are", "b": [0.4238, 0.2722, 0.4495, 0.2936]}, {"w": "asked", "b": [0.4549, 0.2722, 0.5019, 0.2936]}, {"w": "to", "b": [0.5074, 0.2722, 0.5244, 0.2936]}, {"w": "draw", "b": [0.5298, 0.2722, 0.5716, 0.2936]}, {"w": "a", "b": [0.577, 0.2722, 0.5862, 0.2936]}, {"w": "forest", "b": [0.5916, 0.2722, 0.639, 0.2936]}, {"w": "using", "b": [0.6445, 0.2722, 0.6899, 0.2936]}, {"w": "some", "b": [0.6953, 0.2722, 0.7395, 0.2936]}, {"w": "drawing", "b": [0.745, 0.2722, 0.8135, 0.2936]}, {"w": "soft‐", "b": [0.8189, 0.2722, 0.8571, 0.2936]}, {"w": "ware,", "b": [0.1429, 0.2913, 0.1876, 0.3127]}, {"w": "but", "b": [0.1955, 0.2913, 0.2235, 0.3127]}, {"w": "you", "b": [0.2315, 0.2913, 0.2627, 0.3127]}, {"w": "are", "b": [0.2707, 0.2913, 0.2964, 0.3127]}, {"w": "forbidden", "b": [0.3043, 0.2913, 0.3873, 0.3127]}, {"w": "to", "b": [0.3952, 0.2913, 0.4122, 0.3127]}, {"w": "use", "b": [0.4201, 0.2913, 0.4477, 0.3127]}, {"w": "copy/paste.", "b": [0.4556, 0.2913, 0.5501, 0.3127]}, {"w": "You", "b": [0.558, 0.2913, 0.5904, 0.3127]}, {"w": "would", "b": [0.5983, 0.2913, 0.6506, 0.3127]}, {"w": "have", "b": [0.6585, 0.2913, 0.6969, 0.3127]}, {"w": "to", "b": [0.7048, 0.2913, 0.7218, 0.3127]}, {"w": "draw", "b": [0.7298, 0.2913, 0.7715, 0.3127]}, {"w": "each", "b": [0.7795, 0.2913, 0.8174, 0.3127]}, {"w": "tree", "b": [0.8253, 0.2913, 0.8571, 0.3127]}, {"w": "individually,", "b": [0.1428, 0.3103, 0.2462, 0.3317]}, {"w": "branch", "b": [0.2548, 0.3103, 0.3136, 0.3317]}, {"w": "per", "b": [0.3222, 0.3103, 0.3497, 0.3317]}, {"w": "branch,", "b": [0.3583, 0.3103, 0.4218, 0.3317]}, {"w": "leaf", "b": [0.4304, 0.3103, 0.4599, 0.3317]}, {"w": "per", "b": [0.4685, 0.3103, 0.496, 0.3317]}, {"w": "leaf.", "b": [0.5046, 0.3103, 0.5388, 0.3317]}, {"w": "If", "b": [0.5474, 0.3103, 0.5607, 0.3317]}, {"w": "you", "b": [0.5693, 0.3103, 0.6005, 0.3317]}, {"w": "could", "b": [0.6091, 0.3103, 0.6559, 0.3317]}, {"w": "instead", "b": [0.6645, 0.3103, 0.7245, 0.3317]}, {"w": "draw", "b": [0.7331, 0.3103, 0.7749, 0.3317]}, {"w": "one", "b": [0.7835, 0.3103, 0.8143, 0.3317]}, {"w": "leaf,", "b": [0.8229, 0.3103, 0.8571, 0.3317]}, {"w": "copy/paste", "b": [0.1429, 0.3294, 0.2326, 0.3508]}, {"w": "it", "b": [0.2411, 0.3294, 0.253, 0.3508]}, {"w": "to", "b": [0.2615, 0.3294, 0.2785, 0.3508]}, {"w": "draw", "b": [0.287, 0.3294, 0.3287, 0.3508]}, {"w": "a", "b": [0.3372, 0.3294, 0.3464, 0.3508]}, {"w": "branch,", "b": [0.3548, 0.3294, 0.4184, 0.3508]}, {"w": "then", "b": [0.4269, 0.3294, 0.4646, 0.3508]}, {"w": "copy/paste", "b": [0.4731, 0.3294, 0.5628, 0.3508]}, {"w": "that", "b": [0.5713, 0.3294, 0.6039, 0.3508]}, {"w": "branch", "b": [0.6124, 0.3294, 0.6712, 0.3508]}, {"w": "to", "b": [0.6796, 0.3294, 0.6966, 0.3508]}, {"w": "create", "b": [0.7051, 0.3294, 0.7545, 0.3508]}, {"w": "a", "b": [0.7629, 0.3294, 0.7721, 0.3508]}, {"w": "tree,", "b": [0.7806, 0.3294, 0.8171, 0.3508]}, {"w": "and", "b": [0.8256, 0.3294, 0.8571, 0.3508]}, {"w": "finally", "b": [0.1429, 0.3484, 0.1953, 0.3698]}, {"w": "copy/paste", "b": [0.2013, 0.3484, 0.291, 0.3698]}, {"w": "this", "b": [0.297, 0.3484, 0.3278, 0.3698]}, {"w": "tree", "b": [0.3338, 0.3484, 0.3656, 0.3698]}, {"w": "to", "b": [0.3716, 0.3484, 0.3886, 0.3698]}, {"w": "make", "b": [0.3946, 0.3484, 0.44, 0.3698]}, {"w": "a", "b": [0.4461, 0.3484, 0.4552, 0.3698]}, {"w": "forest,", "b": [0.4612, 0.3484, 0.5134, 0.3698]}, {"w": "you", "b": [0.5194, 0.3484, 0.5507, 0.3698]}, {"w": "would", "b": [0.5567, 0.3484, 0.6089, 0.3698]}, {"w": "be", "b": [0.6149, 0.3484, 0.6344, 0.3698]}, {"w": "finished", "b": [0.6404, 0.3484, 0.7078, 0.3698]}, {"w": "in", "b": [0.7138, 0.3484, 0.7308, 0.3698]}, {"w": "no", "b": [0.7368, 0.3484, 0.7588, 0.3698]}, {"w": "time.", "b": [0.7649, 0.3484, 0.8075, 0.3698]}, {"w": "Real-", "b": [0.8135, 0.3484, 0.8571, 0.3698]}, {"w": "world", "b": [0.1429, 0.3675, 0.1917, 0.3889]}, {"w": "data", "b": [0.1977, 0.3675, 0.2329, 0.3889]}, {"w": "is", "b": [0.2389, 0.3675, 0.2521, 0.3889]}, {"w": "often", "b": [0.2581, 0.3675, 0.3015, 0.3889]}, {"w": "structured", "b": [0.3074, 0.3675, 0.394, 0.3889]}, {"w": "in", "b": [0.4, 0.3675, 0.417, 0.3889]}, {"w": "such", "b": [0.4229, 0.3675, 0.4615, 0.3889]}, {"w": "a", "b": [0.4675, 0.3675, 0.4766, 0.3889]}, {"w": "hierarchical", "b": [0.4826, 0.3675, 0.5815, 0.3889]}, {"w": "way", "b": [0.5875, 0.3675, 0.6201, 0.3889]}, {"w": "and", "b": [0.626, 0.3675, 0.6576, 0.3889]}, {"w": "Deep", "b": [0.6635, 0.3675, 0.7074, 0.3889]}, {"w": "Neural", "b": [0.7134, 0.3675, 0.7704, 0.3889]}, {"w": "Networks", "b": [0.7764, 0.3675, 0.8571, 0.3889]}, {"w": "automatically", "b": [0.1429, 0.3865, 0.2555, 0.4079]}, {"w": "take", "b": [0.2618, 0.3865, 0.2965, 0.4079]}, {"w": "advantage", "b": [0.3028, 0.3865, 0.3868, 0.4079]}, {"w": "of", "b": [0.3931, 0.3865, 0.4099, 0.4079]}, {"w": "this", "b": [0.4162, 0.3865, 0.4469, 0.4079]}, {"w": "fact:", "b": [0.4532, 0.3865, 0.4885, 0.4079]}, {"w": "lower", "b": [0.4948, 0.3865, 0.5415, 0.4079]}, {"w": "hidden", "b": [0.5478, 0.3865, 0.6068, 0.4079]}, {"w": "layers", "b": [0.6131, 0.3865, 0.6609, 0.4079]}, {"w": "model", "b": [0.6672, 0.3865, 0.72, 0.4079]}, {"w": "low-level", "b": [0.7263, 0.3865, 0.8018, 0.4079]}, {"w": "struc‐", "b": [0.8081, 0.3865, 0.8572, 0.4079]}, {"w": "tures", "b": [0.1429, 0.4056, 0.1845, 0.427]}, {"w": "(e.g.,", "b": [0.1927, 0.4056, 0.2328, 0.427]}, {"w": "line", "b": [0.241, 0.4056, 0.2721, 0.427]}, {"w": "segments", "b": [0.2803, 0.4056, 0.3575, 0.427]}, {"w": "of", "b": [0.3657, 0.4056, 0.3825, 0.427]}, {"w": "various", "b": [0.3907, 0.4056, 0.4522, 0.427]}, {"w": "shapes", "b": [0.4604, 0.4056, 0.5153, 0.427]}, {"w": "and", "b": [0.5235, 0.4056, 0.5551, 0.427]}, {"w": "orientations),", "b": [0.5633, 0.4056, 0.6758, 0.427]}, {"w": "intermediate", "b": [0.684, 0.4056, 0.79, 0.427]}, {"w": "hidden", "b": [0.7982, 0.4056, 0.8571, 0.427]}, {"w": "layers", "b": [0.1429, 0.4246, 0.1907, 0.446]}, {"w": "combine", "b": [0.196, 0.4246, 0.2689, 0.446]}, {"w": "these", "b": [0.2742, 0.4246, 0.317, 0.446]}, {"w": "low-level", "b": [0.3223, 0.4246, 0.3978, 0.446]}, {"w": "structures", "b": [0.4031, 0.4246, 0.4863, 0.446]}, {"w": "to", "b": [0.4916, 0.4246, 0.5086, 0.446]}, {"w": "model", "b": [0.5139, 0.4246, 0.5667, 0.446]}, {"w": "intermediate-level", "b": [0.572, 0.4246, 0.7233, 0.446]}, {"w": "structures", "b": [0.7285, 0.4246, 0.8118, 0.446]}, {"w": "(e.g.,", "b": [0.8171, 0.4246, 0.8571, 0.446]}, {"w": "squares,", "b": [0.1428, 0.4437, 0.2103, 0.4651]}, {"w": "circles),", "b": [0.2176, 0.4437, 0.2822, 0.4651]}, {"w": "and", "b": [0.2895, 0.4437, 0.321, 0.4651]}, {"w": "the", "b": [0.3282, 0.4437, 0.3546, 0.4651]}, {"w": "highest", "b": [0.3618, 0.4437, 0.4223, 0.4651]}, {"w": "hidden", "b": [0.4295, 0.4437, 0.4885, 0.4651]}, {"w": "layers", "b": [0.4957, 0.4437, 0.5435, 0.4651]}, {"w": "and", "b": [0.5508, 0.4437, 0.5823, 0.4651]}, {"w": "the", "b": [0.5895, 0.4437, 0.6159, 0.4651]}, {"w": "output", "b": [0.6231, 0.4437, 0.6795, 0.4651]}, {"w": "layer", "b": [0.6867, 0.4437, 0.7269, 0.4651]}, {"w": "combine", "b": [0.7341, 0.4437, 0.8071, 0.4651]}, {"w": "these", "b": [0.8143, 0.4437, 0.8571, 0.4651]}, {"w": "intermediate", "b": [0.1429, 0.4627, 0.2488, 0.4841]}, {"w": "structures", "b": [0.2536, 0.4627, 0.3368, 0.4841]}, {"w": "to", "b": [0.3415, 0.4627, 0.3585, 0.4841]}, {"w": "model", "b": [0.3633, 0.4627, 0.4161, 0.4841]}, {"w": "high-level", "b": [0.4208, 0.4627, 0.5037, 0.4841]}, {"w": "structures", "b": [0.5084, 0.4627, 0.5917, 0.4841]}, {"w": "(e.g.,", "b": [0.5964, 0.4627, 0.6365, 0.4841]}, {"w": "faces).", "b": [0.6412, 0.4627, 0.6938, 0.4841]}]}, {"id": "b_3", "type": "paragraph", "text": "Not only does this hierarchical architecture help DNNs converge faster to a good sol‐ ution, it also improves their ability to generalize to new datasets. For example, if you have already trained a model to recognize faces in pictures, and you now want to train a new neural network to recognize hairstyles, then you can kickstart training by reusing the lower layers of the first network. Instead of randomly initializing the weights and biases of the first few layers of the new neural network, you can initialize them to the value of the weights and biases of the lower layers of the first network. This way the network will not have to learn from scratch all the low-level structures that occur in most pictures; it will only have to learn the higher-level structures (e.g., hairstyles). This is called transfer learning.", "words": [{"w": "Not", "b": [0.1429, 0.4908, 0.1748, 0.5122]}, {"w": "only", "b": [0.18, 0.4908, 0.2169, 0.5122]}, {"w": "does", "b": [0.2221, 0.4908, 0.2602, 0.5122]}, {"w": "this", "b": [0.2654, 0.4908, 0.2961, 0.5122]}, {"w": "hierarchical", "b": [0.3013, 0.4908, 0.4002, 0.5122]}, {"w": "architecture", "b": [0.4054, 0.4908, 0.5058, 0.5122]}, {"w": "help", "b": [0.511, 0.4908, 0.5472, 0.5122]}, {"w": "DNNs", "b": [0.5524, 0.4908, 0.6058, 0.5122]}, {"w": "converge", "b": [0.611, 0.4908, 0.6862, 0.5122]}, {"w": "faster", "b": [0.6914, 0.4908, 0.7373, 0.5122]}, {"w": "to", "b": [0.7425, 0.4908, 0.7594, 0.5122]}, {"w": "a", "b": [0.7646, 0.4908, 0.7738, 0.5122]}, {"w": "good", "b": [0.779, 0.4908, 0.821, 0.5122]}, {"w": "sol‐", "b": [0.8262, 0.4908, 0.8571, 0.5122]}, {"w": "ution,", "b": [0.1429, 0.5099, 0.1926, 0.5313]}, {"w": "it", "b": [0.1984, 0.5099, 0.2104, 0.5313]}, {"w": "also", "b": [0.2161, 0.5099, 0.2488, 0.5313]}, {"w": "improves", "b": [0.2546, 0.5099, 0.3323, 0.5313]}, {"w": "their", "b": [0.3381, 0.5099, 0.3777, 0.5313]}, {"w": "ability", "b": [0.3835, 0.5099, 0.4356, 0.5313]}, {"w": "to", "b": [0.4414, 0.5099, 0.4584, 0.5313]}, {"w": "generalize", "b": [0.4642, 0.5099, 0.5483, 0.5313]}, {"w": "to", "b": [0.5541, 0.5099, 0.5711, 0.5313]}, {"w": "new", "b": [0.5769, 0.5099, 0.6114, 0.5313]}, {"w": "datasets.", "b": [0.6172, 0.5099, 0.6877, 0.5313]}, {"w": "For", "b": [0.6935, 0.5099, 0.7225, 0.5313]}, {"w": "example,", "b": [0.7283, 0.5099, 0.8026, 0.5313]}, {"w": "if", "b": [0.8084, 0.5099, 0.8201, 0.5313]}, {"w": "you", "b": [0.8259, 0.5099, 0.8571, 0.5313]}, {"w": "have", "b": [0.1429, 0.5289, 0.1812, 0.5503]}, {"w": "already", "b": [0.1891, 0.5289, 0.2498, 0.5503]}, {"w": "trained", "b": [0.2576, 0.5289, 0.3177, 0.5503]}, {"w": "a", "b": [0.3255, 0.5289, 0.3347, 0.5503]}, {"w": "model", "b": [0.3425, 0.5289, 0.3953, 0.5503]}, {"w": "to", "b": [0.4031, 0.5289, 0.4201, 0.5503]}, {"w": "recognize", "b": [0.428, 0.5289, 0.5083, 0.5503]}, {"w": "faces", "b": [0.5161, 0.5289, 0.5568, 0.5503]}, {"w": "in", "b": [0.5646, 0.5289, 0.5816, 0.5503]}, {"w": "pictures,", "b": [0.5894, 0.5289, 0.6611, 0.5503]}, {"w": "and", "b": [0.669, 0.5289, 0.7005, 0.5503]}, {"w": "you", "b": [0.7083, 0.5289, 0.7396, 0.5503]}, {"w": "now", "b": [0.7474, 0.5289, 0.7837, 0.5503]}, {"w": "want", "b": [0.7916, 0.5289, 0.8323, 0.5503]}, {"w": "to", "b": [0.8402, 0.5289, 0.8571, 0.5503]}, {"w": "train", "b": [0.1429, 0.548, 0.1831, 0.5694]}, {"w": "a", "b": [0.1884, 0.548, 0.1975, 0.5694]}, {"w": "new", "b": [0.2028, 0.548, 0.2373, 0.5694]}, {"w": "neural", "b": [0.2426, 0.548, 0.296, 0.5694]}, {"w": "network", "b": [0.3013, 0.548, 0.3709, 0.5694]}, {"w": "to", "b": [0.3762, 0.548, 0.3932, 0.5694]}, {"w": "recognize", "b": [0.3984, 0.548, 0.4788, 0.5694]}, {"w": "hairstyles,", "b": [0.4841, 0.548, 0.5677, 0.5694]}, {"w": "then", "b": [0.573, 0.548, 0.6108, 0.5694]}, {"w": "you", "b": [0.616, 0.548, 0.6473, 0.5694]}, {"w": "can", "b": [0.6526, 0.548, 0.6819, 0.5694]}, {"w": "kickstart", "b": [0.6872, 0.548, 0.7595, 0.5694]}, {"w": "training", "b": [0.7648, 0.548, 0.8317, 0.5694]}, {"w": "by", "b": [0.837, 0.548, 0.8572, 0.5694]}, {"w": "reusing", "b": [0.1429, 0.567, 0.2049, 0.5884]}, {"w": "the", "b": [0.2136, 0.567, 0.2399, 0.5884]}, {"w": "lower", "b": [0.2486, 0.567, 0.2953, 0.5884]}, {"w": "layers", "b": [0.304, 0.567, 0.3518, 0.5884]}, {"w": "of", "b": [0.3605, 0.567, 0.3773, 0.5884]}, {"w": "the", "b": [0.3859, 0.567, 0.4123, 0.5884]}, {"w": "first", "b": [0.4209, 0.567, 0.4544, 0.5884]}, {"w": "network.", "b": [0.4631, 0.567, 0.5374, 0.5884]}, {"w": "Instead", "b": [0.5461, 0.567, 0.6076, 0.5884]}, {"w": "of", "b": [0.6162, 0.567, 0.633, 0.5884]}, {"w": "randomly", "b": [0.6417, 0.567, 0.7235, 0.5884]}, {"w": "initializing", "b": [0.7322, 0.567, 0.8221, 0.5884]}, {"w": "the", "b": [0.8308, 0.567, 0.8571, 0.5884]}, {"w": "weights", "b": [0.1429, 0.5861, 0.206, 0.6075]}, {"w": "and", "b": [0.2113, 0.5861, 0.2428, 0.6075]}, {"w": "biases", "b": [0.248, 0.5861, 0.2975, 0.6075]}, {"w": "of", "b": [0.3027, 0.5861, 0.3195, 0.6075]}, {"w": "the", "b": [0.3247, 0.5861, 0.351, 0.6075]}, {"w": "first", "b": [0.3562, 0.5861, 0.3897, 0.6075]}, {"w": "few", "b": [0.3949, 0.5861, 0.4242, 0.6075]}, {"w": "layers", "b": [0.4295, 0.5861, 0.4773, 0.6075]}, {"w": "of", "b": [0.4825, 0.5861, 0.4993, 0.6075]}, {"w": "the", "b": [0.5045, 0.5861, 0.5308, 0.6075]}, {"w": "new", "b": [0.5361, 0.5861, 0.5706, 0.6075]}, {"w": "neural", "b": [0.5758, 0.5861, 0.6293, 0.6075]}, {"w": "network,", "b": [0.6345, 0.5861, 0.7088, 0.6075]}, {"w": "you", "b": [0.714, 0.5861, 0.7452, 0.6075]}, {"w": "can", "b": [0.7505, 0.5861, 0.7798, 0.6075]}, {"w": "initialize", "b": [0.785, 0.5861, 0.8571, 0.6075]}, {"w": "them", "b": [0.1428, 0.6051, 0.1862, 0.6265]}, {"w": "to", "b": [0.193, 0.6051, 0.21, 0.6265]}, {"w": "the", "b": [0.2167, 0.6051, 0.243, 0.6265]}, {"w": "value", "b": [0.2497, 0.6051, 0.2937, 0.6265]}, {"w": "of", "b": [0.3005, 0.6051, 0.3172, 0.6265]}, {"w": "the", "b": [0.324, 0.6051, 0.3503, 0.6265]}, {"w": "weights", "b": [0.357, 0.6051, 0.4202, 0.6265]}, {"w": "and", "b": [0.4269, 0.6051, 0.4585, 0.6265]}, {"w": "biases", "b": [0.4652, 0.6051, 0.5147, 0.6265]}, {"w": "of", "b": [0.5214, 0.6051, 0.5382, 0.6265]}, {"w": "the", "b": [0.5449, 0.6051, 0.5713, 0.6265]}, {"w": "lower", "b": [0.578, 0.6051, 0.6247, 0.6265]}, {"w": "layers", "b": [0.6315, 0.6051, 0.6793, 0.6265]}, {"w": "of", "b": [0.686, 0.6051, 0.7028, 0.6265]}, {"w": "the", "b": [0.7096, 0.6051, 0.7359, 0.6265]}, {"w": "first", "b": [0.7426, 0.6051, 0.7761, 0.6265]}, {"w": "network.", "b": [0.7828, 0.6051, 0.8571, 0.6265]}, {"w": "This", "b": [0.1429, 0.6242, 0.1801, 0.6456]}, {"w": "way", "b": [0.1862, 0.6242, 0.2189, 0.6456]}, {"w": "the", "b": [0.225, 0.6242, 0.2514, 0.6456]}, {"w": "network", "b": [0.2575, 0.6242, 0.3271, 0.6456]}, {"w": "will", "b": [0.3333, 0.6242, 0.3637, 0.6456]}, {"w": "not", "b": [0.3699, 0.6242, 0.3982, 0.6456]}, {"w": "have", "b": [0.4044, 0.6242, 0.4428, 0.6456]}, {"w": "to", "b": [0.449, 0.6242, 0.466, 0.6456]}, {"w": "learn", "b": [0.4721, 0.6242, 0.5145, 0.6456]}, {"w": "from", "b": [0.5207, 0.6242, 0.5623, 0.6456]}, {"w": "scratch", "b": [0.5685, 0.6242, 0.6277, 0.6456]}, {"w": "all", "b": [0.6339, 0.6242, 0.6536, 0.6456]}, {"w": "the", "b": [0.6597, 0.6242, 0.6861, 0.6456]}, {"w": "low-level", "b": [0.6922, 0.6242, 0.7677, 0.6456]}, {"w": "structures", "b": [0.7739, 0.6242, 0.8571, 0.6456]}, {"w": "that", "b": [0.1429, 0.6432, 0.1754, 0.6646]}, {"w": "occur", "b": [0.1811, 0.6432, 0.2281, 0.6646]}, {"w": "in", "b": [0.2337, 0.6432, 0.2507, 0.6646]}, {"w": "most", "b": [0.2563, 0.6432, 0.298, 0.6646]}, {"w": "pictures;", "b": [0.3036, 0.6432, 0.3753, 0.6646]}, {"w": "it", "b": [0.381, 0.6432, 0.3929, 0.6646]}, {"w": "will", "b": [0.3985, 0.6432, 0.4289, 0.6646]}, {"w": "only", "b": [0.4345, 0.6432, 0.4714, 0.6646]}, {"w": "have", "b": [0.477, 0.6432, 0.5154, 0.6646]}, {"w": "to", "b": [0.521, 0.6432, 0.538, 0.6646]}, {"w": "learn", "b": [0.5436, 0.6432, 0.586, 0.6646]}, {"w": "the", "b": [0.5917, 0.6432, 0.618, 0.6646]}, {"w": "higher-level", "b": [0.6236, 0.6432, 0.7226, 0.6646]}, {"w": "structures", "b": [0.7282, 0.6432, 0.8115, 0.6646]}, {"w": "(e.g.,", "b": [0.8171, 0.6432, 0.8571, 0.6646]}, {"w": "hairstyles).", "b": [0.1429, 0.6623, 0.2337, 0.6837]}, {"w": "This", "b": [0.2385, 0.6623, 0.2757, 0.6837]}, {"w": "is", "b": [0.2804, 0.6623, 0.2936, 0.6837]}, {"w": "called", "b": [0.2984, 0.6623, 0.3467, 0.6837]}, {"w": "transfer", "b": [0.3514, 0.662, 0.4141, 0.6837]}, {"w": "learning.", "b": [0.4189, 0.662, 0.4904, 0.6837]}]}, {"id": "b_4", "type": "paragraph", "text": "In summary, for many problems you can start with just one or two hidden layers and it will work just fine (e.g., you can easily reach above 97% accuracy on the MNIST dataset using just one hidden layer with a few hundred neurons, and above 98% accu‐ racy using two hidden layers with the same total amount of neurons, in roughly the same amount of training time). For more complex problems, you can gradually ramp up the number of hidden layers, until you start overfitting the training set. Very com‐ plex tasks, such as large image classification or speech recognition, typically require networks with dozens of layers (or even hundreds, but not fully connected ones, as we will see in Chapter 14), and they need a huge amount of training data. However, you will rarely have to train such networks from scratch: it is much more common to", "words": [{"w": "In", "b": [0.1429, 0.6904, 0.1614, 0.7118]}, {"w": "summary,", "b": [0.1666, 0.6904, 0.2497, 0.7118]}, {"w": "for", "b": [0.2549, 0.6904, 0.2794, 0.7118]}, {"w": "many", "b": [0.2847, 0.6904, 0.3313, 0.7118]}, {"w": "problems", "b": [0.3366, 0.6904, 0.4153, 0.7118]}, {"w": "you", "b": [0.4205, 0.6904, 0.4517, 0.7118]}, {"w": "can", "b": [0.457, 0.6904, 0.4863, 0.7118]}, {"w": "start", "b": [0.4915, 0.6904, 0.5288, 0.7118]}, {"w": "with", "b": [0.534, 0.6904, 0.5713, 0.7118]}, {"w": "just", "b": [0.5766, 0.6904, 0.607, 0.7118]}, {"w": "one", "b": [0.6122, 0.6904, 0.6431, 0.7118]}, {"w": "or", "b": [0.6483, 0.6904, 0.6666, 0.7118]}, {"w": "two", "b": [0.6719, 0.6904, 0.7031, 0.7118]}, {"w": "hidden", "b": [0.7083, 0.6904, 0.7673, 0.7118]}, {"w": "layers", "b": [0.7725, 0.6904, 0.8204, 0.7118]}, {"w": "and", "b": [0.8256, 0.6904, 0.8571, 0.7118]}, {"w": "it", "b": [0.1429, 0.7094, 0.1548, 0.7308]}, {"w": "will", "b": [0.1618, 0.7094, 0.1922, 0.7308]}, {"w": "work", "b": [0.1991, 0.7094, 0.2421, 0.7308]}, {"w": "just", "b": [0.249, 0.7094, 0.2794, 0.7308]}, {"w": "fine", "b": [0.2864, 0.7094, 0.3184, 0.7308]}, {"w": "(e.g.,", "b": [0.3253, 0.7094, 0.3654, 0.7308]}, {"w": "you", "b": [0.3723, 0.7094, 0.4036, 0.7308]}, {"w": "can", "b": [0.4105, 0.7094, 0.4399, 0.7308]}, {"w": "easily", "b": [0.4468, 0.7094, 0.4929, 0.7308]}, {"w": "reach", "b": [0.4999, 0.7094, 0.5455, 0.7308]}, {"w": "above", "b": [0.5525, 0.7094, 0.6013, 0.7308]}, {"w": "97%", "b": [0.6083, 0.7094, 0.644, 0.7308]}, {"w": "accuracy", "b": [0.651, 0.7094, 0.7241, 0.7308]}, {"w": "on", "b": [0.731, 0.7094, 0.753, 0.7308]}, {"w": "the", "b": [0.76, 0.7094, 0.7863, 0.7308]}, {"w": "MNIST", "b": [0.7933, 0.7094, 0.8572, 0.7308]}, {"w": "dataset", "b": [0.1429, 0.7285, 0.201, 0.7499]}, {"w": "using", "b": [0.2058, 0.7285, 0.2513, 0.7499]}, {"w": "just", "b": [0.2561, 0.7285, 0.2865, 0.7499]}, {"w": "one", "b": [0.2914, 0.7285, 0.3222, 0.7499]}, {"w": "hidden", "b": [0.3271, 0.7285, 0.386, 0.7499]}, {"w": "layer", "b": [0.3909, 0.7285, 0.4311, 0.7499]}, {"w": "with", "b": [0.4359, 0.7285, 0.4733, 0.7499]}, {"w": "a", "b": [0.4781, 0.7285, 0.4873, 0.7499]}, {"w": "few", "b": [0.4921, 0.7285, 0.5214, 0.7499]}, {"w": "hundred", "b": [0.5263, 0.7285, 0.598, 0.7499]}, {"w": "neurons,", "b": [0.6029, 0.7285, 0.6763, 0.7499]}, {"w": "and", "b": [0.6812, 0.7285, 0.7127, 0.7499]}, {"w": "above", "b": [0.7176, 0.7285, 0.7664, 0.7499]}, {"w": "98%", "b": [0.7713, 0.7285, 0.807, 0.7499]}, {"w": "accu‐", "b": [0.8119, 0.7285, 0.8571, 0.7499]}, {"w": "racy", "b": [0.1429, 0.7475, 0.1781, 0.7689]}, {"w": "using", "b": [0.1844, 0.7475, 0.2298, 0.7689]}, {"w": "two", "b": [0.236, 0.7475, 0.2673, 0.7689]}, {"w": "hidden", "b": [0.2735, 0.7475, 0.3325, 0.7689]}, {"w": "layers", "b": [0.3387, 0.7475, 0.3866, 0.7689]}, {"w": "with", "b": [0.3928, 0.7475, 0.4302, 0.7689]}, {"w": "the", "b": [0.4364, 0.7475, 0.4627, 0.7689]}, {"w": "same", "b": [0.469, 0.7475, 0.5117, 0.7689]}, {"w": "total", "b": [0.518, 0.7475, 0.5557, 0.7689]}, {"w": "amount", "b": [0.562, 0.7475, 0.6272, 0.7689]}, {"w": "of", "b": [0.6335, 0.7475, 0.6502, 0.7689]}, {"w": "neurons,", "b": [0.6565, 0.7475, 0.73, 0.7689]}, {"w": "in", "b": [0.7362, 0.7475, 0.7532, 0.7689]}, {"w": "roughly", "b": [0.7594, 0.7475, 0.8246, 0.7689]}, {"w": "the", "b": [0.8308, 0.7475, 0.8571, 0.7689]}, {"w": "same", "b": [0.1428, 0.7666, 0.1856, 0.788]}, {"w": "amount", "b": [0.1907, 0.7666, 0.256, 0.788]}, {"w": "of", "b": [0.2612, 0.7666, 0.278, 0.788]}, {"w": "training", "b": [0.2831, 0.7666, 0.3501, 0.788]}, {"w": "time).", "b": [0.3552, 0.7666, 0.4051, 0.788]}, {"w": "For", "b": [0.4102, 0.7666, 0.4392, 0.788]}, {"w": "more", "b": [0.4444, 0.7666, 0.4887, 0.788]}, {"w": "complex", "b": [0.4938, 0.7666, 0.5648, 0.788]}, {"w": "problems,", "b": [0.57, 0.7666, 0.6534, 0.788]}, {"w": "you", "b": [0.6586, 0.7666, 0.6899, 0.788]}, {"w": "can", "b": [0.695, 0.7666, 0.7244, 0.788]}, {"w": "gradually", "b": [0.7296, 0.7666, 0.8075, 0.788]}, {"w": "ramp", "b": [0.8127, 0.7666, 0.8571, 0.788]}, {"w": "up", "b": [0.1429, 0.7856, 0.1648, 0.807]}, {"w": "the", "b": [0.1699, 0.7856, 0.1963, 0.807]}, {"w": "number", "b": [0.2014, 0.7856, 0.2677, 0.807]}, {"w": "of", "b": [0.2728, 0.7856, 0.2896, 0.807]}, {"w": "hidden", "b": [0.2947, 0.7856, 0.3536, 0.807]}, {"w": "layers,", "b": [0.3587, 0.7856, 0.4113, 0.807]}, {"w": "until", "b": [0.4164, 0.7856, 0.4557, 0.807]}, {"w": "you", "b": [0.4608, 0.7856, 0.492, 0.807]}, {"w": "start", "b": [0.4971, 0.7856, 0.5343, 0.807]}, {"w": "overfitting", "b": [0.5394, 0.7856, 0.6275, 0.807]}, {"w": "the", "b": [0.6326, 0.7856, 0.6589, 0.807]}, {"w": "training", "b": [0.664, 0.7856, 0.731, 0.807]}, {"w": "set.", "b": [0.7361, 0.7856, 0.7637, 0.807]}, {"w": "Very", "b": [0.7688, 0.7856, 0.8081, 0.807]}, {"w": "com‐", "b": [0.8132, 0.7856, 0.8572, 0.807]}, {"w": "plex", "b": [0.1429, 0.8047, 0.1777, 0.8261]}, {"w": "tasks,", "b": [0.1843, 0.8047, 0.2302, 0.8261]}, {"w": "such", "b": [0.2368, 0.8047, 0.2755, 0.8261]}, {"w": "as", "b": [0.2821, 0.8047, 0.2989, 0.8261]}, {"w": "large", "b": [0.3055, 0.8047, 0.3462, 0.8261]}, {"w": "image", "b": [0.3528, 0.8047, 0.4032, 0.8261]}, {"w": "classification", "b": [0.4098, 0.8047, 0.5172, 0.8261]}, {"w": "or", "b": [0.5238, 0.8047, 0.5421, 0.8261]}, {"w": "speech", "b": [0.5487, 0.8047, 0.6049, 0.8261]}, {"w": "recognition,", "b": [0.6115, 0.8047, 0.713, 0.8261]}, {"w": "typically", "b": [0.7196, 0.8047, 0.7901, 0.8261]}, {"w": "require", "b": [0.7967, 0.8047, 0.8571, 0.8261]}, {"w": "networks", "b": [0.1429, 0.8237, 0.2201, 0.8451]}, {"w": "with", "b": [0.2269, 0.8237, 0.2642, 0.8451]}, {"w": "dozens", "b": [0.271, 0.8237, 0.3293, 0.8451]}, {"w": "of", "b": [0.3361, 0.8237, 0.3529, 0.8451]}, {"w": "layers", "b": [0.3597, 0.8237, 0.4075, 0.8451]}, {"w": "(or", "b": [0.4143, 0.8237, 0.4399, 0.8451]}, {"w": "even", "b": [0.4467, 0.8237, 0.4854, 0.8451]}, {"w": "hundreds,", "b": [0.4923, 0.8237, 0.5764, 0.8451]}, {"w": "but", "b": [0.5832, 0.8237, 0.6112, 0.8451]}, {"w": "not", "b": [0.618, 0.8237, 0.6464, 0.8451]}, {"w": "fully", "b": [0.6532, 0.8237, 0.6905, 0.8451]}, {"w": "connected", "b": [0.6974, 0.8237, 0.7835, 0.8451]}, {"w": "ones,", "b": [0.7903, 0.8237, 0.8335, 0.8451]}, {"w": "as", "b": [0.8403, 0.8237, 0.8571, 0.8451]}, {"w": "we", "b": [0.1429, 0.8428, 0.166, 0.8642]}, {"w": "will", "b": [0.1723, 0.8428, 0.2027, 0.8642]}, {"w": "see", "b": [0.2089, 0.8428, 0.2343, 0.8642]}, {"w": "in", "b": [0.2405, 0.8428, 0.2575, 0.8642]}, {"w": "Chapter", "b": [0.2638, 0.8428, 0.3314, 0.8642]}, {"w": "14),", "b": [0.3376, 0.8428, 0.3696, 0.8642]}, {"w": "and", "b": [0.3759, 0.8428, 0.4074, 0.8642]}, {"w": "they", "b": [0.4137, 0.8428, 0.4496, 0.8642]}, {"w": "need", "b": [0.4558, 0.8428, 0.4959, 0.8642]}, {"w": "a", "b": [0.5022, 0.8428, 0.5113, 0.8642]}, {"w": "huge", "b": [0.5176, 0.8428, 0.558, 0.8642]}, {"w": "amount", "b": [0.5643, 0.8428, 0.6295, 0.8642]}, {"w": "of", "b": [0.6358, 0.8428, 0.6526, 0.8642]}, {"w": "training", "b": [0.6588, 0.8428, 0.7258, 0.8642]}, {"w": "data.", "b": [0.732, 0.8428, 0.772, 0.8642]}, {"w": "However,", "b": [0.7783, 0.8428, 0.8572, 0.8642]}, {"w": "you", "b": [0.1429, 0.8618, 0.1741, 0.8832]}, {"w": "will", "b": [0.1793, 0.8618, 0.2097, 0.8832]}, {"w": "rarely", "b": [0.2149, 0.8618, 0.2632, 0.8832]}, {"w": "have", "b": [0.2683, 0.8618, 0.3067, 0.8832]}, {"w": "to", "b": [0.3119, 0.8618, 0.3289, 0.8832]}, {"w": "train", "b": [0.3341, 0.8618, 0.3743, 0.8832]}, {"w": "such", "b": [0.3795, 0.8618, 0.4181, 0.8832]}, {"w": "networks", "b": [0.4233, 0.8618, 0.5005, 0.8832]}, {"w": "from", "b": [0.5057, 0.8618, 0.5472, 0.8832]}, {"w": "scratch:", "b": [0.5524, 0.8618, 0.6164, 0.8832]}, {"w": "it", "b": [0.6216, 0.8618, 0.6335, 0.8832]}, {"w": "is", "b": [0.6387, 0.8618, 0.6519, 0.8832]}, {"w": "much", "b": [0.6571, 0.8618, 0.7048, 0.8832]}, {"w": "more", "b": [0.71, 0.8618, 0.7542, 0.8832]}, {"w": "common", "b": [0.7594, 0.8618, 0.835, 0.8832]}, {"w": "to", "b": [0.8402, 0.8618, 0.8571, 0.8832]}]}, {"id": "b_5", "type": "equation", "text": "Fine-Tuning Neural Network Hyperparameters | 319", "words": [{"w": "Fine-Tuning", "b": [0.5239, 0.9225, 0.5948, 0.9388]}, {"w": "Neural", "b": [0.5976, 0.9225, 0.6368, 0.9388]}, {"w": "Network", "b": [0.6396, 0.9225, 0.6903, 0.9388]}, {"w": "Hyperparameters", "b": [0.6931, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "319", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 346, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "17 By Vincent Vanhoucke in his Deep Learning class on Udacity.com.", "words": [{"w": "17", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "By", "b": [0.1587, 0.8749, 0.1753, 0.8912]}, {"w": "Vincent", "b": [0.179, 0.8749, 0.2291, 0.8912]}, {"w": "Vanhoucke", "b": [0.2327, 0.8749, 0.3043, 0.8912]}, {"w": "in", "b": [0.3079, 0.8749, 0.3208, 0.8912]}, {"w": "his", "b": [0.3244, 0.8749, 0.343, 0.8912]}, {"w": "Deep", "b": [0.3466, 0.8749, 0.38, 0.8912]}, {"w": "Learning", "b": [0.3836, 0.8749, 0.4408, 0.8912]}, {"w": "class", "b": [0.4444, 0.8749, 0.4738, 0.8912]}, {"w": "on", "b": [0.4774, 0.8749, 0.4942, 0.8912]}, {"w": "Udacity.com.", "b": [0.4978, 0.8749, 0.5812, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "reuse parts of a pretrained state-of-the-art network that performs a similar task. Training will be a lot faster and require much less data (we will discuss this in Chap‐ ter 11).", "words": [{"w": "reuse", "b": [0.1429, 0.0791, 0.187, 0.1005]}, {"w": "parts", "b": [0.1965, 0.0791, 0.2383, 0.1005]}, {"w": "of", "b": [0.2477, 0.0791, 0.2645, 0.1005]}, {"w": "a", "b": [0.274, 0.0791, 0.2831, 0.1005]}, {"w": "pretrained", "b": [0.2926, 0.0791, 0.3801, 0.1005]}, {"w": "state-of-the-art", "b": [0.3896, 0.0791, 0.5161, 0.1005]}, {"w": "network", "b": [0.5256, 0.0791, 0.5952, 0.1005]}, {"w": "that", "b": [0.6046, 0.0791, 0.6372, 0.1005]}, {"w": "performs", "b": [0.6467, 0.0791, 0.7234, 0.1005]}, {"w": "a", "b": [0.7328, 0.0791, 0.742, 0.1005]}, {"w": "similar", "b": [0.7514, 0.0791, 0.8095, 0.1005]}, {"w": "task.", "b": [0.8189, 0.0791, 0.8571, 0.1005]}, {"w": "Training", "b": [0.1429, 0.0981, 0.2146, 0.1195]}, {"w": "will", "b": [0.2203, 0.0981, 0.2507, 0.1195]}, {"w": "be", "b": [0.2564, 0.0981, 0.2758, 0.1195]}, {"w": "a", "b": [0.2815, 0.0981, 0.2906, 0.1195]}, {"w": "lot", "b": [0.2963, 0.0981, 0.3186, 0.1195]}, {"w": "faster", "b": [0.3243, 0.0981, 0.3702, 0.1195]}, {"w": "and", "b": [0.3759, 0.0981, 0.4074, 0.1195]}, {"w": "require", "b": [0.4131, 0.0981, 0.4736, 0.1195]}, {"w": "much", "b": [0.4793, 0.0981, 0.527, 0.1195]}, {"w": "less", "b": [0.5327, 0.0981, 0.5621, 0.1195]}, {"w": "data", "b": [0.5678, 0.0981, 0.603, 0.1195]}, {"w": "(we", "b": [0.6087, 0.0981, 0.6391, 0.1195]}, {"w": "will", "b": [0.6448, 0.0981, 0.6752, 0.1195]}, {"w": "discuss", "b": [0.6809, 0.0981, 0.7403, 0.1195]}, {"w": "this", "b": [0.746, 0.0981, 0.7767, 0.1195]}, {"w": "in", "b": [0.7824, 0.0981, 0.7994, 0.1195]}, {"w": "Chap‐", "b": [0.8051, 0.0981, 0.8571, 0.1195]}, {"w": "ter", "b": [0.1429, 0.1172, 0.1658, 0.1386]}, {"w": "11).", "b": [0.1705, 0.1172, 0.2025, 0.1386]}]}, {"id": "b_2", "type": "paragraph", "text": "Number of Neurons per Hidden Layer", "words": [{"w": "Number", "b": [0.1429, 0.1513, 0.2263, 0.1799]}, {"w": "of", "b": [0.2312, 0.1513, 0.2522, 0.1799]}, {"w": "Neurons", "b": [0.2571, 0.1513, 0.3429, 0.1799]}, {"w": "per", "b": [0.3478, 0.1513, 0.382, 0.1799]}, {"w": "Hidden", "b": [0.3869, 0.1513, 0.4612, 0.1799]}, {"w": "Layer", "b": [0.4662, 0.1513, 0.5224, 0.1799]}]}, {"id": "b_3", "type": "paragraph", "text": "Obviously the number of neurons in the input and output layers is determined by the type of input and output your task requires. For example, the MNIST task requires 28 x 28 = 784 input neurons and 10 output neurons.", "words": [{"w": "Obviously", "b": [0.1429, 0.1858, 0.2284, 0.2072]}, {"w": "the", "b": [0.2334, 0.1858, 0.2598, 0.2072]}, {"w": "number", "b": [0.2648, 0.1858, 0.3311, 0.2072]}, {"w": "of", "b": [0.3361, 0.1858, 0.3529, 0.2072]}, {"w": "neurons", "b": [0.3579, 0.1858, 0.4266, 0.2072]}, {"w": "in", "b": [0.4316, 0.1858, 0.4486, 0.2072]}, {"w": "the", "b": [0.4536, 0.1858, 0.4799, 0.2072]}, {"w": "input", "b": [0.485, 0.1858, 0.5299, 0.2072]}, {"w": "and", "b": [0.5349, 0.1858, 0.5664, 0.2072]}, {"w": "output", "b": [0.5715, 0.1858, 0.6278, 0.2072]}, {"w": "layers", "b": [0.6328, 0.1858, 0.6807, 0.2072]}, {"w": "is", "b": [0.6857, 0.1858, 0.6989, 0.2072]}, {"w": "determined", "b": [0.7039, 0.1858, 0.8006, 0.2072]}, {"w": "by", "b": [0.8056, 0.1858, 0.8258, 0.2072]}, {"w": "the", "b": [0.8308, 0.1858, 0.8571, 0.2072]}, {"w": "type", "b": [0.1429, 0.2048, 0.1785, 0.2263]}, {"w": "of", "b": [0.1834, 0.2048, 0.2002, 0.2263]}, {"w": "input", "b": [0.2051, 0.2048, 0.25, 0.2263]}, {"w": "and", "b": [0.2549, 0.2048, 0.2865, 0.2263]}, {"w": "output", "b": [0.2914, 0.2048, 0.3478, 0.2263]}, {"w": "your", "b": [0.3527, 0.2048, 0.3916, 0.2263]}, {"w": "task", "b": [0.3965, 0.2048, 0.43, 0.2263]}, {"w": "requires.", "b": [0.4349, 0.2048, 0.5078, 0.2263]}, {"w": "For", "b": [0.5127, 0.2048, 0.5417, 0.2263]}, {"w": "example,", "b": [0.5466, 0.2048, 0.6208, 0.2263]}, {"w": "the", "b": [0.6257, 0.2048, 0.6521, 0.2263]}, {"w": "MNIST", "b": [0.657, 0.2048, 0.7209, 0.2263]}, {"w": "task", "b": [0.7258, 0.2048, 0.7592, 0.2263]}, {"w": "requires", "b": [0.7641, 0.2048, 0.8322, 0.2263]}, {"w": "28", "b": [0.8371, 0.2048, 0.8571, 0.2263]}, {"w": "x", "b": [0.1428, 0.2239, 0.1527, 0.2453]}, {"w": "28", "b": [0.1574, 0.2239, 0.1774, 0.2453]}, {"w": "=", "b": [0.1821, 0.2239, 0.1942, 0.2453]}, {"w": "784", "b": [0.199, 0.2239, 0.229, 0.2453]}, {"w": "input", "b": [0.2337, 0.2239, 0.2786, 0.2453]}, {"w": "neurons", "b": [0.2833, 0.2239, 0.352, 0.2453]}, {"w": "and", "b": [0.3568, 0.2239, 0.3883, 0.2453]}, {"w": "10", "b": [0.393, 0.2239, 0.413, 0.2453]}, {"w": "output", "b": [0.4178, 0.2239, 0.4741, 0.2453]}, {"w": "neurons.", "b": [0.4789, 0.2239, 0.5523, 0.2453]}]}, {"id": "b_4", "type": "paragraph", "text": "As for the hidden layers, it used to be a common practice to size them to form a pyra‐ mid, with fewer and fewer neurons at each layer—the rationale being that many low- level features can coalesce into far fewer high-level features. For example, a typical neural network for MNIST may have three hidden layers, the first with 300 neurons, the second with 200, and the third with 100. However, this practice has been largely abandoned now, as it seems that simply using the same number of neurons in all hid‐ den layers performs just as well in most cases, or even better, and there is just one hyperparameter to tune instead of one per layer—for example, all hidden layers could simply have 150 neurons. However, depending on the dataset, it can sometimes help to make the first hidden layer bigger than the others.", "words": [{"w": "As", "b": [0.1428, 0.252, 0.1649, 0.2734]}, {"w": "for", "b": [0.1698, 0.252, 0.1943, 0.2734]}, {"w": "the", "b": [0.1992, 0.252, 0.2256, 0.2734]}, {"w": "hidden", "b": [0.2305, 0.252, 0.2894, 0.2734]}, {"w": "layers,", "b": [0.2943, 0.252, 0.3469, 0.2734]}, {"w": "it", "b": [0.3518, 0.252, 0.3638, 0.2734]}, {"w": "used", "b": [0.3687, 0.252, 0.4072, 0.2734]}, {"w": "to", "b": [0.4121, 0.252, 0.4291, 0.2734]}, {"w": "be", "b": [0.434, 0.252, 0.4534, 0.2734]}, {"w": "a", "b": [0.4584, 0.252, 0.4675, 0.2734]}, {"w": "common", "b": [0.4724, 0.252, 0.548, 0.2734]}, {"w": "practice", "b": [0.5529, 0.252, 0.6191, 0.2734]}, {"w": "to", "b": [0.624, 0.252, 0.641, 0.2734]}, {"w": "size", "b": [0.6459, 0.252, 0.6767, 0.2734]}, {"w": "them", "b": [0.6816, 0.252, 0.725, 0.2734]}, {"w": "to", "b": [0.7299, 0.252, 0.7469, 0.2734]}, {"w": "form", "b": [0.7518, 0.252, 0.7934, 0.2734]}, {"w": "a", "b": [0.7983, 0.252, 0.8075, 0.2734]}, {"w": "pyra‐", "b": [0.8124, 0.252, 0.8571, 0.2734]}, {"w": "mid,", "b": [0.1429, 0.2711, 0.1813, 0.2925]}, {"w": "with", "b": [0.1868, 0.2711, 0.2241, 0.2925]}, {"w": "fewer", "b": [0.2296, 0.2711, 0.2755, 0.2925]}, {"w": "and", "b": [0.281, 0.2711, 0.3125, 0.2925]}, {"w": "fewer", "b": [0.318, 0.2711, 0.3639, 0.2925]}, {"w": "neurons", "b": [0.3694, 0.2711, 0.4381, 0.2925]}, {"w": "at", "b": [0.4436, 0.2711, 0.4587, 0.2925]}, {"w": "each", "b": [0.4642, 0.2711, 0.5022, 0.2925]}, {"w": "layer—the", "b": [0.5077, 0.2711, 0.5929, 0.2925]}, {"w": "rationale", "b": [0.5984, 0.2711, 0.6721, 0.2925]}, {"w": "being", "b": [0.6776, 0.2711, 0.7238, 0.2925]}, {"w": "that", "b": [0.7293, 0.2711, 0.7619, 0.2925]}, {"w": "many", "b": [0.7674, 0.2711, 0.8141, 0.2925]}, {"w": "low-", "b": [0.8196, 0.2711, 0.8571, 0.2925]}, {"w": "level", "b": [0.1429, 0.2901, 0.1808, 0.3115]}, {"w": "features", "b": [0.1883, 0.2901, 0.2537, 0.3115]}, {"w": "can", "b": [0.2612, 0.2901, 0.2905, 0.3115]}, {"w": "coalesce", "b": [0.298, 0.2901, 0.366, 0.3115]}, {"w": "into", "b": [0.3735, 0.2901, 0.4071, 0.3115]}, {"w": "far", "b": [0.4146, 0.2901, 0.4376, 0.3115]}, {"w": "fewer", "b": [0.4451, 0.2901, 0.491, 0.3115]}, {"w": "high-level", "b": [0.4985, 0.2901, 0.5814, 0.3115]}, {"w": "features.", "b": [0.5889, 0.2901, 0.6591, 0.3115]}, {"w": "For", "b": [0.6666, 0.2901, 0.6956, 0.3115]}, {"w": "example,", "b": [0.7031, 0.2901, 0.7774, 0.3115]}, {"w": "a", "b": [0.7849, 0.2901, 0.794, 0.3115]}, {"w": "typical", "b": [0.8015, 0.2901, 0.8571, 0.3115]}, {"w": "neural", "b": [0.1429, 0.3092, 0.1963, 0.3306]}, {"w": "network", "b": [0.202, 0.3092, 0.2716, 0.3306]}, {"w": "for", "b": [0.2773, 0.3092, 0.3018, 0.3306]}, {"w": "MNIST", "b": [0.3075, 0.3092, 0.3713, 0.3306]}, {"w": "may", "b": [0.377, 0.3092, 0.4124, 0.3306]}, {"w": "have", "b": [0.4181, 0.3092, 0.4565, 0.3306]}, {"w": "three", "b": [0.4622, 0.3092, 0.5051, 0.3306]}, {"w": "hidden", "b": [0.5108, 0.3092, 0.5698, 0.3306]}, {"w": "layers,", "b": [0.5755, 0.3092, 0.6281, 0.3306]}, {"w": "the", "b": [0.6338, 0.3092, 0.6601, 0.3306]}, {"w": "first", "b": [0.6658, 0.3092, 0.6993, 0.3306]}, {"w": "with", "b": [0.705, 0.3092, 0.7423, 0.3306]}, {"w": "300", "b": [0.748, 0.3092, 0.778, 0.3306]}, {"w": "neurons,", "b": [0.7837, 0.3092, 0.8571, 0.3306]}, {"w": "the", "b": [0.1429, 0.3282, 0.1692, 0.3496]}, {"w": "second", "b": [0.1754, 0.3282, 0.2337, 0.3496]}, {"w": "with", "b": [0.2399, 0.3282, 0.2773, 0.3496]}, {"w": "200,", "b": [0.2835, 0.3282, 0.3182, 0.3496]}, {"w": "and", "b": [0.3244, 0.3282, 0.356, 0.3496]}, {"w": "the", "b": [0.3622, 0.3282, 0.3885, 0.3496]}, {"w": "third", "b": [0.3947, 0.3282, 0.4365, 0.3496]}, {"w": "with", "b": [0.4427, 0.3282, 0.48, 0.3496]}, {"w": "100.", "b": [0.4862, 0.3282, 0.521, 0.3496]}, {"w": "However,", "b": [0.5272, 0.3282, 0.606, 0.3496]}, {"w": "this", "b": [0.6122, 0.3282, 0.6429, 0.3496]}, {"w": "practice", "b": [0.6491, 0.3282, 0.7154, 0.3496]}, {"w": "has", "b": [0.7216, 0.3282, 0.7495, 0.3496]}, {"w": "been", "b": [0.7557, 0.3282, 0.7954, 0.3496]}, {"w": "largely", "b": [0.8016, 0.3282, 0.8572, 0.3496]}, {"w": "abandoned", "b": [0.1429, 0.3473, 0.236, 0.3687]}, {"w": "now,", "b": [0.2411, 0.3473, 0.2806, 0.3687]}, {"w": "as", "b": [0.2857, 0.3473, 0.3025, 0.3687]}, {"w": "it", "b": [0.3076, 0.3473, 0.3196, 0.3687]}, {"w": "seems", "b": [0.3247, 0.3473, 0.3747, 0.3687]}, {"w": "that", "b": [0.3798, 0.3473, 0.4124, 0.3687]}, {"w": "simply", "b": [0.4175, 0.3473, 0.4732, 0.3687]}, {"w": "using", "b": [0.4783, 0.3473, 0.5237, 0.3687]}, {"w": "the", "b": [0.5288, 0.3473, 0.5551, 0.3687]}, {"w": "same", "b": [0.5602, 0.3473, 0.6029, 0.3687]}, {"w": "number", "b": [0.6081, 0.3473, 0.6743, 0.3687]}, {"w": "of", "b": [0.6794, 0.3473, 0.6962, 0.3687]}, {"w": "neurons", "b": [0.7013, 0.3473, 0.77, 0.3687]}, {"w": "in", "b": [0.7751, 0.3473, 0.7921, 0.3687]}, {"w": "all", "b": [0.7972, 0.3473, 0.8169, 0.3687]}, {"w": "hid‐", "b": [0.822, 0.3473, 0.8571, 0.3687]}, {"w": "den", "b": [0.1429, 0.3663, 0.1741, 0.3877]}, {"w": "layers", "b": [0.1812, 0.3663, 0.2291, 0.3877]}, {"w": "performs", "b": [0.2362, 0.3663, 0.3129, 0.3877]}, {"w": "just", "b": [0.32, 0.3663, 0.3504, 0.3877]}, {"w": "as", "b": [0.3575, 0.3663, 0.3743, 0.3877]}, {"w": "well", "b": [0.3814, 0.3663, 0.4151, 0.3877]}, {"w": "in", "b": [0.4222, 0.3663, 0.4392, 0.3877]}, {"w": "most", "b": [0.4463, 0.3663, 0.488, 0.3877]}, {"w": "cases,", "b": [0.4951, 0.3663, 0.542, 0.3877]}, {"w": "or", "b": [0.5491, 0.3663, 0.5674, 0.3877]}, {"w": "even", "b": [0.5746, 0.3663, 0.6133, 0.3877]}, {"w": "better,", "b": [0.6204, 0.3663, 0.6726, 0.3877]}, {"w": "and", "b": [0.6797, 0.3663, 0.7113, 0.3877]}, {"w": "there", "b": [0.7184, 0.3663, 0.7613, 0.3877]}, {"w": "is", "b": [0.7684, 0.3663, 0.7816, 0.3877]}, {"w": "just", "b": [0.7888, 0.3663, 0.8191, 0.3877]}, {"w": "one", "b": [0.8263, 0.3663, 0.8571, 0.3877]}, {"w": "hyperparameter", "b": [0.1428, 0.3853, 0.2763, 0.4068]}, {"w": "to", "b": [0.2814, 0.3853, 0.2983, 0.4068]}, {"w": "tune", "b": [0.3033, 0.3853, 0.341, 0.4068]}, {"w": "instead", "b": [0.346, 0.3853, 0.406, 0.4068]}, {"w": "of", "b": [0.411, 0.3853, 0.4278, 0.4068]}, {"w": "one", "b": [0.4328, 0.3853, 0.4637, 0.4068]}, {"w": "per", "b": [0.4687, 0.3853, 0.4962, 0.4068]}, {"w": "layer—for", "b": [0.5012, 0.3853, 0.5846, 0.4068]}, {"w": "example,", "b": [0.5896, 0.3853, 0.6639, 0.4068]}, {"w": "all", "b": [0.6689, 0.3853, 0.6886, 0.4068]}, {"w": "hidden", "b": [0.6936, 0.3853, 0.7525, 0.4068]}, {"w": "layers", "b": [0.7575, 0.3853, 0.8054, 0.4068]}, {"w": "could", "b": [0.8104, 0.3853, 0.8571, 0.4068]}, {"w": "simply", "b": [0.1429, 0.4044, 0.1985, 0.4258]}, {"w": "have", "b": [0.2044, 0.4044, 0.2428, 0.4258]}, {"w": "150", "b": [0.2487, 0.4044, 0.2787, 0.4258]}, {"w": "neurons.", "b": [0.2846, 0.4044, 0.3581, 0.4258]}, {"w": "However,", "b": [0.364, 0.4044, 0.4428, 0.4258]}, {"w": "depending", "b": [0.4487, 0.4044, 0.5375, 0.4258]}, {"w": "on", "b": [0.5434, 0.4044, 0.5654, 0.4258]}, {"w": "the", "b": [0.5713, 0.4044, 0.5976, 0.4258]}, {"w": "dataset,", "b": [0.6035, 0.4044, 0.6664, 0.4258]}, {"w": "it", "b": [0.6723, 0.4044, 0.6842, 0.4258]}, {"w": "can", "b": [0.6901, 0.4044, 0.7195, 0.4258]}, {"w": "sometimes", "b": [0.7254, 0.4044, 0.8151, 0.4258]}, {"w": "help", "b": [0.821, 0.4044, 0.8571, 0.4258]}, {"w": "to", "b": [0.1429, 0.4234, 0.1598, 0.4449]}, {"w": "make", "b": [0.1646, 0.4234, 0.21, 0.4449]}, {"w": "the", "b": [0.2147, 0.4234, 0.241, 0.4449]}, {"w": "first", "b": [0.2458, 0.4234, 0.2792, 0.4449]}, {"w": "hidden", "b": [0.284, 0.4234, 0.3429, 0.4449]}, {"w": "layer", "b": [0.3476, 0.4234, 0.3878, 0.4449]}, {"w": "bigger", "b": [0.3926, 0.4234, 0.4448, 0.4449]}, {"w": "than", "b": [0.4495, 0.4234, 0.4876, 0.4449]}, {"w": "the", "b": [0.4923, 0.4234, 0.5186, 0.4449]}, {"w": "others.", "b": [0.5234, 0.4234, 0.5804, 0.4449]}]}, {"id": "b_5", "type": "paragraph", "text": "Just like for the number of layers, you can try increasing the number of neurons grad‐ ually until the network starts overfitting. In general you will get more bang for the buck by increasing the number of layers than the number of neurons per layer. Unfortunately, as you can see, finding the perfect amount of neurons is still somewhat of a dark art.", "words": [{"w": "Just", "b": [0.1429, 0.4516, 0.1741, 0.473]}, {"w": "like", "b": [0.1789, 0.4516, 0.209, 0.473]}, {"w": "for", "b": [0.2138, 0.4516, 0.2383, 0.473]}, {"w": "the", "b": [0.2432, 0.4516, 0.2695, 0.473]}, {"w": "number", "b": [0.2744, 0.4516, 0.3406, 0.473]}, {"w": "of", "b": [0.3455, 0.4516, 0.3623, 0.473]}, {"w": "layers,", "b": [0.3671, 0.4516, 0.4197, 0.473]}, {"w": "you", "b": [0.4245, 0.4516, 0.4558, 0.473]}, {"w": "can", "b": [0.4606, 0.4516, 0.49, 0.473]}, {"w": "try", "b": [0.4948, 0.4516, 0.5191, 0.473]}, {"w": "increasing", "b": [0.5239, 0.4516, 0.6098, 0.473]}, {"w": "the", "b": [0.6146, 0.4516, 0.641, 0.473]}, {"w": "number", "b": [0.6458, 0.4516, 0.7121, 0.473]}, {"w": "of", "b": [0.7169, 0.4516, 0.7337, 0.473]}, {"w": "neurons", "b": [0.7386, 0.4516, 0.8073, 0.473]}, {"w": "grad‐", "b": [0.8121, 0.4516, 0.8571, 0.473]}, {"w": "ually", "b": [0.1429, 0.4706, 0.1832, 0.492]}, {"w": "until", "b": [0.1902, 0.4706, 0.2295, 0.492]}, {"w": "the", "b": [0.2366, 0.4706, 0.2629, 0.492]}, {"w": "network", "b": [0.27, 0.4706, 0.3396, 0.492]}, {"w": "starts", "b": [0.3466, 0.4706, 0.3915, 0.492]}, {"w": "overfitting.", "b": [0.3986, 0.4706, 0.4914, 0.492]}, {"w": "In", "b": [0.4984, 0.4706, 0.5169, 0.492]}, {"w": "general", "b": [0.524, 0.4706, 0.585, 0.492]}, {"w": "you", "b": [0.5921, 0.4706, 0.6233, 0.492]}, {"w": "will", "b": [0.6304, 0.4706, 0.6608, 0.492]}, {"w": "get", "b": [0.6679, 0.4706, 0.6928, 0.492]}, {"w": "more", "b": [0.6999, 0.4706, 0.7442, 0.492]}, {"w": "bang", "b": [0.7513, 0.4706, 0.7921, 0.492]}, {"w": "for", "b": [0.7992, 0.4706, 0.8237, 0.492]}, {"w": "the", "b": [0.8308, 0.4706, 0.8571, 0.492]}, {"w": "buck", "b": [0.1429, 0.4897, 0.1837, 0.5111]}, {"w": "by", "b": [0.1931, 0.4897, 0.2133, 0.5111]}, {"w": "increasing", "b": [0.2227, 0.4897, 0.3086, 0.5111]}, {"w": "the", "b": [0.3181, 0.4897, 0.3444, 0.5111]}, {"w": "number", "b": [0.3539, 0.4897, 0.4201, 0.5111]}, {"w": "of", "b": [0.4296, 0.4897, 0.4464, 0.5111]}, {"w": "layers", "b": [0.4559, 0.4897, 0.5037, 0.5111]}, {"w": "than", "b": [0.5131, 0.4897, 0.5512, 0.5111]}, {"w": "the", "b": [0.5606, 0.4897, 0.587, 0.5111]}, {"w": "number", "b": [0.5964, 0.4897, 0.6627, 0.5111]}, {"w": "of", "b": [0.6722, 0.4897, 0.6889, 0.5111]}, {"w": "neurons", "b": [0.6984, 0.4897, 0.7671, 0.5111]}, {"w": "per", "b": [0.7766, 0.4897, 0.8041, 0.5111]}, {"w": "layer.", "b": [0.8135, 0.4897, 0.8572, 0.5111]}, {"w": "Unfortunately,", "b": [0.1429, 0.5087, 0.264, 0.5301]}, {"w": "as", "b": [0.2688, 0.5087, 0.2856, 0.5301]}, {"w": "you", "b": [0.2903, 0.5087, 0.3215, 0.5301]}, {"w": "can", "b": [0.3263, 0.5087, 0.3556, 0.5301]}, {"w": "see,", "b": [0.3604, 0.5087, 0.3905, 0.5301]}, {"w": "finding", "b": [0.3952, 0.5087, 0.4561, 0.5301]}, {"w": "the", "b": [0.4608, 0.5087, 0.4871, 0.5301]}, {"w": "perfect", "b": [0.4919, 0.5087, 0.5495, 0.5301]}, {"w": "amount", "b": [0.5543, 0.5087, 0.6195, 0.5301]}, {"w": "of", "b": [0.6243, 0.5087, 0.641, 0.5301]}, {"w": "neurons", "b": [0.6458, 0.5087, 0.7145, 0.5301]}, {"w": "is", "b": [0.7192, 0.5087, 0.7324, 0.5301]}, {"w": "still", "b": [0.7372, 0.5087, 0.7673, 0.5301]}, {"w": "somewhat", "b": [0.772, 0.5087, 0.8567, 0.5301]}, {"w": "of", "b": [0.1429, 0.5278, 0.1597, 0.5492]}, {"w": "a", "b": [0.1644, 0.5278, 0.1735, 0.5492]}, {"w": "dark", "b": [0.1783, 0.5278, 0.2165, 0.5492]}, {"w": "art.", "b": [0.2212, 0.5278, 0.2492, 0.5492]}]}, {"id": "b_6", "type": "paragraph", "text": "A simpler approach is to pick a model with more layers and neurons than you actually need, then use early stopping to prevent it from overfitting (and other regu‐ larization techniques, such as dropout, as we will see in Chapter 11). This has been dubbed the “stretch pants” approach:17 instead of wasting time looking for pants that perfectly match your size, just use large stretch pants that will shrink down to the right size.", "words": [{"w": "A", "b": [0.1429, 0.5559, 0.1573, 0.5773]}, {"w": "simpler", "b": [0.1667, 0.5559, 0.2294, 0.5773]}, {"w": "approach", "b": [0.2388, 0.5559, 0.3169, 0.5773]}, {"w": "is", "b": [0.3263, 0.5559, 0.3396, 0.5773]}, {"w": "to", "b": [0.349, 0.5559, 0.366, 0.5773]}, {"w": "pick", "b": [0.3754, 0.5559, 0.4111, 0.5773]}, {"w": "a", "b": [0.4206, 0.5559, 0.4297, 0.5773]}, {"w": "model", "b": [0.4392, 0.5559, 0.492, 0.5773]}, {"w": "with", "b": [0.5014, 0.5559, 0.5388, 0.5773]}, {"w": "more", "b": [0.5482, 0.5559, 0.5925, 0.5773]}, {"w": "layers", "b": [0.602, 0.5559, 0.6498, 0.5773]}, {"w": "and", "b": [0.6592, 0.5559, 0.6908, 0.5773]}, {"w": "neurons", "b": [0.7002, 0.5559, 0.769, 0.5773]}, {"w": "than", "b": [0.7784, 0.5559, 0.8164, 0.5773]}, {"w": "you", "b": [0.8259, 0.5559, 0.8571, 0.5773]}, {"w": "actually", "b": [0.1429, 0.5749, 0.2075, 0.5963]}, {"w": "need,", "b": [0.2133, 0.5749, 0.2582, 0.5963]}, {"w": "then", "b": [0.264, 0.5749, 0.3017, 0.5963]}, {"w": "use", "b": [0.3075, 0.5749, 0.3351, 0.5963]}, {"w": "early", "b": [0.3409, 0.5749, 0.3815, 0.5963]}, {"w": "stopping", "b": [0.3873, 0.5749, 0.4605, 0.5963]}, {"w": "to", "b": [0.4663, 0.5749, 0.4833, 0.5963]}, {"w": "prevent", "b": [0.4891, 0.5749, 0.5524, 0.5963]}, {"w": "it", "b": [0.5582, 0.5749, 0.5702, 0.5963]}, {"w": "from", "b": [0.576, 0.5749, 0.6176, 0.5963]}, {"w": "overfitting", "b": [0.6234, 0.5749, 0.7114, 0.5963]}, {"w": "(and", "b": [0.7173, 0.5749, 0.756, 0.5963]}, {"w": "other", "b": [0.7618, 0.5749, 0.8065, 0.5963]}, {"w": "regu‐", "b": [0.8123, 0.5749, 0.8571, 0.5963]}, {"w": "larization", "b": [0.1428, 0.594, 0.222, 0.6154]}, {"w": "techniques,", "b": [0.2291, 0.594, 0.3242, 0.6154]}, {"w": "such", "b": [0.3312, 0.594, 0.3699, 0.6154]}, {"w": "as", "b": [0.3769, 0.594, 0.3937, 0.6154]}, {"w": "dropout,", "b": [0.4008, 0.5938, 0.4695, 0.6154]}, {"w": "as", "b": [0.4766, 0.594, 0.4934, 0.6154]}, {"w": "we", "b": [0.5004, 0.594, 0.5236, 0.6154]}, {"w": "will", "b": [0.5306, 0.594, 0.561, 0.6154]}, {"w": "see", "b": [0.5681, 0.594, 0.5934, 0.6154]}, {"w": "in", "b": [0.6005, 0.594, 0.6175, 0.6154]}, {"w": "Chapter", "b": [0.6245, 0.594, 0.6921, 0.6154]}, {"w": "11).", "b": [0.6992, 0.594, 0.7311, 0.6154]}, {"w": "This", "b": [0.7382, 0.594, 0.7754, 0.6154]}, {"w": "has", "b": [0.7825, 0.594, 0.8104, 0.6154]}, {"w": "been", "b": [0.8174, 0.594, 0.8571, 0.6154]}, {"w": "dubbed", "b": [0.1429, 0.613, 0.2059, 0.6344]}, {"w": "the", "b": [0.2117, 0.613, 0.2381, 0.6344]}, {"w": "“stretch", "b": [0.2439, 0.613, 0.3078, 0.6344]}, {"w": "pants”", "b": [0.3136, 0.613, 0.3662, 0.6344]}, {"w": "approach:17", "b": [0.372, 0.613, 0.4662, 0.6344]}, {"w": "instead", "b": [0.472, 0.613, 0.532, 0.6344]}, {"w": "of", "b": [0.5378, 0.613, 0.5546, 0.6344]}, {"w": "wasting", "b": [0.5604, 0.613, 0.6245, 0.6344]}, {"w": "time", "b": [0.6303, 0.613, 0.6682, 0.6344]}, {"w": "looking", "b": [0.674, 0.613, 0.7376, 0.6344]}, {"w": "for", "b": [0.7434, 0.613, 0.7679, 0.6344]}, {"w": "pants", "b": [0.7737, 0.613, 0.8188, 0.6344]}, {"w": "that", "b": [0.8246, 0.613, 0.8572, 0.6344]}, {"w": "perfectly", "b": [0.1429, 0.6321, 0.2154, 0.6535]}, {"w": "match", "b": [0.223, 0.6321, 0.2751, 0.6535]}, {"w": "your", "b": [0.2828, 0.6321, 0.3218, 0.6535]}, {"w": "size,", "b": [0.3294, 0.6321, 0.365, 0.6535]}, {"w": "just", "b": [0.3726, 0.6321, 0.403, 0.6535]}, {"w": "use", "b": [0.4107, 0.6321, 0.4382, 0.6535]}, {"w": "large", "b": [0.4459, 0.6321, 0.4866, 0.6535]}, {"w": "stretch", "b": [0.4943, 0.6321, 0.5512, 0.6535]}, {"w": "pants", "b": [0.5588, 0.6321, 0.6039, 0.6535]}, {"w": "that", "b": [0.6115, 0.6321, 0.6441, 0.6535]}, {"w": "will", "b": [0.6517, 0.6321, 0.6821, 0.6535]}, {"w": "shrink", "b": [0.6898, 0.6321, 0.7436, 0.6535]}, {"w": "down", "b": [0.7512, 0.6321, 0.7985, 0.6535]}, {"w": "to", "b": [0.8062, 0.6321, 0.8232, 0.6535]}, {"w": "the", "b": [0.8308, 0.6321, 0.8571, 0.6535]}, {"w": "right", "b": [0.1429, 0.6511, 0.183, 0.6725]}, {"w": "size.", "b": [0.1877, 0.6511, 0.2233, 0.6725]}]}, {"id": "b_7", "type": "paragraph", "text": "Learning Rate, Batch Size and Other Hyperparameters", "words": [{"w": "Learning", "b": [0.1429, 0.6853, 0.2344, 0.7139]}, {"w": "Rate,", "b": [0.2393, 0.6853, 0.2936, 0.7139]}, {"w": "Batch", "b": [0.2986, 0.6853, 0.3575, 0.7139]}, {"w": "Size", "b": [0.3624, 0.6853, 0.4034, 0.7139]}, {"w": "and", "b": [0.4084, 0.6853, 0.4477, 0.7139]}, {"w": "Other", "b": [0.4526, 0.6853, 0.5106, 0.7139]}, {"w": "Hyperparameters", "b": [0.5155, 0.6853, 0.6955, 0.7139]}]}, {"id": "b_8", "type": "paragraph", "text": "The number of hidden layers and neurons are not the only hyperparameters you can tweak in an MLP. Here are some of the most important ones, and some tips on how to set them:", "words": [{"w": "The", "b": [0.1429, 0.7198, 0.1757, 0.7412]}, {"w": "number", "b": [0.1813, 0.7198, 0.2476, 0.7412]}, {"w": "of", "b": [0.2531, 0.7198, 0.2699, 0.7412]}, {"w": "hidden", "b": [0.2755, 0.7198, 0.3344, 0.7412]}, {"w": "layers", "b": [0.34, 0.7198, 0.3878, 0.7412]}, {"w": "and", "b": [0.3934, 0.7198, 0.4249, 0.7412]}, {"w": "neurons", "b": [0.4305, 0.7198, 0.4992, 0.7412]}, {"w": "are", "b": [0.5048, 0.7198, 0.5305, 0.7412]}, {"w": "not", "b": [0.536, 0.7198, 0.5644, 0.7412]}, {"w": "the", "b": [0.57, 0.7198, 0.5963, 0.7412]}, {"w": "only", "b": [0.6019, 0.7198, 0.6387, 0.7412]}, {"w": "hyperparameters", "b": [0.6443, 0.7198, 0.7854, 0.7412]}, {"w": "you", "b": [0.791, 0.7198, 0.8222, 0.7412]}, {"w": "can", "b": [0.8278, 0.7198, 0.8572, 0.7412]}, {"w": "tweak", "b": [0.1429, 0.7388, 0.1918, 0.7602]}, {"w": "in", "b": [0.1979, 0.7388, 0.2149, 0.7602]}, {"w": "an", "b": [0.2209, 0.7388, 0.2415, 0.7602]}, {"w": "MLP.", "b": [0.2475, 0.7388, 0.2909, 0.7602]}, {"w": "Here", "b": [0.2969, 0.7388, 0.3378, 0.7602]}, {"w": "are", "b": [0.3439, 0.7388, 0.3696, 0.7602]}, {"w": "some", "b": [0.3757, 0.7388, 0.4198, 0.7602]}, {"w": "of", "b": [0.4259, 0.7388, 0.4427, 0.7602]}, {"w": "the", "b": [0.4487, 0.7388, 0.4751, 0.7602]}, {"w": "most", "b": [0.4811, 0.7388, 0.5228, 0.7602]}, {"w": "important", "b": [0.5289, 0.7388, 0.6133, 0.7602]}, {"w": "ones,", "b": [0.6193, 0.7388, 0.6626, 0.7602]}, {"w": "and", "b": [0.6686, 0.7388, 0.7002, 0.7602]}, {"w": "some", "b": [0.7062, 0.7388, 0.7504, 0.7602]}, {"w": "tips", "b": [0.7565, 0.7388, 0.787, 0.7602]}, {"w": "on", "b": [0.793, 0.7388, 0.8151, 0.7602]}, {"w": "how", "b": [0.8211, 0.7388, 0.8571, 0.7602]}, {"w": "to", "b": [0.1429, 0.7578, 0.1598, 0.7793]}, {"w": "set", "b": [0.1646, 0.7578, 0.1874, 0.7793]}, {"w": "them:", "b": [0.1921, 0.7578, 0.2403, 0.7793]}]}, {"id": "b_9", "type": "paragraph", "text": "• The learning rate is arguably the most important hyperparameter. In general, the optimal learning rate is about half of the maximum learning rate (i.e., the learn‐", "words": [{"w": "•", "b": [0.16, 0.792, 0.1682, 0.8134]}, {"w": "The", "b": [0.1786, 0.792, 0.2114, 0.8134]}, {"w": "learning", "b": [0.2168, 0.792, 0.2859, 0.8134]}, {"w": "rate", "b": [0.2913, 0.792, 0.323, 0.8134]}, {"w": "is", "b": [0.3284, 0.792, 0.3417, 0.8134]}, {"w": "arguably", "b": [0.3471, 0.792, 0.4193, 0.8134]}, {"w": "the", "b": [0.4247, 0.792, 0.4511, 0.8134]}, {"w": "most", "b": [0.4565, 0.792, 0.4982, 0.8134]}, {"w": "important", "b": [0.5036, 0.792, 0.588, 0.8134]}, {"w": "hyperparameter.", "b": [0.5934, 0.792, 0.7303, 0.8134]}, {"w": "In", "b": [0.7357, 0.792, 0.7542, 0.8134]}, {"w": "general,", "b": [0.7596, 0.792, 0.8254, 0.8134]}, {"w": "the", "b": [0.8308, 0.792, 0.8571, 0.8134]}, {"w": "optimal", "b": [0.1786, 0.8111, 0.2435, 0.8325]}, {"w": "learning", "b": [0.2495, 0.8111, 0.3186, 0.8325]}, {"w": "rate", "b": [0.3246, 0.8111, 0.3563, 0.8325]}, {"w": "is", "b": [0.3623, 0.8111, 0.3755, 0.8325]}, {"w": "about", "b": [0.3815, 0.8111, 0.4293, 0.8325]}, {"w": "half", "b": [0.4352, 0.8111, 0.4669, 0.8325]}, {"w": "of", "b": [0.4729, 0.8111, 0.4897, 0.8325]}, {"w": "the", "b": [0.4957, 0.8111, 0.522, 0.8325]}, {"w": "maximum", "b": [0.528, 0.8111, 0.6144, 0.8325]}, {"w": "learning", "b": [0.6204, 0.8111, 0.6895, 0.8325]}, {"w": "rate", "b": [0.6955, 0.8111, 0.7272, 0.8325]}, {"w": "(i.e.,", "b": [0.7332, 0.8111, 0.769, 0.8325]}, {"w": "the", "b": [0.775, 0.8111, 0.8014, 0.8325]}, {"w": "learn‐", "b": [0.8073, 0.8111, 0.8571, 0.8325]}]}, {"id": "b_10", "type": "paragraph", "text": "320 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "320", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2746, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3636, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4163, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4583, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 347, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "18 “Practical recommendations for gradient-based training of deep architectures,” Yoshua Bengio (2012).", "words": [{"w": "18", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Practical", "b": [0.1587, 0.8749, 0.2203, 0.8912]}, {"w": "recommendations", "b": [0.224, 0.8749, 0.3396, 0.8912]}, {"w": "for", "b": [0.3432, 0.8749, 0.3619, 0.8912]}, {"w": "gradient-based", "b": [0.3655, 0.8749, 0.46, 0.8912]}, {"w": "training", "b": [0.4636, 0.8749, 0.5146, 0.8912]}, {"w": "of", "b": [0.5182, 0.8749, 0.531, 0.8912]}, {"w": "deep", "b": [0.5346, 0.8749, 0.5648, 0.8912]}, {"w": "architectures,”", "b": [0.5684, 0.8749, 0.6585, 0.8912]}, {"w": "Yoshua", "b": [0.6621, 0.8749, 0.7077, 0.8912]}, {"w": "Bengio", "b": [0.7113, 0.8749, 0.7562, 0.8912]}, {"w": "(2012).", "b": [0.7598, 0.8749, 0.8049, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "ing rate above which the training algorithm diverges, as we saw in Chapter 4). So a simple approach for tuning the learning rate is to start with a large value that makes the training algorithm diverge, then divide this value by 3 and try again, and repeat until the training algorithm stops diverging. At that point, you gener‐ ally won’t be too far from the optimal learning rate. That said, it is sometimes useful to reduce the learning rate during training: we will discuss this in Chap‐ ter 11.", "words": [{"w": "ing", "b": [0.1786, 0.0791, 0.2053, 0.1005]}, {"w": "rate", "b": [0.2105, 0.0791, 0.2422, 0.1005]}, {"w": "above", "b": [0.2474, 0.0791, 0.2963, 0.1005]}, {"w": "which", "b": [0.3015, 0.0791, 0.3524, 0.1005]}, {"w": "the", "b": [0.3576, 0.0791, 0.384, 0.1005]}, {"w": "training", "b": [0.3892, 0.0791, 0.4561, 0.1005]}, {"w": "algorithm", "b": [0.4613, 0.0791, 0.544, 0.1005]}, {"w": "diverges,", "b": [0.5492, 0.0791, 0.623, 0.1005]}, {"w": "as", "b": [0.6282, 0.0791, 0.645, 0.1005]}, {"w": "we", "b": [0.6502, 0.0791, 0.6734, 0.1005]}, {"w": "saw", "b": [0.6786, 0.0791, 0.7093, 0.1005]}, {"w": "in", "b": [0.7145, 0.0791, 0.7315, 0.1005]}, {"w": "Chapter", "b": [0.7367, 0.0791, 0.8043, 0.1005]}, {"w": "4).", "b": [0.809, 0.0791, 0.8314, 0.1005]}, {"w": "So", "b": [0.8362, 0.0791, 0.8567, 0.1005]}, {"w": "a", "b": [0.1786, 0.0981, 0.1877, 0.1195]}, {"w": "simple", "b": [0.1943, 0.0981, 0.2492, 0.1195]}, {"w": "approach", "b": [0.2557, 0.0981, 0.3337, 0.1195]}, {"w": "for", "b": [0.3403, 0.0981, 0.3648, 0.1195]}, {"w": "tuning", "b": [0.3713, 0.0981, 0.4269, 0.1195]}, {"w": "the", "b": [0.4334, 0.0981, 0.4598, 0.1195]}, {"w": "learning", "b": [0.4663, 0.0981, 0.5354, 0.1195]}, {"w": "rate", "b": [0.5419, 0.0981, 0.5736, 0.1195]}, {"w": "is", "b": [0.5802, 0.0981, 0.5934, 0.1195]}, {"w": "to", "b": [0.5999, 0.0981, 0.6169, 0.1195]}, {"w": "start", "b": [0.6234, 0.0981, 0.6607, 0.1195]}, {"w": "with", "b": [0.6672, 0.0981, 0.7045, 0.1195]}, {"w": "a", "b": [0.7111, 0.0981, 0.7202, 0.1195]}, {"w": "large", "b": [0.7268, 0.0981, 0.7675, 0.1195]}, {"w": "value", "b": [0.774, 0.0981, 0.818, 0.1195]}, {"w": "that", "b": [0.8246, 0.0981, 0.8571, 0.1195]}, {"w": "makes", "b": [0.1786, 0.1172, 0.2316, 0.1386]}, {"w": "the", "b": [0.238, 0.1172, 0.2644, 0.1386]}, {"w": "training", "b": [0.2708, 0.1172, 0.3377, 0.1386]}, {"w": "algorithm", "b": [0.3442, 0.1172, 0.4268, 0.1386]}, {"w": "diverge,", "b": [0.4333, 0.1172, 0.4994, 0.1386]}, {"w": "then", "b": [0.5059, 0.1172, 0.5436, 0.1386]}, {"w": "divide", "b": [0.55, 0.1172, 0.6017, 0.1386]}, {"w": "this", "b": [0.6081, 0.1172, 0.6388, 0.1386]}, {"w": "value", "b": [0.6453, 0.1172, 0.6892, 0.1386]}, {"w": "by", "b": [0.6957, 0.1172, 0.7158, 0.1386]}, {"w": "3", "b": [0.7223, 0.1172, 0.7323, 0.1386]}, {"w": "and", "b": [0.7387, 0.1172, 0.7702, 0.1386]}, {"w": "try", "b": [0.7767, 0.1172, 0.8009, 0.1386]}, {"w": "again,", "b": [0.8074, 0.1172, 0.8571, 0.1386]}, {"w": "and", "b": [0.1786, 0.1362, 0.2101, 0.1576]}, {"w": "repeat", "b": [0.2156, 0.1362, 0.2671, 0.1576]}, {"w": "until", "b": [0.2726, 0.1362, 0.3119, 0.1576]}, {"w": "the", "b": [0.3174, 0.1362, 0.3437, 0.1576]}, {"w": "training", "b": [0.3492, 0.1362, 0.4162, 0.1576]}, {"w": "algorithm", "b": [0.4217, 0.1362, 0.5043, 0.1576]}, {"w": "stops", "b": [0.5099, 0.1362, 0.553, 0.1576]}, {"w": "diverging.", "b": [0.5586, 0.1362, 0.6426, 0.1576]}, {"w": "At", "b": [0.6481, 0.1362, 0.668, 0.1576]}, {"w": "that", "b": [0.6735, 0.1362, 0.7061, 0.1576]}, {"w": "point,", "b": [0.7116, 0.1362, 0.7609, 0.1576]}, {"w": "you", "b": [0.7664, 0.1362, 0.7976, 0.1576]}, {"w": "gener‐", "b": [0.8031, 0.1362, 0.8571, 0.1576]}, {"w": "ally", "b": [0.1786, 0.1553, 0.2078, 0.1767]}, {"w": "won’t", "b": [0.2152, 0.1553, 0.2601, 0.1767]}, {"w": "be", "b": [0.2675, 0.1553, 0.287, 0.1767]}, {"w": "too", "b": [0.2944, 0.1553, 0.322, 0.1767]}, {"w": "far", "b": [0.3294, 0.1553, 0.3525, 0.1767]}, {"w": "from", "b": [0.3599, 0.1553, 0.4015, 0.1767]}, {"w": "the", "b": [0.4089, 0.1553, 0.4352, 0.1767]}, {"w": "optimal", "b": [0.4426, 0.1553, 0.5076, 0.1767]}, {"w": "learning", "b": [0.515, 0.1553, 0.5841, 0.1767]}, {"w": "rate.", "b": [0.5916, 0.1553, 0.628, 0.1767]}, {"w": "That", "b": [0.6354, 0.1553, 0.6745, 0.1767]}, {"w": "said,", "b": [0.6819, 0.1553, 0.72, 0.1767]}, {"w": "it", "b": [0.7275, 0.1553, 0.7394, 0.1767]}, {"w": "is", "b": [0.7468, 0.1553, 0.76, 0.1767]}, {"w": "sometimes", "b": [0.7675, 0.1553, 0.8572, 0.1767]}, {"w": "useful", "b": [0.1786, 0.1743, 0.2286, 0.1957]}, {"w": "to", "b": [0.2353, 0.1743, 0.2523, 0.1957]}, {"w": "reduce", "b": [0.259, 0.1743, 0.3153, 0.1957]}, {"w": "the", "b": [0.322, 0.1743, 0.3484, 0.1957]}, {"w": "learning", "b": [0.3551, 0.1743, 0.4242, 0.1957]}, {"w": "rate", "b": [0.4309, 0.1743, 0.4626, 0.1957]}, {"w": "during", "b": [0.4693, 0.1743, 0.5258, 0.1957]}, {"w": "training:", "b": [0.5325, 0.1743, 0.6042, 0.1957]}, {"w": "we", "b": [0.6109, 0.1743, 0.6341, 0.1957]}, {"w": "will", "b": [0.6408, 0.1743, 0.6712, 0.1957]}, {"w": "discuss", "b": [0.6779, 0.1743, 0.7373, 0.1957]}, {"w": "this", "b": [0.744, 0.1743, 0.7747, 0.1957]}, {"w": "in", "b": [0.7814, 0.1743, 0.7984, 0.1957]}, {"w": "Chap‐", "b": [0.8051, 0.1743, 0.8571, 0.1957]}, {"w": "ter", "b": [0.1786, 0.1933, 0.2015, 0.2148]}, {"w": "11.", "b": [0.2062, 0.1933, 0.231, 0.2148]}]}, {"id": "b_2", "type": "paragraph", "text": "• Choosing a better optimizer than plain old Mini-batch Gradient Descent (and tuning its hyperparameters) is also quite important. We will discuss this in Chap‐ ter 11.", "words": [{"w": "•", "b": [0.16, 0.2184, 0.1681, 0.2399]}, {"w": "Choosing", "b": [0.1786, 0.2184, 0.2592, 0.2399]}, {"w": "a", "b": [0.2669, 0.2184, 0.276, 0.2399]}, {"w": "better", "b": [0.2837, 0.2184, 0.3325, 0.2399]}, {"w": "optimizer", "b": [0.3402, 0.2184, 0.4216, 0.2399]}, {"w": "than", "b": [0.4293, 0.2184, 0.4674, 0.2399]}, {"w": "plain", "b": [0.4751, 0.2184, 0.5174, 0.2399]}, {"w": "old", "b": [0.5251, 0.2184, 0.552, 0.2399]}, {"w": "Mini-batch", "b": [0.5597, 0.2184, 0.6539, 0.2399]}, {"w": "Gradient", "b": [0.6616, 0.2184, 0.7361, 0.2399]}, {"w": "Descent", "b": [0.7438, 0.2184, 0.8107, 0.2399]}, {"w": "(and", "b": [0.8184, 0.2184, 0.8571, 0.2399]}, {"w": "tuning", "b": [0.1786, 0.2375, 0.2341, 0.2589]}, {"w": "its", "b": [0.2392, 0.2375, 0.2588, 0.2589]}, {"w": "hyperparameters)", "b": [0.2639, 0.2375, 0.4122, 0.2589]}, {"w": "is", "b": [0.4173, 0.2375, 0.4305, 0.2589]}, {"w": "also", "b": [0.4356, 0.2375, 0.4683, 0.2589]}, {"w": "quite", "b": [0.4734, 0.2375, 0.5159, 0.2589]}, {"w": "important.", "b": [0.5209, 0.2375, 0.6101, 0.2589]}, {"w": "We", "b": [0.6151, 0.2375, 0.6422, 0.2589]}, {"w": "will", "b": [0.6473, 0.2375, 0.6777, 0.2589]}, {"w": "discuss", "b": [0.6828, 0.2375, 0.7422, 0.2589]}, {"w": "this", "b": [0.7472, 0.2375, 0.7779, 0.2589]}, {"w": "in", "b": [0.783, 0.2375, 0.8, 0.2589]}, {"w": "Chap‐", "b": [0.8051, 0.2375, 0.8571, 0.2589]}, {"w": "ter", "b": [0.1786, 0.2565, 0.2015, 0.2779]}, {"w": "11.", "b": [0.2062, 0.2565, 0.231, 0.2779]}]}, {"id": "b_3", "type": "paragraph", "text": "• The batch size can also have a significant impact on your model’s performance and the training time. In general the optimal batch size will be lower than 32 (in April 2018, Yann Lecun even tweeted \"Friends don’t let friends use mini-batches larger than 32“). A small batch size ensures that each training iteration is very fast, and although a large batch size will give a more precise estimate of the gradi‐ ents, in practice this does not matter much since the optimization landscape is quite complex and the direction of the true gradients do not point precisely in the direction of the optimum. However, having a batch size greater than 10 helps take advantage of hardware and software optimizations, in particular for matrix multiplications, so it will speed up training. Moreover, if you use Batch Normal‐ ization (see Chapter 11), the batch size should not be too small (in general no less than 20).", "words": [{"w": "•", "b": [0.16, 0.2816, 0.1682, 0.303]}, {"w": "The", "b": [0.1786, 0.2816, 0.2114, 0.303]}, {"w": "batch", "b": [0.2184, 0.2816, 0.2641, 0.303]}, {"w": "size", "b": [0.2711, 0.2816, 0.3019, 0.303]}, {"w": "can", "b": [0.3089, 0.2816, 0.3383, 0.303]}, {"w": "also", "b": [0.3453, 0.2816, 0.378, 0.303]}, {"w": "have", "b": [0.385, 0.2816, 0.4234, 0.303]}, {"w": "a", "b": [0.4305, 0.2816, 0.4396, 0.303]}, {"w": "significant", "b": [0.4466, 0.2816, 0.5336, 0.303]}, {"w": "impact", "b": [0.5407, 0.2816, 0.5982, 0.303]}, {"w": "on", "b": [0.6052, 0.2816, 0.6272, 0.303]}, {"w": "your", "b": [0.6342, 0.2816, 0.6732, 0.303]}, {"w": "model’s", "b": [0.6802, 0.2816, 0.7428, 0.303]}, {"w": "performance", "b": [0.7498, 0.2816, 0.8571, 0.303]}, {"w": "and", "b": [0.1786, 0.3007, 0.2101, 0.3221]}, {"w": "the", "b": [0.2158, 0.3007, 0.2421, 0.3221]}, {"w": "training", "b": [0.2478, 0.3007, 0.3147, 0.3221]}, {"w": "time.", "b": [0.3204, 0.3007, 0.363, 0.3221]}, {"w": "In", "b": [0.3687, 0.3007, 0.3872, 0.3221]}, {"w": "general", "b": [0.3929, 0.3007, 0.4539, 0.3221]}, {"w": "the", "b": [0.4595, 0.3007, 0.4859, 0.3221]}, {"w": "optimal", "b": [0.4915, 0.3007, 0.5565, 0.3221]}, {"w": "batch", "b": [0.5622, 0.3007, 0.6078, 0.3221]}, {"w": "size", "b": [0.6135, 0.3007, 0.6443, 0.3221]}, {"w": "will", "b": [0.65, 0.3007, 0.6804, 0.3221]}, {"w": "be", "b": [0.6861, 0.3007, 0.7055, 0.3221]}, {"w": "lower", "b": [0.7112, 0.3007, 0.7579, 0.3221]}, {"w": "than", "b": [0.7636, 0.3007, 0.8016, 0.3221]}, {"w": "32", "b": [0.8073, 0.3007, 0.8273, 0.3221]}, {"w": "(in", "b": [0.833, 0.3007, 0.8571, 0.3221]}, {"w": "April", "b": [0.1786, 0.3197, 0.2216, 0.3411]}, {"w": "2018,", "b": [0.2288, 0.3197, 0.2736, 0.3411]}, {"w": "Yann", "b": [0.2807, 0.3197, 0.3235, 0.3411]}, {"w": "Lecun", "b": [0.3307, 0.3197, 0.382, 0.3411]}, {"w": "even", "b": [0.3892, 0.3197, 0.428, 0.3411]}, {"w": "tweeted", "b": [0.4352, 0.3197, 0.4997, 0.3411]}, {"w": "\"Friends", "b": [0.5069, 0.3195, 0.5744, 0.3411]}, {"w": "don’t", "b": [0.5816, 0.3195, 0.6215, 0.3411]}, {"w": "let", "b": [0.6287, 0.3195, 0.6484, 0.3411]}, {"w": "friends", "b": [0.6557, 0.3195, 0.7118, 0.3411]}, {"w": "use", "b": [0.7191, 0.3195, 0.7457, 0.3411]}, {"w": "mini-batches", "b": [0.7529, 0.3195, 0.8571, 0.3411]}, {"w": "larger", "b": [0.1786, 0.3386, 0.2257, 0.3602]}, {"w": "than", "b": [0.2332, 0.3386, 0.2709, 0.3602]}, {"w": "32“).", "b": [0.2784, 0.3386, 0.3185, 0.3602]}, {"w": "A", "b": [0.3259, 0.3388, 0.3403, 0.3602]}, {"w": "small", "b": [0.3478, 0.3388, 0.3922, 0.3602]}, {"w": "batch", "b": [0.3996, 0.3388, 0.4453, 0.3602]}, {"w": "size", "b": [0.4527, 0.3388, 0.4835, 0.3602]}, {"w": "ensures", "b": [0.491, 0.3388, 0.5542, 0.3602]}, {"w": "that", "b": [0.5616, 0.3388, 0.5942, 0.3602]}, {"w": "each", "b": [0.6016, 0.3388, 0.6396, 0.3602]}, {"w": "training", "b": [0.647, 0.3388, 0.714, 0.3602]}, {"w": "iteration", "b": [0.7214, 0.3388, 0.7926, 0.3602]}, {"w": "is", "b": [0.8001, 0.3388, 0.8133, 0.3602]}, {"w": "very", "b": [0.8207, 0.3388, 0.8571, 0.3602]}, {"w": "fast,", "b": [0.1786, 0.3578, 0.2126, 0.3792]}, {"w": "and", "b": [0.2175, 0.3578, 0.249, 0.3792]}, {"w": "although", "b": [0.2539, 0.3578, 0.3284, 0.3792]}, {"w": "a", "b": [0.3332, 0.3578, 0.3424, 0.3792]}, {"w": "large", "b": [0.3472, 0.3578, 0.388, 0.3792]}, {"w": "batch", "b": [0.3928, 0.3578, 0.4385, 0.3792]}, {"w": "size", "b": [0.4433, 0.3578, 0.4742, 0.3792]}, {"w": "will", "b": [0.479, 0.3578, 0.5094, 0.3792]}, {"w": "give", "b": [0.5143, 0.3578, 0.5481, 0.3792]}, {"w": "a", "b": [0.553, 0.3578, 0.5621, 0.3792]}, {"w": "more", "b": [0.567, 0.3578, 0.6112, 0.3792]}, {"w": "precise", "b": [0.6161, 0.3578, 0.6745, 0.3792]}, {"w": "estimate", "b": [0.6794, 0.3578, 0.7488, 0.3792]}, {"w": "of", "b": [0.7537, 0.3578, 0.7705, 0.3792]}, {"w": "the", "b": [0.7753, 0.3578, 0.8017, 0.3792]}, {"w": "gradi‐", "b": [0.8065, 0.3578, 0.8572, 0.3792]}, {"w": "ents,", "b": [0.1786, 0.3769, 0.2172, 0.3983]}, {"w": "in", "b": [0.2243, 0.3769, 0.2413, 0.3983]}, {"w": "practice", "b": [0.2484, 0.3769, 0.3146, 0.3983]}, {"w": "this", "b": [0.3218, 0.3769, 0.3525, 0.3983]}, {"w": "does", "b": [0.3596, 0.3769, 0.3977, 0.3983]}, {"w": "not", "b": [0.4048, 0.3769, 0.4332, 0.3983]}, {"w": "matter", "b": [0.4404, 0.3769, 0.4955, 0.3983]}, {"w": "much", "b": [0.5026, 0.3769, 0.5503, 0.3983]}, {"w": "since", "b": [0.5574, 0.3769, 0.5997, 0.3983]}, {"w": "the", "b": [0.6068, 0.3769, 0.6331, 0.3983]}, {"w": "optimization", "b": [0.6403, 0.3769, 0.7479, 0.3983]}, {"w": "landscape", "b": [0.755, 0.3769, 0.8368, 0.3983]}, {"w": "is", "b": [0.8439, 0.3769, 0.8571, 0.3983]}, {"w": "quite", "b": [0.1786, 0.3959, 0.2211, 0.4173]}, {"w": "complex", "b": [0.2282, 0.3959, 0.2992, 0.4173]}, {"w": "and", "b": [0.3063, 0.3959, 0.3378, 0.4173]}, {"w": "the", "b": [0.3449, 0.3959, 0.3713, 0.4173]}, {"w": "direction", "b": [0.3784, 0.3959, 0.4543, 0.4173]}, {"w": "of", "b": [0.4614, 0.3959, 0.4782, 0.4173]}, {"w": "the", "b": [0.4853, 0.3959, 0.5116, 0.4173]}, {"w": "true", "b": [0.5187, 0.3959, 0.5527, 0.4173]}, {"w": "gradients", "b": [0.5599, 0.3959, 0.6369, 0.4173]}, {"w": "do", "b": [0.644, 0.3959, 0.6657, 0.4173]}, {"w": "not", "b": [0.6728, 0.3959, 0.7011, 0.4173]}, {"w": "point", "b": [0.7082, 0.3959, 0.7527, 0.4173]}, {"w": "precisely", "b": [0.7598, 0.3959, 0.8331, 0.4173]}, {"w": "in", "b": [0.8402, 0.3959, 0.8571, 0.4173]}, {"w": "the", "b": [0.1786, 0.415, 0.2049, 0.4364]}, {"w": "direction", "b": [0.2102, 0.415, 0.2862, 0.4364]}, {"w": "of", "b": [0.2915, 0.415, 0.3083, 0.4364]}, {"w": "the", "b": [0.3137, 0.415, 0.34, 0.4364]}, {"w": "optimum.", "b": [0.3454, 0.415, 0.4284, 0.4364]}, {"w": "However,", "b": [0.4337, 0.415, 0.5126, 0.4364]}, {"w": "having", "b": [0.5179, 0.415, 0.5742, 0.4364]}, {"w": "a", "b": [0.5796, 0.415, 0.5887, 0.4364]}, {"w": "batch", "b": [0.5941, 0.415, 0.6397, 0.4364]}, {"w": "size", "b": [0.645, 0.415, 0.6759, 0.4364]}, {"w": "greater", "b": [0.6812, 0.415, 0.7392, 0.4364]}, {"w": "than", "b": [0.7446, 0.415, 0.7826, 0.4364]}, {"w": "10", "b": [0.788, 0.415, 0.808, 0.4364]}, {"w": "helps", "b": [0.8133, 0.415, 0.8571, 0.4364]}, {"w": "take", "b": [0.1786, 0.434, 0.2133, 0.4554]}, {"w": "advantage", "b": [0.2196, 0.434, 0.3036, 0.4554]}, {"w": "of", "b": [0.3099, 0.434, 0.3267, 0.4554]}, {"w": "hardware", "b": [0.333, 0.434, 0.412, 0.4554]}, {"w": "and", "b": [0.4184, 0.434, 0.4499, 0.4554]}, {"w": "software", "b": [0.4562, 0.434, 0.527, 0.4554]}, {"w": "optimizations,", "b": [0.5333, 0.434, 0.6533, 0.4554]}, {"w": "in", "b": [0.6596, 0.434, 0.6766, 0.4554]}, {"w": "particular", "b": [0.6829, 0.434, 0.7647, 0.4554]}, {"w": "for", "b": [0.771, 0.434, 0.7955, 0.4554]}, {"w": "matrix", "b": [0.8018, 0.434, 0.8571, 0.4554]}, {"w": "multiplications,", "b": [0.1786, 0.4531, 0.3092, 0.4745]}, {"w": "so", "b": [0.3154, 0.4531, 0.3336, 0.4745]}, {"w": "it", "b": [0.3398, 0.4531, 0.3517, 0.4745]}, {"w": "will", "b": [0.3579, 0.4531, 0.3883, 0.4745]}, {"w": "speed", "b": [0.3945, 0.4531, 0.4417, 0.4745]}, {"w": "up", "b": [0.4479, 0.4531, 0.4699, 0.4745]}, {"w": "training.", "b": [0.476, 0.4531, 0.5477, 0.4745]}, {"w": "Moreover,", "b": [0.5539, 0.4531, 0.6394, 0.4745]}, {"w": "if", "b": [0.6456, 0.4531, 0.6573, 0.4745]}, {"w": "you", "b": [0.6635, 0.4531, 0.6948, 0.4745]}, {"w": "use", "b": [0.7009, 0.4531, 0.7285, 0.4745]}, {"w": "Batch", "b": [0.7347, 0.4529, 0.7811, 0.4745]}, {"w": "Normal‐", "b": [0.7873, 0.4529, 0.8571, 0.4745]}, {"w": "ization", "b": [0.1786, 0.4719, 0.2353, 0.4935]}, {"w": "(see", "b": [0.2402, 0.4721, 0.2727, 0.4935]}, {"w": "Chapter", "b": [0.2777, 0.4721, 0.3452, 0.4935]}, {"w": "11),", "b": [0.35, 0.4721, 0.3821, 0.4935]}, {"w": "the", "b": [0.3871, 0.4721, 0.4134, 0.4935]}, {"w": "batch", "b": [0.4183, 0.4721, 0.4639, 0.4935]}, {"w": "size", "b": [0.4689, 0.4721, 0.4997, 0.4935]}, {"w": "should", "b": [0.5046, 0.4721, 0.5613, 0.4935]}, {"w": "not", "b": [0.5663, 0.4721, 0.5946, 0.4935]}, {"w": "be", "b": [0.5996, 0.4721, 0.619, 0.4935]}, {"w": "too", "b": [0.6239, 0.4721, 0.6515, 0.4935]}, {"w": "small", "b": [0.6564, 0.4721, 0.7008, 0.4935]}, {"w": "(in", "b": [0.7058, 0.4721, 0.7299, 0.4935]}, {"w": "general", "b": [0.7349, 0.4721, 0.7959, 0.4935]}, {"w": "no", "b": [0.8008, 0.4721, 0.8228, 0.4935]}, {"w": "less", "b": [0.8277, 0.4721, 0.8571, 0.4935]}, {"w": "than", "b": [0.1786, 0.4912, 0.2166, 0.5126]}, {"w": "20).", "b": [0.2213, 0.4912, 0.2533, 0.5126]}]}, {"id": "b_4", "type": "paragraph", "text": "• We discussed the choice of the activation function earlier in this chapter: in gen‐ eral, the ReLU activation function will be a good default for all hidden layers. For the output layer, it really depends on your task.", "words": [{"w": "•", "b": [0.16, 0.5162, 0.1682, 0.5377]}, {"w": "We", "b": [0.1786, 0.5163, 0.2056, 0.5377]}, {"w": "discussed", "b": [0.2112, 0.5163, 0.2904, 0.5377]}, {"w": "the", "b": [0.296, 0.5163, 0.3223, 0.5377]}, {"w": "choice", "b": [0.3279, 0.5163, 0.3817, 0.5377]}, {"w": "of", "b": [0.3873, 0.5163, 0.4041, 0.5377]}, {"w": "the", "b": [0.4096, 0.5163, 0.436, 0.5377]}, {"w": "activation", "b": [0.4415, 0.5163, 0.5238, 0.5377]}, {"w": "function", "b": [0.5293, 0.5163, 0.6007, 0.5377]}, {"w": "earlier", "b": [0.6063, 0.5163, 0.6595, 0.5377]}, {"w": "in", "b": [0.665, 0.5163, 0.682, 0.5377]}, {"w": "this", "b": [0.6876, 0.5163, 0.7183, 0.5377]}, {"w": "chapter:", "b": [0.7238, 0.5163, 0.7916, 0.5377]}, {"w": "in", "b": [0.7972, 0.5163, 0.8142, 0.5377]}, {"w": "gen‐", "b": [0.8197, 0.5163, 0.8571, 0.5377]}, {"w": "eral,", "b": [0.1786, 0.5353, 0.2143, 0.5567]}, {"w": "the", "b": [0.2195, 0.5353, 0.2458, 0.5567]}, {"w": "ReLU", "b": [0.251, 0.5353, 0.2985, 0.5567]}, {"w": "activation", "b": [0.3036, 0.5353, 0.3859, 0.5567]}, {"w": "function", "b": [0.391, 0.5353, 0.4624, 0.5567]}, {"w": "will", "b": [0.4676, 0.5353, 0.498, 0.5567]}, {"w": "be", "b": [0.5031, 0.5353, 0.5226, 0.5567]}, {"w": "a", "b": [0.5277, 0.5353, 0.5369, 0.5567]}, {"w": "good", "b": [0.542, 0.5353, 0.584, 0.5567]}, {"w": "default", "b": [0.5892, 0.5353, 0.6466, 0.5567]}, {"w": "for", "b": [0.6518, 0.5353, 0.6763, 0.5567]}, {"w": "all", "b": [0.6815, 0.5353, 0.7012, 0.5567]}, {"w": "hidden", "b": [0.7063, 0.5353, 0.7653, 0.5567]}, {"w": "layers.", "b": [0.7704, 0.5353, 0.823, 0.5567]}, {"w": "For", "b": [0.8282, 0.5353, 0.8571, 0.5567]}, {"w": "the", "b": [0.1786, 0.5543, 0.2049, 0.5758]}, {"w": "output", "b": [0.2096, 0.5543, 0.266, 0.5758]}, {"w": "layer,", "b": [0.2707, 0.5543, 0.3144, 0.5758]}, {"w": "it", "b": [0.3191, 0.5543, 0.331, 0.5758]}, {"w": "really", "b": [0.3358, 0.5543, 0.3816, 0.5758]}, {"w": "depends", "b": [0.3863, 0.5543, 0.456, 0.5758]}, {"w": "on", "b": [0.4607, 0.5543, 0.4827, 0.5758]}, {"w": "your", "b": [0.4875, 0.5543, 0.5264, 0.5758]}, {"w": "task.", "b": [0.5312, 0.5543, 0.5694, 0.5758]}]}, {"id": "b_5", "type": "paragraph", "text": "• In most cases, the number of training iterations does not actually need to be tweaked: just use early stopping instead.", "words": [{"w": "•", "b": [0.16, 0.5794, 0.1682, 0.6009]}, {"w": "In", "b": [0.1786, 0.5794, 0.1971, 0.6009]}, {"w": "most", "b": [0.2054, 0.5794, 0.2471, 0.6009]}, {"w": "cases,", "b": [0.2555, 0.5794, 0.3023, 0.6009]}, {"w": "the", "b": [0.3107, 0.5794, 0.337, 0.6009]}, {"w": "number", "b": [0.3454, 0.5794, 0.4117, 0.6009]}, {"w": "of", "b": [0.42, 0.5794, 0.4368, 0.6009]}, {"w": "training", "b": [0.4452, 0.5794, 0.5121, 0.6009]}, {"w": "iterations", "b": [0.5205, 0.5794, 0.5993, 0.6009]}, {"w": "does", "b": [0.6077, 0.5794, 0.6458, 0.6009]}, {"w": "not", "b": [0.6542, 0.5794, 0.6826, 0.6009]}, {"w": "actually", "b": [0.6909, 0.5794, 0.7555, 0.6009]}, {"w": "need", "b": [0.7639, 0.5794, 0.804, 0.6009]}, {"w": "to", "b": [0.8124, 0.5794, 0.8293, 0.6009]}, {"w": "be", "b": [0.8377, 0.5794, 0.8571, 0.6009]}, {"w": "tweaked:", "b": [0.1786, 0.5985, 0.2521, 0.6199]}, {"w": "just", "b": [0.2569, 0.5985, 0.2873, 0.6199]}, {"w": "use", "b": [0.292, 0.5985, 0.3196, 0.6199]}, {"w": "early", "b": [0.3243, 0.5985, 0.3648, 0.6199]}, {"w": "stopping", "b": [0.3696, 0.5985, 0.4428, 0.6199]}, {"w": "instead.", "b": [0.4475, 0.5985, 0.5122, 0.6199]}]}, {"id": "b_6", "type": "paragraph", "text": "For more best practices, make sure to read Yoshua Bengio’s great 2012 paper18, which presents many practical recommendations for deep networks.", "words": [{"w": "For", "b": [0.1429, 0.6327, 0.1718, 0.6541]}, {"w": "more", "b": [0.1773, 0.6327, 0.2216, 0.6541]}, {"w": "best", "b": [0.2271, 0.6327, 0.2605, 0.6541]}, {"w": "practices,", "b": [0.266, 0.6327, 0.3446, 0.6541]}, {"w": "make", "b": [0.3501, 0.6327, 0.3955, 0.6541]}, {"w": "sure", "b": [0.401, 0.6327, 0.4363, 0.6541]}, {"w": "to", "b": [0.4418, 0.6327, 0.4588, 0.6541]}, {"w": "read", "b": [0.4642, 0.6327, 0.501, 0.6541]}, {"w": "Yoshua", "b": [0.5065, 0.6327, 0.5663, 0.6541]}, {"w": "Bengio’s", "b": [0.5718, 0.6327, 0.6395, 0.6541]}, {"w": "great", "b": [0.645, 0.6327, 0.6864, 0.6541]}, {"w": "2012", "b": [0.6919, 0.6327, 0.7319, 0.6541]}, {"w": "paper18,", "b": [0.7374, 0.6327, 0.8007, 0.6541]}, {"w": "which", "b": [0.8062, 0.6327, 0.8571, 0.6541]}, {"w": "presents", "b": [0.1428, 0.6517, 0.2118, 0.6731]}, {"w": "many", "b": [0.2166, 0.6517, 0.2633, 0.6731]}, {"w": "practical", "b": [0.268, 0.6517, 0.3398, 0.6731]}, {"w": "recommendations", "b": [0.3445, 0.6517, 0.4962, 0.6731]}, {"w": "for", "b": [0.501, 0.6517, 0.5255, 0.6731]}, {"w": "deep", "b": [0.5302, 0.6517, 0.5698, 0.6731]}, {"w": "networks.", "b": [0.5746, 0.6517, 0.6565, 0.6731]}]}, {"id": "b_7", "type": "paragraph", "text": "This concludes this introduction to artificial neural networks and their implementa‐ tion with Keras. In the next few chapters, we will discuss techniques to train very deep nets, we will see how to customize your models using TensorFlow’s lower-level API and how to load and preprocess data efficiently using the Data API, and we will dive into other popular neural network architectures: convolutional neural networks for image processing, recurrent neural networks for sequential data, autoencoders for", "words": [{"w": "This", "b": [0.1428, 0.6798, 0.1801, 0.7012]}, {"w": "concludes", "b": [0.1862, 0.6798, 0.2697, 0.7012]}, {"w": "this", "b": [0.2758, 0.6798, 0.3065, 0.7012]}, {"w": "introduction", "b": [0.3127, 0.6798, 0.4188, 0.7012]}, {"w": "to", "b": [0.4249, 0.6798, 0.4419, 0.7012]}, {"w": "artificial", "b": [0.4481, 0.6798, 0.5174, 0.7012]}, {"w": "neural", "b": [0.5236, 0.6798, 0.577, 0.7012]}, {"w": "networks", "b": [0.5832, 0.6798, 0.6604, 0.7012]}, {"w": "and", "b": [0.6665, 0.6798, 0.6981, 0.7012]}, {"w": "their", "b": [0.7042, 0.6798, 0.7439, 0.7012]}, {"w": "implementa‐", "b": [0.75, 0.6798, 0.8571, 0.7012]}, {"w": "tion", "b": [0.1429, 0.6989, 0.1768, 0.7203]}, {"w": "with", "b": [0.1846, 0.6989, 0.2219, 0.7203]}, {"w": "Keras.", "b": [0.2297, 0.6989, 0.2814, 0.7203]}, {"w": "In", "b": [0.2892, 0.6989, 0.3077, 0.7203]}, {"w": "the", "b": [0.3154, 0.6989, 0.3418, 0.7203]}, {"w": "next", "b": [0.3496, 0.6989, 0.386, 0.7203]}, {"w": "few", "b": [0.3938, 0.6989, 0.4231, 0.7203]}, {"w": "chapters,", "b": [0.4309, 0.6989, 0.5058, 0.7203]}, {"w": "we", "b": [0.5136, 0.6989, 0.5367, 0.7203]}, {"w": "will", "b": [0.5445, 0.6989, 0.5749, 0.7203]}, {"w": "discuss", "b": [0.5827, 0.6989, 0.6421, 0.7203]}, {"w": "techniques", "b": [0.6499, 0.6989, 0.7402, 0.7203]}, {"w": "to", "b": [0.748, 0.6989, 0.765, 0.7203]}, {"w": "train", "b": [0.7728, 0.6989, 0.813, 0.7203]}, {"w": "very", "b": [0.8208, 0.6989, 0.8571, 0.7203]}, {"w": "deep", "b": [0.1429, 0.7179, 0.1825, 0.7393]}, {"w": "nets,", "b": [0.1887, 0.7179, 0.2277, 0.7393]}, {"w": "we", "b": [0.2338, 0.7179, 0.2569, 0.7393]}, {"w": "will", "b": [0.2631, 0.7179, 0.2935, 0.7393]}, {"w": "see", "b": [0.2997, 0.7179, 0.325, 0.7393]}, {"w": "how", "b": [0.3312, 0.7179, 0.3672, 0.7393]}, {"w": "to", "b": [0.3734, 0.7179, 0.3904, 0.7393]}, {"w": "customize", "b": [0.3965, 0.7179, 0.4813, 0.7393]}, {"w": "your", "b": [0.4875, 0.7179, 0.5264, 0.7393]}, {"w": "models", "b": [0.5326, 0.7179, 0.5931, 0.7393]}, {"w": "using", "b": [0.5992, 0.7179, 0.6447, 0.7393]}, {"w": "TensorFlow’s", "b": [0.6508, 0.7179, 0.7594, 0.7393]}, {"w": "lower-level", "b": [0.7656, 0.7179, 0.8571, 0.7393]}, {"w": "API", "b": [0.1429, 0.737, 0.1761, 0.7584]}, {"w": "and", "b": [0.1819, 0.737, 0.2134, 0.7584]}, {"w": "how", "b": [0.2193, 0.737, 0.2553, 0.7584]}, {"w": "to", "b": [0.2611, 0.737, 0.2781, 0.7584]}, {"w": "load", "b": [0.2839, 0.737, 0.32, 0.7584]}, {"w": "and", "b": [0.3258, 0.737, 0.3573, 0.7584]}, {"w": "preprocess", "b": [0.3632, 0.737, 0.4529, 0.7584]}, {"w": "data", "b": [0.4587, 0.737, 0.494, 0.7584]}, {"w": "efficiently", "b": [0.4998, 0.737, 0.582, 0.7584]}, {"w": "using", "b": [0.5878, 0.737, 0.6333, 0.7584]}, {"w": "the", "b": [0.6391, 0.737, 0.6654, 0.7584]}, {"w": "Data", "b": [0.6712, 0.737, 0.7108, 0.7584]}, {"w": "API,", "b": [0.7166, 0.737, 0.7546, 0.7584]}, {"w": "and", "b": [0.7604, 0.737, 0.792, 0.7584]}, {"w": "we", "b": [0.7978, 0.737, 0.8209, 0.7584]}, {"w": "will", "b": [0.8267, 0.737, 0.8571, 0.7584]}, {"w": "dive", "b": [0.1429, 0.756, 0.1779, 0.7774]}, {"w": "into", "b": [0.1839, 0.756, 0.2175, 0.7774]}, {"w": "other", "b": [0.2234, 0.756, 0.2681, 0.7774]}, {"w": "popular", "b": [0.274, 0.756, 0.3397, 0.7774]}, {"w": "neural", "b": [0.3456, 0.756, 0.3991, 0.7774]}, {"w": "network", "b": [0.405, 0.756, 0.4746, 0.7774]}, {"w": "architectures:", "b": [0.4805, 0.756, 0.5933, 0.7774]}, {"w": "convolutional", "b": [0.5993, 0.756, 0.7146, 0.7774]}, {"w": "neural", "b": [0.7205, 0.756, 0.774, 0.7774]}, {"w": "networks", "b": [0.7799, 0.756, 0.8572, 0.7774]}, {"w": "for", "b": [0.1429, 0.7751, 0.1674, 0.7965]}, {"w": "image", "b": [0.1726, 0.7751, 0.2229, 0.7965]}, {"w": "processing,", "b": [0.2281, 0.7751, 0.3218, 0.7965]}, {"w": "recurrent", "b": [0.327, 0.7751, 0.4051, 0.7965]}, {"w": "neural", "b": [0.4103, 0.7751, 0.4637, 0.7965]}, {"w": "networks", "b": [0.4689, 0.7751, 0.5461, 0.7965]}, {"w": "for", "b": [0.5513, 0.7751, 0.5758, 0.7965]}, {"w": "sequential", "b": [0.581, 0.7751, 0.6654, 0.7965]}, {"w": "data,", "b": [0.6706, 0.7751, 0.7106, 0.7965]}, {"w": "autoencoders", "b": [0.7157, 0.7751, 0.8275, 0.7965]}, {"w": "for", "b": [0.8322, 0.7751, 0.8567, 0.7965]}]}, {"id": "b_8", "type": "equation", "text": "Fine-Tuning Neural Network Hyperparameters | 321", "words": [{"w": "Fine-Tuning", "b": [0.5239, 0.9225, 0.5948, 0.9388]}, {"w": "Neural", "b": [0.5977, 0.9225, 0.6368, 0.9388]}, {"w": "Network", "b": [0.6397, 0.9225, 0.6903, 0.9388]}, {"w": "Hyperparameters", "b": [0.6931, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "321", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 348, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "19 A few extra ANN architectures are presented in ???.", "words": [{"w": "19", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "A", "b": [0.1587, 0.8749, 0.1697, 0.8912]}, {"w": "few", "b": [0.1733, 0.8749, 0.1956, 0.8912]}, {"w": "extra", "b": [0.1992, 0.8749, 0.2312, 0.8912]}, {"w": "ANN", "b": [0.2348, 0.8749, 0.2693, 0.8912]}, {"w": "architectures", "b": [0.2729, 0.8749, 0.3553, 0.8912]}, {"w": "are", "b": [0.3589, 0.8749, 0.3785, 0.8912]}, {"w": "presented", "b": [0.3821, 0.8749, 0.4439, 0.8912]}, {"w": "in", "b": [0.4475, 0.8749, 0.4605, 0.8912]}, {"w": "???.", "b": [0.4641, 0.8749, 0.4857, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "representation learning, and generative adversarial networks to model and generate data.19", "words": [{"w": "representation", "b": [0.1429, 0.0791, 0.2635, 0.1005]}, {"w": "learning,", "b": [0.2704, 0.0791, 0.3443, 0.1005]}, {"w": "and", "b": [0.3513, 0.0791, 0.3828, 0.1005]}, {"w": "generative", "b": [0.3897, 0.0791, 0.4755, 0.1005]}, {"w": "adversarial", "b": [0.4824, 0.0791, 0.5733, 0.1005]}, {"w": "networks", "b": [0.5803, 0.0791, 0.6575, 0.1005]}, {"w": "to", "b": [0.6644, 0.0791, 0.6814, 0.1005]}, {"w": "model", "b": [0.6884, 0.0791, 0.7412, 0.1005]}, {"w": "and", "b": [0.7481, 0.0791, 0.7797, 0.1005]}, {"w": "generate", "b": [0.7866, 0.0791, 0.8571, 0.1005]}, {"w": "data.19", "b": [0.1429, 0.0981, 0.1943, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "Exercises", "words": [{"w": "Exercises", "b": [0.1429, 0.1325, 0.2533, 0.1668]}]}, {"id": "b_3", "type": "equation", "text": "1. Visit the TensorFlow Playground at https://playground.tensorflow.org/", "words": [{"w": "1.", "b": [0.1534, 0.1797, 0.1682, 0.2012]}, {"w": "Visit", "b": [0.1786, 0.1797, 0.2175, 0.2012]}, {"w": "the", "b": [0.2223, 0.1797, 0.2486, 0.2012]}, {"w": "TensorFlow", "b": [0.2533, 0.1797, 0.3516, 0.2012]}, {"w": "Playground", "b": [0.3563, 0.1797, 0.4532, 0.2012]}, {"w": "at", "b": [0.4579, 0.1797, 0.473, 0.2012]}, {"w": "https://playground.tensorflow.org/", "b": [0.4778, 0.1795, 0.7579, 0.2012]}]}, {"id": "b_4", "type": "paragraph", "text": "• Layers and patterns: try training the default neural network by clicking the run button (top left). Notice how it quickly finds a good solution for the classifica‐ tion task. Notice that the neurons in the first hidden layer have learned simple patterns, while the neurons in the second hidden layer have learned to com‐ bine the simple patterns of the first hidden layer into more complex patterns. In general, the more layers, the more complex the patterns can be.", "words": [{"w": "•", "b": [0.1799, 0.2109, 0.188, 0.2323]}, {"w": "Layers", "b": [0.1984, 0.2109, 0.2522, 0.2323]}, {"w": "and", "b": [0.2572, 0.2109, 0.2888, 0.2323]}, {"w": "patterns:", "b": [0.2938, 0.2109, 0.3666, 0.2323]}, {"w": "try", "b": [0.3716, 0.2109, 0.3958, 0.2323]}, {"w": "training", "b": [0.4009, 0.2109, 0.4678, 0.2323]}, {"w": "the", "b": [0.4729, 0.2109, 0.4992, 0.2323]}, {"w": "default", "b": [0.5042, 0.2109, 0.5617, 0.2323]}, {"w": "neural", "b": [0.5667, 0.2109, 0.6202, 0.2323]}, {"w": "network", "b": [0.6252, 0.2109, 0.6948, 0.2323]}, {"w": "by", "b": [0.6998, 0.2109, 0.72, 0.2323]}, {"w": "clicking", "b": [0.725, 0.2109, 0.7906, 0.2323]}, {"w": "the", "b": [0.7956, 0.2109, 0.8219, 0.2323]}, {"w": "run", "b": [0.827, 0.2109, 0.8571, 0.2323]}, {"w": "button", "b": [0.1984, 0.2299, 0.2548, 0.2513]}, {"w": "(top", "b": [0.2602, 0.2299, 0.2953, 0.2513]}, {"w": "left).", "b": [0.3008, 0.2299, 0.3394, 0.2513]}, {"w": "Notice", "b": [0.3448, 0.2299, 0.4, 0.2513]}, {"w": "how", "b": [0.4054, 0.2299, 0.4414, 0.2513]}, {"w": "it", "b": [0.4469, 0.2299, 0.4588, 0.2513]}, {"w": "quickly", "b": [0.4643, 0.2299, 0.5255, 0.2513]}, {"w": "finds", "b": [0.531, 0.2299, 0.5728, 0.2513]}, {"w": "a", "b": [0.5782, 0.2299, 0.5873, 0.2513]}, {"w": "good", "b": [0.5928, 0.2299, 0.6348, 0.2513]}, {"w": "solution", "b": [0.6402, 0.2299, 0.7088, 0.2513]}, {"w": "for", "b": [0.7142, 0.2299, 0.7387, 0.2513]}, {"w": "the", "b": [0.7442, 0.2299, 0.7705, 0.2513]}, {"w": "classifica‐", "b": [0.7759, 0.2299, 0.8572, 0.2513]}, {"w": "tion", "b": [0.1984, 0.249, 0.2324, 0.2704]}, {"w": "task.", "b": [0.2379, 0.249, 0.2762, 0.2704]}, {"w": "Notice", "b": [0.2817, 0.249, 0.3369, 0.2704]}, {"w": "that", "b": [0.3425, 0.249, 0.375, 0.2704]}, {"w": "the", "b": [0.3806, 0.249, 0.4069, 0.2704]}, {"w": "neurons", "b": [0.4125, 0.249, 0.4812, 0.2704]}, {"w": "in", "b": [0.4867, 0.249, 0.5037, 0.2704]}, {"w": "the", "b": [0.5093, 0.249, 0.5356, 0.2704]}, {"w": "first", "b": [0.5412, 0.249, 0.5746, 0.2704]}, {"w": "hidden", "b": [0.5802, 0.249, 0.6392, 0.2704]}, {"w": "layer", "b": [0.6447, 0.249, 0.6849, 0.2704]}, {"w": "have", "b": [0.6905, 0.249, 0.7289, 0.2704]}, {"w": "learned", "b": [0.7344, 0.249, 0.7967, 0.2704]}, {"w": "simple", "b": [0.8022, 0.249, 0.8572, 0.2704]}, {"w": "patterns,", "b": [0.1984, 0.268, 0.2712, 0.2894]}, {"w": "while", "b": [0.2781, 0.268, 0.3232, 0.2894]}, {"w": "the", "b": [0.3302, 0.268, 0.3565, 0.2894]}, {"w": "neurons", "b": [0.3635, 0.268, 0.4322, 0.2894]}, {"w": "in", "b": [0.4392, 0.268, 0.4561, 0.2894]}, {"w": "the", "b": [0.4631, 0.268, 0.4894, 0.2894]}, {"w": "second", "b": [0.4964, 0.268, 0.5547, 0.2894]}, {"w": "hidden", "b": [0.5617, 0.268, 0.6206, 0.2894]}, {"w": "layer", "b": [0.6276, 0.268, 0.6678, 0.2894]}, {"w": "have", "b": [0.6747, 0.268, 0.7131, 0.2894]}, {"w": "learned", "b": [0.7201, 0.268, 0.7823, 0.2894]}, {"w": "to", "b": [0.7893, 0.268, 0.8063, 0.2894]}, {"w": "com‐", "b": [0.8132, 0.268, 0.8572, 0.2894]}, {"w": "bine", "b": [0.1984, 0.2871, 0.2348, 0.3085]}, {"w": "the", "b": [0.2411, 0.2871, 0.2675, 0.3085]}, {"w": "simple", "b": [0.2738, 0.2871, 0.3287, 0.3085]}, {"w": "patterns", "b": [0.335, 0.2871, 0.403, 0.3085]}, {"w": "of", "b": [0.4093, 0.2871, 0.4261, 0.3085]}, {"w": "the", "b": [0.4324, 0.2871, 0.4588, 0.3085]}, {"w": "first", "b": [0.4651, 0.2871, 0.4986, 0.3085]}, {"w": "hidden", "b": [0.5049, 0.2871, 0.5638, 0.3085]}, {"w": "layer", "b": [0.5701, 0.2871, 0.6103, 0.3085]}, {"w": "into", "b": [0.6166, 0.2871, 0.6502, 0.3085]}, {"w": "more", "b": [0.6565, 0.2871, 0.7008, 0.3085]}, {"w": "complex", "b": [0.7071, 0.2871, 0.7781, 0.3085]}, {"w": "patterns.", "b": [0.7844, 0.2871, 0.8571, 0.3085]}, {"w": "In", "b": [0.1984, 0.3061, 0.2169, 0.3275]}, {"w": "general,", "b": [0.2216, 0.3061, 0.2874, 0.3275]}, {"w": "the", "b": [0.2921, 0.3061, 0.3184, 0.3275]}, {"w": "more", "b": [0.3232, 0.3061, 0.3674, 0.3275]}, {"w": "layers,", "b": [0.3722, 0.3061, 0.4248, 0.3275]}, {"w": "the", "b": [0.4295, 0.3061, 0.4558, 0.3275]}, {"w": "more", "b": [0.4605, 0.3061, 0.5048, 0.3275]}, {"w": "complex", "b": [0.5095, 0.3061, 0.5805, 0.3275]}, {"w": "the", "b": [0.5853, 0.3061, 0.6116, 0.3275]}, {"w": "patterns", "b": [0.6163, 0.3061, 0.6843, 0.3275]}, {"w": "can", "b": [0.689, 0.3061, 0.7184, 0.3275]}, {"w": "be.", "b": [0.7231, 0.3061, 0.7473, 0.3275]}]}, {"id": "b_5", "type": "paragraph", "text": "• Activation function: try replacing the Tanh activation function with the ReLU activation function, and train the network again. Notice that it finds a solution even faster, but this time the boundaries are linear. This is due to the shape of the ReLU function.", "words": [{"w": "•", "b": [0.1799, 0.3312, 0.188, 0.3526]}, {"w": "Activation", "b": [0.1984, 0.3312, 0.2854, 0.3526]}, {"w": "function:", "b": [0.2914, 0.3312, 0.3675, 0.3526]}, {"w": "try", "b": [0.3736, 0.3312, 0.3978, 0.3526]}, {"w": "replacing", "b": [0.4038, 0.3312, 0.4813, 0.3526]}, {"w": "the", "b": [0.4873, 0.3312, 0.5136, 0.3526]}, {"w": "Tanh", "b": [0.5196, 0.3312, 0.5623, 0.3526]}, {"w": "activation", "b": [0.5683, 0.3312, 0.6505, 0.3526]}, {"w": "function", "b": [0.6565, 0.3312, 0.7279, 0.3526]}, {"w": "with", "b": [0.7339, 0.3312, 0.7713, 0.3526]}, {"w": "the", "b": [0.7773, 0.3312, 0.8036, 0.3526]}, {"w": "ReLU", "b": [0.8096, 0.3312, 0.8571, 0.3526]}, {"w": "activation", "b": [0.1984, 0.3503, 0.2807, 0.3717]}, {"w": "function,", "b": [0.286, 0.3503, 0.3621, 0.3717]}, {"w": "and", "b": [0.3674, 0.3503, 0.399, 0.3717]}, {"w": "train", "b": [0.4043, 0.3503, 0.4445, 0.3717]}, {"w": "the", "b": [0.4498, 0.3503, 0.4761, 0.3717]}, {"w": "network", "b": [0.4814, 0.3503, 0.551, 0.3717]}, {"w": "again.", "b": [0.5563, 0.3503, 0.6061, 0.3717]}, {"w": "Notice", "b": [0.6114, 0.3503, 0.6666, 0.3717]}, {"w": "that", "b": [0.6719, 0.3503, 0.7045, 0.3717]}, {"w": "it", "b": [0.7098, 0.3503, 0.7217, 0.3717]}, {"w": "finds", "b": [0.727, 0.3503, 0.7688, 0.3717]}, {"w": "a", "b": [0.7741, 0.3503, 0.7833, 0.3717]}, {"w": "solution", "b": [0.7886, 0.3503, 0.8572, 0.3717]}, {"w": "even", "b": [0.1984, 0.3693, 0.2372, 0.3907]}, {"w": "faster,", "b": [0.2431, 0.3693, 0.2924, 0.3907]}, {"w": "but", "b": [0.2983, 0.3693, 0.3263, 0.3907]}, {"w": "this", "b": [0.3322, 0.3693, 0.3629, 0.3907]}, {"w": "time", "b": [0.3687, 0.3693, 0.4066, 0.3907]}, {"w": "the", "b": [0.4125, 0.3693, 0.4388, 0.3907]}, {"w": "boundaries", "b": [0.4447, 0.3693, 0.5383, 0.3907]}, {"w": "are", "b": [0.5442, 0.3693, 0.5699, 0.3907]}, {"w": "linear.", "b": [0.5758, 0.3693, 0.6272, 0.3907]}, {"w": "This", "b": [0.6331, 0.3693, 0.6703, 0.3907]}, {"w": "is", "b": [0.6762, 0.3693, 0.6894, 0.3907]}, {"w": "due", "b": [0.6953, 0.3693, 0.7262, 0.3907]}, {"w": "to", "b": [0.7321, 0.3693, 0.7491, 0.3907]}, {"w": "the", "b": [0.755, 0.3693, 0.7813, 0.3907]}, {"w": "shape", "b": [0.7872, 0.3693, 0.8345, 0.3907]}, {"w": "of", "b": [0.8404, 0.3693, 0.8572, 0.3907]}, {"w": "the", "b": [0.1984, 0.3884, 0.2248, 0.4098]}, {"w": "ReLU", "b": [0.2295, 0.3884, 0.277, 0.4098]}, {"w": "function.", "b": [0.2817, 0.3884, 0.3579, 0.4098]}]}, {"id": "b_6", "type": "paragraph", "text": "• Local minima: modify the network architecture to have just one hidden layer with three neurons. Train it multiple times (to reset the network weights, click the reset button next to the play button). Notice that the training time varies a lot, and sometimes it even gets stuck in a local minimum.", "words": [{"w": "•", "b": [0.1799, 0.4135, 0.188, 0.4349]}, {"w": "Local", "b": [0.1984, 0.4135, 0.2435, 0.4349]}, {"w": "minima:", "b": [0.2499, 0.4135, 0.3205, 0.4349]}, {"w": "modify", "b": [0.3269, 0.4135, 0.3873, 0.4349]}, {"w": "the", "b": [0.3937, 0.4135, 0.42, 0.4349]}, {"w": "network", "b": [0.4264, 0.4135, 0.496, 0.4349]}, {"w": "architecture", "b": [0.5024, 0.4135, 0.6028, 0.4349]}, {"w": "to", "b": [0.6093, 0.4135, 0.6262, 0.4349]}, {"w": "have", "b": [0.6327, 0.4135, 0.6711, 0.4349]}, {"w": "just", "b": [0.6775, 0.4135, 0.7079, 0.4349]}, {"w": "one", "b": [0.7143, 0.4135, 0.7452, 0.4349]}, {"w": "hidden", "b": [0.7516, 0.4135, 0.8105, 0.4349]}, {"w": "layer", "b": [0.817, 0.4135, 0.8571, 0.4349]}, {"w": "with", "b": [0.1984, 0.4325, 0.2358, 0.4539]}, {"w": "three", "b": [0.2413, 0.4325, 0.2842, 0.4539]}, {"w": "neurons.", "b": [0.2897, 0.4325, 0.3632, 0.4539]}, {"w": "Train", "b": [0.3687, 0.4325, 0.4137, 0.4539]}, {"w": "it", "b": [0.4192, 0.4325, 0.4312, 0.4539]}, {"w": "multiple", "b": [0.4367, 0.4325, 0.5067, 0.4539]}, {"w": "times", "b": [0.5122, 0.4325, 0.5577, 0.4539]}, {"w": "(to", "b": [0.5632, 0.4325, 0.5874, 0.4539]}, {"w": "reset", "b": [0.5929, 0.4325, 0.6324, 0.4539]}, {"w": "the", "b": [0.6379, 0.4325, 0.6642, 0.4539]}, {"w": "network", "b": [0.6698, 0.4325, 0.7393, 0.4539]}, {"w": "weights,", "b": [0.7449, 0.4325, 0.8128, 0.4539]}, {"w": "click", "b": [0.8183, 0.4325, 0.8572, 0.4539]}, {"w": "the", "b": [0.1984, 0.4515, 0.2248, 0.473]}, {"w": "reset", "b": [0.2303, 0.4515, 0.2697, 0.473]}, {"w": "button", "b": [0.2752, 0.4515, 0.3316, 0.473]}, {"w": "next", "b": [0.3371, 0.4515, 0.3736, 0.473]}, {"w": "to", "b": [0.3791, 0.4515, 0.3961, 0.473]}, {"w": "the", "b": [0.4016, 0.4515, 0.4279, 0.473]}, {"w": "play", "b": [0.4335, 0.4515, 0.468, 0.473]}, {"w": "button).", "b": [0.4735, 0.4515, 0.5418, 0.473]}, {"w": "Notice", "b": [0.5474, 0.4515, 0.6026, 0.473]}, {"w": "that", "b": [0.6081, 0.4515, 0.6407, 0.473]}, {"w": "the", "b": [0.6462, 0.4515, 0.6725, 0.473]}, {"w": "training", "b": [0.678, 0.4515, 0.745, 0.473]}, {"w": "time", "b": [0.7505, 0.4515, 0.7884, 0.473]}, {"w": "varies", "b": [0.7939, 0.4515, 0.8425, 0.473]}, {"w": "a", "b": [0.848, 0.4515, 0.8572, 0.473]}, {"w": "lot,", "b": [0.1984, 0.4706, 0.2254, 0.492]}, {"w": "and", "b": [0.2302, 0.4706, 0.2617, 0.492]}, {"w": "sometimes", "b": [0.2664, 0.4706, 0.3561, 0.492]}, {"w": "it", "b": [0.3608, 0.4706, 0.3728, 0.492]}, {"w": "even", "b": [0.3775, 0.4706, 0.4163, 0.492]}, {"w": "gets", "b": [0.421, 0.4706, 0.4536, 0.492]}, {"w": "stuck", "b": [0.4583, 0.4706, 0.5025, 0.492]}, {"w": "in", "b": [0.5073, 0.4706, 0.5242, 0.492]}, {"w": "a", "b": [0.529, 0.4706, 0.5381, 0.492]}, {"w": "local", "b": [0.5428, 0.4706, 0.582, 0.492]}, {"w": "minimum.", "b": [0.5867, 0.4706, 0.6759, 0.492]}]}, {"id": "b_7", "type": "paragraph", "text": "• Too small: now remove one neuron to keep just 2. Notice that the neural net‐ work is now incapable of finding a good solution, even if you try multiple times. The model has too few parameters and it systematically underfits the training set.", "words": [{"w": "•", "b": [0.1799, 0.4957, 0.188, 0.5171]}, {"w": "Too", "b": [0.1984, 0.4957, 0.2305, 0.5171]}, {"w": "small:", "b": [0.2365, 0.4957, 0.2856, 0.5171]}, {"w": "now", "b": [0.2916, 0.4957, 0.3279, 0.5171]}, {"w": "remove", "b": [0.3339, 0.4957, 0.3967, 0.5171]}, {"w": "one", "b": [0.4026, 0.4957, 0.4335, 0.5171]}, {"w": "neuron", "b": [0.4395, 0.4957, 0.5006, 0.5171]}, {"w": "to", "b": [0.5066, 0.4957, 0.5235, 0.5171]}, {"w": "keep", "b": [0.5295, 0.4957, 0.5685, 0.5171]}, {"w": "just", "b": [0.5745, 0.4957, 0.6049, 0.5171]}, {"w": "2.", "b": [0.6109, 0.4957, 0.6256, 0.5171]}, {"w": "Notice", "b": [0.6316, 0.4957, 0.6868, 0.5171]}, {"w": "that", "b": [0.6928, 0.4957, 0.7254, 0.5171]}, {"w": "the", "b": [0.7314, 0.4957, 0.7577, 0.5171]}, {"w": "neural", "b": [0.7637, 0.4957, 0.8171, 0.5171]}, {"w": "net‐", "b": [0.8231, 0.4957, 0.8571, 0.5171]}, {"w": "work", "b": [0.1984, 0.5147, 0.2414, 0.5362]}, {"w": "is", "b": [0.2498, 0.5147, 0.263, 0.5362]}, {"w": "now", "b": [0.2714, 0.5147, 0.3076, 0.5362]}, {"w": "incapable", "b": [0.316, 0.5147, 0.3953, 0.5362]}, {"w": "of", "b": [0.4037, 0.5147, 0.4205, 0.5362]}, {"w": "finding", "b": [0.4289, 0.5147, 0.4897, 0.5362]}, {"w": "a", "b": [0.4981, 0.5147, 0.5073, 0.5362]}, {"w": "good", "b": [0.5156, 0.5147, 0.5576, 0.5362]}, {"w": "solution,", "b": [0.566, 0.5147, 0.6393, 0.5362]}, {"w": "even", "b": [0.6477, 0.5147, 0.6864, 0.5362]}, {"w": "if", "b": [0.6948, 0.5147, 0.7066, 0.5362]}, {"w": "you", "b": [0.7149, 0.5147, 0.7462, 0.5362]}, {"w": "try", "b": [0.7545, 0.5147, 0.7788, 0.5362]}, {"w": "multiple", "b": [0.7872, 0.5147, 0.8572, 0.5362]}, {"w": "times.", "b": [0.1984, 0.5338, 0.2487, 0.5552]}, {"w": "The", "b": [0.2562, 0.5338, 0.2891, 0.5552]}, {"w": "model", "b": [0.2966, 0.5338, 0.3494, 0.5552]}, {"w": "has", "b": [0.357, 0.5338, 0.3849, 0.5552]}, {"w": "too", "b": [0.3925, 0.5338, 0.4201, 0.5552]}, {"w": "few", "b": [0.4276, 0.5338, 0.4569, 0.5552]}, {"w": "parameters", "b": [0.4645, 0.5338, 0.5579, 0.5552]}, {"w": "and", "b": [0.5655, 0.5338, 0.597, 0.5552]}, {"w": "it", "b": [0.6045, 0.5338, 0.6165, 0.5552]}, {"w": "systematically", "b": [0.624, 0.5338, 0.7399, 0.5552]}, {"w": "underfits", "b": [0.7475, 0.5338, 0.8233, 0.5552]}, {"w": "the", "b": [0.8308, 0.5338, 0.8572, 0.5552]}, {"w": "training", "b": [0.1984, 0.5528, 0.2654, 0.5742]}, {"w": "set.", "b": [0.2701, 0.5528, 0.2977, 0.5742]}]}, {"id": "b_8", "type": "paragraph", "text": "• Large enough: next, set the number of neurons to 8 and train the network sev‐ eral times. Notice that it is now consistently fast and never gets stuck. This highlights an important finding in neural network theory: large neural net‐ works almost never get stuck in local minima, and even when they do these local optima are almost as good as the global optimum. However, they can still get stuck on long plateaus for a long time.", "words": [{"w": "•", "b": [0.1799, 0.5779, 0.188, 0.5993]}, {"w": "Large", "b": [0.1984, 0.5779, 0.2451, 0.5993]}, {"w": "enough:", "b": [0.2504, 0.5779, 0.318, 0.5993]}, {"w": "next,", "b": [0.3233, 0.5779, 0.3644, 0.5993]}, {"w": "set", "b": [0.3697, 0.5779, 0.3926, 0.5993]}, {"w": "the", "b": [0.3979, 0.5779, 0.4242, 0.5993]}, {"w": "number", "b": [0.4295, 0.5779, 0.4958, 0.5993]}, {"w": "of", "b": [0.5011, 0.5779, 0.5179, 0.5993]}, {"w": "neurons", "b": [0.5232, 0.5779, 0.5919, 0.5993]}, {"w": "to", "b": [0.5972, 0.5779, 0.6142, 0.5993]}, {"w": "8", "b": [0.6195, 0.5779, 0.6295, 0.5993]}, {"w": "and", "b": [0.6348, 0.5779, 0.6663, 0.5993]}, {"w": "train", "b": [0.6716, 0.5779, 0.7118, 0.5993]}, {"w": "the", "b": [0.7171, 0.5779, 0.7434, 0.5993]}, {"w": "network", "b": [0.7487, 0.5779, 0.8183, 0.5993]}, {"w": "sev‐", "b": [0.8236, 0.5779, 0.8571, 0.5993]}, {"w": "eral", "b": [0.1984, 0.597, 0.2294, 0.6184]}, {"w": "times.", "b": [0.2373, 0.597, 0.2876, 0.6184]}, {"w": "Notice", "b": [0.2955, 0.597, 0.3507, 0.6184]}, {"w": "that", "b": [0.3586, 0.597, 0.3912, 0.6184]}, {"w": "it", "b": [0.3991, 0.597, 0.4111, 0.6184]}, {"w": "is", "b": [0.419, 0.597, 0.4322, 0.6184]}, {"w": "now", "b": [0.4402, 0.597, 0.4765, 0.6184]}, {"w": "consistently", "b": [0.4844, 0.597, 0.5835, 0.6184]}, {"w": "fast", "b": [0.5914, 0.597, 0.6207, 0.6184]}, {"w": "and", "b": [0.6287, 0.597, 0.6602, 0.6184]}, {"w": "never", "b": [0.6681, 0.597, 0.7146, 0.6184]}, {"w": "gets", "b": [0.7225, 0.597, 0.7551, 0.6184]}, {"w": "stuck.", "b": [0.7631, 0.597, 0.812, 0.6184]}, {"w": "This", "b": [0.8199, 0.597, 0.8572, 0.6184]}, {"w": "highlights", "b": [0.1984, 0.616, 0.2813, 0.6374]}, {"w": "an", "b": [0.2895, 0.616, 0.31, 0.6374]}, {"w": "important", "b": [0.3182, 0.616, 0.4026, 0.6374]}, {"w": "finding", "b": [0.4107, 0.616, 0.4716, 0.6374]}, {"w": "in", "b": [0.4797, 0.616, 0.4967, 0.6374]}, {"w": "neural", "b": [0.5049, 0.616, 0.5583, 0.6374]}, {"w": "network", "b": [0.5665, 0.616, 0.6361, 0.6374]}, {"w": "theory:", "b": [0.6442, 0.616, 0.7045, 0.6374]}, {"w": "large", "b": [0.7126, 0.616, 0.7534, 0.6374]}, {"w": "neural", "b": [0.7615, 0.616, 0.815, 0.6374]}, {"w": "net‐", "b": [0.8231, 0.616, 0.8572, 0.6374]}, {"w": "works", "b": [0.1984, 0.6351, 0.249, 0.6565]}, {"w": "almost", "b": [0.2562, 0.6351, 0.3123, 0.6565]}, {"w": "never", "b": [0.3195, 0.6351, 0.366, 0.6565]}, {"w": "get", "b": [0.3732, 0.6351, 0.3981, 0.6565]}, {"w": "stuck", "b": [0.4053, 0.6351, 0.4495, 0.6565]}, {"w": "in", "b": [0.4567, 0.6351, 0.4737, 0.6565]}, {"w": "local", "b": [0.4809, 0.6351, 0.52, 0.6565]}, {"w": "minima,", "b": [0.5272, 0.6351, 0.5978, 0.6565]}, {"w": "and", "b": [0.6049, 0.6351, 0.6365, 0.6565]}, {"w": "even", "b": [0.6437, 0.6351, 0.6824, 0.6565]}, {"w": "when", "b": [0.6896, 0.6351, 0.7352, 0.6565]}, {"w": "they", "b": [0.7424, 0.6351, 0.7783, 0.6565]}, {"w": "do", "b": [0.7855, 0.6351, 0.8071, 0.6565]}, {"w": "these", "b": [0.8143, 0.6351, 0.8572, 0.6565]}, {"w": "local", "b": [0.1984, 0.6541, 0.2375, 0.6755]}, {"w": "optima", "b": [0.2428, 0.6541, 0.3025, 0.6755]}, {"w": "are", "b": [0.3077, 0.6541, 0.3334, 0.6755]}, {"w": "almost", "b": [0.3387, 0.6541, 0.3948, 0.6755]}, {"w": "as", "b": [0.4001, 0.6541, 0.4168, 0.6755]}, {"w": "good", "b": [0.4221, 0.6541, 0.4641, 0.6755]}, {"w": "as", "b": [0.4694, 0.6541, 0.4861, 0.6755]}, {"w": "the", "b": [0.4914, 0.6541, 0.5177, 0.6755]}, {"w": "global", "b": [0.523, 0.6541, 0.5736, 0.6755]}, {"w": "optimum.", "b": [0.5789, 0.6541, 0.6619, 0.6755]}, {"w": "However,", "b": [0.6671, 0.6541, 0.746, 0.6755]}, {"w": "they", "b": [0.7513, 0.6541, 0.7872, 0.6755]}, {"w": "can", "b": [0.7924, 0.6541, 0.8218, 0.6755]}, {"w": "still", "b": [0.827, 0.6541, 0.8571, 0.6755]}, {"w": "get", "b": [0.1984, 0.6732, 0.2234, 0.6946]}, {"w": "stuck", "b": [0.2281, 0.6732, 0.2723, 0.6946]}, {"w": "on", "b": [0.277, 0.6732, 0.299, 0.6946]}, {"w": "long", "b": [0.3038, 0.6732, 0.3408, 0.6946]}, {"w": "plateaus", "b": [0.3455, 0.6732, 0.4132, 0.6946]}, {"w": "for", "b": [0.4179, 0.6732, 0.4424, 0.6946]}, {"w": "a", "b": [0.4471, 0.6732, 0.4563, 0.6946]}, {"w": "long", "b": [0.461, 0.6732, 0.498, 0.6946]}, {"w": "time.", "b": [0.5028, 0.6732, 0.5454, 0.6946]}]}, {"id": "b_9", "type": "paragraph", "text": "• Deep net and vanishing gradients: now change the dataset to be the spiral (bot‐ tom right dataset under “DATA”). Change the network architecture to have 4 hidden layers with 8 neurons each. Notice that training takes much longer, and often gets stuck on plateaus for long periods of time. Also notice that the neu‐ rons in the highest layers (i.e. on the right) tend to evolve faster than the neu‐ rons in the lowest layers (i.e. on the left). This problem, called the “vanishing gradients” problem, can be alleviated using better weight initialization and", "words": [{"w": "•", "b": [0.1799, 0.6983, 0.188, 0.7197]}, {"w": "Deep", "b": [0.1984, 0.6983, 0.2424, 0.7197]}, {"w": "net", "b": [0.2472, 0.6983, 0.2738, 0.7197]}, {"w": "and", "b": [0.2786, 0.6983, 0.3101, 0.7197]}, {"w": "vanishing", "b": [0.3149, 0.6983, 0.3962, 0.7197]}, {"w": "gradients:", "b": [0.401, 0.6983, 0.4828, 0.7197]}, {"w": "now", "b": [0.4876, 0.6983, 0.5239, 0.7197]}, {"w": "change", "b": [0.5287, 0.6983, 0.5878, 0.7197]}, {"w": "the", "b": [0.5926, 0.6983, 0.619, 0.7197]}, {"w": "dataset", "b": [0.6238, 0.6983, 0.6819, 0.7197]}, {"w": "to", "b": [0.6867, 0.6983, 0.7037, 0.7197]}, {"w": "be", "b": [0.7085, 0.6983, 0.7279, 0.7197]}, {"w": "the", "b": [0.7327, 0.6983, 0.7591, 0.7197]}, {"w": "spiral", "b": [0.7639, 0.6983, 0.8102, 0.7197]}, {"w": "(bot‐", "b": [0.815, 0.6983, 0.8571, 0.7197]}, {"w": "tom", "b": [0.1984, 0.7173, 0.2325, 0.7387]}, {"w": "right", "b": [0.239, 0.7173, 0.2791, 0.7387]}, {"w": "dataset", "b": [0.2856, 0.7173, 0.3438, 0.7387]}, {"w": "under", "b": [0.3503, 0.7173, 0.4003, 0.7387]}, {"w": "“DATA”).", "b": [0.4068, 0.7173, 0.4857, 0.7387]}, {"w": "Change", "b": [0.4922, 0.7173, 0.5563, 0.7387]}, {"w": "the", "b": [0.5629, 0.7173, 0.5892, 0.7387]}, {"w": "network", "b": [0.5957, 0.7173, 0.6653, 0.7387]}, {"w": "architecture", "b": [0.6718, 0.7173, 0.7722, 0.7387]}, {"w": "to", "b": [0.7787, 0.7173, 0.7957, 0.7387]}, {"w": "have", "b": [0.8022, 0.7173, 0.8406, 0.7387]}, {"w": "4", "b": [0.8472, 0.7173, 0.8572, 0.7387]}, {"w": "hidden", "b": [0.1984, 0.7364, 0.2574, 0.7578]}, {"w": "layers", "b": [0.2624, 0.7364, 0.3102, 0.7578]}, {"w": "with", "b": [0.3152, 0.7364, 0.3525, 0.7578]}, {"w": "8", "b": [0.3575, 0.7364, 0.3675, 0.7578]}, {"w": "neurons", "b": [0.3725, 0.7364, 0.4412, 0.7578]}, {"w": "each.", "b": [0.4462, 0.7364, 0.4889, 0.7578]}, {"w": "Notice", "b": [0.4939, 0.7364, 0.5491, 0.7578]}, {"w": "that", "b": [0.5541, 0.7364, 0.5867, 0.7578]}, {"w": "training", "b": [0.5916, 0.7364, 0.6586, 0.7578]}, {"w": "takes", "b": [0.6636, 0.7364, 0.7059, 0.7578]}, {"w": "much", "b": [0.7109, 0.7364, 0.7586, 0.7578]}, {"w": "longer,", "b": [0.7636, 0.7364, 0.8206, 0.7578]}, {"w": "and", "b": [0.8256, 0.7364, 0.8572, 0.7578]}, {"w": "often", "b": [0.1984, 0.7554, 0.2418, 0.7768]}, {"w": "gets", "b": [0.2474, 0.7554, 0.28, 0.7768]}, {"w": "stuck", "b": [0.2856, 0.7554, 0.3298, 0.7768]}, {"w": "on", "b": [0.3354, 0.7554, 0.3574, 0.7768]}, {"w": "plateaus", "b": [0.363, 0.7554, 0.4306, 0.7768]}, {"w": "for", "b": [0.4362, 0.7554, 0.4608, 0.7768]}, {"w": "long", "b": [0.4664, 0.7554, 0.5034, 0.7768]}, {"w": "periods", "b": [0.509, 0.7554, 0.5714, 0.7768]}, {"w": "of", "b": [0.577, 0.7554, 0.5938, 0.7768]}, {"w": "time.", "b": [0.5993, 0.7554, 0.642, 0.7768]}, {"w": "Also", "b": [0.6476, 0.7554, 0.6855, 0.7768]}, {"w": "notice", "b": [0.6911, 0.7554, 0.7427, 0.7768]}, {"w": "that", "b": [0.7483, 0.7554, 0.7809, 0.7768]}, {"w": "the", "b": [0.7865, 0.7554, 0.8128, 0.7768]}, {"w": "neu‐", "b": [0.8184, 0.7554, 0.8572, 0.7768]}, {"w": "rons", "b": [0.1984, 0.7745, 0.2358, 0.7959]}, {"w": "in", "b": [0.2416, 0.7745, 0.2585, 0.7959]}, {"w": "the", "b": [0.2643, 0.7745, 0.2906, 0.7959]}, {"w": "highest", "b": [0.2964, 0.7745, 0.3568, 0.7959]}, {"w": "layers", "b": [0.3626, 0.7745, 0.4104, 0.7959]}, {"w": "(i.e.", "b": [0.4162, 0.7745, 0.4473, 0.7959]}, {"w": "on", "b": [0.4531, 0.7745, 0.4751, 0.7959]}, {"w": "the", "b": [0.4809, 0.7745, 0.5072, 0.7959]}, {"w": "right)", "b": [0.513, 0.7745, 0.5603, 0.7959]}, {"w": "tend", "b": [0.5661, 0.7745, 0.6037, 0.7959]}, {"w": "to", "b": [0.6095, 0.7745, 0.6264, 0.7959]}, {"w": "evolve", "b": [0.6322, 0.7745, 0.6851, 0.7959]}, {"w": "faster", "b": [0.6909, 0.7745, 0.7368, 0.7959]}, {"w": "than", "b": [0.7425, 0.7745, 0.7805, 0.7959]}, {"w": "the", "b": [0.7863, 0.7745, 0.8126, 0.7959]}, {"w": "neu‐", "b": [0.8184, 0.7745, 0.8571, 0.7959]}, {"w": "rons", "b": [0.1984, 0.7935, 0.2358, 0.8149]}, {"w": "in", "b": [0.2421, 0.7935, 0.2591, 0.8149]}, {"w": "the", "b": [0.2654, 0.7935, 0.2917, 0.8149]}, {"w": "lowest", "b": [0.298, 0.7935, 0.351, 0.8149]}, {"w": "layers", "b": [0.3573, 0.7935, 0.4051, 0.8149]}, {"w": "(i.e.", "b": [0.4114, 0.7935, 0.4426, 0.8149]}, {"w": "on", "b": [0.4489, 0.7935, 0.4709, 0.8149]}, {"w": "the", "b": [0.4772, 0.7935, 0.5035, 0.8149]}, {"w": "left).", "b": [0.5098, 0.7935, 0.5484, 0.8149]}, {"w": "This", "b": [0.5547, 0.7935, 0.5919, 0.8149]}, {"w": "problem,", "b": [0.5982, 0.7935, 0.674, 0.8149]}, {"w": "called", "b": [0.6803, 0.7935, 0.7287, 0.8149]}, {"w": "the", "b": [0.7349, 0.7935, 0.7613, 0.8149]}, {"w": "“vanishing", "b": [0.7676, 0.7935, 0.8571, 0.8149]}, {"w": "gradients”", "b": [0.1984, 0.8125, 0.283, 0.834]}, {"w": "problem,", "b": [0.2923, 0.8125, 0.3681, 0.834]}, {"w": "can", "b": [0.3773, 0.8125, 0.4067, 0.834]}, {"w": "be", "b": [0.416, 0.8125, 0.4354, 0.834]}, {"w": "alleviated", "b": [0.4447, 0.8125, 0.5235, 0.834]}, {"w": "using", "b": [0.5328, 0.8125, 0.5782, 0.834]}, {"w": "better", "b": [0.5875, 0.8125, 0.6362, 0.834]}, {"w": "weight", "b": [0.6455, 0.8125, 0.701, 0.834]}, {"w": "initialization", "b": [0.7103, 0.8125, 0.8163, 0.834]}, {"w": "and", "b": [0.8256, 0.8125, 0.8571, 0.834]}]}, {"id": "b_10", "type": "paragraph", "text": "322 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "322", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2745, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3635, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4582, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 349, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "other techniques, better optimizers (such as AdaGrad or Adam), or using Batch Normalization.", "words": [{"w": "other", "b": [0.1984, 0.0791, 0.2431, 0.1005]}, {"w": "techniques,", "b": [0.2528, 0.0791, 0.3478, 0.1005]}, {"w": "better", "b": [0.3575, 0.0791, 0.4062, 0.1005]}, {"w": "optimizers", "b": [0.4159, 0.0791, 0.505, 0.1005]}, {"w": "(such", "b": [0.5146, 0.0791, 0.5605, 0.1005]}, {"w": "as", "b": [0.5701, 0.0791, 0.5869, 0.1005]}, {"w": "AdaGrad", "b": [0.5966, 0.0791, 0.6734, 0.1005]}, {"w": "or", "b": [0.683, 0.0791, 0.7014, 0.1005]}, {"w": "Adam),", "b": [0.711, 0.0791, 0.774, 0.1005]}, {"w": "or", "b": [0.7837, 0.0791, 0.8021, 0.1005]}, {"w": "using", "b": [0.8117, 0.0791, 0.8571, 0.1005]}, {"w": "Batch", "b": [0.1984, 0.0981, 0.2457, 0.1195]}, {"w": "Normalization.", "b": [0.2504, 0.0981, 0.377, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "• More: go ahead and play with the other parameters to get a feel of what they do. In fact, you should definitely play with this UI for at least one hour, it will grow your intuitions about neural networks significantly.", "words": [{"w": "•", "b": [0.1799, 0.1232, 0.188, 0.1446]}, {"w": "More:", "b": [0.1984, 0.1232, 0.2484, 0.1446]}, {"w": "go", "b": [0.2549, 0.1232, 0.2753, 0.1446]}, {"w": "ahead", "b": [0.2818, 0.1232, 0.3311, 0.1446]}, {"w": "and", "b": [0.3376, 0.1232, 0.3692, 0.1446]}, {"w": "play", "b": [0.3757, 0.1232, 0.4102, 0.1446]}, {"w": "with", "b": [0.4167, 0.1232, 0.4541, 0.1446]}, {"w": "the", "b": [0.4606, 0.1232, 0.4869, 0.1446]}, {"w": "other", "b": [0.4934, 0.1232, 0.5381, 0.1446]}, {"w": "parameters", "b": [0.5446, 0.1232, 0.6381, 0.1446]}, {"w": "to", "b": [0.6446, 0.1232, 0.6616, 0.1446]}, {"w": "get", "b": [0.6681, 0.1232, 0.6931, 0.1446]}, {"w": "a", "b": [0.6996, 0.1232, 0.7087, 0.1446]}, {"w": "feel", "b": [0.7152, 0.1232, 0.7444, 0.1446]}, {"w": "of", "b": [0.7509, 0.1232, 0.7677, 0.1446]}, {"w": "what", "b": [0.7742, 0.1232, 0.8147, 0.1446]}, {"w": "they", "b": [0.8213, 0.1232, 0.8571, 0.1446]}, {"w": "do.", "b": [0.1984, 0.1423, 0.2242, 0.1637]}, {"w": "In", "b": [0.23, 0.1423, 0.2485, 0.1637]}, {"w": "fact,", "b": [0.2544, 0.1423, 0.2896, 0.1637]}, {"w": "you", "b": [0.2955, 0.1423, 0.3267, 0.1637]}, {"w": "should", "b": [0.3326, 0.1423, 0.3893, 0.1637]}, {"w": "definitely", "b": [0.3951, 0.1423, 0.4738, 0.1637]}, {"w": "play", "b": [0.4796, 0.1423, 0.5141, 0.1637]}, {"w": "with", "b": [0.52, 0.1423, 0.5573, 0.1637]}, {"w": "this", "b": [0.5632, 0.1423, 0.5939, 0.1637]}, {"w": "UI", "b": [0.5997, 0.1423, 0.6221, 0.1637]}, {"w": "for", "b": [0.628, 0.1423, 0.6525, 0.1637]}, {"w": "at", "b": [0.6584, 0.1423, 0.6735, 0.1637]}, {"w": "least", "b": [0.6793, 0.1423, 0.7166, 0.1637]}, {"w": "one", "b": [0.7224, 0.1423, 0.7533, 0.1637]}, {"w": "hour,", "b": [0.7591, 0.1423, 0.8031, 0.1637]}, {"w": "it", "b": [0.809, 0.1423, 0.8209, 0.1637]}, {"w": "will", "b": [0.8268, 0.1423, 0.8572, 0.1637]}, {"w": "grow", "b": [0.1984, 0.1613, 0.2408, 0.1827]}, {"w": "your", "b": [0.2455, 0.1613, 0.2845, 0.1827]}, {"w": "intuitions", "b": [0.2892, 0.1613, 0.3704, 0.1827]}, {"w": "about", "b": [0.3752, 0.1613, 0.4229, 0.1827]}, {"w": "neural", "b": [0.4277, 0.1613, 0.4811, 0.1827]}, {"w": "networks", "b": [0.4858, 0.1613, 0.563, 0.1827]}, {"w": "significantly.", "b": [0.5678, 0.1613, 0.6729, 0.1827]}]}, {"id": "b_2", "type": "paragraph", "text": "2. Draw an ANN using the original artificial neurons (like the ones in Figure 10-3) that computes A ⊕ B (where ⊕ represents the XOR operation). Hint: A ⊕ B = (A ∧ ¬ B) ∨ (¬ A ∧ B).", "words": [{"w": "2.", "b": [0.1534, 0.1955, 0.1682, 0.2169]}, {"w": "Draw", "b": [0.1786, 0.1955, 0.2246, 0.2169]}, {"w": "an", "b": [0.2303, 0.1955, 0.2509, 0.2169]}, {"w": "ANN", "b": [0.2566, 0.1955, 0.3019, 0.2169]}, {"w": "using", "b": [0.3076, 0.1955, 0.353, 0.2169]}, {"w": "the", "b": [0.3587, 0.1955, 0.3851, 0.2169]}, {"w": "original", "b": [0.3908, 0.1955, 0.4558, 0.2169]}, {"w": "artificial", "b": [0.4615, 0.1955, 0.5309, 0.2169]}, {"w": "neurons", "b": [0.5366, 0.1955, 0.6053, 0.2169]}, {"w": "(like", "b": [0.611, 0.1955, 0.6482, 0.2169]}, {"w": "the", "b": [0.6539, 0.1955, 0.6803, 0.2169]}, {"w": "ones", "b": [0.6859, 0.1955, 0.7245, 0.2169]}, {"w": "in", "b": [0.7302, 0.1955, 0.7471, 0.2169]}, {"w": "Figure", "b": [0.7528, 0.1955, 0.8068, 0.2169]}, {"w": "10-3)", "b": [0.8125, 0.1955, 0.8571, 0.2169]}, {"w": "that", "b": [0.1786, 0.2145, 0.2112, 0.2359]}, {"w": "computes", "b": [0.2164, 0.2145, 0.2973, 0.2359]}, {"w": "A", "b": [0.3026, 0.2143, 0.3164, 0.2359]}, {"w": "⊕", "b": [0.3216, 0.2178, 0.3378, 0.2336]}, {"w": "B", "b": [0.343, 0.2143, 0.3551, 0.2359]}, {"w": "(where", "b": [0.3603, 0.2145, 0.4184, 0.2359]}, {"w": "⊕", "b": [0.4236, 0.2178, 0.4398, 0.2336]}, {"w": "represents", "b": [0.445, 0.2145, 0.5306, 0.2359]}, {"w": "the", "b": [0.5358, 0.2145, 0.5622, 0.2359]}, {"w": "XOR", "b": [0.5674, 0.2145, 0.6089, 0.2359]}, {"w": "operation).", "b": [0.6141, 0.2145, 0.7069, 0.2359]}, {"w": "Hint:", "b": [0.7121, 0.2145, 0.7558, 0.2359]}, {"w": "A", "b": [0.761, 0.2143, 0.7748, 0.2359]}, {"w": "⊕", "b": [0.7801, 0.2178, 0.7963, 0.2336]}, {"w": "B", "b": [0.8015, 0.2143, 0.8136, 0.2359]}, {"w": "=", "b": [0.8188, 0.2145, 0.8309, 0.2359]}, {"w": "(A", "b": [0.8356, 0.2143, 0.8571, 0.2359]}, {"w": "∧", "b": [0.1786, 0.2368, 0.1924, 0.2527]}, {"w": "¬", "b": [0.1972, 0.2336, 0.2093, 0.255]}, {"w": "B)", "b": [0.214, 0.2334, 0.2333, 0.255]}, {"w": "∨", "b": [0.238, 0.2368, 0.2519, 0.2527]}, {"w": "(¬", "b": [0.2566, 0.2336, 0.2759, 0.255]}, {"w": "A", "b": [0.2806, 0.2334, 0.2944, 0.255]}, {"w": "∧", "b": [0.2992, 0.2368, 0.3131, 0.2527]}, {"w": "B).", "b": [0.3178, 0.2334, 0.3418, 0.255]}]}, {"id": "b_3", "type": "paragraph", "text": "3. Why is it generally preferable to use a Logistic Regression classifier rather than a classical Perceptron (i.e., a single layer of threshold logic units trained using the Perceptron training algorithm)? How can you tweak a Perceptron to make it equivalent to a Logistic Regression classifier?", "words": [{"w": "3.", "b": [0.1534, 0.2587, 0.1682, 0.2801]}, {"w": "Why", "b": [0.1786, 0.2587, 0.219, 0.2801]}, {"w": "is", "b": [0.2246, 0.2587, 0.2378, 0.2801]}, {"w": "it", "b": [0.2434, 0.2587, 0.2553, 0.2801]}, {"w": "generally", "b": [0.2609, 0.2587, 0.3368, 0.2801]}, {"w": "preferable", "b": [0.3423, 0.2587, 0.4264, 0.2801]}, {"w": "to", "b": [0.432, 0.2587, 0.449, 0.2801]}, {"w": "use", "b": [0.4546, 0.2587, 0.4822, 0.2801]}, {"w": "a", "b": [0.4877, 0.2587, 0.4969, 0.2801]}, {"w": "Logistic", "b": [0.5025, 0.2587, 0.568, 0.2801]}, {"w": "Regression", "b": [0.5736, 0.2587, 0.6646, 0.2801]}, {"w": "classifier", "b": [0.6702, 0.2587, 0.7427, 0.2801]}, {"w": "rather", "b": [0.7483, 0.2587, 0.7988, 0.2801]}, {"w": "than", "b": [0.8044, 0.2587, 0.8424, 0.2801]}, {"w": "a", "b": [0.848, 0.2587, 0.8571, 0.2801]}, {"w": "classical", "b": [0.1786, 0.2777, 0.2459, 0.2991]}, {"w": "Perceptron", "b": [0.2521, 0.2777, 0.3445, 0.2991]}, {"w": "(i.e.,", "b": [0.3507, 0.2777, 0.3866, 0.2991]}, {"w": "a", "b": [0.3928, 0.2777, 0.402, 0.2991]}, {"w": "single", "b": [0.4082, 0.2777, 0.4567, 0.2991]}, {"w": "layer", "b": [0.4629, 0.2777, 0.5031, 0.2991]}, {"w": "of", "b": [0.5093, 0.2777, 0.5261, 0.2991]}, {"w": "threshold", "b": [0.5324, 0.2777, 0.6121, 0.2991]}, {"w": "logic", "b": [0.6183, 0.2777, 0.6584, 0.2991]}, {"w": "units", "b": [0.6646, 0.2777, 0.7066, 0.2991]}, {"w": "trained", "b": [0.7129, 0.2777, 0.7729, 0.2991]}, {"w": "using", "b": [0.7791, 0.2777, 0.8246, 0.2991]}, {"w": "the", "b": [0.8308, 0.2777, 0.8571, 0.2991]}, {"w": "Perceptron", "b": [0.1786, 0.2967, 0.2709, 0.3182]}, {"w": "training", "b": [0.2796, 0.2967, 0.3465, 0.3182]}, {"w": "algorithm)?", "b": [0.3553, 0.2967, 0.453, 0.3182]}, {"w": "How", "b": [0.4617, 0.2967, 0.5021, 0.3182]}, {"w": "can", "b": [0.5108, 0.2967, 0.5401, 0.3182]}, {"w": "you", "b": [0.5488, 0.2967, 0.5801, 0.3182]}, {"w": "tweak", "b": [0.5888, 0.2967, 0.6378, 0.3182]}, {"w": "a", "b": [0.6465, 0.2967, 0.6556, 0.3182]}, {"w": "Perceptron", "b": [0.6643, 0.2967, 0.7567, 0.3182]}, {"w": "to", "b": [0.7654, 0.2967, 0.7824, 0.3182]}, {"w": "make", "b": [0.7911, 0.2967, 0.8365, 0.3182]}, {"w": "it", "b": [0.8452, 0.2967, 0.8571, 0.3182]}, {"w": "equivalent", "b": [0.1786, 0.3158, 0.265, 0.3372]}, {"w": "to", "b": [0.2697, 0.3158, 0.2867, 0.3372]}, {"w": "a", "b": [0.2914, 0.3158, 0.3006, 0.3372]}, {"w": "Logistic", "b": [0.3053, 0.3158, 0.3709, 0.3372]}, {"w": "Regression", "b": [0.3756, 0.3158, 0.4666, 0.3372]}, {"w": "classifier?", "b": [0.4713, 0.3158, 0.5517, 0.3372]}]}, {"id": "b_4", "type": "paragraph", "text": "4. Why was the logistic activation function a key ingredient in training the first MLPs?", "words": [{"w": "4.", "b": [0.1534, 0.3409, 0.1682, 0.3623]}, {"w": "Why", "b": [0.1786, 0.3409, 0.219, 0.3623]}, {"w": "was", "b": [0.2273, 0.3409, 0.2584, 0.3623]}, {"w": "the", "b": [0.2667, 0.3409, 0.293, 0.3623]}, {"w": "logistic", "b": [0.3013, 0.3409, 0.361, 0.3623]}, {"w": "activation", "b": [0.3693, 0.3409, 0.4515, 0.3623]}, {"w": "function", "b": [0.4598, 0.3409, 0.5312, 0.3623]}, {"w": "a", "b": [0.5395, 0.3409, 0.5487, 0.3623]}, {"w": "key", "b": [0.557, 0.3409, 0.5857, 0.3623]}, {"w": "ingredient", "b": [0.5941, 0.3409, 0.6802, 0.3623]}, {"w": "in", "b": [0.6885, 0.3409, 0.7055, 0.3623]}, {"w": "training", "b": [0.7138, 0.3409, 0.7807, 0.3623]}, {"w": "the", "b": [0.789, 0.3409, 0.8153, 0.3623]}, {"w": "first", "b": [0.8237, 0.3409, 0.8571, 0.3623]}, {"w": "MLPs?", "b": [0.1786, 0.3599, 0.235, 0.3814]}]}, {"id": "b_5", "type": "paragraph", "text": "5. Name three popular activation functions. Can you draw them?", "words": [{"w": "5.", "b": [0.1534, 0.385, 0.1682, 0.4064]}, {"w": "Name", "b": [0.1786, 0.385, 0.2286, 0.4064]}, {"w": "three", "b": [0.2333, 0.385, 0.2762, 0.4064]}, {"w": "popular", "b": [0.2809, 0.385, 0.3466, 0.4064]}, {"w": "activation", "b": [0.3513, 0.385, 0.4336, 0.4064]}, {"w": "functions.", "b": [0.4383, 0.385, 0.5221, 0.4064]}, {"w": "Can", "b": [0.5268, 0.385, 0.5612, 0.4064]}, {"w": "you", "b": [0.566, 0.385, 0.5972, 0.4064]}, {"w": "draw", "b": [0.6019, 0.385, 0.6437, 0.4064]}, {"w": "them?", "b": [0.6484, 0.385, 0.6997, 0.4064]}]}, {"id": "b_6", "type": "paragraph", "text": "6. Suppose you have an MLP composed of one input layer with 10 passthrough neurons, followed by one hidden layer with 50 artificial neurons, and finally one output layer with 3 artificial neurons. All artificial neurons use the ReLU activa‐ tion function.", "words": [{"w": "6.", "b": [0.1534, 0.4101, 0.1682, 0.4315]}, {"w": "Suppose", "b": [0.1786, 0.4101, 0.2485, 0.4315]}, {"w": "you", "b": [0.2567, 0.4101, 0.2879, 0.4315]}, {"w": "have", "b": [0.2961, 0.4101, 0.3345, 0.4315]}, {"w": "an", "b": [0.3428, 0.4101, 0.3633, 0.4315]}, {"w": "MLP", "b": [0.3715, 0.4101, 0.413, 0.4315]}, {"w": "composed", "b": [0.4212, 0.4101, 0.5064, 0.4315]}, {"w": "of", "b": [0.5146, 0.4101, 0.5314, 0.4315]}, {"w": "one", "b": [0.5396, 0.4101, 0.5705, 0.4315]}, {"w": "input", "b": [0.5787, 0.4101, 0.6236, 0.4315]}, {"w": "layer", "b": [0.6318, 0.4101, 0.672, 0.4315]}, {"w": "with", "b": [0.6802, 0.4101, 0.7176, 0.4315]}, {"w": "10", "b": [0.7258, 0.4101, 0.7458, 0.4315]}, {"w": "passthrough", "b": [0.754, 0.4101, 0.8571, 0.4315]}, {"w": "neurons,", "b": [0.1786, 0.4292, 0.252, 0.4506]}, {"w": "followed", "b": [0.2577, 0.4292, 0.3298, 0.4506]}, {"w": "by", "b": [0.3354, 0.4292, 0.3556, 0.4506]}, {"w": "one", "b": [0.3612, 0.4292, 0.3921, 0.4506]}, {"w": "hidden", "b": [0.3978, 0.4292, 0.4567, 0.4506]}, {"w": "layer", "b": [0.4624, 0.4292, 0.5026, 0.4506]}, {"w": "with", "b": [0.5082, 0.4292, 0.5456, 0.4506]}, {"w": "50", "b": [0.5512, 0.4292, 0.5712, 0.4506]}, {"w": "artificial", "b": [0.5769, 0.4292, 0.6462, 0.4506]}, {"w": "neurons,", "b": [0.6519, 0.4292, 0.7254, 0.4506]}, {"w": "and", "b": [0.731, 0.4292, 0.7626, 0.4506]}, {"w": "finally", "b": [0.7682, 0.4292, 0.8206, 0.4506]}, {"w": "one", "b": [0.8263, 0.4292, 0.8571, 0.4506]}, {"w": "output", "b": [0.1786, 0.4482, 0.2349, 0.4696]}, {"w": "layer", "b": [0.2409, 0.4482, 0.2811, 0.4696]}, {"w": "with", "b": [0.287, 0.4482, 0.3243, 0.4696]}, {"w": "3", "b": [0.3303, 0.4482, 0.3403, 0.4696]}, {"w": "artificial", "b": [0.3462, 0.4482, 0.4156, 0.4696]}, {"w": "neurons.", "b": [0.4216, 0.4482, 0.495, 0.4696]}, {"w": "All", "b": [0.501, 0.4482, 0.5259, 0.4696]}, {"w": "artificial", "b": [0.5318, 0.4482, 0.6012, 0.4696]}, {"w": "neurons", "b": [0.6072, 0.4482, 0.6759, 0.4696]}, {"w": "use", "b": [0.6818, 0.4482, 0.7094, 0.4696]}, {"w": "the", "b": [0.7153, 0.4482, 0.7416, 0.4696]}, {"w": "ReLU", "b": [0.7476, 0.4482, 0.7951, 0.4696]}, {"w": "activa‐", "b": [0.801, 0.4482, 0.8571, 0.4696]}, {"w": "tion", "b": [0.1786, 0.4673, 0.2125, 0.4887]}, {"w": "function.", "b": [0.2173, 0.4673, 0.2934, 0.4887]}]}, {"id": "b_7", "type": "paragraph", "text": "• What is the shape of the input matrix X?", "words": [{"w": "•", "b": [0.1799, 0.4984, 0.188, 0.5198]}, {"w": "What", "b": [0.1984, 0.4984, 0.2449, 0.5198]}, {"w": "is", "b": [0.2496, 0.4984, 0.2628, 0.5198]}, {"w": "the", "b": [0.2676, 0.4984, 0.2939, 0.5198]}, {"w": "shape", "b": [0.2986, 0.4984, 0.3459, 0.5198]}, {"w": "of", "b": [0.3506, 0.4984, 0.3674, 0.5198]}, {"w": "the", "b": [0.3722, 0.4984, 0.3985, 0.5198]}, {"w": "input", "b": [0.4032, 0.4984, 0.4481, 0.5198]}, {"w": "matrix", "b": [0.4529, 0.4984, 0.5082, 0.5198]}, {"w": "X?", "b": [0.5129, 0.4979, 0.5353, 0.5198]}]}, {"id": "b_8", "type": "paragraph", "text": "• What about the shape of the hidden layer’s weight vector Wh, and the shape of its bias vector bh?", "words": [{"w": "•", "b": [0.1799, 0.5235, 0.188, 0.5449]}, {"w": "What", "b": [0.1984, 0.5235, 0.2449, 0.5449]}, {"w": "about", "b": [0.2504, 0.5235, 0.2982, 0.5449]}, {"w": "the", "b": [0.3037, 0.5235, 0.33, 0.5449]}, {"w": "shape", "b": [0.3355, 0.5235, 0.3828, 0.5449]}, {"w": "of", "b": [0.3883, 0.5235, 0.4051, 0.5449]}, {"w": "the", "b": [0.4107, 0.5235, 0.437, 0.5449]}, {"w": "hidden", "b": [0.4425, 0.5235, 0.5015, 0.5449]}, {"w": "layer’s", "b": [0.507, 0.5235, 0.5575, 0.5449]}, {"w": "weight", "b": [0.563, 0.5235, 0.6185, 0.5449]}, {"w": "vector", "b": [0.6241, 0.5235, 0.6761, 0.5449]}, {"w": "Wh,", "b": [0.6816, 0.523, 0.7131, 0.5458]}, {"w": "and", "b": [0.7186, 0.5235, 0.7502, 0.5449]}, {"w": "the", "b": [0.7557, 0.5235, 0.782, 0.5449]}, {"w": "shape", "b": [0.7875, 0.5235, 0.8348, 0.5449]}, {"w": "of", "b": [0.8403, 0.5235, 0.8571, 0.5449]}, {"w": "its", "b": [0.1984, 0.5426, 0.218, 0.564]}, {"w": "bias", "b": [0.2227, 0.5426, 0.2557, 0.564]}, {"w": "vector", "b": [0.2604, 0.5426, 0.3124, 0.564]}, {"w": "bh?", "b": [0.3172, 0.542, 0.3426, 0.5649]}]}, {"id": "b_9", "type": "paragraph", "text": "• What is the shape of the output layer’s weight vector Wo, and its bias vector bo?", "words": [{"w": "•", "b": [0.1799, 0.5676, 0.188, 0.5891]}, {"w": "What", "b": [0.1984, 0.5676, 0.2449, 0.5891]}, {"w": "is", "b": [0.2496, 0.5676, 0.2628, 0.5891]}, {"w": "the", "b": [0.2676, 0.5676, 0.2939, 0.5891]}, {"w": "shape", "b": [0.2986, 0.5676, 0.3459, 0.5891]}, {"w": "of", "b": [0.3506, 0.5676, 0.3674, 0.5891]}, {"w": "the", "b": [0.3722, 0.5676, 0.3985, 0.5891]}, {"w": "output", "b": [0.4032, 0.5676, 0.4596, 0.5891]}, {"w": "layer’s", "b": [0.4643, 0.5676, 0.5148, 0.5891]}, {"w": "weight", "b": [0.5196, 0.5676, 0.5751, 0.5891]}, {"w": "vector", "b": [0.5798, 0.5676, 0.6319, 0.5891]}, {"w": "Wo,", "b": [0.6366, 0.5671, 0.6676, 0.59]}, {"w": "and", "b": [0.6723, 0.5676, 0.7039, 0.5891]}, {"w": "its", "b": [0.7086, 0.5676, 0.7282, 0.5891]}, {"w": "bias", "b": [0.7329, 0.5676, 0.7659, 0.5891]}, {"w": "vector", "b": [0.7706, 0.5676, 0.8226, 0.5891]}, {"w": "bo?", "b": [0.8273, 0.5671, 0.8522, 0.59]}]}, {"id": "b_10", "type": "paragraph", "text": "• What is the shape of the network’s output matrix Y?", "words": [{"w": "•", "b": [0.1799, 0.5927, 0.188, 0.6142]}, {"w": "What", "b": [0.1984, 0.5927, 0.2449, 0.6142]}, {"w": "is", "b": [0.2496, 0.5927, 0.2628, 0.6142]}, {"w": "the", "b": [0.2676, 0.5927, 0.2939, 0.6142]}, {"w": "shape", "b": [0.2986, 0.5927, 0.3459, 0.6142]}, {"w": "of", "b": [0.3506, 0.5927, 0.3674, 0.6142]}, {"w": "the", "b": [0.3722, 0.5927, 0.3985, 0.6142]}, {"w": "network’s", "b": [0.4032, 0.5927, 0.4823, 0.6142]}, {"w": "output", "b": [0.487, 0.5927, 0.5434, 0.6142]}, {"w": "matrix", "b": [0.5481, 0.5927, 0.6034, 0.6142]}, {"w": "Y?", "b": [0.6081, 0.5922, 0.6297, 0.6142]}]}, {"id": "b_11", "type": "paragraph", "text": "• Write the equation that computes the network’s output matrix Y as a function of X, Wh, bh, Wo and bo.", "words": [{"w": "•", "b": [0.1799, 0.6178, 0.188, 0.6392]}, {"w": "Write", "b": [0.1984, 0.6178, 0.2454, 0.6393]}, {"w": "the", "b": [0.2513, 0.6178, 0.2776, 0.6393]}, {"w": "equation", "b": [0.2835, 0.6178, 0.3568, 0.6393]}, {"w": "that", "b": [0.3626, 0.6178, 0.3952, 0.6393]}, {"w": "computes", "b": [0.4011, 0.6178, 0.482, 0.6393]}, {"w": "the", "b": [0.4879, 0.6178, 0.5143, 0.6393]}, {"w": "network’s", "b": [0.5201, 0.6178, 0.5992, 0.6393]}, {"w": "output", "b": [0.6051, 0.6178, 0.6614, 0.6393]}, {"w": "matrix", "b": [0.6673, 0.6178, 0.7226, 0.6393]}, {"w": "Y", "b": [0.7285, 0.6173, 0.7422, 0.6393]}, {"w": "as", "b": [0.748, 0.6178, 0.7648, 0.6393]}, {"w": "a", "b": [0.7707, 0.6178, 0.7799, 0.6393]}, {"w": "function", "b": [0.7858, 0.6178, 0.8572, 0.6393]}, {"w": "of", "b": [0.1984, 0.6369, 0.2152, 0.6583]}, {"w": "X,", "b": [0.2199, 0.6363, 0.2391, 0.6583]}, {"w": "Wh,", "b": [0.2439, 0.6363, 0.2754, 0.6592]}, {"w": "bh,", "b": [0.2801, 0.6363, 0.3024, 0.6592]}, {"w": "Wo", "b": [0.3071, 0.6363, 0.3334, 0.6592]}, {"w": "and", "b": [0.3381, 0.6369, 0.3696, 0.6583]}, {"w": "bo.", "b": [0.3744, 0.6363, 0.3961, 0.6592]}]}, {"id": "b_12", "type": "paragraph", "text": "7. How many neurons do you need in the output layer if you want to classify email into spam or ham? What activation function should you use in the output layer? If instead you want to tackle MNIST, how many neurons do you need in the out‐ put layer, using what activation function? Answer the same questions for getting your network to predict housing prices as in Chapter 2.", "words": [{"w": "7.", "b": [0.1534, 0.671, 0.1681, 0.6925]}, {"w": "How", "b": [0.1786, 0.671, 0.2189, 0.6925]}, {"w": "many", "b": [0.2244, 0.671, 0.2711, 0.6925]}, {"w": "neurons", "b": [0.2767, 0.671, 0.3454, 0.6925]}, {"w": "do", "b": [0.3509, 0.671, 0.3725, 0.6925]}, {"w": "you", "b": [0.3781, 0.671, 0.4093, 0.6925]}, {"w": "need", "b": [0.4149, 0.671, 0.455, 0.6925]}, {"w": "in", "b": [0.4605, 0.671, 0.4775, 0.6925]}, {"w": "the", "b": [0.483, 0.671, 0.5094, 0.6925]}, {"w": "output", "b": [0.5149, 0.671, 0.5713, 0.6925]}, {"w": "layer", "b": [0.5768, 0.671, 0.617, 0.6925]}, {"w": "if", "b": [0.6226, 0.671, 0.6343, 0.6925]}, {"w": "you", "b": [0.6399, 0.671, 0.6711, 0.6925]}, {"w": "want", "b": [0.6767, 0.671, 0.7174, 0.6925]}, {"w": "to", "b": [0.723, 0.671, 0.7399, 0.6925]}, {"w": "classify", "b": [0.7455, 0.671, 0.8057, 0.6925]}, {"w": "email", "b": [0.8112, 0.671, 0.8571, 0.6925]}, {"w": "into", "b": [0.1786, 0.6901, 0.2121, 0.7115]}, {"w": "spam", "b": [0.2178, 0.6901, 0.2625, 0.7115]}, {"w": "or", "b": [0.2682, 0.6901, 0.2865, 0.7115]}, {"w": "ham?", "b": [0.2922, 0.6901, 0.3374, 0.7115]}, {"w": "What", "b": [0.343, 0.6901, 0.3895, 0.7115]}, {"w": "activation", "b": [0.3951, 0.6901, 0.4774, 0.7115]}, {"w": "function", "b": [0.483, 0.6901, 0.5544, 0.7115]}, {"w": "should", "b": [0.56, 0.6901, 0.6168, 0.7115]}, {"w": "you", "b": [0.6224, 0.6901, 0.6536, 0.7115]}, {"w": "use", "b": [0.6593, 0.6901, 0.6868, 0.7115]}, {"w": "in", "b": [0.6925, 0.6901, 0.7095, 0.7115]}, {"w": "the", "b": [0.7151, 0.6901, 0.7414, 0.7115]}, {"w": "output", "b": [0.7471, 0.6901, 0.8034, 0.7115]}, {"w": "layer?", "b": [0.8091, 0.6901, 0.8571, 0.7115]}, {"w": "If", "b": [0.1786, 0.7091, 0.1918, 0.7306]}, {"w": "instead", "b": [0.197, 0.7091, 0.257, 0.7306]}, {"w": "you", "b": [0.2622, 0.7091, 0.2934, 0.7306]}, {"w": "want", "b": [0.2986, 0.7091, 0.3394, 0.7306]}, {"w": "to", "b": [0.3446, 0.7091, 0.3616, 0.7306]}, {"w": "tackle", "b": [0.3668, 0.7091, 0.4155, 0.7306]}, {"w": "MNIST,", "b": [0.4207, 0.7091, 0.4873, 0.7306]}, {"w": "how", "b": [0.4925, 0.7091, 0.5285, 0.7306]}, {"w": "many", "b": [0.5337, 0.7091, 0.5804, 0.7306]}, {"w": "neurons", "b": [0.5855, 0.7091, 0.6543, 0.7306]}, {"w": "do", "b": [0.6594, 0.7091, 0.6811, 0.7306]}, {"w": "you", "b": [0.6863, 0.7091, 0.7175, 0.7306]}, {"w": "need", "b": [0.7227, 0.7091, 0.7628, 0.7306]}, {"w": "in", "b": [0.768, 0.7091, 0.785, 0.7306]}, {"w": "the", "b": [0.7902, 0.7091, 0.8165, 0.7306]}, {"w": "out‐", "b": [0.8217, 0.7091, 0.8571, 0.7306]}, {"w": "put", "b": [0.1786, 0.7282, 0.2069, 0.7496]}, {"w": "layer,", "b": [0.2127, 0.7282, 0.2563, 0.7496]}, {"w": "using", "b": [0.2621, 0.7282, 0.3075, 0.7496]}, {"w": "what", "b": [0.3133, 0.7282, 0.3538, 0.7496]}, {"w": "activation", "b": [0.3595, 0.7282, 0.4418, 0.7496]}, {"w": "function?", "b": [0.4475, 0.7282, 0.5268, 0.7496]}, {"w": "Answer", "b": [0.5326, 0.7282, 0.5969, 0.7496]}, {"w": "the", "b": [0.6027, 0.7282, 0.629, 0.7496]}, {"w": "same", "b": [0.6348, 0.7282, 0.6775, 0.7496]}, {"w": "questions", "b": [0.6832, 0.7282, 0.763, 0.7496]}, {"w": "for", "b": [0.7688, 0.7282, 0.7933, 0.7496]}, {"w": "getting", "b": [0.7991, 0.7282, 0.8571, 0.7496]}, {"w": "your", "b": [0.1786, 0.7472, 0.2176, 0.7687]}, {"w": "network", "b": [0.2223, 0.7472, 0.2919, 0.7687]}, {"w": "to", "b": [0.2966, 0.7472, 0.3136, 0.7687]}, {"w": "predict", "b": [0.3183, 0.7472, 0.3775, 0.7687]}, {"w": "housing", "b": [0.3823, 0.7472, 0.4495, 0.7687]}, {"w": "prices", "b": [0.4542, 0.7472, 0.5037, 0.7687]}, {"w": "as", "b": [0.5085, 0.7472, 0.5252, 0.7687]}, {"w": "in", "b": [0.53, 0.7472, 0.547, 0.7687]}, {"w": "Chapter", "b": [0.5517, 0.7472, 0.6193, 0.7687]}, {"w": "2.", "b": [0.624, 0.7472, 0.6387, 0.7687]}]}, {"id": "b_13", "type": "paragraph", "text": "8. What is backpropagation and how does it work? What is the difference between backpropagation and reverse-mode autodiff?", "words": [{"w": "8.", "b": [0.1534, 0.7723, 0.1681, 0.7937]}, {"w": "What", "b": [0.1786, 0.7723, 0.225, 0.7937]}, {"w": "is", "b": [0.231, 0.7723, 0.2442, 0.7937]}, {"w": "backpropagation", "b": [0.2501, 0.7723, 0.3908, 0.7937]}, {"w": "and", "b": [0.3967, 0.7723, 0.4282, 0.7937]}, {"w": "how", "b": [0.4342, 0.7723, 0.4702, 0.7937]}, {"w": "does", "b": [0.4761, 0.7723, 0.5142, 0.7937]}, {"w": "it", "b": [0.5202, 0.7723, 0.5321, 0.7937]}, {"w": "work?", "b": [0.538, 0.7723, 0.5889, 0.7937]}, {"w": "What", "b": [0.5948, 0.7723, 0.6413, 0.7937]}, {"w": "is", "b": [0.6472, 0.7723, 0.6604, 0.7937]}, {"w": "the", "b": [0.6664, 0.7723, 0.6927, 0.7937]}, {"w": "difference", "b": [0.6986, 0.7723, 0.782, 0.7937]}, {"w": "between", "b": [0.788, 0.7723, 0.8571, 0.7937]}, {"w": "backpropagation", "b": [0.1786, 0.7914, 0.3192, 0.8128]}, {"w": "and", "b": [0.324, 0.7914, 0.3555, 0.8128]}, {"w": "reverse-mode", "b": [0.3602, 0.7914, 0.4745, 0.8128]}, {"w": "autodiff?", "b": [0.4792, 0.7914, 0.5544, 0.8128]}]}, {"id": "b_14", "type": "paragraph", "text": "9. Can you list all the hyperparameters you can tweak in an MLP? If the MLP over‐ fits the training data, how could you tweak these hyperparameters to try to solve the problem?", "words": [{"w": "9.", "b": [0.1534, 0.8165, 0.1682, 0.8379]}, {"w": "Can", "b": [0.1786, 0.8165, 0.213, 0.8379]}, {"w": "you", "b": [0.2182, 0.8165, 0.2495, 0.8379]}, {"w": "list", "b": [0.2548, 0.8165, 0.2796, 0.8379]}, {"w": "all", "b": [0.2849, 0.8165, 0.3046, 0.8379]}, {"w": "the", "b": [0.3098, 0.8165, 0.3362, 0.8379]}, {"w": "hyperparameters", "b": [0.3414, 0.8165, 0.4826, 0.8379]}, {"w": "you", "b": [0.4879, 0.8165, 0.5191, 0.8379]}, {"w": "can", "b": [0.5244, 0.8165, 0.5537, 0.8379]}, {"w": "tweak", "b": [0.559, 0.8165, 0.608, 0.8379]}, {"w": "in", "b": [0.6132, 0.8165, 0.6302, 0.8379]}, {"w": "an", "b": [0.6355, 0.8165, 0.656, 0.8379]}, {"w": "MLP?", "b": [0.6613, 0.8165, 0.7107, 0.8379]}, {"w": "If", "b": [0.716, 0.8165, 0.7292, 0.8379]}, {"w": "the", "b": [0.7345, 0.8165, 0.7608, 0.8379]}, {"w": "MLP", "b": [0.7661, 0.8165, 0.8076, 0.8379]}, {"w": "over‐", "b": [0.8129, 0.8165, 0.8571, 0.8379]}, {"w": "fits", "b": [0.1786, 0.8355, 0.2043, 0.8569]}, {"w": "the", "b": [0.2099, 0.8355, 0.2362, 0.8569]}, {"w": "training", "b": [0.2418, 0.8355, 0.3087, 0.8569]}, {"w": "data,", "b": [0.3143, 0.8355, 0.3543, 0.8569]}, {"w": "how", "b": [0.3598, 0.8355, 0.3959, 0.8569]}, {"w": "could", "b": [0.4014, 0.8355, 0.4482, 0.8569]}, {"w": "you", "b": [0.4538, 0.8355, 0.485, 0.8569]}, {"w": "tweak", "b": [0.4906, 0.8355, 0.5395, 0.8569]}, {"w": "these", "b": [0.5451, 0.8355, 0.5879, 0.8569]}, {"w": "hyperparameters", "b": [0.5935, 0.8355, 0.7346, 0.8569]}, {"w": "to", "b": [0.7402, 0.8355, 0.7572, 0.8569]}, {"w": "try", "b": [0.7627, 0.8355, 0.787, 0.8569]}, {"w": "to", "b": [0.7926, 0.8355, 0.8095, 0.8569]}, {"w": "solve", "b": [0.8151, 0.8355, 0.8571, 0.8569]}, {"w": "the", "b": [0.1786, 0.8546, 0.2049, 0.876]}, {"w": "problem?", "b": [0.2096, 0.8546, 0.2886, 0.876]}]}, {"id": "b_15", "type": "paragraph", "text": "Exercises | 323", "words": [{"w": "Exercises", "b": [0.7433, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "323", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 350, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "10. Train a deep MLP on the MNIST dataset and see if you can get over 98% preci‐ sion. Try adding all the bells and whistles (i.e., save checkpoints, use early stop‐ ping, plot learning curves using TensorBoard, and so on).", "words": [{"w": "10.", "b": [0.1434, 0.0791, 0.1682, 0.1005]}, {"w": "Train", "b": [0.1786, 0.0791, 0.2235, 0.1005]}, {"w": "a", "b": [0.2296, 0.0791, 0.2387, 0.1005]}, {"w": "deep", "b": [0.2448, 0.0791, 0.2844, 0.1005]}, {"w": "MLP", "b": [0.2905, 0.0791, 0.332, 0.1005]}, {"w": "on", "b": [0.338, 0.0791, 0.3601, 0.1005]}, {"w": "the", "b": [0.3661, 0.0791, 0.3924, 0.1005]}, {"w": "MNIST", "b": [0.3985, 0.0791, 0.4624, 0.1005]}, {"w": "dataset", "b": [0.4684, 0.0791, 0.5265, 0.1005]}, {"w": "and", "b": [0.5326, 0.0791, 0.5641, 0.1005]}, {"w": "see", "b": [0.5702, 0.0791, 0.5955, 0.1005]}, {"w": "if", "b": [0.6016, 0.0791, 0.6133, 0.1005]}, {"w": "you", "b": [0.6194, 0.0791, 0.6506, 0.1005]}, {"w": "can", "b": [0.6567, 0.0791, 0.686, 0.1005]}, {"w": "get", "b": [0.6921, 0.0791, 0.7171, 0.1005]}, {"w": "over", "b": [0.7231, 0.0791, 0.76, 0.1005]}, {"w": "98%", "b": [0.766, 0.0791, 0.8018, 0.1005]}, {"w": "preci‐", "b": [0.8078, 0.0791, 0.8571, 0.1005]}, {"w": "sion.", "b": [0.1786, 0.0981, 0.2186, 0.1195]}, {"w": "Try", "b": [0.225, 0.0981, 0.254, 0.1195]}, {"w": "adding", "b": [0.2604, 0.0981, 0.3182, 0.1195]}, {"w": "all", "b": [0.3246, 0.0981, 0.3443, 0.1195]}, {"w": "the", "b": [0.3507, 0.0981, 0.377, 0.1195]}, {"w": "bells", "b": [0.3834, 0.0981, 0.4211, 0.1195]}, {"w": "and", "b": [0.4274, 0.0981, 0.459, 0.1195]}, {"w": "whistles", "b": [0.4654, 0.0981, 0.5321, 0.1195]}, {"w": "(i.e.,", "b": [0.5385, 0.0981, 0.5744, 0.1195]}, {"w": "save", "b": [0.5808, 0.0981, 0.6157, 0.1195]}, {"w": "checkpoints,", "b": [0.6221, 0.0981, 0.7269, 0.1195]}, {"w": "use", "b": [0.7333, 0.0981, 0.7609, 0.1195]}, {"w": "early", "b": [0.7672, 0.0981, 0.8078, 0.1195]}, {"w": "stop‐", "b": [0.8142, 0.0981, 0.8571, 0.1195]}, {"w": "ping,", "b": [0.1786, 0.1172, 0.221, 0.1386]}, {"w": "plot", "b": [0.2257, 0.1172, 0.2589, 0.1386]}, {"w": "learning", "b": [0.2636, 0.1172, 0.3327, 0.1386]}, {"w": "curves", "b": [0.3374, 0.1172, 0.3918, 0.1386]}, {"w": "using", "b": [0.3965, 0.1172, 0.442, 0.1386]}, {"w": "TensorBoard,", "b": [0.4467, 0.1172, 0.5597, 0.1386]}, {"w": "and", "b": [0.5644, 0.1172, 0.5959, 0.1386]}, {"w": "so", "b": [0.6007, 0.1172, 0.6189, 0.1386]}, {"w": "on).", "b": [0.6237, 0.1172, 0.6576, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "Solutions to these exercises are available in ???.", "words": [{"w": "Solutions", "b": [0.1429, 0.1513, 0.2213, 0.1727]}, {"w": "to", "b": [0.226, 0.1513, 0.243, 0.1727]}, {"w": "these", "b": [0.2477, 0.1513, 0.2906, 0.1727]}, {"w": "exercises", "b": [0.2953, 0.1513, 0.3691, 0.1727]}, {"w": "are", "b": [0.3738, 0.1513, 0.3996, 0.1727]}, {"w": "available", "b": [0.4043, 0.1513, 0.4766, 0.1727]}, {"w": "in", "b": [0.4813, 0.1513, 0.4983, 0.1727]}, {"w": "???.", "b": [0.503, 0.1513, 0.5314, 0.1727]}]}, {"id": "b_2", "type": "paragraph", "text": "324 | Chapter 10: Introduction to Artificial Neural Networks with Keras", "words": [{"w": "324", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "10:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Introduction", "b": [0.2745, 0.9225, 0.3483, 0.9388]}, {"w": "to", "b": [0.3511, 0.9225, 0.3635, 0.9388]}, {"w": "Artificial", "b": [0.3664, 0.9225, 0.4162, 0.9388]}, {"w": "Neural", "b": [0.4191, 0.9225, 0.4583, 0.9388]}, {"w": "Networks", "b": [0.4611, 0.9225, 0.5172, 0.9388]}, {"w": "with", "b": [0.52, 0.9225, 0.5472, 0.9388]}, {"w": "Keras", "b": [0.55, 0.9225, 0.5822, 0.9388]}]}]}, {"page": 351, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "CHAPTER 11 Training Deep Neural Networks", "words": [{"w": "CHAPTER", "b": [0.7262, 0.1146, 0.8246, 0.1451]}, {"w": "11", "b": [0.8299, 0.1146, 0.8571, 0.1451]}, {"w": "Training", "b": [0.3446, 0.1478, 0.4821, 0.1935]}, {"w": "Deep", "b": [0.49, 0.1478, 0.5742, 0.1935]}, {"w": "Neural", "b": [0.5821, 0.1478, 0.6919, 0.1935]}, {"w": "Networks", "b": [0.6998, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_1", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 11 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.3643, 0.3102, 0.3839]}, {"w": "Early", "b": [0.3165, 0.3643, 0.3563, 0.3839]}, {"w": "Release", "b": [0.3626, 0.3643, 0.4189, 0.3839]}, {"w": "ebooks,", "b": [0.4251, 0.3643, 0.4831, 0.3839]}, {"w": "you", "b": [0.4894, 0.3643, 0.518, 0.3839]}, {"w": "get", "b": [0.5243, 0.3643, 0.5471, 0.3839]}, {"w": "books", "b": [0.5534, 0.3643, 0.5989, 0.3839]}, {"w": "in", "b": [0.6052, 0.3643, 0.6207, 0.3839]}, {"w": "their", "b": [0.627, 0.3643, 0.6632, 0.3839]}, {"w": "earliest", "b": [0.6695, 0.3643, 0.7239, 0.3839]}, {"w": "form—", "b": [0.7301, 0.3643, 0.7857, 0.3839]}, {"w": "the", "b": [0.2714, 0.3818, 0.2955, 0.4013]}, {"w": "author’s", "b": [0.3012, 0.3818, 0.3615, 0.4013]}, {"w": "raw", "b": [0.3672, 0.3818, 0.3954, 0.4013]}, {"w": "and", "b": [0.4011, 0.3818, 0.4299, 0.4013]}, {"w": "unedited", "b": [0.4357, 0.3818, 0.5034, 0.4013]}, {"w": "content", "b": [0.5091, 0.3818, 0.5667, 0.4013]}, {"w": "as", "b": [0.5725, 0.3818, 0.5878, 0.4013]}, {"w": "he", "b": [0.5935, 0.3818, 0.6118, 0.4013]}, {"w": "or", "b": [0.6175, 0.3818, 0.6343, 0.4013]}, {"w": "she", "b": [0.6401, 0.3818, 0.6653, 0.4013]}, {"w": "writes—so", "b": [0.671, 0.3818, 0.7514, 0.4013]}, {"w": "you", "b": [0.7571, 0.3818, 0.7857, 0.4013]}, {"w": "can", "b": [0.2714, 0.3992, 0.2982, 0.4188]}, {"w": "take", "b": [0.306, 0.3992, 0.3377, 0.4188]}, {"w": "advantage", "b": [0.3455, 0.3992, 0.4223, 0.4188]}, {"w": "of", "b": [0.4301, 0.3992, 0.4454, 0.4188]}, {"w": "these", "b": [0.4532, 0.3992, 0.4923, 0.4188]}, {"w": "technologies", "b": [0.5001, 0.3992, 0.596, 0.4188]}, {"w": "long", "b": [0.6038, 0.3992, 0.6376, 0.4188]}, {"w": "before", "b": [0.6454, 0.3992, 0.6937, 0.4188]}, {"w": "the", "b": [0.7014, 0.3992, 0.7255, 0.4188]}, {"w": "official", "b": [0.7333, 0.3992, 0.7857, 0.4188]}, {"w": "release", "b": [0.2714, 0.4166, 0.3229, 0.4362]}, {"w": "of", "b": [0.3284, 0.4166, 0.3437, 0.4362]}, {"w": "these", "b": [0.3492, 0.4166, 0.3884, 0.4362]}, {"w": "titles.", "b": [0.3938, 0.4166, 0.4348, 0.4362]}, {"w": "The", "b": [0.4403, 0.4166, 0.4703, 0.4362]}, {"w": "following", "b": [0.4757, 0.4166, 0.5479, 0.4362]}, {"w": "will", "b": [0.5534, 0.4166, 0.5812, 0.4362]}, {"w": "be", "b": [0.5866, 0.4166, 0.6044, 0.4362]}, {"w": "Chapter", "b": [0.6099, 0.4166, 0.6717, 0.4362]}, {"w": "11", "b": [0.6771, 0.4166, 0.6954, 0.4362]}, {"w": "in", "b": [0.7009, 0.4166, 0.7164, 0.4362]}, {"w": "the", "b": [0.7218, 0.4166, 0.7459, 0.4362]}, {"w": "final", "b": [0.7514, 0.4166, 0.7857, 0.4362]}, {"w": "release", "b": [0.2714, 0.434, 0.3229, 0.4536]}, {"w": "of", "b": [0.3273, 0.434, 0.3426, 0.4536]}, {"w": "the", "b": [0.3469, 0.434, 0.371, 0.4536]}, {"w": "book.", "b": [0.3753, 0.434, 0.4182, 0.4536]}]}, {"id": "b_2", "type": "paragraph", "text": "In Chapter 10 we introduced artificial neural networks and trained our first deep neural networks. But they were very shallow nets, with just a few hidden layers. What if you need to tackle a very complex problem, such as detecting hundreds of types of objects in high-resolution images? You may need to train a much deeper DNN, per‐ haps with 10 layers or much more, each containing hundreds of neurons, connected by hundreds of thousands of connections. This would not be a walk in the park:", "words": [{"w": "In", "b": [0.1429, 0.4739, 0.1614, 0.4953]}, {"w": "Chapter", "b": [0.1696, 0.4739, 0.2372, 0.4953]}, {"w": "10", "b": [0.2454, 0.4739, 0.2654, 0.4953]}, {"w": "we", "b": [0.2737, 0.4739, 0.2968, 0.4953]}, {"w": "introduced", "b": [0.305, 0.4739, 0.397, 0.4953]}, {"w": "artificial", "b": [0.4053, 0.4739, 0.4747, 0.4953]}, {"w": "neural", "b": [0.4829, 0.4739, 0.5364, 0.4953]}, {"w": "networks", "b": [0.5446, 0.4739, 0.6218, 0.4953]}, {"w": "and", "b": [0.6301, 0.4739, 0.6616, 0.4953]}, {"w": "trained", "b": [0.6698, 0.4739, 0.7299, 0.4953]}, {"w": "our", "b": [0.7381, 0.4739, 0.7676, 0.4953]}, {"w": "first", "b": [0.7758, 0.4739, 0.8093, 0.4953]}, {"w": "deep", "b": [0.8175, 0.4739, 0.8571, 0.4953]}, {"w": "neural", "b": [0.1428, 0.4929, 0.1963, 0.5143]}, {"w": "networks.", "b": [0.2014, 0.4929, 0.2833, 0.5143]}, {"w": "But", "b": [0.2884, 0.4929, 0.318, 0.5143]}, {"w": "they", "b": [0.3231, 0.4929, 0.359, 0.5143]}, {"w": "were", "b": [0.364, 0.4929, 0.4037, 0.5143]}, {"w": "very", "b": [0.4088, 0.4929, 0.4452, 0.5143]}, {"w": "shallow", "b": [0.4502, 0.4929, 0.5136, 0.5143]}, {"w": "nets,", "b": [0.5186, 0.4929, 0.5576, 0.5143]}, {"w": "with", "b": [0.5627, 0.4929, 0.6, 0.5143]}, {"w": "just", "b": [0.6051, 0.4929, 0.6355, 0.5143]}, {"w": "a", "b": [0.6405, 0.4929, 0.6496, 0.5143]}, {"w": "few", "b": [0.6547, 0.4929, 0.684, 0.5143]}, {"w": "hidden", "b": [0.689, 0.4929, 0.748, 0.5143]}, {"w": "layers.", "b": [0.753, 0.4929, 0.8056, 0.5143]}, {"w": "What", "b": [0.8107, 0.4929, 0.8571, 0.5143]}, {"w": "if", "b": [0.1429, 0.512, 0.1546, 0.5334]}, {"w": "you", "b": [0.1602, 0.512, 0.1915, 0.5334]}, {"w": "need", "b": [0.1971, 0.512, 0.2372, 0.5334]}, {"w": "to", "b": [0.2428, 0.512, 0.2598, 0.5334]}, {"w": "tackle", "b": [0.2654, 0.512, 0.3142, 0.5334]}, {"w": "a", "b": [0.3198, 0.512, 0.329, 0.5334]}, {"w": "very", "b": [0.3346, 0.512, 0.371, 0.5334]}, {"w": "complex", "b": [0.3766, 0.512, 0.4476, 0.5334]}, {"w": "problem,", "b": [0.4532, 0.512, 0.529, 0.5334]}, {"w": "such", "b": [0.5347, 0.512, 0.5733, 0.5334]}, {"w": "as", "b": [0.5789, 0.512, 0.5957, 0.5334]}, {"w": "detecting", "b": [0.6014, 0.512, 0.6783, 0.5334]}, {"w": "hundreds", "b": [0.6839, 0.512, 0.7634, 0.5334]}, {"w": "of", "b": [0.769, 0.512, 0.7858, 0.5334]}, {"w": "types", "b": [0.7914, 0.512, 0.8347, 0.5334]}, {"w": "of", "b": [0.8404, 0.512, 0.8571, 0.5334]}, {"w": "objects", "b": [0.1429, 0.531, 0.2011, 0.5524]}, {"w": "in", "b": [0.2071, 0.531, 0.2241, 0.5524]}, {"w": "high-resolution", "b": [0.2302, 0.531, 0.3603, 0.5524]}, {"w": "images?", "b": [0.3664, 0.531, 0.4324, 0.5524]}, {"w": "You", "b": [0.4384, 0.531, 0.4708, 0.5524]}, {"w": "may", "b": [0.4769, 0.531, 0.5123, 0.5524]}, {"w": "need", "b": [0.5183, 0.531, 0.5585, 0.5524]}, {"w": "to", "b": [0.5645, 0.531, 0.5815, 0.5524]}, {"w": "train", "b": [0.5876, 0.531, 0.6278, 0.5524]}, {"w": "a", "b": [0.6339, 0.531, 0.643, 0.5524]}, {"w": "much", "b": [0.6491, 0.531, 0.6968, 0.5524]}, {"w": "deeper", "b": [0.7028, 0.531, 0.759, 0.5524]}, {"w": "DNN,", "b": [0.7651, 0.531, 0.8161, 0.5524]}, {"w": "per‐", "b": [0.8222, 0.531, 0.8571, 0.5524]}, {"w": "haps", "b": [0.1429, 0.5501, 0.1813, 0.5715]}, {"w": "with", "b": [0.1873, 0.5501, 0.2246, 0.5715]}, {"w": "10", "b": [0.2307, 0.5501, 0.2507, 0.5715]}, {"w": "layers", "b": [0.2567, 0.5501, 0.3045, 0.5715]}, {"w": "or", "b": [0.3106, 0.5501, 0.3289, 0.5715]}, {"w": "much", "b": [0.3349, 0.5501, 0.3826, 0.5715]}, {"w": "more,", "b": [0.3886, 0.5501, 0.4376, 0.5715]}, {"w": "each", "b": [0.4437, 0.5501, 0.4816, 0.5715]}, {"w": "containing", "b": [0.4876, 0.5501, 0.5773, 0.5715]}, {"w": "hundreds", "b": [0.5833, 0.5501, 0.6627, 0.5715]}, {"w": "of", "b": [0.6687, 0.5501, 0.6855, 0.5715]}, {"w": "neurons,", "b": [0.6915, 0.5501, 0.765, 0.5715]}, {"w": "connected", "b": [0.771, 0.5501, 0.8571, 0.5715]}, {"w": "by", "b": [0.1429, 0.5691, 0.163, 0.5905]}, {"w": "hundreds", "b": [0.1677, 0.5691, 0.2472, 0.5905]}, {"w": "of", "b": [0.2519, 0.5691, 0.2687, 0.5905]}, {"w": "thousands", "b": [0.2734, 0.5691, 0.3594, 0.5905]}, {"w": "of", "b": [0.3641, 0.5691, 0.3809, 0.5905]}, {"w": "connections.", "b": [0.3857, 0.5691, 0.4919, 0.5905]}, {"w": "This", "b": [0.4966, 0.5691, 0.5338, 0.5905]}, {"w": "would", "b": [0.5386, 0.5691, 0.5908, 0.5905]}, {"w": "not", "b": [0.5955, 0.5691, 0.6239, 0.5905]}, {"w": "be", "b": [0.6286, 0.5691, 0.6481, 0.5905]}, {"w": "a", "b": [0.6528, 0.5691, 0.6619, 0.5905]}, {"w": "walk", "b": [0.6667, 0.5691, 0.7057, 0.5905]}, {"w": "in", "b": [0.7104, 0.5691, 0.7274, 0.5905]}, {"w": "the", "b": [0.7321, 0.5691, 0.7585, 0.5905]}, {"w": "park:", "b": [0.7632, 0.5691, 0.8061, 0.5905]}]}, {"id": "b_3", "type": "paragraph", "text": "• First, you would be faced with the tricky vanishing gradients problem (or the related exploding gradients problem) that affects deep neural networks and makes lower layers very hard to train.", "words": [{"w": "•", "b": [0.16, 0.6033, 0.1682, 0.6247]}, {"w": "First,", "b": [0.1786, 0.6033, 0.2216, 0.6247]}, {"w": "you", "b": [0.2301, 0.6033, 0.2614, 0.6247]}, {"w": "would", "b": [0.2698, 0.6033, 0.322, 0.6247]}, {"w": "be", "b": [0.3305, 0.6033, 0.3499, 0.6247]}, {"w": "faced", "b": [0.3584, 0.6033, 0.4024, 0.6247]}, {"w": "with", "b": [0.4108, 0.6033, 0.4482, 0.6247]}, {"w": "the", "b": [0.4566, 0.6033, 0.483, 0.6247]}, {"w": "tricky", "b": [0.4914, 0.6033, 0.5398, 0.6247]}, {"w": "vanishing", "b": [0.5482, 0.6031, 0.6259, 0.6247]}, {"w": "gradients", "b": [0.6344, 0.6031, 0.7088, 0.6247]}, {"w": "problem", "b": [0.7173, 0.6033, 0.7883, 0.6247]}, {"w": "(or", "b": [0.7968, 0.6033, 0.8223, 0.6247]}, {"w": "the", "b": [0.8308, 0.6033, 0.8571, 0.6247]}, {"w": "related", "b": [0.1786, 0.6223, 0.2354, 0.6437]}, {"w": "exploding", "b": [0.2404, 0.6221, 0.3186, 0.6437]}, {"w": "gradients", "b": [0.3234, 0.6221, 0.3978, 0.6437]}, {"w": "problem)", "b": [0.4032, 0.6223, 0.4814, 0.6437]}, {"w": "that", "b": [0.4864, 0.6223, 0.519, 0.6437]}, {"w": "affects", "b": [0.524, 0.6223, 0.5772, 0.6437]}, {"w": "deep", "b": [0.5822, 0.6223, 0.6218, 0.6437]}, {"w": "neural", "b": [0.6268, 0.6223, 0.6803, 0.6437]}, {"w": "networks", "b": [0.6853, 0.6223, 0.7625, 0.6437]}, {"w": "and", "b": [0.7675, 0.6223, 0.7991, 0.6437]}, {"w": "makes", "b": [0.8041, 0.6223, 0.8571, 0.6437]}, {"w": "lower", "b": [0.1786, 0.6414, 0.2253, 0.6628]}, {"w": "layers", "b": [0.23, 0.6414, 0.2779, 0.6628]}, {"w": "very", "b": [0.2826, 0.6414, 0.319, 0.6628]}, {"w": "hard", "b": [0.3237, 0.6414, 0.3627, 0.6628]}, {"w": "to", "b": [0.3675, 0.6414, 0.3844, 0.6628]}, {"w": "train.", "b": [0.3892, 0.6414, 0.4341, 0.6628]}]}, {"id": "b_4", "type": "paragraph", "text": "• Second, you might not have enough training data for such a large network, or it might be too costly to label.", "words": [{"w": "•", "b": [0.16, 0.6665, 0.1682, 0.6879]}, {"w": "Second,", "b": [0.1786, 0.6665, 0.2439, 0.6879]}, {"w": "you", "b": [0.2498, 0.6665, 0.2811, 0.6879]}, {"w": "might", "b": [0.287, 0.6665, 0.3365, 0.6879]}, {"w": "not", "b": [0.3424, 0.6665, 0.3708, 0.6879]}, {"w": "have", "b": [0.3767, 0.6665, 0.4151, 0.6879]}, {"w": "enough", "b": [0.4211, 0.6665, 0.4839, 0.6879]}, {"w": "training", "b": [0.4898, 0.6665, 0.5567, 0.6879]}, {"w": "data", "b": [0.5627, 0.6665, 0.5979, 0.6879]}, {"w": "for", "b": [0.6039, 0.6665, 0.6284, 0.6879]}, {"w": "such", "b": [0.6343, 0.6665, 0.673, 0.6879]}, {"w": "a", "b": [0.6789, 0.6665, 0.688, 0.6879]}, {"w": "large", "b": [0.694, 0.6665, 0.7347, 0.6879]}, {"w": "network,", "b": [0.7407, 0.6665, 0.815, 0.6879]}, {"w": "or", "b": [0.8209, 0.6665, 0.8393, 0.6879]}, {"w": "it", "b": [0.8452, 0.6665, 0.8571, 0.6879]}, {"w": "might", "b": [0.1786, 0.6855, 0.2281, 0.7069]}, {"w": "be", "b": [0.2328, 0.6855, 0.2522, 0.7069]}, {"w": "too", "b": [0.2569, 0.6855, 0.2846, 0.7069]}, {"w": "costly", "b": [0.2893, 0.6855, 0.3376, 0.7069]}, {"w": "to", "b": [0.3423, 0.6855, 0.3593, 0.7069]}, {"w": "label.", "b": [0.364, 0.6855, 0.4079, 0.7069]}]}, {"id": "b_5", "type": "paragraph", "text": "• Third, training may be extremely slow.", "words": [{"w": "•", "b": [0.16, 0.7106, 0.1682, 0.732]}, {"w": "Third,", "b": [0.1786, 0.7106, 0.2316, 0.732]}, {"w": "training", "b": [0.2363, 0.7106, 0.3033, 0.732]}, {"w": "may", "b": [0.308, 0.7106, 0.3434, 0.732]}, {"w": "be", "b": [0.3481, 0.7106, 0.3676, 0.732]}, {"w": "extremely", "b": [0.3723, 0.7106, 0.4547, 0.732]}, {"w": "slow.", "b": [0.4594, 0.7106, 0.5004, 0.732]}]}, {"id": "b_6", "type": "paragraph", "text": "• Fourth, a model with millions of parameters would severely risk overfitting the training set, especially if there are not enough training instances, or they are too noisy.", "words": [{"w": "•", "b": [0.16, 0.7357, 0.1682, 0.7571]}, {"w": "Fourth,", "b": [0.1786, 0.7357, 0.2408, 0.7571]}, {"w": "a", "b": [0.2476, 0.7357, 0.2567, 0.7571]}, {"w": "model", "b": [0.2634, 0.7357, 0.3163, 0.7571]}, {"w": "with", "b": [0.323, 0.7357, 0.3603, 0.7571]}, {"w": "millions", "b": [0.367, 0.7357, 0.4355, 0.7571]}, {"w": "of", "b": [0.4422, 0.7357, 0.459, 0.7571]}, {"w": "parameters", "b": [0.4657, 0.7357, 0.5592, 0.7571]}, {"w": "would", "b": [0.5659, 0.7357, 0.6181, 0.7571]}, {"w": "severely", "b": [0.6249, 0.7357, 0.6913, 0.7571]}, {"w": "risk", "b": [0.698, 0.7357, 0.7293, 0.7571]}, {"w": "overfitting", "b": [0.736, 0.7357, 0.8241, 0.7571]}, {"w": "the", "b": [0.8308, 0.7357, 0.8571, 0.7571]}, {"w": "training", "b": [0.1786, 0.7548, 0.2455, 0.7762]}, {"w": "set,", "b": [0.2514, 0.7548, 0.279, 0.7762]}, {"w": "especially", "b": [0.2849, 0.7548, 0.3648, 0.7762]}, {"w": "if", "b": [0.3707, 0.7548, 0.3824, 0.7762]}, {"w": "there", "b": [0.3883, 0.7548, 0.4312, 0.7762]}, {"w": "are", "b": [0.4371, 0.7548, 0.4628, 0.7762]}, {"w": "not", "b": [0.4687, 0.7548, 0.4971, 0.7762]}, {"w": "enough", "b": [0.503, 0.7548, 0.5658, 0.7762]}, {"w": "training", "b": [0.5716, 0.7548, 0.6386, 0.7762]}, {"w": "instances,", "b": [0.6445, 0.7548, 0.726, 0.7762]}, {"w": "or", "b": [0.7319, 0.7548, 0.7503, 0.7762]}, {"w": "they", "b": [0.7562, 0.7548, 0.7921, 0.7762]}, {"w": "are", "b": [0.7979, 0.7548, 0.8237, 0.7762]}, {"w": "too", "b": [0.8295, 0.7548, 0.8571, 0.7762]}, {"w": "noisy.", "b": [0.1786, 0.7738, 0.2266, 0.7952]}]}, {"id": "b_7", "type": "paragraph", "text": "In this chapter, we will go through each of these problems in turn and present techni‐ ques to solve them. We will start by explaining the vanishing gradients problem and exploring some of the most popular solutions to this problem. Next, we will look at transfer learning and unsupervised pretraining, which can help you tackle complex", "words": [{"w": "In", "b": [0.1429, 0.808, 0.1614, 0.8294]}, {"w": "this", "b": [0.1664, 0.808, 0.1971, 0.8294]}, {"w": "chapter,", "b": [0.2021, 0.808, 0.2681, 0.8294]}, {"w": "we", "b": [0.2731, 0.808, 0.2962, 0.8294]}, {"w": "will", "b": [0.3012, 0.808, 0.3316, 0.8294]}, {"w": "go", "b": [0.3366, 0.808, 0.357, 0.8294]}, {"w": "through", "b": [0.362, 0.808, 0.4298, 0.8294]}, {"w": "each", "b": [0.4348, 0.808, 0.4728, 0.8294]}, {"w": "of", "b": [0.4778, 0.808, 0.4946, 0.8294]}, {"w": "these", "b": [0.4996, 0.808, 0.5424, 0.8294]}, {"w": "problems", "b": [0.5474, 0.808, 0.6261, 0.8294]}, {"w": "in", "b": [0.6311, 0.808, 0.6481, 0.8294]}, {"w": "turn", "b": [0.6531, 0.808, 0.6897, 0.8294]}, {"w": "and", "b": [0.6947, 0.808, 0.7262, 0.8294]}, {"w": "present", "b": [0.7312, 0.808, 0.7926, 0.8294]}, {"w": "techni‐", "b": [0.7976, 0.808, 0.8571, 0.8294]}, {"w": "ques", "b": [0.1428, 0.827, 0.1811, 0.8484]}, {"w": "to", "b": [0.1871, 0.827, 0.2041, 0.8484]}, {"w": "solve", "b": [0.2102, 0.827, 0.2522, 0.8484]}, {"w": "them.", "b": [0.2583, 0.827, 0.3065, 0.8484]}, {"w": "We", "b": [0.3126, 0.827, 0.3396, 0.8484]}, {"w": "will", "b": [0.3457, 0.827, 0.3761, 0.8484]}, {"w": "start", "b": [0.3822, 0.827, 0.4194, 0.8484]}, {"w": "by", "b": [0.4255, 0.827, 0.4456, 0.8484]}, {"w": "explaining", "b": [0.4517, 0.827, 0.5395, 0.8484]}, {"w": "the", "b": [0.5455, 0.827, 0.5719, 0.8484]}, {"w": "vanishing", "b": [0.578, 0.827, 0.6592, 0.8484]}, {"w": "gradients", "b": [0.6653, 0.827, 0.7424, 0.8484]}, {"w": "problem", "b": [0.7485, 0.827, 0.8195, 0.8484]}, {"w": "and", "b": [0.8256, 0.827, 0.8571, 0.8484]}, {"w": "exploring", "b": [0.1429, 0.8461, 0.2228, 0.8675]}, {"w": "some", "b": [0.2292, 0.8461, 0.2734, 0.8675]}, {"w": "of", "b": [0.2798, 0.8461, 0.2966, 0.8675]}, {"w": "the", "b": [0.303, 0.8461, 0.3294, 0.8675]}, {"w": "most", "b": [0.3358, 0.8461, 0.3775, 0.8675]}, {"w": "popular", "b": [0.3839, 0.8461, 0.4495, 0.8675]}, {"w": "solutions", "b": [0.4559, 0.8461, 0.5322, 0.8675]}, {"w": "to", "b": [0.5386, 0.8461, 0.5555, 0.8675]}, {"w": "this", "b": [0.562, 0.8461, 0.5927, 0.8675]}, {"w": "problem.", "b": [0.5991, 0.8461, 0.6749, 0.8675]}, {"w": "Next,", "b": [0.6813, 0.8461, 0.726, 0.8675]}, {"w": "we", "b": [0.7324, 0.8461, 0.7556, 0.8675]}, {"w": "will", "b": [0.762, 0.8461, 0.7924, 0.8675]}, {"w": "look", "b": [0.7988, 0.8461, 0.8356, 0.8675]}, {"w": "at", "b": [0.842, 0.8461, 0.8571, 0.8675]}, {"w": "transfer", "b": [0.1429, 0.8651, 0.2079, 0.8865]}, {"w": "learning", "b": [0.2149, 0.8651, 0.284, 0.8865]}, {"w": "and", "b": [0.291, 0.8651, 0.3225, 0.8865]}, {"w": "unsupervised", "b": [0.3295, 0.8651, 0.4415, 0.8865]}, {"w": "pretraining,", "b": [0.4485, 0.8651, 0.5477, 0.8865]}, {"w": "which", "b": [0.5547, 0.8651, 0.6056, 0.8865]}, {"w": "can", "b": [0.6126, 0.8651, 0.642, 0.8865]}, {"w": "help", "b": [0.649, 0.8651, 0.6852, 0.8865]}, {"w": "you", "b": [0.6921, 0.8651, 0.7234, 0.8865]}, {"w": "tackle", "b": [0.7304, 0.8651, 0.7792, 0.8865]}, {"w": "complex", "b": [0.7862, 0.8651, 0.8571, 0.8865]}]}, {"id": "b_8", "type": "paragraph", "text": "325", "words": [{"w": "325", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 352, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 “Understanding the Difficulty of Training Deep Feedforward Neural Networks,” X. Glorot, Y Bengio (2010).", "words": [{"w": "1", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Understanding", "b": [0.1587, 0.8749, 0.2608, 0.8912]}, {"w": "the", "b": [0.2644, 0.8749, 0.2845, 0.8912]}, {"w": "Difficulty", "b": [0.2881, 0.8749, 0.3489, 0.8912]}, {"w": "of", "b": [0.3525, 0.8749, 0.3653, 0.8912]}, {"w": "Training", "b": [0.3689, 0.8749, 0.4236, 0.8912]}, {"w": "Deep", "b": [0.4272, 0.8749, 0.4607, 0.8912]}, {"w": "Feedforward", "b": [0.4643, 0.8749, 0.5455, 0.8912]}, {"w": "Neural", "b": [0.5491, 0.8749, 0.5925, 0.8912]}, {"w": "Networks,”", "b": [0.5961, 0.8749, 0.6655, 0.8912]}, {"w": "X.", "b": [0.6691, 0.8749, 0.6831, 0.8912]}, {"w": "Glorot,", "b": [0.6867, 0.8749, 0.7326, 0.8912]}, {"w": "Y", "b": [0.7362, 0.8749, 0.7462, 0.8912]}, {"w": "Bengio", "b": [0.7498, 0.8749, 0.7947, 0.8912]}, {"w": "(2010).", "b": [0.7983, 0.8749, 0.8434, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "tasks even when you have little labeled data. Then we will discuss various optimizers that can speed up training large models tremendously compared to plain Gradient Descent. Finally, we will go through a few popular regularization techniques for large neural networks.", "words": [{"w": "tasks", "b": [0.1429, 0.0791, 0.184, 0.1005]}, {"w": "even", "b": [0.1897, 0.0791, 0.2285, 0.1005]}, {"w": "when", "b": [0.2342, 0.0791, 0.2799, 0.1005]}, {"w": "you", "b": [0.2856, 0.0791, 0.3169, 0.1005]}, {"w": "have", "b": [0.3226, 0.0791, 0.361, 0.1005]}, {"w": "little", "b": [0.3668, 0.0791, 0.4045, 0.1005]}, {"w": "labeled", "b": [0.4102, 0.0791, 0.4692, 0.1005]}, {"w": "data.", "b": [0.475, 0.0791, 0.515, 0.1005]}, {"w": "Then", "b": [0.5207, 0.0791, 0.5649, 0.1005]}, {"w": "we", "b": [0.5707, 0.0791, 0.5938, 0.1005]}, {"w": "will", "b": [0.5996, 0.0791, 0.63, 0.1005]}, {"w": "discuss", "b": [0.6357, 0.0791, 0.6951, 0.1005]}, {"w": "various", "b": [0.7009, 0.0791, 0.7623, 0.1005]}, {"w": "optimizers", "b": [0.768, 0.0791, 0.8571, 0.1005]}, {"w": "that", "b": [0.1429, 0.0981, 0.1754, 0.1195]}, {"w": "can", "b": [0.1829, 0.0981, 0.2122, 0.1195]}, {"w": "speed", "b": [0.2197, 0.0981, 0.267, 0.1195]}, {"w": "up", "b": [0.2744, 0.0981, 0.2964, 0.1195]}, {"w": "training", "b": [0.3038, 0.0981, 0.3708, 0.1195]}, {"w": "large", "b": [0.3782, 0.0981, 0.419, 0.1195]}, {"w": "models", "b": [0.4264, 0.0981, 0.4869, 0.1195]}, {"w": "tremendously", "b": [0.4943, 0.0981, 0.6097, 0.1195]}, {"w": "compared", "b": [0.6172, 0.0981, 0.7009, 0.1195]}, {"w": "to", "b": [0.7084, 0.0981, 0.7254, 0.1195]}, {"w": "plain", "b": [0.7328, 0.0981, 0.7751, 0.1195]}, {"w": "Gradient", "b": [0.7826, 0.0981, 0.8571, 0.1195]}, {"w": "Descent.", "b": [0.1428, 0.1172, 0.2144, 0.1386]}, {"w": "Finally,", "b": [0.2198, 0.1172, 0.2803, 0.1386]}, {"w": "we", "b": [0.2856, 0.1172, 0.3087, 0.1386]}, {"w": "will", "b": [0.3141, 0.1172, 0.3445, 0.1386]}, {"w": "go", "b": [0.3499, 0.1172, 0.3702, 0.1386]}, {"w": "through", "b": [0.3756, 0.1172, 0.4434, 0.1386]}, {"w": "a", "b": [0.4487, 0.1172, 0.4579, 0.1386]}, {"w": "few", "b": [0.4632, 0.1172, 0.4925, 0.1386]}, {"w": "popular", "b": [0.4979, 0.1172, 0.5635, 0.1386]}, {"w": "regularization", "b": [0.5689, 0.1172, 0.6855, 0.1386]}, {"w": "techniques", "b": [0.6908, 0.1172, 0.7812, 0.1386]}, {"w": "for", "b": [0.7865, 0.1172, 0.811, 0.1386]}, {"w": "large", "b": [0.8164, 0.1172, 0.8571, 0.1386]}, {"w": "neural", "b": [0.1429, 0.1362, 0.1963, 0.1576]}, {"w": "networks.", "b": [0.2011, 0.1362, 0.283, 0.1576]}]}, {"id": "b_2", "type": "paragraph", "text": "With these tools, you will be able to train very deep nets: welcome to Deep Learning!", "words": [{"w": "With", "b": [0.1429, 0.1643, 0.1853, 0.1857]}, {"w": "these", "b": [0.19, 0.1643, 0.2329, 0.1857]}, {"w": "tools,", "b": [0.2376, 0.1643, 0.2829, 0.1857]}, {"w": "you", "b": [0.2876, 0.1643, 0.3188, 0.1857]}, {"w": "will", "b": [0.3236, 0.1643, 0.354, 0.1857]}, {"w": "be", "b": [0.3587, 0.1643, 0.3781, 0.1857]}, {"w": "able", "b": [0.3829, 0.1643, 0.4167, 0.1857]}, {"w": "to", "b": [0.4214, 0.1643, 0.4384, 0.1857]}, {"w": "train", "b": [0.4432, 0.1643, 0.4834, 0.1857]}, {"w": "very", "b": [0.4881, 0.1643, 0.5245, 0.1857]}, {"w": "deep", "b": [0.5292, 0.1643, 0.5688, 0.1857]}, {"w": "nets:", "b": [0.5736, 0.1643, 0.6126, 0.1857]}, {"w": "welcome", "b": [0.6173, 0.1643, 0.6911, 0.1857]}, {"w": "to", "b": [0.6958, 0.1643, 0.7128, 0.1857]}, {"w": "Deep", "b": [0.7175, 0.1643, 0.7614, 0.1857]}, {"w": "Learning!", "b": [0.7662, 0.1643, 0.847, 0.1857]}]}, {"id": "b_3", "type": "equation", "text": "Vanishing/Exploding Gradients Problems", "words": [{"w": "Vanishing/Exploding", "b": [0.1429, 0.1987, 0.3996, 0.233]}, {"w": "Gradients", "b": [0.4055, 0.1987, 0.5248, 0.233]}, {"w": "Problems", "b": [0.5307, 0.1987, 0.6473, 0.233]}]}, {"id": "b_4", "type": "paragraph", "text": "As we discussed in Chapter 10, the backpropagation algorithm works by going from the output layer to the input layer, propagating the error gradient on the way. Once the algorithm has computed the gradient of the cost function with regards to each parameter in the network, it uses these gradients to update each parameter with a Gradient Descent step.", "words": [{"w": "As", "b": [0.1429, 0.2399, 0.1649, 0.2613]}, {"w": "we", "b": [0.1709, 0.2399, 0.194, 0.2613]}, {"w": "discussed", "b": [0.1999, 0.2399, 0.2792, 0.2613]}, {"w": "in", "b": [0.2851, 0.2399, 0.3021, 0.2613]}, {"w": "Chapter", "b": [0.3081, 0.2399, 0.3757, 0.2613]}, {"w": "10,", "b": [0.3816, 0.2399, 0.4064, 0.2613]}, {"w": "the", "b": [0.4123, 0.2399, 0.4387, 0.2613]}, {"w": "backpropagation", "b": [0.4446, 0.2399, 0.5853, 0.2613]}, {"w": "algorithm", "b": [0.5912, 0.2399, 0.6739, 0.2613]}, {"w": "works", "b": [0.6798, 0.2399, 0.7304, 0.2613]}, {"w": "by", "b": [0.7364, 0.2399, 0.7565, 0.2613]}, {"w": "going", "b": [0.7625, 0.2399, 0.8096, 0.2613]}, {"w": "from", "b": [0.8156, 0.2399, 0.8571, 0.2613]}, {"w": "the", "b": [0.1429, 0.259, 0.1692, 0.2804]}, {"w": "output", "b": [0.1757, 0.259, 0.2321, 0.2804]}, {"w": "layer", "b": [0.2386, 0.259, 0.2788, 0.2804]}, {"w": "to", "b": [0.2853, 0.259, 0.3023, 0.2804]}, {"w": "the", "b": [0.3088, 0.259, 0.3352, 0.2804]}, {"w": "input", "b": [0.3417, 0.259, 0.3866, 0.2804]}, {"w": "layer,", "b": [0.3931, 0.259, 0.4368, 0.2804]}, {"w": "propagating", "b": [0.4433, 0.259, 0.5442, 0.2804]}, {"w": "the", "b": [0.5507, 0.259, 0.5771, 0.2804]}, {"w": "error", "b": [0.5836, 0.259, 0.6263, 0.2804]}, {"w": "gradient", "b": [0.6328, 0.259, 0.7022, 0.2804]}, {"w": "on", "b": [0.7087, 0.259, 0.7308, 0.2804]}, {"w": "the", "b": [0.7373, 0.259, 0.7636, 0.2804]}, {"w": "way.", "b": [0.7702, 0.259, 0.806, 0.2804]}, {"w": "Once", "b": [0.8125, 0.259, 0.8571, 0.2804]}, {"w": "the", "b": [0.1428, 0.278, 0.1692, 0.2994]}, {"w": "algorithm", "b": [0.1765, 0.278, 0.2592, 0.2994]}, {"w": "has", "b": [0.2665, 0.278, 0.2944, 0.2994]}, {"w": "computed", "b": [0.3017, 0.278, 0.386, 0.2994]}, {"w": "the", "b": [0.3934, 0.278, 0.4197, 0.2994]}, {"w": "gradient", "b": [0.427, 0.278, 0.4964, 0.2994]}, {"w": "of", "b": [0.5038, 0.278, 0.5206, 0.2994]}, {"w": "the", "b": [0.5279, 0.278, 0.5542, 0.2994]}, {"w": "cost", "b": [0.5615, 0.278, 0.595, 0.2994]}, {"w": "function", "b": [0.6023, 0.278, 0.6737, 0.2994]}, {"w": "with", "b": [0.681, 0.278, 0.7184, 0.2994]}, {"w": "regards", "b": [0.7257, 0.278, 0.7876, 0.2994]}, {"w": "to", "b": [0.7949, 0.278, 0.8119, 0.2994]}, {"w": "each", "b": [0.8192, 0.278, 0.8571, 0.2994]}, {"w": "parameter", "b": [0.1429, 0.2971, 0.2287, 0.3185]}, {"w": "in", "b": [0.2363, 0.2971, 0.2533, 0.3185]}, {"w": "the", "b": [0.261, 0.2971, 0.2873, 0.3185]}, {"w": "network,", "b": [0.295, 0.2971, 0.3693, 0.3185]}, {"w": "it", "b": [0.377, 0.2971, 0.3889, 0.3185]}, {"w": "uses", "b": [0.3966, 0.2971, 0.4318, 0.3185]}, {"w": "these", "b": [0.4394, 0.2971, 0.4823, 0.3185]}, {"w": "gradients", "b": [0.4899, 0.2971, 0.567, 0.3185]}, {"w": "to", "b": [0.5747, 0.2971, 0.5917, 0.3185]}, {"w": "update", "b": [0.5993, 0.2971, 0.6563, 0.3185]}, {"w": "each", "b": [0.6639, 0.2971, 0.7019, 0.3185]}, {"w": "parameter", "b": [0.7095, 0.2971, 0.7953, 0.3185]}, {"w": "with", "b": [0.803, 0.2971, 0.8403, 0.3185]}, {"w": "a", "b": [0.848, 0.2971, 0.8571, 0.3185]}, {"w": "Gradient", "b": [0.1429, 0.3161, 0.2174, 0.3375]}, {"w": "Descent", "b": [0.2221, 0.3161, 0.289, 0.3375]}, {"w": "step.", "b": [0.2937, 0.3161, 0.3316, 0.3375]}]}, {"id": "b_5", "type": "paragraph", "text": "Unfortunately, gradients often get smaller and smaller as the algorithm progresses down to the lower layers. As a result, the Gradient Descent update leaves the lower layer connection weights virtually unchanged, and training never converges to a good solution. This is called the vanishing gradients problem. In some cases, the opposite can happen: the gradients can grow bigger and bigger, so many layers get insanely large weight updates and the algorithm diverges. This is the exploding gradients prob‐ lem, which is mostly encountered in recurrent neural networks (see ???). More gener‐ ally, deep neural networks suffer from unstable gradients; different layers may learn at widely different speeds.", "words": [{"w": "Unfortunately,", "b": [0.1429, 0.3442, 0.264, 0.3656]}, {"w": "gradients", "b": [0.2721, 0.3442, 0.3492, 0.3656]}, {"w": "often", "b": [0.3573, 0.3442, 0.4007, 0.3656]}, {"w": "get", "b": [0.4088, 0.3442, 0.4338, 0.3656]}, {"w": "smaller", "b": [0.4419, 0.3442, 0.5028, 0.3656]}, {"w": "and", "b": [0.5109, 0.3442, 0.5425, 0.3656]}, {"w": "smaller", "b": [0.5506, 0.3442, 0.6116, 0.3656]}, {"w": "as", "b": [0.6197, 0.3442, 0.6365, 0.3656]}, {"w": "the", "b": [0.6446, 0.3442, 0.6709, 0.3656]}, {"w": "algorithm", "b": [0.679, 0.3442, 0.7616, 0.3656]}, {"w": "progresses", "b": [0.7697, 0.3442, 0.8571, 0.3656]}, {"w": "down", "b": [0.1429, 0.3633, 0.1901, 0.3847]}, {"w": "to", "b": [0.1969, 0.3633, 0.2139, 0.3847]}, {"w": "the", "b": [0.2207, 0.3633, 0.247, 0.3847]}, {"w": "lower", "b": [0.2537, 0.3633, 0.3005, 0.3847]}, {"w": "layers.", "b": [0.3073, 0.3633, 0.3598, 0.3847]}, {"w": "As", "b": [0.3666, 0.3633, 0.3887, 0.3847]}, {"w": "a", "b": [0.3954, 0.3633, 0.4046, 0.3847]}, {"w": "result,", "b": [0.4113, 0.3633, 0.463, 0.3847]}, {"w": "the", "b": [0.4698, 0.3633, 0.4961, 0.3847]}, {"w": "Gradient", "b": [0.5029, 0.3633, 0.5774, 0.3847]}, {"w": "Descent", "b": [0.5842, 0.3633, 0.651, 0.3847]}, {"w": "update", "b": [0.6578, 0.3633, 0.7147, 0.3847]}, {"w": "leaves", "b": [0.7215, 0.3633, 0.7705, 0.3847]}, {"w": "the", "b": [0.7773, 0.3633, 0.8036, 0.3847]}, {"w": "lower", "b": [0.8104, 0.3633, 0.8571, 0.3847]}, {"w": "layer", "b": [0.1429, 0.3823, 0.1831, 0.4037]}, {"w": "connection", "b": [0.188, 0.3823, 0.2818, 0.4037]}, {"w": "weights", "b": [0.2868, 0.3823, 0.35, 0.4037]}, {"w": "virtually", "b": [0.3549, 0.3823, 0.4245, 0.4037]}, {"w": "unchanged,", "b": [0.4294, 0.3823, 0.5267, 0.4037]}, {"w": "and", "b": [0.5317, 0.3823, 0.5632, 0.4037]}, {"w": "training", "b": [0.5681, 0.3823, 0.6351, 0.4037]}, {"w": "never", "b": [0.64, 0.3823, 0.6865, 0.4037]}, {"w": "converges", "b": [0.6914, 0.3823, 0.7742, 0.4037]}, {"w": "to", "b": [0.7792, 0.3823, 0.7961, 0.4037]}, {"w": "a", "b": [0.8011, 0.3823, 0.8102, 0.4037]}, {"w": "good", "b": [0.8152, 0.3823, 0.8572, 0.4037]}, {"w": "solution.", "b": [0.1429, 0.4014, 0.2162, 0.4228]}, {"w": "This", "b": [0.2229, 0.4014, 0.2601, 0.4228]}, {"w": "is", "b": [0.2668, 0.4014, 0.28, 0.4228]}, {"w": "called", "b": [0.2867, 0.4014, 0.3351, 0.4228]}, {"w": "the", "b": [0.3418, 0.4014, 0.3681, 0.4228]}, {"w": "vanishing", "b": [0.3749, 0.4012, 0.4525, 0.4228]}, {"w": "gradients", "b": [0.4592, 0.4012, 0.5337, 0.4228]}, {"w": "problem.", "b": [0.5404, 0.4014, 0.6162, 0.4228]}, {"w": "In", "b": [0.6229, 0.4014, 0.6414, 0.4228]}, {"w": "some", "b": [0.6481, 0.4014, 0.6923, 0.4228]}, {"w": "cases,", "b": [0.699, 0.4014, 0.7459, 0.4228]}, {"w": "the", "b": [0.7526, 0.4014, 0.7789, 0.4228]}, {"w": "opposite", "b": [0.7856, 0.4014, 0.8571, 0.4228]}, {"w": "can", "b": [0.1429, 0.4204, 0.1722, 0.4418]}, {"w": "happen:", "b": [0.1797, 0.4204, 0.2464, 0.4418]}, {"w": "the", "b": [0.2538, 0.4204, 0.2802, 0.4418]}, {"w": "gradients", "b": [0.2876, 0.4204, 0.3647, 0.4418]}, {"w": "can", "b": [0.3722, 0.4204, 0.4015, 0.4418]}, {"w": "grow", "b": [0.409, 0.4204, 0.4514, 0.4418]}, {"w": "bigger", "b": [0.4588, 0.4204, 0.5111, 0.4418]}, {"w": "and", "b": [0.5185, 0.4204, 0.5501, 0.4418]}, {"w": "bigger,", "b": [0.5575, 0.4204, 0.6132, 0.4418]}, {"w": "so", "b": [0.6207, 0.4204, 0.639, 0.4418]}, {"w": "many", "b": [0.6464, 0.4204, 0.6931, 0.4418]}, {"w": "layers", "b": [0.7006, 0.4204, 0.7484, 0.4418]}, {"w": "get", "b": [0.7559, 0.4204, 0.7808, 0.4418]}, {"w": "insanely", "b": [0.7883, 0.4204, 0.8571, 0.4418]}, {"w": "large", "b": [0.1428, 0.4395, 0.1836, 0.4609]}, {"w": "weight", "b": [0.1888, 0.4395, 0.2443, 0.4609]}, {"w": "updates", "b": [0.2495, 0.4395, 0.3141, 0.4609]}, {"w": "and", "b": [0.3193, 0.4395, 0.3508, 0.4609]}, {"w": "the", "b": [0.356, 0.4395, 0.3824, 0.4609]}, {"w": "algorithm", "b": [0.3876, 0.4395, 0.4702, 0.4609]}, {"w": "diverges.", "b": [0.4754, 0.4395, 0.5492, 0.4609]}, {"w": "This", "b": [0.5544, 0.4395, 0.5916, 0.4609]}, {"w": "is", "b": [0.5968, 0.4395, 0.61, 0.4609]}, {"w": "the", "b": [0.6152, 0.4395, 0.6416, 0.4609]}, {"w": "exploding", "b": [0.6468, 0.4392, 0.725, 0.4609]}, {"w": "gradients", "b": [0.7297, 0.4392, 0.8042, 0.4609]}, {"w": "prob‐", "b": [0.8099, 0.4395, 0.8571, 0.4609]}, {"w": "lem,", "b": [0.1428, 0.4585, 0.1788, 0.4799]}, {"w": "which", "b": [0.1838, 0.4585, 0.2347, 0.4799]}, {"w": "is", "b": [0.2397, 0.4585, 0.2529, 0.4799]}, {"w": "mostly", "b": [0.2579, 0.4585, 0.3144, 0.4799]}, {"w": "encountered", "b": [0.3194, 0.4585, 0.424, 0.4799]}, {"w": "in", "b": [0.429, 0.4585, 0.446, 0.4799]}, {"w": "recurrent", "b": [0.4509, 0.4585, 0.5291, 0.4799]}, {"w": "neural", "b": [0.5341, 0.4585, 0.5875, 0.4799]}, {"w": "networks", "b": [0.5925, 0.4585, 0.6697, 0.4799]}, {"w": "(see", "b": [0.6747, 0.4585, 0.7073, 0.4799]}, {"w": "???).", "b": [0.7123, 0.4585, 0.7479, 0.4799]}, {"w": "More", "b": [0.7527, 0.4585, 0.7979, 0.4799]}, {"w": "gener‐", "b": [0.8026, 0.4585, 0.8566, 0.4799]}, {"w": "ally,", "b": [0.1429, 0.4776, 0.1753, 0.499]}, {"w": "deep", "b": [0.1802, 0.4776, 0.2198, 0.499]}, {"w": "neural", "b": [0.2246, 0.4776, 0.278, 0.499]}, {"w": "networks", "b": [0.2829, 0.4776, 0.3601, 0.499]}, {"w": "suffer", "b": [0.3649, 0.4776, 0.4125, 0.499]}, {"w": "from", "b": [0.4173, 0.4776, 0.4589, 0.499]}, {"w": "unstable", "b": [0.4637, 0.4776, 0.534, 0.499]}, {"w": "gradients;", "b": [0.5388, 0.4776, 0.6207, 0.499]}, {"w": "different", "b": [0.6255, 0.4776, 0.6972, 0.499]}, {"w": "layers", "b": [0.702, 0.4776, 0.7498, 0.499]}, {"w": "may", "b": [0.7546, 0.4776, 0.79, 0.499]}, {"w": "learn", "b": [0.7948, 0.4776, 0.8372, 0.499]}, {"w": "at", "b": [0.842, 0.4776, 0.8571, 0.499]}, {"w": "widely", "b": [0.1429, 0.4966, 0.1974, 0.518]}, {"w": "different", "b": [0.2021, 0.4966, 0.2738, 0.518]}, {"w": "speeds.", "b": [0.2786, 0.4966, 0.3382, 0.518]}]}, {"id": "b_6", "type": "paragraph", "text": "Although this unfortunate behavior has been empirically observed for quite a while (it was one of the reasons why deep neural networks were mostly abandoned for a long time), it is only around 2010 that significant progress was made in understand‐ ing it. A paper titled “Understanding the Difficulty of Training Deep Feedforward Neural Networks” by Xavier Glorot and Yoshua Bengio1 found a few suspects, includ‐ ing the combination of the popular logistic sigmoid activation function and the weight initialization technique that was most popular at the time, namely random ini‐ tialization using a normal distribution with a mean of 0 and a standard deviation of 1. In short, they showed that with this activation function and this initialization scheme, the variance of the outputs of each layer is much greater than the variance of its inputs. Going forward in the network, the variance keeps increasing after each layer until the activation function saturates at the top layers. This is actually made worse by the fact that the logistic function has a mean of 0.5, not 0 (the hyperbolic tangent function has a mean of 0 and behaves slightly better than the logistic function in deep networks).", "words": [{"w": "Although", "b": [0.1429, 0.5247, 0.2226, 0.5461]}, {"w": "this", "b": [0.2292, 0.5247, 0.2599, 0.5461]}, {"w": "unfortunate", "b": [0.2666, 0.5247, 0.3664, 0.5461]}, {"w": "behavior", "b": [0.373, 0.5247, 0.446, 0.5461]}, {"w": "has", "b": [0.4526, 0.5247, 0.4805, 0.5461]}, {"w": "been", "b": [0.4872, 0.5247, 0.5269, 0.5461]}, {"w": "empirically", "b": [0.5336, 0.5247, 0.627, 0.5461]}, {"w": "observed", "b": [0.6336, 0.5247, 0.7092, 0.5461]}, {"w": "for", "b": [0.7159, 0.5247, 0.7404, 0.5461]}, {"w": "quite", "b": [0.747, 0.5247, 0.7895, 0.5461]}, {"w": "a", "b": [0.7962, 0.5247, 0.8054, 0.5461]}, {"w": "while", "b": [0.812, 0.5247, 0.8571, 0.5461]}, {"w": "(it", "b": [0.1429, 0.5438, 0.162, 0.5652]}, {"w": "was", "b": [0.1691, 0.5438, 0.2001, 0.5652]}, {"w": "one", "b": [0.2072, 0.5438, 0.2381, 0.5652]}, {"w": "of", "b": [0.2452, 0.5438, 0.262, 0.5652]}, {"w": "the", "b": [0.2691, 0.5438, 0.2954, 0.5652]}, {"w": "reasons", "b": [0.3025, 0.5438, 0.3655, 0.5652]}, {"w": "why", "b": [0.3726, 0.5438, 0.4071, 0.5652]}, {"w": "deep", "b": [0.4142, 0.5438, 0.4538, 0.5652]}, {"w": "neural", "b": [0.4609, 0.5438, 0.5144, 0.5652]}, {"w": "networks", "b": [0.5214, 0.5438, 0.5987, 0.5652]}, {"w": "were", "b": [0.6057, 0.5438, 0.6455, 0.5652]}, {"w": "mostly", "b": [0.6525, 0.5438, 0.7091, 0.5652]}, {"w": "abandoned", "b": [0.7161, 0.5438, 0.8093, 0.5652]}, {"w": "for", "b": [0.8164, 0.5438, 0.8409, 0.5652]}, {"w": "a", "b": [0.848, 0.5438, 0.8571, 0.5652]}, {"w": "long", "b": [0.1429, 0.5628, 0.1799, 0.5842]}, {"w": "time),", "b": [0.1858, 0.5628, 0.2356, 0.5842]}, {"w": "it", "b": [0.2415, 0.5628, 0.2535, 0.5842]}, {"w": "is", "b": [0.2594, 0.5628, 0.2726, 0.5842]}, {"w": "only", "b": [0.2785, 0.5628, 0.3154, 0.5842]}, {"w": "around", "b": [0.3213, 0.5628, 0.3823, 0.5842]}, {"w": "2010", "b": [0.3882, 0.5628, 0.4282, 0.5842]}, {"w": "that", "b": [0.4341, 0.5628, 0.4667, 0.5842]}, {"w": "significant", "b": [0.4726, 0.5628, 0.5596, 0.5842]}, {"w": "progress", "b": [0.5655, 0.5628, 0.6364, 0.5842]}, {"w": "was", "b": [0.6423, 0.5628, 0.6734, 0.5842]}, {"w": "made", "b": [0.6793, 0.5628, 0.7253, 0.5842]}, {"w": "in", "b": [0.7313, 0.5628, 0.7482, 0.5842]}, {"w": "understand‐", "b": [0.7542, 0.5628, 0.8572, 0.5842]}, {"w": "ing", "b": [0.1429, 0.5819, 0.1696, 0.6033]}, {"w": "it.", "b": [0.1775, 0.5819, 0.1942, 0.6033]}, {"w": "A", "b": [0.202, 0.5819, 0.2164, 0.6033]}, {"w": "paper", "b": [0.2243, 0.5819, 0.2715, 0.6033]}, {"w": "titled", "b": [0.2794, 0.5819, 0.3228, 0.6033]}, {"w": "“Understanding", "b": [0.3306, 0.5819, 0.4646, 0.6033]}, {"w": "the", "b": [0.4725, 0.5819, 0.4988, 0.6033]}, {"w": "Difficulty", "b": [0.5067, 0.5819, 0.5866, 0.6033]}, {"w": "of", "b": [0.5945, 0.5819, 0.6113, 0.6033]}, {"w": "Training", "b": [0.6191, 0.5819, 0.6908, 0.6033]}, {"w": "Deep", "b": [0.6987, 0.5819, 0.7427, 0.6033]}, {"w": "Feedforward", "b": [0.7505, 0.5819, 0.8571, 0.6033]}, {"w": "Neural", "b": [0.1429, 0.6009, 0.1999, 0.6223]}, {"w": "Networks”", "b": [0.2046, 0.6009, 0.2929, 0.6223]}, {"w": "by", "b": [0.2982, 0.6009, 0.3183, 0.6223]}, {"w": "Xavier", "b": [0.3234, 0.6009, 0.3776, 0.6223]}, {"w": "Glorot", "b": [0.3826, 0.6009, 0.4381, 0.6223]}, {"w": "and", "b": [0.4431, 0.6009, 0.4746, 0.6223]}, {"w": "Yoshua", "b": [0.4797, 0.6009, 0.5395, 0.6223]}, {"w": "Bengio1", "b": [0.5445, 0.6009, 0.6091, 0.6223]}, {"w": "found", "b": [0.6142, 0.6009, 0.6644, 0.6223]}, {"w": "a", "b": [0.6694, 0.6009, 0.6786, 0.6223]}, {"w": "few", "b": [0.6836, 0.6009, 0.7129, 0.6223]}, {"w": "suspects,", "b": [0.7179, 0.6009, 0.7916, 0.6223]}, {"w": "includ‐", "b": [0.7966, 0.6009, 0.8571, 0.6223]}, {"w": "ing", "b": [0.1429, 0.62, 0.1696, 0.6414]}, {"w": "the", "b": [0.1793, 0.62, 0.2057, 0.6414]}, {"w": "combination", "b": [0.2154, 0.62, 0.3222, 0.6414]}, {"w": "of", "b": [0.3319, 0.62, 0.3487, 0.6414]}, {"w": "the", "b": [0.3585, 0.62, 0.3848, 0.6414]}, {"w": "popular", "b": [0.3946, 0.62, 0.4602, 0.6414]}, {"w": "logistic", "b": [0.47, 0.62, 0.5296, 0.6414]}, {"w": "sigmoid", "b": [0.5394, 0.62, 0.6066, 0.6414]}, {"w": "activation", "b": [0.6164, 0.62, 0.6986, 0.6414]}, {"w": "function", "b": [0.7084, 0.62, 0.7798, 0.6414]}, {"w": "and", "b": [0.7895, 0.62, 0.8211, 0.6414]}, {"w": "the", "b": [0.8308, 0.62, 0.8571, 0.6414]}, {"w": "weight", "b": [0.1429, 0.639, 0.1984, 0.6604]}, {"w": "initialization", "b": [0.2031, 0.639, 0.3091, 0.6604]}, {"w": "technique", "b": [0.3138, 0.639, 0.3965, 0.6604]}, {"w": "that", "b": [0.4012, 0.639, 0.4338, 0.6604]}, {"w": "was", "b": [0.4385, 0.639, 0.4696, 0.6604]}, {"w": "most", "b": [0.4743, 0.639, 0.516, 0.6604]}, {"w": "popular", "b": [0.5207, 0.639, 0.5864, 0.6604]}, {"w": "at", "b": [0.5911, 0.639, 0.6062, 0.6604]}, {"w": "the", "b": [0.611, 0.639, 0.6373, 0.6604]}, {"w": "time,", "b": [0.642, 0.639, 0.6846, 0.6604]}, {"w": "namely", "b": [0.6894, 0.639, 0.7507, 0.6604]}, {"w": "random", "b": [0.7555, 0.639, 0.8224, 0.6604]}, {"w": "ini‐", "b": [0.8272, 0.639, 0.8571, 0.6604]}, {"w": "tialization", "b": [0.1429, 0.658, 0.2262, 0.6795]}, {"w": "using", "b": [0.2311, 0.658, 0.2765, 0.6795]}, {"w": "a", "b": [0.2813, 0.658, 0.2905, 0.6795]}, {"w": "normal", "b": [0.2953, 0.658, 0.3565, 0.6795]}, {"w": "distribution", "b": [0.3614, 0.658, 0.4609, 0.6795]}, {"w": "with", "b": [0.4657, 0.658, 0.503, 0.6795]}, {"w": "a", "b": [0.5079, 0.658, 0.517, 0.6795]}, {"w": "mean", "b": [0.5218, 0.658, 0.5683, 0.6795]}, {"w": "of", "b": [0.5731, 0.658, 0.5899, 0.6795]}, {"w": "0", "b": [0.5947, 0.658, 0.6047, 0.6795]}, {"w": "and", "b": [0.6096, 0.658, 0.6411, 0.6795]}, {"w": "a", "b": [0.6459, 0.658, 0.6551, 0.6795]}, {"w": "standard", "b": [0.6599, 0.658, 0.7333, 0.6795]}, {"w": "deviation", "b": [0.7381, 0.658, 0.8159, 0.6795]}, {"w": "of", "b": [0.8208, 0.658, 0.8376, 0.6795]}, {"w": "1.", "b": [0.8424, 0.658, 0.8571, 0.6795]}, {"w": "In", "b": [0.1429, 0.6771, 0.1614, 0.6985]}, {"w": "short,", "b": [0.1662, 0.6771, 0.2145, 0.6985]}, {"w": "they", "b": [0.2194, 0.6771, 0.2553, 0.6985]}, {"w": "showed", "b": [0.2601, 0.6771, 0.3237, 0.6985]}, {"w": "that", "b": [0.3285, 0.6771, 0.3611, 0.6985]}, {"w": "with", "b": [0.366, 0.6771, 0.4033, 0.6985]}, {"w": "this", "b": [0.4082, 0.6771, 0.4389, 0.6985]}, {"w": "activation", "b": [0.4438, 0.6771, 0.526, 0.6985]}, {"w": "function", "b": [0.5309, 0.6771, 0.6023, 0.6985]}, {"w": "and", "b": [0.6072, 0.6771, 0.6387, 0.6985]}, {"w": "this", "b": [0.6436, 0.6771, 0.6743, 0.6985]}, {"w": "initialization", "b": [0.6792, 0.6771, 0.7852, 0.6985]}, {"w": "scheme,", "b": [0.79, 0.6771, 0.8572, 0.6985]}, {"w": "the", "b": [0.1429, 0.6961, 0.1692, 0.7176]}, {"w": "variance", "b": [0.1776, 0.6961, 0.2479, 0.7176]}, {"w": "of", "b": [0.2563, 0.6961, 0.273, 0.7176]}, {"w": "the", "b": [0.2814, 0.6961, 0.3078, 0.7176]}, {"w": "outputs", "b": [0.3161, 0.6961, 0.3801, 0.7176]}, {"w": "of", "b": [0.3885, 0.6961, 0.4053, 0.7176]}, {"w": "each", "b": [0.4137, 0.6961, 0.4516, 0.7176]}, {"w": "layer", "b": [0.46, 0.6961, 0.5002, 0.7176]}, {"w": "is", "b": [0.5086, 0.6961, 0.5218, 0.7176]}, {"w": "much", "b": [0.5302, 0.6961, 0.5778, 0.7176]}, {"w": "greater", "b": [0.5862, 0.6961, 0.6442, 0.7176]}, {"w": "than", "b": [0.6526, 0.6961, 0.6906, 0.7176]}, {"w": "the", "b": [0.699, 0.6961, 0.7253, 0.7176]}, {"w": "variance", "b": [0.7337, 0.6961, 0.804, 0.7176]}, {"w": "of", "b": [0.8124, 0.6961, 0.8292, 0.7176]}, {"w": "its", "b": [0.8376, 0.6961, 0.8571, 0.7176]}, {"w": "inputs.", "b": [0.1429, 0.7152, 0.2002, 0.7366]}, {"w": "Going", "b": [0.2064, 0.7152, 0.2586, 0.7366]}, {"w": "forward", "b": [0.2648, 0.7152, 0.3321, 0.7366]}, {"w": "in", "b": [0.3383, 0.7152, 0.3552, 0.7366]}, {"w": "the", "b": [0.3614, 0.7152, 0.3878, 0.7366]}, {"w": "network,", "b": [0.394, 0.7152, 0.4683, 0.7366]}, {"w": "the", "b": [0.4745, 0.7152, 0.5008, 0.7366]}, {"w": "variance", "b": [0.507, 0.7152, 0.5773, 0.7366]}, {"w": "keeps", "b": [0.5835, 0.7152, 0.6301, 0.7366]}, {"w": "increasing", "b": [0.6363, 0.7152, 0.7222, 0.7366]}, {"w": "after", "b": [0.7284, 0.7152, 0.7666, 0.7366]}, {"w": "each", "b": [0.7728, 0.7152, 0.8108, 0.7366]}, {"w": "layer", "b": [0.817, 0.7152, 0.8571, 0.7366]}, {"w": "until", "b": [0.1428, 0.7342, 0.1821, 0.7557]}, {"w": "the", "b": [0.1871, 0.7342, 0.2134, 0.7557]}, {"w": "activation", "b": [0.2184, 0.7342, 0.3006, 0.7557]}, {"w": "function", "b": [0.3056, 0.7342, 0.377, 0.7557]}, {"w": "saturates", "b": [0.382, 0.7342, 0.4551, 0.7557]}, {"w": "at", "b": [0.4601, 0.7342, 0.4752, 0.7557]}, {"w": "the", "b": [0.4802, 0.7342, 0.5065, 0.7557]}, {"w": "top", "b": [0.5115, 0.7342, 0.5394, 0.7557]}, {"w": "layers.", "b": [0.5443, 0.7342, 0.5969, 0.7557]}, {"w": "This", "b": [0.6019, 0.7342, 0.6391, 0.7557]}, {"w": "is", "b": [0.6441, 0.7342, 0.6573, 0.7557]}, {"w": "actually", "b": [0.6623, 0.7342, 0.7269, 0.7557]}, {"w": "made", "b": [0.7319, 0.7342, 0.7779, 0.7557]}, {"w": "worse", "b": [0.7829, 0.7342, 0.832, 0.7557]}, {"w": "by", "b": [0.837, 0.7342, 0.8571, 0.7557]}, {"w": "the", "b": [0.1429, 0.7533, 0.1692, 0.7747]}, {"w": "fact", "b": [0.1768, 0.7533, 0.2073, 0.7747]}, {"w": "that", "b": [0.2149, 0.7533, 0.2475, 0.7747]}, {"w": "the", "b": [0.2551, 0.7533, 0.2815, 0.7747]}, {"w": "logistic", "b": [0.2891, 0.7533, 0.3487, 0.7747]}, {"w": "function", "b": [0.3563, 0.7533, 0.4277, 0.7747]}, {"w": "has", "b": [0.4354, 0.7533, 0.4633, 0.7747]}, {"w": "a", "b": [0.4709, 0.7533, 0.48, 0.7747]}, {"w": "mean", "b": [0.4877, 0.7533, 0.5341, 0.7747]}, {"w": "of", "b": [0.5418, 0.7533, 0.5585, 0.7747]}, {"w": "0.5,", "b": [0.5662, 0.7533, 0.5957, 0.7747]}, {"w": "not", "b": [0.6033, 0.7533, 0.6317, 0.7747]}, {"w": "0", "b": [0.6393, 0.7533, 0.6493, 0.7747]}, {"w": "(the", "b": [0.6569, 0.7533, 0.6905, 0.7747]}, {"w": "hyperbolic", "b": [0.6981, 0.7533, 0.7867, 0.7747]}, {"w": "tangent", "b": [0.7943, 0.7533, 0.8571, 0.7747]}, {"w": "function", "b": [0.1429, 0.7723, 0.2143, 0.7937]}, {"w": "has", "b": [0.2192, 0.7723, 0.2471, 0.7937]}, {"w": "a", "b": [0.2521, 0.7723, 0.2613, 0.7937]}, {"w": "mean", "b": [0.2663, 0.7723, 0.3127, 0.7937]}, {"w": "of", "b": [0.3177, 0.7723, 0.3345, 0.7937]}, {"w": "0", "b": [0.3395, 0.7723, 0.3495, 0.7937]}, {"w": "and", "b": [0.3544, 0.7723, 0.386, 0.7937]}, {"w": "behaves", "b": [0.391, 0.7723, 0.4564, 0.7937]}, {"w": "slightly", "b": [0.4614, 0.7723, 0.5216, 0.7937]}, {"w": "better", "b": [0.5266, 0.7723, 0.5753, 0.7937]}, {"w": "than", "b": [0.5803, 0.7723, 0.6183, 0.7937]}, {"w": "the", "b": [0.6233, 0.7723, 0.6496, 0.7937]}, {"w": "logistic", "b": [0.6546, 0.7723, 0.7142, 0.7937]}, {"w": "function", "b": [0.7192, 0.7723, 0.7906, 0.7937]}, {"w": "in", "b": [0.7956, 0.7723, 0.8125, 0.7937]}, {"w": "deep", "b": [0.8175, 0.7723, 0.8571, 0.7937]}, {"w": "networks).", "b": [0.1429, 0.7914, 0.232, 0.8128]}]}, {"id": "b_7", "type": "paragraph", "text": "326 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "326", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2746, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 353, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "2 Here’s an analogy: if you set a microphone amplifier’s knob too close to zero, people won’t hear your voice, but if you set it too close to the max, your voice will be saturated and people won’t understand what you are say‐ ing. Now imagine a chain of such amplifiers: they all need to be set properly in order for your voice to come out loud and clear at the end of the chain. Your voice has to come out of each amplifier at the same amplitude as it came in.", "words": [{"w": "2", "b": [0.1451, 0.8159, 0.1518, 0.8302]}, {"w": "Here’s", "b": [0.1587, 0.8144, 0.1968, 0.8308]}, {"w": "an", "b": [0.2004, 0.8144, 0.2161, 0.8308]}, {"w": "analogy:", "b": [0.2197, 0.8144, 0.2736, 0.8308]}, {"w": "if", "b": [0.2772, 0.8144, 0.2862, 0.8308]}, {"w": "you", "b": [0.2898, 0.8144, 0.3136, 0.8308]}, {"w": "set", "b": [0.3172, 0.8144, 0.3346, 0.8308]}, {"w": "a", "b": [0.3382, 0.8144, 0.3452, 0.8308]}, {"w": "microphone", "b": [0.3488, 0.8144, 0.427, 0.8308]}, {"w": "amplifier’s", "b": [0.4306, 0.8144, 0.4963, 0.8308]}, {"w": "knob", "b": [0.4999, 0.8144, 0.5327, 0.8308]}, {"w": "too", "b": [0.5363, 0.8144, 0.5573, 0.8308]}, {"w": "close", "b": [0.5609, 0.8144, 0.5923, 0.8308]}, {"w": "to", "b": [0.5959, 0.8144, 0.6088, 0.8308]}, {"w": "zero,", "b": [0.6124, 0.8144, 0.643, 0.8308]}, {"w": "people", "b": [0.6466, 0.8144, 0.6888, 0.8308]}, {"w": "won’t", "b": [0.6924, 0.8144, 0.7266, 0.8308]}, {"w": "hear", "b": [0.7302, 0.8144, 0.7583, 0.8308]}, {"w": "your", "b": [0.7619, 0.8144, 0.7916, 0.8308]}, {"w": "voice,", "b": [0.7952, 0.8144, 0.832, 0.8308]}, {"w": "but", "b": [0.8356, 0.8144, 0.8569, 0.8308]}, {"w": "if", "b": [0.1587, 0.8296, 0.1677, 0.8459]}, {"w": "you", "b": [0.1713, 0.8296, 0.1951, 0.8459]}, {"w": "set", "b": [0.1987, 0.8296, 0.2161, 0.8459]}, {"w": "it", "b": [0.2197, 0.8296, 0.2288, 0.8459]}, {"w": "too", "b": [0.2324, 0.8296, 0.2534, 0.8459]}, {"w": "close", "b": [0.257, 0.8296, 0.2884, 0.8459]}, {"w": "to", "b": [0.292, 0.8296, 0.305, 0.8459]}, {"w": "the", "b": [0.3086, 0.8296, 0.3287, 0.8459]}, {"w": "max,", "b": [0.3323, 0.8296, 0.3633, 0.8459]}, {"w": "your", "b": [0.3669, 0.8296, 0.3966, 0.8459]}, {"w": "voice", "b": [0.4002, 0.8296, 0.4334, 0.8459]}, {"w": "will", "b": [0.437, 0.8296, 0.4602, 0.8459]}, {"w": "be", "b": [0.4638, 0.8296, 0.4786, 0.8459]}, {"w": "saturated", "b": [0.4822, 0.8296, 0.5405, 0.8459]}, {"w": "and", "b": [0.5441, 0.8296, 0.5681, 0.8459]}, {"w": "people", "b": [0.5717, 0.8296, 0.6139, 0.8459]}, {"w": "won’t", "b": [0.6175, 0.8296, 0.6517, 0.8459]}, {"w": "understand", "b": [0.6553, 0.8296, 0.7282, 0.8459]}, {"w": "what", "b": [0.7318, 0.8296, 0.7626, 0.8459]}, {"w": "you", "b": [0.7662, 0.8296, 0.79, 0.8459]}, {"w": "are", "b": [0.7936, 0.8296, 0.8132, 0.8459]}, {"w": "say‐", "b": [0.8168, 0.8296, 0.8423, 0.8459]}, {"w": "ing.", "b": [0.1587, 0.8447, 0.1827, 0.861]}, {"w": "Now", "b": [0.1863, 0.8447, 0.2167, 0.861]}, {"w": "imagine", "b": [0.2203, 0.8447, 0.2716, 0.861]}, {"w": "a", "b": [0.2752, 0.8447, 0.2822, 0.861]}, {"w": "chain", "b": [0.2858, 0.8447, 0.3209, 0.861]}, {"w": "of", "b": [0.3245, 0.8447, 0.3373, 0.861]}, {"w": "such", "b": [0.3409, 0.8447, 0.3703, 0.861]}, {"w": "amplifiers:", "b": [0.3739, 0.8447, 0.4412, 0.861]}, {"w": "they", "b": [0.4448, 0.8447, 0.4722, 0.861]}, {"w": "all", "b": [0.4758, 0.8447, 0.4908, 0.861]}, {"w": "need", "b": [0.4944, 0.8447, 0.5249, 0.861]}, {"w": "to", "b": [0.5285, 0.8447, 0.5415, 0.861]}, {"w": "be", "b": [0.5451, 0.8447, 0.5599, 0.861]}, {"w": "set", "b": [0.5635, 0.8447, 0.5809, 0.861]}, {"w": "properly", "b": [0.5845, 0.8447, 0.6391, 0.861]}, {"w": "in", "b": [0.6427, 0.8447, 0.6556, 0.861]}, {"w": "order", "b": [0.6592, 0.8447, 0.6942, 0.861]}, {"w": "for", "b": [0.6978, 0.8447, 0.7165, 0.861]}, {"w": "your", "b": [0.7201, 0.8447, 0.7498, 0.861]}, {"w": "voice", "b": [0.7534, 0.8447, 0.7866, 0.861]}, {"w": "to", "b": [0.7902, 0.8447, 0.8031, 0.861]}, {"w": "come", "b": [0.8067, 0.8447, 0.8413, 0.861]}, {"w": "out", "b": [0.1587, 0.8598, 0.1801, 0.8761]}, {"w": "loud", "b": [0.1837, 0.8598, 0.2126, 0.8761]}, {"w": "and", "b": [0.2162, 0.8598, 0.2403, 0.8761]}, {"w": "clear", "b": [0.2439, 0.8598, 0.2742, 0.8761]}, {"w": "at", "b": [0.2778, 0.8598, 0.2893, 0.8761]}, {"w": "the", "b": [0.2929, 0.8598, 0.313, 0.8761]}, {"w": "end", "b": [0.3166, 0.8598, 0.3404, 0.8761]}, {"w": "of", "b": [0.344, 0.8598, 0.3568, 0.8761]}, {"w": "the", "b": [0.3604, 0.8598, 0.3804, 0.8761]}, {"w": "chain.", "b": [0.384, 0.8598, 0.4228, 0.8761]}, {"w": "Your", "b": [0.4264, 0.8598, 0.4569, 0.8761]}, {"w": "voice", "b": [0.4605, 0.8598, 0.4937, 0.8761]}, {"w": "has", "b": [0.4973, 0.8598, 0.5185, 0.8761]}, {"w": "to", "b": [0.5221, 0.8598, 0.5351, 0.8761]}, {"w": "come", "b": [0.5387, 0.8598, 0.5732, 0.8761]}, {"w": "out", "b": [0.5768, 0.8598, 0.5982, 0.8761]}, {"w": "of", "b": [0.6018, 0.8598, 0.6146, 0.8761]}, {"w": "each", "b": [0.6182, 0.8598, 0.6471, 0.8761]}, {"w": "amplifier", "b": [0.6507, 0.8598, 0.7086, 0.8761]}, {"w": "at", "b": [0.7122, 0.8598, 0.7237, 0.8761]}, {"w": "the", "b": [0.7273, 0.8598, 0.7473, 0.8761]}, {"w": "same", "b": [0.7509, 0.8598, 0.7835, 0.8761]}, {"w": "amplitude", "b": [0.7871, 0.8598, 0.8517, 0.8761]}, {"w": "as", "b": [0.1587, 0.8749, 0.1715, 0.8912]}, {"w": "it", "b": [0.1751, 0.8749, 0.1842, 0.8912]}, {"w": "came", "b": [0.1878, 0.8749, 0.2213, 0.8912]}, {"w": "in.", "b": [0.2249, 0.8749, 0.2414, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Looking at the logistic activation function (see Figure 11-1), you can see that when inputs become large (negative or positive), the function saturates at 0 or 1, with a derivative extremely close to 0. Thus when backpropagation kicks in, it has virtually no gradient to propagate back through the network, and what little gradient exists keeps getting diluted as backpropagation progresses down through the top layers, so there is really nothing left for the lower layers.", "words": [{"w": "Looking", "b": [0.1429, 0.0791, 0.2124, 0.1005]}, {"w": "at", "b": [0.2193, 0.0791, 0.2344, 0.1005]}, {"w": "the", "b": [0.2413, 0.0791, 0.2676, 0.1005]}, {"w": "logistic", "b": [0.2746, 0.0791, 0.3342, 0.1005]}, {"w": "activation", "b": [0.3411, 0.0791, 0.4234, 0.1005]}, {"w": "function", "b": [0.4303, 0.0791, 0.5017, 0.1005]}, {"w": "(see", "b": [0.5086, 0.0791, 0.5411, 0.1005]}, {"w": "Figure", "b": [0.5481, 0.0791, 0.6021, 0.1005]}, {"w": "11-1),", "b": [0.609, 0.0791, 0.6584, 0.1005]}, {"w": "you", "b": [0.6653, 0.0791, 0.6965, 0.1005]}, {"w": "can", "b": [0.7034, 0.0791, 0.7328, 0.1005]}, {"w": "see", "b": [0.7397, 0.0791, 0.7651, 0.1005]}, {"w": "that", "b": [0.772, 0.0791, 0.8046, 0.1005]}, {"w": "when", "b": [0.8115, 0.0791, 0.8571, 0.1005]}, {"w": "inputs", "b": [0.1429, 0.0981, 0.1954, 0.1195]}, {"w": "become", "b": [0.2032, 0.0981, 0.268, 0.1195]}, {"w": "large", "b": [0.2757, 0.0981, 0.3165, 0.1195]}, {"w": "(negative", "b": [0.3243, 0.0981, 0.4007, 0.1195]}, {"w": "or", "b": [0.4084, 0.0981, 0.4268, 0.1195]}, {"w": "positive),", "b": [0.4345, 0.0981, 0.5117, 0.1195]}, {"w": "the", "b": [0.5195, 0.0981, 0.5458, 0.1195]}, {"w": "function", "b": [0.5536, 0.0981, 0.625, 0.1195]}, {"w": "saturates", "b": [0.6327, 0.0981, 0.7059, 0.1195]}, {"w": "at", "b": [0.7136, 0.0981, 0.7287, 0.1195]}, {"w": "0", "b": [0.7365, 0.0981, 0.7465, 0.1195]}, {"w": "or", "b": [0.7543, 0.0981, 0.7726, 0.1195]}, {"w": "1,", "b": [0.7804, 0.0981, 0.7951, 0.1195]}, {"w": "with", "b": [0.8029, 0.0981, 0.8402, 0.1195]}, {"w": "a", "b": [0.848, 0.0981, 0.8572, 0.1195]}, {"w": "derivative", "b": [0.1429, 0.1172, 0.2249, 0.1386]}, {"w": "extremely", "b": [0.2311, 0.1172, 0.3134, 0.1386]}, {"w": "close", "b": [0.3196, 0.1172, 0.3609, 0.1386]}, {"w": "to", "b": [0.3671, 0.1172, 0.384, 0.1386]}, {"w": "0.", "b": [0.3902, 0.1172, 0.405, 0.1386]}, {"w": "Thus", "b": [0.4112, 0.1172, 0.4535, 0.1386]}, {"w": "when", "b": [0.4597, 0.1172, 0.5053, 0.1386]}, {"w": "backpropagation", "b": [0.5115, 0.1172, 0.6522, 0.1386]}, {"w": "kicks", "b": [0.6584, 0.1172, 0.7011, 0.1386]}, {"w": "in,", "b": [0.7073, 0.1172, 0.7291, 0.1386]}, {"w": "it", "b": [0.7353, 0.1172, 0.7472, 0.1386]}, {"w": "has", "b": [0.7534, 0.1172, 0.7813, 0.1386]}, {"w": "virtually", "b": [0.7875, 0.1172, 0.8571, 0.1386]}, {"w": "no", "b": [0.1429, 0.1362, 0.1649, 0.1576]}, {"w": "gradient", "b": [0.1724, 0.1362, 0.2418, 0.1576]}, {"w": "to", "b": [0.2494, 0.1362, 0.2663, 0.1576]}, {"w": "propagate", "b": [0.2739, 0.1362, 0.3569, 0.1576]}, {"w": "back", "b": [0.3645, 0.1362, 0.4033, 0.1576]}, {"w": "through", "b": [0.4109, 0.1362, 0.4787, 0.1576]}, {"w": "the", "b": [0.4862, 0.1362, 0.5125, 0.1576]}, {"w": "network,", "b": [0.5201, 0.1362, 0.5944, 0.1576]}, {"w": "and", "b": [0.6019, 0.1362, 0.6335, 0.1576]}, {"w": "what", "b": [0.641, 0.1362, 0.6815, 0.1576]}, {"w": "little", "b": [0.689, 0.1362, 0.7267, 0.1576]}, {"w": "gradient", "b": [0.7343, 0.1362, 0.8037, 0.1576]}, {"w": "exists", "b": [0.8112, 0.1362, 0.8571, 0.1576]}, {"w": "keeps", "b": [0.1428, 0.1553, 0.1895, 0.1767]}, {"w": "getting", "b": [0.1954, 0.1553, 0.2534, 0.1767]}, {"w": "diluted", "b": [0.2594, 0.1553, 0.3185, 0.1767]}, {"w": "as", "b": [0.3245, 0.1553, 0.3413, 0.1767]}, {"w": "backpropagation", "b": [0.3472, 0.1553, 0.4879, 0.1767]}, {"w": "progresses", "b": [0.4939, 0.1553, 0.5813, 0.1767]}, {"w": "down", "b": [0.5872, 0.1553, 0.6345, 0.1767]}, {"w": "through", "b": [0.6405, 0.1553, 0.7082, 0.1767]}, {"w": "the", "b": [0.7142, 0.1553, 0.7405, 0.1767]}, {"w": "top", "b": [0.7465, 0.1553, 0.7744, 0.1767]}, {"w": "layers,", "b": [0.7803, 0.1553, 0.8329, 0.1767]}, {"w": "so", "b": [0.8389, 0.1553, 0.8571, 0.1767]}, {"w": "there", "b": [0.1429, 0.1743, 0.1858, 0.1957]}, {"w": "is", "b": [0.1905, 0.1743, 0.2037, 0.1957]}, {"w": "really", "b": [0.2085, 0.1743, 0.2543, 0.1957]}, {"w": "nothing", "b": [0.259, 0.1743, 0.3253, 0.1957]}, {"w": "left", "b": [0.33, 0.1743, 0.3566, 0.1957]}, {"w": "for", "b": [0.3614, 0.1743, 0.3859, 0.1957]}, {"w": "the", "b": [0.3906, 0.1743, 0.4169, 0.1957]}, {"w": "lower", "b": [0.4217, 0.1743, 0.4684, 0.1957]}, {"w": "layers.", "b": [0.4732, 0.1743, 0.5257, 0.1957]}]}, {"id": "b_2", "type": "equation", "text": "Figure 11-1. Logistic activation function saturation", "words": [{"w": "Figure", "b": [0.1429, 0.4701, 0.1943, 0.4918]}, {"w": "11-1.", "b": [0.1991, 0.4701, 0.2407, 0.4918]}, {"w": "Logistic", "b": [0.2455, 0.4701, 0.3077, 0.4918]}, {"w": "activation", "b": [0.3124, 0.4701, 0.3936, 0.4918]}, {"w": "function", "b": [0.3984, 0.4701, 0.4665, 0.4918]}, {"w": "saturation", "b": [0.4712, 0.4701, 0.5546, 0.4918]}]}, {"id": "b_3", "type": "paragraph", "text": "Glorot and He Initialization", "words": [{"w": "Glorot", "b": [0.1429, 0.5048, 0.2068, 0.5333]}, {"w": "and", "b": [0.2118, 0.5048, 0.2511, 0.5333]}, {"w": "He", "b": [0.256, 0.5048, 0.2837, 0.5333]}, {"w": "Initialization", "b": [0.2887, 0.5048, 0.4211, 0.5333]}]}, {"id": "b_4", "type": "paragraph", "text": "In their paper, Glorot and Bengio propose a way to significantly alleviate this prob‐ lem. We need the signal to flow properly in both directions: in the forward direction when making predictions, and in the reverse direction when backpropagating gradi‐ ents. We don’t want the signal to die out, nor do we want it to explode and saturate. For the signal to flow properly, the authors argue that we need the variance of the outputs of each layer to be equal to the variance of its inputs,2 and we also need the gradients to have equal variance before and after flowing through a layer in the reverse direction (please check out the paper if you are interested in the mathematical details). It is actually not possible to guarantee both unless the layer has an equal number of inputs and neurons (these numbers are called the fan-in and fan-out of the layer), but they proposed a good compromise that has proven to work very well in practice: the connection weights of each layer must be initialized randomly as", "words": [{"w": "In", "b": [0.1429, 0.5392, 0.1614, 0.5607]}, {"w": "their", "b": [0.168, 0.5392, 0.2076, 0.5607]}, {"w": "paper,", "b": [0.2142, 0.5392, 0.2648, 0.5607]}, {"w": "Glorot", "b": [0.2715, 0.5392, 0.327, 0.5607]}, {"w": "and", "b": [0.3336, 0.5392, 0.3651, 0.5607]}, {"w": "Bengio", "b": [0.3717, 0.5392, 0.4306, 0.5607]}, {"w": "propose", "b": [0.4372, 0.5392, 0.5045, 0.5607]}, {"w": "a", "b": [0.5112, 0.5392, 0.5203, 0.5607]}, {"w": "way", "b": [0.5269, 0.5392, 0.5595, 0.5607]}, {"w": "to", "b": [0.5661, 0.5392, 0.5831, 0.5607]}, {"w": "significantly", "b": [0.5897, 0.5392, 0.6916, 0.5607]}, {"w": "alleviate", "b": [0.6982, 0.5392, 0.7659, 0.5607]}, {"w": "this", "b": [0.7725, 0.5392, 0.8033, 0.5607]}, {"w": "prob‐", "b": [0.8099, 0.5392, 0.8571, 0.5607]}, {"w": "lem.", "b": [0.1429, 0.5583, 0.1788, 0.5797]}, {"w": "We", "b": [0.1845, 0.5583, 0.2116, 0.5797]}, {"w": "need", "b": [0.2174, 0.5583, 0.2575, 0.5797]}, {"w": "the", "b": [0.2632, 0.5583, 0.2896, 0.5797]}, {"w": "signal", "b": [0.2953, 0.5583, 0.3441, 0.5797]}, {"w": "to", "b": [0.3499, 0.5583, 0.3669, 0.5797]}, {"w": "flow", "b": [0.3726, 0.5583, 0.4089, 0.5797]}, {"w": "properly", "b": [0.4147, 0.5583, 0.4863, 0.5797]}, {"w": "in", "b": [0.4921, 0.5583, 0.509, 0.5797]}, {"w": "both", "b": [0.5148, 0.5583, 0.5535, 0.5797]}, {"w": "directions:", "b": [0.5593, 0.5583, 0.6476, 0.5797]}, {"w": "in", "b": [0.6533, 0.5583, 0.6703, 0.5797]}, {"w": "the", "b": [0.6761, 0.5583, 0.7024, 0.5797]}, {"w": "forward", "b": [0.7082, 0.5583, 0.7754, 0.5797]}, {"w": "direction", "b": [0.7812, 0.5583, 0.8571, 0.5797]}, {"w": "when", "b": [0.1428, 0.5773, 0.1885, 0.5988]}, {"w": "making", "b": [0.1945, 0.5773, 0.2578, 0.5988]}, {"w": "predictions,", "b": [0.2638, 0.5773, 0.363, 0.5988]}, {"w": "and", "b": [0.369, 0.5773, 0.4005, 0.5988]}, {"w": "in", "b": [0.4065, 0.5773, 0.4235, 0.5988]}, {"w": "the", "b": [0.4295, 0.5773, 0.4558, 0.5988]}, {"w": "reverse", "b": [0.4618, 0.5773, 0.5212, 0.5988]}, {"w": "direction", "b": [0.5271, 0.5773, 0.6031, 0.5988]}, {"w": "when", "b": [0.6091, 0.5773, 0.6547, 0.5988]}, {"w": "backpropagating", "b": [0.6607, 0.5773, 0.8005, 0.5988]}, {"w": "gradi‐", "b": [0.8065, 0.5773, 0.8571, 0.5988]}, {"w": "ents.", "b": [0.1429, 0.5964, 0.1815, 0.6178]}, {"w": "We", "b": [0.1876, 0.5964, 0.2147, 0.6178]}, {"w": "don’t", "b": [0.2208, 0.5964, 0.2624, 0.6178]}, {"w": "want", "b": [0.2686, 0.5964, 0.3094, 0.6178]}, {"w": "the", "b": [0.3155, 0.5964, 0.3418, 0.6178]}, {"w": "signal", "b": [0.348, 0.5964, 0.3968, 0.6178]}, {"w": "to", "b": [0.4029, 0.5964, 0.4199, 0.6178]}, {"w": "die", "b": [0.4261, 0.5964, 0.4515, 0.6178]}, {"w": "out,", "b": [0.4577, 0.5964, 0.4905, 0.6178]}, {"w": "nor", "b": [0.4966, 0.5964, 0.5264, 0.6178]}, {"w": "do", "b": [0.5325, 0.5964, 0.5541, 0.6178]}, {"w": "we", "b": [0.5603, 0.5964, 0.5834, 0.6178]}, {"w": "want", "b": [0.5896, 0.5964, 0.6303, 0.6178]}, {"w": "it", "b": [0.6365, 0.5964, 0.6484, 0.6178]}, {"w": "to", "b": [0.6546, 0.5964, 0.6715, 0.6178]}, {"w": "explode", "b": [0.6777, 0.5964, 0.7431, 0.6178]}, {"w": "and", "b": [0.7492, 0.5964, 0.7807, 0.6178]}, {"w": "saturate.", "b": [0.7869, 0.5964, 0.8571, 0.6178]}, {"w": "For", "b": [0.1429, 0.6154, 0.1718, 0.6368]}, {"w": "the", "b": [0.1792, 0.6154, 0.2055, 0.6368]}, {"w": "signal", "b": [0.2129, 0.6154, 0.2617, 0.6368]}, {"w": "to", "b": [0.269, 0.6154, 0.286, 0.6368]}, {"w": "flow", "b": [0.2933, 0.6154, 0.3297, 0.6368]}, {"w": "properly,", "b": [0.337, 0.6154, 0.4119, 0.6368]}, {"w": "the", "b": [0.4192, 0.6154, 0.4456, 0.6368]}, {"w": "authors", "b": [0.4529, 0.6154, 0.5162, 0.6368]}, {"w": "argue", "b": [0.5236, 0.6154, 0.5701, 0.6368]}, {"w": "that", "b": [0.5774, 0.6154, 0.61, 0.6368]}, {"w": "we", "b": [0.6174, 0.6154, 0.6405, 0.6368]}, {"w": "need", "b": [0.6479, 0.6154, 0.688, 0.6368]}, {"w": "the", "b": [0.6953, 0.6154, 0.7216, 0.6368]}, {"w": "variance", "b": [0.729, 0.6154, 0.7993, 0.6368]}, {"w": "of", "b": [0.8067, 0.6154, 0.8235, 0.6368]}, {"w": "the", "b": [0.8308, 0.6154, 0.8571, 0.6368]}, {"w": "outputs", "b": [0.1429, 0.6345, 0.2069, 0.6559]}, {"w": "of", "b": [0.2132, 0.6345, 0.23, 0.6559]}, {"w": "each", "b": [0.2363, 0.6345, 0.2742, 0.6559]}, {"w": "layer", "b": [0.2805, 0.6345, 0.3207, 0.6559]}, {"w": "to", "b": [0.327, 0.6345, 0.344, 0.6559]}, {"w": "be", "b": [0.3503, 0.6345, 0.3697, 0.6559]}, {"w": "equal", "b": [0.376, 0.6345, 0.421, 0.6559]}, {"w": "to", "b": [0.4273, 0.6345, 0.4443, 0.6559]}, {"w": "the", "b": [0.4506, 0.6345, 0.4769, 0.6559]}, {"w": "variance", "b": [0.4832, 0.6345, 0.5535, 0.6559]}, {"w": "of", "b": [0.5598, 0.6345, 0.5766, 0.6559]}, {"w": "its", "b": [0.5829, 0.6345, 0.6025, 0.6559]}, {"w": "inputs,2", "b": [0.6088, 0.6345, 0.6718, 0.6559]}, {"w": "and", "b": [0.6781, 0.6345, 0.7097, 0.6559]}, {"w": "we", "b": [0.716, 0.6345, 0.7391, 0.6559]}, {"w": "also", "b": [0.7454, 0.6345, 0.7781, 0.6559]}, {"w": "need", "b": [0.7844, 0.6345, 0.8245, 0.6559]}, {"w": "the", "b": [0.8308, 0.6345, 0.8571, 0.6559]}, {"w": "gradients", "b": [0.1429, 0.6535, 0.2199, 0.6749]}, {"w": "to", "b": [0.2292, 0.6535, 0.2462, 0.6749]}, {"w": "have", "b": [0.2554, 0.6535, 0.2938, 0.6749]}, {"w": "equal", "b": [0.3031, 0.6535, 0.3481, 0.6749]}, {"w": "variance", "b": [0.3573, 0.6535, 0.4277, 0.6749]}, {"w": "before", "b": [0.4369, 0.6535, 0.4897, 0.6749]}, {"w": "and", "b": [0.499, 0.6535, 0.5305, 0.6749]}, {"w": "after", "b": [0.5398, 0.6535, 0.5781, 0.6749]}, {"w": "flowing", "b": [0.5873, 0.6535, 0.6504, 0.6749]}, {"w": "through", "b": [0.6597, 0.6535, 0.7274, 0.6749]}, {"w": "a", "b": [0.7367, 0.6535, 0.7458, 0.6749]}, {"w": "layer", "b": [0.7551, 0.6535, 0.7953, 0.6749]}, {"w": "in", "b": [0.8046, 0.6535, 0.8215, 0.6749]}, {"w": "the", "b": [0.8308, 0.6535, 0.8571, 0.6749]}, {"w": "reverse", "b": [0.1429, 0.6726, 0.2022, 0.694]}, {"w": "direction", "b": [0.2071, 0.6726, 0.283, 0.694]}, {"w": "(please", "b": [0.288, 0.6726, 0.3459, 0.694]}, {"w": "check", "b": [0.3508, 0.6726, 0.3988, 0.694]}, {"w": "out", "b": [0.4037, 0.6726, 0.4317, 0.694]}, {"w": "the", "b": [0.4367, 0.6726, 0.463, 0.694]}, {"w": "paper", "b": [0.468, 0.6726, 0.5151, 0.694]}, {"w": "if", "b": [0.5201, 0.6726, 0.5318, 0.694]}, {"w": "you", "b": [0.5368, 0.6726, 0.568, 0.694]}, {"w": "are", "b": [0.573, 0.6726, 0.5987, 0.694]}, {"w": "interested", "b": [0.6036, 0.6726, 0.6859, 0.694]}, {"w": "in", "b": [0.6908, 0.6726, 0.7078, 0.694]}, {"w": "the", "b": [0.7127, 0.6726, 0.7391, 0.694]}, {"w": "mathematical", "b": [0.744, 0.6726, 0.8571, 0.694]}, {"w": "details).", "b": [0.1429, 0.6916, 0.2087, 0.713]}, {"w": "It", "b": [0.2168, 0.6916, 0.2294, 0.713]}, {"w": "is", "b": [0.2375, 0.6916, 0.2507, 0.713]}, {"w": "actually", "b": [0.2588, 0.6916, 0.3234, 0.713]}, {"w": "not", "b": [0.3315, 0.6916, 0.3599, 0.713]}, {"w": "possible", "b": [0.3679, 0.6916, 0.4351, 0.713]}, {"w": "to", "b": [0.4431, 0.6916, 0.4601, 0.713]}, {"w": "guarantee", "b": [0.4682, 0.6916, 0.5501, 0.713]}, {"w": "both", "b": [0.5582, 0.6916, 0.5969, 0.713]}, {"w": "unless", "b": [0.6049, 0.6916, 0.6568, 0.713]}, {"w": "the", "b": [0.6649, 0.6916, 0.6912, 0.713]}, {"w": "layer", "b": [0.6993, 0.6916, 0.7395, 0.713]}, {"w": "has", "b": [0.7476, 0.6916, 0.7755, 0.713]}, {"w": "an", "b": [0.7836, 0.6916, 0.8041, 0.713]}, {"w": "equal", "b": [0.8122, 0.6916, 0.8572, 0.713]}, {"w": "number", "b": [0.1429, 0.7107, 0.2092, 0.7321]}, {"w": "of", "b": [0.2141, 0.7107, 0.2309, 0.7321]}, {"w": "inputs", "b": [0.2358, 0.7107, 0.2884, 0.7321]}, {"w": "and", "b": [0.2934, 0.7107, 0.3249, 0.7321]}, {"w": "neurons", "b": [0.3299, 0.7107, 0.3986, 0.7321]}, {"w": "(these", "b": [0.4035, 0.7107, 0.4536, 0.7321]}, {"w": "numbers", "b": [0.4585, 0.7107, 0.5324, 0.7321]}, {"w": "are", "b": [0.5374, 0.7107, 0.5631, 0.7321]}, {"w": "called", "b": [0.5681, 0.7107, 0.6164, 0.7321]}, {"w": "the", "b": [0.6214, 0.7107, 0.6477, 0.7321]}, {"w": "fan-in", "b": [0.6527, 0.7105, 0.7025, 0.7321]}, {"w": "and", "b": [0.7075, 0.7107, 0.739, 0.7321]}, {"w": "fan-out", "b": [0.744, 0.7105, 0.8041, 0.7321]}, {"w": "of", "b": [0.8091, 0.7107, 0.8259, 0.7321]}, {"w": "the", "b": [0.8306, 0.7107, 0.8569, 0.7321]}, {"w": "layer),", "b": [0.1429, 0.7297, 0.195, 0.7511]}, {"w": "but", "b": [0.202, 0.7297, 0.23, 0.7511]}, {"w": "they", "b": [0.237, 0.7297, 0.2728, 0.7511]}, {"w": "proposed", "b": [0.2798, 0.7297, 0.3581, 0.7511]}, {"w": "a", "b": [0.3651, 0.7297, 0.3742, 0.7511]}, {"w": "good", "b": [0.3812, 0.7297, 0.4232, 0.7511]}, {"w": "compromise", "b": [0.4302, 0.7297, 0.5347, 0.7511]}, {"w": "that", "b": [0.5417, 0.7297, 0.5743, 0.7511]}, {"w": "has", "b": [0.5812, 0.7297, 0.6092, 0.7511]}, {"w": "proven", "b": [0.6161, 0.7297, 0.6753, 0.7511]}, {"w": "to", "b": [0.6823, 0.7297, 0.6993, 0.7511]}, {"w": "work", "b": [0.7062, 0.7297, 0.7492, 0.7511]}, {"w": "very", "b": [0.7562, 0.7297, 0.7926, 0.7511]}, {"w": "well", "b": [0.7995, 0.7297, 0.8332, 0.7511]}, {"w": "in", "b": [0.8402, 0.7297, 0.8571, 0.7511]}, {"w": "practice:", "b": [0.1429, 0.7488, 0.2138, 0.7702]}, {"w": "the", "b": [0.2249, 0.7488, 0.2513, 0.7702]}, {"w": "connection", "b": [0.2624, 0.7488, 0.3562, 0.7702]}, {"w": "weights", "b": [0.3673, 0.7488, 0.4305, 0.7702]}, {"w": "of", "b": [0.4416, 0.7488, 0.4584, 0.7702]}, {"w": "each", "b": [0.4695, 0.7488, 0.5075, 0.7702]}, {"w": "layer", "b": [0.5186, 0.7488, 0.5587, 0.7702]}, {"w": "must", "b": [0.5699, 0.7488, 0.6116, 0.7702]}, {"w": "be", "b": [0.6227, 0.7488, 0.6421, 0.7702]}, {"w": "initialized", "b": [0.6532, 0.7488, 0.7363, 0.7702]}, {"w": "randomly", "b": [0.7474, 0.7488, 0.8292, 0.7702]}, {"w": "as", "b": [0.8403, 0.7488, 0.8571, 0.7702]}]}, {"id": "b_5", "type": "equation", "text": "Vanishing/Exploding Gradients Problems | 327", "words": [{"w": "Vanishing/Exploding", "b": [0.5559, 0.9225, 0.678, 0.9388]}, {"w": "Gradients", "b": [0.6808, 0.9225, 0.7376, 0.9388]}, {"w": "Problems", "b": [0.7404, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "327", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 354, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "3 Such as “Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification,” K. He et al. (2015).", "words": [{"w": "3", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Such", "b": [0.1587, 0.8598, 0.1899, 0.8761]}, {"w": "as", "b": [0.1935, 0.8598, 0.2063, 0.8761]}, {"w": "“Delving", "b": [0.2099, 0.8598, 0.2663, 0.8761]}, {"w": "Deep", "b": [0.2699, 0.8598, 0.3034, 0.8761]}, {"w": "into", "b": [0.307, 0.8598, 0.3326, 0.8761]}, {"w": "Rectifiers:", "b": [0.3362, 0.8598, 0.3996, 0.8761]}, {"w": "Surpassing", "b": [0.4032, 0.8598, 0.4724, 0.8761]}, {"w": "Human-Level", "b": [0.476, 0.8598, 0.5637, 0.8761]}, {"w": "Performance", "b": [0.5673, 0.8598, 0.6491, 0.8761]}, {"w": "on", "b": [0.6527, 0.8598, 0.6695, 0.8761]}, {"w": "ImageNet", "b": [0.6731, 0.8598, 0.7356, 0.8761]}, {"w": "Classification,”", "b": [0.7392, 0.8598, 0.8327, 0.8761]}, {"w": "K.", "b": [0.8363, 0.8598, 0.8506, 0.8761]}, {"w": "He", "b": [0.1587, 0.8749, 0.1772, 0.8912]}, {"w": "et", "b": [0.1808, 0.8749, 0.1924, 0.8912]}, {"w": "al.", "b": [0.196, 0.8749, 0.2106, 0.8912]}, {"w": "(2015).", "b": [0.2142, 0.8749, 0.2593, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "described in Equation 11-1, where f anavg = f anin + f anout /2. This initialization strategy is called Xavier initialization (after the author’s first name) or Glorot initiali‐ zation (after his last name).", "words": [{"w": "described", "b": [0.1429, 0.0791, 0.2229, 0.1005]}, {"w": "in", "b": [0.2324, 0.0791, 0.2494, 0.1005]}, {"w": "Equation", "b": [0.2588, 0.0791, 0.335, 0.1005]}, {"w": "11-1,", "b": [0.3445, 0.0791, 0.3867, 0.1005]}, {"w": "where", "b": [0.3961, 0.0791, 0.4469, 0.1005]}, {"w": "f", "b": [0.4593, 0.0789, 0.465, 0.1005]}, {"w": "anavg", "b": [0.4682, 0.0789, 0.5112, 0.1043]}, {"w": "=", "b": [0.517, 0.0791, 0.5291, 0.1005]}, {"w": "f", "b": [0.545, 0.0789, 0.5507, 0.1005]}, {"w": "anin", "b": [0.5539, 0.0789, 0.5881, 0.1043]}, {"w": "+", "b": [0.5927, 0.0791, 0.6048, 0.1005]}, {"w": "f", "b": [0.6124, 0.0789, 0.618, 0.1005]}, {"w": "anout", "b": [0.6212, 0.0789, 0.6639, 0.1043]}, {"w": "/2.", "b": [0.6723, 0.0791, 0.6951, 0.1005]}, {"w": "This", "b": [0.7045, 0.0791, 0.7417, 0.1005]}, {"w": "initialization", "b": [0.7512, 0.0791, 0.8571, 0.1005]}, {"w": "strategy", "b": [0.1429, 0.1007, 0.2084, 0.1221]}, {"w": "is", "b": [0.2144, 0.1007, 0.2276, 0.1221]}, {"w": "called", "b": [0.2337, 0.1007, 0.282, 0.1221]}, {"w": "Xavier", "b": [0.2881, 0.1005, 0.3418, 0.1221]}, {"w": "initialization", "b": [0.3479, 0.1005, 0.4528, 0.1221]}, {"w": "(after", "b": [0.4588, 0.1007, 0.5043, 0.1221]}, {"w": "the", "b": [0.5103, 0.1007, 0.5367, 0.1221]}, {"w": "author’s", "b": [0.5427, 0.1007, 0.6087, 0.1221]}, {"w": "first", "b": [0.6147, 0.1007, 0.6482, 0.1221]}, {"w": "name)", "b": [0.6542, 0.1007, 0.7079, 0.1221]}, {"w": "or", "b": [0.7139, 0.1007, 0.7323, 0.1221]}, {"w": "Glorot", "b": [0.7383, 0.1005, 0.7902, 0.1221]}, {"w": "initiali‐", "b": [0.7963, 0.1005, 0.8571, 0.1221]}, {"w": "zation", "b": [0.1429, 0.1195, 0.1939, 0.1411]}, {"w": "(after", "b": [0.1986, 0.1197, 0.244, 0.1411]}, {"w": "his", "b": [0.2488, 0.1197, 0.2731, 0.1411]}, {"w": "last", "b": [0.2779, 0.1197, 0.3063, 0.1411]}, {"w": "name).", "b": [0.311, 0.1197, 0.3694, 0.1411]}]}, {"id": "b_2", "type": "paragraph", "text": "Equation 11-1. Glorot initialization (when using the logistic activation function)", "words": [{"w": "Equation", "b": [0.1726, 0.1593, 0.2473, 0.1809]}, {"w": "11-1.", "b": [0.252, 0.1593, 0.2937, 0.1809]}, {"w": "Glorot", "b": [0.2985, 0.1593, 0.3504, 0.1809]}, {"w": "initialization", "b": [0.3551, 0.1593, 0.4601, 0.1809]}, {"w": "(when", "b": [0.4648, 0.1593, 0.5157, 0.1809]}, {"w": "using", "b": [0.5205, 0.1593, 0.5634, 0.1809]}, {"w": "the", "b": [0.5682, 0.1593, 0.5933, 0.1809]}, {"w": "logistic", "b": [0.598, 0.1593, 0.6541, 0.1809]}, {"w": "activation", "b": [0.6589, 0.1593, 0.7401, 0.1809]}, {"w": "function)", "b": [0.7449, 0.1593, 0.8199, 0.1809]}]}, {"id": "b_3", "type": "equation", "text": "Normal distribution with mean 0 and variance σ2 = 1 fanavg", "words": [{"w": "Normal", "b": [0.1726, 0.193, 0.2348, 0.2134]}, {"w": "distribution", "b": [0.2393, 0.193, 0.3341, 0.2134]}, {"w": "with", "b": [0.3386, 0.193, 0.3741, 0.2134]}, {"w": "mean", "b": [0.3787, 0.193, 0.4229, 0.2134]}, {"w": "0", "b": [0.4274, 0.193, 0.4369, 0.2134]}, {"w": "and", "b": [0.4414, 0.193, 0.4715, 0.2134]}, {"w": "variance", "b": [0.476, 0.193, 0.5429, 0.2134]}, {"w": "σ2", "b": [0.5474, 0.1893, 0.5654, 0.2134]}, {"w": "=", "b": [0.5709, 0.193, 0.5824, 0.2134]}, {"w": "1", "b": [0.6074, 0.188, 0.615, 0.2043]}, {"w": "fanavg", "b": [0.5901, 0.2026, 0.6322, 0.225]}]}, {"id": "b_4", "type": "equation", "text": "Or a uniform distribution between −r and + r, with r = 3 fanavg", "words": [{"w": "Or", "b": [0.1726, 0.2346, 0.1948, 0.255]}, {"w": "a", "b": [0.1993, 0.2346, 0.208, 0.255]}, {"w": "uniform", "b": [0.2125, 0.2346, 0.2788, 0.255]}, {"w": "distribution", "b": [0.2833, 0.2346, 0.3781, 0.255]}, {"w": "between", "b": [0.3826, 0.2346, 0.4485, 0.255]}, {"w": "−r", "b": [0.453, 0.2344, 0.4728, 0.255]}, {"w": "and", "b": [0.4777, 0.2346, 0.5078, 0.255]}, {"w": "+", "b": [0.5167, 0.2346, 0.5282, 0.255]}, {"w": "r,", "b": [0.5326, 0.2344, 0.5448, 0.255]}, {"w": "with", "b": [0.5493, 0.2346, 0.5848, 0.255]}, {"w": "r", "b": [0.5893, 0.2344, 0.5966, 0.255]}, {"w": "=", "b": [0.6025, 0.2346, 0.614, 0.255]}, {"w": "3", "b": [0.6511, 0.2296, 0.6587, 0.246]}, {"w": "fanavg", "b": [0.6338, 0.2443, 0.6759, 0.2666]}]}, {"id": "b_5", "type": "paragraph", "text": "If you just replace fanavg with fanin in Equation 11-1, you get an initialization strategy that was actually already proposed by Yann LeCun in the 1990s, called LeCun initiali‐ zation, which was even recommended in the 1998 book Neural Networks: Tricks of the Trade by Genevieve Orr and Klaus-Robert Müller (Springer). It is equivalent to Glorot initialization when fanin = fanout. It took over a decade for researchers to realize just how important this trick really is. Using Glorot initialization can speed up train‐ ing considerably, and it is one of the tricks that led to the current success of Deep Learning.", "words": [{"w": "If", "b": [0.1428, 0.2857, 0.1561, 0.3071]}, {"w": "you", "b": [0.1618, 0.2857, 0.193, 0.3071]}, {"w": "just", "b": [0.1987, 0.2857, 0.229, 0.3071]}, {"w": "replace", "b": [0.2347, 0.2857, 0.2943, 0.3071]}, {"w": "fanavg", "b": [0.2999, 0.2855, 0.3432, 0.308]}, {"w": "with", "b": [0.3489, 0.2857, 0.3862, 0.3071]}, {"w": "fanin", "b": [0.3918, 0.2855, 0.4284, 0.308]}, {"w": "in", "b": [0.4341, 0.2857, 0.451, 0.3071]}, {"w": "Equation", "b": [0.4567, 0.2857, 0.5329, 0.3071]}, {"w": "11-1,", "b": [0.5386, 0.2857, 0.5807, 0.3071]}, {"w": "you", "b": [0.5864, 0.2857, 0.6176, 0.3071]}, {"w": "get", "b": [0.6233, 0.2857, 0.6482, 0.3071]}, {"w": "an", "b": [0.6539, 0.2857, 0.6744, 0.3071]}, {"w": "initialization", "b": [0.68, 0.2857, 0.786, 0.3071]}, {"w": "strategy", "b": [0.7916, 0.2857, 0.8571, 0.3071]}, {"w": "that", "b": [0.1429, 0.3047, 0.1754, 0.3261]}, {"w": "was", "b": [0.1807, 0.3047, 0.2118, 0.3261]}, {"w": "actually", "b": [0.217, 0.3047, 0.2816, 0.3261]}, {"w": "already", "b": [0.2869, 0.3047, 0.3476, 0.3261]}, {"w": "proposed", "b": [0.3529, 0.3047, 0.4312, 0.3261]}, {"w": "by", "b": [0.4364, 0.3047, 0.4566, 0.3261]}, {"w": "Yann", "b": [0.4619, 0.3047, 0.5046, 0.3261]}, {"w": "LeCun", "b": [0.5099, 0.3047, 0.5662, 0.3261]}, {"w": "in", "b": [0.5715, 0.3047, 0.5885, 0.3261]}, {"w": "the", "b": [0.5937, 0.3047, 0.6201, 0.3261]}, {"w": "1990s,", "b": [0.6253, 0.3047, 0.6777, 0.3261]}, {"w": "called", "b": [0.683, 0.3047, 0.7313, 0.3261]}, {"w": "LeCun", "b": [0.7366, 0.3045, 0.791, 0.3261]}, {"w": "initiali‐", "b": [0.7957, 0.3045, 0.8566, 0.3261]}, {"w": "zation,", "b": [0.1428, 0.3236, 0.1986, 0.3452]}, {"w": "which", "b": [0.2036, 0.3238, 0.2545, 0.3452]}, {"w": "was", "b": [0.2595, 0.3238, 0.2905, 0.3452]}, {"w": "even", "b": [0.2955, 0.3238, 0.3343, 0.3452]}, {"w": "recommended", "b": [0.3393, 0.3238, 0.4605, 0.3452]}, {"w": "in", "b": [0.4655, 0.3238, 0.4825, 0.3452]}, {"w": "the", "b": [0.4875, 0.3238, 0.5138, 0.3452]}, {"w": "1998", "b": [0.5188, 0.3238, 0.5588, 0.3452]}, {"w": "book", "b": [0.5638, 0.3238, 0.6059, 0.3452]}, {"w": "Neural", "b": [0.6109, 0.3236, 0.6666, 0.3452]}, {"w": "Networks:", "b": [0.6716, 0.3236, 0.7529, 0.3452]}, {"w": "Tricks", "b": [0.7579, 0.3236, 0.8068, 0.3452]}, {"w": "of", "b": [0.8119, 0.3236, 0.8271, 0.3452]}, {"w": "the", "b": [0.8321, 0.3236, 0.8571, 0.3452]}, {"w": "Trade", "b": [0.1429, 0.3426, 0.19, 0.3642]}, {"w": "by", "b": [0.2, 0.3428, 0.2202, 0.3642]}, {"w": "Genevieve", "b": [0.2302, 0.3428, 0.3168, 0.3642]}, {"w": "Orr", "b": [0.3268, 0.3428, 0.3578, 0.3642]}, {"w": "and", "b": [0.3678, 0.3428, 0.3994, 0.3642]}, {"w": "Klaus-Robert", "b": [0.4094, 0.3428, 0.5207, 0.3642]}, {"w": "Müller", "b": [0.5307, 0.3428, 0.5867, 0.3642]}, {"w": "(Springer).", "b": [0.5968, 0.3428, 0.6878, 0.3642]}, {"w": "It", "b": [0.6978, 0.3428, 0.7104, 0.3642]}, {"w": "is", "b": [0.7205, 0.3428, 0.7337, 0.3642]}, {"w": "equivalent", "b": [0.7437, 0.3428, 0.8301, 0.3642]}, {"w": "to", "b": [0.8402, 0.3428, 0.8571, 0.3642]}, {"w": "Glorot", "b": [0.1429, 0.3619, 0.1984, 0.3833]}, {"w": "initialization", "b": [0.2031, 0.3619, 0.309, 0.3833]}, {"w": "when", "b": [0.3138, 0.3619, 0.3594, 0.3833]}, {"w": "fanin", "b": [0.3642, 0.3617, 0.4008, 0.3842]}, {"w": "=", "b": [0.4055, 0.3619, 0.4176, 0.3833]}, {"w": "fanout.", "b": [0.4224, 0.3617, 0.4703, 0.3842]}, {"w": "It", "b": [0.4751, 0.3619, 0.4877, 0.3833]}, {"w": "took", "b": [0.4924, 0.3619, 0.5304, 0.3833]}, {"w": "over", "b": [0.5351, 0.3619, 0.572, 0.3833]}, {"w": "a", "b": [0.5767, 0.3619, 0.5858, 0.3833]}, {"w": "decade", "b": [0.5906, 0.3619, 0.6482, 0.3833]}, {"w": "for", "b": [0.653, 0.3619, 0.6775, 0.3833]}, {"w": "researchers", "b": [0.6822, 0.3619, 0.7763, 0.3833]}, {"w": "to", "b": [0.7811, 0.3619, 0.798, 0.3833]}, {"w": "realize", "b": [0.8028, 0.3619, 0.857, 0.3833]}, {"w": "just", "b": [0.1429, 0.3809, 0.1733, 0.4023]}, {"w": "how", "b": [0.1789, 0.3809, 0.215, 0.4023]}, {"w": "important", "b": [0.2206, 0.3809, 0.305, 0.4023]}, {"w": "this", "b": [0.3107, 0.3809, 0.3414, 0.4023]}, {"w": "trick", "b": [0.3471, 0.3809, 0.3859, 0.4023]}, {"w": "really", "b": [0.3916, 0.3809, 0.4374, 0.4023]}, {"w": "is.", "b": [0.4431, 0.3809, 0.4611, 0.4023]}, {"w": "Using", "b": [0.4668, 0.3809, 0.5154, 0.4023]}, {"w": "Glorot", "b": [0.521, 0.3809, 0.5765, 0.4023]}, {"w": "initialization", "b": [0.5822, 0.3809, 0.6882, 0.4023]}, {"w": "can", "b": [0.6939, 0.3809, 0.7232, 0.4023]}, {"w": "speed", "b": [0.7289, 0.3809, 0.7762, 0.4023]}, {"w": "up", "b": [0.7819, 0.3809, 0.8038, 0.4023]}, {"w": "train‐", "b": [0.8095, 0.3809, 0.8571, 0.4023]}, {"w": "ing", "b": [0.1429, 0.4, 0.1696, 0.4214]}, {"w": "considerably,", "b": [0.1769, 0.4, 0.2863, 0.4214]}, {"w": "and", "b": [0.2937, 0.4, 0.3252, 0.4214]}, {"w": "it", "b": [0.3325, 0.4, 0.3445, 0.4214]}, {"w": "is", "b": [0.3518, 0.4, 0.365, 0.4214]}, {"w": "one", "b": [0.3723, 0.4, 0.4032, 0.4214]}, {"w": "of", "b": [0.4105, 0.4, 0.4273, 0.4214]}, {"w": "the", "b": [0.4347, 0.4, 0.461, 0.4214]}, {"w": "tricks", "b": [0.4683, 0.4, 0.5148, 0.4214]}, {"w": "that", "b": [0.5221, 0.4, 0.5547, 0.4214]}, {"w": "led", "b": [0.562, 0.4, 0.5871, 0.4214]}, {"w": "to", "b": [0.5945, 0.4, 0.6114, 0.4214]}, {"w": "the", "b": [0.6188, 0.4, 0.6451, 0.4214]}, {"w": "current", "b": [0.6524, 0.4, 0.714, 0.4214]}, {"w": "success", "b": [0.7213, 0.4, 0.7818, 0.4214]}, {"w": "of", "b": [0.7891, 0.4, 0.8059, 0.4214]}, {"w": "Deep", "b": [0.8132, 0.4, 0.8571, 0.4214]}, {"w": "Learning.", "b": [0.1429, 0.419, 0.2227, 0.4404]}]}, {"id": "b_6", "type": "paragraph", "text": "Some papers3 have provided similar strategies for different activation functions. These strategies differ only by the scale of the variance and whether they use fanavg or fanin, as shown in Table 11-1 (for the uniform distribution, just compute r = 3σ2). The initialization strategy for the ReLU activation function (and its variants, includ‐ ing the ELU activation described shortly) is sometimes called He initialization (after the last name of its author). The SELU activation function will be explained later in this chapter. It should be used with LeCun initialization (preferably with a normal distribution, as we will see).", "words": [{"w": "Some", "b": [0.1429, 0.4471, 0.1893, 0.4685]}, {"w": "papers3", "b": [0.1999, 0.4471, 0.2604, 0.4685]}, {"w": "have", "b": [0.2711, 0.4471, 0.3095, 0.4685]}, {"w": "provided", "b": [0.3201, 0.4471, 0.3955, 0.4685]}, {"w": "similar", "b": [0.4061, 0.4471, 0.4641, 0.4685]}, {"w": "strategies", "b": [0.4748, 0.4471, 0.5523, 0.4685]}, {"w": "for", "b": [0.5629, 0.4471, 0.5875, 0.4685]}, {"w": "different", "b": [0.5981, 0.4471, 0.6698, 0.4685]}, {"w": "activation", "b": [0.6805, 0.4471, 0.7627, 0.4685]}, {"w": "functions.", "b": [0.7733, 0.4471, 0.8571, 0.4685]}, {"w": "These", "b": [0.1428, 0.4662, 0.1922, 0.4876]}, {"w": "strategies", "b": [0.1975, 0.4662, 0.2751, 0.4876]}, {"w": "differ", "b": [0.2804, 0.4662, 0.3259, 0.4876]}, {"w": "only", "b": [0.3313, 0.4662, 0.3682, 0.4876]}, {"w": "by", "b": [0.3735, 0.4662, 0.3937, 0.4876]}, {"w": "the", "b": [0.399, 0.4662, 0.4254, 0.4876]}, {"w": "scale", "b": [0.4307, 0.4662, 0.4705, 0.4876]}, {"w": "of", "b": [0.4758, 0.4662, 0.4926, 0.4876]}, {"w": "the", "b": [0.498, 0.4662, 0.5243, 0.4876]}, {"w": "variance", "b": [0.5297, 0.4662, 0.6, 0.4876]}, {"w": "and", "b": [0.6053, 0.4662, 0.6369, 0.4876]}, {"w": "whether", "b": [0.6423, 0.4662, 0.7106, 0.4876]}, {"w": "they", "b": [0.7159, 0.4662, 0.7518, 0.4876]}, {"w": "use", "b": [0.7572, 0.4662, 0.7848, 0.4876]}, {"w": "fanavg", "b": [0.7901, 0.466, 0.8334, 0.4885]}, {"w": "or", "b": [0.8388, 0.4662, 0.8571, 0.4876]}, {"w": "fanin,", "b": [0.1429, 0.4891, 0.1842, 0.5116]}, {"w": "as", "b": [0.191, 0.4893, 0.2078, 0.5107]}, {"w": "shown", "b": [0.2146, 0.4893, 0.2696, 0.5107]}, {"w": "in", "b": [0.2764, 0.4893, 0.2934, 0.5107]}, {"w": "Table", "b": [0.3002, 0.4893, 0.345, 0.5107]}, {"w": "11-1", "b": [0.3518, 0.4893, 0.3892, 0.5107]}, {"w": "(for", "b": [0.396, 0.4893, 0.4277, 0.5107]}, {"w": "the", "b": [0.4345, 0.4893, 0.4608, 0.5107]}, {"w": "uniform", "b": [0.4676, 0.4893, 0.5372, 0.5107]}, {"w": "distribution,", "b": [0.544, 0.4893, 0.6483, 0.5107]}, {"w": "just", "b": [0.6551, 0.4893, 0.6855, 0.5107]}, {"w": "compute", "b": [0.6922, 0.4893, 0.7655, 0.5107]}, {"w": "r", "b": [0.7723, 0.4891, 0.78, 0.5108]}, {"w": "=", "b": [0.7861, 0.4893, 0.7982, 0.5108]}, {"w": "3σ2).", "b": [0.8167, 0.4862, 0.8571, 0.5108]}, {"w": "The", "b": [0.1429, 0.5084, 0.1757, 0.5298]}, {"w": "initialization", "b": [0.1819, 0.5084, 0.2878, 0.5298]}, {"w": "strategy", "b": [0.294, 0.5084, 0.3595, 0.5298]}, {"w": "for", "b": [0.3657, 0.5084, 0.3903, 0.5298]}, {"w": "the", "b": [0.3964, 0.5084, 0.4228, 0.5298]}, {"w": "ReLU", "b": [0.429, 0.5084, 0.4765, 0.5298]}, {"w": "activation", "b": [0.4827, 0.5084, 0.5649, 0.5298]}, {"w": "function", "b": [0.5711, 0.5084, 0.6425, 0.5298]}, {"w": "(and", "b": [0.6487, 0.5084, 0.6874, 0.5298]}, {"w": "its", "b": [0.6936, 0.5084, 0.7132, 0.5298]}, {"w": "variants,", "b": [0.7194, 0.5084, 0.7904, 0.5298]}, {"w": "includ‐", "b": [0.7966, 0.5084, 0.8571, 0.5298]}, {"w": "ing", "b": [0.1429, 0.5274, 0.1696, 0.5488]}, {"w": "the", "b": [0.176, 0.5274, 0.2024, 0.5488]}, {"w": "ELU", "b": [0.2088, 0.5274, 0.2464, 0.5488]}, {"w": "activation", "b": [0.2528, 0.5274, 0.3351, 0.5488]}, {"w": "described", "b": [0.3415, 0.5274, 0.4216, 0.5488]}, {"w": "shortly)", "b": [0.428, 0.5274, 0.4936, 0.5488]}, {"w": "is", "b": [0.5, 0.5274, 0.5132, 0.5488]}, {"w": "sometimes", "b": [0.5197, 0.5274, 0.6094, 0.5488]}, {"w": "called", "b": [0.6158, 0.5274, 0.6642, 0.5488]}, {"w": "He", "b": [0.6707, 0.5272, 0.6938, 0.5488]}, {"w": "initialization", "b": [0.7003, 0.5272, 0.8052, 0.5488]}, {"w": "(after", "b": [0.8117, 0.5274, 0.8571, 0.5488]}, {"w": "the", "b": [0.1429, 0.5465, 0.1692, 0.5679]}, {"w": "last", "b": [0.1757, 0.5465, 0.2041, 0.5679]}, {"w": "name", "b": [0.2105, 0.5465, 0.257, 0.5679]}, {"w": "of", "b": [0.2635, 0.5465, 0.2803, 0.5679]}, {"w": "its", "b": [0.2867, 0.5465, 0.3063, 0.5679]}, {"w": "author).", "b": [0.3128, 0.5465, 0.3804, 0.5679]}, {"w": "The", "b": [0.3869, 0.5465, 0.4197, 0.5679]}, {"w": "SELU", "b": [0.4262, 0.5465, 0.4736, 0.5679]}, {"w": "activation", "b": [0.48, 0.5465, 0.5623, 0.5679]}, {"w": "function", "b": [0.5688, 0.5465, 0.6402, 0.5679]}, {"w": "will", "b": [0.6466, 0.5465, 0.677, 0.5679]}, {"w": "be", "b": [0.6835, 0.5465, 0.7029, 0.5679]}, {"w": "explained", "b": [0.7094, 0.5465, 0.7903, 0.5679]}, {"w": "later", "b": [0.7967, 0.5465, 0.8337, 0.5679]}, {"w": "in", "b": [0.8402, 0.5465, 0.8571, 0.5679]}, {"w": "this", "b": [0.1429, 0.5655, 0.1736, 0.5869]}, {"w": "chapter.", "b": [0.1811, 0.5655, 0.2471, 0.5869]}, {"w": "It", "b": [0.2547, 0.5655, 0.2673, 0.5869]}, {"w": "should", "b": [0.2749, 0.5655, 0.3316, 0.5869]}, {"w": "be", "b": [0.3392, 0.5655, 0.3586, 0.5869]}, {"w": "used", "b": [0.3662, 0.5655, 0.4048, 0.5869]}, {"w": "with", "b": [0.4123, 0.5655, 0.4497, 0.5869]}, {"w": "LeCun", "b": [0.4572, 0.5655, 0.5136, 0.5869]}, {"w": "initialization", "b": [0.5212, 0.5655, 0.6271, 0.5869]}, {"w": "(preferably", "b": [0.6347, 0.5655, 0.7267, 0.5869]}, {"w": "with", "b": [0.7343, 0.5655, 0.7716, 0.5869]}, {"w": "a", "b": [0.7792, 0.5655, 0.7884, 0.5869]}, {"w": "normal", "b": [0.7959, 0.5655, 0.8572, 0.5869]}, {"w": "distribution,", "b": [0.1429, 0.5846, 0.2471, 0.606]}, {"w": "as", "b": [0.2518, 0.5846, 0.2686, 0.606]}, {"w": "we", "b": [0.2734, 0.5846, 0.2965, 0.606]}, {"w": "will", "b": [0.3012, 0.5846, 0.3316, 0.606]}, {"w": "see).", "b": [0.3363, 0.5846, 0.3737, 0.606]}]}, {"id": "b_7", "type": "equation", "text": "Table 11-1. Initialization parameters for each type of activation function", "words": [{"w": "Table", "b": [0.1429, 0.6224, 0.1844, 0.643]}, {"w": "11-1.", "b": [0.189, 0.6224, 0.2287, 0.643]}, {"w": "Initialization", "b": [0.2332, 0.6224, 0.3338, 0.643]}, {"w": "parameters", "b": [0.3384, 0.6224, 0.4246, 0.643]}, {"w": "for", "b": [0.4292, 0.6224, 0.4507, 0.643]}, {"w": "each", "b": [0.4553, 0.6224, 0.4902, 0.643]}, {"w": "type", "b": [0.4947, 0.6224, 0.5273, 0.643]}, {"w": "of", "b": [0.5319, 0.6224, 0.5463, 0.643]}, {"w": "activation", "b": [0.5509, 0.6224, 0.6282, 0.643]}, {"w": "function", "b": [0.6327, 0.6224, 0.6976, 0.643]}]}, {"id": "b_8", "type": "paragraph", "text": "Initialization Activation functions σ² (Normal) Glorot None, Tanh, Logistic, Softmax 1 / fanavg He ReLU & variants 2 / fanin LeCun SELU 1 / fanin", "words": [{"w": "Initialization", "b": [0.15, 0.651, 0.2256, 0.6673]}, {"w": "Activation", "b": [0.2399, 0.651, 0.2998, 0.6673]}, {"w": "functions", "b": [0.3032, 0.651, 0.3582, 0.6673]}, {"w": "σ²", "b": [0.4182, 0.651, 0.4302, 0.6673]}, {"w": "(Normal)", "b": [0.4336, 0.651, 0.4863, 0.6673]}, {"w": "Glorot", "b": [0.15, 0.6713, 0.1839, 0.6874]}, {"w": "None,", "b": [0.2399, 0.6713, 0.2722, 0.6874]}, {"w": "Tanh,", "b": [0.2756, 0.6713, 0.3063, 0.6874]}, {"w": "Logistic,", "b": [0.3097, 0.6713, 0.355, 0.6874]}, {"w": "Softmax", "b": [0.3584, 0.6713, 0.4039, 0.6874]}, {"w": "1", "b": [0.4182, 0.6713, 0.4251, 0.6874]}, {"w": "/", "b": [0.4285, 0.6713, 0.4335, 0.6874]}, {"w": "fanavg", "b": [0.4369, 0.6713, 0.4686, 0.6892]}, {"w": "He", "b": [0.15, 0.6923, 0.1647, 0.7085]}, {"w": "ReLU", "b": [0.2399, 0.6923, 0.2679, 0.7085]}, {"w": "&", "b": [0.2713, 0.6923, 0.2801, 0.7085]}, {"w": "variants", "b": [0.2835, 0.6923, 0.3274, 0.7085]}, {"w": "2", "b": [0.4182, 0.6923, 0.4251, 0.7085]}, {"w": "/", "b": [0.4285, 0.6923, 0.4335, 0.7085]}, {"w": "fanin", "b": [0.4369, 0.6924, 0.4621, 0.7102]}, {"w": "LeCun", "b": [0.15, 0.7134, 0.1836, 0.7295]}, {"w": "SELU", "b": [0.2399, 0.7134, 0.2669, 0.7295]}, {"w": "1", "b": [0.4182, 0.7134, 0.4251, 0.7295]}, {"w": "/", "b": [0.4285, 0.7134, 0.4335, 0.7295]}, {"w": "fanin", "b": [0.4369, 0.7134, 0.4621, 0.7312]}]}, {"id": "b_9", "type": "paragraph", "text": "By default, Keras uses Glorot initialization with a uniform distribution. You can change this to He initialization by setting kernel_initializer=\"he_uniform\" or ker nel_initializer=\"he_normal\" when creating a layer, like this:", "words": [{"w": "By", "b": [0.1429, 0.7499, 0.1647, 0.7713]}, {"w": "default,", "b": [0.1742, 0.7499, 0.2364, 0.7713]}, {"w": "Keras", "b": [0.2459, 0.7499, 0.2928, 0.7713]}, {"w": "uses", "b": [0.3023, 0.7499, 0.3375, 0.7713]}, {"w": "Glorot", "b": [0.347, 0.7499, 0.4025, 0.7713]}, {"w": "initialization", "b": [0.412, 0.7499, 0.518, 0.7713]}, {"w": "with", "b": [0.5275, 0.7499, 0.5649, 0.7713]}, {"w": "a", "b": [0.5744, 0.7499, 0.5835, 0.7713]}, {"w": "uniform", "b": [0.593, 0.7499, 0.6626, 0.7713]}, {"w": "distribution.", "b": [0.6722, 0.7499, 0.7764, 0.7713]}, {"w": "You", "b": [0.7859, 0.7499, 0.8183, 0.7713]}, {"w": "can", "b": [0.8278, 0.7499, 0.8571, 0.7713]}, {"w": "change", "b": [0.1429, 0.7698, 0.2019, 0.7912]}, {"w": "this", "b": [0.207, 0.7698, 0.2378, 0.7912]}, {"w": "to", "b": [0.2429, 0.7698, 0.2598, 0.7912]}, {"w": "He", "b": [0.265, 0.7698, 0.2893, 0.7912]}, {"w": "initialization", "b": [0.2944, 0.7698, 0.4003, 0.7912]}, {"w": "by", "b": [0.4054, 0.7698, 0.4256, 0.7912]}, {"w": "setting", "b": [0.4307, 0.7698, 0.4866, 0.7912]}, {"w": "kernel_initializer=\"he_uniform\"", "b": [0.4917, 0.773, 0.7985, 0.7881]}, {"w": "or", "b": [0.8036, 0.7698, 0.822, 0.7912]}, {"w": "ker", "b": [0.8271, 0.773, 0.8568, 0.7881]}, {"w": "nel_initializer=\"he_normal\"", "b": [0.1429, 0.793, 0.41, 0.808]}, {"w": "when", "b": [0.4148, 0.7898, 0.4604, 0.8112]}, {"w": "creating", "b": [0.4651, 0.7898, 0.5324, 0.8112]}, {"w": "a", "b": [0.5371, 0.7898, 0.5463, 0.8112]}, {"w": "layer,", "b": [0.551, 0.7898, 0.5946, 0.8112]}, {"w": "like", "b": [0.5993, 0.7898, 0.6294, 0.8112]}, {"w": "this:", "b": [0.6341, 0.7898, 0.6696, 0.8112]}]}, {"id": "b_10", "type": "paragraph", "text": "328 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "328", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2745, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 355, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "4 Unless it is part of the first hidden layer, a dead neuron may sometimes come back to life: gradient descent may indeed tweak neurons in the layers below in such a way that the weighted sum of the dead neuron’s inputs is positive again.", "words": [{"w": "4", "b": [0.1451, 0.8265, 0.1518, 0.8408]}, {"w": "Unless", "b": [0.1587, 0.825, 0.2008, 0.8413]}, {"w": "it", "b": [0.2044, 0.825, 0.2135, 0.8413]}, {"w": "is", "b": [0.2171, 0.825, 0.2272, 0.8413]}, {"w": "part", "b": [0.2308, 0.825, 0.2568, 0.8413]}, {"w": "of", "b": [0.2604, 0.825, 0.2732, 0.8413]}, {"w": "the", "b": [0.2768, 0.825, 0.2969, 0.8413]}, {"w": "first", "b": [0.3005, 0.825, 0.326, 0.8413]}, {"w": "hidden", "b": [0.3296, 0.825, 0.3745, 0.8413]}, {"w": "layer,", "b": [0.3781, 0.825, 0.4114, 0.8413]}, {"w": "a", "b": [0.415, 0.825, 0.4219, 0.8413]}, {"w": "dead", "b": [0.4255, 0.825, 0.456, 0.8413]}, {"w": "neuron", "b": [0.4596, 0.825, 0.5061, 0.8413]}, {"w": "may", "b": [0.5097, 0.825, 0.5367, 0.8413]}, {"w": "sometimes", "b": [0.5403, 0.825, 0.6087, 0.8413]}, {"w": "come", "b": [0.6123, 0.825, 0.6468, 0.8413]}, {"w": "back", "b": [0.6504, 0.825, 0.68, 0.8413]}, {"w": "to", "b": [0.6836, 0.825, 0.6966, 0.8413]}, {"w": "life:", "b": [0.7002, 0.825, 0.7235, 0.8413]}, {"w": "gradient", "b": [0.7271, 0.825, 0.78, 0.8413]}, {"w": "descent", "b": [0.7836, 0.825, 0.8312, 0.8413]}, {"w": "may", "b": [0.1587, 0.8401, 0.1857, 0.8565]}, {"w": "indeed", "b": [0.1893, 0.8401, 0.2325, 0.8565]}, {"w": "tweak", "b": [0.2361, 0.8401, 0.2734, 0.8565]}, {"w": "neurons", "b": [0.277, 0.8401, 0.3293, 0.8565]}, {"w": "in", "b": [0.333, 0.8401, 0.3459, 0.8565]}, {"w": "the", "b": [0.3495, 0.8401, 0.3696, 0.8565]}, {"w": "layers", "b": [0.3732, 0.8401, 0.4096, 0.8565]}, {"w": "below", "b": [0.4132, 0.8401, 0.451, 0.8565]}, {"w": "in", "b": [0.4546, 0.8401, 0.4675, 0.8565]}, {"w": "such", "b": [0.4711, 0.8401, 0.5006, 0.8565]}, {"w": "a", "b": [0.5042, 0.8401, 0.5112, 0.8565]}, {"w": "way", "b": [0.5148, 0.8401, 0.5396, 0.8565]}, {"w": "that", "b": [0.5432, 0.8401, 0.568, 0.8565]}, {"w": "the", "b": [0.5716, 0.8401, 0.5917, 0.8565]}, {"w": "weighted", "b": [0.5953, 0.8401, 0.6527, 0.8565]}, {"w": "sum", "b": [0.6563, 0.8401, 0.6836, 0.8565]}, {"w": "of", "b": [0.6872, 0.8401, 0.7, 0.8565]}, {"w": "the", "b": [0.7036, 0.8401, 0.7237, 0.8565]}, {"w": "dead", "b": [0.7273, 0.8401, 0.7577, 0.8565]}, {"w": "neuron’s", "b": [0.7613, 0.8401, 0.8144, 0.8565]}, {"w": "inputs", "b": [0.1587, 0.8553, 0.1988, 0.8716]}, {"w": "is", "b": [0.2024, 0.8553, 0.2125, 0.8716]}, {"w": "positive", "b": [0.2161, 0.8553, 0.2657, 0.8716]}, {"w": "again.", "b": [0.2693, 0.8553, 0.3073, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "5 “Empirical Evaluation of Rectified Activations in Convolution Network,” B. Xu et al. (2015).", "words": [{"w": "5", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Empirical", "b": [0.1587, 0.8749, 0.2272, 0.8912]}, {"w": "Evaluation", "b": [0.2308, 0.8749, 0.2988, 0.8912]}, {"w": "of", "b": [0.3024, 0.8749, 0.3152, 0.8912]}, {"w": "Rectified", "b": [0.3188, 0.8749, 0.3753, 0.8912]}, {"w": "Activations", "b": [0.3789, 0.8749, 0.451, 0.8912]}, {"w": "in", "b": [0.4546, 0.8749, 0.4675, 0.8912]}, {"w": "Convolution", "b": [0.4711, 0.8749, 0.5518, 0.8912]}, {"w": "Network,”", "b": [0.5554, 0.8749, 0.6189, 0.8912]}, {"w": "B.", "b": [0.6225, 0.8749, 0.6352, 0.8912]}, {"w": "Xu", "b": [0.6388, 0.8749, 0.6571, 0.8912]}, {"w": "et", "b": [0.6607, 0.8749, 0.6723, 0.8912]}, {"w": "al.", "b": [0.6759, 0.8749, 0.6905, 0.8912]}, {"w": "(2015).", "b": [0.6941, 0.8749, 0.7391, 0.8912]}]}, {"id": "b_2", "type": "equation", "text": "keras.layers.Dense(10, activation=\"relu\", kernel_initializer=\"he_normal\")", "words": [{"w": "keras.layers.Dense(10,", "b": [0.1766, 0.0829, 0.3621, 0.0958]}, {"w": "activation=\"relu\",", "b": [0.3705, 0.0829, 0.5223, 0.0958]}, {"w": "kernel_initializer=\"he_normal\")", "b": [0.5308, 0.0829, 0.7922, 0.0958]}]}, {"id": "b_3", "type": "paragraph", "text": "If you want He initialization with a uniform distribution, but based on fanavg rather than fanin, you can use the VarianceScaling initializer like this:", "words": [{"w": "If", "b": [0.1429, 0.1036, 0.1561, 0.125]}, {"w": "you", "b": [0.1628, 0.1036, 0.1941, 0.125]}, {"w": "want", "b": [0.2008, 0.1036, 0.2416, 0.125]}, {"w": "He", "b": [0.2483, 0.1036, 0.2726, 0.125]}, {"w": "initialization", "b": [0.2793, 0.1036, 0.3853, 0.125]}, {"w": "with", "b": [0.392, 0.1036, 0.4293, 0.125]}, {"w": "a", "b": [0.436, 0.1036, 0.4452, 0.125]}, {"w": "uniform", "b": [0.4519, 0.1036, 0.5215, 0.125]}, {"w": "distribution,", "b": [0.5282, 0.1036, 0.6325, 0.125]}, {"w": "but", "b": [0.6392, 0.1036, 0.6672, 0.125]}, {"w": "based", "b": [0.6739, 0.1036, 0.7211, 0.125]}, {"w": "on", "b": [0.7279, 0.1036, 0.7499, 0.125]}, {"w": "fanavg", "b": [0.7566, 0.1033, 0.7999, 0.1259]}, {"w": "rather", "b": [0.8066, 0.1036, 0.8571, 0.125]}, {"w": "than", "b": [0.1428, 0.1235, 0.1809, 0.1449]}, {"w": "fanin,", "b": [0.1856, 0.1233, 0.2269, 0.1458]}, {"w": "you", "b": [0.2317, 0.1235, 0.2629, 0.1449]}, {"w": "can", "b": [0.2677, 0.1235, 0.297, 0.1449]}, {"w": "use", "b": [0.3017, 0.1235, 0.3293, 0.1449]}, {"w": "the", "b": [0.334, 0.1235, 0.3604, 0.1449]}, {"w": "VarianceScaling", "b": [0.3651, 0.1267, 0.5135, 0.1418]}, {"w": "initializer", "b": [0.5183, 0.1235, 0.5981, 0.1449]}, {"w": "like", "b": [0.6028, 0.1235, 0.6329, 0.1449]}, {"w": "this:", "b": [0.6376, 0.1235, 0.673, 0.1449]}]}, {"id": "b_4", "type": "paragraph", "text": "he_avg_init = keras.initializers.VarianceScaling(scale=2., mode='fan_avg', distribution='uniform') keras.layers.Dense(10, activation=\"sigmoid\", kernel_initializer=he_avg_init)", "words": [{"w": "he_avg_init", "b": [0.1766, 0.1555, 0.2693, 0.1683]}, {"w": "=", "b": [0.2778, 0.1555, 0.2862, 0.1683]}, {"w": "keras.initializers.VarianceScaling(scale=2.,", "b": [0.2946, 0.1555, 0.6657, 0.1683]}, {"w": "mode='fan_avg',", "b": [0.6741, 0.1555, 0.8006, 0.1683]}, {"w": "distribution='uniform')", "b": [0.5898, 0.1709, 0.7837, 0.1837]}, {"w": "keras.layers.Dense(10,", "b": [0.1766, 0.1863, 0.3621, 0.1992]}, {"w": "activation=\"sigmoid\",", "b": [0.3705, 0.1863, 0.5476, 0.1992]}, {"w": "kernel_initializer=he_avg_init)", "b": [0.5561, 0.1863, 0.8175, 0.1992]}]}, {"id": "b_5", "type": "paragraph", "text": "Nonsaturating Activation Functions", "words": [{"w": "Nonsaturating", "b": [0.1429, 0.213, 0.2922, 0.2416]}, {"w": "Activation", "b": [0.2972, 0.213, 0.4022, 0.2416]}, {"w": "Functions", "b": [0.4072, 0.213, 0.5069, 0.2416]}]}, {"id": "b_6", "type": "paragraph", "text": "One of the insights in the 2010 paper by Glorot and Bengio was that the vanishing/ exploding gradients problems were in part due to a poor choice of activation func‐ tion. Until then most people had assumed that if Mother Nature had chosen to use roughly sigmoid activation functions in biological neurons, they must be an excellent choice. But it turns out that other activation functions behave much better in deep neural networks, in particular the ReLU activation function, mostly because it does not saturate for positive values (and also because it is quite fast to compute).", "words": [{"w": "One", "b": [0.1429, 0.2475, 0.1787, 0.2689]}, {"w": "of", "b": [0.1851, 0.2475, 0.2019, 0.2689]}, {"w": "the", "b": [0.2083, 0.2475, 0.2346, 0.2689]}, {"w": "insights", "b": [0.241, 0.2475, 0.3057, 0.2689]}, {"w": "in", "b": [0.3121, 0.2475, 0.3291, 0.2689]}, {"w": "the", "b": [0.3355, 0.2475, 0.3618, 0.2689]}, {"w": "2010", "b": [0.3682, 0.2475, 0.4082, 0.2689]}, {"w": "paper", "b": [0.4146, 0.2475, 0.4618, 0.2689]}, {"w": "by", "b": [0.4682, 0.2475, 0.4883, 0.2689]}, {"w": "Glorot", "b": [0.4947, 0.2475, 0.5502, 0.2689]}, {"w": "and", "b": [0.5566, 0.2475, 0.5881, 0.2689]}, {"w": "Bengio", "b": [0.5945, 0.2475, 0.6534, 0.2689]}, {"w": "was", "b": [0.6598, 0.2475, 0.6909, 0.2689]}, {"w": "that", "b": [0.6973, 0.2475, 0.7299, 0.2689]}, {"w": "the", "b": [0.7363, 0.2475, 0.7626, 0.2689]}, {"w": "vanishing/", "b": [0.769, 0.2475, 0.8571, 0.2689]}, {"w": "exploding", "b": [0.1429, 0.2665, 0.2261, 0.2879]}, {"w": "gradients", "b": [0.233, 0.2665, 0.3101, 0.2879]}, {"w": "problems", "b": [0.317, 0.2665, 0.3957, 0.2879]}, {"w": "were", "b": [0.4026, 0.2665, 0.4423, 0.2879]}, {"w": "in", "b": [0.4492, 0.2665, 0.4662, 0.2879]}, {"w": "part", "b": [0.4731, 0.2665, 0.5072, 0.2879]}, {"w": "due", "b": [0.5141, 0.2665, 0.545, 0.2879]}, {"w": "to", "b": [0.552, 0.2665, 0.5689, 0.2879]}, {"w": "a", "b": [0.5758, 0.2665, 0.585, 0.2879]}, {"w": "poor", "b": [0.5919, 0.2665, 0.6318, 0.2879]}, {"w": "choice", "b": [0.6387, 0.2665, 0.6925, 0.2879]}, {"w": "of", "b": [0.6994, 0.2665, 0.7162, 0.2879]}, {"w": "activation", "b": [0.7231, 0.2665, 0.8054, 0.2879]}, {"w": "func‐", "b": [0.8123, 0.2665, 0.8571, 0.2879]}, {"w": "tion.", "b": [0.1429, 0.2856, 0.1816, 0.307]}, {"w": "Until", "b": [0.1884, 0.2856, 0.231, 0.307]}, {"w": "then", "b": [0.2378, 0.2856, 0.2756, 0.307]}, {"w": "most", "b": [0.2824, 0.2856, 0.3241, 0.307]}, {"w": "people", "b": [0.3309, 0.2856, 0.3863, 0.307]}, {"w": "had", "b": [0.3931, 0.2856, 0.4244, 0.307]}, {"w": "assumed", "b": [0.4312, 0.2856, 0.5036, 0.307]}, {"w": "that", "b": [0.5104, 0.2856, 0.543, 0.307]}, {"w": "if", "b": [0.5498, 0.2856, 0.5616, 0.307]}, {"w": "Mother", "b": [0.5684, 0.2856, 0.6311, 0.307]}, {"w": "Nature", "b": [0.6379, 0.2856, 0.6956, 0.307]}, {"w": "had", "b": [0.7024, 0.2856, 0.7337, 0.307]}, {"w": "chosen", "b": [0.7405, 0.2856, 0.799, 0.307]}, {"w": "to", "b": [0.8058, 0.2856, 0.8228, 0.307]}, {"w": "use", "b": [0.8296, 0.2856, 0.8571, 0.307]}, {"w": "roughly", "b": [0.1429, 0.3046, 0.208, 0.326]}, {"w": "sigmoid", "b": [0.2133, 0.3046, 0.2805, 0.326]}, {"w": "activation", "b": [0.2858, 0.3046, 0.3681, 0.326]}, {"w": "functions", "b": [0.3734, 0.3046, 0.4524, 0.326]}, {"w": "in", "b": [0.4577, 0.3046, 0.4747, 0.326]}, {"w": "biological", "b": [0.48, 0.3046, 0.5612, 0.326]}, {"w": "neurons,", "b": [0.5665, 0.3046, 0.64, 0.326]}, {"w": "they", "b": [0.6453, 0.3046, 0.6812, 0.326]}, {"w": "must", "b": [0.6865, 0.3046, 0.7282, 0.326]}, {"w": "be", "b": [0.7335, 0.3046, 0.7529, 0.326]}, {"w": "an", "b": [0.7582, 0.3046, 0.7788, 0.326]}, {"w": "excellent", "b": [0.784, 0.3046, 0.8572, 0.326]}, {"w": "choice.", "b": [0.1429, 0.3237, 0.2014, 0.3451]}, {"w": "But", "b": [0.2085, 0.3237, 0.2382, 0.3451]}, {"w": "it", "b": [0.2453, 0.3237, 0.2573, 0.3451]}, {"w": "turns", "b": [0.2644, 0.3237, 0.3086, 0.3451]}, {"w": "out", "b": [0.3157, 0.3237, 0.3437, 0.3451]}, {"w": "that", "b": [0.3508, 0.3237, 0.3834, 0.3451]}, {"w": "other", "b": [0.3905, 0.3237, 0.4352, 0.3451]}, {"w": "activation", "b": [0.4423, 0.3237, 0.5246, 0.3451]}, {"w": "functions", "b": [0.5317, 0.3237, 0.6107, 0.3451]}, {"w": "behave", "b": [0.6179, 0.3237, 0.6757, 0.3451]}, {"w": "much", "b": [0.6828, 0.3237, 0.7305, 0.3451]}, {"w": "better", "b": [0.7376, 0.3237, 0.7863, 0.3451]}, {"w": "in", "b": [0.7934, 0.3237, 0.8104, 0.3451]}, {"w": "deep", "b": [0.8175, 0.3237, 0.8571, 0.3451]}, {"w": "neural", "b": [0.1429, 0.3427, 0.1963, 0.3641]}, {"w": "networks,", "b": [0.2033, 0.3427, 0.2852, 0.3641]}, {"w": "in", "b": [0.2922, 0.3427, 0.3092, 0.3641]}, {"w": "particular", "b": [0.3162, 0.3427, 0.3979, 0.3641]}, {"w": "the", "b": [0.4049, 0.3427, 0.4312, 0.3641]}, {"w": "ReLU", "b": [0.4382, 0.3427, 0.4857, 0.3641]}, {"w": "activation", "b": [0.4927, 0.3427, 0.575, 0.3641]}, {"w": "function,", "b": [0.5819, 0.3427, 0.6581, 0.3641]}, {"w": "mostly", "b": [0.6651, 0.3427, 0.7216, 0.3641]}, {"w": "because", "b": [0.7286, 0.3427, 0.7931, 0.3641]}, {"w": "it", "b": [0.8001, 0.3427, 0.812, 0.3641]}, {"w": "does", "b": [0.819, 0.3427, 0.8571, 0.3641]}, {"w": "not", "b": [0.1428, 0.3618, 0.1712, 0.3832]}, {"w": "saturate", "b": [0.176, 0.3618, 0.2415, 0.3832]}, {"w": "for", "b": [0.2462, 0.3618, 0.2707, 0.3832]}, {"w": "positive", "b": [0.2754, 0.3618, 0.3406, 0.3832]}, {"w": "values", "b": [0.3454, 0.3618, 0.397, 0.3832]}, {"w": "(and", "b": [0.4017, 0.3618, 0.4405, 0.3832]}, {"w": "also", "b": [0.4452, 0.3618, 0.4779, 0.3832]}, {"w": "because", "b": [0.4826, 0.3618, 0.5472, 0.3832]}, {"w": "it", "b": [0.5519, 0.3618, 0.5638, 0.3832]}, {"w": "is", "b": [0.5686, 0.3618, 0.5818, 0.3832]}, {"w": "quite", "b": [0.5865, 0.3618, 0.629, 0.3832]}, {"w": "fast", "b": [0.6338, 0.3618, 0.6631, 0.3832]}, {"w": "to", "b": [0.6678, 0.3618, 0.6848, 0.3832]}, {"w": "compute).", "b": [0.6895, 0.3618, 0.7748, 0.3832]}]}, {"id": "b_7", "type": "paragraph", "text": "Unfortunately, the ReLU activation function is not perfect. It suffers from a problem known as the dying ReLUs: during training, some neurons effectively die, meaning they stop outputting anything other than 0. In some cases, you may find that half of your network’s neurons are dead, especially if you used a large learning rate. A neu‐ ron dies when its weights get tweaked in such a way that the weighted sum of its inputs are negative for all instances in the training set. When this happens, it just keeps outputting 0s, and gradient descent does not affect it anymore since the gradi‐ ent of the ReLU function is 0 when its input is negative.4", "words": [{"w": "Unfortunately,", "b": [0.1428, 0.3899, 0.264, 0.4113]}, {"w": "the", "b": [0.27, 0.3899, 0.2964, 0.4113]}, {"w": "ReLU", "b": [0.3024, 0.3899, 0.3499, 0.4113]}, {"w": "activation", "b": [0.3558, 0.3899, 0.4381, 0.4113]}, {"w": "function", "b": [0.4441, 0.3899, 0.5155, 0.4113]}, {"w": "is", "b": [0.5215, 0.3899, 0.5347, 0.4113]}, {"w": "not", "b": [0.5407, 0.3899, 0.5691, 0.4113]}, {"w": "perfect.", "b": [0.5751, 0.3899, 0.6375, 0.4113]}, {"w": "It", "b": [0.6435, 0.3899, 0.6561, 0.4113]}, {"w": "suffers", "b": [0.6621, 0.3899, 0.7174, 0.4113]}, {"w": "from", "b": [0.7234, 0.3899, 0.765, 0.4113]}, {"w": "a", "b": [0.771, 0.3899, 0.7801, 0.4113]}, {"w": "problem", "b": [0.7861, 0.3899, 0.8571, 0.4113]}, {"w": "known", "b": [0.1429, 0.4089, 0.2009, 0.4303]}, {"w": "as", "b": [0.2084, 0.4089, 0.2252, 0.4303]}, {"w": "the", "b": [0.2328, 0.4089, 0.2591, 0.4303]}, {"w": "dying", "b": [0.2667, 0.4087, 0.3114, 0.4303]}, {"w": "ReLUs:", "b": [0.319, 0.4087, 0.3757, 0.4303]}, {"w": "during", "b": [0.3832, 0.4089, 0.4398, 0.4303]}, {"w": "training,", "b": [0.4473, 0.4089, 0.519, 0.4303]}, {"w": "some", "b": [0.5266, 0.4089, 0.5707, 0.4303]}, {"w": "neurons", "b": [0.5783, 0.4089, 0.647, 0.4303]}, {"w": "effectively", "b": [0.6545, 0.4089, 0.7387, 0.4303]}, {"w": "die,", "b": [0.7462, 0.4089, 0.7764, 0.4303]}, {"w": "meaning", "b": [0.784, 0.4089, 0.8571, 0.4303]}, {"w": "they", "b": [0.1429, 0.428, 0.1788, 0.4494]}, {"w": "stop", "b": [0.1848, 0.428, 0.2203, 0.4494]}, {"w": "outputting", "b": [0.2264, 0.428, 0.3158, 0.4494]}, {"w": "anything", "b": [0.3219, 0.428, 0.3957, 0.4494]}, {"w": "other", "b": [0.4018, 0.428, 0.4465, 0.4494]}, {"w": "than", "b": [0.4525, 0.428, 0.4905, 0.4494]}, {"w": "0.", "b": [0.4966, 0.428, 0.5113, 0.4494]}, {"w": "In", "b": [0.5174, 0.428, 0.5359, 0.4494]}, {"w": "some", "b": [0.5419, 0.428, 0.5861, 0.4494]}, {"w": "cases,", "b": [0.5921, 0.428, 0.639, 0.4494]}, {"w": "you", "b": [0.645, 0.428, 0.6763, 0.4494]}, {"w": "may", "b": [0.6823, 0.428, 0.7177, 0.4494]}, {"w": "find", "b": [0.7238, 0.428, 0.7579, 0.4494]}, {"w": "that", "b": [0.764, 0.428, 0.7966, 0.4494]}, {"w": "half", "b": [0.8026, 0.428, 0.8343, 0.4494]}, {"w": "of", "b": [0.8404, 0.428, 0.8571, 0.4494]}, {"w": "your", "b": [0.1429, 0.447, 0.1818, 0.4684]}, {"w": "network’s", "b": [0.188, 0.447, 0.2671, 0.4684]}, {"w": "neurons", "b": [0.2733, 0.447, 0.342, 0.4684]}, {"w": "are", "b": [0.3482, 0.447, 0.3739, 0.4684]}, {"w": "dead,", "b": [0.3802, 0.447, 0.4249, 0.4684]}, {"w": "especially", "b": [0.4311, 0.447, 0.511, 0.4684]}, {"w": "if", "b": [0.5173, 0.447, 0.529, 0.4684]}, {"w": "you", "b": [0.5352, 0.447, 0.5665, 0.4684]}, {"w": "used", "b": [0.5727, 0.447, 0.6113, 0.4684]}, {"w": "a", "b": [0.6175, 0.447, 0.6266, 0.4684]}, {"w": "large", "b": [0.6328, 0.447, 0.6736, 0.4684]}, {"w": "learning", "b": [0.6798, 0.447, 0.7489, 0.4684]}, {"w": "rate.", "b": [0.7551, 0.447, 0.7916, 0.4684]}, {"w": "A", "b": [0.7978, 0.447, 0.8122, 0.4684]}, {"w": "neu‐", "b": [0.8184, 0.447, 0.8571, 0.4684]}, {"w": "ron", "b": [0.1429, 0.4661, 0.1726, 0.4875]}, {"w": "dies", "b": [0.1805, 0.4661, 0.2135, 0.4875]}, {"w": "when", "b": [0.2214, 0.4661, 0.267, 0.4875]}, {"w": "its", "b": [0.2749, 0.4661, 0.2944, 0.4875]}, {"w": "weights", "b": [0.3023, 0.4661, 0.3655, 0.4875]}, {"w": "get", "b": [0.3733, 0.4661, 0.3983, 0.4875]}, {"w": "tweaked", "b": [0.4061, 0.4661, 0.4749, 0.4875]}, {"w": "in", "b": [0.4828, 0.4661, 0.4997, 0.4875]}, {"w": "such", "b": [0.5076, 0.4661, 0.5462, 0.4875]}, {"w": "a", "b": [0.5541, 0.4661, 0.5632, 0.4875]}, {"w": "way", "b": [0.5711, 0.4661, 0.6037, 0.4875]}, {"w": "that", "b": [0.6115, 0.4661, 0.6441, 0.4875]}, {"w": "the", "b": [0.6519, 0.4661, 0.6783, 0.4875]}, {"w": "weighted", "b": [0.6861, 0.4661, 0.7615, 0.4875]}, {"w": "sum", "b": [0.7693, 0.4661, 0.8051, 0.4875]}, {"w": "of", "b": [0.8129, 0.4661, 0.8297, 0.4875]}, {"w": "its", "b": [0.8376, 0.4661, 0.8572, 0.4875]}, {"w": "inputs", "b": [0.1429, 0.4851, 0.1954, 0.5065]}, {"w": "are", "b": [0.2032, 0.4851, 0.2289, 0.5065]}, {"w": "negative", "b": [0.2367, 0.4851, 0.3059, 0.5065]}, {"w": "for", "b": [0.3137, 0.4851, 0.3382, 0.5065]}, {"w": "all", "b": [0.346, 0.4851, 0.3657, 0.5065]}, {"w": "instances", "b": [0.3734, 0.4851, 0.4503, 0.5065]}, {"w": "in", "b": [0.4581, 0.4851, 0.475, 0.5065]}, {"w": "the", "b": [0.4828, 0.4851, 0.5091, 0.5065]}, {"w": "training", "b": [0.5169, 0.4851, 0.5839, 0.5065]}, {"w": "set.", "b": [0.5916, 0.4851, 0.6192, 0.5065]}, {"w": "When", "b": [0.627, 0.4851, 0.6786, 0.5065]}, {"w": "this", "b": [0.6864, 0.4851, 0.7171, 0.5065]}, {"w": "happens,", "b": [0.7249, 0.4851, 0.7993, 0.5065]}, {"w": "it", "b": [0.807, 0.4851, 0.819, 0.5065]}, {"w": "just", "b": [0.8268, 0.4851, 0.8571, 0.5065]}, {"w": "keeps", "b": [0.1429, 0.5042, 0.1895, 0.5256]}, {"w": "outputting", "b": [0.1952, 0.5042, 0.2847, 0.5256]}, {"w": "0s,", "b": [0.2905, 0.5042, 0.3129, 0.5256]}, {"w": "and", "b": [0.3187, 0.5042, 0.3502, 0.5256]}, {"w": "gradient", "b": [0.356, 0.5042, 0.4254, 0.5256]}, {"w": "descent", "b": [0.4312, 0.5042, 0.4937, 0.5256]}, {"w": "does", "b": [0.4995, 0.5042, 0.5377, 0.5256]}, {"w": "not", "b": [0.5434, 0.5042, 0.5718, 0.5256]}, {"w": "affect", "b": [0.5776, 0.5042, 0.6231, 0.5256]}, {"w": "it", "b": [0.6289, 0.5042, 0.6408, 0.5256]}, {"w": "anymore", "b": [0.6466, 0.5042, 0.7205, 0.5256]}, {"w": "since", "b": [0.7263, 0.5042, 0.7686, 0.5256]}, {"w": "the", "b": [0.7744, 0.5042, 0.8007, 0.5256]}, {"w": "gradi‐", "b": [0.8065, 0.5042, 0.8571, 0.5256]}, {"w": "ent", "b": [0.1428, 0.5232, 0.1691, 0.5446]}, {"w": "of", "b": [0.1738, 0.5232, 0.1906, 0.5446]}, {"w": "the", "b": [0.1953, 0.5232, 0.2216, 0.5446]}, {"w": "ReLU", "b": [0.2264, 0.5232, 0.2739, 0.5446]}, {"w": "function", "b": [0.2786, 0.5232, 0.35, 0.5446]}, {"w": "is", "b": [0.3547, 0.5232, 0.368, 0.5446]}, {"w": "0", "b": [0.3727, 0.5232, 0.3827, 0.5446]}, {"w": "when", "b": [0.3874, 0.5232, 0.4331, 0.5446]}, {"w": "its", "b": [0.4378, 0.5232, 0.4574, 0.5446]}, {"w": "input", "b": [0.4621, 0.5232, 0.507, 0.5446]}, {"w": "is", "b": [0.5117, 0.5232, 0.525, 0.5446]}, {"w": "negative.4", "b": [0.5297, 0.5232, 0.6094, 0.5446]}]}, {"id": "b_8", "type": "paragraph", "text": "To solve this problem, you may want to use a variant of the ReLU function, such as the leaky ReLU. This function is defined as LeakyReLUα(z) = max(αz, z) (see Figure 11-2). The hyperparameter α defines how much the function “leaks”: it is the slope of the function for z < 0, and is typically set to 0.01. This small slope ensures that leaky ReLUs never die; they can go into a long coma, but they have a chance to eventually wake up. A 2015 paper5 compared several variants of the ReLU activation function and one of its conclusions was that the leaky variants always outperformed the strict ReLU activation function. In fact, setting α = 0.2 (huge leak) seemed to result in better performance than α = 0.01 (small leak). They also evaluated the randomized leaky ReLU (RReLU), where α is picked randomly in a given range during training, and it is fixed to an average value during testing. It also performed fairly well and seemed to act as a regularizer (reducing the risk of overfitting the training set).", "words": [{"w": "To", "b": [0.1429, 0.5513, 0.1643, 0.5727]}, {"w": "solve", "b": [0.1707, 0.5513, 0.2127, 0.5727]}, {"w": "this", "b": [0.2191, 0.5513, 0.2499, 0.5727]}, {"w": "problem,", "b": [0.2563, 0.5513, 0.332, 0.5727]}, {"w": "you", "b": [0.3384, 0.5513, 0.3697, 0.5727]}, {"w": "may", "b": [0.3761, 0.5513, 0.4115, 0.5727]}, {"w": "want", "b": [0.4179, 0.5513, 0.4587, 0.5727]}, {"w": "to", "b": [0.4651, 0.5513, 0.482, 0.5727]}, {"w": "use", "b": [0.4884, 0.5513, 0.516, 0.5727]}, {"w": "a", "b": [0.5224, 0.5513, 0.5315, 0.5727]}, {"w": "variant", "b": [0.5379, 0.5513, 0.5965, 0.5727]}, {"w": "of", "b": [0.6029, 0.5513, 0.6197, 0.5727]}, {"w": "the", "b": [0.6261, 0.5513, 0.6525, 0.5727]}, {"w": "ReLU", "b": [0.6589, 0.5513, 0.7064, 0.5727]}, {"w": "function,", "b": [0.7128, 0.5513, 0.7889, 0.5727]}, {"w": "such", "b": [0.7953, 0.5513, 0.834, 0.5727]}, {"w": "as", "b": [0.8404, 0.5513, 0.8572, 0.5727]}, {"w": "the", "b": [0.1429, 0.5704, 0.1692, 0.5918]}, {"w": "leaky", "b": [0.1808, 0.5702, 0.2228, 0.5918]}, {"w": "ReLU.", "b": [0.2344, 0.5702, 0.2849, 0.5918]}, {"w": "This", "b": [0.2965, 0.5704, 0.3337, 0.5918]}, {"w": "function", "b": [0.3453, 0.5704, 0.4167, 0.5918]}, {"w": "is", "b": [0.4283, 0.5704, 0.4415, 0.5918]}, {"w": "defined", "b": [0.4531, 0.5704, 0.516, 0.5918]}, {"w": "as", "b": [0.5276, 0.5704, 0.5443, 0.5918]}, {"w": "LeakyReLUα(z)", "b": [0.5559, 0.5702, 0.6824, 0.5927]}, {"w": "=", "b": [0.6939, 0.5704, 0.706, 0.5918]}, {"w": "max(αz,", "b": [0.7176, 0.5702, 0.7855, 0.5918]}, {"w": "z)", "b": [0.7971, 0.5702, 0.813, 0.5918]}, {"w": "(see", "b": [0.8246, 0.5704, 0.8571, 0.5918]}, {"w": "Figure", "b": [0.1429, 0.5894, 0.1969, 0.6108]}, {"w": "11-2).", "b": [0.2029, 0.5894, 0.2523, 0.6108]}, {"w": "The", "b": [0.2584, 0.5894, 0.2913, 0.6108]}, {"w": "hyperparameter", "b": [0.2973, 0.5894, 0.4308, 0.6108]}, {"w": "α", "b": [0.4369, 0.5892, 0.4481, 0.6108]}, {"w": "defines", "b": [0.4542, 0.5894, 0.5137, 0.6108]}, {"w": "how", "b": [0.5198, 0.5894, 0.5558, 0.6108]}, {"w": "much", "b": [0.5619, 0.5894, 0.6096, 0.6108]}, {"w": "the", "b": [0.6157, 0.5894, 0.642, 0.6108]}, {"w": "function", "b": [0.6481, 0.5894, 0.7195, 0.6108]}, {"w": "“leaks”:", "b": [0.7256, 0.5894, 0.7874, 0.6108]}, {"w": "it", "b": [0.7935, 0.5894, 0.8054, 0.6108]}, {"w": "is", "b": [0.8115, 0.5894, 0.8247, 0.6108]}, {"w": "the", "b": [0.8308, 0.5894, 0.8571, 0.6108]}, {"w": "slope", "b": [0.1429, 0.6085, 0.1862, 0.6299]}, {"w": "of", "b": [0.1929, 0.6085, 0.2097, 0.6299]}, {"w": "the", "b": [0.2164, 0.6085, 0.2427, 0.6299]}, {"w": "function", "b": [0.2495, 0.6085, 0.3209, 0.6299]}, {"w": "for", "b": [0.3276, 0.6085, 0.3521, 0.6299]}, {"w": "z", "b": [0.3588, 0.6083, 0.3675, 0.6299]}, {"w": "<", "b": [0.3742, 0.6085, 0.3857, 0.6299]}, {"w": "0,", "b": [0.3925, 0.6085, 0.4072, 0.6299]}, {"w": "and", "b": [0.4139, 0.6085, 0.4455, 0.6299]}, {"w": "is", "b": [0.4522, 0.6085, 0.4654, 0.6299]}, {"w": "typically", "b": [0.4722, 0.6085, 0.5426, 0.6299]}, {"w": "set", "b": [0.5494, 0.6085, 0.5722, 0.6299]}, {"w": "to", "b": [0.5789, 0.6085, 0.5959, 0.6299]}, {"w": "0.01.", "b": [0.6026, 0.6085, 0.6421, 0.6299]}, {"w": "This", "b": [0.6489, 0.6085, 0.6861, 0.6299]}, {"w": "small", "b": [0.6928, 0.6085, 0.7372, 0.6299]}, {"w": "slope", "b": [0.7439, 0.6085, 0.7872, 0.6299]}, {"w": "ensures", "b": [0.7939, 0.6085, 0.8571, 0.6299]}, {"w": "that", "b": [0.1429, 0.6275, 0.1754, 0.6489]}, {"w": "leaky", "b": [0.1817, 0.6275, 0.2248, 0.6489]}, {"w": "ReLUs", "b": [0.231, 0.6275, 0.2851, 0.6489]}, {"w": "never", "b": [0.2913, 0.6275, 0.3378, 0.6489]}, {"w": "die;", "b": [0.344, 0.6275, 0.3741, 0.6489]}, {"w": "they", "b": [0.3804, 0.6275, 0.4162, 0.6489]}, {"w": "can", "b": [0.4225, 0.6275, 0.4518, 0.6489]}, {"w": "go", "b": [0.458, 0.6275, 0.4784, 0.6489]}, {"w": "into", "b": [0.4846, 0.6275, 0.5182, 0.6489]}, {"w": "a", "b": [0.5244, 0.6275, 0.5335, 0.6489]}, {"w": "long", "b": [0.5397, 0.6275, 0.5768, 0.6489]}, {"w": "coma,", "b": [0.583, 0.6275, 0.6334, 0.6489]}, {"w": "but", "b": [0.6396, 0.6275, 0.6676, 0.6489]}, {"w": "they", "b": [0.6738, 0.6275, 0.7097, 0.6489]}, {"w": "have", "b": [0.7159, 0.6275, 0.7543, 0.6489]}, {"w": "a", "b": [0.7605, 0.6275, 0.7696, 0.6489]}, {"w": "chance", "b": [0.7758, 0.6275, 0.834, 0.6489]}, {"w": "to", "b": [0.8402, 0.6275, 0.8572, 0.6489]}, {"w": "eventually", "b": [0.1429, 0.6466, 0.2279, 0.668]}, {"w": "wake", "b": [0.234, 0.6466, 0.2766, 0.668]}, {"w": "up.", "b": [0.2827, 0.6466, 0.3088, 0.668]}, {"w": "A", "b": [0.3149, 0.6466, 0.3293, 0.668]}, {"w": "2015", "b": [0.3354, 0.6466, 0.3754, 0.668]}, {"w": "paper5", "b": [0.3815, 0.6466, 0.4344, 0.668]}, {"w": "compared", "b": [0.4405, 0.6466, 0.5243, 0.668]}, {"w": "several", "b": [0.5304, 0.6466, 0.5875, 0.668]}, {"w": "variants", "b": [0.5936, 0.6466, 0.6599, 0.668]}, {"w": "of", "b": [0.666, 0.6466, 0.6828, 0.668]}, {"w": "the", "b": [0.6889, 0.6466, 0.7152, 0.668]}, {"w": "ReLU", "b": [0.7213, 0.6466, 0.7688, 0.668]}, {"w": "activation", "b": [0.7749, 0.6466, 0.8571, 0.668]}, {"w": "function", "b": [0.1429, 0.6656, 0.2142, 0.687]}, {"w": "and", "b": [0.2204, 0.6656, 0.252, 0.687]}, {"w": "one", "b": [0.2582, 0.6656, 0.289, 0.687]}, {"w": "of", "b": [0.2952, 0.6656, 0.312, 0.687]}, {"w": "its", "b": [0.3182, 0.6656, 0.3378, 0.687]}, {"w": "conclusions", "b": [0.3439, 0.6656, 0.4428, 0.687]}, {"w": "was", "b": [0.449, 0.6656, 0.4801, 0.687]}, {"w": "that", "b": [0.4863, 0.6656, 0.5188, 0.687]}, {"w": "the", "b": [0.525, 0.6656, 0.5513, 0.687]}, {"w": "leaky", "b": [0.5575, 0.6656, 0.6007, 0.687]}, {"w": "variants", "b": [0.6069, 0.6656, 0.6731, 0.687]}, {"w": "always", "b": [0.6793, 0.6656, 0.734, 0.687]}, {"w": "outperformed", "b": [0.7402, 0.6656, 0.8571, 0.687]}, {"w": "the", "b": [0.1429, 0.6847, 0.1692, 0.7061]}, {"w": "strict", "b": [0.1774, 0.6847, 0.2198, 0.7061]}, {"w": "ReLU", "b": [0.228, 0.6847, 0.2755, 0.7061]}, {"w": "activation", "b": [0.2837, 0.6847, 0.3659, 0.7061]}, {"w": "function.", "b": [0.3741, 0.6847, 0.4502, 0.7061]}, {"w": "In", "b": [0.4584, 0.6847, 0.4769, 0.7061]}, {"w": "fact,", "b": [0.485, 0.6847, 0.5203, 0.7061]}, {"w": "setting", "b": [0.5284, 0.6847, 0.5844, 0.7061]}, {"w": "α", "b": [0.5925, 0.6845, 0.6037, 0.7061]}, {"w": "=", "b": [0.6118, 0.6847, 0.6239, 0.7061]}, {"w": "0.2", "b": [0.6321, 0.6847, 0.6568, 0.7061]}, {"w": "(huge", "b": [0.665, 0.6847, 0.7126, 0.7061]}, {"w": "leak)", "b": [0.7208, 0.6847, 0.7616, 0.7061]}, {"w": "seemed", "b": [0.7697, 0.6847, 0.832, 0.7061]}, {"w": "to", "b": [0.8402, 0.6847, 0.8572, 0.7061]}, {"w": "result", "b": [0.1429, 0.7037, 0.1898, 0.7251]}, {"w": "in", "b": [0.1991, 0.7037, 0.2161, 0.7251]}, {"w": "better", "b": [0.2253, 0.7037, 0.2741, 0.7251]}, {"w": "performance", "b": [0.2834, 0.7037, 0.3907, 0.7251]}, {"w": "than", "b": [0.4, 0.7037, 0.438, 0.7251]}, {"w": "α", "b": [0.4473, 0.7035, 0.4584, 0.7251]}, {"w": "=", "b": [0.4677, 0.7037, 0.4798, 0.7251]}, {"w": "0.01", "b": [0.4891, 0.7037, 0.5238, 0.7251]}, {"w": "(small", "b": [0.5331, 0.7037, 0.5847, 0.7251]}, {"w": "leak).", "b": [0.594, 0.7037, 0.6396, 0.7251]}, {"w": "They", "b": [0.6489, 0.7037, 0.6913, 0.7251]}, {"w": "also", "b": [0.7006, 0.7037, 0.7333, 0.7251]}, {"w": "evaluated", "b": [0.7426, 0.7037, 0.8215, 0.7251]}, {"w": "the", "b": [0.8308, 0.7037, 0.8571, 0.7251]}, {"w": "randomized", "b": [0.1429, 0.7225, 0.2403, 0.7442]}, {"w": "leaky", "b": [0.245, 0.7225, 0.287, 0.7442]}, {"w": "ReLU", "b": [0.2918, 0.7225, 0.3375, 0.7442]}, {"w": "(RReLU),", "b": [0.3424, 0.7228, 0.422, 0.7442]}, {"w": "where", "b": [0.4268, 0.7228, 0.4776, 0.7442]}, {"w": "α", "b": [0.4825, 0.7225, 0.4936, 0.7442]}, {"w": "is", "b": [0.4984, 0.7228, 0.5116, 0.7442]}, {"w": "picked", "b": [0.5163, 0.7228, 0.5718, 0.7442]}, {"w": "randomly", "b": [0.5766, 0.7228, 0.6584, 0.7442]}, {"w": "in", "b": [0.6631, 0.7228, 0.6801, 0.7442]}, {"w": "a", "b": [0.6848, 0.7228, 0.6939, 0.7442]}, {"w": "given", "b": [0.6987, 0.7228, 0.7439, 0.7442]}, {"w": "range", "b": [0.7486, 0.7228, 0.7955, 0.7442]}, {"w": "during", "b": [0.8002, 0.7228, 0.8567, 0.7442]}, {"w": "training,", "b": [0.1429, 0.7418, 0.2145, 0.7632]}, {"w": "and", "b": [0.2193, 0.7418, 0.2508, 0.7632]}, {"w": "it", "b": [0.2555, 0.7418, 0.2675, 0.7632]}, {"w": "is", "b": [0.2722, 0.7418, 0.2854, 0.7632]}, {"w": "fixed", "b": [0.2902, 0.7418, 0.3316, 0.7632]}, {"w": "to", "b": [0.3363, 0.7418, 0.3533, 0.7632]}, {"w": "an", "b": [0.358, 0.7418, 0.3786, 0.7632]}, {"w": "average", "b": [0.3833, 0.7418, 0.4461, 0.7632]}, {"w": "value", "b": [0.4508, 0.7418, 0.4948, 0.7632]}, {"w": "during", "b": [0.4995, 0.7418, 0.556, 0.7632]}, {"w": "testing.", "b": [0.5607, 0.7418, 0.6214, 0.7632]}, {"w": "It", "b": [0.6262, 0.7418, 0.6388, 0.7632]}, {"w": "also", "b": [0.6435, 0.7418, 0.6762, 0.7632]}, {"w": "performed", "b": [0.681, 0.7418, 0.7699, 0.7632]}, {"w": "fairly", "b": [0.7746, 0.7418, 0.8181, 0.7632]}, {"w": "well", "b": [0.8228, 0.7418, 0.8565, 0.7632]}, {"w": "and", "b": [0.1429, 0.7608, 0.1744, 0.7823]}, {"w": "seemed", "b": [0.1809, 0.7608, 0.2432, 0.7823]}, {"w": "to", "b": [0.2496, 0.7608, 0.2666, 0.7823]}, {"w": "act", "b": [0.2731, 0.7608, 0.2974, 0.7823]}, {"w": "as", "b": [0.3039, 0.7608, 0.3207, 0.7823]}, {"w": "a", "b": [0.3272, 0.7608, 0.3363, 0.7823]}, {"w": "regularizer", "b": [0.3428, 0.7608, 0.4333, 0.7823]}, {"w": "(reducing", "b": [0.4398, 0.7608, 0.5212, 0.7823]}, {"w": "the", "b": [0.5277, 0.7608, 0.554, 0.7823]}, {"w": "risk", "b": [0.5605, 0.7608, 0.5918, 0.7823]}, {"w": "of", "b": [0.5983, 0.7608, 0.6151, 0.7823]}, {"w": "overfitting", "b": [0.6215, 0.7608, 0.7096, 0.7823]}, {"w": "the", "b": [0.7161, 0.7608, 0.7424, 0.7823]}, {"w": "training", "b": [0.7489, 0.7608, 0.8158, 0.7823]}, {"w": "set).", "b": [0.8223, 0.7608, 0.8571, 0.7823]}]}, {"id": "b_9", "type": "equation", "text": "Vanishing/Exploding Gradients Problems | 329", "words": [{"w": "Vanishing/Exploding", "b": [0.5559, 0.9225, 0.678, 0.9388]}, {"w": "Gradients", "b": [0.6808, 0.9225, 0.7376, 0.9388]}, {"w": "Problems", "b": [0.7404, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "329", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 356, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 “Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs),” D. Clevert, T. Unterthiner, S. Hochreiter (2015).", "words": [{"w": "6", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "“Fast", "b": [0.1587, 0.8598, 0.1908, 0.8761]}, {"w": "and", "b": [0.1944, 0.8598, 0.2184, 0.8761]}, {"w": "Accurate", "b": [0.222, 0.8598, 0.2786, 0.8761]}, {"w": "Deep", "b": [0.2822, 0.8598, 0.3156, 0.8761]}, {"w": "Network", "b": [0.3192, 0.8598, 0.375, 0.8761]}, {"w": "Learning", "b": [0.3786, 0.8598, 0.4357, 0.8761]}, {"w": "by", "b": [0.4393, 0.8598, 0.4547, 0.8761]}, {"w": "Exponential", "b": [0.4583, 0.8598, 0.5351, 0.8761]}, {"w": "Linear", "b": [0.5387, 0.8598, 0.5798, 0.8761]}, {"w": "Units", "b": [0.5834, 0.8598, 0.618, 0.8761]}, {"w": "(ELUs),”", "b": [0.6216, 0.8598, 0.674, 0.8761]}, {"w": "D.", "b": [0.6776, 0.8598, 0.6922, 0.8761]}, {"w": "Clevert,", "b": [0.6958, 0.8598, 0.7456, 0.8761]}, {"w": "T.", "b": [0.7492, 0.8598, 0.761, 0.8761]}, {"w": "Unterthiner,", "b": [0.7646, 0.8598, 0.843, 0.8761]}, {"w": "S.", "b": [0.1587, 0.8749, 0.1699, 0.8912]}, {"w": "Hochreiter", "b": [0.1735, 0.8749, 0.2429, 0.8912]}, {"w": "(2015).", "b": [0.2465, 0.8749, 0.2916, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Finally, they also evaluated the parametric leaky ReLU (PReLU), where α is authorized to be learned during training (instead of being a hyperparameter, it becomes a parameter that can be modified by backpropagation like any other parameter). This was reported to strongly outperform ReLU on large image datasets, but on smaller datasets it runs the risk of overfitting the training set.", "words": [{"w": "Finally,", "b": [0.1429, 0.0791, 0.2033, 0.1005]}, {"w": "they", "b": [0.2083, 0.0791, 0.2442, 0.1005]}, {"w": "also", "b": [0.2492, 0.0791, 0.2819, 0.1005]}, {"w": "evaluated", "b": [0.2868, 0.0791, 0.3658, 0.1005]}, {"w": "the", "b": [0.3708, 0.0791, 0.3971, 0.1005]}, {"w": "parametric", "b": [0.4021, 0.0789, 0.4911, 0.1005]}, {"w": "leaky", "b": [0.4959, 0.0789, 0.5378, 0.1005]}, {"w": "ReLU", "b": [0.5426, 0.0789, 0.5884, 0.1005]}, {"w": "(PReLU),", "b": [0.5938, 0.0791, 0.6722, 0.1005]}, {"w": "where", "b": [0.6772, 0.0791, 0.728, 0.1005]}, {"w": "α", "b": [0.733, 0.0789, 0.7441, 0.1005]}, {"w": "is", "b": [0.7491, 0.0791, 0.7623, 0.1005]}, {"w": "authorized", "b": [0.7671, 0.0791, 0.8569, 0.1005]}, {"w": "to", "b": [0.1428, 0.0981, 0.1598, 0.1195]}, {"w": "be", "b": [0.17, 0.0981, 0.1895, 0.1195]}, {"w": "learned", "b": [0.1997, 0.0981, 0.2619, 0.1195]}, {"w": "during", "b": [0.2721, 0.0981, 0.3286, 0.1195]}, {"w": "training", "b": [0.3388, 0.0981, 0.4058, 0.1195]}, {"w": "(instead", "b": [0.416, 0.0981, 0.4832, 0.1195]}, {"w": "of", "b": [0.4934, 0.0981, 0.5102, 0.1195]}, {"w": "being", "b": [0.5204, 0.0981, 0.5665, 0.1195]}, {"w": "a", "b": [0.5767, 0.0981, 0.5859, 0.1195]}, {"w": "hyperparameter,", "b": [0.5961, 0.0981, 0.733, 0.1195]}, {"w": "it", "b": [0.7432, 0.0981, 0.7551, 0.1195]}, {"w": "becomes", "b": [0.7653, 0.0981, 0.8378, 0.1195]}, {"w": "a", "b": [0.848, 0.0981, 0.8571, 0.1195]}, {"w": "parameter", "b": [0.1429, 0.1172, 0.2287, 0.1386]}, {"w": "that", "b": [0.2351, 0.1172, 0.2677, 0.1386]}, {"w": "can", "b": [0.2742, 0.1172, 0.3035, 0.1386]}, {"w": "be", "b": [0.31, 0.1172, 0.3294, 0.1386]}, {"w": "modified", "b": [0.3359, 0.1172, 0.4118, 0.1386]}, {"w": "by", "b": [0.4182, 0.1172, 0.4384, 0.1386]}, {"w": "backpropagation", "b": [0.4448, 0.1172, 0.5855, 0.1386]}, {"w": "like", "b": [0.592, 0.1172, 0.622, 0.1386]}, {"w": "any", "b": [0.6285, 0.1172, 0.6581, 0.1386]}, {"w": "other", "b": [0.6646, 0.1172, 0.7093, 0.1386]}, {"w": "parameter).", "b": [0.7157, 0.1172, 0.8135, 0.1386]}, {"w": "This", "b": [0.8199, 0.1172, 0.8571, 0.1386]}, {"w": "was", "b": [0.1429, 0.1362, 0.1739, 0.1576]}, {"w": "reported", "b": [0.1811, 0.1362, 0.2532, 0.1576]}, {"w": "to", "b": [0.2604, 0.1362, 0.2774, 0.1576]}, {"w": "strongly", "b": [0.2846, 0.1362, 0.3529, 0.1576]}, {"w": "outperform", "b": [0.3601, 0.1362, 0.4573, 0.1576]}, {"w": "ReLU", "b": [0.4645, 0.1362, 0.512, 0.1576]}, {"w": "on", "b": [0.5192, 0.1362, 0.5412, 0.1576]}, {"w": "large", "b": [0.5484, 0.1362, 0.5892, 0.1576]}, {"w": "image", "b": [0.5964, 0.1362, 0.6468, 0.1576]}, {"w": "datasets,", "b": [0.654, 0.1362, 0.7245, 0.1576]}, {"w": "but", "b": [0.7317, 0.1362, 0.7597, 0.1576]}, {"w": "on", "b": [0.7669, 0.1362, 0.7889, 0.1576]}, {"w": "smaller", "b": [0.7962, 0.1362, 0.8571, 0.1576]}, {"w": "datasets", "b": [0.1429, 0.1553, 0.2086, 0.1767]}, {"w": "it", "b": [0.2133, 0.1553, 0.2253, 0.1767]}, {"w": "runs", "b": [0.23, 0.1553, 0.2678, 0.1767]}, {"w": "the", "b": [0.2726, 0.1553, 0.2989, 0.1767]}, {"w": "risk", "b": [0.3036, 0.1553, 0.3349, 0.1767]}, {"w": "of", "b": [0.3396, 0.1553, 0.3564, 0.1767]}, {"w": "overfitting", "b": [0.3612, 0.1553, 0.4492, 0.1767]}, {"w": "the", "b": [0.4539, 0.1553, 0.4803, 0.1767]}, {"w": "training", "b": [0.485, 0.1553, 0.5519, 0.1767]}, {"w": "set.", "b": [0.5567, 0.1553, 0.5843, 0.1767]}]}, {"id": "b_2", "type": "equation", "text": "Figure 11-2. Leaky ReLU", "words": [{"w": "Figure", "b": [0.1428, 0.3977, 0.1943, 0.4193]}, {"w": "11-2.", "b": [0.1991, 0.3977, 0.2407, 0.4193]}, {"w": "Leaky", "b": [0.2455, 0.3977, 0.2935, 0.4193]}, {"w": "ReLU", "b": [0.2983, 0.3977, 0.344, 0.4193]}]}, {"id": "b_3", "type": "paragraph", "text": "Last but not least, a 2015 paper by Djork-Arné Clevert et al.6 proposed a new activa‐ tion function called the exponential linear unit (ELU) that outperformed all the ReLU variants in their experiments: training time was reduced and the neural network per‐ formed better on the test set. It is represented in Figure 11-3, and Equation 11-2 shows its definition.", "words": [{"w": "Last", "b": [0.1428, 0.4351, 0.1772, 0.4565]}, {"w": "but", "b": [0.183, 0.4351, 0.211, 0.4565]}, {"w": "not", "b": [0.2168, 0.4351, 0.2452, 0.4565]}, {"w": "least,", "b": [0.251, 0.4351, 0.293, 0.4565]}, {"w": "a", "b": [0.2989, 0.4351, 0.308, 0.4565]}, {"w": "2015", "b": [0.3138, 0.4351, 0.3538, 0.4565]}, {"w": "paper", "b": [0.3596, 0.4351, 0.4068, 0.4565]}, {"w": "by", "b": [0.4126, 0.4351, 0.4328, 0.4565]}, {"w": "Djork-Arné", "b": [0.4386, 0.4351, 0.5377, 0.4565]}, {"w": "Clevert", "b": [0.5435, 0.4351, 0.6041, 0.4565]}, {"w": "et", "b": [0.6099, 0.4351, 0.6251, 0.4565]}, {"w": "al.6", "b": [0.6309, 0.4351, 0.6558, 0.4565]}, {"w": "proposed", "b": [0.6616, 0.4351, 0.7399, 0.4565]}, {"w": "a", "b": [0.7457, 0.4351, 0.7549, 0.4565]}, {"w": "new", "b": [0.7607, 0.4351, 0.7952, 0.4565]}, {"w": "activa‐", "b": [0.801, 0.4351, 0.8571, 0.4565]}, {"w": "tion", "b": [0.1429, 0.4541, 0.1768, 0.4755]}, {"w": "function", "b": [0.1822, 0.4541, 0.2535, 0.4755]}, {"w": "called", "b": [0.2589, 0.4541, 0.3072, 0.4755]}, {"w": "the", "b": [0.3126, 0.4541, 0.3389, 0.4755]}, {"w": "exponential", "b": [0.3443, 0.4539, 0.439, 0.4755]}, {"w": "linear", "b": [0.4443, 0.4539, 0.4913, 0.4755]}, {"w": "unit", "b": [0.4967, 0.4539, 0.53, 0.4755]}, {"w": "(ELU)", "b": [0.5354, 0.4541, 0.5873, 0.4755]}, {"w": "that", "b": [0.5927, 0.4541, 0.6253, 0.4755]}, {"w": "outperformed", "b": [0.6306, 0.4541, 0.7476, 0.4755]}, {"w": "all", "b": [0.7529, 0.4541, 0.7726, 0.4755]}, {"w": "the", "b": [0.778, 0.4541, 0.8043, 0.4755]}, {"w": "ReLU", "b": [0.8096, 0.4541, 0.8571, 0.4755]}, {"w": "variants", "b": [0.1429, 0.4732, 0.2091, 0.4946]}, {"w": "in", "b": [0.2145, 0.4732, 0.2315, 0.4946]}, {"w": "their", "b": [0.2369, 0.4732, 0.2766, 0.4946]}, {"w": "experiments:", "b": [0.282, 0.4732, 0.3894, 0.4946]}, {"w": "training", "b": [0.3948, 0.4732, 0.4618, 0.4946]}, {"w": "time", "b": [0.4672, 0.4732, 0.505, 0.4946]}, {"w": "was", "b": [0.5105, 0.4732, 0.5415, 0.4946]}, {"w": "reduced", "b": [0.5469, 0.4732, 0.6142, 0.4946]}, {"w": "and", "b": [0.6197, 0.4732, 0.6512, 0.4946]}, {"w": "the", "b": [0.6566, 0.4732, 0.683, 0.4946]}, {"w": "neural", "b": [0.6884, 0.4732, 0.7418, 0.4946]}, {"w": "network", "b": [0.7472, 0.4732, 0.8168, 0.4946]}, {"w": "per‐", "b": [0.8222, 0.4732, 0.8571, 0.4946]}, {"w": "formed", "b": [0.1428, 0.4922, 0.2043, 0.5136]}, {"w": "better", "b": [0.2126, 0.4922, 0.2614, 0.5136]}, {"w": "on", "b": [0.2697, 0.4922, 0.2917, 0.5136]}, {"w": "the", "b": [0.3001, 0.4922, 0.3264, 0.5136]}, {"w": "test", "b": [0.3348, 0.4922, 0.364, 0.5136]}, {"w": "set.", "b": [0.3723, 0.4922, 0.3999, 0.5136]}, {"w": "It", "b": [0.4083, 0.4922, 0.4209, 0.5136]}, {"w": "is", "b": [0.4293, 0.4922, 0.4425, 0.5136]}, {"w": "represented", "b": [0.4509, 0.4922, 0.5487, 0.5136]}, {"w": "in", "b": [0.557, 0.4922, 0.574, 0.5136]}, {"w": "Figure", "b": [0.5824, 0.4922, 0.6364, 0.5136]}, {"w": "11-3,", "b": [0.6447, 0.4922, 0.6869, 0.5136]}, {"w": "and", "b": [0.6952, 0.4922, 0.7268, 0.5136]}, {"w": "Equation", "b": [0.7351, 0.4922, 0.8114, 0.5136]}, {"w": "11-2", "b": [0.8197, 0.4922, 0.8571, 0.5136]}, {"w": "shows", "b": [0.1429, 0.5113, 0.1942, 0.5327]}, {"w": "its", "b": [0.1989, 0.5113, 0.2185, 0.5327]}, {"w": "definition.", "b": [0.2232, 0.5113, 0.3105, 0.5327]}]}, {"id": "b_4", "type": "equation", "text": "Equation 11-2. ELU activation function", "words": [{"w": "Equation", "b": [0.1726, 0.5508, 0.2473, 0.5724]}, {"w": "11-2.", "b": [0.2521, 0.5508, 0.2937, 0.5724]}, {"w": "ELU", "b": [0.2985, 0.5508, 0.3351, 0.5724]}, {"w": "activation", "b": [0.3399, 0.5508, 0.4211, 0.5724]}, {"w": "function", "b": [0.4258, 0.5508, 0.4939, 0.5724]}]}, {"id": "b_5", "type": "equation", "text": "ELUα z = α exp z −1 if z < 0", "words": [{"w": "ELUα", "b": [0.1726, 0.5896, 0.2177, 0.6143]}, {"w": "z", "b": [0.23, 0.5895, 0.2383, 0.61]}, {"w": "=", "b": [0.2511, 0.5896, 0.2626, 0.61]}, {"w": "α", "b": [0.275, 0.5786, 0.2856, 0.5992]}, {"w": "exp", "b": [0.298, 0.5788, 0.3262, 0.5992]}, {"w": "z", "b": [0.3385, 0.5786, 0.3468, 0.5992]}, {"w": "−1", "b": [0.3585, 0.5788, 0.3839, 0.5992]}, {"w": "if", "b": [0.3995, 0.5788, 0.4107, 0.5992]}, {"w": "z", "b": [0.4203, 0.5786, 0.4285, 0.5992]}, {"w": "<", "b": [0.4344, 0.5788, 0.4454, 0.5992]}, {"w": "0", "b": [0.4509, 0.5788, 0.4604, 0.5992]}]}, {"id": "b_6", "type": "paragraph", "text": "z if z ≥0", "words": [{"w": "z", "b": [0.275, 0.6003, 0.2833, 0.6209]}, {"w": "if", "b": [0.3995, 0.6005, 0.4107, 0.6209]}, {"w": "z", "b": [0.4203, 0.6003, 0.4285, 0.6209]}, {"w": "≥0", "b": [0.4344, 0.6005, 0.461, 0.6209]}]}, {"id": "b_7", "type": "paragraph", "text": "330 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "330", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2745, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 357, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "7 “Self-Normalizing Neural Networks, \" G. Klambauer, T. Unterthiner and A. Mayr (2017).", "words": [{"w": "7", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Self-Normalizing", "b": [0.1587, 0.8749, 0.2739, 0.8912]}, {"w": "Neural", "b": [0.2775, 0.8749, 0.321, 0.8912]}, {"w": "Networks,", "b": [0.3246, 0.8749, 0.3897, 0.8912]}, {"w": "\"", "b": [0.3933, 0.8749, 0.3984, 0.8912]}, {"w": "G.", "b": [0.402, 0.8749, 0.4169, 0.8912]}, {"w": "Klambauer,", "b": [0.4205, 0.8749, 0.4936, 0.8912]}, {"w": "T.", "b": [0.4972, 0.8749, 0.5091, 0.8912]}, {"w": "Unterthiner", "b": [0.5127, 0.8749, 0.5884, 0.8912]}, {"w": "and", "b": [0.592, 0.8749, 0.616, 0.8912]}, {"w": "A.", "b": [0.6197, 0.8749, 0.6342, 0.8912]}, {"w": "Mayr", "b": [0.6378, 0.8749, 0.6716, 0.8912]}, {"w": "(2017).", "b": [0.6752, 0.8749, 0.7203, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 11-3. ELU activation function", "words": [{"w": "Figure", "b": [0.1429, 0.2921, 0.1943, 0.3138]}, {"w": "11-3.", "b": [0.1991, 0.2921, 0.2407, 0.3138]}, {"w": "ELU", "b": [0.2455, 0.2921, 0.2821, 0.3138]}, {"w": "activation", "b": [0.2869, 0.2921, 0.3681, 0.3138]}, {"w": "function", "b": [0.3728, 0.2921, 0.4409, 0.3138]}]}, {"id": "b_2", "type": "paragraph", "text": "It looks a lot like the ReLU function, with a few major differences:", "words": [{"w": "It", "b": [0.1429, 0.3295, 0.1555, 0.351]}, {"w": "looks", "b": [0.1602, 0.3295, 0.2047, 0.351]}, {"w": "a", "b": [0.2095, 0.3295, 0.2186, 0.351]}, {"w": "lot", "b": [0.2233, 0.3295, 0.2456, 0.351]}, {"w": "like", "b": [0.2503, 0.3295, 0.2804, 0.351]}, {"w": "the", "b": [0.2851, 0.3295, 0.3114, 0.351]}, {"w": "ReLU", "b": [0.3161, 0.3295, 0.3636, 0.351]}, {"w": "function,", "b": [0.3684, 0.3295, 0.4445, 0.351]}, {"w": "with", "b": [0.4493, 0.3295, 0.4866, 0.351]}, {"w": "a", "b": [0.4913, 0.3295, 0.5005, 0.351]}, {"w": "few", "b": [0.5052, 0.3295, 0.5345, 0.351]}, {"w": "major", "b": [0.5392, 0.3295, 0.5887, 0.351]}, {"w": "differences:", "b": [0.5934, 0.3295, 0.6893, 0.351]}]}, {"id": "b_3", "type": "paragraph", "text": "• First it takes on negative values when z < 0, which allows the unit to have an average output closer to 0. This helps alleviate the vanishing gradients problem, as discussed earlier. The hyperparameter α defines the value that the ELU func‐ tion approaches when z is a large negative number. It is usually set to 1, but you can tweak it like any other hyperparameter if you want.", "words": [{"w": "•", "b": [0.16, 0.3637, 0.1682, 0.3851]}, {"w": "First", "b": [0.1786, 0.3637, 0.2169, 0.3851]}, {"w": "it", "b": [0.2246, 0.3637, 0.2365, 0.3851]}, {"w": "takes", "b": [0.2442, 0.3637, 0.2865, 0.3851]}, {"w": "on", "b": [0.2942, 0.3637, 0.3162, 0.3851]}, {"w": "negative", "b": [0.3239, 0.3637, 0.3931, 0.3851]}, {"w": "values", "b": [0.4007, 0.3637, 0.4524, 0.3851]}, {"w": "when", "b": [0.46, 0.3637, 0.5057, 0.3851]}, {"w": "z", "b": [0.5133, 0.3635, 0.5221, 0.3851]}, {"w": "<", "b": [0.5297, 0.3637, 0.5412, 0.3851]}, {"w": "0,", "b": [0.5489, 0.3637, 0.5636, 0.3851]}, {"w": "which", "b": [0.5713, 0.3637, 0.6222, 0.3851]}, {"w": "allows", "b": [0.6299, 0.3637, 0.6821, 0.3851]}, {"w": "the", "b": [0.6898, 0.3637, 0.7161, 0.3851]}, {"w": "unit", "b": [0.7238, 0.3637, 0.7582, 0.3851]}, {"w": "to", "b": [0.7659, 0.3637, 0.7829, 0.3851]}, {"w": "have", "b": [0.7905, 0.3637, 0.8289, 0.3851]}, {"w": "an", "b": [0.8366, 0.3637, 0.8571, 0.3851]}, {"w": "average", "b": [0.1786, 0.3828, 0.2413, 0.4042]}, {"w": "output", "b": [0.2477, 0.3828, 0.304, 0.4042]}, {"w": "closer", "b": [0.3103, 0.3828, 0.3593, 0.4042]}, {"w": "to", "b": [0.3656, 0.3828, 0.3826, 0.4042]}, {"w": "0.", "b": [0.3889, 0.3828, 0.4037, 0.4042]}, {"w": "This", "b": [0.41, 0.3828, 0.4472, 0.4042]}, {"w": "helps", "b": [0.4535, 0.3828, 0.4973, 0.4042]}, {"w": "alleviate", "b": [0.5037, 0.3828, 0.5714, 0.4042]}, {"w": "the", "b": [0.5777, 0.3828, 0.604, 0.4042]}, {"w": "vanishing", "b": [0.6104, 0.3828, 0.6916, 0.4042]}, {"w": "gradients", "b": [0.698, 0.3828, 0.775, 0.4042]}, {"w": "problem,", "b": [0.7814, 0.3828, 0.8571, 0.4042]}, {"w": "as", "b": [0.1786, 0.4018, 0.1954, 0.4232]}, {"w": "discussed", "b": [0.2018, 0.4018, 0.281, 0.4232]}, {"w": "earlier.", "b": [0.2875, 0.4018, 0.3441, 0.4232]}, {"w": "The", "b": [0.3505, 0.4018, 0.3834, 0.4232]}, {"w": "hyperparameter", "b": [0.3898, 0.4018, 0.5233, 0.4232]}, {"w": "α", "b": [0.5298, 0.4016, 0.5409, 0.4232]}, {"w": "defines", "b": [0.5473, 0.4018, 0.6068, 0.4232]}, {"w": "the", "b": [0.6133, 0.4018, 0.6396, 0.4232]}, {"w": "value", "b": [0.6461, 0.4018, 0.69, 0.4232]}, {"w": "that", "b": [0.6965, 0.4018, 0.7291, 0.4232]}, {"w": "the", "b": [0.7355, 0.4018, 0.7619, 0.4232]}, {"w": "ELU", "b": [0.7683, 0.4018, 0.8058, 0.4232]}, {"w": "func‐", "b": [0.8123, 0.4018, 0.8571, 0.4232]}, {"w": "tion", "b": [0.1786, 0.4209, 0.2125, 0.4423]}, {"w": "approaches", "b": [0.2185, 0.4209, 0.313, 0.4423]}, {"w": "when", "b": [0.3189, 0.4209, 0.3646, 0.4423]}, {"w": "z", "b": [0.3705, 0.4206, 0.3792, 0.4423]}, {"w": "is", "b": [0.3851, 0.4209, 0.3984, 0.4423]}, {"w": "a", "b": [0.4043, 0.4209, 0.4135, 0.4423]}, {"w": "large", "b": [0.4194, 0.4209, 0.4601, 0.4423]}, {"w": "negative", "b": [0.4661, 0.4209, 0.5353, 0.4423]}, {"w": "number.", "b": [0.5412, 0.4209, 0.6109, 0.4423]}, {"w": "It", "b": [0.6169, 0.4209, 0.6295, 0.4423]}, {"w": "is", "b": [0.6354, 0.4209, 0.6487, 0.4423]}, {"w": "usually", "b": [0.6546, 0.4209, 0.7136, 0.4423]}, {"w": "set", "b": [0.7196, 0.4209, 0.7424, 0.4423]}, {"w": "to", "b": [0.7484, 0.4209, 0.7653, 0.4423]}, {"w": "1,", "b": [0.7713, 0.4209, 0.786, 0.4423]}, {"w": "but", "b": [0.792, 0.4209, 0.82, 0.4423]}, {"w": "you", "b": [0.8259, 0.4209, 0.8571, 0.4423]}, {"w": "can", "b": [0.1786, 0.4399, 0.2079, 0.4613]}, {"w": "tweak", "b": [0.2127, 0.4399, 0.2616, 0.4613]}, {"w": "it", "b": [0.2664, 0.4399, 0.2783, 0.4613]}, {"w": "like", "b": [0.283, 0.4399, 0.3131, 0.4613]}, {"w": "any", "b": [0.3178, 0.4399, 0.3474, 0.4613]}, {"w": "other", "b": [0.3521, 0.4399, 0.3968, 0.4613]}, {"w": "hyperparameter", "b": [0.4016, 0.4399, 0.5351, 0.4613]}, {"w": "if", "b": [0.5398, 0.4399, 0.5515, 0.4613]}, {"w": "you", "b": [0.5563, 0.4399, 0.5875, 0.4613]}, {"w": "want.", "b": [0.5922, 0.4399, 0.6378, 0.4613]}]}, {"id": "b_4", "type": "paragraph", "text": "• Second, it has a nonzero gradient for z < 0, which avoids the dead neurons prob‐ lem.", "words": [{"w": "•", "b": [0.16, 0.465, 0.1681, 0.4864]}, {"w": "Second,", "b": [0.1786, 0.465, 0.2439, 0.4864]}, {"w": "it", "b": [0.2492, 0.465, 0.2611, 0.4864]}, {"w": "has", "b": [0.2664, 0.465, 0.2943, 0.4864]}, {"w": "a", "b": [0.2996, 0.465, 0.3088, 0.4864]}, {"w": "nonzero", "b": [0.3141, 0.465, 0.3834, 0.4864]}, {"w": "gradient", "b": [0.3887, 0.465, 0.4582, 0.4864]}, {"w": "for", "b": [0.4635, 0.465, 0.488, 0.4864]}, {"w": "z", "b": [0.4933, 0.4648, 0.502, 0.4864]}, {"w": "<", "b": [0.5073, 0.465, 0.5188, 0.4864]}, {"w": "0,", "b": [0.5241, 0.465, 0.5389, 0.4864]}, {"w": "which", "b": [0.5442, 0.465, 0.5951, 0.4864]}, {"w": "avoids", "b": [0.6004, 0.465, 0.6536, 0.4864]}, {"w": "the", "b": [0.6589, 0.465, 0.6853, 0.4864]}, {"w": "dead", "b": [0.6906, 0.465, 0.7306, 0.4864]}, {"w": "neurons", "b": [0.7359, 0.465, 0.8046, 0.4864]}, {"w": "prob‐", "b": [0.8099, 0.465, 0.8572, 0.4864]}, {"w": "lem.", "b": [0.1786, 0.484, 0.2145, 0.5055]}]}, {"id": "b_5", "type": "paragraph", "text": "• Third, if α is equal to 1 then the function is smooth everywhere, including around z = 0, which helps speed up Gradient Descent, since it does not bounce as much left and right of z = 0.", "words": [{"w": "•", "b": [0.16, 0.5091, 0.1682, 0.5305]}, {"w": "Third,", "b": [0.1786, 0.5091, 0.2316, 0.5305]}, {"w": "if", "b": [0.2412, 0.5091, 0.2529, 0.5305]}, {"w": "α", "b": [0.2625, 0.5089, 0.2737, 0.5305]}, {"w": "is", "b": [0.2833, 0.5091, 0.2965, 0.5305]}, {"w": "equal", "b": [0.3061, 0.5091, 0.3511, 0.5305]}, {"w": "to", "b": [0.3606, 0.5091, 0.3776, 0.5305]}, {"w": "1", "b": [0.3872, 0.5091, 0.3972, 0.5305]}, {"w": "then", "b": [0.4068, 0.5091, 0.4445, 0.5305]}, {"w": "the", "b": [0.4541, 0.5091, 0.4805, 0.5305]}, {"w": "function", "b": [0.49, 0.5091, 0.5614, 0.5305]}, {"w": "is", "b": [0.571, 0.5091, 0.5843, 0.5305]}, {"w": "smooth", "b": [0.5938, 0.5091, 0.6573, 0.5305]}, {"w": "everywhere,", "b": [0.6669, 0.5091, 0.7677, 0.5305]}, {"w": "including", "b": [0.7773, 0.5091, 0.8571, 0.5305]}, {"w": "around", "b": [0.1786, 0.5282, 0.2395, 0.5496]}, {"w": "z", "b": [0.2444, 0.528, 0.2531, 0.5496]}, {"w": "=", "b": [0.258, 0.5282, 0.2701, 0.5496]}, {"w": "0,", "b": [0.2749, 0.5282, 0.2897, 0.5496]}, {"w": "which", "b": [0.2946, 0.5282, 0.3455, 0.5496]}, {"w": "helps", "b": [0.3504, 0.5282, 0.3942, 0.5496]}, {"w": "speed", "b": [0.399, 0.5282, 0.4463, 0.5496]}, {"w": "up", "b": [0.4512, 0.5282, 0.4732, 0.5496]}, {"w": "Gradient", "b": [0.478, 0.5282, 0.5526, 0.5496]}, {"w": "Descent,", "b": [0.5575, 0.5282, 0.6291, 0.5496]}, {"w": "since", "b": [0.6339, 0.5282, 0.6762, 0.5496]}, {"w": "it", "b": [0.6811, 0.5282, 0.693, 0.5496]}, {"w": "does", "b": [0.6979, 0.5282, 0.736, 0.5496]}, {"w": "not", "b": [0.7409, 0.5282, 0.7693, 0.5496]}, {"w": "bounce", "b": [0.7742, 0.5282, 0.8355, 0.5496]}, {"w": "as", "b": [0.8404, 0.5282, 0.8572, 0.5496]}, {"w": "much", "b": [0.1786, 0.5472, 0.2262, 0.5686]}, {"w": "left", "b": [0.231, 0.5472, 0.2576, 0.5686]}, {"w": "and", "b": [0.2623, 0.5472, 0.2939, 0.5686]}, {"w": "right", "b": [0.2986, 0.5472, 0.3388, 0.5686]}, {"w": "of", "b": [0.3435, 0.5472, 0.3603, 0.5686]}, {"w": "z", "b": [0.365, 0.547, 0.3737, 0.5686]}, {"w": "=", "b": [0.3784, 0.5472, 0.3905, 0.5686]}, {"w": "0.", "b": [0.3953, 0.5472, 0.41, 0.5686]}]}, {"id": "b_6", "type": "paragraph", "text": "The main drawback of the ELU activation function is that it is slower to compute than the ReLU and its variants (due to the use of the exponential function), but dur‐ ing training this is compensated by the faster convergence rate. However, at test time an ELU network will be slower than a ReLU network.", "words": [{"w": "The", "b": [0.1429, 0.5814, 0.1757, 0.6028]}, {"w": "main", "b": [0.1834, 0.5814, 0.2266, 0.6028]}, {"w": "drawback", "b": [0.2343, 0.5814, 0.3149, 0.6028]}, {"w": "of", "b": [0.3226, 0.5814, 0.3394, 0.6028]}, {"w": "the", "b": [0.3471, 0.5814, 0.3734, 0.6028]}, {"w": "ELU", "b": [0.3811, 0.5814, 0.4186, 0.6028]}, {"w": "activation", "b": [0.4263, 0.5814, 0.5086, 0.6028]}, {"w": "function", "b": [0.5163, 0.5814, 0.5877, 0.6028]}, {"w": "is", "b": [0.5954, 0.5814, 0.6086, 0.6028]}, {"w": "that", "b": [0.6163, 0.5814, 0.6489, 0.6028]}, {"w": "it", "b": [0.6565, 0.5814, 0.6685, 0.6028]}, {"w": "is", "b": [0.6762, 0.5814, 0.6894, 0.6028]}, {"w": "slower", "b": [0.6971, 0.5814, 0.7515, 0.6028]}, {"w": "to", "b": [0.7592, 0.5814, 0.7762, 0.6028]}, {"w": "compute", "b": [0.7839, 0.5814, 0.8571, 0.6028]}, {"w": "than", "b": [0.1429, 0.6004, 0.1809, 0.6219]}, {"w": "the", "b": [0.1866, 0.6004, 0.213, 0.6219]}, {"w": "ReLU", "b": [0.2187, 0.6004, 0.2662, 0.6219]}, {"w": "and", "b": [0.272, 0.6004, 0.3036, 0.6219]}, {"w": "its", "b": [0.3093, 0.6004, 0.3289, 0.6219]}, {"w": "variants", "b": [0.3347, 0.6004, 0.4009, 0.6219]}, {"w": "(due", "b": [0.4067, 0.6004, 0.4448, 0.6219]}, {"w": "to", "b": [0.4506, 0.6004, 0.4676, 0.6219]}, {"w": "the", "b": [0.4733, 0.6004, 0.4997, 0.6219]}, {"w": "use", "b": [0.5054, 0.6004, 0.533, 0.6219]}, {"w": "of", "b": [0.5388, 0.6004, 0.5556, 0.6219]}, {"w": "the", "b": [0.5613, 0.6004, 0.5877, 0.6219]}, {"w": "exponential", "b": [0.5934, 0.6004, 0.6913, 0.6219]}, {"w": "function),", "b": [0.697, 0.6004, 0.7804, 0.6219]}, {"w": "but", "b": [0.7862, 0.6004, 0.8142, 0.6219]}, {"w": "dur‐", "b": [0.8199, 0.6004, 0.8571, 0.6219]}, {"w": "ing", "b": [0.1428, 0.6195, 0.1696, 0.6409]}, {"w": "training", "b": [0.1752, 0.6195, 0.2421, 0.6409]}, {"w": "this", "b": [0.2477, 0.6195, 0.2784, 0.6409]}, {"w": "is", "b": [0.284, 0.6195, 0.2972, 0.6409]}, {"w": "compensated", "b": [0.3028, 0.6195, 0.4127, 0.6409]}, {"w": "by", "b": [0.4183, 0.6195, 0.4385, 0.6409]}, {"w": "the", "b": [0.4441, 0.6195, 0.4704, 0.6409]}, {"w": "faster", "b": [0.476, 0.6195, 0.5219, 0.6409]}, {"w": "convergence", "b": [0.5275, 0.6195, 0.6317, 0.6409]}, {"w": "rate.", "b": [0.6373, 0.6195, 0.6738, 0.6409]}, {"w": "However,", "b": [0.6793, 0.6195, 0.7582, 0.6409]}, {"w": "at", "b": [0.7638, 0.6195, 0.7789, 0.6409]}, {"w": "test", "b": [0.7845, 0.6195, 0.8137, 0.6409]}, {"w": "time", "b": [0.8193, 0.6195, 0.8572, 0.6409]}, {"w": "an", "b": [0.1429, 0.6385, 0.1634, 0.66]}, {"w": "ELU", "b": [0.1681, 0.6385, 0.2057, 0.66]}, {"w": "network", "b": [0.2104, 0.6385, 0.28, 0.66]}, {"w": "will", "b": [0.2847, 0.6385, 0.3151, 0.66]}, {"w": "be", "b": [0.3198, 0.6385, 0.3393, 0.66]}, {"w": "slower", "b": [0.344, 0.6385, 0.3984, 0.66]}, {"w": "than", "b": [0.4031, 0.6385, 0.4411, 0.66]}, {"w": "a", "b": [0.4459, 0.6385, 0.455, 0.66]}, {"w": "ReLU", "b": [0.4597, 0.6385, 0.5072, 0.66]}, {"w": "network.", "b": [0.512, 0.6385, 0.5863, 0.66]}]}, {"id": "b_7", "type": "paragraph", "text": "Moreover, in a 2017 paper7 by Günter Klambauer et al., called “Self-Normalizing Neural Networks”, the authors showed that if you build a neural network composed exclusively of a stack of dense layers, and if all hidden layers use the SELU activation function (which is just a scaled version of the ELU activation function, as its name suggests), then the network will self-normalize: the output of each layer will tend to preserve mean 0 and standard deviation 1 during training, which solves the vanish‐ ing/exploding gradients problem. As a result, this activation function often outper‐", "words": [{"w": "Moreover,", "b": [0.1429, 0.6667, 0.2284, 0.6881]}, {"w": "in", "b": [0.2373, 0.6667, 0.2543, 0.6881]}, {"w": "a", "b": [0.2633, 0.6667, 0.2724, 0.6881]}, {"w": "2017", "b": [0.2814, 0.6667, 0.3214, 0.6881]}, {"w": "paper7", "b": [0.3304, 0.6667, 0.3832, 0.6881]}, {"w": "by", "b": [0.3922, 0.6667, 0.4123, 0.6881]}, {"w": "Günter", "b": [0.4213, 0.6667, 0.4812, 0.6881]}, {"w": "Klambauer", "b": [0.4902, 0.6667, 0.5826, 0.6881]}, {"w": "et", "b": [0.5916, 0.6667, 0.6068, 0.6881]}, {"w": "al.,", "b": [0.6158, 0.6667, 0.6397, 0.6881]}, {"w": "called", "b": [0.6487, 0.6667, 0.697, 0.6881]}, {"w": "“Self-Normalizing", "b": [0.706, 0.6667, 0.8571, 0.6881]}, {"w": "Neural", "b": [0.1429, 0.6857, 0.1999, 0.7071]}, {"w": "Networks”,", "b": [0.2064, 0.6857, 0.2961, 0.7071]}, {"w": "the", "b": [0.3026, 0.6857, 0.3289, 0.7071]}, {"w": "authors", "b": [0.3354, 0.6857, 0.3987, 0.7071]}, {"w": "showed", "b": [0.4052, 0.6857, 0.4687, 0.7071]}, {"w": "that", "b": [0.4752, 0.6857, 0.5078, 0.7071]}, {"w": "if", "b": [0.5143, 0.6857, 0.5261, 0.7071]}, {"w": "you", "b": [0.5326, 0.6857, 0.5638, 0.7071]}, {"w": "build", "b": [0.5703, 0.6857, 0.6138, 0.7071]}, {"w": "a", "b": [0.6203, 0.6857, 0.6295, 0.7071]}, {"w": "neural", "b": [0.636, 0.6857, 0.6894, 0.7071]}, {"w": "network", "b": [0.6959, 0.6857, 0.7655, 0.7071]}, {"w": "composed", "b": [0.772, 0.6857, 0.8571, 0.7071]}, {"w": "exclusively", "b": [0.1428, 0.7048, 0.2332, 0.7262]}, {"w": "of", "b": [0.2389, 0.7048, 0.2557, 0.7262]}, {"w": "a", "b": [0.2614, 0.7048, 0.2705, 0.7262]}, {"w": "stack", "b": [0.2762, 0.7048, 0.3185, 0.7262]}, {"w": "of", "b": [0.3242, 0.7048, 0.341, 0.7262]}, {"w": "dense", "b": [0.3467, 0.7048, 0.3944, 0.7262]}, {"w": "layers,", "b": [0.4001, 0.7048, 0.4527, 0.7262]}, {"w": "and", "b": [0.4584, 0.7048, 0.4899, 0.7262]}, {"w": "if", "b": [0.4956, 0.7048, 0.5073, 0.7262]}, {"w": "all", "b": [0.513, 0.7048, 0.5327, 0.7262]}, {"w": "hidden", "b": [0.5384, 0.7048, 0.5973, 0.7262]}, {"w": "layers", "b": [0.603, 0.7048, 0.6509, 0.7262]}, {"w": "use", "b": [0.6565, 0.7048, 0.6841, 0.7262]}, {"w": "the", "b": [0.6898, 0.7048, 0.7161, 0.7262]}, {"w": "SELU", "b": [0.7218, 0.7048, 0.7692, 0.7262]}, {"w": "activation", "b": [0.7749, 0.7048, 0.8571, 0.7262]}, {"w": "function", "b": [0.1429, 0.7238, 0.2143, 0.7452]}, {"w": "(which", "b": [0.2213, 0.7238, 0.2794, 0.7452]}, {"w": "is", "b": [0.2864, 0.7238, 0.2996, 0.7452]}, {"w": "just", "b": [0.3066, 0.7238, 0.337, 0.7452]}, {"w": "a", "b": [0.344, 0.7238, 0.3531, 0.7452]}, {"w": "scaled", "b": [0.3601, 0.7238, 0.4108, 0.7452]}, {"w": "version", "b": [0.4178, 0.7238, 0.4793, 0.7452]}, {"w": "of", "b": [0.4863, 0.7238, 0.5031, 0.7452]}, {"w": "the", "b": [0.5101, 0.7238, 0.5364, 0.7452]}, {"w": "ELU", "b": [0.5434, 0.7238, 0.581, 0.7452]}, {"w": "activation", "b": [0.588, 0.7238, 0.6702, 0.7452]}, {"w": "function,", "b": [0.6772, 0.7238, 0.7533, 0.7452]}, {"w": "as", "b": [0.7603, 0.7238, 0.7771, 0.7452]}, {"w": "its", "b": [0.7841, 0.7238, 0.8037, 0.7452]}, {"w": "name", "b": [0.8107, 0.7238, 0.8571, 0.7452]}, {"w": "suggests),", "b": [0.1429, 0.7428, 0.2235, 0.7643]}, {"w": "then", "b": [0.2302, 0.7428, 0.268, 0.7643]}, {"w": "the", "b": [0.2747, 0.7428, 0.301, 0.7643]}, {"w": "network", "b": [0.3077, 0.7428, 0.3773, 0.7643]}, {"w": "will", "b": [0.384, 0.7428, 0.4144, 0.7643]}, {"w": "self-normalize:", "b": [0.4211, 0.7426, 0.5408, 0.7643]}, {"w": "the", "b": [0.5475, 0.7428, 0.5738, 0.7643]}, {"w": "output", "b": [0.5806, 0.7428, 0.6369, 0.7643]}, {"w": "of", "b": [0.6437, 0.7428, 0.6604, 0.7643]}, {"w": "each", "b": [0.6672, 0.7428, 0.7051, 0.7643]}, {"w": "layer", "b": [0.7118, 0.7428, 0.752, 0.7643]}, {"w": "will", "b": [0.7587, 0.7428, 0.7891, 0.7643]}, {"w": "tend", "b": [0.7958, 0.7428, 0.8334, 0.7643]}, {"w": "to", "b": [0.8402, 0.7428, 0.8571, 0.7643]}, {"w": "preserve", "b": [0.1429, 0.7619, 0.2137, 0.7833]}, {"w": "mean", "b": [0.2201, 0.7619, 0.2666, 0.7833]}, {"w": "0", "b": [0.273, 0.7619, 0.283, 0.7833]}, {"w": "and", "b": [0.2894, 0.7619, 0.321, 0.7833]}, {"w": "standard", "b": [0.3274, 0.7619, 0.4008, 0.7833]}, {"w": "deviation", "b": [0.4072, 0.7619, 0.485, 0.7833]}, {"w": "1", "b": [0.4915, 0.7619, 0.5015, 0.7833]}, {"w": "during", "b": [0.5079, 0.7619, 0.5644, 0.7833]}, {"w": "training,", "b": [0.5708, 0.7619, 0.6425, 0.7833]}, {"w": "which", "b": [0.649, 0.7619, 0.6999, 0.7833]}, {"w": "solves", "b": [0.7063, 0.7619, 0.756, 0.7833]}, {"w": "the", "b": [0.7624, 0.7619, 0.7888, 0.7833]}, {"w": "vanish‐", "b": [0.7952, 0.7619, 0.8571, 0.7833]}, {"w": "ing/exploding", "b": [0.1428, 0.7809, 0.2597, 0.8024]}, {"w": "gradients", "b": [0.2668, 0.7809, 0.3439, 0.8024]}, {"w": "problem.", "b": [0.351, 0.7809, 0.4268, 0.8024]}, {"w": "As", "b": [0.4339, 0.7809, 0.4559, 0.8024]}, {"w": "a", "b": [0.463, 0.7809, 0.4721, 0.8024]}, {"w": "result,", "b": [0.4792, 0.7809, 0.5309, 0.8024]}, {"w": "this", "b": [0.538, 0.7809, 0.5687, 0.8024]}, {"w": "activation", "b": [0.5758, 0.7809, 0.6581, 0.8024]}, {"w": "function", "b": [0.6652, 0.7809, 0.7366, 0.8024]}, {"w": "often", "b": [0.7437, 0.7809, 0.7871, 0.8024]}, {"w": "outper‐", "b": [0.7942, 0.7809, 0.8571, 0.8024]}]}, {"id": "b_8", "type": "equation", "text": "Vanishing/Exploding Gradients Problems | 331", "words": [{"w": "Vanishing/Exploding", "b": [0.5559, 0.9225, 0.678, 0.9388]}, {"w": "Gradients", "b": [0.6808, 0.9225, 0.7376, 0.9388]}, {"w": "Problems", "b": [0.7404, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "331", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 358, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "forms other activation functions very significantly for such neural nets (especially deep ones). However, there are a few conditions for self-normalization to happen:", "words": [{"w": "forms", "b": [0.1429, 0.0791, 0.1921, 0.1005]}, {"w": "other", "b": [0.2004, 0.0791, 0.2451, 0.1005]}, {"w": "activation", "b": [0.2533, 0.0791, 0.3356, 0.1005]}, {"w": "functions", "b": [0.3439, 0.0791, 0.4229, 0.1005]}, {"w": "very", "b": [0.4312, 0.0791, 0.4676, 0.1005]}, {"w": "significantly", "b": [0.4759, 0.0791, 0.5777, 0.1005]}, {"w": "for", "b": [0.586, 0.0791, 0.6105, 0.1005]}, {"w": "such", "b": [0.6188, 0.0791, 0.6575, 0.1005]}, {"w": "neural", "b": [0.6657, 0.0791, 0.7192, 0.1005]}, {"w": "nets", "b": [0.7275, 0.0791, 0.7617, 0.1005]}, {"w": "(especially", "b": [0.77, 0.0791, 0.8571, 0.1005]}, {"w": "deep", "b": [0.1429, 0.0981, 0.1825, 0.1195]}, {"w": "ones).", "b": [0.1872, 0.0981, 0.2377, 0.1195]}, {"w": "However,", "b": [0.2424, 0.0981, 0.3213, 0.1195]}, {"w": "there", "b": [0.326, 0.0981, 0.3689, 0.1195]}, {"w": "are", "b": [0.3736, 0.0981, 0.3994, 0.1195]}, {"w": "a", "b": [0.4041, 0.0981, 0.4132, 0.1195]}, {"w": "few", "b": [0.418, 0.0981, 0.4473, 0.1195]}, {"w": "conditions", "b": [0.452, 0.0981, 0.541, 0.1195]}, {"w": "for", "b": [0.5457, 0.0981, 0.5703, 0.1195]}, {"w": "self-normalization", "b": [0.575, 0.0981, 0.7286, 0.1195]}, {"w": "to", "b": [0.7334, 0.0981, 0.7503, 0.1195]}, {"w": "happen:", "b": [0.7551, 0.0981, 0.8218, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "• The input features must be standardized (mean 0 and standard deviation 1).", "words": [{"w": "•", "b": [0.16, 0.1323, 0.1681, 0.1537]}, {"w": "The", "b": [0.1786, 0.1323, 0.2114, 0.1537]}, {"w": "input", "b": [0.2161, 0.1323, 0.261, 0.1537]}, {"w": "features", "b": [0.2658, 0.1323, 0.3312, 0.1537]}, {"w": "must", "b": [0.3359, 0.1323, 0.3776, 0.1537]}, {"w": "be", "b": [0.3824, 0.1323, 0.4018, 0.1537]}, {"w": "standardized", "b": [0.4065, 0.1323, 0.5141, 0.1537]}, {"w": "(mean", "b": [0.5189, 0.1323, 0.5725, 0.1537]}, {"w": "0", "b": [0.5773, 0.1323, 0.5873, 0.1537]}, {"w": "and", "b": [0.592, 0.1323, 0.6235, 0.1537]}, {"w": "standard", "b": [0.6283, 0.1323, 0.7017, 0.1537]}, {"w": "deviation", "b": [0.7064, 0.1323, 0.7842, 0.1537]}, {"w": "1).", "b": [0.7889, 0.1323, 0.8109, 0.1537]}]}, {"id": "b_2", "type": "paragraph", "text": "• Every hidden layer’s weights must also be initialized using LeCun normal initiali‐ zation. In Keras, this means setting kernel_initializer=\"lecun_normal\".", "words": [{"w": "•", "b": [0.16, 0.1574, 0.1682, 0.1788]}, {"w": "Every", "b": [0.1786, 0.1574, 0.2264, 0.1788]}, {"w": "hidden", "b": [0.2315, 0.1574, 0.2904, 0.1788]}, {"w": "layer’s", "b": [0.2956, 0.1574, 0.3461, 0.1788]}, {"w": "weights", "b": [0.3512, 0.1574, 0.4144, 0.1788]}, {"w": "must", "b": [0.4195, 0.1574, 0.4612, 0.1788]}, {"w": "also", "b": [0.4663, 0.1574, 0.499, 0.1788]}, {"w": "be", "b": [0.5041, 0.1574, 0.5235, 0.1788]}, {"w": "initialized", "b": [0.5286, 0.1574, 0.6117, 0.1788]}, {"w": "using", "b": [0.6169, 0.1574, 0.6623, 0.1788]}, {"w": "LeCun", "b": [0.6674, 0.1574, 0.7238, 0.1788]}, {"w": "normal", "b": [0.7289, 0.1574, 0.7901, 0.1788]}, {"w": "initiali‐", "b": [0.7952, 0.1574, 0.8571, 0.1788]}, {"w": "zation.", "b": [0.1786, 0.1773, 0.2348, 0.1987]}, {"w": "In", "b": [0.2395, 0.1773, 0.258, 0.1987]}, {"w": "Keras,", "b": [0.2627, 0.1773, 0.3144, 0.1987]}, {"w": "this", "b": [0.3191, 0.1773, 0.3498, 0.1987]}, {"w": "means", "b": [0.3546, 0.1773, 0.4087, 0.1987]}, {"w": "setting", "b": [0.4134, 0.1773, 0.4693, 0.1987]}, {"w": "kernel_initializer=\"lecun_normal\".", "b": [0.4741, 0.1773, 0.8054, 0.1987]}]}, {"id": "b_3", "type": "paragraph", "text": "• The network’s architecture must be sequential. Unfortunately, if you try to use SELU in non-sequential architectures, such as recurrent networks (see ???) or networks with skip connections (i.e., connections that skip layers, such as in wide & deep nets), self-normalization will not be guaranteed, so SELU will not neces‐ sarily outperform other activation functions.", "words": [{"w": "•", "b": [0.16, 0.2024, 0.1682, 0.2238]}, {"w": "The", "b": [0.1786, 0.2024, 0.2114, 0.2238]}, {"w": "network’s", "b": [0.2189, 0.2024, 0.298, 0.2238]}, {"w": "architecture", "b": [0.3055, 0.2024, 0.4059, 0.2238]}, {"w": "must", "b": [0.4135, 0.2024, 0.4552, 0.2238]}, {"w": "be", "b": [0.4627, 0.2024, 0.4822, 0.2238]}, {"w": "sequential.", "b": [0.4897, 0.2024, 0.5789, 0.2238]}, {"w": "Unfortunately,", "b": [0.5864, 0.2024, 0.7076, 0.2238]}, {"w": "if", "b": [0.7152, 0.2024, 0.7269, 0.2238]}, {"w": "you", "b": [0.7345, 0.2024, 0.7657, 0.2238]}, {"w": "try", "b": [0.7733, 0.2024, 0.7975, 0.2238]}, {"w": "to", "b": [0.8051, 0.2024, 0.822, 0.2238]}, {"w": "use", "b": [0.8296, 0.2024, 0.8571, 0.2238]}, {"w": "SELU", "b": [0.1786, 0.2215, 0.226, 0.2429]}, {"w": "in", "b": [0.2343, 0.2215, 0.2513, 0.2429]}, {"w": "non-sequential", "b": [0.2597, 0.2215, 0.3849, 0.2429]}, {"w": "architectures,", "b": [0.3933, 0.2215, 0.5061, 0.2429]}, {"w": "such", "b": [0.5144, 0.2215, 0.5531, 0.2429]}, {"w": "as", "b": [0.5614, 0.2215, 0.5782, 0.2429]}, {"w": "recurrent", "b": [0.5866, 0.2215, 0.6647, 0.2429]}, {"w": "networks", "b": [0.6731, 0.2215, 0.7503, 0.2429]}, {"w": "(see", "b": [0.7586, 0.2215, 0.7912, 0.2429]}, {"w": "???)", "b": [0.7995, 0.2215, 0.8304, 0.2429]}, {"w": "or", "b": [0.8388, 0.2215, 0.8571, 0.2429]}, {"w": "networks", "b": [0.1786, 0.2405, 0.2558, 0.2619]}, {"w": "with", "b": [0.2615, 0.2405, 0.2988, 0.2619]}, {"w": "skip", "b": [0.3045, 0.2403, 0.3363, 0.2619]}, {"w": "connections", "b": [0.342, 0.2403, 0.4368, 0.2619]}, {"w": "(i.e.,", "b": [0.4425, 0.2405, 0.4784, 0.2619]}, {"w": "connections", "b": [0.4841, 0.2405, 0.5856, 0.2619]}, {"w": "that", "b": [0.5913, 0.2405, 0.6238, 0.2619]}, {"w": "skip", "b": [0.6295, 0.2405, 0.664, 0.2619]}, {"w": "layers,", "b": [0.6697, 0.2405, 0.7223, 0.2619]}, {"w": "such", "b": [0.728, 0.2405, 0.7666, 0.2619]}, {"w": "as", "b": [0.7723, 0.2405, 0.7891, 0.2619]}, {"w": "in", "b": [0.7948, 0.2405, 0.8117, 0.2619]}, {"w": "wide", "b": [0.8174, 0.2405, 0.8571, 0.2619]}, {"w": "&", "b": [0.1786, 0.2595, 0.1934, 0.281]}, {"w": "deep", "b": [0.1993, 0.2595, 0.2389, 0.281]}, {"w": "nets),", "b": [0.2448, 0.2595, 0.2911, 0.281]}, {"w": "self-normalization", "b": [0.297, 0.2595, 0.4506, 0.281]}, {"w": "will", "b": [0.4565, 0.2595, 0.4869, 0.281]}, {"w": "not", "b": [0.4928, 0.2595, 0.5212, 0.281]}, {"w": "be", "b": [0.5271, 0.2595, 0.5466, 0.281]}, {"w": "guaranteed,", "b": [0.5525, 0.2595, 0.6501, 0.281]}, {"w": "so", "b": [0.656, 0.2595, 0.6743, 0.281]}, {"w": "SELU", "b": [0.6802, 0.2595, 0.7276, 0.281]}, {"w": "will", "b": [0.7336, 0.2595, 0.764, 0.281]}, {"w": "not", "b": [0.7699, 0.2595, 0.7982, 0.281]}, {"w": "neces‐", "b": [0.8042, 0.2595, 0.8571, 0.281]}, {"w": "sarily", "b": [0.1786, 0.2786, 0.2235, 0.3]}, {"w": "outperform", "b": [0.2282, 0.2786, 0.3254, 0.3]}, {"w": "other", "b": [0.3301, 0.2786, 0.3748, 0.3]}, {"w": "activation", "b": [0.3795, 0.2786, 0.4618, 0.3]}, {"w": "functions.", "b": [0.4665, 0.2786, 0.5503, 0.3]}]}, {"id": "b_4", "type": "paragraph", "text": "• The paper only guarantees self-normalization if all layers are dense. However, in practice the SELU activation function seems to work great with convolutional neural nets as well (see Chapter 14).", "words": [{"w": "•", "b": [0.16, 0.3037, 0.1681, 0.3251]}, {"w": "The", "b": [0.1786, 0.3037, 0.2114, 0.3251]}, {"w": "paper", "b": [0.2173, 0.3037, 0.2645, 0.3251]}, {"w": "only", "b": [0.2704, 0.3037, 0.3073, 0.3251]}, {"w": "guarantees", "b": [0.3132, 0.3037, 0.4027, 0.3251]}, {"w": "self-normalization", "b": [0.4087, 0.3037, 0.5623, 0.3251]}, {"w": "if", "b": [0.5682, 0.3037, 0.58, 0.3251]}, {"w": "all", "b": [0.5859, 0.3037, 0.6056, 0.3251]}, {"w": "layers", "b": [0.6115, 0.3037, 0.6594, 0.3251]}, {"w": "are", "b": [0.6653, 0.3037, 0.691, 0.3251]}, {"w": "dense.", "b": [0.6969, 0.3037, 0.7494, 0.3251]}, {"w": "However,", "b": [0.7554, 0.3037, 0.8342, 0.3251]}, {"w": "in", "b": [0.8402, 0.3037, 0.8571, 0.3251]}, {"w": "practice", "b": [0.1786, 0.3227, 0.2448, 0.3442]}, {"w": "the", "b": [0.2529, 0.3227, 0.2792, 0.3442]}, {"w": "SELU", "b": [0.2873, 0.3227, 0.3347, 0.3442]}, {"w": "activation", "b": [0.3428, 0.3227, 0.425, 0.3442]}, {"w": "function", "b": [0.4331, 0.3227, 0.5045, 0.3442]}, {"w": "seems", "b": [0.5126, 0.3227, 0.5627, 0.3442]}, {"w": "to", "b": [0.5708, 0.3227, 0.5877, 0.3442]}, {"w": "work", "b": [0.5958, 0.3227, 0.6388, 0.3442]}, {"w": "great", "b": [0.6469, 0.3227, 0.6883, 0.3442]}, {"w": "with", "b": [0.6964, 0.3227, 0.7337, 0.3442]}, {"w": "convolutional", "b": [0.7418, 0.3227, 0.8571, 0.3442]}, {"w": "neural", "b": [0.1786, 0.3418, 0.232, 0.3632]}, {"w": "nets", "b": [0.2368, 0.3418, 0.271, 0.3632]}, {"w": "as", "b": [0.2757, 0.3418, 0.2925, 0.3632]}, {"w": "well", "b": [0.2972, 0.3418, 0.3309, 0.3632]}, {"w": "(see", "b": [0.3356, 0.3418, 0.3682, 0.3632]}, {"w": "Chapter", "b": [0.3729, 0.3418, 0.4405, 0.3632]}, {"w": "14).", "b": [0.4452, 0.3418, 0.4772, 0.3632]}]}, {"id": "b_5", "type": "paragraph", "text": "So which activation function should you use for the hidden layers of your deep neural networks? Although your mileage will vary, in general SELU > ELU > leaky ReLU (and its variants) > ReLU > tanh > logistic. If the network’s architecture prevents it from self- normalizing, then ELU may perform better than SELU (since SELU is not smooth at z = 0). If you care a lot about runtime latency, then you may prefer leaky ReLU. If you don’t want to tweak yet another hyperparameter, you may just use the default α values used by Keras (e.g., 0.3 for the leaky ReLU). If you have spare time and computing power, you can use cross-validation to evaluate other activation functions, in particular RReLU if your network is over‐ fitting, or PReLU if you have a huge training set.", "words": [{"w": "So", "b": [0.2714, 0.3988, 0.2902, 0.4184]}, {"w": "which", "b": [0.296, 0.3988, 0.3426, 0.4184]}, {"w": "activation", "b": [0.3485, 0.3988, 0.4237, 0.4184]}, {"w": "function", "b": [0.4295, 0.3988, 0.4948, 0.4184]}, {"w": "should", "b": [0.5007, 0.3988, 0.5526, 0.4184]}, {"w": "you", "b": [0.5584, 0.3988, 0.587, 0.4184]}, {"w": "use", "b": [0.5929, 0.3988, 0.6181, 0.4184]}, {"w": "for", "b": [0.624, 0.3988, 0.6464, 0.4184]}, {"w": "the", "b": [0.6523, 0.3988, 0.6763, 0.4184]}, {"w": "hidden", "b": [0.6822, 0.3988, 0.7361, 0.4184]}, {"w": "layers", "b": [0.742, 0.3988, 0.7857, 0.4184]}, {"w": "of", "b": [0.2714, 0.4163, 0.2868, 0.4358]}, {"w": "your", "b": [0.2921, 0.4163, 0.3277, 0.4358]}, {"w": "deep", "b": [0.333, 0.4163, 0.3692, 0.4358]}, {"w": "neural", "b": [0.3745, 0.4163, 0.4234, 0.4358]}, {"w": "networks?", "b": [0.4287, 0.4163, 0.5065, 0.4358]}, {"w": "Although", "b": [0.5118, 0.4163, 0.5847, 0.4358]}, {"w": "your", "b": [0.59, 0.4163, 0.6257, 0.4358]}, {"w": "mileage", "b": [0.631, 0.4163, 0.69, 0.4358]}, {"w": "will", "b": [0.6953, 0.4163, 0.7231, 0.4358]}, {"w": "vary,", "b": [0.7284, 0.4163, 0.7649, 0.4358]}, {"w": "in", "b": [0.7702, 0.4163, 0.7857, 0.4358]}, {"w": "general", "b": [0.2714, 0.4337, 0.3272, 0.4533]}, {"w": "SELU", "b": [0.3316, 0.4337, 0.3749, 0.4533]}, {"w": ">", "b": [0.3793, 0.4337, 0.3898, 0.4533]}, {"w": "ELU", "b": [0.3942, 0.4337, 0.4286, 0.4533]}, {"w": ">", "b": [0.433, 0.4337, 0.4435, 0.4533]}, {"w": "leaky", "b": [0.4479, 0.4337, 0.4874, 0.4533]}, {"w": "ReLU", "b": [0.4918, 0.4337, 0.5352, 0.4533]}, {"w": "(and", "b": [0.5396, 0.4337, 0.575, 0.4533]}, {"w": "its", "b": [0.5794, 0.4337, 0.5973, 0.4533]}, {"w": "variants)", "b": [0.6017, 0.4337, 0.6689, 0.4533]}, {"w": ">", "b": [0.6733, 0.4337, 0.6838, 0.4533]}, {"w": "ReLU", "b": [0.6882, 0.4337, 0.7316, 0.4533]}, {"w": ">", "b": [0.736, 0.4337, 0.7465, 0.4533]}, {"w": "tanh", "b": [0.7509, 0.4337, 0.7857, 0.4533]}, {"w": ">", "b": [0.2714, 0.4511, 0.2819, 0.4707]}, {"w": "logistic.", "b": [0.2929, 0.4511, 0.3517, 0.4707]}, {"w": "If", "b": [0.3627, 0.4511, 0.3748, 0.4707]}, {"w": "the", "b": [0.3857, 0.4511, 0.4098, 0.4707]}, {"w": "network’s", "b": [0.4208, 0.4511, 0.493, 0.4707]}, {"w": "architecture", "b": [0.5039, 0.4511, 0.5958, 0.4707]}, {"w": "prevents", "b": [0.6067, 0.4511, 0.6716, 0.4707]}, {"w": "it", "b": [0.6826, 0.4511, 0.6935, 0.4707]}, {"w": "from", "b": [0.7044, 0.4511, 0.7424, 0.4707]}, {"w": "self-", "b": [0.7534, 0.4511, 0.7857, 0.4707]}, {"w": "normalizing,", "b": [0.2714, 0.4685, 0.3693, 0.4881]}, {"w": "then", "b": [0.3738, 0.4685, 0.4083, 0.4881]}, {"w": "ELU", "b": [0.4128, 0.4685, 0.4472, 0.4881]}, {"w": "may", "b": [0.4517, 0.4685, 0.4841, 0.4881]}, {"w": "perform", "b": [0.4886, 0.4685, 0.5518, 0.4881]}, {"w": "better", "b": [0.5563, 0.4685, 0.6008, 0.4881]}, {"w": "than", "b": [0.6054, 0.4685, 0.6401, 0.4881]}, {"w": "SELU", "b": [0.6447, 0.4685, 0.688, 0.4881]}, {"w": "(since", "b": [0.6926, 0.4685, 0.7378, 0.4881]}, {"w": "SELU", "b": [0.7424, 0.4685, 0.7857, 0.4881]}, {"w": "is", "b": [0.2714, 0.4859, 0.2835, 0.5055]}, {"w": "not", "b": [0.288, 0.4859, 0.3139, 0.5055]}, {"w": "smooth", "b": [0.3184, 0.4859, 0.3764, 0.5055]}, {"w": "at", "b": [0.3809, 0.4859, 0.3947, 0.5055]}, {"w": "z", "b": [0.3992, 0.4857, 0.4072, 0.5055]}, {"w": "=", "b": [0.4117, 0.4859, 0.4227, 0.5055]}, {"w": "0).", "b": [0.4272, 0.4859, 0.4473, 0.5055]}, {"w": "If", "b": [0.4518, 0.4859, 0.464, 0.5055]}, {"w": "you", "b": [0.4685, 0.4859, 0.497, 0.5055]}, {"w": "care", "b": [0.5015, 0.4859, 0.5331, 0.5055]}, {"w": "a", "b": [0.5376, 0.4859, 0.546, 0.5055]}, {"w": "lot", "b": [0.5505, 0.4859, 0.5708, 0.5055]}, {"w": "about", "b": [0.5753, 0.4859, 0.619, 0.5055]}, {"w": "runtime", "b": [0.6235, 0.4859, 0.6853, 0.5055]}, {"w": "latency,", "b": [0.6898, 0.4859, 0.7467, 0.5055]}, {"w": "then", "b": [0.7512, 0.4859, 0.7857, 0.5055]}, {"w": "you", "b": [0.2714, 0.5033, 0.3, 0.5229]}, {"w": "may", "b": [0.3052, 0.5033, 0.3376, 0.5229]}, {"w": "prefer", "b": [0.3428, 0.5033, 0.3888, 0.5229]}, {"w": "leaky", "b": [0.394, 0.5033, 0.4335, 0.5229]}, {"w": "ReLU.", "b": [0.4388, 0.5033, 0.4851, 0.5229]}, {"w": "If", "b": [0.4904, 0.5033, 0.5025, 0.5229]}, {"w": "you", "b": [0.5077, 0.5033, 0.5363, 0.5229]}, {"w": "don’t", "b": [0.5416, 0.5033, 0.5796, 0.5229]}, {"w": "want", "b": [0.5849, 0.5033, 0.6221, 0.5229]}, {"w": "to", "b": [0.6274, 0.5033, 0.6429, 0.5229]}, {"w": "tweak", "b": [0.6482, 0.5033, 0.6929, 0.5229]}, {"w": "yet", "b": [0.6982, 0.5033, 0.7208, 0.5229]}, {"w": "another", "b": [0.7261, 0.5033, 0.7857, 0.5229]}, {"w": "hyperparameter,", "b": [0.2714, 0.5208, 0.3966, 0.5403]}, {"w": "you", "b": [0.4054, 0.5208, 0.4339, 0.5403]}, {"w": "may", "b": [0.4427, 0.5208, 0.475, 0.5403]}, {"w": "just", "b": [0.4838, 0.5208, 0.5116, 0.5403]}, {"w": "use", "b": [0.5203, 0.5208, 0.5455, 0.5403]}, {"w": "the", "b": [0.5543, 0.5208, 0.5784, 0.5403]}, {"w": "default", "b": [0.5871, 0.5208, 0.6396, 0.5403]}, {"w": "α", "b": [0.6484, 0.5206, 0.6586, 0.5403]}, {"w": "values", "b": [0.6673, 0.5208, 0.7145, 0.5403]}, {"w": "used", "b": [0.7233, 0.5208, 0.7585, 0.5403]}, {"w": "by", "b": [0.7673, 0.5208, 0.7857, 0.5403]}, {"w": "Keras", "b": [0.2714, 0.5382, 0.3143, 0.5577]}, {"w": "(e.g.,", "b": [0.322, 0.5382, 0.3586, 0.5577]}, {"w": "0.3", "b": [0.3663, 0.5382, 0.3889, 0.5577]}, {"w": "for", "b": [0.3966, 0.5382, 0.419, 0.5577]}, {"w": "the", "b": [0.4267, 0.5382, 0.4507, 0.5577]}, {"w": "leaky", "b": [0.4584, 0.5382, 0.4979, 0.5577]}, {"w": "ReLU).", "b": [0.5055, 0.5382, 0.5599, 0.5577]}, {"w": "If", "b": [0.5676, 0.5382, 0.5797, 0.5577]}, {"w": "you", "b": [0.5874, 0.5382, 0.616, 0.5577]}, {"w": "have", "b": [0.6236, 0.5382, 0.6587, 0.5577]}, {"w": "spare", "b": [0.6664, 0.5382, 0.7069, 0.5577]}, {"w": "time", "b": [0.7146, 0.5382, 0.7492, 0.5577]}, {"w": "and", "b": [0.7569, 0.5382, 0.7857, 0.5577]}, {"w": "computing", "b": [0.2714, 0.5556, 0.3548, 0.5752]}, {"w": "power,", "b": [0.3621, 0.5556, 0.4132, 0.5752]}, {"w": "you", "b": [0.4206, 0.5556, 0.4491, 0.5752]}, {"w": "can", "b": [0.4565, 0.5556, 0.4833, 0.5752]}, {"w": "use", "b": [0.4907, 0.5556, 0.5159, 0.5752]}, {"w": "cross-validation", "b": [0.5233, 0.5556, 0.6451, 0.5752]}, {"w": "to", "b": [0.6525, 0.5556, 0.668, 0.5752]}, {"w": "evaluate", "b": [0.6754, 0.5556, 0.7375, 0.5752]}, {"w": "other", "b": [0.7449, 0.5556, 0.7857, 0.5752]}, {"w": "activation", "b": [0.2714, 0.573, 0.3466, 0.5926]}, {"w": "functions,", "b": [0.3527, 0.573, 0.4293, 0.5926]}, {"w": "in", "b": [0.4353, 0.573, 0.4508, 0.5926]}, {"w": "particular", "b": [0.4569, 0.573, 0.5316, 0.5926]}, {"w": "RReLU", "b": [0.5377, 0.573, 0.5929, 0.5926]}, {"w": "if", "b": [0.599, 0.573, 0.6097, 0.5926]}, {"w": "your", "b": [0.6158, 0.573, 0.6514, 0.5926]}, {"w": "network", "b": [0.6574, 0.573, 0.721, 0.5926]}, {"w": "is", "b": [0.7271, 0.573, 0.7392, 0.5926]}, {"w": "over‐", "b": [0.7452, 0.573, 0.7857, 0.5926]}, {"w": "fitting,", "b": [0.2714, 0.5904, 0.3226, 0.61]}, {"w": "or", "b": [0.3269, 0.5904, 0.3437, 0.61]}, {"w": "PReLU", "b": [0.348, 0.5904, 0.4021, 0.61]}, {"w": "if", "b": [0.4065, 0.5904, 0.4172, 0.61]}, {"w": "you", "b": [0.4215, 0.5904, 0.4501, 0.61]}, {"w": "have", "b": [0.4544, 0.5904, 0.4895, 0.61]}, {"w": "a", "b": [0.4938, 0.5904, 0.5022, 0.61]}, {"w": "huge", "b": [0.5065, 0.5904, 0.5435, 0.61]}, {"w": "training", "b": [0.5478, 0.5904, 0.609, 0.61]}, {"w": "set.", "b": [0.6133, 0.5904, 0.6386, 0.61]}]}, {"id": "b_6", "type": "paragraph", "text": "To use the leaky ReLU activation function, you must create a LeakyReLU instance like this:", "words": [{"w": "To", "b": [0.1429, 0.6312, 0.1643, 0.6526]}, {"w": "use", "b": [0.1697, 0.6312, 0.1973, 0.6526]}, {"w": "the", "b": [0.2027, 0.6312, 0.229, 0.6526]}, {"w": "leaky", "b": [0.2344, 0.6312, 0.2775, 0.6526]}, {"w": "ReLU", "b": [0.2829, 0.6312, 0.3304, 0.6526]}, {"w": "activation", "b": [0.3358, 0.6312, 0.4181, 0.6526]}, {"w": "function,", "b": [0.4235, 0.6312, 0.4996, 0.6526]}, {"w": "you", "b": [0.505, 0.6312, 0.5363, 0.6526]}, {"w": "must", "b": [0.5417, 0.6312, 0.5834, 0.6526]}, {"w": "create", "b": [0.5888, 0.6312, 0.6381, 0.6526]}, {"w": "a", "b": [0.6435, 0.6312, 0.6527, 0.6526]}, {"w": "LeakyReLU", "b": [0.6581, 0.6344, 0.7471, 0.6494]}, {"w": "instance", "b": [0.7525, 0.6312, 0.8217, 0.6526]}, {"w": "like", "b": [0.8264, 0.6312, 0.8565, 0.6526]}, {"w": "this:", "b": [0.1429, 0.6502, 0.1783, 0.6716]}]}, {"id": "b_7", "type": "paragraph", "text": "leaky_relu = keras.layers.LeakyReLU(alpha=0.2) layer = keras.layers.Dense(10, activation=leaky_relu, kernel_initializer=\"he_normal\")", "words": [{"w": "leaky_relu", "b": [0.1766, 0.6822, 0.2609, 0.6951]}, {"w": "=", "b": [0.2693, 0.6822, 0.2778, 0.6951]}, {"w": "keras.layers.LeakyReLU(alpha=0.2)", "b": [0.2862, 0.6822, 0.5645, 0.6951]}, {"w": "layer", "b": [0.1766, 0.6976, 0.2187, 0.7105]}, {"w": "=", "b": [0.2272, 0.6976, 0.2356, 0.7105]}, {"w": "keras.layers.Dense(10,", "b": [0.244, 0.6976, 0.4296, 0.7105]}, {"w": "activation=leaky_relu,", "b": [0.438, 0.6976, 0.6235, 0.7105]}, {"w": "kernel_initializer=\"he_normal\")", "b": [0.4043, 0.713, 0.6657, 0.7259]}]}, {"id": "b_8", "type": "paragraph", "text": "For PReLU, just replace LeakyRelu(alpha=0.2) with PReLU(). There is currently no official implementation of RReLU in Keras, but you can fairly easily implement your own (see the exercises at the end of Chapter 12).", "words": [{"w": "For", "b": [0.1429, 0.7346, 0.1718, 0.756]}, {"w": "PReLU,", "b": [0.1781, 0.7346, 0.2405, 0.756]}, {"w": "just", "b": [0.2468, 0.7346, 0.2772, 0.756]}, {"w": "replace", "b": [0.2834, 0.7346, 0.343, 0.756]}, {"w": "LeakyRelu(alpha=0.2)", "b": [0.3493, 0.7378, 0.5472, 0.7528]}, {"w": "with", "b": [0.5535, 0.7346, 0.5908, 0.756]}, {"w": "PReLU().", "b": [0.597, 0.7346, 0.6711, 0.756]}, {"w": "There", "b": [0.6773, 0.7346, 0.7267, 0.756]}, {"w": "is", "b": [0.733, 0.7346, 0.7462, 0.756]}, {"w": "currently", "b": [0.7525, 0.7346, 0.8289, 0.756]}, {"w": "no", "b": [0.8351, 0.7346, 0.8571, 0.756]}, {"w": "official", "b": [0.1429, 0.7536, 0.2002, 0.775]}, {"w": "implementation", "b": [0.2061, 0.7536, 0.3393, 0.775]}, {"w": "of", "b": [0.3452, 0.7536, 0.362, 0.775]}, {"w": "RReLU", "b": [0.3678, 0.7536, 0.4282, 0.775]}, {"w": "in", "b": [0.4341, 0.7536, 0.4511, 0.775]}, {"w": "Keras,", "b": [0.4569, 0.7536, 0.5086, 0.775]}, {"w": "but", "b": [0.5144, 0.7536, 0.5424, 0.775]}, {"w": "you", "b": [0.5482, 0.7536, 0.5795, 0.775]}, {"w": "can", "b": [0.5853, 0.7536, 0.6147, 0.775]}, {"w": "fairly", "b": [0.6205, 0.7536, 0.664, 0.775]}, {"w": "easily", "b": [0.6698, 0.7536, 0.7159, 0.775]}, {"w": "implement", "b": [0.7218, 0.7536, 0.8123, 0.775]}, {"w": "your", "b": [0.8182, 0.7536, 0.8571, 0.775]}, {"w": "own", "b": [0.1429, 0.7727, 0.1792, 0.7941]}, {"w": "(see", "b": [0.1839, 0.7727, 0.2165, 0.7941]}, {"w": "the", "b": [0.2212, 0.7727, 0.2475, 0.7941]}, {"w": "exercises", "b": [0.2522, 0.7727, 0.3261, 0.7941]}, {"w": "at", "b": [0.3308, 0.7727, 0.3459, 0.7941]}, {"w": "the", "b": [0.3506, 0.7727, 0.377, 0.7941]}, {"w": "end", "b": [0.3817, 0.7727, 0.4129, 0.7941]}, {"w": "of", "b": [0.4177, 0.7727, 0.4345, 0.7941]}, {"w": "Chapter", "b": [0.4392, 0.7727, 0.5068, 0.7941]}, {"w": "12).", "b": [0.5115, 0.7727, 0.5435, 0.7941]}]}, {"id": "b_9", "type": "paragraph", "text": "For SELU activation, just set activation=\"selu\" and kernel_initial izer=\"lecun_normal\" when creating a layer:", "words": [{"w": "For", "b": [0.1429, 0.8017, 0.1718, 0.8231]}, {"w": "SELU", "b": [0.1925, 0.8017, 0.2399, 0.8231]}, {"w": "activation,", "b": [0.2605, 0.8017, 0.3475, 0.8231]}, {"w": "just", "b": [0.3681, 0.8017, 0.3985, 0.8231]}, {"w": "set", "b": [0.4191, 0.8017, 0.4419, 0.8231]}, {"w": "activation=\"selu\"", "b": [0.4625, 0.8049, 0.6308, 0.8199]}, {"w": "and", "b": [0.6514, 0.8017, 0.6829, 0.8231]}, {"w": "kernel_initial", "b": [0.7035, 0.8049, 0.8421, 0.8199]}, {"w": "izer=\"lecun_normal\"", "b": [0.1429, 0.8248, 0.3309, 0.8399]}, {"w": "when", "b": [0.3356, 0.8216, 0.3812, 0.843]}, {"w": "creating", "b": [0.386, 0.8216, 0.4532, 0.843]}, {"w": "a", "b": [0.4579, 0.8216, 0.4671, 0.843]}, {"w": "layer:", "b": [0.4718, 0.8216, 0.5172, 0.843]}]}, {"id": "b_10", "type": "paragraph", "text": "layer = keras.layers.Dense(10, activation=\"selu\", kernel_initializer=\"lecun_normal\")", "words": [{"w": "layer", "b": [0.1766, 0.8536, 0.2188, 0.8664]}, {"w": "=", "b": [0.2272, 0.8536, 0.2356, 0.8664]}, {"w": "keras.layers.Dense(10,", "b": [0.244, 0.8536, 0.4296, 0.8664]}, {"w": "activation=\"selu\",", "b": [0.438, 0.8536, 0.5898, 0.8664]}, {"w": "kernel_initializer=\"lecun_normal\")", "b": [0.4043, 0.869, 0.691, 0.8819]}]}, {"id": "b_11", "type": "paragraph", "text": "332 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "332", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2746, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3265, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 359, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "8 “Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift,” S. Ioffe and C. Szegedy (2015).", "words": [{"w": "8", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "“Batch", "b": [0.1587, 0.8598, 0.2011, 0.8761]}, {"w": "Normalization:", "b": [0.2047, 0.8598, 0.3011, 0.8761]}, {"w": "Accelerating", "b": [0.3047, 0.8598, 0.384, 0.8761]}, {"w": "Deep", "b": [0.3876, 0.8598, 0.4211, 0.8761]}, {"w": "Network", "b": [0.4247, 0.8598, 0.4804, 0.8761]}, {"w": "Training", "b": [0.484, 0.8598, 0.5386, 0.8761]}, {"w": "by", "b": [0.5422, 0.8598, 0.5576, 0.8761]}, {"w": "Reducing", "b": [0.5612, 0.8598, 0.6217, 0.8761]}, {"w": "Internal", "b": [0.6253, 0.8598, 0.6762, 0.8761]}, {"w": "Covariate", "b": [0.6798, 0.8598, 0.7412, 0.8761]}, {"w": "Shift,”", "b": [0.7448, 0.8598, 0.7824, 0.8761]}, {"w": "S.", "b": [0.786, 0.8598, 0.7971, 0.8761]}, {"w": "Ioffe", "b": [0.8007, 0.8598, 0.83, 0.8761]}, {"w": "and", "b": [0.1587, 0.8749, 0.1828, 0.8912]}, {"w": "C.", "b": [0.1864, 0.8749, 0.2005, 0.8912]}, {"w": "Szegedy", "b": [0.2041, 0.8749, 0.2549, 0.8912]}, {"w": "(2015).", "b": [0.2585, 0.8749, 0.3036, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Batch Normalization", "words": [{"w": "Batch", "b": [0.1429, 0.0763, 0.2018, 0.1049]}, {"w": "Normalization", "b": [0.2067, 0.0763, 0.3539, 0.1049]}]}, {"id": "b_2", "type": "paragraph", "text": "Although using He initialization along with ELU (or any variant of ReLU) can signifi‐ cantly reduce the vanishing/exploding gradients problems at the beginning of train‐ ing, it doesn’t guarantee that they won’t come back during training.", "words": [{"w": "Although", "b": [0.1429, 0.1108, 0.2226, 0.1322]}, {"w": "using", "b": [0.2275, 0.1108, 0.2729, 0.1322]}, {"w": "He", "b": [0.2779, 0.1108, 0.3022, 0.1322]}, {"w": "initialization", "b": [0.3071, 0.1108, 0.413, 0.1322]}, {"w": "along", "b": [0.418, 0.1108, 0.4642, 0.1322]}, {"w": "with", "b": [0.4691, 0.1108, 0.5064, 0.1322]}, {"w": "ELU", "b": [0.5113, 0.1108, 0.5489, 0.1322]}, {"w": "(or", "b": [0.5538, 0.1108, 0.5794, 0.1322]}, {"w": "any", "b": [0.5843, 0.1108, 0.6139, 0.1322]}, {"w": "variant", "b": [0.6189, 0.1108, 0.6775, 0.1322]}, {"w": "of", "b": [0.6824, 0.1108, 0.6992, 0.1322]}, {"w": "ReLU)", "b": [0.7041, 0.1108, 0.7588, 0.1322]}, {"w": "can", "b": [0.7637, 0.1108, 0.7931, 0.1322]}, {"w": "signifi‐", "b": [0.798, 0.1108, 0.8572, 0.1322]}, {"w": "cantly", "b": [0.1429, 0.1298, 0.193, 0.1512]}, {"w": "reduce", "b": [0.1994, 0.1298, 0.2557, 0.1512]}, {"w": "the", "b": [0.2622, 0.1298, 0.2885, 0.1512]}, {"w": "vanishing/exploding", "b": [0.2949, 0.1298, 0.4663, 0.1512]}, {"w": "gradients", "b": [0.4727, 0.1298, 0.5498, 0.1512]}, {"w": "problems", "b": [0.5562, 0.1298, 0.6349, 0.1512]}, {"w": "at", "b": [0.6413, 0.1298, 0.6564, 0.1512]}, {"w": "the", "b": [0.6628, 0.1298, 0.6892, 0.1512]}, {"w": "beginning", "b": [0.6956, 0.1298, 0.7799, 0.1512]}, {"w": "of", "b": [0.7863, 0.1298, 0.8031, 0.1512]}, {"w": "train‐", "b": [0.8095, 0.1298, 0.8571, 0.1512]}, {"w": "ing,", "b": [0.1429, 0.1489, 0.1743, 0.1703]}, {"w": "it", "b": [0.1791, 0.1489, 0.191, 0.1703]}, {"w": "doesn’t", "b": [0.1957, 0.1489, 0.2538, 0.1703]}, {"w": "guarantee", "b": [0.2586, 0.1489, 0.3405, 0.1703]}, {"w": "that", "b": [0.3452, 0.1489, 0.3778, 0.1703]}, {"w": "they", "b": [0.3825, 0.1489, 0.4184, 0.1703]}, {"w": "won’t", "b": [0.4231, 0.1489, 0.468, 0.1703]}, {"w": "come", "b": [0.4727, 0.1489, 0.5181, 0.1703]}, {"w": "back", "b": [0.5228, 0.1489, 0.5617, 0.1703]}, {"w": "during", "b": [0.5664, 0.1489, 0.6229, 0.1703]}, {"w": "training.", "b": [0.6277, 0.1489, 0.6994, 0.1703]}]}, {"id": "b_3", "type": "paragraph", "text": "In a 2015 paper,8 Sergey Ioffe and Christian Szegedy proposed a technique called Batch Normalization (BN) to address the vanishing/exploding gradients problems. The technique consists of adding an operation in the model just before or after the activation function of each hidden layer, simply zero-centering and normalizing each input, then scaling and shifting the result using two new parameter vectors per layer: one for scaling, the other for shifting. In other words, this operation lets the model learn the optimal scale and mean of each of the layer’s inputs. In many cases, if you add a BN layer as the very first layer of your neural network, you do not need to standardize your training set (e.g., using a StandardScaler): the BN layer will do it for you (well, approximately, since it only looks at one batch at a time, and it can also rescale and shift each input feature).", "words": [{"w": "In", "b": [0.1429, 0.177, 0.1614, 0.1984]}, {"w": "a", "b": [0.1698, 0.177, 0.1789, 0.1984]}, {"w": "2015", "b": [0.1873, 0.177, 0.2273, 0.1984]}, {"w": "paper,8", "b": [0.2357, 0.177, 0.2934, 0.1984]}, {"w": "Sergey", "b": [0.3018, 0.177, 0.3564, 0.1984]}, {"w": "Ioffe", "b": [0.3648, 0.177, 0.4032, 0.1984]}, {"w": "and", "b": [0.4116, 0.177, 0.4431, 0.1984]}, {"w": "Christian", "b": [0.4515, 0.177, 0.53, 0.1984]}, {"w": "Szegedy", "b": [0.5384, 0.177, 0.605, 0.1984]}, {"w": "proposed", "b": [0.6134, 0.177, 0.6917, 0.1984]}, {"w": "a", "b": [0.7001, 0.177, 0.7093, 0.1984]}, {"w": "technique", "b": [0.7177, 0.177, 0.8004, 0.1984]}, {"w": "called", "b": [0.8088, 0.177, 0.8571, 0.1984]}, {"w": "Batch", "b": [0.1428, 0.1958, 0.1893, 0.2175]}, {"w": "Normalization", "b": [0.1978, 0.1958, 0.3171, 0.2175]}, {"w": "(BN)", "b": [0.3257, 0.196, 0.3678, 0.2175]}, {"w": "to", "b": [0.3763, 0.196, 0.3933, 0.2175]}, {"w": "address", "b": [0.4018, 0.196, 0.4648, 0.2175]}, {"w": "the", "b": [0.4734, 0.196, 0.4997, 0.2175]}, {"w": "vanishing/exploding", "b": [0.5082, 0.196, 0.6796, 0.2175]}, {"w": "gradients", "b": [0.6881, 0.196, 0.7652, 0.2175]}, {"w": "problems.", "b": [0.7737, 0.196, 0.8571, 0.2175]}, {"w": "The", "b": [0.1429, 0.2151, 0.1757, 0.2365]}, {"w": "technique", "b": [0.1825, 0.2151, 0.2651, 0.2365]}, {"w": "consists", "b": [0.2719, 0.2151, 0.3376, 0.2365]}, {"w": "of", "b": [0.3444, 0.2151, 0.3612, 0.2365]}, {"w": "adding", "b": [0.368, 0.2151, 0.4258, 0.2365]}, {"w": "an", "b": [0.4326, 0.2151, 0.4531, 0.2365]}, {"w": "operation", "b": [0.4599, 0.2151, 0.5407, 0.2365]}, {"w": "in", "b": [0.5475, 0.2151, 0.5645, 0.2365]}, {"w": "the", "b": [0.5713, 0.2151, 0.5976, 0.2365]}, {"w": "model", "b": [0.6044, 0.2151, 0.6572, 0.2365]}, {"w": "just", "b": [0.6639, 0.2151, 0.6943, 0.2365]}, {"w": "before", "b": [0.7011, 0.2151, 0.7539, 0.2365]}, {"w": "or", "b": [0.7607, 0.2151, 0.779, 0.2365]}, {"w": "after", "b": [0.7858, 0.2151, 0.824, 0.2365]}, {"w": "the", "b": [0.8308, 0.2151, 0.8571, 0.2365]}, {"w": "activation", "b": [0.1429, 0.2341, 0.2251, 0.2555]}, {"w": "function", "b": [0.2305, 0.2341, 0.3019, 0.2555]}, {"w": "of", "b": [0.3073, 0.2341, 0.3241, 0.2555]}, {"w": "each", "b": [0.3296, 0.2341, 0.3675, 0.2555]}, {"w": "hidden", "b": [0.3729, 0.2341, 0.4319, 0.2555]}, {"w": "layer,", "b": [0.4373, 0.2341, 0.4809, 0.2555]}, {"w": "simply", "b": [0.4863, 0.2341, 0.542, 0.2555]}, {"w": "zero-centering", "b": [0.5474, 0.2341, 0.6691, 0.2555]}, {"w": "and", "b": [0.6745, 0.2341, 0.7061, 0.2555]}, {"w": "normalizing", "b": [0.7115, 0.2341, 0.8138, 0.2555]}, {"w": "each", "b": [0.8192, 0.2341, 0.8571, 0.2555]}, {"w": "input,", "b": [0.1428, 0.2532, 0.1925, 0.2746]}, {"w": "then", "b": [0.198, 0.2532, 0.2357, 0.2746]}, {"w": "scaling", "b": [0.2412, 0.2532, 0.2988, 0.2746]}, {"w": "and", "b": [0.3043, 0.2532, 0.3358, 0.2746]}, {"w": "shifting", "b": [0.3413, 0.2532, 0.4049, 0.2746]}, {"w": "the", "b": [0.4104, 0.2532, 0.4367, 0.2746]}, {"w": "result", "b": [0.4422, 0.2532, 0.4891, 0.2746]}, {"w": "using", "b": [0.4946, 0.2532, 0.5401, 0.2746]}, {"w": "two", "b": [0.5456, 0.2532, 0.5768, 0.2746]}, {"w": "new", "b": [0.5823, 0.2532, 0.6168, 0.2746]}, {"w": "parameter", "b": [0.6223, 0.2532, 0.7081, 0.2746]}, {"w": "vectors", "b": [0.7136, 0.2532, 0.7732, 0.2746]}, {"w": "per", "b": [0.7787, 0.2532, 0.8062, 0.2746]}, {"w": "layer:", "b": [0.8117, 0.2532, 0.8571, 0.2746]}, {"w": "one", "b": [0.1429, 0.2722, 0.1737, 0.2936]}, {"w": "for", "b": [0.1805, 0.2722, 0.205, 0.2936]}, {"w": "scaling,", "b": [0.2118, 0.2722, 0.2741, 0.2936]}, {"w": "the", "b": [0.2809, 0.2722, 0.3072, 0.2936]}, {"w": "other", "b": [0.314, 0.2722, 0.3587, 0.2936]}, {"w": "for", "b": [0.3654, 0.2722, 0.3899, 0.2936]}, {"w": "shifting.", "b": [0.3967, 0.2722, 0.4651, 0.2936]}, {"w": "In", "b": [0.4718, 0.2722, 0.4903, 0.2936]}, {"w": "other", "b": [0.4971, 0.2722, 0.5418, 0.2936]}, {"w": "words,", "b": [0.5485, 0.2722, 0.6045, 0.2936]}, {"w": "this", "b": [0.6113, 0.2722, 0.642, 0.2936]}, {"w": "operation", "b": [0.6488, 0.2722, 0.7296, 0.2936]}, {"w": "lets", "b": [0.7364, 0.2722, 0.7645, 0.2936]}, {"w": "the", "b": [0.7712, 0.2722, 0.7976, 0.2936]}, {"w": "model", "b": [0.8043, 0.2722, 0.8572, 0.2936]}, {"w": "learn", "b": [0.1429, 0.2913, 0.1853, 0.3127]}, {"w": "the", "b": [0.1916, 0.2913, 0.218, 0.3127]}, {"w": "optimal", "b": [0.2244, 0.2913, 0.2893, 0.3127]}, {"w": "scale", "b": [0.2957, 0.2913, 0.3354, 0.3127]}, {"w": "and", "b": [0.3418, 0.2913, 0.3734, 0.3127]}, {"w": "mean", "b": [0.3797, 0.2913, 0.4262, 0.3127]}, {"w": "of", "b": [0.4326, 0.2913, 0.4494, 0.3127]}, {"w": "each", "b": [0.4558, 0.2913, 0.4937, 0.3127]}, {"w": "of", "b": [0.5001, 0.2913, 0.5169, 0.3127]}, {"w": "the", "b": [0.5233, 0.2913, 0.5496, 0.3127]}, {"w": "layer’s", "b": [0.556, 0.2913, 0.6065, 0.3127]}, {"w": "inputs.", "b": [0.6129, 0.2913, 0.6702, 0.3127]}, {"w": "In", "b": [0.6766, 0.2913, 0.6951, 0.3127]}, {"w": "many", "b": [0.7014, 0.2913, 0.7481, 0.3127]}, {"w": "cases,", "b": [0.7545, 0.2913, 0.8014, 0.3127]}, {"w": "if", "b": [0.8078, 0.2913, 0.8195, 0.3127]}, {"w": "you", "b": [0.8259, 0.2913, 0.8571, 0.3127]}, {"w": "add", "b": [0.1429, 0.3103, 0.174, 0.3317]}, {"w": "a", "b": [0.1817, 0.3103, 0.1909, 0.3317]}, {"w": "BN", "b": [0.1986, 0.3103, 0.2263, 0.3317]}, {"w": "layer", "b": [0.234, 0.3103, 0.2742, 0.3317]}, {"w": "as", "b": [0.2819, 0.3103, 0.2987, 0.3317]}, {"w": "the", "b": [0.3064, 0.3103, 0.3327, 0.3317]}, {"w": "very", "b": [0.3404, 0.3103, 0.3768, 0.3317]}, {"w": "first", "b": [0.3845, 0.3103, 0.418, 0.3317]}, {"w": "layer", "b": [0.4257, 0.3103, 0.4659, 0.3317]}, {"w": "of", "b": [0.4736, 0.3103, 0.4904, 0.3317]}, {"w": "your", "b": [0.4981, 0.3103, 0.5371, 0.3317]}, {"w": "neural", "b": [0.5448, 0.3103, 0.5983, 0.3317]}, {"w": "network,", "b": [0.606, 0.3103, 0.6803, 0.3317]}, {"w": "you", "b": [0.688, 0.3103, 0.7192, 0.3317]}, {"w": "do", "b": [0.7269, 0.3103, 0.7486, 0.3317]}, {"w": "not", "b": [0.7563, 0.3103, 0.7846, 0.3317]}, {"w": "need", "b": [0.7923, 0.3103, 0.8325, 0.3317]}, {"w": "to", "b": [0.8402, 0.3103, 0.8571, 0.3317]}, {"w": "standardize", "b": [0.1428, 0.3303, 0.2395, 0.3517]}, {"w": "your", "b": [0.246, 0.3303, 0.285, 0.3517]}, {"w": "training", "b": [0.2916, 0.3303, 0.3585, 0.3517]}, {"w": "set", "b": [0.3651, 0.3303, 0.388, 0.3517]}, {"w": "(e.g.,", "b": [0.3945, 0.3303, 0.4346, 0.3517]}, {"w": "using", "b": [0.4412, 0.3303, 0.4866, 0.3517]}, {"w": "a", "b": [0.4932, 0.3303, 0.5024, 0.3517]}, {"w": "StandardScaler):", "b": [0.509, 0.3303, 0.6595, 0.3517]}, {"w": "the", "b": [0.666, 0.3303, 0.6924, 0.3517]}, {"w": "BN", "b": [0.699, 0.3303, 0.7267, 0.3517]}, {"w": "layer", "b": [0.7333, 0.3303, 0.7734, 0.3517]}, {"w": "will", "b": [0.78, 0.3303, 0.8104, 0.3517]}, {"w": "do", "b": [0.817, 0.3303, 0.8386, 0.3517]}, {"w": "it", "b": [0.8452, 0.3303, 0.8572, 0.3517]}, {"w": "for", "b": [0.1429, 0.3493, 0.1674, 0.3707]}, {"w": "you", "b": [0.1727, 0.3493, 0.2039, 0.3707]}, {"w": "(well,", "b": [0.2092, 0.3493, 0.2548, 0.3707]}, {"w": "approximately,", "b": [0.2601, 0.3493, 0.3836, 0.3707]}, {"w": "since", "b": [0.3888, 0.3493, 0.4311, 0.3707]}, {"w": "it", "b": [0.4364, 0.3493, 0.4484, 0.3707]}, {"w": "only", "b": [0.4536, 0.3493, 0.4905, 0.3707]}, {"w": "looks", "b": [0.4958, 0.3493, 0.5403, 0.3707]}, {"w": "at", "b": [0.5456, 0.3493, 0.5607, 0.3707]}, {"w": "one", "b": [0.566, 0.3493, 0.5968, 0.3707]}, {"w": "batch", "b": [0.6021, 0.3493, 0.6478, 0.3707]}, {"w": "at", "b": [0.653, 0.3493, 0.6681, 0.3707]}, {"w": "a", "b": [0.6734, 0.3493, 0.6826, 0.3707]}, {"w": "time,", "b": [0.6879, 0.3493, 0.7305, 0.3707]}, {"w": "and", "b": [0.7358, 0.3493, 0.7673, 0.3707]}, {"w": "it", "b": [0.7726, 0.3493, 0.7845, 0.3707]}, {"w": "can", "b": [0.7898, 0.3493, 0.8192, 0.3707]}, {"w": "also", "b": [0.8245, 0.3493, 0.8571, 0.3707]}, {"w": "rescale", "b": [0.1429, 0.3684, 0.1992, 0.3898]}, {"w": "and", "b": [0.2039, 0.3684, 0.2354, 0.3898]}, {"w": "shift", "b": [0.2402, 0.3684, 0.277, 0.3898]}, {"w": "each", "b": [0.2818, 0.3684, 0.3197, 0.3898]}, {"w": "input", "b": [0.3244, 0.3684, 0.3694, 0.3898]}, {"w": "feature).", "b": [0.3741, 0.3684, 0.4438, 0.3898]}]}, {"id": "b_4", "type": "paragraph", "text": "In order to zero-center and normalize the inputs, the algorithm needs to estimate each input’s mean and standard deviation. It does so by evaluating the mean and stan‐ dard deviation of each input over the current mini-batch (hence the name “Batch Normalization”). The whole operation is summarized in Equation 11-3.", "words": [{"w": "In", "b": [0.1429, 0.3965, 0.1614, 0.4179]}, {"w": "order", "b": [0.1693, 0.3965, 0.2152, 0.4179]}, {"w": "to", "b": [0.2231, 0.3965, 0.2401, 0.4179]}, {"w": "zero-center", "b": [0.2481, 0.3965, 0.343, 0.4179]}, {"w": "and", "b": [0.351, 0.3965, 0.3825, 0.4179]}, {"w": "normalize", "b": [0.3904, 0.3965, 0.4748, 0.4179]}, {"w": "the", "b": [0.4828, 0.3965, 0.5091, 0.4179]}, {"w": "inputs,", "b": [0.517, 0.3965, 0.5743, 0.4179]}, {"w": "the", "b": [0.5823, 0.3965, 0.6086, 0.4179]}, {"w": "algorithm", "b": [0.6165, 0.3965, 0.6992, 0.4179]}, {"w": "needs", "b": [0.7071, 0.3965, 0.7548, 0.4179]}, {"w": "to", "b": [0.7628, 0.3965, 0.7798, 0.4179]}, {"w": "estimate", "b": [0.7877, 0.3965, 0.8571, 0.4179]}, {"w": "each", "b": [0.1428, 0.4155, 0.1808, 0.4369]}, {"w": "input’s", "b": [0.1855, 0.4155, 0.2402, 0.4369]}, {"w": "mean", "b": [0.2449, 0.4155, 0.2914, 0.4369]}, {"w": "and", "b": [0.2961, 0.4155, 0.3276, 0.4369]}, {"w": "standard", "b": [0.3324, 0.4155, 0.4058, 0.4369]}, {"w": "deviation.", "b": [0.4105, 0.4155, 0.4931, 0.4369]}, {"w": "It", "b": [0.4978, 0.4155, 0.5104, 0.4369]}, {"w": "does", "b": [0.5152, 0.4155, 0.5533, 0.4369]}, {"w": "so", "b": [0.558, 0.4155, 0.5763, 0.4369]}, {"w": "by", "b": [0.581, 0.4155, 0.6012, 0.4369]}, {"w": "evaluating", "b": [0.6059, 0.4155, 0.6917, 0.4369]}, {"w": "the", "b": [0.6964, 0.4155, 0.7228, 0.4369]}, {"w": "mean", "b": [0.7275, 0.4155, 0.774, 0.4369]}, {"w": "and", "b": [0.7787, 0.4155, 0.8102, 0.4369]}, {"w": "stan‐", "b": [0.815, 0.4155, 0.8569, 0.4369]}, {"w": "dard", "b": [0.1428, 0.4346, 0.1817, 0.456]}, {"w": "deviation", "b": [0.1897, 0.4346, 0.2675, 0.456]}, {"w": "of", "b": [0.2755, 0.4346, 0.2923, 0.456]}, {"w": "each", "b": [0.3003, 0.4346, 0.3382, 0.456]}, {"w": "input", "b": [0.3462, 0.4346, 0.3911, 0.456]}, {"w": "over", "b": [0.3991, 0.4346, 0.436, 0.456]}, {"w": "the", "b": [0.444, 0.4346, 0.4703, 0.456]}, {"w": "current", "b": [0.4783, 0.4346, 0.5399, 0.456]}, {"w": "mini-batch", "b": [0.5479, 0.4346, 0.6405, 0.456]}, {"w": "(hence", "b": [0.6485, 0.4346, 0.7048, 0.456]}, {"w": "the", "b": [0.7128, 0.4346, 0.7391, 0.456]}, {"w": "name", "b": [0.7471, 0.4346, 0.7936, 0.456]}, {"w": "“Batch", "b": [0.8016, 0.4346, 0.8571, 0.456]}, {"w": "Normalization”).", "b": [0.1429, 0.4536, 0.2833, 0.475]}, {"w": "The", "b": [0.288, 0.4536, 0.3209, 0.475]}, {"w": "whole", "b": [0.3256, 0.4536, 0.3757, 0.475]}, {"w": "operation", "b": [0.3805, 0.4536, 0.4613, 0.475]}, {"w": "is", "b": [0.466, 0.4536, 0.4793, 0.475]}, {"w": "summarized", "b": [0.484, 0.4536, 0.5879, 0.475]}, {"w": "in", "b": [0.5926, 0.4536, 0.6096, 0.475]}, {"w": "Equation", "b": [0.6143, 0.4536, 0.6906, 0.475]}, {"w": "11-3.", "b": [0.6953, 0.4536, 0.7375, 0.475]}]}, {"id": "b_5", "type": "equation", "text": "Equation 11-3. Batch Normalization algorithm", "words": [{"w": "Equation", "b": [0.1726, 0.4932, 0.2473, 0.5148]}, {"w": "11-3.", "b": [0.2521, 0.4932, 0.2937, 0.5148]}, {"w": "Batch", "b": [0.2985, 0.4932, 0.3449, 0.5148]}, {"w": "Normalization", "b": [0.3497, 0.4932, 0.469, 0.5148]}, {"w": "algorithm", "b": [0.4738, 0.4932, 0.5532, 0.5148]}]}, {"id": "b_6", "type": "equation", "text": "1 . μB = 1", "words": [{"w": "1", "b": [0.1726, 0.5408, 0.1821, 0.5612]}, {"w": ".", "b": [0.1855, 0.5408, 0.19, 0.5612]}, {"w": "μB", "b": [0.2218, 0.5403, 0.2417, 0.5655]}, {"w": "=", "b": [0.2472, 0.5408, 0.2587, 0.5612]}, {"w": "1", "b": [0.2741, 0.532, 0.2836, 0.5524]}]}, {"id": "b_7", "type": "paragraph", "text": "mB ∑", "words": [{"w": "mB", "b": [0.2664, 0.5494, 0.2912, 0.5743]}, {"w": "∑", "b": [0.302, 0.536, 0.317, 0.5649]}]}, {"id": "b_8", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.2945, 0.5555, 0.2989, 0.572]}, {"w": "=", "b": [0.3033, 0.5556, 0.3125, 0.572]}, {"w": "1", "b": [0.3169, 0.5556, 0.3245, 0.572]}]}, {"id": "b_10", "type": "paragraph", "text": "x i", "words": [{"w": "x", "b": [0.3267, 0.5403, 0.3363, 0.5612]}, {"w": "i", "b": [0.3419, 0.5369, 0.3462, 0.5534]}]}, {"id": "b_11", "type": "paragraph", "text": "2 . σB", "words": [{"w": "2", "b": [0.1726, 0.5956, 0.1821, 0.616]}, {"w": ".", "b": [0.1855, 0.5956, 0.19, 0.616]}, {"w": "σB", "b": [0.2218, 0.595, 0.2415, 0.6202]}]}, {"id": "b_12", "type": "equation", "text": "2 = 1 mB ∑", "words": [{"w": "2", "b": [0.2415, 0.5918, 0.2491, 0.6081]}, {"w": "=", "b": [0.2546, 0.5956, 0.2661, 0.616]}, {"w": "1", "b": [0.2815, 0.5867, 0.291, 0.6071]}, {"w": "mB", "b": [0.2738, 0.6042, 0.2986, 0.629]}, {"w": "∑", "b": [0.3094, 0.5908, 0.3245, 0.6196]}]}, {"id": "b_13", "type": "equation", "text": "i = 1", "words": [{"w": "i", "b": [0.3019, 0.6103, 0.3063, 0.6267]}, {"w": "=", "b": [0.3107, 0.6104, 0.3199, 0.6267]}, {"w": "1", "b": [0.3243, 0.6104, 0.3319, 0.6267]}]}, {"id": "b_15", "type": "paragraph", "text": "x i −μB", "words": [{"w": "x", "b": [0.341, 0.595, 0.3505, 0.616]}, {"w": "i", "b": [0.3562, 0.5917, 0.3605, 0.6081]}, {"w": "−μB", "b": [0.3704, 0.595, 0.4062, 0.6202]}]}, {"id": "b_17", "type": "equation", "text": "3 . x i =", "words": [{"w": "3", "b": [0.1726, 0.6485, 0.1821, 0.6689]}, {"w": ".", "b": [0.1855, 0.6485, 0.19, 0.6689]}, {"w": "x", "b": [0.2226, 0.648, 0.2322, 0.6689]}, {"w": "i", "b": [0.2385, 0.6446, 0.2429, 0.6611]}, {"w": "=", "b": [0.2539, 0.6485, 0.2654, 0.6689]}]}, {"id": "b_18", "type": "paragraph", "text": "x i −μB", "words": [{"w": "x", "b": [0.2749, 0.6347, 0.2844, 0.6556]}, {"w": "i", "b": [0.29, 0.6313, 0.2944, 0.6478]}, {"w": "−μB", "b": [0.3043, 0.6347, 0.3401, 0.6599]}]}, {"id": "b_20", "type": "equation", "text": "2 + �", "words": [{"w": "2", "b": [0.3049, 0.6599, 0.3125, 0.6762]}, {"w": "+", "b": [0.3169, 0.6637, 0.3284, 0.684]}, {"w": "�", "b": [0.3328, 0.6667, 0.3418, 0.6819]}]}, {"id": "b_21", "type": "equation", "text": "4 . z i = γ ⊗x i + β", "words": [{"w": "4", "b": [0.1726, 0.6945, 0.1821, 0.7149]}, {"w": ".", "b": [0.1855, 0.6945, 0.19, 0.7149]}, {"w": "z", "b": [0.2218, 0.6939, 0.2306, 0.7149]}, {"w": "i", "b": [0.2361, 0.6906, 0.2405, 0.707]}, {"w": "=", "b": [0.2515, 0.6945, 0.263, 0.7149]}, {"w": "γ", "b": [0.2685, 0.6939, 0.2785, 0.7149]}, {"w": "⊗x", "b": [0.2829, 0.6939, 0.3131, 0.7149]}, {"w": "i", "b": [0.3194, 0.6906, 0.3238, 0.707]}, {"w": "+", "b": [0.3337, 0.6945, 0.3452, 0.7149]}, {"w": "β", "b": [0.3496, 0.6939, 0.3602, 0.7149]}]}, {"id": "b_22", "type": "paragraph", "text": "• μB is the vector of input means, evaluated over the whole mini-batch B (it con‐ tains one mean per input).", "words": [{"w": "•", "b": [0.16, 0.7397, 0.1682, 0.7611]}, {"w": "μB", "b": [0.1786, 0.7391, 0.197, 0.762]}, {"w": "is", "b": [0.2037, 0.7397, 0.2169, 0.7611]}, {"w": "the", "b": [0.2236, 0.7397, 0.2499, 0.7611]}, {"w": "vector", "b": [0.2566, 0.7397, 0.3086, 0.7611]}, {"w": "of", "b": [0.3153, 0.7397, 0.3321, 0.7611]}, {"w": "input", "b": [0.3388, 0.7397, 0.3837, 0.7611]}, {"w": "means,", "b": [0.3904, 0.7397, 0.4493, 0.7611]}, {"w": "evaluated", "b": [0.4559, 0.7397, 0.5349, 0.7611]}, {"w": "over", "b": [0.5416, 0.7397, 0.5784, 0.7611]}, {"w": "the", "b": [0.5851, 0.7397, 0.6114, 0.7611]}, {"w": "whole", "b": [0.6181, 0.7397, 0.6683, 0.7611]}, {"w": "mini-batch", "b": [0.675, 0.7397, 0.7676, 0.7611]}, {"w": "B", "b": [0.7743, 0.7395, 0.7864, 0.7611]}, {"w": "(it", "b": [0.7931, 0.7397, 0.8122, 0.7611]}, {"w": "con‐", "b": [0.8189, 0.7397, 0.8571, 0.7611]}, {"w": "tains", "b": [0.1786, 0.7587, 0.2187, 0.7802]}, {"w": "one", "b": [0.2234, 0.7587, 0.2543, 0.7802]}, {"w": "mean", "b": [0.259, 0.7587, 0.3055, 0.7802]}, {"w": "per", "b": [0.3102, 0.7587, 0.3377, 0.7802]}, {"w": "input).", "b": [0.3424, 0.7587, 0.3993, 0.7802]}]}, {"id": "b_23", "type": "equation", "text": "Vanishing/Exploding Gradients Problems | 333", "words": [{"w": "Vanishing/Exploding", "b": [0.5559, 0.9225, 0.678, 0.9388]}, {"w": "Gradients", "b": [0.6808, 0.9225, 0.7376, 0.9388]}, {"w": "Problems", "b": [0.7404, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "333", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 360, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• σB is the vector of input standard deviations, also evaluated over the whole mini- batch (it contains one standard deviation per input).", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "σB", "b": [0.1786, 0.0785, 0.1968, 0.1014]}, {"w": "is", "b": [0.2023, 0.0791, 0.2155, 0.1005]}, {"w": "the", "b": [0.221, 0.0791, 0.2474, 0.1005]}, {"w": "vector", "b": [0.2529, 0.0791, 0.3049, 0.1005]}, {"w": "of", "b": [0.3104, 0.0791, 0.3272, 0.1005]}, {"w": "input", "b": [0.3327, 0.0791, 0.3776, 0.1005]}, {"w": "standard", "b": [0.3831, 0.0791, 0.4565, 0.1005]}, {"w": "deviations,", "b": [0.462, 0.0791, 0.5522, 0.1005]}, {"w": "also", "b": [0.5577, 0.0791, 0.5903, 0.1005]}, {"w": "evaluated", "b": [0.5958, 0.0791, 0.6748, 0.1005]}, {"w": "over", "b": [0.6803, 0.0791, 0.7171, 0.1005]}, {"w": "the", "b": [0.7226, 0.0791, 0.749, 0.1005]}, {"w": "whole", "b": [0.7545, 0.0791, 0.8046, 0.1005]}, {"w": "mini-", "b": [0.8101, 0.0791, 0.8571, 0.1005]}, {"w": "batch", "b": [0.1786, 0.0981, 0.2242, 0.1195]}, {"w": "(it", "b": [0.2289, 0.0981, 0.2481, 0.1195]}, {"w": "contains", "b": [0.2528, 0.0981, 0.3234, 0.1195]}, {"w": "one", "b": [0.3281, 0.0981, 0.359, 0.1195]}, {"w": "standard", "b": [0.3637, 0.0981, 0.4371, 0.1195]}, {"w": "deviation", "b": [0.4418, 0.0981, 0.5196, 0.1195]}, {"w": "per", "b": [0.5244, 0.0981, 0.5519, 0.1195]}, {"w": "input).", "b": [0.5566, 0.0981, 0.6135, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "• mB is the number of instances in the mini-batch.", "words": [{"w": "•", "b": [0.16, 0.1232, 0.1682, 0.1446]}, {"w": "mB", "b": [0.1786, 0.123, 0.2022, 0.1455]}, {"w": "is", "b": [0.2069, 0.1232, 0.2202, 0.1446]}, {"w": "the", "b": [0.2249, 0.1232, 0.2512, 0.1446]}, {"w": "number", "b": [0.2559, 0.1232, 0.3222, 0.1446]}, {"w": "of", "b": [0.327, 0.1232, 0.3438, 0.1446]}, {"w": "instances", "b": [0.3485, 0.1232, 0.4253, 0.1446]}, {"w": "in", "b": [0.4301, 0.1232, 0.447, 0.1446]}, {"w": "the", "b": [0.4518, 0.1232, 0.4781, 0.1446]}, {"w": "mini-batch.", "b": [0.4828, 0.1232, 0.5802, 0.1446]}]}, {"id": "b_2", "type": "equation", "text": "• x(i) is the vector of zero-centered and normalized inputs for instance i.", "words": [{"w": "•", "b": [0.16, 0.1483, 0.1682, 0.1697]}, {"w": "x(i)", "b": [0.1794, 0.1477, 0.2022, 0.1697]}, {"w": "is", "b": [0.2069, 0.1483, 0.2201, 0.1697]}, {"w": "the", "b": [0.2248, 0.1483, 0.2512, 0.1697]}, {"w": "vector", "b": [0.2559, 0.1483, 0.3079, 0.1697]}, {"w": "of", "b": [0.3127, 0.1483, 0.3294, 0.1697]}, {"w": "zero-centered", "b": [0.3342, 0.1483, 0.449, 0.1697]}, {"w": "and", "b": [0.4537, 0.1483, 0.4853, 0.1697]}, {"w": "normalized", "b": [0.49, 0.1483, 0.5854, 0.1697]}, {"w": "inputs", "b": [0.5902, 0.1483, 0.6427, 0.1697]}, {"w": "for", "b": [0.6474, 0.1483, 0.672, 0.1697]}, {"w": "instance", "b": [0.6767, 0.1483, 0.7459, 0.1697]}, {"w": "i.", "b": [0.7506, 0.1481, 0.7611, 0.1697]}]}, {"id": "b_3", "type": "paragraph", "text": "• γ is the output scale parameter vector for the layer (it contains one scale parame‐ ter per input).", "words": [{"w": "•", "b": [0.16, 0.1734, 0.1682, 0.1948]}, {"w": "γ", "b": [0.1786, 0.1728, 0.1891, 0.1948]}, {"w": "is", "b": [0.1943, 0.1734, 0.2075, 0.1948]}, {"w": "the", "b": [0.2127, 0.1734, 0.239, 0.1948]}, {"w": "output", "b": [0.2443, 0.1734, 0.3006, 0.1948]}, {"w": "scale", "b": [0.3058, 0.1734, 0.3456, 0.1948]}, {"w": "parameter", "b": [0.3508, 0.1734, 0.4366, 0.1948]}, {"w": "vector", "b": [0.4418, 0.1734, 0.4938, 0.1948]}, {"w": "for", "b": [0.499, 0.1734, 0.5235, 0.1948]}, {"w": "the", "b": [0.5288, 0.1734, 0.5551, 0.1948]}, {"w": "layer", "b": [0.5603, 0.1734, 0.6005, 0.1948]}, {"w": "(it", "b": [0.6057, 0.1734, 0.6248, 0.1948]}, {"w": "contains", "b": [0.6301, 0.1734, 0.7006, 0.1948]}, {"w": "one", "b": [0.7058, 0.1734, 0.7367, 0.1948]}, {"w": "scale", "b": [0.7419, 0.1734, 0.7817, 0.1948]}, {"w": "parame‐", "b": [0.7869, 0.1734, 0.8571, 0.1948]}, {"w": "ter", "b": [0.1786, 0.1924, 0.2015, 0.2139]}, {"w": "per", "b": [0.2062, 0.1924, 0.2337, 0.2139]}, {"w": "input).", "b": [0.2385, 0.1924, 0.2953, 0.2139]}]}, {"id": "b_4", "type": "paragraph", "text": "• ⊗ represents element-wise multiplication (each input is multiplied by its corre‐ sponding output scale parameter).", "words": [{"w": "•", "b": [0.16, 0.2175, 0.1682, 0.2389]}, {"w": "⊗", "b": [0.1786, 0.2208, 0.1948, 0.2366]}, {"w": "represents", "b": [0.2015, 0.2175, 0.2871, 0.2389]}, {"w": "element-wise", "b": [0.2939, 0.2175, 0.4039, 0.2389]}, {"w": "multiplication", "b": [0.4107, 0.2175, 0.5289, 0.2389]}, {"w": "(each", "b": [0.5357, 0.2175, 0.5809, 0.2389]}, {"w": "input", "b": [0.5876, 0.2175, 0.6326, 0.2389]}, {"w": "is", "b": [0.6393, 0.2175, 0.6526, 0.2389]}, {"w": "multiplied", "b": [0.6593, 0.2175, 0.7459, 0.2389]}, {"w": "by", "b": [0.7527, 0.2175, 0.7728, 0.2389]}, {"w": "its", "b": [0.7796, 0.2175, 0.7992, 0.2389]}, {"w": "corre‐", "b": [0.806, 0.2175, 0.8571, 0.2389]}, {"w": "sponding", "b": [0.1786, 0.2366, 0.2569, 0.258]}, {"w": "output", "b": [0.2616, 0.2366, 0.318, 0.258]}, {"w": "scale", "b": [0.3227, 0.2366, 0.3625, 0.258]}, {"w": "parameter).", "b": [0.3672, 0.2366, 0.4649, 0.258]}]}, {"id": "b_5", "type": "paragraph", "text": "• β is the output shift (offset) parameter vector for the layer (it contains one offset parameter per input). Each input is offset by its corresponding shift parameter.", "words": [{"w": "•", "b": [0.16, 0.2617, 0.1681, 0.2831]}, {"w": "β", "b": [0.1786, 0.2611, 0.1897, 0.2831]}, {"w": "is", "b": [0.1954, 0.2617, 0.2086, 0.2831]}, {"w": "the", "b": [0.2142, 0.2617, 0.2406, 0.2831]}, {"w": "output", "b": [0.2462, 0.2617, 0.3026, 0.2831]}, {"w": "shift", "b": [0.3083, 0.2617, 0.3451, 0.2831]}, {"w": "(offset)", "b": [0.3508, 0.2617, 0.411, 0.2831]}, {"w": "parameter", "b": [0.4167, 0.2617, 0.5025, 0.2831]}, {"w": "vector", "b": [0.5081, 0.2617, 0.5601, 0.2831]}, {"w": "for", "b": [0.5658, 0.2617, 0.5903, 0.2831]}, {"w": "the", "b": [0.596, 0.2617, 0.6223, 0.2831]}, {"w": "layer", "b": [0.6279, 0.2617, 0.6681, 0.2831]}, {"w": "(it", "b": [0.6738, 0.2617, 0.6929, 0.2831]}, {"w": "contains", "b": [0.6986, 0.2617, 0.7691, 0.2831]}, {"w": "one", "b": [0.7748, 0.2617, 0.8057, 0.2831]}, {"w": "offset", "b": [0.8113, 0.2617, 0.8571, 0.2831]}, {"w": "parameter", "b": [0.1786, 0.2807, 0.2644, 0.3021]}, {"w": "per", "b": [0.2691, 0.2807, 0.2966, 0.3021]}, {"w": "input).", "b": [0.3013, 0.2807, 0.3582, 0.3021]}, {"w": "Each", "b": [0.3629, 0.2807, 0.4038, 0.3021]}, {"w": "input", "b": [0.4086, 0.2807, 0.4535, 0.3021]}, {"w": "is", "b": [0.4582, 0.2807, 0.4714, 0.3021]}, {"w": "offset", "b": [0.4762, 0.2807, 0.522, 0.3021]}, {"w": "by", "b": [0.5267, 0.2807, 0.5469, 0.3021]}, {"w": "its", "b": [0.5516, 0.2807, 0.5712, 0.3021]}, {"w": "corresponding", "b": [0.5759, 0.2807, 0.698, 0.3021]}, {"w": "shift", "b": [0.7027, 0.2807, 0.7396, 0.3021]}, {"w": "parameter.", "b": [0.7443, 0.2807, 0.8335, 0.3021]}]}, {"id": "b_6", "type": "paragraph", "text": "• ϵ is a tiny number to avoid division by zero (typically 10–5). This is called a smoothing term.", "words": [{"w": "•", "b": [0.16, 0.3058, 0.1682, 0.3272]}, {"w": "ϵ", "b": [0.1786, 0.3091, 0.1932, 0.3249]}, {"w": "is", "b": [0.1968, 0.3058, 0.21, 0.3272]}, {"w": "a", "b": [0.2188, 0.3058, 0.228, 0.3272]}, {"w": "tiny", "b": [0.2368, 0.3058, 0.2692, 0.3272]}, {"w": "number", "b": [0.278, 0.3058, 0.3443, 0.3272]}, {"w": "to", "b": [0.3531, 0.3058, 0.3701, 0.3272]}, {"w": "avoid", "b": [0.3789, 0.3058, 0.4245, 0.3272]}, {"w": "division", "b": [0.4334, 0.3058, 0.5004, 0.3272]}, {"w": "by", "b": [0.5092, 0.3058, 0.5294, 0.3272]}, {"w": "zero", "b": [0.5382, 0.3058, 0.5742, 0.3272]}, {"w": "(typically", "b": [0.583, 0.3058, 0.6607, 0.3272]}, {"w": "10–5).", "b": [0.6695, 0.3058, 0.7139, 0.3272]}, {"w": "This", "b": [0.7227, 0.3058, 0.76, 0.3272]}, {"w": "is", "b": [0.7688, 0.3058, 0.782, 0.3272]}, {"w": "called", "b": [0.7908, 0.3058, 0.8392, 0.3272]}, {"w": "a", "b": [0.848, 0.3058, 0.8571, 0.3272]}, {"w": "smoothing", "b": [0.1786, 0.3247, 0.2624, 0.3463]}, {"w": "term.", "b": [0.2671, 0.3247, 0.3106, 0.3463]}]}, {"id": "b_7", "type": "paragraph", "text": "• z(i) is the output of the BN operation: it is a rescaled and shifted version of the inputs.", "words": [{"w": "•", "b": [0.16, 0.35, 0.1681, 0.3714]}, {"w": "z(i)", "b": [0.1786, 0.3494, 0.1996, 0.3714]}, {"w": "is", "b": [0.2066, 0.35, 0.2198, 0.3714]}, {"w": "the", "b": [0.2267, 0.35, 0.253, 0.3714]}, {"w": "output", "b": [0.2599, 0.35, 0.3163, 0.3714]}, {"w": "of", "b": [0.3232, 0.35, 0.34, 0.3714]}, {"w": "the", "b": [0.3469, 0.35, 0.3733, 0.3714]}, {"w": "BN", "b": [0.3802, 0.35, 0.4079, 0.3714]}, {"w": "operation:", "b": [0.4148, 0.35, 0.5004, 0.3714]}, {"w": "it", "b": [0.5073, 0.35, 0.5193, 0.3714]}, {"w": "is", "b": [0.5262, 0.35, 0.5394, 0.3714]}, {"w": "a", "b": [0.5463, 0.35, 0.5555, 0.3714]}, {"w": "rescaled", "b": [0.5624, 0.35, 0.6297, 0.3714]}, {"w": "and", "b": [0.6366, 0.35, 0.6681, 0.3714]}, {"w": "shifted", "b": [0.6751, 0.35, 0.7318, 0.3714]}, {"w": "version", "b": [0.7387, 0.35, 0.8002, 0.3714]}, {"w": "of", "b": [0.8071, 0.35, 0.8239, 0.3714]}, {"w": "the", "b": [0.8308, 0.35, 0.8571, 0.3714]}, {"w": "inputs.", "b": [0.1786, 0.369, 0.2359, 0.3904]}]}, {"id": "b_8", "type": "paragraph", "text": "So during training, BN just standardizes its inputs then rescales and offsets them. Good! What about at test time? Well it is not that simple. Indeed, we may need to make predictions for individual instances rather than for batches of instances: in this case, we will have no way to compute each input’s mean and standard deviation. Moreover, even if we do have a batch of instances, it may be too small, or the instan‐ ces may not be independent and identically distributed (IID), so computing statistics over the batch instances would be unreliable (during training, the batches should not be too small, if possible more than 30 instances, and all instances should be IID, as we saw in Chapter 4). One solution could be to wait until the end of training, then run the whole training set through the neural network, and compute the mean and stan‐ dard deviation of each input of the BN layer. These “final” input means and standard deviations can then be used instead of the batch input means and standard deviations when making predictions. However, it is often preferred to estimate these final statis‐ tics during training using a moving average of the layer’s input means and standard deviations. To sum up, four parameter vectors are learned in each batch-normalized layer: γ (the ouput scale vector) and β (the output offset vector) are learned through regular backpropagation, and μ (the final input mean vector), and σ (the final input standard deviation vector) are estimated using an exponential moving average. Note that μ and σ are estimated during training, but they are not used at all during train‐ ing, only after training (to replace the batch input means and standard deviations in Equation 11-3).", "words": [{"w": "So", "b": [0.1429, 0.4032, 0.1634, 0.4246]}, {"w": "during", "b": [0.1714, 0.4032, 0.2279, 0.4246]}, {"w": "training,", "b": [0.2359, 0.4032, 0.3076, 0.4246]}, {"w": "BN", "b": [0.3156, 0.4032, 0.3434, 0.4246]}, {"w": "just", "b": [0.3514, 0.4032, 0.3818, 0.4246]}, {"w": "standardizes", "b": [0.3898, 0.4032, 0.494, 0.4246]}, {"w": "its", "b": [0.5021, 0.4032, 0.5216, 0.4246]}, {"w": "inputs", "b": [0.5297, 0.4032, 0.5822, 0.4246]}, {"w": "then", "b": [0.5902, 0.4032, 0.628, 0.4246]}, {"w": "rescales", "b": [0.636, 0.4032, 0.7, 0.4246]}, {"w": "and", "b": [0.708, 0.4032, 0.7395, 0.4246]}, {"w": "offsets", "b": [0.7475, 0.4032, 0.801, 0.4246]}, {"w": "them.", "b": [0.809, 0.4032, 0.8572, 0.4246]}, {"w": "Good!", "b": [0.1429, 0.4222, 0.1958, 0.4436]}, {"w": "What", "b": [0.203, 0.4222, 0.2494, 0.4436]}, {"w": "about", "b": [0.2566, 0.4222, 0.3044, 0.4436]}, {"w": "at", "b": [0.3116, 0.4222, 0.3267, 0.4436]}, {"w": "test", "b": [0.3339, 0.4222, 0.3631, 0.4436]}, {"w": "time?", "b": [0.3703, 0.4222, 0.416, 0.4436]}, {"w": "Well", "b": [0.4232, 0.4222, 0.4608, 0.4436]}, {"w": "it", "b": [0.468, 0.4222, 0.48, 0.4436]}, {"w": "is", "b": [0.4871, 0.4222, 0.5004, 0.4436]}, {"w": "not", "b": [0.5076, 0.4222, 0.5359, 0.4436]}, {"w": "that", "b": [0.5431, 0.4222, 0.5757, 0.4436]}, {"w": "simple.", "b": [0.5829, 0.4222, 0.6426, 0.4436]}, {"w": "Indeed,", "b": [0.6498, 0.4222, 0.7128, 0.4436]}, {"w": "we", "b": [0.72, 0.4222, 0.7431, 0.4436]}, {"w": "may", "b": [0.7503, 0.4222, 0.7857, 0.4436]}, {"w": "need", "b": [0.7929, 0.4222, 0.833, 0.4436]}, {"w": "to", "b": [0.8402, 0.4222, 0.8571, 0.4436]}, {"w": "make", "b": [0.1429, 0.4413, 0.1883, 0.4627]}, {"w": "predictions", "b": [0.1938, 0.4413, 0.2883, 0.4627]}, {"w": "for", "b": [0.2938, 0.4413, 0.3184, 0.4627]}, {"w": "individual", "b": [0.3239, 0.4413, 0.4092, 0.4627]}, {"w": "instances", "b": [0.4147, 0.4413, 0.4915, 0.4627]}, {"w": "rather", "b": [0.4971, 0.4413, 0.5476, 0.4627]}, {"w": "than", "b": [0.5532, 0.4413, 0.5912, 0.4627]}, {"w": "for", "b": [0.5967, 0.4413, 0.6212, 0.4627]}, {"w": "batches", "b": [0.6268, 0.4413, 0.6889, 0.4627]}, {"w": "of", "b": [0.6945, 0.4413, 0.7112, 0.4627]}, {"w": "instances:", "b": [0.7168, 0.4413, 0.7984, 0.4627]}, {"w": "in", "b": [0.8039, 0.4413, 0.8209, 0.4627]}, {"w": "this", "b": [0.8264, 0.4413, 0.8571, 0.4627]}, {"w": "case,", "b": [0.1428, 0.4603, 0.1821, 0.4817]}, {"w": "we", "b": [0.1906, 0.4603, 0.2138, 0.4817]}, {"w": "will", "b": [0.2224, 0.4603, 0.2528, 0.4817]}, {"w": "have", "b": [0.2614, 0.4603, 0.2998, 0.4817]}, {"w": "no", "b": [0.3083, 0.4603, 0.3304, 0.4817]}, {"w": "way", "b": [0.339, 0.4603, 0.3716, 0.4817]}, {"w": "to", "b": [0.3802, 0.4603, 0.3971, 0.4817]}, {"w": "compute", "b": [0.4057, 0.4603, 0.479, 0.4817]}, {"w": "each", "b": [0.4876, 0.4603, 0.5255, 0.4817]}, {"w": "input’s", "b": [0.5341, 0.4603, 0.5888, 0.4817]}, {"w": "mean", "b": [0.5974, 0.4603, 0.6439, 0.4817]}, {"w": "and", "b": [0.6524, 0.4603, 0.684, 0.4817]}, {"w": "standard", "b": [0.6926, 0.4603, 0.766, 0.4817]}, {"w": "deviation.", "b": [0.7746, 0.4603, 0.8571, 0.4817]}, {"w": "Moreover,", "b": [0.1429, 0.4794, 0.2284, 0.5008]}, {"w": "even", "b": [0.234, 0.4794, 0.2727, 0.5008]}, {"w": "if", "b": [0.2783, 0.4794, 0.29, 0.5008]}, {"w": "we", "b": [0.2956, 0.4794, 0.3187, 0.5008]}, {"w": "do", "b": [0.3243, 0.4794, 0.3459, 0.5008]}, {"w": "have", "b": [0.3515, 0.4794, 0.3899, 0.5008]}, {"w": "a", "b": [0.3955, 0.4794, 0.4046, 0.5008]}, {"w": "batch", "b": [0.4102, 0.4794, 0.4558, 0.5008]}, {"w": "of", "b": [0.4614, 0.4794, 0.4782, 0.5008]}, {"w": "instances,", "b": [0.4838, 0.4794, 0.5654, 0.5008]}, {"w": "it", "b": [0.571, 0.4794, 0.5829, 0.5008]}, {"w": "may", "b": [0.5885, 0.4794, 0.6239, 0.5008]}, {"w": "be", "b": [0.6294, 0.4794, 0.6489, 0.5008]}, {"w": "too", "b": [0.6545, 0.4794, 0.6821, 0.5008]}, {"w": "small,", "b": [0.6876, 0.4794, 0.7368, 0.5008]}, {"w": "or", "b": [0.7424, 0.4794, 0.7607, 0.5008]}, {"w": "the", "b": [0.7663, 0.4794, 0.7926, 0.5008]}, {"w": "instan‐", "b": [0.7982, 0.4794, 0.8571, 0.5008]}, {"w": "ces", "b": [0.1429, 0.4984, 0.1682, 0.5198]}, {"w": "may", "b": [0.1738, 0.4984, 0.2092, 0.5198]}, {"w": "not", "b": [0.2148, 0.4984, 0.2432, 0.5198]}, {"w": "be", "b": [0.2488, 0.4984, 0.2683, 0.5198]}, {"w": "independent", "b": [0.2739, 0.4984, 0.3791, 0.5198]}, {"w": "and", "b": [0.3848, 0.4984, 0.4163, 0.5198]}, {"w": "identically", "b": [0.4219, 0.4984, 0.5084, 0.5198]}, {"w": "distributed", "b": [0.514, 0.4984, 0.6058, 0.5198]}, {"w": "(IID),", "b": [0.6114, 0.4984, 0.6601, 0.5198]}, {"w": "so", "b": [0.6657, 0.4984, 0.684, 0.5198]}, {"w": "computing", "b": [0.6896, 0.4984, 0.7808, 0.5198]}, {"w": "statistics", "b": [0.7864, 0.4984, 0.8571, 0.5198]}, {"w": "over", "b": [0.1429, 0.5175, 0.1797, 0.5389]}, {"w": "the", "b": [0.1851, 0.5175, 0.2114, 0.5389]}, {"w": "batch", "b": [0.2167, 0.5175, 0.2624, 0.5389]}, {"w": "instances", "b": [0.2677, 0.5175, 0.3446, 0.5389]}, {"w": "would", "b": [0.3499, 0.5175, 0.4021, 0.5389]}, {"w": "be", "b": [0.4075, 0.5175, 0.4269, 0.5389]}, {"w": "unreliable", "b": [0.4323, 0.5175, 0.516, 0.5389]}, {"w": "(during", "b": [0.5214, 0.5175, 0.5851, 0.5389]}, {"w": "training,", "b": [0.5905, 0.5175, 0.6622, 0.5389]}, {"w": "the", "b": [0.6675, 0.5175, 0.6938, 0.5389]}, {"w": "batches", "b": [0.6992, 0.5175, 0.7613, 0.5389]}, {"w": "should", "b": [0.7667, 0.5175, 0.8234, 0.5389]}, {"w": "not", "b": [0.8288, 0.5175, 0.8571, 0.5389]}, {"w": "be", "b": [0.1429, 0.5365, 0.1623, 0.5579]}, {"w": "too", "b": [0.1672, 0.5365, 0.1948, 0.5579]}, {"w": "small,", "b": [0.1996, 0.5365, 0.2488, 0.5579]}, {"w": "if", "b": [0.2536, 0.5365, 0.2654, 0.5579]}, {"w": "possible", "b": [0.2702, 0.5365, 0.3374, 0.5579]}, {"w": "more", "b": [0.3422, 0.5365, 0.3865, 0.5579]}, {"w": "than", "b": [0.3914, 0.5365, 0.4294, 0.5579]}, {"w": "30", "b": [0.4342, 0.5365, 0.4542, 0.5579]}, {"w": "instances,", "b": [0.4591, 0.5365, 0.5407, 0.5579]}, {"w": "and", "b": [0.5455, 0.5365, 0.5771, 0.5579]}, {"w": "all", "b": [0.5819, 0.5365, 0.6016, 0.5579]}, {"w": "instances", "b": [0.6065, 0.5365, 0.6833, 0.5579]}, {"w": "should", "b": [0.6882, 0.5365, 0.7449, 0.5579]}, {"w": "be", "b": [0.7498, 0.5365, 0.7692, 0.5579]}, {"w": "IID,", "b": [0.7741, 0.5365, 0.8075, 0.5579]}, {"w": "as", "b": [0.8124, 0.5365, 0.8292, 0.5579]}, {"w": "we", "b": [0.834, 0.5365, 0.8572, 0.5579]}, {"w": "saw", "b": [0.1429, 0.5556, 0.1735, 0.577]}, {"w": "in", "b": [0.1799, 0.5556, 0.1968, 0.577]}, {"w": "Chapter", "b": [0.2031, 0.5556, 0.2707, 0.577]}, {"w": "4).", "b": [0.277, 0.5556, 0.299, 0.577]}, {"w": "One", "b": [0.3053, 0.5556, 0.3411, 0.577]}, {"w": "solution", "b": [0.3474, 0.5556, 0.416, 0.577]}, {"w": "could", "b": [0.4223, 0.5556, 0.4691, 0.577]}, {"w": "be", "b": [0.4754, 0.5556, 0.4948, 0.577]}, {"w": "to", "b": [0.5011, 0.5556, 0.5181, 0.577]}, {"w": "wait", "b": [0.5244, 0.5556, 0.5597, 0.577]}, {"w": "until", "b": [0.5661, 0.5556, 0.6053, 0.577]}, {"w": "the", "b": [0.6116, 0.5556, 0.638, 0.577]}, {"w": "end", "b": [0.6443, 0.5556, 0.6755, 0.577]}, {"w": "of", "b": [0.6818, 0.5556, 0.6986, 0.577]}, {"w": "training,", "b": [0.7049, 0.5556, 0.7766, 0.577]}, {"w": "then", "b": [0.7829, 0.5556, 0.8207, 0.577]}, {"w": "run", "b": [0.827, 0.5556, 0.8571, 0.577]}, {"w": "the", "b": [0.1429, 0.5746, 0.1692, 0.596]}, {"w": "whole", "b": [0.175, 0.5746, 0.2251, 0.596]}, {"w": "training", "b": [0.2309, 0.5746, 0.2978, 0.596]}, {"w": "set", "b": [0.3036, 0.5746, 0.3264, 0.596]}, {"w": "through", "b": [0.3322, 0.5746, 0.4, 0.596]}, {"w": "the", "b": [0.4057, 0.5746, 0.4321, 0.596]}, {"w": "neural", "b": [0.4379, 0.5746, 0.4913, 0.596]}, {"w": "network,", "b": [0.4971, 0.5746, 0.5714, 0.596]}, {"w": "and", "b": [0.5772, 0.5746, 0.6087, 0.596]}, {"w": "compute", "b": [0.6145, 0.5746, 0.6878, 0.596]}, {"w": "the", "b": [0.6935, 0.5746, 0.7199, 0.596]}, {"w": "mean", "b": [0.7256, 0.5746, 0.7721, 0.596]}, {"w": "and", "b": [0.7779, 0.5746, 0.8094, 0.596]}, {"w": "stan‐", "b": [0.8152, 0.5746, 0.8571, 0.596]}, {"w": "dard", "b": [0.1428, 0.5937, 0.1817, 0.6151]}, {"w": "deviation", "b": [0.1872, 0.5937, 0.265, 0.6151]}, {"w": "of", "b": [0.2705, 0.5937, 0.2873, 0.6151]}, {"w": "each", "b": [0.2928, 0.5937, 0.3308, 0.6151]}, {"w": "input", "b": [0.3363, 0.5937, 0.3812, 0.6151]}, {"w": "of", "b": [0.3867, 0.5937, 0.4035, 0.6151]}, {"w": "the", "b": [0.409, 0.5937, 0.4354, 0.6151]}, {"w": "BN", "b": [0.4409, 0.5937, 0.4686, 0.6151]}, {"w": "layer.", "b": [0.4741, 0.5937, 0.5177, 0.6151]}, {"w": "These", "b": [0.5232, 0.5937, 0.5726, 0.6151]}, {"w": "“final”", "b": [0.5781, 0.5937, 0.6311, 0.6151]}, {"w": "input", "b": [0.6366, 0.5937, 0.6815, 0.6151]}, {"w": "means", "b": [0.687, 0.5937, 0.7412, 0.6151]}, {"w": "and", "b": [0.7467, 0.5937, 0.7782, 0.6151]}, {"w": "standard", "b": [0.7837, 0.5937, 0.8571, 0.6151]}, {"w": "deviations", "b": [0.1429, 0.6127, 0.2283, 0.6341]}, {"w": "can", "b": [0.2333, 0.6127, 0.2627, 0.6341]}, {"w": "then", "b": [0.2678, 0.6127, 0.3055, 0.6341]}, {"w": "be", "b": [0.3105, 0.6127, 0.33, 0.6341]}, {"w": "used", "b": [0.335, 0.6127, 0.3736, 0.6341]}, {"w": "instead", "b": [0.3786, 0.6127, 0.4386, 0.6341]}, {"w": "of", "b": [0.4436, 0.6127, 0.4604, 0.6341]}, {"w": "the", "b": [0.4655, 0.6127, 0.4918, 0.6341]}, {"w": "batch", "b": [0.4969, 0.6127, 0.5425, 0.6341]}, {"w": "input", "b": [0.5475, 0.6127, 0.5925, 0.6341]}, {"w": "means", "b": [0.5975, 0.6127, 0.6516, 0.6341]}, {"w": "and", "b": [0.6567, 0.6127, 0.6882, 0.6341]}, {"w": "standard", "b": [0.6932, 0.6127, 0.7667, 0.6341]}, {"w": "deviations", "b": [0.7717, 0.6127, 0.8571, 0.6341]}, {"w": "when", "b": [0.1429, 0.6317, 0.1885, 0.6532]}, {"w": "making", "b": [0.1939, 0.6317, 0.2571, 0.6532]}, {"w": "predictions.", "b": [0.2625, 0.6317, 0.3617, 0.6532]}, {"w": "However,", "b": [0.3671, 0.6317, 0.4459, 0.6532]}, {"w": "it", "b": [0.4513, 0.6317, 0.4632, 0.6532]}, {"w": "is", "b": [0.4686, 0.6317, 0.4818, 0.6532]}, {"w": "often", "b": [0.4872, 0.6317, 0.5306, 0.6532]}, {"w": "preferred", "b": [0.5359, 0.6317, 0.6138, 0.6532]}, {"w": "to", "b": [0.6191, 0.6317, 0.6361, 0.6532]}, {"w": "estimate", "b": [0.6415, 0.6317, 0.7109, 0.6532]}, {"w": "these", "b": [0.7163, 0.6317, 0.7591, 0.6532]}, {"w": "final", "b": [0.7645, 0.6317, 0.802, 0.6532]}, {"w": "statis‐", "b": [0.8074, 0.6317, 0.8571, 0.6532]}, {"w": "tics", "b": [0.1429, 0.6508, 0.1712, 0.6722]}, {"w": "during", "b": [0.1777, 0.6508, 0.2342, 0.6722]}, {"w": "training", "b": [0.2406, 0.6508, 0.3075, 0.6722]}, {"w": "using", "b": [0.314, 0.6508, 0.3594, 0.6722]}, {"w": "a", "b": [0.3658, 0.6508, 0.375, 0.6722]}, {"w": "moving", "b": [0.3814, 0.6508, 0.4454, 0.6722]}, {"w": "average", "b": [0.4519, 0.6508, 0.5146, 0.6722]}, {"w": "of", "b": [0.521, 0.6508, 0.5378, 0.6722]}, {"w": "the", "b": [0.5442, 0.6508, 0.5706, 0.6722]}, {"w": "layer’s", "b": [0.577, 0.6508, 0.6275, 0.6722]}, {"w": "input", "b": [0.6339, 0.6508, 0.6788, 0.6722]}, {"w": "means", "b": [0.6852, 0.6508, 0.7393, 0.6722]}, {"w": "and", "b": [0.7458, 0.6508, 0.7773, 0.6722]}, {"w": "standard", "b": [0.7837, 0.6508, 0.8571, 0.6722]}, {"w": "deviations.", "b": [0.1429, 0.6698, 0.2331, 0.6913]}, {"w": "To", "b": [0.2393, 0.6698, 0.2607, 0.6913]}, {"w": "sum", "b": [0.2669, 0.6698, 0.3027, 0.6913]}, {"w": "up,", "b": [0.3089, 0.6698, 0.335, 0.6913]}, {"w": "four", "b": [0.3412, 0.6698, 0.3768, 0.6913]}, {"w": "parameter", "b": [0.383, 0.6698, 0.4688, 0.6913]}, {"w": "vectors", "b": [0.4751, 0.6698, 0.5347, 0.6913]}, {"w": "are", "b": [0.5409, 0.6698, 0.5667, 0.6913]}, {"w": "learned", "b": [0.5729, 0.6698, 0.6351, 0.6913]}, {"w": "in", "b": [0.6413, 0.6698, 0.6583, 0.6913]}, {"w": "each", "b": [0.6645, 0.6698, 0.7025, 0.6913]}, {"w": "batch-normalized", "b": [0.7087, 0.6698, 0.8572, 0.6913]}, {"w": "layer:", "b": [0.1429, 0.6889, 0.1883, 0.7103]}, {"w": "γ", "b": [0.1942, 0.6883, 0.2047, 0.7103]}, {"w": "(the", "b": [0.2106, 0.6889, 0.2441, 0.7103]}, {"w": "ouput", "b": [0.25, 0.6889, 0.3, 0.7103]}, {"w": "scale", "b": [0.3059, 0.6889, 0.3456, 0.7103]}, {"w": "vector)", "b": [0.3515, 0.6889, 0.4108, 0.7103]}, {"w": "and", "b": [0.4166, 0.6889, 0.4482, 0.7103]}, {"w": "β", "b": [0.4541, 0.6883, 0.4652, 0.7103]}, {"w": "(the", "b": [0.4711, 0.6889, 0.5047, 0.7103]}, {"w": "output", "b": [0.5105, 0.6889, 0.5669, 0.7103]}, {"w": "offset", "b": [0.5728, 0.6889, 0.6186, 0.7103]}, {"w": "vector)", "b": [0.6245, 0.6889, 0.6837, 0.7103]}, {"w": "are", "b": [0.6896, 0.6889, 0.7154, 0.7103]}, {"w": "learned", "b": [0.7212, 0.6889, 0.7835, 0.7103]}, {"w": "through", "b": [0.7894, 0.6889, 0.8571, 0.7103]}, {"w": "regular", "b": [0.1429, 0.7079, 0.2024, 0.7293]}, {"w": "backpropagation,", "b": [0.2087, 0.7079, 0.3541, 0.7293]}, {"w": "and", "b": [0.3604, 0.7079, 0.3919, 0.7293]}, {"w": "μ", "b": [0.3982, 0.7074, 0.4094, 0.7293]}, {"w": "(the", "b": [0.4157, 0.7079, 0.4492, 0.7293]}, {"w": "final", "b": [0.4555, 0.7079, 0.493, 0.7293]}, {"w": "input", "b": [0.4993, 0.7079, 0.5442, 0.7293]}, {"w": "mean", "b": [0.5505, 0.7079, 0.597, 0.7293]}, {"w": "vector),", "b": [0.6032, 0.7079, 0.6672, 0.7293]}, {"w": "and", "b": [0.6735, 0.7079, 0.705, 0.7293]}, {"w": "σ", "b": [0.7113, 0.7074, 0.7223, 0.7293]}, {"w": "(the", "b": [0.7286, 0.7079, 0.7621, 0.7293]}, {"w": "final", "b": [0.7684, 0.7079, 0.806, 0.7293]}, {"w": "input", "b": [0.8122, 0.7079, 0.8571, 0.7293]}, {"w": "standard", "b": [0.1428, 0.727, 0.2163, 0.7484]}, {"w": "deviation", "b": [0.2224, 0.727, 0.3002, 0.7484]}, {"w": "vector)", "b": [0.3064, 0.727, 0.3656, 0.7484]}, {"w": "are", "b": [0.3717, 0.727, 0.3975, 0.7484]}, {"w": "estimated", "b": [0.4036, 0.727, 0.4841, 0.7484]}, {"w": "using", "b": [0.4902, 0.727, 0.5357, 0.7484]}, {"w": "an", "b": [0.5418, 0.727, 0.5623, 0.7484]}, {"w": "exponential", "b": [0.5685, 0.727, 0.6663, 0.7484]}, {"w": "moving", "b": [0.6725, 0.727, 0.7365, 0.7484]}, {"w": "average.", "b": [0.7427, 0.727, 0.8102, 0.7484]}, {"w": "Note", "b": [0.8163, 0.727, 0.8571, 0.7484]}, {"w": "that", "b": [0.1429, 0.746, 0.1754, 0.7674]}, {"w": "μ", "b": [0.1816, 0.7455, 0.1928, 0.7674]}, {"w": "and", "b": [0.1989, 0.746, 0.2305, 0.7674]}, {"w": "σ", "b": [0.2366, 0.7455, 0.2476, 0.7674]}, {"w": "are", "b": [0.2537, 0.746, 0.2794, 0.7674]}, {"w": "estimated", "b": [0.2856, 0.746, 0.366, 0.7674]}, {"w": "during", "b": [0.3722, 0.746, 0.4287, 0.7674]}, {"w": "training,", "b": [0.4348, 0.746, 0.5065, 0.7674]}, {"w": "but", "b": [0.5126, 0.746, 0.5406, 0.7674]}, {"w": "they", "b": [0.5467, 0.746, 0.5826, 0.7674]}, {"w": "are", "b": [0.5888, 0.746, 0.6145, 0.7674]}, {"w": "not", "b": [0.6206, 0.746, 0.649, 0.7674]}, {"w": "used", "b": [0.6551, 0.746, 0.6937, 0.7674]}, {"w": "at", "b": [0.6998, 0.746, 0.7149, 0.7674]}, {"w": "all", "b": [0.7211, 0.746, 0.7407, 0.7674]}, {"w": "during", "b": [0.7469, 0.746, 0.8034, 0.7674]}, {"w": "train‐", "b": [0.8095, 0.746, 0.8571, 0.7674]}, {"w": "ing,", "b": [0.1429, 0.7651, 0.1743, 0.7865]}, {"w": "only", "b": [0.1804, 0.7651, 0.2172, 0.7865]}, {"w": "after", "b": [0.2233, 0.7651, 0.2615, 0.7865]}, {"w": "training", "b": [0.2676, 0.7651, 0.3345, 0.7865]}, {"w": "(to", "b": [0.3406, 0.7651, 0.3648, 0.7865]}, {"w": "replace", "b": [0.3708, 0.7651, 0.4304, 0.7865]}, {"w": "the", "b": [0.4364, 0.7651, 0.4628, 0.7865]}, {"w": "batch", "b": [0.4688, 0.7651, 0.5145, 0.7865]}, {"w": "input", "b": [0.5205, 0.7651, 0.5654, 0.7865]}, {"w": "means", "b": [0.5715, 0.7651, 0.6256, 0.7865]}, {"w": "and", "b": [0.6316, 0.7651, 0.6632, 0.7865]}, {"w": "standard", "b": [0.6692, 0.7651, 0.7426, 0.7865]}, {"w": "deviations", "b": [0.7487, 0.7651, 0.8341, 0.7865]}, {"w": "in", "b": [0.8402, 0.7651, 0.8571, 0.7865]}, {"w": "Equation", "b": [0.1429, 0.7841, 0.2191, 0.8055]}, {"w": "11-3).", "b": [0.2238, 0.7841, 0.2732, 0.8055]}]}, {"id": "b_9", "type": "paragraph", "text": "The authors demonstrated that this technique considerably improved all the deep neural networks they experimented with, leading to a huge improvement in the ImageNet classification task (ImageNet is a large database of images classified into many classes and commonly used to evaluate computer vision systems). The vanish‐", "words": [{"w": "The", "b": [0.1429, 0.8122, 0.1757, 0.8337]}, {"w": "authors", "b": [0.1841, 0.8122, 0.2473, 0.8337]}, {"w": "demonstrated", "b": [0.2557, 0.8122, 0.3713, 0.8337]}, {"w": "that", "b": [0.3797, 0.8122, 0.4123, 0.8337]}, {"w": "this", "b": [0.4207, 0.8122, 0.4514, 0.8337]}, {"w": "technique", "b": [0.4597, 0.8122, 0.5424, 0.8337]}, {"w": "considerably", "b": [0.5508, 0.8122, 0.657, 0.8337]}, {"w": "improved", "b": [0.6654, 0.8122, 0.7464, 0.8337]}, {"w": "all", "b": [0.7548, 0.8122, 0.7744, 0.8337]}, {"w": "the", "b": [0.7828, 0.8122, 0.8091, 0.8337]}, {"w": "deep", "b": [0.8175, 0.8122, 0.8571, 0.8337]}, {"w": "neural", "b": [0.1429, 0.8313, 0.1963, 0.8527]}, {"w": "networks", "b": [0.206, 0.8313, 0.2832, 0.8527]}, {"w": "they", "b": [0.2929, 0.8313, 0.3288, 0.8527]}, {"w": "experimented", "b": [0.3385, 0.8313, 0.4534, 0.8527]}, {"w": "with,", "b": [0.4631, 0.8313, 0.5052, 0.8527]}, {"w": "leading", "b": [0.5149, 0.8313, 0.5759, 0.8527]}, {"w": "to", "b": [0.5856, 0.8313, 0.6025, 0.8527]}, {"w": "a", "b": [0.6122, 0.8313, 0.6214, 0.8527]}, {"w": "huge", "b": [0.6311, 0.8313, 0.6715, 0.8527]}, {"w": "improvement", "b": [0.6812, 0.8313, 0.7945, 0.8527]}, {"w": "in", "b": [0.8041, 0.8313, 0.8211, 0.8527]}, {"w": "the", "b": [0.8308, 0.8313, 0.8572, 0.8527]}, {"w": "ImageNet", "b": [0.1429, 0.8503, 0.2249, 0.8718]}, {"w": "classification", "b": [0.2325, 0.8503, 0.3399, 0.8718]}, {"w": "task", "b": [0.3475, 0.8503, 0.381, 0.8718]}, {"w": "(ImageNet", "b": [0.3885, 0.8503, 0.4778, 0.8718]}, {"w": "is", "b": [0.4854, 0.8503, 0.4986, 0.8718]}, {"w": "a", "b": [0.5062, 0.8503, 0.5154, 0.8718]}, {"w": "large", "b": [0.5229, 0.8503, 0.5637, 0.8718]}, {"w": "database", "b": [0.5713, 0.8503, 0.6427, 0.8718]}, {"w": "of", "b": [0.6503, 0.8503, 0.6671, 0.8718]}, {"w": "images", "b": [0.6747, 0.8503, 0.7327, 0.8718]}, {"w": "classified", "b": [0.7403, 0.8503, 0.816, 0.8718]}, {"w": "into", "b": [0.8236, 0.8503, 0.8571, 0.8718]}, {"w": "many", "b": [0.1429, 0.8694, 0.1895, 0.8908]}, {"w": "classes", "b": [0.1954, 0.8694, 0.2504, 0.8908]}, {"w": "and", "b": [0.2562, 0.8694, 0.2878, 0.8908]}, {"w": "commonly", "b": [0.2936, 0.8694, 0.384, 0.8908]}, {"w": "used", "b": [0.3898, 0.8694, 0.4284, 0.8908]}, {"w": "to", "b": [0.4342, 0.8694, 0.4512, 0.8908]}, {"w": "evaluate", "b": [0.457, 0.8694, 0.525, 0.8908]}, {"w": "computer", "b": [0.5308, 0.8694, 0.6118, 0.8908]}, {"w": "vision", "b": [0.6177, 0.8694, 0.6681, 0.8908]}, {"w": "systems).", "b": [0.674, 0.8694, 0.7507, 0.8908]}, {"w": "The", "b": [0.7565, 0.8694, 0.7894, 0.8908]}, {"w": "vanish‐", "b": [0.7952, 0.8694, 0.8571, 0.8908]}]}, {"id": "b_10", "type": "paragraph", "text": "334 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "334", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2746, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 361, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "ing gradients problem was strongly reduced, to the point that they could use saturat‐ ing activation functions such as the tanh and even the logistic activation function. The networks were also much less sensitive to the weight initialization. They were able to use much larger learning rates, significantly speeding up the learning process. Specifically, they note that “Applied to a state-of-the-art image classification model, Batch Normalization achieves the same accuracy with 14 times fewer training steps, and beats the original model by a significant margin. […] Using an ensemble of batch-normalized networks, we improve upon the best published result on ImageNet classification: reaching 4.9% top-5 validation error (and 4.8% test error), exceeding the accuracy of human raters.” Finally, like a gift that keeps on giving, Batch Normal‐ ization also acts like a regularizer, reducing the need for other regularization techni‐ ques (such as dropout, described later in this chapter).", "words": [{"w": "ing", "b": [0.1429, 0.0791, 0.1696, 0.1005]}, {"w": "gradients", "b": [0.1752, 0.0791, 0.2523, 0.1005]}, {"w": "problem", "b": [0.2579, 0.0791, 0.329, 0.1005]}, {"w": "was", "b": [0.3346, 0.0791, 0.3657, 0.1005]}, {"w": "strongly", "b": [0.3713, 0.0791, 0.4396, 0.1005]}, {"w": "reduced,", "b": [0.4453, 0.0791, 0.5174, 0.1005]}, {"w": "to", "b": [0.523, 0.0791, 0.54, 0.1005]}, {"w": "the", "b": [0.5456, 0.0791, 0.5719, 0.1005]}, {"w": "point", "b": [0.5776, 0.0791, 0.6221, 0.1005]}, {"w": "that", "b": [0.6277, 0.0791, 0.6603, 0.1005]}, {"w": "they", "b": [0.6659, 0.0791, 0.7018, 0.1005]}, {"w": "could", "b": [0.7075, 0.0791, 0.7542, 0.1005]}, {"w": "use", "b": [0.7599, 0.0791, 0.7874, 0.1005]}, {"w": "saturat‐", "b": [0.7931, 0.0791, 0.8571, 0.1005]}, {"w": "ing", "b": [0.1429, 0.0981, 0.1696, 0.1195]}, {"w": "activation", "b": [0.1772, 0.0981, 0.2595, 0.1195]}, {"w": "functions", "b": [0.2671, 0.0981, 0.3462, 0.1195]}, {"w": "such", "b": [0.3538, 0.0981, 0.3925, 0.1195]}, {"w": "as", "b": [0.4001, 0.0981, 0.4169, 0.1195]}, {"w": "the", "b": [0.4246, 0.0981, 0.4509, 0.1195]}, {"w": "tanh", "b": [0.4586, 0.0981, 0.4966, 0.1195]}, {"w": "and", "b": [0.5042, 0.0981, 0.5358, 0.1195]}, {"w": "even", "b": [0.5434, 0.0981, 0.5822, 0.1195]}, {"w": "the", "b": [0.5898, 0.0981, 0.6162, 0.1195]}, {"w": "logistic", "b": [0.6238, 0.0981, 0.6834, 0.1195]}, {"w": "activation", "b": [0.6911, 0.0981, 0.7733, 0.1195]}, {"w": "function.", "b": [0.781, 0.0981, 0.8571, 0.1195]}, {"w": "The", "b": [0.1429, 0.1172, 0.1757, 0.1386]}, {"w": "networks", "b": [0.1833, 0.1172, 0.2605, 0.1386]}, {"w": "were", "b": [0.2682, 0.1172, 0.3079, 0.1386]}, {"w": "also", "b": [0.3155, 0.1172, 0.3482, 0.1386]}, {"w": "much", "b": [0.3558, 0.1172, 0.4035, 0.1386]}, {"w": "less", "b": [0.4111, 0.1172, 0.4405, 0.1386]}, {"w": "sensitive", "b": [0.4482, 0.1172, 0.5197, 0.1386]}, {"w": "to", "b": [0.5273, 0.1172, 0.5443, 0.1386]}, {"w": "the", "b": [0.552, 0.1172, 0.5783, 0.1386]}, {"w": "weight", "b": [0.5859, 0.1172, 0.6415, 0.1386]}, {"w": "initialization.", "b": [0.6491, 0.1172, 0.7598, 0.1386]}, {"w": "They", "b": [0.7674, 0.1172, 0.8098, 0.1386]}, {"w": "were", "b": [0.8174, 0.1172, 0.8572, 0.1386]}, {"w": "able", "b": [0.1429, 0.1362, 0.1767, 0.1576]}, {"w": "to", "b": [0.1822, 0.1362, 0.1992, 0.1576]}, {"w": "use", "b": [0.2047, 0.1362, 0.2323, 0.1576]}, {"w": "much", "b": [0.2378, 0.1362, 0.2855, 0.1576]}, {"w": "larger", "b": [0.291, 0.1362, 0.3395, 0.1576]}, {"w": "learning", "b": [0.345, 0.1362, 0.4141, 0.1576]}, {"w": "rates,", "b": [0.4197, 0.1362, 0.4637, 0.1576]}, {"w": "significantly", "b": [0.4693, 0.1362, 0.5711, 0.1576]}, {"w": "speeding", "b": [0.5766, 0.1362, 0.6506, 0.1576]}, {"w": "up", "b": [0.6562, 0.1362, 0.6781, 0.1576]}, {"w": "the", "b": [0.6837, 0.1362, 0.71, 0.1576]}, {"w": "learning", "b": [0.7155, 0.1362, 0.7846, 0.1576]}, {"w": "process.", "b": [0.7902, 0.1362, 0.8571, 0.1576]}, {"w": "Specifically,", "b": [0.1429, 0.1553, 0.2399, 0.1767]}, {"w": "they", "b": [0.2472, 0.1553, 0.2831, 0.1767]}, {"w": "note", "b": [0.2903, 0.1553, 0.3275, 0.1767]}, {"w": "that", "b": [0.3347, 0.1553, 0.3673, 0.1767]}, {"w": "“Applied", "b": [0.3745, 0.1553, 0.4458, 0.1767]}, {"w": "to", "b": [0.453, 0.1553, 0.47, 0.1767]}, {"w": "a", "b": [0.4772, 0.1553, 0.4864, 0.1767]}, {"w": "state-of-the-art", "b": [0.4936, 0.1553, 0.6201, 0.1767]}, {"w": "image", "b": [0.6274, 0.1553, 0.6778, 0.1767]}, {"w": "classification", "b": [0.685, 0.1553, 0.7924, 0.1767]}, {"w": "model,", "b": [0.7996, 0.1553, 0.8571, 0.1767]}, {"w": "Batch", "b": [0.1428, 0.1743, 0.1901, 0.1957]}, {"w": "Normalization", "b": [0.1966, 0.1743, 0.3185, 0.1957]}, {"w": "achieves", "b": [0.325, 0.1743, 0.3947, 0.1957]}, {"w": "the", "b": [0.4012, 0.1743, 0.4275, 0.1957]}, {"w": "same", "b": [0.434, 0.1743, 0.4767, 0.1957]}, {"w": "accuracy", "b": [0.4832, 0.1743, 0.5563, 0.1957]}, {"w": "with", "b": [0.5628, 0.1743, 0.6001, 0.1957]}, {"w": "14", "b": [0.6066, 0.1743, 0.6266, 0.1957]}, {"w": "times", "b": [0.6331, 0.1743, 0.6786, 0.1957]}, {"w": "fewer", "b": [0.6851, 0.1743, 0.731, 0.1957]}, {"w": "training", "b": [0.7375, 0.1743, 0.8045, 0.1957]}, {"w": "steps,", "b": [0.811, 0.1743, 0.8571, 0.1957]}, {"w": "and", "b": [0.1429, 0.1933, 0.1744, 0.2148]}, {"w": "beats", "b": [0.1833, 0.1933, 0.2255, 0.2148]}, {"w": "the", "b": [0.2344, 0.1933, 0.2607, 0.2148]}, {"w": "original", "b": [0.2696, 0.1933, 0.3347, 0.2148]}, {"w": "model", "b": [0.3436, 0.1933, 0.3964, 0.2148]}, {"w": "by", "b": [0.4053, 0.1933, 0.4254, 0.2148]}, {"w": "a", "b": [0.4343, 0.1933, 0.4434, 0.2148]}, {"w": "significant", "b": [0.4523, 0.1933, 0.5394, 0.2148]}, {"w": "margin.", "b": [0.5482, 0.1933, 0.6137, 0.2148]}, {"w": "[…]", "b": [0.6226, 0.1933, 0.6571, 0.2148]}, {"w": "Using", "b": [0.666, 0.1933, 0.7146, 0.2148]}, {"w": "an", "b": [0.7235, 0.1933, 0.7441, 0.2148]}, {"w": "ensemble", "b": [0.7529, 0.1933, 0.8315, 0.2148]}, {"w": "of", "b": [0.8404, 0.1933, 0.8571, 0.2148]}, {"w": "batch-normalized", "b": [0.1429, 0.2124, 0.2913, 0.2338]}, {"w": "networks,", "b": [0.2967, 0.2124, 0.3787, 0.2338]}, {"w": "we", "b": [0.3841, 0.2124, 0.4072, 0.2338]}, {"w": "improve", "b": [0.4126, 0.2124, 0.4826, 0.2338]}, {"w": "upon", "b": [0.488, 0.2124, 0.532, 0.2338]}, {"w": "the", "b": [0.5374, 0.2124, 0.5637, 0.2338]}, {"w": "best", "b": [0.5691, 0.2124, 0.6025, 0.2338]}, {"w": "published", "b": [0.6079, 0.2124, 0.69, 0.2338]}, {"w": "result", "b": [0.6953, 0.2124, 0.7423, 0.2338]}, {"w": "on", "b": [0.7476, 0.2124, 0.7697, 0.2338]}, {"w": "ImageNet", "b": [0.7751, 0.2124, 0.8571, 0.2338]}, {"w": "classification:", "b": [0.1429, 0.2314, 0.255, 0.2529]}, {"w": "reaching", "b": [0.2622, 0.2314, 0.3346, 0.2529]}, {"w": "4.9%", "b": [0.3418, 0.2314, 0.3823, 0.2529]}, {"w": "top-5", "b": [0.3894, 0.2314, 0.4348, 0.2529]}, {"w": "validation", "b": [0.4419, 0.2314, 0.5253, 0.2529]}, {"w": "error", "b": [0.5325, 0.2314, 0.5752, 0.2529]}, {"w": "(and", "b": [0.5824, 0.2314, 0.6211, 0.2529]}, {"w": "4.8%", "b": [0.6283, 0.2314, 0.6688, 0.2529]}, {"w": "test", "b": [0.676, 0.2314, 0.7052, 0.2529]}, {"w": "error),", "b": [0.7124, 0.2314, 0.767, 0.2529]}, {"w": "exceeding", "b": [0.7742, 0.2314, 0.8571, 0.2529]}, {"w": "the", "b": [0.1429, 0.2505, 0.1692, 0.2719]}, {"w": "accuracy", "b": [0.1747, 0.2505, 0.2478, 0.2719]}, {"w": "of", "b": [0.2532, 0.2505, 0.27, 0.2719]}, {"w": "human", "b": [0.2755, 0.2505, 0.3349, 0.2719]}, {"w": "raters.”", "b": [0.3404, 0.2505, 0.3977, 0.2719]}, {"w": "Finally,", "b": [0.4032, 0.2505, 0.4636, 0.2719]}, {"w": "like", "b": [0.4691, 0.2505, 0.4992, 0.2719]}, {"w": "a", "b": [0.5046, 0.2505, 0.5138, 0.2719]}, {"w": "gift", "b": [0.5193, 0.2505, 0.5471, 0.2719]}, {"w": "that", "b": [0.5526, 0.2505, 0.5852, 0.2719]}, {"w": "keeps", "b": [0.5907, 0.2505, 0.6373, 0.2719]}, {"w": "on", "b": [0.6427, 0.2505, 0.6648, 0.2719]}, {"w": "giving,", "b": [0.6702, 0.2505, 0.7267, 0.2719]}, {"w": "Batch", "b": [0.7322, 0.2505, 0.7795, 0.2719]}, {"w": "Normal‐", "b": [0.7849, 0.2505, 0.8572, 0.2719]}, {"w": "ization", "b": [0.1429, 0.2695, 0.1999, 0.291]}, {"w": "also", "b": [0.206, 0.2695, 0.2387, 0.291]}, {"w": "acts", "b": [0.2448, 0.2695, 0.2768, 0.291]}, {"w": "like", "b": [0.2829, 0.2695, 0.313, 0.291]}, {"w": "a", "b": [0.3191, 0.2695, 0.3283, 0.291]}, {"w": "regularizer,", "b": [0.3344, 0.2695, 0.4283, 0.291]}, {"w": "reducing", "b": [0.4344, 0.2695, 0.5086, 0.291]}, {"w": "the", "b": [0.5147, 0.2695, 0.5411, 0.291]}, {"w": "need", "b": [0.5472, 0.2695, 0.5873, 0.291]}, {"w": "for", "b": [0.5934, 0.2695, 0.6179, 0.291]}, {"w": "other", "b": [0.6241, 0.2695, 0.6688, 0.291]}, {"w": "regularization", "b": [0.6749, 0.2695, 0.7915, 0.291]}, {"w": "techni‐", "b": [0.7976, 0.2695, 0.8571, 0.291]}, {"w": "ques", "b": [0.1429, 0.2886, 0.1811, 0.31]}, {"w": "(such", "b": [0.1858, 0.2886, 0.2316, 0.31]}, {"w": "as", "b": [0.2364, 0.2886, 0.2532, 0.31]}, {"w": "dropout,", "b": [0.2579, 0.2886, 0.331, 0.31]}, {"w": "described", "b": [0.3357, 0.2886, 0.4158, 0.31]}, {"w": "later", "b": [0.4205, 0.2886, 0.4574, 0.31]}, {"w": "in", "b": [0.4622, 0.2886, 0.4791, 0.31]}, {"w": "this", "b": [0.4839, 0.2886, 0.5146, 0.31]}, {"w": "chapter).", "b": [0.5193, 0.2886, 0.5938, 0.31]}]}, {"id": "b_1", "type": "paragraph", "text": "Batch Normalization does, however, add some complexity to the model (although it can remove the need for normalizing the input data, as we discussed earlier). More‐ over, there is a runtime penalty: the neural network makes slower predictions due to the extra computations required at each layer. So if you need predictions to be lightning-fast, you may want to check how well plain ELU + He initialization perform before playing with Batch Normalization.", "words": [{"w": "Batch", "b": [0.1429, 0.3167, 0.1901, 0.3381]}, {"w": "Normalization", "b": [0.1965, 0.3167, 0.3184, 0.3381]}, {"w": "does,", "b": [0.3247, 0.3167, 0.3676, 0.3381]}, {"w": "however,", "b": [0.374, 0.3167, 0.4485, 0.3381]}, {"w": "add", "b": [0.4549, 0.3167, 0.4861, 0.3381]}, {"w": "some", "b": [0.4925, 0.3167, 0.5366, 0.3381]}, {"w": "complexity", "b": [0.543, 0.3167, 0.6355, 0.3381]}, {"w": "to", "b": [0.6419, 0.3167, 0.6589, 0.3381]}, {"w": "the", "b": [0.6652, 0.3167, 0.6916, 0.3381]}, {"w": "model", "b": [0.698, 0.3167, 0.7508, 0.3381]}, {"w": "(although", "b": [0.7572, 0.3167, 0.8388, 0.3381]}, {"w": "it", "b": [0.8452, 0.3167, 0.8571, 0.3381]}, {"w": "can", "b": [0.1428, 0.3358, 0.1722, 0.3572]}, {"w": "remove", "b": [0.1784, 0.3358, 0.2412, 0.3572]}, {"w": "the", "b": [0.2474, 0.3358, 0.2737, 0.3572]}, {"w": "need", "b": [0.2799, 0.3358, 0.32, 0.3572]}, {"w": "for", "b": [0.3262, 0.3358, 0.3508, 0.3572]}, {"w": "normalizing", "b": [0.357, 0.3358, 0.4593, 0.3572]}, {"w": "the", "b": [0.4655, 0.3358, 0.4918, 0.3572]}, {"w": "input", "b": [0.498, 0.3358, 0.5429, 0.3572]}, {"w": "data,", "b": [0.5491, 0.3358, 0.5891, 0.3572]}, {"w": "as", "b": [0.5954, 0.3358, 0.6122, 0.3572]}, {"w": "we", "b": [0.6184, 0.3358, 0.6415, 0.3572]}, {"w": "discussed", "b": [0.6477, 0.3358, 0.7269, 0.3572]}, {"w": "earlier).", "b": [0.7332, 0.3358, 0.7983, 0.3572]}, {"w": "More‐", "b": [0.8045, 0.3358, 0.8571, 0.3572]}, {"w": "over,", "b": [0.1429, 0.3548, 0.1832, 0.3762]}, {"w": "there", "b": [0.1889, 0.3548, 0.2318, 0.3762]}, {"w": "is", "b": [0.2376, 0.3548, 0.2508, 0.3762]}, {"w": "a", "b": [0.2566, 0.3548, 0.2657, 0.3762]}, {"w": "runtime", "b": [0.2715, 0.3548, 0.3392, 0.3762]}, {"w": "penalty:", "b": [0.3449, 0.3548, 0.4118, 0.3762]}, {"w": "the", "b": [0.4176, 0.3548, 0.4439, 0.3762]}, {"w": "neural", "b": [0.4497, 0.3548, 0.5032, 0.3762]}, {"w": "network", "b": [0.5089, 0.3548, 0.5785, 0.3762]}, {"w": "makes", "b": [0.5842, 0.3548, 0.6373, 0.3762]}, {"w": "slower", "b": [0.6431, 0.3548, 0.6975, 0.3762]}, {"w": "predictions", "b": [0.7032, 0.3548, 0.7977, 0.3762]}, {"w": "due", "b": [0.8035, 0.3548, 0.8344, 0.3762]}, {"w": "to", "b": [0.8402, 0.3548, 0.8571, 0.3762]}, {"w": "the", "b": [0.1429, 0.3738, 0.1692, 0.3953]}, {"w": "extra", "b": [0.1791, 0.3738, 0.221, 0.3953]}, {"w": "computations", "b": [0.2309, 0.3738, 0.3457, 0.3953]}, {"w": "required", "b": [0.3556, 0.3738, 0.427, 0.3953]}, {"w": "at", "b": [0.4369, 0.3738, 0.452, 0.3953]}, {"w": "each", "b": [0.4619, 0.3738, 0.4999, 0.3953]}, {"w": "layer.", "b": [0.5098, 0.3738, 0.5534, 0.3953]}, {"w": "So", "b": [0.5633, 0.3738, 0.5838, 0.3953]}, {"w": "if", "b": [0.5937, 0.3738, 0.6054, 0.3953]}, {"w": "you", "b": [0.6153, 0.3738, 0.6466, 0.3953]}, {"w": "need", "b": [0.6564, 0.3738, 0.6965, 0.3953]}, {"w": "predictions", "b": [0.7064, 0.3738, 0.8009, 0.3953]}, {"w": "to", "b": [0.8108, 0.3738, 0.8278, 0.3953]}, {"w": "be", "b": [0.8377, 0.3738, 0.8571, 0.3953]}, {"w": "lightning-fast,", "b": [0.1429, 0.3929, 0.2601, 0.4143]}, {"w": "you", "b": [0.265, 0.3929, 0.2963, 0.4143]}, {"w": "may", "b": [0.3012, 0.3929, 0.3366, 0.4143]}, {"w": "want", "b": [0.3415, 0.3929, 0.3823, 0.4143]}, {"w": "to", "b": [0.3872, 0.3929, 0.4041, 0.4143]}, {"w": "check", "b": [0.409, 0.3929, 0.457, 0.4143]}, {"w": "how", "b": [0.4619, 0.3929, 0.4979, 0.4143]}, {"w": "well", "b": [0.5028, 0.3929, 0.5365, 0.4143]}, {"w": "plain", "b": [0.5414, 0.3929, 0.5837, 0.4143]}, {"w": "ELU", "b": [0.5886, 0.3929, 0.6261, 0.4143]}, {"w": "+", "b": [0.631, 0.3929, 0.6431, 0.4143]}, {"w": "He", "b": [0.648, 0.3929, 0.6723, 0.4143]}, {"w": "initialization", "b": [0.6772, 0.3929, 0.7832, 0.4143]}, {"w": "perform", "b": [0.7881, 0.3929, 0.8571, 0.4143]}, {"w": "before", "b": [0.1429, 0.4119, 0.1957, 0.4334]}, {"w": "playing", "b": [0.2004, 0.4119, 0.2617, 0.4334]}, {"w": "with", "b": [0.2664, 0.4119, 0.3037, 0.4334]}, {"w": "Batch", "b": [0.3084, 0.4119, 0.3557, 0.4334]}, {"w": "Normalization.", "b": [0.3605, 0.4119, 0.4871, 0.4334]}]}, {"id": "b_2", "type": "paragraph", "text": "You may find that training is rather slow, because each epoch takes much more time when you use batch normalization. However, this is usually counterbalanced by the fact that convergence is much faster with BN, so it will take fewer epochs to reach the same per‐ formance. All in all, wall time will usually be smaller (this is the time measured by the clock on your wall).", "words": [{"w": "You", "b": [0.2714, 0.4539, 0.301, 0.4735]}, {"w": "may", "b": [0.3061, 0.4539, 0.3384, 0.4735]}, {"w": "find", "b": [0.3435, 0.4539, 0.3747, 0.4735]}, {"w": "that", "b": [0.3798, 0.4539, 0.4096, 0.4735]}, {"w": "training", "b": [0.4147, 0.4539, 0.4759, 0.4735]}, {"w": "is", "b": [0.481, 0.4539, 0.4931, 0.4735]}, {"w": "rather", "b": [0.4981, 0.4539, 0.5444, 0.4735]}, {"w": "slow,", "b": [0.5494, 0.4539, 0.587, 0.4735]}, {"w": "because", "b": [0.592, 0.4539, 0.6511, 0.4735]}, {"w": "each", "b": [0.6562, 0.4539, 0.6908, 0.4735]}, {"w": "epoch", "b": [0.6959, 0.4539, 0.7419, 0.4735]}, {"w": "takes", "b": [0.747, 0.4539, 0.7857, 0.4735]}, {"w": "much", "b": [0.2714, 0.4713, 0.315, 0.4909]}, {"w": "more", "b": [0.3201, 0.4713, 0.3606, 0.4909]}, {"w": "time", "b": [0.3656, 0.4713, 0.4003, 0.4909]}, {"w": "when", "b": [0.4053, 0.4713, 0.4471, 0.4909]}, {"w": "you", "b": [0.4522, 0.4713, 0.4807, 0.4909]}, {"w": "use", "b": [0.4858, 0.4713, 0.511, 0.4909]}, {"w": "batch", "b": [0.5161, 0.4713, 0.5578, 0.4909]}, {"w": "normalization.", "b": [0.5629, 0.4713, 0.6754, 0.4909]}, {"w": "However,", "b": [0.6805, 0.4713, 0.7526, 0.4909]}, {"w": "this", "b": [0.7576, 0.4713, 0.7857, 0.4909]}, {"w": "is", "b": [0.2714, 0.4887, 0.2835, 0.5083]}, {"w": "usually", "b": [0.2913, 0.4887, 0.3453, 0.5083]}, {"w": "counterbalanced", "b": [0.3531, 0.4887, 0.4799, 0.5083]}, {"w": "by", "b": [0.4877, 0.4887, 0.5061, 0.5083]}, {"w": "the", "b": [0.5139, 0.4887, 0.538, 0.5083]}, {"w": "fact", "b": [0.5458, 0.4887, 0.5737, 0.5083]}, {"w": "that", "b": [0.5815, 0.4887, 0.6113, 0.5083]}, {"w": "convergence", "b": [0.6191, 0.4887, 0.7144, 0.5083]}, {"w": "is", "b": [0.7222, 0.4887, 0.7343, 0.5083]}, {"w": "much", "b": [0.7421, 0.4887, 0.7857, 0.5083]}, {"w": "faster", "b": [0.2714, 0.5061, 0.3134, 0.5257]}, {"w": "with", "b": [0.3191, 0.5061, 0.3532, 0.5257]}, {"w": "BN,", "b": [0.3589, 0.5061, 0.3886, 0.5257]}, {"w": "so", "b": [0.3943, 0.5061, 0.411, 0.5257]}, {"w": "it", "b": [0.4167, 0.5061, 0.4276, 0.5257]}, {"w": "will", "b": [0.4333, 0.5061, 0.4611, 0.5257]}, {"w": "take", "b": [0.4668, 0.5061, 0.4985, 0.5257]}, {"w": "fewer", "b": [0.5042, 0.5061, 0.5462, 0.5257]}, {"w": "epochs", "b": [0.5519, 0.5061, 0.6049, 0.5257]}, {"w": "to", "b": [0.6106, 0.5061, 0.6261, 0.5257]}, {"w": "reach", "b": [0.6318, 0.5061, 0.6736, 0.5257]}, {"w": "the", "b": [0.6793, 0.5061, 0.7033, 0.5257]}, {"w": "same", "b": [0.7091, 0.5061, 0.7481, 0.5257]}, {"w": "per‐", "b": [0.7538, 0.5061, 0.7857, 0.5257]}, {"w": "formance.", "b": [0.2714, 0.5235, 0.3487, 0.5431]}, {"w": "All", "b": [0.3559, 0.5235, 0.3787, 0.5431]}, {"w": "in", "b": [0.3858, 0.5235, 0.4013, 0.5431]}, {"w": "all,", "b": [0.4085, 0.5235, 0.4308, 0.5431]}, {"w": "wall", "b": [0.438, 0.5234, 0.4692, 0.5431]}, {"w": "time", "b": [0.4764, 0.5234, 0.5095, 0.5431]}, {"w": "will", "b": [0.5166, 0.5235, 0.5444, 0.5431]}, {"w": "usually", "b": [0.5516, 0.5235, 0.6056, 0.5431]}, {"w": "be", "b": [0.6127, 0.5235, 0.6305, 0.5431]}, {"w": "smaller", "b": [0.6376, 0.5235, 0.6934, 0.5431]}, {"w": "(this", "b": [0.7006, 0.5235, 0.7352, 0.5431]}, {"w": "is", "b": [0.7424, 0.5235, 0.7545, 0.5431]}, {"w": "the", "b": [0.7616, 0.5235, 0.7857, 0.5431]}, {"w": "time", "b": [0.2714, 0.541, 0.306, 0.5605]}, {"w": "measured", "b": [0.3103, 0.541, 0.3847, 0.5605]}, {"w": "by", "b": [0.389, 0.541, 0.4075, 0.5605]}, {"w": "the", "b": [0.4118, 0.541, 0.4359, 0.5605]}, {"w": "clock", "b": [0.4402, 0.541, 0.4803, 0.5605]}, {"w": "on", "b": [0.4846, 0.541, 0.5047, 0.5605]}, {"w": "your", "b": [0.5091, 0.541, 0.5447, 0.5605]}, {"w": "wall).", "b": [0.549, 0.541, 0.591, 0.5605]}]}, {"id": "b_3", "type": "paragraph", "text": "Implementing Batch Normalization with Keras", "words": [{"w": "Implementing", "b": [0.1429, 0.5795, 0.2516, 0.6004]}, {"w": "Batch", "b": [0.2552, 0.5795, 0.2984, 0.6004]}, {"w": "Normalization", "b": [0.302, 0.5795, 0.4099, 0.6004]}, {"w": "with", "b": [0.4135, 0.5795, 0.4484, 0.6004]}, {"w": "Keras", "b": [0.452, 0.5795, 0.4934, 0.6004]}]}, {"id": "b_4", "type": "paragraph", "text": "As with most things with Keras, implementing Batch Normalization is quite simple. Just add a BatchNormalization layer before or after each hidden layer’s activation function, and optionally add a BN layer as well as the first layer in your model. For example, this model applies BN after every hidden layer and as the first layer in the model (after flattening the input images):", "words": [{"w": "As", "b": [0.1429, 0.6061, 0.1649, 0.6275]}, {"w": "with", "b": [0.1713, 0.6061, 0.2087, 0.6275]}, {"w": "most", "b": [0.2151, 0.6061, 0.2568, 0.6275]}, {"w": "things", "b": [0.2632, 0.6061, 0.315, 0.6275]}, {"w": "with", "b": [0.3214, 0.6061, 0.3588, 0.6275]}, {"w": "Keras,", "b": [0.3652, 0.6061, 0.4168, 0.6275]}, {"w": "implementing", "b": [0.4232, 0.6061, 0.5405, 0.6275]}, {"w": "Batch", "b": [0.5469, 0.6061, 0.5942, 0.6275]}, {"w": "Normalization", "b": [0.6007, 0.6061, 0.7225, 0.6275]}, {"w": "is", "b": [0.7289, 0.6061, 0.7421, 0.6275]}, {"w": "quite", "b": [0.7485, 0.6061, 0.791, 0.6275]}, {"w": "simple.", "b": [0.7975, 0.6061, 0.8571, 0.6275]}, {"w": "Just", "b": [0.1429, 0.6261, 0.1741, 0.6475]}, {"w": "add", "b": [0.1819, 0.6261, 0.213, 0.6475]}, {"w": "a", "b": [0.2208, 0.6261, 0.2299, 0.6475]}, {"w": "BatchNormalization", "b": [0.2377, 0.6293, 0.4158, 0.6443]}, {"w": "layer", "b": [0.4236, 0.6261, 0.4638, 0.6475]}, {"w": "before", "b": [0.4715, 0.6261, 0.5243, 0.6475]}, {"w": "or", "b": [0.5321, 0.6261, 0.5504, 0.6475]}, {"w": "after", "b": [0.5582, 0.6261, 0.5965, 0.6475]}, {"w": "each", "b": [0.6042, 0.6261, 0.6422, 0.6475]}, {"w": "hidden", "b": [0.6499, 0.6261, 0.7089, 0.6475]}, {"w": "layer’s", "b": [0.7166, 0.6261, 0.7671, 0.6475]}, {"w": "activation", "b": [0.7749, 0.6261, 0.8571, 0.6475]}, {"w": "function,", "b": [0.1429, 0.6451, 0.219, 0.6665]}, {"w": "and", "b": [0.2255, 0.6451, 0.257, 0.6665]}, {"w": "optionally", "b": [0.2635, 0.6451, 0.3483, 0.6665]}, {"w": "add", "b": [0.3548, 0.6451, 0.3859, 0.6665]}, {"w": "a", "b": [0.3924, 0.6451, 0.4016, 0.6665]}, {"w": "BN", "b": [0.408, 0.6451, 0.4358, 0.6665]}, {"w": "layer", "b": [0.4423, 0.6451, 0.4825, 0.6665]}, {"w": "as", "b": [0.4889, 0.6451, 0.5057, 0.6665]}, {"w": "well", "b": [0.5122, 0.6451, 0.5459, 0.6665]}, {"w": "as", "b": [0.5524, 0.6451, 0.5692, 0.6665]}, {"w": "the", "b": [0.5757, 0.6451, 0.602, 0.6665]}, {"w": "first", "b": [0.6085, 0.6451, 0.642, 0.6665]}, {"w": "layer", "b": [0.6485, 0.6451, 0.6887, 0.6665]}, {"w": "in", "b": [0.6952, 0.6451, 0.7121, 0.6665]}, {"w": "your", "b": [0.7186, 0.6451, 0.7576, 0.6665]}, {"w": "model.", "b": [0.7641, 0.6451, 0.8217, 0.6665]}, {"w": "For", "b": [0.8282, 0.6451, 0.8571, 0.6665]}, {"w": "example,", "b": [0.1429, 0.6642, 0.2172, 0.6856]}, {"w": "this", "b": [0.2236, 0.6642, 0.2543, 0.6856]}, {"w": "model", "b": [0.2607, 0.6642, 0.3135, 0.6856]}, {"w": "applies", "b": [0.32, 0.6642, 0.3779, 0.6856]}, {"w": "BN", "b": [0.3844, 0.6642, 0.4121, 0.6856]}, {"w": "after", "b": [0.4185, 0.6642, 0.4568, 0.6856]}, {"w": "every", "b": [0.4632, 0.6642, 0.5085, 0.6856]}, {"w": "hidden", "b": [0.5149, 0.6642, 0.5738, 0.6856]}, {"w": "layer", "b": [0.5803, 0.6642, 0.6205, 0.6856]}, {"w": "and", "b": [0.6269, 0.6642, 0.6584, 0.6856]}, {"w": "as", "b": [0.6649, 0.6642, 0.6817, 0.6856]}, {"w": "the", "b": [0.6881, 0.6642, 0.7144, 0.6856]}, {"w": "first", "b": [0.7209, 0.6642, 0.7543, 0.6856]}, {"w": "layer", "b": [0.7608, 0.6642, 0.801, 0.6856]}, {"w": "in", "b": [0.8074, 0.6642, 0.8244, 0.6856]}, {"w": "the", "b": [0.8308, 0.6642, 0.8572, 0.6856]}, {"w": "model", "b": [0.1429, 0.6832, 0.1957, 0.7046]}, {"w": "(after", "b": [0.2004, 0.6832, 0.2459, 0.7046]}, {"w": "flattening", "b": [0.2506, 0.6832, 0.3305, 0.7046]}, {"w": "the", "b": [0.3352, 0.6832, 0.3615, 0.7046]}, {"w": "input", "b": [0.3663, 0.6832, 0.4112, 0.7046]}, {"w": "images):", "b": [0.4159, 0.6832, 0.4859, 0.7046]}]}, {"id": "b_5", "type": "paragraph", "text": "model = keras.models.Sequential([ keras.layers.Flatten(input_shape=[28, 28]), keras.layers.BatchNormalization(), keras.layers.Dense(300, activation=\"elu\", kernel_initializer=\"he_normal\"), keras.layers.BatchNormalization(), keras.layers.Dense(100, activation=\"elu\", kernel_initializer=\"he_normal\"), keras.layers.BatchNormalization(), keras.layers.Dense(10, activation=\"softmax\") ])", "words": [{"w": "model", "b": [0.1766, 0.7152, 0.2188, 0.728]}, {"w": "=", "b": [0.2272, 0.7152, 0.2356, 0.728]}, {"w": "keras.models.Sequential([", "b": [0.2441, 0.7152, 0.4549, 0.728]}, {"w": "keras.layers.Flatten(input_shape=[28,", "b": [0.2103, 0.7306, 0.5223, 0.7435]}, {"w": "28]),", "b": [0.5308, 0.7306, 0.5729, 0.7435]}, {"w": "keras.layers.BatchNormalization(),", "b": [0.2103, 0.746, 0.497, 0.7589]}, {"w": "keras.layers.Dense(300,", "b": [0.2103, 0.7614, 0.4043, 0.7743]}, {"w": "activation=\"elu\",", "b": [0.4127, 0.7614, 0.5561, 0.7743]}, {"w": "kernel_initializer=\"he_normal\"),", "b": [0.5645, 0.7614, 0.8343, 0.7743]}, {"w": "keras.layers.BatchNormalization(),", "b": [0.2103, 0.7769, 0.497, 0.7897]}, {"w": "keras.layers.Dense(100,", "b": [0.2103, 0.7923, 0.4043, 0.8051]}, {"w": "activation=\"elu\",", "b": [0.4127, 0.7923, 0.5561, 0.8051]}, {"w": "kernel_initializer=\"he_normal\"),", "b": [0.5645, 0.7923, 0.8343, 0.8051]}, {"w": "keras.layers.BatchNormalization(),", "b": [0.2103, 0.8077, 0.497, 0.8206]}, {"w": "keras.layers.Dense(10,", "b": [0.2103, 0.8231, 0.3958, 0.836]}, {"w": "activation=\"softmax\")", "b": [0.4043, 0.8231, 0.5814, 0.836]}, {"w": "])", "b": [0.1766, 0.8385, 0.1935, 0.8514]}]}, {"id": "b_6", "type": "equation", "text": "Vanishing/Exploding Gradients Problems | 335", "words": [{"w": "Vanishing/Exploding", "b": [0.5559, 0.9225, 0.678, 0.9388]}, {"w": "Gradients", "b": [0.6808, 0.9225, 0.7376, 0.9388]}, {"w": "Problems", "b": [0.7404, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "335", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 362, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "9 However, they are estimated during training, based on the training data, so arguably they are trainable. In Keras, “Non-trainable” really means “untouched by backpropagation”.", "words": [{"w": "9", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "However,", "b": [0.1587, 0.8598, 0.2188, 0.8761]}, {"w": "they", "b": [0.2224, 0.8598, 0.2498, 0.8761]}, {"w": "are", "b": [0.2534, 0.8598, 0.273, 0.8761]}, {"w": "estimated", "b": [0.2766, 0.8598, 0.3379, 0.8761]}, {"w": "during", "b": [0.3415, 0.8598, 0.3845, 0.8761]}, {"w": "training,", "b": [0.3881, 0.8598, 0.4428, 0.8761]}, {"w": "based", "b": [0.4464, 0.8598, 0.4823, 0.8761]}, {"w": "on", "b": [0.486, 0.8598, 0.5027, 0.8761]}, {"w": "the", "b": [0.5063, 0.8598, 0.5264, 0.8761]}, {"w": "training", "b": [0.53, 0.8598, 0.581, 0.8761]}, {"w": "data,", "b": [0.5846, 0.8598, 0.6151, 0.8761]}, {"w": "so", "b": [0.6187, 0.8598, 0.6326, 0.8761]}, {"w": "arguably", "b": [0.6362, 0.8598, 0.6913, 0.8761]}, {"w": "they", "b": [0.6949, 0.8598, 0.7222, 0.8761]}, {"w": "are", "b": [0.7258, 0.8596, 0.7452, 0.8761]}, {"w": "trainable.", "b": [0.7488, 0.8598, 0.8088, 0.8761]}, {"w": "In", "b": [0.8124, 0.8598, 0.8265, 0.8761]}, {"w": "Keras,", "b": [0.1587, 0.8749, 0.1981, 0.8912]}, {"w": "“Non-trainable”", "b": [0.2017, 0.8749, 0.3037, 0.8912]}, {"w": "really", "b": [0.3073, 0.8749, 0.3422, 0.8912]}, {"w": "means", "b": [0.3458, 0.8749, 0.387, 0.8912]}, {"w": "“untouched", "b": [0.3907, 0.8749, 0.4649, 0.8912]}, {"w": "by", "b": [0.4685, 0.8749, 0.4838, 0.8912]}, {"w": "backpropagation”.", "b": [0.4874, 0.8749, 0.6008, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "That’s all! In this tiny example with just two hidden layers, it’s unlikely that Batch Normalization will have a very positive impact, but for deeper networks it can make a tremendous difference.", "words": [{"w": "That’s", "b": [0.1429, 0.0791, 0.1917, 0.1005]}, {"w": "all!", "b": [0.1995, 0.0791, 0.225, 0.1005]}, {"w": "In", "b": [0.2328, 0.0791, 0.2513, 0.1005]}, {"w": "this", "b": [0.2591, 0.0791, 0.2898, 0.1005]}, {"w": "tiny", "b": [0.2976, 0.0791, 0.33, 0.1005]}, {"w": "example", "b": [0.3378, 0.0791, 0.4074, 0.1005]}, {"w": "with", "b": [0.4152, 0.0791, 0.4525, 0.1005]}, {"w": "just", "b": [0.4604, 0.0791, 0.4907, 0.1005]}, {"w": "two", "b": [0.4986, 0.0791, 0.5298, 0.1005]}, {"w": "hidden", "b": [0.5376, 0.0791, 0.5966, 0.1005]}, {"w": "layers,", "b": [0.6044, 0.0791, 0.657, 0.1005]}, {"w": "it’s", "b": [0.6648, 0.0791, 0.6865, 0.1005]}, {"w": "unlikely", "b": [0.6943, 0.0791, 0.7616, 0.1005]}, {"w": "that", "b": [0.7695, 0.0791, 0.802, 0.1005]}, {"w": "Batch", "b": [0.8099, 0.0791, 0.8572, 0.1005]}, {"w": "Normalization", "b": [0.1429, 0.0981, 0.2647, 0.1195]}, {"w": "will", "b": [0.2696, 0.0981, 0.3, 0.1195]}, {"w": "have", "b": [0.3049, 0.0981, 0.3433, 0.1195]}, {"w": "a", "b": [0.3483, 0.0981, 0.3574, 0.1195]}, {"w": "very", "b": [0.3623, 0.0981, 0.3987, 0.1195]}, {"w": "positive", "b": [0.4036, 0.0981, 0.4688, 0.1195]}, {"w": "impact,", "b": [0.4738, 0.0981, 0.536, 0.1195]}, {"w": "but", "b": [0.5409, 0.0981, 0.5689, 0.1195]}, {"w": "for", "b": [0.5738, 0.0981, 0.5984, 0.1195]}, {"w": "deeper", "b": [0.6033, 0.0981, 0.6595, 0.1195]}, {"w": "networks", "b": [0.6644, 0.0981, 0.7416, 0.1195]}, {"w": "it", "b": [0.7465, 0.0981, 0.7585, 0.1195]}, {"w": "can", "b": [0.7634, 0.0981, 0.7928, 0.1195]}, {"w": "make", "b": [0.7977, 0.0981, 0.8431, 0.1195]}, {"w": "a", "b": [0.848, 0.0981, 0.8571, 0.1195]}, {"w": "tremendous", "b": [0.1429, 0.1172, 0.2434, 0.1386]}, {"w": "difference.", "b": [0.2482, 0.1172, 0.3363, 0.1386]}]}, {"id": "b_2", "type": "paragraph", "text": "Let’s zoom in a bit. If you display the model summary, you can see that each BN layer adds 4 parameters per input: γ, β, μ and σ (for example, the first BN layer adds 3136 parameters, which is 4 times 784). The last two parameters, μ and σ, are the moving averages, they are not affected by backpropagation, so Keras calls them “Non- trainable”9 (if you count the total number of BN parameters, 3136 + 1200 + 400, and divide by two, you get 2,368, which is the total number of non-trainable params in this model).", "words": [{"w": "Let’s", "b": [0.1429, 0.1453, 0.179, 0.1667]}, {"w": "zoom", "b": [0.1842, 0.1453, 0.2312, 0.1667]}, {"w": "in", "b": [0.2364, 0.1453, 0.2534, 0.1667]}, {"w": "a", "b": [0.2585, 0.1453, 0.2677, 0.1667]}, {"w": "bit.", "b": [0.2729, 0.1453, 0.3001, 0.1667]}, {"w": "If", "b": [0.3053, 0.1453, 0.3186, 0.1667]}, {"w": "you", "b": [0.3237, 0.1453, 0.355, 0.1667]}, {"w": "display", "b": [0.3601, 0.1453, 0.4189, 0.1667]}, {"w": "the", "b": [0.424, 0.1453, 0.4504, 0.1667]}, {"w": "model", "b": [0.4555, 0.1453, 0.5083, 0.1667]}, {"w": "summary,", "b": [0.5135, 0.1453, 0.5966, 0.1667]}, {"w": "you", "b": [0.6018, 0.1453, 0.633, 0.1667]}, {"w": "can", "b": [0.6382, 0.1453, 0.6675, 0.1667]}, {"w": "see", "b": [0.6727, 0.1453, 0.6981, 0.1667]}, {"w": "that", "b": [0.7032, 0.1453, 0.7358, 0.1667]}, {"w": "each", "b": [0.741, 0.1453, 0.7789, 0.1667]}, {"w": "BN", "b": [0.7841, 0.1453, 0.8118, 0.1667]}, {"w": "layer", "b": [0.817, 0.1453, 0.8571, 0.1667]}, {"w": "adds", "b": [0.1428, 0.1643, 0.1816, 0.1857]}, {"w": "4", "b": [0.1874, 0.1643, 0.1974, 0.1857]}, {"w": "parameters", "b": [0.2031, 0.1643, 0.2965, 0.1857]}, {"w": "per", "b": [0.3023, 0.1643, 0.3298, 0.1857]}, {"w": "input:", "b": [0.3355, 0.1643, 0.3852, 0.1857]}, {"w": "γ,", "b": [0.3909, 0.1638, 0.4062, 0.1857]}, {"w": "β,", "b": [0.4119, 0.1638, 0.4278, 0.1857]}, {"w": "μ", "b": [0.4335, 0.1638, 0.4447, 0.1857]}, {"w": "and", "b": [0.4505, 0.1643, 0.482, 0.1857]}, {"w": "σ", "b": [0.4877, 0.1638, 0.4987, 0.1857]}, {"w": "(for", "b": [0.5045, 0.1643, 0.5362, 0.1857]}, {"w": "example,", "b": [0.5419, 0.1643, 0.6162, 0.1857]}, {"w": "the", "b": [0.622, 0.1643, 0.6483, 0.1857]}, {"w": "first", "b": [0.654, 0.1643, 0.6875, 0.1857]}, {"w": "BN", "b": [0.6932, 0.1643, 0.721, 0.1857]}, {"w": "layer", "b": [0.7267, 0.1643, 0.7669, 0.1857]}, {"w": "adds", "b": [0.7726, 0.1643, 0.8114, 0.1857]}, {"w": "3136", "b": [0.8171, 0.1643, 0.8571, 0.1857]}, {"w": "parameters,", "b": [0.1429, 0.1834, 0.2411, 0.2048]}, {"w": "which", "b": [0.247, 0.1834, 0.2979, 0.2048]}, {"w": "is", "b": [0.3039, 0.1834, 0.3171, 0.2048]}, {"w": "4", "b": [0.323, 0.1834, 0.333, 0.2048]}, {"w": "times", "b": [0.339, 0.1834, 0.3845, 0.2048]}, {"w": "784).", "b": [0.3904, 0.1834, 0.4324, 0.2048]}, {"w": "The", "b": [0.4383, 0.1834, 0.4712, 0.2048]}, {"w": "last", "b": [0.4771, 0.1834, 0.5055, 0.2048]}, {"w": "two", "b": [0.5115, 0.1834, 0.5427, 0.2048]}, {"w": "parameters,", "b": [0.5487, 0.1834, 0.6469, 0.2048]}, {"w": "μ", "b": [0.6528, 0.1828, 0.664, 0.2048]}, {"w": "and", "b": [0.6699, 0.1834, 0.7015, 0.2048]}, {"w": "σ,", "b": [0.7074, 0.1828, 0.7232, 0.2048]}, {"w": "are", "b": [0.7291, 0.1834, 0.7549, 0.2048]}, {"w": "the", "b": [0.7608, 0.1834, 0.7871, 0.2048]}, {"w": "moving", "b": [0.7931, 0.1834, 0.8571, 0.2048]}, {"w": "averages,", "b": [0.1429, 0.2024, 0.218, 0.2238]}, {"w": "they", "b": [0.229, 0.2024, 0.2649, 0.2238]}, {"w": "are", "b": [0.2759, 0.2024, 0.3016, 0.2238]}, {"w": "not", "b": [0.3126, 0.2024, 0.341, 0.2238]}, {"w": "affected", "b": [0.3519, 0.2024, 0.4173, 0.2238]}, {"w": "by", "b": [0.4283, 0.2024, 0.4484, 0.2238]}, {"w": "backpropagation,", "b": [0.4594, 0.2024, 0.6048, 0.2238]}, {"w": "so", "b": [0.6158, 0.2024, 0.6341, 0.2238]}, {"w": "Keras", "b": [0.6451, 0.2024, 0.692, 0.2238]}, {"w": "calls", "b": [0.7029, 0.2024, 0.7391, 0.2238]}, {"w": "them", "b": [0.7501, 0.2024, 0.7935, 0.2238]}, {"w": "“Non-", "b": [0.8045, 0.2024, 0.8571, 0.2238]}, {"w": "trainable”9", "b": [0.1429, 0.2215, 0.2298, 0.2429]}, {"w": "(if", "b": [0.2355, 0.2215, 0.2544, 0.2429]}, {"w": "you", "b": [0.2602, 0.2215, 0.2914, 0.2429]}, {"w": "count", "b": [0.2971, 0.2215, 0.345, 0.2429]}, {"w": "the", "b": [0.3507, 0.2215, 0.377, 0.2429]}, {"w": "total", "b": [0.3828, 0.2215, 0.4205, 0.2429]}, {"w": "number", "b": [0.4262, 0.2215, 0.4925, 0.2429]}, {"w": "of", "b": [0.4982, 0.2215, 0.515, 0.2429]}, {"w": "BN", "b": [0.5207, 0.2215, 0.5485, 0.2429]}, {"w": "parameters,", "b": [0.5542, 0.2215, 0.6524, 0.2429]}, {"w": "3136", "b": [0.6581, 0.2215, 0.6981, 0.2429]}, {"w": "+", "b": [0.7038, 0.2215, 0.7159, 0.2429]}, {"w": "1200", "b": [0.7216, 0.2215, 0.7616, 0.2429]}, {"w": "+", "b": [0.7673, 0.2215, 0.7794, 0.2429]}, {"w": "400,", "b": [0.7851, 0.2215, 0.8199, 0.2429]}, {"w": "and", "b": [0.8256, 0.2215, 0.8571, 0.2429]}, {"w": "divide", "b": [0.1429, 0.2405, 0.1945, 0.2619]}, {"w": "by", "b": [0.2014, 0.2405, 0.2216, 0.2619]}, {"w": "two,", "b": [0.2285, 0.2405, 0.2639, 0.2619]}, {"w": "you", "b": [0.2708, 0.2405, 0.302, 0.2619]}, {"w": "get", "b": [0.3089, 0.2405, 0.3339, 0.2619]}, {"w": "2,368,", "b": [0.3408, 0.2405, 0.3903, 0.2619]}, {"w": "which", "b": [0.3972, 0.2405, 0.4481, 0.2619]}, {"w": "is", "b": [0.455, 0.2405, 0.4682, 0.2619]}, {"w": "the", "b": [0.4751, 0.2405, 0.5014, 0.2619]}, {"w": "total", "b": [0.5083, 0.2405, 0.5461, 0.2619]}, {"w": "number", "b": [0.553, 0.2405, 0.6193, 0.2619]}, {"w": "of", "b": [0.6262, 0.2405, 0.6429, 0.2619]}, {"w": "non-trainable", "b": [0.6498, 0.2405, 0.7647, 0.2619]}, {"w": "params", "b": [0.7716, 0.2405, 0.8333, 0.2619]}, {"w": "in", "b": [0.8402, 0.2405, 0.8572, 0.2619]}, {"w": "this", "b": [0.1429, 0.2596, 0.1736, 0.281]}, {"w": "model).", "b": [0.1783, 0.2596, 0.2431, 0.281]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> model.summary() Model: \"sequential_3\" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= flatten_3 (Flatten) (None, 784) 0 _________________________________________________________________ batch_normalization_v2 (Batc (None, 784) 3136 _________________________________________________________________ dense_50 (Dense) (None, 300) 235500 _________________________________________________________________ batch_normalization_v2_1 (Ba (None, 300) 1200 _________________________________________________________________ dense_51 (Dense) (None, 100) 30100 _________________________________________________________________ batch_normalization_v2_2 (Ba (None, 100) 400 _________________________________________________________________ dense_52 (Dense) (None, 10) 1010 ================================================================= Total params: 271,346 Trainable params: 268,978 Non-trainable params: 2,368", "words": [{"w": ">>>", "b": [0.1766, 0.2915, 0.2019, 0.3044]}, {"w": "model.summary()", "b": [0.2103, 0.2915, 0.3368, 0.3044]}, {"w": "Model:", "b": [0.1766, 0.307, 0.2272, 0.3198]}, {"w": "\"sequential_3\"", "b": [0.2356, 0.307, 0.3537, 0.3198]}, {"w": "_________________________________________________________________", "b": [0.1766, 0.3224, 0.7247, 0.3352]}, {"w": "Layer", "b": [0.1766, 0.3378, 0.2187, 0.3506]}, {"w": "(type)", "b": [0.2272, 0.3378, 0.2778, 0.3506]}, {"w": "Output", "b": [0.4211, 0.3378, 0.4717, 0.3506]}, {"w": "Shape", "b": [0.4802, 0.3378, 0.5223, 0.3506]}, {"w": "Param", "b": [0.6404, 0.3378, 0.6825, 0.3506]}, {"w": "#", "b": [0.691, 0.3378, 0.6994, 0.3506]}, {"w": "=================================================================", "b": [0.1766, 0.3532, 0.7247, 0.3661]}, {"w": "flatten_3", "b": [0.1766, 0.3686, 0.2525, 0.3815]}, {"w": "(Flatten)", "b": [0.2609, 0.3686, 0.3368, 0.3815]}, {"w": "(None,", "b": [0.4211, 0.3686, 0.4717, 0.3815]}, {"w": "784)", "b": [0.4802, 0.3686, 0.5139, 0.3815]}, {"w": "0", "b": [0.6404, 0.3686, 0.6488, 0.3815]}, {"w": "_________________________________________________________________", "b": [0.1766, 0.3841, 0.7247, 0.3969]}, {"w": "batch_normalization_v2", "b": [0.1766, 0.3995, 0.3621, 0.4123]}, {"w": "(Batc", "b": [0.3705, 0.3995, 0.4127, 0.4123]}, {"w": "(None,", "b": [0.4211, 0.3995, 0.4717, 0.4123]}, {"w": "784)", "b": [0.4802, 0.3995, 0.5139, 0.4123]}, {"w": "3136", "b": [0.6404, 0.3995, 0.6741, 0.4123]}, {"w": "_________________________________________________________________", "b": [0.1766, 0.4149, 0.7247, 0.4277]}, {"w": "dense_50", "b": [0.1766, 0.4303, 0.244, 0.4432]}, {"w": "(Dense)", "b": [0.2525, 0.4303, 0.3115, 0.4432]}, {"w": "(None,", "b": [0.4211, 0.4303, 0.4717, 0.4432]}, {"w": "300)", "b": [0.4802, 0.4303, 0.5139, 0.4432]}, {"w": "235500", "b": [0.6404, 0.4303, 0.691, 0.4432]}, {"w": "_________________________________________________________________", "b": [0.1766, 0.4457, 0.7247, 0.4586]}, {"w": "batch_normalization_v2_1", "b": [0.1766, 0.4611, 0.379, 0.474]}, {"w": "(Ba", "b": [0.3874, 0.4611, 0.4127, 0.474]}, {"w": "(None,", "b": [0.4211, 0.4611, 0.4717, 0.474]}, {"w": "300)", "b": [0.4802, 0.4611, 0.5139, 0.474]}, {"w": "1200", "b": [0.6404, 0.4611, 0.6741, 0.474]}, {"w": "_________________________________________________________________", "b": [0.1766, 0.4766, 0.7247, 0.4894]}, {"w": "dense_51", "b": [0.1766, 0.492, 0.244, 0.5048]}, {"w": "(Dense)", "b": [0.2525, 0.492, 0.3115, 0.5048]}, {"w": "(None,", "b": [0.4211, 0.492, 0.4717, 0.5048]}, {"w": "100)", "b": [0.4802, 0.492, 0.5139, 0.5048]}, {"w": "30100", "b": [0.6404, 0.492, 0.6825, 0.5048]}, {"w": "_________________________________________________________________", "b": [0.1766, 0.5074, 0.7247, 0.5203]}, {"w": "batch_normalization_v2_2", "b": [0.1766, 0.5228, 0.379, 0.5357]}, {"w": "(Ba", "b": [0.3874, 0.5228, 0.4127, 0.5357]}, {"w": "(None,", "b": [0.4211, 0.5228, 0.4717, 0.5357]}, {"w": "100)", "b": [0.4802, 0.5228, 0.5139, 0.5357]}, {"w": "400", "b": [0.6404, 0.5228, 0.6657, 0.5357]}, {"w": "_________________________________________________________________", "b": [0.1766, 0.5382, 0.7247, 0.5511]}, {"w": "dense_52", "b": [0.1766, 0.5537, 0.244, 0.5665]}, {"w": "(Dense)", "b": [0.2525, 0.5537, 0.3115, 0.5665]}, {"w": "(None,", "b": [0.4211, 0.5537, 0.4717, 0.5665]}, {"w": "10)", "b": [0.4802, 0.5537, 0.5055, 0.5665]}, {"w": "1010", "b": [0.6404, 0.5537, 0.6741, 0.5665]}, {"w": "=================================================================", "b": [0.1766, 0.5691, 0.7247, 0.5819]}, {"w": "Total", "b": [0.1766, 0.5845, 0.2187, 0.5974]}, {"w": "params:", "b": [0.2272, 0.5845, 0.2862, 0.5974]}, {"w": "271,346", "b": [0.2946, 0.5845, 0.3537, 0.5974]}, {"w": "Trainable", "b": [0.1766, 0.5999, 0.2525, 0.6128]}, {"w": "params:", "b": [0.2609, 0.5999, 0.3199, 0.6128]}, {"w": "268,978", "b": [0.3284, 0.5999, 0.3874, 0.6128]}, {"w": "Non-trainable", "b": [0.1766, 0.6153, 0.2862, 0.6282]}, {"w": "params:", "b": [0.2946, 0.6153, 0.3537, 0.6282]}, {"w": "2,368", "b": [0.3621, 0.6153, 0.4043, 0.6282]}]}, {"id": "b_4", "type": "paragraph", "text": "Let’s look at the parameters of the first BN layer. Two are trainable (by backprop), and two are not:", "words": [{"w": "Let’s", "b": [0.1428, 0.636, 0.179, 0.6574]}, {"w": "look", "b": [0.1838, 0.636, 0.2207, 0.6574]}, {"w": "at", "b": [0.2255, 0.636, 0.2406, 0.6574]}, {"w": "the", "b": [0.2455, 0.636, 0.2718, 0.6574]}, {"w": "parameters", "b": [0.2766, 0.636, 0.3701, 0.6574]}, {"w": "of", "b": [0.3749, 0.636, 0.3917, 0.6574]}, {"w": "the", "b": [0.3965, 0.636, 0.4229, 0.6574]}, {"w": "first", "b": [0.4277, 0.636, 0.4612, 0.6574]}, {"w": "BN", "b": [0.466, 0.636, 0.4937, 0.6574]}, {"w": "layer.", "b": [0.4986, 0.636, 0.5422, 0.6574]}, {"w": "Two", "b": [0.547, 0.636, 0.5833, 0.6574]}, {"w": "are", "b": [0.5881, 0.636, 0.6138, 0.6574]}, {"w": "trainable", "b": [0.6187, 0.636, 0.6927, 0.6574]}, {"w": "(by", "b": [0.6976, 0.636, 0.7249, 0.6574]}, {"w": "backprop),", "b": [0.7297, 0.636, 0.8208, 0.6574]}, {"w": "and", "b": [0.8256, 0.636, 0.8571, 0.6574]}, {"w": "two", "b": [0.1429, 0.655, 0.1741, 0.6764]}, {"w": "are", "b": [0.1788, 0.655, 0.2046, 0.6764]}, {"w": "not:", "b": [0.2093, 0.655, 0.2424, 0.6764]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> [(var.name, var.trainable) for var in model.layers[1].variables] [('batch_normalization_v2/gamma:0', True), ('batch_normalization_v2/beta:0', True), ('batch_normalization_v2/moving_mean:0', False), ('batch_normalization_v2/moving_variance:0', False)]", "words": [{"w": ">>>", "b": [0.1766, 0.687, 0.2019, 0.6998]}, {"w": "[(var.name,", "b": [0.2103, 0.687, 0.3031, 0.6998]}, {"w": "var.trainable)", "b": [0.3115, 0.687, 0.4296, 0.6998]}, {"w": "for", "b": [0.438, 0.687, 0.4633, 0.6998]}, {"w": "var", "b": [0.4717, 0.687, 0.497, 0.6998]}, {"w": "in", "b": [0.5055, 0.687, 0.5223, 0.6998]}, {"w": "model.layers[1].variables]", "b": [0.5308, 0.687, 0.75, 0.6998]}, {"w": "[('batch_normalization_v2/gamma:0',", "b": [0.1766, 0.7024, 0.4717, 0.7153]}, {"w": "True),", "b": [0.4802, 0.7024, 0.5308, 0.7153]}, {"w": "('batch_normalization_v2/beta:0',", "b": [0.185, 0.7178, 0.4633, 0.7307]}, {"w": "True),", "b": [0.4717, 0.7178, 0.5223, 0.7307]}, {"w": "('batch_normalization_v2/moving_mean:0',", "b": [0.185, 0.7333, 0.5223, 0.7461]}, {"w": "False),", "b": [0.5308, 0.7333, 0.5898, 0.7461]}, {"w": "('batch_normalization_v2/moving_variance:0',", "b": [0.185, 0.7487, 0.556, 0.7615]}, {"w": "False)]", "b": [0.5645, 0.7487, 0.6235, 0.7615]}]}, {"id": "b_6", "type": "paragraph", "text": "Now when you create a BN layer in Keras, it also creates two operations that will be called by Keras at each iteration during training. These operations will update the", "words": [{"w": "Now", "b": [0.1429, 0.7693, 0.1827, 0.7907]}, {"w": "when", "b": [0.1889, 0.7693, 0.2345, 0.7907]}, {"w": "you", "b": [0.2407, 0.7693, 0.272, 0.7907]}, {"w": "create", "b": [0.2781, 0.7693, 0.3275, 0.7907]}, {"w": "a", "b": [0.3336, 0.7693, 0.3428, 0.7907]}, {"w": "BN", "b": [0.349, 0.7693, 0.3767, 0.7907]}, {"w": "layer", "b": [0.3829, 0.7693, 0.4231, 0.7907]}, {"w": "in", "b": [0.4292, 0.7693, 0.4462, 0.7907]}, {"w": "Keras,", "b": [0.4524, 0.7693, 0.504, 0.7907]}, {"w": "it", "b": [0.5102, 0.7693, 0.5221, 0.7907]}, {"w": "also", "b": [0.5283, 0.7693, 0.561, 0.7907]}, {"w": "creates", "b": [0.5672, 0.7693, 0.6242, 0.7907]}, {"w": "two", "b": [0.6303, 0.7693, 0.6616, 0.7907]}, {"w": "operations", "b": [0.6677, 0.7693, 0.7562, 0.7907]}, {"w": "that", "b": [0.7624, 0.7693, 0.795, 0.7907]}, {"w": "will", "b": [0.8011, 0.7693, 0.8315, 0.7907]}, {"w": "be", "b": [0.8377, 0.7693, 0.8571, 0.7907]}, {"w": "called", "b": [0.1429, 0.7884, 0.1912, 0.8098]}, {"w": "by", "b": [0.1991, 0.7884, 0.2193, 0.8098]}, {"w": "Keras", "b": [0.2272, 0.7884, 0.2741, 0.8098]}, {"w": "at", "b": [0.282, 0.7884, 0.2971, 0.8098]}, {"w": "each", "b": [0.305, 0.7884, 0.3429, 0.8098]}, {"w": "iteration", "b": [0.3508, 0.7884, 0.4221, 0.8098]}, {"w": "during", "b": [0.43, 0.7884, 0.4865, 0.8098]}, {"w": "training.", "b": [0.4944, 0.7884, 0.5661, 0.8098]}, {"w": "These", "b": [0.574, 0.7884, 0.6234, 0.8098]}, {"w": "operations", "b": [0.6313, 0.7884, 0.7197, 0.8098]}, {"w": "will", "b": [0.7277, 0.7884, 0.758, 0.8098]}, {"w": "update", "b": [0.766, 0.7884, 0.8229, 0.8098]}, {"w": "the", "b": [0.8308, 0.7884, 0.8571, 0.8098]}]}, {"id": "b_7", "type": "paragraph", "text": "336 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "336", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2746, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 363, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "moving averages. Since we are using the TensorFlow backend, these operations are TensorFlow operations (we will discuss TF operations in Chapter 12).", "words": [{"w": "moving", "b": [0.1429, 0.0791, 0.2069, 0.1005]}, {"w": "averages.", "b": [0.2142, 0.0791, 0.2893, 0.1005]}, {"w": "Since", "b": [0.2966, 0.0791, 0.3411, 0.1005]}, {"w": "we", "b": [0.3483, 0.0791, 0.3715, 0.1005]}, {"w": "are", "b": [0.3787, 0.0791, 0.4044, 0.1005]}, {"w": "using", "b": [0.4117, 0.0791, 0.4571, 0.1005]}, {"w": "the", "b": [0.4644, 0.0791, 0.4907, 0.1005]}, {"w": "TensorFlow", "b": [0.498, 0.0791, 0.5962, 0.1005]}, {"w": "backend,", "b": [0.6035, 0.0791, 0.6783, 0.1005]}, {"w": "these", "b": [0.6856, 0.0791, 0.7284, 0.1005]}, {"w": "operations", "b": [0.7357, 0.0791, 0.8242, 0.1005]}, {"w": "are", "b": [0.8314, 0.0791, 0.8571, 0.1005]}, {"w": "TensorFlow", "b": [0.1429, 0.0981, 0.2411, 0.1195]}, {"w": "operations", "b": [0.2458, 0.0981, 0.3343, 0.1195]}, {"w": "(we", "b": [0.339, 0.0981, 0.3694, 0.1195]}, {"w": "will", "b": [0.3741, 0.0981, 0.4045, 0.1195]}, {"w": "discuss", "b": [0.4092, 0.0981, 0.4686, 0.1195]}, {"w": "TF", "b": [0.4734, 0.0981, 0.4972, 0.1195]}, {"w": "operations", "b": [0.502, 0.0981, 0.5904, 0.1195]}, {"w": "in", "b": [0.5952, 0.0981, 0.6121, 0.1195]}, {"w": "Chapter", "b": [0.6169, 0.0981, 0.6845, 0.1195]}, {"w": "12).", "b": [0.6892, 0.0981, 0.7211, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> model.layers[1].updates [, ]", "words": [{"w": ">>>", "b": [0.1766, 0.1301, 0.2019, 0.1429]}, {"w": "model.layers[1].updates", "b": [0.2103, 0.1301, 0.4043, 0.1429]}, {"w": "[,", "b": [0.4549, 0.1455, 0.5813, 0.1584]}, {"w": "]", "b": [0.4549, 0.1609, 0.5813, 0.1738]}]}, {"id": "b_2", "type": "paragraph", "text": "The authors of the BN paper argued in favor of adding the BN layers before the acti‐ vation functions, rather than after (as we just did). There is some debate about this, as it seems to depend on the task. So that’s one more thing you can experiment with to see which option works best on your dataset. To add the BN layers before the activa‐ tion functions, we must remove the activation function from the hidden layers, and add them as separate layers after the BN layers. Moreover, since a Batch Normaliza‐ tion layer includes one offset parameter per input, you can remove the bias term from the previous layer (just pass use_bias=False when creating it):", "words": [{"w": "The", "b": [0.1428, 0.1816, 0.1757, 0.203]}, {"w": "authors", "b": [0.1813, 0.1816, 0.2446, 0.203]}, {"w": "of", "b": [0.2502, 0.1816, 0.267, 0.203]}, {"w": "the", "b": [0.2726, 0.1816, 0.2989, 0.203]}, {"w": "BN", "b": [0.3045, 0.1816, 0.3322, 0.203]}, {"w": "paper", "b": [0.3378, 0.1816, 0.385, 0.203]}, {"w": "argued", "b": [0.3906, 0.1816, 0.4482, 0.203]}, {"w": "in", "b": [0.4538, 0.1816, 0.4707, 0.203]}, {"w": "favor", "b": [0.4763, 0.1816, 0.5193, 0.203]}, {"w": "of", "b": [0.5249, 0.1816, 0.5417, 0.203]}, {"w": "adding", "b": [0.5473, 0.1816, 0.6052, 0.203]}, {"w": "the", "b": [0.6108, 0.1816, 0.6371, 0.203]}, {"w": "BN", "b": [0.6427, 0.1816, 0.6704, 0.203]}, {"w": "layers", "b": [0.676, 0.1816, 0.7239, 0.203]}, {"w": "before", "b": [0.7295, 0.1816, 0.7823, 0.203]}, {"w": "the", "b": [0.7879, 0.1816, 0.8142, 0.203]}, {"w": "acti‐", "b": [0.8198, 0.1816, 0.8571, 0.203]}, {"w": "vation", "b": [0.1429, 0.2006, 0.1952, 0.222]}, {"w": "functions,", "b": [0.2001, 0.2006, 0.2839, 0.222]}, {"w": "rather", "b": [0.2887, 0.2006, 0.3393, 0.222]}, {"w": "than", "b": [0.3442, 0.2006, 0.3822, 0.222]}, {"w": "after", "b": [0.387, 0.2006, 0.4253, 0.222]}, {"w": "(as", "b": [0.4302, 0.2006, 0.4542, 0.222]}, {"w": "we", "b": [0.459, 0.2006, 0.4822, 0.222]}, {"w": "just", "b": [0.487, 0.2006, 0.5174, 0.222]}, {"w": "did).", "b": [0.5223, 0.2006, 0.5618, 0.222]}, {"w": "There", "b": [0.5667, 0.2006, 0.6161, 0.222]}, {"w": "is", "b": [0.621, 0.2006, 0.6342, 0.222]}, {"w": "some", "b": [0.6391, 0.2006, 0.6833, 0.222]}, {"w": "debate", "b": [0.6881, 0.2006, 0.7425, 0.222]}, {"w": "about", "b": [0.7474, 0.2006, 0.7952, 0.222]}, {"w": "this,", "b": [0.8, 0.2006, 0.8355, 0.222]}, {"w": "as", "b": [0.8404, 0.2006, 0.8571, 0.222]}, {"w": "it", "b": [0.1429, 0.2197, 0.1548, 0.2411]}, {"w": "seems", "b": [0.1607, 0.2197, 0.2108, 0.2411]}, {"w": "to", "b": [0.2167, 0.2197, 0.2337, 0.2411]}, {"w": "depend", "b": [0.2396, 0.2197, 0.3016, 0.2411]}, {"w": "on", "b": [0.3075, 0.2197, 0.3295, 0.2411]}, {"w": "the", "b": [0.3354, 0.2197, 0.3618, 0.2411]}, {"w": "task.", "b": [0.3677, 0.2197, 0.4059, 0.2411]}, {"w": "So", "b": [0.4118, 0.2197, 0.4323, 0.2411]}, {"w": "that’s", "b": [0.4382, 0.2197, 0.4806, 0.2411]}, {"w": "one", "b": [0.4865, 0.2197, 0.5173, 0.2411]}, {"w": "more", "b": [0.5232, 0.2197, 0.5675, 0.2411]}, {"w": "thing", "b": [0.5734, 0.2197, 0.6176, 0.2411]}, {"w": "you", "b": [0.6235, 0.2197, 0.6548, 0.2411]}, {"w": "can", "b": [0.6607, 0.2197, 0.6901, 0.2411]}, {"w": "experiment", "b": [0.696, 0.2197, 0.791, 0.2411]}, {"w": "with", "b": [0.7969, 0.2197, 0.8343, 0.2411]}, {"w": "to", "b": [0.8402, 0.2197, 0.8571, 0.2411]}, {"w": "see", "b": [0.1429, 0.2387, 0.1682, 0.2601]}, {"w": "which", "b": [0.1739, 0.2387, 0.2248, 0.2601]}, {"w": "option", "b": [0.2304, 0.2387, 0.2859, 0.2601]}, {"w": "works", "b": [0.2916, 0.2387, 0.3422, 0.2601]}, {"w": "best", "b": [0.3479, 0.2387, 0.3813, 0.2601]}, {"w": "on", "b": [0.387, 0.2387, 0.409, 0.2601]}, {"w": "your", "b": [0.4146, 0.2387, 0.4536, 0.2601]}, {"w": "dataset.", "b": [0.4593, 0.2387, 0.5221, 0.2601]}, {"w": "To", "b": [0.5278, 0.2387, 0.5492, 0.2601]}, {"w": "add", "b": [0.5549, 0.2387, 0.586, 0.2601]}, {"w": "the", "b": [0.5917, 0.2387, 0.618, 0.2601]}, {"w": "BN", "b": [0.6237, 0.2387, 0.6514, 0.2601]}, {"w": "layers", "b": [0.6571, 0.2387, 0.7049, 0.2601]}, {"w": "before", "b": [0.7106, 0.2387, 0.7634, 0.2601]}, {"w": "the", "b": [0.769, 0.2387, 0.7954, 0.2601]}, {"w": "activa‐", "b": [0.801, 0.2387, 0.8571, 0.2601]}, {"w": "tion", "b": [0.1429, 0.2577, 0.1768, 0.2792]}, {"w": "functions,", "b": [0.1833, 0.2577, 0.2671, 0.2792]}, {"w": "we", "b": [0.2736, 0.2577, 0.2967, 0.2792]}, {"w": "must", "b": [0.3032, 0.2577, 0.345, 0.2792]}, {"w": "remove", "b": [0.3514, 0.2577, 0.4142, 0.2792]}, {"w": "the", "b": [0.4207, 0.2577, 0.447, 0.2792]}, {"w": "activation", "b": [0.4535, 0.2577, 0.5358, 0.2792]}, {"w": "function", "b": [0.5423, 0.2577, 0.6137, 0.2792]}, {"w": "from", "b": [0.6202, 0.2577, 0.6618, 0.2792]}, {"w": "the", "b": [0.6683, 0.2577, 0.6946, 0.2792]}, {"w": "hidden", "b": [0.7011, 0.2577, 0.76, 0.2792]}, {"w": "layers,", "b": [0.7665, 0.2577, 0.8191, 0.2792]}, {"w": "and", "b": [0.8256, 0.2577, 0.8572, 0.2792]}, {"w": "add", "b": [0.1429, 0.2768, 0.174, 0.2982]}, {"w": "them", "b": [0.1803, 0.2768, 0.2237, 0.2982]}, {"w": "as", "b": [0.23, 0.2768, 0.2468, 0.2982]}, {"w": "separate", "b": [0.2531, 0.2768, 0.3214, 0.2982]}, {"w": "layers", "b": [0.3277, 0.2768, 0.3755, 0.2982]}, {"w": "after", "b": [0.3818, 0.2768, 0.4201, 0.2982]}, {"w": "the", "b": [0.4264, 0.2768, 0.4527, 0.2982]}, {"w": "BN", "b": [0.459, 0.2768, 0.4868, 0.2982]}, {"w": "layers.", "b": [0.4931, 0.2768, 0.5457, 0.2982]}, {"w": "Moreover,", "b": [0.552, 0.2768, 0.6375, 0.2982]}, {"w": "since", "b": [0.6438, 0.2768, 0.6861, 0.2982]}, {"w": "a", "b": [0.6924, 0.2768, 0.7015, 0.2982]}, {"w": "Batch", "b": [0.7079, 0.2768, 0.7551, 0.2982]}, {"w": "Normaliza‐", "b": [0.7615, 0.2768, 0.8571, 0.2982]}, {"w": "tion", "b": [0.1429, 0.2958, 0.1768, 0.3173]}, {"w": "layer", "b": [0.1815, 0.2958, 0.2217, 0.3173]}, {"w": "includes", "b": [0.2265, 0.2958, 0.2961, 0.3173]}, {"w": "one", "b": [0.3008, 0.2958, 0.3317, 0.3173]}, {"w": "offset", "b": [0.3364, 0.2958, 0.3822, 0.3173]}, {"w": "parameter", "b": [0.387, 0.2958, 0.4728, 0.3173]}, {"w": "per", "b": [0.4775, 0.2958, 0.505, 0.3173]}, {"w": "input,", "b": [0.5097, 0.2958, 0.5594, 0.3173]}, {"w": "you", "b": [0.5641, 0.2958, 0.5954, 0.3173]}, {"w": "can", "b": [0.6001, 0.2958, 0.6294, 0.3173]}, {"w": "remove", "b": [0.6342, 0.2958, 0.6969, 0.3173]}, {"w": "the", "b": [0.7017, 0.2958, 0.728, 0.3173]}, {"w": "bias", "b": [0.7327, 0.2958, 0.7657, 0.3173]}, {"w": "term", "b": [0.7704, 0.2958, 0.8104, 0.3173]}, {"w": "from", "b": [0.8151, 0.2958, 0.8567, 0.3173]}, {"w": "the", "b": [0.1429, 0.3158, 0.1692, 0.3372]}, {"w": "previous", "b": [0.1739, 0.3158, 0.246, 0.3372]}, {"w": "layer", "b": [0.2507, 0.3158, 0.2909, 0.3372]}, {"w": "(just", "b": [0.2956, 0.3158, 0.3332, 0.3372]}, {"w": "pass", "b": [0.338, 0.3158, 0.3733, 0.3372]}, {"w": "use_bias=False", "b": [0.378, 0.319, 0.5166, 0.334]}, {"w": "when", "b": [0.5213, 0.3158, 0.567, 0.3372]}, {"w": "creating", "b": [0.5717, 0.3158, 0.6389, 0.3372]}, {"w": "it):", "b": [0.6436, 0.3158, 0.6675, 0.3372]}]}, {"id": "b_3", "type": "paragraph", "text": "model = keras.models.Sequential([ keras.layers.Flatten(input_shape=[28, 28]), keras.layers.BatchNormalization(), keras.layers.Dense(300, kernel_initializer=\"he_normal\", use_bias=False), keras.layers.BatchNormalization(), keras.layers.Activation(\"elu\"), keras.layers.Dense(100, kernel_initializer=\"he_normal\", use_bias=False), keras.layers.Activation(\"elu\"), keras.layers.BatchNormalization(), keras.layers.Dense(10, activation=\"softmax\") ])", "words": [{"w": "model", "b": [0.1766, 0.3478, 0.2187, 0.3606]}, {"w": "=", "b": [0.2272, 0.3478, 0.2356, 0.3606]}, {"w": "keras.models.Sequential([", "b": [0.244, 0.3478, 0.4549, 0.3606]}, {"w": "keras.layers.Flatten(input_shape=[28,", "b": [0.2103, 0.3632, 0.5223, 0.376]}, {"w": "28]),", "b": [0.5307, 0.3632, 0.5729, 0.376]}, {"w": "keras.layers.BatchNormalization(),", "b": [0.2103, 0.3786, 0.497, 0.3914]}, {"w": "keras.layers.Dense(300,", "b": [0.2103, 0.394, 0.4043, 0.4069]}, {"w": "kernel_initializer=\"he_normal\",", "b": [0.4127, 0.394, 0.6741, 0.4069]}, {"w": "use_bias=False),", "b": [0.6825, 0.394, 0.8175, 0.4069]}, {"w": "keras.layers.BatchNormalization(),", "b": [0.2103, 0.4094, 0.497, 0.4223]}, {"w": "keras.layers.Activation(\"elu\"),", "b": [0.2103, 0.4249, 0.4717, 0.4377]}, {"w": "keras.layers.Dense(100,", "b": [0.2103, 0.4403, 0.4043, 0.4531]}, {"w": "kernel_initializer=\"he_normal\",", "b": [0.4127, 0.4403, 0.6741, 0.4531]}, {"w": "use_bias=False),", "b": [0.6825, 0.4403, 0.8175, 0.4531]}, {"w": "keras.layers.Activation(\"elu\"),", "b": [0.2103, 0.4557, 0.4717, 0.4685]}, {"w": "keras.layers.BatchNormalization(),", "b": [0.2103, 0.4711, 0.497, 0.484]}, {"w": "keras.layers.Dense(10,", "b": [0.2103, 0.4865, 0.3958, 0.4994]}, {"w": "activation=\"softmax\")", "b": [0.4043, 0.4865, 0.5813, 0.4994]}, {"w": "])", "b": [0.1766, 0.502, 0.1934, 0.5148]}]}, {"id": "b_4", "type": "paragraph", "text": "The BatchNormalization class has quite a few hyperparameters you can tweak. The defaults will usually be fine, but you may occasionally need to tweak the momentum. This hyperparameter is used when updating the exponential moving averages: given a new value v (i.e., a new vector of input means or standard deviations computed over the current batch), the running average � is updated using the following equation:", "words": [{"w": "The", "b": [0.1429, 0.5235, 0.1757, 0.5449]}, {"w": "BatchNormalization", "b": [0.1818, 0.5267, 0.36, 0.5417]}, {"w": "class", "b": [0.3661, 0.5235, 0.4046, 0.5449]}, {"w": "has", "b": [0.4108, 0.5235, 0.4387, 0.5449]}, {"w": "quite", "b": [0.4449, 0.5235, 0.4874, 0.5449]}, {"w": "a", "b": [0.4935, 0.5235, 0.5027, 0.5449]}, {"w": "few", "b": [0.5088, 0.5235, 0.5381, 0.5449]}, {"w": "hyperparameters", "b": [0.5443, 0.5235, 0.6854, 0.5449]}, {"w": "you", "b": [0.6916, 0.5235, 0.7228, 0.5449]}, {"w": "can", "b": [0.729, 0.5235, 0.7583, 0.5449]}, {"w": "tweak.", "b": [0.7645, 0.5235, 0.8182, 0.5449]}, {"w": "The", "b": [0.8243, 0.5235, 0.8572, 0.5449]}, {"w": "defaults", "b": [0.1429, 0.5434, 0.208, 0.5648]}, {"w": "will", "b": [0.2149, 0.5434, 0.2453, 0.5648]}, {"w": "usually", "b": [0.2523, 0.5434, 0.3113, 0.5648]}, {"w": "be", "b": [0.3183, 0.5434, 0.3378, 0.5648]}, {"w": "fine,", "b": [0.3447, 0.5434, 0.3815, 0.5648]}, {"w": "but", "b": [0.3885, 0.5434, 0.4165, 0.5648]}, {"w": "you", "b": [0.4234, 0.5434, 0.4547, 0.5648]}, {"w": "may", "b": [0.4617, 0.5434, 0.4971, 0.5648]}, {"w": "occasionally", "b": [0.5041, 0.5434, 0.606, 0.5648]}, {"w": "need", "b": [0.6129, 0.5434, 0.653, 0.5648]}, {"w": "to", "b": [0.66, 0.5434, 0.677, 0.5648]}, {"w": "tweak", "b": [0.684, 0.5434, 0.7329, 0.5648]}, {"w": "the", "b": [0.7399, 0.5434, 0.7662, 0.5648]}, {"w": "momentum.", "b": [0.7732, 0.5434, 0.8571, 0.5648]}, {"w": "This", "b": [0.1429, 0.5625, 0.1801, 0.5839]}, {"w": "hyperparameter", "b": [0.1849, 0.5625, 0.3184, 0.5839]}, {"w": "is", "b": [0.3233, 0.5625, 0.3365, 0.5839]}, {"w": "used", "b": [0.3414, 0.5625, 0.38, 0.5839]}, {"w": "when", "b": [0.3848, 0.5625, 0.4305, 0.5839]}, {"w": "updating", "b": [0.4354, 0.5625, 0.5102, 0.5839]}, {"w": "the", "b": [0.515, 0.5625, 0.5414, 0.5839]}, {"w": "exponential", "b": [0.5462, 0.5625, 0.6441, 0.5839]}, {"w": "moving", "b": [0.6489, 0.5625, 0.713, 0.5839]}, {"w": "averages:", "b": [0.7179, 0.5625, 0.793, 0.5839]}, {"w": "given", "b": [0.7979, 0.5625, 0.8431, 0.5839]}, {"w": "a", "b": [0.848, 0.5625, 0.8571, 0.5839]}, {"w": "new", "b": [0.1428, 0.5815, 0.1774, 0.6029]}, {"w": "value", "b": [0.1831, 0.5815, 0.2271, 0.6029]}, {"w": "v", "b": [0.2328, 0.581, 0.2425, 0.6029]}, {"w": "(i.e.,", "b": [0.2483, 0.5815, 0.2841, 0.6029]}, {"w": "a", "b": [0.2899, 0.5815, 0.299, 0.6029]}, {"w": "new", "b": [0.3048, 0.5815, 0.3393, 0.6029]}, {"w": "vector", "b": [0.345, 0.5815, 0.3971, 0.6029]}, {"w": "of", "b": [0.4028, 0.5815, 0.4196, 0.6029]}, {"w": "input", "b": [0.4253, 0.5815, 0.4702, 0.6029]}, {"w": "means", "b": [0.476, 0.5815, 0.5301, 0.6029]}, {"w": "or", "b": [0.5358, 0.5815, 0.5542, 0.6029]}, {"w": "standard", "b": [0.5599, 0.5815, 0.6333, 0.6029]}, {"w": "deviations", "b": [0.6391, 0.5815, 0.7245, 0.6029]}, {"w": "computed", "b": [0.7302, 0.5815, 0.8145, 0.6029]}, {"w": "over", "b": [0.8203, 0.5815, 0.8571, 0.6029]}, {"w": "the", "b": [0.1429, 0.6006, 0.1692, 0.622]}, {"w": "current", "b": [0.1739, 0.6006, 0.2355, 0.622]}, {"w": "batch),", "b": [0.2402, 0.6006, 0.2978, 0.622]}, {"w": "the", "b": [0.3025, 0.6006, 0.3288, 0.622]}, {"w": "running", "b": [0.3336, 0.6006, 0.4019, 0.622]}, {"w": "average", "b": [0.4066, 0.6006, 0.4694, 0.622]}, {"w": "�", "b": [0.4744, 0.6038, 0.4855, 0.6197]}, {"w": "is", "b": [0.4906, 0.6006, 0.5038, 0.622]}, {"w": "updated", "b": [0.5086, 0.6006, 0.5765, 0.622]}, {"w": "using", "b": [0.5812, 0.6006, 0.6267, 0.622]}, {"w": "the", "b": [0.6314, 0.6006, 0.6577, 0.622]}, {"w": "following", "b": [0.6625, 0.6006, 0.7414, 0.622]}, {"w": "equation:", "b": [0.7461, 0.6006, 0.8242, 0.622]}]}, {"id": "b_5", "type": "equation", "text": "v v × momentum + v × 1 −momentum", "words": [{"w": "v", "b": [0.1736, 0.6408, 0.1828, 0.6617]}, {"w": "v", "b": [0.2132, 0.6408, 0.2224, 0.6617]}, {"w": "×", "b": [0.2279, 0.6413, 0.2394, 0.6617]}, {"w": "momentum", "b": [0.2438, 0.6413, 0.3386, 0.6617]}, {"w": "+", "b": [0.343, 0.6413, 0.3545, 0.6617]}, {"w": "v", "b": [0.359, 0.6408, 0.3682, 0.6617]}, {"w": "×", "b": [0.3729, 0.6413, 0.3844, 0.6617]}, {"w": "1", "b": [0.3957, 0.6413, 0.4052, 0.6617]}, {"w": "−momentum", "b": [0.4096, 0.6413, 0.5203, 0.6617]}]}, {"id": "b_6", "type": "paragraph", "text": "A good momentum value is typically close to 1—for example, 0.9, 0.99, or 0.999 (you want more 9s for larger datasets and smaller mini-batches).", "words": [{"w": "A", "b": [0.1428, 0.6805, 0.1572, 0.7019]}, {"w": "good", "b": [0.1626, 0.6805, 0.2046, 0.7019]}, {"w": "momentum", "b": [0.2099, 0.6805, 0.3089, 0.7019]}, {"w": "value", "b": [0.3143, 0.6805, 0.3582, 0.7019]}, {"w": "is", "b": [0.3635, 0.6805, 0.3768, 0.7019]}, {"w": "typically", "b": [0.3821, 0.6805, 0.4526, 0.7019]}, {"w": "close", "b": [0.4579, 0.6805, 0.4991, 0.7019]}, {"w": "to", "b": [0.5044, 0.6805, 0.5214, 0.7019]}, {"w": "1—for", "b": [0.5267, 0.6805, 0.5804, 0.7019]}, {"w": "example,", "b": [0.5857, 0.6805, 0.66, 0.7019]}, {"w": "0.9,", "b": [0.6653, 0.6805, 0.6948, 0.7019]}, {"w": "0.99,", "b": [0.7001, 0.6805, 0.7396, 0.7019]}, {"w": "or", "b": [0.745, 0.6805, 0.7633, 0.7019]}, {"w": "0.999", "b": [0.7686, 0.6805, 0.8134, 0.7019]}, {"w": "(you", "b": [0.8187, 0.6805, 0.8571, 0.7019]}, {"w": "want", "b": [0.1429, 0.6996, 0.1836, 0.721]}, {"w": "more", "b": [0.1884, 0.6996, 0.2326, 0.721]}, {"w": "9s", "b": [0.2374, 0.6996, 0.255, 0.721]}, {"w": "for", "b": [0.2597, 0.6996, 0.2843, 0.721]}, {"w": "larger", "b": [0.289, 0.6996, 0.3375, 0.721]}, {"w": "datasets", "b": [0.3422, 0.6996, 0.4079, 0.721]}, {"w": "and", "b": [0.4127, 0.6996, 0.4442, 0.721]}, {"w": "smaller", "b": [0.4489, 0.6996, 0.5099, 0.721]}, {"w": "mini-batches).", "b": [0.5147, 0.6996, 0.6358, 0.721]}]}, {"id": "b_7", "type": "paragraph", "text": "Another important hyperparameter is axis: it determines which axis should be nor‐ malized. It defaults to –1, meaning that by default it will normalize the last axis (using the means and standard deviations computed across the other axes). For example, when the input batch is 2D (i.e., the batch shape is [batch size, features]), this means that each input feature will be normalized based on the mean and standard deviation computed across all the instances in the batch. For example, the first BN layer in the previous code example will independently normalize (and rescale and shift) each of the 784 input features. However, if we move the first BN layer before the Flatten", "words": [{"w": "Another", "b": [0.1429, 0.7286, 0.2133, 0.75]}, {"w": "important", "b": [0.2194, 0.7286, 0.3038, 0.75]}, {"w": "hyperparameter", "b": [0.3098, 0.7286, 0.4433, 0.75]}, {"w": "is", "b": [0.4494, 0.7286, 0.4626, 0.75]}, {"w": "axis:", "b": [0.4687, 0.7286, 0.513, 0.75]}, {"w": "it", "b": [0.5191, 0.7286, 0.531, 0.75]}, {"w": "determines", "b": [0.5371, 0.7286, 0.6304, 0.75]}, {"w": "which", "b": [0.6365, 0.7286, 0.6874, 0.75]}, {"w": "axis", "b": [0.6934, 0.7286, 0.7256, 0.75]}, {"w": "should", "b": [0.7317, 0.7286, 0.7884, 0.75]}, {"w": "be", "b": [0.7945, 0.7286, 0.8139, 0.75]}, {"w": "nor‐", "b": [0.82, 0.7286, 0.8571, 0.75]}, {"w": "malized.", "b": [0.1429, 0.7476, 0.2133, 0.769]}, {"w": "It", "b": [0.2182, 0.7476, 0.2308, 0.769]}, {"w": "defaults", "b": [0.2358, 0.7476, 0.3009, 0.769]}, {"w": "to", "b": [0.3058, 0.7476, 0.3228, 0.769]}, {"w": "–1,", "b": [0.3277, 0.7476, 0.3533, 0.769]}, {"w": "meaning", "b": [0.3582, 0.7476, 0.4314, 0.769]}, {"w": "that", "b": [0.4363, 0.7476, 0.4689, 0.769]}, {"w": "by", "b": [0.4738, 0.7476, 0.494, 0.769]}, {"w": "default", "b": [0.4989, 0.7476, 0.5563, 0.769]}, {"w": "it", "b": [0.5613, 0.7476, 0.5732, 0.769]}, {"w": "will", "b": [0.5781, 0.7476, 0.6085, 0.769]}, {"w": "normalize", "b": [0.6134, 0.7476, 0.6979, 0.769]}, {"w": "the", "b": [0.7028, 0.7476, 0.7291, 0.769]}, {"w": "last", "b": [0.734, 0.7476, 0.7624, 0.769]}, {"w": "axis", "b": [0.7674, 0.7476, 0.7996, 0.769]}, {"w": "(using", "b": [0.8045, 0.7476, 0.8571, 0.769]}, {"w": "the", "b": [0.1429, 0.7667, 0.1692, 0.7881]}, {"w": "means", "b": [0.1772, 0.7667, 0.2313, 0.7881]}, {"w": "and", "b": [0.2393, 0.7667, 0.2709, 0.7881]}, {"w": "standard", "b": [0.2789, 0.7667, 0.3523, 0.7881]}, {"w": "deviations", "b": [0.3604, 0.7667, 0.4458, 0.7881]}, {"w": "computed", "b": [0.4538, 0.7667, 0.5381, 0.7881]}, {"w": "across", "b": [0.5461, 0.7667, 0.5977, 0.7881]}, {"w": "the", "b": [0.6058, 0.7667, 0.6321, 0.7881]}, {"w": "other", "b": [0.6401, 0.7665, 0.6823, 0.7881]}, {"w": "axes).", "b": [0.6904, 0.7667, 0.7378, 0.7881]}, {"w": "For", "b": [0.7458, 0.7667, 0.7748, 0.7881]}, {"w": "example,", "b": [0.7828, 0.7667, 0.8571, 0.7881]}, {"w": "when", "b": [0.1429, 0.7857, 0.1885, 0.8071]}, {"w": "the", "b": [0.1943, 0.7857, 0.2207, 0.8071]}, {"w": "input", "b": [0.2265, 0.7857, 0.2714, 0.8071]}, {"w": "batch", "b": [0.2772, 0.7857, 0.3228, 0.8071]}, {"w": "is", "b": [0.3286, 0.7857, 0.3418, 0.8071]}, {"w": "2D", "b": [0.3476, 0.7857, 0.373, 0.8071]}, {"w": "(i.e.,", "b": [0.3788, 0.7857, 0.4147, 0.8071]}, {"w": "the", "b": [0.4205, 0.7857, 0.4468, 0.8071]}, {"w": "batch", "b": [0.4526, 0.7857, 0.4982, 0.8071]}, {"w": "shape", "b": [0.504, 0.7857, 0.5513, 0.8071]}, {"w": "is", "b": [0.5571, 0.7857, 0.5704, 0.8071]}, {"w": "[batch", "b": [0.5762, 0.7857, 0.629, 0.8071]}, {"w": "size,", "b": [0.6348, 0.7857, 0.6704, 0.8071]}, {"w": "features]),", "b": [0.6762, 0.7857, 0.7607, 0.8071]}, {"w": "this", "b": [0.7665, 0.7857, 0.7972, 0.8071]}, {"w": "means", "b": [0.803, 0.7857, 0.8572, 0.8071]}, {"w": "that", "b": [0.1429, 0.8048, 0.1754, 0.8262]}, {"w": "each", "b": [0.1809, 0.8048, 0.2188, 0.8262]}, {"w": "input", "b": [0.2243, 0.8048, 0.2692, 0.8262]}, {"w": "feature", "b": [0.2747, 0.8048, 0.3325, 0.8262]}, {"w": "will", "b": [0.3379, 0.8048, 0.3683, 0.8262]}, {"w": "be", "b": [0.3738, 0.8048, 0.3932, 0.8262]}, {"w": "normalized", "b": [0.3987, 0.8048, 0.4941, 0.8262]}, {"w": "based", "b": [0.4996, 0.8048, 0.5468, 0.8262]}, {"w": "on", "b": [0.5523, 0.8048, 0.5743, 0.8262]}, {"w": "the", "b": [0.5797, 0.8048, 0.6061, 0.8262]}, {"w": "mean", "b": [0.6115, 0.8048, 0.658, 0.8262]}, {"w": "and", "b": [0.6635, 0.8048, 0.695, 0.8262]}, {"w": "standard", "b": [0.7005, 0.8048, 0.7739, 0.8262]}, {"w": "deviation", "b": [0.7794, 0.8048, 0.8571, 0.8262]}, {"w": "computed", "b": [0.1429, 0.8238, 0.2271, 0.8452]}, {"w": "across", "b": [0.233, 0.8238, 0.2846, 0.8452]}, {"w": "all", "b": [0.2904, 0.8238, 0.3101, 0.8452]}, {"w": "the", "b": [0.3159, 0.8238, 0.3423, 0.8452]}, {"w": "instances", "b": [0.3481, 0.8238, 0.4249, 0.8452]}, {"w": "in", "b": [0.4308, 0.8238, 0.4478, 0.8452]}, {"w": "the", "b": [0.4536, 0.8238, 0.4799, 0.8452]}, {"w": "batch.", "b": [0.4858, 0.8238, 0.5361, 0.8452]}, {"w": "For", "b": [0.542, 0.8238, 0.571, 0.8452]}, {"w": "example,", "b": [0.5768, 0.8238, 0.6511, 0.8452]}, {"w": "the", "b": [0.6569, 0.8238, 0.6833, 0.8452]}, {"w": "first", "b": [0.6891, 0.8238, 0.7226, 0.8452]}, {"w": "BN", "b": [0.7284, 0.8238, 0.7561, 0.8452]}, {"w": "layer", "b": [0.762, 0.8238, 0.8022, 0.8452]}, {"w": "in", "b": [0.808, 0.8238, 0.825, 0.8452]}, {"w": "the", "b": [0.8308, 0.8238, 0.8571, 0.8452]}, {"w": "previous", "b": [0.1429, 0.8429, 0.2149, 0.8643]}, {"w": "code", "b": [0.2216, 0.8429, 0.2609, 0.8643]}, {"w": "example", "b": [0.2675, 0.8429, 0.337, 0.8643]}, {"w": "will", "b": [0.3437, 0.8429, 0.3741, 0.8643]}, {"w": "independently", "b": [0.3807, 0.8429, 0.5008, 0.8643]}, {"w": "normalize", "b": [0.5074, 0.8429, 0.5918, 0.8643]}, {"w": "(and", "b": [0.5985, 0.8429, 0.6372, 0.8643]}, {"w": "rescale", "b": [0.6439, 0.8429, 0.7002, 0.8643]}, {"w": "and", "b": [0.7068, 0.8429, 0.7384, 0.8643]}, {"w": "shift)", "b": [0.745, 0.8429, 0.7891, 0.8643]}, {"w": "each", "b": [0.7958, 0.8429, 0.8337, 0.8643]}, {"w": "of", "b": [0.8403, 0.8429, 0.8571, 0.8643]}, {"w": "the", "b": [0.1429, 0.8628, 0.1692, 0.8842]}, {"w": "784", "b": [0.1768, 0.8628, 0.2068, 0.8842]}, {"w": "input", "b": [0.2145, 0.8628, 0.2594, 0.8842]}, {"w": "features.", "b": [0.267, 0.8628, 0.3372, 0.8842]}, {"w": "However,", "b": [0.3448, 0.8628, 0.4237, 0.8842]}, {"w": "if", "b": [0.4313, 0.8628, 0.443, 0.8842]}, {"w": "we", "b": [0.4507, 0.8628, 0.4738, 0.8842]}, {"w": "move", "b": [0.4814, 0.8628, 0.5276, 0.8842]}, {"w": "the", "b": [0.5352, 0.8628, 0.5616, 0.8842]}, {"w": "first", "b": [0.5692, 0.8628, 0.6027, 0.8842]}, {"w": "BN", "b": [0.6103, 0.8628, 0.638, 0.8842]}, {"w": "layer", "b": [0.6457, 0.8628, 0.6858, 0.8842]}, {"w": "before", "b": [0.6935, 0.8628, 0.7463, 0.8842]}, {"w": "the", "b": [0.7539, 0.8628, 0.7803, 0.8842]}, {"w": "Flatten", "b": [0.7879, 0.866, 0.8571, 0.8811]}]}, {"id": "b_8", "type": "equation", "text": "Vanishing/Exploding Gradients Problems | 337", "words": [{"w": "Vanishing/Exploding", "b": [0.5559, 0.9225, 0.678, 0.9388]}, {"w": "Gradients", "b": [0.6808, 0.9225, 0.7376, 0.9388]}, {"w": "Problems", "b": [0.7404, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "337", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 364, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "10 “Fixup Initialization: Residual Learning Without Normalization,” Hongyi Zhang, Yann N. Dauphin, Tengyu Ma (2019).", "words": [{"w": "10", "b": [0.1385, 0.8416, 0.1518, 0.8559]}, {"w": "“Fixup", "b": [0.1587, 0.8401, 0.2019, 0.8565]}, {"w": "Initialization:", "b": [0.2055, 0.8401, 0.291, 0.8565]}, {"w": "Residual", "b": [0.2947, 0.8401, 0.3491, 0.8565]}, {"w": "Learning", "b": [0.3527, 0.8401, 0.4099, 0.8565]}, {"w": "Without", "b": [0.4135, 0.8401, 0.4672, 0.8565]}, {"w": "Normalization,”", "b": [0.4708, 0.8401, 0.5714, 0.8565]}, {"w": "Hongyi", "b": [0.575, 0.8401, 0.6229, 0.8565]}, {"w": "Zhang,", "b": [0.6265, 0.8401, 0.6713, 0.8565]}, {"w": "Yann", "b": [0.6749, 0.8401, 0.7075, 0.8565]}, {"w": "N.", "b": [0.7111, 0.8401, 0.7265, 0.8565]}, {"w": "Dauphin,", "b": [0.7301, 0.8401, 0.7902, 0.8565]}, {"w": "Tengyu", "b": [0.7938, 0.8401, 0.841, 0.8565]}, {"w": "Ma", "b": [0.1587, 0.8553, 0.1796, 0.8716]}, {"w": "(2019).", "b": [0.1832, 0.8553, 0.2283, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "11 “On the difficulty of training recurrent neural networks,” R. Pascanu et al. (2013).", "words": [{"w": "11", "b": [0.1384, 0.8764, 0.1518, 0.8907]}, {"w": "“On", "b": [0.1587, 0.8749, 0.185, 0.8912]}, {"w": "the", "b": [0.1886, 0.8749, 0.2087, 0.8912]}, {"w": "difficulty", "b": [0.2123, 0.8749, 0.2699, 0.8912]}, {"w": "of", "b": [0.2735, 0.8749, 0.2863, 0.8912]}, {"w": "training", "b": [0.2899, 0.8749, 0.3409, 0.8912]}, {"w": "recurrent", "b": [0.3445, 0.8749, 0.404, 0.8912]}, {"w": "neural", "b": [0.4076, 0.8749, 0.4483, 0.8912]}, {"w": "networks,”", "b": [0.4519, 0.8749, 0.5185, 0.8912]}, {"w": "R.", "b": [0.5221, 0.8749, 0.5356, 0.8912]}, {"w": "Pascanu", "b": [0.5392, 0.8749, 0.5911, 0.8912]}, {"w": "et", "b": [0.5947, 0.8749, 0.6063, 0.8912]}, {"w": "al.", "b": [0.6099, 0.8749, 0.6245, 0.8912]}, {"w": "(2013).", "b": [0.6281, 0.8749, 0.6732, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "layer, then the input batches will be 3D, with shape [batch size, height, width], there‐ fore the BN layer will compute 28 means and 28 standard deviations (one per column of pixels, computed across all instances in the batch, and all rows in the column), and it will normalize all pixels in a given column using the same mean and standard devi‐ ation. There will also be just 28 scale parameters and 28 shift parameters. If instead you still want to treat each of the 784 pixels independently, then you should set axis=[1, 2].", "words": [{"w": "layer,", "b": [0.1429, 0.0791, 0.1865, 0.1005]}, {"w": "then", "b": [0.1922, 0.0791, 0.2299, 0.1005]}, {"w": "the", "b": [0.2356, 0.0791, 0.2619, 0.1005]}, {"w": "input", "b": [0.2676, 0.0791, 0.3125, 0.1005]}, {"w": "batches", "b": [0.3182, 0.0791, 0.3804, 0.1005]}, {"w": "will", "b": [0.3861, 0.0791, 0.4165, 0.1005]}, {"w": "be", "b": [0.4222, 0.0791, 0.4416, 0.1005]}, {"w": "3D,", "b": [0.4473, 0.0791, 0.4765, 0.1005]}, {"w": "with", "b": [0.4822, 0.0791, 0.5195, 0.1005]}, {"w": "shape", "b": [0.5252, 0.0791, 0.5725, 0.1005]}, {"w": "[batch", "b": [0.5782, 0.0791, 0.631, 0.1005]}, {"w": "size,", "b": [0.6367, 0.0791, 0.6723, 0.1005]}, {"w": "height,", "b": [0.678, 0.0791, 0.7352, 0.1005]}, {"w": "width],", "b": [0.7408, 0.0791, 0.8011, 0.1005]}, {"w": "there‐", "b": [0.8068, 0.0791, 0.8571, 0.1005]}, {"w": "fore", "b": [0.1429, 0.0981, 0.1762, 0.1195]}, {"w": "the", "b": [0.1811, 0.0981, 0.2075, 0.1195]}, {"w": "BN", "b": [0.2124, 0.0981, 0.2401, 0.1195]}, {"w": "layer", "b": [0.245, 0.0981, 0.2852, 0.1195]}, {"w": "will", "b": [0.2901, 0.0981, 0.3205, 0.1195]}, {"w": "compute", "b": [0.3254, 0.0981, 0.3987, 0.1195]}, {"w": "28", "b": [0.4036, 0.0981, 0.4236, 0.1195]}, {"w": "means", "b": [0.4285, 0.0981, 0.4826, 0.1195]}, {"w": "and", "b": [0.4875, 0.0981, 0.519, 0.1195]}, {"w": "28", "b": [0.524, 0.0981, 0.544, 0.1195]}, {"w": "standard", "b": [0.5489, 0.0981, 0.6223, 0.1195]}, {"w": "deviations", "b": [0.6272, 0.0981, 0.7126, 0.1195]}, {"w": "(one", "b": [0.7175, 0.0981, 0.7556, 0.1195]}, {"w": "per", "b": [0.7605, 0.0981, 0.788, 0.1195]}, {"w": "column", "b": [0.7929, 0.0981, 0.8571, 0.1195]}, {"w": "of", "b": [0.1429, 0.1172, 0.1596, 0.1386]}, {"w": "pixels,", "b": [0.1647, 0.1172, 0.2176, 0.1386]}, {"w": "computed", "b": [0.2226, 0.1172, 0.3069, 0.1386]}, {"w": "across", "b": [0.312, 0.1172, 0.3636, 0.1386]}, {"w": "all", "b": [0.3687, 0.1172, 0.3883, 0.1386]}, {"w": "instances", "b": [0.3934, 0.1172, 0.4702, 0.1386]}, {"w": "in", "b": [0.4753, 0.1172, 0.4923, 0.1386]}, {"w": "the", "b": [0.4974, 0.1172, 0.5237, 0.1386]}, {"w": "batch,", "b": [0.5288, 0.1172, 0.5791, 0.1386]}, {"w": "and", "b": [0.5842, 0.1172, 0.6157, 0.1386]}, {"w": "all", "b": [0.6208, 0.1172, 0.6405, 0.1386]}, {"w": "rows", "b": [0.6456, 0.1172, 0.6858, 0.1386]}, {"w": "in", "b": [0.6909, 0.1172, 0.7079, 0.1386]}, {"w": "the", "b": [0.7129, 0.1172, 0.7393, 0.1386]}, {"w": "column),", "b": [0.7443, 0.1172, 0.8205, 0.1386]}, {"w": "and", "b": [0.8256, 0.1172, 0.8571, 0.1386]}, {"w": "it", "b": [0.1429, 0.1362, 0.1548, 0.1576]}, {"w": "will", "b": [0.1599, 0.1362, 0.1902, 0.1576]}, {"w": "normalize", "b": [0.1953, 0.1362, 0.2797, 0.1576]}, {"w": "all", "b": [0.2848, 0.1362, 0.3045, 0.1576]}, {"w": "pixels", "b": [0.3095, 0.1362, 0.3576, 0.1576]}, {"w": "in", "b": [0.3627, 0.1362, 0.3796, 0.1576]}, {"w": "a", "b": [0.3847, 0.1362, 0.3938, 0.1576]}, {"w": "given", "b": [0.3989, 0.1362, 0.4441, 0.1576]}, {"w": "column", "b": [0.4492, 0.1362, 0.5134, 0.1576]}, {"w": "using", "b": [0.5184, 0.1362, 0.5639, 0.1576]}, {"w": "the", "b": [0.5689, 0.1362, 0.5953, 0.1576]}, {"w": "same", "b": [0.6003, 0.1362, 0.643, 0.1576]}, {"w": "mean", "b": [0.6481, 0.1362, 0.6945, 0.1576]}, {"w": "and", "b": [0.6996, 0.1362, 0.7311, 0.1576]}, {"w": "standard", "b": [0.7362, 0.1362, 0.8096, 0.1576]}, {"w": "devi‐", "b": [0.8147, 0.1362, 0.8572, 0.1576]}, {"w": "ation.", "b": [0.1429, 0.1553, 0.1903, 0.1767]}, {"w": "There", "b": [0.1969, 0.1553, 0.2463, 0.1767]}, {"w": "will", "b": [0.2528, 0.1553, 0.2832, 0.1767]}, {"w": "also", "b": [0.2897, 0.1553, 0.3224, 0.1767]}, {"w": "be", "b": [0.329, 0.1553, 0.3484, 0.1767]}, {"w": "just", "b": [0.3549, 0.1553, 0.3853, 0.1767]}, {"w": "28", "b": [0.3919, 0.1553, 0.4119, 0.1767]}, {"w": "scale", "b": [0.4184, 0.1553, 0.4581, 0.1767]}, {"w": "parameters", "b": [0.4647, 0.1553, 0.5581, 0.1767]}, {"w": "and", "b": [0.5646, 0.1553, 0.5962, 0.1767]}, {"w": "28", "b": [0.6027, 0.1553, 0.6227, 0.1767]}, {"w": "shift", "b": [0.6292, 0.1553, 0.6661, 0.1767]}, {"w": "parameters.", "b": [0.6726, 0.1553, 0.7708, 0.1767]}, {"w": "If", "b": [0.7774, 0.1553, 0.7906, 0.1767]}, {"w": "instead", "b": [0.7972, 0.1553, 0.8571, 0.1767]}, {"w": "you", "b": [0.1429, 0.1743, 0.1741, 0.1957]}, {"w": "still", "b": [0.1831, 0.1743, 0.2132, 0.1957]}, {"w": "want", "b": [0.2222, 0.1743, 0.263, 0.1957]}, {"w": "to", "b": [0.272, 0.1743, 0.289, 0.1957]}, {"w": "treat", "b": [0.298, 0.1743, 0.3361, 0.1957]}, {"w": "each", "b": [0.3451, 0.1743, 0.383, 0.1957]}, {"w": "of", "b": [0.392, 0.1743, 0.4088, 0.1957]}, {"w": "the", "b": [0.4178, 0.1743, 0.4441, 0.1957]}, {"w": "784", "b": [0.4532, 0.1743, 0.4832, 0.1957]}, {"w": "pixels", "b": [0.4922, 0.1743, 0.5403, 0.1957]}, {"w": "independently,", "b": [0.5493, 0.1743, 0.6725, 0.1957]}, {"w": "then", "b": [0.6816, 0.1743, 0.7193, 0.1957]}, {"w": "you", "b": [0.7283, 0.1743, 0.7595, 0.1957]}, {"w": "should", "b": [0.7685, 0.1743, 0.8253, 0.1957]}, {"w": "set", "b": [0.8343, 0.1743, 0.8571, 0.1957]}, {"w": "axis=[1,", "b": [0.1429, 0.1974, 0.222, 0.2125]}, {"w": "2].", "b": [0.2319, 0.1942, 0.2565, 0.2157]}]}, {"id": "b_3", "type": "paragraph", "text": "Notice that the BN layer does not perform the same computation during training and after training: it uses batch statistics during training, and the “final” statistics after training (i.e., the final value of the moving averages). Let’s take a peek at the source code of this class to see how this is handled:", "words": [{"w": "Notice", "b": [0.1429, 0.2224, 0.198, 0.2438]}, {"w": "that", "b": [0.2031, 0.2224, 0.2357, 0.2438]}, {"w": "the", "b": [0.2407, 0.2224, 0.267, 0.2438]}, {"w": "BN", "b": [0.2721, 0.2224, 0.2998, 0.2438]}, {"w": "layer", "b": [0.3048, 0.2224, 0.345, 0.2438]}, {"w": "does", "b": [0.3501, 0.2224, 0.3882, 0.2438]}, {"w": "not", "b": [0.3932, 0.2224, 0.4216, 0.2438]}, {"w": "perform", "b": [0.4266, 0.2224, 0.4957, 0.2438]}, {"w": "the", "b": [0.5008, 0.2224, 0.5271, 0.2438]}, {"w": "same", "b": [0.5321, 0.2224, 0.5748, 0.2438]}, {"w": "computation", "b": [0.5799, 0.2224, 0.687, 0.2438]}, {"w": "during", "b": [0.6921, 0.2224, 0.7486, 0.2438]}, {"w": "training", "b": [0.7536, 0.2224, 0.8206, 0.2438]}, {"w": "and", "b": [0.8256, 0.2224, 0.8571, 0.2438]}, {"w": "after", "b": [0.1429, 0.2414, 0.1811, 0.2628]}, {"w": "training:", "b": [0.1888, 0.2414, 0.2605, 0.2628]}, {"w": "it", "b": [0.2682, 0.2414, 0.2802, 0.2628]}, {"w": "uses", "b": [0.2879, 0.2414, 0.3231, 0.2628]}, {"w": "batch", "b": [0.3309, 0.2414, 0.3765, 0.2628]}, {"w": "statistics", "b": [0.3842, 0.2414, 0.4549, 0.2628]}, {"w": "during", "b": [0.4627, 0.2414, 0.5192, 0.2628]}, {"w": "training,", "b": [0.5269, 0.2414, 0.5986, 0.2628]}, {"w": "and", "b": [0.6063, 0.2414, 0.6379, 0.2628]}, {"w": "the", "b": [0.6456, 0.2414, 0.6719, 0.2628]}, {"w": "“final”", "b": [0.6797, 0.2414, 0.7327, 0.2628]}, {"w": "statistics", "b": [0.7404, 0.2414, 0.8112, 0.2628]}, {"w": "after", "b": [0.8189, 0.2414, 0.8571, 0.2628]}, {"w": "training", "b": [0.1429, 0.2605, 0.2098, 0.2819]}, {"w": "(i.e.,", "b": [0.2164, 0.2605, 0.2523, 0.2819]}, {"w": "the", "b": [0.2589, 0.2605, 0.2852, 0.2819]}, {"w": "final", "b": [0.2918, 0.2605, 0.3294, 0.2819]}, {"w": "value", "b": [0.336, 0.2605, 0.38, 0.2819]}, {"w": "of", "b": [0.3865, 0.2605, 0.4033, 0.2819]}, {"w": "the", "b": [0.4099, 0.2605, 0.4363, 0.2819]}, {"w": "moving", "b": [0.4429, 0.2605, 0.5069, 0.2819]}, {"w": "averages).", "b": [0.5135, 0.2605, 0.5959, 0.2819]}, {"w": "Let’s", "b": [0.6025, 0.2605, 0.6386, 0.2819]}, {"w": "take", "b": [0.6452, 0.2605, 0.6799, 0.2819]}, {"w": "a", "b": [0.6865, 0.2605, 0.6957, 0.2819]}, {"w": "peek", "b": [0.7022, 0.2605, 0.7412, 0.2819]}, {"w": "at", "b": [0.7478, 0.2605, 0.7629, 0.2819]}, {"w": "the", "b": [0.7695, 0.2605, 0.7958, 0.2819]}, {"w": "source", "b": [0.8024, 0.2605, 0.8572, 0.2819]}, {"w": "code", "b": [0.1429, 0.2795, 0.1822, 0.3009]}, {"w": "of", "b": [0.1869, 0.2795, 0.2037, 0.3009]}, {"w": "this", "b": [0.2084, 0.2795, 0.2391, 0.3009]}, {"w": "class", "b": [0.2438, 0.2795, 0.2824, 0.3009]}, {"w": "to", "b": [0.2871, 0.2795, 0.3041, 0.3009]}, {"w": "see", "b": [0.3088, 0.2795, 0.3342, 0.3009]}, {"w": "how", "b": [0.3389, 0.2795, 0.3749, 0.3009]}, {"w": "this", "b": [0.3796, 0.2795, 0.4103, 0.3009]}, {"w": "is", "b": [0.4151, 0.2795, 0.4283, 0.3009]}, {"w": "handled:", "b": [0.433, 0.2795, 0.5056, 0.3009]}]}, {"id": "b_4", "type": "paragraph", "text": "class BatchNormalization(Layer): [...] def call(self, inputs, training=None): if training is None: training = keras.backend.learning_phase() [...]", "words": [{"w": "class", "b": [0.1766, 0.3115, 0.2187, 0.3243]}, {"w": "BatchNormalization(Layer):", "b": [0.2272, 0.3115, 0.4464, 0.3243]}, {"w": "[...]", "b": [0.2103, 0.3269, 0.2525, 0.3397]}, {"w": "def", "b": [0.2103, 0.3423, 0.2356, 0.3552]}, {"w": "call(self,", "b": [0.244, 0.3423, 0.3284, 0.3552]}, {"w": "inputs,", "b": [0.3368, 0.3423, 0.3958, 0.3552]}, {"w": "training=None):", "b": [0.4043, 0.3423, 0.5307, 0.3552]}, {"w": "if", "b": [0.244, 0.3577, 0.2609, 0.3706]}, {"w": "training", "b": [0.2693, 0.3577, 0.3368, 0.3706]}, {"w": "is", "b": [0.3452, 0.3577, 0.3621, 0.3706]}, {"w": "None:", "b": [0.3705, 0.3577, 0.4127, 0.3706]}, {"w": "training", "b": [0.2778, 0.3732, 0.3452, 0.386]}, {"w": "=", "b": [0.3537, 0.3732, 0.3621, 0.386]}, {"w": "keras.backend.learning_phase()", "b": [0.3705, 0.3732, 0.6235, 0.386]}, {"w": "[...]", "b": [0.244, 0.3886, 0.2862, 0.4014]}]}, {"id": "b_5", "type": "paragraph", "text": "The call() method is the one that actually performs the computations, and as you can see it has an extra training argument: if it is None it falls back to keras.back end.learning_phase(), which returns 1 during training (the fit() method ensures that). Otherwise, it returns 0. If you ever need to write a custom layer, and it needs to behave differently during training and testing, simply use the same pattern (we will discuss custom layers in Chapter 12).", "words": [{"w": "The", "b": [0.1429, 0.4101, 0.1757, 0.4315]}, {"w": "call()", "b": [0.1824, 0.4133, 0.2418, 0.4284]}, {"w": "method", "b": [0.2485, 0.4101, 0.3135, 0.4315]}, {"w": "is", "b": [0.3202, 0.4101, 0.3334, 0.4315]}, {"w": "the", "b": [0.3401, 0.4101, 0.3665, 0.4315]}, {"w": "one", "b": [0.3732, 0.4101, 0.4041, 0.4315]}, {"w": "that", "b": [0.4108, 0.4101, 0.4434, 0.4315]}, {"w": "actually", "b": [0.4501, 0.4101, 0.5147, 0.4315]}, {"w": "performs", "b": [0.5214, 0.4101, 0.5981, 0.4315]}, {"w": "the", "b": [0.6048, 0.4101, 0.6312, 0.4315]}, {"w": "computations,", "b": [0.6379, 0.4101, 0.7574, 0.4315]}, {"w": "and", "b": [0.7641, 0.4101, 0.7957, 0.4315]}, {"w": "as", "b": [0.8024, 0.4101, 0.8192, 0.4315]}, {"w": "you", "b": [0.8259, 0.4101, 0.8571, 0.4315]}, {"w": "can", "b": [0.1429, 0.4301, 0.1722, 0.4515]}, {"w": "see", "b": [0.1793, 0.4301, 0.2047, 0.4515]}, {"w": "it", "b": [0.2117, 0.4301, 0.2237, 0.4515]}, {"w": "has", "b": [0.2308, 0.4301, 0.2587, 0.4515]}, {"w": "an", "b": [0.2658, 0.4301, 0.2863, 0.4515]}, {"w": "extra", "b": [0.2934, 0.4301, 0.3353, 0.4515]}, {"w": "training", "b": [0.3424, 0.4332, 0.4216, 0.4483]}, {"w": "argument:", "b": [0.4287, 0.4301, 0.5144, 0.4515]}, {"w": "if", "b": [0.5215, 0.4301, 0.5332, 0.4515]}, {"w": "it", "b": [0.5403, 0.4301, 0.5522, 0.4515]}, {"w": "is", "b": [0.5593, 0.4301, 0.5726, 0.4515]}, {"w": "None", "b": [0.5796, 0.4332, 0.6192, 0.4483]}, {"w": "it", "b": [0.6263, 0.4301, 0.6382, 0.4515]}, {"w": "falls", "b": [0.6453, 0.4301, 0.6788, 0.4515]}, {"w": "back", "b": [0.6859, 0.4301, 0.7248, 0.4515]}, {"w": "to", "b": [0.7319, 0.4301, 0.7489, 0.4515]}, {"w": "keras.back", "b": [0.756, 0.4332, 0.8549, 0.4483]}, {"w": "end.learning_phase(),", "b": [0.1429, 0.45, 0.3455, 0.4714]}, {"w": "which", "b": [0.3517, 0.45, 0.4026, 0.4714]}, {"w": "returns", "b": [0.4087, 0.45, 0.4695, 0.4714]}, {"w": "1", "b": [0.4757, 0.4532, 0.4856, 0.4683]}, {"w": "during", "b": [0.4917, 0.45, 0.5482, 0.4714]}, {"w": "training", "b": [0.5544, 0.45, 0.6213, 0.4714]}, {"w": "(the", "b": [0.6275, 0.45, 0.661, 0.4714]}, {"w": "fit()", "b": [0.6672, 0.4532, 0.7166, 0.4683]}, {"w": "method", "b": [0.7228, 0.45, 0.7878, 0.4714]}, {"w": "ensures", "b": [0.794, 0.45, 0.8572, 0.4714]}, {"w": "that).", "b": [0.1429, 0.4699, 0.1874, 0.4914]}, {"w": "Otherwise,", "b": [0.1926, 0.4699, 0.284, 0.4914]}, {"w": "it", "b": [0.2892, 0.4699, 0.3011, 0.4914]}, {"w": "returns", "b": [0.3064, 0.4699, 0.3672, 0.4914]}, {"w": "0.", "b": [0.3724, 0.4699, 0.387, 0.4914]}, {"w": "If", "b": [0.3923, 0.4699, 0.4055, 0.4914]}, {"w": "you", "b": [0.4108, 0.4699, 0.442, 0.4914]}, {"w": "ever", "b": [0.4473, 0.4699, 0.4824, 0.4914]}, {"w": "need", "b": [0.4876, 0.4699, 0.5277, 0.4914]}, {"w": "to", "b": [0.5329, 0.4699, 0.5499, 0.4914]}, {"w": "write", "b": [0.5552, 0.4699, 0.5979, 0.4914]}, {"w": "a", "b": [0.6032, 0.4699, 0.6123, 0.4914]}, {"w": "custom", "b": [0.6176, 0.4699, 0.6791, 0.4914]}, {"w": "layer,", "b": [0.6844, 0.4699, 0.728, 0.4914]}, {"w": "and", "b": [0.7332, 0.4699, 0.7648, 0.4914]}, {"w": "it", "b": [0.77, 0.4699, 0.7819, 0.4914]}, {"w": "needs", "b": [0.7872, 0.4699, 0.8349, 0.4914]}, {"w": "to", "b": [0.8402, 0.4699, 0.8571, 0.4914]}, {"w": "behave", "b": [0.1429, 0.489, 0.2007, 0.5104]}, {"w": "differently", "b": [0.2074, 0.489, 0.294, 0.5104]}, {"w": "during", "b": [0.3007, 0.489, 0.3572, 0.5104]}, {"w": "training", "b": [0.364, 0.489, 0.4309, 0.5104]}, {"w": "and", "b": [0.4377, 0.489, 0.4692, 0.5104]}, {"w": "testing,", "b": [0.4759, 0.489, 0.5366, 0.5104]}, {"w": "simply", "b": [0.5434, 0.489, 0.599, 0.5104]}, {"w": "use", "b": [0.6057, 0.489, 0.6333, 0.5104]}, {"w": "the", "b": [0.6401, 0.489, 0.6664, 0.5104]}, {"w": "same", "b": [0.6731, 0.489, 0.7158, 0.5104]}, {"w": "pattern", "b": [0.7226, 0.489, 0.7829, 0.5104]}, {"w": "(we", "b": [0.7897, 0.489, 0.82, 0.5104]}, {"w": "will", "b": [0.8267, 0.489, 0.8571, 0.5104]}, {"w": "discuss", "b": [0.1428, 0.508, 0.2022, 0.5294]}, {"w": "custom", "b": [0.207, 0.508, 0.2685, 0.5294]}, {"w": "layers", "b": [0.2733, 0.508, 0.3211, 0.5294]}, {"w": "in", "b": [0.3258, 0.508, 0.3428, 0.5294]}, {"w": "Chapter", "b": [0.3475, 0.508, 0.4151, 0.5294]}, {"w": "12).", "b": [0.4198, 0.508, 0.4518, 0.5294]}]}, {"id": "b_6", "type": "paragraph", "text": "Batch Normalization has become one of the most used layers in deep neural net‐ works, to the point that it is often omitted in the diagrams, as it is assumed that BN is added after every layer. However, a very recent paper10 by Hongyi Zhang et al. may well change this: the authors show that by using a novel fixed-update (fixup) weight initialization technique, they manage to train a very deep neural network (10,000 lay‐ ers!) without BN, achieving state-of-the-art performance on complex image classifi‐ cation tasks.", "words": [{"w": "Batch", "b": [0.1428, 0.5362, 0.1901, 0.5576]}, {"w": "Normalization", "b": [0.1983, 0.5362, 0.3202, 0.5576]}, {"w": "has", "b": [0.3283, 0.5362, 0.3562, 0.5576]}, {"w": "become", "b": [0.3644, 0.5362, 0.4292, 0.5576]}, {"w": "one", "b": [0.4374, 0.5362, 0.4683, 0.5576]}, {"w": "of", "b": [0.4764, 0.5362, 0.4932, 0.5576]}, {"w": "the", "b": [0.5014, 0.5362, 0.5277, 0.5576]}, {"w": "most", "b": [0.5359, 0.5362, 0.5776, 0.5576]}, {"w": "used", "b": [0.5858, 0.5362, 0.6243, 0.5576]}, {"w": "layers", "b": [0.6325, 0.5362, 0.6803, 0.5576]}, {"w": "in", "b": [0.6885, 0.5362, 0.7055, 0.5576]}, {"w": "deep", "b": [0.7137, 0.5362, 0.7533, 0.5576]}, {"w": "neural", "b": [0.7615, 0.5362, 0.8149, 0.5576]}, {"w": "net‐", "b": [0.8231, 0.5362, 0.8571, 0.5576]}, {"w": "works,", "b": [0.1429, 0.5552, 0.1982, 0.5766]}, {"w": "to", "b": [0.2033, 0.5552, 0.2203, 0.5766]}, {"w": "the", "b": [0.2253, 0.5552, 0.2517, 0.5766]}, {"w": "point", "b": [0.2567, 0.5552, 0.3012, 0.5766]}, {"w": "that", "b": [0.3063, 0.5552, 0.3388, 0.5766]}, {"w": "it", "b": [0.3439, 0.5552, 0.3558, 0.5766]}, {"w": "is", "b": [0.3609, 0.5552, 0.3741, 0.5766]}, {"w": "often", "b": [0.3792, 0.5552, 0.4226, 0.5766]}, {"w": "omitted", "b": [0.4277, 0.5552, 0.4935, 0.5766]}, {"w": "in", "b": [0.4985, 0.5552, 0.5155, 0.5766]}, {"w": "the", "b": [0.5206, 0.5552, 0.5469, 0.5766]}, {"w": "diagrams,", "b": [0.552, 0.5552, 0.6338, 0.5766]}, {"w": "as", "b": [0.6389, 0.5552, 0.6557, 0.5766]}, {"w": "it", "b": [0.6607, 0.5552, 0.6727, 0.5766]}, {"w": "is", "b": [0.6777, 0.5552, 0.6909, 0.5766]}, {"w": "assumed", "b": [0.696, 0.5552, 0.7684, 0.5766]}, {"w": "that", "b": [0.7735, 0.5552, 0.8061, 0.5766]}, {"w": "BN", "b": [0.8111, 0.5552, 0.8389, 0.5766]}, {"w": "is", "b": [0.8439, 0.5552, 0.8571, 0.5766]}, {"w": "added", "b": [0.1429, 0.5742, 0.1939, 0.5957]}, {"w": "after", "b": [0.2006, 0.5742, 0.2389, 0.5957]}, {"w": "every", "b": [0.2457, 0.5742, 0.2909, 0.5957]}, {"w": "layer.", "b": [0.2977, 0.5742, 0.3413, 0.5957]}, {"w": "However,", "b": [0.3481, 0.5742, 0.4269, 0.5957]}, {"w": "a", "b": [0.4337, 0.5742, 0.4428, 0.5957]}, {"w": "very", "b": [0.4496, 0.5742, 0.486, 0.5957]}, {"w": "recent", "b": [0.4928, 0.5742, 0.5444, 0.5957]}, {"w": "paper10", "b": [0.5512, 0.5742, 0.6098, 0.5957]}, {"w": "by", "b": [0.6165, 0.5742, 0.6367, 0.5957]}, {"w": "Hongyi", "b": [0.6435, 0.5742, 0.7063, 0.5957]}, {"w": "Zhang", "b": [0.7131, 0.5742, 0.7671, 0.5957]}, {"w": "et", "b": [0.7738, 0.5742, 0.789, 0.5957]}, {"w": "al.", "b": [0.7958, 0.5742, 0.815, 0.5957]}, {"w": "may", "b": [0.8217, 0.5742, 0.8571, 0.5957]}, {"w": "well", "b": [0.1429, 0.5933, 0.1765, 0.6147]}, {"w": "change", "b": [0.1827, 0.5933, 0.2418, 0.6147]}, {"w": "this:", "b": [0.248, 0.5933, 0.2834, 0.6147]}, {"w": "the", "b": [0.2896, 0.5933, 0.3159, 0.6147]}, {"w": "authors", "b": [0.3221, 0.5933, 0.3854, 0.6147]}, {"w": "show", "b": [0.3916, 0.5933, 0.4353, 0.6147]}, {"w": "that", "b": [0.4414, 0.5933, 0.474, 0.6147]}, {"w": "by", "b": [0.4802, 0.5933, 0.5004, 0.6147]}, {"w": "using", "b": [0.5065, 0.5933, 0.552, 0.6147]}, {"w": "a", "b": [0.5582, 0.5933, 0.5673, 0.6147]}, {"w": "novel", "b": [0.5735, 0.5933, 0.6193, 0.6147]}, {"w": "fixed-update", "b": [0.6255, 0.5933, 0.7313, 0.6147]}, {"w": "(fixup)", "b": [0.7374, 0.5933, 0.7954, 0.6147]}, {"w": "weight", "b": [0.8016, 0.5933, 0.8571, 0.6147]}, {"w": "initialization", "b": [0.1429, 0.6123, 0.2488, 0.6338]}, {"w": "technique,", "b": [0.2539, 0.6123, 0.3414, 0.6338]}, {"w": "they", "b": [0.3465, 0.6123, 0.3824, 0.6338]}, {"w": "manage", "b": [0.3875, 0.6123, 0.4528, 0.6338]}, {"w": "to", "b": [0.4579, 0.6123, 0.4749, 0.6338]}, {"w": "train", "b": [0.48, 0.6123, 0.5202, 0.6338]}, {"w": "a", "b": [0.5253, 0.6123, 0.5345, 0.6338]}, {"w": "very", "b": [0.5396, 0.6123, 0.576, 0.6338]}, {"w": "deep", "b": [0.5811, 0.6123, 0.6207, 0.6338]}, {"w": "neural", "b": [0.6258, 0.6123, 0.6793, 0.6338]}, {"w": "network", "b": [0.6844, 0.6123, 0.754, 0.6338]}, {"w": "(10,000", "b": [0.7591, 0.6123, 0.821, 0.6338]}, {"w": "lay‐", "b": [0.8261, 0.6123, 0.8572, 0.6338]}, {"w": "ers!)", "b": [0.1429, 0.6314, 0.18, 0.6528]}, {"w": "without", "b": [0.1866, 0.6314, 0.252, 0.6528]}, {"w": "BN,", "b": [0.2585, 0.6314, 0.291, 0.6528]}, {"w": "achieving", "b": [0.2975, 0.6314, 0.3774, 0.6528]}, {"w": "state-of-the-art", "b": [0.3839, 0.6314, 0.5105, 0.6528]}, {"w": "performance", "b": [0.517, 0.6314, 0.6243, 0.6528]}, {"w": "on", "b": [0.6309, 0.6314, 0.6529, 0.6528]}, {"w": "complex", "b": [0.6594, 0.6314, 0.7304, 0.6528]}, {"w": "image", "b": [0.7369, 0.6314, 0.7873, 0.6528]}, {"w": "classifi‐", "b": [0.7939, 0.6314, 0.8571, 0.6528]}, {"w": "cation", "b": [0.1429, 0.6504, 0.1944, 0.6719]}, {"w": "tasks.", "b": [0.1991, 0.6504, 0.245, 0.6719]}]}, {"id": "b_7", "type": "paragraph", "text": "Gradient Clipping", "words": [{"w": "Gradient", "b": [0.1429, 0.6846, 0.2326, 0.7132]}, {"w": "Clipping", "b": [0.2376, 0.6846, 0.3225, 0.7132]}]}, {"id": "b_8", "type": "paragraph", "text": "Another popular technique to lessen the exploding gradients problem is to simply clip the gradients during backpropagation so that they never exceed some threshold. This is called Gradient Clipping.11 This technique is most often used in recurrent neu‐", "words": [{"w": "Another", "b": [0.1429, 0.7191, 0.2133, 0.7405]}, {"w": "popular", "b": [0.2211, 0.7191, 0.2868, 0.7405]}, {"w": "technique", "b": [0.2945, 0.7191, 0.3772, 0.7405]}, {"w": "to", "b": [0.385, 0.7191, 0.4019, 0.7405]}, {"w": "lessen", "b": [0.4097, 0.7191, 0.4594, 0.7405]}, {"w": "the", "b": [0.4671, 0.7191, 0.4934, 0.7405]}, {"w": "exploding", "b": [0.5012, 0.7191, 0.5844, 0.7405]}, {"w": "gradients", "b": [0.5922, 0.7191, 0.6692, 0.7405]}, {"w": "problem", "b": [0.677, 0.7191, 0.748, 0.7405]}, {"w": "is", "b": [0.7558, 0.7191, 0.769, 0.7405]}, {"w": "to", "b": [0.7768, 0.7191, 0.7937, 0.7405]}, {"w": "simply", "b": [0.8015, 0.7191, 0.8571, 0.7405]}, {"w": "clip", "b": [0.1429, 0.7381, 0.1734, 0.7595]}, {"w": "the", "b": [0.1793, 0.7381, 0.2057, 0.7595]}, {"w": "gradients", "b": [0.2116, 0.7381, 0.2887, 0.7595]}, {"w": "during", "b": [0.2946, 0.7381, 0.3511, 0.7595]}, {"w": "backpropagation", "b": [0.357, 0.7381, 0.4977, 0.7595]}, {"w": "so", "b": [0.5036, 0.7381, 0.5218, 0.7595]}, {"w": "that", "b": [0.5278, 0.7381, 0.5603, 0.7595]}, {"w": "they", "b": [0.5662, 0.7381, 0.6021, 0.7595]}, {"w": "never", "b": [0.6081, 0.7381, 0.6545, 0.7595]}, {"w": "exceed", "b": [0.6604, 0.7381, 0.7167, 0.7595]}, {"w": "some", "b": [0.7226, 0.7381, 0.7668, 0.7595]}, {"w": "threshold.", "b": [0.7727, 0.7381, 0.8571, 0.7595]}, {"w": "This", "b": [0.1428, 0.7572, 0.1801, 0.7786]}, {"w": "is", "b": [0.1853, 0.7572, 0.1985, 0.7786]}, {"w": "called", "b": [0.2037, 0.7572, 0.2521, 0.7786]}, {"w": "Gradient", "b": [0.2573, 0.757, 0.3297, 0.7786]}, {"w": "Clipping.11", "b": [0.3345, 0.757, 0.4196, 0.7786]}, {"w": "This", "b": [0.4249, 0.7572, 0.4621, 0.7786]}, {"w": "technique", "b": [0.4673, 0.7572, 0.55, 0.7786]}, {"w": "is", "b": [0.5552, 0.7572, 0.5684, 0.7786]}, {"w": "most", "b": [0.5736, 0.7572, 0.6153, 0.7786]}, {"w": "often", "b": [0.6205, 0.7572, 0.6639, 0.7786]}, {"w": "used", "b": [0.6691, 0.7572, 0.7077, 0.7786]}, {"w": "in", "b": [0.7129, 0.7572, 0.7299, 0.7786]}, {"w": "recurrent", "b": [0.7351, 0.7572, 0.8132, 0.7786]}, {"w": "neu‐", "b": [0.8184, 0.7572, 0.8571, 0.7786]}]}, {"id": "b_9", "type": "paragraph", "text": "338 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "338", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2745, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 365, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "ral networks, as Batch Normalization is tricky to use in RNNs, as we will see in ???. For other types of networks, BN is usually sufficient.", "words": [{"w": "ral", "b": [0.1429, 0.0791, 0.165, 0.1005]}, {"w": "networks,", "b": [0.1715, 0.0791, 0.2535, 0.1005]}, {"w": "as", "b": [0.26, 0.0791, 0.2768, 0.1005]}, {"w": "Batch", "b": [0.2833, 0.0791, 0.3306, 0.1005]}, {"w": "Normalization", "b": [0.3371, 0.0791, 0.459, 0.1005]}, {"w": "is", "b": [0.4655, 0.0791, 0.4787, 0.1005]}, {"w": "tricky", "b": [0.4852, 0.0791, 0.5336, 0.1005]}, {"w": "to", "b": [0.5401, 0.0791, 0.5571, 0.1005]}, {"w": "use", "b": [0.5636, 0.0791, 0.5912, 0.1005]}, {"w": "in", "b": [0.5977, 0.0791, 0.6147, 0.1005]}, {"w": "RNNs,", "b": [0.6212, 0.0791, 0.6769, 0.1005]}, {"w": "as", "b": [0.6835, 0.0791, 0.7002, 0.1005]}, {"w": "we", "b": [0.7068, 0.0791, 0.7299, 0.1005]}, {"w": "will", "b": [0.7364, 0.0791, 0.7668, 0.1005]}, {"w": "see", "b": [0.7733, 0.0791, 0.7987, 0.1005]}, {"w": "in", "b": [0.8052, 0.0791, 0.8222, 0.1005]}, {"w": "???.", "b": [0.8287, 0.0791, 0.8571, 0.1005]}, {"w": "For", "b": [0.1429, 0.0981, 0.1718, 0.1195]}, {"w": "other", "b": [0.1766, 0.0981, 0.2212, 0.1195]}, {"w": "types", "b": [0.226, 0.0981, 0.2693, 0.1195]}, {"w": "of", "b": [0.274, 0.0981, 0.2908, 0.1195]}, {"w": "networks,", "b": [0.2956, 0.0981, 0.3775, 0.1195]}, {"w": "BN", "b": [0.3822, 0.0981, 0.41, 0.1195]}, {"w": "is", "b": [0.4147, 0.0981, 0.4279, 0.1195]}, {"w": "usually", "b": [0.4327, 0.0981, 0.4917, 0.1195]}, {"w": "sufficient.", "b": [0.4964, 0.0981, 0.5784, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "In Keras, implementing Gradient Clipping is just a matter of setting the clipvalue or clipnorm argument when creating an optimizer. For example:", "words": [{"w": "In", "b": [0.1429, 0.1271, 0.1614, 0.1485]}, {"w": "Keras,", "b": [0.1663, 0.1271, 0.218, 0.1485]}, {"w": "implementing", "b": [0.2229, 0.1271, 0.3402, 0.1485]}, {"w": "Gradient", "b": [0.3452, 0.1271, 0.4198, 0.1485]}, {"w": "Clipping", "b": [0.4247, 0.1271, 0.498, 0.1485]}, {"w": "is", "b": [0.503, 0.1271, 0.5162, 0.1485]}, {"w": "just", "b": [0.5212, 0.1271, 0.5516, 0.1485]}, {"w": "a", "b": [0.5566, 0.1271, 0.5657, 0.1485]}, {"w": "matter", "b": [0.5707, 0.1271, 0.6258, 0.1485]}, {"w": "of", "b": [0.6308, 0.1271, 0.6476, 0.1485]}, {"w": "setting", "b": [0.6525, 0.1271, 0.7085, 0.1485]}, {"w": "the", "b": [0.7134, 0.1271, 0.7398, 0.1485]}, {"w": "clipvalue", "b": [0.7447, 0.1303, 0.8338, 0.1454]}, {"w": "or", "b": [0.8388, 0.1271, 0.8571, 0.1485]}, {"w": "clipnorm", "b": [0.1429, 0.1503, 0.222, 0.1653]}, {"w": "argument", "b": [0.2268, 0.1471, 0.3077, 0.1685]}, {"w": "when", "b": [0.3124, 0.1471, 0.3581, 0.1685]}, {"w": "creating", "b": [0.3628, 0.1471, 0.43, 0.1685]}, {"w": "an", "b": [0.4348, 0.1471, 0.4553, 0.1685]}, {"w": "optimizer.", "b": [0.46, 0.1471, 0.5449, 0.1685]}, {"w": "For", "b": [0.5497, 0.1471, 0.5787, 0.1685]}, {"w": "example:", "b": [0.5834, 0.1471, 0.6577, 0.1685]}]}, {"id": "b_2", "type": "paragraph", "text": "optimizer = keras.optimizers.SGD(clipvalue=1.0) model.compile(loss=\"mse\", optimizer=optimizer)", "words": [{"w": "optimizer", "b": [0.1766, 0.179, 0.2525, 0.1919]}, {"w": "=", "b": [0.2609, 0.179, 0.2693, 0.1919]}, {"w": "keras.optimizers.SGD(clipvalue=1.0)", "b": [0.2778, 0.179, 0.5729, 0.1919]}, {"w": "model.compile(loss=\"mse\",", "b": [0.1766, 0.1945, 0.3874, 0.2073]}, {"w": "optimizer=optimizer)", "b": [0.3958, 0.1945, 0.5645, 0.2073]}]}, {"id": "b_3", "type": "paragraph", "text": "This will clip every component of the gradient vector to a value between –1.0 and 1.0. This means that all the partial derivatives of the loss (with regards to each and every trainable parameter) will be clipped between –1.0 and 1.0. The threshold is a hyper‐ parameter you can tune. Note that it may change the orientation of the gradient vec‐ tor: for example, if the original gradient vector is [0.9, 100.0], it points mostly in the direction of the second axis, but once you clip it by value, you get [0.9, 1.0], which points roughly in the diagonal between the two axes. In practice however, this approach works well. If you want to ensure that Gradient Clipping does not change the direction of the gradient vector, you should clip by norm by setting clipnorm instead of clipvalue. This will clip the whole gradient if its ℓ2 norm is greater than the threshold you picked. For example, if you set clipnorm=1.0, then the vector [0.9, 100.0] will be clipped to [0.00899964, 0.9999595], preserving its orientation, but almost eliminating the first component. If you observe that the gradients explode during training (you can track the size of the gradients using TensorBoard), you may want to try both clipping by value and clipping by norm, with different threshold, and see which option performs best on the validation set.", "words": [{"w": "This", "b": [0.1429, 0.2151, 0.1801, 0.2365]}, {"w": "will", "b": [0.1851, 0.2151, 0.2155, 0.2365]}, {"w": "clip", "b": [0.2205, 0.2151, 0.2511, 0.2365]}, {"w": "every", "b": [0.2561, 0.2151, 0.3013, 0.2365]}, {"w": "component", "b": [0.3063, 0.2151, 0.4016, 0.2365]}, {"w": "of", "b": [0.4066, 0.2151, 0.4234, 0.2365]}, {"w": "the", "b": [0.4284, 0.2151, 0.4547, 0.2365]}, {"w": "gradient", "b": [0.4597, 0.2151, 0.5291, 0.2365]}, {"w": "vector", "b": [0.5342, 0.2151, 0.5862, 0.2365]}, {"w": "to", "b": [0.5912, 0.2151, 0.6082, 0.2365]}, {"w": "a", "b": [0.6132, 0.2151, 0.6223, 0.2365]}, {"w": "value", "b": [0.6273, 0.2151, 0.6713, 0.2365]}, {"w": "between", "b": [0.6763, 0.2151, 0.7455, 0.2365]}, {"w": "–1.0", "b": [0.7505, 0.2151, 0.7861, 0.2365]}, {"w": "and", "b": [0.7911, 0.2151, 0.8226, 0.2365]}, {"w": "1.0.", "b": [0.8276, 0.2151, 0.8571, 0.2365]}, {"w": "This", "b": [0.1429, 0.2341, 0.1801, 0.2556]}, {"w": "means", "b": [0.186, 0.2341, 0.2401, 0.2556]}, {"w": "that", "b": [0.2459, 0.2341, 0.2785, 0.2556]}, {"w": "all", "b": [0.2844, 0.2341, 0.3041, 0.2556]}, {"w": "the", "b": [0.31, 0.2341, 0.3363, 0.2556]}, {"w": "partial", "b": [0.3422, 0.2341, 0.3963, 0.2556]}, {"w": "derivatives", "b": [0.4022, 0.2341, 0.4918, 0.2556]}, {"w": "of", "b": [0.4977, 0.2341, 0.5145, 0.2556]}, {"w": "the", "b": [0.5204, 0.2341, 0.5467, 0.2556]}, {"w": "loss", "b": [0.5526, 0.2341, 0.5838, 0.2556]}, {"w": "(with", "b": [0.5897, 0.2341, 0.6342, 0.2556]}, {"w": "regards", "b": [0.6401, 0.2341, 0.7019, 0.2556]}, {"w": "to", "b": [0.7078, 0.2341, 0.7248, 0.2556]}, {"w": "each", "b": [0.7307, 0.2341, 0.7686, 0.2556]}, {"w": "and", "b": [0.7745, 0.2341, 0.806, 0.2556]}, {"w": "every", "b": [0.8119, 0.2341, 0.8572, 0.2556]}, {"w": "trainable", "b": [0.1429, 0.2532, 0.2169, 0.2746]}, {"w": "parameter)", "b": [0.2231, 0.2532, 0.3161, 0.2746]}, {"w": "will", "b": [0.3223, 0.2532, 0.3527, 0.2746]}, {"w": "be", "b": [0.3588, 0.2532, 0.3783, 0.2746]}, {"w": "clipped", "b": [0.3844, 0.2532, 0.4458, 0.2746]}, {"w": "between", "b": [0.4519, 0.2532, 0.5211, 0.2746]}, {"w": "–1.0", "b": [0.5273, 0.2532, 0.5629, 0.2746]}, {"w": "and", "b": [0.569, 0.2532, 0.6006, 0.2746]}, {"w": "1.0.", "b": [0.6067, 0.2532, 0.6362, 0.2746]}, {"w": "The", "b": [0.6424, 0.2532, 0.6752, 0.2746]}, {"w": "threshold", "b": [0.6814, 0.2532, 0.7611, 0.2746]}, {"w": "is", "b": [0.7673, 0.2532, 0.7805, 0.2746]}, {"w": "a", "b": [0.7867, 0.2532, 0.7959, 0.2746]}, {"w": "hyper‐", "b": [0.802, 0.2532, 0.8571, 0.2746]}, {"w": "parameter", "b": [0.1429, 0.2722, 0.2286, 0.2937]}, {"w": "you", "b": [0.2343, 0.2722, 0.2656, 0.2937]}, {"w": "can", "b": [0.2712, 0.2722, 0.3006, 0.2937]}, {"w": "tune.", "b": [0.3062, 0.2722, 0.3486, 0.2937]}, {"w": "Note", "b": [0.3543, 0.2722, 0.3951, 0.2937]}, {"w": "that", "b": [0.4008, 0.2722, 0.4333, 0.2937]}, {"w": "it", "b": [0.439, 0.2722, 0.4509, 0.2937]}, {"w": "may", "b": [0.4566, 0.2722, 0.492, 0.2937]}, {"w": "change", "b": [0.4976, 0.2722, 0.5567, 0.2937]}, {"w": "the", "b": [0.5624, 0.2722, 0.5887, 0.2937]}, {"w": "orientation", "b": [0.5944, 0.2722, 0.6872, 0.2937]}, {"w": "of", "b": [0.6929, 0.2722, 0.7097, 0.2937]}, {"w": "the", "b": [0.7153, 0.2722, 0.7417, 0.2937]}, {"w": "gradient", "b": [0.7473, 0.2722, 0.8168, 0.2937]}, {"w": "vec‐", "b": [0.8224, 0.2722, 0.8571, 0.2937]}, {"w": "tor:", "b": [0.1428, 0.2913, 0.1728, 0.3127]}, {"w": "for", "b": [0.1788, 0.2913, 0.2034, 0.3127]}, {"w": "example,", "b": [0.2094, 0.2913, 0.2837, 0.3127]}, {"w": "if", "b": [0.2897, 0.2913, 0.3015, 0.3127]}, {"w": "the", "b": [0.3075, 0.2913, 0.3338, 0.3127]}, {"w": "original", "b": [0.3398, 0.2913, 0.4049, 0.3127]}, {"w": "gradient", "b": [0.4109, 0.2913, 0.4804, 0.3127]}, {"w": "vector", "b": [0.4864, 0.2913, 0.5384, 0.3127]}, {"w": "is", "b": [0.5444, 0.2913, 0.5577, 0.3127]}, {"w": "[0.9,", "b": [0.5637, 0.2913, 0.6004, 0.3127]}, {"w": "100.0],", "b": [0.6064, 0.2913, 0.6631, 0.3127]}, {"w": "it", "b": [0.6691, 0.2913, 0.6811, 0.3127]}, {"w": "points", "b": [0.6871, 0.2913, 0.7392, 0.3127]}, {"w": "mostly", "b": [0.7452, 0.2913, 0.8018, 0.3127]}, {"w": "in", "b": [0.8078, 0.2913, 0.8248, 0.3127]}, {"w": "the", "b": [0.8308, 0.2913, 0.8571, 0.3127]}, {"w": "direction", "b": [0.1429, 0.3103, 0.2188, 0.3317]}, {"w": "of", "b": [0.2256, 0.3103, 0.2424, 0.3317]}, {"w": "the", "b": [0.2492, 0.3103, 0.2756, 0.3317]}, {"w": "second", "b": [0.2824, 0.3103, 0.3407, 0.3317]}, {"w": "axis,", "b": [0.3475, 0.3103, 0.3845, 0.3317]}, {"w": "but", "b": [0.3913, 0.3103, 0.4193, 0.3317]}, {"w": "once", "b": [0.4261, 0.3103, 0.4658, 0.3317]}, {"w": "you", "b": [0.4726, 0.3103, 0.5039, 0.3317]}, {"w": "clip", "b": [0.5107, 0.3103, 0.5413, 0.3317]}, {"w": "it", "b": [0.5481, 0.3103, 0.56, 0.3317]}, {"w": "by", "b": [0.5669, 0.3103, 0.587, 0.3317]}, {"w": "value,", "b": [0.5938, 0.3103, 0.6426, 0.3317]}, {"w": "you", "b": [0.6494, 0.3103, 0.6806, 0.3317]}, {"w": "get", "b": [0.6874, 0.3103, 0.7124, 0.3317]}, {"w": "[0.9,", "b": [0.7192, 0.3103, 0.7559, 0.3317]}, {"w": "1.0],", "b": [0.7627, 0.3103, 0.7994, 0.3317]}, {"w": "which", "b": [0.8062, 0.3103, 0.8571, 0.3317]}, {"w": "points", "b": [0.1429, 0.3294, 0.195, 0.3508]}, {"w": "roughly", "b": [0.2054, 0.3294, 0.2705, 0.3508]}, {"w": "in", "b": [0.2809, 0.3294, 0.2979, 0.3508]}, {"w": "the", "b": [0.3083, 0.3294, 0.3346, 0.3508]}, {"w": "diagonal", "b": [0.345, 0.3294, 0.417, 0.3508]}, {"w": "between", "b": [0.4274, 0.3294, 0.4965, 0.3508]}, {"w": "the", "b": [0.5069, 0.3294, 0.5333, 0.3508]}, {"w": "two", "b": [0.5437, 0.3294, 0.5749, 0.3508]}, {"w": "axes.", "b": [0.5853, 0.3294, 0.6256, 0.3508]}, {"w": "In", "b": [0.636, 0.3294, 0.6545, 0.3508]}, {"w": "practice", "b": [0.6649, 0.3294, 0.7311, 0.3508]}, {"w": "however,", "b": [0.7415, 0.3294, 0.816, 0.3508]}, {"w": "this", "b": [0.8264, 0.3294, 0.8571, 0.3508]}, {"w": "approach", "b": [0.1429, 0.3484, 0.2209, 0.3698]}, {"w": "works", "b": [0.2273, 0.3484, 0.2779, 0.3698]}, {"w": "well.", "b": [0.2843, 0.3484, 0.3227, 0.3698]}, {"w": "If", "b": [0.3291, 0.3484, 0.3424, 0.3698]}, {"w": "you", "b": [0.3488, 0.3484, 0.3801, 0.3698]}, {"w": "want", "b": [0.3865, 0.3484, 0.4273, 0.3698]}, {"w": "to", "b": [0.4337, 0.3484, 0.4507, 0.3698]}, {"w": "ensure", "b": [0.4571, 0.3484, 0.5126, 0.3698]}, {"w": "that", "b": [0.519, 0.3484, 0.5516, 0.3698]}, {"w": "Gradient", "b": [0.558, 0.3484, 0.6326, 0.3698]}, {"w": "Clipping", "b": [0.639, 0.3484, 0.7123, 0.3698]}, {"w": "does", "b": [0.7187, 0.3484, 0.7568, 0.3698]}, {"w": "not", "b": [0.7633, 0.3484, 0.7916, 0.3698]}, {"w": "change", "b": [0.7981, 0.3484, 0.8571, 0.3698]}, {"w": "the", "b": [0.1429, 0.3684, 0.1692, 0.3898]}, {"w": "direction", "b": [0.1771, 0.3684, 0.2531, 0.3898]}, {"w": "of", "b": [0.261, 0.3684, 0.2778, 0.3898]}, {"w": "the", "b": [0.2858, 0.3684, 0.3121, 0.3898]}, {"w": "gradient", "b": [0.32, 0.3684, 0.3894, 0.3898]}, {"w": "vector,", "b": [0.3974, 0.3684, 0.4528, 0.3898]}, {"w": "you", "b": [0.4608, 0.3684, 0.492, 0.3898]}, {"w": "should", "b": [0.5, 0.3684, 0.5567, 0.3898]}, {"w": "clip", "b": [0.5647, 0.3684, 0.5952, 0.3898]}, {"w": "by", "b": [0.6032, 0.3684, 0.6233, 0.3898]}, {"w": "norm", "b": [0.6313, 0.3684, 0.6781, 0.3898]}, {"w": "by", "b": [0.686, 0.3684, 0.7062, 0.3898]}, {"w": "setting", "b": [0.7141, 0.3684, 0.77, 0.3898]}, {"w": "clipnorm", "b": [0.778, 0.3716, 0.8571, 0.3866]}, {"w": "instead", "b": [0.1429, 0.3883, 0.2028, 0.4097]}, {"w": "of", "b": [0.2094, 0.3883, 0.2261, 0.4097]}, {"w": "clipvalue.", "b": [0.2327, 0.3883, 0.3265, 0.4097]}, {"w": "This", "b": [0.333, 0.3883, 0.3702, 0.4097]}, {"w": "will", "b": [0.3767, 0.3883, 0.4071, 0.4097]}, {"w": "clip", "b": [0.4136, 0.3883, 0.4442, 0.4097]}, {"w": "the", "b": [0.4507, 0.3883, 0.477, 0.4097]}, {"w": "whole", "b": [0.4835, 0.3883, 0.5337, 0.4097]}, {"w": "gradient", "b": [0.5402, 0.3883, 0.6096, 0.4097]}, {"w": "if", "b": [0.6161, 0.3883, 0.6279, 0.4097]}, {"w": "its", "b": [0.6344, 0.3883, 0.654, 0.4097]}, {"w": "ℓ2", "b": [0.6605, 0.3883, 0.675, 0.4106]}, {"w": "norm", "b": [0.6815, 0.3883, 0.7283, 0.4097]}, {"w": "is", "b": [0.7349, 0.3883, 0.7481, 0.4097]}, {"w": "greater", "b": [0.7546, 0.3883, 0.8126, 0.4097]}, {"w": "than", "b": [0.8191, 0.3883, 0.8571, 0.4097]}, {"w": "the", "b": [0.1429, 0.4083, 0.1692, 0.4297]}, {"w": "threshold", "b": [0.1747, 0.4083, 0.2544, 0.4297]}, {"w": "you", "b": [0.2599, 0.4083, 0.2911, 0.4297]}, {"w": "picked.", "b": [0.2966, 0.4083, 0.3569, 0.4297]}, {"w": "For", "b": [0.3624, 0.4083, 0.3913, 0.4297]}, {"w": "example,", "b": [0.3968, 0.4083, 0.4711, 0.4297]}, {"w": "if", "b": [0.4766, 0.4083, 0.4884, 0.4297]}, {"w": "you", "b": [0.4938, 0.4083, 0.5251, 0.4297]}, {"w": "set", "b": [0.5306, 0.4083, 0.5534, 0.4297]}, {"w": "clipnorm=1.0,", "b": [0.5589, 0.4083, 0.6824, 0.4297]}, {"w": "then", "b": [0.6879, 0.4083, 0.7256, 0.4297]}, {"w": "the", "b": [0.7311, 0.4083, 0.7575, 0.4297]}, {"w": "vector", "b": [0.7629, 0.4083, 0.815, 0.4297]}, {"w": "[0.9,", "b": [0.8205, 0.4083, 0.8571, 0.4297]}, {"w": "100.0]", "b": [0.1429, 0.4273, 0.1948, 0.4487]}, {"w": "will", "b": [0.2045, 0.4273, 0.2349, 0.4487]}, {"w": "be", "b": [0.2446, 0.4273, 0.264, 0.4487]}, {"w": "clipped", "b": [0.2737, 0.4273, 0.335, 0.4487]}, {"w": "to", "b": [0.3447, 0.4273, 0.3617, 0.4487]}, {"w": "[0.00899964,", "b": [0.3714, 0.4273, 0.4781, 0.4487]}, {"w": "0.9999595],", "b": [0.4878, 0.4273, 0.5845, 0.4487]}, {"w": "preserving", "b": [0.5942, 0.4273, 0.6829, 0.4487]}, {"w": "its", "b": [0.6926, 0.4273, 0.7121, 0.4487]}, {"w": "orientation,", "b": [0.7218, 0.4273, 0.8194, 0.4487]}, {"w": "but", "b": [0.8291, 0.4273, 0.8571, 0.4487]}, {"w": "almost", "b": [0.1429, 0.4464, 0.199, 0.4678]}, {"w": "eliminating", "b": [0.2074, 0.4464, 0.303, 0.4678]}, {"w": "the", "b": [0.3114, 0.4464, 0.3377, 0.4678]}, {"w": "first", "b": [0.3461, 0.4464, 0.3796, 0.4678]}, {"w": "component.", "b": [0.388, 0.4464, 0.488, 0.4678]}, {"w": "If", "b": [0.4964, 0.4464, 0.5096, 0.4678]}, {"w": "you", "b": [0.518, 0.4464, 0.5493, 0.4678]}, {"w": "observe", "b": [0.5577, 0.4464, 0.6222, 0.4678]}, {"w": "that", "b": [0.6306, 0.4464, 0.6632, 0.4678]}, {"w": "the", "b": [0.6716, 0.4464, 0.6979, 0.4678]}, {"w": "gradients", "b": [0.7063, 0.4464, 0.7834, 0.4678]}, {"w": "explode", "b": [0.7918, 0.4464, 0.8572, 0.4678]}, {"w": "during", "b": [0.1429, 0.4654, 0.1994, 0.4868]}, {"w": "training", "b": [0.2048, 0.4654, 0.2718, 0.4868]}, {"w": "(you", "b": [0.2772, 0.4654, 0.3157, 0.4868]}, {"w": "can", "b": [0.3212, 0.4654, 0.3505, 0.4868]}, {"w": "track", "b": [0.356, 0.4654, 0.3984, 0.4868]}, {"w": "the", "b": [0.4038, 0.4654, 0.4302, 0.4868]}, {"w": "size", "b": [0.4356, 0.4654, 0.4664, 0.4868]}, {"w": "of", "b": [0.4719, 0.4654, 0.4887, 0.4868]}, {"w": "the", "b": [0.4942, 0.4654, 0.5205, 0.4868]}, {"w": "gradients", "b": [0.526, 0.4654, 0.603, 0.4868]}, {"w": "using", "b": [0.6085, 0.4654, 0.6539, 0.4868]}, {"w": "TensorBoard),", "b": [0.6594, 0.4654, 0.7796, 0.4868]}, {"w": "you", "b": [0.785, 0.4654, 0.8163, 0.4868]}, {"w": "may", "b": [0.8217, 0.4654, 0.8571, 0.4868]}, {"w": "want", "b": [0.1429, 0.4845, 0.1836, 0.5059]}, {"w": "to", "b": [0.191, 0.4845, 0.208, 0.5059]}, {"w": "try", "b": [0.2154, 0.4845, 0.2397, 0.5059]}, {"w": "both", "b": [0.2471, 0.4845, 0.2858, 0.5059]}, {"w": "clipping", "b": [0.2932, 0.4845, 0.3614, 0.5059]}, {"w": "by", "b": [0.3688, 0.4845, 0.3889, 0.5059]}, {"w": "value", "b": [0.3963, 0.4845, 0.4403, 0.5059]}, {"w": "and", "b": [0.4477, 0.4845, 0.4793, 0.5059]}, {"w": "clipping", "b": [0.4867, 0.4845, 0.5549, 0.5059]}, {"w": "by", "b": [0.5623, 0.4845, 0.5824, 0.5059]}, {"w": "norm,", "b": [0.5898, 0.4845, 0.6414, 0.5059]}, {"w": "with", "b": [0.6488, 0.4845, 0.6861, 0.5059]}, {"w": "different", "b": [0.6935, 0.4845, 0.7653, 0.5059]}, {"w": "threshold,", "b": [0.7727, 0.4845, 0.8571, 0.5059]}, {"w": "and", "b": [0.1428, 0.5035, 0.1744, 0.5249]}, {"w": "see", "b": [0.1791, 0.5035, 0.2045, 0.5249]}, {"w": "which", "b": [0.2092, 0.5035, 0.2601, 0.5249]}, {"w": "option", "b": [0.2648, 0.5035, 0.3203, 0.5249]}, {"w": "performs", "b": [0.3251, 0.5035, 0.4018, 0.5249]}, {"w": "best", "b": [0.4065, 0.5035, 0.44, 0.5249]}, {"w": "on", "b": [0.4447, 0.5035, 0.4667, 0.5249]}, {"w": "the", "b": [0.4715, 0.5035, 0.4978, 0.5249]}, {"w": "validation", "b": [0.5025, 0.5035, 0.5859, 0.5249]}, {"w": "set.", "b": [0.5906, 0.5035, 0.6182, 0.5249]}]}, {"id": "b_4", "type": "paragraph", "text": "Reusing Pretrained Layers", "words": [{"w": "Reusing", "b": [0.1429, 0.5379, 0.2419, 0.5722]}, {"w": "Pretrained", "b": [0.2478, 0.5379, 0.3796, 0.5722]}, {"w": "Layers", "b": [0.3855, 0.5379, 0.4646, 0.5722]}]}, {"id": "b_5", "type": "paragraph", "text": "It is generally not a good idea to train a very large DNN from scratch: instead, you should always try to find an existing neural network that accomplishes a similar task to the one you are trying to tackle (we will discuss how to find them in Chapter 14), then just reuse the lower layers of this network: this is called transfer learning. It will not only speed up training considerably, but will also require much less training data.", "words": [{"w": "It", "b": [0.1429, 0.5791, 0.1555, 0.6005]}, {"w": "is", "b": [0.1622, 0.5791, 0.1754, 0.6005]}, {"w": "generally", "b": [0.1821, 0.5791, 0.258, 0.6005]}, {"w": "not", "b": [0.2647, 0.5791, 0.293, 0.6005]}, {"w": "a", "b": [0.2997, 0.5791, 0.3089, 0.6005]}, {"w": "good", "b": [0.3156, 0.5791, 0.3576, 0.6005]}, {"w": "idea", "b": [0.3643, 0.5791, 0.3989, 0.6005]}, {"w": "to", "b": [0.4056, 0.5791, 0.4225, 0.6005]}, {"w": "train", "b": [0.4292, 0.5791, 0.4695, 0.6005]}, {"w": "a", "b": [0.4762, 0.5791, 0.4853, 0.6005]}, {"w": "very", "b": [0.492, 0.5791, 0.5284, 0.6005]}, {"w": "large", "b": [0.5351, 0.5791, 0.5758, 0.6005]}, {"w": "DNN", "b": [0.5825, 0.5791, 0.6288, 0.6005]}, {"w": "from", "b": [0.6355, 0.5791, 0.6771, 0.6005]}, {"w": "scratch:", "b": [0.6838, 0.5791, 0.7478, 0.6005]}, {"w": "instead,", "b": [0.7545, 0.5791, 0.8192, 0.6005]}, {"w": "you", "b": [0.8259, 0.5791, 0.8572, 0.6005]}, {"w": "should", "b": [0.1429, 0.5981, 0.1996, 0.6195]}, {"w": "always", "b": [0.2053, 0.5981, 0.26, 0.6195]}, {"w": "try", "b": [0.2657, 0.5981, 0.29, 0.6195]}, {"w": "to", "b": [0.2957, 0.5981, 0.3127, 0.6195]}, {"w": "find", "b": [0.3184, 0.5981, 0.3526, 0.6195]}, {"w": "an", "b": [0.3583, 0.5981, 0.3789, 0.6195]}, {"w": "existing", "b": [0.3846, 0.5981, 0.4496, 0.6195]}, {"w": "neural", "b": [0.4554, 0.5981, 0.5088, 0.6195]}, {"w": "network", "b": [0.5145, 0.5981, 0.5841, 0.6195]}, {"w": "that", "b": [0.5899, 0.5981, 0.6224, 0.6195]}, {"w": "accomplishes", "b": [0.6282, 0.5981, 0.7393, 0.6195]}, {"w": "a", "b": [0.745, 0.5981, 0.7542, 0.6195]}, {"w": "similar", "b": [0.7599, 0.5981, 0.8179, 0.6195]}, {"w": "task", "b": [0.8237, 0.5981, 0.8571, 0.6195]}, {"w": "to", "b": [0.1429, 0.6172, 0.1598, 0.6386]}, {"w": "the", "b": [0.1657, 0.6172, 0.192, 0.6386]}, {"w": "one", "b": [0.1978, 0.6172, 0.2287, 0.6386]}, {"w": "you", "b": [0.2345, 0.6172, 0.2658, 0.6386]}, {"w": "are", "b": [0.2716, 0.6172, 0.2974, 0.6386]}, {"w": "trying", "b": [0.3032, 0.6172, 0.3542, 0.6386]}, {"w": "to", "b": [0.36, 0.6172, 0.377, 0.6386]}, {"w": "tackle", "b": [0.3828, 0.6172, 0.4316, 0.6386]}, {"w": "(we", "b": [0.4374, 0.6172, 0.4678, 0.6386]}, {"w": "will", "b": [0.4736, 0.6172, 0.504, 0.6386]}, {"w": "discuss", "b": [0.5098, 0.6172, 0.5692, 0.6386]}, {"w": "how", "b": [0.5751, 0.6172, 0.6111, 0.6386]}, {"w": "to", "b": [0.6169, 0.6172, 0.6339, 0.6386]}, {"w": "find", "b": [0.6397, 0.6172, 0.6739, 0.6386]}, {"w": "them", "b": [0.6797, 0.6172, 0.7231, 0.6386]}, {"w": "in", "b": [0.7289, 0.6172, 0.7459, 0.6386]}, {"w": "Chapter", "b": [0.7518, 0.6172, 0.8193, 0.6386]}, {"w": "14),", "b": [0.8252, 0.6172, 0.8571, 0.6386]}, {"w": "then", "b": [0.1428, 0.6362, 0.1806, 0.6576]}, {"w": "just", "b": [0.1866, 0.6362, 0.217, 0.6576]}, {"w": "reuse", "b": [0.2229, 0.6362, 0.2671, 0.6576]}, {"w": "the", "b": [0.2731, 0.6362, 0.2994, 0.6576]}, {"w": "lower", "b": [0.3054, 0.6362, 0.3521, 0.6576]}, {"w": "layers", "b": [0.3581, 0.6362, 0.4059, 0.6576]}, {"w": "of", "b": [0.4119, 0.6362, 0.4287, 0.6576]}, {"w": "this", "b": [0.4347, 0.6362, 0.4654, 0.6576]}, {"w": "network:", "b": [0.4714, 0.6362, 0.5457, 0.6576]}, {"w": "this", "b": [0.5517, 0.6362, 0.5824, 0.6576]}, {"w": "is", "b": [0.5884, 0.6362, 0.6016, 0.6576]}, {"w": "called", "b": [0.6076, 0.6362, 0.656, 0.6576]}, {"w": "transfer", "b": [0.6619, 0.636, 0.7246, 0.6576]}, {"w": "learning.", "b": [0.7307, 0.636, 0.8021, 0.6576]}, {"w": "It", "b": [0.8081, 0.6362, 0.8208, 0.6576]}, {"w": "will", "b": [0.8267, 0.6362, 0.8571, 0.6576]}, {"w": "not", "b": [0.1429, 0.6553, 0.1712, 0.6767]}, {"w": "only", "b": [0.176, 0.6553, 0.2128, 0.6767]}, {"w": "speed", "b": [0.2175, 0.6553, 0.2648, 0.6767]}, {"w": "up", "b": [0.2695, 0.6553, 0.2915, 0.6767]}, {"w": "training", "b": [0.2963, 0.6553, 0.3632, 0.6767]}, {"w": "considerably,", "b": [0.3679, 0.6553, 0.4774, 0.6767]}, {"w": "but", "b": [0.4821, 0.6553, 0.5101, 0.6767]}, {"w": "will", "b": [0.5148, 0.6553, 0.5452, 0.6767]}, {"w": "also", "b": [0.5499, 0.6553, 0.5826, 0.6767]}, {"w": "require", "b": [0.5874, 0.6553, 0.6478, 0.6767]}, {"w": "much", "b": [0.6525, 0.6553, 0.7002, 0.6767]}, {"w": "less", "b": [0.7049, 0.6553, 0.7344, 0.6767]}, {"w": "training", "b": [0.7391, 0.6553, 0.806, 0.6767]}, {"w": "data.", "b": [0.8108, 0.6553, 0.8508, 0.6767]}]}, {"id": "b_6", "type": "paragraph", "text": "For example, suppose that you have access to a DNN that was trained to classify pic‐ tures into 100 different categories, including animals, plants, vehicles, and everyday objects. You now want to train a DNN to classify specific types of vehicles. These tasks are very similar, even partly overlapping, so you should try to reuse parts of the first network (see Figure 11-4).", "words": [{"w": "For", "b": [0.1429, 0.6834, 0.1718, 0.7048]}, {"w": "example,", "b": [0.1775, 0.6834, 0.2517, 0.7048]}, {"w": "suppose", "b": [0.2574, 0.6834, 0.325, 0.7048]}, {"w": "that", "b": [0.3306, 0.6834, 0.3632, 0.7048]}, {"w": "you", "b": [0.3688, 0.6834, 0.4001, 0.7048]}, {"w": "have", "b": [0.4057, 0.6834, 0.4441, 0.7048]}, {"w": "access", "b": [0.4497, 0.6834, 0.5006, 0.7048]}, {"w": "to", "b": [0.5062, 0.6834, 0.5232, 0.7048]}, {"w": "a", "b": [0.5288, 0.6834, 0.538, 0.7048]}, {"w": "DNN", "b": [0.5436, 0.6834, 0.5899, 0.7048]}, {"w": "that", "b": [0.5955, 0.6834, 0.6281, 0.7048]}, {"w": "was", "b": [0.6337, 0.6834, 0.6647, 0.7048]}, {"w": "trained", "b": [0.6703, 0.6834, 0.7304, 0.7048]}, {"w": "to", "b": [0.736, 0.6834, 0.753, 0.7048]}, {"w": "classify", "b": [0.7586, 0.6834, 0.8188, 0.7048]}, {"w": "pic‐", "b": [0.8244, 0.6834, 0.8571, 0.7048]}, {"w": "tures", "b": [0.1429, 0.7024, 0.1845, 0.7239]}, {"w": "into", "b": [0.1913, 0.7024, 0.2249, 0.7239]}, {"w": "100", "b": [0.2317, 0.7024, 0.2617, 0.7239]}, {"w": "different", "b": [0.2685, 0.7024, 0.3402, 0.7239]}, {"w": "categories,", "b": [0.347, 0.7024, 0.4347, 0.7239]}, {"w": "including", "b": [0.4415, 0.7024, 0.5214, 0.7239]}, {"w": "animals,", "b": [0.5282, 0.7024, 0.5982, 0.7239]}, {"w": "plants,", "b": [0.605, 0.7024, 0.6601, 0.7239]}, {"w": "vehicles,", "b": [0.6669, 0.7024, 0.7374, 0.7239]}, {"w": "and", "b": [0.7442, 0.7024, 0.7758, 0.7239]}, {"w": "everyday", "b": [0.7826, 0.7024, 0.8571, 0.7239]}, {"w": "objects.", "b": [0.1428, 0.7215, 0.2058, 0.7429]}, {"w": "You", "b": [0.2136, 0.7215, 0.246, 0.7429]}, {"w": "now", "b": [0.2538, 0.7215, 0.2901, 0.7429]}, {"w": "want", "b": [0.298, 0.7215, 0.3387, 0.7429]}, {"w": "to", "b": [0.3466, 0.7215, 0.3636, 0.7429]}, {"w": "train", "b": [0.3714, 0.7215, 0.4116, 0.7429]}, {"w": "a", "b": [0.4195, 0.7215, 0.4286, 0.7429]}, {"w": "DNN", "b": [0.4364, 0.7215, 0.4827, 0.7429]}, {"w": "to", "b": [0.4906, 0.7215, 0.5075, 0.7429]}, {"w": "classify", "b": [0.5154, 0.7215, 0.5756, 0.7429]}, {"w": "specific", "b": [0.5834, 0.7215, 0.6458, 0.7429]}, {"w": "types", "b": [0.6536, 0.7215, 0.6969, 0.7429]}, {"w": "of", "b": [0.7048, 0.7215, 0.7216, 0.7429]}, {"w": "vehicles.", "b": [0.7294, 0.7215, 0.8, 0.7429]}, {"w": "These", "b": [0.8078, 0.7215, 0.8571, 0.7429]}, {"w": "tasks", "b": [0.1429, 0.7405, 0.184, 0.762]}, {"w": "are", "b": [0.1894, 0.7405, 0.2151, 0.762]}, {"w": "very", "b": [0.2205, 0.7405, 0.2569, 0.762]}, {"w": "similar,", "b": [0.2623, 0.7405, 0.3238, 0.762]}, {"w": "even", "b": [0.3292, 0.7405, 0.368, 0.762]}, {"w": "partly", "b": [0.3734, 0.7405, 0.4223, 0.762]}, {"w": "overlapping,", "b": [0.4277, 0.7405, 0.5319, 0.762]}, {"w": "so", "b": [0.5373, 0.7405, 0.5556, 0.762]}, {"w": "you", "b": [0.561, 0.7405, 0.5923, 0.762]}, {"w": "should", "b": [0.5977, 0.7405, 0.6544, 0.762]}, {"w": "try", "b": [0.6598, 0.7405, 0.6841, 0.762]}, {"w": "to", "b": [0.6895, 0.7405, 0.7065, 0.762]}, {"w": "reuse", "b": [0.7119, 0.7405, 0.756, 0.762]}, {"w": "parts", "b": [0.7614, 0.7405, 0.8032, 0.762]}, {"w": "of", "b": [0.8086, 0.7405, 0.8254, 0.762]}, {"w": "the", "b": [0.8308, 0.7405, 0.8572, 0.762]}, {"w": "first", "b": [0.1429, 0.7596, 0.1763, 0.781]}, {"w": "network", "b": [0.1811, 0.7596, 0.2506, 0.781]}, {"w": "(see", "b": [0.2554, 0.7596, 0.2879, 0.781]}, {"w": "Figure", "b": [0.2927, 0.7596, 0.3467, 0.781]}, {"w": "11-4).", "b": [0.3514, 0.7596, 0.4008, 0.781]}]}, {"id": "b_7", "type": "paragraph", "text": "Reusing Pretrained Layers | 339", "words": [{"w": "Reusing", "b": [0.6428, 0.9225, 0.6899, 0.9388]}, {"w": "Pretrained", "b": [0.6927, 0.9225, 0.7554, 0.9388]}, {"w": "Layers", "b": [0.7582, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "339", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 366, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 11-4. Reusing pretrained layers", "words": [{"w": "Figure", "b": [0.1429, 0.3747, 0.1943, 0.3963]}, {"w": "11-4.", "b": [0.1991, 0.3747, 0.2407, 0.3963]}, {"w": "Reusing", "b": [0.2455, 0.3747, 0.3092, 0.3963]}, {"w": "pretrained", "b": [0.314, 0.3747, 0.3978, 0.3963]}, {"w": "layers", "b": [0.4026, 0.3747, 0.4494, 0.3963]}]}, {"id": "b_1", "type": "paragraph", "text": "If the input pictures of your new task don’t have the same size as the ones used in the original task, you will usually have to add a preprocessing step to resize them to the size expected by the origi‐ nal model. More generally, transfer learning will work best when the inputs have similar low-level features.", "words": [{"w": "If", "b": [0.2714, 0.4168, 0.2835, 0.4364]}, {"w": "the", "b": [0.2899, 0.4168, 0.314, 0.4364]}, {"w": "input", "b": [0.3204, 0.4168, 0.3614, 0.4364]}, {"w": "pictures", "b": [0.3678, 0.4168, 0.429, 0.4364]}, {"w": "of", "b": [0.4354, 0.4168, 0.4507, 0.4364]}, {"w": "your", "b": [0.4571, 0.4168, 0.4927, 0.4364]}, {"w": "new", "b": [0.4991, 0.4168, 0.5307, 0.4364]}, {"w": "task", "b": [0.5371, 0.4168, 0.5677, 0.4364]}, {"w": "don’t", "b": [0.574, 0.4168, 0.6121, 0.4364]}, {"w": "have", "b": [0.6184, 0.4168, 0.6536, 0.4364]}, {"w": "the", "b": [0.6599, 0.4168, 0.684, 0.4364]}, {"w": "same", "b": [0.6904, 0.4168, 0.7294, 0.4364]}, {"w": "size", "b": [0.7358, 0.4168, 0.764, 0.4364]}, {"w": "as", "b": [0.7704, 0.4168, 0.7857, 0.4364]}, {"w": "the", "b": [0.2714, 0.4343, 0.2955, 0.4538]}, {"w": "ones", "b": [0.3022, 0.4343, 0.3375, 0.4538]}, {"w": "used", "b": [0.3442, 0.4343, 0.3795, 0.4538]}, {"w": "in", "b": [0.3862, 0.4343, 0.4018, 0.4538]}, {"w": "the", "b": [0.4085, 0.4343, 0.4326, 0.4538]}, {"w": "original", "b": [0.4394, 0.4343, 0.4989, 0.4538]}, {"w": "task,", "b": [0.5056, 0.4343, 0.5406, 0.4538]}, {"w": "you", "b": [0.5473, 0.4343, 0.5759, 0.4538]}, {"w": "will", "b": [0.5827, 0.4343, 0.6105, 0.4538]}, {"w": "usually", "b": [0.6172, 0.4343, 0.6712, 0.4538]}, {"w": "have", "b": [0.678, 0.4343, 0.7131, 0.4538]}, {"w": "to", "b": [0.7198, 0.4343, 0.7353, 0.4538]}, {"w": "add", "b": [0.7421, 0.4343, 0.7706, 0.4538]}, {"w": "a", "b": [0.7773, 0.4343, 0.7857, 0.4538]}, {"w": "preprocessing", "b": [0.2714, 0.4517, 0.3779, 0.4712]}, {"w": "step", "b": [0.3832, 0.4517, 0.414, 0.4712]}, {"w": "to", "b": [0.4193, 0.4517, 0.4349, 0.4712]}, {"w": "resize", "b": [0.4402, 0.4517, 0.4835, 0.4712]}, {"w": "them", "b": [0.4888, 0.4517, 0.5285, 0.4712]}, {"w": "to", "b": [0.5338, 0.4517, 0.5493, 0.4712]}, {"w": "the", "b": [0.5546, 0.4517, 0.5787, 0.4712]}, {"w": "size", "b": [0.584, 0.4517, 0.6122, 0.4712]}, {"w": "expected", "b": [0.6175, 0.4517, 0.6846, 0.4712]}, {"w": "by", "b": [0.6899, 0.4517, 0.7084, 0.4712]}, {"w": "the", "b": [0.7136, 0.4517, 0.7377, 0.4712]}, {"w": "origi‐", "b": [0.743, 0.4517, 0.7857, 0.4712]}, {"w": "nal", "b": [0.2714, 0.4691, 0.295, 0.4887]}, {"w": "model.", "b": [0.3019, 0.4691, 0.3546, 0.4887]}, {"w": "More", "b": [0.3615, 0.4691, 0.4029, 0.4887]}, {"w": "generally,", "b": [0.4098, 0.4691, 0.4821, 0.4887]}, {"w": "transfer", "b": [0.489, 0.4691, 0.5485, 0.4887]}, {"w": "learning", "b": [0.5554, 0.4691, 0.6186, 0.4887]}, {"w": "will", "b": [0.6255, 0.4691, 0.6533, 0.4887]}, {"w": "work", "b": [0.6603, 0.4691, 0.6995, 0.4887]}, {"w": "best", "b": [0.7065, 0.4691, 0.737, 0.4887]}, {"w": "when", "b": [0.744, 0.4691, 0.7857, 0.4887]}, {"w": "the", "b": [0.2714, 0.4865, 0.2955, 0.5061]}, {"w": "inputs", "b": [0.2998, 0.4865, 0.3479, 0.5061]}, {"w": "have", "b": [0.3522, 0.4865, 0.3873, 0.5061]}, {"w": "similar", "b": [0.3916, 0.4865, 0.4447, 0.5061]}, {"w": "low-level", "b": [0.449, 0.4865, 0.518, 0.5061]}, {"w": "features.", "b": [0.5223, 0.4865, 0.5865, 0.5061]}]}, {"id": "b_2", "type": "paragraph", "text": "The output layer of the original model should usually be replaced since it is most likely not useful at all for the new task, and it may not even have the right number of outputs for the new task.", "words": [{"w": "The", "b": [0.1429, 0.5264, 0.1757, 0.5478]}, {"w": "output", "b": [0.1835, 0.5264, 0.2399, 0.5478]}, {"w": "layer", "b": [0.2476, 0.5264, 0.2878, 0.5478]}, {"w": "of", "b": [0.2956, 0.5264, 0.3124, 0.5478]}, {"w": "the", "b": [0.3202, 0.5264, 0.3465, 0.5478]}, {"w": "original", "b": [0.3543, 0.5264, 0.4194, 0.5478]}, {"w": "model", "b": [0.4272, 0.5264, 0.48, 0.5478]}, {"w": "should", "b": [0.4878, 0.5264, 0.5445, 0.5478]}, {"w": "usually", "b": [0.5523, 0.5264, 0.6113, 0.5478]}, {"w": "be", "b": [0.6191, 0.5264, 0.6385, 0.5478]}, {"w": "replaced", "b": [0.6463, 0.5264, 0.7169, 0.5478]}, {"w": "since", "b": [0.7247, 0.5264, 0.767, 0.5478]}, {"w": "it", "b": [0.7747, 0.5264, 0.7867, 0.5478]}, {"w": "is", "b": [0.7945, 0.5264, 0.8077, 0.5478]}, {"w": "most", "b": [0.8155, 0.5264, 0.8572, 0.5478]}, {"w": "likely", "b": [0.1429, 0.5454, 0.1877, 0.5668]}, {"w": "not", "b": [0.1932, 0.5454, 0.2216, 0.5668]}, {"w": "useful", "b": [0.2271, 0.5454, 0.2771, 0.5668]}, {"w": "at", "b": [0.2826, 0.5454, 0.2977, 0.5668]}, {"w": "all", "b": [0.3032, 0.5454, 0.3229, 0.5668]}, {"w": "for", "b": [0.3284, 0.5454, 0.3529, 0.5668]}, {"w": "the", "b": [0.3584, 0.5454, 0.3847, 0.5668]}, {"w": "new", "b": [0.3902, 0.5454, 0.4247, 0.5668]}, {"w": "task,", "b": [0.4302, 0.5454, 0.4684, 0.5668]}, {"w": "and", "b": [0.4739, 0.5454, 0.5054, 0.5668]}, {"w": "it", "b": [0.5109, 0.5454, 0.5228, 0.5668]}, {"w": "may", "b": [0.5283, 0.5454, 0.5637, 0.5668]}, {"w": "not", "b": [0.5692, 0.5454, 0.5976, 0.5668]}, {"w": "even", "b": [0.603, 0.5454, 0.6418, 0.5668]}, {"w": "have", "b": [0.6473, 0.5454, 0.6857, 0.5668]}, {"w": "the", "b": [0.6911, 0.5454, 0.7175, 0.5668]}, {"w": "right", "b": [0.723, 0.5454, 0.7631, 0.5668]}, {"w": "number", "b": [0.7686, 0.5454, 0.8349, 0.5668]}, {"w": "of", "b": [0.8404, 0.5454, 0.8571, 0.5668]}, {"w": "outputs", "b": [0.1429, 0.5645, 0.2069, 0.5859]}, {"w": "for", "b": [0.2116, 0.5645, 0.2361, 0.5859]}, {"w": "the", "b": [0.2409, 0.5645, 0.2672, 0.5859]}, {"w": "new", "b": [0.2719, 0.5645, 0.3064, 0.5859]}, {"w": "task.", "b": [0.3112, 0.5645, 0.3494, 0.5859]}]}, {"id": "b_3", "type": "paragraph", "text": "Similarly, the upper hidden layers of the original model are less likely to be as useful as the lower layers, since the high-level features that are most useful for the new task may differ significantly from the ones that were most useful for the original task. You want to find the right number of layers to reuse.", "words": [{"w": "Similarly,", "b": [0.1429, 0.5926, 0.2212, 0.614]}, {"w": "the", "b": [0.2271, 0.5926, 0.2534, 0.614]}, {"w": "upper", "b": [0.2594, 0.5926, 0.3089, 0.614]}, {"w": "hidden", "b": [0.3148, 0.5926, 0.3737, 0.614]}, {"w": "layers", "b": [0.3797, 0.5926, 0.4275, 0.614]}, {"w": "of", "b": [0.4335, 0.5926, 0.4502, 0.614]}, {"w": "the", "b": [0.4562, 0.5926, 0.4825, 0.614]}, {"w": "original", "b": [0.4885, 0.5926, 0.5535, 0.614]}, {"w": "model", "b": [0.5595, 0.5926, 0.6123, 0.614]}, {"w": "are", "b": [0.6182, 0.5926, 0.644, 0.614]}, {"w": "less", "b": [0.6499, 0.5926, 0.6793, 0.614]}, {"w": "likely", "b": [0.6852, 0.5926, 0.7301, 0.614]}, {"w": "to", "b": [0.7361, 0.5926, 0.753, 0.614]}, {"w": "be", "b": [0.759, 0.5926, 0.7784, 0.614]}, {"w": "as", "b": [0.7843, 0.5926, 0.8011, 0.614]}, {"w": "useful", "b": [0.8071, 0.5926, 0.8571, 0.614]}, {"w": "as", "b": [0.1428, 0.6116, 0.1596, 0.633]}, {"w": "the", "b": [0.1654, 0.6116, 0.1917, 0.633]}, {"w": "lower", "b": [0.1974, 0.6116, 0.2442, 0.633]}, {"w": "layers,", "b": [0.2499, 0.6116, 0.3025, 0.633]}, {"w": "since", "b": [0.3082, 0.6116, 0.3505, 0.633]}, {"w": "the", "b": [0.3563, 0.6116, 0.3826, 0.633]}, {"w": "high-level", "b": [0.3883, 0.6116, 0.4712, 0.633]}, {"w": "features", "b": [0.4769, 0.6116, 0.5424, 0.633]}, {"w": "that", "b": [0.5481, 0.6116, 0.5807, 0.633]}, {"w": "are", "b": [0.5864, 0.6116, 0.6121, 0.633]}, {"w": "most", "b": [0.6179, 0.6116, 0.6596, 0.633]}, {"w": "useful", "b": [0.6653, 0.6116, 0.7154, 0.633]}, {"w": "for", "b": [0.7211, 0.6116, 0.7456, 0.633]}, {"w": "the", "b": [0.7513, 0.6116, 0.7777, 0.633]}, {"w": "new", "b": [0.7834, 0.6116, 0.8179, 0.633]}, {"w": "task", "b": [0.8237, 0.6116, 0.8571, 0.633]}, {"w": "may", "b": [0.1429, 0.6307, 0.1783, 0.6521]}, {"w": "differ", "b": [0.1836, 0.6307, 0.2291, 0.6521]}, {"w": "significantly", "b": [0.2344, 0.6307, 0.3363, 0.6521]}, {"w": "from", "b": [0.3416, 0.6307, 0.3832, 0.6521]}, {"w": "the", "b": [0.3885, 0.6307, 0.4148, 0.6521]}, {"w": "ones", "b": [0.4201, 0.6307, 0.4587, 0.6521]}, {"w": "that", "b": [0.464, 0.6307, 0.4966, 0.6521]}, {"w": "were", "b": [0.5019, 0.6307, 0.5416, 0.6521]}, {"w": "most", "b": [0.5469, 0.6307, 0.5886, 0.6521]}, {"w": "useful", "b": [0.5939, 0.6307, 0.644, 0.6521]}, {"w": "for", "b": [0.6493, 0.6307, 0.6739, 0.6521]}, {"w": "the", "b": [0.6792, 0.6307, 0.7055, 0.6521]}, {"w": "original", "b": [0.7108, 0.6307, 0.7759, 0.6521]}, {"w": "task.", "b": [0.7812, 0.6307, 0.8195, 0.6521]}, {"w": "You", "b": [0.8248, 0.6307, 0.8571, 0.6521]}, {"w": "want", "b": [0.1429, 0.6497, 0.1836, 0.6711]}, {"w": "to", "b": [0.1884, 0.6497, 0.2053, 0.6711]}, {"w": "find", "b": [0.2101, 0.6497, 0.2442, 0.6711]}, {"w": "the", "b": [0.2489, 0.6497, 0.2753, 0.6711]}, {"w": "right", "b": [0.28, 0.6497, 0.3201, 0.6711]}, {"w": "number", "b": [0.3249, 0.6497, 0.3912, 0.6711]}, {"w": "of", "b": [0.3959, 0.6497, 0.4127, 0.6711]}, {"w": "layers", "b": [0.4174, 0.6497, 0.4653, 0.6711]}, {"w": "to", "b": [0.47, 0.6497, 0.487, 0.6711]}, {"w": "reuse.", "b": [0.4917, 0.6497, 0.5406, 0.6711]}]}, {"id": "b_4", "type": "paragraph", "text": "The more similar the tasks are, the more layers you want to reuse (starting with the lower layers). For very similar tasks, you can try keeping all the hidden layers and just replace the output layer.", "words": [{"w": "The", "b": [0.2714, 0.6917, 0.3014, 0.7112]}, {"w": "more", "b": [0.3074, 0.6917, 0.3478, 0.7112]}, {"w": "similar", "b": [0.3538, 0.6917, 0.4068, 0.7112]}, {"w": "the", "b": [0.4127, 0.6917, 0.4368, 0.7112]}, {"w": "tasks", "b": [0.4428, 0.6917, 0.4804, 0.7112]}, {"w": "are,", "b": [0.4863, 0.6917, 0.5142, 0.7112]}, {"w": "the", "b": [0.5201, 0.6917, 0.5442, 0.7112]}, {"w": "more", "b": [0.5501, 0.6917, 0.5906, 0.7112]}, {"w": "layers", "b": [0.5965, 0.6917, 0.6402, 0.7112]}, {"w": "you", "b": [0.6462, 0.6917, 0.6747, 0.7112]}, {"w": "want", "b": [0.6807, 0.6917, 0.718, 0.7112]}, {"w": "to", "b": [0.7239, 0.6917, 0.7394, 0.7112]}, {"w": "reuse", "b": [0.7453, 0.6917, 0.7857, 0.7112]}, {"w": "(starting", "b": [0.2714, 0.7091, 0.3365, 0.7287]}, {"w": "with", "b": [0.342, 0.7091, 0.3762, 0.7287]}, {"w": "the", "b": [0.3817, 0.7091, 0.4058, 0.7287]}, {"w": "lower", "b": [0.4114, 0.7091, 0.4541, 0.7287]}, {"w": "layers).", "b": [0.4597, 0.7091, 0.5144, 0.7287]}, {"w": "For", "b": [0.5199, 0.7091, 0.5464, 0.7287]}, {"w": "very", "b": [0.552, 0.7091, 0.5853, 0.7287]}, {"w": "similar", "b": [0.5909, 0.7091, 0.6439, 0.7287]}, {"w": "tasks,", "b": [0.6495, 0.7091, 0.6914, 0.7287]}, {"w": "you", "b": [0.697, 0.7091, 0.7256, 0.7287]}, {"w": "can", "b": [0.7311, 0.7091, 0.758, 0.7287]}, {"w": "try", "b": [0.7635, 0.7091, 0.7857, 0.7287]}, {"w": "keeping", "b": [0.2714, 0.7265, 0.3315, 0.7461]}, {"w": "all", "b": [0.3358, 0.7265, 0.3538, 0.7461]}, {"w": "the", "b": [0.3581, 0.7265, 0.3822, 0.7461]}, {"w": "hidden", "b": [0.3865, 0.7265, 0.4404, 0.7461]}, {"w": "layers", "b": [0.4447, 0.7265, 0.4885, 0.7461]}, {"w": "and", "b": [0.4928, 0.7265, 0.5216, 0.7461]}, {"w": "just", "b": [0.526, 0.7265, 0.5537, 0.7461]}, {"w": "replace", "b": [0.5581, 0.7265, 0.6125, 0.7461]}, {"w": "the", "b": [0.6169, 0.7265, 0.6409, 0.7461]}, {"w": "output", "b": [0.6453, 0.7265, 0.6968, 0.7461]}, {"w": "layer.", "b": [0.7011, 0.7265, 0.741, 0.7461]}]}, {"id": "b_5", "type": "paragraph", "text": "Try freezing all the reused layers first (i.e., make their weights non-trainable, so gradi‐ ent descent won’t modify them), then train your model and see how it performs. Then try unfreezing one or two of the top hidden layers to let backpropagation tweak them and see if performance improves. The more training data you have, the more", "words": [{"w": "Try", "b": [0.1429, 0.7903, 0.1719, 0.8117]}, {"w": "freezing", "b": [0.1767, 0.7903, 0.2438, 0.8117]}, {"w": "all", "b": [0.2487, 0.7903, 0.2683, 0.8117]}, {"w": "the", "b": [0.2732, 0.7903, 0.2995, 0.8117]}, {"w": "reused", "b": [0.3044, 0.7903, 0.3595, 0.8117]}, {"w": "layers", "b": [0.3644, 0.7903, 0.4122, 0.8117]}, {"w": "first", "b": [0.4171, 0.7903, 0.4505, 0.8117]}, {"w": "(i.e.,", "b": [0.4554, 0.7903, 0.4913, 0.8117]}, {"w": "make", "b": [0.4961, 0.7903, 0.5415, 0.8117]}, {"w": "their", "b": [0.5464, 0.7903, 0.586, 0.8117]}, {"w": "weights", "b": [0.5909, 0.7903, 0.6541, 0.8117]}, {"w": "non-trainable,", "b": [0.6589, 0.7903, 0.7786, 0.8117]}, {"w": "so", "b": [0.7834, 0.7903, 0.8017, 0.8117]}, {"w": "gradi‐", "b": [0.8065, 0.7903, 0.8571, 0.8117]}, {"w": "ent", "b": [0.1429, 0.8094, 0.1691, 0.8308]}, {"w": "descent", "b": [0.1774, 0.8094, 0.24, 0.8308]}, {"w": "won’t", "b": [0.2483, 0.8094, 0.2932, 0.8308]}, {"w": "modify", "b": [0.3016, 0.8094, 0.3619, 0.8308]}, {"w": "them),", "b": [0.3703, 0.8094, 0.4257, 0.8308]}, {"w": "then", "b": [0.4341, 0.8094, 0.4718, 0.8308]}, {"w": "train", "b": [0.4802, 0.8094, 0.5204, 0.8308]}, {"w": "your", "b": [0.5287, 0.8094, 0.5677, 0.8308]}, {"w": "model", "b": [0.5761, 0.8094, 0.6289, 0.8308]}, {"w": "and", "b": [0.6373, 0.8094, 0.6688, 0.8308]}, {"w": "see", "b": [0.6772, 0.8094, 0.7026, 0.8308]}, {"w": "how", "b": [0.7109, 0.8094, 0.747, 0.8308]}, {"w": "it", "b": [0.7553, 0.8094, 0.7673, 0.8308]}, {"w": "performs.", "b": [0.7757, 0.8094, 0.8571, 0.8308]}, {"w": "Then", "b": [0.1428, 0.8284, 0.1871, 0.8498]}, {"w": "try", "b": [0.1921, 0.8284, 0.2164, 0.8498]}, {"w": "unfreezing", "b": [0.2215, 0.8284, 0.311, 0.8498]}, {"w": "one", "b": [0.3161, 0.8284, 0.3469, 0.8498]}, {"w": "or", "b": [0.352, 0.8284, 0.3704, 0.8498]}, {"w": "two", "b": [0.3754, 0.8284, 0.4067, 0.8498]}, {"w": "of", "b": [0.4117, 0.8284, 0.4285, 0.8498]}, {"w": "the", "b": [0.4336, 0.8284, 0.4599, 0.8498]}, {"w": "top", "b": [0.465, 0.8284, 0.4929, 0.8498]}, {"w": "hidden", "b": [0.4979, 0.8284, 0.5569, 0.8498]}, {"w": "layers", "b": [0.562, 0.8284, 0.6098, 0.8498]}, {"w": "to", "b": [0.6149, 0.8284, 0.6318, 0.8498]}, {"w": "let", "b": [0.6369, 0.8284, 0.6574, 0.8498]}, {"w": "backpropagation", "b": [0.6624, 0.8284, 0.8031, 0.8498]}, {"w": "tweak", "b": [0.8082, 0.8284, 0.8571, 0.8498]}, {"w": "them", "b": [0.1429, 0.8475, 0.1863, 0.8689]}, {"w": "and", "b": [0.193, 0.8475, 0.2246, 0.8689]}, {"w": "see", "b": [0.2314, 0.8475, 0.2567, 0.8689]}, {"w": "if", "b": [0.2635, 0.8475, 0.2753, 0.8689]}, {"w": "performance", "b": [0.2821, 0.8475, 0.3893, 0.8689]}, {"w": "improves.", "b": [0.3961, 0.8475, 0.4786, 0.8689]}, {"w": "The", "b": [0.4853, 0.8475, 0.5182, 0.8689]}, {"w": "more", "b": [0.525, 0.8475, 0.5692, 0.8689]}, {"w": "training", "b": [0.576, 0.8475, 0.643, 0.8689]}, {"w": "data", "b": [0.6497, 0.8475, 0.685, 0.8689]}, {"w": "you", "b": [0.6918, 0.8475, 0.723, 0.8689]}, {"w": "have,", "b": [0.7298, 0.8475, 0.773, 0.8689]}, {"w": "the", "b": [0.7798, 0.8475, 0.8061, 0.8689]}, {"w": "more", "b": [0.8129, 0.8475, 0.8571, 0.8689]}]}, {"id": "b_6", "type": "paragraph", "text": "340 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "340", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2746, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3265, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 367, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "layers you can unfreeze. It is also useful to reduce the learning rate when you unfreeze reused layers: this will avoid wrecking their fine-tuned weights.", "words": [{"w": "layers", "b": [0.1429, 0.0791, 0.1907, 0.1005]}, {"w": "you", "b": [0.1955, 0.0791, 0.2267, 0.1005]}, {"w": "can", "b": [0.2315, 0.0791, 0.2609, 0.1005]}, {"w": "unfreeze.", "b": [0.2657, 0.0791, 0.3421, 0.1005]}, {"w": "It", "b": [0.3469, 0.0791, 0.3595, 0.1005]}, {"w": "is", "b": [0.3643, 0.0791, 0.3775, 0.1005]}, {"w": "also", "b": [0.3823, 0.0791, 0.415, 0.1005]}, {"w": "useful", "b": [0.4198, 0.0791, 0.4698, 0.1005]}, {"w": "to", "b": [0.4746, 0.0791, 0.4916, 0.1005]}, {"w": "reduce", "b": [0.4964, 0.0791, 0.5527, 0.1005]}, {"w": "the", "b": [0.5575, 0.0791, 0.5838, 0.1005]}, {"w": "learning", "b": [0.5886, 0.0791, 0.6577, 0.1005]}, {"w": "rate", "b": [0.6625, 0.0791, 0.6942, 0.1005]}, {"w": "when", "b": [0.699, 0.0791, 0.7447, 0.1005]}, {"w": "you", "b": [0.7494, 0.0791, 0.7807, 0.1005]}, {"w": "unfreeze", "b": [0.7855, 0.0791, 0.8571, 0.1005]}, {"w": "reused", "b": [0.1429, 0.0981, 0.198, 0.1195]}, {"w": "layers:", "b": [0.2027, 0.0981, 0.2553, 0.1195]}, {"w": "this", "b": [0.26, 0.0981, 0.2907, 0.1195]}, {"w": "will", "b": [0.2955, 0.0981, 0.3259, 0.1195]}, {"w": "avoid", "b": [0.3306, 0.0981, 0.3762, 0.1195]}, {"w": "wrecking", "b": [0.381, 0.0981, 0.4577, 0.1195]}, {"w": "their", "b": [0.4624, 0.0981, 0.5021, 0.1195]}, {"w": "fine-tuned", "b": [0.5068, 0.0981, 0.5949, 0.1195]}, {"w": "weights.", "b": [0.5996, 0.0981, 0.6675, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "If you still cannot get good performance, and you have little training data, try drop‐ ping the top hidden layer(s) and freeze all remaining hidden layers again. You can iterate until you find the right number of layers to reuse. If you have plenty of train‐ ing data, you may try replacing the top hidden layers instead of dropping them, and even add more hidden layers.", "words": [{"w": "If", "b": [0.1429, 0.1262, 0.1561, 0.1476]}, {"w": "you", "b": [0.1622, 0.1262, 0.1935, 0.1476]}, {"w": "still", "b": [0.1995, 0.1262, 0.2297, 0.1476]}, {"w": "cannot", "b": [0.2357, 0.1262, 0.2935, 0.1476]}, {"w": "get", "b": [0.2996, 0.1262, 0.3245, 0.1476]}, {"w": "good", "b": [0.3306, 0.1262, 0.3726, 0.1476]}, {"w": "performance,", "b": [0.3787, 0.1262, 0.4907, 0.1476]}, {"w": "and", "b": [0.4968, 0.1262, 0.5283, 0.1476]}, {"w": "you", "b": [0.5344, 0.1262, 0.5657, 0.1476]}, {"w": "have", "b": [0.5718, 0.1262, 0.6102, 0.1476]}, {"w": "little", "b": [0.6162, 0.1262, 0.6539, 0.1476]}, {"w": "training", "b": [0.66, 0.1262, 0.727, 0.1476]}, {"w": "data,", "b": [0.733, 0.1262, 0.773, 0.1476]}, {"w": "try", "b": [0.7791, 0.1262, 0.8034, 0.1476]}, {"w": "drop‐", "b": [0.8094, 0.1262, 0.8571, 0.1476]}, {"w": "ping", "b": [0.1429, 0.1453, 0.1805, 0.1667]}, {"w": "the", "b": [0.1879, 0.1453, 0.2142, 0.1667]}, {"w": "top", "b": [0.2216, 0.1453, 0.2495, 0.1667]}, {"w": "hidden", "b": [0.2569, 0.1453, 0.3159, 0.1667]}, {"w": "layer(s)", "b": [0.3232, 0.1453, 0.3855, 0.1667]}, {"w": "and", "b": [0.3929, 0.1453, 0.4244, 0.1667]}, {"w": "freeze", "b": [0.4318, 0.1453, 0.481, 0.1667]}, {"w": "all", "b": [0.4884, 0.1453, 0.5081, 0.1667]}, {"w": "remaining", "b": [0.5155, 0.1453, 0.602, 0.1667]}, {"w": "hidden", "b": [0.6093, 0.1453, 0.6683, 0.1667]}, {"w": "layers", "b": [0.6757, 0.1453, 0.7235, 0.1667]}, {"w": "again.", "b": [0.7309, 0.1453, 0.7807, 0.1667]}, {"w": "You", "b": [0.7881, 0.1453, 0.8204, 0.1667]}, {"w": "can", "b": [0.8278, 0.1453, 0.8572, 0.1667]}, {"w": "iterate", "b": [0.1429, 0.1643, 0.1953, 0.1857]}, {"w": "until", "b": [0.2013, 0.1643, 0.2405, 0.1857]}, {"w": "you", "b": [0.2464, 0.1643, 0.2777, 0.1857]}, {"w": "find", "b": [0.2836, 0.1643, 0.3177, 0.1857]}, {"w": "the", "b": [0.3237, 0.1643, 0.35, 0.1857]}, {"w": "right", "b": [0.3559, 0.1643, 0.396, 0.1857]}, {"w": "number", "b": [0.402, 0.1643, 0.4682, 0.1857]}, {"w": "of", "b": [0.4742, 0.1643, 0.4909, 0.1857]}, {"w": "layers", "b": [0.4969, 0.1643, 0.5447, 0.1857]}, {"w": "to", "b": [0.5506, 0.1643, 0.5676, 0.1857]}, {"w": "reuse.", "b": [0.5735, 0.1643, 0.6224, 0.1857]}, {"w": "If", "b": [0.6283, 0.1643, 0.6416, 0.1857]}, {"w": "you", "b": [0.6475, 0.1643, 0.6787, 0.1857]}, {"w": "have", "b": [0.6846, 0.1643, 0.723, 0.1857]}, {"w": "plenty", "b": [0.7289, 0.1643, 0.7809, 0.1857]}, {"w": "of", "b": [0.7868, 0.1643, 0.8036, 0.1857]}, {"w": "train‐", "b": [0.8095, 0.1643, 0.8571, 0.1857]}, {"w": "ing", "b": [0.1429, 0.1834, 0.1696, 0.2048]}, {"w": "data,", "b": [0.1756, 0.1834, 0.2156, 0.2048]}, {"w": "you", "b": [0.2216, 0.1834, 0.2528, 0.2048]}, {"w": "may", "b": [0.2588, 0.1834, 0.2942, 0.2048]}, {"w": "try", "b": [0.3002, 0.1834, 0.3244, 0.2048]}, {"w": "replacing", "b": [0.3304, 0.1834, 0.4079, 0.2048]}, {"w": "the", "b": [0.4139, 0.1834, 0.4402, 0.2048]}, {"w": "top", "b": [0.4462, 0.1834, 0.4741, 0.2048]}, {"w": "hidden", "b": [0.4801, 0.1834, 0.539, 0.2048]}, {"w": "layers", "b": [0.545, 0.1834, 0.5928, 0.2048]}, {"w": "instead", "b": [0.5988, 0.1834, 0.6588, 0.2048]}, {"w": "of", "b": [0.6648, 0.1834, 0.6816, 0.2048]}, {"w": "dropping", "b": [0.6876, 0.1834, 0.7655, 0.2048]}, {"w": "them,", "b": [0.7715, 0.1834, 0.8196, 0.2048]}, {"w": "and", "b": [0.8256, 0.1834, 0.8571, 0.2048]}, {"w": "even", "b": [0.1428, 0.2024, 0.1816, 0.2238]}, {"w": "add", "b": [0.1863, 0.2024, 0.2175, 0.2238]}, {"w": "more", "b": [0.2222, 0.2024, 0.2665, 0.2238]}, {"w": "hidden", "b": [0.2712, 0.2024, 0.3302, 0.2238]}, {"w": "layers.", "b": [0.3349, 0.2024, 0.3875, 0.2238]}]}, {"id": "b_2", "type": "paragraph", "text": "Transfer Learning With Keras", "words": [{"w": "Transfer", "b": [0.1429, 0.2366, 0.2278, 0.2652]}, {"w": "Learning", "b": [0.2327, 0.2366, 0.3242, 0.2652]}, {"w": "With", "b": [0.3292, 0.2366, 0.379, 0.2652]}, {"w": "Keras", "b": [0.384, 0.2366, 0.4404, 0.2652]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s look at an example. Suppose the fashion MNIST dataset only contained 8 classes, for example all classes except for sandals and shirts. Someone built and trained a Keras model on that set and got reasonably good performance (>90% accuracy). Let’s call this model A. You now want to tackle a different task: you have images of sandals and shirts, and you want to train a binary classifier (positive=shirts, negative=san‐ dals). However, your dataset is quite small, you only have 200 labeled images. When you train a new model for this task (let’s call it model B), with the same architecture as model A, it performs reasonably well (97.2% accuracy), but since it’s a much easier task (there are just 2 classes), you were hoping for more. While drinking your morn‐ ing coffee, you realize that your task is quite similar to task A, so perhaps transfer learning can help? Let’s find out!", "words": [{"w": "Let’s", "b": [0.1429, 0.2711, 0.179, 0.2925]}, {"w": "look", "b": [0.1838, 0.2711, 0.2206, 0.2925]}, {"w": "at", "b": [0.2253, 0.2711, 0.2404, 0.2925]}, {"w": "an", "b": [0.2452, 0.2711, 0.2657, 0.2925]}, {"w": "example.", "b": [0.2704, 0.2711, 0.3447, 0.2925]}, {"w": "Suppose", "b": [0.3495, 0.2711, 0.4194, 0.2925]}, {"w": "the", "b": [0.4241, 0.2711, 0.4504, 0.2925]}, {"w": "fashion", "b": [0.4552, 0.2711, 0.5168, 0.2925]}, {"w": "MNIST", "b": [0.5216, 0.2711, 0.5854, 0.2925]}, {"w": "dataset", "b": [0.5902, 0.2711, 0.6483, 0.2925]}, {"w": "only", "b": [0.653, 0.2711, 0.6899, 0.2925]}, {"w": "contained", "b": [0.6946, 0.2711, 0.7774, 0.2925]}, {"w": "8", "b": [0.7821, 0.2711, 0.7921, 0.2925]}, {"w": "classes,", "b": [0.7968, 0.2711, 0.8566, 0.2925]}, {"w": "for", "b": [0.1429, 0.2901, 0.1674, 0.3115]}, {"w": "example", "b": [0.1756, 0.2901, 0.2451, 0.3115]}, {"w": "all", "b": [0.2534, 0.2901, 0.2731, 0.3115]}, {"w": "classes", "b": [0.2813, 0.2901, 0.3363, 0.3115]}, {"w": "except", "b": [0.3445, 0.2901, 0.3981, 0.3115]}, {"w": "for", "b": [0.4064, 0.2901, 0.4309, 0.3115]}, {"w": "sandals", "b": [0.4391, 0.2901, 0.5003, 0.3115]}, {"w": "and", "b": [0.5086, 0.2901, 0.5401, 0.3115]}, {"w": "shirts.", "b": [0.5483, 0.2901, 0.5992, 0.3115]}, {"w": "Someone", "b": [0.6074, 0.2901, 0.6847, 0.3115]}, {"w": "built", "b": [0.6929, 0.2901, 0.7317, 0.3115]}, {"w": "and", "b": [0.74, 0.2901, 0.7715, 0.3115]}, {"w": "trained", "b": [0.7797, 0.2901, 0.8398, 0.3115]}, {"w": "a", "b": [0.848, 0.2901, 0.8571, 0.3115]}, {"w": "Keras", "b": [0.1429, 0.3092, 0.1898, 0.3306]}, {"w": "model", "b": [0.1951, 0.3092, 0.2479, 0.3306]}, {"w": "on", "b": [0.2532, 0.3092, 0.2752, 0.3306]}, {"w": "that", "b": [0.2806, 0.3092, 0.3132, 0.3306]}, {"w": "set", "b": [0.3185, 0.3092, 0.3413, 0.3306]}, {"w": "and", "b": [0.3467, 0.3092, 0.3782, 0.3306]}, {"w": "got", "b": [0.3835, 0.3092, 0.4103, 0.3306]}, {"w": "reasonably", "b": [0.4156, 0.3092, 0.5055, 0.3306]}, {"w": "good", "b": [0.5109, 0.3092, 0.5529, 0.3306]}, {"w": "performance", "b": [0.5582, 0.3092, 0.6655, 0.3306]}, {"w": "(>90%", "b": [0.6708, 0.3092, 0.7253, 0.3306]}, {"w": "accuracy).", "b": [0.7306, 0.3092, 0.8156, 0.3306]}, {"w": "Let’s", "b": [0.821, 0.3092, 0.8571, 0.3306]}, {"w": "call", "b": [0.1429, 0.3282, 0.1714, 0.3496]}, {"w": "this", "b": [0.1765, 0.3282, 0.2073, 0.3496]}, {"w": "model", "b": [0.2125, 0.3282, 0.2653, 0.3496]}, {"w": "A.", "b": [0.2705, 0.3282, 0.2896, 0.3496]}, {"w": "You", "b": [0.2948, 0.3282, 0.3272, 0.3496]}, {"w": "now", "b": [0.3324, 0.3282, 0.3686, 0.3496]}, {"w": "want", "b": [0.3738, 0.3282, 0.4146, 0.3496]}, {"w": "to", "b": [0.4198, 0.3282, 0.4368, 0.3496]}, {"w": "tackle", "b": [0.442, 0.3282, 0.4908, 0.3496]}, {"w": "a", "b": [0.496, 0.3282, 0.5051, 0.3496]}, {"w": "different", "b": [0.5103, 0.3282, 0.582, 0.3496]}, {"w": "task:", "b": [0.5872, 0.3282, 0.6254, 0.3496]}, {"w": "you", "b": [0.6306, 0.3282, 0.6619, 0.3496]}, {"w": "have", "b": [0.6671, 0.3282, 0.7055, 0.3496]}, {"w": "images", "b": [0.7107, 0.3282, 0.7687, 0.3496]}, {"w": "of", "b": [0.7739, 0.3282, 0.7907, 0.3496]}, {"w": "sandals", "b": [0.7959, 0.3282, 0.8571, 0.3496]}, {"w": "and", "b": [0.1429, 0.3473, 0.1744, 0.3687]}, {"w": "shirts,", "b": [0.1819, 0.3473, 0.2328, 0.3687]}, {"w": "and", "b": [0.2403, 0.3473, 0.2718, 0.3687]}, {"w": "you", "b": [0.2794, 0.3473, 0.3106, 0.3687]}, {"w": "want", "b": [0.3181, 0.3473, 0.3589, 0.3687]}, {"w": "to", "b": [0.3664, 0.3473, 0.3834, 0.3687]}, {"w": "train", "b": [0.3909, 0.3473, 0.4311, 0.3687]}, {"w": "a", "b": [0.4387, 0.3473, 0.4478, 0.3687]}, {"w": "binary", "b": [0.4553, 0.3473, 0.5099, 0.3687]}, {"w": "classifier", "b": [0.5175, 0.3473, 0.5899, 0.3687]}, {"w": "(positive=shirts,", "b": [0.5974, 0.3473, 0.7328, 0.3687]}, {"w": "negative=san‐", "b": [0.7403, 0.3473, 0.8572, 0.3687]}, {"w": "dals).", "b": [0.1429, 0.3663, 0.1879, 0.3877]}, {"w": "However,", "b": [0.1939, 0.3663, 0.2728, 0.3877]}, {"w": "your", "b": [0.2788, 0.3663, 0.3178, 0.3877]}, {"w": "dataset", "b": [0.3238, 0.3663, 0.382, 0.3877]}, {"w": "is", "b": [0.388, 0.3663, 0.4012, 0.3877]}, {"w": "quite", "b": [0.4073, 0.3663, 0.4498, 0.3877]}, {"w": "small,", "b": [0.4558, 0.3663, 0.505, 0.3877]}, {"w": "you", "b": [0.511, 0.3663, 0.5423, 0.3877]}, {"w": "only", "b": [0.5483, 0.3663, 0.5852, 0.3877]}, {"w": "have", "b": [0.5912, 0.3663, 0.6296, 0.3877]}, {"w": "200", "b": [0.6356, 0.3663, 0.6656, 0.3877]}, {"w": "labeled", "b": [0.6717, 0.3663, 0.7307, 0.3877]}, {"w": "images.", "b": [0.7367, 0.3663, 0.7995, 0.3877]}, {"w": "When", "b": [0.8055, 0.3663, 0.8571, 0.3877]}, {"w": "you", "b": [0.1429, 0.3853, 0.1741, 0.4068]}, {"w": "train", "b": [0.1801, 0.3853, 0.2203, 0.4068]}, {"w": "a", "b": [0.2263, 0.3853, 0.2355, 0.4068]}, {"w": "new", "b": [0.2415, 0.3853, 0.276, 0.4068]}, {"w": "model", "b": [0.282, 0.3853, 0.3348, 0.4068]}, {"w": "for", "b": [0.3408, 0.3853, 0.3653, 0.4068]}, {"w": "this", "b": [0.3713, 0.3853, 0.402, 0.4068]}, {"w": "task", "b": [0.408, 0.3853, 0.4415, 0.4068]}, {"w": "(let’s", "b": [0.4475, 0.3853, 0.4849, 0.4068]}, {"w": "call", "b": [0.4909, 0.3853, 0.5194, 0.4068]}, {"w": "it", "b": [0.5254, 0.3853, 0.5373, 0.4068]}, {"w": "model", "b": [0.5433, 0.3853, 0.5962, 0.4068]}, {"w": "B),", "b": [0.6022, 0.3853, 0.6264, 0.4068]}, {"w": "with", "b": [0.6324, 0.3853, 0.6697, 0.4068]}, {"w": "the", "b": [0.6757, 0.3853, 0.702, 0.4068]}, {"w": "same", "b": [0.708, 0.3853, 0.7507, 0.4068]}, {"w": "architecture", "b": [0.7567, 0.3853, 0.8571, 0.4068]}, {"w": "as", "b": [0.1428, 0.4044, 0.1596, 0.4258]}, {"w": "model", "b": [0.1649, 0.4044, 0.2177, 0.4258]}, {"w": "A,", "b": [0.223, 0.4044, 0.2422, 0.4258]}, {"w": "it", "b": [0.2474, 0.4044, 0.2594, 0.4258]}, {"w": "performs", "b": [0.2646, 0.4044, 0.3414, 0.4258]}, {"w": "reasonably", "b": [0.3467, 0.4044, 0.4366, 0.4258]}, {"w": "well", "b": [0.4419, 0.4044, 0.4756, 0.4258]}, {"w": "(97.2%", "b": [0.4808, 0.4044, 0.5385, 0.4258]}, {"w": "accuracy),", "b": [0.5438, 0.4044, 0.6289, 0.4258]}, {"w": "but", "b": [0.6341, 0.4044, 0.6621, 0.4258]}, {"w": "since", "b": [0.6674, 0.4044, 0.7097, 0.4258]}, {"w": "it’s", "b": [0.715, 0.4044, 0.7367, 0.4258]}, {"w": "a", "b": [0.742, 0.4044, 0.7511, 0.4258]}, {"w": "much", "b": [0.7564, 0.4044, 0.804, 0.4258]}, {"w": "easier", "b": [0.8093, 0.4044, 0.8571, 0.4258]}, {"w": "task", "b": [0.1429, 0.4234, 0.1763, 0.4449]}, {"w": "(there", "b": [0.1818, 0.4234, 0.2319, 0.4449]}, {"w": "are", "b": [0.2374, 0.4234, 0.2631, 0.4449]}, {"w": "just", "b": [0.2686, 0.4234, 0.299, 0.4449]}, {"w": "2", "b": [0.3045, 0.4234, 0.3145, 0.4449]}, {"w": "classes),", "b": [0.32, 0.4234, 0.3869, 0.4449]}, {"w": "you", "b": [0.3924, 0.4234, 0.4237, 0.4449]}, {"w": "were", "b": [0.4291, 0.4234, 0.4689, 0.4449]}, {"w": "hoping", "b": [0.4743, 0.4234, 0.5337, 0.4449]}, {"w": "for", "b": [0.5392, 0.4234, 0.5637, 0.4449]}, {"w": "more.", "b": [0.5692, 0.4234, 0.6182, 0.4449]}, {"w": "While", "b": [0.6237, 0.4234, 0.6747, 0.4449]}, {"w": "drinking", "b": [0.6802, 0.4234, 0.753, 0.4449]}, {"w": "your", "b": [0.7585, 0.4234, 0.7974, 0.4449]}, {"w": "morn‐", "b": [0.8029, 0.4234, 0.8571, 0.4449]}, {"w": "ing", "b": [0.1429, 0.4425, 0.1696, 0.4639]}, {"w": "coffee,", "b": [0.1769, 0.4425, 0.2312, 0.4639]}, {"w": "you", "b": [0.2385, 0.4425, 0.2698, 0.4639]}, {"w": "realize", "b": [0.2771, 0.4425, 0.3313, 0.4639]}, {"w": "that", "b": [0.3387, 0.4425, 0.3712, 0.4639]}, {"w": "your", "b": [0.3786, 0.4425, 0.4176, 0.4639]}, {"w": "task", "b": [0.4249, 0.4425, 0.4584, 0.4639]}, {"w": "is", "b": [0.4658, 0.4425, 0.479, 0.4639]}, {"w": "quite", "b": [0.4863, 0.4425, 0.5288, 0.4639]}, {"w": "similar", "b": [0.5362, 0.4425, 0.5942, 0.4639]}, {"w": "to", "b": [0.6016, 0.4425, 0.6185, 0.4639]}, {"w": "task", "b": [0.6259, 0.4425, 0.6594, 0.4639]}, {"w": "A,", "b": [0.6667, 0.4425, 0.6859, 0.4639]}, {"w": "so", "b": [0.6932, 0.4425, 0.7115, 0.4639]}, {"w": "perhaps", "b": [0.7188, 0.4425, 0.7848, 0.4639]}, {"w": "transfer", "b": [0.7921, 0.4425, 0.8571, 0.4639]}, {"w": "learning", "b": [0.1429, 0.4615, 0.212, 0.483]}, {"w": "can", "b": [0.2167, 0.4615, 0.2461, 0.483]}, {"w": "help?", "b": [0.2508, 0.4615, 0.2949, 0.483]}, {"w": "Let’s", "b": [0.2996, 0.4615, 0.3357, 0.483]}, {"w": "find", "b": [0.3405, 0.4615, 0.3746, 0.483]}, {"w": "out!", "b": [0.3794, 0.4615, 0.4131, 0.483]}]}, {"id": "b_4", "type": "paragraph", "text": "First, you need to load model A, and create a new model based on the model A’s lay‐ ers. Let’s reuse all layers except for the output layer:", "words": [{"w": "First,", "b": [0.1429, 0.4897, 0.1859, 0.5111]}, {"w": "you", "b": [0.1916, 0.4897, 0.2229, 0.5111]}, {"w": "need", "b": [0.2285, 0.4897, 0.2686, 0.5111]}, {"w": "to", "b": [0.2743, 0.4897, 0.2913, 0.5111]}, {"w": "load", "b": [0.297, 0.4897, 0.333, 0.5111]}, {"w": "model", "b": [0.3387, 0.4897, 0.3915, 0.5111]}, {"w": "A,", "b": [0.3972, 0.4897, 0.4163, 0.5111]}, {"w": "and", "b": [0.422, 0.4897, 0.4535, 0.5111]}, {"w": "create", "b": [0.4592, 0.4897, 0.5085, 0.5111]}, {"w": "a", "b": [0.5142, 0.4897, 0.5234, 0.5111]}, {"w": "new", "b": [0.529, 0.4897, 0.5635, 0.5111]}, {"w": "model", "b": [0.5692, 0.4897, 0.622, 0.5111]}, {"w": "based", "b": [0.6277, 0.4897, 0.6749, 0.5111]}, {"w": "on", "b": [0.6806, 0.4897, 0.7026, 0.5111]}, {"w": "the", "b": [0.7083, 0.4897, 0.7346, 0.5111]}, {"w": "model", "b": [0.7403, 0.4897, 0.7931, 0.5111]}, {"w": "A’s", "b": [0.7988, 0.4897, 0.8204, 0.5111]}, {"w": "lay‐", "b": [0.8261, 0.4897, 0.8571, 0.5111]}, {"w": "ers.", "b": [0.1429, 0.5087, 0.1718, 0.5301]}, {"w": "Let’s", "b": [0.1766, 0.5087, 0.2127, 0.5301]}, {"w": "reuse", "b": [0.2175, 0.5087, 0.2616, 0.5301]}, {"w": "all", "b": [0.2663, 0.5087, 0.286, 0.5301]}, {"w": "layers", "b": [0.2908, 0.5087, 0.3386, 0.5301]}, {"w": "except", "b": [0.3433, 0.5087, 0.397, 0.5301]}, {"w": "for", "b": [0.4017, 0.5087, 0.4262, 0.5301]}, {"w": "the", "b": [0.4309, 0.5087, 0.4573, 0.5301]}, {"w": "output", "b": [0.462, 0.5087, 0.5184, 0.5301]}, {"w": "layer:", "b": [0.5231, 0.5087, 0.5685, 0.5301]}]}, {"id": "b_5", "type": "paragraph", "text": "model_A = keras.models.load_model(\"my_model_A.h5\") model_B_on_A = keras.models.Sequential(model_A.layers[:-1]) model_B_on_A.add(keras.layers.Dense(1, activation=\"sigmoid\"))", "words": [{"w": "model_A", "b": [0.1766, 0.5407, 0.2356, 0.5535]}, {"w": "=", "b": [0.244, 0.5407, 0.2525, 0.5535]}, {"w": "keras.models.load_model(\"my_model_A.h5\")", "b": [0.2609, 0.5407, 0.5982, 0.5535]}, {"w": "model_B_on_A", "b": [0.1766, 0.5561, 0.2778, 0.5689]}, {"w": "=", "b": [0.2862, 0.5561, 0.2946, 0.5689]}, {"w": "keras.models.Sequential(model_A.layers[:-1])", "b": [0.3031, 0.5561, 0.6741, 0.5689]}, {"w": "model_B_on_A.add(keras.layers.Dense(1,", "b": [0.1766, 0.5715, 0.497, 0.5844]}, {"w": "activation=\"sigmoid\"))", "b": [0.5055, 0.5715, 0.691, 0.5844]}]}, {"id": "b_6", "type": "paragraph", "text": "Note that model_A and model_B_on_A now share some layers. When you train model_B_on_A, it will also affect model_A. If you want to avoid that, you need to clone model_A before you reuse its layers. To do this, you must clone model A’s architecture, then copy its weights (since clone_model() does not clone the weights):", "words": [{"w": "Note", "b": [0.1428, 0.593, 0.1836, 0.6145]}, {"w": "that", "b": [0.1946, 0.593, 0.2272, 0.6145]}, {"w": "model_A", "b": [0.2382, 0.5962, 0.3074, 0.6113]}, {"w": "and", "b": [0.3184, 0.593, 0.35, 0.6145]}, {"w": "model_B_on_A", "b": [0.3609, 0.5962, 0.4797, 0.6113]}, {"w": "now", "b": [0.4907, 0.593, 0.527, 0.6145]}, {"w": "share", "b": [0.5379, 0.593, 0.5824, 0.6145]}, {"w": "some", "b": [0.5934, 0.593, 0.6376, 0.6145]}, {"w": "layers.", "b": [0.6486, 0.593, 0.7011, 0.6145]}, {"w": "When", "b": [0.7121, 0.593, 0.7637, 0.6145]}, {"w": "you", "b": [0.7747, 0.593, 0.806, 0.6145]}, {"w": "train", "b": [0.8169, 0.593, 0.8571, 0.6145]}, {"w": "model_B_on_A,", "b": [0.1429, 0.613, 0.2664, 0.6344]}, {"w": "it", "b": [0.2715, 0.613, 0.2835, 0.6344]}, {"w": "will", "b": [0.2887, 0.613, 0.3191, 0.6344]}, {"w": "also", "b": [0.3242, 0.613, 0.3569, 0.6344]}, {"w": "affect", "b": [0.3621, 0.613, 0.4076, 0.6344]}, {"w": "model_A.", "b": [0.4128, 0.613, 0.4868, 0.6344]}, {"w": "If", "b": [0.492, 0.613, 0.5053, 0.6344]}, {"w": "you", "b": [0.5104, 0.613, 0.5417, 0.6344]}, {"w": "want", "b": [0.5469, 0.613, 0.5876, 0.6344]}, {"w": "to", "b": [0.5928, 0.613, 0.6098, 0.6344]}, {"w": "avoid", "b": [0.615, 0.613, 0.6606, 0.6344]}, {"w": "that,", "b": [0.6658, 0.613, 0.7031, 0.6344]}, {"w": "you", "b": [0.7083, 0.613, 0.7396, 0.6344]}, {"w": "need", "b": [0.7447, 0.613, 0.7848, 0.6344]}, {"w": "to", "b": [0.79, 0.613, 0.807, 0.6344]}, {"w": "clone", "b": [0.8122, 0.613, 0.8571, 0.6344]}, {"w": "model_A", "b": [0.1429, 0.6361, 0.2121, 0.6512]}, {"w": "before", "b": [0.217, 0.6329, 0.2698, 0.6543]}, {"w": "you", "b": [0.2747, 0.6329, 0.306, 0.6543]}, {"w": "reuse", "b": [0.3109, 0.6329, 0.355, 0.6543]}, {"w": "its", "b": [0.3599, 0.6329, 0.3795, 0.6543]}, {"w": "layers.", "b": [0.3844, 0.6329, 0.437, 0.6543]}, {"w": "To", "b": [0.4419, 0.6329, 0.4633, 0.6543]}, {"w": "do", "b": [0.4682, 0.6329, 0.4898, 0.6543]}, {"w": "this,", "b": [0.4947, 0.6329, 0.5302, 0.6543]}, {"w": "you", "b": [0.5351, 0.6329, 0.5663, 0.6543]}, {"w": "must", "b": [0.5712, 0.6329, 0.613, 0.6543]}, {"w": "clone", "b": [0.6179, 0.6329, 0.6628, 0.6543]}, {"w": "model", "b": [0.6677, 0.6329, 0.7205, 0.6543]}, {"w": "A’s", "b": [0.7254, 0.6329, 0.7471, 0.6543]}, {"w": "architecture,", "b": [0.752, 0.6329, 0.8571, 0.6543]}, {"w": "then", "b": [0.1429, 0.6529, 0.1806, 0.6743]}, {"w": "copy", "b": [0.1853, 0.6529, 0.2252, 0.6743]}, {"w": "its", "b": [0.23, 0.6529, 0.2495, 0.6743]}, {"w": "weights", "b": [0.2543, 0.6529, 0.3175, 0.6743]}, {"w": "(since", "b": [0.3222, 0.6529, 0.3717, 0.6743]}, {"w": "clone_model()", "b": [0.3764, 0.6561, 0.5051, 0.6711]}, {"w": "does", "b": [0.5098, 0.6529, 0.5479, 0.6743]}, {"w": "not", "b": [0.5526, 0.6529, 0.581, 0.6743]}, {"w": "clone", "b": [0.5857, 0.6529, 0.6307, 0.6743]}, {"w": "the", "b": [0.6354, 0.6529, 0.6618, 0.6743]}, {"w": "weights):", "b": [0.6665, 0.6529, 0.7416, 0.6743]}]}, {"id": "b_7", "type": "paragraph", "text": "model_A_clone = keras.models.clone_model(model_A) model_A_clone.set_weights(model_A.get_weights())", "words": [{"w": "model_A_clone", "b": [0.1766, 0.6849, 0.2862, 0.6977]}, {"w": "=", "b": [0.2946, 0.6849, 0.3031, 0.6977]}, {"w": "keras.models.clone_model(model_A)", "b": [0.3115, 0.6849, 0.5898, 0.6977]}, {"w": "model_A_clone.set_weights(model_A.get_weights())", "b": [0.1766, 0.7003, 0.5813, 0.7131]}]}, {"id": "b_8", "type": "paragraph", "text": "Now we could just train model_B_on_A for task B, but since the new output layer was initialized randomly, it will make large errors, at least during the first few epochs, so there will be large error gradients that may wreck the reused weights. To avoid this, one approach is to freeze the reused layers during the first few epochs, giving the new layer some time to learn reasonable weights. To do this, simply set every layer’s train able attribute to False and compile the model:", "words": [{"w": "Now", "b": [0.1429, 0.7218, 0.1827, 0.7432]}, {"w": "we", "b": [0.1882, 0.7218, 0.2113, 0.7432]}, {"w": "could", "b": [0.2167, 0.7218, 0.2635, 0.7432]}, {"w": "just", "b": [0.269, 0.7218, 0.2994, 0.7432]}, {"w": "train", "b": [0.3048, 0.7218, 0.345, 0.7432]}, {"w": "model_B_on_A", "b": [0.3505, 0.725, 0.4692, 0.7401]}, {"w": "for", "b": [0.4747, 0.7218, 0.4992, 0.7432]}, {"w": "task", "b": [0.5046, 0.7218, 0.5381, 0.7432]}, {"w": "B,", "b": [0.5436, 0.7218, 0.5602, 0.7432]}, {"w": "but", "b": [0.5657, 0.7218, 0.5937, 0.7432]}, {"w": "since", "b": [0.5991, 0.7218, 0.6414, 0.7432]}, {"w": "the", "b": [0.6469, 0.7218, 0.6732, 0.7432]}, {"w": "new", "b": [0.6787, 0.7218, 0.7132, 0.7432]}, {"w": "output", "b": [0.7186, 0.7218, 0.775, 0.7432]}, {"w": "layer", "b": [0.7804, 0.7218, 0.8206, 0.7432]}, {"w": "was", "b": [0.8261, 0.7218, 0.8572, 0.7432]}, {"w": "initialized", "b": [0.1429, 0.7409, 0.226, 0.7623]}, {"w": "randomly,", "b": [0.2319, 0.7409, 0.317, 0.7623]}, {"w": "it", "b": [0.3229, 0.7409, 0.3349, 0.7623]}, {"w": "will", "b": [0.3408, 0.7409, 0.3712, 0.7623]}, {"w": "make", "b": [0.3772, 0.7409, 0.4226, 0.7623]}, {"w": "large", "b": [0.4286, 0.7409, 0.4693, 0.7623]}, {"w": "errors,", "b": [0.4753, 0.7409, 0.5304, 0.7623]}, {"w": "at", "b": [0.5363, 0.7409, 0.5514, 0.7623]}, {"w": "least", "b": [0.5574, 0.7409, 0.5947, 0.7623]}, {"w": "during", "b": [0.6007, 0.7409, 0.6572, 0.7623]}, {"w": "the", "b": [0.6631, 0.7409, 0.6895, 0.7623]}, {"w": "first", "b": [0.6955, 0.7409, 0.7289, 0.7623]}, {"w": "few", "b": [0.7349, 0.7409, 0.7642, 0.7623]}, {"w": "epochs,", "b": [0.7702, 0.7409, 0.8329, 0.7623]}, {"w": "so", "b": [0.8389, 0.7409, 0.8571, 0.7623]}, {"w": "there", "b": [0.1429, 0.7599, 0.1858, 0.7813]}, {"w": "will", "b": [0.1923, 0.7599, 0.2227, 0.7813]}, {"w": "be", "b": [0.2292, 0.7599, 0.2486, 0.7813]}, {"w": "large", "b": [0.2551, 0.7599, 0.2959, 0.7813]}, {"w": "error", "b": [0.3024, 0.7599, 0.3451, 0.7813]}, {"w": "gradients", "b": [0.3516, 0.7599, 0.4286, 0.7813]}, {"w": "that", "b": [0.4351, 0.7599, 0.4677, 0.7813]}, {"w": "may", "b": [0.4742, 0.7599, 0.5096, 0.7813]}, {"w": "wreck", "b": [0.5161, 0.7599, 0.5661, 0.7813]}, {"w": "the", "b": [0.5727, 0.7599, 0.599, 0.7813]}, {"w": "reused", "b": [0.6055, 0.7599, 0.6606, 0.7813]}, {"w": "weights.", "b": [0.6672, 0.7599, 0.7351, 0.7813]}, {"w": "To", "b": [0.7416, 0.7599, 0.763, 0.7813]}, {"w": "avoid", "b": [0.7695, 0.7599, 0.8152, 0.7813]}, {"w": "this,", "b": [0.8217, 0.7599, 0.8571, 0.7813]}, {"w": "one", "b": [0.1429, 0.7789, 0.1737, 0.8004]}, {"w": "approach", "b": [0.1788, 0.7789, 0.2568, 0.8004]}, {"w": "is", "b": [0.2619, 0.7789, 0.2751, 0.8004]}, {"w": "to", "b": [0.2801, 0.7789, 0.2971, 0.8004]}, {"w": "freeze", "b": [0.3022, 0.7789, 0.3514, 0.8004]}, {"w": "the", "b": [0.3564, 0.7789, 0.3828, 0.8004]}, {"w": "reused", "b": [0.3878, 0.7789, 0.443, 0.8004]}, {"w": "layers", "b": [0.448, 0.7789, 0.4958, 0.8004]}, {"w": "during", "b": [0.5009, 0.7789, 0.5574, 0.8004]}, {"w": "the", "b": [0.5625, 0.7789, 0.5888, 0.8004]}, {"w": "first", "b": [0.5938, 0.7789, 0.6273, 0.8004]}, {"w": "few", "b": [0.6324, 0.7789, 0.6617, 0.8004]}, {"w": "epochs,", "b": [0.6667, 0.7789, 0.7294, 0.8004]}, {"w": "giving", "b": [0.7345, 0.7789, 0.7862, 0.8004]}, {"w": "the", "b": [0.7912, 0.7789, 0.8176, 0.8004]}, {"w": "new", "b": [0.8226, 0.7789, 0.8572, 0.8004]}, {"w": "layer", "b": [0.1429, 0.7989, 0.183, 0.8203]}, {"w": "some", "b": [0.1882, 0.7989, 0.2324, 0.8203]}, {"w": "time", "b": [0.2376, 0.7989, 0.2755, 0.8203]}, {"w": "to", "b": [0.2807, 0.7989, 0.2977, 0.8203]}, {"w": "learn", "b": [0.3029, 0.7989, 0.3453, 0.8203]}, {"w": "reasonable", "b": [0.3505, 0.7989, 0.4397, 0.8203]}, {"w": "weights.", "b": [0.4449, 0.7989, 0.5129, 0.8203]}, {"w": "To", "b": [0.5181, 0.7989, 0.5395, 0.8203]}, {"w": "do", "b": [0.5447, 0.7989, 0.5663, 0.8203]}, {"w": "this,", "b": [0.5715, 0.7989, 0.607, 0.8203]}, {"w": "simply", "b": [0.6122, 0.7989, 0.6678, 0.8203]}, {"w": "set", "b": [0.673, 0.7989, 0.6959, 0.8203]}, {"w": "every", "b": [0.7011, 0.7989, 0.7463, 0.8203]}, {"w": "layer’s", "b": [0.7515, 0.7989, 0.802, 0.8203]}, {"w": "train", "b": [0.8072, 0.8021, 0.8567, 0.8172]}, {"w": "able", "b": [0.1429, 0.822, 0.1824, 0.8371]}, {"w": "attribute", "b": [0.1872, 0.8188, 0.2588, 0.8402]}, {"w": "to", "b": [0.2635, 0.8188, 0.2805, 0.8402]}, {"w": "False", "b": [0.2852, 0.822, 0.3347, 0.8371]}, {"w": "and", "b": [0.3394, 0.8188, 0.371, 0.8402]}, {"w": "compile", "b": [0.3757, 0.8188, 0.4424, 0.8402]}, {"w": "the", "b": [0.4472, 0.8188, 0.4735, 0.8402]}, {"w": "model:", "b": [0.4782, 0.8188, 0.5358, 0.8402]}]}, {"id": "b_9", "type": "equation", "text": "for layer in model_B_on_A.layers[:-1]: layer.trainable = False", "words": [{"w": "for", "b": [0.1766, 0.8508, 0.2019, 0.8637]}, {"w": "layer", "b": [0.2103, 0.8508, 0.2525, 0.8637]}, {"w": "in", "b": [0.2609, 0.8508, 0.2778, 0.8637]}, {"w": "model_B_on_A.layers[:-1]:", "b": [0.2862, 0.8508, 0.497, 0.8637]}, {"w": "layer.trainable", "b": [0.2103, 0.8662, 0.3368, 0.8791]}, {"w": "=", "b": [0.3452, 0.8662, 0.3537, 0.8791]}, {"w": "False", "b": [0.3621, 0.8662, 0.4043, 0.8791]}]}, {"id": "b_10", "type": "paragraph", "text": "Reusing Pretrained Layers | 341", "words": [{"w": "Reusing", "b": [0.6428, 0.9225, 0.6899, 0.9388]}, {"w": "Pretrained", "b": [0.6927, 0.9225, 0.7554, 0.9388]}, {"w": "Layers", "b": [0.7582, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "341", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 368, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "model_B_on_A.compile(loss=\"binary_crossentropy\", optimizer=\"sgd\", metrics=[\"accuracy\"])", "words": [{"w": "model_B_on_A.compile(loss=\"binary_crossentropy\",", "b": [0.1766, 0.0829, 0.5813, 0.0958]}, {"w": "optimizer=\"sgd\",", "b": [0.5898, 0.0829, 0.7247, 0.0958]}, {"w": "metrics=[\"accuracy\"])", "b": [0.3537, 0.0983, 0.5308, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "You must always compile your model after you freeze or unfreeze layers.", "words": [{"w": "You", "b": [0.2714, 0.1328, 0.301, 0.1524]}, {"w": "must", "b": [0.3071, 0.1328, 0.3452, 0.1524]}, {"w": "always", "b": [0.3513, 0.1328, 0.4013, 0.1524]}, {"w": "compile", "b": [0.4074, 0.1328, 0.4684, 0.1524]}, {"w": "your", "b": [0.4745, 0.1328, 0.5101, 0.1524]}, {"w": "model", "b": [0.5162, 0.1328, 0.5645, 0.1524]}, {"w": "after", "b": [0.5705, 0.1328, 0.6055, 0.1524]}, {"w": "you", "b": [0.6116, 0.1328, 0.6402, 0.1524]}, {"w": "freeze", "b": [0.6462, 0.1328, 0.6912, 0.1524]}, {"w": "or", "b": [0.6973, 0.1328, 0.7141, 0.1524]}, {"w": "unfreeze", "b": [0.7202, 0.1328, 0.7857, 0.1524]}, {"w": "layers.", "b": [0.2714, 0.1502, 0.3195, 0.1698]}]}, {"id": "b_2", "type": "paragraph", "text": "Next, we can train the model for a few epochs, then unfreeze the reused layers (which requires compiling the model again) and continue training to fine-tune the reused layers for task B. After unfreezing the reused layers, it is usually a good idea to reduce the learning rate, once again to avoid damaging the reused weights:", "words": [{"w": "Next,", "b": [0.1429, 0.2314, 0.1876, 0.2529]}, {"w": "we", "b": [0.1926, 0.2314, 0.2157, 0.2529]}, {"w": "can", "b": [0.2208, 0.2314, 0.2501, 0.2529]}, {"w": "train", "b": [0.2551, 0.2314, 0.2953, 0.2529]}, {"w": "the", "b": [0.3003, 0.2314, 0.3267, 0.2529]}, {"w": "model", "b": [0.3317, 0.2314, 0.3845, 0.2529]}, {"w": "for", "b": [0.3895, 0.2314, 0.414, 0.2529]}, {"w": "a", "b": [0.419, 0.2314, 0.4282, 0.2529]}, {"w": "few", "b": [0.4332, 0.2314, 0.4625, 0.2529]}, {"w": "epochs,", "b": [0.4675, 0.2314, 0.5302, 0.2529]}, {"w": "then", "b": [0.5352, 0.2314, 0.573, 0.2529]}, {"w": "unfreeze", "b": [0.578, 0.2314, 0.6497, 0.2529]}, {"w": "the", "b": [0.6547, 0.2314, 0.681, 0.2529]}, {"w": "reused", "b": [0.686, 0.2314, 0.7412, 0.2529]}, {"w": "layers", "b": [0.7462, 0.2314, 0.794, 0.2529]}, {"w": "(which", "b": [0.799, 0.2314, 0.8571, 0.2529]}, {"w": "requires", "b": [0.1428, 0.2505, 0.211, 0.2719]}, {"w": "compiling", "b": [0.2185, 0.2505, 0.3031, 0.2719]}, {"w": "the", "b": [0.3106, 0.2505, 0.337, 0.2719]}, {"w": "model", "b": [0.3445, 0.2505, 0.3973, 0.2719]}, {"w": "again)", "b": [0.4048, 0.2505, 0.4571, 0.2719]}, {"w": "and", "b": [0.4646, 0.2505, 0.4961, 0.2719]}, {"w": "continue", "b": [0.5037, 0.2505, 0.577, 0.2719]}, {"w": "training", "b": [0.5845, 0.2505, 0.6514, 0.2719]}, {"w": "to", "b": [0.659, 0.2505, 0.676, 0.2719]}, {"w": "fine-tune", "b": [0.6835, 0.2505, 0.7606, 0.2719]}, {"w": "the", "b": [0.7681, 0.2505, 0.7945, 0.2719]}, {"w": "reused", "b": [0.802, 0.2505, 0.8571, 0.2719]}, {"w": "layers", "b": [0.1429, 0.2695, 0.1907, 0.291]}, {"w": "for", "b": [0.1958, 0.2695, 0.2203, 0.291]}, {"w": "task", "b": [0.2254, 0.2695, 0.2589, 0.291]}, {"w": "B.", "b": [0.264, 0.2695, 0.2806, 0.291]}, {"w": "After", "b": [0.2857, 0.2695, 0.3292, 0.291]}, {"w": "unfreezing", "b": [0.3343, 0.2695, 0.4238, 0.291]}, {"w": "the", "b": [0.4289, 0.2695, 0.4553, 0.291]}, {"w": "reused", "b": [0.4604, 0.2695, 0.5155, 0.291]}, {"w": "layers,", "b": [0.5206, 0.2695, 0.5732, 0.291]}, {"w": "it", "b": [0.5783, 0.2695, 0.5902, 0.291]}, {"w": "is", "b": [0.5953, 0.2695, 0.6085, 0.291]}, {"w": "usually", "b": [0.6136, 0.2695, 0.6727, 0.291]}, {"w": "a", "b": [0.6778, 0.2695, 0.6869, 0.291]}, {"w": "good", "b": [0.692, 0.2695, 0.734, 0.291]}, {"w": "idea", "b": [0.7391, 0.2695, 0.7737, 0.291]}, {"w": "to", "b": [0.7788, 0.2695, 0.7957, 0.291]}, {"w": "reduce", "b": [0.8008, 0.2695, 0.8571, 0.291]}, {"w": "the", "b": [0.1429, 0.2886, 0.1692, 0.31]}, {"w": "learning", "b": [0.1739, 0.2886, 0.243, 0.31]}, {"w": "rate,", "b": [0.2478, 0.2886, 0.2842, 0.31]}, {"w": "once", "b": [0.2889, 0.2886, 0.3286, 0.31]}, {"w": "again", "b": [0.3334, 0.2886, 0.3784, 0.31]}, {"w": "to", "b": [0.3831, 0.2886, 0.4001, 0.31]}, {"w": "avoid", "b": [0.4048, 0.2886, 0.4504, 0.31]}, {"w": "damaging", "b": [0.4552, 0.2886, 0.538, 0.31]}, {"w": "the", "b": [0.5427, 0.2886, 0.5691, 0.31]}, {"w": "reused", "b": [0.5738, 0.2886, 0.6289, 0.31]}, {"w": "weights:", "b": [0.6337, 0.2886, 0.7016, 0.31]}]}, {"id": "b_3", "type": "paragraph", "text": "history = model_B_on_A.fit(X_train_B, y_train_B, epochs=4, validation_data=(X_valid_B, y_valid_B))", "words": [{"w": "history", "b": [0.1766, 0.3206, 0.2356, 0.3334]}, {"w": "=", "b": [0.244, 0.3206, 0.2525, 0.3334]}, {"w": "model_B_on_A.fit(X_train_B,", "b": [0.2609, 0.3206, 0.4886, 0.3334]}, {"w": "y_train_B,", "b": [0.497, 0.3206, 0.5813, 0.3334]}, {"w": "epochs=4,", "b": [0.5898, 0.3206, 0.6657, 0.3334]}, {"w": "validation_data=(X_valid_B,", "b": [0.4043, 0.336, 0.6319, 0.3488]}, {"w": "y_valid_B))", "b": [0.6404, 0.336, 0.7331, 0.3488]}]}, {"id": "b_4", "type": "equation", "text": "for layer in model_B_on_A.layers[:-1]: layer.trainable = True", "words": [{"w": "for", "b": [0.1766, 0.3668, 0.2019, 0.3797]}, {"w": "layer", "b": [0.2103, 0.3668, 0.2525, 0.3797]}, {"w": "in", "b": [0.2609, 0.3668, 0.2778, 0.3797]}, {"w": "model_B_on_A.layers[:-1]:", "b": [0.2862, 0.3668, 0.497, 0.3797]}, {"w": "layer.trainable", "b": [0.2103, 0.3822, 0.3368, 0.3951]}, {"w": "=", "b": [0.3452, 0.3822, 0.3537, 0.3951]}, {"w": "True", "b": [0.3621, 0.3822, 0.3958, 0.3951]}]}, {"id": "b_5", "type": "paragraph", "text": "optimizer = keras.optimizers.SGD(lr=1e-4) # the default lr is 1e-3 model_B_on_A.compile(loss=\"binary_crossentropy\", optimizer=optimizer, metrics=[\"accuracy\"]) history = model_B_on_A.fit(X_train_B, y_train_B, epochs=16, validation_data=(X_valid_B, y_valid_B))", "words": [{"w": "optimizer", "b": [0.1766, 0.4131, 0.2525, 0.4259]}, {"w": "=", "b": [0.2609, 0.4131, 0.2693, 0.4259]}, {"w": "keras.optimizers.SGD(lr=1e-4)", "b": [0.2778, 0.4131, 0.5223, 0.4259]}, {"w": "#", "b": [0.5307, 0.4131, 0.5392, 0.4259]}, {"w": "the", "b": [0.5476, 0.4131, 0.5729, 0.4259]}, {"w": "default", "b": [0.5813, 0.4131, 0.6404, 0.4259]}, {"w": "lr", "b": [0.6488, 0.4131, 0.6657, 0.4259]}, {"w": "is", "b": [0.6741, 0.4131, 0.691, 0.4259]}, {"w": "1e-3", "b": [0.6994, 0.4131, 0.7331, 0.4259]}, {"w": "model_B_on_A.compile(loss=\"binary_crossentropy\",", "b": [0.1766, 0.4285, 0.5813, 0.4413]}, {"w": "optimizer=optimizer,", "b": [0.5898, 0.4285, 0.7584, 0.4413]}, {"w": "metrics=[\"accuracy\"])", "b": [0.3537, 0.4439, 0.5307, 0.4568]}, {"w": "history", "b": [0.1766, 0.4593, 0.2356, 0.4722]}, {"w": "=", "b": [0.244, 0.4593, 0.2525, 0.4722]}, {"w": "model_B_on_A.fit(X_train_B,", "b": [0.2609, 0.4593, 0.4886, 0.4722]}, {"w": "y_train_B,", "b": [0.497, 0.4593, 0.5813, 0.4722]}, {"w": "epochs=16,", "b": [0.5898, 0.4593, 0.6741, 0.4722]}, {"w": "validation_data=(X_valid_B,", "b": [0.4043, 0.4748, 0.6319, 0.4876]}, {"w": "y_valid_B))", "b": [0.6404, 0.4748, 0.7331, 0.4876]}]}, {"id": "b_6", "type": "paragraph", "text": "So, what’s the final verdict? Well this model’s test accuracy is 99.25%, which means that transfer learning reduced the error rate from 2.8% down to almost 0.7%! That’s a factor of 4!", "words": [{"w": "So,", "b": [0.1429, 0.4954, 0.1675, 0.5168]}, {"w": "what’s", "b": [0.1747, 0.4954, 0.2249, 0.5168]}, {"w": "the", "b": [0.232, 0.4954, 0.2584, 0.5168]}, {"w": "final", "b": [0.2655, 0.4954, 0.3031, 0.5168]}, {"w": "verdict?", "b": [0.3102, 0.4954, 0.3761, 0.5168]}, {"w": "Well", "b": [0.3833, 0.4954, 0.4209, 0.5168]}, {"w": "this", "b": [0.428, 0.4954, 0.4587, 0.5168]}, {"w": "model’s", "b": [0.4659, 0.4954, 0.5285, 0.5168]}, {"w": "test", "b": [0.5356, 0.4954, 0.5648, 0.5168]}, {"w": "accuracy", "b": [0.572, 0.4954, 0.645, 0.5168]}, {"w": "is", "b": [0.6522, 0.4954, 0.6654, 0.5168]}, {"w": "99.25%,", "b": [0.6726, 0.4954, 0.7378, 0.5168]}, {"w": "which", "b": [0.745, 0.4954, 0.7959, 0.5168]}, {"w": "means", "b": [0.803, 0.4954, 0.8571, 0.5168]}, {"w": "that", "b": [0.1429, 0.5144, 0.1754, 0.5358]}, {"w": "transfer", "b": [0.1806, 0.5144, 0.2457, 0.5358]}, {"w": "learning", "b": [0.2509, 0.5144, 0.32, 0.5358]}, {"w": "reduced", "b": [0.3252, 0.5144, 0.3925, 0.5358]}, {"w": "the", "b": [0.3977, 0.5144, 0.424, 0.5358]}, {"w": "error", "b": [0.4293, 0.5144, 0.4719, 0.5358]}, {"w": "rate", "b": [0.4771, 0.5144, 0.5088, 0.5358]}, {"w": "from", "b": [0.514, 0.5144, 0.5556, 0.5358]}, {"w": "2.8%", "b": [0.5608, 0.5144, 0.6013, 0.5358]}, {"w": "down", "b": [0.6065, 0.5144, 0.6538, 0.5358]}, {"w": "to", "b": [0.659, 0.5144, 0.676, 0.5358]}, {"w": "almost", "b": [0.6812, 0.5144, 0.7373, 0.5358]}, {"w": "0.7%!", "b": [0.7425, 0.5144, 0.7887, 0.5358]}, {"w": "That’s", "b": [0.794, 0.5144, 0.8428, 0.5358]}, {"w": "a", "b": [0.848, 0.5144, 0.8571, 0.5358]}, {"w": "factor", "b": [0.1429, 0.5335, 0.1917, 0.5549]}, {"w": "of", "b": [0.1964, 0.5335, 0.2132, 0.5549]}, {"w": "4!", "b": [0.2179, 0.5335, 0.2337, 0.5549]}]}, {"id": "b_7", "type": "equation", "text": ">>> model_B_on_A.evaluate(X_test_B, y_test_B) [0.06887910133600235, 0.9925]", "words": [{"w": ">>>", "b": [0.1766, 0.5655, 0.2019, 0.5783]}, {"w": "model_B_on_A.evaluate(X_test_B,", "b": [0.2103, 0.5655, 0.4717, 0.5783]}, {"w": "y_test_B)", "b": [0.4802, 0.5655, 0.5561, 0.5783]}, {"w": "[0.06887910133600235,", "b": [0.1766, 0.5809, 0.3537, 0.5937]}, {"w": "0.9925]", "b": [0.3621, 0.5809, 0.4211, 0.5937]}]}, {"id": "b_8", "type": "paragraph", "text": "Are you convinced? Well you shouldn’t be: I cheated! :) I tried many configurations until I found one that demonstrated a strong improvement. If you try to change the classes or the random seed, you will see that the improvement generally drops, or even vanishes or reverses. What I did is called “torturing the data until it confesses”. When a paper just looks too positive, you should be suspicious: perhaps the flashy new technique does not help much (in fact, it may even degrade performance), but the authors tried many variants and reported only the best results (which may be due to shear luck), without mentioning how many failures they encountered on the way. Most of the time, this is not malicious at all, but it is part of the reason why so many results in Science can never be reproduced.", "words": [{"w": "Are", "b": [0.1429, 0.6015, 0.1738, 0.6229]}, {"w": "you", "b": [0.1804, 0.6015, 0.2117, 0.6229]}, {"w": "convinced?", "b": [0.2182, 0.6015, 0.3118, 0.6229]}, {"w": "Well", "b": [0.3183, 0.6015, 0.356, 0.6229]}, {"w": "you", "b": [0.3625, 0.6015, 0.3938, 0.6229]}, {"w": "shouldn’t", "b": [0.4003, 0.6015, 0.4771, 0.6229]}, {"w": "be:", "b": [0.4836, 0.6015, 0.5078, 0.6229]}, {"w": "I", "b": [0.5144, 0.6015, 0.5215, 0.6229]}, {"w": "cheated!", "b": [0.5281, 0.6015, 0.5976, 0.6229]}, {"w": ":)", "b": [0.6041, 0.6015, 0.6161, 0.6229]}, {"w": "I", "b": [0.6227, 0.6015, 0.6298, 0.6229]}, {"w": "tried", "b": [0.6363, 0.6015, 0.6758, 0.6229]}, {"w": "many", "b": [0.6824, 0.6015, 0.7291, 0.6229]}, {"w": "configurations", "b": [0.7357, 0.6015, 0.8572, 0.6229]}, {"w": "until", "b": [0.1429, 0.6206, 0.1821, 0.642]}, {"w": "I", "b": [0.1883, 0.6206, 0.1954, 0.642]}, {"w": "found", "b": [0.2016, 0.6206, 0.2519, 0.642]}, {"w": "one", "b": [0.2581, 0.6206, 0.2889, 0.642]}, {"w": "that", "b": [0.2951, 0.6206, 0.3277, 0.642]}, {"w": "demonstrated", "b": [0.3339, 0.6206, 0.4495, 0.642]}, {"w": "a", "b": [0.4557, 0.6206, 0.4649, 0.642]}, {"w": "strong", "b": [0.4711, 0.6206, 0.5246, 0.642]}, {"w": "improvement.", "b": [0.5308, 0.6206, 0.6488, 0.642]}, {"w": "If", "b": [0.655, 0.6206, 0.6683, 0.642]}, {"w": "you", "b": [0.6745, 0.6206, 0.7057, 0.642]}, {"w": "try", "b": [0.7119, 0.6206, 0.7362, 0.642]}, {"w": "to", "b": [0.7424, 0.6206, 0.7593, 0.642]}, {"w": "change", "b": [0.7655, 0.6206, 0.8246, 0.642]}, {"w": "the", "b": [0.8308, 0.6206, 0.8571, 0.642]}, {"w": "classes", "b": [0.1429, 0.6396, 0.1979, 0.661]}, {"w": "or", "b": [0.2056, 0.6396, 0.224, 0.661]}, {"w": "the", "b": [0.2317, 0.6396, 0.258, 0.661]}, {"w": "random", "b": [0.2657, 0.6396, 0.3327, 0.661]}, {"w": "seed,", "b": [0.3404, 0.6396, 0.3815, 0.661]}, {"w": "you", "b": [0.3893, 0.6396, 0.4205, 0.661]}, {"w": "will", "b": [0.4282, 0.6396, 0.4586, 0.661]}, {"w": "see", "b": [0.4664, 0.6396, 0.4917, 0.661]}, {"w": "that", "b": [0.4994, 0.6396, 0.532, 0.661]}, {"w": "the", "b": [0.5398, 0.6396, 0.5661, 0.661]}, {"w": "improvement", "b": [0.5738, 0.6396, 0.6871, 0.661]}, {"w": "generally", "b": [0.6948, 0.6396, 0.7707, 0.661]}, {"w": "drops,", "b": [0.7784, 0.6396, 0.8311, 0.661]}, {"w": "or", "b": [0.8388, 0.6396, 0.8571, 0.661]}, {"w": "even", "b": [0.1428, 0.6587, 0.1816, 0.6801]}, {"w": "vanishes", "b": [0.1879, 0.6587, 0.2589, 0.6801]}, {"w": "or", "b": [0.2652, 0.6587, 0.2836, 0.6801]}, {"w": "reverses.", "b": [0.2899, 0.6587, 0.3616, 0.6801]}, {"w": "What", "b": [0.3679, 0.6587, 0.4144, 0.6801]}, {"w": "I", "b": [0.4207, 0.6587, 0.4278, 0.6801]}, {"w": "did", "b": [0.4341, 0.6587, 0.4617, 0.6801]}, {"w": "is", "b": [0.468, 0.6587, 0.4812, 0.6801]}, {"w": "called", "b": [0.4875, 0.6587, 0.5358, 0.6801]}, {"w": "“torturing", "b": [0.5421, 0.6587, 0.6263, 0.6801]}, {"w": "the", "b": [0.6326, 0.6587, 0.6589, 0.6801]}, {"w": "data", "b": [0.6652, 0.6587, 0.7005, 0.6801]}, {"w": "until", "b": [0.7068, 0.6587, 0.746, 0.6801]}, {"w": "it", "b": [0.7523, 0.6587, 0.7643, 0.6801]}, {"w": "confesses”.", "b": [0.7706, 0.6587, 0.8571, 0.6801]}, {"w": "When", "b": [0.1429, 0.6777, 0.1945, 0.6991]}, {"w": "a", "b": [0.2017, 0.6777, 0.2109, 0.6991]}, {"w": "paper", "b": [0.2181, 0.6777, 0.2653, 0.6991]}, {"w": "just", "b": [0.2726, 0.6777, 0.303, 0.6991]}, {"w": "looks", "b": [0.3102, 0.6777, 0.3547, 0.6991]}, {"w": "too", "b": [0.362, 0.6777, 0.3896, 0.6991]}, {"w": "positive,", "b": [0.3969, 0.6777, 0.4668, 0.6991]}, {"w": "you", "b": [0.4741, 0.6777, 0.5053, 0.6991]}, {"w": "should", "b": [0.5126, 0.6777, 0.5693, 0.6991]}, {"w": "be", "b": [0.5766, 0.6777, 0.596, 0.6991]}, {"w": "suspicious:", "b": [0.6033, 0.6777, 0.6946, 0.6991]}, {"w": "perhaps", "b": [0.7019, 0.6777, 0.7678, 0.6991]}, {"w": "the", "b": [0.7751, 0.6777, 0.8014, 0.6991]}, {"w": "flashy", "b": [0.8087, 0.6777, 0.8572, 0.6991]}, {"w": "new", "b": [0.1429, 0.6967, 0.1774, 0.7182]}, {"w": "technique", "b": [0.1841, 0.6967, 0.2668, 0.7182]}, {"w": "does", "b": [0.2736, 0.6967, 0.3117, 0.7182]}, {"w": "not", "b": [0.3184, 0.6967, 0.3468, 0.7182]}, {"w": "help", "b": [0.3535, 0.6967, 0.3897, 0.7182]}, {"w": "much", "b": [0.3964, 0.6967, 0.4441, 0.7182]}, {"w": "(in", "b": [0.4509, 0.6967, 0.475, 0.7182]}, {"w": "fact,", "b": [0.4818, 0.6967, 0.517, 0.7182]}, {"w": "it", "b": [0.5238, 0.6967, 0.5357, 0.7182]}, {"w": "may", "b": [0.5424, 0.6967, 0.5778, 0.7182]}, {"w": "even", "b": [0.5846, 0.6967, 0.6233, 0.7182]}, {"w": "degrade", "b": [0.6301, 0.6967, 0.6964, 0.7182]}, {"w": "performance),", "b": [0.7032, 0.6967, 0.8224, 0.7182]}, {"w": "but", "b": [0.8291, 0.6967, 0.8571, 0.7182]}, {"w": "the", "b": [0.1429, 0.7158, 0.1692, 0.7372]}, {"w": "authors", "b": [0.1744, 0.7158, 0.2377, 0.7372]}, {"w": "tried", "b": [0.243, 0.7158, 0.2825, 0.7372]}, {"w": "many", "b": [0.2878, 0.7158, 0.3344, 0.7372]}, {"w": "variants", "b": [0.3397, 0.7158, 0.4059, 0.7372]}, {"w": "and", "b": [0.4112, 0.7158, 0.4427, 0.7372]}, {"w": "reported", "b": [0.448, 0.7158, 0.5201, 0.7372]}, {"w": "only", "b": [0.5253, 0.7158, 0.5622, 0.7372]}, {"w": "the", "b": [0.5674, 0.7158, 0.5937, 0.7372]}, {"w": "best", "b": [0.599, 0.7158, 0.6324, 0.7372]}, {"w": "results", "b": [0.6377, 0.7158, 0.6923, 0.7372]}, {"w": "(which", "b": [0.6975, 0.7158, 0.7556, 0.7372]}, {"w": "may", "b": [0.7609, 0.7158, 0.7963, 0.7372]}, {"w": "be", "b": [0.8015, 0.7158, 0.821, 0.7372]}, {"w": "due", "b": [0.8262, 0.7158, 0.8571, 0.7372]}, {"w": "to", "b": [0.1429, 0.7348, 0.1598, 0.7563]}, {"w": "shear", "b": [0.166, 0.7348, 0.2105, 0.7563]}, {"w": "luck),", "b": [0.2166, 0.7348, 0.2641, 0.7563]}, {"w": "without", "b": [0.2702, 0.7348, 0.3356, 0.7563]}, {"w": "mentioning", "b": [0.3417, 0.7348, 0.4393, 0.7563]}, {"w": "how", "b": [0.4454, 0.7348, 0.4814, 0.7563]}, {"w": "many", "b": [0.4876, 0.7348, 0.5343, 0.7563]}, {"w": "failures", "b": [0.5404, 0.7348, 0.6019, 0.7563]}, {"w": "they", "b": [0.608, 0.7348, 0.6439, 0.7563]}, {"w": "encountered", "b": [0.65, 0.7348, 0.7546, 0.7563]}, {"w": "on", "b": [0.7607, 0.7348, 0.7827, 0.7563]}, {"w": "the", "b": [0.7889, 0.7348, 0.8152, 0.7563]}, {"w": "way.", "b": [0.8213, 0.7348, 0.8572, 0.7563]}, {"w": "Most", "b": [0.1429, 0.7539, 0.1855, 0.7753]}, {"w": "of", "b": [0.1912, 0.7539, 0.208, 0.7753]}, {"w": "the", "b": [0.2137, 0.7539, 0.24, 0.7753]}, {"w": "time,", "b": [0.2457, 0.7539, 0.2883, 0.7753]}, {"w": "this", "b": [0.294, 0.7539, 0.3247, 0.7753]}, {"w": "is", "b": [0.3304, 0.7539, 0.3436, 0.7753]}, {"w": "not", "b": [0.3493, 0.7539, 0.3777, 0.7753]}, {"w": "malicious", "b": [0.3833, 0.7539, 0.4641, 0.7753]}, {"w": "at", "b": [0.4698, 0.7539, 0.4849, 0.7753]}, {"w": "all,", "b": [0.4906, 0.7539, 0.515, 0.7753]}, {"w": "but", "b": [0.5207, 0.7539, 0.5487, 0.7753]}, {"w": "it", "b": [0.5544, 0.7539, 0.5663, 0.7753]}, {"w": "is", "b": [0.572, 0.7539, 0.5853, 0.7753]}, {"w": "part", "b": [0.5909, 0.7539, 0.6251, 0.7753]}, {"w": "of", "b": [0.6308, 0.7539, 0.6476, 0.7753]}, {"w": "the", "b": [0.6532, 0.7539, 0.6796, 0.7753]}, {"w": "reason", "b": [0.6853, 0.7539, 0.7407, 0.7753]}, {"w": "why", "b": [0.7463, 0.7539, 0.7808, 0.7753]}, {"w": "so", "b": [0.7865, 0.7539, 0.8048, 0.7753]}, {"w": "many", "b": [0.8105, 0.7539, 0.8571, 0.7753]}, {"w": "results", "b": [0.1429, 0.7729, 0.1974, 0.7944]}, {"w": "in", "b": [0.2021, 0.7729, 0.2191, 0.7944]}, {"w": "Science", "b": [0.2239, 0.7729, 0.286, 0.7944]}, {"w": "can", "b": [0.2908, 0.7729, 0.3201, 0.7944]}, {"w": "never", "b": [0.3249, 0.7729, 0.3713, 0.7944]}, {"w": "be", "b": [0.3761, 0.7729, 0.3955, 0.7944]}, {"w": "reproduced.", "b": [0.4002, 0.7729, 0.5016, 0.7944]}]}, {"id": "b_9", "type": "paragraph", "text": "So why did I cheat? Well it turns out that transfer learning does not work very well with small dense networks: it works best with deep convolutional neural networks, so we will revisit transfer learning in Chapter 14, using the same techniques (and this time there will be no cheating, I promise!).", "words": [{"w": "So", "b": [0.1429, 0.8011, 0.1634, 0.8225]}, {"w": "why", "b": [0.1699, 0.8011, 0.2044, 0.8225]}, {"w": "did", "b": [0.2109, 0.8011, 0.2385, 0.8225]}, {"w": "I", "b": [0.2451, 0.8011, 0.2522, 0.8225]}, {"w": "cheat?", "b": [0.2587, 0.8011, 0.3105, 0.8225]}, {"w": "Well", "b": [0.3171, 0.8011, 0.3547, 0.8225]}, {"w": "it", "b": [0.3612, 0.8011, 0.3732, 0.8225]}, {"w": "turns", "b": [0.3797, 0.8011, 0.4239, 0.8225]}, {"w": "out", "b": [0.4304, 0.8011, 0.4585, 0.8225]}, {"w": "that", "b": [0.465, 0.8011, 0.4976, 0.8225]}, {"w": "transfer", "b": [0.5042, 0.8011, 0.5692, 0.8225]}, {"w": "learning", "b": [0.5757, 0.8011, 0.6449, 0.8225]}, {"w": "does", "b": [0.6514, 0.8011, 0.6895, 0.8225]}, {"w": "not", "b": [0.6961, 0.8011, 0.7245, 0.8225]}, {"w": "work", "b": [0.731, 0.8011, 0.774, 0.8225]}, {"w": "very", "b": [0.7805, 0.8011, 0.8169, 0.8225]}, {"w": "well", "b": [0.8235, 0.8011, 0.8571, 0.8225]}, {"w": "with", "b": [0.1428, 0.8201, 0.1802, 0.8415]}, {"w": "small", "b": [0.1853, 0.8201, 0.2297, 0.8415]}, {"w": "dense", "b": [0.2347, 0.8201, 0.2825, 0.8415]}, {"w": "networks:", "b": [0.2876, 0.8201, 0.3695, 0.8415]}, {"w": "it", "b": [0.3746, 0.8201, 0.3865, 0.8415]}, {"w": "works", "b": [0.3916, 0.8201, 0.4422, 0.8415]}, {"w": "best", "b": [0.4473, 0.8201, 0.4807, 0.8415]}, {"w": "with", "b": [0.4858, 0.8201, 0.5231, 0.8415]}, {"w": "deep", "b": [0.5282, 0.8201, 0.5678, 0.8415]}, {"w": "convolutional", "b": [0.5729, 0.8201, 0.6882, 0.8415]}, {"w": "neural", "b": [0.6933, 0.8201, 0.7468, 0.8415]}, {"w": "networks,", "b": [0.7518, 0.8201, 0.8338, 0.8415]}, {"w": "so", "b": [0.8389, 0.8201, 0.8571, 0.8415]}, {"w": "we", "b": [0.1429, 0.8392, 0.166, 0.8606]}, {"w": "will", "b": [0.173, 0.8392, 0.2034, 0.8606]}, {"w": "revisit", "b": [0.2105, 0.8392, 0.2619, 0.8606]}, {"w": "transfer", "b": [0.2689, 0.8392, 0.3339, 0.8606]}, {"w": "learning", "b": [0.341, 0.8392, 0.4101, 0.8606]}, {"w": "in", "b": [0.4172, 0.8392, 0.4342, 0.8606]}, {"w": "Chapter", "b": [0.4412, 0.8392, 0.5088, 0.8606]}, {"w": "14,", "b": [0.5158, 0.8392, 0.5406, 0.8606]}, {"w": "using", "b": [0.5476, 0.8392, 0.5931, 0.8606]}, {"w": "the", "b": [0.6001, 0.8392, 0.6265, 0.8606]}, {"w": "same", "b": [0.6335, 0.8392, 0.6762, 0.8606]}, {"w": "techniques", "b": [0.6833, 0.8392, 0.7736, 0.8606]}, {"w": "(and", "b": [0.7806, 0.8392, 0.8194, 0.8606]}, {"w": "this", "b": [0.8264, 0.8392, 0.8572, 0.8606]}, {"w": "time", "b": [0.1429, 0.8582, 0.1807, 0.8796]}, {"w": "there", "b": [0.1854, 0.8582, 0.2284, 0.8796]}, {"w": "will", "b": [0.2331, 0.8582, 0.2635, 0.8796]}, {"w": "be", "b": [0.2682, 0.8582, 0.2876, 0.8796]}, {"w": "no", "b": [0.2924, 0.8582, 0.3144, 0.8796]}, {"w": "cheating,", "b": [0.3191, 0.8582, 0.3945, 0.8796]}, {"w": "I", "b": [0.3992, 0.8582, 0.4063, 0.8796]}, {"w": "promise!).", "b": [0.4111, 0.8582, 0.4972, 0.8796]}]}, {"id": "b_10", "type": "paragraph", "text": "342 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "342", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2745, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 369, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Unsupervised Pretraining", "words": [{"w": "Unsupervised", "b": [0.1429, 0.0763, 0.2821, 0.1049]}, {"w": "Pretraining", "b": [0.287, 0.0763, 0.4045, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "Suppose you want to tackle a complex task for which you don’t have much labeled training data, but unfortunately you cannot find a model trained on a similar task. Don’t lose all hope! First, you should of course try to gather more labeled training data, but if this is too hard or too expensive, you may still be able to perform unsuper‐ vised pretraining (see Figure 11-5). It is often rather cheap to gather unlabeled train‐ ing examples, but quite expensive to label them. If you can gather plenty of unlabeled training data, you can try to train the layers one by one, starting with the lowest layer and then going up, using an unsupervised feature detector algorithm such as Restric‐ ted Boltzmann Machines (RBMs; see ???) or autoencoders (see ???). Each layer is trained on the output of the previously trained layers (all layers except the one being trained are frozen). Once all layers have been trained this way, you can add the output layer for your task, and fine-tune the final network using supervised learning (i.e., with the labeled training examples). At this point, you can unfreeze all the pretrained layers, or just some of the upper ones.", "words": [{"w": "Suppose", "b": [0.1429, 0.1108, 0.2128, 0.1322]}, {"w": "you", "b": [0.2199, 0.1108, 0.2511, 0.1322]}, {"w": "want", "b": [0.2583, 0.1108, 0.299, 0.1322]}, {"w": "to", "b": [0.3061, 0.1108, 0.3231, 0.1322]}, {"w": "tackle", "b": [0.3302, 0.1108, 0.379, 0.1322]}, {"w": "a", "b": [0.3861, 0.1108, 0.3953, 0.1322]}, {"w": "complex", "b": [0.4024, 0.1108, 0.4734, 0.1322]}, {"w": "task", "b": [0.4805, 0.1108, 0.514, 0.1322]}, {"w": "for", "b": [0.5211, 0.1108, 0.5456, 0.1322]}, {"w": "which", "b": [0.5527, 0.1108, 0.6037, 0.1322]}, {"w": "you", "b": [0.6108, 0.1108, 0.642, 0.1322]}, {"w": "don’t", "b": [0.6491, 0.1108, 0.6907, 0.1322]}, {"w": "have", "b": [0.6979, 0.1108, 0.7363, 0.1322]}, {"w": "much", "b": [0.7434, 0.1108, 0.7911, 0.1322]}, {"w": "labeled", "b": [0.7982, 0.1108, 0.8572, 0.1322]}, {"w": "training", "b": [0.1429, 0.1298, 0.2098, 0.1512]}, {"w": "data,", "b": [0.2169, 0.1298, 0.2569, 0.1512]}, {"w": "but", "b": [0.264, 0.1298, 0.292, 0.1512]}, {"w": "unfortunately", "b": [0.2991, 0.1298, 0.4137, 0.1512]}, {"w": "you", "b": [0.4208, 0.1298, 0.452, 0.1512]}, {"w": "cannot", "b": [0.4591, 0.1298, 0.5168, 0.1512]}, {"w": "find", "b": [0.5239, 0.1298, 0.5581, 0.1512]}, {"w": "a", "b": [0.5652, 0.1298, 0.5743, 0.1512]}, {"w": "model", "b": [0.5814, 0.1298, 0.6342, 0.1512]}, {"w": "trained", "b": [0.6413, 0.1298, 0.7014, 0.1512]}, {"w": "on", "b": [0.7085, 0.1298, 0.7305, 0.1512]}, {"w": "a", "b": [0.7376, 0.1298, 0.7467, 0.1512]}, {"w": "similar", "b": [0.7538, 0.1298, 0.8118, 0.1512]}, {"w": "task.", "b": [0.8189, 0.1298, 0.8571, 0.1512]}, {"w": "Don’t", "b": [0.1429, 0.1489, 0.1888, 0.1703]}, {"w": "lose", "b": [0.1961, 0.1489, 0.2285, 0.1703]}, {"w": "all", "b": [0.2358, 0.1489, 0.2555, 0.1703]}, {"w": "hope!", "b": [0.2628, 0.1489, 0.3101, 0.1703]}, {"w": "First,", "b": [0.3174, 0.1489, 0.3605, 0.1703]}, {"w": "you", "b": [0.3678, 0.1489, 0.399, 0.1703]}, {"w": "should", "b": [0.4064, 0.1489, 0.4631, 0.1703]}, {"w": "of", "b": [0.4704, 0.1489, 0.4872, 0.1703]}, {"w": "course", "b": [0.4945, 0.1489, 0.5493, 0.1703]}, {"w": "try", "b": [0.5566, 0.1489, 0.5808, 0.1703]}, {"w": "to", "b": [0.5881, 0.1489, 0.6051, 0.1703]}, {"w": "gather", "b": [0.6124, 0.1489, 0.665, 0.1703]}, {"w": "more", "b": [0.6723, 0.1489, 0.7166, 0.1703]}, {"w": "labeled", "b": [0.7239, 0.1489, 0.7829, 0.1703]}, {"w": "training", "b": [0.7902, 0.1489, 0.8571, 0.1703]}, {"w": "data,", "b": [0.1428, 0.1679, 0.1828, 0.1893]}, {"w": "but", "b": [0.1877, 0.1679, 0.2157, 0.1893]}, {"w": "if", "b": [0.2206, 0.1679, 0.2324, 0.1893]}, {"w": "this", "b": [0.2372, 0.1679, 0.268, 0.1893]}, {"w": "is", "b": [0.2728, 0.1679, 0.2861, 0.1893]}, {"w": "too", "b": [0.2909, 0.1679, 0.3186, 0.1893]}, {"w": "hard", "b": [0.3234, 0.1679, 0.3624, 0.1893]}, {"w": "or", "b": [0.3673, 0.1679, 0.3857, 0.1893]}, {"w": "too", "b": [0.3906, 0.1679, 0.4182, 0.1893]}, {"w": "expensive,", "b": [0.423, 0.1679, 0.5094, 0.1893]}, {"w": "you", "b": [0.5143, 0.1679, 0.5455, 0.1893]}, {"w": "may", "b": [0.5504, 0.1679, 0.5858, 0.1893]}, {"w": "still", "b": [0.5907, 0.1679, 0.6208, 0.1893]}, {"w": "be", "b": [0.6257, 0.1679, 0.6451, 0.1893]}, {"w": "able", "b": [0.65, 0.1679, 0.6838, 0.1893]}, {"w": "to", "b": [0.6887, 0.1679, 0.7057, 0.1893]}, {"w": "perform", "b": [0.7106, 0.1679, 0.7797, 0.1893]}, {"w": "unsuper‐", "b": [0.7846, 0.1677, 0.8571, 0.1893]}, {"w": "vised", "b": [0.1429, 0.1868, 0.1841, 0.2084]}, {"w": "pretraining", "b": [0.1903, 0.1868, 0.2801, 0.2084]}, {"w": "(see", "b": [0.2863, 0.187, 0.3188, 0.2084]}, {"w": "Figure", "b": [0.325, 0.187, 0.379, 0.2084]}, {"w": "11-5).", "b": [0.3852, 0.187, 0.4346, 0.2084]}, {"w": "It", "b": [0.4408, 0.187, 0.4534, 0.2084]}, {"w": "is", "b": [0.4596, 0.187, 0.4728, 0.2084]}, {"w": "often", "b": [0.479, 0.187, 0.5224, 0.2084]}, {"w": "rather", "b": [0.5286, 0.187, 0.5792, 0.2084]}, {"w": "cheap", "b": [0.5853, 0.187, 0.6338, 0.2084]}, {"w": "to", "b": [0.64, 0.187, 0.657, 0.2084]}, {"w": "gather", "b": [0.6631, 0.187, 0.7157, 0.2084]}, {"w": "unlabeled", "b": [0.7219, 0.187, 0.8033, 0.2084]}, {"w": "train‐", "b": [0.8095, 0.187, 0.8571, 0.2084]}, {"w": "ing", "b": [0.1429, 0.206, 0.1696, 0.2274]}, {"w": "examples,", "b": [0.1748, 0.206, 0.2567, 0.2274]}, {"w": "but", "b": [0.2619, 0.206, 0.2899, 0.2274]}, {"w": "quite", "b": [0.2951, 0.206, 0.3376, 0.2274]}, {"w": "expensive", "b": [0.3428, 0.206, 0.4244, 0.2274]}, {"w": "to", "b": [0.4296, 0.206, 0.4465, 0.2274]}, {"w": "label", "b": [0.4517, 0.206, 0.4908, 0.2274]}, {"w": "them.", "b": [0.496, 0.206, 0.5442, 0.2274]}, {"w": "If", "b": [0.5494, 0.206, 0.5626, 0.2274]}, {"w": "you", "b": [0.5678, 0.206, 0.5991, 0.2274]}, {"w": "can", "b": [0.6043, 0.206, 0.6336, 0.2274]}, {"w": "gather", "b": [0.6388, 0.206, 0.6914, 0.2274]}, {"w": "plenty", "b": [0.6966, 0.206, 0.7485, 0.2274]}, {"w": "of", "b": [0.7537, 0.206, 0.7705, 0.2274]}, {"w": "unlabeled", "b": [0.7757, 0.206, 0.8571, 0.2274]}, {"w": "training", "b": [0.1428, 0.2251, 0.2098, 0.2465]}, {"w": "data,", "b": [0.215, 0.2251, 0.255, 0.2465]}, {"w": "you", "b": [0.2602, 0.2251, 0.2915, 0.2465]}, {"w": "can", "b": [0.2967, 0.2251, 0.3261, 0.2465]}, {"w": "try", "b": [0.3313, 0.2251, 0.3556, 0.2465]}, {"w": "to", "b": [0.3608, 0.2251, 0.3778, 0.2465]}, {"w": "train", "b": [0.383, 0.2251, 0.4232, 0.2465]}, {"w": "the", "b": [0.4284, 0.2251, 0.4548, 0.2465]}, {"w": "layers", "b": [0.46, 0.2251, 0.5078, 0.2465]}, {"w": "one", "b": [0.5131, 0.2251, 0.5439, 0.2465]}, {"w": "by", "b": [0.5492, 0.2251, 0.5693, 0.2465]}, {"w": "one,", "b": [0.5745, 0.2251, 0.6102, 0.2465]}, {"w": "starting", "b": [0.6154, 0.2251, 0.6793, 0.2465]}, {"w": "with", "b": [0.6846, 0.2251, 0.7219, 0.2465]}, {"w": "the", "b": [0.7271, 0.2251, 0.7535, 0.2465]}, {"w": "lowest", "b": [0.7587, 0.2251, 0.8117, 0.2465]}, {"w": "layer", "b": [0.8169, 0.2251, 0.8571, 0.2465]}, {"w": "and", "b": [0.1429, 0.2441, 0.1744, 0.2655]}, {"w": "then", "b": [0.18, 0.2441, 0.2178, 0.2655]}, {"w": "going", "b": [0.2234, 0.2441, 0.2705, 0.2655]}, {"w": "up,", "b": [0.2761, 0.2441, 0.3022, 0.2655]}, {"w": "using", "b": [0.3078, 0.2441, 0.3533, 0.2655]}, {"w": "an", "b": [0.3589, 0.2441, 0.3794, 0.2655]}, {"w": "unsupervised", "b": [0.3851, 0.2441, 0.4971, 0.2655]}, {"w": "feature", "b": [0.5027, 0.2441, 0.5604, 0.2655]}, {"w": "detector", "b": [0.5661, 0.2441, 0.6347, 0.2655]}, {"w": "algorithm", "b": [0.6403, 0.2441, 0.7229, 0.2655]}, {"w": "such", "b": [0.7285, 0.2441, 0.7672, 0.2655]}, {"w": "as", "b": [0.7728, 0.2441, 0.7896, 0.2655]}, {"w": "Restric‐", "b": [0.7952, 0.2439, 0.8571, 0.2655]}, {"w": "ted", "b": [0.1429, 0.263, 0.1678, 0.2846]}, {"w": "Boltzmann", "b": [0.1771, 0.263, 0.2667, 0.2846]}, {"w": "Machines", "b": [0.2759, 0.263, 0.3532, 0.2846]}, {"w": "(RBMs;", "b": [0.3623, 0.2632, 0.4257, 0.2846]}, {"w": "see", "b": [0.4349, 0.2632, 0.4602, 0.2846]}, {"w": "???)", "b": [0.4694, 0.2632, 0.5003, 0.2846]}, {"w": "or", "b": [0.5095, 0.2632, 0.5278, 0.2846]}, {"w": "autoencoders", "b": [0.537, 0.2632, 0.6487, 0.2846]}, {"w": "(see", "b": [0.6579, 0.2632, 0.6904, 0.2846]}, {"w": "???).", "b": [0.6996, 0.2632, 0.7353, 0.2846]}, {"w": "Each", "b": [0.7445, 0.2632, 0.7854, 0.2846]}, {"w": "layer", "b": [0.7945, 0.2632, 0.8347, 0.2846]}, {"w": "is", "b": [0.8439, 0.2632, 0.8571, 0.2846]}, {"w": "trained", "b": [0.1429, 0.2822, 0.2029, 0.3036]}, {"w": "on", "b": [0.2086, 0.2822, 0.2306, 0.3036]}, {"w": "the", "b": [0.2363, 0.2822, 0.2627, 0.3036]}, {"w": "output", "b": [0.2684, 0.2822, 0.3248, 0.3036]}, {"w": "of", "b": [0.3305, 0.2822, 0.3472, 0.3036]}, {"w": "the", "b": [0.353, 0.2822, 0.3793, 0.3036]}, {"w": "previously", "b": [0.385, 0.2822, 0.4719, 0.3036]}, {"w": "trained", "b": [0.4776, 0.2822, 0.5376, 0.3036]}, {"w": "layers", "b": [0.5434, 0.2822, 0.5912, 0.3036]}, {"w": "(all", "b": [0.5969, 0.2822, 0.6238, 0.3036]}, {"w": "layers", "b": [0.6295, 0.2822, 0.6773, 0.3036]}, {"w": "except", "b": [0.683, 0.2822, 0.7367, 0.3036]}, {"w": "the", "b": [0.7424, 0.2822, 0.7687, 0.3036]}, {"w": "one", "b": [0.7744, 0.2822, 0.8053, 0.3036]}, {"w": "being", "b": [0.811, 0.2822, 0.8571, 0.3036]}, {"w": "trained", "b": [0.1428, 0.3013, 0.2029, 0.3227]}, {"w": "are", "b": [0.2077, 0.3013, 0.2334, 0.3227]}, {"w": "frozen).", "b": [0.2382, 0.3013, 0.3037, 0.3227]}, {"w": "Once", "b": [0.3085, 0.3013, 0.3531, 0.3227]}, {"w": "all", "b": [0.3579, 0.3013, 0.3776, 0.3227]}, {"w": "layers", "b": [0.3823, 0.3013, 0.4302, 0.3227]}, {"w": "have", "b": [0.435, 0.3013, 0.4733, 0.3227]}, {"w": "been", "b": [0.4781, 0.3013, 0.5178, 0.3227]}, {"w": "trained", "b": [0.5226, 0.3013, 0.5827, 0.3227]}, {"w": "this", "b": [0.5874, 0.3013, 0.6181, 0.3227]}, {"w": "way,", "b": [0.6229, 0.3013, 0.6588, 0.3227]}, {"w": "you", "b": [0.6635, 0.3013, 0.6948, 0.3227]}, {"w": "can", "b": [0.6996, 0.3013, 0.7289, 0.3227]}, {"w": "add", "b": [0.7337, 0.3013, 0.7649, 0.3227]}, {"w": "the", "b": [0.7696, 0.3013, 0.796, 0.3227]}, {"w": "output", "b": [0.8008, 0.3013, 0.8571, 0.3227]}, {"w": "layer", "b": [0.1429, 0.3203, 0.183, 0.3417]}, {"w": "for", "b": [0.1906, 0.3203, 0.2151, 0.3417]}, {"w": "your", "b": [0.2226, 0.3203, 0.2616, 0.3417]}, {"w": "task,", "b": [0.2691, 0.3203, 0.3073, 0.3417]}, {"w": "and", "b": [0.3149, 0.3203, 0.3464, 0.3417]}, {"w": "fine-tune", "b": [0.3539, 0.3203, 0.431, 0.3417]}, {"w": "the", "b": [0.4385, 0.3203, 0.4649, 0.3417]}, {"w": "final", "b": [0.4724, 0.3203, 0.51, 0.3417]}, {"w": "network", "b": [0.5175, 0.3203, 0.587, 0.3417]}, {"w": "using", "b": [0.5946, 0.3203, 0.64, 0.3417]}, {"w": "supervised", "b": [0.6475, 0.3203, 0.7371, 0.3417]}, {"w": "learning", "b": [0.7446, 0.3203, 0.8137, 0.3417]}, {"w": "(i.e.,", "b": [0.8212, 0.3203, 0.8571, 0.3417]}, {"w": "with", "b": [0.1429, 0.3394, 0.1802, 0.3608]}, {"w": "the", "b": [0.1856, 0.3394, 0.2119, 0.3608]}, {"w": "labeled", "b": [0.2173, 0.3394, 0.2762, 0.3608]}, {"w": "training", "b": [0.2816, 0.3394, 0.3486, 0.3608]}, {"w": "examples).", "b": [0.3539, 0.3394, 0.4431, 0.3608]}, {"w": "At", "b": [0.4485, 0.3394, 0.4684, 0.3608]}, {"w": "this", "b": [0.4737, 0.3394, 0.5044, 0.3608]}, {"w": "point,", "b": [0.5098, 0.3394, 0.559, 0.3608]}, {"w": "you", "b": [0.5644, 0.3394, 0.5957, 0.3608]}, {"w": "can", "b": [0.601, 0.3394, 0.6304, 0.3608]}, {"w": "unfreeze", "b": [0.6358, 0.3394, 0.7074, 0.3608]}, {"w": "all", "b": [0.7128, 0.3394, 0.7325, 0.3608]}, {"w": "the", "b": [0.7379, 0.3394, 0.7642, 0.3608]}, {"w": "pretrained", "b": [0.7696, 0.3394, 0.8571, 0.3608]}, {"w": "layers,", "b": [0.1428, 0.3584, 0.1954, 0.3798]}, {"w": "or", "b": [0.2002, 0.3584, 0.2185, 0.3798]}, {"w": "just", "b": [0.2232, 0.3584, 0.2536, 0.3798]}, {"w": "some", "b": [0.2584, 0.3584, 0.3026, 0.3798]}, {"w": "of", "b": [0.3073, 0.3584, 0.3241, 0.3798]}, {"w": "the", "b": [0.3288, 0.3584, 0.3551, 0.3798]}, {"w": "upper", "b": [0.3599, 0.3584, 0.4093, 0.3798]}, {"w": "ones.", "b": [0.4141, 0.3584, 0.4573, 0.3798]}]}, {"id": "b_2", "type": "equation", "text": "Figure 11-5. Unsupervised pretraining", "words": [{"w": "Figure", "b": [0.1429, 0.7538, 0.1943, 0.7754]}, {"w": "11-5.", "b": [0.1991, 0.7538, 0.2407, 0.7754]}, {"w": "Unsupervised", "b": [0.2455, 0.7538, 0.3559, 0.7754]}, {"w": "pretraining", "b": [0.3606, 0.7538, 0.4504, 0.7754]}]}, {"id": "b_3", "type": "paragraph", "text": "This is a rather long and tedious process, but it often works well; in fact, it is this technique that Geoffrey Hinton and his team used in 2006 and which led to the revival of neural networks and the success of Deep Learning. Until 2010, unsuper‐ vised pretraining (typically using RBMs) was the norm for deep nets, and it was only after the vanishing gradients problem was alleviated that it became much more com‐", "words": [{"w": "This", "b": [0.1429, 0.7912, 0.1801, 0.8126]}, {"w": "is", "b": [0.1875, 0.7912, 0.2008, 0.8126]}, {"w": "a", "b": [0.2082, 0.7912, 0.2174, 0.8126]}, {"w": "rather", "b": [0.2249, 0.7912, 0.2754, 0.8126]}, {"w": "long", "b": [0.2829, 0.7912, 0.3199, 0.8126]}, {"w": "and", "b": [0.3274, 0.7912, 0.3589, 0.8126]}, {"w": "tedious", "b": [0.3664, 0.7912, 0.4275, 0.8126]}, {"w": "process,", "b": [0.435, 0.7912, 0.502, 0.8126]}, {"w": "but", "b": [0.5094, 0.7912, 0.5374, 0.8126]}, {"w": "it", "b": [0.5449, 0.7912, 0.5569, 0.8126]}, {"w": "often", "b": [0.5643, 0.7912, 0.6077, 0.8126]}, {"w": "works", "b": [0.6152, 0.7912, 0.6658, 0.8126]}, {"w": "well;", "b": [0.6733, 0.7912, 0.7117, 0.8126]}, {"w": "in", "b": [0.7192, 0.7912, 0.7361, 0.8126]}, {"w": "fact,", "b": [0.7436, 0.7912, 0.7788, 0.8126]}, {"w": "it", "b": [0.7863, 0.7912, 0.7983, 0.8126]}, {"w": "is", "b": [0.8057, 0.7912, 0.819, 0.8126]}, {"w": "this", "b": [0.8264, 0.7912, 0.8571, 0.8126]}, {"w": "technique", "b": [0.1429, 0.8102, 0.2256, 0.8316]}, {"w": "that", "b": [0.2342, 0.8102, 0.2668, 0.8316]}, {"w": "Geoffrey", "b": [0.2755, 0.8102, 0.3483, 0.8316]}, {"w": "Hinton", "b": [0.357, 0.8102, 0.4179, 0.8316]}, {"w": "and", "b": [0.4266, 0.8102, 0.4582, 0.8316]}, {"w": "his", "b": [0.4668, 0.8102, 0.4912, 0.8316]}, {"w": "team", "b": [0.4999, 0.8102, 0.5413, 0.8316]}, {"w": "used", "b": [0.55, 0.8102, 0.5885, 0.8316]}, {"w": "in", "b": [0.5972, 0.8102, 0.6142, 0.8316]}, {"w": "2006", "b": [0.6229, 0.8102, 0.6629, 0.8316]}, {"w": "and", "b": [0.6715, 0.8102, 0.7031, 0.8316]}, {"w": "which", "b": [0.7118, 0.8102, 0.7627, 0.8316]}, {"w": "led", "b": [0.7714, 0.8102, 0.7965, 0.8316]}, {"w": "to", "b": [0.8052, 0.8102, 0.8221, 0.8316]}, {"w": "the", "b": [0.8308, 0.8102, 0.8572, 0.8316]}, {"w": "revival", "b": [0.1429, 0.8293, 0.1987, 0.8507]}, {"w": "of", "b": [0.2061, 0.8293, 0.2229, 0.8507]}, {"w": "neural", "b": [0.2303, 0.8293, 0.2837, 0.8507]}, {"w": "networks", "b": [0.2911, 0.8293, 0.3683, 0.8507]}, {"w": "and", "b": [0.3757, 0.8293, 0.4073, 0.8507]}, {"w": "the", "b": [0.4146, 0.8293, 0.441, 0.8507]}, {"w": "success", "b": [0.4484, 0.8293, 0.5088, 0.8507]}, {"w": "of", "b": [0.5162, 0.8293, 0.533, 0.8507]}, {"w": "Deep", "b": [0.5404, 0.8293, 0.5843, 0.8507]}, {"w": "Learning.", "b": [0.5917, 0.8293, 0.6715, 0.8507]}, {"w": "Until", "b": [0.6789, 0.8293, 0.7215, 0.8507]}, {"w": "2010,", "b": [0.7289, 0.8293, 0.7737, 0.8507]}, {"w": "unsuper‐", "b": [0.7811, 0.8293, 0.8571, 0.8507]}, {"w": "vised", "b": [0.1429, 0.8483, 0.1856, 0.8697]}, {"w": "pretraining", "b": [0.1911, 0.8483, 0.2855, 0.8697]}, {"w": "(typically", "b": [0.291, 0.8483, 0.3687, 0.8697]}, {"w": "using", "b": [0.3741, 0.8483, 0.4196, 0.8697]}, {"w": "RBMs)", "b": [0.425, 0.8483, 0.4836, 0.8697]}, {"w": "was", "b": [0.4891, 0.8483, 0.5202, 0.8697]}, {"w": "the", "b": [0.5257, 0.8483, 0.552, 0.8697]}, {"w": "norm", "b": [0.5575, 0.8483, 0.6043, 0.8697]}, {"w": "for", "b": [0.6098, 0.8483, 0.6343, 0.8697]}, {"w": "deep", "b": [0.6397, 0.8483, 0.6794, 0.8697]}, {"w": "nets,", "b": [0.6848, 0.8483, 0.7238, 0.8697]}, {"w": "and", "b": [0.7293, 0.8483, 0.7609, 0.8697]}, {"w": "it", "b": [0.7663, 0.8483, 0.7783, 0.8697]}, {"w": "was", "b": [0.7837, 0.8483, 0.8148, 0.8697]}, {"w": "only", "b": [0.8203, 0.8483, 0.8571, 0.8697]}, {"w": "after", "b": [0.1428, 0.8673, 0.1811, 0.8888]}, {"w": "the", "b": [0.1867, 0.8673, 0.213, 0.8888]}, {"w": "vanishing", "b": [0.2186, 0.8673, 0.2998, 0.8888]}, {"w": "gradients", "b": [0.3054, 0.8673, 0.3825, 0.8888]}, {"w": "problem", "b": [0.388, 0.8673, 0.4591, 0.8888]}, {"w": "was", "b": [0.4647, 0.8673, 0.4957, 0.8888]}, {"w": "alleviated", "b": [0.5013, 0.8673, 0.58, 0.8888]}, {"w": "that", "b": [0.5856, 0.8673, 0.6182, 0.8888]}, {"w": "it", "b": [0.6237, 0.8673, 0.6357, 0.8888]}, {"w": "became", "b": [0.6413, 0.8673, 0.7046, 0.8888]}, {"w": "much", "b": [0.7101, 0.8673, 0.7578, 0.8888]}, {"w": "more", "b": [0.7634, 0.8673, 0.8076, 0.8888]}, {"w": "com‐", "b": [0.8132, 0.8673, 0.8571, 0.8888]}]}, {"id": "b_4", "type": "paragraph", "text": "Reusing Pretrained Layers | 343", "words": [{"w": "Reusing", "b": [0.6428, 0.9225, 0.6899, 0.9388]}, {"w": "Pretrained", "b": [0.6927, 0.9225, 0.7554, 0.9388]}, {"w": "Layers", "b": [0.7582, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "343", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 370, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "mon to train DNNs purely using supervised learning. However, unsupervised pre‐ training (today typically using autoencoders rather than RBMs) is still a good option when you have a complex task to solve, no similar model you can reuse, and little labeled training data but plenty of unlabeled training data.", "words": [{"w": "mon", "b": [0.1429, 0.0791, 0.1819, 0.1005]}, {"w": "to", "b": [0.1896, 0.0791, 0.2066, 0.1005]}, {"w": "train", "b": [0.2142, 0.0791, 0.2545, 0.1005]}, {"w": "DNNs", "b": [0.2621, 0.0791, 0.3155, 0.1005]}, {"w": "purely", "b": [0.3231, 0.0791, 0.3765, 0.1005]}, {"w": "using", "b": [0.3842, 0.0791, 0.4296, 0.1005]}, {"w": "supervised", "b": [0.4373, 0.0791, 0.5268, 0.1005]}, {"w": "learning.", "b": [0.5345, 0.0791, 0.6084, 0.1005]}, {"w": "However,", "b": [0.616, 0.0791, 0.6949, 0.1005]}, {"w": "unsupervised", "b": [0.7026, 0.0791, 0.8146, 0.1005]}, {"w": "pre‐", "b": [0.8222, 0.0791, 0.8571, 0.1005]}, {"w": "training", "b": [0.1429, 0.0981, 0.2098, 0.1195]}, {"w": "(today", "b": [0.2155, 0.0981, 0.2691, 0.1195]}, {"w": "typically", "b": [0.2748, 0.0981, 0.3453, 0.1195]}, {"w": "using", "b": [0.351, 0.0981, 0.3965, 0.1195]}, {"w": "autoencoders", "b": [0.4022, 0.0981, 0.5139, 0.1195]}, {"w": "rather", "b": [0.5197, 0.0981, 0.5702, 0.1195]}, {"w": "than", "b": [0.576, 0.0981, 0.614, 0.1195]}, {"w": "RBMs)", "b": [0.6198, 0.0981, 0.6784, 0.1195]}, {"w": "is", "b": [0.6841, 0.0981, 0.6974, 0.1195]}, {"w": "still", "b": [0.7031, 0.0981, 0.7332, 0.1195]}, {"w": "a", "b": [0.739, 0.0981, 0.7481, 0.1195]}, {"w": "good", "b": [0.7539, 0.0981, 0.7959, 0.1195]}, {"w": "option", "b": [0.8016, 0.0981, 0.8571, 0.1195]}, {"w": "when", "b": [0.1429, 0.1172, 0.1885, 0.1386]}, {"w": "you", "b": [0.1958, 0.1172, 0.2271, 0.1386]}, {"w": "have", "b": [0.2344, 0.1172, 0.2728, 0.1386]}, {"w": "a", "b": [0.2802, 0.1172, 0.2893, 0.1386]}, {"w": "complex", "b": [0.2966, 0.1172, 0.3676, 0.1386]}, {"w": "task", "b": [0.375, 0.1172, 0.4084, 0.1386]}, {"w": "to", "b": [0.4158, 0.1172, 0.4328, 0.1386]}, {"w": "solve,", "b": [0.4401, 0.1172, 0.4869, 0.1386]}, {"w": "no", "b": [0.4942, 0.1172, 0.5162, 0.1386]}, {"w": "similar", "b": [0.5236, 0.1172, 0.5816, 0.1386]}, {"w": "model", "b": [0.5889, 0.1172, 0.6417, 0.1386]}, {"w": "you", "b": [0.6491, 0.1172, 0.6803, 0.1386]}, {"w": "can", "b": [0.6877, 0.1172, 0.717, 0.1386]}, {"w": "reuse,", "b": [0.7244, 0.1172, 0.7733, 0.1386]}, {"w": "and", "b": [0.7806, 0.1172, 0.8121, 0.1386]}, {"w": "little", "b": [0.8195, 0.1172, 0.8572, 0.1386]}, {"w": "labeled", "b": [0.1429, 0.1362, 0.2018, 0.1576]}, {"w": "training", "b": [0.2066, 0.1362, 0.2735, 0.1576]}, {"w": "data", "b": [0.2782, 0.1362, 0.3135, 0.1576]}, {"w": "but", "b": [0.3182, 0.1362, 0.3462, 0.1576]}, {"w": "plenty", "b": [0.3509, 0.1362, 0.4029, 0.1576]}, {"w": "of", "b": [0.4076, 0.1362, 0.4244, 0.1576]}, {"w": "unlabeled", "b": [0.4292, 0.1362, 0.5106, 0.1576]}, {"w": "training", "b": [0.5153, 0.1362, 0.5823, 0.1576]}, {"w": "data.", "b": [0.587, 0.1362, 0.627, 0.1576]}]}, {"id": "b_1", "type": "paragraph", "text": "Pretraining on an Auxiliary Task", "words": [{"w": "Pretraining", "b": [0.1429, 0.1704, 0.2604, 0.1989]}, {"w": "on", "b": [0.2653, 0.1704, 0.2917, 0.1989]}, {"w": "an", "b": [0.2967, 0.1704, 0.3227, 0.1989]}, {"w": "Auxiliary", "b": [0.3276, 0.1704, 0.4185, 0.1989]}, {"w": "Task", "b": [0.4234, 0.1704, 0.4693, 0.1989]}]}, {"id": "b_2", "type": "paragraph", "text": "If you do not have much labeled training data, one last option is to train a first neural network on an auxiliary task for which you can easily obtain or generate labeled training data, then reuse the lower layers of that network for your actual task. The first neural network’s lower layers will learn feature detectors that will likely be reusa‐ ble by the second neural network.", "words": [{"w": "If", "b": [0.1429, 0.2048, 0.1561, 0.2263]}, {"w": "you", "b": [0.1612, 0.2048, 0.1925, 0.2263]}, {"w": "do", "b": [0.1976, 0.2048, 0.2192, 0.2263]}, {"w": "not", "b": [0.2243, 0.2048, 0.2526, 0.2263]}, {"w": "have", "b": [0.2577, 0.2048, 0.2961, 0.2263]}, {"w": "much", "b": [0.3012, 0.2048, 0.3489, 0.2263]}, {"w": "labeled", "b": [0.354, 0.2048, 0.4129, 0.2263]}, {"w": "training", "b": [0.418, 0.2048, 0.485, 0.2263]}, {"w": "data,", "b": [0.4901, 0.2048, 0.5301, 0.2263]}, {"w": "one", "b": [0.5351, 0.2048, 0.566, 0.2263]}, {"w": "last", "b": [0.5711, 0.2048, 0.5995, 0.2263]}, {"w": "option", "b": [0.6046, 0.2048, 0.6601, 0.2263]}, {"w": "is", "b": [0.6652, 0.2048, 0.6784, 0.2263]}, {"w": "to", "b": [0.6835, 0.2048, 0.7005, 0.2263]}, {"w": "train", "b": [0.7056, 0.2048, 0.7458, 0.2263]}, {"w": "a", "b": [0.7509, 0.2048, 0.76, 0.2263]}, {"w": "first", "b": [0.7651, 0.2048, 0.7986, 0.2263]}, {"w": "neural", "b": [0.8037, 0.2048, 0.8571, 0.2263]}, {"w": "network", "b": [0.1429, 0.2239, 0.2124, 0.2453]}, {"w": "on", "b": [0.221, 0.2239, 0.243, 0.2453]}, {"w": "an", "b": [0.2516, 0.2239, 0.2722, 0.2453]}, {"w": "auxiliary", "b": [0.2808, 0.2239, 0.3539, 0.2453]}, {"w": "task", "b": [0.3625, 0.2239, 0.396, 0.2453]}, {"w": "for", "b": [0.4046, 0.2239, 0.4291, 0.2453]}, {"w": "which", "b": [0.4377, 0.2239, 0.4887, 0.2453]}, {"w": "you", "b": [0.4973, 0.2239, 0.5285, 0.2453]}, {"w": "can", "b": [0.5371, 0.2239, 0.5665, 0.2453]}, {"w": "easily", "b": [0.5751, 0.2239, 0.6211, 0.2453]}, {"w": "obtain", "b": [0.6298, 0.2239, 0.6834, 0.2453]}, {"w": "or", "b": [0.692, 0.2239, 0.7104, 0.2453]}, {"w": "generate", "b": [0.719, 0.2239, 0.7896, 0.2453]}, {"w": "labeled", "b": [0.7982, 0.2239, 0.8571, 0.2453]}, {"w": "training", "b": [0.1429, 0.2429, 0.2098, 0.2644]}, {"w": "data,", "b": [0.217, 0.2429, 0.257, 0.2644]}, {"w": "then", "b": [0.2643, 0.2429, 0.302, 0.2644]}, {"w": "reuse", "b": [0.3092, 0.2429, 0.3534, 0.2644]}, {"w": "the", "b": [0.3606, 0.2429, 0.3869, 0.2644]}, {"w": "lower", "b": [0.3942, 0.2429, 0.4409, 0.2644]}, {"w": "layers", "b": [0.4482, 0.2429, 0.496, 0.2644]}, {"w": "of", "b": [0.5032, 0.2429, 0.52, 0.2644]}, {"w": "that", "b": [0.5273, 0.2429, 0.5598, 0.2644]}, {"w": "network", "b": [0.5671, 0.2429, 0.6366, 0.2644]}, {"w": "for", "b": [0.6439, 0.2429, 0.6684, 0.2644]}, {"w": "your", "b": [0.6756, 0.2429, 0.7146, 0.2644]}, {"w": "actual", "b": [0.7218, 0.2429, 0.7716, 0.2644]}, {"w": "task.", "b": [0.7789, 0.2429, 0.8171, 0.2644]}, {"w": "The", "b": [0.8243, 0.2429, 0.8572, 0.2644]}, {"w": "first", "b": [0.1429, 0.262, 0.1763, 0.2834]}, {"w": "neural", "b": [0.1816, 0.262, 0.235, 0.2834]}, {"w": "network’s", "b": [0.2402, 0.262, 0.3193, 0.2834]}, {"w": "lower", "b": [0.3245, 0.262, 0.3712, 0.2834]}, {"w": "layers", "b": [0.3764, 0.262, 0.4243, 0.2834]}, {"w": "will", "b": [0.4295, 0.262, 0.4599, 0.2834]}, {"w": "learn", "b": [0.4651, 0.262, 0.5075, 0.2834]}, {"w": "feature", "b": [0.5127, 0.262, 0.5705, 0.2834]}, {"w": "detectors", "b": [0.5757, 0.262, 0.6519, 0.2834]}, {"w": "that", "b": [0.6571, 0.262, 0.6897, 0.2834]}, {"w": "will", "b": [0.6949, 0.262, 0.7253, 0.2834]}, {"w": "likely", "b": [0.7305, 0.262, 0.7754, 0.2834]}, {"w": "be", "b": [0.7806, 0.262, 0.8001, 0.2834]}, {"w": "reusa‐", "b": [0.8053, 0.262, 0.8571, 0.2834]}, {"w": "ble", "b": [0.1429, 0.281, 0.1676, 0.3025]}, {"w": "by", "b": [0.1723, 0.281, 0.1924, 0.3025]}, {"w": "the", "b": [0.1972, 0.281, 0.2235, 0.3025]}, {"w": "second", "b": [0.2282, 0.281, 0.2866, 0.3025]}, {"w": "neural", "b": [0.2913, 0.281, 0.3448, 0.3025]}, {"w": "network.", "b": [0.3495, 0.281, 0.4238, 0.3025]}]}, {"id": "b_3", "type": "paragraph", "text": "For example, if you want to build a system to recognize faces, you may only have a few pictures of each individual—clearly not enough to train a good classifier. Gather‐ ing hundreds of pictures of each person would not be practical. However, you could gather a lot of pictures of random people on the web and train a first neural network to detect whether or not two different pictures feature the same person. Such a net‐ work would learn good feature detectors for faces, so reusing its lower layers would allow you to train a good face classifier using little training data.", "words": [{"w": "For", "b": [0.1429, 0.3092, 0.1718, 0.3306]}, {"w": "example,", "b": [0.1785, 0.3092, 0.2528, 0.3306]}, {"w": "if", "b": [0.2595, 0.3092, 0.2712, 0.3306]}, {"w": "you", "b": [0.2779, 0.3092, 0.3091, 0.3306]}, {"w": "want", "b": [0.3158, 0.3092, 0.3566, 0.3306]}, {"w": "to", "b": [0.3633, 0.3092, 0.3802, 0.3306]}, {"w": "build", "b": [0.3869, 0.3092, 0.4304, 0.3306]}, {"w": "a", "b": [0.4371, 0.3092, 0.4462, 0.3306]}, {"w": "system", "b": [0.4529, 0.3092, 0.51, 0.3306]}, {"w": "to", "b": [0.5167, 0.3092, 0.5337, 0.3306]}, {"w": "recognize", "b": [0.5403, 0.3092, 0.6207, 0.3306]}, {"w": "faces,", "b": [0.6274, 0.3092, 0.6727, 0.3306]}, {"w": "you", "b": [0.6794, 0.3092, 0.7107, 0.3306]}, {"w": "may", "b": [0.7173, 0.3092, 0.7527, 0.3306]}, {"w": "only", "b": [0.7594, 0.3092, 0.7963, 0.3306]}, {"w": "have", "b": [0.8029, 0.3092, 0.8413, 0.3306]}, {"w": "a", "b": [0.848, 0.3092, 0.8571, 0.3306]}, {"w": "few", "b": [0.1428, 0.3282, 0.1721, 0.3496]}, {"w": "pictures", "b": [0.1774, 0.3282, 0.2444, 0.3496]}, {"w": "of", "b": [0.2497, 0.3282, 0.2665, 0.3496]}, {"w": "each", "b": [0.2718, 0.3282, 0.3097, 0.3496]}, {"w": "individual—clearly", "b": [0.315, 0.3282, 0.4742, 0.3496]}, {"w": "not", "b": [0.4795, 0.3282, 0.5079, 0.3496]}, {"w": "enough", "b": [0.5132, 0.3282, 0.576, 0.3496]}, {"w": "to", "b": [0.5813, 0.3282, 0.5983, 0.3496]}, {"w": "train", "b": [0.6036, 0.3282, 0.6438, 0.3496]}, {"w": "a", "b": [0.6491, 0.3282, 0.6582, 0.3496]}, {"w": "good", "b": [0.6635, 0.3282, 0.7055, 0.3496]}, {"w": "classifier.", "b": [0.7108, 0.3282, 0.7867, 0.3496]}, {"w": "Gather‐", "b": [0.792, 0.3282, 0.8571, 0.3496]}, {"w": "ing", "b": [0.1429, 0.3473, 0.1696, 0.3687]}, {"w": "hundreds", "b": [0.1757, 0.3473, 0.2551, 0.3687]}, {"w": "of", "b": [0.2612, 0.3473, 0.278, 0.3687]}, {"w": "pictures", "b": [0.284, 0.3473, 0.351, 0.3687]}, {"w": "of", "b": [0.3571, 0.3473, 0.3739, 0.3687]}, {"w": "each", "b": [0.38, 0.3473, 0.4179, 0.3687]}, {"w": "person", "b": [0.424, 0.3473, 0.4811, 0.3687]}, {"w": "would", "b": [0.4872, 0.3473, 0.5395, 0.3687]}, {"w": "not", "b": [0.5455, 0.3473, 0.5739, 0.3687]}, {"w": "be", "b": [0.58, 0.3473, 0.5994, 0.3687]}, {"w": "practical.", "b": [0.6055, 0.3473, 0.682, 0.3687]}, {"w": "However,", "b": [0.6881, 0.3473, 0.767, 0.3687]}, {"w": "you", "b": [0.773, 0.3473, 0.8043, 0.3687]}, {"w": "could", "b": [0.8104, 0.3473, 0.8572, 0.3687]}, {"w": "gather", "b": [0.1429, 0.3663, 0.1954, 0.3877]}, {"w": "a", "b": [0.2009, 0.3663, 0.2101, 0.3877]}, {"w": "lot", "b": [0.2156, 0.3663, 0.2378, 0.3877]}, {"w": "of", "b": [0.2433, 0.3663, 0.2601, 0.3877]}, {"w": "pictures", "b": [0.2656, 0.3663, 0.3325, 0.3877]}, {"w": "of", "b": [0.338, 0.3663, 0.3548, 0.3877]}, {"w": "random", "b": [0.3603, 0.3663, 0.4273, 0.3877]}, {"w": "people", "b": [0.4328, 0.3663, 0.4882, 0.3877]}, {"w": "on", "b": [0.4937, 0.3663, 0.5157, 0.3877]}, {"w": "the", "b": [0.5212, 0.3663, 0.5476, 0.3877]}, {"w": "web", "b": [0.5531, 0.3663, 0.5868, 0.3877]}, {"w": "and", "b": [0.5923, 0.3663, 0.6238, 0.3877]}, {"w": "train", "b": [0.6293, 0.3663, 0.6695, 0.3877]}, {"w": "a", "b": [0.675, 0.3663, 0.6842, 0.3877]}, {"w": "first", "b": [0.6897, 0.3663, 0.7231, 0.3877]}, {"w": "neural", "b": [0.7286, 0.3663, 0.7821, 0.3877]}, {"w": "network", "b": [0.7876, 0.3663, 0.8571, 0.3877]}, {"w": "to", "b": [0.1429, 0.3853, 0.1598, 0.4068]}, {"w": "detect", "b": [0.1662, 0.3853, 0.2164, 0.4068]}, {"w": "whether", "b": [0.2228, 0.3853, 0.2911, 0.4068]}, {"w": "or", "b": [0.2975, 0.3853, 0.3159, 0.4068]}, {"w": "not", "b": [0.3223, 0.3853, 0.3506, 0.4068]}, {"w": "two", "b": [0.357, 0.3853, 0.3883, 0.4068]}, {"w": "different", "b": [0.3946, 0.3853, 0.4664, 0.4068]}, {"w": "pictures", "b": [0.4727, 0.3853, 0.5397, 0.4068]}, {"w": "feature", "b": [0.5461, 0.3853, 0.6038, 0.4068]}, {"w": "the", "b": [0.6102, 0.3853, 0.6366, 0.4068]}, {"w": "same", "b": [0.6429, 0.3853, 0.6857, 0.4068]}, {"w": "person.", "b": [0.692, 0.3853, 0.754, 0.4068]}, {"w": "Such", "b": [0.7603, 0.3853, 0.8012, 0.4068]}, {"w": "a", "b": [0.8076, 0.3853, 0.8167, 0.4068]}, {"w": "net‐", "b": [0.8231, 0.3853, 0.8571, 0.4068]}, {"w": "work", "b": [0.1429, 0.4044, 0.1858, 0.4258]}, {"w": "would", "b": [0.1923, 0.4044, 0.2445, 0.4258]}, {"w": "learn", "b": [0.251, 0.4044, 0.2934, 0.4258]}, {"w": "good", "b": [0.2999, 0.4044, 0.3419, 0.4258]}, {"w": "feature", "b": [0.3483, 0.4044, 0.4061, 0.4258]}, {"w": "detectors", "b": [0.4126, 0.4044, 0.4888, 0.4258]}, {"w": "for", "b": [0.4953, 0.4044, 0.5198, 0.4258]}, {"w": "faces,", "b": [0.5263, 0.4044, 0.5716, 0.4258]}, {"w": "so", "b": [0.5781, 0.4044, 0.5964, 0.4258]}, {"w": "reusing", "b": [0.6029, 0.4044, 0.6649, 0.4258]}, {"w": "its", "b": [0.6713, 0.4044, 0.6909, 0.4258]}, {"w": "lower", "b": [0.6974, 0.4044, 0.7441, 0.4258]}, {"w": "layers", "b": [0.7506, 0.4044, 0.7985, 0.4258]}, {"w": "would", "b": [0.8049, 0.4044, 0.8572, 0.4258]}, {"w": "allow", "b": [0.1429, 0.4234, 0.1874, 0.4449]}, {"w": "you", "b": [0.1922, 0.4234, 0.2234, 0.4449]}, {"w": "to", "b": [0.2282, 0.4234, 0.2451, 0.4449]}, {"w": "train", "b": [0.2499, 0.4234, 0.2901, 0.4449]}, {"w": "a", "b": [0.2948, 0.4234, 0.3039, 0.4449]}, {"w": "good", "b": [0.3087, 0.4234, 0.3507, 0.4449]}, {"w": "face", "b": [0.3554, 0.4234, 0.3884, 0.4449]}, {"w": "classifier", "b": [0.3931, 0.4234, 0.4655, 0.4449]}, {"w": "using", "b": [0.4703, 0.4234, 0.5157, 0.4449]}, {"w": "little", "b": [0.5204, 0.4234, 0.5581, 0.4449]}, {"w": "training", "b": [0.5629, 0.4234, 0.6298, 0.4449]}, {"w": "data.", "b": [0.6345, 0.4234, 0.6745, 0.4449]}]}, {"id": "b_4", "type": "paragraph", "text": "For natural language processing (NLP) applications, you can easily download millions of text documents and automatically generate labeled data from it. For example, you could randomly mask out some words and train a model to predict what the missing words are (e.g., it should predict that the missing word in the sentence “What ___ you saying?” is probably “are” or “were”). If you can train a model to reach good per‐ formance on this task, then it will already know quite a lot about language, and you can certainly reuse it for your actual task, and fine-tune it on your labeled data (we will discuss more pretraining tasks in ???).", "words": [{"w": "For", "b": [0.1429, 0.4516, 0.1718, 0.473]}, {"w": "natural", "b": [0.1773, 0.4514, 0.2374, 0.473]}, {"w": "language", "b": [0.2429, 0.4514, 0.3155, 0.473]}, {"w": "processing", "b": [0.321, 0.4514, 0.4024, 0.473]}, {"w": "(NLP)", "b": [0.4079, 0.4516, 0.4607, 0.473]}, {"w": "applications,", "b": [0.4662, 0.4516, 0.5715, 0.473]}, {"w": "you", "b": [0.577, 0.4516, 0.6082, 0.473]}, {"w": "can", "b": [0.6136, 0.4516, 0.643, 0.473]}, {"w": "easily", "b": [0.6484, 0.4516, 0.6945, 0.473]}, {"w": "download", "b": [0.6999, 0.4516, 0.7833, 0.473]}, {"w": "millions", "b": [0.7887, 0.4516, 0.8571, 0.473]}, {"w": "of", "b": [0.1429, 0.4706, 0.1596, 0.492]}, {"w": "text", "b": [0.1656, 0.4706, 0.197, 0.492]}, {"w": "documents", "b": [0.203, 0.4706, 0.2955, 0.492]}, {"w": "and", "b": [0.3015, 0.4706, 0.333, 0.492]}, {"w": "automatically", "b": [0.339, 0.4706, 0.4516, 0.492]}, {"w": "generate", "b": [0.4576, 0.4706, 0.5281, 0.492]}, {"w": "labeled", "b": [0.5341, 0.4706, 0.5931, 0.492]}, {"w": "data", "b": [0.5991, 0.4706, 0.6344, 0.492]}, {"w": "from", "b": [0.6404, 0.4706, 0.6819, 0.492]}, {"w": "it.", "b": [0.6879, 0.4706, 0.7046, 0.492]}, {"w": "For", "b": [0.7106, 0.4706, 0.7396, 0.492]}, {"w": "example,", "b": [0.7456, 0.4706, 0.8199, 0.492]}, {"w": "you", "b": [0.8259, 0.4706, 0.8571, 0.492]}, {"w": "could", "b": [0.1428, 0.4897, 0.1896, 0.5111]}, {"w": "randomly", "b": [0.1951, 0.4897, 0.2769, 0.5111]}, {"w": "mask", "b": [0.2824, 0.4897, 0.3265, 0.5111]}, {"w": "out", "b": [0.332, 0.4897, 0.3601, 0.5111]}, {"w": "some", "b": [0.3655, 0.4897, 0.4097, 0.5111]}, {"w": "words", "b": [0.4152, 0.4897, 0.4665, 0.5111]}, {"w": "and", "b": [0.4719, 0.4897, 0.5035, 0.5111]}, {"w": "train", "b": [0.5089, 0.4897, 0.5491, 0.5111]}, {"w": "a", "b": [0.5546, 0.4897, 0.5638, 0.5111]}, {"w": "model", "b": [0.5692, 0.4897, 0.622, 0.5111]}, {"w": "to", "b": [0.6275, 0.4897, 0.6445, 0.5111]}, {"w": "predict", "b": [0.65, 0.4897, 0.7092, 0.5111]}, {"w": "what", "b": [0.7147, 0.4897, 0.7552, 0.5111]}, {"w": "the", "b": [0.7607, 0.4897, 0.787, 0.5111]}, {"w": "missing", "b": [0.7925, 0.4897, 0.8571, 0.5111]}, {"w": "words", "b": [0.1429, 0.5087, 0.1941, 0.5301]}, {"w": "are", "b": [0.2014, 0.5087, 0.2271, 0.5301]}, {"w": "(e.g.,", "b": [0.2343, 0.5087, 0.2744, 0.5301]}, {"w": "it", "b": [0.2816, 0.5087, 0.2935, 0.5301]}, {"w": "should", "b": [0.3007, 0.5087, 0.3575, 0.5301]}, {"w": "predict", "b": [0.3647, 0.5087, 0.4239, 0.5301]}, {"w": "that", "b": [0.4311, 0.5087, 0.4637, 0.5301]}, {"w": "the", "b": [0.4709, 0.5087, 0.4973, 0.5301]}, {"w": "missing", "b": [0.5045, 0.5087, 0.5691, 0.5301]}, {"w": "word", "b": [0.5764, 0.5087, 0.62, 0.5301]}, {"w": "in", "b": [0.6272, 0.5087, 0.6442, 0.5301]}, {"w": "the", "b": [0.6514, 0.5087, 0.6777, 0.5301]}, {"w": "sentence", "b": [0.6849, 0.5087, 0.7567, 0.5301]}, {"w": "“What", "b": [0.7639, 0.5087, 0.8187, 0.5301]}, {"w": "___", "b": [0.8259, 0.5087, 0.8571, 0.5301]}, {"w": "you", "b": [0.1429, 0.5278, 0.1741, 0.5492]}, {"w": "saying?”", "b": [0.1794, 0.5278, 0.2488, 0.5492]}, {"w": "is", "b": [0.2541, 0.5278, 0.2673, 0.5492]}, {"w": "probably", "b": [0.2726, 0.5278, 0.3471, 0.5492]}, {"w": "“are”", "b": [0.3524, 0.5278, 0.3922, 0.5492]}, {"w": "or", "b": [0.3975, 0.5278, 0.4159, 0.5492]}, {"w": "“were”).", "b": [0.4212, 0.5278, 0.4883, 0.5492]}, {"w": "If", "b": [0.4936, 0.5278, 0.5069, 0.5492]}, {"w": "you", "b": [0.5122, 0.5278, 0.5435, 0.5492]}, {"w": "can", "b": [0.5488, 0.5278, 0.5781, 0.5492]}, {"w": "train", "b": [0.5835, 0.5278, 0.6237, 0.5492]}, {"w": "a", "b": [0.629, 0.5278, 0.6381, 0.5492]}, {"w": "model", "b": [0.6435, 0.5278, 0.6963, 0.5492]}, {"w": "to", "b": [0.7016, 0.5278, 0.7186, 0.5492]}, {"w": "reach", "b": [0.7239, 0.5278, 0.7696, 0.5492]}, {"w": "good", "b": [0.7749, 0.5278, 0.8169, 0.5492]}, {"w": "per‐", "b": [0.8222, 0.5278, 0.8571, 0.5492]}, {"w": "formance", "b": [0.1429, 0.5468, 0.2226, 0.5682]}, {"w": "on", "b": [0.2288, 0.5468, 0.2508, 0.5682]}, {"w": "this", "b": [0.257, 0.5468, 0.2877, 0.5682]}, {"w": "task,", "b": [0.2939, 0.5468, 0.3321, 0.5682]}, {"w": "then", "b": [0.3383, 0.5468, 0.376, 0.5682]}, {"w": "it", "b": [0.3822, 0.5468, 0.3941, 0.5682]}, {"w": "will", "b": [0.4003, 0.5468, 0.4307, 0.5682]}, {"w": "already", "b": [0.4369, 0.5468, 0.4976, 0.5682]}, {"w": "know", "b": [0.5037, 0.5468, 0.5504, 0.5682]}, {"w": "quite", "b": [0.5565, 0.5468, 0.599, 0.5682]}, {"w": "a", "b": [0.6052, 0.5468, 0.6143, 0.5682]}, {"w": "lot", "b": [0.6205, 0.5468, 0.6428, 0.5682]}, {"w": "about", "b": [0.6489, 0.5468, 0.6967, 0.5682]}, {"w": "language,", "b": [0.7029, 0.5468, 0.782, 0.5682]}, {"w": "and", "b": [0.7882, 0.5468, 0.8197, 0.5682]}, {"w": "you", "b": [0.8259, 0.5468, 0.8571, 0.5682]}, {"w": "can", "b": [0.1428, 0.5658, 0.1722, 0.5873]}, {"w": "certainly", "b": [0.1788, 0.5658, 0.2515, 0.5873]}, {"w": "reuse", "b": [0.258, 0.5658, 0.3022, 0.5873]}, {"w": "it", "b": [0.3088, 0.5658, 0.3207, 0.5873]}, {"w": "for", "b": [0.3273, 0.5658, 0.3518, 0.5873]}, {"w": "your", "b": [0.3583, 0.5658, 0.3973, 0.5873]}, {"w": "actual", "b": [0.4039, 0.5658, 0.4537, 0.5873]}, {"w": "task,", "b": [0.4602, 0.5658, 0.4985, 0.5873]}, {"w": "and", "b": [0.505, 0.5658, 0.5366, 0.5873]}, {"w": "fine-tune", "b": [0.5432, 0.5658, 0.6202, 0.5873]}, {"w": "it", "b": [0.6268, 0.5658, 0.6387, 0.5873]}, {"w": "on", "b": [0.6453, 0.5658, 0.6673, 0.5873]}, {"w": "your", "b": [0.6739, 0.5658, 0.7129, 0.5873]}, {"w": "labeled", "b": [0.7194, 0.5658, 0.7784, 0.5873]}, {"w": "data", "b": [0.785, 0.5658, 0.8202, 0.5873]}, {"w": "(we", "b": [0.8268, 0.5658, 0.8571, 0.5873]}, {"w": "will", "b": [0.1429, 0.5849, 0.1733, 0.6063]}, {"w": "discuss", "b": [0.178, 0.5849, 0.2374, 0.6063]}, {"w": "more", "b": [0.2421, 0.5849, 0.2864, 0.6063]}, {"w": "pretraining", "b": [0.2911, 0.5849, 0.3855, 0.6063]}, {"w": "tasks", "b": [0.3903, 0.5849, 0.4314, 0.6063]}, {"w": "in", "b": [0.4361, 0.5849, 0.4531, 0.6063]}, {"w": "???).", "b": [0.4578, 0.5849, 0.4935, 0.6063]}]}, {"id": "b_5", "type": "paragraph", "text": "Self-supervised learning is when you automatically generate the labels from the data itself, then you train a model on the resulting “labeled” dataset using supervised learning techniques. Since this approach requires no human labeling whatsoever, it is best classi‐ fied as a form of unsupervised learning.", "words": [{"w": "Self-supervised", "b": [0.2714, 0.6267, 0.3818, 0.6464]}, {"w": "learning", "b": [0.3917, 0.6267, 0.4527, 0.6464]}, {"w": "is", "b": [0.4626, 0.6268, 0.4746, 0.6464]}, {"w": "when", "b": [0.4845, 0.6268, 0.5262, 0.6464]}, {"w": "you", "b": [0.5361, 0.6268, 0.5646, 0.6464]}, {"w": "automatically", "b": [0.5745, 0.6268, 0.6774, 0.6464]}, {"w": "generate", "b": [0.6873, 0.6268, 0.7518, 0.6464]}, {"w": "the", "b": [0.7616, 0.6268, 0.7857, 0.6464]}, {"w": "labels", "b": [0.2714, 0.6443, 0.3142, 0.6638]}, {"w": "from", "b": [0.3199, 0.6443, 0.3579, 0.6638]}, {"w": "the", "b": [0.3636, 0.6443, 0.3877, 0.6638]}, {"w": "data", "b": [0.3934, 0.6443, 0.4256, 0.6638]}, {"w": "itself,", "b": [0.4313, 0.6443, 0.4721, 0.6638]}, {"w": "then", "b": [0.4778, 0.6443, 0.5123, 0.6638]}, {"w": "you", "b": [0.518, 0.6443, 0.5466, 0.6638]}, {"w": "train", "b": [0.5523, 0.6443, 0.589, 0.6638]}, {"w": "a", "b": [0.5947, 0.6443, 0.6031, 0.6638]}, {"w": "model", "b": [0.6088, 0.6443, 0.6571, 0.6638]}, {"w": "on", "b": [0.6628, 0.6443, 0.6829, 0.6638]}, {"w": "the", "b": [0.6886, 0.6443, 0.7127, 0.6638]}, {"w": "resulting", "b": [0.7184, 0.6443, 0.7857, 0.6638]}, {"w": "“labeled”", "b": [0.2714, 0.6617, 0.3401, 0.6812]}, {"w": "dataset", "b": [0.3472, 0.6617, 0.4004, 0.6812]}, {"w": "using", "b": [0.4075, 0.6617, 0.4491, 0.6812]}, {"w": "supervised", "b": [0.4562, 0.6617, 0.5381, 0.6812]}, {"w": "learning", "b": [0.5453, 0.6617, 0.6085, 0.6812]}, {"w": "techniques.", "b": [0.6157, 0.6617, 0.7026, 0.6812]}, {"w": "Since", "b": [0.7098, 0.6617, 0.7505, 0.6812]}, {"w": "this", "b": [0.7576, 0.6617, 0.7857, 0.6812]}, {"w": "approach", "b": [0.2714, 0.6791, 0.3427, 0.6987]}, {"w": "requires", "b": [0.349, 0.6791, 0.4113, 0.6987]}, {"w": "no", "b": [0.4175, 0.6791, 0.4377, 0.6987]}, {"w": "human", "b": [0.444, 0.6791, 0.4983, 0.6987]}, {"w": "labeling", "b": [0.5045, 0.6791, 0.5647, 0.6987]}, {"w": "whatsoever,", "b": [0.571, 0.6791, 0.66, 0.6987]}, {"w": "it", "b": [0.6662, 0.6791, 0.6771, 0.6987]}, {"w": "is", "b": [0.6834, 0.6791, 0.6955, 0.6987]}, {"w": "best", "b": [0.7018, 0.6791, 0.7323, 0.6987]}, {"w": "classi‐", "b": [0.7386, 0.6791, 0.7857, 0.6987]}, {"w": "fied", "b": [0.2714, 0.6965, 0.3003, 0.7161]}, {"w": "as", "b": [0.3046, 0.6965, 0.32, 0.7161]}, {"w": "a", "b": [0.3243, 0.6965, 0.3327, 0.7161]}, {"w": "form", "b": [0.337, 0.6965, 0.375, 0.7161]}, {"w": "of", "b": [0.3793, 0.6965, 0.3947, 0.7161]}, {"w": "unsupervised", "b": [0.399, 0.6965, 0.5014, 0.7161]}, {"w": "learning.", "b": [0.5057, 0.6965, 0.5733, 0.7161]}]}, {"id": "b_6", "type": "paragraph", "text": "Faster Optimizers", "words": [{"w": "Faster", "b": [0.1428, 0.7326, 0.219, 0.7668]}, {"w": "Optimizers", "b": [0.2249, 0.7326, 0.3581, 0.7668]}]}, {"id": "b_7", "type": "paragraph", "text": "Training a very large deep neural network can be painfully slow. So far we have seen four ways to speed up training (and reach a better solution): applying a good initiali‐ zation strategy for the connection weights, using a good activation function, using Batch Normalization, and reusing parts of a pretrained network (possibly built on an auxiliary task or using unsupervised learning). Another huge speed boost comes from using a faster optimizer than the regular Gradient Descent optimizer. In this section", "words": [{"w": "Training", "b": [0.1429, 0.7737, 0.2146, 0.7952]}, {"w": "a", "b": [0.2204, 0.7737, 0.2295, 0.7952]}, {"w": "very", "b": [0.2354, 0.7737, 0.2718, 0.7952]}, {"w": "large", "b": [0.2776, 0.7737, 0.3184, 0.7952]}, {"w": "deep", "b": [0.3242, 0.7737, 0.3638, 0.7952]}, {"w": "neural", "b": [0.3697, 0.7737, 0.4231, 0.7952]}, {"w": "network", "b": [0.429, 0.7737, 0.4985, 0.7952]}, {"w": "can", "b": [0.5044, 0.7737, 0.5337, 0.7952]}, {"w": "be", "b": [0.5396, 0.7737, 0.559, 0.7952]}, {"w": "painfully", "b": [0.5649, 0.7737, 0.6392, 0.7952]}, {"w": "slow.", "b": [0.6451, 0.7737, 0.6861, 0.7952]}, {"w": "So", "b": [0.692, 0.7737, 0.7125, 0.7952]}, {"w": "far", "b": [0.7183, 0.7737, 0.7413, 0.7952]}, {"w": "we", "b": [0.7472, 0.7737, 0.7703, 0.7952]}, {"w": "have", "b": [0.7762, 0.7737, 0.8145, 0.7952]}, {"w": "seen", "b": [0.8204, 0.7737, 0.8571, 0.7952]}, {"w": "four", "b": [0.1428, 0.7928, 0.1784, 0.8142]}, {"w": "ways", "b": [0.1839, 0.7928, 0.2242, 0.8142]}, {"w": "to", "b": [0.2297, 0.7928, 0.2467, 0.8142]}, {"w": "speed", "b": [0.2522, 0.7928, 0.2995, 0.8142]}, {"w": "up", "b": [0.305, 0.7928, 0.327, 0.8142]}, {"w": "training", "b": [0.3325, 0.7928, 0.3994, 0.8142]}, {"w": "(and", "b": [0.405, 0.7928, 0.4437, 0.8142]}, {"w": "reach", "b": [0.4492, 0.7928, 0.4949, 0.8142]}, {"w": "a", "b": [0.5004, 0.7928, 0.5096, 0.8142]}, {"w": "better", "b": [0.5151, 0.7928, 0.5638, 0.8142]}, {"w": "solution):", "b": [0.5693, 0.7928, 0.6498, 0.8142]}, {"w": "applying", "b": [0.6554, 0.7928, 0.7275, 0.8142]}, {"w": "a", "b": [0.733, 0.7928, 0.7422, 0.8142]}, {"w": "good", "b": [0.7477, 0.7928, 0.7897, 0.8142]}, {"w": "initiali‐", "b": [0.7952, 0.7928, 0.8571, 0.8142]}, {"w": "zation", "b": [0.1429, 0.8118, 0.1943, 0.8333]}, {"w": "strategy", "b": [0.202, 0.8118, 0.2675, 0.8333]}, {"w": "for", "b": [0.2751, 0.8118, 0.2997, 0.8333]}, {"w": "the", "b": [0.3073, 0.8118, 0.3337, 0.8333]}, {"w": "connection", "b": [0.3413, 0.8118, 0.4352, 0.8333]}, {"w": "weights,", "b": [0.4428, 0.8118, 0.5108, 0.8333]}, {"w": "using", "b": [0.5184, 0.8118, 0.5639, 0.8333]}, {"w": "a", "b": [0.5715, 0.8118, 0.5807, 0.8333]}, {"w": "good", "b": [0.5883, 0.8118, 0.6303, 0.8333]}, {"w": "activation", "b": [0.638, 0.8118, 0.7202, 0.8333]}, {"w": "function,", "b": [0.7279, 0.8118, 0.804, 0.8333]}, {"w": "using", "b": [0.8117, 0.8118, 0.8571, 0.8333]}, {"w": "Batch", "b": [0.1429, 0.8309, 0.1901, 0.8523]}, {"w": "Normalization,", "b": [0.1956, 0.8309, 0.3222, 0.8523]}, {"w": "and", "b": [0.3277, 0.8309, 0.3592, 0.8523]}, {"w": "reusing", "b": [0.3647, 0.8309, 0.4267, 0.8523]}, {"w": "parts", "b": [0.4321, 0.8309, 0.4739, 0.8523]}, {"w": "of", "b": [0.4794, 0.8309, 0.4962, 0.8523]}, {"w": "a", "b": [0.5016, 0.8309, 0.5108, 0.8523]}, {"w": "pretrained", "b": [0.5163, 0.8309, 0.6038, 0.8523]}, {"w": "network", "b": [0.6093, 0.8309, 0.6788, 0.8523]}, {"w": "(possibly", "b": [0.6843, 0.8309, 0.7593, 0.8523]}, {"w": "built", "b": [0.7648, 0.8309, 0.8037, 0.8523]}, {"w": "on", "b": [0.8091, 0.8309, 0.8311, 0.8523]}, {"w": "an", "b": [0.8366, 0.8309, 0.8571, 0.8523]}, {"w": "auxiliary", "b": [0.1428, 0.8499, 0.216, 0.8713]}, {"w": "task", "b": [0.2207, 0.8499, 0.2542, 0.8713]}, {"w": "or", "b": [0.2589, 0.8499, 0.2773, 0.8713]}, {"w": "using", "b": [0.282, 0.8499, 0.3274, 0.8713]}, {"w": "unsupervised", "b": [0.3322, 0.8499, 0.4442, 0.8713]}, {"w": "learning).", "b": [0.4489, 0.8499, 0.53, 0.8713]}, {"w": "Another", "b": [0.5347, 0.8499, 0.6052, 0.8713]}, {"w": "huge", "b": [0.6099, 0.8499, 0.6503, 0.8713]}, {"w": "speed", "b": [0.655, 0.8499, 0.7023, 0.8713]}, {"w": "boost", "b": [0.707, 0.8499, 0.7529, 0.8713]}, {"w": "comes", "b": [0.7576, 0.8499, 0.8106, 0.8713]}, {"w": "from", "b": [0.8153, 0.8499, 0.8569, 0.8713]}, {"w": "using", "b": [0.1428, 0.869, 0.1883, 0.8904]}, {"w": "a", "b": [0.1944, 0.869, 0.2036, 0.8904]}, {"w": "faster", "b": [0.2097, 0.869, 0.2556, 0.8904]}, {"w": "optimizer", "b": [0.2617, 0.869, 0.3432, 0.8904]}, {"w": "than", "b": [0.3493, 0.869, 0.3874, 0.8904]}, {"w": "the", "b": [0.3935, 0.869, 0.4198, 0.8904]}, {"w": "regular", "b": [0.426, 0.869, 0.4855, 0.8904]}, {"w": "Gradient", "b": [0.4917, 0.869, 0.5662, 0.8904]}, {"w": "Descent", "b": [0.5724, 0.869, 0.6392, 0.8904]}, {"w": "optimizer.", "b": [0.6453, 0.869, 0.7302, 0.8904]}, {"w": "In", "b": [0.7364, 0.869, 0.7549, 0.8904]}, {"w": "this", "b": [0.761, 0.869, 0.7917, 0.8904]}, {"w": "section", "b": [0.7979, 0.869, 0.8571, 0.8904]}]}, {"id": "b_8", "type": "paragraph", "text": "344 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "344", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2745, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 371, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "12 “Some methods of speeding up the convergence of iteration methods,” B. Polyak (1964).", "words": [{"w": "12", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Some", "b": [0.1587, 0.8749, 0.2, 0.8912]}, {"w": "methods", "b": [0.2036, 0.8749, 0.259, 0.8912]}, {"w": "of", "b": [0.2626, 0.8749, 0.2753, 0.8912]}, {"w": "speeding", "b": [0.279, 0.8749, 0.3353, 0.8912]}, {"w": "up", "b": [0.3389, 0.8749, 0.3557, 0.8912]}, {"w": "the", "b": [0.3593, 0.8749, 0.3793, 0.8912]}, {"w": "convergence", "b": [0.383, 0.8749, 0.4624, 0.8912]}, {"w": "of", "b": [0.466, 0.8749, 0.4788, 0.8912]}, {"w": "iteration", "b": [0.4824, 0.8749, 0.5367, 0.8912]}, {"w": "methods,”", "b": [0.5403, 0.8749, 0.6034, 0.8912]}, {"w": "B.", "b": [0.607, 0.8749, 0.6197, 0.8912]}, {"w": "Polyak", "b": [0.6233, 0.8749, 0.666, 0.8912]}, {"w": "(1964).", "b": [0.6696, 0.8749, 0.7147, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "we will present the most popular ones: Momentum optimization, Nesterov Acceler‐ ated Gradient, AdaGrad, RMSProp, and finally Adam and Nadam optimization.", "words": [{"w": "we", "b": [0.1429, 0.0791, 0.166, 0.1005]}, {"w": "will", "b": [0.1726, 0.0791, 0.203, 0.1005]}, {"w": "present", "b": [0.2095, 0.0791, 0.2709, 0.1005]}, {"w": "the", "b": [0.2775, 0.0791, 0.3038, 0.1005]}, {"w": "most", "b": [0.3104, 0.0791, 0.3521, 0.1005]}, {"w": "popular", "b": [0.3587, 0.0791, 0.4243, 0.1005]}, {"w": "ones:", "b": [0.4309, 0.0791, 0.4742, 0.1005]}, {"w": "Momentum", "b": [0.4808, 0.0791, 0.5808, 0.1005]}, {"w": "optimization,", "b": [0.5874, 0.0791, 0.6997, 0.1005]}, {"w": "Nesterov", "b": [0.7063, 0.0791, 0.781, 0.1005]}, {"w": "Acceler‐", "b": [0.7875, 0.0791, 0.8571, 0.1005]}, {"w": "ated", "b": [0.1429, 0.0981, 0.1778, 0.1195]}, {"w": "Gradient,", "b": [0.1825, 0.0981, 0.2619, 0.1195]}, {"w": "AdaGrad,", "b": [0.2666, 0.0981, 0.3481, 0.1195]}, {"w": "RMSProp,", "b": [0.3528, 0.0981, 0.4394, 0.1195]}, {"w": "and", "b": [0.4441, 0.0981, 0.4756, 0.1195]}, {"w": "finally", "b": [0.4804, 0.0981, 0.5327, 0.1195]}, {"w": "Adam", "b": [0.5375, 0.0981, 0.5885, 0.1195]}, {"w": "and", "b": [0.5933, 0.0981, 0.6248, 0.1195]}, {"w": "Nadam", "b": [0.6295, 0.0981, 0.6908, 0.1195]}, {"w": "optimization.", "b": [0.6956, 0.0981, 0.8079, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "Momentum Optimization", "words": [{"w": "Momentum", "b": [0.1429, 0.1323, 0.2642, 0.1609]}, {"w": "Optimization", "b": [0.2691, 0.1323, 0.4038, 0.1609]}]}, {"id": "b_3", "type": "paragraph", "text": "Imagine a bowling ball rolling down a gentle slope on a smooth surface: it will start out slowly, but it will quickly pick up momentum until it eventually reaches terminal velocity (if there is some friction or air resistance). This is the very simple idea behind Momentum optimization, proposed by Boris Polyak in 1964.12 In contrast, regular Gradient Descent will simply take small regular steps down the slope, so it will take much more time to reach the bottom.", "words": [{"w": "Imagine", "b": [0.1429, 0.1668, 0.2118, 0.1882]}, {"w": "a", "b": [0.2181, 0.1668, 0.2272, 0.1882]}, {"w": "bowling", "b": [0.2335, 0.1668, 0.301, 0.1882]}, {"w": "ball", "b": [0.3073, 0.1668, 0.3376, 0.1882]}, {"w": "rolling", "b": [0.3439, 0.1668, 0.3995, 0.1882]}, {"w": "down", "b": [0.4058, 0.1668, 0.4531, 0.1882]}, {"w": "a", "b": [0.4595, 0.1668, 0.4686, 0.1882]}, {"w": "gentle", "b": [0.4749, 0.1668, 0.525, 0.1882]}, {"w": "slope", "b": [0.5313, 0.1668, 0.5746, 0.1882]}, {"w": "on", "b": [0.5809, 0.1668, 0.603, 0.1882]}, {"w": "a", "b": [0.6093, 0.1668, 0.6184, 0.1882]}, {"w": "smooth", "b": [0.6247, 0.1668, 0.6882, 0.1882]}, {"w": "surface:", "b": [0.6945, 0.1668, 0.7586, 0.1882]}, {"w": "it", "b": [0.765, 0.1668, 0.7769, 0.1882]}, {"w": "will", "b": [0.7832, 0.1668, 0.8136, 0.1882]}, {"w": "start", "b": [0.8199, 0.1668, 0.8571, 0.1882]}, {"w": "out", "b": [0.1429, 0.1858, 0.1709, 0.2072]}, {"w": "slowly,", "b": [0.1765, 0.1858, 0.2323, 0.2072]}, {"w": "but", "b": [0.2379, 0.1858, 0.2659, 0.2072]}, {"w": "it", "b": [0.2714, 0.1858, 0.2834, 0.2072]}, {"w": "will", "b": [0.2889, 0.1858, 0.3193, 0.2072]}, {"w": "quickly", "b": [0.3249, 0.1858, 0.3862, 0.2072]}, {"w": "pick", "b": [0.3917, 0.1858, 0.4274, 0.2072]}, {"w": "up", "b": [0.4329, 0.1858, 0.4549, 0.2072]}, {"w": "momentum", "b": [0.4605, 0.1858, 0.5596, 0.2072]}, {"w": "until", "b": [0.5651, 0.1858, 0.6044, 0.2072]}, {"w": "it", "b": [0.6099, 0.1858, 0.6219, 0.2072]}, {"w": "eventually", "b": [0.6274, 0.1858, 0.7125, 0.2072]}, {"w": "reaches", "b": [0.718, 0.1858, 0.7802, 0.2072]}, {"w": "terminal", "b": [0.7857, 0.1858, 0.8571, 0.2072]}, {"w": "velocity", "b": [0.1428, 0.2048, 0.2076, 0.2263]}, {"w": "(if", "b": [0.2124, 0.2048, 0.2313, 0.2263]}, {"w": "there", "b": [0.2361, 0.2048, 0.279, 0.2263]}, {"w": "is", "b": [0.2838, 0.2048, 0.2971, 0.2263]}, {"w": "some", "b": [0.3019, 0.2048, 0.3461, 0.2263]}, {"w": "friction", "b": [0.3509, 0.2048, 0.4131, 0.2263]}, {"w": "or", "b": [0.4179, 0.2048, 0.4363, 0.2263]}, {"w": "air", "b": [0.4411, 0.2048, 0.4635, 0.2263]}, {"w": "resistance).", "b": [0.4683, 0.2048, 0.5623, 0.2263]}, {"w": "This", "b": [0.5671, 0.2048, 0.6043, 0.2263]}, {"w": "is", "b": [0.6091, 0.2048, 0.6223, 0.2263]}, {"w": "the", "b": [0.6271, 0.2048, 0.6535, 0.2263]}, {"w": "very", "b": [0.6583, 0.2048, 0.6947, 0.2263]}, {"w": "simple", "b": [0.6995, 0.2048, 0.7544, 0.2263]}, {"w": "idea", "b": [0.7592, 0.2048, 0.7938, 0.2263]}, {"w": "behind", "b": [0.7986, 0.2048, 0.8571, 0.2263]}, {"w": "Momentum", "b": [0.1429, 0.2237, 0.2387, 0.2453]}, {"w": "optimization,", "b": [0.2475, 0.2237, 0.3561, 0.2453]}, {"w": "proposed", "b": [0.3648, 0.2239, 0.4432, 0.2453]}, {"w": "by", "b": [0.4519, 0.2239, 0.472, 0.2453]}, {"w": "Boris", "b": [0.4808, 0.2239, 0.525, 0.2453]}, {"w": "Polyak", "b": [0.5338, 0.2239, 0.5898, 0.2453]}, {"w": "in", "b": [0.5985, 0.2239, 0.6155, 0.2453]}, {"w": "1964.12", "b": [0.6243, 0.2239, 0.6804, 0.2453]}, {"w": "In", "b": [0.6892, 0.2239, 0.7077, 0.2453]}, {"w": "contrast,", "b": [0.7164, 0.2239, 0.7888, 0.2453]}, {"w": "regular", "b": [0.7976, 0.2239, 0.8571, 0.2453]}, {"w": "Gradient", "b": [0.1429, 0.2429, 0.2174, 0.2644]}, {"w": "Descent", "b": [0.2238, 0.2429, 0.2907, 0.2644]}, {"w": "will", "b": [0.2971, 0.2429, 0.3275, 0.2644]}, {"w": "simply", "b": [0.3339, 0.2429, 0.3896, 0.2644]}, {"w": "take", "b": [0.396, 0.2429, 0.4307, 0.2644]}, {"w": "small", "b": [0.4371, 0.2429, 0.4815, 0.2644]}, {"w": "regular", "b": [0.4879, 0.2429, 0.5474, 0.2644]}, {"w": "steps", "b": [0.5538, 0.2429, 0.5953, 0.2644]}, {"w": "down", "b": [0.6017, 0.2429, 0.649, 0.2644]}, {"w": "the", "b": [0.6554, 0.2429, 0.6817, 0.2644]}, {"w": "slope,", "b": [0.6881, 0.2429, 0.7362, 0.2644]}, {"w": "so", "b": [0.7426, 0.2429, 0.7609, 0.2644]}, {"w": "it", "b": [0.7673, 0.2429, 0.7792, 0.2644]}, {"w": "will", "b": [0.7857, 0.2429, 0.8161, 0.2644]}, {"w": "take", "b": [0.8225, 0.2429, 0.8572, 0.2644]}, {"w": "much", "b": [0.1429, 0.262, 0.1905, 0.2834]}, {"w": "more", "b": [0.1953, 0.262, 0.2395, 0.2834]}, {"w": "time", "b": [0.2443, 0.262, 0.2821, 0.2834]}, {"w": "to", "b": [0.2868, 0.262, 0.3038, 0.2834]}, {"w": "reach", "b": [0.3086, 0.262, 0.3542, 0.2834]}, {"w": "the", "b": [0.3589, 0.262, 0.3853, 0.2834]}, {"w": "bottom.", "b": [0.39, 0.262, 0.4564, 0.2834]}]}, {"id": "b_4", "type": "paragraph", "text": "Recall that Gradient Descent simply updates the weights θ by directly subtracting the gradient of the cost function J(θ) with regards to the weights (∇θJ(θ)) multiplied by the learning rate η. The equation is: θ ← θ – η∇θJ(θ). It does not care about what the earlier gradients were. If the local gradient is tiny, it goes very slowly.", "words": [{"w": "Recall", "b": [0.1429, 0.2901, 0.1932, 0.3115]}, {"w": "that", "b": [0.1986, 0.2901, 0.2312, 0.3115]}, {"w": "Gradient", "b": [0.2367, 0.2901, 0.3112, 0.3115]}, {"w": "Descent", "b": [0.3167, 0.2901, 0.3835, 0.3115]}, {"w": "simply", "b": [0.389, 0.2901, 0.4446, 0.3115]}, {"w": "updates", "b": [0.4501, 0.2901, 0.5147, 0.3115]}, {"w": "the", "b": [0.5202, 0.2901, 0.5465, 0.3115]}, {"w": "weights", "b": [0.552, 0.2901, 0.6151, 0.3115]}, {"w": "θ", "b": [0.6206, 0.2896, 0.6312, 0.3115]}, {"w": "by", "b": [0.6367, 0.2901, 0.6568, 0.3115]}, {"w": "directly", "b": [0.6623, 0.2901, 0.7255, 0.3115]}, {"w": "subtracting", "b": [0.7309, 0.2901, 0.8254, 0.3115]}, {"w": "the", "b": [0.8308, 0.2901, 0.8572, 0.3115]}, {"w": "gradient", "b": [0.1429, 0.3092, 0.2123, 0.3306]}, {"w": "of", "b": [0.2187, 0.3092, 0.2355, 0.3306]}, {"w": "the", "b": [0.2418, 0.3092, 0.2682, 0.3306]}, {"w": "cost", "b": [0.2746, 0.3092, 0.308, 0.3306]}, {"w": "function", "b": [0.3144, 0.3092, 0.3858, 0.3306]}, {"w": "J(θ)", "b": [0.3922, 0.3086, 0.4239, 0.3306]}, {"w": "with", "b": [0.4303, 0.3092, 0.4676, 0.3306]}, {"w": "regards", "b": [0.474, 0.3092, 0.5359, 0.3306]}, {"w": "to", "b": [0.5423, 0.3092, 0.5592, 0.3306]}, {"w": "the", "b": [0.5656, 0.3092, 0.592, 0.3306]}, {"w": "weights", "b": [0.5984, 0.3092, 0.6615, 0.3306]}, {"w": "(∇θJ(θ))", "b": [0.6679, 0.3086, 0.7377, 0.3315]}, {"w": "multiplied", "b": [0.744, 0.3092, 0.8306, 0.3306]}, {"w": "by", "b": [0.837, 0.3092, 0.8571, 0.3306]}, {"w": "the", "b": [0.1429, 0.3282, 0.1692, 0.3496]}, {"w": "learning", "b": [0.1747, 0.3282, 0.2438, 0.3496]}, {"w": "rate", "b": [0.2493, 0.3282, 0.281, 0.3496]}, {"w": "η.", "b": [0.2864, 0.328, 0.3018, 0.3496]}, {"w": "The", "b": [0.3072, 0.3282, 0.3401, 0.3496]}, {"w": "equation", "b": [0.3455, 0.3282, 0.4188, 0.3496]}, {"w": "is:", "b": [0.4243, 0.3282, 0.4423, 0.3496]}, {"w": "θ", "b": [0.4477, 0.3277, 0.4583, 0.3496]}, {"w": "←", "b": [0.4638, 0.3282, 0.4821, 0.3496]}, {"w": "θ", "b": [0.4875, 0.3277, 0.4982, 0.3496]}, {"w": "–", "b": [0.5036, 0.3282, 0.5145, 0.3496]}, {"w": "η∇θJ(θ).", "b": [0.5199, 0.3277, 0.5906, 0.3505]}, {"w": "It", "b": [0.596, 0.3282, 0.6087, 0.3496]}, {"w": "does", "b": [0.6141, 0.3282, 0.6523, 0.3496]}, {"w": "not", "b": [0.6577, 0.3282, 0.6861, 0.3496]}, {"w": "care", "b": [0.6916, 0.3282, 0.7261, 0.3496]}, {"w": "about", "b": [0.7316, 0.3282, 0.7794, 0.3496]}, {"w": "what", "b": [0.7848, 0.3282, 0.8253, 0.3496]}, {"w": "the", "b": [0.8308, 0.3282, 0.8571, 0.3496]}, {"w": "earlier", "b": [0.1429, 0.3473, 0.196, 0.3687]}, {"w": "gradients", "b": [0.2008, 0.3473, 0.2778, 0.3687]}, {"w": "were.", "b": [0.2826, 0.3473, 0.327, 0.3687]}, {"w": "If", "b": [0.3317, 0.3473, 0.345, 0.3687]}, {"w": "the", "b": [0.3497, 0.3473, 0.3761, 0.3687]}, {"w": "local", "b": [0.3808, 0.3473, 0.4199, 0.3687]}, {"w": "gradient", "b": [0.4247, 0.3473, 0.4941, 0.3687]}, {"w": "is", "b": [0.4988, 0.3473, 0.512, 0.3687]}, {"w": "tiny,", "b": [0.5168, 0.3473, 0.5524, 0.3687]}, {"w": "it", "b": [0.5571, 0.3473, 0.5691, 0.3687]}, {"w": "goes", "b": [0.5738, 0.3473, 0.6107, 0.3687]}, {"w": "very", "b": [0.6154, 0.3473, 0.6518, 0.3687]}, {"w": "slowly.", "b": [0.6565, 0.3473, 0.7124, 0.3687]}]}, {"id": "b_5", "type": "paragraph", "text": "Momentum optimization cares a great deal about what previous gradients were: at each iteration, it subtracts the local gradient from the momentum vector m (multi‐ plied by the learning rate η), and it updates the weights by simply adding this momentum vector (see Equation 11-4). In other words, the gradient is used for accel‐ eration, not for speed. To simulate some sort of friction mechanism and prevent the momentum from growing too large, the algorithm introduces a new hyperparameter β, simply called the momentum, which must be set between 0 (high friction) and 1 (no friction). A typical momentum value is 0.9.", "words": [{"w": "Momentum", "b": [0.1429, 0.3754, 0.2429, 0.3968]}, {"w": "optimization", "b": [0.2504, 0.3754, 0.358, 0.3968]}, {"w": "cares", "b": [0.3655, 0.3754, 0.4077, 0.3968]}, {"w": "a", "b": [0.4152, 0.3754, 0.4244, 0.3968]}, {"w": "great", "b": [0.4319, 0.3754, 0.4733, 0.3968]}, {"w": "deal", "b": [0.4808, 0.3754, 0.5151, 0.3968]}, {"w": "about", "b": [0.5226, 0.3754, 0.5704, 0.3968]}, {"w": "what", "b": [0.5779, 0.3754, 0.6184, 0.3968]}, {"w": "previous", "b": [0.6259, 0.3754, 0.698, 0.3968]}, {"w": "gradients", "b": [0.7055, 0.3754, 0.7826, 0.3968]}, {"w": "were:", "b": [0.7901, 0.3754, 0.8345, 0.3968]}, {"w": "at", "b": [0.8421, 0.3754, 0.8572, 0.3968]}, {"w": "each", "b": [0.1429, 0.3944, 0.1808, 0.4158]}, {"w": "iteration,", "b": [0.1883, 0.3944, 0.2643, 0.4158]}, {"w": "it", "b": [0.2717, 0.3944, 0.2837, 0.4158]}, {"w": "subtracts", "b": [0.2912, 0.3944, 0.3665, 0.4158]}, {"w": "the", "b": [0.374, 0.3944, 0.4003, 0.4158]}, {"w": "local", "b": [0.4078, 0.3944, 0.4469, 0.4158]}, {"w": "gradient", "b": [0.4544, 0.3944, 0.5238, 0.4158]}, {"w": "from", "b": [0.5313, 0.3944, 0.5729, 0.4158]}, {"w": "the", "b": [0.5804, 0.3944, 0.6067, 0.4158]}, {"w": "momentum", "b": [0.6142, 0.3942, 0.7087, 0.4158]}, {"w": "vector", "b": [0.7162, 0.3942, 0.7651, 0.4158]}, {"w": "m", "b": [0.7725, 0.3939, 0.7901, 0.4158]}, {"w": "(multi‐", "b": [0.7976, 0.3944, 0.8571, 0.4158]}, {"w": "plied", "b": [0.1429, 0.4135, 0.1845, 0.4349]}, {"w": "by", "b": [0.1945, 0.4135, 0.2147, 0.4349]}, {"w": "the", "b": [0.2247, 0.4135, 0.2511, 0.4349]}, {"w": "learning", "b": [0.2611, 0.4135, 0.3303, 0.4349]}, {"w": "rate", "b": [0.3403, 0.4135, 0.372, 0.4349]}, {"w": "η),", "b": [0.3821, 0.4133, 0.4046, 0.4349]}, {"w": "and", "b": [0.4147, 0.4135, 0.4462, 0.4349]}, {"w": "it", "b": [0.4563, 0.4135, 0.4682, 0.4349]}, {"w": "updates", "b": [0.4783, 0.4135, 0.5429, 0.4349]}, {"w": "the", "b": [0.5529, 0.4135, 0.5793, 0.4349]}, {"w": "weights", "b": [0.5893, 0.4135, 0.6525, 0.4349]}, {"w": "by", "b": [0.6626, 0.4135, 0.6827, 0.4349]}, {"w": "simply", "b": [0.6928, 0.4135, 0.7484, 0.4349]}, {"w": "adding", "b": [0.7585, 0.4135, 0.8164, 0.4349]}, {"w": "this", "b": [0.8264, 0.4135, 0.8571, 0.4349]}, {"w": "momentum", "b": [0.1429, 0.4325, 0.2419, 0.4539]}, {"w": "vector", "b": [0.247, 0.4325, 0.299, 0.4539]}, {"w": "(see", "b": [0.304, 0.4325, 0.3366, 0.4539]}, {"w": "Equation", "b": [0.3416, 0.4325, 0.4179, 0.4539]}, {"w": "11-4).", "b": [0.4226, 0.4325, 0.4723, 0.4539]}, {"w": "In", "b": [0.4773, 0.4325, 0.4958, 0.4539]}, {"w": "other", "b": [0.5008, 0.4325, 0.5455, 0.4539]}, {"w": "words,", "b": [0.5506, 0.4325, 0.6066, 0.4539]}, {"w": "the", "b": [0.6116, 0.4325, 0.6379, 0.4539]}, {"w": "gradient", "b": [0.643, 0.4325, 0.7124, 0.4539]}, {"w": "is", "b": [0.7174, 0.4325, 0.7307, 0.4539]}, {"w": "used", "b": [0.7357, 0.4325, 0.7743, 0.4539]}, {"w": "for", "b": [0.7793, 0.4325, 0.8038, 0.4539]}, {"w": "accel‐", "b": [0.8088, 0.4325, 0.8571, 0.4539]}, {"w": "eration,", "b": [0.1429, 0.4516, 0.2069, 0.473]}, {"w": "not", "b": [0.2131, 0.4516, 0.2414, 0.473]}, {"w": "for", "b": [0.2476, 0.4516, 0.2721, 0.473]}, {"w": "speed.", "b": [0.2783, 0.4516, 0.3303, 0.473]}, {"w": "To", "b": [0.3365, 0.4516, 0.3579, 0.473]}, {"w": "simulate", "b": [0.3641, 0.4516, 0.4343, 0.473]}, {"w": "some", "b": [0.4405, 0.4516, 0.4846, 0.473]}, {"w": "sort", "b": [0.4908, 0.4516, 0.5232, 0.473]}, {"w": "of", "b": [0.5293, 0.4516, 0.5461, 0.473]}, {"w": "friction", "b": [0.5523, 0.4516, 0.6145, 0.473]}, {"w": "mechanism", "b": [0.6207, 0.4516, 0.7174, 0.473]}, {"w": "and", "b": [0.7236, 0.4516, 0.7551, 0.473]}, {"w": "prevent", "b": [0.7613, 0.4516, 0.8246, 0.473]}, {"w": "the", "b": [0.8308, 0.4516, 0.8571, 0.473]}, {"w": "momentum", "b": [0.1429, 0.4706, 0.2419, 0.492]}, {"w": "from", "b": [0.2476, 0.4706, 0.2892, 0.492]}, {"w": "growing", "b": [0.2948, 0.4706, 0.3639, 0.492]}, {"w": "too", "b": [0.3696, 0.4706, 0.3972, 0.492]}, {"w": "large,", "b": [0.4029, 0.4706, 0.4484, 0.492]}, {"w": "the", "b": [0.454, 0.4706, 0.4804, 0.492]}, {"w": "algorithm", "b": [0.486, 0.4706, 0.5687, 0.492]}, {"w": "introduces", "b": [0.5743, 0.4706, 0.663, 0.492]}, {"w": "a", "b": [0.6687, 0.4706, 0.6778, 0.492]}, {"w": "new", "b": [0.6835, 0.4706, 0.718, 0.492]}, {"w": "hyperparameter", "b": [0.7236, 0.4706, 0.8571, 0.492]}, {"w": "β,", "b": [0.1429, 0.4895, 0.1583, 0.5111]}, {"w": "simply", "b": [0.1654, 0.4897, 0.221, 0.5111]}, {"w": "called", "b": [0.2281, 0.4897, 0.2765, 0.5111]}, {"w": "the", "b": [0.2836, 0.4897, 0.3099, 0.5111]}, {"w": "momentum,", "b": [0.317, 0.4895, 0.4162, 0.5111]}, {"w": "which", "b": [0.4233, 0.4897, 0.4743, 0.5111]}, {"w": "must", "b": [0.4814, 0.4897, 0.5231, 0.5111]}, {"w": "be", "b": [0.5302, 0.4897, 0.5496, 0.5111]}, {"w": "set", "b": [0.5567, 0.4897, 0.5796, 0.5111]}, {"w": "between", "b": [0.5867, 0.4897, 0.6558, 0.5111]}, {"w": "0", "b": [0.663, 0.4897, 0.673, 0.5111]}, {"w": "(high", "b": [0.6801, 0.4897, 0.7248, 0.5111]}, {"w": "friction)", "b": [0.7319, 0.4897, 0.8014, 0.5111]}, {"w": "and", "b": [0.8085, 0.4897, 0.84, 0.5111]}, {"w": "1", "b": [0.8472, 0.4897, 0.8572, 0.5111]}, {"w": "(no", "b": [0.1429, 0.5087, 0.1721, 0.5301]}, {"w": "friction).", "b": [0.1768, 0.5087, 0.251, 0.5301]}, {"w": "A", "b": [0.2558, 0.5087, 0.2702, 0.5301]}, {"w": "typical", "b": [0.2749, 0.5087, 0.3305, 0.5301]}, {"w": "momentum", "b": [0.3353, 0.5087, 0.4343, 0.5301]}, {"w": "value", "b": [0.4391, 0.5087, 0.483, 0.5301]}, {"w": "is", "b": [0.4878, 0.5087, 0.501, 0.5301]}, {"w": "0.9.", "b": [0.5057, 0.5087, 0.5352, 0.5301]}]}, {"id": "b_6", "type": "equation", "text": "Equation 11-4. Momentum algorithm", "words": [{"w": "Equation", "b": [0.1726, 0.5482, 0.2473, 0.5699]}, {"w": "11-4.", "b": [0.2521, 0.5482, 0.2937, 0.5699]}, {"w": "Momentum", "b": [0.2985, 0.5482, 0.3944, 0.5699]}, {"w": "algorithm", "b": [0.3991, 0.5482, 0.4785, 0.5699]}]}, {"id": "b_7", "type": "paragraph", "text": "1 . m βm −η∇θJ θ", "words": [{"w": "1", "b": [0.1726, 0.5771, 0.1821, 0.5975]}, {"w": ".", "b": [0.1854, 0.5771, 0.19, 0.5975]}, {"w": "m", "b": [0.2218, 0.5765, 0.2385, 0.5975]}, {"w": "βm", "b": [0.2673, 0.5765, 0.2942, 0.5975]}, {"w": "−η∇θJ", "b": [0.2986, 0.5769, 0.356, 0.6009]}, {"w": "θ", "b": [0.3639, 0.5765, 0.374, 0.5975]}]}, {"id": "b_8", "type": "equation", "text": "2 . θ θ + m", "words": [{"w": "2", "b": [0.1726, 0.6025, 0.1821, 0.6229]}, {"w": ".", "b": [0.1855, 0.6025, 0.19, 0.6229]}, {"w": "θ", "b": [0.2218, 0.602, 0.2319, 0.6229]}, {"w": "θ", "b": [0.2603, 0.602, 0.2704, 0.6229]}, {"w": "+", "b": [0.2748, 0.6025, 0.2863, 0.6229]}, {"w": "m", "b": [0.2908, 0.602, 0.3075, 0.6229]}]}, {"id": "b_9", "type": "paragraph", "text": "You can easily verify that if the gradient remains constant, the terminal velocity (i.e., the maximum size of the weight updates) is equal to that gradient multiplied by the learning rate η multiplied by 1 1 −β (ignoring the sign). For example, if β = 0.9, then the terminal velocity is equal to 10 times the gradient times the learning rate, so Momen‐ tum optimization ends up going 10 times faster than Gradient Descent! This allows Momentum optimization to escape from plateaus much faster than Gradient Descent. In particular, we saw in Chapter 4 that when the inputs have very different scales the cost function will look like an elongated bowl (see Figure 4-7). Gradient Descent goes down the steep slope quite fast, but then it takes a very long time to go down the val‐", "words": [{"w": "You", "b": [0.1429, 0.6417, 0.1752, 0.6631]}, {"w": "can", "b": [0.1811, 0.6417, 0.2105, 0.6631]}, {"w": "easily", "b": [0.2164, 0.6417, 0.2624, 0.6631]}, {"w": "verify", "b": [0.2683, 0.6417, 0.3162, 0.6631]}, {"w": "that", "b": [0.3221, 0.6417, 0.3547, 0.6631]}, {"w": "if", "b": [0.3606, 0.6417, 0.3724, 0.6631]}, {"w": "the", "b": [0.3783, 0.6417, 0.4046, 0.6631]}, {"w": "gradient", "b": [0.4105, 0.6417, 0.4799, 0.6631]}, {"w": "remains", "b": [0.4858, 0.6417, 0.5532, 0.6631]}, {"w": "constant,", "b": [0.5591, 0.6417, 0.6352, 0.6631]}, {"w": "the", "b": [0.6411, 0.6417, 0.6674, 0.6631]}, {"w": "terminal", "b": [0.6733, 0.6417, 0.7447, 0.6631]}, {"w": "velocity", "b": [0.7506, 0.6417, 0.8153, 0.6631]}, {"w": "(i.e.,", "b": [0.8212, 0.6417, 0.8571, 0.6631]}, {"w": "the", "b": [0.1429, 0.6607, 0.1692, 0.6821]}, {"w": "maximum", "b": [0.1756, 0.6607, 0.262, 0.6821]}, {"w": "size", "b": [0.2685, 0.6607, 0.2993, 0.6821]}, {"w": "of", "b": [0.3057, 0.6607, 0.3225, 0.6821]}, {"w": "the", "b": [0.3289, 0.6607, 0.3553, 0.6821]}, {"w": "weight", "b": [0.3617, 0.6607, 0.4173, 0.6821]}, {"w": "updates)", "b": [0.4237, 0.6607, 0.4955, 0.6821]}, {"w": "is", "b": [0.5019, 0.6607, 0.5151, 0.6821]}, {"w": "equal", "b": [0.5216, 0.6607, 0.5665, 0.6821]}, {"w": "to", "b": [0.573, 0.6607, 0.5899, 0.6821]}, {"w": "that", "b": [0.5964, 0.6607, 0.629, 0.6821]}, {"w": "gradient", "b": [0.6354, 0.6607, 0.7048, 0.6821]}, {"w": "multiplied", "b": [0.7112, 0.6607, 0.7978, 0.6821]}, {"w": "by", "b": [0.8042, 0.6607, 0.8244, 0.6821]}, {"w": "the", "b": [0.8308, 0.6607, 0.8571, 0.6821]}, {"w": "learning", "b": [0.1429, 0.6837, 0.212, 0.7051]}, {"w": "rate", "b": [0.2167, 0.6837, 0.2484, 0.7051]}, {"w": "η", "b": [0.2532, 0.6834, 0.2638, 0.7051]}, {"w": "multiplied", "b": [0.2686, 0.6837, 0.3551, 0.7051]}, {"w": "by", "b": [0.3599, 0.6837, 0.38, 0.7051]}, {"w": "1", "b": [0.3995, 0.6792, 0.4071, 0.6955]}, {"w": "1", "b": [0.3871, 0.6939, 0.3947, 0.7102]}, {"w": "−β", "b": [0.3983, 0.6937, 0.4194, 0.7102]}, {"w": "(ignoring", "b": [0.4265, 0.6837, 0.5055, 0.7051]}, {"w": "the", "b": [0.5102, 0.6837, 0.5366, 0.7051]}, {"w": "sign).", "b": [0.5413, 0.6837, 0.5876, 0.7051]}, {"w": "For", "b": [0.5924, 0.6837, 0.6214, 0.7051]}, {"w": "example,", "b": [0.6261, 0.6837, 0.7004, 0.7051]}, {"w": "if", "b": [0.7051, 0.6837, 0.7169, 0.7051]}, {"w": "β", "b": [0.7218, 0.6834, 0.7324, 0.7051]}, {"w": "=", "b": [0.7372, 0.6837, 0.7493, 0.7051]}, {"w": "0.9,", "b": [0.754, 0.6837, 0.7835, 0.7051]}, {"w": "then", "b": [0.7883, 0.6837, 0.826, 0.7051]}, {"w": "the", "b": [0.8307, 0.6837, 0.857, 0.7051]}, {"w": "terminal", "b": [0.1429, 0.7066, 0.2143, 0.728]}, {"w": "velocity", "b": [0.2194, 0.7066, 0.2842, 0.728]}, {"w": "is", "b": [0.2893, 0.7066, 0.3026, 0.728]}, {"w": "equal", "b": [0.3078, 0.7066, 0.3527, 0.728]}, {"w": "to", "b": [0.3579, 0.7066, 0.3749, 0.728]}, {"w": "10", "b": [0.3801, 0.7066, 0.4001, 0.728]}, {"w": "times", "b": [0.4053, 0.7066, 0.4508, 0.728]}, {"w": "the", "b": [0.456, 0.7066, 0.4823, 0.728]}, {"w": "gradient", "b": [0.4875, 0.7066, 0.5569, 0.728]}, {"w": "times", "b": [0.5621, 0.7066, 0.6076, 0.728]}, {"w": "the", "b": [0.6128, 0.7066, 0.6392, 0.728]}, {"w": "learning", "b": [0.6444, 0.7066, 0.7135, 0.728]}, {"w": "rate,", "b": [0.7187, 0.7066, 0.7551, 0.728]}, {"w": "so", "b": [0.7603, 0.7066, 0.7786, 0.728]}, {"w": "Momen‐", "b": [0.7838, 0.7066, 0.8571, 0.728]}, {"w": "tum", "b": [0.1428, 0.7256, 0.1773, 0.7471]}, {"w": "optimization", "b": [0.1838, 0.7256, 0.2914, 0.7471]}, {"w": "ends", "b": [0.298, 0.7256, 0.3368, 0.7471]}, {"w": "up", "b": [0.3434, 0.7256, 0.3653, 0.7471]}, {"w": "going", "b": [0.3719, 0.7256, 0.419, 0.7471]}, {"w": "10", "b": [0.4255, 0.7256, 0.4455, 0.7471]}, {"w": "times", "b": [0.452, 0.7256, 0.4975, 0.7471]}, {"w": "faster", "b": [0.504, 0.7256, 0.5499, 0.7471]}, {"w": "than", "b": [0.5564, 0.7256, 0.5945, 0.7471]}, {"w": "Gradient", "b": [0.601, 0.7256, 0.6756, 0.7471]}, {"w": "Descent!", "b": [0.6821, 0.7256, 0.7547, 0.7471]}, {"w": "This", "b": [0.7612, 0.7256, 0.7984, 0.7471]}, {"w": "allows", "b": [0.8049, 0.7256, 0.8571, 0.7471]}, {"w": "Momentum", "b": [0.1429, 0.7447, 0.2429, 0.7661]}, {"w": "optimization", "b": [0.2478, 0.7447, 0.3554, 0.7661]}, {"w": "to", "b": [0.3603, 0.7447, 0.3773, 0.7661]}, {"w": "escape", "b": [0.3821, 0.7447, 0.436, 0.7661]}, {"w": "from", "b": [0.4409, 0.7447, 0.4825, 0.7661]}, {"w": "plateaus", "b": [0.4873, 0.7447, 0.555, 0.7661]}, {"w": "much", "b": [0.5598, 0.7447, 0.6075, 0.7661]}, {"w": "faster", "b": [0.6124, 0.7447, 0.6583, 0.7661]}, {"w": "than", "b": [0.6632, 0.7447, 0.7012, 0.7661]}, {"w": "Gradient", "b": [0.7061, 0.7447, 0.7807, 0.7661]}, {"w": "Descent.", "b": [0.7856, 0.7447, 0.8571, 0.7661]}, {"w": "In", "b": [0.1429, 0.7637, 0.1614, 0.7852]}, {"w": "particular,", "b": [0.1667, 0.7637, 0.2519, 0.7852]}, {"w": "we", "b": [0.2572, 0.7637, 0.2803, 0.7852]}, {"w": "saw", "b": [0.2856, 0.7637, 0.3163, 0.7852]}, {"w": "in", "b": [0.3216, 0.7637, 0.3386, 0.7852]}, {"w": "Chapter", "b": [0.3439, 0.7637, 0.4114, 0.7852]}, {"w": "4", "b": [0.4162, 0.7637, 0.4262, 0.7852]}, {"w": "that", "b": [0.4321, 0.7637, 0.4646, 0.7852]}, {"w": "when", "b": [0.4699, 0.7637, 0.5156, 0.7852]}, {"w": "the", "b": [0.5209, 0.7637, 0.5472, 0.7852]}, {"w": "inputs", "b": [0.5525, 0.7637, 0.6051, 0.7852]}, {"w": "have", "b": [0.6104, 0.7637, 0.6488, 0.7852]}, {"w": "very", "b": [0.6541, 0.7637, 0.6905, 0.7852]}, {"w": "different", "b": [0.6958, 0.7637, 0.7675, 0.7852]}, {"w": "scales", "b": [0.7728, 0.7637, 0.8202, 0.7852]}, {"w": "the", "b": [0.8255, 0.7637, 0.8518, 0.7852]}, {"w": "cost", "b": [0.1429, 0.7828, 0.1763, 0.8042]}, {"w": "function", "b": [0.1814, 0.7828, 0.2528, 0.8042]}, {"w": "will", "b": [0.2578, 0.7828, 0.2882, 0.8042]}, {"w": "look", "b": [0.2933, 0.7828, 0.3301, 0.8042]}, {"w": "like", "b": [0.3352, 0.7828, 0.3652, 0.8042]}, {"w": "an", "b": [0.3703, 0.7828, 0.3908, 0.8042]}, {"w": "elongated", "b": [0.3959, 0.7828, 0.4768, 0.8042]}, {"w": "bowl", "b": [0.4818, 0.7828, 0.5226, 0.8042]}, {"w": "(see", "b": [0.5276, 0.7828, 0.5602, 0.8042]}, {"w": "Figure", "b": [0.5653, 0.7828, 0.6193, 0.8042]}, {"w": "4-7).", "b": [0.624, 0.7828, 0.6637, 0.8042]}, {"w": "Gradient", "b": [0.6688, 0.7828, 0.7433, 0.8042]}, {"w": "Descent", "b": [0.7484, 0.7828, 0.8152, 0.8042]}, {"w": "goes", "b": [0.8203, 0.7828, 0.8572, 0.8042]}, {"w": "down", "b": [0.1429, 0.8018, 0.1902, 0.8232]}, {"w": "the", "b": [0.1954, 0.8018, 0.2218, 0.8232]}, {"w": "steep", "b": [0.2271, 0.8018, 0.2697, 0.8232]}, {"w": "slope", "b": [0.275, 0.8018, 0.3183, 0.8232]}, {"w": "quite", "b": [0.3236, 0.8018, 0.3661, 0.8232]}, {"w": "fast,", "b": [0.3714, 0.8018, 0.4054, 0.8232]}, {"w": "but", "b": [0.4107, 0.8018, 0.4387, 0.8232]}, {"w": "then", "b": [0.444, 0.8018, 0.4818, 0.8232]}, {"w": "it", "b": [0.4871, 0.8018, 0.499, 0.8232]}, {"w": "takes", "b": [0.5043, 0.8018, 0.5466, 0.8232]}, {"w": "a", "b": [0.5519, 0.8018, 0.5611, 0.8232]}, {"w": "very", "b": [0.5663, 0.8018, 0.6027, 0.8232]}, {"w": "long", "b": [0.608, 0.8018, 0.6451, 0.8232]}, {"w": "time", "b": [0.6504, 0.8018, 0.6882, 0.8232]}, {"w": "to", "b": [0.6935, 0.8018, 0.7105, 0.8232]}, {"w": "go", "b": [0.7158, 0.8018, 0.7362, 0.8232]}, {"w": "down", "b": [0.7415, 0.8018, 0.7887, 0.8232]}, {"w": "the", "b": [0.794, 0.8018, 0.8204, 0.8232]}, {"w": "val‐", "b": [0.8257, 0.8018, 0.8571, 0.8232]}]}, {"id": "b_10", "type": "paragraph", "text": "Faster Optimizers | 345", "words": [{"w": "Faster", "b": [0.6934, 0.9225, 0.7296, 0.9388]}, {"w": "Optimizers", "b": [0.7325, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "345", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 372, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "13 “A Method for Unconstrained Convex Minimization Problem with the Rate of Convergence O(1/k2),” Yurii Nesterov (1983).", "words": [{"w": "13", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "“A", "b": [0.1587, 0.8598, 0.1736, 0.8761]}, {"w": "Method", "b": [0.1772, 0.8598, 0.2275, 0.8761]}, {"w": "for", "b": [0.2311, 0.8598, 0.2498, 0.8761]}, {"w": "Unconstrained", "b": [0.2534, 0.8598, 0.3482, 0.8761]}, {"w": "Convex", "b": [0.3518, 0.8598, 0.4003, 0.8761]}, {"w": "Minimization", "b": [0.4039, 0.8598, 0.4917, 0.8761]}, {"w": "Problem", "b": [0.4953, 0.8598, 0.5501, 0.8761]}, {"w": "with", "b": [0.5537, 0.8598, 0.5821, 0.8761]}, {"w": "the", "b": [0.5857, 0.8598, 0.6058, 0.8761]}, {"w": "Rate", "b": [0.6094, 0.8598, 0.6378, 0.8761]}, {"w": "of", "b": [0.6414, 0.8598, 0.6542, 0.8761]}, {"w": "Convergence", "b": [0.6578, 0.8598, 0.741, 0.8761]}, {"w": "O(1/k2),”", "b": [0.7447, 0.8583, 0.802, 0.8761]}, {"w": "Yurii", "b": [0.8056, 0.8598, 0.837, 0.8761]}, {"w": "Nesterov", "b": [0.1587, 0.8749, 0.2156, 0.8912]}, {"w": "(1983).", "b": [0.2192, 0.8749, 0.2643, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "ley. In contrast, Momentum optimization will roll down the valley faster and faster until it reaches the bottom (the optimum). In deep neural networks that don’t use Batch Normalization, the upper layers will often end up having inputs with very dif‐ ferent scales, so using Momentum optimization helps a lot. It can also help roll past local optima.", "words": [{"w": "ley.", "b": [0.1429, 0.0791, 0.1698, 0.1005]}, {"w": "In", "b": [0.1768, 0.0791, 0.1953, 0.1005]}, {"w": "contrast,", "b": [0.2024, 0.0791, 0.2748, 0.1005]}, {"w": "Momentum", "b": [0.2819, 0.0791, 0.3819, 0.1005]}, {"w": "optimization", "b": [0.389, 0.0791, 0.4966, 0.1005]}, {"w": "will", "b": [0.5037, 0.0791, 0.5341, 0.1005]}, {"w": "roll", "b": [0.5411, 0.0791, 0.57, 0.1005]}, {"w": "down", "b": [0.5771, 0.0791, 0.6244, 0.1005]}, {"w": "the", "b": [0.6315, 0.0791, 0.6578, 0.1005]}, {"w": "valley", "b": [0.6649, 0.0791, 0.7126, 0.1005]}, {"w": "faster", "b": [0.7197, 0.0791, 0.7656, 0.1005]}, {"w": "and", "b": [0.7726, 0.0791, 0.8042, 0.1005]}, {"w": "faster", "b": [0.8113, 0.0791, 0.8571, 0.1005]}, {"w": "until", "b": [0.1429, 0.0981, 0.1821, 0.1195]}, {"w": "it", "b": [0.1897, 0.0981, 0.2017, 0.1195]}, {"w": "reaches", "b": [0.2092, 0.0981, 0.2714, 0.1195]}, {"w": "the", "b": [0.279, 0.0981, 0.3053, 0.1195]}, {"w": "bottom", "b": [0.3129, 0.0981, 0.3745, 0.1195]}, {"w": "(the", "b": [0.3821, 0.0981, 0.4157, 0.1195]}, {"w": "optimum).", "b": [0.4232, 0.0981, 0.5135, 0.1195]}, {"w": "In", "b": [0.5211, 0.0981, 0.5396, 0.1195]}, {"w": "deep", "b": [0.5472, 0.0981, 0.5868, 0.1195]}, {"w": "neural", "b": [0.5944, 0.0981, 0.6478, 0.1195]}, {"w": "networks", "b": [0.6554, 0.0981, 0.7326, 0.1195]}, {"w": "that", "b": [0.7402, 0.0981, 0.7728, 0.1195]}, {"w": "don’t", "b": [0.7804, 0.0981, 0.822, 0.1195]}, {"w": "use", "b": [0.8296, 0.0981, 0.8571, 0.1195]}, {"w": "Batch", "b": [0.1429, 0.1172, 0.1901, 0.1386]}, {"w": "Normalization,", "b": [0.1961, 0.1172, 0.3227, 0.1386]}, {"w": "the", "b": [0.3286, 0.1172, 0.3549, 0.1386]}, {"w": "upper", "b": [0.3608, 0.1172, 0.4103, 0.1386]}, {"w": "layers", "b": [0.4162, 0.1172, 0.4641, 0.1386]}, {"w": "will", "b": [0.47, 0.1172, 0.5004, 0.1386]}, {"w": "often", "b": [0.5063, 0.1172, 0.5497, 0.1386]}, {"w": "end", "b": [0.5556, 0.1172, 0.5869, 0.1386]}, {"w": "up", "b": [0.5928, 0.1172, 0.6148, 0.1386]}, {"w": "having", "b": [0.6207, 0.1172, 0.677, 0.1386]}, {"w": "inputs", "b": [0.6829, 0.1172, 0.7355, 0.1386]}, {"w": "with", "b": [0.7414, 0.1172, 0.7787, 0.1386]}, {"w": "very", "b": [0.7847, 0.1172, 0.821, 0.1386]}, {"w": "dif‐", "b": [0.827, 0.1172, 0.8571, 0.1386]}, {"w": "ferent", "b": [0.1429, 0.1362, 0.1918, 0.1576]}, {"w": "scales,", "b": [0.1981, 0.1362, 0.2502, 0.1576]}, {"w": "so", "b": [0.2565, 0.1362, 0.2748, 0.1576]}, {"w": "using", "b": [0.2811, 0.1362, 0.3265, 0.1576]}, {"w": "Momentum", "b": [0.3328, 0.1362, 0.4329, 0.1576]}, {"w": "optimization", "b": [0.4392, 0.1362, 0.5467, 0.1576]}, {"w": "helps", "b": [0.553, 0.1362, 0.5969, 0.1576]}, {"w": "a", "b": [0.6031, 0.1362, 0.6123, 0.1576]}, {"w": "lot.", "b": [0.6186, 0.1362, 0.6456, 0.1576]}, {"w": "It", "b": [0.6519, 0.1362, 0.6645, 0.1576]}, {"w": "can", "b": [0.6708, 0.1362, 0.7002, 0.1576]}, {"w": "also", "b": [0.7065, 0.1362, 0.7391, 0.1576]}, {"w": "help", "b": [0.7454, 0.1362, 0.7816, 0.1576]}, {"w": "roll", "b": [0.7879, 0.1362, 0.8168, 0.1576]}, {"w": "past", "b": [0.8231, 0.1362, 0.8572, 0.1576]}, {"w": "local", "b": [0.1429, 0.1553, 0.182, 0.1767]}, {"w": "optima.", "b": [0.1867, 0.1553, 0.2512, 0.1767]}]}, {"id": "b_2", "type": "paragraph", "text": "Due to the momentum, the optimizer may overshoot a bit, then come back, overshoot again, and oscillate like this many times before stabilizing at the minimum. This is one of the reasons why it is good to have a bit of friction in the system: it gets rid of these oscillations and thus speeds up convergence.", "words": [{"w": "Due", "b": [0.2714, 0.1972, 0.3036, 0.2168]}, {"w": "to", "b": [0.3109, 0.1972, 0.3264, 0.2168]}, {"w": "the", "b": [0.3337, 0.1972, 0.3578, 0.2168]}, {"w": "momentum,", "b": [0.365, 0.1972, 0.46, 0.2168]}, {"w": "the", "b": [0.4672, 0.1972, 0.4913, 0.2168]}, {"w": "optimizer", "b": [0.4986, 0.1972, 0.5731, 0.2168]}, {"w": "may", "b": [0.5804, 0.1972, 0.6127, 0.2168]}, {"w": "overshoot", "b": [0.62, 0.1972, 0.6961, 0.2168]}, {"w": "a", "b": [0.7034, 0.1972, 0.7117, 0.2168]}, {"w": "bit,", "b": [0.719, 0.1972, 0.7439, 0.2168]}, {"w": "then", "b": [0.7512, 0.1972, 0.7857, 0.2168]}, {"w": "come", "b": [0.2714, 0.2146, 0.3129, 0.2342]}, {"w": "back,", "b": [0.3219, 0.2146, 0.3618, 0.2342]}, {"w": "overshoot", "b": [0.3708, 0.2146, 0.4469, 0.2342]}, {"w": "again,", "b": [0.4559, 0.2146, 0.5014, 0.2342]}, {"w": "and", "b": [0.5105, 0.2146, 0.5393, 0.2342]}, {"w": "oscillate", "b": [0.5483, 0.2146, 0.6098, 0.2342]}, {"w": "like", "b": [0.6188, 0.2146, 0.6463, 0.2342]}, {"w": "this", "b": [0.6553, 0.2146, 0.6834, 0.2342]}, {"w": "many", "b": [0.6924, 0.2146, 0.7351, 0.2342]}, {"w": "times", "b": [0.7441, 0.2146, 0.7857, 0.2342]}, {"w": "before", "b": [0.2714, 0.232, 0.3197, 0.2516]}, {"w": "stabilizing", "b": [0.3242, 0.232, 0.4025, 0.2516]}, {"w": "at", "b": [0.4071, 0.232, 0.4209, 0.2516]}, {"w": "the", "b": [0.4254, 0.232, 0.4495, 0.2516]}, {"w": "minimum.", "b": [0.454, 0.232, 0.5356, 0.2516]}, {"w": "This", "b": [0.5401, 0.232, 0.5741, 0.2516]}, {"w": "is", "b": [0.5787, 0.232, 0.5907, 0.2516]}, {"w": "one", "b": [0.5953, 0.232, 0.6235, 0.2516]}, {"w": "of", "b": [0.6281, 0.232, 0.6434, 0.2516]}, {"w": "the", "b": [0.6479, 0.232, 0.672, 0.2516]}, {"w": "reasons", "b": [0.6766, 0.232, 0.7342, 0.2516]}, {"w": "why", "b": [0.7387, 0.232, 0.7703, 0.2516]}, {"w": "it", "b": [0.7748, 0.232, 0.7857, 0.2516]}, {"w": "is", "b": [0.2714, 0.2494, 0.2835, 0.269]}, {"w": "good", "b": [0.2901, 0.2494, 0.3285, 0.269]}, {"w": "to", "b": [0.335, 0.2494, 0.3505, 0.269]}, {"w": "have", "b": [0.3571, 0.2494, 0.3922, 0.269]}, {"w": "a", "b": [0.3987, 0.2494, 0.4071, 0.269]}, {"w": "bit", "b": [0.4137, 0.2494, 0.4343, 0.269]}, {"w": "of", "b": [0.4408, 0.2494, 0.4562, 0.269]}, {"w": "friction", "b": [0.4627, 0.2494, 0.5196, 0.269]}, {"w": "in", "b": [0.5262, 0.2494, 0.5417, 0.269]}, {"w": "the", "b": [0.5483, 0.2494, 0.5723, 0.269]}, {"w": "system:", "b": [0.5789, 0.2494, 0.6355, 0.269]}, {"w": "it", "b": [0.642, 0.2494, 0.6529, 0.269]}, {"w": "gets", "b": [0.6595, 0.2494, 0.6893, 0.269]}, {"w": "rid", "b": [0.6959, 0.2494, 0.7181, 0.269]}, {"w": "of", "b": [0.7246, 0.2494, 0.74, 0.269]}, {"w": "these", "b": [0.7465, 0.2494, 0.7857, 0.269]}, {"w": "oscillations", "b": [0.2714, 0.2669, 0.3569, 0.2864]}, {"w": "and", "b": [0.3613, 0.2669, 0.3901, 0.2864]}, {"w": "thus", "b": [0.3944, 0.2669, 0.4272, 0.2864]}, {"w": "speeds", "b": [0.4315, 0.2669, 0.4817, 0.2864]}, {"w": "up", "b": [0.486, 0.2669, 0.5061, 0.2864]}, {"w": "convergence.", "b": [0.5104, 0.2669, 0.6101, 0.2864]}]}, {"id": "b_3", "type": "paragraph", "text": "Implementing Momentum optimization in Keras is a no-brainer: just use the SGD optimizer and set its momentum hyperparameter, then lie back and profit!", "words": [{"w": "Implementing", "b": [0.1429, 0.3076, 0.2617, 0.329]}, {"w": "Momentum", "b": [0.27, 0.3076, 0.3701, 0.329]}, {"w": "optimization", "b": [0.3784, 0.3076, 0.486, 0.329]}, {"w": "in", "b": [0.4944, 0.3076, 0.5113, 0.329]}, {"w": "Keras", "b": [0.5197, 0.3076, 0.5666, 0.329]}, {"w": "is", "b": [0.575, 0.3076, 0.5882, 0.329]}, {"w": "a", "b": [0.5965, 0.3076, 0.6057, 0.329]}, {"w": "no-brainer:", "b": [0.614, 0.3076, 0.7097, 0.329]}, {"w": "just", "b": [0.7181, 0.3076, 0.7485, 0.329]}, {"w": "use", "b": [0.7569, 0.3076, 0.7844, 0.329]}, {"w": "the", "b": [0.7928, 0.3076, 0.8191, 0.329]}, {"w": "SGD", "b": [0.8275, 0.3108, 0.8571, 0.3259]}, {"w": "optimizer", "b": [0.1429, 0.3276, 0.2243, 0.349]}, {"w": "and", "b": [0.229, 0.3276, 0.2606, 0.349]}, {"w": "set", "b": [0.2653, 0.3276, 0.2882, 0.349]}, {"w": "its", "b": [0.2929, 0.3276, 0.3125, 0.349]}, {"w": "momentum", "b": [0.3172, 0.3307, 0.3964, 0.3458]}, {"w": "hyperparameter,", "b": [0.4011, 0.3276, 0.538, 0.349]}, {"w": "then", "b": [0.5428, 0.3276, 0.5805, 0.349]}, {"w": "lie", "b": [0.5852, 0.3276, 0.6049, 0.349]}, {"w": "back", "b": [0.6097, 0.3276, 0.6485, 0.349]}, {"w": "and", "b": [0.6533, 0.3276, 0.6848, 0.349]}, {"w": "profit!", "b": [0.6895, 0.3276, 0.7427, 0.349]}]}, {"id": "b_4", "type": "equation", "text": "optimizer = keras.optimizers.SGD(lr=0.001, momentum=0.9)", "words": [{"w": "optimizer", "b": [0.1766, 0.3595, 0.2525, 0.3724]}, {"w": "=", "b": [0.2609, 0.3595, 0.2693, 0.3724]}, {"w": "keras.optimizers.SGD(lr=0.001,", "b": [0.2778, 0.3595, 0.5308, 0.3724]}, {"w": "momentum=0.9)", "b": [0.5392, 0.3595, 0.6488, 0.3724]}]}, {"id": "b_5", "type": "paragraph", "text": "The one drawback of Momentum optimization is that it adds yet another hyperpara‐ meter to tune. However, the momentum value of 0.9 usually works well in practice and almost always goes faster than regular Gradient Descent.", "words": [{"w": "The", "b": [0.1429, 0.3802, 0.1757, 0.4016]}, {"w": "one", "b": [0.1813, 0.3802, 0.2121, 0.4016]}, {"w": "drawback", "b": [0.2177, 0.3802, 0.2984, 0.4016]}, {"w": "of", "b": [0.3039, 0.3802, 0.3207, 0.4016]}, {"w": "Momentum", "b": [0.3263, 0.3802, 0.4263, 0.4016]}, {"w": "optimization", "b": [0.4319, 0.3802, 0.5395, 0.4016]}, {"w": "is", "b": [0.5451, 0.3802, 0.5583, 0.4016]}, {"w": "that", "b": [0.5639, 0.3802, 0.5965, 0.4016]}, {"w": "it", "b": [0.602, 0.3802, 0.614, 0.4016]}, {"w": "adds", "b": [0.6196, 0.3802, 0.6584, 0.4016]}, {"w": "yet", "b": [0.6639, 0.3802, 0.6887, 0.4016]}, {"w": "another", "b": [0.6943, 0.3802, 0.7595, 0.4016]}, {"w": "hyperpara‐", "b": [0.7651, 0.3802, 0.8571, 0.4016]}, {"w": "meter", "b": [0.1428, 0.3992, 0.1917, 0.4206]}, {"w": "to", "b": [0.1986, 0.3992, 0.2156, 0.4206]}, {"w": "tune.", "b": [0.2225, 0.3992, 0.2649, 0.4206]}, {"w": "However,", "b": [0.2718, 0.3992, 0.3507, 0.4206]}, {"w": "the", "b": [0.3576, 0.3992, 0.3839, 0.4206]}, {"w": "momentum", "b": [0.3908, 0.3992, 0.4899, 0.4206]}, {"w": "value", "b": [0.4968, 0.3992, 0.5408, 0.4206]}, {"w": "of", "b": [0.5477, 0.3992, 0.5645, 0.4206]}, {"w": "0.9", "b": [0.5714, 0.3992, 0.5961, 0.4206]}, {"w": "usually", "b": [0.603, 0.3992, 0.6621, 0.4206]}, {"w": "works", "b": [0.669, 0.3992, 0.7196, 0.4206]}, {"w": "well", "b": [0.7265, 0.3992, 0.7601, 0.4206]}, {"w": "in", "b": [0.767, 0.3992, 0.784, 0.4206]}, {"w": "practice", "b": [0.7909, 0.3992, 0.8571, 0.4206]}, {"w": "and", "b": [0.1429, 0.4183, 0.1744, 0.4397]}, {"w": "almost", "b": [0.1791, 0.4183, 0.2352, 0.4397]}, {"w": "always", "b": [0.24, 0.4183, 0.2946, 0.4397]}, {"w": "goes", "b": [0.2994, 0.4183, 0.3362, 0.4397]}, {"w": "faster", "b": [0.341, 0.4183, 0.3869, 0.4397]}, {"w": "than", "b": [0.3916, 0.4183, 0.4296, 0.4397]}, {"w": "regular", "b": [0.4343, 0.4183, 0.4939, 0.4397]}, {"w": "Gradient", "b": [0.4986, 0.4183, 0.5732, 0.4397]}, {"w": "Descent.", "b": [0.5779, 0.4183, 0.6495, 0.4397]}]}, {"id": "b_6", "type": "paragraph", "text": "Nesterov Accelerated Gradient", "words": [{"w": "Nesterov", "b": [0.1428, 0.4525, 0.2346, 0.481]}, {"w": "Accelerated", "b": [0.2395, 0.4525, 0.3599, 0.481]}, {"w": "Gradient", "b": [0.3648, 0.4525, 0.4546, 0.481]}]}, {"id": "b_7", "type": "paragraph", "text": "One small variant to Momentum optimization, proposed by Yurii Nesterov in 1983,13", "words": [{"w": "One", "b": [0.1429, 0.4869, 0.1787, 0.5083]}, {"w": "small", "b": [0.184, 0.4869, 0.2284, 0.5083]}, {"w": "variant", "b": [0.2337, 0.4869, 0.2923, 0.5083]}, {"w": "to", "b": [0.2977, 0.4869, 0.3147, 0.5083]}, {"w": "Momentum", "b": [0.32, 0.4869, 0.42, 0.5083]}, {"w": "optimization,", "b": [0.4254, 0.4869, 0.5377, 0.5083]}, {"w": "proposed", "b": [0.5431, 0.4869, 0.6214, 0.5083]}, {"w": "by", "b": [0.6267, 0.4869, 0.6469, 0.5083]}, {"w": "Yurii", "b": [0.6522, 0.4869, 0.6933, 0.5083]}, {"w": "Nesterov", "b": [0.6986, 0.4869, 0.7733, 0.5083]}, {"w": "in", "b": [0.7786, 0.4869, 0.7956, 0.5083]}, {"w": "1983,13", "b": [0.801, 0.4869, 0.8571, 0.5083]}]}, {"id": "b_8", "type": "paragraph", "text": "is almost always faster than vanilla Momentum optimization. The idea of Nesterov Momentum optimization, or Nesterov Accelerated Gradient (NAG), is to measure the gradient of the cost function not at the local position but slightly ahead in the direc‐ tion of the momentum (see Equation 11-5). The only difference from vanilla Momentum optimization is that the gradient is measured at θ + βm rather than at θ.", "words": [{"w": "is", "b": [0.1429, 0.506, 0.1561, 0.5274]}, {"w": "almost", "b": [0.1638, 0.506, 0.2199, 0.5274]}, {"w": "always", "b": [0.2276, 0.506, 0.2823, 0.5274]}, {"w": "faster", "b": [0.29, 0.506, 0.3358, 0.5274]}, {"w": "than", "b": [0.3435, 0.506, 0.3816, 0.5274]}, {"w": "vanilla", "b": [0.3893, 0.506, 0.4447, 0.5274]}, {"w": "Momentum", "b": [0.4524, 0.506, 0.5525, 0.5274]}, {"w": "optimization.", "b": [0.5602, 0.506, 0.6725, 0.5274]}, {"w": "The", "b": [0.6802, 0.506, 0.713, 0.5274]}, {"w": "idea", "b": [0.7207, 0.506, 0.7553, 0.5274]}, {"w": "of", "b": [0.763, 0.506, 0.7798, 0.5274]}, {"w": "Nesterov", "b": [0.7875, 0.5058, 0.8571, 0.5274]}, {"w": "Momentum", "b": [0.1428, 0.5248, 0.2387, 0.5464]}, {"w": "optimization,", "b": [0.2454, 0.5248, 0.354, 0.5464]}, {"w": "or", "b": [0.3607, 0.525, 0.3791, 0.5464]}, {"w": "Nesterov", "b": [0.3858, 0.5248, 0.4554, 0.5464]}, {"w": "Accelerated", "b": [0.4621, 0.5248, 0.555, 0.5464]}, {"w": "Gradient", "b": [0.5617, 0.5248, 0.6342, 0.5464]}, {"w": "(NAG),", "b": [0.6409, 0.525, 0.7035, 0.5464]}, {"w": "is", "b": [0.7102, 0.525, 0.7234, 0.5464]}, {"w": "to", "b": [0.7301, 0.525, 0.7471, 0.5464]}, {"w": "measure", "b": [0.7538, 0.525, 0.8241, 0.5464]}, {"w": "the", "b": [0.8308, 0.525, 0.8571, 0.5464]}, {"w": "gradient", "b": [0.1429, 0.5441, 0.2123, 0.5655]}, {"w": "of", "b": [0.2182, 0.5441, 0.235, 0.5655]}, {"w": "the", "b": [0.241, 0.5441, 0.2673, 0.5655]}, {"w": "cost", "b": [0.2732, 0.5441, 0.3067, 0.5655]}, {"w": "function", "b": [0.3126, 0.5441, 0.384, 0.5655]}, {"w": "not", "b": [0.3899, 0.5441, 0.4183, 0.5655]}, {"w": "at", "b": [0.4243, 0.5441, 0.4394, 0.5655]}, {"w": "the", "b": [0.4453, 0.5441, 0.4716, 0.5655]}, {"w": "local", "b": [0.4776, 0.5441, 0.5167, 0.5655]}, {"w": "position", "b": [0.5226, 0.5441, 0.5914, 0.5655]}, {"w": "but", "b": [0.5973, 0.5441, 0.6253, 0.5655]}, {"w": "slightly", "b": [0.6312, 0.5441, 0.6914, 0.5655]}, {"w": "ahead", "b": [0.6974, 0.5441, 0.7466, 0.5655]}, {"w": "in", "b": [0.7526, 0.5441, 0.7695, 0.5655]}, {"w": "the", "b": [0.7755, 0.5441, 0.8018, 0.5655]}, {"w": "direc‐", "b": [0.8078, 0.5441, 0.8571, 0.5655]}, {"w": "tion", "b": [0.1429, 0.5631, 0.1768, 0.5845]}, {"w": "of", "b": [0.1886, 0.5631, 0.2054, 0.5845]}, {"w": "the", "b": [0.2172, 0.5631, 0.2435, 0.5845]}, {"w": "momentum", "b": [0.2553, 0.5631, 0.3544, 0.5845]}, {"w": "(see", "b": [0.3662, 0.5631, 0.3988, 0.5845]}, {"w": "Equation", "b": [0.4106, 0.5631, 0.4868, 0.5845]}, {"w": "11-5).", "b": [0.4986, 0.5631, 0.548, 0.5845]}, {"w": "The", "b": [0.5598, 0.5631, 0.5926, 0.5845]}, {"w": "only", "b": [0.6044, 0.5631, 0.6413, 0.5845]}, {"w": "difference", "b": [0.6531, 0.5631, 0.7365, 0.5845]}, {"w": "from", "b": [0.7483, 0.5631, 0.7899, 0.5845]}, {"w": "vanilla", "b": [0.8017, 0.5631, 0.8571, 0.5845]}, {"w": "Momentum", "b": [0.1429, 0.5822, 0.2429, 0.6036]}, {"w": "optimization", "b": [0.2476, 0.5822, 0.3552, 0.6036]}, {"w": "is", "b": [0.3599, 0.5822, 0.3732, 0.6036]}, {"w": "that", "b": [0.3779, 0.5822, 0.4105, 0.6036]}, {"w": "the", "b": [0.4152, 0.5822, 0.4415, 0.6036]}, {"w": "gradient", "b": [0.4463, 0.5822, 0.5157, 0.6036]}, {"w": "is", "b": [0.5204, 0.5822, 0.5336, 0.6036]}, {"w": "measured", "b": [0.5384, 0.5822, 0.6197, 0.6036]}, {"w": "at", "b": [0.6245, 0.5822, 0.6396, 0.6036]}, {"w": "θ", "b": [0.6443, 0.5816, 0.6549, 0.6036]}, {"w": "+", "b": [0.6596, 0.5822, 0.6717, 0.6036]}, {"w": "βm", "b": [0.6764, 0.5816, 0.7046, 0.6036]}, {"w": "rather", "b": [0.7094, 0.5822, 0.7599, 0.6036]}, {"w": "than", "b": [0.7646, 0.5822, 0.8027, 0.6036]}, {"w": "at", "b": [0.8074, 0.5822, 0.8225, 0.6036]}, {"w": "θ.", "b": [0.8272, 0.5816, 0.8426, 0.6036]}]}, {"id": "b_9", "type": "equation", "text": "Equation 11-5. Nesterov Accelerated Gradient algorithm", "words": [{"w": "Equation", "b": [0.1726, 0.6217, 0.2473, 0.6433]}, {"w": "11-5.", "b": [0.2521, 0.6217, 0.2937, 0.6433]}, {"w": "Nesterov", "b": [0.2985, 0.6217, 0.3681, 0.6433]}, {"w": "Accelerated", "b": [0.3729, 0.6217, 0.4658, 0.6433]}, {"w": "Gradient", "b": [0.4705, 0.6217, 0.543, 0.6433]}, {"w": "algorithm", "b": [0.5478, 0.6217, 0.6272, 0.6433]}]}, {"id": "b_10", "type": "equation", "text": "1 . m βm −η∇θJ θ + βm", "words": [{"w": "1", "b": [0.1726, 0.6505, 0.1821, 0.6709]}, {"w": ".", "b": [0.1854, 0.6505, 0.19, 0.6709]}, {"w": "m", "b": [0.2218, 0.65, 0.2385, 0.6709]}, {"w": "βm", "b": [0.2673, 0.65, 0.2942, 0.6709]}, {"w": "−η∇θJ", "b": [0.2986, 0.6503, 0.356, 0.6743]}, {"w": "θ", "b": [0.3639, 0.65, 0.374, 0.6709]}, {"w": "+", "b": [0.3784, 0.6505, 0.3899, 0.6709]}, {"w": "βm", "b": [0.3947, 0.65, 0.4215, 0.6709]}]}, {"id": "b_11", "type": "equation", "text": "2 . θ θ + m", "words": [{"w": "2", "b": [0.1726, 0.6759, 0.1822, 0.6963]}, {"w": ".", "b": [0.1854, 0.6759, 0.19, 0.6963]}, {"w": "θ", "b": [0.2218, 0.6754, 0.2319, 0.6963]}, {"w": "θ", "b": [0.2603, 0.6754, 0.2704, 0.6963]}, {"w": "+", "b": [0.2748, 0.6759, 0.2864, 0.6963]}, {"w": "m", "b": [0.2908, 0.6754, 0.3075, 0.6963]}]}, {"id": "b_12", "type": "paragraph", "text": "This small tweak works because in general the momentum vector will be pointing in the right direction (i.e., toward the optimum), so it will be slightly more accurate to use the gradient measured a bit farther in that direction rather than using the gradi‐ ent at the original position, as you can see in Figure 11-6 (where ∇1 represents the gradient of the cost function measured at the starting point θ, and ∇2 represents the", "words": [{"w": "This", "b": [0.1429, 0.7151, 0.1801, 0.7365]}, {"w": "small", "b": [0.1858, 0.7151, 0.2302, 0.7365]}, {"w": "tweak", "b": [0.236, 0.7151, 0.285, 0.7365]}, {"w": "works", "b": [0.2907, 0.7151, 0.3414, 0.7365]}, {"w": "because", "b": [0.3471, 0.7151, 0.4117, 0.7365]}, {"w": "in", "b": [0.4175, 0.7151, 0.4345, 0.7365]}, {"w": "general", "b": [0.4402, 0.7151, 0.5012, 0.7365]}, {"w": "the", "b": [0.507, 0.7151, 0.5333, 0.7365]}, {"w": "momentum", "b": [0.5391, 0.7151, 0.6382, 0.7365]}, {"w": "vector", "b": [0.644, 0.7151, 0.696, 0.7365]}, {"w": "will", "b": [0.7018, 0.7151, 0.7322, 0.7365]}, {"w": "be", "b": [0.738, 0.7151, 0.7574, 0.7365]}, {"w": "pointing", "b": [0.7632, 0.7151, 0.8344, 0.7365]}, {"w": "in", "b": [0.8402, 0.7151, 0.8571, 0.7365]}, {"w": "the", "b": [0.1429, 0.7342, 0.1692, 0.7556]}, {"w": "right", "b": [0.1756, 0.7342, 0.2157, 0.7556]}, {"w": "direction", "b": [0.2221, 0.7342, 0.298, 0.7556]}, {"w": "(i.e.,", "b": [0.3044, 0.7342, 0.3403, 0.7556]}, {"w": "toward", "b": [0.3467, 0.7342, 0.4058, 0.7556]}, {"w": "the", "b": [0.4122, 0.7342, 0.4385, 0.7556]}, {"w": "optimum),", "b": [0.4449, 0.7342, 0.5351, 0.7556]}, {"w": "so", "b": [0.5415, 0.7342, 0.5598, 0.7556]}, {"w": "it", "b": [0.5662, 0.7342, 0.5781, 0.7556]}, {"w": "will", "b": [0.5845, 0.7342, 0.6149, 0.7556]}, {"w": "be", "b": [0.6213, 0.7342, 0.6407, 0.7556]}, {"w": "slightly", "b": [0.6471, 0.7342, 0.7072, 0.7556]}, {"w": "more", "b": [0.7136, 0.7342, 0.7579, 0.7556]}, {"w": "accurate", "b": [0.7643, 0.7342, 0.8338, 0.7556]}, {"w": "to", "b": [0.8402, 0.7342, 0.8572, 0.7556]}, {"w": "use", "b": [0.1429, 0.7532, 0.1704, 0.7746]}, {"w": "the", "b": [0.1765, 0.7532, 0.2028, 0.7746]}, {"w": "gradient", "b": [0.2088, 0.7532, 0.2782, 0.7746]}, {"w": "measured", "b": [0.2843, 0.7532, 0.3656, 0.7746]}, {"w": "a", "b": [0.3716, 0.7532, 0.3808, 0.7746]}, {"w": "bit", "b": [0.3868, 0.7532, 0.4093, 0.7746]}, {"w": "farther", "b": [0.4154, 0.7532, 0.4725, 0.7746]}, {"w": "in", "b": [0.4785, 0.7532, 0.4955, 0.7746]}, {"w": "that", "b": [0.5015, 0.7532, 0.5341, 0.7746]}, {"w": "direction", "b": [0.5401, 0.7532, 0.616, 0.7746]}, {"w": "rather", "b": [0.6221, 0.7532, 0.6726, 0.7746]}, {"w": "than", "b": [0.6786, 0.7532, 0.7167, 0.7746]}, {"w": "using", "b": [0.7227, 0.7532, 0.7681, 0.7746]}, {"w": "the", "b": [0.7742, 0.7532, 0.8005, 0.7746]}, {"w": "gradi‐", "b": [0.8065, 0.7532, 0.8571, 0.7746]}, {"w": "ent", "b": [0.1429, 0.7723, 0.1691, 0.7937]}, {"w": "at", "b": [0.176, 0.7723, 0.1911, 0.7937]}, {"w": "the", "b": [0.198, 0.7723, 0.2243, 0.7937]}, {"w": "original", "b": [0.2312, 0.7723, 0.2963, 0.7937]}, {"w": "position,", "b": [0.3032, 0.7723, 0.3767, 0.7937]}, {"w": "as", "b": [0.3836, 0.7723, 0.4004, 0.7937]}, {"w": "you", "b": [0.4074, 0.7723, 0.4386, 0.7937]}, {"w": "can", "b": [0.4455, 0.7723, 0.4749, 0.7937]}, {"w": "see", "b": [0.4818, 0.7723, 0.5071, 0.7937]}, {"w": "in", "b": [0.5141, 0.7723, 0.531, 0.7937]}, {"w": "Figure", "b": [0.538, 0.7723, 0.592, 0.7937]}, {"w": "11-6", "b": [0.5989, 0.7723, 0.6363, 0.7937]}, {"w": "(where", "b": [0.6432, 0.7723, 0.7012, 0.7937]}, {"w": "∇1", "b": [0.7082, 0.7755, 0.7314, 0.7946]}, {"w": "represents", "b": [0.7383, 0.7723, 0.8239, 0.7937]}, {"w": "the", "b": [0.8308, 0.7723, 0.8571, 0.7937]}, {"w": "gradient", "b": [0.1429, 0.7913, 0.2123, 0.8127]}, {"w": "of", "b": [0.2183, 0.7913, 0.235, 0.8127]}, {"w": "the", "b": [0.241, 0.7913, 0.2674, 0.8127]}, {"w": "cost", "b": [0.2733, 0.7913, 0.3068, 0.8127]}, {"w": "function", "b": [0.3127, 0.7913, 0.3841, 0.8127]}, {"w": "measured", "b": [0.3901, 0.7913, 0.4715, 0.8127]}, {"w": "at", "b": [0.4774, 0.7913, 0.4925, 0.8127]}, {"w": "the", "b": [0.4985, 0.7913, 0.5249, 0.8127]}, {"w": "starting", "b": [0.5308, 0.7913, 0.5948, 0.8127]}, {"w": "point", "b": [0.6008, 0.7913, 0.6452, 0.8127]}, {"w": "θ,", "b": [0.6512, 0.7908, 0.6666, 0.8127]}, {"w": "and", "b": [0.6725, 0.7913, 0.7041, 0.8127]}, {"w": "∇2", "b": [0.7101, 0.7945, 0.7333, 0.8136]}, {"w": "represents", "b": [0.7393, 0.7913, 0.8248, 0.8127]}, {"w": "the", "b": [0.8308, 0.7913, 0.8571, 0.8127]}]}, {"id": "b_13", "type": "paragraph", "text": "346 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "346", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2746, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3265, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 373, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "14 “Adaptive Subgradient Methods for Online Learning and Stochastic Optimization,” J. Duchi et al. (2011).", "words": [{"w": "14", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Adaptive", "b": [0.1587, 0.8749, 0.2198, 0.8912]}, {"w": "Subgradient", "b": [0.2234, 0.8749, 0.3003, 0.8912]}, {"w": "Methods", "b": [0.3039, 0.8749, 0.36, 0.8912]}, {"w": "for", "b": [0.3636, 0.8749, 0.3823, 0.8912]}, {"w": "Online", "b": [0.3859, 0.8749, 0.4301, 0.8912]}, {"w": "Learning", "b": [0.4337, 0.8749, 0.4909, 0.8912]}, {"w": "and", "b": [0.4945, 0.8749, 0.5185, 0.8912]}, {"w": "Stochastic", "b": [0.5221, 0.8749, 0.5864, 0.8912]}, {"w": "Optimization,”", "b": [0.59, 0.8749, 0.6835, 0.8912]}, {"w": "J.", "b": [0.6871, 0.8749, 0.6953, 0.8912]}, {"w": "Duchi", "b": [0.6989, 0.8749, 0.7384, 0.8912]}, {"w": "et", "b": [0.742, 0.8749, 0.7536, 0.8912]}, {"w": "al.", "b": [0.7572, 0.8749, 0.7718, 0.8912]}, {"w": "(2011).", "b": [0.7754, 0.8749, 0.8205, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "gradient at the point located at θ + βm). As you can see, the Nesterov update ends up slightly closer to the optimum. After a while, these small improvements add up and NAG ends up being significantly faster than regular Momentum optimization. More‐ over, note that when the momentum pushes the weights across a valley, ∇1 continues to push further across the valley, while ∇2 pushes back toward the bottom of the val‐ ley. This helps reduce oscillations and thus converges faster.", "words": [{"w": "gradient", "b": [0.1429, 0.0791, 0.2123, 0.1005]}, {"w": "at", "b": [0.2176, 0.0791, 0.2327, 0.1005]}, {"w": "the", "b": [0.2379, 0.0791, 0.2643, 0.1005]}, {"w": "point", "b": [0.2696, 0.0791, 0.314, 0.1005]}, {"w": "located", "b": [0.3193, 0.0791, 0.379, 0.1005]}, {"w": "at", "b": [0.3843, 0.0791, 0.3994, 0.1005]}, {"w": "θ", "b": [0.4046, 0.0785, 0.4152, 0.1005]}, {"w": "+", "b": [0.4205, 0.0791, 0.4326, 0.1005]}, {"w": "βm).", "b": [0.4379, 0.0785, 0.4781, 0.1005]}, {"w": "As", "b": [0.4833, 0.0791, 0.5054, 0.1005]}, {"w": "you", "b": [0.5107, 0.0791, 0.5419, 0.1005]}, {"w": "can", "b": [0.5472, 0.0791, 0.5765, 0.1005]}, {"w": "see,", "b": [0.5818, 0.0791, 0.6119, 0.1005]}, {"w": "the", "b": [0.6172, 0.0791, 0.6435, 0.1005]}, {"w": "Nesterov", "b": [0.6488, 0.0791, 0.7235, 0.1005]}, {"w": "update", "b": [0.7288, 0.0791, 0.7857, 0.1005]}, {"w": "ends", "b": [0.791, 0.0791, 0.8299, 0.1005]}, {"w": "up", "b": [0.8352, 0.0791, 0.8571, 0.1005]}, {"w": "slightly", "b": [0.1429, 0.0981, 0.203, 0.1195]}, {"w": "closer", "b": [0.2094, 0.0981, 0.2584, 0.1195]}, {"w": "to", "b": [0.2648, 0.0981, 0.2818, 0.1195]}, {"w": "the", "b": [0.2882, 0.0981, 0.3145, 0.1195]}, {"w": "optimum.", "b": [0.321, 0.0981, 0.404, 0.1195]}, {"w": "After", "b": [0.4104, 0.0981, 0.4539, 0.1195]}, {"w": "a", "b": [0.4603, 0.0981, 0.4695, 0.1195]}, {"w": "while,", "b": [0.4759, 0.0981, 0.5258, 0.1195]}, {"w": "these", "b": [0.5322, 0.0981, 0.575, 0.1195]}, {"w": "small", "b": [0.5814, 0.0981, 0.6258, 0.1195]}, {"w": "improvements", "b": [0.6323, 0.0981, 0.7532, 0.1195]}, {"w": "add", "b": [0.7596, 0.0981, 0.7908, 0.1195]}, {"w": "up", "b": [0.7972, 0.0981, 0.8192, 0.1195]}, {"w": "and", "b": [0.8256, 0.0981, 0.8571, 0.1195]}, {"w": "NAG", "b": [0.1428, 0.1172, 0.1862, 0.1386]}, {"w": "ends", "b": [0.1916, 0.1172, 0.2305, 0.1386]}, {"w": "up", "b": [0.2358, 0.1172, 0.2578, 0.1386]}, {"w": "being", "b": [0.2632, 0.1172, 0.3093, 0.1386]}, {"w": "significantly", "b": [0.3147, 0.1172, 0.4165, 0.1386]}, {"w": "faster", "b": [0.4219, 0.1172, 0.4678, 0.1386]}, {"w": "than", "b": [0.4731, 0.1172, 0.5112, 0.1386]}, {"w": "regular", "b": [0.5165, 0.1172, 0.5761, 0.1386]}, {"w": "Momentum", "b": [0.5814, 0.1172, 0.6815, 0.1386]}, {"w": "optimization.", "b": [0.6868, 0.1172, 0.7991, 0.1386]}, {"w": "More‐", "b": [0.8045, 0.1172, 0.8571, 0.1386]}, {"w": "over,", "b": [0.1429, 0.1362, 0.1832, 0.1576]}, {"w": "note", "b": [0.1886, 0.1362, 0.2258, 0.1576]}, {"w": "that", "b": [0.2312, 0.1362, 0.2638, 0.1576]}, {"w": "when", "b": [0.2692, 0.1362, 0.3149, 0.1576]}, {"w": "the", "b": [0.3203, 0.1362, 0.3466, 0.1576]}, {"w": "momentum", "b": [0.352, 0.1362, 0.4511, 0.1576]}, {"w": "pushes", "b": [0.4565, 0.1362, 0.5138, 0.1576]}, {"w": "the", "b": [0.5192, 0.1362, 0.5455, 0.1576]}, {"w": "weights", "b": [0.551, 0.1362, 0.6142, 0.1576]}, {"w": "across", "b": [0.6196, 0.1362, 0.6712, 0.1576]}, {"w": "a", "b": [0.6766, 0.1362, 0.6857, 0.1576]}, {"w": "valley,", "b": [0.6912, 0.1362, 0.7421, 0.1576]}, {"w": "∇1", "b": [0.7476, 0.1394, 0.7708, 0.1585]}, {"w": "continues", "b": [0.7762, 0.1362, 0.8571, 0.1576]}, {"w": "to", "b": [0.1429, 0.1553, 0.1598, 0.1767]}, {"w": "push", "b": [0.1653, 0.1553, 0.2061, 0.1767]}, {"w": "further", "b": [0.2116, 0.1553, 0.2706, 0.1767]}, {"w": "across", "b": [0.2761, 0.1553, 0.3277, 0.1767]}, {"w": "the", "b": [0.3332, 0.1553, 0.3595, 0.1767]}, {"w": "valley,", "b": [0.365, 0.1553, 0.416, 0.1767]}, {"w": "while", "b": [0.4215, 0.1553, 0.4666, 0.1767]}, {"w": "∇2", "b": [0.4721, 0.1585, 0.4954, 0.1776]}, {"w": "pushes", "b": [0.5009, 0.1553, 0.5581, 0.1767]}, {"w": "back", "b": [0.5636, 0.1553, 0.6025, 0.1767]}, {"w": "toward", "b": [0.608, 0.1553, 0.6671, 0.1767]}, {"w": "the", "b": [0.6726, 0.1553, 0.6989, 0.1767]}, {"w": "bottom", "b": [0.7044, 0.1553, 0.766, 0.1767]}, {"w": "of", "b": [0.7715, 0.1553, 0.7883, 0.1767]}, {"w": "the", "b": [0.7938, 0.1553, 0.8202, 0.1767]}, {"w": "val‐", "b": [0.8257, 0.1553, 0.8571, 0.1767]}, {"w": "ley.", "b": [0.1429, 0.1743, 0.1698, 0.1957]}, {"w": "This", "b": [0.1745, 0.1743, 0.2117, 0.1957]}, {"w": "helps", "b": [0.2164, 0.1743, 0.2603, 0.1957]}, {"w": "reduce", "b": [0.265, 0.1743, 0.3213, 0.1957]}, {"w": "oscillations", "b": [0.326, 0.1743, 0.4196, 0.1957]}, {"w": "and", "b": [0.4243, 0.1743, 0.4559, 0.1957]}, {"w": "thus", "b": [0.4606, 0.1743, 0.4964, 0.1957]}, {"w": "converges", "b": [0.5011, 0.1743, 0.5839, 0.1957]}, {"w": "faster.", "b": [0.5887, 0.1743, 0.638, 0.1957]}]}, {"id": "b_2", "type": "paragraph", "text": "NAG will almost always speed up training compared to regular Momentum optimi‐ zation. To use it, simply set nesterov=True when creating the SGD optimizer:", "words": [{"w": "NAG", "b": [0.1429, 0.2024, 0.1863, 0.2238]}, {"w": "will", "b": [0.1926, 0.2024, 0.223, 0.2238]}, {"w": "almost", "b": [0.2293, 0.2024, 0.2854, 0.2238]}, {"w": "always", "b": [0.2918, 0.2024, 0.3464, 0.2238]}, {"w": "speed", "b": [0.3528, 0.2024, 0.4, 0.2238]}, {"w": "up", "b": [0.4064, 0.2024, 0.4283, 0.2238]}, {"w": "training", "b": [0.4347, 0.2024, 0.5016, 0.2238]}, {"w": "compared", "b": [0.5079, 0.2024, 0.5917, 0.2238]}, {"w": "to", "b": [0.598, 0.2024, 0.615, 0.2238]}, {"w": "regular", "b": [0.6213, 0.2024, 0.6809, 0.2238]}, {"w": "Momentum", "b": [0.6872, 0.2024, 0.7873, 0.2238]}, {"w": "optimi‐", "b": [0.7936, 0.2024, 0.8571, 0.2238]}, {"w": "zation.", "b": [0.1428, 0.2224, 0.1991, 0.2438]}, {"w": "To", "b": [0.2038, 0.2224, 0.2252, 0.2438]}, {"w": "use", "b": [0.23, 0.2224, 0.2575, 0.2438]}, {"w": "it,", "b": [0.2622, 0.2224, 0.2789, 0.2438]}, {"w": "simply", "b": [0.2837, 0.2224, 0.3393, 0.2438]}, {"w": "set", "b": [0.344, 0.2224, 0.3669, 0.2438]}, {"w": "nesterov=True", "b": [0.3716, 0.2255, 0.5003, 0.2406]}, {"w": "when", "b": [0.505, 0.2224, 0.5506, 0.2438]}, {"w": "creating", "b": [0.5554, 0.2224, 0.6226, 0.2438]}, {"w": "the", "b": [0.6273, 0.2224, 0.6537, 0.2438]}, {"w": "SGD", "b": [0.6584, 0.2255, 0.6881, 0.2406]}, {"w": "optimizer:", "b": [0.6928, 0.2224, 0.7795, 0.2438]}]}, {"id": "b_3", "type": "equation", "text": "optimizer = keras.optimizers.SGD(lr=0.001, momentum=0.9, nesterov=True)", "words": [{"w": "optimizer", "b": [0.1766, 0.2543, 0.2525, 0.2672]}, {"w": "=", "b": [0.2609, 0.2543, 0.2693, 0.2672]}, {"w": "keras.optimizers.SGD(lr=0.001,", "b": [0.2778, 0.2543, 0.5308, 0.2672]}, {"w": "momentum=0.9,", "b": [0.5392, 0.2543, 0.6488, 0.2672]}, {"w": "nesterov=True)", "b": [0.6572, 0.2543, 0.7753, 0.2672]}]}, {"id": "b_4", "type": "equation", "text": "Figure 11-6. Regular versus Nesterov Momentum optimization", "words": [{"w": "Figure", "b": [0.1429, 0.5139, 0.1943, 0.5356]}, {"w": "11-6.", "b": [0.1991, 0.5139, 0.2407, 0.5356]}, {"w": "Regular", "b": [0.2455, 0.5139, 0.3085, 0.5356]}, {"w": "versus", "b": [0.3133, 0.5139, 0.3634, 0.5356]}, {"w": "Nesterov", "b": [0.3682, 0.5139, 0.4379, 0.5356]}, {"w": "Momentum", "b": [0.4426, 0.5139, 0.5385, 0.5356]}, {"w": "optimization", "b": [0.5433, 0.5139, 0.6471, 0.5356]}]}, {"id": "b_5", "type": "paragraph", "text": "AdaGrad", "words": [{"w": "AdaGrad", "b": [0.1429, 0.5486, 0.2311, 0.5772]}]}, {"id": "b_6", "type": "paragraph", "text": "Consider the elongated bowl problem again: Gradient Descent starts by quickly going down the steepest slope, then slowly goes down the bottom of the valley. It would be nice if the algorithm could detect this early on and correct its direction to point a bit more toward the global optimum.", "words": [{"w": "Consider", "b": [0.1429, 0.5831, 0.2195, 0.6045]}, {"w": "the", "b": [0.2245, 0.5831, 0.2508, 0.6045]}, {"w": "elongated", "b": [0.2557, 0.5831, 0.3366, 0.6045]}, {"w": "bowl", "b": [0.3415, 0.5831, 0.3822, 0.6045]}, {"w": "problem", "b": [0.3871, 0.5831, 0.4582, 0.6045]}, {"w": "again:", "b": [0.4631, 0.5831, 0.5129, 0.6045]}, {"w": "Gradient", "b": [0.5178, 0.5831, 0.5923, 0.6045]}, {"w": "Descent", "b": [0.5973, 0.5831, 0.6641, 0.6045]}, {"w": "starts", "b": [0.669, 0.5831, 0.7139, 0.6045]}, {"w": "by", "b": [0.7188, 0.5831, 0.7389, 0.6045]}, {"w": "quickly", "b": [0.7439, 0.5831, 0.8051, 0.6045]}, {"w": "going", "b": [0.81, 0.5831, 0.8571, 0.6045]}, {"w": "down", "b": [0.1429, 0.6021, 0.1901, 0.6235]}, {"w": "the", "b": [0.1959, 0.6021, 0.2222, 0.6235]}, {"w": "steepest", "b": [0.228, 0.6021, 0.2935, 0.6235]}, {"w": "slope,", "b": [0.2992, 0.6021, 0.3473, 0.6235]}, {"w": "then", "b": [0.353, 0.6021, 0.3907, 0.6235]}, {"w": "slowly", "b": [0.3965, 0.6021, 0.4491, 0.6235]}, {"w": "goes", "b": [0.4549, 0.6021, 0.4918, 0.6235]}, {"w": "down", "b": [0.4975, 0.6021, 0.5448, 0.6235]}, {"w": "the", "b": [0.5505, 0.6021, 0.5769, 0.6235]}, {"w": "bottom", "b": [0.5826, 0.6021, 0.6442, 0.6235]}, {"w": "of", "b": [0.65, 0.6021, 0.6668, 0.6235]}, {"w": "the", "b": [0.6725, 0.6021, 0.6989, 0.6235]}, {"w": "valley.", "b": [0.7046, 0.6021, 0.7556, 0.6235]}, {"w": "It", "b": [0.7613, 0.6021, 0.774, 0.6235]}, {"w": "would", "b": [0.7797, 0.6021, 0.832, 0.6235]}, {"w": "be", "b": [0.8377, 0.6021, 0.8571, 0.6235]}, {"w": "nice", "b": [0.1429, 0.6212, 0.1775, 0.6426]}, {"w": "if", "b": [0.1831, 0.6212, 0.1949, 0.6426]}, {"w": "the", "b": [0.2005, 0.6212, 0.2268, 0.6426]}, {"w": "algorithm", "b": [0.2324, 0.6212, 0.315, 0.6426]}, {"w": "could", "b": [0.3206, 0.6212, 0.3674, 0.6426]}, {"w": "detect", "b": [0.373, 0.6212, 0.4232, 0.6426]}, {"w": "this", "b": [0.4288, 0.6212, 0.4595, 0.6426]}, {"w": "early", "b": [0.4651, 0.6212, 0.5057, 0.6426]}, {"w": "on", "b": [0.5113, 0.6212, 0.5333, 0.6426]}, {"w": "and", "b": [0.5389, 0.6212, 0.5704, 0.6426]}, {"w": "correct", "b": [0.576, 0.6212, 0.6349, 0.6426]}, {"w": "its", "b": [0.6405, 0.6212, 0.6601, 0.6426]}, {"w": "direction", "b": [0.6657, 0.6212, 0.7416, 0.6426]}, {"w": "to", "b": [0.7472, 0.6212, 0.7642, 0.6426]}, {"w": "point", "b": [0.7698, 0.6212, 0.8143, 0.6426]}, {"w": "a", "b": [0.8199, 0.6212, 0.829, 0.6426]}, {"w": "bit", "b": [0.8346, 0.6212, 0.8572, 0.6426]}, {"w": "more", "b": [0.1429, 0.6402, 0.1871, 0.6616]}, {"w": "toward", "b": [0.1919, 0.6402, 0.251, 0.6616]}, {"w": "the", "b": [0.2557, 0.6402, 0.282, 0.6616]}, {"w": "global", "b": [0.2868, 0.6402, 0.3374, 0.6616]}, {"w": "optimum.", "b": [0.3422, 0.6402, 0.4252, 0.6616]}]}, {"id": "b_7", "type": "paragraph", "text": "The AdaGrad algorithm14 achieves this by scaling down the gradient vector along the steepest dimensions (see Equation 11-6):", "words": [{"w": "The", "b": [0.1429, 0.6683, 0.1757, 0.6897]}, {"w": "AdaGrad", "b": [0.1811, 0.6681, 0.2575, 0.6897]}, {"w": "algorithm14", "b": [0.2629, 0.6683, 0.357, 0.6897]}, {"w": "achieves", "b": [0.3624, 0.6683, 0.4321, 0.6897]}, {"w": "this", "b": [0.4375, 0.6683, 0.4683, 0.6897]}, {"w": "by", "b": [0.4737, 0.6683, 0.4938, 0.6897]}, {"w": "scaling", "b": [0.4993, 0.6683, 0.5569, 0.6897]}, {"w": "down", "b": [0.5623, 0.6683, 0.6096, 0.6897]}, {"w": "the", "b": [0.6151, 0.6683, 0.6414, 0.6897]}, {"w": "gradient", "b": [0.6469, 0.6683, 0.7163, 0.6897]}, {"w": "vector", "b": [0.7217, 0.6683, 0.7737, 0.6897]}, {"w": "along", "b": [0.7792, 0.6683, 0.8254, 0.6897]}, {"w": "the", "b": [0.8308, 0.6683, 0.8571, 0.6897]}, {"w": "steepest", "b": [0.1429, 0.6874, 0.2083, 0.7088]}, {"w": "dimensions", "b": [0.2131, 0.6874, 0.3099, 0.7088]}, {"w": "(see", "b": [0.3146, 0.6874, 0.3471, 0.7088]}, {"w": "Equation", "b": [0.3519, 0.6874, 0.4281, 0.7088]}, {"w": "11-6):", "b": [0.4329, 0.6874, 0.4822, 0.7088]}]}, {"id": "b_8", "type": "equation", "text": "Equation 11-6. AdaGrad algorithm", "words": [{"w": "Equation", "b": [0.1726, 0.7269, 0.2473, 0.7485]}, {"w": "11-6.", "b": [0.2521, 0.7269, 0.2937, 0.7485]}, {"w": "AdaGrad", "b": [0.2985, 0.7269, 0.3748, 0.7485]}, {"w": "algorithm", "b": [0.3796, 0.7269, 0.459, 0.7485]}]}, {"id": "b_9", "type": "equation", "text": "1 . s s + ∇θJ θ ⊗∇θJ θ", "words": [{"w": "1", "b": [0.1726, 0.7557, 0.1821, 0.7761]}, {"w": ".", "b": [0.1854, 0.7557, 0.19, 0.7761]}, {"w": "s", "b": [0.2218, 0.7552, 0.2294, 0.7761]}, {"w": "s", "b": [0.2578, 0.7552, 0.2654, 0.7761]}, {"w": "+", "b": [0.2699, 0.7557, 0.2814, 0.7761]}, {"w": "∇θJ", "b": [0.2858, 0.7555, 0.3171, 0.7795]}, {"w": "θ", "b": [0.325, 0.7552, 0.3351, 0.7761]}, {"w": "⊗∇θJ", "b": [0.3464, 0.7555, 0.3975, 0.7795]}, {"w": "θ", "b": [0.4054, 0.7552, 0.4155, 0.7761]}]}, {"id": "b_10", "type": "equation", "text": "2 . θ θ −η ∇θJ θ ⊘ s + �", "words": [{"w": "2", "b": [0.1726, 0.7833, 0.1821, 0.8037]}, {"w": ".", "b": [0.1855, 0.7833, 0.19, 0.8037]}, {"w": "θ", "b": [0.2218, 0.7828, 0.2319, 0.8037]}, {"w": "θ", "b": [0.2603, 0.7828, 0.2704, 0.8037]}, {"w": "−η", "b": [0.2748, 0.7831, 0.3009, 0.8037]}, {"w": "∇θJ", "b": [0.3042, 0.7831, 0.3355, 0.8071]}, {"w": "θ", "b": [0.3434, 0.7828, 0.3535, 0.8037]}, {"w": "⊘", "b": [0.3648, 0.7864, 0.3802, 0.8015]}, {"w": "s", "b": [0.3967, 0.7828, 0.4043, 0.8037]}, {"w": "+", "b": [0.4087, 0.7833, 0.4202, 0.8037]}, {"w": "�", "b": [0.4246, 0.7864, 0.4336, 0.8015]}]}, {"id": "b_11", "type": "paragraph", "text": "Faster Optimizers | 347", "words": [{"w": "Faster", "b": [0.6934, 0.9225, 0.7296, 0.9388]}, {"w": "Optimizers", "b": [0.7325, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "347", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 374, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "The first step accumulates the square of the gradients into the vector s (recall that the ⊗ symbol represents the element-wise multiplication). This vectorized form is equiv‐ alent to computing si ← si + (∂ J(θ) / ∂ θi)2 for each element si of the vector s; in other words, each si accumulates the squares of the partial derivative of the cost function with regards to parameter θi. If the cost function is steep along the ith dimension, then si will get larger and larger at each iteration.", "words": [{"w": "The", "b": [0.1429, 0.0791, 0.1757, 0.1005]}, {"w": "first", "b": [0.181, 0.0791, 0.2144, 0.1005]}, {"w": "step", "b": [0.2197, 0.0791, 0.2535, 0.1005]}, {"w": "accumulates", "b": [0.2588, 0.0791, 0.3612, 0.1005]}, {"w": "the", "b": [0.3665, 0.0791, 0.3928, 0.1005]}, {"w": "square", "b": [0.3981, 0.0791, 0.4531, 0.1005]}, {"w": "of", "b": [0.4584, 0.0791, 0.4752, 0.1005]}, {"w": "the", "b": [0.4805, 0.0791, 0.5068, 0.1005]}, {"w": "gradients", "b": [0.5121, 0.0791, 0.5891, 0.1005]}, {"w": "into", "b": [0.5944, 0.0791, 0.628, 0.1005]}, {"w": "the", "b": [0.6332, 0.0791, 0.6596, 0.1005]}, {"w": "vector", "b": [0.6649, 0.0791, 0.7169, 0.1005]}, {"w": "s", "b": [0.7221, 0.0785, 0.7301, 0.1005]}, {"w": "(recall", "b": [0.7354, 0.0791, 0.7877, 0.1005]}, {"w": "that", "b": [0.793, 0.0791, 0.8255, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}, {"w": "⊗", "b": [0.1429, 0.1014, 0.159, 0.1172]}, {"w": "symbol", "b": [0.1644, 0.0981, 0.2252, 0.1195]}, {"w": "represents", "b": [0.2305, 0.0981, 0.3161, 0.1195]}, {"w": "the", "b": [0.3215, 0.0981, 0.3478, 0.1195]}, {"w": "element-wise", "b": [0.3532, 0.0981, 0.4632, 0.1195]}, {"w": "multiplication).", "b": [0.4686, 0.0981, 0.5988, 0.1195]}, {"w": "This", "b": [0.6042, 0.0981, 0.6414, 0.1195]}, {"w": "vectorized", "b": [0.6468, 0.0981, 0.733, 0.1195]}, {"w": "form", "b": [0.7384, 0.0981, 0.7799, 0.1195]}, {"w": "is", "b": [0.7853, 0.0981, 0.7986, 0.1195]}, {"w": "equiv‐", "b": [0.8039, 0.0981, 0.8571, 0.1195]}, {"w": "alent", "b": [0.1429, 0.1172, 0.1835, 0.1386]}, {"w": "to", "b": [0.1888, 0.1172, 0.2058, 0.1386]}, {"w": "computing", "b": [0.2112, 0.1172, 0.3024, 0.1386]}, {"w": "si", "b": [0.3077, 0.117, 0.3182, 0.1395]}, {"w": "←", "b": [0.3236, 0.1172, 0.3418, 0.1386]}, {"w": "si", "b": [0.3472, 0.117, 0.3576, 0.1395]}, {"w": "+", "b": [0.363, 0.1172, 0.3751, 0.1386]}, {"w": "(∂", "b": [0.3798, 0.1172, 0.3979, 0.1386]}, {"w": "J(θ)", "b": [0.4033, 0.1166, 0.435, 0.1386]}, {"w": "/", "b": [0.4403, 0.1172, 0.4472, 0.1386]}, {"w": "∂", "b": [0.4526, 0.1172, 0.4628, 0.1386]}, {"w": "θi)2", "b": [0.4682, 0.117, 0.4947, 0.1395]}, {"w": "for", "b": [0.5001, 0.1172, 0.5246, 0.1386]}, {"w": "each", "b": [0.53, 0.1172, 0.5679, 0.1386]}, {"w": "element", "b": [0.5733, 0.1172, 0.6396, 0.1386]}, {"w": "si", "b": [0.6449, 0.117, 0.6554, 0.1395]}, {"w": "of", "b": [0.6607, 0.1172, 0.6775, 0.1386]}, {"w": "the", "b": [0.6829, 0.1172, 0.7092, 0.1386]}, {"w": "vector", "b": [0.7146, 0.1172, 0.7666, 0.1386]}, {"w": "s;", "b": [0.772, 0.1166, 0.7847, 0.1386]}, {"w": "in", "b": [0.7901, 0.1172, 0.8071, 0.1386]}, {"w": "other", "b": [0.8125, 0.1172, 0.8571, 0.1386]}, {"w": "words,", "b": [0.1429, 0.1362, 0.1989, 0.1576]}, {"w": "each", "b": [0.2059, 0.1362, 0.2438, 0.1576]}, {"w": "si", "b": [0.2508, 0.136, 0.2613, 0.1585]}, {"w": "accumulates", "b": [0.2683, 0.1362, 0.3707, 0.1576]}, {"w": "the", "b": [0.3777, 0.1362, 0.4041, 0.1576]}, {"w": "squares", "b": [0.4111, 0.1362, 0.4738, 0.1576]}, {"w": "of", "b": [0.4808, 0.1362, 0.4976, 0.1576]}, {"w": "the", "b": [0.5046, 0.1362, 0.531, 0.1576]}, {"w": "partial", "b": [0.538, 0.1362, 0.5921, 0.1576]}, {"w": "derivative", "b": [0.5991, 0.1362, 0.6811, 0.1576]}, {"w": "of", "b": [0.6882, 0.1362, 0.7049, 0.1576]}, {"w": "the", "b": [0.712, 0.1362, 0.7383, 0.1576]}, {"w": "cost", "b": [0.7453, 0.1362, 0.7787, 0.1576]}, {"w": "function", "b": [0.7858, 0.1362, 0.8572, 0.1576]}, {"w": "with", "b": [0.1429, 0.1553, 0.1802, 0.1767]}, {"w": "regards", "b": [0.1851, 0.1553, 0.247, 0.1767]}, {"w": "to", "b": [0.2519, 0.1553, 0.2689, 0.1767]}, {"w": "parameter", "b": [0.2738, 0.1553, 0.3596, 0.1767]}, {"w": "θi.", "b": [0.3645, 0.155, 0.3826, 0.1776]}, {"w": "If", "b": [0.3875, 0.1553, 0.4008, 0.1767]}, {"w": "the", "b": [0.4057, 0.1553, 0.432, 0.1767]}, {"w": "cost", "b": [0.4369, 0.1553, 0.4704, 0.1767]}, {"w": "function", "b": [0.4753, 0.1553, 0.5467, 0.1767]}, {"w": "is", "b": [0.5516, 0.1553, 0.5648, 0.1767]}, {"w": "steep", "b": [0.5697, 0.1553, 0.6124, 0.1767]}, {"w": "along", "b": [0.6173, 0.1553, 0.6635, 0.1767]}, {"w": "the", "b": [0.6684, 0.1553, 0.6947, 0.1767]}, {"w": "ith", "b": [0.6996, 0.1553, 0.7157, 0.1767]}, {"w": "dimension,", "b": [0.7206, 0.1553, 0.8145, 0.1767]}, {"w": "then", "b": [0.8192, 0.1553, 0.857, 0.1767]}, {"w": "si", "b": [0.1429, 0.1741, 0.1533, 0.1966]}, {"w": "will", "b": [0.158, 0.1743, 0.1884, 0.1957]}, {"w": "get", "b": [0.1931, 0.1743, 0.2181, 0.1957]}, {"w": "larger", "b": [0.2228, 0.1743, 0.2713, 0.1957]}, {"w": "and", "b": [0.276, 0.1743, 0.3076, 0.1957]}, {"w": "larger", "b": [0.3123, 0.1743, 0.3608, 0.1957]}, {"w": "at", "b": [0.3655, 0.1743, 0.3806, 0.1957]}, {"w": "each", "b": [0.3854, 0.1743, 0.4233, 0.1957]}, {"w": "iteration.", "b": [0.428, 0.1743, 0.504, 0.1957]}]}, {"id": "b_1", "type": "paragraph", "text": "The second step is almost identical to Gradient Descent, but with one big difference: the gradient vector is scaled down by a factor of �+ � (the ⊘ symbol represents the element-wise division, and ϵ is a smoothing term to avoid division by zero, typically set to 10–10). This vectorized form is equivalent to computing θi θi −η ∂J θ / ∂θi/ si + � for all parameters θi (simultaneously).", "words": [{"w": "The", "b": [0.1429, 0.2024, 0.1757, 0.2238]}, {"w": "second", "b": [0.1815, 0.2024, 0.2398, 0.2238]}, {"w": "step", "b": [0.2456, 0.2024, 0.2793, 0.2238]}, {"w": "is", "b": [0.2851, 0.2024, 0.2983, 0.2238]}, {"w": "almost", "b": [0.3041, 0.2024, 0.3602, 0.2238]}, {"w": "identical", "b": [0.366, 0.2024, 0.4376, 0.2238]}, {"w": "to", "b": [0.4433, 0.2024, 0.4603, 0.2238]}, {"w": "Gradient", "b": [0.4661, 0.2024, 0.5407, 0.2238]}, {"w": "Descent,", "b": [0.5464, 0.2024, 0.618, 0.2238]}, {"w": "but", "b": [0.6238, 0.2024, 0.6518, 0.2238]}, {"w": "with", "b": [0.6575, 0.2024, 0.6949, 0.2238]}, {"w": "one", "b": [0.7006, 0.2024, 0.7315, 0.2238]}, {"w": "big", "b": [0.7373, 0.2024, 0.7632, 0.2238]}, {"w": "difference:", "b": [0.769, 0.2024, 0.8571, 0.2238]}, {"w": "the", "b": [0.1429, 0.2222, 0.1692, 0.2436]}, {"w": "gradient", "b": [0.175, 0.2222, 0.2444, 0.2436]}, {"w": "vector", "b": [0.2502, 0.2222, 0.3022, 0.2436]}, {"w": "is", "b": [0.308, 0.2222, 0.3212, 0.2436]}, {"w": "scaled", "b": [0.327, 0.2222, 0.3777, 0.2436]}, {"w": "down", "b": [0.3835, 0.2222, 0.4308, 0.2436]}, {"w": "by", "b": [0.4365, 0.2222, 0.4567, 0.2436]}, {"w": "a", "b": [0.4625, 0.2222, 0.4716, 0.2436]}, {"w": "factor", "b": [0.4774, 0.2222, 0.5262, 0.2436]}, {"w": "of", "b": [0.532, 0.2222, 0.5488, 0.2436]}, {"w": "�+", "b": [0.5672, 0.2222, 0.5918, 0.2436]}, {"w": "�", "b": [0.5964, 0.2254, 0.6059, 0.2413]}, {"w": "(the", "b": [0.6117, 0.2222, 0.6452, 0.2436]}, {"w": "⊘", "b": [0.651, 0.2254, 0.6672, 0.2413]}, {"w": "symbol", "b": [0.6729, 0.2222, 0.7337, 0.2436]}, {"w": "represents", "b": [0.7395, 0.2222, 0.825, 0.2436]}, {"w": "the", "b": [0.8308, 0.2222, 0.8572, 0.2436]}, {"w": "element-wise", "b": [0.1429, 0.2412, 0.2529, 0.2626]}, {"w": "division,", "b": [0.2589, 0.2412, 0.3307, 0.2626]}, {"w": "and", "b": [0.3368, 0.2412, 0.3683, 0.2626]}, {"w": "ϵ", "b": [0.3744, 0.2444, 0.3837, 0.2603]}, {"w": "is", "b": [0.3898, 0.2412, 0.403, 0.2626]}, {"w": "a", "b": [0.4091, 0.2412, 0.4182, 0.2626]}, {"w": "smoothing", "b": [0.4242, 0.2412, 0.5144, 0.2626]}, {"w": "term", "b": [0.5205, 0.2412, 0.5605, 0.2626]}, {"w": "to", "b": [0.5665, 0.2412, 0.5835, 0.2626]}, {"w": "avoid", "b": [0.5895, 0.2412, 0.6352, 0.2626]}, {"w": "division", "b": [0.6412, 0.2412, 0.7083, 0.2626]}, {"w": "by", "b": [0.7143, 0.2412, 0.7345, 0.2626]}, {"w": "zero,", "b": [0.7405, 0.2412, 0.7806, 0.2626]}, {"w": "typically", "b": [0.7867, 0.2412, 0.8571, 0.2626]}, {"w": "set", "b": [0.1428, 0.2603, 0.1657, 0.2817]}, {"w": "to", "b": [0.1936, 0.2603, 0.2106, 0.2817]}, {"w": "10–10).", "b": [0.2385, 0.2603, 0.289, 0.2817]}, {"w": "This", "b": [0.3169, 0.2603, 0.3541, 0.2817]}, {"w": "vectorized", "b": [0.382, 0.2603, 0.4682, 0.2817]}, {"w": "form", "b": [0.4961, 0.2603, 0.5377, 0.2817]}, {"w": "is", "b": [0.5656, 0.2603, 0.5789, 0.2817]}, {"w": "equivalent", "b": [0.6068, 0.2603, 0.6932, 0.2817]}, {"w": "to", "b": [0.7211, 0.2603, 0.7381, 0.2817]}, {"w": "computing", "b": [0.766, 0.2603, 0.8571, 0.2817]}, {"w": "θi", "b": [0.1429, 0.2803, 0.1571, 0.3058]}, {"w": "θi", "b": [0.187, 0.2803, 0.2012, 0.3058]}, {"w": "−η", "b": [0.2059, 0.2803, 0.2332, 0.3019]}, {"w": "∂J", "b": [0.2376, 0.2803, 0.2562, 0.3019]}, {"w": "θ", "b": [0.2644, 0.28, 0.275, 0.3019]}, {"w": "/", "b": [0.2834, 0.2805, 0.2903, 0.3019]}, {"w": "∂θi/", "b": [0.2938, 0.2803, 0.3275, 0.3058]}, {"w": "si", "b": [0.3413, 0.2803, 0.3527, 0.3058]}, {"w": "+", "b": [0.3573, 0.2805, 0.3694, 0.3019]}, {"w": "�", "b": [0.374, 0.2838, 0.3835, 0.2996]}, {"w": "for", "b": [0.3882, 0.2805, 0.4127, 0.3019]}, {"w": "all", "b": [0.4175, 0.2805, 0.4371, 0.3019]}, {"w": "parameters", "b": [0.4419, 0.2805, 0.5353, 0.3019]}, {"w": "θi", "b": [0.54, 0.2803, 0.5534, 0.3028]}, {"w": "(simultaneously).", "b": [0.5581, 0.2805, 0.7034, 0.3019]}]}, {"id": "b_2", "type": "paragraph", "text": "In short, this algorithm decays the learning rate, but it does so faster for steep dimen‐ sions than for dimensions with gentler slopes. This is called an adaptive learning rate. It helps point the resulting updates more directly toward the global optimum (see Figure 11-7). One additional benefit is that it requires much less tuning of the learn‐ ing rate hyperparameter η.", "words": [{"w": "In", "b": [0.1429, 0.3112, 0.1614, 0.3326]}, {"w": "short,", "b": [0.1665, 0.3112, 0.2147, 0.3326]}, {"w": "this", "b": [0.2198, 0.3112, 0.2506, 0.3326]}, {"w": "algorithm", "b": [0.2557, 0.3112, 0.3383, 0.3326]}, {"w": "decays", "b": [0.3435, 0.3112, 0.3981, 0.3326]}, {"w": "the", "b": [0.4032, 0.3112, 0.4296, 0.3326]}, {"w": "learning", "b": [0.4347, 0.3112, 0.5038, 0.3326]}, {"w": "rate,", "b": [0.509, 0.3112, 0.5454, 0.3326]}, {"w": "but", "b": [0.5505, 0.3112, 0.5785, 0.3326]}, {"w": "it", "b": [0.5837, 0.3112, 0.5956, 0.3326]}, {"w": "does", "b": [0.6007, 0.3112, 0.6389, 0.3326]}, {"w": "so", "b": [0.644, 0.3112, 0.6623, 0.3326]}, {"w": "faster", "b": [0.6674, 0.3112, 0.7133, 0.3326]}, {"w": "for", "b": [0.7184, 0.3112, 0.7429, 0.3326]}, {"w": "steep", "b": [0.7481, 0.3112, 0.7907, 0.3326]}, {"w": "dimen‐", "b": [0.7958, 0.3112, 0.8571, 0.3326]}, {"w": "sions", "b": [0.1429, 0.3303, 0.1858, 0.3517]}, {"w": "than", "b": [0.1907, 0.3303, 0.2287, 0.3517]}, {"w": "for", "b": [0.2337, 0.3303, 0.2582, 0.3517]}, {"w": "dimensions", "b": [0.2631, 0.3303, 0.3599, 0.3517]}, {"w": "with", "b": [0.3649, 0.3303, 0.4022, 0.3517]}, {"w": "gentler", "b": [0.4072, 0.3303, 0.465, 0.3517]}, {"w": "slopes.", "b": [0.4699, 0.3303, 0.5256, 0.3517]}, {"w": "This", "b": [0.5306, 0.3303, 0.5678, 0.3517]}, {"w": "is", "b": [0.5727, 0.3303, 0.586, 0.3517]}, {"w": "called", "b": [0.5909, 0.3303, 0.6393, 0.3517]}, {"w": "an", "b": [0.6442, 0.3303, 0.6648, 0.3517]}, {"w": "adaptive", "b": [0.6697, 0.3301, 0.7393, 0.3517]}, {"w": "learning", "b": [0.744, 0.3301, 0.8107, 0.3517]}, {"w": "rate.", "b": [0.8155, 0.3301, 0.8522, 0.3517]}, {"w": "It", "b": [0.1429, 0.3493, 0.1555, 0.3707]}, {"w": "helps", "b": [0.1634, 0.3493, 0.2072, 0.3707]}, {"w": "point", "b": [0.215, 0.3493, 0.2595, 0.3707]}, {"w": "the", "b": [0.2674, 0.3493, 0.2937, 0.3707]}, {"w": "resulting", "b": [0.3016, 0.3493, 0.3752, 0.3707]}, {"w": "updates", "b": [0.3831, 0.3493, 0.4477, 0.3707]}, {"w": "more", "b": [0.4556, 0.3493, 0.4998, 0.3707]}, {"w": "directly", "b": [0.5077, 0.3493, 0.5709, 0.3707]}, {"w": "toward", "b": [0.5787, 0.3493, 0.6379, 0.3707]}, {"w": "the", "b": [0.6457, 0.3493, 0.6721, 0.3707]}, {"w": "global", "b": [0.6799, 0.3493, 0.7306, 0.3707]}, {"w": "optimum", "b": [0.7384, 0.3493, 0.8167, 0.3707]}, {"w": "(see", "b": [0.8246, 0.3493, 0.8571, 0.3707]}, {"w": "Figure", "b": [0.1429, 0.3684, 0.1969, 0.3898]}, {"w": "11-7).", "b": [0.2026, 0.3684, 0.252, 0.3898]}, {"w": "One", "b": [0.2578, 0.3684, 0.2936, 0.3898]}, {"w": "additional", "b": [0.2994, 0.3684, 0.3845, 0.3898]}, {"w": "benefit", "b": [0.3902, 0.3684, 0.448, 0.3898]}, {"w": "is", "b": [0.4538, 0.3684, 0.467, 0.3898]}, {"w": "that", "b": [0.4728, 0.3684, 0.5054, 0.3898]}, {"w": "it", "b": [0.5112, 0.3684, 0.5231, 0.3898]}, {"w": "requires", "b": [0.5289, 0.3684, 0.597, 0.3898]}, {"w": "much", "b": [0.6027, 0.3684, 0.6504, 0.3898]}, {"w": "less", "b": [0.6562, 0.3684, 0.6856, 0.3898]}, {"w": "tuning", "b": [0.6914, 0.3684, 0.7469, 0.3898]}, {"w": "of", "b": [0.7527, 0.3684, 0.7695, 0.3898]}, {"w": "the", "b": [0.7752, 0.3684, 0.8016, 0.3898]}, {"w": "learn‐", "b": [0.8073, 0.3684, 0.8572, 0.3898]}, {"w": "ing", "b": [0.1429, 0.3874, 0.1696, 0.4088]}, {"w": "rate", "b": [0.1743, 0.3874, 0.206, 0.4088]}, {"w": "hyperparameter", "b": [0.2107, 0.3874, 0.3442, 0.4088]}, {"w": "η.", "b": [0.349, 0.3872, 0.3643, 0.4088]}]}, {"id": "b_3", "type": "equation", "text": "Figure 11-7. AdaGrad versus Gradient Descent", "words": [{"w": "Figure", "b": [0.1429, 0.6332, 0.1943, 0.6549]}, {"w": "11-7.", "b": [0.1991, 0.6332, 0.2407, 0.6549]}, {"w": "AdaGrad", "b": [0.2455, 0.6332, 0.3218, 0.6549]}, {"w": "versus", "b": [0.3266, 0.6332, 0.3767, 0.6549]}, {"w": "Gradient", "b": [0.3815, 0.6332, 0.454, 0.6549]}, {"w": "Descent", "b": [0.4588, 0.6332, 0.5221, 0.6549]}]}, {"id": "b_4", "type": "paragraph", "text": "AdaGrad often performs well for simple quadratic problems, but unfortunately it often stops too early when training neural networks. The learning rate gets scaled down so much that the algorithm ends up stopping entirely before reaching the global optimum. So even though Keras has an Adagrad optimizer, you should not use it to train deep neural networks (it may be efficient for simpler tasks such as Linear Regression, though). However, understanding Adagrad is helpful to grasp the other adaptive learning rate optimizers.", "words": [{"w": "AdaGrad", "b": [0.1429, 0.6706, 0.2196, 0.692]}, {"w": "often", "b": [0.2284, 0.6706, 0.2718, 0.692]}, {"w": "performs", "b": [0.2805, 0.6706, 0.3572, 0.692]}, {"w": "well", "b": [0.3659, 0.6706, 0.3996, 0.692]}, {"w": "for", "b": [0.4083, 0.6706, 0.4328, 0.692]}, {"w": "simple", "b": [0.4416, 0.6706, 0.4965, 0.692]}, {"w": "quadratic", "b": [0.5052, 0.6706, 0.5843, 0.692]}, {"w": "problems,", "b": [0.593, 0.6706, 0.6765, 0.692]}, {"w": "but", "b": [0.6852, 0.6706, 0.7132, 0.692]}, {"w": "unfortunately", "b": [0.7219, 0.6706, 0.8365, 0.692]}, {"w": "it", "b": [0.8452, 0.6706, 0.8571, 0.692]}, {"w": "often", "b": [0.1429, 0.6897, 0.1863, 0.7111]}, {"w": "stops", "b": [0.1941, 0.6897, 0.2373, 0.7111]}, {"w": "too", "b": [0.2452, 0.6897, 0.2728, 0.7111]}, {"w": "early", "b": [0.2807, 0.6897, 0.3212, 0.7111]}, {"w": "when", "b": [0.3291, 0.6897, 0.3748, 0.7111]}, {"w": "training", "b": [0.3826, 0.6897, 0.4496, 0.7111]}, {"w": "neural", "b": [0.4575, 0.6897, 0.5109, 0.7111]}, {"w": "networks.", "b": [0.5188, 0.6897, 0.6008, 0.7111]}, {"w": "The", "b": [0.6086, 0.6897, 0.6415, 0.7111]}, {"w": "learning", "b": [0.6494, 0.6897, 0.7185, 0.7111]}, {"w": "rate", "b": [0.7264, 0.6897, 0.758, 0.7111]}, {"w": "gets", "b": [0.7659, 0.6897, 0.7985, 0.7111]}, {"w": "scaled", "b": [0.8064, 0.6897, 0.8571, 0.7111]}, {"w": "down", "b": [0.1428, 0.7087, 0.1901, 0.7301]}, {"w": "so", "b": [0.1994, 0.7087, 0.2176, 0.7301]}, {"w": "much", "b": [0.2269, 0.7087, 0.2745, 0.7301]}, {"w": "that", "b": [0.2837, 0.7087, 0.3163, 0.7301]}, {"w": "the", "b": [0.3256, 0.7087, 0.3519, 0.7301]}, {"w": "algorithm", "b": [0.3611, 0.7087, 0.4438, 0.7301]}, {"w": "ends", "b": [0.453, 0.7087, 0.4919, 0.7301]}, {"w": "up", "b": [0.5011, 0.7087, 0.5231, 0.7301]}, {"w": "stopping", "b": [0.5323, 0.7087, 0.6055, 0.7301]}, {"w": "entirely", "b": [0.6147, 0.7087, 0.6779, 0.7301]}, {"w": "before", "b": [0.6871, 0.7087, 0.74, 0.7301]}, {"w": "reaching", "b": [0.7492, 0.7087, 0.8216, 0.7301]}, {"w": "the", "b": [0.8308, 0.7087, 0.8571, 0.7301]}, {"w": "global", "b": [0.1429, 0.7287, 0.1935, 0.7501]}, {"w": "optimum.", "b": [0.1987, 0.7287, 0.2818, 0.7501]}, {"w": "So", "b": [0.287, 0.7287, 0.3075, 0.7501]}, {"w": "even", "b": [0.3127, 0.7287, 0.3514, 0.7501]}, {"w": "though", "b": [0.3567, 0.7287, 0.4167, 0.7501]}, {"w": "Keras", "b": [0.4219, 0.7287, 0.4688, 0.7501]}, {"w": "has", "b": [0.4741, 0.7287, 0.502, 0.7501]}, {"w": "an", "b": [0.5072, 0.7287, 0.5277, 0.7501]}, {"w": "Adagrad", "b": [0.533, 0.7319, 0.6022, 0.7469]}, {"w": "optimizer,", "b": [0.6074, 0.7287, 0.6923, 0.7501]}, {"w": "you", "b": [0.6976, 0.7287, 0.7288, 0.7501]}, {"w": "should", "b": [0.734, 0.7287, 0.7908, 0.7501]}, {"w": "not", "b": [0.796, 0.7287, 0.8244, 0.7501]}, {"w": "use", "b": [0.8296, 0.7287, 0.8571, 0.7501]}, {"w": "it", "b": [0.1429, 0.7477, 0.1548, 0.7691]}, {"w": "to", "b": [0.1612, 0.7477, 0.1782, 0.7691]}, {"w": "train", "b": [0.1846, 0.7477, 0.2248, 0.7691]}, {"w": "deep", "b": [0.2312, 0.7477, 0.2708, 0.7691]}, {"w": "neural", "b": [0.2772, 0.7477, 0.3306, 0.7691]}, {"w": "networks", "b": [0.337, 0.7477, 0.4142, 0.7691]}, {"w": "(it", "b": [0.4206, 0.7477, 0.4398, 0.7691]}, {"w": "may", "b": [0.4462, 0.7477, 0.4816, 0.7691]}, {"w": "be", "b": [0.4879, 0.7477, 0.5074, 0.7691]}, {"w": "efficient", "b": [0.5138, 0.7477, 0.5811, 0.7691]}, {"w": "for", "b": [0.5875, 0.7477, 0.6121, 0.7691]}, {"w": "simpler", "b": [0.6184, 0.7477, 0.6811, 0.7691]}, {"w": "tasks", "b": [0.6875, 0.7477, 0.7286, 0.7691]}, {"w": "such", "b": [0.735, 0.7477, 0.7737, 0.7691]}, {"w": "as", "b": [0.7801, 0.7477, 0.7968, 0.7691]}, {"w": "Linear", "b": [0.8032, 0.7477, 0.8572, 0.7691]}, {"w": "Regression,", "b": [0.1429, 0.7668, 0.2386, 0.7882]}, {"w": "though).", "b": [0.2455, 0.7668, 0.3175, 0.7882]}, {"w": "However,", "b": [0.3244, 0.7668, 0.4032, 0.7882]}, {"w": "understanding", "b": [0.4101, 0.7668, 0.5324, 0.7882]}, {"w": "Adagrad", "b": [0.5393, 0.7668, 0.6109, 0.7882]}, {"w": "is", "b": [0.6177, 0.7668, 0.631, 0.7882]}, {"w": "helpful", "b": [0.6378, 0.7668, 0.6965, 0.7882]}, {"w": "to", "b": [0.7034, 0.7668, 0.7203, 0.7882]}, {"w": "grasp", "b": [0.7272, 0.7668, 0.7724, 0.7882]}, {"w": "the", "b": [0.7793, 0.7668, 0.8056, 0.7882]}, {"w": "other", "b": [0.8125, 0.7668, 0.8571, 0.7882]}, {"w": "adaptive", "b": [0.1429, 0.7858, 0.2131, 0.8072]}, {"w": "learning", "b": [0.2178, 0.7858, 0.287, 0.8072]}, {"w": "rate", "b": [0.2917, 0.7858, 0.3234, 0.8072]}, {"w": "optimizers.", "b": [0.3281, 0.7858, 0.422, 0.8072]}]}, {"id": "b_5", "type": "paragraph", "text": "348 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "348", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2745, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 375, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "15 This algorithm was created by Geoffrey Hinton and Tijmen Tieleman in 2012, and presented by Geoffrey Hinton in his Coursera class on neural networks (slides: https://homl.info/57; video: https://homl.info/58). Amusingly, since the authors did not write a paper to describe it, researchers often cite “slide 29 in lecture 6” in their papers.", "words": [{"w": "15", "b": [0.1385, 0.7766, 0.1518, 0.7909]}, {"w": "This", "b": [0.1587, 0.7751, 0.1871, 0.7915]}, {"w": "algorithm", "b": [0.1907, 0.7751, 0.2537, 0.7915]}, {"w": "was", "b": [0.2573, 0.7751, 0.2809, 0.7915]}, {"w": "created", "b": [0.2845, 0.7751, 0.3305, 0.7915]}, {"w": "by", "b": [0.3341, 0.7751, 0.3495, 0.7915]}, {"w": "Geoffrey", "b": [0.3531, 0.7751, 0.4086, 0.7915]}, {"w": "Hinton", "b": [0.4122, 0.7751, 0.4586, 0.7915]}, {"w": "and", "b": [0.4622, 0.7751, 0.4862, 0.7915]}, {"w": "Tijmen", "b": [0.4898, 0.7751, 0.5357, 0.7915]}, {"w": "Tieleman", "b": [0.5393, 0.7751, 0.5988, 0.7915]}, {"w": "in", "b": [0.6024, 0.7751, 0.6154, 0.7915]}, {"w": "2012,", "b": [0.619, 0.7751, 0.6531, 0.7915]}, {"w": "and", "b": [0.6567, 0.7751, 0.6807, 0.7915]}, {"w": "presented", "b": [0.6843, 0.7751, 0.7462, 0.7915]}, {"w": "by", "b": [0.7498, 0.7751, 0.7651, 0.7915]}, {"w": "Geoffrey", "b": [0.7687, 0.7751, 0.8243, 0.7915]}, {"w": "Hinton", "b": [0.1587, 0.7903, 0.2051, 0.8066]}, {"w": "in", "b": [0.2087, 0.7903, 0.2217, 0.8066]}, {"w": "his", "b": [0.2253, 0.7903, 0.2438, 0.8066]}, {"w": "Coursera", "b": [0.2474, 0.7903, 0.3058, 0.8066]}, {"w": "class", "b": [0.3094, 0.7903, 0.3388, 0.8066]}, {"w": "on", "b": [0.3424, 0.7903, 0.3592, 0.8066]}, {"w": "neural", "b": [0.3628, 0.7903, 0.4035, 0.8066]}, {"w": "networks", "b": [0.4071, 0.7903, 0.4659, 0.8066]}, {"w": "(slides:", "b": [0.4695, 0.7903, 0.5137, 0.8066]}, {"w": "https://homl.info/57;", "b": [0.5173, 0.7901, 0.645, 0.8066]}, {"w": "video:", "b": [0.6486, 0.7903, 0.687, 0.8066]}, {"w": "https://homl.info/58).", "b": [0.6906, 0.7901, 0.8237, 0.8066]}, {"w": "Amusingly,", "b": [0.1587, 0.8054, 0.2308, 0.8217]}, {"w": "since", "b": [0.2344, 0.8054, 0.2666, 0.8217]}, {"w": "the", "b": [0.2702, 0.8054, 0.2903, 0.8217]}, {"w": "authors", "b": [0.2939, 0.8054, 0.3421, 0.8217]}, {"w": "did", "b": [0.3457, 0.8054, 0.3667, 0.8217]}, {"w": "not", "b": [0.3703, 0.8054, 0.3919, 0.8217]}, {"w": "write", "b": [0.3955, 0.8054, 0.4281, 0.8217]}, {"w": "a", "b": [0.4317, 0.8054, 0.4387, 0.8217]}, {"w": "paper", "b": [0.4423, 0.8054, 0.4783, 0.8217]}, {"w": "to", "b": [0.4819, 0.8054, 0.4948, 0.8217]}, {"w": "describe", "b": [0.4984, 0.8054, 0.551, 0.8217]}, {"w": "it,", "b": [0.5546, 0.8054, 0.5673, 0.8217]}, {"w": "researchers", "b": [0.5709, 0.8054, 0.6427, 0.8217]}, {"w": "often", "b": [0.6463, 0.8054, 0.6793, 0.8217]}, {"w": "cite", "b": [0.6829, 0.8054, 0.7055, 0.8217]}, {"w": "“slide", "b": [0.7091, 0.8054, 0.7437, 0.8217]}, {"w": "29", "b": [0.7473, 0.8054, 0.7625, 0.8217]}, {"w": "in", "b": [0.7661, 0.8054, 0.7791, 0.8217]}, {"w": "lecture", "b": [0.7827, 0.8054, 0.8261, 0.8217]}, {"w": "6”", "b": [0.8297, 0.8054, 0.8437, 0.8217]}, {"w": "in", "b": [0.1587, 0.8205, 0.1717, 0.8368]}, {"w": "their", "b": [0.1753, 0.8205, 0.2055, 0.8368]}, {"w": "papers.", "b": [0.2091, 0.8205, 0.2545, 0.8368]}]}, {"id": "b_1", "type": "paragraph", "text": "16 “Adam: A Method for Stochastic Optimization,” D. Kingma, J. Ba (2015).", "words": [{"w": "16", "b": [0.1385, 0.8416, 0.1518, 0.8559]}, {"w": "“Adam:", "b": [0.1587, 0.8401, 0.2052, 0.8565]}, {"w": "A", "b": [0.2088, 0.8401, 0.2198, 0.8565]}, {"w": "Method", "b": [0.2234, 0.8401, 0.2736, 0.8565]}, {"w": "for", "b": [0.2772, 0.8401, 0.2959, 0.8565]}, {"w": "Stochastic", "b": [0.2995, 0.8401, 0.3638, 0.8565]}, {"w": "Optimization,”", "b": [0.3674, 0.8401, 0.4609, 0.8565]}, {"w": "D.", "b": [0.4645, 0.8401, 0.4792, 0.8565]}, {"w": "Kingma,", "b": [0.4828, 0.8401, 0.5374, 0.8565]}, {"w": "J.", "b": [0.541, 0.8401, 0.5492, 0.8565]}, {"w": "Ba", "b": [0.5528, 0.8401, 0.5691, 0.8565]}, {"w": "(2015).", "b": [0.5727, 0.8401, 0.6178, 0.8565]}]}, {"id": "b_2", "type": "paragraph", "text": "17 These are estimations of the mean and (uncentered) variance of the gradients. The mean is often called the first moment, while the variance is often called the second moment, hence the name of the algorithm.", "words": [{"w": "17", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "These", "b": [0.1587, 0.8598, 0.1963, 0.8761]}, {"w": "are", "b": [0.1999, 0.8598, 0.2195, 0.8761]}, {"w": "estimations", "b": [0.2231, 0.8598, 0.2962, 0.8761]}, {"w": "of", "b": [0.2998, 0.8598, 0.3126, 0.8761]}, {"w": "the", "b": [0.3162, 0.8598, 0.3362, 0.8761]}, {"w": "mean", "b": [0.3398, 0.8598, 0.3752, 0.8761]}, {"w": "and", "b": [0.3788, 0.8598, 0.4029, 0.8761]}, {"w": "(uncentered)", "b": [0.4065, 0.8598, 0.489, 0.8761]}, {"w": "variance", "b": [0.4926, 0.8598, 0.5462, 0.8761]}, {"w": "of", "b": [0.5498, 0.8598, 0.5626, 0.8761]}, {"w": "the", "b": [0.5662, 0.8598, 0.5862, 0.8761]}, {"w": "gradients.", "b": [0.5898, 0.8598, 0.6522, 0.8761]}, {"w": "The", "b": [0.6558, 0.8598, 0.6808, 0.8761]}, {"w": "mean", "b": [0.6844, 0.8598, 0.7198, 0.8761]}, {"w": "is", "b": [0.7234, 0.8598, 0.7335, 0.8761]}, {"w": "often", "b": [0.7371, 0.8598, 0.7701, 0.8761]}, {"w": "called", "b": [0.7737, 0.8598, 0.8106, 0.8761]}, {"w": "the", "b": [0.8142, 0.8598, 0.8343, 0.8761]}, {"w": "first", "b": [0.1587, 0.8748, 0.1832, 0.8912]}, {"w": "moment,", "b": [0.1868, 0.8748, 0.2418, 0.8912]}, {"w": "while", "b": [0.2454, 0.8749, 0.2798, 0.8912]}, {"w": "the", "b": [0.2834, 0.8749, 0.3035, 0.8912]}, {"w": "variance", "b": [0.3071, 0.8749, 0.3606, 0.8912]}, {"w": "is", "b": [0.3642, 0.8749, 0.3743, 0.8912]}, {"w": "often", "b": [0.3779, 0.8749, 0.411, 0.8912]}, {"w": "called", "b": [0.4146, 0.8749, 0.4514, 0.8912]}, {"w": "the", "b": [0.455, 0.8749, 0.4751, 0.8912]}, {"w": "second", "b": [0.4787, 0.8748, 0.52, 0.8912]}, {"w": "moment,", "b": [0.5236, 0.8748, 0.5786, 0.8912]}, {"w": "hence", "b": [0.5822, 0.8749, 0.6196, 0.8912]}, {"w": "the", "b": [0.6232, 0.8749, 0.6433, 0.8912]}, {"w": "name", "b": [0.6469, 0.8749, 0.6823, 0.8912]}, {"w": "of", "b": [0.6859, 0.8749, 0.6987, 0.8912]}, {"w": "the", "b": [0.7023, 0.8749, 0.7223, 0.8912]}, {"w": "algorithm.", "b": [0.7259, 0.8749, 0.7925, 0.8912]}]}, {"id": "b_3", "type": "paragraph", "text": "RMSProp", "words": [{"w": "RMSProp", "b": [0.1429, 0.0763, 0.2361, 0.1049]}]}, {"id": "b_4", "type": "paragraph", "text": "Although AdaGrad slows down a bit too fast and ends up never converging to the global optimum, the RMSProp algorithm15 fixes this by accumulating only the gradi‐ ents from the most recent iterations (as opposed to all the gradients since the begin‐ ning of training). It does so by using exponential decay in the first step (see Equation 11-7).", "words": [{"w": "Although", "b": [0.1429, 0.1108, 0.2226, 0.1322]}, {"w": "AdaGrad", "b": [0.2298, 0.1108, 0.3066, 0.1322]}, {"w": "slows", "b": [0.3138, 0.1108, 0.3593, 0.1322]}, {"w": "down", "b": [0.3665, 0.1108, 0.4138, 0.1322]}, {"w": "a", "b": [0.421, 0.1108, 0.4301, 0.1322]}, {"w": "bit", "b": [0.4374, 0.1108, 0.4599, 0.1322]}, {"w": "too", "b": [0.4671, 0.1108, 0.4947, 0.1322]}, {"w": "fast", "b": [0.502, 0.1108, 0.5313, 0.1322]}, {"w": "and", "b": [0.5385, 0.1108, 0.57, 0.1322]}, {"w": "ends", "b": [0.5773, 0.1108, 0.6162, 0.1322]}, {"w": "up", "b": [0.6234, 0.1108, 0.6454, 0.1322]}, {"w": "never", "b": [0.6526, 0.1108, 0.6991, 0.1322]}, {"w": "converging", "b": [0.7063, 0.1108, 0.7994, 0.1322]}, {"w": "to", "b": [0.8066, 0.1108, 0.8236, 0.1322]}, {"w": "the", "b": [0.8308, 0.1108, 0.8571, 0.1322]}, {"w": "global", "b": [0.1429, 0.1298, 0.1935, 0.1512]}, {"w": "optimum,", "b": [0.1995, 0.1298, 0.2825, 0.1512]}, {"w": "the", "b": [0.2885, 0.1298, 0.3149, 0.1512]}, {"w": "RMSProp", "b": [0.3209, 0.1296, 0.3996, 0.1512]}, {"w": "algorithm15", "b": [0.4056, 0.1298, 0.4997, 0.1512]}, {"w": "fixes", "b": [0.5057, 0.1298, 0.5438, 0.1512]}, {"w": "this", "b": [0.5498, 0.1298, 0.5805, 0.1512]}, {"w": "by", "b": [0.5865, 0.1298, 0.6066, 0.1512]}, {"w": "accumulating", "b": [0.6126, 0.1298, 0.7253, 0.1512]}, {"w": "only", "b": [0.7313, 0.1298, 0.7682, 0.1512]}, {"w": "the", "b": [0.7742, 0.1298, 0.8005, 0.1512]}, {"w": "gradi‐", "b": [0.8065, 0.1298, 0.8571, 0.1512]}, {"w": "ents", "b": [0.1428, 0.1489, 0.1767, 0.1703]}, {"w": "from", "b": [0.1827, 0.1489, 0.2242, 0.1703]}, {"w": "the", "b": [0.2302, 0.1489, 0.2565, 0.1703]}, {"w": "most", "b": [0.2625, 0.1489, 0.3042, 0.1703]}, {"w": "recent", "b": [0.3102, 0.1489, 0.3618, 0.1703]}, {"w": "iterations", "b": [0.3677, 0.1489, 0.4466, 0.1703]}, {"w": "(as", "b": [0.4526, 0.1489, 0.4766, 0.1703]}, {"w": "opposed", "b": [0.4825, 0.1489, 0.5531, 0.1703]}, {"w": "to", "b": [0.5591, 0.1489, 0.5761, 0.1703]}, {"w": "all", "b": [0.582, 0.1489, 0.6017, 0.1703]}, {"w": "the", "b": [0.6077, 0.1489, 0.634, 0.1703]}, {"w": "gradients", "b": [0.64, 0.1489, 0.717, 0.1703]}, {"w": "since", "b": [0.723, 0.1489, 0.7653, 0.1703]}, {"w": "the", "b": [0.7713, 0.1489, 0.7976, 0.1703]}, {"w": "begin‐", "b": [0.8035, 0.1489, 0.8571, 0.1703]}, {"w": "ning", "b": [0.1429, 0.1679, 0.181, 0.1893]}, {"w": "of", "b": [0.1864, 0.1679, 0.2032, 0.1893]}, {"w": "training).", "b": [0.2087, 0.1679, 0.2876, 0.1893]}, {"w": "It", "b": [0.293, 0.1679, 0.3056, 0.1893]}, {"w": "does", "b": [0.3111, 0.1679, 0.3492, 0.1893]}, {"w": "so", "b": [0.3547, 0.1679, 0.3729, 0.1893]}, {"w": "by", "b": [0.3784, 0.1679, 0.3985, 0.1893]}, {"w": "using", "b": [0.404, 0.1679, 0.4494, 0.1893]}, {"w": "exponential", "b": [0.4548, 0.1679, 0.5527, 0.1893]}, {"w": "decay", "b": [0.5581, 0.1679, 0.6051, 0.1893]}, {"w": "in", "b": [0.6106, 0.1679, 0.6275, 0.1893]}, {"w": "the", "b": [0.633, 0.1679, 0.6593, 0.1893]}, {"w": "first", "b": [0.6648, 0.1679, 0.6982, 0.1893]}, {"w": "step", "b": [0.7037, 0.1679, 0.7375, 0.1893]}, {"w": "(see", "b": [0.7429, 0.1679, 0.7755, 0.1893]}, {"w": "Equation", "b": [0.7809, 0.1679, 0.8571, 0.1893]}, {"w": "11-7).", "b": [0.1429, 0.187, 0.1922, 0.2084]}]}, {"id": "b_5", "type": "equation", "text": "Equation 11-7. RMSProp algorithm", "words": [{"w": "Equation", "b": [0.1726, 0.2265, 0.2473, 0.2481]}, {"w": "11-7.", "b": [0.2521, 0.2265, 0.2937, 0.2481]}, {"w": "RMSProp", "b": [0.2985, 0.2265, 0.3773, 0.2481]}, {"w": "algorithm", "b": [0.382, 0.2265, 0.4614, 0.2481]}]}, {"id": "b_6", "type": "equation", "text": "1 . s βs + 1 −β ∇θJ θ ⊗∇θJ θ", "words": [{"w": "1", "b": [0.1726, 0.2553, 0.1821, 0.2757]}, {"w": ".", "b": [0.1854, 0.2553, 0.19, 0.2757]}, {"w": "s", "b": [0.2218, 0.2548, 0.2294, 0.2757]}, {"w": "βs", "b": [0.2582, 0.2548, 0.2759, 0.2757]}, {"w": "+", "b": [0.2804, 0.2553, 0.2919, 0.2757]}, {"w": "1", "b": [0.3031, 0.2553, 0.3127, 0.2757]}, {"w": "−β", "b": [0.3171, 0.2551, 0.3435, 0.2757]}, {"w": "∇θJ", "b": [0.3504, 0.2551, 0.3817, 0.2791]}, {"w": "θ", "b": [0.3896, 0.2548, 0.3997, 0.2757]}, {"w": "⊗∇θJ", "b": [0.411, 0.2551, 0.4622, 0.2791]}, {"w": "θ", "b": [0.47, 0.2548, 0.4801, 0.2757]}]}, {"id": "b_7", "type": "equation", "text": "2 . θ θ −η ∇θJ θ ⊘ s + �", "words": [{"w": "2", "b": [0.1726, 0.2829, 0.1821, 0.3033]}, {"w": ".", "b": [0.1855, 0.2829, 0.19, 0.3033]}, {"w": "θ", "b": [0.2218, 0.2824, 0.2319, 0.3033]}, {"w": "θ", "b": [0.2603, 0.2824, 0.2704, 0.3033]}, {"w": "−η", "b": [0.2748, 0.2827, 0.3009, 0.3033]}, {"w": "∇θJ", "b": [0.3042, 0.2827, 0.3355, 0.3067]}, {"w": "θ", "b": [0.3434, 0.2824, 0.3535, 0.3033]}, {"w": "⊘", "b": [0.3648, 0.286, 0.3802, 0.3011]}, {"w": "s", "b": [0.3967, 0.2824, 0.4043, 0.3033]}, {"w": "+", "b": [0.4087, 0.2829, 0.4202, 0.3033]}, {"w": "�", "b": [0.4246, 0.286, 0.4336, 0.3011]}]}, {"id": "b_8", "type": "paragraph", "text": "The decay rate β is typically set to 0.9. Yes, it is once again a new hyperparameter, but this default value often works well, so you may not need to tune it at all.", "words": [{"w": "The", "b": [0.1429, 0.3258, 0.1757, 0.3472]}, {"w": "decay", "b": [0.1809, 0.3258, 0.2279, 0.3472]}, {"w": "rate", "b": [0.2331, 0.3258, 0.2648, 0.3472]}, {"w": "β", "b": [0.27, 0.3256, 0.2807, 0.3472]}, {"w": "is", "b": [0.2859, 0.3258, 0.2991, 0.3472]}, {"w": "typically", "b": [0.3043, 0.3258, 0.3748, 0.3472]}, {"w": "set", "b": [0.38, 0.3258, 0.4029, 0.3472]}, {"w": "to", "b": [0.4081, 0.3258, 0.4251, 0.3472]}, {"w": "0.9.", "b": [0.4303, 0.3258, 0.4598, 0.3472]}, {"w": "Yes,", "b": [0.465, 0.3258, 0.4969, 0.3472]}, {"w": "it", "b": [0.5022, 0.3258, 0.5141, 0.3472]}, {"w": "is", "b": [0.5193, 0.3258, 0.5325, 0.3472]}, {"w": "once", "b": [0.5378, 0.3258, 0.5774, 0.3472]}, {"w": "again", "b": [0.5827, 0.3258, 0.6277, 0.3472]}, {"w": "a", "b": [0.6329, 0.3258, 0.642, 0.3472]}, {"w": "new", "b": [0.6473, 0.3258, 0.6818, 0.3472]}, {"w": "hyperparameter,", "b": [0.687, 0.3258, 0.8239, 0.3472]}, {"w": "but", "b": [0.8292, 0.3258, 0.8572, 0.3472]}, {"w": "this", "b": [0.1429, 0.3448, 0.1736, 0.3662]}, {"w": "default", "b": [0.1783, 0.3448, 0.2358, 0.3662]}, {"w": "value", "b": [0.2405, 0.3448, 0.2845, 0.3662]}, {"w": "often", "b": [0.2892, 0.3448, 0.3326, 0.3662]}, {"w": "works", "b": [0.3373, 0.3448, 0.3879, 0.3662]}, {"w": "well,", "b": [0.3927, 0.3448, 0.4311, 0.3662]}, {"w": "so", "b": [0.4358, 0.3448, 0.4541, 0.3662]}, {"w": "you", "b": [0.4588, 0.3448, 0.49, 0.3662]}, {"w": "may", "b": [0.4948, 0.3448, 0.5302, 0.3662]}, {"w": "not", "b": [0.5349, 0.3448, 0.5633, 0.3662]}, {"w": "need", "b": [0.568, 0.3448, 0.6081, 0.3662]}, {"w": "to", "b": [0.6128, 0.3448, 0.6298, 0.3662]}, {"w": "tune", "b": [0.6345, 0.3448, 0.6722, 0.3662]}, {"w": "it", "b": [0.6769, 0.3448, 0.6889, 0.3662]}, {"w": "at", "b": [0.6936, 0.3448, 0.7087, 0.3662]}, {"w": "all.", "b": [0.7134, 0.3448, 0.7379, 0.3662]}]}, {"id": "b_9", "type": "paragraph", "text": "As you might expect, Keras has an RMSProp optimizer:", "words": [{"w": "As", "b": [0.1429, 0.3738, 0.1649, 0.3953]}, {"w": "you", "b": [0.1696, 0.3738, 0.2009, 0.3953]}, {"w": "might", "b": [0.2056, 0.3738, 0.2551, 0.3953]}, {"w": "expect,", "b": [0.2598, 0.3738, 0.3182, 0.3953]}, {"w": "Keras", "b": [0.3229, 0.3738, 0.3698, 0.3953]}, {"w": "has", "b": [0.3745, 0.3738, 0.4025, 0.3953]}, {"w": "an", "b": [0.4072, 0.3738, 0.4277, 0.3953]}, {"w": "RMSProp", "b": [0.4325, 0.377, 0.5017, 0.3921]}, {"w": "optimizer:", "b": [0.5065, 0.3738, 0.5932, 0.3953]}]}, {"id": "b_10", "type": "equation", "text": "optimizer = keras.optimizers.RMSprop(lr=0.001, rho=0.9)", "words": [{"w": "optimizer", "b": [0.1766, 0.4058, 0.2525, 0.4187]}, {"w": "=", "b": [0.2609, 0.4058, 0.2693, 0.4187]}, {"w": "keras.optimizers.RMSprop(lr=0.001,", "b": [0.2778, 0.4058, 0.5645, 0.4187]}, {"w": "rho=0.9)", "b": [0.5729, 0.4058, 0.6404, 0.4187]}]}, {"id": "b_11", "type": "paragraph", "text": "Except on very simple problems, this optimizer almost always performs much better than AdaGrad. In fact, it was the preferred optimization algorithm of many research‐ ers until Adam optimization came around.", "words": [{"w": "Except", "b": [0.1429, 0.4264, 0.1995, 0.4479]}, {"w": "on", "b": [0.2054, 0.4264, 0.2274, 0.4479]}, {"w": "very", "b": [0.2333, 0.4264, 0.2697, 0.4479]}, {"w": "simple", "b": [0.2756, 0.4264, 0.3305, 0.4479]}, {"w": "problems,", "b": [0.3364, 0.4264, 0.4198, 0.4479]}, {"w": "this", "b": [0.4257, 0.4264, 0.4564, 0.4479]}, {"w": "optimizer", "b": [0.4623, 0.4264, 0.5438, 0.4479]}, {"w": "almost", "b": [0.5497, 0.4264, 0.6058, 0.4479]}, {"w": "always", "b": [0.6117, 0.4264, 0.6663, 0.4479]}, {"w": "performs", "b": [0.6722, 0.4264, 0.749, 0.4479]}, {"w": "much", "b": [0.7549, 0.4264, 0.8025, 0.4479]}, {"w": "better", "b": [0.8084, 0.4264, 0.8571, 0.4479]}, {"w": "than", "b": [0.1429, 0.4455, 0.1809, 0.4669]}, {"w": "AdaGrad.", "b": [0.1861, 0.4455, 0.2676, 0.4669]}, {"w": "In", "b": [0.2729, 0.4455, 0.2914, 0.4669]}, {"w": "fact,", "b": [0.2966, 0.4455, 0.3318, 0.4669]}, {"w": "it", "b": [0.3371, 0.4455, 0.349, 0.4669]}, {"w": "was", "b": [0.3542, 0.4455, 0.3853, 0.4669]}, {"w": "the", "b": [0.3905, 0.4455, 0.4169, 0.4669]}, {"w": "preferred", "b": [0.4221, 0.4455, 0.4999, 0.4669]}, {"w": "optimization", "b": [0.5052, 0.4455, 0.6128, 0.4669]}, {"w": "algorithm", "b": [0.618, 0.4455, 0.7006, 0.4669]}, {"w": "of", "b": [0.7059, 0.4455, 0.7227, 0.4669]}, {"w": "many", "b": [0.7279, 0.4455, 0.7746, 0.4669]}, {"w": "research‐", "b": [0.7798, 0.4455, 0.8571, 0.4669]}, {"w": "ers", "b": [0.1429, 0.4645, 0.1671, 0.486]}, {"w": "until", "b": [0.1718, 0.4645, 0.2111, 0.486]}, {"w": "Adam", "b": [0.2158, 0.4645, 0.2669, 0.486]}, {"w": "optimization", "b": [0.2716, 0.4645, 0.3792, 0.486]}, {"w": "came", "b": [0.3839, 0.4645, 0.4278, 0.486]}, {"w": "around.", "b": [0.4325, 0.4645, 0.4982, 0.486]}]}, {"id": "b_12", "type": "paragraph", "text": "Adam and Nadam Optimization", "words": [{"w": "Adam", "b": [0.1429, 0.4987, 0.203, 0.5273]}, {"w": "and", "b": [0.2079, 0.4987, 0.2472, 0.5273]}, {"w": "Nadam", "b": [0.2521, 0.4987, 0.3261, 0.5273]}, {"w": "Optimization", "b": [0.331, 0.4987, 0.4657, 0.5273]}]}, {"id": "b_13", "type": "paragraph", "text": "Adam,16 which stands for adaptive moment estimation, combines the ideas of Momen‐ tum optimization and RMSProp: just like Momentum optimization it keeps track of an exponentially decaying average of past gradients, and just like RMSProp it keeps track of an exponentially decaying average of past squared gradients (see Equation 11-8).17", "words": [{"w": "Adam,16", "b": [0.1429, 0.533, 0.2096, 0.5546]}, {"w": "which", "b": [0.2144, 0.5332, 0.2653, 0.5546]}, {"w": "stands", "b": [0.2701, 0.5332, 0.3233, 0.5546]}, {"w": "for", "b": [0.3281, 0.5332, 0.3526, 0.5546]}, {"w": "adaptive", "b": [0.3574, 0.533, 0.427, 0.5546]}, {"w": "moment", "b": [0.4318, 0.533, 0.4992, 0.5546]}, {"w": "estimation,", "b": [0.504, 0.533, 0.5939, 0.5546]}, {"w": "combines", "b": [0.5987, 0.5332, 0.6793, 0.5546]}, {"w": "the", "b": [0.684, 0.5332, 0.7103, 0.5546]}, {"w": "ideas", "b": [0.7151, 0.5332, 0.7573, 0.5546]}, {"w": "of", "b": [0.762, 0.5332, 0.7788, 0.5546]}, {"w": "Momen‐", "b": [0.7835, 0.5332, 0.8569, 0.5546]}, {"w": "tum", "b": [0.1429, 0.5522, 0.1773, 0.5736]}, {"w": "optimization", "b": [0.1835, 0.5522, 0.2911, 0.5736]}, {"w": "and", "b": [0.2973, 0.5522, 0.3288, 0.5736]}, {"w": "RMSProp:", "b": [0.335, 0.5522, 0.4221, 0.5736]}, {"w": "just", "b": [0.4282, 0.5522, 0.4586, 0.5736]}, {"w": "like", "b": [0.4648, 0.5522, 0.4948, 0.5736]}, {"w": "Momentum", "b": [0.501, 0.5522, 0.601, 0.5736]}, {"w": "optimization", "b": [0.6072, 0.5522, 0.7148, 0.5736]}, {"w": "it", "b": [0.721, 0.5522, 0.7329, 0.5736]}, {"w": "keeps", "b": [0.7391, 0.5522, 0.7857, 0.5736]}, {"w": "track", "b": [0.7918, 0.5522, 0.8342, 0.5736]}, {"w": "of", "b": [0.8404, 0.5522, 0.8572, 0.5736]}, {"w": "an", "b": [0.1429, 0.5713, 0.1634, 0.5927]}, {"w": "exponentially", "b": [0.17, 0.5713, 0.2827, 0.5927]}, {"w": "decaying", "b": [0.2892, 0.5713, 0.363, 0.5927]}, {"w": "average", "b": [0.3696, 0.5713, 0.4323, 0.5927]}, {"w": "of", "b": [0.4389, 0.5713, 0.4557, 0.5927]}, {"w": "past", "b": [0.4623, 0.5713, 0.4963, 0.5927]}, {"w": "gradients,", "b": [0.5029, 0.5713, 0.5847, 0.5927]}, {"w": "and", "b": [0.5913, 0.5713, 0.6229, 0.5927]}, {"w": "just", "b": [0.6294, 0.5713, 0.6598, 0.5927]}, {"w": "like", "b": [0.6664, 0.5713, 0.6965, 0.5927]}, {"w": "RMSProp", "b": [0.7031, 0.5713, 0.7854, 0.5927]}, {"w": "it", "b": [0.792, 0.5713, 0.804, 0.5927]}, {"w": "keeps", "b": [0.8105, 0.5713, 0.8571, 0.5927]}, {"w": "track", "b": [0.1429, 0.5903, 0.1852, 0.6117]}, {"w": "of", "b": [0.1927, 0.5903, 0.2095, 0.6117]}, {"w": "an", "b": [0.217, 0.5903, 0.2376, 0.6117]}, {"w": "exponentially", "b": [0.2451, 0.5903, 0.3578, 0.6117]}, {"w": "decaying", "b": [0.3653, 0.5903, 0.439, 0.6117]}, {"w": "average", "b": [0.4465, 0.5903, 0.5093, 0.6117]}, {"w": "of", "b": [0.5168, 0.5903, 0.5336, 0.6117]}, {"w": "past", "b": [0.5411, 0.5903, 0.5751, 0.6117]}, {"w": "squared", "b": [0.5826, 0.5903, 0.6487, 0.6117]}, {"w": "gradients", "b": [0.6562, 0.5903, 0.7333, 0.6117]}, {"w": "(see", "b": [0.7408, 0.5903, 0.7734, 0.6117]}, {"w": "Equation", "b": [0.7809, 0.5903, 0.8571, 0.6117]}, {"w": "11-8).17", "b": [0.1428, 0.6094, 0.2037, 0.6308]}]}, {"id": "b_14", "type": "paragraph", "text": "Faster Optimizers | 349", "words": [{"w": "Faster", "b": [0.6934, 0.9225, 0.7296, 0.9388]}, {"w": "Optimizers", "b": [0.7325, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "349", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 376, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Equation 11-8. Adam algorithm", "words": [{"w": "Equation", "b": [0.1726, 0.0995, 0.2473, 0.1212]}, {"w": "11-8.", "b": [0.2521, 0.0995, 0.2937, 0.1212]}, {"w": "Adam", "b": [0.2985, 0.0995, 0.3491, 0.1212]}, {"w": "algorithm", "b": [0.3539, 0.0995, 0.4333, 0.1212]}]}, {"id": "b_1", "type": "paragraph", "text": "1 . m β1m −1 −β1 ∇θJ θ", "words": [{"w": "1", "b": [0.1726, 0.1288, 0.1821, 0.1491]}, {"w": ".", "b": [0.1855, 0.1288, 0.19, 0.1491]}, {"w": "m", "b": [0.2218, 0.1282, 0.2385, 0.1491]}, {"w": "β1m", "b": [0.2673, 0.1282, 0.3018, 0.1534]}, {"w": "−1", "b": [0.3062, 0.1288, 0.3385, 0.1491]}, {"w": "−β1", "b": [0.343, 0.1286, 0.377, 0.1534]}, {"w": "∇θJ", "b": [0.3839, 0.1286, 0.4152, 0.1526]}, {"w": "θ", "b": [0.4231, 0.1282, 0.4332, 0.1491]}]}, {"id": "b_2", "type": "equation", "text": "2 . s β2s + 1 −β2 ∇θJ θ ⊗∇θJ θ", "words": [{"w": "2", "b": [0.1726, 0.1563, 0.1821, 0.1767]}, {"w": ".", "b": [0.1854, 0.1563, 0.19, 0.1767]}, {"w": "s", "b": [0.2218, 0.1557, 0.2294, 0.1767]}, {"w": "β2s", "b": [0.2582, 0.1557, 0.2836, 0.1809]}, {"w": "+", "b": [0.288, 0.1563, 0.2995, 0.1767]}, {"w": "1", "b": [0.3108, 0.1563, 0.3203, 0.1767]}, {"w": "−β2", "b": [0.3247, 0.1561, 0.3587, 0.1809]}, {"w": "∇θJ", "b": [0.3656, 0.1561, 0.397, 0.1801]}, {"w": "θ", "b": [0.4048, 0.1557, 0.4149, 0.1767]}, {"w": "⊗∇θJ", "b": [0.4262, 0.1561, 0.4774, 0.1801]}, {"w": "θ", "b": [0.4853, 0.1557, 0.4954, 0.1767]}]}, {"id": "b_3", "type": "paragraph", "text": "3 . m m 1 −β1 t", "words": [{"w": "3", "b": [0.1726, 0.1914, 0.1821, 0.2117]}, {"w": ".", "b": [0.1854, 0.1914, 0.19, 0.2117]}, {"w": "m", "b": [0.2218, 0.1908, 0.2385, 0.2117]}, {"w": "m", "b": [0.2874, 0.182, 0.3042, 0.2029]}, {"w": "1", "b": [0.2692, 0.2047, 0.2787, 0.2251]}, {"w": "−β1", "b": [0.2831, 0.2045, 0.3172, 0.2294]}, {"w": "t", "b": [0.3172, 0.2008, 0.322, 0.2173]}]}, {"id": "b_4", "type": "paragraph", "text": "4 . s s 1 −β2 t", "words": [{"w": "4", "b": [0.1726, 0.2398, 0.1821, 0.2602]}, {"w": ".", "b": [0.1854, 0.2398, 0.19, 0.2602]}, {"w": "s", "b": [0.2236, 0.2393, 0.2312, 0.2602]}, {"w": "s", "b": [0.2865, 0.2305, 0.2941, 0.2514]}, {"w": "1", "b": [0.2637, 0.2532, 0.2732, 0.2735]}, {"w": "−β2", "b": [0.2776, 0.253, 0.3117, 0.2778]}, {"w": "t", "b": [0.3117, 0.2493, 0.3165, 0.2657]}]}, {"id": "b_5", "type": "equation", "text": "5 . θ θ + η m ⊘ s + �", "words": [{"w": "5", "b": [0.1726, 0.2816, 0.1821, 0.302]}, {"w": ".", "b": [0.1855, 0.2816, 0.19, 0.302]}, {"w": "θ", "b": [0.2218, 0.2811, 0.2319, 0.302]}, {"w": "θ", "b": [0.2603, 0.2811, 0.2704, 0.302]}, {"w": "+", "b": [0.2748, 0.2816, 0.2863, 0.302]}, {"w": "η", "b": [0.2908, 0.2814, 0.3009, 0.302]}, {"w": "m", "b": [0.3042, 0.2811, 0.3209, 0.302]}, {"w": "⊘", "b": [0.3253, 0.2847, 0.3407, 0.2998]}, {"w": "s", "b": [0.359, 0.2811, 0.3666, 0.302]}, {"w": "+", "b": [0.3729, 0.2816, 0.3844, 0.302]}, {"w": "�", "b": [0.3888, 0.2847, 0.3978, 0.2998]}]}, {"id": "b_6", "type": "paragraph", "text": "• t represents the iteration number (starting at 1).", "words": [{"w": "•", "b": [0.16, 0.3268, 0.1682, 0.3482]}, {"w": "t", "b": [0.1786, 0.3266, 0.185, 0.3482]}, {"w": "represents", "b": [0.1897, 0.3268, 0.2753, 0.3482]}, {"w": "the", "b": [0.28, 0.3268, 0.3063, 0.3482]}, {"w": "iteration", "b": [0.3111, 0.3268, 0.3823, 0.3482]}, {"w": "number", "b": [0.387, 0.3268, 0.4533, 0.3482]}, {"w": "(starting", "b": [0.458, 0.3268, 0.5292, 0.3482]}, {"w": "at", "b": [0.5339, 0.3268, 0.549, 0.3482]}, {"w": "1).", "b": [0.5538, 0.3268, 0.5757, 0.3482]}]}, {"id": "b_7", "type": "paragraph", "text": "If you just look at steps 1, 2, and 5, you will notice Adam’s close similarity to both Momentum optimization and RMSProp. The only difference is that step 1 computes an exponentially decaying average rather than an exponentially decaying sum, but these are actually equivalent except for a constant factor (the decaying average is just 1 – β1 times the decaying sum). Steps 3 and 4 are somewhat of a technical detail: since m and s are initialized at 0, they will be biased toward 0 at the beginning of training, so these two steps will help boost m and s at the beginning of training.", "words": [{"w": "If", "b": [0.1429, 0.361, 0.1561, 0.3824]}, {"w": "you", "b": [0.1632, 0.361, 0.1945, 0.3824]}, {"w": "just", "b": [0.2016, 0.361, 0.232, 0.3824]}, {"w": "look", "b": [0.2391, 0.361, 0.276, 0.3824]}, {"w": "at", "b": [0.2831, 0.361, 0.2982, 0.3824]}, {"w": "steps", "b": [0.3053, 0.361, 0.3467, 0.3824]}, {"w": "1,", "b": [0.3538, 0.361, 0.3686, 0.3824]}, {"w": "2,", "b": [0.3757, 0.361, 0.3904, 0.3824]}, {"w": "and", "b": [0.3975, 0.361, 0.4291, 0.3824]}, {"w": "5,", "b": [0.4362, 0.361, 0.4509, 0.3824]}, {"w": "you", "b": [0.458, 0.361, 0.4893, 0.3824]}, {"w": "will", "b": [0.4964, 0.361, 0.5268, 0.3824]}, {"w": "notice", "b": [0.5339, 0.361, 0.5855, 0.3824]}, {"w": "Adam’s", "b": [0.5926, 0.361, 0.6523, 0.3824]}, {"w": "close", "b": [0.6594, 0.361, 0.7006, 0.3824]}, {"w": "similarity", "b": [0.7077, 0.361, 0.7873, 0.3824]}, {"w": "to", "b": [0.7944, 0.361, 0.8113, 0.3824]}, {"w": "both", "b": [0.8185, 0.361, 0.8571, 0.3824]}, {"w": "Momentum", "b": [0.1429, 0.38, 0.2429, 0.4015]}, {"w": "optimization", "b": [0.2488, 0.38, 0.3564, 0.4015]}, {"w": "and", "b": [0.3623, 0.38, 0.3938, 0.4015]}, {"w": "RMSProp.", "b": [0.3997, 0.38, 0.4863, 0.4015]}, {"w": "The", "b": [0.4922, 0.38, 0.525, 0.4015]}, {"w": "only", "b": [0.5309, 0.38, 0.5678, 0.4015]}, {"w": "difference", "b": [0.5737, 0.38, 0.6571, 0.4015]}, {"w": "is", "b": [0.663, 0.38, 0.6762, 0.4015]}, {"w": "that", "b": [0.6821, 0.38, 0.7147, 0.4015]}, {"w": "step", "b": [0.7206, 0.38, 0.7544, 0.4015]}, {"w": "1", "b": [0.7603, 0.38, 0.7703, 0.4015]}, {"w": "computes", "b": [0.7762, 0.38, 0.8571, 0.4015]}, {"w": "an", "b": [0.1429, 0.3991, 0.1634, 0.4205]}, {"w": "exponentially", "b": [0.1715, 0.3991, 0.2841, 0.4205]}, {"w": "decaying", "b": [0.2922, 0.3991, 0.3659, 0.4205]}, {"w": "average", "b": [0.374, 0.3991, 0.4367, 0.4205]}, {"w": "rather", "b": [0.4448, 0.3991, 0.4953, 0.4205]}, {"w": "than", "b": [0.5034, 0.3991, 0.5414, 0.4205]}, {"w": "an", "b": [0.5495, 0.3991, 0.57, 0.4205]}, {"w": "exponentially", "b": [0.5781, 0.3991, 0.6907, 0.4205]}, {"w": "decaying", "b": [0.6988, 0.3991, 0.7725, 0.4205]}, {"w": "sum,", "b": [0.7806, 0.3991, 0.8211, 0.4205]}, {"w": "but", "b": [0.8292, 0.3991, 0.8572, 0.4205]}, {"w": "these", "b": [0.1429, 0.4181, 0.1857, 0.4395]}, {"w": "are", "b": [0.1914, 0.4181, 0.2171, 0.4395]}, {"w": "actually", "b": [0.2227, 0.4181, 0.2874, 0.4395]}, {"w": "equivalent", "b": [0.293, 0.4181, 0.3794, 0.4395]}, {"w": "except", "b": [0.3851, 0.4181, 0.4387, 0.4395]}, {"w": "for", "b": [0.4444, 0.4181, 0.4689, 0.4395]}, {"w": "a", "b": [0.4746, 0.4181, 0.4837, 0.4395]}, {"w": "constant", "b": [0.4894, 0.4181, 0.5607, 0.4395]}, {"w": "factor", "b": [0.5664, 0.4181, 0.6152, 0.4395]}, {"w": "(the", "b": [0.6209, 0.4181, 0.6544, 0.4395]}, {"w": "decaying", "b": [0.6601, 0.4181, 0.7338, 0.4395]}, {"w": "average", "b": [0.7395, 0.4181, 0.8022, 0.4395]}, {"w": "is", "b": [0.8079, 0.4181, 0.8211, 0.4395]}, {"w": "just", "b": [0.8268, 0.4181, 0.8571, 0.4395]}, {"w": "1", "b": [0.1429, 0.4372, 0.1529, 0.4586]}, {"w": "–", "b": [0.1576, 0.4372, 0.1684, 0.4586]}, {"w": "β1", "b": [0.1735, 0.437, 0.1901, 0.4595]}, {"w": "times", "b": [0.195, 0.4372, 0.2405, 0.4586]}, {"w": "the", "b": [0.2454, 0.4372, 0.2718, 0.4586]}, {"w": "decaying", "b": [0.2767, 0.4372, 0.3504, 0.4586]}, {"w": "sum).", "b": [0.3553, 0.4372, 0.403, 0.4586]}, {"w": "Steps", "b": [0.4079, 0.4372, 0.4516, 0.4586]}, {"w": "3", "b": [0.4565, 0.4372, 0.4665, 0.4586]}, {"w": "and", "b": [0.4714, 0.4372, 0.5029, 0.4586]}, {"w": "4", "b": [0.5078, 0.4372, 0.5178, 0.4586]}, {"w": "are", "b": [0.5228, 0.4372, 0.5485, 0.4586]}, {"w": "somewhat", "b": [0.5534, 0.4372, 0.6381, 0.4586]}, {"w": "of", "b": [0.643, 0.4372, 0.6598, 0.4586]}, {"w": "a", "b": [0.6647, 0.4372, 0.6738, 0.4586]}, {"w": "technical", "b": [0.6787, 0.4372, 0.7541, 0.4586]}, {"w": "detail:", "b": [0.759, 0.4372, 0.8099, 0.4586]}, {"w": "since", "b": [0.8148, 0.4372, 0.8571, 0.4586]}, {"w": "m", "b": [0.1429, 0.4557, 0.1604, 0.4776]}, {"w": "and", "b": [0.1661, 0.4562, 0.1977, 0.4776]}, {"w": "s", "b": [0.2033, 0.4557, 0.2113, 0.4776]}, {"w": "are", "b": [0.217, 0.4562, 0.2427, 0.4776]}, {"w": "initialized", "b": [0.2484, 0.4562, 0.3315, 0.4776]}, {"w": "at", "b": [0.3372, 0.4562, 0.3523, 0.4776]}, {"w": "0,", "b": [0.358, 0.4562, 0.3727, 0.4776]}, {"w": "they", "b": [0.3784, 0.4562, 0.4143, 0.4776]}, {"w": "will", "b": [0.42, 0.4562, 0.4504, 0.4776]}, {"w": "be", "b": [0.4561, 0.4562, 0.4755, 0.4776]}, {"w": "biased", "b": [0.4812, 0.4562, 0.534, 0.4776]}, {"w": "toward", "b": [0.5397, 0.4562, 0.5988, 0.4776]}, {"w": "0", "b": [0.6045, 0.4562, 0.6145, 0.4776]}, {"w": "at", "b": [0.6202, 0.4562, 0.6353, 0.4776]}, {"w": "the", "b": [0.641, 0.4562, 0.6673, 0.4776]}, {"w": "beginning", "b": [0.673, 0.4562, 0.7573, 0.4776]}, {"w": "of", "b": [0.763, 0.4562, 0.7798, 0.4776]}, {"w": "training,", "b": [0.7855, 0.4562, 0.8572, 0.4776]}, {"w": "so", "b": [0.1429, 0.4753, 0.1611, 0.4967]}, {"w": "these", "b": [0.1659, 0.4753, 0.2087, 0.4967]}, {"w": "two", "b": [0.2134, 0.4753, 0.2447, 0.4967]}, {"w": "steps", "b": [0.2494, 0.4753, 0.2908, 0.4967]}, {"w": "will", "b": [0.2955, 0.4753, 0.3259, 0.4967]}, {"w": "help", "b": [0.3307, 0.4753, 0.3668, 0.4967]}, {"w": "boost", "b": [0.3716, 0.4753, 0.4174, 0.4967]}, {"w": "m", "b": [0.4221, 0.4747, 0.4397, 0.4967]}, {"w": "and", "b": [0.4444, 0.4753, 0.476, 0.4967]}, {"w": "s", "b": [0.4807, 0.4747, 0.4887, 0.4967]}, {"w": "at", "b": [0.4934, 0.4753, 0.5085, 0.4967]}, {"w": "the", "b": [0.5132, 0.4753, 0.5396, 0.4967]}, {"w": "beginning", "b": [0.5443, 0.4753, 0.6286, 0.4967]}, {"w": "of", "b": [0.6333, 0.4753, 0.6501, 0.4967]}, {"w": "training.", "b": [0.6548, 0.4753, 0.7265, 0.4967]}]}, {"id": "b_8", "type": "paragraph", "text": "The momentum decay hyperparameter β1 is typically initialized to 0.9, while the scal‐ ing decay hyperparameter β2 is often initialized to 0.999. As earlier, the smoothing term ϵ is usually initialized to a tiny number such as 10–7. These are the default values for the Adam class (to be precise, epsilon defaults to None, which tells Keras to use keras.backend.epsilon(), which defaults to 10–7; you can change it using keras.backend.set_epsilon()).", "words": [{"w": "The", "b": [0.1429, 0.5034, 0.1757, 0.5248]}, {"w": "momentum", "b": [0.1809, 0.5034, 0.28, 0.5248]}, {"w": "decay", "b": [0.2851, 0.5034, 0.3321, 0.5248]}, {"w": "hyperparameter", "b": [0.3373, 0.5034, 0.4708, 0.5248]}, {"w": "β1", "b": [0.476, 0.5032, 0.4927, 0.5257]}, {"w": "is", "b": [0.4978, 0.5034, 0.5111, 0.5248]}, {"w": "typically", "b": [0.5163, 0.5034, 0.5867, 0.5248]}, {"w": "initialized", "b": [0.5919, 0.5034, 0.675, 0.5248]}, {"w": "to", "b": [0.6802, 0.5034, 0.6972, 0.5248]}, {"w": "0.9,", "b": [0.7024, 0.5034, 0.7319, 0.5248]}, {"w": "while", "b": [0.7371, 0.5034, 0.7822, 0.5248]}, {"w": "the", "b": [0.7873, 0.5034, 0.8137, 0.5248]}, {"w": "scal‐", "b": [0.8189, 0.5034, 0.8571, 0.5248]}, {"w": "ing", "b": [0.1429, 0.5224, 0.1696, 0.5439]}, {"w": "decay", "b": [0.177, 0.5224, 0.224, 0.5439]}, {"w": "hyperparameter", "b": [0.2314, 0.5224, 0.3649, 0.5439]}, {"w": "β2", "b": [0.3723, 0.5222, 0.389, 0.5447]}, {"w": "is", "b": [0.3964, 0.5224, 0.4096, 0.5439]}, {"w": "often", "b": [0.4171, 0.5224, 0.4605, 0.5439]}, {"w": "initialized", "b": [0.4679, 0.5224, 0.551, 0.5439]}, {"w": "to", "b": [0.5584, 0.5224, 0.5754, 0.5439]}, {"w": "0.999.", "b": [0.5828, 0.5224, 0.6323, 0.5439]}, {"w": "As", "b": [0.6397, 0.5224, 0.6618, 0.5439]}, {"w": "earlier,", "b": [0.6692, 0.5224, 0.7258, 0.5439]}, {"w": "the", "b": [0.7332, 0.5224, 0.7596, 0.5439]}, {"w": "smoothing", "b": [0.767, 0.5224, 0.8571, 0.5439]}, {"w": "term", "b": [0.1429, 0.5415, 0.1829, 0.5629]}, {"w": "ϵ", "b": [0.188, 0.5447, 0.2026, 0.5606]}, {"w": "is", "b": [0.2024, 0.5415, 0.2156, 0.5629]}, {"w": "usually", "b": [0.2207, 0.5415, 0.2798, 0.5629]}, {"w": "initialized", "b": [0.2849, 0.5415, 0.368, 0.5629]}, {"w": "to", "b": [0.3731, 0.5415, 0.39, 0.5629]}, {"w": "a", "b": [0.3951, 0.5415, 0.4043, 0.5629]}, {"w": "tiny", "b": [0.4094, 0.5415, 0.4418, 0.5629]}, {"w": "number", "b": [0.4469, 0.5415, 0.5132, 0.5629]}, {"w": "such", "b": [0.5183, 0.5415, 0.5569, 0.5629]}, {"w": "as", "b": [0.562, 0.5415, 0.5788, 0.5629]}, {"w": "10–7.", "b": [0.5839, 0.5415, 0.6212, 0.5629]}, {"w": "These", "b": [0.6263, 0.5415, 0.6756, 0.5629]}, {"w": "are", "b": [0.6807, 0.5415, 0.7064, 0.5629]}, {"w": "the", "b": [0.7115, 0.5415, 0.7379, 0.5629]}, {"w": "default", "b": [0.743, 0.5415, 0.8004, 0.5629]}, {"w": "values", "b": [0.8055, 0.5415, 0.8571, 0.5629]}, {"w": "for", "b": [0.1429, 0.5614, 0.1674, 0.5828]}, {"w": "the", "b": [0.1745, 0.5614, 0.2008, 0.5828]}, {"w": "Adam", "b": [0.208, 0.5646, 0.2476, 0.5797]}, {"w": "class", "b": [0.2547, 0.5614, 0.2932, 0.5828]}, {"w": "(to", "b": [0.3004, 0.5614, 0.3246, 0.5828]}, {"w": "be", "b": [0.3317, 0.5614, 0.3511, 0.5828]}, {"w": "precise,", "b": [0.3583, 0.5614, 0.4214, 0.5828]}, {"w": "epsilon", "b": [0.4286, 0.5646, 0.4978, 0.5797]}, {"w": "defaults", "b": [0.505, 0.5614, 0.5701, 0.5828]}, {"w": "to", "b": [0.5772, 0.5614, 0.5942, 0.5828]}, {"w": "None,", "b": [0.6013, 0.5614, 0.6457, 0.5828]}, {"w": "which", "b": [0.6528, 0.5614, 0.7037, 0.5828]}, {"w": "tells", "b": [0.7109, 0.5614, 0.7443, 0.5828]}, {"w": "Keras", "b": [0.7514, 0.5614, 0.7983, 0.5828]}, {"w": "to", "b": [0.8055, 0.5614, 0.8224, 0.5828]}, {"w": "use", "b": [0.8296, 0.5614, 0.8571, 0.5828]}, {"w": "keras.backend.epsilon(),", "b": [0.1429, 0.5814, 0.3752, 0.6028]}, {"w": "which", "b": [0.3902, 0.5814, 0.4411, 0.6028]}, {"w": "defaults", "b": [0.456, 0.5814, 0.5211, 0.6028]}, {"w": "to", "b": [0.5361, 0.5814, 0.5531, 0.6028]}, {"w": "10–7;", "b": [0.568, 0.5814, 0.6053, 0.6028]}, {"w": "you", "b": [0.6202, 0.5814, 0.6515, 0.6028]}, {"w": "can", "b": [0.6665, 0.5814, 0.6958, 0.6028]}, {"w": "change", "b": [0.7108, 0.5814, 0.7699, 0.6028]}, {"w": "it", "b": [0.7848, 0.5814, 0.7967, 0.6028]}, {"w": "using", "b": [0.8117, 0.5814, 0.8571, 0.6028]}, {"w": "keras.backend.set_epsilon()).", "b": [0.1429, 0.6013, 0.422, 0.6227]}]}, {"id": "b_9", "type": "equation", "text": "optimizer = keras.optimizers.Adam(lr=0.001, beta_1=0.9, beta_2=0.999)", "words": [{"w": "optimizer", "b": [0.1766, 0.6333, 0.2525, 0.6461]}, {"w": "=", "b": [0.2609, 0.6333, 0.2693, 0.6461]}, {"w": "keras.optimizers.Adam(lr=0.001,", "b": [0.2778, 0.6333, 0.5392, 0.6461]}, {"w": "beta_1=0.9,", "b": [0.5476, 0.6333, 0.6404, 0.6461]}, {"w": "beta_2=0.999)", "b": [0.6488, 0.6333, 0.7584, 0.6461]}]}, {"id": "b_10", "type": "paragraph", "text": "Since Adam is an adaptive learning rate algorithm (like AdaGrad and RMSProp), it requires less tuning of the learning rate hyperparameter η. You can often use the default value η = 0.001, making Adam even easier to use than Gradient Descent.", "words": [{"w": "Since", "b": [0.1428, 0.6539, 0.1874, 0.6753]}, {"w": "Adam", "b": [0.194, 0.6539, 0.245, 0.6753]}, {"w": "is", "b": [0.2517, 0.6539, 0.2649, 0.6753]}, {"w": "an", "b": [0.2715, 0.6539, 0.2921, 0.6753]}, {"w": "adaptive", "b": [0.2987, 0.6539, 0.3689, 0.6753]}, {"w": "learning", "b": [0.3755, 0.6539, 0.4447, 0.6753]}, {"w": "rate", "b": [0.4513, 0.6539, 0.483, 0.6753]}, {"w": "algorithm", "b": [0.4896, 0.6539, 0.5722, 0.6753]}, {"w": "(like", "b": [0.5788, 0.6539, 0.6161, 0.6753]}, {"w": "AdaGrad", "b": [0.6227, 0.6539, 0.6995, 0.6753]}, {"w": "and", "b": [0.7061, 0.6539, 0.7376, 0.6753]}, {"w": "RMSProp),", "b": [0.7442, 0.6539, 0.8386, 0.6753]}, {"w": "it", "b": [0.8452, 0.6539, 0.8571, 0.6753]}, {"w": "requires", "b": [0.1429, 0.673, 0.211, 0.6944]}, {"w": "less", "b": [0.2194, 0.673, 0.2488, 0.6944]}, {"w": "tuning", "b": [0.2572, 0.673, 0.3128, 0.6944]}, {"w": "of", "b": [0.3212, 0.673, 0.338, 0.6944]}, {"w": "the", "b": [0.3464, 0.673, 0.3727, 0.6944]}, {"w": "learning", "b": [0.3811, 0.673, 0.4503, 0.6944]}, {"w": "rate", "b": [0.4587, 0.673, 0.4904, 0.6944]}, {"w": "hyperparameter", "b": [0.4988, 0.673, 0.6323, 0.6944]}, {"w": "η.", "b": [0.6407, 0.6728, 0.6561, 0.6944]}, {"w": "You", "b": [0.6645, 0.673, 0.6968, 0.6944]}, {"w": "can", "b": [0.7053, 0.673, 0.7346, 0.6944]}, {"w": "often", "b": [0.743, 0.673, 0.7864, 0.6944]}, {"w": "use", "b": [0.7948, 0.673, 0.8224, 0.6944]}, {"w": "the", "b": [0.8308, 0.673, 0.8572, 0.6944]}, {"w": "default", "b": [0.1429, 0.692, 0.2003, 0.7134]}, {"w": "value", "b": [0.205, 0.692, 0.249, 0.7134]}, {"w": "η", "b": [0.2538, 0.6918, 0.2644, 0.7134]}, {"w": "=", "b": [0.2691, 0.692, 0.2812, 0.7134]}, {"w": "0.001,", "b": [0.2859, 0.692, 0.3354, 0.7134]}, {"w": "making", "b": [0.3401, 0.692, 0.4034, 0.7134]}, {"w": "Adam", "b": [0.4081, 0.692, 0.4592, 0.7134]}, {"w": "even", "b": [0.4639, 0.692, 0.5027, 0.7134]}, {"w": "easier", "b": [0.5074, 0.692, 0.5552, 0.7134]}, {"w": "to", "b": [0.5599, 0.692, 0.5769, 0.7134]}, {"w": "use", "b": [0.5817, 0.692, 0.6092, 0.7134]}, {"w": "than", "b": [0.6139, 0.692, 0.652, 0.7134]}, {"w": "Gradient", "b": [0.6567, 0.692, 0.7313, 0.7134]}, {"w": "Descent.", "b": [0.736, 0.692, 0.8076, 0.7134]}]}, {"id": "b_11", "type": "paragraph", "text": "If you are starting to feel overwhelmed by all these different techni‐ ques, and wondering how to choose the right ones for your task, don’t worry: some practical guidelines are provided at the end of this chapter.", "words": [{"w": "If", "b": [0.2714, 0.734, 0.2835, 0.7535]}, {"w": "you", "b": [0.2881, 0.734, 0.3166, 0.7535]}, {"w": "are", "b": [0.3212, 0.734, 0.3447, 0.7535]}, {"w": "starting", "b": [0.3492, 0.734, 0.4077, 0.7535]}, {"w": "to", "b": [0.4122, 0.734, 0.4277, 0.7535]}, {"w": "feel", "b": [0.4322, 0.734, 0.4589, 0.7535]}, {"w": "overwhelmed", "b": [0.4634, 0.734, 0.5675, 0.7535]}, {"w": "by", "b": [0.5721, 0.734, 0.5905, 0.7535]}, {"w": "all", "b": [0.595, 0.734, 0.613, 0.7535]}, {"w": "these", "b": [0.6175, 0.734, 0.6567, 0.7535]}, {"w": "different", "b": [0.6612, 0.734, 0.7268, 0.7535]}, {"w": "techni‐", "b": [0.7313, 0.734, 0.7857, 0.7535]}, {"w": "ques,", "b": [0.2714, 0.7514, 0.3107, 0.771]}, {"w": "and", "b": [0.3173, 0.7514, 0.3462, 0.771]}, {"w": "wondering", "b": [0.3528, 0.7514, 0.4357, 0.771]}, {"w": "how", "b": [0.4423, 0.7514, 0.4752, 0.771]}, {"w": "to", "b": [0.4819, 0.7514, 0.4974, 0.771]}, {"w": "choose", "b": [0.5041, 0.7514, 0.5568, 0.771]}, {"w": "the", "b": [0.5635, 0.7514, 0.5875, 0.771]}, {"w": "right", "b": [0.5942, 0.7514, 0.6309, 0.771]}, {"w": "ones", "b": [0.6375, 0.7514, 0.6728, 0.771]}, {"w": "for", "b": [0.6794, 0.7514, 0.7018, 0.771]}, {"w": "your", "b": [0.7085, 0.7514, 0.7441, 0.771]}, {"w": "task,", "b": [0.7508, 0.7514, 0.7857, 0.771]}, {"w": "don’t", "b": [0.2714, 0.7688, 0.3095, 0.7884]}, {"w": "worry:", "b": [0.3162, 0.7688, 0.3673, 0.7884]}, {"w": "some", "b": [0.374, 0.7688, 0.4144, 0.7884]}, {"w": "practical", "b": [0.4211, 0.7688, 0.4868, 0.7884]}, {"w": "guidelines", "b": [0.4935, 0.7688, 0.5712, 0.7884]}, {"w": "are", "b": [0.5779, 0.7688, 0.6014, 0.7884]}, {"w": "provided", "b": [0.6081, 0.7688, 0.677, 0.7884]}, {"w": "at", "b": [0.6838, 0.7688, 0.6976, 0.7884]}, {"w": "the", "b": [0.7043, 0.7688, 0.7284, 0.7884]}, {"w": "end", "b": [0.7351, 0.7688, 0.7637, 0.7884]}, {"w": "of", "b": [0.7704, 0.7688, 0.7857, 0.7884]}, {"w": "this", "b": [0.2714, 0.7862, 0.2995, 0.8058]}, {"w": "chapter.", "b": [0.3038, 0.7862, 0.3641, 0.8058]}]}, {"id": "b_12", "type": "paragraph", "text": "Finally, two variants of Adam are worth mentioning:", "words": [{"w": "Finally,", "b": [0.1428, 0.8326, 0.2033, 0.854]}, {"w": "two", "b": [0.2081, 0.8326, 0.2393, 0.854]}, {"w": "variants", "b": [0.244, 0.8326, 0.3103, 0.854]}, {"w": "of", "b": [0.315, 0.8326, 0.3318, 0.854]}, {"w": "Adam", "b": [0.3365, 0.8326, 0.3876, 0.854]}, {"w": "are", "b": [0.3923, 0.8326, 0.4181, 0.854]}, {"w": "worth", "b": [0.4228, 0.8326, 0.4729, 0.854]}, {"w": "mentioning:", "b": [0.4776, 0.8326, 0.58, 0.854]}]}, {"id": "b_13", "type": "paragraph", "text": "350 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "350", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2745, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 377, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "18 “Incorporating Nesterov Momentum into Adam,” Timothy Dozat (2015).", "words": [{"w": "18", "b": [0.1385, 0.8568, 0.1518, 0.871]}, {"w": "“Incorporating", "b": [0.1587, 0.8553, 0.254, 0.8716]}, {"w": "Nesterov", "b": [0.2576, 0.8553, 0.3145, 0.8716]}, {"w": "Momentum", "b": [0.3181, 0.8553, 0.3943, 0.8716]}, {"w": "into", "b": [0.3979, 0.8553, 0.4235, 0.8716]}, {"w": "Adam,”", "b": [0.4271, 0.8553, 0.4738, 0.8716]}, {"w": "Timothy", "b": [0.4774, 0.8553, 0.5321, 0.8716]}, {"w": "Dozat", "b": [0.5357, 0.8553, 0.5737, 0.8716]}, {"w": "(2015).", "b": [0.5773, 0.8553, 0.6223, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "19 “The Marginal Value of Adaptive Gradient Methods in Machine Learning,” A. C. Wilson et al. (2017).", "words": [{"w": "19", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“The", "b": [0.1587, 0.8749, 0.1905, 0.8912]}, {"w": "Marginal", "b": [0.1941, 0.8749, 0.2521, 0.8912]}, {"w": "Value", "b": [0.2557, 0.8749, 0.2915, 0.8912]}, {"w": "of", "b": [0.2951, 0.8749, 0.3079, 0.8912]}, {"w": "Adaptive", "b": [0.3115, 0.8749, 0.3686, 0.8912]}, {"w": "Gradient", "b": [0.3722, 0.8749, 0.429, 0.8912]}, {"w": "Methods", "b": [0.4326, 0.8749, 0.4887, 0.8912]}, {"w": "in", "b": [0.4923, 0.8749, 0.5053, 0.8912]}, {"w": "Machine", "b": [0.5089, 0.8749, 0.5646, 0.8912]}, {"w": "Learning,”", "b": [0.5682, 0.8749, 0.6332, 0.8912]}, {"w": "A.", "b": [0.6368, 0.8749, 0.6513, 0.8912]}, {"w": "C.", "b": [0.655, 0.8749, 0.6691, 0.8912]}, {"w": "Wilson", "b": [0.6727, 0.8749, 0.7184, 0.8912]}, {"w": "et", "b": [0.722, 0.8749, 0.7336, 0.8912]}, {"w": "al.", "b": [0.7372, 0.8749, 0.7518, 0.8912]}, {"w": "(2017).", "b": [0.7554, 0.8749, 0.8004, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "• Adamax, introduced in the same paper as Adam: notice that in step 2 of Equation 11-8, Adam accumulates the squares of the gradients in s (with a greater weight for more recent weights). In step 5, if we ignore ϵ and steps 3 and 4 (which are technical details anyway), Adam just scales down the parameter updates by the square root of s. In short, Adam scales down the parameter updates by the ℓ2 norm of the time-decayed gradients (recall that the ℓ2 norm is the square root of the sum of squares). Adamax just replaces the ℓ2 norm with the ℓ∞ norm (a fancy way of saying the max). Specifically, it replaces step 2 in Equation 11-8 with � max β2�, ∇θJ θ , it drops step 4, and in step 5 it scales down the gradient updates by a factor of s, which is just the max of the time-decayed gradients. In practice, this can make Adamax more stable than Adam, but this really depends on the dataset, and in general Adam actually performs better. So it’s just one more optimizer you can try if you experience problems with Adam on some task.", "words": [{"w": "•", "b": [0.16, 0.0851, 0.1682, 0.1065]}, {"w": "Adamax,", "b": [0.1786, 0.0851, 0.2534, 0.1065]}, {"w": "introduced", "b": [0.2582, 0.0851, 0.3502, 0.1065]}, {"w": "in", "b": [0.3551, 0.0851, 0.3721, 0.1065]}, {"w": "the", "b": [0.3769, 0.0851, 0.4033, 0.1065]}, {"w": "same", "b": [0.4081, 0.0851, 0.4508, 0.1065]}, {"w": "paper", "b": [0.4557, 0.0851, 0.5028, 0.1065]}, {"w": "as", "b": [0.5077, 0.0851, 0.5245, 0.1065]}, {"w": "Adam:", "b": [0.5293, 0.0851, 0.5852, 0.1065]}, {"w": "notice", "b": [0.59, 0.0851, 0.6416, 0.1065]}, {"w": "that", "b": [0.6465, 0.0851, 0.6791, 0.1065]}, {"w": "in", "b": [0.6839, 0.0851, 0.7009, 0.1065]}, {"w": "step", "b": [0.7058, 0.0851, 0.7395, 0.1065]}, {"w": "2", "b": [0.7444, 0.0851, 0.7544, 0.1065]}, {"w": "of", "b": [0.7592, 0.0851, 0.776, 0.1065]}, {"w": "Equation", "b": [0.7809, 0.0851, 0.8571, 0.1065]}, {"w": "11-8,", "b": [0.1786, 0.1042, 0.2207, 0.1256]}, {"w": "Adam", "b": [0.227, 0.1042, 0.2781, 0.1256]}, {"w": "accumulates", "b": [0.2843, 0.1042, 0.3868, 0.1256]}, {"w": "the", "b": [0.393, 0.1042, 0.4194, 0.1256]}, {"w": "squares", "b": [0.4256, 0.1042, 0.4884, 0.1256]}, {"w": "of", "b": [0.4946, 0.1042, 0.5114, 0.1256]}, {"w": "the", "b": [0.5177, 0.1042, 0.544, 0.1256]}, {"w": "gradients", "b": [0.5503, 0.1042, 0.6273, 0.1256]}, {"w": "in", "b": [0.6336, 0.1042, 0.6506, 0.1256]}, {"w": "s", "b": [0.6569, 0.1036, 0.6648, 0.1256]}, {"w": "(with", "b": [0.6711, 0.1042, 0.7156, 0.1256]}, {"w": "a", "b": [0.7219, 0.1042, 0.7311, 0.1256]}, {"w": "greater", "b": [0.7373, 0.1042, 0.7953, 0.1256]}, {"w": "weight", "b": [0.8016, 0.1042, 0.8571, 0.1256]}, {"w": "for", "b": [0.1786, 0.1232, 0.2031, 0.1446]}, {"w": "more", "b": [0.2095, 0.1232, 0.2538, 0.1446]}, {"w": "recent", "b": [0.2602, 0.1232, 0.3118, 0.1446]}, {"w": "weights).", "b": [0.3183, 0.1232, 0.3934, 0.1446]}, {"w": "In", "b": [0.3999, 0.1232, 0.4184, 0.1446]}, {"w": "step", "b": [0.4248, 0.1232, 0.4586, 0.1446]}, {"w": "5,", "b": [0.465, 0.1232, 0.4798, 0.1446]}, {"w": "if", "b": [0.4862, 0.1232, 0.498, 0.1446]}, {"w": "we", "b": [0.5044, 0.1232, 0.5275, 0.1446]}, {"w": "ignore", "b": [0.534, 0.1232, 0.5879, 0.1446]}, {"w": "ϵ", "b": [0.5943, 0.1264, 0.609, 0.1423]}, {"w": "and", "b": [0.6102, 0.1232, 0.6417, 0.1446]}, {"w": "steps", "b": [0.6481, 0.1232, 0.6896, 0.1446]}, {"w": "3", "b": [0.696, 0.1232, 0.706, 0.1446]}, {"w": "and", "b": [0.7124, 0.1232, 0.744, 0.1446]}, {"w": "4", "b": [0.7504, 0.1232, 0.7604, 0.1446]}, {"w": "(which", "b": [0.7669, 0.1232, 0.825, 0.1446]}, {"w": "are", "b": [0.8314, 0.1232, 0.8572, 0.1446]}, {"w": "technical", "b": [0.1786, 0.1423, 0.2539, 0.1637]}, {"w": "details", "b": [0.2608, 0.1423, 0.3147, 0.1637]}, {"w": "anyway),", "b": [0.3216, 0.1423, 0.3958, 0.1637]}, {"w": "Adam", "b": [0.4027, 0.1423, 0.4537, 0.1637]}, {"w": "just", "b": [0.4606, 0.1423, 0.491, 0.1637]}, {"w": "scales", "b": [0.4979, 0.1423, 0.5453, 0.1637]}, {"w": "down", "b": [0.5522, 0.1423, 0.5995, 0.1637]}, {"w": "the", "b": [0.6064, 0.1423, 0.6327, 0.1637]}, {"w": "parameter", "b": [0.6396, 0.1423, 0.7254, 0.1637]}, {"w": "updates", "b": [0.7323, 0.1423, 0.7969, 0.1637]}, {"w": "by", "b": [0.8038, 0.1423, 0.8239, 0.1637]}, {"w": "the", "b": [0.8308, 0.1423, 0.8571, 0.1637]}, {"w": "square", "b": [0.1786, 0.1613, 0.2337, 0.1827]}, {"w": "root", "b": [0.2414, 0.1613, 0.2767, 0.1827]}, {"w": "of", "b": [0.2845, 0.1613, 0.3013, 0.1827]}, {"w": "s.", "b": [0.309, 0.1607, 0.3217, 0.1827]}, {"w": "In", "b": [0.3295, 0.1613, 0.348, 0.1827]}, {"w": "short,", "b": [0.3557, 0.1613, 0.404, 0.1827]}, {"w": "Adam", "b": [0.4117, 0.1613, 0.4628, 0.1827]}, {"w": "scales", "b": [0.4705, 0.1613, 0.5179, 0.1827]}, {"w": "down", "b": [0.5256, 0.1613, 0.5729, 0.1827]}, {"w": "the", "b": [0.5807, 0.1613, 0.607, 0.1827]}, {"w": "parameter", "b": [0.6148, 0.1613, 0.7005, 0.1827]}, {"w": "updates", "b": [0.7083, 0.1613, 0.7729, 0.1827]}, {"w": "by", "b": [0.7806, 0.1613, 0.8008, 0.1827]}, {"w": "the", "b": [0.8085, 0.1613, 0.8348, 0.1827]}, {"w": "ℓ2", "b": [0.8426, 0.1613, 0.8571, 0.1836]}, {"w": "norm", "b": [0.1786, 0.1803, 0.2254, 0.2018]}, {"w": "of", "b": [0.2311, 0.1803, 0.2479, 0.2018]}, {"w": "the", "b": [0.2536, 0.1803, 0.2799, 0.2018]}, {"w": "time-decayed", "b": [0.2857, 0.1803, 0.3978, 0.2018]}, {"w": "gradients", "b": [0.4035, 0.1803, 0.4806, 0.2018]}, {"w": "(recall", "b": [0.4863, 0.1803, 0.5386, 0.2018]}, {"w": "that", "b": [0.5443, 0.1803, 0.5769, 0.2018]}, {"w": "the", "b": [0.5826, 0.1803, 0.6089, 0.2018]}, {"w": "ℓ2", "b": [0.6147, 0.1803, 0.6292, 0.2026]}, {"w": "norm", "b": [0.635, 0.1803, 0.6818, 0.2018]}, {"w": "is", "b": [0.6875, 0.1803, 0.7007, 0.2018]}, {"w": "the", "b": [0.7064, 0.1803, 0.7328, 0.2018]}, {"w": "square", "b": [0.7385, 0.1803, 0.7936, 0.2018]}, {"w": "root", "b": [0.7993, 0.1803, 0.8346, 0.2018]}, {"w": "of", "b": [0.8404, 0.1803, 0.8571, 0.2018]}, {"w": "the", "b": [0.1786, 0.1994, 0.2049, 0.2208]}, {"w": "sum", "b": [0.2102, 0.1994, 0.246, 0.2208]}, {"w": "of", "b": [0.2513, 0.1994, 0.2681, 0.2208]}, {"w": "squares).", "b": [0.2734, 0.1994, 0.3481, 0.2208]}, {"w": "Adamax", "b": [0.3534, 0.1994, 0.4234, 0.2208]}, {"w": "just", "b": [0.4287, 0.1994, 0.4591, 0.2208]}, {"w": "replaces", "b": [0.4644, 0.1994, 0.5317, 0.2208]}, {"w": "the", "b": [0.537, 0.1994, 0.5633, 0.2208]}, {"w": "ℓ2", "b": [0.5686, 0.1994, 0.5832, 0.2217]}, {"w": "norm", "b": [0.5885, 0.1994, 0.6353, 0.2208]}, {"w": "with", "b": [0.6406, 0.1994, 0.678, 0.2208]}, {"w": "the", "b": [0.6833, 0.1994, 0.7096, 0.2208]}, {"w": "ℓ∞", "b": [0.7149, 0.1994, 0.733, 0.2217]}, {"w": "norm", "b": [0.7383, 0.1994, 0.7851, 0.2208]}, {"w": "(a", "b": [0.7904, 0.1994, 0.8068, 0.2208]}, {"w": "fancy", "b": [0.8121, 0.1994, 0.8571, 0.2208]}, {"w": "way", "b": [0.1786, 0.2184, 0.2112, 0.2399]}, {"w": "of", "b": [0.22, 0.2184, 0.2368, 0.2399]}, {"w": "saying", "b": [0.2455, 0.2184, 0.2982, 0.2399]}, {"w": "the", "b": [0.307, 0.2184, 0.3334, 0.2399]}, {"w": "max).", "b": [0.3421, 0.2184, 0.3901, 0.2399]}, {"w": "Specifically,", "b": [0.3989, 0.2184, 0.496, 0.2399]}, {"w": "it", "b": [0.5048, 0.2184, 0.5167, 0.2399]}, {"w": "replaces", "b": [0.5255, 0.2184, 0.5927, 0.2399]}, {"w": "step", "b": [0.6015, 0.2184, 0.6353, 0.2399]}, {"w": "2", "b": [0.6441, 0.2184, 0.6541, 0.2399]}, {"w": "in", "b": [0.6628, 0.2184, 0.6798, 0.2399]}, {"w": "Equation", "b": [0.6886, 0.2184, 0.7648, 0.2399]}, {"w": "11-8", "b": [0.7736, 0.2184, 0.811, 0.2399]}, {"w": "with", "b": [0.8198, 0.2184, 0.8572, 0.2399]}, {"w": "�", "b": [0.1786, 0.2407, 0.1864, 0.2566]}, {"w": "max", "b": [0.2221, 0.2375, 0.2581, 0.2589]}, {"w": "β2�,", "b": [0.2715, 0.2373, 0.3023, 0.2627]}, {"w": "∇θJ", "b": [0.3058, 0.2373, 0.3378, 0.2618]}, {"w": "θ", "b": [0.3461, 0.2373, 0.356, 0.2589]}, {"w": ",", "b": [0.3704, 0.2375, 0.3752, 0.2589]}, {"w": "it", "b": [0.3813, 0.2375, 0.3932, 0.2589]}, {"w": "drops", "b": [0.3993, 0.2375, 0.4472, 0.2589]}, {"w": "step", "b": [0.4533, 0.2375, 0.487, 0.2589]}, {"w": "4,", "b": [0.4931, 0.2375, 0.5079, 0.2589]}, {"w": "and", "b": [0.5139, 0.2375, 0.5455, 0.2589]}, {"w": "in", "b": [0.5515, 0.2375, 0.5685, 0.2589]}, {"w": "step", "b": [0.5746, 0.2375, 0.6084, 0.2589]}, {"w": "5", "b": [0.6144, 0.2375, 0.6244, 0.2589]}, {"w": "it", "b": [0.6305, 0.2375, 0.6424, 0.2589]}, {"w": "scales", "b": [0.6485, 0.2375, 0.6959, 0.2589]}, {"w": "down", "b": [0.702, 0.2375, 0.7492, 0.2589]}, {"w": "the", "b": [0.7553, 0.2375, 0.7817, 0.2589]}, {"w": "gradient", "b": [0.7877, 0.2375, 0.8571, 0.2589]}, {"w": "updates", "b": [0.1786, 0.2591, 0.2432, 0.2805]}, {"w": "by", "b": [0.2494, 0.2591, 0.2696, 0.2805]}, {"w": "a", "b": [0.2758, 0.2591, 0.285, 0.2805]}, {"w": "factor", "b": [0.2912, 0.2591, 0.3401, 0.2805]}, {"w": "of", "b": [0.3463, 0.2591, 0.3631, 0.2805]}, {"w": "s,", "b": [0.3694, 0.2586, 0.3821, 0.2805]}, {"w": "which", "b": [0.3884, 0.2591, 0.4393, 0.2805]}, {"w": "is", "b": [0.4455, 0.2591, 0.4588, 0.2805]}, {"w": "just", "b": [0.465, 0.2591, 0.4954, 0.2805]}, {"w": "the", "b": [0.5017, 0.2591, 0.528, 0.2805]}, {"w": "max", "b": [0.5343, 0.2591, 0.5703, 0.2805]}, {"w": "of", "b": [0.5766, 0.2591, 0.5933, 0.2805]}, {"w": "the", "b": [0.5996, 0.2591, 0.6259, 0.2805]}, {"w": "time-decayed", "b": [0.6322, 0.2591, 0.7443, 0.2805]}, {"w": "gradients.", "b": [0.7506, 0.2591, 0.8324, 0.2805]}, {"w": "In", "b": [0.8386, 0.2591, 0.8571, 0.2805]}, {"w": "practice,", "b": [0.1786, 0.2782, 0.2495, 0.2996]}, {"w": "this", "b": [0.2555, 0.2782, 0.2862, 0.2996]}, {"w": "can", "b": [0.2922, 0.2782, 0.3216, 0.2996]}, {"w": "make", "b": [0.3276, 0.2782, 0.373, 0.2996]}, {"w": "Adamax", "b": [0.379, 0.2782, 0.449, 0.2996]}, {"w": "more", "b": [0.455, 0.2782, 0.4993, 0.2996]}, {"w": "stable", "b": [0.5053, 0.2782, 0.5531, 0.2996]}, {"w": "than", "b": [0.5591, 0.2782, 0.5971, 0.2996]}, {"w": "Adam,", "b": [0.6031, 0.2782, 0.6589, 0.2996]}, {"w": "but", "b": [0.6649, 0.2782, 0.6929, 0.2996]}, {"w": "this", "b": [0.6989, 0.2782, 0.7296, 0.2996]}, {"w": "really", "b": [0.7356, 0.2782, 0.7815, 0.2996]}, {"w": "depends", "b": [0.7875, 0.2782, 0.8571, 0.2996]}, {"w": "on", "b": [0.1786, 0.2972, 0.2006, 0.3186]}, {"w": "the", "b": [0.209, 0.2972, 0.2354, 0.3186]}, {"w": "dataset,", "b": [0.2438, 0.2972, 0.3067, 0.3186]}, {"w": "and", "b": [0.3151, 0.2972, 0.3467, 0.3186]}, {"w": "in", "b": [0.3551, 0.2972, 0.3721, 0.3186]}, {"w": "general", "b": [0.3805, 0.2972, 0.4415, 0.3186]}, {"w": "Adam", "b": [0.45, 0.2972, 0.501, 0.3186]}, {"w": "actually", "b": [0.5095, 0.2972, 0.5741, 0.3186]}, {"w": "performs", "b": [0.5826, 0.2972, 0.6593, 0.3186]}, {"w": "better.", "b": [0.6677, 0.2972, 0.7199, 0.3186]}, {"w": "So", "b": [0.7284, 0.2972, 0.7489, 0.3186]}, {"w": "it’s", "b": [0.7573, 0.2972, 0.779, 0.3186]}, {"w": "just", "b": [0.7874, 0.2972, 0.8178, 0.3186]}, {"w": "one", "b": [0.8263, 0.2972, 0.8571, 0.3186]}, {"w": "more", "b": [0.1786, 0.3163, 0.2228, 0.3377]}, {"w": "optimizer", "b": [0.2276, 0.3163, 0.309, 0.3377]}, {"w": "you", "b": [0.3138, 0.3163, 0.345, 0.3377]}, {"w": "can", "b": [0.3497, 0.3163, 0.3791, 0.3377]}, {"w": "try", "b": [0.3838, 0.3163, 0.4081, 0.3377]}, {"w": "if", "b": [0.4128, 0.3163, 0.4245, 0.3377]}, {"w": "you", "b": [0.4293, 0.3163, 0.4605, 0.3377]}, {"w": "experience", "b": [0.4653, 0.3163, 0.5549, 0.3377]}, {"w": "problems", "b": [0.5597, 0.3163, 0.6384, 0.3377]}, {"w": "with", "b": [0.6431, 0.3163, 0.6804, 0.3377]}, {"w": "Adam", "b": [0.6851, 0.3163, 0.7362, 0.3377]}, {"w": "on", "b": [0.7409, 0.3163, 0.763, 0.3377]}, {"w": "some", "b": [0.7677, 0.3163, 0.8119, 0.3377]}, {"w": "task.", "b": [0.8166, 0.3163, 0.8548, 0.3377]}]}, {"id": "b_3", "type": "paragraph", "text": "• Nadam optimization18 is more important: it is simply Adam optimization plus the Nesterov trick, so it will often converge slightly faster than Adam. In his report, Timothy Dozat compares many different optimizers on various tasks, and finds that Nadam generally outperforms Adam, but is sometimes outperformed by RMSProp.", "words": [{"w": "•", "b": [0.16, 0.3413, 0.1682, 0.3628]}, {"w": "Nadam", "b": [0.1786, 0.3413, 0.2399, 0.3628]}, {"w": "optimization18", "b": [0.2476, 0.3413, 0.3666, 0.3628]}, {"w": "is", "b": [0.3743, 0.3413, 0.3876, 0.3628]}, {"w": "more", "b": [0.3953, 0.3413, 0.4396, 0.3628]}, {"w": "important:", "b": [0.4473, 0.3413, 0.5364, 0.3628]}, {"w": "it", "b": [0.5441, 0.3413, 0.5561, 0.3628]}, {"w": "is", "b": [0.5638, 0.3413, 0.577, 0.3628]}, {"w": "simply", "b": [0.5848, 0.3413, 0.6404, 0.3628]}, {"w": "Adam", "b": [0.6481, 0.3413, 0.6992, 0.3628]}, {"w": "optimization", "b": [0.7069, 0.3413, 0.8145, 0.3628]}, {"w": "plus", "b": [0.8222, 0.3413, 0.8571, 0.3628]}, {"w": "the", "b": [0.1786, 0.3604, 0.2049, 0.3818]}, {"w": "Nesterov", "b": [0.2135, 0.3604, 0.2882, 0.3818]}, {"w": "trick,", "b": [0.2968, 0.3604, 0.3404, 0.3818]}, {"w": "so", "b": [0.349, 0.3604, 0.3673, 0.3818]}, {"w": "it", "b": [0.3759, 0.3604, 0.3878, 0.3818]}, {"w": "will", "b": [0.3964, 0.3604, 0.4268, 0.3818]}, {"w": "often", "b": [0.4355, 0.3604, 0.4789, 0.3818]}, {"w": "converge", "b": [0.4875, 0.3604, 0.5627, 0.3818]}, {"w": "slightly", "b": [0.5713, 0.3604, 0.6315, 0.3818]}, {"w": "faster", "b": [0.6401, 0.3604, 0.686, 0.3818]}, {"w": "than", "b": [0.6946, 0.3604, 0.7326, 0.3818]}, {"w": "Adam.", "b": [0.7412, 0.3604, 0.797, 0.3818]}, {"w": "In", "b": [0.8057, 0.3604, 0.8242, 0.3818]}, {"w": "his", "b": [0.8328, 0.3604, 0.8571, 0.3818]}, {"w": "report,", "b": [0.1786, 0.3794, 0.2355, 0.4009]}, {"w": "Timothy", "b": [0.2406, 0.3794, 0.3125, 0.4009]}, {"w": "Dozat", "b": [0.3176, 0.3794, 0.3674, 0.4009]}, {"w": "compares", "b": [0.3725, 0.3794, 0.4529, 0.4009]}, {"w": "many", "b": [0.458, 0.3794, 0.5047, 0.4009]}, {"w": "different", "b": [0.5098, 0.3794, 0.5815, 0.4009]}, {"w": "optimizers", "b": [0.5867, 0.3794, 0.6758, 0.4009]}, {"w": "on", "b": [0.6809, 0.3794, 0.7029, 0.4009]}, {"w": "various", "b": [0.708, 0.3794, 0.7695, 0.4009]}, {"w": "tasks,", "b": [0.7746, 0.3794, 0.8205, 0.4009]}, {"w": "and", "b": [0.8256, 0.3794, 0.8571, 0.4009]}, {"w": "finds", "b": [0.1786, 0.3985, 0.2204, 0.4199]}, {"w": "that", "b": [0.2269, 0.3985, 0.2595, 0.4199]}, {"w": "Nadam", "b": [0.266, 0.3985, 0.3273, 0.4199]}, {"w": "generally", "b": [0.3338, 0.3985, 0.4096, 0.4199]}, {"w": "outperforms", "b": [0.4161, 0.3985, 0.5209, 0.4199]}, {"w": "Adam,", "b": [0.5274, 0.3985, 0.5832, 0.4199]}, {"w": "but", "b": [0.5897, 0.3985, 0.6177, 0.4199]}, {"w": "is", "b": [0.6242, 0.3985, 0.6375, 0.4199]}, {"w": "sometimes", "b": [0.644, 0.3985, 0.7337, 0.4199]}, {"w": "outperformed", "b": [0.7402, 0.3985, 0.8571, 0.4199]}, {"w": "by", "b": [0.1786, 0.4175, 0.1987, 0.4389]}, {"w": "RMSProp.", "b": [0.2035, 0.4175, 0.29, 0.4389]}]}, {"id": "b_4", "type": "paragraph", "text": "Adaptive optimization methods (including RMSProp, Adam and Nadam optimization) are often great, converging fast to a good sol‐ ution. However, a 2017 paper19 by Ashia C. Wilson et al. showed that they can lead to solutions that generalize poorly on some data‐ sets. So when you are disappointed by your model’s performance, try using plain Nesterov Accelerated Gradient instead: your dataset may just be allergic to adaptive gradients. Also check out the latest research, it is moving fast (e.g., AdaBound).", "words": [{"w": "Adaptive", "b": [0.2714, 0.4746, 0.3399, 0.4942]}, {"w": "optimization", "b": [0.3477, 0.4746, 0.4461, 0.4942]}, {"w": "methods", "b": [0.4539, 0.4746, 0.5203, 0.4942]}, {"w": "(including", "b": [0.5281, 0.4746, 0.6077, 0.4942]}, {"w": "RMSProp,", "b": [0.6155, 0.4746, 0.6946, 0.4942]}, {"w": "Adam", "b": [0.7024, 0.4746, 0.7491, 0.4942]}, {"w": "and", "b": [0.7569, 0.4746, 0.7857, 0.4942]}, {"w": "Nadam", "b": [0.2714, 0.492, 0.3274, 0.5116]}, {"w": "optimization)", "b": [0.332, 0.492, 0.4369, 0.5116]}, {"w": "are", "b": [0.4415, 0.492, 0.465, 0.5116]}, {"w": "often", "b": [0.4695, 0.492, 0.5092, 0.5116]}, {"w": "great,", "b": [0.5138, 0.492, 0.556, 0.5116]}, {"w": "converging", "b": [0.5605, 0.492, 0.6456, 0.5116]}, {"w": "fast", "b": [0.6502, 0.492, 0.677, 0.5116]}, {"w": "to", "b": [0.6815, 0.492, 0.697, 0.5116]}, {"w": "a", "b": [0.7016, 0.492, 0.7099, 0.5116]}, {"w": "good", "b": [0.7145, 0.492, 0.7529, 0.5116]}, {"w": "sol‐", "b": [0.7574, 0.492, 0.7857, 0.5116]}, {"w": "ution.", "b": [0.2714, 0.5094, 0.3169, 0.529]}, {"w": "However,", "b": [0.3236, 0.5094, 0.3957, 0.529]}, {"w": "a", "b": [0.4024, 0.5094, 0.4108, 0.529]}, {"w": "2017", "b": [0.4175, 0.5094, 0.454, 0.529]}, {"w": "paper19", "b": [0.4608, 0.5094, 0.5153, 0.529]}, {"w": "by", "b": [0.522, 0.5094, 0.5404, 0.529]}, {"w": "Ashia", "b": [0.5471, 0.5094, 0.5909, 0.529]}, {"w": "C.", "b": [0.5976, 0.5094, 0.6146, 0.529]}, {"w": "Wilson", "b": [0.6213, 0.5094, 0.6761, 0.529]}, {"w": "et", "b": [0.6828, 0.5094, 0.6967, 0.529]}, {"w": "al.", "b": [0.7034, 0.5094, 0.7209, 0.529]}, {"w": "showed", "b": [0.7276, 0.5094, 0.7857, 0.529]}, {"w": "that", "b": [0.2714, 0.5268, 0.3012, 0.5464]}, {"w": "they", "b": [0.3059, 0.5268, 0.3387, 0.5464]}, {"w": "can", "b": [0.3435, 0.5268, 0.3703, 0.5464]}, {"w": "lead", "b": [0.375, 0.5268, 0.4064, 0.5464]}, {"w": "to", "b": [0.4111, 0.5268, 0.4266, 0.5464]}, {"w": "solutions", "b": [0.4313, 0.5268, 0.501, 0.5464]}, {"w": "that", "b": [0.5057, 0.5268, 0.5355, 0.5464]}, {"w": "generalize", "b": [0.5403, 0.5268, 0.6172, 0.5464]}, {"w": "poorly", "b": [0.622, 0.5268, 0.672, 0.5464]}, {"w": "on", "b": [0.6767, 0.5268, 0.6969, 0.5464]}, {"w": "some", "b": [0.7016, 0.5268, 0.742, 0.5464]}, {"w": "data‐", "b": [0.7467, 0.5268, 0.7857, 0.5464]}, {"w": "sets.", "b": [0.2714, 0.5443, 0.3036, 0.5638]}, {"w": "So", "b": [0.31, 0.5443, 0.3287, 0.5638]}, {"w": "when", "b": [0.335, 0.5443, 0.3767, 0.5638]}, {"w": "you", "b": [0.3831, 0.5443, 0.4116, 0.5638]}, {"w": "are", "b": [0.4179, 0.5443, 0.4415, 0.5638]}, {"w": "disappointed", "b": [0.4478, 0.5443, 0.5467, 0.5638]}, {"w": "by", "b": [0.5531, 0.5443, 0.5715, 0.5638]}, {"w": "your", "b": [0.5778, 0.5443, 0.6134, 0.5638]}, {"w": "model’s", "b": [0.6197, 0.5443, 0.677, 0.5638]}, {"w": "performance,", "b": [0.6833, 0.5443, 0.7857, 0.5638]}, {"w": "try", "b": [0.2714, 0.5617, 0.2936, 0.5812]}, {"w": "using", "b": [0.2984, 0.5617, 0.34, 0.5812]}, {"w": "plain", "b": [0.3448, 0.5617, 0.3835, 0.5812]}, {"w": "Nesterov", "b": [0.3883, 0.5617, 0.4566, 0.5812]}, {"w": "Accelerated", "b": [0.4614, 0.5617, 0.5502, 0.5812]}, {"w": "Gradient", "b": [0.5551, 0.5617, 0.6233, 0.5812]}, {"w": "instead:", "b": [0.6281, 0.5617, 0.6873, 0.5812]}, {"w": "your", "b": [0.6921, 0.5617, 0.7278, 0.5812]}, {"w": "dataset", "b": [0.7326, 0.5617, 0.7857, 0.5812]}, {"w": "may", "b": [0.2714, 0.5791, 0.3038, 0.5987]}, {"w": "just", "b": [0.3091, 0.5791, 0.3369, 0.5987]}, {"w": "be", "b": [0.3423, 0.5791, 0.36, 0.5987]}, {"w": "allergic", "b": [0.3654, 0.5791, 0.4206, 0.5987]}, {"w": "to", "b": [0.426, 0.5791, 0.4415, 0.5987]}, {"w": "adaptive", "b": [0.4468, 0.5791, 0.5111, 0.5987]}, {"w": "gradients.", "b": [0.5164, 0.5791, 0.5912, 0.5987]}, {"w": "Also", "b": [0.5966, 0.5791, 0.6313, 0.5987]}, {"w": "check", "b": [0.6366, 0.5791, 0.6804, 0.5987]}, {"w": "out", "b": [0.6858, 0.5791, 0.7114, 0.5987]}, {"w": "the", "b": [0.7168, 0.5791, 0.7408, 0.5987]}, {"w": "latest", "b": [0.7462, 0.5791, 0.7857, 0.5987]}, {"w": "research,", "b": [0.2714, 0.5965, 0.3397, 0.6161]}, {"w": "it", "b": [0.344, 0.5965, 0.3549, 0.6161]}, {"w": "is", "b": [0.3592, 0.5965, 0.3713, 0.6161]}, {"w": "moving", "b": [0.3756, 0.5965, 0.4342, 0.6161]}, {"w": "fast", "b": [0.4385, 0.5965, 0.4653, 0.6161]}, {"w": "(e.g.,", "b": [0.4697, 0.5965, 0.5063, 0.6161]}, {"w": "AdaBound).", "b": [0.5106, 0.5965, 0.6045, 0.6161]}]}, {"id": "b_5", "type": "paragraph", "text": "All the optimization techniques discussed so far only rely on the first-order partial derivatives (Jacobians). The optimization literature contains amazing algorithms based on the second-order partial derivatives (the Hessians, which are the partial derivatives of the Jacobians). Unfortunately, these algorithms are very hard to apply to deep neural networks because there are n2 Hessians per output (where n is the number of parameters), as opposed to just n Jacobians per output. Since DNNs typi‐ cally have tens of thousands of parameters, the second-order optimization algorithms", "words": [{"w": "All", "b": [0.1428, 0.6364, 0.1678, 0.6578]}, {"w": "the", "b": [0.1753, 0.6364, 0.2016, 0.6578]}, {"w": "optimization", "b": [0.2091, 0.6364, 0.3167, 0.6578]}, {"w": "techniques", "b": [0.3242, 0.6364, 0.4145, 0.6578]}, {"w": "discussed", "b": [0.422, 0.6364, 0.5013, 0.6578]}, {"w": "so", "b": [0.5088, 0.6364, 0.527, 0.6578]}, {"w": "far", "b": [0.5345, 0.6364, 0.5576, 0.6578]}, {"w": "only", "b": [0.5651, 0.6364, 0.6019, 0.6578]}, {"w": "rely", "b": [0.6094, 0.6364, 0.6408, 0.6578]}, {"w": "on", "b": [0.6483, 0.6364, 0.6703, 0.6578]}, {"w": "the", "b": [0.6778, 0.6364, 0.7042, 0.6578]}, {"w": "first-order", "b": [0.7117, 0.6362, 0.7947, 0.6578]}, {"w": "partial", "b": [0.8022, 0.6362, 0.8571, 0.6578]}, {"w": "derivatives", "b": [0.1429, 0.6552, 0.2299, 0.6768]}, {"w": "(Jacobians).", "b": [0.2416, 0.6552, 0.3378, 0.6768]}, {"w": "The", "b": [0.3496, 0.6554, 0.3824, 0.6768]}, {"w": "optimization", "b": [0.3942, 0.6554, 0.5018, 0.6768]}, {"w": "literature", "b": [0.5136, 0.6554, 0.5901, 0.6768]}, {"w": "contains", "b": [0.6019, 0.6554, 0.6725, 0.6768]}, {"w": "amazing", "b": [0.6842, 0.6554, 0.7551, 0.6768]}, {"w": "algorithms", "b": [0.7669, 0.6554, 0.8571, 0.6768]}, {"w": "based", "b": [0.1429, 0.6745, 0.1901, 0.6959]}, {"w": "on", "b": [0.1998, 0.6745, 0.2218, 0.6959]}, {"w": "the", "b": [0.2315, 0.6745, 0.2578, 0.6959]}, {"w": "second-order", "b": [0.2675, 0.6743, 0.372, 0.6959]}, {"w": "partial", "b": [0.3817, 0.6743, 0.4366, 0.6959]}, {"w": "derivatives", "b": [0.4464, 0.6743, 0.5334, 0.6959]}, {"w": "(the", "b": [0.5431, 0.6745, 0.5766, 0.6959]}, {"w": "Hessians,", "b": [0.5863, 0.6743, 0.6612, 0.6959]}, {"w": "which", "b": [0.6709, 0.6745, 0.7218, 0.6959]}, {"w": "are", "b": [0.7315, 0.6745, 0.7573, 0.6959]}, {"w": "the", "b": [0.767, 0.6745, 0.7933, 0.6959]}, {"w": "partial", "b": [0.803, 0.6745, 0.8571, 0.6959]}, {"w": "derivatives", "b": [0.1429, 0.6935, 0.2325, 0.7149]}, {"w": "of", "b": [0.2391, 0.6935, 0.2559, 0.7149]}, {"w": "the", "b": [0.2625, 0.6935, 0.2888, 0.7149]}, {"w": "Jacobians).", "b": [0.2954, 0.6935, 0.3866, 0.7149]}, {"w": "Unfortunately,", "b": [0.3932, 0.6935, 0.5143, 0.7149]}, {"w": "these", "b": [0.5209, 0.6935, 0.5638, 0.7149]}, {"w": "algorithms", "b": [0.5704, 0.6935, 0.6607, 0.7149]}, {"w": "are", "b": [0.6672, 0.6935, 0.693, 0.7149]}, {"w": "very", "b": [0.6996, 0.6935, 0.736, 0.7149]}, {"w": "hard", "b": [0.7426, 0.6935, 0.7816, 0.7149]}, {"w": "to", "b": [0.7881, 0.6935, 0.8051, 0.7149]}, {"w": "apply", "b": [0.8117, 0.6935, 0.8571, 0.7149]}, {"w": "to", "b": [0.1429, 0.7126, 0.1598, 0.734]}, {"w": "deep", "b": [0.1678, 0.7126, 0.2074, 0.734]}, {"w": "neural", "b": [0.2153, 0.7126, 0.2688, 0.734]}, {"w": "networks", "b": [0.2767, 0.7126, 0.3539, 0.734]}, {"w": "because", "b": [0.3618, 0.7126, 0.4264, 0.734]}, {"w": "there", "b": [0.4343, 0.7126, 0.4772, 0.734]}, {"w": "are", "b": [0.4851, 0.7126, 0.5108, 0.734]}, {"w": "n2", "b": [0.5187, 0.7124, 0.5358, 0.734]}, {"w": "Hessians", "b": [0.5437, 0.7126, 0.6171, 0.734]}, {"w": "per", "b": [0.625, 0.7126, 0.6525, 0.734]}, {"w": "output", "b": [0.6604, 0.7126, 0.7168, 0.734]}, {"w": "(where", "b": [0.7247, 0.7126, 0.7827, 0.734]}, {"w": "n", "b": [0.7907, 0.7124, 0.8017, 0.734]}, {"w": "is", "b": [0.8097, 0.7126, 0.8229, 0.734]}, {"w": "the", "b": [0.8308, 0.7126, 0.8571, 0.734]}, {"w": "number", "b": [0.1428, 0.7316, 0.2091, 0.753]}, {"w": "of", "b": [0.2149, 0.7316, 0.2317, 0.753]}, {"w": "parameters),", "b": [0.2374, 0.7316, 0.3428, 0.753]}, {"w": "as", "b": [0.3485, 0.7316, 0.3653, 0.753]}, {"w": "opposed", "b": [0.371, 0.7316, 0.4416, 0.753]}, {"w": "to", "b": [0.4473, 0.7316, 0.4643, 0.753]}, {"w": "just", "b": [0.47, 0.7316, 0.5004, 0.753]}, {"w": "n", "b": [0.5062, 0.7314, 0.5172, 0.753]}, {"w": "Jacobians", "b": [0.523, 0.7316, 0.6022, 0.753]}, {"w": "per", "b": [0.6079, 0.7316, 0.6354, 0.753]}, {"w": "output.", "b": [0.6411, 0.7316, 0.7022, 0.753]}, {"w": "Since", "b": [0.708, 0.7316, 0.7525, 0.753]}, {"w": "DNNs", "b": [0.7582, 0.7316, 0.8116, 0.753]}, {"w": "typi‐", "b": [0.8173, 0.7316, 0.8571, 0.753]}, {"w": "cally", "b": [0.1429, 0.7507, 0.1809, 0.7721]}, {"w": "have", "b": [0.1859, 0.7507, 0.2243, 0.7721]}, {"w": "tens", "b": [0.2293, 0.7507, 0.2636, 0.7721]}, {"w": "of", "b": [0.2685, 0.7507, 0.2853, 0.7721]}, {"w": "thousands", "b": [0.2903, 0.7507, 0.3763, 0.7721]}, {"w": "of", "b": [0.3813, 0.7507, 0.3981, 0.7721]}, {"w": "parameters,", "b": [0.4031, 0.7507, 0.5013, 0.7721]}, {"w": "the", "b": [0.5063, 0.7507, 0.5326, 0.7721]}, {"w": "second-order", "b": [0.5376, 0.7507, 0.6493, 0.7721]}, {"w": "optimization", "b": [0.6543, 0.7507, 0.7619, 0.7721]}, {"w": "algorithms", "b": [0.7669, 0.7507, 0.8571, 0.7721]}]}, {"id": "b_6", "type": "paragraph", "text": "Faster Optimizers | 351", "words": [{"w": "Faster", "b": [0.6934, 0.9225, 0.7296, 0.9388]}, {"w": "Optimizers", "b": [0.7325, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "351", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 378, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "20 “Primal-Dual Subgradient Methods for Convex Problems,” Yurii Nesterov (2005).", "words": [{"w": "20", "b": [0.1385, 0.8568, 0.1518, 0.871]}, {"w": "“Primal-Dual", "b": [0.1587, 0.8553, 0.2448, 0.8716]}, {"w": "Subgradient", "b": [0.2484, 0.8553, 0.3253, 0.8716]}, {"w": "Methods", "b": [0.329, 0.8553, 0.385, 0.8716]}, {"w": "for", "b": [0.3887, 0.8553, 0.4073, 0.8716]}, {"w": "Convex", "b": [0.4109, 0.8553, 0.4595, 0.8716]}, {"w": "Problems,”", "b": [0.4631, 0.8553, 0.5315, 0.8716]}, {"w": "Yurii", "b": [0.5351, 0.8553, 0.5664, 0.8716]}, {"w": "Nesterov", "b": [0.57, 0.8553, 0.6269, 0.8716]}, {"w": "(2005).", "b": [0.6305, 0.8553, 0.6756, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "21 “Ad Click Prediction: a View from the Trenches,” H. McMahan et al. (2013).", "words": [{"w": "21", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Ad", "b": [0.1587, 0.8749, 0.1816, 0.8912]}, {"w": "Click", "b": [0.1852, 0.8749, 0.2186, 0.8912]}, {"w": "Prediction:", "b": [0.2222, 0.8749, 0.2926, 0.8912]}, {"w": "a", "b": [0.2962, 0.8749, 0.3032, 0.8912]}, {"w": "View", "b": [0.3068, 0.8749, 0.3392, 0.8912]}, {"w": "from", "b": [0.3428, 0.8749, 0.3745, 0.8912]}, {"w": "the", "b": [0.3781, 0.8749, 0.3981, 0.8912]}, {"w": "Trenches,”", "b": [0.4017, 0.8749, 0.4671, 0.8912]}, {"w": "H.", "b": [0.4707, 0.8749, 0.4865, 0.8912]}, {"w": "McMahan", "b": [0.4901, 0.8749, 0.5555, 0.8912]}, {"w": "et", "b": [0.5591, 0.8749, 0.5707, 0.8912]}, {"w": "al.", "b": [0.5743, 0.8749, 0.5889, 0.8912]}, {"w": "(2013).", "b": [0.5925, 0.8749, 0.6376, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "often don’t even fit in memory, and even when they do, computing the Hessians is just too slow.", "words": [{"w": "often", "b": [0.1429, 0.0791, 0.1863, 0.1005]}, {"w": "don’t", "b": [0.1929, 0.0791, 0.2345, 0.1005]}, {"w": "even", "b": [0.2411, 0.0791, 0.2798, 0.1005]}, {"w": "fit", "b": [0.2864, 0.0791, 0.3045, 0.1005]}, {"w": "in", "b": [0.3111, 0.0791, 0.3281, 0.1005]}, {"w": "memory,", "b": [0.3347, 0.0791, 0.4094, 0.1005]}, {"w": "and", "b": [0.416, 0.0791, 0.4476, 0.1005]}, {"w": "even", "b": [0.4542, 0.0791, 0.4929, 0.1005]}, {"w": "when", "b": [0.4995, 0.0791, 0.5452, 0.1005]}, {"w": "they", "b": [0.5518, 0.0791, 0.5877, 0.1005]}, {"w": "do,", "b": [0.5943, 0.0791, 0.6201, 0.1005]}, {"w": "computing", "b": [0.6267, 0.0791, 0.7178, 0.1005]}, {"w": "the", "b": [0.7244, 0.0791, 0.7508, 0.1005]}, {"w": "Hessians", "b": [0.7574, 0.0791, 0.8307, 0.1005]}, {"w": "is", "b": [0.8373, 0.0791, 0.8505, 0.1005]}, {"w": "just", "b": [0.1429, 0.0981, 0.1733, 0.1195]}, {"w": "too", "b": [0.178, 0.0981, 0.2056, 0.1195]}, {"w": "slow.", "b": [0.2103, 0.0981, 0.2514, 0.1195]}]}, {"id": "b_3", "type": "paragraph", "text": "Training Sparse Models", "words": [{"w": "Training", "b": [0.3868, 0.1453, 0.4686, 0.1724]}, {"w": "Sparse", "b": [0.4733, 0.1453, 0.538, 0.1724]}, {"w": "Models", "b": [0.5427, 0.1453, 0.6132, 0.1724]}]}, {"id": "b_4", "type": "paragraph", "text": "All the optimization algorithms just presented produce dense models, meaning that most parameters will be nonzero. If you need a blazingly fast model at runtime, or if you need it to take up less memory, you may prefer to end up with a sparse model instead.", "words": [{"w": "All", "b": [0.1592, 0.177, 0.183, 0.1974]}, {"w": "the", "b": [0.1894, 0.177, 0.2144, 0.1974]}, {"w": "optimization", "b": [0.2208, 0.177, 0.3233, 0.1974]}, {"w": "algorithms", "b": [0.3297, 0.177, 0.4157, 0.1974]}, {"w": "just", "b": [0.4221, 0.177, 0.451, 0.1974]}, {"w": "presented", "b": [0.4574, 0.177, 0.5348, 0.1974]}, {"w": "produce", "b": [0.5412, 0.177, 0.6069, 0.1974]}, {"w": "dense", "b": [0.6133, 0.177, 0.6588, 0.1974]}, {"w": "models,", "b": [0.6651, 0.177, 0.7272, 0.1974]}, {"w": "meaning", "b": [0.7336, 0.177, 0.8033, 0.1974]}, {"w": "that", "b": [0.8097, 0.177, 0.8408, 0.1974]}, {"w": "most", "b": [0.1592, 0.1951, 0.1989, 0.2155]}, {"w": "parameters", "b": [0.2045, 0.1951, 0.2935, 0.2155]}, {"w": "will", "b": [0.2991, 0.1951, 0.3281, 0.2155]}, {"w": "be", "b": [0.3337, 0.1951, 0.3522, 0.2155]}, {"w": "nonzero.", "b": [0.3578, 0.1951, 0.4278, 0.2155]}, {"w": "If", "b": [0.4334, 0.1951, 0.4461, 0.2155]}, {"w": "you", "b": [0.4517, 0.1951, 0.4814, 0.2155]}, {"w": "need", "b": [0.4871, 0.1951, 0.5252, 0.2155]}, {"w": "a", "b": [0.5309, 0.1951, 0.5396, 0.2155]}, {"w": "blazingly", "b": [0.5452, 0.1951, 0.6169, 0.2155]}, {"w": "fast", "b": [0.6225, 0.1951, 0.6504, 0.2155]}, {"w": "model", "b": [0.656, 0.1951, 0.7063, 0.2155]}, {"w": "at", "b": [0.7119, 0.1951, 0.7263, 0.2155]}, {"w": "runtime,", "b": [0.7319, 0.1951, 0.8009, 0.2155]}, {"w": "or", "b": [0.8065, 0.1951, 0.824, 0.2155]}, {"w": "if", "b": [0.8296, 0.1951, 0.8408, 0.2155]}, {"w": "you", "b": [0.1592, 0.2133, 0.189, 0.2337]}, {"w": "need", "b": [0.1955, 0.2133, 0.2337, 0.2337]}, {"w": "it", "b": [0.2402, 0.2133, 0.2516, 0.2337]}, {"w": "to", "b": [0.2581, 0.2133, 0.2743, 0.2337]}, {"w": "take", "b": [0.2808, 0.2133, 0.3138, 0.2337]}, {"w": "up", "b": [0.3203, 0.2133, 0.3412, 0.2337]}, {"w": "less", "b": [0.3478, 0.2133, 0.3758, 0.2337]}, {"w": "memory,", "b": [0.3823, 0.2133, 0.4534, 0.2337]}, {"w": "you", "b": [0.46, 0.2133, 0.4897, 0.2337]}, {"w": "may", "b": [0.4962, 0.2133, 0.5299, 0.2337]}, {"w": "prefer", "b": [0.5365, 0.2133, 0.5843, 0.2337]}, {"w": "to", "b": [0.5908, 0.2133, 0.607, 0.2337]}, {"w": "end", "b": [0.6135, 0.2133, 0.6433, 0.2337]}, {"w": "up", "b": [0.6498, 0.2133, 0.6707, 0.2337]}, {"w": "with", "b": [0.6772, 0.2133, 0.7128, 0.2337]}, {"w": "a", "b": [0.7193, 0.2133, 0.728, 0.2337]}, {"w": "sparse", "b": [0.7345, 0.2133, 0.784, 0.2337]}, {"w": "model", "b": [0.7905, 0.2133, 0.8408, 0.2337]}, {"w": "instead.", "b": [0.1592, 0.2314, 0.2209, 0.2518]}]}, {"id": "b_5", "type": "paragraph", "text": "One trivial way to achieve this is to train the model as usual, then get rid of the tiny weights (set them to 0). However, this will typically not lead to a very sparse model, and it may degrade the model’s performance.", "words": [{"w": "One", "b": [0.1592, 0.2586, 0.1933, 0.279]}, {"w": "trivial", "b": [0.1992, 0.2586, 0.2461, 0.279]}, {"w": "way", "b": [0.252, 0.2586, 0.283, 0.279]}, {"w": "to", "b": [0.2889, 0.2586, 0.305, 0.279]}, {"w": "achieve", "b": [0.3109, 0.2586, 0.3699, 0.279]}, {"w": "this", "b": [0.3758, 0.2586, 0.405, 0.279]}, {"w": "is", "b": [0.4109, 0.2586, 0.4235, 0.279]}, {"w": "to", "b": [0.4293, 0.2586, 0.4455, 0.279]}, {"w": "train", "b": [0.4513, 0.2586, 0.4896, 0.279]}, {"w": "the", "b": [0.4954, 0.2586, 0.5205, 0.279]}, {"w": "model", "b": [0.5264, 0.2586, 0.5767, 0.279]}, {"w": "as", "b": [0.5825, 0.2586, 0.5985, 0.279]}, {"w": "usual,", "b": [0.6043, 0.2586, 0.6509, 0.279]}, {"w": "then", "b": [0.6568, 0.2586, 0.6927, 0.279]}, {"w": "get", "b": [0.6985, 0.2586, 0.7223, 0.279]}, {"w": "rid", "b": [0.7282, 0.2586, 0.7513, 0.279]}, {"w": "of", "b": [0.7571, 0.2586, 0.7731, 0.279]}, {"w": "the", "b": [0.779, 0.2586, 0.8041, 0.279]}, {"w": "tiny", "b": [0.8099, 0.2586, 0.8408, 0.279]}, {"w": "weights", "b": [0.1592, 0.2768, 0.2194, 0.2972]}, {"w": "(set", "b": [0.2254, 0.2768, 0.2541, 0.2972]}, {"w": "them", "b": [0.2601, 0.2768, 0.3014, 0.2972]}, {"w": "to", "b": [0.3074, 0.2768, 0.3236, 0.2972]}, {"w": "0).", "b": [0.3296, 0.2768, 0.3506, 0.2972]}, {"w": "However,", "b": [0.3566, 0.2768, 0.4317, 0.2972]}, {"w": "this", "b": [0.4377, 0.2768, 0.467, 0.2972]}, {"w": "will", "b": [0.473, 0.2768, 0.5019, 0.2972]}, {"w": "typically", "b": [0.508, 0.2768, 0.5751, 0.2972]}, {"w": "not", "b": [0.5811, 0.2768, 0.6081, 0.2972]}, {"w": "lead", "b": [0.6142, 0.2768, 0.6468, 0.2972]}, {"w": "to", "b": [0.6528, 0.2768, 0.669, 0.2972]}, {"w": "a", "b": [0.675, 0.2768, 0.6837, 0.2972]}, {"w": "very", "b": [0.6898, 0.2768, 0.7244, 0.2972]}, {"w": "sparse", "b": [0.7305, 0.2768, 0.7799, 0.2972]}, {"w": "model,", "b": [0.786, 0.2768, 0.8408, 0.2972]}, {"w": "and", "b": [0.1592, 0.2949, 0.1893, 0.3153]}, {"w": "it", "b": [0.1938, 0.2949, 0.2051, 0.3153]}, {"w": "may", "b": [0.2096, 0.2949, 0.2434, 0.3153]}, {"w": "degrade", "b": [0.2479, 0.2949, 0.311, 0.3153]}, {"w": "the", "b": [0.3155, 0.2949, 0.3406, 0.3153]}, {"w": "model’s", "b": [0.3451, 0.2949, 0.4047, 0.3153]}, {"w": "performance.", "b": [0.4092, 0.2949, 0.5159, 0.3153]}]}, {"id": "b_6", "type": "paragraph", "text": "A better option is to apply strong ℓ1 regularization during training, as it pushes the optimizer to zero out as many weights as it can (as discussed in Chapter 4 about Lasso Regression).", "words": [{"w": "A", "b": [0.1592, 0.3221, 0.1729, 0.3425]}, {"w": "better", "b": [0.1795, 0.3221, 0.2259, 0.3425]}, {"w": "option", "b": [0.2324, 0.3221, 0.2852, 0.3425]}, {"w": "is", "b": [0.2918, 0.3221, 0.3044, 0.3425]}, {"w": "to", "b": [0.3109, 0.3221, 0.3271, 0.3425]}, {"w": "apply", "b": [0.3336, 0.3221, 0.3768, 0.3425]}, {"w": "strong", "b": [0.3834, 0.3221, 0.4343, 0.3425]}, {"w": "ℓ1", "b": [0.4408, 0.3221, 0.455, 0.3435]}, {"w": "regularization", "b": [0.4615, 0.3221, 0.5726, 0.3425]}, {"w": "during", "b": [0.5791, 0.3221, 0.6329, 0.3425]}, {"w": "training,", "b": [0.6394, 0.3221, 0.7077, 0.3425]}, {"w": "as", "b": [0.7142, 0.3221, 0.7302, 0.3425]}, {"w": "it", "b": [0.7368, 0.3221, 0.7481, 0.3425]}, {"w": "pushes", "b": [0.7546, 0.3221, 0.8092, 0.3425]}, {"w": "the", "b": [0.8157, 0.3221, 0.8408, 0.3425]}, {"w": "optimizer", "b": [0.1592, 0.3403, 0.2368, 0.3607]}, {"w": "to", "b": [0.2414, 0.3403, 0.2575, 0.3607]}, {"w": "zero", "b": [0.2621, 0.3403, 0.2963, 0.3607]}, {"w": "out", "b": [0.3009, 0.3403, 0.3276, 0.3607]}, {"w": "as", "b": [0.3322, 0.3403, 0.3482, 0.3607]}, {"w": "many", "b": [0.3527, 0.3403, 0.3972, 0.3607]}, {"w": "weights", "b": [0.4017, 0.3403, 0.4619, 0.3607]}, {"w": "as", "b": [0.4665, 0.3403, 0.4825, 0.3607]}, {"w": "it", "b": [0.487, 0.3403, 0.4984, 0.3607]}, {"w": "can", "b": [0.5029, 0.3403, 0.5309, 0.3607]}, {"w": "(as", "b": [0.5355, 0.3403, 0.5583, 0.3607]}, {"w": "discussed", "b": [0.5629, 0.3403, 0.6384, 0.3607]}, {"w": "in", "b": [0.6429, 0.3403, 0.6591, 0.3607]}, {"w": "Chapter", "b": [0.6636, 0.3403, 0.728, 0.3607]}, {"w": "4", "b": [0.7325, 0.3403, 0.742, 0.3607]}, {"w": "about", "b": [0.7467, 0.3403, 0.7922, 0.3607]}, {"w": "Lasso", "b": [0.7967, 0.3403, 0.8407, 0.3607]}, {"w": "Regression).", "b": [0.1592, 0.3584, 0.2573, 0.3788]}]}, {"id": "b_7", "type": "paragraph", "text": "However, in some cases these techniques may remain insufficient. One last option is to apply Dual Averaging, often called Follow The Regularized Leader (FTRL), a techni‐ que proposed by Yurii Nesterov.20 When used with ℓ1 regularization, this technique often leads to very sparse models. Keras implements a variant of FTRL called FTRL- Proximal21 in the FTRL optimizer.", "words": [{"w": "However,", "b": [0.1592, 0.3856, 0.2343, 0.406]}, {"w": "in", "b": [0.2401, 0.3856, 0.2563, 0.406]}, {"w": "some", "b": [0.2621, 0.3856, 0.3042, 0.406]}, {"w": "cases", "b": [0.31, 0.3856, 0.3501, 0.406]}, {"w": "these", "b": [0.3559, 0.3856, 0.3967, 0.406]}, {"w": "techniques", "b": [0.4025, 0.3856, 0.4886, 0.406]}, {"w": "may", "b": [0.4944, 0.3856, 0.5281, 0.406]}, {"w": "remain", "b": [0.5339, 0.3856, 0.5908, 0.406]}, {"w": "insufficient.", "b": [0.5966, 0.3856, 0.6909, 0.406]}, {"w": "One", "b": [0.6967, 0.3856, 0.7308, 0.406]}, {"w": "last", "b": [0.7366, 0.3856, 0.7637, 0.406]}, {"w": "option", "b": [0.7695, 0.3856, 0.8224, 0.406]}, {"w": "is", "b": [0.8282, 0.3856, 0.8408, 0.406]}, {"w": "to", "b": [0.1592, 0.4037, 0.1754, 0.4241]}, {"w": "apply", "b": [0.1803, 0.4037, 0.2235, 0.4241]}, {"w": "Dual", "b": [0.2284, 0.4036, 0.2675, 0.4241]}, {"w": "Averaging,", "b": [0.272, 0.4036, 0.3554, 0.4241]}, {"w": "often", "b": [0.3603, 0.4037, 0.4016, 0.4241]}, {"w": "called", "b": [0.4065, 0.4037, 0.4525, 0.4241]}, {"w": "Follow", "b": [0.4574, 0.4036, 0.5084, 0.4241]}, {"w": "The", "b": [0.5133, 0.4036, 0.5418, 0.4241]}, {"w": "Regularized", "b": [0.5467, 0.4036, 0.6386, 0.4241]}, {"w": "Leader", "b": [0.6435, 0.4036, 0.6967, 0.4241]}, {"w": "(FTRL),", "b": [0.7016, 0.4037, 0.7656, 0.4241]}, {"w": "a", "b": [0.7705, 0.4037, 0.7792, 0.4241]}, {"w": "techni‐", "b": [0.7841, 0.4037, 0.8408, 0.4241]}, {"w": "que", "b": [0.1592, 0.4219, 0.1883, 0.4423]}, {"w": "proposed", "b": [0.195, 0.4219, 0.2696, 0.4423]}, {"w": "by", "b": [0.2762, 0.4219, 0.2954, 0.4423]}, {"w": "Yurii", "b": [0.3021, 0.4219, 0.3412, 0.4423]}, {"w": "Nesterov.20", "b": [0.3479, 0.4219, 0.435, 0.4423]}, {"w": "When", "b": [0.4416, 0.4219, 0.4908, 0.4423]}, {"w": "used", "b": [0.4975, 0.4219, 0.5342, 0.4423]}, {"w": "with", "b": [0.5408, 0.4219, 0.5764, 0.4423]}, {"w": "ℓ1", "b": [0.5831, 0.4219, 0.5972, 0.4433]}, {"w": "regularization,", "b": [0.6039, 0.4219, 0.7194, 0.4423]}, {"w": "this", "b": [0.7261, 0.4219, 0.7554, 0.4423]}, {"w": "technique", "b": [0.762, 0.4219, 0.8408, 0.4423]}, {"w": "often", "b": [0.1592, 0.44, 0.2006, 0.4604]}, {"w": "leads", "b": [0.2064, 0.44, 0.2463, 0.4604]}, {"w": "to", "b": [0.2522, 0.44, 0.2683, 0.4604]}, {"w": "very", "b": [0.2742, 0.44, 0.3089, 0.4604]}, {"w": "sparse", "b": [0.3147, 0.44, 0.3642, 0.4604]}, {"w": "models.", "b": [0.37, 0.44, 0.4321, 0.4604]}, {"w": "Keras", "b": [0.438, 0.44, 0.4826, 0.4604]}, {"w": "implements", "b": [0.4885, 0.44, 0.582, 0.4604]}, {"w": "a", "b": [0.5878, 0.44, 0.5966, 0.4604]}, {"w": "variant", "b": [0.6024, 0.44, 0.6582, 0.4604]}, {"w": "of", "b": [0.6641, 0.44, 0.6801, 0.4604]}, {"w": "FTRL", "b": [0.6859, 0.44, 0.7316, 0.4604]}, {"w": "called", "b": [0.7375, 0.44, 0.7835, 0.4604]}, {"w": "FTRL-", "b": [0.7894, 0.4398, 0.8408, 0.4604]}, {"w": "Proximal21", "b": [0.1592, 0.4588, 0.2419, 0.4794]}, {"w": "in", "b": [0.2464, 0.459, 0.2626, 0.4794]}, {"w": "the", "b": [0.2671, 0.459, 0.2922, 0.4794]}, {"w": "FTRL", "b": [0.2967, 0.4621, 0.3344, 0.4764]}, {"w": "optimizer.", "b": [0.3389, 0.459, 0.4197, 0.4794]}]}, {"id": "b_8", "type": "paragraph", "text": "Learning Rate Scheduling", "words": [{"w": "Learning", "b": [0.1429, 0.5092, 0.2344, 0.5377]}, {"w": "Rate", "b": [0.2393, 0.5092, 0.2869, 0.5377]}, {"w": "Scheduling", "b": [0.2918, 0.5092, 0.4059, 0.5377]}]}, {"id": "b_9", "type": "paragraph", "text": "Finding a good learning rate can be tricky. If you set it way too high, training may actually diverge (as we discussed in Chapter 4). If you set it too low, training will eventually converge to the optimum, but it will take a very long time. If you set it slightly too high, it will make progress very quickly at first, but it will end up dancing around the optimum, never really settling down. If you have a limited computing budget, you may have to interrupt training before it has converged properly, yielding a suboptimal solution (see Figure 11-8).", "words": [{"w": "Finding", "b": [0.1429, 0.5436, 0.2086, 0.5651]}, {"w": "a", "b": [0.2156, 0.5436, 0.2247, 0.5651]}, {"w": "good", "b": [0.2317, 0.5436, 0.2737, 0.5651]}, {"w": "learning", "b": [0.2807, 0.5436, 0.3499, 0.5651]}, {"w": "rate", "b": [0.3569, 0.5436, 0.3886, 0.5651]}, {"w": "can", "b": [0.3956, 0.5436, 0.4249, 0.5651]}, {"w": "be", "b": [0.4319, 0.5436, 0.4513, 0.5651]}, {"w": "tricky.", "b": [0.4583, 0.5436, 0.51, 0.5651]}, {"w": "If", "b": [0.517, 0.5436, 0.5302, 0.5651]}, {"w": "you", "b": [0.5372, 0.5436, 0.5685, 0.5651]}, {"w": "set", "b": [0.5755, 0.5436, 0.5983, 0.5651]}, {"w": "it", "b": [0.6053, 0.5436, 0.6173, 0.5651]}, {"w": "way", "b": [0.6243, 0.5436, 0.6569, 0.5651]}, {"w": "too", "b": [0.6639, 0.5436, 0.6915, 0.5651]}, {"w": "high,", "b": [0.6985, 0.5436, 0.7408, 0.5651]}, {"w": "training", "b": [0.7478, 0.5436, 0.8147, 0.5651]}, {"w": "may", "b": [0.8218, 0.5436, 0.8571, 0.5651]}, {"w": "actually", "b": [0.1429, 0.5627, 0.2075, 0.5841]}, {"w": "diverge", "b": [0.2153, 0.5627, 0.2767, 0.5841]}, {"w": "(as", "b": [0.2846, 0.5627, 0.3086, 0.5841]}, {"w": "we", "b": [0.3164, 0.5627, 0.3396, 0.5841]}, {"w": "discussed", "b": [0.3474, 0.5627, 0.4267, 0.5841]}, {"w": "in", "b": [0.4345, 0.5627, 0.4515, 0.5841]}, {"w": "Chapter", "b": [0.4593, 0.5627, 0.5269, 0.5841]}, {"w": "4).", "b": [0.5348, 0.5627, 0.5567, 0.5841]}, {"w": "If", "b": [0.5646, 0.5627, 0.5778, 0.5841]}, {"w": "you", "b": [0.5857, 0.5627, 0.6169, 0.5841]}, {"w": "set", "b": [0.6248, 0.5627, 0.6476, 0.5841]}, {"w": "it", "b": [0.6555, 0.5627, 0.6674, 0.5841]}, {"w": "too", "b": [0.6753, 0.5627, 0.7029, 0.5841]}, {"w": "low,", "b": [0.7107, 0.5627, 0.7441, 0.5841]}, {"w": "training", "b": [0.752, 0.5627, 0.8189, 0.5841]}, {"w": "will", "b": [0.8267, 0.5627, 0.8571, 0.5841]}, {"w": "eventually", "b": [0.1428, 0.5817, 0.2279, 0.6032]}, {"w": "converge", "b": [0.2353, 0.5817, 0.3104, 0.6032]}, {"w": "to", "b": [0.3178, 0.5817, 0.3348, 0.6032]}, {"w": "the", "b": [0.3422, 0.5817, 0.3685, 0.6032]}, {"w": "optimum,", "b": [0.3759, 0.5817, 0.4589, 0.6032]}, {"w": "but", "b": [0.4663, 0.5817, 0.4943, 0.6032]}, {"w": "it", "b": [0.5017, 0.5817, 0.5137, 0.6032]}, {"w": "will", "b": [0.521, 0.5817, 0.5514, 0.6032]}, {"w": "take", "b": [0.5588, 0.5817, 0.5935, 0.6032]}, {"w": "a", "b": [0.6009, 0.5817, 0.6101, 0.6032]}, {"w": "very", "b": [0.6174, 0.5817, 0.6538, 0.6032]}, {"w": "long", "b": [0.6612, 0.5817, 0.6983, 0.6032]}, {"w": "time.", "b": [0.7057, 0.5817, 0.7483, 0.6032]}, {"w": "If", "b": [0.7557, 0.5817, 0.7689, 0.6032]}, {"w": "you", "b": [0.7763, 0.5817, 0.8076, 0.6032]}, {"w": "set", "b": [0.815, 0.5817, 0.8378, 0.6032]}, {"w": "it", "b": [0.8452, 0.5817, 0.8571, 0.6032]}, {"w": "slightly", "b": [0.1429, 0.6008, 0.203, 0.6222]}, {"w": "too", "b": [0.2083, 0.6008, 0.2359, 0.6222]}, {"w": "high,", "b": [0.2411, 0.6008, 0.2835, 0.6222]}, {"w": "it", "b": [0.2887, 0.6008, 0.3006, 0.6222]}, {"w": "will", "b": [0.3059, 0.6008, 0.3363, 0.6222]}, {"w": "make", "b": [0.3415, 0.6008, 0.3869, 0.6222]}, {"w": "progress", "b": [0.3922, 0.6008, 0.4631, 0.6222]}, {"w": "very", "b": [0.4683, 0.6008, 0.5047, 0.6222]}, {"w": "quickly", "b": [0.5099, 0.6008, 0.5712, 0.6222]}, {"w": "at", "b": [0.5765, 0.6008, 0.5916, 0.6222]}, {"w": "first,", "b": [0.5968, 0.6008, 0.635, 0.6222]}, {"w": "but", "b": [0.6403, 0.6008, 0.6683, 0.6222]}, {"w": "it", "b": [0.6735, 0.6008, 0.6855, 0.6222]}, {"w": "will", "b": [0.6907, 0.6008, 0.7211, 0.6222]}, {"w": "end", "b": [0.7263, 0.6008, 0.7576, 0.6222]}, {"w": "up", "b": [0.7628, 0.6008, 0.7848, 0.6222]}, {"w": "dancing", "b": [0.7901, 0.6008, 0.8571, 0.6222]}, {"w": "around", "b": [0.1429, 0.6198, 0.2038, 0.6413]}, {"w": "the", "b": [0.2118, 0.6198, 0.2381, 0.6413]}, {"w": "optimum,", "b": [0.2461, 0.6198, 0.3291, 0.6413]}, {"w": "never", "b": [0.337, 0.6198, 0.3835, 0.6413]}, {"w": "really", "b": [0.3915, 0.6198, 0.4373, 0.6413]}, {"w": "settling", "b": [0.4453, 0.6198, 0.5065, 0.6413]}, {"w": "down.", "b": [0.5144, 0.6198, 0.5665, 0.6413]}, {"w": "If", "b": [0.5744, 0.6198, 0.5877, 0.6413]}, {"w": "you", "b": [0.5957, 0.6198, 0.6269, 0.6413]}, {"w": "have", "b": [0.6349, 0.6198, 0.6733, 0.6413]}, {"w": "a", "b": [0.6812, 0.6198, 0.6904, 0.6413]}, {"w": "limited", "b": [0.6983, 0.6198, 0.758, 0.6413]}, {"w": "computing", "b": [0.766, 0.6198, 0.8571, 0.6413]}, {"w": "budget,", "b": [0.1429, 0.6389, 0.2052, 0.6603]}, {"w": "you", "b": [0.2108, 0.6389, 0.242, 0.6603]}, {"w": "may", "b": [0.2476, 0.6389, 0.283, 0.6603]}, {"w": "have", "b": [0.2885, 0.6389, 0.3269, 0.6603]}, {"w": "to", "b": [0.3325, 0.6389, 0.3495, 0.6603]}, {"w": "interrupt", "b": [0.355, 0.6389, 0.4306, 0.6603]}, {"w": "training", "b": [0.4362, 0.6389, 0.5031, 0.6603]}, {"w": "before", "b": [0.5087, 0.6389, 0.5615, 0.6603]}, {"w": "it", "b": [0.567, 0.6389, 0.579, 0.6603]}, {"w": "has", "b": [0.5845, 0.6389, 0.6124, 0.6603]}, {"w": "converged", "b": [0.618, 0.6389, 0.7042, 0.6603]}, {"w": "properly,", "b": [0.7097, 0.6389, 0.7846, 0.6603]}, {"w": "yielding", "b": [0.7901, 0.6389, 0.8571, 0.6603]}, {"w": "a", "b": [0.1429, 0.6579, 0.152, 0.6793]}, {"w": "suboptimal", "b": [0.1567, 0.6579, 0.251, 0.6793]}, {"w": "solution", "b": [0.2557, 0.6579, 0.3243, 0.6793]}, {"w": "(see", "b": [0.329, 0.6579, 0.3616, 0.6793]}, {"w": "Figure", "b": [0.3663, 0.6579, 0.4203, 0.6793]}, {"w": "11-8).", "b": [0.425, 0.6579, 0.4744, 0.6793]}]}, {"id": "b_10", "type": "paragraph", "text": "352 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "352", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2746, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 379, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 11-8. Learning curves for various learning rates η", "words": [{"w": "Figure", "b": [0.1429, 0.2865, 0.1943, 0.3081]}, {"w": "11-8.", "b": [0.1991, 0.2865, 0.2407, 0.3081]}, {"w": "Learning", "b": [0.2455, 0.2865, 0.3183, 0.3081]}, {"w": "curves", "b": [0.323, 0.2865, 0.3743, 0.3081]}, {"w": "for", "b": [0.379, 0.2865, 0.4017, 0.3081]}, {"w": "various", "b": [0.4065, 0.2865, 0.4668, 0.3081]}, {"w": "learning", "b": [0.4715, 0.2865, 0.5383, 0.3081]}, {"w": "rates", "b": [0.543, 0.2865, 0.5814, 0.3081]}, {"w": "η", "b": [0.5861, 0.2865, 0.5968, 0.3081]}]}, {"id": "b_1", "type": "paragraph", "text": "As we discussed in Chapter 10, one approach is to start with a large learning rate, and divide it by 3 until the training algorithm stops diverging. You will not be too far from the optimal learning rate, which will learn quickly and converge to good solu‐ tion.", "words": [{"w": "As", "b": [0.1429, 0.3239, 0.1649, 0.3453]}, {"w": "we", "b": [0.1699, 0.3239, 0.193, 0.3453]}, {"w": "discussed", "b": [0.198, 0.3239, 0.2773, 0.3453]}, {"w": "in", "b": [0.2823, 0.3239, 0.2992, 0.3453]}, {"w": "Chapter", "b": [0.3042, 0.3239, 0.3718, 0.3453]}, {"w": "10,", "b": [0.3765, 0.3239, 0.4016, 0.3453]}, {"w": "one", "b": [0.4066, 0.3239, 0.4374, 0.3453]}, {"w": "approach", "b": [0.4424, 0.3239, 0.5204, 0.3453]}, {"w": "is", "b": [0.5254, 0.3239, 0.5387, 0.3453]}, {"w": "to", "b": [0.5437, 0.3239, 0.5606, 0.3453]}, {"w": "start", "b": [0.5656, 0.3239, 0.6029, 0.3453]}, {"w": "with", "b": [0.6079, 0.3239, 0.6452, 0.3453]}, {"w": "a", "b": [0.6502, 0.3239, 0.6593, 0.3453]}, {"w": "large", "b": [0.6643, 0.3239, 0.7051, 0.3453]}, {"w": "learning", "b": [0.7101, 0.3239, 0.7792, 0.3453]}, {"w": "rate,", "b": [0.7842, 0.3239, 0.8206, 0.3453]}, {"w": "and", "b": [0.8256, 0.3239, 0.8571, 0.3453]}, {"w": "divide", "b": [0.1429, 0.3429, 0.1945, 0.3643]}, {"w": "it", "b": [0.2023, 0.3429, 0.2143, 0.3643]}, {"w": "by", "b": [0.2221, 0.3429, 0.2422, 0.3643]}, {"w": "3", "b": [0.25, 0.3429, 0.26, 0.3643]}, {"w": "until", "b": [0.2678, 0.3429, 0.3071, 0.3643]}, {"w": "the", "b": [0.3148, 0.3429, 0.3412, 0.3643]}, {"w": "training", "b": [0.349, 0.3429, 0.4159, 0.3643]}, {"w": "algorithm", "b": [0.4237, 0.3429, 0.5064, 0.3643]}, {"w": "stops", "b": [0.5141, 0.3429, 0.5573, 0.3643]}, {"w": "diverging.", "b": [0.5651, 0.3429, 0.6492, 0.3643]}, {"w": "You", "b": [0.657, 0.3429, 0.6893, 0.3643]}, {"w": "will", "b": [0.6971, 0.3429, 0.7275, 0.3643]}, {"w": "not", "b": [0.7353, 0.3429, 0.7637, 0.3643]}, {"w": "be", "b": [0.7715, 0.3429, 0.7909, 0.3643]}, {"w": "too", "b": [0.7987, 0.3429, 0.8263, 0.3643]}, {"w": "far", "b": [0.8341, 0.3429, 0.8571, 0.3643]}, {"w": "from", "b": [0.1429, 0.3619, 0.1844, 0.3834]}, {"w": "the", "b": [0.1908, 0.3619, 0.2172, 0.3834]}, {"w": "optimal", "b": [0.2236, 0.3619, 0.2885, 0.3834]}, {"w": "learning", "b": [0.2949, 0.3619, 0.364, 0.3834]}, {"w": "rate,", "b": [0.3704, 0.3619, 0.4069, 0.3834]}, {"w": "which", "b": [0.4133, 0.3619, 0.4642, 0.3834]}, {"w": "will", "b": [0.4706, 0.3619, 0.501, 0.3834]}, {"w": "learn", "b": [0.5074, 0.3619, 0.5498, 0.3834]}, {"w": "quickly", "b": [0.5562, 0.3619, 0.6174, 0.3834]}, {"w": "and", "b": [0.6238, 0.3619, 0.6554, 0.3834]}, {"w": "converge", "b": [0.6618, 0.3619, 0.737, 0.3834]}, {"w": "to", "b": [0.7433, 0.3619, 0.7603, 0.3834]}, {"w": "good", "b": [0.7667, 0.3619, 0.8087, 0.3834]}, {"w": "solu‐", "b": [0.8151, 0.3619, 0.8571, 0.3834]}, {"w": "tion.", "b": [0.1429, 0.381, 0.1816, 0.4024]}]}, {"id": "b_2", "type": "paragraph", "text": "However, you can do better than a constant learning rate: if you start with a high learning rate and then reduce it once it stops making fast progress, you can reach a good solution faster than with the optimal constant learning rate. There are many dif‐ ferent strategies to reduce the learning rate during training. These strategies are called learning schedules (we briefly introduced this concept in Chapter 4), the most com‐ mon of which are:", "words": [{"w": "However,", "b": [0.1429, 0.4091, 0.2217, 0.4305]}, {"w": "you", "b": [0.2295, 0.4091, 0.2607, 0.4305]}, {"w": "can", "b": [0.2685, 0.4091, 0.2978, 0.4305]}, {"w": "do", "b": [0.3055, 0.4091, 0.3272, 0.4305]}, {"w": "better", "b": [0.3349, 0.4091, 0.3836, 0.4305]}, {"w": "than", "b": [0.3914, 0.4091, 0.4294, 0.4305]}, {"w": "a", "b": [0.4371, 0.4091, 0.4463, 0.4305]}, {"w": "constant", "b": [0.454, 0.4091, 0.5254, 0.4305]}, {"w": "learning", "b": [0.5331, 0.4091, 0.6022, 0.4305]}, {"w": "rate:", "b": [0.61, 0.4091, 0.6464, 0.4305]}, {"w": "if", "b": [0.6542, 0.4091, 0.6659, 0.4305]}, {"w": "you", "b": [0.6736, 0.4091, 0.7049, 0.4305]}, {"w": "start", "b": [0.7126, 0.4091, 0.7499, 0.4305]}, {"w": "with", "b": [0.7576, 0.4091, 0.7949, 0.4305]}, {"w": "a", "b": [0.8027, 0.4091, 0.8118, 0.4305]}, {"w": "high", "b": [0.8196, 0.4091, 0.8572, 0.4305]}, {"w": "learning", "b": [0.1429, 0.4282, 0.212, 0.4496]}, {"w": "rate", "b": [0.2185, 0.4282, 0.2502, 0.4496]}, {"w": "and", "b": [0.2567, 0.4282, 0.2882, 0.4496]}, {"w": "then", "b": [0.2947, 0.4282, 0.3324, 0.4496]}, {"w": "reduce", "b": [0.3389, 0.4282, 0.3953, 0.4496]}, {"w": "it", "b": [0.4018, 0.4282, 0.4137, 0.4496]}, {"w": "once", "b": [0.4202, 0.4282, 0.4599, 0.4496]}, {"w": "it", "b": [0.4664, 0.4282, 0.4783, 0.4496]}, {"w": "stops", "b": [0.4848, 0.4282, 0.528, 0.4496]}, {"w": "making", "b": [0.5345, 0.4282, 0.5978, 0.4496]}, {"w": "fast", "b": [0.6043, 0.4282, 0.6336, 0.4496]}, {"w": "progress,", "b": [0.6401, 0.4282, 0.7157, 0.4496]}, {"w": "you", "b": [0.7222, 0.4282, 0.7535, 0.4496]}, {"w": "can", "b": [0.76, 0.4282, 0.7893, 0.4496]}, {"w": "reach", "b": [0.7958, 0.4282, 0.8415, 0.4496]}, {"w": "a", "b": [0.848, 0.4282, 0.8571, 0.4496]}, {"w": "good", "b": [0.1429, 0.4472, 0.1849, 0.4686]}, {"w": "solution", "b": [0.1896, 0.4472, 0.2582, 0.4686]}, {"w": "faster", "b": [0.263, 0.4472, 0.3089, 0.4686]}, {"w": "than", "b": [0.3137, 0.4472, 0.3517, 0.4686]}, {"w": "with", "b": [0.3565, 0.4472, 0.3938, 0.4686]}, {"w": "the", "b": [0.3986, 0.4472, 0.425, 0.4686]}, {"w": "optimal", "b": [0.4297, 0.4472, 0.4947, 0.4686]}, {"w": "constant", "b": [0.4995, 0.4472, 0.5708, 0.4686]}, {"w": "learning", "b": [0.5756, 0.4472, 0.6447, 0.4686]}, {"w": "rate.", "b": [0.6495, 0.4472, 0.686, 0.4686]}, {"w": "There", "b": [0.6908, 0.4472, 0.7402, 0.4686]}, {"w": "are", "b": [0.745, 0.4472, 0.7707, 0.4686]}, {"w": "many", "b": [0.7755, 0.4472, 0.8222, 0.4686]}, {"w": "dif‐", "b": [0.827, 0.4472, 0.8571, 0.4686]}, {"w": "ferent", "b": [0.1428, 0.4663, 0.1918, 0.4877]}, {"w": "strategies", "b": [0.1967, 0.4663, 0.2742, 0.4877]}, {"w": "to", "b": [0.279, 0.4663, 0.296, 0.4877]}, {"w": "reduce", "b": [0.3009, 0.4663, 0.3572, 0.4877]}, {"w": "the", "b": [0.362, 0.4663, 0.3884, 0.4877]}, {"w": "learning", "b": [0.3932, 0.4663, 0.4623, 0.4877]}, {"w": "rate", "b": [0.4672, 0.4663, 0.4989, 0.4877]}, {"w": "during", "b": [0.5037, 0.4663, 0.5603, 0.4877]}, {"w": "training.", "b": [0.5651, 0.4663, 0.6368, 0.4877]}, {"w": "These", "b": [0.6416, 0.4663, 0.691, 0.4877]}, {"w": "strategies", "b": [0.6958, 0.4663, 0.7733, 0.4877]}, {"w": "are", "b": [0.7782, 0.4663, 0.8039, 0.4877]}, {"w": "called", "b": [0.8088, 0.4663, 0.8571, 0.4877]}, {"w": "learning", "b": [0.1429, 0.4851, 0.2096, 0.5067]}, {"w": "schedules", "b": [0.2164, 0.4851, 0.2915, 0.5067]}, {"w": "(we", "b": [0.2983, 0.4853, 0.3286, 0.5067]}, {"w": "briefly", "b": [0.3354, 0.4853, 0.3891, 0.5067]}, {"w": "introduced", "b": [0.3959, 0.4853, 0.488, 0.5067]}, {"w": "this", "b": [0.4947, 0.4853, 0.5254, 0.5067]}, {"w": "concept", "b": [0.5322, 0.4853, 0.598, 0.5067]}, {"w": "in", "b": [0.6048, 0.4853, 0.6218, 0.5067]}, {"w": "Chapter", "b": [0.6285, 0.4853, 0.6961, 0.5067]}, {"w": "4),", "b": [0.7029, 0.4853, 0.7249, 0.5067]}, {"w": "the", "b": [0.7316, 0.4853, 0.758, 0.5067]}, {"w": "most", "b": [0.7648, 0.4853, 0.8065, 0.5067]}, {"w": "com‐", "b": [0.8132, 0.4853, 0.8572, 0.5067]}, {"w": "mon", "b": [0.1429, 0.5044, 0.1819, 0.5258]}, {"w": "of", "b": [0.1867, 0.5044, 0.2035, 0.5258]}, {"w": "which", "b": [0.2082, 0.5044, 0.2591, 0.5258]}, {"w": "are:", "b": [0.2638, 0.5044, 0.2943, 0.5258]}]}, {"id": "b_3", "type": "paragraph", "text": "Power scheduling", "words": [{"w": "Power", "b": [0.1429, 0.5338, 0.1933, 0.5554]}, {"w": "scheduling", "b": [0.198, 0.5338, 0.2828, 0.5554]}]}, {"id": "b_4", "type": "paragraph", "text": "Set the learning rate to a function of the iteration number t: η(t) = η0 / (1 + t/k)c. The initial learning rate η0, the power c (typically set to 1) and the steps s are hyperparameters. The learning rate drops at each step, and after s steps it is down to η0 / 2. After s more steps, it is down to η0 / 3. Then down to η0 / 4, then η0 / 5, and so on. As you can see, this schedule first drops quickly, then more and more slowly. Of course, this requires tuning η0, s (and possibly c).", "words": [{"w": "Set", "b": [0.1786, 0.553, 0.2037, 0.5744]}, {"w": "the", "b": [0.2093, 0.553, 0.2356, 0.5744]}, {"w": "learning", "b": [0.2412, 0.553, 0.3103, 0.5744]}, {"w": "rate", "b": [0.3159, 0.553, 0.3476, 0.5744]}, {"w": "to", "b": [0.3532, 0.553, 0.3702, 0.5744]}, {"w": "a", "b": [0.3758, 0.553, 0.385, 0.5744]}, {"w": "function", "b": [0.3906, 0.553, 0.462, 0.5744]}, {"w": "of", "b": [0.4676, 0.553, 0.4844, 0.5744]}, {"w": "the", "b": [0.49, 0.553, 0.5163, 0.5744]}, {"w": "iteration", "b": [0.5219, 0.553, 0.5931, 0.5744]}, {"w": "number", "b": [0.5987, 0.553, 0.665, 0.5744]}, {"w": "t:", "b": [0.6706, 0.5528, 0.6818, 0.5744]}, {"w": "η(t)", "b": [0.6874, 0.5528, 0.7188, 0.5744]}, {"w": "=", "b": [0.7244, 0.553, 0.7365, 0.5744]}, {"w": "η0", "b": [0.7421, 0.5528, 0.7587, 0.5753]}, {"w": "/", "b": [0.7643, 0.553, 0.7712, 0.5744]}, {"w": "(1", "b": [0.7768, 0.553, 0.794, 0.5744]}, {"w": "+", "b": [0.7996, 0.553, 0.8117, 0.5744]}, {"w": "t/k)c.", "b": [0.8173, 0.5528, 0.8571, 0.5744]}, {"w": "The", "b": [0.1786, 0.5721, 0.2114, 0.5935]}, {"w": "initial", "b": [0.219, 0.5721, 0.2679, 0.5935]}, {"w": "learning", "b": [0.2755, 0.5721, 0.3446, 0.5935]}, {"w": "rate", "b": [0.3522, 0.5721, 0.3839, 0.5935]}, {"w": "η0,", "b": [0.3914, 0.5719, 0.4128, 0.5944]}, {"w": "the", "b": [0.4204, 0.5721, 0.4467, 0.5935]}, {"w": "power", "b": [0.4543, 0.5721, 0.5067, 0.5935]}, {"w": "c", "b": [0.5142, 0.5719, 0.5222, 0.5935]}, {"w": "(typically", "b": [0.5298, 0.5721, 0.6075, 0.5935]}, {"w": "set", "b": [0.615, 0.5721, 0.6379, 0.5935]}, {"w": "to", "b": [0.6455, 0.5721, 0.6624, 0.5935]}, {"w": "1)", "b": [0.67, 0.5721, 0.6872, 0.5935]}, {"w": "and", "b": [0.6948, 0.5721, 0.7263, 0.5935]}, {"w": "the", "b": [0.7339, 0.5721, 0.7603, 0.5935]}, {"w": "steps", "b": [0.7678, 0.5721, 0.8092, 0.5935]}, {"w": "s", "b": [0.8168, 0.5719, 0.8238, 0.5935]}, {"w": "are", "b": [0.8314, 0.5721, 0.8571, 0.5935]}, {"w": "hyperparameters.", "b": [0.1786, 0.5911, 0.3245, 0.6125]}, {"w": "The", "b": [0.3294, 0.5911, 0.3623, 0.6125]}, {"w": "learning", "b": [0.3672, 0.5911, 0.4363, 0.6125]}, {"w": "rate", "b": [0.4413, 0.5911, 0.473, 0.6125]}, {"w": "drops", "b": [0.478, 0.5911, 0.5259, 0.6125]}, {"w": "at", "b": [0.5308, 0.5911, 0.5459, 0.6125]}, {"w": "each", "b": [0.5509, 0.5911, 0.5888, 0.6125]}, {"w": "step,", "b": [0.5938, 0.5911, 0.6317, 0.6125]}, {"w": "and", "b": [0.6367, 0.5911, 0.6682, 0.6125]}, {"w": "after", "b": [0.6732, 0.5911, 0.7114, 0.6125]}, {"w": "s", "b": [0.7164, 0.5909, 0.7234, 0.6125]}, {"w": "steps", "b": [0.7284, 0.5911, 0.7698, 0.6125]}, {"w": "it", "b": [0.7748, 0.5911, 0.7867, 0.6125]}, {"w": "is", "b": [0.7917, 0.5911, 0.8049, 0.6125]}, {"w": "down", "b": [0.8099, 0.5911, 0.8572, 0.6125]}, {"w": "to", "b": [0.1786, 0.6102, 0.1955, 0.6316]}, {"w": "η0", "b": [0.201, 0.61, 0.2177, 0.6325]}, {"w": "/", "b": [0.2232, 0.6102, 0.23, 0.6316]}, {"w": "2.", "b": [0.2355, 0.6102, 0.2503, 0.6316]}, {"w": "After", "b": [0.2558, 0.6102, 0.2993, 0.6316]}, {"w": "s", "b": [0.3048, 0.61, 0.3118, 0.6316]}, {"w": "more", "b": [0.3173, 0.6102, 0.3616, 0.6316]}, {"w": "steps,", "b": [0.3671, 0.6102, 0.4132, 0.6316]}, {"w": "it", "b": [0.4187, 0.6102, 0.4307, 0.6316]}, {"w": "is", "b": [0.4362, 0.6102, 0.4494, 0.6316]}, {"w": "down", "b": [0.4549, 0.6102, 0.5022, 0.6316]}, {"w": "to", "b": [0.5077, 0.6102, 0.5247, 0.6316]}, {"w": "η0", "b": [0.5302, 0.61, 0.5468, 0.6325]}, {"w": "/", "b": [0.5523, 0.6102, 0.5592, 0.6316]}, {"w": "3.", "b": [0.5647, 0.6102, 0.5794, 0.6316]}, {"w": "Then", "b": [0.5849, 0.6102, 0.6292, 0.6316]}, {"w": "down", "b": [0.6347, 0.6102, 0.6819, 0.6316]}, {"w": "to", "b": [0.6874, 0.6102, 0.7044, 0.6316]}, {"w": "η0", "b": [0.7099, 0.61, 0.7265, 0.6325]}, {"w": "/", "b": [0.732, 0.6102, 0.7389, 0.6316]}, {"w": "4,", "b": [0.7444, 0.6102, 0.7592, 0.6316]}, {"w": "then", "b": [0.7647, 0.6102, 0.8024, 0.6316]}, {"w": "η0", "b": [0.8079, 0.61, 0.8245, 0.6325]}, {"w": "/", "b": [0.83, 0.6102, 0.8369, 0.6316]}, {"w": "5,", "b": [0.8424, 0.6102, 0.8571, 0.6316]}, {"w": "and", "b": [0.1786, 0.6292, 0.2101, 0.6506]}, {"w": "so", "b": [0.2156, 0.6292, 0.2339, 0.6506]}, {"w": "on.", "b": [0.2393, 0.6292, 0.2661, 0.6506]}, {"w": "As", "b": [0.2716, 0.6292, 0.2936, 0.6506]}, {"w": "you", "b": [0.2991, 0.6292, 0.3304, 0.6506]}, {"w": "can", "b": [0.3359, 0.6292, 0.3652, 0.6506]}, {"w": "see,", "b": [0.3707, 0.6292, 0.4008, 0.6506]}, {"w": "this", "b": [0.4063, 0.6292, 0.437, 0.6506]}, {"w": "schedule", "b": [0.4425, 0.6292, 0.5151, 0.6506]}, {"w": "first", "b": [0.5206, 0.6292, 0.554, 0.6506]}, {"w": "drops", "b": [0.5595, 0.6292, 0.6074, 0.6506]}, {"w": "quickly,", "b": [0.6129, 0.6292, 0.6774, 0.6506]}, {"w": "then", "b": [0.6829, 0.6292, 0.7206, 0.6506]}, {"w": "more", "b": [0.7261, 0.6292, 0.7704, 0.6506]}, {"w": "and", "b": [0.7759, 0.6292, 0.8074, 0.6506]}, {"w": "more", "b": [0.8129, 0.6292, 0.8571, 0.6506]}, {"w": "slowly.", "b": [0.1786, 0.6483, 0.2344, 0.6697]}, {"w": "Of", "b": [0.2392, 0.6483, 0.2609, 0.6697]}, {"w": "course,", "b": [0.2656, 0.6483, 0.3251, 0.6697]}, {"w": "this", "b": [0.3298, 0.6483, 0.3605, 0.6697]}, {"w": "requires", "b": [0.3653, 0.6483, 0.4334, 0.6697]}, {"w": "tuning", "b": [0.4381, 0.6483, 0.4936, 0.6697]}, {"w": "η0,", "b": [0.4984, 0.6481, 0.5197, 0.6706]}, {"w": "s", "b": [0.5245, 0.6481, 0.5315, 0.6697]}, {"w": "(and", "b": [0.5362, 0.6483, 0.575, 0.6697]}, {"w": "possibly", "b": [0.5797, 0.6483, 0.6475, 0.6697]}, {"w": "c).", "b": [0.6523, 0.6481, 0.6722, 0.6697]}]}, {"id": "b_5", "type": "paragraph", "text": "Exponential scheduling", "words": [{"w": "Exponential", "b": [0.1429, 0.6777, 0.2412, 0.6993]}, {"w": "scheduling", "b": [0.246, 0.6777, 0.3307, 0.6993]}]}, {"id": "b_6", "type": "paragraph", "text": "Set the learning rate to: η(t) = η0 0.1t/s. The learning rate will gradually drop by a factor of 10 every s steps. While power scheduling reduces the learning rate more and more slowly, exponential scheduling keeps slashing it by a factor of 10 every s steps.", "words": [{"w": "Set", "b": [0.1786, 0.6969, 0.2036, 0.7184]}, {"w": "the", "b": [0.2094, 0.6969, 0.2357, 0.7184]}, {"w": "learning", "b": [0.2414, 0.6969, 0.3105, 0.7184]}, {"w": "rate", "b": [0.3162, 0.6969, 0.3479, 0.7184]}, {"w": "to:", "b": [0.3536, 0.6969, 0.3754, 0.7184]}, {"w": "η(t)", "b": [0.3811, 0.6967, 0.4125, 0.7184]}, {"w": "=", "b": [0.4182, 0.6969, 0.4303, 0.7184]}, {"w": "η0", "b": [0.436, 0.6967, 0.4526, 0.7192]}, {"w": "0.1t/s.", "b": [0.4583, 0.6969, 0.4999, 0.7184]}, {"w": "The", "b": [0.5056, 0.6969, 0.5384, 0.7184]}, {"w": "learning", "b": [0.5442, 0.6969, 0.6133, 0.7184]}, {"w": "rate", "b": [0.619, 0.6969, 0.6507, 0.7184]}, {"w": "will", "b": [0.6564, 0.6969, 0.6868, 0.7184]}, {"w": "gradually", "b": [0.6925, 0.6969, 0.7704, 0.7184]}, {"w": "drop", "b": [0.7761, 0.6969, 0.8164, 0.7184]}, {"w": "by", "b": [0.8221, 0.6969, 0.8423, 0.7184]}, {"w": "a", "b": [0.848, 0.6969, 0.8571, 0.7184]}, {"w": "factor", "b": [0.1786, 0.716, 0.2274, 0.7374]}, {"w": "of", "b": [0.2324, 0.716, 0.2492, 0.7374]}, {"w": "10", "b": [0.2542, 0.716, 0.2742, 0.7374]}, {"w": "every", "b": [0.2792, 0.716, 0.3245, 0.7374]}, {"w": "s", "b": [0.3295, 0.7158, 0.3365, 0.7374]}, {"w": "steps.", "b": [0.3415, 0.716, 0.3877, 0.7374]}, {"w": "While", "b": [0.3927, 0.716, 0.4438, 0.7374]}, {"w": "power", "b": [0.4488, 0.716, 0.5012, 0.7374]}, {"w": "scheduling", "b": [0.5062, 0.716, 0.5967, 0.7374]}, {"w": "reduces", "b": [0.6017, 0.716, 0.6657, 0.7374]}, {"w": "the", "b": [0.6707, 0.716, 0.697, 0.7374]}, {"w": "learning", "b": [0.702, 0.716, 0.7711, 0.7374]}, {"w": "rate", "b": [0.7762, 0.716, 0.8078, 0.7374]}, {"w": "more", "b": [0.8129, 0.716, 0.8571, 0.7374]}, {"w": "and", "b": [0.1786, 0.735, 0.2101, 0.7565]}, {"w": "more", "b": [0.2157, 0.735, 0.26, 0.7565]}, {"w": "slowly,", "b": [0.2655, 0.735, 0.3214, 0.7565]}, {"w": "exponential", "b": [0.327, 0.735, 0.4248, 0.7565]}, {"w": "scheduling", "b": [0.4304, 0.735, 0.5209, 0.7565]}, {"w": "keeps", "b": [0.5264, 0.735, 0.573, 0.7565]}, {"w": "slashing", "b": [0.5786, 0.735, 0.6462, 0.7565]}, {"w": "it", "b": [0.6517, 0.735, 0.6637, 0.7565]}, {"w": "by", "b": [0.6693, 0.735, 0.6894, 0.7565]}, {"w": "a", "b": [0.695, 0.735, 0.7041, 0.7565]}, {"w": "factor", "b": [0.7097, 0.735, 0.7585, 0.7565]}, {"w": "of", "b": [0.7641, 0.735, 0.7809, 0.7565]}, {"w": "10", "b": [0.7864, 0.7348, 0.8063, 0.7565]}, {"w": "every", "b": [0.8119, 0.735, 0.8571, 0.7565]}, {"w": "s", "b": [0.1786, 0.7539, 0.1856, 0.7755]}, {"w": "steps.", "b": [0.1903, 0.7541, 0.2365, 0.7755]}]}, {"id": "b_7", "type": "paragraph", "text": "Piecewise constant scheduling", "words": [{"w": "Piecewise", "b": [0.1428, 0.7835, 0.2198, 0.8051]}, {"w": "constant", "b": [0.2246, 0.7835, 0.2929, 0.8051]}, {"w": "scheduling", "b": [0.2977, 0.7835, 0.3824, 0.8051]}]}, {"id": "b_8", "type": "paragraph", "text": "Use a constant learning rate for a number of epochs (e.g., η0 = 0.1 for 5 epochs), then a smaller learning rate for another number of epochs (e.g., η1 = 0.001 for 50 epochs), and so on. Although this solution can work very well, it requires fid‐", "words": [{"w": "Use", "b": [0.1786, 0.8028, 0.2093, 0.8242]}, {"w": "a", "b": [0.2152, 0.8028, 0.2243, 0.8242]}, {"w": "constant", "b": [0.2302, 0.8028, 0.3015, 0.8242]}, {"w": "learning", "b": [0.3074, 0.8028, 0.3765, 0.8242]}, {"w": "rate", "b": [0.3824, 0.8028, 0.4141, 0.8242]}, {"w": "for", "b": [0.4199, 0.8028, 0.4445, 0.8242]}, {"w": "a", "b": [0.4503, 0.8028, 0.4595, 0.8242]}, {"w": "number", "b": [0.4653, 0.8028, 0.5316, 0.8242]}, {"w": "of", "b": [0.5375, 0.8028, 0.5543, 0.8242]}, {"w": "epochs", "b": [0.5601, 0.8028, 0.6181, 0.8242]}, {"w": "(e.g.,", "b": [0.624, 0.8028, 0.6641, 0.8242]}, {"w": "η0", "b": [0.6699, 0.8026, 0.6865, 0.8251]}, {"w": "=", "b": [0.6924, 0.8028, 0.7045, 0.8242]}, {"w": "0.1", "b": [0.7103, 0.8028, 0.7351, 0.8242]}, {"w": "for", "b": [0.7409, 0.8028, 0.7655, 0.8242]}, {"w": "5", "b": [0.7713, 0.8028, 0.7813, 0.8242]}, {"w": "epochs),", "b": [0.7872, 0.8028, 0.8571, 0.8242]}, {"w": "then", "b": [0.1786, 0.8218, 0.2163, 0.8432]}, {"w": "a", "b": [0.2217, 0.8218, 0.2309, 0.8432]}, {"w": "smaller", "b": [0.2363, 0.8218, 0.2972, 0.8432]}, {"w": "learning", "b": [0.3026, 0.8218, 0.3718, 0.8432]}, {"w": "rate", "b": [0.3772, 0.8218, 0.4089, 0.8432]}, {"w": "for", "b": [0.4143, 0.8218, 0.4388, 0.8432]}, {"w": "another", "b": [0.4442, 0.8218, 0.5094, 0.8432]}, {"w": "number", "b": [0.5148, 0.8218, 0.5811, 0.8432]}, {"w": "of", "b": [0.5865, 0.8218, 0.6033, 0.8432]}, {"w": "epochs", "b": [0.6087, 0.8218, 0.6667, 0.8432]}, {"w": "(e.g.,", "b": [0.6721, 0.8218, 0.7122, 0.8432]}, {"w": "η1", "b": [0.7176, 0.8216, 0.7342, 0.8441]}, {"w": "=", "b": [0.7396, 0.8218, 0.7517, 0.8432]}, {"w": "0.001", "b": [0.7571, 0.8218, 0.8018, 0.8432]}, {"w": "for", "b": [0.8072, 0.8218, 0.8317, 0.8432]}, {"w": "50", "b": [0.8371, 0.8218, 0.8571, 0.8432]}, {"w": "epochs),", "b": [0.1786, 0.8409, 0.2485, 0.8623]}, {"w": "and", "b": [0.2559, 0.8409, 0.2874, 0.8623]}, {"w": "so", "b": [0.2948, 0.8409, 0.3131, 0.8623]}, {"w": "on.", "b": [0.3204, 0.8409, 0.3472, 0.8623]}, {"w": "Although", "b": [0.3546, 0.8409, 0.4343, 0.8623]}, {"w": "this", "b": [0.4416, 0.8409, 0.4723, 0.8623]}, {"w": "solution", "b": [0.4797, 0.8409, 0.5483, 0.8623]}, {"w": "can", "b": [0.5556, 0.8409, 0.585, 0.8623]}, {"w": "work", "b": [0.5923, 0.8409, 0.6353, 0.8623]}, {"w": "very", "b": [0.6427, 0.8409, 0.6791, 0.8623]}, {"w": "well,", "b": [0.6864, 0.8409, 0.7248, 0.8623]}, {"w": "it", "b": [0.7322, 0.8409, 0.7441, 0.8623]}, {"w": "requires", "b": [0.7515, 0.8409, 0.8196, 0.8623]}, {"w": "fid‐", "b": [0.827, 0.8409, 0.8571, 0.8623]}]}, {"id": "b_9", "type": "paragraph", "text": "Faster Optimizers | 353", "words": [{"w": "Faster", "b": [0.6934, 0.9225, 0.7296, 0.9388]}, {"w": "Optimizers", "b": [0.7325, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "353", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 380, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "22 “An Empirical Study of Learning Rates in Deep Neural Networks for Speech Recognition,” A. Senior et al. (2013).", "words": [{"w": "22", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "“An", "b": [0.1587, 0.8598, 0.1823, 0.8761]}, {"w": "Empirical", "b": [0.1859, 0.8598, 0.248, 0.8761]}, {"w": "Study", "b": [0.2517, 0.8598, 0.2881, 0.8761]}, {"w": "of", "b": [0.2917, 0.8598, 0.3045, 0.8761]}, {"w": "Learning", "b": [0.3081, 0.8598, 0.3653, 0.8761]}, {"w": "Rates", "b": [0.3689, 0.8598, 0.4031, 0.8761]}, {"w": "in", "b": [0.4067, 0.8598, 0.4197, 0.8761]}, {"w": "Deep", "b": [0.4233, 0.8598, 0.4567, 0.8761]}, {"w": "Neural", "b": [0.4603, 0.8598, 0.5038, 0.8761]}, {"w": "Networks", "b": [0.5074, 0.8598, 0.5689, 0.8761]}, {"w": "for", "b": [0.5725, 0.8598, 0.5912, 0.8761]}, {"w": "Speech", "b": [0.5948, 0.8598, 0.6393, 0.8761]}, {"w": "Recognition,”", "b": [0.643, 0.8598, 0.7284, 0.8761]}, {"w": "A.", "b": [0.732, 0.8598, 0.7466, 0.8761]}, {"w": "Senior", "b": [0.7502, 0.8598, 0.7914, 0.8761]}, {"w": "et", "b": [0.795, 0.8598, 0.8066, 0.8761]}, {"w": "al.", "b": [0.8102, 0.8598, 0.8248, 0.8761]}, {"w": "(2013).", "b": [0.1587, 0.8749, 0.2038, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "dling around to figure out the right sequence of learning rates, and how long to use each of them.", "words": [{"w": "dling", "b": [0.1786, 0.0791, 0.2216, 0.1005]}, {"w": "around", "b": [0.2277, 0.0791, 0.2887, 0.1005]}, {"w": "to", "b": [0.2949, 0.0791, 0.3118, 0.1005]}, {"w": "figure", "b": [0.318, 0.0791, 0.3671, 0.1005]}, {"w": "out", "b": [0.3733, 0.0791, 0.4014, 0.1005]}, {"w": "the", "b": [0.4075, 0.0791, 0.4338, 0.1005]}, {"w": "right", "b": [0.44, 0.0791, 0.4802, 0.1005]}, {"w": "sequence", "b": [0.4863, 0.0791, 0.5624, 0.1005]}, {"w": "of", "b": [0.5686, 0.0791, 0.5854, 0.1005]}, {"w": "learning", "b": [0.5916, 0.0791, 0.6607, 0.1005]}, {"w": "rates,", "b": [0.6668, 0.0791, 0.7109, 0.1005]}, {"w": "and", "b": [0.7171, 0.0791, 0.7486, 0.1005]}, {"w": "how", "b": [0.7548, 0.0791, 0.7908, 0.1005]}, {"w": "long", "b": [0.797, 0.0791, 0.834, 0.1005]}, {"w": "to", "b": [0.8402, 0.0791, 0.8572, 0.1005]}, {"w": "use", "b": [0.1786, 0.0981, 0.2061, 0.1195]}, {"w": "each", "b": [0.2109, 0.0981, 0.2488, 0.1195]}, {"w": "of", "b": [0.2535, 0.0981, 0.2703, 0.1195]}, {"w": "them.", "b": [0.275, 0.0981, 0.3232, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "Performance scheduling", "words": [{"w": "Performance", "b": [0.1429, 0.1275, 0.2464, 0.1492]}, {"w": "scheduling", "b": [0.2512, 0.1275, 0.3359, 0.1492]}]}, {"id": "b_3", "type": "paragraph", "text": "Measure the validation error every N steps (just like for early stopping) and reduce the learning rate by a factor of λ when the error stops dropping.", "words": [{"w": "Measure", "b": [0.1786, 0.1468, 0.2499, 0.1682]}, {"w": "the", "b": [0.259, 0.1468, 0.2853, 0.1682]}, {"w": "validation", "b": [0.2944, 0.1468, 0.3777, 0.1682]}, {"w": "error", "b": [0.3868, 0.1468, 0.4295, 0.1682]}, {"w": "every", "b": [0.4385, 0.1468, 0.4838, 0.1682]}, {"w": "N", "b": [0.4929, 0.1466, 0.5075, 0.1682]}, {"w": "steps", "b": [0.5166, 0.1468, 0.558, 0.1682]}, {"w": "(just", "b": [0.5671, 0.1468, 0.6047, 0.1682]}, {"w": "like", "b": [0.6138, 0.1468, 0.6438, 0.1682]}, {"w": "for", "b": [0.6529, 0.1468, 0.6774, 0.1682]}, {"w": "early", "b": [0.6865, 0.1468, 0.7271, 0.1682]}, {"w": "stopping)", "b": [0.7361, 0.1468, 0.8165, 0.1682]}, {"w": "and", "b": [0.8256, 0.1468, 0.8571, 0.1682]}, {"w": "reduce", "b": [0.1786, 0.1658, 0.2349, 0.1872]}, {"w": "the", "b": [0.2396, 0.1658, 0.266, 0.1872]}, {"w": "learning", "b": [0.2707, 0.1658, 0.3398, 0.1872]}, {"w": "rate", "b": [0.3445, 0.1658, 0.3762, 0.1872]}, {"w": "by", "b": [0.381, 0.1658, 0.4011, 0.1872]}, {"w": "a", "b": [0.4058, 0.1658, 0.415, 0.1872]}, {"w": "factor", "b": [0.4197, 0.1658, 0.4685, 0.1872]}, {"w": "of", "b": [0.4733, 0.1658, 0.4901, 0.1872]}, {"w": "λ", "b": [0.4948, 0.1656, 0.5049, 0.1872]}, {"w": "when", "b": [0.5097, 0.1658, 0.5553, 0.1872]}, {"w": "the", "b": [0.56, 0.1658, 0.5864, 0.1872]}, {"w": "error", "b": [0.5911, 0.1658, 0.6338, 0.1872]}, {"w": "stops", "b": [0.6385, 0.1658, 0.6817, 0.1872]}, {"w": "dropping.", "b": [0.6864, 0.1658, 0.7691, 0.1872]}]}, {"id": "b_4", "type": "paragraph", "text": "A 2013 paper22 by Andrew Senior et al. compared the performance of some of the most popular learning schedules when training deep neural networks for speech rec‐ ognition using Momentum optimization. The authors concluded that, in this setting, both performance scheduling and exponential scheduling performed well. They favored exponential scheduling because it was easy to tune and it converged slightly faster to the optimal solution (they also mentioned that it was easier to implement than performance scheduling, but in Keras both options are easy).", "words": [{"w": "A", "b": [0.1428, 0.194, 0.1572, 0.2154]}, {"w": "2013", "b": [0.1646, 0.194, 0.2046, 0.2154]}, {"w": "paper22", "b": [0.212, 0.194, 0.2706, 0.2154]}, {"w": "by", "b": [0.278, 0.194, 0.2982, 0.2154]}, {"w": "Andrew", "b": [0.3056, 0.194, 0.3732, 0.2154]}, {"w": "Senior", "b": [0.3806, 0.194, 0.4347, 0.2154]}, {"w": "et", "b": [0.4421, 0.194, 0.4573, 0.2154]}, {"w": "al.", "b": [0.4647, 0.194, 0.4839, 0.2154]}, {"w": "compared", "b": [0.4913, 0.194, 0.575, 0.2154]}, {"w": "the", "b": [0.5824, 0.194, 0.6088, 0.2154]}, {"w": "performance", "b": [0.6162, 0.194, 0.7234, 0.2154]}, {"w": "of", "b": [0.7308, 0.194, 0.7476, 0.2154]}, {"w": "some", "b": [0.755, 0.194, 0.7992, 0.2154]}, {"w": "of", "b": [0.8066, 0.194, 0.8234, 0.2154]}, {"w": "the", "b": [0.8308, 0.194, 0.8571, 0.2154]}, {"w": "most", "b": [0.1429, 0.213, 0.1845, 0.2344]}, {"w": "popular", "b": [0.1901, 0.213, 0.2558, 0.2344]}, {"w": "learning", "b": [0.2613, 0.213, 0.3304, 0.2344]}, {"w": "schedules", "b": [0.336, 0.213, 0.4163, 0.2344]}, {"w": "when", "b": [0.4218, 0.213, 0.4675, 0.2344]}, {"w": "training", "b": [0.473, 0.213, 0.54, 0.2344]}, {"w": "deep", "b": [0.5455, 0.213, 0.5852, 0.2344]}, {"w": "neural", "b": [0.5907, 0.213, 0.6442, 0.2344]}, {"w": "networks", "b": [0.6497, 0.213, 0.7269, 0.2344]}, {"w": "for", "b": [0.7325, 0.213, 0.757, 0.2344]}, {"w": "speech", "b": [0.7626, 0.213, 0.8188, 0.2344]}, {"w": "rec‐", "b": [0.8243, 0.213, 0.8571, 0.2344]}, {"w": "ognition", "b": [0.1428, 0.232, 0.2142, 0.2535]}, {"w": "using", "b": [0.2198, 0.232, 0.2652, 0.2535]}, {"w": "Momentum", "b": [0.2709, 0.232, 0.3709, 0.2535]}, {"w": "optimization.", "b": [0.3766, 0.232, 0.4889, 0.2535]}, {"w": "The", "b": [0.4946, 0.232, 0.5274, 0.2535]}, {"w": "authors", "b": [0.5331, 0.232, 0.5963, 0.2535]}, {"w": "concluded", "b": [0.602, 0.232, 0.6888, 0.2535]}, {"w": "that,", "b": [0.6945, 0.232, 0.7318, 0.2535]}, {"w": "in", "b": [0.7375, 0.232, 0.7544, 0.2535]}, {"w": "this", "b": [0.7601, 0.232, 0.7908, 0.2535]}, {"w": "setting,", "b": [0.7964, 0.232, 0.8571, 0.2535]}, {"w": "both", "b": [0.1429, 0.2511, 0.1816, 0.2725]}, {"w": "performance", "b": [0.1926, 0.2511, 0.2999, 0.2725]}, {"w": "scheduling", "b": [0.3109, 0.2511, 0.4014, 0.2725]}, {"w": "and", "b": [0.4124, 0.2511, 0.444, 0.2725]}, {"w": "exponential", "b": [0.455, 0.2511, 0.5528, 0.2725]}, {"w": "scheduling", "b": [0.5638, 0.2511, 0.6543, 0.2725]}, {"w": "performed", "b": [0.6654, 0.2511, 0.7543, 0.2725]}, {"w": "well.", "b": [0.7653, 0.2511, 0.8037, 0.2725]}, {"w": "They", "b": [0.8148, 0.2511, 0.8571, 0.2725]}, {"w": "favored", "b": [0.1429, 0.2701, 0.2056, 0.2916]}, {"w": "exponential", "b": [0.212, 0.2701, 0.3098, 0.2916]}, {"w": "scheduling", "b": [0.3161, 0.2701, 0.4066, 0.2916]}, {"w": "because", "b": [0.413, 0.2701, 0.4775, 0.2916]}, {"w": "it", "b": [0.4838, 0.2701, 0.4958, 0.2916]}, {"w": "was", "b": [0.5021, 0.2701, 0.5332, 0.2916]}, {"w": "easy", "b": [0.5395, 0.2701, 0.5747, 0.2916]}, {"w": "to", "b": [0.581, 0.2701, 0.598, 0.2916]}, {"w": "tune", "b": [0.6043, 0.2701, 0.642, 0.2916]}, {"w": "and", "b": [0.6483, 0.2701, 0.6799, 0.2916]}, {"w": "it", "b": [0.6862, 0.2701, 0.6981, 0.2916]}, {"w": "converged", "b": [0.7045, 0.2701, 0.7907, 0.2916]}, {"w": "slightly", "b": [0.797, 0.2701, 0.8571, 0.2916]}, {"w": "faster", "b": [0.1429, 0.2892, 0.1887, 0.3106]}, {"w": "to", "b": [0.196, 0.2892, 0.213, 0.3106]}, {"w": "the", "b": [0.2202, 0.2892, 0.2465, 0.3106]}, {"w": "optimal", "b": [0.2538, 0.2892, 0.3187, 0.3106]}, {"w": "solution", "b": [0.326, 0.2892, 0.3945, 0.3106]}, {"w": "(they", "b": [0.4018, 0.2892, 0.4449, 0.3106]}, {"w": "also", "b": [0.4521, 0.2892, 0.4848, 0.3106]}, {"w": "mentioned", "b": [0.492, 0.2892, 0.5828, 0.3106]}, {"w": "that", "b": [0.59, 0.2892, 0.6226, 0.3106]}, {"w": "it", "b": [0.6298, 0.2892, 0.6418, 0.3106]}, {"w": "was", "b": [0.649, 0.2892, 0.6801, 0.3106]}, {"w": "easier", "b": [0.6873, 0.2892, 0.7351, 0.3106]}, {"w": "to", "b": [0.7424, 0.2892, 0.7593, 0.3106]}, {"w": "implement", "b": [0.7666, 0.2892, 0.8571, 0.3106]}, {"w": "than", "b": [0.1429, 0.3082, 0.1809, 0.3297]}, {"w": "performance", "b": [0.1856, 0.3082, 0.2929, 0.3297]}, {"w": "scheduling,", "b": [0.2976, 0.3082, 0.3929, 0.3297]}, {"w": "but", "b": [0.3976, 0.3082, 0.4256, 0.3297]}, {"w": "in", "b": [0.4303, 0.3082, 0.4473, 0.3297]}, {"w": "Keras", "b": [0.4521, 0.3082, 0.4989, 0.3297]}, {"w": "both", "b": [0.5037, 0.3082, 0.5424, 0.3297]}, {"w": "options", "b": [0.5471, 0.3082, 0.6102, 0.3297]}, {"w": "are", "b": [0.615, 0.3082, 0.6407, 0.3297]}, {"w": "easy).", "b": [0.6454, 0.3082, 0.6926, 0.3297]}]}, {"id": "b_5", "type": "paragraph", "text": "Implementing power scheduling in Keras is the easiest option: just set the decay hyperparameter when creating an optimizer. The decay is the inverse of s (the num‐ ber of steps it takes to divide the learning rate by one more unit), and Keras assumes that c is equal to 1. For example:", "words": [{"w": "Implementing", "b": [0.1429, 0.3373, 0.2617, 0.3587]}, {"w": "power", "b": [0.2705, 0.3373, 0.3229, 0.3587]}, {"w": "scheduling", "b": [0.3317, 0.3373, 0.4222, 0.3587]}, {"w": "in", "b": [0.431, 0.3373, 0.448, 0.3587]}, {"w": "Keras", "b": [0.4568, 0.3373, 0.5037, 0.3587]}, {"w": "is", "b": [0.5125, 0.3373, 0.5257, 0.3587]}, {"w": "the", "b": [0.5346, 0.3373, 0.5609, 0.3587]}, {"w": "easiest", "b": [0.5697, 0.3373, 0.6238, 0.3587]}, {"w": "option:", "b": [0.6326, 0.3373, 0.6928, 0.3587]}, {"w": "just", "b": [0.7017, 0.3373, 0.732, 0.3587]}, {"w": "set", "b": [0.7409, 0.3373, 0.7637, 0.3587]}, {"w": "the", "b": [0.7725, 0.3373, 0.7989, 0.3587]}, {"w": "decay", "b": [0.8077, 0.3404, 0.8572, 0.3555]}, {"w": "hyperparameter", "b": [0.1429, 0.3572, 0.2764, 0.3786]}, {"w": "when", "b": [0.2823, 0.3572, 0.328, 0.3786]}, {"w": "creating", "b": [0.3339, 0.3572, 0.4012, 0.3786]}, {"w": "an", "b": [0.4071, 0.3572, 0.4277, 0.3786]}, {"w": "optimizer.", "b": [0.4336, 0.3572, 0.5185, 0.3786]}, {"w": "The", "b": [0.5245, 0.3572, 0.5573, 0.3786]}, {"w": "decay", "b": [0.5633, 0.3604, 0.6127, 0.3755]}, {"w": "is", "b": [0.6187, 0.3572, 0.6319, 0.3786]}, {"w": "the", "b": [0.6379, 0.3572, 0.6642, 0.3786]}, {"w": "inverse", "b": [0.6702, 0.3572, 0.7294, 0.3786]}, {"w": "of", "b": [0.7354, 0.3572, 0.7522, 0.3786]}, {"w": "s", "b": [0.7581, 0.357, 0.7651, 0.3786]}, {"w": "(the", "b": [0.7711, 0.3572, 0.8046, 0.3786]}, {"w": "num‐", "b": [0.8106, 0.3572, 0.8571, 0.3786]}, {"w": "ber", "b": [0.1429, 0.3762, 0.17, 0.3977]}, {"w": "of", "b": [0.1756, 0.3762, 0.1924, 0.3977]}, {"w": "steps", "b": [0.198, 0.3762, 0.2394, 0.3977]}, {"w": "it", "b": [0.245, 0.3762, 0.257, 0.3977]}, {"w": "takes", "b": [0.2626, 0.3762, 0.3049, 0.3977]}, {"w": "to", "b": [0.3105, 0.3762, 0.3275, 0.3977]}, {"w": "divide", "b": [0.3331, 0.3762, 0.3848, 0.3977]}, {"w": "the", "b": [0.3904, 0.3762, 0.4167, 0.3977]}, {"w": "learning", "b": [0.4223, 0.3762, 0.4915, 0.3977]}, {"w": "rate", "b": [0.4971, 0.3762, 0.5287, 0.3977]}, {"w": "by", "b": [0.5344, 0.3762, 0.5545, 0.3977]}, {"w": "one", "b": [0.5601, 0.3762, 0.591, 0.3977]}, {"w": "more", "b": [0.5966, 0.3762, 0.6409, 0.3977]}, {"w": "unit),", "b": [0.6465, 0.3762, 0.6928, 0.3977]}, {"w": "and", "b": [0.6984, 0.3762, 0.73, 0.3977]}, {"w": "Keras", "b": [0.7356, 0.3762, 0.7825, 0.3977]}, {"w": "assumes", "b": [0.7881, 0.3762, 0.8571, 0.3977]}, {"w": "that", "b": [0.1428, 0.3953, 0.1754, 0.4167]}, {"w": "c", "b": [0.1802, 0.3951, 0.1881, 0.4167]}, {"w": "is", "b": [0.1928, 0.3953, 0.2061, 0.4167]}, {"w": "equal", "b": [0.2108, 0.3953, 0.2558, 0.4167]}, {"w": "to", "b": [0.2605, 0.3953, 0.2775, 0.4167]}, {"w": "1.", "b": [0.2822, 0.3953, 0.297, 0.4167]}, {"w": "For", "b": [0.3017, 0.3953, 0.3307, 0.4167]}, {"w": "example:", "b": [0.3354, 0.3953, 0.4097, 0.4167]}]}, {"id": "b_6", "type": "equation", "text": "optimizer = keras.optimizers.SGD(lr=0.01, decay=1e-4)", "words": [{"w": "optimizer", "b": [0.1766, 0.4273, 0.2525, 0.4401]}, {"w": "=", "b": [0.2609, 0.4273, 0.2694, 0.4401]}, {"w": "keras.optimizers.SGD(lr=0.01,", "b": [0.2778, 0.4273, 0.5223, 0.4401]}, {"w": "decay=1e-4)", "b": [0.5308, 0.4273, 0.6235, 0.4401]}]}, {"id": "b_7", "type": "paragraph", "text": "Exponential scheduling and piecewise scheduling are quite simple too. You first need to define a function that takes the current epoch and returns the learning rate. For example, let’s implement exponential scheduling:", "words": [{"w": "Exponential", "b": [0.1429, 0.4479, 0.2437, 0.4693]}, {"w": "scheduling", "b": [0.2492, 0.4479, 0.3397, 0.4693]}, {"w": "and", "b": [0.3452, 0.4479, 0.3767, 0.4693]}, {"w": "piecewise", "b": [0.3823, 0.4479, 0.4616, 0.4693]}, {"w": "scheduling", "b": [0.4672, 0.4479, 0.5577, 0.4693]}, {"w": "are", "b": [0.5632, 0.4479, 0.5889, 0.4693]}, {"w": "quite", "b": [0.5944, 0.4479, 0.6369, 0.4693]}, {"w": "simple", "b": [0.6424, 0.4479, 0.6974, 0.4693]}, {"w": "too.", "b": [0.7029, 0.4479, 0.7346, 0.4693]}, {"w": "You", "b": [0.7402, 0.4479, 0.7725, 0.4693]}, {"w": "first", "b": [0.778, 0.4479, 0.8115, 0.4693]}, {"w": "need", "b": [0.817, 0.4479, 0.8571, 0.4693]}, {"w": "to", "b": [0.1429, 0.4669, 0.1598, 0.4884]}, {"w": "define", "b": [0.1669, 0.4669, 0.2187, 0.4884]}, {"w": "a", "b": [0.2258, 0.4669, 0.2349, 0.4884]}, {"w": "function", "b": [0.242, 0.4669, 0.3134, 0.4884]}, {"w": "that", "b": [0.3204, 0.4669, 0.353, 0.4884]}, {"w": "takes", "b": [0.36, 0.4669, 0.4024, 0.4884]}, {"w": "the", "b": [0.4094, 0.4669, 0.4357, 0.4884]}, {"w": "current", "b": [0.4428, 0.4669, 0.5043, 0.4884]}, {"w": "epoch", "b": [0.5114, 0.4669, 0.5617, 0.4884]}, {"w": "and", "b": [0.5688, 0.4669, 0.6003, 0.4884]}, {"w": "returns", "b": [0.6073, 0.4669, 0.6681, 0.4884]}, {"w": "the", "b": [0.6751, 0.4669, 0.7015, 0.4884]}, {"w": "learning", "b": [0.7085, 0.4669, 0.7776, 0.4884]}, {"w": "rate.", "b": [0.7847, 0.4669, 0.8211, 0.4884]}, {"w": "For", "b": [0.8282, 0.4669, 0.8572, 0.4884]}, {"w": "example,", "b": [0.1429, 0.486, 0.2172, 0.5074]}, {"w": "let’s", "b": [0.2219, 0.486, 0.2521, 0.5074]}, {"w": "implement", "b": [0.2568, 0.486, 0.3474, 0.5074]}, {"w": "exponential", "b": [0.3521, 0.486, 0.45, 0.5074]}, {"w": "scheduling:", "b": [0.4547, 0.486, 0.5499, 0.5074]}]}, {"id": "b_8", "type": "equation", "text": "def exponential_decay_fn(epoch): return 0.01 * 0.1**(epoch / 20)", "words": [{"w": "def", "b": [0.1766, 0.518, 0.2019, 0.5308]}, {"w": "exponential_decay_fn(epoch):", "b": [0.2103, 0.518, 0.4464, 0.5308]}, {"w": "return", "b": [0.2103, 0.5334, 0.2609, 0.5462]}, {"w": "0.01", "b": [0.2693, 0.5334, 0.3031, 0.5462]}, {"w": "*", "b": [0.3115, 0.5334, 0.3199, 0.5462]}, {"w": "0.1**(epoch", "b": [0.3284, 0.5334, 0.4211, 0.5462]}, {"w": "/", "b": [0.4296, 0.5334, 0.438, 0.5462]}, {"w": "20)", "b": [0.4464, 0.5334, 0.4717, 0.5462]}]}, {"id": "b_9", "type": "paragraph", "text": "If you do not want to hard-code η0 and s, you can create a function that returns a configured function:", "words": [{"w": "If", "b": [0.1428, 0.554, 0.1561, 0.5754]}, {"w": "you", "b": [0.1634, 0.554, 0.1946, 0.5754]}, {"w": "do", "b": [0.2019, 0.554, 0.2235, 0.5754]}, {"w": "not", "b": [0.2308, 0.554, 0.2591, 0.5754]}, {"w": "want", "b": [0.2664, 0.554, 0.3072, 0.5754]}, {"w": "to", "b": [0.3144, 0.554, 0.3314, 0.5754]}, {"w": "hard-code", "b": [0.3387, 0.554, 0.4244, 0.5754]}, {"w": "η0", "b": [0.4316, 0.5538, 0.4483, 0.5763]}, {"w": "and", "b": [0.4555, 0.554, 0.4871, 0.5754]}, {"w": "s,", "b": [0.4943, 0.5538, 0.5061, 0.5754]}, {"w": "you", "b": [0.5133, 0.554, 0.5446, 0.5754]}, {"w": "can", "b": [0.5518, 0.554, 0.5812, 0.5754]}, {"w": "create", "b": [0.5885, 0.554, 0.6378, 0.5754]}, {"w": "a", "b": [0.6451, 0.554, 0.6542, 0.5754]}, {"w": "function", "b": [0.6615, 0.554, 0.7329, 0.5754]}, {"w": "that", "b": [0.7401, 0.554, 0.7727, 0.5754]}, {"w": "returns", "b": [0.78, 0.554, 0.8407, 0.5754]}, {"w": "a", "b": [0.848, 0.554, 0.8571, 0.5754]}, {"w": "configured", "b": [0.1429, 0.5731, 0.2338, 0.5945]}, {"w": "function:", "b": [0.2386, 0.5731, 0.3147, 0.5945]}]}, {"id": "b_10", "type": "paragraph", "text": "def exponential_decay(lr0, s): def exponential_decay_fn(epoch): return lr0 * 0.1**(epoch / s) return exponential_decay_fn", "words": [{"w": "def", "b": [0.1766, 0.605, 0.2019, 0.6179]}, {"w": "exponential_decay(lr0,", "b": [0.2103, 0.605, 0.3958, 0.6179]}, {"w": "s):", "b": [0.4043, 0.605, 0.4296, 0.6179]}, {"w": "def", "b": [0.2103, 0.6205, 0.2356, 0.6333]}, {"w": "exponential_decay_fn(epoch):", "b": [0.244, 0.6205, 0.4802, 0.6333]}, {"w": "return", "b": [0.244, 0.6359, 0.2946, 0.6487]}, {"w": "lr0", "b": [0.3031, 0.6359, 0.3284, 0.6487]}, {"w": "*", "b": [0.3368, 0.6359, 0.3452, 0.6487]}, {"w": "0.1**(epoch", "b": [0.3537, 0.6359, 0.4464, 0.6487]}, {"w": "/", "b": [0.4549, 0.6359, 0.4633, 0.6487]}, {"w": "s)", "b": [0.4717, 0.6359, 0.4886, 0.6487]}, {"w": "return", "b": [0.2103, 0.6513, 0.2609, 0.6642]}, {"w": "exponential_decay_fn", "b": [0.2693, 0.6513, 0.438, 0.6642]}]}, {"id": "b_11", "type": "equation", "text": "exponential_decay_fn = exponential_decay(lr0=0.01, s=20)", "words": [{"w": "exponential_decay_fn", "b": [0.1766, 0.6821, 0.3452, 0.695]}, {"w": "=", "b": [0.3537, 0.6821, 0.3621, 0.695]}, {"w": "exponential_decay(lr0=0.01,", "b": [0.3705, 0.6821, 0.5982, 0.695]}, {"w": "s=20)", "b": [0.6066, 0.6821, 0.6488, 0.695]}]}, {"id": "b_12", "type": "paragraph", "text": "Next, just create a LearningRateScheduler callback, giving it the schedule function, and pass this callback to the fit() method:", "words": [{"w": "Next,", "b": [0.1428, 0.7037, 0.1876, 0.7251]}, {"w": "just", "b": [0.1938, 0.7037, 0.2242, 0.7251]}, {"w": "create", "b": [0.2304, 0.7037, 0.2797, 0.7251]}, {"w": "a", "b": [0.2859, 0.7037, 0.2951, 0.7251]}, {"w": "LearningRateScheduler", "b": [0.3013, 0.7069, 0.5091, 0.7219]}, {"w": "callback,", "b": [0.5153, 0.7037, 0.5874, 0.7251]}, {"w": "giving", "b": [0.5936, 0.7037, 0.6453, 0.7251]}, {"w": "it", "b": [0.6515, 0.7037, 0.6634, 0.7251]}, {"w": "the", "b": [0.6696, 0.7037, 0.696, 0.7251]}, {"w": "schedule", "b": [0.7022, 0.7037, 0.7748, 0.7251]}, {"w": "function,", "b": [0.781, 0.7037, 0.8571, 0.7251]}, {"w": "and", "b": [0.1429, 0.7236, 0.1744, 0.745]}, {"w": "pass", "b": [0.1791, 0.7236, 0.2145, 0.745]}, {"w": "this", "b": [0.2192, 0.7236, 0.2499, 0.745]}, {"w": "callback", "b": [0.2547, 0.7236, 0.322, 0.745]}, {"w": "to", "b": [0.3268, 0.7236, 0.3437, 0.745]}, {"w": "the", "b": [0.3485, 0.7236, 0.3748, 0.745]}, {"w": "fit()", "b": [0.3795, 0.7268, 0.429, 0.7419]}, {"w": "method:", "b": [0.4337, 0.7236, 0.5035, 0.745]}]}, {"id": "b_13", "type": "paragraph", "text": "lr_scheduler = keras.callbacks.LearningRateScheduler(exponential_decay_fn) history = model.fit(X_train_scaled, y_train, [...], callbacks=[lr_scheduler])", "words": [{"w": "lr_scheduler", "b": [0.1766, 0.7556, 0.2778, 0.7684]}, {"w": "=", "b": [0.2862, 0.7556, 0.2946, 0.7684]}, {"w": "keras.callbacks.LearningRateScheduler(exponential_decay_fn)", "b": [0.3031, 0.7556, 0.8006, 0.7684]}, {"w": "history", "b": [0.1766, 0.771, 0.2356, 0.7839]}, {"w": "=", "b": [0.244, 0.771, 0.2525, 0.7839]}, {"w": "model.fit(X_train_scaled,", "b": [0.2609, 0.771, 0.4717, 0.7839]}, {"w": "y_train,", "b": [0.4802, 0.771, 0.5476, 0.7839]}, {"w": "[...],", "b": [0.556, 0.771, 0.6066, 0.7839]}, {"w": "callbacks=[lr_scheduler])", "b": [0.6151, 0.771, 0.8259, 0.7839]}]}, {"id": "b_14", "type": "paragraph", "text": "354 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "354", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2745, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 381, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "The LearningRateScheduler will update the optimizer’s learning_rate attribute at the beginning of each epoch. Updating the learning rate just once per epoch is usually enough, but if you want it to be updated more often, for example at every step, you need to write your own callback (see the notebook for an example). This can make sense if there are many steps per epoch.", "words": [{"w": "The", "b": [0.1429, 0.08, 0.1757, 0.1014]}, {"w": "LearningRateScheduler", "b": [0.1823, 0.0831, 0.3901, 0.0982]}, {"w": "will", "b": [0.3967, 0.08, 0.4271, 0.1014]}, {"w": "update", "b": [0.4337, 0.08, 0.4906, 0.1014]}, {"w": "the", "b": [0.4972, 0.08, 0.5236, 0.1014]}, {"w": "optimizer’s", "b": [0.5302, 0.08, 0.622, 0.1014]}, {"w": "learning_rate", "b": [0.6286, 0.0831, 0.7572, 0.0982]}, {"w": "attribute", "b": [0.7638, 0.08, 0.8354, 0.1014]}, {"w": "at", "b": [0.842, 0.08, 0.8571, 0.1014]}, {"w": "the", "b": [0.1429, 0.099, 0.1692, 0.1204]}, {"w": "beginning", "b": [0.1741, 0.099, 0.2584, 0.1204]}, {"w": "of", "b": [0.2632, 0.099, 0.28, 0.1204]}, {"w": "each", "b": [0.2849, 0.099, 0.3228, 0.1204]}, {"w": "epoch.", "b": [0.3277, 0.099, 0.3828, 0.1204]}, {"w": "Updating", "b": [0.3877, 0.099, 0.4659, 0.1204]}, {"w": "the", "b": [0.4708, 0.099, 0.4971, 0.1204]}, {"w": "learning", "b": [0.502, 0.099, 0.5711, 0.1204]}, {"w": "rate", "b": [0.576, 0.099, 0.6077, 0.1204]}, {"w": "just", "b": [0.6126, 0.099, 0.643, 0.1204]}, {"w": "once", "b": [0.6479, 0.099, 0.6875, 0.1204]}, {"w": "per", "b": [0.6924, 0.099, 0.7199, 0.1204]}, {"w": "epoch", "b": [0.7248, 0.099, 0.7751, 0.1204]}, {"w": "is", "b": [0.78, 0.099, 0.7932, 0.1204]}, {"w": "usually", "b": [0.7981, 0.099, 0.8571, 0.1204]}, {"w": "enough,", "b": [0.1429, 0.1181, 0.2104, 0.1395]}, {"w": "but", "b": [0.2168, 0.1181, 0.2448, 0.1395]}, {"w": "if", "b": [0.2513, 0.1181, 0.263, 0.1395]}, {"w": "you", "b": [0.2694, 0.1181, 0.3007, 0.1395]}, {"w": "want", "b": [0.3071, 0.1181, 0.3479, 0.1395]}, {"w": "it", "b": [0.3543, 0.1181, 0.3662, 0.1395]}, {"w": "to", "b": [0.3726, 0.1181, 0.3896, 0.1395]}, {"w": "be", "b": [0.396, 0.1181, 0.4155, 0.1395]}, {"w": "updated", "b": [0.4219, 0.1181, 0.4898, 0.1395]}, {"w": "more", "b": [0.4962, 0.1181, 0.5405, 0.1395]}, {"w": "often,", "b": [0.5469, 0.1181, 0.5951, 0.1395]}, {"w": "for", "b": [0.6015, 0.1181, 0.626, 0.1395]}, {"w": "example", "b": [0.6324, 0.1181, 0.702, 0.1395]}, {"w": "at", "b": [0.7084, 0.1181, 0.7235, 0.1395]}, {"w": "every", "b": [0.7299, 0.1181, 0.7752, 0.1395]}, {"w": "step,", "b": [0.7816, 0.1181, 0.8195, 0.1395]}, {"w": "you", "b": [0.8259, 0.1181, 0.8572, 0.1395]}, {"w": "need", "b": [0.1429, 0.1371, 0.183, 0.1585]}, {"w": "to", "b": [0.1897, 0.1371, 0.2067, 0.1585]}, {"w": "write", "b": [0.2135, 0.1371, 0.2563, 0.1585]}, {"w": "your", "b": [0.2631, 0.1371, 0.3021, 0.1585]}, {"w": "own", "b": [0.3088, 0.1371, 0.3451, 0.1585]}, {"w": "callback", "b": [0.3519, 0.1371, 0.4193, 0.1585]}, {"w": "(see", "b": [0.4261, 0.1371, 0.4586, 0.1585]}, {"w": "the", "b": [0.4654, 0.1371, 0.4918, 0.1585]}, {"w": "notebook", "b": [0.4985, 0.1371, 0.5779, 0.1585]}, {"w": "for", "b": [0.5847, 0.1371, 0.6092, 0.1585]}, {"w": "an", "b": [0.616, 0.1371, 0.6366, 0.1585]}, {"w": "example).", "b": [0.6433, 0.1371, 0.7248, 0.1585]}, {"w": "This", "b": [0.7316, 0.1371, 0.7688, 0.1585]}, {"w": "can", "b": [0.7756, 0.1371, 0.805, 0.1585]}, {"w": "make", "b": [0.8117, 0.1371, 0.8571, 0.1585]}, {"w": "sense", "b": [0.1429, 0.1561, 0.1872, 0.1776]}, {"w": "if", "b": [0.192, 0.1561, 0.2037, 0.1776]}, {"w": "there", "b": [0.2085, 0.1561, 0.2514, 0.1776]}, {"w": "are", "b": [0.2561, 0.1561, 0.2818, 0.1776]}, {"w": "many", "b": [0.2866, 0.1561, 0.3332, 0.1776]}, {"w": "steps", "b": [0.338, 0.1561, 0.3794, 0.1776]}, {"w": "per", "b": [0.3841, 0.1561, 0.4116, 0.1776]}, {"w": "epoch.", "b": [0.4164, 0.1561, 0.4714, 0.1776]}]}, {"id": "b_1", "type": "paragraph", "text": "The schedule function can optionally take the current learning rate as a second argu‐ ment. For example, the following schedule function just multiplies the previous learning rate by 0.1&1/20, which results in the same exponential decay (except the decay now starts at the beginning of epoch 0 instead of 1). This implementation relies on the optimizer’s initial learning rate (contrary to the previous implementation), so make sure to set it appropriately.", "words": [{"w": "The", "b": [0.1429, 0.1843, 0.1757, 0.2057]}, {"w": "schedule", "b": [0.1811, 0.1843, 0.2537, 0.2057]}, {"w": "function", "b": [0.2592, 0.1843, 0.3306, 0.2057]}, {"w": "can", "b": [0.336, 0.1843, 0.3653, 0.2057]}, {"w": "optionally", "b": [0.3708, 0.1843, 0.4555, 0.2057]}, {"w": "take", "b": [0.461, 0.1843, 0.4956, 0.2057]}, {"w": "the", "b": [0.5011, 0.1843, 0.5274, 0.2057]}, {"w": "current", "b": [0.5328, 0.1843, 0.5944, 0.2057]}, {"w": "learning", "b": [0.5998, 0.1843, 0.6689, 0.2057]}, {"w": "rate", "b": [0.6744, 0.1843, 0.706, 0.2057]}, {"w": "as", "b": [0.7115, 0.1843, 0.7283, 0.2057]}, {"w": "a", "b": [0.7337, 0.1843, 0.7428, 0.2057]}, {"w": "second", "b": [0.7483, 0.1843, 0.8066, 0.2057]}, {"w": "argu‐", "b": [0.812, 0.1843, 0.8571, 0.2057]}, {"w": "ment.", "b": [0.1428, 0.2033, 0.1909, 0.2247]}, {"w": "For", "b": [0.201, 0.2033, 0.23, 0.2247]}, {"w": "example,", "b": [0.2402, 0.2033, 0.3145, 0.2247]}, {"w": "the", "b": [0.3246, 0.2033, 0.351, 0.2247]}, {"w": "following", "b": [0.3611, 0.2033, 0.4401, 0.2247]}, {"w": "schedule", "b": [0.4503, 0.2033, 0.5229, 0.2247]}, {"w": "function", "b": [0.5331, 0.2033, 0.6045, 0.2247]}, {"w": "just", "b": [0.6146, 0.2033, 0.645, 0.2247]}, {"w": "multiplies", "b": [0.6552, 0.2033, 0.7384, 0.2247]}, {"w": "the", "b": [0.7486, 0.2033, 0.7749, 0.2247]}, {"w": "previous", "b": [0.7851, 0.2033, 0.8571, 0.2247]}, {"w": "learning", "b": [0.1429, 0.2224, 0.212, 0.2438]}, {"w": "rate", "b": [0.2167, 0.2224, 0.2484, 0.2438]}, {"w": "by", "b": [0.2531, 0.2224, 0.2733, 0.2438]}, {"w": "0.1&1/20,", "b": [0.278, 0.2224, 0.3387, 0.2438]}, {"w": "which", "b": [0.3435, 0.2224, 0.3944, 0.2438]}, {"w": "results", "b": [0.3991, 0.2224, 0.4537, 0.2438]}, {"w": "in", "b": [0.4584, 0.2224, 0.4754, 0.2438]}, {"w": "the", "b": [0.4801, 0.2224, 0.5064, 0.2438]}, {"w": "same", "b": [0.5112, 0.2224, 0.5539, 0.2438]}, {"w": "exponential", "b": [0.5586, 0.2224, 0.6564, 0.2438]}, {"w": "decay", "b": [0.6612, 0.2224, 0.7082, 0.2438]}, {"w": "(except", "b": [0.7129, 0.2224, 0.7737, 0.2438]}, {"w": "the", "b": [0.7785, 0.2224, 0.8048, 0.2438]}, {"w": "decay", "b": [0.8095, 0.2224, 0.8565, 0.2438]}, {"w": "now", "b": [0.1429, 0.2414, 0.1792, 0.2628]}, {"w": "starts", "b": [0.186, 0.2414, 0.2308, 0.2628]}, {"w": "at", "b": [0.2376, 0.2414, 0.2527, 0.2628]}, {"w": "the", "b": [0.2595, 0.2414, 0.2858, 0.2628]}, {"w": "beginning", "b": [0.2926, 0.2414, 0.3769, 0.2628]}, {"w": "of", "b": [0.3837, 0.2414, 0.4005, 0.2628]}, {"w": "epoch", "b": [0.4073, 0.2414, 0.4576, 0.2628]}, {"w": "0", "b": [0.4644, 0.2414, 0.4744, 0.2628]}, {"w": "instead", "b": [0.4812, 0.2414, 0.5412, 0.2628]}, {"w": "of", "b": [0.548, 0.2414, 0.5648, 0.2628]}, {"w": "1).", "b": [0.5716, 0.2414, 0.5935, 0.2628]}, {"w": "This", "b": [0.6003, 0.2414, 0.6375, 0.2628]}, {"w": "implementation", "b": [0.6443, 0.2414, 0.7776, 0.2628]}, {"w": "relies", "b": [0.7844, 0.2414, 0.8283, 0.2628]}, {"w": "on", "b": [0.8351, 0.2414, 0.8571, 0.2628]}, {"w": "the", "b": [0.1429, 0.2605, 0.1692, 0.2819]}, {"w": "optimizer’s", "b": [0.1781, 0.2605, 0.2698, 0.2819]}, {"w": "initial", "b": [0.2787, 0.2605, 0.3276, 0.2819]}, {"w": "learning", "b": [0.3365, 0.2605, 0.4056, 0.2819]}, {"w": "rate", "b": [0.4145, 0.2605, 0.4462, 0.2819]}, {"w": "(contrary", "b": [0.4551, 0.2605, 0.5339, 0.2819]}, {"w": "to", "b": [0.5427, 0.2605, 0.5597, 0.2819]}, {"w": "the", "b": [0.5686, 0.2605, 0.5949, 0.2819]}, {"w": "previous", "b": [0.6038, 0.2605, 0.6759, 0.2819]}, {"w": "implementation),", "b": [0.6848, 0.2605, 0.83, 0.2819]}, {"w": "so", "b": [0.8389, 0.2605, 0.8571, 0.2819]}, {"w": "make", "b": [0.1429, 0.2795, 0.1883, 0.3009]}, {"w": "sure", "b": [0.193, 0.2795, 0.2283, 0.3009]}, {"w": "to", "b": [0.233, 0.2795, 0.25, 0.3009]}, {"w": "set", "b": [0.2547, 0.2795, 0.2776, 0.3009]}, {"w": "it", "b": [0.2823, 0.2795, 0.2942, 0.3009]}, {"w": "appropriately.", "b": [0.299, 0.2795, 0.4141, 0.3009]}]}, {"id": "b_2", "type": "equation", "text": "def exponential_decay_fn(epoch, lr): return lr * 0.1**(1 / 20)", "words": [{"w": "def", "b": [0.1766, 0.3115, 0.2019, 0.3243]}, {"w": "exponential_decay_fn(epoch,", "b": [0.2103, 0.3115, 0.438, 0.3243]}, {"w": "lr):", "b": [0.4464, 0.3115, 0.4802, 0.3243]}, {"w": "return", "b": [0.2103, 0.3269, 0.2609, 0.3397]}, {"w": "lr", "b": [0.2693, 0.3269, 0.2862, 0.3397]}, {"w": "*", "b": [0.2946, 0.3269, 0.3031, 0.3397]}, {"w": "0.1**(1", "b": [0.3115, 0.3269, 0.3705, 0.3397]}, {"w": "/", "b": [0.379, 0.3269, 0.3874, 0.3397]}, {"w": "20)", "b": [0.3958, 0.3269, 0.4211, 0.3397]}]}, {"id": "b_3", "type": "paragraph", "text": "When you save a model, the optimizer and its learning rate get saved along with it. This means that with this new schedule function, you could just load a trained model and continue training where it left off, no problem. However, things are not so simple if your schedule function uses the epoch argument: indeed, the epoch does not get saved, and it gets reset to 0 every time you call the fit() method. This could lead to a very large learning rate when you continue training a model where it left off, which would likely damage your model’s weights. One solution is to manually set the fit() method’s initial_epoch argument so the epoch starts at the right value.", "words": [{"w": "When", "b": [0.1429, 0.3475, 0.1945, 0.3689]}, {"w": "you", "b": [0.2011, 0.3475, 0.2323, 0.3689]}, {"w": "save", "b": [0.2389, 0.3475, 0.2738, 0.3689]}, {"w": "a", "b": [0.2804, 0.3475, 0.2896, 0.3689]}, {"w": "model,", "b": [0.2962, 0.3475, 0.3537, 0.3689]}, {"w": "the", "b": [0.3603, 0.3475, 0.3867, 0.3689]}, {"w": "optimizer", "b": [0.3933, 0.3475, 0.4747, 0.3689]}, {"w": "and", "b": [0.4813, 0.3475, 0.5129, 0.3689]}, {"w": "its", "b": [0.5195, 0.3475, 0.5391, 0.3689]}, {"w": "learning", "b": [0.5457, 0.3475, 0.6148, 0.3689]}, {"w": "rate", "b": [0.6214, 0.3475, 0.6531, 0.3689]}, {"w": "get", "b": [0.6597, 0.3475, 0.6846, 0.3689]}, {"w": "saved", "b": [0.6912, 0.3475, 0.7371, 0.3689]}, {"w": "along", "b": [0.7437, 0.3475, 0.7899, 0.3689]}, {"w": "with", "b": [0.7965, 0.3475, 0.8339, 0.3689]}, {"w": "it.", "b": [0.8405, 0.3475, 0.8571, 0.3689]}, {"w": "This", "b": [0.1429, 0.3666, 0.1801, 0.388]}, {"w": "means", "b": [0.1852, 0.3666, 0.2393, 0.388]}, {"w": "that", "b": [0.2445, 0.3666, 0.2771, 0.388]}, {"w": "with", "b": [0.2823, 0.3666, 0.3196, 0.388]}, {"w": "this", "b": [0.3248, 0.3666, 0.3555, 0.388]}, {"w": "new", "b": [0.3607, 0.3666, 0.3952, 0.388]}, {"w": "schedule", "b": [0.4004, 0.3666, 0.473, 0.388]}, {"w": "function,", "b": [0.4782, 0.3666, 0.5544, 0.388]}, {"w": "you", "b": [0.5596, 0.3666, 0.5908, 0.388]}, {"w": "could", "b": [0.596, 0.3666, 0.6428, 0.388]}, {"w": "just", "b": [0.6479, 0.3666, 0.6783, 0.388]}, {"w": "load", "b": [0.6835, 0.3666, 0.7196, 0.388]}, {"w": "a", "b": [0.7247, 0.3666, 0.7339, 0.388]}, {"w": "trained", "b": [0.7391, 0.3666, 0.7991, 0.388]}, {"w": "model", "b": [0.8043, 0.3666, 0.8571, 0.388]}, {"w": "and", "b": [0.1428, 0.3856, 0.1744, 0.407]}, {"w": "continue", "b": [0.1794, 0.3856, 0.2526, 0.407]}, {"w": "training", "b": [0.2576, 0.3856, 0.3246, 0.407]}, {"w": "where", "b": [0.3295, 0.3856, 0.3804, 0.407]}, {"w": "it", "b": [0.3853, 0.3856, 0.3973, 0.407]}, {"w": "left", "b": [0.4022, 0.3856, 0.4289, 0.407]}, {"w": "off,", "b": [0.4338, 0.3856, 0.4616, 0.407]}, {"w": "no", "b": [0.4665, 0.3856, 0.4885, 0.407]}, {"w": "problem.", "b": [0.4935, 0.3856, 0.5693, 0.407]}, {"w": "However,", "b": [0.5743, 0.3856, 0.6531, 0.407]}, {"w": "things", "b": [0.6581, 0.3856, 0.7099, 0.407]}, {"w": "are", "b": [0.7149, 0.3856, 0.7406, 0.407]}, {"w": "not", "b": [0.7456, 0.3856, 0.774, 0.407]}, {"w": "so", "b": [0.779, 0.3856, 0.7972, 0.407]}, {"w": "simple", "b": [0.8022, 0.3856, 0.8571, 0.407]}, {"w": "if", "b": [0.1429, 0.4056, 0.1546, 0.427]}, {"w": "your", "b": [0.1618, 0.4056, 0.2008, 0.427]}, {"w": "schedule", "b": [0.2079, 0.4056, 0.2806, 0.427]}, {"w": "function", "b": [0.2877, 0.4056, 0.3591, 0.427]}, {"w": "uses", "b": [0.3663, 0.4056, 0.4015, 0.427]}, {"w": "the", "b": [0.4087, 0.4056, 0.435, 0.427]}, {"w": "epoch", "b": [0.4422, 0.4088, 0.4917, 0.4238]}, {"w": "argument:", "b": [0.4988, 0.4056, 0.5845, 0.427]}, {"w": "indeed,", "b": [0.5917, 0.4056, 0.6532, 0.427]}, {"w": "the", "b": [0.6603, 0.4056, 0.6867, 0.427]}, {"w": "epoch", "b": [0.6938, 0.4056, 0.7442, 0.427]}, {"w": "does", "b": [0.7513, 0.4056, 0.7895, 0.427]}, {"w": "not", "b": [0.7966, 0.4056, 0.825, 0.427]}, {"w": "get", "b": [0.8322, 0.4056, 0.8571, 0.427]}, {"w": "saved,", "b": [0.1429, 0.4255, 0.1935, 0.4469]}, {"w": "and", "b": [0.1984, 0.4255, 0.23, 0.4469]}, {"w": "it", "b": [0.2349, 0.4255, 0.2468, 0.4469]}, {"w": "gets", "b": [0.2517, 0.4255, 0.2843, 0.4469]}, {"w": "reset", "b": [0.2892, 0.4255, 0.3287, 0.4469]}, {"w": "to", "b": [0.3336, 0.4255, 0.3506, 0.4469]}, {"w": "0", "b": [0.3555, 0.4255, 0.3655, 0.4469]}, {"w": "every", "b": [0.3704, 0.4255, 0.4156, 0.4469]}, {"w": "time", "b": [0.4205, 0.4255, 0.4584, 0.4469]}, {"w": "you", "b": [0.4633, 0.4255, 0.4945, 0.4469]}, {"w": "call", "b": [0.4994, 0.4255, 0.5279, 0.4469]}, {"w": "the", "b": [0.5328, 0.4255, 0.5592, 0.4469]}, {"w": "fit()", "b": [0.5641, 0.4287, 0.6136, 0.4438]}, {"w": "method.", "b": [0.6185, 0.4255, 0.6883, 0.4469]}, {"w": "This", "b": [0.6932, 0.4255, 0.7304, 0.4469]}, {"w": "could", "b": [0.7353, 0.4255, 0.782, 0.4469]}, {"w": "lead", "b": [0.7869, 0.4255, 0.8212, 0.4469]}, {"w": "to", "b": [0.8261, 0.4255, 0.8431, 0.4469]}, {"w": "a", "b": [0.848, 0.4255, 0.8572, 0.4469]}, {"w": "very", "b": [0.1429, 0.4446, 0.1793, 0.466]}, {"w": "large", "b": [0.1856, 0.4446, 0.2264, 0.466]}, {"w": "learning", "b": [0.2328, 0.4446, 0.3019, 0.466]}, {"w": "rate", "b": [0.3082, 0.4446, 0.3399, 0.466]}, {"w": "when", "b": [0.3463, 0.4446, 0.392, 0.466]}, {"w": "you", "b": [0.3983, 0.4446, 0.4296, 0.466]}, {"w": "continue", "b": [0.4359, 0.4446, 0.5092, 0.466]}, {"w": "training", "b": [0.5156, 0.4446, 0.5825, 0.466]}, {"w": "a", "b": [0.5889, 0.4446, 0.5981, 0.466]}, {"w": "model", "b": [0.6044, 0.4446, 0.6572, 0.466]}, {"w": "where", "b": [0.6636, 0.4446, 0.7145, 0.466]}, {"w": "it", "b": [0.7208, 0.4446, 0.7328, 0.466]}, {"w": "left", "b": [0.7391, 0.4446, 0.7658, 0.466]}, {"w": "off,", "b": [0.7722, 0.4446, 0.7999, 0.466]}, {"w": "which", "b": [0.8062, 0.4446, 0.8571, 0.466]}, {"w": "would", "b": [0.1429, 0.4645, 0.1951, 0.4859]}, {"w": "likely", "b": [0.2006, 0.4645, 0.2455, 0.4859]}, {"w": "damage", "b": [0.251, 0.4645, 0.316, 0.4859]}, {"w": "your", "b": [0.3215, 0.4645, 0.3605, 0.4859]}, {"w": "model’s", "b": [0.366, 0.4645, 0.4286, 0.4859]}, {"w": "weights.", "b": [0.4342, 0.4645, 0.5021, 0.4859]}, {"w": "One", "b": [0.5076, 0.4645, 0.5434, 0.4859]}, {"w": "solution", "b": [0.549, 0.4645, 0.6175, 0.4859]}, {"w": "is", "b": [0.6231, 0.4645, 0.6363, 0.4859]}, {"w": "to", "b": [0.6418, 0.4645, 0.6588, 0.4859]}, {"w": "manually", "b": [0.6644, 0.4645, 0.7419, 0.4859]}, {"w": "set", "b": [0.7474, 0.4645, 0.7703, 0.4859]}, {"w": "the", "b": [0.7758, 0.4645, 0.8021, 0.4859]}, {"w": "fit()", "b": [0.8077, 0.4677, 0.8571, 0.4828]}, {"w": "method’s", "b": [0.1429, 0.4845, 0.2176, 0.5059]}, {"w": "initial_epoch", "b": [0.2224, 0.4876, 0.351, 0.5027]}, {"w": "argument", "b": [0.3557, 0.4845, 0.4367, 0.5059]}, {"w": "so", "b": [0.4414, 0.4845, 0.4597, 0.5059]}, {"w": "the", "b": [0.4644, 0.4845, 0.4908, 0.5059]}, {"w": "epoch", "b": [0.4955, 0.4876, 0.545, 0.5027]}, {"w": "starts", "b": [0.5497, 0.4845, 0.5946, 0.5059]}, {"w": "at", "b": [0.5993, 0.4845, 0.6144, 0.5059]}, {"w": "the", "b": [0.6191, 0.4845, 0.6455, 0.5059]}, {"w": "right", "b": [0.6502, 0.4845, 0.6904, 0.5059]}, {"w": "value.", "b": [0.6951, 0.4845, 0.7438, 0.5059]}]}, {"id": "b_4", "type": "paragraph", "text": "For piecewise constant scheduling, you can use a schedule function like the following one (as earlier, you can define a more general function if you want, see the notebook for an example), then create a LearningRateScheduler callback with this function and pass it to the fit() method, just like we did for exponential scheduling:", "words": [{"w": "For", "b": [0.1429, 0.5126, 0.1718, 0.534]}, {"w": "piecewise", "b": [0.1771, 0.5126, 0.2564, 0.534]}, {"w": "constant", "b": [0.2617, 0.5126, 0.333, 0.534]}, {"w": "scheduling,", "b": [0.3382, 0.5126, 0.4335, 0.534]}, {"w": "you", "b": [0.4387, 0.5126, 0.4699, 0.534]}, {"w": "can", "b": [0.4752, 0.5126, 0.5045, 0.534]}, {"w": "use", "b": [0.5097, 0.5126, 0.5373, 0.534]}, {"w": "a", "b": [0.5425, 0.5126, 0.5517, 0.534]}, {"w": "schedule", "b": [0.5569, 0.5126, 0.6295, 0.534]}, {"w": "function", "b": [0.6347, 0.5126, 0.7061, 0.534]}, {"w": "like", "b": [0.7114, 0.5126, 0.7414, 0.534]}, {"w": "the", "b": [0.7466, 0.5126, 0.773, 0.534]}, {"w": "following", "b": [0.7782, 0.5126, 0.8571, 0.534]}, {"w": "one", "b": [0.1429, 0.5316, 0.1737, 0.553]}, {"w": "(as", "b": [0.1794, 0.5316, 0.2034, 0.553]}, {"w": "earlier,", "b": [0.2091, 0.5316, 0.2657, 0.553]}, {"w": "you", "b": [0.2713, 0.5316, 0.3026, 0.553]}, {"w": "can", "b": [0.3082, 0.5316, 0.3376, 0.553]}, {"w": "define", "b": [0.3433, 0.5316, 0.3951, 0.553]}, {"w": "a", "b": [0.4008, 0.5316, 0.4099, 0.553]}, {"w": "more", "b": [0.4156, 0.5316, 0.4599, 0.553]}, {"w": "general", "b": [0.4655, 0.5316, 0.5265, 0.553]}, {"w": "function", "b": [0.5322, 0.5316, 0.6036, 0.553]}, {"w": "if", "b": [0.6092, 0.5316, 0.621, 0.553]}, {"w": "you", "b": [0.6267, 0.5316, 0.6579, 0.553]}, {"w": "want,", "b": [0.6636, 0.5316, 0.7091, 0.553]}, {"w": "see", "b": [0.7147, 0.5316, 0.7401, 0.553]}, {"w": "the", "b": [0.7458, 0.5316, 0.7721, 0.553]}, {"w": "notebook", "b": [0.7778, 0.5316, 0.8572, 0.553]}, {"w": "for", "b": [0.1429, 0.5516, 0.1674, 0.573]}, {"w": "an", "b": [0.1751, 0.5516, 0.1956, 0.573]}, {"w": "example),", "b": [0.2033, 0.5516, 0.2848, 0.573]}, {"w": "then", "b": [0.2925, 0.5516, 0.3302, 0.573]}, {"w": "create", "b": [0.3379, 0.5516, 0.3873, 0.573]}, {"w": "a", "b": [0.3949, 0.5516, 0.4041, 0.573]}, {"w": "LearningRateScheduler", "b": [0.4118, 0.5547, 0.6196, 0.5698]}, {"w": "callback", "b": [0.6273, 0.5516, 0.6946, 0.573]}, {"w": "with", "b": [0.7023, 0.5516, 0.7397, 0.573]}, {"w": "this", "b": [0.7474, 0.5516, 0.7781, 0.573]}, {"w": "function", "b": [0.7858, 0.5516, 0.8571, 0.573]}, {"w": "and", "b": [0.1429, 0.5715, 0.1744, 0.5929]}, {"w": "pass", "b": [0.1791, 0.5715, 0.2145, 0.5929]}, {"w": "it", "b": [0.2192, 0.5715, 0.2311, 0.5929]}, {"w": "to", "b": [0.2359, 0.5715, 0.2529, 0.5929]}, {"w": "the", "b": [0.2576, 0.5715, 0.2839, 0.5929]}, {"w": "fit()", "b": [0.2886, 0.5747, 0.3381, 0.5898]}, {"w": "method,", "b": [0.3429, 0.5715, 0.4126, 0.5929]}, {"w": "just", "b": [0.4174, 0.5715, 0.4478, 0.5929]}, {"w": "like", "b": [0.4525, 0.5715, 0.4825, 0.5929]}, {"w": "we", "b": [0.4873, 0.5715, 0.5104, 0.5929]}, {"w": "did", "b": [0.5151, 0.5715, 0.5427, 0.5929]}, {"w": "for", "b": [0.5474, 0.5715, 0.5719, 0.5929]}, {"w": "exponential", "b": [0.5767, 0.5715, 0.6745, 0.5929]}, {"w": "scheduling:", "b": [0.6792, 0.5715, 0.7745, 0.5929]}]}, {"id": "b_5", "type": "paragraph", "text": "def piecewise_constant_fn(epoch): if epoch < 5: return 0.01 elif epoch < 15: return 0.005 else: return 0.001", "words": [{"w": "def", "b": [0.1766, 0.6035, 0.2019, 0.6163]}, {"w": "piecewise_constant_fn(epoch):", "b": [0.2103, 0.6035, 0.4549, 0.6163]}, {"w": "if", "b": [0.2103, 0.6189, 0.2272, 0.6318]}, {"w": "epoch", "b": [0.2356, 0.6189, 0.2778, 0.6318]}, {"w": "<", "b": [0.2862, 0.6189, 0.2947, 0.6318]}, {"w": "5:", "b": [0.3031, 0.6189, 0.3199, 0.6318]}, {"w": "return", "b": [0.2441, 0.6343, 0.2947, 0.6472]}, {"w": "0.01", "b": [0.3031, 0.6343, 0.3368, 0.6472]}, {"w": "elif", "b": [0.2103, 0.6497, 0.2441, 0.6626]}, {"w": "epoch", "b": [0.2525, 0.6497, 0.2947, 0.6626]}, {"w": "<", "b": [0.3031, 0.6497, 0.3115, 0.6626]}, {"w": "15:", "b": [0.3199, 0.6497, 0.3452, 0.6626]}, {"w": "return", "b": [0.2441, 0.6652, 0.2947, 0.678]}, {"w": "0.005", "b": [0.3031, 0.6652, 0.3452, 0.678]}, {"w": "else:", "b": [0.2103, 0.6806, 0.2525, 0.6934]}, {"w": "return", "b": [0.2441, 0.696, 0.2947, 0.7088]}, {"w": "0.001", "b": [0.3031, 0.696, 0.3452, 0.7088]}]}, {"id": "b_6", "type": "paragraph", "text": "For performance scheduling, simply use the ReduceLROnPlateau callback. For exam‐ ple, if you pass the following callback to the fit() method, it will multiply the learn‐ ing rate by 0.5 whenever the best validation loss does not improve for 5 consecutive epochs (other options are available, please check the documentation for more details):", "words": [{"w": "For", "b": [0.1429, 0.7175, 0.1718, 0.7389]}, {"w": "performance", "b": [0.1776, 0.7175, 0.2849, 0.7389]}, {"w": "scheduling,", "b": [0.2906, 0.7175, 0.3858, 0.7389]}, {"w": "simply", "b": [0.3916, 0.7175, 0.4472, 0.7389]}, {"w": "use", "b": [0.4529, 0.7175, 0.4805, 0.7389]}, {"w": "the", "b": [0.4862, 0.7175, 0.5126, 0.7389]}, {"w": "ReduceLROnPlateau", "b": [0.5183, 0.7207, 0.6865, 0.7358]}, {"w": "callback.", "b": [0.6923, 0.7175, 0.7644, 0.7389]}, {"w": "For", "b": [0.7701, 0.7175, 0.7991, 0.7389]}, {"w": "exam‐", "b": [0.8048, 0.7175, 0.8571, 0.7389]}, {"w": "ple,", "b": [0.1429, 0.7375, 0.1727, 0.7589]}, {"w": "if", "b": [0.1781, 0.7375, 0.1899, 0.7589]}, {"w": "you", "b": [0.1953, 0.7375, 0.2266, 0.7589]}, {"w": "pass", "b": [0.232, 0.7375, 0.2674, 0.7589]}, {"w": "the", "b": [0.2728, 0.7375, 0.2991, 0.7589]}, {"w": "following", "b": [0.3046, 0.7375, 0.3836, 0.7589]}, {"w": "callback", "b": [0.389, 0.7375, 0.4564, 0.7589]}, {"w": "to", "b": [0.4618, 0.7375, 0.4788, 0.7589]}, {"w": "the", "b": [0.4843, 0.7375, 0.5106, 0.7589]}, {"w": "fit()", "b": [0.516, 0.7407, 0.5655, 0.7557]}, {"w": "method,", "b": [0.571, 0.7375, 0.6407, 0.7589]}, {"w": "it", "b": [0.6462, 0.7375, 0.6581, 0.7589]}, {"w": "will", "b": [0.6636, 0.7375, 0.694, 0.7589]}, {"w": "multiply", "b": [0.6994, 0.7375, 0.7701, 0.7589]}, {"w": "the", "b": [0.7756, 0.7375, 0.8019, 0.7589]}, {"w": "learn‐", "b": [0.8073, 0.7375, 0.8572, 0.7589]}, {"w": "ing", "b": [0.1429, 0.7565, 0.1696, 0.7779]}, {"w": "rate", "b": [0.1758, 0.7565, 0.2075, 0.7779]}, {"w": "by", "b": [0.2137, 0.7565, 0.2339, 0.7779]}, {"w": "0.5", "b": [0.2401, 0.7565, 0.2649, 0.7779]}, {"w": "whenever", "b": [0.2711, 0.7565, 0.3518, 0.7779]}, {"w": "the", "b": [0.3581, 0.7565, 0.3844, 0.7779]}, {"w": "best", "b": [0.3906, 0.7565, 0.4241, 0.7779]}, {"w": "validation", "b": [0.4303, 0.7565, 0.5136, 0.7779]}, {"w": "loss", "b": [0.5199, 0.7565, 0.5511, 0.7779]}, {"w": "does", "b": [0.5573, 0.7565, 0.5954, 0.7779]}, {"w": "not", "b": [0.6017, 0.7565, 0.63, 0.7779]}, {"w": "improve", "b": [0.6363, 0.7565, 0.7063, 0.7779]}, {"w": "for", "b": [0.7125, 0.7565, 0.737, 0.7779]}, {"w": "5", "b": [0.7433, 0.7565, 0.7533, 0.7779]}, {"w": "consecutive", "b": [0.7595, 0.7565, 0.8571, 0.7779]}, {"w": "epochs", "b": [0.1429, 0.7756, 0.2008, 0.797]}, {"w": "(other", "b": [0.2126, 0.7756, 0.2645, 0.797]}, {"w": "options", "b": [0.2762, 0.7756, 0.3393, 0.797]}, {"w": "are", "b": [0.3511, 0.7756, 0.3768, 0.797]}, {"w": "available,", "b": [0.3885, 0.7756, 0.4655, 0.797]}, {"w": "please", "b": [0.4773, 0.7756, 0.528, 0.797]}, {"w": "check", "b": [0.5397, 0.7756, 0.5876, 0.797]}, {"w": "the", "b": [0.5993, 0.7756, 0.6257, 0.797]}, {"w": "documentation", "b": [0.6374, 0.7756, 0.7649, 0.797]}, {"w": "for", "b": [0.7766, 0.7756, 0.8011, 0.797]}, {"w": "more", "b": [0.8129, 0.7756, 0.8571, 0.797]}, {"w": "details):", "b": [0.1429, 0.7946, 0.2087, 0.816]}]}, {"id": "b_7", "type": "equation", "text": "lr_scheduler = keras.callbacks.ReduceLROnPlateau(factor=0.5, patience=5)", "words": [{"w": "lr_scheduler", "b": [0.1766, 0.8266, 0.2778, 0.8394]}, {"w": "=", "b": [0.2862, 0.8266, 0.2946, 0.8394]}, {"w": "keras.callbacks.ReduceLROnPlateau(factor=0.5,", "b": [0.3031, 0.8266, 0.6825, 0.8394]}, {"w": "patience=5)", "b": [0.691, 0.8266, 0.7837, 0.8394]}]}, {"id": "b_8", "type": "paragraph", "text": "Lastly, tf.keras offers an alternative way to implement learning rate scheduling: just define the learning rate using one of the schedules available in keras.optimiz", "words": [{"w": "Lastly,", "b": [0.1429, 0.8472, 0.1953, 0.8686]}, {"w": "tf.keras", "b": [0.2024, 0.8472, 0.2634, 0.8686]}, {"w": "offers", "b": [0.2705, 0.8472, 0.3177, 0.8686]}, {"w": "an", "b": [0.3249, 0.8472, 0.3454, 0.8686]}, {"w": "alternative", "b": [0.3526, 0.8472, 0.4405, 0.8686]}, {"w": "way", "b": [0.4477, 0.8472, 0.4803, 0.8686]}, {"w": "to", "b": [0.4874, 0.8472, 0.5044, 0.8686]}, {"w": "implement", "b": [0.5115, 0.8472, 0.6021, 0.8686]}, {"w": "learning", "b": [0.6092, 0.8472, 0.6784, 0.8686]}, {"w": "rate", "b": [0.6855, 0.8472, 0.7172, 0.8686]}, {"w": "scheduling:", "b": [0.7243, 0.8472, 0.8196, 0.8686]}, {"w": "just", "b": [0.8267, 0.8472, 0.8571, 0.8686]}, {"w": "define", "b": [0.1428, 0.8672, 0.1947, 0.8886]}, {"w": "the", "b": [0.2049, 0.8672, 0.2313, 0.8886]}, {"w": "learning", "b": [0.2415, 0.8672, 0.3106, 0.8886]}, {"w": "rate", "b": [0.3208, 0.8672, 0.3525, 0.8886]}, {"w": "using", "b": [0.3627, 0.8672, 0.4082, 0.8886]}, {"w": "one", "b": [0.4184, 0.8672, 0.4493, 0.8886]}, {"w": "of", "b": [0.4595, 0.8672, 0.4763, 0.8886]}, {"w": "the", "b": [0.4865, 0.8672, 0.5129, 0.8886]}, {"w": "schedules", "b": [0.5231, 0.8672, 0.6033, 0.8886]}, {"w": "available", "b": [0.6136, 0.8672, 0.6858, 0.8886]}, {"w": "in", "b": [0.6961, 0.8672, 0.713, 0.8886]}, {"w": "keras.optimiz", "b": [0.7233, 0.8704, 0.8519, 0.8854]}]}, {"id": "b_9", "type": "paragraph", "text": "Faster Optimizers | 355", "words": [{"w": "Faster", "b": [0.6934, 0.9225, 0.7296, 0.9388]}, {"w": "Optimizers", "b": [0.7325, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "355", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 382, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "ers.schedules, then pass this learning rate to any optimizer. This approach updates the learning rate at each step rather than at each epoch. For example, here is how to implement the same exponential schedule as earlier:", "words": [{"w": "ers.schedules,", "b": [0.1429, 0.08, 0.2763, 0.1014]}, {"w": "then", "b": [0.2822, 0.08, 0.3199, 0.1014]}, {"w": "pass", "b": [0.3258, 0.08, 0.3611, 0.1014]}, {"w": "this", "b": [0.3671, 0.08, 0.3978, 0.1014]}, {"w": "learning", "b": [0.4037, 0.08, 0.4728, 0.1014]}, {"w": "rate", "b": [0.4787, 0.08, 0.5104, 0.1014]}, {"w": "to", "b": [0.5163, 0.08, 0.5333, 0.1014]}, {"w": "any", "b": [0.5392, 0.08, 0.5688, 0.1014]}, {"w": "optimizer.", "b": [0.5747, 0.08, 0.6596, 0.1014]}, {"w": "This", "b": [0.6655, 0.08, 0.7027, 0.1014]}, {"w": "approach", "b": [0.7086, 0.08, 0.7867, 0.1014]}, {"w": "updates", "b": [0.7926, 0.08, 0.8571, 0.1014]}, {"w": "the", "b": [0.1429, 0.099, 0.1692, 0.1204]}, {"w": "learning", "b": [0.1753, 0.099, 0.2444, 0.1204]}, {"w": "rate", "b": [0.2505, 0.099, 0.2822, 0.1204]}, {"w": "at", "b": [0.2883, 0.099, 0.3034, 0.1204]}, {"w": "each", "b": [0.3095, 0.099, 0.3474, 0.1204]}, {"w": "step", "b": [0.3535, 0.099, 0.3873, 0.1204]}, {"w": "rather", "b": [0.3934, 0.099, 0.4439, 0.1204]}, {"w": "than", "b": [0.45, 0.099, 0.4881, 0.1204]}, {"w": "at", "b": [0.4942, 0.099, 0.5093, 0.1204]}, {"w": "each", "b": [0.5154, 0.099, 0.5533, 0.1204]}, {"w": "epoch.", "b": [0.5594, 0.099, 0.6145, 0.1204]}, {"w": "For", "b": [0.6206, 0.099, 0.6496, 0.1204]}, {"w": "example,", "b": [0.6557, 0.099, 0.73, 0.1204]}, {"w": "here", "b": [0.736, 0.099, 0.7726, 0.1204]}, {"w": "is", "b": [0.7787, 0.099, 0.7919, 0.1204]}, {"w": "how", "b": [0.798, 0.099, 0.8341, 0.1204]}, {"w": "to", "b": [0.8402, 0.099, 0.8571, 0.1204]}, {"w": "implement", "b": [0.1429, 0.1181, 0.2334, 0.1395]}, {"w": "the", "b": [0.2382, 0.1181, 0.2645, 0.1395]}, {"w": "same", "b": [0.2692, 0.1181, 0.3119, 0.1395]}, {"w": "exponential", "b": [0.3167, 0.1181, 0.4145, 0.1395]}, {"w": "schedule", "b": [0.4192, 0.1181, 0.4918, 0.1395]}, {"w": "as", "b": [0.4966, 0.1181, 0.5134, 0.1395]}, {"w": "earlier:", "b": [0.5181, 0.1181, 0.5765, 0.1395]}]}, {"id": "b_1", "type": "paragraph", "text": "s = 20 * len(X_train) // 32 # number of steps in 20 epochs (batch size = 32) learning_rate = keras.optimizers.schedules.ExponentialDecay(0.01, s, 0.1) optimizer = keras.optimizers.SGD(learning_rate)", "words": [{"w": "s", "b": [0.1766, 0.15, 0.185, 0.1629]}, {"w": "=", "b": [0.1935, 0.15, 0.2019, 0.1629]}, {"w": "20", "b": [0.2103, 0.15, 0.2272, 0.1629]}, {"w": "*", "b": [0.2356, 0.15, 0.2441, 0.1629]}, {"w": "len(X_train)", "b": [0.2525, 0.15, 0.3537, 0.1629]}, {"w": "//", "b": [0.3621, 0.15, 0.379, 0.1629]}, {"w": "32", "b": [0.3874, 0.15, 0.4043, 0.1629]}, {"w": "#", "b": [0.4127, 0.15, 0.4211, 0.1629]}, {"w": "number", "b": [0.4296, 0.15, 0.4802, 0.1629]}, {"w": "of", "b": [0.4886, 0.15, 0.5055, 0.1629]}, {"w": "steps", "b": [0.5139, 0.15, 0.5561, 0.1629]}, {"w": "in", "b": [0.5645, 0.15, 0.5814, 0.1629]}, {"w": "20", "b": [0.5898, 0.15, 0.6067, 0.1629]}, {"w": "epochs", "b": [0.6151, 0.15, 0.6657, 0.1629]}, {"w": "(batch", "b": [0.6741, 0.15, 0.7247, 0.1629]}, {"w": "size", "b": [0.7331, 0.15, 0.7669, 0.1629]}, {"w": "=", "b": [0.7753, 0.15, 0.7837, 0.1629]}, {"w": "32)", "b": [0.7922, 0.15, 0.8175, 0.1629]}, {"w": "learning_rate", "b": [0.1766, 0.1654, 0.2862, 0.1783]}, {"w": "=", "b": [0.2946, 0.1654, 0.3031, 0.1783]}, {"w": "keras.optimizers.schedules.ExponentialDecay(0.01,", "b": [0.3115, 0.1654, 0.7247, 0.1783]}, {"w": "s,", "b": [0.7331, 0.1654, 0.75, 0.1783]}, {"w": "0.1)", "b": [0.7584, 0.1654, 0.7922, 0.1783]}, {"w": "optimizer", "b": [0.1766, 0.1809, 0.2525, 0.1937]}, {"w": "=", "b": [0.2609, 0.1809, 0.2693, 0.1937]}, {"w": "keras.optimizers.SGD(learning_rate)", "b": [0.2778, 0.1809, 0.5729, 0.1937]}]}, {"id": "b_2", "type": "paragraph", "text": "This is nice and simple, plus when you save the model, the learning rate and its schedule (including its state) get saved as well. However, this approach is not part of the Keras API, it is specific to tf.keras.", "words": [{"w": "This", "b": [0.1429, 0.2015, 0.1801, 0.2229]}, {"w": "is", "b": [0.1887, 0.2015, 0.2019, 0.2229]}, {"w": "nice", "b": [0.2105, 0.2015, 0.2452, 0.2229]}, {"w": "and", "b": [0.2538, 0.2015, 0.2853, 0.2229]}, {"w": "simple,", "b": [0.2939, 0.2015, 0.3536, 0.2229]}, {"w": "plus", "b": [0.3622, 0.2015, 0.3971, 0.2229]}, {"w": "when", "b": [0.4057, 0.2015, 0.4514, 0.2229]}, {"w": "you", "b": [0.46, 0.2015, 0.4912, 0.2229]}, {"w": "save", "b": [0.4998, 0.2015, 0.5347, 0.2229]}, {"w": "the", "b": [0.5433, 0.2015, 0.5697, 0.2229]}, {"w": "model,", "b": [0.5783, 0.2015, 0.6358, 0.2229]}, {"w": "the", "b": [0.6444, 0.2015, 0.6708, 0.2229]}, {"w": "learning", "b": [0.6794, 0.2015, 0.7485, 0.2229]}, {"w": "rate", "b": [0.7571, 0.2015, 0.7888, 0.2229]}, {"w": "and", "b": [0.7974, 0.2015, 0.829, 0.2229]}, {"w": "its", "b": [0.8376, 0.2015, 0.8571, 0.2229]}, {"w": "schedule", "b": [0.1429, 0.2205, 0.2155, 0.242]}, {"w": "(including", "b": [0.2215, 0.2205, 0.3085, 0.242]}, {"w": "its", "b": [0.3145, 0.2205, 0.3341, 0.242]}, {"w": "state)", "b": [0.34, 0.2205, 0.3852, 0.242]}, {"w": "get", "b": [0.3912, 0.2205, 0.4161, 0.242]}, {"w": "saved", "b": [0.4221, 0.2205, 0.468, 0.242]}, {"w": "as", "b": [0.474, 0.2205, 0.4908, 0.242]}, {"w": "well.", "b": [0.4968, 0.2205, 0.5352, 0.242]}, {"w": "However,", "b": [0.5412, 0.2205, 0.62, 0.242]}, {"w": "this", "b": [0.626, 0.2205, 0.6567, 0.242]}, {"w": "approach", "b": [0.6627, 0.2205, 0.7407, 0.242]}, {"w": "is", "b": [0.7467, 0.2205, 0.7599, 0.242]}, {"w": "not", "b": [0.7659, 0.2205, 0.7943, 0.242]}, {"w": "part", "b": [0.8002, 0.2205, 0.8344, 0.242]}, {"w": "of", "b": [0.8403, 0.2205, 0.8571, 0.242]}, {"w": "the", "b": [0.1429, 0.2396, 0.1692, 0.261]}, {"w": "Keras", "b": [0.1739, 0.2396, 0.2208, 0.261]}, {"w": "API,", "b": [0.2256, 0.2396, 0.2635, 0.261]}, {"w": "it", "b": [0.2683, 0.2396, 0.2802, 0.261]}, {"w": "is", "b": [0.2849, 0.2396, 0.2982, 0.261]}, {"w": "specific", "b": [0.3029, 0.2396, 0.3653, 0.261]}, {"w": "to", "b": [0.37, 0.2396, 0.387, 0.261]}, {"w": "tf.keras.", "b": [0.3917, 0.2396, 0.4574, 0.261]}]}, {"id": "b_3", "type": "paragraph", "text": "To sum up, exponential decay or performance scheduling can considerably speed up convergence, so give them a try!", "words": [{"w": "To", "b": [0.1429, 0.2677, 0.1643, 0.2891]}, {"w": "sum", "b": [0.1702, 0.2677, 0.206, 0.2891]}, {"w": "up,", "b": [0.2119, 0.2677, 0.238, 0.2891]}, {"w": "exponential", "b": [0.244, 0.2677, 0.3418, 0.2891]}, {"w": "decay", "b": [0.3477, 0.2677, 0.3947, 0.2891]}, {"w": "or", "b": [0.4007, 0.2677, 0.419, 0.2891]}, {"w": "performance", "b": [0.4249, 0.2677, 0.5322, 0.2891]}, {"w": "scheduling", "b": [0.5381, 0.2677, 0.6286, 0.2891]}, {"w": "can", "b": [0.6346, 0.2677, 0.6639, 0.2891]}, {"w": "considerably", "b": [0.6698, 0.2677, 0.7761, 0.2891]}, {"w": "speed", "b": [0.782, 0.2677, 0.8293, 0.2891]}, {"w": "up", "b": [0.8352, 0.2677, 0.8572, 0.2891]}, {"w": "convergence,", "b": [0.1429, 0.2868, 0.2519, 0.3082]}, {"w": "so", "b": [0.2566, 0.2868, 0.2749, 0.3082]}, {"w": "give", "b": [0.2796, 0.2868, 0.3134, 0.3082]}, {"w": "them", "b": [0.3182, 0.2868, 0.3615, 0.3082]}, {"w": "a", "b": [0.3663, 0.2868, 0.3754, 0.3082]}, {"w": "try!", "b": [0.3802, 0.2868, 0.4102, 0.3082]}]}, {"id": "b_4", "type": "paragraph", "text": "Avoiding Overfitting Through Regularization", "words": [{"w": "Avoiding", "b": [0.1429, 0.3212, 0.2527, 0.3554]}, {"w": "Overfitting", "b": [0.2586, 0.3212, 0.3937, 0.3554]}, {"w": "Through", "b": [0.3997, 0.3212, 0.504, 0.3554]}, {"w": "Regularization", "b": [0.51, 0.3212, 0.6916, 0.3554]}]}, {"id": "b_5", "type": "paragraph", "text": "With four parameters I can fit an elephant and with five I can make him wiggle his trunk.", "words": [{"w": "With", "b": [0.1786, 0.3626, 0.2162, 0.3816]}, {"w": "four", "b": [0.2225, 0.3626, 0.2541, 0.3816]}, {"w": "parameters", "b": [0.2604, 0.3626, 0.3432, 0.3816]}, {"w": "I", "b": [0.3496, 0.3626, 0.3559, 0.3816]}, {"w": "can", "b": [0.3622, 0.3626, 0.3882, 0.3816]}, {"w": "fit", "b": [0.3946, 0.3626, 0.4106, 0.3816]}, {"w": "an", "b": [0.417, 0.3626, 0.4352, 0.3816]}, {"w": "elephant", "b": [0.4416, 0.3626, 0.5049, 0.3816]}, {"w": "and", "b": [0.5113, 0.3626, 0.5392, 0.3816]}, {"w": "with", "b": [0.5456, 0.3626, 0.5787, 0.3816]}, {"w": "five", "b": [0.585, 0.3626, 0.6118, 0.3816]}, {"w": "I", "b": [0.6182, 0.3626, 0.6245, 0.3816]}, {"w": "can", "b": [0.6309, 0.3626, 0.6569, 0.3816]}, {"w": "make", "b": [0.6633, 0.3626, 0.7035, 0.3816]}, {"w": "him", "b": [0.7098, 0.3626, 0.7397, 0.3816]}, {"w": "wiggle", "b": [0.7461, 0.3626, 0.7935, 0.3816]}, {"w": "his", "b": [0.7999, 0.3626, 0.8214, 0.3816]}, {"w": "trunk.", "b": [0.1786, 0.3795, 0.2243, 0.3985]}]}, {"id": "b_6", "type": "paragraph", "text": "—John von Neumann, cited by Enrico Fermi in Nature 427", "words": [{"w": "—John", "b": [0.2062, 0.4024, 0.2583, 0.4214]}, {"w": "von", "b": [0.2625, 0.4024, 0.2905, 0.4214]}, {"w": "Neumann,", "b": [0.2947, 0.4024, 0.3732, 0.4214]}, {"w": "cited", "b": [0.3774, 0.4022, 0.4114, 0.4214]}, {"w": "by", "b": [0.4156, 0.4022, 0.4325, 0.4214]}, {"w": "Enrico", "b": [0.4367, 0.4022, 0.4837, 0.4214]}, {"w": "Fermi", "b": [0.4879, 0.4022, 0.5306, 0.4214]}, {"w": "in", "b": [0.5348, 0.4022, 0.5494, 0.4214]}, {"w": "Nature", "b": [0.5537, 0.4022, 0.6037, 0.4214]}, {"w": "427", "b": [0.6079, 0.4022, 0.6343, 0.4214]}]}, {"id": "b_7", "type": "paragraph", "text": "With thousands of parameters you can fit the whole zoo. Deep neural networks typi‐ cally have tens of thousands of parameters, sometimes even millions. With so many parameters, the network has an incredible amount of freedom and can fit a huge vari‐ ety of complex datasets. But this great flexibility also means that it is prone to overfit‐ ting the training set. We need regularization.", "words": [{"w": "With", "b": [0.1429, 0.4311, 0.1853, 0.4525]}, {"w": "thousands", "b": [0.1908, 0.4311, 0.2768, 0.4525]}, {"w": "of", "b": [0.2823, 0.4311, 0.2991, 0.4525]}, {"w": "parameters", "b": [0.3047, 0.4311, 0.3981, 0.4525]}, {"w": "you", "b": [0.4036, 0.4311, 0.4349, 0.4525]}, {"w": "can", "b": [0.4404, 0.4311, 0.4698, 0.4525]}, {"w": "fit", "b": [0.4753, 0.4311, 0.4934, 0.4525]}, {"w": "the", "b": [0.4989, 0.4311, 0.5252, 0.4525]}, {"w": "whole", "b": [0.5308, 0.4311, 0.5809, 0.4525]}, {"w": "zoo.", "b": [0.5864, 0.4311, 0.6206, 0.4525]}, {"w": "Deep", "b": [0.6261, 0.4311, 0.6701, 0.4525]}, {"w": "neural", "b": [0.6756, 0.4311, 0.729, 0.4525]}, {"w": "networks", "b": [0.7346, 0.4311, 0.8118, 0.4525]}, {"w": "typi‐", "b": [0.8173, 0.4311, 0.8571, 0.4525]}, {"w": "cally", "b": [0.1429, 0.4501, 0.1809, 0.4716]}, {"w": "have", "b": [0.1873, 0.4501, 0.2257, 0.4716]}, {"w": "tens", "b": [0.2321, 0.4501, 0.2664, 0.4716]}, {"w": "of", "b": [0.2728, 0.4501, 0.2896, 0.4716]}, {"w": "thousands", "b": [0.296, 0.4501, 0.382, 0.4716]}, {"w": "of", "b": [0.3884, 0.4501, 0.4052, 0.4716]}, {"w": "parameters,", "b": [0.4116, 0.4501, 0.5097, 0.4716]}, {"w": "sometimes", "b": [0.5161, 0.4501, 0.6058, 0.4716]}, {"w": "even", "b": [0.6122, 0.4501, 0.651, 0.4716]}, {"w": "millions.", "b": [0.6574, 0.4501, 0.7306, 0.4716]}, {"w": "With", "b": [0.737, 0.4501, 0.7794, 0.4716]}, {"w": "so", "b": [0.7858, 0.4501, 0.8041, 0.4716]}, {"w": "many", "b": [0.8105, 0.4501, 0.8572, 0.4716]}, {"w": "parameters,", "b": [0.1429, 0.4692, 0.241, 0.4906]}, {"w": "the", "b": [0.2459, 0.4692, 0.2722, 0.4906]}, {"w": "network", "b": [0.2771, 0.4692, 0.3466, 0.4906]}, {"w": "has", "b": [0.3514, 0.4692, 0.3794, 0.4906]}, {"w": "an", "b": [0.3842, 0.4692, 0.4047, 0.4906]}, {"w": "incredible", "b": [0.4096, 0.4692, 0.4932, 0.4906]}, {"w": "amount", "b": [0.4981, 0.4692, 0.5633, 0.4906]}, {"w": "of", "b": [0.5682, 0.4692, 0.585, 0.4906]}, {"w": "freedom", "b": [0.5898, 0.4692, 0.6601, 0.4906]}, {"w": "and", "b": [0.6649, 0.4692, 0.6965, 0.4906]}, {"w": "can", "b": [0.7013, 0.4692, 0.7306, 0.4906]}, {"w": "fit", "b": [0.7355, 0.4692, 0.7536, 0.4906]}, {"w": "a", "b": [0.7584, 0.4692, 0.7676, 0.4906]}, {"w": "huge", "b": [0.7724, 0.4692, 0.8128, 0.4906]}, {"w": "vari‐", "b": [0.8176, 0.4692, 0.8571, 0.4906]}, {"w": "ety", "b": [0.1429, 0.4882, 0.1676, 0.5097]}, {"w": "of", "b": [0.1728, 0.4882, 0.1896, 0.5097]}, {"w": "complex", "b": [0.1947, 0.4882, 0.2657, 0.5097]}, {"w": "datasets.", "b": [0.2709, 0.4882, 0.3414, 0.5097]}, {"w": "But", "b": [0.3465, 0.4882, 0.3762, 0.5097]}, {"w": "this", "b": [0.3814, 0.4882, 0.4121, 0.5097]}, {"w": "great", "b": [0.4172, 0.4882, 0.4587, 0.5097]}, {"w": "flexibility", "b": [0.4638, 0.4882, 0.5425, 0.5097]}, {"w": "also", "b": [0.5476, 0.4882, 0.5803, 0.5097]}, {"w": "means", "b": [0.5855, 0.4882, 0.6396, 0.5097]}, {"w": "that", "b": [0.6447, 0.4882, 0.6773, 0.5097]}, {"w": "it", "b": [0.6825, 0.4882, 0.6944, 0.5097]}, {"w": "is", "b": [0.6996, 0.4882, 0.7128, 0.5097]}, {"w": "prone", "b": [0.718, 0.4882, 0.7675, 0.5097]}, {"w": "to", "b": [0.7726, 0.4882, 0.7896, 0.5097]}, {"w": "overfit‐", "b": [0.7948, 0.4882, 0.8571, 0.5097]}, {"w": "ting", "b": [0.1428, 0.5073, 0.1759, 0.5287]}, {"w": "the", "b": [0.1807, 0.5073, 0.207, 0.5287]}, {"w": "training", "b": [0.2117, 0.5073, 0.2787, 0.5287]}, {"w": "set.", "b": [0.2834, 0.5073, 0.311, 0.5287]}, {"w": "We", "b": [0.3157, 0.5073, 0.3428, 0.5287]}, {"w": "need", "b": [0.3475, 0.5073, 0.3876, 0.5287]}, {"w": "regularization.", "b": [0.3923, 0.5073, 0.5137, 0.5287]}]}, {"id": "b_8", "type": "paragraph", "text": "We already implemented one of the best regularization techniques in Chapter 10: early stopping. Moreover, even though Batch Normalization was designed to solve the vanishing/exploding gradients problems, is also acts like a pretty good regularizer. In this section we will present other popular regularization techniques for neural net‐ works: ℓ1 and ℓ2 regularization, dropout and max-norm regularization.", "words": [{"w": "We", "b": [0.1428, 0.5354, 0.1699, 0.5568]}, {"w": "already", "b": [0.1783, 0.5354, 0.239, 0.5568]}, {"w": "implemented", "b": [0.2474, 0.5354, 0.3578, 0.5568]}, {"w": "one", "b": [0.3662, 0.5354, 0.3971, 0.5568]}, {"w": "of", "b": [0.4055, 0.5354, 0.4223, 0.5568]}, {"w": "the", "b": [0.4307, 0.5354, 0.4571, 0.5568]}, {"w": "best", "b": [0.4655, 0.5354, 0.4989, 0.5568]}, {"w": "regularization", "b": [0.5073, 0.5354, 0.6239, 0.5568]}, {"w": "techniques", "b": [0.6323, 0.5354, 0.7226, 0.5568]}, {"w": "in", "b": [0.731, 0.5354, 0.748, 0.5568]}, {"w": "Chapter", "b": [0.7564, 0.5354, 0.824, 0.5568]}, {"w": "10:", "b": [0.8324, 0.5354, 0.8571, 0.5568]}, {"w": "early", "b": [0.1429, 0.5545, 0.1834, 0.5759]}, {"w": "stopping.", "b": [0.1912, 0.5545, 0.2692, 0.5759]}, {"w": "Moreover,", "b": [0.277, 0.5545, 0.3625, 0.5759]}, {"w": "even", "b": [0.3703, 0.5545, 0.4091, 0.5759]}, {"w": "though", "b": [0.4169, 0.5545, 0.477, 0.5759]}, {"w": "Batch", "b": [0.4848, 0.5545, 0.5321, 0.5759]}, {"w": "Normalization", "b": [0.5399, 0.5545, 0.6617, 0.5759]}, {"w": "was", "b": [0.6695, 0.5545, 0.7006, 0.5759]}, {"w": "designed", "b": [0.7084, 0.5545, 0.7825, 0.5759]}, {"w": "to", "b": [0.7903, 0.5545, 0.8073, 0.5759]}, {"w": "solve", "b": [0.8151, 0.5545, 0.8572, 0.5759]}, {"w": "the", "b": [0.1429, 0.5735, 0.1692, 0.5949]}, {"w": "vanishing/exploding", "b": [0.174, 0.5735, 0.3454, 0.5949]}, {"w": "gradients", "b": [0.3503, 0.5735, 0.4273, 0.5949]}, {"w": "problems,", "b": [0.4322, 0.5735, 0.5156, 0.5949]}, {"w": "is", "b": [0.5205, 0.5735, 0.5337, 0.5949]}, {"w": "also", "b": [0.5386, 0.5735, 0.5712, 0.5949]}, {"w": "acts", "b": [0.5761, 0.5735, 0.6081, 0.5949]}, {"w": "like", "b": [0.6129, 0.5735, 0.6429, 0.5949]}, {"w": "a", "b": [0.6478, 0.5735, 0.6569, 0.5949]}, {"w": "pretty", "b": [0.6618, 0.5735, 0.7116, 0.5949]}, {"w": "good", "b": [0.7164, 0.5735, 0.7584, 0.5949]}, {"w": "regularizer.", "b": [0.7632, 0.5735, 0.8571, 0.5949]}, {"w": "In", "b": [0.1429, 0.5926, 0.1614, 0.614]}, {"w": "this", "b": [0.1665, 0.5926, 0.1972, 0.614]}, {"w": "section", "b": [0.2023, 0.5926, 0.2616, 0.614]}, {"w": "we", "b": [0.2667, 0.5926, 0.2899, 0.614]}, {"w": "will", "b": [0.295, 0.5926, 0.3254, 0.614]}, {"w": "present", "b": [0.3305, 0.5926, 0.3919, 0.614]}, {"w": "other", "b": [0.397, 0.5926, 0.4417, 0.614]}, {"w": "popular", "b": [0.4469, 0.5926, 0.5125, 0.614]}, {"w": "regularization", "b": [0.5177, 0.5926, 0.6343, 0.614]}, {"w": "techniques", "b": [0.6394, 0.5926, 0.7297, 0.614]}, {"w": "for", "b": [0.7349, 0.5926, 0.7594, 0.614]}, {"w": "neural", "b": [0.7645, 0.5926, 0.818, 0.614]}, {"w": "net‐", "b": [0.8231, 0.5926, 0.8571, 0.614]}, {"w": "works:", "b": [0.1429, 0.6116, 0.1982, 0.633]}, {"w": "ℓ1", "b": [0.203, 0.6116, 0.2175, 0.6339]}, {"w": "and", "b": [0.2222, 0.6116, 0.2538, 0.633]}, {"w": "ℓ2", "b": [0.2585, 0.6116, 0.2731, 0.6339]}, {"w": "regularization,", "b": [0.2778, 0.6116, 0.3991, 0.633]}, {"w": "dropout", "b": [0.4039, 0.6116, 0.4722, 0.633]}, {"w": "and", "b": [0.4769, 0.6116, 0.5084, 0.633]}, {"w": "max-norm", "b": [0.5132, 0.6116, 0.6034, 0.633]}, {"w": "regularization.", "b": [0.6082, 0.6116, 0.7295, 0.633]}]}, {"id": "b_9", "type": "paragraph", "text": "ℓ1 and ℓ2 Regularization", "words": [{"w": "ℓ1", "b": [0.1429, 0.6458, 0.1614, 0.6755]}, {"w": "and", "b": [0.1663, 0.6458, 0.2056, 0.6743]}, {"w": "ℓ2", "b": [0.2105, 0.6458, 0.229, 0.6755]}, {"w": "Regularization", "b": [0.2339, 0.6458, 0.3854, 0.6743]}]}, {"id": "b_10", "type": "paragraph", "text": "Just like you did in Chapter 4 for simple linear models, you can use ℓ1 and ℓ2 regulari‐ zation to constrain a neural network’s connection weights (but typically not its bia‐ ses). Here is how to apply ℓ2 regularization to a Keras layer’s connection weights, using a regularization factor of 0.01:", "words": [{"w": "Just", "b": [0.1429, 0.6802, 0.1741, 0.7017]}, {"w": "like", "b": [0.1792, 0.6802, 0.2092, 0.7017]}, {"w": "you", "b": [0.2142, 0.6802, 0.2455, 0.7017]}, {"w": "did", "b": [0.2505, 0.6802, 0.2781, 0.7017]}, {"w": "in", "b": [0.2831, 0.6802, 0.3001, 0.7017]}, {"w": "Chapter", "b": [0.3051, 0.6802, 0.3727, 0.7017]}, {"w": "4", "b": [0.3775, 0.6802, 0.3875, 0.7017]}, {"w": "for", "b": [0.3928, 0.6802, 0.4173, 0.7017]}, {"w": "simple", "b": [0.4223, 0.6802, 0.4773, 0.7017]}, {"w": "linear", "b": [0.4823, 0.6802, 0.5303, 0.7017]}, {"w": "models,", "b": [0.5353, 0.6802, 0.6005, 0.7017]}, {"w": "you", "b": [0.6056, 0.6802, 0.6368, 0.7017]}, {"w": "can", "b": [0.6419, 0.6802, 0.6712, 0.7017]}, {"w": "use", "b": [0.6762, 0.6802, 0.7038, 0.7017]}, {"w": "ℓ1", "b": [0.7088, 0.6802, 0.7234, 0.7025]}, {"w": "and", "b": [0.7284, 0.6802, 0.76, 0.7017]}, {"w": "ℓ2", "b": [0.7647, 0.6802, 0.7796, 0.7025]}, {"w": "regulari‐", "b": [0.7846, 0.6802, 0.8571, 0.7017]}, {"w": "zation", "b": [0.1429, 0.6993, 0.1943, 0.7207]}, {"w": "to", "b": [0.2012, 0.6993, 0.2181, 0.7207]}, {"w": "constrain", "b": [0.225, 0.6993, 0.3037, 0.7207]}, {"w": "a", "b": [0.3105, 0.6993, 0.3197, 0.7207]}, {"w": "neural", "b": [0.3265, 0.6993, 0.38, 0.7207]}, {"w": "network’s", "b": [0.3868, 0.6993, 0.4658, 0.7207]}, {"w": "connection", "b": [0.4727, 0.6993, 0.5665, 0.7207]}, {"w": "weights", "b": [0.5734, 0.6993, 0.6366, 0.7207]}, {"w": "(but", "b": [0.6434, 0.6993, 0.6786, 0.7207]}, {"w": "typically", "b": [0.6855, 0.6993, 0.7559, 0.7207]}, {"w": "not", "b": [0.7628, 0.6993, 0.7912, 0.7207]}, {"w": "its", "b": [0.798, 0.6993, 0.8176, 0.7207]}, {"w": "bia‐", "b": [0.8244, 0.6993, 0.8572, 0.7207]}, {"w": "ses).", "b": [0.1429, 0.7183, 0.179, 0.7398]}, {"w": "Here", "b": [0.1874, 0.7183, 0.2282, 0.7398]}, {"w": "is", "b": [0.2366, 0.7183, 0.2499, 0.7398]}, {"w": "how", "b": [0.2583, 0.7183, 0.2943, 0.7398]}, {"w": "to", "b": [0.3027, 0.7183, 0.3197, 0.7398]}, {"w": "apply", "b": [0.3281, 0.7183, 0.3735, 0.7398]}, {"w": "ℓ2", "b": [0.3819, 0.7183, 0.3964, 0.7406]}, {"w": "regularization", "b": [0.4048, 0.7183, 0.5214, 0.7398]}, {"w": "to", "b": [0.5298, 0.7183, 0.5468, 0.7398]}, {"w": "a", "b": [0.5552, 0.7183, 0.5644, 0.7398]}, {"w": "Keras", "b": [0.5728, 0.7183, 0.6197, 0.7398]}, {"w": "layer’s", "b": [0.6281, 0.7183, 0.6786, 0.7398]}, {"w": "connection", "b": [0.687, 0.7183, 0.7808, 0.7398]}, {"w": "weights,", "b": [0.7892, 0.7183, 0.8571, 0.7398]}, {"w": "using", "b": [0.1429, 0.7374, 0.1883, 0.7588]}, {"w": "a", "b": [0.193, 0.7374, 0.2022, 0.7588]}, {"w": "regularization", "b": [0.2069, 0.7374, 0.3235, 0.7588]}, {"w": "factor", "b": [0.3282, 0.7374, 0.377, 0.7588]}, {"w": "of", "b": [0.3818, 0.7374, 0.3986, 0.7588]}, {"w": "0.01:", "b": [0.4033, 0.7374, 0.4428, 0.7588]}]}, {"id": "b_11", "type": "paragraph", "text": "layer = keras.layers.Dense(100, activation=\"elu\", kernel_initializer=\"he_normal\", kernel_regularizer=keras.regularizers.l2(0.01))", "words": [{"w": "layer", "b": [0.1766, 0.7694, 0.2188, 0.7822]}, {"w": "=", "b": [0.2272, 0.7694, 0.2356, 0.7822]}, {"w": "keras.layers.Dense(100,", "b": [0.2441, 0.7694, 0.438, 0.7822]}, {"w": "activation=\"elu\",", "b": [0.4464, 0.7694, 0.5898, 0.7822]}, {"w": "kernel_initializer=\"he_normal\",", "b": [0.4043, 0.7848, 0.6657, 0.7976]}, {"w": "kernel_regularizer=keras.regularizers.l2(0.01))", "b": [0.4043, 0.8002, 0.8006, 0.8131]}]}, {"id": "b_12", "type": "paragraph", "text": "The l2() function returns a regularizer that will be called to compute the regulariza‐ tion loss, at each step during training. This regularization loss is then added to the final loss. As you might expect, you can just use keras.regularizers.l1() if you", "words": [{"w": "The", "b": [0.1429, 0.8217, 0.1757, 0.8431]}, {"w": "l2()", "b": [0.1812, 0.8249, 0.2208, 0.84]}, {"w": "function", "b": [0.2264, 0.8217, 0.2978, 0.8431]}, {"w": "returns", "b": [0.3033, 0.8217, 0.3641, 0.8431]}, {"w": "a", "b": [0.3697, 0.8217, 0.3788, 0.8431]}, {"w": "regularizer", "b": [0.3844, 0.8217, 0.4748, 0.8431]}, {"w": "that", "b": [0.4804, 0.8217, 0.513, 0.8431]}, {"w": "will", "b": [0.5185, 0.8217, 0.5489, 0.8431]}, {"w": "be", "b": [0.5545, 0.8217, 0.5739, 0.8431]}, {"w": "called", "b": [0.5795, 0.8217, 0.6279, 0.8431]}, {"w": "to", "b": [0.6334, 0.8217, 0.6504, 0.8431]}, {"w": "compute", "b": [0.656, 0.8217, 0.7292, 0.8431]}, {"w": "the", "b": [0.7348, 0.8217, 0.7611, 0.8431]}, {"w": "regulariza‐", "b": [0.7667, 0.8217, 0.8571, 0.8431]}, {"w": "tion", "b": [0.1429, 0.8408, 0.1768, 0.8622]}, {"w": "loss,", "b": [0.1839, 0.8408, 0.2198, 0.8622]}, {"w": "at", "b": [0.2269, 0.8408, 0.242, 0.8622]}, {"w": "each", "b": [0.2491, 0.8408, 0.287, 0.8622]}, {"w": "step", "b": [0.2941, 0.8408, 0.3279, 0.8622]}, {"w": "during", "b": [0.335, 0.8408, 0.3915, 0.8622]}, {"w": "training.", "b": [0.3986, 0.8408, 0.4703, 0.8622]}, {"w": "This", "b": [0.4773, 0.8408, 0.5146, 0.8622]}, {"w": "regularization", "b": [0.5216, 0.8408, 0.6382, 0.8622]}, {"w": "loss", "b": [0.6453, 0.8408, 0.6765, 0.8622]}, {"w": "is", "b": [0.6836, 0.8408, 0.6968, 0.8622]}, {"w": "then", "b": [0.7039, 0.8408, 0.7416, 0.8622]}, {"w": "added", "b": [0.7487, 0.8408, 0.7997, 0.8622]}, {"w": "to", "b": [0.8068, 0.8408, 0.8237, 0.8622]}, {"w": "the", "b": [0.8308, 0.8408, 0.8572, 0.8622]}, {"w": "final", "b": [0.1429, 0.8607, 0.1804, 0.8821]}, {"w": "loss.", "b": [0.188, 0.8607, 0.2239, 0.8821]}, {"w": "As", "b": [0.2314, 0.8607, 0.2535, 0.8821]}, {"w": "you", "b": [0.261, 0.8607, 0.2923, 0.8821]}, {"w": "might", "b": [0.2998, 0.8607, 0.3493, 0.8821]}, {"w": "expect,", "b": [0.3568, 0.8607, 0.4152, 0.8821]}, {"w": "you", "b": [0.4227, 0.8607, 0.454, 0.8821]}, {"w": "can", "b": [0.4615, 0.8607, 0.4909, 0.8821]}, {"w": "just", "b": [0.4984, 0.8607, 0.5288, 0.8821]}, {"w": "use", "b": [0.5364, 0.8607, 0.5639, 0.8821]}, {"w": "keras.regularizers.l1()", "b": [0.5715, 0.8639, 0.7991, 0.879]}, {"w": "if", "b": [0.8066, 0.8607, 0.8184, 0.8821]}, {"w": "you", "b": [0.8259, 0.8607, 0.8571, 0.8821]}]}, {"id": "b_13", "type": "paragraph", "text": "356 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "356", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2746, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 383, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "23 “Improving neural networks by preventing co-adaptation of feature detectors,” G. Hinton et al. (2012).", "words": [{"w": "23", "b": [0.1385, 0.8568, 0.1518, 0.871]}, {"w": "“Improving", "b": [0.1587, 0.8553, 0.2332, 0.8716]}, {"w": "neural", "b": [0.2368, 0.8553, 0.2775, 0.8716]}, {"w": "networks", "b": [0.2811, 0.8553, 0.3399, 0.8716]}, {"w": "by", "b": [0.3435, 0.8553, 0.3589, 0.8716]}, {"w": "preventing", "b": [0.3625, 0.8553, 0.4311, 0.8716]}, {"w": "co-adaptation", "b": [0.4347, 0.8553, 0.5229, 0.8716]}, {"w": "of", "b": [0.5265, 0.8553, 0.5393, 0.8716]}, {"w": "feature", "b": [0.5429, 0.8553, 0.5869, 0.8716]}, {"w": "detectors,”", "b": [0.5905, 0.8553, 0.6564, 0.8716]}, {"w": "G.", "b": [0.66, 0.8553, 0.675, 0.8716]}, {"w": "Hinton", "b": [0.6786, 0.8553, 0.725, 0.8716]}, {"w": "et", "b": [0.7286, 0.8553, 0.7402, 0.8716]}, {"w": "al.", "b": [0.7438, 0.8553, 0.7584, 0.8716]}, {"w": "(2012).", "b": [0.762, 0.8553, 0.8071, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "24 “Dropout: A Simple Way to Prevent Neural Networks from Overfitting,” N. Srivastava et al. (2014).", "words": [{"w": "24", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Dropout:", "b": [0.1587, 0.8749, 0.224, 0.8912]}, {"w": "A", "b": [0.2276, 0.8749, 0.2386, 0.8912]}, {"w": "Simple", "b": [0.2422, 0.8749, 0.2857, 0.8912]}, {"w": "Way", "b": [0.2893, 0.8749, 0.3171, 0.8912]}, {"w": "to", "b": [0.3207, 0.8749, 0.3337, 0.8912]}, {"w": "Prevent", "b": [0.3373, 0.8749, 0.3862, 0.8912]}, {"w": "Neural", "b": [0.3898, 0.8749, 0.4332, 0.8912]}, {"w": "Networks", "b": [0.4368, 0.8749, 0.4984, 0.8912]}, {"w": "from", "b": [0.502, 0.8749, 0.5337, 0.8912]}, {"w": "Overfitting,”", "b": [0.5373, 0.8749, 0.6162, 0.8912]}, {"w": "N.", "b": [0.6198, 0.8749, 0.6352, 0.8912]}, {"w": "Srivastava", "b": [0.6388, 0.8749, 0.7024, 0.8912]}, {"w": "et", "b": [0.706, 0.8749, 0.7176, 0.8912]}, {"w": "al.", "b": [0.7212, 0.8749, 0.7358, 0.8912]}, {"w": "(2014).", "b": [0.7394, 0.8749, 0.7845, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "want ℓ1 regularization, and if you want both ℓ1 and ℓ2 regularization, use keras.regu larizers.l1_l2() (specifying both regularization factors).", "words": [{"w": "want", "b": [0.1429, 0.08, 0.1836, 0.1014]}, {"w": "ℓ1", "b": [0.1893, 0.08, 0.2039, 0.1023]}, {"w": "regularization,", "b": [0.2096, 0.08, 0.3309, 0.1014]}, {"w": "and", "b": [0.3366, 0.08, 0.3682, 0.1014]}, {"w": "if", "b": [0.3739, 0.08, 0.3856, 0.1014]}, {"w": "you", "b": [0.3913, 0.08, 0.4226, 0.1014]}, {"w": "want", "b": [0.4283, 0.08, 0.4691, 0.1014]}, {"w": "both", "b": [0.4748, 0.08, 0.5135, 0.1014]}, {"w": "ℓ1", "b": [0.5192, 0.08, 0.5337, 0.1023]}, {"w": "and", "b": [0.5394, 0.08, 0.571, 0.1014]}, {"w": "ℓ2", "b": [0.5767, 0.08, 0.5912, 0.1023]}, {"w": "regularization,", "b": [0.597, 0.08, 0.7183, 0.1014]}, {"w": "use", "b": [0.724, 0.08, 0.7516, 0.1014]}, {"w": "keras.regu", "b": [0.7573, 0.0831, 0.8562, 0.0982]}, {"w": "larizers.l1_l2()", "b": [0.1428, 0.1031, 0.3012, 0.1182]}, {"w": "(specifying", "b": [0.3059, 0.0999, 0.3977, 0.1213]}, {"w": "both", "b": [0.4025, 0.0999, 0.4412, 0.1213]}, {"w": "regularization", "b": [0.4459, 0.0999, 0.5625, 0.1213]}, {"w": "factors).", "b": [0.5672, 0.0999, 0.6356, 0.1213]}]}, {"id": "b_3", "type": "paragraph", "text": "Since you will typically want to apply the same regularizer to all layers in your net‐ work, as well as the same activation function and the same initialization strategy in all hidden layers, you may find yourself repeating the same arguments over and over. This makes it ugly and error-prone. To avoid this, you can try refactoring your code to use loops. Another option is to use Python’s functools.partial() function: it lets you create a thin wrapper for any callable, with some default argument values. For example:", "words": [{"w": "Since", "b": [0.1428, 0.128, 0.1874, 0.1494]}, {"w": "you", "b": [0.1941, 0.128, 0.2253, 0.1494]}, {"w": "will", "b": [0.232, 0.128, 0.2624, 0.1494]}, {"w": "typically", "b": [0.2691, 0.128, 0.3396, 0.1494]}, {"w": "want", "b": [0.3463, 0.128, 0.3871, 0.1494]}, {"w": "to", "b": [0.3938, 0.128, 0.4107, 0.1494]}, {"w": "apply", "b": [0.4174, 0.128, 0.4629, 0.1494]}, {"w": "the", "b": [0.4696, 0.128, 0.4959, 0.1494]}, {"w": "same", "b": [0.5026, 0.128, 0.5453, 0.1494]}, {"w": "regularizer", "b": [0.552, 0.128, 0.6425, 0.1494]}, {"w": "to", "b": [0.6492, 0.128, 0.6661, 0.1494]}, {"w": "all", "b": [0.6728, 0.128, 0.6925, 0.1494]}, {"w": "layers", "b": [0.6992, 0.128, 0.7471, 0.1494]}, {"w": "in", "b": [0.7538, 0.128, 0.7707, 0.1494]}, {"w": "your", "b": [0.7774, 0.128, 0.8164, 0.1494]}, {"w": "net‐", "b": [0.8231, 0.128, 0.8571, 0.1494]}, {"w": "work,", "b": [0.1429, 0.1471, 0.1906, 0.1685]}, {"w": "as", "b": [0.1954, 0.1471, 0.2122, 0.1685]}, {"w": "well", "b": [0.2171, 0.1471, 0.2507, 0.1685]}, {"w": "as", "b": [0.2556, 0.1471, 0.2724, 0.1685]}, {"w": "the", "b": [0.2772, 0.1471, 0.3036, 0.1685]}, {"w": "same", "b": [0.3084, 0.1471, 0.3511, 0.1685]}, {"w": "activation", "b": [0.356, 0.1471, 0.4382, 0.1685]}, {"w": "function", "b": [0.4431, 0.1471, 0.5145, 0.1685]}, {"w": "and", "b": [0.5193, 0.1471, 0.5509, 0.1685]}, {"w": "the", "b": [0.5557, 0.1471, 0.5821, 0.1685]}, {"w": "same", "b": [0.5869, 0.1471, 0.6296, 0.1685]}, {"w": "initialization", "b": [0.6345, 0.1471, 0.7404, 0.1685]}, {"w": "strategy", "b": [0.7453, 0.1471, 0.8108, 0.1685]}, {"w": "in", "b": [0.8156, 0.1471, 0.8326, 0.1685]}, {"w": "all", "b": [0.8375, 0.1471, 0.8571, 0.1685]}, {"w": "hidden", "b": [0.1429, 0.1661, 0.2018, 0.1875]}, {"w": "layers,", "b": [0.2094, 0.1661, 0.2619, 0.1875]}, {"w": "you", "b": [0.2695, 0.1661, 0.3007, 0.1875]}, {"w": "may", "b": [0.3083, 0.1661, 0.3437, 0.1875]}, {"w": "find", "b": [0.3512, 0.1661, 0.3854, 0.1875]}, {"w": "yourself", "b": [0.3929, 0.1661, 0.4598, 0.1875]}, {"w": "repeating", "b": [0.4674, 0.1661, 0.5456, 0.1875]}, {"w": "the", "b": [0.5531, 0.1661, 0.5794, 0.1875]}, {"w": "same", "b": [0.587, 0.1661, 0.6297, 0.1875]}, {"w": "arguments", "b": [0.6372, 0.1661, 0.7258, 0.1875]}, {"w": "over", "b": [0.7334, 0.1661, 0.7702, 0.1875]}, {"w": "and", "b": [0.7778, 0.1661, 0.8093, 0.1875]}, {"w": "over.", "b": [0.8169, 0.1661, 0.8571, 0.1875]}, {"w": "This", "b": [0.1429, 0.1852, 0.1801, 0.2066]}, {"w": "makes", "b": [0.186, 0.1852, 0.239, 0.2066]}, {"w": "it", "b": [0.245, 0.1852, 0.2569, 0.2066]}, {"w": "ugly", "b": [0.2629, 0.1852, 0.2985, 0.2066]}, {"w": "and", "b": [0.3045, 0.1852, 0.336, 0.2066]}, {"w": "error-prone.", "b": [0.342, 0.1852, 0.4458, 0.2066]}, {"w": "To", "b": [0.4518, 0.1852, 0.4732, 0.2066]}, {"w": "avoid", "b": [0.4792, 0.1852, 0.5248, 0.2066]}, {"w": "this,", "b": [0.5307, 0.1852, 0.5662, 0.2066]}, {"w": "you", "b": [0.5721, 0.1852, 0.6034, 0.2066]}, {"w": "can", "b": [0.6093, 0.1852, 0.6387, 0.2066]}, {"w": "try", "b": [0.6446, 0.1852, 0.6689, 0.2066]}, {"w": "refactoring", "b": [0.6748, 0.1852, 0.767, 0.2066]}, {"w": "your", "b": [0.7729, 0.1852, 0.8119, 0.2066]}, {"w": "code", "b": [0.8178, 0.1852, 0.8571, 0.2066]}, {"w": "to", "b": [0.1428, 0.2051, 0.1598, 0.2265]}, {"w": "use", "b": [0.165, 0.2051, 0.1926, 0.2265]}, {"w": "loops.", "b": [0.1978, 0.2051, 0.2476, 0.2265]}, {"w": "Another", "b": [0.2529, 0.2051, 0.3233, 0.2265]}, {"w": "option", "b": [0.3285, 0.2051, 0.384, 0.2265]}, {"w": "is", "b": [0.3893, 0.2051, 0.4025, 0.2265]}, {"w": "to", "b": [0.4077, 0.2051, 0.4247, 0.2265]}, {"w": "use", "b": [0.4299, 0.2051, 0.4575, 0.2265]}, {"w": "Python’s", "b": [0.4627, 0.2051, 0.5321, 0.2265]}, {"w": "functools.partial()", "b": [0.5373, 0.2083, 0.7253, 0.2234]}, {"w": "function:", "b": [0.7305, 0.2051, 0.8067, 0.2265]}, {"w": "it", "b": [0.8119, 0.2051, 0.8238, 0.2265]}, {"w": "lets", "b": [0.829, 0.2051, 0.8571, 0.2265]}, {"w": "you", "b": [0.1429, 0.2242, 0.1741, 0.2456]}, {"w": "create", "b": [0.1814, 0.2242, 0.2307, 0.2456]}, {"w": "a", "b": [0.238, 0.2242, 0.2471, 0.2456]}, {"w": "thin", "b": [0.2544, 0.2242, 0.2888, 0.2456]}, {"w": "wrapper", "b": [0.2961, 0.2242, 0.3653, 0.2456]}, {"w": "for", "b": [0.3725, 0.2242, 0.397, 0.2456]}, {"w": "any", "b": [0.4043, 0.2242, 0.4339, 0.2456]}, {"w": "callable,", "b": [0.4412, 0.2242, 0.5083, 0.2456]}, {"w": "with", "b": [0.5156, 0.2242, 0.5529, 0.2456]}, {"w": "some", "b": [0.5601, 0.2242, 0.6043, 0.2456]}, {"w": "default", "b": [0.6116, 0.2242, 0.6691, 0.2456]}, {"w": "argument", "b": [0.6763, 0.2242, 0.7573, 0.2456]}, {"w": "values.", "b": [0.7645, 0.2242, 0.8209, 0.2456]}, {"w": "For", "b": [0.8282, 0.2242, 0.8571, 0.2456]}, {"w": "example:", "b": [0.1429, 0.2432, 0.2171, 0.2646]}]}, {"id": "b_4", "type": "paragraph", "text": "from functools import partial", "words": [{"w": "from", "b": [0.1766, 0.2752, 0.2103, 0.288]}, {"w": "functools", "b": [0.2187, 0.2752, 0.2946, 0.288]}, {"w": "import", "b": [0.3031, 0.2752, 0.3537, 0.288]}, {"w": "partial", "b": [0.3621, 0.2752, 0.4211, 0.288]}]}, {"id": "b_5", "type": "paragraph", "text": "RegularizedDense = partial(keras.layers.Dense, activation=\"elu\", kernel_initializer=\"he_normal\", kernel_regularizer=keras.regularizers.l2(0.01))", "words": [{"w": "RegularizedDense", "b": [0.1766, 0.306, 0.3115, 0.3189]}, {"w": "=", "b": [0.3199, 0.306, 0.3284, 0.3189]}, {"w": "partial(keras.layers.Dense,", "b": [0.3368, 0.306, 0.5645, 0.3189]}, {"w": "activation=\"elu\",", "b": [0.4043, 0.3214, 0.5476, 0.3343]}, {"w": "kernel_initializer=\"he_normal\",", "b": [0.4043, 0.3369, 0.6657, 0.3497]}, {"w": "kernel_regularizer=keras.regularizers.l2(0.01))", "b": [0.4043, 0.3523, 0.8006, 0.3651]}]}, {"id": "b_6", "type": "paragraph", "text": "model = keras.models.Sequential([ keras.layers.Flatten(input_shape=[28, 28]), RegularizedDense(300), RegularizedDense(100), RegularizedDense(10, activation=\"softmax\", kernel_initializer=\"glorot_uniform\") ])", "words": [{"w": "model", "b": [0.1766, 0.3831, 0.2187, 0.396]}, {"w": "=", "b": [0.2272, 0.3831, 0.2356, 0.396]}, {"w": "keras.models.Sequential([", "b": [0.244, 0.3831, 0.4549, 0.396]}, {"w": "keras.layers.Flatten(input_shape=[28,", "b": [0.2103, 0.3985, 0.5223, 0.4114]}, {"w": "28]),", "b": [0.5307, 0.3985, 0.5729, 0.4114]}, {"w": "RegularizedDense(300),", "b": [0.2103, 0.414, 0.3958, 0.4268]}, {"w": "RegularizedDense(100),", "b": [0.2103, 0.4294, 0.3958, 0.4422]}, {"w": "RegularizedDense(10,", "b": [0.2103, 0.4448, 0.379, 0.4576]}, {"w": "activation=\"softmax\",", "b": [0.3874, 0.4448, 0.5645, 0.4576]}, {"w": "kernel_initializer=\"glorot_uniform\")", "b": [0.3537, 0.4602, 0.6572, 0.4731]}, {"w": "])", "b": [0.1766, 0.4756, 0.1934, 0.4885]}]}, {"id": "b_7", "type": "paragraph", "text": "Dropout", "words": [{"w": "Dropout", "b": [0.1429, 0.5023, 0.2274, 0.5309]}]}, {"id": "b_8", "type": "paragraph", "text": "Dropout is one of the most popular regularization techniques for deep neural net‐ works. It was proposed23 by Geoffrey Hinton in 2012 and further detailed in a paper24", "words": [{"w": "Dropout", "b": [0.1429, 0.5366, 0.2114, 0.5582]}, {"w": "is", "b": [0.2191, 0.5368, 0.2323, 0.5582]}, {"w": "one", "b": [0.24, 0.5368, 0.2709, 0.5582]}, {"w": "of", "b": [0.2786, 0.5368, 0.2954, 0.5582]}, {"w": "the", "b": [0.3031, 0.5368, 0.3295, 0.5582]}, {"w": "most", "b": [0.3372, 0.5368, 0.3789, 0.5582]}, {"w": "popular", "b": [0.3866, 0.5368, 0.4523, 0.5582]}, {"w": "regularization", "b": [0.46, 0.5368, 0.5766, 0.5582]}, {"w": "techniques", "b": [0.5843, 0.5368, 0.6746, 0.5582]}, {"w": "for", "b": [0.6824, 0.5368, 0.7069, 0.5582]}, {"w": "deep", "b": [0.7146, 0.5368, 0.7542, 0.5582]}, {"w": "neural", "b": [0.7619, 0.5368, 0.8154, 0.5582]}, {"w": "net‐", "b": [0.8231, 0.5368, 0.8571, 0.5582]}, {"w": "works.", "b": [0.1428, 0.5558, 0.1982, 0.5773]}, {"w": "It", "b": [0.2034, 0.5558, 0.2161, 0.5773]}, {"w": "was", "b": [0.2213, 0.5558, 0.2524, 0.5773]}, {"w": "proposed23", "b": [0.2576, 0.5558, 0.3474, 0.5773]}, {"w": "by", "b": [0.3526, 0.5558, 0.3727, 0.5773]}, {"w": "Geoffrey", "b": [0.378, 0.5558, 0.4508, 0.5773]}, {"w": "Hinton", "b": [0.4561, 0.5558, 0.517, 0.5773]}, {"w": "in", "b": [0.5222, 0.5558, 0.5392, 0.5773]}, {"w": "2012", "b": [0.5444, 0.5558, 0.5844, 0.5773]}, {"w": "and", "b": [0.5896, 0.5558, 0.6212, 0.5773]}, {"w": "further", "b": [0.6264, 0.5558, 0.6854, 0.5773]}, {"w": "detailed", "b": [0.6907, 0.5558, 0.7567, 0.5773]}, {"w": "in", "b": [0.762, 0.5558, 0.7789, 0.5773]}, {"w": "a", "b": [0.7842, 0.5558, 0.7933, 0.5773]}, {"w": "paper24", "b": [0.7985, 0.5558, 0.8571, 0.5773]}]}, {"id": "b_9", "type": "paragraph", "text": "by Nitish Srivastava et al., and it has proven to be highly successful: even the state-of- the-art neural networks got a 1–2% accuracy boost simply by adding dropout. This may not sound like a lot, but when a model already has 95% accuracy, getting a 2% accuracy boost means dropping the error rate by almost 40% (going from 5% error to roughly 3%).", "words": [{"w": "by", "b": [0.1429, 0.5749, 0.163, 0.5963]}, {"w": "Nitish", "b": [0.1682, 0.5749, 0.2196, 0.5963]}, {"w": "Srivastava", "b": [0.2248, 0.5749, 0.3083, 0.5963]}, {"w": "et", "b": [0.3135, 0.5749, 0.3288, 0.5963]}, {"w": "al.,", "b": [0.334, 0.5749, 0.3579, 0.5963]}, {"w": "and", "b": [0.3631, 0.5749, 0.3947, 0.5963]}, {"w": "it", "b": [0.3999, 0.5749, 0.4118, 0.5963]}, {"w": "has", "b": [0.417, 0.5749, 0.445, 0.5963]}, {"w": "proven", "b": [0.4502, 0.5749, 0.5093, 0.5963]}, {"w": "to", "b": [0.5146, 0.5749, 0.5315, 0.5963]}, {"w": "be", "b": [0.5368, 0.5749, 0.5562, 0.5963]}, {"w": "highly", "b": [0.5614, 0.5749, 0.6138, 0.5963]}, {"w": "successful:", "b": [0.6191, 0.5749, 0.7068, 0.5963]}, {"w": "even", "b": [0.712, 0.5749, 0.7508, 0.5963]}, {"w": "the", "b": [0.756, 0.5749, 0.7823, 0.5963]}, {"w": "state-of-", "b": [0.7876, 0.5749, 0.8571, 0.5963]}, {"w": "the-art", "b": [0.1428, 0.5939, 0.1998, 0.6153]}, {"w": "neural", "b": [0.2066, 0.5939, 0.2601, 0.6153]}, {"w": "networks", "b": [0.2668, 0.5939, 0.344, 0.6153]}, {"w": "got", "b": [0.3508, 0.5939, 0.3776, 0.6153]}, {"w": "a", "b": [0.3843, 0.5939, 0.3935, 0.6153]}, {"w": "1–2%", "b": [0.4003, 0.5939, 0.4468, 0.6153]}, {"w": "accuracy", "b": [0.4536, 0.5939, 0.5267, 0.6153]}, {"w": "boost", "b": [0.5335, 0.5939, 0.5793, 0.6153]}, {"w": "simply", "b": [0.5861, 0.5939, 0.6417, 0.6153]}, {"w": "by", "b": [0.6485, 0.5939, 0.6687, 0.6153]}, {"w": "adding", "b": [0.6754, 0.5939, 0.7333, 0.6153]}, {"w": "dropout.", "b": [0.7401, 0.5939, 0.8131, 0.6153]}, {"w": "This", "b": [0.8199, 0.5939, 0.8571, 0.6153]}, {"w": "may", "b": [0.1429, 0.613, 0.1783, 0.6344]}, {"w": "not", "b": [0.1847, 0.613, 0.2131, 0.6344]}, {"w": "sound", "b": [0.2196, 0.613, 0.2713, 0.6344]}, {"w": "like", "b": [0.2777, 0.613, 0.3078, 0.6344]}, {"w": "a", "b": [0.3142, 0.613, 0.3234, 0.6344]}, {"w": "lot,", "b": [0.3299, 0.613, 0.3569, 0.6344]}, {"w": "but", "b": [0.3633, 0.613, 0.3913, 0.6344]}, {"w": "when", "b": [0.3978, 0.613, 0.4434, 0.6344]}, {"w": "a", "b": [0.4499, 0.613, 0.459, 0.6344]}, {"w": "model", "b": [0.4655, 0.613, 0.5183, 0.6344]}, {"w": "already", "b": [0.5248, 0.613, 0.5855, 0.6344]}, {"w": "has", "b": [0.5919, 0.613, 0.6198, 0.6344]}, {"w": "95%", "b": [0.6263, 0.613, 0.6621, 0.6344]}, {"w": "accuracy,", "b": [0.6685, 0.613, 0.7448, 0.6344]}, {"w": "getting", "b": [0.7513, 0.613, 0.8093, 0.6344]}, {"w": "a", "b": [0.8158, 0.613, 0.8249, 0.6344]}, {"w": "2%", "b": [0.8314, 0.613, 0.8571, 0.6344]}, {"w": "accuracy", "b": [0.1429, 0.632, 0.2159, 0.6534]}, {"w": "boost", "b": [0.2209, 0.632, 0.2667, 0.6534]}, {"w": "means", "b": [0.2717, 0.632, 0.3258, 0.6534]}, {"w": "dropping", "b": [0.3307, 0.632, 0.4087, 0.6534]}, {"w": "the", "b": [0.4136, 0.632, 0.4399, 0.6534]}, {"w": "error", "b": [0.4449, 0.632, 0.4876, 0.6534]}, {"w": "rate", "b": [0.4925, 0.632, 0.5242, 0.6534]}, {"w": "by", "b": [0.5292, 0.632, 0.5493, 0.6534]}, {"w": "almost", "b": [0.5543, 0.632, 0.6104, 0.6534]}, {"w": "40%", "b": [0.6153, 0.632, 0.6511, 0.6534]}, {"w": "(going", "b": [0.656, 0.632, 0.7103, 0.6534]}, {"w": "from", "b": [0.7153, 0.632, 0.7569, 0.6534]}, {"w": "5%", "b": [0.7618, 0.632, 0.7876, 0.6534]}, {"w": "error", "b": [0.7925, 0.632, 0.8352, 0.6534]}, {"w": "to", "b": [0.8402, 0.632, 0.8571, 0.6534]}, {"w": "roughly", "b": [0.1428, 0.6511, 0.208, 0.6725]}, {"w": "3%).", "b": [0.2127, 0.6511, 0.2504, 0.6725]}]}, {"id": "b_10", "type": "paragraph", "text": "It is a fairly simple algorithm: at every training step, every neuron (including the input neurons, but always excluding the output neurons) has a probability p of being temporarily “dropped out,” meaning it will be entirely ignored during this training step, but it may be active during the next step (see Figure 11-9). The hyperparameter p is called the dropout rate, and it is typically set to 50%. After training, neurons don’t get dropped anymore. And that’s all (except for a technical detail we will discuss momentarily).", "words": [{"w": "It", "b": [0.1428, 0.6792, 0.1555, 0.7006]}, {"w": "is", "b": [0.1638, 0.6792, 0.1771, 0.7006]}, {"w": "a", "b": [0.1854, 0.6792, 0.1946, 0.7006]}, {"w": "fairly", "b": [0.2029, 0.6792, 0.2464, 0.7006]}, {"w": "simple", "b": [0.2547, 0.6792, 0.3097, 0.7006]}, {"w": "algorithm:", "b": [0.318, 0.6792, 0.4054, 0.7006]}, {"w": "at", "b": [0.4138, 0.6792, 0.4289, 0.7006]}, {"w": "every", "b": [0.4372, 0.6792, 0.4825, 0.7006]}, {"w": "training", "b": [0.4908, 0.6792, 0.5578, 0.7006]}, {"w": "step,", "b": [0.5661, 0.6792, 0.604, 0.7006]}, {"w": "every", "b": [0.6124, 0.6792, 0.6576, 0.7006]}, {"w": "neuron", "b": [0.666, 0.6792, 0.727, 0.7006]}, {"w": "(including", "b": [0.7354, 0.6792, 0.8225, 0.7006]}, {"w": "the", "b": [0.8308, 0.6792, 0.8571, 0.7006]}, {"w": "input", "b": [0.1429, 0.6982, 0.1878, 0.7197]}, {"w": "neurons,", "b": [0.1932, 0.6982, 0.2667, 0.7197]}, {"w": "but", "b": [0.2722, 0.6982, 0.3002, 0.7197]}, {"w": "always", "b": [0.3056, 0.6982, 0.3603, 0.7197]}, {"w": "excluding", "b": [0.3657, 0.6982, 0.4473, 0.7197]}, {"w": "the", "b": [0.4528, 0.6982, 0.4791, 0.7197]}, {"w": "output", "b": [0.4846, 0.6982, 0.5409, 0.7197]}, {"w": "neurons)", "b": [0.5464, 0.6982, 0.6223, 0.7197]}, {"w": "has", "b": [0.6278, 0.6982, 0.6557, 0.7197]}, {"w": "a", "b": [0.6611, 0.6982, 0.6703, 0.7197]}, {"w": "probability", "b": [0.6758, 0.6982, 0.7677, 0.7197]}, {"w": "p", "b": [0.7731, 0.698, 0.7833, 0.7197]}, {"w": "of", "b": [0.7887, 0.6982, 0.8055, 0.7197]}, {"w": "being", "b": [0.811, 0.6982, 0.8571, 0.7197]}, {"w": "temporarily", "b": [0.1429, 0.7173, 0.2413, 0.7387]}, {"w": "“dropped", "b": [0.2488, 0.7173, 0.3264, 0.7387]}, {"w": "out,”", "b": [0.3339, 0.7173, 0.3722, 0.7387]}, {"w": "meaning", "b": [0.3797, 0.7173, 0.4529, 0.7387]}, {"w": "it", "b": [0.4604, 0.7173, 0.4724, 0.7387]}, {"w": "will", "b": [0.4799, 0.7173, 0.5103, 0.7387]}, {"w": "be", "b": [0.5178, 0.7173, 0.5372, 0.7387]}, {"w": "entirely", "b": [0.5448, 0.7173, 0.608, 0.7387]}, {"w": "ignored", "b": [0.6155, 0.7173, 0.6804, 0.7387]}, {"w": "during", "b": [0.6879, 0.7173, 0.7445, 0.7387]}, {"w": "this", "b": [0.752, 0.7173, 0.7827, 0.7387]}, {"w": "training", "b": [0.7902, 0.7173, 0.8571, 0.7387]}, {"w": "step,", "b": [0.1429, 0.7363, 0.1808, 0.7578]}, {"w": "but", "b": [0.1863, 0.7363, 0.2143, 0.7578]}, {"w": "it", "b": [0.2199, 0.7363, 0.2318, 0.7578]}, {"w": "may", "b": [0.2374, 0.7363, 0.2728, 0.7578]}, {"w": "be", "b": [0.2784, 0.7363, 0.2978, 0.7578]}, {"w": "active", "b": [0.3034, 0.7363, 0.3517, 0.7578]}, {"w": "during", "b": [0.3573, 0.7363, 0.4138, 0.7578]}, {"w": "the", "b": [0.4194, 0.7363, 0.4457, 0.7578]}, {"w": "next", "b": [0.4513, 0.7363, 0.4877, 0.7578]}, {"w": "step", "b": [0.4933, 0.7363, 0.5271, 0.7578]}, {"w": "(see", "b": [0.5326, 0.7363, 0.5652, 0.7578]}, {"w": "Figure", "b": [0.5707, 0.7363, 0.6247, 0.7578]}, {"w": "11-9).", "b": [0.6303, 0.7363, 0.6797, 0.7578]}, {"w": "The", "b": [0.6852, 0.7363, 0.7181, 0.7578]}, {"w": "hyperparameter", "b": [0.7236, 0.7363, 0.8571, 0.7578]}, {"w": "p", "b": [0.1428, 0.7552, 0.153, 0.7768]}, {"w": "is", "b": [0.1582, 0.7554, 0.1714, 0.7768]}, {"w": "called", "b": [0.1766, 0.7554, 0.2249, 0.7768]}, {"w": "the", "b": [0.2301, 0.7554, 0.2564, 0.7768]}, {"w": "dropout", "b": [0.2616, 0.7552, 0.3256, 0.7768]}, {"w": "rate,", "b": [0.3304, 0.7552, 0.3671, 0.7768]}, {"w": "and", "b": [0.3723, 0.7554, 0.4038, 0.7768]}, {"w": "it", "b": [0.409, 0.7554, 0.4209, 0.7768]}, {"w": "is", "b": [0.4261, 0.7554, 0.4394, 0.7768]}, {"w": "typically", "b": [0.4445, 0.7554, 0.515, 0.7768]}, {"w": "set", "b": [0.5202, 0.7554, 0.5431, 0.7768]}, {"w": "to", "b": [0.5482, 0.7554, 0.5652, 0.7768]}, {"w": "50%.", "b": [0.5704, 0.7554, 0.6109, 0.7768]}, {"w": "After", "b": [0.6161, 0.7554, 0.6596, 0.7768]}, {"w": "training,", "b": [0.6648, 0.7554, 0.7365, 0.7768]}, {"w": "neurons", "b": [0.7416, 0.7554, 0.8104, 0.7768]}, {"w": "don’t", "b": [0.8155, 0.7554, 0.8571, 0.7768]}, {"w": "get", "b": [0.1429, 0.7744, 0.1678, 0.7958]}, {"w": "dropped", "b": [0.1764, 0.7744, 0.2475, 0.7958]}, {"w": "anymore.", "b": [0.2561, 0.7744, 0.3347, 0.7958]}, {"w": "And", "b": [0.3433, 0.7744, 0.3801, 0.7958]}, {"w": "that’s", "b": [0.3887, 0.7744, 0.431, 0.7958]}, {"w": "all", "b": [0.4396, 0.7744, 0.4593, 0.7958]}, {"w": "(except", "b": [0.4679, 0.7744, 0.5288, 0.7958]}, {"w": "for", "b": [0.5374, 0.7744, 0.5619, 0.7958]}, {"w": "a", "b": [0.5705, 0.7744, 0.5796, 0.7958]}, {"w": "technical", "b": [0.5882, 0.7744, 0.6636, 0.7958]}, {"w": "detail", "b": [0.6722, 0.7744, 0.7184, 0.7958]}, {"w": "we", "b": [0.727, 0.7744, 0.7501, 0.7958]}, {"w": "will", "b": [0.7587, 0.7744, 0.7891, 0.7958]}, {"w": "discuss", "b": [0.7977, 0.7744, 0.8571, 0.7958]}, {"w": "momentarily).", "b": [0.1429, 0.7935, 0.2631, 0.8149]}]}, {"id": "b_11", "type": "paragraph", "text": "Avoiding Overfitting Through Regularization | 357", "words": [{"w": "Avoiding", "b": [0.5348, 0.9225, 0.587, 0.9388]}, {"w": "Overfitting", "b": [0.5899, 0.9225, 0.6541, 0.9388]}, {"w": "Through", "b": [0.6569, 0.9225, 0.7066, 0.9388]}, {"w": "Regularization", "b": [0.7094, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "357", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 384, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 11-9. Dropout regularization", "words": [{"w": "Figure", "b": [0.1429, 0.3152, 0.1943, 0.3368]}, {"w": "11-9.", "b": [0.1991, 0.3152, 0.2407, 0.3368]}, {"w": "Dropout", "b": [0.2455, 0.3152, 0.314, 0.3368]}, {"w": "regularization", "b": [0.3188, 0.3152, 0.4335, 0.3368]}]}, {"id": "b_1", "type": "paragraph", "text": "It is quite surprising at first that this rather brutal technique works at all. Would a company perform better if its employees were told to toss a coin every morning to decide whether or not to go to work? Well, who knows; perhaps it would! The com‐ pany would obviously be forced to adapt its organization; it could not rely on any sin‐ gle person to fill in the coffee machine or perform any other critical tasks, so this expertise would have to be spread across several people. Employees would have to learn to cooperate with many of their coworkers, not just a handful of them. The company would become much more resilient. If one person quit, it wouldn’t make much of a difference. It’s unclear whether this idea would actually work for compa‐ nies, but it certainly does for neural networks. Neurons trained with dropout cannot co-adapt with their neighboring neurons; they have to be as useful as possible on their own. They also cannot rely excessively on just a few input neurons; they must pay attention to each of their input neurons. They end up being less sensitive to slight changes in the inputs. In the end you get a more robust network that generalizes bet‐ ter.", "words": [{"w": "It", "b": [0.1429, 0.3526, 0.1555, 0.374]}, {"w": "is", "b": [0.1628, 0.3526, 0.1761, 0.374]}, {"w": "quite", "b": [0.1834, 0.3526, 0.2259, 0.374]}, {"w": "surprising", "b": [0.2333, 0.3526, 0.3183, 0.374]}, {"w": "at", "b": [0.3257, 0.3526, 0.3408, 0.374]}, {"w": "first", "b": [0.3481, 0.3526, 0.3816, 0.374]}, {"w": "that", "b": [0.3889, 0.3526, 0.4215, 0.374]}, {"w": "this", "b": [0.4288, 0.3526, 0.4596, 0.374]}, {"w": "rather", "b": [0.4669, 0.3526, 0.5174, 0.374]}, {"w": "brutal", "b": [0.5248, 0.3526, 0.5749, 0.374]}, {"w": "technique", "b": [0.5823, 0.3526, 0.665, 0.374]}, {"w": "works", "b": [0.6723, 0.3526, 0.7229, 0.374]}, {"w": "at", "b": [0.7303, 0.3526, 0.7454, 0.374]}, {"w": "all.", "b": [0.7527, 0.3526, 0.7771, 0.374]}, {"w": "Would", "b": [0.7845, 0.3526, 0.8407, 0.374]}, {"w": "a", "b": [0.848, 0.3526, 0.8571, 0.374]}, {"w": "company", "b": [0.1429, 0.3716, 0.2195, 0.393]}, {"w": "perform", "b": [0.2265, 0.3716, 0.2956, 0.393]}, {"w": "better", "b": [0.3025, 0.3716, 0.3513, 0.393]}, {"w": "if", "b": [0.3582, 0.3716, 0.37, 0.393]}, {"w": "its", "b": [0.377, 0.3716, 0.3966, 0.393]}, {"w": "employees", "b": [0.4035, 0.3716, 0.4908, 0.393]}, {"w": "were", "b": [0.4978, 0.3716, 0.5375, 0.393]}, {"w": "told", "b": [0.5445, 0.3716, 0.5777, 0.393]}, {"w": "to", "b": [0.5847, 0.3716, 0.6017, 0.393]}, {"w": "toss", "b": [0.6086, 0.3716, 0.6409, 0.393]}, {"w": "a", "b": [0.6479, 0.3716, 0.657, 0.393]}, {"w": "coin", "b": [0.664, 0.3716, 0.7004, 0.393]}, {"w": "every", "b": [0.7074, 0.3716, 0.7527, 0.393]}, {"w": "morning", "b": [0.7596, 0.3716, 0.8332, 0.393]}, {"w": "to", "b": [0.8402, 0.3716, 0.8571, 0.393]}, {"w": "decide", "b": [0.1429, 0.3907, 0.197, 0.4121]}, {"w": "whether", "b": [0.203, 0.3907, 0.2713, 0.4121]}, {"w": "or", "b": [0.2773, 0.3907, 0.2956, 0.4121]}, {"w": "not", "b": [0.3016, 0.3907, 0.33, 0.4121]}, {"w": "to", "b": [0.336, 0.3907, 0.353, 0.4121]}, {"w": "go", "b": [0.359, 0.3907, 0.3794, 0.4121]}, {"w": "to", "b": [0.3853, 0.3907, 0.4023, 0.4121]}, {"w": "work?", "b": [0.4083, 0.3907, 0.4592, 0.4121]}, {"w": "Well,", "b": [0.4652, 0.3907, 0.5075, 0.4121]}, {"w": "who", "b": [0.5135, 0.3907, 0.5495, 0.4121]}, {"w": "knows;", "b": [0.5555, 0.3907, 0.6146, 0.4121]}, {"w": "perhaps", "b": [0.6206, 0.3907, 0.6865, 0.4121]}, {"w": "it", "b": [0.6925, 0.3907, 0.7044, 0.4121]}, {"w": "would!", "b": [0.7104, 0.3907, 0.7684, 0.4121]}, {"w": "The", "b": [0.7744, 0.3907, 0.8072, 0.4121]}, {"w": "com‐", "b": [0.8132, 0.3907, 0.8572, 0.4121]}, {"w": "pany", "b": [0.1429, 0.4097, 0.1834, 0.4311]}, {"w": "would", "b": [0.1883, 0.4097, 0.2405, 0.4311]}, {"w": "obviously", "b": [0.2454, 0.4097, 0.326, 0.4311]}, {"w": "be", "b": [0.3308, 0.4097, 0.3503, 0.4311]}, {"w": "forced", "b": [0.3551, 0.4097, 0.4083, 0.4311]}, {"w": "to", "b": [0.4132, 0.4097, 0.4302, 0.4311]}, {"w": "adapt", "b": [0.435, 0.4097, 0.4812, 0.4311]}, {"w": "its", "b": [0.486, 0.4097, 0.5056, 0.4311]}, {"w": "organization;", "b": [0.5105, 0.4097, 0.6209, 0.4311]}, {"w": "it", "b": [0.6258, 0.4097, 0.6377, 0.4311]}, {"w": "could", "b": [0.6426, 0.4097, 0.6894, 0.4311]}, {"w": "not", "b": [0.6942, 0.4097, 0.7226, 0.4311]}, {"w": "rely", "b": [0.7275, 0.4097, 0.7589, 0.4311]}, {"w": "on", "b": [0.7637, 0.4097, 0.7858, 0.4311]}, {"w": "any", "b": [0.7906, 0.4097, 0.8202, 0.4311]}, {"w": "sin‐", "b": [0.8251, 0.4097, 0.8571, 0.4311]}, {"w": "gle", "b": [0.1429, 0.4288, 0.1667, 0.4502]}, {"w": "person", "b": [0.1744, 0.4288, 0.2316, 0.4502]}, {"w": "to", "b": [0.2393, 0.4288, 0.2562, 0.4502]}, {"w": "fill", "b": [0.2639, 0.4288, 0.2862, 0.4502]}, {"w": "in", "b": [0.2939, 0.4288, 0.3109, 0.4502]}, {"w": "the", "b": [0.3186, 0.4288, 0.3449, 0.4502]}, {"w": "coffee", "b": [0.3526, 0.4288, 0.4021, 0.4502]}, {"w": "machine", "b": [0.4098, 0.4288, 0.4817, 0.4502]}, {"w": "or", "b": [0.4894, 0.4288, 0.5078, 0.4502]}, {"w": "perform", "b": [0.5155, 0.4288, 0.5846, 0.4502]}, {"w": "any", "b": [0.5922, 0.4288, 0.6219, 0.4502]}, {"w": "other", "b": [0.6296, 0.4288, 0.6742, 0.4502]}, {"w": "critical", "b": [0.6819, 0.4288, 0.7392, 0.4502]}, {"w": "tasks,", "b": [0.7469, 0.4288, 0.7928, 0.4502]}, {"w": "so", "b": [0.8005, 0.4288, 0.8187, 0.4502]}, {"w": "this", "b": [0.8264, 0.4288, 0.8571, 0.4502]}, {"w": "expertise", "b": [0.1428, 0.4478, 0.2175, 0.4692]}, {"w": "would", "b": [0.225, 0.4478, 0.2772, 0.4692]}, {"w": "have", "b": [0.2848, 0.4478, 0.3232, 0.4692]}, {"w": "to", "b": [0.3307, 0.4478, 0.3477, 0.4692]}, {"w": "be", "b": [0.3553, 0.4478, 0.3747, 0.4692]}, {"w": "spread", "b": [0.3822, 0.4478, 0.4375, 0.4692]}, {"w": "across", "b": [0.4451, 0.4478, 0.4967, 0.4692]}, {"w": "several", "b": [0.5042, 0.4478, 0.5614, 0.4692]}, {"w": "people.", "b": [0.5689, 0.4478, 0.6291, 0.4692]}, {"w": "Employees", "b": [0.6367, 0.4478, 0.7269, 0.4692]}, {"w": "would", "b": [0.7344, 0.4478, 0.7867, 0.4692]}, {"w": "have", "b": [0.7942, 0.4478, 0.8326, 0.4692]}, {"w": "to", "b": [0.8402, 0.4478, 0.8571, 0.4692]}, {"w": "learn", "b": [0.1429, 0.4669, 0.1853, 0.4883]}, {"w": "to", "b": [0.1932, 0.4669, 0.2101, 0.4883]}, {"w": "cooperate", "b": [0.2181, 0.4669, 0.2996, 0.4883]}, {"w": "with", "b": [0.3075, 0.4669, 0.3448, 0.4883]}, {"w": "many", "b": [0.3527, 0.4669, 0.3994, 0.4883]}, {"w": "of", "b": [0.4073, 0.4669, 0.4241, 0.4883]}, {"w": "their", "b": [0.432, 0.4669, 0.4717, 0.4883]}, {"w": "coworkers,", "b": [0.4796, 0.4669, 0.5709, 0.4883]}, {"w": "not", "b": [0.5789, 0.4669, 0.6072, 0.4883]}, {"w": "just", "b": [0.6151, 0.4669, 0.6455, 0.4883]}, {"w": "a", "b": [0.6534, 0.4669, 0.6626, 0.4883]}, {"w": "handful", "b": [0.6705, 0.4669, 0.7357, 0.4883]}, {"w": "of", "b": [0.7436, 0.4669, 0.7604, 0.4883]}, {"w": "them.", "b": [0.7683, 0.4669, 0.8164, 0.4883]}, {"w": "The", "b": [0.8243, 0.4669, 0.8571, 0.4883]}, {"w": "company", "b": [0.1429, 0.4859, 0.2195, 0.5073]}, {"w": "would", "b": [0.2268, 0.4859, 0.279, 0.5073]}, {"w": "become", "b": [0.2864, 0.4859, 0.3512, 0.5073]}, {"w": "much", "b": [0.3585, 0.4859, 0.4061, 0.5073]}, {"w": "more", "b": [0.4135, 0.4859, 0.4577, 0.5073]}, {"w": "resilient.", "b": [0.465, 0.4859, 0.5367, 0.5073]}, {"w": "If", "b": [0.544, 0.4859, 0.5573, 0.5073]}, {"w": "one", "b": [0.5646, 0.4859, 0.5955, 0.5073]}, {"w": "person", "b": [0.6028, 0.4859, 0.6599, 0.5073]}, {"w": "quit,", "b": [0.6673, 0.4859, 0.7057, 0.5073]}, {"w": "it", "b": [0.713, 0.4859, 0.7249, 0.5073]}, {"w": "wouldn’t", "b": [0.7322, 0.4859, 0.8044, 0.5073]}, {"w": "make", "b": [0.8117, 0.4859, 0.8571, 0.5073]}, {"w": "much", "b": [0.1429, 0.5049, 0.1905, 0.5264]}, {"w": "of", "b": [0.1972, 0.5049, 0.214, 0.5264]}, {"w": "a", "b": [0.2206, 0.5049, 0.2297, 0.5264]}, {"w": "difference.", "b": [0.2364, 0.5049, 0.3245, 0.5264]}, {"w": "It’s", "b": [0.3312, 0.5049, 0.3536, 0.5264]}, {"w": "unclear", "b": [0.3602, 0.5049, 0.4225, 0.5264]}, {"w": "whether", "b": [0.4291, 0.5049, 0.4974, 0.5264]}, {"w": "this", "b": [0.5041, 0.5049, 0.5348, 0.5264]}, {"w": "idea", "b": [0.5414, 0.5049, 0.576, 0.5264]}, {"w": "would", "b": [0.5827, 0.5049, 0.6349, 0.5264]}, {"w": "actually", "b": [0.6415, 0.5049, 0.7062, 0.5264]}, {"w": "work", "b": [0.7128, 0.5049, 0.7558, 0.5264]}, {"w": "for", "b": [0.7624, 0.5049, 0.7869, 0.5264]}, {"w": "compa‐", "b": [0.7936, 0.5049, 0.8571, 0.5264]}, {"w": "nies,", "b": [0.1429, 0.524, 0.1811, 0.5454]}, {"w": "but", "b": [0.1869, 0.524, 0.2149, 0.5454]}, {"w": "it", "b": [0.2207, 0.524, 0.2326, 0.5454]}, {"w": "certainly", "b": [0.2384, 0.524, 0.3112, 0.5454]}, {"w": "does", "b": [0.317, 0.524, 0.3551, 0.5454]}, {"w": "for", "b": [0.3609, 0.524, 0.3854, 0.5454]}, {"w": "neural", "b": [0.3912, 0.524, 0.4447, 0.5454]}, {"w": "networks.", "b": [0.4505, 0.524, 0.5324, 0.5454]}, {"w": "Neurons", "b": [0.5382, 0.524, 0.6105, 0.5454]}, {"w": "trained", "b": [0.6163, 0.524, 0.6764, 0.5454]}, {"w": "with", "b": [0.6822, 0.524, 0.7195, 0.5454]}, {"w": "dropout", "b": [0.7253, 0.524, 0.7936, 0.5454]}, {"w": "cannot", "b": [0.7994, 0.524, 0.8572, 0.5454]}, {"w": "co-adapt", "b": [0.1429, 0.543, 0.2159, 0.5645]}, {"w": "with", "b": [0.224, 0.543, 0.2613, 0.5645]}, {"w": "their", "b": [0.2694, 0.543, 0.309, 0.5645]}, {"w": "neighboring", "b": [0.3171, 0.543, 0.4195, 0.5645]}, {"w": "neurons;", "b": [0.4275, 0.543, 0.501, 0.5645]}, {"w": "they", "b": [0.5091, 0.543, 0.545, 0.5645]}, {"w": "have", "b": [0.553, 0.543, 0.5914, 0.5645]}, {"w": "to", "b": [0.5995, 0.543, 0.6165, 0.5645]}, {"w": "be", "b": [0.6246, 0.543, 0.644, 0.5645]}, {"w": "as", "b": [0.6521, 0.543, 0.6689, 0.5645]}, {"w": "useful", "b": [0.6769, 0.543, 0.727, 0.5645]}, {"w": "as", "b": [0.7351, 0.543, 0.7519, 0.5645]}, {"w": "possible", "b": [0.7599, 0.543, 0.8271, 0.5645]}, {"w": "on", "b": [0.8351, 0.543, 0.8571, 0.5645]}, {"w": "their", "b": [0.1429, 0.5621, 0.1825, 0.5835]}, {"w": "own.", "b": [0.1891, 0.5621, 0.2301, 0.5835]}, {"w": "They", "b": [0.2367, 0.5621, 0.2791, 0.5835]}, {"w": "also", "b": [0.2856, 0.5621, 0.3183, 0.5835]}, {"w": "cannot", "b": [0.3249, 0.5621, 0.3826, 0.5835]}, {"w": "rely", "b": [0.3892, 0.5621, 0.4206, 0.5835]}, {"w": "excessively", "b": [0.4272, 0.5621, 0.5177, 0.5835]}, {"w": "on", "b": [0.5243, 0.5621, 0.5463, 0.5835]}, {"w": "just", "b": [0.5529, 0.5621, 0.5833, 0.5835]}, {"w": "a", "b": [0.5899, 0.5621, 0.599, 0.5835]}, {"w": "few", "b": [0.6056, 0.5621, 0.6349, 0.5835]}, {"w": "input", "b": [0.6414, 0.5621, 0.6864, 0.5835]}, {"w": "neurons;", "b": [0.6929, 0.5621, 0.7664, 0.5835]}, {"w": "they", "b": [0.7729, 0.5621, 0.8088, 0.5835]}, {"w": "must", "b": [0.8154, 0.5621, 0.8571, 0.5835]}, {"w": "pay", "b": [0.1428, 0.5811, 0.1721, 0.6026]}, {"w": "attention", "b": [0.1771, 0.5811, 0.2524, 0.6026]}, {"w": "to", "b": [0.2574, 0.5811, 0.2743, 0.6026]}, {"w": "each", "b": [0.2793, 0.5811, 0.3173, 0.6026]}, {"w": "of", "b": [0.3223, 0.5811, 0.3391, 0.6026]}, {"w": "their", "b": [0.3441, 0.5811, 0.3837, 0.6026]}, {"w": "input", "b": [0.3887, 0.5811, 0.4336, 0.6026]}, {"w": "neurons.", "b": [0.4386, 0.5811, 0.5121, 0.6026]}, {"w": "They", "b": [0.5171, 0.5811, 0.5595, 0.6026]}, {"w": "end", "b": [0.5645, 0.5811, 0.5957, 0.6026]}, {"w": "up", "b": [0.6007, 0.5811, 0.6227, 0.6026]}, {"w": "being", "b": [0.6277, 0.5811, 0.6739, 0.6026]}, {"w": "less", "b": [0.6789, 0.5811, 0.7083, 0.6026]}, {"w": "sensitive", "b": [0.7133, 0.5811, 0.7848, 0.6026]}, {"w": "to", "b": [0.7898, 0.5811, 0.8068, 0.6026]}, {"w": "slight", "b": [0.8118, 0.5811, 0.8571, 0.6026]}, {"w": "changes", "b": [0.1429, 0.6002, 0.2096, 0.6216]}, {"w": "in", "b": [0.2149, 0.6002, 0.2319, 0.6216]}, {"w": "the", "b": [0.2372, 0.6002, 0.2636, 0.6216]}, {"w": "inputs.", "b": [0.2689, 0.6002, 0.3262, 0.6216]}, {"w": "In", "b": [0.3316, 0.6002, 0.3501, 0.6216]}, {"w": "the", "b": [0.3554, 0.6002, 0.3817, 0.6216]}, {"w": "end", "b": [0.3871, 0.6002, 0.4183, 0.6216]}, {"w": "you", "b": [0.4237, 0.6002, 0.4549, 0.6216]}, {"w": "get", "b": [0.4602, 0.6002, 0.4852, 0.6216]}, {"w": "a", "b": [0.4905, 0.6002, 0.4997, 0.6216]}, {"w": "more", "b": [0.505, 0.6002, 0.5493, 0.6216]}, {"w": "robust", "b": [0.5546, 0.6002, 0.6086, 0.6216]}, {"w": "network", "b": [0.614, 0.6002, 0.6835, 0.6216]}, {"w": "that", "b": [0.6889, 0.6002, 0.7214, 0.6216]}, {"w": "generalizes", "b": [0.7268, 0.6002, 0.8186, 0.6216]}, {"w": "bet‐", "b": [0.8239, 0.6002, 0.8571, 0.6216]}, {"w": "ter.", "b": [0.1429, 0.6192, 0.1692, 0.6406]}]}, {"id": "b_2", "type": "paragraph", "text": "Another way to understand the power of dropout is to realize that a unique neural network is generated at each training step. Since each neuron can be either present or absent, there is a total of 2N possible networks (where N is the total number of drop‐ pable neurons). This is such a huge number that it is virtually impossible for the same neural network to be sampled twice. Once you have run a 10,000 training steps, you have essentially trained 10,000 different neural networks (each with just one training instance). These neural networks are obviously not independent since they share many of their weights, but they are nevertheless all different. The resulting neural network can be seen as an averaging ensemble of all these smaller neural networks.", "words": [{"w": "Another", "b": [0.1429, 0.6474, 0.2133, 0.6688]}, {"w": "way", "b": [0.2202, 0.6474, 0.2528, 0.6688]}, {"w": "to", "b": [0.2597, 0.6474, 0.2767, 0.6688]}, {"w": "understand", "b": [0.2836, 0.6474, 0.3792, 0.6688]}, {"w": "the", "b": [0.3861, 0.6474, 0.4124, 0.6688]}, {"w": "power", "b": [0.4193, 0.6474, 0.4717, 0.6688]}, {"w": "of", "b": [0.4786, 0.6474, 0.4954, 0.6688]}, {"w": "dropout", "b": [0.5023, 0.6474, 0.5706, 0.6688]}, {"w": "is", "b": [0.5775, 0.6474, 0.5908, 0.6688]}, {"w": "to", "b": [0.5977, 0.6474, 0.6147, 0.6688]}, {"w": "realize", "b": [0.6216, 0.6474, 0.6757, 0.6688]}, {"w": "that", "b": [0.6826, 0.6474, 0.7152, 0.6688]}, {"w": "a", "b": [0.7221, 0.6474, 0.7313, 0.6688]}, {"w": "unique", "b": [0.7382, 0.6474, 0.7968, 0.6688]}, {"w": "neural", "b": [0.8037, 0.6474, 0.8571, 0.6688]}, {"w": "network", "b": [0.1429, 0.6664, 0.2124, 0.6878]}, {"w": "is", "b": [0.2175, 0.6664, 0.2308, 0.6878]}, {"w": "generated", "b": [0.2359, 0.6664, 0.3174, 0.6878]}, {"w": "at", "b": [0.3225, 0.6664, 0.3376, 0.6878]}, {"w": "each", "b": [0.3427, 0.6664, 0.3807, 0.6878]}, {"w": "training", "b": [0.3858, 0.6664, 0.4527, 0.6878]}, {"w": "step.", "b": [0.4578, 0.6664, 0.4957, 0.6878]}, {"w": "Since", "b": [0.5008, 0.6664, 0.5454, 0.6878]}, {"w": "each", "b": [0.5505, 0.6664, 0.5884, 0.6878]}, {"w": "neuron", "b": [0.5935, 0.6664, 0.6546, 0.6878]}, {"w": "can", "b": [0.6597, 0.6664, 0.6891, 0.6878]}, {"w": "be", "b": [0.6942, 0.6664, 0.7136, 0.6878]}, {"w": "either", "b": [0.7187, 0.6664, 0.7672, 0.6878]}, {"w": "present", "b": [0.7723, 0.6664, 0.8337, 0.6878]}, {"w": "or", "b": [0.8388, 0.6664, 0.8571, 0.6878]}, {"w": "absent,", "b": [0.1429, 0.6854, 0.2012, 0.7069]}, {"w": "there", "b": [0.207, 0.6854, 0.2499, 0.7069]}, {"w": "is", "b": [0.2556, 0.6854, 0.2689, 0.7069]}, {"w": "a", "b": [0.2746, 0.6854, 0.2838, 0.7069]}, {"w": "total", "b": [0.2895, 0.6854, 0.3273, 0.7069]}, {"w": "of", "b": [0.333, 0.6854, 0.3498, 0.7069]}, {"w": "2N", "b": [0.3556, 0.6854, 0.3744, 0.7069]}, {"w": "possible", "b": [0.3802, 0.6854, 0.4473, 0.7069]}, {"w": "networks", "b": [0.453, 0.6854, 0.5302, 0.7069]}, {"w": "(where", "b": [0.536, 0.6854, 0.594, 0.7069]}, {"w": "N", "b": [0.5998, 0.6852, 0.6145, 0.7069]}, {"w": "is", "b": [0.6203, 0.6854, 0.6335, 0.7069]}, {"w": "the", "b": [0.6392, 0.6854, 0.6656, 0.7069]}, {"w": "total", "b": [0.6713, 0.6854, 0.7091, 0.7069]}, {"w": "number", "b": [0.7148, 0.6854, 0.7811, 0.7069]}, {"w": "of", "b": [0.7869, 0.6854, 0.8037, 0.7069]}, {"w": "drop‐", "b": [0.8095, 0.6854, 0.8571, 0.7069]}, {"w": "pable", "b": [0.1428, 0.7045, 0.1876, 0.7259]}, {"w": "neurons).", "b": [0.1925, 0.7045, 0.2732, 0.7259]}, {"w": "This", "b": [0.2781, 0.7045, 0.3153, 0.7259]}, {"w": "is", "b": [0.3202, 0.7045, 0.3334, 0.7259]}, {"w": "such", "b": [0.3384, 0.7045, 0.377, 0.7259]}, {"w": "a", "b": [0.3819, 0.7045, 0.3911, 0.7259]}, {"w": "huge", "b": [0.396, 0.7045, 0.4364, 0.7259]}, {"w": "number", "b": [0.4413, 0.7045, 0.5076, 0.7259]}, {"w": "that", "b": [0.5125, 0.7045, 0.545, 0.7259]}, {"w": "it", "b": [0.55, 0.7045, 0.5619, 0.7259]}, {"w": "is", "b": [0.5668, 0.7045, 0.58, 0.7259]}, {"w": "virtually", "b": [0.5849, 0.7045, 0.6546, 0.7259]}, {"w": "impossible", "b": [0.6595, 0.7045, 0.7488, 0.7259]}, {"w": "for", "b": [0.7538, 0.7045, 0.7783, 0.7259]}, {"w": "the", "b": [0.7832, 0.7045, 0.8095, 0.7259]}, {"w": "same", "b": [0.8144, 0.7045, 0.8571, 0.7259]}, {"w": "neural", "b": [0.1429, 0.7235, 0.1963, 0.745]}, {"w": "network", "b": [0.2023, 0.7235, 0.2719, 0.745]}, {"w": "to", "b": [0.2779, 0.7235, 0.2949, 0.745]}, {"w": "be", "b": [0.3009, 0.7235, 0.3203, 0.745]}, {"w": "sampled", "b": [0.3263, 0.7235, 0.3958, 0.745]}, {"w": "twice.", "b": [0.4018, 0.7235, 0.4504, 0.745]}, {"w": "Once", "b": [0.4564, 0.7235, 0.5011, 0.745]}, {"w": "you", "b": [0.5071, 0.7235, 0.5383, 0.745]}, {"w": "have", "b": [0.5443, 0.7235, 0.5827, 0.745]}, {"w": "run", "b": [0.5887, 0.7235, 0.6189, 0.745]}, {"w": "a", "b": [0.6249, 0.7235, 0.634, 0.745]}, {"w": "10,000", "b": [0.64, 0.7235, 0.6948, 0.745]}, {"w": "training", "b": [0.7008, 0.7235, 0.7677, 0.745]}, {"w": "steps,", "b": [0.7737, 0.7235, 0.8199, 0.745]}, {"w": "you", "b": [0.8259, 0.7235, 0.8571, 0.745]}, {"w": "have", "b": [0.1429, 0.7426, 0.1813, 0.764]}, {"w": "essentially", "b": [0.187, 0.7426, 0.2722, 0.764]}, {"w": "trained", "b": [0.2779, 0.7426, 0.3379, 0.764]}, {"w": "10,000", "b": [0.3436, 0.7426, 0.3984, 0.764]}, {"w": "different", "b": [0.4041, 0.7426, 0.4758, 0.764]}, {"w": "neural", "b": [0.4815, 0.7426, 0.535, 0.764]}, {"w": "networks", "b": [0.5407, 0.7426, 0.6179, 0.764]}, {"w": "(each", "b": [0.6236, 0.7426, 0.6688, 0.764]}, {"w": "with", "b": [0.6745, 0.7426, 0.7118, 0.764]}, {"w": "just", "b": [0.7175, 0.7426, 0.7479, 0.764]}, {"w": "one", "b": [0.7536, 0.7426, 0.7845, 0.764]}, {"w": "training", "b": [0.7902, 0.7426, 0.8571, 0.764]}, {"w": "instance).", "b": [0.1429, 0.7616, 0.224, 0.7831]}, {"w": "These", "b": [0.233, 0.7616, 0.2824, 0.7831]}, {"w": "neural", "b": [0.2914, 0.7616, 0.3449, 0.7831]}, {"w": "networks", "b": [0.3539, 0.7616, 0.4312, 0.7831]}, {"w": "are", "b": [0.4402, 0.7616, 0.4659, 0.7831]}, {"w": "obviously", "b": [0.475, 0.7616, 0.5556, 0.7831]}, {"w": "not", "b": [0.5647, 0.7616, 0.593, 0.7831]}, {"w": "independent", "b": [0.6021, 0.7616, 0.7073, 0.7831]}, {"w": "since", "b": [0.7163, 0.7616, 0.7586, 0.7831]}, {"w": "they", "b": [0.7677, 0.7616, 0.8036, 0.7831]}, {"w": "share", "b": [0.8126, 0.7616, 0.8571, 0.7831]}, {"w": "many", "b": [0.1429, 0.7807, 0.1896, 0.8021]}, {"w": "of", "b": [0.1975, 0.7807, 0.2143, 0.8021]}, {"w": "their", "b": [0.2222, 0.7807, 0.2619, 0.8021]}, {"w": "weights,", "b": [0.2698, 0.7807, 0.3377, 0.8021]}, {"w": "but", "b": [0.3457, 0.7807, 0.3737, 0.8021]}, {"w": "they", "b": [0.3816, 0.7807, 0.4175, 0.8021]}, {"w": "are", "b": [0.4255, 0.7807, 0.4512, 0.8021]}, {"w": "nevertheless", "b": [0.4591, 0.7807, 0.5614, 0.8021]}, {"w": "all", "b": [0.5693, 0.7807, 0.589, 0.8021]}, {"w": "different.", "b": [0.5969, 0.7807, 0.6734, 0.8021]}, {"w": "The", "b": [0.6813, 0.7807, 0.7142, 0.8021]}, {"w": "resulting", "b": [0.7221, 0.7807, 0.7958, 0.8021]}, {"w": "neural", "b": [0.8037, 0.7807, 0.8572, 0.8021]}, {"w": "network", "b": [0.1429, 0.7997, 0.2124, 0.8211]}, {"w": "can", "b": [0.2172, 0.7997, 0.2465, 0.8211]}, {"w": "be", "b": [0.2512, 0.7997, 0.2707, 0.8211]}, {"w": "seen", "b": [0.2754, 0.7997, 0.3122, 0.8211]}, {"w": "as", "b": [0.3169, 0.7997, 0.3337, 0.8211]}, {"w": "an", "b": [0.3384, 0.7997, 0.3589, 0.8211]}, {"w": "averaging", "b": [0.3637, 0.7997, 0.4443, 0.8211]}, {"w": "ensemble", "b": [0.449, 0.7997, 0.5275, 0.8211]}, {"w": "of", "b": [0.5323, 0.7997, 0.5491, 0.8211]}, {"w": "all", "b": [0.5538, 0.7997, 0.5735, 0.8211]}, {"w": "these", "b": [0.5782, 0.7997, 0.621, 0.8211]}, {"w": "smaller", "b": [0.6258, 0.7997, 0.6868, 0.8211]}, {"w": "neural", "b": [0.6915, 0.7997, 0.7449, 0.8211]}, {"w": "networks.", "b": [0.7497, 0.7997, 0.8316, 0.8211]}]}, {"id": "b_3", "type": "paragraph", "text": "There is one small but important technical detail. Suppose p = 50%, in which case during testing a neuron will be connected to twice as many input neurons as it was (on average) during training. To compensate for this fact, we need to multiply each", "words": [{"w": "There", "b": [0.1429, 0.8279, 0.1923, 0.8493]}, {"w": "is", "b": [0.1996, 0.8279, 0.2128, 0.8493]}, {"w": "one", "b": [0.2202, 0.8279, 0.2511, 0.8493]}, {"w": "small", "b": [0.2584, 0.8279, 0.3028, 0.8493]}, {"w": "but", "b": [0.3101, 0.8279, 0.3381, 0.8493]}, {"w": "important", "b": [0.3455, 0.8279, 0.4298, 0.8493]}, {"w": "technical", "b": [0.4372, 0.8279, 0.5125, 0.8493]}, {"w": "detail.", "b": [0.5199, 0.8279, 0.5708, 0.8493]}, {"w": "Suppose", "b": [0.5782, 0.8279, 0.6481, 0.8493]}, {"w": "p", "b": [0.6554, 0.8276, 0.6655, 0.8493]}, {"w": "=", "b": [0.6729, 0.8279, 0.6849, 0.8493]}, {"w": "50%,", "b": [0.6923, 0.8279, 0.7328, 0.8493]}, {"w": "in", "b": [0.7401, 0.8279, 0.7571, 0.8493]}, {"w": "which", "b": [0.7644, 0.8279, 0.8153, 0.8493]}, {"w": "case", "b": [0.8227, 0.8279, 0.8571, 0.8493]}, {"w": "during", "b": [0.1429, 0.8469, 0.1994, 0.8683]}, {"w": "testing", "b": [0.2059, 0.8469, 0.2618, 0.8683]}, {"w": "a", "b": [0.2684, 0.8469, 0.2775, 0.8683]}, {"w": "neuron", "b": [0.284, 0.8469, 0.3451, 0.8683]}, {"w": "will", "b": [0.3516, 0.8469, 0.382, 0.8683]}, {"w": "be", "b": [0.3886, 0.8469, 0.408, 0.8683]}, {"w": "connected", "b": [0.4145, 0.8469, 0.5006, 0.8683]}, {"w": "to", "b": [0.5072, 0.8469, 0.5241, 0.8683]}, {"w": "twice", "b": [0.5307, 0.8469, 0.5745, 0.8683]}, {"w": "as", "b": [0.5811, 0.8469, 0.5979, 0.8683]}, {"w": "many", "b": [0.6044, 0.8469, 0.6511, 0.8683]}, {"w": "input", "b": [0.6576, 0.8469, 0.7025, 0.8683]}, {"w": "neurons", "b": [0.7091, 0.8469, 0.7778, 0.8683]}, {"w": "as", "b": [0.7843, 0.8469, 0.8011, 0.8683]}, {"w": "it", "b": [0.8076, 0.8469, 0.8195, 0.8683]}, {"w": "was", "b": [0.8261, 0.8469, 0.8571, 0.8683]}, {"w": "(on", "b": [0.1428, 0.8659, 0.1721, 0.8874]}, {"w": "average)", "b": [0.1788, 0.8659, 0.2487, 0.8874]}, {"w": "during", "b": [0.2555, 0.8659, 0.312, 0.8874]}, {"w": "training.", "b": [0.3187, 0.8659, 0.3904, 0.8874]}, {"w": "To", "b": [0.3971, 0.8659, 0.4185, 0.8874]}, {"w": "compensate", "b": [0.4253, 0.8659, 0.5241, 0.8874]}, {"w": "for", "b": [0.5308, 0.8659, 0.5554, 0.8874]}, {"w": "this", "b": [0.5621, 0.8659, 0.5928, 0.8874]}, {"w": "fact,", "b": [0.5995, 0.8659, 0.6347, 0.8874]}, {"w": "we", "b": [0.6414, 0.8659, 0.6646, 0.8874]}, {"w": "need", "b": [0.6713, 0.8659, 0.7114, 0.8874]}, {"w": "to", "b": [0.7181, 0.8659, 0.7351, 0.8874]}, {"w": "multiply", "b": [0.7418, 0.8659, 0.8125, 0.8874]}, {"w": "each", "b": [0.8192, 0.8659, 0.8571, 0.8874]}]}, {"id": "b_4", "type": "paragraph", "text": "358 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "358", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2745, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 385, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "25 This is specific to tf.keras, so you may prefer to use keras.backend.set_learning_phase(1) before calling the fit() method (and set it back to 0 right after).", "words": [{"w": "25", "b": [0.1385, 0.8602, 0.1518, 0.8745]}, {"w": "This", "b": [0.1587, 0.8587, 0.1871, 0.8751]}, {"w": "is", "b": [0.1907, 0.8587, 0.2008, 0.8751]}, {"w": "specific", "b": [0.2044, 0.8587, 0.2519, 0.8751]}, {"w": "to", "b": [0.2555, 0.8587, 0.2684, 0.8751]}, {"w": "tf.keras,", "b": [0.272, 0.8587, 0.3221, 0.8751]}, {"w": "so", "b": [0.3257, 0.8587, 0.3396, 0.8751]}, {"w": "you", "b": [0.3432, 0.8587, 0.367, 0.8751]}, {"w": "may", "b": [0.3707, 0.8587, 0.3976, 0.8751]}, {"w": "prefer", "b": [0.4012, 0.8587, 0.4395, 0.8751]}, {"w": "to", "b": [0.4431, 0.8587, 0.456, 0.8751]}, {"w": "use", "b": [0.4597, 0.8587, 0.4807, 0.8751]}, {"w": "keras.backend.set_learning_phase(1)", "b": [0.4843, 0.8612, 0.7481, 0.8727]}, {"w": "before", "b": [0.7517, 0.8587, 0.792, 0.8751]}, {"w": "calling", "b": [0.7956, 0.8587, 0.8377, 0.8751]}, {"w": "the", "b": [0.1587, 0.8749, 0.1788, 0.8912]}, {"w": "fit()", "b": [0.1824, 0.8773, 0.2201, 0.8888]}, {"w": "method", "b": [0.2237, 0.8749, 0.2732, 0.8912]}, {"w": "(and", "b": [0.2768, 0.8749, 0.3064, 0.8912]}, {"w": "set", "b": [0.31, 0.8749, 0.3274, 0.8912]}, {"w": "it", "b": [0.331, 0.8749, 0.3401, 0.8912]}, {"w": "back", "b": [0.3437, 0.8749, 0.3733, 0.8912]}, {"w": "to", "b": [0.3769, 0.8749, 0.3898, 0.8912]}, {"w": "0", "b": [0.3934, 0.8749, 0.4011, 0.8912]}, {"w": "right", "b": [0.4047, 0.8749, 0.4353, 0.8912]}, {"w": "after).", "b": [0.4389, 0.8749, 0.4771, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "neuron’s input connection weights by 0.5 after training. If we don’t, each neuron will get a total input signal roughly twice as large as what the network was trained on, and it is unlikely to perform well. More generally, we need to multiply each input connec‐ tion weight by the keep probability (1 – p) after training. Alternatively, we can divide each neuron’s output by the keep probability during training (these alternatives are not perfectly equivalent, but they work equally well).", "words": [{"w": "neuron’s", "b": [0.1429, 0.0791, 0.2125, 0.1005]}, {"w": "input", "b": [0.2183, 0.0791, 0.2633, 0.1005]}, {"w": "connection", "b": [0.2691, 0.0791, 0.3629, 0.1005]}, {"w": "weights", "b": [0.3688, 0.0791, 0.432, 0.1005]}, {"w": "by", "b": [0.4378, 0.0791, 0.4579, 0.1005]}, {"w": "0.5", "b": [0.4637, 0.0791, 0.4885, 0.1005]}, {"w": "after", "b": [0.4943, 0.0791, 0.5326, 0.1005]}, {"w": "training.", "b": [0.5384, 0.0791, 0.6101, 0.1005]}, {"w": "If", "b": [0.6159, 0.0791, 0.6292, 0.1005]}, {"w": "we", "b": [0.635, 0.0791, 0.6581, 0.1005]}, {"w": "don’t,", "b": [0.6639, 0.0791, 0.7103, 0.1005]}, {"w": "each", "b": [0.7161, 0.0791, 0.754, 0.1005]}, {"w": "neuron", "b": [0.7599, 0.0791, 0.8209, 0.1005]}, {"w": "will", "b": [0.8268, 0.0791, 0.8571, 0.1005]}, {"w": "get", "b": [0.1429, 0.0981, 0.1678, 0.1195]}, {"w": "a", "b": [0.1728, 0.0981, 0.1819, 0.1195]}, {"w": "total", "b": [0.1869, 0.0981, 0.2247, 0.1195]}, {"w": "input", "b": [0.2296, 0.0981, 0.2745, 0.1195]}, {"w": "signal", "b": [0.2795, 0.0981, 0.3283, 0.1195]}, {"w": "roughly", "b": [0.3333, 0.0981, 0.3984, 0.1195]}, {"w": "twice", "b": [0.4034, 0.0981, 0.4473, 0.1195]}, {"w": "as", "b": [0.4522, 0.0981, 0.469, 0.1195]}, {"w": "large", "b": [0.474, 0.0981, 0.5147, 0.1195]}, {"w": "as", "b": [0.5197, 0.0981, 0.5365, 0.1195]}, {"w": "what", "b": [0.5415, 0.0981, 0.582, 0.1195]}, {"w": "the", "b": [0.5869, 0.0981, 0.6133, 0.1195]}, {"w": "network", "b": [0.6183, 0.0981, 0.6878, 0.1195]}, {"w": "was", "b": [0.6928, 0.0981, 0.7238, 0.1195]}, {"w": "trained", "b": [0.7288, 0.0981, 0.7889, 0.1195]}, {"w": "on,", "b": [0.7939, 0.0981, 0.8206, 0.1195]}, {"w": "and", "b": [0.8256, 0.0981, 0.8571, 0.1195]}, {"w": "it", "b": [0.1428, 0.1172, 0.1548, 0.1386]}, {"w": "is", "b": [0.1599, 0.1172, 0.1732, 0.1386]}, {"w": "unlikely", "b": [0.1783, 0.1172, 0.2456, 0.1386]}, {"w": "to", "b": [0.2508, 0.1172, 0.2677, 0.1386]}, {"w": "perform", "b": [0.2729, 0.1172, 0.342, 0.1386]}, {"w": "well.", "b": [0.3471, 0.1172, 0.3855, 0.1386]}, {"w": "More", "b": [0.3907, 0.1172, 0.4359, 0.1386]}, {"w": "generally,", "b": [0.441, 0.1172, 0.5201, 0.1386]}, {"w": "we", "b": [0.5252, 0.1172, 0.5484, 0.1386]}, {"w": "need", "b": [0.5535, 0.1172, 0.5936, 0.1386]}, {"w": "to", "b": [0.5987, 0.1172, 0.6157, 0.1386]}, {"w": "multiply", "b": [0.6209, 0.1172, 0.6916, 0.1386]}, {"w": "each", "b": [0.6967, 0.1172, 0.7346, 0.1386]}, {"w": "input", "b": [0.7398, 0.1172, 0.7847, 0.1386]}, {"w": "connec‐", "b": [0.7898, 0.1172, 0.8571, 0.1386]}, {"w": "tion", "b": [0.1429, 0.1362, 0.1768, 0.1576]}, {"w": "weight", "b": [0.1828, 0.1362, 0.2383, 0.1576]}, {"w": "by", "b": [0.2443, 0.1362, 0.2644, 0.1576]}, {"w": "the", "b": [0.2704, 0.1362, 0.2967, 0.1576]}, {"w": "keep", "b": [0.3027, 0.136, 0.3389, 0.1576]}, {"w": "probability", "b": [0.3449, 0.136, 0.4328, 0.1576]}, {"w": "(1", "b": [0.4388, 0.1362, 0.456, 0.1576]}, {"w": "–", "b": [0.4619, 0.1362, 0.4728, 0.1576]}, {"w": "p)", "b": [0.4787, 0.136, 0.4961, 0.1576]}, {"w": "after", "b": [0.502, 0.1362, 0.5403, 0.1576]}, {"w": "training.", "b": [0.5462, 0.1362, 0.6179, 0.1576]}, {"w": "Alternatively,", "b": [0.6239, 0.1362, 0.7351, 0.1576]}, {"w": "we", "b": [0.7411, 0.1362, 0.7642, 0.1576]}, {"w": "can", "b": [0.7702, 0.1362, 0.7995, 0.1576]}, {"w": "divide", "b": [0.8055, 0.1362, 0.8571, 0.1576]}, {"w": "each", "b": [0.1429, 0.1553, 0.1808, 0.1767]}, {"w": "neuron’s", "b": [0.1879, 0.1553, 0.2576, 0.1767]}, {"w": "output", "b": [0.2647, 0.1553, 0.321, 0.1767]}, {"w": "by", "b": [0.3281, 0.1553, 0.3483, 0.1767]}, {"w": "the", "b": [0.3554, 0.1553, 0.3817, 0.1767]}, {"w": "keep", "b": [0.3888, 0.1553, 0.4278, 0.1767]}, {"w": "probability", "b": [0.4349, 0.1553, 0.5268, 0.1767]}, {"w": "during", "b": [0.5339, 0.1553, 0.5904, 0.1767]}, {"w": "training", "b": [0.5975, 0.1553, 0.6645, 0.1767]}, {"w": "(these", "b": [0.6716, 0.1553, 0.7216, 0.1767]}, {"w": "alternatives", "b": [0.7287, 0.1553, 0.8243, 0.1767]}, {"w": "are", "b": [0.8314, 0.1553, 0.8571, 0.1767]}, {"w": "not", "b": [0.1429, 0.1743, 0.1712, 0.1957]}, {"w": "perfectly", "b": [0.176, 0.1743, 0.2485, 0.1957]}, {"w": "equivalent,", "b": [0.2532, 0.1743, 0.3444, 0.1957]}, {"w": "but", "b": [0.3491, 0.1743, 0.3771, 0.1957]}, {"w": "they", "b": [0.3818, 0.1743, 0.4177, 0.1957]}, {"w": "work", "b": [0.4225, 0.1743, 0.4654, 0.1957]}, {"w": "equally", "b": [0.4701, 0.1743, 0.53, 0.1957]}, {"w": "well).", "b": [0.5347, 0.1743, 0.5803, 0.1957]}]}, {"id": "b_2", "type": "paragraph", "text": "To implement dropout using Keras, you can use the keras.layers.Dropout layer. During training, it randomly drops some inputs (setting them to 0) and divides the remaining inputs by the keep probability. After training, it does nothing at all, it just passes the inputs to the next layer. For example, the following code applies dropout regularization before every Dense layer, using a dropout rate of 0.2:", "words": [{"w": "To", "b": [0.1429, 0.2033, 0.1643, 0.2247]}, {"w": "implement", "b": [0.1724, 0.2033, 0.2629, 0.2247]}, {"w": "dropout", "b": [0.271, 0.2033, 0.3393, 0.2247]}, {"w": "using", "b": [0.3474, 0.2033, 0.3929, 0.2247]}, {"w": "Keras,", "b": [0.4009, 0.2033, 0.4526, 0.2247]}, {"w": "you", "b": [0.4607, 0.2033, 0.4919, 0.2247]}, {"w": "can", "b": [0.5, 0.2033, 0.5294, 0.2247]}, {"w": "use", "b": [0.5374, 0.2033, 0.565, 0.2247]}, {"w": "the", "b": [0.5731, 0.2033, 0.5994, 0.2247]}, {"w": "keras.layers.Dropout", "b": [0.6075, 0.2065, 0.8054, 0.2216]}, {"w": "layer.", "b": [0.8135, 0.2033, 0.8571, 0.2247]}, {"w": "During", "b": [0.1429, 0.2224, 0.2037, 0.2438]}, {"w": "training,", "b": [0.2103, 0.2224, 0.282, 0.2438]}, {"w": "it", "b": [0.2885, 0.2224, 0.3005, 0.2438]}, {"w": "randomly", "b": [0.307, 0.2224, 0.3888, 0.2438]}, {"w": "drops", "b": [0.3954, 0.2224, 0.4433, 0.2438]}, {"w": "some", "b": [0.4499, 0.2224, 0.4941, 0.2438]}, {"w": "inputs", "b": [0.5007, 0.2224, 0.5532, 0.2438]}, {"w": "(setting", "b": [0.5598, 0.2224, 0.6229, 0.2438]}, {"w": "them", "b": [0.6295, 0.2224, 0.6729, 0.2438]}, {"w": "to", "b": [0.6795, 0.2224, 0.6965, 0.2438]}, {"w": "0)", "b": [0.703, 0.2224, 0.7202, 0.2438]}, {"w": "and", "b": [0.7268, 0.2224, 0.7584, 0.2438]}, {"w": "divides", "b": [0.7649, 0.2224, 0.8242, 0.2438]}, {"w": "the", "b": [0.8308, 0.2224, 0.8572, 0.2438]}, {"w": "remaining", "b": [0.1429, 0.2414, 0.2294, 0.2628]}, {"w": "inputs", "b": [0.2352, 0.2414, 0.2877, 0.2628]}, {"w": "by", "b": [0.2935, 0.2414, 0.3137, 0.2628]}, {"w": "the", "b": [0.3195, 0.2414, 0.3458, 0.2628]}, {"w": "keep", "b": [0.3516, 0.2414, 0.3906, 0.2628]}, {"w": "probability.", "b": [0.3964, 0.2414, 0.4916, 0.2628]}, {"w": "After", "b": [0.4974, 0.2414, 0.5409, 0.2628]}, {"w": "training,", "b": [0.5467, 0.2414, 0.6183, 0.2628]}, {"w": "it", "b": [0.6242, 0.2414, 0.6361, 0.2628]}, {"w": "does", "b": [0.6419, 0.2414, 0.68, 0.2628]}, {"w": "nothing", "b": [0.6858, 0.2414, 0.7521, 0.2628]}, {"w": "at", "b": [0.7579, 0.2414, 0.773, 0.2628]}, {"w": "all,", "b": [0.7788, 0.2414, 0.8032, 0.2628]}, {"w": "it", "b": [0.809, 0.2414, 0.8209, 0.2628]}, {"w": "just", "b": [0.8268, 0.2414, 0.8571, 0.2628]}, {"w": "passes", "b": [0.1429, 0.2605, 0.1947, 0.2819]}, {"w": "the", "b": [0.2013, 0.2605, 0.2277, 0.2819]}, {"w": "inputs", "b": [0.2343, 0.2605, 0.2868, 0.2819]}, {"w": "to", "b": [0.2935, 0.2605, 0.3104, 0.2819]}, {"w": "the", "b": [0.3171, 0.2605, 0.3434, 0.2819]}, {"w": "next", "b": [0.35, 0.2605, 0.3865, 0.2819]}, {"w": "layer.", "b": [0.3931, 0.2605, 0.4367, 0.2819]}, {"w": "For", "b": [0.4433, 0.2605, 0.4723, 0.2819]}, {"w": "example,", "b": [0.4789, 0.2605, 0.5532, 0.2819]}, {"w": "the", "b": [0.5598, 0.2605, 0.5862, 0.2819]}, {"w": "following", "b": [0.5928, 0.2605, 0.6717, 0.2819]}, {"w": "code", "b": [0.6784, 0.2605, 0.7177, 0.2819]}, {"w": "applies", "b": [0.7243, 0.2605, 0.7822, 0.2819]}, {"w": "dropout", "b": [0.7888, 0.2605, 0.8571, 0.2819]}, {"w": "regularization", "b": [0.1429, 0.2804, 0.2594, 0.3018]}, {"w": "before", "b": [0.2642, 0.2804, 0.317, 0.3018]}, {"w": "every", "b": [0.3217, 0.2804, 0.367, 0.3018]}, {"w": "Dense", "b": [0.3717, 0.2836, 0.4212, 0.2987]}, {"w": "layer,", "b": [0.4259, 0.2804, 0.4695, 0.3018]}, {"w": "using", "b": [0.4742, 0.2804, 0.5197, 0.3018]}, {"w": "a", "b": [0.5244, 0.2804, 0.5336, 0.3018]}, {"w": "dropout", "b": [0.5383, 0.2804, 0.6066, 0.3018]}, {"w": "rate", "b": [0.6113, 0.2804, 0.643, 0.3018]}, {"w": "of", "b": [0.6477, 0.2804, 0.6645, 0.3018]}, {"w": "0.2:", "b": [0.6693, 0.2804, 0.6988, 0.3018]}]}, {"id": "b_3", "type": "paragraph", "text": "model = keras.models.Sequential([ keras.layers.Flatten(input_shape=[28, 28]), keras.layers.Dropout(rate=0.2), keras.layers.Dense(300, activation=\"elu\", kernel_initializer=\"he_normal\"), keras.layers.Dropout(rate=0.2), keras.layers.Dense(100, activation=\"elu\", kernel_initializer=\"he_normal\"), keras.layers.Dropout(rate=0.2), keras.layers.Dense(10, activation=\"softmax\") ])", "words": [{"w": "model", "b": [0.1766, 0.3124, 0.2188, 0.3252]}, {"w": "=", "b": [0.2272, 0.3124, 0.2356, 0.3252]}, {"w": "keras.models.Sequential([", "b": [0.2441, 0.3124, 0.4549, 0.3252]}, {"w": "keras.layers.Flatten(input_shape=[28,", "b": [0.2103, 0.3278, 0.5223, 0.3406]}, {"w": "28]),", "b": [0.5308, 0.3278, 0.5729, 0.3406]}, {"w": "keras.layers.Dropout(rate=0.2),", "b": [0.2103, 0.3432, 0.4717, 0.3561]}, {"w": "keras.layers.Dense(300,", "b": [0.2103, 0.3586, 0.4043, 0.3715]}, {"w": "activation=\"elu\",", "b": [0.4127, 0.3586, 0.5561, 0.3715]}, {"w": "kernel_initializer=\"he_normal\"),", "b": [0.5645, 0.3586, 0.8343, 0.3715]}, {"w": "keras.layers.Dropout(rate=0.2),", "b": [0.2103, 0.3741, 0.4717, 0.3869]}, {"w": "keras.layers.Dense(100,", "b": [0.2103, 0.3895, 0.4043, 0.4023]}, {"w": "activation=\"elu\",", "b": [0.4127, 0.3895, 0.5561, 0.4023]}, {"w": "kernel_initializer=\"he_normal\"),", "b": [0.5645, 0.3895, 0.8343, 0.4023]}, {"w": "keras.layers.Dropout(rate=0.2),", "b": [0.2103, 0.4049, 0.4717, 0.4177]}, {"w": "keras.layers.Dense(10,", "b": [0.2103, 0.4203, 0.3958, 0.4332]}, {"w": "activation=\"softmax\")", "b": [0.4043, 0.4203, 0.5814, 0.4332]}, {"w": "])", "b": [0.1766, 0.4357, 0.1935, 0.4486]}]}, {"id": "b_4", "type": "paragraph", "text": "Since dropout is only active during training, the training loss is penalized compared to the validation loss, so comparing the two can be misleading. In particular, a model may be overfitting the training set and yet have similar training and validation losses. So make sure to evaluate the training loss without dropout (e.g., after training). Alternatively, you can call the fit() method inside a with keras.backend.learning_phase_scope(1) block: this will force dropout to be active during both training and validation.25", "words": [{"w": "Since", "b": [0.2714, 0.4702, 0.3121, 0.4898]}, {"w": "dropout", "b": [0.3199, 0.4702, 0.3824, 0.4898]}, {"w": "is", "b": [0.3902, 0.4702, 0.4023, 0.4898]}, {"w": "only", "b": [0.4101, 0.4702, 0.4438, 0.4898]}, {"w": "active", "b": [0.4516, 0.4702, 0.4958, 0.4898]}, {"w": "during", "b": [0.5036, 0.4702, 0.5553, 0.4898]}, {"w": "training,", "b": [0.5631, 0.4702, 0.6286, 0.4898]}, {"w": "the", "b": [0.6364, 0.4702, 0.6605, 0.4898]}, {"w": "training", "b": [0.6683, 0.4702, 0.7295, 0.4898]}, {"w": "loss", "b": [0.7373, 0.4702, 0.7658, 0.4898]}, {"w": "is", "b": [0.7736, 0.4702, 0.7857, 0.4898]}, {"w": "penalized", "b": [0.2714, 0.4876, 0.3444, 0.5072]}, {"w": "compared", "b": [0.3515, 0.4876, 0.428, 0.5072]}, {"w": "to", "b": [0.4351, 0.4876, 0.4507, 0.5072]}, {"w": "the", "b": [0.4578, 0.4876, 0.4818, 0.5072]}, {"w": "validation", "b": [0.4889, 0.4876, 0.5651, 0.5072]}, {"w": "loss,", "b": [0.5722, 0.4876, 0.6051, 0.5072]}, {"w": "so", "b": [0.6122, 0.4876, 0.6289, 0.5072]}, {"w": "comparing", "b": [0.636, 0.4876, 0.7189, 0.5072]}, {"w": "the", "b": [0.726, 0.4876, 0.7501, 0.5072]}, {"w": "two", "b": [0.7572, 0.4876, 0.7857, 0.5072]}, {"w": "can", "b": [0.2714, 0.505, 0.2983, 0.5246]}, {"w": "be", "b": [0.3058, 0.505, 0.3236, 0.5246]}, {"w": "misleading.", "b": [0.3312, 0.505, 0.419, 0.5246]}, {"w": "In", "b": [0.4266, 0.505, 0.4435, 0.5246]}, {"w": "particular,", "b": [0.451, 0.505, 0.5289, 0.5246]}, {"w": "a", "b": [0.5365, 0.505, 0.5449, 0.5246]}, {"w": "model", "b": [0.5524, 0.505, 0.6007, 0.5246]}, {"w": "may", "b": [0.6083, 0.505, 0.6407, 0.5246]}, {"w": "be", "b": [0.6482, 0.505, 0.666, 0.5246]}, {"w": "overfitting", "b": [0.6736, 0.505, 0.7541, 0.5246]}, {"w": "the", "b": [0.7616, 0.505, 0.7857, 0.5246]}, {"w": "training", "b": [0.2714, 0.5224, 0.3326, 0.542]}, {"w": "set", "b": [0.3386, 0.5224, 0.3595, 0.542]}, {"w": "and", "b": [0.3654, 0.5224, 0.3943, 0.542]}, {"w": "yet", "b": [0.4002, 0.5224, 0.4229, 0.542]}, {"w": "have", "b": [0.4288, 0.5224, 0.4639, 0.542]}, {"w": "similar", "b": [0.4699, 0.5224, 0.523, 0.542]}, {"w": "training", "b": [0.5289, 0.5224, 0.5901, 0.542]}, {"w": "and", "b": [0.5961, 0.5224, 0.6249, 0.542]}, {"w": "validation", "b": [0.6309, 0.5224, 0.7071, 0.542]}, {"w": "losses.", "b": [0.7131, 0.5224, 0.761, 0.542]}, {"w": "So", "b": [0.767, 0.5224, 0.7857, 0.542]}, {"w": "make", "b": [0.2714, 0.5399, 0.3129, 0.5594]}, {"w": "sure", "b": [0.3184, 0.5399, 0.3507, 0.5594]}, {"w": "to", "b": [0.3562, 0.5399, 0.3718, 0.5594]}, {"w": "evaluate", "b": [0.3773, 0.5399, 0.4394, 0.5594]}, {"w": "the", "b": [0.4449, 0.5399, 0.469, 0.5594]}, {"w": "training", "b": [0.4745, 0.5399, 0.5357, 0.5594]}, {"w": "loss", "b": [0.5413, 0.5399, 0.5698, 0.5594]}, {"w": "without", "b": [0.5753, 0.5399, 0.6351, 0.5594]}, {"w": "dropout", "b": [0.6406, 0.5399, 0.7031, 0.5594]}, {"w": "(e.g.,", "b": [0.7086, 0.5399, 0.7452, 0.5594]}, {"w": "after", "b": [0.7507, 0.5399, 0.7857, 0.5594]}, {"w": "training).", "b": [0.2714, 0.5581, 0.3435, 0.5777]}, {"w": "Alternatively,", "b": [0.352, 0.5581, 0.4537, 0.5777]}, {"w": "you", "b": [0.4622, 0.5581, 0.4907, 0.5777]}, {"w": "can", "b": [0.4992, 0.5581, 0.526, 0.5777]}, {"w": "call", "b": [0.5345, 0.5581, 0.5605, 0.5777]}, {"w": "the", "b": [0.569, 0.5581, 0.5931, 0.5777]}, {"w": "fit()", "b": [0.6015, 0.561, 0.6468, 0.5748]}, {"w": "method", "b": [0.6552, 0.5581, 0.7147, 0.5777]}, {"w": "inside", "b": [0.7231, 0.5581, 0.7689, 0.5777]}, {"w": "a", "b": [0.7773, 0.5581, 0.7857, 0.5777]}, {"w": "with", "b": [0.2714, 0.5792, 0.3076, 0.593]}, {"w": "keras.backend.learning_phase_scope(1)", "b": [0.3213, 0.5792, 0.6561, 0.593]}, {"w": "block:", "b": [0.6653, 0.5763, 0.7114, 0.5959]}, {"w": "this", "b": [0.7206, 0.5763, 0.7487, 0.5959]}, {"w": "will", "b": [0.7579, 0.5763, 0.7857, 0.5959]}, {"w": "force", "b": [0.2714, 0.5937, 0.31, 0.6133]}, {"w": "dropout", "b": [0.3143, 0.5937, 0.3768, 0.6133]}, {"w": "to", "b": [0.3811, 0.5937, 0.3966, 0.6133]}, {"w": "be", "b": [0.4009, 0.5937, 0.4187, 0.6133]}, {"w": "active", "b": [0.423, 0.5937, 0.4673, 0.6133]}, {"w": "during", "b": [0.4716, 0.5937, 0.5233, 0.6133]}, {"w": "both", "b": [0.5276, 0.5937, 0.563, 0.6133]}, {"w": "training", "b": [0.5673, 0.5937, 0.6285, 0.6133]}, {"w": "and", "b": [0.6328, 0.5937, 0.6617, 0.6133]}, {"w": "validation.25", "b": [0.666, 0.5937, 0.758, 0.6133]}]}, {"id": "b_5", "type": "paragraph", "text": "If you observe that the model is overfitting, you can increase the dropout rate. Con‐ versely, you should try decreasing the dropout rate if the model underfits the training set. It can also help to increase the dropout rate for large layers, and reduce it for small ones. Moreover, many state-of-the-art architectures only use dropout after the last hidden layer, so you may want to try this if full dropout is too strong.", "words": [{"w": "If", "b": [0.1429, 0.6336, 0.1561, 0.655]}, {"w": "you", "b": [0.1622, 0.6336, 0.1934, 0.655]}, {"w": "observe", "b": [0.1994, 0.6336, 0.264, 0.655]}, {"w": "that", "b": [0.27, 0.6336, 0.3026, 0.655]}, {"w": "the", "b": [0.3086, 0.6336, 0.335, 0.655]}, {"w": "model", "b": [0.341, 0.6336, 0.3938, 0.655]}, {"w": "is", "b": [0.3998, 0.6336, 0.4131, 0.655]}, {"w": "overfitting,", "b": [0.4191, 0.6336, 0.5119, 0.655]}, {"w": "you", "b": [0.5179, 0.6336, 0.5492, 0.655]}, {"w": "can", "b": [0.5552, 0.6336, 0.5846, 0.655]}, {"w": "increase", "b": [0.5906, 0.6336, 0.6586, 0.655]}, {"w": "the", "b": [0.6647, 0.6336, 0.691, 0.655]}, {"w": "dropout", "b": [0.697, 0.6336, 0.7653, 0.655]}, {"w": "rate.", "b": [0.7714, 0.6336, 0.8078, 0.655]}, {"w": "Con‐", "b": [0.8138, 0.6336, 0.8571, 0.655]}, {"w": "versely,", "b": [0.1428, 0.6527, 0.2036, 0.6741]}, {"w": "you", "b": [0.2087, 0.6527, 0.24, 0.6741]}, {"w": "should", "b": [0.2451, 0.6527, 0.3018, 0.6741]}, {"w": "try", "b": [0.3069, 0.6527, 0.3311, 0.6741]}, {"w": "decreasing", "b": [0.3362, 0.6527, 0.425, 0.6741]}, {"w": "the", "b": [0.4301, 0.6527, 0.4564, 0.6741]}, {"w": "dropout", "b": [0.4615, 0.6527, 0.5298, 0.6741]}, {"w": "rate", "b": [0.5349, 0.6527, 0.5666, 0.6741]}, {"w": "if", "b": [0.5717, 0.6527, 0.5835, 0.6741]}, {"w": "the", "b": [0.5886, 0.6527, 0.6149, 0.6741]}, {"w": "model", "b": [0.62, 0.6527, 0.6728, 0.6741]}, {"w": "underfits", "b": [0.6779, 0.6527, 0.7537, 0.6741]}, {"w": "the", "b": [0.7588, 0.6527, 0.7851, 0.6741]}, {"w": "training", "b": [0.7902, 0.6527, 0.8571, 0.6741]}, {"w": "set.", "b": [0.1429, 0.6717, 0.1705, 0.6931]}, {"w": "It", "b": [0.1781, 0.6717, 0.1908, 0.6931]}, {"w": "can", "b": [0.1984, 0.6717, 0.2278, 0.6931]}, {"w": "also", "b": [0.2354, 0.6717, 0.2681, 0.6931]}, {"w": "help", "b": [0.2757, 0.6717, 0.3119, 0.6931]}, {"w": "to", "b": [0.3196, 0.6717, 0.3365, 0.6931]}, {"w": "increase", "b": [0.3442, 0.6717, 0.4122, 0.6931]}, {"w": "the", "b": [0.4198, 0.6717, 0.4462, 0.6931]}, {"w": "dropout", "b": [0.4538, 0.6717, 0.5221, 0.6931]}, {"w": "rate", "b": [0.5298, 0.6717, 0.5615, 0.6931]}, {"w": "for", "b": [0.5691, 0.6717, 0.5936, 0.6931]}, {"w": "large", "b": [0.6013, 0.6717, 0.642, 0.6931]}, {"w": "layers,", "b": [0.6497, 0.6717, 0.7023, 0.6931]}, {"w": "and", "b": [0.7099, 0.6717, 0.7414, 0.6931]}, {"w": "reduce", "b": [0.7491, 0.6717, 0.8054, 0.6931]}, {"w": "it", "b": [0.813, 0.6717, 0.825, 0.6931]}, {"w": "for", "b": [0.8326, 0.6717, 0.8572, 0.6931]}, {"w": "small", "b": [0.1429, 0.6907, 0.1873, 0.7122]}, {"w": "ones.", "b": [0.1935, 0.6907, 0.2368, 0.7122]}, {"w": "Moreover,", "b": [0.243, 0.6907, 0.3285, 0.7122]}, {"w": "many", "b": [0.3348, 0.6907, 0.3815, 0.7122]}, {"w": "state-of-the-art", "b": [0.3877, 0.6907, 0.5143, 0.7122]}, {"w": "architectures", "b": [0.5205, 0.6907, 0.6286, 0.7122]}, {"w": "only", "b": [0.6348, 0.6907, 0.6717, 0.7122]}, {"w": "use", "b": [0.6779, 0.6907, 0.7055, 0.7122]}, {"w": "dropout", "b": [0.7118, 0.6907, 0.7801, 0.7122]}, {"w": "after", "b": [0.7863, 0.6907, 0.8246, 0.7122]}, {"w": "the", "b": [0.8308, 0.6907, 0.8571, 0.7122]}, {"w": "last", "b": [0.1429, 0.7098, 0.1713, 0.7312]}, {"w": "hidden", "b": [0.176, 0.7098, 0.235, 0.7312]}, {"w": "layer,", "b": [0.2397, 0.7098, 0.2833, 0.7312]}, {"w": "so", "b": [0.288, 0.7098, 0.3063, 0.7312]}, {"w": "you", "b": [0.311, 0.7098, 0.3423, 0.7312]}, {"w": "may", "b": [0.347, 0.7098, 0.3824, 0.7312]}, {"w": "want", "b": [0.3871, 0.7098, 0.4279, 0.7312]}, {"w": "to", "b": [0.4326, 0.7098, 0.4496, 0.7312]}, {"w": "try", "b": [0.4544, 0.7098, 0.4786, 0.7312]}, {"w": "this", "b": [0.4833, 0.7098, 0.514, 0.7312]}, {"w": "if", "b": [0.5188, 0.7098, 0.5305, 0.7312]}, {"w": "full", "b": [0.5352, 0.7098, 0.563, 0.7312]}, {"w": "dropout", "b": [0.5677, 0.7098, 0.6361, 0.7312]}, {"w": "is", "b": [0.6408, 0.7098, 0.654, 0.7312]}, {"w": "too", "b": [0.6587, 0.7098, 0.6864, 0.7312]}, {"w": "strong.", "b": [0.6911, 0.7098, 0.7493, 0.7312]}]}, {"id": "b_6", "type": "paragraph", "text": "Dropout does tend to significantly slow down convergence, but it usually results in a much better model when tuned properly. So, it is generally well worth the extra time and effort.", "words": [{"w": "Dropout", "b": [0.1429, 0.7379, 0.2155, 0.7593]}, {"w": "does", "b": [0.2211, 0.7379, 0.2592, 0.7593]}, {"w": "tend", "b": [0.2649, 0.7379, 0.3025, 0.7593]}, {"w": "to", "b": [0.3081, 0.7379, 0.3251, 0.7593]}, {"w": "significantly", "b": [0.3308, 0.7379, 0.4326, 0.7593]}, {"w": "slow", "b": [0.4383, 0.7379, 0.4761, 0.7593]}, {"w": "down", "b": [0.4817, 0.7379, 0.529, 0.7593]}, {"w": "convergence,", "b": [0.5346, 0.7379, 0.6436, 0.7593]}, {"w": "but", "b": [0.6493, 0.7379, 0.6773, 0.7593]}, {"w": "it", "b": [0.6829, 0.7379, 0.6949, 0.7593]}, {"w": "usually", "b": [0.7005, 0.7379, 0.7595, 0.7593]}, {"w": "results", "b": [0.7652, 0.7379, 0.8197, 0.7593]}, {"w": "in", "b": [0.8254, 0.7379, 0.8424, 0.7593]}, {"w": "a", "b": [0.848, 0.7379, 0.8571, 0.7593]}, {"w": "much", "b": [0.1429, 0.757, 0.1905, 0.7784]}, {"w": "better", "b": [0.1963, 0.757, 0.245, 0.7784]}, {"w": "model", "b": [0.2508, 0.757, 0.3036, 0.7784]}, {"w": "when", "b": [0.3093, 0.757, 0.355, 0.7784]}, {"w": "tuned", "b": [0.3607, 0.757, 0.4094, 0.7784]}, {"w": "properly.", "b": [0.4151, 0.757, 0.4899, 0.7784]}, {"w": "So,", "b": [0.4957, 0.757, 0.5203, 0.7784]}, {"w": "it", "b": [0.5261, 0.757, 0.538, 0.7784]}, {"w": "is", "b": [0.5438, 0.757, 0.557, 0.7784]}, {"w": "generally", "b": [0.5627, 0.757, 0.6386, 0.7784]}, {"w": "well", "b": [0.6443, 0.757, 0.678, 0.7784]}, {"w": "worth", "b": [0.6837, 0.757, 0.7338, 0.7784]}, {"w": "the", "b": [0.7396, 0.757, 0.7659, 0.7784]}, {"w": "extra", "b": [0.7716, 0.757, 0.8136, 0.7784]}, {"w": "time", "b": [0.8193, 0.757, 0.8572, 0.7784]}, {"w": "and", "b": [0.1429, 0.776, 0.1744, 0.7974]}, {"w": "effort.", "b": [0.1791, 0.776, 0.2298, 0.7974]}]}, {"id": "b_7", "type": "paragraph", "text": "Avoiding Overfitting Through Regularization | 359", "words": [{"w": "Avoiding", "b": [0.5348, 0.9225, 0.587, 0.9388]}, {"w": "Overfitting", "b": [0.5899, 0.9225, 0.6541, 0.9388]}, {"w": "Through", "b": [0.657, 0.9225, 0.7066, 0.9388]}, {"w": "Regularization", "b": [0.7094, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "359", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 386, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "26 “Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning,” Y. Gal and Z. Ghahramani (2016).", "words": [{"w": "26", "b": [0.1385, 0.8265, 0.1518, 0.8408]}, {"w": "“Dropout", "b": [0.1587, 0.825, 0.2204, 0.8413]}, {"w": "as", "b": [0.224, 0.825, 0.2368, 0.8413]}, {"w": "a", "b": [0.2404, 0.825, 0.2473, 0.8413]}, {"w": "Bayesian", "b": [0.251, 0.825, 0.3067, 0.8413]}, {"w": "Approximation:", "b": [0.3103, 0.825, 0.4122, 0.8413]}, {"w": "Representing", "b": [0.4158, 0.825, 0.4995, 0.8413]}, {"w": "Model", "b": [0.5031, 0.825, 0.5441, 0.8413]}, {"w": "Uncertainty", "b": [0.5477, 0.825, 0.6233, 0.8413]}, {"w": "in", "b": [0.6269, 0.825, 0.6398, 0.8413]}, {"w": "Deep", "b": [0.6434, 0.825, 0.6769, 0.8413]}, {"w": "Learning,”", "b": [0.6805, 0.825, 0.7455, 0.8413]}, {"w": "Y.", "b": [0.7491, 0.825, 0.7609, 0.8413]}, {"w": "Gal", "b": [0.7645, 0.825, 0.7869, 0.8413]}, {"w": "and", "b": [0.7905, 0.825, 0.8145, 0.8413]}, {"w": "Z.", "b": [0.8181, 0.825, 0.8313, 0.8413]}, {"w": "Ghahramani", "b": [0.1587, 0.8401, 0.2398, 0.8565]}, {"w": "(2016).", "b": [0.2434, 0.8401, 0.2884, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "27 Specifically, they show that training a dropout network is mathematically equivalent to approximate Bayesian inference in a specific type of probabilistic model called a deep Gaussian Process.", "words": [{"w": "27", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "Specifically,", "b": [0.1587, 0.8598, 0.2327, 0.8761]}, {"w": "they", "b": [0.2363, 0.8598, 0.2637, 0.8761]}, {"w": "show", "b": [0.2673, 0.8598, 0.3005, 0.8761]}, {"w": "that", "b": [0.3041, 0.8598, 0.329, 0.8761]}, {"w": "training", "b": [0.3326, 0.8598, 0.3836, 0.8761]}, {"w": "a", "b": [0.3872, 0.8598, 0.3941, 0.8761]}, {"w": "dropout", "b": [0.3977, 0.8598, 0.4498, 0.8761]}, {"w": "network", "b": [0.4534, 0.8598, 0.5064, 0.8761]}, {"w": "is", "b": [0.51, 0.8598, 0.5201, 0.8761]}, {"w": "mathematically", "b": [0.5237, 0.8598, 0.6212, 0.8761]}, {"w": "equivalent", "b": [0.6248, 0.8598, 0.6906, 0.8761]}, {"w": "to", "b": [0.6942, 0.8598, 0.7071, 0.8761]}, {"w": "approximate", "b": [0.7107, 0.8598, 0.791, 0.8761]}, {"w": "Bayesian", "b": [0.7946, 0.8598, 0.8504, 0.8761]}, {"w": "inference", "b": [0.1587, 0.8749, 0.2179, 0.8912]}, {"w": "in", "b": [0.2215, 0.8749, 0.2344, 0.8912]}, {"w": "a", "b": [0.238, 0.8749, 0.245, 0.8912]}, {"w": "specific", "b": [0.2486, 0.8749, 0.2961, 0.8912]}, {"w": "type", "b": [0.2997, 0.8749, 0.3269, 0.8912]}, {"w": "of", "b": [0.3305, 0.8749, 0.3433, 0.8912]}, {"w": "probabilistic", "b": [0.3469, 0.8749, 0.4265, 0.8912]}, {"w": "model", "b": [0.4301, 0.8749, 0.4703, 0.8912]}, {"w": "called", "b": [0.4739, 0.8749, 0.5108, 0.8912]}, {"w": "a", "b": [0.5144, 0.8749, 0.5213, 0.8912]}, {"w": "deep", "b": [0.5249, 0.8748, 0.5532, 0.8912]}, {"w": "Gaussian", "b": [0.5568, 0.8748, 0.6144, 0.8912]}, {"w": "Process.", "b": [0.618, 0.8748, 0.666, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "If you want to regularize a self-normalizing network based on the SELU activation function (as discussed earlier), you should use AlphaDropout: this is a variant of dropout that preserves the mean and standard deviation of its inputs (it was introduced in the same paper as SELU, as regular dropout would break self-normalization).", "words": [{"w": "If", "b": [0.2714, 0.0793, 0.2835, 0.0989]}, {"w": "you", "b": [0.2895, 0.0793, 0.3181, 0.0989]}, {"w": "want", "b": [0.3241, 0.0793, 0.3614, 0.0989]}, {"w": "to", "b": [0.3674, 0.0793, 0.3829, 0.0989]}, {"w": "regularize", "b": [0.3889, 0.0793, 0.4645, 0.0989]}, {"w": "a", "b": [0.4705, 0.0793, 0.4789, 0.0989]}, {"w": "self-normalizing", "b": [0.4849, 0.0793, 0.6107, 0.0989]}, {"w": "network", "b": [0.6167, 0.0793, 0.6803, 0.0989]}, {"w": "based", "b": [0.6863, 0.0793, 0.7295, 0.0989]}, {"w": "on", "b": [0.7355, 0.0793, 0.7556, 0.0989]}, {"w": "the", "b": [0.7616, 0.0793, 0.7857, 0.0989]}, {"w": "SELU", "b": [0.2714, 0.0967, 0.3148, 0.1163]}, {"w": "activation", "b": [0.3236, 0.0967, 0.3988, 0.1163]}, {"w": "function", "b": [0.4077, 0.0967, 0.473, 0.1163]}, {"w": "(as", "b": [0.4818, 0.0967, 0.5038, 0.1163]}, {"w": "discussed", "b": [0.5126, 0.0967, 0.5851, 0.1163]}, {"w": "earlier),", "b": [0.594, 0.0967, 0.6535, 0.1163]}, {"w": "you", "b": [0.6624, 0.0967, 0.6909, 0.1163]}, {"w": "should", "b": [0.6998, 0.0967, 0.7517, 0.1163]}, {"w": "use", "b": [0.7605, 0.0967, 0.7857, 0.1163]}, {"w": "AlphaDropout:", "b": [0.2714, 0.1149, 0.3843, 0.1345]}, {"w": "this", "b": [0.3897, 0.1149, 0.4177, 0.1345]}, {"w": "is", "b": [0.4231, 0.1149, 0.4352, 0.1345]}, {"w": "a", "b": [0.4405, 0.1149, 0.4489, 0.1345]}, {"w": "variant", "b": [0.4542, 0.1149, 0.5078, 0.1345]}, {"w": "of", "b": [0.5131, 0.1149, 0.5285, 0.1345]}, {"w": "dropout", "b": [0.5338, 0.1149, 0.5963, 0.1345]}, {"w": "that", "b": [0.6016, 0.1149, 0.6314, 0.1345]}, {"w": "preserves", "b": [0.6367, 0.1149, 0.7085, 0.1345]}, {"w": "the", "b": [0.7138, 0.1149, 0.7379, 0.1345]}, {"w": "mean", "b": [0.7432, 0.1149, 0.7857, 0.1345]}, {"w": "and", "b": [0.2714, 0.1323, 0.3003, 0.1519]}, {"w": "standard", "b": [0.3055, 0.1323, 0.3726, 0.1519]}, {"w": "deviation", "b": [0.3778, 0.1323, 0.4489, 0.1519]}, {"w": "of", "b": [0.4541, 0.1323, 0.4695, 0.1519]}, {"w": "its", "b": [0.4747, 0.1323, 0.4926, 0.1519]}, {"w": "inputs", "b": [0.4978, 0.1323, 0.5458, 0.1519]}, {"w": "(it", "b": [0.551, 0.1323, 0.5685, 0.1519]}, {"w": "was", "b": [0.5737, 0.1323, 0.6021, 0.1519]}, {"w": "introduced", "b": [0.6073, 0.1323, 0.6915, 0.1519]}, {"w": "in", "b": [0.6967, 0.1323, 0.7122, 0.1519]}, {"w": "the", "b": [0.7174, 0.1323, 0.7415, 0.1519]}, {"w": "same", "b": [0.7467, 0.1323, 0.7857, 0.1519]}, {"w": "paper", "b": [0.2714, 0.1498, 0.3145, 0.1693]}, {"w": "as", "b": [0.3189, 0.1498, 0.3342, 0.1693]}, {"w": "SELU,", "b": [0.3385, 0.1498, 0.3848, 0.1693]}, {"w": "as", "b": [0.3891, 0.1498, 0.4045, 0.1693]}, {"w": "regular", "b": [0.4088, 0.1498, 0.4632, 0.1693]}, {"w": "dropout", "b": [0.4676, 0.1498, 0.53, 0.1693]}, {"w": "would", "b": [0.5344, 0.1498, 0.5821, 0.1693]}, {"w": "break", "b": [0.5864, 0.1498, 0.6291, 0.1693]}, {"w": "self-normalization).", "b": [0.6334, 0.1498, 0.7848, 0.1693]}]}, {"id": "b_3", "type": "equation", "text": "Monte-Carlo (MC) Dropout", "words": [{"w": "Monte-Carlo", "b": [0.1428, 0.1869, 0.2707, 0.2154]}, {"w": "(MC)", "b": [0.2756, 0.1869, 0.3231, 0.2154]}, {"w": "Dropout", "b": [0.3281, 0.1869, 0.4126, 0.2154]}]}, {"id": "b_4", "type": "paragraph", "text": "In 2016, a paper26 by Yarin Gal and Zoubin Ghahramani added more good reasons to use dropout:", "words": [{"w": "In", "b": [0.1428, 0.2213, 0.1613, 0.2428]}, {"w": "2016,", "b": [0.1665, 0.2213, 0.2113, 0.2428]}, {"w": "a", "b": [0.2164, 0.2213, 0.2256, 0.2428]}, {"w": "paper26", "b": [0.2307, 0.2213, 0.2893, 0.2428]}, {"w": "by", "b": [0.2945, 0.2213, 0.3146, 0.2428]}, {"w": "Yarin", "b": [0.3198, 0.2213, 0.3644, 0.2428]}, {"w": "Gal", "b": [0.3696, 0.2213, 0.3989, 0.2428]}, {"w": "and", "b": [0.4041, 0.2213, 0.4356, 0.2428]}, {"w": "Zoubin", "b": [0.4407, 0.2213, 0.5026, 0.2428]}, {"w": "Ghahramani", "b": [0.5077, 0.2213, 0.6141, 0.2428]}, {"w": "added", "b": [0.6192, 0.2213, 0.6702, 0.2428]}, {"w": "more", "b": [0.6754, 0.2213, 0.7197, 0.2428]}, {"w": "good", "b": [0.7248, 0.2213, 0.7668, 0.2428]}, {"w": "reasons", "b": [0.772, 0.2213, 0.835, 0.2428]}, {"w": "to", "b": [0.8402, 0.2213, 0.8571, 0.2428]}, {"w": "use", "b": [0.1429, 0.2404, 0.1704, 0.2618]}, {"w": "dropout:", "b": [0.1752, 0.2404, 0.2482, 0.2618]}]}, {"id": "b_5", "type": "paragraph", "text": "• First, the paper establishes a profound connection between dropout networks (i.e., neural networks containing a dropout layer before every weight layer) and approximate Bayesian inference27, giving dropout a solid mathematical justifica‐ tion.", "words": [{"w": "•", "b": [0.16, 0.2746, 0.1682, 0.296]}, {"w": "First,", "b": [0.1786, 0.2746, 0.2216, 0.296]}, {"w": "the", "b": [0.2301, 0.2746, 0.2564, 0.296]}, {"w": "paper", "b": [0.2649, 0.2746, 0.3121, 0.296]}, {"w": "establishes", "b": [0.3205, 0.2746, 0.4092, 0.296]}, {"w": "a", "b": [0.4177, 0.2746, 0.4268, 0.296]}, {"w": "profound", "b": [0.4353, 0.2746, 0.5148, 0.296]}, {"w": "connection", "b": [0.5232, 0.2746, 0.6171, 0.296]}, {"w": "between", "b": [0.6255, 0.2746, 0.6947, 0.296]}, {"w": "dropout", "b": [0.7032, 0.2746, 0.7715, 0.296]}, {"w": "networks", "b": [0.7799, 0.2746, 0.8571, 0.296]}, {"w": "(i.e.,", "b": [0.1786, 0.2936, 0.2145, 0.315]}, {"w": "neural", "b": [0.221, 0.2936, 0.2745, 0.315]}, {"w": "networks", "b": [0.2811, 0.2936, 0.3583, 0.315]}, {"w": "containing", "b": [0.3648, 0.2936, 0.4545, 0.315]}, {"w": "a", "b": [0.461, 0.2936, 0.4702, 0.315]}, {"w": "dropout", "b": [0.4767, 0.2936, 0.545, 0.315]}, {"w": "layer", "b": [0.5516, 0.2936, 0.5918, 0.315]}, {"w": "before", "b": [0.5984, 0.2936, 0.6512, 0.315]}, {"w": "every", "b": [0.6577, 0.2936, 0.703, 0.315]}, {"w": "weight", "b": [0.7095, 0.2936, 0.7651, 0.315]}, {"w": "layer)", "b": [0.7716, 0.2936, 0.819, 0.315]}, {"w": "and", "b": [0.8256, 0.2936, 0.8571, 0.315]}, {"w": "approximate", "b": [0.1786, 0.3127, 0.2839, 0.3341]}, {"w": "Bayesian", "b": [0.2903, 0.3127, 0.3635, 0.3341]}, {"w": "inference27,", "b": [0.3698, 0.3127, 0.4636, 0.3341]}, {"w": "giving", "b": [0.47, 0.3127, 0.5217, 0.3341]}, {"w": "dropout", "b": [0.528, 0.3127, 0.5963, 0.3341]}, {"w": "a", "b": [0.6027, 0.3127, 0.6118, 0.3341]}, {"w": "solid", "b": [0.6181, 0.3127, 0.6583, 0.3341]}, {"w": "mathematical", "b": [0.6646, 0.3127, 0.7777, 0.3341]}, {"w": "justifica‐", "b": [0.784, 0.3127, 0.8571, 0.3341]}, {"w": "tion.", "b": [0.1786, 0.3317, 0.2173, 0.3531]}]}, {"id": "b_6", "type": "paragraph", "text": "• Second, they introduce a powerful technique called MC Dropout, which can boost the performance of any trained dropout model, without having to retrain it or even modify it at all!", "words": [{"w": "•", "b": [0.16, 0.3568, 0.1682, 0.3782]}, {"w": "Second,", "b": [0.1786, 0.3568, 0.2439, 0.3782]}, {"w": "they", "b": [0.2535, 0.3568, 0.2894, 0.3782]}, {"w": "introduce", "b": [0.2991, 0.3568, 0.3801, 0.3782]}, {"w": "a", "b": [0.3898, 0.3568, 0.3989, 0.3782]}, {"w": "powerful", "b": [0.4086, 0.3568, 0.4834, 0.3782]}, {"w": "technique", "b": [0.4931, 0.3568, 0.5758, 0.3782]}, {"w": "called", "b": [0.5854, 0.3568, 0.6338, 0.3782]}, {"w": "MC", "b": [0.6434, 0.3566, 0.6746, 0.3782]}, {"w": "Dropout,", "b": [0.6843, 0.3566, 0.7576, 0.3782]}, {"w": "which", "b": [0.7672, 0.3568, 0.8181, 0.3782]}, {"w": "can", "b": [0.8278, 0.3568, 0.8571, 0.3782]}, {"w": "boost", "b": [0.1786, 0.3758, 0.2244, 0.3973]}, {"w": "the", "b": [0.2294, 0.3758, 0.2557, 0.3973]}, {"w": "performance", "b": [0.2606, 0.3758, 0.3679, 0.3973]}, {"w": "of", "b": [0.3729, 0.3758, 0.3897, 0.3973]}, {"w": "any", "b": [0.3946, 0.3758, 0.4243, 0.3973]}, {"w": "trained", "b": [0.4292, 0.3758, 0.4893, 0.3973]}, {"w": "dropout", "b": [0.4942, 0.3758, 0.5625, 0.3973]}, {"w": "model,", "b": [0.5675, 0.3758, 0.625, 0.3973]}, {"w": "without", "b": [0.63, 0.3758, 0.6954, 0.3973]}, {"w": "having", "b": [0.7003, 0.3758, 0.7566, 0.3973]}, {"w": "to", "b": [0.7615, 0.3758, 0.7785, 0.3973]}, {"w": "retrain", "b": [0.7835, 0.3758, 0.8403, 0.3973]}, {"w": "it", "b": [0.8452, 0.3758, 0.8571, 0.3973]}, {"w": "or", "b": [0.1786, 0.3949, 0.1969, 0.4163]}, {"w": "even", "b": [0.2016, 0.3949, 0.2404, 0.4163]}, {"w": "modify", "b": [0.2451, 0.3949, 0.3055, 0.4163]}, {"w": "it", "b": [0.3102, 0.3949, 0.3221, 0.4163]}, {"w": "at", "b": [0.3269, 0.3949, 0.342, 0.4163]}, {"w": "all!", "b": [0.3467, 0.3949, 0.3721, 0.4163]}]}, {"id": "b_7", "type": "paragraph", "text": "• Moreover, MC Dropout also provides a much better measure of the model’s uncertainty.", "words": [{"w": "•", "b": [0.16, 0.42, 0.1682, 0.4414]}, {"w": "Moreover,", "b": [0.1786, 0.42, 0.2641, 0.4414]}, {"w": "MC", "b": [0.2733, 0.42, 0.3058, 0.4414]}, {"w": "Dropout", "b": [0.315, 0.42, 0.3876, 0.4414]}, {"w": "also", "b": [0.3969, 0.42, 0.4296, 0.4414]}, {"w": "provides", "b": [0.4388, 0.42, 0.5108, 0.4414]}, {"w": "a", "b": [0.5201, 0.42, 0.5292, 0.4414]}, {"w": "much", "b": [0.5384, 0.42, 0.5861, 0.4414]}, {"w": "better", "b": [0.5954, 0.42, 0.6441, 0.4414]}, {"w": "measure", "b": [0.6533, 0.42, 0.7237, 0.4414]}, {"w": "of", "b": [0.7329, 0.42, 0.7497, 0.4414]}, {"w": "the", "b": [0.759, 0.42, 0.7853, 0.4414]}, {"w": "model’s", "b": [0.7946, 0.42, 0.8571, 0.4414]}, {"w": "uncertainty.", "b": [0.1786, 0.439, 0.2777, 0.4604]}]}, {"id": "b_8", "type": "paragraph", "text": "• Finally, it is also amazingly simple to implement. If this all sounds like a “one weird trick” advertisement, then take a look at the following code. It is the full implementation of MC Dropout, boosting the dropout model we trained earlier, without retraining it:", "words": [{"w": "•", "b": [0.16, 0.4641, 0.1682, 0.4855]}, {"w": "Finally,", "b": [0.1786, 0.4641, 0.239, 0.4855]}, {"w": "it", "b": [0.2467, 0.4641, 0.2587, 0.4855]}, {"w": "is", "b": [0.2664, 0.4641, 0.2796, 0.4855]}, {"w": "also", "b": [0.2873, 0.4641, 0.32, 0.4855]}, {"w": "amazingly", "b": [0.3277, 0.4641, 0.4133, 0.4855]}, {"w": "simple", "b": [0.421, 0.4641, 0.476, 0.4855]}, {"w": "to", "b": [0.4836, 0.4641, 0.5006, 0.4855]}, {"w": "implement.", "b": [0.5083, 0.4641, 0.6036, 0.4855]}, {"w": "If", "b": [0.6113, 0.4641, 0.6246, 0.4855]}, {"w": "this", "b": [0.6323, 0.4641, 0.663, 0.4855]}, {"w": "all", "b": [0.6707, 0.4641, 0.6904, 0.4855]}, {"w": "sounds", "b": [0.6981, 0.4641, 0.7574, 0.4855]}, {"w": "like", "b": [0.7651, 0.4641, 0.7952, 0.4855]}, {"w": "a", "b": [0.8029, 0.4641, 0.812, 0.4855]}, {"w": "“one", "b": [0.8197, 0.4641, 0.8571, 0.4855]}, {"w": "weird", "b": [0.1786, 0.4832, 0.226, 0.5046]}, {"w": "trick”", "b": [0.2331, 0.4832, 0.2794, 0.5046]}, {"w": "advertisement,", "b": [0.2865, 0.4832, 0.4093, 0.5046]}, {"w": "then", "b": [0.4164, 0.4832, 0.4541, 0.5046]}, {"w": "take", "b": [0.4612, 0.4832, 0.4959, 0.5046]}, {"w": "a", "b": [0.503, 0.4832, 0.5121, 0.5046]}, {"w": "look", "b": [0.5192, 0.4832, 0.5561, 0.5046]}, {"w": "at", "b": [0.5632, 0.4832, 0.5783, 0.5046]}, {"w": "the", "b": [0.5853, 0.4832, 0.6117, 0.5046]}, {"w": "following", "b": [0.6188, 0.4832, 0.6977, 0.5046]}, {"w": "code.", "b": [0.7048, 0.4832, 0.7488, 0.5046]}, {"w": "It", "b": [0.7559, 0.4832, 0.7686, 0.5046]}, {"w": "is", "b": [0.7756, 0.4832, 0.7889, 0.5046]}, {"w": "the", "b": [0.796, 0.4832, 0.8223, 0.5046]}, {"w": "full", "b": [0.8294, 0.4832, 0.8571, 0.5046]}, {"w": "implementation", "b": [0.1786, 0.5022, 0.3118, 0.5236]}, {"w": "of", "b": [0.3183, 0.5022, 0.335, 0.5236]}, {"w": "MC", "b": [0.3415, 0.502, 0.3726, 0.5236]}, {"w": "Dropout,", "b": [0.3791, 0.502, 0.4524, 0.5236]}, {"w": "boosting", "b": [0.4588, 0.5022, 0.5313, 0.5236]}, {"w": "the", "b": [0.5378, 0.5022, 0.5641, 0.5236]}, {"w": "dropout", "b": [0.5705, 0.5022, 0.6388, 0.5236]}, {"w": "model", "b": [0.6453, 0.5022, 0.6981, 0.5236]}, {"w": "we", "b": [0.7045, 0.5022, 0.7276, 0.5236]}, {"w": "trained", "b": [0.734, 0.5022, 0.7941, 0.5236]}, {"w": "earlier,", "b": [0.8005, 0.5022, 0.8571, 0.5236]}, {"w": "without", "b": [0.1786, 0.5213, 0.2439, 0.5427]}, {"w": "retraining", "b": [0.2487, 0.5213, 0.3322, 0.5427]}, {"w": "it:", "b": [0.3369, 0.5213, 0.3536, 0.5427]}]}, {"id": "b_9", "type": "paragraph", "text": "with keras.backend.learning_phase_scope(1): # force training mode = dropout on y_probas = np.stack([model.predict(X_test_scaled) for sample in range(100)]) y_proba = y_probas.mean(axis=0)", "words": [{"w": "with", "b": [0.1766, 0.5593, 0.2103, 0.5721]}, {"w": "keras.backend.learning_phase_scope(1):", "b": [0.2187, 0.5593, 0.5392, 0.5721]}, {"w": "#", "b": [0.5476, 0.5593, 0.556, 0.5721]}, {"w": "force", "b": [0.5645, 0.5593, 0.6066, 0.5721]}, {"w": "training", "b": [0.6151, 0.5593, 0.6825, 0.5721]}, {"w": "mode", "b": [0.691, 0.5593, 0.7247, 0.5721]}, {"w": "=", "b": [0.7331, 0.5593, 0.7416, 0.5721]}, {"w": "dropout", "b": [0.75, 0.5593, 0.809, 0.5721]}, {"w": "on", "b": [0.8175, 0.5593, 0.8343, 0.5721]}, {"w": "y_probas", "b": [0.2103, 0.5747, 0.2778, 0.5876]}, {"w": "=", "b": [0.2862, 0.5747, 0.2946, 0.5876]}, {"w": "np.stack([model.predict(X_test_scaled)", "b": [0.3031, 0.5747, 0.6235, 0.5876]}, {"w": "for", "b": [0.3874, 0.5901, 0.4127, 0.603]}, {"w": "sample", "b": [0.4211, 0.5901, 0.4717, 0.603]}, {"w": "in", "b": [0.4802, 0.5901, 0.497, 0.603]}, {"w": "range(100)])", "b": [0.5054, 0.5901, 0.6066, 0.603]}, {"w": "y_proba", "b": [0.1766, 0.6056, 0.2356, 0.6184]}, {"w": "=", "b": [0.244, 0.6056, 0.2525, 0.6184]}, {"w": "y_probas.mean(axis=0)", "b": [0.2609, 0.6056, 0.438, 0.6184]}]}, {"id": "b_10", "type": "paragraph", "text": "We first force training mode on, using a learning_phase_scope(1) context. This turns dropout on within the with block. Then we make 100 predictions over the test set, and we stack them. Since dropout is on, all predictions will be different. Recall that predict() returns a matrix with one row per instance, and one column per class. Since there are 10,000 instances in the test set, and 10 classes, this is a matrix of shape [10000, 10]. We stack 100 such matrices, so y_probas is an array of shape [100, 10000, 10]. Once we average over the first dimension (axis=0), we get y_proba, an array of shape [10000, 10], like we would get with a single prediction. That’s all! Averaging", "words": [{"w": "We", "b": [0.1429, 0.6271, 0.1699, 0.6485]}, {"w": "first", "b": [0.1784, 0.6271, 0.2118, 0.6485]}, {"w": "force", "b": [0.2203, 0.6271, 0.2625, 0.6485]}, {"w": "training", "b": [0.2709, 0.6271, 0.3378, 0.6485]}, {"w": "mode", "b": [0.3463, 0.6271, 0.3938, 0.6485]}, {"w": "on,", "b": [0.4022, 0.6271, 0.429, 0.6485]}, {"w": "using", "b": [0.4374, 0.6271, 0.4829, 0.6485]}, {"w": "a", "b": [0.4913, 0.6271, 0.5005, 0.6485]}, {"w": "learning_phase_scope(1)", "b": [0.5089, 0.6303, 0.7365, 0.6453]}, {"w": "context.", "b": [0.7449, 0.6271, 0.8115, 0.6485]}, {"w": "This", "b": [0.8199, 0.6271, 0.8571, 0.6485]}, {"w": "turns", "b": [0.1429, 0.647, 0.187, 0.6684]}, {"w": "dropout", "b": [0.1927, 0.647, 0.261, 0.6684]}, {"w": "on", "b": [0.2667, 0.647, 0.2887, 0.6684]}, {"w": "within", "b": [0.2944, 0.647, 0.3487, 0.6684]}, {"w": "the", "b": [0.3544, 0.647, 0.3807, 0.6684]}, {"w": "with", "b": [0.3864, 0.6502, 0.426, 0.6653]}, {"w": "block.", "b": [0.4317, 0.647, 0.4821, 0.6684]}, {"w": "Then", "b": [0.4877, 0.647, 0.532, 0.6684]}, {"w": "we", "b": [0.5376, 0.647, 0.5608, 0.6684]}, {"w": "make", "b": [0.5665, 0.647, 0.6118, 0.6684]}, {"w": "100", "b": [0.6175, 0.647, 0.6475, 0.6684]}, {"w": "predictions", "b": [0.6532, 0.647, 0.7477, 0.6684]}, {"w": "over", "b": [0.7534, 0.647, 0.7902, 0.6684]}, {"w": "the", "b": [0.7959, 0.647, 0.8223, 0.6684]}, {"w": "test", "b": [0.8279, 0.647, 0.8571, 0.6684]}, {"w": "set,", "b": [0.1429, 0.6661, 0.1705, 0.6875]}, {"w": "and", "b": [0.1775, 0.6661, 0.209, 0.6875]}, {"w": "we", "b": [0.216, 0.6661, 0.2391, 0.6875]}, {"w": "stack", "b": [0.2461, 0.6661, 0.2884, 0.6875]}, {"w": "them.", "b": [0.2954, 0.6661, 0.3436, 0.6875]}, {"w": "Since", "b": [0.3505, 0.6661, 0.3951, 0.6875]}, {"w": "dropout", "b": [0.4021, 0.6661, 0.4704, 0.6875]}, {"w": "is", "b": [0.4774, 0.6661, 0.4906, 0.6875]}, {"w": "on,", "b": [0.4976, 0.6661, 0.5244, 0.6875]}, {"w": "all", "b": [0.5314, 0.6661, 0.5511, 0.6875]}, {"w": "predictions", "b": [0.5581, 0.6661, 0.6526, 0.6875]}, {"w": "will", "b": [0.6596, 0.6661, 0.69, 0.6875]}, {"w": "be", "b": [0.697, 0.6661, 0.7164, 0.6875]}, {"w": "different.", "b": [0.7234, 0.6661, 0.7998, 0.6875]}, {"w": "Recall", "b": [0.8068, 0.6661, 0.8571, 0.6875]}, {"w": "that", "b": [0.1429, 0.686, 0.1754, 0.7074]}, {"w": "predict()", "b": [0.1803, 0.6892, 0.2693, 0.7043]}, {"w": "returns", "b": [0.2742, 0.686, 0.3349, 0.7074]}, {"w": "a", "b": [0.3398, 0.686, 0.3489, 0.7074]}, {"w": "matrix", "b": [0.3538, 0.686, 0.4091, 0.7074]}, {"w": "with", "b": [0.4139, 0.686, 0.4512, 0.7074]}, {"w": "one", "b": [0.4561, 0.686, 0.487, 0.7074]}, {"w": "row", "b": [0.4918, 0.686, 0.5244, 0.7074]}, {"w": "per", "b": [0.5293, 0.686, 0.5568, 0.7074]}, {"w": "instance,", "b": [0.5616, 0.686, 0.6355, 0.7074]}, {"w": "and", "b": [0.6404, 0.686, 0.6719, 0.7074]}, {"w": "one", "b": [0.6768, 0.686, 0.7076, 0.7074]}, {"w": "column", "b": [0.7125, 0.686, 0.7767, 0.7074]}, {"w": "per", "b": [0.7815, 0.686, 0.809, 0.7074]}, {"w": "class.", "b": [0.8139, 0.686, 0.8571, 0.7074]}, {"w": "Since", "b": [0.1428, 0.7051, 0.1874, 0.7265]}, {"w": "there", "b": [0.1924, 0.7051, 0.2353, 0.7265]}, {"w": "are", "b": [0.2404, 0.7051, 0.2661, 0.7265]}, {"w": "10,000", "b": [0.2711, 0.7051, 0.3259, 0.7265]}, {"w": "instances", "b": [0.3309, 0.7051, 0.4077, 0.7265]}, {"w": "in", "b": [0.4128, 0.7051, 0.4298, 0.7265]}, {"w": "the", "b": [0.4348, 0.7051, 0.4611, 0.7265]}, {"w": "test", "b": [0.4662, 0.7051, 0.4954, 0.7265]}, {"w": "set,", "b": [0.5004, 0.7051, 0.528, 0.7265]}, {"w": "and", "b": [0.533, 0.7051, 0.5646, 0.7265]}, {"w": "10", "b": [0.5696, 0.7051, 0.5896, 0.7265]}, {"w": "classes,", "b": [0.5947, 0.7051, 0.6544, 0.7265]}, {"w": "this", "b": [0.6595, 0.7051, 0.6902, 0.7265]}, {"w": "is", "b": [0.6952, 0.7051, 0.7084, 0.7265]}, {"w": "a", "b": [0.7135, 0.7051, 0.7226, 0.7265]}, {"w": "matrix", "b": [0.7277, 0.7051, 0.783, 0.7265]}, {"w": "of", "b": [0.788, 0.7051, 0.8048, 0.7265]}, {"w": "shape", "b": [0.8098, 0.7051, 0.8571, 0.7265]}, {"w": "[10000,", "b": [0.1429, 0.725, 0.2048, 0.7464]}, {"w": "10].", "b": [0.2095, 0.725, 0.2415, 0.7464]}, {"w": "We", "b": [0.2462, 0.725, 0.2733, 0.7464]}, {"w": "stack", "b": [0.278, 0.725, 0.3203, 0.7464]}, {"w": "100", "b": [0.325, 0.725, 0.355, 0.7464]}, {"w": "such", "b": [0.3597, 0.725, 0.3984, 0.7464]}, {"w": "matrices,", "b": [0.4031, 0.725, 0.4787, 0.7464]}, {"w": "so", "b": [0.4834, 0.725, 0.5017, 0.7464]}, {"w": "y_probas", "b": [0.5069, 0.7282, 0.5861, 0.7433]}, {"w": "is", "b": [0.5909, 0.725, 0.6041, 0.7464]}, {"w": "an", "b": [0.6088, 0.725, 0.6294, 0.7464]}, {"w": "array", "b": [0.6341, 0.725, 0.677, 0.7464]}, {"w": "of", "b": [0.6818, 0.725, 0.6986, 0.7464]}, {"w": "shape", "b": [0.7033, 0.725, 0.7506, 0.7464]}, {"w": "[100,", "b": [0.7553, 0.725, 0.7972, 0.7464]}, {"w": "10000,", "b": [0.802, 0.725, 0.8567, 0.7464]}, {"w": "10].", "b": [0.1429, 0.745, 0.1748, 0.7664]}, {"w": "Once", "b": [0.1809, 0.745, 0.2255, 0.7664]}, {"w": "we", "b": [0.2316, 0.745, 0.2547, 0.7664]}, {"w": "average", "b": [0.2608, 0.745, 0.3235, 0.7664]}, {"w": "over", "b": [0.3296, 0.745, 0.3665, 0.7664]}, {"w": "the", "b": [0.3725, 0.745, 0.3989, 0.7664]}, {"w": "first", "b": [0.405, 0.745, 0.4384, 0.7664]}, {"w": "dimension", "b": [0.4445, 0.745, 0.5337, 0.7664]}, {"w": "(axis=0),", "b": [0.5397, 0.745, 0.6183, 0.7664]}, {"w": "we", "b": [0.6244, 0.745, 0.6475, 0.7664]}, {"w": "get", "b": [0.6536, 0.745, 0.6785, 0.7664]}, {"w": "y_proba,", "b": [0.6846, 0.745, 0.7586, 0.7664]}, {"w": "an", "b": [0.7647, 0.745, 0.7853, 0.7664]}, {"w": "array", "b": [0.7913, 0.745, 0.8343, 0.7664]}, {"w": "of", "b": [0.8403, 0.745, 0.8571, 0.7664]}, {"w": "shape", "b": [0.1428, 0.764, 0.1901, 0.7854]}, {"w": "[10000,", "b": [0.1976, 0.764, 0.2595, 0.7854]}, {"w": "10],", "b": [0.267, 0.764, 0.2989, 0.7854]}, {"w": "like", "b": [0.3064, 0.764, 0.3364, 0.7854]}, {"w": "we", "b": [0.3439, 0.764, 0.367, 0.7854]}, {"w": "would", "b": [0.3745, 0.764, 0.4267, 0.7854]}, {"w": "get", "b": [0.4342, 0.764, 0.4592, 0.7854]}, {"w": "with", "b": [0.4666, 0.764, 0.504, 0.7854]}, {"w": "a", "b": [0.5114, 0.764, 0.5206, 0.7854]}, {"w": "single", "b": [0.528, 0.764, 0.5765, 0.7854]}, {"w": "prediction.", "b": [0.584, 0.764, 0.6756, 0.7854]}, {"w": "That’s", "b": [0.6831, 0.764, 0.7319, 0.7854]}, {"w": "all!", "b": [0.7394, 0.764, 0.7648, 0.7854]}, {"w": "Averaging", "b": [0.7723, 0.764, 0.8571, 0.7854]}]}, {"id": "b_11", "type": "paragraph", "text": "360 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "360", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2745, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 387, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "over multiple predictions with dropout on gives us a Monte Carlo estimate that is generally more reliable than the result of a single prediction with dropout off. For example, let’s look at the model’s prediction for the first instance in the test set, with dropout off:", "words": [{"w": "over", "b": [0.1429, 0.0791, 0.1797, 0.1005]}, {"w": "multiple", "b": [0.1873, 0.0791, 0.2573, 0.1005]}, {"w": "predictions", "b": [0.265, 0.0791, 0.3595, 0.1005]}, {"w": "with", "b": [0.3671, 0.0791, 0.4044, 0.1005]}, {"w": "dropout", "b": [0.412, 0.0791, 0.4804, 0.1005]}, {"w": "on", "b": [0.488, 0.0791, 0.51, 0.1005]}, {"w": "gives", "b": [0.5176, 0.0791, 0.5591, 0.1005]}, {"w": "us", "b": [0.5668, 0.0791, 0.5855, 0.1005]}, {"w": "a", "b": [0.5931, 0.0791, 0.6022, 0.1005]}, {"w": "Monte", "b": [0.6099, 0.0791, 0.6647, 0.1005]}, {"w": "Carlo", "b": [0.6724, 0.0791, 0.719, 0.1005]}, {"w": "estimate", "b": [0.7266, 0.0791, 0.7961, 0.1005]}, {"w": "that", "b": [0.8037, 0.0791, 0.8363, 0.1005]}, {"w": "is", "b": [0.8439, 0.0791, 0.8571, 0.1005]}, {"w": "generally", "b": [0.1429, 0.0981, 0.2187, 0.1195]}, {"w": "more", "b": [0.2262, 0.0981, 0.2705, 0.1195]}, {"w": "reliable", "b": [0.278, 0.0981, 0.3393, 0.1195]}, {"w": "than", "b": [0.3469, 0.0981, 0.3849, 0.1195]}, {"w": "the", "b": [0.3924, 0.0981, 0.4188, 0.1195]}, {"w": "result", "b": [0.4263, 0.0981, 0.4732, 0.1195]}, {"w": "of", "b": [0.4807, 0.0981, 0.4975, 0.1195]}, {"w": "a", "b": [0.5051, 0.0981, 0.5142, 0.1195]}, {"w": "single", "b": [0.5218, 0.0981, 0.5703, 0.1195]}, {"w": "prediction", "b": [0.5778, 0.0981, 0.6647, 0.1195]}, {"w": "with", "b": [0.6722, 0.0981, 0.7095, 0.1195]}, {"w": "dropout", "b": [0.7171, 0.0981, 0.7854, 0.1195]}, {"w": "off.", "b": [0.7929, 0.0981, 0.8206, 0.1195]}, {"w": "For", "b": [0.8282, 0.0981, 0.8571, 0.1195]}, {"w": "example,", "b": [0.1429, 0.1172, 0.2172, 0.1386]}, {"w": "let’s", "b": [0.2232, 0.1172, 0.2535, 0.1386]}, {"w": "look", "b": [0.2595, 0.1172, 0.2964, 0.1386]}, {"w": "at", "b": [0.3025, 0.1172, 0.3176, 0.1386]}, {"w": "the", "b": [0.3236, 0.1172, 0.35, 0.1386]}, {"w": "model’s", "b": [0.356, 0.1172, 0.4186, 0.1386]}, {"w": "prediction", "b": [0.4247, 0.1172, 0.5115, 0.1386]}, {"w": "for", "b": [0.5176, 0.1172, 0.5421, 0.1386]}, {"w": "the", "b": [0.5482, 0.1172, 0.5745, 0.1386]}, {"w": "first", "b": [0.5806, 0.1172, 0.6141, 0.1386]}, {"w": "instance", "b": [0.6202, 0.1172, 0.6893, 0.1386]}, {"w": "in", "b": [0.6954, 0.1172, 0.7124, 0.1386]}, {"w": "the", "b": [0.7185, 0.1172, 0.7448, 0.1386]}, {"w": "test", "b": [0.7509, 0.1172, 0.7801, 0.1386]}, {"w": "set,", "b": [0.7861, 0.1172, 0.8137, 0.1386]}, {"w": "with", "b": [0.8198, 0.1172, 0.8572, 0.1386]}, {"w": "dropout", "b": [0.1429, 0.1362, 0.2112, 0.1576]}, {"w": "off:", "b": [0.2159, 0.1362, 0.2436, 0.1576]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> np.round(model.predict(X_test_scaled[:1]), 2) array([[0. , 0. , 0. , 0. , 0. , 0. , 0. , 0.01, 0. , 0.99]], dtype=float32)", "words": [{"w": ">>>", "b": [0.1766, 0.1682, 0.2019, 0.181]}, {"w": "np.round(model.predict(X_test_scaled[:1]),", "b": [0.2103, 0.1682, 0.5645, 0.181]}, {"w": "2)", "b": [0.5729, 0.1682, 0.5898, 0.181]}, {"w": "array([[0.", "b": [0.1766, 0.1836, 0.2609, 0.1964]}, {"w": ",", "b": [0.2778, 0.1836, 0.2862, 0.1964]}, {"w": "0.", "b": [0.2946, 0.1836, 0.3115, 0.1964]}, {"w": ",", "b": [0.3284, 0.1836, 0.3368, 0.1964]}, {"w": "0.", "b": [0.3452, 0.1836, 0.3621, 0.1964]}, {"w": ",", "b": [0.379, 0.1836, 0.3874, 0.1964]}, {"w": "0.", "b": [0.3958, 0.1836, 0.4127, 0.1964]}, {"w": ",", "b": [0.4296, 0.1836, 0.438, 0.1964]}, {"w": "0.", "b": [0.4464, 0.1836, 0.4633, 0.1964]}, {"w": ",", "b": [0.4802, 0.1836, 0.4886, 0.1964]}, {"w": "0.", "b": [0.497, 0.1836, 0.5139, 0.1964]}, {"w": ",", "b": [0.5308, 0.1836, 0.5392, 0.1964]}, {"w": "0.", "b": [0.5476, 0.1836, 0.5645, 0.1964]}, {"w": ",", "b": [0.5814, 0.1836, 0.5898, 0.1964]}, {"w": "0.01,", "b": [0.5982, 0.1836, 0.6404, 0.1964]}, {"w": "0.", "b": [0.6488, 0.1836, 0.6657, 0.1964]}, {"w": ",", "b": [0.6825, 0.1836, 0.691, 0.1964]}, {"w": "0.99]],", "b": [0.6994, 0.1836, 0.7584, 0.1964]}, {"w": "dtype=float32)", "b": [0.2272, 0.199, 0.3452, 0.2119]}]}, {"id": "b_2", "type": "paragraph", "text": "The model seems almost certain that this image belongs to class 9 (ankle boot). Should you trust it? Is there really so little room for doubt? Compare this with the predictions made when dropout is activated:", "words": [{"w": "The", "b": [0.1429, 0.2197, 0.1757, 0.2411]}, {"w": "model", "b": [0.1848, 0.2197, 0.2377, 0.2411]}, {"w": "seems", "b": [0.2468, 0.2197, 0.2969, 0.2411]}, {"w": "almost", "b": [0.306, 0.2197, 0.3621, 0.2411]}, {"w": "certain", "b": [0.3713, 0.2197, 0.4291, 0.2411]}, {"w": "that", "b": [0.4383, 0.2197, 0.4709, 0.2411]}, {"w": "this", "b": [0.48, 0.2197, 0.5107, 0.2411]}, {"w": "image", "b": [0.5199, 0.2197, 0.5703, 0.2411]}, {"w": "belongs", "b": [0.5794, 0.2197, 0.6436, 0.2411]}, {"w": "to", "b": [0.6527, 0.2197, 0.6697, 0.2411]}, {"w": "class", "b": [0.6788, 0.2197, 0.7174, 0.2411]}, {"w": "9", "b": [0.7265, 0.2197, 0.7365, 0.2411]}, {"w": "(ankle", "b": [0.7456, 0.2197, 0.7979, 0.2411]}, {"w": "boot).", "b": [0.807, 0.2197, 0.8572, 0.2411]}, {"w": "Should", "b": [0.1429, 0.2387, 0.2018, 0.2601]}, {"w": "you", "b": [0.2089, 0.2387, 0.2401, 0.2601]}, {"w": "trust", "b": [0.2472, 0.2387, 0.2863, 0.2601]}, {"w": "it?", "b": [0.2934, 0.2387, 0.3132, 0.2601]}, {"w": "Is", "b": [0.3203, 0.2387, 0.3346, 0.2601]}, {"w": "there", "b": [0.3416, 0.2387, 0.3845, 0.2601]}, {"w": "really", "b": [0.3916, 0.2387, 0.4374, 0.2601]}, {"w": "so", "b": [0.4445, 0.2387, 0.4628, 0.2601]}, {"w": "little", "b": [0.4698, 0.2387, 0.5075, 0.2601]}, {"w": "room", "b": [0.5146, 0.2387, 0.5606, 0.2601]}, {"w": "for", "b": [0.5677, 0.2387, 0.5922, 0.2601]}, {"w": "doubt?", "b": [0.5992, 0.2387, 0.6568, 0.2601]}, {"w": "Compare", "b": [0.6638, 0.2387, 0.7416, 0.2601]}, {"w": "this", "b": [0.7487, 0.2387, 0.7794, 0.2601]}, {"w": "with", "b": [0.7864, 0.2387, 0.8238, 0.2601]}, {"w": "the", "b": [0.8308, 0.2387, 0.8571, 0.2601]}, {"w": "predictions", "b": [0.1429, 0.2577, 0.2374, 0.2792]}, {"w": "made", "b": [0.2421, 0.2577, 0.2881, 0.2792]}, {"w": "when", "b": [0.2929, 0.2577, 0.3385, 0.2792]}, {"w": "dropout", "b": [0.3432, 0.2577, 0.4116, 0.2792]}, {"w": "is", "b": [0.4163, 0.2577, 0.4295, 0.2792]}, {"w": "activated:", "b": [0.4342, 0.2577, 0.5135, 0.2792]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> np.round(y_probas[:, :1], 2) array([[[0. , 0. , 0. , 0. , 0. , 0.14, 0. , 0.17, 0. , 0.68]], [[0. , 0. , 0. , 0. , 0. , 0.16, 0. , 0.2 , 0. , 0.64]], [[0. , 0. , 0. , 0. , 0. , 0.02, 0. , 0.01, 0. , 0.97]], [...]", "words": [{"w": ">>>", "b": [0.1766, 0.2897, 0.2019, 0.3026]}, {"w": "np.round(y_probas[:,", "b": [0.2103, 0.2897, 0.379, 0.3026]}, {"w": ":1],", "b": [0.3874, 0.2897, 0.4211, 0.3026]}, {"w": "2)", "b": [0.4296, 0.2897, 0.4464, 0.3026]}, {"w": "array([[[0.", "b": [0.1766, 0.3051, 0.2693, 0.318]}, {"w": ",", "b": [0.2862, 0.3051, 0.2946, 0.318]}, {"w": "0.", "b": [0.3031, 0.3051, 0.3199, 0.318]}, {"w": ",", "b": [0.3368, 0.3051, 0.3452, 0.318]}, {"w": "0.", "b": [0.3537, 0.3051, 0.3705, 0.318]}, {"w": ",", "b": [0.3874, 0.3051, 0.3958, 0.318]}, {"w": "0.", "b": [0.4043, 0.3051, 0.4211, 0.318]}, {"w": ",", "b": [0.438, 0.3051, 0.4464, 0.318]}, {"w": "0.", "b": [0.4549, 0.3051, 0.4717, 0.318]}, {"w": ",", "b": [0.4886, 0.3051, 0.497, 0.318]}, {"w": "0.14,", "b": [0.5055, 0.3051, 0.5476, 0.318]}, {"w": "0.", "b": [0.556, 0.3051, 0.5729, 0.318]}, {"w": ",", "b": [0.5898, 0.3051, 0.5982, 0.318]}, {"w": "0.17,", "b": [0.6066, 0.3051, 0.6488, 0.318]}, {"w": "0.", "b": [0.6572, 0.3051, 0.6741, 0.318]}, {"w": ",", "b": [0.691, 0.3051, 0.6994, 0.318]}, {"w": "0.68]],", "b": [0.7078, 0.3051, 0.7669, 0.318]}, {"w": "[[0.", "b": [0.2356, 0.3206, 0.2693, 0.3334]}, {"w": ",", "b": [0.2862, 0.3206, 0.2946, 0.3334]}, {"w": "0.", "b": [0.3031, 0.3206, 0.3199, 0.3334]}, {"w": ",", "b": [0.3368, 0.3206, 0.3452, 0.3334]}, {"w": "0.", "b": [0.3537, 0.3206, 0.3705, 0.3334]}, {"w": ",", "b": [0.3874, 0.3206, 0.3958, 0.3334]}, {"w": "0.", "b": [0.4043, 0.3206, 0.4211, 0.3334]}, {"w": ",", "b": [0.438, 0.3206, 0.4464, 0.3334]}, {"w": "0.", "b": [0.4549, 0.3206, 0.4717, 0.3334]}, {"w": ",", "b": [0.4886, 0.3206, 0.497, 0.3334]}, {"w": "0.16,", "b": [0.5055, 0.3206, 0.5476, 0.3334]}, {"w": "0.", "b": [0.556, 0.3206, 0.5729, 0.3334]}, {"w": ",", "b": [0.5898, 0.3206, 0.5982, 0.3334]}, {"w": "0.2", "b": [0.6066, 0.3206, 0.6319, 0.3334]}, {"w": ",", "b": [0.6404, 0.3206, 0.6488, 0.3334]}, {"w": "0.", "b": [0.6572, 0.3206, 0.6741, 0.3334]}, {"w": ",", "b": [0.691, 0.3206, 0.6994, 0.3334]}, {"w": "0.64]],", "b": [0.7078, 0.3206, 0.7669, 0.3334]}, {"w": "[[0.", "b": [0.2356, 0.336, 0.2693, 0.3488]}, {"w": ",", "b": [0.2862, 0.336, 0.2946, 0.3488]}, {"w": "0.", "b": [0.3031, 0.336, 0.3199, 0.3488]}, {"w": ",", "b": [0.3368, 0.336, 0.3452, 0.3488]}, {"w": "0.", "b": [0.3537, 0.336, 0.3705, 0.3488]}, {"w": ",", "b": [0.3874, 0.336, 0.3958, 0.3488]}, {"w": "0.", "b": [0.4043, 0.336, 0.4211, 0.3488]}, {"w": ",", "b": [0.438, 0.336, 0.4464, 0.3488]}, {"w": "0.", "b": [0.4549, 0.336, 0.4717, 0.3488]}, {"w": ",", "b": [0.4886, 0.336, 0.497, 0.3488]}, {"w": "0.02,", "b": [0.5055, 0.336, 0.5476, 0.3488]}, {"w": "0.", "b": [0.556, 0.336, 0.5729, 0.3488]}, {"w": ",", "b": [0.5898, 0.336, 0.5982, 0.3488]}, {"w": "0.01,", "b": [0.6066, 0.336, 0.6488, 0.3488]}, {"w": "0.", "b": [0.6572, 0.336, 0.6741, 0.3488]}, {"w": ",", "b": [0.691, 0.336, 0.6994, 0.3488]}, {"w": "0.97]],", "b": [0.7078, 0.336, 0.7669, 0.3488]}, {"w": "[...]", "b": [0.2356, 0.3514, 0.2778, 0.3642]}]}, {"id": "b_4", "type": "paragraph", "text": "This tells a very different story: apparently, when we activate dropout, the model is not sure anymore. It still seems to prefer class 9, but sometimes it hesitates with classes 5 (sandal) and 7 (sneaker), which makes sense given they’re all footwear. Once we average over the first dimension, we get the following MC dropout predictions:", "words": [{"w": "This", "b": [0.1429, 0.372, 0.1801, 0.3934]}, {"w": "tells", "b": [0.1869, 0.372, 0.2203, 0.3934]}, {"w": "a", "b": [0.2272, 0.372, 0.2363, 0.3934]}, {"w": "very", "b": [0.2432, 0.372, 0.2796, 0.3934]}, {"w": "different", "b": [0.2864, 0.372, 0.3581, 0.3934]}, {"w": "story:", "b": [0.365, 0.372, 0.4129, 0.3934]}, {"w": "apparently,", "b": [0.4197, 0.372, 0.5115, 0.3934]}, {"w": "when", "b": [0.5183, 0.372, 0.564, 0.3934]}, {"w": "we", "b": [0.5708, 0.372, 0.5939, 0.3934]}, {"w": "activate", "b": [0.6008, 0.372, 0.6643, 0.3934]}, {"w": "dropout,", "b": [0.6712, 0.372, 0.7442, 0.3934]}, {"w": "the", "b": [0.7511, 0.372, 0.7774, 0.3934]}, {"w": "model", "b": [0.7843, 0.372, 0.8371, 0.3934]}, {"w": "is", "b": [0.8439, 0.372, 0.8571, 0.3934]}, {"w": "not", "b": [0.1429, 0.3911, 0.1712, 0.4125]}, {"w": "sure", "b": [0.1798, 0.3911, 0.2151, 0.4125]}, {"w": "anymore.", "b": [0.2237, 0.3911, 0.3024, 0.4125]}, {"w": "It", "b": [0.311, 0.3911, 0.3236, 0.4125]}, {"w": "still", "b": [0.3322, 0.3911, 0.3624, 0.4125]}, {"w": "seems", "b": [0.371, 0.3911, 0.421, 0.4125]}, {"w": "to", "b": [0.4296, 0.3911, 0.4466, 0.4125]}, {"w": "prefer", "b": [0.4552, 0.3911, 0.5055, 0.4125]}, {"w": "class", "b": [0.5141, 0.3911, 0.5526, 0.4125]}, {"w": "9,", "b": [0.5612, 0.3911, 0.576, 0.4125]}, {"w": "but", "b": [0.5846, 0.3911, 0.6126, 0.4125]}, {"w": "sometimes", "b": [0.6212, 0.3911, 0.7109, 0.4125]}, {"w": "it", "b": [0.7195, 0.3911, 0.7314, 0.4125]}, {"w": "hesitates", "b": [0.74, 0.3911, 0.8112, 0.4125]}, {"w": "with", "b": [0.8198, 0.3911, 0.8571, 0.4125]}, {"w": "classes", "b": [0.1428, 0.4101, 0.1979, 0.4315]}, {"w": "5", "b": [0.2029, 0.4101, 0.2129, 0.4315]}, {"w": "(sandal)", "b": [0.2179, 0.4101, 0.286, 0.4315]}, {"w": "and", "b": [0.291, 0.4101, 0.3225, 0.4315]}, {"w": "7", "b": [0.3276, 0.4101, 0.3376, 0.4315]}, {"w": "(sneaker),", "b": [0.3426, 0.4101, 0.4257, 0.4315]}, {"w": "which", "b": [0.4308, 0.4101, 0.4817, 0.4315]}, {"w": "makes", "b": [0.4867, 0.4101, 0.5398, 0.4315]}, {"w": "sense", "b": [0.5448, 0.4101, 0.5892, 0.4315]}, {"w": "given", "b": [0.5942, 0.4101, 0.6395, 0.4315]}, {"w": "they’re", "b": [0.6445, 0.4101, 0.7005, 0.4315]}, {"w": "all", "b": [0.7055, 0.4101, 0.7252, 0.4315]}, {"w": "footwear.", "b": [0.7303, 0.4101, 0.8075, 0.4315]}, {"w": "Once", "b": [0.8125, 0.4101, 0.8571, 0.4315]}, {"w": "we", "b": [0.1429, 0.4292, 0.166, 0.4506]}, {"w": "average", "b": [0.1707, 0.4292, 0.2335, 0.4506]}, {"w": "over", "b": [0.2382, 0.4292, 0.275, 0.4506]}, {"w": "the", "b": [0.2798, 0.4292, 0.3061, 0.4506]}, {"w": "first", "b": [0.3108, 0.4292, 0.3443, 0.4506]}, {"w": "dimension,", "b": [0.349, 0.4292, 0.4429, 0.4506]}, {"w": "we", "b": [0.4477, 0.4292, 0.4708, 0.4506]}, {"w": "get", "b": [0.4755, 0.4292, 0.5005, 0.4506]}, {"w": "the", "b": [0.5052, 0.4292, 0.5315, 0.4506]}, {"w": "following", "b": [0.5363, 0.4292, 0.6152, 0.4506]}, {"w": "MC", "b": [0.62, 0.4292, 0.6524, 0.4506]}, {"w": "dropout", "b": [0.6571, 0.4292, 0.7254, 0.4506]}, {"w": "predictions:", "b": [0.7302, 0.4292, 0.8294, 0.4506]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> np.round(y_proba[:1], 2) array([[0. , 0. , 0. , 0. , 0. , 0.22, 0. , 0.16, 0. , 0.62]], dtype=float32)", "words": [{"w": ">>>", "b": [0.1766, 0.4611, 0.2019, 0.474]}, {"w": "np.round(y_proba[:1],", "b": [0.2103, 0.4611, 0.3874, 0.474]}, {"w": "2)", "b": [0.3958, 0.4611, 0.4127, 0.474]}, {"w": "array([[0.", "b": [0.1766, 0.4766, 0.2609, 0.4894]}, {"w": ",", "b": [0.2778, 0.4766, 0.2862, 0.4894]}, {"w": "0.", "b": [0.2946, 0.4766, 0.3115, 0.4894]}, {"w": ",", "b": [0.3284, 0.4766, 0.3368, 0.4894]}, {"w": "0.", "b": [0.3452, 0.4766, 0.3621, 0.4894]}, {"w": ",", "b": [0.379, 0.4766, 0.3874, 0.4894]}, {"w": "0.", "b": [0.3958, 0.4766, 0.4127, 0.4894]}, {"w": ",", "b": [0.4296, 0.4766, 0.438, 0.4894]}, {"w": "0.", "b": [0.4464, 0.4766, 0.4633, 0.4894]}, {"w": ",", "b": [0.4802, 0.4766, 0.4886, 0.4894]}, {"w": "0.22,", "b": [0.497, 0.4766, 0.5392, 0.4894]}, {"w": "0.", "b": [0.5476, 0.4766, 0.5645, 0.4894]}, {"w": ",", "b": [0.5814, 0.4766, 0.5898, 0.4894]}, {"w": "0.16,", "b": [0.5982, 0.4766, 0.6404, 0.4894]}, {"w": "0.", "b": [0.6488, 0.4766, 0.6657, 0.4894]}, {"w": ",", "b": [0.6825, 0.4766, 0.691, 0.4894]}, {"w": "0.62]],", "b": [0.6994, 0.4766, 0.7584, 0.4894]}, {"w": "dtype=float32)", "b": [0.2272, 0.492, 0.3452, 0.5048]}]}, {"id": "b_6", "type": "paragraph", "text": "The model still thinks this image belongs to class 9, but only with a 62% confidence, which seems much more reasonable than 99%. Plus it’s useful to know exactly which other classes it thinks are likely. And you can also take a look at the standard devia‐ tion of the probability estimates:", "words": [{"w": "The", "b": [0.1429, 0.5126, 0.1757, 0.534]}, {"w": "model", "b": [0.1815, 0.5126, 0.2343, 0.534]}, {"w": "still", "b": [0.2401, 0.5126, 0.2703, 0.534]}, {"w": "thinks", "b": [0.2761, 0.5126, 0.3285, 0.534]}, {"w": "this", "b": [0.3343, 0.5126, 0.3651, 0.534]}, {"w": "image", "b": [0.3709, 0.5126, 0.4213, 0.534]}, {"w": "belongs", "b": [0.4271, 0.5126, 0.4912, 0.534]}, {"w": "to", "b": [0.497, 0.5126, 0.514, 0.534]}, {"w": "class", "b": [0.5198, 0.5126, 0.5583, 0.534]}, {"w": "9,", "b": [0.5642, 0.5126, 0.5789, 0.534]}, {"w": "but", "b": [0.5847, 0.5126, 0.6127, 0.534]}, {"w": "only", "b": [0.6185, 0.5126, 0.6554, 0.534]}, {"w": "with", "b": [0.6612, 0.5126, 0.6986, 0.534]}, {"w": "a", "b": [0.7044, 0.5126, 0.7135, 0.534]}, {"w": "62%", "b": [0.7193, 0.5126, 0.7551, 0.534]}, {"w": "confidence,", "b": [0.7609, 0.5126, 0.8572, 0.534]}, {"w": "which", "b": [0.1429, 0.5317, 0.1938, 0.5531]}, {"w": "seems", "b": [0.1995, 0.5317, 0.2495, 0.5531]}, {"w": "much", "b": [0.2552, 0.5317, 0.3029, 0.5531]}, {"w": "more", "b": [0.3085, 0.5317, 0.3528, 0.5531]}, {"w": "reasonable", "b": [0.3585, 0.5317, 0.4477, 0.5531]}, {"w": "than", "b": [0.4534, 0.5317, 0.4914, 0.5531]}, {"w": "99%.", "b": [0.4971, 0.5317, 0.5376, 0.5531]}, {"w": "Plus", "b": [0.5433, 0.5317, 0.579, 0.5531]}, {"w": "it’s", "b": [0.5847, 0.5317, 0.6063, 0.5531]}, {"w": "useful", "b": [0.612, 0.5317, 0.6621, 0.5531]}, {"w": "to", "b": [0.6678, 0.5317, 0.6847, 0.5531]}, {"w": "know", "b": [0.6904, 0.5317, 0.737, 0.5531]}, {"w": "exactly", "b": [0.7427, 0.5317, 0.8006, 0.5531]}, {"w": "which", "b": [0.8062, 0.5317, 0.8571, 0.5531]}, {"w": "other", "b": [0.1429, 0.5507, 0.1875, 0.5721]}, {"w": "classes", "b": [0.1937, 0.5507, 0.2488, 0.5721]}, {"w": "it", "b": [0.2549, 0.5507, 0.2669, 0.5721]}, {"w": "thinks", "b": [0.2731, 0.5507, 0.3255, 0.5721]}, {"w": "are", "b": [0.3317, 0.5507, 0.3574, 0.5721]}, {"w": "likely.", "b": [0.3636, 0.5507, 0.4117, 0.5721]}, {"w": "And", "b": [0.4179, 0.5507, 0.4547, 0.5721]}, {"w": "you", "b": [0.4609, 0.5507, 0.4922, 0.5721]}, {"w": "can", "b": [0.4984, 0.5507, 0.5277, 0.5721]}, {"w": "also", "b": [0.5339, 0.5507, 0.5666, 0.5721]}, {"w": "take", "b": [0.5728, 0.5507, 0.6075, 0.5721]}, {"w": "a", "b": [0.6137, 0.5507, 0.6228, 0.5721]}, {"w": "look", "b": [0.629, 0.5507, 0.6659, 0.5721]}, {"w": "at", "b": [0.6721, 0.5507, 0.6872, 0.5721]}, {"w": "the", "b": [0.6934, 0.5507, 0.7197, 0.5721]}, {"w": "standard", "b": [0.7259, 0.5507, 0.7993, 0.5721]}, {"w": "devia‐", "b": [0.8055, 0.5507, 0.8571, 0.5721]}, {"w": "tion", "b": [0.1428, 0.5698, 0.1768, 0.5912]}, {"w": "of", "b": [0.1815, 0.5698, 0.1983, 0.5912]}, {"w": "the", "b": [0.2031, 0.5698, 0.2294, 0.5912]}, {"w": "probability", "b": [0.2341, 0.5698, 0.3261, 0.5912]}, {"w": "estimates:", "b": [0.3308, 0.5698, 0.4126, 0.5912]}]}, {"id": "b_7", "type": "paragraph", "text": ">>> y_std = y_probas.std(axis=0) >>> np.round(y_std[:1], 2) array([[0. , 0. , 0. , 0. , 0. , 0.28, 0. , 0.21, 0.02, 0.32]], dtype=float32)", "words": [{"w": ">>>", "b": [0.1766, 0.6017, 0.2019, 0.6146]}, {"w": "y_std", "b": [0.2103, 0.6017, 0.2525, 0.6146]}, {"w": "=", "b": [0.2609, 0.6017, 0.2693, 0.6146]}, {"w": "y_probas.std(axis=0)", "b": [0.2778, 0.6017, 0.4464, 0.6146]}, {"w": ">>>", "b": [0.1766, 0.6172, 0.2019, 0.63]}, {"w": "np.round(y_std[:1],", "b": [0.2103, 0.6172, 0.3705, 0.63]}, {"w": "2)", "b": [0.379, 0.6172, 0.3958, 0.63]}, {"w": "array([[0.", "b": [0.1766, 0.6326, 0.2609, 0.6454]}, {"w": ",", "b": [0.2778, 0.6326, 0.2862, 0.6454]}, {"w": "0.", "b": [0.2946, 0.6326, 0.3115, 0.6454]}, {"w": ",", "b": [0.3284, 0.6326, 0.3368, 0.6454]}, {"w": "0.", "b": [0.3452, 0.6326, 0.3621, 0.6454]}, {"w": ",", "b": [0.379, 0.6326, 0.3874, 0.6454]}, {"w": "0.", "b": [0.3958, 0.6326, 0.4127, 0.6454]}, {"w": ",", "b": [0.4296, 0.6326, 0.438, 0.6454]}, {"w": "0.", "b": [0.4464, 0.6326, 0.4633, 0.6454]}, {"w": ",", "b": [0.4802, 0.6326, 0.4886, 0.6454]}, {"w": "0.28,", "b": [0.497, 0.6326, 0.5392, 0.6454]}, {"w": "0.", "b": [0.5476, 0.6326, 0.5645, 0.6454]}, {"w": ",", "b": [0.5813, 0.6326, 0.5898, 0.6454]}, {"w": "0.21,", "b": [0.5982, 0.6326, 0.6404, 0.6454]}, {"w": "0.02,", "b": [0.6488, 0.6326, 0.691, 0.6454]}, {"w": "0.32]],", "b": [0.6994, 0.6326, 0.7584, 0.6454]}, {"w": "dtype=float32)", "b": [0.2272, 0.648, 0.3452, 0.6608]}]}, {"id": "b_8", "type": "paragraph", "text": "Apparently there’s quite a lot of variance in the probability estimates: if you were building a risk-sensitive system (e.g., a medical or financial system), you should prob‐ ably treat such an uncertain prediction with extreme caution. You definitely would not treat it like a 99% confident prediction. Moreover, the model’s accuracy got a small boost from 86.8 to 86.9:", "words": [{"w": "Apparently", "b": [0.1429, 0.6686, 0.2361, 0.69]}, {"w": "there’s", "b": [0.2445, 0.6686, 0.2965, 0.69]}, {"w": "quite", "b": [0.3048, 0.6686, 0.3473, 0.69]}, {"w": "a", "b": [0.3556, 0.6686, 0.3648, 0.69]}, {"w": "lot", "b": [0.3731, 0.6686, 0.3953, 0.69]}, {"w": "of", "b": [0.4037, 0.6686, 0.4205, 0.69]}, {"w": "variance", "b": [0.4288, 0.6686, 0.4991, 0.69]}, {"w": "in", "b": [0.5074, 0.6686, 0.5244, 0.69]}, {"w": "the", "b": [0.5327, 0.6686, 0.559, 0.69]}, {"w": "probability", "b": [0.5674, 0.6686, 0.6593, 0.69]}, {"w": "estimates:", "b": [0.6676, 0.6686, 0.7495, 0.69]}, {"w": "if", "b": [0.7578, 0.6686, 0.7695, 0.69]}, {"w": "you", "b": [0.7779, 0.6686, 0.8091, 0.69]}, {"w": "were", "b": [0.8174, 0.6686, 0.8571, 0.69]}, {"w": "building", "b": [0.1428, 0.6877, 0.2131, 0.7091]}, {"w": "a", "b": [0.2178, 0.6877, 0.227, 0.7091]}, {"w": "risk-sensitive", "b": [0.2317, 0.6877, 0.342, 0.7091]}, {"w": "system", "b": [0.3467, 0.6877, 0.4038, 0.7091]}, {"w": "(e.g.,", "b": [0.4085, 0.6877, 0.4486, 0.7091]}, {"w": "a", "b": [0.4533, 0.6877, 0.4625, 0.7091]}, {"w": "medical", "b": [0.4672, 0.6877, 0.5329, 0.7091]}, {"w": "or", "b": [0.5377, 0.6877, 0.556, 0.7091]}, {"w": "financial", "b": [0.5607, 0.6877, 0.6332, 0.7091]}, {"w": "system),", "b": [0.638, 0.6877, 0.7071, 0.7091]}, {"w": "you", "b": [0.7118, 0.6877, 0.743, 0.7091]}, {"w": "should", "b": [0.7478, 0.6877, 0.8045, 0.7091]}, {"w": "prob‐", "b": [0.8092, 0.6877, 0.8565, 0.7091]}, {"w": "ably", "b": [0.1428, 0.7067, 0.1774, 0.7281]}, {"w": "treat", "b": [0.1847, 0.7067, 0.2227, 0.7281]}, {"w": "such", "b": [0.23, 0.7067, 0.2686, 0.7281]}, {"w": "an", "b": [0.2759, 0.7067, 0.2964, 0.7281]}, {"w": "uncertain", "b": [0.3037, 0.7067, 0.384, 0.7281]}, {"w": "prediction", "b": [0.3913, 0.7067, 0.4781, 0.7281]}, {"w": "with", "b": [0.4854, 0.7067, 0.5227, 0.7281]}, {"w": "extreme", "b": [0.53, 0.7067, 0.5975, 0.7281]}, {"w": "caution.", "b": [0.6048, 0.7067, 0.6721, 0.7281]}, {"w": "You", "b": [0.6794, 0.7067, 0.7118, 0.7281]}, {"w": "definitely", "b": [0.719, 0.7067, 0.7976, 0.7281]}, {"w": "would", "b": [0.8049, 0.7067, 0.8571, 0.7281]}, {"w": "not", "b": [0.1429, 0.7258, 0.1712, 0.7472]}, {"w": "treat", "b": [0.1794, 0.7258, 0.2175, 0.7472]}, {"w": "it", "b": [0.2256, 0.7258, 0.2376, 0.7472]}, {"w": "like", "b": [0.2457, 0.7258, 0.2758, 0.7472]}, {"w": "a", "b": [0.2839, 0.7258, 0.2931, 0.7472]}, {"w": "99%", "b": [0.3013, 0.7258, 0.337, 0.7472]}, {"w": "confident", "b": [0.3452, 0.7258, 0.425, 0.7472]}, {"w": "prediction.", "b": [0.4331, 0.7258, 0.5247, 0.7472]}, {"w": "Moreover,", "b": [0.5329, 0.7258, 0.6184, 0.7472]}, {"w": "the", "b": [0.6266, 0.7258, 0.6529, 0.7472]}, {"w": "model’s", "b": [0.6611, 0.7258, 0.7237, 0.7472]}, {"w": "accuracy", "b": [0.7319, 0.7258, 0.8049, 0.7472]}, {"w": "got", "b": [0.8131, 0.7258, 0.8398, 0.7472]}, {"w": "a", "b": [0.848, 0.7258, 0.8572, 0.7472]}, {"w": "small", "b": [0.1429, 0.7448, 0.1873, 0.7662]}, {"w": "boost", "b": [0.192, 0.7448, 0.2378, 0.7662]}, {"w": "from", "b": [0.2425, 0.7448, 0.2841, 0.7662]}, {"w": "86.8", "b": [0.2889, 0.7448, 0.3236, 0.7662]}, {"w": "to", "b": [0.3283, 0.7448, 0.3453, 0.7662]}, {"w": "86.9:", "b": [0.35, 0.7448, 0.3895, 0.7662]}]}, {"id": "b_9", "type": "equation", "text": ">>> accuracy = np.sum(y_pred == y_test) / len(y_test) >>> accuracy 0.8694", "words": [{"w": ">>>", "b": [0.1766, 0.7768, 0.2019, 0.7896]}, {"w": "accuracy", "b": [0.2103, 0.7768, 0.2778, 0.7896]}, {"w": "=", "b": [0.2862, 0.7768, 0.2946, 0.7896]}, {"w": "np.sum(y_pred", "b": [0.3031, 0.7768, 0.4127, 0.7896]}, {"w": "==", "b": [0.4211, 0.7768, 0.438, 0.7896]}, {"w": "y_test)", "b": [0.4464, 0.7768, 0.5055, 0.7896]}, {"w": "/", "b": [0.5139, 0.7768, 0.5223, 0.7896]}, {"w": "len(y_test)", "b": [0.5308, 0.7768, 0.6235, 0.7896]}, {"w": ">>>", "b": [0.1766, 0.7922, 0.2019, 0.8051]}, {"w": "accuracy", "b": [0.2103, 0.7922, 0.2778, 0.8051]}, {"w": "0.8694", "b": [0.1766, 0.8076, 0.2272, 0.8205]}]}, {"id": "b_10", "type": "paragraph", "text": "Avoiding Overfitting Through Regularization | 361", "words": [{"w": "Avoiding", "b": [0.5348, 0.9225, 0.587, 0.9388]}, {"w": "Overfitting", "b": [0.5899, 0.9225, 0.6541, 0.9388]}, {"w": "Through", "b": [0.657, 0.9225, 0.7066, 0.9388]}, {"w": "Regularization", "b": [0.7094, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "361", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 388, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "The number of Monte Carlo samples you use (100 in this example) is a hyperparameter you can tweak. The higher it is, the more accu‐ rate the predictions and their uncertainty estimates will be. How‐ ever, it you double it, inference time will also be doubled. Moreover, above a certain number of samples, you will notice little improvement. So your job is to find the right tradeoff between latency and accuracy, depending on your application.", "words": [{"w": "The", "b": [0.2714, 0.0793, 0.3014, 0.0989]}, {"w": "number", "b": [0.3063, 0.0793, 0.3669, 0.0989]}, {"w": "of", "b": [0.3718, 0.0793, 0.3871, 0.0989]}, {"w": "Monte", "b": [0.392, 0.0793, 0.4421, 0.0989]}, {"w": "Carlo", "b": [0.447, 0.0793, 0.4896, 0.0989]}, {"w": "samples", "b": [0.4945, 0.0793, 0.555, 0.0989]}, {"w": "you", "b": [0.5598, 0.0793, 0.5884, 0.0989]}, {"w": "use", "b": [0.5933, 0.0793, 0.6185, 0.0989]}, {"w": "(100", "b": [0.6233, 0.0793, 0.6574, 0.0989]}, {"w": "in", "b": [0.6622, 0.0793, 0.6777, 0.0989]}, {"w": "this", "b": [0.6826, 0.0793, 0.7107, 0.0989]}, {"w": "example)", "b": [0.7155, 0.0793, 0.7857, 0.0989]}, {"w": "is", "b": [0.2714, 0.0967, 0.2835, 0.1163]}, {"w": "a", "b": [0.288, 0.0967, 0.2964, 0.1163]}, {"w": "hyperparameter", "b": [0.3009, 0.0967, 0.423, 0.1163]}, {"w": "you", "b": [0.4275, 0.0967, 0.4561, 0.1163]}, {"w": "can", "b": [0.4606, 0.0967, 0.4875, 0.1163]}, {"w": "tweak.", "b": [0.492, 0.0967, 0.5411, 0.1163]}, {"w": "The", "b": [0.5457, 0.0967, 0.5757, 0.1163]}, {"w": "higher", "b": [0.5802, 0.0967, 0.6297, 0.1163]}, {"w": "it", "b": [0.6343, 0.0967, 0.6452, 0.1163]}, {"w": "is,", "b": [0.6497, 0.0967, 0.6662, 0.1163]}, {"w": "the", "b": [0.6707, 0.0967, 0.6948, 0.1163]}, {"w": "more", "b": [0.6993, 0.0967, 0.7398, 0.1163]}, {"w": "accu‐", "b": [0.7443, 0.0967, 0.7857, 0.1163]}, {"w": "rate", "b": [0.2714, 0.1141, 0.3004, 0.1337]}, {"w": "the", "b": [0.3068, 0.1141, 0.3309, 0.1337]}, {"w": "predictions", "b": [0.3374, 0.1141, 0.4238, 0.1337]}, {"w": "and", "b": [0.4302, 0.1141, 0.4591, 0.1337]}, {"w": "their", "b": [0.4655, 0.1141, 0.5018, 0.1337]}, {"w": "uncertainty", "b": [0.5082, 0.1141, 0.5958, 0.1337]}, {"w": "estimates", "b": [0.6023, 0.1141, 0.6728, 0.1337]}, {"w": "will", "b": [0.6792, 0.1141, 0.707, 0.1337]}, {"w": "be.", "b": [0.7135, 0.1141, 0.7356, 0.1337]}, {"w": "How‐", "b": [0.7421, 0.1141, 0.7857, 0.1337]}, {"w": "ever,", "b": [0.2714, 0.1315, 0.3066, 0.1511]}, {"w": "it", "b": [0.319, 0.1315, 0.3299, 0.1511]}, {"w": "you", "b": [0.3423, 0.1315, 0.3709, 0.1511]}, {"w": "double", "b": [0.3833, 0.1315, 0.4358, 0.1511]}, {"w": "it,", "b": [0.4482, 0.1315, 0.4634, 0.1511]}, {"w": "inference", "b": [0.4758, 0.1315, 0.5468, 0.1511]}, {"w": "time", "b": [0.5592, 0.1315, 0.5938, 0.1511]}, {"w": "will", "b": [0.6062, 0.1315, 0.634, 0.1511]}, {"w": "also", "b": [0.6464, 0.1315, 0.6763, 0.1511]}, {"w": "be", "b": [0.6887, 0.1315, 0.7064, 0.1511]}, {"w": "doubled.", "b": [0.7188, 0.1315, 0.7857, 0.1511]}, {"w": "Moreover,", "b": [0.2714, 0.1489, 0.3496, 0.1685]}, {"w": "above", "b": [0.3547, 0.1489, 0.3994, 0.1685]}, {"w": "a", "b": [0.4045, 0.1489, 0.4129, 0.1685]}, {"w": "certain", "b": [0.418, 0.1489, 0.471, 0.1685]}, {"w": "number", "b": [0.4761, 0.1489, 0.5367, 0.1685]}, {"w": "of", "b": [0.5418, 0.1489, 0.5572, 0.1685]}, {"w": "samples,", "b": [0.5623, 0.1489, 0.6271, 0.1685]}, {"w": "you", "b": [0.6323, 0.1489, 0.6609, 0.1685]}, {"w": "will", "b": [0.666, 0.1489, 0.6938, 0.1685]}, {"w": "notice", "b": [0.6989, 0.1489, 0.7461, 0.1685]}, {"w": "little", "b": [0.7513, 0.1489, 0.7857, 0.1685]}, {"w": "improvement.", "b": [0.2714, 0.1664, 0.3793, 0.1859]}, {"w": "So", "b": [0.3878, 0.1664, 0.4065, 0.1859]}, {"w": "your", "b": [0.415, 0.1664, 0.4506, 0.1859]}, {"w": "job", "b": [0.4591, 0.1664, 0.4833, 0.1859]}, {"w": "is", "b": [0.4918, 0.1664, 0.5039, 0.1859]}, {"w": "to", "b": [0.5123, 0.1664, 0.5279, 0.1859]}, {"w": "find", "b": [0.5363, 0.1664, 0.5675, 0.1859]}, {"w": "the", "b": [0.576, 0.1664, 0.6, 0.1859]}, {"w": "right", "b": [0.6085, 0.1664, 0.6452, 0.1859]}, {"w": "tradeoff", "b": [0.6537, 0.1664, 0.714, 0.1859]}, {"w": "between", "b": [0.7225, 0.1664, 0.7857, 0.1859]}, {"w": "latency", "b": [0.2714, 0.1838, 0.3254, 0.2033]}, {"w": "and", "b": [0.3297, 0.1838, 0.3585, 0.2033]}, {"w": "accuracy,", "b": [0.3628, 0.1838, 0.4326, 0.2033]}, {"w": "depending", "b": [0.4369, 0.1838, 0.5181, 0.2033]}, {"w": "on", "b": [0.5224, 0.1838, 0.5425, 0.2033]}, {"w": "your", "b": [0.5469, 0.1838, 0.5825, 0.2033]}, {"w": "application.", "b": [0.5868, 0.1838, 0.6762, 0.2033]}]}, {"id": "b_1", "type": "paragraph", "text": "If your model contains other layers that behave in a special way during training (such as Batch Normalization layers), then you should not force training mode like we just did. Instead, you should replace the Dropout layers with the following MCDropout class:", "words": [{"w": "If", "b": [0.1429, 0.2236, 0.1561, 0.2451]}, {"w": "your", "b": [0.1612, 0.2236, 0.2002, 0.2451]}, {"w": "model", "b": [0.2053, 0.2236, 0.2581, 0.2451]}, {"w": "contains", "b": [0.2632, 0.2236, 0.3338, 0.2451]}, {"w": "other", "b": [0.3389, 0.2236, 0.3836, 0.2451]}, {"w": "layers", "b": [0.3887, 0.2236, 0.4365, 0.2451]}, {"w": "that", "b": [0.4416, 0.2236, 0.4742, 0.2451]}, {"w": "behave", "b": [0.4793, 0.2236, 0.5372, 0.2451]}, {"w": "in", "b": [0.5423, 0.2236, 0.5592, 0.2451]}, {"w": "a", "b": [0.5643, 0.2236, 0.5735, 0.2451]}, {"w": "special", "b": [0.5786, 0.2236, 0.6348, 0.2451]}, {"w": "way", "b": [0.6399, 0.2236, 0.6725, 0.2451]}, {"w": "during", "b": [0.6776, 0.2236, 0.7342, 0.2451]}, {"w": "training", "b": [0.7393, 0.2236, 0.8062, 0.2451]}, {"w": "(such", "b": [0.8113, 0.2236, 0.8572, 0.2451]}, {"w": "as", "b": [0.1429, 0.2427, 0.1597, 0.2641]}, {"w": "Batch", "b": [0.1654, 0.2427, 0.2127, 0.2641]}, {"w": "Normalization", "b": [0.2184, 0.2427, 0.3402, 0.2641]}, {"w": "layers),", "b": [0.3459, 0.2427, 0.4057, 0.2641]}, {"w": "then", "b": [0.4114, 0.2427, 0.4491, 0.2641]}, {"w": "you", "b": [0.4549, 0.2427, 0.4861, 0.2641]}, {"w": "should", "b": [0.4918, 0.2427, 0.5486, 0.2641]}, {"w": "not", "b": [0.5543, 0.2427, 0.5826, 0.2641]}, {"w": "force", "b": [0.5884, 0.2427, 0.6305, 0.2641]}, {"w": "training", "b": [0.6363, 0.2427, 0.7032, 0.2641]}, {"w": "mode", "b": [0.7089, 0.2427, 0.7564, 0.2641]}, {"w": "like", "b": [0.7622, 0.2427, 0.7922, 0.2641]}, {"w": "we", "b": [0.7979, 0.2427, 0.821, 0.2641]}, {"w": "just", "b": [0.8267, 0.2427, 0.8571, 0.2641]}, {"w": "did.", "b": [0.1429, 0.2626, 0.1752, 0.284]}, {"w": "Instead,", "b": [0.1836, 0.2626, 0.2499, 0.284]}, {"w": "you", "b": [0.2583, 0.2626, 0.2896, 0.284]}, {"w": "should", "b": [0.2981, 0.2626, 0.3548, 0.284]}, {"w": "replace", "b": [0.3632, 0.2626, 0.4228, 0.284]}, {"w": "the", "b": [0.4313, 0.2626, 0.4576, 0.284]}, {"w": "Dropout", "b": [0.4661, 0.2658, 0.5353, 0.2809]}, {"w": "layers", "b": [0.5438, 0.2626, 0.5916, 0.284]}, {"w": "with", "b": [0.6001, 0.2626, 0.6374, 0.284]}, {"w": "the", "b": [0.6459, 0.2626, 0.6722, 0.284]}, {"w": "following", "b": [0.6807, 0.2626, 0.7596, 0.284]}, {"w": "MCDropout", "b": [0.7681, 0.2658, 0.8571, 0.2809]}, {"w": "class:", "b": [0.1428, 0.2817, 0.1861, 0.3031]}]}, {"id": "b_2", "type": "paragraph", "text": "class MCDropout(keras.layers.Dropout): def call(self, inputs): return super().call(inputs, training=True)", "words": [{"w": "class", "b": [0.1766, 0.3137, 0.2188, 0.3265]}, {"w": "MCDropout(keras.layers.Dropout):", "b": [0.2272, 0.3137, 0.497, 0.3265]}, {"w": "def", "b": [0.2103, 0.3291, 0.2356, 0.3419]}, {"w": "call(self,", "b": [0.2441, 0.3291, 0.3284, 0.3419]}, {"w": "inputs):", "b": [0.3368, 0.3291, 0.4043, 0.3419]}, {"w": "return", "b": [0.2441, 0.3445, 0.2946, 0.3573]}, {"w": "super().call(inputs,", "b": [0.3031, 0.3445, 0.4717, 0.3573]}, {"w": "training=True)", "b": [0.4802, 0.3445, 0.5982, 0.3573]}]}, {"id": "b_3", "type": "paragraph", "text": "We just sublass the Dropout layer and override the call() method to force its train ing argument to True (see Chapter 12). Similarly, you could define an MCAlphaDrop out class by subclassing AlphaDropout instead. If you are creating a model from scratch, it’s just a matter of using MCDropout rather than Dropout. But if you have a model that was already trained using Dropout, you need to create a new model, iden‐ tical to the existing model except replacing the Dropout layers with MCDropout, then copy the existing model’s weights to your new model.", "words": [{"w": "We", "b": [0.1429, 0.366, 0.1699, 0.3874]}, {"w": "just", "b": [0.1757, 0.366, 0.2061, 0.3874]}, {"w": "sublass", "b": [0.2118, 0.366, 0.2708, 0.3874]}, {"w": "the", "b": [0.2766, 0.366, 0.3029, 0.3874]}, {"w": "Dropout", "b": [0.3087, 0.3692, 0.3779, 0.3843]}, {"w": "layer", "b": [0.3837, 0.366, 0.4239, 0.3874]}, {"w": "and", "b": [0.4296, 0.366, 0.4612, 0.3874]}, {"w": "override", "b": [0.4669, 0.366, 0.5369, 0.3874]}, {"w": "the", "b": [0.5427, 0.366, 0.569, 0.3874]}, {"w": "call()", "b": [0.5748, 0.3692, 0.6342, 0.3843]}, {"w": "method", "b": [0.6399, 0.366, 0.7049, 0.3874]}, {"w": "to", "b": [0.7107, 0.366, 0.7277, 0.3874]}, {"w": "force", "b": [0.7334, 0.366, 0.7756, 0.3874]}, {"w": "its", "b": [0.7814, 0.366, 0.8009, 0.3874]}, {"w": "train", "b": [0.8067, 0.3692, 0.8562, 0.3843]}, {"w": "ing", "b": [0.1429, 0.3892, 0.1726, 0.4042]}, {"w": "argument", "b": [0.1789, 0.386, 0.2598, 0.4074]}, {"w": "to", "b": [0.2662, 0.386, 0.2831, 0.4074]}, {"w": "True", "b": [0.2895, 0.3892, 0.329, 0.4042]}, {"w": "(see", "b": [0.3354, 0.386, 0.3679, 0.4074]}, {"w": "Chapter", "b": [0.3743, 0.386, 0.4418, 0.4074]}, {"w": "12).", "b": [0.4482, 0.386, 0.4801, 0.4074]}, {"w": "Similarly,", "b": [0.4864, 0.386, 0.5648, 0.4074]}, {"w": "you", "b": [0.5711, 0.386, 0.6023, 0.4074]}, {"w": "could", "b": [0.6086, 0.386, 0.6554, 0.4074]}, {"w": "define", "b": [0.6617, 0.386, 0.7136, 0.4074]}, {"w": "an", "b": [0.7199, 0.386, 0.7405, 0.4074]}, {"w": "MCAlphaDrop", "b": [0.7468, 0.3892, 0.8556, 0.4042]}, {"w": "out", "b": [0.1429, 0.4091, 0.1725, 0.4242]}, {"w": "class", "b": [0.1815, 0.4059, 0.22, 0.4273]}, {"w": "by", "b": [0.2289, 0.4059, 0.249, 0.4273]}, {"w": "subclassing", "b": [0.2579, 0.4059, 0.3525, 0.4273]}, {"w": "AlphaDropout", "b": [0.3614, 0.4091, 0.4801, 0.4242]}, {"w": "instead.", "b": [0.489, 0.4059, 0.5538, 0.4273]}, {"w": "If", "b": [0.5627, 0.4059, 0.576, 0.4273]}, {"w": "you", "b": [0.5849, 0.4059, 0.6161, 0.4273]}, {"w": "are", "b": [0.625, 0.4059, 0.6507, 0.4273]}, {"w": "creating", "b": [0.6597, 0.4059, 0.7269, 0.4273]}, {"w": "a", "b": [0.7358, 0.4059, 0.7449, 0.4273]}, {"w": "model", "b": [0.7538, 0.4059, 0.8067, 0.4273]}, {"w": "from", "b": [0.8156, 0.4059, 0.8571, 0.4273]}, {"w": "scratch,", "b": [0.1429, 0.4259, 0.2068, 0.4473]}, {"w": "it’s", "b": [0.2135, 0.4259, 0.2352, 0.4473]}, {"w": "just", "b": [0.2418, 0.4259, 0.2722, 0.4473]}, {"w": "a", "b": [0.2789, 0.4259, 0.288, 0.4473]}, {"w": "matter", "b": [0.2947, 0.4259, 0.3498, 0.4473]}, {"w": "of", "b": [0.3565, 0.4259, 0.3733, 0.4473]}, {"w": "using", "b": [0.3799, 0.4259, 0.4254, 0.4473]}, {"w": "MCDropout", "b": [0.432, 0.429, 0.5211, 0.4441]}, {"w": "rather", "b": [0.5277, 0.4259, 0.5783, 0.4473]}, {"w": "than", "b": [0.5849, 0.4259, 0.623, 0.4473]}, {"w": "Dropout.", "b": [0.6296, 0.4259, 0.7036, 0.4473]}, {"w": "But", "b": [0.7103, 0.4259, 0.74, 0.4473]}, {"w": "if", "b": [0.7466, 0.4259, 0.7584, 0.4473]}, {"w": "you", "b": [0.765, 0.4259, 0.7963, 0.4473]}, {"w": "have", "b": [0.8029, 0.4259, 0.8413, 0.4473]}, {"w": "a", "b": [0.848, 0.4259, 0.8571, 0.4473]}, {"w": "model", "b": [0.1429, 0.4458, 0.1957, 0.4672]}, {"w": "that", "b": [0.201, 0.4458, 0.2336, 0.4672]}, {"w": "was", "b": [0.2389, 0.4458, 0.27, 0.4672]}, {"w": "already", "b": [0.2753, 0.4458, 0.336, 0.4672]}, {"w": "trained", "b": [0.3413, 0.4458, 0.4014, 0.4672]}, {"w": "using", "b": [0.4067, 0.4458, 0.4521, 0.4672]}, {"w": "Dropout,", "b": [0.4574, 0.4458, 0.5314, 0.4672]}, {"w": "you", "b": [0.5368, 0.4458, 0.568, 0.4672]}, {"w": "need", "b": [0.5733, 0.4458, 0.6134, 0.4672]}, {"w": "to", "b": [0.6187, 0.4458, 0.6357, 0.4672]}, {"w": "create", "b": [0.641, 0.4458, 0.6904, 0.4672]}, {"w": "a", "b": [0.6957, 0.4458, 0.7049, 0.4672]}, {"w": "new", "b": [0.7102, 0.4458, 0.7447, 0.4672]}, {"w": "model,", "b": [0.75, 0.4458, 0.8076, 0.4672]}, {"w": "iden‐", "b": [0.8129, 0.4458, 0.8571, 0.4672]}, {"w": "tical", "b": [0.1429, 0.4657, 0.178, 0.4872]}, {"w": "to", "b": [0.1842, 0.4657, 0.2012, 0.4872]}, {"w": "the", "b": [0.2074, 0.4657, 0.2338, 0.4872]}, {"w": "existing", "b": [0.24, 0.4657, 0.305, 0.4872]}, {"w": "model", "b": [0.3112, 0.4657, 0.364, 0.4872]}, {"w": "except", "b": [0.3702, 0.4657, 0.4239, 0.4872]}, {"w": "replacing", "b": [0.4301, 0.4657, 0.5075, 0.4872]}, {"w": "the", "b": [0.5138, 0.4657, 0.5401, 0.4872]}, {"w": "Dropout", "b": [0.5463, 0.4689, 0.6156, 0.484]}, {"w": "layers", "b": [0.6218, 0.4657, 0.6696, 0.4872]}, {"w": "with", "b": [0.6758, 0.4657, 0.7132, 0.4872]}, {"w": "MCDropout,", "b": [0.7194, 0.4657, 0.8132, 0.4872]}, {"w": "then", "b": [0.8194, 0.4657, 0.8572, 0.4872]}, {"w": "copy", "b": [0.1429, 0.4848, 0.1828, 0.5062]}, {"w": "the", "b": [0.1875, 0.4848, 0.2138, 0.5062]}, {"w": "existing", "b": [0.2186, 0.4848, 0.2836, 0.5062]}, {"w": "model’s", "b": [0.2883, 0.4848, 0.3509, 0.5062]}, {"w": "weights", "b": [0.3556, 0.4848, 0.4188, 0.5062]}, {"w": "to", "b": [0.4235, 0.4848, 0.4405, 0.5062]}, {"w": "your", "b": [0.4452, 0.4848, 0.4842, 0.5062]}, {"w": "new", "b": [0.4889, 0.4848, 0.5235, 0.5062]}, {"w": "model.", "b": [0.5282, 0.4848, 0.5858, 0.5062]}]}, {"id": "b_4", "type": "paragraph", "text": "In short, MC Dropout is a fantastic technique that boosts dropout models and pro‐ vides better uncertainty estimates. And of course, since it is just regular dropout dur‐ ing training, it also acts like a regularizer.", "words": [{"w": "In", "b": [0.1429, 0.5129, 0.1614, 0.5343]}, {"w": "short,", "b": [0.1678, 0.5129, 0.2161, 0.5343]}, {"w": "MC", "b": [0.2225, 0.5129, 0.255, 0.5343]}, {"w": "Dropout", "b": [0.2614, 0.5129, 0.3341, 0.5343]}, {"w": "is", "b": [0.3405, 0.5129, 0.3538, 0.5343]}, {"w": "a", "b": [0.3602, 0.5129, 0.3694, 0.5343]}, {"w": "fantastic", "b": [0.3759, 0.5129, 0.4461, 0.5343]}, {"w": "technique", "b": [0.4525, 0.5129, 0.5352, 0.5343]}, {"w": "that", "b": [0.5417, 0.5129, 0.5743, 0.5343]}, {"w": "boosts", "b": [0.5808, 0.5129, 0.6342, 0.5343]}, {"w": "dropout", "b": [0.6407, 0.5129, 0.709, 0.5343]}, {"w": "models", "b": [0.7155, 0.5129, 0.776, 0.5343]}, {"w": "and", "b": [0.7824, 0.5129, 0.814, 0.5343]}, {"w": "pro‐", "b": [0.8205, 0.5129, 0.8571, 0.5343]}, {"w": "vides", "b": [0.1429, 0.532, 0.1856, 0.5534]}, {"w": "better", "b": [0.1909, 0.532, 0.2396, 0.5534]}, {"w": "uncertainty", "b": [0.2449, 0.532, 0.3408, 0.5534]}, {"w": "estimates.", "b": [0.3461, 0.532, 0.428, 0.5534]}, {"w": "And", "b": [0.4333, 0.532, 0.4701, 0.5534]}, {"w": "of", "b": [0.4754, 0.532, 0.4922, 0.5534]}, {"w": "course,", "b": [0.4975, 0.532, 0.557, 0.5534]}, {"w": "since", "b": [0.5623, 0.532, 0.6046, 0.5534]}, {"w": "it", "b": [0.6099, 0.532, 0.6219, 0.5534]}, {"w": "is", "b": [0.6272, 0.532, 0.6404, 0.5534]}, {"w": "just", "b": [0.6457, 0.532, 0.6761, 0.5534]}, {"w": "regular", "b": [0.6814, 0.532, 0.741, 0.5534]}, {"w": "dropout", "b": [0.7463, 0.532, 0.8146, 0.5534]}, {"w": "dur‐", "b": [0.8199, 0.532, 0.8571, 0.5534]}, {"w": "ing", "b": [0.1429, 0.551, 0.1696, 0.5724]}, {"w": "training,", "b": [0.1743, 0.551, 0.246, 0.5724]}, {"w": "it", "b": [0.2507, 0.551, 0.2627, 0.5724]}, {"w": "also", "b": [0.2674, 0.551, 0.3001, 0.5724]}, {"w": "acts", "b": [0.3048, 0.551, 0.3368, 0.5724]}, {"w": "like", "b": [0.3415, 0.551, 0.3716, 0.5724]}, {"w": "a", "b": [0.3763, 0.551, 0.3854, 0.5724]}, {"w": "regularizer.", "b": [0.3902, 0.551, 0.4841, 0.5724]}]}, {"id": "b_5", "type": "equation", "text": "Max-Norm Regularization", "words": [{"w": "Max-Norm", "b": [0.1429, 0.5852, 0.2519, 0.6138]}, {"w": "Regularization", "b": [0.2568, 0.5852, 0.4082, 0.6138]}]}, {"id": "b_6", "type": "paragraph", "text": "Another regularization technique that is quite popular for neural networks is called max-norm regularization: for each neuron, it constrains the weights w of the incom‐ ing connections such that ∥ *w* ∥2 ≤ _r_, where r is the max-norm hyperparameter and ∥ · ∥2 is the ℓ2 norm.", "words": [{"w": "Another", "b": [0.1429, 0.6197, 0.2133, 0.6411]}, {"w": "regularization", "b": [0.22, 0.6197, 0.3366, 0.6411]}, {"w": "technique", "b": [0.3433, 0.6197, 0.426, 0.6411]}, {"w": "that", "b": [0.4327, 0.6197, 0.4653, 0.6411]}, {"w": "is", "b": [0.472, 0.6197, 0.4852, 0.6411]}, {"w": "quite", "b": [0.492, 0.6197, 0.5345, 0.6411]}, {"w": "popular", "b": [0.5412, 0.6197, 0.6068, 0.6411]}, {"w": "for", "b": [0.6135, 0.6197, 0.6381, 0.6411]}, {"w": "neural", "b": [0.6448, 0.6197, 0.6982, 0.6411]}, {"w": "networks", "b": [0.7049, 0.6197, 0.7821, 0.6411]}, {"w": "is", "b": [0.7889, 0.6197, 0.8021, 0.6411]}, {"w": "called", "b": [0.8088, 0.6197, 0.8571, 0.6411]}, {"w": "max-norm", "b": [0.1429, 0.6385, 0.2309, 0.6601]}, {"w": "regularization:", "b": [0.2369, 0.6385, 0.3564, 0.6601]}, {"w": "for", "b": [0.3625, 0.6387, 0.387, 0.6601]}, {"w": "each", "b": [0.393, 0.6387, 0.431, 0.6601]}, {"w": "neuron,", "b": [0.437, 0.6387, 0.5028, 0.6601]}, {"w": "it", "b": [0.5088, 0.6387, 0.5208, 0.6601]}, {"w": "constrains", "b": [0.5268, 0.6387, 0.6132, 0.6601]}, {"w": "the", "b": [0.6192, 0.6387, 0.6455, 0.6601]}, {"w": "weights", "b": [0.6516, 0.6387, 0.7148, 0.6601]}, {"w": "w", "b": [0.7208, 0.6381, 0.735, 0.6601]}, {"w": "of", "b": [0.7411, 0.6387, 0.7578, 0.6601]}, {"w": "the", "b": [0.7639, 0.6387, 0.7902, 0.6601]}, {"w": "incom‐", "b": [0.7963, 0.6387, 0.8572, 0.6601]}, {"w": "ing", "b": [0.1429, 0.6577, 0.1696, 0.6792]}, {"w": "connections", "b": [0.176, 0.6577, 0.2775, 0.6792]}, {"w": "such", "b": [0.2839, 0.6577, 0.3226, 0.6792]}, {"w": "that", "b": [0.329, 0.6577, 0.3615, 0.6792]}, {"w": "∥", "b": [0.368, 0.661, 0.3784, 0.6769]}, {"w": "*w*", "b": [0.3848, 0.6577, 0.4159, 0.6792]}, {"w": "∥2", "b": [0.4223, 0.661, 0.4387, 0.6801]}, {"w": "≤", "b": [0.4451, 0.6577, 0.4572, 0.6792]}, {"w": "_r_,", "b": [0.4636, 0.6577, 0.4969, 0.6792]}, {"w": "where", "b": [0.5033, 0.6577, 0.5541, 0.6792]}, {"w": "r", "b": [0.5606, 0.6575, 0.5682, 0.6792]}, {"w": "is", "b": [0.5746, 0.6577, 0.5878, 0.6792]}, {"w": "the", "b": [0.5942, 0.6577, 0.6206, 0.6792]}, {"w": "max-norm", "b": [0.627, 0.6577, 0.7172, 0.6792]}, {"w": "hyperparameter", "b": [0.7236, 0.6577, 0.8571, 0.6792]}, {"w": "and", "b": [0.1429, 0.6768, 0.1744, 0.6982]}, {"w": "∥", "b": [0.1791, 0.68, 0.1895, 0.6959]}, {"w": "·", "b": [0.1943, 0.6768, 0.199, 0.6982]}, {"w": "∥2", "b": [0.2037, 0.68, 0.2201, 0.6991]}, {"w": "is", "b": [0.2249, 0.6768, 0.2381, 0.6982]}, {"w": "the", "b": [0.2428, 0.6768, 0.2691, 0.6982]}, {"w": "ℓ2", "b": [0.2739, 0.6768, 0.2884, 0.6991]}, {"w": "norm.", "b": [0.2932, 0.6768, 0.3447, 0.6982]}]}, {"id": "b_7", "type": "paragraph", "text": "Max-norm regularization does not add a regularization loss term to the overall loss function. Instead, it is typically implemented by computing ∥w∥2 after each training step and clipping w if needed (w w r ∥w ∥2).", "words": [{"w": "Max-norm", "b": [0.1429, 0.7049, 0.2343, 0.7263]}, {"w": "regularization", "b": [0.241, 0.7049, 0.3576, 0.7263]}, {"w": "does", "b": [0.3643, 0.7049, 0.4024, 0.7263]}, {"w": "not", "b": [0.4092, 0.7049, 0.4375, 0.7263]}, {"w": "add", "b": [0.4443, 0.7049, 0.4754, 0.7263]}, {"w": "a", "b": [0.4821, 0.7049, 0.4913, 0.7263]}, {"w": "regularization", "b": [0.498, 0.7049, 0.6146, 0.7263]}, {"w": "loss", "b": [0.6213, 0.7049, 0.6525, 0.7263]}, {"w": "term", "b": [0.6592, 0.7049, 0.6992, 0.7263]}, {"w": "to", "b": [0.7059, 0.7049, 0.7229, 0.7263]}, {"w": "the", "b": [0.7296, 0.7049, 0.756, 0.7263]}, {"w": "overall", "b": [0.7627, 0.7049, 0.8192, 0.7263]}, {"w": "loss", "b": [0.826, 0.7049, 0.8571, 0.7263]}, {"w": "function.", "b": [0.1429, 0.724, 0.219, 0.7454]}, {"w": "Instead,", "b": [0.2254, 0.724, 0.2916, 0.7454]}, {"w": "it", "b": [0.298, 0.724, 0.31, 0.7454]}, {"w": "is", "b": [0.3164, 0.724, 0.3296, 0.7454]}, {"w": "typically", "b": [0.336, 0.724, 0.4065, 0.7454]}, {"w": "implemented", "b": [0.4129, 0.724, 0.5233, 0.7454]}, {"w": "by", "b": [0.5297, 0.724, 0.5498, 0.7454]}, {"w": "computing", "b": [0.5562, 0.724, 0.6474, 0.7454]}, {"w": "∥w∥2", "b": [0.6538, 0.7234, 0.6948, 0.7463]}, {"w": "after", "b": [0.7012, 0.724, 0.7395, 0.7454]}, {"w": "each", "b": [0.7459, 0.724, 0.7838, 0.7454]}, {"w": "training", "b": [0.7902, 0.724, 0.8572, 0.7454]}, {"w": "step", "b": [0.1429, 0.7469, 0.1766, 0.7683]}, {"w": "and", "b": [0.1814, 0.7469, 0.2129, 0.7683]}, {"w": "clipping", "b": [0.2176, 0.7469, 0.2859, 0.7683]}, {"w": "w", "b": [0.2906, 0.7463, 0.3048, 0.7683]}, {"w": "if", "b": [0.3095, 0.7469, 0.3213, 0.7683]}, {"w": "needed", "b": [0.326, 0.7469, 0.386, 0.7683]}, {"w": "(w", "b": [0.3907, 0.7463, 0.4121, 0.7683]}, {"w": "w", "b": [0.442, 0.7463, 0.4562, 0.7683]}, {"w": "r", "b": [0.4771, 0.7423, 0.4829, 0.7587]}, {"w": "∥w", "b": [0.4585, 0.7574, 0.4817, 0.7742]}, {"w": "∥2).", "b": [0.4861, 0.7469, 0.516, 0.7795]}]}, {"id": "b_8", "type": "paragraph", "text": "Reducing r increases the amount of regularization and helps reduce overfitting. Max- norm regularization can also help alleviate the vanishing/exploding gradients prob‐ lems (if you are not using Batch Normalization).", "words": [{"w": "Reducing", "b": [0.1429, 0.785, 0.2223, 0.8064]}, {"w": "r", "b": [0.2275, 0.7848, 0.2351, 0.8064]}, {"w": "increases", "b": [0.2403, 0.785, 0.316, 0.8064]}, {"w": "the", "b": [0.3212, 0.785, 0.3476, 0.8064]}, {"w": "amount", "b": [0.3528, 0.785, 0.4181, 0.8064]}, {"w": "of", "b": [0.4233, 0.785, 0.4401, 0.8064]}, {"w": "regularization", "b": [0.4453, 0.785, 0.5619, 0.8064]}, {"w": "and", "b": [0.5671, 0.785, 0.5987, 0.8064]}, {"w": "helps", "b": [0.6039, 0.785, 0.6477, 0.8064]}, {"w": "reduce", "b": [0.653, 0.785, 0.7093, 0.8064]}, {"w": "overfitting.", "b": [0.7145, 0.785, 0.8073, 0.8064]}, {"w": "Max-", "b": [0.8125, 0.785, 0.8571, 0.8064]}, {"w": "norm", "b": [0.1429, 0.804, 0.1897, 0.8254]}, {"w": "regularization", "b": [0.1967, 0.804, 0.3132, 0.8254]}, {"w": "can", "b": [0.3202, 0.804, 0.3496, 0.8254]}, {"w": "also", "b": [0.3566, 0.804, 0.3893, 0.8254]}, {"w": "help", "b": [0.3963, 0.804, 0.4324, 0.8254]}, {"w": "alleviate", "b": [0.4394, 0.804, 0.5071, 0.8254]}, {"w": "the", "b": [0.5141, 0.804, 0.5405, 0.8254]}, {"w": "vanishing/exploding", "b": [0.5474, 0.804, 0.7188, 0.8254]}, {"w": "gradients", "b": [0.7258, 0.804, 0.8029, 0.8254]}, {"w": "prob‐", "b": [0.8099, 0.804, 0.8571, 0.8254]}, {"w": "lems", "b": [0.1429, 0.8231, 0.1817, 0.8445]}, {"w": "(if", "b": [0.1864, 0.8231, 0.2054, 0.8445]}, {"w": "you", "b": [0.2101, 0.8231, 0.2414, 0.8445]}, {"w": "are", "b": [0.2461, 0.8231, 0.2718, 0.8445]}, {"w": "not", "b": [0.2765, 0.8231, 0.3049, 0.8445]}, {"w": "using", "b": [0.3096, 0.8231, 0.3551, 0.8445]}, {"w": "Batch", "b": [0.3598, 0.8231, 0.4071, 0.8445]}, {"w": "Normalization).", "b": [0.4118, 0.8231, 0.5456, 0.8445]}]}, {"id": "b_9", "type": "paragraph", "text": "362 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "362", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2746, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3265, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 389, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "To implement max-norm regularization in Keras, just set every hidden layer’s ker nel_constraint argument to a max_norm() constraint, with the appropriate max value, for example:", "words": [{"w": "To", "b": [0.1429, 0.08, 0.1643, 0.1014]}, {"w": "implement", "b": [0.1721, 0.08, 0.2627, 0.1014]}, {"w": "max-norm", "b": [0.2705, 0.08, 0.3608, 0.1014]}, {"w": "regularization", "b": [0.3686, 0.08, 0.4852, 0.1014]}, {"w": "in", "b": [0.4931, 0.08, 0.51, 0.1014]}, {"w": "Keras,", "b": [0.5179, 0.08, 0.5695, 0.1014]}, {"w": "just", "b": [0.5774, 0.08, 0.6078, 0.1014]}, {"w": "set", "b": [0.6156, 0.08, 0.6384, 0.1014]}, {"w": "every", "b": [0.6463, 0.08, 0.6915, 0.1014]}, {"w": "hidden", "b": [0.6994, 0.08, 0.7583, 0.1014]}, {"w": "layer’s", "b": [0.7662, 0.08, 0.8167, 0.1014]}, {"w": "ker", "b": [0.8245, 0.0831, 0.8542, 0.0982]}, {"w": "nel_constraint", "b": [0.1429, 0.1031, 0.2814, 0.1182]}, {"w": "argument", "b": [0.2907, 0.0999, 0.3716, 0.1213]}, {"w": "to", "b": [0.3809, 0.0999, 0.3979, 0.1213]}, {"w": "a", "b": [0.4072, 0.0999, 0.4163, 0.1213]}, {"w": "max_norm()", "b": [0.4256, 0.1031, 0.5245, 0.1182]}, {"w": "constraint,", "b": [0.5338, 0.0999, 0.6232, 0.1213]}, {"w": "with", "b": [0.6325, 0.0999, 0.6698, 0.1213]}, {"w": "the", "b": [0.6791, 0.0999, 0.7054, 0.1213]}, {"w": "appropriate", "b": [0.7147, 0.0999, 0.8118, 0.1213]}, {"w": "max", "b": [0.8211, 0.0999, 0.8571, 0.1213]}, {"w": "value,", "b": [0.1429, 0.119, 0.1916, 0.1404]}, {"w": "for", "b": [0.1963, 0.119, 0.2208, 0.1404]}, {"w": "example:", "b": [0.2256, 0.119, 0.2999, 0.1404]}]}, {"id": "b_1", "type": "paragraph", "text": "keras.layers.Dense(100, activation=\"elu\", kernel_initializer=\"he_normal\", kernel_constraint=keras.constraints.max_norm(1.))", "words": [{"w": "keras.layers.Dense(100,", "b": [0.1766, 0.1509, 0.3705, 0.1638]}, {"w": "activation=\"elu\",", "b": [0.379, 0.1509, 0.5223, 0.1638]}, {"w": "kernel_initializer=\"he_normal\",", "b": [0.5308, 0.1509, 0.7922, 0.1638]}, {"w": "kernel_constraint=keras.constraints.max_norm(1.))", "b": [0.3368, 0.1663, 0.75, 0.1792]}]}, {"id": "b_2", "type": "paragraph", "text": "After each training iteration, the model’s fit() method will call the object returned by max_norm(), passing it the layer’s weights and getting clipped weights in return, which then replace the layer’s weights. As we will see in Chapter 12, you can define your own custom constraint function if you ever need to, and use it as the ker nel_constraint. You can also constrain the bias terms by setting the bias_con straint argument.", "words": [{"w": "After", "b": [0.1429, 0.1879, 0.1864, 0.2093]}, {"w": "each", "b": [0.1928, 0.1879, 0.2308, 0.2093]}, {"w": "training", "b": [0.2372, 0.1879, 0.3042, 0.2093]}, {"w": "iteration,", "b": [0.3107, 0.1879, 0.3866, 0.2093]}, {"w": "the", "b": [0.3931, 0.1879, 0.4195, 0.2093]}, {"w": "model’s", "b": [0.4259, 0.1879, 0.4885, 0.2093]}, {"w": "fit()", "b": [0.495, 0.1911, 0.5445, 0.2061]}, {"w": "method", "b": [0.551, 0.1879, 0.616, 0.2093]}, {"w": "will", "b": [0.6225, 0.1879, 0.6528, 0.2093]}, {"w": "call", "b": [0.6593, 0.1879, 0.6878, 0.2093]}, {"w": "the", "b": [0.6943, 0.1879, 0.7206, 0.2093]}, {"w": "object", "b": [0.7271, 0.1879, 0.7777, 0.2093]}, {"w": "returned", "b": [0.7842, 0.1879, 0.8571, 0.2093]}, {"w": "by", "b": [0.1429, 0.2078, 0.163, 0.2292]}, {"w": "max_norm(),", "b": [0.1703, 0.2078, 0.274, 0.2292]}, {"w": "passing", "b": [0.2813, 0.2078, 0.3434, 0.2292]}, {"w": "it", "b": [0.3506, 0.2078, 0.3626, 0.2292]}, {"w": "the", "b": [0.3699, 0.2078, 0.3962, 0.2292]}, {"w": "layer’s", "b": [0.4035, 0.2078, 0.454, 0.2292]}, {"w": "weights", "b": [0.4613, 0.2078, 0.5244, 0.2292]}, {"w": "and", "b": [0.5317, 0.2078, 0.5633, 0.2292]}, {"w": "getting", "b": [0.5706, 0.2078, 0.6286, 0.2292]}, {"w": "clipped", "b": [0.6359, 0.2078, 0.6972, 0.2292]}, {"w": "weights", "b": [0.7045, 0.2078, 0.7677, 0.2292]}, {"w": "in", "b": [0.775, 0.2078, 0.792, 0.2292]}, {"w": "return,", "b": [0.7993, 0.2078, 0.8571, 0.2292]}, {"w": "which", "b": [0.1429, 0.2269, 0.1938, 0.2483]}, {"w": "then", "b": [0.2004, 0.2269, 0.2381, 0.2483]}, {"w": "replace", "b": [0.2447, 0.2269, 0.3042, 0.2483]}, {"w": "the", "b": [0.3108, 0.2269, 0.3371, 0.2483]}, {"w": "layer’s", "b": [0.3437, 0.2269, 0.3942, 0.2483]}, {"w": "weights.", "b": [0.4008, 0.2269, 0.4687, 0.2483]}, {"w": "As", "b": [0.4753, 0.2269, 0.4973, 0.2483]}, {"w": "we", "b": [0.5039, 0.2269, 0.527, 0.2483]}, {"w": "will", "b": [0.5336, 0.2269, 0.564, 0.2483]}, {"w": "see", "b": [0.5706, 0.2269, 0.5959, 0.2483]}, {"w": "in", "b": [0.6025, 0.2269, 0.6195, 0.2483]}, {"w": "Chapter", "b": [0.6261, 0.2269, 0.6936, 0.2483]}, {"w": "12,", "b": [0.7002, 0.2269, 0.725, 0.2483]}, {"w": "you", "b": [0.7315, 0.2269, 0.7628, 0.2483]}, {"w": "can", "b": [0.7694, 0.2269, 0.7987, 0.2483]}, {"w": "define", "b": [0.8053, 0.2269, 0.8571, 0.2483]}, {"w": "your", "b": [0.1429, 0.2468, 0.1818, 0.2682]}, {"w": "own", "b": [0.1908, 0.2468, 0.2271, 0.2682]}, {"w": "custom", "b": [0.236, 0.2468, 0.2976, 0.2682]}, {"w": "constraint", "b": [0.3065, 0.2468, 0.3912, 0.2682]}, {"w": "function", "b": [0.4001, 0.2468, 0.4715, 0.2682]}, {"w": "if", "b": [0.4805, 0.2468, 0.4922, 0.2682]}, {"w": "you", "b": [0.5012, 0.2468, 0.5324, 0.2682]}, {"w": "ever", "b": [0.5414, 0.2468, 0.5765, 0.2682]}, {"w": "need", "b": [0.5854, 0.2468, 0.6255, 0.2682]}, {"w": "to,", "b": [0.6345, 0.2468, 0.6556, 0.2682]}, {"w": "and", "b": [0.6645, 0.2468, 0.6961, 0.2682]}, {"w": "use", "b": [0.705, 0.2468, 0.7326, 0.2682]}, {"w": "it", "b": [0.7415, 0.2468, 0.7535, 0.2682]}, {"w": "as", "b": [0.7624, 0.2468, 0.7792, 0.2682]}, {"w": "the", "b": [0.7882, 0.2468, 0.8145, 0.2682]}, {"w": "ker", "b": [0.8234, 0.25, 0.8531, 0.2651]}, {"w": "nel_constraint.", "b": [0.1429, 0.2668, 0.2861, 0.2882]}, {"w": "You", "b": [0.2957, 0.2668, 0.328, 0.2882]}, {"w": "can", "b": [0.3376, 0.2668, 0.3669, 0.2882]}, {"w": "also", "b": [0.3764, 0.2668, 0.4091, 0.2882]}, {"w": "constrain", "b": [0.4187, 0.2668, 0.4973, 0.2882]}, {"w": "the", "b": [0.5069, 0.2668, 0.5332, 0.2882]}, {"w": "bias", "b": [0.5427, 0.2668, 0.5757, 0.2882]}, {"w": "terms", "b": [0.5852, 0.2668, 0.6329, 0.2882]}, {"w": "by", "b": [0.6424, 0.2668, 0.6625, 0.2882]}, {"w": "setting", "b": [0.6721, 0.2668, 0.728, 0.2882]}, {"w": "the", "b": [0.7375, 0.2668, 0.7639, 0.2882]}, {"w": "bias_con", "b": [0.7734, 0.2699, 0.8526, 0.285]}, {"w": "straint", "b": [0.1429, 0.2899, 0.2121, 0.305]}, {"w": "argument.", "b": [0.2169, 0.2867, 0.3026, 0.3081]}]}, {"id": "b_3", "type": "paragraph", "text": "The max_norm() function has an axis argument that defaults to 0. A Dense layer usu‐ ally has weights of shape [number of inputs, number of neurons], so using axis=0 means that the max norm constraint will apply independently to each neuron’s weight vector. If you want to use max-norm with convolutional layers (see Chapter 14), make sure to set the max_norm() constraint’s axis argument appropriately (usually axis=[0, 1, 2]).", "words": [{"w": "The", "b": [0.1429, 0.3157, 0.1757, 0.3371]}, {"w": "max_norm()", "b": [0.1808, 0.3189, 0.2797, 0.334]}, {"w": "function", "b": [0.2848, 0.3157, 0.3562, 0.3371]}, {"w": "has", "b": [0.3613, 0.3157, 0.3893, 0.3371]}, {"w": "an", "b": [0.3944, 0.3157, 0.4149, 0.3371]}, {"w": "axis", "b": [0.42, 0.3189, 0.4596, 0.334]}, {"w": "argument", "b": [0.4647, 0.3157, 0.5457, 0.3371]}, {"w": "that", "b": [0.5508, 0.3157, 0.5833, 0.3371]}, {"w": "defaults", "b": [0.5884, 0.3157, 0.6535, 0.3371]}, {"w": "to", "b": [0.6586, 0.3157, 0.6756, 0.3371]}, {"w": "0.", "b": [0.6807, 0.3157, 0.6955, 0.3371]}, {"w": "A", "b": [0.7006, 0.3157, 0.715, 0.3371]}, {"w": "Dense", "b": [0.7201, 0.3189, 0.7696, 0.334]}, {"w": "layer", "b": [0.7747, 0.3157, 0.8148, 0.3371]}, {"w": "usu‐", "b": [0.8196, 0.3157, 0.8568, 0.3371]}, {"w": "ally", "b": [0.1428, 0.3357, 0.1721, 0.3571]}, {"w": "has", "b": [0.1794, 0.3357, 0.2074, 0.3571]}, {"w": "weights", "b": [0.2147, 0.3357, 0.2779, 0.3571]}, {"w": "of", "b": [0.2852, 0.3357, 0.302, 0.3571]}, {"w": "shape", "b": [0.3094, 0.3357, 0.3567, 0.3571]}, {"w": "[number", "b": [0.364, 0.3357, 0.4375, 0.3571]}, {"w": "of", "b": [0.4448, 0.3357, 0.4616, 0.3571]}, {"w": "inputs,", "b": [0.469, 0.3357, 0.5263, 0.3571]}, {"w": "number", "b": [0.5336, 0.3357, 0.5999, 0.3571]}, {"w": "of", "b": [0.6072, 0.3357, 0.624, 0.3571]}, {"w": "neurons],", "b": [0.6314, 0.3357, 0.712, 0.3571]}, {"w": "so", "b": [0.7194, 0.3357, 0.7376, 0.3571]}, {"w": "using", "b": [0.745, 0.3357, 0.7904, 0.3571]}, {"w": "axis=0", "b": [0.7978, 0.3388, 0.8571, 0.3539]}, {"w": "means", "b": [0.1429, 0.3547, 0.197, 0.3761]}, {"w": "that", "b": [0.2018, 0.3547, 0.2344, 0.3761]}, {"w": "the", "b": [0.2392, 0.3547, 0.2655, 0.3761]}, {"w": "max", "b": [0.2703, 0.3547, 0.3064, 0.3761]}, {"w": "norm", "b": [0.3112, 0.3547, 0.358, 0.3761]}, {"w": "constraint", "b": [0.3628, 0.3547, 0.4475, 0.3761]}, {"w": "will", "b": [0.4523, 0.3547, 0.4827, 0.3761]}, {"w": "apply", "b": [0.4875, 0.3547, 0.5329, 0.3761]}, {"w": "independently", "b": [0.5377, 0.3547, 0.6578, 0.3761]}, {"w": "to", "b": [0.6626, 0.3547, 0.6796, 0.3761]}, {"w": "each", "b": [0.6844, 0.3547, 0.7223, 0.3761]}, {"w": "neuron’s", "b": [0.7271, 0.3547, 0.7968, 0.3761]}, {"w": "weight", "b": [0.8016, 0.3547, 0.8572, 0.3761]}, {"w": "vector.", "b": [0.1429, 0.3738, 0.1983, 0.3952]}, {"w": "If", "b": [0.2072, 0.3738, 0.2204, 0.3952]}, {"w": "you", "b": [0.2293, 0.3738, 0.2605, 0.3952]}, {"w": "want", "b": [0.2694, 0.3738, 0.3101, 0.3952]}, {"w": "to", "b": [0.319, 0.3738, 0.336, 0.3952]}, {"w": "use", "b": [0.3448, 0.3738, 0.3724, 0.3952]}, {"w": "max-norm", "b": [0.3812, 0.3738, 0.4715, 0.3952]}, {"w": "with", "b": [0.4803, 0.3738, 0.5177, 0.3952]}, {"w": "convolutional", "b": [0.5265, 0.3738, 0.6418, 0.3952]}, {"w": "layers", "b": [0.6507, 0.3738, 0.6985, 0.3952]}, {"w": "(see", "b": [0.7074, 0.3738, 0.7399, 0.3952]}, {"w": "Chapter", "b": [0.7488, 0.3738, 0.8163, 0.3952]}, {"w": "14),", "b": [0.8252, 0.3738, 0.8571, 0.3952]}, {"w": "make", "b": [0.1429, 0.3937, 0.1882, 0.4151]}, {"w": "sure", "b": [0.1958, 0.3937, 0.2311, 0.4151]}, {"w": "to", "b": [0.2386, 0.3937, 0.2556, 0.4151]}, {"w": "set", "b": [0.2631, 0.3937, 0.286, 0.4151]}, {"w": "the", "b": [0.2935, 0.3937, 0.3198, 0.4151]}, {"w": "max_norm()", "b": [0.3274, 0.3969, 0.4263, 0.412]}, {"w": "constraint’s", "b": [0.4339, 0.3937, 0.5283, 0.4151]}, {"w": "axis", "b": [0.5358, 0.3969, 0.5754, 0.412]}, {"w": "argument", "b": [0.5829, 0.3937, 0.6639, 0.4151]}, {"w": "appropriately", "b": [0.6714, 0.3937, 0.7834, 0.4151]}, {"w": "(usually", "b": [0.7909, 0.3937, 0.8571, 0.4151]}, {"w": "axis=[0,", "b": [0.1429, 0.4168, 0.222, 0.4319]}, {"w": "1,", "b": [0.2319, 0.4168, 0.2517, 0.4319]}, {"w": "2]).", "b": [0.2616, 0.4136, 0.2934, 0.4351]}]}, {"id": "b_4", "type": "paragraph", "text": "Summary and Practical Guidelines", "words": [{"w": "Summary", "b": [0.1429, 0.448, 0.2612, 0.4823]}, {"w": "and", "b": [0.2671, 0.448, 0.3142, 0.4823]}, {"w": "Practical", "b": [0.3202, 0.448, 0.4261, 0.4823]}, {"w": "Guidelines", "b": [0.4321, 0.448, 0.5619, 0.4823]}]}, {"id": "b_5", "type": "paragraph", "text": "In this chapter, we have covered a wide range of techniques and you may be wonder‐ ing which ones you should use. The configuration in Table 11-2 will work fine in most cases, without requiring much hyperparameter tuning.", "words": [{"w": "In", "b": [0.1429, 0.4892, 0.1614, 0.5106]}, {"w": "this", "b": [0.1667, 0.4892, 0.1974, 0.5106]}, {"w": "chapter,", "b": [0.2028, 0.4892, 0.2687, 0.5106]}, {"w": "we", "b": [0.2741, 0.4892, 0.2972, 0.5106]}, {"w": "have", "b": [0.3026, 0.4892, 0.341, 0.5106]}, {"w": "covered", "b": [0.3463, 0.4892, 0.4118, 0.5106]}, {"w": "a", "b": [0.4172, 0.4892, 0.4263, 0.5106]}, {"w": "wide", "b": [0.4317, 0.4892, 0.4714, 0.5106]}, {"w": "range", "b": [0.4768, 0.4892, 0.5236, 0.5106]}, {"w": "of", "b": [0.529, 0.4892, 0.5458, 0.5106]}, {"w": "techniques", "b": [0.5511, 0.4892, 0.6415, 0.5106]}, {"w": "and", "b": [0.6468, 0.4892, 0.6784, 0.5106]}, {"w": "you", "b": [0.6837, 0.4892, 0.715, 0.5106]}, {"w": "may", "b": [0.7203, 0.4892, 0.7557, 0.5106]}, {"w": "be", "b": [0.7611, 0.4892, 0.7805, 0.5106]}, {"w": "wonder‐", "b": [0.7858, 0.4892, 0.8571, 0.5106]}, {"w": "ing", "b": [0.1428, 0.5083, 0.1696, 0.5297]}, {"w": "which", "b": [0.1774, 0.5083, 0.2283, 0.5297]}, {"w": "ones", "b": [0.2362, 0.5083, 0.2747, 0.5297]}, {"w": "you", "b": [0.2825, 0.5083, 0.3138, 0.5297]}, {"w": "should", "b": [0.3216, 0.5083, 0.3783, 0.5297]}, {"w": "use.", "b": [0.3862, 0.5083, 0.4185, 0.5297]}, {"w": "The", "b": [0.4263, 0.5083, 0.4591, 0.5297]}, {"w": "configuration", "b": [0.467, 0.5083, 0.5808, 0.5297]}, {"w": "in", "b": [0.5886, 0.5083, 0.6056, 0.5297]}, {"w": "Table", "b": [0.6134, 0.5083, 0.6582, 0.5297]}, {"w": "11-2", "b": [0.6661, 0.5083, 0.7035, 0.5297]}, {"w": "will", "b": [0.7113, 0.5083, 0.7417, 0.5297]}, {"w": "work", "b": [0.7495, 0.5083, 0.7925, 0.5297]}, {"w": "fine", "b": [0.8003, 0.5083, 0.8323, 0.5297]}, {"w": "in", "b": [0.8402, 0.5083, 0.8571, 0.5297]}, {"w": "most", "b": [0.1429, 0.5273, 0.1846, 0.5487]}, {"w": "cases,", "b": [0.1893, 0.5273, 0.2361, 0.5487]}, {"w": "without", "b": [0.2409, 0.5273, 0.3062, 0.5487]}, {"w": "requiring", "b": [0.311, 0.5273, 0.3893, 0.5487]}, {"w": "much", "b": [0.394, 0.5273, 0.4417, 0.5487]}, {"w": "hyperparameter", "b": [0.4464, 0.5273, 0.5799, 0.5487]}, {"w": "tuning.", "b": [0.5847, 0.5273, 0.6449, 0.5487]}]}, {"id": "b_6", "type": "equation", "text": "Table 11-2. Default DNN configuration", "words": [{"w": "Table", "b": [0.1429, 0.5652, 0.1844, 0.5858]}, {"w": "11-2.", "b": [0.189, 0.5652, 0.2287, 0.5858]}, {"w": "Default", "b": [0.2332, 0.5652, 0.2911, 0.5858]}, {"w": "DNN", "b": [0.2957, 0.5652, 0.3375, 0.5858]}, {"w": "configuration", "b": [0.342, 0.5652, 0.4473, 0.5858]}]}, {"id": "b_7", "type": "paragraph", "text": "Hyperparameter Default value Kernel initializer: LeCun initialization", "words": [{"w": "Hyperparameter", "b": [0.15, 0.5937, 0.2472, 0.61]}, {"w": "Default", "b": [0.2933, 0.5937, 0.337, 0.61]}, {"w": "value", "b": [0.3404, 0.5937, 0.3726, 0.61]}, {"w": "Kernel", "b": [0.15, 0.6141, 0.1853, 0.6302]}, {"w": "initializer:", "b": [0.1886, 0.6141, 0.2434, 0.6302]}, {"w": "LeCun", "b": [0.2933, 0.6141, 0.327, 0.6302]}, {"w": "initialization", "b": [0.3304, 0.6141, 0.3992, 0.6302]}]}, {"id": "b_8", "type": "paragraph", "text": "Activation function: SELU", "words": [{"w": "Activation", "b": [0.15, 0.6351, 0.2056, 0.6512]}, {"w": "function:", "b": [0.209, 0.6351, 0.2582, 0.6512]}, {"w": "SELU", "b": [0.2933, 0.6351, 0.3204, 0.6512]}]}, {"id": "b_9", "type": "equation", "text": "Normalization: None (self-normalization)", "words": [{"w": "Normalization:", "b": [0.15, 0.6561, 0.2313, 0.6722]}, {"w": "None", "b": [0.2933, 0.6561, 0.3222, 0.6722]}, {"w": "(self-normalization)", "b": [0.3256, 0.6561, 0.4355, 0.6722]}]}, {"id": "b_10", "type": "paragraph", "text": "Regularization: Early stopping", "words": [{"w": "Regularization:", "b": [0.15, 0.6771, 0.2331, 0.6932]}, {"w": "Early", "b": [0.2933, 0.6771, 0.3202, 0.6932]}, {"w": "stopping", "b": [0.3236, 0.6771, 0.372, 0.6932]}]}, {"id": "b_11", "type": "paragraph", "text": "Optimizer: Nadam", "words": [{"w": "Optimizer:", "b": [0.15, 0.6981, 0.2073, 0.7142]}, {"w": "Nadam", "b": [0.2933, 0.6981, 0.3328, 0.7142]}]}, {"id": "b_12", "type": "paragraph", "text": "Learning rate schedule: Performance scheduling", "words": [{"w": "Learning", "b": [0.15, 0.7191, 0.1984, 0.7353]}, {"w": "rate", "b": [0.2018, 0.7191, 0.2238, 0.7353]}, {"w": "schedule:", "b": [0.2272, 0.7191, 0.2791, 0.7353]}, {"w": "Performance", "b": [0.2933, 0.7191, 0.3634, 0.7353]}, {"w": "scheduling", "b": [0.3668, 0.7191, 0.4263, 0.7353]}]}, {"id": "b_13", "type": "paragraph", "text": "Don’t forget to standardize the input features! Of course, you should also try to reuse parts of a pretrained neural network if you can find one that solves a similar problem, or use unsupervised pretraining if you have a lot of unlabeled data, or pretraining on an auxiliary task if you have a lot of labeled data for a similar task.", "words": [{"w": "Don’t", "b": [0.1429, 0.7557, 0.1888, 0.7771]}, {"w": "forget", "b": [0.1942, 0.7557, 0.2437, 0.7771]}, {"w": "to", "b": [0.2491, 0.7557, 0.266, 0.7771]}, {"w": "standardize", "b": [0.2714, 0.7557, 0.368, 0.7771]}, {"w": "the", "b": [0.3734, 0.7557, 0.3998, 0.7771]}, {"w": "input", "b": [0.4052, 0.7557, 0.4501, 0.7771]}, {"w": "features!", "b": [0.4555, 0.7557, 0.5267, 0.7771]}, {"w": "Of", "b": [0.5321, 0.7557, 0.5538, 0.7771]}, {"w": "course,", "b": [0.5592, 0.7557, 0.6187, 0.7771]}, {"w": "you", "b": [0.6241, 0.7557, 0.6553, 0.7771]}, {"w": "should", "b": [0.6607, 0.7557, 0.7175, 0.7771]}, {"w": "also", "b": [0.7229, 0.7557, 0.7556, 0.7771]}, {"w": "try", "b": [0.761, 0.7557, 0.7852, 0.7771]}, {"w": "to", "b": [0.7906, 0.7557, 0.8076, 0.7771]}, {"w": "reuse", "b": [0.813, 0.7557, 0.8571, 0.7771]}, {"w": "parts", "b": [0.1429, 0.7747, 0.1846, 0.7961]}, {"w": "of", "b": [0.1895, 0.7747, 0.2063, 0.7961]}, {"w": "a", "b": [0.2112, 0.7747, 0.2204, 0.7961]}, {"w": "pretrained", "b": [0.2253, 0.7747, 0.3128, 0.7961]}, {"w": "neural", "b": [0.3177, 0.7747, 0.3712, 0.7961]}, {"w": "network", "b": [0.3761, 0.7747, 0.4456, 0.7961]}, {"w": "if", "b": [0.4505, 0.7747, 0.4623, 0.7961]}, {"w": "you", "b": [0.4672, 0.7747, 0.4984, 0.7961]}, {"w": "can", "b": [0.5033, 0.7747, 0.5326, 0.7961]}, {"w": "find", "b": [0.5375, 0.7747, 0.5717, 0.7961]}, {"w": "one", "b": [0.5766, 0.7747, 0.6075, 0.7961]}, {"w": "that", "b": [0.6123, 0.7747, 0.6449, 0.7961]}, {"w": "solves", "b": [0.6498, 0.7747, 0.6995, 0.7961]}, {"w": "a", "b": [0.7044, 0.7747, 0.7135, 0.7961]}, {"w": "similar", "b": [0.7184, 0.7747, 0.7765, 0.7961]}, {"w": "problem,", "b": [0.7813, 0.7747, 0.8571, 0.7961]}, {"w": "or", "b": [0.1429, 0.7938, 0.1612, 0.8152]}, {"w": "use", "b": [0.1667, 0.7938, 0.1942, 0.8152]}, {"w": "unsupervised", "b": [0.1997, 0.7938, 0.3117, 0.8152]}, {"w": "pretraining", "b": [0.3171, 0.7938, 0.4115, 0.8152]}, {"w": "if", "b": [0.417, 0.7938, 0.4287, 0.8152]}, {"w": "you", "b": [0.4341, 0.7938, 0.4654, 0.8152]}, {"w": "have", "b": [0.4708, 0.7938, 0.5092, 0.8152]}, {"w": "a", "b": [0.5147, 0.7938, 0.5238, 0.8152]}, {"w": "lot", "b": [0.5292, 0.7938, 0.5515, 0.8152]}, {"w": "of", "b": [0.5569, 0.7938, 0.5737, 0.8152]}, {"w": "unlabeled", "b": [0.5792, 0.7938, 0.6606, 0.8152]}, {"w": "data,", "b": [0.666, 0.7938, 0.706, 0.8152]}, {"w": "or", "b": [0.7115, 0.7938, 0.7298, 0.8152]}, {"w": "pretraining", "b": [0.7353, 0.7938, 0.8297, 0.8152]}, {"w": "on", "b": [0.8351, 0.7938, 0.8572, 0.8152]}, {"w": "an", "b": [0.1429, 0.8128, 0.1634, 0.8342]}, {"w": "auxiliary", "b": [0.1681, 0.8128, 0.2413, 0.8342]}, {"w": "task", "b": [0.246, 0.8128, 0.2795, 0.8342]}, {"w": "if", "b": [0.2842, 0.8128, 0.2959, 0.8342]}, {"w": "you", "b": [0.3007, 0.8128, 0.3319, 0.8342]}, {"w": "have", "b": [0.3367, 0.8128, 0.375, 0.8342]}, {"w": "a", "b": [0.3798, 0.8128, 0.3889, 0.8342]}, {"w": "lot", "b": [0.3937, 0.8128, 0.4159, 0.8342]}, {"w": "of", "b": [0.4206, 0.8128, 0.4374, 0.8342]}, {"w": "labeled", "b": [0.4422, 0.8128, 0.5011, 0.8342]}, {"w": "data", "b": [0.5059, 0.8128, 0.5411, 0.8342]}, {"w": "for", "b": [0.5458, 0.8128, 0.5704, 0.8342]}, {"w": "a", "b": [0.5751, 0.8128, 0.5842, 0.8342]}, {"w": "similar", "b": [0.589, 0.8128, 0.647, 0.8342]}, {"w": "task.", "b": [0.6517, 0.8128, 0.6899, 0.8342]}]}, {"id": "b_14", "type": "equation", "text": "The default configuration in Table 11-2 may need to be tweaked:", "words": [{"w": "The", "b": [0.1429, 0.8409, 0.1757, 0.8623]}, {"w": "default", "b": [0.1804, 0.8409, 0.2379, 0.8623]}, {"w": "configuration", "b": [0.2426, 0.8409, 0.3564, 0.8623]}, {"w": "in", "b": [0.3612, 0.8409, 0.3782, 0.8623]}, {"w": "Table", "b": [0.3829, 0.8409, 0.4277, 0.8623]}, {"w": "11-2", "b": [0.4324, 0.8409, 0.4698, 0.8623]}, {"w": "may", "b": [0.4745, 0.8409, 0.5099, 0.8623]}, {"w": "need", "b": [0.5147, 0.8409, 0.5548, 0.8623]}, {"w": "to", "b": [0.5595, 0.8409, 0.5765, 0.8623]}, {"w": "be", "b": [0.5812, 0.8409, 0.6007, 0.8623]}, {"w": "tweaked:", "b": [0.6054, 0.8409, 0.6789, 0.8623]}]}, {"id": "b_15", "type": "paragraph", "text": "Summary and Practical Guidelines | 363", "words": [{"w": "Summary", "b": [0.5965, 0.9225, 0.6528, 0.9388]}, {"w": "and", "b": [0.6556, 0.9225, 0.678, 0.9388]}, {"w": "Practical", "b": [0.6808, 0.9225, 0.7312, 0.9388]}, {"w": "Guidelines", "b": [0.7341, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "363", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 390, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "• If your model self-normalizes:", "words": [{"w": "•", "b": [0.16, 0.0851, 0.1682, 0.1065]}, {"w": "If", "b": [0.1786, 0.0851, 0.1918, 0.1065]}, {"w": "your", "b": [0.1966, 0.0851, 0.2355, 0.1065]}, {"w": "model", "b": [0.2403, 0.0851, 0.2931, 0.1065]}, {"w": "self-normalizes:", "b": [0.2978, 0.0851, 0.43, 0.1065]}]}, {"id": "b_1", "type": "paragraph", "text": "— If it overfits the training set, then you should add alpha dropout (and always", "words": [{"w": "—", "b": [0.1807, 0.1102, 0.1999, 0.1316]}, {"w": "If", "b": [0.2044, 0.1102, 0.2176, 0.1316]}, {"w": "it", "b": [0.2238, 0.1102, 0.2357, 0.1316]}, {"w": "overfits", "b": [0.2419, 0.1102, 0.3045, 0.1316]}, {"w": "the", "b": [0.3106, 0.1102, 0.3369, 0.1316]}, {"w": "training", "b": [0.3431, 0.1102, 0.41, 0.1316]}, {"w": "set,", "b": [0.4162, 0.1102, 0.4438, 0.1316]}, {"w": "then", "b": [0.4499, 0.1102, 0.4877, 0.1316]}, {"w": "you", "b": [0.4938, 0.1102, 0.525, 0.1316]}, {"w": "should", "b": [0.5312, 0.1102, 0.5879, 0.1316]}, {"w": "add", "b": [0.5941, 0.1102, 0.6252, 0.1316]}, {"w": "alpha", "b": [0.6314, 0.1102, 0.677, 0.1316]}, {"w": "dropout", "b": [0.6831, 0.1102, 0.7514, 0.1316]}, {"w": "(and", "b": [0.7576, 0.1102, 0.7963, 0.1316]}, {"w": "always", "b": [0.8025, 0.1102, 0.8571, 0.1316]}]}, {"id": "b_2", "type": "paragraph", "text": "use early stopping as well). Do not use other regularization methods, or else they would break self-normalization.", "words": [{"w": "use", "b": [0.2044, 0.1293, 0.2319, 0.1507]}, {"w": "early", "b": [0.2386, 0.1293, 0.2791, 0.1507]}, {"w": "stopping", "b": [0.2857, 0.1293, 0.3589, 0.1507]}, {"w": "as", "b": [0.3656, 0.1293, 0.3823, 0.1507]}, {"w": "well).", "b": [0.389, 0.1293, 0.4346, 0.1507]}, {"w": "Do", "b": [0.4412, 0.1293, 0.4672, 0.1507]}, {"w": "not", "b": [0.4738, 0.1293, 0.5022, 0.1507]}, {"w": "use", "b": [0.5088, 0.1293, 0.5363, 0.1507]}, {"w": "other", "b": [0.543, 0.1293, 0.5877, 0.1507]}, {"w": "regularization", "b": [0.5943, 0.1293, 0.7109, 0.1507]}, {"w": "methods,", "b": [0.7175, 0.1293, 0.7949, 0.1507]}, {"w": "or", "b": [0.8015, 0.1293, 0.8199, 0.1507]}, {"w": "else", "b": [0.8265, 0.1293, 0.8571, 0.1507]}, {"w": "they", "b": [0.2044, 0.1483, 0.2403, 0.1697]}, {"w": "would", "b": [0.245, 0.1483, 0.2972, 0.1697]}, {"w": "break", "b": [0.302, 0.1483, 0.3486, 0.1697]}, {"w": "self-normalization.", "b": [0.3533, 0.1483, 0.5117, 0.1697]}]}, {"id": "b_3", "type": "paragraph", "text": "• If your model cannot self-normalize (e.g., it is a recurrent net or it contains skip connections):", "words": [{"w": "•", "b": [0.16, 0.1734, 0.1681, 0.1948]}, {"w": "If", "b": [0.1786, 0.1734, 0.1918, 0.1948]}, {"w": "your", "b": [0.1977, 0.1734, 0.2366, 0.1948]}, {"w": "model", "b": [0.2425, 0.1734, 0.2953, 0.1948]}, {"w": "cannot", "b": [0.3011, 0.1734, 0.3588, 0.1948]}, {"w": "self-normalize", "b": [0.3647, 0.1734, 0.4844, 0.1948]}, {"w": "(e.g.,", "b": [0.4903, 0.1734, 0.5303, 0.1948]}, {"w": "it", "b": [0.5361, 0.1734, 0.5481, 0.1948]}, {"w": "is", "b": [0.5539, 0.1734, 0.5671, 0.1948]}, {"w": "a", "b": [0.573, 0.1734, 0.5821, 0.1948]}, {"w": "recurrent", "b": [0.5879, 0.1734, 0.6661, 0.1948]}, {"w": "net", "b": [0.6719, 0.1734, 0.6985, 0.1948]}, {"w": "or", "b": [0.7043, 0.1734, 0.7227, 0.1948]}, {"w": "it", "b": [0.7285, 0.1734, 0.7404, 0.1948]}, {"w": "contains", "b": [0.7463, 0.1734, 0.8168, 0.1948]}, {"w": "skip", "b": [0.8227, 0.1734, 0.8571, 0.1948]}, {"w": "connections):", "b": [0.1786, 0.1924, 0.292, 0.2139]}]}, {"id": "b_4", "type": "paragraph", "text": "— You can try using ELU (or another activation function) instead of SELU, it", "words": [{"w": "—", "b": [0.1807, 0.2175, 0.1999, 0.2389]}, {"w": "You", "b": [0.2044, 0.2175, 0.2367, 0.2389]}, {"w": "can", "b": [0.2445, 0.2175, 0.2738, 0.2389]}, {"w": "try", "b": [0.2815, 0.2175, 0.3058, 0.2389]}, {"w": "using", "b": [0.3135, 0.2175, 0.359, 0.2389]}, {"w": "ELU", "b": [0.3667, 0.2175, 0.4043, 0.2389]}, {"w": "(or", "b": [0.412, 0.2175, 0.4376, 0.2389]}, {"w": "another", "b": [0.4453, 0.2175, 0.5105, 0.2389]}, {"w": "activation", "b": [0.5183, 0.2175, 0.6005, 0.2389]}, {"w": "function)", "b": [0.6083, 0.2175, 0.6869, 0.2389]}, {"w": "instead", "b": [0.6946, 0.2175, 0.7546, 0.2389]}, {"w": "of", "b": [0.7623, 0.2175, 0.7791, 0.2389]}, {"w": "SELU,", "b": [0.7869, 0.2175, 0.8375, 0.2389]}, {"w": "it", "b": [0.8452, 0.2175, 0.8571, 0.2389]}]}, {"id": "b_5", "type": "paragraph", "text": "may perform better. Make sure to change the initialization method accord‐ ingly (e.g., He init for ELU or ReLU).", "words": [{"w": "may", "b": [0.2044, 0.2366, 0.2398, 0.258]}, {"w": "perform", "b": [0.2475, 0.2366, 0.3166, 0.258]}, {"w": "better.", "b": [0.3243, 0.2366, 0.3765, 0.258]}, {"w": "Make", "b": [0.3842, 0.2366, 0.4308, 0.258]}, {"w": "sure", "b": [0.4385, 0.2366, 0.4738, 0.258]}, {"w": "to", "b": [0.4815, 0.2366, 0.4985, 0.258]}, {"w": "change", "b": [0.5063, 0.2366, 0.5653, 0.258]}, {"w": "the", "b": [0.5731, 0.2366, 0.5994, 0.258]}, {"w": "initialization", "b": [0.6071, 0.2366, 0.7131, 0.258]}, {"w": "method", "b": [0.7208, 0.2366, 0.7859, 0.258]}, {"w": "accord‐", "b": [0.7936, 0.2366, 0.8571, 0.258]}, {"w": "ingly", "b": [0.2044, 0.2556, 0.2459, 0.277]}, {"w": "(e.g.,", "b": [0.2507, 0.2556, 0.2907, 0.277]}, {"w": "He", "b": [0.2955, 0.2556, 0.3197, 0.277]}, {"w": "init", "b": [0.3245, 0.2556, 0.3534, 0.277]}, {"w": "for", "b": [0.3581, 0.2556, 0.3826, 0.277]}, {"w": "ELU", "b": [0.3874, 0.2556, 0.4249, 0.277]}, {"w": "or", "b": [0.4296, 0.2556, 0.448, 0.277]}, {"w": "ReLU).", "b": [0.4527, 0.2556, 0.5122, 0.277]}]}, {"id": "b_6", "type": "paragraph", "text": "— If it is a deep network, you should use Batch Normalization after every hidden", "words": [{"w": "—", "b": [0.1807, 0.2807, 0.1999, 0.3021]}, {"w": "If", "b": [0.2044, 0.2807, 0.2176, 0.3021]}, {"w": "it", "b": [0.2226, 0.2807, 0.2345, 0.3021]}, {"w": "is", "b": [0.2394, 0.2807, 0.2527, 0.3021]}, {"w": "a", "b": [0.2576, 0.2807, 0.2667, 0.3021]}, {"w": "deep", "b": [0.2717, 0.2807, 0.3113, 0.3021]}, {"w": "network,", "b": [0.3162, 0.2807, 0.3905, 0.3021]}, {"w": "you", "b": [0.3955, 0.2807, 0.4267, 0.3021]}, {"w": "should", "b": [0.4317, 0.2807, 0.4884, 0.3021]}, {"w": "use", "b": [0.4933, 0.2807, 0.5209, 0.3021]}, {"w": "Batch", "b": [0.5258, 0.2807, 0.5731, 0.3021]}, {"w": "Normalization", "b": [0.578, 0.2807, 0.6999, 0.3021]}, {"w": "after", "b": [0.7048, 0.2807, 0.7431, 0.3021]}, {"w": "every", "b": [0.748, 0.2807, 0.7932, 0.3021]}, {"w": "hidden", "b": [0.7982, 0.2807, 0.8571, 0.3021]}]}, {"id": "b_7", "type": "paragraph", "text": "layer. If it overfits the training set, you can also try using max-norm or ℓ2 reg‐ ularization.", "words": [{"w": "layer.", "b": [0.2044, 0.2998, 0.248, 0.3212]}, {"w": "If", "b": [0.2534, 0.2998, 0.2666, 0.3212]}, {"w": "it", "b": [0.272, 0.2998, 0.2839, 0.3212]}, {"w": "overfits", "b": [0.2893, 0.2998, 0.3519, 0.3212]}, {"w": "the", "b": [0.3573, 0.2998, 0.3836, 0.3212]}, {"w": "training", "b": [0.389, 0.2998, 0.4559, 0.3212]}, {"w": "set,", "b": [0.4613, 0.2998, 0.4889, 0.3212]}, {"w": "you", "b": [0.4943, 0.2998, 0.5255, 0.3212]}, {"w": "can", "b": [0.5309, 0.2998, 0.5602, 0.3212]}, {"w": "also", "b": [0.5656, 0.2998, 0.5983, 0.3212]}, {"w": "try", "b": [0.6037, 0.2998, 0.6279, 0.3212]}, {"w": "using", "b": [0.6333, 0.2998, 0.6787, 0.3212]}, {"w": "max-norm", "b": [0.6841, 0.2998, 0.7744, 0.3212]}, {"w": "or", "b": [0.7797, 0.2998, 0.7981, 0.3212]}, {"w": "ℓ2", "b": [0.8035, 0.2998, 0.818, 0.3221]}, {"w": "reg‐", "b": [0.8234, 0.2998, 0.8571, 0.3212]}, {"w": "ularization.", "b": [0.2044, 0.3188, 0.2994, 0.3402]}]}, {"id": "b_8", "type": "paragraph", "text": "• If you need a sparse model, you can use ℓ1 regularization (and optionally zero out the tiny weights after training). If you need an even sparser model, you can try using FTRL instead of Nadam optimization, along with ℓ1 regularization. In any case, this will break self-normalization, so you will need to switch to BN if your model is deep.", "words": [{"w": "•", "b": [0.16, 0.3439, 0.1682, 0.3653]}, {"w": "If", "b": [0.1786, 0.3439, 0.1918, 0.3653]}, {"w": "you", "b": [0.1967, 0.3439, 0.228, 0.3653]}, {"w": "need", "b": [0.2329, 0.3439, 0.273, 0.3653]}, {"w": "a", "b": [0.2779, 0.3439, 0.287, 0.3653]}, {"w": "sparse", "b": [0.2919, 0.3439, 0.3438, 0.3653]}, {"w": "model,", "b": [0.3487, 0.3439, 0.4063, 0.3653]}, {"w": "you", "b": [0.4112, 0.3439, 0.4424, 0.3653]}, {"w": "can", "b": [0.4473, 0.3439, 0.4767, 0.3653]}, {"w": "use", "b": [0.4816, 0.3439, 0.5091, 0.3653]}, {"w": "ℓ1", "b": [0.514, 0.3439, 0.5286, 0.3662]}, {"w": "regularization", "b": [0.5335, 0.3439, 0.6501, 0.3653]}, {"w": "(and", "b": [0.6548, 0.3439, 0.6936, 0.3653]}, {"w": "optionally", "b": [0.6983, 0.3439, 0.783, 0.3653]}, {"w": "zero", "b": [0.7878, 0.3439, 0.8237, 0.3653]}, {"w": "out", "b": [0.8284, 0.3439, 0.8565, 0.3653]}, {"w": "the", "b": [0.1786, 0.363, 0.2049, 0.3844]}, {"w": "tiny", "b": [0.2116, 0.363, 0.244, 0.3844]}, {"w": "weights", "b": [0.2507, 0.363, 0.3139, 0.3844]}, {"w": "after", "b": [0.3205, 0.363, 0.3588, 0.3844]}, {"w": "training).", "b": [0.3655, 0.363, 0.4444, 0.3844]}, {"w": "If", "b": [0.451, 0.363, 0.4643, 0.3844]}, {"w": "you", "b": [0.471, 0.363, 0.5022, 0.3844]}, {"w": "need", "b": [0.5089, 0.363, 0.549, 0.3844]}, {"w": "an", "b": [0.5557, 0.363, 0.5762, 0.3844]}, {"w": "even", "b": [0.5829, 0.363, 0.6217, 0.3844]}, {"w": "sparser", "b": [0.6284, 0.363, 0.688, 0.3844]}, {"w": "model,", "b": [0.6947, 0.363, 0.7523, 0.3844]}, {"w": "you", "b": [0.7589, 0.363, 0.7902, 0.3844]}, {"w": "can", "b": [0.7969, 0.363, 0.8262, 0.3844]}, {"w": "try", "b": [0.8329, 0.363, 0.8571, 0.3844]}, {"w": "using", "b": [0.1786, 0.382, 0.224, 0.4034]}, {"w": "FTRL", "b": [0.2301, 0.382, 0.2781, 0.4034]}, {"w": "instead", "b": [0.2843, 0.382, 0.3442, 0.4034]}, {"w": "of", "b": [0.3503, 0.382, 0.3671, 0.4034]}, {"w": "Nadam", "b": [0.3732, 0.382, 0.4345, 0.4034]}, {"w": "optimization,", "b": [0.4406, 0.382, 0.553, 0.4034]}, {"w": "along", "b": [0.5591, 0.382, 0.6053, 0.4034]}, {"w": "with", "b": [0.6114, 0.382, 0.6487, 0.4034]}, {"w": "ℓ1", "b": [0.6548, 0.382, 0.6694, 0.4043]}, {"w": "regularization.", "b": [0.6755, 0.382, 0.7968, 0.4034]}, {"w": "In", "b": [0.8029, 0.382, 0.8214, 0.4034]}, {"w": "any", "b": [0.8275, 0.382, 0.8571, 0.4034]}, {"w": "case,", "b": [0.1786, 0.4011, 0.2178, 0.4225]}, {"w": "this", "b": [0.224, 0.4011, 0.2547, 0.4225]}, {"w": "will", "b": [0.2609, 0.4011, 0.2913, 0.4225]}, {"w": "break", "b": [0.2975, 0.4011, 0.3442, 0.4225]}, {"w": "self-normalization,", "b": [0.3504, 0.4011, 0.5088, 0.4225]}, {"w": "so", "b": [0.515, 0.4011, 0.5333, 0.4225]}, {"w": "you", "b": [0.5395, 0.4011, 0.5707, 0.4225]}, {"w": "will", "b": [0.5769, 0.4011, 0.6073, 0.4225]}, {"w": "need", "b": [0.6135, 0.4011, 0.6537, 0.4225]}, {"w": "to", "b": [0.6599, 0.4011, 0.6768, 0.4225]}, {"w": "switch", "b": [0.6831, 0.4011, 0.7369, 0.4225]}, {"w": "to", "b": [0.7431, 0.4011, 0.76, 0.4225]}, {"w": "BN", "b": [0.7663, 0.4011, 0.794, 0.4225]}, {"w": "if", "b": [0.8002, 0.4011, 0.812, 0.4225]}, {"w": "your", "b": [0.8182, 0.4011, 0.8571, 0.4225]}, {"w": "model", "b": [0.1786, 0.4201, 0.2314, 0.4415]}, {"w": "is", "b": [0.2361, 0.4201, 0.2493, 0.4415]}, {"w": "deep.", "b": [0.2541, 0.4201, 0.2978, 0.4415]}]}, {"id": "b_9", "type": "paragraph", "text": "• If you need a low-latency model (one that performs lightning-fast predictions), you may need to use less layers, avoid Batch Normalization, and possibly replace the SELU activation function with the leaky ReLU. Having a sparse model will also help. You may also want to reduce the float precision from 32-bits to 16-bit (or even 8-bits) (see ???).", "words": [{"w": "•", "b": [0.16, 0.4452, 0.1682, 0.4666]}, {"w": "If", "b": [0.1786, 0.4452, 0.1918, 0.4666]}, {"w": "you", "b": [0.1987, 0.4452, 0.23, 0.4666]}, {"w": "need", "b": [0.2369, 0.4452, 0.277, 0.4666]}, {"w": "a", "b": [0.2839, 0.4452, 0.293, 0.4666]}, {"w": "low-latency", "b": [0.2999, 0.4452, 0.3965, 0.4666]}, {"w": "model", "b": [0.4034, 0.4452, 0.4562, 0.4666]}, {"w": "(one", "b": [0.4631, 0.4452, 0.5012, 0.4666]}, {"w": "that", "b": [0.5081, 0.4452, 0.5407, 0.4666]}, {"w": "performs", "b": [0.5476, 0.4452, 0.6243, 0.4666]}, {"w": "lightning-fast", "b": [0.6312, 0.4452, 0.7438, 0.4666]}, {"w": "predictions),", "b": [0.7507, 0.4452, 0.8571, 0.4666]}, {"w": "you", "b": [0.1786, 0.4642, 0.2098, 0.4857]}, {"w": "may", "b": [0.2154, 0.4642, 0.2508, 0.4857]}, {"w": "need", "b": [0.2564, 0.4642, 0.2965, 0.4857]}, {"w": "to", "b": [0.302, 0.4642, 0.319, 0.4857]}, {"w": "use", "b": [0.3246, 0.4642, 0.3521, 0.4857]}, {"w": "less", "b": [0.3577, 0.4642, 0.3871, 0.4857]}, {"w": "layers,", "b": [0.3927, 0.4642, 0.4453, 0.4857]}, {"w": "avoid", "b": [0.4508, 0.4642, 0.4965, 0.4857]}, {"w": "Batch", "b": [0.502, 0.4642, 0.5493, 0.4857]}, {"w": "Normalization,", "b": [0.5549, 0.4642, 0.6815, 0.4857]}, {"w": "and", "b": [0.6871, 0.4642, 0.7186, 0.4857]}, {"w": "possibly", "b": [0.7242, 0.4642, 0.792, 0.4857]}, {"w": "replace", "b": [0.7976, 0.4642, 0.8571, 0.4857]}, {"w": "the", "b": [0.1786, 0.4833, 0.2049, 0.5047]}, {"w": "SELU", "b": [0.2123, 0.4833, 0.2597, 0.5047]}, {"w": "activation", "b": [0.2671, 0.4833, 0.3494, 0.5047]}, {"w": "function", "b": [0.3568, 0.4833, 0.4281, 0.5047]}, {"w": "with", "b": [0.4355, 0.4833, 0.4729, 0.5047]}, {"w": "the", "b": [0.4803, 0.4833, 0.5066, 0.5047]}, {"w": "leaky", "b": [0.514, 0.4833, 0.5572, 0.5047]}, {"w": "ReLU.", "b": [0.5646, 0.4833, 0.6153, 0.5047]}, {"w": "Having", "b": [0.6227, 0.4833, 0.6833, 0.5047]}, {"w": "a", "b": [0.6907, 0.4833, 0.6998, 0.5047]}, {"w": "sparse", "b": [0.7072, 0.4833, 0.7591, 0.5047]}, {"w": "model", "b": [0.7665, 0.4833, 0.8193, 0.5047]}, {"w": "will", "b": [0.8267, 0.4833, 0.8571, 0.5047]}, {"w": "also", "b": [0.1786, 0.5023, 0.2113, 0.5238]}, {"w": "help.", "b": [0.2173, 0.5023, 0.2576, 0.5238]}, {"w": "You", "b": [0.2636, 0.5023, 0.296, 0.5238]}, {"w": "may", "b": [0.302, 0.5023, 0.3374, 0.5238]}, {"w": "also", "b": [0.3434, 0.5023, 0.3761, 0.5238]}, {"w": "want", "b": [0.3821, 0.5023, 0.4229, 0.5238]}, {"w": "to", "b": [0.4289, 0.5023, 0.4459, 0.5238]}, {"w": "reduce", "b": [0.4519, 0.5023, 0.5082, 0.5238]}, {"w": "the", "b": [0.5143, 0.5023, 0.5406, 0.5238]}, {"w": "float", "b": [0.5466, 0.5023, 0.5838, 0.5238]}, {"w": "precision", "b": [0.5898, 0.5023, 0.667, 0.5238]}, {"w": "from", "b": [0.673, 0.5023, 0.7146, 0.5238]}, {"w": "32-bits", "b": [0.7206, 0.5023, 0.7782, 0.5238]}, {"w": "to", "b": [0.7842, 0.5023, 0.8012, 0.5238]}, {"w": "16-bit", "b": [0.8072, 0.5023, 0.8571, 0.5238]}, {"w": "(or", "b": [0.1786, 0.5214, 0.2041, 0.5428]}, {"w": "even", "b": [0.2089, 0.5214, 0.2476, 0.5428]}, {"w": "8-bits)", "b": [0.2524, 0.5214, 0.3071, 0.5428]}, {"w": "(see", "b": [0.3119, 0.5214, 0.3444, 0.5428]}, {"w": "???).", "b": [0.3492, 0.5214, 0.3848, 0.5428]}]}, {"id": "b_10", "type": "paragraph", "text": "• If you are building a risk-sensitive application, or inference latency is not very important in your application, you can use MC Dropout to boost performance and get more reliable probability estimates, along with uncertainty estimates.", "words": [{"w": "•", "b": [0.16, 0.5465, 0.1681, 0.5679]}, {"w": "If", "b": [0.1786, 0.5465, 0.1918, 0.5679]}, {"w": "you", "b": [0.1992, 0.5465, 0.2304, 0.5679]}, {"w": "are", "b": [0.2377, 0.5465, 0.2635, 0.5679]}, {"w": "building", "b": [0.2708, 0.5465, 0.341, 0.5679]}, {"w": "a", "b": [0.3484, 0.5465, 0.3575, 0.5679]}, {"w": "risk-sensitive", "b": [0.3648, 0.5465, 0.4751, 0.5679]}, {"w": "application,", "b": [0.4824, 0.5465, 0.5802, 0.5679]}, {"w": "or", "b": [0.5875, 0.5465, 0.6058, 0.5679]}, {"w": "inference", "b": [0.6132, 0.5465, 0.6908, 0.5679]}, {"w": "latency", "b": [0.6981, 0.5465, 0.7571, 0.5679]}, {"w": "is", "b": [0.7645, 0.5465, 0.7777, 0.5679]}, {"w": "not", "b": [0.785, 0.5465, 0.8134, 0.5679]}, {"w": "very", "b": [0.8207, 0.5465, 0.8571, 0.5679]}, {"w": "important", "b": [0.1786, 0.5655, 0.2629, 0.5869]}, {"w": "in", "b": [0.27, 0.5655, 0.2869, 0.5869]}, {"w": "your", "b": [0.294, 0.5655, 0.3329, 0.5869]}, {"w": "application,", "b": [0.34, 0.5655, 0.4377, 0.5869]}, {"w": "you", "b": [0.4447, 0.5655, 0.4759, 0.5869]}, {"w": "can", "b": [0.483, 0.5655, 0.5123, 0.5869]}, {"w": "use", "b": [0.5193, 0.5655, 0.5469, 0.5869]}, {"w": "MC", "b": [0.5539, 0.5655, 0.5863, 0.5869]}, {"w": "Dropout", "b": [0.5934, 0.5655, 0.666, 0.5869]}, {"w": "to", "b": [0.673, 0.5655, 0.69, 0.5869]}, {"w": "boost", "b": [0.697, 0.5655, 0.7428, 0.5869]}, {"w": "performance", "b": [0.7499, 0.5655, 0.8571, 0.5869]}, {"w": "and", "b": [0.1786, 0.5846, 0.2101, 0.606]}, {"w": "get", "b": [0.2148, 0.5846, 0.2398, 0.606]}, {"w": "more", "b": [0.2445, 0.5846, 0.2888, 0.606]}, {"w": "reliable", "b": [0.2935, 0.5846, 0.3548, 0.606]}, {"w": "probability", "b": [0.3595, 0.5846, 0.4515, 0.606]}, {"w": "estimates,", "b": [0.4562, 0.5846, 0.5381, 0.606]}, {"w": "along", "b": [0.5428, 0.5846, 0.589, 0.606]}, {"w": "with", "b": [0.5937, 0.5846, 0.631, 0.606]}, {"w": "uncertainty", "b": [0.6358, 0.5846, 0.7316, 0.606]}, {"w": "estimates.", "b": [0.7364, 0.5846, 0.8182, 0.606]}]}, {"id": "b_11", "type": "paragraph", "text": "With these guidelines, you are now ready to train very deep nets! I hope you are now convinced that you can go a very long way using just Keras. However, there may come a time when you need to have even more control, for example to write a custom loss function or to tweak the training algorithm. For such cases, you will need to use TensorFlow’s lower-level API, as we will see in the next chapter.", "words": [{"w": "With", "b": [0.1429, 0.6187, 0.1853, 0.6402]}, {"w": "these", "b": [0.1906, 0.6187, 0.2334, 0.6402]}, {"w": "guidelines,", "b": [0.2387, 0.6187, 0.3284, 0.6402]}, {"w": "you", "b": [0.3337, 0.6187, 0.365, 0.6402]}, {"w": "are", "b": [0.3703, 0.6187, 0.396, 0.6402]}, {"w": "now", "b": [0.4013, 0.6187, 0.4376, 0.6402]}, {"w": "ready", "b": [0.4429, 0.6187, 0.4892, 0.6402]}, {"w": "to", "b": [0.4944, 0.6187, 0.5114, 0.6402]}, {"w": "train", "b": [0.5167, 0.6187, 0.5569, 0.6402]}, {"w": "very", "b": [0.5622, 0.6187, 0.5986, 0.6402]}, {"w": "deep", "b": [0.6039, 0.6187, 0.6435, 0.6402]}, {"w": "nets!", "b": [0.6488, 0.6187, 0.6888, 0.6402]}, {"w": "I", "b": [0.6941, 0.6187, 0.7012, 0.6402]}, {"w": "hope", "b": [0.7065, 0.6187, 0.748, 0.6402]}, {"w": "you", "b": [0.7533, 0.6187, 0.7845, 0.6402]}, {"w": "are", "b": [0.7898, 0.6187, 0.8156, 0.6402]}, {"w": "now", "b": [0.8208, 0.6187, 0.8571, 0.6402]}, {"w": "convinced", "b": [0.1428, 0.6378, 0.2285, 0.6592]}, {"w": "that", "b": [0.2367, 0.6378, 0.2693, 0.6592]}, {"w": "you", "b": [0.2775, 0.6378, 0.3088, 0.6592]}, {"w": "can", "b": [0.317, 0.6378, 0.3464, 0.6592]}, {"w": "go", "b": [0.3546, 0.6378, 0.375, 0.6592]}, {"w": "a", "b": [0.3832, 0.6378, 0.3924, 0.6592]}, {"w": "very", "b": [0.4006, 0.6378, 0.437, 0.6592]}, {"w": "long", "b": [0.4452, 0.6378, 0.4823, 0.6592]}, {"w": "way", "b": [0.4905, 0.6378, 0.5231, 0.6592]}, {"w": "using", "b": [0.5313, 0.6378, 0.5768, 0.6592]}, {"w": "just", "b": [0.585, 0.6378, 0.6154, 0.6592]}, {"w": "Keras.", "b": [0.6236, 0.6378, 0.6753, 0.6592]}, {"w": "However,", "b": [0.6835, 0.6378, 0.7624, 0.6592]}, {"w": "there", "b": [0.7706, 0.6378, 0.8135, 0.6592]}, {"w": "may", "b": [0.8217, 0.6378, 0.8571, 0.6592]}, {"w": "come", "b": [0.1429, 0.6568, 0.1882, 0.6783]}, {"w": "a", "b": [0.193, 0.6568, 0.2022, 0.6783]}, {"w": "time", "b": [0.207, 0.6568, 0.2448, 0.6783]}, {"w": "when", "b": [0.2496, 0.6568, 0.2953, 0.6783]}, {"w": "you", "b": [0.3001, 0.6568, 0.3313, 0.6783]}, {"w": "need", "b": [0.3361, 0.6568, 0.3762, 0.6783]}, {"w": "to", "b": [0.381, 0.6568, 0.398, 0.6783]}, {"w": "have", "b": [0.4028, 0.6568, 0.4412, 0.6783]}, {"w": "even", "b": [0.446, 0.6568, 0.4848, 0.6783]}, {"w": "more", "b": [0.4896, 0.6568, 0.5338, 0.6783]}, {"w": "control,", "b": [0.5386, 0.6568, 0.6038, 0.6783]}, {"w": "for", "b": [0.6086, 0.6568, 0.6331, 0.6783]}, {"w": "example", "b": [0.6379, 0.6568, 0.7075, 0.6783]}, {"w": "to", "b": [0.7123, 0.6568, 0.7292, 0.6783]}, {"w": "write", "b": [0.734, 0.6568, 0.7768, 0.6783]}, {"w": "a", "b": [0.7816, 0.6568, 0.7908, 0.6783]}, {"w": "custom", "b": [0.7956, 0.6568, 0.8571, 0.6783]}, {"w": "loss", "b": [0.1429, 0.6759, 0.174, 0.6973]}, {"w": "function", "b": [0.1798, 0.6759, 0.2512, 0.6973]}, {"w": "or", "b": [0.2569, 0.6759, 0.2753, 0.6973]}, {"w": "to", "b": [0.281, 0.6759, 0.298, 0.6973]}, {"w": "tweak", "b": [0.3037, 0.6759, 0.3527, 0.6973]}, {"w": "the", "b": [0.3584, 0.6759, 0.3847, 0.6973]}, {"w": "training", "b": [0.3905, 0.6759, 0.4574, 0.6973]}, {"w": "algorithm.", "b": [0.4631, 0.6759, 0.5505, 0.6973]}, {"w": "For", "b": [0.5563, 0.6759, 0.5852, 0.6973]}, {"w": "such", "b": [0.591, 0.6759, 0.6296, 0.6973]}, {"w": "cases,", "b": [0.6353, 0.6759, 0.6822, 0.6973]}, {"w": "you", "b": [0.6879, 0.6759, 0.7192, 0.6973]}, {"w": "will", "b": [0.7249, 0.6759, 0.7553, 0.6973]}, {"w": "need", "b": [0.761, 0.6759, 0.8011, 0.6973]}, {"w": "to", "b": [0.8069, 0.6759, 0.8238, 0.6973]}, {"w": "use", "b": [0.8296, 0.6759, 0.8571, 0.6973]}, {"w": "TensorFlow’s", "b": [0.1429, 0.6949, 0.2514, 0.7163]}, {"w": "lower-level", "b": [0.2561, 0.6949, 0.3477, 0.7163]}, {"w": "API,", "b": [0.3524, 0.6949, 0.3904, 0.7163]}, {"w": "as", "b": [0.3951, 0.6949, 0.4119, 0.7163]}, {"w": "we", "b": [0.4167, 0.6949, 0.4398, 0.7163]}, {"w": "will", "b": [0.4445, 0.6949, 0.4749, 0.7163]}, {"w": "see", "b": [0.4796, 0.6949, 0.505, 0.7163]}, {"w": "in", "b": [0.5097, 0.6949, 0.5267, 0.7163]}, {"w": "the", "b": [0.5314, 0.6949, 0.5578, 0.7163]}, {"w": "next", "b": [0.5625, 0.6949, 0.5989, 0.7163]}, {"w": "chapter.", "b": [0.6037, 0.6949, 0.6696, 0.7163]}]}, {"id": "b_12", "type": "paragraph", "text": "Exercises", "words": [{"w": "Exercises", "b": [0.1428, 0.7293, 0.2533, 0.7636]}]}, {"id": "b_13", "type": "paragraph", "text": "1. Is it okay to initialize all the weights to the same value as long as that value is selected randomly using He initialization?", "words": [{"w": "1.", "b": [0.1534, 0.7766, 0.1682, 0.798]}, {"w": "Is", "b": [0.1786, 0.7766, 0.1929, 0.798]}, {"w": "it", "b": [0.2002, 0.7766, 0.2121, 0.798]}, {"w": "okay", "b": [0.2194, 0.7766, 0.2587, 0.798]}, {"w": "to", "b": [0.266, 0.7766, 0.283, 0.798]}, {"w": "initialize", "b": [0.2903, 0.7766, 0.3624, 0.798]}, {"w": "all", "b": [0.3697, 0.7766, 0.3894, 0.798]}, {"w": "the", "b": [0.3967, 0.7766, 0.4231, 0.798]}, {"w": "weights", "b": [0.4304, 0.7766, 0.4936, 0.798]}, {"w": "to", "b": [0.5009, 0.7766, 0.5179, 0.798]}, {"w": "the", "b": [0.5252, 0.7766, 0.5515, 0.798]}, {"w": "same", "b": [0.5588, 0.7766, 0.6015, 0.798]}, {"w": "value", "b": [0.6089, 0.7766, 0.6528, 0.798]}, {"w": "as", "b": [0.6601, 0.7766, 0.6769, 0.798]}, {"w": "long", "b": [0.6843, 0.7766, 0.7213, 0.798]}, {"w": "as", "b": [0.7286, 0.7766, 0.7454, 0.798]}, {"w": "that", "b": [0.7527, 0.7766, 0.7853, 0.798]}, {"w": "value", "b": [0.7926, 0.7766, 0.8366, 0.798]}, {"w": "is", "b": [0.8439, 0.7766, 0.8571, 0.798]}, {"w": "selected", "b": [0.1786, 0.7956, 0.2442, 0.817]}, {"w": "randomly", "b": [0.2489, 0.7956, 0.3307, 0.817]}, {"w": "using", "b": [0.3355, 0.7956, 0.3809, 0.817]}, {"w": "He", "b": [0.3856, 0.7956, 0.4099, 0.817]}, {"w": "initialization?", "b": [0.4147, 0.7956, 0.5285, 0.817]}]}, {"id": "b_14", "type": "paragraph", "text": "2. Is it okay to initialize the bias terms to 0?", "words": [{"w": "2.", "b": [0.1534, 0.8207, 0.1682, 0.8421]}, {"w": "Is", "b": [0.1786, 0.8207, 0.1929, 0.8421]}, {"w": "it", "b": [0.1976, 0.8207, 0.2095, 0.8421]}, {"w": "okay", "b": [0.2143, 0.8207, 0.2535, 0.8421]}, {"w": "to", "b": [0.2583, 0.8207, 0.2753, 0.8421]}, {"w": "initialize", "b": [0.28, 0.8207, 0.3521, 0.8421]}, {"w": "the", "b": [0.3568, 0.8207, 0.3831, 0.8421]}, {"w": "bias", "b": [0.3879, 0.8207, 0.4208, 0.8421]}, {"w": "terms", "b": [0.4256, 0.8207, 0.4732, 0.8421]}, {"w": "to", "b": [0.4779, 0.8207, 0.4949, 0.8421]}, {"w": "0?", "b": [0.4996, 0.8207, 0.5175, 0.8421]}]}, {"id": "b_15", "type": "paragraph", "text": "3. Name three advantages of the SELU activation function over ReLU.", "words": [{"w": "3.", "b": [0.1534, 0.8458, 0.1682, 0.8672]}, {"w": "Name", "b": [0.1786, 0.8458, 0.2286, 0.8672]}, {"w": "three", "b": [0.2333, 0.8458, 0.2762, 0.8672]}, {"w": "advantages", "b": [0.2809, 0.8458, 0.3726, 0.8672]}, {"w": "of", "b": [0.3774, 0.8458, 0.3941, 0.8672]}, {"w": "the", "b": [0.3989, 0.8458, 0.4252, 0.8672]}, {"w": "SELU", "b": [0.4299, 0.8458, 0.4774, 0.8672]}, {"w": "activation", "b": [0.4821, 0.8458, 0.5643, 0.8672]}, {"w": "function", "b": [0.5691, 0.8458, 0.6405, 0.8672]}, {"w": "over", "b": [0.6452, 0.8458, 0.682, 0.8672]}, {"w": "ReLU.", "b": [0.6868, 0.8458, 0.7375, 0.8672]}]}, {"id": "b_16", "type": "paragraph", "text": "364 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "364", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2746, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 391, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "4. In which cases would you want to use each of the following activation functions: SELU, leaky ReLU (and its variants), ReLU, tanh, logistic, and softmax?", "words": [{"w": "4.", "b": [0.1534, 0.0791, 0.1682, 0.1005]}, {"w": "In", "b": [0.1786, 0.0791, 0.1971, 0.1005]}, {"w": "which", "b": [0.2026, 0.0791, 0.2535, 0.1005]}, {"w": "cases", "b": [0.2591, 0.0791, 0.3012, 0.1005]}, {"w": "would", "b": [0.3067, 0.0791, 0.359, 0.1005]}, {"w": "you", "b": [0.3645, 0.0791, 0.3958, 0.1005]}, {"w": "want", "b": [0.4013, 0.0791, 0.4421, 0.1005]}, {"w": "to", "b": [0.4477, 0.0791, 0.4646, 0.1005]}, {"w": "use", "b": [0.4702, 0.0791, 0.4978, 0.1005]}, {"w": "each", "b": [0.5033, 0.0791, 0.5412, 0.1005]}, {"w": "of", "b": [0.5468, 0.0791, 0.5636, 0.1005]}, {"w": "the", "b": [0.5691, 0.0791, 0.5955, 0.1005]}, {"w": "following", "b": [0.601, 0.0791, 0.68, 0.1005]}, {"w": "activation", "b": [0.6855, 0.0791, 0.7678, 0.1005]}, {"w": "functions:", "b": [0.7733, 0.0791, 0.8571, 0.1005]}, {"w": "SELU,", "b": [0.1786, 0.0981, 0.2292, 0.1195]}, {"w": "leaky", "b": [0.2339, 0.0981, 0.2771, 0.1195]}, {"w": "ReLU", "b": [0.2818, 0.0981, 0.3293, 0.1195]}, {"w": "(and", "b": [0.334, 0.0981, 0.3728, 0.1195]}, {"w": "its", "b": [0.3775, 0.0981, 0.3971, 0.1195]}, {"w": "variants),", "b": [0.4018, 0.0981, 0.48, 0.1195]}, {"w": "ReLU,", "b": [0.4848, 0.0981, 0.5354, 0.1195]}, {"w": "tanh,", "b": [0.5402, 0.0981, 0.5829, 0.1195]}, {"w": "logistic,", "b": [0.5877, 0.0981, 0.6521, 0.1195]}, {"w": "and", "b": [0.6568, 0.0981, 0.6883, 0.1195]}, {"w": "softmax?", "b": [0.6931, 0.0981, 0.7678, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "5. What may happen if you set the momentum hyperparameter too close to 1 (e.g., 0.99999) when using an SGD optimizer?", "words": [{"w": "5.", "b": [0.1534, 0.1241, 0.1682, 0.1455]}, {"w": "What", "b": [0.1786, 0.1241, 0.225, 0.1455]}, {"w": "may", "b": [0.2323, 0.1241, 0.2677, 0.1455]}, {"w": "happen", "b": [0.2749, 0.1241, 0.3368, 0.1455]}, {"w": "if", "b": [0.3441, 0.1241, 0.3558, 0.1455]}, {"w": "you", "b": [0.3631, 0.1241, 0.3943, 0.1455]}, {"w": "set", "b": [0.4016, 0.1241, 0.4244, 0.1455]}, {"w": "the", "b": [0.4316, 0.1241, 0.458, 0.1455]}, {"w": "momentum", "b": [0.4652, 0.1273, 0.5444, 0.1424]}, {"w": "hyperparameter", "b": [0.5516, 0.1241, 0.6851, 0.1455]}, {"w": "too", "b": [0.6923, 0.1241, 0.7199, 0.1455]}, {"w": "close", "b": [0.7272, 0.1241, 0.7684, 0.1455]}, {"w": "to", "b": [0.7756, 0.1241, 0.7926, 0.1455]}, {"w": "1", "b": [0.7998, 0.1241, 0.8098, 0.1455]}, {"w": "(e.g.,", "b": [0.8171, 0.1241, 0.8571, 0.1455]}, {"w": "0.99999)", "b": [0.1786, 0.144, 0.2505, 0.1655]}, {"w": "when", "b": [0.2553, 0.144, 0.3009, 0.1655]}, {"w": "using", "b": [0.3056, 0.144, 0.3511, 0.1655]}, {"w": "an", "b": [0.3558, 0.144, 0.3763, 0.1655]}, {"w": "SGD", "b": [0.3811, 0.1472, 0.4108, 0.1623]}, {"w": "optimizer?", "b": [0.4155, 0.144, 0.5048, 0.1655]}]}, {"id": "b_2", "type": "paragraph", "text": "6. Name three ways you can produce a sparse model.", "words": [{"w": "6.", "b": [0.1534, 0.1691, 0.1682, 0.1906]}, {"w": "Name", "b": [0.1786, 0.1691, 0.2286, 0.1906]}, {"w": "three", "b": [0.2333, 0.1691, 0.2762, 0.1906]}, {"w": "ways", "b": [0.2809, 0.1691, 0.3212, 0.1906]}, {"w": "you", "b": [0.3259, 0.1691, 0.3572, 0.1906]}, {"w": "can", "b": [0.3619, 0.1691, 0.3913, 0.1906]}, {"w": "produce", "b": [0.396, 0.1691, 0.465, 0.1906]}, {"w": "a", "b": [0.4697, 0.1691, 0.4789, 0.1906]}, {"w": "sparse", "b": [0.4836, 0.1691, 0.5355, 0.1906]}, {"w": "model.", "b": [0.5403, 0.1691, 0.5978, 0.1906]}]}, {"id": "b_3", "type": "paragraph", "text": "7. Does dropout slow down training? Does it slow down inference (i.e., making predictions on new instances)? What are about MC dropout?", "words": [{"w": "7.", "b": [0.1534, 0.1942, 0.1682, 0.2156]}, {"w": "Does", "b": [0.1786, 0.1942, 0.221, 0.2156]}, {"w": "dropout", "b": [0.2293, 0.1942, 0.2976, 0.2156]}, {"w": "slow", "b": [0.306, 0.1942, 0.3438, 0.2156]}, {"w": "down", "b": [0.3521, 0.1942, 0.3994, 0.2156]}, {"w": "training?", "b": [0.4077, 0.1942, 0.4826, 0.2156]}, {"w": "Does", "b": [0.4909, 0.1942, 0.5333, 0.2156]}, {"w": "it", "b": [0.5416, 0.1942, 0.5536, 0.2156]}, {"w": "slow", "b": [0.5619, 0.1942, 0.5997, 0.2156]}, {"w": "down", "b": [0.6081, 0.1942, 0.6553, 0.2156]}, {"w": "inference", "b": [0.6637, 0.1942, 0.7413, 0.2156]}, {"w": "(i.e.,", "b": [0.7496, 0.1942, 0.7855, 0.2156]}, {"w": "making", "b": [0.7939, 0.1942, 0.8571, 0.2156]}, {"w": "predictions", "b": [0.1786, 0.2133, 0.2731, 0.2347]}, {"w": "on", "b": [0.2778, 0.2133, 0.2998, 0.2347]}, {"w": "new", "b": [0.3046, 0.2133, 0.3391, 0.2347]}, {"w": "instances)?", "b": [0.3438, 0.2133, 0.4357, 0.2347]}, {"w": "What", "b": [0.4405, 0.2133, 0.4869, 0.2347]}, {"w": "are", "b": [0.4917, 0.2133, 0.5174, 0.2347]}, {"w": "about", "b": [0.5221, 0.2133, 0.5699, 0.2347]}, {"w": "MC", "b": [0.5746, 0.2133, 0.607, 0.2347]}, {"w": "dropout?", "b": [0.6118, 0.2133, 0.688, 0.2347]}]}, {"id": "b_4", "type": "paragraph", "text": "8. Deep Learning.", "words": [{"w": "8.", "b": [0.1534, 0.2384, 0.1682, 0.2598]}, {"w": "Deep", "b": [0.1786, 0.2384, 0.2225, 0.2598]}, {"w": "Learning.", "b": [0.2272, 0.2384, 0.307, 0.2598]}]}, {"id": "b_5", "type": "paragraph", "text": "a. Build a DNN with five hidden layers of 100 neurons each, He initialization,", "words": [{"w": "a.", "b": [0.1801, 0.2635, 0.1939, 0.2849]}, {"w": "Build", "b": [0.2044, 0.2635, 0.2495, 0.2849]}, {"w": "a", "b": [0.2566, 0.2635, 0.2657, 0.2849]}, {"w": "DNN", "b": [0.2728, 0.2635, 0.319, 0.2849]}, {"w": "with", "b": [0.3261, 0.2635, 0.3634, 0.2849]}, {"w": "five", "b": [0.3705, 0.2635, 0.4007, 0.2849]}, {"w": "hidden", "b": [0.4078, 0.2635, 0.4667, 0.2849]}, {"w": "layers", "b": [0.4738, 0.2635, 0.5216, 0.2849]}, {"w": "of", "b": [0.5287, 0.2635, 0.5455, 0.2849]}, {"w": "100", "b": [0.5525, 0.2635, 0.5825, 0.2849]}, {"w": "neurons", "b": [0.5896, 0.2635, 0.6583, 0.2849]}, {"w": "each,", "b": [0.6653, 0.2635, 0.708, 0.2849]}, {"w": "He", "b": [0.7151, 0.2635, 0.7394, 0.2849]}, {"w": "initialization,", "b": [0.7464, 0.2635, 0.8571, 0.2849]}]}, {"id": "b_6", "type": "paragraph", "text": "and the ELU activation function.", "words": [{"w": "and", "b": [0.2044, 0.2825, 0.2359, 0.3039]}, {"w": "the", "b": [0.2406, 0.2825, 0.267, 0.3039]}, {"w": "ELU", "b": [0.2717, 0.2825, 0.3092, 0.3039]}, {"w": "activation", "b": [0.314, 0.2825, 0.3962, 0.3039]}, {"w": "function.", "b": [0.4009, 0.2825, 0.4771, 0.3039]}]}, {"id": "b_7", "type": "paragraph", "text": "b. Using Adam optimization and early stopping, try training it on MNIST but", "words": [{"w": "b.", "b": [0.1792, 0.3076, 0.194, 0.329]}, {"w": "Using", "b": [0.2044, 0.3076, 0.253, 0.329]}, {"w": "Adam", "b": [0.2601, 0.3076, 0.3112, 0.329]}, {"w": "optimization", "b": [0.3183, 0.3076, 0.4259, 0.329]}, {"w": "and", "b": [0.433, 0.3076, 0.4646, 0.329]}, {"w": "early", "b": [0.4717, 0.3076, 0.5123, 0.329]}, {"w": "stopping,", "b": [0.5194, 0.3076, 0.5973, 0.329]}, {"w": "try", "b": [0.6045, 0.3076, 0.6287, 0.329]}, {"w": "training", "b": [0.6358, 0.3076, 0.7028, 0.329]}, {"w": "it", "b": [0.7099, 0.3076, 0.7218, 0.329]}, {"w": "on", "b": [0.729, 0.3076, 0.751, 0.329]}, {"w": "MNIST", "b": [0.7581, 0.3076, 0.822, 0.329]}, {"w": "but", "b": [0.8291, 0.3076, 0.8571, 0.329]}]}, {"id": "b_8", "type": "paragraph", "text": "only on digits 0 to 4, as we will use transfer learning for digits 5 to 9 in the next exercise. You will need a softmax output layer with five neurons, and as always make sure to save checkpoints at regular intervals and save the final model so you can reuse it later.", "words": [{"w": "only", "b": [0.2044, 0.3267, 0.2412, 0.3481]}, {"w": "on", "b": [0.2481, 0.3267, 0.2701, 0.3481]}, {"w": "digits", "b": [0.277, 0.3267, 0.3229, 0.3481]}, {"w": "0", "b": [0.3297, 0.3267, 0.3397, 0.3481]}, {"w": "to", "b": [0.3466, 0.3267, 0.3636, 0.3481]}, {"w": "4,", "b": [0.3704, 0.3267, 0.3852, 0.3481]}, {"w": "as", "b": [0.3921, 0.3267, 0.4089, 0.3481]}, {"w": "we", "b": [0.4157, 0.3267, 0.4388, 0.3481]}, {"w": "will", "b": [0.4457, 0.3267, 0.4761, 0.3481]}, {"w": "use", "b": [0.483, 0.3267, 0.5105, 0.3481]}, {"w": "transfer", "b": [0.5174, 0.3267, 0.5824, 0.3481]}, {"w": "learning", "b": [0.5893, 0.3267, 0.6584, 0.3481]}, {"w": "for", "b": [0.6653, 0.3267, 0.6898, 0.3481]}, {"w": "digits", "b": [0.6966, 0.3267, 0.7426, 0.3481]}, {"w": "5", "b": [0.7494, 0.3267, 0.7594, 0.3481]}, {"w": "to", "b": [0.7663, 0.3267, 0.7833, 0.3481]}, {"w": "9", "b": [0.7901, 0.3267, 0.8001, 0.3481]}, {"w": "in", "b": [0.807, 0.3267, 0.824, 0.3481]}, {"w": "the", "b": [0.8308, 0.3267, 0.8571, 0.3481]}, {"w": "next", "b": [0.2044, 0.3457, 0.2408, 0.3671]}, {"w": "exercise.", "b": [0.247, 0.3457, 0.3179, 0.3671]}, {"w": "You", "b": [0.3241, 0.3457, 0.3565, 0.3671]}, {"w": "will", "b": [0.3627, 0.3457, 0.3931, 0.3671]}, {"w": "need", "b": [0.3993, 0.3457, 0.4394, 0.3671]}, {"w": "a", "b": [0.4456, 0.3457, 0.4547, 0.3671]}, {"w": "softmax", "b": [0.4609, 0.3457, 0.5278, 0.3671]}, {"w": "output", "b": [0.534, 0.3457, 0.5903, 0.3671]}, {"w": "layer", "b": [0.5966, 0.3457, 0.6367, 0.3671]}, {"w": "with", "b": [0.6429, 0.3457, 0.6803, 0.3671]}, {"w": "five", "b": [0.6865, 0.3457, 0.7167, 0.3671]}, {"w": "neurons,", "b": [0.7229, 0.3457, 0.7964, 0.3671]}, {"w": "and", "b": [0.8026, 0.3457, 0.8341, 0.3671]}, {"w": "as", "b": [0.8403, 0.3457, 0.8571, 0.3671]}, {"w": "always", "b": [0.2044, 0.3648, 0.259, 0.3862]}, {"w": "make", "b": [0.2664, 0.3648, 0.3118, 0.3862]}, {"w": "sure", "b": [0.3192, 0.3648, 0.3545, 0.3862]}, {"w": "to", "b": [0.3619, 0.3648, 0.3789, 0.3862]}, {"w": "save", "b": [0.3862, 0.3648, 0.4212, 0.3862]}, {"w": "checkpoints", "b": [0.4285, 0.3648, 0.5286, 0.3862]}, {"w": "at", "b": [0.536, 0.3648, 0.5511, 0.3862]}, {"w": "regular", "b": [0.5585, 0.3648, 0.618, 0.3862]}, {"w": "intervals", "b": [0.6254, 0.3648, 0.6972, 0.3862]}, {"w": "and", "b": [0.7046, 0.3648, 0.7362, 0.3862]}, {"w": "save", "b": [0.7436, 0.3648, 0.7785, 0.3862]}, {"w": "the", "b": [0.7859, 0.3648, 0.8122, 0.3862]}, {"w": "final", "b": [0.8196, 0.3648, 0.8571, 0.3862]}, {"w": "model", "b": [0.2044, 0.3838, 0.2572, 0.4052]}, {"w": "so", "b": [0.2619, 0.3838, 0.2802, 0.4052]}, {"w": "you", "b": [0.2849, 0.3838, 0.3162, 0.4052]}, {"w": "can", "b": [0.3209, 0.3838, 0.3502, 0.4052]}, {"w": "reuse", "b": [0.355, 0.3838, 0.3991, 0.4052]}, {"w": "it", "b": [0.4039, 0.3838, 0.4158, 0.4052]}, {"w": "later.", "b": [0.4205, 0.3838, 0.4609, 0.4052]}]}, {"id": "b_9", "type": "equation", "text": "c. Tune the hyperparameters using cross-validation and see what precision you", "words": [{"w": "c.", "b": [0.1804, 0.4089, 0.1939, 0.4303]}, {"w": "Tune", "b": [0.2044, 0.4089, 0.2465, 0.4303]}, {"w": "the", "b": [0.253, 0.4089, 0.2794, 0.4303]}, {"w": "hyperparameters", "b": [0.2859, 0.4089, 0.427, 0.4303]}, {"w": "using", "b": [0.4335, 0.4089, 0.479, 0.4303]}, {"w": "cross-validation", "b": [0.4855, 0.4089, 0.6187, 0.4303]}, {"w": "and", "b": [0.6253, 0.4089, 0.6568, 0.4303]}, {"w": "see", "b": [0.6633, 0.4089, 0.6887, 0.4303]}, {"w": "what", "b": [0.6952, 0.4089, 0.7357, 0.4303]}, {"w": "precision", "b": [0.7422, 0.4089, 0.8194, 0.4303]}, {"w": "you", "b": [0.8259, 0.4089, 0.8571, 0.4303]}]}, {"id": "b_10", "type": "paragraph", "text": "can achieve.", "words": [{"w": "can", "b": [0.2044, 0.4279, 0.2337, 0.4494]}, {"w": "achieve.", "b": [0.2384, 0.4279, 0.3052, 0.4494]}]}, {"id": "b_11", "type": "paragraph", "text": "d. Now try adding Batch Normalization and compare the learning curves: is it", "words": [{"w": "d.", "b": [0.1782, 0.453, 0.194, 0.4745]}, {"w": "Now", "b": [0.2044, 0.453, 0.2442, 0.4745]}, {"w": "try", "b": [0.2513, 0.453, 0.2755, 0.4745]}, {"w": "adding", "b": [0.2826, 0.453, 0.3405, 0.4745]}, {"w": "Batch", "b": [0.3475, 0.453, 0.3948, 0.4745]}, {"w": "Normalization", "b": [0.4019, 0.453, 0.5237, 0.4745]}, {"w": "and", "b": [0.5308, 0.453, 0.5623, 0.4745]}, {"w": "compare", "b": [0.5694, 0.453, 0.6421, 0.4745]}, {"w": "the", "b": [0.6492, 0.453, 0.6755, 0.4745]}, {"w": "learning", "b": [0.6826, 0.453, 0.7517, 0.4745]}, {"w": "curves:", "b": [0.7587, 0.453, 0.8178, 0.4745]}, {"w": "is", "b": [0.8249, 0.453, 0.8381, 0.4745]}, {"w": "it", "b": [0.8452, 0.453, 0.8571, 0.4745]}]}, {"id": "b_12", "type": "paragraph", "text": "converging faster than before? Does it produce a better model?", "words": [{"w": "converging", "b": [0.2044, 0.4721, 0.2974, 0.4935]}, {"w": "faster", "b": [0.3022, 0.4721, 0.3481, 0.4935]}, {"w": "than", "b": [0.3528, 0.4721, 0.3908, 0.4935]}, {"w": "before?", "b": [0.3955, 0.4721, 0.4562, 0.4935]}, {"w": "Does", "b": [0.461, 0.4721, 0.5034, 0.4935]}, {"w": "it", "b": [0.5081, 0.4721, 0.5201, 0.4935]}, {"w": "produce", "b": [0.5248, 0.4721, 0.5938, 0.4935]}, {"w": "a", "b": [0.5985, 0.4721, 0.6077, 0.4935]}, {"w": "better", "b": [0.6124, 0.4721, 0.6611, 0.4935]}, {"w": "model?", "b": [0.6659, 0.4721, 0.7266, 0.4935]}]}, {"id": "b_13", "type": "paragraph", "text": "e. Is the model overfitting the training set? Try adding dropout to every layer", "words": [{"w": "e.", "b": [0.1804, 0.4972, 0.194, 0.5186]}, {"w": "Is", "b": [0.2044, 0.4972, 0.2186, 0.5186]}, {"w": "the", "b": [0.2261, 0.4972, 0.2525, 0.5186]}, {"w": "model", "b": [0.2599, 0.4972, 0.3127, 0.5186]}, {"w": "overfitting", "b": [0.3202, 0.4972, 0.4082, 0.5186]}, {"w": "the", "b": [0.4157, 0.4972, 0.4421, 0.5186]}, {"w": "training", "b": [0.4495, 0.4972, 0.5165, 0.5186]}, {"w": "set?", "b": [0.5239, 0.4972, 0.5547, 0.5186]}, {"w": "Try", "b": [0.5622, 0.4972, 0.5912, 0.5186]}, {"w": "adding", "b": [0.5986, 0.4972, 0.6565, 0.5186]}, {"w": "dropout", "b": [0.664, 0.4972, 0.7323, 0.5186]}, {"w": "to", "b": [0.7398, 0.4972, 0.7568, 0.5186]}, {"w": "every", "b": [0.7642, 0.4972, 0.8095, 0.5186]}, {"w": "layer", "b": [0.8169, 0.4972, 0.8571, 0.5186]}]}, {"id": "b_14", "type": "paragraph", "text": "and try again. Does it help?", "words": [{"w": "and", "b": [0.2044, 0.5162, 0.2359, 0.5376]}, {"w": "try", "b": [0.2406, 0.5162, 0.2649, 0.5376]}, {"w": "again.", "b": [0.2696, 0.5162, 0.3194, 0.5376]}, {"w": "Does", "b": [0.3241, 0.5162, 0.3666, 0.5376]}, {"w": "it", "b": [0.3713, 0.5162, 0.3832, 0.5376]}, {"w": "help?", "b": [0.3879, 0.5162, 0.432, 0.5376]}]}, {"id": "b_15", "type": "paragraph", "text": "9. Transfer learning.", "words": [{"w": "9.", "b": [0.1534, 0.5413, 0.1682, 0.5627]}, {"w": "Transfer", "b": [0.1786, 0.5413, 0.2484, 0.5627]}, {"w": "learning.", "b": [0.2531, 0.5413, 0.327, 0.5627]}]}, {"id": "b_16", "type": "paragraph", "text": "a. Create a new DNN that reuses all the pretrained hidden layers of the previous", "words": [{"w": "a.", "b": [0.1801, 0.5664, 0.1939, 0.5878]}, {"w": "Create", "b": [0.2044, 0.5664, 0.2588, 0.5878]}, {"w": "a", "b": [0.264, 0.5664, 0.2732, 0.5878]}, {"w": "new", "b": [0.2784, 0.5664, 0.313, 0.5878]}, {"w": "DNN", "b": [0.3182, 0.5664, 0.3645, 0.5878]}, {"w": "that", "b": [0.3698, 0.5664, 0.4024, 0.5878]}, {"w": "reuses", "b": [0.4076, 0.5664, 0.4594, 0.5878]}, {"w": "all", "b": [0.4647, 0.5664, 0.4844, 0.5878]}, {"w": "the", "b": [0.4896, 0.5664, 0.516, 0.5878]}, {"w": "pretrained", "b": [0.5212, 0.5664, 0.6088, 0.5878]}, {"w": "hidden", "b": [0.6141, 0.5664, 0.673, 0.5878]}, {"w": "layers", "b": [0.6783, 0.5664, 0.7261, 0.5878]}, {"w": "of", "b": [0.7314, 0.5664, 0.7482, 0.5878]}, {"w": "the", "b": [0.7535, 0.5664, 0.7798, 0.5878]}, {"w": "previous", "b": [0.7851, 0.5664, 0.8571, 0.5878]}]}, {"id": "b_17", "type": "paragraph", "text": "model, freezes them, and replaces the softmax output layer with a new one.", "words": [{"w": "model,", "b": [0.2044, 0.5855, 0.2619, 0.6069]}, {"w": "freezes", "b": [0.2667, 0.5855, 0.3235, 0.6069]}, {"w": "them,", "b": [0.3282, 0.5855, 0.3764, 0.6069]}, {"w": "and", "b": [0.3811, 0.5855, 0.4127, 0.6069]}, {"w": "replaces", "b": [0.4174, 0.5855, 0.4846, 0.6069]}, {"w": "the", "b": [0.4893, 0.5855, 0.5157, 0.6069]}, {"w": "softmax", "b": [0.5204, 0.5855, 0.5872, 0.6069]}, {"w": "output", "b": [0.592, 0.5855, 0.6483, 0.6069]}, {"w": "layer", "b": [0.6531, 0.5855, 0.6933, 0.6069]}, {"w": "with", "b": [0.698, 0.5855, 0.7353, 0.6069]}, {"w": "a", "b": [0.7401, 0.5855, 0.7492, 0.6069]}, {"w": "new", "b": [0.7539, 0.5855, 0.7884, 0.6069]}, {"w": "one.", "b": [0.7932, 0.5855, 0.8288, 0.6069]}]}, {"id": "b_18", "type": "paragraph", "text": "b. Train this new DNN on digits 5 to 9, using only 100 images per digit, and time", "words": [{"w": "b.", "b": [0.1792, 0.6106, 0.194, 0.632]}, {"w": "Train", "b": [0.2044, 0.6106, 0.2493, 0.632]}, {"w": "this", "b": [0.2541, 0.6106, 0.2848, 0.632]}, {"w": "new", "b": [0.2896, 0.6106, 0.3241, 0.632]}, {"w": "DNN", "b": [0.3289, 0.6106, 0.3752, 0.632]}, {"w": "on", "b": [0.3799, 0.6106, 0.402, 0.632]}, {"w": "digits", "b": [0.4067, 0.6106, 0.4527, 0.632]}, {"w": "5", "b": [0.4574, 0.6106, 0.4674, 0.632]}, {"w": "to", "b": [0.4722, 0.6106, 0.4892, 0.632]}, {"w": "9,", "b": [0.494, 0.6106, 0.5087, 0.632]}, {"w": "using", "b": [0.5135, 0.6106, 0.5589, 0.632]}, {"w": "only", "b": [0.5637, 0.6106, 0.6005, 0.632]}, {"w": "100", "b": [0.6053, 0.6106, 0.6353, 0.632]}, {"w": "images", "b": [0.6401, 0.6106, 0.6981, 0.632]}, {"w": "per", "b": [0.7029, 0.6106, 0.7304, 0.632]}, {"w": "digit,", "b": [0.7352, 0.6106, 0.7782, 0.632]}, {"w": "and", "b": [0.783, 0.6106, 0.8145, 0.632]}, {"w": "time", "b": [0.8193, 0.6106, 0.8571, 0.632]}]}, {"id": "b_19", "type": "paragraph", "text": "how long it takes. Despite this small number of examples, can you achieve high precision?", "words": [{"w": "how", "b": [0.2044, 0.6296, 0.2404, 0.651]}, {"w": "long", "b": [0.2483, 0.6296, 0.2853, 0.651]}, {"w": "it", "b": [0.2932, 0.6296, 0.3051, 0.651]}, {"w": "takes.", "b": [0.313, 0.6296, 0.3601, 0.651]}, {"w": "Despite", "b": [0.3679, 0.6296, 0.4314, 0.651]}, {"w": "this", "b": [0.4393, 0.6296, 0.47, 0.651]}, {"w": "small", "b": [0.4779, 0.6296, 0.5223, 0.651]}, {"w": "number", "b": [0.5302, 0.6296, 0.5965, 0.651]}, {"w": "of", "b": [0.6043, 0.6296, 0.6211, 0.651]}, {"w": "examples,", "b": [0.629, 0.6296, 0.7109, 0.651]}, {"w": "can", "b": [0.7188, 0.6296, 0.7481, 0.651]}, {"w": "you", "b": [0.756, 0.6296, 0.7873, 0.651]}, {"w": "achieve", "b": [0.7951, 0.6296, 0.8571, 0.651]}, {"w": "high", "b": [0.2044, 0.6487, 0.2419, 0.6701]}, {"w": "precision?", "b": [0.2467, 0.6487, 0.3317, 0.6701]}]}, {"id": "b_20", "type": "paragraph", "text": "c. Try caching the frozen layers, and train the model again: how much faster is it", "words": [{"w": "c.", "b": [0.1804, 0.6738, 0.1939, 0.6952]}, {"w": "Try", "b": [0.2044, 0.6737, 0.2334, 0.6952]}, {"w": "caching", "b": [0.2385, 0.6737, 0.3031, 0.6952]}, {"w": "the", "b": [0.3082, 0.6737, 0.3345, 0.6952]}, {"w": "frozen", "b": [0.3396, 0.6737, 0.3931, 0.6952]}, {"w": "layers,", "b": [0.3982, 0.6737, 0.4508, 0.6952]}, {"w": "and", "b": [0.4559, 0.6737, 0.4874, 0.6952]}, {"w": "train", "b": [0.4925, 0.6737, 0.5327, 0.6952]}, {"w": "the", "b": [0.5378, 0.6737, 0.5642, 0.6952]}, {"w": "model", "b": [0.5693, 0.6737, 0.6221, 0.6952]}, {"w": "again:", "b": [0.6272, 0.6737, 0.6769, 0.6952]}, {"w": "how", "b": [0.682, 0.6737, 0.718, 0.6952]}, {"w": "much", "b": [0.7231, 0.6737, 0.7708, 0.6952]}, {"w": "faster", "b": [0.7759, 0.6737, 0.8218, 0.6952]}, {"w": "is", "b": [0.8269, 0.6737, 0.8401, 0.6952]}, {"w": "it", "b": [0.8452, 0.6737, 0.8571, 0.6952]}]}, {"id": "b_21", "type": "paragraph", "text": "now?", "words": [{"w": "now?", "b": [0.2044, 0.6928, 0.2486, 0.7142]}]}, {"id": "b_22", "type": "paragraph", "text": "d. Try again reusing just four hidden layers instead of five. Can you achieve a", "words": [{"w": "d.", "b": [0.1782, 0.7179, 0.194, 0.7393]}, {"w": "Try", "b": [0.2044, 0.7179, 0.2334, 0.7393]}, {"w": "again", "b": [0.2407, 0.7179, 0.2857, 0.7393]}, {"w": "reusing", "b": [0.2931, 0.7179, 0.3551, 0.7393]}, {"w": "just", "b": [0.3624, 0.7179, 0.3928, 0.7393]}, {"w": "four", "b": [0.4002, 0.7179, 0.4357, 0.7393]}, {"w": "hidden", "b": [0.4431, 0.7179, 0.502, 0.7393]}, {"w": "layers", "b": [0.5094, 0.7179, 0.5572, 0.7393]}, {"w": "instead", "b": [0.5645, 0.7179, 0.6245, 0.7393]}, {"w": "of", "b": [0.6319, 0.7179, 0.6486, 0.7393]}, {"w": "five.", "b": [0.656, 0.7179, 0.691, 0.7393]}, {"w": "Can", "b": [0.6983, 0.7179, 0.7327, 0.7393]}, {"w": "you", "b": [0.74, 0.7179, 0.7713, 0.7393]}, {"w": "achieve", "b": [0.7786, 0.7179, 0.8407, 0.7393]}, {"w": "a", "b": [0.848, 0.7179, 0.8571, 0.7393]}]}, {"id": "b_23", "type": "paragraph", "text": "higher precision?", "words": [{"w": "higher", "b": [0.2044, 0.7369, 0.2585, 0.7584]}, {"w": "precision?", "b": [0.2633, 0.7369, 0.3483, 0.7584]}]}, {"id": "b_24", "type": "paragraph", "text": "e. Now unfreeze the top two hidden layers and continue training: can you get", "words": [{"w": "e.", "b": [0.1804, 0.762, 0.194, 0.7834]}, {"w": "Now", "b": [0.2044, 0.762, 0.2442, 0.7834]}, {"w": "unfreeze", "b": [0.2515, 0.762, 0.3231, 0.7834]}, {"w": "the", "b": [0.3304, 0.762, 0.3567, 0.7834]}, {"w": "top", "b": [0.3639, 0.762, 0.3918, 0.7834]}, {"w": "two", "b": [0.3991, 0.762, 0.4303, 0.7834]}, {"w": "hidden", "b": [0.4376, 0.762, 0.4965, 0.7834]}, {"w": "layers", "b": [0.5038, 0.762, 0.5516, 0.7834]}, {"w": "and", "b": [0.5588, 0.762, 0.5904, 0.7834]}, {"w": "continue", "b": [0.5976, 0.762, 0.6709, 0.7834]}, {"w": "training:", "b": [0.6782, 0.762, 0.7498, 0.7834]}, {"w": "can", "b": [0.7571, 0.762, 0.7864, 0.7834]}, {"w": "you", "b": [0.7937, 0.762, 0.8249, 0.7834]}, {"w": "get", "b": [0.8322, 0.762, 0.8571, 0.7834]}]}, {"id": "b_25", "type": "paragraph", "text": "the model to perform even better?", "words": [{"w": "the", "b": [0.2044, 0.7811, 0.2307, 0.8025]}, {"w": "model", "b": [0.2354, 0.7811, 0.2882, 0.8025]}, {"w": "to", "b": [0.293, 0.7811, 0.3099, 0.8025]}, {"w": "perform", "b": [0.3147, 0.7811, 0.3838, 0.8025]}, {"w": "even", "b": [0.3885, 0.7811, 0.4272, 0.8025]}, {"w": "better?", "b": [0.432, 0.7811, 0.4886, 0.8025]}]}, {"id": "b_26", "type": "paragraph", "text": "10. Pretraining on an auxiliary task.", "words": [{"w": "10.", "b": [0.1434, 0.8062, 0.1682, 0.8276]}, {"w": "Pretraining", "b": [0.1786, 0.8062, 0.2738, 0.8276]}, {"w": "on", "b": [0.2785, 0.8062, 0.3006, 0.8276]}, {"w": "an", "b": [0.3053, 0.8062, 0.3258, 0.8276]}, {"w": "auxiliary", "b": [0.3306, 0.8062, 0.4037, 0.8276]}, {"w": "task.", "b": [0.4084, 0.8062, 0.4466, 0.8276]}]}, {"id": "b_27", "type": "paragraph", "text": "a. In this exercise you will build a DNN that compares two MNIST digit images", "words": [{"w": "a.", "b": [0.1801, 0.8313, 0.1939, 0.8527]}, {"w": "In", "b": [0.2044, 0.8313, 0.2229, 0.8527]}, {"w": "this", "b": [0.2284, 0.8313, 0.2591, 0.8527]}, {"w": "exercise", "b": [0.2647, 0.8313, 0.3309, 0.8527]}, {"w": "you", "b": [0.3364, 0.8313, 0.3677, 0.8527]}, {"w": "will", "b": [0.3733, 0.8313, 0.4037, 0.8527]}, {"w": "build", "b": [0.4092, 0.8313, 0.4527, 0.8527]}, {"w": "a", "b": [0.4583, 0.8313, 0.4675, 0.8527]}, {"w": "DNN", "b": [0.473, 0.8313, 0.5193, 0.8527]}, {"w": "that", "b": [0.5249, 0.8313, 0.5574, 0.8527]}, {"w": "compares", "b": [0.563, 0.8313, 0.6434, 0.8527]}, {"w": "two", "b": [0.649, 0.8313, 0.6802, 0.8527]}, {"w": "MNIST", "b": [0.6858, 0.8313, 0.7497, 0.8527]}, {"w": "digit", "b": [0.7553, 0.8313, 0.7935, 0.8527]}, {"w": "images", "b": [0.7991, 0.8313, 0.8571, 0.8527]}]}, {"id": "b_28", "type": "paragraph", "text": "and predicts whether they represent the same digit or not. Then you will reuse the lower layers of this network to train an MNIST classifier using very little", "words": [{"w": "and", "b": [0.2044, 0.8503, 0.2359, 0.8717]}, {"w": "predicts", "b": [0.2408, 0.8503, 0.3077, 0.8717]}, {"w": "whether", "b": [0.3126, 0.8503, 0.3809, 0.8717]}, {"w": "they", "b": [0.3857, 0.8503, 0.4216, 0.8717]}, {"w": "represent", "b": [0.4265, 0.8503, 0.5044, 0.8717]}, {"w": "the", "b": [0.5093, 0.8503, 0.5357, 0.8717]}, {"w": "same", "b": [0.5405, 0.8503, 0.5832, 0.8717]}, {"w": "digit", "b": [0.5881, 0.8503, 0.6264, 0.8717]}, {"w": "or", "b": [0.6313, 0.8503, 0.6496, 0.8717]}, {"w": "not.", "b": [0.6545, 0.8503, 0.6876, 0.8717]}, {"w": "Then", "b": [0.6925, 0.8503, 0.7367, 0.8717]}, {"w": "you", "b": [0.7416, 0.8503, 0.7728, 0.8717]}, {"w": "will", "b": [0.7777, 0.8503, 0.8081, 0.8717]}, {"w": "reuse", "b": [0.813, 0.8503, 0.8571, 0.8717]}, {"w": "the", "b": [0.2044, 0.8694, 0.2307, 0.8908]}, {"w": "lower", "b": [0.237, 0.8694, 0.2837, 0.8908]}, {"w": "layers", "b": [0.29, 0.8694, 0.3378, 0.8908]}, {"w": "of", "b": [0.344, 0.8694, 0.3608, 0.8908]}, {"w": "this", "b": [0.3671, 0.8694, 0.3978, 0.8908]}, {"w": "network", "b": [0.404, 0.8694, 0.4736, 0.8908]}, {"w": "to", "b": [0.4798, 0.8694, 0.4968, 0.8908]}, {"w": "train", "b": [0.5031, 0.8694, 0.5433, 0.8908]}, {"w": "an", "b": [0.5495, 0.8694, 0.5701, 0.8908]}, {"w": "MNIST", "b": [0.5763, 0.8694, 0.6402, 0.8908]}, {"w": "classifier", "b": [0.6464, 0.8694, 0.7189, 0.8908]}, {"w": "using", "b": [0.7251, 0.8694, 0.7706, 0.8908]}, {"w": "very", "b": [0.7768, 0.8694, 0.8132, 0.8908]}, {"w": "little", "b": [0.8195, 0.8694, 0.8571, 0.8908]}]}, {"id": "b_29", "type": "paragraph", "text": "Exercises | 365", "words": [{"w": "Exercises", "b": [0.7433, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "365", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 392, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "training data. Start by building two DNNs (let’s call them DNN A and B), both similar to the one you built earlier but without the output layer: each DNN should have five hidden layers of 100 neurons each, He initialization, and ELU activation. Next, add one more hidden layer with 10 units on top of both DNNs. To do this, you should use a keras.layers.Concatenate layer to con‐ catenate the outputs of both DNNs for each instance, then feed the result to the hidden layer. Finally, add an output layer with a single neuron using the logistic activation function.", "words": [{"w": "training", "b": [0.2044, 0.0791, 0.2713, 0.1005]}, {"w": "data.", "b": [0.2761, 0.0791, 0.3161, 0.1005]}, {"w": "Start", "b": [0.3209, 0.0791, 0.3603, 0.1005]}, {"w": "by", "b": [0.3651, 0.0791, 0.3852, 0.1005]}, {"w": "building", "b": [0.39, 0.0791, 0.4603, 0.1005]}, {"w": "two", "b": [0.465, 0.0791, 0.4963, 0.1005]}, {"w": "DNNs", "b": [0.5011, 0.0791, 0.5544, 0.1005]}, {"w": "(let’s", "b": [0.5592, 0.0791, 0.5967, 0.1005]}, {"w": "call", "b": [0.6014, 0.0791, 0.6299, 0.1005]}, {"w": "them", "b": [0.6347, 0.0791, 0.6781, 0.1005]}, {"w": "DNN", "b": [0.6829, 0.0791, 0.7292, 0.1005]}, {"w": "A", "b": [0.734, 0.0791, 0.7483, 0.1005]}, {"w": "and", "b": [0.7531, 0.0791, 0.7847, 0.1005]}, {"w": "B),", "b": [0.7895, 0.0791, 0.8137, 0.1005]}, {"w": "both", "b": [0.8184, 0.0791, 0.8571, 0.1005]}, {"w": "similar", "b": [0.2044, 0.0981, 0.2624, 0.1195]}, {"w": "to", "b": [0.2694, 0.0981, 0.2864, 0.1195]}, {"w": "the", "b": [0.2935, 0.0981, 0.3198, 0.1195]}, {"w": "one", "b": [0.3268, 0.0981, 0.3577, 0.1195]}, {"w": "you", "b": [0.3647, 0.0981, 0.396, 0.1195]}, {"w": "built", "b": [0.403, 0.0981, 0.4419, 0.1195]}, {"w": "earlier", "b": [0.4489, 0.0981, 0.5021, 0.1195]}, {"w": "but", "b": [0.5092, 0.0981, 0.5372, 0.1195]}, {"w": "without", "b": [0.5442, 0.0981, 0.6096, 0.1195]}, {"w": "the", "b": [0.6166, 0.0981, 0.6429, 0.1195]}, {"w": "output", "b": [0.65, 0.0981, 0.7064, 0.1195]}, {"w": "layer:", "b": [0.7134, 0.0981, 0.7588, 0.1195]}, {"w": "each", "b": [0.7659, 0.0981, 0.8038, 0.1195]}, {"w": "DNN", "b": [0.8109, 0.0981, 0.8571, 0.1195]}, {"w": "should", "b": [0.2044, 0.1172, 0.2611, 0.1386]}, {"w": "have", "b": [0.266, 0.1172, 0.3044, 0.1386]}, {"w": "five", "b": [0.3092, 0.1172, 0.3395, 0.1386]}, {"w": "hidden", "b": [0.3443, 0.1172, 0.4033, 0.1386]}, {"w": "layers", "b": [0.4082, 0.1172, 0.456, 0.1386]}, {"w": "of", "b": [0.4608, 0.1172, 0.4776, 0.1386]}, {"w": "100", "b": [0.4825, 0.1172, 0.5125, 0.1386]}, {"w": "neurons", "b": [0.5174, 0.1172, 0.5861, 0.1386]}, {"w": "each,", "b": [0.5909, 0.1172, 0.6336, 0.1386]}, {"w": "He", "b": [0.6385, 0.1172, 0.6628, 0.1386]}, {"w": "initialization,", "b": [0.6676, 0.1172, 0.7783, 0.1386]}, {"w": "and", "b": [0.7832, 0.1172, 0.8147, 0.1386]}, {"w": "ELU", "b": [0.8196, 0.1172, 0.8571, 0.1386]}, {"w": "activation.", "b": [0.2044, 0.1362, 0.2914, 0.1576]}, {"w": "Next,", "b": [0.2999, 0.1362, 0.3446, 0.1576]}, {"w": "add", "b": [0.3532, 0.1362, 0.3843, 0.1576]}, {"w": "one", "b": [0.3928, 0.1362, 0.4237, 0.1576]}, {"w": "more", "b": [0.4322, 0.1362, 0.4765, 0.1576]}, {"w": "hidden", "b": [0.485, 0.1362, 0.544, 0.1576]}, {"w": "layer", "b": [0.5525, 0.1362, 0.5927, 0.1576]}, {"w": "with", "b": [0.6012, 0.1362, 0.6386, 0.1576]}, {"w": "10", "b": [0.6471, 0.1362, 0.6671, 0.1576]}, {"w": "units", "b": [0.6756, 0.1362, 0.7176, 0.1576]}, {"w": "on", "b": [0.7262, 0.1362, 0.7482, 0.1576]}, {"w": "top", "b": [0.7567, 0.1362, 0.7846, 0.1576]}, {"w": "of", "b": [0.7931, 0.1362, 0.8099, 0.1576]}, {"w": "both", "b": [0.8184, 0.1362, 0.8571, 0.1576]}, {"w": "DNNs.", "b": [0.2044, 0.1561, 0.2625, 0.1776]}, {"w": "To", "b": [0.2678, 0.1561, 0.2892, 0.1776]}, {"w": "do", "b": [0.2946, 0.1561, 0.3162, 0.1776]}, {"w": "this,", "b": [0.3215, 0.1561, 0.357, 0.1776]}, {"w": "you", "b": [0.3623, 0.1561, 0.3935, 0.1776]}, {"w": "should", "b": [0.3989, 0.1561, 0.4556, 0.1776]}, {"w": "use", "b": [0.4609, 0.1561, 0.4885, 0.1776]}, {"w": "a", "b": [0.4938, 0.1561, 0.5029, 0.1776]}, {"w": "keras.layers.Concatenate", "b": [0.5083, 0.1593, 0.7458, 0.1744]}, {"w": "layer", "b": [0.7511, 0.1561, 0.7913, 0.1776]}, {"w": "to", "b": [0.7966, 0.1561, 0.8136, 0.1776]}, {"w": "con‐", "b": [0.8189, 0.1561, 0.8572, 0.1776]}, {"w": "catenate", "b": [0.2044, 0.1752, 0.2725, 0.1966]}, {"w": "the", "b": [0.2791, 0.1752, 0.3055, 0.1966]}, {"w": "outputs", "b": [0.3121, 0.1752, 0.3761, 0.1966]}, {"w": "of", "b": [0.3827, 0.1752, 0.3995, 0.1966]}, {"w": "both", "b": [0.4062, 0.1752, 0.4449, 0.1966]}, {"w": "DNNs", "b": [0.4515, 0.1752, 0.5048, 0.1966]}, {"w": "for", "b": [0.5115, 0.1752, 0.536, 0.1966]}, {"w": "each", "b": [0.5426, 0.1752, 0.5806, 0.1966]}, {"w": "instance,", "b": [0.5872, 0.1752, 0.6611, 0.1966]}, {"w": "then", "b": [0.6678, 0.1752, 0.7055, 0.1966]}, {"w": "feed", "b": [0.7121, 0.1752, 0.747, 0.1966]}, {"w": "the", "b": [0.7536, 0.1752, 0.78, 0.1966]}, {"w": "result", "b": [0.7866, 0.1752, 0.8335, 0.1966]}, {"w": "to", "b": [0.8402, 0.1752, 0.8571, 0.1966]}, {"w": "the", "b": [0.2044, 0.1942, 0.2307, 0.2157]}, {"w": "hidden", "b": [0.2374, 0.1942, 0.2964, 0.2157]}, {"w": "layer.", "b": [0.3031, 0.1942, 0.3467, 0.2157]}, {"w": "Finally,", "b": [0.3534, 0.1942, 0.4139, 0.2157]}, {"w": "add", "b": [0.4206, 0.1942, 0.4518, 0.2157]}, {"w": "an", "b": [0.4585, 0.1942, 0.479, 0.2157]}, {"w": "output", "b": [0.4858, 0.1942, 0.5421, 0.2157]}, {"w": "layer", "b": [0.5488, 0.1942, 0.589, 0.2157]}, {"w": "with", "b": [0.5957, 0.1942, 0.6331, 0.2157]}, {"w": "a", "b": [0.6398, 0.1942, 0.6489, 0.2157]}, {"w": "single", "b": [0.6557, 0.1942, 0.7042, 0.2157]}, {"w": "neuron", "b": [0.7109, 0.1942, 0.7719, 0.2157]}, {"w": "using", "b": [0.7787, 0.1942, 0.8241, 0.2157]}, {"w": "the", "b": [0.8308, 0.1942, 0.8571, 0.2157]}, {"w": "logistic", "b": [0.2044, 0.2133, 0.264, 0.2347]}, {"w": "activation", "b": [0.2687, 0.2133, 0.351, 0.2347]}, {"w": "function.", "b": [0.3557, 0.2133, 0.4319, 0.2347]}]}, {"id": "b_1", "type": "paragraph", "text": "b. Split the MNIST training set in two sets: split #1 should containing 55,000", "words": [{"w": "b.", "b": [0.1792, 0.2384, 0.1939, 0.2598]}, {"w": "Split", "b": [0.2044, 0.2384, 0.2424, 0.2598]}, {"w": "the", "b": [0.2502, 0.2384, 0.2766, 0.2598]}, {"w": "MNIST", "b": [0.2844, 0.2384, 0.3483, 0.2598]}, {"w": "training", "b": [0.3562, 0.2384, 0.4231, 0.2598]}, {"w": "set", "b": [0.431, 0.2384, 0.4538, 0.2598]}, {"w": "in", "b": [0.4617, 0.2384, 0.4787, 0.2598]}, {"w": "two", "b": [0.4866, 0.2384, 0.5178, 0.2598]}, {"w": "sets:", "b": [0.5257, 0.2384, 0.5609, 0.2598]}, {"w": "split", "b": [0.5688, 0.2384, 0.6046, 0.2598]}, {"w": "#1", "b": [0.6124, 0.2384, 0.6324, 0.2598]}, {"w": "should", "b": [0.6403, 0.2384, 0.697, 0.2598]}, {"w": "containing", "b": [0.7049, 0.2384, 0.7945, 0.2598]}, {"w": "55,000", "b": [0.8024, 0.2384, 0.8572, 0.2598]}]}, {"id": "b_2", "type": "paragraph", "text": "images, and split #2 should contain contain 5,000 images. Create a function that generates a training batch where each instance is a pair of MNIST images picked from split #1. Half of the training instances should be pairs of images that belong to the same class, while the other half should be images from dif‐ ferent classes. For each pair, the training label should be 0 if the images are from the same class, or 1 if they are from different classes.", "words": [{"w": "images,", "b": [0.2044, 0.2574, 0.2672, 0.2788]}, {"w": "and", "b": [0.2742, 0.2574, 0.3058, 0.2788]}, {"w": "split", "b": [0.3128, 0.2574, 0.3486, 0.2788]}, {"w": "#2", "b": [0.3556, 0.2574, 0.3756, 0.2788]}, {"w": "should", "b": [0.3827, 0.2574, 0.4394, 0.2788]}, {"w": "contain", "b": [0.4465, 0.2574, 0.5094, 0.2788]}, {"w": "contain", "b": [0.5165, 0.2574, 0.5794, 0.2788]}, {"w": "5,000", "b": [0.5864, 0.2574, 0.6312, 0.2788]}, {"w": "images.", "b": [0.6382, 0.2574, 0.701, 0.2788]}, {"w": "Create", "b": [0.7081, 0.2574, 0.7625, 0.2788]}, {"w": "a", "b": [0.7695, 0.2574, 0.7787, 0.2788]}, {"w": "function", "b": [0.7857, 0.2574, 0.8571, 0.2788]}, {"w": "that", "b": [0.2044, 0.2765, 0.237, 0.2979]}, {"w": "generates", "b": [0.2422, 0.2765, 0.3204, 0.2979]}, {"w": "a", "b": [0.3256, 0.2765, 0.3347, 0.2979]}, {"w": "training", "b": [0.3399, 0.2765, 0.4069, 0.2979]}, {"w": "batch", "b": [0.4121, 0.2765, 0.4577, 0.2979]}, {"w": "where", "b": [0.463, 0.2765, 0.5138, 0.2979]}, {"w": "each", "b": [0.519, 0.2765, 0.5569, 0.2979]}, {"w": "instance", "b": [0.5622, 0.2765, 0.6314, 0.2979]}, {"w": "is", "b": [0.6366, 0.2765, 0.6498, 0.2979]}, {"w": "a", "b": [0.655, 0.2765, 0.6642, 0.2979]}, {"w": "pair", "b": [0.6694, 0.2765, 0.7028, 0.2979]}, {"w": "of", "b": [0.708, 0.2765, 0.7248, 0.2979]}, {"w": "MNIST", "b": [0.73, 0.2765, 0.7939, 0.2979]}, {"w": "images", "b": [0.7991, 0.2765, 0.8571, 0.2979]}, {"w": "picked", "b": [0.2044, 0.2955, 0.2599, 0.3169]}, {"w": "from", "b": [0.266, 0.2955, 0.3076, 0.3169]}, {"w": "split", "b": [0.3138, 0.2955, 0.3496, 0.3169]}, {"w": "#1.", "b": [0.3557, 0.2955, 0.3805, 0.3169]}, {"w": "Half", "b": [0.3867, 0.2955, 0.4227, 0.3169]}, {"w": "of", "b": [0.4289, 0.2955, 0.4457, 0.3169]}, {"w": "the", "b": [0.4518, 0.2955, 0.4782, 0.3169]}, {"w": "training", "b": [0.4843, 0.2955, 0.5513, 0.3169]}, {"w": "instances", "b": [0.5574, 0.2955, 0.6343, 0.3169]}, {"w": "should", "b": [0.6405, 0.2955, 0.6972, 0.3169]}, {"w": "be", "b": [0.7034, 0.2955, 0.7228, 0.3169]}, {"w": "pairs", "b": [0.729, 0.2955, 0.77, 0.3169]}, {"w": "of", "b": [0.7761, 0.2955, 0.7929, 0.3169]}, {"w": "images", "b": [0.7991, 0.2955, 0.8572, 0.3169]}, {"w": "that", "b": [0.2044, 0.3146, 0.2369, 0.336]}, {"w": "belong", "b": [0.2427, 0.3146, 0.2992, 0.336]}, {"w": "to", "b": [0.3049, 0.3146, 0.3219, 0.336]}, {"w": "the", "b": [0.3277, 0.3146, 0.354, 0.336]}, {"w": "same", "b": [0.3598, 0.3146, 0.4025, 0.336]}, {"w": "class,", "b": [0.4082, 0.3146, 0.4515, 0.336]}, {"w": "while", "b": [0.4573, 0.3146, 0.5024, 0.336]}, {"w": "the", "b": [0.5081, 0.3146, 0.5345, 0.336]}, {"w": "other", "b": [0.5402, 0.3146, 0.5849, 0.336]}, {"w": "half", "b": [0.5907, 0.3146, 0.6224, 0.336]}, {"w": "should", "b": [0.6281, 0.3146, 0.6849, 0.336]}, {"w": "be", "b": [0.6906, 0.3146, 0.7101, 0.336]}, {"w": "images", "b": [0.7158, 0.3146, 0.7739, 0.336]}, {"w": "from", "b": [0.7796, 0.3146, 0.8212, 0.336]}, {"w": "dif‐", "b": [0.827, 0.3146, 0.8571, 0.336]}, {"w": "ferent", "b": [0.2044, 0.3336, 0.2533, 0.355]}, {"w": "classes.", "b": [0.2605, 0.3336, 0.3202, 0.355]}, {"w": "For", "b": [0.3274, 0.3336, 0.3563, 0.355]}, {"w": "each", "b": [0.3635, 0.3336, 0.4014, 0.355]}, {"w": "pair,", "b": [0.4086, 0.3336, 0.4454, 0.355]}, {"w": "the", "b": [0.4525, 0.3336, 0.4788, 0.355]}, {"w": "training", "b": [0.486, 0.3336, 0.5529, 0.355]}, {"w": "label", "b": [0.56, 0.3336, 0.5992, 0.355]}, {"w": "should", "b": [0.6063, 0.3336, 0.663, 0.355]}, {"w": "be", "b": [0.6702, 0.3336, 0.6896, 0.355]}, {"w": "0", "b": [0.6967, 0.3336, 0.7067, 0.355]}, {"w": "if", "b": [0.7139, 0.3336, 0.7256, 0.355]}, {"w": "the", "b": [0.7328, 0.3336, 0.7591, 0.355]}, {"w": "images", "b": [0.7662, 0.3336, 0.8243, 0.355]}, {"w": "are", "b": [0.8314, 0.3336, 0.8571, 0.355]}, {"w": "from", "b": [0.2044, 0.3527, 0.246, 0.3741]}, {"w": "the", "b": [0.2507, 0.3527, 0.277, 0.3741]}, {"w": "same", "b": [0.2818, 0.3527, 0.3245, 0.3741]}, {"w": "class,", "b": [0.3292, 0.3527, 0.3725, 0.3741]}, {"w": "or", "b": [0.3772, 0.3527, 0.3955, 0.3741]}, {"w": "1", "b": [0.4003, 0.3527, 0.4103, 0.3741]}, {"w": "if", "b": [0.415, 0.3527, 0.4268, 0.3741]}, {"w": "they", "b": [0.4315, 0.3527, 0.4674, 0.3741]}, {"w": "are", "b": [0.4721, 0.3527, 0.4978, 0.3741]}, {"w": "from", "b": [0.5026, 0.3527, 0.5441, 0.3741]}, {"w": "different", "b": [0.5489, 0.3527, 0.6206, 0.3741]}, {"w": "classes.", "b": [0.6253, 0.3527, 0.6851, 0.3741]}]}, {"id": "b_3", "type": "paragraph", "text": "c. Train the DNN on this training set. For each image pair, you can simultane‐", "words": [{"w": "c.", "b": [0.1804, 0.3778, 0.1939, 0.3992]}, {"w": "Train", "b": [0.2044, 0.3778, 0.2493, 0.3992]}, {"w": "the", "b": [0.2558, 0.3778, 0.2821, 0.3992]}, {"w": "DNN", "b": [0.2886, 0.3778, 0.3348, 0.3992]}, {"w": "on", "b": [0.3413, 0.3778, 0.3633, 0.3992]}, {"w": "this", "b": [0.3697, 0.3778, 0.4005, 0.3992]}, {"w": "training", "b": [0.4069, 0.3778, 0.4738, 0.3992]}, {"w": "set.", "b": [0.4803, 0.3778, 0.5079, 0.3992]}, {"w": "For", "b": [0.5143, 0.3778, 0.5433, 0.3992]}, {"w": "each", "b": [0.5498, 0.3778, 0.5877, 0.3992]}, {"w": "image", "b": [0.5941, 0.3778, 0.6445, 0.3992]}, {"w": "pair,", "b": [0.651, 0.3778, 0.6878, 0.3992]}, {"w": "you", "b": [0.6942, 0.3778, 0.7255, 0.3992]}, {"w": "can", "b": [0.7319, 0.3778, 0.7613, 0.3992]}, {"w": "simultane‐", "b": [0.7677, 0.3778, 0.8571, 0.3992]}]}, {"id": "b_4", "type": "paragraph", "text": "ously feed the first image to DNN A and the second image to DNN B. The whole network will gradually learn to tell whether two images belong to the same class or not.", "words": [{"w": "ously", "b": [0.2044, 0.3968, 0.2485, 0.4182]}, {"w": "feed", "b": [0.2556, 0.3968, 0.2905, 0.4182]}, {"w": "the", "b": [0.2976, 0.3968, 0.3239, 0.4182]}, {"w": "first", "b": [0.331, 0.3968, 0.3645, 0.4182]}, {"w": "image", "b": [0.3716, 0.3968, 0.422, 0.4182]}, {"w": "to", "b": [0.4291, 0.3968, 0.4461, 0.4182]}, {"w": "DNN", "b": [0.4532, 0.3968, 0.4995, 0.4182]}, {"w": "A", "b": [0.5066, 0.3968, 0.521, 0.4182]}, {"w": "and", "b": [0.5281, 0.3968, 0.5596, 0.4182]}, {"w": "the", "b": [0.5667, 0.3968, 0.5931, 0.4182]}, {"w": "second", "b": [0.6002, 0.3968, 0.6585, 0.4182]}, {"w": "image", "b": [0.6656, 0.3968, 0.716, 0.4182]}, {"w": "to", "b": [0.7231, 0.3968, 0.7401, 0.4182]}, {"w": "DNN", "b": [0.7472, 0.3968, 0.7935, 0.4182]}, {"w": "B.", "b": [0.8006, 0.3968, 0.8172, 0.4182]}, {"w": "The", "b": [0.8243, 0.3968, 0.8571, 0.4182]}, {"w": "whole", "b": [0.2044, 0.4159, 0.2545, 0.4373]}, {"w": "network", "b": [0.2614, 0.4159, 0.3309, 0.4373]}, {"w": "will", "b": [0.3378, 0.4159, 0.3682, 0.4373]}, {"w": "gradually", "b": [0.375, 0.4159, 0.453, 0.4373]}, {"w": "learn", "b": [0.4598, 0.4159, 0.5022, 0.4373]}, {"w": "to", "b": [0.5091, 0.4159, 0.526, 0.4373]}, {"w": "tell", "b": [0.5329, 0.4159, 0.5586, 0.4373]}, {"w": "whether", "b": [0.5655, 0.4159, 0.6338, 0.4373]}, {"w": "two", "b": [0.6407, 0.4159, 0.6719, 0.4373]}, {"w": "images", "b": [0.6788, 0.4159, 0.7368, 0.4373]}, {"w": "belong", "b": [0.7437, 0.4159, 0.8001, 0.4373]}, {"w": "to", "b": [0.807, 0.4159, 0.824, 0.4373]}, {"w": "the", "b": [0.8308, 0.4159, 0.8571, 0.4373]}, {"w": "same", "b": [0.2044, 0.4349, 0.2471, 0.4563]}, {"w": "class", "b": [0.2518, 0.4349, 0.2903, 0.4563]}, {"w": "or", "b": [0.295, 0.4349, 0.3134, 0.4563]}, {"w": "not.", "b": [0.3181, 0.4349, 0.3513, 0.4563]}]}, {"id": "b_5", "type": "paragraph", "text": "d. Now create a new DNN by reusing and freezing the hidden layers of DNN A", "words": [{"w": "d.", "b": [0.1782, 0.46, 0.1939, 0.4814]}, {"w": "Now", "b": [0.2044, 0.46, 0.2442, 0.4814]}, {"w": "create", "b": [0.2501, 0.46, 0.2994, 0.4814]}, {"w": "a", "b": [0.3053, 0.46, 0.3145, 0.4814]}, {"w": "new", "b": [0.3203, 0.46, 0.3549, 0.4814]}, {"w": "DNN", "b": [0.3607, 0.46, 0.407, 0.4814]}, {"w": "by", "b": [0.4129, 0.46, 0.433, 0.4814]}, {"w": "reusing", "b": [0.4389, 0.46, 0.5009, 0.4814]}, {"w": "and", "b": [0.5068, 0.46, 0.5383, 0.4814]}, {"w": "freezing", "b": [0.5442, 0.46, 0.6113, 0.4814]}, {"w": "the", "b": [0.6172, 0.46, 0.6435, 0.4814]}, {"w": "hidden", "b": [0.6494, 0.46, 0.7083, 0.4814]}, {"w": "layers", "b": [0.7142, 0.46, 0.762, 0.4814]}, {"w": "of", "b": [0.7679, 0.46, 0.7847, 0.4814]}, {"w": "DNN", "b": [0.7906, 0.46, 0.8369, 0.4814]}, {"w": "A", "b": [0.8427, 0.46, 0.8571, 0.4814]}]}, {"id": "b_6", "type": "paragraph", "text": "and adding a softmax output layer on top with 10 neurons. Train this network on split #2 and see if you can achieve high performance despite having only 500 images per class.", "words": [{"w": "and", "b": [0.2044, 0.4791, 0.2359, 0.5005]}, {"w": "adding", "b": [0.2409, 0.4791, 0.2988, 0.5005]}, {"w": "a", "b": [0.3038, 0.4791, 0.3129, 0.5005]}, {"w": "softmax", "b": [0.3179, 0.4791, 0.3847, 0.5005]}, {"w": "output", "b": [0.3897, 0.4791, 0.4461, 0.5005]}, {"w": "layer", "b": [0.4511, 0.4791, 0.4913, 0.5005]}, {"w": "on", "b": [0.4963, 0.4791, 0.5183, 0.5005]}, {"w": "top", "b": [0.5233, 0.4791, 0.5512, 0.5005]}, {"w": "with", "b": [0.5562, 0.4791, 0.5935, 0.5005]}, {"w": "10", "b": [0.5985, 0.4791, 0.6185, 0.5005]}, {"w": "neurons.", "b": [0.6235, 0.4791, 0.6969, 0.5005]}, {"w": "Train", "b": [0.7019, 0.4791, 0.7469, 0.5005]}, {"w": "this", "b": [0.7519, 0.4791, 0.7826, 0.5005]}, {"w": "network", "b": [0.7876, 0.4791, 0.8571, 0.5005]}, {"w": "on", "b": [0.2044, 0.4981, 0.2264, 0.5195]}, {"w": "split", "b": [0.233, 0.4981, 0.2688, 0.5195]}, {"w": "#2", "b": [0.2755, 0.4981, 0.2955, 0.5195]}, {"w": "and", "b": [0.3021, 0.4981, 0.3337, 0.5195]}, {"w": "see", "b": [0.3403, 0.4981, 0.3657, 0.5195]}, {"w": "if", "b": [0.3723, 0.4981, 0.3841, 0.5195]}, {"w": "you", "b": [0.3907, 0.4981, 0.422, 0.5195]}, {"w": "can", "b": [0.4286, 0.4981, 0.458, 0.5195]}, {"w": "achieve", "b": [0.4646, 0.4981, 0.5267, 0.5195]}, {"w": "high", "b": [0.5333, 0.4981, 0.5709, 0.5195]}, {"w": "performance", "b": [0.5776, 0.4981, 0.6849, 0.5195]}, {"w": "despite", "b": [0.6915, 0.4981, 0.7507, 0.5195]}, {"w": "having", "b": [0.7574, 0.4981, 0.8136, 0.5195]}, {"w": "only", "b": [0.8203, 0.4981, 0.8571, 0.5195]}, {"w": "500", "b": [0.2044, 0.5171, 0.2344, 0.5386]}, {"w": "images", "b": [0.2391, 0.5171, 0.2971, 0.5386]}, {"w": "per", "b": [0.3019, 0.5171, 0.3294, 0.5386]}, {"w": "class.", "b": [0.3341, 0.5171, 0.3774, 0.5386]}]}, {"id": "b_7", "type": "paragraph", "text": "Solutions to these exercises are available in ???.", "words": [{"w": "Solutions", "b": [0.1429, 0.5513, 0.2213, 0.5727]}, {"w": "to", "b": [0.226, 0.5513, 0.243, 0.5727]}, {"w": "these", "b": [0.2477, 0.5513, 0.2906, 0.5727]}, {"w": "exercises", "b": [0.2953, 0.5513, 0.3691, 0.5727]}, {"w": "are", "b": [0.3738, 0.5513, 0.3996, 0.5727]}, {"w": "available", "b": [0.4043, 0.5513, 0.4766, 0.5727]}, {"w": "in", "b": [0.4813, 0.5513, 0.4983, 0.5727]}, {"w": "???.", "b": [0.503, 0.5513, 0.5314, 0.5727]}]}, {"id": "b_8", "type": "paragraph", "text": "366 | Chapter 11: Training Deep Neural Networks", "words": [{"w": "366", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "11:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Training", "b": [0.2745, 0.9225, 0.3236, 0.9388]}, {"w": "Deep", "b": [0.3264, 0.9225, 0.3565, 0.9388]}, {"w": "Neural", "b": [0.3593, 0.9225, 0.3985, 0.9388]}, {"w": "Networks", "b": [0.4013, 0.9225, 0.4575, 0.9388]}]}]}, {"page": 393, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "CHAPTER 12 Custom Models and Training with", "words": [{"w": "CHAPTER", "b": [0.7262, 0.1146, 0.8246, 0.1451]}, {"w": "12", "b": [0.8299, 0.1146, 0.8571, 0.1451]}, {"w": "Custom", "b": [0.3072, 0.1478, 0.4308, 0.1935]}, {"w": "Models", "b": [0.4387, 0.1478, 0.5571, 0.1935]}, {"w": "and", "b": [0.565, 0.1478, 0.6278, 0.1935]}, {"w": "Training", "b": [0.6357, 0.1478, 0.7732, 0.1935]}, {"w": "with", "b": [0.7811, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_1", "type": "paragraph", "text": "TensorFlow", "words": [{"w": "TensorFlow", "b": [0.668, 0.184, 0.8571, 0.2297]}]}, {"id": "b_2", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 12 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.4006, 0.3102, 0.4201]}, {"w": "Early", "b": [0.3165, 0.4006, 0.3563, 0.4201]}, {"w": "Release", "b": [0.3626, 0.4006, 0.4189, 0.4201]}, {"w": "ebooks,", "b": [0.4251, 0.4006, 0.4831, 0.4201]}, {"w": "you", "b": [0.4894, 0.4006, 0.518, 0.4201]}, {"w": "get", "b": [0.5243, 0.4006, 0.5471, 0.4201]}, {"w": "books", "b": [0.5534, 0.4006, 0.5989, 0.4201]}, {"w": "in", "b": [0.6052, 0.4006, 0.6207, 0.4201]}, {"w": "their", "b": [0.627, 0.4006, 0.6632, 0.4201]}, {"w": "earliest", "b": [0.6695, 0.4006, 0.7239, 0.4201]}, {"w": "form—", "b": [0.7301, 0.4006, 0.7857, 0.4201]}, {"w": "the", "b": [0.2714, 0.418, 0.2955, 0.4376]}, {"w": "author’s", "b": [0.3012, 0.418, 0.3615, 0.4376]}, {"w": "raw", "b": [0.3672, 0.418, 0.3954, 0.4376]}, {"w": "and", "b": [0.4011, 0.418, 0.4299, 0.4376]}, {"w": "unedited", "b": [0.4357, 0.418, 0.5034, 0.4376]}, {"w": "content", "b": [0.5091, 0.418, 0.5667, 0.4376]}, {"w": "as", "b": [0.5725, 0.418, 0.5878, 0.4376]}, {"w": "he", "b": [0.5935, 0.418, 0.6118, 0.4376]}, {"w": "or", "b": [0.6175, 0.418, 0.6343, 0.4376]}, {"w": "she", "b": [0.6401, 0.418, 0.6653, 0.4376]}, {"w": "writes—so", "b": [0.671, 0.418, 0.7514, 0.4376]}, {"w": "you", "b": [0.7571, 0.418, 0.7857, 0.4376]}, {"w": "can", "b": [0.2714, 0.4354, 0.2982, 0.455]}, {"w": "take", "b": [0.306, 0.4354, 0.3377, 0.455]}, {"w": "advantage", "b": [0.3455, 0.4354, 0.4223, 0.455]}, {"w": "of", "b": [0.4301, 0.4354, 0.4454, 0.455]}, {"w": "these", "b": [0.4532, 0.4354, 0.4923, 0.455]}, {"w": "technologies", "b": [0.5001, 0.4354, 0.596, 0.455]}, {"w": "long", "b": [0.6038, 0.4354, 0.6376, 0.455]}, {"w": "before", "b": [0.6454, 0.4354, 0.6937, 0.455]}, {"w": "the", "b": [0.7014, 0.4354, 0.7255, 0.455]}, {"w": "official", "b": [0.7333, 0.4354, 0.7857, 0.455]}, {"w": "release", "b": [0.2714, 0.4528, 0.3229, 0.4724]}, {"w": "of", "b": [0.3284, 0.4528, 0.3437, 0.4724]}, {"w": "these", "b": [0.3492, 0.4528, 0.3884, 0.4724]}, {"w": "titles.", "b": [0.3938, 0.4528, 0.4348, 0.4724]}, {"w": "The", "b": [0.4403, 0.4528, 0.4703, 0.4724]}, {"w": "following", "b": [0.4757, 0.4528, 0.5479, 0.4724]}, {"w": "will", "b": [0.5534, 0.4528, 0.5812, 0.4724]}, {"w": "be", "b": [0.5866, 0.4528, 0.6044, 0.4724]}, {"w": "Chapter", "b": [0.6099, 0.4528, 0.6717, 0.4724]}, {"w": "12", "b": [0.6771, 0.4528, 0.6954, 0.4724]}, {"w": "in", "b": [0.7009, 0.4528, 0.7164, 0.4724]}, {"w": "the", "b": [0.7218, 0.4528, 0.7459, 0.4724]}, {"w": "final", "b": [0.7514, 0.4528, 0.7857, 0.4724]}, {"w": "release", "b": [0.2714, 0.4702, 0.3229, 0.4898]}, {"w": "of", "b": [0.3273, 0.4702, 0.3426, 0.4898]}, {"w": "the", "b": [0.3469, 0.4702, 0.371, 0.4898]}, {"w": "book.", "b": [0.3753, 0.4702, 0.4182, 0.4898]}]}, {"id": "b_3", "type": "paragraph", "text": "So far we have used only TensorFlow’s high level API, tf.keras, but it already got us pretty far: we built various neural network architectures, including regression and classification nets, wide & deep nets and self-normalizing nets, using all sorts of tech‐ niques, such as Batch Normalization, dropout, learning rate schedules, and more. In fact, 95% of the use cases you will encounter will not require anything else than tf.keras (and tf.data, see Chapter 13). But now it’s time to dive deeper into TensorFlow and take a look at its lower-level Python API. This will be useful when you need extra control, to write custom loss functions, custom metrics, layers, models, initializers, regularizers, weight constraints and more. You may even need to fully control the training loop itself, for example to apply special transformations or constraints to the gradients (beyond just clipping them), or to use multiple optimizers for different parts of the network. We will cover all these cases in this chapter, then we will also look at how you can boost your custom models and training algorithms using Ten‐ sorFlow’s automatic graph generation feature. But first, let’s take a quick tour of Ten‐ sorFlow.", "words": [{"w": "So", "b": [0.1429, 0.5101, 0.1634, 0.5315]}, {"w": "far", "b": [0.17, 0.5101, 0.1931, 0.5315]}, {"w": "we", "b": [0.1997, 0.5101, 0.2229, 0.5315]}, {"w": "have", "b": [0.2295, 0.5101, 0.2679, 0.5315]}, {"w": "used", "b": [0.2746, 0.5101, 0.3131, 0.5315]}, {"w": "only", "b": [0.3198, 0.5101, 0.3567, 0.5315]}, {"w": "TensorFlow’s", "b": [0.3633, 0.5101, 0.4719, 0.5315]}, {"w": "high", "b": [0.4785, 0.5101, 0.5161, 0.5315]}, {"w": "level", "b": [0.5228, 0.5101, 0.5607, 0.5315]}, {"w": "API,", "b": [0.5674, 0.5101, 0.6053, 0.5315]}, {"w": "tf.keras,", "b": [0.612, 0.5101, 0.6777, 0.5315]}, {"w": "but", "b": [0.6844, 0.5101, 0.7124, 0.5315]}, {"w": "it", "b": [0.7191, 0.5101, 0.731, 0.5315]}, {"w": "already", "b": [0.7377, 0.5101, 0.7984, 0.5315]}, {"w": "got", "b": [0.805, 0.5101, 0.8318, 0.5315]}, {"w": "us", "b": [0.8384, 0.5101, 0.8571, 0.5315]}, {"w": "pretty", "b": [0.1428, 0.5291, 0.1926, 0.5506]}, {"w": "far:", "b": [0.2006, 0.5291, 0.2289, 0.5506]}, {"w": "we", "b": [0.2369, 0.5291, 0.26, 0.5506]}, {"w": "built", "b": [0.268, 0.5291, 0.3068, 0.5506]}, {"w": "various", "b": [0.3148, 0.5291, 0.3762, 0.5506]}, {"w": "neural", "b": [0.3842, 0.5291, 0.4377, 0.5506]}, {"w": "network", "b": [0.4456, 0.5291, 0.5152, 0.5506]}, {"w": "architectures,", "b": [0.5232, 0.5291, 0.636, 0.5506]}, {"w": "including", "b": [0.644, 0.5291, 0.7238, 0.5506]}, {"w": "regression", "b": [0.7318, 0.5291, 0.8176, 0.5506]}, {"w": "and", "b": [0.8256, 0.5291, 0.8571, 0.5506]}, {"w": "classification", "b": [0.1429, 0.5482, 0.2502, 0.5696]}, {"w": "nets,", "b": [0.2554, 0.5482, 0.2944, 0.5696]}, {"w": "wide", "b": [0.2995, 0.5482, 0.3392, 0.5696]}, {"w": "&", "b": [0.3444, 0.5482, 0.3592, 0.5696]}, {"w": "deep", "b": [0.3643, 0.5482, 0.404, 0.5696]}, {"w": "nets", "b": [0.4091, 0.5482, 0.4433, 0.5696]}, {"w": "and", "b": [0.4485, 0.5482, 0.48, 0.5696]}, {"w": "self-normalizing", "b": [0.4852, 0.5482, 0.6228, 0.5696]}, {"w": "nets,", "b": [0.628, 0.5482, 0.667, 0.5696]}, {"w": "using", "b": [0.6721, 0.5482, 0.7175, 0.5696]}, {"w": "all", "b": [0.7227, 0.5482, 0.7424, 0.5696]}, {"w": "sorts", "b": [0.7475, 0.5482, 0.7875, 0.5696]}, {"w": "of", "b": [0.7927, 0.5482, 0.8094, 0.5696]}, {"w": "tech‐", "b": [0.8146, 0.5482, 0.8571, 0.5696]}, {"w": "niques,", "b": [0.1429, 0.5672, 0.2028, 0.5886]}, {"w": "such", "b": [0.2089, 0.5672, 0.2475, 0.5886]}, {"w": "as", "b": [0.2536, 0.5672, 0.2704, 0.5886]}, {"w": "Batch", "b": [0.2765, 0.5672, 0.3238, 0.5886]}, {"w": "Normalization,", "b": [0.3299, 0.5672, 0.4565, 0.5886]}, {"w": "dropout,", "b": [0.4626, 0.5672, 0.5357, 0.5886]}, {"w": "learning", "b": [0.5418, 0.5672, 0.6109, 0.5886]}, {"w": "rate", "b": [0.617, 0.5672, 0.6487, 0.5886]}, {"w": "schedules,", "b": [0.6548, 0.5672, 0.7398, 0.5886]}, {"w": "and", "b": [0.7459, 0.5672, 0.7774, 0.5886]}, {"w": "more.", "b": [0.7835, 0.5672, 0.8325, 0.5886]}, {"w": "In", "b": [0.8386, 0.5672, 0.8571, 0.5886]}, {"w": "fact,", "b": [0.1429, 0.5863, 0.1781, 0.6077]}, {"w": "95%", "b": [0.1868, 0.5863, 0.2226, 0.6077]}, {"w": "of", "b": [0.2313, 0.5863, 0.2481, 0.6077]}, {"w": "the", "b": [0.2569, 0.5863, 0.2832, 0.6077]}, {"w": "use", "b": [0.2919, 0.5863, 0.3195, 0.6077]}, {"w": "cases", "b": [0.3283, 0.5863, 0.3704, 0.6077]}, {"w": "you", "b": [0.3791, 0.5863, 0.4104, 0.6077]}, {"w": "will", "b": [0.4191, 0.5863, 0.4495, 0.6077]}, {"w": "encounter", "b": [0.4583, 0.5863, 0.5429, 0.6077]}, {"w": "will", "b": [0.5517, 0.5863, 0.5821, 0.6077]}, {"w": "not", "b": [0.5908, 0.5863, 0.6192, 0.6077]}, {"w": "require", "b": [0.628, 0.5863, 0.6884, 0.6077]}, {"w": "anything", "b": [0.6972, 0.5863, 0.771, 0.6077]}, {"w": "else", "b": [0.7797, 0.5863, 0.8104, 0.6077]}, {"w": "than", "b": [0.8191, 0.5863, 0.8571, 0.6077]}, {"w": "tf.keras", "b": [0.1429, 0.6053, 0.2038, 0.6267]}, {"w": "(and", "b": [0.2086, 0.6053, 0.2473, 0.6267]}, {"w": "tf.data,", "b": [0.2521, 0.6053, 0.3093, 0.6267]}, {"w": "see", "b": [0.3141, 0.6053, 0.3394, 0.6267]}, {"w": "Chapter", "b": [0.3443, 0.6053, 0.4119, 0.6267]}, {"w": "13).", "b": [0.4166, 0.6053, 0.4486, 0.6267]}, {"w": "But", "b": [0.4533, 0.6053, 0.483, 0.6267]}, {"w": "now", "b": [0.4877, 0.6053, 0.524, 0.6267]}, {"w": "it’s", "b": [0.5288, 0.6053, 0.5504, 0.6267]}, {"w": "time", "b": [0.5552, 0.6053, 0.593, 0.6267]}, {"w": "to", "b": [0.5978, 0.6053, 0.6147, 0.6267]}, {"w": "dive", "b": [0.6195, 0.6053, 0.6546, 0.6267]}, {"w": "deeper", "b": [0.6593, 0.6053, 0.7155, 0.6267]}, {"w": "into", "b": [0.7202, 0.6053, 0.7538, 0.6267]}, {"w": "TensorFlow", "b": [0.7585, 0.6053, 0.8568, 0.6267]}, {"w": "and", "b": [0.1429, 0.6244, 0.1744, 0.6458]}, {"w": "take", "b": [0.1795, 0.6244, 0.2142, 0.6458]}, {"w": "a", "b": [0.2192, 0.6244, 0.2284, 0.6458]}, {"w": "look", "b": [0.2334, 0.6244, 0.2703, 0.6458]}, {"w": "at", "b": [0.2753, 0.6244, 0.2905, 0.6458]}, {"w": "its", "b": [0.2955, 0.6244, 0.3151, 0.6458]}, {"w": "lower-level", "b": [0.3202, 0.6244, 0.4117, 0.6458]}, {"w": "Python", "b": [0.4168, 0.6244, 0.4776, 0.6458]}, {"w": "API.", "b": [0.4823, 0.6244, 0.5206, 0.6458]}, {"w": "This", "b": [0.5257, 0.6244, 0.5629, 0.6458]}, {"w": "will", "b": [0.568, 0.6244, 0.5984, 0.6458]}, {"w": "be", "b": [0.6034, 0.6244, 0.6229, 0.6458]}, {"w": "useful", "b": [0.6279, 0.6244, 0.678, 0.6458]}, {"w": "when", "b": [0.683, 0.6244, 0.7287, 0.6458]}, {"w": "you", "b": [0.7338, 0.6244, 0.765, 0.6458]}, {"w": "need", "b": [0.7701, 0.6244, 0.8102, 0.6458]}, {"w": "extra", "b": [0.8152, 0.6244, 0.8571, 0.6458]}, {"w": "control,", "b": [0.1429, 0.6434, 0.208, 0.6648]}, {"w": "to", "b": [0.2155, 0.6434, 0.2324, 0.6648]}, {"w": "write", "b": [0.2399, 0.6434, 0.2827, 0.6648]}, {"w": "custom", "b": [0.2901, 0.6434, 0.3517, 0.6648]}, {"w": "loss", "b": [0.3591, 0.6434, 0.3903, 0.6648]}, {"w": "functions,", "b": [0.3978, 0.6434, 0.4816, 0.6648]}, {"w": "custom", "b": [0.489, 0.6434, 0.5506, 0.6648]}, {"w": "metrics,", "b": [0.558, 0.6434, 0.6248, 0.6648]}, {"w": "layers,", "b": [0.6322, 0.6434, 0.6848, 0.6648]}, {"w": "models,", "b": [0.6923, 0.6434, 0.7575, 0.6648]}, {"w": "initializers,", "b": [0.7649, 0.6434, 0.8571, 0.6648]}, {"w": "regularizers,", "b": [0.1429, 0.6625, 0.2457, 0.6839]}, {"w": "weight", "b": [0.2537, 0.6625, 0.3092, 0.6839]}, {"w": "constraints", "b": [0.3171, 0.6625, 0.4094, 0.6839]}, {"w": "and", "b": [0.4174, 0.6625, 0.4489, 0.6839]}, {"w": "more.", "b": [0.4569, 0.6625, 0.5059, 0.6839]}, {"w": "You", "b": [0.5138, 0.6625, 0.5462, 0.6839]}, {"w": "may", "b": [0.5541, 0.6625, 0.5895, 0.6839]}, {"w": "even", "b": [0.5975, 0.6625, 0.6362, 0.6839]}, {"w": "need", "b": [0.6442, 0.6625, 0.6843, 0.6839]}, {"w": "to", "b": [0.6922, 0.6625, 0.7092, 0.6839]}, {"w": "fully", "b": [0.7172, 0.6625, 0.7545, 0.6839]}, {"w": "control", "b": [0.7624, 0.6625, 0.8229, 0.6839]}, {"w": "the", "b": [0.8308, 0.6625, 0.8571, 0.6839]}, {"w": "training", "b": [0.1429, 0.6815, 0.2098, 0.7029]}, {"w": "loop", "b": [0.2152, 0.6815, 0.2526, 0.7029]}, {"w": "itself,", "b": [0.258, 0.6815, 0.3026, 0.7029]}, {"w": "for", "b": [0.308, 0.6815, 0.3325, 0.7029]}, {"w": "example", "b": [0.3379, 0.6815, 0.4074, 0.7029]}, {"w": "to", "b": [0.4128, 0.6815, 0.4298, 0.7029]}, {"w": "apply", "b": [0.4351, 0.6815, 0.4805, 0.7029]}, {"w": "special", "b": [0.4859, 0.6815, 0.5421, 0.7029]}, {"w": "transformations", "b": [0.5475, 0.6815, 0.6817, 0.7029]}, {"w": "or", "b": [0.6871, 0.6815, 0.7054, 0.7029]}, {"w": "constraints", "b": [0.7108, 0.6815, 0.8031, 0.7029]}, {"w": "to", "b": [0.8085, 0.6815, 0.8254, 0.7029]}, {"w": "the", "b": [0.8308, 0.6815, 0.8572, 0.7029]}, {"w": "gradients", "b": [0.1429, 0.7006, 0.2199, 0.722]}, {"w": "(beyond", "b": [0.2286, 0.7006, 0.2979, 0.722]}, {"w": "just", "b": [0.3066, 0.7006, 0.337, 0.722]}, {"w": "clipping", "b": [0.3457, 0.7006, 0.4139, 0.722]}, {"w": "them),", "b": [0.4226, 0.7006, 0.478, 0.722]}, {"w": "or", "b": [0.4867, 0.7006, 0.505, 0.722]}, {"w": "to", "b": [0.5137, 0.7006, 0.5307, 0.722]}, {"w": "use", "b": [0.5394, 0.7006, 0.567, 0.722]}, {"w": "multiple", "b": [0.5757, 0.7006, 0.6457, 0.722]}, {"w": "optimizers", "b": [0.6544, 0.7006, 0.7435, 0.722]}, {"w": "for", "b": [0.7522, 0.7006, 0.7767, 0.722]}, {"w": "different", "b": [0.7854, 0.7006, 0.8571, 0.722]}, {"w": "parts", "b": [0.1429, 0.7196, 0.1846, 0.741]}, {"w": "of", "b": [0.1915, 0.7196, 0.2083, 0.741]}, {"w": "the", "b": [0.2151, 0.7196, 0.2415, 0.741]}, {"w": "network.", "b": [0.2483, 0.7196, 0.3227, 0.741]}, {"w": "We", "b": [0.3295, 0.7196, 0.3566, 0.741]}, {"w": "will", "b": [0.3634, 0.7196, 0.3938, 0.741]}, {"w": "cover", "b": [0.4007, 0.7196, 0.4463, 0.741]}, {"w": "all", "b": [0.4532, 0.7196, 0.4729, 0.741]}, {"w": "these", "b": [0.4797, 0.7196, 0.5226, 0.741]}, {"w": "cases", "b": [0.5294, 0.7196, 0.5715, 0.741]}, {"w": "in", "b": [0.5784, 0.7196, 0.5954, 0.741]}, {"w": "this", "b": [0.6022, 0.7196, 0.6329, 0.741]}, {"w": "chapter,", "b": [0.6398, 0.7196, 0.7058, 0.741]}, {"w": "then", "b": [0.7126, 0.7196, 0.7504, 0.741]}, {"w": "we", "b": [0.7572, 0.7196, 0.7803, 0.741]}, {"w": "will", "b": [0.7872, 0.7196, 0.8176, 0.741]}, {"w": "also", "b": [0.8245, 0.7196, 0.8571, 0.741]}, {"w": "look", "b": [0.1428, 0.7387, 0.1797, 0.7601]}, {"w": "at", "b": [0.1863, 0.7387, 0.2014, 0.7601]}, {"w": "how", "b": [0.2081, 0.7387, 0.2441, 0.7601]}, {"w": "you", "b": [0.2507, 0.7387, 0.282, 0.7601]}, {"w": "can", "b": [0.2886, 0.7387, 0.3179, 0.7601]}, {"w": "boost", "b": [0.3246, 0.7387, 0.3704, 0.7601]}, {"w": "your", "b": [0.377, 0.7387, 0.416, 0.7601]}, {"w": "custom", "b": [0.4226, 0.7387, 0.4842, 0.7601]}, {"w": "models", "b": [0.4908, 0.7387, 0.5513, 0.7601]}, {"w": "and", "b": [0.5579, 0.7387, 0.5895, 0.7601]}, {"w": "training", "b": [0.5961, 0.7387, 0.663, 0.7601]}, {"w": "algorithms", "b": [0.6697, 0.7387, 0.76, 0.7601]}, {"w": "using", "b": [0.7666, 0.7387, 0.812, 0.7601]}, {"w": "Ten‐", "b": [0.8187, 0.7387, 0.8571, 0.7601]}, {"w": "sorFlow’s", "b": [0.1429, 0.7577, 0.2204, 0.7791]}, {"w": "automatic", "b": [0.226, 0.7577, 0.3094, 0.7791]}, {"w": "graph", "b": [0.3151, 0.7577, 0.3634, 0.7791]}, {"w": "generation", "b": [0.369, 0.7577, 0.4583, 0.7791]}, {"w": "feature.", "b": [0.464, 0.7577, 0.5265, 0.7791]}, {"w": "But", "b": [0.5322, 0.7577, 0.5619, 0.7791]}, {"w": "first,", "b": [0.5676, 0.7577, 0.6058, 0.7791]}, {"w": "let’s", "b": [0.6115, 0.7577, 0.6417, 0.7791]}, {"w": "take", "b": [0.6474, 0.7577, 0.6821, 0.7791]}, {"w": "a", "b": [0.6878, 0.7577, 0.6969, 0.7791]}, {"w": "quick", "b": [0.7026, 0.7577, 0.7491, 0.7791]}, {"w": "tour", "b": [0.7547, 0.7577, 0.7905, 0.7791]}, {"w": "of", "b": [0.7962, 0.7577, 0.813, 0.7791]}, {"w": "Ten‐", "b": [0.8187, 0.7577, 0.8571, 0.7791]}, {"w": "sorFlow.", "b": [0.1429, 0.7768, 0.2133, 0.7982]}]}, {"id": "b_4", "type": "paragraph", "text": "367", "words": [{"w": "367", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 394, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 TensorFlow also includes another Deep Learning API called the Estimators API, but it is now recommended to use tf.keras instead.", "words": [{"w": "1", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "TensorFlow", "b": [0.1587, 0.8598, 0.2336, 0.8761]}, {"w": "also", "b": [0.2372, 0.8598, 0.2621, 0.8761]}, {"w": "includes", "b": [0.2657, 0.8598, 0.3187, 0.8761]}, {"w": "another", "b": [0.3223, 0.8598, 0.372, 0.8761]}, {"w": "Deep", "b": [0.3757, 0.8598, 0.4091, 0.8761]}, {"w": "Learning", "b": [0.4127, 0.8598, 0.4699, 0.8761]}, {"w": "API", "b": [0.4735, 0.8598, 0.4988, 0.8761]}, {"w": "called", "b": [0.5024, 0.8598, 0.5393, 0.8761]}, {"w": "the", "b": [0.5429, 0.8598, 0.563, 0.8761]}, {"w": "Estimators", "b": [0.5666, 0.8596, 0.6325, 0.8761]}, {"w": "API,", "b": [0.6361, 0.8596, 0.6642, 0.8761]}, {"w": "but", "b": [0.6678, 0.8598, 0.6891, 0.8761]}, {"w": "it", "b": [0.6927, 0.8598, 0.7018, 0.8761]}, {"w": "is", "b": [0.7054, 0.8598, 0.7155, 0.8761]}, {"w": "now", "b": [0.7191, 0.8598, 0.7467, 0.8761]}, {"w": "recommended", "b": [0.7503, 0.8598, 0.8427, 0.8761]}, {"w": "to", "b": [0.1587, 0.8749, 0.1717, 0.8912]}, {"w": "use", "b": [0.1753, 0.8749, 0.1963, 0.8912]}, {"w": "tf.keras", "b": [0.1999, 0.8749, 0.2463, 0.8912]}, {"w": "instead.", "b": [0.2499, 0.8749, 0.2993, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "TensorFlow 2.0 was released in March 2019, making TensorFlow much easier to use. The first edition of this book used TF 1, while this edition uses TF 2.", "words": [{"w": "TensorFlow", "b": [0.2714, 0.0793, 0.3612, 0.0989]}, {"w": "2.0", "b": [0.3684, 0.0793, 0.391, 0.0989]}, {"w": "was", "b": [0.3982, 0.0793, 0.4266, 0.0989]}, {"w": "released", "b": [0.4338, 0.0793, 0.4954, 0.0989]}, {"w": "in", "b": [0.5026, 0.0793, 0.5181, 0.0989]}, {"w": "March", "b": [0.5253, 0.0793, 0.5756, 0.0989]}, {"w": "2019,", "b": [0.5828, 0.0793, 0.6237, 0.0989]}, {"w": "making", "b": [0.6309, 0.0793, 0.6887, 0.0989]}, {"w": "TensorFlow", "b": [0.6959, 0.0793, 0.7857, 0.0989]}, {"w": "much", "b": [0.2714, 0.0967, 0.315, 0.1163]}, {"w": "easier", "b": [0.3206, 0.0967, 0.3643, 0.1163]}, {"w": "to", "b": [0.37, 0.0967, 0.3855, 0.1163]}, {"w": "use.", "b": [0.3911, 0.0967, 0.4207, 0.1163]}, {"w": "The", "b": [0.4263, 0.0967, 0.4563, 0.1163]}, {"w": "first", "b": [0.4619, 0.0967, 0.4926, 0.1163]}, {"w": "edition", "b": [0.4982, 0.0967, 0.5525, 0.1163]}, {"w": "of", "b": [0.5581, 0.0967, 0.5735, 0.1163]}, {"w": "this", "b": [0.5791, 0.0967, 0.6072, 0.1163]}, {"w": "book", "b": [0.6128, 0.0967, 0.6514, 0.1163]}, {"w": "used", "b": [0.657, 0.0967, 0.6923, 0.1163]}, {"w": "TF", "b": [0.6979, 0.0967, 0.7197, 0.1163]}, {"w": "1,", "b": [0.7254, 0.0967, 0.7388, 0.1163]}, {"w": "while", "b": [0.7445, 0.0967, 0.7857, 0.1163]}, {"w": "this", "b": [0.2714, 0.1141, 0.2995, 0.1337]}, {"w": "edition", "b": [0.3038, 0.1141, 0.3581, 0.1337]}, {"w": "uses", "b": [0.3624, 0.1141, 0.3946, 0.1337]}, {"w": "TF", "b": [0.399, 0.1141, 0.4208, 0.1337]}, {"w": "2.", "b": [0.4251, 0.1141, 0.4386, 0.1337]}]}, {"id": "b_2", "type": "paragraph", "text": "A Quick Tour of TensorFlow", "words": [{"w": "A", "b": [0.1429, 0.1741, 0.1597, 0.2084]}, {"w": "Quick", "b": [0.1656, 0.1741, 0.2331, 0.2084]}, {"w": "Tour", "b": [0.239, 0.1741, 0.2948, 0.2084]}, {"w": "of", "b": [0.3007, 0.1741, 0.3259, 0.2084]}, {"w": "TensorFlow", "b": [0.3318, 0.1741, 0.4737, 0.2084]}]}, {"id": "b_3", "type": "paragraph", "text": "As you know, TensorFlow is a powerful library for numerical computation, particu‐ larly well suited and fine-tuned for large-scale Machine Learning (but you could use it for anything else that requires heavy computations). It was developed by the Google Brain team and it powers many of Google’s large-scale services, such as Google Cloud Speech, Google Photos, and Google Search. It was open sourced in November 2015, and it is now the most popular deep learning library (in terms of citations in papers, adoption in companies, stars on github, etc.): countless projects use TensorFlow for all sorts of Machine Learning tasks, such as image classification, natural language processing (NLP), recommender systems, time series forecasting, and much more.", "words": [{"w": "As", "b": [0.1429, 0.2153, 0.1649, 0.2367]}, {"w": "you", "b": [0.1718, 0.2153, 0.203, 0.2367]}, {"w": "know,", "b": [0.21, 0.2153, 0.2598, 0.2367]}, {"w": "TensorFlow", "b": [0.2667, 0.2151, 0.3605, 0.2367]}, {"w": "is", "b": [0.3674, 0.2153, 0.3806, 0.2367]}, {"w": "a", "b": [0.3875, 0.2153, 0.3966, 0.2367]}, {"w": "powerful", "b": [0.4036, 0.2153, 0.4784, 0.2367]}, {"w": "library", "b": [0.4854, 0.2153, 0.5416, 0.2367]}, {"w": "for", "b": [0.5485, 0.2153, 0.573, 0.2367]}, {"w": "numerical", "b": [0.5799, 0.2153, 0.6644, 0.2367]}, {"w": "computation,", "b": [0.6713, 0.2153, 0.7832, 0.2367]}, {"w": "particu‐", "b": [0.7901, 0.2153, 0.8571, 0.2367]}, {"w": "larly", "b": [0.1429, 0.2344, 0.1798, 0.2558]}, {"w": "well", "b": [0.1859, 0.2344, 0.2195, 0.2558]}, {"w": "suited", "b": [0.2255, 0.2344, 0.276, 0.2558]}, {"w": "and", "b": [0.282, 0.2344, 0.3136, 0.2558]}, {"w": "fine-tuned", "b": [0.3196, 0.2344, 0.4077, 0.2558]}, {"w": "for", "b": [0.4137, 0.2344, 0.4382, 0.2558]}, {"w": "large-scale", "b": [0.4442, 0.2344, 0.5321, 0.2558]}, {"w": "Machine", "b": [0.5381, 0.2344, 0.6112, 0.2558]}, {"w": "Learning", "b": [0.6173, 0.2344, 0.6923, 0.2558]}, {"w": "(but", "b": [0.6983, 0.2344, 0.7335, 0.2558]}, {"w": "you", "b": [0.7395, 0.2344, 0.7708, 0.2558]}, {"w": "could", "b": [0.7768, 0.2344, 0.8236, 0.2558]}, {"w": "use", "b": [0.8296, 0.2344, 0.8572, 0.2558]}, {"w": "it", "b": [0.1429, 0.2534, 0.1548, 0.2748]}, {"w": "for", "b": [0.1596, 0.2534, 0.1841, 0.2748]}, {"w": "anything", "b": [0.189, 0.2534, 0.2628, 0.2748]}, {"w": "else", "b": [0.2676, 0.2534, 0.2983, 0.2748]}, {"w": "that", "b": [0.3031, 0.2534, 0.3357, 0.2748]}, {"w": "requires", "b": [0.3405, 0.2534, 0.4086, 0.2748]}, {"w": "heavy", "b": [0.4134, 0.2534, 0.4614, 0.2748]}, {"w": "computations).", "b": [0.4662, 0.2534, 0.593, 0.2748]}, {"w": "It", "b": [0.5978, 0.2534, 0.6104, 0.2748]}, {"w": "was", "b": [0.6153, 0.2534, 0.6463, 0.2748]}, {"w": "developed", "b": [0.6511, 0.2534, 0.7362, 0.2748]}, {"w": "by", "b": [0.741, 0.2534, 0.7611, 0.2748]}, {"w": "the", "b": [0.766, 0.2534, 0.7923, 0.2748]}, {"w": "Google", "b": [0.797, 0.2534, 0.857, 0.2748]}, {"w": "Brain", "b": [0.1429, 0.2724, 0.189, 0.2939]}, {"w": "team", "b": [0.194, 0.2724, 0.2354, 0.2939]}, {"w": "and", "b": [0.2404, 0.2724, 0.272, 0.2939]}, {"w": "it", "b": [0.277, 0.2724, 0.2889, 0.2939]}, {"w": "powers", "b": [0.294, 0.2724, 0.354, 0.2939]}, {"w": "many", "b": [0.359, 0.2724, 0.4057, 0.2939]}, {"w": "of", "b": [0.4108, 0.2724, 0.4275, 0.2939]}, {"w": "Google’s", "b": [0.4326, 0.2724, 0.5017, 0.2939]}, {"w": "large-scale", "b": [0.5067, 0.2724, 0.5946, 0.2939]}, {"w": "services,", "b": [0.5996, 0.2724, 0.6698, 0.2939]}, {"w": "such", "b": [0.6748, 0.2724, 0.7134, 0.2939]}, {"w": "as", "b": [0.7185, 0.2724, 0.7353, 0.2939]}, {"w": "Google", "b": [0.7403, 0.2724, 0.8003, 0.2939]}, {"w": "Cloud", "b": [0.8053, 0.2724, 0.8571, 0.2939]}, {"w": "Speech,", "b": [0.1429, 0.2915, 0.206, 0.3129]}, {"w": "Google", "b": [0.2123, 0.2915, 0.2723, 0.3129]}, {"w": "Photos,", "b": [0.2786, 0.2915, 0.3414, 0.3129]}, {"w": "and", "b": [0.3477, 0.2915, 0.3792, 0.3129]}, {"w": "Google", "b": [0.3855, 0.2915, 0.4455, 0.3129]}, {"w": "Search.", "b": [0.4518, 0.2915, 0.5121, 0.3129]}, {"w": "It", "b": [0.5183, 0.2915, 0.531, 0.3129]}, {"w": "was", "b": [0.5372, 0.2915, 0.5683, 0.3129]}, {"w": "open", "b": [0.5745, 0.2915, 0.6163, 0.3129]}, {"w": "sourced", "b": [0.6226, 0.2915, 0.6883, 0.3129]}, {"w": "in", "b": [0.6946, 0.2915, 0.7116, 0.3129]}, {"w": "November", "b": [0.7178, 0.2915, 0.8061, 0.3129]}, {"w": "2015,", "b": [0.8124, 0.2915, 0.8571, 0.3129]}, {"w": "and", "b": [0.1428, 0.3105, 0.1744, 0.332]}, {"w": "it", "b": [0.1801, 0.3105, 0.1921, 0.332]}, {"w": "is", "b": [0.1978, 0.3105, 0.2111, 0.332]}, {"w": "now", "b": [0.2168, 0.3105, 0.2531, 0.332]}, {"w": "the", "b": [0.2589, 0.3105, 0.2852, 0.332]}, {"w": "most", "b": [0.291, 0.3105, 0.3327, 0.332]}, {"w": "popular", "b": [0.3384, 0.3105, 0.4041, 0.332]}, {"w": "deep", "b": [0.4098, 0.3105, 0.4495, 0.332]}, {"w": "learning", "b": [0.4552, 0.3105, 0.5244, 0.332]}, {"w": "library", "b": [0.5301, 0.3105, 0.5863, 0.332]}, {"w": "(in", "b": [0.5921, 0.3105, 0.6163, 0.332]}, {"w": "terms", "b": [0.622, 0.3105, 0.6697, 0.332]}, {"w": "of", "b": [0.6754, 0.3105, 0.6922, 0.332]}, {"w": "citations", "b": [0.698, 0.3105, 0.7691, 0.332]}, {"w": "in", "b": [0.7748, 0.3105, 0.7918, 0.332]}, {"w": "papers,", "b": [0.7976, 0.3105, 0.8571, 0.332]}, {"w": "adoption", "b": [0.1429, 0.3296, 0.2185, 0.351]}, {"w": "in", "b": [0.2252, 0.3296, 0.2422, 0.351]}, {"w": "companies,", "b": [0.2489, 0.3296, 0.3433, 0.351]}, {"w": "stars", "b": [0.35, 0.3296, 0.3886, 0.351]}, {"w": "on", "b": [0.3953, 0.3296, 0.4173, 0.351]}, {"w": "github,", "b": [0.424, 0.3296, 0.4822, 0.351]}, {"w": "etc.):", "b": [0.489, 0.3296, 0.5297, 0.351]}, {"w": "countless", "b": [0.5364, 0.3296, 0.6137, 0.351]}, {"w": "projects", "b": [0.6204, 0.3296, 0.6867, 0.351]}, {"w": "use", "b": [0.6934, 0.3296, 0.7209, 0.351]}, {"w": "TensorFlow", "b": [0.7277, 0.3296, 0.8259, 0.351]}, {"w": "for", "b": [0.8326, 0.3296, 0.8572, 0.351]}, {"w": "all", "b": [0.1429, 0.3486, 0.1625, 0.37]}, {"w": "sorts", "b": [0.1709, 0.3486, 0.2109, 0.37]}, {"w": "of", "b": [0.2192, 0.3486, 0.236, 0.37]}, {"w": "Machine", "b": [0.2443, 0.3486, 0.3175, 0.37]}, {"w": "Learning", "b": [0.3258, 0.3486, 0.4009, 0.37]}, {"w": "tasks,", "b": [0.4092, 0.3486, 0.4551, 0.37]}, {"w": "such", "b": [0.4634, 0.3486, 0.5021, 0.37]}, {"w": "as", "b": [0.5104, 0.3486, 0.5272, 0.37]}, {"w": "image", "b": [0.5355, 0.3486, 0.5859, 0.37]}, {"w": "classification,", "b": [0.5943, 0.3486, 0.7064, 0.37]}, {"w": "natural", "b": [0.7147, 0.3486, 0.7744, 0.37]}, {"w": "language", "b": [0.7828, 0.3486, 0.8571, 0.37]}, {"w": "processing", "b": [0.1429, 0.3677, 0.2318, 0.3891]}, {"w": "(NLP),", "b": [0.2365, 0.3677, 0.2941, 0.3891]}, {"w": "recommender", "b": [0.2989, 0.3677, 0.4168, 0.3891]}, {"w": "systems,", "b": [0.4216, 0.3677, 0.4911, 0.3891]}, {"w": "time", "b": [0.4958, 0.3677, 0.5337, 0.3891]}, {"w": "series", "b": [0.5384, 0.3677, 0.5847, 0.3891]}, {"w": "forecasting,", "b": [0.5894, 0.3677, 0.6862, 0.3891]}, {"w": "and", "b": [0.691, 0.3677, 0.7225, 0.3891]}, {"w": "much", "b": [0.7272, 0.3677, 0.7749, 0.3891]}, {"w": "more.", "b": [0.7796, 0.3677, 0.8287, 0.3891]}]}, {"id": "b_4", "type": "paragraph", "text": "So what does TensorFlow actually offer? Here’s a summary:", "words": [{"w": "So", "b": [0.1429, 0.3958, 0.1634, 0.4172]}, {"w": "what", "b": [0.1681, 0.3958, 0.2086, 0.4172]}, {"w": "does", "b": [0.2133, 0.3958, 0.2514, 0.4172]}, {"w": "TensorFlow", "b": [0.2562, 0.3958, 0.3544, 0.4172]}, {"w": "actually", "b": [0.3591, 0.3958, 0.4238, 0.4172]}, {"w": "offer?", "b": [0.4285, 0.3958, 0.4759, 0.4172]}, {"w": "Here’s", "b": [0.4807, 0.3958, 0.5306, 0.4172]}, {"w": "a", "b": [0.5354, 0.3958, 0.5445, 0.4172]}, {"w": "summary:", "b": [0.5492, 0.3958, 0.6345, 0.4172]}]}, {"id": "b_5", "type": "paragraph", "text": "• Its core is very similar to NumPy, but with GPU support.", "words": [{"w": "•", "b": [0.16, 0.43, 0.1681, 0.4514]}, {"w": "Its", "b": [0.1786, 0.43, 0.1989, 0.4514]}, {"w": "core", "b": [0.2036, 0.43, 0.2396, 0.4514]}, {"w": "is", "b": [0.2443, 0.43, 0.2576, 0.4514]}, {"w": "very", "b": [0.2623, 0.43, 0.2987, 0.4514]}, {"w": "similar", "b": [0.3034, 0.43, 0.3614, 0.4514]}, {"w": "to", "b": [0.3662, 0.43, 0.3831, 0.4514]}, {"w": "NumPy,", "b": [0.3879, 0.43, 0.4553, 0.4514]}, {"w": "but", "b": [0.46, 0.43, 0.488, 0.4514]}, {"w": "with", "b": [0.4927, 0.43, 0.5301, 0.4514]}, {"w": "GPU", "b": [0.5348, 0.43, 0.5768, 0.4514]}, {"w": "support.", "b": [0.5815, 0.43, 0.6515, 0.4514]}]}, {"id": "b_6", "type": "paragraph", "text": "• It also supports distributed computing (across multiple devices and servers).", "words": [{"w": "•", "b": [0.16, 0.4551, 0.1682, 0.4765]}, {"w": "It", "b": [0.1786, 0.4551, 0.1912, 0.4765]}, {"w": "also", "b": [0.1959, 0.4551, 0.2286, 0.4765]}, {"w": "supports", "b": [0.2334, 0.4551, 0.3063, 0.4765]}, {"w": "distributed", "b": [0.311, 0.4551, 0.4027, 0.4765]}, {"w": "computing", "b": [0.4075, 0.4551, 0.4986, 0.4765]}, {"w": "(across", "b": [0.5034, 0.4551, 0.5622, 0.4765]}, {"w": "multiple", "b": [0.5669, 0.4551, 0.6369, 0.4765]}, {"w": "devices", "b": [0.6416, 0.4551, 0.702, 0.4765]}, {"w": "and", "b": [0.7067, 0.4551, 0.7383, 0.4765]}, {"w": "servers).", "b": [0.743, 0.4551, 0.8137, 0.4765]}]}, {"id": "b_7", "type": "paragraph", "text": "• It includes a kind of just-in-time (JIT) compiler that allows it to optimize compu‐ tations for speed and memory usage: it works by extracting the computation graph from a Python function, then optimizing it (e.g., by pruning unused nodes) and finally running it efficiently (e.g., by automatically running independent operations in parallel).", "words": [{"w": "•", "b": [0.16, 0.4802, 0.1682, 0.5016]}, {"w": "It", "b": [0.1786, 0.4802, 0.1912, 0.5016]}, {"w": "includes", "b": [0.1961, 0.4802, 0.2657, 0.5016]}, {"w": "a", "b": [0.2705, 0.4802, 0.2797, 0.5016]}, {"w": "kind", "b": [0.2845, 0.4802, 0.3228, 0.5016]}, {"w": "of", "b": [0.3277, 0.4802, 0.3445, 0.5016]}, {"w": "just-in-time", "b": [0.3493, 0.4802, 0.4494, 0.5016]}, {"w": "(JIT)", "b": [0.4542, 0.4802, 0.4958, 0.5016]}, {"w": "compiler", "b": [0.5006, 0.4802, 0.5751, 0.5016]}, {"w": "that", "b": [0.58, 0.4802, 0.6125, 0.5016]}, {"w": "allows", "b": [0.6174, 0.4802, 0.6696, 0.5016]}, {"w": "it", "b": [0.6745, 0.4802, 0.6864, 0.5016]}, {"w": "to", "b": [0.6912, 0.4802, 0.7082, 0.5016]}, {"w": "optimize", "b": [0.7131, 0.4802, 0.7868, 0.5016]}, {"w": "compu‐", "b": [0.7916, 0.4802, 0.8571, 0.5016]}, {"w": "tations", "b": [0.1786, 0.4992, 0.2353, 0.5206]}, {"w": "for", "b": [0.2444, 0.4992, 0.2689, 0.5206]}, {"w": "speed", "b": [0.2781, 0.4992, 0.3253, 0.5206]}, {"w": "and", "b": [0.3345, 0.4992, 0.366, 0.5206]}, {"w": "memory", "b": [0.3751, 0.4992, 0.4466, 0.5206]}, {"w": "usage:", "b": [0.4557, 0.4992, 0.507, 0.5206]}, {"w": "it", "b": [0.5161, 0.4992, 0.528, 0.5206]}, {"w": "works", "b": [0.5371, 0.4992, 0.5877, 0.5206]}, {"w": "by", "b": [0.5969, 0.4992, 0.617, 0.5206]}, {"w": "extracting", "b": [0.6261, 0.4992, 0.71, 0.5206]}, {"w": "the", "b": [0.7191, 0.4992, 0.7454, 0.5206]}, {"w": "computation", "b": [0.7545, 0.499, 0.8571, 0.5206]}, {"w": "graph", "b": [0.1786, 0.518, 0.2252, 0.5397]}, {"w": "from", "b": [0.23, 0.5183, 0.2716, 0.5397]}, {"w": "a", "b": [0.2764, 0.5183, 0.2855, 0.5397]}, {"w": "Python", "b": [0.2903, 0.5183, 0.3511, 0.5397]}, {"w": "function,", "b": [0.3559, 0.5183, 0.4321, 0.5397]}, {"w": "then", "b": [0.4369, 0.5183, 0.4746, 0.5397]}, {"w": "optimizing", "b": [0.4794, 0.5183, 0.571, 0.5397]}, {"w": "it", "b": [0.5758, 0.5183, 0.5878, 0.5397]}, {"w": "(e.g.,", "b": [0.5926, 0.5183, 0.6326, 0.5397]}, {"w": "by", "b": [0.6374, 0.5183, 0.6576, 0.5397]}, {"w": "pruning", "b": [0.6624, 0.5183, 0.7302, 0.5397]}, {"w": "unused", "b": [0.735, 0.5183, 0.7956, 0.5397]}, {"w": "nodes)", "b": [0.8004, 0.5183, 0.8571, 0.5397]}, {"w": "and", "b": [0.1786, 0.5373, 0.2101, 0.5587]}, {"w": "finally", "b": [0.2196, 0.5373, 0.272, 0.5587]}, {"w": "running", "b": [0.2816, 0.5373, 0.3499, 0.5587]}, {"w": "it", "b": [0.3594, 0.5373, 0.3714, 0.5587]}, {"w": "efficiently", "b": [0.3809, 0.5373, 0.4631, 0.5587]}, {"w": "(e.g.,", "b": [0.4726, 0.5373, 0.5127, 0.5587]}, {"w": "by", "b": [0.5223, 0.5373, 0.5424, 0.5587]}, {"w": "automatically", "b": [0.5519, 0.5373, 0.6645, 0.5587]}, {"w": "running", "b": [0.6741, 0.5373, 0.7424, 0.5587]}, {"w": "independent", "b": [0.7519, 0.5373, 0.8571, 0.5587]}, {"w": "operations", "b": [0.1786, 0.5563, 0.2671, 0.5778]}, {"w": "in", "b": [0.2718, 0.5563, 0.2888, 0.5778]}, {"w": "parallel).", "b": [0.2935, 0.5563, 0.3671, 0.5778]}]}, {"id": "b_8", "type": "paragraph", "text": "• Computation graphs can be exported to a portable format, so you can train a TensorFlow model in one environment (e.g., using Python on Linux), and run it in another (e.g., using Java on an Android device).", "words": [{"w": "•", "b": [0.16, 0.5814, 0.1682, 0.6029]}, {"w": "Computation", "b": [0.1786, 0.5814, 0.2908, 0.6029]}, {"w": "graphs", "b": [0.2986, 0.5814, 0.3545, 0.6029]}, {"w": "can", "b": [0.3624, 0.5814, 0.3918, 0.6029]}, {"w": "be", "b": [0.3996, 0.5814, 0.4191, 0.6029]}, {"w": "exported", "b": [0.4269, 0.5814, 0.5011, 0.6029]}, {"w": "to", "b": [0.509, 0.5814, 0.5259, 0.6029]}, {"w": "a", "b": [0.5338, 0.5814, 0.5429, 0.6029]}, {"w": "portable", "b": [0.5508, 0.5814, 0.6203, 0.6029]}, {"w": "format,", "b": [0.6281, 0.5814, 0.6896, 0.6029]}, {"w": "so", "b": [0.6974, 0.5814, 0.7157, 0.6029]}, {"w": "you", "b": [0.7236, 0.5814, 0.7548, 0.6029]}, {"w": "can", "b": [0.7627, 0.5814, 0.7921, 0.6029]}, {"w": "train", "b": [0.7999, 0.5814, 0.8401, 0.6029]}, {"w": "a", "b": [0.848, 0.5814, 0.8571, 0.6029]}, {"w": "TensorFlow", "b": [0.1786, 0.6005, 0.2768, 0.6219]}, {"w": "model", "b": [0.2826, 0.6005, 0.3354, 0.6219]}, {"w": "in", "b": [0.3411, 0.6005, 0.3581, 0.6219]}, {"w": "one", "b": [0.3639, 0.6005, 0.3947, 0.6219]}, {"w": "environment", "b": [0.4005, 0.6005, 0.5085, 0.6219]}, {"w": "(e.g.,", "b": [0.5143, 0.6005, 0.5543, 0.6219]}, {"w": "using", "b": [0.5601, 0.6005, 0.6055, 0.6219]}, {"w": "Python", "b": [0.6113, 0.6005, 0.6721, 0.6219]}, {"w": "on", "b": [0.6778, 0.6005, 0.6998, 0.6219]}, {"w": "Linux),", "b": [0.7056, 0.6005, 0.7662, 0.6219]}, {"w": "and", "b": [0.772, 0.6005, 0.8035, 0.6219]}, {"w": "run", "b": [0.8093, 0.6005, 0.8395, 0.6219]}, {"w": "it", "b": [0.8452, 0.6005, 0.8571, 0.6219]}, {"w": "in", "b": [0.1786, 0.6195, 0.1955, 0.6409]}, {"w": "another", "b": [0.2003, 0.6195, 0.2655, 0.6409]}, {"w": "(e.g.,", "b": [0.2702, 0.6195, 0.3103, 0.6409]}, {"w": "using", "b": [0.315, 0.6195, 0.3605, 0.6409]}, {"w": "Java", "b": [0.3652, 0.6195, 0.399, 0.6409]}, {"w": "on", "b": [0.4038, 0.6195, 0.4258, 0.6409]}, {"w": "an", "b": [0.4305, 0.6195, 0.451, 0.6409]}, {"w": "Android", "b": [0.4558, 0.6195, 0.5275, 0.6409]}, {"w": "device).", "b": [0.5322, 0.6195, 0.5969, 0.6409]}]}, {"id": "b_9", "type": "paragraph", "text": "• It implements autodiff (see Chapter 10 and ???), and provides some excellent optimizers, such as RMSProp, Nadam and FTRL (see Chapter 11), so you can easily minimize all sorts of loss functions.", "words": [{"w": "•", "b": [0.16, 0.6446, 0.1682, 0.666]}, {"w": "It", "b": [0.1786, 0.6446, 0.1912, 0.666]}, {"w": "implements", "b": [0.1997, 0.6446, 0.298, 0.666]}, {"w": "autodiff", "b": [0.3065, 0.6446, 0.3722, 0.666]}, {"w": "(see", "b": [0.3807, 0.6446, 0.4133, 0.666]}, {"w": "Chapter", "b": [0.4218, 0.6446, 0.4894, 0.666]}, {"w": "10", "b": [0.4979, 0.6446, 0.5179, 0.666]}, {"w": "and", "b": [0.5265, 0.6446, 0.558, 0.666]}, {"w": "???),", "b": [0.5665, 0.6446, 0.6022, 0.666]}, {"w": "and", "b": [0.6107, 0.6446, 0.6423, 0.666]}, {"w": "provides", "b": [0.6508, 0.6446, 0.7228, 0.666]}, {"w": "some", "b": [0.7313, 0.6446, 0.7755, 0.666]}, {"w": "excellent", "b": [0.784, 0.6446, 0.8571, 0.666]}, {"w": "optimizers,", "b": [0.1786, 0.6637, 0.2724, 0.6851]}, {"w": "such", "b": [0.28, 0.6637, 0.3187, 0.6851]}, {"w": "as", "b": [0.3262, 0.6637, 0.343, 0.6851]}, {"w": "RMSProp,", "b": [0.3506, 0.6637, 0.4371, 0.6851]}, {"w": "Nadam", "b": [0.4447, 0.6637, 0.506, 0.6851]}, {"w": "and", "b": [0.5136, 0.6637, 0.5451, 0.6851]}, {"w": "FTRL", "b": [0.5527, 0.6637, 0.6007, 0.6851]}, {"w": "(see", "b": [0.6083, 0.6637, 0.6408, 0.6851]}, {"w": "Chapter", "b": [0.6484, 0.6637, 0.716, 0.6851]}, {"w": "11),", "b": [0.7236, 0.6637, 0.7555, 0.6851]}, {"w": "so", "b": [0.7631, 0.6637, 0.7814, 0.6851]}, {"w": "you", "b": [0.789, 0.6637, 0.8202, 0.6851]}, {"w": "can", "b": [0.8278, 0.6637, 0.8571, 0.6851]}, {"w": "easily", "b": [0.1786, 0.6827, 0.2246, 0.7041]}, {"w": "minimize", "b": [0.2294, 0.6827, 0.3092, 0.7041]}, {"w": "all", "b": [0.314, 0.6827, 0.3336, 0.7041]}, {"w": "sorts", "b": [0.3384, 0.6827, 0.3784, 0.7041]}, {"w": "of", "b": [0.3831, 0.6827, 0.3999, 0.7041]}, {"w": "loss", "b": [0.4046, 0.6827, 0.4358, 0.7041]}, {"w": "functions.", "b": [0.4405, 0.6827, 0.5243, 0.7041]}]}, {"id": "b_10", "type": "paragraph", "text": "• TensorFlow offers many more features, built on top of these core features: the most important is of course tf.keras1, but it also has data loading & preprocessing ops (tf.data, tf.io, etc.), image processing ops (tf.image), signal processing ops (tf.signal), and more (see Figure 12-1 for an overview of TensorFlow’s Python API).", "words": [{"w": "•", "b": [0.16, 0.7078, 0.1682, 0.7292]}, {"w": "TensorFlow", "b": [0.1786, 0.7078, 0.2768, 0.7292]}, {"w": "offers", "b": [0.2844, 0.7078, 0.3316, 0.7292]}, {"w": "many", "b": [0.3392, 0.7078, 0.3859, 0.7292]}, {"w": "more", "b": [0.3935, 0.7078, 0.4377, 0.7292]}, {"w": "features,", "b": [0.4453, 0.7078, 0.5155, 0.7292]}, {"w": "built", "b": [0.5231, 0.7078, 0.5619, 0.7292]}, {"w": "on", "b": [0.5695, 0.7078, 0.5915, 0.7292]}, {"w": "top", "b": [0.5991, 0.7078, 0.627, 0.7292]}, {"w": "of", "b": [0.6346, 0.7078, 0.6514, 0.7292]}, {"w": "these", "b": [0.659, 0.7078, 0.7018, 0.7292]}, {"w": "core", "b": [0.7094, 0.7078, 0.7455, 0.7292]}, {"w": "features:", "b": [0.753, 0.7078, 0.8232, 0.7292]}, {"w": "the", "b": [0.8308, 0.7078, 0.8571, 0.7292]}, {"w": "most", "b": [0.1786, 0.7269, 0.2203, 0.7483]}, {"w": "important", "b": [0.2254, 0.7269, 0.3098, 0.7483]}, {"w": "is", "b": [0.3149, 0.7269, 0.3281, 0.7483]}, {"w": "of", "b": [0.3332, 0.7269, 0.35, 0.7483]}, {"w": "course", "b": [0.3551, 0.7269, 0.4098, 0.7483]}, {"w": "tf.keras1,", "b": [0.415, 0.7269, 0.4864, 0.7483]}, {"w": "but", "b": [0.4915, 0.7269, 0.5195, 0.7483]}, {"w": "it", "b": [0.5246, 0.7269, 0.5366, 0.7483]}, {"w": "also", "b": [0.5417, 0.7269, 0.5744, 0.7483]}, {"w": "has", "b": [0.5795, 0.7269, 0.6074, 0.7483]}, {"w": "data", "b": [0.6125, 0.7269, 0.6478, 0.7483]}, {"w": "loading", "b": [0.6529, 0.7269, 0.7156, 0.7483]}, {"w": "&", "b": [0.7208, 0.7269, 0.7356, 0.7483]}, {"w": "preprocessing", "b": [0.7407, 0.7269, 0.8571, 0.7483]}, {"w": "ops", "b": [0.1786, 0.7459, 0.2078, 0.7673]}, {"w": "(tf.data,", "b": [0.2162, 0.7459, 0.2807, 0.7673]}, {"w": "tf.io,", "b": [0.2891, 0.7459, 0.3267, 0.7673]}, {"w": "etc.),", "b": [0.3351, 0.7459, 0.3759, 0.7673]}, {"w": "image", "b": [0.3843, 0.7459, 0.4347, 0.7673]}, {"w": "processing", "b": [0.4431, 0.7459, 0.5321, 0.7673]}, {"w": "ops", "b": [0.5405, 0.7459, 0.5697, 0.7673]}, {"w": "(tf.image),", "b": [0.5781, 0.7459, 0.6649, 0.7673]}, {"w": "signal", "b": [0.6733, 0.7459, 0.7221, 0.7673]}, {"w": "processing", "b": [0.7306, 0.7459, 0.8195, 0.7673]}, {"w": "ops", "b": [0.8279, 0.7459, 0.8571, 0.7673]}, {"w": "(tf.signal),", "b": [0.1786, 0.765, 0.2638, 0.7864]}, {"w": "and", "b": [0.2717, 0.765, 0.3032, 0.7864]}, {"w": "more", "b": [0.3111, 0.765, 0.3553, 0.7864]}, {"w": "(see", "b": [0.3632, 0.765, 0.3958, 0.7864]}, {"w": "Figure", "b": [0.4036, 0.765, 0.4576, 0.7864]}, {"w": "12-1", "b": [0.4655, 0.765, 0.5029, 0.7864]}, {"w": "for", "b": [0.5108, 0.765, 0.5353, 0.7864]}, {"w": "an", "b": [0.5432, 0.765, 0.5637, 0.7864]}, {"w": "overview", "b": [0.5716, 0.765, 0.6474, 0.7864]}, {"w": "of", "b": [0.6553, 0.765, 0.6721, 0.7864]}, {"w": "TensorFlow’s", "b": [0.6799, 0.765, 0.7885, 0.7864]}, {"w": "Python", "b": [0.7964, 0.765, 0.8571, 0.7864]}, {"w": "API).", "b": [0.1786, 0.784, 0.2238, 0.8054]}]}, {"id": "b_11", "type": "paragraph", "text": "368 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "368", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2746, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 395, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "2 If you ever need to (but you probably won’t), you can write your own operations using the C++ API.", "words": [{"w": "2", "b": [0.1451, 0.8416, 0.1518, 0.8559]}, {"w": "If", "b": [0.1587, 0.8401, 0.1688, 0.8565]}, {"w": "you", "b": [0.1724, 0.8401, 0.1963, 0.8565]}, {"w": "ever", "b": [0.1999, 0.8401, 0.2266, 0.8565]}, {"w": "need", "b": [0.2302, 0.8401, 0.2607, 0.8565]}, {"w": "to", "b": [0.2643, 0.8401, 0.2773, 0.8565]}, {"w": "(but", "b": [0.2809, 0.8401, 0.3077, 0.8565]}, {"w": "you", "b": [0.3113, 0.8401, 0.3351, 0.8565]}, {"w": "probably", "b": [0.3387, 0.8401, 0.3954, 0.8565]}, {"w": "won’t),", "b": [0.399, 0.8401, 0.4423, 0.8565]}, {"w": "you", "b": [0.4459, 0.8401, 0.4697, 0.8565]}, {"w": "can", "b": [0.4733, 0.8401, 0.4957, 0.8565]}, {"w": "write", "b": [0.4993, 0.8401, 0.5319, 0.8565]}, {"w": "your", "b": [0.5355, 0.8401, 0.5652, 0.8565]}, {"w": "own", "b": [0.5688, 0.8401, 0.5965, 0.8565]}, {"w": "operations", "b": [0.6001, 0.8401, 0.6675, 0.8565]}, {"w": "using", "b": [0.6711, 0.8401, 0.7057, 0.8565]}, {"w": "the", "b": [0.7093, 0.8401, 0.7294, 0.8565]}, {"w": "C++", "b": [0.733, 0.8401, 0.762, 0.8565]}, {"w": "API.", "b": [0.7656, 0.8401, 0.7945, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "3 If you are a researcher, you may be eligible to use these TPUs for free, see https://tensorflow.org/tfrc/ for more details.", "words": [{"w": "3", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "If", "b": [0.1587, 0.8598, 0.1688, 0.8761]}, {"w": "you", "b": [0.1724, 0.8598, 0.1963, 0.8761]}, {"w": "are", "b": [0.1999, 0.8598, 0.2195, 0.8761]}, {"w": "a", "b": [0.2231, 0.8598, 0.23, 0.8761]}, {"w": "researcher,", "b": [0.2336, 0.8598, 0.3021, 0.8761]}, {"w": "you", "b": [0.3057, 0.8598, 0.3296, 0.8761]}, {"w": "may", "b": [0.3332, 0.8598, 0.3601, 0.8761]}, {"w": "be", "b": [0.3637, 0.8598, 0.3785, 0.8761]}, {"w": "eligible", "b": [0.3821, 0.8598, 0.4277, 0.8761]}, {"w": "to", "b": [0.4313, 0.8598, 0.4442, 0.8761]}, {"w": "use", "b": [0.4478, 0.8598, 0.4688, 0.8761]}, {"w": "these", "b": [0.4724, 0.8598, 0.505, 0.8761]}, {"w": "TPUs", "b": [0.5087, 0.8598, 0.544, 0.8761]}, {"w": "for", "b": [0.5477, 0.8598, 0.5663, 0.8761]}, {"w": "free,", "b": [0.5699, 0.8598, 0.5976, 0.8761]}, {"w": "see", "b": [0.6012, 0.8598, 0.6206, 0.8761]}, {"w": "https://tensorflow.org/tfrc/", "b": [0.6242, 0.8596, 0.7887, 0.8761]}, {"w": "for", "b": [0.7923, 0.8598, 0.811, 0.8761]}, {"w": "more", "b": [0.8146, 0.8598, 0.8483, 0.8761]}, {"w": "details.", "b": [0.1587, 0.8749, 0.2034, 0.8912]}]}, {"id": "b_2", "type": "equation", "text": "Figure 12-1. TensorFlow’s Python API", "words": [{"w": "Figure", "b": [0.1429, 0.3784, 0.1943, 0.4]}, {"w": "12-1.", "b": [0.1991, 0.3784, 0.2407, 0.4]}, {"w": "TensorFlow’s", "b": [0.2455, 0.3784, 0.3481, 0.4]}, {"w": "Python", "b": [0.3529, 0.3784, 0.4116, 0.4]}, {"w": "API", "b": [0.4163, 0.3784, 0.4484, 0.4]}]}, {"id": "b_3", "type": "paragraph", "text": "We will cover many of the packages and functions of the Tensor‐ Flow API, but it’s impossible to cover them all so you should really take some time to browse through the API: you will find that it is quite rich and well documented.", "words": [{"w": "We", "b": [0.2714, 0.4205, 0.2962, 0.4401]}, {"w": "will", "b": [0.3025, 0.4205, 0.3303, 0.4401]}, {"w": "cover", "b": [0.3367, 0.4205, 0.3785, 0.4401]}, {"w": "many", "b": [0.3848, 0.4205, 0.4275, 0.4401]}, {"w": "of", "b": [0.4339, 0.4205, 0.4493, 0.4401]}, {"w": "the", "b": [0.4557, 0.4205, 0.4797, 0.4401]}, {"w": "packages", "b": [0.4861, 0.4205, 0.5543, 0.4401]}, {"w": "and", "b": [0.5607, 0.4205, 0.5895, 0.4401]}, {"w": "functions", "b": [0.5959, 0.4205, 0.6682, 0.4401]}, {"w": "of", "b": [0.6746, 0.4205, 0.6899, 0.4401]}, {"w": "the", "b": [0.6963, 0.4205, 0.7204, 0.4401]}, {"w": "Tensor‐", "b": [0.7268, 0.4205, 0.7857, 0.4401]}, {"w": "Flow", "b": [0.2714, 0.4379, 0.3091, 0.4575]}, {"w": "API,", "b": [0.3141, 0.4379, 0.3489, 0.4575]}, {"w": "but", "b": [0.3539, 0.4379, 0.3795, 0.4575]}, {"w": "it’s", "b": [0.3846, 0.4379, 0.4044, 0.4575]}, {"w": "impossible", "b": [0.4095, 0.4379, 0.4912, 0.4575]}, {"w": "to", "b": [0.4963, 0.4379, 0.5118, 0.4575]}, {"w": "cover", "b": [0.5169, 0.4379, 0.5586, 0.4575]}, {"w": "them", "b": [0.5637, 0.4379, 0.6033, 0.4575]}, {"w": "all", "b": [0.6084, 0.4379, 0.6264, 0.4575]}, {"w": "so", "b": [0.6315, 0.4379, 0.6482, 0.4575]}, {"w": "you", "b": [0.6532, 0.4379, 0.6818, 0.4575]}, {"w": "should", "b": [0.6869, 0.4379, 0.7387, 0.4575]}, {"w": "really", "b": [0.7438, 0.4379, 0.7857, 0.4575]}, {"w": "take", "b": [0.2714, 0.4554, 0.3031, 0.4749]}, {"w": "some", "b": [0.309, 0.4554, 0.3494, 0.4749]}, {"w": "time", "b": [0.3553, 0.4554, 0.3899, 0.4749]}, {"w": "to", "b": [0.3958, 0.4554, 0.4113, 0.4749]}, {"w": "browse", "b": [0.4171, 0.4554, 0.4717, 0.4749]}, {"w": "through", "b": [0.4776, 0.4554, 0.5396, 0.4749]}, {"w": "the", "b": [0.5454, 0.4554, 0.5695, 0.4749]}, {"w": "API:", "b": [0.5754, 0.4554, 0.6101, 0.4749]}, {"w": "you", "b": [0.616, 0.4554, 0.6446, 0.4749]}, {"w": "will", "b": [0.6504, 0.4554, 0.6782, 0.4749]}, {"w": "find", "b": [0.6841, 0.4554, 0.7153, 0.4749]}, {"w": "that", "b": [0.7212, 0.4554, 0.751, 0.4749]}, {"w": "it", "b": [0.7568, 0.4554, 0.7678, 0.4749]}, {"w": "is", "b": [0.7736, 0.4554, 0.7857, 0.4749]}, {"w": "quite", "b": [0.2714, 0.4728, 0.3103, 0.4923]}, {"w": "rich", "b": [0.3146, 0.4728, 0.345, 0.4923]}, {"w": "and", "b": [0.3493, 0.4728, 0.3782, 0.4923]}, {"w": "well", "b": [0.3825, 0.4728, 0.4133, 0.4923]}, {"w": "documented.", "b": [0.4176, 0.4728, 0.5176, 0.4923]}]}, {"id": "b_4", "type": "paragraph", "text": "At the lowest level, each TensorFlow operation is implemented using highly efficient C++ code2. Many operations (or ops for short) have multiple implementations, called kernels: each kernel is dedicated to a specific device type, such as CPUs, GPUs, or even TPUs (Tensor Processing Units). As you may know, GPUs can dramatically speed up computations by splitting computations into many smaller chunks and running them in parallel across many GPU threads. TPUs are even faster. You can purchase your own GPU devices (for now, TensorFlow only supports Nvidia cards with CUDA Compute Capability 3.5+), but TPUs are only available on Google Cloud Machine Learning Engine (see ???).3", "words": [{"w": "At", "b": [0.1429, 0.5192, 0.1628, 0.5406]}, {"w": "the", "b": [0.1688, 0.5192, 0.1951, 0.5406]}, {"w": "lowest", "b": [0.2012, 0.5192, 0.2542, 0.5406]}, {"w": "level,", "b": [0.2602, 0.5192, 0.3029, 0.5406]}, {"w": "each", "b": [0.3089, 0.5192, 0.3469, 0.5406]}, {"w": "TensorFlow", "b": [0.3529, 0.5192, 0.4512, 0.5406]}, {"w": "operation", "b": [0.4572, 0.5192, 0.538, 0.5406]}, {"w": "is", "b": [0.5441, 0.5192, 0.5573, 0.5406]}, {"w": "implemented", "b": [0.5634, 0.5192, 0.6738, 0.5406]}, {"w": "using", "b": [0.6798, 0.5192, 0.7253, 0.5406]}, {"w": "highly", "b": [0.7313, 0.5192, 0.7837, 0.5406]}, {"w": "efficient", "b": [0.7898, 0.5192, 0.8571, 0.5406]}, {"w": "C++", "b": [0.1429, 0.5382, 0.1809, 0.5596]}, {"w": "code2.", "b": [0.1864, 0.5382, 0.2361, 0.5596]}, {"w": "Many", "b": [0.2416, 0.5382, 0.2894, 0.5596]}, {"w": "operations", "b": [0.2949, 0.5382, 0.3834, 0.5596]}, {"w": "(or", "b": [0.3889, 0.5382, 0.4145, 0.5596]}, {"w": "ops", "b": [0.42, 0.538, 0.4466, 0.5596]}, {"w": "for", "b": [0.4521, 0.5382, 0.4766, 0.5596]}, {"w": "short)", "b": [0.4821, 0.5382, 0.5328, 0.5596]}, {"w": "have", "b": [0.5383, 0.5382, 0.5767, 0.5596]}, {"w": "multiple", "b": [0.5822, 0.5382, 0.6521, 0.5596]}, {"w": "implementations,", "b": [0.6576, 0.5382, 0.8033, 0.5596]}, {"w": "called", "b": [0.8088, 0.5382, 0.8571, 0.5596]}, {"w": "kernels:", "b": [0.1429, 0.5571, 0.2046, 0.5787]}, {"w": "each", "b": [0.2123, 0.5573, 0.2503, 0.5787]}, {"w": "kernel", "b": [0.258, 0.5573, 0.3104, 0.5787]}, {"w": "is", "b": [0.3181, 0.5573, 0.3313, 0.5787]}, {"w": "dedicated", "b": [0.339, 0.5573, 0.4192, 0.5787]}, {"w": "to", "b": [0.4269, 0.5573, 0.4439, 0.5787]}, {"w": "a", "b": [0.4516, 0.5573, 0.4608, 0.5787]}, {"w": "specific", "b": [0.4685, 0.5573, 0.5308, 0.5787]}, {"w": "device", "b": [0.5385, 0.5573, 0.5913, 0.5787]}, {"w": "type,", "b": [0.599, 0.5573, 0.6394, 0.5787]}, {"w": "such", "b": [0.6471, 0.5573, 0.6858, 0.5787]}, {"w": "as", "b": [0.6935, 0.5573, 0.7102, 0.5787]}, {"w": "CPUs,", "b": [0.7179, 0.5573, 0.7702, 0.5787]}, {"w": "GPUs,", "b": [0.7779, 0.5573, 0.8311, 0.5787]}, {"w": "or", "b": [0.8388, 0.5573, 0.8572, 0.5787]}, {"w": "even", "b": [0.1429, 0.5763, 0.1816, 0.5977]}, {"w": "TPUs", "b": [0.1868, 0.5763, 0.2332, 0.5977]}, {"w": "(Tensor", "b": [0.2384, 0.5761, 0.2998, 0.5977]}, {"w": "Processing", "b": [0.305, 0.5761, 0.388, 0.5977]}, {"w": "Units).", "b": [0.3932, 0.5761, 0.4486, 0.5977]}, {"w": "As", "b": [0.4538, 0.5763, 0.4758, 0.5977]}, {"w": "you", "b": [0.481, 0.5763, 0.5122, 0.5977]}, {"w": "may", "b": [0.5174, 0.5763, 0.5528, 0.5977]}, {"w": "know,", "b": [0.5579, 0.5763, 0.6078, 0.5977]}, {"w": "GPUs", "b": [0.6129, 0.5763, 0.6614, 0.5977]}, {"w": "can", "b": [0.6665, 0.5763, 0.6959, 0.5977]}, {"w": "dramatically", "b": [0.701, 0.5763, 0.8047, 0.5977]}, {"w": "speed", "b": [0.8099, 0.5763, 0.8571, 0.5977]}, {"w": "up", "b": [0.1429, 0.5954, 0.1648, 0.6168]}, {"w": "computations", "b": [0.1721, 0.5954, 0.2869, 0.6168]}, {"w": "by", "b": [0.2942, 0.5954, 0.3143, 0.6168]}, {"w": "splitting", "b": [0.3216, 0.5954, 0.3904, 0.6168]}, {"w": "computations", "b": [0.3977, 0.5954, 0.5125, 0.6168]}, {"w": "into", "b": [0.5197, 0.5954, 0.5533, 0.6168]}, {"w": "many", "b": [0.5606, 0.5954, 0.6073, 0.6168]}, {"w": "smaller", "b": [0.6145, 0.5954, 0.6755, 0.6168]}, {"w": "chunks", "b": [0.6828, 0.5954, 0.7428, 0.6168]}, {"w": "and", "b": [0.75, 0.5954, 0.7816, 0.6168]}, {"w": "running", "b": [0.7888, 0.5954, 0.8571, 0.6168]}, {"w": "them", "b": [0.1429, 0.6144, 0.1862, 0.6358]}, {"w": "in", "b": [0.193, 0.6144, 0.21, 0.6358]}, {"w": "parallel", "b": [0.2168, 0.6144, 0.2784, 0.6358]}, {"w": "across", "b": [0.2852, 0.6144, 0.3368, 0.6358]}, {"w": "many", "b": [0.3436, 0.6144, 0.3903, 0.6358]}, {"w": "GPU", "b": [0.397, 0.6144, 0.439, 0.6358]}, {"w": "threads.", "b": [0.4458, 0.6144, 0.5124, 0.6358]}, {"w": "TPUs", "b": [0.5192, 0.6144, 0.5656, 0.6358]}, {"w": "are", "b": [0.5724, 0.6144, 0.5981, 0.6358]}, {"w": "even", "b": [0.6049, 0.6144, 0.6437, 0.6358]}, {"w": "faster.", "b": [0.6505, 0.6144, 0.6998, 0.6358]}, {"w": "You", "b": [0.7066, 0.6144, 0.7389, 0.6358]}, {"w": "can", "b": [0.7457, 0.6144, 0.7751, 0.6358]}, {"w": "purchase", "b": [0.7818, 0.6144, 0.8571, 0.6358]}, {"w": "your", "b": [0.1429, 0.6335, 0.1818, 0.6549]}, {"w": "own", "b": [0.187, 0.6335, 0.2233, 0.6549]}, {"w": "GPU", "b": [0.2284, 0.6335, 0.2704, 0.6549]}, {"w": "devices", "b": [0.2755, 0.6335, 0.3359, 0.6549]}, {"w": "(for", "b": [0.3411, 0.6335, 0.3728, 0.6549]}, {"w": "now,", "b": [0.378, 0.6335, 0.4175, 0.6549]}, {"w": "TensorFlow", "b": [0.4226, 0.6335, 0.5209, 0.6549]}, {"w": "only", "b": [0.526, 0.6335, 0.5629, 0.6549]}, {"w": "supports", "b": [0.568, 0.6335, 0.6409, 0.6549]}, {"w": "Nvidia", "b": [0.6461, 0.6335, 0.7019, 0.6549]}, {"w": "cards", "b": [0.707, 0.6335, 0.7514, 0.6549]}, {"w": "with", "b": [0.7565, 0.6335, 0.7939, 0.6549]}, {"w": "CUDA", "b": [0.799, 0.6335, 0.8572, 0.6549]}, {"w": "Compute", "b": [0.1429, 0.6525, 0.2212, 0.6739]}, {"w": "Capability", "b": [0.2298, 0.6525, 0.3154, 0.6739]}, {"w": "3.5+),", "b": [0.3239, 0.6525, 0.3727, 0.6739]}, {"w": "but", "b": [0.3813, 0.6525, 0.4093, 0.6739]}, {"w": "TPUs", "b": [0.4179, 0.6525, 0.4643, 0.6739]}, {"w": "are", "b": [0.4729, 0.6525, 0.4986, 0.6739]}, {"w": "only", "b": [0.5072, 0.6525, 0.5441, 0.6739]}, {"w": "available", "b": [0.5526, 0.6525, 0.6249, 0.6739]}, {"w": "on", "b": [0.6335, 0.6525, 0.6555, 0.6739]}, {"w": "Google", "b": [0.6641, 0.6523, 0.72, 0.6739]}, {"w": "Cloud", "b": [0.7286, 0.6523, 0.7782, 0.6739]}, {"w": "Machine", "b": [0.7868, 0.6523, 0.8571, 0.6739]}, {"w": "Learning", "b": [0.1429, 0.6713, 0.2156, 0.693]}, {"w": "Engine", "b": [0.2204, 0.6713, 0.2761, 0.693]}, {"w": "(see", "b": [0.2808, 0.6716, 0.3134, 0.693]}, {"w": "???).3", "b": [0.3181, 0.6716, 0.3594, 0.693]}]}, {"id": "b_5", "type": "paragraph", "text": "TensorFlow’s architecture is shown in Figure 12-2: most of the time your code will use the high level APIs (especially tf.keras and tf.data), but when you need more flexi‐ bility you will use the lower level Python API, handling tensors directly. Note that APIs for other languages are also available. In any case, TensorFlow’s execution", "words": [{"w": "TensorFlow’s", "b": [0.1429, 0.6997, 0.2514, 0.7211]}, {"w": "architecture", "b": [0.2585, 0.6997, 0.359, 0.7211]}, {"w": "is", "b": [0.3661, 0.6997, 0.3793, 0.7211]}, {"w": "shown", "b": [0.3864, 0.6997, 0.4415, 0.7211]}, {"w": "in", "b": [0.4486, 0.6997, 0.4656, 0.7211]}, {"w": "Figure", "b": [0.4727, 0.6997, 0.5267, 0.7211]}, {"w": "12-2:", "b": [0.5338, 0.6997, 0.576, 0.7211]}, {"w": "most", "b": [0.5831, 0.6997, 0.6248, 0.7211]}, {"w": "of", "b": [0.6319, 0.6997, 0.6487, 0.7211]}, {"w": "the", "b": [0.6558, 0.6997, 0.6822, 0.7211]}, {"w": "time", "b": [0.6893, 0.6997, 0.7271, 0.7211]}, {"w": "your", "b": [0.7342, 0.6997, 0.7732, 0.7211]}, {"w": "code", "b": [0.7803, 0.6997, 0.8196, 0.7211]}, {"w": "will", "b": [0.8267, 0.6997, 0.8571, 0.7211]}, {"w": "use", "b": [0.1429, 0.7187, 0.1704, 0.7401]}, {"w": "the", "b": [0.1753, 0.7187, 0.2016, 0.7401]}, {"w": "high", "b": [0.2065, 0.7187, 0.244, 0.7401]}, {"w": "level", "b": [0.2489, 0.7187, 0.2868, 0.7401]}, {"w": "APIs", "b": [0.2917, 0.7187, 0.3321, 0.7401]}, {"w": "(especially", "b": [0.3369, 0.7187, 0.424, 0.7401]}, {"w": "tf.keras", "b": [0.4289, 0.7187, 0.4899, 0.7401]}, {"w": "and", "b": [0.4947, 0.7187, 0.5263, 0.7401]}, {"w": "tf.data),", "b": [0.5311, 0.7187, 0.5956, 0.7401]}, {"w": "but", "b": [0.6005, 0.7187, 0.6285, 0.7401]}, {"w": "when", "b": [0.6333, 0.7187, 0.679, 0.7401]}, {"w": "you", "b": [0.6838, 0.7187, 0.7151, 0.7401]}, {"w": "need", "b": [0.7199, 0.7187, 0.76, 0.7401]}, {"w": "more", "b": [0.7649, 0.7187, 0.8092, 0.7401]}, {"w": "flexi‐", "b": [0.814, 0.7187, 0.8571, 0.7401]}, {"w": "bility", "b": [0.1429, 0.7378, 0.1858, 0.7592]}, {"w": "you", "b": [0.1933, 0.7378, 0.2246, 0.7592]}, {"w": "will", "b": [0.2321, 0.7378, 0.2625, 0.7592]}, {"w": "use", "b": [0.27, 0.7378, 0.2976, 0.7592]}, {"w": "the", "b": [0.3051, 0.7378, 0.3314, 0.7592]}, {"w": "lower", "b": [0.3389, 0.7378, 0.3857, 0.7592]}, {"w": "level", "b": [0.3932, 0.7378, 0.4311, 0.7592]}, {"w": "Python", "b": [0.4386, 0.7378, 0.4994, 0.7592]}, {"w": "API,", "b": [0.5069, 0.7378, 0.5449, 0.7592]}, {"w": "handling", "b": [0.5524, 0.7378, 0.6271, 0.7592]}, {"w": "tensors", "b": [0.6346, 0.7378, 0.6948, 0.7592]}, {"w": "directly.", "b": [0.7024, 0.7378, 0.7687, 0.7592]}, {"w": "Note", "b": [0.7763, 0.7378, 0.8171, 0.7592]}, {"w": "that", "b": [0.8246, 0.7378, 0.8572, 0.7592]}, {"w": "APIs", "b": [0.1429, 0.7568, 0.1833, 0.7782]}, {"w": "for", "b": [0.1933, 0.7568, 0.2178, 0.7782]}, {"w": "other", "b": [0.2278, 0.7568, 0.2725, 0.7782]}, {"w": "languages", "b": [0.2825, 0.7568, 0.3645, 0.7782]}, {"w": "are", "b": [0.3745, 0.7568, 0.4002, 0.7782]}, {"w": "also", "b": [0.4102, 0.7568, 0.4429, 0.7782]}, {"w": "available.", "b": [0.4529, 0.7568, 0.5299, 0.7782]}, {"w": "In", "b": [0.5399, 0.7568, 0.5584, 0.7782]}, {"w": "any", "b": [0.5684, 0.7568, 0.598, 0.7782]}, {"w": "case,", "b": [0.608, 0.7568, 0.6472, 0.7782]}, {"w": "TensorFlow’s", "b": [0.6572, 0.7568, 0.7658, 0.7782]}, {"w": "execution", "b": [0.7758, 0.7568, 0.8571, 0.7782]}]}, {"id": "b_6", "type": "paragraph", "text": "A Quick Tour of TensorFlow | 369", "words": [{"w": "A", "b": [0.6384, 0.9225, 0.6464, 0.9388]}, {"w": "Quick", "b": [0.6493, 0.9225, 0.6813, 0.9388]}, {"w": "Tour", "b": [0.6842, 0.9225, 0.7107, 0.9388]}, {"w": "of", "b": [0.7135, 0.9225, 0.7255, 0.9388]}, {"w": "TensorFlow", "b": [0.7283, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "369", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 396, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "engine will take care of running the operations efficiently, even across multiple devi‐ ces and machines if you tell it to.", "words": [{"w": "engine", "b": [0.1429, 0.0791, 0.1987, 0.1005]}, {"w": "will", "b": [0.2046, 0.0791, 0.235, 0.1005]}, {"w": "take", "b": [0.2409, 0.0791, 0.2755, 0.1005]}, {"w": "care", "b": [0.2814, 0.0791, 0.316, 0.1005]}, {"w": "of", "b": [0.3219, 0.0791, 0.3387, 0.1005]}, {"w": "running", "b": [0.3445, 0.0791, 0.4129, 0.1005]}, {"w": "the", "b": [0.4187, 0.0791, 0.4451, 0.1005]}, {"w": "operations", "b": [0.451, 0.0791, 0.5394, 0.1005]}, {"w": "efficiently,", "b": [0.5453, 0.0791, 0.6308, 0.1005]}, {"w": "even", "b": [0.6366, 0.0791, 0.6754, 0.1005]}, {"w": "across", "b": [0.6813, 0.0791, 0.7329, 0.1005]}, {"w": "multiple", "b": [0.7388, 0.0791, 0.8088, 0.1005]}, {"w": "devi‐", "b": [0.8146, 0.0791, 0.8571, 0.1005]}, {"w": "ces", "b": [0.1429, 0.0981, 0.1682, 0.1195]}, {"w": "and", "b": [0.1729, 0.0981, 0.2044, 0.1195]}, {"w": "machines", "b": [0.2092, 0.0981, 0.2888, 0.1195]}, {"w": "if", "b": [0.2935, 0.0981, 0.3053, 0.1195]}, {"w": "you", "b": [0.31, 0.0981, 0.3412, 0.1195]}, {"w": "tell", "b": [0.346, 0.0981, 0.3717, 0.1195]}, {"w": "it", "b": [0.3765, 0.0981, 0.3884, 0.1195]}, {"w": "to.", "b": [0.3931, 0.0981, 0.4142, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "Figure 12-2. TensorFlow’s architecture", "words": [{"w": "Figure", "b": [0.1429, 0.4332, 0.1943, 0.4548]}, {"w": "12-2.", "b": [0.1991, 0.4332, 0.2407, 0.4548]}, {"w": "TensorFlow’s", "b": [0.2455, 0.4332, 0.3481, 0.4548]}, {"w": "architecture", "b": [0.3529, 0.4332, 0.4484, 0.4548]}]}, {"id": "b_2", "type": "paragraph", "text": "TensorFlow runs not only on Windows, Linux, and MacOS, but also on mobile devi‐ ces (using TensorFlow Lite), including both iOS and Android (see ???). If you do not want to use the Python API, there are also C++, Java, Go and Swift APIs. There is even a Javascript implementation called TensorFlow.js that makes it possible to run your models directly in your browser.", "words": [{"w": "TensorFlow", "b": [0.1429, 0.4706, 0.2411, 0.492]}, {"w": "runs", "b": [0.2466, 0.4706, 0.2845, 0.492]}, {"w": "not", "b": [0.29, 0.4706, 0.3184, 0.492]}, {"w": "only", "b": [0.3239, 0.4706, 0.3607, 0.492]}, {"w": "on", "b": [0.3663, 0.4706, 0.3883, 0.492]}, {"w": "Windows,", "b": [0.3938, 0.4706, 0.4784, 0.492]}, {"w": "Linux,", "b": [0.484, 0.4706, 0.5374, 0.492]}, {"w": "and", "b": [0.5429, 0.4706, 0.5745, 0.492]}, {"w": "MacOS,", "b": [0.58, 0.4706, 0.6463, 0.492]}, {"w": "but", "b": [0.6519, 0.4706, 0.6799, 0.492]}, {"w": "also", "b": [0.6854, 0.4706, 0.7181, 0.492]}, {"w": "on", "b": [0.7236, 0.4706, 0.7456, 0.492]}, {"w": "mobile", "b": [0.7511, 0.4706, 0.8091, 0.492]}, {"w": "devi‐", "b": [0.8146, 0.4706, 0.8571, 0.492]}, {"w": "ces", "b": [0.1429, 0.4897, 0.1682, 0.5111]}, {"w": "(using", "b": [0.1742, 0.4897, 0.2269, 0.5111]}, {"w": "TensorFlow", "b": [0.2329, 0.4895, 0.3266, 0.5111]}, {"w": "Lite),", "b": [0.3327, 0.4895, 0.3752, 0.5111]}, {"w": "including", "b": [0.3813, 0.4897, 0.4611, 0.5111]}, {"w": "both", "b": [0.4671, 0.4897, 0.5058, 0.5111]}, {"w": "iOS", "b": [0.5119, 0.4897, 0.5429, 0.5111]}, {"w": "and", "b": [0.5489, 0.4897, 0.5805, 0.5111]}, {"w": "Android", "b": [0.5865, 0.4897, 0.6582, 0.5111]}, {"w": "(see", "b": [0.6643, 0.4897, 0.6968, 0.5111]}, {"w": "???).", "b": [0.7029, 0.4897, 0.7385, 0.5111]}, {"w": "If", "b": [0.7445, 0.4897, 0.7578, 0.5111]}, {"w": "you", "b": [0.7638, 0.4897, 0.7951, 0.5111]}, {"w": "do", "b": [0.8011, 0.4897, 0.8227, 0.5111]}, {"w": "not", "b": [0.8288, 0.4897, 0.8572, 0.5111]}, {"w": "want", "b": [0.1429, 0.5087, 0.1836, 0.5301]}, {"w": "to", "b": [0.1908, 0.5087, 0.2077, 0.5301]}, {"w": "use", "b": [0.2149, 0.5087, 0.2424, 0.5301]}, {"w": "the", "b": [0.2496, 0.5087, 0.2759, 0.5301]}, {"w": "Python", "b": [0.283, 0.5087, 0.3438, 0.5301]}, {"w": "API,", "b": [0.3509, 0.5087, 0.3889, 0.5301]}, {"w": "there", "b": [0.396, 0.5087, 0.439, 0.5301]}, {"w": "are", "b": [0.4461, 0.5087, 0.4718, 0.5301]}, {"w": "also", "b": [0.479, 0.5087, 0.5116, 0.5301]}, {"w": "C++,", "b": [0.5188, 0.5087, 0.5615, 0.5301]}, {"w": "Java,", "b": [0.5687, 0.5087, 0.6073, 0.5301]}, {"w": "Go", "b": [0.6144, 0.5087, 0.6399, 0.5301]}, {"w": "and", "b": [0.647, 0.5087, 0.6786, 0.5301]}, {"w": "Swift", "b": [0.6857, 0.5087, 0.7279, 0.5301]}, {"w": "APIs.", "b": [0.7351, 0.5087, 0.7802, 0.5301]}, {"w": "There", "b": [0.7874, 0.5087, 0.8368, 0.5301]}, {"w": "is", "b": [0.8439, 0.5087, 0.8571, 0.5301]}, {"w": "even", "b": [0.1429, 0.5278, 0.1816, 0.5492]}, {"w": "a", "b": [0.1891, 0.5278, 0.1982, 0.5492]}, {"w": "Javascript", "b": [0.2057, 0.5278, 0.2866, 0.5492]}, {"w": "implementation", "b": [0.294, 0.5278, 0.4273, 0.5492]}, {"w": "called", "b": [0.4348, 0.5278, 0.4831, 0.5492]}, {"w": "TensorFlow.js", "b": [0.4906, 0.5275, 0.6005, 0.5492]}, {"w": "that", "b": [0.608, 0.5278, 0.6405, 0.5492]}, {"w": "makes", "b": [0.648, 0.5278, 0.701, 0.5492]}, {"w": "it", "b": [0.7085, 0.5278, 0.7205, 0.5492]}, {"w": "possible", "b": [0.7279, 0.5278, 0.795, 0.5492]}, {"w": "to", "b": [0.8025, 0.5278, 0.8195, 0.5492]}, {"w": "run", "b": [0.827, 0.5278, 0.8571, 0.5492]}, {"w": "your", "b": [0.1428, 0.5468, 0.1818, 0.5682]}, {"w": "models", "b": [0.1866, 0.5468, 0.247, 0.5682]}, {"w": "directly", "b": [0.2517, 0.5468, 0.3149, 0.5682]}, {"w": "in", "b": [0.3196, 0.5468, 0.3366, 0.5682]}, {"w": "your", "b": [0.3413, 0.5468, 0.3803, 0.5682]}, {"w": "browser.", "b": [0.3851, 0.5468, 0.4559, 0.5682]}]}, {"id": "b_3", "type": "paragraph", "text": "There’s more to TensorFlow than just the library. TensorFlow is at the center of an extensive ecosystem of libraries. First, there’s TensorBoard for visualization (see Chapter 10). Next, there’s TensorFlow Extended (TFX), which is a set of libraries built by Google to productionize TensorFlow projects: it includes tools for data validation, preprocessing, model analysis and serving (with TF Serving, see ???). Google also launched TensorFlow Hub, a way to easily download and reuse pretrained neural net‐ works. You can also get many neural network architectures, some of them pretrained, in TensorFlow’s model garden. Check out the TensorFlow Resources, or https:// github.com/jtoy/awesome-tensorflow for more TensorFlow-based projects. You will find hundreds of TensorFlow projects on GitHub, so it is often easy to find existing code for whatever you are trying to do.", "words": [{"w": "There’s", "b": [0.1428, 0.5749, 0.2014, 0.5963]}, {"w": "more", "b": [0.2085, 0.5749, 0.2528, 0.5963]}, {"w": "to", "b": [0.26, 0.5749, 0.2769, 0.5963]}, {"w": "TensorFlow", "b": [0.2841, 0.5749, 0.3823, 0.5963]}, {"w": "than", "b": [0.3895, 0.5749, 0.4275, 0.5963]}, {"w": "just", "b": [0.4347, 0.5749, 0.4651, 0.5963]}, {"w": "the", "b": [0.4722, 0.5749, 0.4986, 0.5963]}, {"w": "library.", "b": [0.5057, 0.5749, 0.5652, 0.5963]}, {"w": "TensorFlow", "b": [0.5723, 0.5749, 0.6706, 0.5963]}, {"w": "is", "b": [0.6777, 0.5749, 0.691, 0.5963]}, {"w": "at", "b": [0.6981, 0.5749, 0.7132, 0.5963]}, {"w": "the", "b": [0.7204, 0.5749, 0.7467, 0.5963]}, {"w": "center", "b": [0.7539, 0.5749, 0.8055, 0.5963]}, {"w": "of", "b": [0.8126, 0.5749, 0.8294, 0.5963]}, {"w": "an", "b": [0.8366, 0.5749, 0.8571, 0.5963]}, {"w": "extensive", "b": [0.1429, 0.594, 0.2199, 0.6154]}, {"w": "ecosystem", "b": [0.2306, 0.594, 0.316, 0.6154]}, {"w": "of", "b": [0.3267, 0.594, 0.3435, 0.6154]}, {"w": "libraries.", "b": [0.3542, 0.594, 0.4271, 0.6154]}, {"w": "First,", "b": [0.4378, 0.594, 0.4809, 0.6154]}, {"w": "there’s", "b": [0.4916, 0.594, 0.5436, 0.6154]}, {"w": "TensorBoard", "b": [0.5543, 0.594, 0.6625, 0.6154]}, {"w": "for", "b": [0.6733, 0.594, 0.6978, 0.6154]}, {"w": "visualization", "b": [0.7085, 0.594, 0.8139, 0.6154]}, {"w": "(see", "b": [0.8246, 0.594, 0.8572, 0.6154]}, {"w": "Chapter", "b": [0.1429, 0.613, 0.2104, 0.6344]}, {"w": "10).", "b": [0.2152, 0.613, 0.2473, 0.6344]}, {"w": "Next,", "b": [0.252, 0.613, 0.2968, 0.6344]}, {"w": "there’s", "b": [0.3015, 0.613, 0.3535, 0.6344]}, {"w": "TensorFlow", "b": [0.3589, 0.613, 0.4571, 0.6344]}, {"w": "Extended", "b": [0.4618, 0.613, 0.541, 0.6344]}, {"w": "(TFX),", "b": [0.5457, 0.613, 0.6028, 0.6344]}, {"w": "which", "b": [0.6077, 0.613, 0.6586, 0.6344]}, {"w": "is", "b": [0.6635, 0.613, 0.6767, 0.6344]}, {"w": "a", "b": [0.6817, 0.613, 0.6908, 0.6344]}, {"w": "set", "b": [0.6957, 0.613, 0.7186, 0.6344]}, {"w": "of", "b": [0.7235, 0.613, 0.7403, 0.6344]}, {"w": "libraries", "b": [0.7452, 0.613, 0.8134, 0.6344]}, {"w": "built", "b": [0.8183, 0.613, 0.8571, 0.6344]}, {"w": "by", "b": [0.1429, 0.6321, 0.163, 0.6535]}, {"w": "Google", "b": [0.1685, 0.6321, 0.2285, 0.6535]}, {"w": "to", "b": [0.234, 0.6321, 0.251, 0.6535]}, {"w": "productionize", "b": [0.2565, 0.6321, 0.3738, 0.6535]}, {"w": "TensorFlow", "b": [0.3793, 0.6321, 0.4776, 0.6535]}, {"w": "projects:", "b": [0.4831, 0.6321, 0.5541, 0.6535]}, {"w": "it", "b": [0.5596, 0.6321, 0.5716, 0.6535]}, {"w": "includes", "b": [0.5771, 0.6321, 0.6467, 0.6535]}, {"w": "tools", "b": [0.6522, 0.6321, 0.6927, 0.6535]}, {"w": "for", "b": [0.6982, 0.6321, 0.7228, 0.6535]}, {"w": "data", "b": [0.7283, 0.6321, 0.7635, 0.6535]}, {"w": "validation,", "b": [0.769, 0.6321, 0.8571, 0.6535]}, {"w": "preprocessing,", "b": [0.1429, 0.6511, 0.2641, 0.6725]}, {"w": "model", "b": [0.2724, 0.6511, 0.3252, 0.6725]}, {"w": "analysis", "b": [0.3336, 0.6511, 0.399, 0.6725]}, {"w": "and", "b": [0.4073, 0.6511, 0.4389, 0.6725]}, {"w": "serving", "b": [0.4472, 0.6511, 0.5084, 0.6725]}, {"w": "(with", "b": [0.5168, 0.6511, 0.5613, 0.6725]}, {"w": "TF", "b": [0.5697, 0.6511, 0.5935, 0.6725]}, {"w": "Serving,", "b": [0.6019, 0.6511, 0.6701, 0.6725]}, {"w": "see", "b": [0.6784, 0.6511, 0.7038, 0.6725]}, {"w": "???).", "b": [0.7121, 0.6511, 0.7478, 0.6725]}, {"w": "Google", "b": [0.7561, 0.6511, 0.8161, 0.6725]}, {"w": "also", "b": [0.8245, 0.6511, 0.8572, 0.6725]}, {"w": "launched", "b": [0.1429, 0.6702, 0.2191, 0.6916]}, {"w": "TensorFlow", "b": [0.2245, 0.67, 0.3183, 0.6916]}, {"w": "Hub,", "b": [0.3231, 0.67, 0.3641, 0.6916]}, {"w": "a", "b": [0.3695, 0.6702, 0.3787, 0.6916]}, {"w": "way", "b": [0.3841, 0.6702, 0.4167, 0.6916]}, {"w": "to", "b": [0.4221, 0.6702, 0.4391, 0.6916]}, {"w": "easily", "b": [0.4445, 0.6702, 0.4906, 0.6916]}, {"w": "download", "b": [0.496, 0.6702, 0.5793, 0.6916]}, {"w": "and", "b": [0.5847, 0.6702, 0.6163, 0.6916]}, {"w": "reuse", "b": [0.6217, 0.6702, 0.6658, 0.6916]}, {"w": "pretrained", "b": [0.6713, 0.6702, 0.7588, 0.6916]}, {"w": "neural", "b": [0.7642, 0.6702, 0.8177, 0.6916]}, {"w": "net‐", "b": [0.8231, 0.6702, 0.8571, 0.6916]}, {"w": "works.", "b": [0.1429, 0.6892, 0.1982, 0.7106]}, {"w": "You", "b": [0.2033, 0.6892, 0.2356, 0.7106]}, {"w": "can", "b": [0.2406, 0.6892, 0.27, 0.7106]}, {"w": "also", "b": [0.275, 0.6892, 0.3077, 0.7106]}, {"w": "get", "b": [0.3127, 0.6892, 0.3377, 0.7106]}, {"w": "many", "b": [0.3427, 0.6892, 0.3894, 0.7106]}, {"w": "neural", "b": [0.3944, 0.6892, 0.4479, 0.7106]}, {"w": "network", "b": [0.4529, 0.6892, 0.5225, 0.7106]}, {"w": "architectures,", "b": [0.5275, 0.6892, 0.6403, 0.7106]}, {"w": "some", "b": [0.6454, 0.6892, 0.6896, 0.7106]}, {"w": "of", "b": [0.6946, 0.6892, 0.7114, 0.7106]}, {"w": "them", "b": [0.7164, 0.6892, 0.7598, 0.7106]}, {"w": "pretrained,", "b": [0.7648, 0.6892, 0.8572, 0.7106]}, {"w": "in", "b": [0.1429, 0.7083, 0.1598, 0.7297]}, {"w": "TensorFlow’s", "b": [0.17, 0.7083, 0.2786, 0.7297]}, {"w": "model", "b": [0.2887, 0.7083, 0.3415, 0.7297]}, {"w": "garden.", "b": [0.3517, 0.7083, 0.4143, 0.7297]}, {"w": "Check", "b": [0.4245, 0.7083, 0.4774, 0.7297]}, {"w": "out", "b": [0.4876, 0.7083, 0.5156, 0.7297]}, {"w": "the", "b": [0.5258, 0.7083, 0.5521, 0.7297]}, {"w": "TensorFlow", "b": [0.5623, 0.7083, 0.6605, 0.7297]}, {"w": "Resources,", "b": [0.6707, 0.7083, 0.7596, 0.7297]}, {"w": "or", "b": [0.7697, 0.7083, 0.7881, 0.7297]}, {"w": "https://", "b": [0.7982, 0.708, 0.8571, 0.7297]}, {"w": "github.com/jtoy/awesome-tensorflow", "b": [0.1429, 0.7271, 0.4449, 0.7487]}, {"w": "for", "b": [0.4544, 0.7273, 0.4789, 0.7487]}, {"w": "more", "b": [0.4883, 0.7273, 0.5326, 0.7487]}, {"w": "TensorFlow-based", "b": [0.5421, 0.7273, 0.695, 0.7487]}, {"w": "projects.", "b": [0.7044, 0.7273, 0.7755, 0.7487]}, {"w": "You", "b": [0.7849, 0.7273, 0.8173, 0.7487]}, {"w": "will", "b": [0.8267, 0.7273, 0.8571, 0.7487]}, {"w": "find", "b": [0.1428, 0.7463, 0.177, 0.7678]}, {"w": "hundreds", "b": [0.1835, 0.7463, 0.2629, 0.7678]}, {"w": "of", "b": [0.2695, 0.7463, 0.2863, 0.7678]}, {"w": "TensorFlow", "b": [0.2928, 0.7463, 0.391, 0.7678]}, {"w": "projects", "b": [0.3976, 0.7463, 0.4639, 0.7678]}, {"w": "on", "b": [0.4704, 0.7463, 0.4924, 0.7678]}, {"w": "GitHub,", "b": [0.4989, 0.7463, 0.5667, 0.7678]}, {"w": "so", "b": [0.5732, 0.7463, 0.5915, 0.7678]}, {"w": "it", "b": [0.598, 0.7463, 0.61, 0.7678]}, {"w": "is", "b": [0.6165, 0.7463, 0.6297, 0.7678]}, {"w": "often", "b": [0.6363, 0.7463, 0.6797, 0.7678]}, {"w": "easy", "b": [0.6862, 0.7463, 0.7214, 0.7678]}, {"w": "to", "b": [0.7279, 0.7463, 0.7449, 0.7678]}, {"w": "find", "b": [0.7515, 0.7463, 0.7856, 0.7678]}, {"w": "existing", "b": [0.7921, 0.7463, 0.8571, 0.7678]}, {"w": "code", "b": [0.1429, 0.7654, 0.1822, 0.7868]}, {"w": "for", "b": [0.1869, 0.7654, 0.2114, 0.7868]}, {"w": "whatever", "b": [0.2161, 0.7654, 0.2917, 0.7868]}, {"w": "you", "b": [0.2964, 0.7654, 0.3277, 0.7868]}, {"w": "are", "b": [0.3324, 0.7654, 0.3582, 0.7868]}, {"w": "trying", "b": [0.3629, 0.7654, 0.4139, 0.7868]}, {"w": "to", "b": [0.4186, 0.7654, 0.4356, 0.7868]}, {"w": "do.", "b": [0.4403, 0.7654, 0.4661, 0.7868]}]}, {"id": "b_4", "type": "paragraph", "text": "More and more ML papers are released along with their implemen‐ tation, and sometimes even with pretrained models. Check out https://paperswithcode.com/ to easily find them.", "words": [{"w": "More", "b": [0.2714, 0.8073, 0.3128, 0.8269]}, {"w": "and", "b": [0.3172, 0.8073, 0.346, 0.8269]}, {"w": "more", "b": [0.3505, 0.8073, 0.391, 0.8269]}, {"w": "ML", "b": [0.3954, 0.8073, 0.4226, 0.8269]}, {"w": "papers", "b": [0.4271, 0.8073, 0.4772, 0.8269]}, {"w": "are", "b": [0.4816, 0.8073, 0.5052, 0.8269]}, {"w": "released", "b": [0.5096, 0.8073, 0.5712, 0.8269]}, {"w": "along", "b": [0.5756, 0.8073, 0.6179, 0.8269]}, {"w": "with", "b": [0.6223, 0.8073, 0.6564, 0.8269]}, {"w": "their", "b": [0.6609, 0.8073, 0.6971, 0.8269]}, {"w": "implemen‐", "b": [0.7016, 0.8073, 0.7857, 0.8269]}, {"w": "tation,", "b": [0.2714, 0.8248, 0.3206, 0.8443]}, {"w": "and", "b": [0.3295, 0.8248, 0.3583, 0.8443]}, {"w": "sometimes", "b": [0.3672, 0.8248, 0.4492, 0.8443]}, {"w": "even", "b": [0.4581, 0.8248, 0.4935, 0.8443]}, {"w": "with", "b": [0.5023, 0.8248, 0.5365, 0.8443]}, {"w": "pretrained", "b": [0.5454, 0.8248, 0.6254, 0.8443]}, {"w": "models.", "b": [0.6343, 0.8248, 0.6939, 0.8443]}, {"w": "Check", "b": [0.7028, 0.8248, 0.7512, 0.8443]}, {"w": "out", "b": [0.7601, 0.8248, 0.7857, 0.8443]}, {"w": "https://paperswithcode.com/", "b": [0.2714, 0.842, 0.4809, 0.8617]}, {"w": "to", "b": [0.4853, 0.8422, 0.5008, 0.8617]}, {"w": "easily", "b": [0.5051, 0.8422, 0.5472, 0.8617]}, {"w": "find", "b": [0.5516, 0.8422, 0.5828, 0.8617]}, {"w": "them.", "b": [0.5871, 0.8422, 0.6311, 0.8617]}]}, {"id": "b_5", "type": "paragraph", "text": "370 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "370", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2745, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 397, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Last but not least, TensorFlow has a dedicated team of passionate and helpful devel‐ opers, and a large community contributing to improving it. To ask technical ques‐ tions, you should use http://stackoverflow.com/ and tag your question with tensorflow and python. You can file bugs and feature requests through GitHub. For general dis‐ cussions, join the Google group.", "words": [{"w": "Last", "b": [0.1429, 0.0791, 0.1772, 0.1005]}, {"w": "but", "b": [0.1833, 0.0791, 0.2113, 0.1005]}, {"w": "not", "b": [0.2175, 0.0791, 0.2458, 0.1005]}, {"w": "least,", "b": [0.252, 0.0791, 0.294, 0.1005]}, {"w": "TensorFlow", "b": [0.3001, 0.0791, 0.3984, 0.1005]}, {"w": "has", "b": [0.4045, 0.0791, 0.4324, 0.1005]}, {"w": "a", "b": [0.4385, 0.0791, 0.4477, 0.1005]}, {"w": "dedicated", "b": [0.4538, 0.0791, 0.534, 0.1005]}, {"w": "team", "b": [0.5401, 0.0791, 0.5816, 0.1005]}, {"w": "of", "b": [0.5877, 0.0791, 0.6045, 0.1005]}, {"w": "passionate", "b": [0.6106, 0.0791, 0.6975, 0.1005]}, {"w": "and", "b": [0.7036, 0.0791, 0.7352, 0.1005]}, {"w": "helpful", "b": [0.7413, 0.0791, 0.8, 0.1005]}, {"w": "devel‐", "b": [0.8061, 0.0791, 0.8571, 0.1005]}, {"w": "opers,", "b": [0.1429, 0.0981, 0.1934, 0.1195]}, {"w": "and", "b": [0.2008, 0.0981, 0.2324, 0.1195]}, {"w": "a", "b": [0.2398, 0.0981, 0.2489, 0.1195]}, {"w": "large", "b": [0.2564, 0.0981, 0.2971, 0.1195]}, {"w": "community", "b": [0.3046, 0.0981, 0.4017, 0.1195]}, {"w": "contributing", "b": [0.4091, 0.0981, 0.514, 0.1195]}, {"w": "to", "b": [0.5214, 0.0981, 0.5384, 0.1195]}, {"w": "improving", "b": [0.5458, 0.0981, 0.6337, 0.1195]}, {"w": "it.", "b": [0.6412, 0.0981, 0.6578, 0.1195]}, {"w": "To", "b": [0.6653, 0.0981, 0.6867, 0.1195]}, {"w": "ask", "b": [0.6942, 0.0981, 0.7213, 0.1195]}, {"w": "technical", "b": [0.7287, 0.0981, 0.8041, 0.1195]}, {"w": "ques‐", "b": [0.8115, 0.0981, 0.8571, 0.1195]}, {"w": "tions,", "b": [0.1429, 0.1172, 0.1892, 0.1386]}, {"w": "you", "b": [0.1946, 0.1172, 0.2258, 0.1386]}, {"w": "should", "b": [0.2312, 0.1172, 0.2879, 0.1386]}, {"w": "use", "b": [0.2932, 0.1172, 0.3208, 0.1386]}, {"w": "http://stackoverflow.com/", "b": [0.3261, 0.117, 0.5349, 0.1386]}, {"w": "and", "b": [0.5402, 0.1172, 0.5718, 0.1386]}, {"w": "tag", "b": [0.5771, 0.1172, 0.6024, 0.1386]}, {"w": "your", "b": [0.6077, 0.1172, 0.6467, 0.1386]}, {"w": "question", "b": [0.652, 0.1172, 0.7242, 0.1386]}, {"w": "with", "b": [0.7295, 0.1172, 0.7669, 0.1386]}, {"w": "tensorflow", "b": [0.7722, 0.117, 0.8571, 0.1386]}, {"w": "and", "b": [0.1429, 0.1362, 0.1744, 0.1576]}, {"w": "python.", "b": [0.1805, 0.136, 0.242, 0.1576]}, {"w": "You", "b": [0.2481, 0.1362, 0.2805, 0.1576]}, {"w": "can", "b": [0.2866, 0.1362, 0.3159, 0.1576]}, {"w": "file", "b": [0.322, 0.1362, 0.3479, 0.1576]}, {"w": "bugs", "b": [0.354, 0.1362, 0.393, 0.1576]}, {"w": "and", "b": [0.3991, 0.1362, 0.4307, 0.1576]}, {"w": "feature", "b": [0.4368, 0.1362, 0.4946, 0.1576]}, {"w": "requests", "b": [0.5007, 0.1362, 0.5695, 0.1576]}, {"w": "through", "b": [0.5756, 0.1362, 0.6433, 0.1576]}, {"w": "GitHub.", "b": [0.6494, 0.1362, 0.7172, 0.1576]}, {"w": "For", "b": [0.7233, 0.1362, 0.7523, 0.1576]}, {"w": "general", "b": [0.7584, 0.1362, 0.8194, 0.1576]}, {"w": "dis‐", "b": [0.8255, 0.1362, 0.8571, 0.1576]}, {"w": "cussions,", "b": [0.1429, 0.1553, 0.218, 0.1767]}, {"w": "join", "b": [0.2228, 0.1553, 0.2557, 0.1767]}, {"w": "the", "b": [0.2604, 0.1553, 0.2868, 0.1767]}, {"w": "Google", "b": [0.2915, 0.1553, 0.3515, 0.1767]}, {"w": "group.", "b": [0.3562, 0.1553, 0.4111, 0.1767]}]}, {"id": "b_1", "type": "paragraph", "text": "Okay, it’s time to start coding!", "words": [{"w": "Okay,", "b": [0.1429, 0.1834, 0.1903, 0.2048]}, {"w": "it’s", "b": [0.1951, 0.1834, 0.2167, 0.2048]}, {"w": "time", "b": [0.2215, 0.1834, 0.2593, 0.2048]}, {"w": "to", "b": [0.2641, 0.1834, 0.281, 0.2048]}, {"w": "start", "b": [0.2858, 0.1834, 0.323, 0.2048]}, {"w": "coding!", "b": [0.3277, 0.1834, 0.3906, 0.2048]}]}, {"id": "b_2", "type": "paragraph", "text": "Using TensorFlow like NumPy", "words": [{"w": "Using", "b": [0.1429, 0.2178, 0.2124, 0.252]}, {"w": "TensorFlow", "b": [0.2184, 0.2178, 0.3603, 0.252]}, {"w": "like", "b": [0.3662, 0.2178, 0.4111, 0.252]}, {"w": "NumPy", "b": [0.417, 0.2178, 0.5061, 0.252]}]}, {"id": "b_3", "type": "paragraph", "text": "TensorFlow’s API revolves around tensors, hence the name Tensor-Flow. A tensor is usually a multidimensional array (exactly like a NumPy ndarray), but it can also hold a scalar (a simple value, such as 42). These tensors will be important when we create custom cost functions, custom metrics, custom layers and more, so let’s see how to create and manipulate them.", "words": [{"w": "TensorFlow’s", "b": [0.1429, 0.259, 0.2514, 0.2804]}, {"w": "API", "b": [0.2579, 0.259, 0.2911, 0.2804]}, {"w": "revolves", "b": [0.2976, 0.259, 0.3659, 0.2804]}, {"w": "around", "b": [0.3723, 0.259, 0.4333, 0.2804]}, {"w": "tensors,", "b": [0.4398, 0.2587, 0.5014, 0.2804]}, {"w": "hence", "b": [0.5078, 0.259, 0.5569, 0.2804]}, {"w": "the", "b": [0.5633, 0.259, 0.5897, 0.2804]}, {"w": "name", "b": [0.5962, 0.259, 0.6426, 0.2804]}, {"w": "Tensor-Flow.", "b": [0.6491, 0.259, 0.7575, 0.2804]}, {"w": "A", "b": [0.764, 0.259, 0.7784, 0.2804]}, {"w": "tensor", "b": [0.7848, 0.259, 0.8374, 0.2804]}, {"w": "is", "b": [0.8439, 0.259, 0.8571, 0.2804]}, {"w": "usually", "b": [0.1428, 0.2789, 0.2019, 0.3003]}, {"w": "a", "b": [0.2069, 0.2789, 0.216, 0.3003]}, {"w": "multidimensional", "b": [0.221, 0.2789, 0.3695, 0.3003]}, {"w": "array", "b": [0.3745, 0.2789, 0.4175, 0.3003]}, {"w": "(exactly", "b": [0.4225, 0.2789, 0.4875, 0.3003]}, {"w": "like", "b": [0.4925, 0.2789, 0.5226, 0.3003]}, {"w": "a", "b": [0.5276, 0.2789, 0.5367, 0.3003]}, {"w": "NumPy", "b": [0.5417, 0.2789, 0.6059, 0.3003]}, {"w": "ndarray),", "b": [0.6109, 0.2789, 0.6921, 0.3003]}, {"w": "but", "b": [0.6971, 0.2789, 0.7251, 0.3003]}, {"w": "it", "b": [0.7301, 0.2789, 0.7421, 0.3003]}, {"w": "can", "b": [0.7471, 0.2789, 0.7764, 0.3003]}, {"w": "also", "b": [0.7814, 0.2789, 0.8141, 0.3003]}, {"w": "hold", "b": [0.8191, 0.2789, 0.8571, 0.3003]}, {"w": "a", "b": [0.1429, 0.2979, 0.152, 0.3194]}, {"w": "scalar", "b": [0.1579, 0.2979, 0.2056, 0.3194]}, {"w": "(a", "b": [0.2115, 0.2979, 0.2279, 0.3194]}, {"w": "simple", "b": [0.2337, 0.2979, 0.2887, 0.3194]}, {"w": "value,", "b": [0.2945, 0.2979, 0.3433, 0.3194]}, {"w": "such", "b": [0.3491, 0.2979, 0.3878, 0.3194]}, {"w": "as", "b": [0.3936, 0.2979, 0.4104, 0.3194]}, {"w": "42).", "b": [0.4163, 0.2979, 0.4483, 0.3194]}, {"w": "These", "b": [0.4541, 0.2979, 0.5035, 0.3194]}, {"w": "tensors", "b": [0.5093, 0.2979, 0.5696, 0.3194]}, {"w": "will", "b": [0.5755, 0.2979, 0.6059, 0.3194]}, {"w": "be", "b": [0.6117, 0.2979, 0.6312, 0.3194]}, {"w": "important", "b": [0.637, 0.2979, 0.7214, 0.3194]}, {"w": "when", "b": [0.7273, 0.2979, 0.7729, 0.3194]}, {"w": "we", "b": [0.7788, 0.2979, 0.8019, 0.3194]}, {"w": "create", "b": [0.8078, 0.2979, 0.8571, 0.3194]}, {"w": "custom", "b": [0.1429, 0.317, 0.2044, 0.3384]}, {"w": "cost", "b": [0.2114, 0.317, 0.2448, 0.3384]}, {"w": "functions,", "b": [0.2518, 0.317, 0.3355, 0.3384]}, {"w": "custom", "b": [0.3425, 0.317, 0.4041, 0.3384]}, {"w": "metrics,", "b": [0.411, 0.317, 0.4778, 0.3384]}, {"w": "custom", "b": [0.4847, 0.317, 0.5463, 0.3384]}, {"w": "layers", "b": [0.5533, 0.317, 0.6011, 0.3384]}, {"w": "and", "b": [0.608, 0.317, 0.6396, 0.3384]}, {"w": "more,", "b": [0.6465, 0.317, 0.6955, 0.3384]}, {"w": "so", "b": [0.7025, 0.317, 0.7208, 0.3384]}, {"w": "let’s", "b": [0.7277, 0.317, 0.7579, 0.3384]}, {"w": "see", "b": [0.7649, 0.317, 0.7902, 0.3384]}, {"w": "how", "b": [0.7972, 0.317, 0.8332, 0.3384]}, {"w": "to", "b": [0.8402, 0.317, 0.8571, 0.3384]}, {"w": "create", "b": [0.1429, 0.336, 0.1922, 0.3575]}, {"w": "and", "b": [0.1969, 0.336, 0.2285, 0.3575]}, {"w": "manipulate", "b": [0.2332, 0.336, 0.3276, 0.3575]}, {"w": "them.", "b": [0.3323, 0.336, 0.3805, 0.3575]}]}, {"id": "b_4", "type": "paragraph", "text": "Tensors and Operations", "words": [{"w": "Tensors", "b": [0.1429, 0.3702, 0.2212, 0.3988]}, {"w": "and", "b": [0.2261, 0.3702, 0.2654, 0.3988]}, {"w": "Operations", "b": [0.2703, 0.3702, 0.3829, 0.3988]}]}, {"id": "b_5", "type": "paragraph", "text": "You can easily create a tensor, using tf.constant(). For example, here is a tensor representing a matrix with two rows and three columns of floats:", "words": [{"w": "You", "b": [0.1429, 0.4056, 0.1752, 0.427]}, {"w": "can", "b": [0.1828, 0.4056, 0.2121, 0.427]}, {"w": "easily", "b": [0.2197, 0.4056, 0.2658, 0.427]}, {"w": "create", "b": [0.2733, 0.4056, 0.3227, 0.427]}, {"w": "a", "b": [0.3302, 0.4056, 0.3394, 0.427]}, {"w": "tensor,", "b": [0.3469, 0.4056, 0.403, 0.427]}, {"w": "using", "b": [0.4105, 0.4056, 0.456, 0.427]}, {"w": "tf.constant().", "b": [0.4636, 0.4056, 0.5969, 0.427]}, {"w": "For", "b": [0.6045, 0.4056, 0.6335, 0.427]}, {"w": "example,", "b": [0.6411, 0.4056, 0.7153, 0.427]}, {"w": "here", "b": [0.7229, 0.4056, 0.7595, 0.427]}, {"w": "is", "b": [0.767, 0.4056, 0.7803, 0.427]}, {"w": "a", "b": [0.7878, 0.4056, 0.797, 0.427]}, {"w": "tensor", "b": [0.8045, 0.4056, 0.8571, 0.427]}, {"w": "representing", "b": [0.1428, 0.4246, 0.2475, 0.446]}, {"w": "a", "b": [0.2522, 0.4246, 0.2614, 0.446]}, {"w": "matrix", "b": [0.2661, 0.4246, 0.3214, 0.446]}, {"w": "with", "b": [0.3262, 0.4246, 0.3635, 0.446]}, {"w": "two", "b": [0.3682, 0.4246, 0.3995, 0.446]}, {"w": "rows", "b": [0.4042, 0.4246, 0.4445, 0.446]}, {"w": "and", "b": [0.4492, 0.4246, 0.4807, 0.446]}, {"w": "three", "b": [0.4855, 0.4246, 0.5284, 0.446]}, {"w": "columns", "b": [0.5331, 0.4246, 0.605, 0.446]}, {"w": "of", "b": [0.6097, 0.4246, 0.6265, 0.446]}, {"w": "floats:", "b": [0.6312, 0.4246, 0.6808, 0.446]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> tf.constant([[1., 2., 3.], [4., 5., 6.]]) # matrix >>> tf.constant(42) # scalar ", "words": [{"w": ">>>", "b": [0.1766, 0.4566, 0.2019, 0.4695]}, {"w": "tf.constant([[1.,", "b": [0.2103, 0.4566, 0.3537, 0.4695]}, {"w": "2.,", "b": [0.3621, 0.4566, 0.3874, 0.4695]}, {"w": "3.],", "b": [0.3958, 0.4566, 0.4296, 0.4695]}, {"w": "[4.,", "b": [0.438, 0.4566, 0.4717, 0.4695]}, {"w": "5.,", "b": [0.4802, 0.4566, 0.5055, 0.4695]}, {"w": "6.]])", "b": [0.5139, 0.4566, 0.5561, 0.4695]}, {"w": "#", "b": [0.5645, 0.4566, 0.5729, 0.4695]}, {"w": "matrix", "b": [0.5814, 0.4566, 0.6319, 0.4695]}, {"w": "", "b": [0.3621, 0.5029, 0.4886, 0.5157]}, {"w": ">>>", "b": [0.1766, 0.5183, 0.2019, 0.5311]}, {"w": "tf.constant(42)", "b": [0.2103, 0.5183, 0.3368, 0.5311]}, {"w": "#", "b": [0.3452, 0.5183, 0.3537, 0.5311]}, {"w": "scalar", "b": [0.3621, 0.5183, 0.4127, 0.5311]}, {"w": "", "b": [0.5223, 0.5337, 0.5982, 0.5466]}]}, {"id": "b_7", "type": "paragraph", "text": "Just like an ndarray, a tf.Tensor has a shape and a data type (dtype):", "words": [{"w": "Just", "b": [0.1429, 0.5552, 0.1741, 0.5766]}, {"w": "like", "b": [0.1788, 0.5552, 0.2089, 0.5766]}, {"w": "an", "b": [0.2136, 0.5552, 0.2342, 0.5766]}, {"w": "ndarray,", "b": [0.2389, 0.5552, 0.3129, 0.5766]}, {"w": "a", "b": [0.3176, 0.5552, 0.3268, 0.5766]}, {"w": "tf.Tensor", "b": [0.3315, 0.5584, 0.4206, 0.5735]}, {"w": "has", "b": [0.4253, 0.5552, 0.4532, 0.5766]}, {"w": "a", "b": [0.4579, 0.5552, 0.4671, 0.5766]}, {"w": "shape", "b": [0.4718, 0.5552, 0.5191, 0.5766]}, {"w": "and", "b": [0.5238, 0.5552, 0.5554, 0.5766]}, {"w": "a", "b": [0.5601, 0.5552, 0.5693, 0.5766]}, {"w": "data", "b": [0.574, 0.5552, 0.6092, 0.5766]}, {"w": "type", "b": [0.614, 0.5552, 0.6497, 0.5766]}, {"w": "(dtype):", "b": [0.6544, 0.5552, 0.723, 0.5766]}]}, {"id": "b_8", "type": "paragraph", "text": ">>> t = tf.constant([[1., 2., 3.], [4., 5., 6.]]) >>> t.shape TensorShape([2, 3]) >>> t.dtype tf.float32", "words": [{"w": ">>>", "b": [0.1766, 0.5872, 0.2019, 0.6001]}, {"w": "t", "b": [0.2103, 0.5872, 0.2188, 0.6001]}, {"w": "=", "b": [0.2272, 0.5872, 0.2356, 0.6001]}, {"w": "tf.constant([[1.,", "b": [0.244, 0.5872, 0.3874, 0.6001]}, {"w": "2.,", "b": [0.3958, 0.5872, 0.4211, 0.6001]}, {"w": "3.],", "b": [0.4296, 0.5872, 0.4633, 0.6001]}, {"w": "[4.,", "b": [0.4717, 0.5872, 0.5055, 0.6001]}, {"w": "5.,", "b": [0.5139, 0.5872, 0.5392, 0.6001]}, {"w": "6.]])", "b": [0.5476, 0.5872, 0.5898, 0.6001]}, {"w": ">>>", "b": [0.1766, 0.6026, 0.2019, 0.6155]}, {"w": "t.shape", "b": [0.2103, 0.6026, 0.2693, 0.6155]}, {"w": "TensorShape([2,", "b": [0.1766, 0.618, 0.3031, 0.6309]}, {"w": "3])", "b": [0.3115, 0.618, 0.3368, 0.6309]}, {"w": ">>>", "b": [0.1766, 0.6335, 0.2019, 0.6463]}, {"w": "t.dtype", "b": [0.2103, 0.6335, 0.2693, 0.6463]}, {"w": "tf.float32", "b": [0.1766, 0.6489, 0.2609, 0.6617]}]}, {"id": "b_9", "type": "paragraph", "text": "Indexing works much like in NumPy:", "words": [{"w": "Indexing", "b": [0.1429, 0.6695, 0.2178, 0.6909]}, {"w": "works", "b": [0.2225, 0.6695, 0.2731, 0.6909]}, {"w": "much", "b": [0.2778, 0.6695, 0.3255, 0.6909]}, {"w": "like", "b": [0.3302, 0.6695, 0.3603, 0.6909]}, {"w": "in", "b": [0.365, 0.6695, 0.382, 0.6909]}, {"w": "NumPy:", "b": [0.3867, 0.6695, 0.4563, 0.6909]}]}, {"id": "b_10", "type": "paragraph", "text": ">>> t[:, 1:] >>> t[..., 1, tf.newaxis] ", "words": [{"w": ">>>", "b": [0.1766, 0.7015, 0.2019, 0.7143]}, {"w": "t[:,", "b": [0.2103, 0.7015, 0.2441, 0.7143]}, {"w": "1:]", "b": [0.2525, 0.7015, 0.2778, 0.7143]}, {"w": "", "b": [0.3284, 0.7478, 0.4549, 0.7606]}, {"w": ">>>", "b": [0.1766, 0.7632, 0.2019, 0.776]}, {"w": "t[...,", "b": [0.2103, 0.7632, 0.2609, 0.776]}, {"w": "1,", "b": [0.2694, 0.7632, 0.2862, 0.776]}, {"w": "tf.newaxis]", "b": [0.2946, 0.7632, 0.3874, 0.776]}, {"w": "", "b": [0.2946, 0.8094, 0.4211, 0.8223]}]}, {"id": "b_11", "type": "paragraph", "text": "Most importantly, all sorts of tensor operations are available:", "words": [{"w": "Most", "b": [0.1429, 0.8301, 0.1855, 0.8515]}, {"w": "importantly,", "b": [0.1902, 0.8301, 0.2927, 0.8515]}, {"w": "all", "b": [0.2974, 0.8301, 0.3171, 0.8515]}, {"w": "sorts", "b": [0.3218, 0.8301, 0.3618, 0.8515]}, {"w": "of", "b": [0.3666, 0.8301, 0.3833, 0.8515]}, {"w": "tensor", "b": [0.3881, 0.8301, 0.4407, 0.8515]}, {"w": "operations", "b": [0.4454, 0.8301, 0.5339, 0.8515]}, {"w": "are", "b": [0.5386, 0.8301, 0.5643, 0.8515]}, {"w": "available:", "b": [0.5691, 0.8301, 0.6461, 0.8515]}]}, {"id": "b_12", "type": "equation", "text": ">>> t + 10 >>", "b": [0.1766, 0.862, 0.2019, 0.8749]}, {"w": "t", "b": [0.2103, 0.862, 0.2188, 0.8749]}, {"w": "+", "b": [0.2272, 0.862, 0.2356, 0.8749]}, {"w": "10", "b": [0.244, 0.862, 0.2609, 0.8749]}, {"w": " >>> tf.square(t) >>> t @ tf.transpose(t) ", "words": [{"w": "array([[11.,", "b": [0.1766, 0.0829, 0.2778, 0.0958]}, {"w": "12.,", "b": [0.2862, 0.0829, 0.3199, 0.0958]}, {"w": "13.],", "b": [0.3284, 0.0829, 0.3705, 0.0958]}, {"w": "[14.,", "b": [0.2356, 0.0983, 0.2778, 0.1112]}, {"w": "15.,", "b": [0.2862, 0.0983, 0.3199, 0.1112]}, {"w": "16.]],", "b": [0.3284, 0.0983, 0.379, 0.1112]}, {"w": "dtype=float32)>", "b": [0.3874, 0.0983, 0.5139, 0.1112]}, {"w": ">>>", "b": [0.1766, 0.1138, 0.2019, 0.1266]}, {"w": "tf.square(t)", "b": [0.2103, 0.1138, 0.3115, 0.1266]}, {"w": "", "b": [0.3874, 0.16, 0.5139, 0.1729]}, {"w": ">>>", "b": [0.1766, 0.1754, 0.2019, 0.1883]}, {"w": "t", "b": [0.2103, 0.1754, 0.2188, 0.1883]}, {"w": "@", "b": [0.2272, 0.1754, 0.2356, 0.1883]}, {"w": "tf.transpose(t)", "b": [0.244, 0.1754, 0.3705, 0.1883]}, {"w": "", "b": [0.3452, 0.2217, 0.4717, 0.2345]}]}, {"id": "b_1", "type": "paragraph", "text": "Note that writing t + 10 is equivalent to calling tf.add(t, 10) (indeed, Python calls the magic method t.__add__(10), which just calls tf.add(t, 10)). Other operators (like -, *, etc.) are also supported. The @ operator was added in Python 3.5, for matrix multiplication: it is equivalent to calling the tf.matmul() function.", "words": [{"w": "Note", "b": [0.1429, 0.2432, 0.1836, 0.2646]}, {"w": "that", "b": [0.1884, 0.2432, 0.221, 0.2646]}, {"w": "writing", "b": [0.2257, 0.2432, 0.2864, 0.2646]}, {"w": "t", "b": [0.2917, 0.2464, 0.3016, 0.2615]}, {"w": "+", "b": [0.3115, 0.2464, 0.3214, 0.2615]}, {"w": "10", "b": [0.3313, 0.2464, 0.3511, 0.2615]}, {"w": "is", "b": [0.3564, 0.2432, 0.3696, 0.2646]}, {"w": "equivalent", "b": [0.3745, 0.2432, 0.4609, 0.2646]}, {"w": "to", "b": [0.4659, 0.2432, 0.4828, 0.2646]}, {"w": "calling", "b": [0.4878, 0.2432, 0.543, 0.2646]}, {"w": "tf.add(t,", "b": [0.5479, 0.2464, 0.637, 0.2615]}, {"w": "10)", "b": [0.6469, 0.2464, 0.6766, 0.2615]}, {"w": "(indeed,", "b": [0.6817, 0.2432, 0.7503, 0.2646]}, {"w": "Python", "b": [0.7551, 0.2432, 0.8159, 0.2646]}, {"w": "calls", "b": [0.8206, 0.2432, 0.8567, 0.2646]}, {"w": "the", "b": [0.1428, 0.2632, 0.1692, 0.2846]}, {"w": "magic", "b": [0.1749, 0.2632, 0.2252, 0.2846]}, {"w": "method", "b": [0.2309, 0.2632, 0.296, 0.2846]}, {"w": "t.__add__(10),", "b": [0.3017, 0.2632, 0.4351, 0.2846]}, {"w": "which", "b": [0.4408, 0.2632, 0.4917, 0.2846]}, {"w": "just", "b": [0.4974, 0.2632, 0.5278, 0.2846]}, {"w": "calls", "b": [0.5335, 0.2632, 0.5697, 0.2846]}, {"w": "tf.add(t,", "b": [0.5754, 0.2664, 0.6644, 0.2814]}, {"w": "10)).", "b": [0.6752, 0.2632, 0.7169, 0.2846]}, {"w": "Other", "b": [0.7226, 0.2632, 0.7722, 0.2846]}, {"w": "operators", "b": [0.7779, 0.2632, 0.8572, 0.2846]}, {"w": "(like", "b": [0.1429, 0.2831, 0.1801, 0.3045]}, {"w": "-,", "b": [0.1851, 0.2831, 0.1998, 0.3045]}, {"w": "*,", "b": [0.2047, 0.2831, 0.2194, 0.3045]}, {"w": "etc.)", "b": [0.2244, 0.2831, 0.2604, 0.3045]}, {"w": "are", "b": [0.2654, 0.2831, 0.2911, 0.3045]}, {"w": "also", "b": [0.2961, 0.2831, 0.3288, 0.3045]}, {"w": "supported.", "b": [0.3338, 0.2831, 0.4236, 0.3045]}, {"w": "The", "b": [0.4286, 0.2831, 0.4615, 0.3045]}, {"w": "@", "b": [0.4665, 0.2863, 0.4764, 0.3014]}, {"w": "operator", "b": [0.4814, 0.2831, 0.553, 0.3045]}, {"w": "was", "b": [0.558, 0.2831, 0.589, 0.3045]}, {"w": "added", "b": [0.594, 0.2831, 0.645, 0.3045]}, {"w": "in", "b": [0.65, 0.2831, 0.667, 0.3045]}, {"w": "Python", "b": [0.672, 0.2831, 0.7328, 0.3045]}, {"w": "3.5,", "b": [0.7378, 0.2831, 0.7673, 0.3045]}, {"w": "for", "b": [0.7723, 0.2831, 0.7968, 0.3045]}, {"w": "matrix", "b": [0.8018, 0.2831, 0.8571, 0.3045]}, {"w": "multiplication:", "b": [0.1429, 0.3031, 0.2658, 0.3245]}, {"w": "it", "b": [0.2706, 0.3031, 0.2825, 0.3245]}, {"w": "is", "b": [0.2872, 0.3031, 0.3005, 0.3245]}, {"w": "equivalent", "b": [0.3052, 0.3031, 0.3916, 0.3245]}, {"w": "to", "b": [0.3963, 0.3031, 0.4133, 0.3245]}, {"w": "calling", "b": [0.4181, 0.3031, 0.4733, 0.3245]}, {"w": "the", "b": [0.478, 0.3031, 0.5043, 0.3245]}, {"w": "tf.matmul()", "b": [0.5091, 0.3062, 0.6179, 0.3213]}, {"w": "function.", "b": [0.6227, 0.3031, 0.6988, 0.3245]}]}, {"id": "b_2", "type": "paragraph", "text": "You will find all the basic math operations you need (e.g., tf.add(), tf.multiply(), tf.square(), tf.exp(), tf.sqrt()…), and more generally most operations that you can find in NumPy (e.g., tf.reshape(), tf.squeeze(), tf.tile()), but sometimes with a different name (e.g., tf.reduce_mean(), tf.reduce_sum(), tf.reduce_max(), tf.math.log() are the equivalent of np.mean(), np.sum(), np.max() and np.log()). When the name differs, there is often a good reason for it: for example, in Tensor‐ Flow you must write tf.transpose(t), you cannot just write t.T like in NumPy. The reason is that it does not do exactly the same thing: in TensorFlow, a new tensor is created with its own copy of the transposed data, while in NumPy, t.T is just a trans‐ posed view on the same data. Similarly, the tf.reduce_sum() operation is named this way because its GPU kernel (i.e., GPU implementation) uses a reduce algorithm that does not guarantee the order in which the elements are added: because 32-bit floats have limited precision, this means that the result may change ever so slightly every time you call this operation. The same is true of tf.reduce_mean() (but of course tf.reduce_max() is deterministic).", "words": [{"w": "You", "b": [0.1429, 0.3321, 0.1752, 0.3535]}, {"w": "will", "b": [0.181, 0.3321, 0.2114, 0.3535]}, {"w": "find", "b": [0.2171, 0.3321, 0.2513, 0.3535]}, {"w": "all", "b": [0.257, 0.3321, 0.2767, 0.3535]}, {"w": "the", "b": [0.2825, 0.3321, 0.3088, 0.3535]}, {"w": "basic", "b": [0.3146, 0.3321, 0.3563, 0.3535]}, {"w": "math", "b": [0.3621, 0.3321, 0.4054, 0.3535]}, {"w": "operations", "b": [0.4112, 0.3321, 0.4996, 0.3535]}, {"w": "you", "b": [0.5054, 0.3321, 0.5366, 0.3535]}, {"w": "need", "b": [0.5424, 0.3321, 0.5825, 0.3535]}, {"w": "(e.g.,", "b": [0.5883, 0.3321, 0.6283, 0.3535]}, {"w": "tf.add(),", "b": [0.6341, 0.3321, 0.718, 0.3535]}, {"w": "tf.multiply(),", "b": [0.7238, 0.3321, 0.8571, 0.3535]}, {"w": "tf.square(),", "b": [0.1428, 0.352, 0.2565, 0.3734]}, {"w": "tf.exp(),", "b": [0.262, 0.352, 0.3459, 0.3734]}, {"w": "tf.sqrt()…),", "b": [0.3515, 0.352, 0.4727, 0.3734]}, {"w": "and", "b": [0.4782, 0.352, 0.5098, 0.3734]}, {"w": "more", "b": [0.5153, 0.352, 0.5596, 0.3734]}, {"w": "generally", "b": [0.5651, 0.352, 0.641, 0.3734]}, {"w": "most", "b": [0.6465, 0.352, 0.6882, 0.3734]}, {"w": "operations", "b": [0.6937, 0.352, 0.7822, 0.3734]}, {"w": "that", "b": [0.7878, 0.352, 0.8203, 0.3734]}, {"w": "you", "b": [0.8259, 0.352, 0.8571, 0.3734]}, {"w": "can", "b": [0.1429, 0.372, 0.1722, 0.3934]}, {"w": "find", "b": [0.1793, 0.372, 0.2135, 0.3934]}, {"w": "in", "b": [0.2206, 0.372, 0.2375, 0.3934]}, {"w": "NumPy", "b": [0.2446, 0.372, 0.3088, 0.3934]}, {"w": "(e.g.,", "b": [0.3159, 0.372, 0.356, 0.3934]}, {"w": "tf.reshape(),", "b": [0.3631, 0.372, 0.4866, 0.3934]}, {"w": "tf.squeeze(),", "b": [0.4936, 0.372, 0.6171, 0.3934]}, {"w": "tf.tile()),", "b": [0.6242, 0.372, 0.7253, 0.3934]}, {"w": "but", "b": [0.7324, 0.372, 0.7604, 0.3934]}, {"w": "sometimes", "b": [0.7675, 0.372, 0.8571, 0.3934]}, {"w": "with", "b": [0.1429, 0.3919, 0.1802, 0.4133]}, {"w": "a", "b": [0.1859, 0.3919, 0.1951, 0.4133]}, {"w": "different", "b": [0.2008, 0.3919, 0.2725, 0.4133]}, {"w": "name", "b": [0.2782, 0.3919, 0.3247, 0.4133]}, {"w": "(e.g.,", "b": [0.3304, 0.3919, 0.3705, 0.4133]}, {"w": "tf.reduce_mean(),", "b": [0.3762, 0.3919, 0.5393, 0.4133]}, {"w": "tf.reduce_sum(),", "b": [0.545, 0.3919, 0.6982, 0.4133]}, {"w": "tf.reduce_max(),", "b": [0.704, 0.3919, 0.8571, 0.4133]}, {"w": "tf.math.log()", "b": [0.1429, 0.415, 0.2715, 0.4301]}, {"w": "are", "b": [0.2772, 0.4118, 0.3029, 0.4333]}, {"w": "the", "b": [0.3085, 0.4118, 0.3349, 0.4333]}, {"w": "equivalent", "b": [0.3405, 0.4118, 0.4269, 0.4333]}, {"w": "of", "b": [0.4326, 0.4118, 0.4494, 0.4333]}, {"w": "np.mean(),", "b": [0.455, 0.4118, 0.5488, 0.4333]}, {"w": "np.sum(),", "b": [0.5545, 0.4118, 0.6384, 0.4333]}, {"w": "np.max()", "b": [0.644, 0.415, 0.7232, 0.4301]}, {"w": "and", "b": [0.7288, 0.4118, 0.7604, 0.4333]}, {"w": "np.log()).", "b": [0.766, 0.4118, 0.8571, 0.4333]}, {"w": "When", "b": [0.1429, 0.4309, 0.1945, 0.4523]}, {"w": "the", "b": [0.2014, 0.4309, 0.2278, 0.4523]}, {"w": "name", "b": [0.2347, 0.4309, 0.2812, 0.4523]}, {"w": "differs,", "b": [0.2881, 0.4309, 0.346, 0.4523]}, {"w": "there", "b": [0.353, 0.4309, 0.3959, 0.4523]}, {"w": "is", "b": [0.4029, 0.4309, 0.4161, 0.4523]}, {"w": "often", "b": [0.4231, 0.4309, 0.4665, 0.4523]}, {"w": "a", "b": [0.4734, 0.4309, 0.4826, 0.4523]}, {"w": "good", "b": [0.4895, 0.4309, 0.5315, 0.4523]}, {"w": "reason", "b": [0.5385, 0.4309, 0.5939, 0.4523]}, {"w": "for", "b": [0.6009, 0.4309, 0.6254, 0.4523]}, {"w": "it:", "b": [0.6323, 0.4309, 0.649, 0.4523]}, {"w": "for", "b": [0.656, 0.4309, 0.6805, 0.4523]}, {"w": "example,", "b": [0.6875, 0.4309, 0.7618, 0.4523]}, {"w": "in", "b": [0.7687, 0.4309, 0.7857, 0.4523]}, {"w": "Tensor‐", "b": [0.7927, 0.4309, 0.8571, 0.4523]}, {"w": "Flow", "b": [0.1428, 0.4508, 0.184, 0.4723]}, {"w": "you", "b": [0.189, 0.4508, 0.2203, 0.4723]}, {"w": "must", "b": [0.2253, 0.4508, 0.267, 0.4723]}, {"w": "write", "b": [0.272, 0.4508, 0.3148, 0.4723]}, {"w": "tf.transpose(t),", "b": [0.3198, 0.4508, 0.473, 0.4723]}, {"w": "you", "b": [0.478, 0.4508, 0.5093, 0.4723]}, {"w": "cannot", "b": [0.5143, 0.4508, 0.572, 0.4723]}, {"w": "just", "b": [0.577, 0.4508, 0.6074, 0.4723]}, {"w": "write", "b": [0.6124, 0.4508, 0.6552, 0.4723]}, {"w": "t.T", "b": [0.6602, 0.454, 0.6899, 0.4691]}, {"w": "like", "b": [0.6949, 0.4508, 0.7249, 0.4723]}, {"w": "in", "b": [0.7299, 0.4508, 0.7469, 0.4723]}, {"w": "NumPy.", "b": [0.7519, 0.4508, 0.8193, 0.4723]}, {"w": "The", "b": [0.8243, 0.4508, 0.8571, 0.4723]}, {"w": "reason", "b": [0.1429, 0.4699, 0.1983, 0.4913]}, {"w": "is", "b": [0.2051, 0.4699, 0.2183, 0.4913]}, {"w": "that", "b": [0.2251, 0.4699, 0.2577, 0.4913]}, {"w": "it", "b": [0.2645, 0.4699, 0.2765, 0.4913]}, {"w": "does", "b": [0.2833, 0.4699, 0.3214, 0.4913]}, {"w": "not", "b": [0.3283, 0.4699, 0.3566, 0.4913]}, {"w": "do", "b": [0.3635, 0.4699, 0.3851, 0.4913]}, {"w": "exactly", "b": [0.3919, 0.4699, 0.4498, 0.4913]}, {"w": "the", "b": [0.4566, 0.4699, 0.4829, 0.4913]}, {"w": "same", "b": [0.4897, 0.4699, 0.5324, 0.4913]}, {"w": "thing:", "b": [0.5393, 0.4699, 0.5882, 0.4913]}, {"w": "in", "b": [0.5951, 0.4699, 0.612, 0.4913]}, {"w": "TensorFlow,", "b": [0.6189, 0.4699, 0.7203, 0.4913]}, {"w": "a", "b": [0.7272, 0.4699, 0.7363, 0.4913]}, {"w": "new", "b": [0.7431, 0.4699, 0.7777, 0.4913]}, {"w": "tensor", "b": [0.7845, 0.4699, 0.8371, 0.4913]}, {"w": "is", "b": [0.8439, 0.4699, 0.8571, 0.4913]}, {"w": "created", "b": [0.1429, 0.4898, 0.2032, 0.5112]}, {"w": "with", "b": [0.2085, 0.4898, 0.2458, 0.5112]}, {"w": "its", "b": [0.2511, 0.4898, 0.2707, 0.5112]}, {"w": "own", "b": [0.276, 0.4898, 0.3123, 0.5112]}, {"w": "copy", "b": [0.3176, 0.4898, 0.3575, 0.5112]}, {"w": "of", "b": [0.3628, 0.4898, 0.3796, 0.5112]}, {"w": "the", "b": [0.3849, 0.4898, 0.4112, 0.5112]}, {"w": "transposed", "b": [0.4165, 0.4898, 0.5078, 0.5112]}, {"w": "data,", "b": [0.5131, 0.4898, 0.5531, 0.5112]}, {"w": "while", "b": [0.5584, 0.4898, 0.6035, 0.5112]}, {"w": "in", "b": [0.6088, 0.4898, 0.6258, 0.5112]}, {"w": "NumPy,", "b": [0.6311, 0.4898, 0.6985, 0.5112]}, {"w": "t.T", "b": [0.7038, 0.493, 0.7335, 0.5081]}, {"w": "is", "b": [0.7388, 0.4898, 0.752, 0.5112]}, {"w": "just", "b": [0.7573, 0.4898, 0.7877, 0.5112]}, {"w": "a", "b": [0.793, 0.4898, 0.8022, 0.5112]}, {"w": "trans‐", "b": [0.8075, 0.4898, 0.8571, 0.5112]}, {"w": "posed", "b": [0.1428, 0.5098, 0.1919, 0.5312]}, {"w": "view", "b": [0.1969, 0.5098, 0.2353, 0.5312]}, {"w": "on", "b": [0.2403, 0.5098, 0.2623, 0.5312]}, {"w": "the", "b": [0.2674, 0.5098, 0.2937, 0.5312]}, {"w": "same", "b": [0.2988, 0.5098, 0.3415, 0.5312]}, {"w": "data.", "b": [0.3465, 0.5098, 0.3865, 0.5312]}, {"w": "Similarly,", "b": [0.3916, 0.5098, 0.4699, 0.5312]}, {"w": "the", "b": [0.4749, 0.5098, 0.5012, 0.5312]}, {"w": "tf.reduce_sum()", "b": [0.5063, 0.513, 0.6547, 0.528]}, {"w": "operation", "b": [0.6598, 0.5098, 0.7406, 0.5312]}, {"w": "is", "b": [0.7457, 0.5098, 0.7589, 0.5312]}, {"w": "named", "b": [0.7639, 0.5098, 0.8214, 0.5312]}, {"w": "this", "b": [0.8264, 0.5098, 0.8571, 0.5312]}, {"w": "way", "b": [0.1429, 0.5288, 0.1755, 0.5502]}, {"w": "because", "b": [0.1812, 0.5288, 0.2458, 0.5502]}, {"w": "its", "b": [0.2515, 0.5288, 0.2711, 0.5502]}, {"w": "GPU", "b": [0.2768, 0.5288, 0.3188, 0.5502]}, {"w": "kernel", "b": [0.3245, 0.5288, 0.377, 0.5502]}, {"w": "(i.e.,", "b": [0.3827, 0.5288, 0.4186, 0.5502]}, {"w": "GPU", "b": [0.4244, 0.5288, 0.4663, 0.5502]}, {"w": "implementation)", "b": [0.4721, 0.5288, 0.6125, 0.5502]}, {"w": "uses", "b": [0.6183, 0.5288, 0.6535, 0.5502]}, {"w": "a", "b": [0.6592, 0.5288, 0.6684, 0.5502]}, {"w": "reduce", "b": [0.6741, 0.5288, 0.7304, 0.5502]}, {"w": "algorithm", "b": [0.7362, 0.5288, 0.8188, 0.5502]}, {"w": "that", "b": [0.8246, 0.5288, 0.8571, 0.5502]}, {"w": "does", "b": [0.1429, 0.5479, 0.181, 0.5693]}, {"w": "not", "b": [0.1875, 0.5479, 0.2159, 0.5693]}, {"w": "guarantee", "b": [0.2224, 0.5479, 0.3043, 0.5693]}, {"w": "the", "b": [0.3108, 0.5479, 0.3371, 0.5693]}, {"w": "order", "b": [0.3436, 0.5479, 0.3896, 0.5693]}, {"w": "in", "b": [0.3961, 0.5479, 0.4131, 0.5693]}, {"w": "which", "b": [0.4196, 0.5479, 0.4705, 0.5693]}, {"w": "the", "b": [0.477, 0.5479, 0.5034, 0.5693]}, {"w": "elements", "b": [0.5099, 0.5479, 0.5838, 0.5693]}, {"w": "are", "b": [0.5903, 0.5479, 0.616, 0.5693]}, {"w": "added:", "b": [0.6225, 0.5479, 0.6783, 0.5693]}, {"w": "because", "b": [0.6848, 0.5479, 0.7494, 0.5693]}, {"w": "32-bit", "b": [0.7559, 0.5479, 0.8058, 0.5693]}, {"w": "floats", "b": [0.8123, 0.5479, 0.8571, 0.5693]}, {"w": "have", "b": [0.1428, 0.5669, 0.1812, 0.5883]}, {"w": "limited", "b": [0.1882, 0.5669, 0.2479, 0.5883]}, {"w": "precision,", "b": [0.2549, 0.5669, 0.3368, 0.5883]}, {"w": "this", "b": [0.3437, 0.5669, 0.3744, 0.5883]}, {"w": "means", "b": [0.3814, 0.5669, 0.4355, 0.5883]}, {"w": "that", "b": [0.4424, 0.5669, 0.475, 0.5883]}, {"w": "the", "b": [0.482, 0.5669, 0.5083, 0.5883]}, {"w": "result", "b": [0.5152, 0.5669, 0.5622, 0.5883]}, {"w": "may", "b": [0.5691, 0.5669, 0.6045, 0.5883]}, {"w": "change", "b": [0.6115, 0.5669, 0.6705, 0.5883]}, {"w": "ever", "b": [0.6775, 0.5669, 0.7126, 0.5883]}, {"w": "so", "b": [0.7195, 0.5669, 0.7378, 0.5883]}, {"w": "slightly", "b": [0.7448, 0.5669, 0.8049, 0.5883]}, {"w": "every", "b": [0.8119, 0.5669, 0.8571, 0.5883]}, {"w": "time", "b": [0.1429, 0.5869, 0.1807, 0.6083]}, {"w": "you", "b": [0.1881, 0.5869, 0.2193, 0.6083]}, {"w": "call", "b": [0.2267, 0.5869, 0.2552, 0.6083]}, {"w": "this", "b": [0.2626, 0.5869, 0.2933, 0.6083]}, {"w": "operation.", "b": [0.3006, 0.5869, 0.3862, 0.6083]}, {"w": "The", "b": [0.3936, 0.5869, 0.4264, 0.6083]}, {"w": "same", "b": [0.4338, 0.5869, 0.4765, 0.6083]}, {"w": "is", "b": [0.4839, 0.5869, 0.4971, 0.6083]}, {"w": "true", "b": [0.5045, 0.5869, 0.5385, 0.6083]}, {"w": "of", "b": [0.5458, 0.5869, 0.5626, 0.6083]}, {"w": "tf.reduce_mean()", "b": [0.57, 0.59, 0.7283, 0.6051]}, {"w": "(but", "b": [0.7357, 0.5869, 0.7709, 0.6083]}, {"w": "of", "b": [0.7783, 0.5869, 0.795, 0.6083]}, {"w": "course", "b": [0.8024, 0.5869, 0.8571, 0.6083]}, {"w": "tf.reduce_max()", "b": [0.1428, 0.61, 0.2913, 0.6251]}, {"w": "is", "b": [0.296, 0.6068, 0.3092, 0.6282]}, {"w": "deterministic).", "b": [0.314, 0.6068, 0.4367, 0.6282]}]}, {"id": "b_3", "type": "paragraph", "text": "372 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "372", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2745, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 399, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "4 A notable exception is tf.math.log() which is commonly used but there is no tf.log() alias (as it might be confused with logging).", "words": [{"w": "4", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "A", "b": [0.1587, 0.8598, 0.1697, 0.8761]}, {"w": "notable", "b": [0.1733, 0.8598, 0.2207, 0.8761]}, {"w": "exception", "b": [0.2243, 0.8598, 0.2862, 0.8761]}, {"w": "is", "b": [0.2898, 0.8598, 0.2999, 0.8761]}, {"w": "tf.math.log()", "b": [0.3035, 0.8622, 0.4015, 0.8737]}, {"w": "which", "b": [0.4051, 0.8598, 0.4439, 0.8761]}, {"w": "is", "b": [0.4475, 0.8598, 0.4576, 0.8761]}, {"w": "commonly", "b": [0.4612, 0.8598, 0.5301, 0.8761]}, {"w": "used", "b": [0.5337, 0.8598, 0.5631, 0.8761]}, {"w": "but", "b": [0.5667, 0.8598, 0.588, 0.8761]}, {"w": "there", "b": [0.5916, 0.8598, 0.6243, 0.8761]}, {"w": "is", "b": [0.6279, 0.8598, 0.638, 0.8761]}, {"w": "no", "b": [0.6416, 0.8598, 0.6584, 0.8761]}, {"w": "tf.log()", "b": [0.662, 0.8622, 0.7223, 0.8737]}, {"w": "alias", "b": [0.7259, 0.8598, 0.7539, 0.8761]}, {"w": "(as", "b": [0.7575, 0.8598, 0.7758, 0.8761]}, {"w": "it", "b": [0.7794, 0.8598, 0.7885, 0.8761]}, {"w": "might", "b": [0.7921, 0.8598, 0.8298, 0.8761]}, {"w": "be", "b": [0.8334, 0.8598, 0.8482, 0.8761]}, {"w": "confused", "b": [0.1587, 0.8749, 0.2163, 0.8912]}, {"w": "with", "b": [0.2199, 0.8749, 0.2483, 0.8912]}, {"w": "logging).", "b": [0.252, 0.8749, 0.3084, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Many functions and classes have aliases. For example, tf.add() and tf.math.add() are the same function. This allows TensorFlow to have concise names for the most common operations4, while preserving well organized packages.", "words": [{"w": "Many", "b": [0.2714, 0.0801, 0.3151, 0.0997]}, {"w": "functions", "b": [0.3232, 0.0801, 0.3954, 0.0997]}, {"w": "and", "b": [0.4035, 0.0801, 0.4323, 0.0997]}, {"w": "classes", "b": [0.4403, 0.0801, 0.4906, 0.0997]}, {"w": "have", "b": [0.4986, 0.0801, 0.5337, 0.0997]}, {"w": "aliases.", "b": [0.5418, 0.0801, 0.5948, 0.0997]}, {"w": "For", "b": [0.6029, 0.0801, 0.6294, 0.0997]}, {"w": "example,", "b": [0.6374, 0.0801, 0.7053, 0.0997]}, {"w": "tf.add()", "b": [0.7133, 0.083, 0.7857, 0.0968]}, {"w": "and", "b": [0.2714, 0.0983, 0.3002, 0.1179]}, {"w": "tf.math.add()", "b": [0.3052, 0.1012, 0.4229, 0.115]}, {"w": "are", "b": [0.4279, 0.0983, 0.4514, 0.1179]}, {"w": "the", "b": [0.4564, 0.0983, 0.4805, 0.1179]}, {"w": "same", "b": [0.4855, 0.0983, 0.5245, 0.1179]}, {"w": "function.", "b": [0.5295, 0.0983, 0.5991, 0.1179]}, {"w": "This", "b": [0.6041, 0.0983, 0.6381, 0.1179]}, {"w": "allows", "b": [0.6431, 0.0983, 0.6909, 0.1179]}, {"w": "TensorFlow", "b": [0.6959, 0.0983, 0.7857, 0.1179]}, {"w": "to", "b": [0.2714, 0.1158, 0.2869, 0.1353]}, {"w": "have", "b": [0.2949, 0.1158, 0.33, 0.1353]}, {"w": "concise", "b": [0.338, 0.1158, 0.3944, 0.1353]}, {"w": "names", "b": [0.4024, 0.1158, 0.4519, 0.1353]}, {"w": "for", "b": [0.4599, 0.1158, 0.4823, 0.1353]}, {"w": "the", "b": [0.4903, 0.1158, 0.5144, 0.1353]}, {"w": "most", "b": [0.5223, 0.1158, 0.5605, 0.1353]}, {"w": "common", "b": [0.5684, 0.1158, 0.6376, 0.1353]}, {"w": "operations4,", "b": [0.6455, 0.1158, 0.7365, 0.1353]}, {"w": "while", "b": [0.7445, 0.1158, 0.7857, 0.1353]}, {"w": "preserving", "b": [0.2714, 0.1332, 0.3525, 0.1527]}, {"w": "well", "b": [0.3568, 0.1332, 0.3876, 0.1527]}, {"w": "organized", "b": [0.3919, 0.1332, 0.4677, 0.1527]}, {"w": "packages.", "b": [0.472, 0.1332, 0.5446, 0.1527]}]}, {"id": "b_2", "type": "equation", "text": "Keras’ Low-Level API", "words": [{"w": "Keras’", "b": [0.3991, 0.1909, 0.4583, 0.2181]}, {"w": "Low-Level", "b": [0.463, 0.1909, 0.5633, 0.2181]}, {"w": "API", "b": [0.568, 0.1909, 0.6009, 0.2181]}]}, {"id": "b_3", "type": "paragraph", "text": "The Keras API actually has its own low-level API, located in keras.backend. It includes functions like square(), exp(), sqrt() and so on. In tf.keras, these func‐ tions generally just call the corresponding TensorFlow operations. If you want to write code that will be portable to other Keras implementations, you should use these Keras functions. However, they only cover a subset of all functions available in Ten‐ sorFlow, so in this book we will use the TensorFlow operations directly. Here is as simple example using keras.backend, which is commonly named K for short:", "words": [{"w": "The", "b": [0.1592, 0.2235, 0.1905, 0.2439]}, {"w": "Keras", "b": [0.1999, 0.2235, 0.2445, 0.2439]}, {"w": "API", "b": [0.2539, 0.2235, 0.2856, 0.2439]}, {"w": "actually", "b": [0.2949, 0.2235, 0.3565, 0.2439]}, {"w": "has", "b": [0.3659, 0.2235, 0.3924, 0.2439]}, {"w": "its", "b": [0.4018, 0.2235, 0.4205, 0.2439]}, {"w": "own", "b": [0.4298, 0.2235, 0.4644, 0.2439]}, {"w": "low-level", "b": [0.4738, 0.2235, 0.5457, 0.2439]}, {"w": "API,", "b": [0.555, 0.2235, 0.5912, 0.2439]}, {"w": "located", "b": [0.6006, 0.2235, 0.6574, 0.2439]}, {"w": "in", "b": [0.6668, 0.2235, 0.6829, 0.2439]}, {"w": "keras.backend.", "b": [0.6923, 0.2235, 0.8194, 0.2439]}, {"w": "It", "b": [0.8287, 0.2235, 0.8408, 0.2439]}, {"w": "includes", "b": [0.1592, 0.2425, 0.2255, 0.2629]}, {"w": "functions", "b": [0.2328, 0.2425, 0.308, 0.2629]}, {"w": "like", "b": [0.3152, 0.2425, 0.3439, 0.2629]}, {"w": "square(),", "b": [0.3511, 0.2425, 0.431, 0.2629]}, {"w": "exp(),", "b": [0.4382, 0.2425, 0.4899, 0.2629]}, {"w": "sqrt()", "b": [0.4971, 0.2455, 0.5536, 0.2599]}, {"w": "and", "b": [0.5608, 0.2425, 0.5909, 0.2629]}, {"w": "so", "b": [0.5981, 0.2425, 0.6155, 0.2629]}, {"w": "on.", "b": [0.6227, 0.2425, 0.6482, 0.2629]}, {"w": "In", "b": [0.6554, 0.2425, 0.673, 0.2629]}, {"w": "tf.keras,", "b": [0.6802, 0.2425, 0.7428, 0.2629]}, {"w": "these", "b": [0.7501, 0.2425, 0.7908, 0.2629]}, {"w": "func‐", "b": [0.7981, 0.2425, 0.8408, 0.2629]}, {"w": "tions", "b": [0.1592, 0.2606, 0.1989, 0.281]}, {"w": "generally", "b": [0.2073, 0.2606, 0.2795, 0.281]}, {"w": "just", "b": [0.2879, 0.2606, 0.3169, 0.281]}, {"w": "call", "b": [0.3253, 0.2606, 0.3524, 0.281]}, {"w": "the", "b": [0.3608, 0.2606, 0.3859, 0.281]}, {"w": "corresponding", "b": [0.3943, 0.2606, 0.5106, 0.281]}, {"w": "TensorFlow", "b": [0.519, 0.2606, 0.6125, 0.281]}, {"w": "operations.", "b": [0.6209, 0.2606, 0.7097, 0.281]}, {"w": "If", "b": [0.7181, 0.2606, 0.7308, 0.281]}, {"w": "you", "b": [0.7392, 0.2606, 0.769, 0.281]}, {"w": "want", "b": [0.7774, 0.2606, 0.8162, 0.281]}, {"w": "to", "b": [0.8246, 0.2606, 0.8408, 0.281]}, {"w": "write", "b": [0.1592, 0.2788, 0.2, 0.2992]}, {"w": "code", "b": [0.205, 0.2788, 0.2425, 0.2992]}, {"w": "that", "b": [0.2475, 0.2788, 0.2786, 0.2992]}, {"w": "will", "b": [0.2836, 0.2788, 0.3126, 0.2992]}, {"w": "be", "b": [0.3176, 0.2788, 0.3361, 0.2992]}, {"w": "portable", "b": [0.3412, 0.2788, 0.4074, 0.2992]}, {"w": "to", "b": [0.4124, 0.2788, 0.4286, 0.2992]}, {"w": "other", "b": [0.4336, 0.2788, 0.4762, 0.2992]}, {"w": "Keras", "b": [0.4813, 0.2788, 0.5259, 0.2992]}, {"w": "implementations,", "b": [0.531, 0.2788, 0.6697, 0.2992]}, {"w": "you", "b": [0.6748, 0.2788, 0.7045, 0.2992]}, {"w": "should", "b": [0.7096, 0.2788, 0.7636, 0.2992]}, {"w": "use", "b": [0.7687, 0.2788, 0.7949, 0.2992]}, {"w": "these", "b": [0.8, 0.2788, 0.8408, 0.2992]}, {"w": "Keras", "b": [0.1592, 0.2969, 0.2039, 0.3173]}, {"w": "functions.", "b": [0.21, 0.2969, 0.2898, 0.3173]}, {"w": "However,", "b": [0.2959, 0.2969, 0.371, 0.3173]}, {"w": "they", "b": [0.3771, 0.2969, 0.4113, 0.3173]}, {"w": "only", "b": [0.4173, 0.2969, 0.4524, 0.3173]}, {"w": "cover", "b": [0.4585, 0.2969, 0.502, 0.3173]}, {"w": "a", "b": [0.5081, 0.2969, 0.5168, 0.3173]}, {"w": "subset", "b": [0.5229, 0.2969, 0.5726, 0.3173]}, {"w": "of", "b": [0.5787, 0.2969, 0.5947, 0.3173]}, {"w": "all", "b": [0.6007, 0.2969, 0.6195, 0.3173]}, {"w": "functions", "b": [0.6256, 0.2969, 0.7009, 0.3173]}, {"w": "available", "b": [0.707, 0.2969, 0.7758, 0.3173]}, {"w": "in", "b": [0.7819, 0.2969, 0.798, 0.3173]}, {"w": "Ten‐", "b": [0.8041, 0.2969, 0.8408, 0.3173]}, {"w": "sorFlow,", "b": [0.1592, 0.3151, 0.2263, 0.3354]}, {"w": "so", "b": [0.2335, 0.3151, 0.2509, 0.3354]}, {"w": "in", "b": [0.2581, 0.3151, 0.2742, 0.3354]}, {"w": "this", "b": [0.2814, 0.3151, 0.3107, 0.3354]}, {"w": "book", "b": [0.3179, 0.3151, 0.358, 0.3354]}, {"w": "we", "b": [0.3652, 0.3151, 0.3872, 0.3354]}, {"w": "will", "b": [0.3944, 0.3151, 0.4234, 0.3354]}, {"w": "use", "b": [0.4306, 0.3151, 0.4568, 0.3354]}, {"w": "the", "b": [0.464, 0.3151, 0.4891, 0.3354]}, {"w": "TensorFlow", "b": [0.4963, 0.3151, 0.5898, 0.3354]}, {"w": "operations", "b": [0.597, 0.3151, 0.6813, 0.3354]}, {"w": "directly.", "b": [0.6885, 0.3151, 0.7517, 0.3354]}, {"w": "Here", "b": [0.7589, 0.3151, 0.7978, 0.3354]}, {"w": "is", "b": [0.805, 0.3151, 0.8176, 0.3354]}, {"w": "as", "b": [0.8248, 0.3151, 0.8408, 0.3354]}, {"w": "simple", "b": [0.1592, 0.3341, 0.2116, 0.3544]}, {"w": "example", "b": [0.2161, 0.3341, 0.2823, 0.3544]}, {"w": "using", "b": [0.2868, 0.3341, 0.3301, 0.3544]}, {"w": "keras.backend,", "b": [0.3346, 0.3341, 0.4616, 0.3544]}, {"w": "which", "b": [0.4661, 0.3341, 0.5146, 0.3544]}, {"w": "is", "b": [0.5191, 0.3341, 0.5317, 0.3544]}, {"w": "commonly", "b": [0.5362, 0.3341, 0.6223, 0.3544]}, {"w": "named", "b": [0.6268, 0.3341, 0.6816, 0.3544]}, {"w": "K", "b": [0.6861, 0.3371, 0.6955, 0.3514]}, {"w": "for", "b": [0.7, 0.3341, 0.7233, 0.3544]}, {"w": "short:", "b": [0.7278, 0.3341, 0.7738, 0.3544]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> from tensorflow import keras >>> K = keras.backend >>> K.square(K.transpose(t)) + 10 ", "words": [{"w": ">>>", "b": [0.193, 0.365, 0.2183, 0.3778]}, {"w": "from", "b": [0.2267, 0.365, 0.2604, 0.3778]}, {"w": "tensorflow", "b": [0.2689, 0.365, 0.3532, 0.3778]}, {"w": "import", "b": [0.3616, 0.365, 0.4122, 0.3778]}, {"w": "keras", "b": [0.4206, 0.365, 0.4628, 0.3778]}, {"w": ">>>", "b": [0.193, 0.3804, 0.2183, 0.3933]}, {"w": "K", "b": [0.2267, 0.3804, 0.2351, 0.3933]}, {"w": "=", "b": [0.2436, 0.3804, 0.252, 0.3933]}, {"w": "keras.backend", "b": [0.2604, 0.3804, 0.37, 0.3933]}, {"w": ">>>", "b": [0.193, 0.3958, 0.2183, 0.4087]}, {"w": "K.square(K.transpose(t))", "b": [0.2267, 0.3958, 0.4291, 0.4087]}, {"w": "+", "b": [0.4375, 0.3958, 0.4459, 0.4087]}, {"w": "10", "b": [0.4544, 0.3958, 0.4712, 0.4087]}, {"w": "", "b": [0.3616, 0.4575, 0.4881, 0.4704]}]}, {"id": "b_5", "type": "paragraph", "text": "Tensors and NumPy", "words": [{"w": "Tensors", "b": [0.1429, 0.5012, 0.2212, 0.5298]}, {"w": "and", "b": [0.2261, 0.5012, 0.2654, 0.5298]}, {"w": "NumPy", "b": [0.2703, 0.5012, 0.3446, 0.5298]}]}, {"id": "b_6", "type": "paragraph", "text": "Tensors play nice with NumPy: you can create a tensor from a NumPy array, and vice versa, and you can even apply TensorFlow operations to NumPy arrays and NumPy operations to tensors:", "words": [{"w": "Tensors", "b": [0.1429, 0.5357, 0.2076, 0.5571]}, {"w": "play", "b": [0.2127, 0.5357, 0.2472, 0.5571]}, {"w": "nice", "b": [0.2523, 0.5357, 0.2869, 0.5571]}, {"w": "with", "b": [0.292, 0.5357, 0.3293, 0.5571]}, {"w": "NumPy:", "b": [0.3344, 0.5357, 0.404, 0.5571]}, {"w": "you", "b": [0.4091, 0.5357, 0.4403, 0.5571]}, {"w": "can", "b": [0.4454, 0.5357, 0.4748, 0.5571]}, {"w": "create", "b": [0.4799, 0.5357, 0.5292, 0.5571]}, {"w": "a", "b": [0.5343, 0.5357, 0.5434, 0.5571]}, {"w": "tensor", "b": [0.5485, 0.5357, 0.6011, 0.5571]}, {"w": "from", "b": [0.6062, 0.5357, 0.6478, 0.5571]}, {"w": "a", "b": [0.6529, 0.5357, 0.662, 0.5571]}, {"w": "NumPy", "b": [0.6671, 0.5357, 0.7313, 0.5571]}, {"w": "array,", "b": [0.7364, 0.5357, 0.7825, 0.5571]}, {"w": "and", "b": [0.7876, 0.5357, 0.8192, 0.5571]}, {"w": "vice", "b": [0.8243, 0.5357, 0.8572, 0.5571]}, {"w": "versa,", "b": [0.1429, 0.5547, 0.1906, 0.5761]}, {"w": "and", "b": [0.197, 0.5547, 0.2285, 0.5761]}, {"w": "you", "b": [0.2348, 0.5547, 0.2661, 0.5761]}, {"w": "can", "b": [0.2724, 0.5547, 0.3018, 0.5761]}, {"w": "even", "b": [0.3081, 0.5547, 0.3469, 0.5761]}, {"w": "apply", "b": [0.3532, 0.5547, 0.3986, 0.5761]}, {"w": "TensorFlow", "b": [0.405, 0.5547, 0.5032, 0.5761]}, {"w": "operations", "b": [0.5095, 0.5547, 0.598, 0.5761]}, {"w": "to", "b": [0.6044, 0.5547, 0.6213, 0.5761]}, {"w": "NumPy", "b": [0.6277, 0.5547, 0.6918, 0.5761]}, {"w": "arrays", "b": [0.6982, 0.5547, 0.7488, 0.5761]}, {"w": "and", "b": [0.7551, 0.5547, 0.7866, 0.5761]}, {"w": "NumPy", "b": [0.793, 0.5547, 0.8571, 0.5761]}, {"w": "operations", "b": [0.1429, 0.5738, 0.2313, 0.5952]}, {"w": "to", "b": [0.2361, 0.5738, 0.253, 0.5952]}, {"w": "tensors:", "b": [0.2578, 0.5738, 0.3228, 0.5952]}]}, {"id": "b_7", "type": "paragraph", "text": ">>> a = np.array([2., 4., 5.]) >>> tf.constant(a) >>> t.numpy() # or np.array(t) array([[1., 2., 3.], [4., 5., 6.]], dtype=float32) >>> tf.square(a) >>> np.square(t) array([[ 1., 4., 9.], [16., 25., 36.]], dtype=float32)", "words": [{"w": ">>>", "b": [0.1766, 0.6058, 0.2019, 0.6186]}, {"w": "a", "b": [0.2103, 0.6058, 0.2187, 0.6186]}, {"w": "=", "b": [0.2272, 0.6058, 0.2356, 0.6186]}, {"w": "np.array([2.,", "b": [0.244, 0.6058, 0.3537, 0.6186]}, {"w": "4.,", "b": [0.3621, 0.6058, 0.3874, 0.6186]}, {"w": "5.])", "b": [0.3958, 0.6058, 0.4296, 0.6186]}, {"w": ">>>", "b": [0.1766, 0.6212, 0.2019, 0.634]}, {"w": "tf.constant(a)", "b": [0.2103, 0.6212, 0.3284, 0.634]}, {"w": "", "b": [0.75, 0.6366, 0.7922, 0.6494]}, {"w": ">>>", "b": [0.1766, 0.652, 0.2019, 0.6649]}, {"w": "t.numpy()", "b": [0.2103, 0.652, 0.2862, 0.6649]}, {"w": "#", "b": [0.2946, 0.652, 0.3031, 0.6649]}, {"w": "or", "b": [0.3115, 0.652, 0.3284, 0.6649]}, {"w": "np.array(t)", "b": [0.3368, 0.652, 0.4296, 0.6649]}, {"w": "array([[1.,", "b": [0.1766, 0.6674, 0.2693, 0.6803]}, {"w": "2.,", "b": [0.2778, 0.6674, 0.3031, 0.6803]}, {"w": "3.],", "b": [0.3115, 0.6674, 0.3452, 0.6803]}, {"w": "[4.,", "b": [0.2356, 0.6828, 0.2693, 0.6957]}, {"w": "5.,", "b": [0.2778, 0.6828, 0.3031, 0.6957]}, {"w": "6.]],", "b": [0.3115, 0.6828, 0.3537, 0.6957]}, {"w": "dtype=float32)", "b": [0.3621, 0.6828, 0.4802, 0.6957]}, {"w": ">>>", "b": [0.1766, 0.6983, 0.2019, 0.7111]}, {"w": "tf.square(a)", "b": [0.2103, 0.6983, 0.3115, 0.7111]}, {"w": "", "b": [0.7584, 0.7137, 0.809, 0.7265]}, {"w": ">>>", "b": [0.1766, 0.7291, 0.2019, 0.742]}, {"w": "np.square(t)", "b": [0.2103, 0.7291, 0.3115, 0.742]}, {"w": "array([[", "b": [0.1766, 0.7445, 0.244, 0.7574]}, {"w": "1.,", "b": [0.2525, 0.7445, 0.2778, 0.7574]}, {"w": "4.,", "b": [0.2946, 0.7445, 0.3199, 0.7574]}, {"w": "9.],", "b": [0.3368, 0.7445, 0.3705, 0.7574]}, {"w": "[16.,", "b": [0.2356, 0.7599, 0.2778, 0.7728]}, {"w": "25.,", "b": [0.2862, 0.7599, 0.3199, 0.7728]}, {"w": "36.]],", "b": [0.3284, 0.7599, 0.379, 0.7728]}, {"w": "dtype=float32)", "b": [0.3874, 0.7599, 0.5055, 0.7728]}]}, {"id": "b_8", "type": "paragraph", "text": "Using TensorFlow like NumPy | 373", "words": [{"w": "Using", "b": [0.623, 0.9225, 0.6561, 0.9388]}, {"w": "TensorFlow", "b": [0.6589, 0.9225, 0.7264, 0.9388]}, {"w": "like", "b": [0.7293, 0.9225, 0.7506, 0.9388]}, {"w": "NumPy", "b": [0.7534, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "373", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 400, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Notice that NumPy uses 64-bit precision by default, while Tensor‐ Flow uses 32-bit. This is because 32-bit precision is generally more than enough for neural networks, plus it runs faster and uses less RAM. So when you create a tensor from a NumPy array, make sure to set dtype=tf.float32.", "words": [{"w": "Notice", "b": [0.2714, 0.0793, 0.3219, 0.0989]}, {"w": "that", "b": [0.3276, 0.0793, 0.3574, 0.0989]}, {"w": "NumPy", "b": [0.3631, 0.0793, 0.4218, 0.0989]}, {"w": "uses", "b": [0.4275, 0.0793, 0.4597, 0.0989]}, {"w": "64-bit", "b": [0.4654, 0.0793, 0.5111, 0.0989]}, {"w": "precision", "b": [0.5168, 0.0793, 0.5873, 0.0989]}, {"w": "by", "b": [0.5931, 0.0793, 0.6115, 0.0989]}, {"w": "default,", "b": [0.6172, 0.0793, 0.6741, 0.0989]}, {"w": "while", "b": [0.6798, 0.0793, 0.721, 0.0989]}, {"w": "Tensor‐", "b": [0.7268, 0.0793, 0.7857, 0.0989]}, {"w": "Flow", "b": [0.2714, 0.0967, 0.3091, 0.1163]}, {"w": "uses", "b": [0.3142, 0.0967, 0.3464, 0.1163]}, {"w": "32-bit.", "b": [0.3515, 0.0967, 0.4015, 0.1163]}, {"w": "This", "b": [0.4066, 0.0967, 0.4406, 0.1163]}, {"w": "is", "b": [0.4458, 0.0967, 0.4579, 0.1163]}, {"w": "because", "b": [0.463, 0.0967, 0.522, 0.1163]}, {"w": "32-bit", "b": [0.5271, 0.0967, 0.5728, 0.1163]}, {"w": "precision", "b": [0.5779, 0.0967, 0.6484, 0.1163]}, {"w": "is", "b": [0.6536, 0.0967, 0.6657, 0.1163]}, {"w": "generally", "b": [0.6708, 0.0967, 0.7401, 0.1163]}, {"w": "more", "b": [0.7452, 0.0967, 0.7857, 0.1163]}, {"w": "than", "b": [0.2714, 0.1141, 0.3062, 0.1337]}, {"w": "enough", "b": [0.3124, 0.1141, 0.3698, 0.1337]}, {"w": "for", "b": [0.3761, 0.1141, 0.3985, 0.1337]}, {"w": "neural", "b": [0.4047, 0.1141, 0.4536, 0.1337]}, {"w": "networks,", "b": [0.4598, 0.1141, 0.5348, 0.1337]}, {"w": "plus", "b": [0.541, 0.1141, 0.5729, 0.1337]}, {"w": "it", "b": [0.5791, 0.1141, 0.5901, 0.1337]}, {"w": "runs", "b": [0.5963, 0.1141, 0.6309, 0.1337]}, {"w": "faster", "b": [0.6371, 0.1141, 0.6791, 0.1337]}, {"w": "and", "b": [0.6853, 0.1141, 0.7142, 0.1337]}, {"w": "uses", "b": [0.7204, 0.1141, 0.7526, 0.1337]}, {"w": "less", "b": [0.7588, 0.1141, 0.7857, 0.1337]}, {"w": "RAM.", "b": [0.2714, 0.1315, 0.3177, 0.1511]}, {"w": "So", "b": [0.3224, 0.1315, 0.3412, 0.1511]}, {"w": "when", "b": [0.3458, 0.1315, 0.3876, 0.1511]}, {"w": "you", "b": [0.3923, 0.1315, 0.4208, 0.1511]}, {"w": "create", "b": [0.4255, 0.1315, 0.4707, 0.1511]}, {"w": "a", "b": [0.4754, 0.1315, 0.4837, 0.1511]}, {"w": "tensor", "b": [0.4884, 0.1315, 0.5365, 0.1511]}, {"w": "from", "b": [0.5412, 0.1315, 0.5792, 0.1511]}, {"w": "a", "b": [0.5839, 0.1315, 0.5923, 0.1511]}, {"w": "NumPy", "b": [0.597, 0.1315, 0.6557, 0.1511]}, {"w": "array,", "b": [0.6603, 0.1315, 0.7026, 0.1511]}, {"w": "make", "b": [0.7073, 0.1315, 0.7488, 0.1511]}, {"w": "sure", "b": [0.7535, 0.1315, 0.7857, 0.1511]}, {"w": "to", "b": [0.2714, 0.1498, 0.2869, 0.1693]}, {"w": "set", "b": [0.2913, 0.1498, 0.3122, 0.1693]}, {"w": "dtype=tf.float32.", "b": [0.3165, 0.1498, 0.4656, 0.1693]}]}, {"id": "b_1", "type": "paragraph", "text": "Type Conversions", "words": [{"w": "Type", "b": [0.1429, 0.1869, 0.1918, 0.2154]}, {"w": "Conversions", "b": [0.1968, 0.1869, 0.3199, 0.2154]}]}, {"id": "b_2", "type": "paragraph", "text": "Type conversions can significantly hurt performance, and they can easily go unno‐ ticed when they are done automatically. To avoid this, TensorFlow does not perform any type conversions automatically: it just raises an exception if you try to execute an operation on tensors with incompatible types. For example, you cannot add a float tensor and an integer tensor, and you cannot even add a 32-bit float and a 64-bit float:", "words": [{"w": "Type", "b": [0.1429, 0.2213, 0.1835, 0.2428]}, {"w": "conversions", "b": [0.1908, 0.2213, 0.2903, 0.2428]}, {"w": "can", "b": [0.2975, 0.2213, 0.3269, 0.2428]}, {"w": "significantly", "b": [0.3341, 0.2213, 0.436, 0.2428]}, {"w": "hurt", "b": [0.4433, 0.2213, 0.4791, 0.2428]}, {"w": "performance,", "b": [0.4864, 0.2213, 0.5984, 0.2428]}, {"w": "and", "b": [0.6057, 0.2213, 0.6372, 0.2428]}, {"w": "they", "b": [0.6445, 0.2213, 0.6804, 0.2428]}, {"w": "can", "b": [0.6877, 0.2213, 0.717, 0.2428]}, {"w": "easily", "b": [0.7243, 0.2213, 0.7703, 0.2428]}, {"w": "go", "b": [0.7776, 0.2213, 0.798, 0.2428]}, {"w": "unno‐", "b": [0.8052, 0.2213, 0.8571, 0.2428]}, {"w": "ticed", "b": [0.1429, 0.2404, 0.1835, 0.2618]}, {"w": "when", "b": [0.1895, 0.2404, 0.2351, 0.2618]}, {"w": "they", "b": [0.2412, 0.2404, 0.2771, 0.2618]}, {"w": "are", "b": [0.2831, 0.2404, 0.3088, 0.2618]}, {"w": "done", "b": [0.3148, 0.2404, 0.3567, 0.2618]}, {"w": "automatically.", "b": [0.3627, 0.2404, 0.4786, 0.2618]}, {"w": "To", "b": [0.4846, 0.2404, 0.506, 0.2618]}, {"w": "avoid", "b": [0.5121, 0.2404, 0.5577, 0.2618]}, {"w": "this,", "b": [0.5637, 0.2404, 0.5992, 0.2618]}, {"w": "TensorFlow", "b": [0.6052, 0.2404, 0.7035, 0.2618]}, {"w": "does", "b": [0.7095, 0.2404, 0.7476, 0.2618]}, {"w": "not", "b": [0.7536, 0.2404, 0.782, 0.2618]}, {"w": "perform", "b": [0.7881, 0.2404, 0.8571, 0.2618]}, {"w": "any", "b": [0.1429, 0.2594, 0.1725, 0.2809]}, {"w": "type", "b": [0.1777, 0.2594, 0.2134, 0.2809]}, {"w": "conversions", "b": [0.2187, 0.2594, 0.3181, 0.2809]}, {"w": "automatically:", "b": [0.3234, 0.2594, 0.4414, 0.2809]}, {"w": "it", "b": [0.4466, 0.2594, 0.4586, 0.2809]}, {"w": "just", "b": [0.4638, 0.2594, 0.4942, 0.2809]}, {"w": "raises", "b": [0.4994, 0.2594, 0.546, 0.2809]}, {"w": "an", "b": [0.5513, 0.2594, 0.5718, 0.2809]}, {"w": "exception", "b": [0.5771, 0.2594, 0.6583, 0.2809]}, {"w": "if", "b": [0.6635, 0.2594, 0.6753, 0.2809]}, {"w": "you", "b": [0.6805, 0.2594, 0.7118, 0.2809]}, {"w": "try", "b": [0.717, 0.2594, 0.7413, 0.2809]}, {"w": "to", "b": [0.7465, 0.2594, 0.7635, 0.2809]}, {"w": "execute", "b": [0.7687, 0.2594, 0.8314, 0.2809]}, {"w": "an", "b": [0.8366, 0.2594, 0.8572, 0.2809]}, {"w": "operation", "b": [0.1429, 0.2785, 0.2237, 0.2999]}, {"w": "on", "b": [0.2309, 0.2785, 0.2529, 0.2999]}, {"w": "tensors", "b": [0.2602, 0.2785, 0.3204, 0.2999]}, {"w": "with", "b": [0.3276, 0.2785, 0.365, 0.2999]}, {"w": "incompatible", "b": [0.3722, 0.2785, 0.4816, 0.2999]}, {"w": "types.", "b": [0.4888, 0.2785, 0.5369, 0.2999]}, {"w": "For", "b": [0.5441, 0.2785, 0.5731, 0.2999]}, {"w": "example,", "b": [0.5803, 0.2785, 0.6546, 0.2999]}, {"w": "you", "b": [0.6618, 0.2785, 0.6931, 0.2999]}, {"w": "cannot", "b": [0.7003, 0.2785, 0.758, 0.2999]}, {"w": "add", "b": [0.7652, 0.2785, 0.7964, 0.2999]}, {"w": "a", "b": [0.8036, 0.2785, 0.8128, 0.2999]}, {"w": "float", "b": [0.82, 0.2785, 0.8571, 0.2999]}, {"w": "tensor", "b": [0.1429, 0.2975, 0.1955, 0.319]}, {"w": "and", "b": [0.2002, 0.2975, 0.2317, 0.319]}, {"w": "an", "b": [0.2365, 0.2975, 0.257, 0.319]}, {"w": "integer", "b": [0.2617, 0.2975, 0.3199, 0.319]}, {"w": "tensor,", "b": [0.3246, 0.2975, 0.3806, 0.319]}, {"w": "and", "b": [0.3854, 0.2975, 0.4169, 0.319]}, {"w": "you", "b": [0.4216, 0.2975, 0.4529, 0.319]}, {"w": "cannot", "b": [0.4576, 0.2975, 0.5153, 0.319]}, {"w": "even", "b": [0.5201, 0.2975, 0.5588, 0.319]}, {"w": "add", "b": [0.5635, 0.2975, 0.5947, 0.319]}, {"w": "a", "b": [0.5994, 0.2975, 0.6086, 0.319]}, {"w": "32-bit", "b": [0.6133, 0.2975, 0.6632, 0.319]}, {"w": "float", "b": [0.668, 0.2975, 0.7051, 0.319]}, {"w": "and", "b": [0.7099, 0.2975, 0.7414, 0.319]}, {"w": "a", "b": [0.7461, 0.2975, 0.7553, 0.319]}, {"w": "64-bit", "b": [0.76, 0.2975, 0.8099, 0.319]}, {"w": "float:", "b": [0.8147, 0.2975, 0.8566, 0.319]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> tf.constant(2.) + tf.constant(40) Traceback[...]InvalidArgumentError[...]expected to be a float[...] >>> tf.constant(2.) + tf.constant(40., dtype=tf.float64) Traceback[...]InvalidArgumentError[...]expected to be a double[...]", "words": [{"w": ">>>", "b": [0.1766, 0.3295, 0.2019, 0.3424]}, {"w": "tf.constant(2.)", "b": [0.2103, 0.3295, 0.3368, 0.3424]}, {"w": "+", "b": [0.3452, 0.3295, 0.3537, 0.3424]}, {"w": "tf.constant(40)", "b": [0.3621, 0.3295, 0.4886, 0.3424]}, {"w": "Traceback[...]InvalidArgumentError[...]expected", "b": [0.1766, 0.3449, 0.5729, 0.3578]}, {"w": "to", "b": [0.5813, 0.3449, 0.5982, 0.3578]}, {"w": "be", "b": [0.6066, 0.3449, 0.6235, 0.3578]}, {"w": "a", "b": [0.6319, 0.3449, 0.6404, 0.3578]}, {"w": "float[...]", "b": [0.6488, 0.3449, 0.7331, 0.3578]}, {"w": ">>>", "b": [0.1766, 0.3604, 0.2019, 0.3732]}, {"w": "tf.constant(2.)", "b": [0.2103, 0.3604, 0.3368, 0.3732]}, {"w": "+", "b": [0.3452, 0.3604, 0.3537, 0.3732]}, {"w": "tf.constant(40.,", "b": [0.3621, 0.3604, 0.497, 0.3732]}, {"w": "dtype=tf.float64)", "b": [0.5055, 0.3604, 0.6488, 0.3732]}, {"w": "Traceback[...]InvalidArgumentError[...]expected", "b": [0.1766, 0.3758, 0.5729, 0.3886]}, {"w": "to", "b": [0.5813, 0.3758, 0.5982, 0.3886]}, {"w": "be", "b": [0.6066, 0.3758, 0.6235, 0.3886]}, {"w": "a", "b": [0.6319, 0.3758, 0.6404, 0.3886]}, {"w": "double[...]", "b": [0.6488, 0.3758, 0.7416, 0.3886]}]}, {"id": "b_4", "type": "paragraph", "text": "This may be a bit annoying at first, but remember that it’s for a good cause! And of course you can use tf.cast() when you really need to convert types:", "words": [{"w": "This", "b": [0.1429, 0.3964, 0.1801, 0.4178]}, {"w": "may", "b": [0.1865, 0.3964, 0.2219, 0.4178]}, {"w": "be", "b": [0.2283, 0.3964, 0.2478, 0.4178]}, {"w": "a", "b": [0.2542, 0.3964, 0.2633, 0.4178]}, {"w": "bit", "b": [0.2698, 0.3964, 0.2923, 0.4178]}, {"w": "annoying", "b": [0.2987, 0.3964, 0.3776, 0.4178]}, {"w": "at", "b": [0.384, 0.3964, 0.3991, 0.4178]}, {"w": "first,", "b": [0.4055, 0.3964, 0.4437, 0.4178]}, {"w": "but", "b": [0.4502, 0.3964, 0.4782, 0.4178]}, {"w": "remember", "b": [0.4846, 0.3964, 0.5713, 0.4178]}, {"w": "that", "b": [0.5778, 0.3964, 0.6103, 0.4178]}, {"w": "it’s", "b": [0.6168, 0.3964, 0.6385, 0.4178]}, {"w": "for", "b": [0.6449, 0.3964, 0.6694, 0.4178]}, {"w": "a", "b": [0.6758, 0.3964, 0.685, 0.4178]}, {"w": "good", "b": [0.6914, 0.3964, 0.7334, 0.4178]}, {"w": "cause!", "b": [0.7398, 0.3964, 0.7907, 0.4178]}, {"w": "And", "b": [0.7971, 0.3964, 0.8339, 0.4178]}, {"w": "of", "b": [0.8403, 0.3964, 0.8571, 0.4178]}, {"w": "course", "b": [0.1428, 0.4164, 0.1976, 0.4378]}, {"w": "you", "b": [0.2023, 0.4164, 0.2336, 0.4378]}, {"w": "can", "b": [0.2383, 0.4164, 0.2676, 0.4378]}, {"w": "use", "b": [0.2724, 0.4164, 0.2999, 0.4378]}, {"w": "tf.cast()", "b": [0.3047, 0.4195, 0.3937, 0.4346]}, {"w": "when", "b": [0.3985, 0.4164, 0.4441, 0.4378]}, {"w": "you", "b": [0.4488, 0.4164, 0.4801, 0.4378]}, {"w": "really", "b": [0.4848, 0.4164, 0.5306, 0.4378]}, {"w": "need", "b": [0.5354, 0.4164, 0.5755, 0.4378]}, {"w": "to", "b": [0.5802, 0.4164, 0.5972, 0.4378]}, {"w": "convert", "b": [0.6019, 0.4164, 0.6648, 0.4378]}, {"w": "types:", "b": [0.6696, 0.4164, 0.7177, 0.4378]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> t2 = tf.constant(40., dtype=tf.float64) >>> tf.constant(2.0) + tf.cast(t2, tf.float32) ", "words": [{"w": ">>>", "b": [0.1766, 0.4483, 0.2019, 0.4612]}, {"w": "t2", "b": [0.2103, 0.4483, 0.2272, 0.4612]}, {"w": "=", "b": [0.2356, 0.4483, 0.244, 0.4612]}, {"w": "tf.constant(40.,", "b": [0.2525, 0.4483, 0.3874, 0.4612]}, {"w": "dtype=tf.float64)", "b": [0.3958, 0.4483, 0.5392, 0.4612]}, {"w": ">>>", "b": [0.1766, 0.4637, 0.2019, 0.4766]}, {"w": "tf.constant(2.0)", "b": [0.2103, 0.4637, 0.3452, 0.4766]}, {"w": "+", "b": [0.3537, 0.4637, 0.3621, 0.4766]}, {"w": "tf.cast(t2,", "b": [0.3705, 0.4637, 0.4633, 0.4766]}, {"w": "tf.float32)", "b": [0.4717, 0.4637, 0.5645, 0.4766]}, {"w": "", "b": [0.556, 0.4792, 0.6488, 0.492]}]}, {"id": "b_6", "type": "paragraph", "text": "Variables", "words": [{"w": "Variables", "b": [0.1428, 0.5059, 0.2381, 0.5344]}]}, {"id": "b_7", "type": "paragraph", "text": "So far, we have used constant tensors: as their name suggests, you cannot modify them. However, the weights in a neural network need to be tweaked by backpropaga‐ tion, and other parameters may also need to change over time (e.g., a momentum optimizer keeps track of past gradients). What we need is a tf.Variable:", "words": [{"w": "So", "b": [0.1429, 0.5403, 0.1634, 0.5617]}, {"w": "far,", "b": [0.1714, 0.5403, 0.1979, 0.5617]}, {"w": "we", "b": [0.206, 0.5403, 0.2291, 0.5617]}, {"w": "have", "b": [0.2372, 0.5403, 0.2756, 0.5617]}, {"w": "used", "b": [0.2837, 0.5403, 0.3223, 0.5617]}, {"w": "constant", "b": [0.3304, 0.5403, 0.4017, 0.5617]}, {"w": "tensors:", "b": [0.4098, 0.5403, 0.4748, 0.5617]}, {"w": "as", "b": [0.4829, 0.5403, 0.4997, 0.5617]}, {"w": "their", "b": [0.5078, 0.5403, 0.5474, 0.5617]}, {"w": "name", "b": [0.5555, 0.5403, 0.602, 0.5617]}, {"w": "suggests,", "b": [0.6101, 0.5403, 0.6835, 0.5617]}, {"w": "you", "b": [0.6916, 0.5403, 0.7229, 0.5617]}, {"w": "cannot", "b": [0.731, 0.5403, 0.7887, 0.5617]}, {"w": "modify", "b": [0.7968, 0.5403, 0.8571, 0.5617]}, {"w": "them.", "b": [0.1428, 0.5594, 0.191, 0.5808]}, {"w": "However,", "b": [0.1963, 0.5594, 0.2751, 0.5808]}, {"w": "the", "b": [0.2804, 0.5594, 0.3067, 0.5808]}, {"w": "weights", "b": [0.312, 0.5594, 0.3752, 0.5808]}, {"w": "in", "b": [0.3805, 0.5594, 0.3975, 0.5808]}, {"w": "a", "b": [0.4027, 0.5594, 0.4119, 0.5808]}, {"w": "neural", "b": [0.4172, 0.5594, 0.4706, 0.5808]}, {"w": "network", "b": [0.4759, 0.5594, 0.5455, 0.5808]}, {"w": "need", "b": [0.5507, 0.5594, 0.5908, 0.5808]}, {"w": "to", "b": [0.5961, 0.5594, 0.6131, 0.5808]}, {"w": "be", "b": [0.6184, 0.5594, 0.6378, 0.5808]}, {"w": "tweaked", "b": [0.6431, 0.5594, 0.7119, 0.5808]}, {"w": "by", "b": [0.7172, 0.5594, 0.7373, 0.5808]}, {"w": "backpropaga‐", "b": [0.7426, 0.5594, 0.8571, 0.5808]}, {"w": "tion,", "b": [0.1429, 0.5784, 0.1816, 0.5998]}, {"w": "and", "b": [0.1892, 0.5784, 0.2207, 0.5998]}, {"w": "other", "b": [0.2283, 0.5784, 0.273, 0.5998]}, {"w": "parameters", "b": [0.2806, 0.5784, 0.374, 0.5998]}, {"w": "may", "b": [0.3816, 0.5784, 0.417, 0.5998]}, {"w": "also", "b": [0.4246, 0.5784, 0.4573, 0.5998]}, {"w": "need", "b": [0.4649, 0.5784, 0.505, 0.5998]}, {"w": "to", "b": [0.5126, 0.5784, 0.5295, 0.5998]}, {"w": "change", "b": [0.5371, 0.5784, 0.5962, 0.5998]}, {"w": "over", "b": [0.6038, 0.5784, 0.6406, 0.5998]}, {"w": "time", "b": [0.6482, 0.5784, 0.6861, 0.5998]}, {"w": "(e.g.,", "b": [0.6937, 0.5784, 0.7337, 0.5998]}, {"w": "a", "b": [0.7413, 0.5784, 0.7505, 0.5998]}, {"w": "momentum", "b": [0.7581, 0.5784, 0.8571, 0.5998]}, {"w": "optimizer", "b": [0.1429, 0.5984, 0.2243, 0.6198]}, {"w": "keeps", "b": [0.229, 0.5984, 0.2756, 0.6198]}, {"w": "track", "b": [0.2804, 0.5984, 0.3228, 0.6198]}, {"w": "of", "b": [0.3275, 0.5984, 0.3443, 0.6198]}, {"w": "past", "b": [0.349, 0.5984, 0.3831, 0.6198]}, {"w": "gradients).", "b": [0.3878, 0.5984, 0.4768, 0.6198]}, {"w": "What", "b": [0.4815, 0.5984, 0.528, 0.6198]}, {"w": "we", "b": [0.5327, 0.5984, 0.5559, 0.6198]}, {"w": "need", "b": [0.5606, 0.5984, 0.6007, 0.6198]}, {"w": "is", "b": [0.6054, 0.5984, 0.6186, 0.6198]}, {"w": "a", "b": [0.6234, 0.5984, 0.6325, 0.6198]}, {"w": "tf.Variable:", "b": [0.6373, 0.5984, 0.7509, 0.6198]}]}, {"id": "b_8", "type": "paragraph", "text": ">>> v = tf.Variable([[1., 2., 3.], [4., 5., 6.]]) >>> v ", "words": [{"w": ">>>", "b": [0.1766, 0.6303, 0.2019, 0.6432]}, {"w": "v", "b": [0.2103, 0.6303, 0.2187, 0.6432]}, {"w": "=", "b": [0.2272, 0.6303, 0.2356, 0.6432]}, {"w": "tf.Variable([[1.,", "b": [0.244, 0.6303, 0.3874, 0.6432]}, {"w": "2.,", "b": [0.3958, 0.6303, 0.4211, 0.6432]}, {"w": "3.],", "b": [0.4296, 0.6303, 0.4633, 0.6432]}, {"w": "[4.,", "b": [0.4717, 0.6303, 0.5055, 0.6432]}, {"w": "5.,", "b": [0.5139, 0.6303, 0.5392, 0.6432]}, {"w": "6.]])", "b": [0.5476, 0.6303, 0.5898, 0.6432]}, {"w": ">>>", "b": [0.1766, 0.6458, 0.2019, 0.6586]}, {"w": "v", "b": [0.2103, 0.6458, 0.2187, 0.6586]}, {"w": "", "b": [0.3621, 0.692, 0.4886, 0.7049]}]}, {"id": "b_9", "type": "paragraph", "text": "A tf.Variable acts much like a constant tensor: you can perform the same opera‐ tions with it, it plays nicely with NumPy as well, and it is just as picky with types. But it can also be modified in place using the assign() method (or assign_add() or assign_sub() which increment or decrement the variable by the given value). You can also modify individual cells (or slices), using the cell’s (or slice’s) assign() method (direct item assignment will not work), or using the scatter_update() or scatter_nd_update() methods:", "words": [{"w": "A", "b": [0.1429, 0.7135, 0.1573, 0.735]}, {"w": "tf.Variable", "b": [0.1642, 0.7167, 0.273, 0.7318]}, {"w": "acts", "b": [0.2799, 0.7135, 0.3119, 0.735]}, {"w": "much", "b": [0.3188, 0.7135, 0.3664, 0.735]}, {"w": "like", "b": [0.3733, 0.7135, 0.4034, 0.735]}, {"w": "a", "b": [0.4102, 0.7135, 0.4194, 0.735]}, {"w": "constant", "b": [0.4263, 0.7135, 0.4976, 0.735]}, {"w": "tensor:", "b": [0.5045, 0.7135, 0.5624, 0.735]}, {"w": "you", "b": [0.5693, 0.7135, 0.6005, 0.735]}, {"w": "can", "b": [0.6074, 0.7135, 0.6368, 0.735]}, {"w": "perform", "b": [0.6437, 0.7135, 0.7127, 0.735]}, {"w": "the", "b": [0.7196, 0.7135, 0.746, 0.735]}, {"w": "same", "b": [0.7529, 0.7135, 0.7956, 0.735]}, {"w": "opera‐", "b": [0.8025, 0.7135, 0.8571, 0.735]}, {"w": "tions", "b": [0.1429, 0.7326, 0.1845, 0.754]}, {"w": "with", "b": [0.1897, 0.7326, 0.227, 0.754]}, {"w": "it,", "b": [0.2323, 0.7326, 0.2489, 0.754]}, {"w": "it", "b": [0.2542, 0.7326, 0.2661, 0.754]}, {"w": "plays", "b": [0.2713, 0.7326, 0.3135, 0.754]}, {"w": "nicely", "b": [0.3187, 0.7326, 0.3682, 0.754]}, {"w": "with", "b": [0.3735, 0.7326, 0.4108, 0.754]}, {"w": "NumPy", "b": [0.416, 0.7326, 0.4802, 0.754]}, {"w": "as", "b": [0.4854, 0.7326, 0.5022, 0.754]}, {"w": "well,", "b": [0.5074, 0.7326, 0.5459, 0.754]}, {"w": "and", "b": [0.5511, 0.7326, 0.5826, 0.754]}, {"w": "it", "b": [0.5879, 0.7326, 0.5998, 0.754]}, {"w": "is", "b": [0.605, 0.7326, 0.6183, 0.754]}, {"w": "just", "b": [0.6235, 0.7326, 0.6539, 0.754]}, {"w": "as", "b": [0.6591, 0.7326, 0.6759, 0.754]}, {"w": "picky", "b": [0.6812, 0.7326, 0.7264, 0.754]}, {"w": "with", "b": [0.7316, 0.7326, 0.7689, 0.754]}, {"w": "types.", "b": [0.7742, 0.7326, 0.8222, 0.754]}, {"w": "But", "b": [0.8275, 0.7326, 0.8571, 0.754]}, {"w": "it", "b": [0.1428, 0.7525, 0.1548, 0.774]}, {"w": "can", "b": [0.163, 0.7525, 0.1923, 0.774]}, {"w": "also", "b": [0.2005, 0.7525, 0.2332, 0.774]}, {"w": "be", "b": [0.2414, 0.7525, 0.2608, 0.774]}, {"w": "modified", "b": [0.269, 0.7525, 0.3449, 0.774]}, {"w": "in", "b": [0.3531, 0.7525, 0.37, 0.774]}, {"w": "place", "b": [0.3782, 0.7525, 0.4212, 0.774]}, {"w": "using", "b": [0.4294, 0.7525, 0.4748, 0.774]}, {"w": "the", "b": [0.483, 0.7525, 0.5094, 0.774]}, {"w": "assign()", "b": [0.5175, 0.7557, 0.5967, 0.7708]}, {"w": "method", "b": [0.6049, 0.7525, 0.6699, 0.774]}, {"w": "(or", "b": [0.6781, 0.7525, 0.7037, 0.774]}, {"w": "assign_add()", "b": [0.7118, 0.7557, 0.8306, 0.7708]}, {"w": "or", "b": [0.8388, 0.7525, 0.8571, 0.774]}, {"w": "assign_sub()", "b": [0.1429, 0.7757, 0.2616, 0.7907]}, {"w": "which", "b": [0.2689, 0.7725, 0.3198, 0.7939]}, {"w": "increment", "b": [0.327, 0.7725, 0.4127, 0.7939]}, {"w": "or", "b": [0.4199, 0.7725, 0.4383, 0.7939]}, {"w": "decrement", "b": [0.4455, 0.7725, 0.5341, 0.7939]}, {"w": "the", "b": [0.5413, 0.7725, 0.5677, 0.7939]}, {"w": "variable", "b": [0.5749, 0.7725, 0.6409, 0.7939]}, {"w": "by", "b": [0.6481, 0.7725, 0.6683, 0.7939]}, {"w": "the", "b": [0.6755, 0.7725, 0.7019, 0.7939]}, {"w": "given", "b": [0.7091, 0.7725, 0.7543, 0.7939]}, {"w": "value).", "b": [0.7616, 0.7725, 0.8175, 0.7939]}, {"w": "You", "b": [0.8248, 0.7725, 0.8571, 0.7939]}, {"w": "can", "b": [0.1429, 0.7924, 0.1722, 0.8138]}, {"w": "also", "b": [0.1824, 0.7924, 0.2151, 0.8138]}, {"w": "modify", "b": [0.2253, 0.7924, 0.2857, 0.8138]}, {"w": "individual", "b": [0.2959, 0.7924, 0.3812, 0.8138]}, {"w": "cells", "b": [0.3914, 0.7924, 0.4272, 0.8138]}, {"w": "(or", "b": [0.4374, 0.7924, 0.463, 0.8138]}, {"w": "slices),", "b": [0.4732, 0.7924, 0.529, 0.8138]}, {"w": "using", "b": [0.5392, 0.7924, 0.5846, 0.8138]}, {"w": "the", "b": [0.5948, 0.7924, 0.6211, 0.8138]}, {"w": "cell’s", "b": [0.6313, 0.7924, 0.6693, 0.8138]}, {"w": "(or", "b": [0.6795, 0.7924, 0.7051, 0.8138]}, {"w": "slice’s)", "b": [0.7153, 0.7924, 0.7678, 0.8138]}, {"w": "assign()", "b": [0.778, 0.7956, 0.8571, 0.8107]}, {"w": "method", "b": [0.1429, 0.8124, 0.2079, 0.8338]}, {"w": "(direct", "b": [0.2152, 0.8124, 0.2708, 0.8338]}, {"w": "item", "b": [0.2781, 0.8124, 0.316, 0.8338]}, {"w": "assignment", "b": [0.3234, 0.8124, 0.4178, 0.8338]}, {"w": "will", "b": [0.4251, 0.8124, 0.4555, 0.8338]}, {"w": "not", "b": [0.4629, 0.8124, 0.4913, 0.8338]}, {"w": "work),", "b": [0.4986, 0.8124, 0.5536, 0.8338]}, {"w": "or", "b": [0.5609, 0.8124, 0.5793, 0.8338]}, {"w": "using", "b": [0.5866, 0.8124, 0.6321, 0.8338]}, {"w": "the", "b": [0.6394, 0.8124, 0.6657, 0.8338]}, {"w": "scatter_update()", "b": [0.6731, 0.8156, 0.8314, 0.8306]}, {"w": "or", "b": [0.8388, 0.8124, 0.8572, 0.8338]}, {"w": "scatter_nd_update()", "b": [0.1429, 0.8355, 0.3309, 0.8506]}, {"w": "methods:", "b": [0.3356, 0.8323, 0.413, 0.8537]}]}, {"id": "b_10", "type": "paragraph", "text": "v.assign(2 * v) # => [[2., 4., 6.], [8., 10., 12.]] v[0, 1].assign(42) # => [[2., 42., 6.], [8., 10., 12.]]", "words": [{"w": "v.assign(2", "b": [0.1766, 0.8643, 0.2609, 0.8771]}, {"w": "*", "b": [0.2693, 0.8643, 0.2778, 0.8771]}, {"w": "v)", "b": [0.2862, 0.8643, 0.3031, 0.8771]}, {"w": "#", "b": [0.3958, 0.8643, 0.4043, 0.8771]}, {"w": "=>", "b": [0.4127, 0.8643, 0.4296, 0.8771]}, {"w": "[[2.,", "b": [0.438, 0.8643, 0.4802, 0.8771]}, {"w": "4.,", "b": [0.4886, 0.8643, 0.5139, 0.8771]}, {"w": "6.],", "b": [0.5223, 0.8643, 0.5561, 0.8771]}, {"w": "[8.,", "b": [0.5645, 0.8643, 0.5982, 0.8771]}, {"w": "10.,", "b": [0.6066, 0.8643, 0.6404, 0.8771]}, {"w": "12.]]", "b": [0.6488, 0.8643, 0.691, 0.8771]}, {"w": "v[0,", "b": [0.1766, 0.8797, 0.2103, 0.8926]}, {"w": "1].assign(42)", "b": [0.2188, 0.8797, 0.3284, 0.8926]}, {"w": "#", "b": [0.3958, 0.8797, 0.4043, 0.8926]}, {"w": "=>", "b": [0.4127, 0.8797, 0.4296, 0.8926]}, {"w": "[[2.,", "b": [0.438, 0.8797, 0.4802, 0.8926]}, {"w": "42.,", "b": [0.4886, 0.8797, 0.5223, 0.8926]}, {"w": "6.],", "b": [0.5308, 0.8797, 0.5645, 0.8926]}, {"w": "[8.,", "b": [0.5729, 0.8797, 0.6066, 0.8926]}, {"w": "10.,", "b": [0.6151, 0.8797, 0.6488, 0.8926]}, {"w": "12.]]", "b": [0.6572, 0.8797, 0.6994, 0.8926]}]}, {"id": "b_11", "type": "paragraph", "text": "374 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "374", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2745, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 401, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "v[:, 2].assign([0., 1.]) # => [[2., 42., 0.], [8., 10., 1.]] v.scatter_nd_update(indices=[[0, 0], [1, 2]], updates=[100., 200.]) # => [[100., 42., 0.], [8., 10., 200.]]", "words": [{"w": "v[:,", "b": [0.1766, 0.0829, 0.2103, 0.0958]}, {"w": "2].assign([0.,", "b": [0.2188, 0.0829, 0.3368, 0.0958]}, {"w": "1.])", "b": [0.3452, 0.0829, 0.379, 0.0958]}, {"w": "#", "b": [0.3958, 0.0829, 0.4043, 0.0958]}, {"w": "=>", "b": [0.4127, 0.0829, 0.4296, 0.0958]}, {"w": "[[2.,", "b": [0.438, 0.0829, 0.4802, 0.0958]}, {"w": "42.,", "b": [0.4886, 0.0829, 0.5223, 0.0958]}, {"w": "0.],", "b": [0.5308, 0.0829, 0.5645, 0.0958]}, {"w": "[8.,", "b": [0.5729, 0.0829, 0.6066, 0.0958]}, {"w": "10.,", "b": [0.6151, 0.0829, 0.6488, 0.0958]}, {"w": "1.]]", "b": [0.6572, 0.0829, 0.691, 0.0958]}, {"w": "v.scatter_nd_update(indices=[[0,", "b": [0.1766, 0.0983, 0.4464, 0.1112]}, {"w": "0],", "b": [0.4549, 0.0983, 0.4802, 0.1112]}, {"w": "[1,", "b": [0.4886, 0.0983, 0.5139, 0.1112]}, {"w": "2]],", "b": [0.5223, 0.0983, 0.5561, 0.1112]}, {"w": "updates=[100.,", "b": [0.5645, 0.0983, 0.6825, 0.1112]}, {"w": "200.])", "b": [0.691, 0.0983, 0.7416, 0.1112]}, {"w": "#", "b": [0.3958, 0.1138, 0.4043, 0.1266]}, {"w": "=>", "b": [0.4127, 0.1138, 0.4296, 0.1266]}, {"w": "[[100.,", "b": [0.438, 0.1138, 0.497, 0.1266]}, {"w": "42.,", "b": [0.5055, 0.1138, 0.5392, 0.1266]}, {"w": "0.],", "b": [0.5476, 0.1138, 0.5813, 0.1266]}, {"w": "[8.,", "b": [0.5898, 0.1138, 0.6235, 0.1266]}, {"w": "10.,", "b": [0.6319, 0.1138, 0.6657, 0.1266]}, {"w": "200.]]", "b": [0.6741, 0.1138, 0.7247, 0.1266]}]}, {"id": "b_1", "type": "paragraph", "text": "In practice you will rarely have to create variables manually, since Keras provides an add_weight() method that will take care of it for you, as we will see. Moreover, model parameters will generally be updated directly by the optimizers, so you will rarely need to update variables manually.", "words": [{"w": "In", "b": [0.2714, 0.1482, 0.2883, 0.1678]}, {"w": "practice", "b": [0.2944, 0.1482, 0.3549, 0.1678]}, {"w": "you", "b": [0.361, 0.1482, 0.3896, 0.1678]}, {"w": "will", "b": [0.3957, 0.1482, 0.4235, 0.1678]}, {"w": "rarely", "b": [0.4295, 0.1482, 0.4737, 0.1678]}, {"w": "have", "b": [0.4798, 0.1482, 0.5149, 0.1678]}, {"w": "to", "b": [0.521, 0.1482, 0.5365, 0.1678]}, {"w": "create", "b": [0.5426, 0.1482, 0.5877, 0.1678]}, {"w": "variables", "b": [0.5938, 0.1482, 0.6611, 0.1678]}, {"w": "manually,", "b": [0.6671, 0.1482, 0.741, 0.1678]}, {"w": "since", "b": [0.747, 0.1482, 0.7857, 0.1678]}, {"w": "Keras", "b": [0.2714, 0.1665, 0.3143, 0.186]}, {"w": "provides", "b": [0.3186, 0.1665, 0.3844, 0.186]}, {"w": "an", "b": [0.3888, 0.1665, 0.4075, 0.186]}, {"w": "add_weight()", "b": [0.4123, 0.1694, 0.5209, 0.1831]}, {"w": "method", "b": [0.5254, 0.1665, 0.5848, 0.186]}, {"w": "that", "b": [0.5893, 0.1665, 0.6191, 0.186]}, {"w": "will", "b": [0.6236, 0.1665, 0.6513, 0.186]}, {"w": "take", "b": [0.6558, 0.1665, 0.6875, 0.186]}, {"w": "care", "b": [0.692, 0.1665, 0.7236, 0.186]}, {"w": "of", "b": [0.7281, 0.1665, 0.7434, 0.186]}, {"w": "it", "b": [0.7479, 0.1665, 0.7588, 0.186]}, {"w": "for", "b": [0.7633, 0.1665, 0.7857, 0.186]}, {"w": "you,", "b": [0.2714, 0.1839, 0.3043, 0.2034]}, {"w": "as", "b": [0.3106, 0.1839, 0.3259, 0.2034]}, {"w": "we", "b": [0.3322, 0.1839, 0.3534, 0.2034]}, {"w": "will", "b": [0.3596, 0.1839, 0.3874, 0.2034]}, {"w": "see.", "b": [0.3937, 0.1839, 0.4212, 0.2034]}, {"w": "Moreover,", "b": [0.4275, 0.1839, 0.5057, 0.2034]}, {"w": "model", "b": [0.512, 0.1839, 0.5603, 0.2034]}, {"w": "parameters", "b": [0.5665, 0.1839, 0.652, 0.2034]}, {"w": "will", "b": [0.6583, 0.1839, 0.686, 0.2034]}, {"w": "generally", "b": [0.6923, 0.1839, 0.7617, 0.2034]}, {"w": "be", "b": [0.7679, 0.1839, 0.7857, 0.2034]}, {"w": "updated", "b": [0.2714, 0.2013, 0.3335, 0.2209]}, {"w": "directly", "b": [0.3432, 0.2013, 0.4009, 0.2209]}, {"w": "by", "b": [0.4106, 0.2013, 0.429, 0.2209]}, {"w": "the", "b": [0.4387, 0.2013, 0.4628, 0.2209]}, {"w": "optimizers,", "b": [0.4725, 0.2013, 0.5583, 0.2209]}, {"w": "so", "b": [0.5679, 0.2013, 0.5846, 0.2209]}, {"w": "you", "b": [0.5943, 0.2013, 0.6229, 0.2209]}, {"w": "will", "b": [0.6326, 0.2013, 0.6603, 0.2209]}, {"w": "rarely", "b": [0.67, 0.2013, 0.7142, 0.2209]}, {"w": "need", "b": [0.7238, 0.2013, 0.7605, 0.2209]}, {"w": "to", "b": [0.7702, 0.2013, 0.7857, 0.2209]}, {"w": "update", "b": [0.2714, 0.2187, 0.3235, 0.2383]}, {"w": "variables", "b": [0.3278, 0.2187, 0.3951, 0.2383]}, {"w": "manually.", "b": [0.3994, 0.2187, 0.4732, 0.2383]}]}, {"id": "b_2", "type": "paragraph", "text": "Other Data Structures", "words": [{"w": "Other", "b": [0.1428, 0.2558, 0.2008, 0.2844]}, {"w": "Data", "b": [0.2057, 0.2558, 0.2542, 0.2844]}, {"w": "Structures", "b": [0.2591, 0.2558, 0.3645, 0.2844]}]}, {"id": "b_3", "type": "paragraph", "text": "TensorFlow supports several other data structures, including the following (please see the notebook or ??? for more details):", "words": [{"w": "TensorFlow", "b": [0.1429, 0.2903, 0.2411, 0.3117]}, {"w": "supports", "b": [0.2461, 0.2903, 0.319, 0.3117]}, {"w": "several", "b": [0.3239, 0.2903, 0.3811, 0.3117]}, {"w": "other", "b": [0.386, 0.2903, 0.4307, 0.3117]}, {"w": "data", "b": [0.4357, 0.2903, 0.4709, 0.3117]}, {"w": "structures,", "b": [0.4759, 0.2903, 0.5639, 0.3117]}, {"w": "including", "b": [0.5689, 0.2903, 0.6487, 0.3117]}, {"w": "the", "b": [0.6537, 0.2903, 0.68, 0.3117]}, {"w": "following", "b": [0.685, 0.2903, 0.764, 0.3117]}, {"w": "(please", "b": [0.7689, 0.2903, 0.8268, 0.3117]}, {"w": "see", "b": [0.8318, 0.2903, 0.8571, 0.3117]}, {"w": "the", "b": [0.1428, 0.3093, 0.1692, 0.3307]}, {"w": "notebook", "b": [0.1739, 0.3093, 0.2533, 0.3307]}, {"w": "or", "b": [0.258, 0.3093, 0.2764, 0.3307]}, {"w": "???", "b": [0.2811, 0.3093, 0.3048, 0.3307]}, {"w": "for", "b": [0.3095, 0.3093, 0.3341, 0.3307]}, {"w": "more", "b": [0.3388, 0.3093, 0.3831, 0.3307]}, {"w": "details):", "b": [0.3878, 0.3093, 0.4536, 0.3307]}]}, {"id": "b_4", "type": "paragraph", "text": "• Sparse tensors (tf.SparseTensor) efficiently represent tensors containing mostly 0s. The tf.sparse package contains operations for sparse tensors.", "words": [{"w": "•", "b": [0.16, 0.3444, 0.1681, 0.3658]}, {"w": "Sparse", "b": [0.1786, 0.3442, 0.2309, 0.3658]}, {"w": "tensors", "b": [0.2366, 0.3442, 0.2935, 0.3658]}, {"w": "(tf.SparseTensor)", "b": [0.2992, 0.3444, 0.462, 0.3658]}, {"w": "efficiently", "b": [0.4677, 0.3444, 0.55, 0.3658]}, {"w": "represent", "b": [0.5557, 0.3444, 0.6336, 0.3658]}, {"w": "tensors", "b": [0.6393, 0.3444, 0.6996, 0.3658]}, {"w": "containing", "b": [0.7053, 0.3444, 0.7949, 0.3658]}, {"w": "mostly", "b": [0.8006, 0.3444, 0.8571, 0.3658]}, {"w": "0s.", "b": [0.1786, 0.3643, 0.201, 0.3858]}, {"w": "The", "b": [0.2057, 0.3643, 0.2385, 0.3858]}, {"w": "tf.sparse", "b": [0.2433, 0.3675, 0.3323, 0.3826]}, {"w": "package", "b": [0.3371, 0.3643, 0.404, 0.3858]}, {"w": "contains", "b": [0.4087, 0.3643, 0.4793, 0.3858]}, {"w": "operations", "b": [0.484, 0.3643, 0.5725, 0.3858]}, {"w": "for", "b": [0.5772, 0.3643, 0.6018, 0.3858]}, {"w": "sparse", "b": [0.6065, 0.3643, 0.6584, 0.3858]}, {"w": "tensors.", "b": [0.6632, 0.3643, 0.7282, 0.3858]}]}, {"id": "b_5", "type": "paragraph", "text": "• Tensor arrays (tf.TensorArray) are lists of tensors. They have a fixed size by default, but can optionally be made dynamic. All tensors they contain must have the same shape and data type.", "words": [{"w": "•", "b": [0.16, 0.3903, 0.1682, 0.4117]}, {"w": "Tensor", "b": [0.1786, 0.3901, 0.2328, 0.4117]}, {"w": "arrays", "b": [0.241, 0.3901, 0.2919, 0.4117]}, {"w": "(tf.TensorArray)", "b": [0.3001, 0.3903, 0.453, 0.4117]}, {"w": "are", "b": [0.4612, 0.3903, 0.4869, 0.4117]}, {"w": "lists", "b": [0.4951, 0.3903, 0.5276, 0.4117]}, {"w": "of", "b": [0.5358, 0.3903, 0.5526, 0.4117]}, {"w": "tensors.", "b": [0.5607, 0.3903, 0.6257, 0.4117]}, {"w": "They", "b": [0.6339, 0.3903, 0.6763, 0.4117]}, {"w": "have", "b": [0.6845, 0.3903, 0.7229, 0.4117]}, {"w": "a", "b": [0.7311, 0.3903, 0.7402, 0.4117]}, {"w": "fixed", "b": [0.7484, 0.3903, 0.7898, 0.4117]}, {"w": "size", "b": [0.798, 0.3903, 0.8288, 0.4117]}, {"w": "by", "b": [0.837, 0.3903, 0.8571, 0.4117]}, {"w": "default,", "b": [0.1786, 0.4094, 0.2408, 0.4308]}, {"w": "but", "b": [0.2464, 0.4094, 0.2744, 0.4308]}, {"w": "can", "b": [0.28, 0.4094, 0.3094, 0.4308]}, {"w": "optionally", "b": [0.315, 0.4094, 0.3997, 0.4308]}, {"w": "be", "b": [0.4053, 0.4094, 0.4248, 0.4308]}, {"w": "made", "b": [0.4304, 0.4094, 0.4764, 0.4308]}, {"w": "dynamic.", "b": [0.482, 0.4094, 0.5594, 0.4308]}, {"w": "All", "b": [0.565, 0.4094, 0.5899, 0.4308]}, {"w": "tensors", "b": [0.5955, 0.4094, 0.6558, 0.4308]}, {"w": "they", "b": [0.6614, 0.4094, 0.6973, 0.4308]}, {"w": "contain", "b": [0.7029, 0.4094, 0.7658, 0.4308]}, {"w": "must", "b": [0.7714, 0.4094, 0.8131, 0.4308]}, {"w": "have", "b": [0.8187, 0.4094, 0.8571, 0.4308]}, {"w": "the", "b": [0.1786, 0.4284, 0.2049, 0.4498]}, {"w": "same", "b": [0.2096, 0.4284, 0.2523, 0.4498]}, {"w": "shape", "b": [0.2571, 0.4284, 0.3044, 0.4498]}, {"w": "and", "b": [0.3091, 0.4284, 0.3406, 0.4498]}, {"w": "data", "b": [0.3454, 0.4284, 0.3806, 0.4498]}, {"w": "type.", "b": [0.3853, 0.4284, 0.4258, 0.4498]}]}, {"id": "b_6", "type": "paragraph", "text": "• Ragged tensors (tf.RaggedTensor) represent static lists of lists of tensors, where every tensor has the same shape and data type. The tf.ragged package contains operations for ragged tensors.", "words": [{"w": "•", "b": [0.16, 0.4544, 0.1682, 0.4758]}, {"w": "Ragged", "b": [0.1786, 0.4542, 0.2375, 0.4758]}, {"w": "tensors", "b": [0.2439, 0.4542, 0.3008, 0.4758]}, {"w": "(tf.RaggedTensor)", "b": [0.3072, 0.4544, 0.47, 0.4758]}, {"w": "represent", "b": [0.4764, 0.4544, 0.5544, 0.4758]}, {"w": "static", "b": [0.5608, 0.4544, 0.6043, 0.4758]}, {"w": "lists", "b": [0.6107, 0.4544, 0.6432, 0.4758]}, {"w": "of", "b": [0.6496, 0.4544, 0.6664, 0.4758]}, {"w": "lists", "b": [0.6728, 0.4544, 0.7053, 0.4758]}, {"w": "of", "b": [0.7117, 0.4544, 0.7285, 0.4758]}, {"w": "tensors,", "b": [0.7349, 0.4544, 0.7999, 0.4758]}, {"w": "where", "b": [0.8063, 0.4544, 0.8571, 0.4758]}, {"w": "every", "b": [0.1786, 0.4744, 0.2238, 0.4958]}, {"w": "tensor", "b": [0.2296, 0.4744, 0.2822, 0.4958]}, {"w": "has", "b": [0.2881, 0.4744, 0.316, 0.4958]}, {"w": "the", "b": [0.3218, 0.4744, 0.3481, 0.4958]}, {"w": "same", "b": [0.354, 0.4744, 0.3967, 0.4958]}, {"w": "shape", "b": [0.4025, 0.4744, 0.4498, 0.4958]}, {"w": "and", "b": [0.4556, 0.4744, 0.4871, 0.4958]}, {"w": "data", "b": [0.4929, 0.4744, 0.5282, 0.4958]}, {"w": "type.", "b": [0.534, 0.4744, 0.5745, 0.4958]}, {"w": "The", "b": [0.5803, 0.4744, 0.6131, 0.4958]}, {"w": "tf.ragged", "b": [0.6189, 0.4775, 0.708, 0.4926]}, {"w": "package", "b": [0.7138, 0.4744, 0.7808, 0.4958]}, {"w": "contains", "b": [0.7866, 0.4744, 0.8571, 0.4958]}, {"w": "operations", "b": [0.1786, 0.4934, 0.267, 0.5148]}, {"w": "for", "b": [0.2718, 0.4934, 0.2963, 0.5148]}, {"w": "ragged", "b": [0.301, 0.4934, 0.3572, 0.5148]}, {"w": "tensors.", "b": [0.362, 0.4934, 0.427, 0.5148]}]}, {"id": "b_7", "type": "paragraph", "text": "• String tensors are regular tensors of type tf.string. These actually represent byte strings, not Unicode strings, so if you create a string tensor using a Unicode string (e.g., a regular Python 3 string like \"café\"`), then it will get encoded to UTF-8 automatically (e.g., b\"caf\\xc3\\xa9\"). Alternatively, you can represent Unicode strings using tensors of type tf.int32, where each item represents a Unicode codepoint (e.g., [99, 97, 102, 233]). The tf.strings package (with an s) contains ops for byte strings and Unicode strings (and to convert one into the other).", "words": [{"w": "•", "b": [0.16, 0.5194, 0.1682, 0.5408]}, {"w": "String", "b": [0.1786, 0.5192, 0.2271, 0.5408]}, {"w": "tensors", "b": [0.2319, 0.5192, 0.2887, 0.5408]}, {"w": "are", "b": [0.2938, 0.5194, 0.3195, 0.5408]}, {"w": "regular", "b": [0.3245, 0.5194, 0.384, 0.5408]}, {"w": "tensors", "b": [0.3889, 0.5194, 0.4492, 0.5408]}, {"w": "of", "b": [0.4541, 0.5194, 0.4709, 0.5408]}, {"w": "type", "b": [0.4758, 0.5194, 0.5115, 0.5408]}, {"w": "tf.string.", "b": [0.5164, 0.5194, 0.6102, 0.5408]}, {"w": "These", "b": [0.6151, 0.5194, 0.6645, 0.5408]}, {"w": "actually", "b": [0.6694, 0.5194, 0.734, 0.5408]}, {"w": "represent", "b": [0.7389, 0.5194, 0.8169, 0.5408]}, {"w": "byte", "b": [0.8218, 0.5194, 0.8572, 0.5408]}, {"w": "strings,", "b": [0.1786, 0.5384, 0.2394, 0.5599]}, {"w": "not", "b": [0.248, 0.5384, 0.2764, 0.5599]}, {"w": "Unicode", "b": [0.285, 0.5384, 0.3557, 0.5599]}, {"w": "strings,", "b": [0.3643, 0.5384, 0.4251, 0.5599]}, {"w": "so", "b": [0.4337, 0.5384, 0.452, 0.5599]}, {"w": "if", "b": [0.4606, 0.5384, 0.4723, 0.5599]}, {"w": "you", "b": [0.4809, 0.5384, 0.5122, 0.5599]}, {"w": "create", "b": [0.5208, 0.5384, 0.5701, 0.5599]}, {"w": "a", "b": [0.5787, 0.5384, 0.5878, 0.5599]}, {"w": "string", "b": [0.5964, 0.5384, 0.6449, 0.5599]}, {"w": "tensor", "b": [0.6535, 0.5384, 0.7061, 0.5599]}, {"w": "using", "b": [0.7147, 0.5384, 0.7601, 0.5599]}, {"w": "a", "b": [0.7687, 0.5384, 0.7778, 0.5599]}, {"w": "Unicode", "b": [0.7864, 0.5384, 0.8571, 0.5599]}, {"w": "string", "b": [0.1786, 0.5584, 0.227, 0.5798]}, {"w": "(e.g.,", "b": [0.2341, 0.5584, 0.2741, 0.5798]}, {"w": "a", "b": [0.2811, 0.5584, 0.2903, 0.5798]}, {"w": "regular", "b": [0.2973, 0.5584, 0.3569, 0.5798]}, {"w": "Python", "b": [0.3639, 0.5584, 0.4247, 0.5798]}, {"w": "3", "b": [0.4317, 0.5584, 0.4417, 0.5798]}, {"w": "string", "b": [0.4487, 0.5584, 0.4972, 0.5798]}, {"w": "like", "b": [0.5042, 0.5584, 0.5342, 0.5798]}, {"w": "\"café\"`),", "b": [0.5413, 0.5584, 0.6225, 0.5798]}, {"w": "then", "b": [0.6295, 0.5584, 0.6672, 0.5798]}, {"w": "it", "b": [0.6743, 0.5584, 0.6862, 0.5798]}, {"w": "will", "b": [0.6932, 0.5584, 0.7236, 0.5798]}, {"w": "get", "b": [0.7306, 0.5584, 0.7556, 0.5798]}, {"w": "encoded", "b": [0.7626, 0.5584, 0.8331, 0.5798]}, {"w": "to", "b": [0.8402, 0.5584, 0.8572, 0.5798]}, {"w": "UTF-8", "b": [0.1786, 0.5783, 0.2348, 0.5997]}, {"w": "automatically", "b": [0.2447, 0.5783, 0.3573, 0.5997]}, {"w": "(e.g.,", "b": [0.3672, 0.5783, 0.4073, 0.5997]}, {"w": "b\"caf\\xc3\\xa9\").", "b": [0.4172, 0.5783, 0.5677, 0.5997]}, {"w": "Alternatively,", "b": [0.5776, 0.5783, 0.6889, 0.5997]}, {"w": "you", "b": [0.6988, 0.5783, 0.73, 0.5997]}, {"w": "can", "b": [0.7399, 0.5783, 0.7693, 0.5997]}, {"w": "represent", "b": [0.7792, 0.5783, 0.8571, 0.5997]}, {"w": "Unicode", "b": [0.1786, 0.5983, 0.2493, 0.6197]}, {"w": "strings", "b": [0.2573, 0.5983, 0.3134, 0.6197]}, {"w": "using", "b": [0.3214, 0.5983, 0.3669, 0.6197]}, {"w": "tensors", "b": [0.3749, 0.5983, 0.4352, 0.6197]}, {"w": "of", "b": [0.4432, 0.5983, 0.46, 0.6197]}, {"w": "type", "b": [0.468, 0.5983, 0.5037, 0.6197]}, {"w": "tf.int32,", "b": [0.5117, 0.5983, 0.5956, 0.6197]}, {"w": "where", "b": [0.6037, 0.5983, 0.6545, 0.6197]}, {"w": "each", "b": [0.6625, 0.5983, 0.7005, 0.6197]}, {"w": "item", "b": [0.7085, 0.5983, 0.7464, 0.6197]}, {"w": "represents", "b": [0.7544, 0.5983, 0.84, 0.6197]}, {"w": "a", "b": [0.848, 0.5983, 0.8571, 0.6197]}, {"w": "Unicode", "b": [0.1786, 0.6182, 0.2493, 0.6396]}, {"w": "codepoint", "b": [0.2558, 0.6182, 0.3396, 0.6396]}, {"w": "(e.g.,", "b": [0.3461, 0.6182, 0.3861, 0.6396]}, {"w": "[99,", "b": [0.3926, 0.6214, 0.4322, 0.6365]}, {"w": "97,", "b": [0.4438, 0.6214, 0.4735, 0.6365]}, {"w": "102,", "b": [0.4851, 0.6214, 0.5247, 0.6365]}, {"w": "233]).", "b": [0.5363, 0.6182, 0.5878, 0.6396]}, {"w": "The", "b": [0.5943, 0.6182, 0.6271, 0.6396]}, {"w": "tf.strings", "b": [0.6337, 0.6214, 0.7326, 0.6365]}, {"w": "package", "b": [0.7391, 0.6182, 0.8061, 0.6396]}, {"w": "(with", "b": [0.8126, 0.6182, 0.8571, 0.6396]}, {"w": "an", "b": [0.1786, 0.6382, 0.1991, 0.6596]}, {"w": "s)", "b": [0.2051, 0.6382, 0.2222, 0.6596]}, {"w": "contains", "b": [0.2282, 0.6382, 0.2987, 0.6596]}, {"w": "ops", "b": [0.3047, 0.6382, 0.3339, 0.6596]}, {"w": "for", "b": [0.3399, 0.6382, 0.3644, 0.6596]}, {"w": "byte", "b": [0.3704, 0.6382, 0.4057, 0.6596]}, {"w": "strings", "b": [0.4117, 0.6382, 0.4678, 0.6596]}, {"w": "and", "b": [0.4738, 0.6382, 0.5054, 0.6596]}, {"w": "Unicode", "b": [0.5113, 0.6382, 0.582, 0.6596]}, {"w": "strings", "b": [0.588, 0.6382, 0.6441, 0.6596]}, {"w": "(and", "b": [0.6501, 0.6382, 0.6889, 0.6596]}, {"w": "to", "b": [0.6948, 0.6382, 0.7118, 0.6596]}, {"w": "convert", "b": [0.7178, 0.6382, 0.7807, 0.6596]}, {"w": "one", "b": [0.7867, 0.6382, 0.8176, 0.6596]}, {"w": "into", "b": [0.8236, 0.6382, 0.8571, 0.6596]}, {"w": "the", "b": [0.1786, 0.6572, 0.2049, 0.6786]}, {"w": "other).", "b": [0.2096, 0.6572, 0.2663, 0.6786]}]}, {"id": "b_8", "type": "paragraph", "text": "• Sets are just represented as regular tensors (or sparse tensors) containing one or more sets, and you can manipulate them using operations from the tf.sets package.", "words": [{"w": "•", "b": [0.16, 0.6823, 0.1681, 0.7037]}, {"w": "Sets", "b": [0.1786, 0.6821, 0.21, 0.7037]}, {"w": "are", "b": [0.2161, 0.6823, 0.2418, 0.7037]}, {"w": "just", "b": [0.2479, 0.6823, 0.2783, 0.7037]}, {"w": "represented", "b": [0.2844, 0.6823, 0.3822, 0.7037]}, {"w": "as", "b": [0.3882, 0.6823, 0.405, 0.7037]}, {"w": "regular", "b": [0.4111, 0.6823, 0.4706, 0.7037]}, {"w": "tensors", "b": [0.4767, 0.6823, 0.5369, 0.7037]}, {"w": "(or", "b": [0.543, 0.6823, 0.5685, 0.7037]}, {"w": "sparse", "b": [0.5746, 0.6823, 0.6266, 0.7037]}, {"w": "tensors)", "b": [0.6326, 0.6823, 0.7001, 0.7037]}, {"w": "containing", "b": [0.7061, 0.6823, 0.7958, 0.7037]}, {"w": "one", "b": [0.8018, 0.6823, 0.8327, 0.7037]}, {"w": "or", "b": [0.8388, 0.6823, 0.8571, 0.7037]}, {"w": "more", "b": [0.1786, 0.7023, 0.2228, 0.7237]}, {"w": "sets,", "b": [0.2318, 0.7023, 0.267, 0.7237]}, {"w": "and", "b": [0.2759, 0.7023, 0.3075, 0.7237]}, {"w": "you", "b": [0.3164, 0.7023, 0.3476, 0.7237]}, {"w": "can", "b": [0.3565, 0.7023, 0.3859, 0.7237]}, {"w": "manipulate", "b": [0.3948, 0.7023, 0.4892, 0.7237]}, {"w": "them", "b": [0.4981, 0.7023, 0.5415, 0.7237]}, {"w": "using", "b": [0.5504, 0.7023, 0.5958, 0.7237]}, {"w": "operations", "b": [0.6047, 0.7023, 0.6932, 0.7237]}, {"w": "from", "b": [0.7021, 0.7023, 0.7437, 0.7237]}, {"w": "the", "b": [0.7526, 0.7023, 0.779, 0.7237]}, {"w": "tf.sets", "b": [0.7879, 0.7054, 0.8571, 0.7205]}, {"w": "package.", "b": [0.1786, 0.7213, 0.2503, 0.7427]}]}, {"id": "b_9", "type": "paragraph", "text": "• Queues, including First In, First Out (FIFO) queues (FIFOQueue), queues that can prioritize some items (PriorityQueue), queues that shuffle their items (Random ShuffleQueue), and queues that can batch items of different shapes by padding (PaddingFIFOQueue). These classes are all in the tf.queue package.", "words": [{"w": "•", "b": [0.16, 0.7473, 0.1682, 0.7687]}, {"w": "Queues,", "b": [0.1786, 0.7471, 0.2437, 0.7687]}, {"w": "including", "b": [0.2487, 0.7473, 0.3286, 0.7687]}, {"w": "First", "b": [0.3336, 0.7473, 0.3719, 0.7687]}, {"w": "In,", "b": [0.377, 0.7473, 0.4002, 0.7687]}, {"w": "First", "b": [0.4052, 0.7473, 0.4435, 0.7687]}, {"w": "Out", "b": [0.4486, 0.7473, 0.4815, 0.7687]}, {"w": "(FIFO)", "b": [0.4865, 0.7473, 0.5457, 0.7687]}, {"w": "queues", "b": [0.5507, 0.7473, 0.6088, 0.7687]}, {"w": "(FIFOQueue),", "b": [0.6138, 0.7473, 0.722, 0.7687]}, {"w": "queues", "b": [0.7271, 0.7473, 0.7852, 0.7687]}, {"w": "that", "b": [0.7902, 0.7473, 0.8228, 0.7687]}, {"w": "can", "b": [0.8278, 0.7473, 0.8571, 0.7687]}, {"w": "prioritize", "b": [0.1786, 0.7672, 0.2563, 0.7887]}, {"w": "some", "b": [0.2633, 0.7672, 0.3075, 0.7887]}, {"w": "items", "b": [0.3144, 0.7672, 0.3599, 0.7887]}, {"w": "(PriorityQueue),", "b": [0.3669, 0.7672, 0.5147, 0.7887]}, {"w": "queues", "b": [0.5217, 0.7672, 0.5799, 0.7887]}, {"w": "that", "b": [0.5868, 0.7672, 0.6194, 0.7887]}, {"w": "shuffle", "b": [0.6264, 0.7672, 0.6823, 0.7887]}, {"w": "their", "b": [0.6893, 0.7672, 0.7289, 0.7887]}, {"w": "items", "b": [0.7359, 0.7672, 0.7814, 0.7887]}, {"w": "(Random", "b": [0.7884, 0.7672, 0.855, 0.7887]}, {"w": "ShuffleQueue),", "b": [0.1786, 0.7872, 0.3093, 0.8086]}, {"w": "and", "b": [0.3159, 0.7872, 0.3474, 0.8086]}, {"w": "queues", "b": [0.3541, 0.7872, 0.4122, 0.8086]}, {"w": "that", "b": [0.4188, 0.7872, 0.4514, 0.8086]}, {"w": "can", "b": [0.458, 0.7872, 0.4873, 0.8086]}, {"w": "batch", "b": [0.494, 0.7872, 0.5396, 0.8086]}, {"w": "items", "b": [0.5462, 0.7872, 0.5917, 0.8086]}, {"w": "of", "b": [0.5983, 0.7872, 0.6151, 0.8086]}, {"w": "different", "b": [0.6217, 0.7872, 0.6934, 0.8086]}, {"w": "shapes", "b": [0.7, 0.7872, 0.755, 0.8086]}, {"w": "by", "b": [0.7616, 0.7872, 0.7817, 0.8086]}, {"w": "padding", "b": [0.7884, 0.7872, 0.8572, 0.8086]}, {"w": "(PaddingFIFOQueue).", "b": [0.1786, 0.8071, 0.3561, 0.8285]}, {"w": "These", "b": [0.3608, 0.8071, 0.4101, 0.8285]}, {"w": "classes", "b": [0.4149, 0.8071, 0.4699, 0.8285]}, {"w": "are", "b": [0.4746, 0.8071, 0.5003, 0.8285]}, {"w": "all", "b": [0.5051, 0.8071, 0.5248, 0.8285]}, {"w": "in", "b": [0.5295, 0.8071, 0.5465, 0.8285]}, {"w": "the", "b": [0.5512, 0.8071, 0.5775, 0.8285]}, {"w": "tf.queue", "b": [0.5823, 0.8103, 0.6614, 0.8254]}, {"w": "package.", "b": [0.6662, 0.8071, 0.7379, 0.8285]}]}, {"id": "b_10", "type": "paragraph", "text": "With tensors, operations, variables and various data structures at your disposal, you are now ready to customize your models and training algorithms!", "words": [{"w": "With", "b": [0.1429, 0.8413, 0.1853, 0.8627]}, {"w": "tensors,", "b": [0.1917, 0.8413, 0.2567, 0.8627]}, {"w": "operations,", "b": [0.2631, 0.8413, 0.3564, 0.8627]}, {"w": "variables", "b": [0.3628, 0.8413, 0.4364, 0.8627]}, {"w": "and", "b": [0.4428, 0.8413, 0.4744, 0.8627]}, {"w": "various", "b": [0.4808, 0.8413, 0.5422, 0.8627]}, {"w": "data", "b": [0.5486, 0.8413, 0.5839, 0.8627]}, {"w": "structures", "b": [0.5903, 0.8413, 0.6736, 0.8627]}, {"w": "at", "b": [0.68, 0.8413, 0.6951, 0.8627]}, {"w": "your", "b": [0.7015, 0.8413, 0.7405, 0.8627]}, {"w": "disposal,", "b": [0.7469, 0.8413, 0.8195, 0.8627]}, {"w": "you", "b": [0.8259, 0.8413, 0.8571, 0.8627]}, {"w": "are", "b": [0.1429, 0.8603, 0.1686, 0.8818]}, {"w": "now", "b": [0.1733, 0.8603, 0.2096, 0.8818]}, {"w": "ready", "b": [0.2143, 0.8603, 0.2606, 0.8818]}, {"w": "to", "b": [0.2654, 0.8603, 0.2823, 0.8818]}, {"w": "customize", "b": [0.2871, 0.8603, 0.3718, 0.8818]}, {"w": "your", "b": [0.3765, 0.8603, 0.4155, 0.8818]}, {"w": "models", "b": [0.4203, 0.8603, 0.4807, 0.8818]}, {"w": "and", "b": [0.4854, 0.8603, 0.517, 0.8818]}, {"w": "training", "b": [0.5217, 0.8603, 0.5886, 0.8818]}, {"w": "algorithms!", "b": [0.5934, 0.8603, 0.6894, 0.8818]}]}, {"id": "b_11", "type": "paragraph", "text": "Using TensorFlow like NumPy | 375", "words": [{"w": "Using", "b": [0.623, 0.9225, 0.6561, 0.9388]}, {"w": "TensorFlow", "b": [0.6589, 0.9225, 0.7264, 0.9388]}, {"w": "like", "b": [0.7293, 0.9225, 0.7506, 0.9388]}, {"w": "NumPy", "b": [0.7534, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "375", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 402, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Customizing Models and Training Algorithms", "words": [{"w": "Customizing", "b": [0.1429, 0.0753, 0.2958, 0.1095]}, {"w": "Models", "b": [0.3017, 0.0753, 0.3905, 0.1095]}, {"w": "and", "b": [0.3965, 0.0753, 0.4436, 0.1095]}, {"w": "Training", "b": [0.4495, 0.0753, 0.5527, 0.1095]}, {"w": "Algorithms", "b": [0.5586, 0.0753, 0.6957, 0.1095]}]}, {"id": "b_1", "type": "paragraph", "text": "Let’s start by creating a custom loss function, which is a simple and common use case.", "words": [{"w": "Let’s", "b": [0.1428, 0.1164, 0.179, 0.1378]}, {"w": "start", "b": [0.1837, 0.1164, 0.221, 0.1378]}, {"w": "by", "b": [0.2257, 0.1164, 0.2458, 0.1378]}, {"w": "creating", "b": [0.2506, 0.1164, 0.3178, 0.1378]}, {"w": "a", "b": [0.3225, 0.1164, 0.3317, 0.1378]}, {"w": "custom", "b": [0.3364, 0.1164, 0.398, 0.1378]}, {"w": "loss", "b": [0.4027, 0.1164, 0.4339, 0.1378]}, {"w": "function,", "b": [0.4386, 0.1164, 0.5148, 0.1378]}, {"w": "which", "b": [0.5195, 0.1164, 0.5704, 0.1378]}, {"w": "is", "b": [0.5751, 0.1164, 0.5884, 0.1378]}, {"w": "a", "b": [0.5931, 0.1164, 0.6022, 0.1378]}, {"w": "simple", "b": [0.607, 0.1164, 0.6619, 0.1378]}, {"w": "and", "b": [0.6666, 0.1164, 0.6982, 0.1378]}, {"w": "common", "b": [0.7029, 0.1164, 0.7785, 0.1378]}, {"w": "use", "b": [0.7832, 0.1164, 0.8108, 0.1378]}, {"w": "case.", "b": [0.8155, 0.1164, 0.8547, 0.1378]}]}, {"id": "b_2", "type": "paragraph", "text": "Custom Loss Functions", "words": [{"w": "Custom", "b": [0.1429, 0.1506, 0.2201, 0.1792]}, {"w": "Loss", "b": [0.2251, 0.1506, 0.2686, 0.1792]}, {"w": "Functions", "b": [0.2735, 0.1506, 0.3733, 0.1792]}]}, {"id": "b_3", "type": "paragraph", "text": "Suppose you want to train a regression model, but your training set is a bit noisy. Of course, you start by trying to clean up your dataset by removing or fixing the outliers, but it turns out to be insufficient, the dataset is still noisy. Which loss function should you use? The mean squared error might penalize large errors too much, so your model will end up being imprecise. The mean absolute error would not penalize out‐ liers as much, but training might take a while to converge and the trained model might not be very precise. This is probably a good time to use the Huber loss (intro‐ duced in Chapter 10) instead of the good old MSE. The Huber loss is not currently part of the official Keras API, but it is available in tf.keras (just use an instance of the keras.losses.Huber class). But let’s pretend it’s not there: implementing it is easy as pie! Just create a function that takes the labels and predictions as arguments, and use TensorFlow operations to compute every instance’s loss:", "words": [{"w": "Suppose", "b": [0.1429, 0.1851, 0.2128, 0.2065]}, {"w": "you", "b": [0.2185, 0.1851, 0.2497, 0.2065]}, {"w": "want", "b": [0.2554, 0.1851, 0.2962, 0.2065]}, {"w": "to", "b": [0.3019, 0.1851, 0.3189, 0.2065]}, {"w": "train", "b": [0.3246, 0.1851, 0.3648, 0.2065]}, {"w": "a", "b": [0.3705, 0.1851, 0.3796, 0.2065]}, {"w": "regression", "b": [0.3853, 0.1851, 0.4711, 0.2065]}, {"w": "model,", "b": [0.4768, 0.1851, 0.5344, 0.2065]}, {"w": "but", "b": [0.5401, 0.1851, 0.5681, 0.2065]}, {"w": "your", "b": [0.5738, 0.1851, 0.6128, 0.2065]}, {"w": "training", "b": [0.6185, 0.1851, 0.6854, 0.2065]}, {"w": "set", "b": [0.6911, 0.1851, 0.714, 0.2065]}, {"w": "is", "b": [0.7197, 0.1851, 0.7329, 0.2065]}, {"w": "a", "b": [0.7386, 0.1851, 0.7478, 0.2065]}, {"w": "bit", "b": [0.7535, 0.1851, 0.776, 0.2065]}, {"w": "noisy.", "b": [0.7817, 0.1851, 0.8297, 0.2065]}, {"w": "Of", "b": [0.8354, 0.1851, 0.8572, 0.2065]}, {"w": "course,", "b": [0.1429, 0.2041, 0.2023, 0.2255]}, {"w": "you", "b": [0.2073, 0.2041, 0.2385, 0.2255]}, {"w": "start", "b": [0.2435, 0.2041, 0.2807, 0.2255]}, {"w": "by", "b": [0.2856, 0.2041, 0.3058, 0.2255]}, {"w": "trying", "b": [0.3107, 0.2041, 0.3617, 0.2255]}, {"w": "to", "b": [0.3666, 0.2041, 0.3836, 0.2255]}, {"w": "clean", "b": [0.3885, 0.2041, 0.432, 0.2255]}, {"w": "up", "b": [0.4369, 0.2041, 0.4589, 0.2255]}, {"w": "your", "b": [0.4639, 0.2041, 0.5028, 0.2255]}, {"w": "dataset", "b": [0.5078, 0.2041, 0.5659, 0.2255]}, {"w": "by", "b": [0.5708, 0.2041, 0.591, 0.2255]}, {"w": "removing", "b": [0.5959, 0.2041, 0.6765, 0.2255]}, {"w": "or", "b": [0.6815, 0.2041, 0.6998, 0.2255]}, {"w": "fixing", "b": [0.7048, 0.2041, 0.7531, 0.2255]}, {"w": "the", "b": [0.758, 0.2041, 0.7843, 0.2255]}, {"w": "outliers,", "b": [0.7893, 0.2041, 0.8571, 0.2255]}, {"w": "but", "b": [0.1429, 0.2232, 0.1709, 0.2446]}, {"w": "it", "b": [0.1758, 0.2232, 0.1878, 0.2446]}, {"w": "turns", "b": [0.1928, 0.2232, 0.2369, 0.2446]}, {"w": "out", "b": [0.2419, 0.2232, 0.27, 0.2446]}, {"w": "to", "b": [0.2749, 0.2232, 0.2919, 0.2446]}, {"w": "be", "b": [0.2969, 0.2232, 0.3163, 0.2446]}, {"w": "insufficient,", "b": [0.3213, 0.2232, 0.4203, 0.2446]}, {"w": "the", "b": [0.4253, 0.2232, 0.4516, 0.2446]}, {"w": "dataset", "b": [0.4566, 0.2232, 0.5147, 0.2446]}, {"w": "is", "b": [0.5197, 0.2232, 0.5329, 0.2446]}, {"w": "still", "b": [0.5379, 0.2232, 0.568, 0.2446]}, {"w": "noisy.", "b": [0.573, 0.2232, 0.621, 0.2446]}, {"w": "Which", "b": [0.626, 0.2232, 0.6829, 0.2446]}, {"w": "loss", "b": [0.6879, 0.2232, 0.719, 0.2446]}, {"w": "function", "b": [0.724, 0.2232, 0.7954, 0.2446]}, {"w": "should", "b": [0.8004, 0.2232, 0.8571, 0.2446]}, {"w": "you", "b": [0.1429, 0.2422, 0.1741, 0.2636]}, {"w": "use?", "b": [0.1828, 0.2422, 0.2183, 0.2636]}, {"w": "The", "b": [0.227, 0.2422, 0.2598, 0.2636]}, {"w": "mean", "b": [0.2685, 0.2422, 0.3149, 0.2636]}, {"w": "squared", "b": [0.3236, 0.2422, 0.3897, 0.2636]}, {"w": "error", "b": [0.3984, 0.2422, 0.4411, 0.2636]}, {"w": "might", "b": [0.4497, 0.2422, 0.4992, 0.2636]}, {"w": "penalize", "b": [0.5079, 0.2422, 0.5767, 0.2636]}, {"w": "large", "b": [0.5854, 0.2422, 0.6261, 0.2636]}, {"w": "errors", "b": [0.6348, 0.2422, 0.6851, 0.2636]}, {"w": "too", "b": [0.6938, 0.2422, 0.7214, 0.2636]}, {"w": "much,", "b": [0.7301, 0.2422, 0.7825, 0.2636]}, {"w": "so", "b": [0.7912, 0.2422, 0.8095, 0.2636]}, {"w": "your", "b": [0.8182, 0.2422, 0.8572, 0.2636]}, {"w": "model", "b": [0.1429, 0.2613, 0.1957, 0.2827]}, {"w": "will", "b": [0.2011, 0.2613, 0.2315, 0.2827]}, {"w": "end", "b": [0.2368, 0.2613, 0.2681, 0.2827]}, {"w": "up", "b": [0.2735, 0.2613, 0.2954, 0.2827]}, {"w": "being", "b": [0.3008, 0.2613, 0.347, 0.2827]}, {"w": "imprecise.", "b": [0.3524, 0.2613, 0.4378, 0.2827]}, {"w": "The", "b": [0.4431, 0.2613, 0.476, 0.2827]}, {"w": "mean", "b": [0.4814, 0.2613, 0.5278, 0.2827]}, {"w": "absolute", "b": [0.5332, 0.2613, 0.6027, 0.2827]}, {"w": "error", "b": [0.6081, 0.2613, 0.6508, 0.2827]}, {"w": "would", "b": [0.6562, 0.2613, 0.7084, 0.2827]}, {"w": "not", "b": [0.7138, 0.2613, 0.7422, 0.2827]}, {"w": "penalize", "b": [0.7475, 0.2613, 0.8163, 0.2827]}, {"w": "out‐", "b": [0.8217, 0.2613, 0.8571, 0.2827]}, {"w": "liers", "b": [0.1429, 0.2803, 0.1779, 0.3017]}, {"w": "as", "b": [0.1861, 0.2803, 0.2029, 0.3017]}, {"w": "much,", "b": [0.211, 0.2803, 0.2634, 0.3017]}, {"w": "but", "b": [0.2715, 0.2803, 0.2995, 0.3017]}, {"w": "training", "b": [0.3076, 0.2803, 0.3746, 0.3017]}, {"w": "might", "b": [0.3827, 0.2803, 0.4322, 0.3017]}, {"w": "take", "b": [0.4403, 0.2803, 0.475, 0.3017]}, {"w": "a", "b": [0.4831, 0.2803, 0.4923, 0.3017]}, {"w": "while", "b": [0.5004, 0.2803, 0.5455, 0.3017]}, {"w": "to", "b": [0.5536, 0.2803, 0.5706, 0.3017]}, {"w": "converge", "b": [0.5787, 0.2803, 0.6539, 0.3017]}, {"w": "and", "b": [0.662, 0.2803, 0.6936, 0.3017]}, {"w": "the", "b": [0.7017, 0.2803, 0.728, 0.3017]}, {"w": "trained", "b": [0.7361, 0.2803, 0.7962, 0.3017]}, {"w": "model", "b": [0.8043, 0.2803, 0.8571, 0.3017]}, {"w": "might", "b": [0.1428, 0.2994, 0.1923, 0.3208]}, {"w": "not", "b": [0.1981, 0.2994, 0.2265, 0.3208]}, {"w": "be", "b": [0.2322, 0.2994, 0.2517, 0.3208]}, {"w": "very", "b": [0.2574, 0.2994, 0.2938, 0.3208]}, {"w": "precise.", "b": [0.2996, 0.2994, 0.3627, 0.3208]}, {"w": "This", "b": [0.3685, 0.2994, 0.4057, 0.3208]}, {"w": "is", "b": [0.4115, 0.2994, 0.4247, 0.3208]}, {"w": "probably", "b": [0.4305, 0.2994, 0.5049, 0.3208]}, {"w": "a", "b": [0.5107, 0.2994, 0.5198, 0.3208]}, {"w": "good", "b": [0.5256, 0.2994, 0.5676, 0.3208]}, {"w": "time", "b": [0.5733, 0.2994, 0.6112, 0.3208]}, {"w": "to", "b": [0.617, 0.2994, 0.6339, 0.3208]}, {"w": "use", "b": [0.6397, 0.2994, 0.6673, 0.3208]}, {"w": "the", "b": [0.673, 0.2994, 0.6994, 0.3208]}, {"w": "Huber", "b": [0.7051, 0.2994, 0.7585, 0.3208]}, {"w": "loss", "b": [0.7643, 0.2994, 0.7955, 0.3208]}, {"w": "(intro‐", "b": [0.8012, 0.2994, 0.8571, 0.3208]}, {"w": "duced", "b": [0.1429, 0.3184, 0.1936, 0.3398]}, {"w": "in", "b": [0.2002, 0.3184, 0.2172, 0.3398]}, {"w": "Chapter", "b": [0.2238, 0.3184, 0.2914, 0.3398]}, {"w": "10)", "b": [0.298, 0.3184, 0.3252, 0.3398]}, {"w": "instead", "b": [0.3319, 0.3184, 0.3918, 0.3398]}, {"w": "of", "b": [0.3985, 0.3184, 0.4153, 0.3398]}, {"w": "the", "b": [0.4219, 0.3184, 0.4482, 0.3398]}, {"w": "good", "b": [0.4549, 0.3184, 0.4969, 0.3398]}, {"w": "old", "b": [0.5035, 0.3184, 0.5304, 0.3398]}, {"w": "MSE.", "b": [0.537, 0.3184, 0.582, 0.3398]}, {"w": "The", "b": [0.5886, 0.3184, 0.6215, 0.3398]}, {"w": "Huber", "b": [0.6281, 0.3184, 0.6815, 0.3398]}, {"w": "loss", "b": [0.6881, 0.3184, 0.7193, 0.3398]}, {"w": "is", "b": [0.7259, 0.3184, 0.7391, 0.3398]}, {"w": "not", "b": [0.7458, 0.3184, 0.7741, 0.3398]}, {"w": "currently", "b": [0.7808, 0.3184, 0.8572, 0.3398]}, {"w": "part", "b": [0.1429, 0.3375, 0.177, 0.3589]}, {"w": "of", "b": [0.1825, 0.3375, 0.1993, 0.3589]}, {"w": "the", "b": [0.2048, 0.3375, 0.2311, 0.3589]}, {"w": "official", "b": [0.2366, 0.3375, 0.294, 0.3589]}, {"w": "Keras", "b": [0.2995, 0.3375, 0.3463, 0.3589]}, {"w": "API,", "b": [0.3518, 0.3375, 0.3898, 0.3589]}, {"w": "but", "b": [0.3953, 0.3375, 0.4233, 0.3589]}, {"w": "it", "b": [0.4288, 0.3375, 0.4407, 0.3589]}, {"w": "is", "b": [0.4462, 0.3375, 0.4595, 0.3589]}, {"w": "available", "b": [0.465, 0.3375, 0.5372, 0.3589]}, {"w": "in", "b": [0.5427, 0.3375, 0.5597, 0.3589]}, {"w": "tf.keras", "b": [0.5652, 0.3375, 0.6262, 0.3589]}, {"w": "(just", "b": [0.6317, 0.3375, 0.6693, 0.3589]}, {"w": "use", "b": [0.6748, 0.3375, 0.7023, 0.3589]}, {"w": "an", "b": [0.7078, 0.3375, 0.7284, 0.3589]}, {"w": "instance", "b": [0.7338, 0.3375, 0.803, 0.3589]}, {"w": "of", "b": [0.8085, 0.3375, 0.8253, 0.3589]}, {"w": "the", "b": [0.8308, 0.3375, 0.8571, 0.3589]}, {"w": "keras.losses.Huber", "b": [0.1429, 0.3606, 0.321, 0.3757]}, {"w": "class).", "b": [0.3267, 0.3574, 0.3772, 0.3788]}, {"w": "But", "b": [0.3829, 0.3574, 0.4126, 0.3788]}, {"w": "let’s", "b": [0.4183, 0.3574, 0.4485, 0.3788]}, {"w": "pretend", "b": [0.4542, 0.3574, 0.5193, 0.3788]}, {"w": "it’s", "b": [0.525, 0.3574, 0.5467, 0.3788]}, {"w": "not", "b": [0.5524, 0.3574, 0.5808, 0.3788]}, {"w": "there:", "b": [0.5865, 0.3574, 0.6342, 0.3788]}, {"w": "implementing", "b": [0.6399, 0.3574, 0.7572, 0.3788]}, {"w": "it", "b": [0.7629, 0.3574, 0.7748, 0.3788]}, {"w": "is", "b": [0.7805, 0.3574, 0.7937, 0.3788]}, {"w": "easy", "b": [0.7994, 0.3574, 0.8346, 0.3788]}, {"w": "as", "b": [0.8404, 0.3574, 0.8571, 0.3788]}, {"w": "pie!", "b": [0.1429, 0.3765, 0.174, 0.3979]}, {"w": "Just", "b": [0.1796, 0.3765, 0.2108, 0.3979]}, {"w": "create", "b": [0.2165, 0.3765, 0.2658, 0.3979]}, {"w": "a", "b": [0.2714, 0.3765, 0.2806, 0.3979]}, {"w": "function", "b": [0.2862, 0.3765, 0.3576, 0.3979]}, {"w": "that", "b": [0.3632, 0.3765, 0.3958, 0.3979]}, {"w": "takes", "b": [0.4014, 0.3765, 0.4438, 0.3979]}, {"w": "the", "b": [0.4494, 0.3765, 0.4757, 0.3979]}, {"w": "labels", "b": [0.4813, 0.3765, 0.5281, 0.3979]}, {"w": "and", "b": [0.5337, 0.3765, 0.5653, 0.3979]}, {"w": "predictions", "b": [0.5709, 0.3765, 0.6654, 0.3979]}, {"w": "as", "b": [0.671, 0.3765, 0.6878, 0.3979]}, {"w": "arguments,", "b": [0.6934, 0.3765, 0.7868, 0.3979]}, {"w": "and", "b": [0.7924, 0.3765, 0.824, 0.3979]}, {"w": "use", "b": [0.8296, 0.3765, 0.8571, 0.3979]}, {"w": "TensorFlow", "b": [0.1429, 0.3955, 0.2411, 0.4169]}, {"w": "operations", "b": [0.2458, 0.3955, 0.3343, 0.4169]}, {"w": "to", "b": [0.339, 0.3955, 0.356, 0.4169]}, {"w": "compute", "b": [0.3607, 0.3955, 0.434, 0.4169]}, {"w": "every", "b": [0.4388, 0.3955, 0.484, 0.4169]}, {"w": "instance’s", "b": [0.4887, 0.3955, 0.567, 0.4169]}, {"w": "loss:", "b": [0.5718, 0.3955, 0.6077, 0.4169]}]}, {"id": "b_4", "type": "paragraph", "text": "def huber_fn(y_true, y_pred): error = y_true - y_pred is_small_error = tf.abs(error) < 1 squared_loss = tf.square(error) / 2 linear_loss = tf.abs(error) - 0.5 return tf.where(is_small_error, squared_loss, linear_loss)", "words": [{"w": "def", "b": [0.1766, 0.4275, 0.2019, 0.4403]}, {"w": "huber_fn(y_true,", "b": [0.2103, 0.4275, 0.3452, 0.4403]}, {"w": "y_pred):", "b": [0.3537, 0.4275, 0.4211, 0.4403]}, {"w": "error", "b": [0.2103, 0.4429, 0.2525, 0.4557]}, {"w": "=", "b": [0.2609, 0.4429, 0.2693, 0.4557]}, {"w": "y_true", "b": [0.2778, 0.4429, 0.3284, 0.4557]}, {"w": "-", "b": [0.3368, 0.4429, 0.3452, 0.4557]}, {"w": "y_pred", "b": [0.3537, 0.4429, 0.4043, 0.4557]}, {"w": "is_small_error", "b": [0.2103, 0.4583, 0.3284, 0.4712]}, {"w": "=", "b": [0.3368, 0.4583, 0.3452, 0.4712]}, {"w": "tf.abs(error)", "b": [0.3537, 0.4583, 0.4633, 0.4712]}, {"w": "<", "b": [0.4717, 0.4583, 0.4802, 0.4712]}, {"w": "1", "b": [0.4886, 0.4583, 0.497, 0.4712]}, {"w": "squared_loss", "b": [0.2103, 0.4737, 0.3115, 0.4866]}, {"w": "=", "b": [0.3199, 0.4737, 0.3284, 0.4866]}, {"w": "tf.square(error)", "b": [0.3368, 0.4737, 0.4717, 0.4866]}, {"w": "/", "b": [0.4802, 0.4737, 0.4886, 0.4866]}, {"w": "2", "b": [0.497, 0.4737, 0.5055, 0.4866]}, {"w": "linear_loss", "b": [0.2103, 0.4892, 0.3031, 0.502]}, {"w": "=", "b": [0.3199, 0.4892, 0.3284, 0.502]}, {"w": "tf.abs(error)", "b": [0.3368, 0.4892, 0.4464, 0.502]}, {"w": "-", "b": [0.4549, 0.4892, 0.4633, 0.502]}, {"w": "0.5", "b": [0.4717, 0.4892, 0.497, 0.502]}, {"w": "return", "b": [0.2103, 0.5046, 0.2609, 0.5174]}, {"w": "tf.where(is_small_error,", "b": [0.2693, 0.5046, 0.4717, 0.5174]}, {"w": "squared_loss,", "b": [0.4802, 0.5046, 0.5898, 0.5174]}, {"w": "linear_loss)", "b": [0.5982, 0.5046, 0.6994, 0.5174]}]}, {"id": "b_5", "type": "paragraph", "text": "For better performance, you should use a vectorized implementa‐ tion, as in this example. Moreover, if you want to benefit from Ten‐ sorFlow’s graph features, you should use only TensorFlow operations.", "words": [{"w": "For", "b": [0.2714, 0.539, 0.2979, 0.5586]}, {"w": "better", "b": [0.3042, 0.539, 0.3487, 0.5586]}, {"w": "performance,", "b": [0.355, 0.539, 0.4574, 0.5586]}, {"w": "you", "b": [0.4637, 0.539, 0.4922, 0.5586]}, {"w": "should", "b": [0.4985, 0.539, 0.5504, 0.5586]}, {"w": "use", "b": [0.5566, 0.539, 0.5818, 0.5586]}, {"w": "a", "b": [0.5881, 0.539, 0.5964, 0.5586]}, {"w": "vectorized", "b": [0.6027, 0.539, 0.6815, 0.5586]}, {"w": "implementa‐", "b": [0.6878, 0.539, 0.7857, 0.5586]}, {"w": "tion,", "b": [0.2714, 0.5564, 0.3068, 0.576]}, {"w": "as", "b": [0.3114, 0.5564, 0.3268, 0.576]}, {"w": "in", "b": [0.3314, 0.5564, 0.347, 0.576]}, {"w": "this", "b": [0.3516, 0.5564, 0.3797, 0.576]}, {"w": "example.", "b": [0.3843, 0.5564, 0.4522, 0.576]}, {"w": "Moreover,", "b": [0.4569, 0.5564, 0.5351, 0.576]}, {"w": "if", "b": [0.5397, 0.5564, 0.5505, 0.576]}, {"w": "you", "b": [0.5551, 0.5564, 0.5837, 0.576]}, {"w": "want", "b": [0.5883, 0.5564, 0.6256, 0.576]}, {"w": "to", "b": [0.6302, 0.5564, 0.6457, 0.576]}, {"w": "benefit", "b": [0.6504, 0.5564, 0.7032, 0.576]}, {"w": "from", "b": [0.7079, 0.5564, 0.7459, 0.576]}, {"w": "Ten‐", "b": [0.7505, 0.5564, 0.7857, 0.576]}, {"w": "sorFlow’s", "b": [0.2714, 0.5739, 0.3423, 0.5934]}, {"w": "graph", "b": [0.3574, 0.5739, 0.4015, 0.5934]}, {"w": "features,", "b": [0.4167, 0.5739, 0.4808, 0.5934]}, {"w": "you", "b": [0.496, 0.5739, 0.5245, 0.5934]}, {"w": "should", "b": [0.5397, 0.5739, 0.5916, 0.5934]}, {"w": "use", "b": [0.6067, 0.5739, 0.6319, 0.5934]}, {"w": "only", "b": [0.647, 0.5739, 0.6807, 0.5934]}, {"w": "TensorFlow", "b": [0.6959, 0.5739, 0.7857, 0.5934]}, {"w": "operations.", "b": [0.2714, 0.5913, 0.3566, 0.6109]}]}, {"id": "b_6", "type": "paragraph", "text": "It is also preferable to return a tensor containing one loss per instance, rather than returning the mean loss. This way, Keras can apply class weights or sample weights when requested (see Chapter 10).", "words": [{"w": "It", "b": [0.1429, 0.6377, 0.1555, 0.6591]}, {"w": "is", "b": [0.1625, 0.6377, 0.1757, 0.6591]}, {"w": "also", "b": [0.1827, 0.6377, 0.2154, 0.6591]}, {"w": "preferable", "b": [0.2224, 0.6377, 0.3065, 0.6591]}, {"w": "to", "b": [0.3135, 0.6377, 0.3305, 0.6591]}, {"w": "return", "b": [0.3375, 0.6377, 0.3906, 0.6591]}, {"w": "a", "b": [0.3976, 0.6377, 0.4068, 0.6591]}, {"w": "tensor", "b": [0.4138, 0.6377, 0.4664, 0.6591]}, {"w": "containing", "b": [0.4734, 0.6377, 0.563, 0.6591]}, {"w": "one", "b": [0.5701, 0.6377, 0.6009, 0.6591]}, {"w": "loss", "b": [0.6079, 0.6377, 0.6391, 0.6591]}, {"w": "per", "b": [0.6461, 0.6377, 0.6736, 0.6591]}, {"w": "instance,", "b": [0.6806, 0.6377, 0.7546, 0.6591]}, {"w": "rather", "b": [0.7616, 0.6377, 0.8121, 0.6591]}, {"w": "than", "b": [0.8191, 0.6377, 0.8571, 0.6591]}, {"w": "returning", "b": [0.1429, 0.6567, 0.2227, 0.6781]}, {"w": "the", "b": [0.2296, 0.6567, 0.2559, 0.6781]}, {"w": "mean", "b": [0.2628, 0.6567, 0.3092, 0.6781]}, {"w": "loss.", "b": [0.3161, 0.6567, 0.352, 0.6781]}, {"w": "This", "b": [0.3589, 0.6567, 0.3961, 0.6781]}, {"w": "way,", "b": [0.403, 0.6567, 0.4388, 0.6781]}, {"w": "Keras", "b": [0.4457, 0.6567, 0.4926, 0.6781]}, {"w": "can", "b": [0.4994, 0.6567, 0.5288, 0.6781]}, {"w": "apply", "b": [0.5357, 0.6567, 0.5811, 0.6781]}, {"w": "class", "b": [0.5879, 0.6567, 0.6265, 0.6781]}, {"w": "weights", "b": [0.6333, 0.6567, 0.6965, 0.6781]}, {"w": "or", "b": [0.7034, 0.6567, 0.7217, 0.6781]}, {"w": "sample", "b": [0.7286, 0.6567, 0.7871, 0.6781]}, {"w": "weights", "b": [0.794, 0.6567, 0.8572, 0.6781]}, {"w": "when", "b": [0.1429, 0.6758, 0.1885, 0.6972]}, {"w": "requested", "b": [0.1932, 0.6758, 0.2742, 0.6972]}, {"w": "(see", "b": [0.279, 0.6758, 0.3115, 0.6972]}, {"w": "Chapter", "b": [0.3163, 0.6758, 0.3838, 0.6972]}, {"w": "10).", "b": [0.3886, 0.6758, 0.4205, 0.6972]}]}, {"id": "b_7", "type": "paragraph", "text": "Next, you can just use this loss when you compile the Keras model, then train your model:", "words": [{"w": "Next,", "b": [0.1429, 0.7039, 0.1876, 0.7253]}, {"w": "you", "b": [0.1941, 0.7039, 0.2254, 0.7253]}, {"w": "can", "b": [0.2319, 0.7039, 0.2612, 0.7253]}, {"w": "just", "b": [0.2678, 0.7039, 0.2982, 0.7253]}, {"w": "use", "b": [0.3047, 0.7039, 0.3322, 0.7253]}, {"w": "this", "b": [0.3388, 0.7039, 0.3695, 0.7253]}, {"w": "loss", "b": [0.376, 0.7039, 0.4072, 0.7253]}, {"w": "when", "b": [0.4137, 0.7039, 0.4593, 0.7253]}, {"w": "you", "b": [0.4658, 0.7039, 0.4971, 0.7253]}, {"w": "compile", "b": [0.5036, 0.7039, 0.5703, 0.7253]}, {"w": "the", "b": [0.5769, 0.7039, 0.6032, 0.7253]}, {"w": "Keras", "b": [0.6097, 0.7039, 0.6566, 0.7253]}, {"w": "model,", "b": [0.6631, 0.7039, 0.7207, 0.7253]}, {"w": "then", "b": [0.7272, 0.7039, 0.7649, 0.7253]}, {"w": "train", "b": [0.7714, 0.7039, 0.8116, 0.7253]}, {"w": "your", "b": [0.8182, 0.7039, 0.8571, 0.7253]}, {"w": "model:", "b": [0.1429, 0.7229, 0.2004, 0.7444]}]}, {"id": "b_8", "type": "paragraph", "text": "model.compile(loss=huber_fn, optimizer=\"nadam\") model.fit(X_train, y_train, [...])", "words": [{"w": "model.compile(loss=huber_fn,", "b": [0.1766, 0.7549, 0.4127, 0.7678]}, {"w": "optimizer=\"nadam\")", "b": [0.4211, 0.7549, 0.5729, 0.7678]}, {"w": "model.fit(X_train,", "b": [0.1766, 0.7703, 0.3284, 0.7832]}, {"w": "y_train,", "b": [0.3368, 0.7703, 0.4043, 0.7832]}, {"w": "[...])", "b": [0.4127, 0.7703, 0.4633, 0.7832]}]}, {"id": "b_9", "type": "paragraph", "text": "And that’s it! For each batch during training, Keras will call the huber_fn() function to compute the loss, and use it to perform a Gradient Descent step. Moreover, it will keep track of the total loss since the beginning of the epoch, and it will display the mean loss.", "words": [{"w": "And", "b": [0.1429, 0.7919, 0.1796, 0.8133]}, {"w": "that’s", "b": [0.1854, 0.7919, 0.2277, 0.8133]}, {"w": "it!", "b": [0.2334, 0.7919, 0.2511, 0.8133]}, {"w": "For", "b": [0.2568, 0.7919, 0.2858, 0.8133]}, {"w": "each", "b": [0.2915, 0.7919, 0.3294, 0.8133]}, {"w": "batch", "b": [0.3351, 0.7919, 0.3808, 0.8133]}, {"w": "during", "b": [0.3865, 0.7919, 0.443, 0.8133]}, {"w": "training,", "b": [0.4487, 0.7919, 0.5204, 0.8133]}, {"w": "Keras", "b": [0.5261, 0.7919, 0.573, 0.8133]}, {"w": "will", "b": [0.5787, 0.7919, 0.6091, 0.8133]}, {"w": "call", "b": [0.6148, 0.7919, 0.6433, 0.8133]}, {"w": "the", "b": [0.649, 0.7919, 0.6754, 0.8133]}, {"w": "huber_fn()", "b": [0.6811, 0.795, 0.78, 0.8101]}, {"w": "function", "b": [0.7857, 0.7919, 0.8571, 0.8133]}, {"w": "to", "b": [0.1428, 0.8109, 0.1598, 0.8323]}, {"w": "compute", "b": [0.1657, 0.8109, 0.239, 0.8323]}, {"w": "the", "b": [0.2449, 0.8109, 0.2712, 0.8323]}, {"w": "loss,", "b": [0.2771, 0.8109, 0.3131, 0.8323]}, {"w": "and", "b": [0.3189, 0.8109, 0.3505, 0.8323]}, {"w": "use", "b": [0.3564, 0.8109, 0.3839, 0.8323]}, {"w": "it", "b": [0.3898, 0.8109, 0.4018, 0.8323]}, {"w": "to", "b": [0.4077, 0.8109, 0.4246, 0.8323]}, {"w": "perform", "b": [0.4305, 0.8109, 0.4996, 0.8323]}, {"w": "a", "b": [0.5055, 0.8109, 0.5146, 0.8323]}, {"w": "Gradient", "b": [0.5205, 0.8109, 0.5951, 0.8323]}, {"w": "Descent", "b": [0.601, 0.8109, 0.6678, 0.8323]}, {"w": "step.", "b": [0.6737, 0.8109, 0.7116, 0.8323]}, {"w": "Moreover,", "b": [0.7175, 0.8109, 0.803, 0.8323]}, {"w": "it", "b": [0.8089, 0.8109, 0.8208, 0.8323]}, {"w": "will", "b": [0.8267, 0.8109, 0.8571, 0.8323]}, {"w": "keep", "b": [0.1429, 0.83, 0.1818, 0.8514]}, {"w": "track", "b": [0.1887, 0.83, 0.2311, 0.8514]}, {"w": "of", "b": [0.238, 0.83, 0.2548, 0.8514]}, {"w": "the", "b": [0.2618, 0.83, 0.2881, 0.8514]}, {"w": "total", "b": [0.295, 0.83, 0.3328, 0.8514]}, {"w": "loss", "b": [0.3397, 0.83, 0.3709, 0.8514]}, {"w": "since", "b": [0.3778, 0.83, 0.4201, 0.8514]}, {"w": "the", "b": [0.427, 0.83, 0.4534, 0.8514]}, {"w": "beginning", "b": [0.4603, 0.83, 0.5446, 0.8514]}, {"w": "of", "b": [0.5515, 0.83, 0.5683, 0.8514]}, {"w": "the", "b": [0.5752, 0.83, 0.6016, 0.8514]}, {"w": "epoch,", "b": [0.6085, 0.83, 0.6636, 0.8514]}, {"w": "and", "b": [0.6705, 0.83, 0.702, 0.8514]}, {"w": "it", "b": [0.709, 0.83, 0.7209, 0.8514]}, {"w": "will", "b": [0.7278, 0.83, 0.7582, 0.8514]}, {"w": "display", "b": [0.7651, 0.83, 0.8239, 0.8514]}, {"w": "the", "b": [0.8308, 0.83, 0.8571, 0.8514]}, {"w": "mean", "b": [0.1429, 0.849, 0.1893, 0.8704]}, {"w": "loss.", "b": [0.194, 0.849, 0.23, 0.8704]}]}, {"id": "b_10", "type": "paragraph", "text": "376 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "376", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2746, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 403, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "But what happens to this custom loss when we save the model?", "words": [{"w": "But", "b": [0.1429, 0.0791, 0.1725, 0.1005]}, {"w": "what", "b": [0.1773, 0.0791, 0.2178, 0.1005]}, {"w": "happens", "b": [0.2225, 0.0791, 0.2921, 0.1005]}, {"w": "to", "b": [0.2968, 0.0791, 0.3138, 0.1005]}, {"w": "this", "b": [0.3185, 0.0791, 0.3492, 0.1005]}, {"w": "custom", "b": [0.354, 0.0791, 0.4155, 0.1005]}, {"w": "loss", "b": [0.4203, 0.0791, 0.4514, 0.1005]}, {"w": "when", "b": [0.4562, 0.0791, 0.5018, 0.1005]}, {"w": "we", "b": [0.5065, 0.0791, 0.5297, 0.1005]}, {"w": "save", "b": [0.5344, 0.0791, 0.5693, 0.1005]}, {"w": "the", "b": [0.574, 0.0791, 0.6004, 0.1005]}, {"w": "model?", "b": [0.6051, 0.0791, 0.6658, 0.1005]}]}, {"id": "b_1", "type": "paragraph", "text": "Saving and Loading Models That Contain Custom Components", "words": [{"w": "Saving", "b": [0.1429, 0.1132, 0.2121, 0.1418]}, {"w": "and", "b": [0.2171, 0.1132, 0.2563, 0.1418]}, {"w": "Loading", "b": [0.2613, 0.1132, 0.3445, 0.1418]}, {"w": "Models", "b": [0.3494, 0.1132, 0.4235, 0.1418]}, {"w": "That", "b": [0.4284, 0.1132, 0.4751, 0.1418]}, {"w": "Contain", "b": [0.48, 0.1132, 0.5598, 0.1418]}, {"w": "Custom", "b": [0.5648, 0.1132, 0.6421, 0.1418]}, {"w": "Components", "b": [0.647, 0.1132, 0.7765, 0.1418]}]}, {"id": "b_2", "type": "paragraph", "text": "Saving a model containing a custom loss function actually works fine, as Keras just saves the name of the function. However, whenever you load it, you need to provide a dictionary that maps the function name to the actual function. More generally, when you load a model containing custom objects, you need to map the names to the objects:", "words": [{"w": "Saving", "b": [0.1429, 0.1477, 0.1979, 0.1691]}, {"w": "a", "b": [0.2047, 0.1477, 0.2138, 0.1691]}, {"w": "model", "b": [0.2206, 0.1477, 0.2734, 0.1691]}, {"w": "containing", "b": [0.2802, 0.1477, 0.3699, 0.1691]}, {"w": "a", "b": [0.3766, 0.1477, 0.3858, 0.1691]}, {"w": "custom", "b": [0.3926, 0.1477, 0.4541, 0.1691]}, {"w": "loss", "b": [0.4609, 0.1477, 0.4921, 0.1691]}, {"w": "function", "b": [0.4989, 0.1477, 0.5703, 0.1691]}, {"w": "actually", "b": [0.5771, 0.1477, 0.6417, 0.1691]}, {"w": "works", "b": [0.6485, 0.1477, 0.6991, 0.1691]}, {"w": "fine,", "b": [0.7059, 0.1477, 0.7427, 0.1691]}, {"w": "as", "b": [0.7495, 0.1477, 0.7663, 0.1691]}, {"w": "Keras", "b": [0.7731, 0.1477, 0.8199, 0.1691]}, {"w": "just", "b": [0.8267, 0.1477, 0.8571, 0.1691]}, {"w": "saves", "b": [0.1429, 0.1668, 0.1854, 0.1882]}, {"w": "the", "b": [0.1904, 0.1668, 0.2167, 0.1882]}, {"w": "name", "b": [0.2217, 0.1668, 0.2681, 0.1882]}, {"w": "of", "b": [0.2731, 0.1668, 0.2899, 0.1882]}, {"w": "the", "b": [0.2948, 0.1668, 0.3211, 0.1882]}, {"w": "function.", "b": [0.3261, 0.1668, 0.4022, 0.1882]}, {"w": "However,", "b": [0.4072, 0.1668, 0.4861, 0.1882]}, {"w": "whenever", "b": [0.491, 0.1668, 0.5717, 0.1882]}, {"w": "you", "b": [0.5767, 0.1668, 0.6079, 0.1882]}, {"w": "load", "b": [0.6129, 0.1668, 0.6489, 0.1882]}, {"w": "it,", "b": [0.6539, 0.1668, 0.6706, 0.1882]}, {"w": "you", "b": [0.6755, 0.1668, 0.7068, 0.1882]}, {"w": "need", "b": [0.7117, 0.1668, 0.7518, 0.1882]}, {"w": "to", "b": [0.7568, 0.1668, 0.7738, 0.1882]}, {"w": "provide", "b": [0.7787, 0.1668, 0.8431, 0.1882]}, {"w": "a", "b": [0.848, 0.1668, 0.8572, 0.1882]}, {"w": "dictionary", "b": [0.1429, 0.1858, 0.2293, 0.2072]}, {"w": "that", "b": [0.2349, 0.1858, 0.2675, 0.2072]}, {"w": "maps", "b": [0.2731, 0.1858, 0.3175, 0.2072]}, {"w": "the", "b": [0.3231, 0.1858, 0.3494, 0.2072]}, {"w": "function", "b": [0.3551, 0.1858, 0.4265, 0.2072]}, {"w": "name", "b": [0.4321, 0.1858, 0.4786, 0.2072]}, {"w": "to", "b": [0.4842, 0.1858, 0.5012, 0.2072]}, {"w": "the", "b": [0.5068, 0.1858, 0.5331, 0.2072]}, {"w": "actual", "b": [0.5388, 0.1858, 0.5885, 0.2072]}, {"w": "function.", "b": [0.5942, 0.1858, 0.6703, 0.2072]}, {"w": "More", "b": [0.6759, 0.1858, 0.7212, 0.2072]}, {"w": "generally,", "b": [0.7268, 0.1858, 0.8059, 0.2072]}, {"w": "when", "b": [0.8115, 0.1858, 0.8571, 0.2072]}, {"w": "you", "b": [0.1429, 0.2048, 0.1741, 0.2263]}, {"w": "load", "b": [0.1828, 0.2048, 0.2189, 0.2263]}, {"w": "a", "b": [0.2276, 0.2048, 0.2367, 0.2263]}, {"w": "model", "b": [0.2454, 0.2048, 0.2983, 0.2263]}, {"w": "containing", "b": [0.307, 0.2048, 0.3966, 0.2263]}, {"w": "custom", "b": [0.4053, 0.2048, 0.4669, 0.2263]}, {"w": "objects,", "b": [0.4756, 0.2048, 0.5386, 0.2263]}, {"w": "you", "b": [0.5473, 0.2048, 0.5785, 0.2263]}, {"w": "need", "b": [0.5873, 0.2048, 0.6274, 0.2263]}, {"w": "to", "b": [0.6361, 0.2048, 0.6531, 0.2263]}, {"w": "map", "b": [0.6618, 0.2048, 0.6985, 0.2263]}, {"w": "the", "b": [0.7072, 0.2048, 0.7336, 0.2263]}, {"w": "names", "b": [0.7423, 0.2048, 0.7964, 0.2263]}, {"w": "to", "b": [0.8051, 0.2048, 0.8221, 0.2263]}, {"w": "the", "b": [0.8308, 0.2048, 0.8571, 0.2263]}, {"w": "objects:", "b": [0.1428, 0.2239, 0.2058, 0.2453]}]}, {"id": "b_3", "type": "paragraph", "text": "model = keras.models.load_model(\"my_model_with_a_custom_loss.h5\", custom_objects={\"huber_fn\": huber_fn})", "words": [{"w": "model", "b": [0.1766, 0.2559, 0.2187, 0.2687]}, {"w": "=", "b": [0.2272, 0.2559, 0.2356, 0.2687]}, {"w": "keras.models.load_model(\"my_model_with_a_custom_loss.h5\",", "b": [0.244, 0.2559, 0.7247, 0.2687]}, {"w": "custom_objects={\"huber_fn\":", "b": [0.4464, 0.2713, 0.6741, 0.2841]}, {"w": "huber_fn})", "b": [0.6825, 0.2713, 0.7669, 0.2841]}]}, {"id": "b_4", "type": "paragraph", "text": "With the current implementation, any error between -1 and 1 is considered “small”. But what if we want a different threshold? One solution is to create a function that creates a configured loss function:", "words": [{"w": "With", "b": [0.1429, 0.2919, 0.1853, 0.3133]}, {"w": "the", "b": [0.192, 0.2919, 0.2183, 0.3133]}, {"w": "current", "b": [0.225, 0.2919, 0.2865, 0.3133]}, {"w": "implementation,", "b": [0.2932, 0.2919, 0.4312, 0.3133]}, {"w": "any", "b": [0.4379, 0.2919, 0.4675, 0.3133]}, {"w": "error", "b": [0.4742, 0.2919, 0.5169, 0.3133]}, {"w": "between", "b": [0.5235, 0.2919, 0.5927, 0.3133]}, {"w": "-1", "b": [0.5994, 0.2919, 0.6168, 0.3133]}, {"w": "and", "b": [0.6235, 0.2919, 0.655, 0.3133]}, {"w": "1", "b": [0.6617, 0.2919, 0.6717, 0.3133]}, {"w": "is", "b": [0.6784, 0.2919, 0.6916, 0.3133]}, {"w": "considered", "b": [0.6983, 0.2919, 0.7898, 0.3133]}, {"w": "“small”.", "b": [0.7964, 0.2919, 0.8571, 0.3133]}, {"w": "But", "b": [0.1429, 0.311, 0.1725, 0.3324]}, {"w": "what", "b": [0.1794, 0.311, 0.2199, 0.3324]}, {"w": "if", "b": [0.2267, 0.311, 0.2385, 0.3324]}, {"w": "we", "b": [0.2454, 0.311, 0.2685, 0.3324]}, {"w": "want", "b": [0.2753, 0.311, 0.3161, 0.3324]}, {"w": "a", "b": [0.323, 0.311, 0.3321, 0.3324]}, {"w": "different", "b": [0.339, 0.311, 0.4107, 0.3324]}, {"w": "threshold?", "b": [0.4176, 0.311, 0.5052, 0.3324]}, {"w": "One", "b": [0.512, 0.311, 0.5479, 0.3324]}, {"w": "solution", "b": [0.5547, 0.311, 0.6233, 0.3324]}, {"w": "is", "b": [0.6301, 0.311, 0.6434, 0.3324]}, {"w": "to", "b": [0.6502, 0.311, 0.6672, 0.3324]}, {"w": "create", "b": [0.6741, 0.311, 0.7234, 0.3324]}, {"w": "a", "b": [0.7303, 0.311, 0.7394, 0.3324]}, {"w": "function", "b": [0.7463, 0.311, 0.8177, 0.3324]}, {"w": "that", "b": [0.8246, 0.311, 0.8571, 0.3324]}, {"w": "creates", "b": [0.1429, 0.33, 0.1999, 0.3514]}, {"w": "a", "b": [0.2046, 0.33, 0.2137, 0.3514]}, {"w": "configured", "b": [0.2185, 0.33, 0.3095, 0.3514]}, {"w": "loss", "b": [0.3142, 0.33, 0.3454, 0.3514]}, {"w": "function:", "b": [0.3501, 0.33, 0.4262, 0.3514]}]}, {"id": "b_5", "type": "paragraph", "text": "def create_huber(threshold=1.0): def huber_fn(y_true, y_pred): error = y_true - y_pred is_small_error = tf.abs(error) < threshold squared_loss = tf.square(error) / 2 linear_loss = threshold * tf.abs(error) - threshold**2 / 2 return tf.where(is_small_error, squared_loss, linear_loss) return huber_fn", "words": [{"w": "def", "b": [0.1766, 0.362, 0.2019, 0.3748]}, {"w": "create_huber(threshold=1.0):", "b": [0.2103, 0.362, 0.4464, 0.3748]}, {"w": "def", "b": [0.2103, 0.3774, 0.2356, 0.3903]}, {"w": "huber_fn(y_true,", "b": [0.244, 0.3774, 0.379, 0.3903]}, {"w": "y_pred):", "b": [0.3874, 0.3774, 0.4549, 0.3903]}, {"w": "error", "b": [0.244, 0.3928, 0.2862, 0.4057]}, {"w": "=", "b": [0.2946, 0.3928, 0.3031, 0.4057]}, {"w": "y_true", "b": [0.3115, 0.3928, 0.3621, 0.4057]}, {"w": "-", "b": [0.3705, 0.3928, 0.379, 0.4057]}, {"w": "y_pred", "b": [0.3874, 0.3928, 0.438, 0.4057]}, {"w": "is_small_error", "b": [0.244, 0.4083, 0.3621, 0.4211]}, {"w": "=", "b": [0.3705, 0.4083, 0.379, 0.4211]}, {"w": "tf.abs(error)", "b": [0.3874, 0.4083, 0.497, 0.4211]}, {"w": "<", "b": [0.5055, 0.4083, 0.5139, 0.4211]}, {"w": "threshold", "b": [0.5223, 0.4083, 0.5982, 0.4211]}, {"w": "squared_loss", "b": [0.244, 0.4237, 0.3452, 0.4365]}, {"w": "=", "b": [0.3537, 0.4237, 0.3621, 0.4365]}, {"w": "tf.square(error)", "b": [0.3705, 0.4237, 0.5055, 0.4365]}, {"w": "/", "b": [0.5139, 0.4237, 0.5223, 0.4365]}, {"w": "2", "b": [0.5308, 0.4237, 0.5392, 0.4365]}, {"w": "linear_loss", "b": [0.244, 0.4391, 0.3368, 0.4519]}, {"w": "=", "b": [0.3537, 0.4391, 0.3621, 0.4519]}, {"w": "threshold", "b": [0.3705, 0.4391, 0.4464, 0.4519]}, {"w": "*", "b": [0.4549, 0.4391, 0.4633, 0.4519]}, {"w": "tf.abs(error)", "b": [0.4717, 0.4391, 0.5813, 0.4519]}, {"w": "-", "b": [0.5898, 0.4391, 0.5982, 0.4519]}, {"w": "threshold**2", "b": [0.6066, 0.4391, 0.7078, 0.4519]}, {"w": "/", "b": [0.7163, 0.4391, 0.7247, 0.4519]}, {"w": "2", "b": [0.7331, 0.4391, 0.7416, 0.4519]}, {"w": "return", "b": [0.244, 0.4545, 0.2946, 0.4674]}, {"w": "tf.where(is_small_error,", "b": [0.3031, 0.4545, 0.5055, 0.4674]}, {"w": "squared_loss,", "b": [0.5139, 0.4545, 0.6235, 0.4674]}, {"w": "linear_loss)", "b": [0.6319, 0.4545, 0.7331, 0.4674]}, {"w": "return", "b": [0.2103, 0.4699, 0.2609, 0.4828]}, {"w": "huber_fn", "b": [0.2693, 0.4699, 0.3368, 0.4828]}]}, {"id": "b_6", "type": "equation", "text": "model.compile(loss=create_huber(2.0), optimizer=\"nadam\")", "words": [{"w": "model.compile(loss=create_huber(2.0),", "b": [0.1766, 0.4944, 0.4886, 0.5073]}, {"w": "optimizer=\"nadam\")", "b": [0.497, 0.4944, 0.6488, 0.5073]}]}, {"id": "b_7", "type": "paragraph", "text": "Unfortunately, when you save the model, the threshold will not be saved. This means that you will have to specify the threshold value when loading the model (note that the name to use is \"huber_fn\", which is the name of the function we gave Keras, not the name of the function that created it):", "words": [{"w": "Unfortunately,", "b": [0.1429, 0.516, 0.264, 0.5374]}, {"w": "when", "b": [0.2688, 0.516, 0.3144, 0.5374]}, {"w": "you", "b": [0.3191, 0.516, 0.3504, 0.5374]}, {"w": "save", "b": [0.3551, 0.516, 0.39, 0.5374]}, {"w": "the", "b": [0.3948, 0.516, 0.4211, 0.5374]}, {"w": "model,", "b": [0.4258, 0.516, 0.4834, 0.5374]}, {"w": "the", "b": [0.4881, 0.516, 0.5145, 0.5374]}, {"w": "threshold", "b": [0.5194, 0.5191, 0.6084, 0.5342]}, {"w": "will", "b": [0.6132, 0.516, 0.6436, 0.5374]}, {"w": "not", "b": [0.6483, 0.516, 0.6767, 0.5374]}, {"w": "be", "b": [0.6814, 0.516, 0.7008, 0.5374]}, {"w": "saved.", "b": [0.7056, 0.516, 0.7562, 0.5374]}, {"w": "This", "b": [0.761, 0.516, 0.7982, 0.5374]}, {"w": "means", "b": [0.8029, 0.516, 0.857, 0.5374]}, {"w": "that", "b": [0.1429, 0.5359, 0.1754, 0.5573]}, {"w": "you", "b": [0.1814, 0.5359, 0.2126, 0.5573]}, {"w": "will", "b": [0.2185, 0.5359, 0.2489, 0.5573]}, {"w": "have", "b": [0.2548, 0.5359, 0.2932, 0.5573]}, {"w": "to", "b": [0.2992, 0.5359, 0.3161, 0.5573]}, {"w": "specify", "b": [0.3221, 0.5359, 0.3799, 0.5573]}, {"w": "the", "b": [0.3859, 0.5359, 0.4122, 0.5573]}, {"w": "threshold", "b": [0.4181, 0.5391, 0.5072, 0.5542]}, {"w": "value", "b": [0.5131, 0.5359, 0.5571, 0.5573]}, {"w": "when", "b": [0.563, 0.5359, 0.6086, 0.5573]}, {"w": "loading", "b": [0.6145, 0.5359, 0.6773, 0.5573]}, {"w": "the", "b": [0.6832, 0.5359, 0.7096, 0.5573]}, {"w": "model", "b": [0.7155, 0.5359, 0.7683, 0.5573]}, {"w": "(note", "b": [0.7742, 0.5359, 0.8186, 0.5573]}, {"w": "that", "b": [0.8246, 0.5359, 0.8571, 0.5573]}, {"w": "the", "b": [0.1429, 0.5558, 0.1692, 0.5773]}, {"w": "name", "b": [0.1747, 0.5558, 0.2212, 0.5773]}, {"w": "to", "b": [0.2267, 0.5558, 0.2437, 0.5773]}, {"w": "use", "b": [0.2492, 0.5558, 0.2768, 0.5773]}, {"w": "is", "b": [0.2823, 0.5558, 0.2955, 0.5773]}, {"w": "\"huber_fn\",", "b": [0.301, 0.5558, 0.4048, 0.5773]}, {"w": "which", "b": [0.4103, 0.5558, 0.4612, 0.5773]}, {"w": "is", "b": [0.4667, 0.5558, 0.4799, 0.5773]}, {"w": "the", "b": [0.4855, 0.5558, 0.5118, 0.5773]}, {"w": "name", "b": [0.5173, 0.5558, 0.5638, 0.5773]}, {"w": "of", "b": [0.5693, 0.5558, 0.5861, 0.5773]}, {"w": "the", "b": [0.5916, 0.5558, 0.618, 0.5773]}, {"w": "function", "b": [0.6235, 0.5558, 0.6949, 0.5773]}, {"w": "we", "b": [0.7004, 0.5558, 0.7235, 0.5773]}, {"w": "gave", "b": [0.7291, 0.5558, 0.7661, 0.5773]}, {"w": "Keras,", "b": [0.7716, 0.5558, 0.8232, 0.5773]}, {"w": "not", "b": [0.8288, 0.5558, 0.8571, 0.5773]}, {"w": "the", "b": [0.1429, 0.5749, 0.1692, 0.5963]}, {"w": "name", "b": [0.1739, 0.5749, 0.2204, 0.5963]}, {"w": "of", "b": [0.2251, 0.5749, 0.2419, 0.5963]}, {"w": "the", "b": [0.2466, 0.5749, 0.273, 0.5963]}, {"w": "function", "b": [0.2777, 0.5749, 0.3491, 0.5963]}, {"w": "that", "b": [0.3538, 0.5749, 0.3864, 0.5963]}, {"w": "created", "b": [0.3911, 0.5749, 0.4515, 0.5963]}, {"w": "it):", "b": [0.4562, 0.5749, 0.4801, 0.5963]}]}, {"id": "b_8", "type": "paragraph", "text": "model = keras.models.load_model(\"my_model_with_a_custom_loss_threshold_2.h5\", custom_objects={\"huber_fn\": create_huber(2.0)})", "words": [{"w": "model", "b": [0.1766, 0.6069, 0.2187, 0.6197]}, {"w": "=", "b": [0.2272, 0.6069, 0.2356, 0.6197]}, {"w": "keras.models.load_model(\"my_model_with_a_custom_loss_threshold_2.h5\",", "b": [0.244, 0.6069, 0.8259, 0.6197]}, {"w": "custom_objects={\"huber_fn\":", "b": [0.4464, 0.6223, 0.6741, 0.6351]}, {"w": "create_huber(2.0)})", "b": [0.6825, 0.6223, 0.8428, 0.6351]}]}, {"id": "b_9", "type": "paragraph", "text": "You can solve this by creating a subclass of the keras.losses.Loss class, and imple‐ ment its get_config() method:", "words": [{"w": "You", "b": [0.1429, 0.6438, 0.1752, 0.6652]}, {"w": "can", "b": [0.181, 0.6438, 0.2103, 0.6652]}, {"w": "solve", "b": [0.216, 0.6438, 0.2581, 0.6652]}, {"w": "this", "b": [0.2638, 0.6438, 0.2945, 0.6652]}, {"w": "by", "b": [0.3003, 0.6438, 0.3204, 0.6652]}, {"w": "creating", "b": [0.3262, 0.6438, 0.3934, 0.6652]}, {"w": "a", "b": [0.3991, 0.6438, 0.4083, 0.6652]}, {"w": "subclass", "b": [0.414, 0.6438, 0.4818, 0.6652]}, {"w": "of", "b": [0.4876, 0.6438, 0.5044, 0.6652]}, {"w": "the", "b": [0.5101, 0.6438, 0.5364, 0.6652]}, {"w": "keras.losses.Loss", "b": [0.5422, 0.647, 0.7104, 0.6621]}, {"w": "class,", "b": [0.7161, 0.6438, 0.7594, 0.6652]}, {"w": "and", "b": [0.7652, 0.6438, 0.7967, 0.6652]}, {"w": "imple‐", "b": [0.8024, 0.6438, 0.8571, 0.6652]}, {"w": "ment", "b": [0.1428, 0.6638, 0.1861, 0.6852]}, {"w": "its", "b": [0.1908, 0.6638, 0.2104, 0.6852]}, {"w": "get_config()", "b": [0.2152, 0.6669, 0.3339, 0.682]}, {"w": "method:", "b": [0.3386, 0.6638, 0.4084, 0.6852]}]}, {"id": "b_10", "type": "paragraph", "text": "class HuberLoss(keras.losses.Loss): def __init__(self, threshold=1.0, **kwargs): self.threshold = threshold super().__init__(**kwargs) def call(self, y_true, y_pred): error = y_true - y_pred is_small_error = tf.abs(error) < self.threshold squared_loss = tf.square(error) / 2 linear_loss = self.threshold * tf.abs(error) - self.threshold**2 / 2 return tf.where(is_small_error, squared_loss, linear_loss) def get_config(self): base_config = super().get_config() return {**base_config, \"threshold\": self.threshold}", "words": [{"w": "class", "b": [0.1766, 0.6957, 0.2187, 0.7086]}, {"w": "HuberLoss(keras.losses.Loss):", "b": [0.2272, 0.6957, 0.4717, 0.7086]}, {"w": "def", "b": [0.2103, 0.7111, 0.2356, 0.724]}, {"w": "__init__(self,", "b": [0.244, 0.7111, 0.3621, 0.724]}, {"w": "threshold=1.0,", "b": [0.3705, 0.7111, 0.4886, 0.724]}, {"w": "**kwargs):", "b": [0.497, 0.7111, 0.5813, 0.724]}, {"w": "self.threshold", "b": [0.244, 0.7266, 0.3621, 0.7394]}, {"w": "=", "b": [0.3705, 0.7266, 0.379, 0.7394]}, {"w": "threshold", "b": [0.3874, 0.7266, 0.4633, 0.7394]}, {"w": "super().__init__(**kwargs)", "b": [0.244, 0.742, 0.4633, 0.7548]}, {"w": "def", "b": [0.2103, 0.7574, 0.2356, 0.7703]}, {"w": "call(self,", "b": [0.244, 0.7574, 0.3284, 0.7703]}, {"w": "y_true,", "b": [0.3368, 0.7574, 0.3958, 0.7703]}, {"w": "y_pred):", "b": [0.4043, 0.7574, 0.4717, 0.7703]}, {"w": "error", "b": [0.244, 0.7728, 0.2862, 0.7857]}, {"w": "=", "b": [0.2946, 0.7728, 0.3031, 0.7857]}, {"w": "y_true", "b": [0.3115, 0.7728, 0.3621, 0.7857]}, {"w": "-", "b": [0.3705, 0.7728, 0.379, 0.7857]}, {"w": "y_pred", "b": [0.3874, 0.7728, 0.438, 0.7857]}, {"w": "is_small_error", "b": [0.244, 0.7882, 0.3621, 0.8011]}, {"w": "=", "b": [0.3705, 0.7882, 0.379, 0.8011]}, {"w": "tf.abs(error)", "b": [0.3874, 0.7882, 0.497, 0.8011]}, {"w": "<", "b": [0.5055, 0.7882, 0.5139, 0.8011]}, {"w": "self.threshold", "b": [0.5223, 0.7882, 0.6404, 0.8011]}, {"w": "squared_loss", "b": [0.244, 0.8037, 0.3452, 0.8165]}, {"w": "=", "b": [0.3537, 0.8037, 0.3621, 0.8165]}, {"w": "tf.square(error)", "b": [0.3705, 0.8037, 0.5055, 0.8165]}, {"w": "/", "b": [0.5139, 0.8037, 0.5223, 0.8165]}, {"w": "2", "b": [0.5308, 0.8037, 0.5392, 0.8165]}, {"w": "linear_loss", "b": [0.244, 0.8191, 0.3368, 0.8319]}, {"w": "=", "b": [0.3537, 0.8191, 0.3621, 0.8319]}, {"w": "self.threshold", "b": [0.3705, 0.8191, 0.4886, 0.8319]}, {"w": "*", "b": [0.497, 0.8191, 0.5055, 0.8319]}, {"w": "tf.abs(error)", "b": [0.5139, 0.8191, 0.6235, 0.8319]}, {"w": "-", "b": [0.6319, 0.8191, 0.6404, 0.8319]}, {"w": "self.threshold**2", "b": [0.6488, 0.8191, 0.7922, 0.8319]}, {"w": "/", "b": [0.8006, 0.8191, 0.809, 0.8319]}, {"w": "2", "b": [0.8175, 0.8191, 0.8259, 0.8319]}, {"w": "return", "b": [0.244, 0.8345, 0.2946, 0.8474]}, {"w": "tf.where(is_small_error,", "b": [0.3031, 0.8345, 0.5055, 0.8474]}, {"w": "squared_loss,", "b": [0.5139, 0.8345, 0.6235, 0.8474]}, {"w": "linear_loss)", "b": [0.6319, 0.8345, 0.7331, 0.8474]}, {"w": "def", "b": [0.2103, 0.8499, 0.2356, 0.8628]}, {"w": "get_config(self):", "b": [0.244, 0.8499, 0.3874, 0.8628]}, {"w": "base_config", "b": [0.244, 0.8653, 0.3368, 0.8782]}, {"w": "=", "b": [0.3452, 0.8653, 0.3537, 0.8782]}, {"w": "super().get_config()", "b": [0.3621, 0.8653, 0.5308, 0.8782]}, {"w": "return", "b": [0.244, 0.8808, 0.2946, 0.8936]}, {"w": "{**base_config,", "b": [0.3031, 0.8808, 0.4296, 0.8936]}, {"w": "\"threshold\":", "b": [0.438, 0.8808, 0.5392, 0.8936]}, {"w": "self.threshold}", "b": [0.5476, 0.8808, 0.6741, 0.8936]}]}, {"id": "b_11", "type": "paragraph", "text": "Customizing Models and Training Algorithms | 377", "words": [{"w": "Customizing", "b": [0.5328, 0.9225, 0.6056, 0.9388]}, {"w": "Models", "b": [0.6084, 0.9225, 0.6507, 0.9388]}, {"w": "and", "b": [0.6535, 0.9225, 0.6759, 0.9388]}, {"w": "Training", "b": [0.6787, 0.9225, 0.7278, 0.9388]}, {"w": "Algorithms", "b": [0.7306, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "377", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 404, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "5 It would not be a good idea to use a weighted mean: if we did, then two instances with the same weight but in different batches would have a different impact on training, depending on the total weight of each batch.", "words": [{"w": "5", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "It", "b": [0.1587, 0.8598, 0.1684, 0.8761]}, {"w": "would", "b": [0.172, 0.8598, 0.2118, 0.8761]}, {"w": "not", "b": [0.2154, 0.8598, 0.237, 0.8761]}, {"w": "be", "b": [0.2406, 0.8598, 0.2554, 0.8761]}, {"w": "a", "b": [0.259, 0.8598, 0.266, 0.8761]}, {"w": "good", "b": [0.2696, 0.8598, 0.3016, 0.8761]}, {"w": "idea", "b": [0.3052, 0.8598, 0.3315, 0.8761]}, {"w": "to", "b": [0.3351, 0.8598, 0.3481, 0.8761]}, {"w": "use", "b": [0.3517, 0.8598, 0.3727, 0.8761]}, {"w": "a", "b": [0.3763, 0.8598, 0.3832, 0.8761]}, {"w": "weighted", "b": [0.3868, 0.8598, 0.4443, 0.8761]}, {"w": "mean:", "b": [0.4479, 0.8598, 0.4869, 0.8761]}, {"w": "if", "b": [0.4905, 0.8598, 0.4995, 0.8761]}, {"w": "we", "b": [0.5031, 0.8598, 0.5207, 0.8761]}, {"w": "did,", "b": [0.5243, 0.8598, 0.5489, 0.8761]}, {"w": "then", "b": [0.5525, 0.8598, 0.5813, 0.8761]}, {"w": "two", "b": [0.5849, 0.8598, 0.6087, 0.8761]}, {"w": "instances", "b": [0.6123, 0.8598, 0.6708, 0.8761]}, {"w": "with", "b": [0.6744, 0.8598, 0.7029, 0.8761]}, {"w": "the", "b": [0.7065, 0.8598, 0.7265, 0.8761]}, {"w": "same", "b": [0.7301, 0.8598, 0.7627, 0.8761]}, {"w": "weight", "b": [0.7663, 0.8598, 0.8086, 0.8761]}, {"w": "but", "b": [0.8122, 0.8598, 0.8335, 0.8761]}, {"w": "in", "b": [0.8371, 0.8598, 0.8501, 0.8761]}, {"w": "different", "b": [0.1587, 0.8749, 0.2134, 0.8912]}, {"w": "batches", "b": [0.217, 0.8749, 0.2643, 0.8912]}, {"w": "would", "b": [0.2679, 0.8749, 0.3077, 0.8912]}, {"w": "have", "b": [0.3113, 0.8749, 0.3406, 0.8912]}, {"w": "a", "b": [0.3442, 0.8749, 0.3511, 0.8912]}, {"w": "different", "b": [0.3547, 0.8749, 0.4094, 0.8912]}, {"w": "impact", "b": [0.413, 0.8749, 0.4568, 0.8912]}, {"w": "on", "b": [0.4604, 0.8749, 0.4771, 0.8912]}, {"w": "training,", "b": [0.4807, 0.8749, 0.5354, 0.8912]}, {"w": "depending", "b": [0.539, 0.8749, 0.6066, 0.8912]}, {"w": "on", "b": [0.6102, 0.8749, 0.627, 0.8912]}, {"w": "the", "b": [0.6306, 0.8749, 0.6506, 0.8912]}, {"w": "total", "b": [0.6542, 0.8749, 0.683, 0.8912]}, {"w": "weight", "b": [0.6866, 0.8749, 0.7289, 0.8912]}, {"w": "of", "b": [0.7325, 0.8749, 0.7453, 0.8912]}, {"w": "each", "b": [0.7489, 0.8749, 0.7778, 0.8912]}, {"w": "batch.", "b": [0.7814, 0.8749, 0.8198, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "The Keras API only specifies how to use subclassing to define lay‐ ers, models, callbacks, and regularizers. If you build other compo‐ nents (such as losses, metrics, initializers or constraints) using subclassing, they may not be portable to other Keras implementa‐ tions.", "words": [{"w": "The", "b": [0.2714, 0.0793, 0.3014, 0.0989]}, {"w": "Keras", "b": [0.3071, 0.0793, 0.3499, 0.0989]}, {"w": "API", "b": [0.3556, 0.0793, 0.3859, 0.0989]}, {"w": "only", "b": [0.3916, 0.0793, 0.4253, 0.0989]}, {"w": "specifies", "b": [0.4309, 0.0793, 0.4949, 0.0989]}, {"w": "how", "b": [0.5006, 0.0793, 0.5335, 0.0989]}, {"w": "to", "b": [0.5391, 0.0793, 0.5547, 0.0989]}, {"w": "use", "b": [0.5603, 0.0793, 0.5855, 0.0989]}, {"w": "subclassing", "b": [0.5911, 0.0793, 0.6775, 0.0989]}, {"w": "to", "b": [0.6832, 0.0793, 0.6987, 0.0989]}, {"w": "define", "b": [0.7043, 0.0793, 0.7517, 0.0989]}, {"w": "lay‐", "b": [0.7574, 0.0793, 0.7857, 0.0989]}, {"w": "ers,", "b": [0.2714, 0.0967, 0.2979, 0.1163]}, {"w": "models,", "b": [0.3036, 0.0967, 0.3633, 0.1163]}, {"w": "callbacks,", "b": [0.369, 0.0967, 0.4419, 0.1163]}, {"w": "and", "b": [0.4476, 0.0967, 0.4765, 0.1163]}, {"w": "regularizers.", "b": [0.4822, 0.0967, 0.5763, 0.1163]}, {"w": "If", "b": [0.582, 0.0967, 0.5941, 0.1163]}, {"w": "you", "b": [0.5998, 0.0967, 0.6284, 0.1163]}, {"w": "build", "b": [0.6341, 0.0967, 0.6739, 0.1163]}, {"w": "other", "b": [0.6796, 0.0967, 0.7205, 0.1163]}, {"w": "compo‐", "b": [0.7262, 0.0967, 0.7857, 0.1163]}, {"w": "nents", "b": [0.2714, 0.1141, 0.3128, 0.1337]}, {"w": "(such", "b": [0.3225, 0.1141, 0.3644, 0.1337]}, {"w": "as", "b": [0.374, 0.1141, 0.3894, 0.1337]}, {"w": "losses,", "b": [0.3991, 0.1141, 0.447, 0.1337]}, {"w": "metrics,", "b": [0.4567, 0.1141, 0.5178, 0.1337]}, {"w": "initializers", "b": [0.5274, 0.1141, 0.6074, 0.1337]}, {"w": "or", "b": [0.6171, 0.1141, 0.6339, 0.1337]}, {"w": "constraints)", "b": [0.6435, 0.1141, 0.7345, 0.1337]}, {"w": "using", "b": [0.7442, 0.1141, 0.7857, 0.1337]}, {"w": "subclassing,", "b": [0.2714, 0.1315, 0.3622, 0.1511]}, {"w": "they", "b": [0.3682, 0.1315, 0.401, 0.1511]}, {"w": "may", "b": [0.407, 0.1315, 0.4394, 0.1511]}, {"w": "not", "b": [0.4453, 0.1315, 0.4713, 0.1511]}, {"w": "be", "b": [0.4773, 0.1315, 0.495, 0.1511]}, {"w": "portable", "b": [0.501, 0.1315, 0.5646, 0.1511]}, {"w": "to", "b": [0.5705, 0.1315, 0.5861, 0.1511]}, {"w": "other", "b": [0.5921, 0.1315, 0.6329, 0.1511]}, {"w": "Keras", "b": [0.6389, 0.1315, 0.6818, 0.1511]}, {"w": "implementa‐", "b": [0.6878, 0.1315, 0.7857, 0.1511]}, {"w": "tions.", "b": [0.2714, 0.1489, 0.3138, 0.1685]}]}, {"id": "b_2", "type": "paragraph", "text": "Let’s walk through this code:", "words": [{"w": "Let’s", "b": [0.1429, 0.1888, 0.179, 0.2102]}, {"w": "walk", "b": [0.1838, 0.1888, 0.2228, 0.2102]}, {"w": "through", "b": [0.2275, 0.1888, 0.2953, 0.2102]}, {"w": "this", "b": [0.3, 0.1888, 0.3307, 0.2102]}, {"w": "code:", "b": [0.3354, 0.1888, 0.3795, 0.2102]}]}, {"id": "b_3", "type": "paragraph", "text": "• The constructor accepts **kwargs and passes them to the parent constructor, which handles standard hyperparameters: the name of the loss and the reduction algorithm to use to aggregate the individual instance losses. By default, it is \"sum_over_batch_size\", which means that the loss will be the sum of the instance losses, possibly weighted by the sample weights, if any, and then divide the result by the batch size (not by the sum of weights, so this is not the weighted mean).5. Other possible values are \"sum\" and None.", "words": [{"w": "•", "b": [0.16, 0.2239, 0.1682, 0.2453]}, {"w": "The", "b": [0.1786, 0.2239, 0.2114, 0.2453]}, {"w": "constructor", "b": [0.2198, 0.2239, 0.317, 0.2453]}, {"w": "accepts", "b": [0.3254, 0.2239, 0.3859, 0.2453]}, {"w": "**kwargs", "b": [0.3943, 0.2271, 0.4735, 0.2421]}, {"w": "and", "b": [0.4819, 0.2239, 0.5135, 0.2453]}, {"w": "passes", "b": [0.5219, 0.2239, 0.5737, 0.2453]}, {"w": "them", "b": [0.5822, 0.2239, 0.6256, 0.2453]}, {"w": "to", "b": [0.634, 0.2239, 0.651, 0.2453]}, {"w": "the", "b": [0.6594, 0.2239, 0.6857, 0.2453]}, {"w": "parent", "b": [0.6941, 0.2239, 0.7481, 0.2453]}, {"w": "constructor,", "b": [0.7566, 0.2239, 0.8571, 0.2453]}, {"w": "which", "b": [0.1786, 0.2438, 0.2295, 0.2652]}, {"w": "handles", "b": [0.2347, 0.2438, 0.2991, 0.2652]}, {"w": "standard", "b": [0.3042, 0.2438, 0.3777, 0.2652]}, {"w": "hyperparameters:", "b": [0.3828, 0.2438, 0.5287, 0.2652]}, {"w": "the", "b": [0.5339, 0.2438, 0.5602, 0.2652]}, {"w": "name", "b": [0.5654, 0.247, 0.6049, 0.2621]}, {"w": "of", "b": [0.6101, 0.2438, 0.6269, 0.2652]}, {"w": "the", "b": [0.632, 0.2438, 0.6584, 0.2652]}, {"w": "loss", "b": [0.6635, 0.2438, 0.6947, 0.2652]}, {"w": "and", "b": [0.6999, 0.2438, 0.7314, 0.2652]}, {"w": "the", "b": [0.7366, 0.2438, 0.7629, 0.2652]}, {"w": "reduction", "b": [0.7681, 0.247, 0.8571, 0.2621]}, {"w": "algorithm", "b": [0.1786, 0.2629, 0.2612, 0.2843]}, {"w": "to", "b": [0.2706, 0.2629, 0.2876, 0.2843]}, {"w": "use", "b": [0.297, 0.2629, 0.3246, 0.2843]}, {"w": "to", "b": [0.334, 0.2629, 0.351, 0.2843]}, {"w": "aggregate", "b": [0.3604, 0.2629, 0.4394, 0.2843]}, {"w": "the", "b": [0.4488, 0.2629, 0.4751, 0.2843]}, {"w": "individual", "b": [0.4845, 0.2629, 0.5698, 0.2843]}, {"w": "instance", "b": [0.5792, 0.2629, 0.6484, 0.2843]}, {"w": "losses.", "b": [0.6578, 0.2629, 0.7103, 0.2843]}, {"w": "By", "b": [0.7197, 0.2629, 0.7415, 0.2843]}, {"w": "default,", "b": [0.7509, 0.2629, 0.8131, 0.2843]}, {"w": "it", "b": [0.8226, 0.2629, 0.8345, 0.2843]}, {"w": "is", "b": [0.8439, 0.2629, 0.8571, 0.2843]}, {"w": "\"sum_over_batch_size\",", "b": [0.1786, 0.2828, 0.3911, 0.3042]}, {"w": "which", "b": [0.4017, 0.2828, 0.4526, 0.3042]}, {"w": "means", "b": [0.4631, 0.2828, 0.5172, 0.3042]}, {"w": "that", "b": [0.5277, 0.2828, 0.5603, 0.3042]}, {"w": "the", "b": [0.5709, 0.2828, 0.5972, 0.3042]}, {"w": "loss", "b": [0.6077, 0.2828, 0.6389, 0.3042]}, {"w": "will", "b": [0.6494, 0.2828, 0.6798, 0.3042]}, {"w": "be", "b": [0.6904, 0.2828, 0.7098, 0.3042]}, {"w": "the", "b": [0.7203, 0.2828, 0.7467, 0.3042]}, {"w": "sum", "b": [0.7572, 0.2828, 0.793, 0.3042]}, {"w": "of", "b": [0.8035, 0.2828, 0.8203, 0.3042]}, {"w": "the", "b": [0.8308, 0.2828, 0.8571, 0.3042]}, {"w": "instance", "b": [0.1786, 0.3019, 0.2478, 0.3233]}, {"w": "losses,", "b": [0.254, 0.3019, 0.3065, 0.3233]}, {"w": "possibly", "b": [0.3127, 0.3019, 0.3806, 0.3233]}, {"w": "weighted", "b": [0.3868, 0.3019, 0.4622, 0.3233]}, {"w": "by", "b": [0.4685, 0.3019, 0.4887, 0.3233]}, {"w": "the", "b": [0.4949, 0.3019, 0.5213, 0.3233]}, {"w": "sample", "b": [0.5275, 0.3019, 0.586, 0.3233]}, {"w": "weights,", "b": [0.5923, 0.3019, 0.6602, 0.3233]}, {"w": "if", "b": [0.6665, 0.3019, 0.6783, 0.3233]}, {"w": "any,", "b": [0.6845, 0.3019, 0.7174, 0.3233]}, {"w": "and", "b": [0.7237, 0.3019, 0.7552, 0.3233]}, {"w": "then", "b": [0.7615, 0.3019, 0.7992, 0.3233]}, {"w": "divide", "b": [0.8055, 0.3019, 0.8571, 0.3233]}, {"w": "the", "b": [0.1786, 0.3209, 0.2049, 0.3423]}, {"w": "result", "b": [0.2101, 0.3209, 0.2571, 0.3423]}, {"w": "by", "b": [0.2623, 0.3209, 0.2824, 0.3423]}, {"w": "the", "b": [0.2877, 0.3209, 0.314, 0.3423]}, {"w": "batch", "b": [0.3192, 0.3209, 0.3649, 0.3423]}, {"w": "size", "b": [0.3701, 0.3209, 0.4009, 0.3423]}, {"w": "(not", "b": [0.4062, 0.3209, 0.4417, 0.3423]}, {"w": "by", "b": [0.447, 0.3209, 0.4671, 0.3423]}, {"w": "the", "b": [0.4724, 0.3209, 0.4987, 0.3423]}, {"w": "sum", "b": [0.5039, 0.3209, 0.5397, 0.3423]}, {"w": "of", "b": [0.5449, 0.3209, 0.5617, 0.3423]}, {"w": "weights,", "b": [0.567, 0.3209, 0.6349, 0.3423]}, {"w": "so", "b": [0.6401, 0.3209, 0.6584, 0.3423]}, {"w": "this", "b": [0.6637, 0.3209, 0.6944, 0.3423]}, {"w": "is", "b": [0.6996, 0.3209, 0.7128, 0.3423]}, {"w": "not", "b": [0.7181, 0.3207, 0.7449, 0.3423]}, {"w": "the", "b": [0.7502, 0.3209, 0.7765, 0.3423]}, {"w": "weighted", "b": [0.7812, 0.3209, 0.8566, 0.3423]}, {"w": "mean).5.", "b": [0.1786, 0.3409, 0.2475, 0.3623]}, {"w": "Other", "b": [0.2522, 0.3409, 0.3018, 0.3623]}, {"w": "possible", "b": [0.3065, 0.3409, 0.3737, 0.3623]}, {"w": "values", "b": [0.3784, 0.3409, 0.43, 0.3623]}, {"w": "are", "b": [0.4347, 0.3409, 0.4605, 0.3623]}, {"w": "\"sum\"", "b": [0.4652, 0.344, 0.5147, 0.3591]}, {"w": "and", "b": [0.5194, 0.3409, 0.551, 0.3623]}, {"w": "None.", "b": [0.5557, 0.3409, 0.6, 0.3623]}]}, {"id": "b_4", "type": "paragraph", "text": "• The call() method takes the labels and predictions, computes all the instance losses, and returns them.", "words": [{"w": "•", "b": [0.16, 0.3668, 0.1682, 0.3883]}, {"w": "The", "b": [0.1786, 0.3668, 0.2114, 0.3883]}, {"w": "call()", "b": [0.2186, 0.37, 0.278, 0.3851]}, {"w": "method", "b": [0.2851, 0.3668, 0.3502, 0.3883]}, {"w": "takes", "b": [0.3573, 0.3668, 0.3997, 0.3883]}, {"w": "the", "b": [0.4068, 0.3668, 0.4332, 0.3883]}, {"w": "labels", "b": [0.4404, 0.3668, 0.4871, 0.3883]}, {"w": "and", "b": [0.4943, 0.3668, 0.5258, 0.3883]}, {"w": "predictions,", "b": [0.533, 0.3668, 0.6323, 0.3883]}, {"w": "computes", "b": [0.6395, 0.3668, 0.7204, 0.3883]}, {"w": "all", "b": [0.7276, 0.3668, 0.7473, 0.3883]}, {"w": "the", "b": [0.7544, 0.3668, 0.7808, 0.3883]}, {"w": "instance", "b": [0.7879, 0.3668, 0.8571, 0.3883]}, {"w": "losses,", "b": [0.1786, 0.3859, 0.231, 0.4073]}, {"w": "and", "b": [0.2357, 0.3859, 0.2673, 0.4073]}, {"w": "returns", "b": [0.272, 0.3859, 0.3328, 0.4073]}, {"w": "them.", "b": [0.3375, 0.3859, 0.3857, 0.4073]}]}, {"id": "b_5", "type": "paragraph", "text": "• The get_config() method returns a dictionary mapping each hyperparameter name to its value. It first calls the parent class’s get_config() method, then adds the new hyperparameters to this dictionary (note that the convenient {**x} syn‐ tax was added in Python 3.5).", "words": [{"w": "•", "b": [0.16, 0.4119, 0.1682, 0.4333]}, {"w": "The", "b": [0.1786, 0.4119, 0.2114, 0.4333]}, {"w": "get_config()", "b": [0.2189, 0.4151, 0.3376, 0.4301]}, {"w": "method", "b": [0.3451, 0.4119, 0.4101, 0.4333]}, {"w": "returns", "b": [0.4176, 0.4119, 0.4784, 0.4333]}, {"w": "a", "b": [0.4859, 0.4119, 0.495, 0.4333]}, {"w": "dictionary", "b": [0.5025, 0.4119, 0.5889, 0.4333]}, {"w": "mapping", "b": [0.5964, 0.4119, 0.6707, 0.4333]}, {"w": "each", "b": [0.6782, 0.4119, 0.7162, 0.4333]}, {"w": "hyperparameter", "b": [0.7236, 0.4119, 0.8571, 0.4333]}, {"w": "name", "b": [0.1786, 0.4318, 0.225, 0.4532]}, {"w": "to", "b": [0.2305, 0.4318, 0.2475, 0.4532]}, {"w": "its", "b": [0.253, 0.4318, 0.2725, 0.4532]}, {"w": "value.", "b": [0.278, 0.4318, 0.3268, 0.4532]}, {"w": "It", "b": [0.3322, 0.4318, 0.3449, 0.4532]}, {"w": "first", "b": [0.3504, 0.4318, 0.3838, 0.4532]}, {"w": "calls", "b": [0.3893, 0.4318, 0.4255, 0.4532]}, {"w": "the", "b": [0.4309, 0.4318, 0.4573, 0.4532]}, {"w": "parent", "b": [0.4627, 0.4318, 0.5167, 0.4532]}, {"w": "class’s", "b": [0.5222, 0.4318, 0.5702, 0.4532]}, {"w": "get_config()", "b": [0.5757, 0.435, 0.6944, 0.4501]}, {"w": "method,", "b": [0.6999, 0.4318, 0.7697, 0.4532]}, {"w": "then", "b": [0.7751, 0.4318, 0.8129, 0.4532]}, {"w": "adds", "b": [0.8184, 0.4318, 0.8571, 0.4532]}, {"w": "the", "b": [0.1786, 0.4518, 0.2049, 0.4732]}, {"w": "new", "b": [0.2105, 0.4518, 0.245, 0.4732]}, {"w": "hyperparameters", "b": [0.2506, 0.4518, 0.3918, 0.4732]}, {"w": "to", "b": [0.3974, 0.4518, 0.4143, 0.4732]}, {"w": "this", "b": [0.4199, 0.4518, 0.4506, 0.4732]}, {"w": "dictionary", "b": [0.4562, 0.4518, 0.5426, 0.4732]}, {"w": "(note", "b": [0.5482, 0.4518, 0.5927, 0.4732]}, {"w": "that", "b": [0.5983, 0.4518, 0.6309, 0.4732]}, {"w": "the", "b": [0.6365, 0.4518, 0.6628, 0.4732]}, {"w": "convenient", "b": [0.6684, 0.4518, 0.7604, 0.4732]}, {"w": "{**x}", "b": [0.766, 0.455, 0.8155, 0.47]}, {"w": "syn‐", "b": [0.8211, 0.4518, 0.8571, 0.4732]}, {"w": "tax", "b": [0.1786, 0.4708, 0.2039, 0.4922]}, {"w": "was", "b": [0.2086, 0.4708, 0.2397, 0.4922]}, {"w": "added", "b": [0.2444, 0.4708, 0.2954, 0.4922]}, {"w": "in", "b": [0.3002, 0.4708, 0.3171, 0.4922]}, {"w": "Python", "b": [0.3219, 0.4708, 0.3827, 0.4922]}, {"w": "3.5).", "b": [0.3874, 0.4708, 0.4241, 0.4922]}]}, {"id": "b_6", "type": "paragraph", "text": "You can then use any instance of this class when you compile the model:", "words": [{"w": "You", "b": [0.1429, 0.505, 0.1752, 0.5264]}, {"w": "can", "b": [0.1799, 0.505, 0.2093, 0.5264]}, {"w": "then", "b": [0.214, 0.505, 0.2518, 0.5264]}, {"w": "use", "b": [0.2565, 0.505, 0.2841, 0.5264]}, {"w": "any", "b": [0.2888, 0.505, 0.3184, 0.5264]}, {"w": "instance", "b": [0.3231, 0.505, 0.3923, 0.5264]}, {"w": "of", "b": [0.3971, 0.505, 0.4138, 0.5264]}, {"w": "this", "b": [0.4186, 0.505, 0.4493, 0.5264]}, {"w": "class", "b": [0.454, 0.505, 0.4925, 0.5264]}, {"w": "when", "b": [0.4973, 0.505, 0.5429, 0.5264]}, {"w": "you", "b": [0.5476, 0.505, 0.5789, 0.5264]}, {"w": "compile", "b": [0.5836, 0.505, 0.6503, 0.5264]}, {"w": "the", "b": [0.6551, 0.505, 0.6814, 0.5264]}, {"w": "model:", "b": [0.6861, 0.505, 0.7437, 0.5264]}]}, {"id": "b_7", "type": "equation", "text": "model.compile(loss=HuberLoss(2.), optimizer=\"nadam\")", "words": [{"w": "model.compile(loss=HuberLoss(2.),", "b": [0.1766, 0.537, 0.4549, 0.5498]}, {"w": "optimizer=\"nadam\")", "b": [0.4633, 0.537, 0.6151, 0.5498]}]}, {"id": "b_8", "type": "paragraph", "text": "When you save the model, the threshold will be saved along with it, and when you load the model you just need to map the class name to the class itself:", "words": [{"w": "When", "b": [0.1429, 0.5576, 0.1945, 0.579]}, {"w": "you", "b": [0.2013, 0.5576, 0.2325, 0.579]}, {"w": "save", "b": [0.2393, 0.5576, 0.2742, 0.579]}, {"w": "the", "b": [0.2811, 0.5576, 0.3074, 0.579]}, {"w": "model,", "b": [0.3142, 0.5576, 0.3718, 0.579]}, {"w": "the", "b": [0.3786, 0.5576, 0.4049, 0.579]}, {"w": "threshold", "b": [0.4117, 0.5576, 0.4914, 0.579]}, {"w": "will", "b": [0.4983, 0.5576, 0.5287, 0.579]}, {"w": "be", "b": [0.5355, 0.5576, 0.5549, 0.579]}, {"w": "saved", "b": [0.5617, 0.5576, 0.6076, 0.579]}, {"w": "along", "b": [0.6144, 0.5576, 0.6606, 0.579]}, {"w": "with", "b": [0.6674, 0.5576, 0.7048, 0.579]}, {"w": "it,", "b": [0.7116, 0.5576, 0.7283, 0.579]}, {"w": "and", "b": [0.7351, 0.5576, 0.7666, 0.579]}, {"w": "when", "b": [0.7734, 0.5576, 0.8191, 0.579]}, {"w": "you", "b": [0.8259, 0.5576, 0.8571, 0.579]}, {"w": "load", "b": [0.1428, 0.5766, 0.1789, 0.598]}, {"w": "the", "b": [0.1836, 0.5766, 0.21, 0.598]}, {"w": "model", "b": [0.2147, 0.5766, 0.2675, 0.598]}, {"w": "you", "b": [0.2722, 0.5766, 0.3035, 0.598]}, {"w": "just", "b": [0.3082, 0.5766, 0.3386, 0.598]}, {"w": "need", "b": [0.3433, 0.5766, 0.3834, 0.598]}, {"w": "to", "b": [0.3882, 0.5766, 0.4051, 0.598]}, {"w": "map", "b": [0.4099, 0.5766, 0.4466, 0.598]}, {"w": "the", "b": [0.4513, 0.5766, 0.4777, 0.598]}, {"w": "class", "b": [0.4824, 0.5766, 0.5209, 0.598]}, {"w": "name", "b": [0.5256, 0.5766, 0.5721, 0.598]}, {"w": "to", "b": [0.5768, 0.5766, 0.5938, 0.598]}, {"w": "the", "b": [0.5985, 0.5766, 0.6249, 0.598]}, {"w": "class", "b": [0.6296, 0.5766, 0.6681, 0.598]}, {"w": "itself:", "b": [0.6728, 0.5766, 0.7175, 0.598]}]}, {"id": "b_9", "type": "paragraph", "text": "model = keras.models.load_model(\"my_model_with_a_custom_loss_class.h5\", custom_objects={\"HuberLoss\": HuberLoss})", "words": [{"w": "model", "b": [0.1766, 0.6086, 0.2188, 0.6215]}, {"w": "=", "b": [0.2272, 0.6086, 0.2356, 0.6215]}, {"w": "keras.models.load_model(\"my_model_with_a_custom_loss_class.h5\",", "b": [0.2441, 0.6086, 0.7753, 0.6215]}, {"w": "custom_objects={\"HuberLoss\":", "b": [0.4464, 0.624, 0.6825, 0.6369]}, {"w": "HuberLoss})", "b": [0.691, 0.624, 0.7837, 0.6369]}]}, {"id": "b_10", "type": "paragraph", "text": "When you save a model, Keras calls the loss instance’s get_config() method and saves the config as JSON in the HDF5 file. When you load the model, it calls the from_config() class method on the HuberLoss class: this method is implemented by the base class (Loss) and just creates an instance of the class, passing **config to the constructor.", "words": [{"w": "When", "b": [0.1429, 0.6456, 0.1945, 0.667]}, {"w": "you", "b": [0.2024, 0.6456, 0.2337, 0.667]}, {"w": "save", "b": [0.2417, 0.6456, 0.2766, 0.667]}, {"w": "a", "b": [0.2845, 0.6456, 0.2937, 0.667]}, {"w": "model,", "b": [0.3017, 0.6456, 0.3592, 0.667]}, {"w": "Keras", "b": [0.3672, 0.6456, 0.4141, 0.667]}, {"w": "calls", "b": [0.4221, 0.6456, 0.4582, 0.667]}, {"w": "the", "b": [0.4662, 0.6456, 0.4925, 0.667]}, {"w": "loss", "b": [0.5005, 0.6456, 0.5317, 0.667]}, {"w": "instance’s", "b": [0.5396, 0.6456, 0.6179, 0.667]}, {"w": "get_config()", "b": [0.6259, 0.6487, 0.7446, 0.6638]}, {"w": "method", "b": [0.7526, 0.6456, 0.8176, 0.667]}, {"w": "and", "b": [0.8256, 0.6456, 0.8571, 0.667]}, {"w": "saves", "b": [0.1429, 0.6646, 0.1854, 0.686]}, {"w": "the", "b": [0.1932, 0.6646, 0.2196, 0.686]}, {"w": "config", "b": [0.2274, 0.6646, 0.2797, 0.686]}, {"w": "as", "b": [0.2875, 0.6646, 0.3043, 0.686]}, {"w": "JSON", "b": [0.3121, 0.6646, 0.3599, 0.686]}, {"w": "in", "b": [0.3677, 0.6646, 0.3847, 0.686]}, {"w": "the", "b": [0.3925, 0.6646, 0.4189, 0.686]}, {"w": "HDF5", "b": [0.4267, 0.6646, 0.479, 0.686]}, {"w": "file.", "b": [0.4868, 0.6646, 0.5174, 0.686]}, {"w": "When", "b": [0.5252, 0.6646, 0.5768, 0.686]}, {"w": "you", "b": [0.5846, 0.6646, 0.6159, 0.686]}, {"w": "load", "b": [0.6237, 0.6646, 0.6597, 0.686]}, {"w": "the", "b": [0.6676, 0.6646, 0.6939, 0.686]}, {"w": "model,", "b": [0.7017, 0.6646, 0.7593, 0.686]}, {"w": "it", "b": [0.7671, 0.6646, 0.779, 0.686]}, {"w": "calls", "b": [0.7868, 0.6646, 0.823, 0.686]}, {"w": "the", "b": [0.8308, 0.6646, 0.8571, 0.686]}, {"w": "from_config()", "b": [0.1429, 0.6877, 0.2715, 0.7028]}, {"w": "class", "b": [0.2771, 0.6846, 0.3157, 0.706]}, {"w": "method", "b": [0.3213, 0.6846, 0.3863, 0.706]}, {"w": "on", "b": [0.3919, 0.6846, 0.4139, 0.706]}, {"w": "the", "b": [0.4196, 0.6846, 0.4459, 0.706]}, {"w": "HuberLoss", "b": [0.4515, 0.6877, 0.5406, 0.7028]}, {"w": "class:", "b": [0.5462, 0.6846, 0.5895, 0.706]}, {"w": "this", "b": [0.5951, 0.6846, 0.6258, 0.706]}, {"w": "method", "b": [0.6315, 0.6846, 0.6965, 0.706]}, {"w": "is", "b": [0.7021, 0.6846, 0.7153, 0.706]}, {"w": "implemented", "b": [0.721, 0.6846, 0.8314, 0.706]}, {"w": "by", "b": [0.837, 0.6846, 0.8571, 0.706]}, {"w": "the", "b": [0.1429, 0.7045, 0.1692, 0.7259]}, {"w": "base", "b": [0.1745, 0.7045, 0.2107, 0.7259]}, {"w": "class", "b": [0.216, 0.7045, 0.2545, 0.7259]}, {"w": "(Loss)", "b": [0.2599, 0.7045, 0.3139, 0.7259]}, {"w": "and", "b": [0.3192, 0.7045, 0.3507, 0.7259]}, {"w": "just", "b": [0.356, 0.7045, 0.3864, 0.7259]}, {"w": "creates", "b": [0.3917, 0.7045, 0.4487, 0.7259]}, {"w": "an", "b": [0.454, 0.7045, 0.4746, 0.7259]}, {"w": "instance", "b": [0.4799, 0.7045, 0.549, 0.7259]}, {"w": "of", "b": [0.5544, 0.7045, 0.5711, 0.7259]}, {"w": "the", "b": [0.5764, 0.7045, 0.6028, 0.7259]}, {"w": "class,", "b": [0.6081, 0.7045, 0.6514, 0.7259]}, {"w": "passing", "b": [0.6567, 0.7045, 0.7187, 0.7259]}, {"w": "**config", "b": [0.724, 0.7077, 0.8032, 0.7228]}, {"w": "to", "b": [0.8085, 0.7045, 0.8255, 0.7259]}, {"w": "the", "b": [0.8302, 0.7045, 0.8566, 0.7259]}, {"w": "constructor.", "b": [0.1429, 0.7235, 0.2434, 0.745]}]}, {"id": "b_11", "type": "paragraph", "text": "That’s it for losses! It was not too hard, was it? Well it’s just as simple for custom acti‐ vation functions, initializers, regularizers, and constraints. Let’s look at these now.", "words": [{"w": "That’s", "b": [0.1429, 0.7517, 0.1917, 0.7731]}, {"w": "it", "b": [0.1971, 0.7517, 0.209, 0.7731]}, {"w": "for", "b": [0.2143, 0.7517, 0.2389, 0.7731]}, {"w": "losses!", "b": [0.2442, 0.7517, 0.2977, 0.7731]}, {"w": "It", "b": [0.303, 0.7517, 0.3157, 0.7731]}, {"w": "was", "b": [0.321, 0.7517, 0.3521, 0.7731]}, {"w": "not", "b": [0.3574, 0.7517, 0.3858, 0.7731]}, {"w": "too", "b": [0.3912, 0.7517, 0.4188, 0.7731]}, {"w": "hard,", "b": [0.4241, 0.7517, 0.4679, 0.7731]}, {"w": "was", "b": [0.4732, 0.7517, 0.5043, 0.7731]}, {"w": "it?", "b": [0.5097, 0.7517, 0.5295, 0.7731]}, {"w": "Well", "b": [0.5348, 0.7517, 0.5724, 0.7731]}, {"w": "it’s", "b": [0.5778, 0.7517, 0.5995, 0.7731]}, {"w": "just", "b": [0.6048, 0.7517, 0.6352, 0.7731]}, {"w": "as", "b": [0.6406, 0.7517, 0.6574, 0.7731]}, {"w": "simple", "b": [0.6627, 0.7517, 0.7177, 0.7731]}, {"w": "for", "b": [0.723, 0.7517, 0.7476, 0.7731]}, {"w": "custom", "b": [0.7529, 0.7517, 0.8145, 0.7731]}, {"w": "acti‐", "b": [0.8198, 0.7517, 0.8571, 0.7731]}, {"w": "vation", "b": [0.1429, 0.7707, 0.1952, 0.7921]}, {"w": "functions,", "b": [0.1999, 0.7707, 0.2837, 0.7921]}, {"w": "initializers,", "b": [0.2885, 0.7707, 0.3807, 0.7921]}, {"w": "regularizers,", "b": [0.3854, 0.7707, 0.4883, 0.7921]}, {"w": "and", "b": [0.493, 0.7707, 0.5245, 0.7921]}, {"w": "constraints.", "b": [0.5293, 0.7707, 0.6263, 0.7921]}, {"w": "Let’s", "b": [0.631, 0.7707, 0.6672, 0.7921]}, {"w": "look", "b": [0.6719, 0.7707, 0.7088, 0.7921]}, {"w": "at", "b": [0.7135, 0.7707, 0.7286, 0.7921]}, {"w": "these", "b": [0.7334, 0.7707, 0.7762, 0.7921]}, {"w": "now.", "b": [0.7809, 0.7707, 0.8204, 0.7921]}]}, {"id": "b_12", "type": "paragraph", "text": "378 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "378", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2745, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 405, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Custom Activation Functions, Initializers, Regularizers, and Constraints", "words": [{"w": "Custom", "b": [0.1429, 0.0763, 0.2201, 0.1049]}, {"w": "Activation", "b": [0.2251, 0.0763, 0.3301, 0.1049]}, {"w": "Functions,", "b": [0.3351, 0.0763, 0.4416, 0.1049]}, {"w": "Initializers,", "b": [0.4466, 0.0763, 0.5621, 0.1049]}, {"w": "Regularizers,", "b": [0.567, 0.0763, 0.7015, 0.1049]}, {"w": "and", "b": [0.7065, 0.0763, 0.7457, 0.1049]}, {"w": "Constraints", "b": [0.1429, 0.099, 0.2594, 0.1275]}]}, {"id": "b_1", "type": "paragraph", "text": "Most Keras functionalities, such as losses, regularizers, constraints, initializers, met‐ rics, activation functions, layers and even full models can be customized in very much the same way. Most of the time, you will just need to write a simple function, with the appropriate inputs and outputs. For example, here are examples of a custom activa‐ tion function (equivalent to keras.activations.softplus or tf.nn.softplus), a custom Glorot initializer (equivalent to keras.initializers.glorot_normal), a cus‐ tom ℓ1 regularizer (equivalent to keras.regularizers.l1(0.01)) and a custom con‐ straint that ensures weights are all positive (equivalent to keras.constraints.nonneg() or tf.nn.relu):", "words": [{"w": "Most", "b": [0.1428, 0.1334, 0.1855, 0.1548]}, {"w": "Keras", "b": [0.1922, 0.1334, 0.2391, 0.1548]}, {"w": "functionalities,", "b": [0.2458, 0.1334, 0.3704, 0.1548]}, {"w": "such", "b": [0.3771, 0.1334, 0.4158, 0.1548]}, {"w": "as", "b": [0.4225, 0.1334, 0.4393, 0.1548]}, {"w": "losses,", "b": [0.446, 0.1334, 0.4984, 0.1548]}, {"w": "regularizers,", "b": [0.5052, 0.1334, 0.608, 0.1548]}, {"w": "constraints,", "b": [0.6147, 0.1334, 0.7118, 0.1548]}, {"w": "initializers,", "b": [0.7185, 0.1334, 0.8107, 0.1548]}, {"w": "met‐", "b": [0.8174, 0.1334, 0.8571, 0.1548]}, {"w": "rics,", "b": [0.1429, 0.1525, 0.1774, 0.1739]}, {"w": "activation", "b": [0.1821, 0.1525, 0.2644, 0.1739]}, {"w": "functions,", "b": [0.2691, 0.1525, 0.3529, 0.1739]}, {"w": "layers", "b": [0.3576, 0.1525, 0.4054, 0.1739]}, {"w": "and", "b": [0.4102, 0.1525, 0.4417, 0.1739]}, {"w": "even", "b": [0.4464, 0.1525, 0.4852, 0.1739]}, {"w": "full", "b": [0.4899, 0.1525, 0.5177, 0.1739]}, {"w": "models", "b": [0.5224, 0.1525, 0.5829, 0.1739]}, {"w": "can", "b": [0.5876, 0.1525, 0.617, 0.1739]}, {"w": "be", "b": [0.6217, 0.1525, 0.6411, 0.1739]}, {"w": "customized", "b": [0.6459, 0.1525, 0.7416, 0.1739]}, {"w": "in", "b": [0.7463, 0.1525, 0.7633, 0.1739]}, {"w": "very", "b": [0.7681, 0.1525, 0.8044, 0.1739]}, {"w": "much", "b": [0.8092, 0.1525, 0.8568, 0.1739]}, {"w": "the", "b": [0.1429, 0.1715, 0.1692, 0.1929]}, {"w": "same", "b": [0.1742, 0.1715, 0.2169, 0.1929]}, {"w": "way.", "b": [0.2219, 0.1715, 0.2578, 0.1929]}, {"w": "Most", "b": [0.2628, 0.1715, 0.3054, 0.1929]}, {"w": "of", "b": [0.3104, 0.1715, 0.3272, 0.1929]}, {"w": "the", "b": [0.3322, 0.1715, 0.3586, 0.1929]}, {"w": "time,", "b": [0.3636, 0.1715, 0.4062, 0.1929]}, {"w": "you", "b": [0.4112, 0.1715, 0.4425, 0.1929]}, {"w": "will", "b": [0.4475, 0.1715, 0.4779, 0.1929]}, {"w": "just", "b": [0.4829, 0.1715, 0.5133, 0.1929]}, {"w": "need", "b": [0.5183, 0.1715, 0.5584, 0.1929]}, {"w": "to", "b": [0.5634, 0.1715, 0.5804, 0.1929]}, {"w": "write", "b": [0.5854, 0.1715, 0.6282, 0.1929]}, {"w": "a", "b": [0.6332, 0.1715, 0.6423, 0.1929]}, {"w": "simple", "b": [0.6474, 0.1715, 0.7023, 0.1929]}, {"w": "function,", "b": [0.7073, 0.1715, 0.7835, 0.1929]}, {"w": "with", "b": [0.7885, 0.1715, 0.8258, 0.1929]}, {"w": "the", "b": [0.8308, 0.1715, 0.8571, 0.1929]}, {"w": "appropriate", "b": [0.1429, 0.1906, 0.24, 0.212]}, {"w": "inputs", "b": [0.2465, 0.1906, 0.299, 0.212]}, {"w": "and", "b": [0.3055, 0.1906, 0.3371, 0.212]}, {"w": "outputs.", "b": [0.3436, 0.1906, 0.4123, 0.212]}, {"w": "For", "b": [0.4188, 0.1906, 0.4478, 0.212]}, {"w": "example,", "b": [0.4543, 0.1906, 0.5286, 0.212]}, {"w": "here", "b": [0.5351, 0.1906, 0.5717, 0.212]}, {"w": "are", "b": [0.5782, 0.1906, 0.6039, 0.212]}, {"w": "examples", "b": [0.6104, 0.1906, 0.6876, 0.212]}, {"w": "of", "b": [0.6941, 0.1906, 0.7108, 0.212]}, {"w": "a", "b": [0.7173, 0.1906, 0.7265, 0.212]}, {"w": "custom", "b": [0.733, 0.1906, 0.7945, 0.212]}, {"w": "activa‐", "b": [0.801, 0.1906, 0.8571, 0.212]}, {"w": "tion", "b": [0.1429, 0.2105, 0.1768, 0.2319]}, {"w": "function", "b": [0.1858, 0.2105, 0.2572, 0.2319]}, {"w": "(equivalent", "b": [0.2662, 0.2105, 0.3598, 0.2319]}, {"w": "to", "b": [0.3688, 0.2105, 0.3858, 0.2319]}, {"w": "keras.activations.softplus", "b": [0.3948, 0.2137, 0.6521, 0.2288]}, {"w": "or", "b": [0.6611, 0.2105, 0.6795, 0.2319]}, {"w": "tf.nn.softplus),", "b": [0.6885, 0.2105, 0.839, 0.2319]}, {"w": "a", "b": [0.848, 0.2105, 0.8571, 0.2319]}, {"w": "custom", "b": [0.1429, 0.2305, 0.2044, 0.2519]}, {"w": "Glorot", "b": [0.2093, 0.2305, 0.2648, 0.2519]}, {"w": "initializer", "b": [0.2697, 0.2305, 0.3495, 0.2519]}, {"w": "(equivalent", "b": [0.3544, 0.2305, 0.448, 0.2519]}, {"w": "to", "b": [0.4529, 0.2305, 0.4698, 0.2519]}, {"w": "keras.initializers.glorot_normal),", "b": [0.4747, 0.2305, 0.8033, 0.2519]}, {"w": "a", "b": [0.8081, 0.2305, 0.8172, 0.2519]}, {"w": "cus‐", "b": [0.8219, 0.2305, 0.8569, 0.2519]}, {"w": "tom", "b": [0.1429, 0.2504, 0.1769, 0.2718]}, {"w": "ℓ1", "b": [0.1824, 0.2504, 0.197, 0.2727]}, {"w": "regularizer", "b": [0.2025, 0.2504, 0.293, 0.2718]}, {"w": "(equivalent", "b": [0.2985, 0.2504, 0.3921, 0.2718]}, {"w": "to", "b": [0.3976, 0.2504, 0.4146, 0.2718]}, {"w": "keras.regularizers.l1(0.01))", "b": [0.4201, 0.2504, 0.6945, 0.2718]}, {"w": "and", "b": [0.7001, 0.2504, 0.7316, 0.2718]}, {"w": "a", "b": [0.7371, 0.2504, 0.7463, 0.2718]}, {"w": "custom", "b": [0.7518, 0.2504, 0.8134, 0.2718]}, {"w": "con‐", "b": [0.8189, 0.2504, 0.8571, 0.2718]}, {"w": "straint", "b": [0.1428, 0.2695, 0.1967, 0.2909]}, {"w": "that", "b": [0.2317, 0.2695, 0.2643, 0.2909]}, {"w": "ensures", "b": [0.2993, 0.2695, 0.3625, 0.2909]}, {"w": "weights", "b": [0.3975, 0.2695, 0.4607, 0.2909]}, {"w": "are", "b": [0.4958, 0.2695, 0.5215, 0.2909]}, {"w": "all", "b": [0.5565, 0.2695, 0.5762, 0.2909]}, {"w": "positive", "b": [0.6113, 0.2695, 0.6765, 0.2909]}, {"w": "(equivalent", "b": [0.7115, 0.2695, 0.8051, 0.2909]}, {"w": "to", "b": [0.8402, 0.2695, 0.8571, 0.2909]}, {"w": "keras.constraints.nonneg()", "b": [0.1429, 0.2926, 0.4001, 0.3077]}, {"w": "or", "b": [0.4049, 0.2894, 0.4232, 0.3108]}, {"w": "tf.nn.relu):", "b": [0.428, 0.2894, 0.5389, 0.3108]}]}, {"id": "b_2", "type": "paragraph", "text": "def my_softplus(z): # return value is just tf.nn.softplus(z) return tf.math.log(tf.exp(z) + 1.0)", "words": [{"w": "def", "b": [0.1766, 0.3214, 0.2019, 0.3342]}, {"w": "my_softplus(z):", "b": [0.2103, 0.3214, 0.3368, 0.3342]}, {"w": "#", "b": [0.3452, 0.3214, 0.3537, 0.3342]}, {"w": "return", "b": [0.3621, 0.3214, 0.4127, 0.3342]}, {"w": "value", "b": [0.4211, 0.3214, 0.4633, 0.3342]}, {"w": "is", "b": [0.4717, 0.3214, 0.4886, 0.3342]}, {"w": "just", "b": [0.497, 0.3214, 0.5308, 0.3342]}, {"w": "tf.nn.softplus(z)", "b": [0.5392, 0.3214, 0.6825, 0.3342]}, {"w": "return", "b": [0.2103, 0.3368, 0.2609, 0.3496]}, {"w": "tf.math.log(tf.exp(z)", "b": [0.2694, 0.3368, 0.4464, 0.3496]}, {"w": "+", "b": [0.4549, 0.3368, 0.4633, 0.3496]}, {"w": "1.0)", "b": [0.4717, 0.3368, 0.5055, 0.3496]}]}, {"id": "b_3", "type": "paragraph", "text": "def my_glorot_initializer(shape, dtype=tf.float32): stddev = tf.sqrt(2. / (shape[0] + shape[1])) return tf.random.normal(shape, stddev=stddev, dtype=dtype)", "words": [{"w": "def", "b": [0.1766, 0.3676, 0.2019, 0.3805]}, {"w": "my_glorot_initializer(shape,", "b": [0.2103, 0.3676, 0.4464, 0.3805]}, {"w": "dtype=tf.float32):", "b": [0.4549, 0.3676, 0.6067, 0.3805]}, {"w": "stddev", "b": [0.2103, 0.383, 0.2609, 0.3959]}, {"w": "=", "b": [0.2694, 0.383, 0.2778, 0.3959]}, {"w": "tf.sqrt(2.", "b": [0.2862, 0.383, 0.3705, 0.3959]}, {"w": "/", "b": [0.379, 0.383, 0.3874, 0.3959]}, {"w": "(shape[0]", "b": [0.3958, 0.383, 0.4717, 0.3959]}, {"w": "+", "b": [0.4802, 0.383, 0.4886, 0.3959]}, {"w": "shape[1]))", "b": [0.497, 0.383, 0.5814, 0.3959]}, {"w": "return", "b": [0.2103, 0.3985, 0.2609, 0.4113]}, {"w": "tf.random.normal(shape,", "b": [0.2694, 0.3985, 0.4633, 0.4113]}, {"w": "stddev=stddev,", "b": [0.4717, 0.3985, 0.5898, 0.4113]}, {"w": "dtype=dtype)", "b": [0.5982, 0.3985, 0.6994, 0.4113]}]}, {"id": "b_4", "type": "equation", "text": "def my_l1_regularizer(weights): return tf.reduce_sum(tf.abs(0.01 * weights))", "words": [{"w": "def", "b": [0.1766, 0.4293, 0.2019, 0.4422]}, {"w": "my_l1_regularizer(weights):", "b": [0.2103, 0.4293, 0.438, 0.4422]}, {"w": "return", "b": [0.2103, 0.4447, 0.2609, 0.4576]}, {"w": "tf.reduce_sum(tf.abs(0.01", "b": [0.2694, 0.4447, 0.4802, 0.4576]}, {"w": "*", "b": [0.4886, 0.4447, 0.497, 0.4576]}, {"w": "weights))", "b": [0.5055, 0.4447, 0.5814, 0.4576]}]}, {"id": "b_5", "type": "paragraph", "text": "def my_positive_weights(weights): # return value is just tf.nn.relu(weights) return tf.where(weights < 0., tf.zeros_like(weights), weights)", "words": [{"w": "def", "b": [0.1766, 0.4756, 0.2019, 0.4884]}, {"w": "my_positive_weights(weights):", "b": [0.2103, 0.4756, 0.4549, 0.4884]}, {"w": "#", "b": [0.4633, 0.4756, 0.4717, 0.4884]}, {"w": "return", "b": [0.4802, 0.4756, 0.5308, 0.4884]}, {"w": "value", "b": [0.5392, 0.4756, 0.5814, 0.4884]}, {"w": "is", "b": [0.5898, 0.4756, 0.6067, 0.4884]}, {"w": "just", "b": [0.6151, 0.4756, 0.6488, 0.4884]}, {"w": "tf.nn.relu(weights)", "b": [0.6572, 0.4756, 0.8175, 0.4884]}, {"w": "return", "b": [0.2103, 0.491, 0.2609, 0.5038]}, {"w": "tf.where(weights", "b": [0.2694, 0.491, 0.4043, 0.5038]}, {"w": "<", "b": [0.4127, 0.491, 0.4211, 0.5038]}, {"w": "0.,", "b": [0.4296, 0.491, 0.4549, 0.5038]}, {"w": "tf.zeros_like(weights),", "b": [0.4633, 0.491, 0.6572, 0.5038]}, {"w": "weights)", "b": [0.6657, 0.491, 0.7331, 0.5038]}]}, {"id": "b_6", "type": "paragraph", "text": "As you can see, the arguments depend on the type of custom function. These custom functions can then be used normally, for example:", "words": [{"w": "As", "b": [0.1429, 0.5116, 0.1649, 0.533]}, {"w": "you", "b": [0.1703, 0.5116, 0.2015, 0.533]}, {"w": "can", "b": [0.2069, 0.5116, 0.2362, 0.533]}, {"w": "see,", "b": [0.2416, 0.5116, 0.2717, 0.533]}, {"w": "the", "b": [0.2771, 0.5116, 0.3034, 0.533]}, {"w": "arguments", "b": [0.3088, 0.5116, 0.3974, 0.533]}, {"w": "depend", "b": [0.4027, 0.5116, 0.4648, 0.533]}, {"w": "on", "b": [0.4701, 0.5116, 0.4921, 0.533]}, {"w": "the", "b": [0.4975, 0.5116, 0.5239, 0.533]}, {"w": "type", "b": [0.5292, 0.5116, 0.5649, 0.533]}, {"w": "of", "b": [0.5703, 0.5116, 0.5871, 0.533]}, {"w": "custom", "b": [0.5924, 0.5116, 0.654, 0.533]}, {"w": "function.", "b": [0.6594, 0.5116, 0.7355, 0.533]}, {"w": "These", "b": [0.7409, 0.5116, 0.7902, 0.533]}, {"w": "custom", "b": [0.7956, 0.5116, 0.8571, 0.533]}, {"w": "functions", "b": [0.1429, 0.5307, 0.2219, 0.5521]}, {"w": "can", "b": [0.2266, 0.5307, 0.256, 0.5521]}, {"w": "then", "b": [0.2607, 0.5307, 0.2984, 0.5521]}, {"w": "be", "b": [0.3032, 0.5307, 0.3226, 0.5521]}, {"w": "used", "b": [0.3273, 0.5307, 0.3659, 0.5521]}, {"w": "normally,", "b": [0.3706, 0.5307, 0.4499, 0.5521]}, {"w": "for", "b": [0.4547, 0.5307, 0.4792, 0.5521]}, {"w": "example:", "b": [0.4839, 0.5307, 0.5582, 0.5521]}]}, {"id": "b_7", "type": "paragraph", "text": "layer = keras.layers.Dense(30, activation=my_softplus, kernel_initializer=my_glorot_initializer, kernel_regularizer=my_l1_regularizer, kernel_constraint=my_positive_weights)", "words": [{"w": "layer", "b": [0.1766, 0.5626, 0.2188, 0.5755]}, {"w": "=", "b": [0.2272, 0.5626, 0.2356, 0.5755]}, {"w": "keras.layers.Dense(30,", "b": [0.2441, 0.5626, 0.4296, 0.5755]}, {"w": "activation=my_softplus,", "b": [0.438, 0.5626, 0.632, 0.5755]}, {"w": "kernel_initializer=my_glorot_initializer,", "b": [0.4043, 0.5781, 0.75, 0.5909]}, {"w": "kernel_regularizer=my_l1_regularizer,", "b": [0.4043, 0.5935, 0.7163, 0.6063]}, {"w": "kernel_constraint=my_positive_weights)", "b": [0.4043, 0.6089, 0.7247, 0.6217]}]}, {"id": "b_8", "type": "paragraph", "text": "The activation function will be applied to the output of this Dense layer, and its result will be passed on to the next layer. The layer’s weights will be initialized using the value returned by the initializer. At each training step the weights will be passed to the regularization function to compute the regularization loss, which will be added to the main loss to get the final loss used for training. Finally, the constraint function will be called after each training step, and the layer’s weights will be replaced by the con‐ strained weights.", "words": [{"w": "The", "b": [0.1429, 0.6304, 0.1757, 0.6518]}, {"w": "activation", "b": [0.1809, 0.6304, 0.2632, 0.6518]}, {"w": "function", "b": [0.2684, 0.6304, 0.3398, 0.6518]}, {"w": "will", "b": [0.345, 0.6304, 0.3754, 0.6518]}, {"w": "be", "b": [0.3806, 0.6304, 0.4001, 0.6518]}, {"w": "applied", "b": [0.4053, 0.6304, 0.4666, 0.6518]}, {"w": "to", "b": [0.4718, 0.6304, 0.4888, 0.6518]}, {"w": "the", "b": [0.494, 0.6304, 0.5203, 0.6518]}, {"w": "output", "b": [0.5256, 0.6304, 0.5819, 0.6518]}, {"w": "of", "b": [0.5872, 0.6304, 0.6039, 0.6518]}, {"w": "this", "b": [0.6092, 0.6304, 0.6399, 0.6518]}, {"w": "Dense", "b": [0.6451, 0.6336, 0.6946, 0.6487]}, {"w": "layer,", "b": [0.6998, 0.6304, 0.7434, 0.6518]}, {"w": "and", "b": [0.7487, 0.6304, 0.7802, 0.6518]}, {"w": "its", "b": [0.7854, 0.6304, 0.805, 0.6518]}, {"w": "result", "b": [0.8102, 0.6304, 0.8571, 0.6518]}, {"w": "will", "b": [0.1429, 0.6495, 0.1732, 0.6709]}, {"w": "be", "b": [0.1808, 0.6495, 0.2002, 0.6709]}, {"w": "passed", "b": [0.2077, 0.6495, 0.2629, 0.6709]}, {"w": "on", "b": [0.2704, 0.6495, 0.2924, 0.6709]}, {"w": "to", "b": [0.2999, 0.6495, 0.3169, 0.6709]}, {"w": "the", "b": [0.3244, 0.6495, 0.3508, 0.6709]}, {"w": "next", "b": [0.3583, 0.6495, 0.3947, 0.6709]}, {"w": "layer.", "b": [0.4022, 0.6495, 0.4458, 0.6709]}, {"w": "The", "b": [0.4534, 0.6495, 0.4862, 0.6709]}, {"w": "layer’s", "b": [0.4937, 0.6495, 0.5442, 0.6709]}, {"w": "weights", "b": [0.5517, 0.6495, 0.6149, 0.6709]}, {"w": "will", "b": [0.6224, 0.6495, 0.6528, 0.6709]}, {"w": "be", "b": [0.6603, 0.6495, 0.6797, 0.6709]}, {"w": "initialized", "b": [0.6872, 0.6495, 0.7704, 0.6709]}, {"w": "using", "b": [0.7779, 0.6495, 0.8233, 0.6709]}, {"w": "the", "b": [0.8308, 0.6495, 0.8571, 0.6709]}, {"w": "value", "b": [0.1428, 0.6685, 0.1868, 0.6899]}, {"w": "returned", "b": [0.1916, 0.6685, 0.2645, 0.6899]}, {"w": "by", "b": [0.2693, 0.6685, 0.2894, 0.6899]}, {"w": "the", "b": [0.2941, 0.6685, 0.3205, 0.6899]}, {"w": "initializer.", "b": [0.3252, 0.6685, 0.4085, 0.6899]}, {"w": "At", "b": [0.4132, 0.6685, 0.4331, 0.6899]}, {"w": "each", "b": [0.4378, 0.6685, 0.4758, 0.6899]}, {"w": "training", "b": [0.4805, 0.6685, 0.5474, 0.6899]}, {"w": "step", "b": [0.5522, 0.6685, 0.5859, 0.6899]}, {"w": "the", "b": [0.5907, 0.6685, 0.617, 0.6899]}, {"w": "weights", "b": [0.6217, 0.6685, 0.6849, 0.6899]}, {"w": "will", "b": [0.6896, 0.6685, 0.72, 0.6899]}, {"w": "be", "b": [0.7248, 0.6685, 0.7442, 0.6899]}, {"w": "passed", "b": [0.7489, 0.6685, 0.8041, 0.6899]}, {"w": "to", "b": [0.8089, 0.6685, 0.8258, 0.6899]}, {"w": "the", "b": [0.8306, 0.6685, 0.8569, 0.6899]}, {"w": "regularization", "b": [0.1428, 0.6876, 0.2594, 0.709]}, {"w": "function", "b": [0.2646, 0.6876, 0.336, 0.709]}, {"w": "to", "b": [0.3412, 0.6876, 0.3582, 0.709]}, {"w": "compute", "b": [0.3633, 0.6876, 0.4366, 0.709]}, {"w": "the", "b": [0.4418, 0.6876, 0.4681, 0.709]}, {"w": "regularization", "b": [0.4733, 0.6876, 0.5899, 0.709]}, {"w": "loss,", "b": [0.5951, 0.6876, 0.631, 0.709]}, {"w": "which", "b": [0.6362, 0.6876, 0.6871, 0.709]}, {"w": "will", "b": [0.6923, 0.6876, 0.7227, 0.709]}, {"w": "be", "b": [0.7279, 0.6876, 0.7473, 0.709]}, {"w": "added", "b": [0.7525, 0.6876, 0.8035, 0.709]}, {"w": "to", "b": [0.8086, 0.6876, 0.8256, 0.709]}, {"w": "the", "b": [0.8308, 0.6876, 0.8571, 0.709]}, {"w": "main", "b": [0.1429, 0.7066, 0.186, 0.728]}, {"w": "loss", "b": [0.1911, 0.7066, 0.2223, 0.728]}, {"w": "to", "b": [0.2273, 0.7066, 0.2443, 0.728]}, {"w": "get", "b": [0.2493, 0.7066, 0.2743, 0.728]}, {"w": "the", "b": [0.2793, 0.7066, 0.3056, 0.728]}, {"w": "final", "b": [0.3107, 0.7066, 0.3482, 0.728]}, {"w": "loss", "b": [0.3532, 0.7066, 0.3844, 0.728]}, {"w": "used", "b": [0.3895, 0.7066, 0.428, 0.728]}, {"w": "for", "b": [0.4331, 0.7066, 0.4576, 0.728]}, {"w": "training.", "b": [0.4626, 0.7066, 0.5343, 0.728]}, {"w": "Finally,", "b": [0.5393, 0.7066, 0.5998, 0.728]}, {"w": "the", "b": [0.6048, 0.7066, 0.6312, 0.728]}, {"w": "constraint", "b": [0.6362, 0.7066, 0.7208, 0.728]}, {"w": "function", "b": [0.7259, 0.7066, 0.7973, 0.728]}, {"w": "will", "b": [0.8023, 0.7066, 0.8327, 0.728]}, {"w": "be", "b": [0.8377, 0.7066, 0.8571, 0.728]}, {"w": "called", "b": [0.1429, 0.7257, 0.1912, 0.7471]}, {"w": "after", "b": [0.1989, 0.7257, 0.2372, 0.7471]}, {"w": "each", "b": [0.2449, 0.7257, 0.2829, 0.7471]}, {"w": "training", "b": [0.2906, 0.7257, 0.3575, 0.7471]}, {"w": "step,", "b": [0.3652, 0.7257, 0.4032, 0.7471]}, {"w": "and", "b": [0.4109, 0.7257, 0.4424, 0.7471]}, {"w": "the", "b": [0.4502, 0.7257, 0.4765, 0.7471]}, {"w": "layer’s", "b": [0.4842, 0.7257, 0.5347, 0.7471]}, {"w": "weights", "b": [0.5424, 0.7257, 0.6056, 0.7471]}, {"w": "will", "b": [0.6134, 0.7257, 0.6438, 0.7471]}, {"w": "be", "b": [0.6515, 0.7257, 0.6709, 0.7471]}, {"w": "replaced", "b": [0.6786, 0.7257, 0.7492, 0.7471]}, {"w": "by", "b": [0.757, 0.7257, 0.7771, 0.7471]}, {"w": "the", "b": [0.7848, 0.7257, 0.8112, 0.7471]}, {"w": "con‐", "b": [0.8189, 0.7257, 0.8571, 0.7471]}, {"w": "strained", "b": [0.1429, 0.7447, 0.2106, 0.7661]}, {"w": "weights.", "b": [0.2153, 0.7447, 0.2832, 0.7661]}]}, {"id": "b_9", "type": "paragraph", "text": "If a function has some hyperparameters that need to be saved along with the model, then you will want to subclass the appropriate class, such as keras.regulariz ers.Regularizer, keras.constraints.Constraint, keras.initializers.Initial izer or keras.layers.Layer (for any layer, including activation functions). For example, much like we did for the custom loss, here is a simple class for ℓ1 regulariza‐", "words": [{"w": "If", "b": [0.1429, 0.7728, 0.1561, 0.7942]}, {"w": "a", "b": [0.1622, 0.7728, 0.1713, 0.7942]}, {"w": "function", "b": [0.1774, 0.7728, 0.2488, 0.7942]}, {"w": "has", "b": [0.2548, 0.7728, 0.2827, 0.7942]}, {"w": "some", "b": [0.2888, 0.7728, 0.333, 0.7942]}, {"w": "hyperparameters", "b": [0.339, 0.7728, 0.4802, 0.7942]}, {"w": "that", "b": [0.4862, 0.7728, 0.5188, 0.7942]}, {"w": "need", "b": [0.5249, 0.7728, 0.565, 0.7942]}, {"w": "to", "b": [0.571, 0.7728, 0.588, 0.7942]}, {"w": "be", "b": [0.5941, 0.7728, 0.6135, 0.7942]}, {"w": "saved", "b": [0.6196, 0.7728, 0.6655, 0.7942]}, {"w": "along", "b": [0.6716, 0.7728, 0.7177, 0.7942]}, {"w": "with", "b": [0.7238, 0.7728, 0.7611, 0.7942]}, {"w": "the", "b": [0.7672, 0.7728, 0.7935, 0.7942]}, {"w": "model,", "b": [0.7996, 0.7728, 0.8571, 0.7942]}, {"w": "then", "b": [0.1429, 0.7928, 0.1806, 0.8142]}, {"w": "you", "b": [0.1909, 0.7928, 0.2222, 0.8142]}, {"w": "will", "b": [0.2325, 0.7928, 0.2629, 0.8142]}, {"w": "want", "b": [0.2732, 0.7928, 0.3139, 0.8142]}, {"w": "to", "b": [0.3243, 0.7928, 0.3412, 0.8142]}, {"w": "subclass", "b": [0.3516, 0.7928, 0.4194, 0.8142]}, {"w": "the", "b": [0.4297, 0.7928, 0.456, 0.8142]}, {"w": "appropriate", "b": [0.4663, 0.7928, 0.5634, 0.8142]}, {"w": "class,", "b": [0.5738, 0.7928, 0.617, 0.8142]}, {"w": "such", "b": [0.6273, 0.7928, 0.666, 0.8142]}, {"w": "as", "b": [0.6763, 0.7928, 0.6931, 0.8142]}, {"w": "keras.regulariz", "b": [0.7034, 0.796, 0.8518, 0.811]}, {"w": "ers.Regularizer,", "b": [0.1428, 0.8127, 0.296, 0.8341]}, {"w": "keras.constraints.Constraint,", "b": [0.305, 0.8127, 0.5868, 0.8341]}, {"w": "keras.initializers.Initial", "b": [0.5958, 0.8159, 0.8531, 0.831]}, {"w": "izer", "b": [0.1429, 0.8358, 0.1824, 0.8509]}, {"w": "or", "b": [0.1926, 0.8327, 0.2109, 0.8541]}, {"w": "keras.layers.Layer", "b": [0.2211, 0.8358, 0.3992, 0.8509]}, {"w": "(for", "b": [0.4093, 0.8327, 0.441, 0.8541]}, {"w": "any", "b": [0.4512, 0.8327, 0.4808, 0.8541]}, {"w": "layer,", "b": [0.4909, 0.8327, 0.5345, 0.8541]}, {"w": "including", "b": [0.5447, 0.8327, 0.6245, 0.8541]}, {"w": "activation", "b": [0.6347, 0.8327, 0.7169, 0.8541]}, {"w": "functions).", "b": [0.727, 0.8327, 0.818, 0.8541]}, {"w": "For", "b": [0.8282, 0.8327, 0.8571, 0.8541]}, {"w": "example,", "b": [0.1429, 0.8517, 0.2171, 0.8731]}, {"w": "much", "b": [0.2222, 0.8517, 0.2699, 0.8731]}, {"w": "like", "b": [0.275, 0.8517, 0.305, 0.8731]}, {"w": "we", "b": [0.3101, 0.8517, 0.3332, 0.8731]}, {"w": "did", "b": [0.3383, 0.8517, 0.3659, 0.8731]}, {"w": "for", "b": [0.371, 0.8517, 0.3955, 0.8731]}, {"w": "the", "b": [0.4006, 0.8517, 0.4269, 0.8731]}, {"w": "custom", "b": [0.432, 0.8517, 0.4936, 0.8731]}, {"w": "loss,", "b": [0.4986, 0.8517, 0.5346, 0.8731]}, {"w": "here", "b": [0.5397, 0.8517, 0.5762, 0.8731]}, {"w": "is", "b": [0.5813, 0.8517, 0.5945, 0.8731]}, {"w": "a", "b": [0.5996, 0.8517, 0.6088, 0.8731]}, {"w": "simple", "b": [0.6138, 0.8517, 0.6688, 0.8731]}, {"w": "class", "b": [0.6739, 0.8517, 0.7124, 0.8731]}, {"w": "for", "b": [0.7175, 0.8517, 0.742, 0.8731]}, {"w": "ℓ1", "b": [0.7471, 0.8517, 0.7616, 0.874]}, {"w": "regulariza‐", "b": [0.7667, 0.8517, 0.8571, 0.8731]}]}, {"id": "b_10", "type": "paragraph", "text": "Customizing Models and Training Algorithms | 379", "words": [{"w": "Customizing", "b": [0.5328, 0.9225, 0.6056, 0.9388]}, {"w": "Models", "b": [0.6084, 0.9225, 0.6507, 0.9388]}, {"w": "and", "b": [0.6535, 0.9225, 0.6759, 0.9388]}, {"w": "Training", "b": [0.6787, 0.9225, 0.7278, 0.9388]}, {"w": "Algorithms", "b": [0.7306, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "379", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 406, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 However, the Huber loss is seldom used as a metric (the MAE or MSE are preferred).", "words": [{"w": "6", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "However,", "b": [0.1587, 0.8749, 0.2188, 0.8912]}, {"w": "the", "b": [0.2224, 0.8749, 0.2425, 0.8912]}, {"w": "Huber", "b": [0.2461, 0.8749, 0.2867, 0.8912]}, {"w": "loss", "b": [0.2903, 0.8749, 0.3141, 0.8912]}, {"w": "is", "b": [0.3177, 0.8749, 0.3278, 0.8912]}, {"w": "seldom", "b": [0.3314, 0.8749, 0.3775, 0.8912]}, {"w": "used", "b": [0.3811, 0.8749, 0.4104, 0.8912]}, {"w": "as", "b": [0.414, 0.8749, 0.4268, 0.8912]}, {"w": "a", "b": [0.4304, 0.8749, 0.4374, 0.8912]}, {"w": "metric", "b": [0.441, 0.8749, 0.4825, 0.8912]}, {"w": "(the", "b": [0.4861, 0.8749, 0.5116, 0.8912]}, {"w": "MAE", "b": [0.5152, 0.8749, 0.5493, 0.8912]}, {"w": "or", "b": [0.553, 0.8749, 0.5669, 0.8912]}, {"w": "MSE", "b": [0.5705, 0.8749, 0.6012, 0.8912]}, {"w": "are", "b": [0.6048, 0.8749, 0.6244, 0.8912]}, {"w": "preferred).", "b": [0.628, 0.8749, 0.6964, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "tion, that saves its factor hyperparameter (this time we do not need to call the parent constructor or the get_config() method, as they are not defined by the parent class):", "words": [{"w": "tion,", "b": [0.1429, 0.08, 0.1816, 0.1014]}, {"w": "that", "b": [0.1863, 0.08, 0.2189, 0.1014]}, {"w": "saves", "b": [0.2236, 0.08, 0.2662, 0.1014]}, {"w": "its", "b": [0.2709, 0.08, 0.2905, 0.1014]}, {"w": "factor", "b": [0.2958, 0.0831, 0.3552, 0.0982]}, {"w": "hyperparameter", "b": [0.3601, 0.08, 0.4936, 0.1014]}, {"w": "(this", "b": [0.4984, 0.08, 0.5364, 0.1014]}, {"w": "time", "b": [0.5412, 0.08, 0.5791, 0.1014]}, {"w": "we", "b": [0.584, 0.08, 0.6071, 0.1014]}, {"w": "do", "b": [0.612, 0.08, 0.6336, 0.1014]}, {"w": "not", "b": [0.6385, 0.08, 0.6668, 0.1014]}, {"w": "need", "b": [0.6717, 0.08, 0.7118, 0.1014]}, {"w": "to", "b": [0.7167, 0.08, 0.7337, 0.1014]}, {"w": "call", "b": [0.7386, 0.08, 0.7671, 0.1014]}, {"w": "the", "b": [0.7719, 0.08, 0.7983, 0.1014]}, {"w": "parent", "b": [0.8031, 0.08, 0.8571, 0.1014]}, {"w": "constructor", "b": [0.1429, 0.0999, 0.24, 0.1213]}, {"w": "or", "b": [0.2447, 0.0999, 0.2631, 0.1213]}, {"w": "the", "b": [0.2678, 0.0999, 0.2941, 0.1213]}, {"w": "get_config()", "b": [0.2989, 0.1031, 0.4176, 0.1182]}, {"w": "method,", "b": [0.4224, 0.0999, 0.4921, 0.1213]}, {"w": "as", "b": [0.4969, 0.0999, 0.5136, 0.1213]}, {"w": "they", "b": [0.5184, 0.0999, 0.5543, 0.1213]}, {"w": "are", "b": [0.559, 0.0999, 0.5847, 0.1213]}, {"w": "not", "b": [0.5895, 0.0999, 0.6178, 0.1213]}, {"w": "defined", "b": [0.6226, 0.0999, 0.6854, 0.1213]}, {"w": "by", "b": [0.6901, 0.0999, 0.7103, 0.1213]}, {"w": "the", "b": [0.715, 0.0999, 0.7414, 0.1213]}, {"w": "parent", "b": [0.7461, 0.0999, 0.8001, 0.1213]}, {"w": "class):", "b": [0.8048, 0.0999, 0.8553, 0.1213]}]}, {"id": "b_2", "type": "paragraph", "text": "class MyL1Regularizer(keras.regularizers.Regularizer): def __init__(self, factor): self.factor = factor def __call__(self, weights): return tf.reduce_sum(tf.abs(self.factor * weights)) def get_config(self): return {\"factor\": self.factor}", "words": [{"w": "class", "b": [0.1766, 0.1319, 0.2188, 0.1447]}, {"w": "MyL1Regularizer(keras.regularizers.Regularizer):", "b": [0.2272, 0.1319, 0.6319, 0.1447]}, {"w": "def", "b": [0.2103, 0.1473, 0.2356, 0.1601]}, {"w": "__init__(self,", "b": [0.2441, 0.1473, 0.3621, 0.1601]}, {"w": "factor):", "b": [0.3705, 0.1473, 0.438, 0.1601]}, {"w": "self.factor", "b": [0.2441, 0.1627, 0.3368, 0.1756]}, {"w": "=", "b": [0.3452, 0.1627, 0.3537, 0.1756]}, {"w": "factor", "b": [0.3621, 0.1627, 0.4127, 0.1756]}, {"w": "def", "b": [0.2103, 0.1781, 0.2356, 0.191]}, {"w": "__call__(self,", "b": [0.2441, 0.1781, 0.3621, 0.191]}, {"w": "weights):", "b": [0.3705, 0.1781, 0.4464, 0.191]}, {"w": "return", "b": [0.2441, 0.1936, 0.2946, 0.2064]}, {"w": "tf.reduce_sum(tf.abs(self.factor", "b": [0.3031, 0.1936, 0.5729, 0.2064]}, {"w": "*", "b": [0.5814, 0.1936, 0.5898, 0.2064]}, {"w": "weights))", "b": [0.5982, 0.1936, 0.6741, 0.2064]}, {"w": "def", "b": [0.2103, 0.209, 0.2356, 0.2218]}, {"w": "get_config(self):", "b": [0.2441, 0.209, 0.3874, 0.2218]}, {"w": "return", "b": [0.2441, 0.2244, 0.2946, 0.2372]}, {"w": "{\"factor\":", "b": [0.3031, 0.2244, 0.3874, 0.2372]}, {"w": "self.factor}", "b": [0.3958, 0.2244, 0.497, 0.2372]}]}, {"id": "b_3", "type": "paragraph", "text": "Note that you must implement the call() method for losses, layers (including activa‐ tion functions) and models, or the __call__() method for regularizers, initializers and constraints. For metrics, things are a bit different, as we will see now.", "words": [{"w": "Note", "b": [0.1429, 0.2459, 0.1837, 0.2673]}, {"w": "that", "b": [0.1885, 0.2459, 0.2211, 0.2673]}, {"w": "you", "b": [0.226, 0.2459, 0.2573, 0.2673]}, {"w": "must", "b": [0.2622, 0.2459, 0.3039, 0.2673]}, {"w": "implement", "b": [0.3088, 0.2459, 0.3993, 0.2673]}, {"w": "the", "b": [0.4042, 0.2459, 0.4306, 0.2673]}, {"w": "call()", "b": [0.4355, 0.2491, 0.4948, 0.2642]}, {"w": "method", "b": [0.4997, 0.2459, 0.5647, 0.2673]}, {"w": "for", "b": [0.5696, 0.2459, 0.5942, 0.2673]}, {"w": "losses,", "b": [0.599, 0.2459, 0.6515, 0.2673]}, {"w": "layers", "b": [0.6564, 0.2459, 0.7042, 0.2673]}, {"w": "(including", "b": [0.7091, 0.2459, 0.7962, 0.2673]}, {"w": "activa‐", "b": [0.801, 0.2459, 0.8572, 0.2673]}, {"w": "tion", "b": [0.1429, 0.2659, 0.1768, 0.2873]}, {"w": "functions)", "b": [0.1842, 0.2659, 0.2705, 0.2873]}, {"w": "and", "b": [0.2778, 0.2659, 0.3094, 0.2873]}, {"w": "models,", "b": [0.3168, 0.2659, 0.382, 0.2873]}, {"w": "or", "b": [0.3893, 0.2659, 0.4077, 0.2873]}, {"w": "the", "b": [0.4151, 0.2659, 0.4414, 0.2873]}, {"w": "__call__()", "b": [0.4488, 0.2691, 0.5478, 0.2841]}, {"w": "method", "b": [0.5551, 0.2659, 0.6202, 0.2873]}, {"w": "for", "b": [0.6275, 0.2659, 0.6521, 0.2873]}, {"w": "regularizers,", "b": [0.6594, 0.2659, 0.7623, 0.2873]}, {"w": "initializers", "b": [0.7697, 0.2659, 0.8571, 0.2873]}, {"w": "and", "b": [0.1429, 0.2849, 0.1744, 0.3063]}, {"w": "constraints.", "b": [0.1791, 0.2849, 0.2762, 0.3063]}, {"w": "For", "b": [0.2809, 0.2849, 0.3099, 0.3063]}, {"w": "metrics,", "b": [0.3146, 0.2849, 0.3814, 0.3063]}, {"w": "things", "b": [0.3861, 0.2849, 0.438, 0.3063]}, {"w": "are", "b": [0.4427, 0.2849, 0.4684, 0.3063]}, {"w": "a", "b": [0.4732, 0.2849, 0.4823, 0.3063]}, {"w": "bit", "b": [0.487, 0.2849, 0.5096, 0.3063]}, {"w": "different,", "b": [0.5143, 0.2849, 0.5908, 0.3063]}, {"w": "as", "b": [0.5955, 0.2849, 0.6123, 0.3063]}, {"w": "we", "b": [0.617, 0.2849, 0.6401, 0.3063]}, {"w": "will", "b": [0.6449, 0.2849, 0.6753, 0.3063]}, {"w": "see", "b": [0.68, 0.2849, 0.7053, 0.3063]}, {"w": "now.", "b": [0.7101, 0.2849, 0.7496, 0.3063]}]}, {"id": "b_4", "type": "paragraph", "text": "Custom Metrics", "words": [{"w": "Custom", "b": [0.1428, 0.3191, 0.2201, 0.3477]}, {"w": "Metrics", "b": [0.2251, 0.3191, 0.3001, 0.3477]}]}, {"id": "b_5", "type": "paragraph", "text": "Losses and metrics are conceptually not the same thing: losses are used by Gradient Descent to train a model, so they must be differentiable (at least where they are evalu‐ ated) and their gradients should not be 0 everywhere. Plus, it’s okay if they are not easily interpretable by humans (e.g. cross-entropy). In contrast, metrics are used to evaluate a model, they must be more easily interpretable, and they can be non- differentiable or have 0 gradients everywhere (e.g., accuracy).", "words": [{"w": "Losses", "b": [0.1429, 0.3536, 0.1965, 0.375]}, {"w": "and", "b": [0.2028, 0.3536, 0.2344, 0.375]}, {"w": "metrics", "b": [0.2407, 0.3536, 0.3027, 0.375]}, {"w": "are", "b": [0.309, 0.3536, 0.3348, 0.375]}, {"w": "conceptually", "b": [0.3411, 0.3536, 0.4472, 0.375]}, {"w": "not", "b": [0.4535, 0.3536, 0.4819, 0.375]}, {"w": "the", "b": [0.4882, 0.3536, 0.5145, 0.375]}, {"w": "same", "b": [0.5209, 0.3536, 0.5636, 0.375]}, {"w": "thing:", "b": [0.5699, 0.3536, 0.6189, 0.375]}, {"w": "losses", "b": [0.6252, 0.3536, 0.6729, 0.375]}, {"w": "are", "b": [0.6792, 0.3536, 0.7049, 0.375]}, {"w": "used", "b": [0.7112, 0.3536, 0.7498, 0.375]}, {"w": "by", "b": [0.7561, 0.3536, 0.7763, 0.375]}, {"w": "Gradient", "b": [0.7826, 0.3536, 0.8572, 0.375]}, {"w": "Descent", "b": [0.1429, 0.3726, 0.2097, 0.394]}, {"w": "to", "b": [0.2144, 0.3726, 0.2314, 0.394]}, {"w": "train", "b": [0.2366, 0.3724, 0.2764, 0.394]}, {"w": "a", "b": [0.2813, 0.3726, 0.2904, 0.394]}, {"w": "model,", "b": [0.2954, 0.3726, 0.3529, 0.394]}, {"w": "so", "b": [0.3579, 0.3726, 0.3762, 0.394]}, {"w": "they", "b": [0.3811, 0.3726, 0.417, 0.394]}, {"w": "must", "b": [0.4219, 0.3726, 0.4636, 0.394]}, {"w": "be", "b": [0.4686, 0.3726, 0.488, 0.394]}, {"w": "differentiable", "b": [0.493, 0.3726, 0.6041, 0.394]}, {"w": "(at", "b": [0.609, 0.3726, 0.6314, 0.394]}, {"w": "least", "b": [0.6363, 0.3726, 0.6736, 0.394]}, {"w": "where", "b": [0.6785, 0.3726, 0.7293, 0.394]}, {"w": "they", "b": [0.7343, 0.3726, 0.7702, 0.394]}, {"w": "are", "b": [0.7751, 0.3726, 0.8008, 0.394]}, {"w": "evalu‐", "b": [0.8058, 0.3726, 0.8572, 0.394]}, {"w": "ated)", "b": [0.1429, 0.3917, 0.185, 0.4131]}, {"w": "and", "b": [0.1921, 0.3917, 0.2236, 0.4131]}, {"w": "their", "b": [0.2306, 0.3917, 0.2703, 0.4131]}, {"w": "gradients", "b": [0.2773, 0.3917, 0.3543, 0.4131]}, {"w": "should", "b": [0.3614, 0.3917, 0.4181, 0.4131]}, {"w": "not", "b": [0.4251, 0.3917, 0.4535, 0.4131]}, {"w": "be", "b": [0.4605, 0.3917, 0.4799, 0.4131]}, {"w": "0", "b": [0.487, 0.3917, 0.497, 0.4131]}, {"w": "everywhere.", "b": [0.504, 0.3917, 0.6048, 0.4131]}, {"w": "Plus,", "b": [0.6118, 0.3917, 0.6523, 0.4131]}, {"w": "it’s", "b": [0.6593, 0.3917, 0.681, 0.4131]}, {"w": "okay", "b": [0.688, 0.3917, 0.7273, 0.4131]}, {"w": "if", "b": [0.7343, 0.3917, 0.7461, 0.4131]}, {"w": "they", "b": [0.7531, 0.3917, 0.789, 0.4131]}, {"w": "are", "b": [0.796, 0.3917, 0.8218, 0.4131]}, {"w": "not", "b": [0.8288, 0.3917, 0.8571, 0.4131]}, {"w": "easily", "b": [0.1429, 0.4107, 0.1889, 0.4321]}, {"w": "interpretable", "b": [0.196, 0.4107, 0.3032, 0.4321]}, {"w": "by", "b": [0.3102, 0.4107, 0.3304, 0.4321]}, {"w": "humans", "b": [0.3374, 0.4107, 0.4044, 0.4321]}, {"w": "(e.g.", "b": [0.4115, 0.4107, 0.4468, 0.4321]}, {"w": "cross-entropy).", "b": [0.4538, 0.4107, 0.5807, 0.4321]}, {"w": "In", "b": [0.5877, 0.4107, 0.6062, 0.4321]}, {"w": "contrast,", "b": [0.6133, 0.4107, 0.6857, 0.4321]}, {"w": "metrics", "b": [0.6927, 0.4107, 0.7548, 0.4321]}, {"w": "are", "b": [0.7618, 0.4107, 0.7875, 0.4321]}, {"w": "used", "b": [0.7946, 0.4107, 0.8331, 0.4321]}, {"w": "to", "b": [0.8402, 0.4107, 0.8571, 0.4321]}, {"w": "evaluate", "b": [0.1429, 0.4295, 0.2107, 0.4512]}, {"w": "a", "b": [0.2202, 0.4298, 0.2293, 0.4512]}, {"w": "model,", "b": [0.2388, 0.4298, 0.2964, 0.4512]}, {"w": "they", "b": [0.3058, 0.4298, 0.3417, 0.4512]}, {"w": "must", "b": [0.3512, 0.4298, 0.393, 0.4512]}, {"w": "be", "b": [0.4024, 0.4298, 0.4219, 0.4512]}, {"w": "more", "b": [0.4314, 0.4298, 0.4756, 0.4512]}, {"w": "easily", "b": [0.4851, 0.4298, 0.5312, 0.4512]}, {"w": "interpretable,", "b": [0.5407, 0.4298, 0.6526, 0.4512]}, {"w": "and", "b": [0.6621, 0.4298, 0.6937, 0.4512]}, {"w": "they", "b": [0.7032, 0.4298, 0.7391, 0.4512]}, {"w": "can", "b": [0.7485, 0.4298, 0.7779, 0.4512]}, {"w": "be", "b": [0.7874, 0.4298, 0.8068, 0.4512]}, {"w": "non-", "b": [0.8163, 0.4298, 0.8571, 0.4512]}, {"w": "differentiable", "b": [0.1429, 0.4488, 0.254, 0.4702]}, {"w": "or", "b": [0.2587, 0.4488, 0.2771, 0.4702]}, {"w": "have", "b": [0.2818, 0.4488, 0.3202, 0.4702]}, {"w": "0", "b": [0.3249, 0.4488, 0.3349, 0.4702]}, {"w": "gradients", "b": [0.3397, 0.4488, 0.4167, 0.4702]}, {"w": "everywhere", "b": [0.4215, 0.4488, 0.5176, 0.4702]}, {"w": "(e.g.,", "b": [0.5223, 0.4488, 0.5623, 0.4702]}, {"w": "accuracy).", "b": [0.5671, 0.4488, 0.6521, 0.4702]}]}, {"id": "b_6", "type": "paragraph", "text": "That said, in most cases, defining a custom metric function is exactly the same as defining a custom loss function. In fact, we could even use the Huber loss function we created earlier as a metric6, it would work just fine (and persistence would also work the same way, in this case only saving the name of the function, \"huber_fn\"):", "words": [{"w": "That", "b": [0.1429, 0.4769, 0.1819, 0.4983]}, {"w": "said,", "b": [0.1897, 0.4769, 0.2278, 0.4983]}, {"w": "in", "b": [0.2356, 0.4769, 0.2525, 0.4983]}, {"w": "most", "b": [0.2603, 0.4769, 0.302, 0.4983]}, {"w": "cases,", "b": [0.3097, 0.4769, 0.3566, 0.4983]}, {"w": "defining", "b": [0.3643, 0.4769, 0.4341, 0.4983]}, {"w": "a", "b": [0.4418, 0.4769, 0.4509, 0.4983]}, {"w": "custom", "b": [0.4587, 0.4769, 0.5202, 0.4983]}, {"w": "metric", "b": [0.528, 0.4769, 0.5824, 0.4983]}, {"w": "function", "b": [0.5901, 0.4769, 0.6615, 0.4983]}, {"w": "is", "b": [0.6693, 0.4769, 0.6825, 0.4983]}, {"w": "exactly", "b": [0.6902, 0.4769, 0.7481, 0.4983]}, {"w": "the", "b": [0.7558, 0.4769, 0.7822, 0.4983]}, {"w": "same", "b": [0.7899, 0.4769, 0.8326, 0.4983]}, {"w": "as", "b": [0.8404, 0.4769, 0.8572, 0.4983]}, {"w": "defining", "b": [0.1429, 0.496, 0.2126, 0.5174]}, {"w": "a", "b": [0.2173, 0.496, 0.2265, 0.5174]}, {"w": "custom", "b": [0.2312, 0.496, 0.2928, 0.5174]}, {"w": "loss", "b": [0.2975, 0.496, 0.3287, 0.5174]}, {"w": "function.", "b": [0.3334, 0.496, 0.4095, 0.5174]}, {"w": "In", "b": [0.4143, 0.496, 0.4328, 0.5174]}, {"w": "fact,", "b": [0.4375, 0.496, 0.4727, 0.5174]}, {"w": "we", "b": [0.4775, 0.496, 0.5006, 0.5174]}, {"w": "could", "b": [0.5053, 0.496, 0.5521, 0.5174]}, {"w": "even", "b": [0.5568, 0.496, 0.5956, 0.5174]}, {"w": "use", "b": [0.6003, 0.496, 0.6279, 0.5174]}, {"w": "the", "b": [0.6326, 0.496, 0.6589, 0.5174]}, {"w": "Huber", "b": [0.6637, 0.496, 0.717, 0.5174]}, {"w": "loss", "b": [0.7218, 0.496, 0.7529, 0.5174]}, {"w": "function", "b": [0.7577, 0.496, 0.8291, 0.5174]}, {"w": "we", "b": [0.8338, 0.496, 0.8569, 0.5174]}, {"w": "created", "b": [0.1429, 0.515, 0.2032, 0.5364]}, {"w": "earlier", "b": [0.209, 0.515, 0.2622, 0.5364]}, {"w": "as", "b": [0.268, 0.515, 0.2848, 0.5364]}, {"w": "a", "b": [0.2906, 0.515, 0.2997, 0.5364]}, {"w": "metric6,", "b": [0.3055, 0.515, 0.3704, 0.5364]}, {"w": "it", "b": [0.3762, 0.515, 0.3881, 0.5364]}, {"w": "would", "b": [0.3939, 0.515, 0.4461, 0.5364]}, {"w": "work", "b": [0.4519, 0.515, 0.4949, 0.5364]}, {"w": "just", "b": [0.5007, 0.515, 0.5311, 0.5364]}, {"w": "fine", "b": [0.5369, 0.515, 0.5689, 0.5364]}, {"w": "(and", "b": [0.5747, 0.515, 0.6134, 0.5364]}, {"w": "persistence", "b": [0.6192, 0.515, 0.7119, 0.5364]}, {"w": "would", "b": [0.7177, 0.515, 0.7699, 0.5364]}, {"w": "also", "b": [0.7757, 0.515, 0.8084, 0.5364]}, {"w": "work", "b": [0.8142, 0.515, 0.8571, 0.5364]}, {"w": "the", "b": [0.1429, 0.535, 0.1692, 0.5564]}, {"w": "same", "b": [0.1739, 0.535, 0.2166, 0.5564]}, {"w": "way,", "b": [0.2214, 0.535, 0.2572, 0.5564]}, {"w": "in", "b": [0.2619, 0.535, 0.2789, 0.5564]}, {"w": "this", "b": [0.2836, 0.535, 0.3143, 0.5564]}, {"w": "case", "b": [0.3191, 0.535, 0.3535, 0.5564]}, {"w": "only", "b": [0.3583, 0.535, 0.3951, 0.5564]}, {"w": "saving", "b": [0.3998, 0.535, 0.4526, 0.5564]}, {"w": "the", "b": [0.4574, 0.535, 0.4837, 0.5564]}, {"w": "name", "b": [0.4884, 0.535, 0.5349, 0.5564]}, {"w": "of", "b": [0.5396, 0.535, 0.5564, 0.5564]}, {"w": "the", "b": [0.5611, 0.535, 0.5875, 0.5564]}, {"w": "function,", "b": [0.5922, 0.535, 0.6683, 0.5564]}, {"w": "\"huber_fn\"):", "b": [0.6731, 0.535, 0.784, 0.5564]}]}, {"id": "b_7", "type": "equation", "text": "model.compile(loss=\"mse\", optimizer=\"nadam\", metrics=[create_huber(2.0)])", "words": [{"w": "model.compile(loss=\"mse\",", "b": [0.1766, 0.5669, 0.3874, 0.5798]}, {"w": "optimizer=\"nadam\",", "b": [0.3958, 0.5669, 0.5476, 0.5798]}, {"w": "metrics=[create_huber(2.0)])", "b": [0.556, 0.5669, 0.7922, 0.5798]}]}, {"id": "b_8", "type": "paragraph", "text": "For each batch during training, Keras will compute this metric and keep track of its mean since the beginning of the epoch. Most of the time, this is exactly what you want. But not always! Consider a binary classifier’s precision, for example. As we saw in Chapter 3, precision is the number of true positives divided by the number of posi‐ tive predictions (including both true positives and false positives). Suppose the model made 5 positive predictions in the first batch, 4 of which were correct: that’s 80% pre‐ cision. Then suppose the model made 3 positive predictions in the second batch, but they were all incorrect: that’s 0% precision for the second batch. If you just compute the mean of these two precisions, you get 40%. But wait a second, this is not the mod‐ el’s precision over these two batches! Indeed, there were a total of 4 true positives (4 + 0) out of 8 positive predictions (5 + 3), so the overall precision is 50%, not 40%. What we need is an object that can keep track of the number of true positives and the num‐", "words": [{"w": "For", "b": [0.1429, 0.5876, 0.1718, 0.609]}, {"w": "each", "b": [0.1782, 0.5876, 0.2161, 0.609]}, {"w": "batch", "b": [0.2224, 0.5876, 0.2681, 0.609]}, {"w": "during", "b": [0.2744, 0.5876, 0.3309, 0.609]}, {"w": "training,", "b": [0.3372, 0.5876, 0.4089, 0.609]}, {"w": "Keras", "b": [0.4153, 0.5876, 0.4622, 0.609]}, {"w": "will", "b": [0.4685, 0.5876, 0.4989, 0.609]}, {"w": "compute", "b": [0.5052, 0.5876, 0.5785, 0.609]}, {"w": "this", "b": [0.5848, 0.5876, 0.6155, 0.609]}, {"w": "metric", "b": [0.6219, 0.5876, 0.6763, 0.609]}, {"w": "and", "b": [0.6826, 0.5876, 0.7141, 0.609]}, {"w": "keep", "b": [0.7205, 0.5876, 0.7594, 0.609]}, {"w": "track", "b": [0.7657, 0.5876, 0.8081, 0.609]}, {"w": "of", "b": [0.8145, 0.5876, 0.8312, 0.609]}, {"w": "its", "b": [0.8376, 0.5876, 0.8572, 0.609]}, {"w": "mean", "b": [0.1429, 0.6066, 0.1893, 0.628]}, {"w": "since", "b": [0.197, 0.6066, 0.2393, 0.628]}, {"w": "the", "b": [0.2469, 0.6066, 0.2733, 0.628]}, {"w": "beginning", "b": [0.2809, 0.6066, 0.3652, 0.628]}, {"w": "of", "b": [0.3729, 0.6066, 0.3896, 0.628]}, {"w": "the", "b": [0.3973, 0.6066, 0.4236, 0.628]}, {"w": "epoch.", "b": [0.4313, 0.6066, 0.4864, 0.628]}, {"w": "Most", "b": [0.494, 0.6066, 0.5367, 0.628]}, {"w": "of", "b": [0.5443, 0.6066, 0.5611, 0.628]}, {"w": "the", "b": [0.5688, 0.6066, 0.5951, 0.628]}, {"w": "time,", "b": [0.6028, 0.6066, 0.6454, 0.628]}, {"w": "this", "b": [0.653, 0.6066, 0.6837, 0.628]}, {"w": "is", "b": [0.6914, 0.6066, 0.7046, 0.628]}, {"w": "exactly", "b": [0.7123, 0.6066, 0.7701, 0.628]}, {"w": "what", "b": [0.7777, 0.6066, 0.8182, 0.628]}, {"w": "you", "b": [0.8259, 0.6066, 0.8571, 0.628]}, {"w": "want.", "b": [0.1429, 0.6257, 0.1884, 0.6471]}, {"w": "But", "b": [0.1938, 0.6257, 0.2235, 0.6471]}, {"w": "not", "b": [0.2289, 0.6257, 0.2573, 0.6471]}, {"w": "always!", "b": [0.2627, 0.6257, 0.3231, 0.6471]}, {"w": "Consider", "b": [0.3285, 0.6257, 0.4052, 0.6471]}, {"w": "a", "b": [0.4107, 0.6257, 0.4198, 0.6471]}, {"w": "binary", "b": [0.4252, 0.6257, 0.4798, 0.6471]}, {"w": "classifier’s", "b": [0.4853, 0.6257, 0.568, 0.6471]}, {"w": "precision,", "b": [0.5734, 0.6257, 0.6553, 0.6471]}, {"w": "for", "b": [0.6608, 0.6257, 0.6853, 0.6471]}, {"w": "example.", "b": [0.6907, 0.6257, 0.765, 0.6471]}, {"w": "As", "b": [0.7704, 0.6257, 0.7925, 0.6471]}, {"w": "we", "b": [0.7979, 0.6257, 0.821, 0.6471]}, {"w": "saw", "b": [0.8265, 0.6257, 0.8571, 0.6471]}, {"w": "in", "b": [0.1429, 0.6447, 0.1598, 0.6661]}, {"w": "Chapter", "b": [0.1648, 0.6447, 0.2324, 0.6661]}, {"w": "3,", "b": [0.2371, 0.6447, 0.252, 0.6661]}, {"w": "precision", "b": [0.257, 0.6447, 0.3341, 0.6661]}, {"w": "is", "b": [0.339, 0.6447, 0.3523, 0.6661]}, {"w": "the", "b": [0.3572, 0.6447, 0.3835, 0.6661]}, {"w": "number", "b": [0.3885, 0.6447, 0.4547, 0.6661]}, {"w": "of", "b": [0.4597, 0.6447, 0.4765, 0.6661]}, {"w": "true", "b": [0.4814, 0.6447, 0.5154, 0.6661]}, {"w": "positives", "b": [0.5203, 0.6447, 0.5932, 0.6661]}, {"w": "divided", "b": [0.5981, 0.6447, 0.6608, 0.6661]}, {"w": "by", "b": [0.6657, 0.6447, 0.6858, 0.6661]}, {"w": "the", "b": [0.6908, 0.6447, 0.7171, 0.6661]}, {"w": "number", "b": [0.722, 0.6447, 0.7883, 0.6661]}, {"w": "of", "b": [0.7933, 0.6447, 0.81, 0.6661]}, {"w": "posi‐", "b": [0.815, 0.6447, 0.8572, 0.6661]}, {"w": "tive", "b": [0.1429, 0.6638, 0.1733, 0.6852]}, {"w": "predictions", "b": [0.1782, 0.6638, 0.2727, 0.6852]}, {"w": "(including", "b": [0.2777, 0.6638, 0.3647, 0.6852]}, {"w": "both", "b": [0.3697, 0.6638, 0.4084, 0.6852]}, {"w": "true", "b": [0.4133, 0.6638, 0.4473, 0.6852]}, {"w": "positives", "b": [0.4522, 0.6638, 0.5251, 0.6852]}, {"w": "and", "b": [0.53, 0.6638, 0.5615, 0.6852]}, {"w": "false", "b": [0.5665, 0.6638, 0.6036, 0.6852]}, {"w": "positives).", "b": [0.6085, 0.6638, 0.6933, 0.6852]}, {"w": "Suppose", "b": [0.6982, 0.6638, 0.7681, 0.6852]}, {"w": "the", "b": [0.7731, 0.6638, 0.7994, 0.6852]}, {"w": "model", "b": [0.8043, 0.6638, 0.8572, 0.6852]}, {"w": "made", "b": [0.1429, 0.6828, 0.1889, 0.7042]}, {"w": "5", "b": [0.1941, 0.6828, 0.2041, 0.7042]}, {"w": "positive", "b": [0.2092, 0.6828, 0.2744, 0.7042]}, {"w": "predictions", "b": [0.2796, 0.6828, 0.3741, 0.7042]}, {"w": "in", "b": [0.3792, 0.6828, 0.3962, 0.7042]}, {"w": "the", "b": [0.4014, 0.6828, 0.4277, 0.7042]}, {"w": "first", "b": [0.4328, 0.6828, 0.4663, 0.7042]}, {"w": "batch,", "b": [0.4715, 0.6828, 0.5219, 0.7042]}, {"w": "4", "b": [0.527, 0.6828, 0.537, 0.7042]}, {"w": "of", "b": [0.5422, 0.6828, 0.5589, 0.7042]}, {"w": "which", "b": [0.5641, 0.6828, 0.615, 0.7042]}, {"w": "were", "b": [0.6202, 0.6828, 0.6599, 0.7042]}, {"w": "correct:", "b": [0.665, 0.6828, 0.7287, 0.7042]}, {"w": "that’s", "b": [0.7338, 0.6828, 0.7762, 0.7042]}, {"w": "80%", "b": [0.7813, 0.6828, 0.8171, 0.7042]}, {"w": "pre‐", "b": [0.8222, 0.6828, 0.8571, 0.7042]}, {"w": "cision.", "b": [0.1429, 0.7019, 0.1972, 0.7233]}, {"w": "Then", "b": [0.2029, 0.7019, 0.2471, 0.7233]}, {"w": "suppose", "b": [0.2527, 0.7019, 0.3204, 0.7233]}, {"w": "the", "b": [0.326, 0.7019, 0.3523, 0.7233]}, {"w": "model", "b": [0.358, 0.7019, 0.4108, 0.7233]}, {"w": "made", "b": [0.4164, 0.7019, 0.4625, 0.7233]}, {"w": "3", "b": [0.4681, 0.7019, 0.4781, 0.7233]}, {"w": "positive", "b": [0.4837, 0.7019, 0.5489, 0.7233]}, {"w": "predictions", "b": [0.5545, 0.7019, 0.649, 0.7233]}, {"w": "in", "b": [0.6546, 0.7019, 0.6716, 0.7233]}, {"w": "the", "b": [0.6772, 0.7019, 0.7036, 0.7233]}, {"w": "second", "b": [0.7092, 0.7019, 0.7675, 0.7233]}, {"w": "batch,", "b": [0.7731, 0.7019, 0.8235, 0.7233]}, {"w": "but", "b": [0.8291, 0.7019, 0.8571, 0.7233]}, {"w": "they", "b": [0.1429, 0.7209, 0.1788, 0.7423]}, {"w": "were", "b": [0.1849, 0.7209, 0.2246, 0.7423]}, {"w": "all", "b": [0.2307, 0.7209, 0.2504, 0.7423]}, {"w": "incorrect:", "b": [0.2564, 0.7209, 0.3371, 0.7423]}, {"w": "that’s", "b": [0.3432, 0.7209, 0.3855, 0.7423]}, {"w": "0%", "b": [0.3916, 0.7209, 0.4174, 0.7423]}, {"w": "precision", "b": [0.4235, 0.7209, 0.5006, 0.7423]}, {"w": "for", "b": [0.5067, 0.7209, 0.5312, 0.7423]}, {"w": "the", "b": [0.5373, 0.7209, 0.5637, 0.7423]}, {"w": "second", "b": [0.5698, 0.7209, 0.6281, 0.7423]}, {"w": "batch.", "b": [0.6342, 0.7209, 0.6846, 0.7423]}, {"w": "If", "b": [0.6907, 0.7209, 0.7039, 0.7423]}, {"w": "you", "b": [0.71, 0.7209, 0.7413, 0.7423]}, {"w": "just", "b": [0.7474, 0.7209, 0.7778, 0.7423]}, {"w": "compute", "b": [0.7839, 0.7209, 0.8572, 0.7423]}, {"w": "the", "b": [0.1429, 0.7399, 0.1692, 0.7614]}, {"w": "mean", "b": [0.1741, 0.7399, 0.2206, 0.7614]}, {"w": "of", "b": [0.2255, 0.7399, 0.2423, 0.7614]}, {"w": "these", "b": [0.2472, 0.7399, 0.2901, 0.7614]}, {"w": "two", "b": [0.295, 0.7399, 0.3263, 0.7614]}, {"w": "precisions,", "b": [0.3312, 0.7399, 0.4207, 0.7614]}, {"w": "you", "b": [0.4257, 0.7399, 0.4569, 0.7614]}, {"w": "get", "b": [0.4619, 0.7399, 0.4868, 0.7614]}, {"w": "40%.", "b": [0.4917, 0.7399, 0.5322, 0.7614]}, {"w": "But", "b": [0.5372, 0.7399, 0.5668, 0.7614]}, {"w": "wait", "b": [0.5718, 0.7399, 0.6071, 0.7614]}, {"w": "a", "b": [0.6121, 0.7399, 0.6212, 0.7614]}, {"w": "second,", "b": [0.6261, 0.7399, 0.6892, 0.7614]}, {"w": "this", "b": [0.6942, 0.7399, 0.7249, 0.7614]}, {"w": "is", "b": [0.7298, 0.7399, 0.743, 0.7614]}, {"w": "not", "b": [0.748, 0.7397, 0.7748, 0.7614]}, {"w": "the", "b": [0.7798, 0.7399, 0.8061, 0.7614]}, {"w": "mod‐", "b": [0.8108, 0.7399, 0.8569, 0.7614]}, {"w": "el’s", "b": [0.1429, 0.759, 0.1668, 0.7804]}, {"w": "precision", "b": [0.1717, 0.759, 0.2488, 0.7804]}, {"w": "over", "b": [0.2538, 0.759, 0.2906, 0.7804]}, {"w": "these", "b": [0.2956, 0.759, 0.3384, 0.7804]}, {"w": "two", "b": [0.3433, 0.759, 0.3746, 0.7804]}, {"w": "batches!", "b": [0.3795, 0.759, 0.4474, 0.7804]}, {"w": "Indeed,", "b": [0.4524, 0.759, 0.5153, 0.7804]}, {"w": "there", "b": [0.5202, 0.759, 0.5632, 0.7804]}, {"w": "were", "b": [0.5681, 0.759, 0.6078, 0.7804]}, {"w": "a", "b": [0.6127, 0.759, 0.6219, 0.7804]}, {"w": "total", "b": [0.6268, 0.759, 0.6646, 0.7804]}, {"w": "of", "b": [0.6695, 0.759, 0.6863, 0.7804]}, {"w": "4", "b": [0.6913, 0.759, 0.7013, 0.7804]}, {"w": "true", "b": [0.7062, 0.759, 0.7402, 0.7804]}, {"w": "positives", "b": [0.7451, 0.759, 0.818, 0.7804]}, {"w": "(4", "b": [0.8229, 0.759, 0.8401, 0.7804]}, {"w": "+", "b": [0.8451, 0.759, 0.8572, 0.7804]}, {"w": "0)", "b": [0.1429, 0.778, 0.1601, 0.7995]}, {"w": "out", "b": [0.165, 0.778, 0.193, 0.7995]}, {"w": "of", "b": [0.198, 0.778, 0.2148, 0.7995]}, {"w": "8", "b": [0.2197, 0.778, 0.2297, 0.7995]}, {"w": "positive", "b": [0.2347, 0.778, 0.2999, 0.7995]}, {"w": "predictions", "b": [0.3048, 0.778, 0.3993, 0.7995]}, {"w": "(5", "b": [0.4042, 0.778, 0.4214, 0.7995]}, {"w": "+", "b": [0.4264, 0.778, 0.4385, 0.7995]}, {"w": "3),", "b": [0.4434, 0.778, 0.4654, 0.7995]}, {"w": "so", "b": [0.4703, 0.778, 0.4886, 0.7995]}, {"w": "the", "b": [0.4935, 0.778, 0.5198, 0.7995]}, {"w": "overall", "b": [0.5248, 0.778, 0.5813, 0.7995]}, {"w": "precision", "b": [0.5863, 0.778, 0.6634, 0.7995]}, {"w": "is", "b": [0.6683, 0.778, 0.6816, 0.7995]}, {"w": "50%,", "b": [0.6865, 0.778, 0.727, 0.7995]}, {"w": "not", "b": [0.7319, 0.778, 0.7603, 0.7995]}, {"w": "40%.", "b": [0.7653, 0.778, 0.8058, 0.7995]}, {"w": "What", "b": [0.8107, 0.778, 0.8571, 0.7995]}, {"w": "we", "b": [0.1429, 0.7971, 0.166, 0.8185]}, {"w": "need", "b": [0.171, 0.7971, 0.2111, 0.8185]}, {"w": "is", "b": [0.2162, 0.7971, 0.2294, 0.8185]}, {"w": "an", "b": [0.2345, 0.7971, 0.255, 0.8185]}, {"w": "object", "b": [0.2601, 0.7971, 0.3106, 0.8185]}, {"w": "that", "b": [0.3157, 0.7971, 0.3483, 0.8185]}, {"w": "can", "b": [0.3533, 0.7971, 0.3827, 0.8185]}, {"w": "keep", "b": [0.3878, 0.7971, 0.4267, 0.8185]}, {"w": "track", "b": [0.4318, 0.7971, 0.4741, 0.8185]}, {"w": "of", "b": [0.4792, 0.7971, 0.496, 0.8185]}, {"w": "the", "b": [0.5011, 0.7971, 0.5274, 0.8185]}, {"w": "number", "b": [0.5324, 0.7971, 0.5987, 0.8185]}, {"w": "of", "b": [0.6038, 0.7971, 0.6206, 0.8185]}, {"w": "true", "b": [0.6256, 0.7971, 0.6596, 0.8185]}, {"w": "positives", "b": [0.6647, 0.7971, 0.7376, 0.8185]}, {"w": "and", "b": [0.7426, 0.7971, 0.7742, 0.8185]}, {"w": "the", "b": [0.7792, 0.7971, 0.8055, 0.8185]}, {"w": "num‐", "b": [0.8106, 0.7971, 0.8571, 0.8185]}]}, {"id": "b_9", "type": "paragraph", "text": "380 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "380", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2745, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 407, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "ber of false positives, and compute their ratio when requested. This is precisely what the keras.metrics.Precision class does:", "words": [{"w": "ber", "b": [0.1429, 0.0791, 0.17, 0.1005]}, {"w": "of", "b": [0.1759, 0.0791, 0.1927, 0.1005]}, {"w": "false", "b": [0.1986, 0.0791, 0.2357, 0.1005]}, {"w": "positives,", "b": [0.2416, 0.0791, 0.3192, 0.1005]}, {"w": "and", "b": [0.3251, 0.0791, 0.3566, 0.1005]}, {"w": "compute", "b": [0.3625, 0.0791, 0.4358, 0.1005]}, {"w": "their", "b": [0.4417, 0.0791, 0.4813, 0.1005]}, {"w": "ratio", "b": [0.4872, 0.0791, 0.5262, 0.1005]}, {"w": "when", "b": [0.5321, 0.0791, 0.5778, 0.1005]}, {"w": "requested.", "b": [0.5837, 0.0791, 0.6694, 0.1005]}, {"w": "This", "b": [0.6753, 0.0791, 0.7125, 0.1005]}, {"w": "is", "b": [0.7184, 0.0791, 0.7316, 0.1005]}, {"w": "precisely", "b": [0.7375, 0.0791, 0.8108, 0.1005]}, {"w": "what", "b": [0.8166, 0.0791, 0.8571, 0.1005]}, {"w": "the", "b": [0.1429, 0.099, 0.1692, 0.1204]}, {"w": "keras.metrics.Precision", "b": [0.1739, 0.1022, 0.4015, 0.1173]}, {"w": "class", "b": [0.4062, 0.099, 0.4448, 0.1204]}, {"w": "does:", "b": [0.4495, 0.099, 0.4924, 0.1204]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> precision = keras.metrics.Precision() >>> precision([0, 1, 1, 1, 0, 1, 0, 1], [1, 1, 0, 1, 0, 1, 0, 1]) >>> precision([0, 1, 0, 0, 1, 0, 1, 1], [1, 0, 1, 1, 0, 0, 0, 0]) ", "words": [{"w": ">>>", "b": [0.1766, 0.131, 0.2019, 0.1438]}, {"w": "precision", "b": [0.2103, 0.131, 0.2862, 0.1438]}, {"w": "=", "b": [0.2946, 0.131, 0.3031, 0.1438]}, {"w": "keras.metrics.Precision()", "b": [0.3115, 0.131, 0.5223, 0.1438]}, {"w": ">>>", "b": [0.1766, 0.1464, 0.2019, 0.1592]}, {"w": "precision([0,", "b": [0.2103, 0.1464, 0.3199, 0.1592]}, {"w": "1,", "b": [0.3284, 0.1464, 0.3452, 0.1592]}, {"w": "1,", "b": [0.3537, 0.1464, 0.3705, 0.1592]}, {"w": "1,", "b": [0.379, 0.1464, 0.3958, 0.1592]}, {"w": "0,", "b": [0.4043, 0.1464, 0.4211, 0.1592]}, {"w": "1,", "b": [0.4296, 0.1464, 0.4464, 0.1592]}, {"w": "0,", "b": [0.4549, 0.1464, 0.4717, 0.1592]}, {"w": "1],", "b": [0.4802, 0.1464, 0.5055, 0.1592]}, {"w": "[1,", "b": [0.5139, 0.1464, 0.5392, 0.1592]}, {"w": "1,", "b": [0.5476, 0.1464, 0.5645, 0.1592]}, {"w": "0,", "b": [0.5729, 0.1464, 0.5898, 0.1592]}, {"w": "1,", "b": [0.5982, 0.1464, 0.6151, 0.1592]}, {"w": "0,", "b": [0.6235, 0.1464, 0.6404, 0.1592]}, {"w": "1,", "b": [0.6488, 0.1464, 0.6657, 0.1592]}, {"w": "0,", "b": [0.6741, 0.1464, 0.691, 0.1592]}, {"w": "1])", "b": [0.6994, 0.1464, 0.7247, 0.1592]}, {"w": "", "b": [0.5814, 0.1618, 0.6657, 0.1747]}, {"w": ">>>", "b": [0.1766, 0.1772, 0.2019, 0.1901]}, {"w": "precision([0,", "b": [0.2103, 0.1772, 0.3199, 0.1901]}, {"w": "1,", "b": [0.3284, 0.1772, 0.3452, 0.1901]}, {"w": "0,", "b": [0.3537, 0.1772, 0.3705, 0.1901]}, {"w": "0,", "b": [0.379, 0.1772, 0.3958, 0.1901]}, {"w": "1,", "b": [0.4043, 0.1772, 0.4211, 0.1901]}, {"w": "0,", "b": [0.4296, 0.1772, 0.4464, 0.1901]}, {"w": "1,", "b": [0.4549, 0.1772, 0.4717, 0.1901]}, {"w": "1],", "b": [0.4802, 0.1772, 0.5055, 0.1901]}, {"w": "[1,", "b": [0.5139, 0.1772, 0.5392, 0.1901]}, {"w": "0,", "b": [0.5476, 0.1772, 0.5645, 0.1901]}, {"w": "1,", "b": [0.5729, 0.1772, 0.5898, 0.1901]}, {"w": "1,", "b": [0.5982, 0.1772, 0.6151, 0.1901]}, {"w": "0,", "b": [0.6235, 0.1772, 0.6404, 0.1901]}, {"w": "0,", "b": [0.6488, 0.1772, 0.6657, 0.1901]}, {"w": "0,", "b": [0.6741, 0.1772, 0.691, 0.1901]}, {"w": "0])", "b": [0.6994, 0.1772, 0.7247, 0.1901]}, {"w": "", "b": [0.5814, 0.1927, 0.6657, 0.2055]}]}, {"id": "b_2", "type": "paragraph", "text": "In this example, we created a Precision object, then we used it like a function, pass‐ ing it the labels and predictions for the first batch, then for the second batch (note that we could also have passed sample weights). We used the same number of true and false positives as in the example we just discussed. After the first batch, it returns the precision of 80%, then after the second batch it returns 50% (which is the overall precision so far, not the second batch’s precision). This is called a streaming metric (or stateful metric), as it is gradually updated, batch after batch.", "words": [{"w": "In", "b": [0.1429, 0.2142, 0.1614, 0.2356]}, {"w": "this", "b": [0.167, 0.2142, 0.1977, 0.2356]}, {"w": "example,", "b": [0.2033, 0.2142, 0.2776, 0.2356]}, {"w": "we", "b": [0.2832, 0.2142, 0.3064, 0.2356]}, {"w": "created", "b": [0.312, 0.2142, 0.3723, 0.2356]}, {"w": "a", "b": [0.378, 0.2142, 0.3871, 0.2356]}, {"w": "Precision", "b": [0.3927, 0.2174, 0.4818, 0.2325]}, {"w": "object,", "b": [0.4874, 0.2142, 0.5427, 0.2356]}, {"w": "then", "b": [0.5483, 0.2142, 0.5861, 0.2356]}, {"w": "we", "b": [0.5917, 0.2142, 0.6148, 0.2356]}, {"w": "used", "b": [0.6204, 0.2142, 0.659, 0.2356]}, {"w": "it", "b": [0.6646, 0.2142, 0.6766, 0.2356]}, {"w": "like", "b": [0.6822, 0.2142, 0.7122, 0.2356]}, {"w": "a", "b": [0.7178, 0.2142, 0.727, 0.2356]}, {"w": "function,", "b": [0.7326, 0.2142, 0.8088, 0.2356]}, {"w": "pass‐", "b": [0.8144, 0.2142, 0.8572, 0.2356]}, {"w": "ing", "b": [0.1429, 0.2332, 0.1696, 0.2546]}, {"w": "it", "b": [0.1766, 0.2332, 0.1885, 0.2546]}, {"w": "the", "b": [0.1955, 0.2332, 0.2218, 0.2546]}, {"w": "labels", "b": [0.2288, 0.2332, 0.2756, 0.2546]}, {"w": "and", "b": [0.2826, 0.2332, 0.3141, 0.2546]}, {"w": "predictions", "b": [0.3211, 0.2332, 0.4156, 0.2546]}, {"w": "for", "b": [0.4226, 0.2332, 0.4471, 0.2546]}, {"w": "the", "b": [0.4541, 0.2332, 0.4804, 0.2546]}, {"w": "first", "b": [0.4874, 0.2332, 0.5209, 0.2546]}, {"w": "batch,", "b": [0.5279, 0.2332, 0.5783, 0.2546]}, {"w": "then", "b": [0.5852, 0.2332, 0.623, 0.2546]}, {"w": "for", "b": [0.63, 0.2332, 0.6545, 0.2546]}, {"w": "the", "b": [0.6615, 0.2332, 0.6878, 0.2546]}, {"w": "second", "b": [0.6948, 0.2332, 0.7531, 0.2546]}, {"w": "batch", "b": [0.7601, 0.2332, 0.8057, 0.2546]}, {"w": "(note", "b": [0.8127, 0.2332, 0.8571, 0.2546]}, {"w": "that", "b": [0.1429, 0.2523, 0.1754, 0.2737]}, {"w": "we", "b": [0.1826, 0.2523, 0.2057, 0.2737]}, {"w": "could", "b": [0.2129, 0.2523, 0.2596, 0.2737]}, {"w": "also", "b": [0.2668, 0.2523, 0.2995, 0.2737]}, {"w": "have", "b": [0.3066, 0.2523, 0.345, 0.2737]}, {"w": "passed", "b": [0.3522, 0.2523, 0.4074, 0.2737]}, {"w": "sample", "b": [0.4145, 0.2523, 0.473, 0.2737]}, {"w": "weights).", "b": [0.4802, 0.2523, 0.5553, 0.2737]}, {"w": "We", "b": [0.5625, 0.2523, 0.5895, 0.2737]}, {"w": "used", "b": [0.5967, 0.2523, 0.6353, 0.2737]}, {"w": "the", "b": [0.6424, 0.2523, 0.6687, 0.2737]}, {"w": "same", "b": [0.6759, 0.2523, 0.7186, 0.2737]}, {"w": "number", "b": [0.7258, 0.2523, 0.792, 0.2737]}, {"w": "of", "b": [0.7992, 0.2523, 0.816, 0.2737]}, {"w": "true", "b": [0.8231, 0.2523, 0.8571, 0.2737]}, {"w": "and", "b": [0.1428, 0.2713, 0.1744, 0.2927]}, {"w": "false", "b": [0.1797, 0.2713, 0.2168, 0.2927]}, {"w": "positives", "b": [0.222, 0.2713, 0.2949, 0.2927]}, {"w": "as", "b": [0.3002, 0.2713, 0.317, 0.2927]}, {"w": "in", "b": [0.3222, 0.2713, 0.3392, 0.2927]}, {"w": "the", "b": [0.3445, 0.2713, 0.3708, 0.2927]}, {"w": "example", "b": [0.3761, 0.2713, 0.4457, 0.2927]}, {"w": "we", "b": [0.451, 0.2713, 0.4741, 0.2927]}, {"w": "just", "b": [0.4794, 0.2713, 0.5098, 0.2927]}, {"w": "discussed.", "b": [0.515, 0.2713, 0.599, 0.2927]}, {"w": "After", "b": [0.6043, 0.2713, 0.6478, 0.2927]}, {"w": "the", "b": [0.6531, 0.2713, 0.6794, 0.2927]}, {"w": "first", "b": [0.6847, 0.2713, 0.7182, 0.2927]}, {"w": "batch,", "b": [0.7235, 0.2713, 0.7739, 0.2927]}, {"w": "it", "b": [0.7791, 0.2713, 0.7911, 0.2927]}, {"w": "returns", "b": [0.7964, 0.2713, 0.8571, 0.2927]}, {"w": "the", "b": [0.1429, 0.2904, 0.1692, 0.3118]}, {"w": "precision", "b": [0.1748, 0.2904, 0.252, 0.3118]}, {"w": "of", "b": [0.2576, 0.2904, 0.2744, 0.3118]}, {"w": "80%,", "b": [0.28, 0.2904, 0.3205, 0.3118]}, {"w": "then", "b": [0.3262, 0.2904, 0.3639, 0.3118]}, {"w": "after", "b": [0.3695, 0.2904, 0.4078, 0.3118]}, {"w": "the", "b": [0.4134, 0.2904, 0.4398, 0.3118]}, {"w": "second", "b": [0.4454, 0.2904, 0.5037, 0.3118]}, {"w": "batch", "b": [0.5094, 0.2904, 0.555, 0.3118]}, {"w": "it", "b": [0.5606, 0.2904, 0.5726, 0.3118]}, {"w": "returns", "b": [0.5782, 0.2904, 0.639, 0.3118]}, {"w": "50%", "b": [0.6446, 0.2904, 0.6804, 0.3118]}, {"w": "(which", "b": [0.686, 0.2904, 0.7441, 0.3118]}, {"w": "is", "b": [0.7498, 0.2904, 0.763, 0.3118]}, {"w": "the", "b": [0.7686, 0.2904, 0.795, 0.3118]}, {"w": "overall", "b": [0.8006, 0.2904, 0.8571, 0.3118]}, {"w": "precision", "b": [0.1429, 0.3094, 0.22, 0.3308]}, {"w": "so", "b": [0.2251, 0.3094, 0.2434, 0.3308]}, {"w": "far,", "b": [0.2484, 0.3094, 0.2749, 0.3308]}, {"w": "not", "b": [0.28, 0.3094, 0.3084, 0.3308]}, {"w": "the", "b": [0.3134, 0.3094, 0.3398, 0.3308]}, {"w": "second", "b": [0.3449, 0.3094, 0.4032, 0.3308]}, {"w": "batch’s", "b": [0.4083, 0.3094, 0.4625, 0.3308]}, {"w": "precision).", "b": [0.4676, 0.3094, 0.5567, 0.3308]}, {"w": "This", "b": [0.5618, 0.3094, 0.599, 0.3308]}, {"w": "is", "b": [0.604, 0.3094, 0.6173, 0.3308]}, {"w": "called", "b": [0.6223, 0.3094, 0.6707, 0.3308]}, {"w": "a", "b": [0.6758, 0.3094, 0.6849, 0.3308]}, {"w": "streaming", "b": [0.69, 0.3092, 0.7694, 0.3308]}, {"w": "metric", "b": [0.7741, 0.3092, 0.8262, 0.3308]}, {"w": "(or", "b": [0.8316, 0.3094, 0.8572, 0.3308]}, {"w": "stateful", "b": [0.1429, 0.3283, 0.2021, 0.3499]}, {"w": "metric),", "b": [0.2069, 0.3283, 0.2709, 0.3499]}, {"w": "as", "b": [0.2756, 0.3285, 0.2924, 0.3499]}, {"w": "it", "b": [0.2971, 0.3285, 0.3091, 0.3499]}, {"w": "is", "b": [0.3138, 0.3285, 0.327, 0.3499]}, {"w": "gradually", "b": [0.3318, 0.3285, 0.4097, 0.3499]}, {"w": "updated,", "b": [0.4144, 0.3285, 0.4871, 0.3499]}, {"w": "batch", "b": [0.4918, 0.3285, 0.5375, 0.3499]}, {"w": "after", "b": [0.5422, 0.3285, 0.5804, 0.3499]}, {"w": "batch.", "b": [0.5852, 0.3285, 0.6355, 0.3499]}]}, {"id": "b_3", "type": "paragraph", "text": "At any point, we can call the result() method to get the current value of the metric. We can also look at its variables (tracking the number of true and false positives) using the variables attribute, and reset these variables using the reset_states() method:", "words": [{"w": "At", "b": [0.1429, 0.3575, 0.1628, 0.3789]}, {"w": "any", "b": [0.1683, 0.3575, 0.1979, 0.3789]}, {"w": "point,", "b": [0.2034, 0.3575, 0.2526, 0.3789]}, {"w": "we", "b": [0.2581, 0.3575, 0.2812, 0.3789]}, {"w": "can", "b": [0.2867, 0.3575, 0.3161, 0.3789]}, {"w": "call", "b": [0.3216, 0.3575, 0.3501, 0.3789]}, {"w": "the", "b": [0.3556, 0.3575, 0.3819, 0.3789]}, {"w": "result()", "b": [0.3874, 0.3607, 0.4666, 0.3758]}, {"w": "method", "b": [0.4721, 0.3575, 0.5371, 0.3789]}, {"w": "to", "b": [0.5426, 0.3575, 0.5596, 0.3789]}, {"w": "get", "b": [0.5651, 0.3575, 0.59, 0.3789]}, {"w": "the", "b": [0.5955, 0.3575, 0.6219, 0.3789]}, {"w": "current", "b": [0.6274, 0.3575, 0.6889, 0.3789]}, {"w": "value", "b": [0.6944, 0.3575, 0.7384, 0.3789]}, {"w": "of", "b": [0.7439, 0.3575, 0.7607, 0.3789]}, {"w": "the", "b": [0.7662, 0.3575, 0.7925, 0.3789]}, {"w": "metric.", "b": [0.798, 0.3575, 0.8571, 0.3789]}, {"w": "We", "b": [0.1429, 0.3765, 0.1699, 0.3979]}, {"w": "can", "b": [0.1779, 0.3765, 0.2072, 0.3979]}, {"w": "also", "b": [0.2152, 0.3765, 0.2479, 0.3979]}, {"w": "look", "b": [0.2559, 0.3765, 0.2927, 0.3979]}, {"w": "at", "b": [0.3007, 0.3765, 0.3158, 0.3979]}, {"w": "its", "b": [0.3238, 0.3765, 0.3434, 0.3979]}, {"w": "variables", "b": [0.3513, 0.3765, 0.4249, 0.3979]}, {"w": "(tracking", "b": [0.4329, 0.3765, 0.5092, 0.3979]}, {"w": "the", "b": [0.5172, 0.3765, 0.5435, 0.3979]}, {"w": "number", "b": [0.5515, 0.3765, 0.6178, 0.3979]}, {"w": "of", "b": [0.6258, 0.3765, 0.6426, 0.3979]}, {"w": "true", "b": [0.6505, 0.3765, 0.6845, 0.3979]}, {"w": "and", "b": [0.6925, 0.3765, 0.724, 0.3979]}, {"w": "false", "b": [0.732, 0.3765, 0.7691, 0.3979]}, {"w": "positives)", "b": [0.7771, 0.3765, 0.8571, 0.3979]}, {"w": "using", "b": [0.1428, 0.3965, 0.1883, 0.4179]}, {"w": "the", "b": [0.1962, 0.3965, 0.2226, 0.4179]}, {"w": "variables", "b": [0.2305, 0.3997, 0.3196, 0.4147]}, {"w": "attribute,", "b": [0.3275, 0.3965, 0.4039, 0.4179]}, {"w": "and", "b": [0.4118, 0.3965, 0.4433, 0.4179]}, {"w": "reset", "b": [0.4513, 0.3965, 0.4907, 0.4179]}, {"w": "these", "b": [0.4986, 0.3965, 0.5415, 0.4179]}, {"w": "variables", "b": [0.5494, 0.3965, 0.623, 0.4179]}, {"w": "using", "b": [0.631, 0.3965, 0.6764, 0.4179]}, {"w": "the", "b": [0.6843, 0.3965, 0.7107, 0.4179]}, {"w": "reset_states()", "b": [0.7186, 0.3997, 0.8571, 0.4147]}, {"w": "method:", "b": [0.1429, 0.4155, 0.2126, 0.4369]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> p.result() >>> p.variables [, ] >>> p.reset_states() # both variables get reset to 0.0", "words": [{"w": ">>>", "b": [0.1766, 0.4475, 0.2019, 0.4604]}, {"w": "p.result()", "b": [0.2103, 0.4475, 0.2946, 0.4604]}, {"w": "", "b": [0.5814, 0.4629, 0.6657, 0.4758]}, {"w": ">>>", "b": [0.1766, 0.4783, 0.2019, 0.4912]}, {"w": "p.variables", "b": [0.2103, 0.4783, 0.3031, 0.4912]}, {"w": "[,", "b": [0.6572, 0.4938, 0.7922, 0.5066]}, {"w": "]", "b": [0.6657, 0.5092, 0.8006, 0.522]}, {"w": ">>>", "b": [0.1766, 0.5246, 0.2019, 0.5375]}, {"w": "p.reset_states()", "b": [0.2103, 0.5246, 0.3452, 0.5375]}, {"w": "#", "b": [0.3537, 0.5246, 0.3621, 0.5375]}, {"w": "both", "b": [0.3705, 0.5246, 0.4043, 0.5375]}, {"w": "variables", "b": [0.4127, 0.5246, 0.4886, 0.5375]}, {"w": "get", "b": [0.497, 0.5246, 0.5223, 0.5375]}, {"w": "reset", "b": [0.5308, 0.5246, 0.5729, 0.5375]}, {"w": "to", "b": [0.5814, 0.5246, 0.5982, 0.5375]}, {"w": "0.0", "b": [0.6067, 0.5246, 0.6319, 0.5375]}]}, {"id": "b_5", "type": "paragraph", "text": "If you need to create such a streaming metric, you can just create a subclass of the keras.metrics.Metric class. Here is a simple example that keeps track of the total Huber loss and the number of instances seen so far. When asked for the result, it returns the ratio, which is simply the mean Huber loss:", "words": [{"w": "If", "b": [0.1429, 0.5452, 0.1561, 0.5666]}, {"w": "you", "b": [0.1632, 0.5452, 0.1944, 0.5666]}, {"w": "need", "b": [0.2014, 0.5452, 0.2415, 0.5666]}, {"w": "to", "b": [0.2486, 0.5452, 0.2656, 0.5666]}, {"w": "create", "b": [0.2726, 0.5452, 0.3219, 0.5666]}, {"w": "such", "b": [0.329, 0.5452, 0.3676, 0.5666]}, {"w": "a", "b": [0.3746, 0.5452, 0.3838, 0.5666]}, {"w": "streaming", "b": [0.3908, 0.5452, 0.4743, 0.5666]}, {"w": "metric,", "b": [0.4814, 0.5452, 0.5405, 0.5666]}, {"w": "you", "b": [0.5475, 0.5452, 0.5788, 0.5666]}, {"w": "can", "b": [0.5858, 0.5452, 0.6152, 0.5666]}, {"w": "just", "b": [0.6222, 0.5452, 0.6526, 0.5666]}, {"w": "create", "b": [0.6596, 0.5452, 0.709, 0.5666]}, {"w": "a", "b": [0.716, 0.5452, 0.7251, 0.5666]}, {"w": "subclass", "b": [0.7322, 0.5452, 0.8, 0.5666]}, {"w": "of", "b": [0.807, 0.5452, 0.8238, 0.5666]}, {"w": "the", "b": [0.8308, 0.5452, 0.8572, 0.5666]}, {"w": "keras.metrics.Metric", "b": [0.1429, 0.5684, 0.3408, 0.5834]}, {"w": "class.", "b": [0.3477, 0.5652, 0.3909, 0.5866]}, {"w": "Here", "b": [0.3979, 0.5652, 0.4387, 0.5866]}, {"w": "is", "b": [0.4456, 0.5652, 0.4589, 0.5866]}, {"w": "a", "b": [0.4658, 0.5652, 0.4749, 0.5866]}, {"w": "simple", "b": [0.4818, 0.5652, 0.5368, 0.5866]}, {"w": "example", "b": [0.5437, 0.5652, 0.6132, 0.5866]}, {"w": "that", "b": [0.6201, 0.5652, 0.6527, 0.5866]}, {"w": "keeps", "b": [0.6596, 0.5652, 0.7062, 0.5866]}, {"w": "track", "b": [0.7132, 0.5652, 0.7555, 0.5866]}, {"w": "of", "b": [0.7624, 0.5652, 0.7792, 0.5866]}, {"w": "the", "b": [0.7861, 0.5652, 0.8125, 0.5866]}, {"w": "total", "b": [0.8194, 0.5652, 0.8571, 0.5866]}, {"w": "Huber", "b": [0.1429, 0.5842, 0.1962, 0.6056]}, {"w": "loss", "b": [0.2041, 0.5842, 0.2353, 0.6056]}, {"w": "and", "b": [0.2431, 0.5842, 0.2746, 0.6056]}, {"w": "the", "b": [0.2824, 0.5842, 0.3088, 0.6056]}, {"w": "number", "b": [0.3166, 0.5842, 0.3829, 0.6056]}, {"w": "of", "b": [0.3907, 0.5842, 0.4075, 0.6056]}, {"w": "instances", "b": [0.4153, 0.5842, 0.4922, 0.6056]}, {"w": "seen", "b": [0.5, 0.5842, 0.5368, 0.6056]}, {"w": "so", "b": [0.5446, 0.5842, 0.5628, 0.6056]}, {"w": "far.", "b": [0.5707, 0.5842, 0.5972, 0.6056]}, {"w": "When", "b": [0.605, 0.5842, 0.6566, 0.6056]}, {"w": "asked", "b": [0.6644, 0.5842, 0.7114, 0.6056]}, {"w": "for", "b": [0.7192, 0.5842, 0.7437, 0.6056]}, {"w": "the", "b": [0.7516, 0.5842, 0.7779, 0.6056]}, {"w": "result,", "b": [0.7857, 0.5842, 0.8374, 0.6056]}, {"w": "it", "b": [0.8452, 0.5842, 0.8572, 0.6056]}, {"w": "returns", "b": [0.1429, 0.6033, 0.2036, 0.6247]}, {"w": "the", "b": [0.2084, 0.6033, 0.2347, 0.6247]}, {"w": "ratio,", "b": [0.2394, 0.6033, 0.2826, 0.6247]}, {"w": "which", "b": [0.2873, 0.6033, 0.3383, 0.6247]}, {"w": "is", "b": [0.343, 0.6033, 0.3562, 0.6247]}, {"w": "simply", "b": [0.3609, 0.6033, 0.4166, 0.6247]}, {"w": "the", "b": [0.4213, 0.6033, 0.4477, 0.6247]}, {"w": "mean", "b": [0.4524, 0.6033, 0.4988, 0.6247]}, {"w": "Huber", "b": [0.5036, 0.6033, 0.5569, 0.6247]}, {"w": "loss:", "b": [0.5617, 0.6033, 0.5976, 0.6247]}]}, {"id": "b_6", "type": "paragraph", "text": "class HuberMetric(keras.metrics.Metric): def __init__(self, threshold=1.0, **kwargs): super().__init__(**kwargs) # handles base args (e.g., dtype) self.threshold = threshold self.huber_fn = create_huber(threshold) self.total = self.add_weight(\"total\", initializer=\"zeros\") self.count = self.add_weight(\"count\", initializer=\"zeros\") def update_state(self, y_true, y_pred, sample_weight=None): metric = self.huber_fn(y_true, y_pred) self.total.assign_add(tf.reduce_sum(metric)) self.count.assign_add(tf.cast(tf.size(y_true), tf.float32)) def result(self): return self.total / self.count def get_config(self): base_config = super().get_config() return {**base_config, \"threshold\": self.threshold}", "words": [{"w": "class", "b": [0.1766, 0.6352, 0.2188, 0.6481]}, {"w": "HuberMetric(keras.metrics.Metric):", "b": [0.2272, 0.6352, 0.5139, 0.6481]}, {"w": "def", "b": [0.2103, 0.6507, 0.2356, 0.6635]}, {"w": "__init__(self,", "b": [0.2441, 0.6507, 0.3621, 0.6635]}, {"w": "threshold=1.0,", "b": [0.3705, 0.6507, 0.4886, 0.6635]}, {"w": "**kwargs):", "b": [0.497, 0.6507, 0.5814, 0.6635]}, {"w": "super().__init__(**kwargs)", "b": [0.2441, 0.6661, 0.4633, 0.6789]}, {"w": "#", "b": [0.4717, 0.6661, 0.4802, 0.6789]}, {"w": "handles", "b": [0.4886, 0.6661, 0.5476, 0.6789]}, {"w": "base", "b": [0.5561, 0.6661, 0.5898, 0.6789]}, {"w": "args", "b": [0.5982, 0.6661, 0.6319, 0.6789]}, {"w": "(e.g.,", "b": [0.6404, 0.6661, 0.691, 0.6789]}, {"w": "dtype)", "b": [0.6994, 0.6661, 0.75, 0.6789]}, {"w": "self.threshold", "b": [0.2441, 0.6815, 0.3621, 0.6944]}, {"w": "=", "b": [0.3705, 0.6815, 0.379, 0.6944]}, {"w": "threshold", "b": [0.3874, 0.6815, 0.4633, 0.6944]}, {"w": "self.huber_fn", "b": [0.2441, 0.6969, 0.3537, 0.7098]}, {"w": "=", "b": [0.3621, 0.6969, 0.3705, 0.7098]}, {"w": "create_huber(threshold)", "b": [0.379, 0.6969, 0.5729, 0.7098]}, {"w": "self.total", "b": [0.2441, 0.7123, 0.3284, 0.7252]}, {"w": "=", "b": [0.3368, 0.7123, 0.3452, 0.7252]}, {"w": "self.add_weight(\"total\",", "b": [0.3537, 0.7123, 0.5561, 0.7252]}, {"w": "initializer=\"zeros\")", "b": [0.5645, 0.7123, 0.7331, 0.7252]}, {"w": "self.count", "b": [0.2441, 0.7278, 0.3284, 0.7406]}, {"w": "=", "b": [0.3368, 0.7278, 0.3452, 0.7406]}, {"w": "self.add_weight(\"count\",", "b": [0.3537, 0.7278, 0.5561, 0.7406]}, {"w": "initializer=\"zeros\")", "b": [0.5645, 0.7278, 0.7331, 0.7406]}, {"w": "def", "b": [0.2103, 0.7432, 0.2356, 0.756]}, {"w": "update_state(self,", "b": [0.2441, 0.7432, 0.3958, 0.756]}, {"w": "y_true,", "b": [0.4043, 0.7432, 0.4633, 0.756]}, {"w": "y_pred,", "b": [0.4717, 0.7432, 0.5308, 0.756]}, {"w": "sample_weight=None):", "b": [0.5392, 0.7432, 0.7078, 0.756]}, {"w": "metric", "b": [0.2441, 0.7586, 0.2946, 0.7715]}, {"w": "=", "b": [0.3031, 0.7586, 0.3115, 0.7715]}, {"w": "self.huber_fn(y_true,", "b": [0.3199, 0.7586, 0.497, 0.7715]}, {"w": "y_pred)", "b": [0.5055, 0.7586, 0.5645, 0.7715]}, {"w": "self.total.assign_add(tf.reduce_sum(metric))", "b": [0.2441, 0.774, 0.6151, 0.7869]}, {"w": "self.count.assign_add(tf.cast(tf.size(y_true),", "b": [0.2441, 0.7894, 0.6319, 0.8023]}, {"w": "tf.float32))", "b": [0.6404, 0.7894, 0.7416, 0.8023]}, {"w": "def", "b": [0.2103, 0.8049, 0.2356, 0.8177]}, {"w": "result(self):", "b": [0.2441, 0.8049, 0.3537, 0.8177]}, {"w": "return", "b": [0.2441, 0.8203, 0.2946, 0.8331]}, {"w": "self.total", "b": [0.3031, 0.8203, 0.3874, 0.8331]}, {"w": "/", "b": [0.3958, 0.8203, 0.4043, 0.8331]}, {"w": "self.count", "b": [0.4127, 0.8203, 0.497, 0.8331]}, {"w": "def", "b": [0.2103, 0.8357, 0.2356, 0.8486]}, {"w": "get_config(self):", "b": [0.2441, 0.8357, 0.3874, 0.8486]}, {"w": "base_config", "b": [0.2441, 0.8511, 0.3368, 0.864]}, {"w": "=", "b": [0.3452, 0.8511, 0.3537, 0.864]}, {"w": "super().get_config()", "b": [0.3621, 0.8511, 0.5308, 0.864]}, {"w": "return", "b": [0.2441, 0.8665, 0.2946, 0.8794]}, {"w": "{**base_config,", "b": [0.3031, 0.8665, 0.4296, 0.8794]}, {"w": "\"threshold\":", "b": [0.438, 0.8665, 0.5392, 0.8794]}, {"w": "self.threshold}", "b": [0.5476, 0.8665, 0.6741, 0.8794]}]}, {"id": "b_7", "type": "paragraph", "text": "Customizing Models and Training Algorithms | 381", "words": [{"w": "Customizing", "b": [0.5328, 0.9225, 0.6056, 0.9388]}, {"w": "Models", "b": [0.6084, 0.9225, 0.6507, 0.9388]}, {"w": "and", "b": [0.6535, 0.9225, 0.6759, 0.9388]}, {"w": "Training", "b": [0.6787, 0.9225, 0.7278, 0.9388]}, {"w": "Algorithms", "b": [0.7306, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "381", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 408, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "7 This class is for illustration purposes only. A simpler and better implementation would just subclass the keras.metrics.Mean class, see the notebook for an example.", "words": [{"w": "7", "b": [0.1451, 0.8602, 0.1518, 0.8745]}, {"w": "This", "b": [0.1587, 0.8587, 0.1871, 0.8751]}, {"w": "class", "b": [0.1907, 0.8587, 0.22, 0.8751]}, {"w": "is", "b": [0.2236, 0.8587, 0.2337, 0.8751]}, {"w": "for", "b": [0.2373, 0.8587, 0.256, 0.8751]}, {"w": "illustration", "b": [0.2596, 0.8587, 0.3294, 0.8751]}, {"w": "purposes", "b": [0.333, 0.8587, 0.3905, 0.8751]}, {"w": "only.", "b": [0.3941, 0.8587, 0.4246, 0.8751]}, {"w": "A", "b": [0.4282, 0.8587, 0.4392, 0.8751]}, {"w": "simpler", "b": [0.4428, 0.8587, 0.4905, 0.8751]}, {"w": "and", "b": [0.4941, 0.8587, 0.5182, 0.8751]}, {"w": "better", "b": [0.5218, 0.8587, 0.5589, 0.8751]}, {"w": "implementation", "b": [0.5625, 0.8587, 0.664, 0.8751]}, {"w": "would", "b": [0.6676, 0.8587, 0.7074, 0.8751]}, {"w": "just", "b": [0.711, 0.8587, 0.7342, 0.8751]}, {"w": "subclass", "b": [0.7378, 0.8587, 0.7895, 0.8751]}, {"w": "the", "b": [0.7931, 0.8587, 0.8131, 0.8751]}, {"w": "keras.metrics.Mean", "b": [0.1587, 0.8773, 0.2944, 0.8888]}, {"w": "class,", "b": [0.298, 0.8749, 0.331, 0.8912]}, {"w": "see", "b": [0.3346, 0.8749, 0.3539, 0.8912]}, {"w": "the", "b": [0.3575, 0.8749, 0.3776, 0.8912]}, {"w": "notebook", "b": [0.3812, 0.8749, 0.4417, 0.8912]}, {"w": "for", "b": [0.4453, 0.8749, 0.464, 0.8912]}, {"w": "an", "b": [0.4676, 0.8749, 0.4832, 0.8912]}, {"w": "example.", "b": [0.4868, 0.8749, 0.5434, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Let’s walk through this code:7:", "words": [{"w": "Let’s", "b": [0.1429, 0.0791, 0.179, 0.1005]}, {"w": "walk", "b": [0.1838, 0.0791, 0.2228, 0.1005]}, {"w": "through", "b": [0.2275, 0.0791, 0.2953, 0.1005]}, {"w": "this", "b": [0.3, 0.0791, 0.3307, 0.1005]}, {"w": "code:7:", "b": [0.3354, 0.0791, 0.3899, 0.1005]}]}, {"id": "b_2", "type": "paragraph", "text": "• The constructor uses the add_weight() method to create the variables needed to keep track of the metric’s state over multiple batches, in this case the sum of all Huber losses (total) and the number of instances seen so far (count). You could just create variables manually if you preferred. Keras tracks any tf.Variable that is set as an attribute (and more generally, any “trackable” object, such as layers or models).", "words": [{"w": "•", "b": [0.16, 0.1141, 0.1682, 0.1355]}, {"w": "The", "b": [0.1786, 0.1141, 0.2114, 0.1355]}, {"w": "constructor", "b": [0.2169, 0.1141, 0.314, 0.1355]}, {"w": "uses", "b": [0.3195, 0.1141, 0.3547, 0.1355]}, {"w": "the", "b": [0.3601, 0.1141, 0.3865, 0.1355]}, {"w": "add_weight()", "b": [0.3919, 0.1173, 0.5107, 0.1324]}, {"w": "method", "b": [0.5161, 0.1141, 0.5812, 0.1355]}, {"w": "to", "b": [0.5866, 0.1141, 0.6036, 0.1355]}, {"w": "create", "b": [0.6091, 0.1141, 0.6584, 0.1355]}, {"w": "the", "b": [0.6639, 0.1141, 0.6902, 0.1355]}, {"w": "variables", "b": [0.6957, 0.1141, 0.7693, 0.1355]}, {"w": "needed", "b": [0.7747, 0.1141, 0.8347, 0.1355]}, {"w": "to", "b": [0.8402, 0.1141, 0.8571, 0.1355]}, {"w": "keep", "b": [0.1786, 0.1332, 0.2175, 0.1546]}, {"w": "track", "b": [0.224, 0.1332, 0.2664, 0.1546]}, {"w": "of", "b": [0.2729, 0.1332, 0.2897, 0.1546]}, {"w": "the", "b": [0.2962, 0.1332, 0.3225, 0.1546]}, {"w": "metric’s", "b": [0.329, 0.1332, 0.3932, 0.1546]}, {"w": "state", "b": [0.3997, 0.1332, 0.4377, 0.1546]}, {"w": "over", "b": [0.4442, 0.1332, 0.481, 0.1546]}, {"w": "multiple", "b": [0.4875, 0.1332, 0.5575, 0.1546]}, {"w": "batches,", "b": [0.564, 0.1332, 0.6309, 0.1546]}, {"w": "in", "b": [0.6374, 0.1332, 0.6544, 0.1546]}, {"w": "this", "b": [0.6609, 0.1332, 0.6916, 0.1546]}, {"w": "case", "b": [0.6981, 0.1332, 0.7326, 0.1546]}, {"w": "the", "b": [0.7391, 0.1332, 0.7654, 0.1546]}, {"w": "sum", "b": [0.7719, 0.1332, 0.8077, 0.1546]}, {"w": "of", "b": [0.8142, 0.1332, 0.831, 0.1546]}, {"w": "all", "b": [0.8375, 0.1332, 0.8571, 0.1546]}, {"w": "Huber", "b": [0.1786, 0.1531, 0.2319, 0.1745]}, {"w": "losses", "b": [0.2373, 0.1531, 0.285, 0.1745]}, {"w": "(total)", "b": [0.2904, 0.1531, 0.3543, 0.1745]}, {"w": "and", "b": [0.3597, 0.1531, 0.3912, 0.1745]}, {"w": "the", "b": [0.3966, 0.1531, 0.4229, 0.1745]}, {"w": "number", "b": [0.4283, 0.1531, 0.4946, 0.1745]}, {"w": "of", "b": [0.5, 0.1531, 0.5168, 0.1745]}, {"w": "instances", "b": [0.5222, 0.1531, 0.599, 0.1745]}, {"w": "seen", "b": [0.6044, 0.1531, 0.6411, 0.1745]}, {"w": "so", "b": [0.6465, 0.1531, 0.6648, 0.1745]}, {"w": "far", "b": [0.6702, 0.1531, 0.6932, 0.1745]}, {"w": "(count).", "b": [0.6986, 0.1531, 0.7672, 0.1745]}, {"w": "You", "b": [0.7726, 0.1531, 0.805, 0.1745]}, {"w": "could", "b": [0.8104, 0.1531, 0.8571, 0.1745]}, {"w": "just", "b": [0.1786, 0.1731, 0.209, 0.1945]}, {"w": "create", "b": [0.2139, 0.1731, 0.2632, 0.1945]}, {"w": "variables", "b": [0.2682, 0.1731, 0.3418, 0.1945]}, {"w": "manually", "b": [0.3467, 0.1731, 0.4242, 0.1945]}, {"w": "if", "b": [0.4291, 0.1731, 0.4409, 0.1945]}, {"w": "you", "b": [0.4458, 0.1731, 0.4771, 0.1945]}, {"w": "preferred.", "b": [0.482, 0.1731, 0.5646, 0.1945]}, {"w": "Keras", "b": [0.5695, 0.1731, 0.6164, 0.1945]}, {"w": "tracks", "b": [0.6213, 0.1731, 0.6713, 0.1945]}, {"w": "any", "b": [0.6762, 0.1731, 0.7059, 0.1945]}, {"w": "tf.Variable", "b": [0.7108, 0.1762, 0.8196, 0.1913]}, {"w": "that", "b": [0.8246, 0.1731, 0.8571, 0.1945]}, {"w": "is", "b": [0.1786, 0.1921, 0.1918, 0.2135]}, {"w": "set", "b": [0.1971, 0.1921, 0.2199, 0.2135]}, {"w": "as", "b": [0.2252, 0.1921, 0.242, 0.2135]}, {"w": "an", "b": [0.2473, 0.1921, 0.2678, 0.2135]}, {"w": "attribute", "b": [0.2731, 0.1921, 0.3448, 0.2135]}, {"w": "(and", "b": [0.35, 0.1921, 0.3888, 0.2135]}, {"w": "more", "b": [0.3941, 0.1921, 0.4383, 0.2135]}, {"w": "generally,", "b": [0.4436, 0.1921, 0.5227, 0.2135]}, {"w": "any", "b": [0.528, 0.1921, 0.5576, 0.2135]}, {"w": "“trackable”", "b": [0.5629, 0.1921, 0.6538, 0.2135]}, {"w": "object,", "b": [0.6591, 0.1921, 0.7144, 0.2135]}, {"w": "such", "b": [0.7197, 0.1921, 0.7583, 0.2135]}, {"w": "as", "b": [0.7636, 0.1921, 0.7804, 0.2135]}, {"w": "layers", "b": [0.7857, 0.1921, 0.8335, 0.2135]}, {"w": "or", "b": [0.8388, 0.1921, 0.8571, 0.2135]}, {"w": "models).", "b": [0.1786, 0.2112, 0.251, 0.2326]}]}, {"id": "b_3", "type": "paragraph", "text": "• The update_state() method is called when you use an instance of this class as a function (as we did with the Precision object). It updates the variables given the labels and predictions for one batch (and sample weights, but in this case we just ignore them).", "words": [{"w": "•", "b": [0.16, 0.2371, 0.1682, 0.2586]}, {"w": "The", "b": [0.1786, 0.2371, 0.2114, 0.2586]}, {"w": "update_state()", "b": [0.2167, 0.2403, 0.3553, 0.2554]}, {"w": "method", "b": [0.3606, 0.2371, 0.4256, 0.2586]}, {"w": "is", "b": [0.4309, 0.2371, 0.4441, 0.2586]}, {"w": "called", "b": [0.4495, 0.2371, 0.4978, 0.2586]}, {"w": "when", "b": [0.5031, 0.2371, 0.5488, 0.2586]}, {"w": "you", "b": [0.5541, 0.2371, 0.5853, 0.2586]}, {"w": "use", "b": [0.5907, 0.2371, 0.6182, 0.2586]}, {"w": "an", "b": [0.6235, 0.2371, 0.6441, 0.2586]}, {"w": "instance", "b": [0.6494, 0.2371, 0.7186, 0.2586]}, {"w": "of", "b": [0.7239, 0.2371, 0.7407, 0.2586]}, {"w": "this", "b": [0.746, 0.2371, 0.7767, 0.2586]}, {"w": "class", "b": [0.782, 0.2371, 0.8206, 0.2586]}, {"w": "as", "b": [0.8259, 0.2371, 0.8427, 0.2586]}, {"w": "a", "b": [0.848, 0.2371, 0.8571, 0.2586]}, {"w": "function", "b": [0.1786, 0.2571, 0.25, 0.2785]}, {"w": "(as", "b": [0.2552, 0.2571, 0.2792, 0.2785]}, {"w": "we", "b": [0.2845, 0.2571, 0.3076, 0.2785]}, {"w": "did", "b": [0.3129, 0.2571, 0.3405, 0.2785]}, {"w": "with", "b": [0.3458, 0.2571, 0.3831, 0.2785]}, {"w": "the", "b": [0.3884, 0.2571, 0.4147, 0.2785]}, {"w": "Precision", "b": [0.42, 0.2603, 0.509, 0.2754]}, {"w": "object).", "b": [0.5143, 0.2571, 0.5768, 0.2785]}, {"w": "It", "b": [0.5821, 0.2571, 0.5947, 0.2785]}, {"w": "updates", "b": [0.6, 0.2571, 0.6646, 0.2785]}, {"w": "the", "b": [0.6698, 0.2571, 0.6962, 0.2785]}, {"w": "variables", "b": [0.7014, 0.2571, 0.775, 0.2785]}, {"w": "given", "b": [0.7803, 0.2571, 0.8255, 0.2785]}, {"w": "the", "b": [0.8308, 0.2571, 0.8571, 0.2785]}, {"w": "labels", "b": [0.1786, 0.2761, 0.2253, 0.2976]}, {"w": "and", "b": [0.2308, 0.2761, 0.2623, 0.2976]}, {"w": "predictions", "b": [0.2677, 0.2761, 0.3622, 0.2976]}, {"w": "for", "b": [0.3676, 0.2761, 0.3922, 0.2976]}, {"w": "one", "b": [0.3976, 0.2761, 0.4285, 0.2976]}, {"w": "batch", "b": [0.4339, 0.2761, 0.4795, 0.2976]}, {"w": "(and", "b": [0.4849, 0.2761, 0.5237, 0.2976]}, {"w": "sample", "b": [0.5291, 0.2761, 0.5876, 0.2976]}, {"w": "weights,", "b": [0.593, 0.2761, 0.6609, 0.2976]}, {"w": "but", "b": [0.6664, 0.2761, 0.6944, 0.2976]}, {"w": "in", "b": [0.6998, 0.2761, 0.7168, 0.2976]}, {"w": "this", "b": [0.7222, 0.2761, 0.7529, 0.2976]}, {"w": "case", "b": [0.7583, 0.2761, 0.7928, 0.2976]}, {"w": "we", "b": [0.7982, 0.2761, 0.8213, 0.2976]}, {"w": "just", "b": [0.8267, 0.2761, 0.8571, 0.2976]}, {"w": "ignore", "b": [0.1786, 0.2952, 0.2325, 0.3166]}, {"w": "them).", "b": [0.2372, 0.2952, 0.2926, 0.3166]}]}, {"id": "b_4", "type": "paragraph", "text": "• The result() method computes and returns the final result, in this case just the mean Huber metric over all instances. When you use the metric as a function, the update_state() method gets called first, then the result() method is called, and its output is returned.", "words": [{"w": "•", "b": [0.16, 0.3212, 0.1682, 0.3426]}, {"w": "The", "b": [0.1786, 0.3212, 0.2114, 0.3426]}, {"w": "result()", "b": [0.2171, 0.3244, 0.2962, 0.3394]}, {"w": "method", "b": [0.3019, 0.3212, 0.3669, 0.3426]}, {"w": "computes", "b": [0.3726, 0.3212, 0.4536, 0.3426]}, {"w": "and", "b": [0.4593, 0.3212, 0.4908, 0.3426]}, {"w": "returns", "b": [0.4965, 0.3212, 0.5572, 0.3426]}, {"w": "the", "b": [0.5629, 0.3212, 0.5893, 0.3426]}, {"w": "final", "b": [0.5949, 0.3212, 0.6325, 0.3426]}, {"w": "result,", "b": [0.6382, 0.3212, 0.6899, 0.3426]}, {"w": "in", "b": [0.6955, 0.3212, 0.7125, 0.3426]}, {"w": "this", "b": [0.7182, 0.3212, 0.7489, 0.3426]}, {"w": "case", "b": [0.7546, 0.3212, 0.789, 0.3426]}, {"w": "just", "b": [0.7947, 0.3212, 0.8251, 0.3426]}, {"w": "the", "b": [0.8308, 0.3212, 0.8571, 0.3426]}, {"w": "mean", "b": [0.1786, 0.3402, 0.225, 0.3616]}, {"w": "Huber", "b": [0.2298, 0.3402, 0.2831, 0.3616]}, {"w": "metric", "b": [0.2879, 0.3402, 0.3423, 0.3616]}, {"w": "over", "b": [0.347, 0.3402, 0.3838, 0.3616]}, {"w": "all", "b": [0.3886, 0.3402, 0.4083, 0.3616]}, {"w": "instances.", "b": [0.413, 0.3402, 0.4946, 0.3616]}, {"w": "When", "b": [0.4993, 0.3402, 0.5509, 0.3616]}, {"w": "you", "b": [0.5556, 0.3402, 0.5869, 0.3616]}, {"w": "use", "b": [0.5916, 0.3402, 0.6192, 0.3616]}, {"w": "the", "b": [0.6239, 0.3402, 0.6502, 0.3616]}, {"w": "metric", "b": [0.655, 0.3402, 0.7094, 0.3616]}, {"w": "as", "b": [0.7141, 0.3402, 0.7309, 0.3616]}, {"w": "a", "b": [0.7356, 0.3402, 0.7448, 0.3616]}, {"w": "function,", "b": [0.7495, 0.3402, 0.8256, 0.3616]}, {"w": "the", "b": [0.8304, 0.3402, 0.8567, 0.3616]}, {"w": "update_state()", "b": [0.1786, 0.3634, 0.3171, 0.3784]}, {"w": "method", "b": [0.3252, 0.3602, 0.3903, 0.3816]}, {"w": "gets", "b": [0.3984, 0.3602, 0.431, 0.3816]}, {"w": "called", "b": [0.4391, 0.3602, 0.4875, 0.3816]}, {"w": "first,", "b": [0.4956, 0.3602, 0.5338, 0.3816]}, {"w": "then", "b": [0.5419, 0.3602, 0.5797, 0.3816]}, {"w": "the", "b": [0.5878, 0.3602, 0.6141, 0.3816]}, {"w": "result()", "b": [0.6223, 0.3634, 0.7014, 0.3784]}, {"w": "method", "b": [0.7095, 0.3602, 0.7746, 0.3816]}, {"w": "is", "b": [0.7827, 0.3602, 0.7959, 0.3816]}, {"w": "called,", "b": [0.804, 0.3602, 0.8571, 0.3816]}, {"w": "and", "b": [0.1786, 0.3792, 0.2101, 0.4006]}, {"w": "its", "b": [0.2148, 0.3792, 0.2344, 0.4006]}, {"w": "output", "b": [0.2391, 0.3792, 0.2955, 0.4006]}, {"w": "is", "b": [0.3003, 0.3792, 0.3135, 0.4006]}, {"w": "returned.", "b": [0.3182, 0.3792, 0.3959, 0.4006]}]}, {"id": "b_5", "type": "paragraph", "text": "• We also implement the get_config() method to ensure the threshold gets saved along with the model.", "words": [{"w": "•", "b": [0.16, 0.4052, 0.1682, 0.4266]}, {"w": "We", "b": [0.1786, 0.4052, 0.2056, 0.4266]}, {"w": "also", "b": [0.2154, 0.4052, 0.2481, 0.4266]}, {"w": "implement", "b": [0.2578, 0.4052, 0.3484, 0.4266]}, {"w": "the", "b": [0.3582, 0.4052, 0.3845, 0.4266]}, {"w": "get_config()", "b": [0.3943, 0.4084, 0.513, 0.4235]}, {"w": "method", "b": [0.5228, 0.4052, 0.5878, 0.4266]}, {"w": "to", "b": [0.5976, 0.4052, 0.6145, 0.4266]}, {"w": "ensure", "b": [0.6243, 0.4052, 0.6798, 0.4266]}, {"w": "the", "b": [0.6896, 0.4052, 0.7159, 0.4266]}, {"w": "threshold", "b": [0.7257, 0.4084, 0.8148, 0.4235]}, {"w": "gets", "b": [0.8245, 0.4052, 0.8571, 0.4266]}, {"w": "saved", "b": [0.1786, 0.4243, 0.2245, 0.4457]}, {"w": "along", "b": [0.2292, 0.4243, 0.2754, 0.4457]}, {"w": "with", "b": [0.2801, 0.4243, 0.3175, 0.4457]}, {"w": "the", "b": [0.3222, 0.4243, 0.3485, 0.4457]}, {"w": "model.", "b": [0.3533, 0.4243, 0.4108, 0.4457]}]}, {"id": "b_6", "type": "paragraph", "text": "• The default implementation of the reset_states() method just resets all vari‐ ables to 0.0 (but you can override it if needed).", "words": [{"w": "•", "b": [0.16, 0.4502, 0.1682, 0.4717]}, {"w": "The", "b": [0.1786, 0.4502, 0.2114, 0.4717]}, {"w": "default", "b": [0.2186, 0.4502, 0.276, 0.4717]}, {"w": "implementation", "b": [0.2832, 0.4502, 0.4165, 0.4717]}, {"w": "of", "b": [0.4236, 0.4502, 0.4404, 0.4717]}, {"w": "the", "b": [0.4476, 0.4502, 0.4739, 0.4717]}, {"w": "reset_states()", "b": [0.4811, 0.4534, 0.6196, 0.4685]}, {"w": "method", "b": [0.6268, 0.4502, 0.6918, 0.4717]}, {"w": "just", "b": [0.699, 0.4502, 0.7294, 0.4717]}, {"w": "resets", "b": [0.7365, 0.4502, 0.7836, 0.4717]}, {"w": "all", "b": [0.7908, 0.4502, 0.8105, 0.4717]}, {"w": "vari‐", "b": [0.8176, 0.4502, 0.8571, 0.4717]}, {"w": "ables", "b": [0.1786, 0.4693, 0.2201, 0.4907]}, {"w": "to", "b": [0.2248, 0.4693, 0.2418, 0.4907]}, {"w": "0.0", "b": [0.2465, 0.4693, 0.2713, 0.4907]}, {"w": "(but", "b": [0.276, 0.4693, 0.3112, 0.4907]}, {"w": "you", "b": [0.3159, 0.4693, 0.3472, 0.4907]}, {"w": "can", "b": [0.3519, 0.4693, 0.3813, 0.4907]}, {"w": "override", "b": [0.386, 0.4693, 0.456, 0.4907]}, {"w": "it", "b": [0.4607, 0.4693, 0.4727, 0.4907]}, {"w": "if", "b": [0.4774, 0.4693, 0.4892, 0.4907]}, {"w": "needed).", "b": [0.4939, 0.4693, 0.5658, 0.4907]}]}, {"id": "b_7", "type": "paragraph", "text": "Keras will take care of variable persistence seamlessly, no action is required.", "words": [{"w": "Keras", "b": [0.2714, 0.5264, 0.3143, 0.5459]}, {"w": "will", "b": [0.3201, 0.5264, 0.3479, 0.5459]}, {"w": "take", "b": [0.3536, 0.5264, 0.3853, 0.5459]}, {"w": "care", "b": [0.3911, 0.5264, 0.4227, 0.5459]}, {"w": "of", "b": [0.4285, 0.5264, 0.4438, 0.5459]}, {"w": "variable", "b": [0.4496, 0.5264, 0.5099, 0.5459]}, {"w": "persistence", "b": [0.5157, 0.5264, 0.6004, 0.5459]}, {"w": "seamlessly,", "b": [0.6062, 0.5264, 0.6887, 0.5459]}, {"w": "no", "b": [0.6944, 0.5264, 0.7146, 0.5459]}, {"w": "action", "b": [0.7204, 0.5264, 0.7678, 0.5459]}, {"w": "is", "b": [0.7736, 0.5264, 0.7857, 0.5459]}, {"w": "required.", "b": [0.2714, 0.5438, 0.3411, 0.5633]}]}, {"id": "b_8", "type": "paragraph", "text": "When you define a metric using a simple function, Keras automatically calls it for each batch, and it keeps track of the mean during each epoch, just like we did man‐ ually. So the only benefit of our HuberMetric class is that the threshold will be saved. But of course, some metrics, like precision, cannot simply be averaged over batches: in thoses cases, there’s no other option than to implement a streaming metric.", "words": [{"w": "When", "b": [0.1429, 0.625, 0.1945, 0.6464]}, {"w": "you", "b": [0.202, 0.625, 0.2333, 0.6464]}, {"w": "define", "b": [0.2408, 0.625, 0.2927, 0.6464]}, {"w": "a", "b": [0.3002, 0.625, 0.3094, 0.6464]}, {"w": "metric", "b": [0.3169, 0.625, 0.3713, 0.6464]}, {"w": "using", "b": [0.3789, 0.625, 0.4243, 0.6464]}, {"w": "a", "b": [0.4319, 0.625, 0.441, 0.6464]}, {"w": "simple", "b": [0.4486, 0.625, 0.5035, 0.6464]}, {"w": "function,", "b": [0.5111, 0.625, 0.5872, 0.6464]}, {"w": "Keras", "b": [0.5948, 0.625, 0.6417, 0.6464]}, {"w": "automatically", "b": [0.6493, 0.625, 0.7619, 0.6464]}, {"w": "calls", "b": [0.7694, 0.625, 0.8056, 0.6464]}, {"w": "it", "b": [0.8131, 0.625, 0.8251, 0.6464]}, {"w": "for", "b": [0.8326, 0.625, 0.8571, 0.6464]}, {"w": "each", "b": [0.1429, 0.644, 0.1808, 0.6655]}, {"w": "batch,", "b": [0.1869, 0.644, 0.2373, 0.6655]}, {"w": "and", "b": [0.2435, 0.644, 0.275, 0.6655]}, {"w": "it", "b": [0.2811, 0.644, 0.2931, 0.6655]}, {"w": "keeps", "b": [0.2992, 0.644, 0.3458, 0.6655]}, {"w": "track", "b": [0.352, 0.644, 0.3943, 0.6655]}, {"w": "of", "b": [0.4005, 0.644, 0.4173, 0.6655]}, {"w": "the", "b": [0.4234, 0.644, 0.4497, 0.6655]}, {"w": "mean", "b": [0.4559, 0.644, 0.5023, 0.6655]}, {"w": "during", "b": [0.5085, 0.644, 0.565, 0.6655]}, {"w": "each", "b": [0.5711, 0.644, 0.6091, 0.6655]}, {"w": "epoch,", "b": [0.6152, 0.644, 0.6703, 0.6655]}, {"w": "just", "b": [0.6764, 0.644, 0.7068, 0.6655]}, {"w": "like", "b": [0.713, 0.644, 0.743, 0.6655]}, {"w": "we", "b": [0.7491, 0.644, 0.7723, 0.6655]}, {"w": "did", "b": [0.7784, 0.644, 0.806, 0.6655]}, {"w": "man‐", "b": [0.8121, 0.644, 0.8572, 0.6655]}, {"w": "ually.", "b": [0.1429, 0.664, 0.1864, 0.6854]}, {"w": "So", "b": [0.1913, 0.664, 0.2118, 0.6854]}, {"w": "the", "b": [0.2168, 0.664, 0.2431, 0.6854]}, {"w": "only", "b": [0.248, 0.664, 0.2849, 0.6854]}, {"w": "benefit", "b": [0.2898, 0.664, 0.3476, 0.6854]}, {"w": "of", "b": [0.3525, 0.664, 0.3693, 0.6854]}, {"w": "our", "b": [0.3743, 0.664, 0.4037, 0.6854]}, {"w": "HuberMetric", "b": [0.4086, 0.6672, 0.5175, 0.6823]}, {"w": "class", "b": [0.5224, 0.664, 0.5609, 0.6854]}, {"w": "is", "b": [0.5659, 0.664, 0.5791, 0.6854]}, {"w": "that", "b": [0.584, 0.664, 0.6166, 0.6854]}, {"w": "the", "b": [0.6215, 0.664, 0.6479, 0.6854]}, {"w": "threshold", "b": [0.6528, 0.6672, 0.7419, 0.6823]}, {"w": "will", "b": [0.7468, 0.664, 0.7772, 0.6854]}, {"w": "be", "b": [0.7819, 0.664, 0.8013, 0.6854]}, {"w": "saved.", "b": [0.8061, 0.664, 0.8567, 0.6854]}, {"w": "But", "b": [0.1429, 0.683, 0.1725, 0.7045]}, {"w": "of", "b": [0.1788, 0.683, 0.1956, 0.7045]}, {"w": "course,", "b": [0.2018, 0.683, 0.2613, 0.7045]}, {"w": "some", "b": [0.2676, 0.683, 0.3118, 0.7045]}, {"w": "metrics,", "b": [0.318, 0.683, 0.3848, 0.7045]}, {"w": "like", "b": [0.3911, 0.683, 0.4211, 0.7045]}, {"w": "precision,", "b": [0.4274, 0.683, 0.5093, 0.7045]}, {"w": "cannot", "b": [0.5155, 0.683, 0.5733, 0.7045]}, {"w": "simply", "b": [0.5795, 0.683, 0.6352, 0.7045]}, {"w": "be", "b": [0.6414, 0.683, 0.6609, 0.7045]}, {"w": "averaged", "b": [0.6671, 0.683, 0.7409, 0.7045]}, {"w": "over", "b": [0.7472, 0.683, 0.784, 0.7045]}, {"w": "batches:", "b": [0.7903, 0.683, 0.8571, 0.7045]}, {"w": "in", "b": [0.1429, 0.7021, 0.1598, 0.7235]}, {"w": "thoses", "b": [0.1646, 0.7021, 0.2168, 0.7235]}, {"w": "cases,", "b": [0.2215, 0.7021, 0.2684, 0.7235]}, {"w": "there’s", "b": [0.2731, 0.7021, 0.3251, 0.7235]}, {"w": "no", "b": [0.3299, 0.7021, 0.3519, 0.7235]}, {"w": "other", "b": [0.3566, 0.7021, 0.4013, 0.7235]}, {"w": "option", "b": [0.406, 0.7021, 0.4615, 0.7235]}, {"w": "than", "b": [0.4663, 0.7021, 0.5043, 0.7235]}, {"w": "to", "b": [0.509, 0.7021, 0.526, 0.7235]}, {"w": "implement", "b": [0.5307, 0.7021, 0.6213, 0.7235]}, {"w": "a", "b": [0.626, 0.7021, 0.6352, 0.7235]}, {"w": "streaming", "b": [0.6399, 0.7021, 0.7234, 0.7235]}, {"w": "metric.", "b": [0.7281, 0.7021, 0.7873, 0.7235]}]}, {"id": "b_9", "type": "paragraph", "text": "Now that we have built a streaming metric, building a custom layer will seem like a walk in the park!", "words": [{"w": "Now", "b": [0.1429, 0.7302, 0.1827, 0.7516]}, {"w": "that", "b": [0.1891, 0.7302, 0.2217, 0.7516]}, {"w": "we", "b": [0.2282, 0.7302, 0.2513, 0.7516]}, {"w": "have", "b": [0.2577, 0.7302, 0.2961, 0.7516]}, {"w": "built", "b": [0.3026, 0.7302, 0.3414, 0.7516]}, {"w": "a", "b": [0.3478, 0.7302, 0.357, 0.7516]}, {"w": "streaming", "b": [0.3634, 0.7302, 0.4469, 0.7516]}, {"w": "metric,", "b": [0.4534, 0.7302, 0.5125, 0.7516]}, {"w": "building", "b": [0.519, 0.7302, 0.5892, 0.7516]}, {"w": "a", "b": [0.5956, 0.7302, 0.6048, 0.7516]}, {"w": "custom", "b": [0.6112, 0.7302, 0.6728, 0.7516]}, {"w": "layer", "b": [0.6792, 0.7302, 0.7194, 0.7516]}, {"w": "will", "b": [0.7258, 0.7302, 0.7562, 0.7516]}, {"w": "seem", "b": [0.7627, 0.7302, 0.8051, 0.7516]}, {"w": "like", "b": [0.8115, 0.7302, 0.8416, 0.7516]}, {"w": "a", "b": [0.848, 0.7302, 0.8571, 0.7516]}, {"w": "walk", "b": [0.1429, 0.7493, 0.1819, 0.7707]}, {"w": "in", "b": [0.1866, 0.7493, 0.2036, 0.7707]}, {"w": "the", "b": [0.2083, 0.7493, 0.2347, 0.7707]}, {"w": "park!", "b": [0.2394, 0.7493, 0.2833, 0.7707]}]}, {"id": "b_10", "type": "paragraph", "text": "382 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "382", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2745, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 409, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Custom Layers", "words": [{"w": "Custom", "b": [0.1429, 0.0763, 0.2201, 0.1049]}, {"w": "Layers", "b": [0.2251, 0.0763, 0.291, 0.1049]}]}, {"id": "b_1", "type": "paragraph", "text": "You may occasionally want to build an architecture that contains an exotic layer for which TensorFlow does not provide a default implementation. In this case, you will need to create a custom layer. Or sometimes you may simply want to build a very repetitive architecture, containing identical blocks of layers repeated many times, and it would be convenient to treat each block of layers as a single layer. For example, if the model is a sequence of layers A, B, C, A, B, C, A, B, C, then you might want to define a custom layer D containing layers A, B, C, and your model would then simply be D, D, D. Let’s see how to build custom layers.", "words": [{"w": "You", "b": [0.1428, 0.1108, 0.1752, 0.1322]}, {"w": "may", "b": [0.1817, 0.1108, 0.2171, 0.1322]}, {"w": "occasionally", "b": [0.2235, 0.1108, 0.3254, 0.1322]}, {"w": "want", "b": [0.3319, 0.1108, 0.3726, 0.1322]}, {"w": "to", "b": [0.3791, 0.1108, 0.3961, 0.1322]}, {"w": "build", "b": [0.4025, 0.1108, 0.446, 0.1322]}, {"w": "an", "b": [0.4525, 0.1108, 0.473, 0.1322]}, {"w": "architecture", "b": [0.4795, 0.1108, 0.5799, 0.1322]}, {"w": "that", "b": [0.5864, 0.1108, 0.619, 0.1322]}, {"w": "contains", "b": [0.6254, 0.1108, 0.696, 0.1322]}, {"w": "an", "b": [0.7024, 0.1108, 0.723, 0.1322]}, {"w": "exotic", "b": [0.7294, 0.1108, 0.7795, 0.1322]}, {"w": "layer", "b": [0.786, 0.1108, 0.8262, 0.1322]}, {"w": "for", "b": [0.8326, 0.1108, 0.8571, 0.1322]}, {"w": "which", "b": [0.1429, 0.1298, 0.1938, 0.1512]}, {"w": "TensorFlow", "b": [0.2004, 0.1298, 0.2987, 0.1512]}, {"w": "does", "b": [0.3053, 0.1298, 0.3434, 0.1512]}, {"w": "not", "b": [0.35, 0.1298, 0.3784, 0.1512]}, {"w": "provide", "b": [0.3851, 0.1298, 0.4494, 0.1512]}, {"w": "a", "b": [0.456, 0.1298, 0.4652, 0.1512]}, {"w": "default", "b": [0.4718, 0.1298, 0.5293, 0.1512]}, {"w": "implementation.", "b": [0.5359, 0.1298, 0.6739, 0.1512]}, {"w": "In", "b": [0.6806, 0.1298, 0.6991, 0.1512]}, {"w": "this", "b": [0.7057, 0.1298, 0.7364, 0.1512]}, {"w": "case,", "b": [0.743, 0.1298, 0.7822, 0.1512]}, {"w": "you", "b": [0.7889, 0.1298, 0.8201, 0.1512]}, {"w": "will", "b": [0.8268, 0.1298, 0.8571, 0.1512]}, {"w": "need", "b": [0.1429, 0.1489, 0.183, 0.1703]}, {"w": "to", "b": [0.1904, 0.1489, 0.2074, 0.1703]}, {"w": "create", "b": [0.2148, 0.1489, 0.2642, 0.1703]}, {"w": "a", "b": [0.2716, 0.1489, 0.2807, 0.1703]}, {"w": "custom", "b": [0.2882, 0.1489, 0.3497, 0.1703]}, {"w": "layer.", "b": [0.3572, 0.1489, 0.4008, 0.1703]}, {"w": "Or", "b": [0.4082, 0.1489, 0.4315, 0.1703]}, {"w": "sometimes", "b": [0.4389, 0.1489, 0.5286, 0.1703]}, {"w": "you", "b": [0.536, 0.1489, 0.5673, 0.1703]}, {"w": "may", "b": [0.5747, 0.1489, 0.6101, 0.1703]}, {"w": "simply", "b": [0.6176, 0.1489, 0.6732, 0.1703]}, {"w": "want", "b": [0.6806, 0.1489, 0.7214, 0.1703]}, {"w": "to", "b": [0.7288, 0.1489, 0.7458, 0.1703]}, {"w": "build", "b": [0.7532, 0.1489, 0.7967, 0.1703]}, {"w": "a", "b": [0.8042, 0.1489, 0.8133, 0.1703]}, {"w": "very", "b": [0.8207, 0.1489, 0.8571, 0.1703]}, {"w": "repetitive", "b": [0.1429, 0.1679, 0.2216, 0.1893]}, {"w": "architecture,", "b": [0.2267, 0.1679, 0.3319, 0.1893]}, {"w": "containing", "b": [0.337, 0.1679, 0.4267, 0.1893]}, {"w": "identical", "b": [0.4318, 0.1679, 0.5034, 0.1893]}, {"w": "blocks", "b": [0.5086, 0.1679, 0.5618, 0.1893]}, {"w": "of", "b": [0.567, 0.1679, 0.5838, 0.1893]}, {"w": "layers", "b": [0.5889, 0.1679, 0.6368, 0.1893]}, {"w": "repeated", "b": [0.6419, 0.1679, 0.7132, 0.1893]}, {"w": "many", "b": [0.7184, 0.1679, 0.7651, 0.1893]}, {"w": "times,", "b": [0.7702, 0.1679, 0.8204, 0.1893]}, {"w": "and", "b": [0.8256, 0.1679, 0.8571, 0.1893]}, {"w": "it", "b": [0.1429, 0.187, 0.1548, 0.2084]}, {"w": "would", "b": [0.1612, 0.187, 0.2134, 0.2084]}, {"w": "be", "b": [0.2198, 0.187, 0.2393, 0.2084]}, {"w": "convenient", "b": [0.2457, 0.187, 0.3377, 0.2084]}, {"w": "to", "b": [0.3441, 0.187, 0.3611, 0.2084]}, {"w": "treat", "b": [0.3675, 0.187, 0.4055, 0.2084]}, {"w": "each", "b": [0.4119, 0.187, 0.4499, 0.2084]}, {"w": "block", "b": [0.4562, 0.187, 0.5019, 0.2084]}, {"w": "of", "b": [0.5083, 0.187, 0.5251, 0.2084]}, {"w": "layers", "b": [0.5315, 0.187, 0.5793, 0.2084]}, {"w": "as", "b": [0.5857, 0.187, 0.6025, 0.2084]}, {"w": "a", "b": [0.6089, 0.187, 0.618, 0.2084]}, {"w": "single", "b": [0.6244, 0.187, 0.6729, 0.2084]}, {"w": "layer.", "b": [0.6793, 0.187, 0.7229, 0.2084]}, {"w": "For", "b": [0.7293, 0.187, 0.7583, 0.2084]}, {"w": "example,", "b": [0.7647, 0.187, 0.839, 0.2084]}, {"w": "if", "b": [0.8454, 0.187, 0.8572, 0.2084]}, {"w": "the", "b": [0.1429, 0.206, 0.1692, 0.2274]}, {"w": "model", "b": [0.1758, 0.206, 0.2286, 0.2274]}, {"w": "is", "b": [0.2353, 0.206, 0.2485, 0.2274]}, {"w": "a", "b": [0.2551, 0.206, 0.2643, 0.2274]}, {"w": "sequence", "b": [0.2709, 0.206, 0.347, 0.2274]}, {"w": "of", "b": [0.3537, 0.206, 0.3705, 0.2274]}, {"w": "layers", "b": [0.3771, 0.206, 0.4249, 0.2274]}, {"w": "A,", "b": [0.4315, 0.206, 0.4507, 0.2274]}, {"w": "B,", "b": [0.4573, 0.206, 0.474, 0.2274]}, {"w": "C,", "b": [0.4806, 0.206, 0.4992, 0.2274]}, {"w": "A,", "b": [0.5058, 0.206, 0.525, 0.2274]}, {"w": "B,", "b": [0.5316, 0.206, 0.5483, 0.2274]}, {"w": "C,", "b": [0.5549, 0.206, 0.5735, 0.2274]}, {"w": "A,", "b": [0.5801, 0.206, 0.5993, 0.2274]}, {"w": "B,", "b": [0.6059, 0.206, 0.6225, 0.2274]}, {"w": "C,", "b": [0.6292, 0.206, 0.6478, 0.2274]}, {"w": "then", "b": [0.6544, 0.206, 0.6921, 0.2274]}, {"w": "you", "b": [0.6988, 0.206, 0.73, 0.2274]}, {"w": "might", "b": [0.7367, 0.206, 0.7861, 0.2274]}, {"w": "want", "b": [0.7928, 0.206, 0.8335, 0.2274]}, {"w": "to", "b": [0.8402, 0.206, 0.8571, 0.2274]}, {"w": "define", "b": [0.1429, 0.2251, 0.1947, 0.2465]}, {"w": "a", "b": [0.1997, 0.2251, 0.2089, 0.2465]}, {"w": "custom", "b": [0.2139, 0.2251, 0.2755, 0.2465]}, {"w": "layer", "b": [0.2805, 0.2251, 0.3207, 0.2465]}, {"w": "D", "b": [0.3257, 0.2251, 0.341, 0.2465]}, {"w": "containing", "b": [0.3461, 0.2251, 0.4357, 0.2465]}, {"w": "layers", "b": [0.4407, 0.2251, 0.4886, 0.2465]}, {"w": "A,", "b": [0.4936, 0.2251, 0.5127, 0.2465]}, {"w": "B,", "b": [0.5178, 0.2251, 0.5344, 0.2465]}, {"w": "C,", "b": [0.5394, 0.2251, 0.558, 0.2465]}, {"w": "and", "b": [0.5631, 0.2251, 0.5946, 0.2465]}, {"w": "your", "b": [0.5996, 0.2251, 0.6386, 0.2465]}, {"w": "model", "b": [0.6436, 0.2251, 0.6965, 0.2465]}, {"w": "would", "b": [0.7015, 0.2251, 0.7537, 0.2465]}, {"w": "then", "b": [0.7587, 0.2251, 0.7965, 0.2465]}, {"w": "simply", "b": [0.8015, 0.2251, 0.8571, 0.2465]}, {"w": "be", "b": [0.1428, 0.2441, 0.1623, 0.2655]}, {"w": "D,", "b": [0.167, 0.2441, 0.1862, 0.2655]}, {"w": "D,", "b": [0.191, 0.2441, 0.2102, 0.2655]}, {"w": "D.", "b": [0.2149, 0.2441, 0.2342, 0.2655]}, {"w": "Let’s", "b": [0.2389, 0.2441, 0.2751, 0.2655]}, {"w": "see", "b": [0.2798, 0.2441, 0.3051, 0.2655]}, {"w": "how", "b": [0.3099, 0.2441, 0.3459, 0.2655]}, {"w": "to", "b": [0.3506, 0.2441, 0.3676, 0.2655]}, {"w": "build", "b": [0.3723, 0.2441, 0.4158, 0.2655]}, {"w": "custom", "b": [0.4206, 0.2441, 0.4821, 0.2655]}, {"w": "layers.", "b": [0.4868, 0.2441, 0.5394, 0.2655]}]}, {"id": "b_2", "type": "paragraph", "text": "First, some layers have no weights, such as keras.layers.Flatten or keras.lay ers.ReLU. If you want to create a custom layer without any weights, the simplest option is to write a function and wrap it in a keras.layers.Lambda layer. For exam‐ ple, the following layer will apply the exponential function to its inputs:", "words": [{"w": "First,", "b": [0.1428, 0.2731, 0.1859, 0.2945]}, {"w": "some", "b": [0.1946, 0.2731, 0.2388, 0.2945]}, {"w": "layers", "b": [0.2474, 0.2731, 0.2952, 0.2945]}, {"w": "have", "b": [0.3039, 0.2731, 0.3423, 0.2945]}, {"w": "no", "b": [0.3509, 0.2731, 0.3729, 0.2945]}, {"w": "weights,", "b": [0.3815, 0.2731, 0.4495, 0.2945]}, {"w": "such", "b": [0.4581, 0.2731, 0.4968, 0.2945]}, {"w": "as", "b": [0.5054, 0.2731, 0.5222, 0.2945]}, {"w": "keras.layers.Flatten", "b": [0.5308, 0.2763, 0.7287, 0.2914]}, {"w": "or", "b": [0.7374, 0.2731, 0.7557, 0.2945]}, {"w": "keras.lay", "b": [0.7644, 0.2763, 0.8534, 0.2914]}, {"w": "ers.ReLU.", "b": [0.1429, 0.2931, 0.2268, 0.3145]}, {"w": "If", "b": [0.2352, 0.2931, 0.2485, 0.3145]}, {"w": "you", "b": [0.2569, 0.2931, 0.2882, 0.3145]}, {"w": "want", "b": [0.2966, 0.2931, 0.3374, 0.3145]}, {"w": "to", "b": [0.3458, 0.2931, 0.3628, 0.3145]}, {"w": "create", "b": [0.3712, 0.2931, 0.4206, 0.3145]}, {"w": "a", "b": [0.429, 0.2931, 0.4382, 0.3145]}, {"w": "custom", "b": [0.4466, 0.2931, 0.5081, 0.3145]}, {"w": "layer", "b": [0.5166, 0.2931, 0.5568, 0.3145]}, {"w": "without", "b": [0.5652, 0.2931, 0.6306, 0.3145]}, {"w": "any", "b": [0.639, 0.2931, 0.6686, 0.3145]}, {"w": "weights,", "b": [0.6771, 0.2931, 0.745, 0.3145]}, {"w": "the", "b": [0.7534, 0.2931, 0.7798, 0.3145]}, {"w": "simplest", "b": [0.7882, 0.2931, 0.8571, 0.3145]}, {"w": "option", "b": [0.1429, 0.313, 0.1984, 0.3344]}, {"w": "is", "b": [0.2041, 0.313, 0.2174, 0.3344]}, {"w": "to", "b": [0.2232, 0.313, 0.2401, 0.3344]}, {"w": "write", "b": [0.2459, 0.313, 0.2887, 0.3344]}, {"w": "a", "b": [0.2945, 0.313, 0.3037, 0.3344]}, {"w": "function", "b": [0.3094, 0.313, 0.3808, 0.3344]}, {"w": "and", "b": [0.3866, 0.313, 0.4182, 0.3344]}, {"w": "wrap", "b": [0.424, 0.313, 0.4656, 0.3344]}, {"w": "it", "b": [0.4714, 0.313, 0.4833, 0.3344]}, {"w": "in", "b": [0.4891, 0.313, 0.5061, 0.3344]}, {"w": "a", "b": [0.5119, 0.313, 0.5211, 0.3344]}, {"w": "keras.layers.Lambda", "b": [0.5268, 0.3162, 0.7149, 0.3313]}, {"w": "layer.", "b": [0.7206, 0.313, 0.7643, 0.3344]}, {"w": "For", "b": [0.7701, 0.313, 0.799, 0.3344]}, {"w": "exam‐", "b": [0.8048, 0.313, 0.8571, 0.3344]}, {"w": "ple,", "b": [0.1429, 0.3321, 0.1726, 0.3535]}, {"w": "the", "b": [0.1774, 0.3321, 0.2037, 0.3535]}, {"w": "following", "b": [0.2084, 0.3321, 0.2874, 0.3535]}, {"w": "layer", "b": [0.2921, 0.3321, 0.3323, 0.3535]}, {"w": "will", "b": [0.337, 0.3321, 0.3674, 0.3535]}, {"w": "apply", "b": [0.3722, 0.3321, 0.4176, 0.3535]}, {"w": "the", "b": [0.4223, 0.3321, 0.4486, 0.3535]}, {"w": "exponential", "b": [0.4534, 0.3321, 0.5512, 0.3535]}, {"w": "function", "b": [0.5559, 0.3321, 0.6273, 0.3535]}, {"w": "to", "b": [0.6321, 0.3321, 0.649, 0.3535]}, {"w": "its", "b": [0.6538, 0.3321, 0.6734, 0.3535]}, {"w": "inputs:", "b": [0.6781, 0.3321, 0.7354, 0.3535]}]}, {"id": "b_3", "type": "equation", "text": "exponential_layer = keras.layers.Lambda(lambda x: tf.exp(x))", "words": [{"w": "exponential_layer", "b": [0.1766, 0.364, 0.3199, 0.3769]}, {"w": "=", "b": [0.3284, 0.364, 0.3368, 0.3769]}, {"w": "keras.layers.Lambda(lambda", "b": [0.3452, 0.364, 0.5645, 0.3769]}, {"w": "x:", "b": [0.5729, 0.364, 0.5898, 0.3769]}, {"w": "tf.exp(x))", "b": [0.5982, 0.364, 0.6825, 0.3769]}]}, {"id": "b_4", "type": "paragraph", "text": "This custom layer can then be used like any other layer, using the sequential API, the functional API, or the subclassing API. You can also use it as an activation function (or you could just use activation=tf.exp, or activation=keras.activations.expo nential, or simply activation=\"exponential\"). The exponential layer is sometimes used in the output layer of a regression model when the values to predict have very different scales (e.g., 0.001, 10., 1000.).", "words": [{"w": "This", "b": [0.1429, 0.3847, 0.1801, 0.4061]}, {"w": "custom", "b": [0.1855, 0.3847, 0.2471, 0.4061]}, {"w": "layer", "b": [0.2525, 0.3847, 0.2927, 0.4061]}, {"w": "can", "b": [0.2982, 0.3847, 0.3275, 0.4061]}, {"w": "then", "b": [0.333, 0.3847, 0.3707, 0.4061]}, {"w": "be", "b": [0.3761, 0.3847, 0.3956, 0.4061]}, {"w": "used", "b": [0.401, 0.3847, 0.4396, 0.4061]}, {"w": "like", "b": [0.4451, 0.3847, 0.4751, 0.4061]}, {"w": "any", "b": [0.4805, 0.3847, 0.5102, 0.4061]}, {"w": "other", "b": [0.5156, 0.3847, 0.5603, 0.4061]}, {"w": "layer,", "b": [0.5658, 0.3847, 0.6094, 0.4061]}, {"w": "using", "b": [0.6148, 0.3847, 0.6603, 0.4061]}, {"w": "the", "b": [0.6657, 0.3847, 0.6921, 0.4061]}, {"w": "sequential", "b": [0.6975, 0.3847, 0.7819, 0.4061]}, {"w": "API,", "b": [0.7874, 0.3847, 0.8254, 0.4061]}, {"w": "the", "b": [0.8308, 0.3847, 0.8571, 0.4061]}, {"w": "functional", "b": [0.1429, 0.4037, 0.2287, 0.4251]}, {"w": "API,", "b": [0.235, 0.4037, 0.273, 0.4251]}, {"w": "or", "b": [0.2793, 0.4037, 0.2976, 0.4251]}, {"w": "the", "b": [0.304, 0.4037, 0.3303, 0.4251]}, {"w": "subclassing", "b": [0.3366, 0.4037, 0.4311, 0.4251]}, {"w": "API.", "b": [0.4375, 0.4037, 0.4754, 0.4251]}, {"w": "You", "b": [0.4818, 0.4037, 0.5141, 0.4251]}, {"w": "can", "b": [0.5204, 0.4037, 0.5498, 0.4251]}, {"w": "also", "b": [0.5561, 0.4037, 0.5888, 0.4251]}, {"w": "use", "b": [0.5951, 0.4037, 0.6227, 0.4251]}, {"w": "it", "b": [0.629, 0.4037, 0.6409, 0.4251]}, {"w": "as", "b": [0.6472, 0.4037, 0.664, 0.4251]}, {"w": "an", "b": [0.6703, 0.4037, 0.6909, 0.4251]}, {"w": "activation", "b": [0.6972, 0.4037, 0.7794, 0.4251]}, {"w": "function", "b": [0.7858, 0.4037, 0.8572, 0.4251]}, {"w": "(or", "b": [0.1429, 0.4237, 0.1684, 0.4451]}, {"w": "you", "b": [0.1734, 0.4237, 0.2046, 0.4451]}, {"w": "could", "b": [0.2096, 0.4237, 0.2563, 0.4451]}, {"w": "just", "b": [0.2613, 0.4237, 0.2917, 0.4451]}, {"w": "use", "b": [0.2966, 0.4237, 0.3242, 0.4451]}, {"w": "activation=tf.exp,", "b": [0.3291, 0.4237, 0.5021, 0.4451]}, {"w": "or", "b": [0.5069, 0.4237, 0.5252, 0.4451]}, {"w": "activation=keras.activations.expo", "b": [0.5304, 0.4268, 0.8569, 0.4419]}, {"w": "nential,", "b": [0.1429, 0.4436, 0.2169, 0.465]}, {"w": "or", "b": [0.2223, 0.4436, 0.2406, 0.465]}, {"w": "simply", "b": [0.246, 0.4436, 0.3016, 0.465]}, {"w": "activation=\"exponential\").", "b": [0.307, 0.4436, 0.5565, 0.465]}, {"w": "The", "b": [0.5618, 0.4436, 0.5947, 0.465]}, {"w": "exponential", "b": [0.6001, 0.4436, 0.6979, 0.465]}, {"w": "layer", "b": [0.7033, 0.4436, 0.7435, 0.465]}, {"w": "is", "b": [0.7488, 0.4436, 0.7621, 0.465]}, {"w": "sometimes", "b": [0.7675, 0.4436, 0.8571, 0.465]}, {"w": "used", "b": [0.1429, 0.4627, 0.1814, 0.4841]}, {"w": "in", "b": [0.1879, 0.4627, 0.2049, 0.4841]}, {"w": "the", "b": [0.2113, 0.4627, 0.2376, 0.4841]}, {"w": "output", "b": [0.2441, 0.4627, 0.3004, 0.4841]}, {"w": "layer", "b": [0.3069, 0.4627, 0.3471, 0.4841]}, {"w": "of", "b": [0.3535, 0.4627, 0.3703, 0.4841]}, {"w": "a", "b": [0.3768, 0.4627, 0.3859, 0.4841]}, {"w": "regression", "b": [0.3924, 0.4627, 0.4782, 0.4841]}, {"w": "model", "b": [0.4846, 0.4627, 0.5374, 0.4841]}, {"w": "when", "b": [0.5439, 0.4627, 0.5895, 0.4841]}, {"w": "the", "b": [0.596, 0.4627, 0.6223, 0.4841]}, {"w": "values", "b": [0.6287, 0.4627, 0.6804, 0.4841]}, {"w": "to", "b": [0.6868, 0.4627, 0.7038, 0.4841]}, {"w": "predict", "b": [0.7102, 0.4627, 0.7695, 0.4841]}, {"w": "have", "b": [0.7759, 0.4627, 0.8143, 0.4841]}, {"w": "very", "b": [0.8208, 0.4627, 0.8572, 0.4841]}, {"w": "different", "b": [0.1429, 0.4817, 0.2146, 0.5031]}, {"w": "scales", "b": [0.2193, 0.4817, 0.2667, 0.5031]}, {"w": "(e.g.,", "b": [0.2714, 0.4817, 0.3115, 0.5031]}, {"w": "0.001,", "b": [0.3162, 0.4817, 0.3657, 0.5031]}, {"w": "10.,", "b": [0.3704, 0.4817, 0.3999, 0.5031]}, {"w": "1000.).", "b": [0.4047, 0.4817, 0.4614, 0.5031]}]}, {"id": "b_5", "type": "paragraph", "text": "As you probably guessed by now, to build a custom stateful layer (i.e., a layer with weights), you need to create a subclass of the keras.layers.Layer class. For exam‐ ple, the following class implements a simplified version of the Dense layer:", "words": [{"w": "As", "b": [0.1429, 0.5098, 0.1649, 0.5312]}, {"w": "you", "b": [0.1721, 0.5098, 0.2033, 0.5312]}, {"w": "probably", "b": [0.2105, 0.5098, 0.2849, 0.5312]}, {"w": "guessed", "b": [0.2921, 0.5098, 0.3569, 0.5312]}, {"w": "by", "b": [0.3641, 0.5098, 0.3842, 0.5312]}, {"w": "now,", "b": [0.3914, 0.5098, 0.4309, 0.5312]}, {"w": "to", "b": [0.4381, 0.5098, 0.4551, 0.5312]}, {"w": "build", "b": [0.4623, 0.5098, 0.5058, 0.5312]}, {"w": "a", "b": [0.513, 0.5098, 0.5221, 0.5312]}, {"w": "custom", "b": [0.5293, 0.5098, 0.5909, 0.5312]}, {"w": "stateful", "b": [0.598, 0.5098, 0.6585, 0.5312]}, {"w": "layer", "b": [0.6657, 0.5098, 0.7059, 0.5312]}, {"w": "(i.e.,", "b": [0.713, 0.5098, 0.7489, 0.5312]}, {"w": "a", "b": [0.7561, 0.5098, 0.7653, 0.5312]}, {"w": "layer", "b": [0.7724, 0.5098, 0.8126, 0.5312]}, {"w": "with", "b": [0.8198, 0.5098, 0.8571, 0.5312]}, {"w": "weights),", "b": [0.1429, 0.5298, 0.218, 0.5512]}, {"w": "you", "b": [0.2246, 0.5298, 0.2558, 0.5512]}, {"w": "need", "b": [0.2624, 0.5298, 0.3025, 0.5512]}, {"w": "to", "b": [0.309, 0.5298, 0.326, 0.5512]}, {"w": "create", "b": [0.3326, 0.5298, 0.3819, 0.5512]}, {"w": "a", "b": [0.3885, 0.5298, 0.3976, 0.5512]}, {"w": "subclass", "b": [0.4042, 0.5298, 0.472, 0.5512]}, {"w": "of", "b": [0.4785, 0.5298, 0.4953, 0.5512]}, {"w": "the", "b": [0.5019, 0.5298, 0.5282, 0.5512]}, {"w": "keras.layers.Layer", "b": [0.5348, 0.5329, 0.7129, 0.548]}, {"w": "class.", "b": [0.7195, 0.5298, 0.7627, 0.5512]}, {"w": "For", "b": [0.7693, 0.5298, 0.7983, 0.5512]}, {"w": "exam‐", "b": [0.8048, 0.5298, 0.8571, 0.5512]}, {"w": "ple,", "b": [0.1428, 0.5497, 0.1726, 0.5711]}, {"w": "the", "b": [0.1774, 0.5497, 0.2037, 0.5711]}, {"w": "following", "b": [0.2084, 0.5497, 0.2874, 0.5711]}, {"w": "class", "b": [0.2921, 0.5497, 0.3306, 0.5711]}, {"w": "implements", "b": [0.3354, 0.5497, 0.4336, 0.5711]}, {"w": "a", "b": [0.4383, 0.5497, 0.4475, 0.5711]}, {"w": "simplified", "b": [0.4522, 0.5497, 0.5355, 0.5711]}, {"w": "version", "b": [0.5402, 0.5497, 0.6017, 0.5711]}, {"w": "of", "b": [0.6064, 0.5497, 0.6232, 0.5711]}, {"w": "the", "b": [0.6279, 0.5497, 0.6542, 0.5711]}, {"w": "Dense", "b": [0.659, 0.5529, 0.7085, 0.568]}, {"w": "layer:", "b": [0.7132, 0.5497, 0.7586, 0.5711]}]}, {"id": "b_6", "type": "paragraph", "text": "class MyDense(keras.layers.Layer): def __init__(self, units, activation=None, **kwargs): super().__init__(**kwargs) self.units = units self.activation = keras.activations.get(activation)", "words": [{"w": "class", "b": [0.1766, 0.5817, 0.2188, 0.5945]}, {"w": "MyDense(keras.layers.Layer):", "b": [0.2272, 0.5817, 0.4633, 0.5945]}, {"w": "def", "b": [0.2103, 0.5971, 0.2356, 0.61]}, {"w": "__init__(self,", "b": [0.2441, 0.5971, 0.3621, 0.61]}, {"w": "units,", "b": [0.3705, 0.5971, 0.4211, 0.61]}, {"w": "activation=None,", "b": [0.4296, 0.5971, 0.5645, 0.61]}, {"w": "**kwargs):", "b": [0.5729, 0.5971, 0.6572, 0.61]}, {"w": "super().__init__(**kwargs)", "b": [0.2441, 0.6125, 0.4633, 0.6254]}, {"w": "self.units", "b": [0.2441, 0.6279, 0.3284, 0.6408]}, {"w": "=", "b": [0.3368, 0.6279, 0.3452, 0.6408]}, {"w": "units", "b": [0.3537, 0.6279, 0.3958, 0.6408]}, {"w": "self.activation", "b": [0.2441, 0.6434, 0.3705, 0.6562]}, {"w": "=", "b": [0.379, 0.6434, 0.3874, 0.6562]}, {"w": "keras.activations.get(activation)", "b": [0.3958, 0.6434, 0.6741, 0.6562]}]}, {"id": "b_7", "type": "paragraph", "text": "def build(self, batch_input_shape): self.kernel = self.add_weight( name=\"kernel\", shape=[batch_input_shape[-1], self.units], initializer=\"glorot_normal\") self.bias = self.add_weight( name=\"bias\", shape=[self.units], initializer=\"zeros\") super().build(batch_input_shape) # must be at the end", "words": [{"w": "def", "b": [0.2103, 0.6742, 0.2356, 0.6871]}, {"w": "build(self,", "b": [0.2441, 0.6742, 0.3368, 0.6871]}, {"w": "batch_input_shape):", "b": [0.3452, 0.6742, 0.5055, 0.6871]}, {"w": "self.kernel", "b": [0.2441, 0.6896, 0.3368, 0.7025]}, {"w": "=", "b": [0.3452, 0.6896, 0.3537, 0.7025]}, {"w": "self.add_weight(", "b": [0.3621, 0.6896, 0.497, 0.7025]}, {"w": "name=\"kernel\",", "b": [0.2778, 0.705, 0.3958, 0.7179]}, {"w": "shape=[batch_input_shape[-1],", "b": [0.4043, 0.705, 0.6488, 0.7179]}, {"w": "self.units],", "b": [0.6572, 0.705, 0.7584, 0.7179]}, {"w": "initializer=\"glorot_normal\")", "b": [0.2778, 0.7205, 0.5139, 0.7333]}, {"w": "self.bias", "b": [0.2441, 0.7359, 0.3199, 0.7487]}, {"w": "=", "b": [0.3284, 0.7359, 0.3368, 0.7487]}, {"w": "self.add_weight(", "b": [0.3452, 0.7359, 0.4802, 0.7487]}, {"w": "name=\"bias\",", "b": [0.2778, 0.7513, 0.379, 0.7641]}, {"w": "shape=[self.units],", "b": [0.3874, 0.7513, 0.5476, 0.7641]}, {"w": "initializer=\"zeros\")", "b": [0.5561, 0.7513, 0.7247, 0.7641]}, {"w": "super().build(batch_input_shape)", "b": [0.2441, 0.7667, 0.5139, 0.7796]}, {"w": "#", "b": [0.5223, 0.7667, 0.5308, 0.7796]}, {"w": "must", "b": [0.5392, 0.7667, 0.5729, 0.7796]}, {"w": "be", "b": [0.5814, 0.7667, 0.5982, 0.7796]}, {"w": "at", "b": [0.6067, 0.7667, 0.6235, 0.7796]}, {"w": "the", "b": [0.6319, 0.7667, 0.6572, 0.7796]}, {"w": "end", "b": [0.6657, 0.7667, 0.691, 0.7796]}]}, {"id": "b_8", "type": "equation", "text": "def call(self, X): return self.activation(X @ self.kernel + self.bias)", "words": [{"w": "def", "b": [0.2103, 0.7976, 0.2356, 0.8104]}, {"w": "call(self,", "b": [0.2441, 0.7976, 0.3284, 0.8104]}, {"w": "X):", "b": [0.3368, 0.7976, 0.3621, 0.8104]}, {"w": "return", "b": [0.2441, 0.813, 0.2946, 0.8258]}, {"w": "self.activation(X", "b": [0.3031, 0.813, 0.4464, 0.8258]}, {"w": "@", "b": [0.4549, 0.813, 0.4633, 0.8258]}, {"w": "self.kernel", "b": [0.4717, 0.813, 0.5645, 0.8258]}, {"w": "+", "b": [0.5729, 0.813, 0.5814, 0.8258]}, {"w": "self.bias)", "b": [0.5898, 0.813, 0.6741, 0.8258]}]}, {"id": "b_9", "type": "paragraph", "text": "def compute_output_shape(self, batch_input_shape): return tf.TensorShape(batch_input_shape.as_list()[:-1] + [self.units])", "words": [{"w": "def", "b": [0.2103, 0.8438, 0.2356, 0.8567]}, {"w": "compute_output_shape(self,", "b": [0.2441, 0.8438, 0.4633, 0.8567]}, {"w": "batch_input_shape):", "b": [0.4717, 0.8438, 0.6319, 0.8567]}, {"w": "return", "b": [0.2441, 0.8592, 0.2946, 0.8721]}, {"w": "tf.TensorShape(batch_input_shape.as_list()[:-1]", "b": [0.3031, 0.8592, 0.6994, 0.8721]}, {"w": "+", "b": [0.7078, 0.8592, 0.7163, 0.8721]}, {"w": "[self.units])", "b": [0.7247, 0.8592, 0.8343, 0.8721]}]}, {"id": "b_10", "type": "paragraph", "text": "Customizing Models and Training Algorithms | 383", "words": [{"w": "Customizing", "b": [0.5328, 0.9225, 0.6056, 0.9388]}, {"w": "Models", "b": [0.6084, 0.9225, 0.6507, 0.9388]}, {"w": "and", "b": [0.6535, 0.9225, 0.6759, 0.9388]}, {"w": "Training", "b": [0.6787, 0.9225, 0.7278, 0.9388]}, {"w": "Algorithms", "b": [0.7306, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "383", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 410, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "8 This function is specific to tf.keras. You could use keras.activations.Activation instead.", "words": [{"w": "8", "b": [0.1451, 0.8395, 0.1518, 0.8538]}, {"w": "This", "b": [0.1587, 0.838, 0.1871, 0.8544]}, {"w": "function", "b": [0.1907, 0.838, 0.2451, 0.8544]}, {"w": "is", "b": [0.2487, 0.838, 0.2588, 0.8544]}, {"w": "specific", "b": [0.2624, 0.838, 0.3099, 0.8544]}, {"w": "to", "b": [0.3135, 0.838, 0.3264, 0.8544]}, {"w": "tf.keras.", "b": [0.33, 0.838, 0.3801, 0.8544]}, {"w": "You", "b": [0.3837, 0.838, 0.4084, 0.8544]}, {"w": "could", "b": [0.412, 0.838, 0.4476, 0.8544]}, {"w": "use", "b": [0.4512, 0.838, 0.4722, 0.8544]}, {"w": "keras.activations.Activation", "b": [0.4758, 0.8405, 0.6869, 0.852]}, {"w": "instead.", "b": [0.6905, 0.838, 0.7398, 0.8544]}]}, {"id": "b_1", "type": "paragraph", "text": "9 The Keras API calls this argument input_shape, but since it also includes the batch dimension, I prefer to call it batch_input_shape. Same for compute_output_shape().", "words": [{"w": "9", "b": [0.1451, 0.8602, 0.1518, 0.8745]}, {"w": "The", "b": [0.1587, 0.8587, 0.1837, 0.8751]}, {"w": "Keras", "b": [0.1873, 0.8587, 0.2231, 0.8751]}, {"w": "API", "b": [0.2267, 0.8587, 0.252, 0.8751]}, {"w": "calls", "b": [0.2556, 0.8587, 0.2831, 0.8751]}, {"w": "this", "b": [0.2867, 0.8587, 0.3101, 0.8751]}, {"w": "argument", "b": [0.3137, 0.8587, 0.3754, 0.8751]}, {"w": "input_shape,", "b": [0.379, 0.8587, 0.4656, 0.8751]}, {"w": "but", "b": [0.4692, 0.8587, 0.4905, 0.8751]}, {"w": "since", "b": [0.4941, 0.8587, 0.5263, 0.8751]}, {"w": "it", "b": [0.53, 0.8587, 0.539, 0.8751]}, {"w": "also", "b": [0.5427, 0.8587, 0.5676, 0.8751]}, {"w": "includes", "b": [0.5712, 0.8587, 0.6242, 0.8751]}, {"w": "the", "b": [0.6278, 0.8587, 0.6479, 0.8751]}, {"w": "batch", "b": [0.6515, 0.8587, 0.6862, 0.8751]}, {"w": "dimension,", "b": [0.6898, 0.8587, 0.7614, 0.8751]}, {"w": "I", "b": [0.765, 0.8587, 0.7704, 0.8751]}, {"w": "prefer", "b": [0.774, 0.8587, 0.8123, 0.8751]}, {"w": "to", "b": [0.8159, 0.8587, 0.8288, 0.8751]}, {"w": "call", "b": [0.8324, 0.8587, 0.8541, 0.8751]}, {"w": "it", "b": [0.1587, 0.8749, 0.1678, 0.8912]}, {"w": "batch_input_shape.", "b": [0.1714, 0.8749, 0.3032, 0.8912]}, {"w": "Same", "b": [0.3068, 0.8749, 0.3411, 0.8912]}, {"w": "for", "b": [0.3447, 0.8749, 0.3633, 0.8912]}, {"w": "compute_output_shape().", "b": [0.367, 0.8749, 0.5364, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "def get_config(self): base_config = super().get_config() return {**base_config, \"units\": self.units, \"activation\": keras.activations.serialize(self.activation)}", "words": [{"w": "def", "b": [0.2103, 0.0829, 0.2356, 0.0958]}, {"w": "get_config(self):", "b": [0.244, 0.0829, 0.3874, 0.0958]}, {"w": "base_config", "b": [0.244, 0.0983, 0.3368, 0.1112]}, {"w": "=", "b": [0.3452, 0.0983, 0.3537, 0.1112]}, {"w": "super().get_config()", "b": [0.3621, 0.0983, 0.5308, 0.1112]}, {"w": "return", "b": [0.244, 0.1138, 0.2946, 0.1266]}, {"w": "{**base_config,", "b": [0.3031, 0.1138, 0.4296, 0.1266]}, {"w": "\"units\":", "b": [0.438, 0.1138, 0.5055, 0.1266]}, {"w": "self.units,", "b": [0.5139, 0.1138, 0.6066, 0.1266]}, {"w": "\"activation\":", "b": [0.3115, 0.1292, 0.4211, 0.142]}, {"w": "keras.activations.serialize(self.activation)}", "b": [0.4296, 0.1292, 0.809, 0.142]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s walk through this code:", "words": [{"w": "Let’s", "b": [0.1429, 0.1498, 0.179, 0.1712]}, {"w": "walk", "b": [0.1838, 0.1498, 0.2228, 0.1712]}, {"w": "through", "b": [0.2275, 0.1498, 0.2953, 0.1712]}, {"w": "this", "b": [0.3, 0.1498, 0.3307, 0.1712]}, {"w": "code:", "b": [0.3354, 0.1498, 0.3795, 0.1712]}]}, {"id": "b_4", "type": "paragraph", "text": "• The constructor takes all the hyperparameters as arguments (in this example just units and activation), and importantly it also takes a **kwargs argument. It calls the parent constructor, passing it the kwargs: this takes care of standard arguments such as input_shape, trainable, name, and so on. Then it saves the hyperparameters as attributes, converting the activation argument to the appropriate activation function using the keras.activations.get() function (it accepts functions, standard strings like \"relu\" or \"selu\", or simply None)8.", "words": [{"w": "•", "b": [0.16, 0.184, 0.1682, 0.2054]}, {"w": "The", "b": [0.1786, 0.184, 0.2114, 0.2054]}, {"w": "constructor", "b": [0.2168, 0.184, 0.3139, 0.2054]}, {"w": "takes", "b": [0.3192, 0.184, 0.3616, 0.2054]}, {"w": "all", "b": [0.3669, 0.184, 0.3866, 0.2054]}, {"w": "the", "b": [0.392, 0.184, 0.4183, 0.2054]}, {"w": "hyperparameters", "b": [0.4237, 0.184, 0.5648, 0.2054]}, {"w": "as", "b": [0.5702, 0.184, 0.5869, 0.2054]}, {"w": "arguments", "b": [0.5923, 0.184, 0.6809, 0.2054]}, {"w": "(in", "b": [0.6863, 0.184, 0.7104, 0.2054]}, {"w": "this", "b": [0.7158, 0.184, 0.7465, 0.2054]}, {"w": "example", "b": [0.7518, 0.184, 0.8214, 0.2054]}, {"w": "just", "b": [0.8267, 0.184, 0.8571, 0.2054]}, {"w": "units", "b": [0.1786, 0.2071, 0.2281, 0.2222]}, {"w": "and", "b": [0.2355, 0.2039, 0.2671, 0.2253]}, {"w": "activation),", "b": [0.2746, 0.2039, 0.3855, 0.2253]}, {"w": "and", "b": [0.393, 0.2039, 0.4245, 0.2253]}, {"w": "importantly", "b": [0.432, 0.2039, 0.5312, 0.2253]}, {"w": "it", "b": [0.5387, 0.2039, 0.5506, 0.2253]}, {"w": "also", "b": [0.5581, 0.2039, 0.5908, 0.2253]}, {"w": "takes", "b": [0.5982, 0.2039, 0.6406, 0.2253]}, {"w": "a", "b": [0.6481, 0.2039, 0.6572, 0.2253]}, {"w": "**kwargs", "b": [0.6647, 0.2071, 0.7438, 0.2222]}, {"w": "argument.", "b": [0.7513, 0.2039, 0.837, 0.2253]}, {"w": "It", "b": [0.8445, 0.2039, 0.8572, 0.2253]}, {"w": "calls", "b": [0.1786, 0.2239, 0.2147, 0.2453]}, {"w": "the", "b": [0.223, 0.2239, 0.2493, 0.2453]}, {"w": "parent", "b": [0.2576, 0.2239, 0.3116, 0.2453]}, {"w": "constructor,", "b": [0.3199, 0.2239, 0.4204, 0.2453]}, {"w": "passing", "b": [0.4287, 0.2239, 0.4908, 0.2453]}, {"w": "it", "b": [0.4991, 0.2239, 0.511, 0.2453]}, {"w": "the", "b": [0.5193, 0.2239, 0.5456, 0.2453]}, {"w": "kwargs:", "b": [0.5539, 0.2239, 0.618, 0.2453]}, {"w": "this", "b": [0.6263, 0.2239, 0.657, 0.2453]}, {"w": "takes", "b": [0.6652, 0.2239, 0.7076, 0.2453]}, {"w": "care", "b": [0.7158, 0.2239, 0.7504, 0.2453]}, {"w": "of", "b": [0.7587, 0.2239, 0.7755, 0.2453]}, {"w": "standard", "b": [0.7837, 0.2239, 0.8571, 0.2453]}, {"w": "arguments", "b": [0.1786, 0.2438, 0.2672, 0.2652]}, {"w": "such", "b": [0.2739, 0.2438, 0.3126, 0.2652]}, {"w": "as", "b": [0.3193, 0.2438, 0.3361, 0.2652]}, {"w": "input_shape,", "b": [0.3429, 0.2438, 0.4565, 0.2652]}, {"w": "trainable,", "b": [0.4633, 0.2438, 0.5571, 0.2652]}, {"w": "name,", "b": [0.5638, 0.2438, 0.6082, 0.2652]}, {"w": "and", "b": [0.6149, 0.2438, 0.6465, 0.2652]}, {"w": "so", "b": [0.6532, 0.2438, 0.6715, 0.2652]}, {"w": "on.", "b": [0.6783, 0.2438, 0.705, 0.2652]}, {"w": "Then", "b": [0.7118, 0.2438, 0.756, 0.2652]}, {"w": "it", "b": [0.7628, 0.2438, 0.7747, 0.2652]}, {"w": "saves", "b": [0.7815, 0.2438, 0.8241, 0.2652]}, {"w": "the", "b": [0.8308, 0.2438, 0.8571, 0.2652]}, {"w": "hyperparameters", "b": [0.1786, 0.2638, 0.3197, 0.2852]}, {"w": "as", "b": [0.3319, 0.2638, 0.3487, 0.2852]}, {"w": "attributes,", "b": [0.3608, 0.2638, 0.4449, 0.2852]}, {"w": "converting", "b": [0.457, 0.2638, 0.5467, 0.2852]}, {"w": "the", "b": [0.5589, 0.2638, 0.5852, 0.2852]}, {"w": "activation", "b": [0.5974, 0.2669, 0.6963, 0.282]}, {"w": "argument", "b": [0.7085, 0.2638, 0.7895, 0.2852]}, {"w": "to", "b": [0.8016, 0.2638, 0.8186, 0.2852]}, {"w": "the", "b": [0.8308, 0.2638, 0.8571, 0.2852]}, {"w": "appropriate", "b": [0.1786, 0.2837, 0.2757, 0.3051]}, {"w": "activation", "b": [0.2811, 0.2837, 0.3634, 0.3051]}, {"w": "function", "b": [0.3688, 0.2837, 0.4402, 0.3051]}, {"w": "using", "b": [0.4456, 0.2837, 0.491, 0.3051]}, {"w": "the", "b": [0.4964, 0.2837, 0.5228, 0.3051]}, {"w": "keras.activations.get()", "b": [0.5282, 0.2869, 0.7558, 0.302]}, {"w": "function", "b": [0.7612, 0.2837, 0.8326, 0.3051]}, {"w": "(it", "b": [0.8373, 0.2837, 0.8565, 0.3051]}, {"w": "accepts", "b": [0.1786, 0.3036, 0.2391, 0.3251]}, {"w": "functions,", "b": [0.2438, 0.3036, 0.3276, 0.3251]}, {"w": "standard", "b": [0.3324, 0.3036, 0.4058, 0.3251]}, {"w": "strings", "b": [0.4105, 0.3036, 0.4666, 0.3251]}, {"w": "like", "b": [0.4713, 0.3036, 0.5014, 0.3251]}, {"w": "\"relu\"", "b": [0.5061, 0.3068, 0.5655, 0.3219]}, {"w": "or", "b": [0.5702, 0.3036, 0.5886, 0.3251]}, {"w": "\"selu\",", "b": [0.5933, 0.3036, 0.6574, 0.3251]}, {"w": "or", "b": [0.6622, 0.3036, 0.6805, 0.3251]}, {"w": "simply", "b": [0.6852, 0.3036, 0.7409, 0.3251]}, {"w": "None)8.", "b": [0.7456, 0.3036, 0.8029, 0.3251]}]}, {"id": "b_5", "type": "paragraph", "text": "• The build() method’s role is to create the layer’s variables, by calling the add_weight() method for each weight. The build() method is called the first time the layer is used. At that point, Keras will know the shape of this layer’s inputs, and it will pass it to the build() method9, which is often necessary to cre‐ ate some of the weights. For example, we need to know the number of neurons in the previous layer in order to create the connection weights matrix (i.e., the \"ker nel\"): this corresponds to the size of the last dimension of the inputs. At the end of the build() method (and only at the end), you must call the parent’s build() method: this tells Keras that the layer is built (it just sets self.built = True).", "words": [{"w": "•", "b": [0.16, 0.3296, 0.1681, 0.351]}, {"w": "The", "b": [0.1786, 0.3296, 0.2114, 0.351]}, {"w": "build()", "b": [0.2225, 0.3328, 0.2917, 0.3479]}, {"w": "method’s", "b": [0.3028, 0.3296, 0.3776, 0.351]}, {"w": "role", "b": [0.3886, 0.3296, 0.4211, 0.351]}, {"w": "is", "b": [0.4322, 0.3296, 0.4454, 0.351]}, {"w": "to", "b": [0.4565, 0.3296, 0.4735, 0.351]}, {"w": "create", "b": [0.4845, 0.3296, 0.5339, 0.351]}, {"w": "the", "b": [0.5449, 0.3296, 0.5713, 0.351]}, {"w": "layer’s", "b": [0.5823, 0.3296, 0.6328, 0.351]}, {"w": "variables,", "b": [0.6439, 0.3296, 0.7222, 0.351]}, {"w": "by", "b": [0.7333, 0.3296, 0.7535, 0.351]}, {"w": "calling", "b": [0.7645, 0.3296, 0.8197, 0.351]}, {"w": "the", "b": [0.8308, 0.3296, 0.8571, 0.351]}, {"w": "add_weight()", "b": [0.1786, 0.3528, 0.2973, 0.3678]}, {"w": "method", "b": [0.3049, 0.3496, 0.3699, 0.371]}, {"w": "for", "b": [0.3775, 0.3496, 0.4021, 0.371]}, {"w": "each", "b": [0.4097, 0.3496, 0.4476, 0.371]}, {"w": "weight.", "b": [0.4552, 0.3496, 0.5155, 0.371]}, {"w": "The", "b": [0.5231, 0.3496, 0.5559, 0.371]}, {"w": "build()", "b": [0.5635, 0.3528, 0.6328, 0.3678]}, {"w": "method", "b": [0.6404, 0.3496, 0.7054, 0.371]}, {"w": "is", "b": [0.713, 0.3496, 0.7262, 0.371]}, {"w": "called", "b": [0.7338, 0.3496, 0.7822, 0.371]}, {"w": "the", "b": [0.7897, 0.3496, 0.8161, 0.371]}, {"w": "first", "b": [0.8237, 0.3496, 0.8572, 0.371]}, {"w": "time", "b": [0.1786, 0.3686, 0.2164, 0.39]}, {"w": "the", "b": [0.2244, 0.3686, 0.2508, 0.39]}, {"w": "layer", "b": [0.2588, 0.3686, 0.299, 0.39]}, {"w": "is", "b": [0.307, 0.3686, 0.3203, 0.39]}, {"w": "used.", "b": [0.3283, 0.3686, 0.3716, 0.39]}, {"w": "At", "b": [0.3796, 0.3686, 0.3995, 0.39]}, {"w": "that", "b": [0.4075, 0.3686, 0.4401, 0.39]}, {"w": "point,", "b": [0.4482, 0.3686, 0.4974, 0.39]}, {"w": "Keras", "b": [0.5054, 0.3686, 0.5523, 0.39]}, {"w": "will", "b": [0.5603, 0.3686, 0.5907, 0.39]}, {"w": "know", "b": [0.5988, 0.3686, 0.6454, 0.39]}, {"w": "the", "b": [0.6534, 0.3686, 0.6797, 0.39]}, {"w": "shape", "b": [0.6878, 0.3686, 0.7351, 0.39]}, {"w": "of", "b": [0.7431, 0.3686, 0.7599, 0.39]}, {"w": "this", "b": [0.7679, 0.3686, 0.7986, 0.39]}, {"w": "layer’s", "b": [0.8066, 0.3686, 0.8571, 0.39]}, {"w": "inputs,", "b": [0.1786, 0.3886, 0.2359, 0.41]}, {"w": "and", "b": [0.2409, 0.3886, 0.2724, 0.41]}, {"w": "it", "b": [0.2774, 0.3886, 0.2893, 0.41]}, {"w": "will", "b": [0.2943, 0.3886, 0.3247, 0.41]}, {"w": "pass", "b": [0.3296, 0.3886, 0.365, 0.41]}, {"w": "it", "b": [0.3699, 0.3886, 0.3819, 0.41]}, {"w": "to", "b": [0.3868, 0.3886, 0.4038, 0.41]}, {"w": "the", "b": [0.4088, 0.3886, 0.4351, 0.41]}, {"w": "build()", "b": [0.4401, 0.3918, 0.5093, 0.4068]}, {"w": "method9,", "b": [0.5143, 0.3886, 0.5898, 0.41]}, {"w": "which", "b": [0.5947, 0.3886, 0.6457, 0.41]}, {"w": "is", "b": [0.6506, 0.3886, 0.6639, 0.41]}, {"w": "often", "b": [0.6688, 0.3886, 0.7122, 0.41]}, {"w": "necessary", "b": [0.7172, 0.3886, 0.7974, 0.41]}, {"w": "to", "b": [0.8024, 0.3886, 0.8194, 0.41]}, {"w": "cre‐", "b": [0.8243, 0.3886, 0.8571, 0.41]}, {"w": "ate", "b": [0.1786, 0.4076, 0.2025, 0.429]}, {"w": "some", "b": [0.2075, 0.4076, 0.2517, 0.429]}, {"w": "of", "b": [0.2566, 0.4076, 0.2734, 0.429]}, {"w": "the", "b": [0.2784, 0.4076, 0.3047, 0.429]}, {"w": "weights.", "b": [0.3096, 0.4076, 0.3776, 0.429]}, {"w": "For", "b": [0.3825, 0.4076, 0.4115, 0.429]}, {"w": "example,", "b": [0.4164, 0.4076, 0.4907, 0.429]}, {"w": "we", "b": [0.4957, 0.4076, 0.5188, 0.429]}, {"w": "need", "b": [0.5237, 0.4076, 0.5638, 0.429]}, {"w": "to", "b": [0.5688, 0.4076, 0.5858, 0.429]}, {"w": "know", "b": [0.5907, 0.4076, 0.6373, 0.429]}, {"w": "the", "b": [0.6423, 0.4076, 0.6686, 0.429]}, {"w": "number", "b": [0.6736, 0.4076, 0.7398, 0.429]}, {"w": "of", "b": [0.7448, 0.4076, 0.7616, 0.429]}, {"w": "neurons", "b": [0.7665, 0.4076, 0.8352, 0.429]}, {"w": "in", "b": [0.8402, 0.4076, 0.8572, 0.429]}, {"w": "the", "b": [0.1786, 0.4276, 0.2049, 0.449]}, {"w": "previous", "b": [0.2103, 0.4276, 0.2823, 0.449]}, {"w": "layer", "b": [0.2877, 0.4276, 0.3279, 0.449]}, {"w": "in", "b": [0.3332, 0.4276, 0.3502, 0.449]}, {"w": "order", "b": [0.3556, 0.4276, 0.4015, 0.449]}, {"w": "to", "b": [0.4069, 0.4276, 0.4238, 0.449]}, {"w": "create", "b": [0.4292, 0.4276, 0.4785, 0.449]}, {"w": "the", "b": [0.4839, 0.4276, 0.5102, 0.449]}, {"w": "connection", "b": [0.5156, 0.4276, 0.6094, 0.449]}, {"w": "weights", "b": [0.6148, 0.4276, 0.678, 0.449]}, {"w": "matrix", "b": [0.6834, 0.4276, 0.7387, 0.449]}, {"w": "(i.e.,", "b": [0.744, 0.4276, 0.7799, 0.449]}, {"w": "the", "b": [0.7853, 0.4276, 0.8116, 0.449]}, {"w": "\"ker", "b": [0.817, 0.4307, 0.8565, 0.4458]}, {"w": "nel\"):", "b": [0.1786, 0.4475, 0.2301, 0.4689]}, {"w": "this", "b": [0.2355, 0.4475, 0.2662, 0.4689]}, {"w": "corresponds", "b": [0.2716, 0.4475, 0.3746, 0.4689]}, {"w": "to", "b": [0.3799, 0.4475, 0.3969, 0.4689]}, {"w": "the", "b": [0.4023, 0.4475, 0.4286, 0.4689]}, {"w": "size", "b": [0.434, 0.4475, 0.4648, 0.4689]}, {"w": "of", "b": [0.4702, 0.4475, 0.487, 0.4689]}, {"w": "the", "b": [0.4924, 0.4475, 0.5187, 0.4689]}, {"w": "last", "b": [0.5241, 0.4475, 0.5525, 0.4689]}, {"w": "dimension", "b": [0.5579, 0.4475, 0.647, 0.4689]}, {"w": "of", "b": [0.6524, 0.4475, 0.6692, 0.4689]}, {"w": "the", "b": [0.6745, 0.4475, 0.7009, 0.4689]}, {"w": "inputs.", "b": [0.7062, 0.4475, 0.7636, 0.4689]}, {"w": "At", "b": [0.7689, 0.4475, 0.7888, 0.4689]}, {"w": "the", "b": [0.7942, 0.4475, 0.8205, 0.4689]}, {"w": "end", "b": [0.8259, 0.4475, 0.8572, 0.4689]}, {"w": "of", "b": [0.1786, 0.4674, 0.1954, 0.4889]}, {"w": "the", "b": [0.2011, 0.4674, 0.2274, 0.4889]}, {"w": "build()", "b": [0.2331, 0.4706, 0.3024, 0.4857]}, {"w": "method", "b": [0.3081, 0.4674, 0.3731, 0.4889]}, {"w": "(and", "b": [0.3789, 0.4674, 0.4176, 0.4889]}, {"w": "only", "b": [0.4233, 0.4674, 0.4602, 0.4889]}, {"w": "at", "b": [0.4659, 0.4674, 0.481, 0.4889]}, {"w": "the", "b": [0.4867, 0.4674, 0.5131, 0.4889]}, {"w": "end),", "b": [0.5188, 0.4674, 0.562, 0.4889]}, {"w": "you", "b": [0.5677, 0.4674, 0.599, 0.4889]}, {"w": "must", "b": [0.6047, 0.4674, 0.6464, 0.4889]}, {"w": "call", "b": [0.6521, 0.4674, 0.6806, 0.4889]}, {"w": "the", "b": [0.6863, 0.4674, 0.7127, 0.4889]}, {"w": "parent’s", "b": [0.7184, 0.4674, 0.7822, 0.4889]}, {"w": "build()", "b": [0.7879, 0.4706, 0.8571, 0.4857]}, {"w": "method:", "b": [0.1786, 0.4874, 0.2483, 0.5088]}, {"w": "this", "b": [0.2531, 0.4874, 0.2838, 0.5088]}, {"w": "tells", "b": [0.2885, 0.4874, 0.3219, 0.5088]}, {"w": "Keras", "b": [0.3266, 0.4874, 0.3735, 0.5088]}, {"w": "that", "b": [0.3783, 0.4874, 0.4108, 0.5088]}, {"w": "the", "b": [0.4156, 0.4874, 0.4419, 0.5088]}, {"w": "layer", "b": [0.4466, 0.4874, 0.4868, 0.5088]}, {"w": "is", "b": [0.4916, 0.4874, 0.5048, 0.5088]}, {"w": "built", "b": [0.5095, 0.4874, 0.5484, 0.5088]}, {"w": "(it", "b": [0.5531, 0.4874, 0.5722, 0.5088]}, {"w": "just", "b": [0.577, 0.4874, 0.6074, 0.5088]}, {"w": "sets", "b": [0.6121, 0.4874, 0.6426, 0.5088]}, {"w": "self.built", "b": [0.6473, 0.4906, 0.7463, 0.5057]}, {"w": "=", "b": [0.7562, 0.4906, 0.7661, 0.5057]}, {"w": "True).", "b": [0.776, 0.4874, 0.8275, 0.5088]}]}, {"id": "b_6", "type": "paragraph", "text": "• The call() method actually performs the desired operations. In this case, we compute the matrix multiplication of the inputs X and the layer’s kernel, we add the bias vector, we apply the activation function to the result, and this gives us the output of the layer.", "words": [{"w": "•", "b": [0.16, 0.5134, 0.1681, 0.5348]}, {"w": "The", "b": [0.1786, 0.5134, 0.2114, 0.5348]}, {"w": "call()", "b": [0.2194, 0.5166, 0.2788, 0.5316]}, {"w": "method", "b": [0.2868, 0.5134, 0.3518, 0.5348]}, {"w": "actually", "b": [0.3599, 0.5134, 0.4245, 0.5348]}, {"w": "performs", "b": [0.4325, 0.5134, 0.5092, 0.5348]}, {"w": "the", "b": [0.5172, 0.5134, 0.5436, 0.5348]}, {"w": "desired", "b": [0.5516, 0.5134, 0.6123, 0.5348]}, {"w": "operations.", "b": [0.6203, 0.5134, 0.7135, 0.5348]}, {"w": "In", "b": [0.7215, 0.5134, 0.74, 0.5348]}, {"w": "this", "b": [0.7481, 0.5134, 0.7788, 0.5348]}, {"w": "case,", "b": [0.7868, 0.5134, 0.826, 0.5348]}, {"w": "we", "b": [0.834, 0.5134, 0.8571, 0.5348]}, {"w": "compute", "b": [0.1786, 0.5333, 0.2519, 0.5547]}, {"w": "the", "b": [0.258, 0.5333, 0.2844, 0.5547]}, {"w": "matrix", "b": [0.2905, 0.5333, 0.3458, 0.5547]}, {"w": "multiplication", "b": [0.352, 0.5333, 0.4702, 0.5547]}, {"w": "of", "b": [0.4764, 0.5333, 0.4931, 0.5547]}, {"w": "the", "b": [0.4993, 0.5333, 0.5256, 0.5547]}, {"w": "inputs", "b": [0.5318, 0.5333, 0.5843, 0.5547]}, {"w": "X", "b": [0.5905, 0.5365, 0.6004, 0.5516]}, {"w": "and", "b": [0.6065, 0.5333, 0.6381, 0.5547]}, {"w": "the", "b": [0.6442, 0.5333, 0.6706, 0.5547]}, {"w": "layer’s", "b": [0.6767, 0.5333, 0.7272, 0.5547]}, {"w": "kernel,", "b": [0.7334, 0.5333, 0.7906, 0.5547]}, {"w": "we", "b": [0.7967, 0.5333, 0.8198, 0.5547]}, {"w": "add", "b": [0.826, 0.5333, 0.8571, 0.5547]}, {"w": "the", "b": [0.1786, 0.5524, 0.2049, 0.5738]}, {"w": "bias", "b": [0.2096, 0.5524, 0.2426, 0.5738]}, {"w": "vector,", "b": [0.2473, 0.5524, 0.3028, 0.5738]}, {"w": "we", "b": [0.3075, 0.5524, 0.3306, 0.5738]}, {"w": "apply", "b": [0.3354, 0.5524, 0.3808, 0.5738]}, {"w": "the", "b": [0.3855, 0.5524, 0.4118, 0.5738]}, {"w": "activation", "b": [0.4166, 0.5524, 0.4988, 0.5738]}, {"w": "function", "b": [0.5035, 0.5524, 0.5749, 0.5738]}, {"w": "to", "b": [0.5797, 0.5524, 0.5966, 0.5738]}, {"w": "the", "b": [0.6014, 0.5524, 0.6277, 0.5738]}, {"w": "result,", "b": [0.6324, 0.5524, 0.6841, 0.5738]}, {"w": "and", "b": [0.6888, 0.5524, 0.7204, 0.5738]}, {"w": "this", "b": [0.7251, 0.5524, 0.7558, 0.5738]}, {"w": "gives", "b": [0.7605, 0.5524, 0.802, 0.5738]}, {"w": "us", "b": [0.8067, 0.5524, 0.8255, 0.5738]}, {"w": "the", "b": [0.8302, 0.5524, 0.8565, 0.5738]}, {"w": "output", "b": [0.1786, 0.5714, 0.2349, 0.5928]}, {"w": "of", "b": [0.2397, 0.5714, 0.2565, 0.5928]}, {"w": "the", "b": [0.2612, 0.5714, 0.2875, 0.5928]}, {"w": "layer.", "b": [0.2922, 0.5714, 0.3359, 0.5928]}]}, {"id": "b_7", "type": "paragraph", "text": "• The compute_output_shape() method simply returns the shape of this layer’s outputs. In this case, it is the same shape as the inputs, except the last dimension is replaced with the number of neurons in the layer. Note that in tf.keras, shapes are instances of the tf.TensorShape class, which you can convert to Python lists using as_list().", "words": [{"w": "•", "b": [0.16, 0.5974, 0.1682, 0.6188]}, {"w": "The", "b": [0.1786, 0.5974, 0.2114, 0.6188]}, {"w": "compute_output_shape()", "b": [0.2197, 0.6006, 0.4374, 0.6157]}, {"w": "method", "b": [0.4458, 0.5974, 0.5108, 0.6188]}, {"w": "simply", "b": [0.5191, 0.5974, 0.5748, 0.6188]}, {"w": "returns", "b": [0.5831, 0.5974, 0.6439, 0.6188]}, {"w": "the", "b": [0.6522, 0.5974, 0.6785, 0.6188]}, {"w": "shape", "b": [0.6869, 0.5974, 0.7341, 0.6188]}, {"w": "of", "b": [0.7425, 0.5974, 0.7593, 0.6188]}, {"w": "this", "b": [0.7676, 0.5974, 0.7983, 0.6188]}, {"w": "layer’s", "b": [0.8066, 0.5974, 0.8571, 0.6188]}, {"w": "outputs.", "b": [0.1786, 0.6165, 0.2473, 0.6379]}, {"w": "In", "b": [0.2528, 0.6165, 0.2713, 0.6379]}, {"w": "this", "b": [0.2768, 0.6165, 0.3075, 0.6379]}, {"w": "case,", "b": [0.3129, 0.6165, 0.3521, 0.6379]}, {"w": "it", "b": [0.3576, 0.6165, 0.3695, 0.6379]}, {"w": "is", "b": [0.375, 0.6165, 0.3882, 0.6379]}, {"w": "the", "b": [0.3937, 0.6165, 0.42, 0.6379]}, {"w": "same", "b": [0.4255, 0.6165, 0.4682, 0.6379]}, {"w": "shape", "b": [0.4737, 0.6165, 0.521, 0.6379]}, {"w": "as", "b": [0.5264, 0.6165, 0.5432, 0.6379]}, {"w": "the", "b": [0.5487, 0.6165, 0.575, 0.6379]}, {"w": "inputs,", "b": [0.5805, 0.6165, 0.6378, 0.6379]}, {"w": "except", "b": [0.6432, 0.6165, 0.6969, 0.6379]}, {"w": "the", "b": [0.7023, 0.6165, 0.7287, 0.6379]}, {"w": "last", "b": [0.7341, 0.6165, 0.7625, 0.6379]}, {"w": "dimension", "b": [0.768, 0.6165, 0.8571, 0.6379]}, {"w": "is", "b": [0.1786, 0.6355, 0.1918, 0.6569]}, {"w": "replaced", "b": [0.1976, 0.6355, 0.2682, 0.6569]}, {"w": "with", "b": [0.274, 0.6355, 0.3113, 0.6569]}, {"w": "the", "b": [0.3171, 0.6355, 0.3435, 0.6569]}, {"w": "number", "b": [0.3493, 0.6355, 0.4156, 0.6569]}, {"w": "of", "b": [0.4214, 0.6355, 0.4382, 0.6569]}, {"w": "neurons", "b": [0.444, 0.6355, 0.5127, 0.6569]}, {"w": "in", "b": [0.5185, 0.6355, 0.5355, 0.6569]}, {"w": "the", "b": [0.5413, 0.6355, 0.5676, 0.6569]}, {"w": "layer.", "b": [0.5734, 0.6355, 0.6171, 0.6569]}, {"w": "Note", "b": [0.6229, 0.6355, 0.6637, 0.6569]}, {"w": "that", "b": [0.6695, 0.6355, 0.7021, 0.6569]}, {"w": "in", "b": [0.7079, 0.6355, 0.7248, 0.6569]}, {"w": "tf.keras,", "b": [0.7307, 0.6355, 0.7964, 0.6569]}, {"w": "shapes", "b": [0.8022, 0.6355, 0.8571, 0.6569]}, {"w": "are", "b": [0.1786, 0.6555, 0.2043, 0.6769]}, {"w": "instances", "b": [0.2098, 0.6555, 0.2867, 0.6769]}, {"w": "of", "b": [0.2922, 0.6555, 0.309, 0.6769]}, {"w": "the", "b": [0.3145, 0.6555, 0.3408, 0.6769]}, {"w": "tf.TensorShape", "b": [0.3464, 0.6586, 0.4849, 0.6737]}, {"w": "class,", "b": [0.4904, 0.6555, 0.5337, 0.6769]}, {"w": "which", "b": [0.5392, 0.6555, 0.5902, 0.6769]}, {"w": "you", "b": [0.5957, 0.6555, 0.6269, 0.6769]}, {"w": "can", "b": [0.6325, 0.6555, 0.6618, 0.6769]}, {"w": "convert", "b": [0.6673, 0.6555, 0.7303, 0.6769]}, {"w": "to", "b": [0.7358, 0.6555, 0.7528, 0.6769]}, {"w": "Python", "b": [0.7583, 0.6555, 0.8191, 0.6769]}, {"w": "lists", "b": [0.8246, 0.6555, 0.8571, 0.6769]}, {"w": "using", "b": [0.1786, 0.6754, 0.224, 0.6968]}, {"w": "as_list().", "b": [0.2287, 0.6754, 0.3226, 0.6968]}]}, {"id": "b_8", "type": "paragraph", "text": "• The get_config() method is just like earlier. Note that we save the activation function’s full configuration by calling keras.activations.serialize().", "words": [{"w": "•", "b": [0.16, 0.7014, 0.1681, 0.7228]}, {"w": "The", "b": [0.1786, 0.7014, 0.2114, 0.7228]}, {"w": "get_config()", "b": [0.219, 0.7046, 0.3378, 0.7197]}, {"w": "method", "b": [0.3454, 0.7014, 0.4105, 0.7228]}, {"w": "is", "b": [0.4181, 0.7014, 0.4313, 0.7228]}, {"w": "just", "b": [0.439, 0.7014, 0.4694, 0.7228]}, {"w": "like", "b": [0.477, 0.7014, 0.507, 0.7228]}, {"w": "earlier.", "b": [0.5147, 0.7014, 0.5713, 0.7228]}, {"w": "Note", "b": [0.5789, 0.7014, 0.6197, 0.7228]}, {"w": "that", "b": [0.6274, 0.7014, 0.6599, 0.7228]}, {"w": "we", "b": [0.6676, 0.7014, 0.6907, 0.7228]}, {"w": "save", "b": [0.6984, 0.7014, 0.7333, 0.7228]}, {"w": "the", "b": [0.7409, 0.7014, 0.7672, 0.7228]}, {"w": "activation", "b": [0.7749, 0.7014, 0.8571, 0.7228]}, {"w": "function’s", "b": [0.1786, 0.7213, 0.2586, 0.7427]}, {"w": "full", "b": [0.2633, 0.7213, 0.2911, 0.7427]}, {"w": "configuration", "b": [0.2958, 0.7213, 0.4096, 0.7427]}, {"w": "by", "b": [0.4144, 0.7213, 0.4345, 0.7427]}, {"w": "calling", "b": [0.4392, 0.7213, 0.4945, 0.7427]}, {"w": "keras.activations.serialize().", "b": [0.4992, 0.7213, 0.7909, 0.7427]}]}, {"id": "b_9", "type": "paragraph", "text": "You can now use a MyDense layer just like any other layer!", "words": [{"w": "You", "b": [0.1429, 0.7564, 0.1752, 0.7778]}, {"w": "can", "b": [0.18, 0.7564, 0.2093, 0.7778]}, {"w": "now", "b": [0.214, 0.7564, 0.2503, 0.7778]}, {"w": "use", "b": [0.2551, 0.7564, 0.2826, 0.7778]}, {"w": "a", "b": [0.2873, 0.7564, 0.2965, 0.7778]}, {"w": "MyDense", "b": [0.3012, 0.7596, 0.3705, 0.7747]}, {"w": "layer", "b": [0.3752, 0.7564, 0.4154, 0.7778]}, {"w": "just", "b": [0.4201, 0.7564, 0.4505, 0.7778]}, {"w": "like", "b": [0.4553, 0.7564, 0.4853, 0.7778]}, {"w": "any", "b": [0.49, 0.7564, 0.5197, 0.7778]}, {"w": "other", "b": [0.5244, 0.7564, 0.5691, 0.7778]}, {"w": "layer!", "b": [0.5738, 0.7564, 0.6197, 0.7778]}]}, {"id": "b_10", "type": "paragraph", "text": "384 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "384", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2745, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 411, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "You can generally omit the compute_output_shape() method, as tf.keras automatically infers the output shape, except when the layer is dynamic (as we will see shortly). In other Keras implemen‐ tations, this method is either required or by default it assumes the output shape is the same as the input shape.", "words": [{"w": "You", "b": [0.2714, 0.0801, 0.301, 0.0997]}, {"w": "can", "b": [0.3081, 0.0801, 0.335, 0.0997]}, {"w": "generally", "b": [0.3421, 0.0801, 0.4115, 0.0997]}, {"w": "omit", "b": [0.4186, 0.0801, 0.4548, 0.0997]}, {"w": "the", "b": [0.462, 0.0801, 0.4861, 0.0997]}, {"w": "compute_output_shape()", "b": [0.4932, 0.083, 0.6923, 0.0968]}, {"w": "method,", "b": [0.6994, 0.0801, 0.7632, 0.0997]}, {"w": "as", "b": [0.7704, 0.0801, 0.7857, 0.0997]}, {"w": "tf.keras", "b": [0.2714, 0.0975, 0.3272, 0.1171]}, {"w": "automatically", "b": [0.3364, 0.0975, 0.4394, 0.1171]}, {"w": "infers", "b": [0.4487, 0.0975, 0.492, 0.1171]}, {"w": "the", "b": [0.5013, 0.0975, 0.5253, 0.1171]}, {"w": "output", "b": [0.5346, 0.0975, 0.5862, 0.1171]}, {"w": "shape,", "b": [0.5955, 0.0975, 0.643, 0.1171]}, {"w": "except", "b": [0.6523, 0.0975, 0.7013, 0.1171]}, {"w": "when", "b": [0.7106, 0.0975, 0.7524, 0.1171]}, {"w": "the", "b": [0.7616, 0.0975, 0.7857, 0.1171]}, {"w": "layer", "b": [0.2714, 0.1149, 0.3082, 0.1345]}, {"w": "is", "b": [0.3132, 0.1149, 0.3253, 0.1345]}, {"w": "dynamic", "b": [0.3304, 0.1149, 0.3968, 0.1345]}, {"w": "(as", "b": [0.4019, 0.1149, 0.4238, 0.1345]}, {"w": "we", "b": [0.4289, 0.1149, 0.4501, 0.1345]}, {"w": "will", "b": [0.4552, 0.1149, 0.4829, 0.1345]}, {"w": "see", "b": [0.488, 0.1149, 0.5112, 0.1345]}, {"w": "shortly).", "b": [0.5163, 0.1149, 0.5806, 0.1345]}, {"w": "In", "b": [0.5857, 0.1149, 0.6026, 0.1345]}, {"w": "other", "b": [0.6077, 0.1149, 0.6485, 0.1345]}, {"w": "Keras", "b": [0.6536, 0.1149, 0.6965, 0.1345]}, {"w": "implemen‐", "b": [0.7016, 0.1149, 0.7857, 0.1345]}, {"w": "tations,", "b": [0.2714, 0.1323, 0.3276, 0.1519]}, {"w": "this", "b": [0.3333, 0.1323, 0.3614, 0.1519]}, {"w": "method", "b": [0.3671, 0.1323, 0.4266, 0.1519]}, {"w": "is", "b": [0.4323, 0.1323, 0.4444, 0.1519]}, {"w": "either", "b": [0.4501, 0.1323, 0.4945, 0.1519]}, {"w": "required", "b": [0.5002, 0.1323, 0.5655, 0.1519]}, {"w": "or", "b": [0.5712, 0.1323, 0.588, 0.1519]}, {"w": "by", "b": [0.5937, 0.1323, 0.6122, 0.1519]}, {"w": "default", "b": [0.6179, 0.1323, 0.6704, 0.1519]}, {"w": "it", "b": [0.6761, 0.1323, 0.6871, 0.1519]}, {"w": "assumes", "b": [0.6928, 0.1323, 0.7559, 0.1519]}, {"w": "the", "b": [0.7616, 0.1323, 0.7857, 0.1519]}, {"w": "output", "b": [0.2714, 0.1498, 0.323, 0.1693]}, {"w": "shape", "b": [0.3273, 0.1498, 0.3705, 0.1693]}, {"w": "is", "b": [0.3748, 0.1498, 0.3869, 0.1693]}, {"w": "the", "b": [0.3913, 0.1498, 0.4153, 0.1693]}, {"w": "same", "b": [0.4197, 0.1498, 0.4587, 0.1693]}, {"w": "as", "b": [0.463, 0.1498, 0.4784, 0.1693]}, {"w": "the", "b": [0.4827, 0.1498, 0.5068, 0.1693]}, {"w": "input", "b": [0.5111, 0.1498, 0.5522, 0.1693]}, {"w": "shape.", "b": [0.5565, 0.1498, 0.6041, 0.1693]}]}, {"id": "b_1", "type": "paragraph", "text": "To create a layer with multiple inputs (e.g., Concatenate), the argument to the call() method should be a tuple containing all the inputs, and similarly the argument to the compute_output_shape() method should be a tuple containing each input’s batch shape. To create a layer with multiple outputs, the call() method should return the list of outputs, and the compute_output_shape() should return the list of batch out‐ put shapes (one per output). For example, the following toy layer takes two inputs and returns three outputs:", "words": [{"w": "To", "b": [0.1429, 0.1905, 0.1643, 0.2119]}, {"w": "create", "b": [0.1692, 0.1905, 0.2185, 0.2119]}, {"w": "a", "b": [0.2234, 0.1905, 0.2325, 0.2119]}, {"w": "layer", "b": [0.2374, 0.1905, 0.2776, 0.2119]}, {"w": "with", "b": [0.2825, 0.1905, 0.3198, 0.2119]}, {"w": "multiple", "b": [0.3247, 0.1905, 0.3947, 0.2119]}, {"w": "inputs", "b": [0.3996, 0.1905, 0.4521, 0.2119]}, {"w": "(e.g.,", "b": [0.457, 0.1905, 0.4971, 0.2119]}, {"w": "Concatenate),", "b": [0.5019, 0.1905, 0.6228, 0.2119]}, {"w": "the", "b": [0.6276, 0.1905, 0.654, 0.2119]}, {"w": "argument", "b": [0.6589, 0.1905, 0.7398, 0.2119]}, {"w": "to", "b": [0.7447, 0.1905, 0.7617, 0.2119]}, {"w": "the", "b": [0.7665, 0.1905, 0.7929, 0.2119]}, {"w": "call()", "b": [0.7978, 0.1937, 0.8571, 0.2088]}, {"w": "method", "b": [0.1429, 0.2096, 0.2079, 0.231]}, {"w": "should", "b": [0.2131, 0.2096, 0.2699, 0.231]}, {"w": "be", "b": [0.2751, 0.2096, 0.2946, 0.231]}, {"w": "a", "b": [0.2998, 0.2096, 0.309, 0.231]}, {"w": "tuple", "b": [0.3142, 0.2096, 0.3567, 0.231]}, {"w": "containing", "b": [0.3619, 0.2096, 0.4516, 0.231]}, {"w": "all", "b": [0.4568, 0.2096, 0.4765, 0.231]}, {"w": "the", "b": [0.4817, 0.2096, 0.5081, 0.231]}, {"w": "inputs,", "b": [0.5133, 0.2096, 0.5706, 0.231]}, {"w": "and", "b": [0.5759, 0.2096, 0.6074, 0.231]}, {"w": "similarly", "b": [0.6127, 0.2096, 0.6855, 0.231]}, {"w": "the", "b": [0.6908, 0.2096, 0.7171, 0.231]}, {"w": "argument", "b": [0.7224, 0.2096, 0.8033, 0.231]}, {"w": "to", "b": [0.8086, 0.2096, 0.8256, 0.231]}, {"w": "the", "b": [0.8308, 0.2096, 0.8572, 0.231]}, {"w": "compute_output_shape()", "b": [0.1429, 0.2327, 0.3606, 0.2478]}, {"w": "method", "b": [0.369, 0.2295, 0.434, 0.2509]}, {"w": "should", "b": [0.4424, 0.2295, 0.4992, 0.2509]}, {"w": "be", "b": [0.5076, 0.2295, 0.5271, 0.2509]}, {"w": "a", "b": [0.5355, 0.2295, 0.5446, 0.2509]}, {"w": "tuple", "b": [0.5531, 0.2295, 0.5955, 0.2509]}, {"w": "containing", "b": [0.604, 0.2295, 0.6936, 0.2509]}, {"w": "each", "b": [0.702, 0.2295, 0.74, 0.2509]}, {"w": "input’s", "b": [0.7484, 0.2295, 0.8031, 0.2509]}, {"w": "batch", "b": [0.8115, 0.2295, 0.8571, 0.2509]}, {"w": "shape.", "b": [0.1429, 0.2495, 0.1949, 0.2709]}, {"w": "To", "b": [0.201, 0.2495, 0.2224, 0.2709]}, {"w": "create", "b": [0.2285, 0.2495, 0.2779, 0.2709]}, {"w": "a", "b": [0.284, 0.2495, 0.2931, 0.2709]}, {"w": "layer", "b": [0.2992, 0.2495, 0.3394, 0.2709]}, {"w": "with", "b": [0.3455, 0.2495, 0.3828, 0.2709]}, {"w": "multiple", "b": [0.3889, 0.2495, 0.4589, 0.2709]}, {"w": "outputs,", "b": [0.4649, 0.2495, 0.5337, 0.2709]}, {"w": "the", "b": [0.5398, 0.2495, 0.5661, 0.2709]}, {"w": "call()", "b": [0.5722, 0.2526, 0.6316, 0.2677]}, {"w": "method", "b": [0.6377, 0.2495, 0.7027, 0.2709]}, {"w": "should", "b": [0.7088, 0.2495, 0.7655, 0.2709]}, {"w": "return", "b": [0.7716, 0.2495, 0.8247, 0.2709]}, {"w": "the", "b": [0.8308, 0.2495, 0.8572, 0.2709]}, {"w": "list", "b": [0.1429, 0.2694, 0.1677, 0.2908]}, {"w": "of", "b": [0.1735, 0.2694, 0.1903, 0.2908]}, {"w": "outputs,", "b": [0.1961, 0.2694, 0.2648, 0.2908]}, {"w": "and", "b": [0.2706, 0.2694, 0.3022, 0.2908]}, {"w": "the", "b": [0.3079, 0.2694, 0.3343, 0.2908]}, {"w": "compute_output_shape()", "b": [0.3401, 0.2726, 0.5578, 0.2877]}, {"w": "should", "b": [0.5635, 0.2694, 0.6203, 0.2908]}, {"w": "return", "b": [0.6261, 0.2694, 0.6792, 0.2908]}, {"w": "the", "b": [0.685, 0.2694, 0.7113, 0.2908]}, {"w": "list", "b": [0.7171, 0.2694, 0.7419, 0.2908]}, {"w": "of", "b": [0.7477, 0.2694, 0.7645, 0.2908]}, {"w": "batch", "b": [0.7703, 0.2694, 0.8159, 0.2908]}, {"w": "out‐", "b": [0.8217, 0.2694, 0.8571, 0.2908]}, {"w": "put", "b": [0.1429, 0.2885, 0.1712, 0.3099]}, {"w": "shapes", "b": [0.1785, 0.2885, 0.2335, 0.3099]}, {"w": "(one", "b": [0.2408, 0.2885, 0.2789, 0.3099]}, {"w": "per", "b": [0.2863, 0.2885, 0.3138, 0.3099]}, {"w": "output).", "b": [0.3211, 0.2885, 0.3895, 0.3099]}, {"w": "For", "b": [0.3968, 0.2885, 0.4258, 0.3099]}, {"w": "example,", "b": [0.4332, 0.2885, 0.5075, 0.3099]}, {"w": "the", "b": [0.5148, 0.2885, 0.5412, 0.3099]}, {"w": "following", "b": [0.5485, 0.2885, 0.6275, 0.3099]}, {"w": "toy", "b": [0.6348, 0.2885, 0.6614, 0.3099]}, {"w": "layer", "b": [0.6687, 0.2885, 0.7089, 0.3099]}, {"w": "takes", "b": [0.7163, 0.2885, 0.7586, 0.3099]}, {"w": "two", "b": [0.766, 0.2885, 0.7972, 0.3099]}, {"w": "inputs", "b": [0.8046, 0.2885, 0.8571, 0.3099]}, {"w": "and", "b": [0.1429, 0.3075, 0.1744, 0.3289]}, {"w": "returns", "b": [0.1791, 0.3075, 0.2399, 0.3289]}, {"w": "three", "b": [0.2446, 0.3075, 0.2876, 0.3289]}, {"w": "outputs:", "b": [0.2923, 0.3075, 0.3611, 0.3289]}]}, {"id": "b_2", "type": "paragraph", "text": "class MyMultiLayer(keras.layers.Layer): def call(self, X): X1, X2 = X return [X1 + X2, X1 * X2, X1 / X2]", "words": [{"w": "class", "b": [0.1766, 0.3395, 0.2188, 0.3523]}, {"w": "MyMultiLayer(keras.layers.Layer):", "b": [0.2272, 0.3395, 0.5055, 0.3523]}, {"w": "def", "b": [0.2103, 0.3549, 0.2356, 0.3677]}, {"w": "call(self,", "b": [0.244, 0.3549, 0.3284, 0.3677]}, {"w": "X):", "b": [0.3368, 0.3549, 0.3621, 0.3677]}, {"w": "X1,", "b": [0.244, 0.3703, 0.2693, 0.3832]}, {"w": "X2", "b": [0.2778, 0.3703, 0.2946, 0.3832]}, {"w": "=", "b": [0.3031, 0.3703, 0.3115, 0.3832]}, {"w": "X", "b": [0.3199, 0.3703, 0.3284, 0.3832]}, {"w": "return", "b": [0.244, 0.3857, 0.2946, 0.3986]}, {"w": "[X1", "b": [0.3031, 0.3857, 0.3284, 0.3986]}, {"w": "+", "b": [0.3368, 0.3857, 0.3452, 0.3986]}, {"w": "X2,", "b": [0.3537, 0.3857, 0.379, 0.3986]}, {"w": "X1", "b": [0.3874, 0.3857, 0.4043, 0.3986]}, {"w": "*", "b": [0.4127, 0.3857, 0.4211, 0.3986]}, {"w": "X2,", "b": [0.4296, 0.3857, 0.4549, 0.3986]}, {"w": "X1", "b": [0.4633, 0.3857, 0.4802, 0.3986]}, {"w": "/", "b": [0.4886, 0.3857, 0.497, 0.3986]}, {"w": "X2]", "b": [0.5055, 0.3857, 0.5308, 0.3986]}]}, {"id": "b_3", "type": "paragraph", "text": "def compute_output_shape(self, batch_input_shape): b1, b2 = batch_input_shape return [b1, b1, b1] # should probably handle broadcasting rules", "words": [{"w": "def", "b": [0.2103, 0.4166, 0.2356, 0.4294]}, {"w": "compute_output_shape(self,", "b": [0.244, 0.4166, 0.4633, 0.4294]}, {"w": "batch_input_shape):", "b": [0.4717, 0.4166, 0.6319, 0.4294]}, {"w": "b1,", "b": [0.244, 0.432, 0.2693, 0.4448]}, {"w": "b2", "b": [0.2778, 0.432, 0.2946, 0.4448]}, {"w": "=", "b": [0.3031, 0.432, 0.3115, 0.4448]}, {"w": "batch_input_shape", "b": [0.3199, 0.432, 0.4633, 0.4448]}, {"w": "return", "b": [0.244, 0.4474, 0.2946, 0.4603]}, {"w": "[b1,", "b": [0.3031, 0.4474, 0.3368, 0.4603]}, {"w": "b1,", "b": [0.3452, 0.4474, 0.3705, 0.4603]}, {"w": "b1]", "b": [0.379, 0.4474, 0.4043, 0.4603]}, {"w": "#", "b": [0.4127, 0.4474, 0.4211, 0.4603]}, {"w": "should", "b": [0.4296, 0.4474, 0.4802, 0.4603]}, {"w": "probably", "b": [0.4886, 0.4474, 0.5561, 0.4603]}, {"w": "handle", "b": [0.5645, 0.4474, 0.6151, 0.4603]}, {"w": "broadcasting", "b": [0.6235, 0.4474, 0.7247, 0.4603]}, {"w": "rules", "b": [0.7331, 0.4474, 0.7753, 0.4603]}]}, {"id": "b_4", "type": "paragraph", "text": "This layer may now be used like any other layer, but of course only using the func‐ tional and subclassing APIs, not the sequential API (which only accepts layers with one input and one output).", "words": [{"w": "This", "b": [0.1429, 0.468, 0.1801, 0.4895]}, {"w": "layer", "b": [0.1867, 0.468, 0.2269, 0.4895]}, {"w": "may", "b": [0.2335, 0.468, 0.2689, 0.4895]}, {"w": "now", "b": [0.2756, 0.468, 0.3119, 0.4895]}, {"w": "be", "b": [0.3185, 0.468, 0.3379, 0.4895]}, {"w": "used", "b": [0.3446, 0.468, 0.3831, 0.4895]}, {"w": "like", "b": [0.3898, 0.468, 0.4198, 0.4895]}, {"w": "any", "b": [0.4265, 0.468, 0.4561, 0.4895]}, {"w": "other", "b": [0.4627, 0.468, 0.5074, 0.4895]}, {"w": "layer,", "b": [0.5141, 0.468, 0.5577, 0.4895]}, {"w": "but", "b": [0.5643, 0.468, 0.5923, 0.4895]}, {"w": "of", "b": [0.599, 0.468, 0.6157, 0.4895]}, {"w": "course", "b": [0.6224, 0.468, 0.6771, 0.4895]}, {"w": "only", "b": [0.6838, 0.468, 0.7206, 0.4895]}, {"w": "using", "b": [0.7272, 0.468, 0.7727, 0.4895]}, {"w": "the", "b": [0.7793, 0.468, 0.8057, 0.4895]}, {"w": "func‐", "b": [0.8123, 0.468, 0.8571, 0.4895]}, {"w": "tional", "b": [0.1429, 0.4871, 0.1912, 0.5085]}, {"w": "and", "b": [0.198, 0.4871, 0.2296, 0.5085]}, {"w": "subclassing", "b": [0.2364, 0.4871, 0.3309, 0.5085]}, {"w": "APIs,", "b": [0.3377, 0.4871, 0.3829, 0.5085]}, {"w": "not", "b": [0.3897, 0.4871, 0.4181, 0.5085]}, {"w": "the", "b": [0.4249, 0.4871, 0.4512, 0.5085]}, {"w": "sequential", "b": [0.458, 0.4871, 0.5424, 0.5085]}, {"w": "API", "b": [0.5492, 0.4871, 0.5824, 0.5085]}, {"w": "(which", "b": [0.5892, 0.4871, 0.6474, 0.5085]}, {"w": "only", "b": [0.6542, 0.4871, 0.691, 0.5085]}, {"w": "accepts", "b": [0.6978, 0.4871, 0.7584, 0.5085]}, {"w": "layers", "b": [0.7652, 0.4871, 0.813, 0.5085]}, {"w": "with", "b": [0.8198, 0.4871, 0.8571, 0.5085]}, {"w": "one", "b": [0.1429, 0.5061, 0.1737, 0.5276]}, {"w": "input", "b": [0.1785, 0.5061, 0.2234, 0.5276]}, {"w": "and", "b": [0.2281, 0.5061, 0.2597, 0.5276]}, {"w": "one", "b": [0.2644, 0.5061, 0.2953, 0.5276]}, {"w": "output).", "b": [0.3, 0.5061, 0.3683, 0.5276]}]}, {"id": "b_5", "type": "paragraph", "text": "If your layer needs to have a different behavior during training and during testing (e.g., if it uses Dropout or BatchNormalization layers), then you must add a train ing argument to the call() method and use this argument to decide what to do. For example, let’s create a layer that adds Gaussian noise during training (for regulariza‐ tion), but does nothing during testing (Keras actually has a layer that does the same thing: keras.layers.GaussianNoise):", "words": [{"w": "If", "b": [0.1429, 0.5343, 0.1561, 0.5557]}, {"w": "your", "b": [0.1636, 0.5343, 0.2026, 0.5557]}, {"w": "layer", "b": [0.2101, 0.5343, 0.2503, 0.5557]}, {"w": "needs", "b": [0.2578, 0.5343, 0.3056, 0.5557]}, {"w": "to", "b": [0.3131, 0.5343, 0.33, 0.5557]}, {"w": "have", "b": [0.3375, 0.5343, 0.3759, 0.5557]}, {"w": "a", "b": [0.3834, 0.5343, 0.3926, 0.5557]}, {"w": "different", "b": [0.4001, 0.5343, 0.4718, 0.5557]}, {"w": "behavior", "b": [0.4793, 0.5343, 0.5522, 0.5557]}, {"w": "during", "b": [0.5597, 0.5343, 0.6162, 0.5557]}, {"w": "training", "b": [0.6237, 0.5343, 0.6907, 0.5557]}, {"w": "and", "b": [0.6982, 0.5343, 0.7297, 0.5557]}, {"w": "during", "b": [0.7372, 0.5343, 0.7937, 0.5557]}, {"w": "testing", "b": [0.8012, 0.5343, 0.8572, 0.5557]}, {"w": "(e.g.,", "b": [0.1429, 0.5542, 0.1829, 0.5756]}, {"w": "if", "b": [0.1897, 0.5542, 0.2014, 0.5756]}, {"w": "it", "b": [0.2081, 0.5542, 0.2201, 0.5756]}, {"w": "uses", "b": [0.2268, 0.5542, 0.262, 0.5756]}, {"w": "Dropout", "b": [0.2687, 0.5574, 0.338, 0.5725]}, {"w": "or", "b": [0.3447, 0.5542, 0.3631, 0.5756]}, {"w": "BatchNormalization", "b": [0.3698, 0.5574, 0.5479, 0.5725]}, {"w": "layers),", "b": [0.5546, 0.5542, 0.6144, 0.5756]}, {"w": "then", "b": [0.6212, 0.5542, 0.6589, 0.5756]}, {"w": "you", "b": [0.6656, 0.5542, 0.6969, 0.5756]}, {"w": "must", "b": [0.7036, 0.5542, 0.7453, 0.5756]}, {"w": "add", "b": [0.752, 0.5542, 0.7832, 0.5756]}, {"w": "a", "b": [0.7899, 0.5542, 0.7991, 0.5756]}, {"w": "train", "b": [0.8058, 0.5574, 0.8553, 0.5725]}, {"w": "ing", "b": [0.1429, 0.5773, 0.1725, 0.5924]}, {"w": "argument", "b": [0.178, 0.5742, 0.259, 0.5956]}, {"w": "to", "b": [0.2644, 0.5742, 0.2814, 0.5956]}, {"w": "the", "b": [0.2868, 0.5742, 0.3132, 0.5956]}, {"w": "call()", "b": [0.3186, 0.5773, 0.378, 0.5924]}, {"w": "method", "b": [0.3835, 0.5742, 0.4485, 0.5956]}, {"w": "and", "b": [0.4539, 0.5742, 0.4855, 0.5956]}, {"w": "use", "b": [0.4909, 0.5742, 0.5185, 0.5956]}, {"w": "this", "b": [0.524, 0.5742, 0.5547, 0.5956]}, {"w": "argument", "b": [0.5601, 0.5742, 0.6411, 0.5956]}, {"w": "to", "b": [0.6465, 0.5742, 0.6635, 0.5956]}, {"w": "decide", "b": [0.669, 0.5742, 0.7231, 0.5956]}, {"w": "what", "b": [0.7285, 0.5742, 0.769, 0.5956]}, {"w": "to", "b": [0.7745, 0.5742, 0.7915, 0.5956]}, {"w": "do.", "b": [0.7969, 0.5742, 0.8227, 0.5956]}, {"w": "For", "b": [0.8282, 0.5742, 0.8571, 0.5956]}, {"w": "example,", "b": [0.1429, 0.5932, 0.2172, 0.6146]}, {"w": "let’s", "b": [0.2233, 0.5932, 0.2535, 0.6146]}, {"w": "create", "b": [0.2597, 0.5932, 0.3091, 0.6146]}, {"w": "a", "b": [0.3152, 0.5932, 0.3244, 0.6146]}, {"w": "layer", "b": [0.3305, 0.5932, 0.3707, 0.6146]}, {"w": "that", "b": [0.3768, 0.5932, 0.4094, 0.6146]}, {"w": "adds", "b": [0.4156, 0.5932, 0.4544, 0.6146]}, {"w": "Gaussian", "b": [0.4605, 0.5932, 0.5367, 0.6146]}, {"w": "noise", "b": [0.5428, 0.5932, 0.5869, 0.6146]}, {"w": "during", "b": [0.5931, 0.5932, 0.6496, 0.6146]}, {"w": "training", "b": [0.6557, 0.5932, 0.7227, 0.6146]}, {"w": "(for", "b": [0.7288, 0.5932, 0.7606, 0.6146]}, {"w": "regulariza‐", "b": [0.7667, 0.5932, 0.8572, 0.6146]}, {"w": "tion),", "b": [0.1429, 0.6122, 0.1888, 0.6337]}, {"w": "but", "b": [0.1951, 0.6122, 0.2231, 0.6337]}, {"w": "does", "b": [0.2293, 0.6122, 0.2675, 0.6337]}, {"w": "nothing", "b": [0.2737, 0.6122, 0.34, 0.6337]}, {"w": "during", "b": [0.3462, 0.6122, 0.4027, 0.6337]}, {"w": "testing", "b": [0.409, 0.6122, 0.465, 0.6337]}, {"w": "(Keras", "b": [0.4712, 0.6122, 0.5253, 0.6337]}, {"w": "actually", "b": [0.5316, 0.6122, 0.5962, 0.6337]}, {"w": "has", "b": [0.6025, 0.6122, 0.6304, 0.6337]}, {"w": "a", "b": [0.6367, 0.6122, 0.6458, 0.6337]}, {"w": "layer", "b": [0.6521, 0.6122, 0.6923, 0.6337]}, {"w": "that", "b": [0.6986, 0.6122, 0.7312, 0.6337]}, {"w": "does", "b": [0.7374, 0.6122, 0.7756, 0.6337]}, {"w": "the", "b": [0.7818, 0.6122, 0.8082, 0.6337]}, {"w": "same", "b": [0.8144, 0.6122, 0.8571, 0.6337]}, {"w": "thing:", "b": [0.1429, 0.6322, 0.1918, 0.6536]}, {"w": "keras.layers.GaussianNoise):", "b": [0.1965, 0.6322, 0.4658, 0.6536]}]}, {"id": "b_6", "type": "paragraph", "text": "class MyGaussianNoise(keras.layers.Layer): def __init__(self, stddev, **kwargs): super().__init__(**kwargs) self.stddev = stddev", "words": [{"w": "class", "b": [0.1766, 0.6642, 0.2188, 0.677]}, {"w": "MyGaussianNoise(keras.layers.Layer):", "b": [0.2272, 0.6642, 0.5308, 0.677]}, {"w": "def", "b": [0.2103, 0.6796, 0.2356, 0.6924]}, {"w": "__init__(self,", "b": [0.2441, 0.6796, 0.3621, 0.6924]}, {"w": "stddev,", "b": [0.3705, 0.6796, 0.4296, 0.6924]}, {"w": "**kwargs):", "b": [0.438, 0.6796, 0.5223, 0.6924]}, {"w": "super().__init__(**kwargs)", "b": [0.2441, 0.695, 0.4633, 0.7079]}, {"w": "self.stddev", "b": [0.2441, 0.7104, 0.3368, 0.7233]}, {"w": "=", "b": [0.3452, 0.7104, 0.3537, 0.7233]}, {"w": "stddev", "b": [0.3621, 0.7104, 0.4127, 0.7233]}]}, {"id": "b_7", "type": "paragraph", "text": "def call(self, X, training=None): if training: noise = tf.random.normal(tf.shape(X), stddev=self.stddev) return X + noise else: return X", "words": [{"w": "def", "b": [0.2103, 0.7413, 0.2356, 0.7541]}, {"w": "call(self,", "b": [0.2441, 0.7413, 0.3284, 0.7541]}, {"w": "X,", "b": [0.3368, 0.7413, 0.3537, 0.7541]}, {"w": "training=None):", "b": [0.3621, 0.7413, 0.4886, 0.7541]}, {"w": "if", "b": [0.2441, 0.7567, 0.2609, 0.7695]}, {"w": "training:", "b": [0.2694, 0.7567, 0.3452, 0.7695]}, {"w": "noise", "b": [0.2778, 0.7721, 0.3199, 0.785]}, {"w": "=", "b": [0.3284, 0.7721, 0.3368, 0.785]}, {"w": "tf.random.normal(tf.shape(X),", "b": [0.3452, 0.7721, 0.5898, 0.785]}, {"w": "stddev=self.stddev)", "b": [0.5982, 0.7721, 0.7584, 0.785]}, {"w": "return", "b": [0.2778, 0.7875, 0.3284, 0.8004]}, {"w": "X", "b": [0.3368, 0.7875, 0.3452, 0.8004]}, {"w": "+", "b": [0.3537, 0.7875, 0.3621, 0.8004]}, {"w": "noise", "b": [0.3705, 0.7875, 0.4127, 0.8004]}, {"w": "else:", "b": [0.2441, 0.8029, 0.2862, 0.8158]}, {"w": "return", "b": [0.2778, 0.8184, 0.3284, 0.8312]}, {"w": "X", "b": [0.3368, 0.8184, 0.3452, 0.8312]}]}, {"id": "b_8", "type": "equation", "text": "def compute_output_shape(self, batch_input_shape): return batch_input_shape", "words": [{"w": "def", "b": [0.2103, 0.8492, 0.2356, 0.862]}, {"w": "compute_output_shape(self,", "b": [0.2441, 0.8492, 0.4633, 0.862]}, {"w": "batch_input_shape):", "b": [0.4717, 0.8492, 0.6319, 0.862]}, {"w": "return", "b": [0.2441, 0.8646, 0.2946, 0.8775]}, {"w": "batch_input_shape", "b": [0.3031, 0.8646, 0.4464, 0.8775]}]}, {"id": "b_9", "type": "paragraph", "text": "Customizing Models and Training Algorithms | 385", "words": [{"w": "Customizing", "b": [0.5328, 0.9225, 0.6056, 0.9388]}, {"w": "Models", "b": [0.6084, 0.9225, 0.6507, 0.9388]}, {"w": "and", "b": [0.6535, 0.9225, 0.6759, 0.9388]}, {"w": "Training", "b": [0.6787, 0.9225, 0.7278, 0.9388]}, {"w": "Algorithms", "b": [0.7306, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "385", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 412, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "10 The name “subclassing API” usually refers only to the creation of custom models by subclassing, although many other things can be created by subclassing, as we saw in this chapter.", "words": [{"w": "10", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "The", "b": [0.1587, 0.8598, 0.1837, 0.8761]}, {"w": "name", "b": [0.1873, 0.8598, 0.2227, 0.8761]}, {"w": "“subclassing", "b": [0.2263, 0.8598, 0.3038, 0.8761]}, {"w": "API”", "b": [0.3074, 0.8598, 0.3391, 0.8761]}, {"w": "usually", "b": [0.3427, 0.8598, 0.3876, 0.8761]}, {"w": "refers", "b": [0.3912, 0.8598, 0.427, 0.8761]}, {"w": "only", "b": [0.4306, 0.8598, 0.4587, 0.8761]}, {"w": "to", "b": [0.4623, 0.8598, 0.4753, 0.8761]}, {"w": "the", "b": [0.4789, 0.8598, 0.4989, 0.8761]}, {"w": "creation", "b": [0.5025, 0.8598, 0.5544, 0.8761]}, {"w": "of", "b": [0.558, 0.8598, 0.5708, 0.8761]}, {"w": "custom", "b": [0.5744, 0.8598, 0.6213, 0.8761]}, {"w": "models", "b": [0.6249, 0.8598, 0.671, 0.8761]}, {"w": "by", "b": [0.6746, 0.8598, 0.6899, 0.8761]}, {"w": "subclassing,", "b": [0.6935, 0.8598, 0.7692, 0.8761]}, {"w": "although", "b": [0.7728, 0.8598, 0.8295, 0.8761]}, {"w": "many", "b": [0.1587, 0.8749, 0.1943, 0.8912]}, {"w": "other", "b": [0.1979, 0.8749, 0.232, 0.8912]}, {"w": "things", "b": [0.2356, 0.8749, 0.2751, 0.8912]}, {"w": "can", "b": [0.2787, 0.8749, 0.301, 0.8912]}, {"w": "be", "b": [0.3046, 0.8749, 0.3194, 0.8912]}, {"w": "created", "b": [0.323, 0.8749, 0.369, 0.8912]}, {"w": "by", "b": [0.3726, 0.8749, 0.388, 0.8912]}, {"w": "subclassing,", "b": [0.3916, 0.8749, 0.4672, 0.8912]}, {"w": "as", "b": [0.4708, 0.8749, 0.4836, 0.8912]}, {"w": "we", "b": [0.4872, 0.8749, 0.5049, 0.8912]}, {"w": "saw", "b": [0.5085, 0.8749, 0.5318, 0.8912]}, {"w": "in", "b": [0.5354, 0.8749, 0.5484, 0.8912]}, {"w": "this", "b": [0.552, 0.8749, 0.5754, 0.8912]}, {"w": "chapter.", "b": [0.579, 0.8749, 0.6293, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "With that, you can now build any custom layer you need! Now let’s create custom models.", "words": [{"w": "With", "b": [0.1429, 0.0791, 0.1853, 0.1005]}, {"w": "that,", "b": [0.1928, 0.0791, 0.2301, 0.1005]}, {"w": "you", "b": [0.2376, 0.0791, 0.2688, 0.1005]}, {"w": "can", "b": [0.2763, 0.0791, 0.3057, 0.1005]}, {"w": "now", "b": [0.3131, 0.0791, 0.3494, 0.1005]}, {"w": "build", "b": [0.3569, 0.0791, 0.4004, 0.1005]}, {"w": "any", "b": [0.4079, 0.0791, 0.4375, 0.1005]}, {"w": "custom", "b": [0.445, 0.0791, 0.5065, 0.1005]}, {"w": "layer", "b": [0.514, 0.0791, 0.5542, 0.1005]}, {"w": "you", "b": [0.5617, 0.0791, 0.5929, 0.1005]}, {"w": "need!", "b": [0.6004, 0.0791, 0.6462, 0.1005]}, {"w": "Now", "b": [0.6537, 0.0791, 0.6936, 0.1005]}, {"w": "let’s", "b": [0.701, 0.0791, 0.7313, 0.1005]}, {"w": "create", "b": [0.7388, 0.0791, 0.7881, 0.1005]}, {"w": "custom", "b": [0.7956, 0.0791, 0.8571, 0.1005]}, {"w": "models.", "b": [0.1429, 0.0981, 0.2081, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "Custom Models", "words": [{"w": "Custom", "b": [0.1429, 0.1323, 0.2201, 0.1609]}, {"w": "Models", "b": [0.2251, 0.1323, 0.2991, 0.1609]}]}, {"id": "b_3", "type": "paragraph", "text": "We already looked at custom model classes in Chapter 10 when we discussed the sub‐ classing API.10 It is actually quite straightforward, just subclass the keras.mod els.Model class, create layers and variables in the constructor, and implement the call() method to do whatever you want the model to do. For example, suppose you want to build the model represented in Figure 12-3:", "words": [{"w": "We", "b": [0.1429, 0.1668, 0.1699, 0.1882]}, {"w": "already", "b": [0.1749, 0.1668, 0.2356, 0.1882]}, {"w": "looked", "b": [0.2406, 0.1668, 0.2973, 0.1882]}, {"w": "at", "b": [0.3023, 0.1668, 0.3174, 0.1882]}, {"w": "custom", "b": [0.3223, 0.1668, 0.3839, 0.1882]}, {"w": "model", "b": [0.3889, 0.1668, 0.4417, 0.1882]}, {"w": "classes", "b": [0.4467, 0.1668, 0.5017, 0.1882]}, {"w": "in", "b": [0.5067, 0.1668, 0.5237, 0.1882]}, {"w": "Chapter", "b": [0.5286, 0.1668, 0.5962, 0.1882]}, {"w": "10", "b": [0.6009, 0.1668, 0.6209, 0.1882]}, {"w": "when", "b": [0.6262, 0.1668, 0.6718, 0.1882]}, {"w": "we", "b": [0.6768, 0.1668, 0.6999, 0.1882]}, {"w": "discussed", "b": [0.7049, 0.1668, 0.7841, 0.1882]}, {"w": "the", "b": [0.7891, 0.1668, 0.8155, 0.1882]}, {"w": "sub‐", "b": [0.8204, 0.1668, 0.8571, 0.1882]}, {"w": "classing", "b": [0.1429, 0.1867, 0.2081, 0.2081]}, {"w": "API.10", "b": [0.2193, 0.1867, 0.2687, 0.2081]}, {"w": "It", "b": [0.2798, 0.1867, 0.2925, 0.2081]}, {"w": "is", "b": [0.3036, 0.1867, 0.3169, 0.2081]}, {"w": "actually", "b": [0.328, 0.1867, 0.3926, 0.2081]}, {"w": "quite", "b": [0.4038, 0.1867, 0.4463, 0.2081]}, {"w": "straightforward,", "b": [0.4575, 0.1867, 0.5928, 0.2081]}, {"w": "just", "b": [0.6039, 0.1867, 0.6343, 0.2081]}, {"w": "subclass", "b": [0.6455, 0.1867, 0.7133, 0.2081]}, {"w": "the", "b": [0.7245, 0.1867, 0.7508, 0.2081]}, {"w": "keras.mod", "b": [0.762, 0.1899, 0.851, 0.205]}, {"w": "els.Model", "b": [0.1429, 0.2098, 0.2319, 0.2249]}, {"w": "class,", "b": [0.2399, 0.2066, 0.2831, 0.2281]}, {"w": "create", "b": [0.2911, 0.2066, 0.3404, 0.2281]}, {"w": "layers", "b": [0.3484, 0.2066, 0.3962, 0.2281]}, {"w": "and", "b": [0.4041, 0.2066, 0.4357, 0.2281]}, {"w": "variables", "b": [0.4436, 0.2066, 0.5172, 0.2281]}, {"w": "in", "b": [0.5251, 0.2066, 0.5421, 0.2281]}, {"w": "the", "b": [0.5501, 0.2066, 0.5764, 0.2281]}, {"w": "constructor,", "b": [0.5843, 0.2066, 0.6849, 0.2281]}, {"w": "and", "b": [0.6928, 0.2066, 0.7244, 0.2281]}, {"w": "implement", "b": [0.7323, 0.2066, 0.8229, 0.2281]}, {"w": "the", "b": [0.8308, 0.2066, 0.8571, 0.2281]}, {"w": "call()", "b": [0.1429, 0.2298, 0.2022, 0.2448]}, {"w": "method", "b": [0.2079, 0.2266, 0.2729, 0.248]}, {"w": "to", "b": [0.2786, 0.2266, 0.2956, 0.248]}, {"w": "do", "b": [0.3013, 0.2266, 0.3229, 0.248]}, {"w": "whatever", "b": [0.3286, 0.2266, 0.4042, 0.248]}, {"w": "you", "b": [0.4099, 0.2266, 0.4411, 0.248]}, {"w": "want", "b": [0.4468, 0.2266, 0.4876, 0.248]}, {"w": "the", "b": [0.4933, 0.2266, 0.5196, 0.248]}, {"w": "model", "b": [0.5253, 0.2266, 0.5781, 0.248]}, {"w": "to", "b": [0.5838, 0.2266, 0.6008, 0.248]}, {"w": "do.", "b": [0.6065, 0.2266, 0.6322, 0.248]}, {"w": "For", "b": [0.6379, 0.2266, 0.6669, 0.248]}, {"w": "example,", "b": [0.6726, 0.2266, 0.7469, 0.248]}, {"w": "suppose", "b": [0.7525, 0.2266, 0.8202, 0.248]}, {"w": "you", "b": [0.8259, 0.2266, 0.8572, 0.248]}, {"w": "want", "b": [0.1429, 0.2456, 0.1836, 0.267]}, {"w": "to", "b": [0.1884, 0.2456, 0.2053, 0.267]}, {"w": "build", "b": [0.2101, 0.2456, 0.2536, 0.267]}, {"w": "the", "b": [0.2583, 0.2456, 0.2846, 0.267]}, {"w": "model", "b": [0.2894, 0.2456, 0.3422, 0.267]}, {"w": "represented", "b": [0.3469, 0.2456, 0.4447, 0.267]}, {"w": "in", "b": [0.4494, 0.2456, 0.4664, 0.267]}, {"w": "Figure", "b": [0.4711, 0.2456, 0.5251, 0.267]}, {"w": "12-3:", "b": [0.5299, 0.2456, 0.572, 0.267]}]}, {"id": "b_4", "type": "equation", "text": "Figure 12-3. Custom Model Example", "words": [{"w": "Figure", "b": [0.1429, 0.6651, 0.1943, 0.6867]}, {"w": "12-3.", "b": [0.1991, 0.6651, 0.2407, 0.6867]}, {"w": "Custom", "b": [0.2455, 0.6651, 0.3086, 0.6867]}, {"w": "Model", "b": [0.3134, 0.6651, 0.3644, 0.6867]}, {"w": "Example", "b": [0.3692, 0.6651, 0.4404, 0.6867]}]}, {"id": "b_5", "type": "paragraph", "text": "The inputs go through a first dense layer, then through a residual block composed of two dense layers and an addition operation (as we will see in Chapter 14, a residual block adds its inputs to its outputs), then through this same residual block 3 more times, then through a second residual block, and the final result goes through a dense output layer. Note that this model does not make much sense, it’s just an example to illustrate the fact that you can easily build any kind of model you want, even contain‐", "words": [{"w": "The", "b": [0.1429, 0.7025, 0.1757, 0.7239]}, {"w": "inputs", "b": [0.1817, 0.7025, 0.2342, 0.7239]}, {"w": "go", "b": [0.2402, 0.7025, 0.2606, 0.7239]}, {"w": "through", "b": [0.2665, 0.7025, 0.3343, 0.7239]}, {"w": "a", "b": [0.3403, 0.7025, 0.3494, 0.7239]}, {"w": "first", "b": [0.3554, 0.7025, 0.3889, 0.7239]}, {"w": "dense", "b": [0.3948, 0.7025, 0.4426, 0.7239]}, {"w": "layer,", "b": [0.4486, 0.7025, 0.4922, 0.7239]}, {"w": "then", "b": [0.4982, 0.7025, 0.5359, 0.7239]}, {"w": "through", "b": [0.5419, 0.7025, 0.6096, 0.7239]}, {"w": "a", "b": [0.6156, 0.7025, 0.6247, 0.7239]}, {"w": "residual", "b": [0.6307, 0.7023, 0.695, 0.7239]}, {"w": "block", "b": [0.701, 0.7023, 0.7433, 0.7239]}, {"w": "composed", "b": [0.7492, 0.7025, 0.8344, 0.7239]}, {"w": "of", "b": [0.8404, 0.7025, 0.8571, 0.7239]}, {"w": "two", "b": [0.1429, 0.7215, 0.1741, 0.7429]}, {"w": "dense", "b": [0.1805, 0.7215, 0.2283, 0.7429]}, {"w": "layers", "b": [0.2347, 0.7215, 0.2825, 0.7429]}, {"w": "and", "b": [0.2889, 0.7215, 0.3205, 0.7429]}, {"w": "an", "b": [0.3269, 0.7215, 0.3474, 0.7429]}, {"w": "addition", "b": [0.3538, 0.7215, 0.4245, 0.7429]}, {"w": "operation", "b": [0.4309, 0.7215, 0.5118, 0.7429]}, {"w": "(as", "b": [0.5182, 0.7215, 0.5422, 0.7429]}, {"w": "we", "b": [0.5486, 0.7215, 0.5717, 0.7429]}, {"w": "will", "b": [0.5782, 0.7215, 0.6085, 0.7429]}, {"w": "see", "b": [0.615, 0.7215, 0.6403, 0.7429]}, {"w": "in", "b": [0.6467, 0.7215, 0.6637, 0.7429]}, {"w": "Chapter", "b": [0.6701, 0.7215, 0.7377, 0.7429]}, {"w": "14,", "b": [0.7441, 0.7215, 0.7689, 0.7429]}, {"w": "a", "b": [0.7753, 0.7215, 0.7844, 0.7429]}, {"w": "residual", "b": [0.7908, 0.7215, 0.8571, 0.7429]}, {"w": "block", "b": [0.1428, 0.7406, 0.1885, 0.762]}, {"w": "adds", "b": [0.1956, 0.7406, 0.2344, 0.762]}, {"w": "its", "b": [0.2416, 0.7406, 0.2611, 0.762]}, {"w": "inputs", "b": [0.2683, 0.7406, 0.3209, 0.762]}, {"w": "to", "b": [0.328, 0.7406, 0.345, 0.762]}, {"w": "its", "b": [0.3521, 0.7406, 0.3717, 0.762]}, {"w": "outputs),", "b": [0.3789, 0.7406, 0.4548, 0.762]}, {"w": "then", "b": [0.462, 0.7406, 0.4997, 0.762]}, {"w": "through", "b": [0.5069, 0.7406, 0.5746, 0.762]}, {"w": "this", "b": [0.5818, 0.7406, 0.6125, 0.762]}, {"w": "same", "b": [0.6196, 0.7406, 0.6624, 0.762]}, {"w": "residual", "b": [0.6695, 0.7406, 0.7358, 0.762]}, {"w": "block", "b": [0.7429, 0.7406, 0.7886, 0.762]}, {"w": "3", "b": [0.7957, 0.7406, 0.8057, 0.762]}, {"w": "more", "b": [0.8129, 0.7406, 0.8571, 0.762]}, {"w": "times,", "b": [0.1429, 0.7596, 0.1931, 0.781]}, {"w": "then", "b": [0.1981, 0.7596, 0.2359, 0.781]}, {"w": "through", "b": [0.2409, 0.7596, 0.3087, 0.781]}, {"w": "a", "b": [0.3137, 0.7596, 0.3229, 0.781]}, {"w": "second", "b": [0.3279, 0.7596, 0.3862, 0.781]}, {"w": "residual", "b": [0.3913, 0.7596, 0.4576, 0.781]}, {"w": "block,", "b": [0.4626, 0.7596, 0.513, 0.781]}, {"w": "and", "b": [0.518, 0.7596, 0.5495, 0.781]}, {"w": "the", "b": [0.5546, 0.7596, 0.5809, 0.781]}, {"w": "final", "b": [0.586, 0.7596, 0.6235, 0.781]}, {"w": "result", "b": [0.6285, 0.7596, 0.6755, 0.781]}, {"w": "goes", "b": [0.6805, 0.7596, 0.7174, 0.781]}, {"w": "through", "b": [0.7224, 0.7596, 0.7902, 0.781]}, {"w": "a", "b": [0.7952, 0.7596, 0.8044, 0.781]}, {"w": "dense", "b": [0.8094, 0.7596, 0.8571, 0.781]}, {"w": "output", "b": [0.1429, 0.7787, 0.1992, 0.8001]}, {"w": "layer.", "b": [0.2052, 0.7787, 0.2488, 0.8001]}, {"w": "Note", "b": [0.2548, 0.7787, 0.2956, 0.8001]}, {"w": "that", "b": [0.3016, 0.7787, 0.3341, 0.8001]}, {"w": "this", "b": [0.3401, 0.7787, 0.3708, 0.8001]}, {"w": "model", "b": [0.3768, 0.7787, 0.4296, 0.8001]}, {"w": "does", "b": [0.4356, 0.7787, 0.4737, 0.8001]}, {"w": "not", "b": [0.4797, 0.7787, 0.508, 0.8001]}, {"w": "make", "b": [0.514, 0.7787, 0.5594, 0.8001]}, {"w": "much", "b": [0.5654, 0.7787, 0.613, 0.8001]}, {"w": "sense,", "b": [0.619, 0.7787, 0.6682, 0.8001]}, {"w": "it’s", "b": [0.6741, 0.7787, 0.6958, 0.8001]}, {"w": "just", "b": [0.7018, 0.7787, 0.7322, 0.8001]}, {"w": "an", "b": [0.7381, 0.7787, 0.7587, 0.8001]}, {"w": "example", "b": [0.7647, 0.7787, 0.8342, 0.8001]}, {"w": "to", "b": [0.8402, 0.7787, 0.8571, 0.8001]}, {"w": "illustrate", "b": [0.1429, 0.7977, 0.2157, 0.8191]}, {"w": "the", "b": [0.221, 0.7977, 0.2473, 0.8191]}, {"w": "fact", "b": [0.2525, 0.7977, 0.283, 0.8191]}, {"w": "that", "b": [0.2882, 0.7977, 0.3208, 0.8191]}, {"w": "you", "b": [0.326, 0.7977, 0.3573, 0.8191]}, {"w": "can", "b": [0.3625, 0.7977, 0.3919, 0.8191]}, {"w": "easily", "b": [0.3971, 0.7977, 0.4432, 0.8191]}, {"w": "build", "b": [0.4484, 0.7977, 0.4919, 0.8191]}, {"w": "any", "b": [0.4971, 0.7977, 0.5268, 0.8191]}, {"w": "kind", "b": [0.532, 0.7977, 0.5703, 0.8191]}, {"w": "of", "b": [0.5755, 0.7977, 0.5923, 0.8191]}, {"w": "model", "b": [0.5975, 0.7977, 0.6504, 0.8191]}, {"w": "you", "b": [0.6556, 0.7977, 0.6868, 0.8191]}, {"w": "want,", "b": [0.6921, 0.7977, 0.7376, 0.8191]}, {"w": "even", "b": [0.7428, 0.7977, 0.7816, 0.8191]}, {"w": "contain‐", "b": [0.7868, 0.7977, 0.8571, 0.8191]}]}, {"id": "b_6", "type": "paragraph", "text": "386 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "386", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2745, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 413, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "ing loops and skip connections. To implement this model, it is best to first create a ResidualBlock layer, since we are going to create a couple identical blocks (and we might want to reuse it in another model):", "words": [{"w": "ing", "b": [0.1429, 0.0791, 0.1696, 0.1005]}, {"w": "loops", "b": [0.1764, 0.0791, 0.2215, 0.1005]}, {"w": "and", "b": [0.2283, 0.0791, 0.2599, 0.1005]}, {"w": "skip", "b": [0.2667, 0.0791, 0.3012, 0.1005]}, {"w": "connections.", "b": [0.308, 0.0791, 0.4142, 0.1005]}, {"w": "To", "b": [0.4211, 0.0791, 0.4425, 0.1005]}, {"w": "implement", "b": [0.4493, 0.0791, 0.5399, 0.1005]}, {"w": "this", "b": [0.5467, 0.0791, 0.5774, 0.1005]}, {"w": "model,", "b": [0.5842, 0.0791, 0.6418, 0.1005]}, {"w": "it", "b": [0.6486, 0.0791, 0.6606, 0.1005]}, {"w": "is", "b": [0.6674, 0.0791, 0.6806, 0.1005]}, {"w": "best", "b": [0.6874, 0.0791, 0.7209, 0.1005]}, {"w": "to", "b": [0.7277, 0.0791, 0.7447, 0.1005]}, {"w": "first", "b": [0.7515, 0.0791, 0.785, 0.1005]}, {"w": "create", "b": [0.7918, 0.0791, 0.8412, 0.1005]}, {"w": "a", "b": [0.848, 0.0791, 0.8571, 0.1005]}, {"w": "ResidualBlock", "b": [0.1429, 0.1022, 0.2715, 0.1173]}, {"w": "layer,", "b": [0.2781, 0.099, 0.3217, 0.1204]}, {"w": "since", "b": [0.3284, 0.099, 0.3707, 0.1204]}, {"w": "we", "b": [0.3773, 0.099, 0.4004, 0.1204]}, {"w": "are", "b": [0.407, 0.099, 0.4327, 0.1204]}, {"w": "going", "b": [0.4394, 0.099, 0.4865, 0.1204]}, {"w": "to", "b": [0.4931, 0.099, 0.5101, 0.1204]}, {"w": "create", "b": [0.5167, 0.099, 0.566, 0.1204]}, {"w": "a", "b": [0.5726, 0.099, 0.5818, 0.1204]}, {"w": "couple", "b": [0.5884, 0.099, 0.6439, 0.1204]}, {"w": "identical", "b": [0.6506, 0.099, 0.7222, 0.1204]}, {"w": "blocks", "b": [0.7288, 0.099, 0.782, 0.1204]}, {"w": "(and", "b": [0.7887, 0.099, 0.8274, 0.1204]}, {"w": "we", "b": [0.834, 0.099, 0.8571, 0.1204]}, {"w": "might", "b": [0.1429, 0.1181, 0.1923, 0.1395]}, {"w": "want", "b": [0.1971, 0.1181, 0.2378, 0.1395]}, {"w": "to", "b": [0.2426, 0.1181, 0.2595, 0.1395]}, {"w": "reuse", "b": [0.2643, 0.1181, 0.3084, 0.1395]}, {"w": "it", "b": [0.3131, 0.1181, 0.3251, 0.1395]}, {"w": "in", "b": [0.3298, 0.1181, 0.3468, 0.1395]}, {"w": "another", "b": [0.3515, 0.1181, 0.4168, 0.1395]}, {"w": "model):", "b": [0.4215, 0.1181, 0.4863, 0.1395]}]}, {"id": "b_1", "type": "paragraph", "text": "class ResidualBlock(keras.layers.Layer): def __init__(self, n_layers, n_neurons, **kwargs): super().__init__(**kwargs) self.hidden = [keras.layers.Dense(n_neurons, activation=\"elu\", kernel_initializer=\"he_normal\") for _ in range(n_layers)]", "words": [{"w": "class", "b": [0.1766, 0.15, 0.2188, 0.1629]}, {"w": "ResidualBlock(keras.layers.Layer):", "b": [0.2272, 0.15, 0.5139, 0.1629]}, {"w": "def", "b": [0.2103, 0.1654, 0.2356, 0.1783]}, {"w": "__init__(self,", "b": [0.2441, 0.1654, 0.3621, 0.1783]}, {"w": "n_layers,", "b": [0.3705, 0.1654, 0.4464, 0.1783]}, {"w": "n_neurons,", "b": [0.4549, 0.1654, 0.5392, 0.1783]}, {"w": "**kwargs):", "b": [0.5476, 0.1654, 0.6319, 0.1783]}, {"w": "super().__init__(**kwargs)", "b": [0.2441, 0.1809, 0.4633, 0.1937]}, {"w": "self.hidden", "b": [0.2441, 0.1963, 0.3368, 0.2091]}, {"w": "=", "b": [0.3452, 0.1963, 0.3537, 0.2091]}, {"w": "[keras.layers.Dense(n_neurons,", "b": [0.3621, 0.1963, 0.6151, 0.2091]}, {"w": "activation=\"elu\",", "b": [0.6235, 0.1963, 0.7669, 0.2091]}, {"w": "kernel_initializer=\"he_normal\")", "b": [0.5308, 0.2117, 0.7922, 0.2246]}, {"w": "for", "b": [0.3705, 0.2271, 0.3958, 0.24]}, {"w": "_", "b": [0.4043, 0.2271, 0.4127, 0.24]}, {"w": "in", "b": [0.4211, 0.2271, 0.438, 0.24]}, {"w": "range(n_layers)]", "b": [0.4464, 0.2271, 0.5814, 0.24]}]}, {"id": "b_2", "type": "paragraph", "text": "def call(self, inputs): Z = inputs for layer in self.hidden: Z = layer(Z) return inputs + Z", "words": [{"w": "def", "b": [0.2103, 0.258, 0.2356, 0.2708]}, {"w": "call(self,", "b": [0.2441, 0.258, 0.3284, 0.2708]}, {"w": "inputs):", "b": [0.3368, 0.258, 0.4043, 0.2708]}, {"w": "Z", "b": [0.2441, 0.2734, 0.2525, 0.2862]}, {"w": "=", "b": [0.2609, 0.2734, 0.2693, 0.2862]}, {"w": "inputs", "b": [0.2778, 0.2734, 0.3284, 0.2862]}, {"w": "for", "b": [0.2441, 0.2888, 0.2693, 0.3017]}, {"w": "layer", "b": [0.2778, 0.2888, 0.3199, 0.3017]}, {"w": "in", "b": [0.3284, 0.2888, 0.3452, 0.3017]}, {"w": "self.hidden:", "b": [0.3537, 0.2888, 0.4549, 0.3017]}, {"w": "Z", "b": [0.2778, 0.3042, 0.2862, 0.3171]}, {"w": "=", "b": [0.2946, 0.3042, 0.3031, 0.3171]}, {"w": "layer(Z)", "b": [0.3115, 0.3042, 0.379, 0.3171]}, {"w": "return", "b": [0.2441, 0.3196, 0.2946, 0.3325]}, {"w": "inputs", "b": [0.3031, 0.3196, 0.3537, 0.3325]}, {"w": "+", "b": [0.3621, 0.3196, 0.3705, 0.3325]}, {"w": "Z", "b": [0.379, 0.3196, 0.3874, 0.3325]}]}, {"id": "b_3", "type": "paragraph", "text": "This layer is a bit special since it contains other layers. This is handled transparently by Keras: it automatically detects that the hidden attribute contains trackable objects (layers in this case), so their variables are automatically added to this layer’s list of variables. The rest of this class is self-explanatory. Next, let’s use the subclassing API to define the model itself:", "words": [{"w": "This", "b": [0.1429, 0.3403, 0.1801, 0.3617]}, {"w": "layer", "b": [0.1861, 0.3403, 0.2263, 0.3617]}, {"w": "is", "b": [0.2323, 0.3403, 0.2455, 0.3617]}, {"w": "a", "b": [0.2516, 0.3403, 0.2607, 0.3617]}, {"w": "bit", "b": [0.2667, 0.3403, 0.2893, 0.3617]}, {"w": "special", "b": [0.2953, 0.3403, 0.3515, 0.3617]}, {"w": "since", "b": [0.3575, 0.3403, 0.3998, 0.3617]}, {"w": "it", "b": [0.4059, 0.3403, 0.4178, 0.3617]}, {"w": "contains", "b": [0.4238, 0.3403, 0.4944, 0.3617]}, {"w": "other", "b": [0.5004, 0.3403, 0.5451, 0.3617]}, {"w": "layers.", "b": [0.5511, 0.3403, 0.6037, 0.3617]}, {"w": "This", "b": [0.6097, 0.3403, 0.6469, 0.3617]}, {"w": "is", "b": [0.653, 0.3403, 0.6662, 0.3617]}, {"w": "handled", "b": [0.6722, 0.3403, 0.74, 0.3617]}, {"w": "transparently", "b": [0.746, 0.3403, 0.8571, 0.3617]}, {"w": "by", "b": [0.1429, 0.3602, 0.163, 0.3816]}, {"w": "Keras:", "b": [0.1689, 0.3602, 0.2206, 0.3816]}, {"w": "it", "b": [0.2265, 0.3602, 0.2384, 0.3816]}, {"w": "automatically", "b": [0.2444, 0.3602, 0.357, 0.3816]}, {"w": "detects", "b": [0.3629, 0.3602, 0.4208, 0.3816]}, {"w": "that", "b": [0.4267, 0.3602, 0.4593, 0.3816]}, {"w": "the", "b": [0.4652, 0.3602, 0.4915, 0.3816]}, {"w": "hidden", "b": [0.4974, 0.3634, 0.5568, 0.3785]}, {"w": "attribute", "b": [0.5627, 0.3602, 0.6344, 0.3816]}, {"w": "contains", "b": [0.6403, 0.3602, 0.7109, 0.3816]}, {"w": "trackable", "b": [0.7168, 0.3602, 0.793, 0.3816]}, {"w": "objects", "b": [0.7989, 0.3602, 0.8571, 0.3816]}, {"w": "(layers", "b": [0.1429, 0.3793, 0.1979, 0.4007]}, {"w": "in", "b": [0.2054, 0.3793, 0.2223, 0.4007]}, {"w": "this", "b": [0.2298, 0.3793, 0.2605, 0.4007]}, {"w": "case),", "b": [0.268, 0.3793, 0.3144, 0.4007]}, {"w": "so", "b": [0.3218, 0.3793, 0.3401, 0.4007]}, {"w": "their", "b": [0.3476, 0.3793, 0.3872, 0.4007]}, {"w": "variables", "b": [0.3947, 0.3793, 0.4683, 0.4007]}, {"w": "are", "b": [0.4757, 0.3793, 0.5015, 0.4007]}, {"w": "automatically", "b": [0.5089, 0.3793, 0.6215, 0.4007]}, {"w": "added", "b": [0.629, 0.3793, 0.68, 0.4007]}, {"w": "to", "b": [0.6875, 0.3793, 0.7044, 0.4007]}, {"w": "this", "b": [0.7119, 0.3793, 0.7426, 0.4007]}, {"w": "layer’s", "b": [0.7501, 0.3793, 0.8006, 0.4007]}, {"w": "list", "b": [0.808, 0.3793, 0.8329, 0.4007]}, {"w": "of", "b": [0.8403, 0.3793, 0.8571, 0.4007]}, {"w": "variables.", "b": [0.1429, 0.3983, 0.2212, 0.4197]}, {"w": "The", "b": [0.2273, 0.3983, 0.2601, 0.4197]}, {"w": "rest", "b": [0.2662, 0.3983, 0.2968, 0.4197]}, {"w": "of", "b": [0.3029, 0.3983, 0.3197, 0.4197]}, {"w": "this", "b": [0.3257, 0.3983, 0.3564, 0.4197]}, {"w": "class", "b": [0.3625, 0.3983, 0.401, 0.4197]}, {"w": "is", "b": [0.4071, 0.3983, 0.4203, 0.4197]}, {"w": "self-explanatory.", "b": [0.4264, 0.3983, 0.564, 0.4197]}, {"w": "Next,", "b": [0.5701, 0.3983, 0.6149, 0.4197]}, {"w": "let’s", "b": [0.621, 0.3983, 0.6512, 0.4197]}, {"w": "use", "b": [0.6573, 0.3983, 0.6848, 0.4197]}, {"w": "the", "b": [0.6909, 0.3983, 0.7172, 0.4197]}, {"w": "subclassing", "b": [0.7233, 0.3983, 0.8178, 0.4197]}, {"w": "API", "b": [0.8239, 0.3983, 0.8572, 0.4197]}, {"w": "to", "b": [0.1429, 0.4174, 0.1598, 0.4388]}, {"w": "define", "b": [0.1646, 0.4174, 0.2164, 0.4388]}, {"w": "the", "b": [0.2212, 0.4174, 0.2475, 0.4388]}, {"w": "model", "b": [0.2522, 0.4174, 0.305, 0.4388]}, {"w": "itself:", "b": [0.3098, 0.4174, 0.3544, 0.4388]}]}, {"id": "b_4", "type": "paragraph", "text": "class ResidualRegressor(keras.models.Model): def __init__(self, output_dim, **kwargs): super().__init__(**kwargs) self.hidden1 = keras.layers.Dense(30, activation=\"elu\", kernel_initializer=\"he_normal\") self.block1 = ResidualBlock(2, 30) self.block2 = ResidualBlock(2, 30) self.out = keras.layers.Dense(output_dim)", "words": [{"w": "class", "b": [0.1766, 0.4493, 0.2188, 0.4622]}, {"w": "ResidualRegressor(keras.models.Model):", "b": [0.2272, 0.4493, 0.5476, 0.4622]}, {"w": "def", "b": [0.2103, 0.4648, 0.2356, 0.4776]}, {"w": "__init__(self,", "b": [0.2441, 0.4648, 0.3621, 0.4776]}, {"w": "output_dim,", "b": [0.3705, 0.4648, 0.4633, 0.4776]}, {"w": "**kwargs):", "b": [0.4717, 0.4648, 0.5561, 0.4776]}, {"w": "super().__init__(**kwargs)", "b": [0.2441, 0.4802, 0.4633, 0.493]}, {"w": "self.hidden1", "b": [0.2441, 0.4956, 0.3452, 0.5084]}, {"w": "=", "b": [0.3537, 0.4956, 0.3621, 0.5084]}, {"w": "keras.layers.Dense(30,", "b": [0.3705, 0.4956, 0.5561, 0.5084]}, {"w": "activation=\"elu\",", "b": [0.5645, 0.4956, 0.7078, 0.5084]}, {"w": "kernel_initializer=\"he_normal\")", "b": [0.5308, 0.511, 0.7922, 0.5239]}, {"w": "self.block1", "b": [0.2441, 0.5264, 0.3368, 0.5393]}, {"w": "=", "b": [0.3452, 0.5264, 0.3537, 0.5393]}, {"w": "ResidualBlock(2,", "b": [0.3621, 0.5264, 0.497, 0.5393]}, {"w": "30)", "b": [0.5055, 0.5264, 0.5308, 0.5393]}, {"w": "self.block2", "b": [0.2441, 0.5419, 0.3368, 0.5547]}, {"w": "=", "b": [0.3452, 0.5419, 0.3537, 0.5547]}, {"w": "ResidualBlock(2,", "b": [0.3621, 0.5419, 0.497, 0.5547]}, {"w": "30)", "b": [0.5055, 0.5419, 0.5308, 0.5547]}, {"w": "self.out", "b": [0.2441, 0.5573, 0.3115, 0.5701]}, {"w": "=", "b": [0.3199, 0.5573, 0.3284, 0.5701]}, {"w": "keras.layers.Dense(output_dim)", "b": [0.3368, 0.5573, 0.5898, 0.5701]}]}, {"id": "b_5", "type": "paragraph", "text": "def call(self, inputs): Z = self.hidden1(inputs) for _ in range(1 + 3): Z = self.block1(Z) Z = self.block2(Z) return self.out(Z)", "words": [{"w": "def", "b": [0.2103, 0.5881, 0.2356, 0.601]}, {"w": "call(self,", "b": [0.2441, 0.5881, 0.3284, 0.601]}, {"w": "inputs):", "b": [0.3368, 0.5881, 0.4043, 0.601]}, {"w": "Z", "b": [0.2441, 0.6035, 0.2525, 0.6164]}, {"w": "=", "b": [0.2609, 0.6035, 0.2693, 0.6164]}, {"w": "self.hidden1(inputs)", "b": [0.2778, 0.6035, 0.4464, 0.6164]}, {"w": "for", "b": [0.2441, 0.619, 0.2693, 0.6318]}, {"w": "_", "b": [0.2778, 0.619, 0.2862, 0.6318]}, {"w": "in", "b": [0.2946, 0.619, 0.3115, 0.6318]}, {"w": "range(1", "b": [0.3199, 0.619, 0.379, 0.6318]}, {"w": "+", "b": [0.3874, 0.619, 0.3958, 0.6318]}, {"w": "3):", "b": [0.4043, 0.619, 0.4296, 0.6318]}, {"w": "Z", "b": [0.2778, 0.6344, 0.2862, 0.6472]}, {"w": "=", "b": [0.2946, 0.6344, 0.3031, 0.6472]}, {"w": "self.block1(Z)", "b": [0.3115, 0.6344, 0.4296, 0.6472]}, {"w": "Z", "b": [0.2441, 0.6498, 0.2525, 0.6626]}, {"w": "=", "b": [0.2609, 0.6498, 0.2693, 0.6626]}, {"w": "self.block2(Z)", "b": [0.2778, 0.6498, 0.3958, 0.6626]}, {"w": "return", "b": [0.2441, 0.6652, 0.2946, 0.6781]}, {"w": "self.out(Z)", "b": [0.3031, 0.6652, 0.3958, 0.6781]}]}, {"id": "b_6", "type": "paragraph", "text": "We create the layers in the constructor, and use them in the call() method. This model can then be used like any other model (compile it, fit it, evaluate it and use it to make predictions). If you also want to be able to save the model using the save() method, and load it using the keras.models.load_model() function, you must implement the get_config() method (as we did earlier) in both the ResidualBlock class and the ResidualRegressor class. Alternatively, you can just save and load the weights using the save_weights() and load_weights() methods.", "words": [{"w": "We", "b": [0.1429, 0.6867, 0.1699, 0.7082]}, {"w": "create", "b": [0.1776, 0.6867, 0.227, 0.7082]}, {"w": "the", "b": [0.2347, 0.6867, 0.261, 0.7082]}, {"w": "layers", "b": [0.2687, 0.6867, 0.3165, 0.7082]}, {"w": "in", "b": [0.3242, 0.6867, 0.3412, 0.7082]}, {"w": "the", "b": [0.3489, 0.6867, 0.3752, 0.7082]}, {"w": "constructor,", "b": [0.3829, 0.6867, 0.4835, 0.7082]}, {"w": "and", "b": [0.4912, 0.6867, 0.5227, 0.7082]}, {"w": "use", "b": [0.5304, 0.6867, 0.5579, 0.7082]}, {"w": "them", "b": [0.5656, 0.6867, 0.609, 0.7082]}, {"w": "in", "b": [0.6167, 0.6867, 0.6337, 0.7082]}, {"w": "the", "b": [0.6414, 0.6867, 0.6677, 0.7082]}, {"w": "call()", "b": [0.6754, 0.6899, 0.7348, 0.705]}, {"w": "method.", "b": [0.7425, 0.6867, 0.8122, 0.7082]}, {"w": "This", "b": [0.8199, 0.6867, 0.8571, 0.7082]}, {"w": "model", "b": [0.1429, 0.7058, 0.1957, 0.7272]}, {"w": "can", "b": [0.2004, 0.7058, 0.2298, 0.7272]}, {"w": "then", "b": [0.2346, 0.7058, 0.2723, 0.7272]}, {"w": "be", "b": [0.2771, 0.7058, 0.2965, 0.7272]}, {"w": "used", "b": [0.3013, 0.7058, 0.3398, 0.7272]}, {"w": "like", "b": [0.3446, 0.7058, 0.3747, 0.7272]}, {"w": "any", "b": [0.3794, 0.7058, 0.409, 0.7272]}, {"w": "other", "b": [0.4138, 0.7058, 0.4585, 0.7272]}, {"w": "model", "b": [0.4633, 0.7058, 0.5161, 0.7272]}, {"w": "(compile", "b": [0.5209, 0.7058, 0.5948, 0.7272]}, {"w": "it,", "b": [0.5996, 0.7058, 0.6163, 0.7272]}, {"w": "fit", "b": [0.621, 0.7058, 0.6391, 0.7272]}, {"w": "it,", "b": [0.6439, 0.7058, 0.6606, 0.7272]}, {"w": "evaluate", "b": [0.6654, 0.7058, 0.7333, 0.7272]}, {"w": "it", "b": [0.7381, 0.7058, 0.75, 0.7272]}, {"w": "and", "b": [0.7548, 0.7058, 0.7863, 0.7272]}, {"w": "use", "b": [0.7911, 0.7058, 0.8187, 0.7272]}, {"w": "it", "b": [0.8234, 0.7058, 0.8354, 0.7272]}, {"w": "to", "b": [0.8402, 0.7058, 0.8571, 0.7272]}, {"w": "make", "b": [0.1429, 0.7257, 0.1883, 0.7471]}, {"w": "predictions).", "b": [0.1957, 0.7257, 0.3022, 0.7471]}, {"w": "If", "b": [0.3097, 0.7257, 0.3229, 0.7471]}, {"w": "you", "b": [0.3304, 0.7257, 0.3616, 0.7471]}, {"w": "also", "b": [0.3691, 0.7257, 0.4018, 0.7471]}, {"w": "want", "b": [0.4093, 0.7257, 0.45, 0.7471]}, {"w": "to", "b": [0.4575, 0.7257, 0.4745, 0.7471]}, {"w": "be", "b": [0.4819, 0.7257, 0.5014, 0.7471]}, {"w": "able", "b": [0.5088, 0.7257, 0.5427, 0.7471]}, {"w": "to", "b": [0.5502, 0.7257, 0.5671, 0.7471]}, {"w": "save", "b": [0.5746, 0.7257, 0.6095, 0.7471]}, {"w": "the", "b": [0.617, 0.7257, 0.6433, 0.7471]}, {"w": "model", "b": [0.6508, 0.7257, 0.7036, 0.7471]}, {"w": "using", "b": [0.7111, 0.7257, 0.7565, 0.7471]}, {"w": "the", "b": [0.764, 0.7257, 0.7903, 0.7471]}, {"w": "save()", "b": [0.7978, 0.7289, 0.8572, 0.744]}, {"w": "method,", "b": [0.1429, 0.7457, 0.2126, 0.7671]}, {"w": "and", "b": [0.2234, 0.7457, 0.2549, 0.7671]}, {"w": "load", "b": [0.2657, 0.7457, 0.3017, 0.7671]}, {"w": "it", "b": [0.3124, 0.7457, 0.3244, 0.7671]}, {"w": "using", "b": [0.3351, 0.7457, 0.3806, 0.7671]}, {"w": "the", "b": [0.3913, 0.7457, 0.4176, 0.7671]}, {"w": "keras.models.load_model()", "b": [0.4284, 0.7489, 0.6758, 0.7639]}, {"w": "function,", "b": [0.6865, 0.7457, 0.7627, 0.7671]}, {"w": "you", "b": [0.7734, 0.7457, 0.8047, 0.7671]}, {"w": "must", "b": [0.8154, 0.7457, 0.8571, 0.7671]}, {"w": "implement", "b": [0.1429, 0.7656, 0.2334, 0.787]}, {"w": "the", "b": [0.2396, 0.7656, 0.2659, 0.787]}, {"w": "get_config()", "b": [0.2721, 0.7688, 0.3908, 0.7839]}, {"w": "method", "b": [0.397, 0.7656, 0.462, 0.787]}, {"w": "(as", "b": [0.4682, 0.7656, 0.4922, 0.787]}, {"w": "we", "b": [0.4984, 0.7656, 0.5215, 0.787]}, {"w": "did", "b": [0.5277, 0.7656, 0.5553, 0.787]}, {"w": "earlier)", "b": [0.5614, 0.7656, 0.6218, 0.787]}, {"w": "in", "b": [0.628, 0.7656, 0.645, 0.787]}, {"w": "both", "b": [0.6511, 0.7656, 0.6898, 0.787]}, {"w": "the", "b": [0.696, 0.7656, 0.7223, 0.787]}, {"w": "ResidualBlock", "b": [0.7285, 0.7688, 0.8571, 0.7839]}, {"w": "class", "b": [0.1428, 0.7856, 0.1814, 0.807]}, {"w": "and", "b": [0.1876, 0.7856, 0.2192, 0.807]}, {"w": "the", "b": [0.2255, 0.7856, 0.2518, 0.807]}, {"w": "ResidualRegressor", "b": [0.2581, 0.7887, 0.4263, 0.8038]}, {"w": "class.", "b": [0.4326, 0.7856, 0.4758, 0.807]}, {"w": "Alternatively,", "b": [0.4821, 0.7856, 0.5934, 0.807]}, {"w": "you", "b": [0.5996, 0.7856, 0.6309, 0.807]}, {"w": "can", "b": [0.6372, 0.7856, 0.6665, 0.807]}, {"w": "just", "b": [0.6728, 0.7856, 0.7032, 0.807]}, {"w": "save", "b": [0.7095, 0.7856, 0.7444, 0.807]}, {"w": "and", "b": [0.7507, 0.7856, 0.7822, 0.807]}, {"w": "load", "b": [0.7885, 0.7856, 0.8245, 0.807]}, {"w": "the", "b": [0.8308, 0.7856, 0.8571, 0.807]}, {"w": "weights", "b": [0.1429, 0.8055, 0.206, 0.8269]}, {"w": "using", "b": [0.2108, 0.8055, 0.2562, 0.8269]}, {"w": "the", "b": [0.2609, 0.8055, 0.2873, 0.8269]}, {"w": "save_weights()", "b": [0.292, 0.8087, 0.4305, 0.8238]}, {"w": "and", "b": [0.4353, 0.8055, 0.4668, 0.8269]}, {"w": "load_weights()", "b": [0.4715, 0.8087, 0.6101, 0.8238]}, {"w": "methods.", "b": [0.6148, 0.8055, 0.6922, 0.8269]}]}, {"id": "b_7", "type": "paragraph", "text": "The Model class is actually a subclass of the Layer class, so models can be defined and used exactly like layers. But a model also has some extra functionalities, including of course its compile(), fit(), evaluate() and predict() methods (and a few var‐", "words": [{"w": "The", "b": [0.1429, 0.8345, 0.1757, 0.8559]}, {"w": "Model", "b": [0.1807, 0.8377, 0.2302, 0.8528]}, {"w": "class", "b": [0.2353, 0.8345, 0.2738, 0.8559]}, {"w": "is", "b": [0.2789, 0.8345, 0.2921, 0.8559]}, {"w": "actually", "b": [0.2971, 0.8345, 0.3618, 0.8559]}, {"w": "a", "b": [0.3668, 0.8345, 0.376, 0.8559]}, {"w": "subclass", "b": [0.381, 0.8345, 0.4488, 0.8559]}, {"w": "of", "b": [0.4539, 0.8345, 0.4707, 0.8559]}, {"w": "the", "b": [0.4757, 0.8345, 0.5021, 0.8559]}, {"w": "Layer", "b": [0.5071, 0.8377, 0.5566, 0.8528]}, {"w": "class,", "b": [0.5616, 0.8345, 0.6049, 0.8559]}, {"w": "so", "b": [0.61, 0.8345, 0.6282, 0.8559]}, {"w": "models", "b": [0.6333, 0.8345, 0.6937, 0.8559]}, {"w": "can", "b": [0.6988, 0.8345, 0.7281, 0.8559]}, {"w": "be", "b": [0.7332, 0.8345, 0.7526, 0.8559]}, {"w": "defined", "b": [0.7577, 0.8345, 0.8205, 0.8559]}, {"w": "and", "b": [0.8256, 0.8345, 0.8571, 0.8559]}, {"w": "used", "b": [0.1428, 0.8536, 0.1814, 0.875]}, {"w": "exactly", "b": [0.1872, 0.8536, 0.2451, 0.875]}, {"w": "like", "b": [0.2509, 0.8536, 0.2809, 0.875]}, {"w": "layers.", "b": [0.2868, 0.8536, 0.3393, 0.875]}, {"w": "But", "b": [0.3452, 0.8536, 0.3748, 0.875]}, {"w": "a", "b": [0.3807, 0.8536, 0.3898, 0.875]}, {"w": "model", "b": [0.3956, 0.8536, 0.4484, 0.875]}, {"w": "also", "b": [0.4543, 0.8536, 0.4869, 0.875]}, {"w": "has", "b": [0.4928, 0.8536, 0.5207, 0.875]}, {"w": "some", "b": [0.5265, 0.8536, 0.5707, 0.875]}, {"w": "extra", "b": [0.5765, 0.8536, 0.6184, 0.875]}, {"w": "functionalities,", "b": [0.6243, 0.8536, 0.7488, 0.875]}, {"w": "including", "b": [0.7547, 0.8536, 0.8345, 0.875]}, {"w": "of", "b": [0.8403, 0.8536, 0.8571, 0.875]}, {"w": "course", "b": [0.1429, 0.8735, 0.1976, 0.8949]}, {"w": "its", "b": [0.2056, 0.8735, 0.2252, 0.8949]}, {"w": "compile(),", "b": [0.2333, 0.8735, 0.3271, 0.8949]}, {"w": "fit(),", "b": [0.3351, 0.8735, 0.3894, 0.8949]}, {"w": "evaluate()", "b": [0.3974, 0.8767, 0.4964, 0.8918]}, {"w": "and", "b": [0.5044, 0.8735, 0.536, 0.8949]}, {"w": "predict()", "b": [0.544, 0.8767, 0.6331, 0.8918]}, {"w": "methods", "b": [0.6411, 0.8735, 0.7138, 0.8949]}, {"w": "(and", "b": [0.7219, 0.8735, 0.7606, 0.8949]}, {"w": "a", "b": [0.7687, 0.8735, 0.7778, 0.8949]}, {"w": "few", "b": [0.7859, 0.8735, 0.8152, 0.8949]}, {"w": "var‐", "b": [0.8232, 0.8735, 0.8571, 0.8949]}]}, {"id": "b_8", "type": "paragraph", "text": "Customizing Models and Training Algorithms | 387", "words": [{"w": "Customizing", "b": [0.5328, 0.9225, 0.6056, 0.9388]}, {"w": "Models", "b": [0.6084, 0.9225, 0.6507, 0.9388]}, {"w": "and", "b": [0.6535, 0.9225, 0.6759, 0.9388]}, {"w": "Training", "b": [0.6787, 0.9225, 0.7278, 0.9388]}, {"w": "Algorithms", "b": [0.7306, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "387", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 414, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "iants, such as train_on_batch() or fit_generator()), plus the get_layers() method (which can return any of the model’s layers by name or by index), and the save() method (and support for keras.models.load_model() and keras.mod els.clone_model()). So if models provide more functionalities than layers, why not just define every layer as a model? Well, technically you could, but it is probably cleaner to distinguish the internal components of your model (layers or reusable blocks of layers) from the model itself. The former should subclass the Layer class, while the latter should subclass the Model class.", "words": [{"w": "iants,", "b": [0.1429, 0.08, 0.1873, 0.1014]}, {"w": "such", "b": [0.1995, 0.08, 0.2381, 0.1014]}, {"w": "as", "b": [0.2503, 0.08, 0.2671, 0.1014]}, {"w": "train_on_batch()", "b": [0.2793, 0.0831, 0.4376, 0.0982]}, {"w": "or", "b": [0.4498, 0.08, 0.4681, 0.1014]}, {"w": "fit_generator()),", "b": [0.4803, 0.08, 0.6407, 0.1014]}, {"w": "plus", "b": [0.6528, 0.08, 0.6877, 0.1014]}, {"w": "the", "b": [0.6999, 0.08, 0.7262, 0.1014]}, {"w": "get_layers()", "b": [0.7384, 0.0831, 0.8571, 0.0982]}, {"w": "method", "b": [0.1429, 0.099, 0.2079, 0.1204]}, {"w": "(which", "b": [0.2148, 0.099, 0.2729, 0.1204]}, {"w": "can", "b": [0.2798, 0.099, 0.3092, 0.1204]}, {"w": "return", "b": [0.3161, 0.099, 0.3693, 0.1204]}, {"w": "any", "b": [0.3762, 0.099, 0.4058, 0.1204]}, {"w": "of", "b": [0.4127, 0.099, 0.4295, 0.1204]}, {"w": "the", "b": [0.4364, 0.099, 0.4628, 0.1204]}, {"w": "model’s", "b": [0.4697, 0.099, 0.5323, 0.1204]}, {"w": "layers", "b": [0.5392, 0.099, 0.5871, 0.1204]}, {"w": "by", "b": [0.594, 0.099, 0.6141, 0.1204]}, {"w": "name", "b": [0.621, 0.099, 0.6675, 0.1204]}, {"w": "or", "b": [0.6744, 0.099, 0.6928, 0.1204]}, {"w": "by", "b": [0.6997, 0.099, 0.7199, 0.1204]}, {"w": "index),", "b": [0.7268, 0.099, 0.7854, 0.1204]}, {"w": "and", "b": [0.7923, 0.099, 0.8239, 0.1204]}, {"w": "the", "b": [0.8308, 0.099, 0.8571, 0.1204]}, {"w": "save()", "b": [0.1429, 0.1221, 0.2022, 0.1372]}, {"w": "method", "b": [0.2145, 0.119, 0.2796, 0.1404]}, {"w": "(and", "b": [0.2919, 0.119, 0.3306, 0.1404]}, {"w": "support", "b": [0.3429, 0.119, 0.4082, 0.1404]}, {"w": "for", "b": [0.4205, 0.119, 0.445, 0.1404]}, {"w": "keras.models.load_model()", "b": [0.4573, 0.1221, 0.7047, 0.1372]}, {"w": "and", "b": [0.717, 0.119, 0.7486, 0.1404]}, {"w": "keras.mod", "b": [0.7609, 0.1221, 0.8499, 0.1372]}, {"w": "els.clone_model()).", "b": [0.1429, 0.1389, 0.323, 0.1603]}, {"w": "So", "b": [0.329, 0.1389, 0.3495, 0.1603]}, {"w": "if", "b": [0.3554, 0.1389, 0.3672, 0.1603]}, {"w": "models", "b": [0.3731, 0.1389, 0.4336, 0.1603]}, {"w": "provide", "b": [0.4395, 0.1389, 0.5039, 0.1603]}, {"w": "more", "b": [0.5098, 0.1389, 0.5541, 0.1603]}, {"w": "functionalities", "b": [0.5601, 0.1389, 0.6799, 0.1603]}, {"w": "than", "b": [0.6858, 0.1389, 0.7239, 0.1603]}, {"w": "layers,", "b": [0.7298, 0.1389, 0.7824, 0.1603]}, {"w": "why", "b": [0.7883, 0.1389, 0.8228, 0.1603]}, {"w": "not", "b": [0.8288, 0.1389, 0.8571, 0.1603]}, {"w": "just", "b": [0.1429, 0.1579, 0.1733, 0.1794]}, {"w": "define", "b": [0.1816, 0.1579, 0.2335, 0.1794]}, {"w": "every", "b": [0.2418, 0.1579, 0.2871, 0.1794]}, {"w": "layer", "b": [0.2954, 0.1579, 0.3356, 0.1794]}, {"w": "as", "b": [0.344, 0.1579, 0.3608, 0.1794]}, {"w": "a", "b": [0.3691, 0.1579, 0.3783, 0.1794]}, {"w": "model?", "b": [0.3866, 0.1579, 0.4474, 0.1794]}, {"w": "Well,", "b": [0.4557, 0.1579, 0.4981, 0.1794]}, {"w": "technically", "b": [0.5064, 0.1579, 0.5966, 0.1794]}, {"w": "you", "b": [0.605, 0.1579, 0.6362, 0.1794]}, {"w": "could,", "b": [0.6446, 0.1579, 0.6961, 0.1794]}, {"w": "but", "b": [0.7045, 0.1579, 0.7325, 0.1794]}, {"w": "it", "b": [0.7408, 0.1579, 0.7528, 0.1794]}, {"w": "is", "b": [0.7611, 0.1579, 0.7744, 0.1794]}, {"w": "probably", "b": [0.7827, 0.1579, 0.8571, 0.1794]}, {"w": "cleaner", "b": [0.1429, 0.177, 0.2029, 0.1984]}, {"w": "to", "b": [0.2119, 0.177, 0.2289, 0.1984]}, {"w": "distinguish", "b": [0.2379, 0.177, 0.3306, 0.1984]}, {"w": "the", "b": [0.3396, 0.177, 0.3659, 0.1984]}, {"w": "internal", "b": [0.3749, 0.177, 0.4402, 0.1984]}, {"w": "components", "b": [0.4492, 0.177, 0.5521, 0.1984]}, {"w": "of", "b": [0.5611, 0.177, 0.5779, 0.1984]}, {"w": "your", "b": [0.5869, 0.177, 0.6258, 0.1984]}, {"w": "model", "b": [0.6348, 0.177, 0.6876, 0.1984]}, {"w": "(layers", "b": [0.6966, 0.177, 0.7517, 0.1984]}, {"w": "or", "b": [0.7607, 0.177, 0.779, 0.1984]}, {"w": "reusable", "b": [0.788, 0.177, 0.8571, 0.1984]}, {"w": "blocks", "b": [0.1429, 0.1969, 0.1961, 0.2183]}, {"w": "of", "b": [0.203, 0.1969, 0.2198, 0.2183]}, {"w": "layers)", "b": [0.2267, 0.1969, 0.2817, 0.2183]}, {"w": "from", "b": [0.2886, 0.1969, 0.3301, 0.2183]}, {"w": "the", "b": [0.337, 0.1969, 0.3633, 0.2183]}, {"w": "model", "b": [0.3702, 0.1969, 0.423, 0.2183]}, {"w": "itself.", "b": [0.4299, 0.1969, 0.4745, 0.2183]}, {"w": "The", "b": [0.4814, 0.1969, 0.5142, 0.2183]}, {"w": "former", "b": [0.5211, 0.1969, 0.5792, 0.2183]}, {"w": "should", "b": [0.5861, 0.1969, 0.6428, 0.2183]}, {"w": "subclass", "b": [0.6497, 0.1969, 0.7175, 0.2183]}, {"w": "the", "b": [0.7243, 0.1969, 0.7507, 0.2183]}, {"w": "Layer", "b": [0.7575, 0.2001, 0.807, 0.2152]}, {"w": "class,", "b": [0.8139, 0.1969, 0.8572, 0.2183]}, {"w": "while", "b": [0.1429, 0.2169, 0.188, 0.2383]}, {"w": "the", "b": [0.1927, 0.2169, 0.219, 0.2383]}, {"w": "latter", "b": [0.2238, 0.2169, 0.2671, 0.2383]}, {"w": "should", "b": [0.2718, 0.2169, 0.3285, 0.2383]}, {"w": "subclass", "b": [0.3333, 0.2169, 0.4011, 0.2383]}, {"w": "the", "b": [0.4058, 0.2169, 0.4321, 0.2383]}, {"w": "Model", "b": [0.4369, 0.2201, 0.4863, 0.2351]}, {"w": "class.", "b": [0.4911, 0.2169, 0.5343, 0.2383]}]}, {"id": "b_1", "type": "paragraph", "text": "With that, you can quite naturally and concisely build almost any model that you find in a paper, either using the sequential API, the functional API, the subclassing API, or even a mix of these. “Almost” any model? Yes, there are still a couple things that we need to look at: first, how to define losses or metrics based on model internals, and second how to build a custom training loop.", "words": [{"w": "With", "b": [0.1429, 0.245, 0.1853, 0.2664]}, {"w": "that,", "b": [0.1902, 0.245, 0.2275, 0.2664]}, {"w": "you", "b": [0.2325, 0.245, 0.2637, 0.2664]}, {"w": "can", "b": [0.2686, 0.245, 0.298, 0.2664]}, {"w": "quite", "b": [0.3029, 0.245, 0.3454, 0.2664]}, {"w": "naturally", "b": [0.3503, 0.245, 0.4248, 0.2664]}, {"w": "and", "b": [0.4297, 0.245, 0.4613, 0.2664]}, {"w": "concisely", "b": [0.4662, 0.245, 0.5428, 0.2664]}, {"w": "build", "b": [0.5477, 0.245, 0.5912, 0.2664]}, {"w": "almost", "b": [0.5961, 0.245, 0.6522, 0.2664]}, {"w": "any", "b": [0.6571, 0.245, 0.6867, 0.2664]}, {"w": "model", "b": [0.6916, 0.245, 0.7444, 0.2664]}, {"w": "that", "b": [0.7493, 0.245, 0.7819, 0.2664]}, {"w": "you", "b": [0.7868, 0.245, 0.8181, 0.2664]}, {"w": "find", "b": [0.823, 0.245, 0.8571, 0.2664]}, {"w": "in", "b": [0.1429, 0.264, 0.1598, 0.2855]}, {"w": "a", "b": [0.1647, 0.264, 0.1738, 0.2855]}, {"w": "paper,", "b": [0.1786, 0.264, 0.2292, 0.2855]}, {"w": "either", "b": [0.2341, 0.264, 0.2826, 0.2855]}, {"w": "using", "b": [0.2874, 0.264, 0.3328, 0.2855]}, {"w": "the", "b": [0.3377, 0.264, 0.364, 0.2855]}, {"w": "sequential", "b": [0.3688, 0.264, 0.4532, 0.2855]}, {"w": "API,", "b": [0.4581, 0.264, 0.496, 0.2855]}, {"w": "the", "b": [0.5009, 0.264, 0.5272, 0.2855]}, {"w": "functional", "b": [0.532, 0.264, 0.6178, 0.2855]}, {"w": "API,", "b": [0.6227, 0.264, 0.6606, 0.2855]}, {"w": "the", "b": [0.6655, 0.264, 0.6918, 0.2855]}, {"w": "subclassing", "b": [0.6966, 0.264, 0.7912, 0.2855]}, {"w": "API,", "b": [0.796, 0.264, 0.834, 0.2855]}, {"w": "or", "b": [0.8388, 0.264, 0.8571, 0.2855]}, {"w": "even", "b": [0.1429, 0.2831, 0.1816, 0.3045]}, {"w": "a", "b": [0.188, 0.2831, 0.1971, 0.3045]}, {"w": "mix", "b": [0.2035, 0.2831, 0.236, 0.3045]}, {"w": "of", "b": [0.2423, 0.2831, 0.2591, 0.3045]}, {"w": "these.", "b": [0.2655, 0.2831, 0.3131, 0.3045]}, {"w": "“Almost”", "b": [0.3195, 0.2831, 0.3938, 0.3045]}, {"w": "any", "b": [0.4001, 0.2831, 0.4298, 0.3045]}, {"w": "model?", "b": [0.4361, 0.2831, 0.4969, 0.3045]}, {"w": "Yes,", "b": [0.5032, 0.2831, 0.5351, 0.3045]}, {"w": "there", "b": [0.5415, 0.2831, 0.5844, 0.3045]}, {"w": "are", "b": [0.5908, 0.2831, 0.6165, 0.3045]}, {"w": "still", "b": [0.6229, 0.2831, 0.653, 0.3045]}, {"w": "a", "b": [0.6594, 0.2831, 0.6685, 0.3045]}, {"w": "couple", "b": [0.6749, 0.2831, 0.7305, 0.3045]}, {"w": "things", "b": [0.7368, 0.2831, 0.7887, 0.3045]}, {"w": "that", "b": [0.7951, 0.2831, 0.8276, 0.3045]}, {"w": "we", "b": [0.834, 0.2831, 0.8571, 0.3045]}, {"w": "need", "b": [0.1429, 0.3021, 0.183, 0.3236]}, {"w": "to", "b": [0.1895, 0.3021, 0.2065, 0.3236]}, {"w": "look", "b": [0.213, 0.3021, 0.2499, 0.3236]}, {"w": "at:", "b": [0.2564, 0.3021, 0.2763, 0.3236]}, {"w": "first,", "b": [0.2828, 0.3021, 0.321, 0.3236]}, {"w": "how", "b": [0.3276, 0.3021, 0.3636, 0.3236]}, {"w": "to", "b": [0.3701, 0.3021, 0.3871, 0.3236]}, {"w": "define", "b": [0.3936, 0.3021, 0.4455, 0.3236]}, {"w": "losses", "b": [0.452, 0.3021, 0.4997, 0.3236]}, {"w": "or", "b": [0.5062, 0.3021, 0.5246, 0.3236]}, {"w": "metrics", "b": [0.5311, 0.3021, 0.5932, 0.3236]}, {"w": "based", "b": [0.5997, 0.3021, 0.6469, 0.3236]}, {"w": "on", "b": [0.6534, 0.3021, 0.6755, 0.3236]}, {"w": "model", "b": [0.682, 0.3021, 0.7348, 0.3236]}, {"w": "internals,", "b": [0.7413, 0.3021, 0.8191, 0.3236]}, {"w": "and", "b": [0.8256, 0.3021, 0.8572, 0.3236]}, {"w": "second", "b": [0.1429, 0.3212, 0.2012, 0.3426]}, {"w": "how", "b": [0.2059, 0.3212, 0.2419, 0.3426]}, {"w": "to", "b": [0.2467, 0.3212, 0.2637, 0.3426]}, {"w": "build", "b": [0.2684, 0.3212, 0.3119, 0.3426]}, {"w": "a", "b": [0.3166, 0.3212, 0.3258, 0.3426]}, {"w": "custom", "b": [0.3305, 0.3212, 0.392, 0.3426]}, {"w": "training", "b": [0.3968, 0.3212, 0.4637, 0.3426]}, {"w": "loop.", "b": [0.4684, 0.3212, 0.51, 0.3426]}]}, {"id": "b_2", "type": "paragraph", "text": "Losses and Metrics Based on Model Internals", "words": [{"w": "Losses", "b": [0.1429, 0.3554, 0.2083, 0.3839]}, {"w": "and", "b": [0.2133, 0.3554, 0.2525, 0.3839]}, {"w": "Metrics", "b": [0.2575, 0.3554, 0.3326, 0.3839]}, {"w": "Based", "b": [0.3375, 0.3554, 0.3993, 0.3839]}, {"w": "on", "b": [0.4043, 0.3554, 0.4307, 0.3839]}, {"w": "Model", "b": [0.4356, 0.3554, 0.5, 0.3839]}, {"w": "Internals", "b": [0.505, 0.3554, 0.5976, 0.3839]}]}, {"id": "b_3", "type": "paragraph", "text": "The custom losses and metrics we defined earlier were all based on the labels and the predictions (and optionally sample weights). However, you will occasionally want to define losses based on other parts of your model, such as the weights or activations of its hidden layers. This may be useful for regularization purposes, or to monitor some internal aspect of your model.", "words": [{"w": "The", "b": [0.1429, 0.3898, 0.1757, 0.4112]}, {"w": "custom", "b": [0.181, 0.3898, 0.2426, 0.4112]}, {"w": "losses", "b": [0.2479, 0.3898, 0.2956, 0.4112]}, {"w": "and", "b": [0.3009, 0.3898, 0.3325, 0.4112]}, {"w": "metrics", "b": [0.3378, 0.3898, 0.3998, 0.4112]}, {"w": "we", "b": [0.4051, 0.3898, 0.4283, 0.4112]}, {"w": "defined", "b": [0.4336, 0.3898, 0.4965, 0.4112]}, {"w": "earlier", "b": [0.5018, 0.3898, 0.5549, 0.4112]}, {"w": "were", "b": [0.5603, 0.3898, 0.6, 0.4112]}, {"w": "all", "b": [0.6053, 0.3898, 0.625, 0.4112]}, {"w": "based", "b": [0.6303, 0.3898, 0.6775, 0.4112]}, {"w": "on", "b": [0.6829, 0.3898, 0.7049, 0.4112]}, {"w": "the", "b": [0.7102, 0.3898, 0.7365, 0.4112]}, {"w": "labels", "b": [0.7419, 0.3898, 0.7886, 0.4112]}, {"w": "and", "b": [0.794, 0.3898, 0.8255, 0.4112]}, {"w": "the", "b": [0.8308, 0.3898, 0.8572, 0.4112]}, {"w": "predictions", "b": [0.1429, 0.4089, 0.2374, 0.4303]}, {"w": "(and", "b": [0.2436, 0.4089, 0.2824, 0.4303]}, {"w": "optionally", "b": [0.2886, 0.4089, 0.3734, 0.4303]}, {"w": "sample", "b": [0.3796, 0.4089, 0.4381, 0.4303]}, {"w": "weights).", "b": [0.4444, 0.4089, 0.5195, 0.4303]}, {"w": "However,", "b": [0.5258, 0.4089, 0.6046, 0.4303]}, {"w": "you", "b": [0.6109, 0.4089, 0.6421, 0.4303]}, {"w": "will", "b": [0.6484, 0.4089, 0.6788, 0.4303]}, {"w": "occasionally", "b": [0.685, 0.4089, 0.7869, 0.4303]}, {"w": "want", "b": [0.7931, 0.4089, 0.8339, 0.4303]}, {"w": "to", "b": [0.8402, 0.4089, 0.8571, 0.4303]}, {"w": "define", "b": [0.1429, 0.4279, 0.1947, 0.4493]}, {"w": "losses", "b": [0.1998, 0.4279, 0.2474, 0.4493]}, {"w": "based", "b": [0.2525, 0.4279, 0.2997, 0.4493]}, {"w": "on", "b": [0.3048, 0.4279, 0.3268, 0.4493]}, {"w": "other", "b": [0.3318, 0.4279, 0.3765, 0.4493]}, {"w": "parts", "b": [0.3816, 0.4279, 0.4234, 0.4493]}, {"w": "of", "b": [0.4284, 0.4279, 0.4452, 0.4493]}, {"w": "your", "b": [0.4502, 0.4279, 0.4892, 0.4493]}, {"w": "model,", "b": [0.4943, 0.4279, 0.5518, 0.4493]}, {"w": "such", "b": [0.5569, 0.4279, 0.5955, 0.4493]}, {"w": "as", "b": [0.6006, 0.4279, 0.6174, 0.4493]}, {"w": "the", "b": [0.6224, 0.4279, 0.6487, 0.4493]}, {"w": "weights", "b": [0.6538, 0.4279, 0.717, 0.4493]}, {"w": "or", "b": [0.722, 0.4279, 0.7404, 0.4493]}, {"w": "activations", "b": [0.7454, 0.4279, 0.8353, 0.4493]}, {"w": "of", "b": [0.8403, 0.4279, 0.8571, 0.4493]}, {"w": "its", "b": [0.1429, 0.447, 0.1625, 0.4684]}, {"w": "hidden", "b": [0.1679, 0.447, 0.2269, 0.4684]}, {"w": "layers.", "b": [0.2323, 0.447, 0.2849, 0.4684]}, {"w": "This", "b": [0.2904, 0.447, 0.3276, 0.4684]}, {"w": "may", "b": [0.333, 0.447, 0.3684, 0.4684]}, {"w": "be", "b": [0.3739, 0.447, 0.3933, 0.4684]}, {"w": "useful", "b": [0.3988, 0.447, 0.4488, 0.4684]}, {"w": "for", "b": [0.4543, 0.447, 0.4788, 0.4684]}, {"w": "regularization", "b": [0.4843, 0.447, 0.6008, 0.4684]}, {"w": "purposes,", "b": [0.6063, 0.447, 0.6864, 0.4684]}, {"w": "or", "b": [0.6919, 0.447, 0.7102, 0.4684]}, {"w": "to", "b": [0.7157, 0.447, 0.7327, 0.4684]}, {"w": "monitor", "b": [0.7381, 0.447, 0.8075, 0.4684]}, {"w": "some", "b": [0.813, 0.447, 0.8572, 0.4684]}, {"w": "internal", "b": [0.1429, 0.466, 0.2082, 0.4874]}, {"w": "aspect", "b": [0.2129, 0.466, 0.2647, 0.4874]}, {"w": "of", "b": [0.2694, 0.466, 0.2862, 0.4874]}, {"w": "your", "b": [0.2909, 0.466, 0.3299, 0.4874]}, {"w": "model.", "b": [0.3346, 0.466, 0.3922, 0.4874]}]}, {"id": "b_4", "type": "paragraph", "text": "To define a custom loss based on model internals, just compute it based on any part of the model you want, then pass the result to the add_loss() method. For example, the following custom model represents a standard MLP regressor with 5 hidden lay‐ ers, except it also implements a reconstruction loss (see ???): we add an extra Dense layer on top of the last hidden layer, and its role is to try to reconstruct the inputs of the model. Since the reconstruction must have the same shape as the model’s inputs, we need to create this Dense layer in the build() method to have access to the shape of the inputs. In the call() method, we compute both the regular output of the MLP, plus the output of the reconstruction layer. We then compute the mean squared dif‐ ference between the reconstructions and the inputs, and we add this value (times 0.05) to the model’s list of losses by calling add_loss(). During training, Keras will add this loss to the main loss (which is why we scaled down the reconstruction loss, to ensure the main loss dominates). As a result, the model will be forced to preserve as much information as possible through the hidden layers, even information that is not directly useful for the regression task itself. In practice, this loss sometimes improves generalization; it is a regularization loss:", "words": [{"w": "To", "b": [0.1429, 0.4941, 0.1643, 0.5156]}, {"w": "define", "b": [0.1703, 0.4941, 0.2222, 0.5156]}, {"w": "a", "b": [0.2282, 0.4941, 0.2374, 0.5156]}, {"w": "custom", "b": [0.2434, 0.4941, 0.305, 0.5156]}, {"w": "loss", "b": [0.311, 0.4941, 0.3422, 0.5156]}, {"w": "based", "b": [0.3483, 0.4941, 0.3955, 0.5156]}, {"w": "on", "b": [0.4015, 0.4941, 0.4236, 0.5156]}, {"w": "model", "b": [0.4296, 0.4941, 0.4824, 0.5156]}, {"w": "internals,", "b": [0.4885, 0.4941, 0.5662, 0.5156]}, {"w": "just", "b": [0.5722, 0.4941, 0.6026, 0.5156]}, {"w": "compute", "b": [0.6087, 0.4941, 0.682, 0.5156]}, {"w": "it", "b": [0.688, 0.4941, 0.7, 0.5156]}, {"w": "based", "b": [0.706, 0.4941, 0.7532, 0.5156]}, {"w": "on", "b": [0.7593, 0.4941, 0.7813, 0.5156]}, {"w": "any", "b": [0.7873, 0.4941, 0.817, 0.5156]}, {"w": "part", "b": [0.823, 0.4941, 0.8571, 0.5156]}, {"w": "of", "b": [0.1429, 0.5141, 0.1596, 0.5355]}, {"w": "the", "b": [0.1654, 0.5141, 0.1917, 0.5355]}, {"w": "model", "b": [0.1974, 0.5141, 0.2502, 0.5355]}, {"w": "you", "b": [0.2559, 0.5141, 0.2872, 0.5355]}, {"w": "want,", "b": [0.2929, 0.5141, 0.3384, 0.5355]}, {"w": "then", "b": [0.3441, 0.5141, 0.3818, 0.5355]}, {"w": "pass", "b": [0.3876, 0.5141, 0.4229, 0.5355]}, {"w": "the", "b": [0.4286, 0.5141, 0.4549, 0.5355]}, {"w": "result", "b": [0.4607, 0.5141, 0.5076, 0.5355]}, {"w": "to", "b": [0.5133, 0.5141, 0.5303, 0.5355]}, {"w": "the", "b": [0.536, 0.5141, 0.5623, 0.5355]}, {"w": "add_loss()", "b": [0.568, 0.5173, 0.667, 0.5323]}, {"w": "method.", "b": [0.6727, 0.5141, 0.7425, 0.5355]}, {"w": "For", "b": [0.7482, 0.5141, 0.7771, 0.5355]}, {"w": "example,", "b": [0.7829, 0.5141, 0.8571, 0.5355]}, {"w": "the", "b": [0.1429, 0.5331, 0.1692, 0.5545]}, {"w": "following", "b": [0.1751, 0.5331, 0.2541, 0.5545]}, {"w": "custom", "b": [0.26, 0.5331, 0.3216, 0.5545]}, {"w": "model", "b": [0.3275, 0.5331, 0.3803, 0.5545]}, {"w": "represents", "b": [0.3862, 0.5331, 0.4718, 0.5545]}, {"w": "a", "b": [0.4777, 0.5331, 0.4869, 0.5545]}, {"w": "standard", "b": [0.4928, 0.5331, 0.5662, 0.5545]}, {"w": "MLP", "b": [0.5721, 0.5331, 0.6136, 0.5545]}, {"w": "regressor", "b": [0.6196, 0.5331, 0.6961, 0.5545]}, {"w": "with", "b": [0.702, 0.5331, 0.7394, 0.5545]}, {"w": "5", "b": [0.7453, 0.5331, 0.7553, 0.5545]}, {"w": "hidden", "b": [0.7612, 0.5331, 0.8202, 0.5545]}, {"w": "lay‐", "b": [0.8261, 0.5331, 0.8571, 0.5545]}, {"w": "ers,", "b": [0.1429, 0.5531, 0.1718, 0.5745]}, {"w": "except", "b": [0.179, 0.5531, 0.2326, 0.5745]}, {"w": "it", "b": [0.2398, 0.5531, 0.2517, 0.5745]}, {"w": "also", "b": [0.2589, 0.5531, 0.2916, 0.5745]}, {"w": "implements", "b": [0.2988, 0.5531, 0.397, 0.5745]}, {"w": "a", "b": [0.4041, 0.5531, 0.4133, 0.5745]}, {"w": "reconstruction", "b": [0.4205, 0.5529, 0.5367, 0.5745]}, {"w": "loss", "b": [0.544, 0.5529, 0.5726, 0.5745]}, {"w": "(see", "b": [0.5797, 0.5531, 0.6123, 0.5745]}, {"w": "???):", "b": [0.6195, 0.5531, 0.6551, 0.5745]}, {"w": "we", "b": [0.6623, 0.5531, 0.6854, 0.5745]}, {"w": "add", "b": [0.6926, 0.5531, 0.7237, 0.5745]}, {"w": "an", "b": [0.7309, 0.5531, 0.7514, 0.5745]}, {"w": "extra", "b": [0.7586, 0.5531, 0.8005, 0.5745]}, {"w": "Dense", "b": [0.8077, 0.5563, 0.8572, 0.5713]}, {"w": "layer", "b": [0.1429, 0.5721, 0.183, 0.5935]}, {"w": "on", "b": [0.1888, 0.5721, 0.2108, 0.5935]}, {"w": "top", "b": [0.2166, 0.5721, 0.2445, 0.5935]}, {"w": "of", "b": [0.2503, 0.5721, 0.2671, 0.5935]}, {"w": "the", "b": [0.2729, 0.5721, 0.2992, 0.5935]}, {"w": "last", "b": [0.305, 0.5721, 0.3334, 0.5935]}, {"w": "hidden", "b": [0.3392, 0.5721, 0.3981, 0.5935]}, {"w": "layer,", "b": [0.4039, 0.5721, 0.4475, 0.5935]}, {"w": "and", "b": [0.4533, 0.5721, 0.4848, 0.5935]}, {"w": "its", "b": [0.4906, 0.5721, 0.5102, 0.5935]}, {"w": "role", "b": [0.516, 0.5721, 0.5484, 0.5935]}, {"w": "is", "b": [0.5542, 0.5721, 0.5674, 0.5935]}, {"w": "to", "b": [0.5732, 0.5721, 0.5902, 0.5935]}, {"w": "try", "b": [0.596, 0.5721, 0.6202, 0.5935]}, {"w": "to", "b": [0.626, 0.5721, 0.643, 0.5935]}, {"w": "reconstruct", "b": [0.6488, 0.5721, 0.7441, 0.5935]}, {"w": "the", "b": [0.7499, 0.5721, 0.7762, 0.5935]}, {"w": "inputs", "b": [0.782, 0.5721, 0.8346, 0.5935]}, {"w": "of", "b": [0.8404, 0.5721, 0.8571, 0.5935]}, {"w": "the", "b": [0.1429, 0.5912, 0.1692, 0.6126]}, {"w": "model.", "b": [0.1751, 0.5912, 0.2327, 0.6126]}, {"w": "Since", "b": [0.2386, 0.5912, 0.2831, 0.6126]}, {"w": "the", "b": [0.2891, 0.5912, 0.3154, 0.6126]}, {"w": "reconstruction", "b": [0.3213, 0.5912, 0.4443, 0.6126]}, {"w": "must", "b": [0.4502, 0.5912, 0.492, 0.6126]}, {"w": "have", "b": [0.4979, 0.5912, 0.5363, 0.6126]}, {"w": "the", "b": [0.5422, 0.5912, 0.5685, 0.6126]}, {"w": "same", "b": [0.5745, 0.5912, 0.6172, 0.6126]}, {"w": "shape", "b": [0.6231, 0.5912, 0.6704, 0.6126]}, {"w": "as", "b": [0.6763, 0.5912, 0.6931, 0.6126]}, {"w": "the", "b": [0.6991, 0.5912, 0.7254, 0.6126]}, {"w": "model’s", "b": [0.7313, 0.5912, 0.7939, 0.6126]}, {"w": "inputs,", "b": [0.7998, 0.5912, 0.8571, 0.6126]}, {"w": "we", "b": [0.1429, 0.6111, 0.166, 0.6325]}, {"w": "need", "b": [0.1716, 0.6111, 0.2117, 0.6325]}, {"w": "to", "b": [0.2173, 0.6111, 0.2343, 0.6325]}, {"w": "create", "b": [0.2399, 0.6111, 0.2893, 0.6325]}, {"w": "this", "b": [0.2949, 0.6111, 0.3256, 0.6325]}, {"w": "Dense", "b": [0.3312, 0.6143, 0.3807, 0.6294]}, {"w": "layer", "b": [0.3863, 0.6111, 0.4265, 0.6325]}, {"w": "in", "b": [0.4321, 0.6111, 0.4491, 0.6325]}, {"w": "the", "b": [0.4547, 0.6111, 0.481, 0.6325]}, {"w": "build()", "b": [0.4866, 0.6143, 0.5559, 0.6294]}, {"w": "method", "b": [0.5615, 0.6111, 0.6265, 0.6325]}, {"w": "to", "b": [0.6322, 0.6111, 0.6491, 0.6325]}, {"w": "have", "b": [0.6548, 0.6111, 0.6932, 0.6325]}, {"w": "access", "b": [0.6988, 0.6111, 0.7497, 0.6325]}, {"w": "to", "b": [0.7553, 0.6111, 0.7723, 0.6325]}, {"w": "the", "b": [0.7779, 0.6111, 0.8042, 0.6325]}, {"w": "shape", "b": [0.8098, 0.6111, 0.8571, 0.6325]}, {"w": "of", "b": [0.1429, 0.6311, 0.1597, 0.6525]}, {"w": "the", "b": [0.1647, 0.6311, 0.1911, 0.6525]}, {"w": "inputs.", "b": [0.1961, 0.6311, 0.2534, 0.6525]}, {"w": "In", "b": [0.2585, 0.6311, 0.277, 0.6525]}, {"w": "the", "b": [0.2821, 0.6311, 0.3084, 0.6525]}, {"w": "call()", "b": [0.3135, 0.6342, 0.3729, 0.6493]}, {"w": "method,", "b": [0.3779, 0.6311, 0.4477, 0.6525]}, {"w": "we", "b": [0.4528, 0.6311, 0.4759, 0.6525]}, {"w": "compute", "b": [0.481, 0.6311, 0.5542, 0.6525]}, {"w": "both", "b": [0.5593, 0.6311, 0.598, 0.6525]}, {"w": "the", "b": [0.6031, 0.6311, 0.6294, 0.6525]}, {"w": "regular", "b": [0.6345, 0.6311, 0.694, 0.6525]}, {"w": "output", "b": [0.6991, 0.6311, 0.7555, 0.6525]}, {"w": "of", "b": [0.7605, 0.6311, 0.7773, 0.6525]}, {"w": "the", "b": [0.7824, 0.6311, 0.8087, 0.6525]}, {"w": "MLP,", "b": [0.8138, 0.6311, 0.8571, 0.6525]}, {"w": "plus", "b": [0.1429, 0.6501, 0.1777, 0.6715]}, {"w": "the", "b": [0.1839, 0.6501, 0.2102, 0.6715]}, {"w": "output", "b": [0.2164, 0.6501, 0.2727, 0.6715]}, {"w": "of", "b": [0.2789, 0.6501, 0.2957, 0.6715]}, {"w": "the", "b": [0.3018, 0.6501, 0.3281, 0.6715]}, {"w": "reconstruction", "b": [0.3343, 0.6501, 0.4573, 0.6715]}, {"w": "layer.", "b": [0.4634, 0.6501, 0.507, 0.6715]}, {"w": "We", "b": [0.5132, 0.6501, 0.5402, 0.6715]}, {"w": "then", "b": [0.5464, 0.6501, 0.5841, 0.6715]}, {"w": "compute", "b": [0.5902, 0.6501, 0.6635, 0.6715]}, {"w": "the", "b": [0.6697, 0.6501, 0.696, 0.6715]}, {"w": "mean", "b": [0.7021, 0.6501, 0.7486, 0.6715]}, {"w": "squared", "b": [0.7547, 0.6501, 0.8208, 0.6715]}, {"w": "dif‐", "b": [0.827, 0.6501, 0.8571, 0.6715]}, {"w": "ference", "b": [0.1429, 0.6692, 0.2035, 0.6906]}, {"w": "between", "b": [0.2118, 0.6692, 0.281, 0.6906]}, {"w": "the", "b": [0.2892, 0.6692, 0.3156, 0.6906]}, {"w": "reconstructions", "b": [0.3238, 0.6692, 0.4544, 0.6906]}, {"w": "and", "b": [0.4627, 0.6692, 0.4942, 0.6906]}, {"w": "the", "b": [0.5025, 0.6692, 0.5288, 0.6906]}, {"w": "inputs,", "b": [0.5371, 0.6692, 0.5944, 0.6906]}, {"w": "and", "b": [0.6027, 0.6692, 0.6342, 0.6906]}, {"w": "we", "b": [0.6425, 0.6692, 0.6656, 0.6906]}, {"w": "add", "b": [0.6738, 0.6692, 0.705, 0.6906]}, {"w": "this", "b": [0.7132, 0.6692, 0.7439, 0.6906]}, {"w": "value", "b": [0.7522, 0.6692, 0.7962, 0.6906]}, {"w": "(times", "b": [0.8044, 0.6692, 0.8572, 0.6906]}, {"w": "0.05)", "b": [0.1429, 0.6891, 0.1848, 0.7105]}, {"w": "to", "b": [0.1916, 0.6891, 0.2086, 0.7105]}, {"w": "the", "b": [0.2154, 0.6891, 0.2417, 0.7105]}, {"w": "model’s", "b": [0.2485, 0.6891, 0.3111, 0.7105]}, {"w": "list", "b": [0.3179, 0.6891, 0.3427, 0.7105]}, {"w": "of", "b": [0.3495, 0.6891, 0.3663, 0.7105]}, {"w": "losses", "b": [0.3731, 0.6891, 0.4208, 0.7105]}, {"w": "by", "b": [0.4275, 0.6891, 0.4477, 0.7105]}, {"w": "calling", "b": [0.4545, 0.6891, 0.5097, 0.7105]}, {"w": "add_loss().", "b": [0.5165, 0.6891, 0.6202, 0.7105]}, {"w": "During", "b": [0.627, 0.6891, 0.6878, 0.7105]}, {"w": "training,", "b": [0.6946, 0.6891, 0.7663, 0.7105]}, {"w": "Keras", "b": [0.7731, 0.6891, 0.82, 0.7105]}, {"w": "will", "b": [0.8268, 0.6891, 0.8571, 0.7105]}, {"w": "add", "b": [0.1429, 0.7081, 0.174, 0.7296]}, {"w": "this", "b": [0.1801, 0.7081, 0.2108, 0.7296]}, {"w": "loss", "b": [0.2169, 0.7081, 0.2481, 0.7296]}, {"w": "to", "b": [0.2542, 0.7081, 0.2711, 0.7296]}, {"w": "the", "b": [0.2772, 0.7081, 0.3036, 0.7296]}, {"w": "main", "b": [0.3097, 0.7081, 0.3528, 0.7296]}, {"w": "loss", "b": [0.3589, 0.7081, 0.3901, 0.7296]}, {"w": "(which", "b": [0.3962, 0.7081, 0.4543, 0.7296]}, {"w": "is", "b": [0.4604, 0.7081, 0.4736, 0.7296]}, {"w": "why", "b": [0.4797, 0.7081, 0.5142, 0.7296]}, {"w": "we", "b": [0.5203, 0.7081, 0.5434, 0.7296]}, {"w": "scaled", "b": [0.5495, 0.7081, 0.6002, 0.7296]}, {"w": "down", "b": [0.6063, 0.7081, 0.6536, 0.7296]}, {"w": "the", "b": [0.6597, 0.7081, 0.686, 0.7296]}, {"w": "reconstruction", "b": [0.6921, 0.7081, 0.8151, 0.7296]}, {"w": "loss,", "b": [0.8212, 0.7081, 0.8571, 0.7296]}, {"w": "to", "b": [0.1428, 0.7272, 0.1598, 0.7486]}, {"w": "ensure", "b": [0.1658, 0.7272, 0.2213, 0.7486]}, {"w": "the", "b": [0.2272, 0.7272, 0.2536, 0.7486]}, {"w": "main", "b": [0.2595, 0.7272, 0.3027, 0.7486]}, {"w": "loss", "b": [0.3086, 0.7272, 0.3398, 0.7486]}, {"w": "dominates).", "b": [0.3457, 0.7272, 0.445, 0.7486]}, {"w": "As", "b": [0.4509, 0.7272, 0.4729, 0.7486]}, {"w": "a", "b": [0.4789, 0.7272, 0.488, 0.7486]}, {"w": "result,", "b": [0.494, 0.7272, 0.5456, 0.7486]}, {"w": "the", "b": [0.5516, 0.7272, 0.5779, 0.7486]}, {"w": "model", "b": [0.5838, 0.7272, 0.6366, 0.7486]}, {"w": "will", "b": [0.6426, 0.7272, 0.673, 0.7486]}, {"w": "be", "b": [0.6789, 0.7272, 0.6983, 0.7486]}, {"w": "forced", "b": [0.7043, 0.7272, 0.7575, 0.7486]}, {"w": "to", "b": [0.7634, 0.7272, 0.7804, 0.7486]}, {"w": "preserve", "b": [0.7863, 0.7272, 0.8571, 0.7486]}, {"w": "as", "b": [0.1429, 0.7462, 0.1597, 0.7677]}, {"w": "much", "b": [0.1658, 0.7462, 0.2134, 0.7677]}, {"w": "information", "b": [0.2195, 0.7462, 0.3208, 0.7677]}, {"w": "as", "b": [0.3269, 0.7462, 0.3437, 0.7677]}, {"w": "possible", "b": [0.3498, 0.7462, 0.4169, 0.7677]}, {"w": "through", "b": [0.423, 0.7462, 0.4908, 0.7677]}, {"w": "the", "b": [0.4969, 0.7462, 0.5232, 0.7677]}, {"w": "hidden", "b": [0.5293, 0.7462, 0.5883, 0.7677]}, {"w": "layers,", "b": [0.5943, 0.7462, 0.6469, 0.7677]}, {"w": "even", "b": [0.653, 0.7462, 0.6918, 0.7677]}, {"w": "information", "b": [0.6979, 0.7462, 0.7991, 0.7677]}, {"w": "that", "b": [0.8052, 0.7462, 0.8378, 0.7677]}, {"w": "is", "b": [0.8439, 0.7462, 0.8572, 0.7677]}, {"w": "not", "b": [0.1429, 0.7653, 0.1712, 0.7867]}, {"w": "directly", "b": [0.181, 0.7653, 0.2441, 0.7867]}, {"w": "useful", "b": [0.2539, 0.7653, 0.3039, 0.7867]}, {"w": "for", "b": [0.3137, 0.7653, 0.3382, 0.7867]}, {"w": "the", "b": [0.3479, 0.7653, 0.3743, 0.7867]}, {"w": "regression", "b": [0.384, 0.7653, 0.4698, 0.7867]}, {"w": "task", "b": [0.4796, 0.7653, 0.513, 0.7867]}, {"w": "itself.", "b": [0.5228, 0.7653, 0.5674, 0.7867]}, {"w": "In", "b": [0.5771, 0.7653, 0.5956, 0.7867]}, {"w": "practice,", "b": [0.6054, 0.7653, 0.6763, 0.7867]}, {"w": "this", "b": [0.6861, 0.7653, 0.7168, 0.7867]}, {"w": "loss", "b": [0.7265, 0.7653, 0.7577, 0.7867]}, {"w": "sometimes", "b": [0.7675, 0.7653, 0.8571, 0.7867]}, {"w": "improves", "b": [0.1429, 0.7843, 0.2205, 0.8058]}, {"w": "generalization;", "b": [0.2252, 0.7843, 0.348, 0.8058]}, {"w": "it", "b": [0.3528, 0.7843, 0.3647, 0.8058]}, {"w": "is", "b": [0.3694, 0.7843, 0.3827, 0.8058]}, {"w": "a", "b": [0.3874, 0.7843, 0.3965, 0.8058]}, {"w": "regularization", "b": [0.4013, 0.7843, 0.5179, 0.8058]}, {"w": "loss:", "b": [0.5226, 0.7843, 0.5585, 0.8058]}]}, {"id": "b_5", "type": "paragraph", "text": "class ReconstructingRegressor(keras.models.Model): def __init__(self, output_dim, **kwargs): super().__init__(**kwargs) self.hidden = [keras.layers.Dense(30, activation=\"selu\", kernel_initializer=\"lecun_normal\")", "words": [{"w": "class", "b": [0.1766, 0.8163, 0.2188, 0.8292]}, {"w": "ReconstructingRegressor(keras.models.Model):", "b": [0.2272, 0.8163, 0.5982, 0.8292]}, {"w": "def", "b": [0.2103, 0.8317, 0.2356, 0.8446]}, {"w": "__init__(self,", "b": [0.2441, 0.8317, 0.3621, 0.8446]}, {"w": "output_dim,", "b": [0.3705, 0.8317, 0.4633, 0.8446]}, {"w": "**kwargs):", "b": [0.4717, 0.8317, 0.5561, 0.8446]}, {"w": "super().__init__(**kwargs)", "b": [0.2441, 0.8472, 0.4633, 0.86]}, {"w": "self.hidden", "b": [0.2441, 0.8626, 0.3368, 0.8754]}, {"w": "=", "b": [0.3452, 0.8626, 0.3537, 0.8754]}, {"w": "[keras.layers.Dense(30,", "b": [0.3621, 0.8626, 0.5561, 0.8754]}, {"w": "activation=\"selu\",", "b": [0.5645, 0.8626, 0.7163, 0.8754]}, {"w": "kernel_initializer=\"lecun_normal\")", "b": [0.5308, 0.878, 0.8175, 0.8908]}]}, {"id": "b_6", "type": "paragraph", "text": "388 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "388", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2746, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 415, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "for _ in range(5)] self.out = keras.layers.Dense(output_dim)", "words": [{"w": "for", "b": [0.3705, 0.0829, 0.3958, 0.0958]}, {"w": "_", "b": [0.4043, 0.0829, 0.4127, 0.0958]}, {"w": "in", "b": [0.4211, 0.0829, 0.438, 0.0958]}, {"w": "range(5)]", "b": [0.4464, 0.0829, 0.5223, 0.0958]}, {"w": "self.out", "b": [0.244, 0.0983, 0.3115, 0.1112]}, {"w": "=", "b": [0.3199, 0.0983, 0.3284, 0.1112]}, {"w": "keras.layers.Dense(output_dim)", "b": [0.3368, 0.0983, 0.5898, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "def build(self, batch_input_shape): n_inputs = batch_input_shape[-1] self.reconstruct = keras.layers.Dense(n_inputs) super().build(batch_input_shape)", "words": [{"w": "def", "b": [0.2103, 0.1292, 0.2356, 0.142]}, {"w": "build(self,", "b": [0.244, 0.1292, 0.3368, 0.142]}, {"w": "batch_input_shape):", "b": [0.3452, 0.1292, 0.5055, 0.142]}, {"w": "n_inputs", "b": [0.244, 0.1446, 0.3115, 0.1574]}, {"w": "=", "b": [0.3199, 0.1446, 0.3284, 0.1574]}, {"w": "batch_input_shape[-1]", "b": [0.3368, 0.1446, 0.5139, 0.1574]}, {"w": "self.reconstruct", "b": [0.244, 0.16, 0.379, 0.1729]}, {"w": "=", "b": [0.3874, 0.16, 0.3958, 0.1729]}, {"w": "keras.layers.Dense(n_inputs)", "b": [0.4043, 0.16, 0.6404, 0.1729]}, {"w": "super().build(batch_input_shape)", "b": [0.244, 0.1754, 0.5139, 0.1883]}]}, {"id": "b_2", "type": "paragraph", "text": "def call(self, inputs): Z = inputs for layer in self.hidden: Z = layer(Z) reconstruction = self.reconstruct(Z) recon_loss = tf.reduce_mean(tf.square(reconstruction - inputs)) self.add_loss(0.05 * recon_loss) return self.out(Z)", "words": [{"w": "def", "b": [0.2103, 0.2063, 0.2356, 0.2191]}, {"w": "call(self,", "b": [0.244, 0.2063, 0.3284, 0.2191]}, {"w": "inputs):", "b": [0.3368, 0.2063, 0.4043, 0.2191]}, {"w": "Z", "b": [0.244, 0.2217, 0.2525, 0.2345]}, {"w": "=", "b": [0.2609, 0.2217, 0.2693, 0.2345]}, {"w": "inputs", "b": [0.2778, 0.2217, 0.3284, 0.2345]}, {"w": "for", "b": [0.244, 0.2371, 0.2693, 0.25]}, {"w": "layer", "b": [0.2778, 0.2371, 0.3199, 0.25]}, {"w": "in", "b": [0.3284, 0.2371, 0.3452, 0.25]}, {"w": "self.hidden:", "b": [0.3537, 0.2371, 0.4549, 0.25]}, {"w": "Z", "b": [0.2778, 0.2525, 0.2862, 0.2654]}, {"w": "=", "b": [0.2946, 0.2525, 0.3031, 0.2654]}, {"w": "layer(Z)", "b": [0.3115, 0.2525, 0.379, 0.2654]}, {"w": "reconstruction", "b": [0.244, 0.268, 0.3621, 0.2808]}, {"w": "=", "b": [0.3705, 0.268, 0.379, 0.2808]}, {"w": "self.reconstruct(Z)", "b": [0.3874, 0.268, 0.5476, 0.2808]}, {"w": "recon_loss", "b": [0.244, 0.2834, 0.3284, 0.2962]}, {"w": "=", "b": [0.3368, 0.2834, 0.3452, 0.2962]}, {"w": "tf.reduce_mean(tf.square(reconstruction", "b": [0.3537, 0.2834, 0.6825, 0.2962]}, {"w": "-", "b": [0.691, 0.2834, 0.6994, 0.2962]}, {"w": "inputs))", "b": [0.7078, 0.2834, 0.7753, 0.2962]}, {"w": "self.add_loss(0.05", "b": [0.244, 0.2988, 0.3958, 0.3116]}, {"w": "*", "b": [0.4043, 0.2988, 0.4127, 0.3116]}, {"w": "recon_loss)", "b": [0.4211, 0.2988, 0.5139, 0.3116]}, {"w": "return", "b": [0.244, 0.3142, 0.2946, 0.3271]}, {"w": "self.out(Z)", "b": [0.3031, 0.3142, 0.3958, 0.3271]}]}, {"id": "b_3", "type": "paragraph", "text": "Similarly, you can add a custom metric based on model internals by computing it in any way you want, as long at the result is the output of a metric object. For example, you can create a keras.metrics.Mean() object in the constructor, then call it in the call() method, passing it the recon_loss, and finally add it to the model by calling the model’s add_metric() method. This way, when you train the model, Keras will display both the mean loss over each epoch (the loss is the sum of the main loss plus 0.05 times the reconstruction loss) and the mean reconstruction error over each epoch. Both will go down during training:", "words": [{"w": "Similarly,", "b": [0.1429, 0.3348, 0.2212, 0.3563]}, {"w": "you", "b": [0.2272, 0.3348, 0.2584, 0.3563]}, {"w": "can", "b": [0.2644, 0.3348, 0.2937, 0.3563]}, {"w": "add", "b": [0.2997, 0.3348, 0.3309, 0.3563]}, {"w": "a", "b": [0.3369, 0.3348, 0.346, 0.3563]}, {"w": "custom", "b": [0.352, 0.3348, 0.4136, 0.3563]}, {"w": "metric", "b": [0.4196, 0.3348, 0.474, 0.3563]}, {"w": "based", "b": [0.4799, 0.3348, 0.5272, 0.3563]}, {"w": "on", "b": [0.5332, 0.3348, 0.5552, 0.3563]}, {"w": "model", "b": [0.5612, 0.3348, 0.614, 0.3563]}, {"w": "internals", "b": [0.62, 0.3348, 0.693, 0.3563]}, {"w": "by", "b": [0.6989, 0.3348, 0.7191, 0.3563]}, {"w": "computing", "b": [0.7251, 0.3348, 0.8162, 0.3563]}, {"w": "it", "b": [0.8222, 0.3348, 0.8342, 0.3563]}, {"w": "in", "b": [0.8402, 0.3348, 0.8571, 0.3563]}, {"w": "any", "b": [0.1428, 0.3539, 0.1725, 0.3753]}, {"w": "way", "b": [0.1783, 0.3539, 0.2109, 0.3753]}, {"w": "you", "b": [0.2166, 0.3539, 0.2479, 0.3753]}, {"w": "want,", "b": [0.2537, 0.3539, 0.2992, 0.3753]}, {"w": "as", "b": [0.305, 0.3539, 0.3218, 0.3753]}, {"w": "long", "b": [0.3275, 0.3539, 0.3646, 0.3753]}, {"w": "at", "b": [0.3704, 0.3539, 0.3855, 0.3753]}, {"w": "the", "b": [0.3912, 0.3539, 0.4176, 0.3753]}, {"w": "result", "b": [0.4234, 0.3539, 0.4703, 0.3753]}, {"w": "is", "b": [0.476, 0.3539, 0.4893, 0.3753]}, {"w": "the", "b": [0.4951, 0.3539, 0.5214, 0.3753]}, {"w": "output", "b": [0.5272, 0.3539, 0.5835, 0.3753]}, {"w": "of", "b": [0.5893, 0.3539, 0.6061, 0.3753]}, {"w": "a", "b": [0.6119, 0.3539, 0.621, 0.3753]}, {"w": "metric", "b": [0.6268, 0.3539, 0.6812, 0.3753]}, {"w": "object.", "b": [0.687, 0.3539, 0.7423, 0.3753]}, {"w": "For", "b": [0.7481, 0.3539, 0.7771, 0.3753]}, {"w": "example,", "b": [0.7828, 0.3539, 0.8571, 0.3753]}, {"w": "you", "b": [0.1429, 0.3738, 0.1741, 0.3952]}, {"w": "can", "b": [0.1804, 0.3738, 0.2097, 0.3952]}, {"w": "create", "b": [0.216, 0.3738, 0.2653, 0.3952]}, {"w": "a", "b": [0.2716, 0.3738, 0.2807, 0.3952]}, {"w": "keras.metrics.Mean()", "b": [0.287, 0.377, 0.4849, 0.3921]}, {"w": "object", "b": [0.4912, 0.3738, 0.5417, 0.3952]}, {"w": "in", "b": [0.548, 0.3738, 0.565, 0.3952]}, {"w": "the", "b": [0.5712, 0.3738, 0.5975, 0.3952]}, {"w": "constructor,", "b": [0.6038, 0.3738, 0.7044, 0.3952]}, {"w": "then", "b": [0.7106, 0.3738, 0.7484, 0.3952]}, {"w": "call", "b": [0.7546, 0.3738, 0.7831, 0.3952]}, {"w": "it", "b": [0.7894, 0.3738, 0.8013, 0.3952]}, {"w": "in", "b": [0.8076, 0.3738, 0.8246, 0.3952]}, {"w": "the", "b": [0.8308, 0.3738, 0.8571, 0.3952]}, {"w": "call()", "b": [0.1428, 0.397, 0.2022, 0.412]}, {"w": "method,", "b": [0.2081, 0.3938, 0.2779, 0.4152]}, {"w": "passing", "b": [0.2838, 0.3938, 0.3459, 0.4152]}, {"w": "it", "b": [0.3518, 0.3938, 0.3637, 0.4152]}, {"w": "the", "b": [0.3696, 0.3938, 0.3959, 0.4152]}, {"w": "recon_loss,", "b": [0.4018, 0.3938, 0.5055, 0.4152]}, {"w": "and", "b": [0.5114, 0.3938, 0.543, 0.4152]}, {"w": "finally", "b": [0.5489, 0.3938, 0.6013, 0.4152]}, {"w": "add", "b": [0.6072, 0.3938, 0.6383, 0.4152]}, {"w": "it", "b": [0.6442, 0.3938, 0.6561, 0.4152]}, {"w": "to", "b": [0.662, 0.3938, 0.679, 0.4152]}, {"w": "the", "b": [0.6849, 0.3938, 0.7113, 0.4152]}, {"w": "model", "b": [0.7172, 0.3938, 0.77, 0.4152]}, {"w": "by", "b": [0.7759, 0.3938, 0.796, 0.4152]}, {"w": "calling", "b": [0.8019, 0.3938, 0.8571, 0.4152]}, {"w": "the", "b": [0.1429, 0.4137, 0.1692, 0.4351]}, {"w": "model’s", "b": [0.1763, 0.4137, 0.2389, 0.4351]}, {"w": "add_metric()", "b": [0.246, 0.4169, 0.3648, 0.432]}, {"w": "method.", "b": [0.3719, 0.4137, 0.4417, 0.4351]}, {"w": "This", "b": [0.4488, 0.4137, 0.486, 0.4351]}, {"w": "way,", "b": [0.4931, 0.4137, 0.529, 0.4351]}, {"w": "when", "b": [0.5361, 0.4137, 0.5817, 0.4351]}, {"w": "you", "b": [0.5889, 0.4137, 0.6201, 0.4351]}, {"w": "train", "b": [0.6272, 0.4137, 0.6675, 0.4351]}, {"w": "the", "b": [0.6746, 0.4137, 0.7009, 0.4351]}, {"w": "model,", "b": [0.708, 0.4137, 0.7656, 0.4351]}, {"w": "Keras", "b": [0.7727, 0.4137, 0.8196, 0.4351]}, {"w": "will", "b": [0.8268, 0.4137, 0.8571, 0.4351]}, {"w": "display", "b": [0.1429, 0.4328, 0.2016, 0.4542]}, {"w": "both", "b": [0.2072, 0.4328, 0.2459, 0.4542]}, {"w": "the", "b": [0.2515, 0.4328, 0.2778, 0.4542]}, {"w": "mean", "b": [0.2834, 0.4328, 0.3299, 0.4542]}, {"w": "loss", "b": [0.3355, 0.4328, 0.3667, 0.4542]}, {"w": "over", "b": [0.3723, 0.4328, 0.4092, 0.4542]}, {"w": "each", "b": [0.4148, 0.4328, 0.4527, 0.4542]}, {"w": "epoch", "b": [0.4583, 0.4328, 0.5086, 0.4542]}, {"w": "(the", "b": [0.5142, 0.4328, 0.5478, 0.4542]}, {"w": "loss", "b": [0.5534, 0.4328, 0.5846, 0.4542]}, {"w": "is", "b": [0.5902, 0.4328, 0.6034, 0.4542]}, {"w": "the", "b": [0.609, 0.4328, 0.6353, 0.4542]}, {"w": "sum", "b": [0.6409, 0.4328, 0.6767, 0.4542]}, {"w": "of", "b": [0.6823, 0.4328, 0.6991, 0.4542]}, {"w": "the", "b": [0.7047, 0.4328, 0.7311, 0.4542]}, {"w": "main", "b": [0.7367, 0.4328, 0.7798, 0.4542]}, {"w": "loss", "b": [0.7855, 0.4328, 0.8166, 0.4542]}, {"w": "plus", "b": [0.8222, 0.4328, 0.8571, 0.4542]}, {"w": "0.05", "b": [0.1428, 0.4518, 0.1776, 0.4732]}, {"w": "times", "b": [0.1868, 0.4518, 0.2323, 0.4732]}, {"w": "the", "b": [0.2416, 0.4518, 0.2679, 0.4732]}, {"w": "reconstruction", "b": [0.2771, 0.4518, 0.4001, 0.4732]}, {"w": "loss)", "b": [0.4093, 0.4518, 0.4477, 0.4732]}, {"w": "and", "b": [0.457, 0.4518, 0.4885, 0.4732]}, {"w": "the", "b": [0.4977, 0.4518, 0.5241, 0.4732]}, {"w": "mean", "b": [0.5333, 0.4518, 0.5798, 0.4732]}, {"w": "reconstruction", "b": [0.589, 0.4518, 0.712, 0.4732]}, {"w": "error", "b": [0.7212, 0.4518, 0.7639, 0.4732]}, {"w": "over", "b": [0.7731, 0.4518, 0.81, 0.4732]}, {"w": "each", "b": [0.8192, 0.4518, 0.8571, 0.4732]}, {"w": "epoch.", "b": [0.1429, 0.4709, 0.1979, 0.4923]}, {"w": "Both", "b": [0.2027, 0.4709, 0.2434, 0.4923]}, {"w": "will", "b": [0.2482, 0.4709, 0.2786, 0.4923]}, {"w": "go", "b": [0.2833, 0.4709, 0.3037, 0.4923]}, {"w": "down", "b": [0.3084, 0.4709, 0.3557, 0.4923]}, {"w": "during", "b": [0.3604, 0.4709, 0.4169, 0.4923]}, {"w": "training:", "b": [0.4217, 0.4709, 0.4934, 0.4923]}]}, {"id": "b_4", "type": "paragraph", "text": "Epoch 1/5 11610/11610 [=============] [...] loss: 4.3092 - reconstruction_error: 1.7360 Epoch 2/5 11610/11610 [=============] [...] loss: 1.1232 - reconstruction_error: 0.8964 [...]", "words": [{"w": "Epoch", "b": [0.1766, 0.5028, 0.2188, 0.5157]}, {"w": "1/5", "b": [0.2272, 0.5028, 0.2525, 0.5157]}, {"w": "11610/11610", "b": [0.1766, 0.5183, 0.2693, 0.5311]}, {"w": "[=============]", "b": [0.2778, 0.5183, 0.4043, 0.5311]}, {"w": "[...]", "b": [0.4127, 0.5183, 0.4549, 0.5311]}, {"w": "loss:", "b": [0.4633, 0.5183, 0.5055, 0.5311]}, {"w": "4.3092", "b": [0.5139, 0.5183, 0.5645, 0.5311]}, {"w": "-", "b": [0.5729, 0.5183, 0.5813, 0.5311]}, {"w": "reconstruction_error:", "b": [0.5898, 0.5183, 0.7669, 0.5311]}, {"w": "1.7360", "b": [0.7753, 0.5183, 0.8259, 0.5311]}, {"w": "Epoch", "b": [0.1766, 0.5337, 0.2188, 0.5465]}, {"w": "2/5", "b": [0.2272, 0.5337, 0.2525, 0.5465]}, {"w": "11610/11610", "b": [0.1766, 0.5491, 0.2693, 0.562]}, {"w": "[=============]", "b": [0.2778, 0.5491, 0.4043, 0.562]}, {"w": "[...]", "b": [0.4127, 0.5491, 0.4549, 0.562]}, {"w": "loss:", "b": [0.4633, 0.5491, 0.5055, 0.562]}, {"w": "1.1232", "b": [0.5139, 0.5491, 0.5645, 0.562]}, {"w": "-", "b": [0.5729, 0.5491, 0.5813, 0.562]}, {"w": "reconstruction_error:", "b": [0.5898, 0.5491, 0.7669, 0.562]}, {"w": "0.8964", "b": [0.7753, 0.5491, 0.8259, 0.562]}, {"w": "[...]", "b": [0.1766, 0.5645, 0.2188, 0.5774]}]}, {"id": "b_5", "type": "paragraph", "text": "In over 99% of the cases, everything we have discussed so far will be sufficient to implement whatever model you want to build, even with complex architectures, los‐ ses, metrics, and so on. However, in some rare cases you may need to customize the training loop itself. However, before we get there, we need to look at how to compute gradients automatically in TensorFlow.", "words": [{"w": "In", "b": [0.1429, 0.5852, 0.1614, 0.6066]}, {"w": "over", "b": [0.1692, 0.5852, 0.2061, 0.6066]}, {"w": "99%", "b": [0.2139, 0.5852, 0.2496, 0.6066]}, {"w": "of", "b": [0.2575, 0.5852, 0.2743, 0.6066]}, {"w": "the", "b": [0.2821, 0.5852, 0.3084, 0.6066]}, {"w": "cases,", "b": [0.3163, 0.5852, 0.3631, 0.6066]}, {"w": "everything", "b": [0.371, 0.5852, 0.4604, 0.6066]}, {"w": "we", "b": [0.4683, 0.5852, 0.4914, 0.6066]}, {"w": "have", "b": [0.4993, 0.5852, 0.5376, 0.6066]}, {"w": "discussed", "b": [0.5455, 0.5852, 0.6247, 0.6066]}, {"w": "so", "b": [0.6326, 0.5852, 0.6509, 0.6066]}, {"w": "far", "b": [0.6587, 0.5852, 0.6817, 0.6066]}, {"w": "will", "b": [0.6896, 0.5852, 0.72, 0.6066]}, {"w": "be", "b": [0.7278, 0.5852, 0.7472, 0.6066]}, {"w": "sufficient", "b": [0.7551, 0.5852, 0.8323, 0.6066]}, {"w": "to", "b": [0.8402, 0.5852, 0.8571, 0.6066]}, {"w": "implement", "b": [0.1428, 0.6042, 0.2334, 0.6256]}, {"w": "whatever", "b": [0.2395, 0.6042, 0.3151, 0.6256]}, {"w": "model", "b": [0.3212, 0.6042, 0.374, 0.6256]}, {"w": "you", "b": [0.3801, 0.6042, 0.4114, 0.6256]}, {"w": "want", "b": [0.4175, 0.6042, 0.4583, 0.6256]}, {"w": "to", "b": [0.4644, 0.6042, 0.4814, 0.6256]}, {"w": "build,", "b": [0.4875, 0.6042, 0.5357, 0.6256]}, {"w": "even", "b": [0.5418, 0.6042, 0.5806, 0.6256]}, {"w": "with", "b": [0.5867, 0.6042, 0.624, 0.6256]}, {"w": "complex", "b": [0.6302, 0.6042, 0.7011, 0.6256]}, {"w": "architectures,", "b": [0.7073, 0.6042, 0.8201, 0.6256]}, {"w": "los‐", "b": [0.8262, 0.6042, 0.8571, 0.6256]}, {"w": "ses,", "b": [0.1429, 0.6232, 0.1718, 0.6447]}, {"w": "metrics,", "b": [0.1779, 0.6232, 0.2447, 0.6447]}, {"w": "and", "b": [0.2508, 0.6232, 0.2823, 0.6447]}, {"w": "so", "b": [0.2884, 0.6232, 0.3067, 0.6447]}, {"w": "on.", "b": [0.3128, 0.6232, 0.3396, 0.6447]}, {"w": "However,", "b": [0.3457, 0.6232, 0.4245, 0.6447]}, {"w": "in", "b": [0.4306, 0.6232, 0.4476, 0.6447]}, {"w": "some", "b": [0.4537, 0.6232, 0.4979, 0.6447]}, {"w": "rare", "b": [0.504, 0.6232, 0.5375, 0.6447]}, {"w": "cases", "b": [0.5436, 0.6232, 0.5857, 0.6447]}, {"w": "you", "b": [0.5918, 0.6232, 0.623, 0.6447]}, {"w": "may", "b": [0.6292, 0.6232, 0.6646, 0.6447]}, {"w": "need", "b": [0.6707, 0.6232, 0.7108, 0.6447]}, {"w": "to", "b": [0.7169, 0.6232, 0.7339, 0.6447]}, {"w": "customize", "b": [0.74, 0.6232, 0.8247, 0.6447]}, {"w": "the", "b": [0.8308, 0.6232, 0.8571, 0.6447]}, {"w": "training", "b": [0.1429, 0.6423, 0.2098, 0.6637]}, {"w": "loop", "b": [0.2151, 0.6423, 0.2525, 0.6637]}, {"w": "itself.", "b": [0.2578, 0.6423, 0.3024, 0.6637]}, {"w": "However,", "b": [0.3077, 0.6423, 0.3866, 0.6637]}, {"w": "before", "b": [0.3919, 0.6423, 0.4447, 0.6637]}, {"w": "we", "b": [0.45, 0.6423, 0.4731, 0.6637]}, {"w": "get", "b": [0.4784, 0.6423, 0.5034, 0.6637]}, {"w": "there,", "b": [0.5087, 0.6423, 0.5563, 0.6637]}, {"w": "we", "b": [0.5616, 0.6423, 0.5848, 0.6637]}, {"w": "need", "b": [0.59, 0.6423, 0.6301, 0.6637]}, {"w": "to", "b": [0.6354, 0.6423, 0.6524, 0.6637]}, {"w": "look", "b": [0.6577, 0.6423, 0.6946, 0.6637]}, {"w": "at", "b": [0.6999, 0.6423, 0.715, 0.6637]}, {"w": "how", "b": [0.7203, 0.6423, 0.7563, 0.6637]}, {"w": "to", "b": [0.7616, 0.6423, 0.7786, 0.6637]}, {"w": "compute", "b": [0.7839, 0.6423, 0.8571, 0.6637]}, {"w": "gradients", "b": [0.1429, 0.6613, 0.2199, 0.6828]}, {"w": "automatically", "b": [0.2246, 0.6613, 0.3372, 0.6828]}, {"w": "in", "b": [0.342, 0.6613, 0.359, 0.6828]}, {"w": "TensorFlow.", "b": [0.3637, 0.6613, 0.4652, 0.6828]}]}, {"id": "b_6", "type": "paragraph", "text": "Computing Gradients Using Autodiff", "words": [{"w": "Computing", "b": [0.1428, 0.6955, 0.2571, 0.7241]}, {"w": "Gradients", "b": [0.262, 0.6955, 0.3614, 0.7241]}, {"w": "Using", "b": [0.3664, 0.6955, 0.4244, 0.7241]}, {"w": "Autodiff", "b": [0.4293, 0.6955, 0.5137, 0.7241]}]}, {"id": "b_7", "type": "paragraph", "text": "To understand how to use autodiff (see Chapter 10 and ???) to compute gradients automatically, let’s consider a simple toy function:", "words": [{"w": "To", "b": [0.1429, 0.73, 0.1643, 0.7514]}, {"w": "understand", "b": [0.1721, 0.73, 0.2677, 0.7514]}, {"w": "how", "b": [0.2754, 0.73, 0.3115, 0.7514]}, {"w": "to", "b": [0.3192, 0.73, 0.3362, 0.7514]}, {"w": "use", "b": [0.344, 0.73, 0.3715, 0.7514]}, {"w": "autodiff", "b": [0.3793, 0.73, 0.445, 0.7514]}, {"w": "(see", "b": [0.4528, 0.73, 0.4854, 0.7514]}, {"w": "Chapter", "b": [0.4931, 0.73, 0.5607, 0.7514]}, {"w": "10", "b": [0.5685, 0.73, 0.5885, 0.7514]}, {"w": "and", "b": [0.5963, 0.73, 0.6278, 0.7514]}, {"w": "???)", "b": [0.6356, 0.73, 0.6665, 0.7514]}, {"w": "to", "b": [0.6743, 0.73, 0.6912, 0.7514]}, {"w": "compute", "b": [0.699, 0.73, 0.7723, 0.7514]}, {"w": "gradients", "b": [0.7801, 0.73, 0.8571, 0.7514]}, {"w": "automatically,", "b": [0.1429, 0.749, 0.2587, 0.7704]}, {"w": "let’s", "b": [0.2634, 0.749, 0.2936, 0.7704]}, {"w": "consider", "b": [0.2984, 0.749, 0.37, 0.7704]}, {"w": "a", "b": [0.3748, 0.749, 0.3839, 0.7704]}, {"w": "simple", "b": [0.3886, 0.749, 0.4436, 0.7704]}, {"w": "toy", "b": [0.4483, 0.749, 0.4748, 0.7704]}, {"w": "function:", "b": [0.4796, 0.749, 0.5557, 0.7704]}]}, {"id": "b_8", "type": "equation", "text": "def f(w1, w2): return 3 * w1 ** 2 + 2 * w1 * w2", "words": [{"w": "def", "b": [0.1766, 0.781, 0.2019, 0.7939]}, {"w": "f(w1,", "b": [0.2103, 0.781, 0.2525, 0.7939]}, {"w": "w2):", "b": [0.2609, 0.781, 0.2946, 0.7939]}, {"w": "return", "b": [0.2103, 0.7964, 0.2609, 0.8093]}, {"w": "3", "b": [0.2693, 0.7964, 0.2778, 0.8093]}, {"w": "*", "b": [0.2862, 0.7964, 0.2946, 0.8093]}, {"w": "w1", "b": [0.3031, 0.7964, 0.3199, 0.8093]}, {"w": "**", "b": [0.3284, 0.7964, 0.3452, 0.8093]}, {"w": "2", "b": [0.3537, 0.7964, 0.3621, 0.8093]}, {"w": "+", "b": [0.3705, 0.7964, 0.379, 0.8093]}, {"w": "2", "b": [0.3874, 0.7964, 0.3958, 0.8093]}, {"w": "*", "b": [0.4043, 0.7964, 0.4127, 0.8093]}, {"w": "w1", "b": [0.4211, 0.7964, 0.438, 0.8093]}, {"w": "*", "b": [0.4464, 0.7964, 0.4549, 0.8093]}, {"w": "w2", "b": [0.4633, 0.7964, 0.4802, 0.8093]}]}, {"id": "b_9", "type": "paragraph", "text": "If you know calculus, you can analytically find that the partial derivative of this func‐ tion with regards to w1 is 6 * w1 + 2 * w2. You can also find that its partial derivative with regards to w2 is 2 * w1. For example, at the point (w1, w2) = (5, 3), these par‐", "words": [{"w": "If", "b": [0.1429, 0.8171, 0.1561, 0.8385]}, {"w": "you", "b": [0.1615, 0.8171, 0.1927, 0.8385]}, {"w": "know", "b": [0.198, 0.8171, 0.2447, 0.8385]}, {"w": "calculus,", "b": [0.25, 0.8171, 0.3218, 0.8385]}, {"w": "you", "b": [0.3272, 0.8171, 0.3584, 0.8385]}, {"w": "can", "b": [0.3637, 0.8171, 0.3931, 0.8385]}, {"w": "analytically", "b": [0.3984, 0.8171, 0.4929, 0.8385]}, {"w": "find", "b": [0.4983, 0.8171, 0.5324, 0.8385]}, {"w": "that", "b": [0.5378, 0.8171, 0.5703, 0.8385]}, {"w": "the", "b": [0.5757, 0.8171, 0.602, 0.8385]}, {"w": "partial", "b": [0.6073, 0.8171, 0.6615, 0.8385]}, {"w": "derivative", "b": [0.6668, 0.8171, 0.7488, 0.8385]}, {"w": "of", "b": [0.7541, 0.8171, 0.7709, 0.8385]}, {"w": "this", "b": [0.7763, 0.8171, 0.807, 0.8385]}, {"w": "func‐", "b": [0.8123, 0.8171, 0.8571, 0.8385]}, {"w": "tion", "b": [0.1429, 0.837, 0.1768, 0.8584]}, {"w": "with", "b": [0.1818, 0.837, 0.2191, 0.8584]}, {"w": "regards", "b": [0.2241, 0.837, 0.286, 0.8584]}, {"w": "to", "b": [0.291, 0.837, 0.308, 0.8584]}, {"w": "w1", "b": [0.313, 0.8402, 0.3327, 0.8553]}, {"w": "is", "b": [0.3377, 0.837, 0.351, 0.8584]}, {"w": "6", "b": [0.356, 0.8402, 0.3659, 0.8553]}, {"w": "*", "b": [0.3758, 0.8402, 0.3856, 0.8553]}, {"w": "w1", "b": [0.3955, 0.8402, 0.4153, 0.8553]}, {"w": "+", "b": [0.4208, 0.8402, 0.4307, 0.8553]}, {"w": "2", "b": [0.4357, 0.8402, 0.4456, 0.8553]}, {"w": "*", "b": [0.4555, 0.8402, 0.4654, 0.8553]}, {"w": "w2.", "b": [0.4753, 0.837, 0.5003, 0.8584]}, {"w": "You", "b": [0.5053, 0.837, 0.5377, 0.8584]}, {"w": "can", "b": [0.5427, 0.837, 0.572, 0.8584]}, {"w": "also", "b": [0.577, 0.837, 0.6097, 0.8584]}, {"w": "find", "b": [0.6147, 0.837, 0.6489, 0.8584]}, {"w": "that", "b": [0.6539, 0.837, 0.6864, 0.8584]}, {"w": "its", "b": [0.6914, 0.837, 0.711, 0.8584]}, {"w": "partial", "b": [0.716, 0.837, 0.7702, 0.8584]}, {"w": "derivative", "b": [0.7751, 0.837, 0.8571, 0.8584]}, {"w": "with", "b": [0.1429, 0.857, 0.1802, 0.8784]}, {"w": "regards", "b": [0.1854, 0.857, 0.2473, 0.8784]}, {"w": "to", "b": [0.2525, 0.857, 0.2695, 0.8784]}, {"w": "w2", "b": [0.2747, 0.8601, 0.2945, 0.8752]}, {"w": "is", "b": [0.2998, 0.857, 0.313, 0.8784]}, {"w": "2", "b": [0.3182, 0.8601, 0.3281, 0.8752]}, {"w": "*", "b": [0.3385, 0.8601, 0.3484, 0.8752]}, {"w": "w1.", "b": [0.3588, 0.857, 0.3833, 0.8784]}, {"w": "For", "b": [0.3886, 0.857, 0.4176, 0.8784]}, {"w": "example,", "b": [0.4228, 0.857, 0.4971, 0.8784]}, {"w": "at", "b": [0.5023, 0.857, 0.5174, 0.8784]}, {"w": "the", "b": [0.5227, 0.857, 0.549, 0.8784]}, {"w": "point", "b": [0.5542, 0.857, 0.5987, 0.8784]}, {"w": "(w1,", "b": [0.604, 0.8601, 0.6436, 0.8752]}, {"w": "w2)", "b": [0.6534, 0.8601, 0.6831, 0.8752]}, {"w": "=", "b": [0.6889, 0.8601, 0.6988, 0.8752]}, {"w": "(5,", "b": [0.704, 0.8601, 0.7337, 0.8752]}, {"w": "3),", "b": [0.7436, 0.857, 0.7686, 0.8784]}, {"w": "these", "b": [0.7739, 0.857, 0.8167, 0.8784]}, {"w": "par‐", "b": [0.8219, 0.857, 0.8571, 0.8784]}]}, {"id": "b_10", "type": "paragraph", "text": "Customizing Models and Training Algorithms | 389", "words": [{"w": "Customizing", "b": [0.5328, 0.9225, 0.6056, 0.9388]}, {"w": "Models", "b": [0.6084, 0.9225, 0.6507, 0.9388]}, {"w": "and", "b": [0.6535, 0.9225, 0.6759, 0.9388]}, {"w": "Training", "b": [0.6787, 0.9225, 0.7278, 0.9388]}, {"w": "Algorithms", "b": [0.7306, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "389", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 416, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "tial derivatives are equal to 36 and 10, respectively, so the gradient vector at this point is (36, 10). But if this were a neural network, the function would be much more com‐ plex, typically with tens of thousands of parameters, and finding the partial deriva‐ tives analytically by hand would be an almost impossible task. One solution could be to compute an approximation of each partial derivative by measuring how much the function’s output changes when you tweak the corresponding parameter:", "words": [{"w": "tial", "b": [0.1429, 0.0791, 0.1692, 0.1005]}, {"w": "derivatives", "b": [0.1743, 0.0791, 0.264, 0.1005]}, {"w": "are", "b": [0.2691, 0.0791, 0.2948, 0.1005]}, {"w": "equal", "b": [0.2999, 0.0791, 0.3449, 0.1005]}, {"w": "to", "b": [0.35, 0.0791, 0.367, 0.1005]}, {"w": "36", "b": [0.3721, 0.0791, 0.3921, 0.1005]}, {"w": "and", "b": [0.3972, 0.0791, 0.4288, 0.1005]}, {"w": "10,", "b": [0.4339, 0.0791, 0.4586, 0.1005]}, {"w": "respectively,", "b": [0.4637, 0.0791, 0.565, 0.1005]}, {"w": "so", "b": [0.5701, 0.0791, 0.5884, 0.1005]}, {"w": "the", "b": [0.5935, 0.0791, 0.6199, 0.1005]}, {"w": "gradient", "b": [0.625, 0.0791, 0.6944, 0.1005]}, {"w": "vector", "b": [0.6995, 0.0791, 0.7515, 0.1005]}, {"w": "at", "b": [0.7566, 0.0791, 0.7717, 0.1005]}, {"w": "this", "b": [0.7768, 0.0791, 0.8076, 0.1005]}, {"w": "point", "b": [0.8127, 0.0791, 0.8571, 0.1005]}, {"w": "is", "b": [0.1429, 0.0981, 0.1561, 0.1195]}, {"w": "(36,", "b": [0.1613, 0.0981, 0.1932, 0.1195]}, {"w": "10).", "b": [0.1984, 0.0981, 0.2304, 0.1195]}, {"w": "But", "b": [0.2356, 0.0981, 0.2653, 0.1195]}, {"w": "if", "b": [0.2704, 0.0981, 0.2822, 0.1195]}, {"w": "this", "b": [0.2874, 0.0981, 0.3181, 0.1195]}, {"w": "were", "b": [0.3233, 0.0981, 0.363, 0.1195]}, {"w": "a", "b": [0.3682, 0.0981, 0.3774, 0.1195]}, {"w": "neural", "b": [0.3825, 0.0981, 0.436, 0.1195]}, {"w": "network,", "b": [0.4412, 0.0981, 0.5155, 0.1195]}, {"w": "the", "b": [0.5207, 0.0981, 0.547, 0.1195]}, {"w": "function", "b": [0.5522, 0.0981, 0.6236, 0.1195]}, {"w": "would", "b": [0.6288, 0.0981, 0.6811, 0.1195]}, {"w": "be", "b": [0.6863, 0.0981, 0.7057, 0.1195]}, {"w": "much", "b": [0.7109, 0.0981, 0.7586, 0.1195]}, {"w": "more", "b": [0.7638, 0.0981, 0.808, 0.1195]}, {"w": "com‐", "b": [0.8132, 0.0981, 0.8571, 0.1195]}, {"w": "plex,", "b": [0.1429, 0.1172, 0.1825, 0.1386]}, {"w": "typically", "b": [0.1894, 0.1172, 0.2599, 0.1386]}, {"w": "with", "b": [0.2667, 0.1172, 0.3041, 0.1386]}, {"w": "tens", "b": [0.3109, 0.1172, 0.3452, 0.1386]}, {"w": "of", "b": [0.3521, 0.1172, 0.3689, 0.1386]}, {"w": "thousands", "b": [0.3757, 0.1172, 0.4617, 0.1386]}, {"w": "of", "b": [0.4686, 0.1172, 0.4854, 0.1386]}, {"w": "parameters,", "b": [0.4923, 0.1172, 0.5905, 0.1386]}, {"w": "and", "b": [0.5974, 0.1172, 0.6289, 0.1386]}, {"w": "finding", "b": [0.6358, 0.1172, 0.6967, 0.1386]}, {"w": "the", "b": [0.7035, 0.1172, 0.7299, 0.1386]}, {"w": "partial", "b": [0.7368, 0.1172, 0.7909, 0.1386]}, {"w": "deriva‐", "b": [0.7978, 0.1172, 0.8572, 0.1386]}, {"w": "tives", "b": [0.1429, 0.1362, 0.1809, 0.1576]}, {"w": "analytically", "b": [0.1865, 0.1362, 0.281, 0.1576]}, {"w": "by", "b": [0.2866, 0.1362, 0.3067, 0.1576]}, {"w": "hand", "b": [0.3123, 0.1362, 0.355, 0.1576]}, {"w": "would", "b": [0.3605, 0.1362, 0.4128, 0.1576]}, {"w": "be", "b": [0.4183, 0.1362, 0.4378, 0.1576]}, {"w": "an", "b": [0.4433, 0.1362, 0.4639, 0.1576]}, {"w": "almost", "b": [0.4695, 0.1362, 0.5256, 0.1576]}, {"w": "impossible", "b": [0.5311, 0.1362, 0.6205, 0.1576]}, {"w": "task.", "b": [0.6261, 0.1362, 0.6643, 0.1576]}, {"w": "One", "b": [0.6699, 0.1362, 0.7057, 0.1576]}, {"w": "solution", "b": [0.7112, 0.1362, 0.7798, 0.1576]}, {"w": "could", "b": [0.7854, 0.1362, 0.8321, 0.1576]}, {"w": "be", "b": [0.8377, 0.1362, 0.8571, 0.1576]}, {"w": "to", "b": [0.1429, 0.1553, 0.1598, 0.1767]}, {"w": "compute", "b": [0.1657, 0.1553, 0.239, 0.1767]}, {"w": "an", "b": [0.2448, 0.1553, 0.2653, 0.1767]}, {"w": "approximation", "b": [0.2712, 0.1553, 0.3953, 0.1767]}, {"w": "of", "b": [0.4012, 0.1553, 0.4179, 0.1767]}, {"w": "each", "b": [0.4238, 0.1553, 0.4617, 0.1767]}, {"w": "partial", "b": [0.4676, 0.1553, 0.5217, 0.1767]}, {"w": "derivative", "b": [0.5275, 0.1553, 0.6095, 0.1767]}, {"w": "by", "b": [0.6154, 0.1553, 0.6355, 0.1767]}, {"w": "measuring", "b": [0.6414, 0.1553, 0.7296, 0.1767]}, {"w": "how", "b": [0.7354, 0.1553, 0.7715, 0.1767]}, {"w": "much", "b": [0.7773, 0.1553, 0.825, 0.1767]}, {"w": "the", "b": [0.8308, 0.1553, 0.8571, 0.1767]}, {"w": "function’s", "b": [0.1428, 0.1743, 0.2228, 0.1957]}, {"w": "output", "b": [0.2276, 0.1743, 0.284, 0.1957]}, {"w": "changes", "b": [0.2887, 0.1743, 0.3554, 0.1957]}, {"w": "when", "b": [0.3601, 0.1743, 0.4058, 0.1957]}, {"w": "you", "b": [0.4105, 0.1743, 0.4418, 0.1957]}, {"w": "tweak", "b": [0.4465, 0.1743, 0.4955, 0.1957]}, {"w": "the", "b": [0.5002, 0.1743, 0.5265, 0.1957]}, {"w": "corresponding", "b": [0.5312, 0.1743, 0.6533, 0.1957]}, {"w": "parameter:", "b": [0.658, 0.1743, 0.7491, 0.1957]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> w1, w2 = 5, 3 >>> eps = 1e-6 >>> (f(w1 + eps, w2) - f(w1, w2)) / eps 36.000003007075065 >>> (f(w1, w2 + eps) - f(w1, w2)) / eps 10.000000003174137", "words": [{"w": ">>>", "b": [0.1766, 0.2063, 0.2019, 0.2191]}, {"w": "w1,", "b": [0.2103, 0.2063, 0.2356, 0.2191]}, {"w": "w2", "b": [0.2441, 0.2063, 0.2609, 0.2191]}, {"w": "=", "b": [0.2694, 0.2063, 0.2778, 0.2191]}, {"w": "5,", "b": [0.2862, 0.2063, 0.3031, 0.2191]}, {"w": "3", "b": [0.3115, 0.2063, 0.3199, 0.2191]}, {"w": ">>>", "b": [0.1766, 0.2217, 0.2019, 0.2345]}, {"w": "eps", "b": [0.2103, 0.2217, 0.2356, 0.2345]}, {"w": "=", "b": [0.2441, 0.2217, 0.2525, 0.2345]}, {"w": "1e-6", "b": [0.2609, 0.2217, 0.2946, 0.2345]}, {"w": ">>>", "b": [0.1766, 0.2371, 0.2019, 0.25]}, {"w": "(f(w1", "b": [0.2103, 0.2371, 0.2525, 0.25]}, {"w": "+", "b": [0.2609, 0.2371, 0.2694, 0.25]}, {"w": "eps,", "b": [0.2778, 0.2371, 0.3115, 0.25]}, {"w": "w2)", "b": [0.3199, 0.2371, 0.3452, 0.25]}, {"w": "-", "b": [0.3537, 0.2371, 0.3621, 0.25]}, {"w": "f(w1,", "b": [0.3705, 0.2371, 0.4127, 0.25]}, {"w": "w2))", "b": [0.4211, 0.2371, 0.4549, 0.25]}, {"w": "/", "b": [0.4633, 0.2371, 0.4717, 0.25]}, {"w": "eps", "b": [0.4802, 0.2371, 0.5055, 0.25]}, {"w": "36.000003007075065", "b": [0.1766, 0.2525, 0.3284, 0.2654]}, {"w": ">>>", "b": [0.1766, 0.268, 0.2019, 0.2808]}, {"w": "(f(w1,", "b": [0.2103, 0.268, 0.2609, 0.2808]}, {"w": "w2", "b": [0.2694, 0.268, 0.2862, 0.2808]}, {"w": "+", "b": [0.2946, 0.268, 0.3031, 0.2808]}, {"w": "eps)", "b": [0.3115, 0.268, 0.3452, 0.2808]}, {"w": "-", "b": [0.3537, 0.268, 0.3621, 0.2808]}, {"w": "f(w1,", "b": [0.3705, 0.268, 0.4127, 0.2808]}, {"w": "w2))", "b": [0.4211, 0.268, 0.4549, 0.2808]}, {"w": "/", "b": [0.4633, 0.268, 0.4717, 0.2808]}, {"w": "eps", "b": [0.4802, 0.268, 0.5055, 0.2808]}, {"w": "10.000000003174137", "b": [0.1766, 0.2834, 0.3284, 0.2962]}]}, {"id": "b_2", "type": "paragraph", "text": "Looks about right! This works rather well and it is trivial to implement, but it is just an approximation, and importantly you need to call f() at least once per parameter (not twice, since we could compute f(w1, w2) just once). This makes this approach intractable for large neural networks. So instead we should use autodiff (see Chap‐ ter 10 and ???). TensorFlow makes this pretty simple:", "words": [{"w": "Looks", "b": [0.1429, 0.304, 0.1933, 0.3254]}, {"w": "about", "b": [0.1993, 0.304, 0.2471, 0.3254]}, {"w": "right!", "b": [0.2531, 0.304, 0.299, 0.3254]}, {"w": "This", "b": [0.305, 0.304, 0.3422, 0.3254]}, {"w": "works", "b": [0.3482, 0.304, 0.3988, 0.3254]}, {"w": "rather", "b": [0.4049, 0.304, 0.4554, 0.3254]}, {"w": "well", "b": [0.4614, 0.304, 0.4951, 0.3254]}, {"w": "and", "b": [0.5011, 0.304, 0.5326, 0.3254]}, {"w": "it", "b": [0.5387, 0.304, 0.5506, 0.3254]}, {"w": "is", "b": [0.5566, 0.304, 0.5699, 0.3254]}, {"w": "trivial", "b": [0.5759, 0.304, 0.6252, 0.3254]}, {"w": "to", "b": [0.6312, 0.304, 0.6482, 0.3254]}, {"w": "implement,", "b": [0.6542, 0.304, 0.7495, 0.3254]}, {"w": "but", "b": [0.7555, 0.304, 0.7835, 0.3254]}, {"w": "it", "b": [0.7895, 0.304, 0.8015, 0.3254]}, {"w": "is", "b": [0.8075, 0.304, 0.8207, 0.3254]}, {"w": "just", "b": [0.8267, 0.304, 0.8571, 0.3254]}, {"w": "an", "b": [0.1429, 0.3239, 0.1634, 0.3454]}, {"w": "approximation,", "b": [0.1697, 0.3239, 0.2986, 0.3454]}, {"w": "and", "b": [0.3049, 0.3239, 0.3365, 0.3454]}, {"w": "importantly", "b": [0.3428, 0.3239, 0.442, 0.3454]}, {"w": "you", "b": [0.4483, 0.3239, 0.4796, 0.3454]}, {"w": "need", "b": [0.4859, 0.3239, 0.526, 0.3454]}, {"w": "to", "b": [0.5323, 0.3239, 0.5493, 0.3454]}, {"w": "call", "b": [0.5556, 0.3239, 0.5841, 0.3454]}, {"w": "f()", "b": [0.5905, 0.3271, 0.6201, 0.3422]}, {"w": "at", "b": [0.6265, 0.3239, 0.6416, 0.3454]}, {"w": "least", "b": [0.6479, 0.3239, 0.6852, 0.3454]}, {"w": "once", "b": [0.6915, 0.3239, 0.7312, 0.3454]}, {"w": "per", "b": [0.7375, 0.3239, 0.765, 0.3454]}, {"w": "parameter", "b": [0.7713, 0.3239, 0.8571, 0.3454]}, {"w": "(not", "b": [0.1429, 0.3439, 0.1784, 0.3653]}, {"w": "twice,", "b": [0.1846, 0.3439, 0.2332, 0.3653]}, {"w": "since", "b": [0.2393, 0.3439, 0.2816, 0.3653]}, {"w": "we", "b": [0.2877, 0.3439, 0.3108, 0.3653]}, {"w": "could", "b": [0.3169, 0.3439, 0.3637, 0.3653]}, {"w": "compute", "b": [0.3698, 0.3439, 0.4431, 0.3653]}, {"w": "f(w1,", "b": [0.4492, 0.3471, 0.4986, 0.3622]}, {"w": "w2)", "b": [0.5098, 0.3471, 0.5395, 0.3622]}, {"w": "just", "b": [0.5456, 0.3439, 0.576, 0.3653]}, {"w": "once).", "b": [0.5821, 0.3439, 0.6338, 0.3653]}, {"w": "This", "b": [0.6399, 0.3439, 0.6771, 0.3653]}, {"w": "makes", "b": [0.6832, 0.3439, 0.7362, 0.3653]}, {"w": "this", "b": [0.7423, 0.3439, 0.773, 0.3653]}, {"w": "approach", "b": [0.7791, 0.3439, 0.8572, 0.3653]}, {"w": "intractable", "b": [0.1429, 0.3629, 0.2317, 0.3844]}, {"w": "for", "b": [0.2389, 0.3629, 0.2634, 0.3844]}, {"w": "large", "b": [0.2706, 0.3629, 0.3114, 0.3844]}, {"w": "neural", "b": [0.3186, 0.3629, 0.3721, 0.3844]}, {"w": "networks.", "b": [0.3793, 0.3629, 0.4612, 0.3844]}, {"w": "So", "b": [0.4684, 0.3629, 0.4889, 0.3844]}, {"w": "instead", "b": [0.4961, 0.3629, 0.5561, 0.3844]}, {"w": "we", "b": [0.5633, 0.3629, 0.5865, 0.3844]}, {"w": "should", "b": [0.5937, 0.3629, 0.6504, 0.3844]}, {"w": "use", "b": [0.6576, 0.3629, 0.6852, 0.3844]}, {"w": "autodiff", "b": [0.6924, 0.3629, 0.7581, 0.3844]}, {"w": "(see", "b": [0.7653, 0.3629, 0.7979, 0.3844]}, {"w": "Chap‐", "b": [0.8051, 0.3629, 0.8571, 0.3844]}, {"w": "ter", "b": [0.1429, 0.382, 0.1658, 0.4034]}, {"w": "10", "b": [0.1705, 0.382, 0.1905, 0.4034]}, {"w": "and", "b": [0.1953, 0.382, 0.2268, 0.4034]}, {"w": "???).", "b": [0.2315, 0.382, 0.2672, 0.4034]}, {"w": "TensorFlow", "b": [0.2719, 0.382, 0.3701, 0.4034]}, {"w": "makes", "b": [0.3749, 0.382, 0.4279, 0.4034]}, {"w": "this", "b": [0.4326, 0.382, 0.4634, 0.4034]}, {"w": "pretty", "b": [0.4681, 0.382, 0.5179, 0.4034]}, {"w": "simple:", "b": [0.5226, 0.382, 0.5823, 0.4034]}]}, {"id": "b_3", "type": "paragraph", "text": "w1, w2 = tf.Variable(5.), tf.Variable(3.) with tf.GradientTape() as tape: z = f(w1, w2)", "words": [{"w": "w1,", "b": [0.1766, 0.414, 0.2019, 0.4268]}, {"w": "w2", "b": [0.2103, 0.414, 0.2272, 0.4268]}, {"w": "=", "b": [0.2356, 0.414, 0.244, 0.4268]}, {"w": "tf.Variable(5.),", "b": [0.2525, 0.414, 0.3874, 0.4268]}, {"w": "tf.Variable(3.)", "b": [0.3958, 0.414, 0.5223, 0.4268]}, {"w": "with", "b": [0.1766, 0.4294, 0.2103, 0.4422]}, {"w": "tf.GradientTape()", "b": [0.2187, 0.4294, 0.3621, 0.4422]}, {"w": "as", "b": [0.3705, 0.4294, 0.3874, 0.4422]}, {"w": "tape:", "b": [0.3958, 0.4294, 0.438, 0.4422]}, {"w": "z", "b": [0.2103, 0.4448, 0.2187, 0.4577]}, {"w": "=", "b": [0.2272, 0.4448, 0.2356, 0.4577]}, {"w": "f(w1,", "b": [0.244, 0.4448, 0.2862, 0.4577]}, {"w": "w2)", "b": [0.2946, 0.4448, 0.3199, 0.4577]}]}, {"id": "b_4", "type": "equation", "text": "gradients = tape.gradient(z, [w1, w2])", "words": [{"w": "gradients", "b": [0.1766, 0.4756, 0.2525, 0.4885]}, {"w": "=", "b": [0.2609, 0.4756, 0.2693, 0.4885]}, {"w": "tape.gradient(z,", "b": [0.2778, 0.4756, 0.4127, 0.4885]}, {"w": "[w1,", "b": [0.4211, 0.4756, 0.4549, 0.4885]}, {"w": "w2])", "b": [0.4633, 0.4756, 0.497, 0.4885]}]}, {"id": "b_5", "type": "paragraph", "text": "We first define two variables w1 and w2, then we create a tf.GradientTape context that will automatically record every operation that involves a variable, and finally we ask this tape to compute the gradients of the result z with regards to both variables [w1, w2]. Let’s take a look at the gradients that TensorFlow computed:", "words": [{"w": "We", "b": [0.1429, 0.4972, 0.1699, 0.5186]}, {"w": "first", "b": [0.177, 0.4972, 0.2104, 0.5186]}, {"w": "define", "b": [0.2175, 0.4972, 0.2693, 0.5186]}, {"w": "two", "b": [0.2764, 0.4972, 0.3076, 0.5186]}, {"w": "variables", "b": [0.3147, 0.4972, 0.3883, 0.5186]}, {"w": "w1", "b": [0.3953, 0.5004, 0.4151, 0.5154]}, {"w": "and", "b": [0.4221, 0.4972, 0.4537, 0.5186]}, {"w": "w2,", "b": [0.4607, 0.4972, 0.4853, 0.5186]}, {"w": "then", "b": [0.4923, 0.4972, 0.53, 0.5186]}, {"w": "we", "b": [0.5371, 0.4972, 0.5602, 0.5186]}, {"w": "create", "b": [0.5672, 0.4972, 0.6166, 0.5186]}, {"w": "a", "b": [0.6236, 0.4972, 0.6328, 0.5186]}, {"w": "tf.GradientTape", "b": [0.6398, 0.5004, 0.7883, 0.5154]}, {"w": "context", "b": [0.7953, 0.4972, 0.8571, 0.5186]}, {"w": "that", "b": [0.1429, 0.5162, 0.1755, 0.5376]}, {"w": "will", "b": [0.1813, 0.5162, 0.2117, 0.5376]}, {"w": "automatically", "b": [0.2175, 0.5162, 0.3301, 0.5376]}, {"w": "record", "b": [0.336, 0.5162, 0.3907, 0.5376]}, {"w": "every", "b": [0.3966, 0.5162, 0.4418, 0.5376]}, {"w": "operation", "b": [0.4477, 0.5162, 0.5285, 0.5376]}, {"w": "that", "b": [0.5344, 0.5162, 0.567, 0.5376]}, {"w": "involves", "b": [0.5728, 0.5162, 0.641, 0.5376]}, {"w": "a", "b": [0.6468, 0.5162, 0.656, 0.5376]}, {"w": "variable,", "b": [0.6618, 0.5162, 0.7325, 0.5376]}, {"w": "and", "b": [0.7384, 0.5162, 0.7699, 0.5376]}, {"w": "finally", "b": [0.7758, 0.5162, 0.8282, 0.5376]}, {"w": "we", "b": [0.834, 0.5162, 0.8572, 0.5376]}, {"w": "ask", "b": [0.1429, 0.5362, 0.17, 0.5576]}, {"w": "this", "b": [0.1766, 0.5362, 0.2073, 0.5576]}, {"w": "tape", "b": [0.214, 0.5362, 0.2488, 0.5576]}, {"w": "to", "b": [0.2555, 0.5362, 0.2725, 0.5576]}, {"w": "compute", "b": [0.2791, 0.5362, 0.3524, 0.5576]}, {"w": "the", "b": [0.359, 0.5362, 0.3853, 0.5576]}, {"w": "gradients", "b": [0.392, 0.5362, 0.469, 0.5576]}, {"w": "of", "b": [0.4757, 0.5362, 0.4925, 0.5576]}, {"w": "the", "b": [0.4991, 0.5362, 0.5254, 0.5576]}, {"w": "result", "b": [0.5321, 0.5362, 0.579, 0.5576]}, {"w": "z", "b": [0.5856, 0.5393, 0.5955, 0.5544]}, {"w": "with", "b": [0.6022, 0.5362, 0.6395, 0.5576]}, {"w": "regards", "b": [0.6461, 0.5362, 0.708, 0.5576]}, {"w": "to", "b": [0.7146, 0.5362, 0.7316, 0.5576]}, {"w": "both", "b": [0.7382, 0.5362, 0.7769, 0.5576]}, {"w": "variables", "b": [0.7835, 0.5362, 0.8571, 0.5576]}, {"w": "[w1,", "b": [0.1429, 0.5593, 0.1825, 0.5744]}, {"w": "w2].", "b": [0.1923, 0.5561, 0.2268, 0.5775]}, {"w": "Let’s", "b": [0.2315, 0.5561, 0.2677, 0.5775]}, {"w": "take", "b": [0.2724, 0.5561, 0.3071, 0.5775]}, {"w": "a", "b": [0.3118, 0.5561, 0.321, 0.5775]}, {"w": "look", "b": [0.3257, 0.5561, 0.3626, 0.5775]}, {"w": "at", "b": [0.3673, 0.5561, 0.3824, 0.5775]}, {"w": "the", "b": [0.3871, 0.5561, 0.4135, 0.5775]}, {"w": "gradients", "b": [0.4182, 0.5561, 0.4952, 0.5775]}, {"w": "that", "b": [0.5, 0.5561, 0.5326, 0.5775]}, {"w": "TensorFlow", "b": [0.5373, 0.5561, 0.6355, 0.5775]}, {"w": "computed:", "b": [0.6403, 0.5561, 0.7293, 0.5775]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> gradients [, ]", "words": [{"w": ">>>", "b": [0.1766, 0.5881, 0.2019, 0.6009]}, {"w": "gradients", "b": [0.2103, 0.5881, 0.2862, 0.6009]}, {"w": "[,", "b": [0.5898, 0.6035, 0.691, 0.6164]}, {"w": "]", "b": [0.5898, 0.6189, 0.691, 0.6318]}]}, {"id": "b_7", "type": "paragraph", "text": "Perfect! Not only is the result accurate (the precision is only limited by the floating point errors), but the gradient() method only goes through the recorded computa‐ tions once (in reverse order), no matter how many variables there are, so it is incredi‐ bly efficient. It’s like magic!", "words": [{"w": "Perfect!", "b": [0.1429, 0.6396, 0.2064, 0.661]}, {"w": "Not", "b": [0.2132, 0.6396, 0.2452, 0.661]}, {"w": "only", "b": [0.252, 0.6396, 0.2888, 0.661]}, {"w": "is", "b": [0.2956, 0.6396, 0.3088, 0.661]}, {"w": "the", "b": [0.3156, 0.6396, 0.342, 0.661]}, {"w": "result", "b": [0.3488, 0.6396, 0.3957, 0.661]}, {"w": "accurate", "b": [0.4025, 0.6396, 0.472, 0.661]}, {"w": "(the", "b": [0.4788, 0.6396, 0.5123, 0.661]}, {"w": "precision", "b": [0.5191, 0.6396, 0.5962, 0.661]}, {"w": "is", "b": [0.603, 0.6396, 0.6163, 0.661]}, {"w": "only", "b": [0.6231, 0.6396, 0.6599, 0.661]}, {"w": "limited", "b": [0.6667, 0.6396, 0.7264, 0.661]}, {"w": "by", "b": [0.7332, 0.6396, 0.7533, 0.661]}, {"w": "the", "b": [0.7601, 0.6396, 0.7865, 0.661]}, {"w": "floating", "b": [0.7933, 0.6396, 0.8572, 0.661]}, {"w": "point", "b": [0.1429, 0.6595, 0.1873, 0.6809]}, {"w": "errors),", "b": [0.1933, 0.6595, 0.2556, 0.6809]}, {"w": "but", "b": [0.2616, 0.6595, 0.2896, 0.6809]}, {"w": "the", "b": [0.2956, 0.6595, 0.3219, 0.6809]}, {"w": "gradient()", "b": [0.3279, 0.6627, 0.4268, 0.6778]}, {"w": "method", "b": [0.4328, 0.6595, 0.4978, 0.6809]}, {"w": "only", "b": [0.5038, 0.6595, 0.5407, 0.6809]}, {"w": "goes", "b": [0.5466, 0.6595, 0.5835, 0.6809]}, {"w": "through", "b": [0.5895, 0.6595, 0.6573, 0.6809]}, {"w": "the", "b": [0.6632, 0.6595, 0.6896, 0.6809]}, {"w": "recorded", "b": [0.6956, 0.6595, 0.7702, 0.6809]}, {"w": "computa‐", "b": [0.7761, 0.6595, 0.8571, 0.6809]}, {"w": "tions", "b": [0.1429, 0.6785, 0.1845, 0.7]}, {"w": "once", "b": [0.1895, 0.6785, 0.2291, 0.7]}, {"w": "(in", "b": [0.2341, 0.6785, 0.2583, 0.7]}, {"w": "reverse", "b": [0.2633, 0.6785, 0.3226, 0.7]}, {"w": "order),", "b": [0.3276, 0.6785, 0.3855, 0.7]}, {"w": "no", "b": [0.3905, 0.6785, 0.4125, 0.7]}, {"w": "matter", "b": [0.4175, 0.6785, 0.4726, 0.7]}, {"w": "how", "b": [0.4776, 0.6785, 0.5137, 0.7]}, {"w": "many", "b": [0.5187, 0.6785, 0.5653, 0.7]}, {"w": "variables", "b": [0.5703, 0.6785, 0.644, 0.7]}, {"w": "there", "b": [0.6489, 0.6785, 0.6919, 0.7]}, {"w": "are,", "b": [0.6969, 0.6785, 0.7273, 0.7]}, {"w": "so", "b": [0.7323, 0.6785, 0.7506, 0.7]}, {"w": "it", "b": [0.7556, 0.6785, 0.7675, 0.7]}, {"w": "is", "b": [0.7725, 0.6785, 0.7858, 0.7]}, {"w": "incredi‐", "b": [0.7908, 0.6785, 0.8571, 0.7]}, {"w": "bly", "b": [0.1429, 0.6976, 0.1683, 0.719]}, {"w": "efficient.", "b": [0.173, 0.6976, 0.2451, 0.719]}, {"w": "It’s", "b": [0.2499, 0.6976, 0.2723, 0.719]}, {"w": "like", "b": [0.277, 0.6976, 0.307, 0.719]}, {"w": "magic!", "b": [0.3118, 0.6976, 0.3679, 0.719]}]}, {"id": "b_8", "type": "paragraph", "text": "Only put the strict minimum inside the tf.GradientTape() block, to save memory. Alternatively, you can pause recording by creating a with tape.stop_recording() block inside the tf.Gradient Tape() block.", "words": [{"w": "Only", "b": [0.2714, 0.7404, 0.3096, 0.7599]}, {"w": "put", "b": [0.3147, 0.7404, 0.3406, 0.7599]}, {"w": "the", "b": [0.3456, 0.7404, 0.3697, 0.7599]}, {"w": "strict", "b": [0.3747, 0.7404, 0.4136, 0.7599]}, {"w": "minimum", "b": [0.4186, 0.7404, 0.4958, 0.7599]}, {"w": "inside", "b": [0.5009, 0.7404, 0.5466, 0.7599]}, {"w": "the", "b": [0.5517, 0.7404, 0.5758, 0.7599]}, {"w": "tf.GradientTape()", "b": [0.5808, 0.7433, 0.7346, 0.7571]}, {"w": "block,", "b": [0.7397, 0.7404, 0.7857, 0.7599]}, {"w": "to", "b": [0.2714, 0.7578, 0.2869, 0.7774]}, {"w": "save", "b": [0.2918, 0.7578, 0.3237, 0.7774]}, {"w": "memory.", "b": [0.3286, 0.7578, 0.3969, 0.7774]}, {"w": "Alternatively,", "b": [0.4018, 0.7578, 0.5035, 0.7774]}, {"w": "you", "b": [0.5084, 0.7578, 0.537, 0.7774]}, {"w": "can", "b": [0.5418, 0.7578, 0.5687, 0.7774]}, {"w": "pause", "b": [0.5735, 0.7578, 0.6167, 0.7774]}, {"w": "recording", "b": [0.6216, 0.7578, 0.6961, 0.7774]}, {"w": "by", "b": [0.701, 0.7578, 0.7194, 0.7774]}, {"w": "creating", "b": [0.7243, 0.7578, 0.7857, 0.7774]}, {"w": "a", "b": [0.2714, 0.776, 0.2798, 0.7956]}, {"w": "with", "b": [0.2896, 0.7789, 0.3258, 0.7927]}, {"w": "tape.stop_recording()", "b": [0.3401, 0.7789, 0.5301, 0.7927]}, {"w": "block", "b": [0.5399, 0.776, 0.5816, 0.7956]}, {"w": "inside", "b": [0.5915, 0.776, 0.6372, 0.7956]}, {"w": "the", "b": [0.6471, 0.776, 0.6711, 0.7956]}, {"w": "tf.Gradient", "b": [0.681, 0.7789, 0.7805, 0.7927]}, {"w": "Tape()", "b": [0.2714, 0.7972, 0.3257, 0.8109]}, {"w": "block.", "b": [0.33, 0.7942, 0.3761, 0.8138]}]}, {"id": "b_9", "type": "paragraph", "text": "The tape is automatically erased immediately after you call its gradient() method, so you will get an exception if you try to call gradient() twice:", "words": [{"w": "The", "b": [0.1429, 0.8391, 0.1757, 0.8605]}, {"w": "tape", "b": [0.1806, 0.8391, 0.2155, 0.8605]}, {"w": "is", "b": [0.2204, 0.8391, 0.2336, 0.8605]}, {"w": "automatically", "b": [0.2385, 0.8391, 0.3511, 0.8605]}, {"w": "erased", "b": [0.3561, 0.8391, 0.4093, 0.8605]}, {"w": "immediately", "b": [0.4142, 0.8391, 0.5181, 0.8605]}, {"w": "after", "b": [0.5231, 0.8391, 0.5613, 0.8605]}, {"w": "you", "b": [0.5662, 0.8391, 0.5975, 0.8605]}, {"w": "call", "b": [0.6024, 0.8391, 0.6309, 0.8605]}, {"w": "its", "b": [0.6358, 0.8391, 0.6554, 0.8605]}, {"w": "gradient()", "b": [0.6603, 0.8423, 0.7593, 0.8573]}, {"w": "method,", "b": [0.7642, 0.8391, 0.8339, 0.8605]}, {"w": "so", "b": [0.8387, 0.8391, 0.8569, 0.8605]}, {"w": "you", "b": [0.1429, 0.859, 0.1741, 0.8804]}, {"w": "will", "b": [0.1788, 0.859, 0.2092, 0.8804]}, {"w": "get", "b": [0.214, 0.859, 0.2389, 0.8804]}, {"w": "an", "b": [0.2437, 0.859, 0.2642, 0.8804]}, {"w": "exception", "b": [0.2689, 0.859, 0.3502, 0.8804]}, {"w": "if", "b": [0.3549, 0.859, 0.3666, 0.8804]}, {"w": "you", "b": [0.3714, 0.859, 0.4026, 0.8804]}, {"w": "try", "b": [0.4073, 0.859, 0.4316, 0.8804]}, {"w": "to", "b": [0.4363, 0.859, 0.4533, 0.8804]}, {"w": "call", "b": [0.458, 0.859, 0.4865, 0.8804]}, {"w": "gradient()", "b": [0.4913, 0.8622, 0.5902, 0.8773]}, {"w": "twice:", "b": [0.5949, 0.859, 0.6436, 0.8804]}]}, {"id": "b_10", "type": "paragraph", "text": "390 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "390", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2746, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3638, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 417, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "with tf.GradientTape() as tape: z = f(w1, w2)", "words": [{"w": "with", "b": [0.1766, 0.0829, 0.2103, 0.0958]}, {"w": "tf.GradientTape()", "b": [0.2188, 0.0829, 0.3621, 0.0958]}, {"w": "as", "b": [0.3705, 0.0829, 0.3874, 0.0958]}, {"w": "tape:", "b": [0.3958, 0.0829, 0.438, 0.0958]}, {"w": "z", "b": [0.2103, 0.0983, 0.2188, 0.1112]}, {"w": "=", "b": [0.2272, 0.0983, 0.2356, 0.1112]}, {"w": "f(w1,", "b": [0.244, 0.0983, 0.2862, 0.1112]}, {"w": "w2)", "b": [0.2946, 0.0983, 0.3199, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "dz_dw1 = tape.gradient(z, w1) # => tensor 36.0 dz_dw2 = tape.gradient(z, w2) # RuntimeError!", "words": [{"w": "dz_dw1", "b": [0.1766, 0.1292, 0.2272, 0.142]}, {"w": "=", "b": [0.2356, 0.1292, 0.244, 0.142]}, {"w": "tape.gradient(z,", "b": [0.2525, 0.1292, 0.3874, 0.142]}, {"w": "w1)", "b": [0.3958, 0.1292, 0.4211, 0.142]}, {"w": "#", "b": [0.4296, 0.1292, 0.438, 0.142]}, {"w": "=>", "b": [0.4464, 0.1292, 0.4633, 0.142]}, {"w": "tensor", "b": [0.4717, 0.1292, 0.5223, 0.142]}, {"w": "36.0", "b": [0.5308, 0.1292, 0.5645, 0.142]}, {"w": "dz_dw2", "b": [0.1766, 0.1446, 0.2272, 0.1574]}, {"w": "=", "b": [0.2356, 0.1446, 0.244, 0.1574]}, {"w": "tape.gradient(z,", "b": [0.2525, 0.1446, 0.3874, 0.1574]}, {"w": "w2)", "b": [0.3958, 0.1446, 0.4211, 0.1574]}, {"w": "#", "b": [0.4296, 0.1446, 0.438, 0.1574]}, {"w": "RuntimeError!", "b": [0.4464, 0.1446, 0.5561, 0.1574]}]}, {"id": "b_2", "type": "paragraph", "text": "If you need to call gradient() more than once, you must make the tape persistent, and delete it when you are done with it to free resources:", "words": [{"w": "If", "b": [0.1429, 0.1661, 0.1561, 0.1875]}, {"w": "you", "b": [0.1628, 0.1661, 0.194, 0.1875]}, {"w": "need", "b": [0.2007, 0.1661, 0.2408, 0.1875]}, {"w": "to", "b": [0.2475, 0.1661, 0.2644, 0.1875]}, {"w": "call", "b": [0.2711, 0.1661, 0.2996, 0.1875]}, {"w": "gradient()", "b": [0.3063, 0.1693, 0.4052, 0.1844]}, {"w": "more", "b": [0.4119, 0.1661, 0.4562, 0.1875]}, {"w": "than", "b": [0.4628, 0.1661, 0.5008, 0.1875]}, {"w": "once,", "b": [0.5075, 0.1661, 0.5519, 0.1875]}, {"w": "you", "b": [0.5586, 0.1661, 0.5898, 0.1875]}, {"w": "must", "b": [0.5965, 0.1661, 0.6382, 0.1875]}, {"w": "make", "b": [0.6449, 0.1661, 0.6903, 0.1875]}, {"w": "the", "b": [0.6969, 0.1661, 0.7233, 0.1875]}, {"w": "tape", "b": [0.7299, 0.1661, 0.7648, 0.1875]}, {"w": "persistent,", "b": [0.7715, 0.1661, 0.8572, 0.1875]}, {"w": "and", "b": [0.1429, 0.1852, 0.1744, 0.2066]}, {"w": "delete", "b": [0.1791, 0.1852, 0.2283, 0.2066]}, {"w": "it", "b": [0.233, 0.1852, 0.245, 0.2066]}, {"w": "when", "b": [0.2497, 0.1852, 0.2954, 0.2066]}, {"w": "you", "b": [0.3001, 0.1852, 0.3313, 0.2066]}, {"w": "are", "b": [0.3361, 0.1852, 0.3618, 0.2066]}, {"w": "done", "b": [0.3665, 0.1852, 0.4084, 0.2066]}, {"w": "with", "b": [0.4131, 0.1852, 0.4505, 0.2066]}, {"w": "it", "b": [0.4552, 0.1852, 0.4671, 0.2066]}, {"w": "to", "b": [0.4719, 0.1852, 0.4888, 0.2066]}, {"w": "free", "b": [0.4936, 0.1852, 0.5252, 0.2066]}, {"w": "resources:", "b": [0.5299, 0.1852, 0.6136, 0.2066]}]}, {"id": "b_3", "type": "equation", "text": "with tf.GradientTape(persistent=True) as tape: z = f(w1, w2)", "words": [{"w": "with", "b": [0.1766, 0.2171, 0.2103, 0.23]}, {"w": "tf.GradientTape(persistent=True)", "b": [0.2187, 0.2171, 0.4886, 0.23]}, {"w": "as", "b": [0.497, 0.2171, 0.5139, 0.23]}, {"w": "tape:", "b": [0.5223, 0.2171, 0.5645, 0.23]}, {"w": "z", "b": [0.2103, 0.2326, 0.2187, 0.2454]}, {"w": "=", "b": [0.2272, 0.2326, 0.2356, 0.2454]}, {"w": "f(w1,", "b": [0.244, 0.2326, 0.2862, 0.2454]}, {"w": "w2)", "b": [0.2946, 0.2326, 0.3199, 0.2454]}]}, {"id": "b_4", "type": "paragraph", "text": "dz_dw1 = tape.gradient(z, w1) # => tensor 36.0 dz_dw2 = tape.gradient(z, w2) # => tensor 10.0, works fine now! del tape", "words": [{"w": "dz_dw1", "b": [0.1766, 0.2634, 0.2272, 0.2763]}, {"w": "=", "b": [0.2356, 0.2634, 0.244, 0.2763]}, {"w": "tape.gradient(z,", "b": [0.2525, 0.2634, 0.3874, 0.2763]}, {"w": "w1)", "b": [0.3958, 0.2634, 0.4211, 0.2763]}, {"w": "#", "b": [0.4296, 0.2634, 0.438, 0.2763]}, {"w": "=>", "b": [0.4464, 0.2634, 0.4633, 0.2763]}, {"w": "tensor", "b": [0.4717, 0.2634, 0.5223, 0.2763]}, {"w": "36.0", "b": [0.5308, 0.2634, 0.5645, 0.2763]}, {"w": "dz_dw2", "b": [0.1766, 0.2788, 0.2272, 0.2917]}, {"w": "=", "b": [0.2356, 0.2788, 0.244, 0.2917]}, {"w": "tape.gradient(z,", "b": [0.2525, 0.2788, 0.3874, 0.2917]}, {"w": "w2)", "b": [0.3958, 0.2788, 0.4211, 0.2917]}, {"w": "#", "b": [0.4296, 0.2788, 0.438, 0.2917]}, {"w": "=>", "b": [0.4464, 0.2788, 0.4633, 0.2917]}, {"w": "tensor", "b": [0.4717, 0.2788, 0.5223, 0.2917]}, {"w": "10.0,", "b": [0.5308, 0.2788, 0.5729, 0.2917]}, {"w": "works", "b": [0.5813, 0.2788, 0.6235, 0.2917]}, {"w": "fine", "b": [0.6319, 0.2788, 0.6657, 0.2917]}, {"w": "now!", "b": [0.6741, 0.2788, 0.7078, 0.2917]}, {"w": "del", "b": [0.1766, 0.2942, 0.2019, 0.3071]}, {"w": "tape", "b": [0.2103, 0.2942, 0.244, 0.3071]}]}, {"id": "b_5", "type": "paragraph", "text": "By default, the tape will only track operations involving variables, so if you try to compute the gradient of z with regards to anything else than a variable, the result will be None:", "words": [{"w": "By", "b": [0.1429, 0.3149, 0.1647, 0.3363]}, {"w": "default,", "b": [0.1726, 0.3149, 0.2349, 0.3363]}, {"w": "the", "b": [0.2428, 0.3149, 0.2692, 0.3363]}, {"w": "tape", "b": [0.2771, 0.3149, 0.312, 0.3363]}, {"w": "will", "b": [0.32, 0.3149, 0.3504, 0.3363]}, {"w": "only", "b": [0.3584, 0.3149, 0.3952, 0.3363]}, {"w": "track", "b": [0.4032, 0.3149, 0.4456, 0.3363]}, {"w": "operations", "b": [0.4536, 0.3149, 0.542, 0.3363]}, {"w": "involving", "b": [0.55, 0.3149, 0.6284, 0.3363]}, {"w": "variables,", "b": [0.6364, 0.3149, 0.7148, 0.3363]}, {"w": "so", "b": [0.7227, 0.3149, 0.741, 0.3363]}, {"w": "if", "b": [0.749, 0.3149, 0.7607, 0.3363]}, {"w": "you", "b": [0.7687, 0.3149, 0.8, 0.3363]}, {"w": "try", "b": [0.8079, 0.3149, 0.8322, 0.3363]}, {"w": "to", "b": [0.8402, 0.3149, 0.8571, 0.3363]}, {"w": "compute", "b": [0.1429, 0.3348, 0.2161, 0.3562]}, {"w": "the", "b": [0.2212, 0.3348, 0.2476, 0.3562]}, {"w": "gradient", "b": [0.2527, 0.3348, 0.3221, 0.3562]}, {"w": "of", "b": [0.3272, 0.3348, 0.344, 0.3562]}, {"w": "z", "b": [0.3491, 0.338, 0.359, 0.3531]}, {"w": "with", "b": [0.3641, 0.3348, 0.4014, 0.3562]}, {"w": "regards", "b": [0.4065, 0.3348, 0.4683, 0.3562]}, {"w": "to", "b": [0.4734, 0.3348, 0.4904, 0.3562]}, {"w": "anything", "b": [0.4955, 0.3348, 0.5693, 0.3562]}, {"w": "else", "b": [0.5744, 0.3348, 0.6051, 0.3562]}, {"w": "than", "b": [0.6102, 0.3348, 0.6482, 0.3562]}, {"w": "a", "b": [0.6533, 0.3348, 0.6624, 0.3562]}, {"w": "variable,", "b": [0.6675, 0.3348, 0.7382, 0.3562]}, {"w": "the", "b": [0.7433, 0.3348, 0.7696, 0.3562]}, {"w": "result", "b": [0.7747, 0.3348, 0.8217, 0.3562]}, {"w": "will", "b": [0.8268, 0.3348, 0.8571, 0.3562]}, {"w": "be", "b": [0.1429, 0.3548, 0.1623, 0.3762]}, {"w": "None:", "b": [0.167, 0.3548, 0.2114, 0.3762]}]}, {"id": "b_6", "type": "paragraph", "text": "c1, c2 = tf.constant(5.), tf.constant(3.) with tf.GradientTape() as tape: z = f(c1, c2)", "words": [{"w": "c1,", "b": [0.1766, 0.3867, 0.2019, 0.3996]}, {"w": "c2", "b": [0.2103, 0.3867, 0.2272, 0.3996]}, {"w": "=", "b": [0.2356, 0.3867, 0.2441, 0.3996]}, {"w": "tf.constant(5.),", "b": [0.2525, 0.3867, 0.3874, 0.3996]}, {"w": "tf.constant(3.)", "b": [0.3958, 0.3867, 0.5223, 0.3996]}, {"w": "with", "b": [0.1766, 0.4022, 0.2103, 0.415]}, {"w": "tf.GradientTape()", "b": [0.2188, 0.4022, 0.3621, 0.415]}, {"w": "as", "b": [0.3705, 0.4022, 0.3874, 0.415]}, {"w": "tape:", "b": [0.3958, 0.4022, 0.438, 0.415]}, {"w": "z", "b": [0.2103, 0.4176, 0.2187, 0.4304]}, {"w": "=", "b": [0.2272, 0.4176, 0.2356, 0.4304]}, {"w": "f(c1,", "b": [0.244, 0.4176, 0.2862, 0.4304]}, {"w": "c2)", "b": [0.2946, 0.4176, 0.3199, 0.4304]}]}, {"id": "b_7", "type": "equation", "text": "gradients = tape.gradient(z, [c1, c2]) # returns [None, None]", "words": [{"w": "gradients", "b": [0.1766, 0.4484, 0.2525, 0.4613]}, {"w": "=", "b": [0.2609, 0.4484, 0.2693, 0.4613]}, {"w": "tape.gradient(z,", "b": [0.2778, 0.4484, 0.4127, 0.4613]}, {"w": "[c1,", "b": [0.4211, 0.4484, 0.4549, 0.4613]}, {"w": "c2])", "b": [0.4633, 0.4484, 0.497, 0.4613]}, {"w": "#", "b": [0.5055, 0.4484, 0.5139, 0.4613]}, {"w": "returns", "b": [0.5223, 0.4484, 0.5813, 0.4613]}, {"w": "[None,", "b": [0.5898, 0.4484, 0.6404, 0.4613]}, {"w": "None]", "b": [0.6488, 0.4484, 0.691, 0.4613]}]}, {"id": "b_8", "type": "paragraph", "text": "However, you can force the tape to watch any tensors you like, to record every opera‐ tion that involves them. You can then compute gradients with regards to these ten‐ sors, as if they were variables:", "words": [{"w": "However,", "b": [0.1429, 0.4691, 0.2217, 0.4905]}, {"w": "you", "b": [0.2269, 0.4691, 0.2581, 0.4905]}, {"w": "can", "b": [0.2633, 0.4691, 0.2927, 0.4905]}, {"w": "force", "b": [0.2978, 0.4691, 0.34, 0.4905]}, {"w": "the", "b": [0.3452, 0.4691, 0.3715, 0.4905]}, {"w": "tape", "b": [0.3767, 0.4691, 0.4116, 0.4905]}, {"w": "to", "b": [0.4167, 0.4691, 0.4337, 0.4905]}, {"w": "watch", "b": [0.4389, 0.4691, 0.4882, 0.4905]}, {"w": "any", "b": [0.4934, 0.4691, 0.523, 0.4905]}, {"w": "tensors", "b": [0.5282, 0.4691, 0.5884, 0.4905]}, {"w": "you", "b": [0.5936, 0.4691, 0.6248, 0.4905]}, {"w": "like,", "b": [0.63, 0.4691, 0.6648, 0.4905]}, {"w": "to", "b": [0.67, 0.4691, 0.687, 0.4905]}, {"w": "record", "b": [0.6921, 0.4691, 0.7469, 0.4905]}, {"w": "every", "b": [0.752, 0.4691, 0.7973, 0.4905]}, {"w": "opera‐", "b": [0.8025, 0.4691, 0.8571, 0.4905]}, {"w": "tion", "b": [0.1429, 0.4881, 0.1768, 0.5095]}, {"w": "that", "b": [0.1836, 0.4881, 0.2162, 0.5095]}, {"w": "involves", "b": [0.223, 0.4881, 0.2912, 0.5095]}, {"w": "them.", "b": [0.298, 0.4881, 0.3462, 0.5095]}, {"w": "You", "b": [0.353, 0.4881, 0.3853, 0.5095]}, {"w": "can", "b": [0.3922, 0.4881, 0.4215, 0.5095]}, {"w": "then", "b": [0.4283, 0.4881, 0.4661, 0.5095]}, {"w": "compute", "b": [0.4729, 0.4881, 0.5462, 0.5095]}, {"w": "gradients", "b": [0.553, 0.4881, 0.63, 0.5095]}, {"w": "with", "b": [0.6369, 0.4881, 0.6742, 0.5095]}, {"w": "regards", "b": [0.681, 0.4881, 0.7429, 0.5095]}, {"w": "to", "b": [0.7497, 0.4881, 0.7667, 0.5095]}, {"w": "these", "b": [0.7735, 0.4881, 0.8163, 0.5095]}, {"w": "ten‐", "b": [0.8231, 0.4881, 0.8571, 0.5095]}, {"w": "sors,", "b": [0.1429, 0.5071, 0.1812, 0.5286]}, {"w": "as", "b": [0.186, 0.5071, 0.2028, 0.5286]}, {"w": "if", "b": [0.2075, 0.5071, 0.2192, 0.5286]}, {"w": "they", "b": [0.224, 0.5071, 0.2599, 0.5286]}, {"w": "were", "b": [0.2646, 0.5071, 0.3043, 0.5286]}, {"w": "variables:", "b": [0.309, 0.5071, 0.3874, 0.5286]}]}, {"id": "b_9", "type": "equation", "text": "with tf.GradientTape() as tape: tape.watch(c1) tape.watch(c2) z = f(c1, c2)", "words": [{"w": "with", "b": [0.1766, 0.5391, 0.2103, 0.552]}, {"w": "tf.GradientTape()", "b": [0.2188, 0.5391, 0.3621, 0.552]}, {"w": "as", "b": [0.3705, 0.5391, 0.3874, 0.552]}, {"w": "tape:", "b": [0.3958, 0.5391, 0.438, 0.552]}, {"w": "tape.watch(c1)", "b": [0.2103, 0.5545, 0.3284, 0.5674]}, {"w": "tape.watch(c2)", "b": [0.2103, 0.57, 0.3284, 0.5828]}, {"w": "z", "b": [0.2103, 0.5854, 0.2188, 0.5982]}, {"w": "=", "b": [0.2272, 0.5854, 0.2356, 0.5982]}, {"w": "f(c1,", "b": [0.2441, 0.5854, 0.2862, 0.5982]}, {"w": "c2)", "b": [0.2947, 0.5854, 0.3199, 0.5982]}]}, {"id": "b_10", "type": "equation", "text": "gradients = tape.gradient(z, [c1, c2]) # returns [tensor 36., tensor 10.]", "words": [{"w": "gradients", "b": [0.1766, 0.6162, 0.2525, 0.6291]}, {"w": "=", "b": [0.2609, 0.6162, 0.2694, 0.6291]}, {"w": "tape.gradient(z,", "b": [0.2778, 0.6162, 0.4127, 0.6291]}, {"w": "[c1,", "b": [0.4211, 0.6162, 0.4549, 0.6291]}, {"w": "c2])", "b": [0.4633, 0.6162, 0.497, 0.6291]}, {"w": "#", "b": [0.5055, 0.6162, 0.5139, 0.6291]}, {"w": "returns", "b": [0.5223, 0.6162, 0.5814, 0.6291]}, {"w": "[tensor", "b": [0.5898, 0.6162, 0.6488, 0.6291]}, {"w": "36.,", "b": [0.6573, 0.6162, 0.691, 0.6291]}, {"w": "tensor", "b": [0.6994, 0.6162, 0.75, 0.6291]}, {"w": "10.]", "b": [0.7584, 0.6162, 0.7922, 0.6291]}]}, {"id": "b_11", "type": "paragraph", "text": "This can be useful in some cases, for example if you want to implement a regulariza‐ tion loss that penalizes activations that vary a lot when the inputs vary little: the loss will be based on the gradient of the activations with regards to the inputs. Since the inputs are not variables, you would need to tell the tape to watch them.", "words": [{"w": "This", "b": [0.1429, 0.6369, 0.1801, 0.6583]}, {"w": "can", "b": [0.1858, 0.6369, 0.2151, 0.6583]}, {"w": "be", "b": [0.2208, 0.6369, 0.2402, 0.6583]}, {"w": "useful", "b": [0.2459, 0.6369, 0.296, 0.6583]}, {"w": "in", "b": [0.3017, 0.6369, 0.3186, 0.6583]}, {"w": "some", "b": [0.3243, 0.6369, 0.3685, 0.6583]}, {"w": "cases,", "b": [0.3742, 0.6369, 0.421, 0.6583]}, {"w": "for", "b": [0.4267, 0.6369, 0.4512, 0.6583]}, {"w": "example", "b": [0.4569, 0.6369, 0.5265, 0.6583]}, {"w": "if", "b": [0.5322, 0.6369, 0.5439, 0.6583]}, {"w": "you", "b": [0.5496, 0.6369, 0.5808, 0.6583]}, {"w": "want", "b": [0.5865, 0.6369, 0.6273, 0.6583]}, {"w": "to", "b": [0.633, 0.6369, 0.65, 0.6583]}, {"w": "implement", "b": [0.6556, 0.6369, 0.7462, 0.6583]}, {"w": "a", "b": [0.7519, 0.6369, 0.761, 0.6583]}, {"w": "regulariza‐", "b": [0.7667, 0.6369, 0.8571, 0.6583]}, {"w": "tion", "b": [0.1429, 0.6559, 0.1768, 0.6773]}, {"w": "loss", "b": [0.1827, 0.6559, 0.2139, 0.6773]}, {"w": "that", "b": [0.2198, 0.6559, 0.2524, 0.6773]}, {"w": "penalizes", "b": [0.2583, 0.6559, 0.3347, 0.6773]}, {"w": "activations", "b": [0.3406, 0.6559, 0.4305, 0.6773]}, {"w": "that", "b": [0.4364, 0.6559, 0.4689, 0.6773]}, {"w": "vary", "b": [0.4748, 0.6559, 0.5115, 0.6773]}, {"w": "a", "b": [0.5174, 0.6559, 0.5266, 0.6773]}, {"w": "lot", "b": [0.5325, 0.6559, 0.5547, 0.6773]}, {"w": "when", "b": [0.5606, 0.6559, 0.6062, 0.6773]}, {"w": "the", "b": [0.6121, 0.6559, 0.6385, 0.6773]}, {"w": "inputs", "b": [0.6444, 0.6559, 0.6969, 0.6773]}, {"w": "vary", "b": [0.7028, 0.6559, 0.7395, 0.6773]}, {"w": "little:", "b": [0.7454, 0.6559, 0.7878, 0.6773]}, {"w": "the", "b": [0.7937, 0.6559, 0.8201, 0.6773]}, {"w": "loss", "b": [0.826, 0.6559, 0.8571, 0.6773]}, {"w": "will", "b": [0.1429, 0.6749, 0.1733, 0.6964]}, {"w": "be", "b": [0.1796, 0.6749, 0.1991, 0.6964]}, {"w": "based", "b": [0.2055, 0.6749, 0.2527, 0.6964]}, {"w": "on", "b": [0.2591, 0.6749, 0.2811, 0.6964]}, {"w": "the", "b": [0.2875, 0.6749, 0.3138, 0.6964]}, {"w": "gradient", "b": [0.3202, 0.6749, 0.3896, 0.6964]}, {"w": "of", "b": [0.396, 0.6749, 0.4128, 0.6964]}, {"w": "the", "b": [0.4192, 0.6749, 0.4455, 0.6964]}, {"w": "activations", "b": [0.4519, 0.6749, 0.5418, 0.6964]}, {"w": "with", "b": [0.5482, 0.6749, 0.5855, 0.6964]}, {"w": "regards", "b": [0.5919, 0.6749, 0.6538, 0.6964]}, {"w": "to", "b": [0.6601, 0.6749, 0.6771, 0.6964]}, {"w": "the", "b": [0.6835, 0.6749, 0.7098, 0.6964]}, {"w": "inputs.", "b": [0.7162, 0.6749, 0.7735, 0.6964]}, {"w": "Since", "b": [0.7799, 0.6749, 0.8244, 0.6964]}, {"w": "the", "b": [0.8308, 0.6749, 0.8572, 0.6964]}, {"w": "inputs", "b": [0.1429, 0.694, 0.1954, 0.7154]}, {"w": "are", "b": [0.2002, 0.694, 0.2259, 0.7154]}, {"w": "not", "b": [0.2306, 0.694, 0.259, 0.7154]}, {"w": "variables,", "b": [0.2637, 0.694, 0.3421, 0.7154]}, {"w": "you", "b": [0.3468, 0.694, 0.3781, 0.7154]}, {"w": "would", "b": [0.3828, 0.694, 0.435, 0.7154]}, {"w": "need", "b": [0.4397, 0.694, 0.4798, 0.7154]}, {"w": "to", "b": [0.4846, 0.694, 0.5016, 0.7154]}, {"w": "tell", "b": [0.5063, 0.694, 0.532, 0.7154]}, {"w": "the", "b": [0.5368, 0.694, 0.5631, 0.7154]}, {"w": "tape", "b": [0.5678, 0.694, 0.6027, 0.7154]}, {"w": "to", "b": [0.6074, 0.694, 0.6244, 0.7154]}, {"w": "watch", "b": [0.6291, 0.694, 0.6784, 0.7154]}, {"w": "them.", "b": [0.6832, 0.694, 0.7313, 0.7154]}]}, {"id": "b_12", "type": "paragraph", "text": "If you compute the gradient of a list of tensors (e.g., [z1, z2, z3]) with regards to some variables (e.g., [w1, w2]), TensorFlow actually efficiently computes the sum of the gradients of these tensors (i.e., gradient(z1, [w1, w2]), plus gradient(z2, [w1, w2]), plus gradient(z3, [w1, w2])). Due to the way reverse-mode autodiff works, it is not possible to compute the individual gradients (z1, z2 and z3) without actually calling gradient() multiple times (once for z1, once for z2 and once for z3), which requires making the tape persistent (and deleting it afterwards).", "words": [{"w": "If", "b": [0.1429, 0.723, 0.1561, 0.7444]}, {"w": "you", "b": [0.1624, 0.723, 0.1937, 0.7444]}, {"w": "compute", "b": [0.1999, 0.723, 0.2732, 0.7444]}, {"w": "the", "b": [0.2795, 0.723, 0.3058, 0.7444]}, {"w": "gradient", "b": [0.3121, 0.723, 0.3815, 0.7444]}, {"w": "of", "b": [0.3878, 0.723, 0.4046, 0.7444]}, {"w": "a", "b": [0.4108, 0.723, 0.42, 0.7444]}, {"w": "list", "b": [0.4263, 0.723, 0.4511, 0.7444]}, {"w": "of", "b": [0.4574, 0.723, 0.4742, 0.7444]}, {"w": "tensors", "b": [0.4804, 0.723, 0.5407, 0.7444]}, {"w": "(e.g.,", "b": [0.547, 0.723, 0.587, 0.7444]}, {"w": "[z1,", "b": [0.5933, 0.7262, 0.6329, 0.7413]}, {"w": "z2,", "b": [0.6442, 0.7262, 0.6739, 0.7413]}, {"w": "z3])", "b": [0.6853, 0.723, 0.7222, 0.7444]}, {"w": "with", "b": [0.7284, 0.723, 0.7658, 0.7444]}, {"w": "regards", "b": [0.772, 0.723, 0.8339, 0.7444]}, {"w": "to", "b": [0.8402, 0.723, 0.8571, 0.7444]}, {"w": "some", "b": [0.1429, 0.743, 0.187, 0.7644]}, {"w": "variables", "b": [0.193, 0.743, 0.2666, 0.7644]}, {"w": "(e.g.,", "b": [0.2725, 0.743, 0.3126, 0.7644]}, {"w": "[w1,", "b": [0.3185, 0.7461, 0.3581, 0.7612]}, {"w": "w2]),", "b": [0.3691, 0.743, 0.4107, 0.7644]}, {"w": "TensorFlow", "b": [0.4167, 0.743, 0.5149, 0.7644]}, {"w": "actually", "b": [0.5209, 0.743, 0.5855, 0.7644]}, {"w": "efficiently", "b": [0.5914, 0.743, 0.6736, 0.7644]}, {"w": "computes", "b": [0.6795, 0.743, 0.7605, 0.7644]}, {"w": "the", "b": [0.7664, 0.743, 0.7927, 0.7644]}, {"w": "sum", "b": [0.7987, 0.743, 0.8344, 0.7644]}, {"w": "of", "b": [0.8404, 0.743, 0.8571, 0.7644]}, {"w": "the", "b": [0.1429, 0.7629, 0.1692, 0.7843]}, {"w": "gradients", "b": [0.1781, 0.7629, 0.2551, 0.7843]}, {"w": "of", "b": [0.264, 0.7629, 0.2808, 0.7843]}, {"w": "these", "b": [0.2897, 0.7629, 0.3325, 0.7843]}, {"w": "tensors", "b": [0.3414, 0.7629, 0.4017, 0.7843]}, {"w": "(i.e.,", "b": [0.4106, 0.7629, 0.4465, 0.7843]}, {"w": "gradient(z1,", "b": [0.4554, 0.7661, 0.5741, 0.7812]}, {"w": "[w1,", "b": [0.588, 0.7661, 0.6275, 0.7812]}, {"w": "w2]),", "b": [0.6414, 0.7629, 0.6857, 0.7843]}, {"w": "plus", "b": [0.6946, 0.7629, 0.7295, 0.7843]}, {"w": "gradient(z2,", "b": [0.7384, 0.7661, 0.8571, 0.7812]}, {"w": "[w1,", "b": [0.1429, 0.786, 0.1824, 0.8011]}, {"w": "w2]),", "b": [0.1947, 0.7828, 0.239, 0.8043]}, {"w": "plus", "b": [0.2462, 0.7828, 0.2811, 0.8043]}, {"w": "gradient(z3,", "b": [0.2884, 0.786, 0.4071, 0.8011]}, {"w": "[w1,", "b": [0.4194, 0.786, 0.4589, 0.8011]}, {"w": "w2])).", "b": [0.4712, 0.7828, 0.5227, 0.8043]}, {"w": "Due", "b": [0.53, 0.7828, 0.5652, 0.8043]}, {"w": "to", "b": [0.5724, 0.7828, 0.5894, 0.8043]}, {"w": "the", "b": [0.5966, 0.7828, 0.6229, 0.8043]}, {"w": "way", "b": [0.6301, 0.7828, 0.6627, 0.8043]}, {"w": "reverse-mode", "b": [0.6699, 0.7828, 0.7842, 0.8043]}, {"w": "autodiff", "b": [0.7914, 0.7828, 0.8571, 0.8043]}, {"w": "works,", "b": [0.1429, 0.8028, 0.1982, 0.8242]}, {"w": "it", "b": [0.2042, 0.8028, 0.2162, 0.8242]}, {"w": "is", "b": [0.2221, 0.8028, 0.2354, 0.8242]}, {"w": "not", "b": [0.2414, 0.8028, 0.2697, 0.8242]}, {"w": "possible", "b": [0.2757, 0.8028, 0.3429, 0.8242]}, {"w": "to", "b": [0.3488, 0.8028, 0.3658, 0.8242]}, {"w": "compute", "b": [0.3718, 0.8028, 0.4451, 0.8242]}, {"w": "the", "b": [0.4511, 0.8028, 0.4774, 0.8242]}, {"w": "individual", "b": [0.4834, 0.8028, 0.5687, 0.8242]}, {"w": "gradients", "b": [0.5747, 0.8028, 0.6517, 0.8242]}, {"w": "(z1,", "b": [0.6577, 0.8028, 0.6895, 0.8242]}, {"w": "z2", "b": [0.6955, 0.806, 0.7153, 0.8211]}, {"w": "and", "b": [0.7213, 0.8028, 0.7528, 0.8242]}, {"w": "z3)", "b": [0.7588, 0.8028, 0.7858, 0.8242]}, {"w": "without", "b": [0.7918, 0.8028, 0.8572, 0.8242]}, {"w": "actually", "b": [0.1429, 0.8227, 0.2075, 0.8441]}, {"w": "calling", "b": [0.2127, 0.8227, 0.2679, 0.8441]}, {"w": "gradient()", "b": [0.2731, 0.8259, 0.372, 0.841]}, {"w": "multiple", "b": [0.3772, 0.8227, 0.4472, 0.8441]}, {"w": "times", "b": [0.4524, 0.8227, 0.4979, 0.8441]}, {"w": "(once", "b": [0.5031, 0.8227, 0.55, 0.8441]}, {"w": "for", "b": [0.5551, 0.8227, 0.5797, 0.8441]}, {"w": "z1,", "b": [0.5848, 0.8227, 0.6094, 0.8441]}, {"w": "once", "b": [0.6146, 0.8227, 0.6542, 0.8441]}, {"w": "for", "b": [0.6594, 0.8227, 0.6839, 0.8441]}, {"w": "z2", "b": [0.6891, 0.8259, 0.7089, 0.841]}, {"w": "and", "b": [0.7141, 0.8227, 0.7456, 0.8441]}, {"w": "once", "b": [0.7508, 0.8227, 0.7905, 0.8441]}, {"w": "for", "b": [0.7957, 0.8227, 0.8202, 0.8441]}, {"w": "z3),", "b": [0.8254, 0.8227, 0.8571, 0.8441]}, {"w": "which", "b": [0.1429, 0.8418, 0.1938, 0.8632]}, {"w": "requires", "b": [0.1985, 0.8418, 0.2666, 0.8632]}, {"w": "making", "b": [0.2713, 0.8418, 0.3346, 0.8632]}, {"w": "the", "b": [0.3393, 0.8418, 0.3657, 0.8632]}, {"w": "tape", "b": [0.3704, 0.8418, 0.4053, 0.8632]}, {"w": "persistent", "b": [0.41, 0.8418, 0.4909, 0.8632]}, {"w": "(and", "b": [0.4957, 0.8418, 0.5344, 0.8632]}, {"w": "deleting", "b": [0.5391, 0.8418, 0.6062, 0.8632]}, {"w": "it", "b": [0.6109, 0.8418, 0.6229, 0.8632]}, {"w": "afterwards).", "b": [0.6276, 0.8418, 0.7282, 0.8632]}]}, {"id": "b_13", "type": "paragraph", "text": "Customizing Models and Training Algorithms | 391", "words": [{"w": "Customizing", "b": [0.5328, 0.9225, 0.6056, 0.9388]}, {"w": "Models", "b": [0.6084, 0.9225, 0.6507, 0.9388]}, {"w": "and", "b": [0.6535, 0.9225, 0.6759, 0.9388]}, {"w": "Training", "b": [0.6787, 0.9225, 0.7278, 0.9388]}, {"w": "Algorithms", "b": [0.7306, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "391", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 418, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Moreover, it is actually possible to compute second order partial derivatives (the Hes‐ sians, i.e., the partial derivatives of the partial derivatives)! To do this, we need to record the operations that are performed when computing the first-order partial derivatives (the Jacobians): this requires a second tape. Here is how it works:", "words": [{"w": "Moreover,", "b": [0.1429, 0.0791, 0.2284, 0.1005]}, {"w": "it", "b": [0.2334, 0.0791, 0.2454, 0.1005]}, {"w": "is", "b": [0.2504, 0.0791, 0.2636, 0.1005]}, {"w": "actually", "b": [0.2687, 0.0791, 0.3333, 0.1005]}, {"w": "possible", "b": [0.3384, 0.0791, 0.4055, 0.1005]}, {"w": "to", "b": [0.4106, 0.0791, 0.4275, 0.1005]}, {"w": "compute", "b": [0.4326, 0.0791, 0.5059, 0.1005]}, {"w": "second", "b": [0.5109, 0.0791, 0.5693, 0.1005]}, {"w": "order", "b": [0.5743, 0.0791, 0.6202, 0.1005]}, {"w": "partial", "b": [0.6253, 0.0791, 0.6794, 0.1005]}, {"w": "derivatives", "b": [0.6845, 0.0791, 0.7741, 0.1005]}, {"w": "(the", "b": [0.7792, 0.0791, 0.8127, 0.1005]}, {"w": "Hes‐", "b": [0.8178, 0.0791, 0.8571, 0.1005]}, {"w": "sians,", "b": [0.1429, 0.0981, 0.189, 0.1195]}, {"w": "i.e.,", "b": [0.1969, 0.0981, 0.2256, 0.1195]}, {"w": "the", "b": [0.2335, 0.0981, 0.2599, 0.1195]}, {"w": "partial", "b": [0.2678, 0.0981, 0.3219, 0.1195]}, {"w": "derivatives", "b": [0.3298, 0.0981, 0.4195, 0.1195]}, {"w": "of", "b": [0.4274, 0.0981, 0.4442, 0.1195]}, {"w": "the", "b": [0.4521, 0.0981, 0.4784, 0.1195]}, {"w": "partial", "b": [0.4863, 0.0981, 0.5405, 0.1195]}, {"w": "derivatives)!", "b": [0.5484, 0.0981, 0.651, 0.1195]}, {"w": "To", "b": [0.6589, 0.0981, 0.6803, 0.1195]}, {"w": "do", "b": [0.6882, 0.0981, 0.7098, 0.1195]}, {"w": "this,", "b": [0.7177, 0.0981, 0.7532, 0.1195]}, {"w": "we", "b": [0.7611, 0.0981, 0.7842, 0.1195]}, {"w": "need", "b": [0.7921, 0.0981, 0.8323, 0.1195]}, {"w": "to", "b": [0.8402, 0.0981, 0.8571, 0.1195]}, {"w": "record", "b": [0.1429, 0.1172, 0.1976, 0.1386]}, {"w": "the", "b": [0.207, 0.1172, 0.2333, 0.1386]}, {"w": "operations", "b": [0.2426, 0.1172, 0.3311, 0.1386]}, {"w": "that", "b": [0.3404, 0.1172, 0.373, 0.1386]}, {"w": "are", "b": [0.3824, 0.1172, 0.4081, 0.1386]}, {"w": "performed", "b": [0.4174, 0.1172, 0.5064, 0.1386]}, {"w": "when", "b": [0.5157, 0.1172, 0.5613, 0.1386]}, {"w": "computing", "b": [0.5707, 0.1172, 0.6618, 0.1386]}, {"w": "the", "b": [0.6712, 0.1172, 0.6975, 0.1386]}, {"w": "first-order", "b": [0.7068, 0.1172, 0.7937, 0.1386]}, {"w": "partial", "b": [0.803, 0.1172, 0.8572, 0.1386]}, {"w": "derivatives", "b": [0.1429, 0.1362, 0.2325, 0.1576]}, {"w": "(the", "b": [0.2372, 0.1362, 0.2708, 0.1576]}, {"w": "Jacobians):", "b": [0.2755, 0.1362, 0.3667, 0.1576]}, {"w": "this", "b": [0.3714, 0.1362, 0.4021, 0.1576]}, {"w": "requires", "b": [0.4068, 0.1362, 0.4749, 0.1576]}, {"w": "a", "b": [0.4797, 0.1362, 0.4888, 0.1576]}, {"w": "second", "b": [0.4935, 0.1362, 0.5519, 0.1576]}, {"w": "tape.", "b": [0.5566, 0.1362, 0.5962, 0.1576]}, {"w": "Here", "b": [0.601, 0.1362, 0.6418, 0.1576]}, {"w": "is", "b": [0.6466, 0.1362, 0.6598, 0.1576]}, {"w": "how", "b": [0.6645, 0.1362, 0.7005, 0.1576]}, {"w": "it", "b": [0.7053, 0.1362, 0.7172, 0.1576]}, {"w": "works:", "b": [0.7219, 0.1362, 0.7773, 0.1576]}]}, {"id": "b_1", "type": "paragraph", "text": "with tf.GradientTape(persistent=True) as hessian_tape: with tf.GradientTape() as jacobian_tape: z = f(w1, w2) jacobians = jacobian_tape.gradient(z, [w1, w2]) hessians = [hessian_tape.gradient(jacobian, [w1, w2]) for jacobian in jacobians] del hessian_tape", "words": [{"w": "with", "b": [0.1766, 0.1682, 0.2103, 0.181]}, {"w": "tf.GradientTape(persistent=True)", "b": [0.2187, 0.1682, 0.4886, 0.181]}, {"w": "as", "b": [0.497, 0.1682, 0.5139, 0.181]}, {"w": "hessian_tape:", "b": [0.5223, 0.1682, 0.6319, 0.181]}, {"w": "with", "b": [0.2103, 0.1836, 0.244, 0.1964]}, {"w": "tf.GradientTape()", "b": [0.2525, 0.1836, 0.3958, 0.1964]}, {"w": "as", "b": [0.4043, 0.1836, 0.4211, 0.1964]}, {"w": "jacobian_tape:", "b": [0.4296, 0.1836, 0.5476, 0.1964]}, {"w": "z", "b": [0.244, 0.199, 0.2525, 0.2119]}, {"w": "=", "b": [0.2609, 0.199, 0.2693, 0.2119]}, {"w": "f(w1,", "b": [0.2778, 0.199, 0.3199, 0.2119]}, {"w": "w2)", "b": [0.3284, 0.199, 0.3537, 0.2119]}, {"w": "jacobians", "b": [0.2103, 0.2144, 0.2862, 0.2273]}, {"w": "=", "b": [0.2946, 0.2144, 0.3031, 0.2273]}, {"w": "jacobian_tape.gradient(z,", "b": [0.3115, 0.2144, 0.5223, 0.2273]}, {"w": "[w1,", "b": [0.5307, 0.2144, 0.5645, 0.2273]}, {"w": "w2])", "b": [0.5729, 0.2144, 0.6066, 0.2273]}, {"w": "hessians", "b": [0.1766, 0.2299, 0.244, 0.2427]}, {"w": "=", "b": [0.2525, 0.2299, 0.2609, 0.2427]}, {"w": "[hessian_tape.gradient(jacobian,", "b": [0.2693, 0.2299, 0.5392, 0.2427]}, {"w": "[w1,", "b": [0.5476, 0.2299, 0.5813, 0.2427]}, {"w": "w2])", "b": [0.5898, 0.2299, 0.6235, 0.2427]}, {"w": "for", "b": [0.2778, 0.2453, 0.3031, 0.2581]}, {"w": "jacobian", "b": [0.3115, 0.2453, 0.379, 0.2581]}, {"w": "in", "b": [0.3874, 0.2453, 0.4043, 0.2581]}, {"w": "jacobians]", "b": [0.4127, 0.2453, 0.497, 0.2581]}, {"w": "del", "b": [0.1766, 0.2607, 0.2019, 0.2735]}, {"w": "hessian_tape", "b": [0.2103, 0.2607, 0.3115, 0.2735]}]}, {"id": "b_2", "type": "paragraph", "text": "The inner tape is used to compute the Jacobians, as we did earlier. The outer tape is used to compute the partial derivatives of each Jacobian. Since we need to call gradi ent() once for each Jacobian (or else we would get the sum of the partial derivatives over all the Jabobians, as explained earlier), we need the outer tape to be persistent, so we delete it at the end. The Jacobians are obviously the same as earlier (36 and 5), but now we also have the Hessians:", "words": [{"w": "The", "b": [0.1429, 0.2813, 0.1757, 0.3027]}, {"w": "inner", "b": [0.1819, 0.2813, 0.2269, 0.3027]}, {"w": "tape", "b": [0.2331, 0.2813, 0.268, 0.3027]}, {"w": "is", "b": [0.2742, 0.2813, 0.2874, 0.3027]}, {"w": "used", "b": [0.2937, 0.2813, 0.3322, 0.3027]}, {"w": "to", "b": [0.3384, 0.2813, 0.3554, 0.3027]}, {"w": "compute", "b": [0.3616, 0.2813, 0.4349, 0.3027]}, {"w": "the", "b": [0.4412, 0.2813, 0.4675, 0.3027]}, {"w": "Jacobians,", "b": [0.4737, 0.2813, 0.5577, 0.3027]}, {"w": "as", "b": [0.5639, 0.2813, 0.5807, 0.3027]}, {"w": "we", "b": [0.5869, 0.2813, 0.61, 0.3027]}, {"w": "did", "b": [0.6163, 0.2813, 0.6438, 0.3027]}, {"w": "earlier.", "b": [0.6501, 0.2813, 0.7067, 0.3027]}, {"w": "The", "b": [0.7129, 0.2813, 0.7457, 0.3027]}, {"w": "outer", "b": [0.752, 0.2813, 0.7966, 0.3027]}, {"w": "tape", "b": [0.8028, 0.2813, 0.8377, 0.3027]}, {"w": "is", "b": [0.8439, 0.2813, 0.8571, 0.3027]}, {"w": "used", "b": [0.1428, 0.3013, 0.1814, 0.3227]}, {"w": "to", "b": [0.1872, 0.3013, 0.2041, 0.3227]}, {"w": "compute", "b": [0.2099, 0.3013, 0.2832, 0.3227]}, {"w": "the", "b": [0.289, 0.3013, 0.3153, 0.3227]}, {"w": "partial", "b": [0.321, 0.3013, 0.3752, 0.3227]}, {"w": "derivatives", "b": [0.3809, 0.3013, 0.4706, 0.3227]}, {"w": "of", "b": [0.4764, 0.3013, 0.4931, 0.3227]}, {"w": "each", "b": [0.4989, 0.3013, 0.5368, 0.3227]}, {"w": "Jacobian.", "b": [0.5426, 0.3013, 0.6189, 0.3227]}, {"w": "Since", "b": [0.6247, 0.3013, 0.6692, 0.3227]}, {"w": "we", "b": [0.6749, 0.3013, 0.6981, 0.3227]}, {"w": "need", "b": [0.7038, 0.3013, 0.7439, 0.3227]}, {"w": "to", "b": [0.7497, 0.3013, 0.7667, 0.3227]}, {"w": "call", "b": [0.7724, 0.3013, 0.8009, 0.3227]}, {"w": "gradi", "b": [0.8067, 0.3045, 0.8562, 0.3195]}, {"w": "ent()", "b": [0.1428, 0.3244, 0.1923, 0.3395]}, {"w": "once", "b": [0.198, 0.3212, 0.2377, 0.3426]}, {"w": "for", "b": [0.2434, 0.3212, 0.2679, 0.3426]}, {"w": "each", "b": [0.2737, 0.3212, 0.3116, 0.3426]}, {"w": "Jacobian", "b": [0.3173, 0.3212, 0.3889, 0.3426]}, {"w": "(or", "b": [0.3946, 0.3212, 0.4201, 0.3426]}, {"w": "else", "b": [0.4258, 0.3212, 0.4565, 0.3426]}, {"w": "we", "b": [0.4622, 0.3212, 0.4853, 0.3426]}, {"w": "would", "b": [0.491, 0.3212, 0.5432, 0.3426]}, {"w": "get", "b": [0.5489, 0.3212, 0.5739, 0.3426]}, {"w": "the", "b": [0.5796, 0.3212, 0.6059, 0.3426]}, {"w": "sum", "b": [0.6116, 0.3212, 0.6474, 0.3426]}, {"w": "of", "b": [0.6531, 0.3212, 0.6699, 0.3426]}, {"w": "the", "b": [0.6756, 0.3212, 0.7019, 0.3426]}, {"w": "partial", "b": [0.7076, 0.3212, 0.7618, 0.3426]}, {"w": "derivatives", "b": [0.7675, 0.3212, 0.8571, 0.3426]}, {"w": "over", "b": [0.1429, 0.3403, 0.1797, 0.3617]}, {"w": "all", "b": [0.1846, 0.3403, 0.2043, 0.3617]}, {"w": "the", "b": [0.2092, 0.3403, 0.2355, 0.3617]}, {"w": "Jabobians,", "b": [0.2404, 0.3403, 0.3262, 0.3617]}, {"w": "as", "b": [0.3311, 0.3403, 0.3479, 0.3617]}, {"w": "explained", "b": [0.3527, 0.3403, 0.4336, 0.3617]}, {"w": "earlier),", "b": [0.4385, 0.3403, 0.5036, 0.3617]}, {"w": "we", "b": [0.5085, 0.3403, 0.5316, 0.3617]}, {"w": "need", "b": [0.5365, 0.3403, 0.5767, 0.3617]}, {"w": "the", "b": [0.5816, 0.3403, 0.6079, 0.3617]}, {"w": "outer", "b": [0.6128, 0.3403, 0.6574, 0.3617]}, {"w": "tape", "b": [0.6623, 0.3403, 0.6972, 0.3617]}, {"w": "to", "b": [0.7021, 0.3403, 0.7191, 0.3617]}, {"w": "be", "b": [0.724, 0.3403, 0.7434, 0.3617]}, {"w": "persistent,", "b": [0.7483, 0.3403, 0.834, 0.3617]}, {"w": "so", "b": [0.8389, 0.3403, 0.8571, 0.3617]}, {"w": "we", "b": [0.1429, 0.3593, 0.166, 0.3807]}, {"w": "delete", "b": [0.1711, 0.3593, 0.2203, 0.3807]}, {"w": "it", "b": [0.2253, 0.3593, 0.2373, 0.3807]}, {"w": "at", "b": [0.2424, 0.3593, 0.2575, 0.3807]}, {"w": "the", "b": [0.2626, 0.3593, 0.2889, 0.3807]}, {"w": "end.", "b": [0.294, 0.3593, 0.33, 0.3807]}, {"w": "The", "b": [0.3351, 0.3593, 0.3679, 0.3807]}, {"w": "Jacobians", "b": [0.373, 0.3593, 0.4522, 0.3807]}, {"w": "are", "b": [0.4573, 0.3593, 0.483, 0.3807]}, {"w": "obviously", "b": [0.4881, 0.3593, 0.5687, 0.3807]}, {"w": "the", "b": [0.5738, 0.3593, 0.6001, 0.3807]}, {"w": "same", "b": [0.6052, 0.3593, 0.6479, 0.3807]}, {"w": "as", "b": [0.653, 0.3593, 0.6698, 0.3807]}, {"w": "earlier", "b": [0.6749, 0.3593, 0.7281, 0.3807]}, {"w": "(36", "b": [0.7332, 0.3593, 0.7604, 0.3807]}, {"w": "and", "b": [0.7655, 0.3593, 0.797, 0.3807]}, {"w": "5),", "b": [0.8021, 0.3593, 0.8241, 0.3807]}, {"w": "but", "b": [0.8291, 0.3593, 0.8571, 0.3807]}, {"w": "now", "b": [0.1429, 0.3784, 0.1791, 0.3998]}, {"w": "we", "b": [0.1839, 0.3784, 0.207, 0.3998]}, {"w": "also", "b": [0.2117, 0.3784, 0.2444, 0.3998]}, {"w": "have", "b": [0.2491, 0.3784, 0.2875, 0.3998]}, {"w": "the", "b": [0.2923, 0.3784, 0.3186, 0.3998]}, {"w": "Hessians:", "b": [0.3233, 0.3784, 0.4014, 0.3998]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> hessians # dz_dw1_dw1, dz_dw1_dw2, dz_dw2_dw1, dz_dw2_dw2 [[, ], [, None]]", "words": [{"w": ">>>", "b": [0.1766, 0.4103, 0.2019, 0.4232]}, {"w": "hessians", "b": [0.2103, 0.4103, 0.2778, 0.4232]}, {"w": "#", "b": [0.2862, 0.4103, 0.2946, 0.4232]}, {"w": "dz_dw1_dw1,", "b": [0.3031, 0.4103, 0.3958, 0.4232]}, {"w": "dz_dw1_dw2,", "b": [0.4043, 0.4103, 0.497, 0.4232]}, {"w": "dz_dw2_dw1,", "b": [0.5055, 0.4103, 0.5982, 0.4232]}, {"w": "dz_dw2_dw2", "b": [0.6066, 0.4103, 0.691, 0.4232]}, {"w": "[[,", "b": [0.5982, 0.4258, 0.691, 0.4386]}, {"w": "],", "b": [0.5982, 0.4412, 0.6994, 0.454]}, {"w": "[,", "b": [0.5982, 0.4566, 0.691, 0.4694]}, {"w": "None]]", "b": [0.6994, 0.4566, 0.75, 0.4694]}]}, {"id": "b_4", "type": "paragraph", "text": "Let’s verify these Hessians. The first two are the partial derivatives of 6 * w1 + 2 * w2 (which is, as we saw earlier, the partial derivative of f with regards to w1), with regards to w1 and w2. The result is correct: 6 for w1 and 2 for w2. The next two are the partial derivatives of 2 * w1 (the partial derivative of f with regards to w2), with regards to w1 and w2, which are 2 for w1 and 0 for w2. Note that TensorFlow returns None instead of 0 since w2 does not appear at all in 2 * w1. TensorFlow also returns None when you use an operation whose gradients are not defined (e.g., tf.argmax()).", "words": [{"w": "Let’s", "b": [0.1429, 0.4781, 0.179, 0.4995]}, {"w": "verify", "b": [0.184, 0.4781, 0.2319, 0.4995]}, {"w": "these", "b": [0.2369, 0.4781, 0.2797, 0.4995]}, {"w": "Hessians.", "b": [0.2847, 0.4781, 0.3628, 0.4995]}, {"w": "The", "b": [0.3677, 0.4781, 0.4006, 0.4995]}, {"w": "first", "b": [0.4055, 0.4781, 0.439, 0.4995]}, {"w": "two", "b": [0.444, 0.4781, 0.4752, 0.4995]}, {"w": "are", "b": [0.4802, 0.4781, 0.5059, 0.4995]}, {"w": "the", "b": [0.5109, 0.4781, 0.5372, 0.4995]}, {"w": "partial", "b": [0.5422, 0.4781, 0.5963, 0.4995]}, {"w": "derivatives", "b": [0.6013, 0.4781, 0.6909, 0.4995]}, {"w": "of", "b": [0.6959, 0.4781, 0.7127, 0.4995]}, {"w": "6", "b": [0.7177, 0.4813, 0.7276, 0.4964]}, {"w": "*", "b": [0.7375, 0.4813, 0.7473, 0.4964]}, {"w": "w1", "b": [0.7572, 0.4813, 0.777, 0.4964]}, {"w": "+", "b": [0.7825, 0.4813, 0.7924, 0.4964]}, {"w": "2", "b": [0.7973, 0.4813, 0.8072, 0.4964]}, {"w": "*", "b": [0.8171, 0.4813, 0.827, 0.4964]}, {"w": "w2", "b": [0.8369, 0.4813, 0.8567, 0.4964]}, {"w": "(which", "b": [0.1429, 0.4981, 0.201, 0.5195]}, {"w": "is,", "b": [0.2101, 0.4981, 0.2281, 0.5195]}, {"w": "as", "b": [0.2372, 0.4981, 0.254, 0.5195]}, {"w": "we", "b": [0.2631, 0.4981, 0.2862, 0.5195]}, {"w": "saw", "b": [0.2953, 0.4981, 0.326, 0.5195]}, {"w": "earlier,", "b": [0.3351, 0.4981, 0.3917, 0.5195]}, {"w": "the", "b": [0.4008, 0.4981, 0.4271, 0.5195]}, {"w": "partial", "b": [0.4362, 0.4981, 0.4904, 0.5195]}, {"w": "derivative", "b": [0.4995, 0.4981, 0.5815, 0.5195]}, {"w": "of", "b": [0.5906, 0.4981, 0.6074, 0.5195]}, {"w": "f", "b": [0.6165, 0.5013, 0.6264, 0.5163]}, {"w": "with", "b": [0.6355, 0.4981, 0.6728, 0.5195]}, {"w": "regards", "b": [0.6819, 0.4981, 0.7438, 0.5195]}, {"w": "to", "b": [0.7529, 0.4981, 0.7699, 0.5195]}, {"w": "w1),", "b": [0.779, 0.4981, 0.8107, 0.5195]}, {"w": "with", "b": [0.8198, 0.4981, 0.8572, 0.5195]}, {"w": "regards", "b": [0.1429, 0.518, 0.2047, 0.5394]}, {"w": "to", "b": [0.21, 0.518, 0.227, 0.5394]}, {"w": "w1", "b": [0.2322, 0.5212, 0.252, 0.5363]}, {"w": "and", "b": [0.2573, 0.518, 0.2888, 0.5394]}, {"w": "w2.", "b": [0.2941, 0.518, 0.3186, 0.5394]}, {"w": "The", "b": [0.3239, 0.518, 0.3567, 0.5394]}, {"w": "result", "b": [0.362, 0.518, 0.4089, 0.5394]}, {"w": "is", "b": [0.4142, 0.518, 0.4274, 0.5394]}, {"w": "correct:", "b": [0.4327, 0.518, 0.4964, 0.5394]}, {"w": "6", "b": [0.5016, 0.518, 0.5116, 0.5394]}, {"w": "for", "b": [0.5169, 0.518, 0.5414, 0.5394]}, {"w": "w1", "b": [0.5467, 0.5212, 0.5665, 0.5363]}, {"w": "and", "b": [0.5718, 0.518, 0.6033, 0.5394]}, {"w": "2", "b": [0.6086, 0.518, 0.6186, 0.5394]}, {"w": "for", "b": [0.6239, 0.518, 0.6484, 0.5394]}, {"w": "w2.", "b": [0.6537, 0.518, 0.6782, 0.5394]}, {"w": "The", "b": [0.6835, 0.518, 0.7163, 0.5394]}, {"w": "next", "b": [0.7216, 0.518, 0.758, 0.5394]}, {"w": "two", "b": [0.7633, 0.518, 0.7945, 0.5394]}, {"w": "are", "b": [0.7998, 0.518, 0.8255, 0.5394]}, {"w": "the", "b": [0.8308, 0.518, 0.8571, 0.5394]}, {"w": "partial", "b": [0.1429, 0.538, 0.197, 0.5594]}, {"w": "derivatives", "b": [0.2052, 0.538, 0.2948, 0.5594]}, {"w": "of", "b": [0.303, 0.538, 0.3198, 0.5594]}, {"w": "2", "b": [0.3279, 0.5411, 0.3378, 0.5562]}, {"w": "*", "b": [0.351, 0.5411, 0.3609, 0.5562]}, {"w": "w1", "b": [0.3741, 0.5411, 0.3939, 0.5562]}, {"w": "(the", "b": [0.402, 0.538, 0.4356, 0.5594]}, {"w": "partial", "b": [0.4437, 0.538, 0.4979, 0.5594]}, {"w": "derivative", "b": [0.506, 0.538, 0.588, 0.5594]}, {"w": "of", "b": [0.5962, 0.538, 0.613, 0.5594]}, {"w": "f", "b": [0.6212, 0.5411, 0.6311, 0.5562]}, {"w": "with", "b": [0.6392, 0.538, 0.6766, 0.5594]}, {"w": "regards", "b": [0.6847, 0.538, 0.7466, 0.5594]}, {"w": "to", "b": [0.7548, 0.538, 0.7717, 0.5594]}, {"w": "w2),", "b": [0.7799, 0.538, 0.8116, 0.5594]}, {"w": "with", "b": [0.8198, 0.538, 0.8571, 0.5594]}, {"w": "regards", "b": [0.1429, 0.5579, 0.2047, 0.5793]}, {"w": "to", "b": [0.2109, 0.5579, 0.2279, 0.5793]}, {"w": "w1", "b": [0.2341, 0.5611, 0.2539, 0.5762]}, {"w": "and", "b": [0.2601, 0.5579, 0.2917, 0.5793]}, {"w": "w2,", "b": [0.2979, 0.5579, 0.3224, 0.5793]}, {"w": "which", "b": [0.3286, 0.5579, 0.3795, 0.5793]}, {"w": "are", "b": [0.3858, 0.5579, 0.4115, 0.5793]}, {"w": "2", "b": [0.4177, 0.5579, 0.4277, 0.5793]}, {"w": "for", "b": [0.4339, 0.5579, 0.4584, 0.5793]}, {"w": "w1", "b": [0.4646, 0.5611, 0.4844, 0.5762]}, {"w": "and", "b": [0.4907, 0.5579, 0.5222, 0.5793]}, {"w": "0", "b": [0.5284, 0.5579, 0.5384, 0.5793]}, {"w": "for", "b": [0.5446, 0.5579, 0.5691, 0.5793]}, {"w": "w2.", "b": [0.5754, 0.5579, 0.5999, 0.5793]}, {"w": "Note", "b": [0.6061, 0.5579, 0.6469, 0.5793]}, {"w": "that", "b": [0.6531, 0.5579, 0.6857, 0.5793]}, {"w": "TensorFlow", "b": [0.6919, 0.5579, 0.7902, 0.5793]}, {"w": "returns", "b": [0.7964, 0.5579, 0.8571, 0.5793]}, {"w": "None", "b": [0.1429, 0.581, 0.1824, 0.5961]}, {"w": "instead", "b": [0.1886, 0.5778, 0.2486, 0.5993]}, {"w": "of", "b": [0.2548, 0.5778, 0.2716, 0.5993]}, {"w": "0", "b": [0.2778, 0.5778, 0.2878, 0.5993]}, {"w": "since", "b": [0.2939, 0.5778, 0.3362, 0.5993]}, {"w": "w2", "b": [0.3424, 0.581, 0.3622, 0.5961]}, {"w": "does", "b": [0.3684, 0.5778, 0.4065, 0.5993]}, {"w": "not", "b": [0.4127, 0.5778, 0.441, 0.5993]}, {"w": "appear", "b": [0.4472, 0.5778, 0.5035, 0.5993]}, {"w": "at", "b": [0.5097, 0.5778, 0.5248, 0.5993]}, {"w": "all", "b": [0.531, 0.5778, 0.5507, 0.5993]}, {"w": "in", "b": [0.5569, 0.5778, 0.5738, 0.5993]}, {"w": "2", "b": [0.58, 0.581, 0.5899, 0.5961]}, {"w": "*", "b": [0.6012, 0.581, 0.6111, 0.5961]}, {"w": "w1.", "b": [0.6224, 0.5778, 0.6469, 0.5993]}, {"w": "TensorFlow", "b": [0.6531, 0.5778, 0.7513, 0.5993]}, {"w": "also", "b": [0.7575, 0.5778, 0.7902, 0.5993]}, {"w": "returns", "b": [0.7964, 0.5778, 0.8571, 0.5993]}, {"w": "None", "b": [0.1428, 0.601, 0.1824, 0.6161]}, {"w": "when", "b": [0.1872, 0.5978, 0.2328, 0.6192]}, {"w": "you", "b": [0.2375, 0.5978, 0.2688, 0.6192]}, {"w": "use", "b": [0.2735, 0.5978, 0.3011, 0.6192]}, {"w": "an", "b": [0.3058, 0.5978, 0.3263, 0.6192]}, {"w": "operation", "b": [0.3311, 0.5978, 0.4119, 0.6192]}, {"w": "whose", "b": [0.4166, 0.5978, 0.4692, 0.6192]}, {"w": "gradients", "b": [0.4739, 0.5978, 0.551, 0.6192]}, {"w": "are", "b": [0.5557, 0.5978, 0.5814, 0.6192]}, {"w": "not", "b": [0.5861, 0.5978, 0.6145, 0.6192]}, {"w": "defined", "b": [0.6192, 0.5978, 0.6821, 0.6192]}, {"w": "(e.g.,", "b": [0.6868, 0.5978, 0.7269, 0.6192]}, {"w": "tf.argmax()).", "b": [0.7316, 0.5978, 0.8524, 0.6192]}]}, {"id": "b_5", "type": "paragraph", "text": "In some rare cases you may want to stop gradients from backpropagating through some part of your neural network. To do this, you must use the tf.stop_gradient() function: it just returns its inputs during the forward pass (like tf.identity()), but it does not let gradients through during backpropagation (it acts like a constant). For example:", "words": [{"w": "In", "b": [0.1428, 0.6259, 0.1613, 0.6473]}, {"w": "some", "b": [0.1688, 0.6259, 0.213, 0.6473]}, {"w": "rare", "b": [0.2205, 0.6259, 0.254, 0.6473]}, {"w": "cases", "b": [0.2615, 0.6259, 0.3036, 0.6473]}, {"w": "you", "b": [0.3111, 0.6259, 0.3423, 0.6473]}, {"w": "may", "b": [0.3498, 0.6259, 0.3852, 0.6473]}, {"w": "want", "b": [0.3927, 0.6259, 0.4335, 0.6473]}, {"w": "to", "b": [0.4409, 0.6259, 0.4579, 0.6473]}, {"w": "stop", "b": [0.4654, 0.6259, 0.501, 0.6473]}, {"w": "gradients", "b": [0.5085, 0.6259, 0.5855, 0.6473]}, {"w": "from", "b": [0.593, 0.6259, 0.6346, 0.6473]}, {"w": "backpropagating", "b": [0.6421, 0.6259, 0.7819, 0.6473]}, {"w": "through", "b": [0.7894, 0.6259, 0.8571, 0.6473]}, {"w": "some", "b": [0.1429, 0.6459, 0.187, 0.6673]}, {"w": "part", "b": [0.1923, 0.6459, 0.2265, 0.6673]}, {"w": "of", "b": [0.2318, 0.6459, 0.2486, 0.6673]}, {"w": "your", "b": [0.2539, 0.6459, 0.2929, 0.6673]}, {"w": "neural", "b": [0.2982, 0.6459, 0.3516, 0.6673]}, {"w": "network.", "b": [0.3569, 0.6459, 0.4312, 0.6673]}, {"w": "To", "b": [0.4365, 0.6459, 0.458, 0.6673]}, {"w": "do", "b": [0.4633, 0.6459, 0.4849, 0.6673]}, {"w": "this,", "b": [0.4902, 0.6459, 0.5257, 0.6673]}, {"w": "you", "b": [0.5309, 0.6459, 0.5622, 0.6673]}, {"w": "must", "b": [0.5675, 0.6459, 0.6092, 0.6673]}, {"w": "use", "b": [0.6145, 0.6459, 0.6421, 0.6673]}, {"w": "the", "b": [0.6474, 0.6459, 0.6737, 0.6673]}, {"w": "tf.stop_gradient()", "b": [0.679, 0.649, 0.8571, 0.6641]}, {"w": "function:", "b": [0.1429, 0.6658, 0.219, 0.6872]}, {"w": "it", "b": [0.225, 0.6658, 0.2369, 0.6872]}, {"w": "just", "b": [0.2429, 0.6658, 0.2733, 0.6872]}, {"w": "returns", "b": [0.2792, 0.6658, 0.34, 0.6872]}, {"w": "its", "b": [0.346, 0.6658, 0.3655, 0.6872]}, {"w": "inputs", "b": [0.3715, 0.6658, 0.4241, 0.6872]}, {"w": "during", "b": [0.43, 0.6658, 0.4865, 0.6872]}, {"w": "the", "b": [0.4925, 0.6658, 0.5188, 0.6872]}, {"w": "forward", "b": [0.5248, 0.6658, 0.5921, 0.6872]}, {"w": "pass", "b": [0.598, 0.6658, 0.6334, 0.6872]}, {"w": "(like", "b": [0.6394, 0.6658, 0.6766, 0.6872]}, {"w": "tf.identity()),", "b": [0.6826, 0.6658, 0.8232, 0.6872]}, {"w": "but", "b": [0.8291, 0.6658, 0.8571, 0.6872]}, {"w": "it", "b": [0.1428, 0.6848, 0.1548, 0.7063]}, {"w": "does", "b": [0.1602, 0.6848, 0.1984, 0.7063]}, {"w": "not", "b": [0.2038, 0.6848, 0.2322, 0.7063]}, {"w": "let", "b": [0.2376, 0.6848, 0.2581, 0.7063]}, {"w": "gradients", "b": [0.2635, 0.6848, 0.3406, 0.7063]}, {"w": "through", "b": [0.3461, 0.6848, 0.4138, 0.7063]}, {"w": "during", "b": [0.4193, 0.6848, 0.4758, 0.7063]}, {"w": "backpropagation", "b": [0.4812, 0.6848, 0.6219, 0.7063]}, {"w": "(it", "b": [0.6273, 0.6848, 0.6465, 0.7063]}, {"w": "acts", "b": [0.6519, 0.6848, 0.6839, 0.7063]}, {"w": "like", "b": [0.6893, 0.6848, 0.7194, 0.7063]}, {"w": "a", "b": [0.7248, 0.6848, 0.734, 0.7063]}, {"w": "constant).", "b": [0.7394, 0.6848, 0.8227, 0.7063]}, {"w": "For", "b": [0.8282, 0.6848, 0.8571, 0.7063]}, {"w": "example:", "b": [0.1429, 0.7039, 0.2172, 0.7253]}]}, {"id": "b_6", "type": "equation", "text": "def f(w1, w2): return 3 * w1 ** 2 + tf.stop_gradient(2 * w1 * w2)", "words": [{"w": "def", "b": [0.1766, 0.7359, 0.2019, 0.7487]}, {"w": "f(w1,", "b": [0.2103, 0.7359, 0.2525, 0.7487]}, {"w": "w2):", "b": [0.2609, 0.7359, 0.2946, 0.7487]}, {"w": "return", "b": [0.2103, 0.7513, 0.2609, 0.7641]}, {"w": "3", "b": [0.2693, 0.7513, 0.2778, 0.7641]}, {"w": "*", "b": [0.2862, 0.7513, 0.2946, 0.7641]}, {"w": "w1", "b": [0.3031, 0.7513, 0.3199, 0.7641]}, {"w": "**", "b": [0.3284, 0.7513, 0.3452, 0.7641]}, {"w": "2", "b": [0.3537, 0.7513, 0.3621, 0.7641]}, {"w": "+", "b": [0.3705, 0.7513, 0.379, 0.7641]}, {"w": "tf.stop_gradient(2", "b": [0.3874, 0.7513, 0.5392, 0.7641]}, {"w": "*", "b": [0.5476, 0.7513, 0.556, 0.7641]}, {"w": "w1", "b": [0.5645, 0.7513, 0.5813, 0.7641]}, {"w": "*", "b": [0.5898, 0.7513, 0.5982, 0.7641]}, {"w": "w2)", "b": [0.6066, 0.7513, 0.6319, 0.7641]}]}, {"id": "b_7", "type": "paragraph", "text": "with tf.GradientTape() as tape: z = f(w1, w2) # same result as without stop_gradient()", "words": [{"w": "with", "b": [0.1766, 0.7821, 0.2103, 0.795]}, {"w": "tf.GradientTape()", "b": [0.2187, 0.7821, 0.3621, 0.795]}, {"w": "as", "b": [0.3705, 0.7821, 0.3874, 0.795]}, {"w": "tape:", "b": [0.3958, 0.7821, 0.438, 0.795]}, {"w": "z", "b": [0.2103, 0.7975, 0.2187, 0.8104]}, {"w": "=", "b": [0.2272, 0.7975, 0.2356, 0.8104]}, {"w": "f(w1,", "b": [0.244, 0.7975, 0.2862, 0.8104]}, {"w": "w2)", "b": [0.2946, 0.7975, 0.3199, 0.8104]}, {"w": "#", "b": [0.3284, 0.7975, 0.3368, 0.8104]}, {"w": "same", "b": [0.3452, 0.7975, 0.379, 0.8104]}, {"w": "result", "b": [0.3874, 0.7975, 0.438, 0.8104]}, {"w": "as", "b": [0.4464, 0.7975, 0.4633, 0.8104]}, {"w": "without", "b": [0.4717, 0.7975, 0.5307, 0.8104]}, {"w": "stop_gradient()", "b": [0.5392, 0.7975, 0.6657, 0.8104]}]}, {"id": "b_8", "type": "equation", "text": "gradients = tape.gradient(z, [w1, w2]) # => returns [tensor 30., None]", "words": [{"w": "gradients", "b": [0.1766, 0.8284, 0.2525, 0.8412]}, {"w": "=", "b": [0.2609, 0.8284, 0.2693, 0.8412]}, {"w": "tape.gradient(z,", "b": [0.2778, 0.8284, 0.4127, 0.8412]}, {"w": "[w1,", "b": [0.4211, 0.8284, 0.4549, 0.8412]}, {"w": "w2])", "b": [0.4633, 0.8284, 0.497, 0.8412]}, {"w": "#", "b": [0.5054, 0.8284, 0.5139, 0.8412]}, {"w": "=>", "b": [0.5223, 0.8284, 0.5392, 0.8412]}, {"w": "returns", "b": [0.5476, 0.8284, 0.6066, 0.8412]}, {"w": "[tensor", "b": [0.6151, 0.8284, 0.6741, 0.8412]}, {"w": "30.,", "b": [0.6825, 0.8284, 0.7163, 0.8412]}, {"w": "None]", "b": [0.7247, 0.8284, 0.7669, 0.8412]}]}, {"id": "b_9", "type": "paragraph", "text": "392 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "392", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2746, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3638, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 419, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Finally, you may occasionally run into some numerical issues when computing gradi‐ ents. For example, if you compute the gradients of the my_softplus() function for large inputs, the result will be NaN:", "words": [{"w": "Finally,", "b": [0.1429, 0.0791, 0.2033, 0.1005]}, {"w": "you", "b": [0.2085, 0.0791, 0.2398, 0.1005]}, {"w": "may", "b": [0.2449, 0.0791, 0.2803, 0.1005]}, {"w": "occasionally", "b": [0.2855, 0.0791, 0.3874, 0.1005]}, {"w": "run", "b": [0.3926, 0.0791, 0.4228, 0.1005]}, {"w": "into", "b": [0.4279, 0.0791, 0.4615, 0.1005]}, {"w": "some", "b": [0.4667, 0.0791, 0.5109, 0.1005]}, {"w": "numerical", "b": [0.516, 0.0791, 0.6006, 0.1005]}, {"w": "issues", "b": [0.6057, 0.0791, 0.6542, 0.1005]}, {"w": "when", "b": [0.6594, 0.0791, 0.705, 0.1005]}, {"w": "computing", "b": [0.7102, 0.0791, 0.8013, 0.1005]}, {"w": "gradi‐", "b": [0.8065, 0.0791, 0.8571, 0.1005]}, {"w": "ents.", "b": [0.1429, 0.099, 0.1815, 0.1204]}, {"w": "For", "b": [0.1885, 0.099, 0.2175, 0.1204]}, {"w": "example,", "b": [0.2246, 0.099, 0.2989, 0.1204]}, {"w": "if", "b": [0.306, 0.099, 0.3177, 0.1204]}, {"w": "you", "b": [0.3248, 0.099, 0.3561, 0.1204]}, {"w": "compute", "b": [0.3632, 0.099, 0.4364, 0.1204]}, {"w": "the", "b": [0.4435, 0.099, 0.4699, 0.1204]}, {"w": "gradients", "b": [0.477, 0.099, 0.554, 0.1204]}, {"w": "of", "b": [0.5611, 0.099, 0.5779, 0.1204]}, {"w": "the", "b": [0.585, 0.099, 0.6113, 0.1204]}, {"w": "my_softplus()", "b": [0.6184, 0.1022, 0.747, 0.1173]}, {"w": "function", "b": [0.7541, 0.099, 0.8255, 0.1204]}, {"w": "for", "b": [0.8326, 0.099, 0.8571, 0.1204]}, {"w": "large", "b": [0.1429, 0.1181, 0.1836, 0.1395]}, {"w": "inputs,", "b": [0.1883, 0.1181, 0.2457, 0.1395]}, {"w": "the", "b": [0.2504, 0.1181, 0.2767, 0.1395]}, {"w": "result", "b": [0.2815, 0.1181, 0.3284, 0.1395]}, {"w": "will", "b": [0.3331, 0.1181, 0.3635, 0.1395]}, {"w": "be", "b": [0.3682, 0.1181, 0.3877, 0.1395]}, {"w": "NaN:", "b": [0.3924, 0.1181, 0.4367, 0.1395]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> x = tf.Variable([100.]) >>> with tf.GradientTape() as tape: ... z = my_softplus(x) ... >>> tape.gradient(z, [x]) ", "words": [{"w": ">>>", "b": [0.1766, 0.15, 0.2019, 0.1629]}, {"w": "x", "b": [0.2103, 0.15, 0.2188, 0.1629]}, {"w": "=", "b": [0.2272, 0.15, 0.2356, 0.1629]}, {"w": "tf.Variable([100.])", "b": [0.2441, 0.15, 0.4043, 0.1629]}, {"w": ">>>", "b": [0.1766, 0.1654, 0.2019, 0.1783]}, {"w": "with", "b": [0.2103, 0.1654, 0.2441, 0.1783]}, {"w": "tf.GradientTape()", "b": [0.2525, 0.1654, 0.3958, 0.1783]}, {"w": "as", "b": [0.4043, 0.1654, 0.4211, 0.1783]}, {"w": "tape:", "b": [0.4296, 0.1654, 0.4717, 0.1783]}, {"w": "...", "b": [0.1766, 0.1809, 0.2019, 0.1937]}, {"w": "z", "b": [0.2441, 0.1809, 0.2525, 0.1937]}, {"w": "=", "b": [0.2609, 0.1809, 0.2693, 0.1937]}, {"w": "my_softplus(x)", "b": [0.2778, 0.1809, 0.3958, 0.1937]}, {"w": "...", "b": [0.1766, 0.1963, 0.2019, 0.2091]}, {"w": ">>>", "b": [0.1766, 0.2117, 0.2019, 0.2246]}, {"w": "tape.gradient(z,", "b": [0.2103, 0.2117, 0.3452, 0.2246]}, {"w": "[x])", "b": [0.3537, 0.2117, 0.3874, 0.2246]}, {"w": "", "b": [0.4886, 0.2271, 0.6151, 0.24]}]}, {"id": "b_2", "type": "paragraph", "text": "This is because computing the gradients of this function using autodiff leads to some numerical difficulties: due to floating point precision errors, autodiff ends up com‐ puting infinity divided by infinity (which returns NaN). Fortunately, we can analyti‐ cally find that the derivative of the softplus function is just 1 / (1 + 1 / exp(x)), which is numerically stable. Next, we can tell TensorFlow to use this stable function when computing the gradients of the my_softplus() function, by decorating it with @tf.custom_gradient, and making it return both its normal output and the function that computes the derivatives (note that it will receive as input the gradients that were backpropagated so far, down to the softplus function, and according to the chain rule we should multiply them with this function’s gradients):", "words": [{"w": "This", "b": [0.1429, 0.2478, 0.1801, 0.2692]}, {"w": "is", "b": [0.1856, 0.2478, 0.1988, 0.2692]}, {"w": "because", "b": [0.2043, 0.2478, 0.2689, 0.2692]}, {"w": "computing", "b": [0.2744, 0.2478, 0.3655, 0.2692]}, {"w": "the", "b": [0.3711, 0.2478, 0.3974, 0.2692]}, {"w": "gradients", "b": [0.4029, 0.2478, 0.48, 0.2692]}, {"w": "of", "b": [0.4855, 0.2478, 0.5023, 0.2692]}, {"w": "this", "b": [0.5078, 0.2478, 0.5385, 0.2692]}, {"w": "function", "b": [0.544, 0.2478, 0.6154, 0.2692]}, {"w": "using", "b": [0.6209, 0.2478, 0.6663, 0.2692]}, {"w": "autodiff", "b": [0.6718, 0.2478, 0.7375, 0.2692]}, {"w": "leads", "b": [0.743, 0.2478, 0.785, 0.2692]}, {"w": "to", "b": [0.7905, 0.2478, 0.8074, 0.2692]}, {"w": "some", "b": [0.813, 0.2478, 0.8571, 0.2692]}, {"w": "numerical", "b": [0.1429, 0.2668, 0.2274, 0.2882]}, {"w": "difficulties:", "b": [0.2345, 0.2668, 0.3273, 0.2882]}, {"w": "due", "b": [0.3344, 0.2668, 0.3653, 0.2882]}, {"w": "to", "b": [0.3724, 0.2668, 0.3894, 0.2882]}, {"w": "floating", "b": [0.3965, 0.2668, 0.4604, 0.2882]}, {"w": "point", "b": [0.4674, 0.2668, 0.5119, 0.2882]}, {"w": "precision", "b": [0.519, 0.2668, 0.5962, 0.2882]}, {"w": "errors,", "b": [0.6032, 0.2668, 0.6583, 0.2882]}, {"w": "autodiff", "b": [0.6654, 0.2668, 0.7311, 0.2882]}, {"w": "ends", "b": [0.7382, 0.2668, 0.7771, 0.2882]}, {"w": "up", "b": [0.7842, 0.2668, 0.8062, 0.2882]}, {"w": "com‐", "b": [0.8132, 0.2668, 0.8572, 0.2882]}, {"w": "puting", "b": [0.1429, 0.2859, 0.1979, 0.3073]}, {"w": "infinity", "b": [0.204, 0.2859, 0.2656, 0.3073]}, {"w": "divided", "b": [0.2717, 0.2859, 0.3343, 0.3073]}, {"w": "by", "b": [0.3404, 0.2859, 0.3605, 0.3073]}, {"w": "infinity", "b": [0.3666, 0.2859, 0.4282, 0.3073]}, {"w": "(which", "b": [0.4342, 0.2859, 0.4924, 0.3073]}, {"w": "returns", "b": [0.4984, 0.2859, 0.5592, 0.3073]}, {"w": "NaN).", "b": [0.5653, 0.2859, 0.6168, 0.3073]}, {"w": "Fortunately,", "b": [0.6228, 0.2859, 0.7226, 0.3073]}, {"w": "we", "b": [0.7287, 0.2859, 0.7518, 0.3073]}, {"w": "can", "b": [0.7579, 0.2859, 0.7872, 0.3073]}, {"w": "analyti‐", "b": [0.7933, 0.2859, 0.8571, 0.3073]}, {"w": "cally", "b": [0.1429, 0.3049, 0.1809, 0.3263]}, {"w": "find", "b": [0.1863, 0.3049, 0.2205, 0.3263]}, {"w": "that", "b": [0.2259, 0.3049, 0.2585, 0.3263]}, {"w": "the", "b": [0.2639, 0.3049, 0.2902, 0.3263]}, {"w": "derivative", "b": [0.2957, 0.3049, 0.3777, 0.3263]}, {"w": "of", "b": [0.3831, 0.3049, 0.3999, 0.3263]}, {"w": "the", "b": [0.4053, 0.3049, 0.4316, 0.3263]}, {"w": "softplus", "b": [0.437, 0.3049, 0.5027, 0.3263]}, {"w": "function", "b": [0.5081, 0.3049, 0.5795, 0.3263]}, {"w": "is", "b": [0.5849, 0.3049, 0.5982, 0.3263]}, {"w": "just", "b": [0.6036, 0.3049, 0.634, 0.3263]}, {"w": "1", "b": [0.6394, 0.3049, 0.6494, 0.3263]}, {"w": "/", "b": [0.6548, 0.3049, 0.6617, 0.3263]}, {"w": "(1", "b": [0.6671, 0.3049, 0.6843, 0.3263]}, {"w": "+", "b": [0.6898, 0.3049, 0.7018, 0.3263]}, {"w": "1", "b": [0.7073, 0.3049, 0.7173, 0.3263]}, {"w": "/", "b": [0.7227, 0.3049, 0.7296, 0.3263]}, {"w": "exp(x)),", "b": [0.735, 0.3049, 0.8008, 0.3263]}, {"w": "which", "b": [0.8062, 0.3049, 0.8571, 0.3263]}, {"w": "is", "b": [0.1429, 0.3239, 0.1561, 0.3454]}, {"w": "numerically", "b": [0.1628, 0.3239, 0.2622, 0.3454]}, {"w": "stable.", "b": [0.2689, 0.3239, 0.3215, 0.3454]}, {"w": "Next,", "b": [0.3283, 0.3239, 0.373, 0.3454]}, {"w": "we", "b": [0.3798, 0.3239, 0.4029, 0.3454]}, {"w": "can", "b": [0.4097, 0.3239, 0.439, 0.3454]}, {"w": "tell", "b": [0.4458, 0.3239, 0.4715, 0.3454]}, {"w": "TensorFlow", "b": [0.4783, 0.3239, 0.5765, 0.3454]}, {"w": "to", "b": [0.5833, 0.3239, 0.6002, 0.3454]}, {"w": "use", "b": [0.607, 0.3239, 0.6345, 0.3454]}, {"w": "this", "b": [0.6413, 0.3239, 0.672, 0.3454]}, {"w": "stable", "b": [0.6787, 0.3239, 0.7266, 0.3454]}, {"w": "function", "b": [0.7333, 0.3239, 0.8047, 0.3454]}, {"w": "when", "b": [0.8115, 0.3239, 0.8571, 0.3454]}, {"w": "computing", "b": [0.1429, 0.3439, 0.234, 0.3653]}, {"w": "the", "b": [0.2454, 0.3439, 0.2717, 0.3653]}, {"w": "gradients", "b": [0.2831, 0.3439, 0.3601, 0.3653]}, {"w": "of", "b": [0.3715, 0.3439, 0.3883, 0.3653]}, {"w": "the", "b": [0.3996, 0.3439, 0.426, 0.3653]}, {"w": "my_softplus()", "b": [0.4373, 0.3471, 0.566, 0.3622]}, {"w": "function,", "b": [0.5773, 0.3439, 0.6535, 0.3653]}, {"w": "by", "b": [0.6648, 0.3439, 0.685, 0.3653]}, {"w": "decorating", "b": [0.6963, 0.3439, 0.7852, 0.3653]}, {"w": "it", "b": [0.7965, 0.3439, 0.8085, 0.3653]}, {"w": "with", "b": [0.8198, 0.3439, 0.8572, 0.3653]}, {"w": "@tf.custom_gradient,", "b": [0.1429, 0.3638, 0.3356, 0.3853]}, {"w": "and", "b": [0.3408, 0.3638, 0.3723, 0.3853]}, {"w": "making", "b": [0.3774, 0.3638, 0.4407, 0.3853]}, {"w": "it", "b": [0.4458, 0.3638, 0.4578, 0.3853]}, {"w": "return", "b": [0.4629, 0.3638, 0.516, 0.3853]}, {"w": "both", "b": [0.5212, 0.3638, 0.5599, 0.3853]}, {"w": "its", "b": [0.565, 0.3638, 0.5846, 0.3853]}, {"w": "normal", "b": [0.5897, 0.3638, 0.6509, 0.3853]}, {"w": "output", "b": [0.6561, 0.3638, 0.7125, 0.3853]}, {"w": "and", "b": [0.7176, 0.3638, 0.7491, 0.3853]}, {"w": "the", "b": [0.7543, 0.3638, 0.7806, 0.3853]}, {"w": "function", "b": [0.7857, 0.3638, 0.8571, 0.3853]}, {"w": "that", "b": [0.1429, 0.3829, 0.1754, 0.4043]}, {"w": "computes", "b": [0.1804, 0.3829, 0.2614, 0.4043]}, {"w": "the", "b": [0.2663, 0.3829, 0.2927, 0.4043]}, {"w": "derivatives", "b": [0.2977, 0.3829, 0.3873, 0.4043]}, {"w": "(note", "b": [0.3923, 0.3829, 0.4367, 0.4043]}, {"w": "that", "b": [0.4417, 0.3829, 0.4743, 0.4043]}, {"w": "it", "b": [0.4793, 0.3829, 0.4912, 0.4043]}, {"w": "will", "b": [0.4962, 0.3829, 0.5266, 0.4043]}, {"w": "receive", "b": [0.5315, 0.3829, 0.5899, 0.4043]}, {"w": "as", "b": [0.5949, 0.3829, 0.6117, 0.4043]}, {"w": "input", "b": [0.6166, 0.3829, 0.6615, 0.4043]}, {"w": "the", "b": [0.6665, 0.3829, 0.6929, 0.4043]}, {"w": "gradients", "b": [0.6978, 0.3829, 0.7749, 0.4043]}, {"w": "that", "b": [0.7799, 0.3829, 0.8125, 0.4043]}, {"w": "were", "b": [0.8174, 0.3829, 0.8572, 0.4043]}, {"w": "backpropagated", "b": [0.1429, 0.4019, 0.2758, 0.4233]}, {"w": "so", "b": [0.281, 0.4019, 0.2992, 0.4233]}, {"w": "far,", "b": [0.3044, 0.4019, 0.3309, 0.4233]}, {"w": "down", "b": [0.3361, 0.4019, 0.3834, 0.4233]}, {"w": "to", "b": [0.3886, 0.4019, 0.4056, 0.4233]}, {"w": "the", "b": [0.4108, 0.4019, 0.4371, 0.4233]}, {"w": "softplus", "b": [0.4423, 0.4019, 0.508, 0.4233]}, {"w": "function,", "b": [0.5132, 0.4019, 0.5893, 0.4233]}, {"w": "and", "b": [0.5945, 0.4019, 0.626, 0.4233]}, {"w": "according", "b": [0.6312, 0.4019, 0.7141, 0.4233]}, {"w": "to", "b": [0.7193, 0.4019, 0.7363, 0.4233]}, {"w": "the", "b": [0.7414, 0.4019, 0.7678, 0.4233]}, {"w": "chain", "b": [0.773, 0.4019, 0.819, 0.4233]}, {"w": "rule", "b": [0.8242, 0.4019, 0.8571, 0.4233]}, {"w": "we", "b": [0.1429, 0.421, 0.166, 0.4424]}, {"w": "should", "b": [0.1707, 0.421, 0.2274, 0.4424]}, {"w": "multiply", "b": [0.2322, 0.421, 0.3029, 0.4424]}, {"w": "them", "b": [0.3076, 0.421, 0.351, 0.4424]}, {"w": "with", "b": [0.3557, 0.421, 0.393, 0.4424]}, {"w": "this", "b": [0.3978, 0.421, 0.4285, 0.4424]}, {"w": "function’s", "b": [0.4332, 0.421, 0.5132, 0.4424]}, {"w": "gradients):", "b": [0.5179, 0.421, 0.607, 0.4424]}]}, {"id": "b_3", "type": "paragraph", "text": "@tf.custom_gradient def my_better_softplus(z): exp = tf.exp(z) def my_softplus_gradients(grad): return grad / (1 + 1 / exp) return tf.math.log(exp + 1), my_softplus_gradients", "words": [{"w": "@tf.custom_gradient", "b": [0.1766, 0.453, 0.3368, 0.4658]}, {"w": "def", "b": [0.1766, 0.4684, 0.2019, 0.4812]}, {"w": "my_better_softplus(z):", "b": [0.2103, 0.4684, 0.3958, 0.4812]}, {"w": "exp", "b": [0.2103, 0.4838, 0.2356, 0.4966]}, {"w": "=", "b": [0.2441, 0.4838, 0.2525, 0.4966]}, {"w": "tf.exp(z)", "b": [0.2609, 0.4838, 0.3368, 0.4966]}, {"w": "def", "b": [0.2103, 0.4992, 0.2356, 0.5121]}, {"w": "my_softplus_gradients(grad):", "b": [0.2441, 0.4992, 0.4802, 0.5121]}, {"w": "return", "b": [0.2441, 0.5146, 0.2947, 0.5275]}, {"w": "grad", "b": [0.3031, 0.5146, 0.3368, 0.5275]}, {"w": "/", "b": [0.3452, 0.5146, 0.3537, 0.5275]}, {"w": "(1", "b": [0.3621, 0.5146, 0.379, 0.5275]}, {"w": "+", "b": [0.3874, 0.5146, 0.3958, 0.5275]}, {"w": "1", "b": [0.4043, 0.5146, 0.4127, 0.5275]}, {"w": "/", "b": [0.4211, 0.5146, 0.4296, 0.5275]}, {"w": "exp)", "b": [0.438, 0.5146, 0.4717, 0.5275]}, {"w": "return", "b": [0.2103, 0.5301, 0.2609, 0.5429]}, {"w": "tf.math.log(exp", "b": [0.2694, 0.5301, 0.3958, 0.5429]}, {"w": "+", "b": [0.4043, 0.5301, 0.4127, 0.5429]}, {"w": "1),", "b": [0.4211, 0.5301, 0.4464, 0.5429]}, {"w": "my_softplus_gradients", "b": [0.4549, 0.5301, 0.632, 0.5429]}]}, {"id": "b_4", "type": "paragraph", "text": "Now when we compute the gradients of the my_better_softplus() function, we get the proper result, even for large input values (however, the main output still explodes because of the exponential: one workaround is to use tf.where() to just return the inputs when they are large).", "words": [{"w": "Now", "b": [0.1429, 0.5516, 0.1827, 0.573]}, {"w": "when", "b": [0.1885, 0.5516, 0.2342, 0.573]}, {"w": "we", "b": [0.24, 0.5516, 0.2631, 0.573]}, {"w": "compute", "b": [0.2689, 0.5516, 0.3422, 0.573]}, {"w": "the", "b": [0.3479, 0.5516, 0.3743, 0.573]}, {"w": "gradients", "b": [0.3801, 0.5516, 0.4571, 0.573]}, {"w": "of", "b": [0.4629, 0.5516, 0.4797, 0.573]}, {"w": "the", "b": [0.4855, 0.5516, 0.5118, 0.573]}, {"w": "my_better_softplus()", "b": [0.5176, 0.5548, 0.7155, 0.5698]}, {"w": "function,", "b": [0.7213, 0.5516, 0.7975, 0.573]}, {"w": "we", "b": [0.8033, 0.5516, 0.8264, 0.573]}, {"w": "get", "b": [0.8322, 0.5516, 0.8571, 0.573]}, {"w": "the", "b": [0.1429, 0.5706, 0.1692, 0.592]}, {"w": "proper", "b": [0.1744, 0.5706, 0.2312, 0.592]}, {"w": "result,", "b": [0.2365, 0.5706, 0.2881, 0.592]}, {"w": "even", "b": [0.2934, 0.5706, 0.3321, 0.592]}, {"w": "for", "b": [0.3374, 0.5706, 0.3619, 0.592]}, {"w": "large", "b": [0.3671, 0.5706, 0.4079, 0.592]}, {"w": "input", "b": [0.4131, 0.5706, 0.458, 0.592]}, {"w": "values", "b": [0.4633, 0.5706, 0.5149, 0.592]}, {"w": "(however,", "b": [0.5202, 0.5706, 0.6019, 0.592]}, {"w": "the", "b": [0.6071, 0.5706, 0.6335, 0.592]}, {"w": "main", "b": [0.6387, 0.5706, 0.6819, 0.592]}, {"w": "output", "b": [0.6872, 0.5706, 0.7435, 0.592]}, {"w": "still", "b": [0.7488, 0.5706, 0.7789, 0.592]}, {"w": "explodes", "b": [0.7841, 0.5706, 0.8571, 0.592]}, {"w": "because", "b": [0.1429, 0.5906, 0.2074, 0.612]}, {"w": "of", "b": [0.214, 0.5906, 0.2308, 0.612]}, {"w": "the", "b": [0.2374, 0.5906, 0.2637, 0.612]}, {"w": "exponential:", "b": [0.2703, 0.5906, 0.3729, 0.612]}, {"w": "one", "b": [0.3795, 0.5906, 0.4104, 0.612]}, {"w": "workaround", "b": [0.4169, 0.5906, 0.5209, 0.612]}, {"w": "is", "b": [0.5275, 0.5906, 0.5407, 0.612]}, {"w": "to", "b": [0.5473, 0.5906, 0.5643, 0.612]}, {"w": "use", "b": [0.5708, 0.5906, 0.5984, 0.612]}, {"w": "tf.where()", "b": [0.605, 0.5938, 0.704, 0.6088]}, {"w": "to", "b": [0.7105, 0.5906, 0.7275, 0.612]}, {"w": "just", "b": [0.7341, 0.5906, 0.7645, 0.612]}, {"w": "return", "b": [0.7711, 0.5906, 0.8242, 0.612]}, {"w": "the", "b": [0.8308, 0.5906, 0.8571, 0.612]}, {"w": "inputs", "b": [0.1429, 0.6096, 0.1954, 0.631]}, {"w": "when", "b": [0.2001, 0.6096, 0.2458, 0.631]}, {"w": "they", "b": [0.2505, 0.6096, 0.2864, 0.631]}, {"w": "are", "b": [0.2911, 0.6096, 0.3169, 0.631]}, {"w": "large).", "b": [0.3216, 0.6096, 0.3743, 0.631]}]}, {"id": "b_5", "type": "paragraph", "text": "Congratulations! You can now compute the gradients of any function (provided it is differentiable at the point where you compute it), you can even compute Hessians, block backpropagation when needed and even write your own gradient functions! This is probably more flexibility than you will ever need, even if you build your own custom training loops, as we will see now.", "words": [{"w": "Congratulations!", "b": [0.1429, 0.6377, 0.2837, 0.6592]}, {"w": "You", "b": [0.2898, 0.6377, 0.3222, 0.6592]}, {"w": "can", "b": [0.3283, 0.6377, 0.3576, 0.6592]}, {"w": "now", "b": [0.3637, 0.6377, 0.4, 0.6592]}, {"w": "compute", "b": [0.4061, 0.6377, 0.4794, 0.6592]}, {"w": "the", "b": [0.4855, 0.6377, 0.5119, 0.6592]}, {"w": "gradients", "b": [0.518, 0.6377, 0.595, 0.6592]}, {"w": "of", "b": [0.6011, 0.6377, 0.6179, 0.6592]}, {"w": "any", "b": [0.624, 0.6377, 0.6536, 0.6592]}, {"w": "function", "b": [0.6597, 0.6377, 0.7311, 0.6592]}, {"w": "(provided", "b": [0.7372, 0.6377, 0.8198, 0.6592]}, {"w": "it", "b": [0.8259, 0.6377, 0.8378, 0.6592]}, {"w": "is", "b": [0.8439, 0.6377, 0.8571, 0.6592]}, {"w": "differentiable", "b": [0.1429, 0.6568, 0.254, 0.6782]}, {"w": "at", "b": [0.2613, 0.6568, 0.2764, 0.6782]}, {"w": "the", "b": [0.2836, 0.6568, 0.31, 0.6782]}, {"w": "point", "b": [0.3172, 0.6568, 0.3617, 0.6782]}, {"w": "where", "b": [0.369, 0.6568, 0.4198, 0.6782]}, {"w": "you", "b": [0.4271, 0.6568, 0.4583, 0.6782]}, {"w": "compute", "b": [0.4656, 0.6568, 0.5389, 0.6782]}, {"w": "it),", "b": [0.5462, 0.6568, 0.5701, 0.6782]}, {"w": "you", "b": [0.5773, 0.6568, 0.6086, 0.6782]}, {"w": "can", "b": [0.6159, 0.6568, 0.6452, 0.6782]}, {"w": "even", "b": [0.6525, 0.6568, 0.6912, 0.6782]}, {"w": "compute", "b": [0.6985, 0.6568, 0.7718, 0.6782]}, {"w": "Hessians,", "b": [0.779, 0.6568, 0.8572, 0.6782]}, {"w": "block", "b": [0.1429, 0.6758, 0.1885, 0.6972]}, {"w": "backpropagation", "b": [0.1965, 0.6758, 0.3371, 0.6972]}, {"w": "when", "b": [0.3451, 0.6758, 0.3908, 0.6972]}, {"w": "needed", "b": [0.3987, 0.6758, 0.4587, 0.6972]}, {"w": "and", "b": [0.4667, 0.6758, 0.4982, 0.6972]}, {"w": "even", "b": [0.5062, 0.6758, 0.545, 0.6972]}, {"w": "write", "b": [0.5529, 0.6758, 0.5957, 0.6972]}, {"w": "your", "b": [0.6037, 0.6758, 0.6427, 0.6972]}, {"w": "own", "b": [0.6507, 0.6758, 0.687, 0.6972]}, {"w": "gradient", "b": [0.695, 0.6758, 0.7644, 0.6972]}, {"w": "functions!", "b": [0.7724, 0.6758, 0.8571, 0.6972]}, {"w": "This", "b": [0.1429, 0.6949, 0.1801, 0.7163]}, {"w": "is", "b": [0.1858, 0.6949, 0.1991, 0.7163]}, {"w": "probably", "b": [0.2048, 0.6949, 0.2792, 0.7163]}, {"w": "more", "b": [0.285, 0.6949, 0.3293, 0.7163]}, {"w": "flexibility", "b": [0.335, 0.6949, 0.4137, 0.7163]}, {"w": "than", "b": [0.4194, 0.6949, 0.4574, 0.7163]}, {"w": "you", "b": [0.4632, 0.6949, 0.4945, 0.7163]}, {"w": "will", "b": [0.5002, 0.6949, 0.5306, 0.7163]}, {"w": "ever", "b": [0.5364, 0.6949, 0.5714, 0.7163]}, {"w": "need,", "b": [0.5772, 0.6949, 0.6221, 0.7163]}, {"w": "even", "b": [0.6278, 0.6949, 0.6666, 0.7163]}, {"w": "if", "b": [0.6723, 0.6949, 0.6841, 0.7163]}, {"w": "you", "b": [0.6898, 0.6949, 0.7211, 0.7163]}, {"w": "build", "b": [0.7268, 0.6949, 0.7703, 0.7163]}, {"w": "your", "b": [0.7761, 0.6949, 0.8151, 0.7163]}, {"w": "own", "b": [0.8208, 0.6949, 0.8571, 0.7163]}, {"w": "custom", "b": [0.1428, 0.7139, 0.2044, 0.7353]}, {"w": "training", "b": [0.2091, 0.7139, 0.2761, 0.7353]}, {"w": "loops,", "b": [0.2808, 0.7139, 0.3306, 0.7353]}, {"w": "as", "b": [0.3354, 0.7139, 0.3522, 0.7353]}, {"w": "we", "b": [0.3569, 0.7139, 0.38, 0.7353]}, {"w": "will", "b": [0.3847, 0.7139, 0.4151, 0.7353]}, {"w": "see", "b": [0.4199, 0.7139, 0.4452, 0.7353]}, {"w": "now.", "b": [0.45, 0.7139, 0.4895, 0.7353]}]}, {"id": "b_6", "type": "paragraph", "text": "Custom Training Loops", "words": [{"w": "Custom", "b": [0.1428, 0.7481, 0.2201, 0.7767]}, {"w": "Training", "b": [0.2251, 0.7481, 0.3111, 0.7767]}, {"w": "Loops", "b": [0.316, 0.7481, 0.376, 0.7767]}]}, {"id": "b_7", "type": "paragraph", "text": "In some rare cases, the fit() method may not be flexible enough for what you need to do. For example, the Wide and Deep paper we discussed in Chapter 10 actually uses two different optimizers: one for the wide path and the other for the deep path. Since the fit() method only uses one optimizer (the one that we specify when", "words": [{"w": "In", "b": [0.1429, 0.7835, 0.1614, 0.8049]}, {"w": "some", "b": [0.1672, 0.7835, 0.2114, 0.8049]}, {"w": "rare", "b": [0.2172, 0.7835, 0.2507, 0.8049]}, {"w": "cases,", "b": [0.2565, 0.7835, 0.3034, 0.8049]}, {"w": "the", "b": [0.3092, 0.7835, 0.3356, 0.8049]}, {"w": "fit()", "b": [0.3414, 0.7867, 0.3909, 0.8017]}, {"w": "method", "b": [0.3967, 0.7835, 0.4618, 0.8049]}, {"w": "may", "b": [0.4676, 0.7835, 0.503, 0.8049]}, {"w": "not", "b": [0.5088, 0.7835, 0.5372, 0.8049]}, {"w": "be", "b": [0.543, 0.7835, 0.5625, 0.8049]}, {"w": "flexible", "b": [0.5683, 0.7835, 0.6287, 0.8049]}, {"w": "enough", "b": [0.6346, 0.7835, 0.6974, 0.8049]}, {"w": "for", "b": [0.7032, 0.7835, 0.7278, 0.8049]}, {"w": "what", "b": [0.7336, 0.7835, 0.7741, 0.8049]}, {"w": "you", "b": [0.78, 0.7835, 0.8112, 0.8049]}, {"w": "need", "b": [0.817, 0.7835, 0.8571, 0.8049]}, {"w": "to", "b": [0.1429, 0.8025, 0.1598, 0.8239]}, {"w": "do.", "b": [0.1672, 0.8025, 0.193, 0.8239]}, {"w": "For", "b": [0.2003, 0.8025, 0.2293, 0.8239]}, {"w": "example,", "b": [0.2366, 0.8025, 0.3109, 0.8239]}, {"w": "the", "b": [0.3183, 0.8025, 0.3446, 0.8239]}, {"w": "Wide", "b": [0.352, 0.8025, 0.3968, 0.8239]}, {"w": "and", "b": [0.4041, 0.8025, 0.4357, 0.8239]}, {"w": "Deep", "b": [0.443, 0.8025, 0.487, 0.8239]}, {"w": "paper", "b": [0.4943, 0.8025, 0.5415, 0.8239]}, {"w": "we", "b": [0.5488, 0.8025, 0.5719, 0.8239]}, {"w": "discussed", "b": [0.5793, 0.8025, 0.6586, 0.8239]}, {"w": "in", "b": [0.6659, 0.8025, 0.6829, 0.8239]}, {"w": "Chapter", "b": [0.6902, 0.8025, 0.7578, 0.8239]}, {"w": "10", "b": [0.7652, 0.8025, 0.7852, 0.8239]}, {"w": "actually", "b": [0.7925, 0.8025, 0.8571, 0.8239]}, {"w": "uses", "b": [0.1428, 0.8216, 0.1781, 0.843]}, {"w": "two", "b": [0.184, 0.8216, 0.2152, 0.843]}, {"w": "different", "b": [0.2211, 0.8216, 0.2928, 0.843]}, {"w": "optimizers:", "b": [0.2988, 0.8216, 0.3926, 0.843]}, {"w": "one", "b": [0.3985, 0.8216, 0.4294, 0.843]}, {"w": "for", "b": [0.4353, 0.8216, 0.4598, 0.843]}, {"w": "the", "b": [0.4658, 0.8216, 0.4921, 0.843]}, {"w": "wide", "b": [0.498, 0.8216, 0.5377, 0.843]}, {"w": "path", "b": [0.5436, 0.8216, 0.5808, 0.843]}, {"w": "and", "b": [0.5867, 0.8216, 0.6182, 0.843]}, {"w": "the", "b": [0.6242, 0.8216, 0.6505, 0.843]}, {"w": "other", "b": [0.6564, 0.8216, 0.7011, 0.843]}, {"w": "for", "b": [0.707, 0.8216, 0.7315, 0.843]}, {"w": "the", "b": [0.7374, 0.8216, 0.7638, 0.843]}, {"w": "deep", "b": [0.7697, 0.8216, 0.8093, 0.843]}, {"w": "path.", "b": [0.8152, 0.8216, 0.8571, 0.843]}, {"w": "Since", "b": [0.1429, 0.8415, 0.1874, 0.8629]}, {"w": "the", "b": [0.1967, 0.8415, 0.223, 0.8629]}, {"w": "fit()", "b": [0.2323, 0.8447, 0.2818, 0.8598]}, {"w": "method", "b": [0.2911, 0.8415, 0.3561, 0.8629]}, {"w": "only", "b": [0.3654, 0.8415, 0.4023, 0.8629]}, {"w": "uses", "b": [0.4116, 0.8415, 0.4468, 0.8629]}, {"w": "one", "b": [0.4561, 0.8415, 0.4869, 0.8629]}, {"w": "optimizer", "b": [0.4962, 0.8415, 0.5777, 0.8629]}, {"w": "(the", "b": [0.587, 0.8415, 0.6205, 0.8629]}, {"w": "one", "b": [0.6298, 0.8415, 0.6607, 0.8629]}, {"w": "that", "b": [0.67, 0.8415, 0.7026, 0.8629]}, {"w": "we", "b": [0.7119, 0.8415, 0.735, 0.8629]}, {"w": "specify", "b": [0.7443, 0.8415, 0.8022, 0.8629]}, {"w": "when", "b": [0.8115, 0.8415, 0.8571, 0.8629]}]}, {"id": "b_8", "type": "paragraph", "text": "Customizing Models and Training Algorithms | 393", "words": [{"w": "Customizing", "b": [0.5328, 0.9225, 0.6056, 0.9388]}, {"w": "Models", "b": [0.6084, 0.9225, 0.6507, 0.9388]}, {"w": "and", "b": [0.6535, 0.9225, 0.6759, 0.9388]}, {"w": "Training", "b": [0.6787, 0.9225, 0.7278, 0.9388]}, {"w": "Algorithms", "b": [0.7306, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "393", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 420, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "compiling the model), implementing this paper requires writing your own custom loop.", "words": [{"w": "compiling", "b": [0.1429, 0.0791, 0.2275, 0.1005]}, {"w": "the", "b": [0.2352, 0.0791, 0.2616, 0.1005]}, {"w": "model),", "b": [0.2694, 0.0791, 0.3341, 0.1005]}, {"w": "implementing", "b": [0.3419, 0.0791, 0.4592, 0.1005]}, {"w": "this", "b": [0.467, 0.0791, 0.4977, 0.1005]}, {"w": "paper", "b": [0.5055, 0.0791, 0.5526, 0.1005]}, {"w": "requires", "b": [0.5604, 0.0791, 0.6285, 0.1005]}, {"w": "writing", "b": [0.6363, 0.0791, 0.697, 0.1005]}, {"w": "your", "b": [0.7047, 0.0791, 0.7437, 0.1005]}, {"w": "own", "b": [0.7515, 0.0791, 0.7878, 0.1005]}, {"w": "custom", "b": [0.7956, 0.0791, 0.8571, 0.1005]}, {"w": "loop.", "b": [0.1429, 0.0981, 0.1844, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "You may also like to write your own custom training loops simply to feel more confi‐ dent that it does precisely what you intent it to do (perhaps you are unsure about some details of the fit() method). It can sometimes feel safer to make everything explicit. However, remember that writing a custom training loop will make your code longer, more error prone and harder to maintain.", "words": [{"w": "You", "b": [0.1429, 0.1262, 0.1752, 0.1476]}, {"w": "may", "b": [0.1805, 0.1262, 0.2159, 0.1476]}, {"w": "also", "b": [0.2212, 0.1262, 0.2538, 0.1476]}, {"w": "like", "b": [0.2591, 0.1262, 0.2892, 0.1476]}, {"w": "to", "b": [0.2944, 0.1262, 0.3114, 0.1476]}, {"w": "write", "b": [0.3167, 0.1262, 0.3595, 0.1476]}, {"w": "your", "b": [0.3648, 0.1262, 0.4037, 0.1476]}, {"w": "own", "b": [0.409, 0.1262, 0.4453, 0.1476]}, {"w": "custom", "b": [0.4506, 0.1262, 0.5121, 0.1476]}, {"w": "training", "b": [0.5174, 0.1262, 0.5844, 0.1476]}, {"w": "loops", "b": [0.5896, 0.1262, 0.6347, 0.1476]}, {"w": "simply", "b": [0.64, 0.1262, 0.6956, 0.1476]}, {"w": "to", "b": [0.7009, 0.1262, 0.7179, 0.1476]}, {"w": "feel", "b": [0.7232, 0.1262, 0.7523, 0.1476]}, {"w": "more", "b": [0.7576, 0.1262, 0.8019, 0.1476]}, {"w": "confi‐", "b": [0.8071, 0.1262, 0.8571, 0.1476]}, {"w": "dent", "b": [0.1429, 0.1453, 0.1801, 0.1667]}, {"w": "that", "b": [0.1877, 0.1453, 0.2203, 0.1667]}, {"w": "it", "b": [0.2279, 0.1453, 0.2398, 0.1667]}, {"w": "does", "b": [0.2474, 0.1453, 0.2855, 0.1667]}, {"w": "precisely", "b": [0.2932, 0.1453, 0.3664, 0.1667]}, {"w": "what", "b": [0.374, 0.1453, 0.4145, 0.1667]}, {"w": "you", "b": [0.4221, 0.1453, 0.4533, 0.1667]}, {"w": "intent", "b": [0.461, 0.1453, 0.5101, 0.1667]}, {"w": "it", "b": [0.5177, 0.1453, 0.5296, 0.1667]}, {"w": "to", "b": [0.5373, 0.1453, 0.5542, 0.1667]}, {"w": "do", "b": [0.5618, 0.1453, 0.5835, 0.1667]}, {"w": "(perhaps", "b": [0.5911, 0.1453, 0.6642, 0.1667]}, {"w": "you", "b": [0.6718, 0.1453, 0.7031, 0.1667]}, {"w": "are", "b": [0.7107, 0.1453, 0.7364, 0.1667]}, {"w": "unsure", "b": [0.744, 0.1453, 0.8018, 0.1667]}, {"w": "about", "b": [0.8094, 0.1453, 0.8572, 0.1667]}, {"w": "some", "b": [0.1429, 0.1652, 0.187, 0.1866]}, {"w": "details", "b": [0.1943, 0.1652, 0.2482, 0.1866]}, {"w": "of", "b": [0.2554, 0.1652, 0.2722, 0.1866]}, {"w": "the", "b": [0.2795, 0.1652, 0.3058, 0.1866]}, {"w": "fit()", "b": [0.3131, 0.1684, 0.3626, 0.1835]}, {"w": "method).", "b": [0.3698, 0.1652, 0.4468, 0.1866]}, {"w": "It", "b": [0.4541, 0.1652, 0.4667, 0.1866]}, {"w": "can", "b": [0.474, 0.1652, 0.5033, 0.1866]}, {"w": "sometimes", "b": [0.5106, 0.1652, 0.6003, 0.1866]}, {"w": "feel", "b": [0.6076, 0.1652, 0.6367, 0.1866]}, {"w": "safer", "b": [0.644, 0.1652, 0.6835, 0.1866]}, {"w": "to", "b": [0.6908, 0.1652, 0.7078, 0.1866]}, {"w": "make", "b": [0.715, 0.1652, 0.7604, 0.1866]}, {"w": "everything", "b": [0.7677, 0.1652, 0.8571, 0.1866]}, {"w": "explicit.", "b": [0.1429, 0.1843, 0.2088, 0.2057]}, {"w": "However,", "b": [0.2138, 0.1843, 0.2927, 0.2057]}, {"w": "remember", "b": [0.2977, 0.1843, 0.3845, 0.2057]}, {"w": "that", "b": [0.3895, 0.1843, 0.4221, 0.2057]}, {"w": "writing", "b": [0.4271, 0.1843, 0.4878, 0.2057]}, {"w": "a", "b": [0.4928, 0.1843, 0.5019, 0.2057]}, {"w": "custom", "b": [0.507, 0.1843, 0.5685, 0.2057]}, {"w": "training", "b": [0.5736, 0.1843, 0.6405, 0.2057]}, {"w": "loop", "b": [0.6455, 0.1843, 0.683, 0.2057]}, {"w": "will", "b": [0.688, 0.1843, 0.7184, 0.2057]}, {"w": "make", "b": [0.7234, 0.1843, 0.7688, 0.2057]}, {"w": "your", "b": [0.7738, 0.1843, 0.8128, 0.2057]}, {"w": "code", "b": [0.8178, 0.1843, 0.8571, 0.2057]}, {"w": "longer,", "b": [0.1428, 0.2033, 0.1999, 0.2247]}, {"w": "more", "b": [0.2046, 0.2033, 0.2489, 0.2247]}, {"w": "error", "b": [0.2536, 0.2033, 0.2963, 0.2247]}, {"w": "prone", "b": [0.301, 0.2033, 0.3506, 0.2247]}, {"w": "and", "b": [0.3553, 0.2033, 0.3868, 0.2247]}, {"w": "harder", "b": [0.3916, 0.2033, 0.4471, 0.2247]}, {"w": "to", "b": [0.4519, 0.2033, 0.4688, 0.2247]}, {"w": "maintain.", "b": [0.4736, 0.2033, 0.5536, 0.2247]}]}, {"id": "b_2", "type": "paragraph", "text": "Unless you really need the extra flexibility, you should prefer using the fit() method rather than implementing your own training loop, especially if you work in a team.", "words": [{"w": "Unless", "b": [0.2714, 0.2453, 0.3219, 0.2648]}, {"w": "you", "b": [0.3271, 0.2453, 0.3556, 0.2648]}, {"w": "really", "b": [0.3608, 0.2453, 0.4027, 0.2648]}, {"w": "need", "b": [0.4078, 0.2453, 0.4445, 0.2648]}, {"w": "the", "b": [0.4497, 0.2453, 0.4737, 0.2648]}, {"w": "extra", "b": [0.4789, 0.2453, 0.5172, 0.2648]}, {"w": "flexibility,", "b": [0.5223, 0.2453, 0.5972, 0.2648]}, {"w": "you", "b": [0.6023, 0.2453, 0.6309, 0.2648]}, {"w": "should", "b": [0.6361, 0.2453, 0.6879, 0.2648]}, {"w": "prefer", "b": [0.6931, 0.2453, 0.739, 0.2648]}, {"w": "using", "b": [0.7442, 0.2453, 0.7857, 0.2648]}, {"w": "the", "b": [0.2714, 0.2635, 0.2955, 0.2831]}, {"w": "fit()", "b": [0.3039, 0.2664, 0.3491, 0.2802]}, {"w": "method", "b": [0.3576, 0.2635, 0.417, 0.2831]}, {"w": "rather", "b": [0.4254, 0.2635, 0.4716, 0.2831]}, {"w": "than", "b": [0.48, 0.2635, 0.5148, 0.2831]}, {"w": "implementing", "b": [0.5232, 0.2635, 0.6305, 0.2831]}, {"w": "your", "b": [0.6389, 0.2635, 0.6745, 0.2831]}, {"w": "own", "b": [0.6829, 0.2635, 0.7161, 0.2831]}, {"w": "training", "b": [0.7245, 0.2635, 0.7857, 0.2831]}, {"w": "loop,", "b": [0.2714, 0.2809, 0.3094, 0.3005]}, {"w": "especially", "b": [0.3138, 0.2809, 0.3868, 0.3005]}, {"w": "if", "b": [0.3911, 0.2809, 0.4019, 0.3005]}, {"w": "you", "b": [0.4062, 0.2809, 0.4348, 0.3005]}, {"w": "work", "b": [0.4391, 0.2809, 0.4784, 0.3005]}, {"w": "in", "b": [0.4827, 0.2809, 0.4982, 0.3005]}, {"w": "a", "b": [0.5026, 0.2809, 0.5109, 0.3005]}, {"w": "team.", "b": [0.5152, 0.2809, 0.5574, 0.3005]}]}, {"id": "b_3", "type": "paragraph", "text": "First, let’s build a simple model. No need to compile it, since we will handle the train‐ ing loop manually:", "words": [{"w": "First,", "b": [0.1429, 0.3439, 0.1859, 0.3653]}, {"w": "let’s", "b": [0.1911, 0.3439, 0.2214, 0.3653]}, {"w": "build", "b": [0.2266, 0.3439, 0.2701, 0.3653]}, {"w": "a", "b": [0.2753, 0.3439, 0.2844, 0.3653]}, {"w": "simple", "b": [0.2896, 0.3439, 0.3446, 0.3653]}, {"w": "model.", "b": [0.3498, 0.3439, 0.4073, 0.3653]}, {"w": "No", "b": [0.4125, 0.3439, 0.4381, 0.3653]}, {"w": "need", "b": [0.4433, 0.3439, 0.4834, 0.3653]}, {"w": "to", "b": [0.4886, 0.3439, 0.5056, 0.3653]}, {"w": "compile", "b": [0.5108, 0.3439, 0.5775, 0.3653]}, {"w": "it,", "b": [0.5827, 0.3439, 0.5994, 0.3653]}, {"w": "since", "b": [0.6046, 0.3439, 0.6469, 0.3653]}, {"w": "we", "b": [0.6521, 0.3439, 0.6752, 0.3653]}, {"w": "will", "b": [0.6804, 0.3439, 0.7108, 0.3653]}, {"w": "handle", "b": [0.716, 0.3439, 0.7728, 0.3653]}, {"w": "the", "b": [0.778, 0.3439, 0.8043, 0.3653]}, {"w": "train‐", "b": [0.8095, 0.3439, 0.8571, 0.3653]}, {"w": "ing", "b": [0.1429, 0.363, 0.1696, 0.3844]}, {"w": "loop", "b": [0.1743, 0.363, 0.2118, 0.3844]}, {"w": "manually:", "b": [0.2165, 0.363, 0.2994, 0.3844]}]}, {"id": "b_4", "type": "paragraph", "text": "l2_reg = keras.regularizers.l2(0.05) model = keras.models.Sequential([ keras.layers.Dense(30, activation=\"elu\", kernel_initializer=\"he_normal\", kernel_regularizer=l2_reg), keras.layers.Dense(1, kernel_regularizer=l2_reg) ])", "words": [{"w": "l2_reg", "b": [0.1766, 0.3949, 0.2272, 0.4078]}, {"w": "=", "b": [0.2356, 0.3949, 0.244, 0.4078]}, {"w": "keras.regularizers.l2(0.05)", "b": [0.2525, 0.3949, 0.4802, 0.4078]}, {"w": "model", "b": [0.1766, 0.4103, 0.2188, 0.4232]}, {"w": "=", "b": [0.2272, 0.4103, 0.2356, 0.4232]}, {"w": "keras.models.Sequential([", "b": [0.244, 0.4103, 0.4549, 0.4232]}, {"w": "keras.layers.Dense(30,", "b": [0.2103, 0.4258, 0.3958, 0.4386]}, {"w": "activation=\"elu\",", "b": [0.4043, 0.4258, 0.5476, 0.4386]}, {"w": "kernel_initializer=\"he_normal\",", "b": [0.5561, 0.4258, 0.8175, 0.4386]}, {"w": "kernel_regularizer=l2_reg),", "b": [0.3705, 0.4412, 0.5982, 0.454]}, {"w": "keras.layers.Dense(1,", "b": [0.2103, 0.4566, 0.3874, 0.4695]}, {"w": "kernel_regularizer=l2_reg)", "b": [0.3958, 0.4566, 0.6151, 0.4695]}, {"w": "])", "b": [0.1766, 0.472, 0.1935, 0.4849]}]}, {"id": "b_5", "type": "paragraph", "text": "Next, let’s create a tiny function that will randomly sample a batch of instances from the training set (in Chapter 13 we will discuss the Data API, which offers a much bet‐ ter alternative):", "words": [{"w": "Next,", "b": [0.1428, 0.4927, 0.1876, 0.5141]}, {"w": "let’s", "b": [0.1936, 0.4927, 0.2238, 0.5141]}, {"w": "create", "b": [0.2298, 0.4927, 0.2791, 0.5141]}, {"w": "a", "b": [0.2851, 0.4927, 0.2943, 0.5141]}, {"w": "tiny", "b": [0.3003, 0.4927, 0.3327, 0.5141]}, {"w": "function", "b": [0.3387, 0.4927, 0.41, 0.5141]}, {"w": "that", "b": [0.416, 0.4927, 0.4486, 0.5141]}, {"w": "will", "b": [0.4546, 0.4927, 0.485, 0.5141]}, {"w": "randomly", "b": [0.491, 0.4927, 0.5728, 0.5141]}, {"w": "sample", "b": [0.5787, 0.4927, 0.6372, 0.5141]}, {"w": "a", "b": [0.6432, 0.4927, 0.6524, 0.5141]}, {"w": "batch", "b": [0.6584, 0.4927, 0.704, 0.5141]}, {"w": "of", "b": [0.71, 0.4927, 0.7268, 0.5141]}, {"w": "instances", "b": [0.7327, 0.4927, 0.8096, 0.5141]}, {"w": "from", "b": [0.8156, 0.4927, 0.8571, 0.5141]}, {"w": "the", "b": [0.1429, 0.5117, 0.1692, 0.5331]}, {"w": "training", "b": [0.1743, 0.5117, 0.2412, 0.5331]}, {"w": "set", "b": [0.2463, 0.5117, 0.2692, 0.5331]}, {"w": "(in", "b": [0.2743, 0.5117, 0.2985, 0.5331]}, {"w": "Chapter", "b": [0.3035, 0.5117, 0.3711, 0.5331]}, {"w": "13", "b": [0.3759, 0.5117, 0.3959, 0.5331]}, {"w": "we", "b": [0.4013, 0.5117, 0.4244, 0.5331]}, {"w": "will", "b": [0.4295, 0.5117, 0.4599, 0.5331]}, {"w": "discuss", "b": [0.465, 0.5117, 0.5244, 0.5331]}, {"w": "the", "b": [0.5295, 0.5117, 0.5558, 0.5331]}, {"w": "Data", "b": [0.5609, 0.5117, 0.6005, 0.5331]}, {"w": "API,", "b": [0.6056, 0.5117, 0.6435, 0.5331]}, {"w": "which", "b": [0.6486, 0.5117, 0.6996, 0.5331]}, {"w": "offers", "b": [0.7046, 0.5117, 0.7518, 0.5331]}, {"w": "a", "b": [0.7569, 0.5117, 0.7661, 0.5331]}, {"w": "much", "b": [0.7712, 0.5117, 0.8188, 0.5331]}, {"w": "bet‐", "b": [0.8239, 0.5117, 0.8571, 0.5331]}, {"w": "ter", "b": [0.1429, 0.5308, 0.1658, 0.5522]}, {"w": "alternative):", "b": [0.1705, 0.5308, 0.2704, 0.5522]}]}, {"id": "b_6", "type": "paragraph", "text": "def random_batch(X, y, batch_size=32): idx = np.random.randint(len(X), size=batch_size) return X[idx], y[idx]", "words": [{"w": "def", "b": [0.1766, 0.5627, 0.2019, 0.5756]}, {"w": "random_batch(X,", "b": [0.2103, 0.5627, 0.3368, 0.5756]}, {"w": "y,", "b": [0.3452, 0.5627, 0.3621, 0.5756]}, {"w": "batch_size=32):", "b": [0.3705, 0.5627, 0.497, 0.5756]}, {"w": "idx", "b": [0.2103, 0.5781, 0.2356, 0.591]}, {"w": "=", "b": [0.244, 0.5781, 0.2525, 0.591]}, {"w": "np.random.randint(len(X),", "b": [0.2609, 0.5781, 0.4717, 0.591]}, {"w": "size=batch_size)", "b": [0.4802, 0.5781, 0.6151, 0.591]}, {"w": "return", "b": [0.2103, 0.5936, 0.2609, 0.6064]}, {"w": "X[idx],", "b": [0.2693, 0.5936, 0.3284, 0.6064]}, {"w": "y[idx]", "b": [0.3368, 0.5936, 0.3874, 0.6064]}]}, {"id": "b_7", "type": "paragraph", "text": "Let’s also define a function that will display the training status, including the number of steps, the total number of steps, the mean loss since the start of the epoch (i.e., we will use the Mean metric to compute it), and other metrics:", "words": [{"w": "Let’s", "b": [0.1429, 0.6142, 0.179, 0.6356]}, {"w": "also", "b": [0.1846, 0.6142, 0.2173, 0.6356]}, {"w": "define", "b": [0.2229, 0.6142, 0.2748, 0.6356]}, {"w": "a", "b": [0.2804, 0.6142, 0.2896, 0.6356]}, {"w": "function", "b": [0.2952, 0.6142, 0.3666, 0.6356]}, {"w": "that", "b": [0.3722, 0.6142, 0.4048, 0.6356]}, {"w": "will", "b": [0.4104, 0.6142, 0.4408, 0.6356]}, {"w": "display", "b": [0.4464, 0.6142, 0.5051, 0.6356]}, {"w": "the", "b": [0.5108, 0.6142, 0.5371, 0.6356]}, {"w": "training", "b": [0.5427, 0.6142, 0.6096, 0.6356]}, {"w": "status,", "b": [0.6153, 0.6142, 0.6678, 0.6356]}, {"w": "including", "b": [0.6734, 0.6142, 0.7533, 0.6356]}, {"w": "the", "b": [0.7589, 0.6142, 0.7852, 0.6356]}, {"w": "number", "b": [0.7909, 0.6142, 0.8571, 0.6356]}, {"w": "of", "b": [0.1429, 0.6332, 0.1596, 0.6547]}, {"w": "steps,", "b": [0.1653, 0.6332, 0.2114, 0.6547]}, {"w": "the", "b": [0.2171, 0.6332, 0.2434, 0.6547]}, {"w": "total", "b": [0.249, 0.6332, 0.2868, 0.6547]}, {"w": "number", "b": [0.2924, 0.6332, 0.3587, 0.6547]}, {"w": "of", "b": [0.3643, 0.6332, 0.3811, 0.6547]}, {"w": "steps,", "b": [0.3867, 0.6332, 0.4329, 0.6547]}, {"w": "the", "b": [0.4385, 0.6332, 0.4649, 0.6547]}, {"w": "mean", "b": [0.4705, 0.6332, 0.517, 0.6547]}, {"w": "loss", "b": [0.5226, 0.6332, 0.5538, 0.6547]}, {"w": "since", "b": [0.5594, 0.6332, 0.6017, 0.6547]}, {"w": "the", "b": [0.6073, 0.6332, 0.6337, 0.6547]}, {"w": "start", "b": [0.6393, 0.6332, 0.6765, 0.6547]}, {"w": "of", "b": [0.6821, 0.6332, 0.6989, 0.6547]}, {"w": "the", "b": [0.7046, 0.6332, 0.7309, 0.6547]}, {"w": "epoch", "b": [0.7365, 0.6332, 0.7869, 0.6547]}, {"w": "(i.e.,", "b": [0.7925, 0.6332, 0.8284, 0.6547]}, {"w": "we", "b": [0.834, 0.6332, 0.8571, 0.6547]}, {"w": "will", "b": [0.1428, 0.6532, 0.1732, 0.6746]}, {"w": "use", "b": [0.178, 0.6532, 0.2055, 0.6746]}, {"w": "the", "b": [0.2103, 0.6532, 0.2366, 0.6746]}, {"w": "Mean", "b": [0.2413, 0.6564, 0.2809, 0.6715]}, {"w": "metric", "b": [0.2857, 0.6532, 0.3401, 0.6746]}, {"w": "to", "b": [0.3448, 0.6532, 0.3618, 0.6746]}, {"w": "compute", "b": [0.3665, 0.6532, 0.4398, 0.6746]}, {"w": "it),", "b": [0.4445, 0.6532, 0.4684, 0.6746]}, {"w": "and", "b": [0.4731, 0.6532, 0.5047, 0.6746]}, {"w": "other", "b": [0.5094, 0.6532, 0.5541, 0.6746]}, {"w": "metrics:", "b": [0.5588, 0.6532, 0.6256, 0.6746]}]}, {"id": "b_8", "type": "paragraph", "text": "def print_status_bar(iteration, total, loss, metrics=None): metrics = \" - \".join([\"{}: {:.4f}\".format(m.name, m.result()) for m in [loss] + (metrics or [])]) end = \"\" if iteration < total else \"\\n\" print(\"\\r{}/{} - \".format(iteration, total) + metrics, end=end)", "words": [{"w": "def", "b": [0.1766, 0.6852, 0.2019, 0.698]}, {"w": "print_status_bar(iteration,", "b": [0.2103, 0.6852, 0.438, 0.698]}, {"w": "total,", "b": [0.4464, 0.6852, 0.497, 0.698]}, {"w": "loss,", "b": [0.5055, 0.6852, 0.5476, 0.698]}, {"w": "metrics=None):", "b": [0.556, 0.6852, 0.6741, 0.698]}, {"w": "metrics", "b": [0.2103, 0.7006, 0.2693, 0.7134]}, {"w": "=", "b": [0.2778, 0.7006, 0.2862, 0.7134]}, {"w": "\"", "b": [0.2946, 0.7006, 0.3031, 0.7134]}, {"w": "-", "b": [0.3115, 0.7006, 0.3199, 0.7134]}, {"w": "\".join([\"{}:", "b": [0.3284, 0.7006, 0.4296, 0.7134]}, {"w": "{:.4f}\".format(m.name,", "b": [0.438, 0.7006, 0.6235, 0.7134]}, {"w": "m.result())", "b": [0.6319, 0.7006, 0.7247, 0.7134]}, {"w": "for", "b": [0.3874, 0.716, 0.4127, 0.7289]}, {"w": "m", "b": [0.4211, 0.716, 0.4296, 0.7289]}, {"w": "in", "b": [0.438, 0.716, 0.4549, 0.7289]}, {"w": "[loss]", "b": [0.4633, 0.716, 0.5139, 0.7289]}, {"w": "+", "b": [0.5223, 0.716, 0.5308, 0.7289]}, {"w": "(metrics", "b": [0.5392, 0.716, 0.6066, 0.7289]}, {"w": "or", "b": [0.6151, 0.716, 0.6319, 0.7289]}, {"w": "[])])", "b": [0.6404, 0.716, 0.6825, 0.7289]}, {"w": "end", "b": [0.2103, 0.7314, 0.2356, 0.7443]}, {"w": "=", "b": [0.244, 0.7314, 0.2525, 0.7443]}, {"w": "\"\"", "b": [0.2609, 0.7314, 0.2778, 0.7443]}, {"w": "if", "b": [0.2862, 0.7314, 0.3031, 0.7443]}, {"w": "iteration", "b": [0.3115, 0.7314, 0.3874, 0.7443]}, {"w": "<", "b": [0.3958, 0.7314, 0.4043, 0.7443]}, {"w": "total", "b": [0.4127, 0.7314, 0.4549, 0.7443]}, {"w": "else", "b": [0.4633, 0.7314, 0.497, 0.7443]}, {"w": "\"\\n\"", "b": [0.5055, 0.7314, 0.5392, 0.7443]}, {"w": "print(\"\\r{}/{}", "b": [0.2103, 0.7468, 0.3284, 0.7597]}, {"w": "-", "b": [0.3368, 0.7468, 0.3452, 0.7597]}, {"w": "\".format(iteration,", "b": [0.3537, 0.7468, 0.5139, 0.7597]}, {"w": "total)", "b": [0.5223, 0.7468, 0.5729, 0.7597]}, {"w": "+", "b": [0.5813, 0.7468, 0.5898, 0.7597]}, {"w": "metrics,", "b": [0.5982, 0.7468, 0.6657, 0.7597]}, {"w": "end=end)", "b": [0.2609, 0.7623, 0.3284, 0.7751]}]}, {"id": "b_9", "type": "paragraph", "text": "This code is self-explanatory, unless you are unfamiliar with Python string format‐ ting: {:.4f} will format a float with 4 digits after the decimal point. Moreover, using \\r (carriage return) along with end=\"\" ensures that the status bar always gets printed on the same line. In the notebook, the print_status_bar() function also includes a progress bar, but you could use the handy tqdm library instead.", "words": [{"w": "This", "b": [0.1428, 0.7829, 0.1801, 0.8043]}, {"w": "code", "b": [0.1873, 0.7829, 0.2266, 0.8043]}, {"w": "is", "b": [0.2338, 0.7829, 0.247, 0.8043]}, {"w": "self-explanatory,", "b": [0.2542, 0.7829, 0.3918, 0.8043]}, {"w": "unless", "b": [0.399, 0.7829, 0.4509, 0.8043]}, {"w": "you", "b": [0.4581, 0.7829, 0.4893, 0.8043]}, {"w": "are", "b": [0.4966, 0.7829, 0.5223, 0.8043]}, {"w": "unfamiliar", "b": [0.5295, 0.7829, 0.6176, 0.8043]}, {"w": "with", "b": [0.6248, 0.7829, 0.6622, 0.8043]}, {"w": "Python", "b": [0.6694, 0.7829, 0.7302, 0.8043]}, {"w": "string", "b": [0.7374, 0.7829, 0.7858, 0.8043]}, {"w": "format‐", "b": [0.793, 0.7829, 0.8571, 0.8043]}, {"w": "ting:", "b": [0.1429, 0.8028, 0.1807, 0.8243]}, {"w": "{:.4f}", "b": [0.1864, 0.806, 0.2458, 0.8211]}, {"w": "will", "b": [0.2515, 0.8028, 0.2819, 0.8243]}, {"w": "format", "b": [0.2876, 0.8028, 0.3443, 0.8243]}, {"w": "a", "b": [0.35, 0.8028, 0.3591, 0.8243]}, {"w": "float", "b": [0.3648, 0.8028, 0.402, 0.8243]}, {"w": "with", "b": [0.4077, 0.8028, 0.4451, 0.8243]}, {"w": "4", "b": [0.4508, 0.8028, 0.4608, 0.8243]}, {"w": "digits", "b": [0.4665, 0.8028, 0.5124, 0.8243]}, {"w": "after", "b": [0.5181, 0.8028, 0.5564, 0.8243]}, {"w": "the", "b": [0.5621, 0.8028, 0.5884, 0.8243]}, {"w": "decimal", "b": [0.5941, 0.8028, 0.6598, 0.8243]}, {"w": "point.", "b": [0.6655, 0.8028, 0.7148, 0.8243]}, {"w": "Moreover,", "b": [0.7205, 0.8028, 0.806, 0.8243]}, {"w": "using", "b": [0.8117, 0.8028, 0.8572, 0.8243]}, {"w": "\\r", "b": [0.1428, 0.826, 0.1626, 0.841]}, {"w": "(carriage", "b": [0.1681, 0.8228, 0.2421, 0.8442]}, {"w": "return)", "b": [0.2476, 0.8228, 0.3079, 0.8442]}, {"w": "along", "b": [0.3134, 0.8228, 0.3596, 0.8442]}, {"w": "with", "b": [0.365, 0.8228, 0.4024, 0.8442]}, {"w": "end=\"\"", "b": [0.4078, 0.826, 0.4672, 0.841]}, {"w": "ensures", "b": [0.4727, 0.8228, 0.5359, 0.8442]}, {"w": "that", "b": [0.5414, 0.8228, 0.574, 0.8442]}, {"w": "the", "b": [0.5794, 0.8228, 0.6058, 0.8442]}, {"w": "status", "b": [0.6112, 0.8228, 0.6591, 0.8442]}, {"w": "bar", "b": [0.6645, 0.8228, 0.692, 0.8442]}, {"w": "always", "b": [0.6975, 0.8228, 0.7521, 0.8442]}, {"w": "gets", "b": [0.7576, 0.8228, 0.7902, 0.8442]}, {"w": "printed", "b": [0.7957, 0.8228, 0.8571, 0.8442]}, {"w": "on", "b": [0.1429, 0.8427, 0.1649, 0.8641]}, {"w": "the", "b": [0.1708, 0.8427, 0.1971, 0.8641]}, {"w": "same", "b": [0.2031, 0.8427, 0.2458, 0.8641]}, {"w": "line.", "b": [0.2517, 0.8427, 0.2876, 0.8641]}, {"w": "In", "b": [0.2935, 0.8427, 0.312, 0.8641]}, {"w": "the", "b": [0.3179, 0.8427, 0.3442, 0.8641]}, {"w": "notebook,", "b": [0.3502, 0.8427, 0.4343, 0.8641]}, {"w": "the", "b": [0.4402, 0.8427, 0.4666, 0.8641]}, {"w": "print_status_bar()", "b": [0.4725, 0.8459, 0.6506, 0.861]}, {"w": "function", "b": [0.6565, 0.8427, 0.7279, 0.8641]}, {"w": "also", "b": [0.7338, 0.8427, 0.7665, 0.8641]}, {"w": "includes", "b": [0.7725, 0.8427, 0.8421, 0.8641]}, {"w": "a", "b": [0.848, 0.8427, 0.8571, 0.8641]}, {"w": "progress", "b": [0.1429, 0.8618, 0.2138, 0.8832]}, {"w": "bar,", "b": [0.2185, 0.8618, 0.2494, 0.8832]}, {"w": "but", "b": [0.2541, 0.8618, 0.2821, 0.8832]}, {"w": "you", "b": [0.2868, 0.8618, 0.3181, 0.8832]}, {"w": "could", "b": [0.3228, 0.8618, 0.3696, 0.8832]}, {"w": "use", "b": [0.3743, 0.8618, 0.4019, 0.8832]}, {"w": "the", "b": [0.4066, 0.8618, 0.4329, 0.8832]}, {"w": "handy", "b": [0.4377, 0.8618, 0.4899, 0.8832]}, {"w": "tqdm", "b": [0.4946, 0.8618, 0.5397, 0.8832]}, {"w": "library", "b": [0.5444, 0.8618, 0.6006, 0.8832]}, {"w": "instead.", "b": [0.6054, 0.8618, 0.6701, 0.8832]}]}, {"id": "b_10", "type": "paragraph", "text": "394 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "394", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2746, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 421, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "With that, let’s get down to business! First, we need to define some hyperparameters, choose the optimizer, the loss function and the metrics (just the MAE in this exam‐ ple):", "words": [{"w": "With", "b": [0.1429, 0.0791, 0.1853, 0.1005]}, {"w": "that,", "b": [0.191, 0.0791, 0.2283, 0.1005]}, {"w": "let’s", "b": [0.234, 0.0791, 0.2642, 0.1005]}, {"w": "get", "b": [0.2699, 0.0791, 0.2948, 0.1005]}, {"w": "down", "b": [0.3005, 0.0791, 0.3478, 0.1005]}, {"w": "to", "b": [0.3534, 0.0791, 0.3704, 0.1005]}, {"w": "business!", "b": [0.3761, 0.0791, 0.4523, 0.1005]}, {"w": "First,", "b": [0.4579, 0.0791, 0.501, 0.1005]}, {"w": "we", "b": [0.5067, 0.0791, 0.5298, 0.1005]}, {"w": "need", "b": [0.5355, 0.0791, 0.5756, 0.1005]}, {"w": "to", "b": [0.5812, 0.0791, 0.5982, 0.1005]}, {"w": "define", "b": [0.6039, 0.0791, 0.6557, 0.1005]}, {"w": "some", "b": [0.6614, 0.0791, 0.7056, 0.1005]}, {"w": "hyperparameters,", "b": [0.7112, 0.0791, 0.8571, 0.1005]}, {"w": "choose", "b": [0.1429, 0.0981, 0.2005, 0.1195]}, {"w": "the", "b": [0.2068, 0.0981, 0.2331, 0.1195]}, {"w": "optimizer,", "b": [0.2394, 0.0981, 0.3243, 0.1195]}, {"w": "the", "b": [0.3306, 0.0981, 0.3569, 0.1195]}, {"w": "loss", "b": [0.3632, 0.0981, 0.3944, 0.1195]}, {"w": "function", "b": [0.4006, 0.0981, 0.472, 0.1195]}, {"w": "and", "b": [0.4783, 0.0981, 0.5099, 0.1195]}, {"w": "the", "b": [0.5161, 0.0981, 0.5425, 0.1195]}, {"w": "metrics", "b": [0.5487, 0.0981, 0.6108, 0.1195]}, {"w": "(just", "b": [0.617, 0.0981, 0.6547, 0.1195]}, {"w": "the", "b": [0.6609, 0.0981, 0.6873, 0.1195]}, {"w": "MAE", "b": [0.6935, 0.0981, 0.7383, 0.1195]}, {"w": "in", "b": [0.7446, 0.0981, 0.7616, 0.1195]}, {"w": "this", "b": [0.7678, 0.0981, 0.7986, 0.1195]}, {"w": "exam‐", "b": [0.8048, 0.0981, 0.8571, 0.1195]}, {"w": "ple):", "b": [0.1429, 0.1172, 0.1799, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "n_epochs = 5 batch_size = 32 n_steps = len(X_train) // batch_size optimizer = keras.optimizers.Nadam(lr=0.01) loss_fn = keras.losses.mean_squared_error mean_loss = keras.metrics.Mean() metrics = [keras.metrics.MeanAbsoluteError()]", "words": [{"w": "n_epochs", "b": [0.1766, 0.1491, 0.2441, 0.162]}, {"w": "=", "b": [0.2525, 0.1491, 0.2609, 0.162]}, {"w": "5", "b": [0.2694, 0.1491, 0.2778, 0.162]}, {"w": "batch_size", "b": [0.1766, 0.1646, 0.2609, 0.1774]}, {"w": "=", "b": [0.2694, 0.1646, 0.2778, 0.1774]}, {"w": "32", "b": [0.2862, 0.1646, 0.3031, 0.1774]}, {"w": "n_steps", "b": [0.1766, 0.18, 0.2356, 0.1928]}, {"w": "=", "b": [0.2441, 0.18, 0.2525, 0.1928]}, {"w": "len(X_train)", "b": [0.2609, 0.18, 0.3621, 0.1928]}, {"w": "//", "b": [0.3705, 0.18, 0.3874, 0.1928]}, {"w": "batch_size", "b": [0.3958, 0.18, 0.4802, 0.1928]}, {"w": "optimizer", "b": [0.1766, 0.1954, 0.2525, 0.2082]}, {"w": "=", "b": [0.2609, 0.1954, 0.2694, 0.2082]}, {"w": "keras.optimizers.Nadam(lr=0.01)", "b": [0.2778, 0.1954, 0.5392, 0.2082]}, {"w": "loss_fn", "b": [0.1766, 0.2108, 0.2356, 0.2237]}, {"w": "=", "b": [0.2441, 0.2108, 0.2525, 0.2237]}, {"w": "keras.losses.mean_squared_error", "b": [0.2609, 0.2108, 0.5223, 0.2237]}, {"w": "mean_loss", "b": [0.1766, 0.2262, 0.2525, 0.2391]}, {"w": "=", "b": [0.2609, 0.2262, 0.2694, 0.2391]}, {"w": "keras.metrics.Mean()", "b": [0.2778, 0.2262, 0.4464, 0.2391]}, {"w": "metrics", "b": [0.1766, 0.2416, 0.2356, 0.2545]}, {"w": "=", "b": [0.2441, 0.2416, 0.2525, 0.2545]}, {"w": "[keras.metrics.MeanAbsoluteError()]", "b": [0.2609, 0.2416, 0.5561, 0.2545]}]}, {"id": "b_2", "type": "paragraph", "text": "And now we are ready to build the custom loop!", "words": [{"w": "And", "b": [0.1429, 0.2623, 0.1796, 0.2837]}, {"w": "now", "b": [0.1844, 0.2623, 0.2207, 0.2837]}, {"w": "we", "b": [0.2254, 0.2623, 0.2485, 0.2837]}, {"w": "are", "b": [0.2532, 0.2623, 0.279, 0.2837]}, {"w": "ready", "b": [0.2837, 0.2623, 0.33, 0.2837]}, {"w": "to", "b": [0.3347, 0.2623, 0.3517, 0.2837]}, {"w": "build", "b": [0.3564, 0.2623, 0.3999, 0.2837]}, {"w": "the", "b": [0.4047, 0.2623, 0.431, 0.2837]}, {"w": "custom", "b": [0.4357, 0.2623, 0.4973, 0.2837]}, {"w": "loop!", "b": [0.502, 0.2623, 0.5452, 0.2837]}]}, {"id": "b_3", "type": "paragraph", "text": "for epoch in range(1, n_epochs + 1): print(\"Epoch {}/{}\".format(epoch, n_epochs)) for step in range(1, n_steps + 1): X_batch, y_batch = random_batch(X_train_scaled, y_train) with tf.GradientTape() as tape: y_pred = model(X_batch, training=True) main_loss = tf.reduce_mean(loss_fn(y_batch, y_pred)) loss = tf.add_n([main_loss] + model.losses) gradients = tape.gradient(loss, model.trainable_variables) optimizer.apply_gradients(zip(gradients, model.trainable_variables)) mean_loss(loss) for metric in metrics: metric(y_batch, y_pred) print_status_bar(step * batch_size, len(y_train), mean_loss, metrics) print_status_bar(len(y_train), len(y_train), mean_loss, metrics) for metric in [mean_loss] + metrics: metric.reset_states()", "words": [{"w": "for", "b": [0.1766, 0.2943, 0.2019, 0.3071]}, {"w": "epoch", "b": [0.2103, 0.2943, 0.2525, 0.3071]}, {"w": "in", "b": [0.2609, 0.2943, 0.2778, 0.3071]}, {"w": "range(1,", "b": [0.2862, 0.2943, 0.3537, 0.3071]}, {"w": "n_epochs", "b": [0.3621, 0.2943, 0.4296, 0.3071]}, {"w": "+", "b": [0.438, 0.2943, 0.4464, 0.3071]}, {"w": "1):", "b": [0.4549, 0.2943, 0.4802, 0.3071]}, {"w": "print(\"Epoch", "b": [0.2103, 0.3097, 0.3115, 0.3225]}, {"w": "{}/{}\".format(epoch,", "b": [0.3199, 0.3097, 0.4886, 0.3225]}, {"w": "n_epochs))", "b": [0.497, 0.3097, 0.5813, 0.3225]}, {"w": "for", "b": [0.2103, 0.3251, 0.2356, 0.3379]}, {"w": "step", "b": [0.244, 0.3251, 0.2778, 0.3379]}, {"w": "in", "b": [0.2862, 0.3251, 0.3031, 0.3379]}, {"w": "range(1,", "b": [0.3115, 0.3251, 0.379, 0.3379]}, {"w": "n_steps", "b": [0.3874, 0.3251, 0.4464, 0.3379]}, {"w": "+", "b": [0.4549, 0.3251, 0.4633, 0.3379]}, {"w": "1):", "b": [0.4717, 0.3251, 0.497, 0.3379]}, {"w": "X_batch,", "b": [0.244, 0.3405, 0.3115, 0.3534]}, {"w": "y_batch", "b": [0.3199, 0.3405, 0.379, 0.3534]}, {"w": "=", "b": [0.3874, 0.3405, 0.3958, 0.3534]}, {"w": "random_batch(X_train_scaled,", "b": [0.4043, 0.3405, 0.6404, 0.3534]}, {"w": "y_train)", "b": [0.6488, 0.3405, 0.7163, 0.3534]}, {"w": "with", "b": [0.244, 0.3559, 0.2778, 0.3688]}, {"w": "tf.GradientTape()", "b": [0.2862, 0.3559, 0.4296, 0.3688]}, {"w": "as", "b": [0.438, 0.3559, 0.4549, 0.3688]}, {"w": "tape:", "b": [0.4633, 0.3559, 0.5055, 0.3688]}, {"w": "y_pred", "b": [0.2778, 0.3714, 0.3284, 0.3842]}, {"w": "=", "b": [0.3368, 0.3714, 0.3452, 0.3842]}, {"w": "model(X_batch,", "b": [0.3537, 0.3714, 0.4717, 0.3842]}, {"w": "training=True)", "b": [0.4802, 0.3714, 0.5982, 0.3842]}, {"w": "main_loss", "b": [0.2778, 0.3868, 0.3537, 0.3996]}, {"w": "=", "b": [0.3621, 0.3868, 0.3705, 0.3996]}, {"w": "tf.reduce_mean(loss_fn(y_batch,", "b": [0.379, 0.3868, 0.6404, 0.3996]}, {"w": "y_pred))", "b": [0.6488, 0.3868, 0.7163, 0.3996]}, {"w": "loss", "b": [0.2778, 0.4022, 0.3115, 0.415]}, {"w": "=", "b": [0.3199, 0.4022, 0.3284, 0.415]}, {"w": "tf.add_n([main_loss]", "b": [0.3368, 0.4022, 0.5055, 0.415]}, {"w": "+", "b": [0.5139, 0.4022, 0.5223, 0.415]}, {"w": "model.losses)", "b": [0.5308, 0.4022, 0.6404, 0.415]}, {"w": "gradients", "b": [0.244, 0.4176, 0.3199, 0.4305]}, {"w": "=", "b": [0.3284, 0.4176, 0.3368, 0.4305]}, {"w": "tape.gradient(loss,", "b": [0.3452, 0.4176, 0.5055, 0.4305]}, {"w": "model.trainable_variables)", "b": [0.5139, 0.4176, 0.7331, 0.4305]}, {"w": "optimizer.apply_gradients(zip(gradients,", "b": [0.244, 0.433, 0.5813, 0.4459]}, {"w": "model.trainable_variables))", "b": [0.5898, 0.433, 0.8175, 0.4459]}, {"w": "mean_loss(loss)", "b": [0.244, 0.4485, 0.3705, 0.4613]}, {"w": "for", "b": [0.244, 0.4639, 0.2693, 0.4767]}, {"w": "metric", "b": [0.2778, 0.4639, 0.3284, 0.4767]}, {"w": "in", "b": [0.3368, 0.4639, 0.3537, 0.4767]}, {"w": "metrics:", "b": [0.3621, 0.4639, 0.4296, 0.4767]}, {"w": "metric(y_batch,", "b": [0.2778, 0.4793, 0.4043, 0.4921]}, {"w": "y_pred)", "b": [0.4127, 0.4793, 0.4717, 0.4921]}, {"w": "print_status_bar(step", "b": [0.244, 0.4947, 0.4211, 0.5076]}, {"w": "*", "b": [0.4296, 0.4947, 0.438, 0.5076]}, {"w": "batch_size,", "b": [0.4464, 0.4947, 0.5392, 0.5076]}, {"w": "len(y_train),", "b": [0.5476, 0.4947, 0.6572, 0.5076]}, {"w": "mean_loss,", "b": [0.6657, 0.4947, 0.75, 0.5076]}, {"w": "metrics)", "b": [0.7584, 0.4947, 0.8259, 0.5076]}, {"w": "print_status_bar(len(y_train),", "b": [0.2103, 0.5101, 0.4633, 0.523]}, {"w": "len(y_train),", "b": [0.4717, 0.5101, 0.5813, 0.523]}, {"w": "mean_loss,", "b": [0.5898, 0.5101, 0.6741, 0.523]}, {"w": "metrics)", "b": [0.6825, 0.5101, 0.75, 0.523]}, {"w": "for", "b": [0.2103, 0.5255, 0.2356, 0.5384]}, {"w": "metric", "b": [0.244, 0.5255, 0.2946, 0.5384]}, {"w": "in", "b": [0.3031, 0.5255, 0.3199, 0.5384]}, {"w": "[mean_loss]", "b": [0.3284, 0.5255, 0.4211, 0.5384]}, {"w": "+", "b": [0.4296, 0.5255, 0.438, 0.5384]}, {"w": "metrics:", "b": [0.4464, 0.5255, 0.5139, 0.5384]}, {"w": "metric.reset_states()", "b": [0.244, 0.541, 0.4211, 0.5538]}]}, {"id": "b_4", "type": "paragraph", "text": "There’s a lot going on in this code, so let’s walk through it:", "words": [{"w": "There’s", "b": [0.1429, 0.5616, 0.2014, 0.583]}, {"w": "a", "b": [0.2061, 0.5616, 0.2153, 0.583]}, {"w": "lot", "b": [0.22, 0.5616, 0.2422, 0.583]}, {"w": "going", "b": [0.247, 0.5616, 0.2941, 0.583]}, {"w": "on", "b": [0.2988, 0.5616, 0.3208, 0.583]}, {"w": "in", "b": [0.3255, 0.5616, 0.3425, 0.583]}, {"w": "this", "b": [0.3473, 0.5616, 0.378, 0.583]}, {"w": "code,", "b": [0.3827, 0.5616, 0.4267, 0.583]}, {"w": "so", "b": [0.4315, 0.5616, 0.4497, 0.583]}, {"w": "let’s", "b": [0.4545, 0.5616, 0.4847, 0.583]}, {"w": "walk", "b": [0.4894, 0.5616, 0.5284, 0.583]}, {"w": "through", "b": [0.5332, 0.5616, 0.6009, 0.583]}, {"w": "it:", "b": [0.6057, 0.5616, 0.6224, 0.583]}]}, {"id": "b_5", "type": "paragraph", "text": "• We create two nested loops: one for the epochs, the other for the batches within an epoch.", "words": [{"w": "•", "b": [0.16, 0.5958, 0.1682, 0.6172]}, {"w": "We", "b": [0.1786, 0.5958, 0.2056, 0.6172]}, {"w": "create", "b": [0.2116, 0.5958, 0.261, 0.6172]}, {"w": "two", "b": [0.267, 0.5958, 0.2983, 0.6172]}, {"w": "nested", "b": [0.3043, 0.5958, 0.3584, 0.6172]}, {"w": "loops:", "b": [0.3644, 0.5958, 0.4142, 0.6172]}, {"w": "one", "b": [0.4202, 0.5958, 0.4511, 0.6172]}, {"w": "for", "b": [0.4571, 0.5958, 0.4816, 0.6172]}, {"w": "the", "b": [0.4877, 0.5958, 0.514, 0.6172]}, {"w": "epochs,", "b": [0.52, 0.5958, 0.5827, 0.6172]}, {"w": "the", "b": [0.5888, 0.5958, 0.6151, 0.6172]}, {"w": "other", "b": [0.6211, 0.5958, 0.6658, 0.6172]}, {"w": "for", "b": [0.6718, 0.5958, 0.6963, 0.6172]}, {"w": "the", "b": [0.7023, 0.5958, 0.7287, 0.6172]}, {"w": "batches", "b": [0.7347, 0.5958, 0.7968, 0.6172]}, {"w": "within", "b": [0.8028, 0.5958, 0.8571, 0.6172]}, {"w": "an", "b": [0.1786, 0.6148, 0.1991, 0.6362]}, {"w": "epoch.", "b": [0.2038, 0.6148, 0.2589, 0.6362]}]}, {"id": "b_6", "type": "paragraph", "text": "• Then we sample a random batch from the training set.", "words": [{"w": "•", "b": [0.16, 0.6399, 0.1682, 0.6613]}, {"w": "Then", "b": [0.1786, 0.6399, 0.2228, 0.6613]}, {"w": "we", "b": [0.2275, 0.6399, 0.2506, 0.6613]}, {"w": "sample", "b": [0.2554, 0.6399, 0.3139, 0.6613]}, {"w": "a", "b": [0.3186, 0.6399, 0.3278, 0.6613]}, {"w": "random", "b": [0.3325, 0.6399, 0.3994, 0.6613]}, {"w": "batch", "b": [0.4042, 0.6399, 0.4498, 0.6613]}, {"w": "from", "b": [0.4545, 0.6399, 0.4961, 0.6613]}, {"w": "the", "b": [0.5008, 0.6399, 0.5272, 0.6613]}, {"w": "training", "b": [0.5319, 0.6399, 0.5988, 0.6613]}, {"w": "set.", "b": [0.6036, 0.6399, 0.6312, 0.6613]}]}, {"id": "b_7", "type": "paragraph", "text": "• Inside the tf.GradientTape() block, we make a prediction for one batch (using the model as a function), and we compute the loss: it is equal to the main loss plus the other losses (in this model, there is one regularization loss per layer). Since the mean_squared_error() function returns one loss per instance, we compute the mean over the batch using tf.reduce_mean() (if you wanted to apply different weights to each instance, this is where you would do it). The regu‐ larization losses are already reduced to a single scalar each, so we just need to sum them (using tf.add_n(), which sums multiple tensors of the same shape and data type).", "words": [{"w": "•", "b": [0.16, 0.6659, 0.1682, 0.6873]}, {"w": "Inside", "b": [0.1786, 0.6659, 0.2301, 0.6873]}, {"w": "the", "b": [0.236, 0.6659, 0.2623, 0.6873]}, {"w": "tf.GradientTape()", "b": [0.2681, 0.6691, 0.4363, 0.6842]}, {"w": "block,", "b": [0.4421, 0.6659, 0.4925, 0.6873]}, {"w": "we", "b": [0.4983, 0.6659, 0.5214, 0.6873]}, {"w": "make", "b": [0.5272, 0.6659, 0.5726, 0.6873]}, {"w": "a", "b": [0.5784, 0.6659, 0.5876, 0.6873]}, {"w": "prediction", "b": [0.5934, 0.6659, 0.6802, 0.6873]}, {"w": "for", "b": [0.6861, 0.6659, 0.7106, 0.6873]}, {"w": "one", "b": [0.7164, 0.6659, 0.7473, 0.6873]}, {"w": "batch", "b": [0.7531, 0.6659, 0.7987, 0.6873]}, {"w": "(using", "b": [0.8045, 0.6659, 0.8571, 0.6873]}, {"w": "the", "b": [0.1786, 0.6849, 0.2049, 0.7064]}, {"w": "model", "b": [0.2119, 0.6849, 0.2647, 0.7064]}, {"w": "as", "b": [0.2717, 0.6849, 0.2885, 0.7064]}, {"w": "a", "b": [0.2955, 0.6849, 0.3047, 0.7064]}, {"w": "function),", "b": [0.3117, 0.6849, 0.395, 0.7064]}, {"w": "and", "b": [0.402, 0.6849, 0.4336, 0.7064]}, {"w": "we", "b": [0.4406, 0.6849, 0.4637, 0.7064]}, {"w": "compute", "b": [0.4707, 0.6849, 0.544, 0.7064]}, {"w": "the", "b": [0.551, 0.6849, 0.5773, 0.7064]}, {"w": "loss:", "b": [0.5843, 0.6849, 0.6203, 0.7064]}, {"w": "it", "b": [0.6273, 0.6849, 0.6392, 0.7064]}, {"w": "is", "b": [0.6462, 0.6849, 0.6595, 0.7064]}, {"w": "equal", "b": [0.6665, 0.6849, 0.7114, 0.7064]}, {"w": "to", "b": [0.7184, 0.6849, 0.7354, 0.7064]}, {"w": "the", "b": [0.7424, 0.6849, 0.7688, 0.7064]}, {"w": "main", "b": [0.7758, 0.6849, 0.819, 0.7064]}, {"w": "loss", "b": [0.826, 0.6849, 0.8571, 0.7064]}, {"w": "plus", "b": [0.1786, 0.704, 0.2135, 0.7254]}, {"w": "the", "b": [0.221, 0.704, 0.2473, 0.7254]}, {"w": "other", "b": [0.2549, 0.704, 0.2996, 0.7254]}, {"w": "losses", "b": [0.3071, 0.704, 0.3548, 0.7254]}, {"w": "(in", "b": [0.3623, 0.704, 0.3865, 0.7254]}, {"w": "this", "b": [0.3941, 0.704, 0.4248, 0.7254]}, {"w": "model,", "b": [0.4323, 0.704, 0.4899, 0.7254]}, {"w": "there", "b": [0.4974, 0.704, 0.5403, 0.7254]}, {"w": "is", "b": [0.5479, 0.704, 0.5611, 0.7254]}, {"w": "one", "b": [0.5687, 0.704, 0.5995, 0.7254]}, {"w": "regularization", "b": [0.6071, 0.704, 0.7237, 0.7254]}, {"w": "loss", "b": [0.7312, 0.704, 0.7624, 0.7254]}, {"w": "per", "b": [0.7699, 0.704, 0.7974, 0.7254]}, {"w": "layer).", "b": [0.805, 0.704, 0.8571, 0.7254]}, {"w": "Since", "b": [0.1786, 0.7239, 0.2231, 0.7454]}, {"w": "the", "b": [0.2332, 0.7239, 0.2595, 0.7454]}, {"w": "mean_squared_error()", "b": [0.2697, 0.7271, 0.4676, 0.7422]}, {"w": "function", "b": [0.4777, 0.7239, 0.5491, 0.7454]}, {"w": "returns", "b": [0.5592, 0.7239, 0.62, 0.7454]}, {"w": "one", "b": [0.6301, 0.7239, 0.6609, 0.7454]}, {"w": "loss", "b": [0.6711, 0.7239, 0.7022, 0.7454]}, {"w": "per", "b": [0.7124, 0.7239, 0.7399, 0.7454]}, {"w": "instance,", "b": [0.75, 0.7239, 0.8239, 0.7454]}, {"w": "we", "b": [0.834, 0.7239, 0.8571, 0.7454]}, {"w": "compute", "b": [0.1786, 0.7439, 0.2519, 0.7653]}, {"w": "the", "b": [0.2602, 0.7439, 0.2866, 0.7653]}, {"w": "mean", "b": [0.2949, 0.7439, 0.3414, 0.7653]}, {"w": "over", "b": [0.3498, 0.7439, 0.3866, 0.7653]}, {"w": "the", "b": [0.395, 0.7439, 0.4213, 0.7653]}, {"w": "batch", "b": [0.4297, 0.7439, 0.4753, 0.7653]}, {"w": "using", "b": [0.4837, 0.7439, 0.5291, 0.7653]}, {"w": "tf.reduce_mean()", "b": [0.5375, 0.7471, 0.6959, 0.7621]}, {"w": "(if", "b": [0.7042, 0.7439, 0.7232, 0.7653]}, {"w": "you", "b": [0.7316, 0.7439, 0.7628, 0.7653]}, {"w": "wanted", "b": [0.7712, 0.7439, 0.8318, 0.7653]}, {"w": "to", "b": [0.8402, 0.7439, 0.8572, 0.7653]}, {"w": "apply", "b": [0.1786, 0.7629, 0.224, 0.7843]}, {"w": "different", "b": [0.2288, 0.7629, 0.3006, 0.7843]}, {"w": "weights", "b": [0.3054, 0.7629, 0.3686, 0.7843]}, {"w": "to", "b": [0.3735, 0.7629, 0.3904, 0.7843]}, {"w": "each", "b": [0.3953, 0.7629, 0.4332, 0.7843]}, {"w": "instance,", "b": [0.4381, 0.7629, 0.512, 0.7843]}, {"w": "this", "b": [0.5169, 0.7629, 0.5476, 0.7843]}, {"w": "is", "b": [0.5524, 0.7629, 0.5657, 0.7843]}, {"w": "where", "b": [0.5705, 0.7629, 0.6214, 0.7843]}, {"w": "you", "b": [0.6262, 0.7629, 0.6575, 0.7843]}, {"w": "would", "b": [0.6623, 0.7629, 0.7145, 0.7843]}, {"w": "do", "b": [0.7194, 0.7629, 0.741, 0.7843]}, {"w": "it).", "b": [0.7459, 0.7629, 0.7698, 0.7843]}, {"w": "The", "b": [0.7746, 0.7629, 0.8075, 0.7843]}, {"w": "regu‐", "b": [0.8123, 0.7629, 0.8571, 0.7843]}, {"w": "larization", "b": [0.1786, 0.782, 0.2578, 0.8034]}, {"w": "losses", "b": [0.2652, 0.782, 0.3129, 0.8034]}, {"w": "are", "b": [0.3203, 0.782, 0.346, 0.8034]}, {"w": "already", "b": [0.3535, 0.782, 0.4142, 0.8034]}, {"w": "reduced", "b": [0.4216, 0.782, 0.4889, 0.8034]}, {"w": "to", "b": [0.4964, 0.782, 0.5133, 0.8034]}, {"w": "a", "b": [0.5208, 0.782, 0.5299, 0.8034]}, {"w": "single", "b": [0.5373, 0.782, 0.5858, 0.8034]}, {"w": "scalar", "b": [0.5933, 0.782, 0.641, 0.8034]}, {"w": "each,", "b": [0.6484, 0.782, 0.6911, 0.8034]}, {"w": "so", "b": [0.6986, 0.782, 0.7168, 0.8034]}, {"w": "we", "b": [0.7243, 0.782, 0.7474, 0.8034]}, {"w": "just", "b": [0.7548, 0.782, 0.7852, 0.8034]}, {"w": "need", "b": [0.7926, 0.782, 0.8327, 0.8034]}, {"w": "to", "b": [0.8402, 0.782, 0.8572, 0.8034]}, {"w": "sum", "b": [0.1786, 0.8019, 0.2143, 0.8233]}, {"w": "them", "b": [0.2221, 0.8019, 0.2655, 0.8233]}, {"w": "(using", "b": [0.2733, 0.8019, 0.3259, 0.8233]}, {"w": "tf.add_n(),", "b": [0.3337, 0.8019, 0.4374, 0.8233]}, {"w": "which", "b": [0.4451, 0.8019, 0.496, 0.8233]}, {"w": "sums", "b": [0.5038, 0.8019, 0.5472, 0.8233]}, {"w": "multiple", "b": [0.555, 0.8019, 0.625, 0.8233]}, {"w": "tensors", "b": [0.6327, 0.8019, 0.693, 0.8233]}, {"w": "of", "b": [0.7007, 0.8019, 0.7175, 0.8233]}, {"w": "the", "b": [0.7253, 0.8019, 0.7516, 0.8233]}, {"w": "same", "b": [0.7594, 0.8019, 0.8021, 0.8233]}, {"w": "shape", "b": [0.8098, 0.8019, 0.8571, 0.8233]}, {"w": "and", "b": [0.1786, 0.821, 0.2101, 0.8424]}, {"w": "data", "b": [0.2148, 0.821, 0.2501, 0.8424]}, {"w": "type).", "b": [0.2548, 0.821, 0.3025, 0.8424]}]}, {"id": "b_8", "type": "paragraph", "text": "Customizing Models and Training Algorithms | 395", "words": [{"w": "Customizing", "b": [0.5328, 0.9225, 0.6056, 0.9388]}, {"w": "Models", "b": [0.6084, 0.9225, 0.6507, 0.9388]}, {"w": "and", "b": [0.6535, 0.9225, 0.6759, 0.9388]}, {"w": "Training", "b": [0.6787, 0.9225, 0.7278, 0.9388]}, {"w": "Algorithms", "b": [0.7306, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "395", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 422, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "11 The truth is we did not process every single instance in the training set because we sampled instances ran‐ domly, so some were processed more than once while others were not processed at all. In practice that’s fine. Moreover, if the training set size is not a multiple of the batch size, we will miss a few instances.", "words": [{"w": "11", "b": [0.1385, 0.8058, 0.1518, 0.8201]}, {"w": "The", "b": [0.1587, 0.8043, 0.1837, 0.8206]}, {"w": "truth", "b": [0.1873, 0.8043, 0.2198, 0.8206]}, {"w": "is", "b": [0.2234, 0.8043, 0.2335, 0.8206]}, {"w": "we", "b": [0.2371, 0.8043, 0.2547, 0.8206]}, {"w": "did", "b": [0.2583, 0.8043, 0.2793, 0.8206]}, {"w": "not", "b": [0.283, 0.8043, 0.3046, 0.8206]}, {"w": "process", "b": [0.3082, 0.8043, 0.3556, 0.8206]}, {"w": "every", "b": [0.3592, 0.8043, 0.3937, 0.8206]}, {"w": "single", "b": [0.3973, 0.8043, 0.4342, 0.8206]}, {"w": "instance", "b": [0.4378, 0.8043, 0.4905, 0.8206]}, {"w": "in", "b": [0.4941, 0.8043, 0.5071, 0.8206]}, {"w": "the", "b": [0.5107, 0.8043, 0.5307, 0.8206]}, {"w": "training", "b": [0.5343, 0.8043, 0.5853, 0.8206]}, {"w": "set", "b": [0.589, 0.8043, 0.6064, 0.8206]}, {"w": "because", "b": [0.61, 0.8043, 0.6592, 0.8206]}, {"w": "we", "b": [0.6628, 0.8043, 0.6804, 0.8206]}, {"w": "sampled", "b": [0.684, 0.8043, 0.7369, 0.8206]}, {"w": "instances", "b": [0.7405, 0.8043, 0.7991, 0.8206]}, {"w": "ran‐", "b": [0.8027, 0.8043, 0.8299, 0.8206]}, {"w": "domly,", "b": [0.1587, 0.8194, 0.202, 0.8358]}, {"w": "so", "b": [0.2056, 0.8194, 0.2195, 0.8358]}, {"w": "some", "b": [0.2231, 0.8194, 0.2568, 0.8358]}, {"w": "were", "b": [0.2604, 0.8194, 0.2906, 0.8358]}, {"w": "processed", "b": [0.2942, 0.8194, 0.3568, 0.8358]}, {"w": "more", "b": [0.3604, 0.8194, 0.3941, 0.8358]}, {"w": "than", "b": [0.3977, 0.8194, 0.4267, 0.8358]}, {"w": "once", "b": [0.4303, 0.8194, 0.4605, 0.8358]}, {"w": "while", "b": [0.4641, 0.8194, 0.4985, 0.8358]}, {"w": "others", "b": [0.5021, 0.8194, 0.542, 0.8358]}, {"w": "were", "b": [0.5456, 0.8194, 0.5758, 0.8358]}, {"w": "not", "b": [0.5794, 0.8194, 0.601, 0.8358]}, {"w": "processed", "b": [0.6046, 0.8194, 0.6672, 0.8358]}, {"w": "at", "b": [0.6708, 0.8194, 0.6823, 0.8358]}, {"w": "all.", "b": [0.6859, 0.8194, 0.7045, 0.8358]}, {"w": "In", "b": [0.7081, 0.8194, 0.7222, 0.8358]}, {"w": "practice", "b": [0.7258, 0.8194, 0.7763, 0.8358]}, {"w": "that’s", "b": [0.7799, 0.8194, 0.8121, 0.8358]}, {"w": "fine.", "b": [0.8157, 0.8194, 0.8437, 0.8358]}, {"w": "Moreover,", "b": [0.1587, 0.8346, 0.2239, 0.8509]}, {"w": "if", "b": [0.2275, 0.8346, 0.2364, 0.8509]}, {"w": "the", "b": [0.24, 0.8346, 0.2601, 0.8509]}, {"w": "training", "b": [0.2637, 0.8346, 0.3147, 0.8509]}, {"w": "set", "b": [0.3183, 0.8346, 0.3357, 0.8509]}, {"w": "size", "b": [0.3393, 0.8346, 0.3628, 0.8509]}, {"w": "is", "b": [0.3664, 0.8346, 0.3765, 0.8509]}, {"w": "not", "b": [0.3801, 0.8346, 0.4017, 0.8509]}, {"w": "a", "b": [0.4053, 0.8346, 0.4123, 0.8509]}, {"w": "multiple", "b": [0.4159, 0.8346, 0.4692, 0.8509]}, {"w": "of", "b": [0.4728, 0.8346, 0.4856, 0.8509]}, {"w": "the", "b": [0.4892, 0.8346, 0.5093, 0.8509]}, {"w": "batch", "b": [0.5129, 0.8346, 0.5477, 0.8509]}, {"w": "size,", "b": [0.5513, 0.8346, 0.5784, 0.8509]}, {"w": "we", "b": [0.582, 0.8346, 0.5996, 0.8509]}, {"w": "will", "b": [0.6032, 0.8346, 0.6263, 0.8509]}, {"w": "miss", "b": [0.63, 0.8346, 0.6589, 0.8509]}, {"w": "a", "b": [0.6625, 0.8346, 0.6694, 0.8509]}, {"w": "few", "b": [0.673, 0.8346, 0.6953, 0.8509]}, {"w": "instances.", "b": [0.699, 0.8346, 0.7611, 0.8509]}]}, {"id": "b_1", "type": "paragraph", "text": "12 Alternatively, check out K.learning_phase(), K.set_learning_phase() and K.learning_phase_scope().", "words": [{"w": "12", "b": [0.1385, 0.8568, 0.1518, 0.871]}, {"w": "Alternatively,", "b": [0.1587, 0.8553, 0.2435, 0.8716]}, {"w": "check", "b": [0.2471, 0.8553, 0.2836, 0.8716]}, {"w": "out", "b": [0.2872, 0.8553, 0.3086, 0.8716]}, {"w": "K.learning_phase(),", "b": [0.3122, 0.8553, 0.4515, 0.8716]}, {"w": "K.set_learning_phase()", "b": [0.4551, 0.8577, 0.621, 0.8692]}, {"w": "and", "b": [0.6246, 0.8553, 0.6486, 0.8716]}, {"w": "K.learning_phase_scope().", "b": [0.6522, 0.8553, 0.8368, 0.8716]}]}, {"id": "b_2", "type": "paragraph", "text": "13 With the exception of optimizers, as very few people ever customize these: see the notebook for an example.", "words": [{"w": "13", "b": [0.1384, 0.8764, 0.1518, 0.8907]}, {"w": "With", "b": [0.1587, 0.8749, 0.1911, 0.8912]}, {"w": "the", "b": [0.1947, 0.8749, 0.2147, 0.8912]}, {"w": "exception", "b": [0.2183, 0.8749, 0.2802, 0.8912]}, {"w": "of", "b": [0.2838, 0.8749, 0.2966, 0.8912]}, {"w": "optimizers,", "b": [0.3002, 0.8749, 0.3717, 0.8912]}, {"w": "as", "b": [0.3753, 0.8749, 0.3881, 0.8912]}, {"w": "very", "b": [0.3917, 0.8749, 0.4195, 0.8912]}, {"w": "few", "b": [0.4231, 0.8749, 0.4454, 0.8912]}, {"w": "people", "b": [0.449, 0.8749, 0.4912, 0.8912]}, {"w": "ever", "b": [0.4948, 0.8749, 0.5216, 0.8912]}, {"w": "customize", "b": [0.5252, 0.8749, 0.5897, 0.8912]}, {"w": "these:", "b": [0.5933, 0.8749, 0.6296, 0.8912]}, {"w": "see", "b": [0.6332, 0.8749, 0.6525, 0.8912]}, {"w": "the", "b": [0.6561, 0.8749, 0.6762, 0.8912]}, {"w": "notebook", "b": [0.6798, 0.8749, 0.7403, 0.8912]}, {"w": "for", "b": [0.7439, 0.8749, 0.7626, 0.8912]}, {"w": "an", "b": [0.7662, 0.8749, 0.7818, 0.8912]}, {"w": "example.", "b": [0.7854, 0.8749, 0.842, 0.8912]}]}, {"id": "b_3", "type": "paragraph", "text": "• Next, we ask the tape to compute the gradient of the loss with regards to each trainable variable (not all variables!), and we apply them to the optimizer to per‐ form a Gradient Descent step.", "words": [{"w": "•", "b": [0.16, 0.08, 0.1681, 0.1014]}, {"w": "Next,", "b": [0.1786, 0.08, 0.2233, 0.1014]}, {"w": "we", "b": [0.2302, 0.08, 0.2533, 0.1014]}, {"w": "ask", "b": [0.2602, 0.08, 0.2873, 0.1014]}, {"w": "the", "b": [0.2942, 0.08, 0.3205, 0.1014]}, {"w": "tape", "b": [0.3274, 0.0831, 0.367, 0.0982]}, {"w": "to", "b": [0.3739, 0.08, 0.3909, 0.1014]}, {"w": "compute", "b": [0.3977, 0.08, 0.471, 0.1014]}, {"w": "the", "b": [0.4779, 0.08, 0.5043, 0.1014]}, {"w": "gradient", "b": [0.5111, 0.08, 0.5806, 0.1014]}, {"w": "of", "b": [0.5874, 0.08, 0.6042, 0.1014]}, {"w": "the", "b": [0.6111, 0.08, 0.6374, 0.1014]}, {"w": "loss", "b": [0.6443, 0.08, 0.6755, 0.1014]}, {"w": "with", "b": [0.6824, 0.08, 0.7197, 0.1014]}, {"w": "regards", "b": [0.7266, 0.08, 0.7885, 0.1014]}, {"w": "to", "b": [0.7953, 0.08, 0.8123, 0.1014]}, {"w": "each", "b": [0.8192, 0.08, 0.8571, 0.1014]}, {"w": "trainable", "b": [0.1786, 0.099, 0.2526, 0.1204]}, {"w": "variable", "b": [0.2583, 0.099, 0.3242, 0.1204]}, {"w": "(not", "b": [0.3299, 0.0988, 0.364, 0.1204]}, {"w": "all", "b": [0.3696, 0.099, 0.3893, 0.1204]}, {"w": "variables!),", "b": [0.3949, 0.099, 0.4862, 0.1204]}, {"w": "and", "b": [0.4919, 0.099, 0.5234, 0.1204]}, {"w": "we", "b": [0.5291, 0.099, 0.5522, 0.1204]}, {"w": "apply", "b": [0.5578, 0.099, 0.6032, 0.1204]}, {"w": "them", "b": [0.6089, 0.099, 0.6523, 0.1204]}, {"w": "to", "b": [0.6579, 0.099, 0.6749, 0.1204]}, {"w": "the", "b": [0.6805, 0.099, 0.7069, 0.1204]}, {"w": "optimizer", "b": [0.7125, 0.099, 0.794, 0.1204]}, {"w": "to", "b": [0.7996, 0.099, 0.8166, 0.1204]}, {"w": "per‐", "b": [0.8222, 0.099, 0.8571, 0.1204]}, {"w": "form", "b": [0.1786, 0.1181, 0.2201, 0.1395]}, {"w": "a", "b": [0.2249, 0.1181, 0.234, 0.1395]}, {"w": "Gradient", "b": [0.2388, 0.1181, 0.3133, 0.1395]}, {"w": "Descent", "b": [0.318, 0.1181, 0.3849, 0.1395]}, {"w": "step.", "b": [0.3896, 0.1181, 0.4275, 0.1395]}]}, {"id": "b_4", "type": "paragraph", "text": "• Next we update the mean loss and the metrics (over the current epoch), and we display the status bar.", "words": [{"w": "•", "b": [0.16, 0.1431, 0.1682, 0.1646]}, {"w": "Next", "b": [0.1786, 0.1431, 0.2186, 0.1646]}, {"w": "we", "b": [0.2247, 0.1431, 0.2478, 0.1646]}, {"w": "update", "b": [0.2539, 0.1431, 0.3109, 0.1646]}, {"w": "the", "b": [0.317, 0.1431, 0.3433, 0.1646]}, {"w": "mean", "b": [0.3495, 0.1431, 0.3959, 0.1646]}, {"w": "loss", "b": [0.402, 0.1431, 0.4332, 0.1646]}, {"w": "and", "b": [0.4393, 0.1431, 0.4709, 0.1646]}, {"w": "the", "b": [0.477, 0.1431, 0.5033, 0.1646]}, {"w": "metrics", "b": [0.5095, 0.1431, 0.5715, 0.1646]}, {"w": "(over", "b": [0.5776, 0.1431, 0.6217, 0.1646]}, {"w": "the", "b": [0.6278, 0.1431, 0.6541, 0.1646]}, {"w": "current", "b": [0.6603, 0.1431, 0.7218, 0.1646]}, {"w": "epoch),", "b": [0.7279, 0.1431, 0.7902, 0.1646]}, {"w": "and", "b": [0.7963, 0.1431, 0.8279, 0.1646]}, {"w": "we", "b": [0.834, 0.1431, 0.8571, 0.1646]}, {"w": "display", "b": [0.1786, 0.1622, 0.2373, 0.1836]}, {"w": "the", "b": [0.2421, 0.1622, 0.2684, 0.1836]}, {"w": "status", "b": [0.2731, 0.1622, 0.3209, 0.1836]}, {"w": "bar.", "b": [0.3257, 0.1622, 0.3566, 0.1836]}]}, {"id": "b_5", "type": "paragraph", "text": "• At the end of each epoch, we display the status bar again to make it look com‐ plete11 and to print a line feed, and we reset the states of the mean loss and the metrics.", "words": [{"w": "•", "b": [0.16, 0.1873, 0.1682, 0.2087]}, {"w": "At", "b": [0.1786, 0.1873, 0.1985, 0.2087]}, {"w": "the", "b": [0.2052, 0.1873, 0.2315, 0.2087]}, {"w": "end", "b": [0.2383, 0.1873, 0.2695, 0.2087]}, {"w": "of", "b": [0.2762, 0.1873, 0.293, 0.2087]}, {"w": "each", "b": [0.2998, 0.1873, 0.3377, 0.2087]}, {"w": "epoch,", "b": [0.3444, 0.1873, 0.3995, 0.2087]}, {"w": "we", "b": [0.4062, 0.1873, 0.4294, 0.2087]}, {"w": "display", "b": [0.4361, 0.1873, 0.4948, 0.2087]}, {"w": "the", "b": [0.5016, 0.1873, 0.5279, 0.2087]}, {"w": "status", "b": [0.5346, 0.1873, 0.5825, 0.2087]}, {"w": "bar", "b": [0.5892, 0.1873, 0.6166, 0.2087]}, {"w": "again", "b": [0.6234, 0.1873, 0.6684, 0.2087]}, {"w": "to", "b": [0.6751, 0.1873, 0.6921, 0.2087]}, {"w": "make", "b": [0.6988, 0.1873, 0.7442, 0.2087]}, {"w": "it", "b": [0.751, 0.1873, 0.7629, 0.2087]}, {"w": "look", "b": [0.7696, 0.1873, 0.8065, 0.2087]}, {"w": "com‐", "b": [0.8132, 0.1873, 0.8571, 0.2087]}, {"w": "plete11", "b": [0.1786, 0.2063, 0.2303, 0.2278]}, {"w": "and", "b": [0.2369, 0.2063, 0.2684, 0.2278]}, {"w": "to", "b": [0.275, 0.2063, 0.292, 0.2278]}, {"w": "print", "b": [0.2986, 0.2063, 0.3402, 0.2278]}, {"w": "a", "b": [0.3468, 0.2063, 0.3559, 0.2278]}, {"w": "line", "b": [0.3625, 0.2063, 0.3936, 0.2278]}, {"w": "feed,", "b": [0.4002, 0.2063, 0.4398, 0.2278]}, {"w": "and", "b": [0.4464, 0.2063, 0.478, 0.2278]}, {"w": "we", "b": [0.4846, 0.2063, 0.5077, 0.2278]}, {"w": "reset", "b": [0.5143, 0.2063, 0.5538, 0.2278]}, {"w": "the", "b": [0.5604, 0.2063, 0.5867, 0.2278]}, {"w": "states", "b": [0.5933, 0.2063, 0.6389, 0.2278]}, {"w": "of", "b": [0.6455, 0.2063, 0.6623, 0.2278]}, {"w": "the", "b": [0.6689, 0.2063, 0.6952, 0.2278]}, {"w": "mean", "b": [0.7018, 0.2063, 0.7483, 0.2278]}, {"w": "loss", "b": [0.7549, 0.2063, 0.7861, 0.2278]}, {"w": "and", "b": [0.7927, 0.2063, 0.8242, 0.2278]}, {"w": "the", "b": [0.8308, 0.2063, 0.8571, 0.2278]}, {"w": "metrics.", "b": [0.1786, 0.2254, 0.2454, 0.2468]}]}, {"id": "b_6", "type": "paragraph", "text": "If you set the optimizer’s clipnorm or clipvalue hyperparameters, it will take care of this for you. If you want to apply any other transformation to the gradients, simply do so before calling the apply_gradients() method.", "words": [{"w": "If", "b": [0.1429, 0.2604, 0.1561, 0.2819]}, {"w": "you", "b": [0.1614, 0.2604, 0.1926, 0.2819]}, {"w": "set", "b": [0.1978, 0.2604, 0.2207, 0.2819]}, {"w": "the", "b": [0.2259, 0.2604, 0.2522, 0.2819]}, {"w": "optimizer’s", "b": [0.2575, 0.2604, 0.3492, 0.2819]}, {"w": "clipnorm", "b": [0.3545, 0.2636, 0.4336, 0.2787]}, {"w": "or", "b": [0.4389, 0.2604, 0.4572, 0.2819]}, {"w": "clipvalue", "b": [0.4625, 0.2636, 0.5515, 0.2787]}, {"w": "hyperparameters,", "b": [0.5567, 0.2604, 0.7026, 0.2819]}, {"w": "it", "b": [0.7079, 0.2604, 0.7198, 0.2819]}, {"w": "will", "b": [0.725, 0.2604, 0.7554, 0.2819]}, {"w": "take", "b": [0.7607, 0.2604, 0.7953, 0.2819]}, {"w": "care", "b": [0.8006, 0.2604, 0.8351, 0.2819]}, {"w": "of", "b": [0.8403, 0.2604, 0.8571, 0.2819]}, {"w": "this", "b": [0.1429, 0.2795, 0.1736, 0.3009]}, {"w": "for", "b": [0.1784, 0.2795, 0.2029, 0.3009]}, {"w": "you.", "b": [0.2077, 0.2795, 0.2437, 0.3009]}, {"w": "If", "b": [0.2485, 0.2795, 0.2618, 0.3009]}, {"w": "you", "b": [0.2666, 0.2795, 0.2978, 0.3009]}, {"w": "want", "b": [0.3026, 0.2795, 0.3434, 0.3009]}, {"w": "to", "b": [0.3482, 0.2795, 0.3652, 0.3009]}, {"w": "apply", "b": [0.37, 0.2795, 0.4154, 0.3009]}, {"w": "any", "b": [0.4202, 0.2795, 0.4499, 0.3009]}, {"w": "other", "b": [0.4547, 0.2795, 0.4994, 0.3009]}, {"w": "transformation", "b": [0.5042, 0.2795, 0.6307, 0.3009]}, {"w": "to", "b": [0.6355, 0.2795, 0.6525, 0.3009]}, {"w": "the", "b": [0.6573, 0.2795, 0.6836, 0.3009]}, {"w": "gradients,", "b": [0.6885, 0.2795, 0.7703, 0.3009]}, {"w": "simply", "b": [0.7751, 0.2795, 0.8307, 0.3009]}, {"w": "do", "b": [0.8355, 0.2795, 0.8572, 0.3009]}, {"w": "so", "b": [0.1429, 0.2994, 0.1611, 0.3209]}, {"w": "before", "b": [0.1659, 0.2994, 0.2187, 0.3209]}, {"w": "calling", "b": [0.2234, 0.2994, 0.2786, 0.3209]}, {"w": "the", "b": [0.2834, 0.2994, 0.3097, 0.3209]}, {"w": "apply_gradients()", "b": [0.3144, 0.3026, 0.4827, 0.3177]}, {"w": "method.", "b": [0.4874, 0.2994, 0.5572, 0.3209]}]}, {"id": "b_7", "type": "paragraph", "text": "If you add weight constraints to your model (e.g., by setting kernel_constraint or bias_constraint when creating a layer), you should update the training loop to apply these constraints just after apply_gradients():", "words": [{"w": "If", "b": [0.1429, 0.3285, 0.1561, 0.3499]}, {"w": "you", "b": [0.1627, 0.3285, 0.194, 0.3499]}, {"w": "add", "b": [0.2006, 0.3285, 0.2317, 0.3499]}, {"w": "weight", "b": [0.2383, 0.3285, 0.2939, 0.3499]}, {"w": "constraints", "b": [0.3005, 0.3285, 0.3928, 0.3499]}, {"w": "to", "b": [0.3994, 0.3285, 0.4164, 0.3499]}, {"w": "your", "b": [0.423, 0.3285, 0.462, 0.3499]}, {"w": "model", "b": [0.4686, 0.3285, 0.5214, 0.3499]}, {"w": "(e.g.,", "b": [0.528, 0.3285, 0.5681, 0.3499]}, {"w": "by", "b": [0.5747, 0.3285, 0.5948, 0.3499]}, {"w": "setting", "b": [0.6014, 0.3285, 0.6573, 0.3499]}, {"w": "kernel_constraint", "b": [0.664, 0.3316, 0.8322, 0.3467]}, {"w": "or", "b": [0.8388, 0.3285, 0.8571, 0.3499]}, {"w": "bias_constraint", "b": [0.1429, 0.3516, 0.2913, 0.3667]}, {"w": "when", "b": [0.3003, 0.3484, 0.346, 0.3698]}, {"w": "creating", "b": [0.355, 0.3484, 0.4222, 0.3698]}, {"w": "a", "b": [0.4312, 0.3484, 0.4403, 0.3698]}, {"w": "layer),", "b": [0.4494, 0.3484, 0.5015, 0.3698]}, {"w": "you", "b": [0.5105, 0.3484, 0.5418, 0.3698]}, {"w": "should", "b": [0.5508, 0.3484, 0.6075, 0.3698]}, {"w": "update", "b": [0.6165, 0.3484, 0.6734, 0.3698]}, {"w": "the", "b": [0.6824, 0.3484, 0.7088, 0.3698]}, {"w": "training", "b": [0.7178, 0.3484, 0.7847, 0.3698]}, {"w": "loop", "b": [0.7937, 0.3484, 0.8312, 0.3698]}, {"w": "to", "b": [0.8402, 0.3484, 0.8572, 0.3698]}, {"w": "apply", "b": [0.1429, 0.3683, 0.1883, 0.3898]}, {"w": "these", "b": [0.193, 0.3683, 0.2358, 0.3898]}, {"w": "constraints", "b": [0.2406, 0.3683, 0.3329, 0.3898]}, {"w": "just", "b": [0.3376, 0.3683, 0.368, 0.3898]}, {"w": "after", "b": [0.3727, 0.3683, 0.411, 0.3898]}, {"w": "apply_gradients():", "b": [0.4157, 0.3683, 0.5887, 0.3898]}]}, {"id": "b_8", "type": "paragraph", "text": "for variable in model.variables: if variable.constraint is not None: variable.assign(variable.constraint(variable))", "words": [{"w": "for", "b": [0.1766, 0.4003, 0.2019, 0.4132]}, {"w": "variable", "b": [0.2103, 0.4003, 0.2778, 0.4132]}, {"w": "in", "b": [0.2862, 0.4003, 0.3031, 0.4132]}, {"w": "model.variables:", "b": [0.3115, 0.4003, 0.4464, 0.4132]}, {"w": "if", "b": [0.2103, 0.4157, 0.2272, 0.4286]}, {"w": "variable.constraint", "b": [0.2356, 0.4157, 0.3958, 0.4286]}, {"w": "is", "b": [0.4043, 0.4157, 0.4211, 0.4286]}, {"w": "not", "b": [0.4296, 0.4157, 0.4549, 0.4286]}, {"w": "None:", "b": [0.4633, 0.4157, 0.5055, 0.4286]}, {"w": "variable.assign(variable.constraint(variable))", "b": [0.2441, 0.4312, 0.6319, 0.444]}]}, {"id": "b_9", "type": "paragraph", "text": "Most importantly, this training loop does not handle layers that behave differently during training and testing (e.g., BatchNormalization or Dropout). To handle these, you need to call the model with training=True and make sure it propagates this to every layer that needs it.12", "words": [{"w": "Most", "b": [0.1429, 0.4518, 0.1855, 0.4732]}, {"w": "importantly,", "b": [0.1933, 0.4518, 0.2958, 0.4732]}, {"w": "this", "b": [0.3036, 0.4518, 0.3343, 0.4732]}, {"w": "training", "b": [0.3421, 0.4518, 0.4091, 0.4732]}, {"w": "loop", "b": [0.4169, 0.4518, 0.4543, 0.4732]}, {"w": "does", "b": [0.4621, 0.4518, 0.5003, 0.4732]}, {"w": "not", "b": [0.5081, 0.4518, 0.5365, 0.4732]}, {"w": "handle", "b": [0.5443, 0.4518, 0.6011, 0.4732]}, {"w": "layers", "b": [0.6089, 0.4518, 0.6567, 0.4732]}, {"w": "that", "b": [0.6645, 0.4518, 0.6971, 0.4732]}, {"w": "behave", "b": [0.705, 0.4518, 0.7628, 0.4732]}, {"w": "differently", "b": [0.7706, 0.4518, 0.8571, 0.4732]}, {"w": "during", "b": [0.1429, 0.4717, 0.1994, 0.4931]}, {"w": "training", "b": [0.2054, 0.4717, 0.2723, 0.4931]}, {"w": "and", "b": [0.2783, 0.4717, 0.3098, 0.4931]}, {"w": "testing", "b": [0.3158, 0.4717, 0.3717, 0.4931]}, {"w": "(e.g.,", "b": [0.3777, 0.4717, 0.4178, 0.4931]}, {"w": "BatchNormalization", "b": [0.4237, 0.4749, 0.6019, 0.49]}, {"w": "or", "b": [0.6078, 0.4717, 0.6262, 0.4931]}, {"w": "Dropout).", "b": [0.6322, 0.4717, 0.7134, 0.4931]}, {"w": "To", "b": [0.7194, 0.4717, 0.7408, 0.4931]}, {"w": "handle", "b": [0.7468, 0.4717, 0.8036, 0.4931]}, {"w": "these,", "b": [0.8096, 0.4717, 0.8571, 0.4931]}, {"w": "you", "b": [0.1429, 0.4917, 0.1741, 0.5131]}, {"w": "need", "b": [0.1805, 0.4917, 0.2206, 0.5131]}, {"w": "to", "b": [0.227, 0.4917, 0.244, 0.5131]}, {"w": "call", "b": [0.2504, 0.4917, 0.2789, 0.5131]}, {"w": "the", "b": [0.2853, 0.4917, 0.3117, 0.5131]}, {"w": "model", "b": [0.3181, 0.4917, 0.3709, 0.5131]}, {"w": "with", "b": [0.3773, 0.4917, 0.4146, 0.5131]}, {"w": "training=True", "b": [0.4211, 0.4949, 0.5497, 0.5099]}, {"w": "and", "b": [0.5561, 0.4917, 0.5877, 0.5131]}, {"w": "make", "b": [0.5941, 0.4917, 0.6395, 0.5131]}, {"w": "sure", "b": [0.6459, 0.4917, 0.6812, 0.5131]}, {"w": "it", "b": [0.6876, 0.4917, 0.6995, 0.5131]}, {"w": "propagates", "b": [0.7059, 0.4917, 0.7966, 0.5131]}, {"w": "this", "b": [0.803, 0.4917, 0.8337, 0.5131]}, {"w": "to", "b": [0.8402, 0.4917, 0.8571, 0.5131]}, {"w": "every", "b": [0.1429, 0.5107, 0.1881, 0.5321]}, {"w": "layer", "b": [0.1928, 0.5107, 0.233, 0.5321]}, {"w": "that", "b": [0.2378, 0.5107, 0.2703, 0.5321]}, {"w": "needs", "b": [0.2751, 0.5107, 0.3228, 0.5321]}, {"w": "it.12", "b": [0.3276, 0.5107, 0.3557, 0.5321]}]}, {"id": "b_10", "type": "paragraph", "text": "As you can see, there are quite a lot of things you need to get right, it is easy to make a mistake. But on the bright side, you get full control, so it’s your call.", "words": [{"w": "As", "b": [0.1429, 0.5388, 0.1649, 0.5603]}, {"w": "you", "b": [0.1697, 0.5388, 0.2009, 0.5603]}, {"w": "can", "b": [0.2057, 0.5388, 0.2351, 0.5603]}, {"w": "see,", "b": [0.2398, 0.5388, 0.2699, 0.5603]}, {"w": "there", "b": [0.2747, 0.5388, 0.3176, 0.5603]}, {"w": "are", "b": [0.3224, 0.5388, 0.3481, 0.5603]}, {"w": "quite", "b": [0.3529, 0.5388, 0.3954, 0.5603]}, {"w": "a", "b": [0.4002, 0.5388, 0.4093, 0.5603]}, {"w": "lot", "b": [0.4141, 0.5388, 0.4364, 0.5603]}, {"w": "of", "b": [0.4411, 0.5388, 0.4579, 0.5603]}, {"w": "things", "b": [0.4627, 0.5388, 0.5146, 0.5603]}, {"w": "you", "b": [0.5193, 0.5388, 0.5506, 0.5603]}, {"w": "need", "b": [0.5553, 0.5388, 0.5955, 0.5603]}, {"w": "to", "b": [0.6002, 0.5388, 0.6172, 0.5603]}, {"w": "get", "b": [0.622, 0.5388, 0.6469, 0.5603]}, {"w": "right,", "b": [0.6517, 0.5388, 0.6966, 0.5603]}, {"w": "it", "b": [0.7014, 0.5388, 0.7133, 0.5603]}, {"w": "is", "b": [0.7181, 0.5388, 0.7313, 0.5603]}, {"w": "easy", "b": [0.7361, 0.5388, 0.7713, 0.5603]}, {"w": "to", "b": [0.7761, 0.5388, 0.7931, 0.5603]}, {"w": "make", "b": [0.7978, 0.5388, 0.8432, 0.5603]}, {"w": "a", "b": [0.848, 0.5388, 0.8572, 0.5603]}, {"w": "mistake.", "b": [0.1429, 0.5579, 0.2126, 0.5793]}, {"w": "But", "b": [0.2173, 0.5579, 0.247, 0.5793]}, {"w": "on", "b": [0.2517, 0.5579, 0.2737, 0.5793]}, {"w": "the", "b": [0.2785, 0.5579, 0.3048, 0.5793]}, {"w": "bright", "b": [0.3095, 0.5579, 0.3603, 0.5793]}, {"w": "side,", "b": [0.365, 0.5579, 0.4028, 0.5793]}, {"w": "you", "b": [0.4075, 0.5579, 0.4388, 0.5793]}, {"w": "get", "b": [0.4435, 0.5579, 0.4685, 0.5793]}, {"w": "full", "b": [0.4732, 0.5579, 0.501, 0.5793]}, {"w": "control,", "b": [0.5057, 0.5579, 0.5709, 0.5793]}, {"w": "so", "b": [0.5756, 0.5579, 0.5939, 0.5793]}, {"w": "it’s", "b": [0.5986, 0.5579, 0.6203, 0.5793]}, {"w": "your", "b": [0.625, 0.5579, 0.664, 0.5793]}, {"w": "call.", "b": [0.6687, 0.5579, 0.702, 0.5793]}]}, {"id": "b_11", "type": "paragraph", "text": "Now that you know how to customize any part of your models13 and training algo‐ rithms, let’s see how you can use TensorFlow’s automatic graph generation feature: it can speed up your custom code considerably, and it will also make it portable to any platform supported by TensorFlow (see ???).", "words": [{"w": "Now", "b": [0.1429, 0.586, 0.1827, 0.6074]}, {"w": "that", "b": [0.1894, 0.586, 0.222, 0.6074]}, {"w": "you", "b": [0.2287, 0.586, 0.26, 0.6074]}, {"w": "know", "b": [0.2667, 0.586, 0.3133, 0.6074]}, {"w": "how", "b": [0.3201, 0.586, 0.3561, 0.6074]}, {"w": "to", "b": [0.3628, 0.586, 0.3798, 0.6074]}, {"w": "customize", "b": [0.3865, 0.586, 0.4713, 0.6074]}, {"w": "any", "b": [0.478, 0.586, 0.5076, 0.6074]}, {"w": "part", "b": [0.5143, 0.586, 0.5485, 0.6074]}, {"w": "of", "b": [0.5552, 0.586, 0.572, 0.6074]}, {"w": "your", "b": [0.5787, 0.586, 0.6177, 0.6074]}, {"w": "models13", "b": [0.6244, 0.586, 0.6963, 0.6074]}, {"w": "and", "b": [0.703, 0.586, 0.7346, 0.6074]}, {"w": "training", "b": [0.7413, 0.586, 0.8082, 0.6074]}, {"w": "algo‐", "b": [0.8149, 0.586, 0.8571, 0.6074]}, {"w": "rithms,", "b": [0.1429, 0.6051, 0.2031, 0.6265]}, {"w": "let’s", "b": [0.209, 0.6051, 0.2392, 0.6265]}, {"w": "see", "b": [0.2451, 0.6051, 0.2704, 0.6265]}, {"w": "how", "b": [0.2763, 0.6051, 0.3123, 0.6265]}, {"w": "you", "b": [0.3182, 0.6051, 0.3494, 0.6265]}, {"w": "can", "b": [0.3553, 0.6051, 0.3846, 0.6265]}, {"w": "use", "b": [0.3905, 0.6051, 0.418, 0.6265]}, {"w": "TensorFlow’s", "b": [0.4239, 0.6051, 0.5325, 0.6265]}, {"w": "automatic", "b": [0.5383, 0.6051, 0.6217, 0.6265]}, {"w": "graph", "b": [0.6275, 0.6051, 0.6758, 0.6265]}, {"w": "generation", "b": [0.6817, 0.6051, 0.771, 0.6265]}, {"w": "feature:", "b": [0.7768, 0.6051, 0.8393, 0.6265]}, {"w": "it", "b": [0.8452, 0.6051, 0.8571, 0.6265]}, {"w": "can", "b": [0.1428, 0.6241, 0.1722, 0.6455]}, {"w": "speed", "b": [0.178, 0.6241, 0.2252, 0.6455]}, {"w": "up", "b": [0.231, 0.6241, 0.253, 0.6455]}, {"w": "your", "b": [0.2587, 0.6241, 0.2977, 0.6455]}, {"w": "custom", "b": [0.3035, 0.6241, 0.365, 0.6455]}, {"w": "code", "b": [0.3708, 0.6241, 0.4101, 0.6455]}, {"w": "considerably,", "b": [0.4159, 0.6241, 0.5253, 0.6455]}, {"w": "and", "b": [0.5311, 0.6241, 0.5626, 0.6455]}, {"w": "it", "b": [0.5684, 0.6241, 0.5803, 0.6455]}, {"w": "will", "b": [0.5861, 0.6241, 0.6165, 0.6455]}, {"w": "also", "b": [0.6222, 0.6241, 0.6549, 0.6455]}, {"w": "make", "b": [0.6607, 0.6241, 0.7061, 0.6455]}, {"w": "it", "b": [0.7118, 0.6241, 0.7238, 0.6455]}, {"w": "portable", "b": [0.7295, 0.6241, 0.799, 0.6455]}, {"w": "to", "b": [0.8048, 0.6241, 0.8217, 0.6455]}, {"w": "any", "b": [0.8275, 0.6241, 0.8571, 0.6455]}, {"w": "platform", "b": [0.1429, 0.6432, 0.2157, 0.6646]}, {"w": "supported", "b": [0.2205, 0.6432, 0.3056, 0.6646]}, {"w": "by", "b": [0.3103, 0.6432, 0.3304, 0.6646]}, {"w": "TensorFlow", "b": [0.3352, 0.6432, 0.4334, 0.6646]}, {"w": "(see", "b": [0.4382, 0.6432, 0.4707, 0.6646]}, {"w": "???).", "b": [0.4754, 0.6432, 0.5111, 0.6646]}]}, {"id": "b_12", "type": "paragraph", "text": "TensorFlow Functions and Graphs", "words": [{"w": "TensorFlow", "b": [0.1429, 0.6776, 0.2848, 0.7118]}, {"w": "Functions", "b": [0.2907, 0.6776, 0.4104, 0.7118]}, {"w": "and", "b": [0.4163, 0.6776, 0.4635, 0.7118]}, {"w": "Graphs", "b": [0.4694, 0.6776, 0.5554, 0.7118]}]}, {"id": "b_13", "type": "paragraph", "text": "In TensorFlow 1, graphs were unavoidable (as were the complexities that came with them): they were a central part of TensorFlow’s API. In TensorFlow 2, they are still", "words": [{"w": "In", "b": [0.1429, 0.7187, 0.1614, 0.7402]}, {"w": "TensorFlow", "b": [0.1677, 0.7187, 0.266, 0.7402]}, {"w": "1,", "b": [0.2723, 0.7187, 0.2871, 0.7402]}, {"w": "graphs", "b": [0.2935, 0.7187, 0.3494, 0.7402]}, {"w": "were", "b": [0.3557, 0.7187, 0.3955, 0.7402]}, {"w": "unavoidable", "b": [0.4018, 0.7187, 0.5038, 0.7402]}, {"w": "(as", "b": [0.5101, 0.7187, 0.5341, 0.7402]}, {"w": "were", "b": [0.5405, 0.7187, 0.5802, 0.7402]}, {"w": "the", "b": [0.5866, 0.7187, 0.6129, 0.7402]}, {"w": "complexities", "b": [0.6193, 0.7187, 0.7243, 0.7402]}, {"w": "that", "b": [0.7306, 0.7187, 0.7632, 0.7402]}, {"w": "came", "b": [0.7696, 0.7187, 0.8135, 0.7402]}, {"w": "with", "b": [0.8198, 0.7187, 0.8572, 0.7402]}, {"w": "them):", "b": [0.1429, 0.7378, 0.1982, 0.7592]}, {"w": "they", "b": [0.2051, 0.7378, 0.241, 0.7592]}, {"w": "were", "b": [0.2479, 0.7378, 0.2876, 0.7592]}, {"w": "a", "b": [0.2945, 0.7378, 0.3036, 0.7592]}, {"w": "central", "b": [0.3105, 0.7378, 0.3676, 0.7592]}, {"w": "part", "b": [0.3745, 0.7378, 0.4087, 0.7592]}, {"w": "of", "b": [0.4155, 0.7378, 0.4323, 0.7592]}, {"w": "TensorFlow’s", "b": [0.4392, 0.7378, 0.5478, 0.7592]}, {"w": "API.", "b": [0.5547, 0.7378, 0.5926, 0.7592]}, {"w": "In", "b": [0.5995, 0.7378, 0.618, 0.7592]}, {"w": "TensorFlow", "b": [0.6249, 0.7378, 0.7231, 0.7592]}, {"w": "2,", "b": [0.73, 0.7378, 0.7448, 0.7592]}, {"w": "they", "b": [0.7516, 0.7378, 0.7875, 0.7592]}, {"w": "are", "b": [0.7944, 0.7378, 0.8201, 0.7592]}, {"w": "still", "b": [0.827, 0.7378, 0.8571, 0.7592]}]}, {"id": "b_14", "type": "paragraph", "text": "396 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "396", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2746, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3638, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 423, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "there, but not as central, and much (much!) simpler to use. To demonstrate this, let’s start with a trivial function that just computes the cube of its input:", "words": [{"w": "there,", "b": [0.1429, 0.0791, 0.1905, 0.1005]}, {"w": "but", "b": [0.1963, 0.0791, 0.2243, 0.1005]}, {"w": "not", "b": [0.2301, 0.0791, 0.2584, 0.1005]}, {"w": "as", "b": [0.2642, 0.0791, 0.281, 0.1005]}, {"w": "central,", "b": [0.2868, 0.0791, 0.3487, 0.1005]}, {"w": "and", "b": [0.3545, 0.0791, 0.386, 0.1005]}, {"w": "much", "b": [0.3918, 0.0791, 0.4394, 0.1005]}, {"w": "(much!)", "b": [0.4452, 0.0791, 0.513, 0.1005]}, {"w": "simpler", "b": [0.5188, 0.0791, 0.5815, 0.1005]}, {"w": "to", "b": [0.5872, 0.0791, 0.6042, 0.1005]}, {"w": "use.", "b": [0.61, 0.0791, 0.6423, 0.1005]}, {"w": "To", "b": [0.6481, 0.0791, 0.6695, 0.1005]}, {"w": "demonstrate", "b": [0.6753, 0.0791, 0.7799, 0.1005]}, {"w": "this,", "b": [0.7857, 0.0791, 0.8211, 0.1005]}, {"w": "let’s", "b": [0.8269, 0.0791, 0.8571, 0.1005]}, {"w": "start", "b": [0.1429, 0.0981, 0.1801, 0.1195]}, {"w": "with", "b": [0.1848, 0.0981, 0.2221, 0.1195]}, {"w": "a", "b": [0.2269, 0.0981, 0.236, 0.1195]}, {"w": "trivial", "b": [0.2407, 0.0981, 0.2901, 0.1195]}, {"w": "function", "b": [0.2948, 0.0981, 0.3662, 0.1195]}, {"w": "that", "b": [0.3709, 0.0981, 0.4035, 0.1195]}, {"w": "just", "b": [0.4082, 0.0981, 0.4386, 0.1195]}, {"w": "computes", "b": [0.4434, 0.0981, 0.5243, 0.1195]}, {"w": "the", "b": [0.529, 0.0981, 0.5554, 0.1195]}, {"w": "cube", "b": [0.5601, 0.0981, 0.5994, 0.1195]}, {"w": "of", "b": [0.6041, 0.0981, 0.6209, 0.1195]}, {"w": "its", "b": [0.6256, 0.0981, 0.6452, 0.1195]}, {"w": "input:", "b": [0.65, 0.0981, 0.6996, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "def cube(x): return x ** 3", "words": [{"w": "def", "b": [0.1766, 0.1301, 0.2019, 0.1429]}, {"w": "cube(x):", "b": [0.2103, 0.1301, 0.2778, 0.1429]}, {"w": "return", "b": [0.2103, 0.1455, 0.2609, 0.1584]}, {"w": "x", "b": [0.2693, 0.1455, 0.2778, 0.1584]}, {"w": "**", "b": [0.2862, 0.1455, 0.3031, 0.1584]}, {"w": "3", "b": [0.3115, 0.1455, 0.3199, 0.1584]}]}, {"id": "b_2", "type": "paragraph", "text": "We can obviously call this function with a Python value, such as an int or a float, or we can call it with a tensor:", "words": [{"w": "We", "b": [0.1429, 0.1661, 0.1699, 0.1875]}, {"w": "can", "b": [0.176, 0.1661, 0.2054, 0.1875]}, {"w": "obviously", "b": [0.2115, 0.1661, 0.2921, 0.1875]}, {"w": "call", "b": [0.2982, 0.1661, 0.3267, 0.1875]}, {"w": "this", "b": [0.3328, 0.1661, 0.3635, 0.1875]}, {"w": "function", "b": [0.3697, 0.1661, 0.4411, 0.1875]}, {"w": "with", "b": [0.4472, 0.1661, 0.4845, 0.1875]}, {"w": "a", "b": [0.4906, 0.1661, 0.4998, 0.1875]}, {"w": "Python", "b": [0.5059, 0.1661, 0.5667, 0.1875]}, {"w": "value,", "b": [0.5728, 0.1661, 0.6215, 0.1875]}, {"w": "such", "b": [0.6276, 0.1661, 0.6663, 0.1875]}, {"w": "as", "b": [0.6724, 0.1661, 0.6892, 0.1875]}, {"w": "an", "b": [0.6953, 0.1661, 0.7159, 0.1875]}, {"w": "int", "b": [0.722, 0.1661, 0.7449, 0.1875]}, {"w": "or", "b": [0.751, 0.1661, 0.7694, 0.1875]}, {"w": "a", "b": [0.7755, 0.1661, 0.7846, 0.1875]}, {"w": "float,", "b": [0.7908, 0.1661, 0.8327, 0.1875]}, {"w": "or", "b": [0.8388, 0.1661, 0.8571, 0.1875]}, {"w": "we", "b": [0.1428, 0.1852, 0.166, 0.2066]}, {"w": "can", "b": [0.1707, 0.1852, 0.2001, 0.2066]}, {"w": "call", "b": [0.2048, 0.1852, 0.2333, 0.2066]}, {"w": "it", "b": [0.238, 0.1852, 0.25, 0.2066]}, {"w": "with", "b": [0.2547, 0.1852, 0.292, 0.2066]}, {"w": "a", "b": [0.2967, 0.1852, 0.3059, 0.2066]}, {"w": "tensor:", "b": [0.3106, 0.1852, 0.3685, 0.2066]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> cube(2) 8 >>> cube(tf.constant(2.0)) ", "words": [{"w": ">>>", "b": [0.1766, 0.2172, 0.2019, 0.23]}, {"w": "cube(2)", "b": [0.2103, 0.2172, 0.2693, 0.23]}, {"w": "8", "b": [0.1766, 0.2326, 0.185, 0.2454]}, {"w": ">>>", "b": [0.1766, 0.248, 0.2019, 0.2608]}, {"w": "cube(tf.constant(2.0))", "b": [0.2103, 0.248, 0.3958, 0.2608]}, {"w": "", "b": [0.5982, 0.2634, 0.6825, 0.2763]}]}, {"id": "b_4", "type": "paragraph", "text": "Now, let’s use tf.function() to convert this Python function to a TensorFlow Func‐ tion:", "words": [{"w": "Now,", "b": [0.1428, 0.2849, 0.1859, 0.3064]}, {"w": "let’s", "b": [0.1922, 0.2849, 0.2224, 0.3064]}, {"w": "use", "b": [0.2286, 0.2849, 0.2562, 0.3064]}, {"w": "tf.function()", "b": [0.2624, 0.2881, 0.3911, 0.3032]}, {"w": "to", "b": [0.3973, 0.2849, 0.4143, 0.3064]}, {"w": "convert", "b": [0.4205, 0.2849, 0.4835, 0.3064]}, {"w": "this", "b": [0.4897, 0.2849, 0.5204, 0.3064]}, {"w": "Python", "b": [0.5267, 0.2849, 0.5875, 0.3064]}, {"w": "function", "b": [0.5937, 0.2849, 0.6651, 0.3064]}, {"w": "to", "b": [0.6713, 0.2849, 0.6883, 0.3064]}, {"w": "a", "b": [0.6946, 0.2849, 0.7037, 0.3064]}, {"w": "TensorFlow", "b": [0.7099, 0.2847, 0.8037, 0.3064]}, {"w": "Func‐", "b": [0.81, 0.2847, 0.8571, 0.3064]}, {"w": "tion:", "b": [0.1429, 0.3038, 0.1801, 0.3254]}]}, {"id": "b_5", "type": "paragraph", "text": ">>> tf_cube = tf.function(cube) >>> tf_cube ", "words": [{"w": ">>>", "b": [0.1766, 0.336, 0.2019, 0.3488]}, {"w": "tf_cube", "b": [0.2103, 0.336, 0.2693, 0.3488]}, {"w": "=", "b": [0.2778, 0.336, 0.2862, 0.3488]}, {"w": "tf.function(cube)", "b": [0.2946, 0.336, 0.438, 0.3488]}, {"w": ">>>", "b": [0.1766, 0.3514, 0.2019, 0.3642]}, {"w": "tf_cube", "b": [0.2103, 0.3514, 0.2693, 0.3642]}, {"w": "", "b": [0.5982, 0.3668, 0.6994, 0.3797]}]}, {"id": "b_6", "type": "paragraph", "text": "This TF Function can then be used exactly like the original Python function, and it will return the same result (but as tensors):", "words": [{"w": "This", "b": [0.1429, 0.3874, 0.1801, 0.4089]}, {"w": "TF", "b": [0.1867, 0.3874, 0.2106, 0.4089]}, {"w": "Function", "b": [0.2172, 0.3874, 0.293, 0.4089]}, {"w": "can", "b": [0.2996, 0.3874, 0.329, 0.4089]}, {"w": "then", "b": [0.3356, 0.3874, 0.3733, 0.4089]}, {"w": "be", "b": [0.3799, 0.3874, 0.3994, 0.4089]}, {"w": "used", "b": [0.406, 0.3874, 0.4445, 0.4089]}, {"w": "exactly", "b": [0.4511, 0.3874, 0.509, 0.4089]}, {"w": "like", "b": [0.5156, 0.3874, 0.5456, 0.4089]}, {"w": "the", "b": [0.5522, 0.3874, 0.5786, 0.4089]}, {"w": "original", "b": [0.5852, 0.3874, 0.6503, 0.4089]}, {"w": "Python", "b": [0.6569, 0.3874, 0.7177, 0.4089]}, {"w": "function,", "b": [0.7243, 0.3874, 0.8004, 0.4089]}, {"w": "and", "b": [0.8071, 0.3874, 0.8386, 0.4089]}, {"w": "it", "b": [0.8452, 0.3874, 0.8571, 0.4089]}, {"w": "will", "b": [0.1429, 0.4065, 0.1732, 0.4279]}, {"w": "return", "b": [0.178, 0.4065, 0.2311, 0.4279]}, {"w": "the", "b": [0.2358, 0.4065, 0.2622, 0.4279]}, {"w": "same", "b": [0.2669, 0.4065, 0.3096, 0.4279]}, {"w": "result", "b": [0.3143, 0.4065, 0.3612, 0.4279]}, {"w": "(but", "b": [0.366, 0.4065, 0.4012, 0.4279]}, {"w": "as", "b": [0.4059, 0.4065, 0.4227, 0.4279]}, {"w": "tensors):", "b": [0.4274, 0.4065, 0.4996, 0.4279]}]}, {"id": "b_7", "type": "paragraph", "text": ">>> tf_cube(2) >>> tf_cube(tf.constant(2.0)) ", "words": [{"w": ">>>", "b": [0.1766, 0.4385, 0.2019, 0.4513]}, {"w": "tf_cube(2)", "b": [0.2103, 0.4385, 0.2946, 0.4513]}, {"w": "", "b": [0.5814, 0.4539, 0.6488, 0.4667]}, {"w": ">>>", "b": [0.1766, 0.4693, 0.2019, 0.4822]}, {"w": "tf_cube(tf.constant(2.0))", "b": [0.2103, 0.4693, 0.4211, 0.4822]}, {"w": "", "b": [0.5982, 0.4847, 0.6825, 0.4976]}]}, {"id": "b_8", "type": "paragraph", "text": "Under the hood, tf.function() analyzed the computations performed by the cube() function and generated an equivalent computation graph! As you can see, it was rather painless (we will see how this works shortly). Alternatively, we could have used tf.function as a decorator; this is actually more common:", "words": [{"w": "Under", "b": [0.1429, 0.5063, 0.1963, 0.5277]}, {"w": "the", "b": [0.201, 0.5063, 0.2273, 0.5277]}, {"w": "hood,", "b": [0.2321, 0.5063, 0.2802, 0.5277]}, {"w": "tf.function()", "b": [0.2854, 0.5094, 0.414, 0.5245]}, {"w": "analyzed", "b": [0.4189, 0.5063, 0.492, 0.5277]}, {"w": "the", "b": [0.4969, 0.5063, 0.5232, 0.5277]}, {"w": "computations", "b": [0.5281, 0.5063, 0.6429, 0.5277]}, {"w": "performed", "b": [0.6477, 0.5063, 0.7367, 0.5277]}, {"w": "by", "b": [0.7415, 0.5063, 0.7617, 0.5277]}, {"w": "the", "b": [0.7666, 0.5063, 0.7929, 0.5277]}, {"w": "cube()", "b": [0.7978, 0.5094, 0.8571, 0.5245]}, {"w": "function", "b": [0.1429, 0.5253, 0.2143, 0.5467]}, {"w": "and", "b": [0.2231, 0.5253, 0.2546, 0.5467]}, {"w": "generated", "b": [0.2635, 0.5253, 0.345, 0.5467]}, {"w": "an", "b": [0.3538, 0.5253, 0.3744, 0.5467]}, {"w": "equivalent", "b": [0.3832, 0.5253, 0.4696, 0.5467]}, {"w": "computation", "b": [0.4784, 0.5253, 0.5856, 0.5467]}, {"w": "graph!", "b": [0.5944, 0.5253, 0.6484, 0.5467]}, {"w": "As", "b": [0.6573, 0.5253, 0.6793, 0.5467]}, {"w": "you", "b": [0.6881, 0.5253, 0.7194, 0.5467]}, {"w": "can", "b": [0.7282, 0.5253, 0.7576, 0.5467]}, {"w": "see,", "b": [0.7664, 0.5253, 0.7965, 0.5467]}, {"w": "it", "b": [0.8053, 0.5253, 0.8173, 0.5467]}, {"w": "was", "b": [0.8261, 0.5253, 0.8571, 0.5467]}, {"w": "rather", "b": [0.1429, 0.5443, 0.1934, 0.5658]}, {"w": "painless", "b": [0.1984, 0.5443, 0.2649, 0.5658]}, {"w": "(we", "b": [0.2699, 0.5443, 0.3003, 0.5658]}, {"w": "will", "b": [0.3053, 0.5443, 0.3357, 0.5658]}, {"w": "see", "b": [0.3407, 0.5443, 0.3661, 0.5658]}, {"w": "how", "b": [0.3711, 0.5443, 0.4072, 0.5658]}, {"w": "this", "b": [0.4122, 0.5443, 0.4429, 0.5658]}, {"w": "works", "b": [0.4479, 0.5443, 0.4985, 0.5658]}, {"w": "shortly).", "b": [0.5036, 0.5443, 0.5738, 0.5658]}, {"w": "Alternatively,", "b": [0.5789, 0.5443, 0.6901, 0.5658]}, {"w": "we", "b": [0.6952, 0.5443, 0.7183, 0.5658]}, {"w": "could", "b": [0.7233, 0.5443, 0.7701, 0.5658]}, {"w": "have", "b": [0.7751, 0.5443, 0.8135, 0.5658]}, {"w": "used", "b": [0.8186, 0.5443, 0.8571, 0.5658]}, {"w": "tf.function", "b": [0.1429, 0.5675, 0.2517, 0.5826]}, {"w": "as", "b": [0.2564, 0.5643, 0.2732, 0.5857]}, {"w": "a", "b": [0.278, 0.5643, 0.2871, 0.5857]}, {"w": "decorator;", "b": [0.2918, 0.5643, 0.3776, 0.5857]}, {"w": "this", "b": [0.3823, 0.5643, 0.413, 0.5857]}, {"w": "is", "b": [0.4177, 0.5643, 0.431, 0.5857]}, {"w": "actually", "b": [0.4357, 0.5643, 0.5003, 0.5857]}, {"w": "more", "b": [0.505, 0.5643, 0.5493, 0.5857]}, {"w": "common:", "b": [0.554, 0.5643, 0.6344, 0.5857]}]}, {"id": "b_9", "type": "equation", "text": "@tf.function def tf_cube(x): return x ** 3", "words": [{"w": "@tf.function", "b": [0.1766, 0.5963, 0.2778, 0.6091]}, {"w": "def", "b": [0.1766, 0.6117, 0.2019, 0.6245]}, {"w": "tf_cube(x):", "b": [0.2103, 0.6117, 0.3031, 0.6245]}, {"w": "return", "b": [0.2103, 0.6271, 0.2609, 0.64]}, {"w": "x", "b": [0.2693, 0.6271, 0.2778, 0.64]}, {"w": "**", "b": [0.2862, 0.6271, 0.3031, 0.64]}, {"w": "3", "b": [0.3115, 0.6271, 0.3199, 0.64]}]}, {"id": "b_10", "type": "paragraph", "text": "The original Python function is still available via the TF Function’s python_function attribute, in case you ever need it:", "words": [{"w": "The", "b": [0.1428, 0.6486, 0.1757, 0.67]}, {"w": "original", "b": [0.1812, 0.6486, 0.2463, 0.67]}, {"w": "Python", "b": [0.2519, 0.6486, 0.3127, 0.67]}, {"w": "function", "b": [0.3182, 0.6486, 0.3896, 0.67]}, {"w": "is", "b": [0.3952, 0.6486, 0.4084, 0.67]}, {"w": "still", "b": [0.414, 0.6486, 0.4441, 0.67]}, {"w": "available", "b": [0.4496, 0.6486, 0.5219, 0.67]}, {"w": "via", "b": [0.5275, 0.6486, 0.5518, 0.67]}, {"w": "the", "b": [0.5574, 0.6486, 0.5837, 0.67]}, {"w": "TF", "b": [0.5893, 0.6486, 0.6132, 0.67]}, {"w": "Function’s", "b": [0.6187, 0.6486, 0.7031, 0.67]}, {"w": "python_function", "b": [0.7087, 0.6518, 0.8571, 0.6669]}, {"w": "attribute,", "b": [0.1429, 0.6677, 0.2192, 0.6891]}, {"w": "in", "b": [0.224, 0.6677, 0.2409, 0.6891]}, {"w": "case", "b": [0.2457, 0.6677, 0.2801, 0.6891]}, {"w": "you", "b": [0.2849, 0.6677, 0.3161, 0.6891]}, {"w": "ever", "b": [0.3208, 0.6677, 0.3559, 0.6891]}, {"w": "need", "b": [0.3607, 0.6677, 0.4008, 0.6891]}, {"w": "it:", "b": [0.4055, 0.6677, 0.4222, 0.6891]}]}, {"id": "b_11", "type": "equation", "text": ">>> tf_cube.python_function(2) 8", "words": [{"w": ">>>", "b": [0.1766, 0.6997, 0.2019, 0.7125]}, {"w": "tf_cube.python_function(2)", "b": [0.2103, 0.6997, 0.4296, 0.7125]}, {"w": "8", "b": [0.1766, 0.7151, 0.185, 0.7279]}]}, {"id": "b_12", "type": "paragraph", "text": "TensorFlow optimizes the computation graph, pruning unused nodes, simplifying expressions (e.g., 1 + 2 would get replaced with 3), and more. Once the optimized graph is ready, the TF Function efficiently executes the operations in the graph, in the appropriate order (and in parallel when it can). As a result, a TF Function will usually run much faster than the original Python function, especially if it performs complex", "words": [{"w": "TensorFlow", "b": [0.1429, 0.7357, 0.2411, 0.7571]}, {"w": "optimizes", "b": [0.25, 0.7357, 0.3313, 0.7571]}, {"w": "the", "b": [0.3402, 0.7357, 0.3666, 0.7571]}, {"w": "computation", "b": [0.3754, 0.7357, 0.4826, 0.7571]}, {"w": "graph,", "b": [0.4914, 0.7357, 0.5445, 0.7571]}, {"w": "pruning", "b": [0.5533, 0.7357, 0.6212, 0.7571]}, {"w": "unused", "b": [0.63, 0.7357, 0.6907, 0.7571]}, {"w": "nodes,", "b": [0.6995, 0.7357, 0.7538, 0.7571]}, {"w": "simplifying", "b": [0.7627, 0.7357, 0.8571, 0.7571]}, {"w": "expressions", "b": [0.1428, 0.7548, 0.2396, 0.7762]}, {"w": "(e.g.,", "b": [0.2469, 0.7548, 0.2869, 0.7762]}, {"w": "1", "b": [0.2942, 0.7548, 0.3042, 0.7762]}, {"w": "+", "b": [0.3115, 0.7548, 0.3236, 0.7762]}, {"w": "2", "b": [0.3309, 0.7548, 0.3409, 0.7762]}, {"w": "would", "b": [0.3482, 0.7548, 0.4004, 0.7762]}, {"w": "get", "b": [0.4077, 0.7548, 0.4327, 0.7762]}, {"w": "replaced", "b": [0.44, 0.7548, 0.5105, 0.7762]}, {"w": "with", "b": [0.5178, 0.7548, 0.5552, 0.7762]}, {"w": "3),", "b": [0.5625, 0.7548, 0.5844, 0.7762]}, {"w": "and", "b": [0.5917, 0.7548, 0.6233, 0.7762]}, {"w": "more.", "b": [0.6305, 0.7548, 0.6796, 0.7762]}, {"w": "Once", "b": [0.6869, 0.7548, 0.7315, 0.7762]}, {"w": "the", "b": [0.7388, 0.7548, 0.7651, 0.7762]}, {"w": "optimized", "b": [0.7724, 0.7548, 0.8571, 0.7762]}, {"w": "graph", "b": [0.1429, 0.7738, 0.1911, 0.7952]}, {"w": "is", "b": [0.1962, 0.7738, 0.2094, 0.7952]}, {"w": "ready,", "b": [0.2144, 0.7738, 0.2639, 0.7952]}, {"w": "the", "b": [0.2689, 0.7738, 0.2953, 0.7952]}, {"w": "TF", "b": [0.3003, 0.7738, 0.3242, 0.7952]}, {"w": "Function", "b": [0.3292, 0.7738, 0.405, 0.7952]}, {"w": "efficiently", "b": [0.41, 0.7738, 0.4923, 0.7952]}, {"w": "executes", "b": [0.4973, 0.7738, 0.5675, 0.7952]}, {"w": "the", "b": [0.5726, 0.7738, 0.5989, 0.7952]}, {"w": "operations", "b": [0.6039, 0.7738, 0.6924, 0.7952]}, {"w": "in", "b": [0.6974, 0.7738, 0.7144, 0.7952]}, {"w": "the", "b": [0.7194, 0.7738, 0.7458, 0.7952]}, {"w": "graph,", "b": [0.7508, 0.7738, 0.8038, 0.7952]}, {"w": "in", "b": [0.8088, 0.7738, 0.8258, 0.7952]}, {"w": "the", "b": [0.8308, 0.7738, 0.8571, 0.7952]}, {"w": "appropriate", "b": [0.1429, 0.7929, 0.24, 0.8143]}, {"w": "order", "b": [0.2449, 0.7929, 0.2908, 0.8143]}, {"w": "(and", "b": [0.2958, 0.7929, 0.3345, 0.8143]}, {"w": "in", "b": [0.3394, 0.7929, 0.3564, 0.8143]}, {"w": "parallel", "b": [0.3613, 0.7929, 0.423, 0.8143]}, {"w": "when", "b": [0.4279, 0.7929, 0.4735, 0.8143]}, {"w": "it", "b": [0.4784, 0.7929, 0.4904, 0.8143]}, {"w": "can).", "b": [0.4953, 0.7929, 0.5366, 0.8143]}, {"w": "As", "b": [0.5415, 0.7929, 0.5636, 0.8143]}, {"w": "a", "b": [0.5685, 0.7929, 0.5777, 0.8143]}, {"w": "result,", "b": [0.5826, 0.7929, 0.6342, 0.8143]}, {"w": "a", "b": [0.6392, 0.7929, 0.6483, 0.8143]}, {"w": "TF", "b": [0.6532, 0.7929, 0.6771, 0.8143]}, {"w": "Function", "b": [0.682, 0.7929, 0.7579, 0.8143]}, {"w": "will", "b": [0.7628, 0.7929, 0.7932, 0.8143]}, {"w": "usually", "b": [0.7981, 0.7929, 0.8571, 0.8143]}, {"w": "run", "b": [0.1429, 0.8119, 0.173, 0.8333]}, {"w": "much", "b": [0.1791, 0.8119, 0.2268, 0.8333]}, {"w": "faster", "b": [0.2328, 0.8119, 0.2787, 0.8333]}, {"w": "than", "b": [0.2848, 0.8119, 0.3228, 0.8333]}, {"w": "the", "b": [0.3289, 0.8119, 0.3552, 0.8333]}, {"w": "original", "b": [0.3613, 0.8119, 0.4264, 0.8333]}, {"w": "Python", "b": [0.4325, 0.8119, 0.4933, 0.8333]}, {"w": "function,", "b": [0.4993, 0.8119, 0.5755, 0.8333]}, {"w": "especially", "b": [0.5815, 0.8119, 0.6615, 0.8333]}, {"w": "if", "b": [0.6675, 0.8119, 0.6793, 0.8333]}, {"w": "it", "b": [0.6854, 0.8119, 0.6973, 0.8333]}, {"w": "performs", "b": [0.7034, 0.8119, 0.7801, 0.8333]}, {"w": "complex", "b": [0.7862, 0.8119, 0.8571, 0.8333]}]}, {"id": "b_13", "type": "paragraph", "text": "TensorFlow Functions and Graphs | 397", "words": [{"w": "TensorFlow", "b": [0.5996, 0.9225, 0.6671, 0.9388]}, {"w": "Functions", "b": [0.6699, 0.9225, 0.7268, 0.9388]}, {"w": "and", "b": [0.7297, 0.9225, 0.7521, 0.9388]}, {"w": "Graphs", "b": [0.7549, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "397", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 424, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "14 However, in this trivial example, the computation graph is so small that there is nothing at all to optimize, so tf_cube() actually runs much slower than cube().", "words": [{"w": "14", "b": [0.1385, 0.8602, 0.1518, 0.8745]}, {"w": "However,", "b": [0.1587, 0.8587, 0.2188, 0.8751]}, {"w": "in", "b": [0.2224, 0.8587, 0.2353, 0.8751]}, {"w": "this", "b": [0.239, 0.8587, 0.2623, 0.8751]}, {"w": "trivial", "b": [0.266, 0.8587, 0.3035, 0.8751]}, {"w": "example,", "b": [0.3071, 0.8587, 0.3637, 0.8751]}, {"w": "the", "b": [0.3673, 0.8587, 0.3874, 0.8751]}, {"w": "computation", "b": [0.391, 0.8587, 0.4726, 0.8751]}, {"w": "graph", "b": [0.4762, 0.8587, 0.513, 0.8751]}, {"w": "is", "b": [0.5166, 0.8587, 0.5267, 0.8751]}, {"w": "so", "b": [0.5303, 0.8587, 0.5442, 0.8751]}, {"w": "small", "b": [0.5478, 0.8587, 0.5817, 0.8751]}, {"w": "that", "b": [0.5853, 0.8587, 0.6101, 0.8751]}, {"w": "there", "b": [0.6137, 0.8587, 0.6464, 0.8751]}, {"w": "is", "b": [0.65, 0.8587, 0.6601, 0.8751]}, {"w": "nothing", "b": [0.6637, 0.8587, 0.7141, 0.8751]}, {"w": "at", "b": [0.7177, 0.8587, 0.7292, 0.8751]}, {"w": "all", "b": [0.7328, 0.8587, 0.7478, 0.8751]}, {"w": "to", "b": [0.7514, 0.8587, 0.7644, 0.8751]}, {"w": "optimize,", "b": [0.768, 0.8587, 0.8278, 0.8751]}, {"w": "so", "b": [0.8314, 0.8587, 0.8453, 0.8751]}, {"w": "tf_cube()", "b": [0.1587, 0.8773, 0.2266, 0.8888]}, {"w": "actually", "b": [0.2302, 0.8749, 0.2794, 0.8912]}, {"w": "runs", "b": [0.283, 0.8749, 0.3119, 0.8912]}, {"w": "much", "b": [0.3155, 0.8749, 0.3518, 0.8912]}, {"w": "slower", "b": [0.3554, 0.8749, 0.3968, 0.8912]}, {"w": "than", "b": [0.4004, 0.8749, 0.4294, 0.8912]}, {"w": "cube().", "b": [0.433, 0.8749, 0.4819, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "computations.14 Most of the time you will not really need to know more than that: when you want to boost a Python function, just transform it into a TF Function. That’s all!", "words": [{"w": "computations.14", "b": [0.1429, 0.0791, 0.2738, 0.1005]}, {"w": "Most", "b": [0.281, 0.0791, 0.3237, 0.1005]}, {"w": "of", "b": [0.3308, 0.0791, 0.3476, 0.1005]}, {"w": "the", "b": [0.3548, 0.0791, 0.3811, 0.1005]}, {"w": "time", "b": [0.3883, 0.0791, 0.4262, 0.1005]}, {"w": "you", "b": [0.4334, 0.0791, 0.4646, 0.1005]}, {"w": "will", "b": [0.4718, 0.0791, 0.5022, 0.1005]}, {"w": "not", "b": [0.5094, 0.0791, 0.5377, 0.1005]}, {"w": "really", "b": [0.5449, 0.0791, 0.5907, 0.1005]}, {"w": "need", "b": [0.5979, 0.0791, 0.638, 0.1005]}, {"w": "to", "b": [0.6452, 0.0791, 0.6622, 0.1005]}, {"w": "know", "b": [0.6694, 0.0791, 0.716, 0.1005]}, {"w": "more", "b": [0.7232, 0.0791, 0.7674, 0.1005]}, {"w": "than", "b": [0.7746, 0.0791, 0.8126, 0.1005]}, {"w": "that:", "b": [0.8198, 0.0791, 0.8571, 0.1005]}, {"w": "when", "b": [0.1429, 0.0981, 0.1885, 0.1195]}, {"w": "you", "b": [0.1967, 0.0981, 0.2279, 0.1195]}, {"w": "want", "b": [0.2361, 0.0981, 0.2769, 0.1195]}, {"w": "to", "b": [0.285, 0.0981, 0.302, 0.1195]}, {"w": "boost", "b": [0.3102, 0.0981, 0.356, 0.1195]}, {"w": "a", "b": [0.3642, 0.0981, 0.3733, 0.1195]}, {"w": "Python", "b": [0.3815, 0.0981, 0.4423, 0.1195]}, {"w": "function,", "b": [0.4505, 0.0981, 0.5266, 0.1195]}, {"w": "just", "b": [0.5348, 0.0981, 0.5652, 0.1195]}, {"w": "transform", "b": [0.5733, 0.0981, 0.6572, 0.1195]}, {"w": "it", "b": [0.6654, 0.0981, 0.6773, 0.1195]}, {"w": "into", "b": [0.6855, 0.0981, 0.719, 0.1195]}, {"w": "a", "b": [0.7272, 0.0981, 0.7363, 0.1195]}, {"w": "TF", "b": [0.7445, 0.0981, 0.7684, 0.1195]}, {"w": "Function.", "b": [0.7766, 0.0981, 0.8571, 0.1195]}, {"w": "That’s", "b": [0.1429, 0.1172, 0.1917, 0.1386]}, {"w": "all!", "b": [0.1964, 0.1172, 0.2219, 0.1386]}]}, {"id": "b_2", "type": "paragraph", "text": "Moreover, when you write a custom loss function, a custom metric, a custom layer or any other custom function, and you use it in a Keras model (as we did throughout this chapter), Keras automatically converts your function into a TF Function, no need to use tf.function(). So most of the time, all this magic is 100% transparent.", "words": [{"w": "Moreover,", "b": [0.1429, 0.1453, 0.2284, 0.1667]}, {"w": "when", "b": [0.2335, 0.1453, 0.2792, 0.1667]}, {"w": "you", "b": [0.2843, 0.1453, 0.3155, 0.1667]}, {"w": "write", "b": [0.3207, 0.1453, 0.3635, 0.1667]}, {"w": "a", "b": [0.3686, 0.1453, 0.3778, 0.1667]}, {"w": "custom", "b": [0.3829, 0.1453, 0.4445, 0.1667]}, {"w": "loss", "b": [0.4496, 0.1453, 0.4808, 0.1667]}, {"w": "function,", "b": [0.4859, 0.1453, 0.5621, 0.1667]}, {"w": "a", "b": [0.5672, 0.1453, 0.5763, 0.1667]}, {"w": "custom", "b": [0.5815, 0.1453, 0.6431, 0.1667]}, {"w": "metric,", "b": [0.6482, 0.1453, 0.7073, 0.1667]}, {"w": "a", "b": [0.7125, 0.1453, 0.7216, 0.1667]}, {"w": "custom", "b": [0.7268, 0.1453, 0.7883, 0.1667]}, {"w": "layer", "b": [0.7935, 0.1453, 0.8336, 0.1667]}, {"w": "or", "b": [0.8388, 0.1453, 0.8571, 0.1667]}, {"w": "any", "b": [0.1429, 0.1643, 0.1725, 0.1857]}, {"w": "other", "b": [0.1794, 0.1643, 0.2241, 0.1857]}, {"w": "custom", "b": [0.231, 0.1643, 0.2926, 0.1857]}, {"w": "function,", "b": [0.2995, 0.1643, 0.3756, 0.1857]}, {"w": "and", "b": [0.3825, 0.1643, 0.4141, 0.1857]}, {"w": "you", "b": [0.421, 0.1643, 0.4522, 0.1857]}, {"w": "use", "b": [0.4591, 0.1643, 0.4867, 0.1857]}, {"w": "it", "b": [0.4936, 0.1643, 0.5055, 0.1857]}, {"w": "in", "b": [0.5124, 0.1643, 0.5294, 0.1857]}, {"w": "a", "b": [0.5363, 0.1643, 0.5455, 0.1857]}, {"w": "Keras", "b": [0.5524, 0.1643, 0.5993, 0.1857]}, {"w": "model", "b": [0.6062, 0.1643, 0.659, 0.1857]}, {"w": "(as", "b": [0.6659, 0.1643, 0.6899, 0.1857]}, {"w": "we", "b": [0.6968, 0.1643, 0.7199, 0.1857]}, {"w": "did", "b": [0.7268, 0.1643, 0.7544, 0.1857]}, {"w": "throughout", "b": [0.7613, 0.1643, 0.8572, 0.1857]}, {"w": "this", "b": [0.1429, 0.1834, 0.1736, 0.2048]}, {"w": "chapter),", "b": [0.1785, 0.1834, 0.253, 0.2048]}, {"w": "Keras", "b": [0.258, 0.1834, 0.3049, 0.2048]}, {"w": "automatically", "b": [0.3098, 0.1834, 0.4224, 0.2048]}, {"w": "converts", "b": [0.4273, 0.1834, 0.4979, 0.2048]}, {"w": "your", "b": [0.5029, 0.1834, 0.5418, 0.2048]}, {"w": "function", "b": [0.5468, 0.1834, 0.6182, 0.2048]}, {"w": "into", "b": [0.6231, 0.1834, 0.6567, 0.2048]}, {"w": "a", "b": [0.6616, 0.1834, 0.6708, 0.2048]}, {"w": "TF", "b": [0.6757, 0.1834, 0.6996, 0.2048]}, {"w": "Function,", "b": [0.7045, 0.1834, 0.7851, 0.2048]}, {"w": "no", "b": [0.7901, 0.1834, 0.8121, 0.2048]}, {"w": "need", "b": [0.817, 0.1834, 0.8571, 0.2048]}, {"w": "to", "b": [0.1429, 0.2033, 0.1598, 0.2247]}, {"w": "use", "b": [0.1646, 0.2033, 0.1921, 0.2247]}, {"w": "tf.function().", "b": [0.1969, 0.2033, 0.3302, 0.2247]}, {"w": "So", "b": [0.335, 0.2033, 0.3555, 0.2247]}, {"w": "most", "b": [0.3602, 0.2033, 0.4019, 0.2247]}, {"w": "of", "b": [0.4066, 0.2033, 0.4234, 0.2247]}, {"w": "the", "b": [0.4281, 0.2033, 0.4545, 0.2247]}, {"w": "time,", "b": [0.4592, 0.2033, 0.5018, 0.2247]}, {"w": "all", "b": [0.5065, 0.2033, 0.5262, 0.2247]}, {"w": "this", "b": [0.531, 0.2033, 0.5617, 0.2247]}, {"w": "magic", "b": [0.5664, 0.2033, 0.6167, 0.2247]}, {"w": "is", "b": [0.6215, 0.2033, 0.6347, 0.2247]}, {"w": "100%", "b": [0.6394, 0.2033, 0.6852, 0.2247]}, {"w": "transparent.", "b": [0.6899, 0.2033, 0.7909, 0.2247]}]}, {"id": "b_3", "type": "paragraph", "text": "You can tell Keras not to convert your Python functions to TF Functions by setting dynamic=True when creating a custom layer or a custom model. Alternatively, you can set run_eagerly=True when calling the model’s compile() method.", "words": [{"w": "You", "b": [0.2714, 0.2453, 0.301, 0.2648]}, {"w": "can", "b": [0.3094, 0.2453, 0.3363, 0.2648]}, {"w": "tell", "b": [0.3447, 0.2453, 0.3683, 0.2648]}, {"w": "Keras", "b": [0.3767, 0.2453, 0.4196, 0.2648]}, {"w": "not", "b": [0.4281, 0.2451, 0.4526, 0.2648]}, {"w": "to", "b": [0.4611, 0.2453, 0.4766, 0.2648]}, {"w": "convert", "b": [0.4851, 0.2453, 0.5426, 0.2648]}, {"w": "your", "b": [0.5511, 0.2453, 0.5867, 0.2648]}, {"w": "Python", "b": [0.5952, 0.2453, 0.6507, 0.2648]}, {"w": "functions", "b": [0.6592, 0.2453, 0.7315, 0.2648]}, {"w": "to", "b": [0.7399, 0.2453, 0.7554, 0.2648]}, {"w": "TF", "b": [0.7639, 0.2453, 0.7857, 0.2648]}, {"w": "Functions", "b": [0.2714, 0.2635, 0.3477, 0.2831]}, {"w": "by", "b": [0.3546, 0.2635, 0.3731, 0.2831]}, {"w": "setting", "b": [0.38, 0.2635, 0.4311, 0.2831]}, {"w": "dynamic=True", "b": [0.438, 0.2664, 0.5466, 0.2802]}, {"w": "when", "b": [0.5535, 0.2635, 0.5952, 0.2831]}, {"w": "creating", "b": [0.6021, 0.2635, 0.6636, 0.2831]}, {"w": "a", "b": [0.6705, 0.2635, 0.6789, 0.2831]}, {"w": "custom", "b": [0.6858, 0.2635, 0.7421, 0.2831]}, {"w": "layer", "b": [0.749, 0.2635, 0.7857, 0.2831]}, {"w": "or", "b": [0.2714, 0.2817, 0.2882, 0.3013]}, {"w": "a", "b": [0.2954, 0.2817, 0.3037, 0.3013]}, {"w": "custom", "b": [0.3109, 0.2817, 0.3672, 0.3013]}, {"w": "model.", "b": [0.3744, 0.2817, 0.427, 0.3013]}, {"w": "Alternatively,", "b": [0.4342, 0.2817, 0.5359, 0.3013]}, {"w": "you", "b": [0.5431, 0.2817, 0.5717, 0.3013]}, {"w": "can", "b": [0.5789, 0.2817, 0.6057, 0.3013]}, {"w": "set", "b": [0.6129, 0.2817, 0.6338, 0.3013]}, {"w": "run_eagerly=True", "b": [0.641, 0.2846, 0.7857, 0.2984]}, {"w": "when", "b": [0.2714, 0.3, 0.3131, 0.3195]}, {"w": "calling", "b": [0.3175, 0.3, 0.368, 0.3195]}, {"w": "the", "b": [0.3723, 0.3, 0.3964, 0.3195]}, {"w": "model’s", "b": [0.4007, 0.3, 0.4579, 0.3195]}, {"w": "compile()", "b": [0.4622, 0.3029, 0.5437, 0.3167]}, {"w": "method.", "b": [0.548, 0.3, 0.6118, 0.3195]}]}, {"id": "b_4", "type": "paragraph", "text": "TF Function generates a new graph for every unique set of input shapes and data types, and it caches it for subsequent calls. For example, if you call tf_cube(tf.con stant(10)), a graph will be generated for int32 tensors of shape []. Then if you call tf_cube(tf.constant(20)), the same graph will be reused. But if you then call tf_cube(tf.constant([10, 20])), a new graph will be generated for int32 tensors of shape [2]. This is how TF Functions handle polymorphism (i.e., varying argument types and shapes). However, this is only true for tensor arguments: if you pass numer‐ ical Python values to a TF Function, a new graph will be generated for every distinct value: for example, calling tf_cube(10) and tf_cube(20) will generate two graphs.", "words": [{"w": "TF", "b": [0.1429, 0.3439, 0.1667, 0.3653]}, {"w": "Function", "b": [0.1746, 0.3439, 0.2504, 0.3653]}, {"w": "generates", "b": [0.2583, 0.3439, 0.3364, 0.3653]}, {"w": "a", "b": [0.3443, 0.3439, 0.3534, 0.3653]}, {"w": "new", "b": [0.3613, 0.3439, 0.3958, 0.3653]}, {"w": "graph", "b": [0.4036, 0.3439, 0.4519, 0.3653]}, {"w": "for", "b": [0.4597, 0.3439, 0.4843, 0.3653]}, {"w": "every", "b": [0.4921, 0.3439, 0.5374, 0.3653]}, {"w": "unique", "b": [0.5452, 0.3439, 0.6038, 0.3653]}, {"w": "set", "b": [0.6116, 0.3439, 0.6345, 0.3653]}, {"w": "of", "b": [0.6423, 0.3439, 0.6591, 0.3653]}, {"w": "input", "b": [0.667, 0.3439, 0.7119, 0.3653]}, {"w": "shapes", "b": [0.7197, 0.3439, 0.7747, 0.3653]}, {"w": "and", "b": [0.7825, 0.3439, 0.8141, 0.3653]}, {"w": "data", "b": [0.8219, 0.3439, 0.8571, 0.3653]}, {"w": "types,", "b": [0.1429, 0.3638, 0.1909, 0.3853]}, {"w": "and", "b": [0.1973, 0.3638, 0.2288, 0.3853]}, {"w": "it", "b": [0.2352, 0.3638, 0.2471, 0.3853]}, {"w": "caches", "b": [0.2534, 0.3638, 0.3078, 0.3853]}, {"w": "it", "b": [0.3142, 0.3638, 0.3261, 0.3853]}, {"w": "for", "b": [0.3325, 0.3638, 0.357, 0.3853]}, {"w": "subsequent", "b": [0.3633, 0.3638, 0.457, 0.3853]}, {"w": "calls.", "b": [0.4634, 0.3638, 0.5043, 0.3853]}, {"w": "For", "b": [0.5106, 0.3638, 0.5396, 0.3853]}, {"w": "example,", "b": [0.5459, 0.3638, 0.6202, 0.3853]}, {"w": "if", "b": [0.6265, 0.3638, 0.6383, 0.3853]}, {"w": "you", "b": [0.6446, 0.3638, 0.6759, 0.3853]}, {"w": "call", "b": [0.6822, 0.3638, 0.7107, 0.3853]}, {"w": "tf_cube(tf.con", "b": [0.7171, 0.367, 0.8556, 0.3821]}, {"w": "stant(10)),", "b": [0.1429, 0.3838, 0.2466, 0.4052]}, {"w": "a", "b": [0.2529, 0.3838, 0.262, 0.4052]}, {"w": "graph", "b": [0.2684, 0.3838, 0.3167, 0.4052]}, {"w": "will", "b": [0.323, 0.3838, 0.3534, 0.4052]}, {"w": "be", "b": [0.3597, 0.3838, 0.3792, 0.4052]}, {"w": "generated", "b": [0.3855, 0.3838, 0.4671, 0.4052]}, {"w": "for", "b": [0.4734, 0.3838, 0.4979, 0.4052]}, {"w": "int32", "b": [0.5043, 0.3838, 0.5472, 0.4052]}, {"w": "tensors", "b": [0.5536, 0.3838, 0.6138, 0.4052]}, {"w": "of", "b": [0.6201, 0.3838, 0.6369, 0.4052]}, {"w": "shape", "b": [0.6433, 0.3838, 0.6906, 0.4052]}, {"w": "[].", "b": [0.6969, 0.3838, 0.716, 0.4052]}, {"w": "Then", "b": [0.7224, 0.3838, 0.7666, 0.4052]}, {"w": "if", "b": [0.773, 0.3838, 0.7847, 0.4052]}, {"w": "you", "b": [0.791, 0.3838, 0.8223, 0.4052]}, {"w": "call", "b": [0.8286, 0.3838, 0.8571, 0.4052]}, {"w": "tf_cube(tf.constant(20)),", "b": [0.1429, 0.4037, 0.3851, 0.4251]}, {"w": "the", "b": [0.3948, 0.4037, 0.4211, 0.4251]}, {"w": "same", "b": [0.4307, 0.4037, 0.4734, 0.4251]}, {"w": "graph", "b": [0.4831, 0.4037, 0.5314, 0.4251]}, {"w": "will", "b": [0.541, 0.4037, 0.5714, 0.4251]}, {"w": "be", "b": [0.581, 0.4037, 0.6005, 0.4251]}, {"w": "reused.", "b": [0.6101, 0.4037, 0.67, 0.4251]}, {"w": "But", "b": [0.6797, 0.4037, 0.7093, 0.4251]}, {"w": "if", "b": [0.719, 0.4037, 0.7307, 0.4251]}, {"w": "you", "b": [0.7404, 0.4037, 0.7716, 0.4251]}, {"w": "then", "b": [0.7813, 0.4037, 0.819, 0.4251]}, {"w": "call", "b": [0.8286, 0.4037, 0.8571, 0.4251]}, {"w": "tf_cube(tf.constant([10,", "b": [0.1429, 0.4269, 0.3804, 0.4419]}, {"w": "20])),", "b": [0.3921, 0.4237, 0.4463, 0.4451]}, {"w": "a", "b": [0.453, 0.4237, 0.4621, 0.4451]}, {"w": "new", "b": [0.4687, 0.4237, 0.5033, 0.4451]}, {"w": "graph", "b": [0.5099, 0.4237, 0.5582, 0.4451]}, {"w": "will", "b": [0.5648, 0.4237, 0.5952, 0.4451]}, {"w": "be", "b": [0.6019, 0.4237, 0.6213, 0.4451]}, {"w": "generated", "b": [0.628, 0.4237, 0.7095, 0.4451]}, {"w": "for", "b": [0.7161, 0.4237, 0.7407, 0.4451]}, {"w": "int32", "b": [0.7473, 0.4237, 0.7902, 0.4451]}, {"w": "tensors", "b": [0.7969, 0.4237, 0.8571, 0.4451]}, {"w": "of", "b": [0.1429, 0.4427, 0.1596, 0.4641]}, {"w": "shape", "b": [0.1652, 0.4427, 0.2124, 0.4641]}, {"w": "[2].", "b": [0.218, 0.4427, 0.2471, 0.4641]}, {"w": "This", "b": [0.2526, 0.4427, 0.2898, 0.4641]}, {"w": "is", "b": [0.2953, 0.4427, 0.3085, 0.4641]}, {"w": "how", "b": [0.314, 0.4427, 0.3501, 0.4641]}, {"w": "TF", "b": [0.3556, 0.4427, 0.3794, 0.4641]}, {"w": "Functions", "b": [0.3849, 0.4427, 0.4684, 0.4641]}, {"w": "handle", "b": [0.4739, 0.4427, 0.5307, 0.4641]}, {"w": "polymorphism", "b": [0.5362, 0.4427, 0.6604, 0.4641]}, {"w": "(i.e.,", "b": [0.6659, 0.4427, 0.7018, 0.4641]}, {"w": "varying", "b": [0.7073, 0.4427, 0.7707, 0.4641]}, {"w": "argument", "b": [0.7762, 0.4427, 0.8571, 0.4641]}, {"w": "types", "b": [0.1428, 0.4618, 0.1862, 0.4832]}, {"w": "and", "b": [0.191, 0.4618, 0.2225, 0.4832]}, {"w": "shapes).", "b": [0.2273, 0.4618, 0.2942, 0.4832]}, {"w": "However,", "b": [0.299, 0.4618, 0.3778, 0.4832]}, {"w": "this", "b": [0.3826, 0.4618, 0.4133, 0.4832]}, {"w": "is", "b": [0.4181, 0.4618, 0.4313, 0.4832]}, {"w": "only", "b": [0.4361, 0.4618, 0.4729, 0.4832]}, {"w": "true", "b": [0.4777, 0.4618, 0.5117, 0.4832]}, {"w": "for", "b": [0.5165, 0.4618, 0.541, 0.4832]}, {"w": "tensor", "b": [0.5458, 0.4618, 0.5984, 0.4832]}, {"w": "arguments:", "b": [0.6032, 0.4618, 0.6965, 0.4832]}, {"w": "if", "b": [0.7013, 0.4618, 0.7131, 0.4832]}, {"w": "you", "b": [0.7178, 0.4618, 0.7491, 0.4832]}, {"w": "pass", "b": [0.7539, 0.4618, 0.7892, 0.4832]}, {"w": "numer‐", "b": [0.794, 0.4618, 0.8571, 0.4832]}, {"w": "ical", "b": [0.1429, 0.4808, 0.1717, 0.5022]}, {"w": "Python", "b": [0.1775, 0.4808, 0.2382, 0.5022]}, {"w": "values", "b": [0.244, 0.4808, 0.2956, 0.5022]}, {"w": "to", "b": [0.3014, 0.4808, 0.3184, 0.5022]}, {"w": "a", "b": [0.3242, 0.4808, 0.3333, 0.5022]}, {"w": "TF", "b": [0.3391, 0.4808, 0.363, 0.5022]}, {"w": "Function,", "b": [0.3688, 0.4808, 0.4493, 0.5022]}, {"w": "a", "b": [0.4551, 0.4808, 0.4643, 0.5022]}, {"w": "new", "b": [0.47, 0.4808, 0.5046, 0.5022]}, {"w": "graph", "b": [0.5103, 0.4808, 0.5586, 0.5022]}, {"w": "will", "b": [0.5644, 0.4808, 0.5948, 0.5022]}, {"w": "be", "b": [0.6006, 0.4808, 0.62, 0.5022]}, {"w": "generated", "b": [0.6258, 0.4808, 0.7073, 0.5022]}, {"w": "for", "b": [0.7131, 0.4808, 0.7376, 0.5022]}, {"w": "every", "b": [0.7434, 0.4808, 0.7886, 0.5022]}, {"w": "distinct", "b": [0.7944, 0.4808, 0.8571, 0.5022]}, {"w": "value:", "b": [0.1429, 0.5008, 0.1916, 0.5222]}, {"w": "for", "b": [0.1963, 0.5008, 0.2208, 0.5222]}, {"w": "example,", "b": [0.2256, 0.5008, 0.2999, 0.5222]}, {"w": "calling", "b": [0.3046, 0.5008, 0.3598, 0.5222]}, {"w": "tf_cube(10)", "b": [0.3645, 0.504, 0.4734, 0.519]}, {"w": "and", "b": [0.4781, 0.5008, 0.5097, 0.5222]}, {"w": "tf_cube(20)", "b": [0.5144, 0.504, 0.6233, 0.519]}, {"w": "will", "b": [0.628, 0.5008, 0.6584, 0.5222]}, {"w": "generate", "b": [0.6631, 0.5008, 0.7337, 0.5222]}, {"w": "two", "b": [0.7384, 0.5008, 0.7696, 0.5222]}, {"w": "graphs.", "b": [0.7744, 0.5008, 0.835, 0.5222]}]}, {"id": "b_5", "type": "paragraph", "text": "If you call a TF Function many times with different numerical Python values, then many graphs will be generated, slowing down your program and using up a lot of RAM. Python values should be reserved for arguments that will have few unique values, such as hyperparameters like the number of neurons per layer. This allows TensorFlow to better optimize each variant of your model.", "words": [{"w": "If", "b": [0.2714, 0.5427, 0.2835, 0.5623]}, {"w": "you", "b": [0.2922, 0.5427, 0.3208, 0.5623]}, {"w": "call", "b": [0.3295, 0.5427, 0.3555, 0.5623]}, {"w": "a", "b": [0.3642, 0.5427, 0.3726, 0.5623]}, {"w": "TF", "b": [0.3812, 0.5427, 0.4031, 0.5623]}, {"w": "Function", "b": [0.4117, 0.5427, 0.4811, 0.5623]}, {"w": "many", "b": [0.4897, 0.5427, 0.5324, 0.5623]}, {"w": "times", "b": [0.5411, 0.5427, 0.5827, 0.5623]}, {"w": "with", "b": [0.5914, 0.5427, 0.6255, 0.5623]}, {"w": "different", "b": [0.6342, 0.5427, 0.6998, 0.5623]}, {"w": "numerical", "b": [0.7084, 0.5427, 0.7857, 0.5623]}, {"w": "Python", "b": [0.2714, 0.5601, 0.327, 0.5797]}, {"w": "values,", "b": [0.3328, 0.5601, 0.3843, 0.5797]}, {"w": "then", "b": [0.3901, 0.5601, 0.4246, 0.5797]}, {"w": "many", "b": [0.4304, 0.5601, 0.4731, 0.5797]}, {"w": "graphs", "b": [0.4789, 0.5601, 0.53, 0.5797]}, {"w": "will", "b": [0.5358, 0.5601, 0.5636, 0.5797]}, {"w": "be", "b": [0.5694, 0.5601, 0.5872, 0.5797]}, {"w": "generated,", "b": [0.593, 0.5601, 0.6719, 0.5797]}, {"w": "slowing", "b": [0.6777, 0.5601, 0.7367, 0.5797]}, {"w": "down", "b": [0.7425, 0.5601, 0.7857, 0.5797]}, {"w": "your", "b": [0.2714, 0.5775, 0.307, 0.5971]}, {"w": "program", "b": [0.3119, 0.5775, 0.3786, 0.5971]}, {"w": "and", "b": [0.3835, 0.5775, 0.4124, 0.5971]}, {"w": "using", "b": [0.4173, 0.5775, 0.4588, 0.5971]}, {"w": "up", "b": [0.4637, 0.5775, 0.4838, 0.5971]}, {"w": "a", "b": [0.4887, 0.5775, 0.497, 0.5971]}, {"w": "lot", "b": [0.5019, 0.5775, 0.5223, 0.5971]}, {"w": "of", "b": [0.5272, 0.5775, 0.5425, 0.5971]}, {"w": "RAM.", "b": [0.5474, 0.5775, 0.5937, 0.5971]}, {"w": "Python", "b": [0.5986, 0.5775, 0.6542, 0.5971]}, {"w": "values", "b": [0.6591, 0.5775, 0.7063, 0.5971]}, {"w": "should", "b": [0.7112, 0.5775, 0.763, 0.5971]}, {"w": "be", "b": [0.7679, 0.5775, 0.7857, 0.5971]}, {"w": "reserved", "b": [0.2714, 0.595, 0.3362, 0.6145]}, {"w": "for", "b": [0.3433, 0.595, 0.3657, 0.6145]}, {"w": "arguments", "b": [0.3728, 0.595, 0.4538, 0.6145]}, {"w": "that", "b": [0.4609, 0.595, 0.4907, 0.6145]}, {"w": "will", "b": [0.4978, 0.595, 0.5256, 0.6145]}, {"w": "have", "b": [0.5326, 0.595, 0.5677, 0.6145]}, {"w": "few", "b": [0.5748, 0.595, 0.6016, 0.6145]}, {"w": "unique", "b": [0.6087, 0.595, 0.6623, 0.6145]}, {"w": "values,", "b": [0.6693, 0.595, 0.7209, 0.6145]}, {"w": "such", "b": [0.728, 0.595, 0.7633, 0.6145]}, {"w": "as", "b": [0.7704, 0.595, 0.7857, 0.6145]}, {"w": "hyperparameters", "b": [0.2714, 0.6124, 0.4005, 0.6319]}, {"w": "like", "b": [0.4058, 0.6124, 0.4333, 0.6319]}, {"w": "the", "b": [0.4386, 0.6124, 0.4627, 0.6319]}, {"w": "number", "b": [0.468, 0.6124, 0.5287, 0.6319]}, {"w": "of", "b": [0.534, 0.6124, 0.5494, 0.6319]}, {"w": "neurons", "b": [0.5547, 0.6124, 0.6175, 0.6319]}, {"w": "per", "b": [0.6229, 0.6124, 0.648, 0.6319]}, {"w": "layer.", "b": [0.6534, 0.6124, 0.6932, 0.6319]}, {"w": "This", "b": [0.6986, 0.6124, 0.7326, 0.6319]}, {"w": "allows", "b": [0.738, 0.6124, 0.7857, 0.6319]}, {"w": "TensorFlow", "b": [0.2714, 0.6298, 0.3612, 0.6494]}, {"w": "to", "b": [0.3656, 0.6298, 0.3811, 0.6494]}, {"w": "better", "b": [0.3854, 0.6298, 0.43, 0.6494]}, {"w": "optimize", "b": [0.4343, 0.6298, 0.5017, 0.6494]}, {"w": "each", "b": [0.506, 0.6298, 0.5407, 0.6494]}, {"w": "variant", "b": [0.545, 0.6298, 0.5986, 0.6494]}, {"w": "of", "b": [0.6029, 0.6298, 0.6183, 0.6494]}, {"w": "your", "b": [0.6226, 0.6298, 0.6582, 0.6494]}, {"w": "model.", "b": [0.6626, 0.6298, 0.7152, 0.6494]}]}, {"id": "b_6", "type": "paragraph", "text": "Autograph and Tracing", "words": [{"w": "Autograph", "b": [0.1428, 0.6669, 0.2531, 0.6955]}, {"w": "and", "b": [0.2581, 0.6669, 0.2974, 0.6955]}, {"w": "Tracing", "b": [0.3023, 0.6669, 0.3781, 0.6955]}]}, {"id": "b_7", "type": "paragraph", "text": "So how does TensorFlow generate graphs? Well, first it starts by analyzing the Python function’s source code to capture all the control flow statements, such as for loops and while loops, if statements, as well as break, continue and return statements. This first step is called autograph. The reason TensorFlow has to analyze the source code is that Python does not provide any other way to capture control flow state‐ ments: it offers magic methods like __add__() or __mul__() to capture operators like", "words": [{"w": "So", "b": [0.1429, 0.7014, 0.1634, 0.7228]}, {"w": "how", "b": [0.1685, 0.7014, 0.2045, 0.7228]}, {"w": "does", "b": [0.2097, 0.7014, 0.2478, 0.7228]}, {"w": "TensorFlow", "b": [0.253, 0.7014, 0.3512, 0.7228]}, {"w": "generate", "b": [0.3564, 0.7014, 0.4269, 0.7228]}, {"w": "graphs?", "b": [0.4321, 0.7014, 0.4959, 0.7228]}, {"w": "Well,", "b": [0.5011, 0.7014, 0.5434, 0.7228]}, {"w": "first", "b": [0.5486, 0.7014, 0.5821, 0.7228]}, {"w": "it", "b": [0.5872, 0.7014, 0.5992, 0.7228]}, {"w": "starts", "b": [0.6043, 0.7014, 0.6492, 0.7228]}, {"w": "by", "b": [0.6544, 0.7014, 0.6745, 0.7228]}, {"w": "analyzing", "b": [0.6797, 0.7014, 0.7597, 0.7228]}, {"w": "the", "b": [0.7649, 0.7014, 0.7912, 0.7228]}, {"w": "Python", "b": [0.7963, 0.7014, 0.8571, 0.7228]}, {"w": "function’s", "b": [0.1428, 0.7213, 0.2228, 0.7427]}, {"w": "source", "b": [0.2301, 0.7213, 0.2848, 0.7427]}, {"w": "code", "b": [0.2921, 0.7213, 0.3314, 0.7427]}, {"w": "to", "b": [0.3386, 0.7213, 0.3556, 0.7427]}, {"w": "capture", "b": [0.3628, 0.7213, 0.4253, 0.7427]}, {"w": "all", "b": [0.4326, 0.7213, 0.4522, 0.7427]}, {"w": "the", "b": [0.4595, 0.7213, 0.4858, 0.7427]}, {"w": "control", "b": [0.4931, 0.7213, 0.5535, 0.7427]}, {"w": "flow", "b": [0.5607, 0.7213, 0.5971, 0.7427]}, {"w": "statements,", "b": [0.6043, 0.7213, 0.6979, 0.7427]}, {"w": "such", "b": [0.7052, 0.7213, 0.7438, 0.7427]}, {"w": "as", "b": [0.7511, 0.7213, 0.7679, 0.7427]}, {"w": "for", "b": [0.7751, 0.7245, 0.8048, 0.7396]}, {"w": "loops", "b": [0.8121, 0.7213, 0.8571, 0.7427]}, {"w": "and", "b": [0.1429, 0.7413, 0.1744, 0.7627]}, {"w": "while", "b": [0.1815, 0.7444, 0.231, 0.7595]}, {"w": "loops,", "b": [0.238, 0.7413, 0.2879, 0.7627]}, {"w": "if", "b": [0.2949, 0.7444, 0.3147, 0.7595]}, {"w": "statements,", "b": [0.3218, 0.7413, 0.4154, 0.7627]}, {"w": "as", "b": [0.4225, 0.7413, 0.4393, 0.7627]}, {"w": "well", "b": [0.4463, 0.7413, 0.48, 0.7627]}, {"w": "as", "b": [0.4871, 0.7413, 0.5039, 0.7627]}, {"w": "break,", "b": [0.5109, 0.7413, 0.5652, 0.7627]}, {"w": "continue", "b": [0.5722, 0.7444, 0.6514, 0.7595]}, {"w": "and", "b": [0.6585, 0.7413, 0.69, 0.7627]}, {"w": "return", "b": [0.6971, 0.7444, 0.7565, 0.7595]}, {"w": "statements.", "b": [0.7635, 0.7413, 0.8572, 0.7627]}, {"w": "This", "b": [0.1429, 0.7603, 0.1801, 0.7817]}, {"w": "first", "b": [0.1867, 0.7603, 0.2201, 0.7817]}, {"w": "step", "b": [0.2267, 0.7603, 0.2605, 0.7817]}, {"w": "is", "b": [0.2671, 0.7603, 0.2803, 0.7817]}, {"w": "called", "b": [0.2869, 0.7603, 0.3352, 0.7817]}, {"w": "autograph.", "b": [0.3418, 0.7601, 0.4299, 0.7817]}, {"w": "The", "b": [0.4365, 0.7603, 0.4693, 0.7817]}, {"w": "reason", "b": [0.4759, 0.7603, 0.5313, 0.7817]}, {"w": "TensorFlow", "b": [0.5379, 0.7603, 0.6361, 0.7817]}, {"w": "has", "b": [0.6427, 0.7603, 0.6706, 0.7817]}, {"w": "to", "b": [0.6772, 0.7603, 0.6942, 0.7817]}, {"w": "analyze", "b": [0.7008, 0.7603, 0.7629, 0.7817]}, {"w": "the", "b": [0.7695, 0.7603, 0.7958, 0.7817]}, {"w": "source", "b": [0.8024, 0.7603, 0.8571, 0.7817]}, {"w": "code", "b": [0.1429, 0.7794, 0.1821, 0.8008]}, {"w": "is", "b": [0.1899, 0.7794, 0.2032, 0.8008]}, {"w": "that", "b": [0.211, 0.7794, 0.2435, 0.8008]}, {"w": "Python", "b": [0.2513, 0.7794, 0.3121, 0.8008]}, {"w": "does", "b": [0.3199, 0.7794, 0.358, 0.8008]}, {"w": "not", "b": [0.3658, 0.7794, 0.3942, 0.8008]}, {"w": "provide", "b": [0.402, 0.7794, 0.4663, 0.8008]}, {"w": "any", "b": [0.4741, 0.7794, 0.5037, 0.8008]}, {"w": "other", "b": [0.5115, 0.7794, 0.5562, 0.8008]}, {"w": "way", "b": [0.564, 0.7794, 0.5966, 0.8008]}, {"w": "to", "b": [0.6044, 0.7794, 0.6214, 0.8008]}, {"w": "capture", "b": [0.6292, 0.7794, 0.6916, 0.8008]}, {"w": "control", "b": [0.6994, 0.7794, 0.7599, 0.8008]}, {"w": "flow", "b": [0.7676, 0.7794, 0.804, 0.8008]}, {"w": "state‐", "b": [0.8118, 0.7794, 0.8571, 0.8008]}, {"w": "ments:", "b": [0.1428, 0.7993, 0.1985, 0.8207]}, {"w": "it", "b": [0.2036, 0.7993, 0.2156, 0.8207]}, {"w": "offers", "b": [0.2207, 0.7993, 0.2678, 0.8207]}, {"w": "magic", "b": [0.2729, 0.7993, 0.3233, 0.8207]}, {"w": "methods", "b": [0.3284, 0.7993, 0.4011, 0.8207]}, {"w": "like", "b": [0.4062, 0.7993, 0.4362, 0.8207]}, {"w": "__add__()", "b": [0.4413, 0.8025, 0.5304, 0.8176]}, {"w": "or", "b": [0.5355, 0.7993, 0.5538, 0.8207]}, {"w": "__mul__()", "b": [0.5589, 0.8025, 0.648, 0.8176]}, {"w": "to", "b": [0.6531, 0.7993, 0.6701, 0.8207]}, {"w": "capture", "b": [0.6752, 0.7993, 0.7377, 0.8207]}, {"w": "operators", "b": [0.7428, 0.7993, 0.822, 0.8207]}, {"w": "like", "b": [0.8271, 0.7993, 0.8571, 0.8207]}]}, {"id": "b_8", "type": "paragraph", "text": "398 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "398", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2746, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 425, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "+ and *, but there are no __while__() or __if__() magic methods. After analyzing the function’s code, autograph outputs an upgraded version of that function in which all the control flow statements are replaced by the appropriate TensorFlow opera‐ tions, such as tf.while_loop() for loops and tf.cond() for if statements. For example, in Figure 12-4, autograph analyzes the source code of the sum_squares() Python function, and it generates the tf__sum_squares() function. In this function, the for loop is replaced by the definition of the loop_body() function (containing the body of the original for loop), followed by a call to the for_stmt() function. This call will build the appropriate tf.while_loop() operation in the computation graph.", "words": [{"w": "+", "b": [0.1429, 0.0831, 0.1528, 0.0982]}, {"w": "and", "b": [0.1591, 0.08, 0.1906, 0.1014]}, {"w": "*,", "b": [0.1969, 0.08, 0.2115, 0.1014]}, {"w": "but", "b": [0.2178, 0.08, 0.2458, 0.1014]}, {"w": "there", "b": [0.2521, 0.08, 0.2951, 0.1014]}, {"w": "are", "b": [0.3014, 0.08, 0.3271, 0.1014]}, {"w": "no", "b": [0.3334, 0.08, 0.3554, 0.1014]}, {"w": "__while__()", "b": [0.3617, 0.0831, 0.4706, 0.0982]}, {"w": "or", "b": [0.4769, 0.08, 0.4952, 0.1014]}, {"w": "__if__()", "b": [0.5015, 0.0831, 0.5807, 0.0982]}, {"w": "magic", "b": [0.587, 0.08, 0.6373, 0.1014]}, {"w": "methods.", "b": [0.6436, 0.08, 0.721, 0.1014]}, {"w": "After", "b": [0.7273, 0.08, 0.7708, 0.1014]}, {"w": "analyzing", "b": [0.7771, 0.08, 0.8571, 0.1014]}, {"w": "the", "b": [0.1429, 0.099, 0.1692, 0.1204]}, {"w": "function’s", "b": [0.1746, 0.099, 0.2546, 0.1204]}, {"w": "code,", "b": [0.26, 0.099, 0.304, 0.1204]}, {"w": "autograph", "b": [0.3094, 0.099, 0.3945, 0.1204]}, {"w": "outputs", "b": [0.3998, 0.099, 0.4639, 0.1204]}, {"w": "an", "b": [0.4693, 0.099, 0.4898, 0.1204]}, {"w": "upgraded", "b": [0.4952, 0.099, 0.5747, 0.1204]}, {"w": "version", "b": [0.58, 0.099, 0.6415, 0.1204]}, {"w": "of", "b": [0.6469, 0.099, 0.6637, 0.1204]}, {"w": "that", "b": [0.6691, 0.099, 0.7017, 0.1204]}, {"w": "function", "b": [0.7071, 0.099, 0.7785, 0.1204]}, {"w": "in", "b": [0.7839, 0.099, 0.8008, 0.1204]}, {"w": "which", "b": [0.8062, 0.099, 0.8571, 0.1204]}, {"w": "all", "b": [0.1429, 0.1181, 0.1626, 0.1395]}, {"w": "the", "b": [0.1707, 0.1181, 0.197, 0.1395]}, {"w": "control", "b": [0.2052, 0.1181, 0.2656, 0.1395]}, {"w": "flow", "b": [0.2738, 0.1181, 0.3101, 0.1395]}, {"w": "statements", "b": [0.3183, 0.1181, 0.4072, 0.1395]}, {"w": "are", "b": [0.4153, 0.1181, 0.4411, 0.1395]}, {"w": "replaced", "b": [0.4492, 0.1181, 0.5198, 0.1395]}, {"w": "by", "b": [0.528, 0.1181, 0.5481, 0.1395]}, {"w": "the", "b": [0.5563, 0.1181, 0.5826, 0.1395]}, {"w": "appropriate", "b": [0.5908, 0.1181, 0.6879, 0.1395]}, {"w": "TensorFlow", "b": [0.6961, 0.1181, 0.7943, 0.1395]}, {"w": "opera‐", "b": [0.8025, 0.1181, 0.8572, 0.1395]}, {"w": "tions,", "b": [0.1429, 0.138, 0.1892, 0.1594]}, {"w": "such", "b": [0.1989, 0.138, 0.2376, 0.1594]}, {"w": "as", "b": [0.2473, 0.138, 0.2641, 0.1594]}, {"w": "tf.while_loop()", "b": [0.2738, 0.1412, 0.4223, 0.1563]}, {"w": "for", "b": [0.432, 0.138, 0.4565, 0.1594]}, {"w": "loops", "b": [0.4662, 0.138, 0.5113, 0.1594]}, {"w": "and", "b": [0.521, 0.138, 0.5526, 0.1594]}, {"w": "tf.cond()", "b": [0.5623, 0.1412, 0.6513, 0.1563]}, {"w": "for", "b": [0.6611, 0.138, 0.6856, 0.1594]}, {"w": "if", "b": [0.6953, 0.1412, 0.7151, 0.1563]}, {"w": "statements.", "b": [0.7248, 0.138, 0.8184, 0.1594]}, {"w": "For", "b": [0.8282, 0.138, 0.8571, 0.1594]}, {"w": "example,", "b": [0.1429, 0.1579, 0.2171, 0.1794]}, {"w": "in", "b": [0.2244, 0.1579, 0.2414, 0.1794]}, {"w": "Figure", "b": [0.2487, 0.1579, 0.3027, 0.1794]}, {"w": "12-4,", "b": [0.3099, 0.1579, 0.3521, 0.1794]}, {"w": "autograph", "b": [0.3593, 0.1579, 0.4444, 0.1794]}, {"w": "analyzes", "b": [0.4517, 0.1579, 0.5214, 0.1794]}, {"w": "the", "b": [0.5287, 0.1579, 0.555, 0.1794]}, {"w": "source", "b": [0.5623, 0.1579, 0.617, 0.1794]}, {"w": "code", "b": [0.6243, 0.1579, 0.6636, 0.1794]}, {"w": "of", "b": [0.6708, 0.1579, 0.6876, 0.1794]}, {"w": "the", "b": [0.6949, 0.1579, 0.7212, 0.1794]}, {"w": "sum_squares()", "b": [0.7285, 0.1611, 0.8571, 0.1762]}, {"w": "Python", "b": [0.1428, 0.1779, 0.2036, 0.1993]}, {"w": "function,", "b": [0.2096, 0.1779, 0.2857, 0.1993]}, {"w": "and", "b": [0.2917, 0.1779, 0.3233, 0.1993]}, {"w": "it", "b": [0.3292, 0.1779, 0.3412, 0.1993]}, {"w": "generates", "b": [0.3471, 0.1779, 0.4253, 0.1993]}, {"w": "the", "b": [0.4313, 0.1779, 0.4576, 0.1993]}, {"w": "tf__sum_squares()", "b": [0.4636, 0.1811, 0.6318, 0.1961]}, {"w": "function.", "b": [0.6377, 0.1779, 0.7139, 0.1993]}, {"w": "In", "b": [0.7199, 0.1779, 0.7384, 0.1993]}, {"w": "this", "b": [0.7443, 0.1779, 0.775, 0.1993]}, {"w": "function,", "b": [0.781, 0.1779, 0.8571, 0.1993]}, {"w": "the", "b": [0.1429, 0.1978, 0.1692, 0.2192]}, {"w": "for", "b": [0.1765, 0.201, 0.2062, 0.2161]}, {"w": "loop", "b": [0.2135, 0.1978, 0.2509, 0.2192]}, {"w": "is", "b": [0.2583, 0.1978, 0.2715, 0.2192]}, {"w": "replaced", "b": [0.2788, 0.1978, 0.3494, 0.2192]}, {"w": "by", "b": [0.3567, 0.1978, 0.3768, 0.2192]}, {"w": "the", "b": [0.3842, 0.1978, 0.4105, 0.2192]}, {"w": "definition", "b": [0.4178, 0.1978, 0.5004, 0.2192]}, {"w": "of", "b": [0.5077, 0.1978, 0.5245, 0.2192]}, {"w": "the", "b": [0.5318, 0.1978, 0.5581, 0.2192]}, {"w": "loop_body()", "b": [0.5654, 0.201, 0.6743, 0.2161]}, {"w": "function", "b": [0.6816, 0.1978, 0.753, 0.2192]}, {"w": "(containing", "b": [0.7603, 0.1978, 0.8571, 0.2192]}, {"w": "the", "b": [0.1429, 0.2178, 0.1692, 0.2392]}, {"w": "body", "b": [0.1741, 0.2178, 0.2159, 0.2392]}, {"w": "of", "b": [0.2207, 0.2178, 0.2375, 0.2392]}, {"w": "the", "b": [0.2424, 0.2178, 0.2688, 0.2392]}, {"w": "original", "b": [0.2737, 0.2178, 0.3387, 0.2392]}, {"w": "for", "b": [0.3436, 0.221, 0.3733, 0.236]}, {"w": "loop),", "b": [0.3782, 0.2178, 0.4276, 0.2392]}, {"w": "followed", "b": [0.4325, 0.2178, 0.5046, 0.2392]}, {"w": "by", "b": [0.5095, 0.2178, 0.5296, 0.2392]}, {"w": "a", "b": [0.5345, 0.2178, 0.5437, 0.2392]}, {"w": "call", "b": [0.5486, 0.2178, 0.5771, 0.2392]}, {"w": "to", "b": [0.582, 0.2178, 0.5989, 0.2392]}, {"w": "the", "b": [0.6038, 0.2178, 0.6302, 0.2392]}, {"w": "for_stmt()", "b": [0.635, 0.221, 0.734, 0.236]}, {"w": "function.", "b": [0.7389, 0.2178, 0.815, 0.2392]}, {"w": "This", "b": [0.8198, 0.2178, 0.857, 0.2392]}, {"w": "call", "b": [0.1429, 0.2377, 0.1714, 0.2591]}, {"w": "will", "b": [0.1761, 0.2377, 0.2065, 0.2591]}, {"w": "build", "b": [0.2112, 0.2377, 0.2547, 0.2591]}, {"w": "the", "b": [0.2594, 0.2377, 0.2858, 0.2591]}, {"w": "appropriate", "b": [0.2905, 0.2377, 0.3876, 0.2591]}, {"w": "tf.while_loop()", "b": [0.3924, 0.2409, 0.5408, 0.256]}, {"w": "operation", "b": [0.5455, 0.2377, 0.6264, 0.2591]}, {"w": "in", "b": [0.6311, 0.2377, 0.6481, 0.2591]}, {"w": "the", "b": [0.6528, 0.2377, 0.6791, 0.2591]}, {"w": "computation", "b": [0.6839, 0.2377, 0.791, 0.2591]}, {"w": "graph.", "b": [0.7957, 0.2377, 0.8488, 0.2591]}]}, {"id": "b_1", "type": "equation", "text": "Figure 12-4. How TensorFlow generates graphs using autograph and tracing", "words": [{"w": "Figure", "b": [0.1429, 0.5686, 0.1943, 0.5902]}, {"w": "12-4.", "b": [0.1991, 0.5686, 0.2407, 0.5902]}, {"w": "How", "b": [0.2455, 0.5686, 0.2838, 0.5902]}, {"w": "TensorFlow", "b": [0.2886, 0.5686, 0.3823, 0.5902]}, {"w": "generates", "b": [0.3871, 0.5686, 0.4618, 0.5902]}, {"w": "graphs", "b": [0.4666, 0.5686, 0.5202, 0.5902]}, {"w": "using", "b": [0.525, 0.5686, 0.568, 0.5902]}, {"w": "autograph", "b": [0.5728, 0.5686, 0.6561, 0.5902]}, {"w": "and", "b": [0.6608, 0.5686, 0.6922, 0.5902]}, {"w": "tracing", "b": [0.697, 0.5686, 0.7534, 0.5902]}]}, {"id": "b_2", "type": "paragraph", "text": "Next, TensorFlow calls this “upgraded” function, but instead of passing the actual argument, it passes a symbolic tensor, meaning a tensor without any actual value, only a name, a data type, and a shape. For example, if you call sum_squares(tf.con stant(10)), then the tf__sum_squares() function will actually be called with a sym‐ bolic tensor of type int32 and shape []. The function will run in graph mode, meaning that each TensorFlow operation will just add a node in the graph to represent itself and its output tensor(s) (as opposed to the regular mode, called eager execution, or eager mode). In graph mode, TF operations do not perform any actual computations. This should feel familiar if you know TensorFlow 1, as graph mode was the default mode. In Figure 12-4, you can see the tf__sum_squares() function being called with a symbolic tensor as argument (in this case, an int32 tensor of shape []), and the final graph generated during tracing. The ellipses represent operations, and the arrows represent tensors (both the generated function and the graph are simplified).", "words": [{"w": "Next,", "b": [0.1429, 0.606, 0.1876, 0.6274]}, {"w": "TensorFlow", "b": [0.1958, 0.606, 0.2941, 0.6274]}, {"w": "calls", "b": [0.3023, 0.606, 0.3385, 0.6274]}, {"w": "this", "b": [0.3467, 0.606, 0.3774, 0.6274]}, {"w": "“upgraded”", "b": [0.3856, 0.606, 0.4804, 0.6274]}, {"w": "function,", "b": [0.4887, 0.606, 0.5648, 0.6274]}, {"w": "but", "b": [0.573, 0.606, 0.601, 0.6274]}, {"w": "instead", "b": [0.6093, 0.606, 0.6692, 0.6274]}, {"w": "of", "b": [0.6775, 0.606, 0.6943, 0.6274]}, {"w": "passing", "b": [0.7025, 0.606, 0.7646, 0.6274]}, {"w": "the", "b": [0.7728, 0.606, 0.7991, 0.6274]}, {"w": "actual", "b": [0.8074, 0.606, 0.8571, 0.6274]}, {"w": "argument,", "b": [0.1429, 0.625, 0.2286, 0.6464]}, {"w": "it", "b": [0.2336, 0.625, 0.2455, 0.6464]}, {"w": "passes", "b": [0.2505, 0.625, 0.3024, 0.6464]}, {"w": "a", "b": [0.3074, 0.625, 0.3165, 0.6464]}, {"w": "symbolic", "b": [0.3216, 0.6248, 0.392, 0.6464]}, {"w": "tensor,", "b": [0.3968, 0.6248, 0.4517, 0.6464]}, {"w": "meaning", "b": [0.4567, 0.625, 0.5299, 0.6464]}, {"w": "a", "b": [0.5349, 0.625, 0.5441, 0.6464]}, {"w": "tensor", "b": [0.5491, 0.625, 0.6017, 0.6464]}, {"w": "without", "b": [0.6067, 0.625, 0.6721, 0.6464]}, {"w": "any", "b": [0.6771, 0.625, 0.7067, 0.6464]}, {"w": "actual", "b": [0.7117, 0.625, 0.7615, 0.6464]}, {"w": "value,", "b": [0.7666, 0.625, 0.8153, 0.6464]}, {"w": "only", "b": [0.8203, 0.625, 0.8571, 0.6464]}, {"w": "a", "b": [0.1429, 0.645, 0.152, 0.6664]}, {"w": "name,", "b": [0.1612, 0.645, 0.2124, 0.6664]}, {"w": "a", "b": [0.2216, 0.645, 0.2307, 0.6664]}, {"w": "data", "b": [0.2399, 0.645, 0.2751, 0.6664]}, {"w": "type,", "b": [0.2843, 0.645, 0.3247, 0.6664]}, {"w": "and", "b": [0.3339, 0.645, 0.3655, 0.6664]}, {"w": "a", "b": [0.3746, 0.645, 0.3838, 0.6664]}, {"w": "shape.", "b": [0.3929, 0.645, 0.445, 0.6664]}, {"w": "For", "b": [0.4542, 0.645, 0.4831, 0.6664]}, {"w": "example,", "b": [0.4923, 0.645, 0.5666, 0.6664]}, {"w": "if", "b": [0.5758, 0.645, 0.5875, 0.6664]}, {"w": "you", "b": [0.5967, 0.645, 0.6279, 0.6664]}, {"w": "call", "b": [0.6371, 0.645, 0.6656, 0.6664]}, {"w": "sum_squares(tf.con", "b": [0.6748, 0.6481, 0.8529, 0.6632]}, {"w": "stant(10)),", "b": [0.1429, 0.6649, 0.2466, 0.6863]}, {"w": "then", "b": [0.2516, 0.6649, 0.2894, 0.6863]}, {"w": "the", "b": [0.2945, 0.6649, 0.3208, 0.6863]}, {"w": "tf__sum_squares()", "b": [0.3259, 0.6681, 0.4941, 0.6832]}, {"w": "function", "b": [0.4992, 0.6649, 0.5706, 0.6863]}, {"w": "will", "b": [0.5757, 0.6649, 0.6061, 0.6863]}, {"w": "actually", "b": [0.6111, 0.6649, 0.6758, 0.6863]}, {"w": "be", "b": [0.6809, 0.6649, 0.7003, 0.6863]}, {"w": "called", "b": [0.7054, 0.6649, 0.7537, 0.6863]}, {"w": "with", "b": [0.7588, 0.6649, 0.7961, 0.6863]}, {"w": "a", "b": [0.8012, 0.6649, 0.8104, 0.6863]}, {"w": "sym‐", "b": [0.8155, 0.6649, 0.8571, 0.6863]}, {"w": "bolic", "b": [0.1428, 0.684, 0.1837, 0.7054]}, {"w": "tensor", "b": [0.1888, 0.684, 0.2414, 0.7054]}, {"w": "of", "b": [0.2465, 0.684, 0.2633, 0.7054]}, {"w": "type", "b": [0.2684, 0.684, 0.3041, 0.7054]}, {"w": "int32", "b": [0.3091, 0.684, 0.3521, 0.7054]}, {"w": "and", "b": [0.3572, 0.684, 0.3887, 0.7054]}, {"w": "shape", "b": [0.3938, 0.684, 0.4411, 0.7054]}, {"w": "[].", "b": [0.4461, 0.684, 0.4653, 0.7054]}, {"w": "The", "b": [0.4704, 0.684, 0.5032, 0.7054]}, {"w": "function", "b": [0.5083, 0.684, 0.5797, 0.7054]}, {"w": "will", "b": [0.5847, 0.684, 0.6151, 0.7054]}, {"w": "run", "b": [0.6202, 0.684, 0.6504, 0.7054]}, {"w": "in", "b": [0.6555, 0.684, 0.6725, 0.7054]}, {"w": "graph", "b": [0.6776, 0.6837, 0.7242, 0.7054]}, {"w": "mode,", "b": [0.729, 0.6837, 0.7789, 0.7054]}, {"w": "meaning", "b": [0.7836, 0.684, 0.8568, 0.7054]}, {"w": "that", "b": [0.1428, 0.703, 0.1754, 0.7244]}, {"w": "each", "b": [0.1822, 0.703, 0.2202, 0.7244]}, {"w": "TensorFlow", "b": [0.227, 0.703, 0.3252, 0.7244]}, {"w": "operation", "b": [0.3321, 0.703, 0.4129, 0.7244]}, {"w": "will", "b": [0.4197, 0.703, 0.4501, 0.7244]}, {"w": "just", "b": [0.4569, 0.703, 0.4873, 0.7244]}, {"w": "add", "b": [0.4941, 0.703, 0.5253, 0.7244]}, {"w": "a", "b": [0.5321, 0.703, 0.5412, 0.7244]}, {"w": "node", "b": [0.548, 0.703, 0.5899, 0.7244]}, {"w": "in", "b": [0.5967, 0.703, 0.6137, 0.7244]}, {"w": "the", "b": [0.6205, 0.703, 0.6468, 0.7244]}, {"w": "graph", "b": [0.6536, 0.703, 0.7019, 0.7244]}, {"w": "to", "b": [0.7087, 0.703, 0.7257, 0.7244]}, {"w": "represent", "b": [0.7325, 0.703, 0.8104, 0.7244]}, {"w": "itself", "b": [0.8173, 0.703, 0.8571, 0.7244]}, {"w": "and", "b": [0.1429, 0.7221, 0.1744, 0.7435]}, {"w": "its", "b": [0.1814, 0.7221, 0.2009, 0.7435]}, {"w": "output", "b": [0.2079, 0.7221, 0.2643, 0.7435]}, {"w": "tensor(s)", "b": [0.2712, 0.7221, 0.3459, 0.7435]}, {"w": "(as", "b": [0.3528, 0.7221, 0.3768, 0.7435]}, {"w": "opposed", "b": [0.3838, 0.7221, 0.4544, 0.7435]}, {"w": "to", "b": [0.4613, 0.7221, 0.4783, 0.7435]}, {"w": "the", "b": [0.4852, 0.7221, 0.5116, 0.7435]}, {"w": "regular", "b": [0.5185, 0.7221, 0.5781, 0.7435]}, {"w": "mode,", "b": [0.585, 0.7221, 0.6373, 0.7435]}, {"w": "called", "b": [0.6443, 0.7221, 0.6926, 0.7435]}, {"w": "eager", "b": [0.6996, 0.7218, 0.7424, 0.7435]}, {"w": "execution,", "b": [0.7493, 0.7218, 0.8318, 0.7435]}, {"w": "or", "b": [0.8388, 0.7221, 0.8571, 0.7435]}, {"w": "eager", "b": [0.1429, 0.7409, 0.1856, 0.7625]}, {"w": "mode).", "b": [0.1911, 0.7409, 0.2479, 0.7625]}, {"w": "In", "b": [0.2533, 0.7411, 0.2718, 0.7625]}, {"w": "graph", "b": [0.2773, 0.7411, 0.3255, 0.7625]}, {"w": "mode,", "b": [0.331, 0.7411, 0.3833, 0.7625]}, {"w": "TF", "b": [0.3887, 0.7411, 0.4126, 0.7625]}, {"w": "operations", "b": [0.418, 0.7411, 0.5065, 0.7625]}, {"w": "do", "b": [0.5119, 0.7411, 0.5335, 0.7625]}, {"w": "not", "b": [0.539, 0.7411, 0.5674, 0.7625]}, {"w": "perform", "b": [0.5728, 0.7411, 0.6419, 0.7625]}, {"w": "any", "b": [0.6473, 0.7411, 0.6769, 0.7625]}, {"w": "actual", "b": [0.6824, 0.7411, 0.7322, 0.7625]}, {"w": "computations.", "b": [0.7376, 0.7411, 0.8571, 0.7625]}, {"w": "This", "b": [0.1429, 0.7601, 0.1801, 0.7816]}, {"w": "should", "b": [0.1869, 0.7601, 0.2436, 0.7816]}, {"w": "feel", "b": [0.2504, 0.7601, 0.2796, 0.7816]}, {"w": "familiar", "b": [0.2864, 0.7601, 0.3521, 0.7816]}, {"w": "if", "b": [0.3589, 0.7601, 0.3706, 0.7816]}, {"w": "you", "b": [0.3775, 0.7601, 0.4087, 0.7816]}, {"w": "know", "b": [0.4155, 0.7601, 0.4621, 0.7816]}, {"w": "TensorFlow", "b": [0.469, 0.7601, 0.5672, 0.7816]}, {"w": "1,", "b": [0.574, 0.7601, 0.5888, 0.7816]}, {"w": "as", "b": [0.5956, 0.7601, 0.6124, 0.7816]}, {"w": "graph", "b": [0.6192, 0.7601, 0.6675, 0.7816]}, {"w": "mode", "b": [0.6743, 0.7601, 0.7218, 0.7816]}, {"w": "was", "b": [0.7286, 0.7601, 0.7597, 0.7816]}, {"w": "the", "b": [0.7665, 0.7601, 0.7929, 0.7816]}, {"w": "default", "b": [0.7997, 0.7601, 0.8571, 0.7816]}, {"w": "mode.", "b": [0.1429, 0.7801, 0.1952, 0.8015]}, {"w": "In", "b": [0.2005, 0.7801, 0.219, 0.8015]}, {"w": "Figure", "b": [0.2243, 0.7801, 0.2783, 0.8015]}, {"w": "12-4,", "b": [0.283, 0.7801, 0.3257, 0.8015]}, {"w": "you", "b": [0.331, 0.7801, 0.3623, 0.8015]}, {"w": "can", "b": [0.3676, 0.7801, 0.3969, 0.8015]}, {"w": "see", "b": [0.4022, 0.7801, 0.4276, 0.8015]}, {"w": "the", "b": [0.4329, 0.7801, 0.4592, 0.8015]}, {"w": "tf__sum_squares()", "b": [0.4645, 0.7833, 0.6327, 0.7984]}, {"w": "function", "b": [0.638, 0.7801, 0.7094, 0.8015]}, {"w": "being", "b": [0.7147, 0.7801, 0.7609, 0.8015]}, {"w": "called", "b": [0.7662, 0.7801, 0.8145, 0.8015]}, {"w": "with", "b": [0.8198, 0.7801, 0.8571, 0.8015]}, {"w": "a", "b": [0.1429, 0.7991, 0.152, 0.8206]}, {"w": "symbolic", "b": [0.1572, 0.7991, 0.2324, 0.8206]}, {"w": "tensor", "b": [0.2376, 0.7991, 0.2902, 0.8206]}, {"w": "as", "b": [0.2954, 0.7991, 0.3122, 0.8206]}, {"w": "argument", "b": [0.3174, 0.7991, 0.3984, 0.8206]}, {"w": "(in", "b": [0.4036, 0.7991, 0.4278, 0.8206]}, {"w": "this", "b": [0.433, 0.7991, 0.4637, 0.8206]}, {"w": "case,", "b": [0.469, 0.7991, 0.5082, 0.8206]}, {"w": "an", "b": [0.5134, 0.7991, 0.5339, 0.8206]}, {"w": "int32", "b": [0.5392, 0.7991, 0.5821, 0.8206]}, {"w": "tensor", "b": [0.5873, 0.7991, 0.6399, 0.8206]}, {"w": "of", "b": [0.6452, 0.7991, 0.6619, 0.8206]}, {"w": "shape", "b": [0.6672, 0.7991, 0.7145, 0.8206]}, {"w": "[]),", "b": [0.7197, 0.7991, 0.746, 0.8206]}, {"w": "and", "b": [0.7512, 0.7991, 0.7828, 0.8206]}, {"w": "the", "b": [0.788, 0.7991, 0.8143, 0.8206]}, {"w": "final", "b": [0.8196, 0.7991, 0.8571, 0.8206]}, {"w": "graph", "b": [0.1429, 0.8182, 0.1911, 0.8396]}, {"w": "generated", "b": [0.1997, 0.8182, 0.2812, 0.8396]}, {"w": "during", "b": [0.2898, 0.8182, 0.3463, 0.8396]}, {"w": "tracing.", "b": [0.3548, 0.8182, 0.4183, 0.8396]}, {"w": "The", "b": [0.4269, 0.8182, 0.4597, 0.8396]}, {"w": "ellipses", "b": [0.4682, 0.8182, 0.5283, 0.8396]}, {"w": "represent", "b": [0.5368, 0.8182, 0.6148, 0.8396]}, {"w": "operations,", "b": [0.6233, 0.8182, 0.7165, 0.8396]}, {"w": "and", "b": [0.7251, 0.8182, 0.7566, 0.8396]}, {"w": "the", "b": [0.7651, 0.8182, 0.7915, 0.8396]}, {"w": "arrows", "b": [0.8, 0.8182, 0.8572, 0.8396]}, {"w": "represent", "b": [0.1429, 0.8372, 0.2208, 0.8586]}, {"w": "tensors", "b": [0.2255, 0.8372, 0.2858, 0.8586]}, {"w": "(both", "b": [0.2905, 0.8372, 0.3364, 0.8586]}, {"w": "the", "b": [0.3411, 0.8372, 0.3675, 0.8586]}, {"w": "generated", "b": [0.3722, 0.8372, 0.4537, 0.8586]}, {"w": "function", "b": [0.4585, 0.8372, 0.5299, 0.8586]}, {"w": "and", "b": [0.5346, 0.8372, 0.5661, 0.8586]}, {"w": "the", "b": [0.5709, 0.8372, 0.5972, 0.8586]}, {"w": "graph", "b": [0.6019, 0.8372, 0.6502, 0.8586]}, {"w": "are", "b": [0.6549, 0.8372, 0.6807, 0.8586]}, {"w": "simplified).", "b": [0.6854, 0.8372, 0.7806, 0.8586]}]}, {"id": "b_3", "type": "paragraph", "text": "TensorFlow Functions and Graphs | 399", "words": [{"w": "TensorFlow", "b": [0.5996, 0.9225, 0.6671, 0.9388]}, {"w": "Functions", "b": [0.6699, 0.9225, 0.7268, 0.9388]}, {"w": "and", "b": [0.7297, 0.9225, 0.7521, 0.9388]}, {"w": "Graphs", "b": [0.7549, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "399", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 426, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "To view the generated function’s source code, you can call tf.auto graph.to_code(sum_squares.python_function). The code is not meant to be pretty, but it can sometimes help for debugging.", "words": [{"w": "To", "b": [0.2714, 0.0801, 0.291, 0.0997]}, {"w": "view", "b": [0.2962, 0.0801, 0.3313, 0.0997]}, {"w": "the", "b": [0.3365, 0.0801, 0.3605, 0.0997]}, {"w": "generated", "b": [0.3657, 0.0801, 0.4403, 0.0997]}, {"w": "function’s", "b": [0.4455, 0.0801, 0.5186, 0.0997]}, {"w": "source", "b": [0.5238, 0.0801, 0.5739, 0.0997]}, {"w": "code,", "b": [0.579, 0.0801, 0.6193, 0.0997]}, {"w": "you", "b": [0.6245, 0.0801, 0.6531, 0.0997]}, {"w": "can", "b": [0.6583, 0.0801, 0.6851, 0.0997]}, {"w": "call", "b": [0.6903, 0.0801, 0.7164, 0.0997]}, {"w": "tf.auto", "b": [0.7216, 0.083, 0.7849, 0.0968]}, {"w": "graph.to_code(sum_squares.python_function).", "b": [0.2714, 0.0983, 0.6557, 0.1179]}, {"w": "The", "b": [0.6622, 0.0983, 0.6923, 0.1179]}, {"w": "code", "b": [0.6988, 0.0983, 0.7347, 0.1179]}, {"w": "is", "b": [0.7412, 0.0983, 0.7533, 0.1179]}, {"w": "not", "b": [0.7598, 0.0983, 0.7857, 0.1179]}, {"w": "meant", "b": [0.2714, 0.1158, 0.3193, 0.1353]}, {"w": "to", "b": [0.3236, 0.1158, 0.3392, 0.1353]}, {"w": "be", "b": [0.3435, 0.1158, 0.3613, 0.1353]}, {"w": "pretty,", "b": [0.3656, 0.1158, 0.414, 0.1353]}, {"w": "but", "b": [0.4184, 0.1158, 0.444, 0.1353]}, {"w": "it", "b": [0.4483, 0.1158, 0.4592, 0.1353]}, {"w": "can", "b": [0.4635, 0.1158, 0.4904, 0.1353]}, {"w": "sometimes", "b": [0.4947, 0.1158, 0.5767, 0.1353]}, {"w": "help", "b": [0.581, 0.1158, 0.6141, 0.1353]}, {"w": "for", "b": [0.6184, 0.1158, 0.6408, 0.1353]}, {"w": "debugging.", "b": [0.6452, 0.1158, 0.7297, 0.1353]}]}, {"id": "b_1", "type": "paragraph", "text": "TF Function Rules", "words": [{"w": "TF", "b": [0.1429, 0.1752, 0.1662, 0.2037]}, {"w": "Function", "b": [0.1712, 0.1752, 0.2613, 0.2037]}, {"w": "Rules", "b": [0.2663, 0.1752, 0.3221, 0.2037]}]}, {"id": "b_2", "type": "paragraph", "text": "Most of the time, converting a Python function that performs TensorFlow operations into a TF Function is trivial: just decorate it with @tf.function or let Keras take care of it for you. However, there are a few rules to respect:", "words": [{"w": "Most", "b": [0.1429, 0.2096, 0.1855, 0.2311]}, {"w": "of", "b": [0.1909, 0.2096, 0.2076, 0.2311]}, {"w": "the", "b": [0.213, 0.2096, 0.2393, 0.2311]}, {"w": "time,", "b": [0.2447, 0.2096, 0.2873, 0.2311]}, {"w": "converting", "b": [0.2926, 0.2096, 0.3823, 0.2311]}, {"w": "a", "b": [0.3877, 0.2096, 0.3968, 0.2311]}, {"w": "Python", "b": [0.4022, 0.2096, 0.4629, 0.2311]}, {"w": "function", "b": [0.4683, 0.2096, 0.5397, 0.2311]}, {"w": "that", "b": [0.545, 0.2096, 0.5776, 0.2311]}, {"w": "performs", "b": [0.583, 0.2096, 0.6597, 0.2311]}, {"w": "TensorFlow", "b": [0.6651, 0.2096, 0.7633, 0.2311]}, {"w": "operations", "b": [0.7687, 0.2096, 0.8571, 0.2311]}, {"w": "into", "b": [0.1429, 0.2296, 0.1764, 0.251]}, {"w": "a", "b": [0.1818, 0.2296, 0.1909, 0.251]}, {"w": "TF", "b": [0.1963, 0.2296, 0.2201, 0.251]}, {"w": "Function", "b": [0.2255, 0.2296, 0.3013, 0.251]}, {"w": "is", "b": [0.3067, 0.2296, 0.3199, 0.251]}, {"w": "trivial:", "b": [0.3252, 0.2296, 0.3793, 0.251]}, {"w": "just", "b": [0.3846, 0.2296, 0.415, 0.251]}, {"w": "decorate", "b": [0.4204, 0.2296, 0.4914, 0.251]}, {"w": "it", "b": [0.4967, 0.2296, 0.5087, 0.251]}, {"w": "with", "b": [0.514, 0.2296, 0.5513, 0.251]}, {"w": "@tf.function", "b": [0.5567, 0.2328, 0.6754, 0.2479]}, {"w": "or", "b": [0.6808, 0.2296, 0.6991, 0.251]}, {"w": "let", "b": [0.7045, 0.2296, 0.725, 0.251]}, {"w": "Keras", "b": [0.7303, 0.2296, 0.7772, 0.251]}, {"w": "take", "b": [0.7826, 0.2296, 0.8173, 0.251]}, {"w": "care", "b": [0.8226, 0.2296, 0.8571, 0.251]}, {"w": "of", "b": [0.1428, 0.2486, 0.1596, 0.2701]}, {"w": "it", "b": [0.1644, 0.2486, 0.1763, 0.2701]}, {"w": "for", "b": [0.181, 0.2486, 0.2056, 0.2701]}, {"w": "you.", "b": [0.2103, 0.2486, 0.2463, 0.2701]}, {"w": "However,", "b": [0.251, 0.2486, 0.3299, 0.2701]}, {"w": "there", "b": [0.3346, 0.2486, 0.3775, 0.2701]}, {"w": "are", "b": [0.3822, 0.2486, 0.408, 0.2701]}, {"w": "a", "b": [0.4127, 0.2486, 0.4218, 0.2701]}, {"w": "few", "b": [0.4266, 0.2486, 0.4559, 0.2701]}, {"w": "rules", "b": [0.4606, 0.2486, 0.5012, 0.2701]}, {"w": "to", "b": [0.5059, 0.2486, 0.5229, 0.2701]}, {"w": "respect:", "b": [0.5276, 0.2486, 0.5915, 0.2701]}]}, {"id": "b_3", "type": "paragraph", "text": "• If you call any external library, including NumPy or even the standard library, this call will run only during tracing, it will not be part of the graph. Indeed, a TensorFlow graph can only include TensorFlow constructs (tensors, operations, variables, datasets, and so on). So make sure you use tf.reduce_sum() instead of np.sum(), and tf.sort() instead of the built-in sorted() function, and so on (unless you really want the code to run only during tracing).", "words": [{"w": "•", "b": [0.16, 0.2828, 0.1681, 0.3042]}, {"w": "If", "b": [0.1786, 0.2828, 0.1918, 0.3042]}, {"w": "you", "b": [0.1992, 0.2828, 0.2305, 0.3042]}, {"w": "call", "b": [0.2379, 0.2828, 0.2664, 0.3042]}, {"w": "any", "b": [0.2738, 0.2828, 0.3034, 0.3042]}, {"w": "external", "b": [0.3108, 0.2828, 0.3782, 0.3042]}, {"w": "library,", "b": [0.3856, 0.2828, 0.4451, 0.3042]}, {"w": "including", "b": [0.4525, 0.2828, 0.5323, 0.3042]}, {"w": "NumPy", "b": [0.5397, 0.2828, 0.6039, 0.3042]}, {"w": "or", "b": [0.6113, 0.2828, 0.6296, 0.3042]}, {"w": "even", "b": [0.637, 0.2828, 0.6758, 0.3042]}, {"w": "the", "b": [0.6832, 0.2828, 0.7095, 0.3042]}, {"w": "standard", "b": [0.7169, 0.2828, 0.7903, 0.3042]}, {"w": "library,", "b": [0.7977, 0.2828, 0.8571, 0.3042]}, {"w": "this", "b": [0.1786, 0.3018, 0.2093, 0.3233]}, {"w": "call", "b": [0.2161, 0.3018, 0.2446, 0.3233]}, {"w": "will", "b": [0.2515, 0.3018, 0.2818, 0.3233]}, {"w": "run", "b": [0.2887, 0.3018, 0.3189, 0.3233]}, {"w": "only", "b": [0.3257, 0.3018, 0.3626, 0.3233]}, {"w": "during", "b": [0.3694, 0.3018, 0.4259, 0.3233]}, {"w": "tracing,", "b": [0.4327, 0.3018, 0.4963, 0.3233]}, {"w": "it", "b": [0.5031, 0.3018, 0.515, 0.3233]}, {"w": "will", "b": [0.5219, 0.3018, 0.5523, 0.3233]}, {"w": "not", "b": [0.5591, 0.3018, 0.5875, 0.3233]}, {"w": "be", "b": [0.5943, 0.3018, 0.6137, 0.3233]}, {"w": "part", "b": [0.6206, 0.3018, 0.6547, 0.3233]}, {"w": "of", "b": [0.6616, 0.3018, 0.6784, 0.3233]}, {"w": "the", "b": [0.6852, 0.3018, 0.7115, 0.3233]}, {"w": "graph.", "b": [0.7184, 0.3018, 0.7714, 0.3233]}, {"w": "Indeed,", "b": [0.7782, 0.3018, 0.8412, 0.3233]}, {"w": "a", "b": [0.848, 0.3018, 0.8571, 0.3233]}, {"w": "TensorFlow", "b": [0.1786, 0.3209, 0.2768, 0.3423]}, {"w": "graph", "b": [0.2835, 0.3209, 0.3318, 0.3423]}, {"w": "can", "b": [0.3385, 0.3209, 0.3679, 0.3423]}, {"w": "only", "b": [0.3746, 0.3209, 0.4114, 0.3423]}, {"w": "include", "b": [0.4182, 0.3209, 0.4801, 0.3423]}, {"w": "TensorFlow", "b": [0.4869, 0.3209, 0.5851, 0.3423]}, {"w": "constructs", "b": [0.5918, 0.3209, 0.6783, 0.3423]}, {"w": "(tensors,", "b": [0.685, 0.3209, 0.7572, 0.3423]}, {"w": "operations,", "b": [0.7639, 0.3209, 0.8571, 0.3423]}, {"w": "variables,", "b": [0.1786, 0.3408, 0.2569, 0.3623]}, {"w": "datasets,", "b": [0.262, 0.3408, 0.3325, 0.3623]}, {"w": "and", "b": [0.3375, 0.3408, 0.3691, 0.3623]}, {"w": "so", "b": [0.3741, 0.3408, 0.3924, 0.3623]}, {"w": "on).", "b": [0.3975, 0.3408, 0.4315, 0.3623]}, {"w": "So", "b": [0.4365, 0.3408, 0.457, 0.3623]}, {"w": "make", "b": [0.4621, 0.3408, 0.5075, 0.3623]}, {"w": "sure", "b": [0.5125, 0.3408, 0.5478, 0.3623]}, {"w": "you", "b": [0.5529, 0.3408, 0.5841, 0.3623]}, {"w": "use", "b": [0.5892, 0.3408, 0.6168, 0.3623]}, {"w": "tf.reduce_sum()", "b": [0.6218, 0.344, 0.7703, 0.3591]}, {"w": "instead", "b": [0.7753, 0.3408, 0.8353, 0.3623]}, {"w": "of", "b": [0.84, 0.3408, 0.8568, 0.3623]}, {"w": "np.sum(),", "b": [0.1786, 0.3608, 0.2625, 0.3822]}, {"w": "and", "b": [0.2698, 0.3608, 0.3014, 0.3822]}, {"w": "tf.sort()", "b": [0.3087, 0.364, 0.3977, 0.379]}, {"w": "instead", "b": [0.4051, 0.3608, 0.465, 0.3822]}, {"w": "of", "b": [0.4724, 0.3608, 0.4892, 0.3822]}, {"w": "the", "b": [0.4965, 0.3608, 0.5228, 0.3822]}, {"w": "built-in", "b": [0.5301, 0.3608, 0.5934, 0.3822]}, {"w": "sorted()", "b": [0.6007, 0.364, 0.6799, 0.379]}, {"w": "function,", "b": [0.6872, 0.3608, 0.7633, 0.3822]}, {"w": "and", "b": [0.7707, 0.3608, 0.8022, 0.3822]}, {"w": "so", "b": [0.8095, 0.3608, 0.8278, 0.3822]}, {"w": "on", "b": [0.8351, 0.3608, 0.8571, 0.3822]}, {"w": "(unless", "b": [0.1786, 0.3798, 0.2376, 0.4012]}, {"w": "you", "b": [0.2424, 0.3798, 0.2736, 0.4012]}, {"w": "really", "b": [0.2784, 0.3798, 0.3242, 0.4012]}, {"w": "want", "b": [0.3289, 0.3798, 0.3697, 0.4012]}, {"w": "the", "b": [0.3744, 0.3798, 0.4008, 0.4012]}, {"w": "code", "b": [0.4055, 0.3798, 0.4448, 0.4012]}, {"w": "to", "b": [0.4495, 0.3798, 0.4665, 0.4012]}, {"w": "run", "b": [0.4712, 0.3798, 0.5014, 0.4012]}, {"w": "only", "b": [0.5061, 0.3798, 0.543, 0.4012]}, {"w": "during", "b": [0.5477, 0.3798, 0.6042, 0.4012]}, {"w": "tracing).", "b": [0.609, 0.3798, 0.6797, 0.4012]}]}, {"id": "b_4", "type": "paragraph", "text": "— For example, if you define a TF function f(x) that just returns np.ran", "words": [{"w": "—", "b": [0.1807, 0.4058, 0.1999, 0.4272]}, {"w": "For", "b": [0.2044, 0.4058, 0.2333, 0.4272]}, {"w": "example,", "b": [0.2435, 0.4058, 0.3178, 0.4272]}, {"w": "if", "b": [0.328, 0.4058, 0.3398, 0.4272]}, {"w": "you", "b": [0.35, 0.4058, 0.3812, 0.4272]}, {"w": "define", "b": [0.3914, 0.4058, 0.4433, 0.4272]}, {"w": "a", "b": [0.4535, 0.4058, 0.4626, 0.4272]}, {"w": "TF", "b": [0.4728, 0.4058, 0.4967, 0.4272]}, {"w": "function", "b": [0.5069, 0.4058, 0.5783, 0.4272]}, {"w": "f(x)", "b": [0.5885, 0.409, 0.628, 0.4241]}, {"w": "that", "b": [0.6382, 0.4058, 0.6708, 0.4272]}, {"w": "just", "b": [0.681, 0.4058, 0.7114, 0.4272]}, {"w": "returns", "b": [0.7216, 0.4058, 0.7824, 0.4272]}, {"w": "np.ran", "b": [0.7926, 0.409, 0.8519, 0.4241]}]}, {"id": "b_5", "type": "paragraph", "text": "dom.rand(), a random number will only be generated when the function is traced, so f(tf.constant(2.)) and f(tf.constant(3.)) will return the same random number, but f(tf.constant([2., 3.])) will return a different one. If you replace np.random.rand() with tf.random.uniform([]), then a new random number will be generated upon every call, since the operation will be part of the graph.", "words": [{"w": "dom.rand(),", "b": [0.2044, 0.4258, 0.3081, 0.4472]}, {"w": "a", "b": [0.3155, 0.4258, 0.3247, 0.4472]}, {"w": "random", "b": [0.3321, 0.4258, 0.3991, 0.4472]}, {"w": "number", "b": [0.4065, 0.4258, 0.4728, 0.4472]}, {"w": "will", "b": [0.4802, 0.4258, 0.5106, 0.4472]}, {"w": "only", "b": [0.5181, 0.4258, 0.5549, 0.4472]}, {"w": "be", "b": [0.5624, 0.4258, 0.5818, 0.4472]}, {"w": "generated", "b": [0.5892, 0.4258, 0.6708, 0.4472]}, {"w": "when", "b": [0.6782, 0.4258, 0.7239, 0.4472]}, {"w": "the", "b": [0.7313, 0.4258, 0.7576, 0.4472]}, {"w": "function", "b": [0.7651, 0.4258, 0.8365, 0.4472]}, {"w": "is", "b": [0.8439, 0.4258, 0.8571, 0.4472]}, {"w": "traced,", "b": [0.2044, 0.4457, 0.261, 0.4671]}, {"w": "so", "b": [0.2725, 0.4457, 0.2907, 0.4671]}, {"w": "f(tf.constant(2.))", "b": [0.3022, 0.4489, 0.4803, 0.464]}, {"w": "and", "b": [0.4918, 0.4457, 0.5233, 0.4671]}, {"w": "f(tf.constant(3.))", "b": [0.5348, 0.4489, 0.7129, 0.464]}, {"w": "will", "b": [0.7244, 0.4457, 0.7548, 0.4671]}, {"w": "return", "b": [0.7662, 0.4457, 0.8194, 0.4671]}, {"w": "the", "b": [0.8308, 0.4457, 0.8571, 0.4671]}, {"w": "same", "b": [0.2044, 0.4657, 0.2471, 0.4871]}, {"w": "random", "b": [0.2524, 0.4657, 0.3194, 0.4871]}, {"w": "number,", "b": [0.3248, 0.4657, 0.3945, 0.4871]}, {"w": "but", "b": [0.3999, 0.4657, 0.4279, 0.4871]}, {"w": "f(tf.constant([2.,", "b": [0.4332, 0.4688, 0.6113, 0.4839]}, {"w": "3.]))", "b": [0.6212, 0.4688, 0.6707, 0.4839]}, {"w": "will", "b": [0.6767, 0.4657, 0.7071, 0.4871]}, {"w": "return", "b": [0.7124, 0.4657, 0.7656, 0.4871]}, {"w": "a", "b": [0.7709, 0.4657, 0.7801, 0.4871]}, {"w": "different", "b": [0.7854, 0.4657, 0.8571, 0.4871]}, {"w": "one.", "b": [0.2044, 0.4856, 0.24, 0.507]}, {"w": "If", "b": [0.2472, 0.4856, 0.2605, 0.507]}, {"w": "you", "b": [0.2678, 0.4856, 0.299, 0.507]}, {"w": "replace", "b": [0.3062, 0.4856, 0.3658, 0.507]}, {"w": "np.random.rand()", "b": [0.3731, 0.4888, 0.5314, 0.5039]}, {"w": "with", "b": [0.5387, 0.4856, 0.576, 0.507]}, {"w": "tf.random.uniform([]),", "b": [0.5832, 0.4856, 0.7958, 0.507]}, {"w": "then", "b": [0.803, 0.4856, 0.8408, 0.507]}, {"w": "a", "b": [0.848, 0.4856, 0.8572, 0.507]}, {"w": "new", "b": [0.2044, 0.5047, 0.2389, 0.5261]}, {"w": "random", "b": [0.2463, 0.5047, 0.3133, 0.5261]}, {"w": "number", "b": [0.3207, 0.5047, 0.387, 0.5261]}, {"w": "will", "b": [0.3944, 0.5047, 0.4248, 0.5261]}, {"w": "be", "b": [0.4322, 0.5047, 0.4517, 0.5261]}, {"w": "generated", "b": [0.4591, 0.5047, 0.5406, 0.5261]}, {"w": "upon", "b": [0.5481, 0.5047, 0.5921, 0.5261]}, {"w": "every", "b": [0.5995, 0.5047, 0.6447, 0.5261]}, {"w": "call,", "b": [0.6522, 0.5047, 0.6854, 0.5261]}, {"w": "since", "b": [0.6928, 0.5047, 0.7351, 0.5261]}, {"w": "the", "b": [0.7425, 0.5047, 0.7689, 0.5261]}, {"w": "operation", "b": [0.7763, 0.5047, 0.8571, 0.5261]}, {"w": "will", "b": [0.2044, 0.5237, 0.2348, 0.5451]}, {"w": "be", "b": [0.2395, 0.5237, 0.2589, 0.5451]}, {"w": "part", "b": [0.2637, 0.5237, 0.2978, 0.5451]}, {"w": "of", "b": [0.3025, 0.5237, 0.3193, 0.5451]}, {"w": "the", "b": [0.3241, 0.5237, 0.3504, 0.5451]}, {"w": "graph.", "b": [0.3551, 0.5237, 0.4081, 0.5451]}]}, {"id": "b_6", "type": "equation", "text": "— If your non-TensorFlow code has side-effects (such as logging something or", "words": [{"w": "—", "b": [0.1807, 0.5488, 0.1999, 0.5702]}, {"w": "If", "b": [0.2044, 0.5488, 0.2176, 0.5702]}, {"w": "your", "b": [0.2246, 0.5488, 0.2635, 0.5702]}, {"w": "non-TensorFlow", "b": [0.2705, 0.5488, 0.4096, 0.5702]}, {"w": "code", "b": [0.4165, 0.5488, 0.4558, 0.5702]}, {"w": "has", "b": [0.4627, 0.5488, 0.4906, 0.5702]}, {"w": "side-effects", "b": [0.4976, 0.5488, 0.5909, 0.5702]}, {"w": "(such", "b": [0.5979, 0.5488, 0.6437, 0.5702]}, {"w": "as", "b": [0.6507, 0.5488, 0.6675, 0.5702]}, {"w": "logging", "b": [0.6744, 0.5488, 0.7365, 0.5702]}, {"w": "something", "b": [0.7434, 0.5488, 0.8318, 0.5702]}, {"w": "or", "b": [0.8388, 0.5488, 0.8571, 0.5702]}]}, {"id": "b_7", "type": "paragraph", "text": "updating a Python counter), then you should not expect that side-effect to occur every time you call the TF Function, as it will only occur when the func‐ tion is traced.", "words": [{"w": "updating", "b": [0.2044, 0.5678, 0.2792, 0.5893]}, {"w": "a", "b": [0.2872, 0.5678, 0.2964, 0.5893]}, {"w": "Python", "b": [0.3044, 0.5678, 0.3652, 0.5893]}, {"w": "counter),", "b": [0.3733, 0.5678, 0.4497, 0.5893]}, {"w": "then", "b": [0.4577, 0.5678, 0.4955, 0.5893]}, {"w": "you", "b": [0.5035, 0.5678, 0.5348, 0.5893]}, {"w": "should", "b": [0.5428, 0.5678, 0.5996, 0.5893]}, {"w": "not", "b": [0.6076, 0.5678, 0.636, 0.5893]}, {"w": "expect", "b": [0.6441, 0.5678, 0.6977, 0.5893]}, {"w": "that", "b": [0.7058, 0.5678, 0.7383, 0.5893]}, {"w": "side-effect", "b": [0.7464, 0.5678, 0.8321, 0.5893]}, {"w": "to", "b": [0.8402, 0.5678, 0.8571, 0.5893]}, {"w": "occur", "b": [0.2044, 0.5869, 0.2514, 0.6083]}, {"w": "every", "b": [0.2562, 0.5869, 0.3015, 0.6083]}, {"w": "time", "b": [0.3063, 0.5869, 0.3441, 0.6083]}, {"w": "you", "b": [0.349, 0.5869, 0.3802, 0.6083]}, {"w": "call", "b": [0.385, 0.5869, 0.4135, 0.6083]}, {"w": "the", "b": [0.4183, 0.5869, 0.4447, 0.6083]}, {"w": "TF", "b": [0.4495, 0.5869, 0.4734, 0.6083]}, {"w": "Function,", "b": [0.4782, 0.5869, 0.5588, 0.6083]}, {"w": "as", "b": [0.5636, 0.5869, 0.5804, 0.6083]}, {"w": "it", "b": [0.5852, 0.5869, 0.5971, 0.6083]}, {"w": "will", "b": [0.6019, 0.5869, 0.6323, 0.6083]}, {"w": "only", "b": [0.6372, 0.5869, 0.674, 0.6083]}, {"w": "occur", "b": [0.6788, 0.5869, 0.7259, 0.6083]}, {"w": "when", "b": [0.7307, 0.5869, 0.7763, 0.6083]}, {"w": "the", "b": [0.7811, 0.5869, 0.8075, 0.6083]}, {"w": "func‐", "b": [0.8123, 0.5869, 0.8571, 0.6083]}, {"w": "tion", "b": [0.2044, 0.6059, 0.2383, 0.6273]}, {"w": "is", "b": [0.243, 0.6059, 0.2563, 0.6273]}, {"w": "traced.", "b": [0.261, 0.6059, 0.3176, 0.6273]}]}, {"id": "b_8", "type": "equation", "text": "— You can wrap arbitrary Python code in a tf.py_function() operation, but", "words": [{"w": "—", "b": [0.1807, 0.6319, 0.1999, 0.6533]}, {"w": "You", "b": [0.2044, 0.6319, 0.2367, 0.6533]}, {"w": "can", "b": [0.2444, 0.6319, 0.2738, 0.6533]}, {"w": "wrap", "b": [0.2815, 0.6319, 0.3232, 0.6533]}, {"w": "arbitrary", "b": [0.3309, 0.6319, 0.405, 0.6533]}, {"w": "Python", "b": [0.4127, 0.6319, 0.4735, 0.6533]}, {"w": "code", "b": [0.4812, 0.6319, 0.5205, 0.6533]}, {"w": "in", "b": [0.5282, 0.6319, 0.5452, 0.6533]}, {"w": "a", "b": [0.5529, 0.6319, 0.5621, 0.6533]}, {"w": "tf.py_function()", "b": [0.5698, 0.6351, 0.7281, 0.6502]}, {"w": "operation,", "b": [0.7358, 0.6319, 0.8214, 0.6533]}, {"w": "but", "b": [0.8291, 0.6319, 0.8571, 0.6533]}]}, {"id": "b_9", "type": "paragraph", "text": "this will hinder performance, as TensorFlow will not be able to do any graph optimization on this code, and it will also reduce portability, as the graph will only run on platforms where Python is available (and the right libraries installed).", "words": [{"w": "this", "b": [0.2044, 0.651, 0.2351, 0.6724]}, {"w": "will", "b": [0.2413, 0.651, 0.2716, 0.6724]}, {"w": "hinder", "b": [0.2778, 0.651, 0.3335, 0.6724]}, {"w": "performance,", "b": [0.3397, 0.651, 0.4517, 0.6724]}, {"w": "as", "b": [0.4579, 0.651, 0.4747, 0.6724]}, {"w": "TensorFlow", "b": [0.4809, 0.651, 0.5791, 0.6724]}, {"w": "will", "b": [0.5853, 0.651, 0.6157, 0.6724]}, {"w": "not", "b": [0.6219, 0.651, 0.6503, 0.6724]}, {"w": "be", "b": [0.6564, 0.651, 0.6759, 0.6724]}, {"w": "able", "b": [0.6821, 0.651, 0.7159, 0.6724]}, {"w": "to", "b": [0.7221, 0.651, 0.7391, 0.6724]}, {"w": "do", "b": [0.7453, 0.651, 0.7669, 0.6724]}, {"w": "any", "b": [0.7731, 0.651, 0.8027, 0.6724]}, {"w": "graph", "b": [0.8089, 0.651, 0.8571, 0.6724]}, {"w": "optimization", "b": [0.2044, 0.67, 0.312, 0.6914]}, {"w": "on", "b": [0.3176, 0.67, 0.3396, 0.6914]}, {"w": "this", "b": [0.3452, 0.67, 0.3759, 0.6914]}, {"w": "code,", "b": [0.3815, 0.67, 0.4255, 0.6914]}, {"w": "and", "b": [0.4311, 0.67, 0.4627, 0.6914]}, {"w": "it", "b": [0.4683, 0.67, 0.4802, 0.6914]}, {"w": "will", "b": [0.4858, 0.67, 0.5162, 0.6914]}, {"w": "also", "b": [0.5218, 0.67, 0.5545, 0.6914]}, {"w": "reduce", "b": [0.5601, 0.67, 0.6164, 0.6914]}, {"w": "portability,", "b": [0.622, 0.67, 0.713, 0.6914]}, {"w": "as", "b": [0.7186, 0.67, 0.7353, 0.6914]}, {"w": "the", "b": [0.7409, 0.67, 0.7673, 0.6914]}, {"w": "graph", "b": [0.7729, 0.67, 0.8212, 0.6914]}, {"w": "will", "b": [0.8268, 0.67, 0.8571, 0.6914]}, {"w": "only", "b": [0.2044, 0.6891, 0.2412, 0.7105]}, {"w": "run", "b": [0.2515, 0.6891, 0.2816, 0.7105]}, {"w": "on", "b": [0.2919, 0.6891, 0.3139, 0.7105]}, {"w": "platforms", "b": [0.3242, 0.6891, 0.4047, 0.7105]}, {"w": "where", "b": [0.4149, 0.6891, 0.4658, 0.7105]}, {"w": "Python", "b": [0.476, 0.6891, 0.5368, 0.7105]}, {"w": "is", "b": [0.547, 0.6891, 0.5603, 0.7105]}, {"w": "available", "b": [0.5705, 0.6891, 0.6428, 0.7105]}, {"w": "(and", "b": [0.653, 0.6891, 0.6918, 0.7105]}, {"w": "the", "b": [0.702, 0.6891, 0.7284, 0.7105]}, {"w": "right", "b": [0.7386, 0.6891, 0.7788, 0.7105]}, {"w": "libraries", "b": [0.789, 0.6891, 0.8571, 0.7105]}, {"w": "installed).", "b": [0.2044, 0.7081, 0.2868, 0.7295]}]}, {"id": "b_10", "type": "paragraph", "text": "• You can call other Python functions or TF Functions, but they should follow the same rules, as TensorFlow will also capture their operations in the computation graph. Note that these other functions do not need to be decorated with @tf.function.", "words": [{"w": "•", "b": [0.16, 0.7332, 0.1682, 0.7546]}, {"w": "You", "b": [0.1786, 0.7332, 0.2109, 0.7546]}, {"w": "can", "b": [0.2166, 0.7332, 0.246, 0.7546]}, {"w": "call", "b": [0.2517, 0.7332, 0.2802, 0.7546]}, {"w": "other", "b": [0.2859, 0.7332, 0.3306, 0.7546]}, {"w": "Python", "b": [0.3363, 0.7332, 0.3971, 0.7546]}, {"w": "functions", "b": [0.4028, 0.7332, 0.4818, 0.7546]}, {"w": "or", "b": [0.4875, 0.7332, 0.5059, 0.7546]}, {"w": "TF", "b": [0.5116, 0.7332, 0.5355, 0.7546]}, {"w": "Functions,", "b": [0.5412, 0.7332, 0.6294, 0.7546]}, {"w": "but", "b": [0.6351, 0.7332, 0.6631, 0.7546]}, {"w": "they", "b": [0.6688, 0.7332, 0.7047, 0.7546]}, {"w": "should", "b": [0.7104, 0.7332, 0.7672, 0.7546]}, {"w": "follow", "b": [0.7729, 0.7332, 0.8251, 0.7546]}, {"w": "the", "b": [0.8308, 0.7332, 0.8571, 0.7546]}, {"w": "same", "b": [0.1786, 0.7523, 0.2213, 0.7737]}, {"w": "rules,", "b": [0.2278, 0.7523, 0.2731, 0.7737]}, {"w": "as", "b": [0.2796, 0.7523, 0.2964, 0.7737]}, {"w": "TensorFlow", "b": [0.3028, 0.7523, 0.4011, 0.7737]}, {"w": "will", "b": [0.4076, 0.7523, 0.438, 0.7737]}, {"w": "also", "b": [0.4445, 0.7523, 0.4772, 0.7737]}, {"w": "capture", "b": [0.4836, 0.7523, 0.5461, 0.7737]}, {"w": "their", "b": [0.5526, 0.7523, 0.5923, 0.7737]}, {"w": "operations", "b": [0.5987, 0.7523, 0.6872, 0.7737]}, {"w": "in", "b": [0.6937, 0.7523, 0.7107, 0.7737]}, {"w": "the", "b": [0.7172, 0.7523, 0.7435, 0.7737]}, {"w": "computation", "b": [0.75, 0.7523, 0.8571, 0.7737]}, {"w": "graph.", "b": [0.1786, 0.7713, 0.2316, 0.7927]}, {"w": "Note", "b": [0.2432, 0.7713, 0.284, 0.7927]}, {"w": "that", "b": [0.2957, 0.7713, 0.3283, 0.7927]}, {"w": "these", "b": [0.3399, 0.7713, 0.3827, 0.7927]}, {"w": "other", "b": [0.3944, 0.7713, 0.4391, 0.7927]}, {"w": "functions", "b": [0.4507, 0.7713, 0.5298, 0.7927]}, {"w": "do", "b": [0.5414, 0.7713, 0.563, 0.7927]}, {"w": "not", "b": [0.5747, 0.7713, 0.6031, 0.7927]}, {"w": "need", "b": [0.6147, 0.7713, 0.6548, 0.7927]}, {"w": "to", "b": [0.6665, 0.7713, 0.6834, 0.7927]}, {"w": "be", "b": [0.6951, 0.7713, 0.7145, 0.7927]}, {"w": "decorated", "b": [0.7262, 0.7713, 0.8082, 0.7927]}, {"w": "with", "b": [0.8198, 0.7713, 0.8571, 0.7927]}, {"w": "@tf.function.", "b": [0.1786, 0.7913, 0.3021, 0.8127]}]}, {"id": "b_11", "type": "paragraph", "text": "• If the function creates a TensorFlow variable (or any other stateful TensorFlow object, such as a dataset or a queue), it must do so upon the very first call, and only then, or else you will get an exception. It is usually preferable to create vari‐ ables outside of the TF Function (e.g., in the build() method of a custom layer).", "words": [{"w": "•", "b": [0.16, 0.8163, 0.1681, 0.8378]}, {"w": "If", "b": [0.1786, 0.8163, 0.1918, 0.8378]}, {"w": "the", "b": [0.199, 0.8163, 0.2253, 0.8378]}, {"w": "function", "b": [0.2325, 0.8163, 0.3039, 0.8378]}, {"w": "creates", "b": [0.311, 0.8163, 0.368, 0.8378]}, {"w": "a", "b": [0.3752, 0.8163, 0.3843, 0.8378]}, {"w": "TensorFlow", "b": [0.3915, 0.8163, 0.4897, 0.8378]}, {"w": "variable", "b": [0.4969, 0.8163, 0.5628, 0.8378]}, {"w": "(or", "b": [0.57, 0.8163, 0.5955, 0.8378]}, {"w": "any", "b": [0.6027, 0.8163, 0.6323, 0.8378]}, {"w": "other", "b": [0.6394, 0.8163, 0.6841, 0.8378]}, {"w": "stateful", "b": [0.6913, 0.8163, 0.7517, 0.8378]}, {"w": "TensorFlow", "b": [0.7589, 0.8163, 0.8571, 0.8378]}, {"w": "object,", "b": [0.1786, 0.8354, 0.2339, 0.8568]}, {"w": "such", "b": [0.2405, 0.8354, 0.2791, 0.8568]}, {"w": "as", "b": [0.2857, 0.8354, 0.3025, 0.8568]}, {"w": "a", "b": [0.3091, 0.8354, 0.3182, 0.8568]}, {"w": "dataset", "b": [0.3248, 0.8354, 0.3829, 0.8568]}, {"w": "or", "b": [0.3895, 0.8354, 0.4079, 0.8568]}, {"w": "a", "b": [0.4145, 0.8354, 0.4236, 0.8568]}, {"w": "queue),", "b": [0.4302, 0.8354, 0.4927, 0.8568]}, {"w": "it", "b": [0.4993, 0.8354, 0.5112, 0.8568]}, {"w": "must", "b": [0.5178, 0.8354, 0.5595, 0.8568]}, {"w": "do", "b": [0.5661, 0.8354, 0.5877, 0.8568]}, {"w": "so", "b": [0.5943, 0.8354, 0.6126, 0.8568]}, {"w": "upon", "b": [0.6192, 0.8354, 0.6632, 0.8568]}, {"w": "the", "b": [0.6698, 0.8354, 0.6961, 0.8568]}, {"w": "very", "b": [0.7027, 0.8354, 0.7391, 0.8568]}, {"w": "first", "b": [0.7457, 0.8354, 0.7792, 0.8568]}, {"w": "call,", "b": [0.7858, 0.8354, 0.819, 0.8568]}, {"w": "and", "b": [0.8256, 0.8354, 0.8571, 0.8568]}, {"w": "only", "b": [0.1786, 0.8544, 0.2154, 0.8759]}, {"w": "then,", "b": [0.2209, 0.8544, 0.2634, 0.8759]}, {"w": "or", "b": [0.2689, 0.8544, 0.2872, 0.8759]}, {"w": "else", "b": [0.2927, 0.8544, 0.3233, 0.8759]}, {"w": "you", "b": [0.3288, 0.8544, 0.3601, 0.8759]}, {"w": "will", "b": [0.3656, 0.8544, 0.3959, 0.8759]}, {"w": "get", "b": [0.4014, 0.8544, 0.4264, 0.8759]}, {"w": "an", "b": [0.4319, 0.8544, 0.4524, 0.8759]}, {"w": "exception.", "b": [0.4579, 0.8544, 0.5439, 0.8759]}, {"w": "It", "b": [0.5494, 0.8544, 0.562, 0.8759]}, {"w": "is", "b": [0.5675, 0.8544, 0.5807, 0.8759]}, {"w": "usually", "b": [0.5862, 0.8544, 0.6452, 0.8759]}, {"w": "preferable", "b": [0.6507, 0.8544, 0.7348, 0.8759]}, {"w": "to", "b": [0.7403, 0.8544, 0.7573, 0.8759]}, {"w": "create", "b": [0.7628, 0.8544, 0.8121, 0.8759]}, {"w": "vari‐", "b": [0.8176, 0.8544, 0.8571, 0.8759]}, {"w": "ables", "b": [0.1786, 0.8744, 0.2201, 0.8958]}, {"w": "outside", "b": [0.2248, 0.8744, 0.2859, 0.8958]}, {"w": "of", "b": [0.2907, 0.8744, 0.3074, 0.8958]}, {"w": "the", "b": [0.3122, 0.8744, 0.3385, 0.8958]}, {"w": "TF", "b": [0.3432, 0.8744, 0.3671, 0.8958]}, {"w": "Function", "b": [0.3718, 0.8744, 0.4477, 0.8958]}, {"w": "(e.g.,", "b": [0.4524, 0.8744, 0.4925, 0.8958]}, {"w": "in", "b": [0.4972, 0.8744, 0.5142, 0.8958]}, {"w": "the", "b": [0.5189, 0.8744, 0.5452, 0.8958]}, {"w": "build()", "b": [0.55, 0.8776, 0.6192, 0.8926]}, {"w": "method", "b": [0.624, 0.8744, 0.689, 0.8958]}, {"w": "of", "b": [0.6937, 0.8744, 0.7105, 0.8958]}, {"w": "a", "b": [0.7152, 0.8744, 0.7244, 0.8958]}, {"w": "custom", "b": [0.7291, 0.8744, 0.7907, 0.8958]}, {"w": "layer).", "b": [0.7954, 0.8744, 0.8476, 0.8958]}]}, {"id": "b_12", "type": "paragraph", "text": "400 | Chapter 12: Custom Models and Training with TensorFlow", "words": [{"w": "400", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "12:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Custom", "b": [0.2746, 0.9225, 0.3187, 0.9388]}, {"w": "Models", "b": [0.3215, 0.9225, 0.3637, 0.9388]}, {"w": "and", "b": [0.3666, 0.9225, 0.389, 0.9388]}, {"w": "Training", "b": [0.3918, 0.9225, 0.4409, 0.9388]}, {"w": "with", "b": [0.4437, 0.9225, 0.4708, 0.9388]}, {"w": "TensorFlow", "b": [0.4736, 0.9225, 0.5411, 0.9388]}]}]}, {"page": 427, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• The source code of your Python function should be available to TensorFlow. If the source code is unavailable (for example, if you define your function in the Python shell, which does not give access to the source code, or if you deploy only the compiled Python files *.pyc to production), then the graph generation pro‐ cess will fail or have limited functionality.", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "The", "b": [0.1786, 0.0791, 0.2114, 0.1005]}, {"w": "source", "b": [0.2184, 0.0791, 0.2731, 0.1005]}, {"w": "code", "b": [0.2801, 0.0791, 0.3194, 0.1005]}, {"w": "of", "b": [0.3263, 0.0791, 0.3431, 0.1005]}, {"w": "your", "b": [0.3501, 0.0791, 0.3891, 0.1005]}, {"w": "Python", "b": [0.396, 0.0791, 0.4568, 0.1005]}, {"w": "function", "b": [0.4638, 0.0791, 0.5352, 0.1005]}, {"w": "should", "b": [0.5421, 0.0791, 0.5989, 0.1005]}, {"w": "be", "b": [0.6058, 0.0791, 0.6253, 0.1005]}, {"w": "available", "b": [0.6322, 0.0791, 0.7045, 0.1005]}, {"w": "to", "b": [0.7115, 0.0791, 0.7285, 0.1005]}, {"w": "TensorFlow.", "b": [0.7354, 0.0791, 0.8369, 0.1005]}, {"w": "If", "b": [0.8439, 0.0791, 0.8571, 0.1005]}, {"w": "the", "b": [0.1786, 0.0981, 0.2049, 0.1195]}, {"w": "source", "b": [0.2123, 0.0981, 0.267, 0.1195]}, {"w": "code", "b": [0.2744, 0.0981, 0.3137, 0.1195]}, {"w": "is", "b": [0.321, 0.0981, 0.3342, 0.1195]}, {"w": "unavailable", "b": [0.3416, 0.0981, 0.4363, 0.1195]}, {"w": "(for", "b": [0.4437, 0.0981, 0.4754, 0.1195]}, {"w": "example,", "b": [0.4828, 0.0981, 0.5571, 0.1195]}, {"w": "if", "b": [0.5644, 0.0981, 0.5762, 0.1195]}, {"w": "you", "b": [0.5835, 0.0981, 0.6148, 0.1195]}, {"w": "define", "b": [0.6222, 0.0981, 0.674, 0.1195]}, {"w": "your", "b": [0.6814, 0.0981, 0.7204, 0.1195]}, {"w": "function", "b": [0.7277, 0.0981, 0.7991, 0.1195]}, {"w": "in", "b": [0.8065, 0.0981, 0.8235, 0.1195]}, {"w": "the", "b": [0.8308, 0.0981, 0.8571, 0.1195]}, {"w": "Python", "b": [0.1786, 0.1172, 0.2394, 0.1386]}, {"w": "shell,", "b": [0.2444, 0.1172, 0.2873, 0.1386]}, {"w": "which", "b": [0.2924, 0.1172, 0.3433, 0.1386]}, {"w": "does", "b": [0.3484, 0.1172, 0.3865, 0.1386]}, {"w": "not", "b": [0.3916, 0.1172, 0.42, 0.1386]}, {"w": "give", "b": [0.4251, 0.1172, 0.4589, 0.1386]}, {"w": "access", "b": [0.464, 0.1172, 0.5149, 0.1386]}, {"w": "to", "b": [0.52, 0.1172, 0.537, 0.1386]}, {"w": "the", "b": [0.542, 0.1172, 0.5684, 0.1386]}, {"w": "source", "b": [0.5735, 0.1172, 0.6282, 0.1386]}, {"w": "code,", "b": [0.6333, 0.1172, 0.6773, 0.1386]}, {"w": "or", "b": [0.6824, 0.1172, 0.7007, 0.1386]}, {"w": "if", "b": [0.7058, 0.1172, 0.7176, 0.1386]}, {"w": "you", "b": [0.7226, 0.1172, 0.7539, 0.1386]}, {"w": "deploy", "b": [0.759, 0.1172, 0.8152, 0.1386]}, {"w": "only", "b": [0.8203, 0.1172, 0.8571, 0.1386]}, {"w": "the", "b": [0.1786, 0.1371, 0.2049, 0.1585]}, {"w": "compiled", "b": [0.2112, 0.1371, 0.2889, 0.1585]}, {"w": "Python", "b": [0.2952, 0.1371, 0.356, 0.1585]}, {"w": "files", "b": [0.3623, 0.1371, 0.3959, 0.1585]}, {"w": "*.pyc", "b": [0.4022, 0.1403, 0.4516, 0.1554]}, {"w": "to", "b": [0.458, 0.1371, 0.4749, 0.1585]}, {"w": "production),", "b": [0.4812, 0.1371, 0.5873, 0.1585]}, {"w": "then", "b": [0.5936, 0.1371, 0.6313, 0.1585]}, {"w": "the", "b": [0.6376, 0.1371, 0.664, 0.1585]}, {"w": "graph", "b": [0.6703, 0.1371, 0.7186, 0.1585]}, {"w": "generation", "b": [0.7249, 0.1371, 0.8141, 0.1585]}, {"w": "pro‐", "b": [0.8205, 0.1371, 0.8571, 0.1585]}, {"w": "cess", "b": [0.1786, 0.1561, 0.2115, 0.1776]}, {"w": "will", "b": [0.2163, 0.1561, 0.2467, 0.1776]}, {"w": "fail", "b": [0.2514, 0.1561, 0.2776, 0.1776]}, {"w": "or", "b": [0.2823, 0.1561, 0.3006, 0.1776]}, {"w": "have", "b": [0.3054, 0.1561, 0.3438, 0.1776]}, {"w": "limited", "b": [0.3485, 0.1561, 0.4082, 0.1776]}, {"w": "functionality.", "b": [0.4129, 0.1561, 0.5235, 0.1776]}]}, {"id": "b_1", "type": "paragraph", "text": "• TensorFlow will only capture for loops that iterate over a tensor or a Dataset. So make sure you use for i in tf.range(10) rather than for i in range(10), or else the loop will not be captured in the graph. Instead, it will run during tracing. This may be what you want, if the for loop is meant to build the graph, for exam‐ ple to create each layer in a neural network.", "words": [{"w": "•", "b": [0.16, 0.1821, 0.1681, 0.2036]}, {"w": "TensorFlow", "b": [0.1786, 0.1821, 0.2768, 0.2036]}, {"w": "will", "b": [0.2818, 0.1821, 0.3122, 0.2036]}, {"w": "only", "b": [0.3172, 0.1821, 0.3541, 0.2036]}, {"w": "capture", "b": [0.3591, 0.1821, 0.4216, 0.2036]}, {"w": "for", "b": [0.4266, 0.1853, 0.4563, 0.2004]}, {"w": "loops", "b": [0.4613, 0.1821, 0.5064, 0.2036]}, {"w": "that", "b": [0.5114, 0.1821, 0.544, 0.2036]}, {"w": "iterate", "b": [0.549, 0.1821, 0.6015, 0.2036]}, {"w": "over", "b": [0.6065, 0.1821, 0.6433, 0.2036]}, {"w": "a", "b": [0.6483, 0.1821, 0.6575, 0.2036]}, {"w": "tensor", "b": [0.6625, 0.1821, 0.7151, 0.2036]}, {"w": "or", "b": [0.7201, 0.1821, 0.7385, 0.2036]}, {"w": "a", "b": [0.7435, 0.1821, 0.7526, 0.2036]}, {"w": "Dataset.", "b": [0.7576, 0.1821, 0.8316, 0.2036]}, {"w": "So", "b": [0.8364, 0.1821, 0.8569, 0.2036]}, {"w": "make", "b": [0.1786, 0.2021, 0.224, 0.2235]}, {"w": "sure", "b": [0.229, 0.2021, 0.2643, 0.2235]}, {"w": "you", "b": [0.2693, 0.2021, 0.3005, 0.2235]}, {"w": "use", "b": [0.3055, 0.2021, 0.3331, 0.2235]}, {"w": "for", "b": [0.3381, 0.2053, 0.3677, 0.2203]}, {"w": "i", "b": [0.3779, 0.2053, 0.3878, 0.2203]}, {"w": "in", "b": [0.3979, 0.2053, 0.4177, 0.2203]}, {"w": "tf.range(10)", "b": [0.4279, 0.2053, 0.5466, 0.2203]}, {"w": "rather", "b": [0.5516, 0.2021, 0.6022, 0.2235]}, {"w": "than", "b": [0.6069, 0.2021, 0.6449, 0.2235]}, {"w": "for", "b": [0.6502, 0.2053, 0.6798, 0.2203]}, {"w": "i", "b": [0.69, 0.2053, 0.6999, 0.2203]}, {"w": "in", "b": [0.71, 0.2053, 0.7298, 0.2203]}, {"w": "range(10),", "b": [0.74, 0.2021, 0.8338, 0.2235]}, {"w": "or", "b": [0.8385, 0.2021, 0.8569, 0.2235]}, {"w": "else", "b": [0.1786, 0.2211, 0.2092, 0.2425]}, {"w": "the", "b": [0.2144, 0.2211, 0.2407, 0.2425]}, {"w": "loop", "b": [0.2459, 0.2211, 0.2833, 0.2425]}, {"w": "will", "b": [0.2884, 0.2211, 0.3188, 0.2425]}, {"w": "not", "b": [0.324, 0.2211, 0.3524, 0.2425]}, {"w": "be", "b": [0.3575, 0.2211, 0.377, 0.2425]}, {"w": "captured", "b": [0.3821, 0.2211, 0.4556, 0.2425]}, {"w": "in", "b": [0.4608, 0.2211, 0.4777, 0.2425]}, {"w": "the", "b": [0.4829, 0.2211, 0.5092, 0.2425]}, {"w": "graph.", "b": [0.5144, 0.2211, 0.5674, 0.2425]}, {"w": "Instead,", "b": [0.5726, 0.2211, 0.6388, 0.2425]}, {"w": "it", "b": [0.644, 0.2211, 0.6559, 0.2425]}, {"w": "will", "b": [0.6611, 0.2211, 0.6915, 0.2425]}, {"w": "run", "b": [0.6966, 0.2211, 0.7268, 0.2425]}, {"w": "during", "b": [0.732, 0.2211, 0.7885, 0.2425]}, {"w": "tracing.", "b": [0.7936, 0.2211, 0.8572, 0.2425]}, {"w": "This", "b": [0.1786, 0.2411, 0.2158, 0.2625]}, {"w": "may", "b": [0.2205, 0.2411, 0.2559, 0.2625]}, {"w": "be", "b": [0.2606, 0.2411, 0.2801, 0.2625]}, {"w": "what", "b": [0.2848, 0.2411, 0.3253, 0.2625]}, {"w": "you", "b": [0.33, 0.2411, 0.3613, 0.2625]}, {"w": "want,", "b": [0.366, 0.2411, 0.4115, 0.2625]}, {"w": "if", "b": [0.4163, 0.2411, 0.428, 0.2625]}, {"w": "the", "b": [0.4327, 0.2411, 0.4591, 0.2625]}, {"w": "for", "b": [0.4644, 0.2443, 0.4941, 0.2593]}, {"w": "loop", "b": [0.4989, 0.2411, 0.5364, 0.2625]}, {"w": "is", "b": [0.5411, 0.2411, 0.5543, 0.2625]}, {"w": "meant", "b": [0.5591, 0.2411, 0.6115, 0.2625]}, {"w": "to", "b": [0.6162, 0.2411, 0.6332, 0.2625]}, {"w": "build", "b": [0.6379, 0.2411, 0.6814, 0.2625]}, {"w": "the", "b": [0.6861, 0.2411, 0.7125, 0.2625]}, {"w": "graph,", "b": [0.7172, 0.2411, 0.7702, 0.2625]}, {"w": "for", "b": [0.775, 0.2411, 0.7995, 0.2625]}, {"w": "exam‐", "b": [0.8042, 0.2411, 0.8565, 0.2625]}, {"w": "ple", "b": [0.1786, 0.2601, 0.2036, 0.2815]}, {"w": "to", "b": [0.2083, 0.2601, 0.2253, 0.2815]}, {"w": "create", "b": [0.2301, 0.2601, 0.2794, 0.2815]}, {"w": "each", "b": [0.2841, 0.2601, 0.3221, 0.2815]}, {"w": "layer", "b": [0.3268, 0.2601, 0.367, 0.2815]}, {"w": "in", "b": [0.3717, 0.2601, 0.3887, 0.2815]}, {"w": "a", "b": [0.3934, 0.2601, 0.4026, 0.2815]}, {"w": "neural", "b": [0.4073, 0.2601, 0.4608, 0.2815]}, {"w": "network.", "b": [0.4655, 0.2601, 0.5398, 0.2815]}]}, {"id": "b_2", "type": "paragraph", "text": "• And as always, for performance reasons, you should prefer a vectorized imple‐ mentation whenever you can, rather than using loops.", "words": [{"w": "•", "b": [0.16, 0.2852, 0.1681, 0.3066]}, {"w": "And", "b": [0.1786, 0.2852, 0.2154, 0.3066]}, {"w": "as", "b": [0.2224, 0.2852, 0.2392, 0.3066]}, {"w": "always,", "b": [0.2463, 0.2852, 0.3057, 0.3066]}, {"w": "for", "b": [0.3127, 0.2852, 0.3373, 0.3066]}, {"w": "performance", "b": [0.3443, 0.2852, 0.4516, 0.3066]}, {"w": "reasons,", "b": [0.4587, 0.2852, 0.5265, 0.3066]}, {"w": "you", "b": [0.5335, 0.2852, 0.5648, 0.3066]}, {"w": "should", "b": [0.5718, 0.2852, 0.6286, 0.3066]}, {"w": "prefer", "b": [0.6356, 0.2852, 0.6859, 0.3066]}, {"w": "a", "b": [0.693, 0.2852, 0.7021, 0.3066]}, {"w": "vectorized", "b": [0.7092, 0.2852, 0.7954, 0.3066]}, {"w": "imple‐", "b": [0.8024, 0.2852, 0.8571, 0.3066]}, {"w": "mentation", "b": [0.1786, 0.3043, 0.2646, 0.3257]}, {"w": "whenever", "b": [0.2693, 0.3043, 0.35, 0.3257]}, {"w": "you", "b": [0.3547, 0.3043, 0.386, 0.3257]}, {"w": "can,", "b": [0.3907, 0.3043, 0.4248, 0.3257]}, {"w": "rather", "b": [0.4296, 0.3043, 0.4801, 0.3257]}, {"w": "than", "b": [0.4848, 0.3043, 0.5228, 0.3257]}, {"w": "using", "b": [0.5276, 0.3043, 0.573, 0.3257]}, {"w": "loops.", "b": [0.5777, 0.3043, 0.6276, 0.3257]}]}, {"id": "b_3", "type": "paragraph", "text": "It’s time to sum up! In this chapter we started with a brief overview of TensorFlow, then we looked at TensorFlow’s low-level API, including tensors, operations, variables and special data structures. We then used these tools to customize almost every com‐ ponent in tf.keras. Finally, we looked at how TF Functions can boost performance, how graphs are generated using autograph and tracing, and what rules to follow when you write TF Functions (if you would like to open the black box a bit further, for example to explore the generated graphs, you will find further technical details in ???).", "words": [{"w": "It’s", "b": [0.1429, 0.3384, 0.1653, 0.3598]}, {"w": "time", "b": [0.1721, 0.3384, 0.2099, 0.3598]}, {"w": "to", "b": [0.2167, 0.3384, 0.2337, 0.3598]}, {"w": "sum", "b": [0.2405, 0.3384, 0.2763, 0.3598]}, {"w": "up!", "b": [0.2831, 0.3384, 0.3108, 0.3598]}, {"w": "In", "b": [0.3176, 0.3384, 0.3361, 0.3598]}, {"w": "this", "b": [0.3429, 0.3384, 0.3737, 0.3598]}, {"w": "chapter", "b": [0.3805, 0.3384, 0.443, 0.3598]}, {"w": "we", "b": [0.4498, 0.3384, 0.4729, 0.3598]}, {"w": "started", "b": [0.4797, 0.3384, 0.5368, 0.3598]}, {"w": "with", "b": [0.5436, 0.3384, 0.581, 0.3598]}, {"w": "a", "b": [0.5878, 0.3384, 0.5969, 0.3598]}, {"w": "brief", "b": [0.6037, 0.3384, 0.6426, 0.3598]}, {"w": "overview", "b": [0.6495, 0.3384, 0.7253, 0.3598]}, {"w": "of", "b": [0.7321, 0.3384, 0.7489, 0.3598]}, {"w": "TensorFlow,", "b": [0.7557, 0.3384, 0.8572, 0.3598]}, {"w": "then", "b": [0.1429, 0.3575, 0.1806, 0.3789]}, {"w": "we", "b": [0.1853, 0.3575, 0.2084, 0.3789]}, {"w": "looked", "b": [0.2132, 0.3575, 0.2699, 0.3789]}, {"w": "at", "b": [0.2746, 0.3575, 0.2897, 0.3789]}, {"w": "TensorFlow’s", "b": [0.2944, 0.3575, 0.403, 0.3789]}, {"w": "low-level", "b": [0.4077, 0.3575, 0.4832, 0.3789]}, {"w": "API,", "b": [0.4879, 0.3575, 0.5259, 0.3789]}, {"w": "including", "b": [0.5307, 0.3575, 0.6105, 0.3789]}, {"w": "tensors,", "b": [0.6152, 0.3575, 0.6802, 0.3789]}, {"w": "operations,", "b": [0.685, 0.3575, 0.7782, 0.3789]}, {"w": "variables", "b": [0.7829, 0.3575, 0.8565, 0.3789]}, {"w": "and", "b": [0.1429, 0.3765, 0.1744, 0.3979]}, {"w": "special", "b": [0.1798, 0.3765, 0.236, 0.3979]}, {"w": "data", "b": [0.2413, 0.3765, 0.2766, 0.3979]}, {"w": "structures.", "b": [0.2819, 0.3765, 0.3699, 0.3979]}, {"w": "We", "b": [0.3753, 0.3765, 0.4023, 0.3979]}, {"w": "then", "b": [0.4077, 0.3765, 0.4454, 0.3979]}, {"w": "used", "b": [0.4508, 0.3765, 0.4893, 0.3979]}, {"w": "these", "b": [0.4947, 0.3765, 0.5375, 0.3979]}, {"w": "tools", "b": [0.5429, 0.3765, 0.5834, 0.3979]}, {"w": "to", "b": [0.5887, 0.3765, 0.6057, 0.3979]}, {"w": "customize", "b": [0.6111, 0.3765, 0.6958, 0.3979]}, {"w": "almost", "b": [0.7012, 0.3765, 0.7573, 0.3979]}, {"w": "every", "b": [0.7626, 0.3765, 0.8079, 0.3979]}, {"w": "com‐", "b": [0.8132, 0.3765, 0.8571, 0.3979]}, {"w": "ponent", "b": [0.1429, 0.3956, 0.202, 0.417]}, {"w": "in", "b": [0.2092, 0.3956, 0.2262, 0.417]}, {"w": "tf.keras.", "b": [0.2334, 0.3956, 0.2991, 0.417]}, {"w": "Finally,", "b": [0.3063, 0.3956, 0.3668, 0.417]}, {"w": "we", "b": [0.374, 0.3956, 0.3971, 0.417]}, {"w": "looked", "b": [0.4043, 0.3956, 0.461, 0.417]}, {"w": "at", "b": [0.4682, 0.3956, 0.4833, 0.417]}, {"w": "how", "b": [0.4905, 0.3956, 0.5266, 0.417]}, {"w": "TF", "b": [0.5338, 0.3956, 0.5576, 0.417]}, {"w": "Functions", "b": [0.5648, 0.3956, 0.6483, 0.417]}, {"w": "can", "b": [0.6555, 0.3956, 0.6849, 0.417]}, {"w": "boost", "b": [0.6921, 0.3956, 0.7379, 0.417]}, {"w": "performance,", "b": [0.7451, 0.3956, 0.8571, 0.417]}, {"w": "how", "b": [0.1428, 0.4146, 0.1789, 0.436]}, {"w": "graphs", "b": [0.1836, 0.4146, 0.2395, 0.436]}, {"w": "are", "b": [0.2442, 0.4146, 0.27, 0.436]}, {"w": "generated", "b": [0.2747, 0.4146, 0.3562, 0.436]}, {"w": "using", "b": [0.361, 0.4146, 0.4064, 0.436]}, {"w": "autograph", "b": [0.4111, 0.4146, 0.4962, 0.436]}, {"w": "and", "b": [0.5009, 0.4146, 0.5325, 0.436]}, {"w": "tracing,", "b": [0.5372, 0.4146, 0.6007, 0.436]}, {"w": "and", "b": [0.6055, 0.4146, 0.637, 0.436]}, {"w": "what", "b": [0.6417, 0.4146, 0.6822, 0.436]}, {"w": "rules", "b": [0.687, 0.4146, 0.7275, 0.436]}, {"w": "to", "b": [0.7322, 0.4146, 0.7492, 0.436]}, {"w": "follow", "b": [0.754, 0.4146, 0.8062, 0.436]}, {"w": "when", "b": [0.8109, 0.4146, 0.8566, 0.436]}, {"w": "you", "b": [0.1428, 0.4337, 0.1741, 0.4551]}, {"w": "write", "b": [0.1817, 0.4337, 0.2245, 0.4551]}, {"w": "TF", "b": [0.2321, 0.4337, 0.2559, 0.4551]}, {"w": "Functions", "b": [0.2635, 0.4337, 0.347, 0.4551]}, {"w": "(if", "b": [0.3546, 0.4337, 0.3736, 0.4551]}, {"w": "you", "b": [0.3812, 0.4337, 0.4124, 0.4551]}, {"w": "would", "b": [0.42, 0.4337, 0.4722, 0.4551]}, {"w": "like", "b": [0.4798, 0.4337, 0.5099, 0.4551]}, {"w": "to", "b": [0.5175, 0.4337, 0.5344, 0.4551]}, {"w": "open", "b": [0.542, 0.4337, 0.5838, 0.4551]}, {"w": "the", "b": [0.5914, 0.4337, 0.6177, 0.4551]}, {"w": "black", "b": [0.6253, 0.4337, 0.6695, 0.4551]}, {"w": "box", "b": [0.6771, 0.4337, 0.7081, 0.4551]}, {"w": "a", "b": [0.7157, 0.4337, 0.7249, 0.4551]}, {"w": "bit", "b": [0.7325, 0.4337, 0.755, 0.4551]}, {"w": "further,", "b": [0.7626, 0.4337, 0.825, 0.4551]}, {"w": "for", "b": [0.8326, 0.4337, 0.8571, 0.4551]}, {"w": "example", "b": [0.1429, 0.4527, 0.2124, 0.4741]}, {"w": "to", "b": [0.2227, 0.4527, 0.2397, 0.4741]}, {"w": "explore", "b": [0.25, 0.4527, 0.312, 0.4741]}, {"w": "the", "b": [0.3223, 0.4527, 0.3487, 0.4741]}, {"w": "generated", "b": [0.3589, 0.4527, 0.4405, 0.4741]}, {"w": "graphs,", "b": [0.4508, 0.4527, 0.5114, 0.4741]}, {"w": "you", "b": [0.5217, 0.4527, 0.553, 0.4741]}, {"w": "will", "b": [0.5632, 0.4527, 0.5936, 0.4741]}, {"w": "find", "b": [0.6039, 0.4527, 0.6381, 0.4741]}, {"w": "further", "b": [0.6484, 0.4527, 0.7074, 0.4741]}, {"w": "technical", "b": [0.7177, 0.4527, 0.793, 0.4741]}, {"w": "details", "b": [0.8033, 0.4527, 0.8571, 0.4741]}, {"w": "in", "b": [0.1429, 0.4718, 0.1598, 0.4932]}, {"w": "???).", "b": [0.1646, 0.4718, 0.2002, 0.4932]}]}, {"id": "b_4", "type": "paragraph", "text": "In the next chapter, we will look at how to efficiently load and preprocess data with TensorFlow.", "words": [{"w": "In", "b": [0.1429, 0.4999, 0.1614, 0.5213]}, {"w": "the", "b": [0.1678, 0.4999, 0.1941, 0.5213]}, {"w": "next", "b": [0.2006, 0.4999, 0.237, 0.5213]}, {"w": "chapter,", "b": [0.2434, 0.4999, 0.3094, 0.5213]}, {"w": "we", "b": [0.3158, 0.4999, 0.339, 0.5213]}, {"w": "will", "b": [0.3454, 0.4999, 0.3758, 0.5213]}, {"w": "look", "b": [0.3822, 0.4999, 0.4191, 0.5213]}, {"w": "at", "b": [0.4255, 0.4999, 0.4406, 0.5213]}, {"w": "how", "b": [0.447, 0.4999, 0.483, 0.5213]}, {"w": "to", "b": [0.4895, 0.4999, 0.5065, 0.5213]}, {"w": "efficiently", "b": [0.5129, 0.4999, 0.5951, 0.5213]}, {"w": "load", "b": [0.6015, 0.4999, 0.6376, 0.5213]}, {"w": "and", "b": [0.644, 0.4999, 0.6755, 0.5213]}, {"w": "preprocess", "b": [0.682, 0.4999, 0.7717, 0.5213]}, {"w": "data", "b": [0.7781, 0.4999, 0.8134, 0.5213]}, {"w": "with", "b": [0.8198, 0.4999, 0.8571, 0.5213]}, {"w": "TensorFlow.", "b": [0.1429, 0.5189, 0.2443, 0.5403]}]}, {"id": "b_5", "type": "paragraph", "text": "TensorFlow Functions and Graphs | 401", "words": [{"w": "TensorFlow", "b": [0.5996, 0.9225, 0.6671, 0.9388]}, {"w": "Functions", "b": [0.6699, 0.9225, 0.7268, 0.9388]}, {"w": "and", "b": [0.7297, 0.9225, 0.7521, 0.9388]}, {"w": "Graphs", "b": [0.7549, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "401", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 428, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": []}, {"page": 429, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "CHAPTER 13 Loading and Preprocessing Data with", "words": [{"w": "CHAPTER", "b": [0.7262, 0.1146, 0.8246, 0.1451]}, {"w": "13", "b": [0.8299, 0.1146, 0.8571, 0.1451]}, {"w": "Loading", "b": [0.2464, 0.1478, 0.3794, 0.1935]}, {"w": "and", "b": [0.3873, 0.1478, 0.4501, 0.1935]}, {"w": "Preprocessing", "b": [0.458, 0.1478, 0.6879, 0.1935]}, {"w": "Data", "b": [0.6958, 0.1478, 0.7732, 0.1935]}, {"w": "with", "b": [0.7811, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_1", "type": "paragraph", "text": "TensorFlow", "words": [{"w": "TensorFlow", "b": [0.668, 0.184, 0.8571, 0.2297]}]}, {"id": "b_2", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 13 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.4006, 0.3102, 0.4201]}, {"w": "Early", "b": [0.3165, 0.4006, 0.3563, 0.4201]}, {"w": "Release", "b": [0.3626, 0.4006, 0.4189, 0.4201]}, {"w": "ebooks,", "b": [0.4251, 0.4006, 0.4831, 0.4201]}, {"w": "you", "b": [0.4894, 0.4006, 0.518, 0.4201]}, {"w": "get", "b": [0.5243, 0.4006, 0.5471, 0.4201]}, {"w": "books", "b": [0.5534, 0.4006, 0.5989, 0.4201]}, {"w": "in", "b": [0.6052, 0.4006, 0.6207, 0.4201]}, {"w": "their", "b": [0.627, 0.4006, 0.6632, 0.4201]}, {"w": "earliest", "b": [0.6695, 0.4006, 0.7239, 0.4201]}, {"w": "form—", "b": [0.7301, 0.4006, 0.7857, 0.4201]}, {"w": "the", "b": [0.2714, 0.418, 0.2955, 0.4376]}, {"w": "author’s", "b": [0.3012, 0.418, 0.3615, 0.4376]}, {"w": "raw", "b": [0.3672, 0.418, 0.3954, 0.4376]}, {"w": "and", "b": [0.4011, 0.418, 0.4299, 0.4376]}, {"w": "unedited", "b": [0.4357, 0.418, 0.5034, 0.4376]}, {"w": "content", "b": [0.5091, 0.418, 0.5667, 0.4376]}, {"w": "as", "b": [0.5725, 0.418, 0.5878, 0.4376]}, {"w": "he", "b": [0.5935, 0.418, 0.6118, 0.4376]}, {"w": "or", "b": [0.6175, 0.418, 0.6343, 0.4376]}, {"w": "she", "b": [0.6401, 0.418, 0.6653, 0.4376]}, {"w": "writes—so", "b": [0.671, 0.418, 0.7514, 0.4376]}, {"w": "you", "b": [0.7571, 0.418, 0.7857, 0.4376]}, {"w": "can", "b": [0.2714, 0.4354, 0.2982, 0.455]}, {"w": "take", "b": [0.306, 0.4354, 0.3377, 0.455]}, {"w": "advantage", "b": [0.3455, 0.4354, 0.4223, 0.455]}, {"w": "of", "b": [0.4301, 0.4354, 0.4454, 0.455]}, {"w": "these", "b": [0.4532, 0.4354, 0.4923, 0.455]}, {"w": "technologies", "b": [0.5001, 0.4354, 0.596, 0.455]}, {"w": "long", "b": [0.6038, 0.4354, 0.6376, 0.455]}, {"w": "before", "b": [0.6454, 0.4354, 0.6937, 0.455]}, {"w": "the", "b": [0.7014, 0.4354, 0.7255, 0.455]}, {"w": "official", "b": [0.7333, 0.4354, 0.7857, 0.455]}, {"w": "release", "b": [0.2714, 0.4528, 0.3229, 0.4724]}, {"w": "of", "b": [0.3284, 0.4528, 0.3437, 0.4724]}, {"w": "these", "b": [0.3492, 0.4528, 0.3884, 0.4724]}, {"w": "titles.", "b": [0.3938, 0.4528, 0.4348, 0.4724]}, {"w": "The", "b": [0.4403, 0.4528, 0.4703, 0.4724]}, {"w": "following", "b": [0.4757, 0.4528, 0.5479, 0.4724]}, {"w": "will", "b": [0.5534, 0.4528, 0.5812, 0.4724]}, {"w": "be", "b": [0.5866, 0.4528, 0.6044, 0.4724]}, {"w": "Chapter", "b": [0.6099, 0.4528, 0.6717, 0.4724]}, {"w": "13", "b": [0.6771, 0.4528, 0.6954, 0.4724]}, {"w": "in", "b": [0.7009, 0.4528, 0.7164, 0.4724]}, {"w": "the", "b": [0.7218, 0.4528, 0.7459, 0.4724]}, {"w": "final", "b": [0.7514, 0.4528, 0.7857, 0.4724]}, {"w": "release", "b": [0.2714, 0.4702, 0.3229, 0.4898]}, {"w": "of", "b": [0.3273, 0.4702, 0.3426, 0.4898]}, {"w": "the", "b": [0.3469, 0.4702, 0.371, 0.4898]}, {"w": "book.", "b": [0.3753, 0.4702, 0.4182, 0.4898]}]}, {"id": "b_3", "type": "paragraph", "text": "So far we have used only datasets that fit in memory, but Deep Learning systems are often trained on very large datasets that will not fit in RAM. Ingesting a large dataset and preprocessing it efficiently can be tricky to implement with other Deep Learning libraries, but TensorFlow makes it easy thanks to the Data API: you just create a data‐ set object, tell it where to get the data, then transform it in any way you want, and TensorFlow takes care of all the implementation details, such as multithreading, queuing, batching, prefetching, and so on.", "words": [{"w": "So", "b": [0.1429, 0.5101, 0.1634, 0.5315]}, {"w": "far", "b": [0.1692, 0.5101, 0.1923, 0.5315]}, {"w": "we", "b": [0.1982, 0.5101, 0.2213, 0.5315]}, {"w": "have", "b": [0.2272, 0.5101, 0.2655, 0.5315]}, {"w": "used", "b": [0.2714, 0.5101, 0.31, 0.5315]}, {"w": "only", "b": [0.3159, 0.5101, 0.3527, 0.5315]}, {"w": "datasets", "b": [0.3586, 0.5101, 0.4243, 0.5315]}, {"w": "that", "b": [0.4302, 0.5101, 0.4628, 0.5315]}, {"w": "fit", "b": [0.4687, 0.5101, 0.4868, 0.5315]}, {"w": "in", "b": [0.4927, 0.5101, 0.5096, 0.5315]}, {"w": "memory,", "b": [0.5155, 0.5101, 0.5903, 0.5315]}, {"w": "but", "b": [0.5961, 0.5101, 0.6241, 0.5315]}, {"w": "Deep", "b": [0.63, 0.5101, 0.6739, 0.5315]}, {"w": "Learning", "b": [0.6798, 0.5101, 0.7549, 0.5315]}, {"w": "systems", "b": [0.7608, 0.5101, 0.8255, 0.5315]}, {"w": "are", "b": [0.8314, 0.5101, 0.8571, 0.5315]}, {"w": "often", "b": [0.1428, 0.5291, 0.1862, 0.5506]}, {"w": "trained", "b": [0.1918, 0.5291, 0.2518, 0.5506]}, {"w": "on", "b": [0.2574, 0.5291, 0.2794, 0.5506]}, {"w": "very", "b": [0.2849, 0.5291, 0.3213, 0.5506]}, {"w": "large", "b": [0.3269, 0.5291, 0.3676, 0.5506]}, {"w": "datasets", "b": [0.3731, 0.5291, 0.4389, 0.5506]}, {"w": "that", "b": [0.4444, 0.5291, 0.477, 0.5506]}, {"w": "will", "b": [0.4825, 0.5291, 0.5129, 0.5506]}, {"w": "not", "b": [0.5185, 0.5291, 0.5468, 0.5506]}, {"w": "fit", "b": [0.5524, 0.5291, 0.5705, 0.5506]}, {"w": "in", "b": [0.576, 0.5291, 0.593, 0.5506]}, {"w": "RAM.", "b": [0.5985, 0.5291, 0.6492, 0.5506]}, {"w": "Ingesting", "b": [0.6547, 0.5291, 0.7325, 0.5506]}, {"w": "a", "b": [0.7381, 0.5291, 0.7472, 0.5506]}, {"w": "large", "b": [0.7527, 0.5291, 0.7935, 0.5506]}, {"w": "dataset", "b": [0.799, 0.5291, 0.8571, 0.5506]}, {"w": "and", "b": [0.1429, 0.5482, 0.1744, 0.5696]}, {"w": "preprocessing", "b": [0.1799, 0.5482, 0.2964, 0.5696]}, {"w": "it", "b": [0.3019, 0.5482, 0.3139, 0.5696]}, {"w": "efficiently", "b": [0.3194, 0.5482, 0.4016, 0.5696]}, {"w": "can", "b": [0.4071, 0.5482, 0.4365, 0.5696]}, {"w": "be", "b": [0.442, 0.5482, 0.4615, 0.5696]}, {"w": "tricky", "b": [0.467, 0.5482, 0.5154, 0.5696]}, {"w": "to", "b": [0.5209, 0.5482, 0.5379, 0.5696]}, {"w": "implement", "b": [0.5434, 0.5482, 0.634, 0.5696]}, {"w": "with", "b": [0.6395, 0.5482, 0.6769, 0.5696]}, {"w": "other", "b": [0.6824, 0.5482, 0.7271, 0.5696]}, {"w": "Deep", "b": [0.7326, 0.5482, 0.7766, 0.5696]}, {"w": "Learning", "b": [0.7821, 0.5482, 0.8571, 0.5696]}, {"w": "libraries,", "b": [0.1429, 0.5672, 0.2157, 0.5886]}, {"w": "but", "b": [0.2207, 0.5672, 0.2487, 0.5886]}, {"w": "TensorFlow", "b": [0.2537, 0.5672, 0.352, 0.5886]}, {"w": "makes", "b": [0.357, 0.5672, 0.41, 0.5886]}, {"w": "it", "b": [0.415, 0.5672, 0.4269, 0.5886]}, {"w": "easy", "b": [0.4319, 0.5672, 0.4671, 0.5886]}, {"w": "thanks", "b": [0.4721, 0.5672, 0.5281, 0.5886]}, {"w": "to", "b": [0.5331, 0.5672, 0.5501, 0.5886]}, {"w": "the", "b": [0.5551, 0.5672, 0.5814, 0.5886]}, {"w": "Data", "b": [0.5864, 0.567, 0.6275, 0.5886]}, {"w": "API:", "b": [0.6323, 0.567, 0.6694, 0.5886]}, {"w": "you", "b": [0.6744, 0.5672, 0.7056, 0.5886]}, {"w": "just", "b": [0.7106, 0.5672, 0.741, 0.5886]}, {"w": "create", "b": [0.746, 0.5672, 0.7953, 0.5886]}, {"w": "a", "b": [0.8003, 0.5672, 0.8095, 0.5886]}, {"w": "data‐", "b": [0.8145, 0.5672, 0.8571, 0.5886]}, {"w": "set", "b": [0.1429, 0.5863, 0.1657, 0.6077]}, {"w": "object,", "b": [0.1727, 0.5863, 0.228, 0.6077]}, {"w": "tell", "b": [0.2349, 0.5863, 0.2607, 0.6077]}, {"w": "it", "b": [0.2676, 0.5863, 0.2796, 0.6077]}, {"w": "where", "b": [0.2865, 0.5863, 0.3374, 0.6077]}, {"w": "to", "b": [0.3443, 0.5863, 0.3613, 0.6077]}, {"w": "get", "b": [0.3683, 0.5863, 0.3932, 0.6077]}, {"w": "the", "b": [0.4002, 0.5863, 0.4265, 0.6077]}, {"w": "data,", "b": [0.4335, 0.5863, 0.4735, 0.6077]}, {"w": "then", "b": [0.4804, 0.5863, 0.5182, 0.6077]}, {"w": "transform", "b": [0.5251, 0.5863, 0.609, 0.6077]}, {"w": "it", "b": [0.6159, 0.5863, 0.6279, 0.6077]}, {"w": "in", "b": [0.6348, 0.5863, 0.6518, 0.6077]}, {"w": "any", "b": [0.6588, 0.5863, 0.6884, 0.6077]}, {"w": "way", "b": [0.6953, 0.5863, 0.728, 0.6077]}, {"w": "you", "b": [0.7349, 0.5863, 0.7662, 0.6077]}, {"w": "want,", "b": [0.7731, 0.5863, 0.8186, 0.6077]}, {"w": "and", "b": [0.8256, 0.5863, 0.8571, 0.6077]}, {"w": "TensorFlow", "b": [0.1428, 0.6053, 0.2411, 0.6267]}, {"w": "takes", "b": [0.2509, 0.6053, 0.2933, 0.6267]}, {"w": "care", "b": [0.3031, 0.6053, 0.3377, 0.6267]}, {"w": "of", "b": [0.3475, 0.6053, 0.3643, 0.6267]}, {"w": "all", "b": [0.3741, 0.6053, 0.3938, 0.6267]}, {"w": "the", "b": [0.4037, 0.6053, 0.43, 0.6267]}, {"w": "implementation", "b": [0.4398, 0.6053, 0.5731, 0.6267]}, {"w": "details,", "b": [0.5829, 0.6053, 0.6415, 0.6267]}, {"w": "such", "b": [0.6514, 0.6053, 0.69, 0.6267]}, {"w": "as", "b": [0.6999, 0.6053, 0.7167, 0.6267]}, {"w": "multithreading,", "b": [0.7265, 0.6053, 0.8571, 0.6267]}, {"w": "queuing,", "b": [0.1429, 0.6244, 0.216, 0.6458]}, {"w": "batching,", "b": [0.2207, 0.6244, 0.2978, 0.6458]}, {"w": "prefetching,", "b": [0.3025, 0.6244, 0.4028, 0.6458]}, {"w": "and", "b": [0.4076, 0.6244, 0.4391, 0.6458]}, {"w": "so", "b": [0.4438, 0.6244, 0.4621, 0.6458]}, {"w": "on.", "b": [0.4668, 0.6244, 0.4936, 0.6458]}]}, {"id": "b_4", "type": "paragraph", "text": "Off the shelf, the Data API can read from text files (such as CSV files), binary files with fixed-size records, and binary files that use TensorFlow’s TFRecord format, which supports records of varying sizes. TFRecord is a flexible and efficient binary format based on Protocol Buffers (an open source binary format). The Data API also has support for reading from SQL databases. Moreover, many Open Source exten‐ sions are available to read from all sorts of data sources, such as Google’s BigQuery service.", "words": [{"w": "Off", "b": [0.1429, 0.6525, 0.1708, 0.6739]}, {"w": "the", "b": [0.1776, 0.6525, 0.204, 0.6739]}, {"w": "shelf,", "b": [0.2108, 0.6525, 0.2546, 0.6739]}, {"w": "the", "b": [0.2615, 0.6525, 0.2878, 0.6739]}, {"w": "Data", "b": [0.2947, 0.6525, 0.3343, 0.6739]}, {"w": "API", "b": [0.3411, 0.6525, 0.3744, 0.6739]}, {"w": "can", "b": [0.3812, 0.6525, 0.4106, 0.6739]}, {"w": "read", "b": [0.4175, 0.6525, 0.4542, 0.6739]}, {"w": "from", "b": [0.4611, 0.6525, 0.5027, 0.6739]}, {"w": "text", "b": [0.5095, 0.6525, 0.5409, 0.6739]}, {"w": "files", "b": [0.5478, 0.6525, 0.5813, 0.6739]}, {"w": "(such", "b": [0.5882, 0.6525, 0.634, 0.6739]}, {"w": "as", "b": [0.6409, 0.6525, 0.6577, 0.6739]}, {"w": "CSV", "b": [0.6646, 0.6525, 0.7029, 0.6739]}, {"w": "files),", "b": [0.7098, 0.6525, 0.7553, 0.6739]}, {"w": "binary", "b": [0.7622, 0.6525, 0.8168, 0.6739]}, {"w": "files", "b": [0.8236, 0.6525, 0.8571, 0.6739]}, {"w": "with", "b": [0.1429, 0.6715, 0.1802, 0.693]}, {"w": "fixed-size", "b": [0.1898, 0.6715, 0.2695, 0.693]}, {"w": "records,", "b": [0.2792, 0.6715, 0.3463, 0.693]}, {"w": "and", "b": [0.356, 0.6715, 0.3875, 0.693]}, {"w": "binary", "b": [0.3972, 0.6715, 0.4518, 0.693]}, {"w": "files", "b": [0.4614, 0.6715, 0.4949, 0.693]}, {"w": "that", "b": [0.5046, 0.6715, 0.5372, 0.693]}, {"w": "use", "b": [0.5468, 0.6715, 0.5744, 0.693]}, {"w": "TensorFlow’s", "b": [0.584, 0.6715, 0.6926, 0.693]}, {"w": "TFRecord", "b": [0.7022, 0.6715, 0.7861, 0.693]}, {"w": "format,", "b": [0.7957, 0.6715, 0.8571, 0.693]}, {"w": "which", "b": [0.1429, 0.6906, 0.1938, 0.712]}, {"w": "supports", "b": [0.2008, 0.6906, 0.2737, 0.712]}, {"w": "records", "b": [0.2807, 0.6906, 0.3431, 0.712]}, {"w": "of", "b": [0.3502, 0.6906, 0.367, 0.712]}, {"w": "varying", "b": [0.374, 0.6906, 0.4374, 0.712]}, {"w": "sizes.", "b": [0.4445, 0.6906, 0.4877, 0.712]}, {"w": "TFRecord", "b": [0.4947, 0.6906, 0.5786, 0.712]}, {"w": "is", "b": [0.5856, 0.6906, 0.5988, 0.712]}, {"w": "a", "b": [0.6059, 0.6906, 0.615, 0.712]}, {"w": "flexible", "b": [0.6221, 0.6906, 0.6825, 0.712]}, {"w": "and", "b": [0.6895, 0.6906, 0.7211, 0.712]}, {"w": "efficient", "b": [0.7281, 0.6906, 0.7955, 0.712]}, {"w": "binary", "b": [0.8025, 0.6906, 0.8571, 0.712]}, {"w": "format", "b": [0.1429, 0.7096, 0.1996, 0.7311]}, {"w": "based", "b": [0.205, 0.7096, 0.2522, 0.7311]}, {"w": "on", "b": [0.2577, 0.7096, 0.2797, 0.7311]}, {"w": "Protocol", "b": [0.2852, 0.7096, 0.3569, 0.7311]}, {"w": "Buffers", "b": [0.3624, 0.7096, 0.4223, 0.7311]}, {"w": "(an", "b": [0.4277, 0.7096, 0.4555, 0.7311]}, {"w": "open", "b": [0.4609, 0.7096, 0.5027, 0.7311]}, {"w": "source", "b": [0.5082, 0.7096, 0.5629, 0.7311]}, {"w": "binary", "b": [0.5683, 0.7096, 0.6229, 0.7311]}, {"w": "format).", "b": [0.6284, 0.7096, 0.697, 0.7311]}, {"w": "The", "b": [0.7025, 0.7096, 0.7353, 0.7311]}, {"w": "Data", "b": [0.7408, 0.7096, 0.7803, 0.7311]}, {"w": "API", "b": [0.7858, 0.7096, 0.819, 0.7311]}, {"w": "also", "b": [0.8245, 0.7096, 0.8572, 0.7311]}, {"w": "has", "b": [0.1429, 0.7287, 0.1708, 0.7501]}, {"w": "support", "b": [0.1783, 0.7287, 0.2435, 0.7501]}, {"w": "for", "b": [0.251, 0.7287, 0.2755, 0.7501]}, {"w": "reading", "b": [0.283, 0.7287, 0.3465, 0.7501]}, {"w": "from", "b": [0.354, 0.7287, 0.3956, 0.7501]}, {"w": "SQL", "b": [0.4031, 0.7287, 0.4397, 0.7501]}, {"w": "databases.", "b": [0.4472, 0.7287, 0.5311, 0.7501]}, {"w": "Moreover,", "b": [0.5386, 0.7287, 0.6241, 0.7501]}, {"w": "many", "b": [0.6316, 0.7287, 0.6783, 0.7501]}, {"w": "Open", "b": [0.6858, 0.7287, 0.7325, 0.7501]}, {"w": "Source", "b": [0.74, 0.7287, 0.7969, 0.7501]}, {"w": "exten‐", "b": [0.8044, 0.7287, 0.8571, 0.7501]}, {"w": "sions", "b": [0.1429, 0.7477, 0.1858, 0.7691]}, {"w": "are", "b": [0.1924, 0.7477, 0.2182, 0.7691]}, {"w": "available", "b": [0.2249, 0.7477, 0.2971, 0.7691]}, {"w": "to", "b": [0.3038, 0.7477, 0.3208, 0.7691]}, {"w": "read", "b": [0.3275, 0.7477, 0.3642, 0.7691]}, {"w": "from", "b": [0.3709, 0.7477, 0.4125, 0.7691]}, {"w": "all", "b": [0.4192, 0.7477, 0.4389, 0.7691]}, {"w": "sorts", "b": [0.4456, 0.7477, 0.4856, 0.7691]}, {"w": "of", "b": [0.4923, 0.7477, 0.5091, 0.7691]}, {"w": "data", "b": [0.5158, 0.7477, 0.551, 0.7691]}, {"w": "sources,", "b": [0.5577, 0.7477, 0.6249, 0.7691]}, {"w": "such", "b": [0.6316, 0.7477, 0.6702, 0.7691]}, {"w": "as", "b": [0.6769, 0.7477, 0.6937, 0.7691]}, {"w": "Google’s", "b": [0.7004, 0.7477, 0.7695, 0.7691]}, {"w": "BigQuery", "b": [0.7762, 0.7477, 0.8571, 0.7691]}, {"w": "service.", "b": [0.1428, 0.7668, 0.2053, 0.7882]}]}, {"id": "b_5", "type": "paragraph", "text": "However, reading huge datasets efficiently is not the only difficulty: the data also needs to be preprocessed. Indeed, it is not always composed strictly of convenient numerical fields: sometimes there will be text features, categorical features, and so on. To handle this, TensorFlow provides the Features API: it lets you easily convert these features to numerical features that can be consumed by your neural network. For", "words": [{"w": "However,", "b": [0.1428, 0.7949, 0.2217, 0.8163]}, {"w": "reading", "b": [0.2303, 0.7949, 0.2938, 0.8163]}, {"w": "huge", "b": [0.3024, 0.7949, 0.3428, 0.8163]}, {"w": "datasets", "b": [0.3515, 0.7949, 0.4172, 0.8163]}, {"w": "efficiently", "b": [0.4258, 0.7949, 0.508, 0.8163]}, {"w": "is", "b": [0.5167, 0.7949, 0.5299, 0.8163]}, {"w": "not", "b": [0.5385, 0.7949, 0.5669, 0.8163]}, {"w": "the", "b": [0.5756, 0.7949, 0.6019, 0.8163]}, {"w": "only", "b": [0.6105, 0.7949, 0.6474, 0.8163]}, {"w": "difficulty:", "b": [0.656, 0.7949, 0.737, 0.8163]}, {"w": "the", "b": [0.7456, 0.7949, 0.7719, 0.8163]}, {"w": "data", "b": [0.7806, 0.7949, 0.8158, 0.8163]}, {"w": "also", "b": [0.8244, 0.7949, 0.8571, 0.8163]}, {"w": "needs", "b": [0.1429, 0.8139, 0.1906, 0.8354]}, {"w": "to", "b": [0.1984, 0.8139, 0.2154, 0.8354]}, {"w": "be", "b": [0.2231, 0.8139, 0.2426, 0.8354]}, {"w": "preprocessed.", "b": [0.2504, 0.8139, 0.3647, 0.8354]}, {"w": "Indeed,", "b": [0.3725, 0.8139, 0.4354, 0.8354]}, {"w": "it", "b": [0.4432, 0.8139, 0.4551, 0.8354]}, {"w": "is", "b": [0.4629, 0.8139, 0.4762, 0.8354]}, {"w": "not", "b": [0.4839, 0.8139, 0.5123, 0.8354]}, {"w": "always", "b": [0.5201, 0.8139, 0.5747, 0.8354]}, {"w": "composed", "b": [0.5825, 0.8139, 0.6677, 0.8354]}, {"w": "strictly", "b": [0.6754, 0.8139, 0.7328, 0.8354]}, {"w": "of", "b": [0.7405, 0.8139, 0.7573, 0.8354]}, {"w": "convenient", "b": [0.7651, 0.8139, 0.8572, 0.8354]}, {"w": "numerical", "b": [0.1429, 0.833, 0.2274, 0.8544]}, {"w": "fields:", "b": [0.2324, 0.833, 0.2817, 0.8544]}, {"w": "sometimes", "b": [0.2867, 0.833, 0.3763, 0.8544]}, {"w": "there", "b": [0.3814, 0.833, 0.4243, 0.8544]}, {"w": "will", "b": [0.4293, 0.833, 0.4597, 0.8544]}, {"w": "be", "b": [0.4647, 0.833, 0.4841, 0.8544]}, {"w": "text", "b": [0.4891, 0.833, 0.5205, 0.8544]}, {"w": "features,", "b": [0.5255, 0.833, 0.5957, 0.8544]}, {"w": "categorical", "b": [0.6007, 0.833, 0.6904, 0.8544]}, {"w": "features,", "b": [0.6954, 0.833, 0.7655, 0.8544]}, {"w": "and", "b": [0.7706, 0.833, 0.8021, 0.8544]}, {"w": "so", "b": [0.8071, 0.833, 0.8254, 0.8544]}, {"w": "on.", "b": [0.8304, 0.833, 0.8571, 0.8544]}, {"w": "To", "b": [0.1429, 0.852, 0.1643, 0.8735]}, {"w": "handle", "b": [0.1702, 0.852, 0.2269, 0.8735]}, {"w": "this,", "b": [0.2328, 0.852, 0.2683, 0.8735]}, {"w": "TensorFlow", "b": [0.2741, 0.852, 0.3724, 0.8735]}, {"w": "provides", "b": [0.3783, 0.852, 0.4503, 0.8735]}, {"w": "the", "b": [0.4561, 0.852, 0.4825, 0.8735]}, {"w": "Features", "b": [0.4883, 0.8518, 0.5561, 0.8735]}, {"w": "API:", "b": [0.562, 0.8518, 0.5988, 0.8735]}, {"w": "it", "b": [0.6047, 0.852, 0.6166, 0.8735]}, {"w": "lets", "b": [0.6225, 0.852, 0.6506, 0.8735]}, {"w": "you", "b": [0.6565, 0.852, 0.6877, 0.8735]}, {"w": "easily", "b": [0.6936, 0.852, 0.7396, 0.8735]}, {"w": "convert", "b": [0.7455, 0.852, 0.8084, 0.8735]}, {"w": "these", "b": [0.8143, 0.852, 0.8571, 0.8735]}, {"w": "features", "b": [0.1429, 0.8711, 0.2083, 0.8925]}, {"w": "to", "b": [0.2165, 0.8711, 0.2334, 0.8925]}, {"w": "numerical", "b": [0.2416, 0.8711, 0.3262, 0.8925]}, {"w": "features", "b": [0.3343, 0.8711, 0.3998, 0.8925]}, {"w": "that", "b": [0.4079, 0.8711, 0.4405, 0.8925]}, {"w": "can", "b": [0.4487, 0.8711, 0.4781, 0.8925]}, {"w": "be", "b": [0.4863, 0.8711, 0.5057, 0.8925]}, {"w": "consumed", "b": [0.5139, 0.8711, 0.6003, 0.8925]}, {"w": "by", "b": [0.6085, 0.8711, 0.6287, 0.8925]}, {"w": "your", "b": [0.6369, 0.8711, 0.6758, 0.8925]}, {"w": "neural", "b": [0.684, 0.8711, 0.7375, 0.8925]}, {"w": "network.", "b": [0.7457, 0.8711, 0.82, 0.8925]}, {"w": "For", "b": [0.8282, 0.8711, 0.8572, 0.8925]}]}, {"id": "b_6", "type": "paragraph", "text": "403", "words": [{"w": "403", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 430, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "example, categorical features with a large number of categories (such as cities, or words) can be encoded using embeddings (as we will see, an embedding is a trainable dense vector that represents a category).", "words": [{"w": "example,", "b": [0.1429, 0.0791, 0.2171, 0.1005]}, {"w": "categorical", "b": [0.2257, 0.0791, 0.3154, 0.1005]}, {"w": "features", "b": [0.324, 0.0791, 0.3894, 0.1005]}, {"w": "with", "b": [0.398, 0.0791, 0.4353, 0.1005]}, {"w": "a", "b": [0.4439, 0.0791, 0.4531, 0.1005]}, {"w": "large", "b": [0.4617, 0.0791, 0.5024, 0.1005]}, {"w": "number", "b": [0.511, 0.0791, 0.5773, 0.1005]}, {"w": "of", "b": [0.5859, 0.0791, 0.6027, 0.1005]}, {"w": "categories", "b": [0.6113, 0.0791, 0.6942, 0.1005]}, {"w": "(such", "b": [0.7028, 0.0791, 0.7487, 0.1005]}, {"w": "as", "b": [0.7572, 0.0791, 0.774, 0.1005]}, {"w": "cities,", "b": [0.7826, 0.0791, 0.8302, 0.1005]}, {"w": "or", "b": [0.8388, 0.0791, 0.8571, 0.1005]}, {"w": "words)", "b": [0.1429, 0.0981, 0.2013, 0.1195]}, {"w": "can", "b": [0.2068, 0.0981, 0.2362, 0.1195]}, {"w": "be", "b": [0.2417, 0.0981, 0.2611, 0.1195]}, {"w": "encoded", "b": [0.2666, 0.0981, 0.3371, 0.1195]}, {"w": "using", "b": [0.3426, 0.0981, 0.3881, 0.1195]}, {"w": "embeddings", "b": [0.3936, 0.0979, 0.489, 0.1195]}, {"w": "(as", "b": [0.4945, 0.0981, 0.5185, 0.1195]}, {"w": "we", "b": [0.524, 0.0981, 0.5471, 0.1195]}, {"w": "will", "b": [0.5526, 0.0981, 0.583, 0.1195]}, {"w": "see,", "b": [0.5885, 0.0981, 0.6186, 0.1195]}, {"w": "an", "b": [0.6241, 0.0981, 0.6447, 0.1195]}, {"w": "embedding", "b": [0.6501, 0.0981, 0.7442, 0.1195]}, {"w": "is", "b": [0.7497, 0.0981, 0.7629, 0.1195]}, {"w": "a", "b": [0.7684, 0.0981, 0.7776, 0.1195]}, {"w": "trainable", "b": [0.7831, 0.0981, 0.8571, 0.1195]}, {"w": "dense", "b": [0.1429, 0.1172, 0.1906, 0.1386]}, {"w": "vector", "b": [0.1953, 0.1172, 0.2474, 0.1386]}, {"w": "that", "b": [0.2521, 0.1172, 0.2847, 0.1386]}, {"w": "represents", "b": [0.2894, 0.1172, 0.375, 0.1386]}, {"w": "a", "b": [0.3797, 0.1172, 0.3889, 0.1386]}, {"w": "category).", "b": [0.3936, 0.1172, 0.4766, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "Both the Data API and the Features API work seamlessly with tf.keras.", "words": [{"w": "Both", "b": [0.2714, 0.1591, 0.3087, 0.1787]}, {"w": "the", "b": [0.3173, 0.1591, 0.3414, 0.1787]}, {"w": "Data", "b": [0.35, 0.1591, 0.3862, 0.1787]}, {"w": "API", "b": [0.3948, 0.1591, 0.4252, 0.1787]}, {"w": "and", "b": [0.4338, 0.1591, 0.4627, 0.1787]}, {"w": "the", "b": [0.4713, 0.1591, 0.4954, 0.1787]}, {"w": "Features", "b": [0.504, 0.1591, 0.5679, 0.1787]}, {"w": "API", "b": [0.5765, 0.1591, 0.6069, 0.1787]}, {"w": "work", "b": [0.6155, 0.1591, 0.6548, 0.1787]}, {"w": "seamlessly", "b": [0.6635, 0.1591, 0.743, 0.1787]}, {"w": "with", "b": [0.7516, 0.1591, 0.7857, 0.1787]}, {"w": "tf.keras.", "b": [0.2714, 0.1765, 0.3315, 0.1961]}]}, {"id": "b_2", "type": "paragraph", "text": "In this chapter, we will cover the Data API, the TFRecord format and the Features API in detail. We will also take a quick look at a few related projects from Tensor‐ Flow’s ecosystem:", "words": [{"w": "In", "b": [0.1429, 0.2577, 0.1614, 0.2792]}, {"w": "this", "b": [0.1686, 0.2577, 0.1993, 0.2792]}, {"w": "chapter,", "b": [0.2066, 0.2577, 0.2725, 0.2792]}, {"w": "we", "b": [0.2798, 0.2577, 0.3029, 0.2792]}, {"w": "will", "b": [0.3102, 0.2577, 0.3406, 0.2792]}, {"w": "cover", "b": [0.3478, 0.2577, 0.3935, 0.2792]}, {"w": "the", "b": [0.4007, 0.2577, 0.427, 0.2792]}, {"w": "Data", "b": [0.4343, 0.2577, 0.4739, 0.2792]}, {"w": "API,", "b": [0.4811, 0.2577, 0.5191, 0.2792]}, {"w": "the", "b": [0.5263, 0.2577, 0.5527, 0.2792]}, {"w": "TFRecord", "b": [0.5599, 0.2577, 0.6437, 0.2792]}, {"w": "format", "b": [0.651, 0.2577, 0.7077, 0.2792]}, {"w": "and", "b": [0.7149, 0.2577, 0.7465, 0.2792]}, {"w": "the", "b": [0.7537, 0.2577, 0.78, 0.2792]}, {"w": "Features", "b": [0.7873, 0.2577, 0.8572, 0.2792]}, {"w": "API", "b": [0.1429, 0.2768, 0.1761, 0.2982]}, {"w": "in", "b": [0.1832, 0.2768, 0.2001, 0.2982]}, {"w": "detail.", "b": [0.2072, 0.2768, 0.2582, 0.2982]}, {"w": "We", "b": [0.2652, 0.2768, 0.2923, 0.2982]}, {"w": "will", "b": [0.2994, 0.2768, 0.3298, 0.2982]}, {"w": "also", "b": [0.3368, 0.2768, 0.3695, 0.2982]}, {"w": "take", "b": [0.3766, 0.2768, 0.4113, 0.2982]}, {"w": "a", "b": [0.4184, 0.2768, 0.4275, 0.2982]}, {"w": "quick", "b": [0.4346, 0.2768, 0.481, 0.2982]}, {"w": "look", "b": [0.4881, 0.2768, 0.5249, 0.2982]}, {"w": "at", "b": [0.532, 0.2768, 0.5471, 0.2982]}, {"w": "a", "b": [0.5542, 0.2768, 0.5633, 0.2982]}, {"w": "few", "b": [0.5704, 0.2768, 0.5997, 0.2982]}, {"w": "related", "b": [0.6068, 0.2768, 0.6636, 0.2982]}, {"w": "projects", "b": [0.6707, 0.2768, 0.7369, 0.2982]}, {"w": "from", "b": [0.744, 0.2768, 0.7856, 0.2982]}, {"w": "Tensor‐", "b": [0.7927, 0.2768, 0.8571, 0.2982]}, {"w": "Flow’s", "b": [0.1429, 0.2958, 0.1944, 0.3173]}, {"w": "ecosystem:", "b": [0.1991, 0.2958, 0.2892, 0.3173]}]}, {"id": "b_3", "type": "paragraph", "text": "• TF Transform (tf.Transform) makes it possible to write a single preprocessing function that can be run both in batch mode on your full training set, before training (to speed it up), and then exported to a TF Function and incorporated into your trained model, so that once it is deployed in production, it can take care of preprocessing new instances on the fly.", "words": [{"w": "•", "b": [0.16, 0.33, 0.1682, 0.3514]}, {"w": "TF", "b": [0.1786, 0.33, 0.2024, 0.3514]}, {"w": "Transform", "b": [0.2108, 0.33, 0.2995, 0.3514]}, {"w": "(tf.Transform)", "b": [0.3078, 0.3298, 0.4241, 0.3514]}, {"w": "makes", "b": [0.4325, 0.33, 0.4855, 0.3514]}, {"w": "it", "b": [0.4939, 0.33, 0.5058, 0.3514]}, {"w": "possible", "b": [0.5142, 0.33, 0.5813, 0.3514]}, {"w": "to", "b": [0.5897, 0.33, 0.6067, 0.3514]}, {"w": "write", "b": [0.6151, 0.33, 0.6579, 0.3514]}, {"w": "a", "b": [0.6663, 0.33, 0.6754, 0.3514]}, {"w": "single", "b": [0.6838, 0.33, 0.7323, 0.3514]}, {"w": "preprocessing", "b": [0.7407, 0.33, 0.8571, 0.3514]}, {"w": "function", "b": [0.1786, 0.3491, 0.25, 0.3705]}, {"w": "that", "b": [0.2579, 0.3491, 0.2905, 0.3705]}, {"w": "can", "b": [0.2984, 0.3491, 0.3277, 0.3705]}, {"w": "be", "b": [0.3356, 0.3491, 0.3551, 0.3705]}, {"w": "run", "b": [0.363, 0.3491, 0.3931, 0.3705]}, {"w": "both", "b": [0.4011, 0.3491, 0.4397, 0.3705]}, {"w": "in", "b": [0.4476, 0.3491, 0.4646, 0.3705]}, {"w": "batch", "b": [0.4725, 0.3491, 0.5182, 0.3705]}, {"w": "mode", "b": [0.5261, 0.3491, 0.5736, 0.3705]}, {"w": "on", "b": [0.5815, 0.3491, 0.6035, 0.3705]}, {"w": "your", "b": [0.6114, 0.3491, 0.6504, 0.3705]}, {"w": "full", "b": [0.6583, 0.3491, 0.6861, 0.3705]}, {"w": "training", "b": [0.694, 0.3491, 0.7609, 0.3705]}, {"w": "set,", "b": [0.7688, 0.3491, 0.7964, 0.3705]}, {"w": "before", "b": [0.8043, 0.3491, 0.8571, 0.3705]}, {"w": "training", "b": [0.1786, 0.3681, 0.2455, 0.3895]}, {"w": "(to", "b": [0.252, 0.3681, 0.2762, 0.3895]}, {"w": "speed", "b": [0.2828, 0.3681, 0.3301, 0.3895]}, {"w": "it", "b": [0.3366, 0.3681, 0.3485, 0.3895]}, {"w": "up),", "b": [0.3551, 0.3681, 0.389, 0.3895]}, {"w": "and", "b": [0.3956, 0.3681, 0.4271, 0.3895]}, {"w": "then", "b": [0.4337, 0.3681, 0.4714, 0.3895]}, {"w": "exported", "b": [0.4779, 0.3681, 0.5521, 0.3895]}, {"w": "to", "b": [0.5586, 0.3681, 0.5756, 0.3895]}, {"w": "a", "b": [0.5822, 0.3681, 0.5913, 0.3895]}, {"w": "TF", "b": [0.5979, 0.3681, 0.6217, 0.3895]}, {"w": "Function", "b": [0.6283, 0.3681, 0.7041, 0.3895]}, {"w": "and", "b": [0.7107, 0.3681, 0.7422, 0.3895]}, {"w": "incorporated", "b": [0.7488, 0.3681, 0.8571, 0.3895]}, {"w": "into", "b": [0.1786, 0.3871, 0.2121, 0.4086]}, {"w": "your", "b": [0.2196, 0.3871, 0.2586, 0.4086]}, {"w": "trained", "b": [0.2661, 0.3871, 0.3261, 0.4086]}, {"w": "model,", "b": [0.3336, 0.3871, 0.3912, 0.4086]}, {"w": "so", "b": [0.3987, 0.3871, 0.417, 0.4086]}, {"w": "that", "b": [0.4244, 0.3871, 0.457, 0.4086]}, {"w": "once", "b": [0.4645, 0.3871, 0.5042, 0.4086]}, {"w": "it", "b": [0.5117, 0.3871, 0.5236, 0.4086]}, {"w": "is", "b": [0.5311, 0.3871, 0.5443, 0.4086]}, {"w": "deployed", "b": [0.5518, 0.3871, 0.6279, 0.4086]}, {"w": "in", "b": [0.6354, 0.3871, 0.6524, 0.4086]}, {"w": "production,", "b": [0.6599, 0.3871, 0.7587, 0.4086]}, {"w": "it", "b": [0.7662, 0.3871, 0.7781, 0.4086]}, {"w": "can", "b": [0.7856, 0.3871, 0.815, 0.4086]}, {"w": "take", "b": [0.8225, 0.3871, 0.8571, 0.4086]}, {"w": "care", "b": [0.1786, 0.4062, 0.2131, 0.4276]}, {"w": "of", "b": [0.2179, 0.4062, 0.2346, 0.4276]}, {"w": "preprocessing", "b": [0.2394, 0.4062, 0.3558, 0.4276]}, {"w": "new", "b": [0.3606, 0.4062, 0.3951, 0.4276]}, {"w": "instances", "b": [0.3998, 0.4062, 0.4766, 0.4276]}, {"w": "on", "b": [0.4814, 0.4062, 0.5034, 0.4276]}, {"w": "the", "b": [0.5081, 0.4062, 0.5345, 0.4276]}, {"w": "fly.", "b": [0.5392, 0.4062, 0.5634, 0.4276]}]}, {"id": "b_4", "type": "paragraph", "text": "• TF Datasets (TFDS) provides a convenient function to download many common datasets of all kinds, including large ones like ImageNet, and it provides conve‐ nient dataset objects to manipulate them using the Data API.", "words": [{"w": "•", "b": [0.16, 0.4313, 0.1681, 0.4527]}, {"w": "TF", "b": [0.1786, 0.4313, 0.2024, 0.4527]}, {"w": "Datasets", "b": [0.2078, 0.4313, 0.2779, 0.4527]}, {"w": "(TFDS)", "b": [0.2833, 0.4313, 0.3468, 0.4527]}, {"w": "provides", "b": [0.3522, 0.4313, 0.4242, 0.4527]}, {"w": "a", "b": [0.4296, 0.4313, 0.4387, 0.4527]}, {"w": "convenient", "b": [0.4441, 0.4313, 0.5362, 0.4527]}, {"w": "function", "b": [0.5416, 0.4313, 0.613, 0.4527]}, {"w": "to", "b": [0.6184, 0.4313, 0.6353, 0.4527]}, {"w": "download", "b": [0.6407, 0.4313, 0.7241, 0.4527]}, {"w": "many", "b": [0.7295, 0.4313, 0.7762, 0.4527]}, {"w": "common", "b": [0.7816, 0.4313, 0.8571, 0.4527]}, {"w": "datasets", "b": [0.1786, 0.4503, 0.2443, 0.4718]}, {"w": "of", "b": [0.2508, 0.4503, 0.2676, 0.4718]}, {"w": "all", "b": [0.2741, 0.4503, 0.2938, 0.4718]}, {"w": "kinds,", "b": [0.3003, 0.4503, 0.351, 0.4718]}, {"w": "including", "b": [0.3575, 0.4503, 0.4373, 0.4718]}, {"w": "large", "b": [0.4438, 0.4503, 0.4846, 0.4718]}, {"w": "ones", "b": [0.4911, 0.4503, 0.5296, 0.4718]}, {"w": "like", "b": [0.5361, 0.4503, 0.5661, 0.4718]}, {"w": "ImageNet,", "b": [0.5726, 0.4503, 0.6594, 0.4718]}, {"w": "and", "b": [0.6659, 0.4503, 0.6975, 0.4718]}, {"w": "it", "b": [0.704, 0.4503, 0.7159, 0.4718]}, {"w": "provides", "b": [0.7224, 0.4503, 0.7944, 0.4718]}, {"w": "conve‐", "b": [0.8009, 0.4503, 0.8571, 0.4718]}, {"w": "nient", "b": [0.1786, 0.4694, 0.2218, 0.4908]}, {"w": "dataset", "b": [0.2265, 0.4694, 0.2846, 0.4908]}, {"w": "objects", "b": [0.2893, 0.4694, 0.3475, 0.4908]}, {"w": "to", "b": [0.3523, 0.4694, 0.3692, 0.4908]}, {"w": "manipulate", "b": [0.374, 0.4694, 0.4684, 0.4908]}, {"w": "them", "b": [0.4731, 0.4694, 0.5165, 0.4908]}, {"w": "using", "b": [0.5212, 0.4694, 0.5666, 0.4908]}, {"w": "the", "b": [0.5714, 0.4694, 0.5977, 0.4908]}, {"w": "Data", "b": [0.6024, 0.4694, 0.642, 0.4908]}, {"w": "API.", "b": [0.6467, 0.4694, 0.6847, 0.4908]}]}, {"id": "b_5", "type": "paragraph", "text": "So let’s get started!", "words": [{"w": "So", "b": [0.1429, 0.5036, 0.1634, 0.525]}, {"w": "let’s", "b": [0.1681, 0.5036, 0.1983, 0.525]}, {"w": "get", "b": [0.203, 0.5036, 0.228, 0.525]}, {"w": "started!", "b": [0.2327, 0.5036, 0.2956, 0.525]}]}, {"id": "b_6", "type": "paragraph", "text": "The Data API", "words": [{"w": "The", "b": [0.1429, 0.538, 0.188, 0.5722]}, {"w": "Data", "b": [0.194, 0.538, 0.2521, 0.5722]}, {"w": "API", "b": [0.258, 0.538, 0.2995, 0.5722]}]}, {"id": "b_7", "type": "paragraph", "text": "The whole Data API revolves around the concept of a dataset: as you might suspect, this represents a sequence of data items. Usually you will use datasets that gradually read data from disk, but for simplicity let’s just create a dataset entirely in RAM using tf.data.Dataset.from_tensor_slices():", "words": [{"w": "The", "b": [0.1429, 0.5791, 0.1757, 0.6006]}, {"w": "whole", "b": [0.1817, 0.5791, 0.2319, 0.6006]}, {"w": "Data", "b": [0.2379, 0.5791, 0.2775, 0.6006]}, {"w": "API", "b": [0.2835, 0.5791, 0.3168, 0.6006]}, {"w": "revolves", "b": [0.3228, 0.5791, 0.3911, 0.6006]}, {"w": "around", "b": [0.3971, 0.5791, 0.4581, 0.6006]}, {"w": "the", "b": [0.4641, 0.5791, 0.4905, 0.6006]}, {"w": "concept", "b": [0.4965, 0.5791, 0.5623, 0.6006]}, {"w": "of", "b": [0.5683, 0.5791, 0.5851, 0.6006]}, {"w": "a", "b": [0.5912, 0.5791, 0.6003, 0.6006]}, {"w": "dataset:", "b": [0.6063, 0.5789, 0.6694, 0.6006]}, {"w": "as", "b": [0.6754, 0.5791, 0.6922, 0.6006]}, {"w": "you", "b": [0.6983, 0.5791, 0.7295, 0.6006]}, {"w": "might", "b": [0.7356, 0.5791, 0.7851, 0.6006]}, {"w": "suspect,", "b": [0.7911, 0.5791, 0.8571, 0.6006]}, {"w": "this", "b": [0.1429, 0.5982, 0.1736, 0.6196]}, {"w": "represents", "b": [0.1799, 0.5982, 0.2655, 0.6196]}, {"w": "a", "b": [0.2719, 0.5982, 0.281, 0.6196]}, {"w": "sequence", "b": [0.2874, 0.5982, 0.3635, 0.6196]}, {"w": "of", "b": [0.3699, 0.5982, 0.3867, 0.6196]}, {"w": "data", "b": [0.393, 0.5982, 0.4283, 0.6196]}, {"w": "items.", "b": [0.4347, 0.5982, 0.4849, 0.6196]}, {"w": "Usually", "b": [0.4913, 0.5982, 0.5535, 0.6196]}, {"w": "you", "b": [0.5598, 0.5982, 0.5911, 0.6196]}, {"w": "will", "b": [0.5974, 0.5982, 0.6278, 0.6196]}, {"w": "use", "b": [0.6342, 0.5982, 0.6618, 0.6196]}, {"w": "datasets", "b": [0.6681, 0.5982, 0.7339, 0.6196]}, {"w": "that", "b": [0.7403, 0.5982, 0.7728, 0.6196]}, {"w": "gradually", "b": [0.7792, 0.5982, 0.8571, 0.6196]}, {"w": "read", "b": [0.1429, 0.6172, 0.1796, 0.6386]}, {"w": "data", "b": [0.1848, 0.6172, 0.2201, 0.6386]}, {"w": "from", "b": [0.2253, 0.6172, 0.2669, 0.6386]}, {"w": "disk,", "b": [0.2721, 0.6172, 0.3114, 0.6386]}, {"w": "but", "b": [0.3166, 0.6172, 0.3446, 0.6386]}, {"w": "for", "b": [0.3498, 0.6172, 0.3743, 0.6386]}, {"w": "simplicity", "b": [0.3795, 0.6172, 0.4615, 0.6386]}, {"w": "let’s", "b": [0.4667, 0.6172, 0.4969, 0.6386]}, {"w": "just", "b": [0.5022, 0.6172, 0.5326, 0.6386]}, {"w": "create", "b": [0.5378, 0.6172, 0.5871, 0.6386]}, {"w": "a", "b": [0.5923, 0.6172, 0.6015, 0.6386]}, {"w": "dataset", "b": [0.6067, 0.6172, 0.6648, 0.6386]}, {"w": "entirely", "b": [0.67, 0.6172, 0.7332, 0.6386]}, {"w": "in", "b": [0.7384, 0.6172, 0.7554, 0.6386]}, {"w": "RAM", "b": [0.7606, 0.6172, 0.8065, 0.6386]}, {"w": "using", "b": [0.8117, 0.6172, 0.8572, 0.6386]}, {"w": "tf.data.Dataset.from_tensor_slices():", "b": [0.1429, 0.6372, 0.5039, 0.6586]}]}, {"id": "b_8", "type": "paragraph", "text": ">>> X = tf.range(10) # any data tensor >>> dataset = tf.data.Dataset.from_tensor_slices(X) >>> dataset ", "words": [{"w": ">>>", "b": [0.1766, 0.6692, 0.2019, 0.682]}, {"w": "X", "b": [0.2103, 0.6692, 0.2188, 0.682]}, {"w": "=", "b": [0.2272, 0.6692, 0.2356, 0.682]}, {"w": "tf.range(10)", "b": [0.244, 0.6692, 0.3452, 0.682]}, {"w": "#", "b": [0.3621, 0.6692, 0.3705, 0.682]}, {"w": "any", "b": [0.379, 0.6692, 0.4043, 0.682]}, {"w": "data", "b": [0.4127, 0.6692, 0.4464, 0.682]}, {"w": "tensor", "b": [0.4549, 0.6692, 0.5055, 0.682]}, {"w": ">>>", "b": [0.1766, 0.6846, 0.2019, 0.6974]}, {"w": "dataset", "b": [0.2103, 0.6846, 0.2693, 0.6974]}, {"w": "=", "b": [0.2778, 0.6846, 0.2862, 0.6974]}, {"w": "tf.data.Dataset.from_tensor_slices(X)", "b": [0.2946, 0.6846, 0.6066, 0.6974]}, {"w": ">>>", "b": [0.1766, 0.7, 0.2019, 0.7128]}, {"w": "dataset", "b": [0.2103, 0.7, 0.2693, 0.7128]}, {"w": "", "b": [0.5055, 0.7154, 0.5813, 0.7283]}]}, {"id": "b_9", "type": "paragraph", "text": "The from_tensor_slices() function takes a tensor and creates a tf.data.Dataset whose elements are all the slices of X (along the first dimension), so this dataset con‐ tains 10 items: tensors 0, 1, 2, …, 9. In this case we would have obtained the same dataset if we had used tf.data.Dataset.range(10).", "words": [{"w": "The", "b": [0.1428, 0.7369, 0.1757, 0.7584]}, {"w": "from_tensor_slices()", "b": [0.1826, 0.7401, 0.3805, 0.7552]}, {"w": "function", "b": [0.3874, 0.7369, 0.4588, 0.7584]}, {"w": "takes", "b": [0.4656, 0.7369, 0.508, 0.7584]}, {"w": "a", "b": [0.5149, 0.7369, 0.524, 0.7584]}, {"w": "tensor", "b": [0.5309, 0.7369, 0.5835, 0.7584]}, {"w": "and", "b": [0.5904, 0.7369, 0.6219, 0.7584]}, {"w": "creates", "b": [0.6288, 0.7369, 0.6858, 0.7584]}, {"w": "a", "b": [0.6927, 0.7369, 0.7018, 0.7584]}, {"w": "tf.data.Dataset", "b": [0.7087, 0.7401, 0.8571, 0.7552]}, {"w": "whose", "b": [0.1429, 0.7569, 0.1954, 0.7783]}, {"w": "elements", "b": [0.2011, 0.7569, 0.275, 0.7783]}, {"w": "are", "b": [0.2807, 0.7569, 0.3065, 0.7783]}, {"w": "all", "b": [0.3122, 0.7569, 0.3319, 0.7783]}, {"w": "the", "b": [0.3376, 0.7569, 0.364, 0.7783]}, {"w": "slices", "b": [0.3697, 0.7569, 0.4135, 0.7783]}, {"w": "of", "b": [0.4192, 0.7569, 0.436, 0.7783]}, {"w": "X", "b": [0.4418, 0.7601, 0.4517, 0.7751]}, {"w": "(along", "b": [0.4574, 0.7569, 0.5108, 0.7783]}, {"w": "the", "b": [0.5165, 0.7569, 0.5428, 0.7783]}, {"w": "first", "b": [0.5486, 0.7569, 0.5821, 0.7783]}, {"w": "dimension),", "b": [0.5878, 0.7569, 0.6889, 0.7783]}, {"w": "so", "b": [0.6946, 0.7569, 0.7129, 0.7783]}, {"w": "this", "b": [0.7186, 0.7569, 0.7493, 0.7783]}, {"w": "dataset", "b": [0.7551, 0.7569, 0.8132, 0.7783]}, {"w": "con‐", "b": [0.8189, 0.7569, 0.8571, 0.7783]}, {"w": "tains", "b": [0.1429, 0.7759, 0.183, 0.7973]}, {"w": "10", "b": [0.19, 0.7759, 0.21, 0.7973]}, {"w": "items:", "b": [0.2171, 0.7759, 0.2673, 0.7973]}, {"w": "tensors", "b": [0.2744, 0.7759, 0.3346, 0.7973]}, {"w": "0,", "b": [0.3416, 0.7759, 0.3564, 0.7973]}, {"w": "1,", "b": [0.3634, 0.7759, 0.3782, 0.7973]}, {"w": "2,", "b": [0.3852, 0.7759, 0.4, 0.7973]}, {"w": "…,", "b": [0.407, 0.7759, 0.432, 0.7973]}, {"w": "9.", "b": [0.439, 0.7759, 0.4538, 0.7973]}, {"w": "In", "b": [0.4608, 0.7759, 0.4793, 0.7973]}, {"w": "this", "b": [0.4864, 0.7759, 0.5171, 0.7973]}, {"w": "case", "b": [0.5241, 0.7759, 0.5586, 0.7973]}, {"w": "we", "b": [0.5656, 0.7759, 0.5887, 0.7973]}, {"w": "would", "b": [0.5958, 0.7759, 0.648, 0.7973]}, {"w": "have", "b": [0.655, 0.7759, 0.6934, 0.7973]}, {"w": "obtained", "b": [0.7005, 0.7759, 0.774, 0.7973]}, {"w": "the", "b": [0.7811, 0.7759, 0.8074, 0.7973]}, {"w": "same", "b": [0.8144, 0.7759, 0.8571, 0.7973]}, {"w": "dataset", "b": [0.1429, 0.7959, 0.201, 0.8173]}, {"w": "if", "b": [0.2057, 0.7959, 0.2174, 0.8173]}, {"w": "we", "b": [0.2222, 0.7959, 0.2453, 0.8173]}, {"w": "had", "b": [0.25, 0.7959, 0.2813, 0.8173]}, {"w": "used", "b": [0.286, 0.7959, 0.3246, 0.8173]}, {"w": "tf.data.Dataset.range(10).", "b": [0.3293, 0.7959, 0.5815, 0.8173]}]}, {"id": "b_10", "type": "paragraph", "text": "You can simply iterate over a dataset’s items like this:", "words": [{"w": "You", "b": [0.1428, 0.824, 0.1752, 0.8454]}, {"w": "can", "b": [0.1799, 0.824, 0.2093, 0.8454]}, {"w": "simply", "b": [0.214, 0.824, 0.2697, 0.8454]}, {"w": "iterate", "b": [0.2744, 0.824, 0.3269, 0.8454]}, {"w": "over", "b": [0.3316, 0.824, 0.3685, 0.8454]}, {"w": "a", "b": [0.3732, 0.824, 0.3823, 0.8454]}, {"w": "dataset’s", "b": [0.3871, 0.824, 0.4549, 0.8454]}, {"w": "items", "b": [0.4596, 0.824, 0.5051, 0.8454]}, {"w": "like", "b": [0.5099, 0.824, 0.5399, 0.8454]}, {"w": "this:", "b": [0.5446, 0.824, 0.5801, 0.8454]}]}, {"id": "b_11", "type": "paragraph", "text": ">>> for item in dataset: ... print(item)", "words": [{"w": ">>>", "b": [0.1766, 0.856, 0.2019, 0.8688]}, {"w": "for", "b": [0.2103, 0.856, 0.2356, 0.8688]}, {"w": "item", "b": [0.244, 0.856, 0.2778, 0.8688]}, {"w": "in", "b": [0.2862, 0.856, 0.3031, 0.8688]}, {"w": "dataset:", "b": [0.3115, 0.856, 0.379, 0.8688]}, {"w": "...", "b": [0.1766, 0.8714, 0.2019, 0.8842]}, {"w": "print(item)", "b": [0.244, 0.8714, 0.3368, 0.8842]}]}, {"id": "b_12", "type": "paragraph", "text": "404 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "404", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 431, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "... tf.Tensor(0, shape=(), dtype=int32) tf.Tensor(1, shape=(), dtype=int32) tf.Tensor(2, shape=(), dtype=int32) [...] tf.Tensor(9, shape=(), dtype=int32)", "words": [{"w": "...", "b": [0.1766, 0.0829, 0.2019, 0.0958]}, {"w": "tf.Tensor(0,", "b": [0.1766, 0.0983, 0.2778, 0.1112]}, {"w": "shape=(),", "b": [0.2862, 0.0983, 0.3621, 0.1112]}, {"w": "dtype=int32)", "b": [0.3705, 0.0983, 0.4717, 0.1112]}, {"w": "tf.Tensor(1,", "b": [0.1766, 0.1138, 0.2778, 0.1266]}, {"w": "shape=(),", "b": [0.2862, 0.1138, 0.3621, 0.1266]}, {"w": "dtype=int32)", "b": [0.3705, 0.1138, 0.4717, 0.1266]}, {"w": "tf.Tensor(2,", "b": [0.1766, 0.1292, 0.2778, 0.142]}, {"w": "shape=(),", "b": [0.2862, 0.1292, 0.3621, 0.142]}, {"w": "dtype=int32)", "b": [0.3705, 0.1292, 0.4717, 0.142]}, {"w": "[...]", "b": [0.1766, 0.1446, 0.2188, 0.1574]}, {"w": "tf.Tensor(9,", "b": [0.1766, 0.16, 0.2778, 0.1729]}, {"w": "shape=(),", "b": [0.2862, 0.16, 0.3621, 0.1729]}, {"w": "dtype=int32)", "b": [0.3705, 0.16, 0.4717, 0.1729]}]}, {"id": "b_1", "type": "paragraph", "text": "Chaining Transformations", "words": [{"w": "Chaining", "b": [0.1429, 0.1867, 0.2342, 0.2153]}, {"w": "Transformations", "b": [0.2391, 0.1867, 0.4088, 0.2153]}]}, {"id": "b_2", "type": "paragraph", "text": "Once you have a dataset, you can apply all sorts of transformations to it by calling its transformation methods. Each method returns a new dataset, so you can chain trans‐ formations like this (this chain is illustrated in Figure 13-1):", "words": [{"w": "Once", "b": [0.1429, 0.2212, 0.1875, 0.2426]}, {"w": "you", "b": [0.1929, 0.2212, 0.2242, 0.2426]}, {"w": "have", "b": [0.2297, 0.2212, 0.2681, 0.2426]}, {"w": "a", "b": [0.2735, 0.2212, 0.2827, 0.2426]}, {"w": "dataset,", "b": [0.2881, 0.2212, 0.351, 0.2426]}, {"w": "you", "b": [0.3564, 0.2212, 0.3877, 0.2426]}, {"w": "can", "b": [0.3932, 0.2212, 0.4225, 0.2426]}, {"w": "apply", "b": [0.428, 0.2212, 0.4734, 0.2426]}, {"w": "all", "b": [0.4789, 0.2212, 0.4985, 0.2426]}, {"w": "sorts", "b": [0.504, 0.2212, 0.544, 0.2426]}, {"w": "of", "b": [0.5495, 0.2212, 0.5663, 0.2426]}, {"w": "transformations", "b": [0.5717, 0.2212, 0.7059, 0.2426]}, {"w": "to", "b": [0.7114, 0.2212, 0.7284, 0.2426]}, {"w": "it", "b": [0.7339, 0.2212, 0.7458, 0.2426]}, {"w": "by", "b": [0.7513, 0.2212, 0.7714, 0.2426]}, {"w": "calling", "b": [0.7769, 0.2212, 0.8321, 0.2426]}, {"w": "its", "b": [0.8376, 0.2212, 0.8571, 0.2426]}, {"w": "transformation", "b": [0.1428, 0.2402, 0.2694, 0.2616]}, {"w": "methods.", "b": [0.2746, 0.2402, 0.352, 0.2616]}, {"w": "Each", "b": [0.3572, 0.2402, 0.3982, 0.2616]}, {"w": "method", "b": [0.4034, 0.2402, 0.4684, 0.2616]}, {"w": "returns", "b": [0.4736, 0.2402, 0.5344, 0.2616]}, {"w": "a", "b": [0.5396, 0.2402, 0.5487, 0.2616]}, {"w": "new", "b": [0.5539, 0.2402, 0.5884, 0.2616]}, {"w": "dataset,", "b": [0.5936, 0.2402, 0.6565, 0.2616]}, {"w": "so", "b": [0.6617, 0.2402, 0.68, 0.2616]}, {"w": "you", "b": [0.6852, 0.2402, 0.7164, 0.2616]}, {"w": "can", "b": [0.7216, 0.2402, 0.751, 0.2616]}, {"w": "chain", "b": [0.7562, 0.2402, 0.8022, 0.2616]}, {"w": "trans‐", "b": [0.8074, 0.2402, 0.8571, 0.2616]}, {"w": "formations", "b": [0.1429, 0.2593, 0.2348, 0.2807]}, {"w": "like", "b": [0.2395, 0.2593, 0.2696, 0.2807]}, {"w": "this", "b": [0.2743, 0.2593, 0.305, 0.2807]}, {"w": "(this", "b": [0.3097, 0.2593, 0.3477, 0.2807]}, {"w": "chain", "b": [0.3524, 0.2593, 0.3984, 0.2807]}, {"w": "is", "b": [0.4032, 0.2593, 0.4164, 0.2807]}, {"w": "illustrated", "b": [0.4211, 0.2593, 0.505, 0.2807]}, {"w": "in", "b": [0.5097, 0.2593, 0.5267, 0.2807]}, {"w": "Figure", "b": [0.5314, 0.2593, 0.5854, 0.2807]}, {"w": "13-1):", "b": [0.5902, 0.2593, 0.6396, 0.2807]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> dataset = dataset.repeat(3).batch(7) >>> for item in dataset: ... print(item) ... tf.Tensor([0 1 2 3 4 5 6], shape=(7,), dtype=int32) tf.Tensor([7 8 9 0 1 2 3], shape=(7,), dtype=int32) tf.Tensor([4 5 6 7 8 9 0], shape=(7,), dtype=int32) tf.Tensor([1 2 3 4 5 6 7], shape=(7,), dtype=int32) tf.Tensor([8 9], shape=(2,), dtype=int32)", "words": [{"w": ">>>", "b": [0.1766, 0.2912, 0.2019, 0.3041]}, {"w": "dataset", "b": [0.2103, 0.2912, 0.2693, 0.3041]}, {"w": "=", "b": [0.2778, 0.2912, 0.2862, 0.3041]}, {"w": "dataset.repeat(3).batch(7)", "b": [0.2946, 0.2912, 0.5139, 0.3041]}, {"w": ">>>", "b": [0.1766, 0.3067, 0.2019, 0.3195]}, {"w": "for", "b": [0.2103, 0.3067, 0.2356, 0.3195]}, {"w": "item", "b": [0.244, 0.3067, 0.2778, 0.3195]}, {"w": "in", "b": [0.2862, 0.3067, 0.3031, 0.3195]}, {"w": "dataset:", "b": [0.3115, 0.3067, 0.379, 0.3195]}, {"w": "...", "b": [0.1766, 0.3221, 0.2019, 0.3349]}, {"w": "print(item)", "b": [0.244, 0.3221, 0.3368, 0.3349]}, {"w": "...", "b": [0.1766, 0.3375, 0.2019, 0.3504]}, {"w": "tf.Tensor([0", "b": [0.1766, 0.3529, 0.2778, 0.3658]}, {"w": "1", "b": [0.2862, 0.3529, 0.2946, 0.3658]}, {"w": "2", "b": [0.3031, 0.3529, 0.3115, 0.3658]}, {"w": "3", "b": [0.3199, 0.3529, 0.3284, 0.3658]}, {"w": "4", "b": [0.3368, 0.3529, 0.3452, 0.3658]}, {"w": "5", "b": [0.3537, 0.3529, 0.3621, 0.3658]}, {"w": "6],", "b": [0.3705, 0.3529, 0.3958, 0.3658]}, {"w": "shape=(7,),", "b": [0.4043, 0.3529, 0.497, 0.3658]}, {"w": "dtype=int32)", "b": [0.5055, 0.3529, 0.6066, 0.3658]}, {"w": "tf.Tensor([7", "b": [0.1766, 0.3683, 0.2778, 0.3812]}, {"w": "8", "b": [0.2862, 0.3683, 0.2946, 0.3812]}, {"w": "9", "b": [0.3031, 0.3683, 0.3115, 0.3812]}, {"w": "0", "b": [0.3199, 0.3683, 0.3284, 0.3812]}, {"w": "1", "b": [0.3368, 0.3683, 0.3452, 0.3812]}, {"w": "2", "b": [0.3537, 0.3683, 0.3621, 0.3812]}, {"w": "3],", "b": [0.3705, 0.3683, 0.3958, 0.3812]}, {"w": "shape=(7,),", "b": [0.4043, 0.3683, 0.497, 0.3812]}, {"w": "dtype=int32)", "b": [0.5055, 0.3683, 0.6066, 0.3812]}, {"w": "tf.Tensor([4", "b": [0.1766, 0.3838, 0.2778, 0.3966]}, {"w": "5", "b": [0.2862, 0.3838, 0.2946, 0.3966]}, {"w": "6", "b": [0.3031, 0.3838, 0.3115, 0.3966]}, {"w": "7", "b": [0.3199, 0.3838, 0.3284, 0.3966]}, {"w": "8", "b": [0.3368, 0.3838, 0.3452, 0.3966]}, {"w": "9", "b": [0.3537, 0.3838, 0.3621, 0.3966]}, {"w": "0],", "b": [0.3705, 0.3838, 0.3958, 0.3966]}, {"w": "shape=(7,),", "b": [0.4043, 0.3838, 0.497, 0.3966]}, {"w": "dtype=int32)", "b": [0.5055, 0.3838, 0.6066, 0.3966]}, {"w": "tf.Tensor([1", "b": [0.1766, 0.3992, 0.2778, 0.412]}, {"w": "2", "b": [0.2862, 0.3992, 0.2946, 0.412]}, {"w": "3", "b": [0.3031, 0.3992, 0.3115, 0.412]}, {"w": "4", "b": [0.3199, 0.3992, 0.3284, 0.412]}, {"w": "5", "b": [0.3368, 0.3992, 0.3452, 0.412]}, {"w": "6", "b": [0.3537, 0.3992, 0.3621, 0.412]}, {"w": "7],", "b": [0.3705, 0.3992, 0.3958, 0.412]}, {"w": "shape=(7,),", "b": [0.4043, 0.3992, 0.497, 0.412]}, {"w": "dtype=int32)", "b": [0.5055, 0.3992, 0.6066, 0.412]}, {"w": "tf.Tensor([8", "b": [0.1766, 0.4146, 0.2778, 0.4275]}, {"w": "9],", "b": [0.2862, 0.4146, 0.3115, 0.4275]}, {"w": "shape=(2,),", "b": [0.3199, 0.4146, 0.4127, 0.4275]}, {"w": "dtype=int32)", "b": [0.4211, 0.4146, 0.5223, 0.4275]}]}, {"id": "b_4", "type": "equation", "text": "Figure 13-1. Chaining Dataset Transformations", "words": [{"w": "Figure", "b": [0.1429, 0.6553, 0.1943, 0.6769]}, {"w": "13-1.", "b": [0.1991, 0.6553, 0.2407, 0.6769]}, {"w": "Chaining", "b": [0.2455, 0.6553, 0.3202, 0.6769]}, {"w": "Dataset", "b": [0.325, 0.6553, 0.3877, 0.6769]}, {"w": "Transformations", "b": [0.3925, 0.6553, 0.5269, 0.6769]}]}, {"id": "b_5", "type": "paragraph", "text": "In this example, we first call the repeat() method on the original dataset, and it returns a new dataset that will repeat the items of the original dataset 3 times. Of course, this will not copy the whole data in memory 3 times! In fact, if you call this method with no arguments, the new dataset will repeat the source dataset forever. Then we call the batch() method on this new dataset, and again this creates a new dataset. This one will group the items of the previous dataset in batches of 7 items. Finally, we iterate over the items of this final dataset. As you can see, the batch() method had to output a final batch of size 2 instead of 7, but you can call it with drop_remainder=True if you want it to drop this final batch so that all batches have the exact same size.", "words": [{"w": "In", "b": [0.1429, 0.6936, 0.1614, 0.715]}, {"w": "this", "b": [0.1696, 0.6936, 0.2003, 0.715]}, {"w": "example,", "b": [0.2086, 0.6936, 0.2828, 0.715]}, {"w": "we", "b": [0.2911, 0.6936, 0.3142, 0.715]}, {"w": "first", "b": [0.3225, 0.6936, 0.3559, 0.715]}, {"w": "call", "b": [0.3642, 0.6936, 0.3927, 0.715]}, {"w": "the", "b": [0.4009, 0.6936, 0.4273, 0.715]}, {"w": "repeat()", "b": [0.4355, 0.6968, 0.5147, 0.7118]}, {"w": "method", "b": [0.5229, 0.6936, 0.5879, 0.715]}, {"w": "on", "b": [0.5962, 0.6936, 0.6182, 0.715]}, {"w": "the", "b": [0.6264, 0.6936, 0.6528, 0.715]}, {"w": "original", "b": [0.661, 0.6936, 0.7261, 0.715]}, {"w": "dataset,", "b": [0.7343, 0.6936, 0.7972, 0.715]}, {"w": "and", "b": [0.8054, 0.6936, 0.837, 0.715]}, {"w": "it", "b": [0.8452, 0.6936, 0.8572, 0.715]}, {"w": "returns", "b": [0.1429, 0.7126, 0.2036, 0.734]}, {"w": "a", "b": [0.2114, 0.7126, 0.2206, 0.734]}, {"w": "new", "b": [0.2284, 0.7126, 0.2629, 0.734]}, {"w": "dataset", "b": [0.2707, 0.7126, 0.3288, 0.734]}, {"w": "that", "b": [0.3366, 0.7126, 0.3692, 0.734]}, {"w": "will", "b": [0.377, 0.7126, 0.4074, 0.734]}, {"w": "repeat", "b": [0.4153, 0.7126, 0.4667, 0.734]}, {"w": "the", "b": [0.4745, 0.7126, 0.5009, 0.734]}, {"w": "items", "b": [0.5087, 0.7126, 0.5542, 0.734]}, {"w": "of", "b": [0.562, 0.7126, 0.5788, 0.734]}, {"w": "the", "b": [0.5866, 0.7126, 0.6129, 0.734]}, {"w": "original", "b": [0.6207, 0.7126, 0.6858, 0.734]}, {"w": "dataset", "b": [0.6936, 0.7126, 0.7517, 0.734]}, {"w": "3", "b": [0.7595, 0.7126, 0.7695, 0.734]}, {"w": "times.", "b": [0.7774, 0.7126, 0.8276, 0.734]}, {"w": "Of", "b": [0.8354, 0.7126, 0.8571, 0.734]}, {"w": "course,", "b": [0.1429, 0.7317, 0.2023, 0.7531]}, {"w": "this", "b": [0.2087, 0.7317, 0.2394, 0.7531]}, {"w": "will", "b": [0.2457, 0.7317, 0.2761, 0.7531]}, {"w": "not", "b": [0.2825, 0.7317, 0.3109, 0.7531]}, {"w": "copy", "b": [0.3172, 0.7317, 0.3571, 0.7531]}, {"w": "the", "b": [0.3635, 0.7317, 0.3898, 0.7531]}, {"w": "whole", "b": [0.3962, 0.7317, 0.4463, 0.7531]}, {"w": "data", "b": [0.4527, 0.7317, 0.4879, 0.7531]}, {"w": "in", "b": [0.4943, 0.7317, 0.5113, 0.7531]}, {"w": "memory", "b": [0.5176, 0.7317, 0.5891, 0.7531]}, {"w": "3", "b": [0.5955, 0.7317, 0.6055, 0.7531]}, {"w": "times!", "b": [0.6118, 0.7317, 0.6631, 0.7531]}, {"w": "In", "b": [0.6694, 0.7317, 0.6879, 0.7531]}, {"w": "fact,", "b": [0.6943, 0.7317, 0.7295, 0.7531]}, {"w": "if", "b": [0.7359, 0.7317, 0.7476, 0.7531]}, {"w": "you", "b": [0.754, 0.7317, 0.7852, 0.7531]}, {"w": "call", "b": [0.7916, 0.7317, 0.8201, 0.7531]}, {"w": "this", "b": [0.8264, 0.7317, 0.8571, 0.7531]}, {"w": "method", "b": [0.1429, 0.7507, 0.2079, 0.7721]}, {"w": "with", "b": [0.2157, 0.7507, 0.253, 0.7721]}, {"w": "no", "b": [0.2608, 0.7507, 0.2828, 0.7721]}, {"w": "arguments,", "b": [0.2906, 0.7507, 0.384, 0.7721]}, {"w": "the", "b": [0.3918, 0.7507, 0.4181, 0.7721]}, {"w": "new", "b": [0.4259, 0.7507, 0.4604, 0.7721]}, {"w": "dataset", "b": [0.4682, 0.7507, 0.5263, 0.7721]}, {"w": "will", "b": [0.5341, 0.7507, 0.5645, 0.7721]}, {"w": "repeat", "b": [0.5723, 0.7507, 0.6238, 0.7721]}, {"w": "the", "b": [0.6316, 0.7507, 0.6579, 0.7721]}, {"w": "source", "b": [0.6657, 0.7507, 0.7204, 0.7721]}, {"w": "dataset", "b": [0.7282, 0.7507, 0.7863, 0.7721]}, {"w": "forever.", "b": [0.7941, 0.7507, 0.8572, 0.7721]}, {"w": "Then", "b": [0.1429, 0.7707, 0.1871, 0.7921]}, {"w": "we", "b": [0.1937, 0.7707, 0.2169, 0.7921]}, {"w": "call", "b": [0.2235, 0.7707, 0.252, 0.7921]}, {"w": "the", "b": [0.2587, 0.7707, 0.285, 0.7921]}, {"w": "batch()", "b": [0.2917, 0.7738, 0.3609, 0.7889]}, {"w": "method", "b": [0.3676, 0.7707, 0.4326, 0.7921]}, {"w": "on", "b": [0.4392, 0.7707, 0.4613, 0.7921]}, {"w": "this", "b": [0.4679, 0.7707, 0.4986, 0.7921]}, {"w": "new", "b": [0.5053, 0.7707, 0.5398, 0.7921]}, {"w": "dataset,", "b": [0.5464, 0.7707, 0.6093, 0.7921]}, {"w": "and", "b": [0.616, 0.7707, 0.6475, 0.7921]}, {"w": "again", "b": [0.6541, 0.7707, 0.6992, 0.7921]}, {"w": "this", "b": [0.7058, 0.7707, 0.7365, 0.7921]}, {"w": "creates", "b": [0.7432, 0.7707, 0.8002, 0.7921]}, {"w": "a", "b": [0.8068, 0.7707, 0.816, 0.7921]}, {"w": "new", "b": [0.8226, 0.7707, 0.8571, 0.7921]}, {"w": "dataset.", "b": [0.1429, 0.7897, 0.2057, 0.8111]}, {"w": "This", "b": [0.2125, 0.7897, 0.2497, 0.8111]}, {"w": "one", "b": [0.2565, 0.7897, 0.2873, 0.8111]}, {"w": "will", "b": [0.2941, 0.7897, 0.3245, 0.8111]}, {"w": "group", "b": [0.3313, 0.7897, 0.3814, 0.8111]}, {"w": "the", "b": [0.3881, 0.7897, 0.4145, 0.8111]}, {"w": "items", "b": [0.4212, 0.7897, 0.4667, 0.8111]}, {"w": "of", "b": [0.4735, 0.7897, 0.4903, 0.8111]}, {"w": "the", "b": [0.4971, 0.7897, 0.5234, 0.8111]}, {"w": "previous", "b": [0.5302, 0.7897, 0.6023, 0.8111]}, {"w": "dataset", "b": [0.609, 0.7897, 0.6671, 0.8111]}, {"w": "in", "b": [0.6739, 0.7897, 0.6909, 0.8111]}, {"w": "batches", "b": [0.6977, 0.7897, 0.7598, 0.8111]}, {"w": "of", "b": [0.7666, 0.7897, 0.7833, 0.8111]}, {"w": "7", "b": [0.7901, 0.7897, 0.8001, 0.8111]}, {"w": "items.", "b": [0.8069, 0.7897, 0.8571, 0.8111]}, {"w": "Finally,", "b": [0.1429, 0.8097, 0.2033, 0.8311]}, {"w": "we", "b": [0.2109, 0.8097, 0.234, 0.8311]}, {"w": "iterate", "b": [0.2416, 0.8097, 0.294, 0.8311]}, {"w": "over", "b": [0.3016, 0.8097, 0.3384, 0.8311]}, {"w": "the", "b": [0.346, 0.8097, 0.3723, 0.8311]}, {"w": "items", "b": [0.3799, 0.8097, 0.4254, 0.8311]}, {"w": "of", "b": [0.4329, 0.8097, 0.4497, 0.8311]}, {"w": "this", "b": [0.4573, 0.8097, 0.488, 0.8311]}, {"w": "final", "b": [0.4955, 0.8097, 0.5331, 0.8311]}, {"w": "dataset.", "b": [0.5406, 0.8097, 0.6035, 0.8311]}, {"w": "As", "b": [0.611, 0.8097, 0.6331, 0.8311]}, {"w": "you", "b": [0.6406, 0.8097, 0.6719, 0.8311]}, {"w": "can", "b": [0.6794, 0.8097, 0.7088, 0.8311]}, {"w": "see,", "b": [0.7163, 0.8097, 0.7464, 0.8311]}, {"w": "the", "b": [0.754, 0.8097, 0.7803, 0.8311]}, {"w": "batch()", "b": [0.7879, 0.8128, 0.8571, 0.8279]}, {"w": "method", "b": [0.1429, 0.8287, 0.2079, 0.8501]}, {"w": "had", "b": [0.2155, 0.8287, 0.2468, 0.8501]}, {"w": "to", "b": [0.2544, 0.8287, 0.2713, 0.8501]}, {"w": "output", "b": [0.2789, 0.8287, 0.3353, 0.8501]}, {"w": "a", "b": [0.3429, 0.8287, 0.3521, 0.8501]}, {"w": "final", "b": [0.3597, 0.8287, 0.3972, 0.8501]}, {"w": "batch", "b": [0.4048, 0.8287, 0.4504, 0.8501]}, {"w": "of", "b": [0.458, 0.8287, 0.4748, 0.8501]}, {"w": "size", "b": [0.4824, 0.8287, 0.5133, 0.8501]}, {"w": "2", "b": [0.5209, 0.8287, 0.5309, 0.8501]}, {"w": "instead", "b": [0.5385, 0.8287, 0.5984, 0.8501]}, {"w": "of", "b": [0.606, 0.8287, 0.6228, 0.8501]}, {"w": "7,", "b": [0.6304, 0.8287, 0.6452, 0.8501]}, {"w": "but", "b": [0.6528, 0.8287, 0.6808, 0.8501]}, {"w": "you", "b": [0.6884, 0.8287, 0.7196, 0.8501]}, {"w": "can", "b": [0.7272, 0.8287, 0.7566, 0.8501]}, {"w": "call", "b": [0.7642, 0.8287, 0.7927, 0.8501]}, {"w": "it", "b": [0.8003, 0.8287, 0.8122, 0.8501]}, {"w": "with", "b": [0.8198, 0.8287, 0.8571, 0.8501]}, {"w": "drop_remainder=True", "b": [0.1428, 0.8518, 0.3309, 0.8669]}, {"w": "if", "b": [0.3372, 0.8486, 0.3489, 0.8701]}, {"w": "you", "b": [0.3552, 0.8486, 0.3865, 0.8701]}, {"w": "want", "b": [0.3928, 0.8486, 0.4336, 0.8701]}, {"w": "it", "b": [0.4399, 0.8486, 0.4518, 0.8701]}, {"w": "to", "b": [0.4581, 0.8486, 0.4751, 0.8701]}, {"w": "drop", "b": [0.4814, 0.8486, 0.5217, 0.8701]}, {"w": "this", "b": [0.528, 0.8486, 0.5587, 0.8701]}, {"w": "final", "b": [0.565, 0.8486, 0.6026, 0.8701]}, {"w": "batch", "b": [0.6089, 0.8486, 0.6545, 0.8701]}, {"w": "so", "b": [0.6608, 0.8486, 0.6791, 0.8701]}, {"w": "that", "b": [0.6854, 0.8486, 0.718, 0.8701]}, {"w": "all", "b": [0.7243, 0.8486, 0.744, 0.8701]}, {"w": "batches", "b": [0.7503, 0.8486, 0.8124, 0.8701]}, {"w": "have", "b": [0.8187, 0.8486, 0.8571, 0.8701]}, {"w": "the", "b": [0.1429, 0.8677, 0.1692, 0.8891]}, {"w": "exact", "b": [0.1739, 0.8677, 0.2169, 0.8891]}, {"w": "same", "b": [0.2217, 0.8677, 0.2644, 0.8891]}, {"w": "size.", "b": [0.2691, 0.8677, 0.3047, 0.8891]}]}, {"id": "b_6", "type": "paragraph", "text": "The Data API | 405", "words": [{"w": "The", "b": [0.7213, 0.9225, 0.7428, 0.9388]}, {"w": "Data", "b": [0.7456, 0.9225, 0.7733, 0.9388]}, {"w": "API", "b": [0.7761, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "405", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 432, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "The dataset methods do not modify datasets, they create new ones, so make sure to keep a reference to these new datasets (e.g., data set = ...), or else nothing will happen.", "words": [{"w": "The", "b": [0.2714, 0.0793, 0.3014, 0.0989]}, {"w": "dataset", "b": [0.3066, 0.0793, 0.3597, 0.0989]}, {"w": "methods", "b": [0.3649, 0.0793, 0.4313, 0.0989]}, {"w": "do", "b": [0.4365, 0.0793, 0.4563, 0.0989]}, {"w": "not", "b": [0.4614, 0.0791, 0.486, 0.0989]}, {"w": "modify", "b": [0.4912, 0.0793, 0.5464, 0.0989]}, {"w": "datasets,", "b": [0.5515, 0.0793, 0.616, 0.0989]}, {"w": "they", "b": [0.6211, 0.0793, 0.654, 0.0989]}, {"w": "create", "b": [0.6591, 0.0793, 0.7043, 0.0989]}, {"w": "new", "b": [0.7094, 0.0793, 0.741, 0.0989]}, {"w": "ones,", "b": [0.7462, 0.0793, 0.7857, 0.0989]}, {"w": "so", "b": [0.2714, 0.0975, 0.2881, 0.1171]}, {"w": "make", "b": [0.2942, 0.0975, 0.3357, 0.1171]}, {"w": "sure", "b": [0.3418, 0.0975, 0.374, 0.1171]}, {"w": "to", "b": [0.3801, 0.0975, 0.3956, 0.1171]}, {"w": "keep", "b": [0.4017, 0.0975, 0.4373, 0.1171]}, {"w": "a", "b": [0.4434, 0.0975, 0.4517, 0.1171]}, {"w": "reference", "b": [0.4578, 0.0975, 0.5284, 0.1171]}, {"w": "to", "b": [0.5345, 0.0975, 0.55, 0.1171]}, {"w": "these", "b": [0.5561, 0.0975, 0.5953, 0.1171]}, {"w": "new", "b": [0.6013, 0.0975, 0.6329, 0.1171]}, {"w": "datasets", "b": [0.639, 0.0975, 0.6991, 0.1171]}, {"w": "(e.g.,", "b": [0.7052, 0.0975, 0.7418, 0.1171]}, {"w": "data", "b": [0.7479, 0.1004, 0.7841, 0.1142]}, {"w": "set", "b": [0.2714, 0.1187, 0.2986, 0.1324]}, {"w": "=", "b": [0.3076, 0.1187, 0.3167, 0.1324]}, {"w": "...),", "b": [0.3257, 0.1158, 0.3638, 0.1353]}, {"w": "or", "b": [0.3681, 0.1158, 0.3849, 0.1353]}, {"w": "else", "b": [0.3892, 0.1158, 0.4172, 0.1353]}, {"w": "nothing", "b": [0.4215, 0.1158, 0.4821, 0.1353]}, {"w": "will", "b": [0.4864, 0.1158, 0.5142, 0.1353]}, {"w": "happen.", "b": [0.5185, 0.1158, 0.5795, 0.1353]}]}, {"id": "b_1", "type": "paragraph", "text": "You can also apply any transformation you want to the items by calling the map() method. For example, this creates a new dataset with all items doubled:", "words": [{"w": "You", "b": [0.1429, 0.1788, 0.1752, 0.2002]}, {"w": "can", "b": [0.1828, 0.1788, 0.2122, 0.2002]}, {"w": "also", "b": [0.2198, 0.1788, 0.2524, 0.2002]}, {"w": "apply", "b": [0.26, 0.1788, 0.3054, 0.2002]}, {"w": "any", "b": [0.313, 0.1788, 0.3427, 0.2002]}, {"w": "transformation", "b": [0.3503, 0.1788, 0.4768, 0.2002]}, {"w": "you", "b": [0.4844, 0.1788, 0.5157, 0.2002]}, {"w": "want", "b": [0.5232, 0.1788, 0.564, 0.2002]}, {"w": "to", "b": [0.5716, 0.1788, 0.5886, 0.2002]}, {"w": "the", "b": [0.5962, 0.1788, 0.6225, 0.2002]}, {"w": "items", "b": [0.6301, 0.1788, 0.6756, 0.2002]}, {"w": "by", "b": [0.6832, 0.1788, 0.7033, 0.2002]}, {"w": "calling", "b": [0.7109, 0.1788, 0.7662, 0.2002]}, {"w": "the", "b": [0.7737, 0.1788, 0.8001, 0.2002]}, {"w": "map()", "b": [0.8077, 0.182, 0.8571, 0.1971]}, {"w": "method.", "b": [0.1429, 0.1979, 0.2126, 0.2193]}, {"w": "For", "b": [0.2174, 0.1979, 0.2463, 0.2193]}, {"w": "example,", "b": [0.2511, 0.1979, 0.3254, 0.2193]}, {"w": "this", "b": [0.3301, 0.1979, 0.3608, 0.2193]}, {"w": "creates", "b": [0.3655, 0.1979, 0.4225, 0.2193]}, {"w": "a", "b": [0.4273, 0.1979, 0.4364, 0.2193]}, {"w": "new", "b": [0.4411, 0.1979, 0.4757, 0.2193]}, {"w": "dataset", "b": [0.4804, 0.1979, 0.5385, 0.2193]}, {"w": "with", "b": [0.5432, 0.1979, 0.5805, 0.2193]}, {"w": "all", "b": [0.5853, 0.1979, 0.605, 0.2193]}, {"w": "items", "b": [0.6097, 0.1979, 0.6552, 0.2193]}, {"w": "doubled:", "b": [0.6599, 0.1979, 0.7331, 0.2193]}]}, {"id": "b_2", "type": "equation", "text": ">>> dataset = dataset.map(lambda x: x * 2) # Items: [0,2,4,6,8,10,12]", "words": [{"w": ">>>", "b": [0.1766, 0.2298, 0.2019, 0.2427]}, {"w": "dataset", "b": [0.2103, 0.2298, 0.2693, 0.2427]}, {"w": "=", "b": [0.2778, 0.2298, 0.2862, 0.2427]}, {"w": "dataset.map(lambda", "b": [0.2946, 0.2298, 0.4464, 0.2427]}, {"w": "x:", "b": [0.4549, 0.2298, 0.4717, 0.2427]}, {"w": "x", "b": [0.4802, 0.2298, 0.4886, 0.2427]}, {"w": "*", "b": [0.497, 0.2298, 0.5055, 0.2427]}, {"w": "2)", "b": [0.5139, 0.2298, 0.5308, 0.2427]}, {"w": "#", "b": [0.5392, 0.2298, 0.5476, 0.2427]}, {"w": "Items:", "b": [0.5561, 0.2298, 0.6066, 0.2427]}, {"w": "[0,2,4,6,8,10,12]", "b": [0.6151, 0.2298, 0.7584, 0.2427]}]}, {"id": "b_3", "type": "paragraph", "text": "This function is the one you will call to apply any preprocessing you want to your data. Sometimes, this will include computations that can be quite intensive, such as reshaping or rotating an image, so you will usually want to spawn multiple threads to speed things up: it’s as simple as setting the num_parallel_calls argument.", "words": [{"w": "This", "b": [0.1428, 0.2505, 0.1801, 0.2719]}, {"w": "function", "b": [0.1873, 0.2505, 0.2587, 0.2719]}, {"w": "is", "b": [0.2659, 0.2505, 0.2792, 0.2719]}, {"w": "the", "b": [0.2864, 0.2505, 0.3127, 0.2719]}, {"w": "one", "b": [0.32, 0.2505, 0.3509, 0.2719]}, {"w": "you", "b": [0.3581, 0.2505, 0.3894, 0.2719]}, {"w": "will", "b": [0.3966, 0.2505, 0.427, 0.2719]}, {"w": "call", "b": [0.4342, 0.2505, 0.4627, 0.2719]}, {"w": "to", "b": [0.47, 0.2505, 0.487, 0.2719]}, {"w": "apply", "b": [0.4942, 0.2505, 0.5396, 0.2719]}, {"w": "any", "b": [0.5469, 0.2505, 0.5765, 0.2719]}, {"w": "preprocessing", "b": [0.5837, 0.2505, 0.7002, 0.2719]}, {"w": "you", "b": [0.7074, 0.2505, 0.7387, 0.2719]}, {"w": "want", "b": [0.7459, 0.2505, 0.7867, 0.2719]}, {"w": "to", "b": [0.7939, 0.2505, 0.8109, 0.2719]}, {"w": "your", "b": [0.8182, 0.2505, 0.8571, 0.2719]}, {"w": "data.", "b": [0.1429, 0.2695, 0.1829, 0.2909]}, {"w": "Sometimes,", "b": [0.1896, 0.2695, 0.2863, 0.2909]}, {"w": "this", "b": [0.293, 0.2695, 0.3237, 0.2909]}, {"w": "will", "b": [0.3304, 0.2695, 0.3608, 0.2909]}, {"w": "include", "b": [0.3676, 0.2695, 0.4295, 0.2909]}, {"w": "computations", "b": [0.4363, 0.2695, 0.5511, 0.2909]}, {"w": "that", "b": [0.5578, 0.2695, 0.5904, 0.2909]}, {"w": "can", "b": [0.5971, 0.2695, 0.6265, 0.2909]}, {"w": "be", "b": [0.6332, 0.2695, 0.6526, 0.2909]}, {"w": "quite", "b": [0.6594, 0.2695, 0.7019, 0.2909]}, {"w": "intensive,", "b": [0.7086, 0.2695, 0.7883, 0.2909]}, {"w": "such", "b": [0.795, 0.2695, 0.8336, 0.2909]}, {"w": "as", "b": [0.8404, 0.2695, 0.8571, 0.2909]}, {"w": "reshaping", "b": [0.1429, 0.2886, 0.2246, 0.31]}, {"w": "or", "b": [0.2299, 0.2886, 0.2482, 0.31]}, {"w": "rotating", "b": [0.2535, 0.2886, 0.32, 0.31]}, {"w": "an", "b": [0.3252, 0.2886, 0.3458, 0.31]}, {"w": "image,", "b": [0.351, 0.2886, 0.4062, 0.31]}, {"w": "so", "b": [0.4114, 0.2886, 0.4297, 0.31]}, {"w": "you", "b": [0.4349, 0.2886, 0.4662, 0.31]}, {"w": "will", "b": [0.4714, 0.2886, 0.5018, 0.31]}, {"w": "usually", "b": [0.5071, 0.2886, 0.5661, 0.31]}, {"w": "want", "b": [0.5713, 0.2886, 0.6121, 0.31]}, {"w": "to", "b": [0.6174, 0.2886, 0.6343, 0.31]}, {"w": "spawn", "b": [0.6396, 0.2886, 0.6926, 0.31]}, {"w": "multiple", "b": [0.6978, 0.2886, 0.7678, 0.31]}, {"w": "threads", "b": [0.7731, 0.2886, 0.8349, 0.31]}, {"w": "to", "b": [0.8402, 0.2886, 0.8571, 0.31]}, {"w": "speed", "b": [0.1429, 0.3085, 0.1901, 0.3299]}, {"w": "things", "b": [0.1949, 0.3085, 0.2467, 0.3299]}, {"w": "up:", "b": [0.2514, 0.3085, 0.2782, 0.3299]}, {"w": "it’s", "b": [0.2829, 0.3085, 0.3046, 0.3299]}, {"w": "as", "b": [0.3093, 0.3085, 0.3261, 0.3299]}, {"w": "simple", "b": [0.3308, 0.3085, 0.3858, 0.3299]}, {"w": "as", "b": [0.3905, 0.3085, 0.4073, 0.3299]}, {"w": "setting", "b": [0.412, 0.3085, 0.468, 0.3299]}, {"w": "the", "b": [0.4727, 0.3085, 0.499, 0.3299]}, {"w": "num_parallel_calls", "b": [0.5037, 0.3117, 0.6819, 0.3268]}, {"w": "argument.", "b": [0.6866, 0.3085, 0.7723, 0.3299]}]}, {"id": "b_4", "type": "paragraph", "text": "While the map() applies a transformation to each item, the apply() method applies a transformation to the dataset as a whole. For example, the following code “unbatches” the dataset, by applying the unbatch() function to the dataset (this function is cur‐ rently experimental, but it will most likely move to the core API in a future release). Each item in the new dataset will be a single integer tensor instead of a batch of 7 integers:", "words": [{"w": "While", "b": [0.1429, 0.3375, 0.1939, 0.3589]}, {"w": "the", "b": [0.1992, 0.3375, 0.2255, 0.3589]}, {"w": "map()", "b": [0.2308, 0.3407, 0.2803, 0.3558]}, {"w": "applies", "b": [0.2855, 0.3375, 0.3435, 0.3589]}, {"w": "a", "b": [0.3488, 0.3375, 0.3579, 0.3589]}, {"w": "transformation", "b": [0.3632, 0.3375, 0.4897, 0.3589]}, {"w": "to", "b": [0.495, 0.3375, 0.512, 0.3589]}, {"w": "each", "b": [0.5173, 0.3375, 0.5552, 0.3589]}, {"w": "item,", "b": [0.5605, 0.3375, 0.6031, 0.3589]}, {"w": "the", "b": [0.6083, 0.3375, 0.6347, 0.3589]}, {"w": "apply()", "b": [0.6399, 0.3407, 0.7092, 0.3558]}, {"w": "method", "b": [0.7145, 0.3375, 0.7795, 0.3589]}, {"w": "applies", "b": [0.7848, 0.3375, 0.8427, 0.3589]}, {"w": "a", "b": [0.848, 0.3375, 0.8571, 0.3589]}, {"w": "transformation", "b": [0.1429, 0.3566, 0.2694, 0.378]}, {"w": "to", "b": [0.2743, 0.3566, 0.2912, 0.378]}, {"w": "the", "b": [0.2961, 0.3566, 0.3224, 0.378]}, {"w": "dataset", "b": [0.3272, 0.3566, 0.3853, 0.378]}, {"w": "as", "b": [0.3902, 0.3566, 0.407, 0.378]}, {"w": "a", "b": [0.4118, 0.3566, 0.4209, 0.378]}, {"w": "whole.", "b": [0.4258, 0.3566, 0.4807, 0.378]}, {"w": "For", "b": [0.4855, 0.3566, 0.5145, 0.378]}, {"w": "example,", "b": [0.5193, 0.3566, 0.5936, 0.378]}, {"w": "the", "b": [0.5984, 0.3566, 0.6248, 0.378]}, {"w": "following", "b": [0.6296, 0.3566, 0.7086, 0.378]}, {"w": "code", "b": [0.7134, 0.3566, 0.7527, 0.378]}, {"w": "“unbatches”", "b": [0.7575, 0.3566, 0.8572, 0.378]}, {"w": "the", "b": [0.1429, 0.3765, 0.1692, 0.3979]}, {"w": "dataset,", "b": [0.1759, 0.3765, 0.2387, 0.3979]}, {"w": "by", "b": [0.2454, 0.3765, 0.2656, 0.3979]}, {"w": "applying", "b": [0.2723, 0.3765, 0.3444, 0.3979]}, {"w": "the", "b": [0.3511, 0.3765, 0.3775, 0.3979]}, {"w": "unbatch()", "b": [0.3841, 0.3797, 0.4732, 0.3948]}, {"w": "function", "b": [0.4799, 0.3765, 0.5513, 0.3979]}, {"w": "to", "b": [0.558, 0.3765, 0.575, 0.3979]}, {"w": "the", "b": [0.5817, 0.3765, 0.608, 0.3979]}, {"w": "dataset", "b": [0.6147, 0.3765, 0.6728, 0.3979]}, {"w": "(this", "b": [0.6795, 0.3765, 0.7174, 0.3979]}, {"w": "function", "b": [0.7241, 0.3765, 0.7955, 0.3979]}, {"w": "is", "b": [0.8022, 0.3765, 0.8154, 0.3979]}, {"w": "cur‐", "b": [0.8221, 0.3765, 0.8571, 0.3979]}, {"w": "rently", "b": [0.1429, 0.3956, 0.1916, 0.417]}, {"w": "experimental,", "b": [0.1976, 0.3956, 0.3118, 0.417]}, {"w": "but", "b": [0.3178, 0.3956, 0.3458, 0.417]}, {"w": "it", "b": [0.3518, 0.3956, 0.3638, 0.417]}, {"w": "will", "b": [0.3698, 0.3956, 0.4002, 0.417]}, {"w": "most", "b": [0.4062, 0.3956, 0.4479, 0.417]}, {"w": "likely", "b": [0.4539, 0.3956, 0.4987, 0.417]}, {"w": "move", "b": [0.5047, 0.3956, 0.5509, 0.417]}, {"w": "to", "b": [0.5569, 0.3956, 0.5739, 0.417]}, {"w": "the", "b": [0.5799, 0.3956, 0.6062, 0.417]}, {"w": "core", "b": [0.6122, 0.3956, 0.6482, 0.417]}, {"w": "API", "b": [0.6542, 0.3956, 0.6875, 0.417]}, {"w": "in", "b": [0.6935, 0.3956, 0.7105, 0.417]}, {"w": "a", "b": [0.7165, 0.3956, 0.7256, 0.417]}, {"w": "future", "b": [0.7316, 0.3956, 0.7828, 0.417]}, {"w": "release).", "b": [0.7888, 0.3956, 0.8571, 0.417]}, {"w": "Each", "b": [0.1428, 0.4146, 0.1838, 0.436]}, {"w": "item", "b": [0.191, 0.4146, 0.2289, 0.436]}, {"w": "in", "b": [0.2361, 0.4146, 0.2531, 0.436]}, {"w": "the", "b": [0.2603, 0.4146, 0.2866, 0.436]}, {"w": "new", "b": [0.2939, 0.4146, 0.3284, 0.436]}, {"w": "dataset", "b": [0.3356, 0.4146, 0.3937, 0.436]}, {"w": "will", "b": [0.401, 0.4146, 0.4314, 0.436]}, {"w": "be", "b": [0.4386, 0.4146, 0.4581, 0.436]}, {"w": "a", "b": [0.4653, 0.4146, 0.4744, 0.436]}, {"w": "single", "b": [0.4817, 0.4146, 0.5302, 0.436]}, {"w": "integer", "b": [0.5374, 0.4146, 0.5955, 0.436]}, {"w": "tensor", "b": [0.6028, 0.4146, 0.6554, 0.436]}, {"w": "instead", "b": [0.6626, 0.4146, 0.7226, 0.436]}, {"w": "of", "b": [0.7298, 0.4146, 0.7466, 0.436]}, {"w": "a", "b": [0.7539, 0.4146, 0.763, 0.436]}, {"w": "batch", "b": [0.7702, 0.4146, 0.8159, 0.436]}, {"w": "of", "b": [0.8231, 0.4146, 0.8399, 0.436]}, {"w": "7", "b": [0.8471, 0.4146, 0.8571, 0.436]}, {"w": "integers:", "b": [0.1429, 0.4337, 0.2134, 0.4551]}]}, {"id": "b_5", "type": "equation", "text": ">>> dataset = dataset.apply(tf.data.experimental.unbatch()) # Items: 0,2,4,...", "words": [{"w": ">>>", "b": [0.1766, 0.4656, 0.2019, 0.4785]}, {"w": "dataset", "b": [0.2103, 0.4656, 0.2693, 0.4785]}, {"w": "=", "b": [0.2778, 0.4656, 0.2862, 0.4785]}, {"w": "dataset.apply(tf.data.experimental.unbatch())", "b": [0.2946, 0.4656, 0.6741, 0.4785]}, {"w": "#", "b": [0.6825, 0.4656, 0.691, 0.4785]}, {"w": "Items:", "b": [0.6994, 0.4656, 0.75, 0.4785]}, {"w": "0,2,4,...", "b": [0.7584, 0.4656, 0.8343, 0.4785]}]}, {"id": "b_6", "type": "paragraph", "text": "It is also possible to simply filter the dataset using the filter() method:", "words": [{"w": "It", "b": [0.1429, 0.4872, 0.1555, 0.5086]}, {"w": "is", "b": [0.1602, 0.4872, 0.1735, 0.5086]}, {"w": "also", "b": [0.1782, 0.4872, 0.2109, 0.5086]}, {"w": "possible", "b": [0.2156, 0.4872, 0.2827, 0.5086]}, {"w": "to", "b": [0.2875, 0.4872, 0.3044, 0.5086]}, {"w": "simply", "b": [0.3092, 0.4872, 0.3648, 0.5086]}, {"w": "filter", "b": [0.3696, 0.4872, 0.4095, 0.5086]}, {"w": "the", "b": [0.4142, 0.4872, 0.4406, 0.5086]}, {"w": "dataset", "b": [0.4453, 0.4872, 0.5034, 0.5086]}, {"w": "using", "b": [0.5081, 0.4872, 0.5536, 0.5086]}, {"w": "the", "b": [0.5583, 0.4872, 0.5846, 0.5086]}, {"w": "filter()", "b": [0.5894, 0.4904, 0.6685, 0.5054]}, {"w": "method:", "b": [0.6733, 0.4872, 0.743, 0.5086]}]}, {"id": "b_7", "type": "equation", "text": ">>> dataset = dataset.filter(lambda x: x < 10) # Items: 0 2 4 6 8 0 2 4 6...", "words": [{"w": ">>>", "b": [0.1766, 0.5191, 0.2019, 0.532]}, {"w": "dataset", "b": [0.2103, 0.5191, 0.2693, 0.532]}, {"w": "=", "b": [0.2778, 0.5191, 0.2862, 0.532]}, {"w": "dataset.filter(lambda", "b": [0.2946, 0.5191, 0.4717, 0.532]}, {"w": "x:", "b": [0.4802, 0.5191, 0.497, 0.532]}, {"w": "x", "b": [0.5055, 0.5191, 0.5139, 0.532]}, {"w": "<", "b": [0.5223, 0.5191, 0.5308, 0.532]}, {"w": "10)", "b": [0.5392, 0.5191, 0.5645, 0.532]}, {"w": "#", "b": [0.5729, 0.5191, 0.5813, 0.532]}, {"w": "Items:", "b": [0.5898, 0.5191, 0.6404, 0.532]}, {"w": "0", "b": [0.6488, 0.5191, 0.6572, 0.532]}, {"w": "2", "b": [0.6657, 0.5191, 0.6741, 0.532]}, {"w": "4", "b": [0.6825, 0.5191, 0.691, 0.532]}, {"w": "6", "b": [0.6994, 0.5191, 0.7078, 0.532]}, {"w": "8", "b": [0.7163, 0.5191, 0.7247, 0.532]}, {"w": "0", "b": [0.7331, 0.5191, 0.7416, 0.532]}, {"w": "2", "b": [0.75, 0.5191, 0.7584, 0.532]}, {"w": "4", "b": [0.7669, 0.5191, 0.7753, 0.532]}, {"w": "6...", "b": [0.7837, 0.5191, 0.8175, 0.532]}]}, {"id": "b_8", "type": "paragraph", "text": "You will often want to look at just a few items from a dataset. You can use the take() method for that:", "words": [{"w": "You", "b": [0.1429, 0.5407, 0.1752, 0.5621]}, {"w": "will", "b": [0.1805, 0.5407, 0.2109, 0.5621]}, {"w": "often", "b": [0.2162, 0.5407, 0.2596, 0.5621]}, {"w": "want", "b": [0.2649, 0.5407, 0.3057, 0.5621]}, {"w": "to", "b": [0.311, 0.5407, 0.328, 0.5621]}, {"w": "look", "b": [0.3333, 0.5407, 0.3701, 0.5621]}, {"w": "at", "b": [0.3755, 0.5407, 0.3906, 0.5621]}, {"w": "just", "b": [0.3959, 0.5407, 0.4263, 0.5621]}, {"w": "a", "b": [0.4316, 0.5407, 0.4407, 0.5621]}, {"w": "few", "b": [0.446, 0.5407, 0.4753, 0.5621]}, {"w": "items", "b": [0.4806, 0.5407, 0.5261, 0.5621]}, {"w": "from", "b": [0.5314, 0.5407, 0.573, 0.5621]}, {"w": "a", "b": [0.5783, 0.5407, 0.5875, 0.5621]}, {"w": "dataset.", "b": [0.5928, 0.5407, 0.6556, 0.5621]}, {"w": "You", "b": [0.6609, 0.5407, 0.6933, 0.5621]}, {"w": "can", "b": [0.6986, 0.5407, 0.7279, 0.5621]}, {"w": "use", "b": [0.7333, 0.5407, 0.7608, 0.5621]}, {"w": "the", "b": [0.7661, 0.5407, 0.7925, 0.5621]}, {"w": "take()", "b": [0.7978, 0.5439, 0.8571, 0.5589]}, {"w": "method", "b": [0.1428, 0.5597, 0.2079, 0.5811]}, {"w": "for", "b": [0.2126, 0.5597, 0.2371, 0.5811]}, {"w": "that:", "b": [0.2418, 0.5597, 0.2792, 0.5811]}]}, {"id": "b_9", "type": "paragraph", "text": ">>> for item in dataset.take(3): ... print(item) ... tf.Tensor(0, shape=(), dtype=int64) tf.Tensor(2, shape=(), dtype=int64) tf.Tensor(4, shape=(), dtype=int64)", "words": [{"w": ">>>", "b": [0.1766, 0.5917, 0.2019, 0.6045]}, {"w": "for", "b": [0.2103, 0.5917, 0.2356, 0.6045]}, {"w": "item", "b": [0.2441, 0.5917, 0.2778, 0.6045]}, {"w": "in", "b": [0.2862, 0.5917, 0.3031, 0.6045]}, {"w": "dataset.take(3):", "b": [0.3115, 0.5917, 0.4464, 0.6045]}, {"w": "...", "b": [0.1766, 0.6071, 0.2019, 0.62]}, {"w": "print(item)", "b": [0.2441, 0.6071, 0.3368, 0.62]}, {"w": "...", "b": [0.1766, 0.6225, 0.2019, 0.6354]}, {"w": "tf.Tensor(0,", "b": [0.1766, 0.638, 0.2778, 0.6508]}, {"w": "shape=(),", "b": [0.2862, 0.638, 0.3621, 0.6508]}, {"w": "dtype=int64)", "b": [0.3705, 0.638, 0.4717, 0.6508]}, {"w": "tf.Tensor(2,", "b": [0.1766, 0.6534, 0.2778, 0.6662]}, {"w": "shape=(),", "b": [0.2862, 0.6534, 0.3621, 0.6662]}, {"w": "dtype=int64)", "b": [0.3705, 0.6534, 0.4717, 0.6662]}, {"w": "tf.Tensor(4,", "b": [0.1766, 0.6688, 0.2778, 0.6816]}, {"w": "shape=(),", "b": [0.2862, 0.6688, 0.3621, 0.6816]}, {"w": "dtype=int64)", "b": [0.3705, 0.6688, 0.4717, 0.6816]}]}, {"id": "b_10", "type": "paragraph", "text": "Shuffling the Data", "words": [{"w": "Shuffling", "b": [0.1428, 0.6955, 0.2369, 0.7241]}, {"w": "the", "b": [0.2418, 0.6955, 0.2767, 0.7241]}, {"w": "Data", "b": [0.2816, 0.6955, 0.33, 0.7241]}]}, {"id": "b_11", "type": "paragraph", "text": "As you know, Gradient Descent works best when the instances in the training set are independent and identically distributed (see Chapter 4). A simple way to ensure this is to shuffle the instances. For this, you can just use the shuffle() method. It will create a new dataset that will start by filling up a buffer with the first items of the source dataset, then whenever it is asked for an item, it will pull one out randomly from the buffer, and replace it with a fresh one from the source dataset, until it has iterated entirely through the source dataset. At this point it continues to pull out items randomly from the buffer until it is empty. You must specify the buffer size, and", "words": [{"w": "As", "b": [0.1429, 0.73, 0.1649, 0.7514]}, {"w": "you", "b": [0.1705, 0.73, 0.2017, 0.7514]}, {"w": "know,", "b": [0.2073, 0.73, 0.2572, 0.7514]}, {"w": "Gradient", "b": [0.2627, 0.73, 0.3373, 0.7514]}, {"w": "Descent", "b": [0.3429, 0.73, 0.4097, 0.7514]}, {"w": "works", "b": [0.4153, 0.73, 0.4659, 0.7514]}, {"w": "best", "b": [0.4715, 0.73, 0.5049, 0.7514]}, {"w": "when", "b": [0.5105, 0.73, 0.5561, 0.7514]}, {"w": "the", "b": [0.5617, 0.73, 0.588, 0.7514]}, {"w": "instances", "b": [0.5936, 0.73, 0.6704, 0.7514]}, {"w": "in", "b": [0.676, 0.73, 0.693, 0.7514]}, {"w": "the", "b": [0.6986, 0.73, 0.7249, 0.7514]}, {"w": "training", "b": [0.7305, 0.73, 0.7974, 0.7514]}, {"w": "set", "b": [0.803, 0.73, 0.8258, 0.7514]}, {"w": "are", "b": [0.8314, 0.73, 0.8571, 0.7514]}, {"w": "independent", "b": [0.1429, 0.749, 0.2481, 0.7704]}, {"w": "and", "b": [0.2541, 0.749, 0.2856, 0.7704]}, {"w": "identically", "b": [0.2916, 0.749, 0.3781, 0.7704]}, {"w": "distributed", "b": [0.3841, 0.749, 0.4758, 0.7704]}, {"w": "(see", "b": [0.4818, 0.749, 0.5144, 0.7704]}, {"w": "Chapter", "b": [0.5204, 0.749, 0.588, 0.7704]}, {"w": "4).", "b": [0.594, 0.749, 0.6159, 0.7704]}, {"w": "A", "b": [0.6219, 0.749, 0.6363, 0.7704]}, {"w": "simple", "b": [0.6423, 0.749, 0.6973, 0.7704]}, {"w": "way", "b": [0.7033, 0.749, 0.7359, 0.7704]}, {"w": "to", "b": [0.7419, 0.749, 0.7589, 0.7704]}, {"w": "ensure", "b": [0.7649, 0.749, 0.8204, 0.7704]}, {"w": "this", "b": [0.8264, 0.749, 0.8571, 0.7704]}, {"w": "is", "b": [0.1429, 0.769, 0.1561, 0.7904]}, {"w": "to", "b": [0.1634, 0.769, 0.1803, 0.7904]}, {"w": "shuffle", "b": [0.1876, 0.769, 0.2435, 0.7904]}, {"w": "the", "b": [0.2508, 0.769, 0.2771, 0.7904]}, {"w": "instances.", "b": [0.2844, 0.769, 0.366, 0.7904]}, {"w": "For", "b": [0.3732, 0.769, 0.4022, 0.7904]}, {"w": "this,", "b": [0.4095, 0.769, 0.4449, 0.7904]}, {"w": "you", "b": [0.4522, 0.769, 0.4835, 0.7904]}, {"w": "can", "b": [0.4907, 0.769, 0.5201, 0.7904]}, {"w": "just", "b": [0.5273, 0.769, 0.5577, 0.7904]}, {"w": "use", "b": [0.565, 0.769, 0.5926, 0.7904]}, {"w": "the", "b": [0.5998, 0.769, 0.6262, 0.7904]}, {"w": "shuffle()", "b": [0.6335, 0.7721, 0.7225, 0.7872]}, {"w": "method.", "b": [0.7298, 0.769, 0.7996, 0.7904]}, {"w": "It", "b": [0.8068, 0.769, 0.8195, 0.7904]}, {"w": "will", "b": [0.8267, 0.769, 0.8571, 0.7904]}, {"w": "create", "b": [0.1429, 0.788, 0.1922, 0.8094]}, {"w": "a", "b": [0.1997, 0.788, 0.2088, 0.8094]}, {"w": "new", "b": [0.2162, 0.788, 0.2507, 0.8094]}, {"w": "dataset", "b": [0.2582, 0.788, 0.3163, 0.8094]}, {"w": "that", "b": [0.3237, 0.788, 0.3563, 0.8094]}, {"w": "will", "b": [0.3637, 0.788, 0.3941, 0.8094]}, {"w": "start", "b": [0.4016, 0.788, 0.4388, 0.8094]}, {"w": "by", "b": [0.4462, 0.788, 0.4664, 0.8094]}, {"w": "filling", "b": [0.4738, 0.788, 0.5228, 0.8094]}, {"w": "up", "b": [0.5302, 0.788, 0.5522, 0.8094]}, {"w": "a", "b": [0.5597, 0.788, 0.5688, 0.8094]}, {"w": "buffer", "b": [0.5762, 0.788, 0.6268, 0.8094]}, {"w": "with", "b": [0.6342, 0.788, 0.6716, 0.8094]}, {"w": "the", "b": [0.679, 0.788, 0.7053, 0.8094]}, {"w": "first", "b": [0.7128, 0.788, 0.7462, 0.8094]}, {"w": "items", "b": [0.7537, 0.788, 0.7992, 0.8094]}, {"w": "of", "b": [0.8066, 0.788, 0.8234, 0.8094]}, {"w": "the", "b": [0.8308, 0.788, 0.8572, 0.8094]}, {"w": "source", "b": [0.1429, 0.807, 0.1976, 0.8285]}, {"w": "dataset,", "b": [0.2044, 0.807, 0.2673, 0.8285]}, {"w": "then", "b": [0.2742, 0.807, 0.3119, 0.8285]}, {"w": "whenever", "b": [0.3187, 0.807, 0.3995, 0.8285]}, {"w": "it", "b": [0.4063, 0.807, 0.4183, 0.8285]}, {"w": "is", "b": [0.4251, 0.807, 0.4384, 0.8285]}, {"w": "asked", "b": [0.4452, 0.807, 0.4922, 0.8285]}, {"w": "for", "b": [0.4991, 0.807, 0.5236, 0.8285]}, {"w": "an", "b": [0.5304, 0.807, 0.551, 0.8285]}, {"w": "item,", "b": [0.5578, 0.807, 0.6004, 0.8285]}, {"w": "it", "b": [0.6073, 0.807, 0.6192, 0.8285]}, {"w": "will", "b": [0.6261, 0.807, 0.6565, 0.8285]}, {"w": "pull", "b": [0.6633, 0.807, 0.6959, 0.8285]}, {"w": "one", "b": [0.7027, 0.807, 0.7336, 0.8285]}, {"w": "out", "b": [0.7405, 0.807, 0.7685, 0.8285]}, {"w": "randomly", "b": [0.7754, 0.807, 0.8571, 0.8285]}, {"w": "from", "b": [0.1429, 0.8261, 0.1844, 0.8475]}, {"w": "the", "b": [0.1911, 0.8261, 0.2174, 0.8475]}, {"w": "buffer,", "b": [0.224, 0.8261, 0.278, 0.8475]}, {"w": "and", "b": [0.2846, 0.8261, 0.3162, 0.8475]}, {"w": "replace", "b": [0.3228, 0.8261, 0.3823, 0.8475]}, {"w": "it", "b": [0.389, 0.8261, 0.4009, 0.8475]}, {"w": "with", "b": [0.4075, 0.8261, 0.4448, 0.8475]}, {"w": "a", "b": [0.4515, 0.8261, 0.4606, 0.8475]}, {"w": "fresh", "b": [0.4672, 0.8261, 0.5087, 0.8475]}, {"w": "one", "b": [0.5153, 0.8261, 0.5462, 0.8475]}, {"w": "from", "b": [0.5528, 0.8261, 0.5944, 0.8475]}, {"w": "the", "b": [0.601, 0.8261, 0.6274, 0.8475]}, {"w": "source", "b": [0.634, 0.8261, 0.6887, 0.8475]}, {"w": "dataset,", "b": [0.6953, 0.8261, 0.7582, 0.8475]}, {"w": "until", "b": [0.7648, 0.8261, 0.8041, 0.8475]}, {"w": "it", "b": [0.8107, 0.8261, 0.8226, 0.8475]}, {"w": "has", "b": [0.8292, 0.8261, 0.8571, 0.8475]}, {"w": "iterated", "b": [0.1428, 0.8451, 0.2063, 0.8666]}, {"w": "entirely", "b": [0.2148, 0.8451, 0.278, 0.8666]}, {"w": "through", "b": [0.2865, 0.8451, 0.3543, 0.8666]}, {"w": "the", "b": [0.3628, 0.8451, 0.3891, 0.8666]}, {"w": "source", "b": [0.3976, 0.8451, 0.4523, 0.8666]}, {"w": "dataset.", "b": [0.4608, 0.8451, 0.5237, 0.8666]}, {"w": "At", "b": [0.5322, 0.8451, 0.5521, 0.8666]}, {"w": "this", "b": [0.5606, 0.8451, 0.5913, 0.8666]}, {"w": "point", "b": [0.5998, 0.8451, 0.6443, 0.8666]}, {"w": "it", "b": [0.6527, 0.8451, 0.6647, 0.8666]}, {"w": "continues", "b": [0.6732, 0.8451, 0.7541, 0.8666]}, {"w": "to", "b": [0.7626, 0.8451, 0.7796, 0.8666]}, {"w": "pull", "b": [0.7881, 0.8451, 0.8206, 0.8666]}, {"w": "out", "b": [0.8291, 0.8451, 0.8571, 0.8666]}, {"w": "items", "b": [0.1429, 0.8642, 0.1884, 0.8856]}, {"w": "randomly", "b": [0.1932, 0.8642, 0.275, 0.8856]}, {"w": "from", "b": [0.2798, 0.8642, 0.3214, 0.8856]}, {"w": "the", "b": [0.3262, 0.8642, 0.3526, 0.8856]}, {"w": "buffer", "b": [0.3574, 0.8642, 0.408, 0.8856]}, {"w": "until", "b": [0.4128, 0.8642, 0.4521, 0.8856]}, {"w": "it", "b": [0.4569, 0.8642, 0.4688, 0.8856]}, {"w": "is", "b": [0.4737, 0.8642, 0.4869, 0.8856]}, {"w": "empty.", "b": [0.4917, 0.8642, 0.5473, 0.8856]}, {"w": "You", "b": [0.5522, 0.8642, 0.5845, 0.8856]}, {"w": "must", "b": [0.5893, 0.8642, 0.6311, 0.8856]}, {"w": "specify", "b": [0.6359, 0.8642, 0.6938, 0.8856]}, {"w": "the", "b": [0.6986, 0.8642, 0.725, 0.8856]}, {"w": "buffer", "b": [0.7298, 0.8642, 0.7804, 0.8856]}, {"w": "size,", "b": [0.7852, 0.8642, 0.8208, 0.8856]}, {"w": "and", "b": [0.8256, 0.8642, 0.8571, 0.8856]}]}, {"id": "b_12", "type": "paragraph", "text": "406 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "406", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 433, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 Imagine a sorted deck of cards on your left: suppose you just take the top 3 cards and shuffle them, then pick one randomly and put it to your right, keeping the other 2 in your hands. Take another card on your left, shuffle the 3 cards in your hands and pick one of them randomly, and put it on your right. When you are done going through all the cards like this, you will have a deck of cards on your right: do you think it will be perfectly shuffled?", "words": [{"w": "1", "b": [0.1451, 0.8159, 0.1518, 0.8302]}, {"w": "Imagine", "b": [0.1587, 0.8144, 0.2112, 0.8308]}, {"w": "a", "b": [0.2148, 0.8144, 0.2218, 0.8308]}, {"w": "sorted", "b": [0.2254, 0.8144, 0.2652, 0.8308]}, {"w": "deck", "b": [0.2688, 0.8144, 0.2985, 0.8308]}, {"w": "of", "b": [0.3021, 0.8144, 0.3149, 0.8308]}, {"w": "cards", "b": [0.3185, 0.8144, 0.3523, 0.8308]}, {"w": "on", "b": [0.3559, 0.8144, 0.3727, 0.8308]}, {"w": "your", "b": [0.3763, 0.8144, 0.406, 0.8308]}, {"w": "left:", "b": [0.4096, 0.8144, 0.4335, 0.8308]}, {"w": "suppose", "b": [0.4371, 0.8144, 0.4886, 0.8308]}, {"w": "you", "b": [0.4922, 0.8144, 0.516, 0.8308]}, {"w": "just", "b": [0.5197, 0.8144, 0.5428, 0.8308]}, {"w": "take", "b": [0.5464, 0.8144, 0.5728, 0.8308]}, {"w": "the", "b": [0.5764, 0.8144, 0.5965, 0.8308]}, {"w": "top", "b": [0.6001, 0.8144, 0.6214, 0.8308]}, {"w": "3", "b": [0.625, 0.8144, 0.6326, 0.8308]}, {"w": "cards", "b": [0.6362, 0.8144, 0.67, 0.8308]}, {"w": "and", "b": [0.6736, 0.8144, 0.6976, 0.8308]}, {"w": "shuffle", "b": [0.7012, 0.8144, 0.7438, 0.8308]}, {"w": "them,", "b": [0.7474, 0.8144, 0.7841, 0.8308]}, {"w": "then", "b": [0.7877, 0.8144, 0.8164, 0.8308]}, {"w": "pick", "b": [0.82, 0.8144, 0.8472, 0.8308]}, {"w": "one", "b": [0.1587, 0.8296, 0.1823, 0.8459]}, {"w": "randomly", "b": [0.1859, 0.8296, 0.2482, 0.8459]}, {"w": "and", "b": [0.2518, 0.8296, 0.2758, 0.8459]}, {"w": "put", "b": [0.2794, 0.8296, 0.301, 0.8459]}, {"w": "it", "b": [0.3046, 0.8296, 0.3137, 0.8459]}, {"w": "to", "b": [0.3173, 0.8296, 0.3302, 0.8459]}, {"w": "your", "b": [0.3338, 0.8296, 0.3635, 0.8459]}, {"w": "right,", "b": [0.3671, 0.8296, 0.4013, 0.8459]}, {"w": "keeping", "b": [0.405, 0.8296, 0.455, 0.8459]}, {"w": "the", "b": [0.4586, 0.8296, 0.4787, 0.8459]}, {"w": "other", "b": [0.4823, 0.8296, 0.5163, 0.8459]}, {"w": "2", "b": [0.5199, 0.8296, 0.5275, 0.8459]}, {"w": "in", "b": [0.5311, 0.8296, 0.5441, 0.8459]}, {"w": "your", "b": [0.5477, 0.8296, 0.5774, 0.8459]}, {"w": "hands.", "b": [0.581, 0.8296, 0.6229, 0.8459]}, {"w": "Take", "b": [0.6265, 0.8296, 0.6565, 0.8459]}, {"w": "another", "b": [0.6601, 0.8296, 0.7098, 0.8459]}, {"w": "card", "b": [0.7134, 0.8296, 0.7413, 0.8459]}, {"w": "on", "b": [0.7449, 0.8296, 0.7617, 0.8459]}, {"w": "your", "b": [0.7653, 0.8296, 0.795, 0.8459]}, {"w": "left,", "b": [0.7986, 0.8296, 0.8225, 0.8459]}, {"w": "shuffle", "b": [0.1587, 0.8447, 0.2013, 0.861]}, {"w": "the", "b": [0.2049, 0.8447, 0.225, 0.861]}, {"w": "3", "b": [0.2286, 0.8447, 0.2362, 0.861]}, {"w": "cards", "b": [0.2398, 0.8447, 0.2736, 0.861]}, {"w": "in", "b": [0.2772, 0.8447, 0.2901, 0.861]}, {"w": "your", "b": [0.2937, 0.8447, 0.3234, 0.861]}, {"w": "hands", "b": [0.327, 0.8447, 0.3654, 0.861]}, {"w": "and", "b": [0.369, 0.8447, 0.393, 0.861]}, {"w": "pick", "b": [0.3966, 0.8447, 0.4238, 0.861]}, {"w": "one", "b": [0.4274, 0.8447, 0.4509, 0.861]}, {"w": "of", "b": [0.4545, 0.8447, 0.4673, 0.861]}, {"w": "them", "b": [0.4709, 0.8447, 0.504, 0.861]}, {"w": "randomly,", "b": [0.5076, 0.8447, 0.5723, 0.861]}, {"w": "and", "b": [0.5759, 0.8447, 0.6, 0.861]}, {"w": "put", "b": [0.6036, 0.8447, 0.6252, 0.861]}, {"w": "it", "b": [0.6288, 0.8447, 0.6379, 0.861]}, {"w": "on", "b": [0.6415, 0.8447, 0.6582, 0.861]}, {"w": "your", "b": [0.6618, 0.8447, 0.6915, 0.861]}, {"w": "right.", "b": [0.6951, 0.8447, 0.7293, 0.861]}, {"w": "When", "b": [0.733, 0.8447, 0.7723, 0.861]}, {"w": "you", "b": [0.7759, 0.8447, 0.7997, 0.861]}, {"w": "are", "b": [0.8033, 0.8447, 0.8229, 0.861]}, {"w": "done", "b": [0.1587, 0.8598, 0.1906, 0.8761]}, {"w": "going", "b": [0.1942, 0.8598, 0.2301, 0.8761]}, {"w": "through", "b": [0.2337, 0.8598, 0.2854, 0.8761]}, {"w": "all", "b": [0.289, 0.8598, 0.304, 0.8761]}, {"w": "the", "b": [0.3076, 0.8598, 0.3276, 0.8761]}, {"w": "cards", "b": [0.3312, 0.8598, 0.365, 0.8761]}, {"w": "like", "b": [0.3686, 0.8598, 0.3915, 0.8761]}, {"w": "this,", "b": [0.3951, 0.8598, 0.4221, 0.8761]}, {"w": "you", "b": [0.4257, 0.8598, 0.4495, 0.8761]}, {"w": "will", "b": [0.4531, 0.8598, 0.4763, 0.8761]}, {"w": "have", "b": [0.4799, 0.8598, 0.5092, 0.8761]}, {"w": "a", "b": [0.5128, 0.8598, 0.5197, 0.8761]}, {"w": "deck", "b": [0.5233, 0.8598, 0.553, 0.8761]}, {"w": "of", "b": [0.5567, 0.8598, 0.5694, 0.8761]}, {"w": "cards", "b": [0.573, 0.8598, 0.6068, 0.8761]}, {"w": "on", "b": [0.6104, 0.8598, 0.6272, 0.8761]}, {"w": "your", "b": [0.6308, 0.8598, 0.6605, 0.8761]}, {"w": "right:", "b": [0.6641, 0.8598, 0.6983, 0.8761]}, {"w": "do", "b": [0.7019, 0.8598, 0.7184, 0.8761]}, {"w": "you", "b": [0.722, 0.8598, 0.7458, 0.8761]}, {"w": "think", "b": [0.7494, 0.8598, 0.7835, 0.8761]}, {"w": "it", "b": [0.7871, 0.8598, 0.7962, 0.8761]}, {"w": "will", "b": [0.7998, 0.8598, 0.823, 0.8761]}, {"w": "be", "b": [0.8266, 0.8598, 0.8414, 0.8761]}, {"w": "perfectly", "b": [0.1587, 0.8749, 0.214, 0.8912]}, {"w": "shuffled?", "b": [0.2176, 0.8749, 0.2746, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "it is important to make it large enough or else shuffling will not be very efficient.1", "words": [{"w": "it", "b": [0.1429, 0.0791, 0.1548, 0.1005]}, {"w": "is", "b": [0.1622, 0.0791, 0.1755, 0.1005]}, {"w": "important", "b": [0.1829, 0.0791, 0.2673, 0.1005]}, {"w": "to", "b": [0.2747, 0.0791, 0.2917, 0.1005]}, {"w": "make", "b": [0.2992, 0.0791, 0.3446, 0.1005]}, {"w": "it", "b": [0.352, 0.0791, 0.3639, 0.1005]}, {"w": "large", "b": [0.3714, 0.0791, 0.4121, 0.1005]}, {"w": "enough", "b": [0.4196, 0.0791, 0.4824, 0.1005]}, {"w": "or", "b": [0.4898, 0.0791, 0.5082, 0.1005]}, {"w": "else", "b": [0.5156, 0.0791, 0.5463, 0.1005]}, {"w": "shuffling", "b": [0.5537, 0.0791, 0.6275, 0.1005]}, {"w": "will", "b": [0.6349, 0.0791, 0.6653, 0.1005]}, {"w": "not", "b": [0.6728, 0.0791, 0.7011, 0.1005]}, {"w": "be", "b": [0.7086, 0.0791, 0.728, 0.1005]}, {"w": "very", "b": [0.7355, 0.0791, 0.7719, 0.1005]}, {"w": "efficient.1", "b": [0.7793, 0.0791, 0.8571, 0.1005]}]}, {"id": "b_2", "type": "paragraph", "text": "However, obviously do not exceed the amount of RAM you have, and even if you have plenty of it, there’s no need to go well beyond the dataset’s size. You can provide a random seed if you want the same random order every time you run your program.", "words": [{"w": "However,", "b": [0.1429, 0.0981, 0.2217, 0.1195]}, {"w": "obviously", "b": [0.2293, 0.0981, 0.3099, 0.1195]}, {"w": "do", "b": [0.3176, 0.0981, 0.3392, 0.1195]}, {"w": "not", "b": [0.3468, 0.0981, 0.3752, 0.1195]}, {"w": "exceed", "b": [0.3828, 0.0981, 0.439, 0.1195]}, {"w": "the", "b": [0.4466, 0.0981, 0.473, 0.1195]}, {"w": "amount", "b": [0.4806, 0.0981, 0.5458, 0.1195]}, {"w": "of", "b": [0.5534, 0.0981, 0.5702, 0.1195]}, {"w": "RAM", "b": [0.5778, 0.0981, 0.6237, 0.1195]}, {"w": "you", "b": [0.6314, 0.0981, 0.6626, 0.1195]}, {"w": "have,", "b": [0.6702, 0.0981, 0.7134, 0.1195]}, {"w": "and", "b": [0.721, 0.0981, 0.7525, 0.1195]}, {"w": "even", "b": [0.7602, 0.0981, 0.7989, 0.1195]}, {"w": "if", "b": [0.8065, 0.0981, 0.8183, 0.1195]}, {"w": "you", "b": [0.8259, 0.0981, 0.8571, 0.1195]}, {"w": "have", "b": [0.1429, 0.1172, 0.1812, 0.1386]}, {"w": "plenty", "b": [0.1867, 0.1172, 0.2387, 0.1386]}, {"w": "of", "b": [0.2441, 0.1172, 0.2609, 0.1386]}, {"w": "it,", "b": [0.2664, 0.1172, 0.2831, 0.1386]}, {"w": "there’s", "b": [0.2885, 0.1172, 0.3406, 0.1386]}, {"w": "no", "b": [0.346, 0.1172, 0.368, 0.1386]}, {"w": "need", "b": [0.3735, 0.1172, 0.4136, 0.1386]}, {"w": "to", "b": [0.4191, 0.1172, 0.4361, 0.1386]}, {"w": "go", "b": [0.4415, 0.1172, 0.4619, 0.1386]}, {"w": "well", "b": [0.4674, 0.1172, 0.501, 0.1386]}, {"w": "beyond", "b": [0.5065, 0.1172, 0.5685, 0.1386]}, {"w": "the", "b": [0.574, 0.1172, 0.6003, 0.1386]}, {"w": "dataset’s", "b": [0.6058, 0.1172, 0.6736, 0.1386]}, {"w": "size.", "b": [0.6791, 0.1172, 0.7147, 0.1386]}, {"w": "You", "b": [0.7201, 0.1172, 0.7525, 0.1386]}, {"w": "can", "b": [0.758, 0.1172, 0.7873, 0.1386]}, {"w": "provide", "b": [0.7928, 0.1172, 0.8571, 0.1386]}, {"w": "a", "b": [0.1429, 0.1362, 0.152, 0.1576]}, {"w": "random", "b": [0.1567, 0.1362, 0.2237, 0.1576]}, {"w": "seed", "b": [0.2284, 0.1362, 0.2648, 0.1576]}, {"w": "if", "b": [0.2695, 0.1362, 0.2813, 0.1576]}, {"w": "you", "b": [0.286, 0.1362, 0.3172, 0.1576]}, {"w": "want", "b": [0.322, 0.1362, 0.3627, 0.1576]}, {"w": "the", "b": [0.3675, 0.1362, 0.3938, 0.1576]}, {"w": "same", "b": [0.3985, 0.1362, 0.4412, 0.1576]}, {"w": "random", "b": [0.446, 0.1362, 0.5129, 0.1576]}, {"w": "order", "b": [0.5177, 0.1362, 0.5636, 0.1576]}, {"w": "every", "b": [0.5683, 0.1362, 0.6136, 0.1576]}, {"w": "time", "b": [0.6183, 0.1362, 0.6562, 0.1576]}, {"w": "you", "b": [0.6609, 0.1362, 0.6921, 0.1576]}, {"w": "run", "b": [0.6969, 0.1362, 0.7271, 0.1576]}, {"w": "your", "b": [0.7318, 0.1362, 0.7708, 0.1576]}, {"w": "program.", "b": [0.7755, 0.1362, 0.8532, 0.1576]}]}, {"id": "b_3", "type": "paragraph", "text": ">>> dataset = tf.data.Dataset.range(10).repeat(3) # 0 to 9, three times >>> dataset = dataset.shuffle(buffer_size=5, seed=42).batch(7) >>> for item in dataset: ... print(item) ... tf.Tensor([0 2 3 6 7 9 4], shape=(7,), dtype=int64) tf.Tensor([5 0 1 1 8 6 5], shape=(7,), dtype=int64) tf.Tensor([4 8 7 1 2 3 0], shape=(7,), dtype=int64) tf.Tensor([5 4 2 7 8 9 9], shape=(7,), dtype=int64) tf.Tensor([3 6], shape=(2,), dtype=int64)", "words": [{"w": ">>>", "b": [0.1766, 0.1682, 0.2019, 0.181]}, {"w": "dataset", "b": [0.2103, 0.1682, 0.2693, 0.181]}, {"w": "=", "b": [0.2778, 0.1682, 0.2862, 0.181]}, {"w": "tf.data.Dataset.range(10).repeat(3)", "b": [0.2946, 0.1682, 0.5898, 0.181]}, {"w": "#", "b": [0.5982, 0.1682, 0.6066, 0.181]}, {"w": "0", "b": [0.6151, 0.1682, 0.6235, 0.181]}, {"w": "to", "b": [0.6319, 0.1682, 0.6488, 0.181]}, {"w": "9,", "b": [0.6572, 0.1682, 0.6741, 0.181]}, {"w": "three", "b": [0.6825, 0.1682, 0.7247, 0.181]}, {"w": "times", "b": [0.7331, 0.1682, 0.7753, 0.181]}, {"w": ">>>", "b": [0.1766, 0.1836, 0.2019, 0.1964]}, {"w": "dataset", "b": [0.2103, 0.1836, 0.2693, 0.1964]}, {"w": "=", "b": [0.2778, 0.1836, 0.2862, 0.1964]}, {"w": "dataset.shuffle(buffer_size=5,", "b": [0.2946, 0.1836, 0.5476, 0.1964]}, {"w": "seed=42).batch(7)", "b": [0.5561, 0.1836, 0.6994, 0.1964]}, {"w": ">>>", "b": [0.1766, 0.199, 0.2019, 0.2119]}, {"w": "for", "b": [0.2103, 0.199, 0.2356, 0.2119]}, {"w": "item", "b": [0.244, 0.199, 0.2778, 0.2119]}, {"w": "in", "b": [0.2862, 0.199, 0.3031, 0.2119]}, {"w": "dataset:", "b": [0.3115, 0.199, 0.379, 0.2119]}, {"w": "...", "b": [0.1766, 0.2144, 0.2019, 0.2273]}, {"w": "print(item)", "b": [0.244, 0.2144, 0.3368, 0.2273]}, {"w": "...", "b": [0.1766, 0.2299, 0.2019, 0.2427]}, {"w": "tf.Tensor([0", "b": [0.1766, 0.2453, 0.2778, 0.2581]}, {"w": "2", "b": [0.2862, 0.2453, 0.2946, 0.2581]}, {"w": "3", "b": [0.3031, 0.2453, 0.3115, 0.2581]}, {"w": "6", "b": [0.3199, 0.2453, 0.3284, 0.2581]}, {"w": "7", "b": [0.3368, 0.2453, 0.3452, 0.2581]}, {"w": "9", "b": [0.3537, 0.2453, 0.3621, 0.2581]}, {"w": "4],", "b": [0.3705, 0.2453, 0.3958, 0.2581]}, {"w": "shape=(7,),", "b": [0.4043, 0.2453, 0.497, 0.2581]}, {"w": "dtype=int64)", "b": [0.5055, 0.2453, 0.6066, 0.2581]}, {"w": "tf.Tensor([5", "b": [0.1766, 0.2607, 0.2778, 0.2735]}, {"w": "0", "b": [0.2862, 0.2607, 0.2946, 0.2735]}, {"w": "1", "b": [0.3031, 0.2607, 0.3115, 0.2735]}, {"w": "1", "b": [0.3199, 0.2607, 0.3284, 0.2735]}, {"w": "8", "b": [0.3368, 0.2607, 0.3452, 0.2735]}, {"w": "6", "b": [0.3537, 0.2607, 0.3621, 0.2735]}, {"w": "5],", "b": [0.3705, 0.2607, 0.3958, 0.2735]}, {"w": "shape=(7,),", "b": [0.4043, 0.2607, 0.497, 0.2735]}, {"w": "dtype=int64)", "b": [0.5055, 0.2607, 0.6066, 0.2735]}, {"w": "tf.Tensor([4", "b": [0.1766, 0.2761, 0.2778, 0.289]}, {"w": "8", "b": [0.2862, 0.2761, 0.2946, 0.289]}, {"w": "7", "b": [0.3031, 0.2761, 0.3115, 0.289]}, {"w": "1", "b": [0.3199, 0.2761, 0.3284, 0.289]}, {"w": "2", "b": [0.3368, 0.2761, 0.3452, 0.289]}, {"w": "3", "b": [0.3537, 0.2761, 0.3621, 0.289]}, {"w": "0],", "b": [0.3705, 0.2761, 0.3958, 0.289]}, {"w": "shape=(7,),", "b": [0.4043, 0.2761, 0.497, 0.289]}, {"w": "dtype=int64)", "b": [0.5055, 0.2761, 0.6066, 0.289]}, {"w": "tf.Tensor([5", "b": [0.1766, 0.2915, 0.2778, 0.3044]}, {"w": "4", "b": [0.2862, 0.2915, 0.2946, 0.3044]}, {"w": "2", "b": [0.3031, 0.2915, 0.3115, 0.3044]}, {"w": "7", "b": [0.3199, 0.2915, 0.3284, 0.3044]}, {"w": "8", "b": [0.3368, 0.2915, 0.3452, 0.3044]}, {"w": "9", "b": [0.3537, 0.2915, 0.3621, 0.3044]}, {"w": "9],", "b": [0.3705, 0.2915, 0.3958, 0.3044]}, {"w": "shape=(7,),", "b": [0.4043, 0.2915, 0.497, 0.3044]}, {"w": "dtype=int64)", "b": [0.5055, 0.2915, 0.6066, 0.3044]}, {"w": "tf.Tensor([3", "b": [0.1766, 0.307, 0.2778, 0.3198]}, {"w": "6],", "b": [0.2862, 0.307, 0.3115, 0.3198]}, {"w": "shape=(2,),", "b": [0.3199, 0.307, 0.4127, 0.3198]}, {"w": "dtype=int64)", "b": [0.4211, 0.307, 0.5223, 0.3198]}]}, {"id": "b_4", "type": "paragraph", "text": "If you call repeat() on a shuffled dataset, by default it will generate a new order at every iteration. This is generally a good idea, but if you prefer to reuse the same order at each iteration (e.g., for tests or debugging), you can set reshuffle_each_iteration=False.", "words": [{"w": "If", "b": [0.2714, 0.3422, 0.2835, 0.3618]}, {"w": "you", "b": [0.2879, 0.3422, 0.3164, 0.3618]}, {"w": "call", "b": [0.3208, 0.3422, 0.3468, 0.3618]}, {"w": "repeat()", "b": [0.3516, 0.3451, 0.424, 0.3589]}, {"w": "on", "b": [0.4285, 0.3422, 0.4486, 0.3618]}, {"w": "a", "b": [0.4531, 0.3422, 0.4615, 0.3618]}, {"w": "shuffled", "b": [0.466, 0.3422, 0.5271, 0.3618]}, {"w": "dataset,", "b": [0.5316, 0.3422, 0.5891, 0.3618]}, {"w": "by", "b": [0.5936, 0.3422, 0.612, 0.3618]}, {"w": "default", "b": [0.6165, 0.3422, 0.669, 0.3618]}, {"w": "it", "b": [0.6735, 0.3422, 0.6844, 0.3618]}, {"w": "will", "b": [0.6889, 0.3422, 0.7167, 0.3618]}, {"w": "generate", "b": [0.7212, 0.3422, 0.7857, 0.3618]}, {"w": "a", "b": [0.2714, 0.3596, 0.2798, 0.3792]}, {"w": "new", "b": [0.2854, 0.3596, 0.317, 0.3792]}, {"w": "order", "b": [0.3226, 0.3596, 0.3646, 0.3792]}, {"w": "at", "b": [0.3702, 0.3596, 0.384, 0.3792]}, {"w": "every", "b": [0.3897, 0.3596, 0.431, 0.3792]}, {"w": "iteration.", "b": [0.4367, 0.3596, 0.5061, 0.3792]}, {"w": "This", "b": [0.5118, 0.3596, 0.5458, 0.3792]}, {"w": "is", "b": [0.5514, 0.3596, 0.5635, 0.3792]}, {"w": "generally", "b": [0.5691, 0.3596, 0.6385, 0.3792]}, {"w": "a", "b": [0.6441, 0.3596, 0.6525, 0.3792]}, {"w": "good", "b": [0.6581, 0.3596, 0.6965, 0.3792]}, {"w": "idea,", "b": [0.7021, 0.3596, 0.7381, 0.3792]}, {"w": "but", "b": [0.7437, 0.3596, 0.7693, 0.3792]}, {"w": "if", "b": [0.775, 0.3596, 0.7857, 0.3792]}, {"w": "you", "b": [0.2714, 0.3771, 0.3, 0.3966]}, {"w": "prefer", "b": [0.306, 0.3771, 0.352, 0.3966]}, {"w": "to", "b": [0.358, 0.3771, 0.3735, 0.3966]}, {"w": "reuse", "b": [0.3795, 0.3771, 0.4199, 0.3966]}, {"w": "the", "b": [0.4259, 0.3771, 0.45, 0.3966]}, {"w": "same", "b": [0.4561, 0.3771, 0.4951, 0.3966]}, {"w": "order", "b": [0.5011, 0.3771, 0.5431, 0.3966]}, {"w": "at", "b": [0.5492, 0.3771, 0.563, 0.3966]}, {"w": "each", "b": [0.569, 0.3771, 0.6037, 0.3966]}, {"w": "iteration", "b": [0.6097, 0.3771, 0.6749, 0.3966]}, {"w": "(e.g.,", "b": [0.6809, 0.3771, 0.7175, 0.3966]}, {"w": "for", "b": [0.7236, 0.3771, 0.746, 0.3966]}, {"w": "tests", "b": [0.752, 0.3771, 0.7857, 0.3966]}, {"w": "or", "b": [0.2714, 0.3953, 0.2882, 0.4149]}, {"w": "debugging),", "b": [0.2925, 0.3953, 0.3837, 0.4149]}, {"w": "you", "b": [0.388, 0.3953, 0.4165, 0.4149]}, {"w": "can", "b": [0.4209, 0.3953, 0.4477, 0.4149]}, {"w": "set", "b": [0.452, 0.3953, 0.4729, 0.4149]}, {"w": "reshuffle_each_iteration=False.", "b": [0.4773, 0.3953, 0.753, 0.4149]}]}, {"id": "b_5", "type": "paragraph", "text": "For a large dataset that does not fit in memory, this simple shuffling-buffer approach may not be sufficient, since the buffer will be small compared to the dataset. One sol‐ ution is to shuffle the source data itself (for example, on Linux you can shuffle text files using the shuf command). This will definitely improve shuffling a lot! However, even if the source data is shuffled, you will usually want to shuffle it some more, or else the same order will be repeated at each epoch, and the model may end up being biased (e.g., due to some spurious patterns present by chance in the source data’s order). To shuffle the instances some more, a common approach is to split the source data into multiple files, then read them in a random order during training. However, instances located in the same file will still end up close to each other. To avoid this you can pick multiple files randomly, and read them simultaneously, interleaving their lines. Then on top of that you can add a shuffling buffer using the shuffle() method. If all this sounds like a lot of work, don’t worry: the Data API actually makes all this possible in just a few lines of code. Let’s see how to do this.", "words": [{"w": "For", "b": [0.1429, 0.4401, 0.1718, 0.4615]}, {"w": "a", "b": [0.1774, 0.4401, 0.1866, 0.4615]}, {"w": "large", "b": [0.1922, 0.4401, 0.233, 0.4615]}, {"w": "dataset", "b": [0.2386, 0.4401, 0.2967, 0.4615]}, {"w": "that", "b": [0.3023, 0.4401, 0.3349, 0.4615]}, {"w": "does", "b": [0.3405, 0.4401, 0.3786, 0.4615]}, {"w": "not", "b": [0.3842, 0.4401, 0.4126, 0.4615]}, {"w": "fit", "b": [0.4182, 0.4401, 0.4363, 0.4615]}, {"w": "in", "b": [0.4419, 0.4401, 0.4589, 0.4615]}, {"w": "memory,", "b": [0.4645, 0.4401, 0.5393, 0.4615]}, {"w": "this", "b": [0.5449, 0.4401, 0.5756, 0.4615]}, {"w": "simple", "b": [0.5812, 0.4401, 0.6361, 0.4615]}, {"w": "shuffling-buffer", "b": [0.6418, 0.4401, 0.7735, 0.4615]}, {"w": "approach", "b": [0.7791, 0.4401, 0.8571, 0.4615]}, {"w": "may", "b": [0.1428, 0.4591, 0.1782, 0.4805]}, {"w": "not", "b": [0.1835, 0.4591, 0.2119, 0.4805]}, {"w": "be", "b": [0.2172, 0.4591, 0.2366, 0.4805]}, {"w": "sufficient,", "b": [0.2419, 0.4591, 0.3238, 0.4805]}, {"w": "since", "b": [0.3291, 0.4591, 0.3714, 0.4805]}, {"w": "the", "b": [0.3767, 0.4591, 0.403, 0.4805]}, {"w": "buffer", "b": [0.4083, 0.4591, 0.4588, 0.4805]}, {"w": "will", "b": [0.4641, 0.4591, 0.4945, 0.4805]}, {"w": "be", "b": [0.4998, 0.4591, 0.5192, 0.4805]}, {"w": "small", "b": [0.5245, 0.4591, 0.5689, 0.4805]}, {"w": "compared", "b": [0.5741, 0.4591, 0.6579, 0.4805]}, {"w": "to", "b": [0.6631, 0.4591, 0.6801, 0.4805]}, {"w": "the", "b": [0.6854, 0.4591, 0.7117, 0.4805]}, {"w": "dataset.", "b": [0.717, 0.4591, 0.7798, 0.4805]}, {"w": "One", "b": [0.7851, 0.4591, 0.8209, 0.4805]}, {"w": "sol‐", "b": [0.8262, 0.4591, 0.8571, 0.4805]}, {"w": "ution", "b": [0.1429, 0.4782, 0.1879, 0.4996]}, {"w": "is", "b": [0.1947, 0.4782, 0.2079, 0.4996]}, {"w": "to", "b": [0.2148, 0.4782, 0.2317, 0.4996]}, {"w": "shuffle", "b": [0.2386, 0.4782, 0.2945, 0.4996]}, {"w": "the", "b": [0.3013, 0.4782, 0.3276, 0.4996]}, {"w": "source", "b": [0.3344, 0.4782, 0.3892, 0.4996]}, {"w": "data", "b": [0.396, 0.4782, 0.4312, 0.4996]}, {"w": "itself", "b": [0.4381, 0.4782, 0.4779, 0.4996]}, {"w": "(for", "b": [0.4848, 0.4782, 0.5165, 0.4996]}, {"w": "example,", "b": [0.5233, 0.4782, 0.5976, 0.4996]}, {"w": "on", "b": [0.6044, 0.4782, 0.6265, 0.4996]}, {"w": "Linux", "b": [0.6333, 0.4782, 0.682, 0.4996]}, {"w": "you", "b": [0.6888, 0.4782, 0.72, 0.4996]}, {"w": "can", "b": [0.7269, 0.4782, 0.7562, 0.4996]}, {"w": "shuffle", "b": [0.763, 0.4782, 0.8189, 0.4996]}, {"w": "text", "b": [0.8258, 0.4782, 0.8572, 0.4996]}, {"w": "files", "b": [0.1429, 0.4981, 0.1764, 0.5195]}, {"w": "using", "b": [0.1819, 0.4981, 0.2273, 0.5195]}, {"w": "the", "b": [0.2329, 0.4981, 0.2592, 0.5195]}, {"w": "shuf", "b": [0.2647, 0.5013, 0.3043, 0.5164]}, {"w": "command).", "b": [0.3098, 0.4981, 0.4069, 0.5195]}, {"w": "This", "b": [0.4124, 0.4981, 0.4496, 0.5195]}, {"w": "will", "b": [0.4552, 0.4981, 0.4856, 0.5195]}, {"w": "definitely", "b": [0.4911, 0.4981, 0.5697, 0.5195]}, {"w": "improve", "b": [0.5752, 0.4981, 0.6453, 0.5195]}, {"w": "shuffling", "b": [0.6508, 0.4981, 0.7246, 0.5195]}, {"w": "a", "b": [0.7301, 0.4981, 0.7392, 0.5195]}, {"w": "lot!", "b": [0.7448, 0.4981, 0.7728, 0.5195]}, {"w": "However,", "b": [0.7783, 0.4981, 0.8571, 0.5195]}, {"w": "even", "b": [0.1429, 0.5171, 0.1816, 0.5386]}, {"w": "if", "b": [0.1882, 0.5171, 0.1999, 0.5386]}, {"w": "the", "b": [0.2065, 0.5171, 0.2328, 0.5386]}, {"w": "source", "b": [0.2393, 0.5171, 0.2941, 0.5386]}, {"w": "data", "b": [0.3006, 0.5171, 0.3359, 0.5386]}, {"w": "is", "b": [0.3424, 0.5171, 0.3556, 0.5386]}, {"w": "shuffled,", "b": [0.3622, 0.5171, 0.4338, 0.5386]}, {"w": "you", "b": [0.4404, 0.5171, 0.4716, 0.5386]}, {"w": "will", "b": [0.4782, 0.5171, 0.5086, 0.5386]}, {"w": "usually", "b": [0.5151, 0.5171, 0.5741, 0.5386]}, {"w": "want", "b": [0.5807, 0.5171, 0.6215, 0.5386]}, {"w": "to", "b": [0.628, 0.5171, 0.645, 0.5386]}, {"w": "shuffle", "b": [0.6515, 0.5171, 0.7074, 0.5386]}, {"w": "it", "b": [0.714, 0.5171, 0.7259, 0.5386]}, {"w": "some", "b": [0.7325, 0.5171, 0.7767, 0.5386]}, {"w": "more,", "b": [0.7832, 0.5171, 0.8322, 0.5386]}, {"w": "or", "b": [0.8388, 0.5171, 0.8571, 0.5386]}, {"w": "else", "b": [0.1428, 0.5362, 0.1735, 0.5576]}, {"w": "the", "b": [0.1793, 0.5362, 0.2057, 0.5576]}, {"w": "same", "b": [0.2115, 0.5362, 0.2543, 0.5576]}, {"w": "order", "b": [0.2601, 0.5362, 0.3061, 0.5576]}, {"w": "will", "b": [0.3119, 0.5362, 0.3423, 0.5576]}, {"w": "be", "b": [0.3482, 0.5362, 0.3676, 0.5576]}, {"w": "repeated", "b": [0.3735, 0.5362, 0.4448, 0.5576]}, {"w": "at", "b": [0.4507, 0.5362, 0.4658, 0.5576]}, {"w": "each", "b": [0.4717, 0.5362, 0.5096, 0.5576]}, {"w": "epoch,", "b": [0.5155, 0.5362, 0.5706, 0.5576]}, {"w": "and", "b": [0.5764, 0.5362, 0.608, 0.5576]}, {"w": "the", "b": [0.6138, 0.5362, 0.6402, 0.5576]}, {"w": "model", "b": [0.646, 0.5362, 0.6989, 0.5576]}, {"w": "may", "b": [0.7047, 0.5362, 0.7401, 0.5576]}, {"w": "end", "b": [0.746, 0.5362, 0.7772, 0.5576]}, {"w": "up", "b": [0.7831, 0.5362, 0.8051, 0.5576]}, {"w": "being", "b": [0.811, 0.5362, 0.8571, 0.5576]}, {"w": "biased", "b": [0.1429, 0.5552, 0.1957, 0.5767]}, {"w": "(e.g.,", "b": [0.2039, 0.5552, 0.244, 0.5767]}, {"w": "due", "b": [0.2523, 0.5552, 0.2832, 0.5767]}, {"w": "to", "b": [0.2915, 0.5552, 0.3084, 0.5767]}, {"w": "some", "b": [0.3167, 0.5552, 0.3609, 0.5767]}, {"w": "spurious", "b": [0.3691, 0.5552, 0.4414, 0.5767]}, {"w": "patterns", "b": [0.4497, 0.5552, 0.5177, 0.5767]}, {"w": "present", "b": [0.526, 0.5552, 0.5873, 0.5767]}, {"w": "by", "b": [0.5956, 0.5552, 0.6157, 0.5767]}, {"w": "chance", "b": [0.624, 0.5552, 0.6821, 0.5767]}, {"w": "in", "b": [0.6904, 0.5552, 0.7074, 0.5767]}, {"w": "the", "b": [0.7156, 0.5552, 0.742, 0.5767]}, {"w": "source", "b": [0.7502, 0.5552, 0.805, 0.5767]}, {"w": "data’s", "b": [0.8132, 0.5552, 0.8571, 0.5767]}, {"w": "order).", "b": [0.1429, 0.5743, 0.2008, 0.5957]}, {"w": "To", "b": [0.206, 0.5743, 0.2274, 0.5957]}, {"w": "shuffle", "b": [0.2326, 0.5743, 0.2885, 0.5957]}, {"w": "the", "b": [0.2937, 0.5743, 0.32, 0.5957]}, {"w": "instances", "b": [0.3252, 0.5743, 0.4021, 0.5957]}, {"w": "some", "b": [0.4073, 0.5743, 0.4515, 0.5957]}, {"w": "more,", "b": [0.4567, 0.5743, 0.5057, 0.5957]}, {"w": "a", "b": [0.5109, 0.5743, 0.5201, 0.5957]}, {"w": "common", "b": [0.5253, 0.5743, 0.6008, 0.5957]}, {"w": "approach", "b": [0.606, 0.5743, 0.6841, 0.5957]}, {"w": "is", "b": [0.6893, 0.5743, 0.7025, 0.5957]}, {"w": "to", "b": [0.7077, 0.5743, 0.7247, 0.5957]}, {"w": "split", "b": [0.7299, 0.5743, 0.7657, 0.5957]}, {"w": "the", "b": [0.7709, 0.5743, 0.7972, 0.5957]}, {"w": "source", "b": [0.8024, 0.5743, 0.8571, 0.5957]}, {"w": "data", "b": [0.1429, 0.5933, 0.1781, 0.6147]}, {"w": "into", "b": [0.1837, 0.5933, 0.2173, 0.6147]}, {"w": "multiple", "b": [0.2229, 0.5933, 0.2929, 0.6147]}, {"w": "files,", "b": [0.2986, 0.5933, 0.3368, 0.6147]}, {"w": "then", "b": [0.3425, 0.5933, 0.3802, 0.6147]}, {"w": "read", "b": [0.3858, 0.5933, 0.4226, 0.6147]}, {"w": "them", "b": [0.4282, 0.5933, 0.4716, 0.6147]}, {"w": "in", "b": [0.4772, 0.5933, 0.4942, 0.6147]}, {"w": "a", "b": [0.4998, 0.5933, 0.509, 0.6147]}, {"w": "random", "b": [0.5146, 0.5933, 0.5816, 0.6147]}, {"w": "order", "b": [0.5872, 0.5933, 0.6332, 0.6147]}, {"w": "during", "b": [0.6388, 0.5933, 0.6953, 0.6147]}, {"w": "training.", "b": [0.701, 0.5933, 0.7726, 0.6147]}, {"w": "However,", "b": [0.7783, 0.5933, 0.8571, 0.6147]}, {"w": "instances", "b": [0.1429, 0.6124, 0.2197, 0.6338]}, {"w": "located", "b": [0.2266, 0.6124, 0.2862, 0.6338]}, {"w": "in", "b": [0.2931, 0.6124, 0.3101, 0.6338]}, {"w": "the", "b": [0.317, 0.6124, 0.3433, 0.6338]}, {"w": "same", "b": [0.3502, 0.6124, 0.3929, 0.6338]}, {"w": "file", "b": [0.3998, 0.6124, 0.4257, 0.6338]}, {"w": "will", "b": [0.4326, 0.6124, 0.463, 0.6338]}, {"w": "still", "b": [0.4698, 0.6124, 0.5, 0.6338]}, {"w": "end", "b": [0.5068, 0.6124, 0.5381, 0.6338]}, {"w": "up", "b": [0.545, 0.6124, 0.567, 0.6338]}, {"w": "close", "b": [0.5738, 0.6124, 0.615, 0.6338]}, {"w": "to", "b": [0.6219, 0.6124, 0.6389, 0.6338]}, {"w": "each", "b": [0.6458, 0.6124, 0.6837, 0.6338]}, {"w": "other.", "b": [0.6906, 0.6124, 0.7387, 0.6338]}, {"w": "To", "b": [0.7456, 0.6124, 0.7671, 0.6338]}, {"w": "avoid", "b": [0.7739, 0.6124, 0.8196, 0.6338]}, {"w": "this", "b": [0.8264, 0.6124, 0.8572, 0.6338]}, {"w": "you", "b": [0.1429, 0.6314, 0.1741, 0.6528]}, {"w": "can", "b": [0.1831, 0.6314, 0.2124, 0.6528]}, {"w": "pick", "b": [0.2214, 0.6314, 0.257, 0.6528]}, {"w": "multiple", "b": [0.266, 0.6314, 0.336, 0.6528]}, {"w": "files", "b": [0.345, 0.6314, 0.3785, 0.6528]}, {"w": "randomly,", "b": [0.3875, 0.6314, 0.4725, 0.6528]}, {"w": "and", "b": [0.4814, 0.6314, 0.513, 0.6528]}, {"w": "read", "b": [0.5219, 0.6314, 0.5587, 0.6528]}, {"w": "them", "b": [0.5676, 0.6314, 0.611, 0.6528]}, {"w": "simultaneously,", "b": [0.62, 0.6314, 0.7494, 0.6528]}, {"w": "interleaving", "b": [0.7584, 0.6314, 0.8571, 0.6528]}, {"w": "their", "b": [0.1429, 0.6514, 0.1825, 0.6728]}, {"w": "lines.", "b": [0.1893, 0.6514, 0.2328, 0.6728]}, {"w": "Then", "b": [0.2395, 0.6514, 0.2838, 0.6728]}, {"w": "on", "b": [0.2905, 0.6514, 0.3126, 0.6728]}, {"w": "top", "b": [0.3193, 0.6514, 0.3472, 0.6728]}, {"w": "of", "b": [0.354, 0.6514, 0.3708, 0.6728]}, {"w": "that", "b": [0.3776, 0.6514, 0.4101, 0.6728]}, {"w": "you", "b": [0.4169, 0.6514, 0.4482, 0.6728]}, {"w": "can", "b": [0.4549, 0.6514, 0.4843, 0.6728]}, {"w": "add", "b": [0.4911, 0.6514, 0.5222, 0.6728]}, {"w": "a", "b": [0.529, 0.6514, 0.5381, 0.6728]}, {"w": "shuffling", "b": [0.5449, 0.6514, 0.6187, 0.6728]}, {"w": "buffer", "b": [0.6254, 0.6514, 0.676, 0.6728]}, {"w": "using", "b": [0.6828, 0.6514, 0.7282, 0.6728]}, {"w": "the", "b": [0.735, 0.6514, 0.7613, 0.6728]}, {"w": "shuffle()", "b": [0.7681, 0.6546, 0.8571, 0.6696]}, {"w": "method.", "b": [0.1428, 0.6704, 0.2126, 0.6918]}, {"w": "If", "b": [0.2177, 0.6704, 0.231, 0.6918]}, {"w": "all", "b": [0.236, 0.6704, 0.2557, 0.6918]}, {"w": "this", "b": [0.2608, 0.6704, 0.2915, 0.6918]}, {"w": "sounds", "b": [0.2966, 0.6704, 0.356, 0.6918]}, {"w": "like", "b": [0.361, 0.6704, 0.3911, 0.6918]}, {"w": "a", "b": [0.3962, 0.6704, 0.4053, 0.6918]}, {"w": "lot", "b": [0.4104, 0.6704, 0.4326, 0.6918]}, {"w": "of", "b": [0.4377, 0.6704, 0.4545, 0.6918]}, {"w": "work,", "b": [0.4596, 0.6704, 0.5073, 0.6918]}, {"w": "don’t", "b": [0.5124, 0.6704, 0.554, 0.6918]}, {"w": "worry:", "b": [0.559, 0.6704, 0.615, 0.6918]}, {"w": "the", "b": [0.62, 0.6704, 0.6464, 0.6918]}, {"w": "Data", "b": [0.6514, 0.6704, 0.691, 0.6918]}, {"w": "API", "b": [0.6961, 0.6704, 0.7293, 0.6918]}, {"w": "actually", "b": [0.7344, 0.6704, 0.799, 0.6918]}, {"w": "makes", "b": [0.8041, 0.6704, 0.8571, 0.6918]}, {"w": "all", "b": [0.1429, 0.6895, 0.1626, 0.7109]}, {"w": "this", "b": [0.1673, 0.6895, 0.198, 0.7109]}, {"w": "possible", "b": [0.2027, 0.6895, 0.2698, 0.7109]}, {"w": "in", "b": [0.2746, 0.6895, 0.2916, 0.7109]}, {"w": "just", "b": [0.2963, 0.6895, 0.3267, 0.7109]}, {"w": "a", "b": [0.3314, 0.6895, 0.3406, 0.7109]}, {"w": "few", "b": [0.3453, 0.6895, 0.3746, 0.7109]}, {"w": "lines", "b": [0.3793, 0.6895, 0.4181, 0.7109]}, {"w": "of", "b": [0.4228, 0.6895, 0.4396, 0.7109]}, {"w": "code.", "b": [0.4443, 0.6895, 0.4883, 0.7109]}, {"w": "Let’s", "b": [0.4931, 0.6895, 0.5292, 0.7109]}, {"w": "see", "b": [0.534, 0.6895, 0.5593, 0.7109]}, {"w": "how", "b": [0.564, 0.6895, 0.6001, 0.7109]}, {"w": "to", "b": [0.6048, 0.6895, 0.6218, 0.7109]}, {"w": "do", "b": [0.6265, 0.6895, 0.6481, 0.7109]}, {"w": "this.", "b": [0.6529, 0.6895, 0.6883, 0.7109]}]}, {"id": "b_6", "type": "paragraph", "text": "The Data API | 407", "words": [{"w": "The", "b": [0.7213, 0.9225, 0.7428, 0.9388]}, {"w": "Data", "b": [0.7456, 0.9225, 0.7733, 0.9388]}, {"w": "API", "b": [0.7761, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "407", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 434, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Interleaving Lines From Multiple Files", "words": [{"w": "Interleaving", "b": [0.1429, 0.0777, 0.2358, 0.0987]}, {"w": "Lines", "b": [0.2394, 0.0777, 0.2785, 0.0987]}, {"w": "From", "b": [0.2821, 0.0777, 0.3213, 0.0987]}, {"w": "Multiple", "b": [0.3249, 0.0777, 0.3886, 0.0987]}, {"w": "Files", "b": [0.3922, 0.0777, 0.4264, 0.0987]}]}, {"id": "b_1", "type": "paragraph", "text": "First, let’s suppose that you loaded the California housing dataset, you shuffled it (unless it was already shuffled), you split it into a training set, a validation set and a test set, then you split each set into many CSV files that each look like this (each row contains 8 input features plus the target median house value):", "words": [{"w": "First,", "b": [0.1429, 0.1044, 0.1859, 0.1258]}, {"w": "let’s", "b": [0.1945, 0.1044, 0.2247, 0.1258]}, {"w": "suppose", "b": [0.2333, 0.1044, 0.3009, 0.1258]}, {"w": "that", "b": [0.3095, 0.1044, 0.3421, 0.1258]}, {"w": "you", "b": [0.3506, 0.1044, 0.3819, 0.1258]}, {"w": "loaded", "b": [0.3904, 0.1044, 0.4463, 0.1258]}, {"w": "the", "b": [0.4549, 0.1044, 0.4812, 0.1258]}, {"w": "California", "b": [0.4898, 0.1044, 0.5743, 0.1258]}, {"w": "housing", "b": [0.5828, 0.1044, 0.65, 0.1258]}, {"w": "dataset,", "b": [0.6585, 0.1044, 0.7214, 0.1258]}, {"w": "you", "b": [0.73, 0.1044, 0.7612, 0.1258]}, {"w": "shuffled", "b": [0.7698, 0.1044, 0.8367, 0.1258]}, {"w": "it", "b": [0.8452, 0.1044, 0.8571, 0.1258]}, {"w": "(unless", "b": [0.1428, 0.1234, 0.2019, 0.1448]}, {"w": "it", "b": [0.2082, 0.1234, 0.2201, 0.1448]}, {"w": "was", "b": [0.2264, 0.1234, 0.2575, 0.1448]}, {"w": "already", "b": [0.2638, 0.1234, 0.3245, 0.1448]}, {"w": "shuffled),", "b": [0.3307, 0.1234, 0.4096, 0.1448]}, {"w": "you", "b": [0.4159, 0.1234, 0.4471, 0.1448]}, {"w": "split", "b": [0.4534, 0.1234, 0.4892, 0.1448]}, {"w": "it", "b": [0.4954, 0.1234, 0.5074, 0.1448]}, {"w": "into", "b": [0.5136, 0.1234, 0.5472, 0.1448]}, {"w": "a", "b": [0.5535, 0.1234, 0.5626, 0.1448]}, {"w": "training", "b": [0.5689, 0.1234, 0.6358, 0.1448]}, {"w": "set,", "b": [0.6421, 0.1234, 0.6697, 0.1448]}, {"w": "a", "b": [0.676, 0.1234, 0.6851, 0.1448]}, {"w": "validation", "b": [0.6914, 0.1234, 0.7748, 0.1448]}, {"w": "set", "b": [0.781, 0.1234, 0.8039, 0.1448]}, {"w": "and", "b": [0.8102, 0.1234, 0.8417, 0.1448]}, {"w": "a", "b": [0.848, 0.1234, 0.8571, 0.1448]}, {"w": "test", "b": [0.1429, 0.1425, 0.1721, 0.1639]}, {"w": "set,", "b": [0.1776, 0.1425, 0.2052, 0.1639]}, {"w": "then", "b": [0.2107, 0.1425, 0.2485, 0.1639]}, {"w": "you", "b": [0.254, 0.1425, 0.2852, 0.1639]}, {"w": "split", "b": [0.2907, 0.1425, 0.3265, 0.1639]}, {"w": "each", "b": [0.332, 0.1425, 0.37, 0.1639]}, {"w": "set", "b": [0.3755, 0.1425, 0.3984, 0.1639]}, {"w": "into", "b": [0.4039, 0.1425, 0.4374, 0.1639]}, {"w": "many", "b": [0.443, 0.1425, 0.4897, 0.1639]}, {"w": "CSV", "b": [0.4952, 0.1425, 0.5335, 0.1639]}, {"w": "files", "b": [0.5391, 0.1425, 0.5726, 0.1639]}, {"w": "that", "b": [0.5781, 0.1425, 0.6107, 0.1639]}, {"w": "each", "b": [0.6162, 0.1425, 0.6542, 0.1639]}, {"w": "look", "b": [0.6597, 0.1425, 0.6965, 0.1639]}, {"w": "like", "b": [0.7021, 0.1425, 0.7321, 0.1639]}, {"w": "this", "b": [0.7376, 0.1425, 0.7683, 0.1639]}, {"w": "(each", "b": [0.7739, 0.1425, 0.819, 0.1639]}, {"w": "row", "b": [0.8245, 0.1425, 0.8571, 0.1639]}, {"w": "contains", "b": [0.1429, 0.1615, 0.2134, 0.1829]}, {"w": "8", "b": [0.2181, 0.1615, 0.2281, 0.1829]}, {"w": "input", "b": [0.2329, 0.1615, 0.2778, 0.1829]}, {"w": "features", "b": [0.2825, 0.1615, 0.3479, 0.1829]}, {"w": "plus", "b": [0.3527, 0.1615, 0.3876, 0.1829]}, {"w": "the", "b": [0.3923, 0.1615, 0.4186, 0.1829]}, {"w": "target", "b": [0.4234, 0.1615, 0.4715, 0.1829]}, {"w": "median", "b": [0.4763, 0.1615, 0.5393, 0.1829]}, {"w": "house", "b": [0.544, 0.1615, 0.5934, 0.1829]}, {"w": "value):", "b": [0.5981, 0.1615, 0.654, 0.1829]}]}, {"id": "b_2", "type": "paragraph", "text": "MedInc,HouseAge,AveRooms,AveBedrms,Popul,AveOccup,Lat,Long,MedianHouseValue 3.5214,15.0,3.0499,1.1065,1447.0,1.6059,37.63,-122.43,1.442 5.3275,5.0,6.4900,0.9910,3464.0,3.4433,33.69,-117.39,1.687 3.1,29.0,7.5423,1.5915,1328.0,2.2508,38.44,-122.98,1.621 [...]", "words": [{"w": "MedInc,HouseAge,AveRooms,AveBedrms,Popul,AveOccup,Lat,Long,MedianHouseValue", "b": [0.1766, 0.1935, 0.809, 0.2063]}, {"w": "3.5214,15.0,3.0499,1.1065,1447.0,1.6059,37.63,-122.43,1.442", "b": [0.1766, 0.2089, 0.6741, 0.2217]}, {"w": "5.3275,5.0,6.4900,0.9910,3464.0,3.4433,33.69,-117.39,1.687", "b": [0.1766, 0.2243, 0.6657, 0.2372]}, {"w": "3.1,29.0,7.5423,1.5915,1328.0,2.2508,38.44,-122.98,1.621", "b": [0.1766, 0.2397, 0.6488, 0.2526]}, {"w": "[...]", "b": [0.1766, 0.2552, 0.2188, 0.268]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s also suppose train_filepaths contains the list of file paths (and you also have valid_filepaths and test_filepaths):", "words": [{"w": "Let’s", "b": [0.1429, 0.2767, 0.179, 0.2981]}, {"w": "also", "b": [0.1851, 0.2767, 0.2178, 0.2981]}, {"w": "suppose", "b": [0.2239, 0.2767, 0.2915, 0.2981]}, {"w": "train_filepaths", "b": [0.2976, 0.2799, 0.4461, 0.2949]}, {"w": "contains", "b": [0.4521, 0.2767, 0.5227, 0.2981]}, {"w": "the", "b": [0.5288, 0.2767, 0.5551, 0.2981]}, {"w": "list", "b": [0.5612, 0.2767, 0.586, 0.2981]}, {"w": "of", "b": [0.5921, 0.2767, 0.6089, 0.2981]}, {"w": "file", "b": [0.615, 0.2767, 0.6409, 0.2981]}, {"w": "paths", "b": [0.6469, 0.2767, 0.6917, 0.2981]}, {"w": "(and", "b": [0.6978, 0.2767, 0.7366, 0.2981]}, {"w": "you", "b": [0.7427, 0.2767, 0.7739, 0.2981]}, {"w": "also", "b": [0.78, 0.2767, 0.8127, 0.2981]}, {"w": "have", "b": [0.8187, 0.2767, 0.8571, 0.2981]}, {"w": "valid_filepaths", "b": [0.1429, 0.2998, 0.2913, 0.3149]}, {"w": "and", "b": [0.296, 0.2966, 0.3276, 0.318]}, {"w": "test_filepaths):", "b": [0.3323, 0.2966, 0.4828, 0.318]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> train_filepaths ['datasets/housing/my_train_00.csv', 'datasets/housing/my_train_01.csv',...]", "words": [{"w": ">>>", "b": [0.1766, 0.3286, 0.2019, 0.3414]}, {"w": "train_filepaths", "b": [0.2103, 0.3286, 0.3368, 0.3414]}, {"w": "['datasets/housing/my_train_00.csv',", "b": [0.1766, 0.344, 0.4802, 0.3569]}, {"w": "'datasets/housing/my_train_01.csv',...]", "b": [0.4886, 0.344, 0.8175, 0.3569]}]}, {"id": "b_5", "type": "paragraph", "text": "Now let’s create a dataset containing only these file paths:", "words": [{"w": "Now", "b": [0.1428, 0.3647, 0.1827, 0.3861]}, {"w": "let’s", "b": [0.1874, 0.3647, 0.2177, 0.3861]}, {"w": "create", "b": [0.2224, 0.3647, 0.2717, 0.3861]}, {"w": "a", "b": [0.2765, 0.3647, 0.2856, 0.3861]}, {"w": "dataset", "b": [0.2903, 0.3647, 0.3485, 0.3861]}, {"w": "containing", "b": [0.3532, 0.3647, 0.4428, 0.3861]}, {"w": "only", "b": [0.4476, 0.3647, 0.4844, 0.3861]}, {"w": "these", "b": [0.4891, 0.3647, 0.532, 0.3861]}, {"w": "file", "b": [0.5367, 0.3647, 0.5626, 0.3861]}, {"w": "paths:", "b": [0.5673, 0.3647, 0.6168, 0.3861]}]}, {"id": "b_6", "type": "equation", "text": "filepath_dataset = tf.data.Dataset.list_files(train_filepaths, seed=42)", "words": [{"w": "filepath_dataset", "b": [0.1766, 0.3966, 0.3115, 0.4095]}, {"w": "=", "b": [0.3199, 0.3966, 0.3284, 0.4095]}, {"w": "tf.data.Dataset.list_files(train_filepaths,", "b": [0.3368, 0.3966, 0.6994, 0.4095]}, {"w": "seed=42)", "b": [0.7078, 0.3966, 0.7753, 0.4095]}]}, {"id": "b_7", "type": "paragraph", "text": "By default, the list_files() function returns a dataset that shuffles the file paths. In general this is a good thing, but you can set shuffle=False if you do not want that, for some reason.", "words": [{"w": "By", "b": [0.1429, 0.4182, 0.1647, 0.4396]}, {"w": "default,", "b": [0.17, 0.4182, 0.2322, 0.4396]}, {"w": "the", "b": [0.2376, 0.4182, 0.2639, 0.4396]}, {"w": "list_files()", "b": [0.2692, 0.4213, 0.388, 0.4364]}, {"w": "function", "b": [0.3933, 0.4182, 0.4647, 0.4396]}, {"w": "returns", "b": [0.47, 0.4182, 0.5308, 0.4396]}, {"w": "a", "b": [0.5362, 0.4182, 0.5453, 0.4396]}, {"w": "dataset", "b": [0.5506, 0.4182, 0.6087, 0.4396]}, {"w": "that", "b": [0.6141, 0.4182, 0.6467, 0.4396]}, {"w": "shuffles", "b": [0.652, 0.4182, 0.7155, 0.4396]}, {"w": "the", "b": [0.7209, 0.4182, 0.7472, 0.4396]}, {"w": "file", "b": [0.7525, 0.4182, 0.7784, 0.4396]}, {"w": "paths.", "b": [0.7838, 0.4182, 0.8333, 0.4396]}, {"w": "In", "b": [0.8386, 0.4182, 0.8571, 0.4396]}, {"w": "general", "b": [0.1429, 0.4381, 0.2039, 0.4595]}, {"w": "this", "b": [0.21, 0.4381, 0.2407, 0.4595]}, {"w": "is", "b": [0.2468, 0.4381, 0.26, 0.4595]}, {"w": "a", "b": [0.2662, 0.4381, 0.2753, 0.4595]}, {"w": "good", "b": [0.2814, 0.4381, 0.3234, 0.4595]}, {"w": "thing,", "b": [0.3296, 0.4381, 0.3785, 0.4595]}, {"w": "but", "b": [0.3847, 0.4381, 0.4127, 0.4595]}, {"w": "you", "b": [0.4188, 0.4381, 0.45, 0.4595]}, {"w": "can", "b": [0.4562, 0.4381, 0.4855, 0.4595]}, {"w": "set", "b": [0.4916, 0.4381, 0.5145, 0.4595]}, {"w": "shuffle=False", "b": [0.5206, 0.4413, 0.6493, 0.4564]}, {"w": "if", "b": [0.6554, 0.4381, 0.6671, 0.4595]}, {"w": "you", "b": [0.6733, 0.4381, 0.7045, 0.4595]}, {"w": "do", "b": [0.7106, 0.4381, 0.7323, 0.4595]}, {"w": "not", "b": [0.7384, 0.4381, 0.7668, 0.4595]}, {"w": "want", "b": [0.7729, 0.4381, 0.8137, 0.4595]}, {"w": "that,", "b": [0.8198, 0.4381, 0.8571, 0.4595]}, {"w": "for", "b": [0.1429, 0.4571, 0.1674, 0.4786]}, {"w": "some", "b": [0.1721, 0.4571, 0.2163, 0.4786]}, {"w": "reason.", "b": [0.221, 0.4571, 0.2812, 0.4786]}]}, {"id": "b_8", "type": "paragraph", "text": "Next, we can call the interleave() method to read from 5 files at a time and inter‐ leave their lines (skipping the first line of each file, which is the header row, using the skip() method):", "words": [{"w": "Next,", "b": [0.1429, 0.4862, 0.1876, 0.5076]}, {"w": "we", "b": [0.1938, 0.4862, 0.2169, 0.5076]}, {"w": "can", "b": [0.2231, 0.4862, 0.2525, 0.5076]}, {"w": "call", "b": [0.2587, 0.4862, 0.2872, 0.5076]}, {"w": "the", "b": [0.2934, 0.4862, 0.3197, 0.5076]}, {"w": "interleave()", "b": [0.3259, 0.4893, 0.4446, 0.5044]}, {"w": "method", "b": [0.4508, 0.4862, 0.5158, 0.5076]}, {"w": "to", "b": [0.522, 0.4862, 0.539, 0.5076]}, {"w": "read", "b": [0.5452, 0.4862, 0.5819, 0.5076]}, {"w": "from", "b": [0.5881, 0.4862, 0.6297, 0.5076]}, {"w": "5", "b": [0.6359, 0.4862, 0.6459, 0.5076]}, {"w": "files", "b": [0.6521, 0.4862, 0.6856, 0.5076]}, {"w": "at", "b": [0.6918, 0.4862, 0.7069, 0.5076]}, {"w": "a", "b": [0.7131, 0.4862, 0.7222, 0.5076]}, {"w": "time", "b": [0.7284, 0.4862, 0.7663, 0.5076]}, {"w": "and", "b": [0.7725, 0.4862, 0.804, 0.5076]}, {"w": "inter‐", "b": [0.8102, 0.4862, 0.8572, 0.5076]}, {"w": "leave", "b": [0.1429, 0.5052, 0.1843, 0.5266]}, {"w": "their", "b": [0.1895, 0.5052, 0.2292, 0.5266]}, {"w": "lines", "b": [0.2344, 0.5052, 0.2732, 0.5266]}, {"w": "(skipping", "b": [0.2784, 0.5052, 0.3577, 0.5266]}, {"w": "the", "b": [0.363, 0.5052, 0.3893, 0.5266]}, {"w": "first", "b": [0.3946, 0.5052, 0.4281, 0.5266]}, {"w": "line", "b": [0.4333, 0.5052, 0.4644, 0.5266]}, {"w": "of", "b": [0.4697, 0.5052, 0.4865, 0.5266]}, {"w": "each", "b": [0.4917, 0.5052, 0.5297, 0.5266]}, {"w": "file,", "b": [0.5349, 0.5052, 0.5655, 0.5266]}, {"w": "which", "b": [0.5708, 0.5052, 0.6217, 0.5266]}, {"w": "is", "b": [0.627, 0.5052, 0.6402, 0.5266]}, {"w": "the", "b": [0.6455, 0.5052, 0.6718, 0.5266]}, {"w": "header", "b": [0.677, 0.5052, 0.7338, 0.5266]}, {"w": "row,", "b": [0.739, 0.5052, 0.7749, 0.5266]}, {"w": "using", "b": [0.7801, 0.5052, 0.8256, 0.5266]}, {"w": "the", "b": [0.8308, 0.5052, 0.8571, 0.5266]}, {"w": "skip()", "b": [0.1429, 0.5283, 0.2022, 0.5434]}, {"w": "method):", "b": [0.207, 0.5252, 0.2839, 0.5466]}]}, {"id": "b_9", "type": "paragraph", "text": "n_readers = 5 dataset = filepath_dataset.interleave( lambda filepath: tf.data.TextLineDataset(filepath).skip(1), cycle_length=n_readers)", "words": [{"w": "n_readers", "b": [0.1766, 0.5571, 0.2525, 0.57]}, {"w": "=", "b": [0.2609, 0.5571, 0.2693, 0.57]}, {"w": "5", "b": [0.2778, 0.5571, 0.2862, 0.57]}, {"w": "dataset", "b": [0.1766, 0.5725, 0.2356, 0.5854]}, {"w": "=", "b": [0.244, 0.5725, 0.2525, 0.5854]}, {"w": "filepath_dataset.interleave(", "b": [0.2609, 0.5725, 0.497, 0.5854]}, {"w": "lambda", "b": [0.2103, 0.588, 0.2609, 0.6008]}, {"w": "filepath:", "b": [0.2693, 0.588, 0.3452, 0.6008]}, {"w": "tf.data.TextLineDataset(filepath).skip(1),", "b": [0.3537, 0.588, 0.7078, 0.6008]}, {"w": "cycle_length=n_readers)", "b": [0.2103, 0.6034, 0.4043, 0.6162]}]}, {"id": "b_10", "type": "paragraph", "text": "The interleave() method will create a dataset that will pull 5 file paths from the filepath_dataset, and for each one it will call the function we gave it (a lambda in this example) to create a new dataset, in this case a TextLineDataset. It will then cycle through these 5 datasets, reading one line at a time from each until all datasets are out of items. Then it will get the next 5 file paths from the filepath_dataset, and interleave them the same way, and so on until it runs out of file paths.", "words": [{"w": "The", "b": [0.1429, 0.6249, 0.1757, 0.6463]}, {"w": "interleave()", "b": [0.1833, 0.6281, 0.3021, 0.6432]}, {"w": "method", "b": [0.3097, 0.6249, 0.3747, 0.6463]}, {"w": "will", "b": [0.3823, 0.6249, 0.4127, 0.6463]}, {"w": "create", "b": [0.4203, 0.6249, 0.4697, 0.6463]}, {"w": "a", "b": [0.4773, 0.6249, 0.4864, 0.6463]}, {"w": "dataset", "b": [0.4941, 0.6249, 0.5522, 0.6463]}, {"w": "that", "b": [0.5598, 0.6249, 0.5924, 0.6463]}, {"w": "will", "b": [0.6, 0.6249, 0.6304, 0.6463]}, {"w": "pull", "b": [0.638, 0.6249, 0.6705, 0.6463]}, {"w": "5", "b": [0.6781, 0.6249, 0.6881, 0.6463]}, {"w": "file", "b": [0.6957, 0.6249, 0.7216, 0.6463]}, {"w": "paths", "b": [0.7292, 0.6249, 0.774, 0.6463]}, {"w": "from", "b": [0.7816, 0.6249, 0.8232, 0.6463]}, {"w": "the", "b": [0.8308, 0.6249, 0.8572, 0.6463]}, {"w": "filepath_dataset,", "b": [0.1428, 0.6449, 0.3059, 0.6663]}, {"w": "and", "b": [0.3119, 0.6449, 0.3435, 0.6663]}, {"w": "for", "b": [0.3495, 0.6449, 0.374, 0.6663]}, {"w": "each", "b": [0.38, 0.6449, 0.418, 0.6663]}, {"w": "one", "b": [0.424, 0.6449, 0.4548, 0.6663]}, {"w": "it", "b": [0.4609, 0.6449, 0.4728, 0.6663]}, {"w": "will", "b": [0.4788, 0.6449, 0.5092, 0.6663]}, {"w": "call", "b": [0.5152, 0.6449, 0.5437, 0.6663]}, {"w": "the", "b": [0.5497, 0.6449, 0.576, 0.6663]}, {"w": "function", "b": [0.5821, 0.6449, 0.6535, 0.6663]}, {"w": "we", "b": [0.6595, 0.6449, 0.6826, 0.6663]}, {"w": "gave", "b": [0.6886, 0.6449, 0.7256, 0.6663]}, {"w": "it", "b": [0.7316, 0.6449, 0.7436, 0.6663]}, {"w": "(a", "b": [0.7496, 0.6449, 0.7659, 0.6663]}, {"w": "lambda", "b": [0.7719, 0.6449, 0.8341, 0.6663]}, {"w": "in", "b": [0.8402, 0.6449, 0.8571, 0.6663]}, {"w": "this", "b": [0.1429, 0.6648, 0.1736, 0.6862]}, {"w": "example)", "b": [0.1813, 0.6648, 0.2581, 0.6862]}, {"w": "to", "b": [0.2659, 0.6648, 0.2828, 0.6862]}, {"w": "create", "b": [0.2906, 0.6648, 0.34, 0.6862]}, {"w": "a", "b": [0.3477, 0.6648, 0.3569, 0.6862]}, {"w": "new", "b": [0.3646, 0.6648, 0.3992, 0.6862]}, {"w": "dataset,", "b": [0.4069, 0.6648, 0.4698, 0.6862]}, {"w": "in", "b": [0.4775, 0.6648, 0.4945, 0.6862]}, {"w": "this", "b": [0.5023, 0.6648, 0.533, 0.6862]}, {"w": "case", "b": [0.5408, 0.6648, 0.5752, 0.6862]}, {"w": "a", "b": [0.583, 0.6648, 0.5921, 0.6862]}, {"w": "TextLineDataset.", "b": [0.5999, 0.6648, 0.7531, 0.6862]}, {"w": "It", "b": [0.7608, 0.6648, 0.7735, 0.6862]}, {"w": "will", "b": [0.7813, 0.6648, 0.8117, 0.6862]}, {"w": "then", "b": [0.8194, 0.6648, 0.8572, 0.6862]}, {"w": "cycle", "b": [0.1429, 0.6839, 0.1842, 0.7053]}, {"w": "through", "b": [0.1902, 0.6839, 0.2579, 0.7053]}, {"w": "these", "b": [0.264, 0.6839, 0.3068, 0.7053]}, {"w": "5", "b": [0.3128, 0.6839, 0.3228, 0.7053]}, {"w": "datasets,", "b": [0.3288, 0.6839, 0.3993, 0.7053]}, {"w": "reading", "b": [0.4053, 0.6839, 0.4688, 0.7053]}, {"w": "one", "b": [0.4748, 0.6839, 0.5056, 0.7053]}, {"w": "line", "b": [0.5117, 0.6839, 0.5428, 0.7053]}, {"w": "at", "b": [0.5488, 0.6839, 0.5639, 0.7053]}, {"w": "a", "b": [0.5699, 0.6839, 0.579, 0.7053]}, {"w": "time", "b": [0.585, 0.6839, 0.6229, 0.7053]}, {"w": "from", "b": [0.6289, 0.6839, 0.6705, 0.7053]}, {"w": "each", "b": [0.6765, 0.6839, 0.7144, 0.7053]}, {"w": "until", "b": [0.7204, 0.6839, 0.7597, 0.7053]}, {"w": "all", "b": [0.7657, 0.6839, 0.7854, 0.7053]}, {"w": "datasets", "b": [0.7914, 0.6839, 0.8571, 0.7053]}, {"w": "are", "b": [0.1429, 0.7038, 0.1686, 0.7252]}, {"w": "out", "b": [0.1733, 0.7038, 0.2014, 0.7252]}, {"w": "of", "b": [0.2061, 0.7038, 0.2229, 0.7252]}, {"w": "items.", "b": [0.2276, 0.7038, 0.2779, 0.7252]}, {"w": "Then", "b": [0.2826, 0.7038, 0.3268, 0.7252]}, {"w": "it", "b": [0.3315, 0.7038, 0.3435, 0.7252]}, {"w": "will", "b": [0.3482, 0.7038, 0.3786, 0.7252]}, {"w": "get", "b": [0.3833, 0.7038, 0.4083, 0.7252]}, {"w": "the", "b": [0.413, 0.7038, 0.4394, 0.7252]}, {"w": "next", "b": [0.4441, 0.7038, 0.4805, 0.7252]}, {"w": "5", "b": [0.4852, 0.7038, 0.4952, 0.7252]}, {"w": "file", "b": [0.5, 0.7038, 0.5259, 0.7252]}, {"w": "paths", "b": [0.5306, 0.7038, 0.5754, 0.7252]}, {"w": "from", "b": [0.5801, 0.7038, 0.6217, 0.7252]}, {"w": "the", "b": [0.6264, 0.7038, 0.6527, 0.7252]}, {"w": "filepath_dataset,", "b": [0.6578, 0.7038, 0.8209, 0.7252]}, {"w": "and", "b": [0.8256, 0.7038, 0.8571, 0.7252]}, {"w": "interleave", "b": [0.1429, 0.7228, 0.2238, 0.7443]}, {"w": "them", "b": [0.2285, 0.7228, 0.2719, 0.7443]}, {"w": "the", "b": [0.2766, 0.7228, 0.303, 0.7443]}, {"w": "same", "b": [0.3077, 0.7228, 0.3504, 0.7443]}, {"w": "way,", "b": [0.3551, 0.7228, 0.391, 0.7443]}, {"w": "and", "b": [0.3957, 0.7228, 0.4272, 0.7443]}, {"w": "so", "b": [0.432, 0.7228, 0.4502, 0.7443]}, {"w": "on", "b": [0.455, 0.7228, 0.477, 0.7443]}, {"w": "until", "b": [0.4817, 0.7228, 0.521, 0.7443]}, {"w": "it", "b": [0.5257, 0.7228, 0.5377, 0.7443]}, {"w": "runs", "b": [0.5424, 0.7228, 0.5802, 0.7443]}, {"w": "out", "b": [0.5849, 0.7228, 0.613, 0.7443]}, {"w": "of", "b": [0.6177, 0.7228, 0.6345, 0.7443]}, {"w": "file", "b": [0.6392, 0.7228, 0.6651, 0.7443]}, {"w": "paths.", "b": [0.6698, 0.7228, 0.7194, 0.7443]}]}, {"id": "b_11", "type": "paragraph", "text": "For interleaving to work best, it is preferable to have files of identi‐ cal length, or else the end of the longest files will not be interleaved.", "words": [{"w": "For", "b": [0.2714, 0.7648, 0.2979, 0.7844]}, {"w": "interleaving", "b": [0.3029, 0.7648, 0.3933, 0.7844]}, {"w": "to", "b": [0.3983, 0.7648, 0.4138, 0.7844]}, {"w": "work", "b": [0.4188, 0.7648, 0.4581, 0.7844]}, {"w": "best,", "b": [0.4631, 0.7648, 0.498, 0.7844]}, {"w": "it", "b": [0.503, 0.7648, 0.514, 0.7844]}, {"w": "is", "b": [0.519, 0.7648, 0.5311, 0.7844]}, {"w": "preferable", "b": [0.5361, 0.7648, 0.613, 0.7844]}, {"w": "to", "b": [0.618, 0.7648, 0.6335, 0.7844]}, {"w": "have", "b": [0.6386, 0.7648, 0.6737, 0.7844]}, {"w": "files", "b": [0.6787, 0.7648, 0.7093, 0.7844]}, {"w": "of", "b": [0.7143, 0.7648, 0.7297, 0.7844]}, {"w": "identi‐", "b": [0.7347, 0.7648, 0.7857, 0.7844]}, {"w": "cal", "b": [0.2714, 0.7822, 0.2926, 0.8018]}, {"w": "length,", "b": [0.297, 0.7822, 0.3495, 0.8018]}, {"w": "or", "b": [0.3539, 0.7822, 0.3706, 0.8018]}, {"w": "else", "b": [0.375, 0.7822, 0.403, 0.8018]}, {"w": "the", "b": [0.4073, 0.7822, 0.4314, 0.8018]}, {"w": "end", "b": [0.4357, 0.7822, 0.4643, 0.8018]}, {"w": "of", "b": [0.4686, 0.7822, 0.4839, 0.8018]}, {"w": "the", "b": [0.4883, 0.7822, 0.5123, 0.8018]}, {"w": "longest", "b": [0.5167, 0.7822, 0.5714, 0.8018]}, {"w": "files", "b": [0.5757, 0.7822, 0.6064, 0.8018]}, {"w": "will", "b": [0.6107, 0.7822, 0.6385, 0.8018]}, {"w": "not", "b": [0.6428, 0.7822, 0.6688, 0.8018]}, {"w": "be", "b": [0.6731, 0.7822, 0.6909, 0.8018]}, {"w": "interleaved.", "b": [0.6952, 0.7822, 0.7836, 0.8018]}]}, {"id": "b_12", "type": "paragraph", "text": "408 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "408", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 435, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "By default, interleave() does not use parallelism, it just reads one line at a time from each file, sequentially. However, if you want it to actually read files in parallel, you can set the num_parallel_calls argument to the number of threads you want. You can even set it to tf.data.experimental.AUTOTUNE to make TensorFlow choose the right number of threads dynamically based on the available CPU (however, this is an experimental feature for now). Let’s look at what the dataset contains now:", "words": [{"w": "By", "b": [0.1429, 0.08, 0.1647, 0.1014]}, {"w": "default,", "b": [0.1725, 0.08, 0.2347, 0.1014]}, {"w": "interleave()", "b": [0.2426, 0.0831, 0.3613, 0.0982]}, {"w": "does", "b": [0.3692, 0.08, 0.4073, 0.1014]}, {"w": "not", "b": [0.4152, 0.08, 0.4436, 0.1014]}, {"w": "use", "b": [0.4514, 0.08, 0.479, 0.1014]}, {"w": "parallelism,", "b": [0.4868, 0.08, 0.5835, 0.1014]}, {"w": "it", "b": [0.5913, 0.08, 0.6033, 0.1014]}, {"w": "just", "b": [0.6111, 0.08, 0.6415, 0.1014]}, {"w": "reads", "b": [0.6494, 0.08, 0.6938, 0.1014]}, {"w": "one", "b": [0.7016, 0.08, 0.7325, 0.1014]}, {"w": "line", "b": [0.7404, 0.08, 0.7715, 0.1014]}, {"w": "at", "b": [0.7793, 0.08, 0.7944, 0.1014]}, {"w": "a", "b": [0.8023, 0.08, 0.8114, 0.1014]}, {"w": "time", "b": [0.8193, 0.08, 0.8571, 0.1014]}, {"w": "from", "b": [0.1429, 0.099, 0.1844, 0.1204]}, {"w": "each", "b": [0.191, 0.099, 0.2289, 0.1204]}, {"w": "file,", "b": [0.2355, 0.099, 0.2661, 0.1204]}, {"w": "sequentially.", "b": [0.2727, 0.099, 0.3752, 0.1204]}, {"w": "However,", "b": [0.3817, 0.099, 0.4606, 0.1204]}, {"w": "if", "b": [0.4672, 0.099, 0.4789, 0.1204]}, {"w": "you", "b": [0.4855, 0.099, 0.5167, 0.1204]}, {"w": "want", "b": [0.5233, 0.099, 0.5641, 0.1204]}, {"w": "it", "b": [0.5706, 0.099, 0.5826, 0.1204]}, {"w": "to", "b": [0.5891, 0.099, 0.6061, 0.1204]}, {"w": "actually", "b": [0.6127, 0.099, 0.6773, 0.1204]}, {"w": "read", "b": [0.6839, 0.099, 0.7206, 0.1204]}, {"w": "files", "b": [0.7272, 0.099, 0.7607, 0.1204]}, {"w": "in", "b": [0.7672, 0.099, 0.7842, 0.1204]}, {"w": "parallel,", "b": [0.7908, 0.099, 0.8571, 0.1204]}, {"w": "you", "b": [0.1429, 0.119, 0.1741, 0.1404]}, {"w": "can", "b": [0.1808, 0.119, 0.2102, 0.1404]}, {"w": "set", "b": [0.2169, 0.119, 0.2397, 0.1404]}, {"w": "the", "b": [0.2464, 0.119, 0.2728, 0.1404]}, {"w": "num_parallel_calls", "b": [0.2795, 0.1221, 0.4576, 0.1372]}, {"w": "argument", "b": [0.4643, 0.119, 0.5452, 0.1404]}, {"w": "to", "b": [0.5519, 0.119, 0.5689, 0.1404]}, {"w": "the", "b": [0.5756, 0.119, 0.6019, 0.1404]}, {"w": "number", "b": [0.6086, 0.119, 0.6749, 0.1404]}, {"w": "of", "b": [0.6816, 0.119, 0.6984, 0.1404]}, {"w": "threads", "b": [0.7051, 0.119, 0.767, 0.1404]}, {"w": "you", "b": [0.7737, 0.119, 0.8049, 0.1404]}, {"w": "want.", "b": [0.8116, 0.119, 0.8572, 0.1404]}, {"w": "You", "b": [0.1429, 0.1389, 0.1752, 0.1603]}, {"w": "can", "b": [0.1809, 0.1389, 0.2102, 0.1603]}, {"w": "even", "b": [0.2159, 0.1389, 0.2547, 0.1603]}, {"w": "set", "b": [0.2603, 0.1389, 0.2832, 0.1603]}, {"w": "it", "b": [0.2889, 0.1389, 0.3008, 0.1603]}, {"w": "to", "b": [0.3065, 0.1389, 0.3235, 0.1603]}, {"w": "tf.data.experimental.AUTOTUNE", "b": [0.3291, 0.1421, 0.6161, 0.1572]}, {"w": "to", "b": [0.6218, 0.1389, 0.6388, 0.1603]}, {"w": "make", "b": [0.6445, 0.1389, 0.6899, 0.1603]}, {"w": "TensorFlow", "b": [0.6955, 0.1389, 0.7938, 0.1603]}, {"w": "choose", "b": [0.7995, 0.1389, 0.8571, 0.1603]}, {"w": "the", "b": [0.1429, 0.1579, 0.1692, 0.1794]}, {"w": "right", "b": [0.1743, 0.1579, 0.2145, 0.1794]}, {"w": "number", "b": [0.2196, 0.1579, 0.2859, 0.1794]}, {"w": "of", "b": [0.291, 0.1579, 0.3078, 0.1794]}, {"w": "threads", "b": [0.3129, 0.1579, 0.3748, 0.1794]}, {"w": "dynamically", "b": [0.3799, 0.1579, 0.4817, 0.1794]}, {"w": "based", "b": [0.4868, 0.1579, 0.534, 0.1794]}, {"w": "on", "b": [0.5392, 0.1579, 0.5612, 0.1794]}, {"w": "the", "b": [0.5663, 0.1579, 0.5926, 0.1794]}, {"w": "available", "b": [0.5978, 0.1579, 0.67, 0.1794]}, {"w": "CPU", "b": [0.6752, 0.1579, 0.7161, 0.1794]}, {"w": "(however,", "b": [0.7212, 0.1579, 0.803, 0.1794]}, {"w": "this", "b": [0.8081, 0.1579, 0.8388, 0.1794]}, {"w": "is", "b": [0.8439, 0.1579, 0.8571, 0.1794]}, {"w": "an", "b": [0.1428, 0.177, 0.1634, 0.1984]}, {"w": "experimental", "b": [0.1681, 0.177, 0.2776, 0.1984]}, {"w": "feature", "b": [0.2823, 0.177, 0.3401, 0.1984]}, {"w": "for", "b": [0.3448, 0.177, 0.3693, 0.1984]}, {"w": "now).", "b": [0.3741, 0.177, 0.4223, 0.1984]}, {"w": "Let’s", "b": [0.427, 0.177, 0.4632, 0.1984]}, {"w": "look", "b": [0.4679, 0.177, 0.5048, 0.1984]}, {"w": "at", "b": [0.5095, 0.177, 0.5246, 0.1984]}, {"w": "what", "b": [0.5293, 0.177, 0.5698, 0.1984]}, {"w": "the", "b": [0.5746, 0.177, 0.6009, 0.1984]}, {"w": "dataset", "b": [0.6056, 0.177, 0.6637, 0.1984]}, {"w": "contains", "b": [0.6685, 0.177, 0.739, 0.1984]}, {"w": "now:", "b": [0.7438, 0.177, 0.7855, 0.1984]}]}, {"id": "b_1", "type": "paragraph", "text": ">>> for line in dataset.take(5): ... print(line.numpy()) ... b'4.2083,44.0,5.3232,0.9171,846.0,2.3370,37.47,-122.2,2.782' b'4.1812,52.0,5.7013,0.9965,692.0,2.4027,33.73,-118.31,3.215' b'3.6875,44.0,4.5244,0.9930,457.0,3.1958,34.04,-118.15,1.625' b'3.3456,37.0,4.5140,0.9084,458.0,3.2253,36.67,-121.7,2.526' b'3.5214,15.0,3.0499,1.1065,1447.0,1.6059,37.63,-122.43,1.442'", "words": [{"w": ">>>", "b": [0.1766, 0.209, 0.2019, 0.2218]}, {"w": "for", "b": [0.2103, 0.209, 0.2356, 0.2218]}, {"w": "line", "b": [0.244, 0.209, 0.2778, 0.2218]}, {"w": "in", "b": [0.2862, 0.209, 0.3031, 0.2218]}, {"w": "dataset.take(5):", "b": [0.3115, 0.209, 0.4464, 0.2218]}, {"w": "...", "b": [0.1766, 0.2244, 0.2019, 0.2372]}, {"w": "print(line.numpy())", "b": [0.244, 0.2244, 0.4043, 0.2372]}, {"w": "...", "b": [0.1766, 0.2398, 0.2019, 0.2527]}, {"w": "b'4.2083,44.0,5.3232,0.9171,846.0,2.3370,37.47,-122.2,2.782'", "b": [0.1766, 0.2552, 0.6825, 0.2681]}, {"w": "b'4.1812,52.0,5.7013,0.9965,692.0,2.4027,33.73,-118.31,3.215'", "b": [0.1766, 0.2706, 0.691, 0.2835]}, {"w": "b'3.6875,44.0,4.5244,0.9930,457.0,3.1958,34.04,-118.15,1.625'", "b": [0.1766, 0.2861, 0.691, 0.2989]}, {"w": "b'3.3456,37.0,4.5140,0.9084,458.0,3.2253,36.67,-121.7,2.526'", "b": [0.1766, 0.3015, 0.6825, 0.3143]}, {"w": "b'3.5214,15.0,3.0499,1.1065,1447.0,1.6059,37.63,-122.43,1.442'", "b": [0.1766, 0.3169, 0.6994, 0.3298]}]}, {"id": "b_2", "type": "paragraph", "text": "These are the first rows (ignoring the header row) of 5 CSV files, chosen randomly. Looks good! But as you can see, these are just byte strings, we need to parse them, and also scale the data.", "words": [{"w": "These", "b": [0.1429, 0.3375, 0.1922, 0.3589]}, {"w": "are", "b": [0.1986, 0.3375, 0.2244, 0.3589]}, {"w": "the", "b": [0.2308, 0.3375, 0.2572, 0.3589]}, {"w": "first", "b": [0.2636, 0.3375, 0.2971, 0.3589]}, {"w": "rows", "b": [0.3035, 0.3375, 0.3438, 0.3589]}, {"w": "(ignoring", "b": [0.3503, 0.3375, 0.4293, 0.3589]}, {"w": "the", "b": [0.4357, 0.3375, 0.4621, 0.3589]}, {"w": "header", "b": [0.4685, 0.3375, 0.5252, 0.3589]}, {"w": "row)", "b": [0.5317, 0.3375, 0.5715, 0.3589]}, {"w": "of", "b": [0.578, 0.3375, 0.5948, 0.3589]}, {"w": "5", "b": [0.6012, 0.3375, 0.6112, 0.3589]}, {"w": "CSV", "b": [0.6177, 0.3375, 0.656, 0.3589]}, {"w": "files,", "b": [0.6625, 0.3375, 0.7008, 0.3589]}, {"w": "chosen", "b": [0.7072, 0.3375, 0.7657, 0.3589]}, {"w": "randomly.", "b": [0.7721, 0.3375, 0.8571, 0.3589]}, {"w": "Looks", "b": [0.1429, 0.3566, 0.1933, 0.378]}, {"w": "good!", "b": [0.2002, 0.3566, 0.248, 0.378]}, {"w": "But", "b": [0.2549, 0.3566, 0.2846, 0.378]}, {"w": "as", "b": [0.2915, 0.3566, 0.3083, 0.378]}, {"w": "you", "b": [0.3153, 0.3566, 0.3465, 0.378]}, {"w": "can", "b": [0.3535, 0.3566, 0.3828, 0.378]}, {"w": "see,", "b": [0.3898, 0.3566, 0.4199, 0.378]}, {"w": "these", "b": [0.4268, 0.3566, 0.4697, 0.378]}, {"w": "are", "b": [0.4766, 0.3566, 0.5023, 0.378]}, {"w": "just", "b": [0.5093, 0.3566, 0.5397, 0.378]}, {"w": "byte", "b": [0.5466, 0.3566, 0.582, 0.378]}, {"w": "strings,", "b": [0.5889, 0.3566, 0.6498, 0.378]}, {"w": "we", "b": [0.6567, 0.3566, 0.6798, 0.378]}, {"w": "need", "b": [0.6868, 0.3566, 0.7269, 0.378]}, {"w": "to", "b": [0.7338, 0.3566, 0.7508, 0.378]}, {"w": "parse", "b": [0.7578, 0.3566, 0.8021, 0.378]}, {"w": "them,", "b": [0.809, 0.3566, 0.8571, 0.378]}, {"w": "and", "b": [0.1429, 0.3756, 0.1744, 0.397]}, {"w": "also", "b": [0.1791, 0.3756, 0.2118, 0.397]}, {"w": "scale", "b": [0.2165, 0.3756, 0.2563, 0.397]}, {"w": "the", "b": [0.261, 0.3756, 0.2873, 0.397]}, {"w": "data.", "b": [0.2921, 0.3756, 0.3321, 0.397]}]}, {"id": "b_3", "type": "paragraph", "text": "Preprocessing the Data", "words": [{"w": "Preprocessing", "b": [0.1429, 0.4098, 0.2866, 0.4384]}, {"w": "the", "b": [0.2915, 0.4098, 0.3264, 0.4384]}, {"w": "Data", "b": [0.3313, 0.4098, 0.3797, 0.4384]}]}, {"id": "b_4", "type": "paragraph", "text": "Let’s implement a small function that will perform this preprocessing:", "words": [{"w": "Let’s", "b": [0.1429, 0.4443, 0.179, 0.4657]}, {"w": "implement", "b": [0.1837, 0.4443, 0.2743, 0.4657]}, {"w": "a", "b": [0.279, 0.4443, 0.2882, 0.4657]}, {"w": "small", "b": [0.2929, 0.4443, 0.3373, 0.4657]}, {"w": "function", "b": [0.342, 0.4443, 0.4134, 0.4657]}, {"w": "that", "b": [0.4182, 0.4443, 0.4507, 0.4657]}, {"w": "will", "b": [0.4555, 0.4443, 0.4859, 0.4657]}, {"w": "perform", "b": [0.4906, 0.4443, 0.5597, 0.4657]}, {"w": "this", "b": [0.5644, 0.4443, 0.5951, 0.4657]}, {"w": "preprocessing:", "b": [0.5999, 0.4443, 0.7211, 0.4657]}]}, {"id": "b_5", "type": "paragraph", "text": "X_mean, X_std = [...] # mean and scale of each feature in the training set n_inputs = 8", "words": [{"w": "X_mean,", "b": [0.1766, 0.4762, 0.2356, 0.4891]}, {"w": "X_std", "b": [0.244, 0.4762, 0.2862, 0.4891]}, {"w": "=", "b": [0.2946, 0.4762, 0.3031, 0.4891]}, {"w": "[...]", "b": [0.3115, 0.4762, 0.3537, 0.4891]}, {"w": "#", "b": [0.3621, 0.4762, 0.3705, 0.4891]}, {"w": "mean", "b": [0.379, 0.4762, 0.4127, 0.4891]}, {"w": "and", "b": [0.4211, 0.4762, 0.4464, 0.4891]}, {"w": "scale", "b": [0.4549, 0.4762, 0.497, 0.4891]}, {"w": "of", "b": [0.5055, 0.4762, 0.5223, 0.4891]}, {"w": "each", "b": [0.5308, 0.4762, 0.5645, 0.4891]}, {"w": "feature", "b": [0.5729, 0.4762, 0.6319, 0.4891]}, {"w": "in", "b": [0.6404, 0.4762, 0.6572, 0.4891]}, {"w": "the", "b": [0.6657, 0.4762, 0.691, 0.4891]}, {"w": "training", "b": [0.6994, 0.4762, 0.7669, 0.4891]}, {"w": "set", "b": [0.7753, 0.4762, 0.8006, 0.4891]}, {"w": "n_inputs", "b": [0.1766, 0.4917, 0.244, 0.5045]}, {"w": "=", "b": [0.2525, 0.4917, 0.2609, 0.5045]}, {"w": "8", "b": [0.2693, 0.4917, 0.2778, 0.5045]}]}, {"id": "b_6", "type": "paragraph", "text": "def preprocess(line): defs = [0.] * n_inputs + [tf.constant([], dtype=tf.float32)] fields = tf.io.decode_csv(line, record_defaults=defs) x = tf.stack(fields[:-1]) y = tf.stack(fields[-1:]) return (x - X_mean) / X_std, y", "words": [{"w": "def", "b": [0.1766, 0.5225, 0.2019, 0.5354]}, {"w": "preprocess(line):", "b": [0.2103, 0.5225, 0.3537, 0.5354]}, {"w": "defs", "b": [0.1935, 0.5379, 0.2272, 0.5508]}, {"w": "=", "b": [0.2356, 0.5379, 0.244, 0.5508]}, {"w": "[0.]", "b": [0.2525, 0.5379, 0.2862, 0.5508]}, {"w": "*", "b": [0.2946, 0.5379, 0.3031, 0.5508]}, {"w": "n_inputs", "b": [0.3115, 0.5379, 0.379, 0.5508]}, {"w": "+", "b": [0.3874, 0.5379, 0.3958, 0.5508]}, {"w": "[tf.constant([],", "b": [0.4043, 0.5379, 0.5392, 0.5508]}, {"w": "dtype=tf.float32)]", "b": [0.5476, 0.5379, 0.6994, 0.5508]}, {"w": "fields", "b": [0.1935, 0.5533, 0.244, 0.5662]}, {"w": "=", "b": [0.2525, 0.5533, 0.2609, 0.5662]}, {"w": "tf.io.decode_csv(line,", "b": [0.2693, 0.5533, 0.4549, 0.5662]}, {"w": "record_defaults=defs)", "b": [0.4633, 0.5533, 0.6404, 0.5662]}, {"w": "x", "b": [0.1935, 0.5688, 0.2019, 0.5816]}, {"w": "=", "b": [0.2103, 0.5688, 0.2187, 0.5816]}, {"w": "tf.stack(fields[:-1])", "b": [0.2272, 0.5688, 0.4043, 0.5816]}, {"w": "y", "b": [0.1935, 0.5842, 0.2019, 0.597]}, {"w": "=", "b": [0.2103, 0.5842, 0.2187, 0.597]}, {"w": "tf.stack(fields[-1:])", "b": [0.2272, 0.5842, 0.4043, 0.597]}, {"w": "return", "b": [0.1935, 0.5996, 0.244, 0.6125]}, {"w": "(x", "b": [0.2525, 0.5996, 0.2693, 0.6125]}, {"w": "-", "b": [0.2778, 0.5996, 0.2862, 0.6125]}, {"w": "X_mean)", "b": [0.2946, 0.5996, 0.3537, 0.6125]}, {"w": "/", "b": [0.3621, 0.5996, 0.3705, 0.6125]}, {"w": "X_std,", "b": [0.379, 0.5996, 0.4296, 0.6125]}, {"w": "y", "b": [0.438, 0.5996, 0.4464, 0.6125]}]}, {"id": "b_7", "type": "paragraph", "text": "Let’s walk through this code:", "words": [{"w": "Let’s", "b": [0.1429, 0.6202, 0.179, 0.6417]}, {"w": "walk", "b": [0.1838, 0.6202, 0.2228, 0.6417]}, {"w": "through", "b": [0.2275, 0.6202, 0.2953, 0.6417]}, {"w": "this", "b": [0.3, 0.6202, 0.3307, 0.6417]}, {"w": "code:", "b": [0.3354, 0.6202, 0.3795, 0.6417]}]}, {"id": "b_8", "type": "paragraph", "text": "• First, we assume that you have precomputed the mean and standard deviation of each feature in the training set. X_mean and X_std are just 1D tensors (or NumPy arrays) containing 8 floats, one per input feature.", "words": [{"w": "•", "b": [0.16, 0.6544, 0.1682, 0.6758]}, {"w": "First,", "b": [0.1786, 0.6544, 0.2216, 0.6758]}, {"w": "we", "b": [0.227, 0.6544, 0.2502, 0.6758]}, {"w": "assume", "b": [0.2555, 0.6544, 0.317, 0.6758]}, {"w": "that", "b": [0.3223, 0.6544, 0.3549, 0.6758]}, {"w": "you", "b": [0.3603, 0.6544, 0.3916, 0.6758]}, {"w": "have", "b": [0.3969, 0.6544, 0.4353, 0.6758]}, {"w": "precomputed", "b": [0.4407, 0.6544, 0.5525, 0.6758]}, {"w": "the", "b": [0.5579, 0.6544, 0.5842, 0.6758]}, {"w": "mean", "b": [0.5896, 0.6544, 0.6361, 0.6758]}, {"w": "and", "b": [0.6414, 0.6544, 0.673, 0.6758]}, {"w": "standard", "b": [0.6784, 0.6544, 0.7518, 0.6758]}, {"w": "deviation", "b": [0.7572, 0.6544, 0.835, 0.6758]}, {"w": "of", "b": [0.8403, 0.6544, 0.8571, 0.6758]}, {"w": "each", "b": [0.1786, 0.6743, 0.2165, 0.6958]}, {"w": "feature", "b": [0.2217, 0.6743, 0.2795, 0.6958]}, {"w": "in", "b": [0.2847, 0.6743, 0.3017, 0.6958]}, {"w": "the", "b": [0.3069, 0.6743, 0.3333, 0.6958]}, {"w": "training", "b": [0.3385, 0.6743, 0.4054, 0.6958]}, {"w": "set.", "b": [0.4107, 0.6743, 0.4383, 0.6958]}, {"w": "X_mean", "b": [0.4435, 0.6775, 0.5029, 0.6926]}, {"w": "and", "b": [0.5081, 0.6743, 0.5397, 0.6958]}, {"w": "X_std", "b": [0.5449, 0.6775, 0.5944, 0.6926]}, {"w": "are", "b": [0.5996, 0.6743, 0.6253, 0.6958]}, {"w": "just", "b": [0.6305, 0.6743, 0.6609, 0.6958]}, {"w": "1D", "b": [0.6662, 0.6743, 0.6915, 0.6958]}, {"w": "tensors", "b": [0.6967, 0.6743, 0.757, 0.6958]}, {"w": "(or", "b": [0.7622, 0.6743, 0.7877, 0.6958]}, {"w": "NumPy", "b": [0.793, 0.6743, 0.8571, 0.6958]}, {"w": "arrays)", "b": [0.1786, 0.6934, 0.2364, 0.7148]}, {"w": "containing", "b": [0.2411, 0.6934, 0.3307, 0.7148]}, {"w": "8", "b": [0.3355, 0.6934, 0.3455, 0.7148]}, {"w": "floats,", "b": [0.3502, 0.6934, 0.3998, 0.7148]}, {"w": "one", "b": [0.4045, 0.6934, 0.4354, 0.7148]}, {"w": "per", "b": [0.4401, 0.6934, 0.4676, 0.7148]}, {"w": "input", "b": [0.4723, 0.6934, 0.5172, 0.7148]}, {"w": "feature.", "b": [0.522, 0.6934, 0.5845, 0.7148]}]}, {"id": "b_9", "type": "paragraph", "text": "• The preprocess() function takes one CSV line, and starts by parsing it. For this, it uses the tf.io.decode_csv() function, which takes two arguments: the first is the line to parse, and the second is an array containing the default value for each column in the CSV file. This tells TensorFlow not only the default value for each column, but also the number of columns and the type of each column. In this example, we tell it that all feature columns are floats and missing values should default to 0, but we provide an empty array of type tf.float32 as the default value for the last column (the target): this tells TensorFlow that this column con‐", "words": [{"w": "•", "b": [0.16, 0.7194, 0.1681, 0.7408]}, {"w": "The", "b": [0.1786, 0.7194, 0.2114, 0.7408]}, {"w": "preprocess()", "b": [0.2167, 0.7226, 0.3354, 0.7376]}, {"w": "function", "b": [0.3407, 0.7194, 0.4121, 0.7408]}, {"w": "takes", "b": [0.4173, 0.7194, 0.4596, 0.7408]}, {"w": "one", "b": [0.4649, 0.7194, 0.4958, 0.7408]}, {"w": "CSV", "b": [0.501, 0.7194, 0.5394, 0.7408]}, {"w": "line,", "b": [0.5447, 0.7194, 0.5805, 0.7408]}, {"w": "and", "b": [0.5858, 0.7194, 0.6173, 0.7408]}, {"w": "starts", "b": [0.6226, 0.7194, 0.6674, 0.7408]}, {"w": "by", "b": [0.6727, 0.7194, 0.6928, 0.7408]}, {"w": "parsing", "b": [0.6981, 0.7194, 0.7603, 0.7408]}, {"w": "it.", "b": [0.7655, 0.7194, 0.7822, 0.7408]}, {"w": "For", "b": [0.7875, 0.7194, 0.8164, 0.7408]}, {"w": "this,", "b": [0.8217, 0.7194, 0.8571, 0.7408]}, {"w": "it", "b": [0.1786, 0.7393, 0.1905, 0.7607]}, {"w": "uses", "b": [0.196, 0.7393, 0.2312, 0.7607]}, {"w": "the", "b": [0.2366, 0.7393, 0.263, 0.7607]}, {"w": "tf.io.decode_csv()", "b": [0.2684, 0.7425, 0.4465, 0.7576]}, {"w": "function,", "b": [0.452, 0.7393, 0.5281, 0.7607]}, {"w": "which", "b": [0.5336, 0.7393, 0.5845, 0.7607]}, {"w": "takes", "b": [0.5899, 0.7393, 0.6323, 0.7607]}, {"w": "two", "b": [0.6377, 0.7393, 0.669, 0.7607]}, {"w": "arguments:", "b": [0.6744, 0.7393, 0.7678, 0.7607]}, {"w": "the", "b": [0.7732, 0.7393, 0.7995, 0.7607]}, {"w": "first", "b": [0.805, 0.7393, 0.8385, 0.7607]}, {"w": "is", "b": [0.8439, 0.7393, 0.8572, 0.7607]}, {"w": "the", "b": [0.1786, 0.7584, 0.2049, 0.7798]}, {"w": "line", "b": [0.2104, 0.7584, 0.2415, 0.7798]}, {"w": "to", "b": [0.247, 0.7584, 0.264, 0.7798]}, {"w": "parse,", "b": [0.2694, 0.7584, 0.3185, 0.7798]}, {"w": "and", "b": [0.324, 0.7584, 0.3555, 0.7798]}, {"w": "the", "b": [0.361, 0.7584, 0.3873, 0.7798]}, {"w": "second", "b": [0.3928, 0.7584, 0.4512, 0.7798]}, {"w": "is", "b": [0.4567, 0.7584, 0.4699, 0.7798]}, {"w": "an", "b": [0.4754, 0.7584, 0.4959, 0.7798]}, {"w": "array", "b": [0.5014, 0.7584, 0.5443, 0.7798]}, {"w": "containing", "b": [0.5498, 0.7584, 0.6395, 0.7798]}, {"w": "the", "b": [0.645, 0.7584, 0.6713, 0.7798]}, {"w": "default", "b": [0.6768, 0.7584, 0.7342, 0.7798]}, {"w": "value", "b": [0.7397, 0.7584, 0.7837, 0.7798]}, {"w": "for", "b": [0.7892, 0.7584, 0.8137, 0.7798]}, {"w": "each", "b": [0.8192, 0.7584, 0.8571, 0.7798]}, {"w": "column", "b": [0.1786, 0.7774, 0.2428, 0.7988]}, {"w": "in", "b": [0.2484, 0.7774, 0.2653, 0.7988]}, {"w": "the", "b": [0.2709, 0.7774, 0.2972, 0.7988]}, {"w": "CSV", "b": [0.3028, 0.7774, 0.3411, 0.7988]}, {"w": "file.", "b": [0.3467, 0.7774, 0.3773, 0.7988]}, {"w": "This", "b": [0.3829, 0.7774, 0.4201, 0.7988]}, {"w": "tells", "b": [0.4256, 0.7774, 0.459, 0.7988]}, {"w": "TensorFlow", "b": [0.4646, 0.7774, 0.5628, 0.7988]}, {"w": "not", "b": [0.5684, 0.7774, 0.5968, 0.7988]}, {"w": "only", "b": [0.6023, 0.7774, 0.6392, 0.7988]}, {"w": "the", "b": [0.6447, 0.7774, 0.671, 0.7988]}, {"w": "default", "b": [0.6766, 0.7774, 0.7341, 0.7988]}, {"w": "value", "b": [0.7396, 0.7774, 0.7836, 0.7988]}, {"w": "for", "b": [0.7891, 0.7774, 0.8137, 0.7988]}, {"w": "each", "b": [0.8192, 0.7774, 0.8571, 0.7988]}, {"w": "column,", "b": [0.1786, 0.7965, 0.2475, 0.8179]}, {"w": "but", "b": [0.2548, 0.7965, 0.2828, 0.8179]}, {"w": "also", "b": [0.29, 0.7965, 0.3227, 0.8179]}, {"w": "the", "b": [0.3299, 0.7965, 0.3562, 0.8179]}, {"w": "number", "b": [0.3635, 0.7965, 0.4298, 0.8179]}, {"w": "of", "b": [0.437, 0.7965, 0.4538, 0.8179]}, {"w": "columns", "b": [0.461, 0.7965, 0.5329, 0.8179]}, {"w": "and", "b": [0.5401, 0.7965, 0.5716, 0.8179]}, {"w": "the", "b": [0.5789, 0.7965, 0.6052, 0.8179]}, {"w": "type", "b": [0.6124, 0.7965, 0.6481, 0.8179]}, {"w": "of", "b": [0.6553, 0.7965, 0.6721, 0.8179]}, {"w": "each", "b": [0.6793, 0.7965, 0.7173, 0.8179]}, {"w": "column.", "b": [0.7245, 0.7965, 0.7935, 0.8179]}, {"w": "In", "b": [0.8007, 0.7965, 0.8192, 0.8179]}, {"w": "this", "b": [0.8264, 0.7965, 0.8571, 0.8179]}, {"w": "example,", "b": [0.1786, 0.8155, 0.2529, 0.8369]}, {"w": "we", "b": [0.2595, 0.8155, 0.2826, 0.8369]}, {"w": "tell", "b": [0.2893, 0.8155, 0.315, 0.8369]}, {"w": "it", "b": [0.3217, 0.8155, 0.3336, 0.8369]}, {"w": "that", "b": [0.3403, 0.8155, 0.3729, 0.8369]}, {"w": "all", "b": [0.3795, 0.8155, 0.3992, 0.8369]}, {"w": "feature", "b": [0.4058, 0.8155, 0.4636, 0.8369]}, {"w": "columns", "b": [0.4703, 0.8155, 0.5421, 0.8369]}, {"w": "are", "b": [0.5488, 0.8155, 0.5745, 0.8369]}, {"w": "floats", "b": [0.5812, 0.8155, 0.626, 0.8369]}, {"w": "and", "b": [0.6326, 0.8155, 0.6642, 0.8369]}, {"w": "missing", "b": [0.6708, 0.8155, 0.7355, 0.8369]}, {"w": "values", "b": [0.7421, 0.8155, 0.7938, 0.8369]}, {"w": "should", "b": [0.8004, 0.8155, 0.8571, 0.8369]}, {"w": "default", "b": [0.1786, 0.8355, 0.236, 0.8569]}, {"w": "to", "b": [0.2436, 0.8355, 0.2606, 0.8569]}, {"w": "0,", "b": [0.2681, 0.8355, 0.2829, 0.8569]}, {"w": "but", "b": [0.2905, 0.8355, 0.3185, 0.8569]}, {"w": "we", "b": [0.326, 0.8355, 0.3492, 0.8569]}, {"w": "provide", "b": [0.3567, 0.8355, 0.4211, 0.8569]}, {"w": "an", "b": [0.4287, 0.8355, 0.4492, 0.8569]}, {"w": "empty", "b": [0.4568, 0.8355, 0.5091, 0.8569]}, {"w": "array", "b": [0.5167, 0.8355, 0.5597, 0.8569]}, {"w": "of", "b": [0.5672, 0.8355, 0.584, 0.8569]}, {"w": "type", "b": [0.5916, 0.8355, 0.6273, 0.8569]}, {"w": "tf.float32", "b": [0.6349, 0.8386, 0.7338, 0.8537]}, {"w": "as", "b": [0.7414, 0.8355, 0.7582, 0.8569]}, {"w": "the", "b": [0.7658, 0.8355, 0.7921, 0.8569]}, {"w": "default", "b": [0.7997, 0.8355, 0.8571, 0.8569]}, {"w": "value", "b": [0.1786, 0.8545, 0.2226, 0.8759]}, {"w": "for", "b": [0.2279, 0.8545, 0.2524, 0.8759]}, {"w": "the", "b": [0.2577, 0.8545, 0.2841, 0.8759]}, {"w": "last", "b": [0.2894, 0.8545, 0.3178, 0.8759]}, {"w": "column", "b": [0.3231, 0.8545, 0.3874, 0.8759]}, {"w": "(the", "b": [0.3927, 0.8545, 0.4262, 0.8759]}, {"w": "target):", "b": [0.4316, 0.8545, 0.4917, 0.8759]}, {"w": "this", "b": [0.497, 0.8545, 0.5278, 0.8759]}, {"w": "tells", "b": [0.5331, 0.8545, 0.5665, 0.8759]}, {"w": "TensorFlow", "b": [0.5718, 0.8545, 0.6701, 0.8759]}, {"w": "that", "b": [0.6754, 0.8545, 0.708, 0.8759]}, {"w": "this", "b": [0.7133, 0.8545, 0.744, 0.8759]}, {"w": "column", "b": [0.7493, 0.8545, 0.8136, 0.8759]}, {"w": "con‐", "b": [0.8189, 0.8545, 0.8571, 0.8759]}]}, {"id": "b_10", "type": "paragraph", "text": "The Data API | 409", "words": [{"w": "The", "b": [0.7213, 0.9225, 0.7428, 0.9388]}, {"w": "Data", "b": [0.7456, 0.9225, 0.7733, 0.9388]}, {"w": "API", "b": [0.7761, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "409", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 436, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "tains floats, but that there is no default value, so it will raise an exception if it encounters a missing value.", "words": [{"w": "tains", "b": [0.1786, 0.0791, 0.2187, 0.1005]}, {"w": "floats,", "b": [0.2261, 0.0791, 0.2757, 0.1005]}, {"w": "but", "b": [0.2831, 0.0791, 0.3111, 0.1005]}, {"w": "that", "b": [0.3186, 0.0791, 0.3511, 0.1005]}, {"w": "there", "b": [0.3586, 0.0791, 0.4015, 0.1005]}, {"w": "is", "b": [0.4089, 0.0791, 0.4221, 0.1005]}, {"w": "no", "b": [0.4296, 0.0791, 0.4516, 0.1005]}, {"w": "default", "b": [0.459, 0.0791, 0.5165, 0.1005]}, {"w": "value,", "b": [0.5239, 0.0791, 0.5727, 0.1005]}, {"w": "so", "b": [0.5801, 0.0791, 0.5984, 0.1005]}, {"w": "it", "b": [0.6058, 0.0791, 0.6177, 0.1005]}, {"w": "will", "b": [0.6252, 0.0791, 0.6556, 0.1005]}, {"w": "raise", "b": [0.663, 0.0791, 0.7019, 0.1005]}, {"w": "an", "b": [0.7094, 0.0791, 0.7299, 0.1005]}, {"w": "exception", "b": [0.7374, 0.0791, 0.8186, 0.1005]}, {"w": "if", "b": [0.826, 0.0791, 0.8378, 0.1005]}, {"w": "it", "b": [0.8452, 0.0791, 0.8571, 0.1005]}, {"w": "encounters", "b": [0.1786, 0.0981, 0.2709, 0.1195]}, {"w": "a", "b": [0.2756, 0.0981, 0.2848, 0.1195]}, {"w": "missing", "b": [0.2895, 0.0981, 0.3542, 0.1195]}, {"w": "value.", "b": [0.3589, 0.0981, 0.4076, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "• The decode_csv() function returns a list of scalar tensors (one per column) but we need to return 1D tensor arrays. So we call tf.stack() on all tensors except for the last one (the target): this will stack these tensors into a 1D array. We then do the same for the target value (this makes it a 1D tensor array with a single value, rather than a scalar tensor).", "words": [{"w": "•", "b": [0.16, 0.1241, 0.1682, 0.1455]}, {"w": "The", "b": [0.1786, 0.1241, 0.2114, 0.1455]}, {"w": "decode_csv()", "b": [0.2173, 0.1273, 0.3361, 0.1424]}, {"w": "function", "b": [0.342, 0.1241, 0.4134, 0.1455]}, {"w": "returns", "b": [0.4193, 0.1241, 0.4801, 0.1455]}, {"w": "a", "b": [0.486, 0.1241, 0.4951, 0.1455]}, {"w": "list", "b": [0.501, 0.1241, 0.5259, 0.1455]}, {"w": "of", "b": [0.5318, 0.1241, 0.5486, 0.1455]}, {"w": "scalar", "b": [0.5545, 0.1241, 0.6023, 0.1455]}, {"w": "tensors", "b": [0.6082, 0.1241, 0.6684, 0.1455]}, {"w": "(one", "b": [0.6744, 0.1241, 0.7124, 0.1455]}, {"w": "per", "b": [0.7184, 0.1241, 0.7459, 0.1455]}, {"w": "column)", "b": [0.7518, 0.1241, 0.8232, 0.1455]}, {"w": "but", "b": [0.8291, 0.1241, 0.8571, 0.1455]}, {"w": "we", "b": [0.1786, 0.144, 0.2017, 0.1655]}, {"w": "need", "b": [0.2078, 0.144, 0.2479, 0.1655]}, {"w": "to", "b": [0.254, 0.144, 0.271, 0.1655]}, {"w": "return", "b": [0.2771, 0.144, 0.3302, 0.1655]}, {"w": "1D", "b": [0.3363, 0.144, 0.3616, 0.1655]}, {"w": "tensor", "b": [0.3677, 0.144, 0.4203, 0.1655]}, {"w": "arrays.", "b": [0.4264, 0.144, 0.4817, 0.1655]}, {"w": "So", "b": [0.4878, 0.144, 0.5083, 0.1655]}, {"w": "we", "b": [0.5144, 0.144, 0.5375, 0.1655]}, {"w": "call", "b": [0.5436, 0.144, 0.5721, 0.1655]}, {"w": "tf.stack()", "b": [0.5782, 0.1472, 0.6772, 0.1623]}, {"w": "on", "b": [0.6833, 0.144, 0.7053, 0.1655]}, {"w": "all", "b": [0.7114, 0.144, 0.7311, 0.1655]}, {"w": "tensors", "b": [0.7372, 0.144, 0.7974, 0.1655]}, {"w": "except", "b": [0.8035, 0.144, 0.8571, 0.1655]}, {"w": "for", "b": [0.1786, 0.1631, 0.2031, 0.1845]}, {"w": "the", "b": [0.2087, 0.1631, 0.235, 0.1845]}, {"w": "last", "b": [0.2406, 0.1631, 0.269, 0.1845]}, {"w": "one", "b": [0.2746, 0.1631, 0.3054, 0.1845]}, {"w": "(the", "b": [0.311, 0.1631, 0.3446, 0.1845]}, {"w": "target):", "b": [0.3502, 0.1631, 0.4103, 0.1845]}, {"w": "this", "b": [0.4159, 0.1631, 0.4466, 0.1845]}, {"w": "will", "b": [0.4522, 0.1631, 0.4826, 0.1845]}, {"w": "stack", "b": [0.4881, 0.1631, 0.5304, 0.1845]}, {"w": "these", "b": [0.536, 0.1631, 0.5788, 0.1845]}, {"w": "tensors", "b": [0.5844, 0.1631, 0.6447, 0.1845]}, {"w": "into", "b": [0.6503, 0.1631, 0.6838, 0.1845]}, {"w": "a", "b": [0.6894, 0.1631, 0.6985, 0.1845]}, {"w": "1D", "b": [0.7041, 0.1631, 0.7294, 0.1845]}, {"w": "array.", "b": [0.735, 0.1631, 0.7812, 0.1845]}, {"w": "We", "b": [0.7868, 0.1631, 0.8138, 0.1845]}, {"w": "then", "b": [0.8194, 0.1631, 0.8571, 0.1845]}, {"w": "do", "b": [0.1786, 0.1821, 0.2002, 0.2036]}, {"w": "the", "b": [0.2075, 0.1821, 0.2338, 0.2036]}, {"w": "same", "b": [0.2412, 0.1821, 0.2839, 0.2036]}, {"w": "for", "b": [0.2912, 0.1821, 0.3157, 0.2036]}, {"w": "the", "b": [0.323, 0.1821, 0.3493, 0.2036]}, {"w": "target", "b": [0.3567, 0.1821, 0.4048, 0.2036]}, {"w": "value", "b": [0.4122, 0.1821, 0.4561, 0.2036]}, {"w": "(this", "b": [0.4635, 0.1821, 0.5014, 0.2036]}, {"w": "makes", "b": [0.5087, 0.1821, 0.5617, 0.2036]}, {"w": "it", "b": [0.569, 0.1821, 0.581, 0.2036]}, {"w": "a", "b": [0.5883, 0.1821, 0.5974, 0.2036]}, {"w": "1D", "b": [0.6047, 0.1821, 0.6301, 0.2036]}, {"w": "tensor", "b": [0.6374, 0.1821, 0.69, 0.2036]}, {"w": "array", "b": [0.6973, 0.1821, 0.7402, 0.2036]}, {"w": "with", "b": [0.7475, 0.1821, 0.7849, 0.2036]}, {"w": "a", "b": [0.7922, 0.1821, 0.8013, 0.2036]}, {"w": "single", "b": [0.8086, 0.1821, 0.8571, 0.2036]}, {"w": "value,", "b": [0.1786, 0.2012, 0.2273, 0.2226]}, {"w": "rather", "b": [0.232, 0.2012, 0.2826, 0.2226]}, {"w": "than", "b": [0.2873, 0.2012, 0.3253, 0.2226]}, {"w": "a", "b": [0.3301, 0.2012, 0.3392, 0.2226]}, {"w": "scalar", "b": [0.3439, 0.2012, 0.3917, 0.2226]}, {"w": "tensor).", "b": [0.3964, 0.2012, 0.461, 0.2226]}]}, {"id": "b_2", "type": "paragraph", "text": "• Finally, we scale the input features by subtracting the feature means and then dividing by the feature standard deviations, and we return a tuple containing the scaled features and the target.", "words": [{"w": "•", "b": [0.16, 0.2263, 0.1681, 0.2477]}, {"w": "Finally,", "b": [0.1786, 0.2263, 0.239, 0.2477]}, {"w": "we", "b": [0.2471, 0.2263, 0.2702, 0.2477]}, {"w": "scale", "b": [0.2783, 0.2263, 0.318, 0.2477]}, {"w": "the", "b": [0.326, 0.2263, 0.3524, 0.2477]}, {"w": "input", "b": [0.3604, 0.2263, 0.4053, 0.2477]}, {"w": "features", "b": [0.4134, 0.2263, 0.4788, 0.2477]}, {"w": "by", "b": [0.4868, 0.2263, 0.507, 0.2477]}, {"w": "subtracting", "b": [0.515, 0.2263, 0.6094, 0.2477]}, {"w": "the", "b": [0.6175, 0.2263, 0.6438, 0.2477]}, {"w": "feature", "b": [0.6519, 0.2263, 0.7096, 0.2477]}, {"w": "means", "b": [0.7177, 0.2263, 0.7718, 0.2477]}, {"w": "and", "b": [0.7798, 0.2263, 0.8114, 0.2477]}, {"w": "then", "b": [0.8194, 0.2263, 0.8571, 0.2477]}, {"w": "dividing", "b": [0.1786, 0.2453, 0.2481, 0.2667]}, {"w": "by", "b": [0.2536, 0.2453, 0.2737, 0.2667]}, {"w": "the", "b": [0.2792, 0.2453, 0.3056, 0.2667]}, {"w": "feature", "b": [0.311, 0.2453, 0.3688, 0.2667]}, {"w": "standard", "b": [0.3743, 0.2453, 0.4477, 0.2667]}, {"w": "deviations,", "b": [0.4532, 0.2453, 0.5434, 0.2667]}, {"w": "and", "b": [0.5489, 0.2453, 0.5804, 0.2667]}, {"w": "we", "b": [0.5859, 0.2453, 0.609, 0.2667]}, {"w": "return", "b": [0.6145, 0.2453, 0.6676, 0.2667]}, {"w": "a", "b": [0.6731, 0.2453, 0.6823, 0.2667]}, {"w": "tuple", "b": [0.6877, 0.2453, 0.7302, 0.2667]}, {"w": "containing", "b": [0.7357, 0.2453, 0.8253, 0.2667]}, {"w": "the", "b": [0.8308, 0.2453, 0.8571, 0.2667]}, {"w": "scaled", "b": [0.1786, 0.2644, 0.2293, 0.2858]}, {"w": "features", "b": [0.234, 0.2644, 0.2994, 0.2858]}, {"w": "and", "b": [0.3042, 0.2644, 0.3357, 0.2858]}, {"w": "the", "b": [0.3404, 0.2644, 0.3668, 0.2858]}, {"w": "target.", "b": [0.3715, 0.2644, 0.4244, 0.2858]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s test this preprocessing function:", "words": [{"w": "Let’s", "b": [0.1429, 0.2985, 0.179, 0.32]}, {"w": "test", "b": [0.1838, 0.2985, 0.213, 0.32]}, {"w": "this", "b": [0.2177, 0.2985, 0.2484, 0.32]}, {"w": "preprocessing", "b": [0.2531, 0.2985, 0.3696, 0.32]}, {"w": "function:", "b": [0.3743, 0.2985, 0.4505, 0.32]}]}, {"id": "b_4", "type": "paragraph", "text": ">>> preprocess(b'4.2083,44.0,5.3232,0.9171,846.0,2.3370,37.47,-122.2,2.782') (, )", "words": [{"w": ">>>", "b": [0.1766, 0.3305, 0.2019, 0.3434]}, {"w": "preprocess(b'4.2083,44.0,5.3232,0.9171,846.0,2.3370,37.47,-122.2,2.782')", "b": [0.2103, 0.3305, 0.8175, 0.3434]}, {"w": "(,", "b": [0.5813, 0.3768, 0.7163, 0.3896]}, {"w": ")", "b": [0.5223, 0.3922, 0.6572, 0.405]}]}, {"id": "b_5", "type": "paragraph", "text": "We can now apply this preprocessing function to the dataset.", "words": [{"w": "We", "b": [0.1429, 0.4128, 0.1699, 0.4342]}, {"w": "can", "b": [0.1747, 0.4128, 0.204, 0.4342]}, {"w": "now", "b": [0.2087, 0.4128, 0.245, 0.4342]}, {"w": "apply", "b": [0.2498, 0.4128, 0.2952, 0.4342]}, {"w": "this", "b": [0.2999, 0.4128, 0.3306, 0.4342]}, {"w": "preprocessing", "b": [0.3353, 0.4128, 0.4518, 0.4342]}, {"w": "function", "b": [0.4565, 0.4128, 0.5279, 0.4342]}, {"w": "to", "b": [0.5327, 0.4128, 0.5496, 0.4342]}, {"w": "the", "b": [0.5544, 0.4128, 0.5807, 0.4342]}, {"w": "dataset.", "b": [0.5854, 0.4128, 0.6483, 0.4342]}]}, {"id": "b_6", "type": "paragraph", "text": "Putting Everything Together", "words": [{"w": "Putting", "b": [0.1429, 0.447, 0.2209, 0.4756]}, {"w": "Everything", "b": [0.2259, 0.447, 0.3376, 0.4756]}, {"w": "Together", "b": [0.3426, 0.447, 0.4362, 0.4756]}]}, {"id": "b_7", "type": "paragraph", "text": "To make the code reusable, let’s put together everything we have discussed so far into a small helper function: it will create and return a dataset that will efficiently load Cal‐ ifornia housing data from multiple CSV files, then shuffle it, preprocess it and batch it (see Figure 13-2):", "words": [{"w": "To", "b": [0.1429, 0.4815, 0.1643, 0.5029]}, {"w": "make", "b": [0.1696, 0.4815, 0.215, 0.5029]}, {"w": "the", "b": [0.2204, 0.4815, 0.2467, 0.5029]}, {"w": "code", "b": [0.252, 0.4815, 0.2913, 0.5029]}, {"w": "reusable,", "b": [0.2966, 0.4815, 0.3705, 0.5029]}, {"w": "let’s", "b": [0.3759, 0.4815, 0.4061, 0.5029]}, {"w": "put", "b": [0.4114, 0.4815, 0.4398, 0.5029]}, {"w": "together", "b": [0.4451, 0.4815, 0.5147, 0.5029]}, {"w": "everything", "b": [0.5201, 0.4815, 0.6095, 0.5029]}, {"w": "we", "b": [0.6148, 0.4815, 0.638, 0.5029]}, {"w": "have", "b": [0.6433, 0.4815, 0.6817, 0.5029]}, {"w": "discussed", "b": [0.687, 0.4815, 0.7663, 0.5029]}, {"w": "so", "b": [0.7716, 0.4815, 0.7899, 0.5029]}, {"w": "far", "b": [0.7952, 0.4815, 0.8183, 0.5029]}, {"w": "into", "b": [0.8236, 0.4815, 0.8571, 0.5029]}, {"w": "a", "b": [0.1429, 0.5005, 0.152, 0.5219]}, {"w": "small", "b": [0.1567, 0.5005, 0.2011, 0.5219]}, {"w": "helper", "b": [0.2059, 0.5005, 0.2586, 0.5219]}, {"w": "function:", "b": [0.2633, 0.5005, 0.3395, 0.5219]}, {"w": "it", "b": [0.3442, 0.5005, 0.3561, 0.5219]}, {"w": "will", "b": [0.3609, 0.5005, 0.3913, 0.5219]}, {"w": "create", "b": [0.396, 0.5005, 0.4454, 0.5219]}, {"w": "and", "b": [0.4501, 0.5005, 0.4816, 0.5219]}, {"w": "return", "b": [0.4864, 0.5005, 0.5395, 0.5219]}, {"w": "a", "b": [0.5442, 0.5005, 0.5534, 0.5219]}, {"w": "dataset", "b": [0.5581, 0.5005, 0.6162, 0.5219]}, {"w": "that", "b": [0.6209, 0.5005, 0.6535, 0.5219]}, {"w": "will", "b": [0.6582, 0.5005, 0.6886, 0.5219]}, {"w": "efficiently", "b": [0.6934, 0.5005, 0.7756, 0.5219]}, {"w": "load", "b": [0.7803, 0.5005, 0.8163, 0.5219]}, {"w": "Cal‐", "b": [0.8211, 0.5005, 0.8567, 0.5219]}, {"w": "ifornia", "b": [0.1429, 0.5196, 0.1991, 0.541]}, {"w": "housing", "b": [0.2038, 0.5196, 0.271, 0.541]}, {"w": "data", "b": [0.2757, 0.5196, 0.311, 0.541]}, {"w": "from", "b": [0.3157, 0.5196, 0.3573, 0.541]}, {"w": "multiple", "b": [0.362, 0.5196, 0.432, 0.541]}, {"w": "CSV", "b": [0.4367, 0.5196, 0.4751, 0.541]}, {"w": "files,", "b": [0.4798, 0.5196, 0.5181, 0.541]}, {"w": "then", "b": [0.5228, 0.5196, 0.5606, 0.541]}, {"w": "shuffle", "b": [0.5653, 0.5196, 0.6212, 0.541]}, {"w": "it,", "b": [0.6259, 0.5196, 0.6426, 0.541]}, {"w": "preprocess", "b": [0.6473, 0.5196, 0.7371, 0.541]}, {"w": "it", "b": [0.7418, 0.5196, 0.7537, 0.541]}, {"w": "and", "b": [0.7585, 0.5196, 0.79, 0.541]}, {"w": "batch", "b": [0.7947, 0.5196, 0.8404, 0.541]}, {"w": "it", "b": [0.8451, 0.5196, 0.857, 0.541]}, {"w": "(see", "b": [0.1429, 0.5386, 0.1754, 0.56]}, {"w": "Figure", "b": [0.1801, 0.5386, 0.2341, 0.56]}, {"w": "13-2):", "b": [0.2389, 0.5386, 0.2882, 0.56]}]}, {"id": "b_8", "type": "paragraph", "text": "def csv_reader_dataset(filepaths, repeat=None, n_readers=5, n_read_threads=None, shuffle_buffer_size=10000, n_parse_threads=5, batch_size=32): dataset = tf.data.Dataset.list_files(filepaths).repeat(repeat) dataset = dataset.interleave( lambda filepath: tf.data.TextLineDataset(filepath).skip(1), cycle_length=n_readers, num_parallel_calls=n_read_threads) dataset = dataset.shuffle(shuffle_buffer_size) dataset = dataset.map(preprocess, num_parallel_calls=n_parse_threads) dataset = dataset.batch(batch_size) return dataset.prefetch(1)", "words": [{"w": "def", "b": [0.1766, 0.5706, 0.2019, 0.5834]}, {"w": "csv_reader_dataset(filepaths,", "b": [0.2103, 0.5706, 0.4549, 0.5834]}, {"w": "repeat=None,", "b": [0.4633, 0.5706, 0.5645, 0.5834]}, {"w": "n_readers=5,", "b": [0.5729, 0.5706, 0.6741, 0.5834]}, {"w": "n_read_threads=None,", "b": [0.3705, 0.586, 0.5392, 0.5989]}, {"w": "shuffle_buffer_size=10000,", "b": [0.5476, 0.586, 0.7669, 0.5989]}, {"w": "n_parse_threads=5,", "b": [0.3705, 0.6014, 0.5223, 0.6143]}, {"w": "batch_size=32):", "b": [0.5308, 0.6014, 0.6572, 0.6143]}, {"w": "dataset", "b": [0.2103, 0.6168, 0.2693, 0.6297]}, {"w": "=", "b": [0.2778, 0.6168, 0.2862, 0.6297]}, {"w": "tf.data.Dataset.list_files(filepaths).repeat(repeat)", "b": [0.2946, 0.6168, 0.7331, 0.6297]}, {"w": "dataset", "b": [0.2103, 0.6323, 0.2693, 0.6451]}, {"w": "=", "b": [0.2778, 0.6323, 0.2862, 0.6451]}, {"w": "dataset.interleave(", "b": [0.2946, 0.6323, 0.4549, 0.6451]}, {"w": "lambda", "b": [0.244, 0.6477, 0.2946, 0.6605]}, {"w": "filepath:", "b": [0.3031, 0.6477, 0.379, 0.6605]}, {"w": "tf.data.TextLineDataset(filepath).skip(1),", "b": [0.3874, 0.6477, 0.7416, 0.6605]}, {"w": "cycle_length=n_readers,", "b": [0.244, 0.6631, 0.438, 0.676]}, {"w": "num_parallel_calls=n_read_threads)", "b": [0.4464, 0.6631, 0.7331, 0.676]}, {"w": "dataset", "b": [0.2103, 0.6785, 0.2693, 0.6914]}, {"w": "=", "b": [0.2778, 0.6785, 0.2862, 0.6914]}, {"w": "dataset.shuffle(shuffle_buffer_size)", "b": [0.2946, 0.6785, 0.5982, 0.6914]}, {"w": "dataset", "b": [0.2103, 0.6939, 0.2693, 0.7068]}, {"w": "=", "b": [0.2778, 0.6939, 0.2862, 0.7068]}, {"w": "dataset.map(preprocess,", "b": [0.2946, 0.6939, 0.4886, 0.7068]}, {"w": "num_parallel_calls=n_parse_threads)", "b": [0.497, 0.6939, 0.7922, 0.7068]}, {"w": "dataset", "b": [0.2103, 0.7094, 0.2693, 0.7222]}, {"w": "=", "b": [0.2778, 0.7094, 0.2862, 0.7222]}, {"w": "dataset.batch(batch_size)", "b": [0.2946, 0.7094, 0.5055, 0.7222]}, {"w": "return", "b": [0.2103, 0.7248, 0.2609, 0.7376]}, {"w": "dataset.prefetch(1)", "b": [0.2693, 0.7248, 0.4296, 0.7376]}]}, {"id": "b_9", "type": "paragraph", "text": "410 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "410", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 437, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "2 In general, just prefetching one batch is fine, but in some cases you may need to prefetch a few more. Alterna‐ tively, you can let TensorFlow decide automatically by passing tf.data.experimental.AUTOTUNE (this is an experimental feature for now).", "words": [{"w": "2", "b": [0.1451, 0.8451, 0.1518, 0.8594]}, {"w": "In", "b": [0.1587, 0.8436, 0.1728, 0.8599]}, {"w": "general,", "b": [0.1764, 0.8436, 0.2265, 0.8599]}, {"w": "just", "b": [0.2301, 0.8436, 0.2533, 0.8599]}, {"w": "prefetching", "b": [0.2569, 0.8436, 0.3297, 0.8599]}, {"w": "one", "b": [0.3333, 0.8436, 0.3568, 0.8599]}, {"w": "batch", "b": [0.3604, 0.8436, 0.3952, 0.8599]}, {"w": "is", "b": [0.3988, 0.8436, 0.4089, 0.8599]}, {"w": "fine,", "b": [0.4125, 0.8436, 0.4405, 0.8599]}, {"w": "but", "b": [0.4441, 0.8436, 0.4654, 0.8599]}, {"w": "in", "b": [0.469, 0.8436, 0.4819, 0.8599]}, {"w": "some", "b": [0.4855, 0.8436, 0.5192, 0.8599]}, {"w": "cases", "b": [0.5228, 0.8436, 0.5549, 0.8599]}, {"w": "you", "b": [0.5585, 0.8436, 0.5823, 0.8599]}, {"w": "may", "b": [0.5859, 0.8436, 0.6129, 0.8599]}, {"w": "need", "b": [0.6165, 0.8436, 0.647, 0.8599]}, {"w": "to", "b": [0.6506, 0.8436, 0.6636, 0.8599]}, {"w": "prefetch", "b": [0.6672, 0.8436, 0.7196, 0.8599]}, {"w": "a", "b": [0.7232, 0.8436, 0.7302, 0.8599]}, {"w": "few", "b": [0.7338, 0.8436, 0.7561, 0.8599]}, {"w": "more.", "b": [0.7597, 0.8436, 0.797, 0.8599]}, {"w": "Alterna‐", "b": [0.8007, 0.8436, 0.8544, 0.8599]}, {"w": "tively,", "b": [0.1587, 0.8598, 0.1957, 0.8761]}, {"w": "you", "b": [0.1993, 0.8598, 0.2231, 0.8761]}, {"w": "can", "b": [0.2267, 0.8598, 0.2491, 0.8761]}, {"w": "let", "b": [0.2527, 0.8598, 0.2683, 0.8761]}, {"w": "TensorFlow", "b": [0.2719, 0.8598, 0.3467, 0.8761]}, {"w": "decide", "b": [0.3503, 0.8598, 0.3916, 0.8761]}, {"w": "automatically", "b": [0.3952, 0.8598, 0.481, 0.8761]}, {"w": "by", "b": [0.4846, 0.8598, 0.4999, 0.8761]}, {"w": "passing", "b": [0.5035, 0.8598, 0.5508, 0.8761]}, {"w": "tf.data.experimental.AUTOTUNE", "b": [0.5544, 0.8622, 0.7731, 0.8737]}, {"w": "(this", "b": [0.7767, 0.8598, 0.8056, 0.8761]}, {"w": "is", "b": [0.8092, 0.8598, 0.8192, 0.8761]}, {"w": "an", "b": [0.8228, 0.8598, 0.8385, 0.8761]}, {"w": "experimental", "b": [0.1587, 0.8749, 0.2421, 0.8912]}, {"w": "feature", "b": [0.2457, 0.8749, 0.2897, 0.8912]}, {"w": "for", "b": [0.2933, 0.8749, 0.312, 0.8912]}, {"w": "now).", "b": [0.3156, 0.8749, 0.3524, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 13-2. Loading and Preprocessing Data From Multiple CSV Files", "words": [{"w": "Figure", "b": [0.1429, 0.4339, 0.1943, 0.4555]}, {"w": "13-2.", "b": [0.1991, 0.4339, 0.2407, 0.4555]}, {"w": "Loading", "b": [0.2455, 0.4339, 0.3117, 0.4555]}, {"w": "and", "b": [0.3165, 0.4339, 0.3479, 0.4555]}, {"w": "Preprocessing", "b": [0.3526, 0.4339, 0.461, 0.4555]}, {"w": "Data", "b": [0.4658, 0.4339, 0.5069, 0.4555]}, {"w": "From", "b": [0.5116, 0.4339, 0.5553, 0.4555]}, {"w": "Multiple", "b": [0.5601, 0.4339, 0.6287, 0.4555]}, {"w": "CSV", "b": [0.6335, 0.4339, 0.6705, 0.4555]}, {"w": "Files", "b": [0.6753, 0.4339, 0.7118, 0.4555]}]}, {"id": "b_2", "type": "paragraph", "text": "Everything should make sense in this code, except the very last line (prefetch(1)), which is actually quite important for performance.", "words": [{"w": "Everything", "b": [0.1429, 0.4722, 0.2349, 0.4936]}, {"w": "should", "b": [0.2416, 0.4722, 0.2983, 0.4936]}, {"w": "make", "b": [0.305, 0.4722, 0.3504, 0.4936]}, {"w": "sense", "b": [0.357, 0.4722, 0.4014, 0.4936]}, {"w": "in", "b": [0.4081, 0.4722, 0.4251, 0.4936]}, {"w": "this", "b": [0.4318, 0.4722, 0.4625, 0.4936]}, {"w": "code,", "b": [0.4691, 0.4722, 0.5132, 0.4936]}, {"w": "except", "b": [0.5199, 0.4722, 0.5735, 0.4936]}, {"w": "the", "b": [0.5802, 0.4722, 0.6065, 0.4936]}, {"w": "very", "b": [0.6132, 0.4722, 0.6496, 0.4936]}, {"w": "last", "b": [0.6562, 0.4722, 0.6847, 0.4936]}, {"w": "line", "b": [0.6913, 0.4722, 0.7224, 0.4936]}, {"w": "(prefetch(1)),", "b": [0.7291, 0.4722, 0.8571, 0.4936]}, {"w": "which", "b": [0.1429, 0.4912, 0.1938, 0.5126]}, {"w": "is", "b": [0.1985, 0.4912, 0.2117, 0.5126]}, {"w": "actually", "b": [0.2165, 0.4912, 0.2811, 0.5126]}, {"w": "quite", "b": [0.2858, 0.4912, 0.3283, 0.5126]}, {"w": "important", "b": [0.333, 0.4912, 0.4174, 0.5126]}, {"w": "for", "b": [0.4221, 0.4912, 0.4467, 0.5126]}, {"w": "performance.", "b": [0.4514, 0.4912, 0.5634, 0.5126]}]}, {"id": "b_3", "type": "paragraph", "text": "Prefetching", "words": [{"w": "Prefetching", "b": [0.1429, 0.5254, 0.2633, 0.554]}]}, {"id": "b_4", "type": "paragraph", "text": "By calling prefetch(1) at the end, we are creating a dataset that will do its best to always be one batch ahead2. In other words, while our training algorithm is working on one batch, the dataset will already be working in parallel on getting the next batch ready. This can improve performance dramatically, as is illustrated on Figure 13-3. If we also ensure that loading and preprocessing are multithreaded (by setting num_par allel_calls when calling interleave() and map()), we can exploit multiple cores on the CPU and hopefully make preparing one batch of data shorter than running a training step on the GPU: this way the GPU will be almost 100% utilized (except for the data transfer time from the CPU to the GPU), and training will run much faster.", "words": [{"w": "By", "b": [0.1429, 0.5608, 0.1647, 0.5822]}, {"w": "calling", "b": [0.1717, 0.5608, 0.227, 0.5822]}, {"w": "prefetch(1)", "b": [0.234, 0.564, 0.3429, 0.579]}, {"w": "at", "b": [0.35, 0.5608, 0.3651, 0.5822]}, {"w": "the", "b": [0.3721, 0.5608, 0.3985, 0.5822]}, {"w": "end,", "b": [0.4055, 0.5608, 0.4415, 0.5822]}, {"w": "we", "b": [0.4486, 0.5608, 0.4717, 0.5822]}, {"w": "are", "b": [0.4788, 0.5608, 0.5045, 0.5822]}, {"w": "creating", "b": [0.5116, 0.5608, 0.5788, 0.5822]}, {"w": "a", "b": [0.5859, 0.5608, 0.595, 0.5822]}, {"w": "dataset", "b": [0.6021, 0.5608, 0.6602, 0.5822]}, {"w": "that", "b": [0.6672, 0.5608, 0.6998, 0.5822]}, {"w": "will", "b": [0.7069, 0.5608, 0.7373, 0.5822]}, {"w": "do", "b": [0.7443, 0.5608, 0.766, 0.5822]}, {"w": "its", "b": [0.773, 0.5608, 0.7926, 0.5822]}, {"w": "best", "b": [0.7997, 0.5608, 0.8331, 0.5822]}, {"w": "to", "b": [0.8402, 0.5608, 0.8572, 0.5822]}, {"w": "always", "b": [0.1429, 0.5798, 0.1975, 0.6012]}, {"w": "be", "b": [0.2035, 0.5798, 0.2229, 0.6012]}, {"w": "one", "b": [0.2289, 0.5798, 0.2598, 0.6012]}, {"w": "batch", "b": [0.2658, 0.5798, 0.3114, 0.6012]}, {"w": "ahead2.", "b": [0.3174, 0.5798, 0.3771, 0.6012]}, {"w": "In", "b": [0.3831, 0.5798, 0.4016, 0.6012]}, {"w": "other", "b": [0.4076, 0.5798, 0.4523, 0.6012]}, {"w": "words,", "b": [0.4582, 0.5798, 0.5143, 0.6012]}, {"w": "while", "b": [0.5202, 0.5798, 0.5653, 0.6012]}, {"w": "our", "b": [0.5713, 0.5798, 0.6007, 0.6012]}, {"w": "training", "b": [0.6067, 0.5798, 0.6736, 0.6012]}, {"w": "algorithm", "b": [0.6796, 0.5798, 0.7623, 0.6012]}, {"w": "is", "b": [0.7683, 0.5798, 0.7815, 0.6012]}, {"w": "working", "b": [0.7875, 0.5798, 0.8571, 0.6012]}, {"w": "on", "b": [0.1429, 0.5989, 0.1649, 0.6203]}, {"w": "one", "b": [0.1702, 0.5989, 0.201, 0.6203]}, {"w": "batch,", "b": [0.2063, 0.5989, 0.2567, 0.6203]}, {"w": "the", "b": [0.262, 0.5989, 0.2883, 0.6203]}, {"w": "dataset", "b": [0.2936, 0.5989, 0.3517, 0.6203]}, {"w": "will", "b": [0.357, 0.5989, 0.3874, 0.6203]}, {"w": "already", "b": [0.3927, 0.5989, 0.4534, 0.6203]}, {"w": "be", "b": [0.4587, 0.5989, 0.4781, 0.6203]}, {"w": "working", "b": [0.4834, 0.5989, 0.5531, 0.6203]}, {"w": "in", "b": [0.5584, 0.5989, 0.5754, 0.6203]}, {"w": "parallel", "b": [0.5806, 0.5989, 0.6422, 0.6203]}, {"w": "on", "b": [0.6475, 0.5989, 0.6696, 0.6203]}, {"w": "getting", "b": [0.6748, 0.5989, 0.7329, 0.6203]}, {"w": "the", "b": [0.7382, 0.5989, 0.7645, 0.6203]}, {"w": "next", "b": [0.7698, 0.5989, 0.8062, 0.6203]}, {"w": "batch", "b": [0.8115, 0.5989, 0.8571, 0.6203]}, {"w": "ready.", "b": [0.1428, 0.6179, 0.1924, 0.6393]}, {"w": "This", "b": [0.1981, 0.6179, 0.2353, 0.6393]}, {"w": "can", "b": [0.241, 0.6179, 0.2704, 0.6393]}, {"w": "improve", "b": [0.2761, 0.6179, 0.3461, 0.6393]}, {"w": "performance", "b": [0.3518, 0.6179, 0.4591, 0.6393]}, {"w": "dramatically,", "b": [0.4648, 0.6179, 0.5718, 0.6393]}, {"w": "as", "b": [0.5775, 0.6179, 0.5943, 0.6393]}, {"w": "is", "b": [0.6, 0.6179, 0.6132, 0.6393]}, {"w": "illustrated", "b": [0.6189, 0.6179, 0.7028, 0.6393]}, {"w": "on", "b": [0.7085, 0.6179, 0.7305, 0.6393]}, {"w": "Figure", "b": [0.7363, 0.6179, 0.7903, 0.6393]}, {"w": "13-3.", "b": [0.796, 0.6179, 0.8381, 0.6393]}, {"w": "If", "b": [0.8439, 0.6179, 0.8571, 0.6393]}, {"w": "we", "b": [0.1429, 0.6379, 0.166, 0.6593]}, {"w": "also", "b": [0.1716, 0.6379, 0.2043, 0.6593]}, {"w": "ensure", "b": [0.2099, 0.6379, 0.2654, 0.6593]}, {"w": "that", "b": [0.271, 0.6379, 0.3036, 0.6593]}, {"w": "loading", "b": [0.3092, 0.6379, 0.3719, 0.6593]}, {"w": "and", "b": [0.3775, 0.6379, 0.4091, 0.6593]}, {"w": "preprocessing", "b": [0.4146, 0.6379, 0.5311, 0.6593]}, {"w": "are", "b": [0.5367, 0.6379, 0.5624, 0.6593]}, {"w": "multithreaded", "b": [0.568, 0.6379, 0.687, 0.6593]}, {"w": "(by", "b": [0.6926, 0.6379, 0.7199, 0.6593]}, {"w": "setting", "b": [0.7255, 0.6379, 0.7815, 0.6593]}, {"w": "num_par", "b": [0.7871, 0.641, 0.8563, 0.6561]}, {"w": "allel_calls", "b": [0.1429, 0.661, 0.2517, 0.6761]}, {"w": "when", "b": [0.2586, 0.6578, 0.3043, 0.6792]}, {"w": "calling", "b": [0.3112, 0.6578, 0.3664, 0.6792]}, {"w": "interleave()", "b": [0.3734, 0.661, 0.4921, 0.6761]}, {"w": "and", "b": [0.499, 0.6578, 0.5306, 0.6792]}, {"w": "map()),", "b": [0.5375, 0.6578, 0.599, 0.6792]}, {"w": "we", "b": [0.6059, 0.6578, 0.629, 0.6792]}, {"w": "can", "b": [0.6359, 0.6578, 0.6653, 0.6792]}, {"w": "exploit", "b": [0.6722, 0.6578, 0.7296, 0.6792]}, {"w": "multiple", "b": [0.7366, 0.6578, 0.8066, 0.6792]}, {"w": "cores", "b": [0.8135, 0.6578, 0.8571, 0.6792]}, {"w": "on", "b": [0.1429, 0.6768, 0.1649, 0.6983]}, {"w": "the", "b": [0.1708, 0.6768, 0.1971, 0.6983]}, {"w": "CPU", "b": [0.2031, 0.6768, 0.244, 0.6983]}, {"w": "and", "b": [0.2499, 0.6768, 0.2815, 0.6983]}, {"w": "hopefully", "b": [0.2874, 0.6768, 0.3663, 0.6983]}, {"w": "make", "b": [0.3722, 0.6768, 0.4176, 0.6983]}, {"w": "preparing", "b": [0.4235, 0.6768, 0.5056, 0.6983]}, {"w": "one", "b": [0.5115, 0.6768, 0.5424, 0.6983]}, {"w": "batch", "b": [0.5483, 0.6768, 0.5939, 0.6983]}, {"w": "of", "b": [0.5999, 0.6768, 0.6167, 0.6983]}, {"w": "data", "b": [0.6226, 0.6768, 0.6579, 0.6983]}, {"w": "shorter", "b": [0.6638, 0.6768, 0.7239, 0.6983]}, {"w": "than", "b": [0.7298, 0.6768, 0.7678, 0.6983]}, {"w": "running", "b": [0.7737, 0.6768, 0.8421, 0.6983]}, {"w": "a", "b": [0.848, 0.6768, 0.8571, 0.6983]}, {"w": "training", "b": [0.1429, 0.6959, 0.2098, 0.7173]}, {"w": "step", "b": [0.2156, 0.6959, 0.2494, 0.7173]}, {"w": "on", "b": [0.2552, 0.6959, 0.2772, 0.7173]}, {"w": "the", "b": [0.2831, 0.6959, 0.3094, 0.7173]}, {"w": "GPU:", "b": [0.3152, 0.6959, 0.3619, 0.7173]}, {"w": "this", "b": [0.3678, 0.6959, 0.3985, 0.7173]}, {"w": "way", "b": [0.4043, 0.6959, 0.4369, 0.7173]}, {"w": "the", "b": [0.4427, 0.6959, 0.4691, 0.7173]}, {"w": "GPU", "b": [0.4749, 0.6959, 0.5168, 0.7173]}, {"w": "will", "b": [0.5227, 0.6959, 0.5531, 0.7173]}, {"w": "be", "b": [0.5589, 0.6959, 0.5783, 0.7173]}, {"w": "almost", "b": [0.5842, 0.6959, 0.6403, 0.7173]}, {"w": "100%", "b": [0.6461, 0.6959, 0.6918, 0.7173]}, {"w": "utilized", "b": [0.6977, 0.6959, 0.7601, 0.7173]}, {"w": "(except", "b": [0.766, 0.6959, 0.8268, 0.7173]}, {"w": "for", "b": [0.8326, 0.6959, 0.8571, 0.7173]}, {"w": "the", "b": [0.1429, 0.7149, 0.1692, 0.7364]}, {"w": "data", "b": [0.1739, 0.7149, 0.2092, 0.7364]}, {"w": "transfer", "b": [0.2139, 0.7149, 0.2789, 0.7364]}, {"w": "time", "b": [0.2837, 0.7149, 0.3215, 0.7364]}, {"w": "from", "b": [0.3262, 0.7149, 0.3678, 0.7364]}, {"w": "the", "b": [0.3726, 0.7149, 0.3989, 0.7364]}, {"w": "CPU", "b": [0.4036, 0.7149, 0.4445, 0.7364]}, {"w": "to", "b": [0.4493, 0.7149, 0.4662, 0.7364]}, {"w": "the", "b": [0.471, 0.7149, 0.4973, 0.7364]}, {"w": "GPU),", "b": [0.502, 0.7149, 0.5559, 0.7364]}, {"w": "and", "b": [0.5607, 0.7149, 0.5922, 0.7364]}, {"w": "training", "b": [0.5969, 0.7149, 0.6639, 0.7364]}, {"w": "will", "b": [0.6686, 0.7149, 0.699, 0.7364]}, {"w": "run", "b": [0.7037, 0.7149, 0.7339, 0.7364]}, {"w": "much", "b": [0.7387, 0.7149, 0.7863, 0.7364]}, {"w": "faster.", "b": [0.7911, 0.7149, 0.8404, 0.7364]}]}, {"id": "b_5", "type": "paragraph", "text": "The Data API | 411", "words": [{"w": "The", "b": [0.7213, 0.9225, 0.7428, 0.9388]}, {"w": "Data", "b": [0.7456, 0.9225, 0.7733, 0.9388]}, {"w": "API", "b": [0.7761, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "411", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 438, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 13-3. Speedup Training Thanks to Prefetching and Multithreading", "words": [{"w": "Figure", "b": [0.1429, 0.4961, 0.1943, 0.5177]}, {"w": "13-3.", "b": [0.1991, 0.4961, 0.2407, 0.5177]}, {"w": "Speedup", "b": [0.2455, 0.4961, 0.3128, 0.5177]}, {"w": "Training", "b": [0.3175, 0.4961, 0.3868, 0.5177]}, {"w": "Thanks", "b": [0.3915, 0.4961, 0.4511, 0.5177]}, {"w": "to", "b": [0.4559, 0.4961, 0.4719, 0.5177]}, {"w": "Prefetching", "b": [0.4767, 0.4961, 0.5665, 0.5177]}, {"w": "and", "b": [0.5713, 0.4961, 0.6027, 0.5177]}, {"w": "Multithreading", "b": [0.6074, 0.4961, 0.7299, 0.5177]}]}, {"id": "b_1", "type": "paragraph", "text": "If you plan to purchase a GPU card, its processing power and its memory size are of course very important (in particular, a large RAM is crucial for computer vision), but its memory bandwidth is just as important as the processing power to get good performance: this is the number of gigabytes of data it can get in or out of its RAM per second.", "words": [{"w": "If", "b": [0.2714, 0.5382, 0.2835, 0.5578]}, {"w": "you", "b": [0.29, 0.5382, 0.3185, 0.5578]}, {"w": "plan", "b": [0.325, 0.5382, 0.3585, 0.5578]}, {"w": "to", "b": [0.365, 0.5382, 0.3805, 0.5578]}, {"w": "purchase", "b": [0.3869, 0.5382, 0.4558, 0.5578]}, {"w": "a", "b": [0.4622, 0.5382, 0.4706, 0.5578]}, {"w": "GPU", "b": [0.477, 0.5382, 0.5154, 0.5578]}, {"w": "card,", "b": [0.5218, 0.5382, 0.5597, 0.5578]}, {"w": "its", "b": [0.5661, 0.5382, 0.584, 0.5578]}, {"w": "processing", "b": [0.5904, 0.5382, 0.6718, 0.5578]}, {"w": "power", "b": [0.6782, 0.5382, 0.7261, 0.5578]}, {"w": "and", "b": [0.7325, 0.5382, 0.7614, 0.5578]}, {"w": "its", "b": [0.7678, 0.5382, 0.7857, 0.5578]}, {"w": "memory", "b": [0.2714, 0.5557, 0.3368, 0.5752]}, {"w": "size", "b": [0.3444, 0.5557, 0.3725, 0.5752]}, {"w": "are", "b": [0.3801, 0.5557, 0.4036, 0.5752]}, {"w": "of", "b": [0.4112, 0.5557, 0.4266, 0.5752]}, {"w": "course", "b": [0.4342, 0.5557, 0.4842, 0.5752]}, {"w": "very", "b": [0.4918, 0.5557, 0.5251, 0.5752]}, {"w": "important", "b": [0.5326, 0.5557, 0.6098, 0.5752]}, {"w": "(in", "b": [0.6174, 0.5557, 0.6395, 0.5752]}, {"w": "particular,", "b": [0.647, 0.5557, 0.7249, 0.5752]}, {"w": "a", "b": [0.7325, 0.5557, 0.7409, 0.5752]}, {"w": "large", "b": [0.7485, 0.5557, 0.7857, 0.5752]}, {"w": "RAM", "b": [0.2714, 0.5731, 0.3134, 0.5926]}, {"w": "is", "b": [0.3191, 0.5731, 0.3312, 0.5926]}, {"w": "crucial", "b": [0.3369, 0.5731, 0.3884, 0.5926]}, {"w": "for", "b": [0.3942, 0.5731, 0.4166, 0.5926]}, {"w": "computer", "b": [0.4223, 0.5731, 0.4964, 0.5926]}, {"w": "vision),", "b": [0.5021, 0.5731, 0.5591, 0.5926]}, {"w": "but", "b": [0.5648, 0.5731, 0.5904, 0.5926]}, {"w": "its", "b": [0.5961, 0.5731, 0.614, 0.5926]}, {"w": "memory", "b": [0.6198, 0.5729, 0.6816, 0.5926]}, {"w": "bandwidth", "b": [0.6874, 0.5729, 0.7679, 0.5926]}, {"w": "is", "b": [0.7736, 0.5731, 0.7857, 0.5926]}, {"w": "just", "b": [0.2714, 0.5905, 0.2992, 0.6101]}, {"w": "as", "b": [0.3038, 0.5905, 0.3192, 0.6101]}, {"w": "important", "b": [0.3238, 0.5905, 0.4009, 0.6101]}, {"w": "as", "b": [0.4055, 0.5905, 0.4209, 0.6101]}, {"w": "the", "b": [0.4255, 0.5905, 0.4496, 0.6101]}, {"w": "processing", "b": [0.4542, 0.5905, 0.5355, 0.6101]}, {"w": "power", "b": [0.5402, 0.5905, 0.5881, 0.6101]}, {"w": "to", "b": [0.5927, 0.5905, 0.6082, 0.6101]}, {"w": "get", "b": [0.6128, 0.5905, 0.6356, 0.6101]}, {"w": "good", "b": [0.6403, 0.5905, 0.6787, 0.6101]}, {"w": "performance:", "b": [0.6833, 0.5905, 0.7857, 0.6101]}, {"w": "this", "b": [0.2714, 0.6079, 0.2995, 0.6275]}, {"w": "is", "b": [0.3064, 0.6079, 0.3185, 0.6275]}, {"w": "the", "b": [0.3255, 0.6079, 0.3495, 0.6275]}, {"w": "number", "b": [0.3565, 0.6079, 0.4171, 0.6275]}, {"w": "of", "b": [0.424, 0.6079, 0.4394, 0.6275]}, {"w": "gigabytes", "b": [0.4463, 0.6079, 0.5169, 0.6275]}, {"w": "of", "b": [0.5239, 0.6079, 0.5392, 0.6275]}, {"w": "data", "b": [0.5462, 0.6079, 0.5784, 0.6275]}, {"w": "it", "b": [0.5853, 0.6079, 0.5963, 0.6275]}, {"w": "can", "b": [0.6032, 0.6079, 0.63, 0.6275]}, {"w": "get", "b": [0.637, 0.6079, 0.6598, 0.6275]}, {"w": "in", "b": [0.6667, 0.6079, 0.6823, 0.6275]}, {"w": "or", "b": [0.6892, 0.6079, 0.706, 0.6275]}, {"w": "out", "b": [0.7129, 0.6079, 0.7386, 0.6275]}, {"w": "of", "b": [0.7455, 0.6079, 0.7609, 0.6275]}, {"w": "its", "b": [0.7678, 0.6079, 0.7857, 0.6275]}, {"w": "RAM", "b": [0.2714, 0.6253, 0.3134, 0.6449]}, {"w": "per", "b": [0.3177, 0.6253, 0.3428, 0.6449]}, {"w": "second.", "b": [0.3472, 0.6253, 0.4048, 0.6449]}]}, {"id": "b_2", "type": "paragraph", "text": "With that, you can now build efficient input pipelines to load and preprocess data from multiple text files. We have discussed the most common dataset methods, but there are a few more you may want to look at: concatenate(), zip(), window(), reduce(), cache(), shard(), flat_map() and padded_batch(). There are also a cou‐ ple more class methods: from_generator() and from_tensors(), which create a new dataset from a Python generator or a list of tensors respectively. Please check the API documentation for more details. Also note that there are experimental features avail‐ able in tf.data.experimental, many of which will most likely make it to the core API in future releases (e.g., check out the CsvDataset class and the SqlDataset classes).", "words": [{"w": "With", "b": [0.1429, 0.6652, 0.1853, 0.6866]}, {"w": "that,", "b": [0.1928, 0.6652, 0.2301, 0.6866]}, {"w": "you", "b": [0.2376, 0.6652, 0.2688, 0.6866]}, {"w": "can", "b": [0.2763, 0.6652, 0.3057, 0.6866]}, {"w": "now", "b": [0.3132, 0.6652, 0.3495, 0.6866]}, {"w": "build", "b": [0.3569, 0.6652, 0.4004, 0.6866]}, {"w": "efficient", "b": [0.4079, 0.6652, 0.4753, 0.6866]}, {"w": "input", "b": [0.4828, 0.6652, 0.5277, 0.6866]}, {"w": "pipelines", "b": [0.5352, 0.6652, 0.6102, 0.6866]}, {"w": "to", "b": [0.6177, 0.6652, 0.6347, 0.6866]}, {"w": "load", "b": [0.6421, 0.6652, 0.6782, 0.6866]}, {"w": "and", "b": [0.6857, 0.6652, 0.7172, 0.6866]}, {"w": "preprocess", "b": [0.7247, 0.6652, 0.8144, 0.6866]}, {"w": "data", "b": [0.8219, 0.6652, 0.8571, 0.6866]}, {"w": "from", "b": [0.1428, 0.6842, 0.1844, 0.7056]}, {"w": "multiple", "b": [0.1912, 0.6842, 0.2612, 0.7056]}, {"w": "text", "b": [0.2679, 0.6842, 0.2993, 0.7056]}, {"w": "files.", "b": [0.3061, 0.6842, 0.3444, 0.7056]}, {"w": "We", "b": [0.3512, 0.6842, 0.3782, 0.7056]}, {"w": "have", "b": [0.385, 0.6842, 0.4234, 0.7056]}, {"w": "discussed", "b": [0.4301, 0.6842, 0.5094, 0.7056]}, {"w": "the", "b": [0.5162, 0.6842, 0.5425, 0.7056]}, {"w": "most", "b": [0.5493, 0.6842, 0.591, 0.7056]}, {"w": "common", "b": [0.5977, 0.6842, 0.6733, 0.7056]}, {"w": "dataset", "b": [0.6801, 0.6842, 0.7382, 0.7056]}, {"w": "methods,", "b": [0.745, 0.6842, 0.8224, 0.7056]}, {"w": "but", "b": [0.8291, 0.6842, 0.8571, 0.7056]}, {"w": "there", "b": [0.1429, 0.7042, 0.1858, 0.7256]}, {"w": "are", "b": [0.1943, 0.7042, 0.22, 0.7256]}, {"w": "a", "b": [0.2285, 0.7042, 0.2376, 0.7256]}, {"w": "few", "b": [0.2461, 0.7042, 0.2754, 0.7256]}, {"w": "more", "b": [0.2839, 0.7042, 0.3282, 0.7256]}, {"w": "you", "b": [0.3366, 0.7042, 0.3679, 0.7256]}, {"w": "may", "b": [0.3764, 0.7042, 0.4118, 0.7256]}, {"w": "want", "b": [0.4202, 0.7042, 0.461, 0.7256]}, {"w": "to", "b": [0.4695, 0.7042, 0.4865, 0.7256]}, {"w": "look", "b": [0.495, 0.7042, 0.5318, 0.7256]}, {"w": "at:", "b": [0.5403, 0.7042, 0.5602, 0.7256]}, {"w": "concatenate(),", "b": [0.5686, 0.7042, 0.702, 0.7256]}, {"w": "zip(),", "b": [0.7105, 0.7042, 0.7648, 0.7256]}, {"w": "window(),", "b": [0.7732, 0.7042, 0.8572, 0.7256]}, {"w": "reduce(),", "b": [0.1428, 0.7241, 0.2268, 0.7455]}, {"w": "cache(),", "b": [0.2321, 0.7241, 0.3061, 0.7455]}, {"w": "shard(),", "b": [0.3115, 0.7241, 0.3856, 0.7455]}, {"w": "flat_map()", "b": [0.3909, 0.7273, 0.4899, 0.7424]}, {"w": "and", "b": [0.4952, 0.7241, 0.5268, 0.7455]}, {"w": "padded_batch().", "b": [0.5321, 0.7241, 0.6754, 0.7455]}, {"w": "There", "b": [0.6808, 0.7241, 0.7302, 0.7455]}, {"w": "are", "b": [0.7356, 0.7241, 0.7613, 0.7455]}, {"w": "also", "b": [0.7667, 0.7241, 0.7993, 0.7455]}, {"w": "a", "b": [0.8047, 0.7241, 0.8139, 0.7455]}, {"w": "cou‐", "b": [0.8192, 0.7241, 0.8571, 0.7455]}, {"w": "ple", "b": [0.1428, 0.7441, 0.1679, 0.7655]}, {"w": "more", "b": [0.1731, 0.7441, 0.2174, 0.7655]}, {"w": "class", "b": [0.2225, 0.7441, 0.2611, 0.7655]}, {"w": "methods:", "b": [0.2663, 0.7441, 0.3437, 0.7655]}, {"w": "from_generator()", "b": [0.3489, 0.7472, 0.5072, 0.7623]}, {"w": "and", "b": [0.5124, 0.7441, 0.544, 0.7655]}, {"w": "from_tensors(),", "b": [0.5491, 0.7441, 0.6924, 0.7655]}, {"w": "which", "b": [0.6976, 0.7441, 0.7485, 0.7655]}, {"w": "create", "b": [0.7537, 0.7441, 0.8031, 0.7655]}, {"w": "a", "b": [0.8083, 0.7441, 0.8174, 0.7655]}, {"w": "new", "b": [0.8226, 0.7441, 0.8571, 0.7655]}, {"w": "dataset", "b": [0.1428, 0.7631, 0.201, 0.7845]}, {"w": "from", "b": [0.2063, 0.7631, 0.2479, 0.7845]}, {"w": "a", "b": [0.2532, 0.7631, 0.2624, 0.7845]}, {"w": "Python", "b": [0.2677, 0.7631, 0.3285, 0.7845]}, {"w": "generator", "b": [0.3339, 0.7631, 0.4139, 0.7845]}, {"w": "or", "b": [0.4193, 0.7631, 0.4376, 0.7845]}, {"w": "a", "b": [0.443, 0.7631, 0.4521, 0.7845]}, {"w": "list", "b": [0.4575, 0.7631, 0.4823, 0.7845]}, {"w": "of", "b": [0.4877, 0.7631, 0.5045, 0.7845]}, {"w": "tensors", "b": [0.5098, 0.7631, 0.5701, 0.7845]}, {"w": "respectively.", "b": [0.5754, 0.7631, 0.6767, 0.7845]}, {"w": "Please", "b": [0.6821, 0.7631, 0.7336, 0.7845]}, {"w": "check", "b": [0.7389, 0.7631, 0.7869, 0.7845]}, {"w": "the", "b": [0.7922, 0.7631, 0.8186, 0.7845]}, {"w": "API", "b": [0.8239, 0.7631, 0.8571, 0.7845]}, {"w": "documentation", "b": [0.1429, 0.7822, 0.2703, 0.8036]}, {"w": "for", "b": [0.276, 0.7822, 0.3005, 0.8036]}, {"w": "more", "b": [0.3062, 0.7822, 0.3505, 0.8036]}, {"w": "details.", "b": [0.3561, 0.7822, 0.4147, 0.8036]}, {"w": "Also", "b": [0.4204, 0.7822, 0.4583, 0.8036]}, {"w": "note", "b": [0.464, 0.7822, 0.5012, 0.8036]}, {"w": "that", "b": [0.5069, 0.7822, 0.5395, 0.8036]}, {"w": "there", "b": [0.5451, 0.7822, 0.5881, 0.8036]}, {"w": "are", "b": [0.5937, 0.7822, 0.6194, 0.8036]}, {"w": "experimental", "b": [0.6251, 0.7822, 0.7346, 0.8036]}, {"w": "features", "b": [0.7402, 0.7822, 0.8057, 0.8036]}, {"w": "avail‐", "b": [0.8113, 0.7822, 0.8571, 0.8036]}, {"w": "able", "b": [0.1429, 0.8021, 0.1767, 0.8235]}, {"w": "in", "b": [0.1838, 0.8021, 0.2008, 0.8235]}, {"w": "tf.data.experimental,", "b": [0.208, 0.8021, 0.4106, 0.8235]}, {"w": "many", "b": [0.4178, 0.8021, 0.4645, 0.8235]}, {"w": "of", "b": [0.4716, 0.8021, 0.4884, 0.8235]}, {"w": "which", "b": [0.4955, 0.8021, 0.5464, 0.8235]}, {"w": "will", "b": [0.5536, 0.8021, 0.584, 0.8235]}, {"w": "most", "b": [0.5911, 0.8021, 0.6328, 0.8235]}, {"w": "likely", "b": [0.6399, 0.8021, 0.6848, 0.8235]}, {"w": "make", "b": [0.6919, 0.8021, 0.7373, 0.8235]}, {"w": "it", "b": [0.7445, 0.8021, 0.7564, 0.8235]}, {"w": "to", "b": [0.7635, 0.8021, 0.7805, 0.8235]}, {"w": "the", "b": [0.7877, 0.8021, 0.814, 0.8235]}, {"w": "core", "b": [0.8211, 0.8021, 0.8571, 0.8235]}, {"w": "API", "b": [0.1429, 0.822, 0.1761, 0.8435]}, {"w": "in", "b": [0.1854, 0.822, 0.2024, 0.8435]}, {"w": "future", "b": [0.2118, 0.822, 0.263, 0.8435]}, {"w": "releases", "b": [0.2723, 0.822, 0.3363, 0.8435]}, {"w": "(e.g.,", "b": [0.3457, 0.822, 0.3857, 0.8435]}, {"w": "check", "b": [0.3951, 0.822, 0.443, 0.8435]}, {"w": "out", "b": [0.4524, 0.822, 0.4804, 0.8435]}, {"w": "the", "b": [0.4898, 0.822, 0.5161, 0.8435]}, {"w": "CsvDataset", "b": [0.5254, 0.8252, 0.6244, 0.8403]}, {"w": "class", "b": [0.6337, 0.822, 0.6723, 0.8435]}, {"w": "and", "b": [0.6816, 0.822, 0.7132, 0.8435]}, {"w": "the", "b": [0.7225, 0.822, 0.7488, 0.8435]}, {"w": "SqlDataset", "b": [0.7582, 0.8252, 0.8571, 0.8403]}, {"w": "classes).", "b": [0.1429, 0.8411, 0.2098, 0.8625]}]}, {"id": "b_3", "type": "paragraph", "text": "412 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "412", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 439, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "3 Support for datasets is specific to tf.keras, it will not work on other implementations of the Keras API.", "words": [{"w": "3", "b": [0.1451, 0.8069, 0.1518, 0.8211]}, {"w": "Support", "b": [0.1587, 0.8054, 0.2101, 0.8217]}, {"w": "for", "b": [0.2137, 0.8054, 0.2324, 0.8217]}, {"w": "datasets", "b": [0.236, 0.8054, 0.2861, 0.8217]}, {"w": "is", "b": [0.2897, 0.8054, 0.2998, 0.8217]}, {"w": "specific", "b": [0.3034, 0.8054, 0.3509, 0.8217]}, {"w": "to", "b": [0.3545, 0.8054, 0.3675, 0.8217]}, {"w": "tf.keras,", "b": [0.3711, 0.8054, 0.4212, 0.8217]}, {"w": "it", "b": [0.4248, 0.8054, 0.4339, 0.8217]}, {"w": "will", "b": [0.4375, 0.8054, 0.4606, 0.8217]}, {"w": "not", "b": [0.4642, 0.8054, 0.4858, 0.8217]}, {"w": "work", "b": [0.4894, 0.8054, 0.5222, 0.8217]}, {"w": "on", "b": [0.5258, 0.8054, 0.5426, 0.8217]}, {"w": "other", "b": [0.5462, 0.8054, 0.5802, 0.8217]}, {"w": "implementations", "b": [0.5838, 0.8054, 0.6912, 0.8217]}, {"w": "of", "b": [0.6948, 0.8054, 0.7076, 0.8217]}, {"w": "the", "b": [0.7112, 0.8054, 0.7312, 0.8217]}, {"w": "Keras", "b": [0.7348, 0.8054, 0.7706, 0.8217]}, {"w": "API.", "b": [0.7742, 0.8054, 0.8031, 0.8217]}]}, {"id": "b_1", "type": "paragraph", "text": "4 The number of steps per epoch is optional if the dataset just goes through the data once, but if you do not specify it, the progress bar will not be displayed during the first epoch.", "words": [{"w": "4", "b": [0.1451, 0.8265, 0.1518, 0.8408]}, {"w": "The", "b": [0.1587, 0.825, 0.1837, 0.8413]}, {"w": "number", "b": [0.1873, 0.825, 0.2379, 0.8413]}, {"w": "of", "b": [0.2415, 0.825, 0.2543, 0.8413]}, {"w": "steps", "b": [0.2579, 0.825, 0.2894, 0.8413]}, {"w": "per", "b": [0.293, 0.825, 0.314, 0.8413]}, {"w": "epoch", "b": [0.3176, 0.825, 0.3559, 0.8413]}, {"w": "is", "b": [0.3595, 0.825, 0.3696, 0.8413]}, {"w": "optional", "b": [0.3732, 0.825, 0.4265, 0.8413]}, {"w": "if", "b": [0.4301, 0.825, 0.439, 0.8413]}, {"w": "the", "b": [0.4426, 0.825, 0.4627, 0.8413]}, {"w": "dataset", "b": [0.4663, 0.825, 0.5106, 0.8413]}, {"w": "just", "b": [0.5142, 0.825, 0.5373, 0.8413]}, {"w": "goes", "b": [0.5409, 0.825, 0.569, 0.8413]}, {"w": "through", "b": [0.5726, 0.825, 0.6243, 0.8413]}, {"w": "the", "b": [0.6279, 0.825, 0.6479, 0.8413]}, {"w": "data", "b": [0.6515, 0.825, 0.6784, 0.8413]}, {"w": "once,", "b": [0.682, 0.825, 0.7159, 0.8413]}, {"w": "but", "b": [0.7195, 0.825, 0.7408, 0.8413]}, {"w": "if", "b": [0.7444, 0.825, 0.7533, 0.8413]}, {"w": "you", "b": [0.757, 0.825, 0.7808, 0.8413]}, {"w": "do", "b": [0.7844, 0.825, 0.8008, 0.8413]}, {"w": "not", "b": [0.8044, 0.825, 0.8261, 0.8413]}, {"w": "specify", "b": [0.1587, 0.8401, 0.2028, 0.8565]}, {"w": "it,", "b": [0.2064, 0.8401, 0.2192, 0.8565]}, {"w": "the", "b": [0.2228, 0.8401, 0.2428, 0.8565]}, {"w": "progress", "b": [0.2464, 0.8401, 0.3004, 0.8565]}, {"w": "bar", "b": [0.304, 0.8401, 0.325, 0.8565]}, {"w": "will", "b": [0.3286, 0.8401, 0.3517, 0.8565]}, {"w": "not", "b": [0.3553, 0.8401, 0.377, 0.8565]}, {"w": "be", "b": [0.3806, 0.8401, 0.3954, 0.8565]}, {"w": "displayed", "b": [0.399, 0.8401, 0.4589, 0.8565]}, {"w": "during", "b": [0.4625, 0.8401, 0.5055, 0.8565]}, {"w": "the", "b": [0.5091, 0.8401, 0.5292, 0.8565]}, {"w": "first", "b": [0.5328, 0.8401, 0.5583, 0.8565]}, {"w": "epoch.", "b": [0.5619, 0.8401, 0.6039, 0.8565]}]}, {"id": "b_2", "type": "paragraph", "text": "5 Note that for now the dataset must be created within the TF Function. This may be fixed by the time you read these lines (see TensorFlow issue #25414).", "words": [{"w": "5", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Note", "b": [0.1587, 0.8598, 0.1898, 0.8761]}, {"w": "that", "b": [0.1934, 0.8598, 0.2182, 0.8761]}, {"w": "for", "b": [0.2218, 0.8598, 0.2405, 0.8761]}, {"w": "now", "b": [0.2441, 0.8598, 0.2718, 0.8761]}, {"w": "the", "b": [0.2754, 0.8598, 0.2954, 0.8761]}, {"w": "dataset", "b": [0.299, 0.8598, 0.3433, 0.8761]}, {"w": "must", "b": [0.3469, 0.8598, 0.3787, 0.8761]}, {"w": "be", "b": [0.3823, 0.8598, 0.3971, 0.8761]}, {"w": "created", "b": [0.4007, 0.8598, 0.4467, 0.8761]}, {"w": "within", "b": [0.4503, 0.8598, 0.4917, 0.8761]}, {"w": "the", "b": [0.4953, 0.8598, 0.5154, 0.8761]}, {"w": "TF", "b": [0.519, 0.8598, 0.5372, 0.8761]}, {"w": "Function.", "b": [0.5408, 0.8598, 0.6022, 0.8761]}, {"w": "This", "b": [0.6058, 0.8598, 0.6341, 0.8761]}, {"w": "may", "b": [0.6377, 0.8598, 0.6647, 0.8761]}, {"w": "be", "b": [0.6683, 0.8598, 0.6831, 0.8761]}, {"w": "fixed", "b": [0.6867, 0.8598, 0.7183, 0.8761]}, {"w": "by", "b": [0.7219, 0.8598, 0.7372, 0.8761]}, {"w": "the", "b": [0.7408, 0.8598, 0.7609, 0.8761]}, {"w": "time", "b": [0.7645, 0.8598, 0.7933, 0.8761]}, {"w": "you", "b": [0.7969, 0.8598, 0.8207, 0.8761]}, {"w": "read", "b": [0.8243, 0.8598, 0.8523, 0.8761]}, {"w": "these", "b": [0.1587, 0.8749, 0.1914, 0.8912]}, {"w": "lines", "b": [0.195, 0.8749, 0.2245, 0.8912]}, {"w": "(see", "b": [0.2281, 0.8749, 0.2529, 0.8912]}, {"w": "TensorFlow", "b": [0.2565, 0.8749, 0.3314, 0.8912]}, {"w": "issue", "b": [0.335, 0.8749, 0.366, 0.8912]}, {"w": "#25414).", "b": [0.3697, 0.8749, 0.4245, 0.8912]}]}, {"id": "b_3", "type": "paragraph", "text": "Using the Dataset With tf.keras", "words": [{"w": "Using", "b": [0.1429, 0.0763, 0.2008, 0.1049]}, {"w": "the", "b": [0.2058, 0.0763, 0.2406, 0.1049]}, {"w": "Dataset", "b": [0.2456, 0.0763, 0.3249, 0.1049]}, {"w": "With", "b": [0.3299, 0.0763, 0.3797, 0.1049]}, {"w": "tf.keras", "b": [0.3847, 0.0763, 0.4635, 0.1049]}]}, {"id": "b_4", "type": "paragraph", "text": "Now we can use the csv_reader_dataset() function to create a dataset for the train‐ ing set (ensuring it repeats the data forever), the validation set and the test set:", "words": [{"w": "Now", "b": [0.1428, 0.1117, 0.1827, 0.1331]}, {"w": "we", "b": [0.1878, 0.1117, 0.211, 0.1331]}, {"w": "can", "b": [0.2161, 0.1117, 0.2454, 0.1331]}, {"w": "use", "b": [0.2506, 0.1117, 0.2781, 0.1331]}, {"w": "the", "b": [0.2833, 0.1117, 0.3096, 0.1331]}, {"w": "csv_reader_dataset()", "b": [0.3147, 0.1149, 0.5126, 0.1299]}, {"w": "function", "b": [0.5178, 0.1117, 0.5892, 0.1331]}, {"w": "to", "b": [0.5943, 0.1117, 0.6113, 0.1331]}, {"w": "create", "b": [0.6164, 0.1117, 0.6658, 0.1331]}, {"w": "a", "b": [0.6709, 0.1117, 0.6801, 0.1331]}, {"w": "dataset", "b": [0.6852, 0.1117, 0.7433, 0.1331]}, {"w": "for", "b": [0.7484, 0.1117, 0.7729, 0.1331]}, {"w": "the", "b": [0.7781, 0.1117, 0.8044, 0.1331]}, {"w": "train‐", "b": [0.8095, 0.1117, 0.8572, 0.1331]}, {"w": "ing", "b": [0.1429, 0.1307, 0.1696, 0.1521]}, {"w": "set", "b": [0.1743, 0.1307, 0.1972, 0.1521]}, {"w": "(ensuring", "b": [0.2019, 0.1307, 0.2825, 0.1521]}, {"w": "it", "b": [0.2873, 0.1307, 0.2992, 0.1521]}, {"w": "repeats", "b": [0.3039, 0.1307, 0.363, 0.1521]}, {"w": "the", "b": [0.3678, 0.1307, 0.3941, 0.1521]}, {"w": "data", "b": [0.3988, 0.1307, 0.4341, 0.1521]}, {"w": "forever),", "b": [0.4388, 0.1307, 0.5104, 0.1521]}, {"w": "the", "b": [0.5151, 0.1307, 0.5414, 0.1521]}, {"w": "validation", "b": [0.5462, 0.1307, 0.6295, 0.1521]}, {"w": "set", "b": [0.6342, 0.1307, 0.6571, 0.1521]}, {"w": "and", "b": [0.6618, 0.1307, 0.6934, 0.1521]}, {"w": "the", "b": [0.6981, 0.1307, 0.7244, 0.1521]}, {"w": "test", "b": [0.7292, 0.1307, 0.7584, 0.1521]}, {"w": "set:", "b": [0.7631, 0.1307, 0.7907, 0.1521]}]}, {"id": "b_5", "type": "paragraph", "text": "train_set = csv_reader_dataset(train_filepaths, repeat=None) valid_set = csv_reader_dataset(valid_filepaths) test_set = csv_reader_dataset(test_filepaths)", "words": [{"w": "train_set", "b": [0.1766, 0.1627, 0.2525, 0.1755]}, {"w": "=", "b": [0.2609, 0.1627, 0.2693, 0.1755]}, {"w": "csv_reader_dataset(train_filepaths,", "b": [0.2778, 0.1627, 0.5729, 0.1755]}, {"w": "repeat=None)", "b": [0.5813, 0.1627, 0.6825, 0.1755]}, {"w": "valid_set", "b": [0.1766, 0.1781, 0.2525, 0.191]}, {"w": "=", "b": [0.2609, 0.1781, 0.2693, 0.191]}, {"w": "csv_reader_dataset(valid_filepaths)", "b": [0.2778, 0.1781, 0.5729, 0.191]}, {"w": "test_set", "b": [0.1766, 0.1935, 0.244, 0.2064]}, {"w": "=", "b": [0.2525, 0.1935, 0.2609, 0.2064]}, {"w": "csv_reader_dataset(test_filepaths)", "b": [0.2693, 0.1935, 0.556, 0.2064]}]}, {"id": "b_6", "type": "paragraph", "text": "And now we can simply build and train a Keras model using these datasets.3 All we need to do is to call the fit() method with the datasets instead of X_train and y_train, and specify the number of steps per epoch for each set:4", "words": [{"w": "And", "b": [0.1429, 0.2142, 0.1797, 0.2356]}, {"w": "now", "b": [0.1861, 0.2142, 0.2224, 0.2356]}, {"w": "we", "b": [0.2288, 0.2142, 0.2519, 0.2356]}, {"w": "can", "b": [0.2584, 0.2142, 0.2877, 0.2356]}, {"w": "simply", "b": [0.2941, 0.2142, 0.3498, 0.2356]}, {"w": "build", "b": [0.3562, 0.2142, 0.3997, 0.2356]}, {"w": "and", "b": [0.4061, 0.2142, 0.4377, 0.2356]}, {"w": "train", "b": [0.4441, 0.2142, 0.4843, 0.2356]}, {"w": "a", "b": [0.4907, 0.2142, 0.4999, 0.2356]}, {"w": "Keras", "b": [0.5063, 0.2142, 0.5532, 0.2356]}, {"w": "model", "b": [0.5596, 0.2142, 0.6125, 0.2356]}, {"w": "using", "b": [0.6189, 0.2142, 0.6643, 0.2356]}, {"w": "these", "b": [0.6708, 0.2142, 0.7136, 0.2356]}, {"w": "datasets.3", "b": [0.72, 0.2142, 0.7962, 0.2356]}, {"w": "All", "b": [0.8027, 0.2142, 0.8276, 0.2356]}, {"w": "we", "b": [0.834, 0.2142, 0.8571, 0.2356]}, {"w": "need", "b": [0.1429, 0.2341, 0.183, 0.2555]}, {"w": "to", "b": [0.1916, 0.2341, 0.2085, 0.2555]}, {"w": "do", "b": [0.2171, 0.2341, 0.2388, 0.2555]}, {"w": "is", "b": [0.2474, 0.2341, 0.2606, 0.2555]}, {"w": "to", "b": [0.2692, 0.2341, 0.2862, 0.2555]}, {"w": "call", "b": [0.2948, 0.2341, 0.3233, 0.2555]}, {"w": "the", "b": [0.3319, 0.2341, 0.3582, 0.2555]}, {"w": "fit()", "b": [0.3668, 0.2373, 0.4163, 0.2524]}, {"w": "method", "b": [0.4249, 0.2341, 0.4899, 0.2555]}, {"w": "with", "b": [0.4985, 0.2341, 0.5359, 0.2555]}, {"w": "the", "b": [0.5445, 0.2341, 0.5708, 0.2555]}, {"w": "datasets", "b": [0.5794, 0.2341, 0.6451, 0.2555]}, {"w": "instead", "b": [0.6538, 0.2341, 0.7137, 0.2555]}, {"w": "of", "b": [0.7223, 0.2341, 0.7391, 0.2555]}, {"w": "X_train", "b": [0.7477, 0.2373, 0.817, 0.2524]}, {"w": "and", "b": [0.8256, 0.2341, 0.8571, 0.2555]}, {"w": "y_train,", "b": [0.1429, 0.2541, 0.2169, 0.2755]}, {"w": "and", "b": [0.2216, 0.2541, 0.2532, 0.2755]}, {"w": "specify", "b": [0.2579, 0.2541, 0.3158, 0.2755]}, {"w": "the", "b": [0.3205, 0.2541, 0.3468, 0.2755]}, {"w": "number", "b": [0.3516, 0.2541, 0.4179, 0.2755]}, {"w": "of", "b": [0.4226, 0.2541, 0.4394, 0.2755]}, {"w": "steps", "b": [0.4441, 0.2541, 0.4855, 0.2755]}, {"w": "per", "b": [0.4903, 0.2541, 0.5178, 0.2755]}, {"w": "epoch", "b": [0.5225, 0.2541, 0.5728, 0.2755]}, {"w": "for", "b": [0.5775, 0.2541, 0.6021, 0.2755]}, {"w": "each", "b": [0.6068, 0.2541, 0.6447, 0.2755]}, {"w": "set:4", "b": [0.6495, 0.2541, 0.6828, 0.2755]}]}, {"id": "b_7", "type": "paragraph", "text": "model = keras.models.Sequential([...]) model.compile([...]) model.fit(train_set, steps_per_epoch=len(X_train) // batch_size, epochs=10, validation_data=valid_set, validation_steps=len(X_valid) // batch_size)", "words": [{"w": "model", "b": [0.1766, 0.286, 0.2188, 0.2989]}, {"w": "=", "b": [0.2272, 0.286, 0.2356, 0.2989]}, {"w": "keras.models.Sequential([...])", "b": [0.2441, 0.286, 0.497, 0.2989]}, {"w": "model.compile([...])", "b": [0.1766, 0.3015, 0.3452, 0.3143]}, {"w": "model.fit(train_set,", "b": [0.1766, 0.3169, 0.3452, 0.3297]}, {"w": "steps_per_epoch=len(X_train)", "b": [0.3537, 0.3169, 0.5898, 0.3297]}, {"w": "//", "b": [0.5982, 0.3169, 0.6151, 0.3297]}, {"w": "batch_size,", "b": [0.6235, 0.3169, 0.7163, 0.3297]}, {"w": "epochs=10,", "b": [0.7247, 0.3169, 0.809, 0.3297]}, {"w": "validation_data=valid_set,", "b": [0.2609, 0.3323, 0.4802, 0.3451]}, {"w": "validation_steps=len(X_valid)", "b": [0.2609, 0.3477, 0.5055, 0.3606]}, {"w": "//", "b": [0.5139, 0.3477, 0.5308, 0.3606]}, {"w": "batch_size)", "b": [0.5392, 0.3477, 0.6319, 0.3606]}]}, {"id": "b_8", "type": "paragraph", "text": "Similarly, we can pass a dataset to the evaluate() and predict() methods (and again specify the number of steps per epoch):", "words": [{"w": "Similarly,", "b": [0.1428, 0.3692, 0.2212, 0.3907]}, {"w": "we", "b": [0.2259, 0.3692, 0.249, 0.3907]}, {"w": "can", "b": [0.2537, 0.3692, 0.2831, 0.3907]}, {"w": "pass", "b": [0.2878, 0.3692, 0.3232, 0.3907]}, {"w": "a", "b": [0.3279, 0.3692, 0.3371, 0.3907]}, {"w": "dataset", "b": [0.3418, 0.3692, 0.3999, 0.3907]}, {"w": "to", "b": [0.4046, 0.3692, 0.4216, 0.3907]}, {"w": "the", "b": [0.4263, 0.3692, 0.4527, 0.3907]}, {"w": "evaluate()", "b": [0.4575, 0.3724, 0.5564, 0.3875]}, {"w": "and", "b": [0.5612, 0.3692, 0.5927, 0.3907]}, {"w": "predict()", "b": [0.5974, 0.3724, 0.6865, 0.3875]}, {"w": "methods", "b": [0.6912, 0.3692, 0.7639, 0.3907]}, {"w": "(and", "b": [0.7686, 0.3692, 0.8074, 0.3907]}, {"w": "again", "b": [0.8121, 0.3692, 0.8571, 0.3907]}, {"w": "specify", "b": [0.1429, 0.3883, 0.2008, 0.4097]}, {"w": "the", "b": [0.2055, 0.3883, 0.2318, 0.4097]}, {"w": "number", "b": [0.2366, 0.3883, 0.3028, 0.4097]}, {"w": "of", "b": [0.3076, 0.3883, 0.3244, 0.4097]}, {"w": "steps", "b": [0.3291, 0.3883, 0.3705, 0.4097]}, {"w": "per", "b": [0.3752, 0.3883, 0.4027, 0.4097]}, {"w": "epoch):", "b": [0.4075, 0.3883, 0.4698, 0.4097]}]}, {"id": "b_9", "type": "paragraph", "text": "model.evaluate(test_set, steps=len(X_test) // batch_size) model.predict(new_set, steps=len(X_new) // batch_size)", "words": [{"w": "model.evaluate(test_set,", "b": [0.1766, 0.4203, 0.379, 0.4331]}, {"w": "steps=len(X_test)", "b": [0.3874, 0.4203, 0.5308, 0.4331]}, {"w": "//", "b": [0.5392, 0.4203, 0.5561, 0.4331]}, {"w": "batch_size)", "b": [0.5645, 0.4203, 0.6572, 0.4331]}, {"w": "model.predict(new_set,", "b": [0.1766, 0.4357, 0.3621, 0.4485]}, {"w": "steps=len(X_new)", "b": [0.3705, 0.4357, 0.5055, 0.4485]}, {"w": "//", "b": [0.5139, 0.4357, 0.5308, 0.4485]}, {"w": "batch_size)", "b": [0.5392, 0.4357, 0.6319, 0.4485]}]}, {"id": "b_10", "type": "paragraph", "text": "Unlike the other sets, the new_set will usually not contain labels (if it does, Keras will just ignore them). Note that in all these cases, you can still use NumPy arrays instead of datasets if you want (but of course they need to have been loaded and preprocessed first).", "words": [{"w": "Unlike", "b": [0.1428, 0.4572, 0.1987, 0.4786]}, {"w": "the", "b": [0.2039, 0.4572, 0.2303, 0.4786]}, {"w": "other", "b": [0.2355, 0.4572, 0.2801, 0.4786]}, {"w": "sets,", "b": [0.2853, 0.4572, 0.3206, 0.4786]}, {"w": "the", "b": [0.3258, 0.4572, 0.3521, 0.4786]}, {"w": "new_set", "b": [0.3573, 0.4604, 0.4266, 0.4755]}, {"w": "will", "b": [0.4318, 0.4572, 0.4622, 0.4786]}, {"w": "usually", "b": [0.4674, 0.4572, 0.5264, 0.4786]}, {"w": "not", "b": [0.5316, 0.4572, 0.56, 0.4786]}, {"w": "contain", "b": [0.5652, 0.4572, 0.6281, 0.4786]}, {"w": "labels", "b": [0.6333, 0.4572, 0.6801, 0.4786]}, {"w": "(if", "b": [0.6853, 0.4572, 0.7042, 0.4786]}, {"w": "it", "b": [0.7094, 0.4572, 0.7214, 0.4786]}, {"w": "does,", "b": [0.7266, 0.4572, 0.7694, 0.4786]}, {"w": "Keras", "b": [0.7746, 0.4572, 0.8215, 0.4786]}, {"w": "will", "b": [0.8267, 0.4572, 0.8571, 0.4786]}, {"w": "just", "b": [0.1428, 0.4763, 0.1732, 0.4977]}, {"w": "ignore", "b": [0.1787, 0.4763, 0.2326, 0.4977]}, {"w": "them).", "b": [0.2381, 0.4763, 0.2934, 0.4977]}, {"w": "Note", "b": [0.2989, 0.4763, 0.3397, 0.4977]}, {"w": "that", "b": [0.3452, 0.4763, 0.3777, 0.4977]}, {"w": "in", "b": [0.3832, 0.4763, 0.4002, 0.4977]}, {"w": "all", "b": [0.4056, 0.4763, 0.4253, 0.4977]}, {"w": "these", "b": [0.4308, 0.4763, 0.4736, 0.4977]}, {"w": "cases,", "b": [0.4791, 0.4763, 0.5259, 0.4977]}, {"w": "you", "b": [0.5314, 0.4763, 0.5626, 0.4977]}, {"w": "can", "b": [0.5681, 0.4763, 0.5974, 0.4977]}, {"w": "still", "b": [0.6029, 0.4763, 0.633, 0.4977]}, {"w": "use", "b": [0.6385, 0.4763, 0.666, 0.4977]}, {"w": "NumPy", "b": [0.6715, 0.4763, 0.7357, 0.4977]}, {"w": "arrays", "b": [0.7411, 0.4763, 0.7917, 0.4977]}, {"w": "instead", "b": [0.7972, 0.4763, 0.8571, 0.4977]}, {"w": "of", "b": [0.1429, 0.4953, 0.1597, 0.5167]}, {"w": "datasets", "b": [0.1645, 0.4953, 0.2303, 0.5167]}, {"w": "if", "b": [0.2352, 0.4953, 0.2469, 0.5167]}, {"w": "you", "b": [0.2518, 0.4953, 0.283, 0.5167]}, {"w": "want", "b": [0.2879, 0.4953, 0.3287, 0.5167]}, {"w": "(but", "b": [0.3336, 0.4953, 0.3688, 0.5167]}, {"w": "of", "b": [0.3736, 0.4953, 0.3904, 0.5167]}, {"w": "course", "b": [0.3953, 0.4953, 0.45, 0.5167]}, {"w": "they", "b": [0.4549, 0.4953, 0.4908, 0.5167]}, {"w": "need", "b": [0.4957, 0.4953, 0.5358, 0.5167]}, {"w": "to", "b": [0.5407, 0.4953, 0.5577, 0.5167]}, {"w": "have", "b": [0.5625, 0.4953, 0.6009, 0.5167]}, {"w": "been", "b": [0.6058, 0.4953, 0.6455, 0.5167]}, {"w": "loaded", "b": [0.6504, 0.4953, 0.7063, 0.5167]}, {"w": "and", "b": [0.7111, 0.4953, 0.7427, 0.5167]}, {"w": "preprocessed", "b": [0.7476, 0.4953, 0.8571, 0.5167]}, {"w": "first).", "b": [0.1429, 0.5144, 0.1883, 0.5358]}]}, {"id": "b_11", "type": "paragraph", "text": "If you want to build your own custom training loop (as in Chapter 12), you can just iterate over the training set, very naturally:", "words": [{"w": "If", "b": [0.1429, 0.5425, 0.1561, 0.5639]}, {"w": "you", "b": [0.1621, 0.5425, 0.1934, 0.5639]}, {"w": "want", "b": [0.1993, 0.5425, 0.2401, 0.5639]}, {"w": "to", "b": [0.2461, 0.5425, 0.2631, 0.5639]}, {"w": "build", "b": [0.2691, 0.5425, 0.3126, 0.5639]}, {"w": "your", "b": [0.3186, 0.5425, 0.3575, 0.5639]}, {"w": "own", "b": [0.3635, 0.5425, 0.3998, 0.5639]}, {"w": "custom", "b": [0.4058, 0.5425, 0.4674, 0.5639]}, {"w": "training", "b": [0.4734, 0.5425, 0.5403, 0.5639]}, {"w": "loop", "b": [0.5463, 0.5425, 0.5837, 0.5639]}, {"w": "(as", "b": [0.5897, 0.5425, 0.6137, 0.5639]}, {"w": "in", "b": [0.6197, 0.5425, 0.6367, 0.5639]}, {"w": "Chapter", "b": [0.6427, 0.5425, 0.7102, 0.5639]}, {"w": "12),", "b": [0.7162, 0.5425, 0.7482, 0.5639]}, {"w": "you", "b": [0.7542, 0.5425, 0.7854, 0.5639]}, {"w": "can", "b": [0.7914, 0.5425, 0.8208, 0.5639]}, {"w": "just", "b": [0.8267, 0.5425, 0.8571, 0.5639]}, {"w": "iterate", "b": [0.1429, 0.5615, 0.1953, 0.5829]}, {"w": "over", "b": [0.2001, 0.5615, 0.2369, 0.5829]}, {"w": "the", "b": [0.2416, 0.5615, 0.268, 0.5829]}, {"w": "training", "b": [0.2727, 0.5615, 0.3396, 0.5829]}, {"w": "set,", "b": [0.3444, 0.5615, 0.372, 0.5829]}, {"w": "very", "b": [0.3767, 0.5615, 0.4131, 0.5829]}, {"w": "naturally:", "b": [0.4178, 0.5615, 0.4978, 0.5829]}]}, {"id": "b_12", "type": "equation", "text": "for X_batch, y_batch in train_set: [...] # perform one gradient descent step", "words": [{"w": "for", "b": [0.1766, 0.5935, 0.2019, 0.6063]}, {"w": "X_batch,", "b": [0.2103, 0.5935, 0.2778, 0.6063]}, {"w": "y_batch", "b": [0.2862, 0.5935, 0.3452, 0.6063]}, {"w": "in", "b": [0.3537, 0.5935, 0.3705, 0.6063]}, {"w": "train_set:", "b": [0.379, 0.5935, 0.4633, 0.6063]}, {"w": "[...]", "b": [0.2103, 0.6089, 0.2525, 0.6218]}, {"w": "#", "b": [0.2609, 0.6089, 0.2693, 0.6218]}, {"w": "perform", "b": [0.2778, 0.6089, 0.3368, 0.6218]}, {"w": "one", "b": [0.3452, 0.6089, 0.3705, 0.6218]}, {"w": "gradient", "b": [0.379, 0.6089, 0.4464, 0.6218]}, {"w": "descent", "b": [0.4549, 0.6089, 0.5139, 0.6218]}, {"w": "step", "b": [0.5223, 0.6089, 0.5561, 0.6218]}]}, {"id": "b_13", "type": "paragraph", "text": "In fact, it is even possible to create a tf.function (see Chapter 12) that performs the whole training loop!5", "words": [{"w": "In", "b": [0.1429, 0.6295, 0.1614, 0.651]}, {"w": "fact,", "b": [0.1682, 0.6295, 0.2034, 0.651]}, {"w": "it", "b": [0.2102, 0.6295, 0.2222, 0.651]}, {"w": "is", "b": [0.229, 0.6295, 0.2422, 0.651]}, {"w": "even", "b": [0.2491, 0.6295, 0.2878, 0.651]}, {"w": "possible", "b": [0.2946, 0.6295, 0.3618, 0.651]}, {"w": "to", "b": [0.3686, 0.6295, 0.3856, 0.651]}, {"w": "create", "b": [0.3924, 0.6295, 0.4417, 0.651]}, {"w": "a", "b": [0.4486, 0.6295, 0.4577, 0.651]}, {"w": "tf.function", "b": [0.4645, 0.6295, 0.5532, 0.651]}, {"w": "(see", "b": [0.56, 0.6295, 0.5926, 0.651]}, {"w": "Chapter", "b": [0.5994, 0.6295, 0.667, 0.651]}, {"w": "12)", "b": [0.6738, 0.6295, 0.701, 0.651]}, {"w": "that", "b": [0.7079, 0.6295, 0.7404, 0.651]}, {"w": "performs", "b": [0.7473, 0.6295, 0.824, 0.651]}, {"w": "the", "b": [0.8308, 0.6295, 0.8572, 0.651]}, {"w": "whole", "b": [0.1429, 0.6486, 0.193, 0.67]}, {"w": "training", "b": [0.1977, 0.6486, 0.2647, 0.67]}, {"w": "loop!5", "b": [0.2694, 0.6486, 0.3183, 0.67]}]}, {"id": "b_14", "type": "paragraph", "text": "@tf.function def train(model, optimizer, loss_fn, n_epochs, [...]): train_set = csv_reader_dataset(train_filepaths, repeat=n_epochs, [...]) for X_batch, y_batch in train_set: with tf.GradientTape() as tape:", "words": [{"w": "@tf.function", "b": [0.1766, 0.6806, 0.2778, 0.6934]}, {"w": "def", "b": [0.1766, 0.696, 0.2019, 0.7088]}, {"w": "train(model,", "b": [0.2103, 0.696, 0.3115, 0.7088]}, {"w": "optimizer,", "b": [0.3199, 0.696, 0.4043, 0.7088]}, {"w": "loss_fn,", "b": [0.4127, 0.696, 0.4802, 0.7088]}, {"w": "n_epochs,", "b": [0.4886, 0.696, 0.5645, 0.7088]}, {"w": "[...]):", "b": [0.5729, 0.696, 0.6319, 0.7088]}, {"w": "train_set", "b": [0.2103, 0.7114, 0.2862, 0.7243]}, {"w": "=", "b": [0.2946, 0.7114, 0.3031, 0.7243]}, {"w": "csv_reader_dataset(train_filepaths,", "b": [0.3115, 0.7114, 0.6066, 0.7243]}, {"w": "repeat=n_epochs,", "b": [0.6151, 0.7114, 0.75, 0.7243]}, {"w": "[...])", "b": [0.7584, 0.7114, 0.809, 0.7243]}, {"w": "for", "b": [0.2103, 0.7268, 0.2356, 0.7397]}, {"w": "X_batch,", "b": [0.244, 0.7268, 0.3115, 0.7397]}, {"w": "y_batch", "b": [0.3199, 0.7268, 0.379, 0.7397]}, {"w": "in", "b": [0.3874, 0.7268, 0.4043, 0.7397]}, {"w": "train_set:", "b": [0.4127, 0.7268, 0.497, 0.7397]}, {"w": "with", "b": [0.244, 0.7422, 0.2778, 0.7551]}, {"w": "tf.GradientTape()", "b": [0.2862, 0.7422, 0.4296, 0.7551]}, {"w": "as", "b": [0.438, 0.7422, 0.4549, 0.7551]}, {"w": "tape:", "b": [0.4633, 0.7422, 0.5055, 0.7551]}]}, {"id": "b_15", "type": "paragraph", "text": "The Data API | 413", "words": [{"w": "The", "b": [0.7213, 0.9225, 0.7428, 0.9388]}, {"w": "Data", "b": [0.7456, 0.9225, 0.7733, 0.9388]}, {"w": "API", "b": [0.7761, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "413", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 440, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "y_pred = model(X_batch) main_loss = tf.reduce_mean(loss_fn(y_batch, y_pred)) loss = tf.add_n([main_loss] + model.losses) grads = tape.gradient(loss, model.trainable_variables) optimizer.apply_gradients(zip(grads, model.trainable_variables))", "words": [{"w": "y_pred", "b": [0.2778, 0.0829, 0.3284, 0.0958]}, {"w": "=", "b": [0.3368, 0.0829, 0.3452, 0.0958]}, {"w": "model(X_batch)", "b": [0.3537, 0.0829, 0.4717, 0.0958]}, {"w": "main_loss", "b": [0.2778, 0.0983, 0.3537, 0.1112]}, {"w": "=", "b": [0.3621, 0.0983, 0.3705, 0.1112]}, {"w": "tf.reduce_mean(loss_fn(y_batch,", "b": [0.379, 0.0983, 0.6404, 0.1112]}, {"w": "y_pred))", "b": [0.6488, 0.0983, 0.7163, 0.1112]}, {"w": "loss", "b": [0.2778, 0.1138, 0.3115, 0.1266]}, {"w": "=", "b": [0.3199, 0.1138, 0.3284, 0.1266]}, {"w": "tf.add_n([main_loss]", "b": [0.3368, 0.1138, 0.5055, 0.1266]}, {"w": "+", "b": [0.5139, 0.1138, 0.5223, 0.1266]}, {"w": "model.losses)", "b": [0.5308, 0.1138, 0.6404, 0.1266]}, {"w": "grads", "b": [0.244, 0.1292, 0.2862, 0.142]}, {"w": "=", "b": [0.2946, 0.1292, 0.3031, 0.142]}, {"w": "tape.gradient(loss,", "b": [0.3115, 0.1292, 0.4717, 0.142]}, {"w": "model.trainable_variables)", "b": [0.4802, 0.1292, 0.6994, 0.142]}, {"w": "optimizer.apply_gradients(zip(grads,", "b": [0.244, 0.1446, 0.5476, 0.1574]}, {"w": "model.trainable_variables))", "b": [0.5561, 0.1446, 0.7837, 0.1574]}]}, {"id": "b_1", "type": "paragraph", "text": "Congratulations, you now know how to build powerful input pipelines using the Data API! However, so far we have used CSV files, which are common, simple and conve‐ nient, but they are not really efficient, and they do not support large or complex data structures very well, such as images or audio. So let’s use TFRecords instead.", "words": [{"w": "Congratulations,", "b": [0.1429, 0.1652, 0.2828, 0.1866]}, {"w": "you", "b": [0.2875, 0.1652, 0.3188, 0.1866]}, {"w": "now", "b": [0.3236, 0.1652, 0.3599, 0.1866]}, {"w": "know", "b": [0.3647, 0.1652, 0.4113, 0.1866]}, {"w": "how", "b": [0.4161, 0.1652, 0.4521, 0.1866]}, {"w": "to", "b": [0.4569, 0.1652, 0.4739, 0.1866]}, {"w": "build", "b": [0.4787, 0.1652, 0.5222, 0.1866]}, {"w": "powerful", "b": [0.527, 0.1652, 0.6019, 0.1866]}, {"w": "input", "b": [0.6067, 0.1652, 0.6516, 0.1866]}, {"w": "pipelines", "b": [0.6564, 0.1652, 0.7314, 0.1866]}, {"w": "using", "b": [0.7362, 0.1652, 0.7817, 0.1866]}, {"w": "the", "b": [0.7864, 0.1652, 0.8128, 0.1866]}, {"w": "Data", "b": [0.8176, 0.1652, 0.8571, 0.1866]}, {"w": "API!", "b": [0.1428, 0.1843, 0.1818, 0.2057]}, {"w": "However,", "b": [0.1874, 0.1843, 0.2663, 0.2057]}, {"w": "so", "b": [0.2719, 0.1843, 0.2902, 0.2057]}, {"w": "far", "b": [0.2958, 0.1843, 0.3189, 0.2057]}, {"w": "we", "b": [0.3245, 0.1843, 0.3476, 0.2057]}, {"w": "have", "b": [0.3532, 0.1843, 0.3916, 0.2057]}, {"w": "used", "b": [0.3972, 0.1843, 0.4358, 0.2057]}, {"w": "CSV", "b": [0.4414, 0.1843, 0.4798, 0.2057]}, {"w": "files,", "b": [0.4854, 0.1843, 0.5237, 0.2057]}, {"w": "which", "b": [0.5293, 0.1843, 0.5802, 0.2057]}, {"w": "are", "b": [0.5858, 0.1843, 0.6116, 0.2057]}, {"w": "common,", "b": [0.6172, 0.1843, 0.6975, 0.2057]}, {"w": "simple", "b": [0.7031, 0.1843, 0.7581, 0.2057]}, {"w": "and", "b": [0.7637, 0.1843, 0.7952, 0.2057]}, {"w": "conve‐", "b": [0.8009, 0.1843, 0.8571, 0.2057]}, {"w": "nient,", "b": [0.1429, 0.2033, 0.1908, 0.2247]}, {"w": "but", "b": [0.1963, 0.2033, 0.2243, 0.2247]}, {"w": "they", "b": [0.2298, 0.2033, 0.2657, 0.2247]}, {"w": "are", "b": [0.2712, 0.2033, 0.2969, 0.2247]}, {"w": "not", "b": [0.3024, 0.2033, 0.3308, 0.2247]}, {"w": "really", "b": [0.3363, 0.2033, 0.3821, 0.2247]}, {"w": "efficient,", "b": [0.3876, 0.2033, 0.4597, 0.2247]}, {"w": "and", "b": [0.4652, 0.2033, 0.4967, 0.2247]}, {"w": "they", "b": [0.5022, 0.2033, 0.5381, 0.2247]}, {"w": "do", "b": [0.5436, 0.2033, 0.5652, 0.2247]}, {"w": "not", "b": [0.5707, 0.2033, 0.5991, 0.2247]}, {"w": "support", "b": [0.6046, 0.2033, 0.6699, 0.2247]}, {"w": "large", "b": [0.6753, 0.2033, 0.7161, 0.2247]}, {"w": "or", "b": [0.7216, 0.2033, 0.7399, 0.2247]}, {"w": "complex", "b": [0.7454, 0.2033, 0.8164, 0.2247]}, {"w": "data", "b": [0.8219, 0.2033, 0.8572, 0.2247]}, {"w": "structures", "b": [0.1429, 0.2224, 0.2261, 0.2438]}, {"w": "very", "b": [0.2308, 0.2224, 0.2672, 0.2438]}, {"w": "well,", "b": [0.272, 0.2224, 0.3104, 0.2438]}, {"w": "such", "b": [0.3151, 0.2224, 0.3538, 0.2438]}, {"w": "as", "b": [0.3585, 0.2224, 0.3753, 0.2438]}, {"w": "images", "b": [0.38, 0.2224, 0.438, 0.2438]}, {"w": "or", "b": [0.4428, 0.2224, 0.4611, 0.2438]}, {"w": "audio.", "b": [0.4659, 0.2224, 0.517, 0.2438]}, {"w": "So", "b": [0.5218, 0.2224, 0.5423, 0.2438]}, {"w": "let’s", "b": [0.547, 0.2224, 0.5772, 0.2438]}, {"w": "use", "b": [0.5819, 0.2224, 0.6095, 0.2438]}, {"w": "TFRecords", "b": [0.6142, 0.2224, 0.7057, 0.2438]}, {"w": "instead.", "b": [0.7104, 0.2224, 0.7752, 0.2438]}]}, {"id": "b_2", "type": "paragraph", "text": "If you are happy with CSV files (or whatever other format you are using), you do not have to use TFRecords. As the saying goes, if it ain’t broke, don’t fix it! TFRecords are useful when the bottleneck during training is loading and parsing the data.", "words": [{"w": "If", "b": [0.2714, 0.2643, 0.2835, 0.2839]}, {"w": "you", "b": [0.289, 0.2643, 0.3176, 0.2839]}, {"w": "are", "b": [0.3231, 0.2643, 0.3466, 0.2839]}, {"w": "happy", "b": [0.3521, 0.2643, 0.399, 0.2839]}, {"w": "with", "b": [0.4045, 0.2643, 0.4387, 0.2839]}, {"w": "CSV", "b": [0.4442, 0.2643, 0.4793, 0.2839]}, {"w": "files", "b": [0.4848, 0.2643, 0.5154, 0.2839]}, {"w": "(or", "b": [0.5209, 0.2643, 0.5443, 0.2839]}, {"w": "whatever", "b": [0.5498, 0.2643, 0.6189, 0.2839]}, {"w": "other", "b": [0.6244, 0.2643, 0.6653, 0.2839]}, {"w": "format", "b": [0.6708, 0.2643, 0.7226, 0.2839]}, {"w": "you", "b": [0.7281, 0.2643, 0.7567, 0.2839]}, {"w": "are", "b": [0.7622, 0.2643, 0.7857, 0.2839]}, {"w": "using),", "b": [0.2714, 0.2817, 0.3239, 0.3013]}, {"w": "you", "b": [0.3294, 0.2817, 0.358, 0.3013]}, {"w": "do", "b": [0.3635, 0.2817, 0.3833, 0.3013]}, {"w": "not", "b": [0.3889, 0.2817, 0.4148, 0.3013]}, {"w": "have", "b": [0.4204, 0.2815, 0.4549, 0.3013]}, {"w": "to", "b": [0.4605, 0.2817, 0.476, 0.3013]}, {"w": "use", "b": [0.4815, 0.2817, 0.5067, 0.3013]}, {"w": "TFRecords.", "b": [0.5123, 0.2817, 0.6003, 0.3013]}, {"w": "As", "b": [0.6058, 0.2817, 0.626, 0.3013]}, {"w": "the", "b": [0.6315, 0.2817, 0.6556, 0.3013]}, {"w": "saying", "b": [0.6612, 0.2817, 0.7093, 0.3013]}, {"w": "goes,", "b": [0.7149, 0.2817, 0.7529, 0.3013]}, {"w": "if", "b": [0.7585, 0.2817, 0.7692, 0.3013]}, {"w": "it", "b": [0.7748, 0.2817, 0.7857, 0.3013]}, {"w": "ain’t", "b": [0.2714, 0.2991, 0.3031, 0.3187]}, {"w": "broke,", "b": [0.3093, 0.2991, 0.3576, 0.3187]}, {"w": "don’t", "b": [0.3638, 0.2991, 0.4018, 0.3187]}, {"w": "fix", "b": [0.408, 0.2991, 0.4277, 0.3187]}, {"w": "it!", "b": [0.4339, 0.2991, 0.4501, 0.3187]}, {"w": "TFRecords", "b": [0.4562, 0.2991, 0.5399, 0.3187]}, {"w": "are", "b": [0.546, 0.2991, 0.5695, 0.3187]}, {"w": "useful", "b": [0.5757, 0.2991, 0.6215, 0.3187]}, {"w": "when", "b": [0.6276, 0.2991, 0.6694, 0.3187]}, {"w": "the", "b": [0.6755, 0.2991, 0.6996, 0.3187]}, {"w": "bottleneck", "b": [0.7058, 0.2991, 0.7857, 0.3187]}, {"w": "during", "b": [0.2714, 0.3166, 0.3231, 0.3361]}, {"w": "training", "b": [0.3274, 0.3166, 0.3886, 0.3361]}, {"w": "is", "b": [0.3929, 0.3166, 0.405, 0.3361]}, {"w": "loading", "b": [0.4093, 0.3166, 0.4667, 0.3361]}, {"w": "and", "b": [0.4711, 0.3166, 0.4999, 0.3361]}, {"w": "parsing", "b": [0.5042, 0.3166, 0.5611, 0.3361]}, {"w": "the", "b": [0.5654, 0.3166, 0.5895, 0.3361]}, {"w": "data.", "b": [0.5938, 0.3166, 0.6304, 0.3361]}]}, {"id": "b_3", "type": "paragraph", "text": "The TFRecord Format", "words": [{"w": "The", "b": [0.1429, 0.3592, 0.1881, 0.3934]}, {"w": "TFRecord", "b": [0.194, 0.3592, 0.3068, 0.3934]}, {"w": "Format", "b": [0.3127, 0.3592, 0.4024, 0.3934]}]}, {"id": "b_4", "type": "paragraph", "text": "The TFRecord format is TensorFlow’s preferred format for storing large amounts of data and reading it efficiently. It is a very simple binary format that just contains a sequence of binary records of varying sizes (each record just has a length, a CRC checksum to check that the length was not corrupted, then the actual data, and finally a CRC checksum for the data). You can easily create a TFRecord file using the tf.io.TFRecordWriter class:", "words": [{"w": "The", "b": [0.1429, 0.4003, 0.1757, 0.4217]}, {"w": "TFRecord", "b": [0.1821, 0.4003, 0.2659, 0.4217]}, {"w": "format", "b": [0.2723, 0.4003, 0.329, 0.4217]}, {"w": "is", "b": [0.3355, 0.4003, 0.3487, 0.4217]}, {"w": "TensorFlow’s", "b": [0.3551, 0.4003, 0.4637, 0.4217]}, {"w": "preferred", "b": [0.4701, 0.4003, 0.5479, 0.4217]}, {"w": "format", "b": [0.5543, 0.4003, 0.611, 0.4217]}, {"w": "for", "b": [0.6174, 0.4003, 0.642, 0.4217]}, {"w": "storing", "b": [0.6484, 0.4003, 0.7075, 0.4217]}, {"w": "large", "b": [0.7139, 0.4003, 0.7546, 0.4217]}, {"w": "amounts", "b": [0.761, 0.4003, 0.8339, 0.4217]}, {"w": "of", "b": [0.8403, 0.4003, 0.8571, 0.4217]}, {"w": "data", "b": [0.1429, 0.4194, 0.1781, 0.4408]}, {"w": "and", "b": [0.1852, 0.4194, 0.2167, 0.4408]}, {"w": "reading", "b": [0.2238, 0.4194, 0.2873, 0.4408]}, {"w": "it", "b": [0.2944, 0.4194, 0.3063, 0.4408]}, {"w": "efficiently.", "b": [0.3134, 0.4194, 0.3988, 0.4408]}, {"w": "It", "b": [0.4059, 0.4194, 0.4186, 0.4408]}, {"w": "is", "b": [0.4257, 0.4194, 0.4389, 0.4408]}, {"w": "a", "b": [0.446, 0.4194, 0.4551, 0.4408]}, {"w": "very", "b": [0.4622, 0.4194, 0.4986, 0.4408]}, {"w": "simple", "b": [0.5057, 0.4194, 0.5606, 0.4408]}, {"w": "binary", "b": [0.5677, 0.4194, 0.6223, 0.4408]}, {"w": "format", "b": [0.6294, 0.4194, 0.6861, 0.4408]}, {"w": "that", "b": [0.6932, 0.4194, 0.7258, 0.4408]}, {"w": "just", "b": [0.7329, 0.4194, 0.7633, 0.4408]}, {"w": "contains", "b": [0.7704, 0.4194, 0.8409, 0.4408]}, {"w": "a", "b": [0.848, 0.4194, 0.8572, 0.4408]}, {"w": "sequence", "b": [0.1429, 0.4384, 0.219, 0.4598]}, {"w": "of", "b": [0.2269, 0.4384, 0.2437, 0.4598]}, {"w": "binary", "b": [0.2516, 0.4384, 0.3062, 0.4598]}, {"w": "records", "b": [0.3142, 0.4384, 0.3766, 0.4598]}, {"w": "of", "b": [0.3845, 0.4384, 0.4013, 0.4598]}, {"w": "varying", "b": [0.4092, 0.4384, 0.4726, 0.4598]}, {"w": "sizes", "b": [0.4806, 0.4384, 0.5191, 0.4598]}, {"w": "(each", "b": [0.527, 0.4384, 0.5721, 0.4598]}, {"w": "record", "b": [0.5801, 0.4384, 0.6348, 0.4598]}, {"w": "just", "b": [0.6427, 0.4384, 0.6731, 0.4598]}, {"w": "has", "b": [0.6811, 0.4384, 0.709, 0.4598]}, {"w": "a", "b": [0.7169, 0.4384, 0.7261, 0.4598]}, {"w": "length,", "b": [0.734, 0.4384, 0.7915, 0.4598]}, {"w": "a", "b": [0.7994, 0.4384, 0.8086, 0.4598]}, {"w": "CRC", "b": [0.8165, 0.4384, 0.8571, 0.4598]}, {"w": "checksum", "b": [0.1429, 0.4575, 0.2266, 0.4789]}, {"w": "to", "b": [0.2315, 0.4575, 0.2485, 0.4789]}, {"w": "check", "b": [0.2534, 0.4575, 0.3013, 0.4789]}, {"w": "that", "b": [0.3062, 0.4575, 0.3388, 0.4789]}, {"w": "the", "b": [0.3438, 0.4575, 0.3701, 0.4789]}, {"w": "length", "b": [0.375, 0.4575, 0.4278, 0.4789]}, {"w": "was", "b": [0.4327, 0.4575, 0.4637, 0.4789]}, {"w": "not", "b": [0.4687, 0.4575, 0.497, 0.4789]}, {"w": "corrupted,", "b": [0.502, 0.4575, 0.5898, 0.4789]}, {"w": "then", "b": [0.5947, 0.4575, 0.6325, 0.4789]}, {"w": "the", "b": [0.6374, 0.4575, 0.6637, 0.4789]}, {"w": "actual", "b": [0.6686, 0.4575, 0.7184, 0.4789]}, {"w": "data,", "b": [0.7234, 0.4575, 0.7634, 0.4789]}, {"w": "and", "b": [0.7683, 0.4575, 0.7998, 0.4789]}, {"w": "finally", "b": [0.8047, 0.4575, 0.8571, 0.4789]}, {"w": "a", "b": [0.1428, 0.4765, 0.152, 0.4979]}, {"w": "CRC", "b": [0.1616, 0.4765, 0.2023, 0.4979]}, {"w": "checksum", "b": [0.2119, 0.4765, 0.2956, 0.4979]}, {"w": "for", "b": [0.3053, 0.4765, 0.3298, 0.4979]}, {"w": "the", "b": [0.3394, 0.4765, 0.3658, 0.4979]}, {"w": "data).", "b": [0.3754, 0.4765, 0.4226, 0.4979]}, {"w": "You", "b": [0.4323, 0.4765, 0.4646, 0.4979]}, {"w": "can", "b": [0.4743, 0.4765, 0.5036, 0.4979]}, {"w": "easily", "b": [0.5132, 0.4765, 0.5593, 0.4979]}, {"w": "create", "b": [0.5689, 0.4765, 0.6183, 0.4979]}, {"w": "a", "b": [0.6279, 0.4765, 0.6371, 0.4979]}, {"w": "TFRecord", "b": [0.6467, 0.4765, 0.7306, 0.4979]}, {"w": "file", "b": [0.7402, 0.4765, 0.7661, 0.4979]}, {"w": "using", "b": [0.7757, 0.4765, 0.8212, 0.4979]}, {"w": "the", "b": [0.8308, 0.4765, 0.8571, 0.4979]}, {"w": "tf.io.TFRecordWriter", "b": [0.1429, 0.4997, 0.3408, 0.5147]}, {"w": "class:", "b": [0.3455, 0.4965, 0.3888, 0.5179]}]}, {"id": "b_5", "type": "paragraph", "text": "with tf.io.TFRecordWriter(\"my_data.tfrecord\") as f: f.write(b\"This is the first record\") f.write(b\"And this is the second record\")", "words": [{"w": "with", "b": [0.1766, 0.5284, 0.2103, 0.5413]}, {"w": "tf.io.TFRecordWriter(\"my_data.tfrecord\")", "b": [0.2188, 0.5284, 0.5561, 0.5413]}, {"w": "as", "b": [0.5645, 0.5284, 0.5814, 0.5413]}, {"w": "f:", "b": [0.5898, 0.5284, 0.6066, 0.5413]}, {"w": "f.write(b\"This", "b": [0.2103, 0.5439, 0.3284, 0.5567]}, {"w": "is", "b": [0.3368, 0.5439, 0.3537, 0.5567]}, {"w": "the", "b": [0.3621, 0.5439, 0.3874, 0.5567]}, {"w": "first", "b": [0.3958, 0.5439, 0.438, 0.5567]}, {"w": "record\")", "b": [0.4464, 0.5439, 0.5139, 0.5567]}, {"w": "f.write(b\"And", "b": [0.2103, 0.5593, 0.3199, 0.5721]}, {"w": "this", "b": [0.3284, 0.5593, 0.3621, 0.5721]}, {"w": "is", "b": [0.3705, 0.5593, 0.3874, 0.5721]}, {"w": "the", "b": [0.3958, 0.5593, 0.4211, 0.5721]}, {"w": "second", "b": [0.4296, 0.5593, 0.4802, 0.5721]}, {"w": "record\")", "b": [0.4886, 0.5593, 0.5561, 0.5721]}]}, {"id": "b_6", "type": "paragraph", "text": "And you can then use a tf.data.TFRecordDataset to read one or more TFRecord files:", "words": [{"w": "And", "b": [0.1429, 0.5808, 0.1797, 0.6022]}, {"w": "you", "b": [0.1866, 0.5808, 0.2179, 0.6022]}, {"w": "can", "b": [0.2249, 0.5808, 0.2542, 0.6022]}, {"w": "then", "b": [0.2612, 0.5808, 0.2989, 0.6022]}, {"w": "use", "b": [0.3059, 0.5808, 0.3335, 0.6022]}, {"w": "a", "b": [0.3405, 0.5808, 0.3496, 0.6022]}, {"w": "tf.data.TFRecordDataset", "b": [0.3566, 0.584, 0.5842, 0.5991]}, {"w": "to", "b": [0.5912, 0.5808, 0.6082, 0.6022]}, {"w": "read", "b": [0.6152, 0.5808, 0.6519, 0.6022]}, {"w": "one", "b": [0.6589, 0.5808, 0.6897, 0.6022]}, {"w": "or", "b": [0.6967, 0.5808, 0.7151, 0.6022]}, {"w": "more", "b": [0.7221, 0.5808, 0.7663, 0.6022]}, {"w": "TFRecord", "b": [0.7733, 0.5808, 0.8572, 0.6022]}, {"w": "files:", "b": [0.1429, 0.5999, 0.1811, 0.6213]}]}, {"id": "b_7", "type": "paragraph", "text": "filepaths = [\"my_data.tfrecord\"] dataset = tf.data.TFRecordDataset(filepaths) for item in dataset: print(item)", "words": [{"w": "filepaths", "b": [0.1766, 0.6318, 0.2525, 0.6447]}, {"w": "=", "b": [0.2609, 0.6318, 0.2694, 0.6447]}, {"w": "[\"my_data.tfrecord\"]", "b": [0.2778, 0.6318, 0.4464, 0.6447]}, {"w": "dataset", "b": [0.1766, 0.6473, 0.2356, 0.6601]}, {"w": "=", "b": [0.2441, 0.6473, 0.2525, 0.6601]}, {"w": "tf.data.TFRecordDataset(filepaths)", "b": [0.2609, 0.6473, 0.5476, 0.6601]}, {"w": "for", "b": [0.1766, 0.6627, 0.2019, 0.6755]}, {"w": "item", "b": [0.2103, 0.6627, 0.2441, 0.6755]}, {"w": "in", "b": [0.2525, 0.6627, 0.2694, 0.6755]}, {"w": "dataset:", "b": [0.2778, 0.6627, 0.3452, 0.6755]}, {"w": "print(item)", "b": [0.2103, 0.6781, 0.3031, 0.6909]}]}, {"id": "b_8", "type": "paragraph", "text": "This will output:", "words": [{"w": "This", "b": [0.1429, 0.6987, 0.1801, 0.7201]}, {"w": "will", "b": [0.1848, 0.6987, 0.2152, 0.7201]}, {"w": "output:", "b": [0.2199, 0.6987, 0.281, 0.7201]}]}, {"id": "b_9", "type": "paragraph", "text": "tf.Tensor(b'This is the first record', shape=(), dtype=string) tf.Tensor(b'And this is the second record', shape=(), dtype=string)", "words": [{"w": "tf.Tensor(b'This", "b": [0.1766, 0.7307, 0.3115, 0.7436]}, {"w": "is", "b": [0.3199, 0.7307, 0.3368, 0.7436]}, {"w": "the", "b": [0.3452, 0.7307, 0.3705, 0.7436]}, {"w": "first", "b": [0.379, 0.7307, 0.4211, 0.7436]}, {"w": "record',", "b": [0.4296, 0.7307, 0.497, 0.7436]}, {"w": "shape=(),", "b": [0.5055, 0.7307, 0.5814, 0.7436]}, {"w": "dtype=string)", "b": [0.5898, 0.7307, 0.6994, 0.7436]}, {"w": "tf.Tensor(b'And", "b": [0.1766, 0.7461, 0.3031, 0.759]}, {"w": "this", "b": [0.3115, 0.7461, 0.3452, 0.759]}, {"w": "is", "b": [0.3537, 0.7461, 0.3705, 0.759]}, {"w": "the", "b": [0.379, 0.7461, 0.4043, 0.759]}, {"w": "second", "b": [0.4127, 0.7461, 0.4633, 0.759]}, {"w": "record',", "b": [0.4717, 0.7461, 0.5392, 0.759]}, {"w": "shape=(),", "b": [0.5476, 0.7461, 0.6235, 0.759]}, {"w": "dtype=string)", "b": [0.632, 0.7461, 0.7416, 0.759]}]}, {"id": "b_10", "type": "paragraph", "text": "By default, a TFRecordDataset will read files one by one, but you can make it read multiple files in parallel and interleave their records by setting num_parallel_reads. Alternatively, you could obtain the same result by using list_files() and interleave() as we did earlier to read multiple CSV files.", "words": [{"w": "By", "b": [0.2714, 0.7814, 0.2913, 0.801]}, {"w": "default,", "b": [0.2975, 0.7814, 0.3544, 0.801]}, {"w": "a", "b": [0.3606, 0.7814, 0.3689, 0.801]}, {"w": "TFRecordDataset", "b": [0.3751, 0.7843, 0.5108, 0.7981]}, {"w": "will", "b": [0.517, 0.7814, 0.5448, 0.801]}, {"w": "read", "b": [0.551, 0.7814, 0.5846, 0.801]}, {"w": "files", "b": [0.5908, 0.7814, 0.6214, 0.801]}, {"w": "one", "b": [0.6276, 0.7814, 0.6558, 0.801]}, {"w": "by", "b": [0.662, 0.7814, 0.6804, 0.801]}, {"w": "one,", "b": [0.6866, 0.7814, 0.7192, 0.801]}, {"w": "but", "b": [0.7254, 0.7814, 0.751, 0.801]}, {"w": "you", "b": [0.7571, 0.7814, 0.7857, 0.801]}, {"w": "can", "b": [0.2714, 0.7988, 0.2982, 0.8184]}, {"w": "make", "b": [0.3078, 0.7988, 0.3493, 0.8184]}, {"w": "it", "b": [0.3589, 0.7988, 0.3698, 0.8184]}, {"w": "read", "b": [0.3794, 0.7988, 0.413, 0.8184]}, {"w": "multiple", "b": [0.4226, 0.7988, 0.4866, 0.8184]}, {"w": "files", "b": [0.4962, 0.7988, 0.5268, 0.8184]}, {"w": "in", "b": [0.5364, 0.7988, 0.5519, 0.8184]}, {"w": "parallel", "b": [0.5615, 0.7988, 0.6179, 0.8184]}, {"w": "and", "b": [0.6275, 0.7988, 0.6563, 0.8184]}, {"w": "interleave", "b": [0.6659, 0.7988, 0.7399, 0.8184]}, {"w": "their", "b": [0.7495, 0.7988, 0.7857, 0.8184]}, {"w": "records", "b": [0.2714, 0.8171, 0.3285, 0.8366]}, {"w": "by", "b": [0.3364, 0.8171, 0.3548, 0.8366]}, {"w": "setting", "b": [0.3627, 0.8171, 0.4138, 0.8366]}, {"w": "num_parallel_reads.", "b": [0.4217, 0.8171, 0.5889, 0.8366]}, {"w": "Alternatively,", "b": [0.5968, 0.8171, 0.6986, 0.8366]}, {"w": "you", "b": [0.7065, 0.8171, 0.735, 0.8366]}, {"w": "could", "b": [0.7429, 0.8171, 0.7857, 0.8366]}, {"w": "obtain", "b": [0.2714, 0.8353, 0.3205, 0.8549]}, {"w": "the", "b": [0.3271, 0.8353, 0.3512, 0.8549]}, {"w": "same", "b": [0.3579, 0.8353, 0.3969, 0.8549]}, {"w": "result", "b": [0.4036, 0.8353, 0.4465, 0.8549]}, {"w": "by", "b": [0.4531, 0.8353, 0.4716, 0.8549]}, {"w": "using", "b": [0.4782, 0.8353, 0.5198, 0.8549]}, {"w": "list_files()", "b": [0.5264, 0.8382, 0.635, 0.852]}, {"w": "and", "b": [0.6416, 0.8353, 0.6705, 0.8549]}, {"w": "interleave()", "b": [0.6771, 0.8382, 0.7857, 0.852]}, {"w": "as", "b": [0.2714, 0.8527, 0.2868, 0.8723]}, {"w": "we", "b": [0.2911, 0.8527, 0.3122, 0.8723]}, {"w": "did", "b": [0.3165, 0.8527, 0.3418, 0.8723]}, {"w": "earlier", "b": [0.3461, 0.8527, 0.3947, 0.8723]}, {"w": "to", "b": [0.399, 0.8527, 0.4145, 0.8723]}, {"w": "read", "b": [0.4189, 0.8527, 0.4525, 0.8723]}, {"w": "multiple", "b": [0.4568, 0.8527, 0.5208, 0.8723]}, {"w": "CSV", "b": [0.5251, 0.8527, 0.5602, 0.8723]}, {"w": "files.", "b": [0.5645, 0.8527, 0.5995, 0.8723]}]}, {"id": "b_11", "type": "paragraph", "text": "414 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "414", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 441, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 Since protobuf objects are meant to be serialized and transmitted, they are called messages.", "words": [{"w": "6", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "Since", "b": [0.1587, 0.8749, 0.1927, 0.8912]}, {"w": "protobuf", "b": [0.1963, 0.8749, 0.2527, 0.8912]}, {"w": "objects", "b": [0.2563, 0.8749, 0.3006, 0.8912]}, {"w": "are", "b": [0.3042, 0.8749, 0.3238, 0.8912]}, {"w": "meant", "b": [0.3274, 0.8749, 0.3674, 0.8912]}, {"w": "to", "b": [0.371, 0.8749, 0.3839, 0.8912]}, {"w": "be", "b": [0.3875, 0.8749, 0.4023, 0.8912]}, {"w": "serialized", "b": [0.4059, 0.8749, 0.4657, 0.8912]}, {"w": "and", "b": [0.4693, 0.8749, 0.4933, 0.8912]}, {"w": "transmitted,", "b": [0.4969, 0.8749, 0.5748, 0.8912]}, {"w": "they", "b": [0.5784, 0.8749, 0.6058, 0.8912]}, {"w": "are", "b": [0.6094, 0.8749, 0.629, 0.8912]}, {"w": "called", "b": [0.6326, 0.8749, 0.6694, 0.8912]}, {"w": "messages.", "b": [0.673, 0.8748, 0.7316, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Compressed TFRecord Files", "words": [{"w": "Compressed", "b": [0.1429, 0.0763, 0.2672, 0.1049]}, {"w": "TFRecord", "b": [0.2722, 0.0763, 0.3662, 0.1049]}, {"w": "Files", "b": [0.3712, 0.0763, 0.4177, 0.1049]}]}, {"id": "b_2", "type": "paragraph", "text": "It can sometimes be useful to compress your TFRecord files, especially if they need to be loaded via a network connection. You can create a compressed TFRecord file by setting the options argument:", "words": [{"w": "It", "b": [0.1429, 0.1108, 0.1555, 0.1322]}, {"w": "can", "b": [0.1606, 0.1108, 0.19, 0.1322]}, {"w": "sometimes", "b": [0.1951, 0.1108, 0.2848, 0.1322]}, {"w": "be", "b": [0.2899, 0.1108, 0.3093, 0.1322]}, {"w": "useful", "b": [0.3144, 0.1108, 0.3645, 0.1322]}, {"w": "to", "b": [0.3696, 0.1108, 0.3866, 0.1322]}, {"w": "compress", "b": [0.3917, 0.1108, 0.4706, 0.1322]}, {"w": "your", "b": [0.4757, 0.1108, 0.5147, 0.1322]}, {"w": "TFRecord", "b": [0.5198, 0.1108, 0.6036, 0.1322]}, {"w": "files,", "b": [0.6087, 0.1108, 0.647, 0.1322]}, {"w": "especially", "b": [0.6521, 0.1108, 0.732, 0.1322]}, {"w": "if", "b": [0.7371, 0.1108, 0.7489, 0.1322]}, {"w": "they", "b": [0.754, 0.1108, 0.7899, 0.1322]}, {"w": "need", "b": [0.795, 0.1108, 0.8351, 0.1322]}, {"w": "to", "b": [0.8402, 0.1108, 0.8572, 0.1322]}, {"w": "be", "b": [0.1429, 0.1298, 0.1623, 0.1512]}, {"w": "loaded", "b": [0.1691, 0.1298, 0.225, 0.1512]}, {"w": "via", "b": [0.2318, 0.1298, 0.2562, 0.1512]}, {"w": "a", "b": [0.263, 0.1298, 0.2721, 0.1512]}, {"w": "network", "b": [0.2789, 0.1298, 0.3485, 0.1512]}, {"w": "connection.", "b": [0.3553, 0.1298, 0.4539, 0.1512]}, {"w": "You", "b": [0.4607, 0.1298, 0.4931, 0.1512]}, {"w": "can", "b": [0.4999, 0.1298, 0.5292, 0.1512]}, {"w": "create", "b": [0.536, 0.1298, 0.5854, 0.1512]}, {"w": "a", "b": [0.5922, 0.1298, 0.6013, 0.1512]}, {"w": "compressed", "b": [0.6081, 0.1298, 0.7069, 0.1512]}, {"w": "TFRecord", "b": [0.7137, 0.1298, 0.7975, 0.1512]}, {"w": "file", "b": [0.8043, 0.1298, 0.8302, 0.1512]}, {"w": "by", "b": [0.837, 0.1298, 0.8571, 0.1512]}, {"w": "setting", "b": [0.1429, 0.1498, 0.1988, 0.1712]}, {"w": "the", "b": [0.2035, 0.1498, 0.2299, 0.1712]}, {"w": "options", "b": [0.2346, 0.153, 0.3039, 0.168]}, {"w": "argument:", "b": [0.3086, 0.1498, 0.3943, 0.1712]}]}, {"id": "b_3", "type": "paragraph", "text": "options = tf.io.TFRecordOptions(compression_type=\"GZIP\") with tf.io.TFRecordWriter(\"my_compressed.tfrecord\", options) as f: [...]", "words": [{"w": "options", "b": [0.1766, 0.1817, 0.2356, 0.1946]}, {"w": "=", "b": [0.244, 0.1817, 0.2525, 0.1946]}, {"w": "tf.io.TFRecordOptions(compression_type=\"GZIP\")", "b": [0.2609, 0.1817, 0.6488, 0.1946]}, {"w": "with", "b": [0.1766, 0.1972, 0.2103, 0.21]}, {"w": "tf.io.TFRecordWriter(\"my_compressed.tfrecord\",", "b": [0.2187, 0.1972, 0.6066, 0.21]}, {"w": "options)", "b": [0.6151, 0.1972, 0.6825, 0.21]}, {"w": "as", "b": [0.691, 0.1972, 0.7078, 0.21]}, {"w": "f:", "b": [0.7163, 0.1972, 0.7331, 0.21]}, {"w": "[...]", "b": [0.1934, 0.2126, 0.2356, 0.2254]}]}, {"id": "b_4", "type": "paragraph", "text": "When reading a compressed TFRecord file, you need to specify the compression type:", "words": [{"w": "When", "b": [0.1429, 0.2332, 0.1945, 0.2546]}, {"w": "reading", "b": [0.1992, 0.2332, 0.2627, 0.2546]}, {"w": "a", "b": [0.2674, 0.2332, 0.2765, 0.2546]}, {"w": "compressed", "b": [0.2813, 0.2332, 0.38, 0.2546]}, {"w": "TFRecord", "b": [0.3847, 0.2332, 0.4686, 0.2546]}, {"w": "file,", "b": [0.4733, 0.2332, 0.5039, 0.2546]}, {"w": "you", "b": [0.5087, 0.2332, 0.5399, 0.2546]}, {"w": "need", "b": [0.5446, 0.2332, 0.5847, 0.2546]}, {"w": "to", "b": [0.5895, 0.2332, 0.6064, 0.2546]}, {"w": "specify", "b": [0.6112, 0.2332, 0.6691, 0.2546]}, {"w": "the", "b": [0.6738, 0.2332, 0.7001, 0.2546]}, {"w": "compression", "b": [0.7049, 0.2332, 0.8114, 0.2546]}, {"w": "type:", "b": [0.8161, 0.2332, 0.8565, 0.2546]}]}, {"id": "b_5", "type": "paragraph", "text": "dataset = tf.data.TFRecordDataset([\"my_compressed.tfrecord\"], compression_type=\"GZIP\")", "words": [{"w": "dataset", "b": [0.1766, 0.2652, 0.2356, 0.278]}, {"w": "=", "b": [0.2441, 0.2652, 0.2525, 0.278]}, {"w": "tf.data.TFRecordDataset([\"my_compressed.tfrecord\"],", "b": [0.2609, 0.2652, 0.691, 0.278]}, {"w": "compression_type=\"GZIP\")", "b": [0.4633, 0.2806, 0.6657, 0.2935]}]}, {"id": "b_6", "type": "paragraph", "text": "A Brief Introduction to Protocol Buffers", "words": [{"w": "A", "b": [0.1429, 0.3073, 0.1569, 0.3359]}, {"w": "Brief", "b": [0.1618, 0.3073, 0.2114, 0.3359]}, {"w": "Introduction", "b": [0.2164, 0.3073, 0.3456, 0.3359]}, {"w": "to", "b": [0.3505, 0.3073, 0.3723, 0.3359]}, {"w": "Protocol", "b": [0.3773, 0.3073, 0.4631, 0.3359]}, {"w": "Buffers", "b": [0.468, 0.3073, 0.5416, 0.3359]}]}, {"id": "b_7", "type": "paragraph", "text": "Even though each record can use any binary format you want, TFRecord files usually contain serialized Protocol Buffers (also called protobufs). This is a portable, extensi‐ ble and efficient binary format developed at Google back in 2001 and Open Sourced in 2008, and they are now widely used, in particular in gRPC, Google’s remote proce‐ dure call system. Protocol Buffers are defined using a simple language that looks like this:", "words": [{"w": "Even", "b": [0.1429, 0.3418, 0.1842, 0.3632]}, {"w": "though", "b": [0.1895, 0.3418, 0.2495, 0.3632]}, {"w": "each", "b": [0.2549, 0.3418, 0.2928, 0.3632]}, {"w": "record", "b": [0.2981, 0.3418, 0.3529, 0.3632]}, {"w": "can", "b": [0.3582, 0.3418, 0.3876, 0.3632]}, {"w": "use", "b": [0.3929, 0.3418, 0.4205, 0.3632]}, {"w": "any", "b": [0.4258, 0.3418, 0.4554, 0.3632]}, {"w": "binary", "b": [0.4607, 0.3418, 0.5153, 0.3632]}, {"w": "format", "b": [0.5207, 0.3418, 0.5774, 0.3632]}, {"w": "you", "b": [0.5827, 0.3418, 0.6139, 0.3632]}, {"w": "want,", "b": [0.6193, 0.3418, 0.6648, 0.3632]}, {"w": "TFRecord", "b": [0.6701, 0.3418, 0.7539, 0.3632]}, {"w": "files", "b": [0.7593, 0.3418, 0.7928, 0.3632]}, {"w": "usually", "b": [0.7981, 0.3418, 0.8571, 0.3632]}, {"w": "contain", "b": [0.1429, 0.3608, 0.2058, 0.3822]}, {"w": "serialized", "b": [0.2117, 0.3608, 0.2902, 0.3822]}, {"w": "Protocol", "b": [0.2961, 0.3608, 0.3679, 0.3822]}, {"w": "Buffers", "b": [0.3739, 0.3608, 0.4337, 0.3822]}, {"w": "(also", "b": [0.4397, 0.3608, 0.4796, 0.3822]}, {"w": "called", "b": [0.4856, 0.3608, 0.5339, 0.3822]}, {"w": "protobufs).", "b": [0.5399, 0.3606, 0.6275, 0.3822]}, {"w": "This", "b": [0.6335, 0.3608, 0.6707, 0.3822]}, {"w": "is", "b": [0.6767, 0.3608, 0.6899, 0.3822]}, {"w": "a", "b": [0.6959, 0.3608, 0.705, 0.3822]}, {"w": "portable,", "b": [0.711, 0.3608, 0.7852, 0.3822]}, {"w": "extensi‐", "b": [0.7912, 0.3608, 0.8571, 0.3822]}, {"w": "ble", "b": [0.1429, 0.3799, 0.1676, 0.4013]}, {"w": "and", "b": [0.1735, 0.3799, 0.205, 0.4013]}, {"w": "efficient", "b": [0.211, 0.3799, 0.2784, 0.4013]}, {"w": "binary", "b": [0.2843, 0.3799, 0.3389, 0.4013]}, {"w": "format", "b": [0.3448, 0.3799, 0.4015, 0.4013]}, {"w": "developed", "b": [0.4075, 0.3799, 0.4925, 0.4013]}, {"w": "at", "b": [0.4984, 0.3799, 0.5135, 0.4013]}, {"w": "Google", "b": [0.5194, 0.3799, 0.5795, 0.4013]}, {"w": "back", "b": [0.5854, 0.3799, 0.6243, 0.4013]}, {"w": "in", "b": [0.6302, 0.3799, 0.6472, 0.4013]}, {"w": "2001", "b": [0.6531, 0.3799, 0.6931, 0.4013]}, {"w": "and", "b": [0.6991, 0.3799, 0.7306, 0.4013]}, {"w": "Open", "b": [0.7365, 0.3799, 0.7833, 0.4013]}, {"w": "Sourced", "b": [0.7892, 0.3799, 0.8572, 0.4013]}, {"w": "in", "b": [0.1429, 0.3989, 0.1598, 0.4203]}, {"w": "2008,", "b": [0.1651, 0.3989, 0.2098, 0.4203]}, {"w": "and", "b": [0.2151, 0.3989, 0.2466, 0.4203]}, {"w": "they", "b": [0.2519, 0.3989, 0.2878, 0.4203]}, {"w": "are", "b": [0.293, 0.3989, 0.3188, 0.4203]}, {"w": "now", "b": [0.324, 0.3989, 0.3603, 0.4203]}, {"w": "widely", "b": [0.3656, 0.3989, 0.4201, 0.4203]}, {"w": "used,", "b": [0.4254, 0.3989, 0.4687, 0.4203]}, {"w": "in", "b": [0.4739, 0.3989, 0.4909, 0.4203]}, {"w": "particular", "b": [0.4962, 0.3989, 0.5779, 0.4203]}, {"w": "in", "b": [0.5832, 0.3989, 0.6001, 0.4203]}, {"w": "gRPC,", "b": [0.6054, 0.3989, 0.6584, 0.4203]}, {"w": "Google’s", "b": [0.6637, 0.3989, 0.7328, 0.4203]}, {"w": "remote", "b": [0.7381, 0.3989, 0.7975, 0.4203]}, {"w": "proce‐", "b": [0.8028, 0.3989, 0.8571, 0.4203]}, {"w": "dure", "b": [0.1429, 0.418, 0.1815, 0.4394]}, {"w": "call", "b": [0.1872, 0.418, 0.2157, 0.4394]}, {"w": "system.", "b": [0.2214, 0.418, 0.2833, 0.4394]}, {"w": "Protocol", "b": [0.289, 0.418, 0.3607, 0.4394]}, {"w": "Buffers", "b": [0.3664, 0.418, 0.4263, 0.4394]}, {"w": "are", "b": [0.432, 0.418, 0.4577, 0.4394]}, {"w": "defined", "b": [0.4634, 0.418, 0.5263, 0.4394]}, {"w": "using", "b": [0.532, 0.418, 0.5774, 0.4394]}, {"w": "a", "b": [0.5831, 0.418, 0.5922, 0.4394]}, {"w": "simple", "b": [0.5979, 0.418, 0.6529, 0.4394]}, {"w": "language", "b": [0.6586, 0.418, 0.7329, 0.4394]}, {"w": "that", "b": [0.7386, 0.418, 0.7712, 0.4394]}, {"w": "looks", "b": [0.7769, 0.418, 0.8214, 0.4394]}, {"w": "like", "b": [0.8271, 0.418, 0.8571, 0.4394]}, {"w": "this:", "b": [0.1428, 0.437, 0.1783, 0.4584]}]}, {"id": "b_8", "type": "paragraph", "text": "syntax = \"proto3\"; message Person { string name = 1; int32 id = 2; repeated string email = 3; }", "words": [{"w": "syntax", "b": [0.1766, 0.469, 0.2272, 0.4818]}, {"w": "=", "b": [0.2356, 0.469, 0.244, 0.4818]}, {"w": "\"proto3\";", "b": [0.2525, 0.469, 0.3284, 0.4818]}, {"w": "message", "b": [0.1766, 0.4844, 0.2356, 0.4973]}, {"w": "Person", "b": [0.244, 0.4844, 0.2946, 0.4973]}, {"w": "{", "b": [0.3031, 0.4844, 0.3115, 0.4973]}, {"w": "string", "b": [0.1934, 0.4998, 0.244, 0.5127]}, {"w": "name", "b": [0.2525, 0.4998, 0.2862, 0.5127]}, {"w": "=", "b": [0.2946, 0.4998, 0.3031, 0.5127]}, {"w": "1;", "b": [0.3115, 0.4998, 0.3284, 0.5127]}, {"w": "int32", "b": [0.1934, 0.5152, 0.2356, 0.5281]}, {"w": "id", "b": [0.244, 0.5152, 0.2609, 0.5281]}, {"w": "=", "b": [0.2693, 0.5152, 0.2778, 0.5281]}, {"w": "2;", "b": [0.2862, 0.5152, 0.3031, 0.5281]}, {"w": "repeated", "b": [0.1934, 0.5307, 0.2609, 0.5435]}, {"w": "string", "b": [0.2693, 0.5307, 0.3199, 0.5435]}, {"w": "email", "b": [0.3284, 0.5307, 0.3705, 0.5435]}, {"w": "=", "b": [0.379, 0.5307, 0.3874, 0.5435]}, {"w": "3;", "b": [0.3958, 0.5307, 0.4127, 0.5435]}, {"w": "}", "b": [0.1766, 0.5461, 0.185, 0.5589]}]}, {"id": "b_9", "type": "paragraph", "text": "This definition says we are using the protobuf format version 3, and it specifies that each Person object6 may (optionally) have a name of type string, an id of type int32, and zero or more email fields, each of type string. The numbers 1, 2 and 3 are the field identifiers: they will be used in each record’s binary representation. Once you have a definition in a .proto file, you can compile it. This requires protoc, the proto‐ buf compiler, to generate access classes in Python (or some other language). Note that the protobuf definitions we will use have already been compiled for you, and their Python classes are part of TensorFlow, so you will not need to use protoc. All you need to know is how to use protobuf access classes in Python. To illustrate the basics, let’s look at a simple example that uses the access classes generated for the Person protobuf (the code is explained in the comments):", "words": [{"w": "This", "b": [0.1429, 0.5667, 0.1801, 0.5881]}, {"w": "definition", "b": [0.1863, 0.5667, 0.2688, 0.5881]}, {"w": "says", "b": [0.2751, 0.5667, 0.3087, 0.5881]}, {"w": "we", "b": [0.3149, 0.5667, 0.338, 0.5881]}, {"w": "are", "b": [0.3443, 0.5667, 0.37, 0.5881]}, {"w": "using", "b": [0.3762, 0.5667, 0.4217, 0.5881]}, {"w": "the", "b": [0.4279, 0.5667, 0.4542, 0.5881]}, {"w": "protobuf", "b": [0.4604, 0.5667, 0.5345, 0.5881]}, {"w": "format", "b": [0.5407, 0.5667, 0.5974, 0.5881]}, {"w": "version", "b": [0.6036, 0.5667, 0.6651, 0.5881]}, {"w": "3,", "b": [0.6714, 0.5667, 0.6861, 0.5881]}, {"w": "and", "b": [0.6923, 0.5667, 0.7239, 0.5881]}, {"w": "it", "b": [0.7301, 0.5667, 0.742, 0.5881]}, {"w": "specifies", "b": [0.7483, 0.5667, 0.8183, 0.5881]}, {"w": "that", "b": [0.8246, 0.5667, 0.8571, 0.5881]}, {"w": "each", "b": [0.1429, 0.5867, 0.1808, 0.6081]}, {"w": "Person", "b": [0.1858, 0.5898, 0.2452, 0.6049]}, {"w": "object6", "b": [0.2502, 0.5867, 0.3065, 0.6081]}, {"w": "may", "b": [0.3115, 0.5867, 0.3469, 0.6081]}, {"w": "(optionally)", "b": [0.3519, 0.5867, 0.4511, 0.6081]}, {"w": "have", "b": [0.4561, 0.5867, 0.4945, 0.6081]}, {"w": "a", "b": [0.4995, 0.5867, 0.5087, 0.6081]}, {"w": "name", "b": [0.5137, 0.5898, 0.5533, 0.6049]}, {"w": "of", "b": [0.5583, 0.5867, 0.5751, 0.6081]}, {"w": "type", "b": [0.5798, 0.5867, 0.6155, 0.6081]}, {"w": "string,", "b": [0.6208, 0.5867, 0.685, 0.6081]}, {"w": "an", "b": [0.6897, 0.5867, 0.7102, 0.6081]}, {"w": "id", "b": [0.7156, 0.5898, 0.7354, 0.6049]}, {"w": "of", "b": [0.7404, 0.5867, 0.7572, 0.6081]}, {"w": "type", "b": [0.7619, 0.5867, 0.7976, 0.6081]}, {"w": "int32,", "b": [0.8029, 0.5867, 0.8571, 0.6081]}, {"w": "and", "b": [0.1428, 0.6066, 0.1744, 0.628]}, {"w": "zero", "b": [0.1806, 0.6066, 0.2166, 0.628]}, {"w": "or", "b": [0.2228, 0.6066, 0.2411, 0.628]}, {"w": "more", "b": [0.2474, 0.6066, 0.2916, 0.628]}, {"w": "email", "b": [0.2979, 0.6098, 0.3473, 0.6249]}, {"w": "fields,", "b": [0.3536, 0.6066, 0.4028, 0.628]}, {"w": "each", "b": [0.409, 0.6066, 0.447, 0.628]}, {"w": "of", "b": [0.4532, 0.6066, 0.47, 0.628]}, {"w": "type", "b": [0.4762, 0.6066, 0.5119, 0.628]}, {"w": "string.", "b": [0.5181, 0.6066, 0.5822, 0.628]}, {"w": "The", "b": [0.5885, 0.6066, 0.6213, 0.628]}, {"w": "numbers", "b": [0.6275, 0.6066, 0.7015, 0.628]}, {"w": "1,", "b": [0.7077, 0.6066, 0.7224, 0.628]}, {"w": "2", "b": [0.7286, 0.6066, 0.7386, 0.628]}, {"w": "and", "b": [0.7449, 0.6066, 0.7764, 0.628]}, {"w": "3", "b": [0.7826, 0.6066, 0.7926, 0.628]}, {"w": "are", "b": [0.7989, 0.6066, 0.8246, 0.628]}, {"w": "the", "b": [0.8308, 0.6066, 0.8571, 0.628]}, {"w": "field", "b": [0.1429, 0.6257, 0.1797, 0.6471]}, {"w": "identifiers:", "b": [0.1871, 0.6257, 0.2762, 0.6471]}, {"w": "they", "b": [0.2836, 0.6257, 0.3195, 0.6471]}, {"w": "will", "b": [0.3269, 0.6257, 0.3573, 0.6471]}, {"w": "be", "b": [0.3647, 0.6257, 0.3841, 0.6471]}, {"w": "used", "b": [0.3915, 0.6257, 0.4301, 0.6471]}, {"w": "in", "b": [0.4375, 0.6257, 0.4545, 0.6471]}, {"w": "each", "b": [0.4619, 0.6257, 0.4998, 0.6471]}, {"w": "record’s", "b": [0.5072, 0.6257, 0.5717, 0.6471]}, {"w": "binary", "b": [0.5791, 0.6257, 0.6337, 0.6471]}, {"w": "representation.", "b": [0.6411, 0.6257, 0.7665, 0.6471]}, {"w": "Once", "b": [0.7739, 0.6257, 0.8185, 0.6471]}, {"w": "you", "b": [0.8259, 0.6257, 0.8571, 0.6471]}, {"w": "have", "b": [0.1429, 0.6456, 0.1813, 0.667]}, {"w": "a", "b": [0.1862, 0.6456, 0.1954, 0.667]}, {"w": "definition", "b": [0.2003, 0.6456, 0.2829, 0.667]}, {"w": "in", "b": [0.2879, 0.6456, 0.3048, 0.667]}, {"w": "a", "b": [0.3098, 0.6456, 0.319, 0.667]}, {"w": ".proto", "b": [0.3239, 0.6488, 0.3833, 0.6639]}, {"w": "file,", "b": [0.3883, 0.6456, 0.4189, 0.667]}, {"w": "you", "b": [0.4239, 0.6456, 0.4551, 0.667]}, {"w": "can", "b": [0.4601, 0.6456, 0.4895, 0.667]}, {"w": "compile", "b": [0.4944, 0.6456, 0.5612, 0.667]}, {"w": "it.", "b": [0.5661, 0.6456, 0.5828, 0.667]}, {"w": "This", "b": [0.5878, 0.6456, 0.625, 0.667]}, {"w": "requires", "b": [0.63, 0.6456, 0.6981, 0.667]}, {"w": "protoc,", "b": [0.7031, 0.6456, 0.7672, 0.667]}, {"w": "the", "b": [0.7719, 0.6456, 0.7983, 0.667]}, {"w": "proto‐", "b": [0.803, 0.6456, 0.8567, 0.667]}, {"w": "buf", "b": [0.1429, 0.6646, 0.1707, 0.6861]}, {"w": "compiler,", "b": [0.1755, 0.6646, 0.2534, 0.6861]}, {"w": "to", "b": [0.2583, 0.6646, 0.2753, 0.6861]}, {"w": "generate", "b": [0.2801, 0.6646, 0.3507, 0.6861]}, {"w": "access", "b": [0.3555, 0.6646, 0.4065, 0.6861]}, {"w": "classes", "b": [0.4113, 0.6646, 0.4663, 0.6861]}, {"w": "in", "b": [0.4712, 0.6646, 0.4882, 0.6861]}, {"w": "Python", "b": [0.493, 0.6646, 0.5538, 0.6861]}, {"w": "(or", "b": [0.5587, 0.6646, 0.5843, 0.6861]}, {"w": "some", "b": [0.5891, 0.6646, 0.6333, 0.6861]}, {"w": "other", "b": [0.6382, 0.6646, 0.6829, 0.6861]}, {"w": "language).", "b": [0.6877, 0.6646, 0.7741, 0.6861]}, {"w": "Note", "b": [0.7789, 0.6646, 0.8197, 0.6861]}, {"w": "that", "b": [0.8246, 0.6646, 0.8571, 0.6861]}, {"w": "the", "b": [0.1429, 0.6837, 0.1692, 0.7051]}, {"w": "protobuf", "b": [0.1765, 0.6837, 0.2505, 0.7051]}, {"w": "definitions", "b": [0.2578, 0.6837, 0.348, 0.7051]}, {"w": "we", "b": [0.3552, 0.6837, 0.3783, 0.7051]}, {"w": "will", "b": [0.3856, 0.6837, 0.416, 0.7051]}, {"w": "use", "b": [0.4233, 0.6837, 0.4508, 0.7051]}, {"w": "have", "b": [0.4581, 0.6837, 0.4965, 0.7051]}, {"w": "already", "b": [0.5037, 0.6837, 0.5645, 0.7051]}, {"w": "been", "b": [0.5717, 0.6837, 0.6114, 0.7051]}, {"w": "compiled", "b": [0.6187, 0.6837, 0.6964, 0.7051]}, {"w": "for", "b": [0.7037, 0.6837, 0.7282, 0.7051]}, {"w": "you,", "b": [0.7354, 0.6837, 0.7714, 0.7051]}, {"w": "and", "b": [0.7787, 0.6837, 0.8102, 0.7051]}, {"w": "their", "b": [0.8175, 0.6837, 0.8571, 0.7051]}, {"w": "Python", "b": [0.1429, 0.7036, 0.2036, 0.725]}, {"w": "classes", "b": [0.2108, 0.7036, 0.2658, 0.725]}, {"w": "are", "b": [0.2729, 0.7036, 0.2987, 0.725]}, {"w": "part", "b": [0.3058, 0.7036, 0.34, 0.725]}, {"w": "of", "b": [0.3471, 0.7036, 0.3639, 0.725]}, {"w": "TensorFlow,", "b": [0.371, 0.7036, 0.4725, 0.725]}, {"w": "so", "b": [0.4796, 0.7036, 0.4979, 0.725]}, {"w": "you", "b": [0.5051, 0.7036, 0.5363, 0.725]}, {"w": "will", "b": [0.5434, 0.7036, 0.5738, 0.725]}, {"w": "not", "b": [0.581, 0.7036, 0.6093, 0.725]}, {"w": "need", "b": [0.6165, 0.7036, 0.6566, 0.725]}, {"w": "to", "b": [0.6637, 0.7036, 0.6807, 0.725]}, {"w": "use", "b": [0.6878, 0.7036, 0.7154, 0.725]}, {"w": "protoc.", "b": [0.7225, 0.7036, 0.7867, 0.725]}, {"w": "All", "b": [0.7938, 0.7036, 0.8187, 0.725]}, {"w": "you", "b": [0.8259, 0.7036, 0.8571, 0.725]}, {"w": "need", "b": [0.1428, 0.7227, 0.183, 0.7441]}, {"w": "to", "b": [0.1882, 0.7227, 0.2052, 0.7441]}, {"w": "know", "b": [0.2105, 0.7227, 0.2571, 0.7441]}, {"w": "is", "b": [0.2624, 0.7227, 0.2757, 0.7441]}, {"w": "how", "b": [0.281, 0.7227, 0.317, 0.7441]}, {"w": "to", "b": [0.3223, 0.7227, 0.3393, 0.7441]}, {"w": "use", "b": [0.3446, 0.7227, 0.3721, 0.7441]}, {"w": "protobuf", "b": [0.3774, 0.7227, 0.4515, 0.7441]}, {"w": "access", "b": [0.4568, 0.7227, 0.5077, 0.7441]}, {"w": "classes", "b": [0.513, 0.7227, 0.568, 0.7441]}, {"w": "in", "b": [0.5733, 0.7227, 0.5903, 0.7441]}, {"w": "Python.", "b": [0.5956, 0.7227, 0.6611, 0.7441]}, {"w": "To", "b": [0.6664, 0.7227, 0.6879, 0.7441]}, {"w": "illustrate", "b": [0.6932, 0.7227, 0.766, 0.7441]}, {"w": "the", "b": [0.7713, 0.7227, 0.7977, 0.7441]}, {"w": "basics,", "b": [0.803, 0.7227, 0.8571, 0.7441]}, {"w": "let’s", "b": [0.1429, 0.7426, 0.1731, 0.764]}, {"w": "look", "b": [0.1807, 0.7426, 0.2176, 0.764]}, {"w": "at", "b": [0.2252, 0.7426, 0.2403, 0.764]}, {"w": "a", "b": [0.2479, 0.7426, 0.257, 0.764]}, {"w": "simple", "b": [0.2647, 0.7426, 0.3196, 0.764]}, {"w": "example", "b": [0.3272, 0.7426, 0.3968, 0.764]}, {"w": "that", "b": [0.4044, 0.7426, 0.437, 0.764]}, {"w": "uses", "b": [0.4446, 0.7426, 0.4798, 0.764]}, {"w": "the", "b": [0.4874, 0.7426, 0.5137, 0.764]}, {"w": "access", "b": [0.5214, 0.7426, 0.5723, 0.764]}, {"w": "classes", "b": [0.5799, 0.7426, 0.6349, 0.764]}, {"w": "generated", "b": [0.6425, 0.7426, 0.7241, 0.764]}, {"w": "for", "b": [0.7317, 0.7426, 0.7562, 0.764]}, {"w": "the", "b": [0.7638, 0.7426, 0.7902, 0.764]}, {"w": "Person", "b": [0.7978, 0.7458, 0.8571, 0.7609]}, {"w": "protobuf", "b": [0.1429, 0.7617, 0.2169, 0.7831]}, {"w": "(the", "b": [0.2216, 0.7617, 0.2552, 0.7831]}, {"w": "code", "b": [0.2599, 0.7617, 0.2992, 0.7831]}, {"w": "is", "b": [0.3039, 0.7617, 0.3172, 0.7831]}, {"w": "explained", "b": [0.3219, 0.7617, 0.4028, 0.7831]}, {"w": "in", "b": [0.4075, 0.7617, 0.4245, 0.7831]}, {"w": "the", "b": [0.4292, 0.7617, 0.4555, 0.7831]}, {"w": "comments):", "b": [0.4603, 0.7617, 0.5596, 0.7831]}]}, {"id": "b_10", "type": "paragraph", "text": ">>> from person_pb2 import Person # import the generated access class >>> person = Person(name=\"Al\", id=123, email=[\"a@b.com\"]) # create a Person >>> print(person) # display the Person", "words": [{"w": ">>>", "b": [0.1766, 0.7937, 0.2019, 0.8065]}, {"w": "from", "b": [0.2103, 0.7937, 0.244, 0.8065]}, {"w": "person_pb2", "b": [0.2525, 0.7937, 0.3368, 0.8065]}, {"w": "import", "b": [0.3452, 0.7937, 0.3958, 0.8065]}, {"w": "Person", "b": [0.4043, 0.7937, 0.4549, 0.8065]}, {"w": "#", "b": [0.4717, 0.7937, 0.4802, 0.8065]}, {"w": "import", "b": [0.4886, 0.7937, 0.5392, 0.8065]}, {"w": "the", "b": [0.5476, 0.7937, 0.5729, 0.8065]}, {"w": "generated", "b": [0.5813, 0.7937, 0.6572, 0.8065]}, {"w": "access", "b": [0.6657, 0.7937, 0.7163, 0.8065]}, {"w": "class", "b": [0.7247, 0.7937, 0.7669, 0.8065]}, {"w": ">>>", "b": [0.1766, 0.8091, 0.2019, 0.8219]}, {"w": "person", "b": [0.2103, 0.8091, 0.2609, 0.8219]}, {"w": "=", "b": [0.2693, 0.8091, 0.2778, 0.8219]}, {"w": "Person(name=\"Al\",", "b": [0.2862, 0.8091, 0.4296, 0.8219]}, {"w": "id=123,", "b": [0.438, 0.8091, 0.497, 0.8219]}, {"w": "email=[\"a@b.com\"])", "b": [0.5055, 0.8091, 0.6572, 0.8219]}, {"w": "#", "b": [0.6741, 0.8091, 0.6825, 0.8219]}, {"w": "create", "b": [0.691, 0.8091, 0.7416, 0.8219]}, {"w": "a", "b": [0.75, 0.8091, 0.7584, 0.8219]}, {"w": "Person", "b": [0.7669, 0.8091, 0.8175, 0.8219]}, {"w": ">>>", "b": [0.1766, 0.8245, 0.2019, 0.8373]}, {"w": "print(person)", "b": [0.2103, 0.8245, 0.3199, 0.8373]}, {"w": "#", "b": [0.3368, 0.8245, 0.3452, 0.8373]}, {"w": "display", "b": [0.3537, 0.8245, 0.4127, 0.8373]}, {"w": "the", "b": [0.4211, 0.8245, 0.4464, 0.8373]}, {"w": "Person", "b": [0.4549, 0.8245, 0.5055, 0.8373]}]}, {"id": "b_11", "type": "paragraph", "text": "The TFRecord Format | 415", "words": [{"w": "The", "b": [0.6723, 0.9225, 0.6938, 0.9388]}, {"w": "TFRecord", "b": [0.6967, 0.9225, 0.7503, 0.9388]}, {"w": "Format", "b": [0.7532, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "415", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 442, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "7 This chapter contains the bare minimum you need to know about protobufs to use TFRecords. To learn more about protobufs, please visit https://homl.info/protobuf.", "words": [{"w": "7", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "This", "b": [0.1587, 0.8598, 0.1871, 0.8761]}, {"w": "chapter", "b": [0.1907, 0.8598, 0.2383, 0.8761]}, {"w": "contains", "b": [0.2419, 0.8598, 0.2957, 0.8761]}, {"w": "the", "b": [0.2993, 0.8598, 0.3194, 0.8761]}, {"w": "bare", "b": [0.323, 0.8598, 0.3506, 0.8761]}, {"w": "minimum", "b": [0.3542, 0.8598, 0.4186, 0.8761]}, {"w": "you", "b": [0.4222, 0.8598, 0.446, 0.8761]}, {"w": "need", "b": [0.4496, 0.8598, 0.4801, 0.8761]}, {"w": "to", "b": [0.4837, 0.8598, 0.4967, 0.8761]}, {"w": "know", "b": [0.5003, 0.8598, 0.5358, 0.8761]}, {"w": "about", "b": [0.5394, 0.8598, 0.5758, 0.8761]}, {"w": "protobufs", "b": [0.5794, 0.8598, 0.6417, 0.8761]}, {"w": "to", "b": [0.6453, 0.8598, 0.6582, 0.8761]}, {"w": "use", "b": [0.6618, 0.8598, 0.6828, 0.8761]}, {"w": "TFRecords.", "b": [0.6864, 0.8598, 0.7597, 0.8761]}, {"w": "To", "b": [0.7633, 0.8598, 0.7797, 0.8761]}, {"w": "learn", "b": [0.7833, 0.8598, 0.8156, 0.8761]}, {"w": "more", "b": [0.8192, 0.8598, 0.8529, 0.8761]}, {"w": "about", "b": [0.1587, 0.8749, 0.1951, 0.8912]}, {"w": "protobufs,", "b": [0.1987, 0.8749, 0.2646, 0.8912]}, {"w": "please", "b": [0.2682, 0.8749, 0.3068, 0.8912]}, {"w": "visit", "b": [0.3104, 0.8749, 0.337, 0.8912]}, {"w": "https://homl.info/protobuf.", "b": [0.3406, 0.8748, 0.5055, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "name: \"Al\" id: 123 email: \"a@b.com\" >>> person.name # read a field \"Al\" >>> person.name = \"Alice\" # modify a field >>> person.email[0] # repeated fields can be accessed like arrays \"a@b.com\" >>> person.email.append(\"c@d.com\") # add an email address >>> s = person.SerializeToString() # serialize the object to a byte string >>> s b'\\n\\x05Alice\\x10{\\x1a\\x07a@b.com\\x1a\\x07c@d.com' >>> person2 = Person() # create a new Person >>> person2.ParseFromString(s) # parse the byte string (27 bytes long) 27 >>> person == person2 # now they are equal True", "words": [{"w": "name:", "b": [0.1766, 0.0829, 0.2188, 0.0958]}, {"w": "\"Al\"", "b": [0.2272, 0.0829, 0.2609, 0.0958]}, {"w": "id:", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "123", "b": [0.2103, 0.0983, 0.2356, 0.1112]}, {"w": "email:", "b": [0.1766, 0.1138, 0.2272, 0.1266]}, {"w": "\"a@b.com\"", "b": [0.2356, 0.1138, 0.3115, 0.1266]}, {"w": ">>>", "b": [0.1766, 0.1292, 0.2019, 0.142]}, {"w": "person.name", "b": [0.2103, 0.1292, 0.3031, 0.142]}, {"w": "#", "b": [0.3199, 0.1292, 0.3284, 0.142]}, {"w": "read", "b": [0.3368, 0.1292, 0.3705, 0.142]}, {"w": "a", "b": [0.379, 0.1292, 0.3874, 0.142]}, {"w": "field", "b": [0.3958, 0.1292, 0.438, 0.142]}, {"w": "\"Al\"", "b": [0.1766, 0.1446, 0.2103, 0.1574]}, {"w": ">>>", "b": [0.1766, 0.16, 0.2019, 0.1729]}, {"w": "person.name", "b": [0.2103, 0.16, 0.3031, 0.1729]}, {"w": "=", "b": [0.3115, 0.16, 0.3199, 0.1729]}, {"w": "\"Alice\"", "b": [0.3284, 0.16, 0.3874, 0.1729]}, {"w": "#", "b": [0.4043, 0.16, 0.4127, 0.1729]}, {"w": "modify", "b": [0.4211, 0.16, 0.4717, 0.1729]}, {"w": "a", "b": [0.4802, 0.16, 0.4886, 0.1729]}, {"w": "field", "b": [0.497, 0.16, 0.5392, 0.1729]}, {"w": ">>>", "b": [0.1766, 0.1754, 0.2019, 0.1883]}, {"w": "person.email[0]", "b": [0.2103, 0.1754, 0.3368, 0.1883]}, {"w": "#", "b": [0.3537, 0.1754, 0.3621, 0.1883]}, {"w": "repeated", "b": [0.3705, 0.1754, 0.438, 0.1883]}, {"w": "fields", "b": [0.4464, 0.1754, 0.497, 0.1883]}, {"w": "can", "b": [0.5055, 0.1754, 0.5308, 0.1883]}, {"w": "be", "b": [0.5392, 0.1754, 0.5561, 0.1883]}, {"w": "accessed", "b": [0.5645, 0.1754, 0.6319, 0.1883]}, {"w": "like", "b": [0.6404, 0.1754, 0.6741, 0.1883]}, {"w": "arrays", "b": [0.6825, 0.1754, 0.7331, 0.1883]}, {"w": "\"a@b.com\"", "b": [0.1766, 0.1909, 0.2525, 0.2037]}, {"w": ">>>", "b": [0.1766, 0.2063, 0.2019, 0.2191]}, {"w": "person.email.append(\"c@d.com\")", "b": [0.2103, 0.2063, 0.4633, 0.2191]}, {"w": "#", "b": [0.4802, 0.2063, 0.4886, 0.2191]}, {"w": "add", "b": [0.497, 0.2063, 0.5223, 0.2191]}, {"w": "an", "b": [0.5308, 0.2063, 0.5476, 0.2191]}, {"w": "email", "b": [0.5561, 0.2063, 0.5982, 0.2191]}, {"w": "address", "b": [0.6066, 0.2063, 0.6657, 0.2191]}, {"w": ">>>", "b": [0.1766, 0.2217, 0.2019, 0.2345]}, {"w": "s", "b": [0.2103, 0.2217, 0.2188, 0.2345]}, {"w": "=", "b": [0.2272, 0.2217, 0.2356, 0.2345]}, {"w": "person.SerializeToString()", "b": [0.244, 0.2217, 0.4633, 0.2345]}, {"w": "#", "b": [0.4802, 0.2217, 0.4886, 0.2345]}, {"w": "serialize", "b": [0.497, 0.2217, 0.5729, 0.2345]}, {"w": "the", "b": [0.5814, 0.2217, 0.6066, 0.2345]}, {"w": "object", "b": [0.6151, 0.2217, 0.6657, 0.2345]}, {"w": "to", "b": [0.6741, 0.2217, 0.691, 0.2345]}, {"w": "a", "b": [0.6994, 0.2217, 0.7078, 0.2345]}, {"w": "byte", "b": [0.7163, 0.2217, 0.75, 0.2345]}, {"w": "string", "b": [0.7584, 0.2217, 0.809, 0.2345]}, {"w": ">>>", "b": [0.1766, 0.2371, 0.2019, 0.25]}, {"w": "s", "b": [0.2103, 0.2371, 0.2188, 0.25]}, {"w": "b'\\n\\x05Alice\\x10{\\x1a\\x07a@b.com\\x1a\\x07c@d.com'", "b": [0.1766, 0.2525, 0.5898, 0.2654]}, {"w": ">>>", "b": [0.1766, 0.268, 0.2019, 0.2808]}, {"w": "person2", "b": [0.2103, 0.268, 0.2693, 0.2808]}, {"w": "=", "b": [0.2778, 0.268, 0.2862, 0.2808]}, {"w": "Person()", "b": [0.2946, 0.268, 0.3621, 0.2808]}, {"w": "#", "b": [0.379, 0.268, 0.3874, 0.2808]}, {"w": "create", "b": [0.3958, 0.268, 0.4464, 0.2808]}, {"w": "a", "b": [0.4549, 0.268, 0.4633, 0.2808]}, {"w": "new", "b": [0.4717, 0.268, 0.497, 0.2808]}, {"w": "Person", "b": [0.5055, 0.268, 0.5561, 0.2808]}, {"w": ">>>", "b": [0.1766, 0.2834, 0.2019, 0.2962]}, {"w": "person2.ParseFromString(s)", "b": [0.2103, 0.2834, 0.4296, 0.2962]}, {"w": "#", "b": [0.4464, 0.2834, 0.4549, 0.2962]}, {"w": "parse", "b": [0.4633, 0.2834, 0.5055, 0.2962]}, {"w": "the", "b": [0.5139, 0.2834, 0.5392, 0.2962]}, {"w": "byte", "b": [0.5476, 0.2834, 0.5814, 0.2962]}, {"w": "string", "b": [0.5898, 0.2834, 0.6404, 0.2962]}, {"w": "(27", "b": [0.6488, 0.2834, 0.6741, 0.2962]}, {"w": "bytes", "b": [0.6825, 0.2834, 0.7247, 0.2962]}, {"w": "long)", "b": [0.7331, 0.2834, 0.7753, 0.2962]}, {"w": "27", "b": [0.1766, 0.2988, 0.1935, 0.3116]}, {"w": ">>>", "b": [0.1766, 0.3142, 0.2019, 0.3271]}, {"w": "person", "b": [0.2103, 0.3142, 0.2609, 0.3271]}, {"w": "==", "b": [0.2693, 0.3142, 0.2862, 0.3271]}, {"w": "person2", "b": [0.2946, 0.3142, 0.3537, 0.3271]}, {"w": "#", "b": [0.3705, 0.3142, 0.379, 0.3271]}, {"w": "now", "b": [0.3874, 0.3142, 0.4127, 0.3271]}, {"w": "they", "b": [0.4211, 0.3142, 0.4549, 0.3271]}, {"w": "are", "b": [0.4633, 0.3142, 0.4886, 0.3271]}, {"w": "equal", "b": [0.497, 0.3142, 0.5392, 0.3271]}, {"w": "True", "b": [0.1766, 0.3296, 0.2103, 0.3425]}]}, {"id": "b_2", "type": "paragraph", "text": "In short, we import the Person class generated by protoc, we create an instance and we play with it, visualizing it, reading and writing some fields, then we serialize it using the SerializeToString() method. This is the binary data that is ready to be saved or transmitted over the network. When reading or receiving this binary data, we can parse it using the ParseFromString() method, and we get a copy of the object that was serialized.7", "words": [{"w": "In", "b": [0.1429, 0.3512, 0.1614, 0.3726]}, {"w": "short,", "b": [0.1673, 0.3512, 0.2155, 0.3726]}, {"w": "we", "b": [0.2214, 0.3512, 0.2445, 0.3726]}, {"w": "import", "b": [0.2505, 0.3512, 0.3083, 0.3726]}, {"w": "the", "b": [0.3142, 0.3512, 0.3406, 0.3726]}, {"w": "Person", "b": [0.3465, 0.3543, 0.4059, 0.3694]}, {"w": "class", "b": [0.4118, 0.3512, 0.4503, 0.3726]}, {"w": "generated", "b": [0.4562, 0.3512, 0.5377, 0.3726]}, {"w": "by", "b": [0.5437, 0.3512, 0.5638, 0.3726]}, {"w": "protoc,", "b": [0.5697, 0.3512, 0.6338, 0.3726]}, {"w": "we", "b": [0.6397, 0.3512, 0.6629, 0.3726]}, {"w": "create", "b": [0.6688, 0.3512, 0.7181, 0.3726]}, {"w": "an", "b": [0.7241, 0.3512, 0.7446, 0.3726]}, {"w": "instance", "b": [0.7505, 0.3512, 0.8197, 0.3726]}, {"w": "and", "b": [0.8256, 0.3512, 0.8571, 0.3726]}, {"w": "we", "b": [0.1429, 0.3702, 0.166, 0.3916]}, {"w": "play", "b": [0.1736, 0.3702, 0.2082, 0.3916]}, {"w": "with", "b": [0.2158, 0.3702, 0.2531, 0.3916]}, {"w": "it,", "b": [0.2608, 0.3702, 0.2775, 0.3916]}, {"w": "visualizing", "b": [0.2851, 0.3702, 0.3746, 0.3916]}, {"w": "it,", "b": [0.3822, 0.3702, 0.3989, 0.3916]}, {"w": "reading", "b": [0.4066, 0.3702, 0.47, 0.3916]}, {"w": "and", "b": [0.4777, 0.3702, 0.5092, 0.3916]}, {"w": "writing", "b": [0.5169, 0.3702, 0.5775, 0.3916]}, {"w": "some", "b": [0.5852, 0.3702, 0.6294, 0.3916]}, {"w": "fields,", "b": [0.637, 0.3702, 0.6863, 0.3916]}, {"w": "then", "b": [0.694, 0.3702, 0.7317, 0.3916]}, {"w": "we", "b": [0.7394, 0.3702, 0.7625, 0.3916]}, {"w": "serialize", "b": [0.7701, 0.3702, 0.8375, 0.3916]}, {"w": "it", "b": [0.8452, 0.3702, 0.8571, 0.3916]}, {"w": "using", "b": [0.1428, 0.3902, 0.1883, 0.4116]}, {"w": "the", "b": [0.1952, 0.3902, 0.2215, 0.4116]}, {"w": "SerializeToString()", "b": [0.2284, 0.3933, 0.4164, 0.4084]}, {"w": "method.", "b": [0.4233, 0.3902, 0.4931, 0.4116]}, {"w": "This", "b": [0.5, 0.3902, 0.5372, 0.4116]}, {"w": "is", "b": [0.5441, 0.3902, 0.5573, 0.4116]}, {"w": "the", "b": [0.5642, 0.3902, 0.5905, 0.4116]}, {"w": "binary", "b": [0.5974, 0.3902, 0.652, 0.4116]}, {"w": "data", "b": [0.6589, 0.3902, 0.6942, 0.4116]}, {"w": "that", "b": [0.7011, 0.3902, 0.7336, 0.4116]}, {"w": "is", "b": [0.7405, 0.3902, 0.7538, 0.4116]}, {"w": "ready", "b": [0.7606, 0.3902, 0.8069, 0.4116]}, {"w": "to", "b": [0.8138, 0.3902, 0.8308, 0.4116]}, {"w": "be", "b": [0.8377, 0.3902, 0.8571, 0.4116]}, {"w": "saved", "b": [0.1429, 0.4092, 0.1888, 0.4306]}, {"w": "or", "b": [0.1955, 0.4092, 0.2138, 0.4306]}, {"w": "transmitted", "b": [0.2205, 0.4092, 0.318, 0.4306]}, {"w": "over", "b": [0.3246, 0.4092, 0.3615, 0.4306]}, {"w": "the", "b": [0.3682, 0.4092, 0.3945, 0.4306]}, {"w": "network.", "b": [0.4012, 0.4092, 0.4755, 0.4306]}, {"w": "When", "b": [0.4822, 0.4092, 0.5338, 0.4306]}, {"w": "reading", "b": [0.5404, 0.4092, 0.6039, 0.4306]}, {"w": "or", "b": [0.6106, 0.4092, 0.6289, 0.4306]}, {"w": "receiving", "b": [0.6356, 0.4092, 0.7118, 0.4306]}, {"w": "this", "b": [0.7185, 0.4092, 0.7492, 0.4306]}, {"w": "binary", "b": [0.7559, 0.4092, 0.8105, 0.4306]}, {"w": "data,", "b": [0.8172, 0.4092, 0.8572, 0.4306]}, {"w": "we", "b": [0.1429, 0.4291, 0.166, 0.4506]}, {"w": "can", "b": [0.1709, 0.4291, 0.2002, 0.4506]}, {"w": "parse", "b": [0.2051, 0.4291, 0.2494, 0.4506]}, {"w": "it", "b": [0.2543, 0.4291, 0.2663, 0.4506]}, {"w": "using", "b": [0.2711, 0.4291, 0.3166, 0.4506]}, {"w": "the", "b": [0.3215, 0.4291, 0.3478, 0.4506]}, {"w": "ParseFromString()", "b": [0.3527, 0.4323, 0.5209, 0.4474]}, {"w": "method,", "b": [0.5258, 0.4291, 0.5956, 0.4506]}, {"w": "and", "b": [0.6005, 0.4291, 0.632, 0.4506]}, {"w": "we", "b": [0.6369, 0.4291, 0.6601, 0.4506]}, {"w": "get", "b": [0.665, 0.4291, 0.6899, 0.4506]}, {"w": "a", "b": [0.6948, 0.4291, 0.704, 0.4506]}, {"w": "copy", "b": [0.7089, 0.4291, 0.7488, 0.4506]}, {"w": "of", "b": [0.7537, 0.4291, 0.7705, 0.4506]}, {"w": "the", "b": [0.7754, 0.4291, 0.8017, 0.4506]}, {"w": "object", "b": [0.8066, 0.4291, 0.8571, 0.4506]}, {"w": "that", "b": [0.1429, 0.4482, 0.1754, 0.4696]}, {"w": "was", "b": [0.1802, 0.4482, 0.2112, 0.4696]}, {"w": "serialized.7", "b": [0.216, 0.4482, 0.3048, 0.4696]}]}, {"id": "b_3", "type": "paragraph", "text": "We could save the serialized Person object to a TFRecord file, then we could load and parse it: everything would work fine. However, SerializeToString() and ParseFrom String() are not TensorFlow operations (and neither are the other operations in this code), so they cannot be included in a TensorFlow Function (except by wrapping them in a tf.py_function() operation, which would make the code slower and less portable, as we saw in Chapter 12). Fortunately, TensorFlow does include special pro‐ tobuf definitions for which it provides parsing operations.", "words": [{"w": "We", "b": [0.1429, 0.4772, 0.1699, 0.4986]}, {"w": "could", "b": [0.1749, 0.4772, 0.2217, 0.4986]}, {"w": "save", "b": [0.2267, 0.4772, 0.2616, 0.4986]}, {"w": "the", "b": [0.2666, 0.4772, 0.293, 0.4986]}, {"w": "serialized", "b": [0.298, 0.4772, 0.3764, 0.4986]}, {"w": "Person", "b": [0.3814, 0.4804, 0.4408, 0.4955]}, {"w": "object", "b": [0.4458, 0.4772, 0.4963, 0.4986]}, {"w": "to", "b": [0.5013, 0.4772, 0.5183, 0.4986]}, {"w": "a", "b": [0.5233, 0.4772, 0.5324, 0.4986]}, {"w": "TFRecord", "b": [0.5375, 0.4772, 0.6213, 0.4986]}, {"w": "file,", "b": [0.6263, 0.4772, 0.6569, 0.4986]}, {"w": "then", "b": [0.6619, 0.4772, 0.6996, 0.4986]}, {"w": "we", "b": [0.7046, 0.4772, 0.7278, 0.4986]}, {"w": "could", "b": [0.7328, 0.4772, 0.7795, 0.4986]}, {"w": "load", "b": [0.7846, 0.4772, 0.8206, 0.4986]}, {"w": "and", "b": [0.8256, 0.4772, 0.8571, 0.4986]}, {"w": "parse", "b": [0.1428, 0.4972, 0.1871, 0.5186]}, {"w": "it:", "b": [0.1921, 0.4972, 0.2087, 0.5186]}, {"w": "everything", "b": [0.2137, 0.4972, 0.3031, 0.5186]}, {"w": "would", "b": [0.308, 0.4972, 0.3603, 0.5186]}, {"w": "work", "b": [0.3652, 0.4972, 0.4081, 0.5186]}, {"w": "fine.", "b": [0.4131, 0.4972, 0.4498, 0.5186]}, {"w": "However,", "b": [0.4547, 0.4972, 0.5336, 0.5186]}, {"w": "SerializeToString()", "b": [0.5385, 0.5003, 0.7265, 0.5154]}, {"w": "and", "b": [0.7314, 0.4972, 0.763, 0.5186]}, {"w": "ParseFrom", "b": [0.7679, 0.5003, 0.857, 0.5154]}, {"w": "String()", "b": [0.1429, 0.5203, 0.222, 0.5354]}, {"w": "are", "b": [0.2273, 0.5171, 0.253, 0.5385]}, {"w": "not", "b": [0.2582, 0.5171, 0.2866, 0.5385]}, {"w": "TensorFlow", "b": [0.2918, 0.5171, 0.3901, 0.5385]}, {"w": "operations", "b": [0.3953, 0.5171, 0.4838, 0.5385]}, {"w": "(and", "b": [0.489, 0.5171, 0.5278, 0.5385]}, {"w": "neither", "b": [0.533, 0.5171, 0.5929, 0.5385]}, {"w": "are", "b": [0.5981, 0.5171, 0.6238, 0.5385]}, {"w": "the", "b": [0.6291, 0.5171, 0.6554, 0.5385]}, {"w": "other", "b": [0.6606, 0.5171, 0.7053, 0.5385]}, {"w": "operations", "b": [0.7105, 0.5171, 0.799, 0.5385]}, {"w": "in", "b": [0.8042, 0.5171, 0.8212, 0.5385]}, {"w": "this", "b": [0.8264, 0.5171, 0.8572, 0.5385]}, {"w": "code),", "b": [0.1429, 0.5361, 0.1941, 0.5576]}, {"w": "so", "b": [0.2023, 0.5361, 0.2206, 0.5576]}, {"w": "they", "b": [0.2288, 0.5361, 0.2646, 0.5576]}, {"w": "cannot", "b": [0.2728, 0.5361, 0.3306, 0.5576]}, {"w": "be", "b": [0.3387, 0.5361, 0.3582, 0.5576]}, {"w": "included", "b": [0.3664, 0.5361, 0.4393, 0.5576]}, {"w": "in", "b": [0.4475, 0.5361, 0.4645, 0.5576]}, {"w": "a", "b": [0.4727, 0.5361, 0.4818, 0.5576]}, {"w": "TensorFlow", "b": [0.49, 0.5361, 0.5883, 0.5576]}, {"w": "Function", "b": [0.5965, 0.5361, 0.6723, 0.5576]}, {"w": "(except", "b": [0.6805, 0.5361, 0.7413, 0.5576]}, {"w": "by", "b": [0.7495, 0.5361, 0.7696, 0.5576]}, {"w": "wrapping", "b": [0.7778, 0.5361, 0.8571, 0.5576]}, {"w": "them", "b": [0.1429, 0.5561, 0.1863, 0.5775]}, {"w": "in", "b": [0.1922, 0.5561, 0.2092, 0.5775]}, {"w": "a", "b": [0.2151, 0.5561, 0.2243, 0.5775]}, {"w": "tf.py_function()", "b": [0.2302, 0.5593, 0.3885, 0.5743]}, {"w": "operation,", "b": [0.3945, 0.5561, 0.4801, 0.5775]}, {"w": "which", "b": [0.486, 0.5561, 0.5369, 0.5775]}, {"w": "would", "b": [0.5429, 0.5561, 0.5951, 0.5775]}, {"w": "make", "b": [0.601, 0.5561, 0.6464, 0.5775]}, {"w": "the", "b": [0.6524, 0.5561, 0.6787, 0.5775]}, {"w": "code", "b": [0.6847, 0.5561, 0.724, 0.5775]}, {"w": "slower", "b": [0.7299, 0.5561, 0.7843, 0.5775]}, {"w": "and", "b": [0.7902, 0.5561, 0.8218, 0.5775]}, {"w": "less", "b": [0.8277, 0.5561, 0.8571, 0.5775]}, {"w": "portable,", "b": [0.1428, 0.5751, 0.2171, 0.5965]}, {"w": "as", "b": [0.2222, 0.5751, 0.239, 0.5965]}, {"w": "we", "b": [0.2442, 0.5751, 0.2673, 0.5965]}, {"w": "saw", "b": [0.2725, 0.5751, 0.3031, 0.5965]}, {"w": "in", "b": [0.3083, 0.5751, 0.3253, 0.5965]}, {"w": "Chapter", "b": [0.3304, 0.5751, 0.398, 0.5965]}, {"w": "12).", "b": [0.4027, 0.5751, 0.4351, 0.5965]}, {"w": "Fortunately,", "b": [0.4403, 0.5751, 0.5401, 0.5965]}, {"w": "TensorFlow", "b": [0.5453, 0.5751, 0.6435, 0.5965]}, {"w": "does", "b": [0.6487, 0.5751, 0.6868, 0.5965]}, {"w": "include", "b": [0.6919, 0.5751, 0.7539, 0.5965]}, {"w": "special", "b": [0.7591, 0.5751, 0.8153, 0.5965]}, {"w": "pro‐", "b": [0.8205, 0.5751, 0.8571, 0.5965]}, {"w": "tobuf", "b": [0.1429, 0.5942, 0.1876, 0.6156]}, {"w": "definitions", "b": [0.1924, 0.5942, 0.2826, 0.6156]}, {"w": "for", "b": [0.2873, 0.5942, 0.3118, 0.6156]}, {"w": "which", "b": [0.3165, 0.5942, 0.3675, 0.6156]}, {"w": "it", "b": [0.3722, 0.5942, 0.3841, 0.6156]}, {"w": "provides", "b": [0.3889, 0.5942, 0.4609, 0.6156]}, {"w": "parsing", "b": [0.4656, 0.5942, 0.5278, 0.6156]}, {"w": "operations.", "b": [0.5325, 0.5942, 0.6257, 0.6156]}]}, {"id": "b_4", "type": "paragraph", "text": "TensorFlow Protobufs", "words": [{"w": "TensorFlow", "b": [0.1428, 0.6284, 0.2611, 0.6569]}, {"w": "Protobufs", "b": [0.2661, 0.6284, 0.3672, 0.6569]}]}, {"id": "b_5", "type": "paragraph", "text": "The main protobuf typically used in a TFRecord file is the Example protobuf, which represents one instance in a dataset. It contains a list of named features, where each feature can either be a list of byte strings, a list of floats or a list of integers. Here is the protobuf definition:", "words": [{"w": "The", "b": [0.1429, 0.6637, 0.1757, 0.6851]}, {"w": "main", "b": [0.1819, 0.6637, 0.2251, 0.6851]}, {"w": "protobuf", "b": [0.2313, 0.6637, 0.3054, 0.6851]}, {"w": "typically", "b": [0.3116, 0.6637, 0.3821, 0.6851]}, {"w": "used", "b": [0.3883, 0.6637, 0.4268, 0.6851]}, {"w": "in", "b": [0.433, 0.6637, 0.45, 0.6851]}, {"w": "a", "b": [0.4562, 0.6637, 0.4654, 0.6851]}, {"w": "TFRecord", "b": [0.4716, 0.6637, 0.5554, 0.6851]}, {"w": "file", "b": [0.5616, 0.6637, 0.5875, 0.6851]}, {"w": "is", "b": [0.5937, 0.6637, 0.607, 0.6851]}, {"w": "the", "b": [0.6132, 0.6637, 0.6395, 0.6851]}, {"w": "Example", "b": [0.6457, 0.6669, 0.715, 0.682]}, {"w": "protobuf,", "b": [0.7212, 0.6637, 0.8, 0.6851]}, {"w": "which", "b": [0.8062, 0.6637, 0.8571, 0.6851]}, {"w": "represents", "b": [0.1429, 0.6828, 0.2284, 0.7042]}, {"w": "one", "b": [0.2348, 0.6828, 0.2657, 0.7042]}, {"w": "instance", "b": [0.2721, 0.6828, 0.3413, 0.7042]}, {"w": "in", "b": [0.3476, 0.6828, 0.3646, 0.7042]}, {"w": "a", "b": [0.371, 0.6828, 0.3801, 0.7042]}, {"w": "dataset.", "b": [0.3865, 0.6828, 0.4494, 0.7042]}, {"w": "It", "b": [0.4557, 0.6828, 0.4684, 0.7042]}, {"w": "contains", "b": [0.4748, 0.6828, 0.5453, 0.7042]}, {"w": "a", "b": [0.5517, 0.6828, 0.5609, 0.7042]}, {"w": "list", "b": [0.5672, 0.6828, 0.5921, 0.7042]}, {"w": "of", "b": [0.5985, 0.6828, 0.6153, 0.7042]}, {"w": "named", "b": [0.6216, 0.6828, 0.6791, 0.7042]}, {"w": "features,", "b": [0.6855, 0.6828, 0.7556, 0.7042]}, {"w": "where", "b": [0.762, 0.6828, 0.8128, 0.7042]}, {"w": "each", "b": [0.8192, 0.6828, 0.8572, 0.7042]}, {"w": "feature", "b": [0.1429, 0.7018, 0.2006, 0.7232]}, {"w": "can", "b": [0.2055, 0.7018, 0.2348, 0.7232]}, {"w": "either", "b": [0.2396, 0.7018, 0.2881, 0.7232]}, {"w": "be", "b": [0.293, 0.7018, 0.3124, 0.7232]}, {"w": "a", "b": [0.3172, 0.7018, 0.3264, 0.7232]}, {"w": "list", "b": [0.3312, 0.7018, 0.3561, 0.7232]}, {"w": "of", "b": [0.3609, 0.7018, 0.3777, 0.7232]}, {"w": "byte", "b": [0.3825, 0.7018, 0.4178, 0.7232]}, {"w": "strings,", "b": [0.4227, 0.7018, 0.4835, 0.7232]}, {"w": "a", "b": [0.4884, 0.7018, 0.4975, 0.7232]}, {"w": "list", "b": [0.5023, 0.7018, 0.5272, 0.7232]}, {"w": "of", "b": [0.532, 0.7018, 0.5488, 0.7232]}, {"w": "floats", "b": [0.5536, 0.7018, 0.5984, 0.7232]}, {"w": "or", "b": [0.6033, 0.7018, 0.6216, 0.7232]}, {"w": "a", "b": [0.6264, 0.7018, 0.6356, 0.7232]}, {"w": "list", "b": [0.6404, 0.7018, 0.6653, 0.7232]}, {"w": "of", "b": [0.6701, 0.7018, 0.6869, 0.7232]}, {"w": "integers.", "b": [0.6917, 0.7018, 0.7622, 0.7232]}, {"w": "Here", "b": [0.7671, 0.7018, 0.8079, 0.7232]}, {"w": "is", "b": [0.8128, 0.7018, 0.826, 0.7232]}, {"w": "the", "b": [0.8308, 0.7018, 0.8571, 0.7232]}, {"w": "protobuf", "b": [0.1429, 0.7209, 0.2169, 0.7423]}, {"w": "definition:", "b": [0.2216, 0.7209, 0.3089, 0.7423]}]}, {"id": "b_6", "type": "paragraph", "text": "syntax = \"proto3\"; message BytesList { repeated bytes value = 1; } message FloatList { repeated float value = 1 [packed = true]; } message Int64List { repeated int64 value = 1 [packed = true]; }", "words": [{"w": "syntax", "b": [0.1766, 0.7528, 0.2272, 0.7657]}, {"w": "=", "b": [0.2356, 0.7528, 0.2441, 0.7657]}, {"w": "\"proto3\";", "b": [0.2525, 0.7528, 0.3284, 0.7657]}, {"w": "message", "b": [0.1766, 0.7683, 0.2356, 0.7811]}, {"w": "BytesList", "b": [0.2441, 0.7683, 0.3199, 0.7811]}, {"w": "{", "b": [0.3284, 0.7683, 0.3368, 0.7811]}, {"w": "repeated", "b": [0.3452, 0.7683, 0.4127, 0.7811]}, {"w": "bytes", "b": [0.4211, 0.7683, 0.4633, 0.7811]}, {"w": "value", "b": [0.4717, 0.7683, 0.5139, 0.7811]}, {"w": "=", "b": [0.5223, 0.7683, 0.5308, 0.7811]}, {"w": "1;", "b": [0.5392, 0.7683, 0.5561, 0.7811]}, {"w": "}", "b": [0.5645, 0.7683, 0.5729, 0.7811]}, {"w": "message", "b": [0.1766, 0.7837, 0.2356, 0.7965]}, {"w": "FloatList", "b": [0.2441, 0.7837, 0.3199, 0.7965]}, {"w": "{", "b": [0.3284, 0.7837, 0.3368, 0.7965]}, {"w": "repeated", "b": [0.3452, 0.7837, 0.4127, 0.7965]}, {"w": "float", "b": [0.4211, 0.7837, 0.4633, 0.7965]}, {"w": "value", "b": [0.4717, 0.7837, 0.5139, 0.7965]}, {"w": "=", "b": [0.5223, 0.7837, 0.5308, 0.7965]}, {"w": "1", "b": [0.5392, 0.7837, 0.5476, 0.7965]}, {"w": "[packed", "b": [0.5561, 0.7837, 0.6151, 0.7965]}, {"w": "=", "b": [0.6235, 0.7837, 0.632, 0.7965]}, {"w": "true];", "b": [0.6404, 0.7837, 0.691, 0.7965]}, {"w": "}", "b": [0.6994, 0.7837, 0.7078, 0.7965]}, {"w": "message", "b": [0.1766, 0.7991, 0.2356, 0.812]}, {"w": "Int64List", "b": [0.2441, 0.7991, 0.3199, 0.812]}, {"w": "{", "b": [0.3284, 0.7991, 0.3368, 0.812]}, {"w": "repeated", "b": [0.3452, 0.7991, 0.4127, 0.812]}, {"w": "int64", "b": [0.4211, 0.7991, 0.4633, 0.812]}, {"w": "value", "b": [0.4717, 0.7991, 0.5139, 0.812]}, {"w": "=", "b": [0.5223, 0.7991, 0.5308, 0.812]}, {"w": "1", "b": [0.5392, 0.7991, 0.5476, 0.812]}, {"w": "[packed", "b": [0.5561, 0.7991, 0.6151, 0.812]}, {"w": "=", "b": [0.6235, 0.7991, 0.632, 0.812]}, {"w": "true];", "b": [0.6404, 0.7991, 0.691, 0.812]}, {"w": "}", "b": [0.6994, 0.7991, 0.7078, 0.812]}]}, {"id": "b_7", "type": "paragraph", "text": "416 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "416", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 443, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "8 Why was Example even defined since it contains no more than a Features object? Well, TensorFlow may one day decide to add more fields to it. As long as the new Example definition still contains the features field, with the same id, it will be backward compatible. This extensibility is one of the great features of protobufs.", "words": [{"w": "8", "b": [0.1451, 0.8451, 0.1518, 0.8594]}, {"w": "Why", "b": [0.1587, 0.8436, 0.1895, 0.8599]}, {"w": "was", "b": [0.1931, 0.8436, 0.2168, 0.8599]}, {"w": "Example", "b": [0.2204, 0.8461, 0.2732, 0.8575]}, {"w": "even", "b": [0.2768, 0.8436, 0.3063, 0.8599]}, {"w": "defined", "b": [0.3099, 0.8436, 0.3578, 0.8599]}, {"w": "since", "b": [0.3614, 0.8436, 0.3936, 0.8599]}, {"w": "it", "b": [0.3972, 0.8436, 0.4063, 0.8599]}, {"w": "contains", "b": [0.4099, 0.8436, 0.4637, 0.8599]}, {"w": "no", "b": [0.4673, 0.8436, 0.4841, 0.8599]}, {"w": "more", "b": [0.4877, 0.8436, 0.5214, 0.8599]}, {"w": "than", "b": [0.525, 0.8436, 0.554, 0.8599]}, {"w": "a", "b": [0.5576, 0.8436, 0.5646, 0.8599]}, {"w": "Features", "b": [0.5682, 0.8461, 0.6285, 0.8575]}, {"w": "object?", "b": [0.6321, 0.8436, 0.6766, 0.8599]}, {"w": "Well,", "b": [0.6802, 0.8436, 0.7125, 0.8599]}, {"w": "TensorFlow", "b": [0.7161, 0.8436, 0.791, 0.8599]}, {"w": "may", "b": [0.7946, 0.8436, 0.8215, 0.8599]}, {"w": "one", "b": [0.8251, 0.8436, 0.8487, 0.8599]}, {"w": "day", "b": [0.1587, 0.8598, 0.1811, 0.8761]}, {"w": "decide", "b": [0.1847, 0.8598, 0.2259, 0.8761]}, {"w": "to", "b": [0.2295, 0.8598, 0.2424, 0.8761]}, {"w": "add", "b": [0.246, 0.8598, 0.2698, 0.8761]}, {"w": "more", "b": [0.2734, 0.8598, 0.3071, 0.8761]}, {"w": "fields", "b": [0.3107, 0.8598, 0.3446, 0.8761]}, {"w": "to", "b": [0.3482, 0.8598, 0.3612, 0.8761]}, {"w": "it.", "b": [0.3648, 0.8598, 0.3775, 0.8761]}, {"w": "As", "b": [0.3811, 0.8598, 0.3979, 0.8761]}, {"w": "long", "b": [0.4015, 0.8598, 0.4297, 0.8761]}, {"w": "as", "b": [0.4333, 0.8598, 0.4461, 0.8761]}, {"w": "the", "b": [0.4497, 0.8598, 0.4698, 0.8761]}, {"w": "new", "b": [0.4734, 0.8598, 0.4997, 0.8761]}, {"w": "Example", "b": [0.5033, 0.8622, 0.5561, 0.8737]}, {"w": "definition", "b": [0.5597, 0.8598, 0.6226, 0.8761]}, {"w": "still", "b": [0.6262, 0.8598, 0.6491, 0.8761]}, {"w": "contains", "b": [0.6527, 0.8598, 0.7065, 0.8761]}, {"w": "the", "b": [0.7101, 0.8598, 0.7301, 0.8761]}, {"w": "features", "b": [0.7337, 0.8622, 0.7941, 0.8737]}, {"w": "field,", "b": [0.7977, 0.8598, 0.8294, 0.8761]}, {"w": "with", "b": [0.1587, 0.8749, 0.1872, 0.8912]}, {"w": "the", "b": [0.1908, 0.8749, 0.2108, 0.8912]}, {"w": "same", "b": [0.2144, 0.8749, 0.247, 0.8912]}, {"w": "id,", "b": [0.2506, 0.8749, 0.2668, 0.8912]}, {"w": "it", "b": [0.2704, 0.8749, 0.2795, 0.8912]}, {"w": "will", "b": [0.2831, 0.8749, 0.3063, 0.8912]}, {"w": "be", "b": [0.3099, 0.8749, 0.3247, 0.8912]}, {"w": "backward", "b": [0.3283, 0.8749, 0.39, 0.8912]}, {"w": "compatible.", "b": [0.3937, 0.8749, 0.4677, 0.8912]}, {"w": "This", "b": [0.4713, 0.8749, 0.4996, 0.8912]}, {"w": "extensibility", "b": [0.5032, 0.8749, 0.5805, 0.8912]}, {"w": "is", "b": [0.5841, 0.8749, 0.5942, 0.8912]}, {"w": "one", "b": [0.5978, 0.8749, 0.6213, 0.8912]}, {"w": "of", "b": [0.625, 0.8749, 0.6377, 0.8912]}, {"w": "the", "b": [0.6413, 0.8749, 0.6614, 0.8912]}, {"w": "great", "b": [0.665, 0.8749, 0.6966, 0.8912]}, {"w": "features", "b": [0.7002, 0.8749, 0.75, 0.8912]}, {"w": "of", "b": [0.7536, 0.8749, 0.7664, 0.8912]}, {"w": "protobufs.", "b": [0.77, 0.8749, 0.8359, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "message Feature { oneof kind { BytesList bytes_list = 1; FloatList float_list = 2; Int64List int64_list = 3; } }; message Features { map feature = 1; }; message Example { Features features = 1; };", "words": [{"w": "message", "b": [0.1766, 0.0829, 0.2356, 0.0958]}, {"w": "Feature", "b": [0.244, 0.0829, 0.3031, 0.0958]}, {"w": "{", "b": [0.3115, 0.0829, 0.3199, 0.0958]}, {"w": "oneof", "b": [0.2103, 0.0983, 0.2525, 0.1112]}, {"w": "kind", "b": [0.2609, 0.0983, 0.2946, 0.1112]}, {"w": "{", "b": [0.3031, 0.0983, 0.3115, 0.1112]}, {"w": "BytesList", "b": [0.244, 0.1138, 0.3199, 0.1266]}, {"w": "bytes_list", "b": [0.3284, 0.1138, 0.4127, 0.1266]}, {"w": "=", "b": [0.4211, 0.1138, 0.4296, 0.1266]}, {"w": "1;", "b": [0.438, 0.1138, 0.4549, 0.1266]}, {"w": "FloatList", "b": [0.244, 0.1292, 0.3199, 0.142]}, {"w": "float_list", "b": [0.3284, 0.1292, 0.4127, 0.142]}, {"w": "=", "b": [0.4211, 0.1292, 0.4296, 0.142]}, {"w": "2;", "b": [0.438, 0.1292, 0.4549, 0.142]}, {"w": "Int64List", "b": [0.244, 0.1446, 0.3199, 0.1574]}, {"w": "int64_list", "b": [0.3284, 0.1446, 0.4127, 0.1574]}, {"w": "=", "b": [0.4211, 0.1446, 0.4296, 0.1574]}, {"w": "3;", "b": [0.438, 0.1446, 0.4549, 0.1574]}, {"w": "}", "b": [0.2103, 0.16, 0.2187, 0.1729]}, {"w": "};", "b": [0.1766, 0.1754, 0.1934, 0.1883]}, {"w": "message", "b": [0.1766, 0.1909, 0.2356, 0.2037]}, {"w": "Features", "b": [0.244, 0.1909, 0.3115, 0.2037]}, {"w": "{", "b": [0.3199, 0.1909, 0.3284, 0.2037]}, {"w": "map", "b": [0.438, 0.1909, 0.5055, 0.2037]}, {"w": "feature", "b": [0.5139, 0.1909, 0.5729, 0.2037]}, {"w": "=", "b": [0.5813, 0.1909, 0.5898, 0.2037]}, {"w": "1;", "b": [0.5982, 0.1909, 0.6151, 0.2037]}, {"w": "};", "b": [0.6235, 0.1909, 0.6404, 0.2037]}, {"w": "message", "b": [0.1766, 0.2063, 0.2356, 0.2191]}, {"w": "Example", "b": [0.244, 0.2063, 0.3031, 0.2191]}, {"w": "{", "b": [0.3115, 0.2063, 0.3199, 0.2191]}, {"w": "Features", "b": [0.3284, 0.2063, 0.3958, 0.2191]}, {"w": "features", "b": [0.4043, 0.2063, 0.4717, 0.2191]}, {"w": "=", "b": [0.4802, 0.2063, 0.4886, 0.2191]}, {"w": "1;", "b": [0.497, 0.2063, 0.5139, 0.2191]}, {"w": "};", "b": [0.5223, 0.2063, 0.5392, 0.2191]}]}, {"id": "b_2", "type": "paragraph", "text": "The definitions of BytesList, FloatList and Int64List are straightforward enough ([packed = true] is used for repeated numerical fields, for a more efficient encod‐ ing). A Feature either contains a BytesList, a FloatList or an Int64List. A Fea tures (with an s) contains a dictionary that maps a feature name to the corresponding feature value. And finally, an Example just contains a Features object.8", "words": [{"w": "The", "b": [0.1428, 0.2278, 0.1757, 0.2492]}, {"w": "definitions", "b": [0.1814, 0.2278, 0.2716, 0.2492]}, {"w": "of", "b": [0.2774, 0.2278, 0.2942, 0.2492]}, {"w": "BytesList,", "b": [0.3, 0.2278, 0.3938, 0.2492]}, {"w": "FloatList", "b": [0.3996, 0.231, 0.4886, 0.2461]}, {"w": "and", "b": [0.4944, 0.2278, 0.5259, 0.2492]}, {"w": "Int64List", "b": [0.5317, 0.231, 0.6208, 0.2461]}, {"w": "are", "b": [0.6265, 0.2278, 0.6522, 0.2492]}, {"w": "straightforward", "b": [0.658, 0.2278, 0.7886, 0.2492]}, {"w": "enough", "b": [0.7943, 0.2278, 0.8572, 0.2492]}, {"w": "([packed", "b": [0.1429, 0.2477, 0.2193, 0.2692]}, {"w": "=", "b": [0.2308, 0.2509, 0.2407, 0.266]}, {"w": "true]", "b": [0.2522, 0.2509, 0.3017, 0.266]}, {"w": "is", "b": [0.3081, 0.2477, 0.3214, 0.2692]}, {"w": "used", "b": [0.3278, 0.2477, 0.3663, 0.2692]}, {"w": "for", "b": [0.3728, 0.2477, 0.3973, 0.2692]}, {"w": "repeated", "b": [0.4037, 0.2477, 0.475, 0.2692]}, {"w": "numerical", "b": [0.4814, 0.2477, 0.566, 0.2692]}, {"w": "fields,", "b": [0.5724, 0.2477, 0.6216, 0.2692]}, {"w": "for", "b": [0.6281, 0.2477, 0.6526, 0.2692]}, {"w": "a", "b": [0.659, 0.2477, 0.6681, 0.2692]}, {"w": "more", "b": [0.6746, 0.2477, 0.7188, 0.2692]}, {"w": "efficient", "b": [0.7252, 0.2477, 0.7926, 0.2692]}, {"w": "encod‐", "b": [0.799, 0.2477, 0.8571, 0.2692]}, {"w": "ing).", "b": [0.1429, 0.2677, 0.1815, 0.2891]}, {"w": "A", "b": [0.1887, 0.2677, 0.2031, 0.2891]}, {"w": "Feature", "b": [0.2102, 0.2709, 0.2795, 0.286]}, {"w": "either", "b": [0.2866, 0.2677, 0.3351, 0.2891]}, {"w": "contains", "b": [0.3422, 0.2677, 0.4128, 0.2891]}, {"w": "a", "b": [0.4199, 0.2677, 0.429, 0.2891]}, {"w": "BytesList,", "b": [0.4362, 0.2677, 0.53, 0.2891]}, {"w": "a", "b": [0.5371, 0.2677, 0.5463, 0.2891]}, {"w": "FloatList", "b": [0.5534, 0.2709, 0.6424, 0.286]}, {"w": "or", "b": [0.6496, 0.2677, 0.6679, 0.2891]}, {"w": "an", "b": [0.675, 0.2677, 0.6956, 0.2891]}, {"w": "Int64List.", "b": [0.7027, 0.2677, 0.7965, 0.2891]}, {"w": "A", "b": [0.8037, 0.2677, 0.8181, 0.2891]}, {"w": "Fea", "b": [0.8252, 0.2709, 0.8549, 0.286]}, {"w": "tures", "b": [0.1429, 0.2908, 0.1923, 0.3059]}, {"w": "(with", "b": [0.2066, 0.2876, 0.2511, 0.3091]}, {"w": "an", "b": [0.2654, 0.2876, 0.2859, 0.3091]}, {"w": "s)", "b": [0.3001, 0.2876, 0.315, 0.3091]}, {"w": "contains", "b": [0.3292, 0.2876, 0.3998, 0.3091]}, {"w": "a", "b": [0.414, 0.2876, 0.4232, 0.3091]}, {"w": "dictionary", "b": [0.4374, 0.2876, 0.5238, 0.3091]}, {"w": "that", "b": [0.5381, 0.2876, 0.5706, 0.3091]}, {"w": "maps", "b": [0.5849, 0.2876, 0.6293, 0.3091]}, {"w": "a", "b": [0.6435, 0.2876, 0.6526, 0.3091]}, {"w": "feature", "b": [0.6669, 0.2876, 0.7247, 0.3091]}, {"w": "name", "b": [0.7389, 0.2876, 0.7854, 0.3091]}, {"w": "to", "b": [0.7996, 0.2876, 0.8166, 0.3091]}, {"w": "the", "b": [0.8308, 0.2876, 0.8571, 0.3091]}, {"w": "corresponding", "b": [0.1429, 0.3076, 0.2649, 0.329]}, {"w": "feature", "b": [0.2696, 0.3076, 0.3274, 0.329]}, {"w": "value.", "b": [0.3321, 0.3076, 0.3809, 0.329]}, {"w": "And", "b": [0.3856, 0.3076, 0.4224, 0.329]}, {"w": "finally,", "b": [0.4271, 0.3076, 0.4827, 0.329]}, {"w": "an", "b": [0.4875, 0.3076, 0.508, 0.329]}, {"w": "Example", "b": [0.5134, 0.3108, 0.5827, 0.3258]}, {"w": "just", "b": [0.5875, 0.3076, 0.6179, 0.329]}, {"w": "contains", "b": [0.6226, 0.3076, 0.6932, 0.329]}, {"w": "a", "b": [0.6979, 0.3076, 0.7071, 0.329]}, {"w": "Features", "b": [0.7121, 0.3108, 0.7913, 0.3258]}, {"w": "object.8", "b": [0.7961, 0.3076, 0.8571, 0.329]}]}, {"id": "b_3", "type": "paragraph", "text": "Here is how you could create a tf.train.Example representing the same person as earlier, and write it to TFRecord file:", "words": [{"w": "Here", "b": [0.1429, 0.3275, 0.1837, 0.3489]}, {"w": "is", "b": [0.1905, 0.3275, 0.2038, 0.3489]}, {"w": "how", "b": [0.2106, 0.3275, 0.2466, 0.3489]}, {"w": "you", "b": [0.2534, 0.3275, 0.2846, 0.3489]}, {"w": "could", "b": [0.2914, 0.3275, 0.3382, 0.3489]}, {"w": "create", "b": [0.345, 0.3275, 0.3944, 0.3489]}, {"w": "a", "b": [0.4012, 0.3275, 0.4103, 0.3489]}, {"w": "tf.train.Example", "b": [0.4171, 0.3307, 0.5755, 0.3458]}, {"w": "representing", "b": [0.5823, 0.3275, 0.6869, 0.3489]}, {"w": "the", "b": [0.6937, 0.3275, 0.7201, 0.3489]}, {"w": "same", "b": [0.7269, 0.3275, 0.7696, 0.3489]}, {"w": "person", "b": [0.7764, 0.3275, 0.8335, 0.3489]}, {"w": "as", "b": [0.8403, 0.3275, 0.8571, 0.3489]}, {"w": "earlier,", "b": [0.1429, 0.3466, 0.1995, 0.368]}, {"w": "and", "b": [0.2042, 0.3466, 0.2357, 0.368]}, {"w": "write", "b": [0.2405, 0.3466, 0.2833, 0.368]}, {"w": "it", "b": [0.288, 0.3466, 0.2999, 0.368]}, {"w": "to", "b": [0.3047, 0.3466, 0.3216, 0.368]}, {"w": "TFRecord", "b": [0.3264, 0.3466, 0.4102, 0.368]}, {"w": "file:", "b": [0.4149, 0.3466, 0.4456, 0.368]}]}, {"id": "b_4", "type": "paragraph", "text": "from tensorflow.train import BytesList, FloatList, Int64List from tensorflow.train import Feature, Features, Example", "words": [{"w": "from", "b": [0.1766, 0.3785, 0.2103, 0.3914]}, {"w": "tensorflow.train", "b": [0.2188, 0.3785, 0.3537, 0.3914]}, {"w": "import", "b": [0.3621, 0.3785, 0.4127, 0.3914]}, {"w": "BytesList,", "b": [0.4211, 0.3785, 0.5055, 0.3914]}, {"w": "FloatList,", "b": [0.5139, 0.3785, 0.5982, 0.3914]}, {"w": "Int64List", "b": [0.6066, 0.3785, 0.6825, 0.3914]}, {"w": "from", "b": [0.1766, 0.394, 0.2103, 0.4068]}, {"w": "tensorflow.train", "b": [0.2188, 0.394, 0.3537, 0.4068]}, {"w": "import", "b": [0.3621, 0.394, 0.4127, 0.4068]}, {"w": "Feature,", "b": [0.4211, 0.394, 0.4886, 0.4068]}, {"w": "Features,", "b": [0.497, 0.394, 0.5729, 0.4068]}, {"w": "Example", "b": [0.5814, 0.394, 0.6404, 0.4068]}]}, {"id": "b_5", "type": "paragraph", "text": "person_example = Example( features=Features( feature={ \"name\": Feature(bytes_list=BytesList(value=[b\"Alice\"])), \"id\": Feature(int64_list=Int64List(value=[123])), \"emails\": Feature(bytes_list=BytesList(value=[b\"a@b.com\", b\"c@d.com\"])) }))", "words": [{"w": "person_example", "b": [0.1766, 0.4248, 0.2946, 0.4377]}, {"w": "=", "b": [0.3031, 0.4248, 0.3115, 0.4377]}, {"w": "Example(", "b": [0.3199, 0.4248, 0.3874, 0.4377]}, {"w": "features=Features(", "b": [0.2103, 0.4402, 0.3621, 0.4531]}, {"w": "feature={", "b": [0.244, 0.4556, 0.3199, 0.4685]}, {"w": "\"name\":", "b": [0.2778, 0.4711, 0.3368, 0.4839]}, {"w": "Feature(bytes_list=BytesList(value=[b\"Alice\"])),", "b": [0.3452, 0.4711, 0.75, 0.4839]}, {"w": "\"id\":", "b": [0.2778, 0.4865, 0.3199, 0.4993]}, {"w": "Feature(int64_list=Int64List(value=[123])),", "b": [0.3284, 0.4865, 0.691, 0.4993]}, {"w": "\"emails\":", "b": [0.2778, 0.5019, 0.3537, 0.5148]}, {"w": "Feature(bytes_list=BytesList(value=[b\"a@b.com\",", "b": [0.3621, 0.5019, 0.7584, 0.5148]}, {"w": "b\"c@d.com\"]))", "b": [0.6657, 0.5173, 0.7753, 0.5302]}, {"w": "}))", "b": [0.244, 0.5327, 0.2693, 0.5456]}]}, {"id": "b_6", "type": "paragraph", "text": "The code is a bit verbose and repetitive, but it’s rather straightforward (and you could easily wrap it inside a small helper function). Now that we have an Example protobuf, we can serialize it by calling its SerializeToString() method, then write the result‐ ing data to a TFRecord file:", "words": [{"w": "The", "b": [0.1429, 0.5534, 0.1757, 0.5748]}, {"w": "code", "b": [0.1808, 0.5534, 0.22, 0.5748]}, {"w": "is", "b": [0.2251, 0.5534, 0.2383, 0.5748]}, {"w": "a", "b": [0.2434, 0.5534, 0.2525, 0.5748]}, {"w": "bit", "b": [0.2576, 0.5534, 0.2801, 0.5748]}, {"w": "verbose", "b": [0.2852, 0.5534, 0.3491, 0.5748]}, {"w": "and", "b": [0.3541, 0.5534, 0.3857, 0.5748]}, {"w": "repetitive,", "b": [0.3907, 0.5534, 0.4742, 0.5748]}, {"w": "but", "b": [0.4793, 0.5534, 0.5073, 0.5748]}, {"w": "it’s", "b": [0.5123, 0.5534, 0.534, 0.5748]}, {"w": "rather", "b": [0.5391, 0.5534, 0.5896, 0.5748]}, {"w": "straightforward", "b": [0.5947, 0.5534, 0.7252, 0.5748]}, {"w": "(and", "b": [0.7303, 0.5534, 0.769, 0.5748]}, {"w": "you", "b": [0.7741, 0.5534, 0.8053, 0.5748]}, {"w": "could", "b": [0.8104, 0.5534, 0.8572, 0.5748]}, {"w": "easily", "b": [0.1429, 0.5733, 0.1889, 0.5947]}, {"w": "wrap", "b": [0.1941, 0.5733, 0.2358, 0.5947]}, {"w": "it", "b": [0.2409, 0.5733, 0.2529, 0.5947]}, {"w": "inside", "b": [0.258, 0.5733, 0.3081, 0.5947]}, {"w": "a", "b": [0.3133, 0.5733, 0.3224, 0.5947]}, {"w": "small", "b": [0.3276, 0.5733, 0.372, 0.5947]}, {"w": "helper", "b": [0.3771, 0.5733, 0.4299, 0.5947]}, {"w": "function).", "b": [0.435, 0.5733, 0.5184, 0.5947]}, {"w": "Now", "b": [0.5236, 0.5733, 0.5634, 0.5947]}, {"w": "that", "b": [0.5686, 0.5733, 0.6012, 0.5947]}, {"w": "we", "b": [0.6063, 0.5733, 0.6295, 0.5947]}, {"w": "have", "b": [0.6346, 0.5733, 0.673, 0.5947]}, {"w": "an", "b": [0.6782, 0.5733, 0.6987, 0.5947]}, {"w": "Example", "b": [0.7039, 0.5765, 0.7732, 0.5916]}, {"w": "protobuf,", "b": [0.7783, 0.5733, 0.8571, 0.5947]}, {"w": "we", "b": [0.1429, 0.5933, 0.166, 0.6147]}, {"w": "can", "b": [0.1717, 0.5933, 0.201, 0.6147]}, {"w": "serialize", "b": [0.2068, 0.5933, 0.2742, 0.6147]}, {"w": "it", "b": [0.2799, 0.5933, 0.2918, 0.6147]}, {"w": "by", "b": [0.2975, 0.5933, 0.3177, 0.6147]}, {"w": "calling", "b": [0.3234, 0.5933, 0.3786, 0.6147]}, {"w": "its", "b": [0.3843, 0.5933, 0.4039, 0.6147]}, {"w": "SerializeToString()", "b": [0.4096, 0.5964, 0.5976, 0.6115]}, {"w": "method,", "b": [0.6033, 0.5933, 0.6731, 0.6147]}, {"w": "then", "b": [0.6788, 0.5933, 0.7166, 0.6147]}, {"w": "write", "b": [0.7223, 0.5933, 0.7651, 0.6147]}, {"w": "the", "b": [0.7708, 0.5933, 0.7971, 0.6147]}, {"w": "result‐", "b": [0.8028, 0.5933, 0.8571, 0.6147]}, {"w": "ing", "b": [0.1429, 0.6123, 0.1696, 0.6337]}, {"w": "data", "b": [0.1743, 0.6123, 0.2096, 0.6337]}, {"w": "to", "b": [0.2143, 0.6123, 0.2313, 0.6337]}, {"w": "a", "b": [0.236, 0.6123, 0.2451, 0.6337]}, {"w": "TFRecord", "b": [0.2499, 0.6123, 0.3337, 0.6337]}, {"w": "file:", "b": [0.3384, 0.6123, 0.3691, 0.6337]}]}, {"id": "b_7", "type": "paragraph", "text": "with tf.io.TFRecordWriter(\"my_contacts.tfrecord\") as f: f.write(person_example.SerializeToString())", "words": [{"w": "with", "b": [0.1766, 0.6443, 0.2103, 0.6571]}, {"w": "tf.io.TFRecordWriter(\"my_contacts.tfrecord\")", "b": [0.2188, 0.6443, 0.5898, 0.6571]}, {"w": "as", "b": [0.5982, 0.6443, 0.6151, 0.6571]}, {"w": "f:", "b": [0.6235, 0.6443, 0.6404, 0.6571]}, {"w": "f.write(person_example.SerializeToString())", "b": [0.2103, 0.6597, 0.5729, 0.6726]}]}, {"id": "b_8", "type": "paragraph", "text": "Normally you would write much more than just one example! Typically, you would create a conversion script that reads from your current format (say, CSV files), creates an Example protobuf for each instance, serializes them and saves them to several TFRecord files, ideally shuffling them in the process. This requires a bit of work, so once again make sure it is really necessary (perhaps your pipeline works fine with CSV files).", "words": [{"w": "Normally", "b": [0.1429, 0.6803, 0.2225, 0.7018]}, {"w": "you", "b": [0.2291, 0.6803, 0.2604, 0.7018]}, {"w": "would", "b": [0.267, 0.6803, 0.3193, 0.7018]}, {"w": "write", "b": [0.3259, 0.6803, 0.3687, 0.7018]}, {"w": "much", "b": [0.3753, 0.6803, 0.423, 0.7018]}, {"w": "more", "b": [0.4296, 0.6803, 0.4739, 0.7018]}, {"w": "than", "b": [0.4805, 0.6803, 0.5186, 0.7018]}, {"w": "just", "b": [0.5252, 0.6803, 0.5556, 0.7018]}, {"w": "one", "b": [0.5622, 0.6803, 0.5931, 0.7018]}, {"w": "example!", "b": [0.5998, 0.6803, 0.6751, 0.7018]}, {"w": "Typically,", "b": [0.6817, 0.6803, 0.7604, 0.7018]}, {"w": "you", "b": [0.767, 0.6803, 0.7983, 0.7018]}, {"w": "would", "b": [0.8049, 0.6803, 0.8571, 0.7018]}, {"w": "create", "b": [0.1429, 0.6994, 0.1922, 0.7208]}, {"w": "a", "b": [0.1971, 0.6994, 0.2063, 0.7208]}, {"w": "conversion", "b": [0.2112, 0.6994, 0.303, 0.7208]}, {"w": "script", "b": [0.3079, 0.6994, 0.355, 0.7208]}, {"w": "that", "b": [0.3599, 0.6994, 0.3925, 0.7208]}, {"w": "reads", "b": [0.3974, 0.6994, 0.4418, 0.7208]}, {"w": "from", "b": [0.4467, 0.6994, 0.4883, 0.7208]}, {"w": "your", "b": [0.4932, 0.6994, 0.5322, 0.7208]}, {"w": "current", "b": [0.5371, 0.6994, 0.5986, 0.7208]}, {"w": "format", "b": [0.6035, 0.6994, 0.6602, 0.7208]}, {"w": "(say,", "b": [0.6651, 0.6994, 0.7015, 0.7208]}, {"w": "CSV", "b": [0.7065, 0.6994, 0.7448, 0.7208]}, {"w": "files),", "b": [0.7497, 0.6994, 0.7952, 0.7208]}, {"w": "creates", "b": [0.8001, 0.6994, 0.8571, 0.7208]}, {"w": "an", "b": [0.1429, 0.7193, 0.1634, 0.7407]}, {"w": "Example", "b": [0.1721, 0.7225, 0.2413, 0.7376]}, {"w": "protobuf", "b": [0.25, 0.7193, 0.324, 0.7407]}, {"w": "for", "b": [0.3327, 0.7193, 0.3572, 0.7407]}, {"w": "each", "b": [0.3659, 0.7193, 0.4038, 0.7407]}, {"w": "instance,", "b": [0.4125, 0.7193, 0.4864, 0.7407]}, {"w": "serializes", "b": [0.4951, 0.7193, 0.5701, 0.7407]}, {"w": "them", "b": [0.5788, 0.7193, 0.6222, 0.7407]}, {"w": "and", "b": [0.6309, 0.7193, 0.6624, 0.7407]}, {"w": "saves", "b": [0.6711, 0.7193, 0.7136, 0.7407]}, {"w": "them", "b": [0.7223, 0.7193, 0.7657, 0.7407]}, {"w": "to", "b": [0.7743, 0.7193, 0.7913, 0.7407]}, {"w": "several", "b": [0.8, 0.7193, 0.8571, 0.7407]}, {"w": "TFRecord", "b": [0.1429, 0.7384, 0.2267, 0.7598]}, {"w": "files,", "b": [0.2331, 0.7384, 0.2714, 0.7598]}, {"w": "ideally", "b": [0.2779, 0.7384, 0.3326, 0.7598]}, {"w": "shuffling", "b": [0.339, 0.7384, 0.4128, 0.7598]}, {"w": "them", "b": [0.4192, 0.7384, 0.4626, 0.7598]}, {"w": "in", "b": [0.4691, 0.7384, 0.486, 0.7598]}, {"w": "the", "b": [0.4925, 0.7384, 0.5188, 0.7598]}, {"w": "process.", "b": [0.5253, 0.7384, 0.5923, 0.7598]}, {"w": "This", "b": [0.5987, 0.7384, 0.6359, 0.7598]}, {"w": "requires", "b": [0.6424, 0.7384, 0.7105, 0.7598]}, {"w": "a", "b": [0.7169, 0.7384, 0.7261, 0.7598]}, {"w": "bit", "b": [0.7325, 0.7384, 0.755, 0.7598]}, {"w": "of", "b": [0.7615, 0.7384, 0.7783, 0.7598]}, {"w": "work,", "b": [0.7847, 0.7384, 0.8324, 0.7598]}, {"w": "so", "b": [0.8389, 0.7384, 0.8572, 0.7598]}, {"w": "once", "b": [0.1429, 0.7574, 0.1825, 0.7788]}, {"w": "again", "b": [0.1901, 0.7574, 0.2351, 0.7788]}, {"w": "make", "b": [0.2427, 0.7574, 0.2881, 0.7788]}, {"w": "sure", "b": [0.2956, 0.7574, 0.3309, 0.7788]}, {"w": "it", "b": [0.3385, 0.7574, 0.3504, 0.7788]}, {"w": "is", "b": [0.358, 0.7574, 0.3712, 0.7788]}, {"w": "really", "b": [0.3787, 0.7574, 0.4246, 0.7788]}, {"w": "necessary", "b": [0.4321, 0.7574, 0.5124, 0.7788]}, {"w": "(perhaps", "b": [0.5199, 0.7574, 0.5931, 0.7788]}, {"w": "your", "b": [0.6006, 0.7574, 0.6396, 0.7788]}, {"w": "pipeline", "b": [0.6472, 0.7574, 0.7145, 0.7788]}, {"w": "works", "b": [0.7221, 0.7574, 0.7727, 0.7788]}, {"w": "fine", "b": [0.7803, 0.7574, 0.8123, 0.7788]}, {"w": "with", "b": [0.8198, 0.7574, 0.8571, 0.7788]}, {"w": "CSV", "b": [0.1429, 0.7765, 0.1812, 0.7979]}, {"w": "files).", "b": [0.186, 0.7765, 0.2314, 0.7979]}]}, {"id": "b_9", "type": "paragraph", "text": "The TFRecord Format | 417", "words": [{"w": "The", "b": [0.6724, 0.9225, 0.6939, 0.9388]}, {"w": "TFRecord", "b": [0.6967, 0.9225, 0.7503, 0.9388]}, {"w": "Format", "b": [0.7532, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "417", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 444, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Now that we have a nice TFRecord file containing a serialized Example, let’s try to load it.", "words": [{"w": "Now", "b": [0.1429, 0.08, 0.1827, 0.1014]}, {"w": "that", "b": [0.1901, 0.08, 0.2227, 0.1014]}, {"w": "we", "b": [0.2302, 0.08, 0.2533, 0.1014]}, {"w": "have", "b": [0.2607, 0.08, 0.2991, 0.1014]}, {"w": "a", "b": [0.3066, 0.08, 0.3157, 0.1014]}, {"w": "nice", "b": [0.3232, 0.08, 0.3578, 0.1014]}, {"w": "TFRecord", "b": [0.3652, 0.08, 0.4491, 0.1014]}, {"w": "file", "b": [0.4565, 0.08, 0.4824, 0.1014]}, {"w": "containing", "b": [0.4898, 0.08, 0.5795, 0.1014]}, {"w": "a", "b": [0.5869, 0.08, 0.5961, 0.1014]}, {"w": "serialized", "b": [0.6035, 0.08, 0.6819, 0.1014]}, {"w": "Example,", "b": [0.6893, 0.08, 0.7634, 0.1014]}, {"w": "let’s", "b": [0.7708, 0.08, 0.801, 0.1014]}, {"w": "try", "b": [0.8085, 0.08, 0.8327, 0.1014]}, {"w": "to", "b": [0.8402, 0.08, 0.8571, 0.1014]}, {"w": "load", "b": [0.1429, 0.099, 0.1789, 0.1204]}, {"w": "it.", "b": [0.1836, 0.099, 0.2003, 0.1204]}]}, {"id": "b_1", "type": "paragraph", "text": "Loading and Parsing Examples", "words": [{"w": "Loading", "b": [0.1429, 0.1332, 0.2261, 0.1617]}, {"w": "and", "b": [0.231, 0.1332, 0.2703, 0.1617]}, {"w": "Parsing", "b": [0.2752, 0.1332, 0.3526, 0.1617]}, {"w": "Examples", "b": [0.3575, 0.1332, 0.4555, 0.1617]}]}, {"id": "b_2", "type": "paragraph", "text": "To load the serialized Example protobufs, we will use a tf.data.TFRecordDataset once again, and we will parse each Example using tf.io.parse_single_example(). This is a TensorFlow operation so it can be included in a TF Function. It requires at least two arguments: a string scalar tensor containing the serialized data, and a description of each feature. The description is a dictionary that maps each feature name to either a tf.io.FixedLenFeature descriptor indicating the feature’s shape, type and default value, or a tf.io.VarLenFeature descriptor indicating only the type (if the length may vary, such as for the \"emails\" feature). For example:", "words": [{"w": "To", "b": [0.1429, 0.1685, 0.1643, 0.19]}, {"w": "load", "b": [0.1721, 0.1685, 0.2082, 0.19]}, {"w": "the", "b": [0.216, 0.1685, 0.2424, 0.19]}, {"w": "serialized", "b": [0.2502, 0.1685, 0.3286, 0.19]}, {"w": "Example", "b": [0.3365, 0.1717, 0.4058, 0.1868]}, {"w": "protobufs,", "b": [0.4136, 0.1685, 0.5001, 0.19]}, {"w": "we", "b": [0.5079, 0.1685, 0.531, 0.19]}, {"w": "will", "b": [0.5389, 0.1685, 0.5693, 0.19]}, {"w": "use", "b": [0.5771, 0.1685, 0.6047, 0.19]}, {"w": "a", "b": [0.6125, 0.1685, 0.6217, 0.19]}, {"w": "tf.data.TFRecordDataset", "b": [0.6295, 0.1717, 0.8571, 0.1868]}, {"w": "once", "b": [0.1429, 0.1885, 0.1825, 0.2099]}, {"w": "again,", "b": [0.1893, 0.1885, 0.2391, 0.2099]}, {"w": "and", "b": [0.2459, 0.1885, 0.2774, 0.2099]}, {"w": "we", "b": [0.2842, 0.1885, 0.3073, 0.2099]}, {"w": "will", "b": [0.3141, 0.1885, 0.3445, 0.2099]}, {"w": "parse", "b": [0.3513, 0.1885, 0.3956, 0.2099]}, {"w": "each", "b": [0.4023, 0.1885, 0.4403, 0.2099]}, {"w": "Example", "b": [0.447, 0.1917, 0.5163, 0.2068]}, {"w": "using", "b": [0.5231, 0.1885, 0.5685, 0.2099]}, {"w": "tf.io.parse_single_example().", "b": [0.5753, 0.1885, 0.8571, 0.2099]}, {"w": "This", "b": [0.1428, 0.2075, 0.1801, 0.229]}, {"w": "is", "b": [0.1861, 0.2075, 0.1994, 0.229]}, {"w": "a", "b": [0.2054, 0.2075, 0.2146, 0.229]}, {"w": "TensorFlow", "b": [0.2207, 0.2075, 0.3189, 0.229]}, {"w": "operation", "b": [0.325, 0.2075, 0.4058, 0.229]}, {"w": "so", "b": [0.4119, 0.2075, 0.4302, 0.229]}, {"w": "it", "b": [0.4362, 0.2075, 0.4482, 0.229]}, {"w": "can", "b": [0.4543, 0.2075, 0.4836, 0.229]}, {"w": "be", "b": [0.4897, 0.2075, 0.5091, 0.229]}, {"w": "included", "b": [0.5152, 0.2075, 0.5882, 0.229]}, {"w": "in", "b": [0.5942, 0.2075, 0.6112, 0.229]}, {"w": "a", "b": [0.6173, 0.2075, 0.6264, 0.229]}, {"w": "TF", "b": [0.6325, 0.2075, 0.6564, 0.229]}, {"w": "Function.", "b": [0.6625, 0.2075, 0.7431, 0.229]}, {"w": "It", "b": [0.7491, 0.2075, 0.7618, 0.229]}, {"w": "requires", "b": [0.7679, 0.2075, 0.836, 0.229]}, {"w": "at", "b": [0.842, 0.2075, 0.8571, 0.229]}, {"w": "least", "b": [0.1429, 0.2266, 0.1801, 0.248]}, {"w": "two", "b": [0.1901, 0.2266, 0.2213, 0.248]}, {"w": "arguments:", "b": [0.2313, 0.2266, 0.3246, 0.248]}, {"w": "a", "b": [0.3346, 0.2266, 0.3437, 0.248]}, {"w": "string", "b": [0.3537, 0.2266, 0.4021, 0.248]}, {"w": "scalar", "b": [0.4121, 0.2266, 0.4598, 0.248]}, {"w": "tensor", "b": [0.4698, 0.2266, 0.5224, 0.248]}, {"w": "containing", "b": [0.5323, 0.2266, 0.622, 0.248]}, {"w": "the", "b": [0.6319, 0.2266, 0.6583, 0.248]}, {"w": "serialized", "b": [0.6682, 0.2266, 0.7466, 0.248]}, {"w": "data,", "b": [0.7566, 0.2266, 0.7966, 0.248]}, {"w": "and", "b": [0.8065, 0.2266, 0.8381, 0.248]}, {"w": "a", "b": [0.848, 0.2266, 0.8571, 0.248]}, {"w": "description", "b": [0.1429, 0.2456, 0.2374, 0.267]}, {"w": "of", "b": [0.2452, 0.2456, 0.262, 0.267]}, {"w": "each", "b": [0.2698, 0.2456, 0.3077, 0.267]}, {"w": "feature.", "b": [0.3155, 0.2456, 0.378, 0.267]}, {"w": "The", "b": [0.3859, 0.2456, 0.4187, 0.267]}, {"w": "description", "b": [0.4265, 0.2456, 0.521, 0.267]}, {"w": "is", "b": [0.5288, 0.2456, 0.5421, 0.267]}, {"w": "a", "b": [0.5499, 0.2456, 0.559, 0.267]}, {"w": "dictionary", "b": [0.5668, 0.2456, 0.6532, 0.267]}, {"w": "that", "b": [0.661, 0.2456, 0.6936, 0.267]}, {"w": "maps", "b": [0.7014, 0.2456, 0.7458, 0.267]}, {"w": "each", "b": [0.7536, 0.2456, 0.7916, 0.267]}, {"w": "feature", "b": [0.7994, 0.2456, 0.8571, 0.267]}, {"w": "name", "b": [0.1429, 0.2656, 0.1893, 0.287]}, {"w": "to", "b": [0.1972, 0.2656, 0.2141, 0.287]}, {"w": "either", "b": [0.222, 0.2656, 0.2705, 0.287]}, {"w": "a", "b": [0.2784, 0.2656, 0.2875, 0.287]}, {"w": "tf.io.FixedLenFeature", "b": [0.2953, 0.2688, 0.5032, 0.2838]}, {"w": "descriptor", "b": [0.511, 0.2656, 0.5963, 0.287]}, {"w": "indicating", "b": [0.6041, 0.2656, 0.6883, 0.287]}, {"w": "the", "b": [0.6962, 0.2656, 0.7225, 0.287]}, {"w": "feature’s", "b": [0.7304, 0.2656, 0.7972, 0.287]}, {"w": "shape,", "b": [0.8051, 0.2656, 0.8571, 0.287]}, {"w": "type", "b": [0.1428, 0.2855, 0.1785, 0.3069]}, {"w": "and", "b": [0.1837, 0.2855, 0.2153, 0.3069]}, {"w": "default", "b": [0.2204, 0.2855, 0.2779, 0.3069]}, {"w": "value,", "b": [0.2831, 0.2855, 0.3318, 0.3069]}, {"w": "or", "b": [0.337, 0.2855, 0.3554, 0.3069]}, {"w": "a", "b": [0.3605, 0.2855, 0.3697, 0.3069]}, {"w": "tf.io.VarLenFeature", "b": [0.3749, 0.2887, 0.5629, 0.3038]}, {"w": "descriptor", "b": [0.5681, 0.2855, 0.6533, 0.3069]}, {"w": "indicating", "b": [0.6585, 0.2855, 0.7427, 0.3069]}, {"w": "only", "b": [0.7479, 0.2855, 0.7848, 0.3069]}, {"w": "the", "b": [0.7899, 0.2855, 0.8163, 0.3069]}, {"w": "type", "b": [0.8215, 0.2855, 0.8571, 0.3069]}, {"w": "(if", "b": [0.1429, 0.3055, 0.1618, 0.3269]}, {"w": "the", "b": [0.1666, 0.3055, 0.1929, 0.3269]}, {"w": "length", "b": [0.1976, 0.3055, 0.2504, 0.3269]}, {"w": "may", "b": [0.2551, 0.3055, 0.2905, 0.3269]}, {"w": "vary,", "b": [0.2952, 0.3055, 0.3351, 0.3269]}, {"w": "such", "b": [0.3399, 0.3055, 0.3785, 0.3269]}, {"w": "as", "b": [0.3832, 0.3055, 0.4, 0.3269]}, {"w": "for", "b": [0.4048, 0.3055, 0.4293, 0.3269]}, {"w": "the", "b": [0.434, 0.3055, 0.4603, 0.3269]}, {"w": "\"emails\"", "b": [0.4651, 0.3087, 0.5442, 0.3237]}, {"w": "feature).", "b": [0.549, 0.3055, 0.6187, 0.3269]}, {"w": "For", "b": [0.6234, 0.3055, 0.6524, 0.3269]}, {"w": "example:", "b": [0.6571, 0.3055, 0.7314, 0.3269]}]}, {"id": "b_3", "type": "paragraph", "text": "feature_description = { \"name\": tf.io.FixedLenFeature([], tf.string, default_value=\"\"), \"id\": tf.io.FixedLenFeature([], tf.int64, default_value=0), \"emails\": tf.io.VarLenFeature(tf.string), }", "words": [{"w": "feature_description", "b": [0.1766, 0.3374, 0.3368, 0.3503]}, {"w": "=", "b": [0.3452, 0.3374, 0.3537, 0.3503]}, {"w": "{", "b": [0.3621, 0.3374, 0.3705, 0.3503]}, {"w": "\"name\":", "b": [0.2103, 0.3529, 0.2693, 0.3657]}, {"w": "tf.io.FixedLenFeature([],", "b": [0.2778, 0.3529, 0.4886, 0.3657]}, {"w": "tf.string,", "b": [0.497, 0.3529, 0.5813, 0.3657]}, {"w": "default_value=\"\"),", "b": [0.5898, 0.3529, 0.7416, 0.3657]}, {"w": "\"id\":", "b": [0.2103, 0.3683, 0.2525, 0.3811]}, {"w": "tf.io.FixedLenFeature([],", "b": [0.2609, 0.3683, 0.4717, 0.3811]}, {"w": "tf.int64,", "b": [0.4802, 0.3683, 0.5561, 0.3811]}, {"w": "default_value=0),", "b": [0.5645, 0.3683, 0.7078, 0.3811]}, {"w": "\"emails\":", "b": [0.2103, 0.3837, 0.2862, 0.3966]}, {"w": "tf.io.VarLenFeature(tf.string),", "b": [0.2946, 0.3837, 0.5561, 0.3966]}, {"w": "}", "b": [0.1766, 0.3991, 0.185, 0.412]}]}, {"id": "b_4", "type": "paragraph", "text": "for serialized_example in tf.data.TFRecordDataset([\"my_contacts.tfrecord\"]): parsed_example = tf.io.parse_single_example(serialized_example, feature_description)", "words": [{"w": "for", "b": [0.1766, 0.43, 0.2019, 0.4428]}, {"w": "serialized_example", "b": [0.2103, 0.43, 0.3621, 0.4428]}, {"w": "in", "b": [0.3705, 0.43, 0.3874, 0.4428]}, {"w": "tf.data.TFRecordDataset([\"my_contacts.tfrecord\"]):", "b": [0.3958, 0.43, 0.8175, 0.4428]}, {"w": "parsed_example", "b": [0.2103, 0.4454, 0.3284, 0.4582]}, {"w": "=", "b": [0.3368, 0.4454, 0.3452, 0.4582]}, {"w": "tf.io.parse_single_example(serialized_example,", "b": [0.3537, 0.4454, 0.7416, 0.4582]}, {"w": "feature_description)", "b": [0.5813, 0.4608, 0.75, 0.4736]}]}, {"id": "b_5", "type": "paragraph", "text": "The fixed length features are parsed as regular tensors, but the variable length fea‐ tures are parsed as sparse tensors. You can convert a sparse tensor to a dense tensor using tf.sparse.to_dense(), but in this case it is simpler to just access its values:", "words": [{"w": "The", "b": [0.1429, 0.4814, 0.1757, 0.5028]}, {"w": "fixed", "b": [0.183, 0.4814, 0.2244, 0.5028]}, {"w": "length", "b": [0.2317, 0.4814, 0.2845, 0.5028]}, {"w": "features", "b": [0.2918, 0.4814, 0.3572, 0.5028]}, {"w": "are", "b": [0.3645, 0.4814, 0.3902, 0.5028]}, {"w": "parsed", "b": [0.3975, 0.4814, 0.4528, 0.5028]}, {"w": "as", "b": [0.4601, 0.4814, 0.4769, 0.5028]}, {"w": "regular", "b": [0.4842, 0.4814, 0.5437, 0.5028]}, {"w": "tensors,", "b": [0.551, 0.4814, 0.616, 0.5028]}, {"w": "but", "b": [0.6233, 0.4814, 0.6513, 0.5028]}, {"w": "the", "b": [0.6586, 0.4814, 0.685, 0.5028]}, {"w": "variable", "b": [0.6923, 0.4814, 0.7582, 0.5028]}, {"w": "length", "b": [0.7655, 0.4814, 0.8183, 0.5028]}, {"w": "fea‐", "b": [0.8256, 0.4814, 0.8571, 0.5028]}, {"w": "tures", "b": [0.1429, 0.5005, 0.1845, 0.5219]}, {"w": "are", "b": [0.1907, 0.5005, 0.2164, 0.5219]}, {"w": "parsed", "b": [0.2227, 0.5005, 0.2779, 0.5219]}, {"w": "as", "b": [0.2842, 0.5005, 0.3009, 0.5219]}, {"w": "sparse", "b": [0.3071, 0.5005, 0.3591, 0.5219]}, {"w": "tensors.", "b": [0.3653, 0.5005, 0.4303, 0.5219]}, {"w": "You", "b": [0.4365, 0.5005, 0.4688, 0.5219]}, {"w": "can", "b": [0.4751, 0.5005, 0.5044, 0.5219]}, {"w": "convert", "b": [0.5106, 0.5005, 0.5736, 0.5219]}, {"w": "a", "b": [0.5798, 0.5005, 0.5889, 0.5219]}, {"w": "sparse", "b": [0.5951, 0.5005, 0.647, 0.5219]}, {"w": "tensor", "b": [0.6533, 0.5005, 0.7059, 0.5219]}, {"w": "to", "b": [0.7121, 0.5005, 0.729, 0.5219]}, {"w": "a", "b": [0.7352, 0.5005, 0.7444, 0.5219]}, {"w": "dense", "b": [0.7506, 0.5005, 0.7983, 0.5219]}, {"w": "tensor", "b": [0.8045, 0.5005, 0.8572, 0.5219]}, {"w": "using", "b": [0.1429, 0.5204, 0.1883, 0.5418]}, {"w": "tf.sparse.to_dense(),", "b": [0.193, 0.5204, 0.3957, 0.5418]}, {"w": "but", "b": [0.4004, 0.5204, 0.4284, 0.5418]}, {"w": "in", "b": [0.4332, 0.5204, 0.4501, 0.5418]}, {"w": "this", "b": [0.4549, 0.5204, 0.4856, 0.5418]}, {"w": "case", "b": [0.4903, 0.5204, 0.5248, 0.5418]}, {"w": "it", "b": [0.5295, 0.5204, 0.5414, 0.5418]}, {"w": "is", "b": [0.5462, 0.5204, 0.5594, 0.5418]}, {"w": "simpler", "b": [0.5641, 0.5204, 0.6268, 0.5418]}, {"w": "to", "b": [0.6315, 0.5204, 0.6485, 0.5418]}, {"w": "just", "b": [0.6532, 0.5204, 0.6836, 0.5418]}, {"w": "access", "b": [0.6883, 0.5204, 0.7393, 0.5418]}, {"w": "its", "b": [0.744, 0.5204, 0.7636, 0.5418]}, {"w": "values:", "b": [0.7683, 0.5204, 0.8247, 0.5418]}]}, {"id": "b_6", "type": "paragraph", "text": ">>> tf.sparse.to_dense(parsed_example[\"emails\"], default_value=b\"\") >>> parsed_example[\"emails\"].values ", "words": [{"w": ">>>", "b": [0.1766, 0.5524, 0.2019, 0.5652]}, {"w": "tf.sparse.to_dense(parsed_example[\"emails\"],", "b": [0.2103, 0.5524, 0.5813, 0.5652]}, {"w": "default_value=b\"\")", "b": [0.5898, 0.5524, 0.7416, 0.5652]}, {"w": "", "b": [0.7669, 0.5678, 0.8259, 0.5807]}, {"w": ">>>", "b": [0.1766, 0.5832, 0.2019, 0.5961]}, {"w": "parsed_example[\"emails\"].values", "b": [0.2103, 0.5832, 0.4717, 0.5961]}, {"w": "", "b": [0.7669, 0.5987, 0.8259, 0.6115]}]}, {"id": "b_7", "type": "paragraph", "text": "A BytesList can contain any binary data you want, including any serialized object. For example, you can use tf.io.encode_jpeg() to encode an image using the JPEG format, and put this binary data in a BytesList. Later, when your code reads the TFRecord, it will start by parsing the Example, then you will need to call tf.io.decode_jpeg() to parse the data and get the original image (or you can use tf.io.decode_image(), which can decode any BMP, GIF, JPEG or PNG image). You can also store any tensor you want in a BytesList by serializing the tensor using tf.io.serialize_tensor(), then putting the resulting byte string in a BytesList feature. Later, when you parse the TFRecord, you can parse this data using tf.io.parse_tensor().", "words": [{"w": "A", "b": [0.1429, 0.6202, 0.1573, 0.6416]}, {"w": "BytesList", "b": [0.1639, 0.6234, 0.2529, 0.6384]}, {"w": "can", "b": [0.2595, 0.6202, 0.2889, 0.6416]}, {"w": "contain", "b": [0.2955, 0.6202, 0.3584, 0.6416]}, {"w": "any", "b": [0.365, 0.6202, 0.3946, 0.6416]}, {"w": "binary", "b": [0.4012, 0.6202, 0.4558, 0.6416]}, {"w": "data", "b": [0.4624, 0.6202, 0.4976, 0.6416]}, {"w": "you", "b": [0.5042, 0.6202, 0.5355, 0.6416]}, {"w": "want,", "b": [0.5421, 0.6202, 0.5876, 0.6416]}, {"w": "including", "b": [0.5942, 0.6202, 0.674, 0.6416]}, {"w": "any", "b": [0.6806, 0.6202, 0.7102, 0.6416]}, {"w": "serialized", "b": [0.7168, 0.6202, 0.7952, 0.6416]}, {"w": "object.", "b": [0.8018, 0.6202, 0.8572, 0.6416]}, {"w": "For", "b": [0.1429, 0.6401, 0.1718, 0.6615]}, {"w": "example,", "b": [0.1777, 0.6401, 0.252, 0.6615]}, {"w": "you", "b": [0.2578, 0.6401, 0.2891, 0.6615]}, {"w": "can", "b": [0.295, 0.6401, 0.3243, 0.6615]}, {"w": "use", "b": [0.3302, 0.6401, 0.3577, 0.6615]}, {"w": "tf.io.encode_jpeg()", "b": [0.3636, 0.6433, 0.5516, 0.6584]}, {"w": "to", "b": [0.5575, 0.6401, 0.5744, 0.6615]}, {"w": "encode", "b": [0.5803, 0.6401, 0.6398, 0.6615]}, {"w": "an", "b": [0.6457, 0.6401, 0.6662, 0.6615]}, {"w": "image", "b": [0.6721, 0.6401, 0.7225, 0.6615]}, {"w": "using", "b": [0.7284, 0.6401, 0.7738, 0.6615]}, {"w": "the", "b": [0.7796, 0.6401, 0.806, 0.6615]}, {"w": "JPEG", "b": [0.8118, 0.6401, 0.8571, 0.6615]}, {"w": "format,", "b": [0.1429, 0.6601, 0.2043, 0.6815]}, {"w": "and", "b": [0.2123, 0.6601, 0.2438, 0.6815]}, {"w": "put", "b": [0.2518, 0.6601, 0.2801, 0.6815]}, {"w": "this", "b": [0.2881, 0.6601, 0.3188, 0.6815]}, {"w": "binary", "b": [0.3267, 0.6601, 0.3813, 0.6815]}, {"w": "data", "b": [0.3893, 0.6601, 0.4246, 0.6815]}, {"w": "in", "b": [0.4325, 0.6601, 0.4495, 0.6815]}, {"w": "a", "b": [0.4575, 0.6601, 0.4666, 0.6815]}, {"w": "BytesList.", "b": [0.4746, 0.6601, 0.5684, 0.6815]}, {"w": "Later,", "b": [0.5764, 0.6601, 0.6227, 0.6815]}, {"w": "when", "b": [0.6307, 0.6601, 0.6763, 0.6815]}, {"w": "your", "b": [0.6843, 0.6601, 0.7232, 0.6815]}, {"w": "code", "b": [0.7312, 0.6601, 0.7705, 0.6815]}, {"w": "reads", "b": [0.7785, 0.6601, 0.8228, 0.6815]}, {"w": "the", "b": [0.8308, 0.6601, 0.8571, 0.6815]}, {"w": "TFRecord,", "b": [0.1428, 0.68, 0.2314, 0.7014]}, {"w": "it", "b": [0.2452, 0.68, 0.2571, 0.7014]}, {"w": "will", "b": [0.2708, 0.68, 0.3012, 0.7014]}, {"w": "start", "b": [0.315, 0.68, 0.3522, 0.7014]}, {"w": "by", "b": [0.3659, 0.68, 0.3861, 0.7014]}, {"w": "parsing", "b": [0.3998, 0.68, 0.462, 0.7014]}, {"w": "the", "b": [0.4757, 0.68, 0.502, 0.7014]}, {"w": "Example,", "b": [0.5158, 0.68, 0.5898, 0.7014]}, {"w": "then", "b": [0.6035, 0.68, 0.6412, 0.7014]}, {"w": "you", "b": [0.655, 0.68, 0.6862, 0.7014]}, {"w": "will", "b": [0.7, 0.68, 0.7304, 0.7014]}, {"w": "need", "b": [0.7441, 0.68, 0.7842, 0.7014]}, {"w": "to", "b": [0.7979, 0.68, 0.8149, 0.7014]}, {"w": "call", "b": [0.8286, 0.68, 0.8571, 0.7014]}, {"w": "tf.io.decode_jpeg()", "b": [0.1429, 0.7031, 0.3309, 0.7182]}, {"w": "to", "b": [0.3379, 0.7, 0.3549, 0.7214]}, {"w": "parse", "b": [0.3619, 0.7, 0.4062, 0.7214]}, {"w": "the", "b": [0.4132, 0.7, 0.4396, 0.7214]}, {"w": "data", "b": [0.4466, 0.7, 0.4818, 0.7214]}, {"w": "and", "b": [0.4889, 0.7, 0.5204, 0.7214]}, {"w": "get", "b": [0.5274, 0.7, 0.5524, 0.7214]}, {"w": "the", "b": [0.5594, 0.7, 0.5858, 0.7214]}, {"w": "original", "b": [0.5928, 0.7, 0.6579, 0.7214]}, {"w": "image", "b": [0.6649, 0.7, 0.7153, 0.7214]}, {"w": "(or", "b": [0.7223, 0.7, 0.7479, 0.7214]}, {"w": "you", "b": [0.7549, 0.7, 0.7862, 0.7214]}, {"w": "can", "b": [0.7932, 0.7, 0.8225, 0.7214]}, {"w": "use", "b": [0.8296, 0.7, 0.8571, 0.7214]}, {"w": "tf.io.decode_image(),", "b": [0.1429, 0.7199, 0.3455, 0.7413]}, {"w": "which", "b": [0.3512, 0.7199, 0.4021, 0.7413]}, {"w": "can", "b": [0.4078, 0.7199, 0.4371, 0.7413]}, {"w": "decode", "b": [0.4428, 0.7199, 0.5019, 0.7413]}, {"w": "any", "b": [0.5076, 0.7199, 0.5372, 0.7413]}, {"w": "BMP,", "b": [0.5429, 0.7199, 0.5872, 0.7413]}, {"w": "GIF,", "b": [0.5929, 0.7199, 0.6284, 0.7413]}, {"w": "JPEG", "b": [0.634, 0.7199, 0.6794, 0.7413]}, {"w": "or", "b": [0.685, 0.7199, 0.7034, 0.7413]}, {"w": "PNG", "b": [0.709, 0.7199, 0.7511, 0.7413]}, {"w": "image).", "b": [0.7568, 0.7199, 0.8191, 0.7413]}, {"w": "You", "b": [0.8248, 0.7199, 0.8571, 0.7413]}, {"w": "can", "b": [0.1429, 0.7399, 0.1722, 0.7613]}, {"w": "also", "b": [0.1802, 0.7399, 0.2129, 0.7613]}, {"w": "store", "b": [0.2209, 0.7399, 0.2621, 0.7613]}, {"w": "any", "b": [0.2701, 0.7399, 0.2997, 0.7613]}, {"w": "tensor", "b": [0.3077, 0.7399, 0.3603, 0.7613]}, {"w": "you", "b": [0.3683, 0.7399, 0.3995, 0.7613]}, {"w": "want", "b": [0.4075, 0.7399, 0.4483, 0.7613]}, {"w": "in", "b": [0.4562, 0.7399, 0.4732, 0.7613]}, {"w": "a", "b": [0.4812, 0.7399, 0.4904, 0.7613]}, {"w": "BytesList", "b": [0.4983, 0.743, 0.5874, 0.7581]}, {"w": "by", "b": [0.5954, 0.7399, 0.6155, 0.7613]}, {"w": "serializing", "b": [0.6235, 0.7399, 0.7088, 0.7613]}, {"w": "the", "b": [0.7168, 0.7399, 0.7431, 0.7613]}, {"w": "tensor", "b": [0.7511, 0.7399, 0.8037, 0.7613]}, {"w": "using", "b": [0.8117, 0.7399, 0.8571, 0.7613]}, {"w": "tf.io.serialize_tensor(),", "b": [0.1429, 0.7598, 0.3851, 0.7812]}, {"w": "then", "b": [0.3933, 0.7598, 0.4311, 0.7812]}, {"w": "putting", "b": [0.4393, 0.7598, 0.5007, 0.7812]}, {"w": "the", "b": [0.5089, 0.7598, 0.5352, 0.7812]}, {"w": "resulting", "b": [0.5434, 0.7598, 0.6171, 0.7812]}, {"w": "byte", "b": [0.6253, 0.7598, 0.6606, 0.7812]}, {"w": "string", "b": [0.6689, 0.7598, 0.7173, 0.7812]}, {"w": "in", "b": [0.7255, 0.7598, 0.7425, 0.7812]}, {"w": "a", "b": [0.7507, 0.7598, 0.7599, 0.7812]}, {"w": "BytesList", "b": [0.7681, 0.763, 0.8571, 0.7781]}, {"w": "feature.", "b": [0.1429, 0.7788, 0.2054, 0.8003]}, {"w": "Later,", "b": [0.2181, 0.7788, 0.2645, 0.8003]}, {"w": "when", "b": [0.2772, 0.7788, 0.3229, 0.8003]}, {"w": "you", "b": [0.3356, 0.7788, 0.3669, 0.8003]}, {"w": "parse", "b": [0.3796, 0.7788, 0.4239, 0.8003]}, {"w": "the", "b": [0.4367, 0.7788, 0.463, 0.8003]}, {"w": "TFRecord,", "b": [0.4757, 0.7788, 0.5643, 0.8003]}, {"w": "you", "b": [0.5771, 0.7788, 0.6083, 0.8003]}, {"w": "can", "b": [0.6211, 0.7788, 0.6504, 0.8003]}, {"w": "parse", "b": [0.6632, 0.7788, 0.7075, 0.8003]}, {"w": "this", "b": [0.7202, 0.7788, 0.7509, 0.8003]}, {"w": "data", "b": [0.7637, 0.7788, 0.7989, 0.8003]}, {"w": "using", "b": [0.8117, 0.7788, 0.8571, 0.8003]}, {"w": "tf.io.parse_tensor().", "b": [0.1429, 0.7988, 0.3455, 0.8202]}]}, {"id": "b_8", "type": "paragraph", "text": "Instead of parsing examples one by one using tf.io.parse_single_example(), you may want to parse them batch by batch using tf.io.parse_example():", "words": [{"w": "Instead", "b": [0.1429, 0.8278, 0.2044, 0.8492]}, {"w": "of", "b": [0.2106, 0.8278, 0.2274, 0.8492]}, {"w": "parsing", "b": [0.2336, 0.8278, 0.2958, 0.8492]}, {"w": "examples", "b": [0.3021, 0.8278, 0.3792, 0.8492]}, {"w": "one", "b": [0.3855, 0.8278, 0.4164, 0.8492]}, {"w": "by", "b": [0.4226, 0.8278, 0.4428, 0.8492]}, {"w": "one", "b": [0.449, 0.8278, 0.4799, 0.8492]}, {"w": "using", "b": [0.4861, 0.8278, 0.5316, 0.8492]}, {"w": "tf.io.parse_single_example(),", "b": [0.5378, 0.8278, 0.8196, 0.8492]}, {"w": "you", "b": [0.8259, 0.8278, 0.8571, 0.8492]}, {"w": "may", "b": [0.1429, 0.8477, 0.1782, 0.8692]}, {"w": "want", "b": [0.183, 0.8477, 0.2237, 0.8692]}, {"w": "to", "b": [0.2285, 0.8477, 0.2455, 0.8692]}, {"w": "parse", "b": [0.2502, 0.8477, 0.2945, 0.8692]}, {"w": "them", "b": [0.2992, 0.8477, 0.3426, 0.8692]}, {"w": "batch", "b": [0.3473, 0.8477, 0.393, 0.8692]}, {"w": "by", "b": [0.3977, 0.8477, 0.4178, 0.8692]}, {"w": "batch", "b": [0.4226, 0.8477, 0.4682, 0.8692]}, {"w": "using", "b": [0.4729, 0.8477, 0.5184, 0.8692]}, {"w": "tf.io.parse_example():", "b": [0.5231, 0.8477, 0.7356, 0.8692]}]}, {"id": "b_9", "type": "paragraph", "text": "418 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "418", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 445, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "dataset = tf.data.TFRecordDataset([\"my_contacts.tfrecord\"]).batch(10) for serialized_examples in dataset: parsed_examples = tf.io.parse_example(serialized_examples, feature_description)", "words": [{"w": "dataset", "b": [0.1766, 0.0829, 0.2356, 0.0958]}, {"w": "=", "b": [0.244, 0.0829, 0.2525, 0.0958]}, {"w": "tf.data.TFRecordDataset([\"my_contacts.tfrecord\"]).batch(10)", "b": [0.2609, 0.0829, 0.7584, 0.0958]}, {"w": "for", "b": [0.1766, 0.0983, 0.2019, 0.1112]}, {"w": "serialized_examples", "b": [0.2103, 0.0983, 0.3705, 0.1112]}, {"w": "in", "b": [0.379, 0.0983, 0.3958, 0.1112]}, {"w": "dataset:", "b": [0.4043, 0.0983, 0.4717, 0.1112]}, {"w": "parsed_examples", "b": [0.2103, 0.1138, 0.3368, 0.1266]}, {"w": "=", "b": [0.3452, 0.1138, 0.3537, 0.1266]}, {"w": "tf.io.parse_example(serialized_examples,", "b": [0.3621, 0.1138, 0.6994, 0.1266]}, {"w": "feature_description)", "b": [0.5308, 0.1292, 0.6994, 0.142]}]}, {"id": "b_1", "type": "paragraph", "text": "As you can see, the Example proto will probably be sufficient for most use cases. However, it may be a bit cumbersome to use when you are dealing with lists of lists. For example, suppose you want to classify text documents. Each document may be represented as a list of sentences, where each sentence is represented as a list of words. And perhaps each document also has a list of comments, where each com‐ ment is also represented as a list of words. Moreover, there may be some contextual data as well, such as the document’s author, title and publication date. TensorFlow’s SequenceExample protobuf is designed for such use cases.", "words": [{"w": "As", "b": [0.1429, 0.1507, 0.1649, 0.1721]}, {"w": "you", "b": [0.1733, 0.1507, 0.2046, 0.1721]}, {"w": "can", "b": [0.213, 0.1507, 0.2423, 0.1721]}, {"w": "see,", "b": [0.2507, 0.1507, 0.2808, 0.1721]}, {"w": "the", "b": [0.2892, 0.1507, 0.3155, 0.1721]}, {"w": "Example", "b": [0.3239, 0.1539, 0.3932, 0.169]}, {"w": "proto", "b": [0.4016, 0.1507, 0.4479, 0.1721]}, {"w": "will", "b": [0.4563, 0.1507, 0.4867, 0.1721]}, {"w": "probably", "b": [0.4951, 0.1507, 0.5695, 0.1721]}, {"w": "be", "b": [0.5779, 0.1507, 0.5973, 0.1721]}, {"w": "sufficient", "b": [0.6057, 0.1507, 0.6829, 0.1721]}, {"w": "for", "b": [0.6913, 0.1507, 0.7158, 0.1721]}, {"w": "most", "b": [0.7242, 0.1507, 0.7659, 0.1721]}, {"w": "use", "b": [0.7743, 0.1507, 0.8019, 0.1721]}, {"w": "cases.", "b": [0.8103, 0.1507, 0.8571, 0.1721]}, {"w": "However,", "b": [0.1429, 0.1698, 0.2217, 0.1912]}, {"w": "it", "b": [0.2278, 0.1698, 0.2397, 0.1912]}, {"w": "may", "b": [0.2457, 0.1698, 0.2811, 0.1912]}, {"w": "be", "b": [0.2872, 0.1698, 0.3066, 0.1912]}, {"w": "a", "b": [0.3126, 0.1698, 0.3218, 0.1912]}, {"w": "bit", "b": [0.3278, 0.1698, 0.3504, 0.1912]}, {"w": "cumbersome", "b": [0.3564, 0.1698, 0.4647, 0.1912]}, {"w": "to", "b": [0.4707, 0.1698, 0.4877, 0.1912]}, {"w": "use", "b": [0.4938, 0.1698, 0.5213, 0.1912]}, {"w": "when", "b": [0.5274, 0.1698, 0.573, 0.1912]}, {"w": "you", "b": [0.579, 0.1698, 0.6103, 0.1912]}, {"w": "are", "b": [0.6163, 0.1698, 0.6421, 0.1912]}, {"w": "dealing", "b": [0.6481, 0.1698, 0.7091, 0.1912]}, {"w": "with", "b": [0.7151, 0.1698, 0.7525, 0.1912]}, {"w": "lists", "b": [0.7585, 0.1698, 0.791, 0.1912]}, {"w": "of", "b": [0.7971, 0.1698, 0.8139, 0.1912]}, {"w": "lists.", "b": [0.8199, 0.1698, 0.8571, 0.1912]}, {"w": "For", "b": [0.1429, 0.1888, 0.1718, 0.2102]}, {"w": "example,", "b": [0.1789, 0.1888, 0.2532, 0.2102]}, {"w": "suppose", "b": [0.2603, 0.1888, 0.328, 0.2102]}, {"w": "you", "b": [0.3351, 0.1888, 0.3663, 0.2102]}, {"w": "want", "b": [0.3734, 0.1888, 0.4142, 0.2102]}, {"w": "to", "b": [0.4213, 0.1888, 0.4382, 0.2102]}, {"w": "classify", "b": [0.4453, 0.1888, 0.5055, 0.2102]}, {"w": "text", "b": [0.5126, 0.1888, 0.544, 0.2102]}, {"w": "documents.", "b": [0.5511, 0.1888, 0.6483, 0.2102]}, {"w": "Each", "b": [0.6553, 0.1888, 0.6963, 0.2102]}, {"w": "document", "b": [0.7034, 0.1888, 0.7881, 0.2102]}, {"w": "may", "b": [0.7952, 0.1888, 0.8306, 0.2102]}, {"w": "be", "b": [0.8377, 0.1888, 0.8571, 0.2102]}, {"w": "represented", "b": [0.1429, 0.2078, 0.2407, 0.2293]}, {"w": "as", "b": [0.2496, 0.2078, 0.2664, 0.2293]}, {"w": "a", "b": [0.2754, 0.2078, 0.2845, 0.2293]}, {"w": "list", "b": [0.2935, 0.2078, 0.3184, 0.2293]}, {"w": "of", "b": [0.3273, 0.2078, 0.3441, 0.2293]}, {"w": "sentences,", "b": [0.3531, 0.2078, 0.4373, 0.2293]}, {"w": "where", "b": [0.4462, 0.2078, 0.4971, 0.2293]}, {"w": "each", "b": [0.506, 0.2078, 0.544, 0.2293]}, {"w": "sentence", "b": [0.5529, 0.2078, 0.6247, 0.2293]}, {"w": "is", "b": [0.6337, 0.2078, 0.6469, 0.2293]}, {"w": "represented", "b": [0.6559, 0.2078, 0.7537, 0.2293]}, {"w": "as", "b": [0.7627, 0.2078, 0.7794, 0.2293]}, {"w": "a", "b": [0.7884, 0.2078, 0.7976, 0.2293]}, {"w": "list", "b": [0.8065, 0.2078, 0.8314, 0.2293]}, {"w": "of", "b": [0.8404, 0.2078, 0.8572, 0.2293]}, {"w": "words.", "b": [0.1429, 0.2269, 0.1989, 0.2483]}, {"w": "And", "b": [0.2063, 0.2269, 0.2431, 0.2483]}, {"w": "perhaps", "b": [0.2505, 0.2269, 0.3165, 0.2483]}, {"w": "each", "b": [0.3239, 0.2269, 0.3618, 0.2483]}, {"w": "document", "b": [0.3693, 0.2269, 0.454, 0.2483]}, {"w": "also", "b": [0.4615, 0.2269, 0.4942, 0.2483]}, {"w": "has", "b": [0.5016, 0.2269, 0.5295, 0.2483]}, {"w": "a", "b": [0.5369, 0.2269, 0.5461, 0.2483]}, {"w": "list", "b": [0.5535, 0.2269, 0.5784, 0.2483]}, {"w": "of", "b": [0.5858, 0.2269, 0.6026, 0.2483]}, {"w": "comments,", "b": [0.61, 0.2269, 0.7022, 0.2483]}, {"w": "where", "b": [0.7096, 0.2269, 0.7604, 0.2483]}, {"w": "each", "b": [0.7679, 0.2269, 0.8058, 0.2483]}, {"w": "com‐", "b": [0.8132, 0.2269, 0.8571, 0.2483]}, {"w": "ment", "b": [0.1429, 0.2459, 0.1861, 0.2674]}, {"w": "is", "b": [0.1925, 0.2459, 0.2057, 0.2674]}, {"w": "also", "b": [0.2121, 0.2459, 0.2447, 0.2674]}, {"w": "represented", "b": [0.2511, 0.2459, 0.3489, 0.2674]}, {"w": "as", "b": [0.3552, 0.2459, 0.372, 0.2674]}, {"w": "a", "b": [0.3784, 0.2459, 0.3875, 0.2674]}, {"w": "list", "b": [0.3939, 0.2459, 0.4187, 0.2674]}, {"w": "of", "b": [0.4251, 0.2459, 0.4419, 0.2674]}, {"w": "words.", "b": [0.4482, 0.2459, 0.5043, 0.2674]}, {"w": "Moreover,", "b": [0.5106, 0.2459, 0.5961, 0.2674]}, {"w": "there", "b": [0.6025, 0.2459, 0.6454, 0.2674]}, {"w": "may", "b": [0.6518, 0.2459, 0.6871, 0.2674]}, {"w": "be", "b": [0.6935, 0.2459, 0.7129, 0.2674]}, {"w": "some", "b": [0.7193, 0.2459, 0.7635, 0.2674]}, {"w": "contextual", "b": [0.7698, 0.2459, 0.8571, 0.2674]}, {"w": "data", "b": [0.1428, 0.265, 0.1781, 0.2864]}, {"w": "as", "b": [0.1849, 0.265, 0.2017, 0.2864]}, {"w": "well,", "b": [0.2084, 0.265, 0.2469, 0.2864]}, {"w": "such", "b": [0.2536, 0.265, 0.2923, 0.2864]}, {"w": "as", "b": [0.299, 0.265, 0.3158, 0.2864]}, {"w": "the", "b": [0.3226, 0.265, 0.3489, 0.2864]}, {"w": "document’s", "b": [0.3557, 0.265, 0.4502, 0.2864]}, {"w": "author,", "b": [0.457, 0.265, 0.5161, 0.2864]}, {"w": "title", "b": [0.5229, 0.265, 0.5553, 0.2864]}, {"w": "and", "b": [0.5621, 0.265, 0.5936, 0.2864]}, {"w": "publication", "b": [0.6004, 0.265, 0.6953, 0.2864]}, {"w": "date.", "b": [0.7021, 0.265, 0.7418, 0.2864]}, {"w": "TensorFlow’s", "b": [0.7486, 0.265, 0.8571, 0.2864]}, {"w": "SequenceExample", "b": [0.1429, 0.2881, 0.2913, 0.3032]}, {"w": "protobuf", "b": [0.296, 0.2849, 0.3701, 0.3063]}, {"w": "is", "b": [0.3748, 0.2849, 0.388, 0.3063]}, {"w": "designed", "b": [0.3928, 0.2849, 0.4669, 0.3063]}, {"w": "for", "b": [0.4716, 0.2849, 0.4961, 0.3063]}, {"w": "such", "b": [0.5008, 0.2849, 0.5395, 0.3063]}, {"w": "use", "b": [0.5442, 0.2849, 0.5718, 0.3063]}, {"w": "cases.", "b": [0.5765, 0.2849, 0.6234, 0.3063]}]}, {"id": "b_2", "type": "paragraph", "text": "Handling Lists of Lists Using the SequenceExample Protobuf", "words": [{"w": "Handling", "b": [0.1429, 0.3206, 0.2374, 0.3492]}, {"w": "Lists", "b": [0.2423, 0.3206, 0.2884, 0.3492]}, {"w": "of", "b": [0.2933, 0.3206, 0.3143, 0.3492]}, {"w": "Lists", "b": [0.3192, 0.3206, 0.3652, 0.3492]}, {"w": "Using", "b": [0.3702, 0.3206, 0.4282, 0.3492]}, {"w": "the", "b": [0.4331, 0.3206, 0.468, 0.3492]}, {"w": "SequenceExample", "b": [0.4729, 0.3244, 0.6959, 0.3471]}, {"w": "Protobuf", "b": [0.7008, 0.3206, 0.7923, 0.3492]}]}, {"id": "b_3", "type": "paragraph", "text": "Here is the definition of the SequenceExample protobuf:", "words": [{"w": "Here", "b": [0.1429, 0.356, 0.1837, 0.3774]}, {"w": "is", "b": [0.1885, 0.356, 0.2017, 0.3774]}, {"w": "the", "b": [0.2064, 0.356, 0.2328, 0.3774]}, {"w": "definition", "b": [0.2375, 0.356, 0.32, 0.3774]}, {"w": "of", "b": [0.3248, 0.356, 0.3415, 0.3774]}, {"w": "the", "b": [0.3463, 0.356, 0.3726, 0.3774]}, {"w": "SequenceExample", "b": [0.3773, 0.3592, 0.5258, 0.3743]}, {"w": "protobuf:", "b": [0.5305, 0.356, 0.6093, 0.3774]}]}, {"id": "b_4", "type": "paragraph", "text": "message FeatureList { repeated Feature feature = 1; }; message FeatureLists { map feature_list = 1; }; message SequenceExample { Features context = 1; FeatureLists feature_lists = 2; };", "words": [{"w": "message", "b": [0.1766, 0.388, 0.2356, 0.4008]}, {"w": "FeatureList", "b": [0.2441, 0.388, 0.3368, 0.4008]}, {"w": "{", "b": [0.3452, 0.388, 0.3537, 0.4008]}, {"w": "repeated", "b": [0.3621, 0.388, 0.4296, 0.4008]}, {"w": "Feature", "b": [0.438, 0.388, 0.497, 0.4008]}, {"w": "feature", "b": [0.5055, 0.388, 0.5645, 0.4008]}, {"w": "=", "b": [0.5729, 0.388, 0.5814, 0.4008]}, {"w": "1;", "b": [0.5898, 0.388, 0.6067, 0.4008]}, {"w": "};", "b": [0.6151, 0.388, 0.632, 0.4008]}, {"w": "message", "b": [0.1766, 0.4034, 0.2356, 0.4162]}, {"w": "FeatureLists", "b": [0.2441, 0.4034, 0.3452, 0.4162]}, {"w": "{", "b": [0.3537, 0.4034, 0.3621, 0.4162]}, {"w": "map", "b": [0.4717, 0.4034, 0.5729, 0.4162]}, {"w": "feature_list", "b": [0.5814, 0.4034, 0.6825, 0.4162]}, {"w": "=", "b": [0.691, 0.4034, 0.6994, 0.4162]}, {"w": "1;", "b": [0.7078, 0.4034, 0.7247, 0.4162]}, {"w": "};", "b": [0.7331, 0.4034, 0.75, 0.4162]}, {"w": "message", "b": [0.1766, 0.4188, 0.2356, 0.4317]}, {"w": "SequenceExample", "b": [0.2441, 0.4188, 0.3705, 0.4317]}, {"w": "{", "b": [0.379, 0.4188, 0.3874, 0.4317]}, {"w": "Features", "b": [0.2103, 0.4342, 0.2778, 0.4471]}, {"w": "context", "b": [0.2862, 0.4342, 0.3452, 0.4471]}, {"w": "=", "b": [0.3537, 0.4342, 0.3621, 0.4471]}, {"w": "1;", "b": [0.3705, 0.4342, 0.3874, 0.4471]}, {"w": "FeatureLists", "b": [0.2103, 0.4496, 0.3115, 0.4625]}, {"w": "feature_lists", "b": [0.3199, 0.4496, 0.4296, 0.4625]}, {"w": "=", "b": [0.438, 0.4496, 0.4464, 0.4625]}, {"w": "2;", "b": [0.4549, 0.4496, 0.4717, 0.4625]}, {"w": "};", "b": [0.1766, 0.4651, 0.1935, 0.4779]}]}, {"id": "b_5", "type": "paragraph", "text": "A SequenceExample contains a Features object for the contextual data and a Fea tureLists object which contains one or more named FeatureList objects (e.g., a FeatureList named \"content\" and another named \"comments\"). Each FeatureList just contains a list of Feature objects, each of which may be a list of byte strings, a list of 64-bit integers or a list of floats (in this example, each Feature would represent a sentence or a comment, perhaps in the form of a list of word identifiers). Building a SequenceExample, serializing it and parsing it is very similar to building, serializing and parsing an Example, but you must use tf.io.parse_single_sequence_exam ple() to parse a single SequenceExample or tf.io.parse_sequence_example() to parse a batch, and both functions return a tuple containing the context features (as a dictionary) and the feature lists (also as a dictionary). If the feature lists contain sequences of varying sizes (as in the example above), you may want to convert them to ragged tensors using tf.RaggedTensor.from_sparse() (see the notebook for the full code):", "words": [{"w": "A", "b": [0.1429, 0.4866, 0.1573, 0.508]}, {"w": "SequenceExample", "b": [0.1652, 0.4898, 0.3136, 0.5049]}, {"w": "contains", "b": [0.3216, 0.4866, 0.3921, 0.508]}, {"w": "a", "b": [0.4, 0.4866, 0.4092, 0.508]}, {"w": "Features", "b": [0.4171, 0.4898, 0.4963, 0.5049]}, {"w": "object", "b": [0.5042, 0.4866, 0.5548, 0.508]}, {"w": "for", "b": [0.5627, 0.4866, 0.5872, 0.508]}, {"w": "the", "b": [0.5952, 0.4866, 0.6215, 0.508]}, {"w": "contextual", "b": [0.6294, 0.4866, 0.7167, 0.508]}, {"w": "data", "b": [0.7247, 0.4866, 0.7599, 0.508]}, {"w": "and", "b": [0.7679, 0.4866, 0.7994, 0.508]}, {"w": "a", "b": [0.8073, 0.4866, 0.8165, 0.508]}, {"w": "Fea", "b": [0.8244, 0.4898, 0.8541, 0.5049]}, {"w": "tureLists", "b": [0.1429, 0.5097, 0.2319, 0.5248]}, {"w": "object", "b": [0.2397, 0.5065, 0.2903, 0.528]}, {"w": "which", "b": [0.2981, 0.5065, 0.349, 0.528]}, {"w": "contains", "b": [0.3568, 0.5065, 0.4274, 0.528]}, {"w": "one", "b": [0.4352, 0.5065, 0.4661, 0.528]}, {"w": "or", "b": [0.4739, 0.5065, 0.4923, 0.528]}, {"w": "more", "b": [0.5001, 0.5065, 0.5444, 0.528]}, {"w": "named", "b": [0.5522, 0.5065, 0.6096, 0.528]}, {"w": "FeatureList", "b": [0.6174, 0.5097, 0.7263, 0.5248]}, {"w": "objects", "b": [0.7341, 0.5065, 0.7923, 0.528]}, {"w": "(e.g.,", "b": [0.8001, 0.5065, 0.8402, 0.528]}, {"w": "a", "b": [0.848, 0.5065, 0.8572, 0.528]}, {"w": "FeatureList", "b": [0.1429, 0.5297, 0.2517, 0.5447]}, {"w": "named", "b": [0.2572, 0.5265, 0.3147, 0.5479]}, {"w": "\"content\"", "b": [0.3202, 0.5297, 0.4092, 0.5447]}, {"w": "and", "b": [0.4147, 0.5265, 0.4463, 0.5479]}, {"w": "another", "b": [0.4518, 0.5265, 0.517, 0.5479]}, {"w": "named", "b": [0.5225, 0.5265, 0.58, 0.5479]}, {"w": "\"comments\").", "b": [0.5855, 0.5265, 0.6964, 0.5479]}, {"w": "Each", "b": [0.7019, 0.5265, 0.7428, 0.5479]}, {"w": "FeatureList", "b": [0.7483, 0.5297, 0.8571, 0.5447]}, {"w": "just", "b": [0.1429, 0.5464, 0.1733, 0.5678]}, {"w": "contains", "b": [0.1782, 0.5464, 0.2488, 0.5678]}, {"w": "a", "b": [0.2537, 0.5464, 0.2628, 0.5678]}, {"w": "list", "b": [0.2678, 0.5464, 0.2926, 0.5678]}, {"w": "of", "b": [0.2976, 0.5464, 0.3144, 0.5678]}, {"w": "Feature", "b": [0.3193, 0.5496, 0.3886, 0.5647]}, {"w": "objects,", "b": [0.3935, 0.5464, 0.4565, 0.5678]}, {"w": "each", "b": [0.4614, 0.5464, 0.4993, 0.5678]}, {"w": "of", "b": [0.5043, 0.5464, 0.5211, 0.5678]}, {"w": "which", "b": [0.526, 0.5464, 0.5769, 0.5678]}, {"w": "may", "b": [0.5818, 0.5464, 0.6172, 0.5678]}, {"w": "be", "b": [0.6222, 0.5464, 0.6416, 0.5678]}, {"w": "a", "b": [0.6465, 0.5464, 0.6557, 0.5678]}, {"w": "list", "b": [0.6606, 0.5464, 0.6855, 0.5678]}, {"w": "of", "b": [0.6904, 0.5464, 0.7072, 0.5678]}, {"w": "byte", "b": [0.7121, 0.5464, 0.7475, 0.5678]}, {"w": "strings,", "b": [0.7524, 0.5464, 0.8133, 0.5678]}, {"w": "a", "b": [0.8182, 0.5464, 0.8274, 0.5678]}, {"w": "list", "b": [0.8323, 0.5464, 0.8572, 0.5678]}, {"w": "of", "b": [0.1429, 0.5664, 0.1597, 0.5878]}, {"w": "64-bit", "b": [0.1658, 0.5664, 0.2157, 0.5878]}, {"w": "integers", "b": [0.2219, 0.5664, 0.2876, 0.5878]}, {"w": "or", "b": [0.2938, 0.5664, 0.3121, 0.5878]}, {"w": "a", "b": [0.3183, 0.5664, 0.3274, 0.5878]}, {"w": "list", "b": [0.3336, 0.5664, 0.3584, 0.5878]}, {"w": "of", "b": [0.3646, 0.5664, 0.3814, 0.5878]}, {"w": "floats", "b": [0.3875, 0.5664, 0.4323, 0.5878]}, {"w": "(in", "b": [0.4385, 0.5664, 0.4626, 0.5878]}, {"w": "this", "b": [0.4688, 0.5664, 0.4995, 0.5878]}, {"w": "example,", "b": [0.5056, 0.5664, 0.5799, 0.5878]}, {"w": "each", "b": [0.5861, 0.5664, 0.624, 0.5878]}, {"w": "Feature", "b": [0.6301, 0.5696, 0.6994, 0.5846]}, {"w": "would", "b": [0.7056, 0.5664, 0.7578, 0.5878]}, {"w": "represent", "b": [0.7639, 0.5664, 0.8419, 0.5878]}, {"w": "a", "b": [0.848, 0.5664, 0.8571, 0.5878]}, {"w": "sentence", "b": [0.1429, 0.5854, 0.2146, 0.6068]}, {"w": "or", "b": [0.2207, 0.5854, 0.2391, 0.6068]}, {"w": "a", "b": [0.2451, 0.5854, 0.2543, 0.6068]}, {"w": "comment,", "b": [0.2603, 0.5854, 0.3449, 0.6068]}, {"w": "perhaps", "b": [0.3509, 0.5854, 0.4169, 0.6068]}, {"w": "in", "b": [0.423, 0.5854, 0.4399, 0.6068]}, {"w": "the", "b": [0.446, 0.5854, 0.4723, 0.6068]}, {"w": "form", "b": [0.4784, 0.5854, 0.52, 0.6068]}, {"w": "of", "b": [0.5261, 0.5854, 0.5429, 0.6068]}, {"w": "a", "b": [0.5489, 0.5854, 0.5581, 0.6068]}, {"w": "list", "b": [0.5642, 0.5854, 0.589, 0.6068]}, {"w": "of", "b": [0.5951, 0.5854, 0.6119, 0.6068]}, {"w": "word", "b": [0.6179, 0.5854, 0.6616, 0.6068]}, {"w": "identifiers).", "b": [0.6676, 0.5854, 0.764, 0.6068]}, {"w": "Building", "b": [0.77, 0.5854, 0.8419, 0.6068]}, {"w": "a", "b": [0.848, 0.5854, 0.8571, 0.6068]}, {"w": "SequenceExample,", "b": [0.1429, 0.6054, 0.296, 0.6268]}, {"w": "serializing", "b": [0.3027, 0.6054, 0.388, 0.6268]}, {"w": "it", "b": [0.3947, 0.6054, 0.4066, 0.6268]}, {"w": "and", "b": [0.4133, 0.6054, 0.4448, 0.6268]}, {"w": "parsing", "b": [0.4515, 0.6054, 0.5137, 0.6268]}, {"w": "it", "b": [0.5203, 0.6054, 0.5323, 0.6268]}, {"w": "is", "b": [0.5389, 0.6054, 0.5521, 0.6268]}, {"w": "very", "b": [0.5588, 0.6054, 0.5952, 0.6268]}, {"w": "similar", "b": [0.6019, 0.6054, 0.6599, 0.6268]}, {"w": "to", "b": [0.6666, 0.6054, 0.6835, 0.6268]}, {"w": "building,", "b": [0.6902, 0.6054, 0.7652, 0.6268]}, {"w": "serializing", "b": [0.7719, 0.6054, 0.8571, 0.6268]}, {"w": "and", "b": [0.1429, 0.6253, 0.1744, 0.6467]}, {"w": "parsing", "b": [0.1839, 0.6253, 0.2461, 0.6467]}, {"w": "an", "b": [0.2556, 0.6253, 0.2762, 0.6467]}, {"w": "Example,", "b": [0.2857, 0.6253, 0.3597, 0.6467]}, {"w": "but", "b": [0.3692, 0.6253, 0.3972, 0.6467]}, {"w": "you", "b": [0.4068, 0.6253, 0.438, 0.6467]}, {"w": "must", "b": [0.4476, 0.6253, 0.4893, 0.6467]}, {"w": "use", "b": [0.4988, 0.6253, 0.5264, 0.6467]}, {"w": "tf.io.parse_single_sequence_exam", "b": [0.5359, 0.6285, 0.8526, 0.6436]}, {"w": "ple()", "b": [0.1429, 0.6484, 0.1923, 0.6635]}, {"w": "to", "b": [0.2005, 0.6453, 0.2175, 0.6667]}, {"w": "parse", "b": [0.2256, 0.6453, 0.2699, 0.6667]}, {"w": "a", "b": [0.2781, 0.6453, 0.2872, 0.6667]}, {"w": "single", "b": [0.2954, 0.6453, 0.3439, 0.6667]}, {"w": "SequenceExample", "b": [0.352, 0.6484, 0.5005, 0.6635]}, {"w": "or", "b": [0.5086, 0.6453, 0.527, 0.6667]}, {"w": "tf.io.parse_sequence_example()", "b": [0.5351, 0.6484, 0.832, 0.6635]}, {"w": "to", "b": [0.8402, 0.6453, 0.8571, 0.6667]}, {"w": "parse", "b": [0.1429, 0.6643, 0.1872, 0.6857]}, {"w": "a", "b": [0.1929, 0.6643, 0.202, 0.6857]}, {"w": "batch,", "b": [0.2077, 0.6643, 0.2581, 0.6857]}, {"w": "and", "b": [0.2638, 0.6643, 0.2954, 0.6857]}, {"w": "both", "b": [0.3011, 0.6643, 0.3398, 0.6857]}, {"w": "functions", "b": [0.3455, 0.6643, 0.4246, 0.6857]}, {"w": "return", "b": [0.4303, 0.6643, 0.4834, 0.6857]}, {"w": "a", "b": [0.4891, 0.6643, 0.4983, 0.6857]}, {"w": "tuple", "b": [0.504, 0.6643, 0.5464, 0.6857]}, {"w": "containing", "b": [0.5522, 0.6643, 0.6418, 0.6857]}, {"w": "the", "b": [0.6475, 0.6643, 0.6739, 0.6857]}, {"w": "context", "b": [0.6796, 0.6643, 0.7414, 0.6857]}, {"w": "features", "b": [0.7471, 0.6643, 0.8126, 0.6857]}, {"w": "(as", "b": [0.8183, 0.6643, 0.8423, 0.6857]}, {"w": "a", "b": [0.848, 0.6643, 0.8572, 0.6857]}, {"w": "dictionary)", "b": [0.1429, 0.6833, 0.2365, 0.7048]}, {"w": "and", "b": [0.2454, 0.6833, 0.2769, 0.7048]}, {"w": "the", "b": [0.2858, 0.6833, 0.3121, 0.7048]}, {"w": "feature", "b": [0.321, 0.6833, 0.3788, 0.7048]}, {"w": "lists", "b": [0.3877, 0.6833, 0.4202, 0.7048]}, {"w": "(also", "b": [0.4291, 0.6833, 0.469, 0.7048]}, {"w": "as", "b": [0.4778, 0.6833, 0.4946, 0.7048]}, {"w": "a", "b": [0.5035, 0.6833, 0.5127, 0.7048]}, {"w": "dictionary).", "b": [0.5216, 0.6833, 0.6199, 0.7048]}, {"w": "If", "b": [0.6288, 0.6833, 0.6421, 0.7048]}, {"w": "the", "b": [0.651, 0.6833, 0.6773, 0.7048]}, {"w": "feature", "b": [0.6862, 0.6833, 0.744, 0.7048]}, {"w": "lists", "b": [0.7528, 0.6833, 0.7853, 0.7048]}, {"w": "contain", "b": [0.7942, 0.6833, 0.8571, 0.7048]}, {"w": "sequences", "b": [0.1429, 0.7024, 0.2266, 0.7238]}, {"w": "of", "b": [0.2326, 0.7024, 0.2494, 0.7238]}, {"w": "varying", "b": [0.2553, 0.7024, 0.3188, 0.7238]}, {"w": "sizes", "b": [0.3247, 0.7024, 0.3632, 0.7238]}, {"w": "(as", "b": [0.3692, 0.7024, 0.3932, 0.7238]}, {"w": "in", "b": [0.3991, 0.7024, 0.4161, 0.7238]}, {"w": "the", "b": [0.422, 0.7024, 0.4484, 0.7238]}, {"w": "example", "b": [0.4543, 0.7024, 0.5239, 0.7238]}, {"w": "above),", "b": [0.5298, 0.7024, 0.5907, 0.7238]}, {"w": "you", "b": [0.5966, 0.7024, 0.6279, 0.7238]}, {"w": "may", "b": [0.6338, 0.7024, 0.6692, 0.7238]}, {"w": "want", "b": [0.6752, 0.7024, 0.7159, 0.7238]}, {"w": "to", "b": [0.7219, 0.7024, 0.7389, 0.7238]}, {"w": "convert", "b": [0.7448, 0.7024, 0.8078, 0.7238]}, {"w": "them", "b": [0.8137, 0.7024, 0.8571, 0.7238]}, {"w": "to", "b": [0.1429, 0.7223, 0.1598, 0.7438]}, {"w": "ragged", "b": [0.1664, 0.7223, 0.2227, 0.7438]}, {"w": "tensors", "b": [0.2292, 0.7223, 0.2895, 0.7438]}, {"w": "using", "b": [0.2961, 0.7223, 0.3415, 0.7438]}, {"w": "tf.RaggedTensor.from_sparse()", "b": [0.3481, 0.7255, 0.6351, 0.7406]}, {"w": "(see", "b": [0.6417, 0.7223, 0.6742, 0.7438]}, {"w": "the", "b": [0.6808, 0.7223, 0.7071, 0.7438]}, {"w": "notebook", "b": [0.7137, 0.7223, 0.7931, 0.7438]}, {"w": "for", "b": [0.7997, 0.7223, 0.8242, 0.7438]}, {"w": "the", "b": [0.8308, 0.7223, 0.8572, 0.7438]}, {"w": "full", "b": [0.1429, 0.7414, 0.1706, 0.7628]}, {"w": "code):", "b": [0.1754, 0.7414, 0.2266, 0.7628]}]}, {"id": "b_6", "type": "paragraph", "text": "parsed_context, parsed_feature_lists = tf.io.parse_single_sequence_example( serialized_sequence_example, context_feature_descriptions, sequence_feature_descriptions) parsed_content = tf.RaggedTensor.from_sparse(parsed_feature_lists[\"content\"])", "words": [{"w": "parsed_context,", "b": [0.1766, 0.7734, 0.3031, 0.7862]}, {"w": "parsed_feature_lists", "b": [0.3115, 0.7734, 0.4802, 0.7862]}, {"w": "=", "b": [0.4886, 0.7734, 0.497, 0.7862]}, {"w": "tf.io.parse_single_sequence_example(", "b": [0.5055, 0.7734, 0.809, 0.7862]}, {"w": "serialized_sequence_example,", "b": [0.2103, 0.7888, 0.4464, 0.8016]}, {"w": "context_feature_descriptions,", "b": [0.4549, 0.7888, 0.6994, 0.8016]}, {"w": "sequence_feature_descriptions)", "b": [0.2103, 0.8042, 0.4633, 0.8171]}, {"w": "parsed_content", "b": [0.1766, 0.8196, 0.2946, 0.8325]}, {"w": "=", "b": [0.3031, 0.8196, 0.3115, 0.8325]}, {"w": "tf.RaggedTensor.from_sparse(parsed_feature_lists[\"content\"])", "b": [0.3199, 0.8196, 0.8259, 0.8325]}]}, {"id": "b_7", "type": "paragraph", "text": "Now that you know how to efficiently store, load and parse data, the next step is to prepare it so that it can be fed to a neural network. This means converting all features", "words": [{"w": "Now", "b": [0.1429, 0.8403, 0.1827, 0.8617]}, {"w": "that", "b": [0.1892, 0.8403, 0.2218, 0.8617]}, {"w": "you", "b": [0.2283, 0.8403, 0.2596, 0.8617]}, {"w": "know", "b": [0.2661, 0.8403, 0.3127, 0.8617]}, {"w": "how", "b": [0.3192, 0.8403, 0.3552, 0.8617]}, {"w": "to", "b": [0.3617, 0.8403, 0.3787, 0.8617]}, {"w": "efficiently", "b": [0.3852, 0.8403, 0.4674, 0.8617]}, {"w": "store,", "b": [0.474, 0.8403, 0.5199, 0.8617]}, {"w": "load", "b": [0.5264, 0.8403, 0.5625, 0.8617]}, {"w": "and", "b": [0.569, 0.8403, 0.6005, 0.8617]}, {"w": "parse", "b": [0.607, 0.8403, 0.6513, 0.8617]}, {"w": "data,", "b": [0.6578, 0.8403, 0.6978, 0.8617]}, {"w": "the", "b": [0.7043, 0.8403, 0.7307, 0.8617]}, {"w": "next", "b": [0.7372, 0.8403, 0.7736, 0.8617]}, {"w": "step", "b": [0.7801, 0.8403, 0.8139, 0.8617]}, {"w": "is", "b": [0.8204, 0.8403, 0.8337, 0.8617]}, {"w": "to", "b": [0.8402, 0.8403, 0.8571, 0.8617]}, {"w": "prepare", "b": [0.1429, 0.8593, 0.207, 0.8807]}, {"w": "it", "b": [0.2121, 0.8593, 0.224, 0.8807]}, {"w": "so", "b": [0.229, 0.8593, 0.2473, 0.8807]}, {"w": "that", "b": [0.2523, 0.8593, 0.2849, 0.8807]}, {"w": "it", "b": [0.29, 0.8593, 0.3019, 0.8807]}, {"w": "can", "b": [0.3069, 0.8593, 0.3363, 0.8807]}, {"w": "be", "b": [0.3413, 0.8593, 0.3608, 0.8807]}, {"w": "fed", "b": [0.3658, 0.8593, 0.3918, 0.8807]}, {"w": "to", "b": [0.3969, 0.8593, 0.4138, 0.8807]}, {"w": "a", "b": [0.4189, 0.8593, 0.428, 0.8807]}, {"w": "neural", "b": [0.4331, 0.8593, 0.4865, 0.8807]}, {"w": "network.", "b": [0.4916, 0.8593, 0.5659, 0.8807]}, {"w": "This", "b": [0.5709, 0.8593, 0.6081, 0.8807]}, {"w": "means", "b": [0.6132, 0.8593, 0.6673, 0.8807]}, {"w": "converting", "b": [0.6723, 0.8593, 0.762, 0.8807]}, {"w": "all", "b": [0.767, 0.8593, 0.7867, 0.8807]}, {"w": "features", "b": [0.7917, 0.8593, 0.8572, 0.8807]}]}, {"id": "b_8", "type": "paragraph", "text": "The TFRecord Format | 419", "words": [{"w": "The", "b": [0.6723, 0.9225, 0.6938, 0.9388]}, {"w": "TFRecord", "b": [0.6967, 0.9225, 0.7503, 0.9388]}, {"w": "Format", "b": [0.7532, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "419", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 446, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "into numerical features (ideally not too sparse), scaling them, and more. In particular, if your data contains categorical features or text features, they need to be converted to numbers. For this, the Features API can help.", "words": [{"w": "into", "b": [0.1429, 0.0791, 0.1764, 0.1005]}, {"w": "numerical", "b": [0.1813, 0.0791, 0.2659, 0.1005]}, {"w": "features", "b": [0.2708, 0.0791, 0.3362, 0.1005]}, {"w": "(ideally", "b": [0.3411, 0.0791, 0.403, 0.1005]}, {"w": "not", "b": [0.4079, 0.0791, 0.4363, 0.1005]}, {"w": "too", "b": [0.4412, 0.0791, 0.4688, 0.1005]}, {"w": "sparse),", "b": [0.4737, 0.0791, 0.5376, 0.1005]}, {"w": "scaling", "b": [0.5426, 0.0791, 0.6002, 0.1005]}, {"w": "them,", "b": [0.6051, 0.0791, 0.6532, 0.1005]}, {"w": "and", "b": [0.6581, 0.0791, 0.6897, 0.1005]}, {"w": "more.", "b": [0.6946, 0.0791, 0.7436, 0.1005]}, {"w": "In", "b": [0.7485, 0.0791, 0.767, 0.1005]}, {"w": "particular,", "b": [0.772, 0.0791, 0.8571, 0.1005]}, {"w": "if", "b": [0.1429, 0.0981, 0.1546, 0.1195]}, {"w": "your", "b": [0.1596, 0.0981, 0.1986, 0.1195]}, {"w": "data", "b": [0.2037, 0.0981, 0.2389, 0.1195]}, {"w": "contains", "b": [0.2439, 0.0981, 0.3145, 0.1195]}, {"w": "categorical", "b": [0.3195, 0.0981, 0.4092, 0.1195]}, {"w": "features", "b": [0.4143, 0.0981, 0.4797, 0.1195]}, {"w": "or", "b": [0.4847, 0.0981, 0.5031, 0.1195]}, {"w": "text", "b": [0.5081, 0.0981, 0.5395, 0.1195]}, {"w": "features,", "b": [0.5446, 0.0981, 0.6147, 0.1195]}, {"w": "they", "b": [0.6198, 0.0981, 0.6557, 0.1195]}, {"w": "need", "b": [0.6607, 0.0981, 0.7008, 0.1195]}, {"w": "to", "b": [0.7058, 0.0981, 0.7228, 0.1195]}, {"w": "be", "b": [0.7279, 0.0981, 0.7473, 0.1195]}, {"w": "converted", "b": [0.7523, 0.0981, 0.8351, 0.1195]}, {"w": "to", "b": [0.8402, 0.0981, 0.8571, 0.1195]}, {"w": "numbers.", "b": [0.1429, 0.1172, 0.2216, 0.1386]}, {"w": "For", "b": [0.2263, 0.1172, 0.2553, 0.1386]}, {"w": "this,", "b": [0.26, 0.1172, 0.2954, 0.1386]}, {"w": "the", "b": [0.3002, 0.1172, 0.3265, 0.1386]}, {"w": "Features", "b": [0.3312, 0.117, 0.399, 0.1386]}, {"w": "API", "b": [0.4037, 0.117, 0.4358, 0.1386]}, {"w": "can", "b": [0.4406, 0.1172, 0.4699, 0.1386]}, {"w": "help.", "b": [0.4746, 0.1172, 0.5149, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "The Features API", "words": [{"w": "The", "b": [0.1429, 0.1516, 0.1881, 0.1858]}, {"w": "Features", "b": [0.194, 0.1516, 0.301, 0.1858]}, {"w": "API", "b": [0.3069, 0.1516, 0.3484, 0.1858]}]}, {"id": "b_2", "type": "paragraph", "text": "Preprocessing your data can be performed in many ways: it can be done ahead of time when preparing your data files, using any tool you like. Or you can preprocess your data on the fly when loading it with the Data API (e.g., using the dataset’s map() method, as we saw earlier). Or you can include a preprocessing layer directly in your model. Whichever solution you prefer, the Features API can help you: it is a set of functions available in the tf.feature_column package, which let you define how each feature (or group of features) in your data should be preprocessed (therefore you can think of this API as the analog of Scikit-Learn’s ColumnTransformer class). We will start by looking at the different types of columns available, and then we will look at how to use them.", "words": [{"w": "Preprocessing", "b": [0.1429, 0.1927, 0.2601, 0.2142]}, {"w": "your", "b": [0.2678, 0.1927, 0.3068, 0.2142]}, {"w": "data", "b": [0.3145, 0.1927, 0.3498, 0.2142]}, {"w": "can", "b": [0.3574, 0.1927, 0.3868, 0.2142]}, {"w": "be", "b": [0.3945, 0.1927, 0.4139, 0.2142]}, {"w": "performed", "b": [0.4216, 0.1927, 0.5106, 0.2142]}, {"w": "in", "b": [0.5183, 0.1927, 0.5352, 0.2142]}, {"w": "many", "b": [0.5429, 0.1927, 0.5896, 0.2142]}, {"w": "ways:", "b": [0.5973, 0.1927, 0.6423, 0.2142]}, {"w": "it", "b": [0.65, 0.1927, 0.6619, 0.2142]}, {"w": "can", "b": [0.6696, 0.1927, 0.699, 0.2142]}, {"w": "be", "b": [0.7067, 0.1927, 0.7261, 0.2142]}, {"w": "done", "b": [0.7338, 0.1927, 0.7757, 0.2142]}, {"w": "ahead", "b": [0.7834, 0.1927, 0.8327, 0.2142]}, {"w": "of", "b": [0.8404, 0.1927, 0.8572, 0.2142]}, {"w": "time", "b": [0.1429, 0.2118, 0.1807, 0.2332]}, {"w": "when", "b": [0.187, 0.2118, 0.2327, 0.2332]}, {"w": "preparing", "b": [0.239, 0.2118, 0.321, 0.2332]}, {"w": "your", "b": [0.3274, 0.2118, 0.3664, 0.2332]}, {"w": "data", "b": [0.3727, 0.2118, 0.4079, 0.2332]}, {"w": "files,", "b": [0.4143, 0.2118, 0.4525, 0.2332]}, {"w": "using", "b": [0.4589, 0.2118, 0.5043, 0.2332]}, {"w": "any", "b": [0.5106, 0.2118, 0.5403, 0.2332]}, {"w": "tool", "b": [0.5466, 0.2118, 0.5795, 0.2332]}, {"w": "you", "b": [0.5858, 0.2118, 0.6171, 0.2332]}, {"w": "like.", "b": [0.6234, 0.2118, 0.6582, 0.2332]}, {"w": "Or", "b": [0.6645, 0.2118, 0.6878, 0.2332]}, {"w": "you", "b": [0.6941, 0.2118, 0.7254, 0.2332]}, {"w": "can", "b": [0.7317, 0.2118, 0.7611, 0.2332]}, {"w": "preprocess", "b": [0.7674, 0.2118, 0.8571, 0.2332]}, {"w": "your", "b": [0.1429, 0.2317, 0.1818, 0.2531]}, {"w": "data", "b": [0.1871, 0.2317, 0.2224, 0.2531]}, {"w": "on", "b": [0.2277, 0.2317, 0.2497, 0.2531]}, {"w": "the", "b": [0.255, 0.2317, 0.2813, 0.2531]}, {"w": "fly", "b": [0.2866, 0.2317, 0.3076, 0.2531]}, {"w": "when", "b": [0.3129, 0.2317, 0.3586, 0.2531]}, {"w": "loading", "b": [0.3639, 0.2317, 0.4266, 0.2531]}, {"w": "it", "b": [0.4319, 0.2317, 0.4439, 0.2531]}, {"w": "with", "b": [0.4492, 0.2317, 0.4865, 0.2531]}, {"w": "the", "b": [0.4918, 0.2317, 0.5181, 0.2531]}, {"w": "Data", "b": [0.5234, 0.2317, 0.563, 0.2531]}, {"w": "API", "b": [0.5683, 0.2317, 0.6015, 0.2531]}, {"w": "(e.g.,", "b": [0.6068, 0.2317, 0.6469, 0.2531]}, {"w": "using", "b": [0.6521, 0.2317, 0.6976, 0.2531]}, {"w": "the", "b": [0.7029, 0.2317, 0.7292, 0.2531]}, {"w": "dataset’s", "b": [0.7345, 0.2317, 0.8024, 0.2531]}, {"w": "map()", "b": [0.8077, 0.2349, 0.8571, 0.25]}, {"w": "method,", "b": [0.1428, 0.2508, 0.2126, 0.2722]}, {"w": "as", "b": [0.2182, 0.2508, 0.235, 0.2722]}, {"w": "we", "b": [0.2406, 0.2508, 0.2637, 0.2722]}, {"w": "saw", "b": [0.2692, 0.2508, 0.2999, 0.2722]}, {"w": "earlier).", "b": [0.3055, 0.2508, 0.3706, 0.2722]}, {"w": "Or", "b": [0.3762, 0.2508, 0.3995, 0.2722]}, {"w": "you", "b": [0.4051, 0.2508, 0.4363, 0.2722]}, {"w": "can", "b": [0.4419, 0.2508, 0.4712, 0.2722]}, {"w": "include", "b": [0.4768, 0.2508, 0.5388, 0.2722]}, {"w": "a", "b": [0.5444, 0.2508, 0.5535, 0.2722]}, {"w": "preprocessing", "b": [0.5591, 0.2508, 0.6755, 0.2722]}, {"w": "layer", "b": [0.6811, 0.2508, 0.7213, 0.2722]}, {"w": "directly", "b": [0.7269, 0.2508, 0.79, 0.2722]}, {"w": "in", "b": [0.7956, 0.2508, 0.8126, 0.2722]}, {"w": "your", "b": [0.8182, 0.2508, 0.8571, 0.2722]}, {"w": "model.", "b": [0.1429, 0.2698, 0.2004, 0.2912]}, {"w": "Whichever", "b": [0.2075, 0.2698, 0.2995, 0.2912]}, {"w": "solution", "b": [0.3066, 0.2698, 0.3751, 0.2912]}, {"w": "you", "b": [0.3822, 0.2698, 0.4135, 0.2912]}, {"w": "prefer,", "b": [0.4206, 0.2698, 0.4742, 0.2912]}, {"w": "the", "b": [0.4813, 0.2698, 0.5077, 0.2912]}, {"w": "Features", "b": [0.5148, 0.2698, 0.5846, 0.2912]}, {"w": "API", "b": [0.5917, 0.2698, 0.6249, 0.2912]}, {"w": "can", "b": [0.632, 0.2698, 0.6614, 0.2912]}, {"w": "help", "b": [0.6685, 0.2698, 0.7047, 0.2912]}, {"w": "you:", "b": [0.7117, 0.2698, 0.7477, 0.2912]}, {"w": "it", "b": [0.7548, 0.2698, 0.7668, 0.2912]}, {"w": "is", "b": [0.7739, 0.2698, 0.7871, 0.2912]}, {"w": "a", "b": [0.7942, 0.2698, 0.8033, 0.2912]}, {"w": "set", "b": [0.8104, 0.2698, 0.8333, 0.2912]}, {"w": "of", "b": [0.8404, 0.2698, 0.8571, 0.2912]}, {"w": "functions", "b": [0.1429, 0.2898, 0.2219, 0.3112]}, {"w": "available", "b": [0.2308, 0.2898, 0.3031, 0.3112]}, {"w": "in", "b": [0.312, 0.2898, 0.329, 0.3112]}, {"w": "the", "b": [0.3379, 0.2898, 0.3642, 0.3112]}, {"w": "tf.feature_column", "b": [0.3732, 0.293, 0.5414, 0.308]}, {"w": "package,", "b": [0.5503, 0.2898, 0.622, 0.3112]}, {"w": "which", "b": [0.6309, 0.2898, 0.6819, 0.3112]}, {"w": "let", "b": [0.6908, 0.2898, 0.7113, 0.3112]}, {"w": "you", "b": [0.7202, 0.2898, 0.7514, 0.3112]}, {"w": "define", "b": [0.7603, 0.2898, 0.8122, 0.3112]}, {"w": "how", "b": [0.8211, 0.2898, 0.8571, 0.3112]}, {"w": "each", "b": [0.1428, 0.3088, 0.1808, 0.3302]}, {"w": "feature", "b": [0.1855, 0.3088, 0.2433, 0.3302]}, {"w": "(or", "b": [0.248, 0.3088, 0.2736, 0.3302]}, {"w": "group", "b": [0.2783, 0.3088, 0.3284, 0.3302]}, {"w": "of", "b": [0.3331, 0.3088, 0.3499, 0.3302]}, {"w": "features)", "b": [0.3546, 0.3088, 0.4273, 0.3302]}, {"w": "in", "b": [0.432, 0.3088, 0.449, 0.3302]}, {"w": "your", "b": [0.4537, 0.3088, 0.4927, 0.3302]}, {"w": "data", "b": [0.4974, 0.3088, 0.5327, 0.3302]}, {"w": "should", "b": [0.5374, 0.3088, 0.5941, 0.3302]}, {"w": "be", "b": [0.5988, 0.3088, 0.6183, 0.3302]}, {"w": "preprocessed", "b": [0.623, 0.3088, 0.7326, 0.3302]}, {"w": "(therefore", "b": [0.7373, 0.3088, 0.8208, 0.3302]}, {"w": "you", "b": [0.8256, 0.3088, 0.8568, 0.3302]}, {"w": "can", "b": [0.1428, 0.3288, 0.1722, 0.3502]}, {"w": "think", "b": [0.1795, 0.3288, 0.2243, 0.3502]}, {"w": "of", "b": [0.2316, 0.3288, 0.2484, 0.3502]}, {"w": "this", "b": [0.2557, 0.3288, 0.2864, 0.3502]}, {"w": "API", "b": [0.2937, 0.3288, 0.3269, 0.3502]}, {"w": "as", "b": [0.3342, 0.3288, 0.351, 0.3502]}, {"w": "the", "b": [0.3583, 0.3288, 0.3846, 0.3502]}, {"w": "analog", "b": [0.3919, 0.3288, 0.4472, 0.3502]}, {"w": "of", "b": [0.4545, 0.3288, 0.4713, 0.3502]}, {"w": "Scikit-Learn’s", "b": [0.4786, 0.3288, 0.5895, 0.3502]}, {"w": "ColumnTransformer", "b": [0.5968, 0.3319, 0.765, 0.347]}, {"w": "class).", "b": [0.7723, 0.3288, 0.8228, 0.3502]}, {"w": "We", "b": [0.8301, 0.3288, 0.8571, 0.3502]}, {"w": "will", "b": [0.1429, 0.3478, 0.1733, 0.3692]}, {"w": "start", "b": [0.1787, 0.3478, 0.2159, 0.3692]}, {"w": "by", "b": [0.2213, 0.3478, 0.2415, 0.3692]}, {"w": "looking", "b": [0.2469, 0.3478, 0.3104, 0.3692]}, {"w": "at", "b": [0.3159, 0.3478, 0.331, 0.3692]}, {"w": "the", "b": [0.3364, 0.3478, 0.3627, 0.3692]}, {"w": "different", "b": [0.3681, 0.3478, 0.4398, 0.3692]}, {"w": "types", "b": [0.4452, 0.3478, 0.4886, 0.3692]}, {"w": "of", "b": [0.494, 0.3478, 0.5108, 0.3692]}, {"w": "columns", "b": [0.5162, 0.3478, 0.588, 0.3692]}, {"w": "available,", "b": [0.5934, 0.3478, 0.6705, 0.3692]}, {"w": "and", "b": [0.6759, 0.3478, 0.7074, 0.3692]}, {"w": "then", "b": [0.7128, 0.3478, 0.7506, 0.3692]}, {"w": "we", "b": [0.756, 0.3478, 0.7791, 0.3692]}, {"w": "will", "b": [0.7845, 0.3478, 0.8149, 0.3692]}, {"w": "look", "b": [0.8203, 0.3478, 0.8572, 0.3692]}, {"w": "at", "b": [0.1429, 0.3669, 0.158, 0.3883]}, {"w": "how", "b": [0.1627, 0.3669, 0.1987, 0.3883]}, {"w": "to", "b": [0.2034, 0.3669, 0.2204, 0.3883]}, {"w": "use", "b": [0.2252, 0.3669, 0.2527, 0.3883]}, {"w": "them.", "b": [0.2574, 0.3669, 0.3056, 0.3883]}]}, {"id": "b_3", "type": "paragraph", "text": "Let’s go back to the variant of the California housing dataset that we used in Chap‐ ter 2, since it includes a categorical feature and missing data. Here is a simple numeri‐ cal column named \"housing_median_age\":", "words": [{"w": "Let’s", "b": [0.1429, 0.395, 0.179, 0.4164]}, {"w": "go", "b": [0.1857, 0.395, 0.2061, 0.4164]}, {"w": "back", "b": [0.2128, 0.395, 0.2517, 0.4164]}, {"w": "to", "b": [0.2584, 0.395, 0.2754, 0.4164]}, {"w": "the", "b": [0.2821, 0.395, 0.3084, 0.4164]}, {"w": "variant", "b": [0.3152, 0.395, 0.3738, 0.4164]}, {"w": "of", "b": [0.3805, 0.395, 0.3973, 0.4164]}, {"w": "the", "b": [0.404, 0.395, 0.4303, 0.4164]}, {"w": "California", "b": [0.437, 0.395, 0.5215, 0.4164]}, {"w": "housing", "b": [0.5283, 0.395, 0.5954, 0.4164]}, {"w": "dataset", "b": [0.6022, 0.395, 0.6603, 0.4164]}, {"w": "that", "b": [0.667, 0.395, 0.6996, 0.4164]}, {"w": "we", "b": [0.7063, 0.395, 0.7294, 0.4164]}, {"w": "used", "b": [0.7361, 0.395, 0.7747, 0.4164]}, {"w": "in", "b": [0.7814, 0.395, 0.7984, 0.4164]}, {"w": "Chap‐", "b": [0.8051, 0.395, 0.8571, 0.4164]}, {"w": "ter", "b": [0.1429, 0.414, 0.1658, 0.4354]}, {"w": "2,", "b": [0.1705, 0.414, 0.1854, 0.4354]}, {"w": "since", "b": [0.1903, 0.414, 0.2326, 0.4354]}, {"w": "it", "b": [0.2374, 0.414, 0.2494, 0.4354]}, {"w": "includes", "b": [0.2543, 0.414, 0.3239, 0.4354]}, {"w": "a", "b": [0.3287, 0.414, 0.3379, 0.4354]}, {"w": "categorical", "b": [0.3428, 0.414, 0.4324, 0.4354]}, {"w": "feature", "b": [0.4373, 0.414, 0.4951, 0.4354]}, {"w": "and", "b": [0.5, 0.414, 0.5315, 0.4354]}, {"w": "missing", "b": [0.5364, 0.414, 0.601, 0.4354]}, {"w": "data.", "b": [0.6059, 0.414, 0.6459, 0.4354]}, {"w": "Here", "b": [0.6508, 0.414, 0.6916, 0.4354]}, {"w": "is", "b": [0.6965, 0.414, 0.7097, 0.4354]}, {"w": "a", "b": [0.7146, 0.414, 0.7238, 0.4354]}, {"w": "simple", "b": [0.7286, 0.414, 0.7836, 0.4354]}, {"w": "numeri‐", "b": [0.7884, 0.414, 0.8571, 0.4354]}, {"w": "cal", "b": [0.1429, 0.434, 0.1661, 0.4554]}, {"w": "column", "b": [0.1708, 0.434, 0.235, 0.4554]}, {"w": "named", "b": [0.2398, 0.434, 0.2972, 0.4554]}, {"w": "\"housing_median_age\":", "b": [0.302, 0.434, 0.5046, 0.4554]}]}, {"id": "b_4", "type": "equation", "text": "housing_median_age = tf.feature_column.numeric_column(\"housing_median_age\")", "words": [{"w": "housing_median_age", "b": [0.1766, 0.4659, 0.3284, 0.4788]}, {"w": "=", "b": [0.3368, 0.4659, 0.3452, 0.4788]}, {"w": "tf.feature_column.numeric_column(\"housing_median_age\")", "b": [0.3537, 0.4659, 0.809, 0.4788]}]}, {"id": "b_5", "type": "paragraph", "text": "Numeric columns let you specify a normalization function using the normalizer_fn argument. For example, let’s tweak the \"housing_median_age\" column to define how it should be scaled. Note that this requires computing ahead of time the mean and standard deviation of this feature in the training set:", "words": [{"w": "Numeric", "b": [0.1429, 0.4875, 0.2167, 0.5089]}, {"w": "columns", "b": [0.2227, 0.4875, 0.2946, 0.5089]}, {"w": "let", "b": [0.3005, 0.4875, 0.321, 0.5089]}, {"w": "you", "b": [0.327, 0.4875, 0.3582, 0.5089]}, {"w": "specify", "b": [0.3642, 0.4875, 0.4221, 0.5089]}, {"w": "a", "b": [0.4281, 0.4875, 0.4372, 0.5089]}, {"w": "normalization", "b": [0.4432, 0.4875, 0.5614, 0.5089]}, {"w": "function", "b": [0.5674, 0.4875, 0.6388, 0.5089]}, {"w": "using", "b": [0.6448, 0.4875, 0.6902, 0.5089]}, {"w": "the", "b": [0.6962, 0.4875, 0.7225, 0.5089]}, {"w": "normalizer_fn", "b": [0.7285, 0.4907, 0.8571, 0.5057]}, {"w": "argument.", "b": [0.1428, 0.5074, 0.2286, 0.5288]}, {"w": "For", "b": [0.2338, 0.5074, 0.2628, 0.5288]}, {"w": "example,", "b": [0.2681, 0.5074, 0.3424, 0.5288]}, {"w": "let’s", "b": [0.3477, 0.5074, 0.3779, 0.5288]}, {"w": "tweak", "b": [0.3832, 0.5074, 0.4321, 0.5288]}, {"w": "the", "b": [0.4374, 0.5074, 0.4637, 0.5288]}, {"w": "\"housing_median_age\"", "b": [0.469, 0.5106, 0.6669, 0.5257]}, {"w": "column", "b": [0.6722, 0.5074, 0.7365, 0.5288]}, {"w": "to", "b": [0.7417, 0.5074, 0.7587, 0.5288]}, {"w": "define", "b": [0.764, 0.5074, 0.8158, 0.5288]}, {"w": "how", "b": [0.8211, 0.5074, 0.8571, 0.5288]}, {"w": "it", "b": [0.1429, 0.5265, 0.1548, 0.5479]}, {"w": "should", "b": [0.1619, 0.5265, 0.2186, 0.5479]}, {"w": "be", "b": [0.2257, 0.5265, 0.2451, 0.5479]}, {"w": "scaled.", "b": [0.2522, 0.5265, 0.3077, 0.5479]}, {"w": "Note", "b": [0.3148, 0.5265, 0.3555, 0.5479]}, {"w": "that", "b": [0.3626, 0.5265, 0.3952, 0.5479]}, {"w": "this", "b": [0.4023, 0.5265, 0.433, 0.5479]}, {"w": "requires", "b": [0.4401, 0.5265, 0.5082, 0.5479]}, {"w": "computing", "b": [0.5153, 0.5265, 0.6064, 0.5479]}, {"w": "ahead", "b": [0.6135, 0.5265, 0.6628, 0.5479]}, {"w": "of", "b": [0.6698, 0.5265, 0.6866, 0.5479]}, {"w": "time", "b": [0.6937, 0.5265, 0.7316, 0.5479]}, {"w": "the", "b": [0.7387, 0.5265, 0.765, 0.5479]}, {"w": "mean", "b": [0.7721, 0.5265, 0.8185, 0.5479]}, {"w": "and", "b": [0.8256, 0.5265, 0.8571, 0.5479]}, {"w": "standard", "b": [0.1428, 0.5455, 0.2163, 0.5669]}, {"w": "deviation", "b": [0.221, 0.5455, 0.2988, 0.5669]}, {"w": "of", "b": [0.3035, 0.5455, 0.3203, 0.5669]}, {"w": "this", "b": [0.325, 0.5455, 0.3557, 0.5669]}, {"w": "feature", "b": [0.3605, 0.5455, 0.4182, 0.5669]}, {"w": "in", "b": [0.423, 0.5455, 0.44, 0.5669]}, {"w": "the", "b": [0.4447, 0.5455, 0.471, 0.5669]}, {"w": "training", "b": [0.4757, 0.5455, 0.5427, 0.5669]}, {"w": "set:", "b": [0.5474, 0.5455, 0.575, 0.5669]}]}, {"id": "b_6", "type": "paragraph", "text": "age_mean, age_std = X_mean[1], X_std[1] # The median age is column in 1 housing_median_age = tf.feature_column.numeric_column( \"housing_median_age\", normalizer_fn=lambda x: (x - age_mean) / age_std)", "words": [{"w": "age_mean,", "b": [0.1766, 0.5775, 0.2525, 0.5903]}, {"w": "age_std", "b": [0.2609, 0.5775, 0.3199, 0.5903]}, {"w": "=", "b": [0.3284, 0.5775, 0.3368, 0.5903]}, {"w": "X_mean[1],", "b": [0.3452, 0.5775, 0.4296, 0.5903]}, {"w": "X_std[1]", "b": [0.438, 0.5775, 0.5054, 0.5903]}, {"w": "#", "b": [0.5223, 0.5775, 0.5307, 0.5903]}, {"w": "The", "b": [0.5392, 0.5775, 0.5645, 0.5903]}, {"w": "median", "b": [0.5729, 0.5775, 0.6235, 0.5903]}, {"w": "age", "b": [0.6319, 0.5775, 0.6572, 0.5903]}, {"w": "is", "b": [0.6657, 0.5775, 0.6825, 0.5903]}, {"w": "column", "b": [0.691, 0.5775, 0.7416, 0.5903]}, {"w": "in", "b": [0.75, 0.5775, 0.7669, 0.5903]}, {"w": "1", "b": [0.7753, 0.5775, 0.7837, 0.5903]}, {"w": "housing_median_age", "b": [0.1766, 0.5929, 0.3284, 0.6058]}, {"w": "=", "b": [0.3368, 0.5929, 0.3452, 0.6058]}, {"w": "tf.feature_column.numeric_column(", "b": [0.3537, 0.5929, 0.6319, 0.6058]}, {"w": "\"housing_median_age\",", "b": [0.2103, 0.6083, 0.3874, 0.6212]}, {"w": "normalizer_fn=lambda", "b": [0.3958, 0.6083, 0.5645, 0.6212]}, {"w": "x:", "b": [0.5729, 0.6083, 0.5898, 0.6212]}, {"w": "(x", "b": [0.5982, 0.6083, 0.6151, 0.6212]}, {"w": "-", "b": [0.6235, 0.6083, 0.6319, 0.6212]}, {"w": "age_mean)", "b": [0.6404, 0.6083, 0.7163, 0.6212]}, {"w": "/", "b": [0.7247, 0.6083, 0.7331, 0.6212]}, {"w": "age_std)", "b": [0.7416, 0.6083, 0.809, 0.6212]}]}, {"id": "b_7", "type": "paragraph", "text": "In some cases, it might improve performance to bucketize some numerical features, effectively transforming a numerical feature into a categorical feature. For example, let’s create a bucketized column based on the median_income column, with 5 buckets: less than 1.5 ($15,000), then 1.5 to 3, 3 to 4.5, 4.5 to 6., and above 6. (notice that when you specify 4 boundaries, there are actually 5 buckets):", "words": [{"w": "In", "b": [0.1429, 0.629, 0.1614, 0.6504]}, {"w": "some", "b": [0.1678, 0.629, 0.212, 0.6504]}, {"w": "cases,", "b": [0.2184, 0.629, 0.2653, 0.6504]}, {"w": "it", "b": [0.2718, 0.629, 0.2837, 0.6504]}, {"w": "might", "b": [0.2901, 0.629, 0.3396, 0.6504]}, {"w": "improve", "b": [0.3461, 0.629, 0.4161, 0.6504]}, {"w": "performance", "b": [0.4225, 0.629, 0.5298, 0.6504]}, {"w": "to", "b": [0.5363, 0.629, 0.5533, 0.6504]}, {"w": "bucketize", "b": [0.5597, 0.629, 0.6389, 0.6504]}, {"w": "some", "b": [0.6454, 0.629, 0.6895, 0.6504]}, {"w": "numerical", "b": [0.696, 0.629, 0.7805, 0.6504]}, {"w": "features,", "b": [0.787, 0.629, 0.8571, 0.6504]}, {"w": "effectively", "b": [0.1428, 0.648, 0.227, 0.6694]}, {"w": "transforming", "b": [0.234, 0.648, 0.3446, 0.6694]}, {"w": "a", "b": [0.3515, 0.648, 0.3607, 0.6694]}, {"w": "numerical", "b": [0.3677, 0.648, 0.4522, 0.6694]}, {"w": "feature", "b": [0.4592, 0.648, 0.517, 0.6694]}, {"w": "into", "b": [0.524, 0.648, 0.5575, 0.6694]}, {"w": "a", "b": [0.5645, 0.648, 0.5737, 0.6694]}, {"w": "categorical", "b": [0.5807, 0.648, 0.6704, 0.6694]}, {"w": "feature.", "b": [0.6774, 0.648, 0.7399, 0.6694]}, {"w": "For", "b": [0.7469, 0.648, 0.7758, 0.6694]}, {"w": "example,", "b": [0.7828, 0.648, 0.8571, 0.6694]}, {"w": "let’s", "b": [0.1429, 0.668, 0.1731, 0.6894]}, {"w": "create", "b": [0.1783, 0.668, 0.2276, 0.6894]}, {"w": "a", "b": [0.2328, 0.668, 0.242, 0.6894]}, {"w": "bucketized", "b": [0.2471, 0.668, 0.3373, 0.6894]}, {"w": "column", "b": [0.3425, 0.668, 0.4067, 0.6894]}, {"w": "based", "b": [0.4119, 0.668, 0.4592, 0.6894]}, {"w": "on", "b": [0.4643, 0.668, 0.4864, 0.6894]}, {"w": "the", "b": [0.4915, 0.668, 0.5179, 0.6894]}, {"w": "median_income", "b": [0.5231, 0.6711, 0.6517, 0.6862]}, {"w": "column,", "b": [0.6569, 0.668, 0.7259, 0.6894]}, {"w": "with", "b": [0.7311, 0.668, 0.7684, 0.6894]}, {"w": "5", "b": [0.7736, 0.668, 0.7836, 0.6894]}, {"w": "buckets:", "b": [0.7888, 0.668, 0.8572, 0.6894]}, {"w": "less", "b": [0.1429, 0.687, 0.1723, 0.7084]}, {"w": "than", "b": [0.1772, 0.687, 0.2152, 0.7084]}, {"w": "1.5", "b": [0.2202, 0.687, 0.2449, 0.7084]}, {"w": "($15,000),", "b": [0.2499, 0.687, 0.3338, 0.7084]}, {"w": "then", "b": [0.3388, 0.687, 0.3765, 0.7084]}, {"w": "1.5", "b": [0.3814, 0.687, 0.4062, 0.7084]}, {"w": "to", "b": [0.4111, 0.687, 0.4281, 0.7084]}, {"w": "3,", "b": [0.4331, 0.687, 0.4478, 0.7084]}, {"w": "3", "b": [0.4528, 0.687, 0.4628, 0.7084]}, {"w": "to", "b": [0.4677, 0.687, 0.4847, 0.7084]}, {"w": "4.5,", "b": [0.4897, 0.687, 0.5192, 0.7084]}, {"w": "4.5", "b": [0.5241, 0.687, 0.5489, 0.7084]}, {"w": "to", "b": [0.5538, 0.687, 0.5708, 0.7084]}, {"w": "6.,", "b": [0.5757, 0.687, 0.5952, 0.7084]}, {"w": "and", "b": [0.6002, 0.687, 0.6317, 0.7084]}, {"w": "above", "b": [0.6367, 0.687, 0.6855, 0.7084]}, {"w": "6.", "b": [0.6905, 0.687, 0.7052, 0.7084]}, {"w": "(notice", "b": [0.7102, 0.687, 0.769, 0.7084]}, {"w": "that", "b": [0.774, 0.687, 0.8065, 0.7084]}, {"w": "when", "b": [0.8115, 0.687, 0.8571, 0.7084]}, {"w": "you", "b": [0.1429, 0.7061, 0.1741, 0.7275]}, {"w": "specify", "b": [0.1788, 0.7061, 0.2367, 0.7275]}, {"w": "4", "b": [0.2415, 0.7061, 0.2515, 0.7275]}, {"w": "boundaries,", "b": [0.2562, 0.7061, 0.3546, 0.7275]}, {"w": "there", "b": [0.3593, 0.7061, 0.4022, 0.7275]}, {"w": "are", "b": [0.4069, 0.7061, 0.4327, 0.7275]}, {"w": "actually", "b": [0.4374, 0.7061, 0.502, 0.7275]}, {"w": "5", "b": [0.5067, 0.7061, 0.5167, 0.7275]}, {"w": "buckets):", "b": [0.5215, 0.7061, 0.5971, 0.7275]}]}, {"id": "b_8", "type": "paragraph", "text": "median_income = tf.feature_column.numeric_column(\"median_income\") bucketized_income = tf.feature_column.bucketized_column( median_income, boundaries=[1.5, 3., 4.5, 6.])", "words": [{"w": "median_income", "b": [0.1766, 0.738, 0.2862, 0.7509]}, {"w": "=", "b": [0.2946, 0.738, 0.3031, 0.7509]}, {"w": "tf.feature_column.numeric_column(\"median_income\")", "b": [0.3115, 0.738, 0.7247, 0.7509]}, {"w": "bucketized_income", "b": [0.1766, 0.7534, 0.3199, 0.7663]}, {"w": "=", "b": [0.3284, 0.7534, 0.3368, 0.7663]}, {"w": "tf.feature_column.bucketized_column(", "b": [0.3452, 0.7534, 0.6488, 0.7663]}, {"w": "median_income,", "b": [0.2103, 0.7689, 0.3284, 0.7817]}, {"w": "boundaries=[1.5,", "b": [0.3368, 0.7689, 0.4717, 0.7817]}, {"w": "3.,", "b": [0.4802, 0.7689, 0.5055, 0.7817]}, {"w": "4.5,", "b": [0.5139, 0.7689, 0.5476, 0.7817]}, {"w": "6.])", "b": [0.5561, 0.7689, 0.5898, 0.7817]}]}, {"id": "b_9", "type": "paragraph", "text": "If the median_income feature is equal to, say, 3.2, then the bucketized_income feature will automatically be equal to 2 (i.e., the index of the corresponding income bucket). Choosing the right boundaries can be somewhat of an art, but one approach is to just use percentiles of the data (e.g., the 10th percentile, the 20th percentile, and so on). If a feature is multimodal, meaning it has separate peaks in its distribution, you may", "words": [{"w": "If", "b": [0.1429, 0.7904, 0.1561, 0.8118]}, {"w": "the", "b": [0.1609, 0.7904, 0.1872, 0.8118]}, {"w": "median_income", "b": [0.1925, 0.7936, 0.3211, 0.8087]}, {"w": "feature", "b": [0.3261, 0.7904, 0.3839, 0.8118]}, {"w": "is", "b": [0.3889, 0.7904, 0.4022, 0.8118]}, {"w": "equal", "b": [0.4072, 0.7904, 0.4522, 0.8118]}, {"w": "to,", "b": [0.4572, 0.7904, 0.4783, 0.8118]}, {"w": "say,", "b": [0.4833, 0.7904, 0.5125, 0.8118]}, {"w": "3.2,", "b": [0.5175, 0.7904, 0.547, 0.8118]}, {"w": "then", "b": [0.552, 0.7904, 0.5898, 0.8118]}, {"w": "the", "b": [0.5948, 0.7904, 0.6211, 0.8118]}, {"w": "bucketized_income", "b": [0.6261, 0.7936, 0.7944, 0.8087]}, {"w": "feature", "b": [0.7994, 0.7904, 0.8572, 0.8118]}, {"w": "will", "b": [0.1429, 0.8094, 0.1733, 0.8309]}, {"w": "automatically", "b": [0.1791, 0.8094, 0.2917, 0.8309]}, {"w": "be", "b": [0.2975, 0.8094, 0.3169, 0.8309]}, {"w": "equal", "b": [0.3227, 0.8094, 0.3677, 0.8309]}, {"w": "to", "b": [0.3735, 0.8094, 0.3905, 0.8309]}, {"w": "2", "b": [0.3963, 0.8094, 0.4063, 0.8309]}, {"w": "(i.e.,", "b": [0.4121, 0.8094, 0.448, 0.8309]}, {"w": "the", "b": [0.4538, 0.8094, 0.4801, 0.8309]}, {"w": "index", "b": [0.486, 0.8094, 0.5326, 0.8309]}, {"w": "of", "b": [0.5384, 0.8094, 0.5552, 0.8309]}, {"w": "the", "b": [0.561, 0.8094, 0.5874, 0.8309]}, {"w": "corresponding", "b": [0.5932, 0.8094, 0.7152, 0.8309]}, {"w": "income", "b": [0.721, 0.8094, 0.7834, 0.8309]}, {"w": "bucket).", "b": [0.7892, 0.8094, 0.8571, 0.8309]}, {"w": "Choosing", "b": [0.1429, 0.8285, 0.2235, 0.8499]}, {"w": "the", "b": [0.2286, 0.8285, 0.2549, 0.8499]}, {"w": "right", "b": [0.2601, 0.8285, 0.3002, 0.8499]}, {"w": "boundaries", "b": [0.3054, 0.8285, 0.399, 0.8499]}, {"w": "can", "b": [0.4042, 0.8285, 0.4335, 0.8499]}, {"w": "be", "b": [0.4387, 0.8285, 0.4581, 0.8499]}, {"w": "somewhat", "b": [0.4633, 0.8285, 0.548, 0.8499]}, {"w": "of", "b": [0.5531, 0.8285, 0.5699, 0.8499]}, {"w": "an", "b": [0.5751, 0.8285, 0.5956, 0.8499]}, {"w": "art,", "b": [0.6007, 0.8285, 0.6287, 0.8499]}, {"w": "but", "b": [0.6339, 0.8285, 0.6619, 0.8499]}, {"w": "one", "b": [0.667, 0.8285, 0.6979, 0.8499]}, {"w": "approach", "b": [0.7031, 0.8285, 0.7811, 0.8499]}, {"w": "is", "b": [0.7862, 0.8285, 0.7995, 0.8499]}, {"w": "to", "b": [0.8046, 0.8285, 0.8216, 0.8499]}, {"w": "just", "b": [0.8267, 0.8285, 0.8571, 0.8499]}, {"w": "use", "b": [0.1428, 0.8475, 0.1704, 0.8689]}, {"w": "percentiles", "b": [0.1757, 0.8475, 0.2656, 0.8689]}, {"w": "of", "b": [0.2709, 0.8475, 0.2877, 0.8689]}, {"w": "the", "b": [0.293, 0.8475, 0.3194, 0.8689]}, {"w": "data", "b": [0.3247, 0.8475, 0.3599, 0.8689]}, {"w": "(e.g.,", "b": [0.3652, 0.8475, 0.4053, 0.8689]}, {"w": "the", "b": [0.4106, 0.8475, 0.437, 0.8689]}, {"w": "10th", "b": [0.4423, 0.8475, 0.4798, 0.8689]}, {"w": "percentile,", "b": [0.4851, 0.8475, 0.5721, 0.8689]}, {"w": "the", "b": [0.5774, 0.8475, 0.6037, 0.8689]}, {"w": "20th", "b": [0.609, 0.8475, 0.6465, 0.8689]}, {"w": "percentile,", "b": [0.6518, 0.8475, 0.7388, 0.8689]}, {"w": "and", "b": [0.7441, 0.8475, 0.7757, 0.8689]}, {"w": "so", "b": [0.781, 0.8475, 0.7992, 0.8689]}, {"w": "on).", "b": [0.8046, 0.8475, 0.8385, 0.8689]}, {"w": "If", "b": [0.8439, 0.8475, 0.8571, 0.8689]}, {"w": "a", "b": [0.1429, 0.8666, 0.152, 0.888]}, {"w": "feature", "b": [0.1596, 0.8666, 0.2174, 0.888]}, {"w": "is", "b": [0.2249, 0.8666, 0.2382, 0.888]}, {"w": "multimodal,", "b": [0.2458, 0.8664, 0.3457, 0.888]}, {"w": "meaning", "b": [0.3533, 0.8666, 0.4265, 0.888]}, {"w": "it", "b": [0.434, 0.8666, 0.446, 0.888]}, {"w": "has", "b": [0.4536, 0.8666, 0.4815, 0.888]}, {"w": "separate", "b": [0.4891, 0.8666, 0.5573, 0.888]}, {"w": "peaks", "b": [0.5649, 0.8666, 0.6118, 0.888]}, {"w": "in", "b": [0.6194, 0.8666, 0.6363, 0.888]}, {"w": "its", "b": [0.6439, 0.8666, 0.6635, 0.888]}, {"w": "distribution,", "b": [0.6711, 0.8666, 0.7753, 0.888]}, {"w": "you", "b": [0.7829, 0.8666, 0.8142, 0.888]}, {"w": "may", "b": [0.8218, 0.8666, 0.8571, 0.888]}]}, {"id": "b_10", "type": "paragraph", "text": "420 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "420", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 447, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "want to define a bucket for each mode, placing the boundaries in between the peaks. Whether you use the percentiles or the modes, you need to analyze the distribution of your data ahead of time, just like we had to measure the mean and standard deviation ahead of time to normalize the housing_median_age column.", "words": [{"w": "want", "b": [0.1429, 0.0791, 0.1836, 0.1005]}, {"w": "to", "b": [0.1893, 0.0791, 0.2063, 0.1005]}, {"w": "define", "b": [0.212, 0.0791, 0.2639, 0.1005]}, {"w": "a", "b": [0.2696, 0.0791, 0.2787, 0.1005]}, {"w": "bucket", "b": [0.2844, 0.0791, 0.3404, 0.1005]}, {"w": "for", "b": [0.3461, 0.0791, 0.3706, 0.1005]}, {"w": "each", "b": [0.3763, 0.0791, 0.4143, 0.1005]}, {"w": "mode,", "b": [0.42, 0.0791, 0.4723, 0.1005]}, {"w": "placing", "b": [0.478, 0.0791, 0.5388, 0.1005]}, {"w": "the", "b": [0.5445, 0.0791, 0.5709, 0.1005]}, {"w": "boundaries", "b": [0.5766, 0.0791, 0.6702, 0.1005]}, {"w": "in", "b": [0.6759, 0.0791, 0.6929, 0.1005]}, {"w": "between", "b": [0.6986, 0.0791, 0.7678, 0.1005]}, {"w": "the", "b": [0.7735, 0.0791, 0.7998, 0.1005]}, {"w": "peaks.", "b": [0.8055, 0.0791, 0.8571, 0.1005]}, {"w": "Whether", "b": [0.1429, 0.0981, 0.2171, 0.1195]}, {"w": "you", "b": [0.2219, 0.0981, 0.2532, 0.1195]}, {"w": "use", "b": [0.258, 0.0981, 0.2855, 0.1195]}, {"w": "the", "b": [0.2904, 0.0981, 0.3167, 0.1195]}, {"w": "percentiles", "b": [0.3215, 0.0981, 0.4114, 0.1195]}, {"w": "or", "b": [0.4162, 0.0981, 0.4345, 0.1195]}, {"w": "the", "b": [0.4393, 0.0981, 0.4657, 0.1195]}, {"w": "modes,", "b": [0.4705, 0.0981, 0.5304, 0.1195]}, {"w": "you", "b": [0.5352, 0.0981, 0.5665, 0.1195]}, {"w": "need", "b": [0.5713, 0.0981, 0.6114, 0.1195]}, {"w": "to", "b": [0.6162, 0.0981, 0.6332, 0.1195]}, {"w": "analyze", "b": [0.638, 0.0981, 0.7001, 0.1195]}, {"w": "the", "b": [0.7049, 0.0981, 0.7312, 0.1195]}, {"w": "distribution", "b": [0.736, 0.0981, 0.8355, 0.1195]}, {"w": "of", "b": [0.8403, 0.0981, 0.8571, 0.1195]}, {"w": "your", "b": [0.1429, 0.1172, 0.1818, 0.1386]}, {"w": "data", "b": [0.1868, 0.1172, 0.222, 0.1386]}, {"w": "ahead", "b": [0.2269, 0.1172, 0.2762, 0.1386]}, {"w": "of", "b": [0.2811, 0.1172, 0.2979, 0.1386]}, {"w": "time,", "b": [0.3028, 0.1172, 0.3454, 0.1386]}, {"w": "just", "b": [0.3503, 0.1172, 0.3807, 0.1386]}, {"w": "like", "b": [0.3856, 0.1172, 0.4157, 0.1386]}, {"w": "we", "b": [0.4206, 0.1172, 0.4437, 0.1386]}, {"w": "had", "b": [0.4486, 0.1172, 0.4799, 0.1386]}, {"w": "to", "b": [0.4848, 0.1172, 0.5018, 0.1386]}, {"w": "measure", "b": [0.5067, 0.1172, 0.577, 0.1386]}, {"w": "the", "b": [0.582, 0.1172, 0.6083, 0.1386]}, {"w": "mean", "b": [0.6132, 0.1172, 0.6597, 0.1386]}, {"w": "and", "b": [0.6646, 0.1172, 0.6961, 0.1386]}, {"w": "standard", "b": [0.701, 0.1172, 0.7744, 0.1386]}, {"w": "deviation", "b": [0.7794, 0.1172, 0.8572, 0.1386]}, {"w": "ahead", "b": [0.1429, 0.1371, 0.1921, 0.1585]}, {"w": "of", "b": [0.1969, 0.1371, 0.2137, 0.1585]}, {"w": "time", "b": [0.2184, 0.1371, 0.2562, 0.1585]}, {"w": "to", "b": [0.261, 0.1371, 0.2779, 0.1585]}, {"w": "normalize", "b": [0.2827, 0.1371, 0.3671, 0.1585]}, {"w": "the", "b": [0.3718, 0.1371, 0.3982, 0.1585]}, {"w": "housing_median_age", "b": [0.4029, 0.1403, 0.581, 0.1554]}, {"w": "column.", "b": [0.5857, 0.1371, 0.6547, 0.1585]}]}, {"id": "b_1", "type": "paragraph", "text": "Categorical Features", "words": [{"w": "Categorical", "b": [0.1428, 0.1713, 0.2584, 0.1998]}, {"w": "Features", "b": [0.2633, 0.1713, 0.3525, 0.1998]}]}, {"id": "b_2", "type": "paragraph", "text": "For categorical features such as ocean_proximity, there are several options. If it is already represented as a category ID (i.e., an integer from 0 to the max ID), then you can use the categorical_column_with_identity() function (specifying the max ID). If not, and you know the list of all possible categories, then you can use categori cal_column_with_vocabulary_list():", "words": [{"w": "For", "b": [0.1429, 0.2066, 0.1718, 0.2281]}, {"w": "categorical", "b": [0.1793, 0.2066, 0.269, 0.2281]}, {"w": "features", "b": [0.2764, 0.2066, 0.3418, 0.2281]}, {"w": "such", "b": [0.3493, 0.2066, 0.3879, 0.2281]}, {"w": "as", "b": [0.3954, 0.2066, 0.4122, 0.2281]}, {"w": "ocean_proximity,", "b": [0.4196, 0.2066, 0.5728, 0.2281]}, {"w": "there", "b": [0.5803, 0.2066, 0.6232, 0.2281]}, {"w": "are", "b": [0.6307, 0.2066, 0.6564, 0.2281]}, {"w": "several", "b": [0.6638, 0.2066, 0.721, 0.2281]}, {"w": "options.", "b": [0.7284, 0.2066, 0.7963, 0.2281]}, {"w": "If", "b": [0.8038, 0.2066, 0.8171, 0.2281]}, {"w": "it", "b": [0.8245, 0.2066, 0.8365, 0.2281]}, {"w": "is", "b": [0.8439, 0.2066, 0.8571, 0.2281]}, {"w": "already", "b": [0.1429, 0.2257, 0.2036, 0.2471]}, {"w": "represented", "b": [0.209, 0.2257, 0.3068, 0.2471]}, {"w": "as", "b": [0.3123, 0.2257, 0.3291, 0.2471]}, {"w": "a", "b": [0.3346, 0.2257, 0.3437, 0.2471]}, {"w": "category", "b": [0.3492, 0.2257, 0.4202, 0.2471]}, {"w": "ID", "b": [0.4257, 0.2257, 0.4481, 0.2471]}, {"w": "(i.e.,", "b": [0.4536, 0.2257, 0.4895, 0.2471]}, {"w": "an", "b": [0.495, 0.2257, 0.5155, 0.2471]}, {"w": "integer", "b": [0.521, 0.2257, 0.5791, 0.2471]}, {"w": "from", "b": [0.5846, 0.2257, 0.6262, 0.2471]}, {"w": "0", "b": [0.6316, 0.2257, 0.6416, 0.2471]}, {"w": "to", "b": [0.6471, 0.2257, 0.6641, 0.2471]}, {"w": "the", "b": [0.6695, 0.2257, 0.6959, 0.2471]}, {"w": "max", "b": [0.7013, 0.2257, 0.7374, 0.2471]}, {"w": "ID),", "b": [0.7429, 0.2257, 0.7772, 0.2471]}, {"w": "then", "b": [0.7827, 0.2257, 0.8204, 0.2471]}, {"w": "you", "b": [0.8259, 0.2257, 0.8572, 0.2471]}, {"w": "can", "b": [0.1429, 0.2456, 0.1722, 0.267]}, {"w": "use", "b": [0.1821, 0.2456, 0.2096, 0.267]}, {"w": "the", "b": [0.2195, 0.2456, 0.2458, 0.267]}, {"w": "categorical_column_with_identity()", "b": [0.2557, 0.2488, 0.5921, 0.2639]}, {"w": "function", "b": [0.602, 0.2456, 0.6734, 0.267]}, {"w": "(specifying", "b": [0.6832, 0.2456, 0.7751, 0.267]}, {"w": "the", "b": [0.7849, 0.2456, 0.8113, 0.267]}, {"w": "max", "b": [0.8211, 0.2456, 0.8572, 0.267]}, {"w": "ID).", "b": [0.1429, 0.2656, 0.1772, 0.287]}, {"w": "If", "b": [0.182, 0.2656, 0.1953, 0.287]}, {"w": "not,", "b": [0.2001, 0.2656, 0.2332, 0.287]}, {"w": "and", "b": [0.238, 0.2656, 0.2695, 0.287]}, {"w": "you", "b": [0.2743, 0.2656, 0.3055, 0.287]}, {"w": "know", "b": [0.3103, 0.2656, 0.3569, 0.287]}, {"w": "the", "b": [0.3617, 0.2656, 0.3881, 0.287]}, {"w": "list", "b": [0.3928, 0.2656, 0.4177, 0.287]}, {"w": "of", "b": [0.4225, 0.2656, 0.4393, 0.287]}, {"w": "all", "b": [0.444, 0.2656, 0.4637, 0.287]}, {"w": "possible", "b": [0.4685, 0.2656, 0.5356, 0.287]}, {"w": "categories,", "b": [0.5404, 0.2656, 0.6281, 0.287]}, {"w": "then", "b": [0.6329, 0.2656, 0.6706, 0.287]}, {"w": "you", "b": [0.6754, 0.2656, 0.7067, 0.287]}, {"w": "can", "b": [0.7115, 0.2656, 0.7408, 0.287]}, {"w": "use", "b": [0.7456, 0.2656, 0.7731, 0.287]}, {"w": "categori", "b": [0.7779, 0.2688, 0.8571, 0.2838]}, {"w": "cal_column_with_vocabulary_list():", "b": [0.1429, 0.2855, 0.4742, 0.3069]}]}, {"id": "b_3", "type": "paragraph", "text": "ocean_prox_vocab = ['<1H OCEAN', 'INLAND', 'ISLAND', 'NEAR BAY', 'NEAR OCEAN'] ocean_proximity = tf.feature_column.categorical_column_with_vocabulary_list( \"ocean_proximity\", ocean_prox_vocab)", "words": [{"w": "ocean_prox_vocab", "b": [0.1766, 0.3175, 0.3115, 0.3303]}, {"w": "=", "b": [0.32, 0.3175, 0.3284, 0.3303]}, {"w": "['<1H", "b": [0.3368, 0.3175, 0.379, 0.3303]}, {"w": "OCEAN',", "b": [0.3874, 0.3175, 0.4464, 0.3303]}, {"w": "'INLAND',", "b": [0.4549, 0.3175, 0.5308, 0.3303]}, {"w": "'ISLAND',", "b": [0.5392, 0.3175, 0.6151, 0.3303]}, {"w": "'NEAR", "b": [0.6235, 0.3175, 0.6657, 0.3303]}, {"w": "BAY',", "b": [0.6741, 0.3175, 0.7163, 0.3303]}, {"w": "'NEAR", "b": [0.7247, 0.3175, 0.7669, 0.3303]}, {"w": "OCEAN']", "b": [0.7753, 0.3175, 0.8343, 0.3303]}, {"w": "ocean_proximity", "b": [0.1766, 0.3329, 0.3031, 0.3458]}, {"w": "=", "b": [0.3115, 0.3329, 0.32, 0.3458]}, {"w": "tf.feature_column.categorical_column_with_vocabulary_list(", "b": [0.3284, 0.3329, 0.8175, 0.3458]}, {"w": "\"ocean_proximity\",", "b": [0.2103, 0.3483, 0.3621, 0.3612]}, {"w": "ocean_prox_vocab)", "b": [0.3705, 0.3483, 0.5139, 0.3612]}]}, {"id": "b_4", "type": "paragraph", "text": "If you prefer to have TensorFlow load the vocabulary from a file, you can call catego rical_column_with_vocabulary_file() instead. As you might expect, these two functions will simply map each category to its index in the vocabulary (e.g., NEAR BAY will be mapped to 3), and unknown categories will be mapped to -1.", "words": [{"w": "If", "b": [0.1429, 0.3699, 0.1561, 0.3913]}, {"w": "you", "b": [0.1615, 0.3699, 0.1928, 0.3913]}, {"w": "prefer", "b": [0.1982, 0.3699, 0.2484, 0.3913]}, {"w": "to", "b": [0.2538, 0.3699, 0.2708, 0.3913]}, {"w": "have", "b": [0.2762, 0.3699, 0.3146, 0.3913]}, {"w": "TensorFlow", "b": [0.32, 0.3699, 0.4182, 0.3913]}, {"w": "load", "b": [0.4236, 0.3699, 0.4596, 0.3913]}, {"w": "the", "b": [0.465, 0.3699, 0.4914, 0.3913]}, {"w": "vocabulary", "b": [0.4968, 0.3699, 0.5889, 0.3913]}, {"w": "from", "b": [0.5943, 0.3699, 0.6359, 0.3913]}, {"w": "a", "b": [0.6413, 0.3699, 0.6505, 0.3913]}, {"w": "file,", "b": [0.6558, 0.3699, 0.6865, 0.3913]}, {"w": "you", "b": [0.6919, 0.3699, 0.7231, 0.3913]}, {"w": "can", "b": [0.7285, 0.3699, 0.7579, 0.3913]}, {"w": "call", "b": [0.7632, 0.3699, 0.7917, 0.3913]}, {"w": "catego", "b": [0.7971, 0.3731, 0.8565, 0.3881]}, {"w": "rical_column_with_vocabulary_file()", "b": [0.1429, 0.393, 0.4892, 0.4081]}, {"w": "instead.", "b": [0.4989, 0.3898, 0.5637, 0.4112]}, {"w": "As", "b": [0.5734, 0.3898, 0.5954, 0.4112]}, {"w": "you", "b": [0.6051, 0.3898, 0.6364, 0.4112]}, {"w": "might", "b": [0.6461, 0.3898, 0.6956, 0.4112]}, {"w": "expect,", "b": [0.7053, 0.3898, 0.7636, 0.4112]}, {"w": "these", "b": [0.7734, 0.3898, 0.8162, 0.4112]}, {"w": "two", "b": [0.8259, 0.3898, 0.8572, 0.4112]}, {"w": "functions", "b": [0.1429, 0.4089, 0.2219, 0.4303]}, {"w": "will", "b": [0.229, 0.4089, 0.2594, 0.4303]}, {"w": "simply", "b": [0.2665, 0.4089, 0.3221, 0.4303]}, {"w": "map", "b": [0.3292, 0.4089, 0.3659, 0.4303]}, {"w": "each", "b": [0.373, 0.4089, 0.4109, 0.4303]}, {"w": "category", "b": [0.418, 0.4089, 0.4891, 0.4303]}, {"w": "to", "b": [0.4961, 0.4089, 0.5131, 0.4303]}, {"w": "its", "b": [0.5202, 0.4089, 0.5398, 0.4303]}, {"w": "index", "b": [0.5469, 0.4089, 0.5935, 0.4303]}, {"w": "in", "b": [0.6006, 0.4089, 0.6176, 0.4303]}, {"w": "the", "b": [0.6247, 0.4089, 0.651, 0.4303]}, {"w": "vocabulary", "b": [0.6581, 0.4089, 0.7503, 0.4303]}, {"w": "(e.g.,", "b": [0.7574, 0.4089, 0.7974, 0.4303]}, {"w": "NEAR", "b": [0.8045, 0.4087, 0.8571, 0.4303]}, {"w": "BAY", "b": [0.1429, 0.4277, 0.1811, 0.4493]}, {"w": "will", "b": [0.1858, 0.4279, 0.2162, 0.4493]}, {"w": "be", "b": [0.221, 0.4279, 0.2404, 0.4493]}, {"w": "mapped", "b": [0.2451, 0.4279, 0.3126, 0.4493]}, {"w": "to", "b": [0.3174, 0.4279, 0.3343, 0.4493]}, {"w": "3),", "b": [0.3391, 0.4279, 0.361, 0.4493]}, {"w": "and", "b": [0.3658, 0.4279, 0.3973, 0.4493]}, {"w": "unknown", "b": [0.402, 0.4279, 0.4825, 0.4493]}, {"w": "categories", "b": [0.4872, 0.4279, 0.5702, 0.4493]}, {"w": "will", "b": [0.5749, 0.4279, 0.6053, 0.4493]}, {"w": "be", "b": [0.61, 0.4279, 0.6295, 0.4493]}, {"w": "mapped", "b": [0.6342, 0.4279, 0.7017, 0.4493]}, {"w": "to", "b": [0.7064, 0.4279, 0.7234, 0.4493]}, {"w": "-1.", "b": [0.7281, 0.4279, 0.7503, 0.4493]}]}, {"id": "b_5", "type": "paragraph", "text": "For categorical columns with a large vocabulary (e.g., for zipcodes, cities, words, products, users, etc.), it may not be convenient to get the full list of possible cate‐ gories, or perhaps categories may be added or removed so frequently that using cate‐ gory indices would be too unreliable. In this case, you may prefer to use a categorical_column_with_hash_bucket(). If we had a \"city\" feature in the dataset, we could encode it like this:", "words": [{"w": "For", "b": [0.1429, 0.456, 0.1718, 0.4774]}, {"w": "categorical", "b": [0.1809, 0.456, 0.2705, 0.4774]}, {"w": "columns", "b": [0.2796, 0.456, 0.3514, 0.4774]}, {"w": "with", "b": [0.3605, 0.456, 0.3978, 0.4774]}, {"w": "a", "b": [0.4068, 0.456, 0.4159, 0.4774]}, {"w": "large", "b": [0.425, 0.456, 0.4657, 0.4774]}, {"w": "vocabulary", "b": [0.4747, 0.456, 0.5669, 0.4774]}, {"w": "(e.g.,", "b": [0.5759, 0.456, 0.616, 0.4774]}, {"w": "for", "b": [0.625, 0.456, 0.6495, 0.4774]}, {"w": "zipcodes,", "b": [0.6586, 0.456, 0.7355, 0.4774]}, {"w": "cities,", "b": [0.7445, 0.456, 0.7921, 0.4774]}, {"w": "words,", "b": [0.8011, 0.456, 0.8571, 0.4774]}, {"w": "products,", "b": [0.1429, 0.4751, 0.2218, 0.4965]}, {"w": "users,", "b": [0.2294, 0.4751, 0.2771, 0.4965]}, {"w": "etc.),", "b": [0.2848, 0.4751, 0.3255, 0.4965]}, {"w": "it", "b": [0.3331, 0.4751, 0.3451, 0.4965]}, {"w": "may", "b": [0.3527, 0.4751, 0.3881, 0.4965]}, {"w": "not", "b": [0.3958, 0.4751, 0.4242, 0.4965]}, {"w": "be", "b": [0.4318, 0.4751, 0.4512, 0.4965]}, {"w": "convenient", "b": [0.4589, 0.4751, 0.5509, 0.4965]}, {"w": "to", "b": [0.5586, 0.4751, 0.5756, 0.4965]}, {"w": "get", "b": [0.5832, 0.4751, 0.6082, 0.4965]}, {"w": "the", "b": [0.6158, 0.4751, 0.6422, 0.4965]}, {"w": "full", "b": [0.6498, 0.4751, 0.6776, 0.4965]}, {"w": "list", "b": [0.6852, 0.4751, 0.7101, 0.4965]}, {"w": "of", "b": [0.7177, 0.4751, 0.7345, 0.4965]}, {"w": "possible", "b": [0.7422, 0.4751, 0.8093, 0.4965]}, {"w": "cate‐", "b": [0.817, 0.4751, 0.8572, 0.4965]}, {"w": "gories,", "b": [0.1429, 0.4941, 0.1978, 0.5155]}, {"w": "or", "b": [0.2034, 0.4941, 0.2217, 0.5155]}, {"w": "perhaps", "b": [0.2273, 0.4941, 0.2932, 0.5155]}, {"w": "categories", "b": [0.2987, 0.4941, 0.3817, 0.5155]}, {"w": "may", "b": [0.3873, 0.4941, 0.4227, 0.5155]}, {"w": "be", "b": [0.4282, 0.4941, 0.4476, 0.5155]}, {"w": "added", "b": [0.4532, 0.4941, 0.5042, 0.5155]}, {"w": "or", "b": [0.5097, 0.4941, 0.5281, 0.5155]}, {"w": "removed", "b": [0.5336, 0.4941, 0.6074, 0.5155]}, {"w": "so", "b": [0.613, 0.4941, 0.6312, 0.5155]}, {"w": "frequently", "b": [0.6368, 0.4941, 0.7223, 0.5155]}, {"w": "that", "b": [0.7278, 0.4941, 0.7604, 0.5155]}, {"w": "using", "b": [0.766, 0.4941, 0.8114, 0.5155]}, {"w": "cate‐", "b": [0.817, 0.4941, 0.8571, 0.5155]}, {"w": "gory", "b": [0.1429, 0.5132, 0.1811, 0.5346]}, {"w": "indices", "b": [0.1933, 0.5132, 0.2522, 0.5346]}, {"w": "would", "b": [0.2643, 0.5132, 0.3166, 0.5346]}, {"w": "be", "b": [0.3287, 0.5132, 0.3482, 0.5346]}, {"w": "too", "b": [0.3603, 0.5132, 0.388, 0.5346]}, {"w": "unreliable.", "b": [0.4001, 0.5132, 0.4886, 0.5346]}, {"w": "In", "b": [0.5008, 0.5132, 0.5193, 0.5346]}, {"w": "this", "b": [0.5315, 0.5132, 0.5622, 0.5346]}, {"w": "case,", "b": [0.5743, 0.5132, 0.6135, 0.5346]}, {"w": "you", "b": [0.6257, 0.5132, 0.657, 0.5346]}, {"w": "may", "b": [0.6691, 0.5132, 0.7045, 0.5346]}, {"w": "prefer", "b": [0.7167, 0.5132, 0.7669, 0.5346]}, {"w": "to", "b": [0.7791, 0.5132, 0.7961, 0.5346]}, {"w": "use", "b": [0.8083, 0.5132, 0.8358, 0.5346]}, {"w": "a", "b": [0.848, 0.5132, 0.8571, 0.5346]}, {"w": "categorical_column_with_hash_bucket().", "b": [0.1429, 0.5331, 0.5138, 0.5545]}, {"w": "If", "b": [0.5185, 0.5331, 0.5318, 0.5545]}, {"w": "we", "b": [0.5365, 0.5331, 0.5596, 0.5545]}, {"w": "had", "b": [0.5643, 0.5331, 0.5956, 0.5545]}, {"w": "a", "b": [0.6003, 0.5331, 0.6095, 0.5545]}, {"w": "\"city\"", "b": [0.6146, 0.5363, 0.674, 0.5514]}, {"w": "feature", "b": [0.6788, 0.5331, 0.7365, 0.5545]}, {"w": "in", "b": [0.7413, 0.5331, 0.7583, 0.5545]}, {"w": "the", "b": [0.763, 0.5331, 0.7893, 0.5545]}, {"w": "dataset,", "b": [0.794, 0.5331, 0.8569, 0.5545]}, {"w": "we", "b": [0.1429, 0.5522, 0.166, 0.5736]}, {"w": "could", "b": [0.1707, 0.5522, 0.2175, 0.5736]}, {"w": "encode", "b": [0.2222, 0.5522, 0.2818, 0.5736]}, {"w": "it", "b": [0.2865, 0.5522, 0.2984, 0.5736]}, {"w": "like", "b": [0.3032, 0.5522, 0.3332, 0.5736]}, {"w": "this:", "b": [0.3379, 0.5522, 0.3734, 0.5736]}]}, {"id": "b_6", "type": "paragraph", "text": "city_hash = tf.feature_column.categorical_column_with_hash_bucket( \"city\", hash_bucket_size=1000)", "words": [{"w": "city_hash", "b": [0.1766, 0.5841, 0.2525, 0.597]}, {"w": "=", "b": [0.2609, 0.5841, 0.2693, 0.597]}, {"w": "tf.feature_column.categorical_column_with_hash_bucket(", "b": [0.2778, 0.5841, 0.7331, 0.597]}, {"w": "\"city\",", "b": [0.2103, 0.5996, 0.2693, 0.6124]}, {"w": "hash_bucket_size=1000)", "b": [0.2778, 0.5996, 0.4633, 0.6124]}]}, {"id": "b_7", "type": "paragraph", "text": "This feature will compute a hash for each category (i.e., for each city), modulo the number of hash buckets (hash_bucket_size). You must set the number of buckets high enough to avoid getting too many collisions (i.e., different categories ending up in the same bucket), but the higher you set it, the more RAM will be used (by the embedding table, as we will see shortly).", "words": [{"w": "This", "b": [0.1429, 0.6202, 0.1801, 0.6416]}, {"w": "feature", "b": [0.1873, 0.6202, 0.2451, 0.6416]}, {"w": "will", "b": [0.2523, 0.6202, 0.2827, 0.6416]}, {"w": "compute", "b": [0.2899, 0.6202, 0.3632, 0.6416]}, {"w": "a", "b": [0.3705, 0.6202, 0.3796, 0.6416]}, {"w": "hash", "b": [0.3869, 0.6202, 0.4259, 0.6416]}, {"w": "for", "b": [0.4331, 0.6202, 0.4577, 0.6416]}, {"w": "each", "b": [0.4649, 0.6202, 0.5028, 0.6416]}, {"w": "category", "b": [0.5101, 0.6202, 0.5811, 0.6416]}, {"w": "(i.e.,", "b": [0.5883, 0.6202, 0.6242, 0.6416]}, {"w": "for", "b": [0.6315, 0.6202, 0.656, 0.6416]}, {"w": "each", "b": [0.6632, 0.6202, 0.7012, 0.6416]}, {"w": "city),", "b": [0.7084, 0.6202, 0.7507, 0.6416]}, {"w": "modulo", "b": [0.7579, 0.6202, 0.8236, 0.6416]}, {"w": "the", "b": [0.8308, 0.6202, 0.8571, 0.6416]}, {"w": "number", "b": [0.1429, 0.6401, 0.2092, 0.6615]}, {"w": "of", "b": [0.2165, 0.6401, 0.2333, 0.6615]}, {"w": "hash", "b": [0.2407, 0.6401, 0.2797, 0.6615]}, {"w": "buckets", "b": [0.2871, 0.6401, 0.3507, 0.6615]}, {"w": "(hash_bucket_size).", "b": [0.3581, 0.6401, 0.5356, 0.6615]}, {"w": "You", "b": [0.543, 0.6401, 0.5753, 0.6615]}, {"w": "must", "b": [0.5827, 0.6401, 0.6244, 0.6615]}, {"w": "set", "b": [0.6318, 0.6401, 0.6546, 0.6615]}, {"w": "the", "b": [0.662, 0.6401, 0.6883, 0.6615]}, {"w": "number", "b": [0.6957, 0.6401, 0.762, 0.6615]}, {"w": "of", "b": [0.7694, 0.6401, 0.7861, 0.6615]}, {"w": "buckets", "b": [0.7935, 0.6401, 0.8572, 0.6615]}, {"w": "high", "b": [0.1429, 0.6592, 0.1804, 0.6806]}, {"w": "enough", "b": [0.1863, 0.6592, 0.2491, 0.6806]}, {"w": "to", "b": [0.2549, 0.6592, 0.2719, 0.6806]}, {"w": "avoid", "b": [0.2777, 0.6592, 0.3234, 0.6806]}, {"w": "getting", "b": [0.3292, 0.6592, 0.3872, 0.6806]}, {"w": "too", "b": [0.3931, 0.6592, 0.4207, 0.6806]}, {"w": "many", "b": [0.4265, 0.6592, 0.4732, 0.6806]}, {"w": "collisions", "b": [0.479, 0.6592, 0.5575, 0.6806]}, {"w": "(i.e.,", "b": [0.5633, 0.6592, 0.5992, 0.6806]}, {"w": "different", "b": [0.605, 0.6592, 0.6767, 0.6806]}, {"w": "categories", "b": [0.6826, 0.6592, 0.7655, 0.6806]}, {"w": "ending", "b": [0.7714, 0.6592, 0.8293, 0.6806]}, {"w": "up", "b": [0.8352, 0.6592, 0.8571, 0.6806]}, {"w": "in", "b": [0.1429, 0.6782, 0.1598, 0.6996]}, {"w": "the", "b": [0.167, 0.6782, 0.1934, 0.6996]}, {"w": "same", "b": [0.2006, 0.6782, 0.2433, 0.6996]}, {"w": "bucket),", "b": [0.2505, 0.6782, 0.3184, 0.6996]}, {"w": "but", "b": [0.3256, 0.6782, 0.3536, 0.6996]}, {"w": "the", "b": [0.3608, 0.6782, 0.3872, 0.6996]}, {"w": "higher", "b": [0.3944, 0.6782, 0.4485, 0.6996]}, {"w": "you", "b": [0.4557, 0.6782, 0.487, 0.6996]}, {"w": "set", "b": [0.4942, 0.6782, 0.5171, 0.6996]}, {"w": "it,", "b": [0.5243, 0.6782, 0.5409, 0.6996]}, {"w": "the", "b": [0.5481, 0.6782, 0.5745, 0.6996]}, {"w": "more", "b": [0.5817, 0.6782, 0.626, 0.6996]}, {"w": "RAM", "b": [0.6332, 0.6782, 0.679, 0.6996]}, {"w": "will", "b": [0.6863, 0.6782, 0.7166, 0.6996]}, {"w": "be", "b": [0.7238, 0.6782, 0.7433, 0.6996]}, {"w": "used", "b": [0.7505, 0.6782, 0.7891, 0.6996]}, {"w": "(by", "b": [0.7963, 0.6782, 0.8236, 0.6996]}, {"w": "the", "b": [0.8308, 0.6782, 0.8571, 0.6996]}, {"w": "embedding", "b": [0.1429, 0.6973, 0.2369, 0.7187]}, {"w": "table,", "b": [0.2417, 0.6973, 0.2866, 0.7187]}, {"w": "as", "b": [0.2914, 0.6973, 0.3081, 0.7187]}, {"w": "we", "b": [0.3129, 0.6973, 0.336, 0.7187]}, {"w": "will", "b": [0.3407, 0.6973, 0.3711, 0.7187]}, {"w": "see", "b": [0.3759, 0.6973, 0.4012, 0.7187]}, {"w": "shortly).", "b": [0.4059, 0.6973, 0.4762, 0.7187]}]}, {"id": "b_8", "type": "paragraph", "text": "Crossed Categorical Features", "words": [{"w": "Crossed", "b": [0.1428, 0.7315, 0.2212, 0.76]}, {"w": "Categorical", "b": [0.2261, 0.7315, 0.3417, 0.76]}, {"w": "Features", "b": [0.3466, 0.7315, 0.4358, 0.76]}]}, {"id": "b_9", "type": "paragraph", "text": "If you suspect that two (or more) categorical features are more meaningful when used jointly, then you can create a crossed column. For example, suppose people are partic‐ ularly fond of old houses inland and new houses near the ocean, then it might help to", "words": [{"w": "If", "b": [0.1429, 0.7659, 0.1561, 0.7873]}, {"w": "you", "b": [0.1609, 0.7659, 0.1922, 0.7873]}, {"w": "suspect", "b": [0.197, 0.7659, 0.2583, 0.7873]}, {"w": "that", "b": [0.2631, 0.7659, 0.2957, 0.7873]}, {"w": "two", "b": [0.3005, 0.7659, 0.3318, 0.7873]}, {"w": "(or", "b": [0.3366, 0.7659, 0.3621, 0.7873]}, {"w": "more)", "b": [0.367, 0.7659, 0.4184, 0.7873]}, {"w": "categorical", "b": [0.4233, 0.7659, 0.5129, 0.7873]}, {"w": "features", "b": [0.5178, 0.7659, 0.5832, 0.7873]}, {"w": "are", "b": [0.588, 0.7659, 0.6137, 0.7873]}, {"w": "more", "b": [0.6185, 0.7659, 0.6628, 0.7873]}, {"w": "meaningful", "b": [0.6676, 0.7659, 0.7633, 0.7873]}, {"w": "when", "b": [0.7681, 0.7659, 0.8138, 0.7873]}, {"w": "used", "b": [0.8186, 0.7659, 0.8571, 0.7873]}, {"w": "jointly,", "b": [0.1429, 0.785, 0.1998, 0.8064]}, {"w": "then", "b": [0.2052, 0.785, 0.2429, 0.8064]}, {"w": "you", "b": [0.2483, 0.785, 0.2795, 0.8064]}, {"w": "can", "b": [0.2849, 0.785, 0.3143, 0.8064]}, {"w": "create", "b": [0.3196, 0.785, 0.369, 0.8064]}, {"w": "a", "b": [0.3744, 0.785, 0.3835, 0.8064]}, {"w": "crossed", "b": [0.3889, 0.7848, 0.4464, 0.8064]}, {"w": "column.", "b": [0.4512, 0.7848, 0.5169, 0.8064]}, {"w": "For", "b": [0.5222, 0.785, 0.5512, 0.8064]}, {"w": "example,", "b": [0.5566, 0.785, 0.6309, 0.8064]}, {"w": "suppose", "b": [0.6362, 0.785, 0.7039, 0.8064]}, {"w": "people", "b": [0.7093, 0.785, 0.7647, 0.8064]}, {"w": "are", "b": [0.7701, 0.785, 0.7958, 0.8064]}, {"w": "partic‐", "b": [0.8012, 0.785, 0.8571, 0.8064]}, {"w": "ularly", "b": [0.1429, 0.804, 0.1909, 0.8254]}, {"w": "fond", "b": [0.1959, 0.804, 0.2351, 0.8254]}, {"w": "of", "b": [0.2401, 0.804, 0.2569, 0.8254]}, {"w": "old", "b": [0.2619, 0.804, 0.2888, 0.8254]}, {"w": "houses", "b": [0.2938, 0.804, 0.3508, 0.8254]}, {"w": "inland", "b": [0.3558, 0.804, 0.4096, 0.8254]}, {"w": "and", "b": [0.4146, 0.804, 0.4462, 0.8254]}, {"w": "new", "b": [0.4512, 0.804, 0.4857, 0.8254]}, {"w": "houses", "b": [0.4907, 0.804, 0.5477, 0.8254]}, {"w": "near", "b": [0.5527, 0.804, 0.5898, 0.8254]}, {"w": "the", "b": [0.5948, 0.804, 0.6212, 0.8254]}, {"w": "ocean,", "b": [0.6262, 0.804, 0.6798, 0.8254]}, {"w": "then", "b": [0.6848, 0.804, 0.7225, 0.8254]}, {"w": "it", "b": [0.7275, 0.804, 0.7395, 0.8254]}, {"w": "might", "b": [0.7445, 0.804, 0.794, 0.8254]}, {"w": "help", "b": [0.799, 0.804, 0.8351, 0.8254]}, {"w": "to", "b": [0.8402, 0.804, 0.8571, 0.8254]}]}, {"id": "b_10", "type": "paragraph", "text": "The Features API | 421", "words": [{"w": "The", "b": [0.698, 0.9225, 0.7195, 0.9388]}, {"w": "Features", "b": [0.7224, 0.9225, 0.7733, 0.9388]}, {"w": "API", "b": [0.7761, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "421", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 448, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "9 Since the housing_median_age feature was normalized, the boundaries are for normalized ages.", "words": [{"w": "9", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "Since", "b": [0.1587, 0.8749, 0.1927, 0.8912]}, {"w": "the", "b": [0.1963, 0.8749, 0.2163, 0.8912]}, {"w": "housing_median_age", "b": [0.2199, 0.8773, 0.3556, 0.8888]}, {"w": "feature", "b": [0.3592, 0.8749, 0.4033, 0.8912]}, {"w": "was", "b": [0.4069, 0.8749, 0.4305, 0.8912]}, {"w": "normalized,", "b": [0.4341, 0.8749, 0.5104, 0.8912]}, {"w": "the", "b": [0.514, 0.8749, 0.5341, 0.8912]}, {"w": "boundaries", "b": [0.5377, 0.8749, 0.609, 0.8912]}, {"w": "are", "b": [0.6127, 0.8749, 0.6323, 0.8912]}, {"w": "for", "b": [0.6359, 0.8749, 0.6545, 0.8912]}, {"w": "normalized", "b": [0.6581, 0.8749, 0.7308, 0.8912]}, {"w": "ages.", "b": [0.7344, 0.8749, 0.765, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "create a bucketized column for the housing_median_age feature9, and cross it with the ocean_proximity column. The crossed column will compute a hash of every age & ocean proximity combination it comes across, modulo the hash_bucket_size, and this will give it the cross category ID. You may then choose to use only this crossed column in your model, or also include the individual columns.", "words": [{"w": "create", "b": [0.1429, 0.08, 0.1922, 0.1014]}, {"w": "a", "b": [0.1996, 0.08, 0.2087, 0.1014]}, {"w": "bucketized", "b": [0.2161, 0.08, 0.3063, 0.1014]}, {"w": "column", "b": [0.3136, 0.08, 0.3778, 0.1014]}, {"w": "for", "b": [0.3852, 0.08, 0.4097, 0.1014]}, {"w": "the", "b": [0.4171, 0.08, 0.4434, 0.1014]}, {"w": "housing_median_age", "b": [0.4508, 0.0831, 0.6289, 0.0982]}, {"w": "feature9,", "b": [0.6362, 0.08, 0.7045, 0.1014]}, {"w": "and", "b": [0.7118, 0.08, 0.7434, 0.1014]}, {"w": "cross", "b": [0.7507, 0.08, 0.7932, 0.1014]}, {"w": "it", "b": [0.8005, 0.08, 0.8125, 0.1014]}, {"w": "with", "b": [0.8198, 0.08, 0.8571, 0.1014]}, {"w": "the", "b": [0.1428, 0.0999, 0.1692, 0.1213]}, {"w": "ocean_proximity", "b": [0.175, 0.1031, 0.3234, 0.1182]}, {"w": "column.", "b": [0.3292, 0.0999, 0.3982, 0.1213]}, {"w": "The", "b": [0.404, 0.0999, 0.4368, 0.1213]}, {"w": "crossed", "b": [0.4426, 0.0999, 0.5049, 0.1213]}, {"w": "column", "b": [0.5107, 0.0999, 0.5749, 0.1213]}, {"w": "will", "b": [0.5807, 0.0999, 0.6111, 0.1213]}, {"w": "compute", "b": [0.6169, 0.0999, 0.6902, 0.1213]}, {"w": "a", "b": [0.696, 0.0999, 0.7052, 0.1213]}, {"w": "hash", "b": [0.7109, 0.0999, 0.75, 0.1213]}, {"w": "of", "b": [0.7558, 0.0999, 0.7726, 0.1213]}, {"w": "every", "b": [0.7784, 0.0999, 0.8236, 0.1213]}, {"w": "age", "b": [0.8294, 0.0999, 0.8572, 0.1213]}, {"w": "&", "b": [0.1429, 0.1198, 0.1577, 0.1413]}, {"w": "ocean", "b": [0.1629, 0.1198, 0.2118, 0.1413]}, {"w": "proximity", "b": [0.2171, 0.1198, 0.3003, 0.1413]}, {"w": "combination", "b": [0.3056, 0.1198, 0.4123, 0.1413]}, {"w": "it", "b": [0.4176, 0.1198, 0.4296, 0.1413]}, {"w": "comes", "b": [0.4348, 0.1198, 0.4878, 0.1413]}, {"w": "across,", "b": [0.4931, 0.1198, 0.5495, 0.1413]}, {"w": "modulo", "b": [0.5547, 0.1198, 0.6204, 0.1413]}, {"w": "the", "b": [0.6256, 0.1198, 0.652, 0.1413]}, {"w": "hash_bucket_size,", "b": [0.6572, 0.1198, 0.8203, 0.1413]}, {"w": "and", "b": [0.8251, 0.1198, 0.8566, 0.1413]}, {"w": "this", "b": [0.1429, 0.1389, 0.1736, 0.1603]}, {"w": "will", "b": [0.18, 0.1389, 0.2104, 0.1603]}, {"w": "give", "b": [0.2169, 0.1389, 0.2507, 0.1603]}, {"w": "it", "b": [0.2572, 0.1389, 0.2692, 0.1603]}, {"w": "the", "b": [0.2756, 0.1389, 0.302, 0.1603]}, {"w": "cross", "b": [0.3085, 0.1389, 0.3509, 0.1603]}, {"w": "category", "b": [0.3574, 0.1389, 0.4284, 0.1603]}, {"w": "ID.", "b": [0.4349, 0.1389, 0.4612, 0.1603]}, {"w": "You", "b": [0.4677, 0.1389, 0.5001, 0.1603]}, {"w": "may", "b": [0.5066, 0.1389, 0.542, 0.1603]}, {"w": "then", "b": [0.5484, 0.1389, 0.5862, 0.1603]}, {"w": "choose", "b": [0.5926, 0.1389, 0.6503, 0.1603]}, {"w": "to", "b": [0.6568, 0.1389, 0.6738, 0.1603]}, {"w": "use", "b": [0.6803, 0.1389, 0.7078, 0.1603]}, {"w": "only", "b": [0.7143, 0.1389, 0.7512, 0.1603]}, {"w": "this", "b": [0.7576, 0.1389, 0.7883, 0.1603]}, {"w": "crossed", "b": [0.7948, 0.1389, 0.8571, 0.1603]}, {"w": "column", "b": [0.1428, 0.1579, 0.2071, 0.1794]}, {"w": "in", "b": [0.2118, 0.1579, 0.2288, 0.1794]}, {"w": "your", "b": [0.2335, 0.1579, 0.2725, 0.1794]}, {"w": "model,", "b": [0.2772, 0.1579, 0.3348, 0.1794]}, {"w": "or", "b": [0.3395, 0.1579, 0.3579, 0.1794]}, {"w": "also", "b": [0.3626, 0.1579, 0.3953, 0.1794]}, {"w": "include", "b": [0.4, 0.1579, 0.462, 0.1794]}, {"w": "the", "b": [0.4667, 0.1579, 0.4931, 0.1794]}, {"w": "individual", "b": [0.4978, 0.1579, 0.5831, 0.1794]}, {"w": "columns.", "b": [0.5878, 0.1579, 0.6644, 0.1794]}]}, {"id": "b_2", "type": "paragraph", "text": "bucketized_age = tf.feature_column.bucketized_column( housing_median_age, boundaries=[-1., -0.5, 0., 0.5, 1.]) # age was scaled age_and_ocean_proximity = tf.feature_column.crossed_column( [bucketized_age, ocean_proximity], hash_bucket_size=100)", "words": [{"w": "bucketized_age", "b": [0.1766, 0.1899, 0.2946, 0.2028]}, {"w": "=", "b": [0.3031, 0.1899, 0.3115, 0.2028]}, {"w": "tf.feature_column.bucketized_column(", "b": [0.3199, 0.1899, 0.6235, 0.2028]}, {"w": "housing_median_age,", "b": [0.2103, 0.2053, 0.3705, 0.2182]}, {"w": "boundaries=[-1.,", "b": [0.379, 0.2053, 0.5139, 0.2182]}, {"w": "-0.5,", "b": [0.5223, 0.2053, 0.5645, 0.2182]}, {"w": "0.,", "b": [0.5729, 0.2053, 0.5982, 0.2182]}, {"w": "0.5,", "b": [0.6066, 0.2053, 0.6404, 0.2182]}, {"w": "1.])", "b": [0.6488, 0.2053, 0.6825, 0.2182]}, {"w": "#", "b": [0.691, 0.2053, 0.6994, 0.2182]}, {"w": "age", "b": [0.7078, 0.2053, 0.7331, 0.2182]}, {"w": "was", "b": [0.7416, 0.2053, 0.7669, 0.2182]}, {"w": "scaled", "b": [0.7753, 0.2053, 0.8259, 0.2182]}, {"w": "age_and_ocean_proximity", "b": [0.1766, 0.2208, 0.3705, 0.2336]}, {"w": "=", "b": [0.379, 0.2208, 0.3874, 0.2336]}, {"w": "tf.feature_column.crossed_column(", "b": [0.3958, 0.2208, 0.6741, 0.2336]}, {"w": "[bucketized_age,", "b": [0.2103, 0.2362, 0.3452, 0.249]}, {"w": "ocean_proximity],", "b": [0.3537, 0.2362, 0.497, 0.249]}, {"w": "hash_bucket_size=100)", "b": [0.5055, 0.2362, 0.6825, 0.249]}]}, {"id": "b_3", "type": "paragraph", "text": "Another common use case for crossed columns is to cross latitude and longitude into a single categorical feature: you start by bucketizing the latitude and longitude, for example into 20 buckets each, then you cross these bucketized features into a loca tion column. This will create a 20×20 grid over California, and each cell in the grid will correspond to one category:", "words": [{"w": "Another", "b": [0.1429, 0.2568, 0.2133, 0.2782]}, {"w": "common", "b": [0.2185, 0.2568, 0.294, 0.2782]}, {"w": "use", "b": [0.2992, 0.2568, 0.3267, 0.2782]}, {"w": "case", "b": [0.3318, 0.2568, 0.3663, 0.2782]}, {"w": "for", "b": [0.3714, 0.2568, 0.3959, 0.2782]}, {"w": "crossed", "b": [0.4011, 0.2568, 0.4634, 0.2782]}, {"w": "columns", "b": [0.4685, 0.2568, 0.5404, 0.2782]}, {"w": "is", "b": [0.5455, 0.2568, 0.5587, 0.2782]}, {"w": "to", "b": [0.5639, 0.2568, 0.5808, 0.2782]}, {"w": "cross", "b": [0.586, 0.2568, 0.6284, 0.2782]}, {"w": "latitude", "b": [0.6335, 0.2568, 0.6968, 0.2782]}, {"w": "and", "b": [0.7019, 0.2568, 0.7334, 0.2782]}, {"w": "longitude", "b": [0.7386, 0.2568, 0.8185, 0.2782]}, {"w": "into", "b": [0.8236, 0.2568, 0.8571, 0.2782]}, {"w": "a", "b": [0.1429, 0.2759, 0.152, 0.2973]}, {"w": "single", "b": [0.1594, 0.2759, 0.2079, 0.2973]}, {"w": "categorical", "b": [0.2153, 0.2759, 0.3049, 0.2973]}, {"w": "feature:", "b": [0.3123, 0.2759, 0.3748, 0.2973]}, {"w": "you", "b": [0.3822, 0.2759, 0.4135, 0.2973]}, {"w": "start", "b": [0.4208, 0.2759, 0.4581, 0.2973]}, {"w": "by", "b": [0.4654, 0.2759, 0.4856, 0.2973]}, {"w": "bucketizing", "b": [0.493, 0.2759, 0.59, 0.2973]}, {"w": "the", "b": [0.5974, 0.2759, 0.6237, 0.2973]}, {"w": "latitude", "b": [0.6311, 0.2759, 0.6943, 0.2973]}, {"w": "and", "b": [0.7017, 0.2759, 0.7332, 0.2973]}, {"w": "longitude,", "b": [0.7406, 0.2759, 0.8253, 0.2973]}, {"w": "for", "b": [0.8326, 0.2759, 0.8572, 0.2973]}, {"w": "example", "b": [0.1429, 0.2958, 0.2124, 0.3172]}, {"w": "into", "b": [0.2194, 0.2958, 0.2529, 0.3172]}, {"w": "20", "b": [0.2599, 0.2958, 0.2799, 0.3172]}, {"w": "buckets", "b": [0.2869, 0.2958, 0.3505, 0.3172]}, {"w": "each,", "b": [0.3575, 0.2958, 0.4002, 0.3172]}, {"w": "then", "b": [0.4071, 0.2958, 0.4449, 0.3172]}, {"w": "you", "b": [0.4518, 0.2958, 0.4831, 0.3172]}, {"w": "cross", "b": [0.49, 0.2958, 0.5325, 0.3172]}, {"w": "these", "b": [0.5395, 0.2958, 0.5823, 0.3172]}, {"w": "bucketized", "b": [0.5893, 0.2958, 0.6795, 0.3172]}, {"w": "features", "b": [0.6864, 0.2958, 0.7518, 0.3172]}, {"w": "into", "b": [0.7588, 0.2958, 0.7924, 0.3172]}, {"w": "a", "b": [0.7993, 0.2958, 0.8085, 0.3172]}, {"w": "loca", "b": [0.8154, 0.299, 0.855, 0.3141]}, {"w": "tion", "b": [0.1429, 0.3189, 0.1824, 0.334]}, {"w": "column.", "b": [0.1886, 0.3157, 0.2576, 0.3372]}, {"w": "This", "b": [0.2637, 0.3157, 0.3009, 0.3372]}, {"w": "will", "b": [0.3071, 0.3157, 0.3375, 0.3372]}, {"w": "create", "b": [0.3436, 0.3157, 0.393, 0.3372]}, {"w": "a", "b": [0.3992, 0.3157, 0.4083, 0.3372]}, {"w": "20×20", "b": [0.4145, 0.3157, 0.4665, 0.3372]}, {"w": "grid", "b": [0.4727, 0.3157, 0.5067, 0.3372]}, {"w": "over", "b": [0.5129, 0.3157, 0.5498, 0.3372]}, {"w": "California,", "b": [0.5559, 0.3157, 0.6452, 0.3372]}, {"w": "and", "b": [0.6513, 0.3157, 0.6829, 0.3372]}, {"w": "each", "b": [0.689, 0.3157, 0.7269, 0.3372]}, {"w": "cell", "b": [0.7331, 0.3157, 0.7613, 0.3372]}, {"w": "in", "b": [0.7675, 0.3157, 0.7844, 0.3372]}, {"w": "the", "b": [0.7906, 0.3157, 0.8169, 0.3372]}, {"w": "grid", "b": [0.8231, 0.3157, 0.8571, 0.3372]}, {"w": "will", "b": [0.1429, 0.3348, 0.1733, 0.3562]}, {"w": "correspond", "b": [0.178, 0.3348, 0.2733, 0.3562]}, {"w": "to", "b": [0.278, 0.3348, 0.295, 0.3562]}, {"w": "one", "b": [0.2998, 0.3348, 0.3306, 0.3562]}, {"w": "category:", "b": [0.3354, 0.3348, 0.4118, 0.3562]}]}, {"id": "b_4", "type": "paragraph", "text": "latitude = tf.feature_column.numeric_column(\"latitude\") longitude = tf.feature_column.numeric_column(\"longitude\") bucketized_latitude = tf.feature_column.bucketized_column( latitude, boundaries=list(np.linspace(32., 42., 20 - 1))) bucketized_longitude = tf.feature_column.bucketized_column( longitude, boundaries=list(np.linspace(-125., -114., 20 - 1))) location = tf.feature_column.crossed_column( [bucketized_latitude, bucketized_longitude], hash_bucket_size=1000)", "words": [{"w": "latitude", "b": [0.1766, 0.3668, 0.2441, 0.3796]}, {"w": "=", "b": [0.2525, 0.3668, 0.2609, 0.3796]}, {"w": "tf.feature_column.numeric_column(\"latitude\")", "b": [0.2694, 0.3668, 0.6404, 0.3796]}, {"w": "longitude", "b": [0.1766, 0.3822, 0.2525, 0.395]}, {"w": "=", "b": [0.2609, 0.3822, 0.2694, 0.395]}, {"w": "tf.feature_column.numeric_column(\"longitude\")", "b": [0.2778, 0.3822, 0.6572, 0.395]}, {"w": "bucketized_latitude", "b": [0.1766, 0.3976, 0.3368, 0.4105]}, {"w": "=", "b": [0.3452, 0.3976, 0.3537, 0.4105]}, {"w": "tf.feature_column.bucketized_column(", "b": [0.3621, 0.3976, 0.6657, 0.4105]}, {"w": "latitude,", "b": [0.2103, 0.413, 0.2862, 0.4259]}, {"w": "boundaries=list(np.linspace(32.,", "b": [0.2946, 0.413, 0.5645, 0.4259]}, {"w": "42.,", "b": [0.5729, 0.413, 0.6067, 0.4259]}, {"w": "20", "b": [0.6151, 0.413, 0.6319, 0.4259]}, {"w": "-", "b": [0.6404, 0.413, 0.6488, 0.4259]}, {"w": "1)))", "b": [0.6572, 0.413, 0.691, 0.4259]}, {"w": "bucketized_longitude", "b": [0.1766, 0.4284, 0.3452, 0.4413]}, {"w": "=", "b": [0.3537, 0.4284, 0.3621, 0.4413]}, {"w": "tf.feature_column.bucketized_column(", "b": [0.3705, 0.4284, 0.6741, 0.4413]}, {"w": "longitude,", "b": [0.2103, 0.4439, 0.2946, 0.4567]}, {"w": "boundaries=list(np.linspace(-125.,", "b": [0.3031, 0.4439, 0.5898, 0.4567]}, {"w": "-114.,", "b": [0.5982, 0.4439, 0.6488, 0.4567]}, {"w": "20", "b": [0.6572, 0.4439, 0.6741, 0.4567]}, {"w": "-", "b": [0.6825, 0.4439, 0.691, 0.4567]}, {"w": "1)))", "b": [0.6994, 0.4439, 0.7331, 0.4567]}, {"w": "location", "b": [0.1766, 0.4593, 0.2441, 0.4721]}, {"w": "=", "b": [0.2525, 0.4593, 0.2609, 0.4721]}, {"w": "tf.feature_column.crossed_column(", "b": [0.2694, 0.4593, 0.5476, 0.4721]}, {"w": "[bucketized_latitude,", "b": [0.2103, 0.4747, 0.3874, 0.4876]}, {"w": "bucketized_longitude],", "b": [0.3958, 0.4747, 0.5814, 0.4876]}, {"w": "hash_bucket_size=1000)", "b": [0.5898, 0.4747, 0.7753, 0.4876]}]}, {"id": "b_5", "type": "equation", "text": "Encoding Categorical Features Using One-Hot Vectors", "words": [{"w": "Encoding", "b": [0.1428, 0.5014, 0.2374, 0.53]}, {"w": "Categorical", "b": [0.2423, 0.5014, 0.3579, 0.53]}, {"w": "Features", "b": [0.3628, 0.5014, 0.452, 0.53]}, {"w": "Using", "b": [0.457, 0.5014, 0.5149, 0.53]}, {"w": "One-Hot", "b": [0.5199, 0.5014, 0.6059, 0.53]}, {"w": "Vectors", "b": [0.6108, 0.5014, 0.6866, 0.53]}]}, {"id": "b_6", "type": "paragraph", "text": "No matter which option you choose to build a categorical feature (categorical col‐ umns, bucketized columns or crossed columns), it must be encoded before you can feed it to a neural network. There are two options to encode a categorical feature: one-hot vectors or embeddings. For the first option, simply use the indicator_col umn() function:", "words": [{"w": "No", "b": [0.1429, 0.5359, 0.1684, 0.5573]}, {"w": "matter", "b": [0.1761, 0.5359, 0.2312, 0.5573]}, {"w": "which", "b": [0.2389, 0.5359, 0.2898, 0.5573]}, {"w": "option", "b": [0.2975, 0.5359, 0.353, 0.5573]}, {"w": "you", "b": [0.3607, 0.5359, 0.3919, 0.5573]}, {"w": "choose", "b": [0.3996, 0.5359, 0.4573, 0.5573]}, {"w": "to", "b": [0.465, 0.5359, 0.4819, 0.5573]}, {"w": "build", "b": [0.4896, 0.5359, 0.5331, 0.5573]}, {"w": "a", "b": [0.5408, 0.5359, 0.5499, 0.5573]}, {"w": "categorical", "b": [0.5576, 0.5359, 0.6473, 0.5573]}, {"w": "feature", "b": [0.655, 0.5359, 0.7128, 0.5573]}, {"w": "(categorical", "b": [0.7204, 0.5359, 0.8173, 0.5573]}, {"w": "col‐", "b": [0.825, 0.5359, 0.8571, 0.5573]}, {"w": "umns,", "b": [0.1429, 0.5549, 0.1948, 0.5763]}, {"w": "bucketized", "b": [0.2013, 0.5549, 0.2915, 0.5763]}, {"w": "columns", "b": [0.2981, 0.5549, 0.37, 0.5763]}, {"w": "or", "b": [0.3765, 0.5549, 0.3949, 0.5763]}, {"w": "crossed", "b": [0.4014, 0.5549, 0.4637, 0.5763]}, {"w": "columns),", "b": [0.4703, 0.5549, 0.5541, 0.5763]}, {"w": "it", "b": [0.5607, 0.5549, 0.5726, 0.5763]}, {"w": "must", "b": [0.5792, 0.5549, 0.6209, 0.5763]}, {"w": "be", "b": [0.6275, 0.5549, 0.6469, 0.5763]}, {"w": "encoded", "b": [0.6535, 0.5549, 0.724, 0.5763]}, {"w": "before", "b": [0.7306, 0.5549, 0.7834, 0.5763]}, {"w": "you", "b": [0.79, 0.5549, 0.8212, 0.5763]}, {"w": "can", "b": [0.8278, 0.5549, 0.8571, 0.5763]}, {"w": "feed", "b": [0.1429, 0.574, 0.1777, 0.5954]}, {"w": "it", "b": [0.1853, 0.574, 0.1973, 0.5954]}, {"w": "to", "b": [0.2048, 0.574, 0.2218, 0.5954]}, {"w": "a", "b": [0.2294, 0.574, 0.2386, 0.5954]}, {"w": "neural", "b": [0.2461, 0.574, 0.2996, 0.5954]}, {"w": "network.", "b": [0.3072, 0.574, 0.3815, 0.5954]}, {"w": "There", "b": [0.3891, 0.574, 0.4385, 0.5954]}, {"w": "are", "b": [0.4461, 0.574, 0.4718, 0.5954]}, {"w": "two", "b": [0.4794, 0.574, 0.5106, 0.5954]}, {"w": "options", "b": [0.5182, 0.574, 0.5814, 0.5954]}, {"w": "to", "b": [0.5889, 0.574, 0.6059, 0.5954]}, {"w": "encode", "b": [0.6135, 0.574, 0.673, 0.5954]}, {"w": "a", "b": [0.6806, 0.574, 0.6898, 0.5954]}, {"w": "categorical", "b": [0.6974, 0.574, 0.787, 0.5954]}, {"w": "feature:", "b": [0.7946, 0.574, 0.8572, 0.5954]}, {"w": "one-hot", "b": [0.1429, 0.5939, 0.2093, 0.6153]}, {"w": "vectors", "b": [0.2165, 0.5939, 0.2762, 0.6153]}, {"w": "or", "b": [0.2835, 0.5939, 0.3018, 0.6153]}, {"w": "embeddings.", "b": [0.3091, 0.5937, 0.4093, 0.6153]}, {"w": "For", "b": [0.4166, 0.5939, 0.4456, 0.6153]}, {"w": "the", "b": [0.4528, 0.5939, 0.4792, 0.6153]}, {"w": "first", "b": [0.4865, 0.5939, 0.5199, 0.6153]}, {"w": "option,", "b": [0.5272, 0.5939, 0.5875, 0.6153]}, {"w": "simply", "b": [0.5947, 0.5939, 0.6504, 0.6153]}, {"w": "use", "b": [0.6576, 0.5939, 0.6852, 0.6153]}, {"w": "the", "b": [0.6925, 0.5939, 0.7188, 0.6153]}, {"w": "indicator_col", "b": [0.7261, 0.5971, 0.8547, 0.6122]}, {"w": "umn()", "b": [0.1429, 0.617, 0.1923, 0.6321]}, {"w": "function:", "b": [0.1971, 0.6138, 0.2732, 0.6353]}]}, {"id": "b_7", "type": "equation", "text": "ocean_proximity_one_hot = tf.feature_column.indicator_column(ocean_proximity)", "words": [{"w": "ocean_proximity_one_hot", "b": [0.1766, 0.6458, 0.3705, 0.6587]}, {"w": "=", "b": [0.379, 0.6458, 0.3874, 0.6587]}, {"w": "tf.feature_column.indicator_column(ocean_proximity)", "b": [0.3958, 0.6458, 0.8259, 0.6587]}]}, {"id": "b_8", "type": "paragraph", "text": "A one-hot vector encoding has the size of the vocabulary length, which is fine if there are just a few possible categories, but if the vocabulary is large, you will end up with too many inputs fed to your neural network: it will have too many weights to learn and it will probably not perform very well. In particular, this will typically be the case when you use hash buckets. In this case, you should probably encode them using embeddings instead.", "words": [{"w": "A", "b": [0.1429, 0.6665, 0.1573, 0.6879]}, {"w": "one-hot", "b": [0.1623, 0.6665, 0.2287, 0.6879]}, {"w": "vector", "b": [0.2337, 0.6665, 0.2857, 0.6879]}, {"w": "encoding", "b": [0.2907, 0.6665, 0.3682, 0.6879]}, {"w": "has", "b": [0.3732, 0.6665, 0.4011, 0.6879]}, {"w": "the", "b": [0.4061, 0.6665, 0.4325, 0.6879]}, {"w": "size", "b": [0.4375, 0.6665, 0.4683, 0.6879]}, {"w": "of", "b": [0.4733, 0.6665, 0.4901, 0.6879]}, {"w": "the", "b": [0.4952, 0.6665, 0.5215, 0.6879]}, {"w": "vocabulary", "b": [0.5265, 0.6665, 0.6187, 0.6879]}, {"w": "length,", "b": [0.6237, 0.6665, 0.6812, 0.6879]}, {"w": "which", "b": [0.6862, 0.6665, 0.7372, 0.6879]}, {"w": "is", "b": [0.7422, 0.6665, 0.7554, 0.6879]}, {"w": "fine", "b": [0.7604, 0.6665, 0.7924, 0.6879]}, {"w": "if", "b": [0.7975, 0.6665, 0.8092, 0.6879]}, {"w": "there", "b": [0.8142, 0.6665, 0.8571, 0.6879]}, {"w": "are", "b": [0.1429, 0.6855, 0.1686, 0.7069]}, {"w": "just", "b": [0.1746, 0.6855, 0.205, 0.7069]}, {"w": "a", "b": [0.2109, 0.6855, 0.2201, 0.7069]}, {"w": "few", "b": [0.2261, 0.6855, 0.2554, 0.7069]}, {"w": "possible", "b": [0.2613, 0.6855, 0.3285, 0.7069]}, {"w": "categories,", "b": [0.3344, 0.6855, 0.4222, 0.7069]}, {"w": "but", "b": [0.4281, 0.6855, 0.4561, 0.7069]}, {"w": "if", "b": [0.4621, 0.6855, 0.4739, 0.7069]}, {"w": "the", "b": [0.4798, 0.6855, 0.5062, 0.7069]}, {"w": "vocabulary", "b": [0.5122, 0.6855, 0.6043, 0.7069]}, {"w": "is", "b": [0.6103, 0.6855, 0.6236, 0.7069]}, {"w": "large,", "b": [0.6295, 0.6855, 0.675, 0.7069]}, {"w": "you", "b": [0.681, 0.6855, 0.7123, 0.7069]}, {"w": "will", "b": [0.7182, 0.6855, 0.7486, 0.7069]}, {"w": "end", "b": [0.7546, 0.6855, 0.7859, 0.7069]}, {"w": "up", "b": [0.7918, 0.6855, 0.8138, 0.7069]}, {"w": "with", "b": [0.8198, 0.6855, 0.8571, 0.7069]}, {"w": "too", "b": [0.1429, 0.7046, 0.1705, 0.726]}, {"w": "many", "b": [0.1771, 0.7046, 0.2238, 0.726]}, {"w": "inputs", "b": [0.2305, 0.7046, 0.2831, 0.726]}, {"w": "fed", "b": [0.2897, 0.7046, 0.3157, 0.726]}, {"w": "to", "b": [0.3224, 0.7046, 0.3394, 0.726]}, {"w": "your", "b": [0.3461, 0.7046, 0.385, 0.726]}, {"w": "neural", "b": [0.3917, 0.7046, 0.4452, 0.726]}, {"w": "network:", "b": [0.4519, 0.7046, 0.5262, 0.726]}, {"w": "it", "b": [0.5328, 0.7046, 0.5448, 0.726]}, {"w": "will", "b": [0.5515, 0.7046, 0.5818, 0.726]}, {"w": "have", "b": [0.5885, 0.7046, 0.6269, 0.726]}, {"w": "too", "b": [0.6336, 0.7046, 0.6612, 0.726]}, {"w": "many", "b": [0.6679, 0.7046, 0.7146, 0.726]}, {"w": "weights", "b": [0.7212, 0.7046, 0.7844, 0.726]}, {"w": "to", "b": [0.7911, 0.7046, 0.8081, 0.726]}, {"w": "learn", "b": [0.8147, 0.7046, 0.8571, 0.726]}, {"w": "and", "b": [0.1429, 0.7236, 0.1744, 0.745]}, {"w": "it", "b": [0.1796, 0.7236, 0.1916, 0.745]}, {"w": "will", "b": [0.1968, 0.7236, 0.2272, 0.745]}, {"w": "probably", "b": [0.2324, 0.7236, 0.3068, 0.745]}, {"w": "not", "b": [0.312, 0.7236, 0.3404, 0.745]}, {"w": "perform", "b": [0.3456, 0.7236, 0.4147, 0.745]}, {"w": "very", "b": [0.4199, 0.7236, 0.4563, 0.745]}, {"w": "well.", "b": [0.4615, 0.7236, 0.4999, 0.745]}, {"w": "In", "b": [0.5051, 0.7236, 0.5236, 0.745]}, {"w": "particular,", "b": [0.5289, 0.7236, 0.614, 0.745]}, {"w": "this", "b": [0.6193, 0.7236, 0.65, 0.745]}, {"w": "will", "b": [0.6552, 0.7236, 0.6856, 0.745]}, {"w": "typically", "b": [0.6908, 0.7236, 0.7613, 0.745]}, {"w": "be", "b": [0.7665, 0.7236, 0.7859, 0.745]}, {"w": "the", "b": [0.7911, 0.7236, 0.8175, 0.745]}, {"w": "case", "b": [0.8227, 0.7236, 0.8572, 0.745]}, {"w": "when", "b": [0.1429, 0.7426, 0.1885, 0.7641]}, {"w": "you", "b": [0.1964, 0.7426, 0.2277, 0.7641]}, {"w": "use", "b": [0.2356, 0.7426, 0.2632, 0.7641]}, {"w": "hash", "b": [0.2711, 0.7426, 0.3102, 0.7641]}, {"w": "buckets.", "b": [0.3181, 0.7426, 0.3865, 0.7641]}, {"w": "In", "b": [0.3944, 0.7426, 0.4129, 0.7641]}, {"w": "this", "b": [0.4209, 0.7426, 0.4516, 0.7641]}, {"w": "case,", "b": [0.4595, 0.7426, 0.4987, 0.7641]}, {"w": "you", "b": [0.5067, 0.7426, 0.5379, 0.7641]}, {"w": "should", "b": [0.5459, 0.7426, 0.6026, 0.7641]}, {"w": "probably", "b": [0.6105, 0.7426, 0.685, 0.7641]}, {"w": "encode", "b": [0.6929, 0.7426, 0.7524, 0.7641]}, {"w": "them", "b": [0.7604, 0.7426, 0.8038, 0.7641]}, {"w": "using", "b": [0.8117, 0.7426, 0.8571, 0.7641]}, {"w": "embeddings", "b": [0.1429, 0.7615, 0.2383, 0.7831]}, {"w": "instead.", "b": [0.2431, 0.7617, 0.3078, 0.7831]}]}, {"id": "b_9", "type": "paragraph", "text": "422 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "422", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 449, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "As a rule of thumb (but your mileage may vary!), if the number of categories is lower than 10, then one-hot encoding is generally the way to go. If the number of categories is greater than 50 (which is often the case when you use hash buckets), then embeddings are usually preferable. In between 10 and 50 categories, you may want to experiment with both options and see which one works best for your use case. Also, embeddings typically require more training data, unless you can reuse pretrained embeddings.", "words": [{"w": "As", "b": [0.2714, 0.0793, 0.2916, 0.0989]}, {"w": "a", "b": [0.2969, 0.0793, 0.3053, 0.0989]}, {"w": "rule", "b": [0.3106, 0.0793, 0.3407, 0.0989]}, {"w": "of", "b": [0.3461, 0.0793, 0.3614, 0.0989]}, {"w": "thumb", "b": [0.3668, 0.0793, 0.4178, 0.0989]}, {"w": "(but", "b": [0.4232, 0.0793, 0.4554, 0.0989]}, {"w": "your", "b": [0.4607, 0.0793, 0.4964, 0.0989]}, {"w": "mileage", "b": [0.5017, 0.0793, 0.5607, 0.0989]}, {"w": "may", "b": [0.5661, 0.0793, 0.5984, 0.0989]}, {"w": "vary!),", "b": [0.6038, 0.0793, 0.6535, 0.0989]}, {"w": "if", "b": [0.6589, 0.0793, 0.6696, 0.0989]}, {"w": "the", "b": [0.675, 0.0793, 0.699, 0.0989]}, {"w": "number", "b": [0.7044, 0.0793, 0.765, 0.0989]}, {"w": "of", "b": [0.7704, 0.0793, 0.7857, 0.0989]}, {"w": "categories", "b": [0.2714, 0.0967, 0.3473, 0.1163]}, {"w": "is", "b": [0.3527, 0.0967, 0.3648, 0.1163]}, {"w": "lower", "b": [0.3703, 0.0967, 0.413, 0.1163]}, {"w": "than", "b": [0.4185, 0.0967, 0.4533, 0.1163]}, {"w": "10,", "b": [0.4588, 0.0967, 0.4814, 0.1163]}, {"w": "then", "b": [0.4869, 0.0967, 0.5214, 0.1163]}, {"w": "one-hot", "b": [0.5268, 0.0967, 0.5875, 0.1163]}, {"w": "encoding", "b": [0.593, 0.0967, 0.6638, 0.1163]}, {"w": "is", "b": [0.6693, 0.0967, 0.6814, 0.1163]}, {"w": "generally", "b": [0.6868, 0.0967, 0.7562, 0.1163]}, {"w": "the", "b": [0.7616, 0.0967, 0.7857, 0.1163]}, {"w": "way", "b": [0.2714, 0.1141, 0.3012, 0.1337]}, {"w": "to", "b": [0.307, 0.1141, 0.3225, 0.1337]}, {"w": "go.", "b": [0.3283, 0.1141, 0.3507, 0.1337]}, {"w": "If", "b": [0.3565, 0.1141, 0.3686, 0.1337]}, {"w": "the", "b": [0.3744, 0.1141, 0.3985, 0.1337]}, {"w": "number", "b": [0.4043, 0.1141, 0.4649, 0.1337]}, {"w": "of", "b": [0.4706, 0.1141, 0.486, 0.1337]}, {"w": "categories", "b": [0.4918, 0.1141, 0.5676, 0.1337]}, {"w": "is", "b": [0.5734, 0.1141, 0.5855, 0.1337]}, {"w": "greater", "b": [0.5913, 0.1141, 0.6443, 0.1337]}, {"w": "than", "b": [0.6501, 0.1141, 0.6849, 0.1337]}, {"w": "50", "b": [0.6906, 0.1141, 0.7089, 0.1337]}, {"w": "(which", "b": [0.7147, 0.1141, 0.7678, 0.1337]}, {"w": "is", "b": [0.7736, 0.1141, 0.7857, 0.1337]}, {"w": "often", "b": [0.2714, 0.1315, 0.3111, 0.1511]}, {"w": "the", "b": [0.3179, 0.1315, 0.3419, 0.1511]}, {"w": "case", "b": [0.3487, 0.1315, 0.3802, 0.1511]}, {"w": "when", "b": [0.387, 0.1315, 0.4287, 0.1511]}, {"w": "you", "b": [0.4355, 0.1315, 0.4641, 0.1511]}, {"w": "use", "b": [0.4708, 0.1315, 0.496, 0.1511]}, {"w": "hash", "b": [0.5028, 0.1315, 0.5385, 0.1511]}, {"w": "buckets),", "b": [0.5453, 0.1315, 0.6144, 0.1511]}, {"w": "then", "b": [0.6211, 0.1315, 0.6556, 0.1511]}, {"w": "embeddings", "b": [0.6624, 0.1315, 0.7554, 0.1511]}, {"w": "are", "b": [0.7622, 0.1315, 0.7857, 0.1511]}, {"w": "usually", "b": [0.2714, 0.1489, 0.3254, 0.1685]}, {"w": "preferable.", "b": [0.3309, 0.1489, 0.4121, 0.1685]}, {"w": "In", "b": [0.4176, 0.1489, 0.4346, 0.1685]}, {"w": "between", "b": [0.4401, 0.1489, 0.5033, 0.1685]}, {"w": "10", "b": [0.5088, 0.1489, 0.5271, 0.1685]}, {"w": "and", "b": [0.5326, 0.1489, 0.5615, 0.1685]}, {"w": "50", "b": [0.567, 0.1489, 0.5853, 0.1685]}, {"w": "categories,", "b": [0.5908, 0.1489, 0.671, 0.1685]}, {"w": "you", "b": [0.6765, 0.1489, 0.7051, 0.1685]}, {"w": "may", "b": [0.7106, 0.1489, 0.7429, 0.1685]}, {"w": "want", "b": [0.7484, 0.1489, 0.7857, 0.1685]}, {"w": "to", "b": [0.2714, 0.1664, 0.2869, 0.1859]}, {"w": "experiment", "b": [0.2923, 0.1664, 0.3792, 0.1859]}, {"w": "with", "b": [0.3845, 0.1664, 0.4186, 0.1859]}, {"w": "both", "b": [0.4239, 0.1664, 0.4593, 0.1859]}, {"w": "options", "b": [0.4646, 0.1664, 0.5224, 0.1859]}, {"w": "and", "b": [0.5277, 0.1664, 0.5565, 0.1859]}, {"w": "see", "b": [0.5619, 0.1664, 0.585, 0.1859]}, {"w": "which", "b": [0.5904, 0.1664, 0.6369, 0.1859]}, {"w": "one", "b": [0.6423, 0.1664, 0.6705, 0.1859]}, {"w": "works", "b": [0.6758, 0.1664, 0.7221, 0.1859]}, {"w": "best", "b": [0.7274, 0.1664, 0.758, 0.1859]}, {"w": "for", "b": [0.7633, 0.1664, 0.7857, 0.1859]}, {"w": "your", "b": [0.2714, 0.1838, 0.3071, 0.2033]}, {"w": "use", "b": [0.3151, 0.1838, 0.3403, 0.2033]}, {"w": "case.", "b": [0.3484, 0.1838, 0.3843, 0.2033]}, {"w": "Also,", "b": [0.3924, 0.1838, 0.4309, 0.2033]}, {"w": "embeddings", "b": [0.4389, 0.1838, 0.532, 0.2033]}, {"w": "typically", "b": [0.5401, 0.1838, 0.6045, 0.2033]}, {"w": "require", "b": [0.6126, 0.1838, 0.6679, 0.2033]}, {"w": "more", "b": [0.676, 0.1838, 0.7164, 0.2033]}, {"w": "training", "b": [0.7245, 0.1838, 0.7857, 0.2033]}, {"w": "data,", "b": [0.2714, 0.2012, 0.308, 0.2208]}, {"w": "unless", "b": [0.3123, 0.2012, 0.3597, 0.2208]}, {"w": "you", "b": [0.3641, 0.2012, 0.3926, 0.2208]}, {"w": "can", "b": [0.397, 0.2012, 0.4238, 0.2208]}, {"w": "reuse", "b": [0.4281, 0.2012, 0.4685, 0.2208]}, {"w": "pretrained", "b": [0.4728, 0.2012, 0.5529, 0.2208]}, {"w": "embeddings.", "b": [0.5572, 0.2012, 0.6545, 0.2208]}]}, {"id": "b_1", "type": "paragraph", "text": "Encoding Categorical Features Using Embeddings", "words": [{"w": "Encoding", "b": [0.1429, 0.2383, 0.2374, 0.2669]}, {"w": "Categorical", "b": [0.2424, 0.2383, 0.3579, 0.2669]}, {"w": "Features", "b": [0.3629, 0.2383, 0.452, 0.2669]}, {"w": "Using", "b": [0.457, 0.2383, 0.515, 0.2669]}, {"w": "Embeddings", "b": [0.5199, 0.2383, 0.6472, 0.2669]}]}, {"id": "b_2", "type": "paragraph", "text": "An embedding is a trainable dense vector that represents a category. By default, embeddings are initialized randomly, so for example the \"NEAR BAY\" category could be represented initially by a random vector such as [0.131, 0.890], while the \"NEAR OCEAN\" category may be represented by another random vector such as [0.631, 0.791] (in this example, we are using 2D embeddings, but the number of dimensions is a hyperparameter you can tweak). Since these embeddings are trainable, they will gradually improve during training, and as they represent fairly similar categories, Gradient Descent will certainly end up pushing them closer together, while it will tend to move them away from the \"INLAND\" category’s embedding (see Figure 13-4). Indeed, the better the representation, the easier it will be for the neural network to make accurate predictions, so training tends to make embeddings useful representa‐ tions of the categories. This is called representation learning (we will see other types of representation learning in ???).", "words": [{"w": "An", "b": [0.1429, 0.2728, 0.1686, 0.2942]}, {"w": "embedding", "b": [0.178, 0.2728, 0.2721, 0.2942]}, {"w": "is", "b": [0.2815, 0.2728, 0.2947, 0.2942]}, {"w": "a", "b": [0.3041, 0.2728, 0.3133, 0.2942]}, {"w": "trainable", "b": [0.3226, 0.2728, 0.3967, 0.2942]}, {"w": "dense", "b": [0.4061, 0.2728, 0.4538, 0.2942]}, {"w": "vector", "b": [0.4632, 0.2728, 0.5152, 0.2942]}, {"w": "that", "b": [0.5246, 0.2728, 0.5572, 0.2942]}, {"w": "represents", "b": [0.5666, 0.2728, 0.6522, 0.2942]}, {"w": "a", "b": [0.6616, 0.2728, 0.6707, 0.2942]}, {"w": "category.", "b": [0.6801, 0.2728, 0.7544, 0.2942]}, {"w": "By", "b": [0.7637, 0.2728, 0.7855, 0.2942]}, {"w": "default,", "b": [0.7949, 0.2728, 0.8571, 0.2942]}, {"w": "embeddings", "b": [0.1429, 0.2927, 0.2446, 0.3141]}, {"w": "are", "b": [0.2508, 0.2927, 0.2765, 0.3141]}, {"w": "initialized", "b": [0.2827, 0.2927, 0.3658, 0.3141]}, {"w": "randomly,", "b": [0.372, 0.2927, 0.457, 0.3141]}, {"w": "so", "b": [0.4632, 0.2927, 0.4815, 0.3141]}, {"w": "for", "b": [0.4877, 0.2927, 0.5122, 0.3141]}, {"w": "example", "b": [0.5184, 0.2927, 0.5879, 0.3141]}, {"w": "the", "b": [0.5941, 0.2927, 0.6204, 0.3141]}, {"w": "\"NEAR", "b": [0.6266, 0.2959, 0.6761, 0.311]}, {"w": "BAY\"", "b": [0.6874, 0.2959, 0.727, 0.311]}, {"w": "category", "b": [0.7332, 0.2927, 0.8042, 0.3141]}, {"w": "could", "b": [0.8104, 0.2927, 0.8572, 0.3141]}, {"w": "be", "b": [0.1429, 0.3127, 0.1623, 0.3341]}, {"w": "represented", "b": [0.1677, 0.3127, 0.2655, 0.3341]}, {"w": "initially", "b": [0.2709, 0.3127, 0.3346, 0.3341]}, {"w": "by", "b": [0.34, 0.3127, 0.3602, 0.3341]}, {"w": "a", "b": [0.3656, 0.3127, 0.3747, 0.3341]}, {"w": "random", "b": [0.3801, 0.3127, 0.4471, 0.3341]}, {"w": "vector", "b": [0.4525, 0.3127, 0.5045, 0.3341]}, {"w": "such", "b": [0.5099, 0.3127, 0.5485, 0.3341]}, {"w": "as", "b": [0.5539, 0.3127, 0.5707, 0.3341]}, {"w": "[0.131,", "b": [0.5761, 0.3158, 0.6454, 0.3309]}, {"w": "0.890],", "b": [0.6553, 0.3127, 0.72, 0.3341]}, {"w": "while", "b": [0.7254, 0.3127, 0.7705, 0.3341]}, {"w": "the", "b": [0.7759, 0.3127, 0.8023, 0.3341]}, {"w": "\"NEAR", "b": [0.8077, 0.3158, 0.8571, 0.3309]}, {"w": "OCEAN\"", "b": [0.1429, 0.3358, 0.2022, 0.3509]}, {"w": "category", "b": [0.2115, 0.3326, 0.2826, 0.354]}, {"w": "may", "b": [0.2919, 0.3326, 0.3272, 0.354]}, {"w": "be", "b": [0.3365, 0.3326, 0.356, 0.354]}, {"w": "represented", "b": [0.3653, 0.3326, 0.4631, 0.354]}, {"w": "by", "b": [0.4723, 0.3326, 0.4925, 0.354]}, {"w": "another", "b": [0.5018, 0.3326, 0.567, 0.354]}, {"w": "random", "b": [0.5763, 0.3326, 0.6433, 0.354]}, {"w": "vector", "b": [0.6525, 0.3326, 0.7046, 0.354]}, {"w": "such", "b": [0.7139, 0.3326, 0.7525, 0.354]}, {"w": "as", "b": [0.7618, 0.3326, 0.7786, 0.354]}, {"w": "[0.631,", "b": [0.7879, 0.3358, 0.8571, 0.3509]}, {"w": "0.791]", "b": [0.1429, 0.3557, 0.2022, 0.3708]}, {"w": "(in", "b": [0.2073, 0.3526, 0.2314, 0.374]}, {"w": "this", "b": [0.2365, 0.3526, 0.2672, 0.374]}, {"w": "example,", "b": [0.2722, 0.3526, 0.3465, 0.374]}, {"w": "we", "b": [0.3515, 0.3526, 0.3747, 0.374]}, {"w": "are", "b": [0.3797, 0.3526, 0.4054, 0.374]}, {"w": "using", "b": [0.4105, 0.3526, 0.4559, 0.374]}, {"w": "2D", "b": [0.4609, 0.3526, 0.4863, 0.374]}, {"w": "embeddings,", "b": [0.4913, 0.3526, 0.5978, 0.374]}, {"w": "but", "b": [0.6028, 0.3526, 0.6308, 0.374]}, {"w": "the", "b": [0.6358, 0.3526, 0.6622, 0.374]}, {"w": "number", "b": [0.6672, 0.3526, 0.7335, 0.374]}, {"w": "of", "b": [0.7385, 0.3526, 0.7553, 0.374]}, {"w": "dimensions", "b": [0.7603, 0.3526, 0.8571, 0.374]}, {"w": "is", "b": [0.1429, 0.3716, 0.1561, 0.393]}, {"w": "a", "b": [0.1625, 0.3716, 0.1717, 0.393]}, {"w": "hyperparameter", "b": [0.1781, 0.3716, 0.3116, 0.393]}, {"w": "you", "b": [0.318, 0.3716, 0.3492, 0.393]}, {"w": "can", "b": [0.3556, 0.3716, 0.385, 0.393]}, {"w": "tweak).", "b": [0.3914, 0.3716, 0.4523, 0.393]}, {"w": "Since", "b": [0.4587, 0.3716, 0.5033, 0.393]}, {"w": "these", "b": [0.5097, 0.3716, 0.5525, 0.393]}, {"w": "embeddings", "b": [0.5589, 0.3716, 0.6607, 0.393]}, {"w": "are", "b": [0.6671, 0.3716, 0.6928, 0.393]}, {"w": "trainable,", "b": [0.6992, 0.3716, 0.778, 0.393]}, {"w": "they", "b": [0.7844, 0.3716, 0.8203, 0.393]}, {"w": "will", "b": [0.8268, 0.3716, 0.8572, 0.393]}, {"w": "gradually", "b": [0.1429, 0.3906, 0.2208, 0.4121]}, {"w": "improve", "b": [0.2295, 0.3906, 0.2995, 0.4121]}, {"w": "during", "b": [0.3082, 0.3906, 0.3647, 0.4121]}, {"w": "training,", "b": [0.3734, 0.3906, 0.4451, 0.4121]}, {"w": "and", "b": [0.4537, 0.3906, 0.4853, 0.4121]}, {"w": "as", "b": [0.494, 0.3906, 0.5107, 0.4121]}, {"w": "they", "b": [0.5194, 0.3906, 0.5553, 0.4121]}, {"w": "represent", "b": [0.564, 0.3906, 0.6419, 0.4121]}, {"w": "fairly", "b": [0.6506, 0.3906, 0.6941, 0.4121]}, {"w": "similar", "b": [0.7027, 0.3906, 0.7608, 0.4121]}, {"w": "categories,", "b": [0.7694, 0.3906, 0.8571, 0.4121]}, {"w": "Gradient", "b": [0.1429, 0.4097, 0.2174, 0.4311]}, {"w": "Descent", "b": [0.2254, 0.4097, 0.2923, 0.4311]}, {"w": "will", "b": [0.3003, 0.4097, 0.3307, 0.4311]}, {"w": "certainly", "b": [0.3387, 0.4097, 0.4114, 0.4311]}, {"w": "end", "b": [0.4194, 0.4097, 0.4507, 0.4311]}, {"w": "up", "b": [0.4587, 0.4097, 0.4807, 0.4311]}, {"w": "pushing", "b": [0.4887, 0.4097, 0.5562, 0.4311]}, {"w": "them", "b": [0.5642, 0.4097, 0.6076, 0.4311]}, {"w": "closer", "b": [0.6156, 0.4097, 0.6645, 0.4311]}, {"w": "together,", "b": [0.6726, 0.4097, 0.7456, 0.4311]}, {"w": "while", "b": [0.7537, 0.4097, 0.7988, 0.4311]}, {"w": "it", "b": [0.8068, 0.4097, 0.8187, 0.4311]}, {"w": "will", "b": [0.8267, 0.4097, 0.8571, 0.4311]}, {"w": "tend", "b": [0.1429, 0.4296, 0.1805, 0.4511]}, {"w": "to", "b": [0.1863, 0.4296, 0.2033, 0.4511]}, {"w": "move", "b": [0.2092, 0.4296, 0.2554, 0.4511]}, {"w": "them", "b": [0.2612, 0.4296, 0.3046, 0.4511]}, {"w": "away", "b": [0.3105, 0.4296, 0.3518, 0.4511]}, {"w": "from", "b": [0.3577, 0.4296, 0.3993, 0.4511]}, {"w": "the", "b": [0.4051, 0.4296, 0.4315, 0.4511]}, {"w": "\"INLAND\"", "b": [0.4373, 0.4328, 0.5165, 0.4479]}, {"w": "category’s", "b": [0.5224, 0.4296, 0.6037, 0.4511]}, {"w": "embedding", "b": [0.6096, 0.4296, 0.7036, 0.4511]}, {"w": "(see", "b": [0.7095, 0.4296, 0.7421, 0.4511]}, {"w": "Figure", "b": [0.7479, 0.4296, 0.8019, 0.4511]}, {"w": "13-4).", "b": [0.8078, 0.4296, 0.8572, 0.4511]}, {"w": "Indeed,", "b": [0.1429, 0.4487, 0.2058, 0.4701]}, {"w": "the", "b": [0.2128, 0.4487, 0.2391, 0.4701]}, {"w": "better", "b": [0.2461, 0.4487, 0.2949, 0.4701]}, {"w": "the", "b": [0.3018, 0.4487, 0.3282, 0.4701]}, {"w": "representation,", "b": [0.3351, 0.4487, 0.4605, 0.4701]}, {"w": "the", "b": [0.4675, 0.4487, 0.4939, 0.4701]}, {"w": "easier", "b": [0.5008, 0.4487, 0.5487, 0.4701]}, {"w": "it", "b": [0.5556, 0.4487, 0.5676, 0.4701]}, {"w": "will", "b": [0.5746, 0.4487, 0.605, 0.4701]}, {"w": "be", "b": [0.6119, 0.4487, 0.6314, 0.4701]}, {"w": "for", "b": [0.6384, 0.4487, 0.6629, 0.4701]}, {"w": "the", "b": [0.6699, 0.4487, 0.6962, 0.4701]}, {"w": "neural", "b": [0.7032, 0.4487, 0.7566, 0.4701]}, {"w": "network", "b": [0.7636, 0.4487, 0.8332, 0.4701]}, {"w": "to", "b": [0.8402, 0.4487, 0.8571, 0.4701]}, {"w": "make", "b": [0.1429, 0.4677, 0.1883, 0.4891]}, {"w": "accurate", "b": [0.1944, 0.4677, 0.2639, 0.4891]}, {"w": "predictions,", "b": [0.27, 0.4677, 0.3692, 0.4891]}, {"w": "so", "b": [0.3753, 0.4677, 0.3936, 0.4891]}, {"w": "training", "b": [0.3997, 0.4677, 0.4666, 0.4891]}, {"w": "tends", "b": [0.4727, 0.4677, 0.518, 0.4891]}, {"w": "to", "b": [0.5241, 0.4677, 0.5411, 0.4891]}, {"w": "make", "b": [0.5472, 0.4677, 0.5926, 0.4891]}, {"w": "embeddings", "b": [0.5987, 0.4677, 0.7004, 0.4891]}, {"w": "useful", "b": [0.7065, 0.4677, 0.7565, 0.4891]}, {"w": "representa‐", "b": [0.7626, 0.4677, 0.8571, 0.4891]}, {"w": "tions", "b": [0.1429, 0.4868, 0.1845, 0.5082]}, {"w": "of", "b": [0.1895, 0.4868, 0.2063, 0.5082]}, {"w": "the", "b": [0.2113, 0.4868, 0.2376, 0.5082]}, {"w": "categories.", "b": [0.2426, 0.4868, 0.3303, 0.5082]}, {"w": "This", "b": [0.3353, 0.4868, 0.3725, 0.5082]}, {"w": "is", "b": [0.3776, 0.4868, 0.3908, 0.5082]}, {"w": "called", "b": [0.3958, 0.4868, 0.4441, 0.5082]}, {"w": "representation", "b": [0.4492, 0.4866, 0.5644, 0.5082]}, {"w": "learning", "b": [0.5692, 0.4866, 0.6359, 0.5082]}, {"w": "(we", "b": [0.6412, 0.4868, 0.6715, 0.5082]}, {"w": "will", "b": [0.6765, 0.4868, 0.7069, 0.5082]}, {"w": "see", "b": [0.7119, 0.4868, 0.7373, 0.5082]}, {"w": "other", "b": [0.7423, 0.4868, 0.787, 0.5082]}, {"w": "types", "b": [0.792, 0.4868, 0.8353, 0.5082]}, {"w": "of", "b": [0.8403, 0.4868, 0.8571, 0.5082]}, {"w": "representation", "b": [0.1429, 0.5058, 0.2635, 0.5272]}, {"w": "learning", "b": [0.2682, 0.5058, 0.3374, 0.5272]}, {"w": "in", "b": [0.3421, 0.5058, 0.3591, 0.5272]}, {"w": "???).", "b": [0.3638, 0.5058, 0.3994, 0.5272]}]}, {"id": "b_3", "type": "paragraph", "text": "The Features API | 423", "words": [{"w": "The", "b": [0.6981, 0.9225, 0.7196, 0.9388]}, {"w": "Features", "b": [0.7224, 0.9225, 0.7733, 0.9388]}, {"w": "API", "b": [0.7761, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "423", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 450, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "10 “Distributed Representations of Words and Phrases and their Compositionality”, T. Mikolov et al. (2013).", "words": [{"w": "10", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Distributed", "b": [0.1587, 0.8749, 0.2382, 0.8912]}, {"w": "Representations", "b": [0.2418, 0.8749, 0.3436, 0.8912]}, {"w": "of", "b": [0.3472, 0.8749, 0.36, 0.8912]}, {"w": "Words", "b": [0.3636, 0.8749, 0.4056, 0.8912]}, {"w": "and", "b": [0.4092, 0.8749, 0.4333, 0.8912]}, {"w": "Phrases", "b": [0.4369, 0.8749, 0.4855, 0.8912]}, {"w": "and", "b": [0.4891, 0.8749, 0.5132, 0.8912]}, {"w": "their", "b": [0.5168, 0.8749, 0.547, 0.8912]}, {"w": "Compositionality”,", "b": [0.5506, 0.8749, 0.6691, 0.8912]}, {"w": "T.", "b": [0.6727, 0.8749, 0.6845, 0.8912]}, {"w": "Mikolov", "b": [0.6881, 0.8749, 0.742, 0.8912]}, {"w": "et", "b": [0.7456, 0.8749, 0.7572, 0.8912]}, {"w": "al.", "b": [0.7608, 0.8749, 0.7754, 0.8912]}, {"w": "(2013).", "b": [0.779, 0.8749, 0.824, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 13-4. Embeddings Will Gradually Improve During Training", "words": [{"w": "Figure", "b": [0.1429, 0.3601, 0.1943, 0.3817]}, {"w": "13-4.", "b": [0.1991, 0.3601, 0.2407, 0.3817]}, {"w": "Embeddings", "b": [0.2455, 0.3601, 0.344, 0.3817]}, {"w": "Will", "b": [0.3487, 0.3601, 0.3833, 0.3817]}, {"w": "Gradually", "b": [0.3881, 0.3601, 0.4698, 0.3817]}, {"w": "Improve", "b": [0.4745, 0.3601, 0.541, 0.3817]}, {"w": "During", "b": [0.5458, 0.3601, 0.6042, 0.3817]}, {"w": "Training", "b": [0.609, 0.3601, 0.6782, 0.3817]}]}, {"id": "b_2", "type": "paragraph", "text": "Word Embeddings", "words": [{"w": "Word", "b": [0.4106, 0.4105, 0.4635, 0.4376]}, {"w": "Embeddings", "b": [0.4682, 0.4105, 0.5893, 0.4376]}]}, {"id": "b_3", "type": "paragraph", "text": "Not only will embeddings generally be useful representations for the task at hand, but quite often these same embeddings can be reused successfully for other tasks as well. The most common example of this is word embeddings (i.e., embeddings of individual words): when you are working on a natural language processing task, you are often better off reusing pretrained word embeddings than training your own. The idea of using vectors to represent words dates back to the 1960s, and many sophisticated techniques have been used to generate useful vectors, including using neural net‐ works, but things really took off in 2013, when Tomáš Mikolov and other Google researchers published a paper10 describing how to learn word embeddings using deep neural networks, much faster than previous attempts. This allowed them to learn embeddings on a very large corpus of text: they trained a deep neural network to pre‐ dict the words near any given word. This allowed them to obtain astounding word embeddings. For example, synonyms had very close embeddings, and semantically related words such as France, Spain, Italy, and so on, ended up clustered together. But it’s not just about proximity: word embeddings were also organized along meaningful axes in the embedding space. Here is a famous example: if you compute King – Man + Woman (adding and subtracting the embedding vectors of these words), then the result will be very close to the embedding of the word Queen (see Figure 13-5). In other words, the word embeddings encode the concept of gender! Similarly, you can compute Madrid – Spain + France, and of course the result is close to Paris, which seems to show that the notion of capital city was also encoded in the embeddings.", "words": [{"w": "Not", "b": [0.1592, 0.4422, 0.1896, 0.4626]}, {"w": "only", "b": [0.1945, 0.4422, 0.2296, 0.4626]}, {"w": "will", "b": [0.2344, 0.4422, 0.2634, 0.4626]}, {"w": "embeddings", "b": [0.2682, 0.4422, 0.3651, 0.4626]}, {"w": "generally", "b": [0.37, 0.4422, 0.4422, 0.4626]}, {"w": "be", "b": [0.447, 0.4422, 0.4656, 0.4626]}, {"w": "useful", "b": [0.4704, 0.4422, 0.5181, 0.4626]}, {"w": "representations", "b": [0.5229, 0.4422, 0.6451, 0.4626]}, {"w": "for", "b": [0.65, 0.4422, 0.6733, 0.4626]}, {"w": "the", "b": [0.6782, 0.4422, 0.7033, 0.4626]}, {"w": "task", "b": [0.7081, 0.4422, 0.74, 0.4626]}, {"w": "at", "b": [0.7449, 0.4422, 0.7592, 0.4626]}, {"w": "hand,", "b": [0.7641, 0.4422, 0.8092, 0.4626]}, {"w": "but", "b": [0.8141, 0.4422, 0.8408, 0.4626]}, {"w": "quite", "b": [0.1592, 0.4603, 0.1997, 0.4807]}, {"w": "often", "b": [0.2052, 0.4603, 0.2465, 0.4807]}, {"w": "these", "b": [0.252, 0.4603, 0.2928, 0.4807]}, {"w": "same", "b": [0.2983, 0.4603, 0.339, 0.4807]}, {"w": "embeddings", "b": [0.3445, 0.4603, 0.4414, 0.4807]}, {"w": "can", "b": [0.4469, 0.4603, 0.4749, 0.4807]}, {"w": "be", "b": [0.4804, 0.4603, 0.4989, 0.4807]}, {"w": "reused", "b": [0.5044, 0.4603, 0.5569, 0.4807]}, {"w": "successfully", "b": [0.5624, 0.4603, 0.6556, 0.4807]}, {"w": "for", "b": [0.6611, 0.4603, 0.6844, 0.4807]}, {"w": "other", "b": [0.6899, 0.4603, 0.7325, 0.4807]}, {"w": "tasks", "b": [0.738, 0.4603, 0.7772, 0.4807]}, {"w": "as", "b": [0.7827, 0.4603, 0.7987, 0.4807]}, {"w": "well.", "b": [0.8042, 0.4603, 0.8408, 0.4807]}, {"w": "The", "b": [0.1592, 0.4785, 0.1905, 0.4989]}, {"w": "most", "b": [0.1952, 0.4785, 0.2349, 0.4989]}, {"w": "common", "b": [0.2395, 0.4785, 0.3115, 0.4989]}, {"w": "example", "b": [0.3162, 0.4785, 0.3824, 0.4989]}, {"w": "of", "b": [0.3871, 0.4785, 0.4031, 0.4989]}, {"w": "this", "b": [0.4077, 0.4785, 0.437, 0.4989]}, {"w": "is", "b": [0.4416, 0.4785, 0.4542, 0.4989]}, {"w": "word", "b": [0.4589, 0.4783, 0.4982, 0.4989]}, {"w": "embeddings", "b": [0.5027, 0.4783, 0.5937, 0.4989]}, {"w": "(i.e.,", "b": [0.5985, 0.4785, 0.6327, 0.4989]}, {"w": "embeddings", "b": [0.6372, 0.4785, 0.7341, 0.4989]}, {"w": "of", "b": [0.7386, 0.4785, 0.7546, 0.4989]}, {"w": "individual", "b": [0.7591, 0.4785, 0.8403, 0.4989]}, {"w": "words):", "b": [0.1592, 0.4966, 0.2194, 0.517]}, {"w": "when", "b": [0.2258, 0.4966, 0.2693, 0.517]}, {"w": "you", "b": [0.2757, 0.4966, 0.3055, 0.517]}, {"w": "are", "b": [0.3119, 0.4966, 0.3364, 0.517]}, {"w": "working", "b": [0.3428, 0.4966, 0.4091, 0.517]}, {"w": "on", "b": [0.4155, 0.4966, 0.4365, 0.517]}, {"w": "a", "b": [0.4429, 0.4966, 0.4516, 0.517]}, {"w": "natural", "b": [0.458, 0.4966, 0.5149, 0.517]}, {"w": "language", "b": [0.5213, 0.4966, 0.5921, 0.517]}, {"w": "processing", "b": [0.5985, 0.4966, 0.6832, 0.517]}, {"w": "task,", "b": [0.6896, 0.4966, 0.726, 0.517]}, {"w": "you", "b": [0.7324, 0.4966, 0.7622, 0.517]}, {"w": "are", "b": [0.7686, 0.4966, 0.7931, 0.517]}, {"w": "often", "b": [0.7994, 0.4966, 0.8408, 0.517]}, {"w": "better", "b": [0.1592, 0.5148, 0.2056, 0.5351]}, {"w": "off", "b": [0.212, 0.5148, 0.2338, 0.5351]}, {"w": "reusing", "b": [0.2402, 0.5148, 0.2992, 0.5351]}, {"w": "pretrained", "b": [0.3056, 0.5148, 0.389, 0.5351]}, {"w": "word", "b": [0.3953, 0.5148, 0.4368, 0.5351]}, {"w": "embeddings", "b": [0.4432, 0.5148, 0.5401, 0.5351]}, {"w": "than", "b": [0.5464, 0.5148, 0.5826, 0.5351]}, {"w": "training", "b": [0.5889, 0.5148, 0.6527, 0.5351]}, {"w": "your", "b": [0.659, 0.5148, 0.6962, 0.5351]}, {"w": "own.", "b": [0.7025, 0.5148, 0.7416, 0.5351]}, {"w": "The", "b": [0.7479, 0.5148, 0.7792, 0.5351]}, {"w": "idea", "b": [0.7855, 0.5148, 0.8185, 0.5351]}, {"w": "of", "b": [0.8248, 0.5148, 0.8408, 0.5351]}, {"w": "using", "b": [0.1592, 0.5329, 0.2025, 0.5533]}, {"w": "vectors", "b": [0.2104, 0.5329, 0.2672, 0.5533]}, {"w": "to", "b": [0.2751, 0.5329, 0.2913, 0.5533]}, {"w": "represent", "b": [0.2992, 0.5329, 0.3735, 0.5533]}, {"w": "words", "b": [0.3814, 0.5329, 0.4302, 0.5533]}, {"w": "dates", "b": [0.4381, 0.5329, 0.4787, 0.5533]}, {"w": "back", "b": [0.4866, 0.5329, 0.5236, 0.5533]}, {"w": "to", "b": [0.5315, 0.5329, 0.5477, 0.5533]}, {"w": "the", "b": [0.5556, 0.5329, 0.5807, 0.5533]}, {"w": "1960s,", "b": [0.5886, 0.5329, 0.6385, 0.5533]}, {"w": "and", "b": [0.6464, 0.5329, 0.6764, 0.5533]}, {"w": "many", "b": [0.6844, 0.5329, 0.7288, 0.5533]}, {"w": "sophisticated", "b": [0.7367, 0.5329, 0.8408, 0.5533]}, {"w": "techniques", "b": [0.1592, 0.551, 0.2453, 0.5714]}, {"w": "have", "b": [0.2534, 0.551, 0.29, 0.5714]}, {"w": "been", "b": [0.2981, 0.551, 0.3359, 0.5714]}, {"w": "used", "b": [0.344, 0.551, 0.3807, 0.5714]}, {"w": "to", "b": [0.3889, 0.551, 0.405, 0.5714]}, {"w": "generate", "b": [0.4132, 0.551, 0.4803, 0.5714]}, {"w": "useful", "b": [0.4885, 0.551, 0.5362, 0.5714]}, {"w": "vectors,", "b": [0.5443, 0.551, 0.6056, 0.5714]}, {"w": "including", "b": [0.6138, 0.551, 0.6898, 0.5714]}, {"w": "using", "b": [0.6979, 0.551, 0.7412, 0.5714]}, {"w": "neural", "b": [0.7493, 0.551, 0.8002, 0.5714]}, {"w": "net‐", "b": [0.8084, 0.551, 0.8408, 0.5714]}, {"w": "works,", "b": [0.1592, 0.5692, 0.2119, 0.5896]}, {"w": "but", "b": [0.2196, 0.5692, 0.2462, 0.5896]}, {"w": "things", "b": [0.2539, 0.5692, 0.3033, 0.5896]}, {"w": "really", "b": [0.3109, 0.5692, 0.3545, 0.5896]}, {"w": "took", "b": [0.3622, 0.5692, 0.3983, 0.5896]}, {"w": "off", "b": [0.4059, 0.5692, 0.4278, 0.5896]}, {"w": "in", "b": [0.4354, 0.5692, 0.4516, 0.5896]}, {"w": "2013,", "b": [0.4592, 0.5692, 0.5018, 0.5896]}, {"w": "when", "b": [0.5095, 0.5692, 0.5529, 0.5896]}, {"w": "Tomáš", "b": [0.5606, 0.5692, 0.6132, 0.5896]}, {"w": "Mikolov", "b": [0.6208, 0.5692, 0.6881, 0.5896]}, {"w": "and", "b": [0.6958, 0.5692, 0.7258, 0.5896]}, {"w": "other", "b": [0.7334, 0.5692, 0.776, 0.5896]}, {"w": "Google", "b": [0.7836, 0.5692, 0.8408, 0.5896]}, {"w": "researchers", "b": [0.1592, 0.5873, 0.2489, 0.6077]}, {"w": "published", "b": [0.2539, 0.5873, 0.3321, 0.6077]}, {"w": "a", "b": [0.3371, 0.5873, 0.3458, 0.6077]}, {"w": "paper10", "b": [0.3509, 0.5873, 0.4072, 0.6077]}, {"w": "describing", "b": [0.4123, 0.5873, 0.4951, 0.6077]}, {"w": "how", "b": [0.5001, 0.5873, 0.5345, 0.6077]}, {"w": "to", "b": [0.5395, 0.5873, 0.5557, 0.6077]}, {"w": "learn", "b": [0.5607, 0.5873, 0.6011, 0.6077]}, {"w": "word", "b": [0.6062, 0.5873, 0.6477, 0.6077]}, {"w": "embeddings", "b": [0.6528, 0.5873, 0.7497, 0.6077]}, {"w": "using", "b": [0.7547, 0.5873, 0.798, 0.6077]}, {"w": "deep", "b": [0.803, 0.5873, 0.8408, 0.6077]}, {"w": "neural", "b": [0.1592, 0.6055, 0.2101, 0.6258]}, {"w": "networks,", "b": [0.2184, 0.6055, 0.2965, 0.6258]}, {"w": "much", "b": [0.3047, 0.6055, 0.3501, 0.6258]}, {"w": "faster", "b": [0.3584, 0.6055, 0.4021, 0.6258]}, {"w": "than", "b": [0.4104, 0.6055, 0.4466, 0.6258]}, {"w": "previous", "b": [0.4549, 0.6055, 0.5235, 0.6258]}, {"w": "attempts.", "b": [0.5318, 0.6055, 0.6048, 0.6258]}, {"w": "This", "b": [0.613, 0.6055, 0.6485, 0.6258]}, {"w": "allowed", "b": [0.6567, 0.6055, 0.7181, 0.6258]}, {"w": "them", "b": [0.7264, 0.6055, 0.7677, 0.6258]}, {"w": "to", "b": [0.776, 0.6055, 0.7921, 0.6258]}, {"w": "learn", "b": [0.8004, 0.6055, 0.8408, 0.6258]}, {"w": "embeddings", "b": [0.1592, 0.6236, 0.2561, 0.644]}, {"w": "on", "b": [0.261, 0.6236, 0.2819, 0.644]}, {"w": "a", "b": [0.2868, 0.6236, 0.2955, 0.644]}, {"w": "very", "b": [0.3003, 0.6236, 0.335, 0.644]}, {"w": "large", "b": [0.3398, 0.6236, 0.3786, 0.644]}, {"w": "corpus", "b": [0.3835, 0.6236, 0.4376, 0.644]}, {"w": "of", "b": [0.4424, 0.6236, 0.4584, 0.644]}, {"w": "text:", "b": [0.4632, 0.6236, 0.4976, 0.644]}, {"w": "they", "b": [0.5025, 0.6236, 0.5367, 0.644]}, {"w": "trained", "b": [0.5415, 0.6236, 0.5987, 0.644]}, {"w": "a", "b": [0.6036, 0.6236, 0.6123, 0.644]}, {"w": "deep", "b": [0.6171, 0.6236, 0.6548, 0.644]}, {"w": "neural", "b": [0.6597, 0.6236, 0.7106, 0.644]}, {"w": "network", "b": [0.7154, 0.6236, 0.7817, 0.644]}, {"w": "to", "b": [0.7865, 0.6236, 0.8027, 0.644]}, {"w": "pre‐", "b": [0.8075, 0.6236, 0.8408, 0.644]}, {"w": "dict", "b": [0.1592, 0.6417, 0.1895, 0.6621]}, {"w": "the", "b": [0.1963, 0.6417, 0.2213, 0.6621]}, {"w": "words", "b": [0.2281, 0.6417, 0.277, 0.6621]}, {"w": "near", "b": [0.2837, 0.6417, 0.3191, 0.6621]}, {"w": "any", "b": [0.3259, 0.6417, 0.3541, 0.6621]}, {"w": "given", "b": [0.3609, 0.6417, 0.404, 0.6621]}, {"w": "word.", "b": [0.4107, 0.6417, 0.4568, 0.6621]}, {"w": "This", "b": [0.4636, 0.6417, 0.499, 0.6621]}, {"w": "allowed", "b": [0.5058, 0.6417, 0.5672, 0.6621]}, {"w": "them", "b": [0.574, 0.6417, 0.6153, 0.6621]}, {"w": "to", "b": [0.6221, 0.6417, 0.6383, 0.6621]}, {"w": "obtain", "b": [0.645, 0.6417, 0.6962, 0.6621]}, {"w": "astounding", "b": [0.703, 0.6417, 0.7924, 0.6621]}, {"w": "word", "b": [0.7992, 0.6417, 0.8408, 0.6621]}, {"w": "embeddings.", "b": [0.1592, 0.6599, 0.2606, 0.6803]}, {"w": "For", "b": [0.2681, 0.6599, 0.2957, 0.6803]}, {"w": "example,", "b": [0.3032, 0.6599, 0.374, 0.6803]}, {"w": "synonyms", "b": [0.3815, 0.6599, 0.4619, 0.6803]}, {"w": "had", "b": [0.4694, 0.6599, 0.4992, 0.6803]}, {"w": "very", "b": [0.5067, 0.6599, 0.5413, 0.6803]}, {"w": "close", "b": [0.5488, 0.6599, 0.5881, 0.6803]}, {"w": "embeddings,", "b": [0.5956, 0.6599, 0.697, 0.6803]}, {"w": "and", "b": [0.7045, 0.6599, 0.7345, 0.6803]}, {"w": "semantically", "b": [0.742, 0.6599, 0.8408, 0.6803]}, {"w": "related", "b": [0.1592, 0.678, 0.2133, 0.6984]}, {"w": "words", "b": [0.2182, 0.678, 0.267, 0.6984]}, {"w": "such", "b": [0.2718, 0.678, 0.3086, 0.6984]}, {"w": "as", "b": [0.3134, 0.678, 0.3294, 0.6984]}, {"w": "France,", "b": [0.3343, 0.678, 0.393, 0.6984]}, {"w": "Spain,", "b": [0.3978, 0.678, 0.447, 0.6984]}, {"w": "Italy,", "b": [0.4519, 0.678, 0.4898, 0.6984]}, {"w": "and", "b": [0.4946, 0.678, 0.5247, 0.6984]}, {"w": "so", "b": [0.5295, 0.678, 0.5469, 0.6984]}, {"w": "on,", "b": [0.5517, 0.678, 0.5772, 0.6984]}, {"w": "ended", "b": [0.582, 0.678, 0.6307, 0.6984]}, {"w": "up", "b": [0.6355, 0.678, 0.6565, 0.6984]}, {"w": "clustered", "b": [0.6613, 0.678, 0.7333, 0.6984]}, {"w": "together.", "b": [0.7381, 0.678, 0.8077, 0.6984]}, {"w": "But", "b": [0.8125, 0.678, 0.8408, 0.6984]}, {"w": "it’s", "b": [0.1592, 0.6962, 0.1799, 0.7165]}, {"w": "not", "b": [0.1848, 0.6962, 0.2118, 0.7165]}, {"w": "just", "b": [0.2167, 0.6962, 0.2456, 0.7165]}, {"w": "about", "b": [0.2505, 0.6962, 0.296, 0.7165]}, {"w": "proximity:", "b": [0.3009, 0.6962, 0.3853, 0.7165]}, {"w": "word", "b": [0.3901, 0.6962, 0.4317, 0.7165]}, {"w": "embeddings", "b": [0.4366, 0.6962, 0.5335, 0.7165]}, {"w": "were", "b": [0.5383, 0.6962, 0.5761, 0.7165]}, {"w": "also", "b": [0.581, 0.6962, 0.6122, 0.7165]}, {"w": "organized", "b": [0.617, 0.6962, 0.6959, 0.7165]}, {"w": "along", "b": [0.7008, 0.6962, 0.7448, 0.7165]}, {"w": "meaningful", "b": [0.7496, 0.6962, 0.8408, 0.7165]}, {"w": "axes", "b": [0.1592, 0.7143, 0.193, 0.7347]}, {"w": "in", "b": [0.1985, 0.7143, 0.2147, 0.7347]}, {"w": "the", "b": [0.2202, 0.7143, 0.2453, 0.7347]}, {"w": "embedding", "b": [0.2508, 0.7143, 0.3404, 0.7347]}, {"w": "space.", "b": [0.3459, 0.7143, 0.3936, 0.7347]}, {"w": "Here", "b": [0.3992, 0.7143, 0.4381, 0.7347]}, {"w": "is", "b": [0.4436, 0.7143, 0.4562, 0.7347]}, {"w": "a", "b": [0.4617, 0.7143, 0.4704, 0.7347]}, {"w": "famous", "b": [0.4759, 0.7143, 0.5347, 0.7347]}, {"w": "example:", "b": [0.5402, 0.7143, 0.6109, 0.7347]}, {"w": "if", "b": [0.6165, 0.7143, 0.6276, 0.7347]}, {"w": "you", "b": [0.6332, 0.7143, 0.6629, 0.7347]}, {"w": "compute", "b": [0.6684, 0.7143, 0.7382, 0.7347]}, {"w": "King", "b": [0.7437, 0.7143, 0.7825, 0.7347]}, {"w": "–", "b": [0.788, 0.7143, 0.7984, 0.7347]}, {"w": "Man", "b": [0.8039, 0.7143, 0.8408, 0.7347]}, {"w": "+", "b": [0.1592, 0.7324, 0.1707, 0.7528]}, {"w": "Woman", "b": [0.177, 0.7324, 0.2403, 0.7528]}, {"w": "(adding", "b": [0.2466, 0.7324, 0.3085, 0.7528]}, {"w": "and", "b": [0.3148, 0.7324, 0.3449, 0.7528]}, {"w": "subtracting", "b": [0.3511, 0.7324, 0.4411, 0.7528]}, {"w": "the", "b": [0.4473, 0.7324, 0.4724, 0.7528]}, {"w": "embedding", "b": [0.4787, 0.7324, 0.5683, 0.7528]}, {"w": "vectors", "b": [0.5746, 0.7324, 0.6314, 0.7528]}, {"w": "of", "b": [0.6377, 0.7324, 0.6537, 0.7528]}, {"w": "these", "b": [0.6599, 0.7324, 0.7007, 0.7528]}, {"w": "words),", "b": [0.707, 0.7324, 0.7672, 0.7528]}, {"w": "then", "b": [0.7735, 0.7324, 0.8094, 0.7528]}, {"w": "the", "b": [0.8157, 0.7324, 0.8408, 0.7528]}, {"w": "result", "b": [0.1592, 0.7506, 0.2039, 0.771]}, {"w": "will", "b": [0.2107, 0.7506, 0.2397, 0.771]}, {"w": "be", "b": [0.2465, 0.7506, 0.265, 0.771]}, {"w": "very", "b": [0.2718, 0.7506, 0.3064, 0.771]}, {"w": "close", "b": [0.3132, 0.7506, 0.3525, 0.771]}, {"w": "to", "b": [0.3593, 0.7506, 0.3754, 0.771]}, {"w": "the", "b": [0.3822, 0.7506, 0.4073, 0.771]}, {"w": "embedding", "b": [0.4141, 0.7506, 0.5037, 0.771]}, {"w": "of", "b": [0.5105, 0.7506, 0.5265, 0.771]}, {"w": "the", "b": [0.5333, 0.7506, 0.5584, 0.771]}, {"w": "word", "b": [0.5651, 0.7506, 0.6067, 0.771]}, {"w": "Queen", "b": [0.6135, 0.7506, 0.6665, 0.771]}, {"w": "(see", "b": [0.6733, 0.7506, 0.7043, 0.771]}, {"w": "Figure", "b": [0.7111, 0.7506, 0.7625, 0.771]}, {"w": "13-5).", "b": [0.7693, 0.7506, 0.8164, 0.771]}, {"w": "In", "b": [0.8232, 0.7506, 0.8408, 0.771]}, {"w": "other", "b": [0.1592, 0.7687, 0.2018, 0.7891]}, {"w": "words,", "b": [0.2075, 0.7687, 0.2609, 0.7891]}, {"w": "the", "b": [0.2667, 0.7687, 0.2917, 0.7891]}, {"w": "word", "b": [0.2975, 0.7687, 0.339, 0.7891]}, {"w": "embeddings", "b": [0.3448, 0.7687, 0.4417, 0.7891]}, {"w": "encode", "b": [0.4474, 0.7687, 0.5041, 0.7891]}, {"w": "the", "b": [0.5099, 0.7687, 0.535, 0.7891]}, {"w": "concept", "b": [0.5407, 0.7687, 0.6034, 0.7891]}, {"w": "of", "b": [0.6091, 0.7687, 0.6251, 0.7891]}, {"w": "gender!", "b": [0.6309, 0.7687, 0.6912, 0.7891]}, {"w": "Similarly,", "b": [0.697, 0.7687, 0.7715, 0.7891]}, {"w": "you", "b": [0.7773, 0.7687, 0.8071, 0.7891]}, {"w": "can", "b": [0.8128, 0.7687, 0.8408, 0.7891]}, {"w": "compute", "b": [0.1592, 0.7869, 0.229, 0.8073]}, {"w": "Madrid", "b": [0.2356, 0.7869, 0.2953, 0.8073]}, {"w": "–", "b": [0.3018, 0.7869, 0.3122, 0.8073]}, {"w": "Spain", "b": [0.3187, 0.7869, 0.3634, 0.8073]}, {"w": "+", "b": [0.37, 0.7869, 0.3815, 0.8073]}, {"w": "France,", "b": [0.388, 0.7869, 0.4468, 0.8073]}, {"w": "and", "b": [0.4534, 0.7869, 0.4834, 0.8073]}, {"w": "of", "b": [0.49, 0.7869, 0.506, 0.8073]}, {"w": "course", "b": [0.5125, 0.7869, 0.5646, 0.8073]}, {"w": "the", "b": [0.5712, 0.7869, 0.5963, 0.8073]}, {"w": "result", "b": [0.6028, 0.7869, 0.6475, 0.8073]}, {"w": "is", "b": [0.6541, 0.7869, 0.6667, 0.8073]}, {"w": "close", "b": [0.6733, 0.7869, 0.7125, 0.8073]}, {"w": "to", "b": [0.7191, 0.7869, 0.7352, 0.8073]}, {"w": "Paris,", "b": [0.7418, 0.7869, 0.7857, 0.8073]}, {"w": "which", "b": [0.7923, 0.7869, 0.8408, 0.8073]}, {"w": "seems", "b": [0.1592, 0.805, 0.2069, 0.8254]}, {"w": "to", "b": [0.2114, 0.805, 0.2276, 0.8254]}, {"w": "show", "b": [0.2321, 0.805, 0.2737, 0.8254]}, {"w": "that", "b": [0.2782, 0.805, 0.3092, 0.8254]}, {"w": "the", "b": [0.3137, 0.805, 0.3388, 0.8254]}, {"w": "notion", "b": [0.3433, 0.805, 0.3966, 0.8254]}, {"w": "of", "b": [0.4011, 0.805, 0.4171, 0.8254]}, {"w": "capital", "b": [0.4216, 0.805, 0.4738, 0.8254]}, {"w": "city", "b": [0.4783, 0.805, 0.5072, 0.8254]}, {"w": "was", "b": [0.5117, 0.805, 0.5413, 0.8254]}, {"w": "also", "b": [0.5458, 0.805, 0.5769, 0.8254]}, {"w": "encoded", "b": [0.5814, 0.805, 0.6486, 0.8254]}, {"w": "in", "b": [0.6531, 0.805, 0.6693, 0.8254]}, {"w": "the", "b": [0.6738, 0.805, 0.6989, 0.8254]}, {"w": "embeddings.", "b": [0.7034, 0.805, 0.8048, 0.8254]}]}, {"id": "b_4", "type": "paragraph", "text": "424 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "424", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 451, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 13-5. Word Embeddings", "words": [{"w": "Figure", "b": [0.1592, 0.421, 0.2082, 0.4416]}, {"w": "13-5.", "b": [0.2128, 0.421, 0.2524, 0.4416]}, {"w": "Word", "b": [0.257, 0.421, 0.3001, 0.4416]}, {"w": "Embeddings", "b": [0.3046, 0.421, 0.3984, 0.4416]}]}, {"id": "b_1", "type": "paragraph", "text": "Let’s go back to the Features API. Here is how you could encode the ocean_proxim ity categories as 2D embeddings:", "words": [{"w": "Let’s", "b": [0.1429, 0.4813, 0.179, 0.5027]}, {"w": "go", "b": [0.1857, 0.4813, 0.206, 0.5027]}, {"w": "back", "b": [0.2127, 0.4813, 0.2516, 0.5027]}, {"w": "to", "b": [0.2582, 0.4813, 0.2752, 0.5027]}, {"w": "the", "b": [0.2818, 0.4813, 0.3082, 0.5027]}, {"w": "Features", "b": [0.3148, 0.4813, 0.3847, 0.5027]}, {"w": "API.", "b": [0.3914, 0.4813, 0.4293, 0.5027]}, {"w": "Here", "b": [0.436, 0.4813, 0.4769, 0.5027]}, {"w": "is", "b": [0.4835, 0.4813, 0.4967, 0.5027]}, {"w": "how", "b": [0.5034, 0.4813, 0.5394, 0.5027]}, {"w": "you", "b": [0.5461, 0.4813, 0.5773, 0.5027]}, {"w": "could", "b": [0.584, 0.4813, 0.6307, 0.5027]}, {"w": "encode", "b": [0.6374, 0.4813, 0.6969, 0.5027]}, {"w": "the", "b": [0.7036, 0.4813, 0.7299, 0.5027]}, {"w": "ocean_proxim", "b": [0.7366, 0.4845, 0.8553, 0.4995]}, {"w": "ity", "b": [0.1429, 0.5044, 0.1725, 0.5195]}, {"w": "categories", "b": [0.1773, 0.5012, 0.2602, 0.5226]}, {"w": "as", "b": [0.265, 0.5012, 0.2817, 0.5226]}, {"w": "2D", "b": [0.2865, 0.5012, 0.3118, 0.5226]}, {"w": "embeddings:", "b": [0.3165, 0.5012, 0.423, 0.5226]}]}, {"id": "b_2", "type": "paragraph", "text": "ocean_proximity_embed = tf.feature_column.embedding_column(ocean_proximity, dimension=2)", "words": [{"w": "ocean_proximity_embed", "b": [0.1766, 0.5332, 0.3537, 0.546]}, {"w": "=", "b": [0.3621, 0.5332, 0.3705, 0.546]}, {"w": "tf.feature_column.embedding_column(ocean_proximity,", "b": [0.379, 0.5332, 0.809, 0.546]}, {"w": "dimension=2)", "b": [0.6741, 0.5486, 0.7753, 0.5615]}]}, {"id": "b_3", "type": "paragraph", "text": "Each of the five ocean_proximity categories will now be represented as a 2D vector. These vectors are stored in an embedding matrix with one row per category, and one column per embedding dimension, so in this example it is a 5×2 matrix. When an embedding column is given a category index as input (say, 3, which corresponds to the category \"NEAR BAY\"), it just performs a lookup in the embedding matrix and returns the corresponding row (say, [0.331, 0.190]). Unfortunately, the embedding matrix can be quite large, especially when you have a large vocabulary: if this is the case, the model can only learn good representations for the categories for which it has sufficient training data. To reduce the size of the embedding matrix, you can of course try lowering the dimension hyperparameter, but if you reduce this parameter too much, the representations may not be as good. Another option is to reduce the vocabulary size (e.g., if you are dealing with text, you can try dropping the rare words from the vocabulary, and replace them all with a token like \"\" or \"\"). If you are using hash buckets, you can also try reducing the hash_bucket_size (but not too much, or else you will get collisions).", "words": [{"w": "Each", "b": [0.1429, 0.5701, 0.1838, 0.5916]}, {"w": "of", "b": [0.1898, 0.5701, 0.2066, 0.5916]}, {"w": "the", "b": [0.2126, 0.5701, 0.2389, 0.5916]}, {"w": "five", "b": [0.2449, 0.5701, 0.2751, 0.5916]}, {"w": "ocean_proximity", "b": [0.2811, 0.5733, 0.4296, 0.5884]}, {"w": "categories", "b": [0.4356, 0.5701, 0.5185, 0.5916]}, {"w": "will", "b": [0.5245, 0.5701, 0.5549, 0.5916]}, {"w": "now", "b": [0.5609, 0.5701, 0.5972, 0.5916]}, {"w": "be", "b": [0.6032, 0.5701, 0.6227, 0.5916]}, {"w": "represented", "b": [0.6286, 0.5701, 0.7264, 0.5916]}, {"w": "as", "b": [0.7324, 0.5701, 0.7492, 0.5916]}, {"w": "a", "b": [0.7552, 0.5701, 0.7644, 0.5916]}, {"w": "2D", "b": [0.7704, 0.5701, 0.7957, 0.5916]}, {"w": "vector.", "b": [0.8017, 0.5701, 0.8571, 0.5916]}, {"w": "These", "b": [0.1429, 0.5892, 0.1922, 0.6106]}, {"w": "vectors", "b": [0.198, 0.5892, 0.2576, 0.6106]}, {"w": "are", "b": [0.2634, 0.5892, 0.2891, 0.6106]}, {"w": "stored", "b": [0.2949, 0.5892, 0.3471, 0.6106]}, {"w": "in", "b": [0.3529, 0.5892, 0.3699, 0.6106]}, {"w": "an", "b": [0.3756, 0.5892, 0.3962, 0.6106]}, {"w": "embedding", "b": [0.4019, 0.589, 0.4903, 0.6106]}, {"w": "matrix", "b": [0.4961, 0.589, 0.5517, 0.6106]}, {"w": "with", "b": [0.5575, 0.5892, 0.5948, 0.6106]}, {"w": "one", "b": [0.6006, 0.5892, 0.6315, 0.6106]}, {"w": "row", "b": [0.6372, 0.5892, 0.6699, 0.6106]}, {"w": "per", "b": [0.6756, 0.5892, 0.7031, 0.6106]}, {"w": "category,", "b": [0.7089, 0.5892, 0.7832, 0.6106]}, {"w": "and", "b": [0.7889, 0.5892, 0.8205, 0.6106]}, {"w": "one", "b": [0.8263, 0.5892, 0.8571, 0.6106]}, {"w": "column", "b": [0.1429, 0.6082, 0.2071, 0.6297]}, {"w": "per", "b": [0.2143, 0.6082, 0.2418, 0.6297]}, {"w": "embedding", "b": [0.2489, 0.6082, 0.343, 0.6297]}, {"w": "dimension,", "b": [0.3502, 0.6082, 0.4441, 0.6297]}, {"w": "so", "b": [0.4513, 0.6082, 0.4696, 0.6297]}, {"w": "in", "b": [0.4767, 0.6082, 0.4937, 0.6297]}, {"w": "this", "b": [0.5009, 0.6082, 0.5316, 0.6297]}, {"w": "example", "b": [0.5388, 0.6082, 0.6083, 0.6297]}, {"w": "it", "b": [0.6155, 0.6082, 0.6274, 0.6297]}, {"w": "is", "b": [0.6346, 0.6082, 0.6478, 0.6297]}, {"w": "a", "b": [0.655, 0.6082, 0.6642, 0.6297]}, {"w": "5×2", "b": [0.6713, 0.6082, 0.7034, 0.6297]}, {"w": "matrix.", "b": [0.7106, 0.6082, 0.7707, 0.6297]}, {"w": "When", "b": [0.7778, 0.6082, 0.8294, 0.6297]}, {"w": "an", "b": [0.8366, 0.6082, 0.8572, 0.6297]}, {"w": "embedding", "b": [0.1429, 0.6273, 0.2369, 0.6487]}, {"w": "column", "b": [0.2436, 0.6273, 0.3079, 0.6487]}, {"w": "is", "b": [0.3145, 0.6273, 0.3278, 0.6487]}, {"w": "given", "b": [0.3345, 0.6273, 0.3797, 0.6487]}, {"w": "a", "b": [0.3864, 0.6273, 0.3955, 0.6487]}, {"w": "category", "b": [0.4022, 0.6273, 0.4732, 0.6487]}, {"w": "index", "b": [0.4799, 0.6273, 0.5266, 0.6487]}, {"w": "as", "b": [0.5333, 0.6273, 0.5501, 0.6487]}, {"w": "input", "b": [0.5568, 0.6273, 0.6017, 0.6487]}, {"w": "(say,", "b": [0.6084, 0.6273, 0.6448, 0.6487]}, {"w": "3,", "b": [0.6515, 0.6273, 0.6662, 0.6487]}, {"w": "which", "b": [0.6729, 0.6273, 0.7238, 0.6487]}, {"w": "corresponds", "b": [0.7305, 0.6273, 0.8335, 0.6487]}, {"w": "to", "b": [0.8402, 0.6273, 0.8571, 0.6487]}, {"w": "the", "b": [0.1429, 0.6472, 0.1692, 0.6686]}, {"w": "category", "b": [0.1768, 0.6472, 0.2479, 0.6686]}, {"w": "\"NEAR", "b": [0.2555, 0.6504, 0.305, 0.6655]}, {"w": "BAY\"),", "b": [0.3177, 0.6472, 0.3692, 0.6686]}, {"w": "it", "b": [0.3769, 0.6472, 0.3888, 0.6686]}, {"w": "just", "b": [0.3965, 0.6472, 0.4269, 0.6686]}, {"w": "performs", "b": [0.4346, 0.6472, 0.5113, 0.6686]}, {"w": "a", "b": [0.519, 0.6472, 0.5281, 0.6686]}, {"w": "lookup", "b": [0.5358, 0.6472, 0.5946, 0.6686]}, {"w": "in", "b": [0.6022, 0.6472, 0.6192, 0.6686]}, {"w": "the", "b": [0.6269, 0.6472, 0.6532, 0.6686]}, {"w": "embedding", "b": [0.6609, 0.6472, 0.755, 0.6686]}, {"w": "matrix", "b": [0.7626, 0.6472, 0.8179, 0.6686]}, {"w": "and", "b": [0.8256, 0.6472, 0.8571, 0.6686]}, {"w": "returns", "b": [0.1429, 0.6672, 0.2036, 0.6886]}, {"w": "the", "b": [0.2091, 0.6672, 0.2354, 0.6886]}, {"w": "corresponding", "b": [0.2408, 0.6672, 0.3629, 0.6886]}, {"w": "row", "b": [0.3683, 0.6672, 0.4009, 0.6886]}, {"w": "(say,", "b": [0.4063, 0.6672, 0.4427, 0.6886]}, {"w": "[0.331,", "b": [0.4481, 0.6704, 0.5174, 0.6854]}, {"w": "0.190]).", "b": [0.5273, 0.6672, 0.5993, 0.6886]}, {"w": "Unfortunately,", "b": [0.6047, 0.6672, 0.7259, 0.6886]}, {"w": "the", "b": [0.7313, 0.6672, 0.7576, 0.6886]}, {"w": "embedding", "b": [0.7631, 0.6672, 0.8571, 0.6886]}, {"w": "matrix", "b": [0.1429, 0.6862, 0.1982, 0.7076]}, {"w": "can", "b": [0.2047, 0.6862, 0.234, 0.7076]}, {"w": "be", "b": [0.2405, 0.6862, 0.26, 0.7076]}, {"w": "quite", "b": [0.2665, 0.6862, 0.309, 0.7076]}, {"w": "large,", "b": [0.3155, 0.6862, 0.361, 0.7076]}, {"w": "especially", "b": [0.3675, 0.6862, 0.4474, 0.7076]}, {"w": "when", "b": [0.4539, 0.6862, 0.4995, 0.7076]}, {"w": "you", "b": [0.506, 0.6862, 0.5373, 0.7076]}, {"w": "have", "b": [0.5438, 0.6862, 0.5822, 0.7076]}, {"w": "a", "b": [0.5887, 0.6862, 0.5978, 0.7076]}, {"w": "large", "b": [0.6043, 0.6862, 0.645, 0.7076]}, {"w": "vocabulary:", "b": [0.6515, 0.6862, 0.7491, 0.7076]}, {"w": "if", "b": [0.7556, 0.6862, 0.7674, 0.7076]}, {"w": "this", "b": [0.7739, 0.6862, 0.8046, 0.7076]}, {"w": "is", "b": [0.8111, 0.6862, 0.8243, 0.7076]}, {"w": "the", "b": [0.8308, 0.6862, 0.8571, 0.7076]}, {"w": "case,", "b": [0.1428, 0.7053, 0.1821, 0.7267]}, {"w": "the", "b": [0.1869, 0.7053, 0.2132, 0.7267]}, {"w": "model", "b": [0.2181, 0.7053, 0.2709, 0.7267]}, {"w": "can", "b": [0.2758, 0.7053, 0.3051, 0.7267]}, {"w": "only", "b": [0.31, 0.7053, 0.3468, 0.7267]}, {"w": "learn", "b": [0.3517, 0.7053, 0.3941, 0.7267]}, {"w": "good", "b": [0.3989, 0.7053, 0.4409, 0.7267]}, {"w": "representations", "b": [0.4458, 0.7053, 0.5741, 0.7267]}, {"w": "for", "b": [0.5789, 0.7053, 0.6034, 0.7267]}, {"w": "the", "b": [0.6083, 0.7053, 0.6346, 0.7267]}, {"w": "categories", "b": [0.6395, 0.7053, 0.7224, 0.7267]}, {"w": "for", "b": [0.7273, 0.7053, 0.7518, 0.7267]}, {"w": "which", "b": [0.7567, 0.7053, 0.8076, 0.7267]}, {"w": "it", "b": [0.8124, 0.7053, 0.8244, 0.7267]}, {"w": "has", "b": [0.8292, 0.7053, 0.8571, 0.7267]}, {"w": "sufficient", "b": [0.1429, 0.7243, 0.2201, 0.7457]}, {"w": "training", "b": [0.2294, 0.7243, 0.2963, 0.7457]}, {"w": "data.", "b": [0.3056, 0.7243, 0.3456, 0.7457]}, {"w": "To", "b": [0.3548, 0.7243, 0.3763, 0.7457]}, {"w": "reduce", "b": [0.3856, 0.7243, 0.4419, 0.7457]}, {"w": "the", "b": [0.4511, 0.7243, 0.4775, 0.7457]}, {"w": "size", "b": [0.4867, 0.7243, 0.5176, 0.7457]}, {"w": "of", "b": [0.5269, 0.7243, 0.5436, 0.7457]}, {"w": "the", "b": [0.5529, 0.7243, 0.5792, 0.7457]}, {"w": "embedding", "b": [0.5885, 0.7243, 0.6826, 0.7457]}, {"w": "matrix,", "b": [0.6919, 0.7243, 0.7519, 0.7457]}, {"w": "you", "b": [0.7612, 0.7243, 0.7925, 0.7457]}, {"w": "can", "b": [0.8017, 0.7243, 0.8311, 0.7457]}, {"w": "of", "b": [0.8404, 0.7243, 0.8572, 0.7457]}, {"w": "course", "b": [0.1429, 0.7443, 0.1976, 0.7657]}, {"w": "try", "b": [0.2036, 0.7443, 0.2278, 0.7657]}, {"w": "lowering", "b": [0.2338, 0.7443, 0.3073, 0.7657]}, {"w": "the", "b": [0.3132, 0.7443, 0.3396, 0.7657]}, {"w": "dimension", "b": [0.3455, 0.7474, 0.4346, 0.7625]}, {"w": "hyperparameter,", "b": [0.4406, 0.7443, 0.5775, 0.7657]}, {"w": "but", "b": [0.5835, 0.7443, 0.6115, 0.7657]}, {"w": "if", "b": [0.6174, 0.7443, 0.6292, 0.7657]}, {"w": "you", "b": [0.6352, 0.7443, 0.6664, 0.7657]}, {"w": "reduce", "b": [0.6724, 0.7443, 0.7287, 0.7657]}, {"w": "this", "b": [0.7347, 0.7443, 0.7654, 0.7657]}, {"w": "parameter", "b": [0.7714, 0.7443, 0.8571, 0.7657]}, {"w": "too", "b": [0.1429, 0.7633, 0.1705, 0.7847]}, {"w": "much,", "b": [0.1772, 0.7633, 0.2296, 0.7847]}, {"w": "the", "b": [0.2363, 0.7633, 0.2626, 0.7847]}, {"w": "representations", "b": [0.2694, 0.7633, 0.3977, 0.7847]}, {"w": "may", "b": [0.4044, 0.7633, 0.4398, 0.7847]}, {"w": "not", "b": [0.4465, 0.7633, 0.4749, 0.7847]}, {"w": "be", "b": [0.4816, 0.7633, 0.501, 0.7847]}, {"w": "as", "b": [0.5077, 0.7633, 0.5245, 0.7847]}, {"w": "good.", "b": [0.5312, 0.7633, 0.578, 0.7847]}, {"w": "Another", "b": [0.5847, 0.7633, 0.6552, 0.7847]}, {"w": "option", "b": [0.6619, 0.7633, 0.7174, 0.7847]}, {"w": "is", "b": [0.7241, 0.7633, 0.7374, 0.7847]}, {"w": "to", "b": [0.7441, 0.7633, 0.7611, 0.7847]}, {"w": "reduce", "b": [0.7678, 0.7633, 0.8241, 0.7847]}, {"w": "the", "b": [0.8308, 0.7633, 0.8571, 0.7847]}, {"w": "vocabulary", "b": [0.1428, 0.7824, 0.235, 0.8038]}, {"w": "size", "b": [0.24, 0.7824, 0.2708, 0.8038]}, {"w": "(e.g.,", "b": [0.2758, 0.7824, 0.3158, 0.8038]}, {"w": "if", "b": [0.3208, 0.7824, 0.3325, 0.8038]}, {"w": "you", "b": [0.3375, 0.7824, 0.3687, 0.8038]}, {"w": "are", "b": [0.3737, 0.7824, 0.3994, 0.8038]}, {"w": "dealing", "b": [0.4043, 0.7824, 0.4653, 0.8038]}, {"w": "with", "b": [0.4703, 0.7824, 0.5076, 0.8038]}, {"w": "text,", "b": [0.5125, 0.7824, 0.5487, 0.8038]}, {"w": "you", "b": [0.5536, 0.7824, 0.5849, 0.8038]}, {"w": "can", "b": [0.5898, 0.7824, 0.6192, 0.8038]}, {"w": "try", "b": [0.6241, 0.7824, 0.6484, 0.8038]}, {"w": "dropping", "b": [0.6533, 0.7824, 0.7312, 0.8038]}, {"w": "the", "b": [0.7362, 0.7824, 0.7625, 0.8038]}, {"w": "rare", "b": [0.7675, 0.7824, 0.8009, 0.8038]}, {"w": "words", "b": [0.8059, 0.7824, 0.8571, 0.8038]}, {"w": "from", "b": [0.1429, 0.8023, 0.1844, 0.8237]}, {"w": "the", "b": [0.1894, 0.8023, 0.2157, 0.8237]}, {"w": "vocabulary,", "b": [0.2207, 0.8023, 0.3161, 0.8237]}, {"w": "and", "b": [0.321, 0.8023, 0.3526, 0.8237]}, {"w": "replace", "b": [0.3575, 0.8023, 0.4171, 0.8237]}, {"w": "them", "b": [0.422, 0.8023, 0.4654, 0.8237]}, {"w": "all", "b": [0.4704, 0.8023, 0.49, 0.8237]}, {"w": "with", "b": [0.495, 0.8023, 0.5323, 0.8237]}, {"w": "a", "b": [0.5373, 0.8023, 0.5464, 0.8237]}, {"w": "token", "b": [0.5513, 0.8023, 0.5989, 0.8237]}, {"w": "like", "b": [0.6038, 0.8023, 0.6339, 0.8237]}, {"w": "\"\"", "b": [0.6388, 0.8055, 0.7477, 0.8206]}, {"w": "or", "b": [0.7526, 0.8023, 0.771, 0.8237]}, {"w": "\"\").", "b": [0.7759, 0.8023, 0.8572, 0.8237]}, {"w": "If", "b": [0.1429, 0.8222, 0.1561, 0.8437]}, {"w": "you", "b": [0.1623, 0.8222, 0.1935, 0.8437]}, {"w": "are", "b": [0.1996, 0.8222, 0.2254, 0.8437]}, {"w": "using", "b": [0.2315, 0.8222, 0.2769, 0.8437]}, {"w": "hash", "b": [0.283, 0.8222, 0.3221, 0.8437]}, {"w": "buckets,", "b": [0.3282, 0.8222, 0.3966, 0.8437]}, {"w": "you", "b": [0.4027, 0.8222, 0.434, 0.8437]}, {"w": "can", "b": [0.4401, 0.8222, 0.4694, 0.8437]}, {"w": "also", "b": [0.4755, 0.8222, 0.5082, 0.8437]}, {"w": "try", "b": [0.5144, 0.8222, 0.5386, 0.8437]}, {"w": "reducing", "b": [0.5447, 0.8222, 0.6189, 0.8437]}, {"w": "the", "b": [0.625, 0.8222, 0.6514, 0.8437]}, {"w": "hash_bucket_size", "b": [0.6575, 0.8254, 0.8158, 0.8405]}, {"w": "(but", "b": [0.8219, 0.8222, 0.8571, 0.8437]}, {"w": "not", "b": [0.1429, 0.8413, 0.1712, 0.8627]}, {"w": "too", "b": [0.176, 0.8413, 0.2036, 0.8627]}, {"w": "much,", "b": [0.2083, 0.8413, 0.2607, 0.8627]}, {"w": "or", "b": [0.2654, 0.8413, 0.2838, 0.8627]}, {"w": "else", "b": [0.2885, 0.8413, 0.3191, 0.8627]}, {"w": "you", "b": [0.3239, 0.8413, 0.3551, 0.8627]}, {"w": "will", "b": [0.3599, 0.8413, 0.3903, 0.8627]}, {"w": "get", "b": [0.395, 0.8413, 0.4199, 0.8627]}, {"w": "collisions).", "b": [0.4247, 0.8413, 0.5151, 0.8627]}]}, {"id": "b_4", "type": "paragraph", "text": "The Features API | 425", "words": [{"w": "The", "b": [0.698, 0.9225, 0.7195, 0.9388]}, {"w": "Features", "b": [0.7224, 0.9225, 0.7733, 0.9388]}, {"w": "API", "b": [0.7761, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "425", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 452, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "If there are no pretrained embeddings that you can reuse for the task you are trying to tackle, and if you do not have enough train‐ ing data to learn them, then you can try to learn them on some auxiliary task for which it is easier to obtain plenty of training data. After that, you can reuse the trained embeddings for your main task.", "words": [{"w": "If", "b": [0.2714, 0.0793, 0.2835, 0.0989]}, {"w": "there", "b": [0.2903, 0.0793, 0.3295, 0.0989]}, {"w": "are", "b": [0.3363, 0.0793, 0.3598, 0.0989]}, {"w": "no", "b": [0.3665, 0.0793, 0.3867, 0.0989]}, {"w": "pretrained", "b": [0.3934, 0.0793, 0.4735, 0.0989]}, {"w": "embeddings", "b": [0.4802, 0.0793, 0.5732, 0.0989]}, {"w": "that", "b": [0.58, 0.0793, 0.6097, 0.0989]}, {"w": "you", "b": [0.6165, 0.0793, 0.6451, 0.0989]}, {"w": "can", "b": [0.6518, 0.0793, 0.6786, 0.0989]}, {"w": "reuse", "b": [0.6854, 0.0793, 0.7257, 0.0989]}, {"w": "for", "b": [0.7325, 0.0793, 0.7549, 0.0989]}, {"w": "the", "b": [0.7616, 0.0793, 0.7857, 0.0989]}, {"w": "task", "b": [0.2714, 0.0967, 0.302, 0.1163]}, {"w": "you", "b": [0.3074, 0.0967, 0.336, 0.1163]}, {"w": "are", "b": [0.3415, 0.0967, 0.365, 0.1163]}, {"w": "trying", "b": [0.3704, 0.0967, 0.417, 0.1163]}, {"w": "to", "b": [0.4224, 0.0967, 0.438, 0.1163]}, {"w": "tackle,", "b": [0.4434, 0.0967, 0.4923, 0.1163]}, {"w": "and", "b": [0.4978, 0.0967, 0.5266, 0.1163]}, {"w": "if", "b": [0.532, 0.0967, 0.5428, 0.1163]}, {"w": "you", "b": [0.5482, 0.0967, 0.5768, 0.1163]}, {"w": "do", "b": [0.5822, 0.0967, 0.602, 0.1163]}, {"w": "not", "b": [0.6074, 0.0967, 0.6333, 0.1163]}, {"w": "have", "b": [0.6388, 0.0967, 0.6739, 0.1163]}, {"w": "enough", "b": [0.6793, 0.0967, 0.7367, 0.1163]}, {"w": "train‐", "b": [0.7422, 0.0967, 0.7857, 0.1163]}, {"w": "ing", "b": [0.2714, 0.1141, 0.2958, 0.1337]}, {"w": "data", "b": [0.303, 0.1141, 0.3352, 0.1337]}, {"w": "to", "b": [0.3423, 0.1141, 0.3579, 0.1337]}, {"w": "learn", "b": [0.365, 0.1141, 0.4038, 0.1337]}, {"w": "them,", "b": [0.4109, 0.1141, 0.4549, 0.1337]}, {"w": "then", "b": [0.4621, 0.1141, 0.4966, 0.1337]}, {"w": "you", "b": [0.5037, 0.1141, 0.5323, 0.1337]}, {"w": "can", "b": [0.5394, 0.1141, 0.5662, 0.1337]}, {"w": "try", "b": [0.5734, 0.1141, 0.5955, 0.1337]}, {"w": "to", "b": [0.6027, 0.1141, 0.6182, 0.1337]}, {"w": "learn", "b": [0.6253, 0.1141, 0.6641, 0.1337]}, {"w": "them", "b": [0.6712, 0.1141, 0.7109, 0.1337]}, {"w": "on", "b": [0.718, 0.1141, 0.7382, 0.1337]}, {"w": "some", "b": [0.7453, 0.1141, 0.7857, 0.1337]}, {"w": "auxiliary", "b": [0.2714, 0.1315, 0.3383, 0.1511]}, {"w": "task", "b": [0.3429, 0.1315, 0.3735, 0.1511]}, {"w": "for", "b": [0.3782, 0.1315, 0.4006, 0.1511]}, {"w": "which", "b": [0.4053, 0.1315, 0.4518, 0.1511]}, {"w": "it", "b": [0.4565, 0.1315, 0.4674, 0.1511]}, {"w": "is", "b": [0.4721, 0.1315, 0.4842, 0.1511]}, {"w": "easier", "b": [0.4888, 0.1315, 0.5325, 0.1511]}, {"w": "to", "b": [0.5372, 0.1315, 0.5527, 0.1511]}, {"w": "obtain", "b": [0.5574, 0.1315, 0.6065, 0.1511]}, {"w": "plenty", "b": [0.6111, 0.1315, 0.6586, 0.1511]}, {"w": "of", "b": [0.6633, 0.1315, 0.6786, 0.1511]}, {"w": "training", "b": [0.6833, 0.1315, 0.7445, 0.1511]}, {"w": "data.", "b": [0.7491, 0.1315, 0.7857, 0.1511]}, {"w": "After", "b": [0.2714, 0.1489, 0.3112, 0.1685]}, {"w": "that,", "b": [0.3187, 0.1489, 0.3528, 0.1685]}, {"w": "you", "b": [0.3603, 0.1489, 0.3889, 0.1685]}, {"w": "can", "b": [0.3964, 0.1489, 0.4233, 0.1685]}, {"w": "reuse", "b": [0.4308, 0.1489, 0.4711, 0.1685]}, {"w": "the", "b": [0.4786, 0.1489, 0.5027, 0.1685]}, {"w": "trained", "b": [0.5102, 0.1489, 0.5651, 0.1685]}, {"w": "embeddings", "b": [0.5726, 0.1489, 0.6656, 0.1685]}, {"w": "for", "b": [0.6732, 0.1489, 0.6956, 0.1685]}, {"w": "your", "b": [0.7031, 0.1489, 0.7387, 0.1685]}, {"w": "main", "b": [0.7462, 0.1489, 0.7857, 0.1685]}, {"w": "task.", "b": [0.2714, 0.1664, 0.3064, 0.1859]}]}, {"id": "b_1", "type": "paragraph", "text": "Using Feature Columns for Parsing", "words": [{"w": "Using", "b": [0.1428, 0.2035, 0.2008, 0.232]}, {"w": "Feature", "b": [0.2058, 0.2035, 0.2853, 0.232]}, {"w": "Columns", "b": [0.2903, 0.2035, 0.3787, 0.232]}, {"w": "for", "b": [0.3837, 0.2035, 0.4132, 0.232]}, {"w": "Parsing", "b": [0.4181, 0.2035, 0.4955, 0.232]}]}, {"id": "b_2", "type": "paragraph", "text": "Let’s suppose you have created feature columns for each of your input features, as well as for the target. What can you do with them? Well, for one you can pass them to the make_parse_example_spec() function to generate feature descriptions (so you don’t have to do it manually, as we did earlier):", "words": [{"w": "Let’s", "b": [0.1429, 0.2379, 0.179, 0.2594]}, {"w": "suppose", "b": [0.1838, 0.2379, 0.2515, 0.2594]}, {"w": "you", "b": [0.2563, 0.2379, 0.2875, 0.2594]}, {"w": "have", "b": [0.2923, 0.2379, 0.3307, 0.2594]}, {"w": "created", "b": [0.3355, 0.2379, 0.3958, 0.2594]}, {"w": "feature", "b": [0.4006, 0.2379, 0.4584, 0.2594]}, {"w": "columns", "b": [0.4632, 0.2379, 0.5351, 0.2594]}, {"w": "for", "b": [0.5399, 0.2379, 0.5644, 0.2594]}, {"w": "each", "b": [0.5692, 0.2379, 0.6071, 0.2594]}, {"w": "of", "b": [0.6119, 0.2379, 0.6287, 0.2594]}, {"w": "your", "b": [0.6335, 0.2379, 0.6724, 0.2594]}, {"w": "input", "b": [0.6772, 0.2379, 0.7222, 0.2594]}, {"w": "features,", "b": [0.7269, 0.2379, 0.7971, 0.2594]}, {"w": "as", "b": [0.8019, 0.2379, 0.8187, 0.2594]}, {"w": "well", "b": [0.8235, 0.2379, 0.8571, 0.2594]}, {"w": "as", "b": [0.1428, 0.257, 0.1596, 0.2784]}, {"w": "for", "b": [0.165, 0.257, 0.1895, 0.2784]}, {"w": "the", "b": [0.1948, 0.257, 0.2212, 0.2784]}, {"w": "target.", "b": [0.2265, 0.257, 0.2794, 0.2784]}, {"w": "What", "b": [0.2848, 0.257, 0.3312, 0.2784]}, {"w": "can", "b": [0.3366, 0.257, 0.3659, 0.2784]}, {"w": "you", "b": [0.3712, 0.257, 0.4025, 0.2784]}, {"w": "do", "b": [0.4078, 0.257, 0.4294, 0.2784]}, {"w": "with", "b": [0.4348, 0.257, 0.4721, 0.2784]}, {"w": "them?", "b": [0.4774, 0.257, 0.5287, 0.2784]}, {"w": "Well,", "b": [0.5341, 0.257, 0.5764, 0.2784]}, {"w": "for", "b": [0.5817, 0.257, 0.6063, 0.2784]}, {"w": "one", "b": [0.6116, 0.257, 0.6425, 0.2784]}, {"w": "you", "b": [0.6478, 0.257, 0.6791, 0.2784]}, {"w": "can", "b": [0.6844, 0.257, 0.7137, 0.2784]}, {"w": "pass", "b": [0.7191, 0.257, 0.7544, 0.2784]}, {"w": "them", "b": [0.7598, 0.257, 0.8032, 0.2784]}, {"w": "to", "b": [0.8085, 0.257, 0.8255, 0.2784]}, {"w": "the", "b": [0.8308, 0.257, 0.8571, 0.2784]}, {"w": "make_parse_example_spec()", "b": [0.1429, 0.2801, 0.3902, 0.2952]}, {"w": "function", "b": [0.3965, 0.2769, 0.4679, 0.2983]}, {"w": "to", "b": [0.4741, 0.2769, 0.4911, 0.2983]}, {"w": "generate", "b": [0.4973, 0.2769, 0.5678, 0.2983]}, {"w": "feature", "b": [0.574, 0.2769, 0.6318, 0.2983]}, {"w": "descriptions", "b": [0.638, 0.2769, 0.7402, 0.2983]}, {"w": "(so", "b": [0.7464, 0.2769, 0.7719, 0.2983]}, {"w": "you", "b": [0.7781, 0.2769, 0.8093, 0.2983]}, {"w": "don’t", "b": [0.8155, 0.2769, 0.8571, 0.2983]}, {"w": "have", "b": [0.1428, 0.296, 0.1812, 0.3174]}, {"w": "to", "b": [0.186, 0.296, 0.203, 0.3174]}, {"w": "do", "b": [0.2077, 0.296, 0.2293, 0.3174]}, {"w": "it", "b": [0.234, 0.296, 0.246, 0.3174]}, {"w": "manually,", "b": [0.2507, 0.296, 0.3315, 0.3174]}, {"w": "as", "b": [0.3362, 0.296, 0.353, 0.3174]}, {"w": "we", "b": [0.3577, 0.296, 0.3808, 0.3174]}, {"w": "did", "b": [0.3856, 0.296, 0.4131, 0.3174]}, {"w": "earlier):", "b": [0.4179, 0.296, 0.483, 0.3174]}]}, {"id": "b_3", "type": "paragraph", "text": "columns = [bucketized_age, ....., median_house_value] # all features + target feature_descriptions = tf.feature_column.make_parse_example_spec(columns)", "words": [{"w": "columns", "b": [0.1766, 0.328, 0.2356, 0.3408]}, {"w": "=", "b": [0.244, 0.328, 0.2525, 0.3408]}, {"w": "[bucketized_age,", "b": [0.2609, 0.328, 0.3958, 0.3408]}, {"w": ".....,", "b": [0.4043, 0.328, 0.4549, 0.3408]}, {"w": "median_house_value]", "b": [0.4633, 0.328, 0.6235, 0.3408]}, {"w": "#", "b": [0.6319, 0.328, 0.6404, 0.3408]}, {"w": "all", "b": [0.6488, 0.328, 0.6741, 0.3408]}, {"w": "features", "b": [0.6825, 0.328, 0.75, 0.3408]}, {"w": "+", "b": [0.7584, 0.328, 0.7669, 0.3408]}, {"w": "target", "b": [0.7753, 0.328, 0.8259, 0.3408]}, {"w": "feature_descriptions", "b": [0.1766, 0.3434, 0.3452, 0.3562]}, {"w": "=", "b": [0.3537, 0.3434, 0.3621, 0.3562]}, {"w": "tf.feature_column.make_parse_example_spec(columns)", "b": [0.3705, 0.3434, 0.7922, 0.3562]}]}, {"id": "b_4", "type": "paragraph", "text": "You don’t always have to create a separate feature column for each and every feature. For example, instead of having 2 numerical fea‐ ture columns, you could choose to have a single 2D column: just set shape=[2] when calling numerical_column().", "words": [{"w": "You", "b": [0.2714, 0.3778, 0.301, 0.3974]}, {"w": "don’t", "b": [0.3066, 0.3778, 0.3446, 0.3974]}, {"w": "always", "b": [0.3502, 0.3778, 0.4002, 0.3974]}, {"w": "have", "b": [0.4058, 0.3778, 0.4409, 0.3974]}, {"w": "to", "b": [0.4465, 0.3778, 0.462, 0.3974]}, {"w": "create", "b": [0.4676, 0.3778, 0.5127, 0.3974]}, {"w": "a", "b": [0.5183, 0.3778, 0.5267, 0.3974]}, {"w": "separate", "b": [0.5323, 0.3778, 0.5947, 0.3974]}, {"w": "feature", "b": [0.6003, 0.3778, 0.6531, 0.3974]}, {"w": "column", "b": [0.6587, 0.3778, 0.7174, 0.3974]}, {"w": "for", "b": [0.723, 0.3778, 0.7454, 0.3974]}, {"w": "each", "b": [0.751, 0.3778, 0.7857, 0.3974]}, {"w": "and", "b": [0.2714, 0.3953, 0.3002, 0.4148]}, {"w": "every", "b": [0.3058, 0.3953, 0.3472, 0.4148]}, {"w": "feature.", "b": [0.3527, 0.3953, 0.4099, 0.4148]}, {"w": "For", "b": [0.4154, 0.3953, 0.4419, 0.4148]}, {"w": "example,", "b": [0.4475, 0.3953, 0.5154, 0.4148]}, {"w": "instead", "b": [0.521, 0.3953, 0.5758, 0.4148]}, {"w": "of", "b": [0.5814, 0.3953, 0.5967, 0.4148]}, {"w": "having", "b": [0.6023, 0.3953, 0.6537, 0.4148]}, {"w": "2", "b": [0.6593, 0.3953, 0.6684, 0.4148]}, {"w": "numerical", "b": [0.674, 0.3953, 0.7513, 0.4148]}, {"w": "fea‐", "b": [0.7568, 0.3953, 0.7857, 0.4148]}, {"w": "ture", "b": [0.2714, 0.4127, 0.3025, 0.4322]}, {"w": "columns,", "b": [0.309, 0.4127, 0.3791, 0.4322]}, {"w": "you", "b": [0.3856, 0.4127, 0.4142, 0.4322]}, {"w": "could", "b": [0.4207, 0.4127, 0.4634, 0.4322]}, {"w": "choose", "b": [0.47, 0.4127, 0.5227, 0.4322]}, {"w": "to", "b": [0.5292, 0.4127, 0.5448, 0.4322]}, {"w": "have", "b": [0.5513, 0.4127, 0.5864, 0.4322]}, {"w": "a", "b": [0.5929, 0.4127, 0.6013, 0.4322]}, {"w": "single", "b": [0.6078, 0.4127, 0.6521, 0.4322]}, {"w": "2D", "b": [0.6587, 0.4127, 0.6818, 0.4322]}, {"w": "column:", "b": [0.6883, 0.4127, 0.7514, 0.4322]}, {"w": "just", "b": [0.7579, 0.4127, 0.7857, 0.4322]}, {"w": "set", "b": [0.2714, 0.4309, 0.2923, 0.4505]}, {"w": "shape=[2]", "b": [0.2966, 0.4338, 0.3781, 0.4476]}, {"w": "when", "b": [0.3824, 0.4309, 0.4241, 0.4505]}, {"w": "calling", "b": [0.4284, 0.4309, 0.4789, 0.4505]}, {"w": "numerical_column().", "b": [0.4833, 0.4309, 0.6505, 0.4505]}]}, {"id": "b_5", "type": "paragraph", "text": "You can then create a function that parses serialized examples using these feature descriptions, and separates the target column from the input features:", "words": [{"w": "You", "b": [0.1428, 0.4765, 0.1752, 0.4979]}, {"w": "can", "b": [0.1834, 0.4765, 0.2128, 0.4979]}, {"w": "then", "b": [0.221, 0.4765, 0.2587, 0.4979]}, {"w": "create", "b": [0.267, 0.4765, 0.3163, 0.4979]}, {"w": "a", "b": [0.3246, 0.4765, 0.3337, 0.4979]}, {"w": "function", "b": [0.3419, 0.4765, 0.4133, 0.4979]}, {"w": "that", "b": [0.4216, 0.4765, 0.4542, 0.4979]}, {"w": "parses", "b": [0.4624, 0.4765, 0.5143, 0.4979]}, {"w": "serialized", "b": [0.5226, 0.4765, 0.601, 0.4979]}, {"w": "examples", "b": [0.6092, 0.4765, 0.6864, 0.4979]}, {"w": "using", "b": [0.6946, 0.4765, 0.7401, 0.4979]}, {"w": "these", "b": [0.7483, 0.4765, 0.7911, 0.4979]}, {"w": "feature", "b": [0.7994, 0.4765, 0.8571, 0.4979]}, {"w": "descriptions,", "b": [0.1429, 0.4955, 0.2498, 0.5169]}, {"w": "and", "b": [0.2545, 0.4955, 0.286, 0.5169]}, {"w": "separates", "b": [0.2908, 0.4955, 0.3667, 0.5169]}, {"w": "the", "b": [0.3714, 0.4955, 0.3977, 0.5169]}, {"w": "target", "b": [0.4024, 0.4955, 0.4506, 0.5169]}, {"w": "column", "b": [0.4554, 0.4955, 0.5196, 0.5169]}, {"w": "from", "b": [0.5243, 0.4955, 0.5659, 0.5169]}, {"w": "the", "b": [0.5706, 0.4955, 0.597, 0.5169]}, {"w": "input", "b": [0.6017, 0.4955, 0.6466, 0.5169]}, {"w": "features:", "b": [0.6513, 0.4955, 0.7215, 0.5169]}]}, {"id": "b_6", "type": "paragraph", "text": "def parse_examples(serialized_examples): examples = tf.io.parse_example(serialized_examples, feature_descriptions) targets = examples.pop(\"median_house_value\") # separate the targets return examples, targets", "words": [{"w": "def", "b": [0.1766, 0.5275, 0.2019, 0.5404]}, {"w": "parse_examples(serialized_examples):", "b": [0.2103, 0.5275, 0.5139, 0.5404]}, {"w": "examples", "b": [0.2103, 0.5429, 0.2778, 0.5558]}, {"w": "=", "b": [0.2862, 0.5429, 0.2946, 0.5558]}, {"w": "tf.io.parse_example(serialized_examples,", "b": [0.3031, 0.5429, 0.6404, 0.5558]}, {"w": "feature_descriptions)", "b": [0.6488, 0.5429, 0.8259, 0.5558]}, {"w": "targets", "b": [0.2103, 0.5583, 0.2693, 0.5712]}, {"w": "=", "b": [0.2778, 0.5583, 0.2862, 0.5712]}, {"w": "examples.pop(\"median_house_value\")", "b": [0.2946, 0.5583, 0.5813, 0.5712]}, {"w": "#", "b": [0.5898, 0.5583, 0.5982, 0.5712]}, {"w": "separate", "b": [0.6066, 0.5583, 0.6741, 0.5712]}, {"w": "the", "b": [0.6825, 0.5583, 0.7078, 0.5712]}, {"w": "targets", "b": [0.7163, 0.5583, 0.7753, 0.5712]}, {"w": "return", "b": [0.2103, 0.5738, 0.2609, 0.5866]}, {"w": "examples,", "b": [0.2693, 0.5738, 0.3452, 0.5866]}, {"w": "targets", "b": [0.3537, 0.5738, 0.4127, 0.5866]}]}, {"id": "b_7", "type": "paragraph", "text": "Next, you can create a TFRecordDataset that will read batches of serialized examples (assuming the TFRecord file contains serialized Example protobufs with the appropri‐ ate features):", "words": [{"w": "Next,", "b": [0.1429, 0.5953, 0.1876, 0.6167]}, {"w": "you", "b": [0.1933, 0.5953, 0.2245, 0.6167]}, {"w": "can", "b": [0.2302, 0.5953, 0.2595, 0.6167]}, {"w": "create", "b": [0.2652, 0.5953, 0.3145, 0.6167]}, {"w": "a", "b": [0.3202, 0.5953, 0.3293, 0.6167]}, {"w": "TFRecordDataset", "b": [0.3349, 0.5985, 0.4834, 0.6136]}, {"w": "that", "b": [0.489, 0.5953, 0.5216, 0.6167]}, {"w": "will", "b": [0.5273, 0.5953, 0.5577, 0.6167]}, {"w": "read", "b": [0.5633, 0.5953, 0.6, 0.6167]}, {"w": "batches", "b": [0.6057, 0.5953, 0.6678, 0.6167]}, {"w": "of", "b": [0.6735, 0.5953, 0.6902, 0.6167]}, {"w": "serialized", "b": [0.6959, 0.5953, 0.7743, 0.6167]}, {"w": "examples", "b": [0.78, 0.5953, 0.8571, 0.6167]}, {"w": "(assuming", "b": [0.1429, 0.6152, 0.2294, 0.6367]}, {"w": "the", "b": [0.2341, 0.6152, 0.2604, 0.6367]}, {"w": "TFRecord", "b": [0.2651, 0.6152, 0.349, 0.6367]}, {"w": "file", "b": [0.3537, 0.6152, 0.3796, 0.6367]}, {"w": "contains", "b": [0.3843, 0.6152, 0.4549, 0.6367]}, {"w": "serialized", "b": [0.4596, 0.6152, 0.538, 0.6367]}, {"w": "Example", "b": [0.5429, 0.6184, 0.6122, 0.6335]}, {"w": "protobufs", "b": [0.6169, 0.6152, 0.6986, 0.6367]}, {"w": "with", "b": [0.7034, 0.6152, 0.7407, 0.6367]}, {"w": "the", "b": [0.7454, 0.6152, 0.7718, 0.6367]}, {"w": "appropri‐", "b": [0.7765, 0.6152, 0.8571, 0.6367]}, {"w": "ate", "b": [0.1429, 0.6343, 0.1668, 0.6557]}, {"w": "features):", "b": [0.1716, 0.6343, 0.2489, 0.6557]}]}, {"id": "b_8", "type": "paragraph", "text": "batch_size = 32 dataset = tf.data.TFRecordDataset([\"my_data_with_features.tfrecords\"]) dataset = dataset.repeat().shuffle(10000).batch(batch_size).map(parse_examples)", "words": [{"w": "batch_size", "b": [0.1766, 0.6663, 0.2609, 0.6791]}, {"w": "=", "b": [0.2694, 0.6663, 0.2778, 0.6791]}, {"w": "32", "b": [0.2862, 0.6663, 0.3031, 0.6791]}, {"w": "dataset", "b": [0.1766, 0.6817, 0.2356, 0.6945]}, {"w": "=", "b": [0.2441, 0.6817, 0.2525, 0.6945]}, {"w": "tf.data.TFRecordDataset([\"my_data_with_features.tfrecords\"])", "b": [0.2609, 0.6817, 0.7669, 0.6945]}, {"w": "dataset", "b": [0.1766, 0.6971, 0.2356, 0.7099]}, {"w": "=", "b": [0.2441, 0.6971, 0.2525, 0.7099]}, {"w": "dataset.repeat().shuffle(10000).batch(batch_size).map(parse_examples)", "b": [0.2609, 0.6971, 0.8428, 0.7099]}]}, {"id": "b_9", "type": "paragraph", "text": "Using Feature Columns in Your Models", "words": [{"w": "Using", "b": [0.1428, 0.7238, 0.2008, 0.7524]}, {"w": "Feature", "b": [0.2058, 0.7238, 0.2853, 0.7524]}, {"w": "Columns", "b": [0.2903, 0.7238, 0.3787, 0.7524]}, {"w": "in", "b": [0.3837, 0.7238, 0.4037, 0.7524]}, {"w": "Your", "b": [0.4086, 0.7238, 0.4558, 0.7524]}, {"w": "Models", "b": [0.4608, 0.7238, 0.5348, 0.7524]}]}, {"id": "b_10", "type": "paragraph", "text": "Feature columns can also be used directly in your model, to convert all your input features into a single dense vector which the neural network can then process. For this, all you need to do is add a keras.layers.DenseFeatures layer as the first layer in your model, passing it the list of feature columns (excluding the target column):", "words": [{"w": "Feature", "b": [0.1429, 0.7583, 0.2051, 0.7797]}, {"w": "columns", "b": [0.2122, 0.7583, 0.2841, 0.7797]}, {"w": "can", "b": [0.2912, 0.7583, 0.3206, 0.7797]}, {"w": "also", "b": [0.3277, 0.7583, 0.3604, 0.7797]}, {"w": "be", "b": [0.3676, 0.7583, 0.387, 0.7797]}, {"w": "used", "b": [0.3941, 0.7583, 0.4327, 0.7797]}, {"w": "directly", "b": [0.4398, 0.7583, 0.503, 0.7797]}, {"w": "in", "b": [0.5102, 0.7583, 0.5271, 0.7797]}, {"w": "your", "b": [0.5343, 0.7583, 0.5732, 0.7797]}, {"w": "model,", "b": [0.5804, 0.7583, 0.638, 0.7797]}, {"w": "to", "b": [0.6451, 0.7583, 0.6621, 0.7797]}, {"w": "convert", "b": [0.6692, 0.7583, 0.7321, 0.7797]}, {"w": "all", "b": [0.7393, 0.7583, 0.759, 0.7797]}, {"w": "your", "b": [0.7661, 0.7583, 0.8051, 0.7797]}, {"w": "input", "b": [0.8122, 0.7583, 0.8571, 0.7797]}, {"w": "features", "b": [0.1429, 0.7773, 0.2083, 0.7987]}, {"w": "into", "b": [0.2155, 0.7773, 0.2491, 0.7987]}, {"w": "a", "b": [0.2564, 0.7773, 0.2655, 0.7987]}, {"w": "single", "b": [0.2728, 0.7773, 0.3213, 0.7987]}, {"w": "dense", "b": [0.3286, 0.7773, 0.3763, 0.7987]}, {"w": "vector", "b": [0.3836, 0.7773, 0.4356, 0.7987]}, {"w": "which", "b": [0.4429, 0.7773, 0.4938, 0.7987]}, {"w": "the", "b": [0.5011, 0.7773, 0.5274, 0.7987]}, {"w": "neural", "b": [0.5347, 0.7773, 0.5882, 0.7987]}, {"w": "network", "b": [0.5954, 0.7773, 0.665, 0.7987]}, {"w": "can", "b": [0.6723, 0.7773, 0.7016, 0.7987]}, {"w": "then", "b": [0.7089, 0.7773, 0.7466, 0.7987]}, {"w": "process.", "b": [0.7539, 0.7773, 0.8209, 0.7987]}, {"w": "For", "b": [0.8282, 0.7773, 0.8571, 0.7987]}, {"w": "this,", "b": [0.1429, 0.7973, 0.1783, 0.8187]}, {"w": "all", "b": [0.1841, 0.7973, 0.2038, 0.8187]}, {"w": "you", "b": [0.2096, 0.7973, 0.2409, 0.8187]}, {"w": "need", "b": [0.2467, 0.7973, 0.2868, 0.8187]}, {"w": "to", "b": [0.2926, 0.7973, 0.3096, 0.8187]}, {"w": "do", "b": [0.3154, 0.7973, 0.337, 0.8187]}, {"w": "is", "b": [0.3428, 0.7973, 0.3561, 0.8187]}, {"w": "add", "b": [0.3619, 0.7973, 0.393, 0.8187]}, {"w": "a", "b": [0.3988, 0.7973, 0.408, 0.8187]}, {"w": "keras.layers.DenseFeatures", "b": [0.4138, 0.8004, 0.6711, 0.8155]}, {"w": "layer", "b": [0.6769, 0.7973, 0.7171, 0.8187]}, {"w": "as", "b": [0.7229, 0.7973, 0.7397, 0.8187]}, {"w": "the", "b": [0.7455, 0.7973, 0.7718, 0.8187]}, {"w": "first", "b": [0.7777, 0.7973, 0.8111, 0.8187]}, {"w": "layer", "b": [0.8169, 0.7973, 0.8571, 0.8187]}, {"w": "in", "b": [0.1429, 0.8163, 0.1598, 0.8377]}, {"w": "your", "b": [0.1646, 0.8163, 0.2036, 0.8377]}, {"w": "model,", "b": [0.2083, 0.8163, 0.2658, 0.8377]}, {"w": "passing", "b": [0.2706, 0.8163, 0.3327, 0.8377]}, {"w": "it", "b": [0.3374, 0.8163, 0.3493, 0.8377]}, {"w": "the", "b": [0.3541, 0.8163, 0.3804, 0.8377]}, {"w": "list", "b": [0.3851, 0.8163, 0.41, 0.8377]}, {"w": "of", "b": [0.4147, 0.8163, 0.4315, 0.8377]}, {"w": "feature", "b": [0.4362, 0.8163, 0.494, 0.8377]}, {"w": "columns", "b": [0.4987, 0.8163, 0.5706, 0.8377]}, {"w": "(excluding", "b": [0.5753, 0.8163, 0.6641, 0.8377]}, {"w": "the", "b": [0.6688, 0.8163, 0.6952, 0.8377]}, {"w": "target", "b": [0.6999, 0.8163, 0.7481, 0.8377]}, {"w": "column):", "b": [0.7528, 0.8163, 0.829, 0.8377]}]}, {"id": "b_11", "type": "paragraph", "text": "columns_without_target = columns[:-1] model = keras.models.Sequential([ keras.layers.DenseFeatures(feature_columns=columns_without_target),", "words": [{"w": "columns_without_target", "b": [0.1766, 0.8483, 0.3621, 0.8611]}, {"w": "=", "b": [0.3705, 0.8483, 0.379, 0.8611]}, {"w": "columns[:-1]", "b": [0.3874, 0.8483, 0.4886, 0.8611]}, {"w": "model", "b": [0.1766, 0.8637, 0.2187, 0.8765]}, {"w": "=", "b": [0.2272, 0.8637, 0.2356, 0.8765]}, {"w": "keras.models.Sequential([", "b": [0.244, 0.8637, 0.4549, 0.8765]}, {"w": "keras.layers.DenseFeatures(feature_columns=columns_without_target),", "b": [0.2103, 0.8791, 0.7753, 0.892]}]}, {"id": "b_12", "type": "paragraph", "text": "426 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "426", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 453, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "keras.layers.Dense(1) ]) model.compile(loss=\"mse\", optimizer=\"sgd\", metrics=[\"accuracy\"]) steps_per_epoch = len(X_train) // batch_size history = model.fit(dataset, steps_per_epoch=steps_per_epoch, epochs=5)", "words": [{"w": "keras.layers.Dense(1)", "b": [0.2103, 0.0829, 0.3874, 0.0958]}, {"w": "])", "b": [0.1766, 0.0983, 0.1935, 0.1112]}, {"w": "model.compile(loss=\"mse\",", "b": [0.1766, 0.1138, 0.3874, 0.1266]}, {"w": "optimizer=\"sgd\",", "b": [0.3958, 0.1138, 0.5308, 0.1266]}, {"w": "metrics=[\"accuracy\"])", "b": [0.5392, 0.1138, 0.7163, 0.1266]}, {"w": "steps_per_epoch", "b": [0.1766, 0.1292, 0.3031, 0.142]}, {"w": "=", "b": [0.3115, 0.1292, 0.3199, 0.142]}, {"w": "len(X_train)", "b": [0.3284, 0.1292, 0.4296, 0.142]}, {"w": "//", "b": [0.438, 0.1292, 0.4549, 0.142]}, {"w": "batch_size", "b": [0.4633, 0.1292, 0.5476, 0.142]}, {"w": "history", "b": [0.1766, 0.1446, 0.2356, 0.1574]}, {"w": "=", "b": [0.244, 0.1446, 0.2525, 0.1574]}, {"w": "model.fit(dataset,", "b": [0.2609, 0.1446, 0.4127, 0.1574]}, {"w": "steps_per_epoch=steps_per_epoch,", "b": [0.4211, 0.1446, 0.691, 0.1574]}, {"w": "epochs=5)", "b": [0.6994, 0.1446, 0.7753, 0.1574]}]}, {"id": "b_1", "type": "paragraph", "text": "The DenseFeatures layer will take care of converting every input feature to a dense representation, and it will also apply any extra transformation we specified, such as scaling the housing_median_age using the normalizer_fn function we provided. You can take a closer look at what the DenseFeatures layer does by calling it directly:", "words": [{"w": "The", "b": [0.1429, 0.1661, 0.1757, 0.1875]}, {"w": "DenseFeatures", "b": [0.1822, 0.1693, 0.3109, 0.1844]}, {"w": "layer", "b": [0.3174, 0.1661, 0.3576, 0.1875]}, {"w": "will", "b": [0.3641, 0.1661, 0.3945, 0.1875]}, {"w": "take", "b": [0.401, 0.1661, 0.4357, 0.1875]}, {"w": "care", "b": [0.4422, 0.1661, 0.4767, 0.1875]}, {"w": "of", "b": [0.4833, 0.1661, 0.5, 0.1875]}, {"w": "converting", "b": [0.5066, 0.1661, 0.5962, 0.1875]}, {"w": "every", "b": [0.6027, 0.1661, 0.648, 0.1875]}, {"w": "input", "b": [0.6545, 0.1661, 0.6994, 0.1875]}, {"w": "feature", "b": [0.7059, 0.1661, 0.7637, 0.1875]}, {"w": "to", "b": [0.7702, 0.1661, 0.7872, 0.1875]}, {"w": "a", "b": [0.7937, 0.1661, 0.8029, 0.1875]}, {"w": "dense", "b": [0.8094, 0.1661, 0.8571, 0.1875]}, {"w": "representation,", "b": [0.1429, 0.1852, 0.2683, 0.2066]}, {"w": "and", "b": [0.2751, 0.1852, 0.3066, 0.2066]}, {"w": "it", "b": [0.3135, 0.1852, 0.3254, 0.2066]}, {"w": "will", "b": [0.3322, 0.1852, 0.3626, 0.2066]}, {"w": "also", "b": [0.3695, 0.1852, 0.4022, 0.2066]}, {"w": "apply", "b": [0.409, 0.1852, 0.4544, 0.2066]}, {"w": "any", "b": [0.4613, 0.1852, 0.4909, 0.2066]}, {"w": "extra", "b": [0.4977, 0.1852, 0.5397, 0.2066]}, {"w": "transformation", "b": [0.5465, 0.1852, 0.6731, 0.2066]}, {"w": "we", "b": [0.6799, 0.1852, 0.703, 0.2066]}, {"w": "specified,", "b": [0.7099, 0.1852, 0.788, 0.2066]}, {"w": "such", "b": [0.7949, 0.1852, 0.8335, 0.2066]}, {"w": "as", "b": [0.8403, 0.1852, 0.8571, 0.2066]}, {"w": "scaling", "b": [0.1428, 0.2051, 0.2005, 0.2265]}, {"w": "the", "b": [0.2052, 0.2051, 0.2315, 0.2265]}, {"w": "housing_median_age", "b": [0.2368, 0.2083, 0.4149, 0.2234]}, {"w": "using", "b": [0.4199, 0.2051, 0.4653, 0.2265]}, {"w": "the", "b": [0.47, 0.2051, 0.4964, 0.2265]}, {"w": "normalizer_fn", "b": [0.5016, 0.2083, 0.6302, 0.2234]}, {"w": "function", "b": [0.6352, 0.2051, 0.7066, 0.2265]}, {"w": "we", "b": [0.7116, 0.2051, 0.7347, 0.2265]}, {"w": "provided.", "b": [0.7397, 0.2051, 0.8198, 0.2265]}, {"w": "You", "b": [0.8248, 0.2051, 0.8571, 0.2265]}, {"w": "can", "b": [0.1429, 0.2251, 0.1722, 0.2465]}, {"w": "take", "b": [0.1769, 0.2251, 0.2116, 0.2465]}, {"w": "a", "b": [0.2164, 0.2251, 0.2255, 0.2465]}, {"w": "closer", "b": [0.2302, 0.2251, 0.2792, 0.2465]}, {"w": "look", "b": [0.2839, 0.2251, 0.3208, 0.2465]}, {"w": "at", "b": [0.3255, 0.2251, 0.3406, 0.2465]}, {"w": "what", "b": [0.3453, 0.2251, 0.3858, 0.2465]}, {"w": "the", "b": [0.3906, 0.2251, 0.4169, 0.2465]}, {"w": "DenseFeatures", "b": [0.4216, 0.2282, 0.5503, 0.2433]}, {"w": "layer", "b": [0.555, 0.2251, 0.5952, 0.2465]}, {"w": "does", "b": [0.5999, 0.2251, 0.638, 0.2465]}, {"w": "by", "b": [0.6428, 0.2251, 0.6629, 0.2465]}, {"w": "calling", "b": [0.6676, 0.2251, 0.7229, 0.2465]}, {"w": "it", "b": [0.7276, 0.2251, 0.7395, 0.2465]}, {"w": "directly:", "b": [0.7443, 0.2251, 0.8128, 0.2465]}]}, {"id": "b_2", "type": "paragraph", "text": ">>> some_columns = [ocean_proximity_embed, bucketized_income] >>> dense_features = keras.layers.DenseFeatures(some_columns) >>> dense_features({ ... \"ocean_proximity\": [[\"NEAR OCEAN\"], [\"INLAND\"], [\"INLAND\"]], ... \"median_income\": [[3.], [7.2], [1.]] ... }) ... ", "words": [{"w": ">>>", "b": [0.1766, 0.257, 0.2019, 0.2699]}, {"w": "some_columns", "b": [0.2103, 0.257, 0.3115, 0.2699]}, {"w": "=", "b": [0.3199, 0.257, 0.3284, 0.2699]}, {"w": "[ocean_proximity_embed,", "b": [0.3368, 0.257, 0.5308, 0.2699]}, {"w": "bucketized_income]", "b": [0.5392, 0.257, 0.691, 0.2699]}, {"w": ">>>", "b": [0.1766, 0.2725, 0.2019, 0.2853]}, {"w": "dense_features", "b": [0.2103, 0.2725, 0.3284, 0.2853]}, {"w": "=", "b": [0.3368, 0.2725, 0.3452, 0.2853]}, {"w": "keras.layers.DenseFeatures(some_columns)", "b": [0.3537, 0.2725, 0.691, 0.2853]}, {"w": ">>>", "b": [0.1766, 0.2879, 0.2019, 0.3007]}, {"w": "dense_features({", "b": [0.2103, 0.2879, 0.3452, 0.3007]}, {"w": "...", "b": [0.1766, 0.3033, 0.2019, 0.3161]}, {"w": "\"ocean_proximity\":", "b": [0.244, 0.3033, 0.3958, 0.3161]}, {"w": "[[\"NEAR", "b": [0.4043, 0.3033, 0.4633, 0.3161]}, {"w": "OCEAN\"],", "b": [0.4717, 0.3033, 0.5392, 0.3161]}, {"w": "[\"INLAND\"],", "b": [0.5476, 0.3033, 0.6404, 0.3161]}, {"w": "[\"INLAND\"]],", "b": [0.6488, 0.3033, 0.75, 0.3161]}, {"w": "...", "b": [0.1766, 0.3187, 0.2019, 0.3316]}, {"w": "\"median_income\":", "b": [0.244, 0.3187, 0.379, 0.3316]}, {"w": "[[3.],", "b": [0.3874, 0.3187, 0.438, 0.3316]}, {"w": "[7.2],", "b": [0.4464, 0.3187, 0.497, 0.3316]}, {"w": "[1.]]", "b": [0.5055, 0.3187, 0.5476, 0.3316]}, {"w": "...", "b": [0.1766, 0.3341, 0.2019, 0.347]}, {"w": "})", "b": [0.2103, 0.3341, 0.2272, 0.347]}, {"w": "...", "b": [0.1766, 0.3496, 0.2019, 0.3624]}, {"w": "", "b": [0.691, 0.4112, 0.8175, 0.4241]}]}, {"id": "b_3", "type": "paragraph", "text": "In this example, we create a DenseFeatures layer with just two columns, and we call it with some data, in the form of a dictionary of features. In this case, since the bucke tized_income column relies on the median_income column, the dictionary must include the \"median_income\" key, and similarly since the ocean_proximity_embed column is based on the ocean_proximity column, the dictionary must include the \"ocean_proximity\" key. Columns are handled in alphabetical order, so first we look at the bucketized income column (its name is the same as the median_income column name, plus \"_bucketized\"). The incomes 3, 7.2 and 1 get mapped respectively to cat‐ egory 2 (for incomes between 1.5 and 3), category 0 (for incomes below 1.5), and cat‐ egory 4 (for incomes greater than 6). Then these category IDs get one-hot encoded: category 2 gets encoded as [0., 0., 1., 0., 0.] and so on (note that bucketized columns get one-hot encoded by default, no need to call indicator_column()). Now on to the ocean_proximity_embed column. The \"NEAR OCEAN\" and \"INLAND\" cate‐ gories just get mapped to their respective embeddings (which were initialized ran‐ domly). The resulting tensor is the concatenation of the one-hot vectors and the embeddings.", "words": [{"w": "In", "b": [0.1429, 0.4328, 0.1614, 0.4542]}, {"w": "this", "b": [0.1672, 0.4328, 0.1979, 0.4542]}, {"w": "example,", "b": [0.2037, 0.4328, 0.278, 0.4542]}, {"w": "we", "b": [0.2838, 0.4328, 0.307, 0.4542]}, {"w": "create", "b": [0.3128, 0.4328, 0.3621, 0.4542]}, {"w": "a", "b": [0.368, 0.4328, 0.3771, 0.4542]}, {"w": "DenseFeatures", "b": [0.3829, 0.4359, 0.5116, 0.451]}, {"w": "layer", "b": [0.5174, 0.4328, 0.5576, 0.4542]}, {"w": "with", "b": [0.5634, 0.4328, 0.6008, 0.4542]}, {"w": "just", "b": [0.6066, 0.4328, 0.637, 0.4542]}, {"w": "two", "b": [0.6428, 0.4328, 0.674, 0.4542]}, {"w": "columns,", "b": [0.6799, 0.4328, 0.7565, 0.4542]}, {"w": "and", "b": [0.7623, 0.4328, 0.7939, 0.4542]}, {"w": "we", "b": [0.7997, 0.4328, 0.8228, 0.4542]}, {"w": "call", "b": [0.8286, 0.4328, 0.8571, 0.4542]}, {"w": "it", "b": [0.1428, 0.4527, 0.1548, 0.4741]}, {"w": "with", "b": [0.1601, 0.4527, 0.1974, 0.4741]}, {"w": "some", "b": [0.2027, 0.4527, 0.2468, 0.4741]}, {"w": "data,", "b": [0.2521, 0.4527, 0.2921, 0.4741]}, {"w": "in", "b": [0.2974, 0.4527, 0.3144, 0.4741]}, {"w": "the", "b": [0.3196, 0.4527, 0.346, 0.4741]}, {"w": "form", "b": [0.3512, 0.4527, 0.3928, 0.4741]}, {"w": "of", "b": [0.3981, 0.4527, 0.4149, 0.4741]}, {"w": "a", "b": [0.4202, 0.4527, 0.4293, 0.4741]}, {"w": "dictionary", "b": [0.4346, 0.4527, 0.521, 0.4741]}, {"w": "of", "b": [0.5262, 0.4527, 0.543, 0.4741]}, {"w": "features.", "b": [0.5483, 0.4527, 0.6185, 0.4741]}, {"w": "In", "b": [0.6237, 0.4527, 0.6422, 0.4741]}, {"w": "this", "b": [0.6475, 0.4527, 0.6782, 0.4741]}, {"w": "case,", "b": [0.6835, 0.4527, 0.7227, 0.4741]}, {"w": "since", "b": [0.728, 0.4527, 0.7703, 0.4741]}, {"w": "the", "b": [0.7755, 0.4527, 0.8019, 0.4741]}, {"w": "bucke", "b": [0.8071, 0.4559, 0.8566, 0.471]}, {"w": "tized_income", "b": [0.1429, 0.4758, 0.2616, 0.4909]}, {"w": "column", "b": [0.2713, 0.4727, 0.3355, 0.4941]}, {"w": "relies", "b": [0.3452, 0.4727, 0.3891, 0.4941]}, {"w": "on", "b": [0.3987, 0.4727, 0.4208, 0.4941]}, {"w": "the", "b": [0.4304, 0.4727, 0.4568, 0.4941]}, {"w": "median_income", "b": [0.4664, 0.4758, 0.5951, 0.4909]}, {"w": "column,", "b": [0.6047, 0.4727, 0.6737, 0.4941]}, {"w": "the", "b": [0.6834, 0.4727, 0.7097, 0.4941]}, {"w": "dictionary", "b": [0.7194, 0.4727, 0.8057, 0.4941]}, {"w": "must", "b": [0.8154, 0.4727, 0.8571, 0.4941]}, {"w": "include", "b": [0.1428, 0.4926, 0.2048, 0.514]}, {"w": "the", "b": [0.2129, 0.4926, 0.2392, 0.514]}, {"w": "\"median_income\"", "b": [0.2473, 0.4958, 0.3958, 0.5109]}, {"w": "key,", "b": [0.4039, 0.4926, 0.4358, 0.514]}, {"w": "and", "b": [0.4439, 0.4926, 0.4755, 0.514]}, {"w": "similarly", "b": [0.4836, 0.4926, 0.5564, 0.514]}, {"w": "since", "b": [0.5645, 0.4926, 0.6068, 0.514]}, {"w": "the", "b": [0.6149, 0.4926, 0.6412, 0.514]}, {"w": "ocean_proximity_embed", "b": [0.6493, 0.4958, 0.8571, 0.5109]}, {"w": "column", "b": [0.1429, 0.5125, 0.2071, 0.534]}, {"w": "is", "b": [0.2145, 0.5125, 0.2277, 0.534]}, {"w": "based", "b": [0.2351, 0.5125, 0.2823, 0.534]}, {"w": "on", "b": [0.2897, 0.5125, 0.3117, 0.534]}, {"w": "the", "b": [0.319, 0.5125, 0.3454, 0.534]}, {"w": "ocean_proximity", "b": [0.3527, 0.5157, 0.5012, 0.5308]}, {"w": "column,", "b": [0.5086, 0.5125, 0.5775, 0.534]}, {"w": "the", "b": [0.5849, 0.5125, 0.6112, 0.534]}, {"w": "dictionary", "b": [0.6186, 0.5125, 0.705, 0.534]}, {"w": "must", "b": [0.7124, 0.5125, 0.7541, 0.534]}, {"w": "include", "b": [0.7615, 0.5125, 0.8234, 0.534]}, {"w": "the", "b": [0.8308, 0.5125, 0.8571, 0.534]}, {"w": "\"ocean_proximity\"", "b": [0.1428, 0.5357, 0.3111, 0.5507]}, {"w": "key.", "b": [0.317, 0.5325, 0.349, 0.5539]}, {"w": "Columns", "b": [0.3549, 0.5325, 0.4319, 0.5539]}, {"w": "are", "b": [0.4378, 0.5325, 0.4635, 0.5539]}, {"w": "handled", "b": [0.4695, 0.5325, 0.5373, 0.5539]}, {"w": "in", "b": [0.5432, 0.5325, 0.5602, 0.5539]}, {"w": "alphabetical", "b": [0.5661, 0.5325, 0.6663, 0.5539]}, {"w": "order,", "b": [0.6723, 0.5325, 0.7216, 0.5539]}, {"w": "so", "b": [0.7276, 0.5325, 0.7459, 0.5539]}, {"w": "first", "b": [0.7518, 0.5325, 0.7853, 0.5539]}, {"w": "we", "b": [0.7912, 0.5325, 0.8143, 0.5539]}, {"w": "look", "b": [0.8203, 0.5325, 0.8571, 0.5539]}, {"w": "at", "b": [0.1429, 0.5524, 0.158, 0.5738]}, {"w": "the", "b": [0.1629, 0.5524, 0.1893, 0.5738]}, {"w": "bucketized", "b": [0.1942, 0.5524, 0.2844, 0.5738]}, {"w": "income", "b": [0.2894, 0.5524, 0.3517, 0.5738]}, {"w": "column", "b": [0.3567, 0.5524, 0.4209, 0.5738]}, {"w": "(its", "b": [0.4259, 0.5524, 0.4527, 0.5738]}, {"w": "name", "b": [0.4576, 0.5524, 0.5041, 0.5738]}, {"w": "is", "b": [0.5091, 0.5524, 0.5223, 0.5738]}, {"w": "the", "b": [0.5273, 0.5524, 0.5536, 0.5738]}, {"w": "same", "b": [0.5586, 0.5524, 0.6013, 0.5738]}, {"w": "as", "b": [0.6062, 0.5524, 0.623, 0.5738]}, {"w": "the", "b": [0.628, 0.5524, 0.6543, 0.5738]}, {"w": "median_income", "b": [0.6593, 0.5556, 0.7879, 0.5707]}, {"w": "column", "b": [0.7929, 0.5524, 0.8571, 0.5738]}, {"w": "name,", "b": [0.1428, 0.5724, 0.1941, 0.5938]}, {"w": "plus", "b": [0.1988, 0.5724, 0.2337, 0.5938]}, {"w": "\"_bucketized\").", "b": [0.2389, 0.5724, 0.3795, 0.5938]}, {"w": "The", "b": [0.3845, 0.5724, 0.4174, 0.5938]}, {"w": "incomes", "b": [0.4224, 0.5724, 0.4923, 0.5938]}, {"w": "3,", "b": [0.4973, 0.5724, 0.5121, 0.5938]}, {"w": "7.2", "b": [0.5171, 0.5724, 0.5418, 0.5938]}, {"w": "and", "b": [0.5468, 0.5724, 0.5783, 0.5938]}, {"w": "1", "b": [0.5833, 0.5724, 0.5933, 0.5938]}, {"w": "get", "b": [0.5983, 0.5724, 0.6233, 0.5938]}, {"w": "mapped", "b": [0.6283, 0.5724, 0.6958, 0.5938]}, {"w": "respectively", "b": [0.7008, 0.5724, 0.7989, 0.5938]}, {"w": "to", "b": [0.8038, 0.5724, 0.8208, 0.5938]}, {"w": "cat‐", "b": [0.8258, 0.5724, 0.8571, 0.5938]}, {"w": "egory", "b": [0.1429, 0.5914, 0.19, 0.6128]}, {"w": "2", "b": [0.1951, 0.5914, 0.2051, 0.6128]}, {"w": "(for", "b": [0.2101, 0.5914, 0.2419, 0.6128]}, {"w": "incomes", "b": [0.2469, 0.5914, 0.3169, 0.6128]}, {"w": "between", "b": [0.322, 0.5914, 0.3911, 0.6128]}, {"w": "1.5", "b": [0.3962, 0.5914, 0.421, 0.6128]}, {"w": "and", "b": [0.426, 0.5914, 0.4576, 0.6128]}, {"w": "3),", "b": [0.4627, 0.5914, 0.4846, 0.6128]}, {"w": "category", "b": [0.4897, 0.5914, 0.5607, 0.6128]}, {"w": "0", "b": [0.5658, 0.5914, 0.5758, 0.6128]}, {"w": "(for", "b": [0.5809, 0.5914, 0.6126, 0.6128]}, {"w": "incomes", "b": [0.6177, 0.5914, 0.6877, 0.6128]}, {"w": "below", "b": [0.6927, 0.5914, 0.7423, 0.6128]}, {"w": "1.5),", "b": [0.7474, 0.5914, 0.7841, 0.6128]}, {"w": "and", "b": [0.7892, 0.5914, 0.8207, 0.6128]}, {"w": "cat‐", "b": [0.8258, 0.5914, 0.8571, 0.6128]}, {"w": "egory", "b": [0.1428, 0.6105, 0.19, 0.6319]}, {"w": "4", "b": [0.1963, 0.6105, 0.2063, 0.6319]}, {"w": "(for", "b": [0.2127, 0.6105, 0.2444, 0.6319]}, {"w": "incomes", "b": [0.2508, 0.6105, 0.3208, 0.6319]}, {"w": "greater", "b": [0.3271, 0.6105, 0.3851, 0.6319]}, {"w": "than", "b": [0.3915, 0.6105, 0.4295, 0.6319]}, {"w": "6).", "b": [0.4359, 0.6105, 0.4578, 0.6319]}, {"w": "Then", "b": [0.4642, 0.6105, 0.5084, 0.6319]}, {"w": "these", "b": [0.5148, 0.6105, 0.5576, 0.6319]}, {"w": "category", "b": [0.564, 0.6105, 0.635, 0.6319]}, {"w": "IDs", "b": [0.6414, 0.6105, 0.6714, 0.6319]}, {"w": "get", "b": [0.6778, 0.6105, 0.7027, 0.6319]}, {"w": "one-hot", "b": [0.7091, 0.6105, 0.7755, 0.6319]}, {"w": "encoded:", "b": [0.7818, 0.6105, 0.8571, 0.6319]}, {"w": "category", "b": [0.1429, 0.6304, 0.2139, 0.6518]}, {"w": "2", "b": [0.2203, 0.6304, 0.2303, 0.6518]}, {"w": "gets", "b": [0.2366, 0.6304, 0.2693, 0.6518]}, {"w": "encoded", "b": [0.2756, 0.6304, 0.3462, 0.6518]}, {"w": "as", "b": [0.3525, 0.6304, 0.3693, 0.6518]}, {"w": "[0.,", "b": [0.3757, 0.6336, 0.4153, 0.6487]}, {"w": "0.,", "b": [0.4267, 0.6336, 0.4564, 0.6487]}, {"w": "1.,", "b": [0.4679, 0.6336, 0.4976, 0.6487]}, {"w": "0.,", "b": [0.509, 0.6336, 0.5387, 0.6487]}, {"w": "0.]", "b": [0.5502, 0.6336, 0.5799, 0.6487]}, {"w": "and", "b": [0.5862, 0.6304, 0.6178, 0.6518]}, {"w": "so", "b": [0.6242, 0.6304, 0.6424, 0.6518]}, {"w": "on", "b": [0.6488, 0.6304, 0.6708, 0.6518]}, {"w": "(note", "b": [0.6772, 0.6304, 0.7216, 0.6518]}, {"w": "that", "b": [0.728, 0.6304, 0.7606, 0.6518]}, {"w": "bucketized", "b": [0.767, 0.6304, 0.8571, 0.6518]}, {"w": "columns", "b": [0.1429, 0.6504, 0.2147, 0.6718]}, {"w": "get", "b": [0.2202, 0.6504, 0.2452, 0.6718]}, {"w": "one-hot", "b": [0.2507, 0.6504, 0.3171, 0.6718]}, {"w": "encoded", "b": [0.3226, 0.6504, 0.3932, 0.6718]}, {"w": "by", "b": [0.3987, 0.6504, 0.4188, 0.6718]}, {"w": "default,", "b": [0.4243, 0.6504, 0.4865, 0.6718]}, {"w": "no", "b": [0.492, 0.6504, 0.5141, 0.6718]}, {"w": "need", "b": [0.5196, 0.6504, 0.5597, 0.6718]}, {"w": "to", "b": [0.5652, 0.6504, 0.5822, 0.6718]}, {"w": "call", "b": [0.5877, 0.6504, 0.6162, 0.6718]}, {"w": "indicator_column()).", "b": [0.6217, 0.6504, 0.8118, 0.6718]}, {"w": "Now", "b": [0.8173, 0.6504, 0.8571, 0.6718]}, {"w": "on", "b": [0.1428, 0.6703, 0.1649, 0.6917]}, {"w": "to", "b": [0.1723, 0.6703, 0.1893, 0.6917]}, {"w": "the", "b": [0.1968, 0.6703, 0.2231, 0.6917]}, {"w": "ocean_proximity_embed", "b": [0.2305, 0.6735, 0.4384, 0.6886]}, {"w": "column.", "b": [0.4458, 0.6703, 0.5148, 0.6917]}, {"w": "The", "b": [0.5222, 0.6703, 0.5551, 0.6917]}, {"w": "\"NEAR", "b": [0.5625, 0.6735, 0.612, 0.6886]}, {"w": "OCEAN\"", "b": [0.6245, 0.6735, 0.6839, 0.6886]}, {"w": "and", "b": [0.6913, 0.6703, 0.7229, 0.6917]}, {"w": "\"INLAND\"", "b": [0.7303, 0.6735, 0.8095, 0.6886]}, {"w": "cate‐", "b": [0.8169, 0.6703, 0.8571, 0.6917]}, {"w": "gories", "b": [0.1429, 0.6893, 0.1931, 0.7108]}, {"w": "just", "b": [0.2006, 0.6893, 0.231, 0.7108]}, {"w": "get", "b": [0.2385, 0.6893, 0.2635, 0.7108]}, {"w": "mapped", "b": [0.271, 0.6893, 0.3385, 0.7108]}, {"w": "to", "b": [0.3461, 0.6893, 0.3631, 0.7108]}, {"w": "their", "b": [0.3706, 0.6893, 0.4103, 0.7108]}, {"w": "respective", "b": [0.4178, 0.6893, 0.5011, 0.7108]}, {"w": "embeddings", "b": [0.5086, 0.6893, 0.6103, 0.7108]}, {"w": "(which", "b": [0.6179, 0.6893, 0.676, 0.7108]}, {"w": "were", "b": [0.6836, 0.6893, 0.7233, 0.7108]}, {"w": "initialized", "b": [0.7308, 0.6893, 0.8139, 0.7108]}, {"w": "ran‐", "b": [0.8215, 0.6893, 0.8571, 0.7108]}, {"w": "domly).", "b": [0.1429, 0.7084, 0.2083, 0.7298]}, {"w": "The", "b": [0.2171, 0.7084, 0.25, 0.7298]}, {"w": "resulting", "b": [0.2587, 0.7084, 0.3324, 0.7298]}, {"w": "tensor", "b": [0.3412, 0.7084, 0.3938, 0.7298]}, {"w": "is", "b": [0.4025, 0.7084, 0.4158, 0.7298]}, {"w": "the", "b": [0.4246, 0.7084, 0.4509, 0.7298]}, {"w": "concatenation", "b": [0.4597, 0.7084, 0.5774, 0.7298]}, {"w": "of", "b": [0.5862, 0.7084, 0.603, 0.7298]}, {"w": "the", "b": [0.6117, 0.7084, 0.6381, 0.7298]}, {"w": "one-hot", "b": [0.6469, 0.7084, 0.7133, 0.7298]}, {"w": "vectors", "b": [0.722, 0.7084, 0.7817, 0.7298]}, {"w": "and", "b": [0.7905, 0.7084, 0.822, 0.7298]}, {"w": "the", "b": [0.8308, 0.7084, 0.8571, 0.7298]}, {"w": "embeddings.", "b": [0.1429, 0.7274, 0.2493, 0.7489]}]}, {"id": "b_4", "type": "paragraph", "text": "Now you can feed all kinds of features to a neural network, including numerical fea‐ tures, categorical features, and even text (by splitting the text into words, then using word embedding)! However, performing all the preprocessing on the fly can slow down training. Let’s see how this can be improved.", "words": [{"w": "Now", "b": [0.1429, 0.7556, 0.1827, 0.777]}, {"w": "you", "b": [0.1885, 0.7556, 0.2198, 0.777]}, {"w": "can", "b": [0.2256, 0.7556, 0.2549, 0.777]}, {"w": "feed", "b": [0.2607, 0.7556, 0.2956, 0.777]}, {"w": "all", "b": [0.3014, 0.7556, 0.3211, 0.777]}, {"w": "kinds", "b": [0.3269, 0.7556, 0.3728, 0.777]}, {"w": "of", "b": [0.3786, 0.7556, 0.3954, 0.777]}, {"w": "features", "b": [0.4012, 0.7556, 0.4667, 0.777]}, {"w": "to", "b": [0.4725, 0.7556, 0.4894, 0.777]}, {"w": "a", "b": [0.4952, 0.7556, 0.5044, 0.777]}, {"w": "neural", "b": [0.5102, 0.7556, 0.5637, 0.777]}, {"w": "network,", "b": [0.5695, 0.7556, 0.6438, 0.777]}, {"w": "including", "b": [0.6496, 0.7556, 0.7294, 0.777]}, {"w": "numerical", "b": [0.7352, 0.7556, 0.8198, 0.777]}, {"w": "fea‐", "b": [0.8256, 0.7556, 0.8571, 0.777]}, {"w": "tures,", "b": [0.1428, 0.7746, 0.1892, 0.796]}, {"w": "categorical", "b": [0.1954, 0.7746, 0.2851, 0.796]}, {"w": "features,", "b": [0.2912, 0.7746, 0.3614, 0.796]}, {"w": "and", "b": [0.3675, 0.7746, 0.399, 0.796]}, {"w": "even", "b": [0.4051, 0.7746, 0.4439, 0.796]}, {"w": "text", "b": [0.45, 0.7746, 0.4814, 0.796]}, {"w": "(by", "b": [0.4875, 0.7746, 0.5149, 0.796]}, {"w": "splitting", "b": [0.521, 0.7746, 0.5899, 0.796]}, {"w": "the", "b": [0.596, 0.7746, 0.6223, 0.796]}, {"w": "text", "b": [0.6285, 0.7746, 0.6599, 0.796]}, {"w": "into", "b": [0.666, 0.7746, 0.6996, 0.796]}, {"w": "words,", "b": [0.7057, 0.7746, 0.7617, 0.796]}, {"w": "then", "b": [0.7678, 0.7746, 0.8056, 0.796]}, {"w": "using", "b": [0.8117, 0.7746, 0.8571, 0.796]}, {"w": "word", "b": [0.1429, 0.7937, 0.1865, 0.8151]}, {"w": "embedding)!", "b": [0.1947, 0.7937, 0.3017, 0.8151]}, {"w": "However,", "b": [0.3099, 0.7937, 0.3887, 0.8151]}, {"w": "performing", "b": [0.3969, 0.7937, 0.4927, 0.8151]}, {"w": "all", "b": [0.5009, 0.7937, 0.5206, 0.8151]}, {"w": "the", "b": [0.5288, 0.7937, 0.5551, 0.8151]}, {"w": "preprocessing", "b": [0.5633, 0.7937, 0.6797, 0.8151]}, {"w": "on", "b": [0.6879, 0.7937, 0.7099, 0.8151]}, {"w": "the", "b": [0.7181, 0.7937, 0.7444, 0.8151]}, {"w": "fly", "b": [0.7526, 0.7937, 0.7736, 0.8151]}, {"w": "can", "b": [0.7818, 0.7937, 0.8112, 0.8151]}, {"w": "slow", "b": [0.8193, 0.7937, 0.8571, 0.8151]}, {"w": "down", "b": [0.1429, 0.8127, 0.1901, 0.8341]}, {"w": "training.", "b": [0.1949, 0.8127, 0.2666, 0.8341]}, {"w": "Let’s", "b": [0.2713, 0.8127, 0.3075, 0.8341]}, {"w": "see", "b": [0.3122, 0.8127, 0.3375, 0.8341]}, {"w": "how", "b": [0.3423, 0.8127, 0.3783, 0.8341]}, {"w": "this", "b": [0.383, 0.8127, 0.4137, 0.8341]}, {"w": "can", "b": [0.4185, 0.8127, 0.4478, 0.8341]}, {"w": "be", "b": [0.4525, 0.8127, 0.472, 0.8341]}, {"w": "improved.", "b": [0.4767, 0.8127, 0.5625, 0.8341]}]}, {"id": "b_5", "type": "paragraph", "text": "The Features API | 427", "words": [{"w": "The", "b": [0.6981, 0.9225, 0.7196, 0.9388]}, {"w": "Features", "b": [0.7224, 0.9225, 0.7733, 0.9388]}, {"w": "API", "b": [0.7761, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "427", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 454, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "TF Transform", "words": [{"w": "TF", "b": [0.1429, 0.0753, 0.1709, 0.1095]}, {"w": "Transform", "b": [0.1768, 0.0753, 0.3038, 0.1095]}]}, {"id": "b_1", "type": "paragraph", "text": "If preprocessing is computationally expensive, then handling it before training rather than on the fly may give you a significant speedup: the data will be preprocessed just once per instance before training, rather than once per instance and per epoch during training. Tools like Apache Beam let you run efficient data processing pipelines over large amounts of data, even distributed across multiple servers, so why not use it to preprocess all the training data? This works great and indeed can speed up training, but there is one problem: once your model is trained, suppose you want to deploy it to a mobile app: you will need to write some code in your app to take care of prepro‐ cessing the data before it is fed to the model. And suppose you also want to deploy the model to TensorFlow.js so it runs in a web browser? Once again, you will need to write some preprocessing code. This can become a maintenance nightmare: when‐ ever you want to change the preprocessing logic, you will need to update your Apache Beam code, your mobile app code and your Javascript code. It is not only time con‐ suming, but also error prone: you may end up with subtle differences between the preprocessing operations performed before training and the ones performed in your app or in the browser. This training/serving skew will lead to bugs or degraded perfor‐ mance.", "words": [{"w": "If", "b": [0.1428, 0.1164, 0.1561, 0.1378]}, {"w": "preprocessing", "b": [0.1615, 0.1164, 0.278, 0.1378]}, {"w": "is", "b": [0.2834, 0.1164, 0.2966, 0.1378]}, {"w": "computationally", "b": [0.302, 0.1164, 0.4384, 0.1378]}, {"w": "expensive,", "b": [0.4438, 0.1164, 0.5301, 0.1378]}, {"w": "then", "b": [0.5355, 0.1164, 0.5733, 0.1378]}, {"w": "handling", "b": [0.5786, 0.1164, 0.6533, 0.1378]}, {"w": "it", "b": [0.6587, 0.1164, 0.6707, 0.1378]}, {"w": "before", "b": [0.676, 0.1164, 0.7289, 0.1378]}, {"w": "training", "b": [0.7343, 0.1164, 0.8012, 0.1378]}, {"w": "rather", "b": [0.8066, 0.1164, 0.8571, 0.1378]}, {"w": "than", "b": [0.1429, 0.1355, 0.1809, 0.1569]}, {"w": "on", "b": [0.1865, 0.1355, 0.2086, 0.1569]}, {"w": "the", "b": [0.2142, 0.1355, 0.2406, 0.1569]}, {"w": "fly", "b": [0.2462, 0.1355, 0.2672, 0.1569]}, {"w": "may", "b": [0.2729, 0.1355, 0.3083, 0.1569]}, {"w": "give", "b": [0.3139, 0.1355, 0.3478, 0.1569]}, {"w": "you", "b": [0.3534, 0.1355, 0.3847, 0.1569]}, {"w": "a", "b": [0.3903, 0.1355, 0.3995, 0.1569]}, {"w": "significant", "b": [0.4051, 0.1355, 0.4921, 0.1569]}, {"w": "speedup:", "b": [0.4978, 0.1355, 0.5718, 0.1569]}, {"w": "the", "b": [0.5775, 0.1355, 0.6038, 0.1569]}, {"w": "data", "b": [0.6095, 0.1355, 0.6447, 0.1569]}, {"w": "will", "b": [0.6504, 0.1355, 0.6808, 0.1569]}, {"w": "be", "b": [0.6864, 0.1355, 0.7059, 0.1569]}, {"w": "preprocessed", "b": [0.7115, 0.1355, 0.8211, 0.1569]}, {"w": "just", "b": [0.8268, 0.1355, 0.8571, 0.1569]}, {"w": "once", "b": [0.1429, 0.1545, 0.1825, 0.1759]}, {"w": "per", "b": [0.1879, 0.1545, 0.2154, 0.1759]}, {"w": "instance", "b": [0.2207, 0.1545, 0.2898, 0.1759]}, {"w": "before", "b": [0.2952, 0.1543, 0.3441, 0.1759]}, {"w": "training,", "b": [0.3494, 0.1545, 0.4211, 0.1759]}, {"w": "rather", "b": [0.4264, 0.1545, 0.477, 0.1759]}, {"w": "than", "b": [0.4823, 0.1545, 0.5203, 0.1759]}, {"w": "once", "b": [0.5256, 0.1545, 0.5653, 0.1759]}, {"w": "per", "b": [0.5706, 0.1545, 0.5981, 0.1759]}, {"w": "instance", "b": [0.6034, 0.1545, 0.6726, 0.1759]}, {"w": "and", "b": [0.6779, 0.1545, 0.7094, 0.1759]}, {"w": "per", "b": [0.7148, 0.1545, 0.7423, 0.1759]}, {"w": "epoch", "b": [0.7476, 0.1545, 0.7979, 0.1759]}, {"w": "during", "b": [0.8032, 0.1543, 0.8571, 0.1759]}, {"w": "training.", "b": [0.1429, 0.1736, 0.2145, 0.195]}, {"w": "Tools", "b": [0.2205, 0.1736, 0.2655, 0.195]}, {"w": "like", "b": [0.2715, 0.1736, 0.3016, 0.195]}, {"w": "Apache", "b": [0.3076, 0.1736, 0.37, 0.195]}, {"w": "Beam", "b": [0.376, 0.1736, 0.4237, 0.195]}, {"w": "let", "b": [0.4297, 0.1736, 0.4502, 0.195]}, {"w": "you", "b": [0.4562, 0.1736, 0.4875, 0.195]}, {"w": "run", "b": [0.4935, 0.1736, 0.5236, 0.195]}, {"w": "efficient", "b": [0.5297, 0.1736, 0.597, 0.195]}, {"w": "data", "b": [0.603, 0.1736, 0.6383, 0.195]}, {"w": "processing", "b": [0.6443, 0.1736, 0.7333, 0.195]}, {"w": "pipelines", "b": [0.7393, 0.1736, 0.8143, 0.195]}, {"w": "over", "b": [0.8203, 0.1736, 0.8571, 0.195]}, {"w": "large", "b": [0.1428, 0.1926, 0.1836, 0.214]}, {"w": "amounts", "b": [0.1901, 0.1926, 0.263, 0.214]}, {"w": "of", "b": [0.2695, 0.1926, 0.2862, 0.214]}, {"w": "data,", "b": [0.2927, 0.1926, 0.3327, 0.214]}, {"w": "even", "b": [0.3392, 0.1926, 0.378, 0.214]}, {"w": "distributed", "b": [0.3844, 0.1926, 0.4762, 0.214]}, {"w": "across", "b": [0.4827, 0.1926, 0.5343, 0.214]}, {"w": "multiple", "b": [0.5407, 0.1926, 0.6107, 0.214]}, {"w": "servers,", "b": [0.6172, 0.1926, 0.6807, 0.214]}, {"w": "so", "b": [0.6871, 0.1926, 0.7054, 0.214]}, {"w": "why", "b": [0.7119, 0.1926, 0.7464, 0.214]}, {"w": "not", "b": [0.7528, 0.1926, 0.7812, 0.214]}, {"w": "use", "b": [0.7877, 0.1926, 0.8153, 0.214]}, {"w": "it", "b": [0.8217, 0.1926, 0.8337, 0.214]}, {"w": "to", "b": [0.8402, 0.1926, 0.8571, 0.214]}, {"w": "preprocess", "b": [0.1429, 0.2117, 0.2326, 0.2331]}, {"w": "all", "b": [0.2388, 0.2117, 0.2585, 0.2331]}, {"w": "the", "b": [0.2647, 0.2117, 0.291, 0.2331]}, {"w": "training", "b": [0.2972, 0.2117, 0.3642, 0.2331]}, {"w": "data?", "b": [0.3704, 0.2117, 0.4135, 0.2331]}, {"w": "This", "b": [0.4197, 0.2117, 0.4569, 0.2331]}, {"w": "works", "b": [0.4631, 0.2117, 0.5137, 0.2331]}, {"w": "great", "b": [0.52, 0.2117, 0.5614, 0.2331]}, {"w": "and", "b": [0.5676, 0.2117, 0.5991, 0.2331]}, {"w": "indeed", "b": [0.6053, 0.2117, 0.662, 0.2331]}, {"w": "can", "b": [0.6682, 0.2117, 0.6976, 0.2331]}, {"w": "speed", "b": [0.7038, 0.2117, 0.7511, 0.2331]}, {"w": "up", "b": [0.7573, 0.2117, 0.7793, 0.2331]}, {"w": "training,", "b": [0.7855, 0.2117, 0.8571, 0.2331]}, {"w": "but", "b": [0.1429, 0.2307, 0.1709, 0.2521]}, {"w": "there", "b": [0.1768, 0.2307, 0.2197, 0.2521]}, {"w": "is", "b": [0.2257, 0.2307, 0.2389, 0.2521]}, {"w": "one", "b": [0.2448, 0.2307, 0.2757, 0.2521]}, {"w": "problem:", "b": [0.2816, 0.2307, 0.3574, 0.2521]}, {"w": "once", "b": [0.3634, 0.2307, 0.4031, 0.2521]}, {"w": "your", "b": [0.409, 0.2307, 0.448, 0.2521]}, {"w": "model", "b": [0.4539, 0.2307, 0.5067, 0.2521]}, {"w": "is", "b": [0.5127, 0.2307, 0.5259, 0.2521]}, {"w": "trained,", "b": [0.5318, 0.2307, 0.5967, 0.2521]}, {"w": "suppose", "b": [0.6026, 0.2307, 0.6703, 0.2521]}, {"w": "you", "b": [0.6762, 0.2307, 0.7075, 0.2521]}, {"w": "want", "b": [0.7134, 0.2307, 0.7542, 0.2521]}, {"w": "to", "b": [0.7601, 0.2307, 0.7771, 0.2521]}, {"w": "deploy", "b": [0.783, 0.2307, 0.8393, 0.2521]}, {"w": "it", "b": [0.8452, 0.2307, 0.8571, 0.2521]}, {"w": "to", "b": [0.1429, 0.2498, 0.1598, 0.2712]}, {"w": "a", "b": [0.1652, 0.2498, 0.1743, 0.2712]}, {"w": "mobile", "b": [0.1797, 0.2498, 0.2376, 0.2712]}, {"w": "app:", "b": [0.243, 0.2498, 0.2783, 0.2712]}, {"w": "you", "b": [0.2836, 0.2498, 0.3149, 0.2712]}, {"w": "will", "b": [0.3202, 0.2498, 0.3506, 0.2712]}, {"w": "need", "b": [0.356, 0.2498, 0.3961, 0.2712]}, {"w": "to", "b": [0.4014, 0.2498, 0.4184, 0.2712]}, {"w": "write", "b": [0.4237, 0.2498, 0.4665, 0.2712]}, {"w": "some", "b": [0.4719, 0.2498, 0.5161, 0.2712]}, {"w": "code", "b": [0.5214, 0.2498, 0.5607, 0.2712]}, {"w": "in", "b": [0.566, 0.2498, 0.583, 0.2712]}, {"w": "your", "b": [0.5883, 0.2498, 0.6273, 0.2712]}, {"w": "app", "b": [0.6327, 0.2498, 0.6632, 0.2712]}, {"w": "to", "b": [0.6686, 0.2498, 0.6856, 0.2712]}, {"w": "take", "b": [0.6909, 0.2498, 0.7256, 0.2712]}, {"w": "care", "b": [0.7309, 0.2498, 0.7655, 0.2712]}, {"w": "of", "b": [0.7708, 0.2498, 0.7876, 0.2712]}, {"w": "prepro‐", "b": [0.7929, 0.2498, 0.8571, 0.2712]}, {"w": "cessing", "b": [0.1429, 0.2688, 0.2026, 0.2902]}, {"w": "the", "b": [0.2092, 0.2688, 0.2355, 0.2902]}, {"w": "data", "b": [0.2421, 0.2688, 0.2774, 0.2902]}, {"w": "before", "b": [0.284, 0.2688, 0.3368, 0.2902]}, {"w": "it", "b": [0.3434, 0.2688, 0.3553, 0.2902]}, {"w": "is", "b": [0.3619, 0.2688, 0.3752, 0.2902]}, {"w": "fed", "b": [0.3818, 0.2688, 0.4078, 0.2902]}, {"w": "to", "b": [0.4144, 0.2688, 0.4314, 0.2902]}, {"w": "the", "b": [0.438, 0.2688, 0.4643, 0.2902]}, {"w": "model.", "b": [0.4709, 0.2688, 0.5285, 0.2902]}, {"w": "And", "b": [0.5351, 0.2688, 0.5719, 0.2902]}, {"w": "suppose", "b": [0.5785, 0.2688, 0.6462, 0.2902]}, {"w": "you", "b": [0.6528, 0.2688, 0.684, 0.2902]}, {"w": "also", "b": [0.6907, 0.2688, 0.7233, 0.2902]}, {"w": "want", "b": [0.73, 0.2688, 0.7707, 0.2902]}, {"w": "to", "b": [0.7773, 0.2688, 0.7943, 0.2902]}, {"w": "deploy", "b": [0.8009, 0.2688, 0.8572, 0.2902]}, {"w": "the", "b": [0.1429, 0.2879, 0.1692, 0.3093]}, {"w": "model", "b": [0.1747, 0.2879, 0.2275, 0.3093]}, {"w": "to", "b": [0.2329, 0.2879, 0.2499, 0.3093]}, {"w": "TensorFlow.js", "b": [0.2554, 0.2879, 0.3698, 0.3093]}, {"w": "so", "b": [0.3753, 0.2879, 0.3936, 0.3093]}, {"w": "it", "b": [0.399, 0.2879, 0.411, 0.3093]}, {"w": "runs", "b": [0.4164, 0.2879, 0.4542, 0.3093]}, {"w": "in", "b": [0.4597, 0.2879, 0.4767, 0.3093]}, {"w": "a", "b": [0.4821, 0.2879, 0.4913, 0.3093]}, {"w": "web", "b": [0.4968, 0.2879, 0.5305, 0.3093]}, {"w": "browser?", "b": [0.5359, 0.2879, 0.6113, 0.3093]}, {"w": "Once", "b": [0.6167, 0.2879, 0.6613, 0.3093]}, {"w": "again,", "b": [0.6668, 0.2879, 0.7166, 0.3093]}, {"w": "you", "b": [0.722, 0.2879, 0.7533, 0.3093]}, {"w": "will", "b": [0.7587, 0.2879, 0.7891, 0.3093]}, {"w": "need", "b": [0.7946, 0.2879, 0.8347, 0.3093]}, {"w": "to", "b": [0.8402, 0.2879, 0.8571, 0.3093]}, {"w": "write", "b": [0.1429, 0.3069, 0.1856, 0.3283]}, {"w": "some", "b": [0.1931, 0.3069, 0.2373, 0.3283]}, {"w": "preprocessing", "b": [0.2447, 0.3069, 0.3611, 0.3283]}, {"w": "code.", "b": [0.3686, 0.3069, 0.4126, 0.3283]}, {"w": "This", "b": [0.42, 0.3069, 0.4573, 0.3283]}, {"w": "can", "b": [0.4647, 0.3069, 0.494, 0.3283]}, {"w": "become", "b": [0.5015, 0.3069, 0.5663, 0.3283]}, {"w": "a", "b": [0.5737, 0.3069, 0.5828, 0.3283]}, {"w": "maintenance", "b": [0.5903, 0.3069, 0.6979, 0.3283]}, {"w": "nightmare:", "b": [0.7053, 0.3069, 0.7966, 0.3283]}, {"w": "when‐", "b": [0.8041, 0.3069, 0.8571, 0.3283]}, {"w": "ever", "b": [0.1428, 0.326, 0.1779, 0.3474]}, {"w": "you", "b": [0.1827, 0.326, 0.2139, 0.3474]}, {"w": "want", "b": [0.2186, 0.326, 0.2594, 0.3474]}, {"w": "to", "b": [0.2641, 0.326, 0.2811, 0.3474]}, {"w": "change", "b": [0.2858, 0.326, 0.3449, 0.3474]}, {"w": "the", "b": [0.3497, 0.326, 0.376, 0.3474]}, {"w": "preprocessing", "b": [0.3807, 0.326, 0.4972, 0.3474]}, {"w": "logic,", "b": [0.5019, 0.326, 0.5467, 0.3474]}, {"w": "you", "b": [0.5514, 0.326, 0.5827, 0.3474]}, {"w": "will", "b": [0.5874, 0.326, 0.6178, 0.3474]}, {"w": "need", "b": [0.6225, 0.326, 0.6626, 0.3474]}, {"w": "to", "b": [0.6674, 0.326, 0.6843, 0.3474]}, {"w": "update", "b": [0.6891, 0.326, 0.746, 0.3474]}, {"w": "your", "b": [0.7507, 0.326, 0.7897, 0.3474]}, {"w": "Apache", "b": [0.7945, 0.326, 0.8568, 0.3474]}, {"w": "Beam", "b": [0.1428, 0.345, 0.1906, 0.3664]}, {"w": "code,", "b": [0.1968, 0.345, 0.2408, 0.3664]}, {"w": "your", "b": [0.247, 0.345, 0.286, 0.3664]}, {"w": "mobile", "b": [0.2922, 0.345, 0.3502, 0.3664]}, {"w": "app", "b": [0.3564, 0.345, 0.387, 0.3664]}, {"w": "code", "b": [0.3932, 0.345, 0.4325, 0.3664]}, {"w": "and", "b": [0.4387, 0.345, 0.4702, 0.3664]}, {"w": "your", "b": [0.4764, 0.345, 0.5154, 0.3664]}, {"w": "Javascript", "b": [0.5216, 0.345, 0.6025, 0.3664]}, {"w": "code.", "b": [0.6087, 0.345, 0.6527, 0.3664]}, {"w": "It", "b": [0.6589, 0.345, 0.6716, 0.3664]}, {"w": "is", "b": [0.6778, 0.345, 0.691, 0.3664]}, {"w": "not", "b": [0.6972, 0.345, 0.7256, 0.3664]}, {"w": "only", "b": [0.7318, 0.345, 0.7686, 0.3664]}, {"w": "time", "b": [0.7748, 0.345, 0.8127, 0.3664]}, {"w": "con‐", "b": [0.8189, 0.345, 0.8571, 0.3664]}, {"w": "suming,", "b": [0.1429, 0.3641, 0.2101, 0.3855]}, {"w": "but", "b": [0.2175, 0.3641, 0.2455, 0.3855]}, {"w": "also", "b": [0.2529, 0.3641, 0.2856, 0.3855]}, {"w": "error", "b": [0.2929, 0.3641, 0.3356, 0.3855]}, {"w": "prone:", "b": [0.343, 0.3641, 0.3972, 0.3855]}, {"w": "you", "b": [0.4046, 0.3641, 0.4359, 0.3855]}, {"w": "may", "b": [0.4432, 0.3641, 0.4786, 0.3855]}, {"w": "end", "b": [0.486, 0.3641, 0.5173, 0.3855]}, {"w": "up", "b": [0.5246, 0.3641, 0.5466, 0.3855]}, {"w": "with", "b": [0.554, 0.3641, 0.5913, 0.3855]}, {"w": "subtle", "b": [0.5987, 0.3641, 0.6485, 0.3855]}, {"w": "differences", "b": [0.6558, 0.3641, 0.7469, 0.3855]}, {"w": "between", "b": [0.7543, 0.3641, 0.8234, 0.3855]}, {"w": "the", "b": [0.8308, 0.3641, 0.8571, 0.3855]}, {"w": "preprocessing", "b": [0.1429, 0.3831, 0.2593, 0.4045]}, {"w": "operations", "b": [0.2653, 0.3831, 0.3537, 0.4045]}, {"w": "performed", "b": [0.3597, 0.3831, 0.4486, 0.4045]}, {"w": "before", "b": [0.4545, 0.3831, 0.5074, 0.4045]}, {"w": "training", "b": [0.5133, 0.3831, 0.5802, 0.4045]}, {"w": "and", "b": [0.5862, 0.3831, 0.6177, 0.4045]}, {"w": "the", "b": [0.6236, 0.3831, 0.65, 0.4045]}, {"w": "ones", "b": [0.6559, 0.3831, 0.6944, 0.4045]}, {"w": "performed", "b": [0.7004, 0.3831, 0.7893, 0.4045]}, {"w": "in", "b": [0.7952, 0.3831, 0.8122, 0.4045]}, {"w": "your", "b": [0.8182, 0.3831, 0.8571, 0.4045]}, {"w": "app", "b": [0.1429, 0.4022, 0.1734, 0.4236]}, {"w": "or", "b": [0.1784, 0.4022, 0.1968, 0.4236]}, {"w": "in", "b": [0.2018, 0.4022, 0.2188, 0.4236]}, {"w": "the", "b": [0.2238, 0.4022, 0.2501, 0.4236]}, {"w": "browser.", "b": [0.2551, 0.4022, 0.326, 0.4236]}, {"w": "This", "b": [0.331, 0.4022, 0.3682, 0.4236]}, {"w": "training/serving", "b": [0.3733, 0.4019, 0.5024, 0.4236]}, {"w": "skew", "b": [0.5072, 0.4019, 0.546, 0.4236]}, {"w": "will", "b": [0.5513, 0.4022, 0.5817, 0.4236]}, {"w": "lead", "b": [0.5867, 0.4022, 0.6209, 0.4236]}, {"w": "to", "b": [0.6259, 0.4022, 0.6429, 0.4236]}, {"w": "bugs", "b": [0.6479, 0.4022, 0.687, 0.4236]}, {"w": "or", "b": [0.692, 0.4022, 0.7103, 0.4236]}, {"w": "degraded", "b": [0.7154, 0.4022, 0.7927, 0.4236]}, {"w": "perfor‐", "b": [0.7977, 0.4022, 0.8571, 0.4236]}, {"w": "mance.", "b": [0.1429, 0.4212, 0.2029, 0.4426]}]}, {"id": "b_2", "type": "paragraph", "text": "One improvement would be to take the trained model (trained on data that was pre‐ processed by your Apache Beam code), and before deploying it to your app or the browser, add an extra input layer to take care of preprocessing on the fly (either by writing a custom layer or by using a DenseFeatures layer). That’s definitely better, since now you just have two versions of your preprocessing code: the Apache Beam code and the preprocessing layer’s code.", "words": [{"w": "One", "b": [0.1429, 0.4493, 0.1787, 0.4707]}, {"w": "improvement", "b": [0.1844, 0.4493, 0.2977, 0.4707]}, {"w": "would", "b": [0.3033, 0.4493, 0.3556, 0.4707]}, {"w": "be", "b": [0.3612, 0.4493, 0.3807, 0.4707]}, {"w": "to", "b": [0.3864, 0.4493, 0.4033, 0.4707]}, {"w": "take", "b": [0.409, 0.4493, 0.4437, 0.4707]}, {"w": "the", "b": [0.4494, 0.4493, 0.4757, 0.4707]}, {"w": "trained", "b": [0.4814, 0.4493, 0.5415, 0.4707]}, {"w": "model", "b": [0.5471, 0.4493, 0.6, 0.4707]}, {"w": "(trained", "b": [0.6056, 0.4493, 0.6729, 0.4707]}, {"w": "on", "b": [0.6786, 0.4493, 0.7006, 0.4707]}, {"w": "data", "b": [0.7063, 0.4493, 0.7415, 0.4707]}, {"w": "that", "b": [0.7472, 0.4493, 0.7798, 0.4707]}, {"w": "was", "b": [0.7855, 0.4493, 0.8166, 0.4707]}, {"w": "pre‐", "b": [0.8222, 0.4493, 0.8572, 0.4707]}, {"w": "processed", "b": [0.1429, 0.4684, 0.2249, 0.4898]}, {"w": "by", "b": [0.2322, 0.4684, 0.2523, 0.4898]}, {"w": "your", "b": [0.2595, 0.4684, 0.2985, 0.4898]}, {"w": "Apache", "b": [0.3058, 0.4684, 0.3682, 0.4898]}, {"w": "Beam", "b": [0.3754, 0.4684, 0.4231, 0.4898]}, {"w": "code),", "b": [0.4303, 0.4684, 0.4816, 0.4898]}, {"w": "and", "b": [0.4888, 0.4684, 0.5204, 0.4898]}, {"w": "before", "b": [0.5276, 0.4684, 0.5804, 0.4898]}, {"w": "deploying", "b": [0.5876, 0.4684, 0.6706, 0.4898]}, {"w": "it", "b": [0.6778, 0.4684, 0.6898, 0.4898]}, {"w": "to", "b": [0.697, 0.4684, 0.714, 0.4898]}, {"w": "your", "b": [0.7212, 0.4684, 0.7602, 0.4898]}, {"w": "app", "b": [0.7674, 0.4684, 0.798, 0.4898]}, {"w": "or", "b": [0.8052, 0.4684, 0.8236, 0.4898]}, {"w": "the", "b": [0.8308, 0.4684, 0.8571, 0.4898]}, {"w": "browser,", "b": [0.1429, 0.4874, 0.2137, 0.5088]}, {"w": "add", "b": [0.2204, 0.4874, 0.2515, 0.5088]}, {"w": "an", "b": [0.2582, 0.4874, 0.2788, 0.5088]}, {"w": "extra", "b": [0.2854, 0.4874, 0.3273, 0.5088]}, {"w": "input", "b": [0.334, 0.4874, 0.3789, 0.5088]}, {"w": "layer", "b": [0.3856, 0.4874, 0.4258, 0.5088]}, {"w": "to", "b": [0.4325, 0.4874, 0.4494, 0.5088]}, {"w": "take", "b": [0.4561, 0.4874, 0.4908, 0.5088]}, {"w": "care", "b": [0.4975, 0.4874, 0.532, 0.5088]}, {"w": "of", "b": [0.5387, 0.4874, 0.5555, 0.5088]}, {"w": "preprocessing", "b": [0.5621, 0.4874, 0.6786, 0.5088]}, {"w": "on", "b": [0.6853, 0.4874, 0.7073, 0.5088]}, {"w": "the", "b": [0.7139, 0.4874, 0.7403, 0.5088]}, {"w": "fly", "b": [0.7469, 0.4874, 0.7679, 0.5088]}, {"w": "(either", "b": [0.7746, 0.4874, 0.8303, 0.5088]}, {"w": "by", "b": [0.837, 0.4874, 0.8571, 0.5088]}, {"w": "writing", "b": [0.1428, 0.5074, 0.2035, 0.5288]}, {"w": "a", "b": [0.2109, 0.5074, 0.2201, 0.5288]}, {"w": "custom", "b": [0.2275, 0.5074, 0.2891, 0.5288]}, {"w": "layer", "b": [0.2965, 0.5074, 0.3367, 0.5288]}, {"w": "or", "b": [0.3442, 0.5074, 0.3625, 0.5288]}, {"w": "by", "b": [0.3699, 0.5074, 0.3901, 0.5288]}, {"w": "using", "b": [0.3975, 0.5074, 0.443, 0.5288]}, {"w": "a", "b": [0.4504, 0.5074, 0.4595, 0.5288]}, {"w": "DenseFeatures", "b": [0.467, 0.5105, 0.5956, 0.5256]}, {"w": "layer).", "b": [0.6031, 0.5074, 0.6552, 0.5288]}, {"w": "That’s", "b": [0.6627, 0.5074, 0.7115, 0.5288]}, {"w": "definitely", "b": [0.7189, 0.5074, 0.7976, 0.5288]}, {"w": "better,", "b": [0.805, 0.5074, 0.8572, 0.5288]}, {"w": "since", "b": [0.1429, 0.5264, 0.1852, 0.5478]}, {"w": "now", "b": [0.1915, 0.5264, 0.2278, 0.5478]}, {"w": "you", "b": [0.2341, 0.5264, 0.2654, 0.5478]}, {"w": "just", "b": [0.2717, 0.5264, 0.3021, 0.5478]}, {"w": "have", "b": [0.3085, 0.5264, 0.3469, 0.5478]}, {"w": "two", "b": [0.3532, 0.5264, 0.3845, 0.5478]}, {"w": "versions", "b": [0.3908, 0.5264, 0.46, 0.5478]}, {"w": "of", "b": [0.4663, 0.5264, 0.4831, 0.5478]}, {"w": "your", "b": [0.4895, 0.5264, 0.5284, 0.5478]}, {"w": "preprocessing", "b": [0.5348, 0.5264, 0.6512, 0.5478]}, {"w": "code:", "b": [0.6576, 0.5264, 0.7016, 0.5478]}, {"w": "the", "b": [0.708, 0.5264, 0.7343, 0.5478]}, {"w": "Apache", "b": [0.7407, 0.5264, 0.8031, 0.5478]}, {"w": "Beam", "b": [0.8094, 0.5264, 0.8571, 0.5478]}, {"w": "code", "b": [0.1429, 0.5455, 0.1821, 0.5669]}, {"w": "and", "b": [0.1869, 0.5455, 0.2184, 0.5669]}, {"w": "the", "b": [0.2231, 0.5455, 0.2495, 0.5669]}, {"w": "preprocessing", "b": [0.2542, 0.5455, 0.3707, 0.5669]}, {"w": "layer’s", "b": [0.3754, 0.5455, 0.4259, 0.5669]}, {"w": "code.", "b": [0.4306, 0.5455, 0.4747, 0.5669]}]}, {"id": "b_3", "type": "paragraph", "text": "But what if you could define your preprocessing operations just once? This is what TF Transform was designed for. It is part of TensorFlow Extended (TFX), an end-to- end platform for productionizing TensorFlow models. First, to use a TFX component, such as TF Transform, you must install it, it does not come bundled with TensorFlow. You define your preprocessing function just once (in Python), by using TF Transform functions for scaling, bucketizing, crossing features, and more. You can also use any TensorFlow operation you need. Here is what this preprocessing function might look like if we just had two features:", "words": [{"w": "But", "b": [0.1429, 0.5736, 0.1725, 0.595]}, {"w": "what", "b": [0.1794, 0.5736, 0.2199, 0.595]}, {"w": "if", "b": [0.2268, 0.5736, 0.2386, 0.595]}, {"w": "you", "b": [0.2455, 0.5736, 0.2767, 0.595]}, {"w": "could", "b": [0.2836, 0.5736, 0.3304, 0.595]}, {"w": "define", "b": [0.3373, 0.5736, 0.3891, 0.595]}, {"w": "your", "b": [0.396, 0.5736, 0.435, 0.595]}, {"w": "preprocessing", "b": [0.4419, 0.5736, 0.5584, 0.595]}, {"w": "operations", "b": [0.5653, 0.5736, 0.6537, 0.595]}, {"w": "just", "b": [0.6606, 0.5736, 0.691, 0.595]}, {"w": "once?", "b": [0.6979, 0.5736, 0.7455, 0.595]}, {"w": "This", "b": [0.7524, 0.5736, 0.7896, 0.595]}, {"w": "is", "b": [0.7965, 0.5736, 0.8097, 0.595]}, {"w": "what", "b": [0.8166, 0.5736, 0.8571, 0.595]}, {"w": "TF", "b": [0.1428, 0.5926, 0.1667, 0.614]}, {"w": "Transform", "b": [0.1724, 0.5926, 0.2611, 0.614]}, {"w": "was", "b": [0.2668, 0.5926, 0.2978, 0.614]}, {"w": "designed", "b": [0.3035, 0.5926, 0.3776, 0.614]}, {"w": "for.", "b": [0.3833, 0.5926, 0.4113, 0.614]}, {"w": "It", "b": [0.417, 0.5926, 0.4296, 0.614]}, {"w": "is", "b": [0.4354, 0.5926, 0.4486, 0.614]}, {"w": "part", "b": [0.4543, 0.5926, 0.4884, 0.614]}, {"w": "of", "b": [0.4941, 0.5926, 0.5109, 0.614]}, {"w": "TensorFlow", "b": [0.5167, 0.5926, 0.6149, 0.614]}, {"w": "Extended", "b": [0.6206, 0.5926, 0.6997, 0.614]}, {"w": "(TFX),", "b": [0.7054, 0.5926, 0.7621, 0.614]}, {"w": "an", "b": [0.7678, 0.5926, 0.7884, 0.614]}, {"w": "end-to-", "b": [0.7941, 0.5926, 0.8571, 0.614]}, {"w": "end", "b": [0.1429, 0.6117, 0.1741, 0.6331]}, {"w": "platform", "b": [0.1789, 0.6117, 0.2518, 0.6331]}, {"w": "for", "b": [0.2566, 0.6117, 0.2811, 0.6331]}, {"w": "productionizing", "b": [0.2859, 0.6117, 0.4211, 0.6331]}, {"w": "TensorFlow", "b": [0.4259, 0.6117, 0.5241, 0.6331]}, {"w": "models.", "b": [0.5289, 0.6117, 0.5941, 0.6331]}, {"w": "First,", "b": [0.5989, 0.6117, 0.642, 0.6331]}, {"w": "to", "b": [0.6468, 0.6117, 0.6638, 0.6331]}, {"w": "use", "b": [0.6686, 0.6117, 0.6961, 0.6331]}, {"w": "a", "b": [0.7009, 0.6117, 0.7101, 0.6331]}, {"w": "TFX", "b": [0.7149, 0.6117, 0.7524, 0.6331]}, {"w": "component,", "b": [0.7571, 0.6117, 0.8571, 0.6331]}, {"w": "such", "b": [0.1429, 0.6307, 0.1815, 0.6521]}, {"w": "as", "b": [0.1865, 0.6307, 0.2033, 0.6521]}, {"w": "TF", "b": [0.2082, 0.6307, 0.2321, 0.6521]}, {"w": "Transform,", "b": [0.2371, 0.6307, 0.3304, 0.6521]}, {"w": "you", "b": [0.3354, 0.6307, 0.3667, 0.6521]}, {"w": "must", "b": [0.3716, 0.6307, 0.4133, 0.6521]}, {"w": "install", "b": [0.4183, 0.6307, 0.469, 0.6521]}, {"w": "it,", "b": [0.4739, 0.6307, 0.4906, 0.6521]}, {"w": "it", "b": [0.4956, 0.6307, 0.5075, 0.6521]}, {"w": "does", "b": [0.5125, 0.6307, 0.5506, 0.6521]}, {"w": "not", "b": [0.5556, 0.6307, 0.584, 0.6521]}, {"w": "come", "b": [0.5889, 0.6307, 0.6343, 0.6521]}, {"w": "bundled", "b": [0.6392, 0.6307, 0.7084, 0.6521]}, {"w": "with", "b": [0.7134, 0.6307, 0.7507, 0.6521]}, {"w": "TensorFlow.", "b": [0.7557, 0.6307, 0.8571, 0.6521]}, {"w": "You", "b": [0.1429, 0.6498, 0.1752, 0.6712]}, {"w": "define", "b": [0.1801, 0.6498, 0.2319, 0.6712]}, {"w": "your", "b": [0.2367, 0.6498, 0.2757, 0.6712]}, {"w": "preprocessing", "b": [0.2806, 0.6498, 0.397, 0.6712]}, {"w": "function", "b": [0.4019, 0.6498, 0.4733, 0.6712]}, {"w": "just", "b": [0.4781, 0.6498, 0.5085, 0.6712]}, {"w": "once", "b": [0.5134, 0.6498, 0.553, 0.6712]}, {"w": "(in", "b": [0.5579, 0.6498, 0.5821, 0.6712]}, {"w": "Python),", "b": [0.5869, 0.6498, 0.6597, 0.6712]}, {"w": "by", "b": [0.6645, 0.6498, 0.6847, 0.6712]}, {"w": "using", "b": [0.6895, 0.6498, 0.7349, 0.6712]}, {"w": "TF", "b": [0.7398, 0.6498, 0.7637, 0.6712]}, {"w": "Transform", "b": [0.7685, 0.6498, 0.8571, 0.6712]}, {"w": "functions", "b": [0.1429, 0.6688, 0.2219, 0.6902]}, {"w": "for", "b": [0.2282, 0.6688, 0.2527, 0.6902]}, {"w": "scaling,", "b": [0.2589, 0.6688, 0.3213, 0.6902]}, {"w": "bucketizing,", "b": [0.3275, 0.6688, 0.4294, 0.6902]}, {"w": "crossing", "b": [0.4356, 0.6688, 0.5048, 0.6902]}, {"w": "features,", "b": [0.5111, 0.6688, 0.5812, 0.6902]}, {"w": "and", "b": [0.5875, 0.6688, 0.619, 0.6902]}, {"w": "more.", "b": [0.6253, 0.6688, 0.6743, 0.6902]}, {"w": "You", "b": [0.6805, 0.6688, 0.7129, 0.6902]}, {"w": "can", "b": [0.7192, 0.6688, 0.7485, 0.6902]}, {"w": "also", "b": [0.7548, 0.6688, 0.7875, 0.6902]}, {"w": "use", "b": [0.7937, 0.6688, 0.8213, 0.6902]}, {"w": "any", "b": [0.8275, 0.6688, 0.8572, 0.6902]}, {"w": "TensorFlow", "b": [0.1429, 0.6879, 0.2411, 0.7093]}, {"w": "operation", "b": [0.2465, 0.6879, 0.3274, 0.7093]}, {"w": "you", "b": [0.3328, 0.6879, 0.364, 0.7093]}, {"w": "need.", "b": [0.3694, 0.6879, 0.4143, 0.7093]}, {"w": "Here", "b": [0.4197, 0.6879, 0.4606, 0.7093]}, {"w": "is", "b": [0.466, 0.6879, 0.4792, 0.7093]}, {"w": "what", "b": [0.4847, 0.6879, 0.5252, 0.7093]}, {"w": "this", "b": [0.5306, 0.6879, 0.5613, 0.7093]}, {"w": "preprocessing", "b": [0.5667, 0.6879, 0.6832, 0.7093]}, {"w": "function", "b": [0.6886, 0.6879, 0.76, 0.7093]}, {"w": "might", "b": [0.7654, 0.6879, 0.8149, 0.7093]}, {"w": "look", "b": [0.8203, 0.6879, 0.8571, 0.7093]}, {"w": "like", "b": [0.1429, 0.7069, 0.1729, 0.7283]}, {"w": "if", "b": [0.1776, 0.7069, 0.1894, 0.7283]}, {"w": "we", "b": [0.1941, 0.7069, 0.2172, 0.7283]}, {"w": "just", "b": [0.222, 0.7069, 0.2524, 0.7283]}, {"w": "had", "b": [0.2571, 0.7069, 0.2884, 0.7283]}, {"w": "two", "b": [0.2931, 0.7069, 0.3243, 0.7283]}, {"w": "features:", "b": [0.3291, 0.7069, 0.3992, 0.7283]}]}, {"id": "b_4", "type": "equation", "text": "import tensorflow_transform as tft", "words": [{"w": "import", "b": [0.1766, 0.7389, 0.2272, 0.7517]}, {"w": "tensorflow_transform", "b": [0.2356, 0.7389, 0.4043, 0.7517]}, {"w": "as", "b": [0.4127, 0.7389, 0.4296, 0.7517]}, {"w": "tft", "b": [0.438, 0.7389, 0.4633, 0.7517]}]}, {"id": "b_5", "type": "paragraph", "text": "def preprocess(inputs): # inputs is a batch of input features median_age = inputs[\"housing_median_age\"] ocean_proximity = inputs[\"ocean_proximity\"] standardized_age = tft.scale_to_z_score(median_age - tft.mean(median_age)) ocean_proximity_id = tft.compute_and_apply_vocabulary(ocean_proximity) return { \"standardized_median_age\": standardized_age,", "words": [{"w": "def", "b": [0.1766, 0.7697, 0.2019, 0.7826]}, {"w": "preprocess(inputs):", "b": [0.2103, 0.7697, 0.3705, 0.7826]}, {"w": "#", "b": [0.3874, 0.7697, 0.3958, 0.7826]}, {"w": "inputs", "b": [0.4043, 0.7697, 0.4549, 0.7826]}, {"w": "is", "b": [0.4633, 0.7697, 0.4802, 0.7826]}, {"w": "a", "b": [0.4886, 0.7697, 0.497, 0.7826]}, {"w": "batch", "b": [0.5055, 0.7697, 0.5476, 0.7826]}, {"w": "of", "b": [0.5561, 0.7697, 0.5729, 0.7826]}, {"w": "input", "b": [0.5814, 0.7697, 0.6235, 0.7826]}, {"w": "features", "b": [0.632, 0.7697, 0.6994, 0.7826]}, {"w": "median_age", "b": [0.2103, 0.7851, 0.2946, 0.798]}, {"w": "=", "b": [0.3031, 0.7851, 0.3115, 0.798]}, {"w": "inputs[\"housing_median_age\"]", "b": [0.3199, 0.7851, 0.5561, 0.798]}, {"w": "ocean_proximity", "b": [0.2103, 0.8006, 0.3368, 0.8134]}, {"w": "=", "b": [0.3452, 0.8006, 0.3537, 0.8134]}, {"w": "inputs[\"ocean_proximity\"]", "b": [0.3621, 0.8006, 0.5729, 0.8134]}, {"w": "standardized_age", "b": [0.2103, 0.816, 0.3452, 0.8288]}, {"w": "=", "b": [0.3537, 0.816, 0.3621, 0.8288]}, {"w": "tft.scale_to_z_score(median_age", "b": [0.3705, 0.816, 0.632, 0.8288]}, {"w": "-", "b": [0.6404, 0.816, 0.6488, 0.8288]}, {"w": "tft.mean(median_age))", "b": [0.6572, 0.816, 0.8343, 0.8288]}, {"w": "ocean_proximity_id", "b": [0.2103, 0.8314, 0.3621, 0.8442]}, {"w": "=", "b": [0.3705, 0.8314, 0.379, 0.8442]}, {"w": "tft.compute_and_apply_vocabulary(ocean_proximity)", "b": [0.3874, 0.8314, 0.8006, 0.8442]}, {"w": "return", "b": [0.2103, 0.8468, 0.2609, 0.8597]}, {"w": "{", "b": [0.2694, 0.8468, 0.2778, 0.8597]}, {"w": "\"standardized_median_age\":", "b": [0.2441, 0.8622, 0.4633, 0.8751]}, {"w": "standardized_age,", "b": [0.4717, 0.8622, 0.6151, 0.8751]}]}, {"id": "b_6", "type": "paragraph", "text": "428 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "428", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2746, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 455, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "11 At the time of writing, TFDS requires you to download a few files manually for ImageNet (for legal reasons), but this will hopefully get resolved soon.", "words": [{"w": "11", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "At", "b": [0.1587, 0.8598, 0.1739, 0.8761]}, {"w": "the", "b": [0.1775, 0.8598, 0.1976, 0.8761]}, {"w": "time", "b": [0.2012, 0.8598, 0.23, 0.8761]}, {"w": "of", "b": [0.2336, 0.8598, 0.2464, 0.8761]}, {"w": "writing,", "b": [0.25, 0.8598, 0.2998, 0.8761]}, {"w": "TFDS", "b": [0.3034, 0.8598, 0.3408, 0.8761]}, {"w": "requires", "b": [0.3444, 0.8598, 0.3963, 0.8761]}, {"w": "you", "b": [0.3999, 0.8598, 0.4237, 0.8761]}, {"w": "to", "b": [0.4273, 0.8598, 0.4403, 0.8761]}, {"w": "download", "b": [0.4439, 0.8598, 0.5074, 0.8761]}, {"w": "a", "b": [0.511, 0.8598, 0.5179, 0.8761]}, {"w": "few", "b": [0.5215, 0.8598, 0.5439, 0.8761]}, {"w": "files", "b": [0.5475, 0.8598, 0.573, 0.8761]}, {"w": "manually", "b": [0.5766, 0.8598, 0.6357, 0.8761]}, {"w": "for", "b": [0.6393, 0.8598, 0.658, 0.8761]}, {"w": "ImageNet", "b": [0.6616, 0.8598, 0.7241, 0.8761]}, {"w": "(for", "b": [0.7277, 0.8598, 0.7519, 0.8761]}, {"w": "legal", "b": [0.7555, 0.8598, 0.7847, 0.8761]}, {"w": "reasons),", "b": [0.7883, 0.8598, 0.8454, 0.8761]}, {"w": "but", "b": [0.1587, 0.8749, 0.1801, 0.8912]}, {"w": "this", "b": [0.1837, 0.8749, 0.2071, 0.8912]}, {"w": "will", "b": [0.2107, 0.8749, 0.2338, 0.8912]}, {"w": "hopefully", "b": [0.2374, 0.8749, 0.2975, 0.8912]}, {"w": "get", "b": [0.3011, 0.8749, 0.3201, 0.8912]}, {"w": "resolved", "b": [0.3237, 0.8749, 0.3768, 0.8912]}, {"w": "soon.", "b": [0.3804, 0.8749, 0.4147, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "\"ocean_proximity_id\": ocean_proximity_id }", "words": [{"w": "\"ocean_proximity_id\":", "b": [0.244, 0.0829, 0.4211, 0.0958]}, {"w": "ocean_proximity_id", "b": [0.4296, 0.0829, 0.5813, 0.0958]}, {"w": "}", "b": [0.2103, 0.0983, 0.2188, 0.1112]}]}, {"id": "b_2", "type": "paragraph", "text": "Next, TF Transform lets you apply this preprocess() function to the whole training set using Apache Beam (it provides an AnalyzeAndTransformDataset class that you can use for this purpose in your Apache Beam pipeline). In the process, it will also compute all the necessary statistics over the whole training set: in this example, the mean and standard deviation of the housing_median_age feature, and the vocabulary for the ocean_proximity feature. The components that compute these statistics are called analyzers.", "words": [{"w": "Next,", "b": [0.1429, 0.1199, 0.1876, 0.1413]}, {"w": "TF", "b": [0.1935, 0.1199, 0.2174, 0.1413]}, {"w": "Transform", "b": [0.2233, 0.1199, 0.3119, 0.1413]}, {"w": "lets", "b": [0.3179, 0.1199, 0.346, 0.1413]}, {"w": "you", "b": [0.3519, 0.1199, 0.3831, 0.1413]}, {"w": "apply", "b": [0.3891, 0.1199, 0.4345, 0.1413]}, {"w": "this", "b": [0.4404, 0.1199, 0.4711, 0.1413]}, {"w": "preprocess()", "b": [0.477, 0.123, 0.5958, 0.1381]}, {"w": "function", "b": [0.6017, 0.1199, 0.6731, 0.1413]}, {"w": "to", "b": [0.679, 0.1199, 0.696, 0.1413]}, {"w": "the", "b": [0.7019, 0.1199, 0.7282, 0.1413]}, {"w": "whole", "b": [0.7341, 0.1199, 0.7843, 0.1413]}, {"w": "training", "b": [0.7902, 0.1199, 0.8571, 0.1413]}, {"w": "set", "b": [0.1428, 0.1398, 0.1657, 0.1612]}, {"w": "using", "b": [0.1722, 0.1398, 0.2176, 0.1612]}, {"w": "Apache", "b": [0.224, 0.1398, 0.2864, 0.1612]}, {"w": "Beam", "b": [0.2929, 0.1398, 0.3406, 0.1612]}, {"w": "(it", "b": [0.3471, 0.1398, 0.3662, 0.1612]}, {"w": "provides", "b": [0.3727, 0.1398, 0.4447, 0.1612]}, {"w": "an", "b": [0.4511, 0.1398, 0.4717, 0.1612]}, {"w": "AnalyzeAndTransformDataset", "b": [0.4781, 0.143, 0.7354, 0.1581]}, {"w": "class", "b": [0.7419, 0.1398, 0.7804, 0.1612]}, {"w": "that", "b": [0.7868, 0.1398, 0.8194, 0.1612]}, {"w": "you", "b": [0.8259, 0.1398, 0.8571, 0.1612]}, {"w": "can", "b": [0.1429, 0.1589, 0.1722, 0.1803]}, {"w": "use", "b": [0.179, 0.1589, 0.2066, 0.1803]}, {"w": "for", "b": [0.2134, 0.1589, 0.2379, 0.1803]}, {"w": "this", "b": [0.2447, 0.1589, 0.2754, 0.1803]}, {"w": "purpose", "b": [0.2822, 0.1589, 0.35, 0.1803]}, {"w": "in", "b": [0.3568, 0.1589, 0.3738, 0.1803]}, {"w": "your", "b": [0.3806, 0.1589, 0.4196, 0.1803]}, {"w": "Apache", "b": [0.4264, 0.1589, 0.4888, 0.1803]}, {"w": "Beam", "b": [0.4956, 0.1589, 0.5433, 0.1803]}, {"w": "pipeline).", "b": [0.5501, 0.1589, 0.6295, 0.1803]}, {"w": "In", "b": [0.6363, 0.1589, 0.6548, 0.1803]}, {"w": "the", "b": [0.6616, 0.1589, 0.6879, 0.1803]}, {"w": "process,", "b": [0.6947, 0.1589, 0.7617, 0.1803]}, {"w": "it", "b": [0.7685, 0.1589, 0.7804, 0.1803]}, {"w": "will", "b": [0.7873, 0.1589, 0.8177, 0.1803]}, {"w": "also", "b": [0.8245, 0.1589, 0.8571, 0.1803]}, {"w": "compute", "b": [0.1429, 0.1779, 0.2161, 0.1993]}, {"w": "all", "b": [0.2229, 0.1779, 0.2426, 0.1993]}, {"w": "the", "b": [0.2493, 0.1779, 0.2757, 0.1993]}, {"w": "necessary", "b": [0.2824, 0.1779, 0.3627, 0.1993]}, {"w": "statistics", "b": [0.3694, 0.1779, 0.4402, 0.1993]}, {"w": "over", "b": [0.4469, 0.1779, 0.4838, 0.1993]}, {"w": "the", "b": [0.4905, 0.1779, 0.5169, 0.1993]}, {"w": "whole", "b": [0.5236, 0.1779, 0.5738, 0.1993]}, {"w": "training", "b": [0.5805, 0.1779, 0.6475, 0.1993]}, {"w": "set:", "b": [0.6542, 0.1779, 0.6818, 0.1993]}, {"w": "in", "b": [0.6886, 0.1779, 0.7055, 0.1993]}, {"w": "this", "b": [0.7123, 0.1779, 0.743, 0.1993]}, {"w": "example,", "b": [0.7498, 0.1779, 0.8241, 0.1993]}, {"w": "the", "b": [0.8308, 0.1779, 0.8571, 0.1993]}, {"w": "mean", "b": [0.1429, 0.1979, 0.1893, 0.2193]}, {"w": "and", "b": [0.1944, 0.1979, 0.226, 0.2193]}, {"w": "standard", "b": [0.2311, 0.1979, 0.3045, 0.2193]}, {"w": "deviation", "b": [0.3096, 0.1979, 0.3874, 0.2193]}, {"w": "of", "b": [0.3926, 0.1979, 0.4093, 0.2193]}, {"w": "the", "b": [0.4145, 0.1979, 0.4408, 0.2193]}, {"w": "housing_median_age", "b": [0.4459, 0.201, 0.6241, 0.2161]}, {"w": "feature,", "b": [0.6292, 0.1979, 0.6917, 0.2193]}, {"w": "and", "b": [0.6968, 0.1979, 0.7284, 0.2193]}, {"w": "the", "b": [0.7335, 0.1979, 0.7598, 0.2193]}, {"w": "vocabulary", "b": [0.765, 0.1979, 0.8571, 0.2193]}, {"w": "for", "b": [0.1429, 0.2178, 0.1674, 0.2392]}, {"w": "the", "b": [0.1745, 0.2178, 0.2009, 0.2392]}, {"w": "ocean_proximity", "b": [0.208, 0.221, 0.3565, 0.2361]}, {"w": "feature.", "b": [0.3636, 0.2178, 0.4262, 0.2392]}, {"w": "The", "b": [0.4333, 0.2178, 0.4661, 0.2392]}, {"w": "components", "b": [0.4733, 0.2178, 0.5762, 0.2392]}, {"w": "that", "b": [0.5834, 0.2178, 0.6159, 0.2392]}, {"w": "compute", "b": [0.6231, 0.2178, 0.6964, 0.2392]}, {"w": "these", "b": [0.7035, 0.2178, 0.7464, 0.2392]}, {"w": "statistics", "b": [0.7535, 0.2178, 0.8243, 0.2392]}, {"w": "are", "b": [0.8314, 0.2178, 0.8572, 0.2392]}, {"w": "called", "b": [0.1429, 0.2368, 0.1912, 0.2583]}, {"w": "analyzers.", "b": [0.1959, 0.2366, 0.2772, 0.2583]}]}, {"id": "b_3", "type": "paragraph", "text": "Importantly, TF Transform will also generate an equivalent TensorFlow Function that you can plug into the model you deploy. This TF Function contains all the necessary statistics computed by Apache Beam (the mean, standard deviation, and vocabulary), simply included as constants.", "words": [{"w": "Importantly,", "b": [0.1429, 0.265, 0.2468, 0.2864]}, {"w": "TF", "b": [0.2519, 0.265, 0.2758, 0.2864]}, {"w": "Transform", "b": [0.2808, 0.265, 0.3694, 0.2864]}, {"w": "will", "b": [0.3745, 0.265, 0.4049, 0.2864]}, {"w": "also", "b": [0.4099, 0.265, 0.4426, 0.2864]}, {"w": "generate", "b": [0.4477, 0.265, 0.5182, 0.2864]}, {"w": "an", "b": [0.5233, 0.265, 0.5438, 0.2864]}, {"w": "equivalent", "b": [0.5489, 0.265, 0.6353, 0.2864]}, {"w": "TensorFlow", "b": [0.6404, 0.265, 0.7386, 0.2864]}, {"w": "Function", "b": [0.7437, 0.265, 0.8195, 0.2864]}, {"w": "that", "b": [0.8246, 0.265, 0.8571, 0.2864]}, {"w": "you", "b": [0.1429, 0.284, 0.1741, 0.3054]}, {"w": "can", "b": [0.1798, 0.284, 0.2091, 0.3054]}, {"w": "plug", "b": [0.2148, 0.284, 0.2518, 0.3054]}, {"w": "into", "b": [0.2575, 0.284, 0.2911, 0.3054]}, {"w": "the", "b": [0.2967, 0.284, 0.3231, 0.3054]}, {"w": "model", "b": [0.3288, 0.284, 0.3816, 0.3054]}, {"w": "you", "b": [0.3872, 0.284, 0.4185, 0.3054]}, {"w": "deploy.", "b": [0.4242, 0.284, 0.4836, 0.3054]}, {"w": "This", "b": [0.4893, 0.284, 0.5265, 0.3054]}, {"w": "TF", "b": [0.5322, 0.284, 0.5561, 0.3054]}, {"w": "Function", "b": [0.5618, 0.284, 0.6376, 0.3054]}, {"w": "contains", "b": [0.6433, 0.284, 0.7138, 0.3054]}, {"w": "all", "b": [0.7195, 0.284, 0.7392, 0.3054]}, {"w": "the", "b": [0.7449, 0.284, 0.7712, 0.3054]}, {"w": "necessary", "b": [0.7769, 0.284, 0.8571, 0.3054]}, {"w": "statistics", "b": [0.1429, 0.3031, 0.2136, 0.3245]}, {"w": "computed", "b": [0.2188, 0.3031, 0.3031, 0.3245]}, {"w": "by", "b": [0.3084, 0.3031, 0.3285, 0.3245]}, {"w": "Apache", "b": [0.3338, 0.3031, 0.3962, 0.3245]}, {"w": "Beam", "b": [0.4015, 0.3031, 0.4492, 0.3245]}, {"w": "(the", "b": [0.4544, 0.3031, 0.488, 0.3245]}, {"w": "mean,", "b": [0.4932, 0.3031, 0.5445, 0.3245]}, {"w": "standard", "b": [0.5497, 0.3031, 0.6231, 0.3245]}, {"w": "deviation,", "b": [0.6284, 0.3031, 0.7109, 0.3245]}, {"w": "and", "b": [0.7162, 0.3031, 0.7477, 0.3245]}, {"w": "vocabulary),", "b": [0.753, 0.3031, 0.8571, 0.3245]}, {"w": "simply", "b": [0.1429, 0.3221, 0.1985, 0.3435]}, {"w": "included", "b": [0.2032, 0.3221, 0.2762, 0.3435]}, {"w": "as", "b": [0.2809, 0.3221, 0.2977, 0.3435]}, {"w": "constants.", "b": [0.3025, 0.3221, 0.3862, 0.3435]}]}, {"id": "b_4", "type": "paragraph", "text": "At the time of this writing, TF Transform only supports Tensor‐ Flow 1. Moreover, Apache Beam only has partial support for Python 3. That said, both these limitations will likely be fixed by the time your read this.", "words": [{"w": "At", "b": [0.2714, 0.364, 0.2896, 0.3836]}, {"w": "the", "b": [0.2968, 0.364, 0.3209, 0.3836]}, {"w": "time", "b": [0.3281, 0.364, 0.3627, 0.3836]}, {"w": "of", "b": [0.3699, 0.364, 0.3853, 0.3836]}, {"w": "this", "b": [0.3925, 0.364, 0.4205, 0.3836]}, {"w": "writing,", "b": [0.4277, 0.364, 0.4876, 0.3836]}, {"w": "TF", "b": [0.4948, 0.364, 0.5166, 0.3836]}, {"w": "Transform", "b": [0.5238, 0.364, 0.6048, 0.3836]}, {"w": "only", "b": [0.612, 0.364, 0.6457, 0.3836]}, {"w": "supports", "b": [0.6529, 0.364, 0.7196, 0.3836]}, {"w": "Tensor‐", "b": [0.7268, 0.364, 0.7857, 0.3836]}, {"w": "Flow", "b": [0.2714, 0.3815, 0.3091, 0.401]}, {"w": "1.", "b": [0.3195, 0.3815, 0.3329, 0.401]}, {"w": "Moreover,", "b": [0.3433, 0.3815, 0.4215, 0.401]}, {"w": "Apache", "b": [0.4319, 0.3815, 0.489, 0.401]}, {"w": "Beam", "b": [0.4993, 0.3815, 0.543, 0.401]}, {"w": "only", "b": [0.5534, 0.3815, 0.5871, 0.401]}, {"w": "has", "b": [0.5975, 0.3815, 0.623, 0.401]}, {"w": "partial", "b": [0.6334, 0.3815, 0.6829, 0.401]}, {"w": "support", "b": [0.6933, 0.3815, 0.7529, 0.401]}, {"w": "for", "b": [0.7633, 0.3815, 0.7857, 0.401]}, {"w": "Python", "b": [0.2714, 0.3989, 0.327, 0.4185]}, {"w": "3.", "b": [0.3338, 0.3989, 0.3473, 0.4185]}, {"w": "That", "b": [0.3541, 0.3989, 0.3898, 0.4185]}, {"w": "said,", "b": [0.3966, 0.3989, 0.4315, 0.4185]}, {"w": "both", "b": [0.4383, 0.3989, 0.4736, 0.4185]}, {"w": "these", "b": [0.4804, 0.3989, 0.5196, 0.4185]}, {"w": "limitations", "b": [0.5264, 0.3989, 0.6089, 0.4185]}, {"w": "will", "b": [0.6156, 0.3989, 0.6434, 0.4185]}, {"w": "likely", "b": [0.6502, 0.3989, 0.6913, 0.4185]}, {"w": "be", "b": [0.6981, 0.3989, 0.7158, 0.4185]}, {"w": "fixed", "b": [0.7226, 0.3989, 0.7605, 0.4185]}, {"w": "by", "b": [0.7673, 0.3989, 0.7857, 0.4185]}, {"w": "the", "b": [0.2714, 0.4163, 0.2955, 0.4359]}, {"w": "time", "b": [0.2998, 0.4163, 0.3344, 0.4359]}, {"w": "your", "b": [0.3387, 0.4163, 0.3744, 0.4359]}, {"w": "read", "b": [0.3787, 0.4163, 0.4123, 0.4359]}, {"w": "this.", "b": [0.4166, 0.4163, 0.449, 0.4359]}]}, {"id": "b_5", "type": "paragraph", "text": "With the Data API, TFRecords, the Features API and TF Transform, you can build highly scalable input pipelines for training, and also benefit from fast and portable data preprocessing in production.", "words": [{"w": "With", "b": [0.1429, 0.4627, 0.1853, 0.4841]}, {"w": "the", "b": [0.1922, 0.4627, 0.2185, 0.4841]}, {"w": "Data", "b": [0.2254, 0.4627, 0.2649, 0.4841]}, {"w": "API,", "b": [0.2718, 0.4627, 0.3098, 0.4841]}, {"w": "TFRecords,", "b": [0.3167, 0.4627, 0.4129, 0.4841]}, {"w": "the", "b": [0.4198, 0.4627, 0.4461, 0.4841]}, {"w": "Features", "b": [0.453, 0.4627, 0.5229, 0.4841]}, {"w": "API", "b": [0.5297, 0.4627, 0.563, 0.4841]}, {"w": "and", "b": [0.5699, 0.4627, 0.6014, 0.4841]}, {"w": "TF", "b": [0.6083, 0.4627, 0.6321, 0.4841]}, {"w": "Transform,", "b": [0.639, 0.4627, 0.7324, 0.4841]}, {"w": "you", "b": [0.7393, 0.4627, 0.7705, 0.4841]}, {"w": "can", "b": [0.7774, 0.4627, 0.8068, 0.4841]}, {"w": "build", "b": [0.8136, 0.4627, 0.8571, 0.4841]}, {"w": "highly", "b": [0.1429, 0.4817, 0.1953, 0.5032]}, {"w": "scalable", "b": [0.2025, 0.4817, 0.2673, 0.5032]}, {"w": "input", "b": [0.2745, 0.4817, 0.3194, 0.5032]}, {"w": "pipelines", "b": [0.3267, 0.4817, 0.4017, 0.5032]}, {"w": "for", "b": [0.409, 0.4817, 0.4335, 0.5032]}, {"w": "training,", "b": [0.4407, 0.4817, 0.5124, 0.5032]}, {"w": "and", "b": [0.5197, 0.4817, 0.5512, 0.5032]}, {"w": "also", "b": [0.5585, 0.4817, 0.5912, 0.5032]}, {"w": "benefit", "b": [0.5984, 0.4817, 0.6562, 0.5032]}, {"w": "from", "b": [0.6635, 0.4817, 0.7051, 0.5032]}, {"w": "fast", "b": [0.7123, 0.4817, 0.7416, 0.5032]}, {"w": "and", "b": [0.7489, 0.4817, 0.7804, 0.5032]}, {"w": "portable", "b": [0.7877, 0.4817, 0.8572, 0.5032]}, {"w": "data", "b": [0.1429, 0.5008, 0.1781, 0.5222]}, {"w": "preprocessing", "b": [0.1828, 0.5008, 0.2993, 0.5222]}, {"w": "in", "b": [0.304, 0.5008, 0.321, 0.5222]}, {"w": "production.", "b": [0.3257, 0.5008, 0.4246, 0.5222]}]}, {"id": "b_6", "type": "paragraph", "text": "But what if you just wanted to use a standard dataset? Well in that case, things are much simpler: just use TFDS!", "words": [{"w": "But", "b": [0.1429, 0.5289, 0.1725, 0.5503]}, {"w": "what", "b": [0.1796, 0.5289, 0.2201, 0.5503]}, {"w": "if", "b": [0.2272, 0.5289, 0.2389, 0.5503]}, {"w": "you", "b": [0.246, 0.5289, 0.2772, 0.5503]}, {"w": "just", "b": [0.2843, 0.5289, 0.3147, 0.5503]}, {"w": "wanted", "b": [0.3217, 0.5289, 0.3824, 0.5503]}, {"w": "to", "b": [0.3894, 0.5289, 0.4064, 0.5503]}, {"w": "use", "b": [0.4135, 0.5289, 0.441, 0.5503]}, {"w": "a", "b": [0.4481, 0.5289, 0.4573, 0.5503]}, {"w": "standard", "b": [0.4643, 0.5289, 0.5377, 0.5503]}, {"w": "dataset?", "b": [0.5448, 0.5289, 0.6108, 0.5503]}, {"w": "Well", "b": [0.6179, 0.5289, 0.6555, 0.5503]}, {"w": "in", "b": [0.6625, 0.5289, 0.6795, 0.5503]}, {"w": "that", "b": [0.6866, 0.5289, 0.7192, 0.5503]}, {"w": "case,", "b": [0.7262, 0.5289, 0.7654, 0.5503]}, {"w": "things", "b": [0.7725, 0.5289, 0.8244, 0.5503]}, {"w": "are", "b": [0.8314, 0.5289, 0.8571, 0.5503]}, {"w": "much", "b": [0.1429, 0.548, 0.1905, 0.5694]}, {"w": "simpler:", "b": [0.1953, 0.548, 0.2632, 0.5694]}, {"w": "just", "b": [0.2679, 0.548, 0.2983, 0.5694]}, {"w": "use", "b": [0.303, 0.548, 0.3306, 0.5694]}, {"w": "TFDS!", "b": [0.3353, 0.548, 0.3901, 0.5694]}]}, {"id": "b_7", "type": "paragraph", "text": "The TensorFlow Datasets (TFDS) Project", "words": [{"w": "The", "b": [0.1429, 0.5824, 0.1881, 0.6166]}, {"w": "TensorFlow", "b": [0.194, 0.5824, 0.3359, 0.6166]}, {"w": "Datasets", "b": [0.3418, 0.5824, 0.4486, 0.6166]}, {"w": "(TFDS)", "b": [0.4545, 0.5824, 0.5336, 0.6166]}, {"w": "Project", "b": [0.5396, 0.5824, 0.6265, 0.6166]}]}, {"id": "b_8", "type": "paragraph", "text": "The TensorFlow Datasets project makes it trivial to download common datasets, from small ones like MNIST or Fashion MNIST, to huge datasets like ImageNet11 (you will need quite a bit of disk space!). The list includes image datasets, text datasets (includ‐ ing translation datasets), audio and video datasets, and more. You can visit https:// homl.info/tfds to view the full list, along with a description of each dataset.", "words": [{"w": "The", "b": [0.1429, 0.6235, 0.1757, 0.645]}, {"w": "TensorFlow", "b": [0.1804, 0.6235, 0.2787, 0.645]}, {"w": "Datasets", "b": [0.2834, 0.6235, 0.3535, 0.645]}, {"w": "project", "b": [0.3582, 0.6235, 0.4169, 0.645]}, {"w": "makes", "b": [0.4216, 0.6235, 0.4746, 0.645]}, {"w": "it", "b": [0.4794, 0.6235, 0.4913, 0.645]}, {"w": "trivial", "b": [0.496, 0.6235, 0.5454, 0.645]}, {"w": "to", "b": [0.5501, 0.6235, 0.5671, 0.645]}, {"w": "download", "b": [0.5718, 0.6235, 0.6551, 0.645]}, {"w": "common", "b": [0.6599, 0.6235, 0.7354, 0.645]}, {"w": "datasets,", "b": [0.7402, 0.6235, 0.8107, 0.645]}, {"w": "from", "b": [0.8154, 0.6235, 0.857, 0.645]}, {"w": "small", "b": [0.1429, 0.6426, 0.1872, 0.664]}, {"w": "ones", "b": [0.1927, 0.6426, 0.2312, 0.664]}, {"w": "like", "b": [0.2367, 0.6426, 0.2667, 0.664]}, {"w": "MNIST", "b": [0.2722, 0.6426, 0.336, 0.664]}, {"w": "or", "b": [0.3415, 0.6426, 0.3598, 0.664]}, {"w": "Fashion", "b": [0.3653, 0.6426, 0.4314, 0.664]}, {"w": "MNIST,", "b": [0.4369, 0.6426, 0.5034, 0.664]}, {"w": "to", "b": [0.5089, 0.6426, 0.5259, 0.664]}, {"w": "huge", "b": [0.5313, 0.6426, 0.5717, 0.664]}, {"w": "datasets", "b": [0.5772, 0.6426, 0.6429, 0.664]}, {"w": "like", "b": [0.6484, 0.6426, 0.6784, 0.664]}, {"w": "ImageNet11", "b": [0.6839, 0.6426, 0.7774, 0.664]}, {"w": "(you", "b": [0.7828, 0.6426, 0.8213, 0.664]}, {"w": "will", "b": [0.8268, 0.6426, 0.8571, 0.664]}, {"w": "need", "b": [0.1429, 0.6616, 0.183, 0.683]}, {"w": "quite", "b": [0.1881, 0.6616, 0.2306, 0.683]}, {"w": "a", "b": [0.2358, 0.6616, 0.245, 0.683]}, {"w": "bit", "b": [0.2501, 0.6616, 0.2727, 0.683]}, {"w": "of", "b": [0.2778, 0.6616, 0.2946, 0.683]}, {"w": "disk", "b": [0.2998, 0.6616, 0.3344, 0.683]}, {"w": "space!).", "b": [0.3395, 0.6616, 0.4026, 0.683]}, {"w": "The", "b": [0.4078, 0.6616, 0.4406, 0.683]}, {"w": "list", "b": [0.4458, 0.6616, 0.4707, 0.683]}, {"w": "includes", "b": [0.4758, 0.6616, 0.5455, 0.683]}, {"w": "image", "b": [0.5506, 0.6616, 0.601, 0.683]}, {"w": "datasets,", "b": [0.6062, 0.6616, 0.6767, 0.683]}, {"w": "text", "b": [0.6819, 0.6616, 0.7133, 0.683]}, {"w": "datasets", "b": [0.7185, 0.6616, 0.7842, 0.683]}, {"w": "(includ‐", "b": [0.7894, 0.6616, 0.8571, 0.683]}, {"w": "ing", "b": [0.1429, 0.6807, 0.1696, 0.7021]}, {"w": "translation", "b": [0.177, 0.6807, 0.2673, 0.7021]}, {"w": "datasets),", "b": [0.2747, 0.6807, 0.3524, 0.7021]}, {"w": "audio", "b": [0.3599, 0.6807, 0.4069, 0.7021]}, {"w": "and", "b": [0.4144, 0.6807, 0.4459, 0.7021]}, {"w": "video", "b": [0.4534, 0.6807, 0.4991, 0.7021]}, {"w": "datasets,", "b": [0.5065, 0.6807, 0.577, 0.7021]}, {"w": "and", "b": [0.5845, 0.6807, 0.616, 0.7021]}, {"w": "more.", "b": [0.6235, 0.6807, 0.6725, 0.7021]}, {"w": "You", "b": [0.6799, 0.6807, 0.7123, 0.7021]}, {"w": "can", "b": [0.7198, 0.6807, 0.7491, 0.7021]}, {"w": "visit", "b": [0.7566, 0.6807, 0.7914, 0.7021]}, {"w": "https://", "b": [0.7988, 0.6805, 0.8571, 0.7021]}, {"w": "homl.info/tfds", "b": [0.1429, 0.6995, 0.2569, 0.7211]}, {"w": "to", "b": [0.2617, 0.6997, 0.2786, 0.7211]}, {"w": "view", "b": [0.2834, 0.6997, 0.3217, 0.7211]}, {"w": "the", "b": [0.3264, 0.6997, 0.3528, 0.7211]}, {"w": "full", "b": [0.3575, 0.6997, 0.3853, 0.7211]}, {"w": "list,", "b": [0.39, 0.6997, 0.4196, 0.7211]}, {"w": "along", "b": [0.4243, 0.6997, 0.4705, 0.7211]}, {"w": "with", "b": [0.4753, 0.6997, 0.5126, 0.7211]}, {"w": "a", "b": [0.5173, 0.6997, 0.5265, 0.7211]}, {"w": "description", "b": [0.5312, 0.6997, 0.6257, 0.7211]}, {"w": "of", "b": [0.6304, 0.6997, 0.6472, 0.7211]}, {"w": "each", "b": [0.6519, 0.6997, 0.6899, 0.7211]}, {"w": "dataset.", "b": [0.6946, 0.6997, 0.7575, 0.7211]}]}, {"id": "b_9", "type": "paragraph", "text": "TFDS is not bundled with TensorFlow, so you need to install the tensorflow- datasets library (e.g., using pip). Then all you need to do is call the tfds.load() function, and it will download the data you want (unless it was already downloaded earlier), and return the data as a dictionary of Datasets (typically one for training,", "words": [{"w": "TFDS", "b": [0.1429, 0.7287, 0.1919, 0.7502]}, {"w": "is", "b": [0.2022, 0.7287, 0.2154, 0.7502]}, {"w": "not", "b": [0.2257, 0.7287, 0.2541, 0.7502]}, {"w": "bundled", "b": [0.2643, 0.7287, 0.3335, 0.7502]}, {"w": "with", "b": [0.3438, 0.7287, 0.3811, 0.7502]}, {"w": "TensorFlow,", "b": [0.3914, 0.7287, 0.4928, 0.7502]}, {"w": "so", "b": [0.5031, 0.7287, 0.5214, 0.7502]}, {"w": "you", "b": [0.5316, 0.7287, 0.5629, 0.7502]}, {"w": "need", "b": [0.5732, 0.7287, 0.6133, 0.7502]}, {"w": "to", "b": [0.6235, 0.7287, 0.6405, 0.7502]}, {"w": "install", "b": [0.6508, 0.7287, 0.7014, 0.7502]}, {"w": "the", "b": [0.7117, 0.7287, 0.738, 0.7502]}, {"w": "tensorflow-", "b": [0.7483, 0.7319, 0.8572, 0.747]}, {"w": "datasets", "b": [0.1429, 0.7519, 0.222, 0.767]}, {"w": "library", "b": [0.2294, 0.7487, 0.2856, 0.7701]}, {"w": "(e.g.,", "b": [0.293, 0.7487, 0.333, 0.7701]}, {"w": "using", "b": [0.3404, 0.7487, 0.3859, 0.7701]}, {"w": "pip).", "b": [0.3932, 0.7487, 0.4326, 0.7701]}, {"w": "Then", "b": [0.44, 0.7487, 0.4842, 0.7701]}, {"w": "all", "b": [0.4916, 0.7487, 0.5113, 0.7701]}, {"w": "you", "b": [0.5186, 0.7487, 0.5499, 0.7701]}, {"w": "need", "b": [0.5573, 0.7487, 0.5974, 0.7701]}, {"w": "to", "b": [0.6047, 0.7487, 0.6217, 0.7701]}, {"w": "do", "b": [0.6291, 0.7487, 0.6507, 0.7701]}, {"w": "is", "b": [0.6581, 0.7487, 0.6713, 0.7701]}, {"w": "call", "b": [0.6787, 0.7487, 0.7072, 0.7701]}, {"w": "the", "b": [0.7146, 0.7487, 0.7409, 0.7701]}, {"w": "tfds.load()", "b": [0.7483, 0.7519, 0.8571, 0.767]}, {"w": "function,", "b": [0.1429, 0.7677, 0.219, 0.7892]}, {"w": "and", "b": [0.2253, 0.7677, 0.2568, 0.7892]}, {"w": "it", "b": [0.2631, 0.7677, 0.275, 0.7892]}, {"w": "will", "b": [0.2813, 0.7677, 0.3117, 0.7892]}, {"w": "download", "b": [0.3179, 0.7677, 0.4013, 0.7892]}, {"w": "the", "b": [0.4075, 0.7677, 0.4338, 0.7892]}, {"w": "data", "b": [0.4401, 0.7677, 0.4754, 0.7892]}, {"w": "you", "b": [0.4816, 0.7677, 0.5129, 0.7892]}, {"w": "want", "b": [0.5191, 0.7677, 0.5599, 0.7892]}, {"w": "(unless", "b": [0.5661, 0.7677, 0.6252, 0.7892]}, {"w": "it", "b": [0.6315, 0.7677, 0.6434, 0.7892]}, {"w": "was", "b": [0.6497, 0.7677, 0.6807, 0.7892]}, {"w": "already", "b": [0.687, 0.7677, 0.7477, 0.7892]}, {"w": "downloaded", "b": [0.754, 0.7677, 0.8572, 0.7892]}, {"w": "earlier),", "b": [0.1429, 0.7877, 0.208, 0.8091]}, {"w": "and", "b": [0.2149, 0.7877, 0.2464, 0.8091]}, {"w": "return", "b": [0.2534, 0.7877, 0.3065, 0.8091]}, {"w": "the", "b": [0.3134, 0.7877, 0.3397, 0.8091]}, {"w": "data", "b": [0.3466, 0.7877, 0.3819, 0.8091]}, {"w": "as", "b": [0.3888, 0.7877, 0.4056, 0.8091]}, {"w": "a", "b": [0.4125, 0.7877, 0.4216, 0.8091]}, {"w": "dictionary", "b": [0.4286, 0.7877, 0.515, 0.8091]}, {"w": "of", "b": [0.5219, 0.7877, 0.5387, 0.8091]}, {"w": "Datasets", "b": [0.5456, 0.7909, 0.6247, 0.8059]}, {"w": "(typically", "b": [0.6316, 0.7877, 0.7093, 0.8091]}, {"w": "one", "b": [0.7162, 0.7877, 0.7471, 0.8091]}, {"w": "for", "b": [0.754, 0.7877, 0.7785, 0.8091]}, {"w": "training,", "b": [0.7855, 0.7877, 0.8571, 0.8091]}]}, {"id": "b_10", "type": "paragraph", "text": "The TensorFlow Datasets (TFDS) Project | 429", "words": [{"w": "The", "b": [0.5658, 0.9225, 0.5873, 0.9388]}, {"w": "TensorFlow", "b": [0.5901, 0.9225, 0.6576, 0.9388]}, {"w": "Datasets", "b": [0.6604, 0.9225, 0.7112, 0.9388]}, {"w": "(TFDS)", "b": [0.714, 0.9225, 0.7517, 0.9388]}, {"w": "Project", "b": [0.7545, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "429", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 456, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "and one for testing, but this depends on the dataset you choose). For example, let’s download MNIST:", "words": [{"w": "and", "b": [0.1429, 0.0791, 0.1744, 0.1005]}, {"w": "one", "b": [0.1814, 0.0791, 0.2122, 0.1005]}, {"w": "for", "b": [0.2192, 0.0791, 0.2437, 0.1005]}, {"w": "testing,", "b": [0.2507, 0.0791, 0.3114, 0.1005]}, {"w": "but", "b": [0.3183, 0.0791, 0.3463, 0.1005]}, {"w": "this", "b": [0.3533, 0.0791, 0.384, 0.1005]}, {"w": "depends", "b": [0.3909, 0.0791, 0.4606, 0.1005]}, {"w": "on", "b": [0.4676, 0.0791, 0.4896, 0.1005]}, {"w": "the", "b": [0.4966, 0.0791, 0.5229, 0.1005]}, {"w": "dataset", "b": [0.5298, 0.0791, 0.5879, 0.1005]}, {"w": "you", "b": [0.5949, 0.0791, 0.6262, 0.1005]}, {"w": "choose).", "b": [0.6331, 0.0791, 0.7028, 0.1005]}, {"w": "For", "b": [0.7097, 0.0791, 0.7387, 0.1005]}, {"w": "example,", "b": [0.7457, 0.0791, 0.82, 0.1005]}, {"w": "let’s", "b": [0.8269, 0.0791, 0.8571, 0.1005]}, {"w": "download", "b": [0.1429, 0.0981, 0.2262, 0.1195]}, {"w": "MNIST:", "b": [0.2309, 0.0981, 0.2989, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "import tensorflow_datasets as tfds", "words": [{"w": "import", "b": [0.1766, 0.1301, 0.2272, 0.1429]}, {"w": "tensorflow_datasets", "b": [0.2356, 0.1301, 0.3958, 0.1429]}, {"w": "as", "b": [0.4043, 0.1301, 0.4211, 0.1429]}, {"w": "tfds", "b": [0.4296, 0.1301, 0.4633, 0.1429]}]}, {"id": "b_2", "type": "paragraph", "text": "dataset = tfds.load(name=\"mnist\") mnist_train, mnist_test = dataset[\"train\"], dataset[\"test\"]", "words": [{"w": "dataset", "b": [0.1766, 0.1609, 0.2356, 0.1738]}, {"w": "=", "b": [0.244, 0.1609, 0.2525, 0.1738]}, {"w": "tfds.load(name=\"mnist\")", "b": [0.2609, 0.1609, 0.4549, 0.1738]}, {"w": "mnist_train,", "b": [0.1766, 0.1763, 0.2778, 0.1892]}, {"w": "mnist_test", "b": [0.2862, 0.1763, 0.3705, 0.1892]}, {"w": "=", "b": [0.379, 0.1763, 0.3874, 0.1892]}, {"w": "dataset[\"train\"],", "b": [0.3958, 0.1763, 0.5392, 0.1892]}, {"w": "dataset[\"test\"]", "b": [0.5476, 0.1763, 0.6741, 0.1892]}]}, {"id": "b_3", "type": "paragraph", "text": "You can then apply any transformation you want (typically repeating, batching and prefetching), and you’re ready to train your model. Here is a simple example:", "words": [{"w": "You", "b": [0.1429, 0.197, 0.1752, 0.2184]}, {"w": "can", "b": [0.1822, 0.197, 0.2115, 0.2184]}, {"w": "then", "b": [0.2185, 0.197, 0.2562, 0.2184]}, {"w": "apply", "b": [0.2632, 0.197, 0.3086, 0.2184]}, {"w": "any", "b": [0.3156, 0.197, 0.3452, 0.2184]}, {"w": "transformation", "b": [0.3522, 0.197, 0.4788, 0.2184]}, {"w": "you", "b": [0.4857, 0.197, 0.517, 0.2184]}, {"w": "want", "b": [0.524, 0.197, 0.5647, 0.2184]}, {"w": "(typically", "b": [0.5717, 0.197, 0.6494, 0.2184]}, {"w": "repeating,", "b": [0.6564, 0.197, 0.7393, 0.2184]}, {"w": "batching", "b": [0.7463, 0.197, 0.8186, 0.2184]}, {"w": "and", "b": [0.8256, 0.197, 0.8571, 0.2184]}, {"w": "prefetching),", "b": [0.1428, 0.216, 0.2503, 0.2374]}, {"w": "and", "b": [0.2551, 0.216, 0.2866, 0.2374]}, {"w": "you’re", "b": [0.2913, 0.216, 0.3422, 0.2374]}, {"w": "ready", "b": [0.3469, 0.216, 0.3932, 0.2374]}, {"w": "to", "b": [0.3979, 0.216, 0.4149, 0.2374]}, {"w": "train", "b": [0.4196, 0.216, 0.4598, 0.2374]}, {"w": "your", "b": [0.4646, 0.216, 0.5036, 0.2374]}, {"w": "model.", "b": [0.5083, 0.216, 0.5658, 0.2374]}, {"w": "Here", "b": [0.5706, 0.216, 0.6115, 0.2374]}, {"w": "is", "b": [0.6162, 0.216, 0.6294, 0.2374]}, {"w": "a", "b": [0.6341, 0.216, 0.6433, 0.2374]}, {"w": "simple", "b": [0.648, 0.216, 0.703, 0.2374]}, {"w": "example:", "b": [0.7077, 0.216, 0.782, 0.2374]}]}, {"id": "b_4", "type": "paragraph", "text": "mnist_train = mnist_train.repeat(5).batch(32).prefetch(1) for item in mnist_train: images = item[\"image\"] labels = item[\"label\"] [...]", "words": [{"w": "mnist_train", "b": [0.1766, 0.248, 0.2693, 0.2608]}, {"w": "=", "b": [0.2778, 0.248, 0.2862, 0.2608]}, {"w": "mnist_train.repeat(5).batch(32).prefetch(1)", "b": [0.2946, 0.248, 0.6572, 0.2608]}, {"w": "for", "b": [0.1766, 0.2634, 0.2019, 0.2763]}, {"w": "item", "b": [0.2103, 0.2634, 0.244, 0.2763]}, {"w": "in", "b": [0.2525, 0.2634, 0.2693, 0.2763]}, {"w": "mnist_train:", "b": [0.2778, 0.2634, 0.379, 0.2763]}, {"w": "images", "b": [0.2103, 0.2788, 0.2609, 0.2917]}, {"w": "=", "b": [0.2693, 0.2788, 0.2778, 0.2917]}, {"w": "item[\"image\"]", "b": [0.2862, 0.2788, 0.3958, 0.2917]}, {"w": "labels", "b": [0.2103, 0.2943, 0.2609, 0.3071]}, {"w": "=", "b": [0.2693, 0.2943, 0.2778, 0.3071]}, {"w": "item[\"label\"]", "b": [0.2862, 0.2943, 0.3958, 0.3071]}, {"w": "[...]", "b": [0.2103, 0.3097, 0.2525, 0.3225]}]}, {"id": "b_5", "type": "paragraph", "text": "In general, load() returns a shuffled training set, so there’s no need to shuffle it some more.", "words": [{"w": "In", "b": [0.2714, 0.345, 0.2883, 0.3645]}, {"w": "general,", "b": [0.2926, 0.345, 0.3528, 0.3645]}, {"w": "load()", "b": [0.3576, 0.3479, 0.4119, 0.3617]}, {"w": "returns", "b": [0.4165, 0.345, 0.472, 0.3645]}, {"w": "a", "b": [0.4766, 0.345, 0.485, 0.3645]}, {"w": "shuffled", "b": [0.4896, 0.345, 0.5507, 0.3645]}, {"w": "training", "b": [0.5553, 0.345, 0.6165, 0.3645]}, {"w": "set,", "b": [0.6211, 0.345, 0.6463, 0.3645]}, {"w": "so", "b": [0.6509, 0.345, 0.6676, 0.3645]}, {"w": "there’s", "b": [0.6722, 0.345, 0.7198, 0.3645]}, {"w": "no", "b": [0.7243, 0.345, 0.7445, 0.3645]}, {"w": "need", "b": [0.749, 0.345, 0.7857, 0.3645]}, {"w": "to", "b": [0.2714, 0.3624, 0.2869, 0.3819]}, {"w": "shuffle", "b": [0.2913, 0.3624, 0.3424, 0.3819]}, {"w": "it", "b": [0.3467, 0.3624, 0.3576, 0.3819]}, {"w": "some", "b": [0.3619, 0.3624, 0.4023, 0.3819]}, {"w": "more.", "b": [0.4066, 0.3624, 0.4515, 0.3819]}]}, {"id": "b_6", "type": "paragraph", "text": "Note that each item in the dataset is a dictionary containing both the features and the labels. But Keras expects each item to be a tuple containing 2 elements (again, the fea‐ tures and the labels). You could transform the dataset using the map() method, like this:", "words": [{"w": "Note", "b": [0.1429, 0.4428, 0.1837, 0.4642]}, {"w": "that", "b": [0.1888, 0.4428, 0.2214, 0.4642]}, {"w": "each", "b": [0.2265, 0.4428, 0.2644, 0.4642]}, {"w": "item", "b": [0.2696, 0.4428, 0.3074, 0.4642]}, {"w": "in", "b": [0.3126, 0.4428, 0.3295, 0.4642]}, {"w": "the", "b": [0.3347, 0.4428, 0.361, 0.4642]}, {"w": "dataset", "b": [0.3661, 0.4428, 0.4242, 0.4642]}, {"w": "is", "b": [0.4294, 0.4428, 0.4426, 0.4642]}, {"w": "a", "b": [0.4477, 0.4428, 0.4569, 0.4642]}, {"w": "dictionary", "b": [0.462, 0.4428, 0.5484, 0.4642]}, {"w": "containing", "b": [0.5535, 0.4428, 0.6432, 0.4642]}, {"w": "both", "b": [0.6483, 0.4428, 0.687, 0.4642]}, {"w": "the", "b": [0.6921, 0.4428, 0.7185, 0.4642]}, {"w": "features", "b": [0.7236, 0.4428, 0.789, 0.4642]}, {"w": "and", "b": [0.7941, 0.4428, 0.8257, 0.4642]}, {"w": "the", "b": [0.8308, 0.4428, 0.8571, 0.4642]}, {"w": "labels.", "b": [0.1429, 0.4618, 0.1944, 0.4832]}, {"w": "But", "b": [0.1992, 0.4618, 0.2289, 0.4832]}, {"w": "Keras", "b": [0.2337, 0.4618, 0.2806, 0.4832]}, {"w": "expects", "b": [0.2855, 0.4618, 0.3467, 0.4832]}, {"w": "each", "b": [0.3516, 0.4618, 0.3895, 0.4832]}, {"w": "item", "b": [0.3944, 0.4618, 0.4322, 0.4832]}, {"w": "to", "b": [0.4371, 0.4618, 0.4541, 0.4832]}, {"w": "be", "b": [0.4589, 0.4618, 0.4783, 0.4832]}, {"w": "a", "b": [0.4832, 0.4618, 0.4923, 0.4832]}, {"w": "tuple", "b": [0.4972, 0.4618, 0.5396, 0.4832]}, {"w": "containing", "b": [0.5445, 0.4618, 0.6341, 0.4832]}, {"w": "2", "b": [0.639, 0.4618, 0.649, 0.4832]}, {"w": "elements", "b": [0.6538, 0.4618, 0.7277, 0.4832]}, {"w": "(again,", "b": [0.7326, 0.4618, 0.7895, 0.4832]}, {"w": "the", "b": [0.7944, 0.4618, 0.8207, 0.4832]}, {"w": "fea‐", "b": [0.8256, 0.4618, 0.8571, 0.4832]}, {"w": "tures", "b": [0.1429, 0.4818, 0.1845, 0.5032]}, {"w": "and", "b": [0.1912, 0.4818, 0.2228, 0.5032]}, {"w": "the", "b": [0.2295, 0.4818, 0.2558, 0.5032]}, {"w": "labels).", "b": [0.2626, 0.4818, 0.3213, 0.5032]}, {"w": "You", "b": [0.328, 0.4818, 0.3604, 0.5032]}, {"w": "could", "b": [0.3671, 0.4818, 0.4139, 0.5032]}, {"w": "transform", "b": [0.4206, 0.4818, 0.5045, 0.5032]}, {"w": "the", "b": [0.5112, 0.4818, 0.5376, 0.5032]}, {"w": "dataset", "b": [0.5443, 0.4818, 0.6024, 0.5032]}, {"w": "using", "b": [0.6091, 0.4818, 0.6546, 0.5032]}, {"w": "the", "b": [0.6613, 0.4818, 0.6876, 0.5032]}, {"w": "map()", "b": [0.6944, 0.485, 0.7439, 0.5]}, {"w": "method,", "b": [0.7506, 0.4818, 0.8204, 0.5032]}, {"w": "like", "b": [0.8271, 0.4818, 0.8571, 0.5032]}, {"w": "this:", "b": [0.1429, 0.5008, 0.1783, 0.5222]}]}, {"id": "b_7", "type": "paragraph", "text": "mnist_train = mnist_train.repeat(5).batch(32) mnist_train = mnist_train.map(lambda items: (items[\"image\"], items[\"label\"])) mnist_train = mnist_train.prefetch(1)", "words": [{"w": "mnist_train", "b": [0.1766, 0.5328, 0.2693, 0.5456]}, {"w": "=", "b": [0.2778, 0.5328, 0.2862, 0.5456]}, {"w": "mnist_train.repeat(5).batch(32)", "b": [0.2946, 0.5328, 0.5561, 0.5456]}, {"w": "mnist_train", "b": [0.1766, 0.5482, 0.2693, 0.5611]}, {"w": "=", "b": [0.2778, 0.5482, 0.2862, 0.5611]}, {"w": "mnist_train.map(lambda", "b": [0.2946, 0.5482, 0.4802, 0.5611]}, {"w": "items:", "b": [0.4886, 0.5482, 0.5392, 0.5611]}, {"w": "(items[\"image\"],", "b": [0.5476, 0.5482, 0.6825, 0.5611]}, {"w": "items[\"label\"]))", "b": [0.691, 0.5482, 0.8259, 0.5611]}, {"w": "mnist_train", "b": [0.1766, 0.5636, 0.2693, 0.5765]}, {"w": "=", "b": [0.2778, 0.5636, 0.2862, 0.5765]}, {"w": "mnist_train.prefetch(1)", "b": [0.2946, 0.5636, 0.4886, 0.5765]}]}, {"id": "b_8", "type": "paragraph", "text": "Or you can just ask the load() function to do this for you by setting as_super vised=True (obviously this works only for labeled datasets). You can also specify the batch size if you want. Then the dataset can be passed directly to your tf.keras model:", "words": [{"w": "Or", "b": [0.1429, 0.5852, 0.1662, 0.6066]}, {"w": "you", "b": [0.1749, 0.5852, 0.2062, 0.6066]}, {"w": "can", "b": [0.2149, 0.5852, 0.2443, 0.6066]}, {"w": "just", "b": [0.2531, 0.5852, 0.2835, 0.6066]}, {"w": "ask", "b": [0.2922, 0.5852, 0.3194, 0.6066]}, {"w": "the", "b": [0.3281, 0.5852, 0.3545, 0.6066]}, {"w": "load()", "b": [0.3632, 0.5883, 0.4226, 0.6034]}, {"w": "function", "b": [0.4314, 0.5852, 0.5028, 0.6066]}, {"w": "to", "b": [0.5116, 0.5852, 0.5285, 0.6066]}, {"w": "do", "b": [0.5373, 0.5852, 0.5589, 0.6066]}, {"w": "this", "b": [0.5677, 0.5852, 0.5984, 0.6066]}, {"w": "for", "b": [0.6072, 0.5852, 0.6317, 0.6066]}, {"w": "you", "b": [0.6405, 0.5852, 0.6717, 0.6066]}, {"w": "by", "b": [0.6805, 0.5852, 0.7007, 0.6066]}, {"w": "setting", "b": [0.7094, 0.5852, 0.7654, 0.6066]}, {"w": "as_super", "b": [0.7741, 0.5883, 0.8533, 0.6034]}, {"w": "vised=True", "b": [0.1429, 0.6083, 0.2418, 0.6234]}, {"w": "(obviously", "b": [0.2476, 0.6051, 0.3354, 0.6265]}, {"w": "this", "b": [0.3412, 0.6051, 0.3719, 0.6265]}, {"w": "works", "b": [0.3777, 0.6051, 0.4283, 0.6265]}, {"w": "only", "b": [0.4341, 0.6051, 0.471, 0.6265]}, {"w": "for", "b": [0.4768, 0.6051, 0.5013, 0.6265]}, {"w": "labeled", "b": [0.5071, 0.6051, 0.5661, 0.6265]}, {"w": "datasets).", "b": [0.5719, 0.6051, 0.6496, 0.6265]}, {"w": "You", "b": [0.6554, 0.6051, 0.6877, 0.6265]}, {"w": "can", "b": [0.6935, 0.6051, 0.7229, 0.6265]}, {"w": "also", "b": [0.7286, 0.6051, 0.7613, 0.6265]}, {"w": "specify", "b": [0.7671, 0.6051, 0.825, 0.6265]}, {"w": "the", "b": [0.8308, 0.6051, 0.8571, 0.6265]}, {"w": "batch", "b": [0.1429, 0.6242, 0.1885, 0.6456]}, {"w": "size", "b": [0.1932, 0.6242, 0.224, 0.6456]}, {"w": "if", "b": [0.2288, 0.6242, 0.2405, 0.6456]}, {"w": "you", "b": [0.2453, 0.6242, 0.2765, 0.6456]}, {"w": "want.", "b": [0.2812, 0.6242, 0.3268, 0.6456]}, {"w": "Then", "b": [0.3315, 0.6242, 0.3757, 0.6456]}, {"w": "the", "b": [0.3804, 0.6242, 0.4068, 0.6456]}, {"w": "dataset", "b": [0.4115, 0.6242, 0.4696, 0.6456]}, {"w": "can", "b": [0.4743, 0.6242, 0.5037, 0.6456]}, {"w": "be", "b": [0.5084, 0.6242, 0.5279, 0.6456]}, {"w": "passed", "b": [0.5326, 0.6242, 0.5878, 0.6456]}, {"w": "directly", "b": [0.5925, 0.6242, 0.6557, 0.6456]}, {"w": "to", "b": [0.6604, 0.6242, 0.6774, 0.6456]}, {"w": "your", "b": [0.6821, 0.6242, 0.7211, 0.6456]}, {"w": "tf.keras", "b": [0.7258, 0.6242, 0.7868, 0.6456]}, {"w": "model:", "b": [0.7915, 0.6242, 0.8491, 0.6456]}]}, {"id": "b_9", "type": "paragraph", "text": "dataset = tfds.load(name=\"mnist\", batch_size=32, as_supervised=True) mnist_train = dataset[\"train\"].repeat().prefetch(1) model = keras.models.Sequential([...]) model.compile(loss=\"sparse_categorical_crossentropy\", optimizer=\"sgd\") model.fit(mnist_train, steps_per_epoch=60000 // 32, epochs=5)", "words": [{"w": "dataset", "b": [0.1766, 0.6561, 0.2356, 0.669]}, {"w": "=", "b": [0.244, 0.6561, 0.2525, 0.669]}, {"w": "tfds.load(name=\"mnist\",", "b": [0.2609, 0.6561, 0.4549, 0.669]}, {"w": "batch_size=32,", "b": [0.4633, 0.6561, 0.5813, 0.669]}, {"w": "as_supervised=True)", "b": [0.5898, 0.6561, 0.75, 0.669]}, {"w": "mnist_train", "b": [0.1766, 0.6715, 0.2693, 0.6844]}, {"w": "=", "b": [0.2778, 0.6715, 0.2862, 0.6844]}, {"w": "dataset[\"train\"].repeat().prefetch(1)", "b": [0.2946, 0.6715, 0.6066, 0.6844]}, {"w": "model", "b": [0.1766, 0.687, 0.2187, 0.6998]}, {"w": "=", "b": [0.2272, 0.687, 0.2356, 0.6998]}, {"w": "keras.models.Sequential([...])", "b": [0.244, 0.687, 0.497, 0.6998]}, {"w": "model.compile(loss=\"sparse_categorical_crossentropy\",", "b": [0.1766, 0.7024, 0.6235, 0.7152]}, {"w": "optimizer=\"sgd\")", "b": [0.6319, 0.7024, 0.7669, 0.7152]}, {"w": "model.fit(mnist_train,", "b": [0.1766, 0.7178, 0.3621, 0.7307]}, {"w": "steps_per_epoch=60000", "b": [0.3705, 0.7178, 0.5476, 0.7307]}, {"w": "//", "b": [0.556, 0.7178, 0.5729, 0.7307]}, {"w": "32,", "b": [0.5813, 0.7178, 0.6066, 0.7307]}, {"w": "epochs=5)", "b": [0.6151, 0.7178, 0.691, 0.7307]}]}, {"id": "b_10", "type": "paragraph", "text": "This was quite a technical chapter, and you may feel that it is a bit far from the abstract beauty of neural networks, but the fact is deep learning often involves large amounts of data, and knowing how to load, parse and preprocess it efficiently is a crucial skill to have. In the next chapter, we will look at Convolutional Neural Net‐ works, which are among the most successful neural net architectures for image pro‐ cessing, and many other applications.", "words": [{"w": "This", "b": [0.1429, 0.7384, 0.1801, 0.7599]}, {"w": "was", "b": [0.1886, 0.7384, 0.2197, 0.7599]}, {"w": "quite", "b": [0.2282, 0.7384, 0.2707, 0.7599]}, {"w": "a", "b": [0.2793, 0.7384, 0.2884, 0.7599]}, {"w": "technical", "b": [0.297, 0.7384, 0.3723, 0.7599]}, {"w": "chapter,", "b": [0.3809, 0.7384, 0.4469, 0.7599]}, {"w": "and", "b": [0.4554, 0.7384, 0.4869, 0.7599]}, {"w": "you", "b": [0.4955, 0.7384, 0.5267, 0.7599]}, {"w": "may", "b": [0.5353, 0.7384, 0.5707, 0.7599]}, {"w": "feel", "b": [0.5792, 0.7384, 0.6084, 0.7599]}, {"w": "that", "b": [0.6169, 0.7384, 0.6495, 0.7599]}, {"w": "it", "b": [0.6581, 0.7384, 0.67, 0.7599]}, {"w": "is", "b": [0.6785, 0.7384, 0.6918, 0.7599]}, {"w": "a", "b": [0.7003, 0.7384, 0.7095, 0.7599]}, {"w": "bit", "b": [0.718, 0.7384, 0.7405, 0.7599]}, {"w": "far", "b": [0.7491, 0.7384, 0.7721, 0.7599]}, {"w": "from", "b": [0.7807, 0.7384, 0.8223, 0.7599]}, {"w": "the", "b": [0.8308, 0.7384, 0.8571, 0.7599]}, {"w": "abstract", "b": [0.1429, 0.7575, 0.2086, 0.7789]}, {"w": "beauty", "b": [0.2149, 0.7575, 0.2701, 0.7789]}, {"w": "of", "b": [0.2764, 0.7575, 0.2932, 0.7789]}, {"w": "neural", "b": [0.2995, 0.7575, 0.353, 0.7789]}, {"w": "networks,", "b": [0.3593, 0.7575, 0.4412, 0.7789]}, {"w": "but", "b": [0.4475, 0.7575, 0.4755, 0.7789]}, {"w": "the", "b": [0.4819, 0.7575, 0.5082, 0.7789]}, {"w": "fact", "b": [0.5145, 0.7575, 0.545, 0.7789]}, {"w": "is", "b": [0.5513, 0.7575, 0.5645, 0.7789]}, {"w": "deep", "b": [0.5708, 0.7575, 0.6104, 0.7789]}, {"w": "learning", "b": [0.6168, 0.7575, 0.6859, 0.7789]}, {"w": "often", "b": [0.6922, 0.7575, 0.7356, 0.7789]}, {"w": "involves", "b": [0.7419, 0.7575, 0.8101, 0.7789]}, {"w": "large", "b": [0.8164, 0.7575, 0.8571, 0.7789]}, {"w": "amounts", "b": [0.1428, 0.7765, 0.2157, 0.7979]}, {"w": "of", "b": [0.2232, 0.7765, 0.24, 0.7979]}, {"w": "data,", "b": [0.2474, 0.7765, 0.2874, 0.7979]}, {"w": "and", "b": [0.2948, 0.7765, 0.3263, 0.7979]}, {"w": "knowing", "b": [0.3337, 0.7765, 0.4071, 0.7979]}, {"w": "how", "b": [0.4145, 0.7765, 0.4505, 0.7979]}, {"w": "to", "b": [0.4579, 0.7765, 0.4749, 0.7979]}, {"w": "load,", "b": [0.4823, 0.7765, 0.5231, 0.7979]}, {"w": "parse", "b": [0.5306, 0.7765, 0.5748, 0.7979]}, {"w": "and", "b": [0.5823, 0.7765, 0.6138, 0.7979]}, {"w": "preprocess", "b": [0.6212, 0.7765, 0.7109, 0.7979]}, {"w": "it", "b": [0.7184, 0.7765, 0.7303, 0.7979]}, {"w": "efficiently", "b": [0.7377, 0.7765, 0.8199, 0.7979]}, {"w": "is", "b": [0.8273, 0.7765, 0.8406, 0.7979]}, {"w": "a", "b": [0.848, 0.7765, 0.8571, 0.7979]}, {"w": "crucial", "b": [0.1429, 0.7956, 0.1993, 0.817]}, {"w": "skill", "b": [0.2061, 0.7956, 0.2402, 0.817]}, {"w": "to", "b": [0.2471, 0.7956, 0.2641, 0.817]}, {"w": "have.", "b": [0.2709, 0.7956, 0.3141, 0.817]}, {"w": "In", "b": [0.3209, 0.7956, 0.3394, 0.817]}, {"w": "the", "b": [0.3463, 0.7956, 0.3726, 0.817]}, {"w": "next", "b": [0.3795, 0.7956, 0.4159, 0.817]}, {"w": "chapter,", "b": [0.4227, 0.7956, 0.4887, 0.817]}, {"w": "we", "b": [0.4956, 0.7956, 0.5187, 0.817]}, {"w": "will", "b": [0.5256, 0.7956, 0.5559, 0.817]}, {"w": "look", "b": [0.5628, 0.7956, 0.5997, 0.817]}, {"w": "at", "b": [0.6065, 0.7956, 0.6216, 0.817]}, {"w": "Convolutional", "b": [0.6285, 0.7956, 0.7488, 0.817]}, {"w": "Neural", "b": [0.7557, 0.7956, 0.8127, 0.817]}, {"w": "Net‐", "b": [0.8196, 0.7956, 0.8571, 0.817]}, {"w": "works,", "b": [0.1429, 0.8146, 0.1982, 0.836]}, {"w": "which", "b": [0.2043, 0.8146, 0.2553, 0.836]}, {"w": "are", "b": [0.2614, 0.8146, 0.2871, 0.836]}, {"w": "among", "b": [0.2933, 0.8146, 0.3512, 0.836]}, {"w": "the", "b": [0.3574, 0.8146, 0.3837, 0.836]}, {"w": "most", "b": [0.3898, 0.8146, 0.4315, 0.836]}, {"w": "successful", "b": [0.4376, 0.8146, 0.5206, 0.836]}, {"w": "neural", "b": [0.5268, 0.8146, 0.5802, 0.836]}, {"w": "net", "b": [0.5863, 0.8146, 0.613, 0.836]}, {"w": "architectures", "b": [0.6191, 0.8146, 0.7271, 0.836]}, {"w": "for", "b": [0.7333, 0.8146, 0.7578, 0.836]}, {"w": "image", "b": [0.7639, 0.8146, 0.8143, 0.836]}, {"w": "pro‐", "b": [0.8205, 0.8146, 0.8571, 0.836]}, {"w": "cessing,", "b": [0.1429, 0.8337, 0.2073, 0.8551]}, {"w": "and", "b": [0.212, 0.8337, 0.2436, 0.8551]}, {"w": "many", "b": [0.2483, 0.8337, 0.295, 0.8551]}, {"w": "other", "b": [0.2997, 0.8337, 0.3444, 0.8551]}, {"w": "applications.", "b": [0.3491, 0.8337, 0.4545, 0.8551]}]}, {"id": "b_11", "type": "paragraph", "text": "430 | Chapter 13: Loading and Preprocessing Data with TensorFlow", "words": [{"w": "430", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "13:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Loading", "b": [0.2745, 0.9225, 0.322, 0.9388]}, {"w": "and", "b": [0.3249, 0.9225, 0.3473, 0.9388]}, {"w": "Preprocessing", "b": [0.3501, 0.9225, 0.4321, 0.9388]}, {"w": "Data", "b": [0.4349, 0.9225, 0.4626, 0.9388]}, {"w": "with", "b": [0.4654, 0.9225, 0.4925, 0.9388]}, {"w": "TensorFlow", "b": [0.4953, 0.9225, 0.5628, 0.9388]}]}]}, {"page": 457, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "CHAPTER 14 Deep Computer Vision Using Convolutional", "words": [{"w": "CHAPTER", "b": [0.7262, 0.1146, 0.8246, 0.1451]}, {"w": "14", "b": [0.8299, 0.1146, 0.8571, 0.1451]}, {"w": "Deep", "b": [0.1559, 0.1478, 0.2401, 0.1935]}, {"w": "Computer", "b": [0.248, 0.1478, 0.4108, 0.1935]}, {"w": "Vision", "b": [0.4187, 0.1478, 0.5188, 0.1935]}, {"w": "Using", "b": [0.5267, 0.1478, 0.6195, 0.1935]}, {"w": "Convolutional", "b": [0.6274, 0.1478, 0.8571, 0.1935]}]}, {"id": "b_1", "type": "paragraph", "text": "Neural Networks", "words": [{"w": "Neural", "b": [0.5821, 0.184, 0.6919, 0.2297]}, {"w": "Networks", "b": [0.6998, 0.184, 0.8571, 0.2297]}]}, {"id": "b_2", "type": "paragraph", "text": "With Early Release ebooks, you get books in their earliest form— the author’s raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. The following will be Chapter 14 in the final release of the book.", "words": [{"w": "With", "b": [0.2714, 0.4006, 0.3102, 0.4201]}, {"w": "Early", "b": [0.3165, 0.4006, 0.3563, 0.4201]}, {"w": "Release", "b": [0.3626, 0.4006, 0.4189, 0.4201]}, {"w": "ebooks,", "b": [0.4251, 0.4006, 0.4831, 0.4201]}, {"w": "you", "b": [0.4894, 0.4006, 0.518, 0.4201]}, {"w": "get", "b": [0.5243, 0.4006, 0.5471, 0.4201]}, {"w": "books", "b": [0.5534, 0.4006, 0.5989, 0.4201]}, {"w": "in", "b": [0.6052, 0.4006, 0.6207, 0.4201]}, {"w": "their", "b": [0.627, 0.4006, 0.6632, 0.4201]}, {"w": "earliest", "b": [0.6695, 0.4006, 0.7238, 0.4201]}, {"w": "form—", "b": [0.7301, 0.4006, 0.7857, 0.4201]}, {"w": "the", "b": [0.2714, 0.418, 0.2955, 0.4376]}, {"w": "author’s", "b": [0.3012, 0.418, 0.3615, 0.4376]}, {"w": "raw", "b": [0.3672, 0.418, 0.3954, 0.4376]}, {"w": "and", "b": [0.4011, 0.418, 0.4299, 0.4376]}, {"w": "unedited", "b": [0.4357, 0.418, 0.5034, 0.4376]}, {"w": "content", "b": [0.5091, 0.418, 0.5667, 0.4376]}, {"w": "as", "b": [0.5725, 0.418, 0.5878, 0.4376]}, {"w": "he", "b": [0.5935, 0.418, 0.6118, 0.4376]}, {"w": "or", "b": [0.6175, 0.418, 0.6343, 0.4376]}, {"w": "she", "b": [0.64, 0.418, 0.6653, 0.4376]}, {"w": "writes—so", "b": [0.671, 0.418, 0.7514, 0.4376]}, {"w": "you", "b": [0.7571, 0.418, 0.7857, 0.4376]}, {"w": "can", "b": [0.2714, 0.4354, 0.2982, 0.455]}, {"w": "take", "b": [0.306, 0.4354, 0.3377, 0.455]}, {"w": "advantage", "b": [0.3455, 0.4354, 0.4223, 0.455]}, {"w": "of", "b": [0.4301, 0.4354, 0.4454, 0.455]}, {"w": "these", "b": [0.4532, 0.4354, 0.4923, 0.455]}, {"w": "technologies", "b": [0.5001, 0.4354, 0.596, 0.455]}, {"w": "long", "b": [0.6038, 0.4354, 0.6376, 0.455]}, {"w": "before", "b": [0.6454, 0.4354, 0.6937, 0.455]}, {"w": "the", "b": [0.7014, 0.4354, 0.7255, 0.455]}, {"w": "official", "b": [0.7333, 0.4354, 0.7857, 0.455]}, {"w": "release", "b": [0.2714, 0.4528, 0.3229, 0.4724]}, {"w": "of", "b": [0.3284, 0.4528, 0.3437, 0.4724]}, {"w": "these", "b": [0.3492, 0.4528, 0.3884, 0.4724]}, {"w": "titles.", "b": [0.3938, 0.4528, 0.4348, 0.4724]}, {"w": "The", "b": [0.4403, 0.4528, 0.4703, 0.4724]}, {"w": "following", "b": [0.4757, 0.4528, 0.5479, 0.4724]}, {"w": "will", "b": [0.5534, 0.4528, 0.5812, 0.4724]}, {"w": "be", "b": [0.5866, 0.4528, 0.6044, 0.4724]}, {"w": "Chapter", "b": [0.6099, 0.4528, 0.6716, 0.4724]}, {"w": "14", "b": [0.6771, 0.4528, 0.6954, 0.4724]}, {"w": "in", "b": [0.7009, 0.4528, 0.7164, 0.4724]}, {"w": "the", "b": [0.7218, 0.4528, 0.7459, 0.4724]}, {"w": "final", "b": [0.7514, 0.4528, 0.7857, 0.4724]}, {"w": "release", "b": [0.2714, 0.4702, 0.3229, 0.4898]}, {"w": "of", "b": [0.3273, 0.4702, 0.3426, 0.4898]}, {"w": "the", "b": [0.3469, 0.4702, 0.371, 0.4898]}, {"w": "book.", "b": [0.3753, 0.4702, 0.4182, 0.4898]}]}, {"id": "b_3", "type": "paragraph", "text": "Although IBM’s Deep Blue supercomputer beat the chess world champion Garry Kas‐ parov back in 1996, it wasn’t until fairly recently that computers were able to reliably perform seemingly trivial tasks such as detecting a puppy in a picture or recognizing spoken words. Why are these tasks so effortless to us humans? The answer lies in the fact that perception largely takes place outside the realm of our consciousness, within specialized visual, auditory, and other sensory modules in our brains. By the time sensory information reaches our consciousness, it is already adorned with high-level features; for example, when you look at a picture of a cute puppy, you cannot choose not to see the puppy, or not to notice its cuteness. Nor can you explain how you rec‐ ognize a cute puppy; it’s just obvious to you. Thus, we cannot trust our subjective experience: perception is not trivial at all, and to understand it we must look at how the sensory modules work.", "words": [{"w": "Although", "b": [0.1429, 0.5101, 0.2226, 0.5315]}, {"w": "IBM’s", "b": [0.2273, 0.5101, 0.2751, 0.5315]}, {"w": "Deep", "b": [0.2799, 0.5101, 0.3238, 0.5315]}, {"w": "Blue", "b": [0.3285, 0.5101, 0.366, 0.5315]}, {"w": "supercomputer", "b": [0.3707, 0.5101, 0.4979, 0.5315]}, {"w": "beat", "b": [0.5026, 0.5101, 0.5372, 0.5315]}, {"w": "the", "b": [0.5419, 0.5101, 0.5682, 0.5315]}, {"w": "chess", "b": [0.573, 0.5101, 0.6171, 0.5315]}, {"w": "world", "b": [0.6218, 0.5101, 0.6707, 0.5315]}, {"w": "champion", "b": [0.6754, 0.5101, 0.7597, 0.5315]}, {"w": "Garry", "b": [0.7644, 0.5101, 0.8141, 0.5315]}, {"w": "Kas‐", "b": [0.8188, 0.5101, 0.857, 0.5315]}, {"w": "parov", "b": [0.1429, 0.5291, 0.1909, 0.5506]}, {"w": "back", "b": [0.1966, 0.5291, 0.2355, 0.5506]}, {"w": "in", "b": [0.2412, 0.5291, 0.2582, 0.5506]}, {"w": "1996,", "b": [0.2638, 0.5291, 0.3086, 0.5506]}, {"w": "it", "b": [0.3143, 0.5291, 0.3262, 0.5506]}, {"w": "wasn’t", "b": [0.3319, 0.5291, 0.383, 0.5506]}, {"w": "until", "b": [0.3886, 0.5291, 0.4279, 0.5506]}, {"w": "fairly", "b": [0.4336, 0.5291, 0.4771, 0.5506]}, {"w": "recently", "b": [0.4828, 0.5291, 0.5492, 0.5506]}, {"w": "that", "b": [0.5549, 0.5291, 0.5875, 0.5506]}, {"w": "computers", "b": [0.5932, 0.5291, 0.6818, 0.5506]}, {"w": "were", "b": [0.6875, 0.5291, 0.7272, 0.5506]}, {"w": "able", "b": [0.7329, 0.5291, 0.7668, 0.5506]}, {"w": "to", "b": [0.7725, 0.5291, 0.7894, 0.5506]}, {"w": "reliably", "b": [0.7951, 0.5291, 0.8571, 0.5506]}, {"w": "perform", "b": [0.1428, 0.5482, 0.2119, 0.5696]}, {"w": "seemingly", "b": [0.2176, 0.5482, 0.3016, 0.5696]}, {"w": "trivial", "b": [0.3073, 0.5482, 0.3566, 0.5696]}, {"w": "tasks", "b": [0.3623, 0.5482, 0.4034, 0.5696]}, {"w": "such", "b": [0.4091, 0.5482, 0.4477, 0.5696]}, {"w": "as", "b": [0.4534, 0.5482, 0.4702, 0.5696]}, {"w": "detecting", "b": [0.4759, 0.5482, 0.5528, 0.5696]}, {"w": "a", "b": [0.5585, 0.5482, 0.5677, 0.5696]}, {"w": "puppy", "b": [0.5733, 0.5482, 0.6267, 0.5696]}, {"w": "in", "b": [0.6324, 0.5482, 0.6494, 0.5696]}, {"w": "a", "b": [0.655, 0.5482, 0.6642, 0.5696]}, {"w": "picture", "b": [0.6699, 0.5482, 0.7292, 0.5696]}, {"w": "or", "b": [0.7349, 0.5482, 0.7532, 0.5696]}, {"w": "recognizing", "b": [0.7589, 0.5482, 0.8571, 0.5696]}, {"w": "spoken", "b": [0.1429, 0.5672, 0.2026, 0.5886]}, {"w": "words.", "b": [0.2081, 0.5672, 0.2641, 0.5886]}, {"w": "Why", "b": [0.2695, 0.5672, 0.31, 0.5886]}, {"w": "are", "b": [0.3154, 0.5672, 0.3411, 0.5886]}, {"w": "these", "b": [0.3466, 0.5672, 0.3894, 0.5886]}, {"w": "tasks", "b": [0.3949, 0.5672, 0.436, 0.5886]}, {"w": "so", "b": [0.4414, 0.5672, 0.4597, 0.5886]}, {"w": "effortless", "b": [0.4651, 0.5672, 0.5404, 0.5886]}, {"w": "to", "b": [0.5459, 0.5672, 0.5629, 0.5886]}, {"w": "us", "b": [0.5683, 0.5672, 0.587, 0.5886]}, {"w": "humans?", "b": [0.5925, 0.5672, 0.6674, 0.5886]}, {"w": "The", "b": [0.6728, 0.5672, 0.7057, 0.5886]}, {"w": "answer", "b": [0.7111, 0.5672, 0.7702, 0.5886]}, {"w": "lies", "b": [0.7756, 0.5672, 0.803, 0.5886]}, {"w": "in", "b": [0.8084, 0.5672, 0.8254, 0.5886]}, {"w": "the", "b": [0.8308, 0.5672, 0.8571, 0.5886]}, {"w": "fact", "b": [0.1429, 0.5863, 0.1733, 0.6077]}, {"w": "that", "b": [0.1785, 0.5863, 0.2111, 0.6077]}, {"w": "perception", "b": [0.2162, 0.5863, 0.3062, 0.6077]}, {"w": "largely", "b": [0.3114, 0.5863, 0.367, 0.6077]}, {"w": "takes", "b": [0.3721, 0.5863, 0.4144, 0.6077]}, {"w": "place", "b": [0.4196, 0.5863, 0.4626, 0.6077]}, {"w": "outside", "b": [0.4677, 0.5863, 0.5289, 0.6077]}, {"w": "the", "b": [0.534, 0.5863, 0.5603, 0.6077]}, {"w": "realm", "b": [0.5655, 0.5863, 0.6135, 0.6077]}, {"w": "of", "b": [0.6187, 0.5863, 0.6355, 0.6077]}, {"w": "our", "b": [0.6406, 0.5863, 0.67, 0.6077]}, {"w": "consciousness,", "b": [0.6752, 0.5863, 0.7977, 0.6077]}, {"w": "within", "b": [0.8028, 0.5863, 0.8571, 0.6077]}, {"w": "specialized", "b": [0.1428, 0.6053, 0.2333, 0.6267]}, {"w": "visual,", "b": [0.2412, 0.6053, 0.2943, 0.6267]}, {"w": "auditory,", "b": [0.3022, 0.6053, 0.3767, 0.6267]}, {"w": "and", "b": [0.3847, 0.6053, 0.4162, 0.6267]}, {"w": "other", "b": [0.4242, 0.6053, 0.4688, 0.6267]}, {"w": "sensory", "b": [0.4768, 0.6053, 0.5408, 0.6267]}, {"w": "modules", "b": [0.5488, 0.6053, 0.6203, 0.6267]}, {"w": "in", "b": [0.6282, 0.6053, 0.6452, 0.6267]}, {"w": "our", "b": [0.6531, 0.6053, 0.6826, 0.6267]}, {"w": "brains.", "b": [0.6905, 0.6053, 0.7473, 0.6267]}, {"w": "By", "b": [0.7553, 0.6053, 0.7771, 0.6267]}, {"w": "the", "b": [0.785, 0.6053, 0.8113, 0.6267]}, {"w": "time", "b": [0.8193, 0.6053, 0.8571, 0.6267]}, {"w": "sensory", "b": [0.1429, 0.6244, 0.2069, 0.6458]}, {"w": "information", "b": [0.2128, 0.6244, 0.3141, 0.6458]}, {"w": "reaches", "b": [0.32, 0.6244, 0.3822, 0.6458]}, {"w": "our", "b": [0.3881, 0.6244, 0.4175, 0.6458]}, {"w": "consciousness,", "b": [0.4234, 0.6244, 0.5459, 0.6458]}, {"w": "it", "b": [0.5518, 0.6244, 0.5637, 0.6458]}, {"w": "is", "b": [0.5696, 0.6244, 0.5829, 0.6458]}, {"w": "already", "b": [0.5888, 0.6244, 0.6495, 0.6458]}, {"w": "adorned", "b": [0.6554, 0.6244, 0.7251, 0.6458]}, {"w": "with", "b": [0.731, 0.6244, 0.7684, 0.6458]}, {"w": "high-level", "b": [0.7743, 0.6244, 0.8571, 0.6458]}, {"w": "features;", "b": [0.1429, 0.6434, 0.213, 0.6648]}, {"w": "for", "b": [0.2186, 0.6434, 0.2431, 0.6648]}, {"w": "example,", "b": [0.2487, 0.6434, 0.323, 0.6648]}, {"w": "when", "b": [0.3286, 0.6434, 0.3742, 0.6648]}, {"w": "you", "b": [0.3798, 0.6434, 0.4111, 0.6648]}, {"w": "look", "b": [0.4166, 0.6434, 0.4535, 0.6648]}, {"w": "at", "b": [0.4591, 0.6434, 0.4742, 0.6648]}, {"w": "a", "b": [0.4798, 0.6434, 0.4889, 0.6648]}, {"w": "picture", "b": [0.4945, 0.6434, 0.5538, 0.6648]}, {"w": "of", "b": [0.5594, 0.6434, 0.5762, 0.6648]}, {"w": "a", "b": [0.5817, 0.6434, 0.5909, 0.6648]}, {"w": "cute", "b": [0.5965, 0.6434, 0.6316, 0.6648]}, {"w": "puppy,", "b": [0.6371, 0.6434, 0.6937, 0.6648]}, {"w": "you", "b": [0.6993, 0.6434, 0.7306, 0.6648]}, {"w": "cannot", "b": [0.7361, 0.6434, 0.7939, 0.6648]}, {"w": "choose", "b": [0.7995, 0.6434, 0.8571, 0.6648]}, {"w": "not", "b": [0.1429, 0.6623, 0.1697, 0.6839]}, {"w": "to", "b": [0.1756, 0.6625, 0.1926, 0.6839]}, {"w": "see", "b": [0.1985, 0.6625, 0.2239, 0.6839]}, {"w": "the", "b": [0.2298, 0.6625, 0.2561, 0.6839]}, {"w": "puppy,", "b": [0.262, 0.6625, 0.3186, 0.6839]}, {"w": "or", "b": [0.3245, 0.6625, 0.3429, 0.6839]}, {"w": "not", "b": [0.3488, 0.6623, 0.3757, 0.6839]}, {"w": "to", "b": [0.3816, 0.6625, 0.3985, 0.6839]}, {"w": "notice", "b": [0.4044, 0.6625, 0.4561, 0.6839]}, {"w": "its", "b": [0.462, 0.6625, 0.4816, 0.6839]}, {"w": "cuteness.", "b": [0.4875, 0.6625, 0.5628, 0.6839]}, {"w": "Nor", "b": [0.5687, 0.6625, 0.6021, 0.6839]}, {"w": "can", "b": [0.608, 0.6625, 0.6373, 0.6839]}, {"w": "you", "b": [0.6432, 0.6625, 0.6745, 0.6839]}, {"w": "explain", "b": [0.6804, 0.6625, 0.7414, 0.6839]}, {"w": "how", "b": [0.7473, 0.6623, 0.7813, 0.6839]}, {"w": "you", "b": [0.7872, 0.6625, 0.8184, 0.6839]}, {"w": "rec‐", "b": [0.8243, 0.6625, 0.8571, 0.6839]}, {"w": "ognize", "b": [0.1428, 0.6815, 0.1978, 0.7029]}, {"w": "a", "b": [0.2054, 0.6815, 0.2145, 0.7029]}, {"w": "cute", "b": [0.2221, 0.6815, 0.2572, 0.7029]}, {"w": "puppy;", "b": [0.2648, 0.6815, 0.3236, 0.7029]}, {"w": "it’s", "b": [0.3312, 0.6815, 0.3529, 0.7029]}, {"w": "just", "b": [0.3605, 0.6815, 0.3909, 0.7029]}, {"w": "obvious", "b": [0.3984, 0.6815, 0.4642, 0.7029]}, {"w": "to", "b": [0.4718, 0.6815, 0.4888, 0.7029]}, {"w": "you.", "b": [0.4964, 0.6815, 0.5324, 0.7029]}, {"w": "Thus,", "b": [0.54, 0.6815, 0.587, 0.7029]}, {"w": "we", "b": [0.5946, 0.6815, 0.6177, 0.7029]}, {"w": "cannot", "b": [0.6253, 0.6815, 0.6831, 0.7029]}, {"w": "trust", "b": [0.6907, 0.6815, 0.7298, 0.7029]}, {"w": "our", "b": [0.7374, 0.6815, 0.7668, 0.7029]}, {"w": "subjective", "b": [0.7744, 0.6815, 0.8571, 0.7029]}, {"w": "experience:", "b": [0.1429, 0.7006, 0.2373, 0.722]}, {"w": "perception", "b": [0.2433, 0.7006, 0.3334, 0.722]}, {"w": "is", "b": [0.3394, 0.7006, 0.3526, 0.722]}, {"w": "not", "b": [0.3587, 0.7006, 0.387, 0.722]}, {"w": "trivial", "b": [0.3931, 0.7006, 0.4424, 0.722]}, {"w": "at", "b": [0.4484, 0.7006, 0.4635, 0.722]}, {"w": "all,", "b": [0.4695, 0.7006, 0.494, 0.722]}, {"w": "and", "b": [0.5, 0.7006, 0.5316, 0.722]}, {"w": "to", "b": [0.5376, 0.7006, 0.5546, 0.722]}, {"w": "understand", "b": [0.5606, 0.7006, 0.6562, 0.722]}, {"w": "it", "b": [0.6622, 0.7006, 0.6742, 0.722]}, {"w": "we", "b": [0.6802, 0.7006, 0.7033, 0.722]}, {"w": "must", "b": [0.7093, 0.7006, 0.7511, 0.722]}, {"w": "look", "b": [0.7571, 0.7006, 0.794, 0.722]}, {"w": "at", "b": [0.8, 0.7006, 0.8151, 0.722]}, {"w": "how", "b": [0.8211, 0.7006, 0.8571, 0.722]}, {"w": "the", "b": [0.1429, 0.7196, 0.1692, 0.741]}, {"w": "sensory", "b": [0.1739, 0.7196, 0.238, 0.741]}, {"w": "modules", "b": [0.2427, 0.7196, 0.3142, 0.741]}, {"w": "work.", "b": [0.319, 0.7196, 0.3667, 0.741]}]}, {"id": "b_4", "type": "paragraph", "text": "Convolutional neural networks (CNNs) emerged from the study of the brain’s visual cortex, and they have been used in image recognition since the 1980s. In the last few years, thanks to the increase in computational power, the amount of available training data, and the tricks presented in Chapter 11 for training deep nets, CNNs have man‐ aged to achieve superhuman performance on some complex visual tasks. They power image search services, self-driving cars, automatic video classification systems, and more. Moreover, CNNs are not restricted to visual perception: they are also successful", "words": [{"w": "Convolutional", "b": [0.1429, 0.7477, 0.2632, 0.7691]}, {"w": "neural", "b": [0.2693, 0.7477, 0.3228, 0.7691]}, {"w": "networks", "b": [0.3288, 0.7477, 0.406, 0.7691]}, {"w": "(CNNs)", "b": [0.4121, 0.7477, 0.4784, 0.7691]}, {"w": "emerged", "b": [0.4845, 0.7477, 0.5566, 0.7691]}, {"w": "from", "b": [0.5627, 0.7477, 0.6042, 0.7691]}, {"w": "the", "b": [0.6103, 0.7477, 0.6366, 0.7691]}, {"w": "study", "b": [0.6427, 0.7477, 0.6883, 0.7691]}, {"w": "of", "b": [0.6944, 0.7477, 0.7112, 0.7691]}, {"w": "the", "b": [0.7173, 0.7477, 0.7436, 0.7691]}, {"w": "brain’s", "b": [0.7497, 0.7477, 0.8027, 0.7691]}, {"w": "visual", "b": [0.8088, 0.7477, 0.8571, 0.7691]}, {"w": "cortex,", "b": [0.1428, 0.7668, 0.1998, 0.7882]}, {"w": "and", "b": [0.2055, 0.7668, 0.2371, 0.7882]}, {"w": "they", "b": [0.2428, 0.7668, 0.2787, 0.7882]}, {"w": "have", "b": [0.2844, 0.7668, 0.3228, 0.7882]}, {"w": "been", "b": [0.3285, 0.7668, 0.3682, 0.7882]}, {"w": "used", "b": [0.3739, 0.7668, 0.4124, 0.7882]}, {"w": "in", "b": [0.4181, 0.7668, 0.4351, 0.7882]}, {"w": "image", "b": [0.4408, 0.7668, 0.4912, 0.7882]}, {"w": "recognition", "b": [0.4969, 0.7668, 0.5936, 0.7882]}, {"w": "since", "b": [0.5993, 0.7668, 0.6416, 0.7882]}, {"w": "the", "b": [0.6473, 0.7668, 0.6737, 0.7882]}, {"w": "1980s.", "b": [0.6794, 0.7668, 0.7318, 0.7882]}, {"w": "In", "b": [0.7375, 0.7668, 0.756, 0.7882]}, {"w": "the", "b": [0.7617, 0.7668, 0.788, 0.7882]}, {"w": "last", "b": [0.7937, 0.7668, 0.8221, 0.7882]}, {"w": "few", "b": [0.8278, 0.7668, 0.8571, 0.7882]}, {"w": "years,", "b": [0.1429, 0.7858, 0.1906, 0.8072]}, {"w": "thanks", "b": [0.1953, 0.7858, 0.2513, 0.8072]}, {"w": "to", "b": [0.256, 0.7858, 0.273, 0.8072]}, {"w": "the", "b": [0.2777, 0.7858, 0.3041, 0.8072]}, {"w": "increase", "b": [0.3088, 0.7858, 0.3768, 0.8072]}, {"w": "in", "b": [0.3815, 0.7858, 0.3985, 0.8072]}, {"w": "computational", "b": [0.4032, 0.7858, 0.5248, 0.8072]}, {"w": "power,", "b": [0.5295, 0.7858, 0.5854, 0.8072]}, {"w": "the", "b": [0.5901, 0.7858, 0.6164, 0.8072]}, {"w": "amount", "b": [0.6212, 0.7858, 0.6864, 0.8072]}, {"w": "of", "b": [0.6911, 0.7858, 0.7079, 0.8072]}, {"w": "available", "b": [0.7127, 0.7858, 0.7849, 0.8072]}, {"w": "training", "b": [0.7897, 0.7858, 0.8566, 0.8072]}, {"w": "data,", "b": [0.1429, 0.8049, 0.1829, 0.8263]}, {"w": "and", "b": [0.1885, 0.8049, 0.22, 0.8263]}, {"w": "the", "b": [0.2257, 0.8049, 0.252, 0.8263]}, {"w": "tricks", "b": [0.2576, 0.8049, 0.3041, 0.8263]}, {"w": "presented", "b": [0.3097, 0.8049, 0.3909, 0.8263]}, {"w": "in", "b": [0.3965, 0.8049, 0.4135, 0.8263]}, {"w": "Chapter", "b": [0.4191, 0.8049, 0.4867, 0.8263]}, {"w": "11", "b": [0.4924, 0.8049, 0.5124, 0.8263]}, {"w": "for", "b": [0.518, 0.8049, 0.5425, 0.8263]}, {"w": "training", "b": [0.5481, 0.8049, 0.6151, 0.8263]}, {"w": "deep", "b": [0.6207, 0.8049, 0.6603, 0.8263]}, {"w": "nets,", "b": [0.666, 0.8049, 0.705, 0.8263]}, {"w": "CNNs", "b": [0.7106, 0.8049, 0.7625, 0.8263]}, {"w": "have", "b": [0.7681, 0.8049, 0.8065, 0.8263]}, {"w": "man‐", "b": [0.8121, 0.8049, 0.8571, 0.8263]}, {"w": "aged", "b": [0.1429, 0.8239, 0.1816, 0.8453]}, {"w": "to", "b": [0.1868, 0.8239, 0.2038, 0.8453]}, {"w": "achieve", "b": [0.209, 0.8239, 0.2711, 0.8453]}, {"w": "superhuman", "b": [0.2763, 0.8239, 0.3819, 0.8453]}, {"w": "performance", "b": [0.3871, 0.8239, 0.4944, 0.8453]}, {"w": "on", "b": [0.4996, 0.8239, 0.5216, 0.8453]}, {"w": "some", "b": [0.5269, 0.8239, 0.571, 0.8453]}, {"w": "complex", "b": [0.5763, 0.8239, 0.6472, 0.8453]}, {"w": "visual", "b": [0.6525, 0.8239, 0.7008, 0.8453]}, {"w": "tasks.", "b": [0.706, 0.8239, 0.7519, 0.8453]}, {"w": "They", "b": [0.7571, 0.8239, 0.7995, 0.8453]}, {"w": "power", "b": [0.8047, 0.8239, 0.8571, 0.8453]}, {"w": "image", "b": [0.1429, 0.843, 0.1932, 0.8644]}, {"w": "search", "b": [0.2009, 0.843, 0.2542, 0.8644]}, {"w": "services,", "b": [0.2619, 0.843, 0.332, 0.8644]}, {"w": "self-driving", "b": [0.3396, 0.843, 0.4357, 0.8644]}, {"w": "cars,", "b": [0.4433, 0.843, 0.4814, 0.8644]}, {"w": "automatic", "b": [0.489, 0.843, 0.5724, 0.8644]}, {"w": "video", "b": [0.58, 0.843, 0.6258, 0.8644]}, {"w": "classification", "b": [0.6334, 0.843, 0.7408, 0.8644]}, {"w": "systems,", "b": [0.7484, 0.843, 0.8179, 0.8644]}, {"w": "and", "b": [0.8256, 0.843, 0.8571, 0.8644]}, {"w": "more.", "b": [0.1428, 0.862, 0.1919, 0.8834]}, {"w": "Moreover,", "b": [0.1966, 0.862, 0.2821, 0.8834]}, {"w": "CNNs", "b": [0.2868, 0.862, 0.3387, 0.8834]}, {"w": "are", "b": [0.3435, 0.862, 0.3692, 0.8834]}, {"w": "not", "b": [0.3739, 0.862, 0.4023, 0.8834]}, {"w": "restricted", "b": [0.407, 0.862, 0.486, 0.8834]}, {"w": "to", "b": [0.4907, 0.862, 0.5077, 0.8834]}, {"w": "visual", "b": [0.5124, 0.862, 0.5607, 0.8834]}, {"w": "perception:", "b": [0.5655, 0.862, 0.6603, 0.8834]}, {"w": "they", "b": [0.665, 0.862, 0.7009, 0.8834]}, {"w": "are", "b": [0.7056, 0.862, 0.7313, 0.8834]}, {"w": "also", "b": [0.7361, 0.862, 0.7688, 0.8834]}, {"w": "successful", "b": [0.7735, 0.862, 0.8565, 0.8834]}]}, {"id": "b_5", "type": "paragraph", "text": "431", "words": [{"w": "431", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 458, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "1 “Single Unit Activity in Striate Cortex of Unrestrained Cats,” D. Hubel and T. Wiesel (1958).", "words": [{"w": "1", "b": [0.1451, 0.8371, 0.1518, 0.8514]}, {"w": "“Single", "b": [0.1587, 0.8356, 0.2033, 0.8519]}, {"w": "Unit", "b": [0.2069, 0.8356, 0.2357, 0.8519]}, {"w": "Activity", "b": [0.2393, 0.8356, 0.2893, 0.8519]}, {"w": "in", "b": [0.293, 0.8356, 0.3059, 0.8519]}, {"w": "Striate", "b": [0.3095, 0.8356, 0.3503, 0.8519]}, {"w": "Cortex", "b": [0.3539, 0.8356, 0.3975, 0.8519]}, {"w": "of", "b": [0.4011, 0.8356, 0.4139, 0.8519]}, {"w": "Unrestrained", "b": [0.4175, 0.8356, 0.5014, 0.8519]}, {"w": "Cats,”", "b": [0.505, 0.8356, 0.5407, 0.8519]}, {"w": "D.", "b": [0.5443, 0.8356, 0.5589, 0.8519]}, {"w": "Hubel", "b": [0.5625, 0.8356, 0.6013, 0.8519]}, {"w": "and", "b": [0.6049, 0.8356, 0.629, 0.8519]}, {"w": "T.", "b": [0.6326, 0.8356, 0.6444, 0.8519]}, {"w": "Wiesel", "b": [0.648, 0.8356, 0.6903, 0.8519]}, {"w": "(1958).", "b": [0.694, 0.8356, 0.739, 0.8519]}]}, {"id": "b_1", "type": "paragraph", "text": "2 “Receptive Fields of Single Neurones in the Cat’s Striate Cortex,” D. Hubel and T. Wiesel (1959).", "words": [{"w": "2", "b": [0.1451, 0.8568, 0.1518, 0.871]}, {"w": "“Receptive", "b": [0.1587, 0.8553, 0.2266, 0.8716]}, {"w": "Fields", "b": [0.2302, 0.8553, 0.2678, 0.8716]}, {"w": "of", "b": [0.2714, 0.8553, 0.2842, 0.8716]}, {"w": "Single", "b": [0.2878, 0.8553, 0.3265, 0.8716]}, {"w": "Neurones", "b": [0.3301, 0.8553, 0.3919, 0.8716]}, {"w": "in", "b": [0.3955, 0.8553, 0.4084, 0.8716]}, {"w": "the", "b": [0.412, 0.8553, 0.4321, 0.8716]}, {"w": "Cat’s", "b": [0.4357, 0.8553, 0.4652, 0.8716]}, {"w": "Striate", "b": [0.4688, 0.8553, 0.5096, 0.8716]}, {"w": "Cortex,”", "b": [0.5132, 0.8553, 0.5646, 0.8716]}, {"w": "D.", "b": [0.5682, 0.8553, 0.5828, 0.8716]}, {"w": "Hubel", "b": [0.5864, 0.8553, 0.6252, 0.8716]}, {"w": "and", "b": [0.6288, 0.8553, 0.6529, 0.8716]}, {"w": "T.", "b": [0.6565, 0.8553, 0.6683, 0.8716]}, {"w": "Wiesel", "b": [0.6719, 0.8553, 0.7143, 0.8716]}, {"w": "(1959).", "b": [0.7179, 0.8553, 0.763, 0.8716]}]}, {"id": "b_2", "type": "paragraph", "text": "3 “Receptive Fields and Functional Architecture of Monkey Striate Cortex,” D. Hubel and T. Wiesel (1968).", "words": [{"w": "3", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Receptive", "b": [0.1587, 0.8749, 0.2266, 0.8912]}, {"w": "Fields", "b": [0.2302, 0.8749, 0.2678, 0.8912]}, {"w": "and", "b": [0.2714, 0.8749, 0.2955, 0.8912]}, {"w": "Functional", "b": [0.2991, 0.8749, 0.3678, 0.8912]}, {"w": "Architecture", "b": [0.3714, 0.8749, 0.452, 0.8912]}, {"w": "of", "b": [0.4556, 0.8749, 0.4683, 0.8912]}, {"w": "Monkey", "b": [0.472, 0.8749, 0.5244, 0.8912]}, {"w": "Striate", "b": [0.528, 0.8749, 0.5687, 0.8912]}, {"w": "Cortex,”", "b": [0.5723, 0.8749, 0.6237, 0.8912]}, {"w": "D.", "b": [0.6273, 0.8749, 0.642, 0.8912]}, {"w": "Hubel", "b": [0.6456, 0.8749, 0.6844, 0.8912]}, {"w": "and", "b": [0.688, 0.8749, 0.712, 0.8912]}, {"w": "T.", "b": [0.7156, 0.8749, 0.7275, 0.8912]}, {"w": "Wiesel", "b": [0.7311, 0.8749, 0.7734, 0.8912]}, {"w": "(1968).", "b": [0.777, 0.8749, 0.8221, 0.8912]}]}, {"id": "b_3", "type": "paragraph", "text": "at many other tasks, such as voice recognition or natural language processing (NLP); however, we will focus on visual applications for now.", "words": [{"w": "at", "b": [0.1429, 0.0791, 0.158, 0.1005]}, {"w": "many", "b": [0.1651, 0.0791, 0.2117, 0.1005]}, {"w": "other", "b": [0.2188, 0.0791, 0.2635, 0.1005]}, {"w": "tasks,", "b": [0.2706, 0.0791, 0.3165, 0.1005]}, {"w": "such", "b": [0.3236, 0.0791, 0.3622, 0.1005]}, {"w": "as", "b": [0.3693, 0.0791, 0.3861, 0.1005]}, {"w": "voice", "b": [0.3932, 0.0789, 0.4338, 0.1005]}, {"w": "recognition", "b": [0.4409, 0.0789, 0.5314, 0.1005]}, {"w": "or", "b": [0.5385, 0.0791, 0.5569, 0.1005]}, {"w": "natural", "b": [0.564, 0.0789, 0.6241, 0.1005]}, {"w": "language", "b": [0.6312, 0.0789, 0.7039, 0.1005]}, {"w": "processing", "b": [0.711, 0.0789, 0.7925, 0.1005]}, {"w": "(NLP);", "b": [0.7996, 0.0791, 0.8571, 0.1005]}, {"w": "however,", "b": [0.1429, 0.0981, 0.2174, 0.1195]}, {"w": "we", "b": [0.2221, 0.0981, 0.2453, 0.1195]}, {"w": "will", "b": [0.25, 0.0981, 0.2804, 0.1195]}, {"w": "focus", "b": [0.2851, 0.0981, 0.3294, 0.1195]}, {"w": "on", "b": [0.3341, 0.0981, 0.3562, 0.1195]}, {"w": "visual", "b": [0.3609, 0.0981, 0.4093, 0.1195]}, {"w": "applications", "b": [0.414, 0.0981, 0.5146, 0.1195]}, {"w": "for", "b": [0.5193, 0.0981, 0.5438, 0.1195]}, {"w": "now.", "b": [0.5486, 0.0981, 0.5881, 0.1195]}]}, {"id": "b_4", "type": "paragraph", "text": "In this chapter we will present where CNNs came from, what their building blocks look like, and how to implement them using TensorFlow and Keras. Then we will dis‐ cuss some of the best CNN architectures, and discuss other visual tasks, including object detection (classifying multiple objects in an image and placing bounding boxes around them) and semantic segmentation (classifying each pixel according to the class of the object it belongs to).", "words": [{"w": "In", "b": [0.1429, 0.1262, 0.1614, 0.1476]}, {"w": "this", "b": [0.1684, 0.1262, 0.1991, 0.1476]}, {"w": "chapter", "b": [0.2061, 0.1262, 0.2686, 0.1476]}, {"w": "we", "b": [0.2756, 0.1262, 0.2987, 0.1476]}, {"w": "will", "b": [0.3058, 0.1262, 0.3361, 0.1476]}, {"w": "present", "b": [0.3432, 0.1262, 0.4045, 0.1476]}, {"w": "where", "b": [0.4115, 0.1262, 0.4623, 0.1476]}, {"w": "CNNs", "b": [0.4694, 0.1262, 0.5213, 0.1476]}, {"w": "came", "b": [0.5283, 0.1262, 0.5721, 0.1476]}, {"w": "from,", "b": [0.5791, 0.1262, 0.6255, 0.1476]}, {"w": "what", "b": [0.6325, 0.1262, 0.673, 0.1476]}, {"w": "their", "b": [0.68, 0.1262, 0.7196, 0.1476]}, {"w": "building", "b": [0.7266, 0.1262, 0.7969, 0.1476]}, {"w": "blocks", "b": [0.8039, 0.1262, 0.8571, 0.1476]}, {"w": "look", "b": [0.1428, 0.1453, 0.1797, 0.1667]}, {"w": "like,", "b": [0.1846, 0.1453, 0.2193, 0.1667]}, {"w": "and", "b": [0.2242, 0.1453, 0.2557, 0.1667]}, {"w": "how", "b": [0.2606, 0.1453, 0.2966, 0.1667]}, {"w": "to", "b": [0.3014, 0.1453, 0.3184, 0.1667]}, {"w": "implement", "b": [0.3233, 0.1453, 0.4138, 0.1667]}, {"w": "them", "b": [0.4187, 0.1453, 0.4621, 0.1667]}, {"w": "using", "b": [0.4669, 0.1453, 0.5124, 0.1667]}, {"w": "TensorFlow", "b": [0.5172, 0.1453, 0.6155, 0.1667]}, {"w": "and", "b": [0.6203, 0.1453, 0.6519, 0.1667]}, {"w": "Keras.", "b": [0.6567, 0.1453, 0.7083, 0.1667]}, {"w": "Then", "b": [0.7132, 0.1453, 0.7574, 0.1667]}, {"w": "we", "b": [0.7623, 0.1453, 0.7854, 0.1667]}, {"w": "will", "b": [0.7902, 0.1453, 0.8206, 0.1667]}, {"w": "dis‐", "b": [0.8255, 0.1453, 0.8571, 0.1667]}, {"w": "cuss", "b": [0.1429, 0.1643, 0.178, 0.1857]}, {"w": "some", "b": [0.1856, 0.1643, 0.2298, 0.1857]}, {"w": "of", "b": [0.2374, 0.1643, 0.2542, 0.1857]}, {"w": "the", "b": [0.2618, 0.1643, 0.2881, 0.1857]}, {"w": "best", "b": [0.2957, 0.1643, 0.3291, 0.1857]}, {"w": "CNN", "b": [0.3367, 0.1643, 0.3815, 0.1857]}, {"w": "architectures,", "b": [0.3891, 0.1643, 0.5019, 0.1857]}, {"w": "and", "b": [0.5095, 0.1643, 0.5411, 0.1857]}, {"w": "discuss", "b": [0.5486, 0.1643, 0.608, 0.1857]}, {"w": "other", "b": [0.6156, 0.1643, 0.6603, 0.1857]}, {"w": "visual", "b": [0.6679, 0.1643, 0.7162, 0.1857]}, {"w": "tasks,", "b": [0.7238, 0.1643, 0.7697, 0.1857]}, {"w": "including", "b": [0.7773, 0.1643, 0.8571, 0.1857]}, {"w": "object", "b": [0.1429, 0.1832, 0.1905, 0.2048]}, {"w": "detection", "b": [0.1961, 0.1832, 0.2697, 0.2048]}, {"w": "(classifying", "b": [0.2753, 0.1834, 0.3694, 0.2048]}, {"w": "multiple", "b": [0.375, 0.1834, 0.445, 0.2048]}, {"w": "objects", "b": [0.4506, 0.1834, 0.5088, 0.2048]}, {"w": "in", "b": [0.5144, 0.1834, 0.5313, 0.2048]}, {"w": "an", "b": [0.5369, 0.1834, 0.5575, 0.2048]}, {"w": "image", "b": [0.5631, 0.1834, 0.6135, 0.2048]}, {"w": "and", "b": [0.619, 0.1834, 0.6506, 0.2048]}, {"w": "placing", "b": [0.6562, 0.1834, 0.717, 0.2048]}, {"w": "bounding", "b": [0.7226, 0.1834, 0.804, 0.2048]}, {"w": "boxes", "b": [0.8096, 0.1834, 0.8571, 0.2048]}, {"w": "around", "b": [0.1429, 0.2024, 0.2038, 0.2238]}, {"w": "them)", "b": [0.2085, 0.2024, 0.2591, 0.2238]}, {"w": "and", "b": [0.2639, 0.2024, 0.2954, 0.2238]}, {"w": "semantic", "b": [0.3008, 0.2022, 0.3727, 0.2238]}, {"w": "segmentation", "b": [0.3775, 0.2022, 0.4852, 0.2238]}, {"w": "(classifying", "b": [0.4903, 0.2024, 0.5845, 0.2238]}, {"w": "each", "b": [0.5894, 0.2024, 0.6273, 0.2238]}, {"w": "pixel", "b": [0.6323, 0.2024, 0.6727, 0.2238]}, {"w": "according", "b": [0.6777, 0.2024, 0.7605, 0.2238]}, {"w": "to", "b": [0.7654, 0.2024, 0.7824, 0.2238]}, {"w": "the", "b": [0.7874, 0.2024, 0.8137, 0.2238]}, {"w": "class", "b": [0.8186, 0.2024, 0.8571, 0.2238]}, {"w": "of", "b": [0.1428, 0.2215, 0.1596, 0.2429]}, {"w": "the", "b": [0.1644, 0.2215, 0.1907, 0.2429]}, {"w": "object", "b": [0.1954, 0.2215, 0.246, 0.2429]}, {"w": "it", "b": [0.2507, 0.2215, 0.2627, 0.2429]}, {"w": "belongs", "b": [0.2674, 0.2215, 0.3315, 0.2429]}, {"w": "to).", "b": [0.3362, 0.2215, 0.3652, 0.2429]}]}, {"id": "b_5", "type": "paragraph", "text": "The Architecture of the Visual Cortex", "words": [{"w": "The", "b": [0.1429, 0.2559, 0.1881, 0.2901]}, {"w": "Architecture", "b": [0.194, 0.2559, 0.3459, 0.2901]}, {"w": "of", "b": [0.3519, 0.2559, 0.377, 0.2901]}, {"w": "the", "b": [0.3829, 0.2559, 0.4248, 0.2901]}, {"w": "Visual", "b": [0.4307, 0.2559, 0.5052, 0.2901]}, {"w": "Cortex", "b": [0.5111, 0.2559, 0.5906, 0.2901]}]}, {"id": "b_6", "type": "paragraph", "text": "David H. Hubel and Torsten Wiesel performed a series of experiments on cats in 19581 and 19592 (and a few years later on monkeys3), giving crucial insights on the structure of the visual cortex (the authors received the Nobel Prize in Physiology or Medicine in 1981 for their work). In particular, they showed that many neurons in the visual cortex have a small local receptive field, meaning they react only to visual stimuli located in a limited region of the visual field (see Figure 14-1, in which the local receptive fields of five neurons are represented by dashed circles). The receptive fields of different neurons may overlap, and together they tile the whole visual field. Moreover, the authors showed that some neurons react only to images of horizontal lines, while others react only to lines with different orientations (two neurons may have the same receptive field but react to different line orientations). They also noticed that some neurons have larger receptive fields, and they react to more com‐ plex patterns that are combinations of the lower-level patterns. These observations led to the idea that the higher-level neurons are based on the outputs of neighboring lower-level neurons (in Figure 14-1, notice that each neuron is connected only to a few neurons from the previous layer). This powerful architecture is able to detect all sorts of complex patterns in any area of the visual field.", "words": [{"w": "David", "b": [0.1429, 0.2971, 0.1932, 0.3185]}, {"w": "H.", "b": [0.2014, 0.2971, 0.2221, 0.3185]}, {"w": "Hubel", "b": [0.2304, 0.2971, 0.2813, 0.3185]}, {"w": "and", "b": [0.2896, 0.2971, 0.3211, 0.3185]}, {"w": "Torsten", "b": [0.3294, 0.2971, 0.3928, 0.3185]}, {"w": "Wiesel", "b": [0.401, 0.2971, 0.4566, 0.3185]}, {"w": "performed", "b": [0.4649, 0.2971, 0.5538, 0.3185]}, {"w": "a", "b": [0.5621, 0.2971, 0.5712, 0.3185]}, {"w": "series", "b": [0.5795, 0.2971, 0.6258, 0.3185]}, {"w": "of", "b": [0.6341, 0.2971, 0.6509, 0.3185]}, {"w": "experiments", "b": [0.6591, 0.2971, 0.7618, 0.3185]}, {"w": "on", "b": [0.7701, 0.2971, 0.7921, 0.3185]}, {"w": "cats", "b": [0.8003, 0.2971, 0.8319, 0.3185]}, {"w": "in", "b": [0.8402, 0.2971, 0.8571, 0.3185]}, {"w": "19581", "b": [0.1429, 0.3161, 0.1886, 0.3375]}, {"w": "and", "b": [0.1956, 0.3161, 0.2271, 0.3375]}, {"w": "19592", "b": [0.2341, 0.3161, 0.2798, 0.3375]}, {"w": "(and", "b": [0.2868, 0.3161, 0.3256, 0.3375]}, {"w": "a", "b": [0.3325, 0.3161, 0.3417, 0.3375]}, {"w": "few", "b": [0.3487, 0.3161, 0.378, 0.3375]}, {"w": "years", "b": [0.385, 0.3161, 0.4279, 0.3375]}, {"w": "later", "b": [0.4349, 0.3161, 0.4719, 0.3375]}, {"w": "on", "b": [0.4788, 0.3161, 0.5009, 0.3375]}, {"w": "monkeys3),", "b": [0.5079, 0.3161, 0.601, 0.3375]}, {"w": "giving", "b": [0.608, 0.3161, 0.6597, 0.3375]}, {"w": "crucial", "b": [0.6667, 0.3161, 0.7231, 0.3375]}, {"w": "insights", "b": [0.7301, 0.3161, 0.7948, 0.3375]}, {"w": "on", "b": [0.8018, 0.3161, 0.8238, 0.3375]}, {"w": "the", "b": [0.8308, 0.3161, 0.8571, 0.3375]}, {"w": "structure", "b": [0.1428, 0.3351, 0.2185, 0.3566]}, {"w": "of", "b": [0.2248, 0.3351, 0.2416, 0.3566]}, {"w": "the", "b": [0.248, 0.3351, 0.2743, 0.3566]}, {"w": "visual", "b": [0.2807, 0.3351, 0.329, 0.3566]}, {"w": "cortex", "b": [0.3354, 0.3351, 0.3876, 0.3566]}, {"w": "(the", "b": [0.394, 0.3351, 0.4275, 0.3566]}, {"w": "authors", "b": [0.4339, 0.3351, 0.4972, 0.3566]}, {"w": "received", "b": [0.5035, 0.3351, 0.5729, 0.3566]}, {"w": "the", "b": [0.5792, 0.3351, 0.6055, 0.3566]}, {"w": "Nobel", "b": [0.6119, 0.3351, 0.6622, 0.3566]}, {"w": "Prize", "b": [0.6686, 0.3351, 0.7112, 0.3566]}, {"w": "in", "b": [0.7176, 0.3351, 0.7346, 0.3566]}, {"w": "Physiology", "b": [0.7409, 0.3351, 0.8324, 0.3566]}, {"w": "or", "b": [0.8388, 0.3351, 0.8571, 0.3566]}, {"w": "Medicine", "b": [0.1429, 0.3542, 0.221, 0.3756]}, {"w": "in", "b": [0.2281, 0.3542, 0.245, 0.3756]}, {"w": "1981", "b": [0.2521, 0.3542, 0.2921, 0.3756]}, {"w": "for", "b": [0.2992, 0.3542, 0.3237, 0.3756]}, {"w": "their", "b": [0.3308, 0.3542, 0.3704, 0.3756]}, {"w": "work).", "b": [0.3775, 0.3542, 0.4324, 0.3756]}, {"w": "In", "b": [0.4395, 0.3542, 0.458, 0.3756]}, {"w": "particular,", "b": [0.4651, 0.3542, 0.5503, 0.3756]}, {"w": "they", "b": [0.5574, 0.3542, 0.5933, 0.3756]}, {"w": "showed", "b": [0.6003, 0.3542, 0.6639, 0.3756]}, {"w": "that", "b": [0.6709, 0.3542, 0.7035, 0.3756]}, {"w": "many", "b": [0.7106, 0.3542, 0.7573, 0.3756]}, {"w": "neurons", "b": [0.7644, 0.3542, 0.8331, 0.3756]}, {"w": "in", "b": [0.8402, 0.3542, 0.8572, 0.3756]}, {"w": "the", "b": [0.1429, 0.3732, 0.1692, 0.3947]}, {"w": "visual", "b": [0.176, 0.3732, 0.2243, 0.3947]}, {"w": "cortex", "b": [0.2311, 0.3732, 0.2833, 0.3947]}, {"w": "have", "b": [0.2901, 0.3732, 0.3285, 0.3947]}, {"w": "a", "b": [0.3353, 0.3732, 0.3444, 0.3947]}, {"w": "small", "b": [0.3512, 0.3732, 0.3956, 0.3947]}, {"w": "local", "b": [0.4024, 0.373, 0.4402, 0.3947]}, {"w": "receptive", "b": [0.447, 0.373, 0.5175, 0.3947]}, {"w": "field,", "b": [0.5244, 0.373, 0.5643, 0.3947]}, {"w": "meaning", "b": [0.5711, 0.3732, 0.6442, 0.3947]}, {"w": "they", "b": [0.651, 0.3732, 0.6869, 0.3947]}, {"w": "react", "b": [0.6937, 0.3732, 0.7346, 0.3947]}, {"w": "only", "b": [0.7414, 0.3732, 0.7782, 0.3947]}, {"w": "to", "b": [0.785, 0.3732, 0.802, 0.3947]}, {"w": "visual", "b": [0.8088, 0.3732, 0.8571, 0.3947]}, {"w": "stimuli", "b": [0.1429, 0.3923, 0.201, 0.4137]}, {"w": "located", "b": [0.208, 0.3923, 0.2677, 0.4137]}, {"w": "in", "b": [0.2747, 0.3923, 0.2917, 0.4137]}, {"w": "a", "b": [0.2987, 0.3923, 0.3079, 0.4137]}, {"w": "limited", "b": [0.3149, 0.3923, 0.3746, 0.4137]}, {"w": "region", "b": [0.3816, 0.3923, 0.4356, 0.4137]}, {"w": "of", "b": [0.4426, 0.3923, 0.4594, 0.4137]}, {"w": "the", "b": [0.4664, 0.3923, 0.4928, 0.4137]}, {"w": "visual", "b": [0.4998, 0.3923, 0.5481, 0.4137]}, {"w": "field", "b": [0.5552, 0.3923, 0.592, 0.4137]}, {"w": "(see", "b": [0.5991, 0.3923, 0.6316, 0.4137]}, {"w": "Figure", "b": [0.6386, 0.3923, 0.6926, 0.4137]}, {"w": "14-1,", "b": [0.6997, 0.3923, 0.7418, 0.4137]}, {"w": "in", "b": [0.7489, 0.3923, 0.7658, 0.4137]}, {"w": "which", "b": [0.7729, 0.3923, 0.8238, 0.4137]}, {"w": "the", "b": [0.8308, 0.3923, 0.8571, 0.4137]}, {"w": "local", "b": [0.1429, 0.4113, 0.182, 0.4327]}, {"w": "receptive", "b": [0.1873, 0.4113, 0.2629, 0.4327]}, {"w": "fields", "b": [0.2682, 0.4113, 0.3127, 0.4327]}, {"w": "of", "b": [0.3181, 0.4113, 0.3348, 0.4327]}, {"w": "five", "b": [0.3402, 0.4113, 0.3704, 0.4327]}, {"w": "neurons", "b": [0.3757, 0.4113, 0.4444, 0.4327]}, {"w": "are", "b": [0.4497, 0.4113, 0.4755, 0.4327]}, {"w": "represented", "b": [0.4808, 0.4113, 0.5786, 0.4327]}, {"w": "by", "b": [0.5839, 0.4113, 0.604, 0.4327]}, {"w": "dashed", "b": [0.6093, 0.4113, 0.6681, 0.4327]}, {"w": "circles).", "b": [0.6734, 0.4113, 0.7381, 0.4327]}, {"w": "The", "b": [0.7434, 0.4113, 0.7762, 0.4327]}, {"w": "receptive", "b": [0.7815, 0.4113, 0.8572, 0.4327]}, {"w": "fields", "b": [0.1429, 0.4304, 0.1874, 0.4518]}, {"w": "of", "b": [0.1937, 0.4304, 0.2105, 0.4518]}, {"w": "different", "b": [0.2167, 0.4304, 0.2884, 0.4518]}, {"w": "neurons", "b": [0.2947, 0.4304, 0.3634, 0.4518]}, {"w": "may", "b": [0.3697, 0.4304, 0.4051, 0.4518]}, {"w": "overlap,", "b": [0.4114, 0.4304, 0.4773, 0.4518]}, {"w": "and", "b": [0.4836, 0.4304, 0.5151, 0.4518]}, {"w": "together", "b": [0.5214, 0.4304, 0.5911, 0.4518]}, {"w": "they", "b": [0.5973, 0.4304, 0.6332, 0.4518]}, {"w": "tile", "b": [0.6395, 0.4304, 0.6656, 0.4518]}, {"w": "the", "b": [0.6719, 0.4304, 0.6982, 0.4518]}, {"w": "whole", "b": [0.7045, 0.4304, 0.7546, 0.4518]}, {"w": "visual", "b": [0.7609, 0.4304, 0.8092, 0.4518]}, {"w": "field.", "b": [0.8155, 0.4304, 0.8571, 0.4518]}, {"w": "Moreover,", "b": [0.1429, 0.4494, 0.2284, 0.4708]}, {"w": "the", "b": [0.2346, 0.4494, 0.2609, 0.4708]}, {"w": "authors", "b": [0.2671, 0.4494, 0.3304, 0.4708]}, {"w": "showed", "b": [0.3366, 0.4494, 0.4001, 0.4708]}, {"w": "that", "b": [0.4063, 0.4494, 0.4389, 0.4708]}, {"w": "some", "b": [0.4451, 0.4494, 0.4893, 0.4708]}, {"w": "neurons", "b": [0.4955, 0.4494, 0.5642, 0.4708]}, {"w": "react", "b": [0.5704, 0.4494, 0.6113, 0.4708]}, {"w": "only", "b": [0.6175, 0.4494, 0.6543, 0.4708]}, {"w": "to", "b": [0.6605, 0.4494, 0.6775, 0.4708]}, {"w": "images", "b": [0.6837, 0.4494, 0.7417, 0.4708]}, {"w": "of", "b": [0.7479, 0.4494, 0.7647, 0.4708]}, {"w": "horizontal", "b": [0.7709, 0.4494, 0.8571, 0.4708]}, {"w": "lines,", "b": [0.1428, 0.4685, 0.1863, 0.4899]}, {"w": "while", "b": [0.1937, 0.4685, 0.2388, 0.4899]}, {"w": "others", "b": [0.2461, 0.4685, 0.2984, 0.4899]}, {"w": "react", "b": [0.3057, 0.4685, 0.3466, 0.4899]}, {"w": "only", "b": [0.3539, 0.4685, 0.3908, 0.4899]}, {"w": "to", "b": [0.3981, 0.4685, 0.4151, 0.4899]}, {"w": "lines", "b": [0.4224, 0.4685, 0.4611, 0.4899]}, {"w": "with", "b": [0.4685, 0.4685, 0.5058, 0.4899]}, {"w": "different", "b": [0.5131, 0.4685, 0.5848, 0.4899]}, {"w": "orientations", "b": [0.5921, 0.4685, 0.6926, 0.4899]}, {"w": "(two", "b": [0.6999, 0.4685, 0.7384, 0.4899]}, {"w": "neurons", "b": [0.7457, 0.4685, 0.8144, 0.4899]}, {"w": "may", "b": [0.8217, 0.4685, 0.8571, 0.4899]}, {"w": "have", "b": [0.1429, 0.4875, 0.1813, 0.5089]}, {"w": "the", "b": [0.1911, 0.4875, 0.2174, 0.5089]}, {"w": "same", "b": [0.2273, 0.4875, 0.27, 0.5089]}, {"w": "receptive", "b": [0.2798, 0.4875, 0.3554, 0.5089]}, {"w": "field", "b": [0.3653, 0.4875, 0.4022, 0.5089]}, {"w": "but", "b": [0.412, 0.4875, 0.44, 0.5089]}, {"w": "react", "b": [0.4498, 0.4875, 0.4907, 0.5089]}, {"w": "to", "b": [0.5006, 0.4875, 0.5176, 0.5089]}, {"w": "different", "b": [0.5274, 0.4875, 0.5991, 0.5089]}, {"w": "line", "b": [0.609, 0.4875, 0.6401, 0.5089]}, {"w": "orientations).", "b": [0.6499, 0.4875, 0.7624, 0.5089]}, {"w": "They", "b": [0.7722, 0.4875, 0.8146, 0.5089]}, {"w": "also", "b": [0.8245, 0.4875, 0.8571, 0.5089]}, {"w": "noticed", "b": [0.1429, 0.5066, 0.2055, 0.528]}, {"w": "that", "b": [0.2117, 0.5066, 0.2443, 0.528]}, {"w": "some", "b": [0.2505, 0.5066, 0.2947, 0.528]}, {"w": "neurons", "b": [0.3009, 0.5066, 0.3696, 0.528]}, {"w": "have", "b": [0.3759, 0.5066, 0.4143, 0.528]}, {"w": "larger", "b": [0.4205, 0.5066, 0.469, 0.528]}, {"w": "receptive", "b": [0.4752, 0.5066, 0.5508, 0.528]}, {"w": "fields,", "b": [0.557, 0.5066, 0.6063, 0.528]}, {"w": "and", "b": [0.6125, 0.5066, 0.6441, 0.528]}, {"w": "they", "b": [0.6503, 0.5066, 0.6862, 0.528]}, {"w": "react", "b": [0.6924, 0.5066, 0.7333, 0.528]}, {"w": "to", "b": [0.7395, 0.5066, 0.7565, 0.528]}, {"w": "more", "b": [0.7627, 0.5066, 0.807, 0.528]}, {"w": "com‐", "b": [0.8132, 0.5066, 0.8571, 0.528]}, {"w": "plex", "b": [0.1429, 0.5256, 0.1777, 0.547]}, {"w": "patterns", "b": [0.1853, 0.5256, 0.2533, 0.547]}, {"w": "that", "b": [0.2609, 0.5256, 0.2935, 0.547]}, {"w": "are", "b": [0.3011, 0.5256, 0.3268, 0.547]}, {"w": "combinations", "b": [0.3344, 0.5256, 0.4488, 0.547]}, {"w": "of", "b": [0.4564, 0.5256, 0.4732, 0.547]}, {"w": "the", "b": [0.4808, 0.5256, 0.5071, 0.547]}, {"w": "lower-level", "b": [0.5147, 0.5256, 0.6063, 0.547]}, {"w": "patterns.", "b": [0.6138, 0.5256, 0.6866, 0.547]}, {"w": "These", "b": [0.6942, 0.5256, 0.7435, 0.547]}, {"w": "observations", "b": [0.7511, 0.5256, 0.8571, 0.547]}, {"w": "led", "b": [0.1429, 0.5447, 0.168, 0.5661]}, {"w": "to", "b": [0.1737, 0.5447, 0.1907, 0.5661]}, {"w": "the", "b": [0.1964, 0.5447, 0.2228, 0.5661]}, {"w": "idea", "b": [0.2285, 0.5447, 0.2631, 0.5661]}, {"w": "that", "b": [0.2688, 0.5447, 0.3014, 0.5661]}, {"w": "the", "b": [0.3071, 0.5447, 0.3334, 0.5661]}, {"w": "higher-level", "b": [0.3392, 0.5447, 0.4381, 0.5661]}, {"w": "neurons", "b": [0.4439, 0.5447, 0.5126, 0.5661]}, {"w": "are", "b": [0.5183, 0.5447, 0.544, 0.5661]}, {"w": "based", "b": [0.5498, 0.5447, 0.597, 0.5661]}, {"w": "on", "b": [0.6027, 0.5447, 0.6247, 0.5661]}, {"w": "the", "b": [0.6305, 0.5447, 0.6568, 0.5661]}, {"w": "outputs", "b": [0.6625, 0.5447, 0.7265, 0.5661]}, {"w": "of", "b": [0.7323, 0.5447, 0.7491, 0.5661]}, {"w": "neighboring", "b": [0.7548, 0.5447, 0.8572, 0.5661]}, {"w": "lower-level", "b": [0.1429, 0.5637, 0.2344, 0.5851]}, {"w": "neurons", "b": [0.2412, 0.5637, 0.3099, 0.5851]}, {"w": "(in", "b": [0.3167, 0.5637, 0.3409, 0.5851]}, {"w": "Figure", "b": [0.3477, 0.5637, 0.4017, 0.5851]}, {"w": "14-1,", "b": [0.4084, 0.5637, 0.4506, 0.5851]}, {"w": "notice", "b": [0.4574, 0.5637, 0.509, 0.5851]}, {"w": "that", "b": [0.5158, 0.5637, 0.5484, 0.5851]}, {"w": "each", "b": [0.5552, 0.5637, 0.5931, 0.5851]}, {"w": "neuron", "b": [0.5999, 0.5637, 0.6609, 0.5851]}, {"w": "is", "b": [0.6677, 0.5637, 0.6809, 0.5851]}, {"w": "connected", "b": [0.6877, 0.5637, 0.7738, 0.5851]}, {"w": "only", "b": [0.7806, 0.5637, 0.8175, 0.5851]}, {"w": "to", "b": [0.8242, 0.5637, 0.8412, 0.5851]}, {"w": "a", "b": [0.848, 0.5637, 0.8571, 0.5851]}, {"w": "few", "b": [0.1429, 0.5828, 0.1721, 0.6042]}, {"w": "neurons", "b": [0.1781, 0.5828, 0.2468, 0.6042]}, {"w": "from", "b": [0.2528, 0.5828, 0.2944, 0.6042]}, {"w": "the", "b": [0.3004, 0.5828, 0.3267, 0.6042]}, {"w": "previous", "b": [0.3327, 0.5828, 0.4047, 0.6042]}, {"w": "layer).", "b": [0.4107, 0.5828, 0.4628, 0.6042]}, {"w": "This", "b": [0.4688, 0.5828, 0.506, 0.6042]}, {"w": "powerful", "b": [0.512, 0.5828, 0.5869, 0.6042]}, {"w": "architecture", "b": [0.5929, 0.5828, 0.6933, 0.6042]}, {"w": "is", "b": [0.6993, 0.5828, 0.7125, 0.6042]}, {"w": "able", "b": [0.7185, 0.5828, 0.7523, 0.6042]}, {"w": "to", "b": [0.7583, 0.5828, 0.7753, 0.6042]}, {"w": "detect", "b": [0.7812, 0.5828, 0.8315, 0.6042]}, {"w": "all", "b": [0.8375, 0.5828, 0.8571, 0.6042]}, {"w": "sorts", "b": [0.1428, 0.6018, 0.1828, 0.6232]}, {"w": "of", "b": [0.1876, 0.6018, 0.2044, 0.6232]}, {"w": "complex", "b": [0.2091, 0.6018, 0.2801, 0.6232]}, {"w": "patterns", "b": [0.2848, 0.6018, 0.3528, 0.6232]}, {"w": "in", "b": [0.3575, 0.6018, 0.3745, 0.6232]}, {"w": "any", "b": [0.3792, 0.6018, 0.4089, 0.6232]}, {"w": "area", "b": [0.4136, 0.6018, 0.4485, 0.6232]}, {"w": "of", "b": [0.4532, 0.6018, 0.47, 0.6232]}, {"w": "the", "b": [0.4747, 0.6018, 0.5011, 0.6232]}, {"w": "visual", "b": [0.5058, 0.6018, 0.5541, 0.6232]}, {"w": "field.", "b": [0.5589, 0.6018, 0.6005, 0.6232]}]}, {"id": "b_7", "type": "paragraph", "text": "432 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "432", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 459, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "4 “Neocognitron: A Self-organizing Neural Network Model for a Mechanism of Pattern Recognition Unaffected by Shift in Position,” K. Fukushima (1980).", "words": [{"w": "4", "b": [0.1451, 0.8416, 0.1518, 0.8559]}, {"w": "“Neocognitron:", "b": [0.1587, 0.8401, 0.2576, 0.8565]}, {"w": "A", "b": [0.2612, 0.8401, 0.2722, 0.8565]}, {"w": "Self-organizing", "b": [0.2758, 0.8401, 0.3727, 0.8565]}, {"w": "Neural", "b": [0.3763, 0.8401, 0.4198, 0.8565]}, {"w": "Network", "b": [0.4234, 0.8401, 0.4791, 0.8565]}, {"w": "Model", "b": [0.4827, 0.8401, 0.5237, 0.8565]}, {"w": "for", "b": [0.5273, 0.8401, 0.546, 0.8565]}, {"w": "a", "b": [0.5496, 0.8401, 0.5565, 0.8565]}, {"w": "Mechanism", "b": [0.5601, 0.8401, 0.6345, 0.8565]}, {"w": "of", "b": [0.6381, 0.8401, 0.6509, 0.8565]}, {"w": "Pattern", "b": [0.6545, 0.8401, 0.7008, 0.8565]}, {"w": "Recognition", "b": [0.7044, 0.8401, 0.782, 0.8565]}, {"w": "Unaffected", "b": [0.7857, 0.8401, 0.8551, 0.8565]}, {"w": "by", "b": [0.1587, 0.8553, 0.1741, 0.8716]}, {"w": "Shift", "b": [0.1777, 0.8553, 0.2075, 0.8716]}, {"w": "in", "b": [0.2111, 0.8553, 0.224, 0.8716]}, {"w": "Position,”", "b": [0.2276, 0.8553, 0.2879, 0.8716]}, {"w": "K.", "b": [0.2915, 0.8553, 0.3058, 0.8716]}, {"w": "Fukushima", "b": [0.3094, 0.8553, 0.3807, 0.8716]}, {"w": "(1980).", "b": [0.3843, 0.8553, 0.4294, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "5 “Gradient-Based Learning Applied to Document Recognition,” Y. LeCun et al. (1998).", "words": [{"w": "5", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "“Gradient-Based", "b": [0.1587, 0.8749, 0.2642, 0.8912]}, {"w": "Learning", "b": [0.2678, 0.8749, 0.325, 0.8912]}, {"w": "Applied", "b": [0.3286, 0.8749, 0.3789, 0.8912]}, {"w": "to", "b": [0.3825, 0.8749, 0.3955, 0.8912]}, {"w": "Document", "b": [0.3991, 0.8749, 0.467, 0.8912]}, {"w": "Recognition,”", "b": [0.4706, 0.8749, 0.556, 0.8912]}, {"w": "Y.", "b": [0.5596, 0.8749, 0.5714, 0.8912]}, {"w": "LeCun", "b": [0.575, 0.8749, 0.618, 0.8912]}, {"w": "et", "b": [0.6216, 0.8749, 0.6332, 0.8912]}, {"w": "al.", "b": [0.6368, 0.8749, 0.6514, 0.8912]}, {"w": "(1998).", "b": [0.655, 0.8749, 0.7001, 0.8912]}]}, {"id": "b_2", "type": "equation", "text": "Figure 14-1. Local receptive fields in the visual cortex", "words": [{"w": "Figure", "b": [0.1429, 0.272, 0.1943, 0.2936]}, {"w": "14-1.", "b": [0.1991, 0.272, 0.2407, 0.2936]}, {"w": "Local", "b": [0.2455, 0.272, 0.2893, 0.2936]}, {"w": "receptive", "b": [0.2941, 0.272, 0.3646, 0.2936]}, {"w": "fields", "b": [0.3694, 0.272, 0.4116, 0.2936]}, {"w": "in", "b": [0.4164, 0.272, 0.4329, 0.2936]}, {"w": "the", "b": [0.4376, 0.272, 0.4627, 0.2936]}, {"w": "visual", "b": [0.4674, 0.272, 0.5158, 0.2936]}, {"w": "cortex", "b": [0.5206, 0.272, 0.5704, 0.2936]}]}, {"id": "b_3", "type": "paragraph", "text": "These studies of the visual cortex inspired the neocognitron, introduced in 1980,4", "words": [{"w": "These", "b": [0.1429, 0.3094, 0.1922, 0.3308]}, {"w": "studies", "b": [0.2004, 0.3094, 0.2586, 0.3308]}, {"w": "of", "b": [0.2668, 0.3094, 0.2836, 0.3308]}, {"w": "the", "b": [0.2919, 0.3094, 0.3182, 0.3308]}, {"w": "visual", "b": [0.3264, 0.3094, 0.3748, 0.3308]}, {"w": "cortex", "b": [0.383, 0.3094, 0.4353, 0.3308]}, {"w": "inspired", "b": [0.4435, 0.3094, 0.5122, 0.3308]}, {"w": "the", "b": [0.5205, 0.3094, 0.5468, 0.3308]}, {"w": "neocognitron,", "b": [0.555, 0.3094, 0.6729, 0.3308]}, {"w": "introduced", "b": [0.6812, 0.3094, 0.7732, 0.3308]}, {"w": "in", "b": [0.7814, 0.3094, 0.7984, 0.3308]}, {"w": "1980,4", "b": [0.8067, 0.3094, 0.8571, 0.3308]}]}, {"id": "b_4", "type": "paragraph", "text": "which gradually evolved into what we now call convolutional neural networks. An important milestone was a 1998 paper5 by Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner, which introduced the famous LeNet-5 architecture, widely used to recognize handwritten check numbers. This architecture has some building blocks that you already know, such as fully connected layers and sigmoid activation func‐ tions, but it also introduces two new building blocks: convolutional layers and pooling layers. Let’s look at them now.", "words": [{"w": "which", "b": [0.1429, 0.3284, 0.1938, 0.3498]}, {"w": "gradually", "b": [0.2022, 0.3284, 0.2802, 0.3498]}, {"w": "evolved", "b": [0.2887, 0.3284, 0.3525, 0.3498]}, {"w": "into", "b": [0.361, 0.3284, 0.3946, 0.3498]}, {"w": "what", "b": [0.4031, 0.3284, 0.4436, 0.3498]}, {"w": "we", "b": [0.452, 0.3284, 0.4752, 0.3498]}, {"w": "now", "b": [0.4836, 0.3284, 0.5199, 0.3498]}, {"w": "call", "b": [0.5284, 0.3284, 0.5569, 0.3498]}, {"w": "convolutional", "b": [0.5654, 0.3282, 0.6754, 0.3498]}, {"w": "neural", "b": [0.6839, 0.3282, 0.7364, 0.3498]}, {"w": "networks.", "b": [0.7449, 0.3282, 0.8229, 0.3498]}, {"w": "An", "b": [0.8314, 0.3284, 0.8571, 0.3498]}, {"w": "important", "b": [0.1429, 0.3475, 0.2272, 0.3689]}, {"w": "milestone", "b": [0.2325, 0.3475, 0.3142, 0.3689]}, {"w": "was", "b": [0.3195, 0.3475, 0.3506, 0.3689]}, {"w": "a", "b": [0.3559, 0.3475, 0.365, 0.3689]}, {"w": "1998", "b": [0.3703, 0.3475, 0.4103, 0.3689]}, {"w": "paper5", "b": [0.4151, 0.3475, 0.4685, 0.3689]}, {"w": "by", "b": [0.4738, 0.3475, 0.494, 0.3689]}, {"w": "Yann", "b": [0.4993, 0.3475, 0.5421, 0.3689]}, {"w": "LeCun,", "b": [0.5474, 0.3475, 0.6085, 0.3689]}, {"w": "Léon", "b": [0.6138, 0.3475, 0.6559, 0.3689]}, {"w": "Bottou,", "b": [0.6612, 0.3475, 0.7236, 0.3689]}, {"w": "Yoshua", "b": [0.7289, 0.3475, 0.7888, 0.3689]}, {"w": "Bengio,", "b": [0.7941, 0.3475, 0.8572, 0.3689]}, {"w": "and", "b": [0.1429, 0.3665, 0.1744, 0.3879]}, {"w": "Patrick", "b": [0.1805, 0.3665, 0.2394, 0.3879]}, {"w": "Haffner,", "b": [0.2455, 0.3665, 0.3138, 0.3879]}, {"w": "which", "b": [0.32, 0.3665, 0.3709, 0.3879]}, {"w": "introduced", "b": [0.377, 0.3665, 0.469, 0.3879]}, {"w": "the", "b": [0.4752, 0.3665, 0.5015, 0.3879]}, {"w": "famous", "b": [0.5076, 0.3665, 0.5693, 0.3879]}, {"w": "LeNet-5", "b": [0.5755, 0.3663, 0.6405, 0.3879]}, {"w": "architecture,", "b": [0.6466, 0.3665, 0.7518, 0.3879]}, {"w": "widely", "b": [0.7579, 0.3665, 0.8125, 0.3879]}, {"w": "used", "b": [0.8186, 0.3665, 0.8571, 0.3879]}, {"w": "to", "b": [0.1429, 0.3856, 0.1598, 0.407]}, {"w": "recognize", "b": [0.1652, 0.3856, 0.2456, 0.407]}, {"w": "handwritten", "b": [0.251, 0.3856, 0.3542, 0.407]}, {"w": "check", "b": [0.3596, 0.3856, 0.4075, 0.407]}, {"w": "numbers.", "b": [0.4129, 0.3856, 0.4916, 0.407]}, {"w": "This", "b": [0.497, 0.3856, 0.5342, 0.407]}, {"w": "architecture", "b": [0.5396, 0.3856, 0.64, 0.407]}, {"w": "has", "b": [0.6454, 0.3856, 0.6733, 0.407]}, {"w": "some", "b": [0.6787, 0.3856, 0.7229, 0.407]}, {"w": "building", "b": [0.7282, 0.3856, 0.7985, 0.407]}, {"w": "blocks", "b": [0.8039, 0.3856, 0.8571, 0.407]}, {"w": "that", "b": [0.1429, 0.4046, 0.1755, 0.426]}, {"w": "you", "b": [0.1827, 0.4046, 0.214, 0.426]}, {"w": "already", "b": [0.2212, 0.4046, 0.282, 0.426]}, {"w": "know,", "b": [0.2892, 0.4046, 0.3391, 0.426]}, {"w": "such", "b": [0.3464, 0.4046, 0.385, 0.426]}, {"w": "as", "b": [0.3923, 0.4046, 0.4091, 0.426]}, {"w": "fully", "b": [0.4163, 0.4046, 0.4537, 0.426]}, {"w": "connected", "b": [0.461, 0.4046, 0.5471, 0.426]}, {"w": "layers", "b": [0.5543, 0.4046, 0.6022, 0.426]}, {"w": "and", "b": [0.6094, 0.4046, 0.641, 0.426]}, {"w": "sigmoid", "b": [0.6483, 0.4046, 0.7155, 0.426]}, {"w": "activation", "b": [0.7228, 0.4046, 0.805, 0.426]}, {"w": "func‐", "b": [0.8123, 0.4046, 0.8572, 0.426]}, {"w": "tions,", "b": [0.1429, 0.4237, 0.1892, 0.4451]}, {"w": "but", "b": [0.1946, 0.4237, 0.2226, 0.4451]}, {"w": "it", "b": [0.228, 0.4237, 0.24, 0.4451]}, {"w": "also", "b": [0.2454, 0.4237, 0.2781, 0.4451]}, {"w": "introduces", "b": [0.2835, 0.4237, 0.3722, 0.4451]}, {"w": "two", "b": [0.3776, 0.4237, 0.4088, 0.4451]}, {"w": "new", "b": [0.4142, 0.4237, 0.4488, 0.4451]}, {"w": "building", "b": [0.4542, 0.4237, 0.5244, 0.4451]}, {"w": "blocks:", "b": [0.5298, 0.4237, 0.5878, 0.4451]}, {"w": "convolutional", "b": [0.5932, 0.4234, 0.7032, 0.4451]}, {"w": "layers", "b": [0.708, 0.4234, 0.7549, 0.4451]}, {"w": "and", "b": [0.761, 0.4237, 0.7925, 0.4451]}, {"w": "pooling", "b": [0.7979, 0.4234, 0.8571, 0.4451]}, {"w": "layers.", "b": [0.1429, 0.4425, 0.1945, 0.4641]}, {"w": "Let’s", "b": [0.1992, 0.4427, 0.2354, 0.4641]}, {"w": "look", "b": [0.2401, 0.4427, 0.277, 0.4641]}, {"w": "at", "b": [0.2817, 0.4427, 0.2968, 0.4641]}, {"w": "them", "b": [0.3015, 0.4427, 0.3449, 0.4641]}, {"w": "now.", "b": [0.3496, 0.4427, 0.3892, 0.4641]}]}, {"id": "b_5", "type": "paragraph", "text": "Why not simply use a regular deep neural network with fully con‐ nected layers for image recognition tasks? Unfortunately, although this works fine for small images (e.g., MNIST), it breaks down for larger images because of the huge number of parameters it requires. For example, a 100 × 100 image has 10,000 pixels, and if the first layer has just 1,000 neurons (which already severely restricts the amount of information transmitted to the next layer), this means a total of 10 million connections. And that’s just the first layer. CNNs solve this problem using partially connected layers and weight sharing.", "words": [{"w": "Why", "b": [0.2714, 0.4846, 0.3084, 0.5042]}, {"w": "not", "b": [0.3139, 0.4846, 0.3398, 0.5042]}, {"w": "simply", "b": [0.3453, 0.4846, 0.3962, 0.5042]}, {"w": "use", "b": [0.4017, 0.4846, 0.4269, 0.5042]}, {"w": "a", "b": [0.4324, 0.4846, 0.4408, 0.5042]}, {"w": "regular", "b": [0.4463, 0.4846, 0.5007, 0.5042]}, {"w": "deep", "b": [0.5062, 0.4846, 0.5425, 0.5042]}, {"w": "neural", "b": [0.548, 0.4846, 0.5968, 0.5042]}, {"w": "network", "b": [0.6024, 0.4846, 0.666, 0.5042]}, {"w": "with", "b": [0.6715, 0.4846, 0.7056, 0.5042]}, {"w": "fully", "b": [0.7111, 0.4846, 0.7452, 0.5042]}, {"w": "con‐", "b": [0.7507, 0.4846, 0.7857, 0.5042]}, {"w": "nected", "b": [0.2714, 0.5021, 0.3219, 0.5216]}, {"w": "layers", "b": [0.3276, 0.5021, 0.3713, 0.5216]}, {"w": "for", "b": [0.3769, 0.5021, 0.3994, 0.5216]}, {"w": "image", "b": [0.405, 0.5021, 0.4511, 0.5216]}, {"w": "recognition", "b": [0.4567, 0.5021, 0.5451, 0.5216]}, {"w": "tasks?", "b": [0.5508, 0.5021, 0.5956, 0.5216]}, {"w": "Unfortunately,", "b": [0.6012, 0.5021, 0.712, 0.5216]}, {"w": "although", "b": [0.7176, 0.5021, 0.7857, 0.5216]}, {"w": "this", "b": [0.2714, 0.5195, 0.2995, 0.5391]}, {"w": "works", "b": [0.3052, 0.5195, 0.3514, 0.5391]}, {"w": "fine", "b": [0.3571, 0.5195, 0.3864, 0.5391]}, {"w": "for", "b": [0.392, 0.5195, 0.4145, 0.5391]}, {"w": "small", "b": [0.4201, 0.5195, 0.4607, 0.5391]}, {"w": "images", "b": [0.4664, 0.5195, 0.5195, 0.5391]}, {"w": "(e.g.,", "b": [0.5252, 0.5195, 0.5618, 0.5391]}, {"w": "MNIST),", "b": [0.5675, 0.5195, 0.6368, 0.5391]}, {"w": "it", "b": [0.6425, 0.5195, 0.6534, 0.5391]}, {"w": "breaks", "b": [0.6591, 0.5195, 0.7087, 0.5391]}, {"w": "down", "b": [0.7144, 0.5195, 0.7576, 0.5391]}, {"w": "for", "b": [0.7633, 0.5195, 0.7857, 0.5391]}, {"w": "larger", "b": [0.2714, 0.5369, 0.3157, 0.5565]}, {"w": "images", "b": [0.3279, 0.5369, 0.3809, 0.5565]}, {"w": "because", "b": [0.3931, 0.5369, 0.4521, 0.5565]}, {"w": "of", "b": [0.4642, 0.5369, 0.4796, 0.5565]}, {"w": "the", "b": [0.4917, 0.5369, 0.5158, 0.5565]}, {"w": "huge", "b": [0.5279, 0.5369, 0.5649, 0.5565]}, {"w": "number", "b": [0.577, 0.5369, 0.6376, 0.5565]}, {"w": "of", "b": [0.6497, 0.5369, 0.6651, 0.5565]}, {"w": "parameters", "b": [0.6772, 0.5369, 0.7627, 0.5565]}, {"w": "it", "b": [0.7748, 0.5369, 0.7857, 0.5565]}, {"w": "requires.", "b": [0.2714, 0.5543, 0.338, 0.5739]}, {"w": "For", "b": [0.3438, 0.5543, 0.3703, 0.5739]}, {"w": "example,", "b": [0.3761, 0.5543, 0.444, 0.5739]}, {"w": "a", "b": [0.4498, 0.5543, 0.4582, 0.5739]}, {"w": "100", "b": [0.4639, 0.5543, 0.4914, 0.5739]}, {"w": "×", "b": [0.4972, 0.5543, 0.5082, 0.5739]}, {"w": "100", "b": [0.514, 0.5543, 0.5414, 0.5739]}, {"w": "image", "b": [0.5472, 0.5543, 0.5933, 0.5739]}, {"w": "has", "b": [0.5991, 0.5543, 0.6246, 0.5739]}, {"w": "10,000", "b": [0.6304, 0.5543, 0.6804, 0.5739]}, {"w": "pixels,", "b": [0.6862, 0.5543, 0.7346, 0.5739]}, {"w": "and", "b": [0.7403, 0.5543, 0.7692, 0.5739]}, {"w": "if", "b": [0.775, 0.5543, 0.7857, 0.5739]}, {"w": "the", "b": [0.2714, 0.5717, 0.2955, 0.5913]}, {"w": "first", "b": [0.3062, 0.5717, 0.3368, 0.5913]}, {"w": "layer", "b": [0.3475, 0.5717, 0.3843, 0.5913]}, {"w": "has", "b": [0.395, 0.5717, 0.4205, 0.5913]}, {"w": "just", "b": [0.4312, 0.5717, 0.459, 0.5913]}, {"w": "1,000", "b": [0.4697, 0.5717, 0.5107, 0.5913]}, {"w": "neurons", "b": [0.5214, 0.5717, 0.5842, 0.5913]}, {"w": "(which", "b": [0.5949, 0.5717, 0.6481, 0.5913]}, {"w": "already", "b": [0.6588, 0.5717, 0.7143, 0.5913]}, {"w": "severely", "b": [0.725, 0.5717, 0.7857, 0.5913]}, {"w": "restricts", "b": [0.2714, 0.5891, 0.3324, 0.6087]}, {"w": "the", "b": [0.3382, 0.5891, 0.3622, 0.6087]}, {"w": "amount", "b": [0.368, 0.5891, 0.4277, 0.6087]}, {"w": "of", "b": [0.4334, 0.5891, 0.4488, 0.6087]}, {"w": "information", "b": [0.4546, 0.5891, 0.5472, 0.6087]}, {"w": "transmitted", "b": [0.5529, 0.5891, 0.642, 0.6087]}, {"w": "to", "b": [0.6478, 0.5891, 0.6633, 0.6087]}, {"w": "the", "b": [0.6691, 0.5891, 0.6932, 0.6087]}, {"w": "next", "b": [0.699, 0.5891, 0.7323, 0.6087]}, {"w": "layer),", "b": [0.738, 0.5891, 0.7857, 0.6087]}, {"w": "this", "b": [0.2714, 0.6065, 0.2995, 0.6261]}, {"w": "means", "b": [0.3039, 0.6065, 0.3533, 0.6261]}, {"w": "a", "b": [0.3577, 0.6065, 0.3661, 0.6261]}, {"w": "total", "b": [0.3705, 0.6065, 0.405, 0.6261]}, {"w": "of", "b": [0.4094, 0.6065, 0.4248, 0.6261]}, {"w": "10", "b": [0.4291, 0.6065, 0.4474, 0.6261]}, {"w": "million", "b": [0.4518, 0.6065, 0.5074, 0.6261]}, {"w": "connections.", "b": [0.5118, 0.6065, 0.6089, 0.6261]}, {"w": "And", "b": [0.6133, 0.6065, 0.647, 0.6261]}, {"w": "that’s", "b": [0.6514, 0.6065, 0.6901, 0.6261]}, {"w": "just", "b": [0.6945, 0.6065, 0.7222, 0.6261]}, {"w": "the", "b": [0.7266, 0.6065, 0.7507, 0.6261]}, {"w": "first", "b": [0.7551, 0.6065, 0.7857, 0.6261]}, {"w": "layer.", "b": [0.2714, 0.624, 0.3113, 0.6435]}, {"w": "CNNs", "b": [0.3157, 0.624, 0.3631, 0.6435]}, {"w": "solve", "b": [0.3675, 0.624, 0.406, 0.6435]}, {"w": "this", "b": [0.4104, 0.624, 0.4385, 0.6435]}, {"w": "problem", "b": [0.4429, 0.624, 0.5078, 0.6435]}, {"w": "using", "b": [0.5122, 0.624, 0.5538, 0.6435]}, {"w": "partially", "b": [0.5582, 0.624, 0.6212, 0.6435]}, {"w": "connected", "b": [0.6256, 0.624, 0.7043, 0.6435]}, {"w": "layers", "b": [0.7087, 0.624, 0.7525, 0.6435]}, {"w": "and", "b": [0.7569, 0.624, 0.7857, 0.6435]}, {"w": "weight", "b": [0.2714, 0.6414, 0.3222, 0.661]}, {"w": "sharing.", "b": [0.3265, 0.6414, 0.3879, 0.661]}]}, {"id": "b_6", "type": "paragraph", "text": "The Architecture of the Visual Cortex | 433", "words": [{"w": "The", "b": [0.5828, 0.9225, 0.6043, 0.9388]}, {"w": "Architecture", "b": [0.6071, 0.9225, 0.6794, 0.9388]}, {"w": "of", "b": [0.6822, 0.9225, 0.6942, 0.9388]}, {"w": "the", "b": [0.697, 0.9225, 0.7169, 0.9388]}, {"w": "Visual", "b": [0.7197, 0.9225, 0.7552, 0.9388]}, {"w": "Cortex", "b": [0.758, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "433", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 460, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "6 A convolution is a mathematical operation that slides one function over another and measures the integral of their pointwise multiplication. It has deep connections with the Fourier transform and the Laplace transform, and is heavily used in signal processing. Convolutional layers actually use cross-correlations, which are very similar to convolutions (see https://homl.info/76 for more details).", "words": [{"w": "6", "b": [0.1451, 0.8311, 0.1518, 0.8453]}, {"w": "A", "b": [0.1587, 0.8296, 0.1697, 0.8459]}, {"w": "convolution", "b": [0.1733, 0.8296, 0.2502, 0.8459]}, {"w": "is", "b": [0.2538, 0.8296, 0.2639, 0.8459]}, {"w": "a", "b": [0.2675, 0.8296, 0.2744, 0.8459]}, {"w": "mathematical", "b": [0.278, 0.8296, 0.3642, 0.8459]}, {"w": "operation", "b": [0.3678, 0.8296, 0.4294, 0.8459]}, {"w": "that", "b": [0.433, 0.8296, 0.4579, 0.8459]}, {"w": "slides", "b": [0.4615, 0.8296, 0.4965, 0.8459]}, {"w": "one", "b": [0.5001, 0.8296, 0.5236, 0.8459]}, {"w": "function", "b": [0.5272, 0.8296, 0.5816, 0.8459]}, {"w": "over", "b": [0.5852, 0.8296, 0.6133, 0.8459]}, {"w": "another", "b": [0.6169, 0.8296, 0.6666, 0.8459]}, {"w": "and", "b": [0.6702, 0.8296, 0.6943, 0.8459]}, {"w": "measures", "b": [0.6979, 0.8296, 0.7573, 0.8459]}, {"w": "the", "b": [0.7609, 0.8296, 0.781, 0.8459]}, {"w": "integral", "b": [0.7846, 0.8296, 0.8331, 0.8459]}, {"w": "of", "b": [0.8367, 0.8296, 0.8495, 0.8459]}, {"w": "their", "b": [0.1587, 0.8447, 0.1889, 0.861]}, {"w": "pointwise", "b": [0.1925, 0.8447, 0.2541, 0.861]}, {"w": "multiplication.", "b": [0.2577, 0.8447, 0.3514, 0.861]}, {"w": "It", "b": [0.355, 0.8447, 0.3647, 0.861]}, {"w": "has", "b": [0.3683, 0.8447, 0.3895, 0.861]}, {"w": "deep", "b": [0.3931, 0.8447, 0.4233, 0.861]}, {"w": "connections", "b": [0.4269, 0.8447, 0.5043, 0.861]}, {"w": "with", "b": [0.5079, 0.8447, 0.5363, 0.861]}, {"w": "the", "b": [0.5399, 0.8447, 0.56, 0.861]}, {"w": "Fourier", "b": [0.5636, 0.8447, 0.611, 0.861]}, {"w": "transform", "b": [0.6146, 0.8447, 0.6785, 0.861]}, {"w": "and", "b": [0.6821, 0.8447, 0.7061, 0.861]}, {"w": "the", "b": [0.7097, 0.8447, 0.7298, 0.861]}, {"w": "Laplace", "b": [0.7334, 0.8447, 0.7813, 0.861]}, {"w": "transform,", "b": [0.785, 0.8447, 0.8525, 0.861]}, {"w": "and", "b": [0.1587, 0.8598, 0.1828, 0.8761]}, {"w": "is", "b": [0.1864, 0.8598, 0.1964, 0.8761]}, {"w": "heavily", "b": [0.2, 0.8598, 0.2449, 0.8761]}, {"w": "used", "b": [0.2485, 0.8598, 0.2778, 0.8761]}, {"w": "in", "b": [0.2814, 0.8598, 0.2944, 0.8761]}, {"w": "signal", "b": [0.298, 0.8598, 0.3352, 0.8761]}, {"w": "processing.", "b": [0.3388, 0.8598, 0.4102, 0.8761]}, {"w": "Convolutional", "b": [0.4138, 0.8598, 0.5055, 0.8761]}, {"w": "layers", "b": [0.5091, 0.8598, 0.5455, 0.8761]}, {"w": "actually", "b": [0.5491, 0.8598, 0.5984, 0.8761]}, {"w": "use", "b": [0.602, 0.8598, 0.623, 0.8761]}, {"w": "cross-correlations,", "b": [0.6266, 0.8598, 0.7439, 0.8761]}, {"w": "which", "b": [0.7475, 0.8598, 0.7863, 0.8761]}, {"w": "are", "b": [0.7899, 0.8598, 0.8095, 0.8761]}, {"w": "very", "b": [0.8131, 0.8598, 0.8408, 0.8761]}, {"w": "similar", "b": [0.1587, 0.8749, 0.2029, 0.8912]}, {"w": "to", "b": [0.2065, 0.8749, 0.2195, 0.8912]}, {"w": "convolutions", "b": [0.2231, 0.8749, 0.3058, 0.8912]}, {"w": "(see", "b": [0.3094, 0.8749, 0.3342, 0.8912]}, {"w": "https://homl.info/76", "b": [0.3378, 0.8748, 0.4618, 0.8912]}, {"w": "for", "b": [0.4654, 0.8749, 0.4841, 0.8912]}, {"w": "more", "b": [0.4877, 0.8749, 0.5215, 0.8912]}, {"w": "details).", "b": [0.5251, 0.8749, 0.5752, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Convolutional Layer", "words": [{"w": "Convolutional", "b": [0.1429, 0.0753, 0.3152, 0.1095]}, {"w": "Layer", "b": [0.3212, 0.0753, 0.3886, 0.1095]}]}, {"id": "b_2", "type": "paragraph", "text": "The most important building block of a CNN is the convolutional layer:6 neurons in the first convolutional layer are not connected to every single pixel in the input image (like they were in previous chapters), but only to pixels in their receptive fields (see Figure 14-2). In turn, each neuron in the second convolutional layer is connected only to neurons located within a small rectangle in the first layer. This architecture allows the network to concentrate on small low-level features in the first hidden layer, then assemble them into larger higher-level features in the next hidden layer, and so on. This hierarchical structure is common in real-world images, which is one of the reasons why CNNs work so well for image recognition.", "words": [{"w": "The", "b": [0.1429, 0.1164, 0.1757, 0.1378]}, {"w": "most", "b": [0.1821, 0.1164, 0.2238, 0.1378]}, {"w": "important", "b": [0.2302, 0.1164, 0.3145, 0.1378]}, {"w": "building", "b": [0.3209, 0.1164, 0.3912, 0.1378]}, {"w": "block", "b": [0.3976, 0.1164, 0.4432, 0.1378]}, {"w": "of", "b": [0.4496, 0.1164, 0.4664, 0.1378]}, {"w": "a", "b": [0.4728, 0.1164, 0.4819, 0.1378]}, {"w": "CNN", "b": [0.4883, 0.1164, 0.5331, 0.1378]}, {"w": "is", "b": [0.5395, 0.1164, 0.5527, 0.1378]}, {"w": "the", "b": [0.5591, 0.1164, 0.5855, 0.1378]}, {"w": "convolutional", "b": [0.5919, 0.1162, 0.7019, 0.1378]}, {"w": "layer:6", "b": [0.7083, 0.1162, 0.7587, 0.1378]}, {"w": "neurons", "b": [0.7651, 0.1164, 0.8338, 0.1378]}, {"w": "in", "b": [0.8402, 0.1164, 0.8571, 0.1378]}, {"w": "the", "b": [0.1429, 0.1355, 0.1692, 0.1569]}, {"w": "first", "b": [0.1741, 0.1355, 0.2076, 0.1569]}, {"w": "convolutional", "b": [0.2125, 0.1355, 0.3279, 0.1569]}, {"w": "layer", "b": [0.3328, 0.1355, 0.373, 0.1569]}, {"w": "are", "b": [0.3779, 0.1355, 0.4036, 0.1569]}, {"w": "not", "b": [0.4085, 0.1355, 0.4369, 0.1569]}, {"w": "connected", "b": [0.4418, 0.1355, 0.5279, 0.1569]}, {"w": "to", "b": [0.5329, 0.1355, 0.5498, 0.1569]}, {"w": "every", "b": [0.5548, 0.1355, 0.6, 0.1569]}, {"w": "single", "b": [0.6049, 0.1355, 0.6534, 0.1569]}, {"w": "pixel", "b": [0.6584, 0.1355, 0.6988, 0.1569]}, {"w": "in", "b": [0.7037, 0.1355, 0.7207, 0.1569]}, {"w": "the", "b": [0.7257, 0.1355, 0.752, 0.1569]}, {"w": "input", "b": [0.7569, 0.1355, 0.8018, 0.1569]}, {"w": "image", "b": [0.8067, 0.1355, 0.8571, 0.1569]}, {"w": "(like", "b": [0.1429, 0.1545, 0.1801, 0.1759]}, {"w": "they", "b": [0.1866, 0.1545, 0.2225, 0.1759]}, {"w": "were", "b": [0.229, 0.1545, 0.2687, 0.1759]}, {"w": "in", "b": [0.2752, 0.1545, 0.2922, 0.1759]}, {"w": "previous", "b": [0.2987, 0.1545, 0.3707, 0.1759]}, {"w": "chapters),", "b": [0.3772, 0.1545, 0.4594, 0.1759]}, {"w": "but", "b": [0.4659, 0.1545, 0.4939, 0.1759]}, {"w": "only", "b": [0.5004, 0.1545, 0.5372, 0.1759]}, {"w": "to", "b": [0.5437, 0.1545, 0.5607, 0.1759]}, {"w": "pixels", "b": [0.5672, 0.1545, 0.6153, 0.1759]}, {"w": "in", "b": [0.6218, 0.1545, 0.6388, 0.1759]}, {"w": "their", "b": [0.6453, 0.1545, 0.685, 0.1759]}, {"w": "receptive", "b": [0.6915, 0.1545, 0.7671, 0.1759]}, {"w": "fields", "b": [0.7736, 0.1545, 0.8181, 0.1759]}, {"w": "(see", "b": [0.8246, 0.1545, 0.8571, 0.1759]}, {"w": "Figure", "b": [0.1429, 0.1736, 0.1969, 0.195]}, {"w": "14-2).", "b": [0.2048, 0.1736, 0.2542, 0.195]}, {"w": "In", "b": [0.2622, 0.1736, 0.2807, 0.195]}, {"w": "turn,", "b": [0.2886, 0.1736, 0.3299, 0.195]}, {"w": "each", "b": [0.3379, 0.1736, 0.3758, 0.195]}, {"w": "neuron", "b": [0.3838, 0.1736, 0.4449, 0.195]}, {"w": "in", "b": [0.4528, 0.1736, 0.4698, 0.195]}, {"w": "the", "b": [0.4778, 0.1736, 0.5041, 0.195]}, {"w": "second", "b": [0.5121, 0.1736, 0.5704, 0.195]}, {"w": "convolutional", "b": [0.5784, 0.1736, 0.6937, 0.195]}, {"w": "layer", "b": [0.7017, 0.1736, 0.7419, 0.195]}, {"w": "is", "b": [0.7499, 0.1736, 0.7631, 0.195]}, {"w": "connected", "b": [0.771, 0.1736, 0.8572, 0.195]}, {"w": "only", "b": [0.1429, 0.1926, 0.1797, 0.214]}, {"w": "to", "b": [0.1866, 0.1926, 0.2036, 0.214]}, {"w": "neurons", "b": [0.2105, 0.1926, 0.2793, 0.214]}, {"w": "located", "b": [0.2862, 0.1926, 0.3458, 0.214]}, {"w": "within", "b": [0.3528, 0.1926, 0.4071, 0.214]}, {"w": "a", "b": [0.414, 0.1926, 0.4231, 0.214]}, {"w": "small", "b": [0.4301, 0.1926, 0.4745, 0.214]}, {"w": "rectangle", "b": [0.4814, 0.1926, 0.5576, 0.214]}, {"w": "in", "b": [0.5645, 0.1926, 0.5815, 0.214]}, {"w": "the", "b": [0.5884, 0.1926, 0.6147, 0.214]}, {"w": "first", "b": [0.6216, 0.1926, 0.6551, 0.214]}, {"w": "layer.", "b": [0.662, 0.1926, 0.7057, 0.214]}, {"w": "This", "b": [0.7126, 0.1926, 0.7498, 0.214]}, {"w": "architecture", "b": [0.7567, 0.1926, 0.8571, 0.214]}, {"w": "allows", "b": [0.1429, 0.2117, 0.1951, 0.2331]}, {"w": "the", "b": [0.2001, 0.2117, 0.2264, 0.2331]}, {"w": "network", "b": [0.2314, 0.2117, 0.301, 0.2331]}, {"w": "to", "b": [0.306, 0.2117, 0.3229, 0.2331]}, {"w": "concentrate", "b": [0.3279, 0.2117, 0.4255, 0.2331]}, {"w": "on", "b": [0.4305, 0.2117, 0.4525, 0.2331]}, {"w": "small", "b": [0.4575, 0.2117, 0.5019, 0.2331]}, {"w": "low-level", "b": [0.5069, 0.2117, 0.5824, 0.2331]}, {"w": "features", "b": [0.5874, 0.2117, 0.6528, 0.2331]}, {"w": "in", "b": [0.6578, 0.2117, 0.6748, 0.2331]}, {"w": "the", "b": [0.6798, 0.2117, 0.7061, 0.2331]}, {"w": "first", "b": [0.7111, 0.2117, 0.7446, 0.2331]}, {"w": "hidden", "b": [0.7496, 0.2117, 0.8085, 0.2331]}, {"w": "layer,", "b": [0.8135, 0.2117, 0.8571, 0.2331]}, {"w": "then", "b": [0.1428, 0.2307, 0.1806, 0.2521]}, {"w": "assemble", "b": [0.1867, 0.2307, 0.2618, 0.2521]}, {"w": "them", "b": [0.2679, 0.2307, 0.3113, 0.2521]}, {"w": "into", "b": [0.3174, 0.2307, 0.3509, 0.2521]}, {"w": "larger", "b": [0.3571, 0.2307, 0.4055, 0.2521]}, {"w": "higher-level", "b": [0.4117, 0.2307, 0.5106, 0.2521]}, {"w": "features", "b": [0.5168, 0.2307, 0.5822, 0.2521]}, {"w": "in", "b": [0.5883, 0.2307, 0.6053, 0.2521]}, {"w": "the", "b": [0.6114, 0.2307, 0.6377, 0.2521]}, {"w": "next", "b": [0.6438, 0.2307, 0.6803, 0.2521]}, {"w": "hidden", "b": [0.6864, 0.2307, 0.7453, 0.2521]}, {"w": "layer,", "b": [0.7515, 0.2307, 0.7951, 0.2521]}, {"w": "and", "b": [0.8012, 0.2307, 0.8327, 0.2521]}, {"w": "so", "b": [0.8389, 0.2307, 0.8571, 0.2521]}, {"w": "on.", "b": [0.1429, 0.2498, 0.1696, 0.2712]}, {"w": "This", "b": [0.1759, 0.2498, 0.2131, 0.2712]}, {"w": "hierarchical", "b": [0.2194, 0.2498, 0.3183, 0.2712]}, {"w": "structure", "b": [0.3246, 0.2498, 0.4002, 0.2712]}, {"w": "is", "b": [0.4065, 0.2498, 0.4197, 0.2712]}, {"w": "common", "b": [0.426, 0.2498, 0.5016, 0.2712]}, {"w": "in", "b": [0.5079, 0.2498, 0.5249, 0.2712]}, {"w": "real-world", "b": [0.5312, 0.2498, 0.6185, 0.2712]}, {"w": "images,", "b": [0.6248, 0.2498, 0.6876, 0.2712]}, {"w": "which", "b": [0.6939, 0.2498, 0.7448, 0.2712]}, {"w": "is", "b": [0.7511, 0.2498, 0.7643, 0.2712]}, {"w": "one", "b": [0.7706, 0.2498, 0.8014, 0.2712]}, {"w": "of", "b": [0.8077, 0.2498, 0.8245, 0.2712]}, {"w": "the", "b": [0.8308, 0.2498, 0.8571, 0.2712]}, {"w": "reasons", "b": [0.1429, 0.2688, 0.2059, 0.2902]}, {"w": "why", "b": [0.2106, 0.2688, 0.2451, 0.2902]}, {"w": "CNNs", "b": [0.2498, 0.2688, 0.3017, 0.2902]}, {"w": "work", "b": [0.3065, 0.2688, 0.3494, 0.2902]}, {"w": "so", "b": [0.3541, 0.2688, 0.3724, 0.2902]}, {"w": "well", "b": [0.3771, 0.2688, 0.4108, 0.2902]}, {"w": "for", "b": [0.4155, 0.2688, 0.4401, 0.2902]}, {"w": "image", "b": [0.4448, 0.2688, 0.4952, 0.2902]}, {"w": "recognition.", "b": [0.4999, 0.2688, 0.6014, 0.2902]}]}, {"id": "b_3", "type": "equation", "text": "Figure 14-2. CNN layers with rectangular local receptive fields", "words": [{"w": "Figure", "b": [0.1429, 0.5465, 0.1943, 0.5681]}, {"w": "14-2.", "b": [0.1991, 0.5465, 0.2407, 0.5681]}, {"w": "CNN", "b": [0.2455, 0.5465, 0.2881, 0.5681]}, {"w": "layers", "b": [0.2929, 0.5465, 0.3397, 0.5681]}, {"w": "with", "b": [0.3445, 0.5465, 0.381, 0.5681]}, {"w": "rectangular", "b": [0.3858, 0.5465, 0.4786, 0.5681]}, {"w": "local", "b": [0.4834, 0.5465, 0.5211, 0.5681]}, {"w": "receptive", "b": [0.5259, 0.5465, 0.5964, 0.5681]}, {"w": "fields", "b": [0.6012, 0.5465, 0.6434, 0.5681]}]}, {"id": "b_4", "type": "paragraph", "text": "Until now, all multilayer neural networks we looked at had layers composed of a long line of neurons, and we had to flatten input images to 1D before feeding them to the neural network. Now each layer is represented in 2D, which makes it easier to match neurons with their corresponding inputs.", "words": [{"w": "Until", "b": [0.2714, 0.5887, 0.3104, 0.6083]}, {"w": "now,", "b": [0.3169, 0.5887, 0.353, 0.6083]}, {"w": "all", "b": [0.3595, 0.5887, 0.3775, 0.6083]}, {"w": "multilayer", "b": [0.384, 0.5887, 0.4618, 0.6083]}, {"w": "neural", "b": [0.4683, 0.5887, 0.5172, 0.6083]}, {"w": "networks", "b": [0.5236, 0.5887, 0.5942, 0.6083]}, {"w": "we", "b": [0.6007, 0.5887, 0.6218, 0.6083]}, {"w": "looked", "b": [0.6283, 0.5887, 0.6802, 0.6083]}, {"w": "at", "b": [0.6866, 0.5887, 0.7004, 0.6083]}, {"w": "had", "b": [0.7069, 0.5887, 0.7355, 0.6083]}, {"w": "layers", "b": [0.742, 0.5887, 0.7857, 0.6083]}, {"w": "composed", "b": [0.2714, 0.6061, 0.3492, 0.6257]}, {"w": "of", "b": [0.3563, 0.6061, 0.3716, 0.6257]}, {"w": "a", "b": [0.3786, 0.6061, 0.387, 0.6257]}, {"w": "long", "b": [0.394, 0.6061, 0.4279, 0.6257]}, {"w": "line", "b": [0.4349, 0.6061, 0.4633, 0.6257]}, {"w": "of", "b": [0.4703, 0.6061, 0.4857, 0.6257]}, {"w": "neurons,", "b": [0.4927, 0.6061, 0.5599, 0.6257]}, {"w": "and", "b": [0.5669, 0.6061, 0.5957, 0.6257]}, {"w": "we", "b": [0.6027, 0.6061, 0.6239, 0.6257]}, {"w": "had", "b": [0.6309, 0.6061, 0.6595, 0.6257]}, {"w": "to", "b": [0.6665, 0.6061, 0.682, 0.6257]}, {"w": "flatten", "b": [0.689, 0.6061, 0.7376, 0.6257]}, {"w": "input", "b": [0.7446, 0.6061, 0.7857, 0.6257]}, {"w": "images", "b": [0.2714, 0.6235, 0.3245, 0.6431]}, {"w": "to", "b": [0.3291, 0.6235, 0.3446, 0.6431]}, {"w": "1D", "b": [0.3492, 0.6235, 0.3724, 0.6431]}, {"w": "before", "b": [0.377, 0.6235, 0.4253, 0.6431]}, {"w": "feeding", "b": [0.4299, 0.6235, 0.4862, 0.6431]}, {"w": "them", "b": [0.4908, 0.6235, 0.5305, 0.6431]}, {"w": "to", "b": [0.5351, 0.6235, 0.5506, 0.6431]}, {"w": "the", "b": [0.5552, 0.6235, 0.5793, 0.6431]}, {"w": "neural", "b": [0.5839, 0.6235, 0.6328, 0.6431]}, {"w": "network.", "b": [0.6374, 0.6235, 0.7054, 0.6431]}, {"w": "Now", "b": [0.71, 0.6235, 0.7464, 0.6431]}, {"w": "each", "b": [0.751, 0.6235, 0.7857, 0.6431]}, {"w": "layer", "b": [0.2714, 0.6409, 0.3081, 0.6605]}, {"w": "is", "b": [0.3134, 0.6409, 0.3255, 0.6605]}, {"w": "represented", "b": [0.3308, 0.6409, 0.4202, 0.6605]}, {"w": "in", "b": [0.4255, 0.6409, 0.441, 0.6605]}, {"w": "2D,", "b": [0.4463, 0.6409, 0.473, 0.6605]}, {"w": "which", "b": [0.4783, 0.6409, 0.5249, 0.6605]}, {"w": "makes", "b": [0.5302, 0.6409, 0.5787, 0.6605]}, {"w": "it", "b": [0.584, 0.6409, 0.5949, 0.6605]}, {"w": "easier", "b": [0.6002, 0.6409, 0.6439, 0.6605]}, {"w": "to", "b": [0.6492, 0.6409, 0.6647, 0.6605]}, {"w": "match", "b": [0.67, 0.6409, 0.7176, 0.6605]}, {"w": "neurons", "b": [0.7229, 0.6409, 0.7857, 0.6605]}, {"w": "with", "b": [0.2714, 0.6583, 0.3055, 0.6779]}, {"w": "their", "b": [0.3099, 0.6583, 0.3461, 0.6779]}, {"w": "corresponding", "b": [0.3504, 0.6583, 0.462, 0.6779]}, {"w": "inputs.", "b": [0.4664, 0.6583, 0.5188, 0.6779]}]}, {"id": "b_5", "type": "paragraph", "text": "A neuron located in row i, column j of a given layer is connected to the outputs of the neurons in the previous layer located in rows i to i + fh – 1, columns j to j + fw – 1, where fh and fw are the height and width of the receptive field (see Figure 14-3). In order for a layer to have the same height and width as the previous layer, it is com‐", "words": [{"w": "A", "b": [0.1429, 0.6982, 0.1573, 0.7196]}, {"w": "neuron", "b": [0.1622, 0.6982, 0.2232, 0.7196]}, {"w": "located", "b": [0.2281, 0.6982, 0.2878, 0.7196]}, {"w": "in", "b": [0.2927, 0.6982, 0.3097, 0.7196]}, {"w": "row", "b": [0.3146, 0.6982, 0.3472, 0.7196]}, {"w": "i,", "b": [0.3521, 0.698, 0.3625, 0.7196]}, {"w": "column", "b": [0.3673, 0.6982, 0.4315, 0.7196]}, {"w": "j", "b": [0.4365, 0.698, 0.4421, 0.7196]}, {"w": "of", "b": [0.447, 0.6982, 0.4638, 0.7196]}, {"w": "a", "b": [0.4687, 0.6982, 0.4778, 0.7196]}, {"w": "given", "b": [0.4827, 0.6982, 0.528, 0.7196]}, {"w": "layer", "b": [0.5329, 0.6982, 0.5731, 0.7196]}, {"w": "is", "b": [0.578, 0.6982, 0.5912, 0.7196]}, {"w": "connected", "b": [0.5961, 0.6982, 0.6822, 0.7196]}, {"w": "to", "b": [0.6871, 0.6982, 0.7041, 0.7196]}, {"w": "the", "b": [0.709, 0.6982, 0.7353, 0.7196]}, {"w": "outputs", "b": [0.7402, 0.6982, 0.8042, 0.7196]}, {"w": "of", "b": [0.8091, 0.6982, 0.8259, 0.7196]}, {"w": "the", "b": [0.8308, 0.6982, 0.8572, 0.7196]}, {"w": "neurons", "b": [0.1429, 0.7173, 0.2116, 0.7387]}, {"w": "in", "b": [0.2181, 0.7173, 0.2351, 0.7387]}, {"w": "the", "b": [0.2416, 0.7173, 0.2679, 0.7387]}, {"w": "previous", "b": [0.2744, 0.7173, 0.3465, 0.7387]}, {"w": "layer", "b": [0.353, 0.7173, 0.3932, 0.7387]}, {"w": "located", "b": [0.3997, 0.7173, 0.4594, 0.7387]}, {"w": "in", "b": [0.4659, 0.7173, 0.4829, 0.7387]}, {"w": "rows", "b": [0.4894, 0.7173, 0.5297, 0.7387]}, {"w": "i", "b": [0.5362, 0.717, 0.5419, 0.7387]}, {"w": "to", "b": [0.5484, 0.7173, 0.5654, 0.7387]}, {"w": "i", "b": [0.5719, 0.717, 0.5776, 0.7387]}, {"w": "+", "b": [0.5841, 0.7173, 0.5962, 0.7387]}, {"w": "fh", "b": [0.6027, 0.717, 0.6147, 0.7396]}, {"w": "–", "b": [0.6213, 0.7173, 0.6321, 0.7387]}, {"w": "1,", "b": [0.6386, 0.7173, 0.6534, 0.7387]}, {"w": "columns", "b": [0.6599, 0.7173, 0.7318, 0.7387]}, {"w": "j", "b": [0.7383, 0.717, 0.7438, 0.7387]}, {"w": "to", "b": [0.7503, 0.7173, 0.7673, 0.7387]}, {"w": "j", "b": [0.7738, 0.717, 0.7794, 0.7387]}, {"w": "+", "b": [0.7859, 0.7173, 0.798, 0.7387]}, {"w": "fw", "b": [0.8045, 0.717, 0.8185, 0.7396]}, {"w": "–", "b": [0.825, 0.7173, 0.8359, 0.7387]}, {"w": "1,", "b": [0.8424, 0.7173, 0.8571, 0.7387]}, {"w": "where", "b": [0.1429, 0.7363, 0.1937, 0.7577]}, {"w": "fh", "b": [0.2007, 0.7361, 0.2127, 0.7586]}, {"w": "and", "b": [0.2197, 0.7363, 0.2512, 0.7577]}, {"w": "fw", "b": [0.2582, 0.7361, 0.2722, 0.7586]}, {"w": "are", "b": [0.2792, 0.7363, 0.3049, 0.7577]}, {"w": "the", "b": [0.3119, 0.7363, 0.3382, 0.7577]}, {"w": "height", "b": [0.3452, 0.7363, 0.3975, 0.7577]}, {"w": "and", "b": [0.4045, 0.7363, 0.4361, 0.7577]}, {"w": "width", "b": [0.443, 0.7363, 0.4914, 0.7577]}, {"w": "of", "b": [0.4983, 0.7363, 0.5151, 0.7577]}, {"w": "the", "b": [0.5221, 0.7363, 0.5484, 0.7577]}, {"w": "receptive", "b": [0.5554, 0.7363, 0.631, 0.7577]}, {"w": "field", "b": [0.638, 0.7363, 0.6748, 0.7577]}, {"w": "(see", "b": [0.6818, 0.7363, 0.7144, 0.7577]}, {"w": "Figure", "b": [0.7213, 0.7363, 0.7753, 0.7577]}, {"w": "14-3).", "b": [0.7823, 0.7363, 0.8317, 0.7577]}, {"w": "In", "b": [0.8386, 0.7363, 0.8571, 0.7577]}, {"w": "order", "b": [0.1428, 0.7554, 0.1888, 0.7768]}, {"w": "for", "b": [0.1953, 0.7554, 0.2198, 0.7768]}, {"w": "a", "b": [0.2262, 0.7554, 0.2354, 0.7768]}, {"w": "layer", "b": [0.2418, 0.7554, 0.282, 0.7768]}, {"w": "to", "b": [0.2885, 0.7554, 0.3055, 0.7768]}, {"w": "have", "b": [0.3119, 0.7554, 0.3503, 0.7768]}, {"w": "the", "b": [0.3568, 0.7554, 0.3831, 0.7768]}, {"w": "same", "b": [0.3896, 0.7554, 0.4323, 0.7768]}, {"w": "height", "b": [0.4388, 0.7554, 0.4912, 0.7768]}, {"w": "and", "b": [0.4976, 0.7554, 0.5292, 0.7768]}, {"w": "width", "b": [0.5356, 0.7554, 0.584, 0.7768]}, {"w": "as", "b": [0.5904, 0.7554, 0.6072, 0.7768]}, {"w": "the", "b": [0.6137, 0.7554, 0.64, 0.7768]}, {"w": "previous", "b": [0.6465, 0.7554, 0.7186, 0.7768]}, {"w": "layer,", "b": [0.725, 0.7554, 0.7687, 0.7768]}, {"w": "it", "b": [0.7751, 0.7554, 0.7871, 0.7768]}, {"w": "is", "b": [0.7935, 0.7554, 0.8068, 0.7768]}, {"w": "com‐", "b": [0.8132, 0.7554, 0.8571, 0.7768]}]}, {"id": "b_6", "type": "paragraph", "text": "434 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "434", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3683, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 461, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "mon to add zeros around the inputs, as shown in the diagram. This is called zero pad‐ ding.", "words": [{"w": "mon", "b": [0.1429, 0.0791, 0.1819, 0.1005]}, {"w": "to", "b": [0.1869, 0.0791, 0.2039, 0.1005]}, {"w": "add", "b": [0.2088, 0.0791, 0.2399, 0.1005]}, {"w": "zeros", "b": [0.2449, 0.0791, 0.2885, 0.1005]}, {"w": "around", "b": [0.2934, 0.0791, 0.3544, 0.1005]}, {"w": "the", "b": [0.3593, 0.0791, 0.3856, 0.1005]}, {"w": "inputs,", "b": [0.3906, 0.0791, 0.4479, 0.1005]}, {"w": "as", "b": [0.4528, 0.0791, 0.4696, 0.1005]}, {"w": "shown", "b": [0.4745, 0.0791, 0.5296, 0.1005]}, {"w": "in", "b": [0.5345, 0.0791, 0.5515, 0.1005]}, {"w": "the", "b": [0.5564, 0.0791, 0.5828, 0.1005]}, {"w": "diagram.", "b": [0.5877, 0.0791, 0.6619, 0.1005]}, {"w": "This", "b": [0.6668, 0.0791, 0.704, 0.1005]}, {"w": "is", "b": [0.7089, 0.0791, 0.7222, 0.1005]}, {"w": "called", "b": [0.7271, 0.0791, 0.7755, 0.1005]}, {"w": "zero", "b": [0.7804, 0.0789, 0.8145, 0.1005]}, {"w": "pad‐", "b": [0.8193, 0.0789, 0.8569, 0.1005]}, {"w": "ding.", "b": [0.1429, 0.0979, 0.1829, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "Figure 14-3. Connections between layers and zero padding", "words": [{"w": "Figure", "b": [0.1429, 0.4167, 0.1943, 0.4383]}, {"w": "14-3.", "b": [0.1991, 0.4167, 0.2407, 0.4383]}, {"w": "Connections", "b": [0.2455, 0.4167, 0.3458, 0.4383]}, {"w": "between", "b": [0.3506, 0.4167, 0.4167, 0.4383]}, {"w": "layers", "b": [0.4215, 0.4167, 0.4683, 0.4383]}, {"w": "and", "b": [0.4731, 0.4167, 0.5045, 0.4383]}, {"w": "zero", "b": [0.5093, 0.4167, 0.5434, 0.4383]}, {"w": "padding", "b": [0.5482, 0.4167, 0.614, 0.4383]}]}, {"id": "b_2", "type": "paragraph", "text": "It is also possible to connect a large input layer to a much smaller layer by spacing out the receptive fields, as shown in Figure 14-4. The shift from one receptive field to the next is called the stride. In the diagram, a 5 × 7 input layer (plus zero padding) is con‐ nected to a 3 × 4 layer, using 3 × 3 receptive fields and a stride of 2 (in this example the stride is the same in both directions, but it does not have to be so). A neuron loca‐ ted in row i, column j in the upper layer is connected to the outputs of the neurons in the previous layer located in rows i × sh to i × sh + fh – 1, columns j × sw to j × sw + fw – 1, where sh and sw are the vertical and horizontal strides.", "words": [{"w": "It", "b": [0.1429, 0.4541, 0.1555, 0.4755]}, {"w": "is", "b": [0.1604, 0.4541, 0.1737, 0.4755]}, {"w": "also", "b": [0.1786, 0.4541, 0.2113, 0.4755]}, {"w": "possible", "b": [0.2162, 0.4541, 0.2834, 0.4755]}, {"w": "to", "b": [0.2883, 0.4541, 0.3053, 0.4755]}, {"w": "connect", "b": [0.3102, 0.4541, 0.3765, 0.4755]}, {"w": "a", "b": [0.3814, 0.4541, 0.3906, 0.4755]}, {"w": "large", "b": [0.3955, 0.4541, 0.4362, 0.4755]}, {"w": "input", "b": [0.4412, 0.4541, 0.4861, 0.4755]}, {"w": "layer", "b": [0.491, 0.4541, 0.5312, 0.4755]}, {"w": "to", "b": [0.5362, 0.4541, 0.5532, 0.4755]}, {"w": "a", "b": [0.5581, 0.4541, 0.5672, 0.4755]}, {"w": "much", "b": [0.5722, 0.4541, 0.6198, 0.4755]}, {"w": "smaller", "b": [0.6248, 0.4541, 0.6858, 0.4755]}, {"w": "layer", "b": [0.6907, 0.4541, 0.7309, 0.4755]}, {"w": "by", "b": [0.7358, 0.4541, 0.756, 0.4755]}, {"w": "spacing", "b": [0.7609, 0.4541, 0.8242, 0.4755]}, {"w": "out", "b": [0.8291, 0.4541, 0.8571, 0.4755]}, {"w": "the", "b": [0.1429, 0.4731, 0.1692, 0.4946]}, {"w": "receptive", "b": [0.1745, 0.4731, 0.2501, 0.4946]}, {"w": "fields,", "b": [0.2555, 0.4731, 0.3047, 0.4946]}, {"w": "as", "b": [0.3101, 0.4731, 0.3269, 0.4946]}, {"w": "shown", "b": [0.3322, 0.4731, 0.3873, 0.4946]}, {"w": "in", "b": [0.3926, 0.4731, 0.4096, 0.4946]}, {"w": "Figure", "b": [0.4149, 0.4731, 0.4689, 0.4946]}, {"w": "14-4.", "b": [0.4737, 0.4731, 0.5165, 0.4946]}, {"w": "The", "b": [0.5218, 0.4731, 0.5546, 0.4946]}, {"w": "shift", "b": [0.56, 0.4731, 0.5969, 0.4946]}, {"w": "from", "b": [0.6022, 0.4731, 0.6438, 0.4946]}, {"w": "one", "b": [0.6491, 0.4731, 0.68, 0.4946]}, {"w": "receptive", "b": [0.6853, 0.4731, 0.7609, 0.4946]}, {"w": "field", "b": [0.7663, 0.4731, 0.8032, 0.4946]}, {"w": "to", "b": [0.8085, 0.4731, 0.8255, 0.4946]}, {"w": "the", "b": [0.8308, 0.4731, 0.8572, 0.4946]}, {"w": "next", "b": [0.1429, 0.4922, 0.1793, 0.5136]}, {"w": "is", "b": [0.184, 0.4922, 0.1973, 0.5136]}, {"w": "called", "b": [0.202, 0.4922, 0.2503, 0.5136]}, {"w": "the", "b": [0.2557, 0.4922, 0.282, 0.5136]}, {"w": "stride.", "b": [0.287, 0.492, 0.337, 0.5136]}, {"w": "In", "b": [0.342, 0.4922, 0.3605, 0.5136]}, {"w": "the", "b": [0.3654, 0.4922, 0.3918, 0.5136]}, {"w": "diagram,", "b": [0.3967, 0.4922, 0.4709, 0.5136]}, {"w": "a", "b": [0.4758, 0.4922, 0.485, 0.5136]}, {"w": "5", "b": [0.4899, 0.4922, 0.4999, 0.5136]}, {"w": "×", "b": [0.5049, 0.4922, 0.5169, 0.5136]}, {"w": "7", "b": [0.5219, 0.4922, 0.5319, 0.5136]}, {"w": "input", "b": [0.5368, 0.4922, 0.5817, 0.5136]}, {"w": "layer", "b": [0.5867, 0.4922, 0.6269, 0.5136]}, {"w": "(plus", "b": [0.6318, 0.4922, 0.6739, 0.5136]}, {"w": "zero", "b": [0.6789, 0.4922, 0.7148, 0.5136]}, {"w": "padding)", "b": [0.7198, 0.4922, 0.7958, 0.5136]}, {"w": "is", "b": [0.8007, 0.4922, 0.814, 0.5136]}, {"w": "con‐", "b": [0.8189, 0.4922, 0.8572, 0.5136]}, {"w": "nected", "b": [0.1429, 0.5112, 0.1981, 0.5326]}, {"w": "to", "b": [0.2042, 0.5112, 0.2211, 0.5326]}, {"w": "a", "b": [0.2272, 0.5112, 0.2363, 0.5326]}, {"w": "3", "b": [0.2423, 0.5112, 0.2523, 0.5326]}, {"w": "×", "b": [0.2583, 0.5112, 0.2704, 0.5326]}, {"w": "4", "b": [0.2765, 0.5112, 0.2865, 0.5326]}, {"w": "layer,", "b": [0.2925, 0.5112, 0.3361, 0.5326]}, {"w": "using", "b": [0.3421, 0.5112, 0.3876, 0.5326]}, {"w": "3", "b": [0.3936, 0.5112, 0.4036, 0.5326]}, {"w": "×", "b": [0.4096, 0.5112, 0.4217, 0.5326]}, {"w": "3", "b": [0.4277, 0.5112, 0.4377, 0.5326]}, {"w": "receptive", "b": [0.4437, 0.5112, 0.5193, 0.5326]}, {"w": "fields", "b": [0.5254, 0.5112, 0.5699, 0.5326]}, {"w": "and", "b": [0.5759, 0.5112, 0.6074, 0.5326]}, {"w": "a", "b": [0.6135, 0.5112, 0.6226, 0.5326]}, {"w": "stride", "b": [0.6286, 0.5112, 0.6758, 0.5326]}, {"w": "of", "b": [0.6818, 0.5112, 0.6986, 0.5326]}, {"w": "2", "b": [0.7046, 0.5112, 0.7146, 0.5326]}, {"w": "(in", "b": [0.7207, 0.5112, 0.7449, 0.5326]}, {"w": "this", "b": [0.7509, 0.5112, 0.7816, 0.5326]}, {"w": "example", "b": [0.7876, 0.5112, 0.8571, 0.5326]}, {"w": "the", "b": [0.1429, 0.5303, 0.1692, 0.5517]}, {"w": "stride", "b": [0.174, 0.5303, 0.2211, 0.5517]}, {"w": "is", "b": [0.2259, 0.5303, 0.2392, 0.5517]}, {"w": "the", "b": [0.244, 0.5303, 0.2703, 0.5517]}, {"w": "same", "b": [0.2751, 0.5303, 0.3178, 0.5517]}, {"w": "in", "b": [0.3226, 0.5303, 0.3396, 0.5517]}, {"w": "both", "b": [0.3444, 0.5303, 0.3831, 0.5517]}, {"w": "directions,", "b": [0.3879, 0.5303, 0.4762, 0.5517]}, {"w": "but", "b": [0.481, 0.5303, 0.509, 0.5517]}, {"w": "it", "b": [0.5138, 0.5303, 0.5257, 0.5517]}, {"w": "does", "b": [0.5305, 0.5303, 0.5686, 0.5517]}, {"w": "not", "b": [0.5734, 0.5303, 0.6018, 0.5517]}, {"w": "have", "b": [0.6066, 0.5303, 0.645, 0.5517]}, {"w": "to", "b": [0.6498, 0.5303, 0.6668, 0.5517]}, {"w": "be", "b": [0.6716, 0.5303, 0.691, 0.5517]}, {"w": "so).", "b": [0.6958, 0.5303, 0.726, 0.5517]}, {"w": "A", "b": [0.7308, 0.5303, 0.7452, 0.5517]}, {"w": "neuron", "b": [0.75, 0.5303, 0.8111, 0.5517]}, {"w": "loca‐", "b": [0.8159, 0.5303, 0.8571, 0.5517]}, {"w": "ted", "b": [0.1428, 0.5493, 0.1691, 0.5707]}, {"w": "in", "b": [0.174, 0.5493, 0.191, 0.5707]}, {"w": "row", "b": [0.196, 0.5493, 0.2286, 0.5707]}, {"w": "i,", "b": [0.2336, 0.5491, 0.2441, 0.5707]}, {"w": "column", "b": [0.2488, 0.5493, 0.313, 0.5707]}, {"w": "j", "b": [0.3183, 0.5491, 0.3238, 0.5707]}, {"w": "in", "b": [0.3288, 0.5493, 0.3458, 0.5707]}, {"w": "the", "b": [0.3508, 0.5493, 0.3771, 0.5707]}, {"w": "upper", "b": [0.3821, 0.5493, 0.4316, 0.5707]}, {"w": "layer", "b": [0.4366, 0.5493, 0.4768, 0.5707]}, {"w": "is", "b": [0.4818, 0.5493, 0.495, 0.5707]}, {"w": "connected", "b": [0.5, 0.5493, 0.5861, 0.5707]}, {"w": "to", "b": [0.5911, 0.5493, 0.608, 0.5707]}, {"w": "the", "b": [0.613, 0.5493, 0.6394, 0.5707]}, {"w": "outputs", "b": [0.6444, 0.5493, 0.7084, 0.5707]}, {"w": "of", "b": [0.7134, 0.5493, 0.7302, 0.5707]}, {"w": "the", "b": [0.7351, 0.5493, 0.7615, 0.5707]}, {"w": "neurons", "b": [0.7665, 0.5493, 0.8352, 0.5707]}, {"w": "in", "b": [0.8402, 0.5493, 0.8571, 0.5707]}, {"w": "the", "b": [0.1429, 0.5684, 0.1692, 0.5898]}, {"w": "previous", "b": [0.1743, 0.5684, 0.2464, 0.5898]}, {"w": "layer", "b": [0.2515, 0.5684, 0.2917, 0.5898]}, {"w": "located", "b": [0.2968, 0.5684, 0.3564, 0.5898]}, {"w": "in", "b": [0.3615, 0.5684, 0.3785, 0.5898]}, {"w": "rows", "b": [0.3836, 0.5684, 0.4239, 0.5898]}, {"w": "i", "b": [0.429, 0.5682, 0.4347, 0.5898]}, {"w": "×", "b": [0.4398, 0.5684, 0.4519, 0.5898]}, {"w": "sh", "b": [0.457, 0.5682, 0.4704, 0.5907]}, {"w": "to", "b": [0.4755, 0.5684, 0.4925, 0.5898]}, {"w": "i", "b": [0.4976, 0.5682, 0.5033, 0.5898]}, {"w": "×", "b": [0.5084, 0.5684, 0.5205, 0.5898]}, {"w": "sh", "b": [0.5256, 0.5682, 0.539, 0.5907]}, {"w": "+", "b": [0.5441, 0.5684, 0.5562, 0.5898]}, {"w": "fh", "b": [0.5613, 0.5682, 0.5733, 0.5907]}, {"w": "–", "b": [0.5784, 0.5684, 0.5893, 0.5898]}, {"w": "1,", "b": [0.5944, 0.5684, 0.6091, 0.5898]}, {"w": "columns", "b": [0.6142, 0.5684, 0.6861, 0.5898]}, {"w": "j", "b": [0.6912, 0.5682, 0.6967, 0.5898]}, {"w": "×", "b": [0.7019, 0.5684, 0.714, 0.5898]}, {"w": "sw", "b": [0.7191, 0.5682, 0.7345, 0.5907]}, {"w": "to", "b": [0.7396, 0.5684, 0.7565, 0.5898]}, {"w": "j", "b": [0.7616, 0.5682, 0.7672, 0.5898]}, {"w": "×", "b": [0.7723, 0.5684, 0.7844, 0.5898]}, {"w": "sw", "b": [0.7895, 0.5682, 0.8049, 0.5907]}, {"w": "+", "b": [0.81, 0.5684, 0.8221, 0.5898]}, {"w": "fw", "b": [0.8272, 0.5682, 0.8412, 0.5907]}, {"w": "–", "b": [0.8463, 0.5684, 0.8571, 0.5898]}, {"w": "1,", "b": [0.1429, 0.5874, 0.1576, 0.6088]}, {"w": "where", "b": [0.1623, 0.5874, 0.2132, 0.6088]}, {"w": "sh", "b": [0.2179, 0.5872, 0.2313, 0.6097]}, {"w": "and", "b": [0.236, 0.5874, 0.2676, 0.6088]}, {"w": "sw", "b": [0.2723, 0.5872, 0.2877, 0.6097]}, {"w": "are", "b": [0.2924, 0.5874, 0.3182, 0.6088]}, {"w": "the", "b": [0.3229, 0.5874, 0.3492, 0.6088]}, {"w": "vertical", "b": [0.3539, 0.5874, 0.4153, 0.6088]}, {"w": "and", "b": [0.4201, 0.5874, 0.4516, 0.6088]}, {"w": "horizontal", "b": [0.4563, 0.5874, 0.5425, 0.6088]}, {"w": "strides.", "b": [0.5473, 0.5874, 0.6068, 0.6088]}]}, {"id": "b_3", "type": "paragraph", "text": "Convolutional Layer | 435", "words": [{"w": "Convolutional", "b": [0.6789, 0.9225, 0.7609, 0.9388]}, {"w": "Layer", "b": [0.7637, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "435", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 462, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 14-4. Reducing dimensionality using a stride of 2", "words": [{"w": "Figure", "b": [0.1429, 0.3493, 0.1943, 0.3709]}, {"w": "14-4.", "b": [0.1991, 0.3493, 0.2407, 0.3709]}, {"w": "Reducing", "b": [0.2455, 0.3493, 0.3204, 0.3709]}, {"w": "dimensionality", "b": [0.3252, 0.3493, 0.4454, 0.3709]}, {"w": "using", "b": [0.4502, 0.3493, 0.4931, 0.3709]}, {"w": "a", "b": [0.4979, 0.3493, 0.5081, 0.3709]}, {"w": "stride", "b": [0.5129, 0.3493, 0.5582, 0.3709]}, {"w": "of", "b": [0.5629, 0.3493, 0.5781, 0.3709]}, {"w": "2", "b": [0.5829, 0.3493, 0.5929, 0.3709]}]}, {"id": "b_1", "type": "paragraph", "text": "Filters", "words": [{"w": "Filters", "b": [0.1428, 0.384, 0.2069, 0.4125]}]}, {"id": "b_2", "type": "paragraph", "text": "A neuron’s weights can be represented as a small image the size of the receptive field. For example, Figure 14-5 shows two possible sets of weights, called filters (or convolu‐ tion kernels). The first one is represented as a black square with a vertical white line in the middle (it is a 7 × 7 matrix full of 0s except for the central column, which is full of 1s); neurons using these weights will ignore everything in their receptive field except for the central vertical line (since all inputs will get multiplied by 0, except for the ones located in the central vertical line). The second filter is a black square with a horizontal white line in the middle. Once again, neurons using these weights will ignore everything in their receptive field except for the central horizontal line.", "words": [{"w": "A", "b": [0.1429, 0.4184, 0.1573, 0.4398]}, {"w": "neuron’s", "b": [0.1627, 0.4184, 0.2324, 0.4398]}, {"w": "weights", "b": [0.2379, 0.4184, 0.3011, 0.4398]}, {"w": "can", "b": [0.3065, 0.4184, 0.3359, 0.4398]}, {"w": "be", "b": [0.3414, 0.4184, 0.3608, 0.4398]}, {"w": "represented", "b": [0.3663, 0.4184, 0.4641, 0.4398]}, {"w": "as", "b": [0.4696, 0.4184, 0.4864, 0.4398]}, {"w": "a", "b": [0.4918, 0.4184, 0.501, 0.4398]}, {"w": "small", "b": [0.5065, 0.4184, 0.5509, 0.4398]}, {"w": "image", "b": [0.5563, 0.4184, 0.6067, 0.4398]}, {"w": "the", "b": [0.6122, 0.4184, 0.6386, 0.4398]}, {"w": "size", "b": [0.644, 0.4184, 0.6749, 0.4398]}, {"w": "of", "b": [0.6803, 0.4184, 0.6971, 0.4398]}, {"w": "the", "b": [0.7026, 0.4184, 0.729, 0.4398]}, {"w": "receptive", "b": [0.7344, 0.4184, 0.81, 0.4398]}, {"w": "field.", "b": [0.8155, 0.4184, 0.8571, 0.4398]}, {"w": "For", "b": [0.1429, 0.4375, 0.1718, 0.4589]}, {"w": "example,", "b": [0.1766, 0.4375, 0.2509, 0.4589]}, {"w": "Figure", "b": [0.2562, 0.4375, 0.3102, 0.4589]}, {"w": "14-5", "b": [0.3149, 0.4375, 0.3523, 0.4589]}, {"w": "shows", "b": [0.3577, 0.4375, 0.409, 0.4589]}, {"w": "two", "b": [0.414, 0.4375, 0.4453, 0.4589]}, {"w": "possible", "b": [0.4503, 0.4375, 0.5174, 0.4589]}, {"w": "sets", "b": [0.5224, 0.4375, 0.5529, 0.4589]}, {"w": "of", "b": [0.558, 0.4375, 0.5748, 0.4589]}, {"w": "weights,", "b": [0.5798, 0.4375, 0.6477, 0.4589]}, {"w": "called", "b": [0.6528, 0.4375, 0.7011, 0.4589]}, {"w": "filters", "b": [0.7061, 0.4373, 0.7518, 0.4589]}, {"w": "(or", "b": [0.7568, 0.4375, 0.7824, 0.4589]}, {"w": "convolu‐", "b": [0.7874, 0.4373, 0.8571, 0.4589]}, {"w": "tion", "b": [0.1429, 0.4563, 0.1753, 0.4779]}, {"w": "kernels).", "b": [0.1801, 0.4563, 0.2492, 0.4779]}, {"w": "The", "b": [0.254, 0.4565, 0.2868, 0.4779]}, {"w": "first", "b": [0.2917, 0.4565, 0.3252, 0.4779]}, {"w": "one", "b": [0.33, 0.4565, 0.3609, 0.4779]}, {"w": "is", "b": [0.3657, 0.4565, 0.3789, 0.4779]}, {"w": "represented", "b": [0.3837, 0.4565, 0.4815, 0.4779]}, {"w": "as", "b": [0.4864, 0.4565, 0.5032, 0.4779]}, {"w": "a", "b": [0.508, 0.4565, 0.5171, 0.4779]}, {"w": "black", "b": [0.522, 0.4565, 0.5661, 0.4779]}, {"w": "square", "b": [0.5709, 0.4565, 0.626, 0.4779]}, {"w": "with", "b": [0.6309, 0.4565, 0.6682, 0.4779]}, {"w": "a", "b": [0.673, 0.4565, 0.6822, 0.4779]}, {"w": "vertical", "b": [0.687, 0.4565, 0.7484, 0.4779]}, {"w": "white", "b": [0.7532, 0.4565, 0.7994, 0.4779]}, {"w": "line", "b": [0.8042, 0.4565, 0.8353, 0.4779]}, {"w": "in", "b": [0.8402, 0.4565, 0.8571, 0.4779]}, {"w": "the", "b": [0.1429, 0.4756, 0.1692, 0.497]}, {"w": "middle", "b": [0.1741, 0.4756, 0.2329, 0.497]}, {"w": "(it", "b": [0.2378, 0.4756, 0.257, 0.497]}, {"w": "is", "b": [0.2619, 0.4756, 0.2751, 0.497]}, {"w": "a", "b": [0.2801, 0.4756, 0.2892, 0.497]}, {"w": "7", "b": [0.2942, 0.4756, 0.3042, 0.497]}, {"w": "×", "b": [0.3091, 0.4756, 0.3212, 0.497]}, {"w": "7", "b": [0.3261, 0.4756, 0.3361, 0.497]}, {"w": "matrix", "b": [0.341, 0.4756, 0.3964, 0.497]}, {"w": "full", "b": [0.4013, 0.4756, 0.4291, 0.497]}, {"w": "of", "b": [0.434, 0.4756, 0.4508, 0.497]}, {"w": "0s", "b": [0.4557, 0.4756, 0.4734, 0.497]}, {"w": "except", "b": [0.4783, 0.4756, 0.5319, 0.497]}, {"w": "for", "b": [0.5369, 0.4756, 0.5614, 0.497]}, {"w": "the", "b": [0.5663, 0.4756, 0.5927, 0.497]}, {"w": "central", "b": [0.5976, 0.4756, 0.6548, 0.497]}, {"w": "column,", "b": [0.6597, 0.4756, 0.7287, 0.497]}, {"w": "which", "b": [0.7336, 0.4756, 0.7845, 0.497]}, {"w": "is", "b": [0.7895, 0.4756, 0.8027, 0.497]}, {"w": "full", "b": [0.8076, 0.4756, 0.8354, 0.497]}, {"w": "of", "b": [0.8403, 0.4756, 0.8571, 0.497]}, {"w": "1s);", "b": [0.1429, 0.4946, 0.1725, 0.516]}, {"w": "neurons", "b": [0.1781, 0.4946, 0.2468, 0.516]}, {"w": "using", "b": [0.2525, 0.4946, 0.2979, 0.516]}, {"w": "these", "b": [0.3036, 0.4946, 0.3464, 0.516]}, {"w": "weights", "b": [0.3521, 0.4946, 0.4153, 0.516]}, {"w": "will", "b": [0.421, 0.4946, 0.4514, 0.516]}, {"w": "ignore", "b": [0.457, 0.4946, 0.511, 0.516]}, {"w": "everything", "b": [0.5166, 0.4946, 0.6061, 0.516]}, {"w": "in", "b": [0.6118, 0.4946, 0.6287, 0.516]}, {"w": "their", "b": [0.6344, 0.4946, 0.674, 0.516]}, {"w": "receptive", "b": [0.6797, 0.4946, 0.7553, 0.516]}, {"w": "field", "b": [0.761, 0.4946, 0.7979, 0.516]}, {"w": "except", "b": [0.8035, 0.4946, 0.8572, 0.516]}, {"w": "for", "b": [0.1429, 0.5137, 0.1674, 0.5351]}, {"w": "the", "b": [0.1748, 0.5137, 0.2011, 0.5351]}, {"w": "central", "b": [0.2085, 0.5137, 0.2656, 0.5351]}, {"w": "vertical", "b": [0.273, 0.5137, 0.3344, 0.5351]}, {"w": "line", "b": [0.3418, 0.5137, 0.3729, 0.5351]}, {"w": "(since", "b": [0.3803, 0.5137, 0.4298, 0.5351]}, {"w": "all", "b": [0.4372, 0.5137, 0.4569, 0.5351]}, {"w": "inputs", "b": [0.4642, 0.5137, 0.5168, 0.5351]}, {"w": "will", "b": [0.5242, 0.5137, 0.5546, 0.5351]}, {"w": "get", "b": [0.562, 0.5137, 0.5869, 0.5351]}, {"w": "multiplied", "b": [0.5943, 0.5137, 0.6809, 0.5351]}, {"w": "by", "b": [0.6882, 0.5137, 0.7084, 0.5351]}, {"w": "0,", "b": [0.7158, 0.5137, 0.7305, 0.5351]}, {"w": "except", "b": [0.7379, 0.5137, 0.7915, 0.5351]}, {"w": "for", "b": [0.7989, 0.5137, 0.8234, 0.5351]}, {"w": "the", "b": [0.8308, 0.5137, 0.8571, 0.5351]}, {"w": "ones", "b": [0.1429, 0.5327, 0.1814, 0.5541]}, {"w": "located", "b": [0.1888, 0.5327, 0.2485, 0.5541]}, {"w": "in", "b": [0.256, 0.5327, 0.2729, 0.5541]}, {"w": "the", "b": [0.2804, 0.5327, 0.3067, 0.5541]}, {"w": "central", "b": [0.3142, 0.5327, 0.3714, 0.5541]}, {"w": "vertical", "b": [0.3788, 0.5327, 0.4402, 0.5541]}, {"w": "line).", "b": [0.4477, 0.5327, 0.4908, 0.5541]}, {"w": "The", "b": [0.4982, 0.5327, 0.5311, 0.5541]}, {"w": "second", "b": [0.5385, 0.5327, 0.5969, 0.5541]}, {"w": "filter", "b": [0.6043, 0.5327, 0.6443, 0.5541]}, {"w": "is", "b": [0.6517, 0.5327, 0.665, 0.5541]}, {"w": "a", "b": [0.6724, 0.5327, 0.6816, 0.5541]}, {"w": "black", "b": [0.689, 0.5327, 0.7332, 0.5541]}, {"w": "square", "b": [0.7407, 0.5327, 0.7957, 0.5541]}, {"w": "with", "b": [0.8032, 0.5327, 0.8405, 0.5541]}, {"w": "a", "b": [0.848, 0.5327, 0.8571, 0.5541]}, {"w": "horizontal", "b": [0.1428, 0.5518, 0.2291, 0.5732]}, {"w": "white", "b": [0.2373, 0.5518, 0.2835, 0.5732]}, {"w": "line", "b": [0.2917, 0.5518, 0.3228, 0.5732]}, {"w": "in", "b": [0.3311, 0.5518, 0.3481, 0.5732]}, {"w": "the", "b": [0.3563, 0.5518, 0.3827, 0.5732]}, {"w": "middle.", "b": [0.3909, 0.5518, 0.4544, 0.5732]}, {"w": "Once", "b": [0.4627, 0.5518, 0.5073, 0.5732]}, {"w": "again,", "b": [0.5156, 0.5518, 0.5653, 0.5732]}, {"w": "neurons", "b": [0.5736, 0.5518, 0.6423, 0.5732]}, {"w": "using", "b": [0.6505, 0.5518, 0.696, 0.5732]}, {"w": "these", "b": [0.7042, 0.5518, 0.7471, 0.5732]}, {"w": "weights", "b": [0.7553, 0.5518, 0.8185, 0.5732]}, {"w": "will", "b": [0.8267, 0.5518, 0.8571, 0.5732]}, {"w": "ignore", "b": [0.1429, 0.5708, 0.1968, 0.5922]}, {"w": "everything", "b": [0.2015, 0.5708, 0.291, 0.5922]}, {"w": "in", "b": [0.2957, 0.5708, 0.3127, 0.5922]}, {"w": "their", "b": [0.3174, 0.5708, 0.3571, 0.5922]}, {"w": "receptive", "b": [0.3618, 0.5708, 0.4374, 0.5922]}, {"w": "field", "b": [0.4421, 0.5708, 0.479, 0.5922]}, {"w": "except", "b": [0.4837, 0.5708, 0.5374, 0.5922]}, {"w": "for", "b": [0.5421, 0.5708, 0.5666, 0.5922]}, {"w": "the", "b": [0.5713, 0.5708, 0.5977, 0.5922]}, {"w": "central", "b": [0.6024, 0.5708, 0.6596, 0.5922]}, {"w": "horizontal", "b": [0.6643, 0.5708, 0.7505, 0.5922]}, {"w": "line.", "b": [0.7552, 0.5708, 0.7911, 0.5922]}]}, {"id": "b_3", "type": "paragraph", "text": "Now if all neurons in a layer use the same vertical line filter (and the same bias term), and you feed the network the input image shown in Figure 14-5 (bottom image), the layer will output the top-left image. Notice that the vertical white lines get enhanced while the rest gets blurred. Similarly, the upper-right image is what you get if all neu‐ rons use the same horizontal line filter; notice that the horizontal white lines get enhanced while the rest is blurred out. Thus, a layer full of neurons using the same filter outputs a feature map, which highlights the areas in an image that activate the filter the most. Of course you do not have to define the filters manually: instead, dur‐ ing training the convolutional layer will automatically learn the most useful filters for its task, and the layers above will learn to combine them into more complex patterns.", "words": [{"w": "Now", "b": [0.1429, 0.5989, 0.1827, 0.6203]}, {"w": "if", "b": [0.1878, 0.5989, 0.1995, 0.6203]}, {"w": "all", "b": [0.2046, 0.5989, 0.2243, 0.6203]}, {"w": "neurons", "b": [0.2294, 0.5989, 0.2981, 0.6203]}, {"w": "in", "b": [0.3031, 0.5989, 0.3201, 0.6203]}, {"w": "a", "b": [0.3252, 0.5989, 0.3343, 0.6203]}, {"w": "layer", "b": [0.3394, 0.5989, 0.3796, 0.6203]}, {"w": "use", "b": [0.3847, 0.5989, 0.4122, 0.6203]}, {"w": "the", "b": [0.4173, 0.5989, 0.4436, 0.6203]}, {"w": "same", "b": [0.4487, 0.5989, 0.4914, 0.6203]}, {"w": "vertical", "b": [0.4965, 0.5989, 0.5579, 0.6203]}, {"w": "line", "b": [0.563, 0.5989, 0.5941, 0.6203]}, {"w": "filter", "b": [0.5991, 0.5989, 0.6391, 0.6203]}, {"w": "(and", "b": [0.6442, 0.5989, 0.6829, 0.6203]}, {"w": "the", "b": [0.688, 0.5989, 0.7143, 0.6203]}, {"w": "same", "b": [0.7194, 0.5989, 0.7621, 0.6203]}, {"w": "bias", "b": [0.7672, 0.5989, 0.8001, 0.6203]}, {"w": "term),", "b": [0.8052, 0.5989, 0.8571, 0.6203]}, {"w": "and", "b": [0.1429, 0.618, 0.1744, 0.6394]}, {"w": "you", "b": [0.18, 0.618, 0.2112, 0.6394]}, {"w": "feed", "b": [0.2168, 0.618, 0.2517, 0.6394]}, {"w": "the", "b": [0.2573, 0.618, 0.2836, 0.6394]}, {"w": "network", "b": [0.2892, 0.618, 0.3587, 0.6394]}, {"w": "the", "b": [0.3643, 0.618, 0.3907, 0.6394]}, {"w": "input", "b": [0.3962, 0.618, 0.4411, 0.6394]}, {"w": "image", "b": [0.4467, 0.618, 0.4971, 0.6394]}, {"w": "shown", "b": [0.5027, 0.618, 0.5578, 0.6394]}, {"w": "in", "b": [0.5633, 0.618, 0.5803, 0.6394]}, {"w": "Figure", "b": [0.5859, 0.618, 0.6399, 0.6394]}, {"w": "14-5", "b": [0.6455, 0.618, 0.6829, 0.6394]}, {"w": "(bottom", "b": [0.6885, 0.618, 0.7573, 0.6394]}, {"w": "image),", "b": [0.7629, 0.618, 0.8252, 0.6394]}, {"w": "the", "b": [0.8308, 0.618, 0.8571, 0.6394]}, {"w": "layer", "b": [0.1429, 0.637, 0.183, 0.6584]}, {"w": "will", "b": [0.189, 0.637, 0.2194, 0.6584]}, {"w": "output", "b": [0.2254, 0.637, 0.2818, 0.6584]}, {"w": "the", "b": [0.2878, 0.637, 0.3141, 0.6584]}, {"w": "top-left", "b": [0.3201, 0.637, 0.3821, 0.6584]}, {"w": "image.", "b": [0.3881, 0.637, 0.4432, 0.6584]}, {"w": "Notice", "b": [0.4492, 0.637, 0.5044, 0.6584]}, {"w": "that", "b": [0.5104, 0.637, 0.543, 0.6584]}, {"w": "the", "b": [0.549, 0.637, 0.5753, 0.6584]}, {"w": "vertical", "b": [0.5813, 0.637, 0.6427, 0.6584]}, {"w": "white", "b": [0.6487, 0.637, 0.6949, 0.6584]}, {"w": "lines", "b": [0.7009, 0.637, 0.7396, 0.6584]}, {"w": "get", "b": [0.7456, 0.637, 0.7706, 0.6584]}, {"w": "enhanced", "b": [0.7766, 0.637, 0.8571, 0.6584]}, {"w": "while", "b": [0.1429, 0.6561, 0.188, 0.6775]}, {"w": "the", "b": [0.1934, 0.6561, 0.2197, 0.6775]}, {"w": "rest", "b": [0.2251, 0.6561, 0.2557, 0.6775]}, {"w": "gets", "b": [0.2611, 0.6561, 0.2937, 0.6775]}, {"w": "blurred.", "b": [0.2991, 0.6561, 0.3661, 0.6775]}, {"w": "Similarly,", "b": [0.3715, 0.6561, 0.4498, 0.6775]}, {"w": "the", "b": [0.4552, 0.6561, 0.4815, 0.6775]}, {"w": "upper-right", "b": [0.4869, 0.6561, 0.5835, 0.6775]}, {"w": "image", "b": [0.5889, 0.6561, 0.6393, 0.6775]}, {"w": "is", "b": [0.6447, 0.6561, 0.6579, 0.6775]}, {"w": "what", "b": [0.6633, 0.6561, 0.7038, 0.6775]}, {"w": "you", "b": [0.7092, 0.6561, 0.7404, 0.6775]}, {"w": "get", "b": [0.7458, 0.6561, 0.7708, 0.6775]}, {"w": "if", "b": [0.7762, 0.6561, 0.7879, 0.6775]}, {"w": "all", "b": [0.7933, 0.6561, 0.813, 0.6775]}, {"w": "neu‐", "b": [0.8184, 0.6561, 0.8572, 0.6775]}, {"w": "rons", "b": [0.1429, 0.6751, 0.1803, 0.6965]}, {"w": "use", "b": [0.1888, 0.6751, 0.2164, 0.6965]}, {"w": "the", "b": [0.2249, 0.6751, 0.2512, 0.6965]}, {"w": "same", "b": [0.2598, 0.6751, 0.3025, 0.6965]}, {"w": "horizontal", "b": [0.3111, 0.6751, 0.3973, 0.6965]}, {"w": "line", "b": [0.4058, 0.6751, 0.4369, 0.6965]}, {"w": "filter;", "b": [0.4455, 0.6751, 0.4907, 0.6965]}, {"w": "notice", "b": [0.4992, 0.6751, 0.5508, 0.6965]}, {"w": "that", "b": [0.5594, 0.6751, 0.592, 0.6965]}, {"w": "the", "b": [0.6005, 0.6751, 0.6269, 0.6965]}, {"w": "horizontal", "b": [0.6354, 0.6751, 0.7216, 0.6965]}, {"w": "white", "b": [0.7302, 0.6751, 0.7763, 0.6965]}, {"w": "lines", "b": [0.7849, 0.6751, 0.8236, 0.6965]}, {"w": "get", "b": [0.8322, 0.6751, 0.8571, 0.6965]}, {"w": "enhanced", "b": [0.1429, 0.6942, 0.2234, 0.7156]}, {"w": "while", "b": [0.2301, 0.6942, 0.2752, 0.7156]}, {"w": "the", "b": [0.2818, 0.6942, 0.3081, 0.7156]}, {"w": "rest", "b": [0.3147, 0.6942, 0.3453, 0.7156]}, {"w": "is", "b": [0.3519, 0.6942, 0.3652, 0.7156]}, {"w": "blurred", "b": [0.3718, 0.6942, 0.434, 0.7156]}, {"w": "out.", "b": [0.4406, 0.6942, 0.4734, 0.7156]}, {"w": "Thus,", "b": [0.4801, 0.6942, 0.5271, 0.7156]}, {"w": "a", "b": [0.5337, 0.6942, 0.5429, 0.7156]}, {"w": "layer", "b": [0.5495, 0.6942, 0.5897, 0.7156]}, {"w": "full", "b": [0.5963, 0.6942, 0.6241, 0.7156]}, {"w": "of", "b": [0.6307, 0.6942, 0.6475, 0.7156]}, {"w": "neurons", "b": [0.6541, 0.6942, 0.7228, 0.7156]}, {"w": "using", "b": [0.7294, 0.6942, 0.7749, 0.7156]}, {"w": "the", "b": [0.7815, 0.6942, 0.8078, 0.7156]}, {"w": "same", "b": [0.8144, 0.6942, 0.8571, 0.7156]}, {"w": "filter", "b": [0.1428, 0.7132, 0.1828, 0.7346]}, {"w": "outputs", "b": [0.1893, 0.7132, 0.2533, 0.7346]}, {"w": "a", "b": [0.2598, 0.7132, 0.269, 0.7346]}, {"w": "feature", "b": [0.2755, 0.713, 0.3315, 0.7346]}, {"w": "map,", "b": [0.338, 0.713, 0.3791, 0.7346]}, {"w": "which", "b": [0.3856, 0.7132, 0.4365, 0.7346]}, {"w": "highlights", "b": [0.443, 0.7132, 0.526, 0.7346]}, {"w": "the", "b": [0.5325, 0.7132, 0.5588, 0.7346]}, {"w": "areas", "b": [0.5653, 0.7132, 0.6078, 0.7346]}, {"w": "in", "b": [0.6143, 0.7132, 0.6313, 0.7346]}, {"w": "an", "b": [0.6378, 0.7132, 0.6583, 0.7346]}, {"w": "image", "b": [0.6648, 0.7132, 0.7152, 0.7346]}, {"w": "that", "b": [0.7217, 0.7132, 0.7543, 0.7346]}, {"w": "activate", "b": [0.7608, 0.7132, 0.8243, 0.7346]}, {"w": "the", "b": [0.8308, 0.7132, 0.8571, 0.7346]}, {"w": "filter", "b": [0.1429, 0.7323, 0.1828, 0.7537]}, {"w": "the", "b": [0.188, 0.7323, 0.2143, 0.7537]}, {"w": "most.", "b": [0.2195, 0.7323, 0.266, 0.7537]}, {"w": "Of", "b": [0.2712, 0.7323, 0.2929, 0.7537]}, {"w": "course", "b": [0.2981, 0.7323, 0.3528, 0.7537]}, {"w": "you", "b": [0.358, 0.7323, 0.3892, 0.7537]}, {"w": "do", "b": [0.3944, 0.7323, 0.4161, 0.7537]}, {"w": "not", "b": [0.4212, 0.7323, 0.4496, 0.7537]}, {"w": "have", "b": [0.4548, 0.7323, 0.4932, 0.7537]}, {"w": "to", "b": [0.4984, 0.7323, 0.5154, 0.7537]}, {"w": "define", "b": [0.5206, 0.7323, 0.5724, 0.7537]}, {"w": "the", "b": [0.5776, 0.7323, 0.6039, 0.7537]}, {"w": "filters", "b": [0.6091, 0.7323, 0.6567, 0.7537]}, {"w": "manually:", "b": [0.6619, 0.7323, 0.7448, 0.7537]}, {"w": "instead,", "b": [0.75, 0.7323, 0.8148, 0.7537]}, {"w": "dur‐", "b": [0.8199, 0.7323, 0.8572, 0.7537]}, {"w": "ing", "b": [0.1429, 0.7513, 0.1696, 0.7727]}, {"w": "training", "b": [0.1749, 0.7513, 0.2418, 0.7727]}, {"w": "the", "b": [0.2471, 0.7513, 0.2734, 0.7727]}, {"w": "convolutional", "b": [0.2786, 0.7513, 0.394, 0.7727]}, {"w": "layer", "b": [0.3992, 0.7513, 0.4394, 0.7727]}, {"w": "will", "b": [0.4447, 0.7513, 0.4751, 0.7727]}, {"w": "automatically", "b": [0.4804, 0.7513, 0.593, 0.7727]}, {"w": "learn", "b": [0.5982, 0.7513, 0.6406, 0.7727]}, {"w": "the", "b": [0.6459, 0.7513, 0.6722, 0.7727]}, {"w": "most", "b": [0.6775, 0.7513, 0.7192, 0.7727]}, {"w": "useful", "b": [0.7244, 0.7513, 0.7745, 0.7727]}, {"w": "filters", "b": [0.7798, 0.7513, 0.8274, 0.7727]}, {"w": "for", "b": [0.8326, 0.7513, 0.8571, 0.7727]}, {"w": "its", "b": [0.1429, 0.7704, 0.1624, 0.7918]}, {"w": "task,", "b": [0.1672, 0.7704, 0.2054, 0.7918]}, {"w": "and", "b": [0.2101, 0.7704, 0.2417, 0.7918]}, {"w": "the", "b": [0.2464, 0.7704, 0.2727, 0.7918]}, {"w": "layers", "b": [0.2775, 0.7704, 0.3253, 0.7918]}, {"w": "above", "b": [0.33, 0.7704, 0.3789, 0.7918]}, {"w": "will", "b": [0.3836, 0.7704, 0.414, 0.7918]}, {"w": "learn", "b": [0.4187, 0.7704, 0.4611, 0.7918]}, {"w": "to", "b": [0.4659, 0.7704, 0.4828, 0.7918]}, {"w": "combine", "b": [0.4876, 0.7704, 0.5605, 0.7918]}, {"w": "them", "b": [0.5652, 0.7704, 0.6086, 0.7918]}, {"w": "into", "b": [0.6133, 0.7704, 0.6469, 0.7918]}, {"w": "more", "b": [0.6516, 0.7704, 0.6959, 0.7918]}, {"w": "complex", "b": [0.7006, 0.7704, 0.7716, 0.7918]}, {"w": "patterns.", "b": [0.7763, 0.7704, 0.8491, 0.7918]}]}, {"id": "b_4", "type": "paragraph", "text": "436 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "436", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3683, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 463, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 14-5. Applying two different filters to get two feature maps", "words": [{"w": "Figure", "b": [0.1429, 0.4292, 0.1943, 0.4508]}, {"w": "14-5.", "b": [0.1991, 0.4292, 0.2407, 0.4508]}, {"w": "Applying", "b": [0.2455, 0.4292, 0.3185, 0.4508]}, {"w": "two", "b": [0.3233, 0.4292, 0.3534, 0.4508]}, {"w": "different", "b": [0.3581, 0.4292, 0.4272, 0.4508]}, {"w": "filters", "b": [0.432, 0.4292, 0.4776, 0.4508]}, {"w": "to", "b": [0.4824, 0.4292, 0.4984, 0.4508]}, {"w": "get", "b": [0.5031, 0.4292, 0.5265, 0.4508]}, {"w": "two", "b": [0.5312, 0.4292, 0.5613, 0.4508]}, {"w": "feature", "b": [0.5661, 0.4292, 0.6221, 0.4508]}, {"w": "maps", "b": [0.6268, 0.4292, 0.6701, 0.4508]}]}, {"id": "b_1", "type": "paragraph", "text": "Stacking Multiple Feature Maps", "words": [{"w": "Stacking", "b": [0.1429, 0.4638, 0.2312, 0.4924]}, {"w": "Multiple", "b": [0.2362, 0.4638, 0.3231, 0.4924]}, {"w": "Feature", "b": [0.328, 0.4638, 0.4076, 0.4924]}, {"w": "Maps", "b": [0.4125, 0.4638, 0.4672, 0.4924]}]}, {"id": "b_2", "type": "paragraph", "text": "Up to now, for simplicity, I have represented the output of each convolutional layer as a thin 2D layer, but in reality a convolutional layer has multiple filters (you decide how many), and it outputs one feature map per filter, so it is more accurately repre‐ sented in 3D (see Figure 14-6). To do so, it has one neuron per pixel in each feature map, and all neurons within a given feature map share the same parameters (i.e., the same weights and bias term). However, neurons in different feature maps use differ‐ ent parameters. A neuron’s receptive field is the same as described earlier, but it extends across all the previous layers’ feature maps. In short, a convolutional layer simultaneously applies multiple trainable filters to its inputs, making it capable of detecting multiple features anywhere in its inputs.", "words": [{"w": "Up", "b": [0.1429, 0.4983, 0.1683, 0.5197]}, {"w": "to", "b": [0.1733, 0.4983, 0.1902, 0.5197]}, {"w": "now,", "b": [0.1952, 0.4983, 0.2347, 0.5197]}, {"w": "for", "b": [0.2397, 0.4983, 0.2642, 0.5197]}, {"w": "simplicity,", "b": [0.2692, 0.4983, 0.3544, 0.5197]}, {"w": "I", "b": [0.3594, 0.4983, 0.3665, 0.5197]}, {"w": "have", "b": [0.3714, 0.4983, 0.4098, 0.5197]}, {"w": "represented", "b": [0.4148, 0.4983, 0.5126, 0.5197]}, {"w": "the", "b": [0.5176, 0.4983, 0.5439, 0.5197]}, {"w": "output", "b": [0.5489, 0.4983, 0.6052, 0.5197]}, {"w": "of", "b": [0.6102, 0.4983, 0.627, 0.5197]}, {"w": "each", "b": [0.632, 0.4983, 0.6699, 0.5197]}, {"w": "convolutional", "b": [0.6749, 0.4983, 0.7902, 0.5197]}, {"w": "layer", "b": [0.7952, 0.4983, 0.8354, 0.5197]}, {"w": "as", "b": [0.8403, 0.4983, 0.8571, 0.5197]}, {"w": "a", "b": [0.1429, 0.5173, 0.152, 0.5387]}, {"w": "thin", "b": [0.1593, 0.5173, 0.1937, 0.5387]}, {"w": "2D", "b": [0.201, 0.5173, 0.2263, 0.5387]}, {"w": "layer,", "b": [0.2335, 0.5173, 0.2772, 0.5387]}, {"w": "but", "b": [0.2844, 0.5173, 0.3124, 0.5387]}, {"w": "in", "b": [0.3197, 0.5173, 0.3366, 0.5387]}, {"w": "reality", "b": [0.3439, 0.5173, 0.3964, 0.5387]}, {"w": "a", "b": [0.4037, 0.5173, 0.4128, 0.5387]}, {"w": "convolutional", "b": [0.4201, 0.5173, 0.5354, 0.5387]}, {"w": "layer", "b": [0.5426, 0.5173, 0.5828, 0.5387]}, {"w": "has", "b": [0.5901, 0.5173, 0.618, 0.5387]}, {"w": "multiple", "b": [0.6252, 0.5173, 0.6952, 0.5387]}, {"w": "filters", "b": [0.7025, 0.5173, 0.7501, 0.5387]}, {"w": "(you", "b": [0.7573, 0.5173, 0.7958, 0.5387]}, {"w": "decide", "b": [0.803, 0.5173, 0.8571, 0.5387]}, {"w": "how", "b": [0.1429, 0.5364, 0.1789, 0.5578]}, {"w": "many),", "b": [0.185, 0.5364, 0.2437, 0.5578]}, {"w": "and", "b": [0.2498, 0.5364, 0.2814, 0.5578]}, {"w": "it", "b": [0.2875, 0.5364, 0.2995, 0.5578]}, {"w": "outputs", "b": [0.3056, 0.5364, 0.3696, 0.5578]}, {"w": "one", "b": [0.3758, 0.5364, 0.4067, 0.5578]}, {"w": "feature", "b": [0.4128, 0.5364, 0.4706, 0.5578]}, {"w": "map", "b": [0.4767, 0.5364, 0.5135, 0.5578]}, {"w": "per", "b": [0.5196, 0.5364, 0.5471, 0.5578]}, {"w": "filter,", "b": [0.5533, 0.5364, 0.5967, 0.5578]}, {"w": "so", "b": [0.6028, 0.5364, 0.6211, 0.5578]}, {"w": "it", "b": [0.6272, 0.5364, 0.6392, 0.5578]}, {"w": "is", "b": [0.6453, 0.5364, 0.6586, 0.5578]}, {"w": "more", "b": [0.6647, 0.5364, 0.709, 0.5578]}, {"w": "accurately", "b": [0.7151, 0.5364, 0.7995, 0.5578]}, {"w": "repre‐", "b": [0.8056, 0.5364, 0.8571, 0.5578]}, {"w": "sented", "b": [0.1429, 0.5554, 0.1966, 0.5768]}, {"w": "in", "b": [0.2027, 0.5554, 0.2197, 0.5768]}, {"w": "3D", "b": [0.2258, 0.5554, 0.2511, 0.5768]}, {"w": "(see", "b": [0.2573, 0.5554, 0.2898, 0.5768]}, {"w": "Figure", "b": [0.296, 0.5554, 0.35, 0.5768]}, {"w": "14-6).", "b": [0.3561, 0.5554, 0.4055, 0.5768]}, {"w": "To", "b": [0.4116, 0.5554, 0.4331, 0.5768]}, {"w": "do", "b": [0.4392, 0.5554, 0.4609, 0.5768]}, {"w": "so,", "b": [0.467, 0.5554, 0.4894, 0.5768]}, {"w": "it", "b": [0.4956, 0.5554, 0.5075, 0.5768]}, {"w": "has", "b": [0.5136, 0.5554, 0.5416, 0.5768]}, {"w": "one", "b": [0.5477, 0.5554, 0.5786, 0.5768]}, {"w": "neuron", "b": [0.5847, 0.5554, 0.6458, 0.5768]}, {"w": "per", "b": [0.6519, 0.5554, 0.6794, 0.5768]}, {"w": "pixel", "b": [0.6856, 0.5554, 0.726, 0.5768]}, {"w": "in", "b": [0.7322, 0.5554, 0.7491, 0.5768]}, {"w": "each", "b": [0.7553, 0.5554, 0.7932, 0.5768]}, {"w": "feature", "b": [0.7994, 0.5554, 0.8571, 0.5768]}, {"w": "map,", "b": [0.1429, 0.5745, 0.1837, 0.5959]}, {"w": "and", "b": [0.1895, 0.5745, 0.2211, 0.5959]}, {"w": "all", "b": [0.2269, 0.5745, 0.2466, 0.5959]}, {"w": "neurons", "b": [0.2523, 0.5745, 0.3211, 0.5959]}, {"w": "within", "b": [0.3268, 0.5745, 0.3812, 0.5959]}, {"w": "a", "b": [0.3869, 0.5745, 0.3961, 0.5959]}, {"w": "given", "b": [0.4019, 0.5745, 0.4471, 0.5959]}, {"w": "feature", "b": [0.4529, 0.5745, 0.5107, 0.5959]}, {"w": "map", "b": [0.5165, 0.5745, 0.5532, 0.5959]}, {"w": "share", "b": [0.559, 0.5745, 0.6035, 0.5959]}, {"w": "the", "b": [0.6093, 0.5745, 0.6356, 0.5959]}, {"w": "same", "b": [0.6414, 0.5745, 0.6841, 0.5959]}, {"w": "parameters", "b": [0.6899, 0.5745, 0.7833, 0.5959]}, {"w": "(i.e.,", "b": [0.7891, 0.5745, 0.825, 0.5959]}, {"w": "the", "b": [0.8308, 0.5745, 0.8572, 0.5959]}, {"w": "same", "b": [0.1429, 0.5935, 0.1856, 0.6149]}, {"w": "weights", "b": [0.1917, 0.5935, 0.2548, 0.6149]}, {"w": "and", "b": [0.2609, 0.5935, 0.2925, 0.6149]}, {"w": "bias", "b": [0.2986, 0.5935, 0.3315, 0.6149]}, {"w": "term).", "b": [0.3376, 0.5935, 0.3896, 0.6149]}, {"w": "However,", "b": [0.3957, 0.5935, 0.4745, 0.6149]}, {"w": "neurons", "b": [0.4806, 0.5935, 0.5493, 0.6149]}, {"w": "in", "b": [0.5554, 0.5935, 0.5724, 0.6149]}, {"w": "different", "b": [0.5785, 0.5935, 0.6502, 0.6149]}, {"w": "feature", "b": [0.6563, 0.5935, 0.714, 0.6149]}, {"w": "maps", "b": [0.7201, 0.5935, 0.7645, 0.6149]}, {"w": "use", "b": [0.7706, 0.5935, 0.7981, 0.6149]}, {"w": "differ‐", "b": [0.8042, 0.5935, 0.8571, 0.6149]}, {"w": "ent", "b": [0.1429, 0.6126, 0.1691, 0.634]}, {"w": "parameters.", "b": [0.1781, 0.6126, 0.2763, 0.634]}, {"w": "A", "b": [0.2854, 0.6126, 0.2998, 0.634]}, {"w": "neuron’s", "b": [0.3088, 0.6126, 0.3785, 0.634]}, {"w": "receptive", "b": [0.3875, 0.6126, 0.4631, 0.634]}, {"w": "field", "b": [0.4722, 0.6126, 0.5091, 0.634]}, {"w": "is", "b": [0.5181, 0.6126, 0.5313, 0.634]}, {"w": "the", "b": [0.5404, 0.6126, 0.5667, 0.634]}, {"w": "same", "b": [0.5758, 0.6126, 0.6185, 0.634]}, {"w": "as", "b": [0.6275, 0.6126, 0.6443, 0.634]}, {"w": "described", "b": [0.6534, 0.6126, 0.7334, 0.634]}, {"w": "earlier,", "b": [0.7425, 0.6126, 0.7991, 0.634]}, {"w": "but", "b": [0.8082, 0.6126, 0.8362, 0.634]}, {"w": "it", "b": [0.8452, 0.6126, 0.8571, 0.634]}, {"w": "extends", "b": [0.1428, 0.6316, 0.2068, 0.653]}, {"w": "across", "b": [0.2143, 0.6316, 0.266, 0.653]}, {"w": "all", "b": [0.2735, 0.6316, 0.2932, 0.653]}, {"w": "the", "b": [0.3008, 0.6316, 0.3271, 0.653]}, {"w": "previous", "b": [0.3347, 0.6316, 0.4067, 0.653]}, {"w": "layers’", "b": [0.4143, 0.6316, 0.4659, 0.653]}, {"w": "feature", "b": [0.4735, 0.6316, 0.5312, 0.653]}, {"w": "maps.", "b": [0.5388, 0.6316, 0.5879, 0.653]}, {"w": "In", "b": [0.5955, 0.6316, 0.614, 0.653]}, {"w": "short,", "b": [0.6216, 0.6316, 0.6698, 0.653]}, {"w": "a", "b": [0.6773, 0.6316, 0.6865, 0.653]}, {"w": "convolutional", "b": [0.6941, 0.6316, 0.8094, 0.653]}, {"w": "layer", "b": [0.8169, 0.6316, 0.8571, 0.653]}, {"w": "simultaneously", "b": [0.1429, 0.6507, 0.269, 0.6721]}, {"w": "applies", "b": [0.2772, 0.6507, 0.3352, 0.6721]}, {"w": "multiple", "b": [0.3434, 0.6507, 0.4134, 0.6721]}, {"w": "trainable", "b": [0.4216, 0.6507, 0.4956, 0.6721]}, {"w": "filters", "b": [0.5038, 0.6507, 0.5514, 0.6721]}, {"w": "to", "b": [0.5597, 0.6507, 0.5766, 0.6721]}, {"w": "its", "b": [0.5849, 0.6507, 0.6044, 0.6721]}, {"w": "inputs,", "b": [0.6127, 0.6507, 0.67, 0.6721]}, {"w": "making", "b": [0.6782, 0.6507, 0.7414, 0.6721]}, {"w": "it", "b": [0.7497, 0.6507, 0.7616, 0.6721]}, {"w": "capable", "b": [0.7698, 0.6507, 0.8321, 0.6721]}, {"w": "of", "b": [0.8404, 0.6507, 0.8572, 0.6721]}, {"w": "detecting", "b": [0.1429, 0.6697, 0.2198, 0.6911]}, {"w": "multiple", "b": [0.2245, 0.6697, 0.2945, 0.6911]}, {"w": "features", "b": [0.2993, 0.6697, 0.3647, 0.6911]}, {"w": "anywhere", "b": [0.3694, 0.6697, 0.4499, 0.6911]}, {"w": "in", "b": [0.4546, 0.6697, 0.4716, 0.6911]}, {"w": "its", "b": [0.4763, 0.6697, 0.4959, 0.6911]}, {"w": "inputs.", "b": [0.5006, 0.6697, 0.5579, 0.6911]}]}, {"id": "b_3", "type": "paragraph", "text": "The fact that all neurons in a feature map share the same parame‐ ters dramatically reduces the number of parameters in the model. Moreover, once the CNN has learned to recognize a pattern in one location, it can recognize it in any other location. In contrast, once a regular DNN has learned to recognize a pattern in one location, it can recognize it only in that particular location.", "words": [{"w": "The", "b": [0.2714, 0.7117, 0.3014, 0.7312]}, {"w": "fact", "b": [0.307, 0.7117, 0.3349, 0.7312]}, {"w": "that", "b": [0.3405, 0.7117, 0.3703, 0.7312]}, {"w": "all", "b": [0.376, 0.7117, 0.394, 0.7312]}, {"w": "neurons", "b": [0.3996, 0.7117, 0.4624, 0.7312]}, {"w": "in", "b": [0.468, 0.7117, 0.4835, 0.7312]}, {"w": "a", "b": [0.4892, 0.7117, 0.4975, 0.7312]}, {"w": "feature", "b": [0.5031, 0.7117, 0.556, 0.7312]}, {"w": "map", "b": [0.5616, 0.7117, 0.5952, 0.7312]}, {"w": "share", "b": [0.6008, 0.7117, 0.6415, 0.7312]}, {"w": "the", "b": [0.6471, 0.7117, 0.6712, 0.7312]}, {"w": "same", "b": [0.6768, 0.7117, 0.7158, 0.7312]}, {"w": "parame‐", "b": [0.7215, 0.7117, 0.7857, 0.7312]}, {"w": "ters", "b": [0.2714, 0.7291, 0.2994, 0.7487]}, {"w": "dramatically", "b": [0.3055, 0.7291, 0.4003, 0.7487]}, {"w": "reduces", "b": [0.4065, 0.7291, 0.465, 0.7487]}, {"w": "the", "b": [0.4711, 0.7291, 0.4952, 0.7487]}, {"w": "number", "b": [0.5013, 0.7291, 0.5619, 0.7487]}, {"w": "of", "b": [0.5681, 0.7291, 0.5834, 0.7487]}, {"w": "parameters", "b": [0.5896, 0.7291, 0.675, 0.7487]}, {"w": "in", "b": [0.6812, 0.7291, 0.6967, 0.7487]}, {"w": "the", "b": [0.7029, 0.7291, 0.7269, 0.7487]}, {"w": "model.", "b": [0.7331, 0.7291, 0.7857, 0.7487]}, {"w": "Moreover,", "b": [0.2714, 0.7465, 0.3496, 0.7661]}, {"w": "once", "b": [0.3547, 0.7465, 0.391, 0.7661]}, {"w": "the", "b": [0.3961, 0.7465, 0.4202, 0.7661]}, {"w": "CNN", "b": [0.4252, 0.7465, 0.4662, 0.7661]}, {"w": "has", "b": [0.4713, 0.7465, 0.4968, 0.7661]}, {"w": "learned", "b": [0.5019, 0.7465, 0.5589, 0.7661]}, {"w": "to", "b": [0.5639, 0.7465, 0.5795, 0.7661]}, {"w": "recognize", "b": [0.5846, 0.7465, 0.658, 0.7661]}, {"w": "a", "b": [0.6631, 0.7465, 0.6715, 0.7661]}, {"w": "pattern", "b": [0.6766, 0.7465, 0.7318, 0.7661]}, {"w": "in", "b": [0.7369, 0.7465, 0.7524, 0.7661]}, {"w": "one", "b": [0.7575, 0.7465, 0.7857, 0.7661]}, {"w": "location,", "b": [0.2714, 0.7639, 0.3374, 0.7835]}, {"w": "it", "b": [0.3426, 0.7639, 0.3535, 0.7835]}, {"w": "can", "b": [0.3587, 0.7639, 0.3856, 0.7835]}, {"w": "recognize", "b": [0.3908, 0.7639, 0.4642, 0.7835]}, {"w": "it", "b": [0.4695, 0.7639, 0.4804, 0.7835]}, {"w": "in", "b": [0.4856, 0.7639, 0.5011, 0.7835]}, {"w": "any", "b": [0.5063, 0.7639, 0.5334, 0.7835]}, {"w": "other", "b": [0.5386, 0.7639, 0.5795, 0.7835]}, {"w": "location.", "b": [0.5847, 0.7639, 0.6507, 0.7835]}, {"w": "In", "b": [0.6559, 0.7639, 0.6728, 0.7835]}, {"w": "contrast,", "b": [0.678, 0.7639, 0.7442, 0.7835]}, {"w": "once", "b": [0.7494, 0.7639, 0.7857, 0.7835]}, {"w": "a", "b": [0.2714, 0.7813, 0.2798, 0.8009]}, {"w": "regular", "b": [0.2842, 0.7813, 0.3387, 0.8009]}, {"w": "DNN", "b": [0.3431, 0.7813, 0.3854, 0.8009]}, {"w": "has", "b": [0.3899, 0.7813, 0.4154, 0.8009]}, {"w": "learned", "b": [0.4199, 0.7813, 0.4768, 0.8009]}, {"w": "to", "b": [0.4813, 0.7813, 0.4968, 0.8009]}, {"w": "recognize", "b": [0.5013, 0.7813, 0.5747, 0.8009]}, {"w": "a", "b": [0.5792, 0.7813, 0.5876, 0.8009]}, {"w": "pattern", "b": [0.592, 0.7813, 0.6472, 0.8009]}, {"w": "in", "b": [0.6517, 0.7813, 0.6672, 0.8009]}, {"w": "one", "b": [0.6717, 0.7813, 0.6999, 0.8009]}, {"w": "location,", "b": [0.7044, 0.7813, 0.7703, 0.8009]}, {"w": "it", "b": [0.7748, 0.7813, 0.7857, 0.8009]}, {"w": "can", "b": [0.2714, 0.7987, 0.2982, 0.8183]}, {"w": "recognize", "b": [0.3026, 0.7987, 0.376, 0.8183]}, {"w": "it", "b": [0.3804, 0.7987, 0.3913, 0.8183]}, {"w": "only", "b": [0.3956, 0.7987, 0.4293, 0.8183]}, {"w": "in", "b": [0.4336, 0.7987, 0.4491, 0.8183]}, {"w": "that", "b": [0.4535, 0.7987, 0.4833, 0.8183]}, {"w": "particular", "b": [0.4876, 0.7987, 0.5623, 0.8183]}, {"w": "location.", "b": [0.5666, 0.7987, 0.6326, 0.8183]}]}, {"id": "b_4", "type": "paragraph", "text": "Moreover, input images are also composed of multiple sublayers: one per color chan‐ nel. There are typically three: red, green, and blue (RGB). Grayscale images have just", "words": [{"w": "Moreover,", "b": [0.1429, 0.8386, 0.2284, 0.86]}, {"w": "input", "b": [0.2342, 0.8386, 0.2791, 0.86]}, {"w": "images", "b": [0.2849, 0.8386, 0.3429, 0.86]}, {"w": "are", "b": [0.3487, 0.8386, 0.3744, 0.86]}, {"w": "also", "b": [0.3802, 0.8386, 0.4129, 0.86]}, {"w": "composed", "b": [0.4186, 0.8386, 0.5038, 0.86]}, {"w": "of", "b": [0.5096, 0.8386, 0.5264, 0.86]}, {"w": "multiple", "b": [0.5321, 0.8386, 0.6021, 0.86]}, {"w": "sublayers:", "b": [0.6079, 0.8386, 0.6898, 0.86]}, {"w": "one", "b": [0.6956, 0.8386, 0.7264, 0.86]}, {"w": "per", "b": [0.7322, 0.8386, 0.7597, 0.86]}, {"w": "color", "b": [0.7655, 0.8384, 0.8052, 0.86]}, {"w": "chan‐", "b": [0.811, 0.8384, 0.8571, 0.86]}, {"w": "nel.", "b": [0.1429, 0.8574, 0.1717, 0.8791]}, {"w": "There", "b": [0.1774, 0.8577, 0.2269, 0.8791]}, {"w": "are", "b": [0.2326, 0.8577, 0.2583, 0.8791]}, {"w": "typically", "b": [0.264, 0.8577, 0.3345, 0.8791]}, {"w": "three:", "b": [0.3402, 0.8577, 0.3879, 0.8791]}, {"w": "red,", "b": [0.3936, 0.8577, 0.426, 0.8791]}, {"w": "green,", "b": [0.4317, 0.8577, 0.483, 0.8791]}, {"w": "and", "b": [0.4887, 0.8577, 0.5203, 0.8791]}, {"w": "blue", "b": [0.526, 0.8577, 0.5618, 0.8791]}, {"w": "(RGB).", "b": [0.5675, 0.8577, 0.6267, 0.8791]}, {"w": "Grayscale", "b": [0.6325, 0.8577, 0.7131, 0.8791]}, {"w": "images", "b": [0.7189, 0.8577, 0.7769, 0.8791]}, {"w": "have", "b": [0.7826, 0.8577, 0.821, 0.8791]}, {"w": "just", "b": [0.8267, 0.8577, 0.8571, 0.8791]}]}, {"id": "b_5", "type": "paragraph", "text": "Convolutional Layer | 437", "words": [{"w": "Convolutional", "b": [0.6789, 0.9225, 0.7609, 0.9388]}, {"w": "Layer", "b": [0.7637, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "437", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 464, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "one channel, but some images may have much more—for example, satellite images that capture extra light frequencies (such as infrared).", "words": [{"w": "one", "b": [0.1429, 0.0791, 0.1737, 0.1005]}, {"w": "channel,", "b": [0.1808, 0.0791, 0.2515, 0.1005]}, {"w": "but", "b": [0.2586, 0.0791, 0.2866, 0.1005]}, {"w": "some", "b": [0.2937, 0.0791, 0.3379, 0.1005]}, {"w": "images", "b": [0.3449, 0.0791, 0.403, 0.1005]}, {"w": "may", "b": [0.41, 0.0791, 0.4454, 0.1005]}, {"w": "have", "b": [0.4525, 0.0791, 0.4909, 0.1005]}, {"w": "much", "b": [0.4979, 0.0791, 0.5456, 0.1005]}, {"w": "more—for", "b": [0.5527, 0.0791, 0.6407, 0.1005]}, {"w": "example,", "b": [0.6477, 0.0791, 0.722, 0.1005]}, {"w": "satellite", "b": [0.7291, 0.0791, 0.792, 0.1005]}, {"w": "images", "b": [0.7991, 0.0791, 0.8571, 0.1005]}, {"w": "that", "b": [0.1429, 0.0981, 0.1754, 0.1195]}, {"w": "capture", "b": [0.1802, 0.0981, 0.2426, 0.1195]}, {"w": "extra", "b": [0.2474, 0.0981, 0.2893, 0.1195]}, {"w": "light", "b": [0.294, 0.0981, 0.3317, 0.1195]}, {"w": "frequencies", "b": [0.3364, 0.0981, 0.432, 0.1195]}, {"w": "(such", "b": [0.4368, 0.0981, 0.4826, 0.1195]}, {"w": "as", "b": [0.4874, 0.0981, 0.5041, 0.1195]}, {"w": "infrared).", "b": [0.5089, 0.0981, 0.5884, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "Figure 14-6. Convolution layers with multiple feature maps, and images with three color channels", "words": [{"w": "Figure", "b": [0.1429, 0.6149, 0.1943, 0.6366]}, {"w": "14-6.", "b": [0.1991, 0.6149, 0.2407, 0.6366]}, {"w": "Convolution", "b": [0.2455, 0.6149, 0.346, 0.6366]}, {"w": "layers", "b": [0.3507, 0.6149, 0.3976, 0.6366]}, {"w": "with", "b": [0.4024, 0.6149, 0.4388, 0.6366]}, {"w": "multiple", "b": [0.4436, 0.6149, 0.5106, 0.6366]}, {"w": "feature", "b": [0.5154, 0.6149, 0.5714, 0.6366]}, {"w": "maps,", "b": [0.5761, 0.6149, 0.6243, 0.6366]}, {"w": "and", "b": [0.629, 0.6149, 0.6604, 0.6366]}, {"w": "images", "b": [0.6652, 0.6149, 0.7207, 0.6366]}, {"w": "with", "b": [0.7255, 0.6149, 0.7619, 0.6366]}, {"w": "three", "b": [0.7667, 0.6149, 0.807, 0.6366]}, {"w": "color", "b": [0.8117, 0.6149, 0.8515, 0.6366]}, {"w": "channels", "b": [0.1429, 0.634, 0.2129, 0.6556]}]}, {"id": "b_2", "type": "paragraph", "text": "Specifically, a neuron located in row i, column j of the feature map k in a given convo‐ lutional layer l is connected to the outputs of the neurons in the previous layer l – 1, located in rows i × sh to i × sh + fh – 1 and columns j × sw to j × sw + fw – 1, across all feature maps (in layer l – 1). Note that all neurons located in the same row i and col‐ umn j but in different feature maps are connected to the outputs of the exact same neurons in the previous layer.", "words": [{"w": "Specifically,", "b": [0.1429, 0.6714, 0.2399, 0.6928]}, {"w": "a", "b": [0.2447, 0.6714, 0.2538, 0.6928]}, {"w": "neuron", "b": [0.2585, 0.6714, 0.3196, 0.6928]}, {"w": "located", "b": [0.3243, 0.6714, 0.384, 0.6928]}, {"w": "in", "b": [0.3887, 0.6714, 0.4057, 0.6928]}, {"w": "row", "b": [0.4104, 0.6714, 0.4431, 0.6928]}, {"w": "i,", "b": [0.4479, 0.6712, 0.4583, 0.6928]}, {"w": "column", "b": [0.4631, 0.6714, 0.5273, 0.6928]}, {"w": "j", "b": [0.5321, 0.6712, 0.5376, 0.6928]}, {"w": "of", "b": [0.5424, 0.6714, 0.5591, 0.6928]}, {"w": "the", "b": [0.5639, 0.6714, 0.5902, 0.6928]}, {"w": "feature", "b": [0.5949, 0.6714, 0.6527, 0.6928]}, {"w": "map", "b": [0.6574, 0.6714, 0.6942, 0.6928]}, {"w": "k", "b": [0.699, 0.6712, 0.7088, 0.6928]}, {"w": "in", "b": [0.7135, 0.6714, 0.7305, 0.6928]}, {"w": "a", "b": [0.7352, 0.6714, 0.7444, 0.6928]}, {"w": "given", "b": [0.7491, 0.6714, 0.7943, 0.6928]}, {"w": "convo‐", "b": [0.799, 0.6714, 0.8571, 0.6928]}, {"w": "lutional", "b": [0.1429, 0.6904, 0.2076, 0.7118]}, {"w": "layer", "b": [0.2134, 0.6904, 0.2536, 0.7118]}, {"w": "l", "b": [0.2594, 0.6902, 0.2646, 0.7118]}, {"w": "is", "b": [0.2705, 0.6904, 0.2837, 0.7118]}, {"w": "connected", "b": [0.2895, 0.6904, 0.3756, 0.7118]}, {"w": "to", "b": [0.3815, 0.6904, 0.3985, 0.7118]}, {"w": "the", "b": [0.4043, 0.6904, 0.4307, 0.7118]}, {"w": "outputs", "b": [0.4365, 0.6904, 0.5005, 0.7118]}, {"w": "of", "b": [0.5064, 0.6904, 0.5232, 0.7118]}, {"w": "the", "b": [0.529, 0.6904, 0.5553, 0.7118]}, {"w": "neurons", "b": [0.5612, 0.6904, 0.6299, 0.7118]}, {"w": "in", "b": [0.6357, 0.6904, 0.6527, 0.7118]}, {"w": "the", "b": [0.6586, 0.6904, 0.6849, 0.7118]}, {"w": "previous", "b": [0.6907, 0.6904, 0.7628, 0.7118]}, {"w": "layer", "b": [0.7686, 0.6904, 0.8088, 0.7118]}, {"w": "l", "b": [0.8147, 0.6902, 0.8199, 0.7118]}, {"w": "–", "b": [0.8257, 0.6904, 0.8365, 0.7118]}, {"w": "1,", "b": [0.8424, 0.6904, 0.8571, 0.7118]}, {"w": "located", "b": [0.1429, 0.7095, 0.2025, 0.7309]}, {"w": "in", "b": [0.2084, 0.7095, 0.2254, 0.7309]}, {"w": "rows", "b": [0.2312, 0.7095, 0.2715, 0.7309]}, {"w": "i", "b": [0.2773, 0.7093, 0.283, 0.7309]}, {"w": "×", "b": [0.2888, 0.7095, 0.3009, 0.7309]}, {"w": "sh", "b": [0.3068, 0.7093, 0.3202, 0.7318]}, {"w": "to", "b": [0.326, 0.7095, 0.343, 0.7309]}, {"w": "i", "b": [0.3488, 0.7093, 0.3545, 0.7309]}, {"w": "×", "b": [0.3604, 0.7095, 0.3725, 0.7309]}, {"w": "sh", "b": [0.3783, 0.7093, 0.3917, 0.7318]}, {"w": "+", "b": [0.3976, 0.7095, 0.4096, 0.7309]}, {"w": "fh", "b": [0.4155, 0.7093, 0.4275, 0.7318]}, {"w": "–", "b": [0.4334, 0.7095, 0.4442, 0.7309]}, {"w": "1", "b": [0.45, 0.7095, 0.46, 0.7309]}, {"w": "and", "b": [0.4659, 0.7095, 0.4974, 0.7309]}, {"w": "columns", "b": [0.5033, 0.7095, 0.5751, 0.7309]}, {"w": "j", "b": [0.581, 0.7093, 0.5865, 0.7309]}, {"w": "×", "b": [0.5924, 0.7095, 0.6045, 0.7309]}, {"w": "sw", "b": [0.6103, 0.7093, 0.6257, 0.7318]}, {"w": "to", "b": [0.6316, 0.7095, 0.6485, 0.7309]}, {"w": "j", "b": [0.6544, 0.7093, 0.6599, 0.7309]}, {"w": "×", "b": [0.6658, 0.7095, 0.6778, 0.7309]}, {"w": "sw", "b": [0.6837, 0.7093, 0.6991, 0.7318]}, {"w": "+", "b": [0.7049, 0.7095, 0.717, 0.7309]}, {"w": "fw", "b": [0.7229, 0.7093, 0.7369, 0.7318]}, {"w": "–", "b": [0.7427, 0.7095, 0.7536, 0.7309]}, {"w": "1,", "b": [0.7594, 0.7095, 0.7742, 0.7309]}, {"w": "across", "b": [0.78, 0.7095, 0.8316, 0.7309]}, {"w": "all", "b": [0.8374, 0.7095, 0.8571, 0.7309]}, {"w": "feature", "b": [0.1428, 0.7285, 0.2006, 0.7499]}, {"w": "maps", "b": [0.2062, 0.7285, 0.2506, 0.7499]}, {"w": "(in", "b": [0.2561, 0.7285, 0.2803, 0.7499]}, {"w": "layer", "b": [0.2859, 0.7285, 0.3261, 0.7499]}, {"w": "l", "b": [0.3317, 0.7283, 0.3369, 0.7499]}, {"w": "–", "b": [0.3424, 0.7285, 0.3533, 0.7499]}, {"w": "1).", "b": [0.3589, 0.7283, 0.3808, 0.7499]}, {"w": "Note", "b": [0.3863, 0.7285, 0.4271, 0.7499]}, {"w": "that", "b": [0.4327, 0.7285, 0.4653, 0.7499]}, {"w": "all", "b": [0.4709, 0.7285, 0.4906, 0.7499]}, {"w": "neurons", "b": [0.4961, 0.7285, 0.5648, 0.7499]}, {"w": "located", "b": [0.5704, 0.7285, 0.6301, 0.7499]}, {"w": "in", "b": [0.6357, 0.7285, 0.6526, 0.7499]}, {"w": "the", "b": [0.6582, 0.7285, 0.6846, 0.7499]}, {"w": "same", "b": [0.6901, 0.7285, 0.7328, 0.7499]}, {"w": "row", "b": [0.7384, 0.7285, 0.771, 0.7499]}, {"w": "i", "b": [0.7766, 0.7283, 0.7823, 0.7499]}, {"w": "and", "b": [0.7879, 0.7285, 0.8194, 0.7499]}, {"w": "col‐", "b": [0.825, 0.7285, 0.8571, 0.7499]}, {"w": "umn", "b": [0.1429, 0.7476, 0.1824, 0.769]}, {"w": "j", "b": [0.1892, 0.7474, 0.1947, 0.769]}, {"w": "but", "b": [0.2016, 0.7476, 0.2296, 0.769]}, {"w": "in", "b": [0.2364, 0.7476, 0.2534, 0.769]}, {"w": "different", "b": [0.2602, 0.7476, 0.3319, 0.769]}, {"w": "feature", "b": [0.3387, 0.7476, 0.3965, 0.769]}, {"w": "maps", "b": [0.4033, 0.7476, 0.4477, 0.769]}, {"w": "are", "b": [0.4545, 0.7476, 0.4803, 0.769]}, {"w": "connected", "b": [0.4871, 0.7476, 0.5732, 0.769]}, {"w": "to", "b": [0.58, 0.7476, 0.597, 0.769]}, {"w": "the", "b": [0.6038, 0.7476, 0.6302, 0.769]}, {"w": "outputs", "b": [0.637, 0.7476, 0.701, 0.769]}, {"w": "of", "b": [0.7078, 0.7476, 0.7246, 0.769]}, {"w": "the", "b": [0.7315, 0.7476, 0.7578, 0.769]}, {"w": "exact", "b": [0.7646, 0.7476, 0.8076, 0.769]}, {"w": "same", "b": [0.8144, 0.7476, 0.8571, 0.769]}, {"w": "neurons", "b": [0.1429, 0.7666, 0.2116, 0.788]}, {"w": "in", "b": [0.2163, 0.7666, 0.2333, 0.788]}, {"w": "the", "b": [0.238, 0.7666, 0.2643, 0.788]}, {"w": "previous", "b": [0.2691, 0.7666, 0.3411, 0.788]}, {"w": "layer.", "b": [0.3459, 0.7666, 0.3895, 0.788]}]}, {"id": "b_3", "type": "paragraph", "text": "Equation 14-1 summarizes the preceding explanations in one big mathematical equa‐ tion: it shows how to compute the output of a given neuron in a convolutional layer.", "words": [{"w": "Equation", "b": [0.1429, 0.7947, 0.2191, 0.8162]}, {"w": "14-1", "b": [0.2238, 0.7947, 0.2613, 0.8162]}, {"w": "summarizes", "b": [0.2667, 0.7947, 0.3673, 0.8162]}, {"w": "the", "b": [0.3724, 0.7947, 0.3987, 0.8162]}, {"w": "preceding", "b": [0.4038, 0.7947, 0.4867, 0.8162]}, {"w": "explanations", "b": [0.4918, 0.7947, 0.5976, 0.8162]}, {"w": "in", "b": [0.6027, 0.7947, 0.6197, 0.8162]}, {"w": "one", "b": [0.6248, 0.7947, 0.6557, 0.8162]}, {"w": "big", "b": [0.6608, 0.7947, 0.6867, 0.8162]}, {"w": "mathematical", "b": [0.6918, 0.7947, 0.8049, 0.8162]}, {"w": "equa‐", "b": [0.81, 0.7947, 0.8571, 0.8162]}, {"w": "tion:", "b": [0.1428, 0.8138, 0.1816, 0.8352]}, {"w": "it", "b": [0.1873, 0.8138, 0.1992, 0.8352]}, {"w": "shows", "b": [0.205, 0.8138, 0.2563, 0.8352]}, {"w": "how", "b": [0.262, 0.8138, 0.298, 0.8352]}, {"w": "to", "b": [0.3038, 0.8138, 0.3207, 0.8352]}, {"w": "compute", "b": [0.3265, 0.8138, 0.3998, 0.8352]}, {"w": "the", "b": [0.4055, 0.8138, 0.4318, 0.8352]}, {"w": "output", "b": [0.4376, 0.8138, 0.4939, 0.8352]}, {"w": "of", "b": [0.4997, 0.8138, 0.5165, 0.8352]}, {"w": "a", "b": [0.5222, 0.8138, 0.5314, 0.8352]}, {"w": "given", "b": [0.5371, 0.8138, 0.5823, 0.8352]}, {"w": "neuron", "b": [0.588, 0.8138, 0.6491, 0.8352]}, {"w": "in", "b": [0.6548, 0.8138, 0.6718, 0.8352]}, {"w": "a", "b": [0.6776, 0.8138, 0.6867, 0.8352]}, {"w": "convolutional", "b": [0.6924, 0.8138, 0.8078, 0.8352]}, {"w": "layer.", "b": [0.8135, 0.8138, 0.8571, 0.8352]}]}, {"id": "b_4", "type": "paragraph", "text": "438 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "438", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 465, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "It is a bit ugly due to all the different indices, but all it does is calculate the weighted sum of all the inputs, plus the bias term.", "words": [{"w": "It", "b": [0.1429, 0.0791, 0.1555, 0.1005]}, {"w": "is", "b": [0.1614, 0.0791, 0.1747, 0.1005]}, {"w": "a", "b": [0.1806, 0.0791, 0.1897, 0.1005]}, {"w": "bit", "b": [0.1957, 0.0791, 0.2182, 0.1005]}, {"w": "ugly", "b": [0.2241, 0.0791, 0.2598, 0.1005]}, {"w": "due", "b": [0.2657, 0.0791, 0.2966, 0.1005]}, {"w": "to", "b": [0.3026, 0.0791, 0.3195, 0.1005]}, {"w": "all", "b": [0.3255, 0.0791, 0.3452, 0.1005]}, {"w": "the", "b": [0.3511, 0.0791, 0.3774, 0.1005]}, {"w": "different", "b": [0.3834, 0.0791, 0.4551, 0.1005]}, {"w": "indices,", "b": [0.461, 0.0791, 0.5246, 0.1005]}, {"w": "but", "b": [0.5306, 0.0791, 0.5586, 0.1005]}, {"w": "all", "b": [0.5645, 0.0791, 0.5842, 0.1005]}, {"w": "it", "b": [0.5901, 0.0791, 0.6021, 0.1005]}, {"w": "does", "b": [0.608, 0.0791, 0.6461, 0.1005]}, {"w": "is", "b": [0.652, 0.0791, 0.6653, 0.1005]}, {"w": "calculate", "b": [0.6712, 0.0791, 0.7435, 0.1005]}, {"w": "the", "b": [0.7495, 0.0791, 0.7758, 0.1005]}, {"w": "weighted", "b": [0.7817, 0.0791, 0.8571, 0.1005]}, {"w": "sum", "b": [0.1429, 0.0981, 0.1786, 0.1195]}, {"w": "of", "b": [0.1834, 0.0981, 0.2001, 0.1195]}, {"w": "all", "b": [0.2049, 0.0981, 0.2246, 0.1195]}, {"w": "the", "b": [0.2293, 0.0981, 0.2556, 0.1195]}, {"w": "inputs,", "b": [0.2604, 0.0981, 0.3177, 0.1195]}, {"w": "plus", "b": [0.3224, 0.0981, 0.3573, 0.1195]}, {"w": "the", "b": [0.362, 0.0981, 0.3884, 0.1195]}, {"w": "bias", "b": [0.3931, 0.0981, 0.426, 0.1195]}, {"w": "term.", "b": [0.4308, 0.0981, 0.4755, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "Equation 14-1. Computing the output of a neuron in a convolutional layer", "words": [{"w": "Equation", "b": [0.1726, 0.1376, 0.2473, 0.1593]}, {"w": "14-1.", "b": [0.2521, 0.1376, 0.2937, 0.1593]}, {"w": "Computing", "b": [0.2985, 0.1376, 0.3894, 0.1593]}, {"w": "the", "b": [0.3941, 0.1376, 0.4192, 0.1593]}, {"w": "output", "b": [0.4239, 0.1376, 0.4779, 0.1593]}, {"w": "of", "b": [0.4826, 0.1376, 0.4978, 0.1593]}, {"w": "a", "b": [0.5026, 0.1376, 0.5128, 0.1593]}, {"w": "neuron", "b": [0.5176, 0.1376, 0.5756, 0.1593]}, {"w": "in", "b": [0.5804, 0.1376, 0.5969, 0.1593]}, {"w": "a", "b": [0.6016, 0.1376, 0.6118, 0.1593]}, {"w": "convolutional", "b": [0.6166, 0.1376, 0.7266, 0.1593]}, {"w": "layer", "b": [0.7314, 0.1376, 0.7713, 0.1593]}]}, {"id": "b_2", "type": "equation", "text": "zi, j, k = bk + ∑", "words": [{"w": "zi,", "b": [0.1726, 0.1858, 0.1892, 0.2106]}, {"w": "j,", "b": [0.1935, 0.1942, 0.2013, 0.2106]}, {"w": "k", "b": [0.204, 0.1942, 0.2115, 0.2106]}, {"w": "=", "b": [0.217, 0.186, 0.2285, 0.2064]}, {"w": "bk", "b": [0.234, 0.1858, 0.2511, 0.2106]}, {"w": "+", "b": [0.2555, 0.186, 0.267, 0.2064]}, {"w": "∑", "b": [0.2855, 0.1812, 0.3005, 0.21]}]}, {"id": "b_3", "type": "equation", "text": "u = 0", "words": [{"w": "u", "b": [0.2759, 0.2007, 0.2844, 0.2171]}, {"w": "=", "b": [0.2888, 0.2008, 0.298, 0.2171]}, {"w": "0", "b": [0.3024, 0.2008, 0.3101, 0.2171]}]}, {"id": "b_4", "type": "paragraph", "text": "f h −1", "words": [{"w": "f", "b": [0.2747, 0.1669, 0.279, 0.1834]}, {"w": "h", "b": [0.2815, 0.173, 0.2896, 0.1895]}, {"w": "−1", "b": [0.2931, 0.1671, 0.3135, 0.1834]}]}, {"id": "b_5", "type": "equation", "text": "∑ v = 0", "words": [{"w": "∑", "b": [0.3376, 0.1812, 0.3527, 0.21]}, {"w": "v", "b": [0.3288, 0.2007, 0.3359, 0.2171]}, {"w": "=", "b": [0.3403, 0.2008, 0.3495, 0.2171]}, {"w": "0", "b": [0.3539, 0.2008, 0.3615, 0.2171]}]}, {"id": "b_6", "type": "paragraph", "text": "f w −1", "words": [{"w": "f", "b": [0.3256, 0.1669, 0.3299, 0.1834]}, {"w": "w", "b": [0.3324, 0.173, 0.343, 0.1895]}, {"w": "−1", "b": [0.3466, 0.1671, 0.3669, 0.1834]}]}, {"id": "b_7", "type": "equation", "text": "∑ k′ = 0", "words": [{"w": "∑", "b": [0.3919, 0.1812, 0.407, 0.21]}, {"w": "k′", "b": [0.3809, 0.2014, 0.3923, 0.2178]}, {"w": "=", "b": [0.3967, 0.2015, 0.4059, 0.2178]}, {"w": "0", "b": [0.4103, 0.2015, 0.418, 0.2178]}]}, {"id": "b_8", "type": "paragraph", "text": "f n′ −1", "words": [{"w": "f", "b": [0.379, 0.1663, 0.3833, 0.1827]}, {"w": "n′", "b": [0.3858, 0.173, 0.3982, 0.1895]}, {"w": "−1", "b": [0.4017, 0.1664, 0.4221, 0.1827]}]}, {"id": "b_9", "type": "paragraph", "text": "xi′, j′, k′ . wu, v, k′, k with", "words": [{"w": "xi′,", "b": [0.4309, 0.1858, 0.4521, 0.2113]}, {"w": "j′,", "b": [0.4564, 0.1949, 0.4682, 0.2113]}, {"w": "k′", "b": [0.4708, 0.1949, 0.4822, 0.2113]}, {"w": ".", "b": [0.4855, 0.186, 0.49, 0.2064]}, {"w": "wu,", "b": [0.4933, 0.1858, 0.5187, 0.2113]}, {"w": "v,", "b": [0.5213, 0.1949, 0.5321, 0.2113]}, {"w": "k′,", "b": [0.5347, 0.1949, 0.5497, 0.2113]}, {"w": "k", "b": [0.5524, 0.1949, 0.5598, 0.2113]}, {"w": "with", "b": [0.5797, 0.186, 0.6152, 0.2064]}]}, {"id": "b_10", "type": "equation", "text": "i′ = i × sh + u", "words": [{"w": "i′", "b": [0.63, 0.1704, 0.6404, 0.191]}, {"w": "=", "b": [0.6459, 0.1706, 0.6574, 0.191]}, {"w": "i", "b": [0.6629, 0.1704, 0.6683, 0.191]}, {"w": "×", "b": [0.6727, 0.1706, 0.6842, 0.191]}, {"w": "sh", "b": [0.6886, 0.1704, 0.7034, 0.1952]}, {"w": "+", "b": [0.7078, 0.1706, 0.7193, 0.191]}, {"w": "u", "b": [0.7238, 0.1704, 0.7343, 0.191]}]}, {"id": "b_11", "type": "equation", "text": "j′ = j × sw + v", "words": [{"w": "j′", "b": [0.6321, 0.1975, 0.6422, 0.2181]}, {"w": "=", "b": [0.6478, 0.1977, 0.6593, 0.2181]}, {"w": "j", "b": [0.6668, 0.1975, 0.6721, 0.2181]}, {"w": "×", "b": [0.6765, 0.1977, 0.688, 0.2181]}, {"w": "sw", "b": [0.6924, 0.1975, 0.7097, 0.2224]}, {"w": "+", "b": [0.7141, 0.1977, 0.7256, 0.2181]}, {"w": "v", "b": [0.73, 0.1975, 0.7389, 0.2181]}]}, {"id": "b_12", "type": "paragraph", "text": "• zi, j, k is the output of the neuron located in row i, column j in feature map k of the convolutional layer (layer l).", "words": [{"w": "•", "b": [0.16, 0.2475, 0.1682, 0.2689]}, {"w": "zi,", "b": [0.1786, 0.2473, 0.1936, 0.2698]}, {"w": "j,", "b": [0.1967, 0.2568, 0.2028, 0.2698]}, {"w": "k", "b": [0.2059, 0.2568, 0.2117, 0.2698]}, {"w": "is", "b": [0.2168, 0.2475, 0.23, 0.2689]}, {"w": "the", "b": [0.2351, 0.2475, 0.2615, 0.2689]}, {"w": "output", "b": [0.2665, 0.2475, 0.3229, 0.2689]}, {"w": "of", "b": [0.328, 0.2475, 0.3448, 0.2689]}, {"w": "the", "b": [0.3499, 0.2475, 0.3762, 0.2689]}, {"w": "neuron", "b": [0.3813, 0.2475, 0.4423, 0.2689]}, {"w": "located", "b": [0.4474, 0.2475, 0.5071, 0.2689]}, {"w": "in", "b": [0.5122, 0.2475, 0.5291, 0.2689]}, {"w": "row", "b": [0.5342, 0.2475, 0.5668, 0.2689]}, {"w": "i,", "b": [0.5719, 0.2473, 0.5824, 0.2689]}, {"w": "column", "b": [0.5874, 0.2475, 0.6517, 0.2689]}, {"w": "j", "b": [0.6567, 0.2473, 0.6623, 0.2689]}, {"w": "in", "b": [0.6674, 0.2475, 0.6843, 0.2689]}, {"w": "feature", "b": [0.6894, 0.2475, 0.7472, 0.2689]}, {"w": "map", "b": [0.7523, 0.2475, 0.789, 0.2689]}, {"w": "k", "b": [0.7941, 0.2473, 0.8039, 0.2689]}, {"w": "of", "b": [0.8089, 0.2475, 0.8257, 0.2689]}, {"w": "the", "b": [0.8305, 0.2475, 0.8568, 0.2689]}, {"w": "convolutional", "b": [0.1786, 0.2665, 0.2939, 0.2879]}, {"w": "layer", "b": [0.2986, 0.2665, 0.3388, 0.2879]}, {"w": "(layer", "b": [0.3436, 0.2665, 0.3909, 0.2879]}, {"w": "l).", "b": [0.3957, 0.2663, 0.4128, 0.2879]}]}, {"id": "b_13", "type": "paragraph", "text": "• As explained earlier, sh and sw are the vertical and horizontal strides, fh and fw are the height and width of the receptive field, and fn′ is the number of feature maps in the previous layer (layer l – 1).", "words": [{"w": "•", "b": [0.16, 0.2916, 0.1682, 0.313]}, {"w": "As", "b": [0.1786, 0.2916, 0.2006, 0.313]}, {"w": "explained", "b": [0.2062, 0.2916, 0.2871, 0.313]}, {"w": "earlier,", "b": [0.2927, 0.2916, 0.3493, 0.313]}, {"w": "sh", "b": [0.355, 0.2914, 0.3684, 0.3139]}, {"w": "and", "b": [0.374, 0.2916, 0.4056, 0.313]}, {"w": "sw", "b": [0.4112, 0.2914, 0.4266, 0.3139]}, {"w": "are", "b": [0.4323, 0.2916, 0.458, 0.313]}, {"w": "the", "b": [0.4636, 0.2916, 0.49, 0.313]}, {"w": "vertical", "b": [0.4956, 0.2916, 0.557, 0.313]}, {"w": "and", "b": [0.5626, 0.2916, 0.5942, 0.313]}, {"w": "horizontal", "b": [0.5998, 0.2916, 0.686, 0.313]}, {"w": "strides,", "b": [0.6917, 0.2916, 0.7512, 0.313]}, {"w": "fh", "b": [0.7569, 0.2914, 0.7689, 0.3139]}, {"w": "and", "b": [0.7746, 0.2916, 0.8061, 0.313]}, {"w": "fw", "b": [0.8117, 0.2914, 0.8258, 0.3139]}, {"w": "are", "b": [0.8314, 0.2916, 0.8571, 0.313]}, {"w": "the", "b": [0.1786, 0.3107, 0.2049, 0.3321]}, {"w": "height", "b": [0.2108, 0.3107, 0.2632, 0.3321]}, {"w": "and", "b": [0.269, 0.3107, 0.3006, 0.3321]}, {"w": "width", "b": [0.3064, 0.3107, 0.3548, 0.3321]}, {"w": "of", "b": [0.3606, 0.3107, 0.3774, 0.3321]}, {"w": "the", "b": [0.3833, 0.3107, 0.4096, 0.3321]}, {"w": "receptive", "b": [0.4155, 0.3107, 0.4911, 0.3321]}, {"w": "field,", "b": [0.4969, 0.3107, 0.5385, 0.3321]}, {"w": "and", "b": [0.5444, 0.3107, 0.576, 0.3321]}, {"w": "fn′", "b": [0.5818, 0.3105, 0.5972, 0.333]}, {"w": "is", "b": [0.6031, 0.3107, 0.6163, 0.3321]}, {"w": "the", "b": [0.6221, 0.3107, 0.6485, 0.3321]}, {"w": "number", "b": [0.6543, 0.3107, 0.7206, 0.3321]}, {"w": "of", "b": [0.7265, 0.3107, 0.7433, 0.3321]}, {"w": "feature", "b": [0.7491, 0.3107, 0.8069, 0.3321]}, {"w": "maps", "b": [0.8128, 0.3107, 0.8571, 0.3321]}, {"w": "in", "b": [0.1786, 0.3297, 0.1955, 0.3511]}, {"w": "the", "b": [0.2003, 0.3297, 0.2266, 0.3511]}, {"w": "previous", "b": [0.2313, 0.3297, 0.3034, 0.3511]}, {"w": "layer", "b": [0.3081, 0.3297, 0.3483, 0.3511]}, {"w": "(layer", "b": [0.353, 0.3297, 0.4004, 0.3511]}, {"w": "l", "b": [0.4052, 0.3295, 0.4104, 0.3511]}, {"w": "–", "b": [0.4151, 0.3297, 0.4259, 0.3511]}, {"w": "1).", "b": [0.4306, 0.3297, 0.4526, 0.3511]}]}, {"id": "b_14", "type": "paragraph", "text": "• xi′, j′, k′ is the output of the neuron located in layer l – 1, row i′, column j′, feature map k′ (or channel k′ if the previous layer is the input layer).", "words": [{"w": "•", "b": [0.16, 0.3548, 0.1682, 0.3762]}, {"w": "xi′,", "b": [0.1786, 0.3546, 0.1978, 0.3771]}, {"w": "j′,", "b": [0.2013, 0.3641, 0.2106, 0.3771]}, {"w": "k′", "b": [0.2141, 0.3641, 0.2231, 0.3771]}, {"w": "is", "b": [0.229, 0.3548, 0.2423, 0.3762]}, {"w": "the", "b": [0.2482, 0.3548, 0.2745, 0.3762]}, {"w": "output", "b": [0.2804, 0.3548, 0.3368, 0.3762]}, {"w": "of", "b": [0.3427, 0.3548, 0.3595, 0.3762]}, {"w": "the", "b": [0.3654, 0.3548, 0.3918, 0.3762]}, {"w": "neuron", "b": [0.3977, 0.3548, 0.4588, 0.3762]}, {"w": "located", "b": [0.4647, 0.3548, 0.5244, 0.3762]}, {"w": "in", "b": [0.5303, 0.3548, 0.5473, 0.3762]}, {"w": "layer", "b": [0.5532, 0.3548, 0.5934, 0.3762]}, {"w": "l", "b": [0.5993, 0.3546, 0.6045, 0.3762]}, {"w": "–", "b": [0.6104, 0.3548, 0.6212, 0.3762]}, {"w": "1,", "b": [0.6271, 0.3548, 0.6419, 0.3762]}, {"w": "row", "b": [0.6478, 0.3548, 0.6804, 0.3762]}, {"w": "i′,", "b": [0.6864, 0.3546, 0.7019, 0.3762]}, {"w": "column", "b": [0.7079, 0.3548, 0.7721, 0.3762]}, {"w": "j′,", "b": [0.778, 0.3546, 0.7935, 0.3762]}, {"w": "feature", "b": [0.7994, 0.3548, 0.8571, 0.3762]}, {"w": "map", "b": [0.1786, 0.3739, 0.2153, 0.3953]}, {"w": "k′", "b": [0.22, 0.3736, 0.235, 0.3953]}, {"w": "(or", "b": [0.2402, 0.3739, 0.2657, 0.3953]}, {"w": "channel", "b": [0.2705, 0.3739, 0.3365, 0.3953]}, {"w": "k′", "b": [0.3412, 0.3736, 0.3561, 0.3953]}, {"w": "if", "b": [0.3614, 0.3739, 0.3731, 0.3953]}, {"w": "the", "b": [0.3778, 0.3739, 0.4042, 0.3953]}, {"w": "previous", "b": [0.4089, 0.3739, 0.481, 0.3953]}, {"w": "layer", "b": [0.4857, 0.3739, 0.5259, 0.3953]}, {"w": "is", "b": [0.5306, 0.3739, 0.5438, 0.3953]}, {"w": "the", "b": [0.5486, 0.3739, 0.5749, 0.3953]}, {"w": "input", "b": [0.5796, 0.3739, 0.6245, 0.3953]}, {"w": "layer).", "b": [0.6293, 0.3739, 0.6814, 0.3953]}]}, {"id": "b_15", "type": "paragraph", "text": "• bk is the bias term for feature map k (in layer l). You can think of it as a knob that tweaks the overall brightness of the feature map k.", "words": [{"w": "•", "b": [0.16, 0.3989, 0.1681, 0.4204]}, {"w": "bk", "b": [0.1786, 0.3987, 0.1946, 0.4212]}, {"w": "is", "b": [0.1997, 0.3989, 0.213, 0.4204]}, {"w": "the", "b": [0.2181, 0.3989, 0.2444, 0.4204]}, {"w": "bias", "b": [0.2496, 0.3989, 0.2826, 0.4204]}, {"w": "term", "b": [0.2877, 0.3989, 0.3277, 0.4204]}, {"w": "for", "b": [0.3329, 0.3989, 0.3574, 0.4204]}, {"w": "feature", "b": [0.3625, 0.3989, 0.4203, 0.4204]}, {"w": "map", "b": [0.4255, 0.3989, 0.4622, 0.4204]}, {"w": "k", "b": [0.4673, 0.3987, 0.4771, 0.4204]}, {"w": "(in", "b": [0.4823, 0.3989, 0.5065, 0.4204]}, {"w": "layer", "b": [0.5116, 0.3989, 0.5518, 0.4204]}, {"w": "l).", "b": [0.5569, 0.3987, 0.5741, 0.4204]}, {"w": "You", "b": [0.5792, 0.3989, 0.6116, 0.4204]}, {"w": "can", "b": [0.6168, 0.3989, 0.6461, 0.4204]}, {"w": "think", "b": [0.6513, 0.3989, 0.696, 0.4204]}, {"w": "of", "b": [0.7012, 0.3989, 0.718, 0.4204]}, {"w": "it", "b": [0.7231, 0.3989, 0.7351, 0.4204]}, {"w": "as", "b": [0.7402, 0.3989, 0.757, 0.4204]}, {"w": "a", "b": [0.7622, 0.3989, 0.7713, 0.4204]}, {"w": "knob", "b": [0.7765, 0.3989, 0.8194, 0.4204]}, {"w": "that", "b": [0.8246, 0.3989, 0.8571, 0.4204]}, {"w": "tweaks", "b": [0.1786, 0.418, 0.2352, 0.4394]}, {"w": "the", "b": [0.2399, 0.418, 0.2662, 0.4394]}, {"w": "overall", "b": [0.271, 0.418, 0.3275, 0.4394]}, {"w": "brightness", "b": [0.3322, 0.418, 0.4185, 0.4394]}, {"w": "of", "b": [0.4232, 0.418, 0.44, 0.4394]}, {"w": "the", "b": [0.4448, 0.418, 0.4711, 0.4394]}, {"w": "feature", "b": [0.4758, 0.418, 0.5336, 0.4394]}, {"w": "map", "b": [0.5383, 0.418, 0.575, 0.4394]}, {"w": "k.", "b": [0.5798, 0.4178, 0.5943, 0.4394]}]}, {"id": "b_16", "type": "paragraph", "text": "• wu, v, k′ ,k is the connection weight between any neuron in feature map k of the layer l and its input located at row u, column v (relative to the neuron’s receptive field), and feature map k′.", "words": [{"w": "•", "b": [0.16, 0.4431, 0.1682, 0.4645]}, {"w": "wu,", "b": [0.1786, 0.4429, 0.202, 0.4654]}, {"w": "v,", "b": [0.2049, 0.4524, 0.2133, 0.4654]}, {"w": "k′", "b": [0.2162, 0.4524, 0.2252, 0.4654]}, {"w": ",k", "b": [0.2283, 0.4524, 0.237, 0.4654]}, {"w": "is", "b": [0.2418, 0.4431, 0.255, 0.4645]}, {"w": "the", "b": [0.2598, 0.4431, 0.2861, 0.4645]}, {"w": "connection", "b": [0.2908, 0.4431, 0.3847, 0.4645]}, {"w": "weight", "b": [0.3894, 0.4431, 0.445, 0.4645]}, {"w": "between", "b": [0.4497, 0.4431, 0.5188, 0.4645]}, {"w": "any", "b": [0.5236, 0.4431, 0.5532, 0.4645]}, {"w": "neuron", "b": [0.5579, 0.4431, 0.619, 0.4645]}, {"w": "in", "b": [0.6237, 0.4431, 0.6407, 0.4645]}, {"w": "feature", "b": [0.6454, 0.4431, 0.7032, 0.4645]}, {"w": "map", "b": [0.7079, 0.4431, 0.7447, 0.4645]}, {"w": "k", "b": [0.7497, 0.4429, 0.7595, 0.4645]}, {"w": "of", "b": [0.7643, 0.4431, 0.7811, 0.4645]}, {"w": "the", "b": [0.7858, 0.4431, 0.8122, 0.4645]}, {"w": "layer", "b": [0.8169, 0.4431, 0.8571, 0.4645]}, {"w": "l", "b": [0.1786, 0.4619, 0.1838, 0.4835]}, {"w": "and", "b": [0.1887, 0.4621, 0.2203, 0.4835]}, {"w": "its", "b": [0.2253, 0.4621, 0.2449, 0.4835]}, {"w": "input", "b": [0.2499, 0.4621, 0.2948, 0.4835]}, {"w": "located", "b": [0.2998, 0.4621, 0.3594, 0.4835]}, {"w": "at", "b": [0.3644, 0.4621, 0.3795, 0.4835]}, {"w": "row", "b": [0.3845, 0.4621, 0.4171, 0.4835]}, {"w": "u,", "b": [0.4221, 0.4619, 0.438, 0.4835]}, {"w": "column", "b": [0.4427, 0.4621, 0.5069, 0.4835]}, {"w": "v", "b": [0.5122, 0.4619, 0.5215, 0.4835]}, {"w": "(relative", "b": [0.5265, 0.4621, 0.5948, 0.4835]}, {"w": "to", "b": [0.5998, 0.4621, 0.6167, 0.4835]}, {"w": "the", "b": [0.6217, 0.4621, 0.6481, 0.4835]}, {"w": "neuron’s", "b": [0.653, 0.4621, 0.7227, 0.4835]}, {"w": "receptive", "b": [0.7277, 0.4621, 0.8033, 0.4835]}, {"w": "field),", "b": [0.8083, 0.4621, 0.8571, 0.4835]}, {"w": "and", "b": [0.1786, 0.4812, 0.2101, 0.5026]}, {"w": "feature", "b": [0.2148, 0.4812, 0.2726, 0.5026]}, {"w": "map", "b": [0.2773, 0.4812, 0.3141, 0.5026]}, {"w": "k′.", "b": [0.3188, 0.481, 0.3385, 0.5026]}]}, {"id": "b_17", "type": "paragraph", "text": "TensorFlow Implementation", "words": [{"w": "TensorFlow", "b": [0.1429, 0.5305, 0.2611, 0.559]}, {"w": "Implementation", "b": [0.2661, 0.5305, 0.4352, 0.559]}]}, {"id": "b_18", "type": "paragraph", "text": "In TensorFlow, each input image is typically represented as a 3D tensor of shape [height, width, channels]. A mini-batch is represented as a 4D tensor of shape [mini-batch size, height, width, channels]. The weights of a convolutional layer are represented as a 4D tensor of shape [fh, fw, fn′, fn]. The bias terms of a convo‐ lutional layer are simply represented as a 1D tensor of shape [fn].", "words": [{"w": "In", "b": [0.1429, 0.5658, 0.1614, 0.5873]}, {"w": "TensorFlow,", "b": [0.1698, 0.5658, 0.2713, 0.5873]}, {"w": "each", "b": [0.2797, 0.5658, 0.3176, 0.5873]}, {"w": "input", "b": [0.326, 0.5658, 0.371, 0.5873]}, {"w": "image", "b": [0.3794, 0.5658, 0.4298, 0.5873]}, {"w": "is", "b": [0.4382, 0.5658, 0.4514, 0.5873]}, {"w": "typically", "b": [0.4598, 0.5658, 0.5303, 0.5873]}, {"w": "represented", "b": [0.5387, 0.5658, 0.6365, 0.5873]}, {"w": "as", "b": [0.6449, 0.5658, 0.6617, 0.5873]}, {"w": "a", "b": [0.6701, 0.5658, 0.6793, 0.5873]}, {"w": "3D", "b": [0.6877, 0.5658, 0.713, 0.5873]}, {"w": "tensor", "b": [0.7214, 0.5658, 0.774, 0.5873]}, {"w": "of", "b": [0.7825, 0.5658, 0.7993, 0.5873]}, {"w": "shape", "b": [0.8077, 0.569, 0.8572, 0.5841]}, {"w": "[height,", "b": [0.1428, 0.589, 0.222, 0.604]}, {"w": "width,", "b": [0.234, 0.589, 0.2934, 0.604]}, {"w": "channels].", "b": [0.3054, 0.5858, 0.3992, 0.6072]}, {"w": "A", "b": [0.4062, 0.5858, 0.4206, 0.6072]}, {"w": "mini-batch", "b": [0.4276, 0.5858, 0.5202, 0.6072]}, {"w": "is", "b": [0.5272, 0.5858, 0.5404, 0.6072]}, {"w": "represented", "b": [0.5474, 0.5858, 0.6452, 0.6072]}, {"w": "as", "b": [0.6522, 0.5858, 0.669, 0.6072]}, {"w": "a", "b": [0.6759, 0.5858, 0.6851, 0.6072]}, {"w": "4D", "b": [0.692, 0.5858, 0.7174, 0.6072]}, {"w": "tensor", "b": [0.7243, 0.5858, 0.7769, 0.6072]}, {"w": "of", "b": [0.7839, 0.5858, 0.8007, 0.6072]}, {"w": "shape", "b": [0.8077, 0.589, 0.8571, 0.604]}, {"w": "[mini-batch", "b": [0.1429, 0.6089, 0.2517, 0.624]}, {"w": "size,", "b": [0.2652, 0.6089, 0.3146, 0.624]}, {"w": "height,", "b": [0.3281, 0.6089, 0.3974, 0.624]}, {"w": "width,", "b": [0.4108, 0.6089, 0.4702, 0.624]}, {"w": "channels].", "b": [0.4837, 0.6057, 0.5775, 0.6271]}, {"w": "The", "b": [0.5859, 0.6057, 0.6188, 0.6271]}, {"w": "weights", "b": [0.6273, 0.6057, 0.6904, 0.6271]}, {"w": "of", "b": [0.6989, 0.6057, 0.7157, 0.6271]}, {"w": "a", "b": [0.7242, 0.6057, 0.7333, 0.6271]}, {"w": "convolutional", "b": [0.7418, 0.6057, 0.8571, 0.6271]}, {"w": "layer", "b": [0.1428, 0.6248, 0.183, 0.6462]}, {"w": "are", "b": [0.1885, 0.6248, 0.2142, 0.6462]}, {"w": "represented", "b": [0.2197, 0.6248, 0.3175, 0.6462]}, {"w": "as", "b": [0.3229, 0.6248, 0.3397, 0.6462]}, {"w": "a", "b": [0.3452, 0.6248, 0.3543, 0.6462]}, {"w": "4D", "b": [0.3597, 0.6248, 0.3851, 0.6462]}, {"w": "tensor", "b": [0.3905, 0.6248, 0.4431, 0.6462]}, {"w": "of", "b": [0.4486, 0.6248, 0.4654, 0.6462]}, {"w": "shape", "b": [0.4708, 0.6248, 0.5181, 0.6462]}, {"w": "[fh,", "b": [0.5236, 0.6246, 0.5475, 0.6471]}, {"w": "fw,", "b": [0.553, 0.6246, 0.5718, 0.6471]}, {"w": "fn′,", "b": [0.5772, 0.6246, 0.5973, 0.6471]}, {"w": "fn].", "b": [0.6028, 0.6246, 0.627, 0.6471]}, {"w": "The", "b": [0.6325, 0.6248, 0.6653, 0.6462]}, {"w": "bias", "b": [0.6708, 0.6248, 0.7037, 0.6462]}, {"w": "terms", "b": [0.7092, 0.6248, 0.7568, 0.6462]}, {"w": "of", "b": [0.7623, 0.6248, 0.7791, 0.6462]}, {"w": "a", "b": [0.7845, 0.6248, 0.7937, 0.6462]}, {"w": "convo‐", "b": [0.7991, 0.6248, 0.8571, 0.6462]}, {"w": "lutional", "b": [0.1429, 0.6438, 0.2076, 0.6652]}, {"w": "layer", "b": [0.2123, 0.6438, 0.2525, 0.6652]}, {"w": "are", "b": [0.2572, 0.6438, 0.2829, 0.6652]}, {"w": "simply", "b": [0.2877, 0.6438, 0.3433, 0.6652]}, {"w": "represented", "b": [0.348, 0.6438, 0.4458, 0.6652]}, {"w": "as", "b": [0.4506, 0.6438, 0.4674, 0.6652]}, {"w": "a", "b": [0.4721, 0.6438, 0.4812, 0.6652]}, {"w": "1D", "b": [0.486, 0.6438, 0.5113, 0.6652]}, {"w": "tensor", "b": [0.516, 0.6438, 0.5686, 0.6652]}, {"w": "of", "b": [0.5733, 0.6438, 0.5901, 0.6652]}, {"w": "shape", "b": [0.5949, 0.6438, 0.6421, 0.6652]}, {"w": "[fn].", "b": [0.6469, 0.6436, 0.6783, 0.6661]}]}, {"id": "b_19", "type": "paragraph", "text": "Let’s look at a simple example. The following code loads two sample images, using Scikit-Learn’s load_sample_images() (which loads two color images, one of a Chi‐ nese temple, and the other of a flower). The pixel intensities (for each color channel) is represented as a byte from 0 to 255, so we scale these features simply by dividing by 255, to get floats ranging from 0 to 1. Then we create two 7 × 7 filters (one with a vertical white line in the middle, and the other with a horizontal white line in the middle), and we apply them to both images using the tf.nn.conv2d() function, which is part of TensorFlow’s low-level Deep Learning API. In this example, we use zero padding (padding=\"SAME\") and a stride of 2. Finally, we plot one of the resulting feature maps (similar to the top-right image in Figure 14-5).", "words": [{"w": "Let’s", "b": [0.1429, 0.6719, 0.179, 0.6934]}, {"w": "look", "b": [0.1863, 0.6719, 0.2232, 0.6934]}, {"w": "at", "b": [0.2305, 0.6719, 0.2456, 0.6934]}, {"w": "a", "b": [0.2529, 0.6719, 0.2621, 0.6934]}, {"w": "simple", "b": [0.2694, 0.6719, 0.3243, 0.6934]}, {"w": "example.", "b": [0.3316, 0.6719, 0.4059, 0.6934]}, {"w": "The", "b": [0.4132, 0.6719, 0.4461, 0.6934]}, {"w": "following", "b": [0.4534, 0.6719, 0.5323, 0.6934]}, {"w": "code", "b": [0.5396, 0.6719, 0.5789, 0.6934]}, {"w": "loads", "b": [0.5862, 0.6719, 0.6299, 0.6934]}, {"w": "two", "b": [0.6372, 0.6719, 0.6685, 0.6934]}, {"w": "sample", "b": [0.6758, 0.6719, 0.7343, 0.6934]}, {"w": "images,", "b": [0.7416, 0.6719, 0.8044, 0.6934]}, {"w": "using", "b": [0.8117, 0.6719, 0.8571, 0.6934]}, {"w": "Scikit-Learn’s", "b": [0.1429, 0.6919, 0.2537, 0.7133]}, {"w": "load_sample_images()", "b": [0.2609, 0.6951, 0.4588, 0.7102]}, {"w": "(which", "b": [0.466, 0.6919, 0.5241, 0.7133]}, {"w": "loads", "b": [0.5313, 0.6919, 0.575, 0.7133]}, {"w": "two", "b": [0.5822, 0.6919, 0.6134, 0.7133]}, {"w": "color", "b": [0.6206, 0.6919, 0.6637, 0.7133]}, {"w": "images,", "b": [0.6708, 0.6919, 0.7336, 0.7133]}, {"w": "one", "b": [0.7408, 0.6919, 0.7717, 0.7133]}, {"w": "of", "b": [0.7789, 0.6919, 0.7957, 0.7133]}, {"w": "a", "b": [0.8028, 0.6919, 0.812, 0.7133]}, {"w": "Chi‐", "b": [0.8192, 0.6919, 0.8571, 0.7133]}, {"w": "nese", "b": [0.1428, 0.7109, 0.1796, 0.7323]}, {"w": "temple,", "b": [0.1852, 0.7109, 0.2469, 0.7323]}, {"w": "and", "b": [0.2525, 0.7109, 0.284, 0.7323]}, {"w": "the", "b": [0.2896, 0.7109, 0.3159, 0.7323]}, {"w": "other", "b": [0.3215, 0.7109, 0.3662, 0.7323]}, {"w": "of", "b": [0.3718, 0.7109, 0.3886, 0.7323]}, {"w": "a", "b": [0.3942, 0.7109, 0.4034, 0.7323]}, {"w": "flower).", "b": [0.409, 0.7109, 0.4738, 0.7323]}, {"w": "The", "b": [0.4794, 0.7109, 0.5123, 0.7323]}, {"w": "pixel", "b": [0.5179, 0.7109, 0.5583, 0.7323]}, {"w": "intensities", "b": [0.5639, 0.7109, 0.6488, 0.7323]}, {"w": "(for", "b": [0.6544, 0.7109, 0.6861, 0.7323]}, {"w": "each", "b": [0.6917, 0.7109, 0.7297, 0.7323]}, {"w": "color", "b": [0.7353, 0.7109, 0.7783, 0.7323]}, {"w": "channel)", "b": [0.7839, 0.7109, 0.8571, 0.7323]}, {"w": "is", "b": [0.1429, 0.73, 0.1561, 0.7514]}, {"w": "represented", "b": [0.161, 0.73, 0.2588, 0.7514]}, {"w": "as", "b": [0.2637, 0.73, 0.2805, 0.7514]}, {"w": "a", "b": [0.2855, 0.73, 0.2946, 0.7514]}, {"w": "byte", "b": [0.2995, 0.73, 0.3349, 0.7514]}, {"w": "from", "b": [0.3398, 0.73, 0.3814, 0.7514]}, {"w": "0", "b": [0.3863, 0.73, 0.3963, 0.7514]}, {"w": "to", "b": [0.4013, 0.73, 0.4182, 0.7514]}, {"w": "255,", "b": [0.4232, 0.73, 0.4579, 0.7514]}, {"w": "so", "b": [0.4629, 0.73, 0.4811, 0.7514]}, {"w": "we", "b": [0.4861, 0.73, 0.5092, 0.7514]}, {"w": "scale", "b": [0.5141, 0.73, 0.5538, 0.7514]}, {"w": "these", "b": [0.5588, 0.73, 0.6016, 0.7514]}, {"w": "features", "b": [0.6065, 0.73, 0.6719, 0.7514]}, {"w": "simply", "b": [0.6769, 0.73, 0.7325, 0.7514]}, {"w": "by", "b": [0.7375, 0.73, 0.7576, 0.7514]}, {"w": "dividing", "b": [0.7625, 0.73, 0.8321, 0.7514]}, {"w": "by", "b": [0.837, 0.73, 0.8571, 0.7514]}, {"w": "255,", "b": [0.1429, 0.749, 0.1776, 0.7704]}, {"w": "to", "b": [0.1846, 0.749, 0.2016, 0.7704]}, {"w": "get", "b": [0.2085, 0.749, 0.2335, 0.7704]}, {"w": "floats", "b": [0.2405, 0.749, 0.2853, 0.7704]}, {"w": "ranging", "b": [0.2923, 0.749, 0.357, 0.7704]}, {"w": "from", "b": [0.364, 0.749, 0.4056, 0.7704]}, {"w": "0", "b": [0.4125, 0.749, 0.4225, 0.7704]}, {"w": "to", "b": [0.4295, 0.749, 0.4465, 0.7704]}, {"w": "1.", "b": [0.4535, 0.749, 0.4682, 0.7704]}, {"w": "Then", "b": [0.4752, 0.749, 0.5194, 0.7704]}, {"w": "we", "b": [0.5264, 0.749, 0.5495, 0.7704]}, {"w": "create", "b": [0.5565, 0.749, 0.6058, 0.7704]}, {"w": "two", "b": [0.6128, 0.749, 0.6441, 0.7704]}, {"w": "7", "b": [0.651, 0.749, 0.661, 0.7704]}, {"w": "×", "b": [0.668, 0.749, 0.6801, 0.7704]}, {"w": "7", "b": [0.6871, 0.749, 0.6971, 0.7704]}, {"w": "filters", "b": [0.7041, 0.749, 0.7517, 0.7704]}, {"w": "(one", "b": [0.7586, 0.749, 0.7967, 0.7704]}, {"w": "with", "b": [0.8037, 0.749, 0.841, 0.7704]}, {"w": "a", "b": [0.848, 0.749, 0.8571, 0.7704]}, {"w": "vertical", "b": [0.1429, 0.7681, 0.2042, 0.7895]}, {"w": "white", "b": [0.2118, 0.7681, 0.258, 0.7895]}, {"w": "line", "b": [0.2655, 0.7681, 0.2966, 0.7895]}, {"w": "in", "b": [0.3041, 0.7681, 0.3211, 0.7895]}, {"w": "the", "b": [0.3286, 0.7681, 0.355, 0.7895]}, {"w": "middle,", "b": [0.3625, 0.7681, 0.426, 0.7895]}, {"w": "and", "b": [0.4335, 0.7681, 0.4651, 0.7895]}, {"w": "the", "b": [0.4726, 0.7681, 0.4989, 0.7895]}, {"w": "other", "b": [0.5065, 0.7681, 0.5512, 0.7895]}, {"w": "with", "b": [0.5587, 0.7681, 0.596, 0.7895]}, {"w": "a", "b": [0.6035, 0.7681, 0.6127, 0.7895]}, {"w": "horizontal", "b": [0.6202, 0.7681, 0.7064, 0.7895]}, {"w": "white", "b": [0.7139, 0.7681, 0.7601, 0.7895]}, {"w": "line", "b": [0.7677, 0.7681, 0.7988, 0.7895]}, {"w": "in", "b": [0.8063, 0.7681, 0.8233, 0.7895]}, {"w": "the", "b": [0.8308, 0.7681, 0.8571, 0.7895]}, {"w": "middle),", "b": [0.1429, 0.788, 0.2136, 0.8094]}, {"w": "and", "b": [0.2227, 0.788, 0.2542, 0.8094]}, {"w": "we", "b": [0.2633, 0.788, 0.2864, 0.8094]}, {"w": "apply", "b": [0.2955, 0.788, 0.3409, 0.8094]}, {"w": "them", "b": [0.35, 0.788, 0.3934, 0.8094]}, {"w": "to", "b": [0.4025, 0.788, 0.4195, 0.8094]}, {"w": "both", "b": [0.4285, 0.788, 0.4672, 0.8094]}, {"w": "images", "b": [0.4763, 0.788, 0.5344, 0.8094]}, {"w": "using", "b": [0.5434, 0.788, 0.5889, 0.8094]}, {"w": "the", "b": [0.598, 0.788, 0.6243, 0.8094]}, {"w": "tf.nn.conv2d()", "b": [0.6334, 0.7912, 0.7719, 0.8063]}, {"w": "function,", "b": [0.781, 0.788, 0.8572, 0.8094]}, {"w": "which", "b": [0.1429, 0.8071, 0.1938, 0.8285]}, {"w": "is", "b": [0.2002, 0.8071, 0.2135, 0.8285]}, {"w": "part", "b": [0.2199, 0.8071, 0.2541, 0.8285]}, {"w": "of", "b": [0.2605, 0.8071, 0.2773, 0.8285]}, {"w": "TensorFlow’s", "b": [0.2838, 0.8071, 0.3924, 0.8285]}, {"w": "low-level", "b": [0.3988, 0.8071, 0.4743, 0.8285]}, {"w": "Deep", "b": [0.4808, 0.8071, 0.5247, 0.8285]}, {"w": "Learning", "b": [0.5312, 0.8071, 0.6062, 0.8285]}, {"w": "API.", "b": [0.6127, 0.8071, 0.6507, 0.8285]}, {"w": "In", "b": [0.6571, 0.8071, 0.6756, 0.8285]}, {"w": "this", "b": [0.6821, 0.8071, 0.7128, 0.8285]}, {"w": "example,", "b": [0.7192, 0.8071, 0.7935, 0.8285]}, {"w": "we", "b": [0.8, 0.8071, 0.8231, 0.8285]}, {"w": "use", "b": [0.8296, 0.8071, 0.8571, 0.8285]}, {"w": "zero", "b": [0.1429, 0.827, 0.1788, 0.8484]}, {"w": "padding", "b": [0.184, 0.827, 0.2528, 0.8484]}, {"w": "(padding=\"SAME\")", "b": [0.258, 0.827, 0.411, 0.8484]}, {"w": "and", "b": [0.4162, 0.827, 0.4477, 0.8484]}, {"w": "a", "b": [0.4529, 0.827, 0.4621, 0.8484]}, {"w": "stride", "b": [0.4673, 0.827, 0.5144, 0.8484]}, {"w": "of", "b": [0.5196, 0.827, 0.5364, 0.8484]}, {"w": "2.", "b": [0.5416, 0.827, 0.5563, 0.8484]}, {"w": "Finally,", "b": [0.5615, 0.827, 0.622, 0.8484]}, {"w": "we", "b": [0.6272, 0.827, 0.6503, 0.8484]}, {"w": "plot", "b": [0.6555, 0.827, 0.6887, 0.8484]}, {"w": "one", "b": [0.6939, 0.827, 0.7248, 0.8484]}, {"w": "of", "b": [0.73, 0.827, 0.7468, 0.8484]}, {"w": "the", "b": [0.752, 0.827, 0.7783, 0.8484]}, {"w": "resulting", "b": [0.7835, 0.827, 0.8571, 0.8484]}, {"w": "feature", "b": [0.1429, 0.8461, 0.2006, 0.8675]}, {"w": "maps", "b": [0.2054, 0.8461, 0.2497, 0.8675]}, {"w": "(similar", "b": [0.2545, 0.8461, 0.3197, 0.8675]}, {"w": "to", "b": [0.3244, 0.8461, 0.3414, 0.8675]}, {"w": "the", "b": [0.3461, 0.8461, 0.3725, 0.8675]}, {"w": "top-right", "b": [0.3772, 0.8461, 0.4526, 0.8675]}, {"w": "image", "b": [0.4574, 0.8461, 0.5078, 0.8675]}, {"w": "in", "b": [0.5125, 0.8461, 0.5295, 0.8675]}, {"w": "Figure", "b": [0.5342, 0.8461, 0.5882, 0.8675]}, {"w": "14-5).", "b": [0.5929, 0.8461, 0.6423, 0.8675]}]}, {"id": "b_20", "type": "paragraph", "text": "Convolutional Layer | 439", "words": [{"w": "Convolutional", "b": [0.6789, 0.9225, 0.7609, 0.9388]}, {"w": "Layer", "b": [0.7637, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "439", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 466, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "from sklearn.datasets import load_sample_image", "words": [{"w": "from", "b": [0.1766, 0.0829, 0.2103, 0.0958]}, {"w": "sklearn.datasets", "b": [0.2188, 0.0829, 0.3537, 0.0958]}, {"w": "import", "b": [0.3621, 0.0829, 0.4127, 0.0958]}, {"w": "load_sample_image", "b": [0.4211, 0.0829, 0.5645, 0.0958]}]}, {"id": "b_1", "type": "paragraph", "text": "# Load sample images china = load_sample_image(\"china.jpg\") / 255 flower = load_sample_image(\"flower.jpg\") / 255 images = np.array([china, flower]) batch_size, height, width, channels = images.shape", "words": [{"w": "#", "b": [0.1766, 0.1138, 0.185, 0.1266]}, {"w": "Load", "b": [0.1935, 0.1138, 0.2272, 0.1266]}, {"w": "sample", "b": [0.2356, 0.1138, 0.2862, 0.1266]}, {"w": "images", "b": [0.2946, 0.1138, 0.3452, 0.1266]}, {"w": "china", "b": [0.1766, 0.1292, 0.2188, 0.142]}, {"w": "=", "b": [0.2272, 0.1292, 0.2356, 0.142]}, {"w": "load_sample_image(\"china.jpg\")", "b": [0.244, 0.1292, 0.497, 0.142]}, {"w": "/", "b": [0.5055, 0.1292, 0.5139, 0.142]}, {"w": "255", "b": [0.5223, 0.1292, 0.5476, 0.142]}, {"w": "flower", "b": [0.1766, 0.1446, 0.2272, 0.1574]}, {"w": "=", "b": [0.2356, 0.1446, 0.244, 0.1574]}, {"w": "load_sample_image(\"flower.jpg\")", "b": [0.2525, 0.1446, 0.5139, 0.1574]}, {"w": "/", "b": [0.5223, 0.1446, 0.5308, 0.1574]}, {"w": "255", "b": [0.5392, 0.1446, 0.5645, 0.1574]}, {"w": "images", "b": [0.1766, 0.16, 0.2272, 0.1729]}, {"w": "=", "b": [0.2356, 0.16, 0.244, 0.1729]}, {"w": "np.array([china,", "b": [0.2525, 0.16, 0.3874, 0.1729]}, {"w": "flower])", "b": [0.3958, 0.16, 0.4633, 0.1729]}, {"w": "batch_size,", "b": [0.1766, 0.1754, 0.2693, 0.1883]}, {"w": "height,", "b": [0.2778, 0.1754, 0.3368, 0.1883]}, {"w": "width,", "b": [0.3452, 0.1754, 0.3958, 0.1883]}, {"w": "channels", "b": [0.4043, 0.1754, 0.4717, 0.1883]}, {"w": "=", "b": [0.4802, 0.1754, 0.4886, 0.1883]}, {"w": "images.shape", "b": [0.497, 0.1754, 0.5982, 0.1883]}]}, {"id": "b_2", "type": "paragraph", "text": "# Create 2 filters filters = np.zeros(shape=(7, 7, channels, 2), dtype=np.float32) filters[:, 3, :, 0] = 1 # vertical line filters[3, :, :, 1] = 1 # horizontal line", "words": [{"w": "#", "b": [0.1766, 0.2063, 0.185, 0.2191]}, {"w": "Create", "b": [0.1935, 0.2063, 0.244, 0.2191]}, {"w": "2", "b": [0.2525, 0.2063, 0.2609, 0.2191]}, {"w": "filters", "b": [0.2693, 0.2063, 0.3284, 0.2191]}, {"w": "filters", "b": [0.1766, 0.2217, 0.2356, 0.2345]}, {"w": "=", "b": [0.244, 0.2217, 0.2525, 0.2345]}, {"w": "np.zeros(shape=(7,", "b": [0.2609, 0.2217, 0.4127, 0.2345]}, {"w": "7,", "b": [0.4211, 0.2217, 0.438, 0.2345]}, {"w": "channels,", "b": [0.4464, 0.2217, 0.5223, 0.2345]}, {"w": "2),", "b": [0.5308, 0.2217, 0.5561, 0.2345]}, {"w": "dtype=np.float32)", "b": [0.5645, 0.2217, 0.7078, 0.2345]}, {"w": "filters[:,", "b": [0.1766, 0.2371, 0.2609, 0.25]}, {"w": "3,", "b": [0.2693, 0.2371, 0.2862, 0.25]}, {"w": ":,", "b": [0.2946, 0.2371, 0.3115, 0.25]}, {"w": "0]", "b": [0.3199, 0.2371, 0.3368, 0.25]}, {"w": "=", "b": [0.3452, 0.2371, 0.3537, 0.25]}, {"w": "1", "b": [0.3621, 0.2371, 0.3705, 0.25]}, {"w": "#", "b": [0.3874, 0.2371, 0.3958, 0.25]}, {"w": "vertical", "b": [0.4043, 0.2371, 0.4717, 0.25]}, {"w": "line", "b": [0.4802, 0.2371, 0.5139, 0.25]}, {"w": "filters[3,", "b": [0.1766, 0.2525, 0.2609, 0.2654]}, {"w": ":,", "b": [0.2693, 0.2525, 0.2862, 0.2654]}, {"w": ":,", "b": [0.2946, 0.2525, 0.3115, 0.2654]}, {"w": "1]", "b": [0.3199, 0.2525, 0.3368, 0.2654]}, {"w": "=", "b": [0.3452, 0.2525, 0.3537, 0.2654]}, {"w": "1", "b": [0.3621, 0.2525, 0.3705, 0.2654]}, {"w": "#", "b": [0.3874, 0.2525, 0.3958, 0.2654]}, {"w": "horizontal", "b": [0.4043, 0.2525, 0.4886, 0.2654]}, {"w": "line", "b": [0.497, 0.2525, 0.5308, 0.2654]}]}, {"id": "b_3", "type": "equation", "text": "outputs = tf.nn.conv2d(images, filters, strides=1, padding=\"SAME\")", "words": [{"w": "outputs", "b": [0.1766, 0.2834, 0.2356, 0.2962]}, {"w": "=", "b": [0.244, 0.2834, 0.2525, 0.2962]}, {"w": "tf.nn.conv2d(images,", "b": [0.2609, 0.2834, 0.4296, 0.2962]}, {"w": "filters,", "b": [0.438, 0.2834, 0.5055, 0.2962]}, {"w": "strides=1,", "b": [0.5139, 0.2834, 0.5982, 0.2962]}, {"w": "padding=\"SAME\")", "b": [0.6066, 0.2834, 0.7331, 0.2962]}]}, {"id": "b_4", "type": "paragraph", "text": "plt.imshow(outputs[0, :, :, 1], cmap=\"gray\") # plot 1st image's 2nd feature map plt.show()", "words": [{"w": "plt.imshow(outputs[0,", "b": [0.1766, 0.3142, 0.3537, 0.3271]}, {"w": ":,", "b": [0.3621, 0.3142, 0.379, 0.3271]}, {"w": ":,", "b": [0.3874, 0.3142, 0.4043, 0.3271]}, {"w": "1],", "b": [0.4127, 0.3142, 0.438, 0.3271]}, {"w": "cmap=\"gray\")", "b": [0.4464, 0.3142, 0.5476, 0.3271]}, {"w": "#", "b": [0.5561, 0.3142, 0.5645, 0.3271]}, {"w": "plot", "b": [0.5729, 0.3142, 0.6066, 0.3271]}, {"w": "1st", "b": [0.6151, 0.3142, 0.6404, 0.3271]}, {"w": "image's", "b": [0.6488, 0.3142, 0.7078, 0.3271]}, {"w": "2nd", "b": [0.7163, 0.3142, 0.7416, 0.3271]}, {"w": "feature", "b": [0.75, 0.3142, 0.809, 0.3271]}, {"w": "map", "b": [0.8175, 0.3142, 0.8428, 0.3271]}, {"w": "plt.show()", "b": [0.1766, 0.3296, 0.2609, 0.3425]}]}, {"id": "b_5", "type": "paragraph", "text": "Most of this code is self-explanatory, but the tf.nn.conv2d() line deserves a bit of explanation:", "words": [{"w": "Most", "b": [0.1429, 0.3512, 0.1855, 0.3726]}, {"w": "of", "b": [0.1925, 0.3512, 0.2093, 0.3726]}, {"w": "this", "b": [0.2162, 0.3512, 0.247, 0.3726]}, {"w": "code", "b": [0.2539, 0.3512, 0.2932, 0.3726]}, {"w": "is", "b": [0.3002, 0.3512, 0.3134, 0.3726]}, {"w": "self-explanatory,", "b": [0.3204, 0.3512, 0.458, 0.3726]}, {"w": "but", "b": [0.465, 0.3512, 0.493, 0.3726]}, {"w": "the", "b": [0.5, 0.3512, 0.5263, 0.3726]}, {"w": "tf.nn.conv2d()", "b": [0.5333, 0.3543, 0.6718, 0.3694]}, {"w": "line", "b": [0.6788, 0.3512, 0.7099, 0.3726]}, {"w": "deserves", "b": [0.7169, 0.3512, 0.7877, 0.3726]}, {"w": "a", "b": [0.7947, 0.3512, 0.8039, 0.3726]}, {"w": "bit", "b": [0.8108, 0.3512, 0.8334, 0.3726]}, {"w": "of", "b": [0.8403, 0.3512, 0.8571, 0.3726]}, {"w": "explanation:", "b": [0.1429, 0.3702, 0.2457, 0.3916]}]}, {"id": "b_6", "type": "equation", "text": "• images is the input mini-batch (a 4D tensor, as explained earlier).", "words": [{"w": "•", "b": [0.16, 0.4053, 0.1682, 0.4267]}, {"w": "images", "b": [0.1786, 0.4085, 0.238, 0.4235]}, {"w": "is", "b": [0.2427, 0.4053, 0.2559, 0.4267]}, {"w": "the", "b": [0.2606, 0.4053, 0.287, 0.4267]}, {"w": "input", "b": [0.2917, 0.4053, 0.3366, 0.4267]}, {"w": "mini-batch", "b": [0.3414, 0.4053, 0.434, 0.4267]}, {"w": "(a", "b": [0.4387, 0.4053, 0.4551, 0.4267]}, {"w": "4D", "b": [0.4598, 0.4053, 0.4851, 0.4267]}, {"w": "tensor,", "b": [0.4899, 0.4053, 0.5459, 0.4267]}, {"w": "as", "b": [0.5506, 0.4053, 0.5674, 0.4267]}, {"w": "explained", "b": [0.5722, 0.4053, 0.653, 0.4267]}, {"w": "earlier).", "b": [0.6577, 0.4053, 0.7229, 0.4267]}]}, {"id": "b_7", "type": "paragraph", "text": "• filters is the set of filters to apply (also a 4D tensor, as explained earlier).", "words": [{"w": "•", "b": [0.16, 0.4313, 0.1681, 0.4527]}, {"w": "filters", "b": [0.1786, 0.4344, 0.2479, 0.4495]}, {"w": "is", "b": [0.2526, 0.4313, 0.2658, 0.4527]}, {"w": "the", "b": [0.2705, 0.4313, 0.2969, 0.4527]}, {"w": "set", "b": [0.3016, 0.4313, 0.3245, 0.4527]}, {"w": "of", "b": [0.3292, 0.4313, 0.346, 0.4527]}, {"w": "filters", "b": [0.3507, 0.4313, 0.3983, 0.4527]}, {"w": "to", "b": [0.403, 0.4313, 0.42, 0.4527]}, {"w": "apply", "b": [0.4247, 0.4313, 0.4702, 0.4527]}, {"w": "(also", "b": [0.4749, 0.4313, 0.5148, 0.4527]}, {"w": "a", "b": [0.5195, 0.4313, 0.5287, 0.4527]}, {"w": "4D", "b": [0.5334, 0.4313, 0.5587, 0.4527]}, {"w": "tensor,", "b": [0.5634, 0.4313, 0.6195, 0.4527]}, {"w": "as", "b": [0.6242, 0.4313, 0.641, 0.4527]}, {"w": "explained", "b": [0.6457, 0.4313, 0.7266, 0.4527]}, {"w": "earlier).", "b": [0.7313, 0.4313, 0.7964, 0.4527]}]}, {"id": "b_8", "type": "paragraph", "text": "• strides is equal to 1, but it could also be a 1D array with 4 elements, where the two central elements are the vertical and horizontal strides (sh and sw). The first and last elements must currently be equal to 1. They may one day be used to specify a batch stride (to skip some instances) and a channel stride (to skip some of the previous layer’s feature maps or channels).", "words": [{"w": "•", "b": [0.16, 0.4573, 0.1681, 0.4787]}, {"w": "strides", "b": [0.1786, 0.4604, 0.2479, 0.4755]}, {"w": "is", "b": [0.2537, 0.4573, 0.267, 0.4787]}, {"w": "equal", "b": [0.2728, 0.4573, 0.3178, 0.4787]}, {"w": "to", "b": [0.3237, 0.4573, 0.3407, 0.4787]}, {"w": "1,", "b": [0.3466, 0.4573, 0.3613, 0.4787]}, {"w": "but", "b": [0.3672, 0.4573, 0.3952, 0.4787]}, {"w": "it", "b": [0.4011, 0.4573, 0.413, 0.4787]}, {"w": "could", "b": [0.4189, 0.4573, 0.4657, 0.4787]}, {"w": "also", "b": [0.4716, 0.4573, 0.5042, 0.4787]}, {"w": "be", "b": [0.5101, 0.4573, 0.5296, 0.4787]}, {"w": "a", "b": [0.5354, 0.4573, 0.5446, 0.4787]}, {"w": "1D", "b": [0.5505, 0.4573, 0.5758, 0.4787]}, {"w": "array", "b": [0.5817, 0.4573, 0.6246, 0.4787]}, {"w": "with", "b": [0.6305, 0.4573, 0.6678, 0.4787]}, {"w": "4", "b": [0.6737, 0.4573, 0.6837, 0.4787]}, {"w": "elements,", "b": [0.6896, 0.4573, 0.7682, 0.4787]}, {"w": "where", "b": [0.7741, 0.4573, 0.8249, 0.4787]}, {"w": "the", "b": [0.8308, 0.4573, 0.8572, 0.4787]}, {"w": "two", "b": [0.1786, 0.4763, 0.2098, 0.4977]}, {"w": "central", "b": [0.2163, 0.4763, 0.2735, 0.4977]}, {"w": "elements", "b": [0.28, 0.4763, 0.3539, 0.4977]}, {"w": "are", "b": [0.3604, 0.4763, 0.3861, 0.4977]}, {"w": "the", "b": [0.3926, 0.4763, 0.4189, 0.4977]}, {"w": "vertical", "b": [0.4254, 0.4763, 0.4868, 0.4977]}, {"w": "and", "b": [0.4933, 0.4763, 0.5248, 0.4977]}, {"w": "horizontal", "b": [0.5313, 0.4763, 0.6175, 0.4977]}, {"w": "strides", "b": [0.624, 0.4763, 0.6788, 0.4977]}, {"w": "(sh", "b": [0.6853, 0.4761, 0.706, 0.4986]}, {"w": "and", "b": [0.7125, 0.4763, 0.744, 0.4977]}, {"w": "sw).", "b": [0.7505, 0.4761, 0.7778, 0.4986]}, {"w": "The", "b": [0.7843, 0.4763, 0.8172, 0.4977]}, {"w": "first", "b": [0.8237, 0.4763, 0.8571, 0.4977]}, {"w": "and", "b": [0.1786, 0.4953, 0.2101, 0.5168]}, {"w": "last", "b": [0.218, 0.4953, 0.2464, 0.5168]}, {"w": "elements", "b": [0.2542, 0.4953, 0.3281, 0.5168]}, {"w": "must", "b": [0.3359, 0.4953, 0.3777, 0.5168]}, {"w": "currently", "b": [0.3855, 0.4953, 0.4619, 0.5168]}, {"w": "be", "b": [0.4697, 0.4953, 0.4891, 0.5168]}, {"w": "equal", "b": [0.497, 0.4953, 0.5419, 0.5168]}, {"w": "to", "b": [0.5498, 0.4953, 0.5668, 0.5168]}, {"w": "1.", "b": [0.5746, 0.4953, 0.5893, 0.5168]}, {"w": "They", "b": [0.5972, 0.4953, 0.6396, 0.5168]}, {"w": "may", "b": [0.6474, 0.4953, 0.6828, 0.5168]}, {"w": "one", "b": [0.6906, 0.4953, 0.7215, 0.5168]}, {"w": "day", "b": [0.7293, 0.4953, 0.7587, 0.5168]}, {"w": "be", "b": [0.7665, 0.4953, 0.7859, 0.5168]}, {"w": "used", "b": [0.7938, 0.4953, 0.8323, 0.5168]}, {"w": "to", "b": [0.8402, 0.4953, 0.8571, 0.5168]}, {"w": "specify", "b": [0.1786, 0.5144, 0.2365, 0.5358]}, {"w": "a", "b": [0.2418, 0.5144, 0.251, 0.5358]}, {"w": "batch", "b": [0.2563, 0.5144, 0.302, 0.5358]}, {"w": "stride", "b": [0.3073, 0.5144, 0.3545, 0.5358]}, {"w": "(to", "b": [0.3599, 0.5144, 0.3841, 0.5358]}, {"w": "skip", "b": [0.3894, 0.5144, 0.4239, 0.5358]}, {"w": "some", "b": [0.4293, 0.5144, 0.4735, 0.5358]}, {"w": "instances)", "b": [0.4788, 0.5144, 0.5629, 0.5358]}, {"w": "and", "b": [0.5682, 0.5144, 0.5998, 0.5358]}, {"w": "a", "b": [0.6051, 0.5144, 0.6143, 0.5358]}, {"w": "channel", "b": [0.6197, 0.5144, 0.6857, 0.5358]}, {"w": "stride", "b": [0.691, 0.5144, 0.7382, 0.5358]}, {"w": "(to", "b": [0.7436, 0.5144, 0.7677, 0.5358]}, {"w": "skip", "b": [0.7731, 0.5144, 0.8076, 0.5358]}, {"w": "some", "b": [0.813, 0.5144, 0.8571, 0.5358]}, {"w": "of", "b": [0.1786, 0.5334, 0.1954, 0.5549]}, {"w": "the", "b": [0.2001, 0.5334, 0.2264, 0.5549]}, {"w": "previous", "b": [0.2312, 0.5334, 0.3032, 0.5549]}, {"w": "layer’s", "b": [0.308, 0.5334, 0.3585, 0.5549]}, {"w": "feature", "b": [0.3632, 0.5334, 0.421, 0.5549]}, {"w": "maps", "b": [0.4257, 0.5334, 0.4701, 0.5549]}, {"w": "or", "b": [0.4748, 0.5334, 0.4931, 0.5549]}, {"w": "channels).", "b": [0.4979, 0.5334, 0.5835, 0.5549]}]}, {"id": "b_9", "type": "paragraph", "text": "• padding must be either \"VALID\" or \"SAME\":", "words": [{"w": "•", "b": [0.16, 0.5594, 0.1682, 0.5808]}, {"w": "padding", "b": [0.1786, 0.5626, 0.2479, 0.5777]}, {"w": "must", "b": [0.2526, 0.5594, 0.2943, 0.5808]}, {"w": "be", "b": [0.299, 0.5594, 0.3185, 0.5808]}, {"w": "either", "b": [0.3232, 0.5594, 0.3717, 0.5808]}, {"w": "\"VALID\"", "b": [0.3764, 0.5626, 0.4457, 0.5777]}, {"w": "or", "b": [0.4504, 0.5594, 0.4688, 0.5808]}, {"w": "\"SAME\":", "b": [0.4735, 0.5594, 0.5376, 0.5808]}]}, {"id": "b_10", "type": "paragraph", "text": "— If set to \"VALID\", the convolutional layer does not use zero padding, and may", "words": [{"w": "—", "b": [0.1807, 0.5854, 0.1999, 0.6068]}, {"w": "If", "b": [0.2044, 0.5854, 0.2176, 0.6068]}, {"w": "set", "b": [0.2234, 0.5854, 0.2462, 0.6068]}, {"w": "to", "b": [0.252, 0.5854, 0.269, 0.6068]}, {"w": "\"VALID\",", "b": [0.2747, 0.5854, 0.3487, 0.6068]}, {"w": "the", "b": [0.3545, 0.5854, 0.3808, 0.6068]}, {"w": "convolutional", "b": [0.3866, 0.5854, 0.5019, 0.6068]}, {"w": "layer", "b": [0.5077, 0.5854, 0.5479, 0.6068]}, {"w": "does", "b": [0.5536, 0.5854, 0.5917, 0.6068]}, {"w": "not", "b": [0.5975, 0.5852, 0.6244, 0.6068]}, {"w": "use", "b": [0.6301, 0.5854, 0.6577, 0.6068]}, {"w": "zero", "b": [0.6634, 0.5854, 0.6994, 0.6068]}, {"w": "padding,", "b": [0.7051, 0.5854, 0.7787, 0.6068]}, {"w": "and", "b": [0.7844, 0.5854, 0.816, 0.6068]}, {"w": "may", "b": [0.8217, 0.5854, 0.8571, 0.6068]}]}, {"id": "b_11", "type": "paragraph", "text": "ignore some rows and columns at the bottom and right of the input image, depending on the stride, as shown in Figure 14-7 (for simplicity, only the hor‐ izontal dimension is shown here, but of course the same logic applies to the vertical dimension).", "words": [{"w": "ignore", "b": [0.2044, 0.6045, 0.2583, 0.6259]}, {"w": "some", "b": [0.2655, 0.6045, 0.3096, 0.6259]}, {"w": "rows", "b": [0.3168, 0.6045, 0.3571, 0.6259]}, {"w": "and", "b": [0.3642, 0.6045, 0.3958, 0.6259]}, {"w": "columns", "b": [0.4029, 0.6045, 0.4748, 0.6259]}, {"w": "at", "b": [0.482, 0.6045, 0.4971, 0.6259]}, {"w": "the", "b": [0.5042, 0.6045, 0.5306, 0.6259]}, {"w": "bottom", "b": [0.5377, 0.6045, 0.5993, 0.6259]}, {"w": "and", "b": [0.6065, 0.6045, 0.638, 0.6259]}, {"w": "right", "b": [0.6452, 0.6045, 0.6853, 0.6259]}, {"w": "of", "b": [0.6925, 0.6045, 0.7093, 0.6259]}, {"w": "the", "b": [0.7164, 0.6045, 0.7428, 0.6259]}, {"w": "input", "b": [0.7499, 0.6045, 0.7948, 0.6259]}, {"w": "image,", "b": [0.802, 0.6045, 0.8571, 0.6259]}, {"w": "depending", "b": [0.2044, 0.6235, 0.2931, 0.6449]}, {"w": "on", "b": [0.2982, 0.6235, 0.3203, 0.6449]}, {"w": "the", "b": [0.3254, 0.6235, 0.3517, 0.6449]}, {"w": "stride,", "b": [0.3568, 0.6235, 0.4087, 0.6449]}, {"w": "as", "b": [0.4138, 0.6235, 0.4306, 0.6449]}, {"w": "shown", "b": [0.4358, 0.6235, 0.4908, 0.6449]}, {"w": "in", "b": [0.4959, 0.6235, 0.5129, 0.6449]}, {"w": "Figure", "b": [0.518, 0.6235, 0.572, 0.6449]}, {"w": "14-7", "b": [0.5768, 0.6235, 0.6142, 0.6449]}, {"w": "(for", "b": [0.6197, 0.6235, 0.6514, 0.6449]}, {"w": "simplicity,", "b": [0.6565, 0.6235, 0.7417, 0.6449]}, {"w": "only", "b": [0.7468, 0.6235, 0.7837, 0.6449]}, {"w": "the", "b": [0.7888, 0.6235, 0.8151, 0.6449]}, {"w": "hor‐", "b": [0.8203, 0.6235, 0.8572, 0.6449]}, {"w": "izontal", "b": [0.2044, 0.6426, 0.2611, 0.664]}, {"w": "dimension", "b": [0.2678, 0.6426, 0.357, 0.664]}, {"w": "is", "b": [0.3637, 0.6426, 0.3769, 0.664]}, {"w": "shown", "b": [0.3836, 0.6426, 0.4387, 0.664]}, {"w": "here,", "b": [0.4454, 0.6426, 0.4867, 0.664]}, {"w": "but", "b": [0.4935, 0.6426, 0.5215, 0.664]}, {"w": "of", "b": [0.5282, 0.6426, 0.545, 0.664]}, {"w": "course", "b": [0.5517, 0.6426, 0.6064, 0.664]}, {"w": "the", "b": [0.6132, 0.6426, 0.6395, 0.664]}, {"w": "same", "b": [0.6462, 0.6426, 0.6889, 0.664]}, {"w": "logic", "b": [0.6957, 0.6426, 0.7357, 0.664]}, {"w": "applies", "b": [0.7424, 0.6426, 0.8004, 0.664]}, {"w": "to", "b": [0.8071, 0.6426, 0.8241, 0.664]}, {"w": "the", "b": [0.8308, 0.6426, 0.8571, 0.664]}, {"w": "vertical", "b": [0.2044, 0.6616, 0.2658, 0.683]}, {"w": "dimension).", "b": [0.2705, 0.6616, 0.3716, 0.683]}]}, {"id": "b_12", "type": "paragraph", "text": "— If set to \"SAME\", the convolutional layer uses zero padding if necessary. In this", "words": [{"w": "—", "b": [0.1807, 0.6876, 0.1999, 0.709]}, {"w": "If", "b": [0.2044, 0.6876, 0.2176, 0.709]}, {"w": "set", "b": [0.223, 0.6876, 0.2458, 0.709]}, {"w": "to", "b": [0.2511, 0.6876, 0.2681, 0.709]}, {"w": "\"SAME\",", "b": [0.2735, 0.6876, 0.3376, 0.709]}, {"w": "the", "b": [0.3429, 0.6876, 0.3692, 0.709]}, {"w": "convolutional", "b": [0.3746, 0.6876, 0.4899, 0.709]}, {"w": "layer", "b": [0.4952, 0.6876, 0.5354, 0.709]}, {"w": "uses", "b": [0.5408, 0.6876, 0.576, 0.709]}, {"w": "zero", "b": [0.5813, 0.6876, 0.6173, 0.709]}, {"w": "padding", "b": [0.6226, 0.6876, 0.6914, 0.709]}, {"w": "if", "b": [0.6967, 0.6876, 0.7085, 0.709]}, {"w": "necessary.", "b": [0.7138, 0.6876, 0.7973, 0.709]}, {"w": "In", "b": [0.8026, 0.6876, 0.8211, 0.709]}, {"w": "this", "b": [0.8264, 0.6876, 0.8571, 0.709]}]}, {"id": "b_13", "type": "paragraph", "text": "case, the number of output neurons is equal to the number of input neurons divided by the stride, rounded up (in this example, 13 / 5 = 2.6, rounded up to 3). Then zeros are added as evenly as possible around the inputs.", "words": [{"w": "case,", "b": [0.2044, 0.7067, 0.2436, 0.7281]}, {"w": "the", "b": [0.2498, 0.7067, 0.2761, 0.7281]}, {"w": "number", "b": [0.2823, 0.7067, 0.3486, 0.7281]}, {"w": "of", "b": [0.3549, 0.7067, 0.3716, 0.7281]}, {"w": "output", "b": [0.3779, 0.7067, 0.4342, 0.7281]}, {"w": "neurons", "b": [0.4405, 0.7067, 0.5092, 0.7281]}, {"w": "is", "b": [0.5154, 0.7067, 0.5286, 0.7281]}, {"w": "equal", "b": [0.5348, 0.7067, 0.5798, 0.7281]}, {"w": "to", "b": [0.586, 0.7067, 0.603, 0.7281]}, {"w": "the", "b": [0.6092, 0.7067, 0.6356, 0.7281]}, {"w": "number", "b": [0.6418, 0.7067, 0.7081, 0.7281]}, {"w": "of", "b": [0.7143, 0.7067, 0.7311, 0.7281]}, {"w": "input", "b": [0.7373, 0.7067, 0.7822, 0.7281]}, {"w": "neurons", "b": [0.7884, 0.7067, 0.8571, 0.7281]}, {"w": "divided", "b": [0.2044, 0.7257, 0.267, 0.7471]}, {"w": "by", "b": [0.272, 0.7257, 0.2922, 0.7471]}, {"w": "the", "b": [0.2972, 0.7257, 0.3235, 0.7471]}, {"w": "stride,", "b": [0.3285, 0.7257, 0.3804, 0.7471]}, {"w": "rounded", "b": [0.3854, 0.7257, 0.457, 0.7471]}, {"w": "up", "b": [0.462, 0.7257, 0.484, 0.7471]}, {"w": "(in", "b": [0.489, 0.7257, 0.5132, 0.7471]}, {"w": "this", "b": [0.5182, 0.7257, 0.5489, 0.7471]}, {"w": "example,", "b": [0.5539, 0.7257, 0.6282, 0.7471]}, {"w": "13", "b": [0.6331, 0.7257, 0.6531, 0.7471]}, {"w": "/", "b": [0.6581, 0.7257, 0.665, 0.7471]}, {"w": "5", "b": [0.67, 0.7257, 0.68, 0.7471]}, {"w": "=", "b": [0.685, 0.7257, 0.6971, 0.7471]}, {"w": "2.6,", "b": [0.7021, 0.7257, 0.7316, 0.7471]}, {"w": "rounded", "b": [0.7366, 0.7257, 0.8082, 0.7471]}, {"w": "up", "b": [0.8132, 0.7257, 0.8352, 0.7471]}, {"w": "to", "b": [0.8402, 0.7257, 0.8571, 0.7471]}, {"w": "3).", "b": [0.2044, 0.7447, 0.2263, 0.7662]}, {"w": "Then", "b": [0.231, 0.7447, 0.2753, 0.7662]}, {"w": "zeros", "b": [0.28, 0.7447, 0.3236, 0.7662]}, {"w": "are", "b": [0.3283, 0.7447, 0.3541, 0.7662]}, {"w": "added", "b": [0.3588, 0.7447, 0.4098, 0.7662]}, {"w": "as", "b": [0.4145, 0.7447, 0.4313, 0.7662]}, {"w": "evenly", "b": [0.436, 0.7447, 0.4896, 0.7662]}, {"w": "as", "b": [0.4944, 0.7447, 0.5111, 0.7662]}, {"w": "possible", "b": [0.5159, 0.7447, 0.583, 0.7662]}, {"w": "around", "b": [0.5877, 0.7447, 0.6487, 0.7662]}, {"w": "the", "b": [0.6534, 0.7447, 0.6798, 0.7662]}, {"w": "inputs.", "b": [0.6845, 0.7447, 0.7418, 0.7662]}]}, {"id": "b_14", "type": "paragraph", "text": "440 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "440", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3683, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 467, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 14-7. Padding options—input width: 13, filter width: 6, stride: 5", "words": [{"w": "Figure", "b": [0.1429, 0.4222, 0.1943, 0.4438]}, {"w": "14-7.", "b": [0.1991, 0.4222, 0.2407, 0.4438]}, {"w": "Padding", "b": [0.2455, 0.4222, 0.3124, 0.4438]}, {"w": "options—input", "b": [0.3172, 0.4222, 0.4384, 0.4438]}, {"w": "width:", "b": [0.4431, 0.4222, 0.495, 0.4438]}, {"w": "13,", "b": [0.4998, 0.4222, 0.5245, 0.4438]}, {"w": "filter", "b": [0.5293, 0.4222, 0.5679, 0.4438]}, {"w": "width:", "b": [0.5727, 0.4222, 0.6246, 0.4438]}, {"w": "6,", "b": [0.6293, 0.4222, 0.6442, 0.4438]}, {"w": "stride:", "b": [0.6489, 0.4222, 0.6991, 0.4438]}, {"w": "5", "b": [0.7039, 0.4222, 0.7138, 0.4438]}]}, {"id": "b_1", "type": "paragraph", "text": "In this example, we manually defined the filters, but in a real CNN you would nor‐ mally define filters as trainable variables, so the neural net can learn which filters work best, as explained earlier. Instead of manually creating the variables, however, you can simply use the keras.layers.Conv2D layer:", "words": [{"w": "In", "b": [0.1429, 0.4596, 0.1614, 0.481]}, {"w": "this", "b": [0.1679, 0.4596, 0.1986, 0.481]}, {"w": "example,", "b": [0.2051, 0.4596, 0.2794, 0.481]}, {"w": "we", "b": [0.286, 0.4596, 0.3091, 0.481]}, {"w": "manually", "b": [0.3156, 0.4596, 0.3931, 0.481]}, {"w": "defined", "b": [0.3997, 0.4596, 0.4625, 0.481]}, {"w": "the", "b": [0.4691, 0.4596, 0.4954, 0.481]}, {"w": "filters,", "b": [0.5019, 0.4596, 0.5543, 0.481]}, {"w": "but", "b": [0.5608, 0.4596, 0.5888, 0.481]}, {"w": "in", "b": [0.5954, 0.4596, 0.6123, 0.481]}, {"w": "a", "b": [0.6189, 0.4596, 0.628, 0.481]}, {"w": "real", "b": [0.6345, 0.4596, 0.6655, 0.481]}, {"w": "CNN", "b": [0.6721, 0.4596, 0.7169, 0.481]}, {"w": "you", "b": [0.7234, 0.4596, 0.7547, 0.481]}, {"w": "would", "b": [0.7612, 0.4596, 0.8134, 0.481]}, {"w": "nor‐", "b": [0.82, 0.4596, 0.8571, 0.481]}, {"w": "mally", "b": [0.1429, 0.4786, 0.1892, 0.5001]}, {"w": "define", "b": [0.1972, 0.4786, 0.249, 0.5001]}, {"w": "filters", "b": [0.2571, 0.4786, 0.3047, 0.5001]}, {"w": "as", "b": [0.3127, 0.4786, 0.3295, 0.5001]}, {"w": "trainable", "b": [0.3375, 0.4786, 0.4116, 0.5001]}, {"w": "variables,", "b": [0.4196, 0.4786, 0.498, 0.5001]}, {"w": "so", "b": [0.506, 0.4786, 0.5243, 0.5001]}, {"w": "the", "b": [0.5323, 0.4786, 0.5586, 0.5001]}, {"w": "neural", "b": [0.5667, 0.4786, 0.6201, 0.5001]}, {"w": "net", "b": [0.6281, 0.4786, 0.6548, 0.5001]}, {"w": "can", "b": [0.6628, 0.4786, 0.6921, 0.5001]}, {"w": "learn", "b": [0.7002, 0.4786, 0.7426, 0.5001]}, {"w": "which", "b": [0.7506, 0.4786, 0.8015, 0.5001]}, {"w": "filters", "b": [0.8095, 0.4786, 0.8571, 0.5001]}, {"w": "work", "b": [0.1429, 0.4977, 0.1858, 0.5191]}, {"w": "best,", "b": [0.1928, 0.4977, 0.231, 0.5191]}, {"w": "as", "b": [0.2379, 0.4977, 0.2547, 0.5191]}, {"w": "explained", "b": [0.2617, 0.4977, 0.3426, 0.5191]}, {"w": "earlier.", "b": [0.3495, 0.4977, 0.4061, 0.5191]}, {"w": "Instead", "b": [0.4131, 0.4977, 0.4746, 0.5191]}, {"w": "of", "b": [0.4816, 0.4977, 0.4983, 0.5191]}, {"w": "manually", "b": [0.5053, 0.4977, 0.5828, 0.5191]}, {"w": "creating", "b": [0.5898, 0.4977, 0.657, 0.5191]}, {"w": "the", "b": [0.664, 0.4977, 0.6903, 0.5191]}, {"w": "variables,", "b": [0.6973, 0.4977, 0.7756, 0.5191]}, {"w": "however,", "b": [0.7826, 0.4977, 0.8572, 0.5191]}, {"w": "you", "b": [0.1429, 0.5176, 0.1741, 0.539]}, {"w": "can", "b": [0.1788, 0.5176, 0.2082, 0.539]}, {"w": "simply", "b": [0.2129, 0.5176, 0.2686, 0.539]}, {"w": "use", "b": [0.2733, 0.5176, 0.3009, 0.539]}, {"w": "the", "b": [0.3056, 0.5176, 0.3319, 0.539]}, {"w": "keras.layers.Conv2D", "b": [0.3367, 0.5208, 0.5247, 0.5359]}, {"w": "layer:", "b": [0.5294, 0.5176, 0.5748, 0.539]}]}, {"id": "b_2", "type": "paragraph", "text": "conv = keras.layers.Conv2D(filters=32, kernel_size=3, strides=1, padding=\"SAME\", activation=\"relu\")", "words": [{"w": "conv", "b": [0.1766, 0.5496, 0.2103, 0.5625]}, {"w": "=", "b": [0.2188, 0.5496, 0.2272, 0.5625]}, {"w": "keras.layers.Conv2D(filters=32,", "b": [0.2356, 0.5496, 0.497, 0.5625]}, {"w": "kernel_size=3,", "b": [0.5055, 0.5496, 0.6235, 0.5625]}, {"w": "strides=1,", "b": [0.6319, 0.5496, 0.7163, 0.5625]}, {"w": "padding=\"SAME\",", "b": [0.4043, 0.565, 0.5308, 0.5779]}, {"w": "activation=\"relu\")", "b": [0.5392, 0.565, 0.691, 0.5779]}]}, {"id": "b_3", "type": "paragraph", "text": "This code creates a Conv2D layer with 32 filters, each 3 × 3, using a stride of 1 (both horizontally and vertically), SAME padding, and applying the ReLU activation func‐ tion to its outputs. As you can see, convolutional layers have quite a few hyperpara‐ meters: you must choose the number of filters, their height and width, the strides, and the padding type. As always, you can use cross-validation to find the right hyperpara‐ meter values, but this is very time-consuming. We will discuss common CNN archi‐ tectures later, to give you some idea of what hyperparameter values work best in practice.", "words": [{"w": "This", "b": [0.1428, 0.5866, 0.1801, 0.608]}, {"w": "code", "b": [0.1863, 0.5866, 0.2256, 0.608]}, {"w": "creates", "b": [0.2319, 0.5866, 0.2889, 0.608]}, {"w": "a", "b": [0.2952, 0.5866, 0.3044, 0.608]}, {"w": "Conv2D", "b": [0.3106, 0.5897, 0.37, 0.6048]}, {"w": "layer", "b": [0.3763, 0.5866, 0.4165, 0.608]}, {"w": "with", "b": [0.4228, 0.5866, 0.4601, 0.608]}, {"w": "32", "b": [0.4664, 0.5866, 0.4864, 0.608]}, {"w": "filters,", "b": [0.4927, 0.5866, 0.545, 0.608]}, {"w": "each", "b": [0.5513, 0.5866, 0.5893, 0.608]}, {"w": "3", "b": [0.5956, 0.5866, 0.6056, 0.608]}, {"w": "×", "b": [0.6118, 0.5866, 0.6239, 0.608]}, {"w": "3,", "b": [0.6302, 0.5866, 0.645, 0.608]}, {"w": "using", "b": [0.6513, 0.5866, 0.6967, 0.608]}, {"w": "a", "b": [0.703, 0.5866, 0.7121, 0.608]}, {"w": "stride", "b": [0.7184, 0.5866, 0.7656, 0.608]}, {"w": "of", "b": [0.7719, 0.5866, 0.7887, 0.608]}, {"w": "1", "b": [0.7949, 0.5866, 0.8049, 0.608]}, {"w": "(both", "b": [0.8112, 0.5866, 0.8571, 0.608]}, {"w": "horizontally", "b": [0.1429, 0.6056, 0.2439, 0.627]}, {"w": "and", "b": [0.25, 0.6056, 0.2815, 0.627]}, {"w": "vertically),", "b": [0.2876, 0.6056, 0.3758, 0.627]}, {"w": "SAME", "b": [0.3818, 0.6056, 0.4365, 0.627]}, {"w": "padding,", "b": [0.4426, 0.6056, 0.5161, 0.627]}, {"w": "and", "b": [0.5222, 0.6056, 0.5537, 0.627]}, {"w": "applying", "b": [0.5598, 0.6056, 0.6319, 0.627]}, {"w": "the", "b": [0.638, 0.6056, 0.6643, 0.627]}, {"w": "ReLU", "b": [0.6704, 0.6056, 0.7179, 0.627]}, {"w": "activation", "b": [0.724, 0.6056, 0.8062, 0.627]}, {"w": "func‐", "b": [0.8123, 0.6056, 0.8571, 0.627]}, {"w": "tion", "b": [0.1429, 0.6247, 0.1768, 0.6461]}, {"w": "to", "b": [0.1831, 0.6247, 0.2001, 0.6461]}, {"w": "its", "b": [0.2063, 0.6247, 0.2259, 0.6461]}, {"w": "outputs.", "b": [0.2322, 0.6247, 0.3009, 0.6461]}, {"w": "As", "b": [0.3072, 0.6247, 0.3292, 0.6461]}, {"w": "you", "b": [0.3355, 0.6247, 0.3668, 0.6461]}, {"w": "can", "b": [0.373, 0.6247, 0.4024, 0.6461]}, {"w": "see,", "b": [0.4086, 0.6247, 0.4387, 0.6461]}, {"w": "convolutional", "b": [0.445, 0.6247, 0.5603, 0.6461]}, {"w": "layers", "b": [0.5666, 0.6247, 0.6144, 0.6461]}, {"w": "have", "b": [0.6207, 0.6247, 0.6591, 0.6461]}, {"w": "quite", "b": [0.6654, 0.6247, 0.7079, 0.6461]}, {"w": "a", "b": [0.7141, 0.6247, 0.7233, 0.6461]}, {"w": "few", "b": [0.7295, 0.6247, 0.7588, 0.6461]}, {"w": "hyperpara‐", "b": [0.7651, 0.6247, 0.8571, 0.6461]}, {"w": "meters:", "b": [0.1429, 0.6437, 0.2041, 0.6651]}, {"w": "you", "b": [0.2088, 0.6437, 0.2401, 0.6651]}, {"w": "must", "b": [0.2448, 0.6437, 0.2865, 0.6651]}, {"w": "choose", "b": [0.2913, 0.6437, 0.349, 0.6651]}, {"w": "the", "b": [0.3537, 0.6437, 0.38, 0.6651]}, {"w": "number", "b": [0.3847, 0.6437, 0.451, 0.6651]}, {"w": "of", "b": [0.4558, 0.6437, 0.4726, 0.6651]}, {"w": "filters,", "b": [0.4773, 0.6437, 0.5296, 0.6651]}, {"w": "their", "b": [0.5344, 0.6437, 0.574, 0.6651]}, {"w": "height", "b": [0.5787, 0.6437, 0.6311, 0.6651]}, {"w": "and", "b": [0.6359, 0.6437, 0.6674, 0.6651]}, {"w": "width,", "b": [0.6721, 0.6437, 0.7252, 0.6651]}, {"w": "the", "b": [0.73, 0.6437, 0.7563, 0.6651]}, {"w": "strides,", "b": [0.761, 0.6437, 0.8206, 0.6651]}, {"w": "and", "b": [0.8253, 0.6437, 0.8569, 0.6651]}, {"w": "the", "b": [0.1429, 0.6628, 0.1692, 0.6842]}, {"w": "padding", "b": [0.1743, 0.6628, 0.2431, 0.6842]}, {"w": "type.", "b": [0.2482, 0.6628, 0.2886, 0.6842]}, {"w": "As", "b": [0.2937, 0.6628, 0.3157, 0.6842]}, {"w": "always,", "b": [0.3208, 0.6628, 0.3802, 0.6842]}, {"w": "you", "b": [0.3853, 0.6628, 0.4166, 0.6842]}, {"w": "can", "b": [0.4217, 0.6628, 0.451, 0.6842]}, {"w": "use", "b": [0.4561, 0.6628, 0.4837, 0.6842]}, {"w": "cross-validation", "b": [0.4888, 0.6628, 0.622, 0.6842]}, {"w": "to", "b": [0.6271, 0.6628, 0.6441, 0.6842]}, {"w": "find", "b": [0.6492, 0.6628, 0.6833, 0.6842]}, {"w": "the", "b": [0.6884, 0.6628, 0.7147, 0.6842]}, {"w": "right", "b": [0.7198, 0.6628, 0.76, 0.6842]}, {"w": "hyperpara‐", "b": [0.7651, 0.6628, 0.8571, 0.6842]}, {"w": "meter", "b": [0.1429, 0.6818, 0.1917, 0.7032]}, {"w": "values,", "b": [0.1976, 0.6818, 0.254, 0.7032]}, {"w": "but", "b": [0.2598, 0.6818, 0.2878, 0.7032]}, {"w": "this", "b": [0.2937, 0.6818, 0.3244, 0.7032]}, {"w": "is", "b": [0.3302, 0.6818, 0.3435, 0.7032]}, {"w": "very", "b": [0.3493, 0.6818, 0.3857, 0.7032]}, {"w": "time-consuming.", "b": [0.3916, 0.6818, 0.5349, 0.7032]}, {"w": "We", "b": [0.5408, 0.6818, 0.5679, 0.7032]}, {"w": "will", "b": [0.5737, 0.6818, 0.6041, 0.7032]}, {"w": "discuss", "b": [0.61, 0.6818, 0.6694, 0.7032]}, {"w": "common", "b": [0.6752, 0.6818, 0.7508, 0.7032]}, {"w": "CNN", "b": [0.7567, 0.6818, 0.8015, 0.7032]}, {"w": "archi‐", "b": [0.8073, 0.6818, 0.8572, 0.7032]}, {"w": "tectures", "b": [0.1429, 0.7008, 0.2085, 0.7223]}, {"w": "later,", "b": [0.2165, 0.7008, 0.2569, 0.7223]}, {"w": "to", "b": [0.2649, 0.7008, 0.2818, 0.7223]}, {"w": "give", "b": [0.2898, 0.7008, 0.3236, 0.7223]}, {"w": "you", "b": [0.3316, 0.7008, 0.3629, 0.7223]}, {"w": "some", "b": [0.3708, 0.7008, 0.415, 0.7223]}, {"w": "idea", "b": [0.423, 0.7008, 0.4576, 0.7223]}, {"w": "of", "b": [0.4656, 0.7008, 0.4823, 0.7223]}, {"w": "what", "b": [0.4903, 0.7008, 0.5308, 0.7223]}, {"w": "hyperparameter", "b": [0.5388, 0.7008, 0.6723, 0.7223]}, {"w": "values", "b": [0.6803, 0.7008, 0.7319, 0.7223]}, {"w": "work", "b": [0.7399, 0.7008, 0.7828, 0.7223]}, {"w": "best", "b": [0.7908, 0.7008, 0.8242, 0.7223]}, {"w": "in", "b": [0.8322, 0.7008, 0.8492, 0.7223]}, {"w": "practice.", "b": [0.1429, 0.7199, 0.2138, 0.7413]}]}, {"id": "b_4", "type": "paragraph", "text": "Memory Requirements", "words": [{"w": "Memory", "b": [0.1428, 0.7541, 0.228, 0.7826]}, {"w": "Requirements", "b": [0.2329, 0.7541, 0.378, 0.7826]}]}, {"id": "b_5", "type": "paragraph", "text": "Another problem with CNNs is that the convolutional layers require a huge amount of RAM. This is especially true during training, because the reverse pass of backpro‐ pagation requires all the intermediate values computed during the forward pass.", "words": [{"w": "Another", "b": [0.1429, 0.7885, 0.2133, 0.81]}, {"w": "problem", "b": [0.2194, 0.7885, 0.2905, 0.81]}, {"w": "with", "b": [0.2965, 0.7885, 0.3339, 0.81]}, {"w": "CNNs", "b": [0.34, 0.7885, 0.3919, 0.81]}, {"w": "is", "b": [0.3979, 0.7885, 0.4112, 0.81]}, {"w": "that", "b": [0.4172, 0.7885, 0.4498, 0.81]}, {"w": "the", "b": [0.4559, 0.7885, 0.4822, 0.81]}, {"w": "convolutional", "b": [0.4883, 0.7885, 0.6037, 0.81]}, {"w": "layers", "b": [0.6097, 0.7885, 0.6576, 0.81]}, {"w": "require", "b": [0.6637, 0.7885, 0.7241, 0.81]}, {"w": "a", "b": [0.7302, 0.7885, 0.7393, 0.81]}, {"w": "huge", "b": [0.7454, 0.7885, 0.7858, 0.81]}, {"w": "amount", "b": [0.7919, 0.7885, 0.8572, 0.81]}, {"w": "of", "b": [0.1429, 0.8076, 0.1597, 0.829]}, {"w": "RAM.", "b": [0.1655, 0.8076, 0.2162, 0.829]}, {"w": "This", "b": [0.222, 0.8076, 0.2593, 0.829]}, {"w": "is", "b": [0.2651, 0.8076, 0.2784, 0.829]}, {"w": "especially", "b": [0.2842, 0.8076, 0.3641, 0.829]}, {"w": "true", "b": [0.37, 0.8076, 0.404, 0.829]}, {"w": "during", "b": [0.4099, 0.8076, 0.4664, 0.829]}, {"w": "training,", "b": [0.4723, 0.8076, 0.544, 0.829]}, {"w": "because", "b": [0.5499, 0.8076, 0.6144, 0.829]}, {"w": "the", "b": [0.6203, 0.8076, 0.6466, 0.829]}, {"w": "reverse", "b": [0.6525, 0.8076, 0.7118, 0.829]}, {"w": "pass", "b": [0.7177, 0.8076, 0.753, 0.829]}, {"w": "of", "b": [0.7589, 0.8076, 0.7757, 0.829]}, {"w": "backpro‐", "b": [0.7816, 0.8076, 0.8571, 0.829]}, {"w": "pagation", "b": [0.1429, 0.8266, 0.2154, 0.848]}, {"w": "requires", "b": [0.2201, 0.8266, 0.2882, 0.848]}, {"w": "all", "b": [0.2929, 0.8266, 0.3126, 0.848]}, {"w": "the", "b": [0.3174, 0.8266, 0.3437, 0.848]}, {"w": "intermediate", "b": [0.3484, 0.8266, 0.4544, 0.848]}, {"w": "values", "b": [0.4591, 0.8266, 0.5107, 0.848]}, {"w": "computed", "b": [0.5155, 0.8266, 0.5998, 0.848]}, {"w": "during", "b": [0.6045, 0.8266, 0.661, 0.848]}, {"w": "the", "b": [0.6657, 0.8266, 0.6921, 0.848]}, {"w": "forward", "b": [0.6968, 0.8266, 0.7641, 0.848]}, {"w": "pass.", "b": [0.7688, 0.8266, 0.8089, 0.848]}]}, {"id": "b_6", "type": "paragraph", "text": "For example, consider a convolutional layer with 5 × 5 filters, outputting 200 feature maps of size 150 × 100, with stride 1 and SAME padding. If the input is a 150 × 100", "words": [{"w": "For", "b": [0.1429, 0.8548, 0.1718, 0.8762]}, {"w": "example,", "b": [0.1777, 0.8548, 0.2519, 0.8762]}, {"w": "consider", "b": [0.2578, 0.8548, 0.3294, 0.8762]}, {"w": "a", "b": [0.3352, 0.8548, 0.3444, 0.8762]}, {"w": "convolutional", "b": [0.3502, 0.8548, 0.4655, 0.8762]}, {"w": "layer", "b": [0.4714, 0.8548, 0.5116, 0.8762]}, {"w": "with", "b": [0.5174, 0.8548, 0.5547, 0.8762]}, {"w": "5", "b": [0.5605, 0.8548, 0.5705, 0.8762]}, {"w": "×", "b": [0.5764, 0.8548, 0.5884, 0.8762]}, {"w": "5", "b": [0.5943, 0.8548, 0.6043, 0.8762]}, {"w": "filters,", "b": [0.6101, 0.8548, 0.6624, 0.8762]}, {"w": "outputting", "b": [0.6683, 0.8548, 0.7577, 0.8762]}, {"w": "200", "b": [0.7635, 0.8548, 0.7935, 0.8762]}, {"w": "feature", "b": [0.7994, 0.8548, 0.8571, 0.8762]}, {"w": "maps", "b": [0.1429, 0.8738, 0.1872, 0.8952]}, {"w": "of", "b": [0.1931, 0.8738, 0.2099, 0.8952]}, {"w": "size", "b": [0.2158, 0.8738, 0.2467, 0.8952]}, {"w": "150", "b": [0.2526, 0.8738, 0.2826, 0.8952]}, {"w": "×", "b": [0.2885, 0.8738, 0.3006, 0.8952]}, {"w": "100,", "b": [0.3065, 0.8738, 0.3412, 0.8952]}, {"w": "with", "b": [0.3471, 0.8738, 0.3845, 0.8952]}, {"w": "stride", "b": [0.3904, 0.8738, 0.4375, 0.8952]}, {"w": "1", "b": [0.4435, 0.8738, 0.4535, 0.8952]}, {"w": "and", "b": [0.4594, 0.8738, 0.4909, 0.8952]}, {"w": "SAME", "b": [0.4968, 0.8738, 0.5515, 0.8952]}, {"w": "padding.", "b": [0.5574, 0.8738, 0.6309, 0.8952]}, {"w": "If", "b": [0.6368, 0.8738, 0.6501, 0.8952]}, {"w": "the", "b": [0.656, 0.8738, 0.6823, 0.8952]}, {"w": "input", "b": [0.6882, 0.8738, 0.7332, 0.8952]}, {"w": "is", "b": [0.7391, 0.8738, 0.7523, 0.8952]}, {"w": "a", "b": [0.7582, 0.8738, 0.7674, 0.8952]}, {"w": "150", "b": [0.7733, 0.8738, 0.8033, 0.8952]}, {"w": "×", "b": [0.8092, 0.8738, 0.8212, 0.8952]}, {"w": "100", "b": [0.8272, 0.8738, 0.8572, 0.8952]}]}, {"id": "b_7", "type": "paragraph", "text": "Convolutional Layer | 441", "words": [{"w": "Convolutional", "b": [0.6789, 0.9225, 0.7609, 0.9388]}, {"w": "Layer", "b": [0.7637, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "441", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 468, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "7 A fully connected layer with 150 × 100 neurons, each connected to all 150 × 100 × 3 inputs, would have 1502", "words": [{"w": "7", "b": [0.1451, 0.8416, 0.1518, 0.8559]}, {"w": "A", "b": [0.1587, 0.8401, 0.1697, 0.8565]}, {"w": "fully", "b": [0.1733, 0.8401, 0.2017, 0.8565]}, {"w": "connected", "b": [0.2053, 0.8401, 0.271, 0.8565]}, {"w": "layer", "b": [0.2746, 0.8401, 0.3052, 0.8565]}, {"w": "with", "b": [0.3088, 0.8401, 0.3372, 0.8565]}, {"w": "150", "b": [0.3408, 0.8401, 0.3637, 0.8565]}, {"w": "×", "b": [0.3673, 0.8401, 0.3765, 0.8565]}, {"w": "100", "b": [0.3801, 0.8401, 0.403, 0.8565]}, {"w": "neurons,", "b": [0.4066, 0.8401, 0.4625, 0.8565]}, {"w": "each", "b": [0.4661, 0.8401, 0.495, 0.8565]}, {"w": "connected", "b": [0.4986, 0.8401, 0.5642, 0.8565]}, {"w": "to", "b": [0.5678, 0.8401, 0.5808, 0.8565]}, {"w": "all", "b": [0.5844, 0.8401, 0.5994, 0.8565]}, {"w": "150", "b": [0.603, 0.8401, 0.6258, 0.8565]}, {"w": "×", "b": [0.6294, 0.8401, 0.6387, 0.8565]}, {"w": "100", "b": [0.6423, 0.8401, 0.6651, 0.8565]}, {"w": "×", "b": [0.6687, 0.8401, 0.6779, 0.8565]}, {"w": "3", "b": [0.6815, 0.8401, 0.6891, 0.8565]}, {"w": "inputs,", "b": [0.6927, 0.8401, 0.7364, 0.8565]}, {"w": "would", "b": [0.74, 0.8401, 0.7798, 0.8565]}, {"w": "have", "b": [0.7834, 0.8401, 0.8127, 0.8565]}, {"w": "1502", "b": [0.8163, 0.8387, 0.8451, 0.8565]}]}, {"id": "b_1", "type": "equation", "text": "× 1002 × 3 = 675 million parameters!", "words": [{"w": "×", "b": [0.1587, 0.8553, 0.1679, 0.8716]}, {"w": "1002", "b": [0.1715, 0.8538, 0.2004, 0.8716]}, {"w": "×", "b": [0.204, 0.8553, 0.2132, 0.8716]}, {"w": "3", "b": [0.2168, 0.8553, 0.2244, 0.8716]}, {"w": "=", "b": [0.228, 0.8553, 0.2372, 0.8716]}, {"w": "675", "b": [0.2408, 0.8553, 0.2637, 0.8716]}, {"w": "million", "b": [0.2673, 0.8553, 0.3136, 0.8716]}, {"w": "parameters!", "b": [0.3172, 0.8553, 0.3928, 0.8716]}]}, {"id": "b_2", "type": "paragraph", "text": "8 In the international system of units (SI), 1 MB = 1,000 kB = 1,000 × 1,000 bytes = 1,000 × 1,000 × 8 bits.", "words": [{"w": "8", "b": [0.1451, 0.8764, 0.1518, 0.8907]}, {"w": "In", "b": [0.1587, 0.8749, 0.1728, 0.8912]}, {"w": "the", "b": [0.1764, 0.8749, 0.1965, 0.8912]}, {"w": "international", "b": [0.2001, 0.8749, 0.2824, 0.8912]}, {"w": "system", "b": [0.286, 0.8749, 0.3295, 0.8912]}, {"w": "of", "b": [0.3331, 0.8749, 0.3459, 0.8912]}, {"w": "units", "b": [0.3495, 0.8749, 0.3816, 0.8912]}, {"w": "(SI),", "b": [0.3852, 0.8749, 0.4127, 0.8912]}, {"w": "1", "b": [0.4163, 0.8749, 0.4239, 0.8912]}, {"w": "MB", "b": [0.4275, 0.8749, 0.451, 0.8912]}, {"w": "=", "b": [0.4546, 0.8749, 0.4638, 0.8912]}, {"w": "1,000", "b": [0.4674, 0.8749, 0.5015, 0.8912]}, {"w": "kB", "b": [0.5051, 0.8749, 0.5223, 0.8912]}, {"w": "=", "b": [0.5259, 0.8749, 0.5351, 0.8912]}, {"w": "1,000", "b": [0.5387, 0.8749, 0.5728, 0.8912]}, {"w": "×", "b": [0.5764, 0.8749, 0.5857, 0.8912]}, {"w": "1,000", "b": [0.5893, 0.8749, 0.6233, 0.8912]}, {"w": "bytes", "b": [0.627, 0.8749, 0.6597, 0.8912]}, {"w": "=", "b": [0.6633, 0.8749, 0.6725, 0.8912]}, {"w": "1,000", "b": [0.6761, 0.8749, 0.7102, 0.8912]}, {"w": "×", "b": [0.7138, 0.8749, 0.723, 0.8912]}, {"w": "1,000", "b": [0.7266, 0.8749, 0.7607, 0.8912]}, {"w": "×", "b": [0.7643, 0.8749, 0.7735, 0.8912]}, {"w": "8", "b": [0.7771, 0.8749, 0.7848, 0.8912]}, {"w": "bits.", "b": [0.7884, 0.8749, 0.815, 0.8912]}]}, {"id": "b_3", "type": "paragraph", "text": "RGB image (three channels), then the number of parameters is (5 × 5 × 3 + 1) × 200 = 15,200 (the +1 corresponds to the bias terms), which is fairly small compared to a fully connected layer.7 However, each of the 200 feature maps contains 150 × 100 neu‐ rons, and each of these neurons needs to compute a weighted sum of its 5 × 5 × 3 = 75 inputs: that’s a total of 225 million float multiplications. Not as bad as a fully con‐ nected layer, but still quite computationally intensive. Moreover, if the feature maps are represented using 32-bit floats, then the convolutional layer’s output will occupy 200 × 150 × 100 × 32 = 96 million bits (12 MB) of RAM.8 And that’s just for one instance! If a training batch contains 100 instances, then this layer will use up 1.2 GB of RAM!", "words": [{"w": "RGB", "b": [0.1429, 0.0791, 0.1829, 0.1005]}, {"w": "image", "b": [0.1886, 0.0791, 0.239, 0.1005]}, {"w": "(three", "b": [0.2446, 0.0791, 0.2947, 0.1005]}, {"w": "channels),", "b": [0.3004, 0.0791, 0.386, 0.1005]}, {"w": "then", "b": [0.3916, 0.0791, 0.4294, 0.1005]}, {"w": "the", "b": [0.435, 0.0791, 0.4613, 0.1005]}, {"w": "number", "b": [0.467, 0.0791, 0.5333, 0.1005]}, {"w": "of", "b": [0.5389, 0.0791, 0.5557, 0.1005]}, {"w": "parameters", "b": [0.5613, 0.0791, 0.6548, 0.1005]}, {"w": "is", "b": [0.6604, 0.0791, 0.6736, 0.1005]}, {"w": "(5", "b": [0.6793, 0.0791, 0.6965, 0.1005]}, {"w": "×", "b": [0.7021, 0.0791, 0.7142, 0.1005]}, {"w": "5", "b": [0.7199, 0.0791, 0.7299, 0.1005]}, {"w": "×", "b": [0.7355, 0.0791, 0.7476, 0.1005]}, {"w": "3", "b": [0.7532, 0.0791, 0.7632, 0.1005]}, {"w": "+", "b": [0.7689, 0.0791, 0.7809, 0.1005]}, {"w": "1)", "b": [0.7866, 0.0791, 0.8038, 0.1005]}, {"w": "×", "b": [0.8094, 0.0791, 0.8215, 0.1005]}, {"w": "200", "b": [0.8272, 0.0791, 0.8572, 0.1005]}, {"w": "=", "b": [0.1429, 0.0981, 0.1549, 0.1195]}, {"w": "15,200", "b": [0.161, 0.0981, 0.2158, 0.1195]}, {"w": "(the", "b": [0.2218, 0.0981, 0.2554, 0.1195]}, {"w": "+1", "b": [0.2615, 0.0981, 0.2835, 0.1195]}, {"w": "corresponds", "b": [0.2896, 0.0981, 0.3926, 0.1195]}, {"w": "to", "b": [0.3987, 0.0981, 0.4156, 0.1195]}, {"w": "the", "b": [0.4217, 0.0981, 0.448, 0.1195]}, {"w": "bias", "b": [0.4541, 0.0981, 0.4871, 0.1195]}, {"w": "terms),", "b": [0.4932, 0.0981, 0.5528, 0.1195]}, {"w": "which", "b": [0.5588, 0.0981, 0.6097, 0.1195]}, {"w": "is", "b": [0.6158, 0.0981, 0.629, 0.1195]}, {"w": "fairly", "b": [0.6351, 0.0981, 0.6786, 0.1195]}, {"w": "small", "b": [0.6847, 0.0981, 0.729, 0.1195]}, {"w": "compared", "b": [0.7351, 0.0981, 0.8189, 0.1195]}, {"w": "to", "b": [0.8249, 0.0981, 0.8419, 0.1195]}, {"w": "a", "b": [0.848, 0.0981, 0.8571, 0.1195]}, {"w": "fully", "b": [0.1429, 0.1172, 0.1802, 0.1386]}, {"w": "connected", "b": [0.1849, 0.1172, 0.271, 0.1386]}, {"w": "layer.7", "b": [0.2757, 0.1172, 0.3254, 0.1386]}, {"w": "However,", "b": [0.3302, 0.1172, 0.4091, 0.1386]}, {"w": "each", "b": [0.4139, 0.1172, 0.4519, 0.1386]}, {"w": "of", "b": [0.4567, 0.1172, 0.4735, 0.1386]}, {"w": "the", "b": [0.4784, 0.1172, 0.5047, 0.1386]}, {"w": "200", "b": [0.5096, 0.1172, 0.5396, 0.1386]}, {"w": "feature", "b": [0.5444, 0.1172, 0.6022, 0.1386]}, {"w": "maps", "b": [0.6071, 0.1172, 0.6515, 0.1386]}, {"w": "contains", "b": [0.6563, 0.1172, 0.7269, 0.1386]}, {"w": "150", "b": [0.7317, 0.1172, 0.7617, 0.1386]}, {"w": "×", "b": [0.7666, 0.1172, 0.7787, 0.1386]}, {"w": "100", "b": [0.7835, 0.1172, 0.8135, 0.1386]}, {"w": "neu‐", "b": [0.8184, 0.1172, 0.8571, 0.1386]}, {"w": "rons,", "b": [0.1429, 0.1362, 0.185, 0.1576]}, {"w": "and", "b": [0.191, 0.1362, 0.2225, 0.1576]}, {"w": "each", "b": [0.2285, 0.1362, 0.2664, 0.1576]}, {"w": "of", "b": [0.2724, 0.1362, 0.2892, 0.1576]}, {"w": "these", "b": [0.2952, 0.1362, 0.338, 0.1576]}, {"w": "neurons", "b": [0.344, 0.1362, 0.4127, 0.1576]}, {"w": "needs", "b": [0.4186, 0.1362, 0.4664, 0.1576]}, {"w": "to", "b": [0.4723, 0.1362, 0.4893, 0.1576]}, {"w": "compute", "b": [0.4953, 0.1362, 0.5686, 0.1576]}, {"w": "a", "b": [0.5745, 0.1362, 0.5837, 0.1576]}, {"w": "weighted", "b": [0.5897, 0.1362, 0.6651, 0.1576]}, {"w": "sum", "b": [0.671, 0.1362, 0.7068, 0.1576]}, {"w": "of", "b": [0.7128, 0.1362, 0.7296, 0.1576]}, {"w": "its", "b": [0.7355, 0.1362, 0.7551, 0.1576]}, {"w": "5", "b": [0.7611, 0.1362, 0.7711, 0.1576]}, {"w": "×", "b": [0.777, 0.1362, 0.7891, 0.1576]}, {"w": "5", "b": [0.7951, 0.1362, 0.8051, 0.1576]}, {"w": "×", "b": [0.8111, 0.1362, 0.8231, 0.1576]}, {"w": "3", "b": [0.8291, 0.1362, 0.8391, 0.1576]}, {"w": "=", "b": [0.8451, 0.1362, 0.8572, 0.1576]}, {"w": "75", "b": [0.1429, 0.1553, 0.1629, 0.1767]}, {"w": "inputs:", "b": [0.1686, 0.1553, 0.2259, 0.1767]}, {"w": "that’s", "b": [0.2316, 0.1553, 0.2739, 0.1767]}, {"w": "a", "b": [0.2796, 0.1553, 0.2888, 0.1767]}, {"w": "total", "b": [0.2945, 0.1553, 0.3322, 0.1767]}, {"w": "of", "b": [0.338, 0.1553, 0.3548, 0.1767]}, {"w": "225", "b": [0.3605, 0.1553, 0.3905, 0.1767]}, {"w": "million", "b": [0.3962, 0.1553, 0.457, 0.1767]}, {"w": "float", "b": [0.4627, 0.1553, 0.4998, 0.1767]}, {"w": "multiplications.", "b": [0.5056, 0.1553, 0.6362, 0.1767]}, {"w": "Not", "b": [0.6419, 0.1553, 0.6738, 0.1767]}, {"w": "as", "b": [0.6795, 0.1553, 0.6963, 0.1767]}, {"w": "bad", "b": [0.702, 0.1553, 0.7328, 0.1767]}, {"w": "as", "b": [0.7385, 0.1553, 0.7553, 0.1767]}, {"w": "a", "b": [0.761, 0.1553, 0.7701, 0.1767]}, {"w": "fully", "b": [0.7759, 0.1553, 0.8132, 0.1767]}, {"w": "con‐", "b": [0.8189, 0.1553, 0.8571, 0.1767]}, {"w": "nected", "b": [0.1429, 0.1743, 0.1981, 0.1957]}, {"w": "layer,", "b": [0.2048, 0.1743, 0.2484, 0.1957]}, {"w": "but", "b": [0.255, 0.1743, 0.283, 0.1957]}, {"w": "still", "b": [0.2896, 0.1743, 0.3198, 0.1957]}, {"w": "quite", "b": [0.3264, 0.1743, 0.3689, 0.1957]}, {"w": "computationally", "b": [0.3755, 0.1743, 0.5119, 0.1957]}, {"w": "intensive.", "b": [0.5186, 0.1743, 0.5982, 0.1957]}, {"w": "Moreover,", "b": [0.6049, 0.1743, 0.6904, 0.1957]}, {"w": "if", "b": [0.697, 0.1743, 0.7088, 0.1957]}, {"w": "the", "b": [0.7154, 0.1743, 0.7417, 0.1957]}, {"w": "feature", "b": [0.7484, 0.1743, 0.8061, 0.1957]}, {"w": "maps", "b": [0.8128, 0.1743, 0.8571, 0.1957]}, {"w": "are", "b": [0.1428, 0.1933, 0.1686, 0.2148]}, {"w": "represented", "b": [0.1749, 0.1933, 0.2727, 0.2148]}, {"w": "using", "b": [0.279, 0.1933, 0.3244, 0.2148]}, {"w": "32-bit", "b": [0.3307, 0.1933, 0.3807, 0.2148]}, {"w": "floats,", "b": [0.387, 0.1933, 0.4365, 0.2148]}, {"w": "then", "b": [0.4428, 0.1933, 0.4806, 0.2148]}, {"w": "the", "b": [0.4869, 0.1933, 0.5132, 0.2148]}, {"w": "convolutional", "b": [0.5195, 0.1933, 0.6348, 0.2148]}, {"w": "layer’s", "b": [0.6412, 0.1933, 0.6917, 0.2148]}, {"w": "output", "b": [0.698, 0.1933, 0.7543, 0.2148]}, {"w": "will", "b": [0.7606, 0.1933, 0.791, 0.2148]}, {"w": "occupy", "b": [0.7973, 0.1933, 0.8571, 0.2148]}, {"w": "200", "b": [0.1429, 0.2124, 0.1729, 0.2338]}, {"w": "×", "b": [0.1803, 0.2124, 0.1924, 0.2338]}, {"w": "150", "b": [0.1999, 0.2124, 0.2299, 0.2338]}, {"w": "×", "b": [0.2373, 0.2124, 0.2494, 0.2338]}, {"w": "100", "b": [0.2569, 0.2124, 0.2869, 0.2338]}, {"w": "×", "b": [0.2943, 0.2124, 0.3064, 0.2338]}, {"w": "32", "b": [0.3139, 0.2124, 0.3339, 0.2338]}, {"w": "=", "b": [0.3413, 0.2124, 0.3534, 0.2338]}, {"w": "96", "b": [0.3609, 0.2124, 0.3809, 0.2338]}, {"w": "million", "b": [0.3883, 0.2124, 0.4491, 0.2338]}, {"w": "bits", "b": [0.4566, 0.2124, 0.4867, 0.2338]}, {"w": "(12", "b": [0.4942, 0.2124, 0.5214, 0.2338]}, {"w": "MB)", "b": [0.5289, 0.2124, 0.5669, 0.2338]}, {"w": "of", "b": [0.5743, 0.2124, 0.5911, 0.2338]}, {"w": "RAM.8", "b": [0.5986, 0.2124, 0.6549, 0.2338]}, {"w": "And", "b": [0.6624, 0.2124, 0.6992, 0.2338]}, {"w": "that’s", "b": [0.7066, 0.2124, 0.749, 0.2338]}, {"w": "just", "b": [0.7564, 0.2124, 0.7868, 0.2338]}, {"w": "for", "b": [0.7943, 0.2124, 0.8188, 0.2338]}, {"w": "one", "b": [0.8263, 0.2124, 0.8571, 0.2338]}, {"w": "instance!", "b": [0.1429, 0.2314, 0.2178, 0.2529]}, {"w": "If", "b": [0.2233, 0.2314, 0.2365, 0.2529]}, {"w": "a", "b": [0.242, 0.2314, 0.2511, 0.2529]}, {"w": "training", "b": [0.2566, 0.2314, 0.3235, 0.2529]}, {"w": "batch", "b": [0.329, 0.2314, 0.3746, 0.2529]}, {"w": "contains", "b": [0.38, 0.2314, 0.4506, 0.2529]}, {"w": "100", "b": [0.4561, 0.2314, 0.4861, 0.2529]}, {"w": "instances,", "b": [0.4915, 0.2314, 0.5731, 0.2529]}, {"w": "then", "b": [0.5785, 0.2314, 0.6163, 0.2529]}, {"w": "this", "b": [0.6217, 0.2314, 0.6524, 0.2529]}, {"w": "layer", "b": [0.6579, 0.2314, 0.6981, 0.2529]}, {"w": "will", "b": [0.7035, 0.2314, 0.7339, 0.2529]}, {"w": "use", "b": [0.7394, 0.2314, 0.7669, 0.2529]}, {"w": "up", "b": [0.7724, 0.2314, 0.7944, 0.2529]}, {"w": "1.2", "b": [0.7998, 0.2314, 0.8246, 0.2529]}, {"w": "GB", "b": [0.83, 0.2314, 0.8572, 0.2529]}, {"w": "of", "b": [0.1429, 0.2505, 0.1597, 0.2719]}, {"w": "RAM!", "b": [0.1644, 0.2505, 0.216, 0.2719]}]}, {"id": "b_4", "type": "paragraph", "text": "During inference (i.e., when making a prediction for a new instance) the RAM occu‐ pied by one layer can be released as soon as the next layer has been computed, so you only need as much RAM as required by two consecutive layers. But during training everything computed during the forward pass needs to be preserved for the reverse pass, so the amount of RAM needed is (at least) the total amount of RAM required by all layers.", "words": [{"w": "During", "b": [0.1429, 0.2786, 0.2037, 0.3]}, {"w": "inference", "b": [0.2092, 0.2786, 0.2868, 0.3]}, {"w": "(i.e.,", "b": [0.2923, 0.2786, 0.3282, 0.3]}, {"w": "when", "b": [0.3337, 0.2786, 0.3794, 0.3]}, {"w": "making", "b": [0.3849, 0.2786, 0.4481, 0.3]}, {"w": "a", "b": [0.4536, 0.2786, 0.4628, 0.3]}, {"w": "prediction", "b": [0.4683, 0.2786, 0.5551, 0.3]}, {"w": "for", "b": [0.5606, 0.2786, 0.5851, 0.3]}, {"w": "a", "b": [0.5906, 0.2786, 0.5998, 0.3]}, {"w": "new", "b": [0.6053, 0.2786, 0.6398, 0.3]}, {"w": "instance)", "b": [0.6453, 0.2786, 0.7217, 0.3]}, {"w": "the", "b": [0.7272, 0.2786, 0.7535, 0.3]}, {"w": "RAM", "b": [0.759, 0.2786, 0.8049, 0.3]}, {"w": "occu‐", "b": [0.8104, 0.2786, 0.8571, 0.3]}, {"w": "pied", "b": [0.1429, 0.2977, 0.1792, 0.3191]}, {"w": "by", "b": [0.1844, 0.2977, 0.2045, 0.3191]}, {"w": "one", "b": [0.2097, 0.2977, 0.2405, 0.3191]}, {"w": "layer", "b": [0.2457, 0.2977, 0.2859, 0.3191]}, {"w": "can", "b": [0.291, 0.2977, 0.3204, 0.3191]}, {"w": "be", "b": [0.3255, 0.2977, 0.345, 0.3191]}, {"w": "released", "b": [0.3501, 0.2977, 0.4175, 0.3191]}, {"w": "as", "b": [0.4226, 0.2977, 0.4394, 0.3191]}, {"w": "soon", "b": [0.4446, 0.2977, 0.4849, 0.3191]}, {"w": "as", "b": [0.49, 0.2977, 0.5068, 0.3191]}, {"w": "the", "b": [0.512, 0.2977, 0.5383, 0.3191]}, {"w": "next", "b": [0.5434, 0.2977, 0.5799, 0.3191]}, {"w": "layer", "b": [0.585, 0.2977, 0.6252, 0.3191]}, {"w": "has", "b": [0.6304, 0.2977, 0.6583, 0.3191]}, {"w": "been", "b": [0.6634, 0.2977, 0.7031, 0.3191]}, {"w": "computed,", "b": [0.7083, 0.2977, 0.7973, 0.3191]}, {"w": "so", "b": [0.8025, 0.2977, 0.8207, 0.3191]}, {"w": "you", "b": [0.8259, 0.2977, 0.8571, 0.3191]}, {"w": "only", "b": [0.1428, 0.3167, 0.1797, 0.3381]}, {"w": "need", "b": [0.1862, 0.3167, 0.2263, 0.3381]}, {"w": "as", "b": [0.2327, 0.3167, 0.2495, 0.3381]}, {"w": "much", "b": [0.256, 0.3167, 0.3036, 0.3381]}, {"w": "RAM", "b": [0.3101, 0.3167, 0.356, 0.3381]}, {"w": "as", "b": [0.3625, 0.3167, 0.3793, 0.3381]}, {"w": "required", "b": [0.3857, 0.3167, 0.4572, 0.3381]}, {"w": "by", "b": [0.4636, 0.3167, 0.4838, 0.3381]}, {"w": "two", "b": [0.4902, 0.3167, 0.5215, 0.3381]}, {"w": "consecutive", "b": [0.5279, 0.3167, 0.6256, 0.3381]}, {"w": "layers.", "b": [0.632, 0.3167, 0.6846, 0.3381]}, {"w": "But", "b": [0.6911, 0.3167, 0.7208, 0.3381]}, {"w": "during", "b": [0.7272, 0.3167, 0.7837, 0.3381]}, {"w": "training", "b": [0.7902, 0.3167, 0.8571, 0.3381]}, {"w": "everything", "b": [0.1429, 0.3358, 0.2323, 0.3572]}, {"w": "computed", "b": [0.2389, 0.3358, 0.3232, 0.3572]}, {"w": "during", "b": [0.3298, 0.3358, 0.3863, 0.3572]}, {"w": "the", "b": [0.3929, 0.3358, 0.4192, 0.3572]}, {"w": "forward", "b": [0.4258, 0.3358, 0.493, 0.3572]}, {"w": "pass", "b": [0.4996, 0.3358, 0.535, 0.3572]}, {"w": "needs", "b": [0.5415, 0.3358, 0.5893, 0.3572]}, {"w": "to", "b": [0.5959, 0.3358, 0.6128, 0.3572]}, {"w": "be", "b": [0.6194, 0.3358, 0.6389, 0.3572]}, {"w": "preserved", "b": [0.6454, 0.3358, 0.7273, 0.3572]}, {"w": "for", "b": [0.7338, 0.3358, 0.7584, 0.3572]}, {"w": "the", "b": [0.7649, 0.3358, 0.7913, 0.3572]}, {"w": "reverse", "b": [0.7978, 0.3358, 0.8572, 0.3572]}, {"w": "pass,", "b": [0.1429, 0.3548, 0.183, 0.3762]}, {"w": "so", "b": [0.1878, 0.3548, 0.2061, 0.3762]}, {"w": "the", "b": [0.211, 0.3548, 0.2373, 0.3762]}, {"w": "amount", "b": [0.2422, 0.3548, 0.3074, 0.3762]}, {"w": "of", "b": [0.3123, 0.3548, 0.3291, 0.3762]}, {"w": "RAM", "b": [0.334, 0.3548, 0.3799, 0.3762]}, {"w": "needed", "b": [0.3848, 0.3548, 0.4447, 0.3762]}, {"w": "is", "b": [0.4496, 0.3548, 0.4628, 0.3762]}, {"w": "(at", "b": [0.4677, 0.3548, 0.49, 0.3762]}, {"w": "least)", "b": [0.4949, 0.3548, 0.5394, 0.3762]}, {"w": "the", "b": [0.5443, 0.3548, 0.5706, 0.3762]}, {"w": "total", "b": [0.5755, 0.3548, 0.6132, 0.3762]}, {"w": "amount", "b": [0.6181, 0.3548, 0.6833, 0.3762]}, {"w": "of", "b": [0.6882, 0.3548, 0.705, 0.3762]}, {"w": "RAM", "b": [0.7099, 0.3548, 0.7558, 0.3762]}, {"w": "required", "b": [0.7607, 0.3548, 0.8321, 0.3762]}, {"w": "by", "b": [0.837, 0.3548, 0.8571, 0.3762]}, {"w": "all", "b": [0.1429, 0.3738, 0.1625, 0.3953]}, {"w": "layers.", "b": [0.1673, 0.3738, 0.2199, 0.3953]}]}, {"id": "b_5", "type": "paragraph", "text": "If training crashes because of an out-of-memory error, you can try reducing the mini-batch size. Alternatively, you can try reducing dimensionality using a stride, or removing a few layers. Or you can try using 16-bit floats instead of 32-bit floats. Or you could distrib‐ ute the CNN across multiple devices.", "words": [{"w": "If", "b": [0.2714, 0.4158, 0.2835, 0.4354]}, {"w": "training", "b": [0.2888, 0.4158, 0.35, 0.4354]}, {"w": "crashes", "b": [0.3552, 0.4158, 0.411, 0.4354]}, {"w": "because", "b": [0.4162, 0.4158, 0.4752, 0.4354]}, {"w": "of", "b": [0.4805, 0.4158, 0.4958, 0.4354]}, {"w": "an", "b": [0.5011, 0.4158, 0.5199, 0.4354]}, {"w": "out-of-memory", "b": [0.5251, 0.4158, 0.645, 0.4354]}, {"w": "error,", "b": [0.6503, 0.4158, 0.6924, 0.4354]}, {"w": "you", "b": [0.6977, 0.4158, 0.7262, 0.4354]}, {"w": "can", "b": [0.7315, 0.4158, 0.7583, 0.4354]}, {"w": "try", "b": [0.7635, 0.4158, 0.7857, 0.4354]}, {"w": "reducing", "b": [0.2714, 0.4332, 0.3392, 0.4528]}, {"w": "the", "b": [0.3465, 0.4332, 0.3706, 0.4528]}, {"w": "mini-batch", "b": [0.3778, 0.4332, 0.4625, 0.4528]}, {"w": "size.", "b": [0.4698, 0.4332, 0.5023, 0.4528]}, {"w": "Alternatively,", "b": [0.5096, 0.4332, 0.6113, 0.4528]}, {"w": "you", "b": [0.6186, 0.4332, 0.6471, 0.4528]}, {"w": "can", "b": [0.6544, 0.4332, 0.6812, 0.4528]}, {"w": "try", "b": [0.6885, 0.4332, 0.7106, 0.4528]}, {"w": "reducing", "b": [0.7179, 0.4332, 0.7857, 0.4528]}, {"w": "dimensionality", "b": [0.2714, 0.4506, 0.3858, 0.4702]}, {"w": "using", "b": [0.3905, 0.4506, 0.432, 0.4702]}, {"w": "a", "b": [0.4368, 0.4506, 0.4451, 0.4702]}, {"w": "stride,", "b": [0.4499, 0.4506, 0.4974, 0.4702]}, {"w": "or", "b": [0.5021, 0.4506, 0.5189, 0.4702]}, {"w": "removing", "b": [0.5236, 0.4506, 0.5974, 0.4702]}, {"w": "a", "b": [0.6021, 0.4506, 0.6105, 0.4702]}, {"w": "few", "b": [0.6152, 0.4506, 0.642, 0.4702]}, {"w": "layers.", "b": [0.6467, 0.4506, 0.6948, 0.4702]}, {"w": "Or", "b": [0.6995, 0.4506, 0.7208, 0.4702]}, {"w": "you", "b": [0.7256, 0.4506, 0.7541, 0.4702]}, {"w": "can", "b": [0.7589, 0.4506, 0.7857, 0.4702]}, {"w": "try", "b": [0.2714, 0.468, 0.2936, 0.4876]}, {"w": "using", "b": [0.2985, 0.468, 0.34, 0.4876]}, {"w": "16-bit", "b": [0.3449, 0.468, 0.3905, 0.4876]}, {"w": "floats", "b": [0.3954, 0.468, 0.4364, 0.4876]}, {"w": "instead", "b": [0.4412, 0.468, 0.4961, 0.4876]}, {"w": "of", "b": [0.501, 0.468, 0.5163, 0.4876]}, {"w": "32-bit", "b": [0.5212, 0.468, 0.5668, 0.4876]}, {"w": "floats.", "b": [0.5717, 0.468, 0.617, 0.4876]}, {"w": "Or", "b": [0.6219, 0.468, 0.6432, 0.4876]}, {"w": "you", "b": [0.6481, 0.468, 0.6766, 0.4876]}, {"w": "could", "b": [0.6815, 0.468, 0.7243, 0.4876]}, {"w": "distrib‐", "b": [0.7291, 0.468, 0.7857, 0.4876]}, {"w": "ute", "b": [0.2714, 0.4854, 0.2954, 0.505]}, {"w": "the", "b": [0.2998, 0.4854, 0.3238, 0.505]}, {"w": "CNN", "b": [0.3282, 0.4854, 0.3691, 0.505]}, {"w": "across", "b": [0.3735, 0.4854, 0.4206, 0.505]}, {"w": "multiple", "b": [0.425, 0.4854, 0.4889, 0.505]}, {"w": "devices.", "b": [0.4933, 0.4854, 0.5528, 0.505]}]}, {"id": "b_6", "type": "paragraph", "text": "Now let’s look at the second common building block of CNNs: the pooling layer.", "words": [{"w": "Now", "b": [0.1428, 0.5253, 0.1827, 0.5467]}, {"w": "let’s", "b": [0.1874, 0.5253, 0.2177, 0.5467]}, {"w": "look", "b": [0.2224, 0.5253, 0.2592, 0.5467]}, {"w": "at", "b": [0.264, 0.5253, 0.2791, 0.5467]}, {"w": "the", "b": [0.2838, 0.5253, 0.3101, 0.5467]}, {"w": "second", "b": [0.3149, 0.5253, 0.3732, 0.5467]}, {"w": "common", "b": [0.3779, 0.5253, 0.4535, 0.5467]}, {"w": "building", "b": [0.4582, 0.5253, 0.5285, 0.5467]}, {"w": "block", "b": [0.5332, 0.5253, 0.5788, 0.5467]}, {"w": "of", "b": [0.5836, 0.5253, 0.6003, 0.5467]}, {"w": "CNNs:", "b": [0.6051, 0.5253, 0.6617, 0.5467]}, {"w": "the", "b": [0.6665, 0.5253, 0.6928, 0.5467]}, {"w": "pooling", "b": [0.6975, 0.5251, 0.7567, 0.5467]}, {"w": "layer.", "b": [0.7615, 0.5251, 0.8062, 0.5467]}]}, {"id": "b_7", "type": "paragraph", "text": "Pooling Layer", "words": [{"w": "Pooling", "b": [0.1429, 0.5597, 0.2376, 0.594]}, {"w": "Layer", "b": [0.2436, 0.5597, 0.311, 0.594]}]}, {"id": "b_8", "type": "paragraph", "text": "Once you understand how convolutional layers work, the pooling layers are quite easy to grasp. Their goal is to subsample (i.e., shrink) the input image in order to reduce the computational load, the memory usage, and the number of parameters (thereby limiting the risk of overfitting).", "words": [{"w": "Once", "b": [0.1429, 0.6009, 0.1875, 0.6223]}, {"w": "you", "b": [0.1956, 0.6009, 0.2269, 0.6223]}, {"w": "understand", "b": [0.235, 0.6009, 0.3306, 0.6223]}, {"w": "how", "b": [0.3387, 0.6009, 0.3747, 0.6223]}, {"w": "convolutional", "b": [0.3828, 0.6009, 0.4982, 0.6223]}, {"w": "layers", "b": [0.5063, 0.6009, 0.5541, 0.6223]}, {"w": "work,", "b": [0.5623, 0.6009, 0.61, 0.6223]}, {"w": "the", "b": [0.6181, 0.6009, 0.6444, 0.6223]}, {"w": "pooling", "b": [0.6525, 0.6009, 0.7167, 0.6223]}, {"w": "layers", "b": [0.7248, 0.6009, 0.7727, 0.6223]}, {"w": "are", "b": [0.7808, 0.6009, 0.8065, 0.6223]}, {"w": "quite", "b": [0.8147, 0.6009, 0.8572, 0.6223]}, {"w": "easy", "b": [0.1429, 0.62, 0.1781, 0.6414]}, {"w": "to", "b": [0.186, 0.62, 0.203, 0.6414]}, {"w": "grasp.", "b": [0.2109, 0.62, 0.2603, 0.6414]}, {"w": "Their", "b": [0.2682, 0.62, 0.3144, 0.6414]}, {"w": "goal", "b": [0.3223, 0.62, 0.3571, 0.6414]}, {"w": "is", "b": [0.365, 0.62, 0.3783, 0.6414]}, {"w": "to", "b": [0.3862, 0.62, 0.4032, 0.6414]}, {"w": "subsample", "b": [0.4111, 0.6197, 0.4951, 0.6414]}, {"w": "(i.e.,", "b": [0.5031, 0.62, 0.539, 0.6414]}, {"w": "shrink)", "b": [0.5469, 0.62, 0.6079, 0.6414]}, {"w": "the", "b": [0.6159, 0.62, 0.6422, 0.6414]}, {"w": "input", "b": [0.6502, 0.62, 0.6951, 0.6414]}, {"w": "image", "b": [0.703, 0.62, 0.7534, 0.6414]}, {"w": "in", "b": [0.7614, 0.62, 0.7783, 0.6414]}, {"w": "order", "b": [0.7863, 0.62, 0.8322, 0.6414]}, {"w": "to", "b": [0.8402, 0.62, 0.8571, 0.6414]}, {"w": "reduce", "b": [0.1429, 0.639, 0.1992, 0.6604]}, {"w": "the", "b": [0.207, 0.639, 0.2333, 0.6604]}, {"w": "computational", "b": [0.2411, 0.639, 0.3627, 0.6604]}, {"w": "load,", "b": [0.3705, 0.639, 0.4113, 0.6604]}, {"w": "the", "b": [0.4191, 0.639, 0.4454, 0.6604]}, {"w": "memory", "b": [0.4532, 0.639, 0.5247, 0.6604]}, {"w": "usage,", "b": [0.5325, 0.639, 0.5837, 0.6604]}, {"w": "and", "b": [0.5915, 0.639, 0.6231, 0.6604]}, {"w": "the", "b": [0.6309, 0.639, 0.6572, 0.6604]}, {"w": "number", "b": [0.665, 0.639, 0.7313, 0.6604]}, {"w": "of", "b": [0.7391, 0.639, 0.7559, 0.6604]}, {"w": "parameters", "b": [0.7637, 0.639, 0.8571, 0.6604]}, {"w": "(thereby", "b": [0.1428, 0.658, 0.2131, 0.6795]}, {"w": "limiting", "b": [0.2178, 0.658, 0.2844, 0.6795]}, {"w": "the", "b": [0.2892, 0.658, 0.3155, 0.6795]}, {"w": "risk", "b": [0.3202, 0.658, 0.3515, 0.6795]}, {"w": "of", "b": [0.3562, 0.658, 0.373, 0.6795]}, {"w": "overfitting).", "b": [0.3778, 0.658, 0.4778, 0.6795]}]}, {"id": "b_9", "type": "paragraph", "text": "Just like in convolutional layers, each neuron in a pooling layer is connected to the outputs of a limited number of neurons in the previous layer, located within a small rectangular receptive field. You must define its size, the stride, and the padding type, just like before. However, a pooling neuron has no weights; all it does is aggregate the inputs using an aggregation function such as the max or mean. Figure 14-8 shows a max pooling layer, which is the most common type of pooling layer. In this example,", "words": [{"w": "Just", "b": [0.1428, 0.6862, 0.1741, 0.7076]}, {"w": "like", "b": [0.181, 0.6862, 0.211, 0.7076]}, {"w": "in", "b": [0.2179, 0.6862, 0.2348, 0.7076]}, {"w": "convolutional", "b": [0.2417, 0.6862, 0.357, 0.7076]}, {"w": "layers,", "b": [0.3639, 0.6862, 0.4165, 0.7076]}, {"w": "each", "b": [0.4233, 0.6862, 0.4613, 0.7076]}, {"w": "neuron", "b": [0.4681, 0.6862, 0.5292, 0.7076]}, {"w": "in", "b": [0.536, 0.6862, 0.553, 0.7076]}, {"w": "a", "b": [0.5599, 0.6862, 0.569, 0.7076]}, {"w": "pooling", "b": [0.5759, 0.6862, 0.64, 0.7076]}, {"w": "layer", "b": [0.6469, 0.6862, 0.6871, 0.7076]}, {"w": "is", "b": [0.6939, 0.6862, 0.7072, 0.7076]}, {"w": "connected", "b": [0.714, 0.6862, 0.8001, 0.7076]}, {"w": "to", "b": [0.807, 0.6862, 0.8239, 0.7076]}, {"w": "the", "b": [0.8308, 0.6862, 0.8571, 0.7076]}, {"w": "outputs", "b": [0.1429, 0.7052, 0.2069, 0.7266]}, {"w": "of", "b": [0.213, 0.7052, 0.2298, 0.7266]}, {"w": "a", "b": [0.236, 0.7052, 0.2452, 0.7266]}, {"w": "limited", "b": [0.2513, 0.7052, 0.311, 0.7266]}, {"w": "number", "b": [0.3172, 0.7052, 0.3835, 0.7266]}, {"w": "of", "b": [0.3896, 0.7052, 0.4064, 0.7266]}, {"w": "neurons", "b": [0.4126, 0.7052, 0.4813, 0.7266]}, {"w": "in", "b": [0.4875, 0.7052, 0.5045, 0.7266]}, {"w": "the", "b": [0.5106, 0.7052, 0.537, 0.7266]}, {"w": "previous", "b": [0.5431, 0.7052, 0.6152, 0.7266]}, {"w": "layer,", "b": [0.6213, 0.7052, 0.665, 0.7266]}, {"w": "located", "b": [0.6711, 0.7052, 0.7308, 0.7266]}, {"w": "within", "b": [0.737, 0.7052, 0.7913, 0.7266]}, {"w": "a", "b": [0.7974, 0.7052, 0.8066, 0.7266]}, {"w": "small", "b": [0.8128, 0.7052, 0.8572, 0.7266]}, {"w": "rectangular", "b": [0.1429, 0.7243, 0.2381, 0.7457]}, {"w": "receptive", "b": [0.2439, 0.7243, 0.3195, 0.7457]}, {"w": "field.", "b": [0.3253, 0.7243, 0.3669, 0.7457]}, {"w": "You", "b": [0.3727, 0.7243, 0.4051, 0.7457]}, {"w": "must", "b": [0.4109, 0.7243, 0.4526, 0.7457]}, {"w": "define", "b": [0.4584, 0.7243, 0.5103, 0.7457]}, {"w": "its", "b": [0.5161, 0.7243, 0.5356, 0.7457]}, {"w": "size,", "b": [0.5414, 0.7243, 0.577, 0.7457]}, {"w": "the", "b": [0.5828, 0.7243, 0.6091, 0.7457]}, {"w": "stride,", "b": [0.6149, 0.7243, 0.6669, 0.7457]}, {"w": "and", "b": [0.6727, 0.7243, 0.7042, 0.7457]}, {"w": "the", "b": [0.71, 0.7243, 0.7363, 0.7457]}, {"w": "padding", "b": [0.7421, 0.7243, 0.8109, 0.7457]}, {"w": "type,", "b": [0.8167, 0.7243, 0.8571, 0.7457]}, {"w": "just", "b": [0.1429, 0.7433, 0.1732, 0.7647]}, {"w": "like", "b": [0.1784, 0.7433, 0.2084, 0.7647]}, {"w": "before.", "b": [0.2135, 0.7433, 0.2711, 0.7647]}, {"w": "However,", "b": [0.2762, 0.7433, 0.3551, 0.7647]}, {"w": "a", "b": [0.3602, 0.7433, 0.3694, 0.7647]}, {"w": "pooling", "b": [0.3745, 0.7433, 0.4387, 0.7647]}, {"w": "neuron", "b": [0.4438, 0.7433, 0.5049, 0.7647]}, {"w": "has", "b": [0.51, 0.7433, 0.5379, 0.7647]}, {"w": "no", "b": [0.543, 0.7433, 0.565, 0.7647]}, {"w": "weights;", "b": [0.5702, 0.7433, 0.6381, 0.7647]}, {"w": "all", "b": [0.6432, 0.7433, 0.6629, 0.7647]}, {"w": "it", "b": [0.6681, 0.7433, 0.68, 0.7647]}, {"w": "does", "b": [0.6851, 0.7433, 0.7233, 0.7647]}, {"w": "is", "b": [0.7284, 0.7433, 0.7416, 0.7647]}, {"w": "aggregate", "b": [0.7467, 0.7433, 0.8257, 0.7647]}, {"w": "the", "b": [0.8308, 0.7433, 0.8571, 0.7647]}, {"w": "inputs", "b": [0.1429, 0.7624, 0.1954, 0.7838]}, {"w": "using", "b": [0.2017, 0.7624, 0.2471, 0.7838]}, {"w": "an", "b": [0.2534, 0.7624, 0.2739, 0.7838]}, {"w": "aggregation", "b": [0.2801, 0.7624, 0.3778, 0.7838]}, {"w": "function", "b": [0.3841, 0.7624, 0.4555, 0.7838]}, {"w": "such", "b": [0.4617, 0.7624, 0.5004, 0.7838]}, {"w": "as", "b": [0.5066, 0.7624, 0.5234, 0.7838]}, {"w": "the", "b": [0.5296, 0.7624, 0.556, 0.7838]}, {"w": "max", "b": [0.5622, 0.7624, 0.5983, 0.7838]}, {"w": "or", "b": [0.6045, 0.7624, 0.6229, 0.7838]}, {"w": "mean.", "b": [0.6291, 0.7624, 0.6803, 0.7838]}, {"w": "Figure", "b": [0.6865, 0.7624, 0.7405, 0.7838]}, {"w": "14-8", "b": [0.7468, 0.7624, 0.7842, 0.7838]}, {"w": "shows", "b": [0.7905, 0.7624, 0.8418, 0.7838]}, {"w": "a", "b": [0.848, 0.7624, 0.8572, 0.7838]}, {"w": "max", "b": [0.1429, 0.7812, 0.1792, 0.8028]}, {"w": "pooling", "b": [0.1851, 0.7812, 0.2443, 0.8028]}, {"w": "layer,", "b": [0.2503, 0.7812, 0.2949, 0.8028]}, {"w": "which", "b": [0.3008, 0.7814, 0.3517, 0.8028]}, {"w": "is", "b": [0.3576, 0.7814, 0.3709, 0.8028]}, {"w": "the", "b": [0.3768, 0.7814, 0.4031, 0.8028]}, {"w": "most", "b": [0.409, 0.7814, 0.4507, 0.8028]}, {"w": "common", "b": [0.4566, 0.7814, 0.5321, 0.8028]}, {"w": "type", "b": [0.538, 0.7814, 0.5737, 0.8028]}, {"w": "of", "b": [0.5796, 0.7814, 0.5964, 0.8028]}, {"w": "pooling", "b": [0.6023, 0.7814, 0.6665, 0.8028]}, {"w": "layer.", "b": [0.6724, 0.7814, 0.716, 0.8028]}, {"w": "In", "b": [0.7219, 0.7814, 0.7404, 0.8028]}, {"w": "this", "b": [0.7463, 0.7814, 0.777, 0.8028]}, {"w": "example,", "b": [0.7829, 0.7814, 0.8571, 0.8028]}]}, {"id": "b_10", "type": "paragraph", "text": "442 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "442", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 469, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "9 Other kernels we discussed so far had weights, but pooling kernels do not: they are just stateless sliding win‐ dows.", "words": [{"w": "9", "b": [0.1451, 0.8613, 0.1518, 0.8756]}, {"w": "Other", "b": [0.1587, 0.8598, 0.1965, 0.8761]}, {"w": "kernels", "b": [0.2001, 0.8598, 0.2459, 0.8761]}, {"w": "we", "b": [0.2495, 0.8598, 0.2671, 0.8761]}, {"w": "discussed", "b": [0.2707, 0.8598, 0.3311, 0.8761]}, {"w": "so", "b": [0.3347, 0.8598, 0.3487, 0.8761]}, {"w": "far", "b": [0.3523, 0.8598, 0.3698, 0.8761]}, {"w": "had", "b": [0.3734, 0.8598, 0.3972, 0.8761]}, {"w": "weights,", "b": [0.4008, 0.8598, 0.4526, 0.8761]}, {"w": "but", "b": [0.4562, 0.8598, 0.4775, 0.8761]}, {"w": "pooling", "b": [0.4811, 0.8598, 0.53, 0.8761]}, {"w": "kernels", "b": [0.5336, 0.8598, 0.5794, 0.8761]}, {"w": "do", "b": [0.583, 0.8598, 0.5995, 0.8761]}, {"w": "not:", "b": [0.6031, 0.8598, 0.6283, 0.8761]}, {"w": "they", "b": [0.6319, 0.8598, 0.6593, 0.8761]}, {"w": "are", "b": [0.6629, 0.8598, 0.6825, 0.8761]}, {"w": "just", "b": [0.6861, 0.8598, 0.7093, 0.8761]}, {"w": "stateless", "b": [0.7129, 0.8598, 0.7642, 0.8761]}, {"w": "sliding", "b": [0.7678, 0.8598, 0.8106, 0.8761]}, {"w": "win‐", "b": [0.8142, 0.8598, 0.8437, 0.8761]}, {"w": "dows.", "b": [0.1587, 0.8749, 0.1955, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "we use a 2 × 2 _pooling kernel_9, with a stride of 2, and no padding. Only the max input value in each receptive field makes it to the next layer, while the other inputs are dropped. For example, in the lower left receptive field in Figure 14-8, the input values are 1, 5, 3, 2, so only the max value, 5, is propagated to the next layer. Because of the stride of 2, the output image has half the height and half the width of the input image (rounded down since we use no padding).", "words": [{"w": "we", "b": [0.1429, 0.0791, 0.166, 0.1005]}, {"w": "use", "b": [0.1725, 0.0791, 0.2001, 0.1005]}, {"w": "a", "b": [0.2067, 0.0791, 0.2158, 0.1005]}, {"w": "2", "b": [0.2224, 0.0791, 0.2324, 0.1005]}, {"w": "×", "b": [0.2389, 0.0791, 0.251, 0.1005]}, {"w": "2", "b": [0.2576, 0.0791, 0.2676, 0.1005]}, {"w": "_pooling", "b": [0.2741, 0.0791, 0.3487, 0.1005]}, {"w": "kernel_9,", "b": [0.3552, 0.0791, 0.4286, 0.1005]}, {"w": "with", "b": [0.4351, 0.0791, 0.4725, 0.1005]}, {"w": "a", "b": [0.479, 0.0791, 0.4882, 0.1005]}, {"w": "stride", "b": [0.4947, 0.0791, 0.5419, 0.1005]}, {"w": "of", "b": [0.5484, 0.0791, 0.5652, 0.1005]}, {"w": "2,", "b": [0.5718, 0.0791, 0.5865, 0.1005]}, {"w": "and", "b": [0.5931, 0.0791, 0.6246, 0.1005]}, {"w": "no", "b": [0.6312, 0.0791, 0.6532, 0.1005]}, {"w": "padding.", "b": [0.6598, 0.0791, 0.7333, 0.1005]}, {"w": "Only", "b": [0.7399, 0.0791, 0.7817, 0.1005]}, {"w": "the", "b": [0.7882, 0.0791, 0.8145, 0.1005]}, {"w": "max", "b": [0.8211, 0.0791, 0.8571, 0.1005]}, {"w": "input", "b": [0.1429, 0.0981, 0.1878, 0.1195]}, {"w": "value", "b": [0.1945, 0.0981, 0.2385, 0.1195]}, {"w": "in", "b": [0.2452, 0.0981, 0.2622, 0.1195]}, {"w": "each", "b": [0.2689, 0.0981, 0.3069, 0.1195]}, {"w": "receptive", "b": [0.3136, 0.0981, 0.3892, 0.1195]}, {"w": "field", "b": [0.3959, 0.0981, 0.4328, 0.1195]}, {"w": "makes", "b": [0.4395, 0.0981, 0.4926, 0.1195]}, {"w": "it", "b": [0.4993, 0.0981, 0.5112, 0.1195]}, {"w": "to", "b": [0.518, 0.0981, 0.5349, 0.1195]}, {"w": "the", "b": [0.5417, 0.0981, 0.568, 0.1195]}, {"w": "next", "b": [0.5747, 0.0981, 0.6112, 0.1195]}, {"w": "layer,", "b": [0.6179, 0.0981, 0.6615, 0.1195]}, {"w": "while", "b": [0.6683, 0.0981, 0.7134, 0.1195]}, {"w": "the", "b": [0.7201, 0.0981, 0.7464, 0.1195]}, {"w": "other", "b": [0.7532, 0.0981, 0.7978, 0.1195]}, {"w": "inputs", "b": [0.8046, 0.0981, 0.8571, 0.1195]}, {"w": "are", "b": [0.1428, 0.1172, 0.1686, 0.1386]}, {"w": "dropped.", "b": [0.1754, 0.1172, 0.2512, 0.1386]}, {"w": "For", "b": [0.2581, 0.1172, 0.2871, 0.1386]}, {"w": "example,", "b": [0.2939, 0.1172, 0.3682, 0.1386]}, {"w": "in", "b": [0.375, 0.1172, 0.392, 0.1386]}, {"w": "the", "b": [0.3989, 0.1172, 0.4252, 0.1386]}, {"w": "lower", "b": [0.4321, 0.1172, 0.4788, 0.1386]}, {"w": "left", "b": [0.4857, 0.1172, 0.5123, 0.1386]}, {"w": "receptive", "b": [0.5192, 0.1172, 0.5948, 0.1386]}, {"w": "field", "b": [0.6016, 0.1172, 0.6385, 0.1386]}, {"w": "in", "b": [0.6453, 0.1172, 0.6623, 0.1386]}, {"w": "Figure", "b": [0.6692, 0.1172, 0.7232, 0.1386]}, {"w": "14-8,", "b": [0.73, 0.1172, 0.7722, 0.1386]}, {"w": "the", "b": [0.779, 0.1172, 0.8054, 0.1386]}, {"w": "input", "b": [0.8122, 0.1172, 0.8571, 0.1386]}, {"w": "values", "b": [0.1429, 0.1362, 0.1945, 0.1576]}, {"w": "are", "b": [0.2, 0.1362, 0.2258, 0.1576]}, {"w": "1,", "b": [0.2313, 0.1362, 0.246, 0.1576]}, {"w": "5,", "b": [0.2516, 0.1362, 0.2663, 0.1576]}, {"w": "3,", "b": [0.2719, 0.1362, 0.2866, 0.1576]}, {"w": "2,", "b": [0.2922, 0.1362, 0.3069, 0.1576]}, {"w": "so", "b": [0.3124, 0.1362, 0.3307, 0.1576]}, {"w": "only", "b": [0.3362, 0.1362, 0.3731, 0.1576]}, {"w": "the", "b": [0.3786, 0.1362, 0.405, 0.1576]}, {"w": "max", "b": [0.4105, 0.1362, 0.4465, 0.1576]}, {"w": "value,", "b": [0.4521, 0.1362, 0.5008, 0.1576]}, {"w": "5,", "b": [0.5064, 0.1362, 0.5211, 0.1576]}, {"w": "is", "b": [0.5266, 0.1362, 0.5399, 0.1576]}, {"w": "propagated", "b": [0.5454, 0.1362, 0.6394, 0.1576]}, {"w": "to", "b": [0.645, 0.1362, 0.662, 0.1576]}, {"w": "the", "b": [0.6675, 0.1362, 0.6938, 0.1576]}, {"w": "next", "b": [0.6994, 0.1362, 0.7358, 0.1576]}, {"w": "layer.", "b": [0.7413, 0.1362, 0.785, 0.1576]}, {"w": "Because", "b": [0.7905, 0.1362, 0.8572, 0.1576]}, {"w": "of", "b": [0.1429, 0.1553, 0.1597, 0.1767]}, {"w": "the", "b": [0.1649, 0.1553, 0.1913, 0.1767]}, {"w": "stride", "b": [0.1965, 0.1553, 0.2437, 0.1767]}, {"w": "of", "b": [0.249, 0.1553, 0.2658, 0.1767]}, {"w": "2,", "b": [0.2711, 0.1553, 0.2858, 0.1767]}, {"w": "the", "b": [0.2911, 0.1553, 0.3174, 0.1767]}, {"w": "output", "b": [0.3227, 0.1553, 0.3791, 0.1767]}, {"w": "image", "b": [0.3844, 0.1553, 0.4348, 0.1767]}, {"w": "has", "b": [0.44, 0.1553, 0.468, 0.1767]}, {"w": "half", "b": [0.4732, 0.1553, 0.5049, 0.1767]}, {"w": "the", "b": [0.5102, 0.1553, 0.5366, 0.1767]}, {"w": "height", "b": [0.5418, 0.1553, 0.5942, 0.1767]}, {"w": "and", "b": [0.5995, 0.1553, 0.631, 0.1767]}, {"w": "half", "b": [0.6363, 0.1553, 0.668, 0.1767]}, {"w": "the", "b": [0.6733, 0.1553, 0.6997, 0.1767]}, {"w": "width", "b": [0.7049, 0.1553, 0.7533, 0.1767]}, {"w": "of", "b": [0.7585, 0.1553, 0.7753, 0.1767]}, {"w": "the", "b": [0.7806, 0.1553, 0.8069, 0.1767]}, {"w": "input", "b": [0.8122, 0.1553, 0.8571, 0.1767]}, {"w": "image", "b": [0.1429, 0.1743, 0.1932, 0.1957]}, {"w": "(rounded", "b": [0.198, 0.1743, 0.2769, 0.1957]}, {"w": "down", "b": [0.2816, 0.1743, 0.3289, 0.1957]}, {"w": "since", "b": [0.3336, 0.1743, 0.3759, 0.1957]}, {"w": "we", "b": [0.3806, 0.1743, 0.4037, 0.1957]}, {"w": "use", "b": [0.4085, 0.1743, 0.436, 0.1957]}, {"w": "no", "b": [0.4408, 0.1743, 0.4628, 0.1957]}, {"w": "padding).", "b": [0.4675, 0.1743, 0.5483, 0.1957]}]}, {"id": "b_2", "type": "equation", "text": "Figure 14-8. Max pooling layer (2 × 2 pooling kernel, stride 2, no padding)", "words": [{"w": "Figure", "b": [0.1429, 0.4061, 0.1943, 0.4277]}, {"w": "14-8.", "b": [0.1991, 0.4061, 0.2407, 0.4277]}, {"w": "Max", "b": [0.2455, 0.4061, 0.2832, 0.4277]}, {"w": "pooling", "b": [0.288, 0.4061, 0.3472, 0.4277]}, {"w": "layer", "b": [0.352, 0.4061, 0.3919, 0.4277]}, {"w": "(2", "b": [0.3966, 0.4061, 0.4136, 0.4277]}, {"w": "×", "b": [0.4184, 0.4061, 0.4308, 0.4277]}, {"w": "2", "b": [0.4356, 0.4061, 0.4455, 0.4277]}, {"w": "pooling", "b": [0.4503, 0.4061, 0.5095, 0.4277]}, {"w": "kernel,", "b": [0.5143, 0.4061, 0.5691, 0.4277]}, {"w": "stride", "b": [0.5739, 0.4061, 0.6191, 0.4277]}, {"w": "2,", "b": [0.6239, 0.4061, 0.6387, 0.4277]}, {"w": "no", "b": [0.6435, 0.4061, 0.6642, 0.4277]}, {"w": "padding)", "b": [0.669, 0.4061, 0.7419, 0.4277]}]}, {"id": "b_3", "type": "paragraph", "text": "A pooling layer typically works on every input channel independ‐ ently, so the output depth is the same as the input depth.", "words": [{"w": "A", "b": [0.2714, 0.4483, 0.2846, 0.4678]}, {"w": "pooling", "b": [0.2905, 0.4483, 0.3491, 0.4678]}, {"w": "layer", "b": [0.355, 0.4483, 0.3918, 0.4678]}, {"w": "typically", "b": [0.3977, 0.4483, 0.4621, 0.4678]}, {"w": "works", "b": [0.468, 0.4483, 0.5143, 0.4678]}, {"w": "on", "b": [0.5202, 0.4483, 0.5403, 0.4678]}, {"w": "every", "b": [0.5462, 0.4483, 0.5876, 0.4678]}, {"w": "input", "b": [0.5935, 0.4483, 0.6346, 0.4678]}, {"w": "channel", "b": [0.6405, 0.4483, 0.7008, 0.4678]}, {"w": "independ‐", "b": [0.7067, 0.4483, 0.7857, 0.4678]}, {"w": "ently,", "b": [0.2714, 0.4657, 0.3119, 0.4853]}, {"w": "so", "b": [0.3162, 0.4657, 0.3329, 0.4853]}, {"w": "the", "b": [0.3372, 0.4657, 0.3613, 0.4853]}, {"w": "output", "b": [0.3656, 0.4657, 0.4172, 0.4853]}, {"w": "depth", "b": [0.4215, 0.4657, 0.4656, 0.4853]}, {"w": "is", "b": [0.4699, 0.4657, 0.482, 0.4853]}, {"w": "the", "b": [0.4864, 0.4657, 0.5104, 0.4853]}, {"w": "same", "b": [0.5148, 0.4657, 0.5538, 0.4853]}, {"w": "as", "b": [0.5581, 0.4657, 0.5735, 0.4853]}, {"w": "the", "b": [0.5778, 0.4657, 0.6019, 0.4853]}, {"w": "input", "b": [0.6062, 0.4657, 0.6473, 0.4853]}, {"w": "depth.", "b": [0.6516, 0.4657, 0.7001, 0.4853]}]}, {"id": "b_4", "type": "paragraph", "text": "Other than reducing computations, memory usage and the number of parameters, a max pooling layer also introduces some level of invariance to small translations, as shown in Figure 14-9. Here we assume that the bright pixels have a lower value than dark pixels, and we consider 3 images (A, B, C) going through a max pooling layer with a 2 × 2 kernel and stride 2. Images B and C are the same as image A, but shifted by one and two pixels to the right. As you can see, the outputs of the max pooling layer for images A and B are identical. This is what translation invariance means. However, for image C, the output is different: it is shifted by one pixel to the right (but there is still 75% invariance). By inserting a max pooling layer every few layers in a CNN, it is possible to get some level of translation invariance at a larger scale. Moreover, max pooling also offers a small amount of rotational invariance and a slight scale invariance. Such invariance (even if it is limited) can be useful in cases where the prediction should not depend on these details, such as in classification tasks.", "words": [{"w": "Other", "b": [0.1429, 0.5469, 0.1925, 0.5683]}, {"w": "than", "b": [0.1985, 0.5469, 0.2366, 0.5683]}, {"w": "reducing", "b": [0.2426, 0.5469, 0.3168, 0.5683]}, {"w": "computations,", "b": [0.3229, 0.5469, 0.4424, 0.5683]}, {"w": "memory", "b": [0.4485, 0.5469, 0.52, 0.5683]}, {"w": "usage", "b": [0.526, 0.5469, 0.5725, 0.5683]}, {"w": "and", "b": [0.5785, 0.5469, 0.6101, 0.5683]}, {"w": "the", "b": [0.6161, 0.5469, 0.6425, 0.5683]}, {"w": "number", "b": [0.6485, 0.5469, 0.7148, 0.5683]}, {"w": "of", "b": [0.7209, 0.5469, 0.7377, 0.5683]}, {"w": "parameters,", "b": [0.7437, 0.5469, 0.8419, 0.5683]}, {"w": "a", "b": [0.848, 0.5469, 0.8571, 0.5683]}, {"w": "max", "b": [0.1428, 0.566, 0.1789, 0.5874]}, {"w": "pooling", "b": [0.1862, 0.566, 0.2503, 0.5874]}, {"w": "layer", "b": [0.2576, 0.566, 0.2978, 0.5874]}, {"w": "also", "b": [0.3051, 0.566, 0.3378, 0.5874]}, {"w": "introduces", "b": [0.3451, 0.566, 0.4337, 0.5874]}, {"w": "some", "b": [0.441, 0.566, 0.4852, 0.5874]}, {"w": "level", "b": [0.4925, 0.566, 0.5304, 0.5874]}, {"w": "of", "b": [0.5377, 0.566, 0.5545, 0.5874]}, {"w": "invariance", "b": [0.5617, 0.5658, 0.6472, 0.5874]}, {"w": "to", "b": [0.6545, 0.566, 0.6715, 0.5874]}, {"w": "small", "b": [0.6787, 0.566, 0.7231, 0.5874]}, {"w": "translations,", "b": [0.7304, 0.566, 0.8331, 0.5874]}, {"w": "as", "b": [0.8403, 0.566, 0.8571, 0.5874]}, {"w": "shown", "b": [0.1429, 0.585, 0.1979, 0.6064]}, {"w": "in", "b": [0.2037, 0.585, 0.2207, 0.6064]}, {"w": "Figure", "b": [0.2265, 0.585, 0.2805, 0.6064]}, {"w": "14-9.", "b": [0.2862, 0.585, 0.3284, 0.6064]}, {"w": "Here", "b": [0.3342, 0.585, 0.375, 0.6064]}, {"w": "we", "b": [0.3808, 0.585, 0.4039, 0.6064]}, {"w": "assume", "b": [0.4097, 0.585, 0.4711, 0.6064]}, {"w": "that", "b": [0.4769, 0.585, 0.5095, 0.6064]}, {"w": "the", "b": [0.5153, 0.585, 0.5416, 0.6064]}, {"w": "bright", "b": [0.5474, 0.585, 0.5981, 0.6064]}, {"w": "pixels", "b": [0.6039, 0.585, 0.652, 0.6064]}, {"w": "have", "b": [0.6578, 0.585, 0.6962, 0.6064]}, {"w": "a", "b": [0.7019, 0.585, 0.7111, 0.6064]}, {"w": "lower", "b": [0.7168, 0.585, 0.7636, 0.6064]}, {"w": "value", "b": [0.7694, 0.585, 0.8134, 0.6064]}, {"w": "than", "b": [0.8191, 0.585, 0.8571, 0.6064]}, {"w": "dark", "b": [0.1429, 0.6041, 0.1811, 0.6255]}, {"w": "pixels,", "b": [0.1878, 0.6041, 0.2406, 0.6255]}, {"w": "and", "b": [0.2473, 0.6041, 0.2788, 0.6255]}, {"w": "we", "b": [0.2855, 0.6041, 0.3087, 0.6255]}, {"w": "consider", "b": [0.3154, 0.6041, 0.387, 0.6255]}, {"w": "3", "b": [0.3937, 0.6041, 0.4037, 0.6255]}, {"w": "images", "b": [0.4104, 0.6041, 0.4684, 0.6255]}, {"w": "(A,", "b": [0.4751, 0.6041, 0.5015, 0.6255]}, {"w": "B,", "b": [0.5082, 0.6041, 0.5248, 0.6255]}, {"w": "C)", "b": [0.5315, 0.6041, 0.5526, 0.6255]}, {"w": "going", "b": [0.5593, 0.6041, 0.6064, 0.6255]}, {"w": "through", "b": [0.6131, 0.6041, 0.6808, 0.6255]}, {"w": "a", "b": [0.6875, 0.6041, 0.6967, 0.6255]}, {"w": "max", "b": [0.7034, 0.6041, 0.7394, 0.6255]}, {"w": "pooling", "b": [0.7461, 0.6041, 0.8103, 0.6255]}, {"w": "layer", "b": [0.817, 0.6041, 0.8571, 0.6255]}, {"w": "with", "b": [0.1429, 0.6231, 0.1802, 0.6445]}, {"w": "a", "b": [0.1855, 0.6231, 0.1947, 0.6445]}, {"w": "2", "b": [0.2, 0.6231, 0.21, 0.6445]}, {"w": "×", "b": [0.2153, 0.6231, 0.2274, 0.6445]}, {"w": "2", "b": [0.2328, 0.6231, 0.2428, 0.6445]}, {"w": "kernel", "b": [0.2481, 0.6231, 0.3005, 0.6445]}, {"w": "and", "b": [0.3059, 0.6231, 0.3374, 0.6445]}, {"w": "stride", "b": [0.3428, 0.6231, 0.3899, 0.6445]}, {"w": "2.", "b": [0.3953, 0.6231, 0.41, 0.6445]}, {"w": "Images", "b": [0.4154, 0.6231, 0.4749, 0.6445]}, {"w": "B", "b": [0.4803, 0.6231, 0.4925, 0.6445]}, {"w": "and", "b": [0.4979, 0.6231, 0.5294, 0.6445]}, {"w": "C", "b": [0.5347, 0.6231, 0.5486, 0.6445]}, {"w": "are", "b": [0.5539, 0.6231, 0.5797, 0.6445]}, {"w": "the", "b": [0.585, 0.6231, 0.6113, 0.6445]}, {"w": "same", "b": [0.6167, 0.6231, 0.6594, 0.6445]}, {"w": "as", "b": [0.6647, 0.6231, 0.6815, 0.6445]}, {"w": "image", "b": [0.6868, 0.6231, 0.7372, 0.6445]}, {"w": "A,", "b": [0.7426, 0.6231, 0.7617, 0.6445]}, {"w": "but", "b": [0.7671, 0.6231, 0.7951, 0.6445]}, {"w": "shifted", "b": [0.8004, 0.6231, 0.8571, 0.6445]}, {"w": "by", "b": [0.1429, 0.6421, 0.163, 0.6636]}, {"w": "one", "b": [0.1699, 0.6421, 0.2008, 0.6636]}, {"w": "and", "b": [0.2077, 0.6421, 0.2393, 0.6636]}, {"w": "two", "b": [0.2462, 0.6421, 0.2775, 0.6636]}, {"w": "pixels", "b": [0.2844, 0.6421, 0.3325, 0.6636]}, {"w": "to", "b": [0.3394, 0.6421, 0.3564, 0.6636]}, {"w": "the", "b": [0.3633, 0.6421, 0.3896, 0.6636]}, {"w": "right.", "b": [0.3966, 0.6421, 0.4415, 0.6636]}, {"w": "As", "b": [0.4484, 0.6421, 0.4704, 0.6636]}, {"w": "you", "b": [0.4774, 0.6421, 0.5086, 0.6636]}, {"w": "can", "b": [0.5155, 0.6421, 0.5449, 0.6636]}, {"w": "see,", "b": [0.5518, 0.6421, 0.5819, 0.6636]}, {"w": "the", "b": [0.5888, 0.6421, 0.6152, 0.6636]}, {"w": "outputs", "b": [0.6221, 0.6421, 0.6861, 0.6636]}, {"w": "of", "b": [0.693, 0.6421, 0.7098, 0.6636]}, {"w": "the", "b": [0.7168, 0.6421, 0.7431, 0.6636]}, {"w": "max", "b": [0.75, 0.6421, 0.7861, 0.6636]}, {"w": "pooling", "b": [0.793, 0.6421, 0.8572, 0.6636]}, {"w": "layer", "b": [0.1429, 0.6612, 0.183, 0.6826]}, {"w": "for", "b": [0.1911, 0.6612, 0.2156, 0.6826]}, {"w": "images", "b": [0.2236, 0.6612, 0.2817, 0.6826]}, {"w": "A", "b": [0.2897, 0.6612, 0.3041, 0.6826]}, {"w": "and", "b": [0.3121, 0.6612, 0.3437, 0.6826]}, {"w": "B", "b": [0.3517, 0.6612, 0.364, 0.6826]}, {"w": "are", "b": [0.372, 0.6612, 0.3977, 0.6826]}, {"w": "identical.", "b": [0.4057, 0.6612, 0.4821, 0.6826]}, {"w": "This", "b": [0.4901, 0.6612, 0.5273, 0.6826]}, {"w": "is", "b": [0.5354, 0.6612, 0.5486, 0.6826]}, {"w": "what", "b": [0.5566, 0.6612, 0.5971, 0.6826]}, {"w": "translation", "b": [0.6052, 0.6612, 0.6954, 0.6826]}, {"w": "invariance", "b": [0.7034, 0.6612, 0.7903, 0.6826]}, {"w": "means.", "b": [0.7983, 0.6612, 0.8571, 0.6826]}, {"w": "However,", "b": [0.1429, 0.6802, 0.2217, 0.7017]}, {"w": "for", "b": [0.2288, 0.6802, 0.2533, 0.7017]}, {"w": "image", "b": [0.2603, 0.6802, 0.3107, 0.7017]}, {"w": "C,", "b": [0.3178, 0.6802, 0.3364, 0.7017]}, {"w": "the", "b": [0.3434, 0.6802, 0.3697, 0.7017]}, {"w": "output", "b": [0.3768, 0.6802, 0.4332, 0.7017]}, {"w": "is", "b": [0.4402, 0.6802, 0.4534, 0.7017]}, {"w": "different:", "b": [0.4605, 0.6802, 0.5369, 0.7017]}, {"w": "it", "b": [0.544, 0.6802, 0.5559, 0.7017]}, {"w": "is", "b": [0.5629, 0.6802, 0.5762, 0.7017]}, {"w": "shifted", "b": [0.5832, 0.6802, 0.6399, 0.7017]}, {"w": "by", "b": [0.647, 0.6802, 0.6671, 0.7017]}, {"w": "one", "b": [0.6742, 0.6802, 0.7051, 0.7017]}, {"w": "pixel", "b": [0.7121, 0.6802, 0.7526, 0.7017]}, {"w": "to", "b": [0.7596, 0.6802, 0.7766, 0.7017]}, {"w": "the", "b": [0.7836, 0.6802, 0.81, 0.7017]}, {"w": "right", "b": [0.817, 0.6802, 0.8571, 0.7017]}, {"w": "(but", "b": [0.1428, 0.6993, 0.1781, 0.7207]}, {"w": "there", "b": [0.1829, 0.6993, 0.2259, 0.7207]}, {"w": "is", "b": [0.2307, 0.6993, 0.244, 0.7207]}, {"w": "still", "b": [0.2489, 0.6993, 0.279, 0.7207]}, {"w": "75%", "b": [0.2839, 0.6993, 0.3196, 0.7207]}, {"w": "invariance).", "b": [0.3245, 0.6993, 0.4233, 0.7207]}, {"w": "By", "b": [0.4282, 0.6993, 0.45, 0.7207]}, {"w": "inserting", "b": [0.4549, 0.6993, 0.5292, 0.7207]}, {"w": "a", "b": [0.534, 0.6993, 0.5432, 0.7207]}, {"w": "max", "b": [0.5481, 0.6993, 0.5841, 0.7207]}, {"w": "pooling", "b": [0.589, 0.6993, 0.6532, 0.7207]}, {"w": "layer", "b": [0.658, 0.6993, 0.6982, 0.7207]}, {"w": "every", "b": [0.7031, 0.6993, 0.7484, 0.7207]}, {"w": "few", "b": [0.7533, 0.6993, 0.7826, 0.7207]}, {"w": "layers", "b": [0.7874, 0.6993, 0.8353, 0.7207]}, {"w": "in", "b": [0.8402, 0.6993, 0.8571, 0.7207]}, {"w": "a", "b": [0.1429, 0.7183, 0.152, 0.7398]}, {"w": "CNN,", "b": [0.1606, 0.7183, 0.2101, 0.7398]}, {"w": "it", "b": [0.2187, 0.7183, 0.2306, 0.7398]}, {"w": "is", "b": [0.2392, 0.7183, 0.2524, 0.7398]}, {"w": "possible", "b": [0.2609, 0.7183, 0.3281, 0.7398]}, {"w": "to", "b": [0.3366, 0.7183, 0.3536, 0.7398]}, {"w": "get", "b": [0.3621, 0.7183, 0.3871, 0.7398]}, {"w": "some", "b": [0.3956, 0.7183, 0.4398, 0.7398]}, {"w": "level", "b": [0.4484, 0.7183, 0.4863, 0.7398]}, {"w": "of", "b": [0.4948, 0.7183, 0.5116, 0.7398]}, {"w": "translation", "b": [0.5201, 0.7183, 0.6104, 0.7398]}, {"w": "invariance", "b": [0.6189, 0.7183, 0.7058, 0.7398]}, {"w": "at", "b": [0.7143, 0.7183, 0.7294, 0.7398]}, {"w": "a", "b": [0.738, 0.7183, 0.7471, 0.7398]}, {"w": "larger", "b": [0.7556, 0.7183, 0.8041, 0.7398]}, {"w": "scale.", "b": [0.8127, 0.7183, 0.8571, 0.7398]}, {"w": "Moreover,", "b": [0.1429, 0.7374, 0.2284, 0.7588]}, {"w": "max", "b": [0.237, 0.7374, 0.2731, 0.7588]}, {"w": "pooling", "b": [0.2817, 0.7374, 0.3459, 0.7588]}, {"w": "also", "b": [0.3545, 0.7374, 0.3872, 0.7588]}, {"w": "offers", "b": [0.3959, 0.7374, 0.4431, 0.7588]}, {"w": "a", "b": [0.4517, 0.7374, 0.4608, 0.7588]}, {"w": "small", "b": [0.4695, 0.7374, 0.5139, 0.7588]}, {"w": "amount", "b": [0.5225, 0.7374, 0.5878, 0.7588]}, {"w": "of", "b": [0.5964, 0.7374, 0.6132, 0.7588]}, {"w": "rotational", "b": [0.6219, 0.7374, 0.7037, 0.7588]}, {"w": "invariance", "b": [0.7123, 0.7374, 0.7992, 0.7588]}, {"w": "and", "b": [0.8078, 0.7374, 0.8394, 0.7588]}, {"w": "a", "b": [0.848, 0.7374, 0.8571, 0.7588]}, {"w": "slight", "b": [0.1429, 0.7564, 0.1882, 0.7778]}, {"w": "scale", "b": [0.1955, 0.7564, 0.2352, 0.7778]}, {"w": "invariance.", "b": [0.2425, 0.7564, 0.3341, 0.7778]}, {"w": "Such", "b": [0.3414, 0.7564, 0.3823, 0.7778]}, {"w": "invariance", "b": [0.3896, 0.7564, 0.4764, 0.7778]}, {"w": "(even", "b": [0.4837, 0.7564, 0.5296, 0.7778]}, {"w": "if", "b": [0.5369, 0.7564, 0.5487, 0.7778]}, {"w": "it", "b": [0.556, 0.7564, 0.5679, 0.7778]}, {"w": "is", "b": [0.5752, 0.7564, 0.5885, 0.7778]}, {"w": "limited)", "b": [0.5958, 0.7564, 0.6627, 0.7778]}, {"w": "can", "b": [0.67, 0.7564, 0.6993, 0.7778]}, {"w": "be", "b": [0.7066, 0.7564, 0.7261, 0.7778]}, {"w": "useful", "b": [0.7334, 0.7564, 0.7834, 0.7778]}, {"w": "in", "b": [0.7908, 0.7564, 0.8077, 0.7778]}, {"w": "cases", "b": [0.815, 0.7564, 0.8571, 0.7778]}, {"w": "where", "b": [0.1429, 0.7755, 0.1937, 0.7969]}, {"w": "the", "b": [0.202, 0.7755, 0.2284, 0.7969]}, {"w": "prediction", "b": [0.2367, 0.7755, 0.3235, 0.7969]}, {"w": "should", "b": [0.3319, 0.7755, 0.3886, 0.7969]}, {"w": "not", "b": [0.3969, 0.7755, 0.4253, 0.7969]}, {"w": "depend", "b": [0.4336, 0.7755, 0.4956, 0.7969]}, {"w": "on", "b": [0.504, 0.7755, 0.526, 0.7969]}, {"w": "these", "b": [0.5343, 0.7755, 0.5771, 0.7969]}, {"w": "details,", "b": [0.5855, 0.7755, 0.6441, 0.7969]}, {"w": "such", "b": [0.6524, 0.7755, 0.691, 0.7969]}, {"w": "as", "b": [0.6994, 0.7755, 0.7161, 0.7969]}, {"w": "in", "b": [0.7245, 0.7755, 0.7415, 0.7969]}, {"w": "classification", "b": [0.7498, 0.7755, 0.8572, 0.7969]}, {"w": "tasks.", "b": [0.1429, 0.7945, 0.1887, 0.8159]}]}, {"id": "b_5", "type": "paragraph", "text": "Pooling Layer | 443", "words": [{"w": "Pooling", "b": [0.7158, 0.9225, 0.7609, 0.9388]}, {"w": "Layer", "b": [0.7637, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "443", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 470, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 14-9. Invariance to small translations", "words": [{"w": "Figure", "b": [0.1429, 0.4521, 0.1943, 0.4737]}, {"w": "14-9.", "b": [0.1991, 0.4521, 0.2407, 0.4737]}, {"w": "Invariance", "b": [0.2455, 0.4521, 0.3317, 0.4737]}, {"w": "to", "b": [0.3365, 0.4521, 0.3525, 0.4737]}, {"w": "small", "b": [0.3572, 0.4521, 0.4005, 0.4737]}, {"w": "translations", "b": [0.4053, 0.4521, 0.5008, 0.4737]}]}, {"id": "b_1", "type": "paragraph", "text": "But max pooling has some downsides: firstly, it is obviously very destructive: even with a tiny 2 × 2 kernel and a stride of 2, the output will be two times smaller in both directions (so its area will be four times smaller), simply dropping 75% of the input values. And in some applications, invariance is not desirable, for example for seman‐ tic segmentation: this is the task of classifying each pixel in an image depending on the object that pixel belongs to: obviously, if the input image is translated by 1 pixel to the right, the output should also be translated by 1 pixel to the right. The goal in this case is equivariance, not invariance: a small change to the inputs should lead to a corre‐ sponding small change in the output.", "words": [{"w": "But", "b": [0.1429, 0.4895, 0.1725, 0.5109]}, {"w": "max", "b": [0.1801, 0.4895, 0.2161, 0.5109]}, {"w": "pooling", "b": [0.2236, 0.4895, 0.2878, 0.5109]}, {"w": "has", "b": [0.2953, 0.4895, 0.3233, 0.5109]}, {"w": "some", "b": [0.3308, 0.4895, 0.375, 0.5109]}, {"w": "downsides:", "b": [0.3825, 0.4895, 0.4753, 0.5109]}, {"w": "firstly,", "b": [0.4828, 0.4895, 0.5344, 0.5109]}, {"w": "it", "b": [0.5419, 0.4895, 0.5538, 0.5109]}, {"w": "is", "b": [0.5614, 0.4895, 0.5746, 0.5109]}, {"w": "obviously", "b": [0.5821, 0.4895, 0.6627, 0.5109]}, {"w": "very", "b": [0.6703, 0.4895, 0.7067, 0.5109]}, {"w": "destructive:", "b": [0.7142, 0.4895, 0.8109, 0.5109]}, {"w": "even", "b": [0.8184, 0.4895, 0.8571, 0.5109]}, {"w": "with", "b": [0.1429, 0.5085, 0.1802, 0.5299]}, {"w": "a", "b": [0.1855, 0.5085, 0.1946, 0.5299]}, {"w": "tiny", "b": [0.1999, 0.5085, 0.2323, 0.5299]}, {"w": "2", "b": [0.2376, 0.5085, 0.2476, 0.5299]}, {"w": "×", "b": [0.2529, 0.5085, 0.2649, 0.5299]}, {"w": "2", "b": [0.2702, 0.5085, 0.2802, 0.5299]}, {"w": "kernel", "b": [0.2855, 0.5085, 0.3379, 0.5299]}, {"w": "and", "b": [0.3432, 0.5085, 0.3747, 0.5299]}, {"w": "a", "b": [0.38, 0.5085, 0.3892, 0.5299]}, {"w": "stride", "b": [0.3944, 0.5085, 0.4416, 0.5299]}, {"w": "of", "b": [0.4469, 0.5085, 0.4637, 0.5299]}, {"w": "2,", "b": [0.469, 0.5085, 0.4837, 0.5299]}, {"w": "the", "b": [0.489, 0.5085, 0.5153, 0.5299]}, {"w": "output", "b": [0.5206, 0.5085, 0.577, 0.5299]}, {"w": "will", "b": [0.5822, 0.5085, 0.6126, 0.5299]}, {"w": "be", "b": [0.6179, 0.5085, 0.6374, 0.5299]}, {"w": "two", "b": [0.6426, 0.5085, 0.6739, 0.5299]}, {"w": "times", "b": [0.6792, 0.5085, 0.7247, 0.5299]}, {"w": "smaller", "b": [0.7299, 0.5085, 0.7909, 0.5299]}, {"w": "in", "b": [0.7962, 0.5085, 0.8132, 0.5299]}, {"w": "both", "b": [0.8184, 0.5085, 0.8571, 0.5299]}, {"w": "directions", "b": [0.1429, 0.5275, 0.2264, 0.549]}, {"w": "(so", "b": [0.2328, 0.5275, 0.2583, 0.549]}, {"w": "its", "b": [0.2647, 0.5275, 0.2843, 0.549]}, {"w": "area", "b": [0.2907, 0.5275, 0.3256, 0.549]}, {"w": "will", "b": [0.332, 0.5275, 0.3624, 0.549]}, {"w": "be", "b": [0.3688, 0.5275, 0.3882, 0.549]}, {"w": "four", "b": [0.3946, 0.5275, 0.4302, 0.549]}, {"w": "times", "b": [0.4366, 0.5275, 0.4821, 0.549]}, {"w": "smaller),", "b": [0.4885, 0.5275, 0.5614, 0.549]}, {"w": "simply", "b": [0.5678, 0.5275, 0.6235, 0.549]}, {"w": "dropping", "b": [0.6299, 0.5275, 0.7078, 0.549]}, {"w": "75%", "b": [0.7142, 0.5275, 0.7499, 0.549]}, {"w": "of", "b": [0.7563, 0.5275, 0.7731, 0.549]}, {"w": "the", "b": [0.7795, 0.5275, 0.8058, 0.549]}, {"w": "input", "b": [0.8122, 0.5275, 0.8572, 0.549]}, {"w": "values.", "b": [0.1429, 0.5466, 0.1992, 0.568]}, {"w": "And", "b": [0.205, 0.5466, 0.2417, 0.568]}, {"w": "in", "b": [0.2475, 0.5466, 0.2644, 0.568]}, {"w": "some", "b": [0.2702, 0.5466, 0.3143, 0.568]}, {"w": "applications,", "b": [0.3201, 0.5466, 0.4254, 0.568]}, {"w": "invariance", "b": [0.4311, 0.5466, 0.5179, 0.568]}, {"w": "is", "b": [0.5237, 0.5466, 0.5369, 0.568]}, {"w": "not", "b": [0.5426, 0.5466, 0.571, 0.568]}, {"w": "desirable,", "b": [0.5767, 0.5466, 0.6561, 0.568]}, {"w": "for", "b": [0.6618, 0.5466, 0.6864, 0.568]}, {"w": "example", "b": [0.6921, 0.5466, 0.7616, 0.568]}, {"w": "for", "b": [0.7673, 0.5466, 0.7918, 0.568]}, {"w": "seman‐", "b": [0.7976, 0.5464, 0.8571, 0.568]}, {"w": "tic", "b": [0.1429, 0.5654, 0.1626, 0.5871]}, {"w": "segmentation:", "b": [0.1674, 0.5654, 0.2799, 0.5871]}, {"w": "this", "b": [0.2846, 0.5656, 0.3153, 0.5871]}, {"w": "is", "b": [0.3201, 0.5656, 0.3333, 0.5871]}, {"w": "the", "b": [0.338, 0.5656, 0.3644, 0.5871]}, {"w": "task", "b": [0.3691, 0.5656, 0.4026, 0.5871]}, {"w": "of", "b": [0.4073, 0.5656, 0.4241, 0.5871]}, {"w": "classifying", "b": [0.4288, 0.5656, 0.5157, 0.5871]}, {"w": "each", "b": [0.5205, 0.5656, 0.5584, 0.5871]}, {"w": "pixel", "b": [0.5631, 0.5656, 0.6036, 0.5871]}, {"w": "in", "b": [0.6083, 0.5656, 0.6253, 0.5871]}, {"w": "an", "b": [0.63, 0.5656, 0.6506, 0.5871]}, {"w": "image", "b": [0.6553, 0.5656, 0.7057, 0.5871]}, {"w": "depending", "b": [0.7104, 0.5656, 0.7992, 0.5871]}, {"w": "on", "b": [0.8039, 0.5656, 0.8259, 0.5871]}, {"w": "the", "b": [0.8306, 0.5656, 0.857, 0.5871]}, {"w": "object", "b": [0.1429, 0.5847, 0.1934, 0.6061]}, {"w": "that", "b": [0.1983, 0.5847, 0.2309, 0.6061]}, {"w": "pixel", "b": [0.2357, 0.5847, 0.2762, 0.6061]}, {"w": "belongs", "b": [0.2811, 0.5847, 0.3452, 0.6061]}, {"w": "to:", "b": [0.3501, 0.5847, 0.3718, 0.6061]}, {"w": "obviously,", "b": [0.3767, 0.5847, 0.4605, 0.6061]}, {"w": "if", "b": [0.4654, 0.5847, 0.4771, 0.6061]}, {"w": "the", "b": [0.482, 0.5847, 0.5083, 0.6061]}, {"w": "input", "b": [0.5132, 0.5847, 0.5581, 0.6061]}, {"w": "image", "b": [0.563, 0.5847, 0.6134, 0.6061]}, {"w": "is", "b": [0.6183, 0.5847, 0.6315, 0.6061]}, {"w": "translated", "b": [0.6364, 0.5847, 0.7189, 0.6061]}, {"w": "by", "b": [0.7237, 0.5847, 0.7439, 0.6061]}, {"w": "1", "b": [0.7488, 0.5847, 0.7588, 0.6061]}, {"w": "pixel", "b": [0.7636, 0.5847, 0.8041, 0.6061]}, {"w": "to", "b": [0.809, 0.5847, 0.8259, 0.6061]}, {"w": "the", "b": [0.8308, 0.5847, 0.8571, 0.6061]}, {"w": "right,", "b": [0.1428, 0.6037, 0.1877, 0.6251]}, {"w": "the", "b": [0.1928, 0.6037, 0.2192, 0.6251]}, {"w": "output", "b": [0.2243, 0.6037, 0.2807, 0.6251]}, {"w": "should", "b": [0.2858, 0.6037, 0.3425, 0.6251]}, {"w": "also", "b": [0.3476, 0.6037, 0.3803, 0.6251]}, {"w": "be", "b": [0.3854, 0.6037, 0.4048, 0.6251]}, {"w": "translated", "b": [0.4099, 0.6037, 0.4924, 0.6251]}, {"w": "by", "b": [0.4975, 0.6037, 0.5177, 0.6251]}, {"w": "1", "b": [0.5228, 0.6037, 0.5328, 0.6251]}, {"w": "pixel", "b": [0.5379, 0.6037, 0.5783, 0.6251]}, {"w": "to", "b": [0.5834, 0.6037, 0.6004, 0.6251]}, {"w": "the", "b": [0.6055, 0.6037, 0.6319, 0.6251]}, {"w": "right.", "b": [0.637, 0.6037, 0.6819, 0.6251]}, {"w": "The", "b": [0.687, 0.6037, 0.7198, 0.6251]}, {"w": "goal", "b": [0.7249, 0.6037, 0.7597, 0.6251]}, {"w": "in", "b": [0.7648, 0.6037, 0.7818, 0.6251]}, {"w": "this", "b": [0.7869, 0.6037, 0.8176, 0.6251]}, {"w": "case", "b": [0.8227, 0.6037, 0.8571, 0.6251]}, {"w": "is", "b": [0.1429, 0.6228, 0.1561, 0.6442]}, {"w": "equivariance,", "b": [0.1629, 0.6226, 0.2714, 0.6442]}, {"w": "not", "b": [0.2782, 0.6228, 0.3066, 0.6442]}, {"w": "invariance:", "b": [0.3134, 0.6228, 0.405, 0.6442]}, {"w": "a", "b": [0.4118, 0.6228, 0.421, 0.6442]}, {"w": "small", "b": [0.4278, 0.6228, 0.4722, 0.6442]}, {"w": "change", "b": [0.4791, 0.6228, 0.5382, 0.6442]}, {"w": "to", "b": [0.545, 0.6228, 0.562, 0.6442]}, {"w": "the", "b": [0.5689, 0.6228, 0.5952, 0.6442]}, {"w": "inputs", "b": [0.602, 0.6228, 0.6546, 0.6442]}, {"w": "should", "b": [0.6615, 0.6228, 0.7182, 0.6442]}, {"w": "lead", "b": [0.725, 0.6228, 0.7593, 0.6442]}, {"w": "to", "b": [0.7662, 0.6228, 0.7831, 0.6442]}, {"w": "a", "b": [0.79, 0.6228, 0.7991, 0.6442]}, {"w": "corre‐", "b": [0.806, 0.6228, 0.8571, 0.6442]}, {"w": "sponding", "b": [0.1429, 0.6418, 0.2212, 0.6632]}, {"w": "small", "b": [0.2259, 0.6418, 0.2703, 0.6632]}, {"w": "change", "b": [0.275, 0.6418, 0.3341, 0.6632]}, {"w": "in", "b": [0.3388, 0.6418, 0.3558, 0.6632]}, {"w": "the", "b": [0.3605, 0.6418, 0.3869, 0.6632]}, {"w": "output.", "b": [0.3916, 0.6418, 0.4527, 0.6632]}]}, {"id": "b_2", "type": "paragraph", "text": "TensorFlow Implementation", "words": [{"w": "TensorFlow", "b": [0.1429, 0.676, 0.2611, 0.7046]}, {"w": "Implementation", "b": [0.2661, 0.676, 0.4352, 0.7046]}]}, {"id": "b_3", "type": "paragraph", "text": "Implementing a max pooling layer in TensorFlow is quite easy. The following code creates a max pooling layer using a 2 × 2 kernel. The strides default to the kernel size, so this layer will use a stride of 2 (both horizontally and vertically). By default, it uses VALID padding (i.e., no padding at all):", "words": [{"w": "Implementing", "b": [0.1429, 0.7105, 0.2617, 0.7319]}, {"w": "a", "b": [0.2688, 0.7105, 0.2779, 0.7319]}, {"w": "max", "b": [0.2851, 0.7105, 0.3211, 0.7319]}, {"w": "pooling", "b": [0.3282, 0.7105, 0.3924, 0.7319]}, {"w": "layer", "b": [0.3995, 0.7105, 0.4397, 0.7319]}, {"w": "in", "b": [0.4468, 0.7105, 0.4638, 0.7319]}, {"w": "TensorFlow", "b": [0.4709, 0.7105, 0.5692, 0.7319]}, {"w": "is", "b": [0.5763, 0.7105, 0.5895, 0.7319]}, {"w": "quite", "b": [0.5966, 0.7105, 0.6391, 0.7319]}, {"w": "easy.", "b": [0.6463, 0.7105, 0.6847, 0.7319]}, {"w": "The", "b": [0.6918, 0.7105, 0.7247, 0.7319]}, {"w": "following", "b": [0.7318, 0.7105, 0.8107, 0.7319]}, {"w": "code", "b": [0.8179, 0.7105, 0.8572, 0.7319]}, {"w": "creates", "b": [0.1429, 0.7295, 0.1999, 0.7509]}, {"w": "a", "b": [0.205, 0.7295, 0.2142, 0.7509]}, {"w": "max", "b": [0.2193, 0.7295, 0.2553, 0.7509]}, {"w": "pooling", "b": [0.2605, 0.7295, 0.3246, 0.7509]}, {"w": "layer", "b": [0.3298, 0.7295, 0.37, 0.7509]}, {"w": "using", "b": [0.3751, 0.7295, 0.4206, 0.7509]}, {"w": "a", "b": [0.4257, 0.7295, 0.4349, 0.7509]}, {"w": "2", "b": [0.44, 0.7295, 0.45, 0.7509]}, {"w": "×", "b": [0.4551, 0.7295, 0.4672, 0.7509]}, {"w": "2", "b": [0.4724, 0.7295, 0.4824, 0.7509]}, {"w": "kernel.", "b": [0.4875, 0.7295, 0.5447, 0.7509]}, {"w": "The", "b": [0.5498, 0.7295, 0.5827, 0.7509]}, {"w": "strides", "b": [0.5878, 0.7295, 0.6426, 0.7509]}, {"w": "default", "b": [0.6478, 0.7295, 0.7052, 0.7509]}, {"w": "to", "b": [0.7104, 0.7295, 0.7274, 0.7509]}, {"w": "the", "b": [0.7325, 0.7295, 0.7588, 0.7509]}, {"w": "kernel", "b": [0.764, 0.7295, 0.8164, 0.7509]}, {"w": "size,", "b": [0.8216, 0.7295, 0.8571, 0.7509]}, {"w": "so", "b": [0.1429, 0.7486, 0.1611, 0.77]}, {"w": "this", "b": [0.1665, 0.7486, 0.1972, 0.77]}, {"w": "layer", "b": [0.2026, 0.7486, 0.2428, 0.77]}, {"w": "will", "b": [0.2482, 0.7486, 0.2786, 0.77]}, {"w": "use", "b": [0.284, 0.7486, 0.3115, 0.77]}, {"w": "a", "b": [0.3169, 0.7486, 0.3261, 0.77]}, {"w": "stride", "b": [0.3315, 0.7486, 0.3786, 0.77]}, {"w": "of", "b": [0.384, 0.7486, 0.4008, 0.77]}, {"w": "2", "b": [0.4062, 0.7486, 0.4162, 0.77]}, {"w": "(both", "b": [0.4216, 0.7486, 0.4675, 0.77]}, {"w": "horizontally", "b": [0.4729, 0.7486, 0.5739, 0.77]}, {"w": "and", "b": [0.5793, 0.7486, 0.6108, 0.77]}, {"w": "vertically).", "b": [0.6162, 0.7486, 0.7044, 0.77]}, {"w": "By", "b": [0.7098, 0.7486, 0.7316, 0.77]}, {"w": "default,", "b": [0.737, 0.7486, 0.7992, 0.77]}, {"w": "it", "b": [0.8046, 0.7486, 0.8165, 0.77]}, {"w": "uses", "b": [0.8219, 0.7486, 0.8571, 0.77]}, {"w": "VALID", "b": [0.1428, 0.7676, 0.203, 0.789]}, {"w": "padding", "b": [0.2077, 0.7676, 0.2765, 0.789]}, {"w": "(i.e.,", "b": [0.2812, 0.7676, 0.3171, 0.789]}, {"w": "no", "b": [0.3218, 0.7676, 0.3438, 0.789]}, {"w": "padding", "b": [0.3486, 0.7676, 0.4174, 0.789]}, {"w": "at", "b": [0.4221, 0.7676, 0.4372, 0.789]}, {"w": "all):", "b": [0.4419, 0.7676, 0.4736, 0.789]}]}, {"id": "b_4", "type": "equation", "text": "max_pool = keras.layers.MaxPool2D(pool_size=2)", "words": [{"w": "max_pool", "b": [0.1766, 0.7996, 0.244, 0.8124]}, {"w": "=", "b": [0.2525, 0.7996, 0.2609, 0.8124]}, {"w": "keras.layers.MaxPool2D(pool_size=2)", "b": [0.2693, 0.7996, 0.5645, 0.8124]}]}, {"id": "b_5", "type": "paragraph", "text": "To create an average pooling layer, just use AvgPool2D instead of MaxPool2D. As you might expect, it works exactly like a max pooling layer, except it computes the mean rather than the max. Average pooling layers used to be very popular, but people", "words": [{"w": "To", "b": [0.1429, 0.8211, 0.1643, 0.8425]}, {"w": "create", "b": [0.171, 0.8211, 0.2203, 0.8425]}, {"w": "an", "b": [0.227, 0.8211, 0.2475, 0.8425]}, {"w": "average", "b": [0.2542, 0.8209, 0.3157, 0.8425]}, {"w": "pooling", "b": [0.3224, 0.8209, 0.3816, 0.8425]}, {"w": "layer,", "b": [0.3883, 0.8209, 0.433, 0.8425]}, {"w": "just", "b": [0.4396, 0.8211, 0.47, 0.8425]}, {"w": "use", "b": [0.4767, 0.8211, 0.5042, 0.8425]}, {"w": "AvgPool2D", "b": [0.5109, 0.8243, 0.6, 0.8394]}, {"w": "instead", "b": [0.6066, 0.8211, 0.6666, 0.8425]}, {"w": "of", "b": [0.6733, 0.8211, 0.6901, 0.8425]}, {"w": "MaxPool2D.", "b": [0.6967, 0.8211, 0.7905, 0.8425]}, {"w": "As", "b": [0.7972, 0.8211, 0.8192, 0.8425]}, {"w": "you", "b": [0.8259, 0.8211, 0.8571, 0.8425]}, {"w": "might", "b": [0.1429, 0.8402, 0.1923, 0.8616]}, {"w": "expect,", "b": [0.1983, 0.8402, 0.2567, 0.8616]}, {"w": "it", "b": [0.2627, 0.8402, 0.2746, 0.8616]}, {"w": "works", "b": [0.2806, 0.8402, 0.3312, 0.8616]}, {"w": "exactly", "b": [0.3372, 0.8402, 0.395, 0.8616]}, {"w": "like", "b": [0.401, 0.8402, 0.431, 0.8616]}, {"w": "a", "b": [0.437, 0.8402, 0.4462, 0.8616]}, {"w": "max", "b": [0.4521, 0.8402, 0.4882, 0.8616]}, {"w": "pooling", "b": [0.4942, 0.8402, 0.5583, 0.8616]}, {"w": "layer,", "b": [0.5643, 0.8402, 0.6079, 0.8616]}, {"w": "except", "b": [0.6139, 0.8402, 0.6675, 0.8616]}, {"w": "it", "b": [0.6735, 0.8402, 0.6855, 0.8616]}, {"w": "computes", "b": [0.6914, 0.8402, 0.7724, 0.8616]}, {"w": "the", "b": [0.7784, 0.8402, 0.8047, 0.8616]}, {"w": "mean", "b": [0.8107, 0.8402, 0.8571, 0.8616]}, {"w": "rather", "b": [0.1429, 0.8592, 0.1934, 0.8806]}, {"w": "than", "b": [0.2023, 0.8592, 0.2403, 0.8806]}, {"w": "the", "b": [0.2492, 0.8592, 0.2756, 0.8806]}, {"w": "max.", "b": [0.2845, 0.8592, 0.3252, 0.8806]}, {"w": "Average", "b": [0.3341, 0.8592, 0.4011, 0.8806]}, {"w": "pooling", "b": [0.41, 0.8592, 0.4742, 0.8806]}, {"w": "layers", "b": [0.4831, 0.8592, 0.5309, 0.8806]}, {"w": "used", "b": [0.5398, 0.8592, 0.5784, 0.8806]}, {"w": "to", "b": [0.5873, 0.8592, 0.6043, 0.8806]}, {"w": "be", "b": [0.6132, 0.8592, 0.6326, 0.8806]}, {"w": "very", "b": [0.6415, 0.8592, 0.6779, 0.8806]}, {"w": "popular,", "b": [0.6868, 0.8592, 0.7559, 0.8806]}, {"w": "but", "b": [0.7648, 0.8592, 0.7928, 0.8806]}, {"w": "people", "b": [0.8017, 0.8592, 0.8572, 0.8806]}]}, {"id": "b_6", "type": "paragraph", "text": "444 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "444", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 471, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "mostly use max pooling layers now, as they generally perform better. This may seem surprising, since computing the mean generally loses less information than comput‐ ing the max. But on the other hand, max pooling preserves only the strongest feature, getting rid of all the meaningless ones, so the next layers get a cleaner signal to work with. Moreover, max pooling offers stronger translation invariance than average pooling.", "words": [{"w": "mostly", "b": [0.1429, 0.0791, 0.1994, 0.1005]}, {"w": "use", "b": [0.2054, 0.0791, 0.2329, 0.1005]}, {"w": "max", "b": [0.2389, 0.0791, 0.275, 0.1005]}, {"w": "pooling", "b": [0.2809, 0.0791, 0.3451, 0.1005]}, {"w": "layers", "b": [0.3511, 0.0791, 0.3989, 0.1005]}, {"w": "now,", "b": [0.4049, 0.0791, 0.4444, 0.1005]}, {"w": "as", "b": [0.4504, 0.0791, 0.4672, 0.1005]}, {"w": "they", "b": [0.4732, 0.0791, 0.5091, 0.1005]}, {"w": "generally", "b": [0.5151, 0.0791, 0.5909, 0.1005]}, {"w": "perform", "b": [0.5969, 0.0791, 0.666, 0.1005]}, {"w": "better.", "b": [0.672, 0.0791, 0.7242, 0.1005]}, {"w": "This", "b": [0.7301, 0.0791, 0.7674, 0.1005]}, {"w": "may", "b": [0.7733, 0.0791, 0.8087, 0.1005]}, {"w": "seem", "b": [0.8147, 0.0791, 0.8571, 0.1005]}, {"w": "surprising,", "b": [0.1429, 0.0981, 0.2326, 0.1195]}, {"w": "since", "b": [0.2388, 0.0981, 0.2811, 0.1195]}, {"w": "computing", "b": [0.2873, 0.0981, 0.3785, 0.1195]}, {"w": "the", "b": [0.3846, 0.0981, 0.411, 0.1195]}, {"w": "mean", "b": [0.4172, 0.0981, 0.4636, 0.1195]}, {"w": "generally", "b": [0.4698, 0.0981, 0.5456, 0.1195]}, {"w": "loses", "b": [0.5518, 0.0981, 0.5919, 0.1195]}, {"w": "less", "b": [0.598, 0.0981, 0.6274, 0.1195]}, {"w": "information", "b": [0.6336, 0.0981, 0.7349, 0.1195]}, {"w": "than", "b": [0.7411, 0.0981, 0.7791, 0.1195]}, {"w": "comput‐", "b": [0.7853, 0.0981, 0.8571, 0.1195]}, {"w": "ing", "b": [0.1429, 0.1172, 0.1696, 0.1386]}, {"w": "the", "b": [0.1746, 0.1172, 0.2009, 0.1386]}, {"w": "max.", "b": [0.2059, 0.1172, 0.2467, 0.1386]}, {"w": "But", "b": [0.2516, 0.1172, 0.2813, 0.1386]}, {"w": "on", "b": [0.2863, 0.1172, 0.3083, 0.1386]}, {"w": "the", "b": [0.3132, 0.1172, 0.3396, 0.1386]}, {"w": "other", "b": [0.3446, 0.1172, 0.3892, 0.1386]}, {"w": "hand,", "b": [0.3942, 0.1172, 0.4416, 0.1386]}, {"w": "max", "b": [0.4466, 0.1172, 0.4826, 0.1386]}, {"w": "pooling", "b": [0.4876, 0.1172, 0.5518, 0.1386]}, {"w": "preserves", "b": [0.5567, 0.1172, 0.6352, 0.1386]}, {"w": "only", "b": [0.6402, 0.1172, 0.677, 0.1386]}, {"w": "the", "b": [0.682, 0.1172, 0.7083, 0.1386]}, {"w": "strongest", "b": [0.7133, 0.1172, 0.7897, 0.1386]}, {"w": "feature,", "b": [0.7946, 0.1172, 0.8572, 0.1386]}, {"w": "getting", "b": [0.1429, 0.1362, 0.2009, 0.1576]}, {"w": "rid", "b": [0.2066, 0.1362, 0.2309, 0.1576]}, {"w": "of", "b": [0.2366, 0.1362, 0.2534, 0.1576]}, {"w": "all", "b": [0.2592, 0.1362, 0.2788, 0.1576]}, {"w": "the", "b": [0.2846, 0.1362, 0.3109, 0.1576]}, {"w": "meaningless", "b": [0.3166, 0.1362, 0.4192, 0.1576]}, {"w": "ones,", "b": [0.4249, 0.1362, 0.4682, 0.1576]}, {"w": "so", "b": [0.4739, 0.1362, 0.4922, 0.1576]}, {"w": "the", "b": [0.4979, 0.1362, 0.5242, 0.1576]}, {"w": "next", "b": [0.53, 0.1362, 0.5664, 0.1576]}, {"w": "layers", "b": [0.5721, 0.1362, 0.6199, 0.1576]}, {"w": "get", "b": [0.6257, 0.1362, 0.6506, 0.1576]}, {"w": "a", "b": [0.6563, 0.1362, 0.6655, 0.1576]}, {"w": "cleaner", "b": [0.6712, 0.1362, 0.7313, 0.1576]}, {"w": "signal", "b": [0.737, 0.1362, 0.7858, 0.1576]}, {"w": "to", "b": [0.7915, 0.1362, 0.8085, 0.1576]}, {"w": "work", "b": [0.8142, 0.1362, 0.8571, 0.1576]}, {"w": "with.", "b": [0.1429, 0.1553, 0.1849, 0.1767]}, {"w": "Moreover,", "b": [0.1951, 0.1553, 0.2806, 0.1767]}, {"w": "max", "b": [0.2908, 0.1553, 0.3268, 0.1767]}, {"w": "pooling", "b": [0.337, 0.1553, 0.4011, 0.1767]}, {"w": "offers", "b": [0.4113, 0.1553, 0.4585, 0.1767]}, {"w": "stronger", "b": [0.4686, 0.1553, 0.5387, 0.1767]}, {"w": "translation", "b": [0.5489, 0.1553, 0.6391, 0.1767]}, {"w": "invariance", "b": [0.6493, 0.1553, 0.7361, 0.1767]}, {"w": "than", "b": [0.7462, 0.1553, 0.7842, 0.1767]}, {"w": "average", "b": [0.7944, 0.1553, 0.8571, 0.1767]}, {"w": "pooling.", "b": [0.1428, 0.1743, 0.2118, 0.1957]}]}, {"id": "b_1", "type": "paragraph", "text": "Note that max pooling and average pooling can be performed along the depth dimen‐ sion rather than the spatial dimensions, although this is not as common. This can allow the CNN to learn to be invariant to various features. For example, it could learn multiple filters, each detecting a different rotation of the same pattern, such as hand- written digits (see Figure 14-10), and the depth-wise max pooling layer would ensure that the output is the same regardless of the rotation. The CNN could similarly learn to be invariant to anything else: thickness, brightness, skew, color, and so on.", "words": [{"w": "Note", "b": [0.1428, 0.2024, 0.1836, 0.2238]}, {"w": "that", "b": [0.1884, 0.2024, 0.221, 0.2238]}, {"w": "max", "b": [0.2258, 0.2024, 0.2619, 0.2238]}, {"w": "pooling", "b": [0.2667, 0.2024, 0.3308, 0.2238]}, {"w": "and", "b": [0.3356, 0.2024, 0.3672, 0.2238]}, {"w": "average", "b": [0.372, 0.2024, 0.4347, 0.2238]}, {"w": "pooling", "b": [0.4395, 0.2024, 0.5037, 0.2238]}, {"w": "can", "b": [0.5085, 0.2024, 0.5379, 0.2238]}, {"w": "be", "b": [0.5427, 0.2024, 0.5621, 0.2238]}, {"w": "performed", "b": [0.5669, 0.2024, 0.6558, 0.2238]}, {"w": "along", "b": [0.6606, 0.2024, 0.7068, 0.2238]}, {"w": "the", "b": [0.7116, 0.2024, 0.738, 0.2238]}, {"w": "depth", "b": [0.7428, 0.2024, 0.791, 0.2238]}, {"w": "dimen‐", "b": [0.7958, 0.2024, 0.8571, 0.2238]}, {"w": "sion", "b": [0.1429, 0.2215, 0.1781, 0.2429]}, {"w": "rather", "b": [0.1857, 0.2215, 0.2362, 0.2429]}, {"w": "than", "b": [0.2438, 0.2215, 0.2818, 0.2429]}, {"w": "the", "b": [0.2894, 0.2215, 0.3157, 0.2429]}, {"w": "spatial", "b": [0.3233, 0.2215, 0.377, 0.2429]}, {"w": "dimensions,", "b": [0.3846, 0.2215, 0.4861, 0.2429]}, {"w": "although", "b": [0.4937, 0.2215, 0.5681, 0.2429]}, {"w": "this", "b": [0.5757, 0.2215, 0.6064, 0.2429]}, {"w": "is", "b": [0.614, 0.2215, 0.6272, 0.2429]}, {"w": "not", "b": [0.6348, 0.2215, 0.6632, 0.2429]}, {"w": "as", "b": [0.6707, 0.2215, 0.6875, 0.2429]}, {"w": "common.", "b": [0.6951, 0.2215, 0.7754, 0.2429]}, {"w": "This", "b": [0.783, 0.2215, 0.8202, 0.2429]}, {"w": "can", "b": [0.8278, 0.2215, 0.8571, 0.2429]}, {"w": "allow", "b": [0.1429, 0.2405, 0.1874, 0.2619]}, {"w": "the", "b": [0.1924, 0.2405, 0.2188, 0.2619]}, {"w": "CNN", "b": [0.2237, 0.2405, 0.2685, 0.2619]}, {"w": "to", "b": [0.2735, 0.2405, 0.2905, 0.2619]}, {"w": "learn", "b": [0.2955, 0.2405, 0.3379, 0.2619]}, {"w": "to", "b": [0.3429, 0.2405, 0.3598, 0.2619]}, {"w": "be", "b": [0.3648, 0.2405, 0.3843, 0.2619]}, {"w": "invariant", "b": [0.3892, 0.2405, 0.4643, 0.2619]}, {"w": "to", "b": [0.4693, 0.2405, 0.4863, 0.2619]}, {"w": "various", "b": [0.4913, 0.2405, 0.5527, 0.2619]}, {"w": "features.", "b": [0.5577, 0.2405, 0.6279, 0.2619]}, {"w": "For", "b": [0.6328, 0.2405, 0.6618, 0.2619]}, {"w": "example,", "b": [0.6668, 0.2405, 0.7411, 0.2619]}, {"w": "it", "b": [0.7461, 0.2405, 0.758, 0.2619]}, {"w": "could", "b": [0.763, 0.2405, 0.8098, 0.2619]}, {"w": "learn", "b": [0.8147, 0.2405, 0.8571, 0.2619]}, {"w": "multiple", "b": [0.1429, 0.2596, 0.2128, 0.281]}, {"w": "filters,", "b": [0.2184, 0.2596, 0.2707, 0.281]}, {"w": "each", "b": [0.2763, 0.2596, 0.3142, 0.281]}, {"w": "detecting", "b": [0.3198, 0.2596, 0.3968, 0.281]}, {"w": "a", "b": [0.4023, 0.2596, 0.4115, 0.281]}, {"w": "different", "b": [0.417, 0.2596, 0.4888, 0.281]}, {"w": "rotation", "b": [0.4943, 0.2596, 0.5617, 0.281]}, {"w": "of", "b": [0.5673, 0.2596, 0.5841, 0.281]}, {"w": "the", "b": [0.5897, 0.2596, 0.616, 0.281]}, {"w": "same", "b": [0.6215, 0.2596, 0.6643, 0.281]}, {"w": "pattern,", "b": [0.6698, 0.2596, 0.7349, 0.281]}, {"w": "such", "b": [0.7405, 0.2596, 0.7791, 0.281]}, {"w": "as", "b": [0.7847, 0.2596, 0.8015, 0.281]}, {"w": "hand-", "b": [0.8071, 0.2596, 0.8571, 0.281]}, {"w": "written", "b": [0.1429, 0.2786, 0.2034, 0.3]}, {"w": "digits", "b": [0.2087, 0.2786, 0.2546, 0.3]}, {"w": "(see", "b": [0.26, 0.2786, 0.2925, 0.3]}, {"w": "Figure", "b": [0.2978, 0.2786, 0.3518, 0.3]}, {"w": "14-10),", "b": [0.3566, 0.2786, 0.4165, 0.3]}, {"w": "and", "b": [0.4219, 0.2786, 0.4534, 0.3]}, {"w": "the", "b": [0.4587, 0.2786, 0.485, 0.3]}, {"w": "depth-wise", "b": [0.4904, 0.2786, 0.5824, 0.3]}, {"w": "max", "b": [0.5877, 0.2786, 0.6237, 0.3]}, {"w": "pooling", "b": [0.6291, 0.2786, 0.6932, 0.3]}, {"w": "layer", "b": [0.6985, 0.2786, 0.7387, 0.3]}, {"w": "would", "b": [0.7441, 0.2786, 0.7963, 0.3]}, {"w": "ensure", "b": [0.8016, 0.2786, 0.8571, 0.3]}, {"w": "that", "b": [0.1429, 0.2977, 0.1754, 0.3191]}, {"w": "the", "b": [0.181, 0.2977, 0.2074, 0.3191]}, {"w": "output", "b": [0.2129, 0.2977, 0.2693, 0.3191]}, {"w": "is", "b": [0.2749, 0.2977, 0.2881, 0.3191]}, {"w": "the", "b": [0.2937, 0.2977, 0.32, 0.3191]}, {"w": "same", "b": [0.3256, 0.2977, 0.3683, 0.3191]}, {"w": "regardless", "b": [0.3739, 0.2977, 0.4575, 0.3191]}, {"w": "of", "b": [0.4631, 0.2977, 0.4799, 0.3191]}, {"w": "the", "b": [0.4855, 0.2977, 0.5118, 0.3191]}, {"w": "rotation.", "b": [0.5174, 0.2977, 0.5896, 0.3191]}, {"w": "The", "b": [0.5951, 0.2977, 0.628, 0.3191]}, {"w": "CNN", "b": [0.6336, 0.2977, 0.6784, 0.3191]}, {"w": "could", "b": [0.684, 0.2977, 0.7307, 0.3191]}, {"w": "similarly", "b": [0.7363, 0.2977, 0.8092, 0.3191]}, {"w": "learn", "b": [0.8147, 0.2977, 0.8571, 0.3191]}, {"w": "to", "b": [0.1428, 0.3167, 0.1598, 0.3381]}, {"w": "be", "b": [0.1646, 0.3167, 0.184, 0.3381]}, {"w": "invariant", "b": [0.1887, 0.3167, 0.2638, 0.3381]}, {"w": "to", "b": [0.2686, 0.3167, 0.2855, 0.3381]}, {"w": "anything", "b": [0.2903, 0.3167, 0.3641, 0.3381]}, {"w": "else:", "b": [0.3688, 0.3167, 0.4042, 0.3381]}, {"w": "thickness,", "b": [0.4089, 0.3167, 0.4914, 0.3381]}, {"w": "brightness,", "b": [0.4962, 0.3167, 0.5872, 0.3381]}, {"w": "skew,", "b": [0.5919, 0.3167, 0.6362, 0.3381]}, {"w": "color,", "b": [0.641, 0.3167, 0.6875, 0.3381]}, {"w": "and", "b": [0.6922, 0.3167, 0.7237, 0.3381]}, {"w": "so", "b": [0.7285, 0.3167, 0.7467, 0.3381]}, {"w": "on.", "b": [0.7515, 0.3167, 0.7782, 0.3381]}]}, {"id": "b_2", "type": "equation", "text": "Figure 14-10. Depth-wise max pooling can help the CNN learn any invariance", "words": [{"w": "Figure", "b": [0.1428, 0.8291, 0.1943, 0.8507]}, {"w": "14-10.", "b": [0.1991, 0.8291, 0.2507, 0.8507]}, {"w": "Depth-wise", "b": [0.2554, 0.8291, 0.3477, 0.8507]}, {"w": "max", "b": [0.3525, 0.8291, 0.3888, 0.8507]}, {"w": "pooling", "b": [0.3935, 0.8291, 0.4528, 0.8507]}, {"w": "can", "b": [0.4575, 0.8291, 0.4863, 0.8507]}, {"w": "help", "b": [0.4911, 0.8291, 0.5247, 0.8507]}, {"w": "the", "b": [0.5295, 0.8291, 0.5545, 0.8507]}, {"w": "CNN", "b": [0.5593, 0.8291, 0.6019, 0.8507]}, {"w": "learn", "b": [0.6066, 0.8291, 0.6487, 0.8507]}, {"w": "any", "b": [0.6535, 0.8291, 0.6831, 0.8507]}, {"w": "invariance", "b": [0.6879, 0.8291, 0.7734, 0.8507]}]}, {"id": "b_3", "type": "paragraph", "text": "Pooling Layer | 445", "words": [{"w": "Pooling", "b": [0.7158, 0.9225, 0.7609, 0.9388]}, {"w": "Layer", "b": [0.7637, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "445", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 472, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Keras does not include a depth-wise max pooling layer, but TensorFlow’s low-level Deep Learning API does: just use the tf.nn.max_pool() function, and specify the kernel size and strides as 4-tuples. The first three values of each should be 1: this indi‐ cates that the kernel size and stride along the batch, height and width dimensions shoud be 1. The last value should be whatever kernel size and stride you want along the depth dimension, for example 3 (this must be a divisor of the input depth; for example, it will not work if the previous layer outputs 20 feature maps, since 20 is not a multiple of 3):", "words": [{"w": "Keras", "b": [0.1429, 0.0791, 0.1898, 0.1005]}, {"w": "does", "b": [0.1972, 0.0791, 0.2353, 0.1005]}, {"w": "not", "b": [0.2428, 0.0791, 0.2711, 0.1005]}, {"w": "include", "b": [0.2786, 0.0791, 0.3406, 0.1005]}, {"w": "a", "b": [0.348, 0.0791, 0.3571, 0.1005]}, {"w": "depth-wise", "b": [0.3646, 0.0791, 0.4566, 0.1005]}, {"w": "max", "b": [0.4641, 0.0791, 0.5001, 0.1005]}, {"w": "pooling", "b": [0.5075, 0.0791, 0.5717, 0.1005]}, {"w": "layer,", "b": [0.5791, 0.0791, 0.6228, 0.1005]}, {"w": "but", "b": [0.6302, 0.0791, 0.6582, 0.1005]}, {"w": "TensorFlow’s", "b": [0.6657, 0.0791, 0.7742, 0.1005]}, {"w": "low-level", "b": [0.7817, 0.0791, 0.8571, 0.1005]}, {"w": "Deep", "b": [0.1429, 0.099, 0.1868, 0.1204]}, {"w": "Learning", "b": [0.1945, 0.099, 0.2695, 0.1204]}, {"w": "API", "b": [0.2772, 0.099, 0.3105, 0.1204]}, {"w": "does:", "b": [0.3182, 0.099, 0.361, 0.1204]}, {"w": "just", "b": [0.3687, 0.099, 0.3991, 0.1204]}, {"w": "use", "b": [0.4068, 0.099, 0.4344, 0.1204]}, {"w": "the", "b": [0.4421, 0.099, 0.4684, 0.1204]}, {"w": "tf.nn.max_pool()", "b": [0.4761, 0.1022, 0.6344, 0.1173]}, {"w": "function,", "b": [0.6421, 0.099, 0.7183, 0.1204]}, {"w": "and", "b": [0.726, 0.099, 0.7575, 0.1204]}, {"w": "specify", "b": [0.7652, 0.099, 0.8231, 0.1204]}, {"w": "the", "b": [0.8308, 0.099, 0.8571, 0.1204]}, {"w": "kernel", "b": [0.1429, 0.1181, 0.1953, 0.1395]}, {"w": "size", "b": [0.2001, 0.1181, 0.231, 0.1395]}, {"w": "and", "b": [0.2358, 0.1181, 0.2674, 0.1395]}, {"w": "strides", "b": [0.2722, 0.1181, 0.327, 0.1395]}, {"w": "as", "b": [0.3318, 0.1181, 0.3486, 0.1395]}, {"w": "4-tuples.", "b": [0.3535, 0.1181, 0.4257, 0.1395]}, {"w": "The", "b": [0.4306, 0.1181, 0.4634, 0.1395]}, {"w": "first", "b": [0.4683, 0.1181, 0.5017, 0.1395]}, {"w": "three", "b": [0.5066, 0.1181, 0.5495, 0.1395]}, {"w": "values", "b": [0.5543, 0.1181, 0.606, 0.1395]}, {"w": "of", "b": [0.6108, 0.1181, 0.6276, 0.1395]}, {"w": "each", "b": [0.6324, 0.1181, 0.6704, 0.1395]}, {"w": "should", "b": [0.6752, 0.1181, 0.7319, 0.1395]}, {"w": "be", "b": [0.7368, 0.1181, 0.7562, 0.1395]}, {"w": "1:", "b": [0.761, 0.1181, 0.7758, 0.1395]}, {"w": "this", "b": [0.7806, 0.1181, 0.8113, 0.1395]}, {"w": "indi‐", "b": [0.8162, 0.1181, 0.8572, 0.1395]}, {"w": "cates", "b": [0.1429, 0.1371, 0.1833, 0.1585]}, {"w": "that", "b": [0.191, 0.1371, 0.2236, 0.1585]}, {"w": "the", "b": [0.2314, 0.1371, 0.2577, 0.1585]}, {"w": "kernel", "b": [0.2655, 0.1371, 0.3179, 0.1585]}, {"w": "size", "b": [0.3257, 0.1371, 0.3565, 0.1585]}, {"w": "and", "b": [0.3643, 0.1371, 0.3959, 0.1585]}, {"w": "stride", "b": [0.4036, 0.1371, 0.4508, 0.1585]}, {"w": "along", "b": [0.4586, 0.1371, 0.5048, 0.1585]}, {"w": "the", "b": [0.5125, 0.1371, 0.5389, 0.1585]}, {"w": "batch,", "b": [0.5466, 0.1371, 0.597, 0.1585]}, {"w": "height", "b": [0.6048, 0.1371, 0.6572, 0.1585]}, {"w": "and", "b": [0.6649, 0.1371, 0.6965, 0.1585]}, {"w": "width", "b": [0.7043, 0.1371, 0.7526, 0.1585]}, {"w": "dimensions", "b": [0.7604, 0.1371, 0.8571, 0.1585]}, {"w": "shoud", "b": [0.1429, 0.1561, 0.1943, 0.1776]}, {"w": "be", "b": [0.2004, 0.1561, 0.2198, 0.1776]}, {"w": "1.", "b": [0.2259, 0.1561, 0.2407, 0.1776]}, {"w": "The", "b": [0.2468, 0.1561, 0.2796, 0.1776]}, {"w": "last", "b": [0.2857, 0.1561, 0.3141, 0.1776]}, {"w": "value", "b": [0.3202, 0.1561, 0.3642, 0.1776]}, {"w": "should", "b": [0.3703, 0.1561, 0.427, 0.1776]}, {"w": "be", "b": [0.4331, 0.1561, 0.4526, 0.1776]}, {"w": "whatever", "b": [0.4587, 0.1561, 0.5343, 0.1776]}, {"w": "kernel", "b": [0.5404, 0.1561, 0.5928, 0.1776]}, {"w": "size", "b": [0.5989, 0.1561, 0.6297, 0.1776]}, {"w": "and", "b": [0.6358, 0.1561, 0.6674, 0.1776]}, {"w": "stride", "b": [0.6735, 0.1561, 0.7206, 0.1776]}, {"w": "you", "b": [0.7267, 0.1561, 0.758, 0.1776]}, {"w": "want", "b": [0.7641, 0.1561, 0.8049, 0.1776]}, {"w": "along", "b": [0.811, 0.1561, 0.8571, 0.1776]}, {"w": "the", "b": [0.1428, 0.1752, 0.1692, 0.1966]}, {"w": "depth", "b": [0.1765, 0.1752, 0.2248, 0.1966]}, {"w": "dimension,", "b": [0.2321, 0.1752, 0.326, 0.1966]}, {"w": "for", "b": [0.3334, 0.1752, 0.3579, 0.1966]}, {"w": "example", "b": [0.3652, 0.1752, 0.4348, 0.1966]}, {"w": "3", "b": [0.4421, 0.1752, 0.4521, 0.1966]}, {"w": "(this", "b": [0.4594, 0.1752, 0.4974, 0.1966]}, {"w": "must", "b": [0.5047, 0.1752, 0.5464, 0.1966]}, {"w": "be", "b": [0.5538, 0.1752, 0.5732, 0.1966]}, {"w": "a", "b": [0.5806, 0.1752, 0.5897, 0.1966]}, {"w": "divisor", "b": [0.597, 0.1752, 0.6549, 0.1966]}, {"w": "of", "b": [0.6622, 0.1752, 0.679, 0.1966]}, {"w": "the", "b": [0.6863, 0.1752, 0.7127, 0.1966]}, {"w": "input", "b": [0.72, 0.1752, 0.7649, 0.1966]}, {"w": "depth;", "b": [0.7723, 0.1752, 0.8253, 0.1966]}, {"w": "for", "b": [0.8326, 0.1752, 0.8571, 0.1966]}, {"w": "example,", "b": [0.1429, 0.1942, 0.2172, 0.2157]}, {"w": "it", "b": [0.2222, 0.1942, 0.2342, 0.2157]}, {"w": "will", "b": [0.2392, 0.1942, 0.2696, 0.2157]}, {"w": "not", "b": [0.2747, 0.1942, 0.3031, 0.2157]}, {"w": "work", "b": [0.3082, 0.1942, 0.3511, 0.2157]}, {"w": "if", "b": [0.3562, 0.1942, 0.3679, 0.2157]}, {"w": "the", "b": [0.373, 0.1942, 0.3993, 0.2157]}, {"w": "previous", "b": [0.4044, 0.1942, 0.4765, 0.2157]}, {"w": "layer", "b": [0.4816, 0.1942, 0.5217, 0.2157]}, {"w": "outputs", "b": [0.5268, 0.1942, 0.5908, 0.2157]}, {"w": "20", "b": [0.5959, 0.1942, 0.6159, 0.2157]}, {"w": "feature", "b": [0.621, 0.1942, 0.6788, 0.2157]}, {"w": "maps,", "b": [0.6838, 0.1942, 0.733, 0.2157]}, {"w": "since", "b": [0.738, 0.1942, 0.7803, 0.2157]}, {"w": "20", "b": [0.7854, 0.1942, 0.8054, 0.2157]}, {"w": "is", "b": [0.8105, 0.1942, 0.8237, 0.2157]}, {"w": "not", "b": [0.8288, 0.1942, 0.8571, 0.2157]}, {"w": "a", "b": [0.1429, 0.2133, 0.152, 0.2347]}, {"w": "multiple", "b": [0.1567, 0.2133, 0.2267, 0.2347]}, {"w": "of", "b": [0.2314, 0.2133, 0.2482, 0.2347]}, {"w": "3):", "b": [0.253, 0.2133, 0.2749, 0.2347]}]}, {"id": "b_1", "type": "paragraph", "text": "output = tf.nn.max_pool(images, ksize=(1, 1, 1, 3), strides=(1, 1, 1, 3), padding=\"VALID\")", "words": [{"w": "output", "b": [0.1766, 0.2453, 0.2272, 0.2581]}, {"w": "=", "b": [0.2356, 0.2453, 0.244, 0.2581]}, {"w": "tf.nn.max_pool(images,", "b": [0.2525, 0.2453, 0.438, 0.2581]}, {"w": "ksize=(1,", "b": [0.379, 0.2607, 0.4549, 0.2735]}, {"w": "1,", "b": [0.4633, 0.2607, 0.4802, 0.2735]}, {"w": "1,", "b": [0.4886, 0.2607, 0.5054, 0.2735]}, {"w": "3),", "b": [0.5139, 0.2607, 0.5392, 0.2735]}, {"w": "strides=(1,", "b": [0.379, 0.2761, 0.4717, 0.289]}, {"w": "1,", "b": [0.4802, 0.2761, 0.497, 0.289]}, {"w": "1,", "b": [0.5054, 0.2761, 0.5223, 0.289]}, {"w": "3),", "b": [0.5307, 0.2761, 0.556, 0.289]}, {"w": "padding=\"VALID\")", "b": [0.379, 0.2915, 0.5139, 0.3044]}]}, {"id": "b_2", "type": "paragraph", "text": "If you want to include this as a layer in your Keras models, you can simply wrap it in a Lambda layer (or create a custom Keras layer):", "words": [{"w": "If", "b": [0.1429, 0.3122, 0.1561, 0.3336]}, {"w": "you", "b": [0.1616, 0.3122, 0.1928, 0.3336]}, {"w": "want", "b": [0.1983, 0.3122, 0.2391, 0.3336]}, {"w": "to", "b": [0.2445, 0.3122, 0.2615, 0.3336]}, {"w": "include", "b": [0.267, 0.3122, 0.329, 0.3336]}, {"w": "this", "b": [0.3344, 0.3122, 0.3651, 0.3336]}, {"w": "as", "b": [0.3706, 0.3122, 0.3874, 0.3336]}, {"w": "a", "b": [0.3928, 0.3122, 0.402, 0.3336]}, {"w": "layer", "b": [0.4074, 0.3122, 0.4476, 0.3336]}, {"w": "in", "b": [0.4531, 0.3122, 0.4701, 0.3336]}, {"w": "your", "b": [0.4755, 0.3122, 0.5145, 0.3336]}, {"w": "Keras", "b": [0.52, 0.3122, 0.5669, 0.3336]}, {"w": "models,", "b": [0.5723, 0.3122, 0.6375, 0.3336]}, {"w": "you", "b": [0.643, 0.3122, 0.6743, 0.3336]}, {"w": "can", "b": [0.6797, 0.3122, 0.7091, 0.3336]}, {"w": "simply", "b": [0.7145, 0.3122, 0.7702, 0.3336]}, {"w": "wrap", "b": [0.7756, 0.3122, 0.8173, 0.3336]}, {"w": "it", "b": [0.8228, 0.3122, 0.8347, 0.3336]}, {"w": "in", "b": [0.8402, 0.3122, 0.8571, 0.3336]}, {"w": "a", "b": [0.1429, 0.3321, 0.152, 0.3535]}, {"w": "Lambda", "b": [0.1567, 0.3353, 0.2161, 0.3504]}, {"w": "layer", "b": [0.2208, 0.3321, 0.261, 0.3535]}, {"w": "(or", "b": [0.2658, 0.3321, 0.2913, 0.3535]}, {"w": "create", "b": [0.296, 0.3321, 0.3454, 0.3535]}, {"w": "a", "b": [0.3501, 0.3321, 0.3593, 0.3535]}, {"w": "custom", "b": [0.364, 0.3321, 0.4256, 0.3535]}, {"w": "Keras", "b": [0.4303, 0.3321, 0.4772, 0.3535]}, {"w": "layer):", "b": [0.4819, 0.3321, 0.5341, 0.3535]}]}, {"id": "b_3", "type": "paragraph", "text": "depth_pool = keras.layers.Lambda( lambda X: tf.nn.max_pool(X, ksize=(1, 1, 1, 3), strides=(1, 1, 1, 3), padding=\"VALID\"))", "words": [{"w": "depth_pool", "b": [0.1766, 0.3641, 0.2609, 0.3769]}, {"w": "=", "b": [0.2694, 0.3641, 0.2778, 0.3769]}, {"w": "keras.layers.Lambda(", "b": [0.2862, 0.3641, 0.4549, 0.3769]}, {"w": "lambda", "b": [0.2103, 0.3795, 0.2609, 0.3923]}, {"w": "X:", "b": [0.2694, 0.3795, 0.2862, 0.3923]}, {"w": "tf.nn.max_pool(X,", "b": [0.2946, 0.3795, 0.438, 0.3923]}, {"w": "ksize=(1,", "b": [0.4464, 0.3795, 0.5223, 0.3923]}, {"w": "1,", "b": [0.5308, 0.3795, 0.5476, 0.3923]}, {"w": "1,", "b": [0.5561, 0.3795, 0.5729, 0.3923]}, {"w": "3),", "b": [0.5814, 0.3795, 0.6067, 0.3923]}, {"w": "strides=(1,", "b": [0.6151, 0.3795, 0.7078, 0.3923]}, {"w": "1,", "b": [0.7163, 0.3795, 0.7331, 0.3923]}, {"w": "1,", "b": [0.7416, 0.3795, 0.7584, 0.3923]}, {"w": "3),", "b": [0.7669, 0.3795, 0.7922, 0.3923]}, {"w": "padding=\"VALID\"))", "b": [0.4211, 0.3949, 0.5645, 0.4078]}]}, {"id": "b_4", "type": "paragraph", "text": "One last type of pooling layer that you will often see in modern architectures is the global average pooling layer. It works very differently: all it does is compute the mean of each entire feature map (it’s like an average pooling layer using a pooling kernel with the same spatial dimensions as the inputs). This means that it just outputs a sin‐ gle number per feature map and per instance. Although this is of course extremely destructive (most of the information in the feature map is lost), it can be useful as the output layer, as we will see later in this chapter. To create such a layer, simply use the keras.layers.GlobalAvgPool2D class:", "words": [{"w": "One", "b": [0.1429, 0.4155, 0.1787, 0.437]}, {"w": "last", "b": [0.1853, 0.4155, 0.2137, 0.437]}, {"w": "type", "b": [0.2203, 0.4155, 0.256, 0.437]}, {"w": "of", "b": [0.2626, 0.4155, 0.2794, 0.437]}, {"w": "pooling", "b": [0.286, 0.4155, 0.3501, 0.437]}, {"w": "layer", "b": [0.3567, 0.4155, 0.3969, 0.437]}, {"w": "that", "b": [0.4035, 0.4155, 0.4361, 0.437]}, {"w": "you", "b": [0.4427, 0.4155, 0.4739, 0.437]}, {"w": "will", "b": [0.4805, 0.4155, 0.5109, 0.437]}, {"w": "often", "b": [0.5175, 0.4155, 0.5609, 0.437]}, {"w": "see", "b": [0.5675, 0.4155, 0.5929, 0.437]}, {"w": "in", "b": [0.5995, 0.4155, 0.6165, 0.437]}, {"w": "modern", "b": [0.6231, 0.4155, 0.6897, 0.437]}, {"w": "architectures", "b": [0.6963, 0.4155, 0.8044, 0.437]}, {"w": "is", "b": [0.811, 0.4155, 0.8242, 0.437]}, {"w": "the", "b": [0.8308, 0.4155, 0.8572, 0.437]}, {"w": "global", "b": [0.1429, 0.4344, 0.1914, 0.456]}, {"w": "average", "b": [0.1972, 0.4344, 0.2587, 0.456]}, {"w": "pooling", "b": [0.2645, 0.4344, 0.3238, 0.456]}, {"w": "layer.", "b": [0.3295, 0.4346, 0.3731, 0.456]}, {"w": "It", "b": [0.3789, 0.4346, 0.3915, 0.456]}, {"w": "works", "b": [0.3973, 0.4346, 0.4479, 0.456]}, {"w": "very", "b": [0.4537, 0.4346, 0.4901, 0.456]}, {"w": "differently:", "b": [0.4958, 0.4346, 0.5878, 0.456]}, {"w": "all", "b": [0.5935, 0.4346, 0.6132, 0.456]}, {"w": "it", "b": [0.619, 0.4346, 0.6309, 0.456]}, {"w": "does", "b": [0.6367, 0.4346, 0.6748, 0.456]}, {"w": "is", "b": [0.6806, 0.4346, 0.6938, 0.456]}, {"w": "compute", "b": [0.6995, 0.4346, 0.7728, 0.456]}, {"w": "the", "b": [0.7786, 0.4346, 0.8049, 0.456]}, {"w": "mean", "b": [0.8107, 0.4346, 0.8571, 0.456]}, {"w": "of", "b": [0.1429, 0.4536, 0.1596, 0.4751]}, {"w": "each", "b": [0.1667, 0.4536, 0.2046, 0.4751]}, {"w": "entire", "b": [0.2117, 0.4536, 0.2601, 0.4751]}, {"w": "feature", "b": [0.2672, 0.4536, 0.3249, 0.4751]}, {"w": "map", "b": [0.332, 0.4536, 0.3687, 0.4751]}, {"w": "(it’s", "b": [0.3758, 0.4536, 0.4047, 0.4751]}, {"w": "like", "b": [0.4117, 0.4536, 0.4418, 0.4751]}, {"w": "an", "b": [0.4488, 0.4536, 0.4694, 0.4751]}, {"w": "average", "b": [0.4765, 0.4536, 0.5392, 0.4751]}, {"w": "pooling", "b": [0.5463, 0.4536, 0.6104, 0.4751]}, {"w": "layer", "b": [0.6175, 0.4536, 0.6577, 0.4751]}, {"w": "using", "b": [0.6648, 0.4536, 0.7102, 0.4751]}, {"w": "a", "b": [0.7173, 0.4536, 0.7264, 0.4751]}, {"w": "pooling", "b": [0.7335, 0.4536, 0.7976, 0.4751]}, {"w": "kernel", "b": [0.8047, 0.4536, 0.8571, 0.4751]}, {"w": "with", "b": [0.1429, 0.4727, 0.1802, 0.4941]}, {"w": "the", "b": [0.1854, 0.4727, 0.2118, 0.4941]}, {"w": "same", "b": [0.217, 0.4727, 0.2597, 0.4941]}, {"w": "spatial", "b": [0.2649, 0.4727, 0.3186, 0.4941]}, {"w": "dimensions", "b": [0.3238, 0.4727, 0.4206, 0.4941]}, {"w": "as", "b": [0.4258, 0.4727, 0.4426, 0.4941]}, {"w": "the", "b": [0.4478, 0.4727, 0.4742, 0.4941]}, {"w": "inputs).", "b": [0.4794, 0.4727, 0.5439, 0.4941]}, {"w": "This", "b": [0.5491, 0.4727, 0.5864, 0.4941]}, {"w": "means", "b": [0.5916, 0.4727, 0.6457, 0.4941]}, {"w": "that", "b": [0.6509, 0.4727, 0.6835, 0.4941]}, {"w": "it", "b": [0.6887, 0.4727, 0.7007, 0.4941]}, {"w": "just", "b": [0.7059, 0.4727, 0.7363, 0.4941]}, {"w": "outputs", "b": [0.7415, 0.4727, 0.8055, 0.4941]}, {"w": "a", "b": [0.8107, 0.4727, 0.8199, 0.4941]}, {"w": "sin‐", "b": [0.8251, 0.4727, 0.8572, 0.4941]}, {"w": "gle", "b": [0.1429, 0.4917, 0.1667, 0.5132]}, {"w": "number", "b": [0.1738, 0.4917, 0.2401, 0.5132]}, {"w": "per", "b": [0.2471, 0.4917, 0.2746, 0.5132]}, {"w": "feature", "b": [0.2817, 0.4917, 0.3394, 0.5132]}, {"w": "map", "b": [0.3465, 0.4917, 0.3832, 0.5132]}, {"w": "and", "b": [0.3903, 0.4917, 0.4218, 0.5132]}, {"w": "per", "b": [0.4288, 0.4917, 0.4563, 0.5132]}, {"w": "instance.", "b": [0.4634, 0.4917, 0.5373, 0.5132]}, {"w": "Although", "b": [0.5444, 0.4917, 0.6241, 0.5132]}, {"w": "this", "b": [0.6311, 0.4917, 0.6618, 0.5132]}, {"w": "is", "b": [0.6689, 0.4917, 0.6821, 0.5132]}, {"w": "of", "b": [0.6892, 0.4917, 0.706, 0.5132]}, {"w": "course", "b": [0.713, 0.4917, 0.7677, 0.5132]}, {"w": "extremely", "b": [0.7748, 0.4917, 0.8571, 0.5132]}, {"w": "destructive", "b": [0.1429, 0.5108, 0.2348, 0.5322]}, {"w": "(most", "b": [0.2399, 0.5108, 0.2888, 0.5322]}, {"w": "of", "b": [0.2939, 0.5108, 0.3107, 0.5322]}, {"w": "the", "b": [0.3159, 0.5108, 0.3422, 0.5322]}, {"w": "information", "b": [0.3473, 0.5108, 0.4486, 0.5322]}, {"w": "in", "b": [0.4538, 0.5108, 0.4707, 0.5322]}, {"w": "the", "b": [0.4759, 0.5108, 0.5022, 0.5322]}, {"w": "feature", "b": [0.5074, 0.5108, 0.5651, 0.5322]}, {"w": "map", "b": [0.5703, 0.5108, 0.607, 0.5322]}, {"w": "is", "b": [0.6121, 0.5108, 0.6254, 0.5322]}, {"w": "lost),", "b": [0.6305, 0.5108, 0.6724, 0.5322]}, {"w": "it", "b": [0.6775, 0.5108, 0.6894, 0.5322]}, {"w": "can", "b": [0.6946, 0.5108, 0.7239, 0.5322]}, {"w": "be", "b": [0.7291, 0.5108, 0.7485, 0.5322]}, {"w": "useful", "b": [0.7537, 0.5108, 0.8037, 0.5322]}, {"w": "as", "b": [0.8089, 0.5108, 0.8257, 0.5322]}, {"w": "the", "b": [0.8308, 0.5108, 0.8571, 0.5322]}, {"w": "output", "b": [0.1428, 0.5298, 0.1992, 0.5512]}, {"w": "layer,", "b": [0.2049, 0.5298, 0.2485, 0.5512]}, {"w": "as", "b": [0.2542, 0.5298, 0.271, 0.5512]}, {"w": "we", "b": [0.2766, 0.5298, 0.2998, 0.5512]}, {"w": "will", "b": [0.3054, 0.5298, 0.3358, 0.5512]}, {"w": "see", "b": [0.3415, 0.5298, 0.3668, 0.5512]}, {"w": "later", "b": [0.3725, 0.5298, 0.4094, 0.5512]}, {"w": "in", "b": [0.4151, 0.5298, 0.4321, 0.5512]}, {"w": "this", "b": [0.4377, 0.5298, 0.4685, 0.5512]}, {"w": "chapter.", "b": [0.4741, 0.5298, 0.5401, 0.5512]}, {"w": "To", "b": [0.5458, 0.5298, 0.5672, 0.5512]}, {"w": "create", "b": [0.5729, 0.5298, 0.6222, 0.5512]}, {"w": "such", "b": [0.6279, 0.5298, 0.6665, 0.5512]}, {"w": "a", "b": [0.6722, 0.5298, 0.6813, 0.5512]}, {"w": "layer,", "b": [0.687, 0.5298, 0.7306, 0.5512]}, {"w": "simply", "b": [0.7363, 0.5298, 0.7919, 0.5512]}, {"w": "use", "b": [0.7976, 0.5298, 0.8251, 0.5512]}, {"w": "the", "b": [0.8308, 0.5298, 0.8571, 0.5512]}, {"w": "keras.layers.GlobalAvgPool2D", "b": [0.1429, 0.553, 0.4199, 0.568]}, {"w": "class:", "b": [0.4247, 0.5498, 0.4679, 0.5712]}]}, {"id": "b_5", "type": "equation", "text": "global_avg_pool = keras.layers.GlobalAvgPool2D()", "words": [{"w": "global_avg_pool", "b": [0.1766, 0.5818, 0.3031, 0.5946]}, {"w": "=", "b": [0.3115, 0.5818, 0.3199, 0.5946]}, {"w": "keras.layers.GlobalAvgPool2D()", "b": [0.3284, 0.5818, 0.5814, 0.5946]}]}, {"id": "b_6", "type": "paragraph", "text": "It is actually equivalent to this simple Lamba layer, which computes the mean over the spatial dimensions (height and width):", "words": [{"w": "It", "b": [0.1429, 0.6033, 0.1555, 0.6247]}, {"w": "is", "b": [0.1608, 0.6033, 0.174, 0.6247]}, {"w": "actually", "b": [0.1793, 0.6033, 0.2439, 0.6247]}, {"w": "equivalent", "b": [0.2492, 0.6033, 0.3356, 0.6247]}, {"w": "to", "b": [0.3409, 0.6033, 0.3578, 0.6247]}, {"w": "this", "b": [0.3631, 0.6033, 0.3938, 0.6247]}, {"w": "simple", "b": [0.3991, 0.6033, 0.454, 0.6247]}, {"w": "Lamba", "b": [0.4593, 0.6065, 0.5088, 0.6215]}, {"w": "layer,", "b": [0.5141, 0.6033, 0.5577, 0.6247]}, {"w": "which", "b": [0.5629, 0.6033, 0.6139, 0.6247]}, {"w": "computes", "b": [0.6191, 0.6033, 0.7001, 0.6247]}, {"w": "the", "b": [0.7053, 0.6033, 0.7317, 0.6247]}, {"w": "mean", "b": [0.737, 0.6033, 0.7834, 0.6247]}, {"w": "over", "b": [0.7887, 0.6033, 0.8255, 0.6247]}, {"w": "the", "b": [0.8308, 0.6033, 0.8571, 0.6247]}, {"w": "spatial", "b": [0.1429, 0.6223, 0.1965, 0.6437]}, {"w": "dimensions", "b": [0.2013, 0.6223, 0.2981, 0.6437]}, {"w": "(height", "b": [0.3028, 0.6223, 0.3624, 0.6437]}, {"w": "and", "b": [0.3671, 0.6223, 0.3987, 0.6437]}, {"w": "width):", "b": [0.4034, 0.6223, 0.4637, 0.6437]}]}, {"id": "b_7", "type": "equation", "text": "global_avg_pool = keras.layers.Lambda(lambda X: tf.reduce_mean(X, axis=[1, 2]))", "words": [{"w": "global_avg_pool", "b": [0.1766, 0.6543, 0.3031, 0.6672]}, {"w": "=", "b": [0.3115, 0.6543, 0.3199, 0.6672]}, {"w": "keras.layers.Lambda(lambda", "b": [0.3284, 0.6543, 0.5476, 0.6672]}, {"w": "X:", "b": [0.5561, 0.6543, 0.5729, 0.6672]}, {"w": "tf.reduce_mean(X,", "b": [0.5814, 0.6543, 0.7247, 0.6672]}, {"w": "axis=[1,", "b": [0.7331, 0.6543, 0.8006, 0.6672]}, {"w": "2]))", "b": [0.809, 0.6543, 0.8428, 0.6672]}]}, {"id": "b_8", "type": "paragraph", "text": "Now you know all the building blocks to create a convolutional neural network. Let’s see how to assemble them.", "words": [{"w": "Now", "b": [0.1429, 0.6749, 0.1827, 0.6964]}, {"w": "you", "b": [0.1883, 0.6749, 0.2195, 0.6964]}, {"w": "know", "b": [0.2251, 0.6749, 0.2717, 0.6964]}, {"w": "all", "b": [0.2773, 0.6749, 0.297, 0.6964]}, {"w": "the", "b": [0.3025, 0.6749, 0.3289, 0.6964]}, {"w": "building", "b": [0.3344, 0.6749, 0.4046, 0.6964]}, {"w": "blocks", "b": [0.4102, 0.6749, 0.4635, 0.6964]}, {"w": "to", "b": [0.469, 0.6749, 0.486, 0.6964]}, {"w": "create", "b": [0.4916, 0.6749, 0.5409, 0.6964]}, {"w": "a", "b": [0.5465, 0.6749, 0.5556, 0.6964]}, {"w": "convolutional", "b": [0.5612, 0.6749, 0.6765, 0.6964]}, {"w": "neural", "b": [0.6821, 0.6749, 0.7355, 0.6964]}, {"w": "network.", "b": [0.7411, 0.6749, 0.8154, 0.6964]}, {"w": "Let’s", "b": [0.821, 0.6749, 0.8571, 0.6964]}, {"w": "see", "b": [0.1429, 0.694, 0.1682, 0.7154]}, {"w": "how", "b": [0.1729, 0.694, 0.209, 0.7154]}, {"w": "to", "b": [0.2137, 0.694, 0.2307, 0.7154]}, {"w": "assemble", "b": [0.2354, 0.694, 0.3105, 0.7154]}, {"w": "them.", "b": [0.3152, 0.694, 0.3633, 0.7154]}]}, {"id": "b_9", "type": "paragraph", "text": "CNN Architectures", "words": [{"w": "CNN", "b": [0.1429, 0.7284, 0.1943, 0.7627]}, {"w": "Architectures", "b": [0.2003, 0.7284, 0.3638, 0.7627]}]}, {"id": "b_10", "type": "paragraph", "text": "Typical CNN architectures stack a few convolutional layers (each one generally fol‐ lowed by a ReLU layer), then a pooling layer, then another few convolutional layers (+ReLU), then another pooling layer, and so on. The image gets smaller and smaller as it progresses through the network, but it also typically gets deeper and deeper (i.e., with more feature maps) thanks to the convolutional layers (see Figure 14-11). At the top of the stack, a regular feedforward neural network is added, composed of a few", "words": [{"w": "Typical", "b": [0.1429, 0.7696, 0.2035, 0.791]}, {"w": "CNN", "b": [0.2103, 0.7696, 0.2552, 0.791]}, {"w": "architectures", "b": [0.262, 0.7696, 0.3701, 0.791]}, {"w": "stack", "b": [0.377, 0.7696, 0.4193, 0.791]}, {"w": "a", "b": [0.4261, 0.7696, 0.4353, 0.791]}, {"w": "few", "b": [0.4421, 0.7696, 0.4714, 0.791]}, {"w": "convolutional", "b": [0.4783, 0.7696, 0.5936, 0.791]}, {"w": "layers", "b": [0.6005, 0.7696, 0.6483, 0.791]}, {"w": "(each", "b": [0.6552, 0.7696, 0.7003, 0.791]}, {"w": "one", "b": [0.7072, 0.7696, 0.7381, 0.791]}, {"w": "generally", "b": [0.745, 0.7696, 0.8208, 0.791]}, {"w": "fol‐", "b": [0.8277, 0.7696, 0.8571, 0.791]}, {"w": "lowed", "b": [0.1429, 0.7886, 0.1929, 0.81]}, {"w": "by", "b": [0.1994, 0.7886, 0.2196, 0.81]}, {"w": "a", "b": [0.2262, 0.7886, 0.2353, 0.81]}, {"w": "ReLU", "b": [0.2419, 0.7886, 0.2894, 0.81]}, {"w": "layer),", "b": [0.2959, 0.7886, 0.3481, 0.81]}, {"w": "then", "b": [0.3546, 0.7886, 0.3923, 0.81]}, {"w": "a", "b": [0.3989, 0.7886, 0.408, 0.81]}, {"w": "pooling", "b": [0.4146, 0.7886, 0.4788, 0.81]}, {"w": "layer,", "b": [0.4853, 0.7886, 0.529, 0.81]}, {"w": "then", "b": [0.5355, 0.7886, 0.5732, 0.81]}, {"w": "another", "b": [0.5798, 0.7886, 0.645, 0.81]}, {"w": "few", "b": [0.6516, 0.7886, 0.6809, 0.81]}, {"w": "convolutional", "b": [0.6874, 0.7886, 0.8028, 0.81]}, {"w": "layers", "b": [0.8093, 0.7886, 0.8572, 0.81]}, {"w": "(+ReLU),", "b": [0.1429, 0.8077, 0.2216, 0.8291]}, {"w": "then", "b": [0.2277, 0.8077, 0.2654, 0.8291]}, {"w": "another", "b": [0.2715, 0.8077, 0.3367, 0.8291]}, {"w": "pooling", "b": [0.3428, 0.8077, 0.4069, 0.8291]}, {"w": "layer,", "b": [0.413, 0.8077, 0.4566, 0.8291]}, {"w": "and", "b": [0.4627, 0.8077, 0.4942, 0.8291]}, {"w": "so", "b": [0.5003, 0.8077, 0.5186, 0.8291]}, {"w": "on.", "b": [0.5246, 0.8077, 0.5514, 0.8291]}, {"w": "The", "b": [0.5575, 0.8077, 0.5903, 0.8291]}, {"w": "image", "b": [0.5964, 0.8077, 0.6468, 0.8291]}, {"w": "gets", "b": [0.6528, 0.8077, 0.6854, 0.8291]}, {"w": "smaller", "b": [0.6915, 0.8077, 0.7525, 0.8291]}, {"w": "and", "b": [0.7586, 0.8077, 0.7901, 0.8291]}, {"w": "smaller", "b": [0.7962, 0.8077, 0.8571, 0.8291]}, {"w": "as", "b": [0.1429, 0.8267, 0.1596, 0.8481]}, {"w": "it", "b": [0.1649, 0.8267, 0.1769, 0.8481]}, {"w": "progresses", "b": [0.1822, 0.8267, 0.2696, 0.8481]}, {"w": "through", "b": [0.2749, 0.8267, 0.3426, 0.8481]}, {"w": "the", "b": [0.3479, 0.8267, 0.3743, 0.8481]}, {"w": "network,", "b": [0.3796, 0.8267, 0.4539, 0.8481]}, {"w": "but", "b": [0.4592, 0.8267, 0.4872, 0.8481]}, {"w": "it", "b": [0.4925, 0.8267, 0.5044, 0.8481]}, {"w": "also", "b": [0.5097, 0.8267, 0.5424, 0.8481]}, {"w": "typically", "b": [0.5477, 0.8267, 0.6182, 0.8481]}, {"w": "gets", "b": [0.6235, 0.8267, 0.6561, 0.8481]}, {"w": "deeper", "b": [0.6614, 0.8267, 0.7176, 0.8481]}, {"w": "and", "b": [0.7229, 0.8267, 0.7544, 0.8481]}, {"w": "deeper", "b": [0.7597, 0.8267, 0.8159, 0.8481]}, {"w": "(i.e.,", "b": [0.8212, 0.8267, 0.8571, 0.8481]}, {"w": "with", "b": [0.1429, 0.8458, 0.1802, 0.8672]}, {"w": "more", "b": [0.1855, 0.8458, 0.2297, 0.8672]}, {"w": "feature", "b": [0.235, 0.8458, 0.2928, 0.8672]}, {"w": "maps)", "b": [0.2981, 0.8458, 0.3497, 0.8672]}, {"w": "thanks", "b": [0.3549, 0.8458, 0.4109, 0.8672]}, {"w": "to", "b": [0.4162, 0.8458, 0.4332, 0.8672]}, {"w": "the", "b": [0.4385, 0.8458, 0.4648, 0.8672]}, {"w": "convolutional", "b": [0.4701, 0.8458, 0.5854, 0.8672]}, {"w": "layers", "b": [0.5907, 0.8458, 0.6386, 0.8672]}, {"w": "(see", "b": [0.6438, 0.8458, 0.6764, 0.8672]}, {"w": "Figure", "b": [0.6817, 0.8458, 0.7357, 0.8672]}, {"w": "14-11).", "b": [0.7404, 0.8458, 0.8003, 0.8672]}, {"w": "At", "b": [0.8056, 0.8458, 0.8255, 0.8672]}, {"w": "the", "b": [0.8308, 0.8458, 0.8571, 0.8672]}, {"w": "top", "b": [0.1429, 0.8648, 0.1707, 0.8862]}, {"w": "of", "b": [0.1774, 0.8648, 0.1942, 0.8862]}, {"w": "the", "b": [0.2008, 0.8648, 0.2272, 0.8862]}, {"w": "stack,", "b": [0.2338, 0.8648, 0.2808, 0.8862]}, {"w": "a", "b": [0.2875, 0.8648, 0.2966, 0.8862]}, {"w": "regular", "b": [0.3033, 0.8648, 0.3628, 0.8862]}, {"w": "feedforward", "b": [0.3695, 0.8648, 0.4716, 0.8862]}, {"w": "neural", "b": [0.4783, 0.8648, 0.5317, 0.8862]}, {"w": "network", "b": [0.5384, 0.8648, 0.6079, 0.8862]}, {"w": "is", "b": [0.6146, 0.8648, 0.6278, 0.8862]}, {"w": "added,", "b": [0.6344, 0.8648, 0.6902, 0.8862]}, {"w": "composed", "b": [0.6968, 0.8648, 0.782, 0.8862]}, {"w": "of", "b": [0.7886, 0.8648, 0.8054, 0.8862]}, {"w": "a", "b": [0.8121, 0.8648, 0.8212, 0.8862]}, {"w": "few", "b": [0.8278, 0.8648, 0.8571, 0.8862]}]}, {"id": "b_11", "type": "paragraph", "text": "446 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "446", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 473, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "fully connected layers (+ReLUs), and the final layer outputs the prediction (e.g., a softmax layer that outputs estimated class probabilities).", "words": [{"w": "fully", "b": [0.1429, 0.0791, 0.1802, 0.1005]}, {"w": "connected", "b": [0.1882, 0.0791, 0.2743, 0.1005]}, {"w": "layers", "b": [0.2822, 0.0791, 0.3301, 0.1005]}, {"w": "(+ReLUs),", "b": [0.338, 0.0791, 0.4233, 0.1005]}, {"w": "and", "b": [0.4313, 0.0791, 0.4629, 0.1005]}, {"w": "the", "b": [0.4708, 0.0791, 0.4972, 0.1005]}, {"w": "final", "b": [0.5051, 0.0791, 0.5427, 0.1005]}, {"w": "layer", "b": [0.5507, 0.0791, 0.5909, 0.1005]}, {"w": "outputs", "b": [0.5988, 0.0791, 0.6629, 0.1005]}, {"w": "the", "b": [0.6708, 0.0791, 0.6972, 0.1005]}, {"w": "prediction", "b": [0.7051, 0.0791, 0.792, 0.1005]}, {"w": "(e.g.,", "b": [0.8, 0.0791, 0.84, 0.1005]}, {"w": "a", "b": [0.848, 0.0791, 0.8571, 0.1005]}, {"w": "softmax", "b": [0.1429, 0.0981, 0.2097, 0.1195]}, {"w": "layer", "b": [0.2144, 0.0981, 0.2546, 0.1195]}, {"w": "that", "b": [0.2593, 0.0981, 0.2919, 0.1195]}, {"w": "outputs", "b": [0.2966, 0.0981, 0.3607, 0.1195]}, {"w": "estimated", "b": [0.3654, 0.0981, 0.4459, 0.1195]}, {"w": "class", "b": [0.4506, 0.0981, 0.4891, 0.1195]}, {"w": "probabilities).", "b": [0.4938, 0.0981, 0.6102, 0.1195]}]}, {"id": "b_1", "type": "equation", "text": "Figure 14-11. Typical CNN architecture", "words": [{"w": "Figure", "b": [0.1429, 0.2735, 0.1943, 0.2951]}, {"w": "14-11.", "b": [0.1991, 0.2735, 0.2507, 0.2951]}, {"w": "Typical", "b": [0.2554, 0.2735, 0.3144, 0.2951]}, {"w": "CNN", "b": [0.3191, 0.2735, 0.3617, 0.2951]}, {"w": "architecture", "b": [0.3665, 0.2735, 0.4621, 0.2951]}]}, {"id": "b_2", "type": "paragraph", "text": "A common mistake is to use convolution kernels that are too large. For example, instead of using a convolutional layer with a 5 × 5 kernel, it is generally preferable to stack two layers with 3 × 3 ker‐ nels: it will use less parameters and require less computations, and it will usually perform better. One exception to this recommenda‐ tion is for the first convolutional layer: it can typically have a large kernel (e.g., 5 × 5), usually with stride of 2 or more: this will reduce the spatial dimension of the image without losing too much infor‐ mation, and since the input image only has 3 channels in general, it will not be too costly.", "words": [{"w": "A", "b": [0.2714, 0.3157, 0.2846, 0.3352]}, {"w": "common", "b": [0.2893, 0.3157, 0.3584, 0.3352]}, {"w": "mistake", "b": [0.3632, 0.3157, 0.4226, 0.3352]}, {"w": "is", "b": [0.4274, 0.3157, 0.4395, 0.3352]}, {"w": "to", "b": [0.4443, 0.3157, 0.4598, 0.3352]}, {"w": "use", "b": [0.4646, 0.3157, 0.4898, 0.3352]}, {"w": "convolution", "b": [0.4945, 0.3157, 0.5868, 0.3352]}, {"w": "kernels", "b": [0.5916, 0.3157, 0.6465, 0.3352]}, {"w": "that", "b": [0.6513, 0.3157, 0.681, 0.3352]}, {"w": "are", "b": [0.6858, 0.3157, 0.7093, 0.3352]}, {"w": "too", "b": [0.7141, 0.3157, 0.7393, 0.3352]}, {"w": "large.", "b": [0.7441, 0.3157, 0.7857, 0.3352]}, {"w": "For", "b": [0.2714, 0.3331, 0.2979, 0.3527]}, {"w": "example,", "b": [0.3051, 0.3331, 0.373, 0.3527]}, {"w": "instead", "b": [0.3801, 0.3331, 0.435, 0.3527]}, {"w": "of", "b": [0.4421, 0.3331, 0.4575, 0.3527]}, {"w": "using", "b": [0.4646, 0.3331, 0.5062, 0.3527]}, {"w": "a", "b": [0.5133, 0.3331, 0.5217, 0.3527]}, {"w": "convolutional", "b": [0.5288, 0.3331, 0.6343, 0.3527]}, {"w": "layer", "b": [0.6414, 0.3331, 0.6782, 0.3527]}, {"w": "with", "b": [0.6853, 0.3331, 0.7194, 0.3527]}, {"w": "a", "b": [0.7266, 0.3331, 0.7349, 0.3527]}, {"w": "5", "b": [0.7421, 0.3331, 0.7512, 0.3527]}, {"w": "×", "b": [0.7584, 0.3331, 0.7694, 0.3527]}, {"w": "5", "b": [0.7766, 0.3331, 0.7857, 0.3527]}, {"w": "kernel,", "b": [0.2714, 0.3505, 0.3237, 0.3701]}, {"w": "it", "b": [0.3292, 0.3505, 0.3401, 0.3701]}, {"w": "is", "b": [0.3456, 0.3505, 0.3577, 0.3701]}, {"w": "generally", "b": [0.3632, 0.3505, 0.4325, 0.3701]}, {"w": "preferable", "b": [0.438, 0.3505, 0.5149, 0.3701]}, {"w": "to", "b": [0.5204, 0.3505, 0.5359, 0.3701]}, {"w": "stack", "b": [0.5414, 0.3505, 0.5801, 0.3701]}, {"w": "two", "b": [0.5856, 0.3505, 0.6142, 0.3701]}, {"w": "layers", "b": [0.6197, 0.3505, 0.6634, 0.3701]}, {"w": "with", "b": [0.6689, 0.3505, 0.703, 0.3701]}, {"w": "3", "b": [0.7085, 0.3505, 0.7177, 0.3701]}, {"w": "×", "b": [0.7231, 0.3505, 0.7342, 0.3701]}, {"w": "3", "b": [0.7397, 0.3505, 0.7488, 0.3701]}, {"w": "ker‐", "b": [0.7543, 0.3505, 0.7857, 0.3701]}, {"w": "nels:", "b": [0.2714, 0.3679, 0.3061, 0.3875]}, {"w": "it", "b": [0.3115, 0.3679, 0.3224, 0.3875]}, {"w": "will", "b": [0.3278, 0.3679, 0.3556, 0.3875]}, {"w": "use", "b": [0.3611, 0.3679, 0.3863, 0.3875]}, {"w": "less", "b": [0.3917, 0.3679, 0.4186, 0.3875]}, {"w": "parameters", "b": [0.424, 0.3679, 0.5094, 0.3875]}, {"w": "and", "b": [0.5149, 0.3679, 0.5437, 0.3875]}, {"w": "require", "b": [0.5491, 0.3679, 0.6044, 0.3875]}, {"w": "less", "b": [0.6098, 0.3679, 0.6367, 0.3875]}, {"w": "computations,", "b": [0.6422, 0.3679, 0.7515, 0.3875]}, {"w": "and", "b": [0.7569, 0.3679, 0.7857, 0.3875]}, {"w": "it", "b": [0.2714, 0.3853, 0.2823, 0.4049]}, {"w": "will", "b": [0.2881, 0.3853, 0.3159, 0.4049]}, {"w": "usually", "b": [0.3217, 0.3853, 0.3757, 0.4049]}, {"w": "perform", "b": [0.3815, 0.3853, 0.4447, 0.4049]}, {"w": "better.", "b": [0.4505, 0.3853, 0.4982, 0.4049]}, {"w": "One", "b": [0.504, 0.3853, 0.5368, 0.4049]}, {"w": "exception", "b": [0.5426, 0.3853, 0.6168, 0.4049]}, {"w": "to", "b": [0.6226, 0.3853, 0.6382, 0.4049]}, {"w": "this", "b": [0.644, 0.3853, 0.6721, 0.4049]}, {"w": "recommenda‐", "b": [0.6779, 0.3853, 0.7857, 0.4049]}, {"w": "tion", "b": [0.2714, 0.4027, 0.3025, 0.4223]}, {"w": "is", "b": [0.3078, 0.4027, 0.3199, 0.4223]}, {"w": "for", "b": [0.3253, 0.4027, 0.3477, 0.4223]}, {"w": "the", "b": [0.353, 0.4027, 0.3771, 0.4223]}, {"w": "first", "b": [0.3824, 0.4027, 0.413, 0.4223]}, {"w": "convolutional", "b": [0.4184, 0.4027, 0.5238, 0.4223]}, {"w": "layer:", "b": [0.5292, 0.4027, 0.5707, 0.4223]}, {"w": "it", "b": [0.5761, 0.4027, 0.587, 0.4223]}, {"w": "can", "b": [0.5923, 0.4027, 0.6192, 0.4223]}, {"w": "typically", "b": [0.6245, 0.4027, 0.689, 0.4223]}, {"w": "have", "b": [0.6943, 0.4027, 0.7294, 0.4223]}, {"w": "a", "b": [0.7348, 0.4027, 0.7431, 0.4223]}, {"w": "large", "b": [0.7485, 0.4027, 0.7857, 0.4223]}, {"w": "kernel", "b": [0.2714, 0.4202, 0.3194, 0.4397]}, {"w": "(e.g.,", "b": [0.324, 0.4202, 0.3606, 0.4397]}, {"w": "5", "b": [0.3652, 0.4202, 0.3744, 0.4397]}, {"w": "×", "b": [0.379, 0.4202, 0.3901, 0.4397]}, {"w": "5),", "b": [0.3947, 0.4202, 0.4148, 0.4397]}, {"w": "usually", "b": [0.4194, 0.4202, 0.4734, 0.4397]}, {"w": "with", "b": [0.478, 0.4202, 0.5121, 0.4397]}, {"w": "stride", "b": [0.5167, 0.4202, 0.5599, 0.4397]}, {"w": "of", "b": [0.5645, 0.4202, 0.5799, 0.4397]}, {"w": "2", "b": [0.5845, 0.4202, 0.5936, 0.4397]}, {"w": "or", "b": [0.5983, 0.4202, 0.615, 0.4397]}, {"w": "more:", "b": [0.6197, 0.4202, 0.6645, 0.4397]}, {"w": "this", "b": [0.6691, 0.4202, 0.6972, 0.4397]}, {"w": "will", "b": [0.7018, 0.4202, 0.7296, 0.4397]}, {"w": "reduce", "b": [0.7342, 0.4202, 0.7857, 0.4397]}, {"w": "the", "b": [0.2714, 0.4376, 0.2955, 0.4571]}, {"w": "spatial", "b": [0.301, 0.4376, 0.35, 0.4571]}, {"w": "dimension", "b": [0.3555, 0.4376, 0.437, 0.4571]}, {"w": "of", "b": [0.4425, 0.4376, 0.4579, 0.4571]}, {"w": "the", "b": [0.4634, 0.4376, 0.4874, 0.4571]}, {"w": "image", "b": [0.4929, 0.4376, 0.539, 0.4571]}, {"w": "without", "b": [0.5445, 0.4376, 0.6043, 0.4571]}, {"w": "losing", "b": [0.6098, 0.4376, 0.6557, 0.4571]}, {"w": "too", "b": [0.6612, 0.4376, 0.6864, 0.4571]}, {"w": "much", "b": [0.6919, 0.4376, 0.7355, 0.4571]}, {"w": "infor‐", "b": [0.741, 0.4376, 0.7857, 0.4571]}, {"w": "mation,", "b": [0.2714, 0.455, 0.3304, 0.4746]}, {"w": "and", "b": [0.3349, 0.455, 0.3638, 0.4746]}, {"w": "since", "b": [0.3683, 0.455, 0.407, 0.4746]}, {"w": "the", "b": [0.4115, 0.455, 0.4356, 0.4746]}, {"w": "input", "b": [0.4401, 0.455, 0.4812, 0.4746]}, {"w": "image", "b": [0.4857, 0.455, 0.5318, 0.4746]}, {"w": "only", "b": [0.5363, 0.455, 0.57, 0.4746]}, {"w": "has", "b": [0.5745, 0.455, 0.6001, 0.4746]}, {"w": "3", "b": [0.6046, 0.455, 0.6137, 0.4746]}, {"w": "channels", "b": [0.6183, 0.455, 0.6856, 0.4746]}, {"w": "in", "b": [0.6901, 0.455, 0.7056, 0.4746]}, {"w": "general,", "b": [0.7102, 0.455, 0.7703, 0.4746]}, {"w": "it", "b": [0.7748, 0.455, 0.7857, 0.4746]}, {"w": "will", "b": [0.2714, 0.4724, 0.2992, 0.492]}, {"w": "not", "b": [0.3035, 0.4724, 0.3295, 0.492]}, {"w": "be", "b": [0.3338, 0.4724, 0.3516, 0.492]}, {"w": "too", "b": [0.3559, 0.4724, 0.3811, 0.492]}, {"w": "costly.", "b": [0.3854, 0.4724, 0.4325, 0.492]}]}, {"id": "b_3", "type": "paragraph", "text": "Here is how you can implement a simple CNN to tackle the fashion MNIST dataset (introduced in Chapter 10):", "words": [{"w": "Here", "b": [0.1429, 0.5123, 0.1837, 0.5337]}, {"w": "is", "b": [0.19, 0.5123, 0.2033, 0.5337]}, {"w": "how", "b": [0.2096, 0.5123, 0.2456, 0.5337]}, {"w": "you", "b": [0.2519, 0.5123, 0.2832, 0.5337]}, {"w": "can", "b": [0.2895, 0.5123, 0.3188, 0.5337]}, {"w": "implement", "b": [0.3251, 0.5123, 0.4157, 0.5337]}, {"w": "a", "b": [0.422, 0.5123, 0.4312, 0.5337]}, {"w": "simple", "b": [0.4375, 0.5123, 0.4924, 0.5337]}, {"w": "CNN", "b": [0.4987, 0.5123, 0.5435, 0.5337]}, {"w": "to", "b": [0.5498, 0.5123, 0.5668, 0.5337]}, {"w": "tackle", "b": [0.5731, 0.5123, 0.6219, 0.5337]}, {"w": "the", "b": [0.6282, 0.5123, 0.6545, 0.5337]}, {"w": "fashion", "b": [0.6609, 0.5123, 0.7225, 0.5337]}, {"w": "MNIST", "b": [0.7289, 0.5123, 0.7927, 0.5337]}, {"w": "dataset", "b": [0.799, 0.5123, 0.8571, 0.5337]}, {"w": "(introduced", "b": [0.1429, 0.5313, 0.2421, 0.5527]}, {"w": "in", "b": [0.2468, 0.5313, 0.2638, 0.5527]}, {"w": "Chapter", "b": [0.2685, 0.5313, 0.3361, 0.5527]}, {"w": "10):", "b": [0.3408, 0.5313, 0.3728, 0.5527]}]}, {"id": "b_4", "type": "paragraph", "text": "from functools import partial", "words": [{"w": "from", "b": [0.1766, 0.5633, 0.2103, 0.5761]}, {"w": "functools", "b": [0.2187, 0.5633, 0.2946, 0.5761]}, {"w": "import", "b": [0.3031, 0.5633, 0.3537, 0.5761]}, {"w": "partial", "b": [0.3621, 0.5633, 0.4211, 0.5761]}]}, {"id": "b_5", "type": "paragraph", "text": "DefaultConv2D = partial(keras.layers.Conv2D, kernel_size=3, activation='relu', padding=\"SAME\")", "words": [{"w": "DefaultConv2D", "b": [0.1766, 0.5941, 0.2862, 0.607]}, {"w": "=", "b": [0.2946, 0.5941, 0.3031, 0.607]}, {"w": "partial(keras.layers.Conv2D,", "b": [0.3115, 0.5941, 0.5476, 0.607]}, {"w": "kernel_size=3,", "b": [0.379, 0.6096, 0.497, 0.6224]}, {"w": "activation='relu',", "b": [0.5054, 0.6096, 0.6572, 0.6224]}, {"w": "padding=\"SAME\")", "b": [0.6657, 0.6096, 0.7922, 0.6224]}]}, {"id": "b_6", "type": "paragraph", "text": "model = keras.models.Sequential([ DefaultConv2D(filters=64, kernel_size=7, input_shape=[28, 28, 1]), keras.layers.MaxPooling2D(pool_size=2), DefaultConv2D(filters=128), DefaultConv2D(filters=128), keras.layers.MaxPooling2D(pool_size=2), DefaultConv2D(filters=256), DefaultConv2D(filters=256), keras.layers.MaxPooling2D(pool_size=2), keras.layers.Flatten(), keras.layers.Dense(units=128, activation='relu'), keras.layers.Dropout(0.5), keras.layers.Dense(units=64, activation='relu'), keras.layers.Dropout(0.5), keras.layers.Dense(units=10, activation='softmax'), ])", "words": [{"w": "model", "b": [0.1766, 0.6404, 0.2187, 0.6532]}, {"w": "=", "b": [0.2272, 0.6404, 0.2356, 0.6532]}, {"w": "keras.models.Sequential([", "b": [0.244, 0.6404, 0.4549, 0.6532]}, {"w": "DefaultConv2D(filters=64,", "b": [0.2103, 0.6558, 0.4211, 0.6687]}, {"w": "kernel_size=7,", "b": [0.4296, 0.6558, 0.5476, 0.6687]}, {"w": "input_shape=[28,", "b": [0.556, 0.6558, 0.691, 0.6687]}, {"w": "28,", "b": [0.6994, 0.6558, 0.7247, 0.6687]}, {"w": "1]),", "b": [0.7331, 0.6558, 0.7669, 0.6687]}, {"w": "keras.layers.MaxPooling2D(pool_size=2),", "b": [0.2103, 0.6712, 0.5392, 0.6841]}, {"w": "DefaultConv2D(filters=128),", "b": [0.2103, 0.6866, 0.438, 0.6995]}, {"w": "DefaultConv2D(filters=128),", "b": [0.2103, 0.7021, 0.438, 0.7149]}, {"w": "keras.layers.MaxPooling2D(pool_size=2),", "b": [0.2103, 0.7175, 0.5392, 0.7303]}, {"w": "DefaultConv2D(filters=256),", "b": [0.2103, 0.7329, 0.438, 0.7458]}, {"w": "DefaultConv2D(filters=256),", "b": [0.2103, 0.7483, 0.438, 0.7612]}, {"w": "keras.layers.MaxPooling2D(pool_size=2),", "b": [0.2103, 0.7637, 0.5392, 0.7766]}, {"w": "keras.layers.Flatten(),", "b": [0.2103, 0.7792, 0.4043, 0.792]}, {"w": "keras.layers.Dense(units=128,", "b": [0.2103, 0.7946, 0.4549, 0.8074]}, {"w": "activation='relu'),", "b": [0.4633, 0.7946, 0.6235, 0.8074]}, {"w": "keras.layers.Dropout(0.5),", "b": [0.2103, 0.81, 0.4296, 0.8229]}, {"w": "keras.layers.Dense(units=64,", "b": [0.2103, 0.8254, 0.4464, 0.8383]}, {"w": "activation='relu'),", "b": [0.4549, 0.8254, 0.6151, 0.8383]}, {"w": "keras.layers.Dropout(0.5),", "b": [0.2103, 0.8408, 0.4296, 0.8537]}, {"w": "keras.layers.Dense(units=10,", "b": [0.2103, 0.8563, 0.4464, 0.8691]}, {"w": "activation='softmax'),", "b": [0.4549, 0.8563, 0.6404, 0.8691]}, {"w": "])", "b": [0.1766, 0.8717, 0.1934, 0.8845]}]}, {"id": "b_7", "type": "paragraph", "text": "CNN Architectures | 447", "words": [{"w": "CNN", "b": [0.6907, 0.9225, 0.7152, 0.9388]}, {"w": "Architectures", "b": [0.7181, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "447", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 474, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• In this code, we start by using the partial() function to define a thin wrapper around the Conv2D class, called DefaultConv2D: it simply avoids having to repeat the same hyperparameter values over and over again.", "words": [{"w": "•", "b": [0.16, 0.086, 0.1682, 0.1074]}, {"w": "In", "b": [0.1786, 0.086, 0.1971, 0.1074]}, {"w": "this", "b": [0.2036, 0.086, 0.2343, 0.1074]}, {"w": "code,", "b": [0.2408, 0.086, 0.2848, 0.1074]}, {"w": "we", "b": [0.2913, 0.086, 0.3144, 0.1074]}, {"w": "start", "b": [0.3209, 0.086, 0.3582, 0.1074]}, {"w": "by", "b": [0.3647, 0.086, 0.3848, 0.1074]}, {"w": "using", "b": [0.3913, 0.086, 0.4367, 0.1074]}, {"w": "the", "b": [0.4432, 0.086, 0.4696, 0.1074]}, {"w": "partial()", "b": [0.4761, 0.0892, 0.5651, 0.1043]}, {"w": "function", "b": [0.5716, 0.086, 0.643, 0.1074]}, {"w": "to", "b": [0.6495, 0.086, 0.6665, 0.1074]}, {"w": "define", "b": [0.673, 0.086, 0.7249, 0.1074]}, {"w": "a", "b": [0.7314, 0.086, 0.7405, 0.1074]}, {"w": "thin", "b": [0.747, 0.086, 0.7815, 0.1074]}, {"w": "wrapper", "b": [0.788, 0.086, 0.8571, 0.1074]}, {"w": "around", "b": [0.1786, 0.1059, 0.2395, 0.1274]}, {"w": "the", "b": [0.2451, 0.1059, 0.2714, 0.1274]}, {"w": "Conv2D", "b": [0.277, 0.1091, 0.3364, 0.1242]}, {"w": "class,", "b": [0.342, 0.1059, 0.3852, 0.1274]}, {"w": "called", "b": [0.3908, 0.1059, 0.4392, 0.1274]}, {"w": "DefaultConv2D:", "b": [0.4447, 0.1059, 0.5781, 0.1274]}, {"w": "it", "b": [0.5837, 0.1059, 0.5956, 0.1274]}, {"w": "simply", "b": [0.6012, 0.1059, 0.6569, 0.1274]}, {"w": "avoids", "b": [0.6624, 0.1059, 0.7157, 0.1274]}, {"w": "having", "b": [0.7213, 0.1059, 0.7776, 0.1274]}, {"w": "to", "b": [0.7831, 0.1059, 0.8001, 0.1274]}, {"w": "repeat", "b": [0.8057, 0.1059, 0.8571, 0.1274]}, {"w": "the", "b": [0.1786, 0.125, 0.2049, 0.1464]}, {"w": "same", "b": [0.2096, 0.125, 0.2523, 0.1464]}, {"w": "hyperparameter", "b": [0.2571, 0.125, 0.3906, 0.1464]}, {"w": "values", "b": [0.3953, 0.125, 0.4469, 0.1464]}, {"w": "over", "b": [0.4516, 0.125, 0.4885, 0.1464]}, {"w": "and", "b": [0.4932, 0.125, 0.5248, 0.1464]}, {"w": "over", "b": [0.5295, 0.125, 0.5664, 0.1464]}, {"w": "again.", "b": [0.5711, 0.125, 0.6209, 0.1464]}]}, {"id": "b_1", "type": "paragraph", "text": "• The first layer uses a large kernel size, but no stride because the input images are not very large. It also sets input_shape=[28, 28, 1], which means the images are 28 × 28 pixels, with a single color channel (i.e., grayscale).", "words": [{"w": "•", "b": [0.16, 0.1501, 0.1682, 0.1715]}, {"w": "The", "b": [0.1786, 0.1501, 0.2114, 0.1715]}, {"w": "first", "b": [0.2169, 0.1501, 0.2504, 0.1715]}, {"w": "layer", "b": [0.2558, 0.1501, 0.296, 0.1715]}, {"w": "uses", "b": [0.3015, 0.1501, 0.3367, 0.1715]}, {"w": "a", "b": [0.3422, 0.1501, 0.3513, 0.1715]}, {"w": "large", "b": [0.3568, 0.1501, 0.3976, 0.1715]}, {"w": "kernel", "b": [0.403, 0.1501, 0.4555, 0.1715]}, {"w": "size,", "b": [0.461, 0.1501, 0.4965, 0.1715]}, {"w": "but", "b": [0.502, 0.1501, 0.53, 0.1715]}, {"w": "no", "b": [0.5355, 0.1501, 0.5575, 0.1715]}, {"w": "stride", "b": [0.563, 0.1501, 0.6102, 0.1715]}, {"w": "because", "b": [0.6156, 0.1501, 0.6802, 0.1715]}, {"w": "the", "b": [0.6857, 0.1501, 0.712, 0.1715]}, {"w": "input", "b": [0.7175, 0.1501, 0.7624, 0.1715]}, {"w": "images", "b": [0.7679, 0.1501, 0.8259, 0.1715]}, {"w": "are", "b": [0.8314, 0.1501, 0.8571, 0.1715]}, {"w": "not", "b": [0.1786, 0.17, 0.2069, 0.1914]}, {"w": "very", "b": [0.2136, 0.17, 0.25, 0.1914]}, {"w": "large.", "b": [0.2567, 0.17, 0.3022, 0.1914]}, {"w": "It", "b": [0.3089, 0.17, 0.3216, 0.1914]}, {"w": "also", "b": [0.3283, 0.17, 0.361, 0.1914]}, {"w": "sets", "b": [0.3677, 0.17, 0.3982, 0.1914]}, {"w": "input_shape=[28,", "b": [0.4049, 0.1732, 0.5632, 0.1883]}, {"w": "28,", "b": [0.575, 0.1732, 0.6047, 0.1883]}, {"w": "1],", "b": [0.6164, 0.17, 0.641, 0.1914]}, {"w": "which", "b": [0.6477, 0.17, 0.6986, 0.1914]}, {"w": "means", "b": [0.7053, 0.17, 0.7594, 0.1914]}, {"w": "the", "b": [0.7661, 0.17, 0.7924, 0.1914]}, {"w": "images", "b": [0.7991, 0.17, 0.8571, 0.1914]}, {"w": "are", "b": [0.1786, 0.1891, 0.2043, 0.2105]}, {"w": "28", "b": [0.209, 0.1891, 0.229, 0.2105]}, {"w": "×", "b": [0.2338, 0.1891, 0.2458, 0.2105]}, {"w": "28", "b": [0.2506, 0.1891, 0.2706, 0.2105]}, {"w": "pixels,", "b": [0.2753, 0.1891, 0.3281, 0.2105]}, {"w": "with", "b": [0.3329, 0.1891, 0.3702, 0.2105]}, {"w": "a", "b": [0.3749, 0.1891, 0.3841, 0.2105]}, {"w": "single", "b": [0.3888, 0.1891, 0.4373, 0.2105]}, {"w": "color", "b": [0.442, 0.1891, 0.4851, 0.2105]}, {"w": "channel", "b": [0.4898, 0.1891, 0.5558, 0.2105]}, {"w": "(i.e.,", "b": [0.5606, 0.1891, 0.5965, 0.2105]}, {"w": "grayscale).", "b": [0.6012, 0.1891, 0.6887, 0.2105]}]}, {"id": "b_2", "type": "paragraph", "text": "• Next, we have a max pooling layer, which divides each spatial dimension by a fac‐ tor of two (since pool_size=2).", "words": [{"w": "•", "b": [0.16, 0.2142, 0.1682, 0.2356]}, {"w": "Next,", "b": [0.1786, 0.2142, 0.2233, 0.2356]}, {"w": "we", "b": [0.2281, 0.2142, 0.2513, 0.2356]}, {"w": "have", "b": [0.2561, 0.2142, 0.2945, 0.2356]}, {"w": "a", "b": [0.2993, 0.2142, 0.3084, 0.2356]}, {"w": "max", "b": [0.3133, 0.2142, 0.3493, 0.2356]}, {"w": "pooling", "b": [0.3541, 0.2142, 0.4183, 0.2356]}, {"w": "layer,", "b": [0.4231, 0.2142, 0.4667, 0.2356]}, {"w": "which", "b": [0.4716, 0.2142, 0.5225, 0.2356]}, {"w": "divides", "b": [0.5273, 0.2142, 0.5866, 0.2356]}, {"w": "each", "b": [0.5914, 0.2142, 0.6294, 0.2356]}, {"w": "spatial", "b": [0.6342, 0.2142, 0.6879, 0.2356]}, {"w": "dimension", "b": [0.6927, 0.2142, 0.7818, 0.2356]}, {"w": "by", "b": [0.7867, 0.2142, 0.8068, 0.2356]}, {"w": "a", "b": [0.8116, 0.2142, 0.8208, 0.2356]}, {"w": "fac‐", "b": [0.8256, 0.2142, 0.8571, 0.2356]}, {"w": "tor", "b": [0.1786, 0.2341, 0.2033, 0.2555]}, {"w": "of", "b": [0.208, 0.2341, 0.2248, 0.2555]}, {"w": "two", "b": [0.2295, 0.2341, 0.2608, 0.2555]}, {"w": "(since", "b": [0.2655, 0.2341, 0.315, 0.2555]}, {"w": "pool_size=2).", "b": [0.3197, 0.2341, 0.4406, 0.2555]}]}, {"id": "b_3", "type": "paragraph", "text": "• Then we repeat the same structure twice: two convolutional layers followed by a max pooling layer. For larger images, we could repeat this structure several times (the number of repetitions is a hyperparameter you can tune).", "words": [{"w": "•", "b": [0.16, 0.2592, 0.1682, 0.2806]}, {"w": "Then", "b": [0.1786, 0.2592, 0.2228, 0.2806]}, {"w": "we", "b": [0.2287, 0.2592, 0.2518, 0.2806]}, {"w": "repeat", "b": [0.2577, 0.2592, 0.3092, 0.2806]}, {"w": "the", "b": [0.3151, 0.2592, 0.3414, 0.2806]}, {"w": "same", "b": [0.3473, 0.2592, 0.39, 0.2806]}, {"w": "structure", "b": [0.3959, 0.2592, 0.4715, 0.2806]}, {"w": "twice:", "b": [0.4774, 0.2592, 0.526, 0.2806]}, {"w": "two", "b": [0.5319, 0.2592, 0.5631, 0.2806]}, {"w": "convolutional", "b": [0.569, 0.2592, 0.6844, 0.2806]}, {"w": "layers", "b": [0.6903, 0.2592, 0.7381, 0.2806]}, {"w": "followed", "b": [0.744, 0.2592, 0.8161, 0.2806]}, {"w": "by", "b": [0.822, 0.2592, 0.8421, 0.2806]}, {"w": "a", "b": [0.848, 0.2592, 0.8571, 0.2806]}, {"w": "max", "b": [0.1786, 0.2783, 0.2146, 0.2997]}, {"w": "pooling", "b": [0.22, 0.2783, 0.2841, 0.2997]}, {"w": "layer.", "b": [0.2895, 0.2783, 0.3331, 0.2997]}, {"w": "For", "b": [0.3385, 0.2783, 0.3674, 0.2997]}, {"w": "larger", "b": [0.3728, 0.2783, 0.4213, 0.2997]}, {"w": "images,", "b": [0.4266, 0.2783, 0.4894, 0.2997]}, {"w": "we", "b": [0.4947, 0.2783, 0.5179, 0.2997]}, {"w": "could", "b": [0.5232, 0.2783, 0.57, 0.2997]}, {"w": "repeat", "b": [0.5753, 0.2783, 0.6268, 0.2997]}, {"w": "this", "b": [0.6321, 0.2783, 0.6629, 0.2997]}, {"w": "structure", "b": [0.6682, 0.2783, 0.7438, 0.2997]}, {"w": "several", "b": [0.7492, 0.2783, 0.8063, 0.2997]}, {"w": "times", "b": [0.8116, 0.2783, 0.8571, 0.2997]}, {"w": "(the", "b": [0.1786, 0.2973, 0.2121, 0.3187]}, {"w": "number", "b": [0.2168, 0.2973, 0.2831, 0.3187]}, {"w": "of", "b": [0.2879, 0.2973, 0.3046, 0.3187]}, {"w": "repetitions", "b": [0.3094, 0.2973, 0.3993, 0.3187]}, {"w": "is", "b": [0.404, 0.2973, 0.4172, 0.3187]}, {"w": "a", "b": [0.422, 0.2973, 0.4311, 0.3187]}, {"w": "hyperparameter", "b": [0.4358, 0.2973, 0.5693, 0.3187]}, {"w": "you", "b": [0.5741, 0.2973, 0.6053, 0.3187]}, {"w": "can", "b": [0.61, 0.2973, 0.6394, 0.3187]}, {"w": "tune).", "b": [0.6441, 0.2973, 0.6937, 0.3187]}]}, {"id": "b_4", "type": "paragraph", "text": "• Note that the number of filters grows as we climb up the CNN towards the out‐ put layer (it is initially 64, then 128, then 256): it makes sense for it to grow, since the number of low level features is often fairly low (e.g., small circles, horizontal lines, etc.), but there are many different ways to combine them into higher level features. It is a common practice to double the number of filters after each pool‐ ing layer: since a pooling layer divides each spatial dimension by a factor of 2, we can afford doubling the number of feature maps in the next layer, without fear of exploding the number of parameters, memory usage, or computational load.", "words": [{"w": "•", "b": [0.16, 0.3224, 0.1682, 0.3438]}, {"w": "Note", "b": [0.1786, 0.3224, 0.2194, 0.3438]}, {"w": "that", "b": [0.2253, 0.3224, 0.2579, 0.3438]}, {"w": "the", "b": [0.2638, 0.3224, 0.2902, 0.3438]}, {"w": "number", "b": [0.2961, 0.3224, 0.3624, 0.3438]}, {"w": "of", "b": [0.3684, 0.3224, 0.3852, 0.3438]}, {"w": "filters", "b": [0.3911, 0.3224, 0.4387, 0.3438]}, {"w": "grows", "b": [0.4447, 0.3224, 0.4947, 0.3438]}, {"w": "as", "b": [0.5006, 0.3224, 0.5174, 0.3438]}, {"w": "we", "b": [0.5234, 0.3224, 0.5465, 0.3438]}, {"w": "climb", "b": [0.5524, 0.3224, 0.5998, 0.3438]}, {"w": "up", "b": [0.6057, 0.3224, 0.6277, 0.3438]}, {"w": "the", "b": [0.6336, 0.3224, 0.66, 0.3438]}, {"w": "CNN", "b": [0.6659, 0.3224, 0.7107, 0.3438]}, {"w": "towards", "b": [0.7167, 0.3224, 0.7834, 0.3438]}, {"w": "the", "b": [0.7894, 0.3224, 0.8157, 0.3438]}, {"w": "out‐", "b": [0.8217, 0.3224, 0.8571, 0.3438]}, {"w": "put", "b": [0.1786, 0.3415, 0.2069, 0.3629]}, {"w": "layer", "b": [0.212, 0.3415, 0.2522, 0.3629]}, {"w": "(it", "b": [0.2572, 0.3415, 0.2764, 0.3629]}, {"w": "is", "b": [0.2815, 0.3415, 0.2947, 0.3629]}, {"w": "initially", "b": [0.2998, 0.3415, 0.3635, 0.3629]}, {"w": "64,", "b": [0.3686, 0.3415, 0.3934, 0.3629]}, {"w": "then", "b": [0.3984, 0.3415, 0.4362, 0.3629]}, {"w": "128,", "b": [0.4412, 0.3415, 0.476, 0.3629]}, {"w": "then", "b": [0.4811, 0.3415, 0.5188, 0.3629]}, {"w": "256):", "b": [0.5239, 0.3415, 0.5658, 0.3629]}, {"w": "it", "b": [0.5709, 0.3415, 0.5828, 0.3629]}, {"w": "makes", "b": [0.5879, 0.3415, 0.641, 0.3629]}, {"w": "sense", "b": [0.646, 0.3415, 0.6904, 0.3629]}, {"w": "for", "b": [0.6955, 0.3415, 0.72, 0.3629]}, {"w": "it", "b": [0.7251, 0.3415, 0.737, 0.3629]}, {"w": "to", "b": [0.7421, 0.3415, 0.7591, 0.3629]}, {"w": "grow,", "b": [0.7642, 0.3415, 0.8098, 0.3629]}, {"w": "since", "b": [0.8149, 0.3415, 0.8571, 0.3629]}, {"w": "the", "b": [0.1786, 0.3605, 0.2049, 0.3819]}, {"w": "number", "b": [0.2108, 0.3605, 0.2771, 0.3819]}, {"w": "of", "b": [0.2831, 0.3605, 0.2999, 0.3819]}, {"w": "low", "b": [0.3058, 0.3605, 0.336, 0.3819]}, {"w": "level", "b": [0.3419, 0.3605, 0.3798, 0.3819]}, {"w": "features", "b": [0.3858, 0.3605, 0.4512, 0.3819]}, {"w": "is", "b": [0.4571, 0.3605, 0.4704, 0.3819]}, {"w": "often", "b": [0.4763, 0.3605, 0.5197, 0.3819]}, {"w": "fairly", "b": [0.5257, 0.3605, 0.5691, 0.3819]}, {"w": "low", "b": [0.5751, 0.3605, 0.6052, 0.3819]}, {"w": "(e.g.,", "b": [0.6112, 0.3605, 0.6512, 0.3819]}, {"w": "small", "b": [0.6572, 0.3605, 0.7016, 0.3819]}, {"w": "circles,", "b": [0.7075, 0.3605, 0.765, 0.3819]}, {"w": "horizontal", "b": [0.7709, 0.3605, 0.8571, 0.3819]}, {"w": "lines,", "b": [0.1786, 0.3796, 0.2221, 0.401]}, {"w": "etc.),", "b": [0.2282, 0.3796, 0.269, 0.401]}, {"w": "but", "b": [0.2751, 0.3796, 0.3031, 0.401]}, {"w": "there", "b": [0.3093, 0.3796, 0.3522, 0.401]}, {"w": "are", "b": [0.3584, 0.3796, 0.3841, 0.401]}, {"w": "many", "b": [0.3903, 0.3796, 0.437, 0.401]}, {"w": "different", "b": [0.4431, 0.3796, 0.5148, 0.401]}, {"w": "ways", "b": [0.521, 0.3796, 0.5612, 0.401]}, {"w": "to", "b": [0.5674, 0.3796, 0.5844, 0.401]}, {"w": "combine", "b": [0.5905, 0.3796, 0.6635, 0.401]}, {"w": "them", "b": [0.6696, 0.3796, 0.713, 0.401]}, {"w": "into", "b": [0.7192, 0.3796, 0.7528, 0.401]}, {"w": "higher", "b": [0.7589, 0.3796, 0.8131, 0.401]}, {"w": "level", "b": [0.8192, 0.3796, 0.8571, 0.401]}, {"w": "features.", "b": [0.1786, 0.3986, 0.2487, 0.42]}, {"w": "It", "b": [0.2544, 0.3986, 0.267, 0.42]}, {"w": "is", "b": [0.2727, 0.3986, 0.2859, 0.42]}, {"w": "a", "b": [0.2916, 0.3986, 0.3007, 0.42]}, {"w": "common", "b": [0.3064, 0.3986, 0.382, 0.42]}, {"w": "practice", "b": [0.3876, 0.3986, 0.4538, 0.42]}, {"w": "to", "b": [0.4595, 0.3986, 0.4765, 0.42]}, {"w": "double", "b": [0.4821, 0.3986, 0.5395, 0.42]}, {"w": "the", "b": [0.5452, 0.3986, 0.5715, 0.42]}, {"w": "number", "b": [0.5772, 0.3986, 0.6434, 0.42]}, {"w": "of", "b": [0.6491, 0.3986, 0.6659, 0.42]}, {"w": "filters", "b": [0.6715, 0.3986, 0.7191, 0.42]}, {"w": "after", "b": [0.7248, 0.3986, 0.7631, 0.42]}, {"w": "each", "b": [0.7687, 0.3986, 0.8066, 0.42]}, {"w": "pool‐", "b": [0.8123, 0.3986, 0.8572, 0.42]}, {"w": "ing", "b": [0.1786, 0.4176, 0.2053, 0.4391]}, {"w": "layer:", "b": [0.2105, 0.4176, 0.2559, 0.4391]}, {"w": "since", "b": [0.2611, 0.4176, 0.3034, 0.4391]}, {"w": "a", "b": [0.3086, 0.4176, 0.3177, 0.4391]}, {"w": "pooling", "b": [0.3229, 0.4176, 0.3871, 0.4391]}, {"w": "layer", "b": [0.3923, 0.4176, 0.4324, 0.4391]}, {"w": "divides", "b": [0.4376, 0.4176, 0.4969, 0.4391]}, {"w": "each", "b": [0.5021, 0.4176, 0.5401, 0.4391]}, {"w": "spatial", "b": [0.5452, 0.4176, 0.5989, 0.4391]}, {"w": "dimension", "b": [0.6041, 0.4176, 0.6932, 0.4391]}, {"w": "by", "b": [0.6984, 0.4176, 0.7186, 0.4391]}, {"w": "a", "b": [0.7238, 0.4176, 0.7329, 0.4391]}, {"w": "factor", "b": [0.7381, 0.4176, 0.7869, 0.4391]}, {"w": "of", "b": [0.7921, 0.4176, 0.8089, 0.4391]}, {"w": "2,", "b": [0.8141, 0.4176, 0.8288, 0.4391]}, {"w": "we", "b": [0.834, 0.4176, 0.8571, 0.4391]}, {"w": "can", "b": [0.1786, 0.4367, 0.2079, 0.4581]}, {"w": "afford", "b": [0.2132, 0.4367, 0.2641, 0.4581]}, {"w": "doubling", "b": [0.2694, 0.4367, 0.3446, 0.4581]}, {"w": "the", "b": [0.3499, 0.4367, 0.3763, 0.4581]}, {"w": "number", "b": [0.3815, 0.4367, 0.4478, 0.4581]}, {"w": "of", "b": [0.4531, 0.4367, 0.4699, 0.4581]}, {"w": "feature", "b": [0.4752, 0.4367, 0.533, 0.4581]}, {"w": "maps", "b": [0.5383, 0.4367, 0.5827, 0.4581]}, {"w": "in", "b": [0.5879, 0.4367, 0.6049, 0.4581]}, {"w": "the", "b": [0.6102, 0.4367, 0.6366, 0.4581]}, {"w": "next", "b": [0.6418, 0.4367, 0.6783, 0.4581]}, {"w": "layer,", "b": [0.6836, 0.4367, 0.7272, 0.4581]}, {"w": "without", "b": [0.7325, 0.4367, 0.7979, 0.4581]}, {"w": "fear", "b": [0.8032, 0.4367, 0.8351, 0.4581]}, {"w": "of", "b": [0.8404, 0.4367, 0.8571, 0.4581]}, {"w": "exploding", "b": [0.1786, 0.4557, 0.2618, 0.4772]}, {"w": "the", "b": [0.2665, 0.4557, 0.2929, 0.4772]}, {"w": "number", "b": [0.2976, 0.4557, 0.3639, 0.4772]}, {"w": "of", "b": [0.3686, 0.4557, 0.3854, 0.4772]}, {"w": "parameters,", "b": [0.3901, 0.4557, 0.4883, 0.4772]}, {"w": "memory", "b": [0.493, 0.4557, 0.5645, 0.4772]}, {"w": "usage,", "b": [0.5693, 0.4557, 0.6205, 0.4772]}, {"w": "or", "b": [0.6252, 0.4557, 0.6436, 0.4772]}, {"w": "computational", "b": [0.6483, 0.4557, 0.7699, 0.4772]}, {"w": "load.", "b": [0.7746, 0.4557, 0.8154, 0.4772]}]}, {"id": "b_5", "type": "paragraph", "text": "• Next is the fully connected network, composed of 2 hidden dense layers and a dense output layer. Note that we must flatten its inputs, since a dense network expects a 1D array of features for each instance. We also add two dropout layers, with a dropout rate of 50% each, to reduce overfitting.", "words": [{"w": "•", "b": [0.16, 0.4808, 0.1682, 0.5022]}, {"w": "Next", "b": [0.1786, 0.4808, 0.2186, 0.5022]}, {"w": "is", "b": [0.2258, 0.4808, 0.239, 0.5022]}, {"w": "the", "b": [0.2463, 0.4808, 0.2726, 0.5022]}, {"w": "fully", "b": [0.2798, 0.4808, 0.3172, 0.5022]}, {"w": "connected", "b": [0.3244, 0.4808, 0.4105, 0.5022]}, {"w": "network,", "b": [0.4178, 0.4808, 0.4921, 0.5022]}, {"w": "composed", "b": [0.4993, 0.4808, 0.5845, 0.5022]}, {"w": "of", "b": [0.5917, 0.4808, 0.6085, 0.5022]}, {"w": "2", "b": [0.6157, 0.4808, 0.6257, 0.5022]}, {"w": "hidden", "b": [0.633, 0.4808, 0.6919, 0.5022]}, {"w": "dense", "b": [0.6992, 0.4808, 0.7469, 0.5022]}, {"w": "layers", "b": [0.7541, 0.4808, 0.802, 0.5022]}, {"w": "and", "b": [0.8092, 0.4808, 0.8408, 0.5022]}, {"w": "a", "b": [0.848, 0.4808, 0.8571, 0.5022]}, {"w": "dense", "b": [0.1786, 0.4999, 0.2263, 0.5213]}, {"w": "output", "b": [0.2335, 0.4999, 0.2899, 0.5213]}, {"w": "layer.", "b": [0.2971, 0.4999, 0.3408, 0.5213]}, {"w": "Note", "b": [0.348, 0.4999, 0.3888, 0.5213]}, {"w": "that", "b": [0.396, 0.4999, 0.4286, 0.5213]}, {"w": "we", "b": [0.4358, 0.4999, 0.4589, 0.5213]}, {"w": "must", "b": [0.4661, 0.4999, 0.5078, 0.5213]}, {"w": "flatten", "b": [0.5151, 0.4999, 0.5682, 0.5213]}, {"w": "its", "b": [0.5754, 0.4999, 0.595, 0.5213]}, {"w": "inputs,", "b": [0.6022, 0.4999, 0.6595, 0.5213]}, {"w": "since", "b": [0.6667, 0.4999, 0.709, 0.5213]}, {"w": "a", "b": [0.7163, 0.4999, 0.7254, 0.5213]}, {"w": "dense", "b": [0.7326, 0.4999, 0.7804, 0.5213]}, {"w": "network", "b": [0.7876, 0.4999, 0.8571, 0.5213]}, {"w": "expects", "b": [0.1786, 0.5189, 0.2398, 0.5403]}, {"w": "a", "b": [0.2454, 0.5189, 0.2546, 0.5403]}, {"w": "1D", "b": [0.2602, 0.5189, 0.2855, 0.5403]}, {"w": "array", "b": [0.2911, 0.5189, 0.334, 0.5403]}, {"w": "of", "b": [0.3396, 0.5189, 0.3564, 0.5403]}, {"w": "features", "b": [0.362, 0.5189, 0.4274, 0.5403]}, {"w": "for", "b": [0.433, 0.5189, 0.4575, 0.5403]}, {"w": "each", "b": [0.4631, 0.5189, 0.501, 0.5403]}, {"w": "instance.", "b": [0.5066, 0.5189, 0.5806, 0.5403]}, {"w": "We", "b": [0.5861, 0.5189, 0.6132, 0.5403]}, {"w": "also", "b": [0.6188, 0.5189, 0.6515, 0.5403]}, {"w": "add", "b": [0.6571, 0.5189, 0.6882, 0.5403]}, {"w": "two", "b": [0.6938, 0.5189, 0.7251, 0.5403]}, {"w": "dropout", "b": [0.7306, 0.5189, 0.799, 0.5403]}, {"w": "layers,", "b": [0.8046, 0.5189, 0.8571, 0.5403]}, {"w": "with", "b": [0.1786, 0.538, 0.2159, 0.5594]}, {"w": "a", "b": [0.2206, 0.538, 0.2298, 0.5594]}, {"w": "dropout", "b": [0.2345, 0.538, 0.3028, 0.5594]}, {"w": "rate", "b": [0.3076, 0.538, 0.3392, 0.5594]}, {"w": "of", "b": [0.344, 0.538, 0.3608, 0.5594]}, {"w": "50%", "b": [0.3655, 0.538, 0.4012, 0.5594]}, {"w": "each,", "b": [0.406, 0.538, 0.4487, 0.5594]}, {"w": "to", "b": [0.4534, 0.538, 0.4704, 0.5594]}, {"w": "reduce", "b": [0.4751, 0.538, 0.5314, 0.5594]}, {"w": "overfitting.", "b": [0.5361, 0.538, 0.6289, 0.5594]}]}, {"id": "b_6", "type": "paragraph", "text": "This CNN reaches over 92% accuracy on the test set. It’s not the state of the art, but it is pretty good, and clearly much better than what we achieved with dense networks in Chapter 10.", "words": [{"w": "This", "b": [0.1429, 0.5721, 0.1801, 0.5936]}, {"w": "CNN", "b": [0.1852, 0.5721, 0.2301, 0.5936]}, {"w": "reaches", "b": [0.2352, 0.5721, 0.2974, 0.5936]}, {"w": "over", "b": [0.3026, 0.5721, 0.3394, 0.5936]}, {"w": "92%", "b": [0.3446, 0.5721, 0.3804, 0.5936]}, {"w": "accuracy", "b": [0.3855, 0.5721, 0.4586, 0.5936]}, {"w": "on", "b": [0.4638, 0.5721, 0.4858, 0.5936]}, {"w": "the", "b": [0.491, 0.5721, 0.5173, 0.5936]}, {"w": "test", "b": [0.5225, 0.5721, 0.5517, 0.5936]}, {"w": "set.", "b": [0.5569, 0.5721, 0.5845, 0.5936]}, {"w": "It’s", "b": [0.5896, 0.5721, 0.612, 0.5936]}, {"w": "not", "b": [0.6172, 0.5721, 0.6456, 0.5936]}, {"w": "the", "b": [0.6508, 0.5721, 0.6771, 0.5936]}, {"w": "state", "b": [0.6823, 0.5721, 0.7202, 0.5936]}, {"w": "of", "b": [0.7254, 0.5721, 0.7422, 0.5936]}, {"w": "the", "b": [0.7474, 0.5721, 0.7737, 0.5936]}, {"w": "art,", "b": [0.7789, 0.5721, 0.8069, 0.5936]}, {"w": "but", "b": [0.812, 0.5721, 0.84, 0.5936]}, {"w": "it", "b": [0.8452, 0.5721, 0.8571, 0.5936]}, {"w": "is", "b": [0.1429, 0.5912, 0.1561, 0.6126]}, {"w": "pretty", "b": [0.1609, 0.5912, 0.2107, 0.6126]}, {"w": "good,", "b": [0.2156, 0.5912, 0.2623, 0.6126]}, {"w": "and", "b": [0.2672, 0.5912, 0.2987, 0.6126]}, {"w": "clearly", "b": [0.3036, 0.5912, 0.3582, 0.6126]}, {"w": "much", "b": [0.3631, 0.5912, 0.4108, 0.6126]}, {"w": "better", "b": [0.4156, 0.5912, 0.4643, 0.6126]}, {"w": "than", "b": [0.4692, 0.5912, 0.5072, 0.6126]}, {"w": "what", "b": [0.5121, 0.5912, 0.5526, 0.6126]}, {"w": "we", "b": [0.5574, 0.5912, 0.5806, 0.6126]}, {"w": "achieved", "b": [0.5854, 0.5912, 0.6584, 0.6126]}, {"w": "with", "b": [0.6633, 0.5912, 0.7006, 0.6126]}, {"w": "dense", "b": [0.7055, 0.5912, 0.7532, 0.6126]}, {"w": "networks", "b": [0.7581, 0.5912, 0.8353, 0.6126]}, {"w": "in", "b": [0.8402, 0.5912, 0.8571, 0.6126]}, {"w": "Chapter", "b": [0.1429, 0.6102, 0.2104, 0.6317]}, {"w": "10.", "b": [0.2152, 0.6102, 0.2399, 0.6317]}]}, {"id": "b_7", "type": "paragraph", "text": "Over the years, variants of this fundamental architecture have been developed, lead‐ ing to amazing advances in the field. A good measure of this progress is the error rate in competitions such as the ILSVRC ImageNet challenge. In this competition the top-5 error rate for image classification fell from over 26% to less than 2.3% in just six years. The top-five error rate is the number of test images for which the system’s top 5 predictions did not include the correct answer. The images are large (256 pixels high) and there are 1,000 classes, some of which are really subtle (try distinguishing 120 dog breeds). Looking at the evolution of the winning entries is a good way to under‐ stand how CNNs work.", "words": [{"w": "Over", "b": [0.1429, 0.6384, 0.185, 0.6598]}, {"w": "the", "b": [0.1912, 0.6384, 0.2175, 0.6598]}, {"w": "years,", "b": [0.2237, 0.6384, 0.2714, 0.6598]}, {"w": "variants", "b": [0.2776, 0.6384, 0.3438, 0.6598]}, {"w": "of", "b": [0.35, 0.6384, 0.3668, 0.6598]}, {"w": "this", "b": [0.3729, 0.6384, 0.4037, 0.6598]}, {"w": "fundamental", "b": [0.4098, 0.6384, 0.5163, 0.6598]}, {"w": "architecture", "b": [0.5225, 0.6384, 0.6229, 0.6598]}, {"w": "have", "b": [0.6291, 0.6384, 0.6675, 0.6598]}, {"w": "been", "b": [0.6736, 0.6384, 0.7133, 0.6598]}, {"w": "developed,", "b": [0.7195, 0.6384, 0.8093, 0.6598]}, {"w": "lead‐", "b": [0.8154, 0.6384, 0.8571, 0.6598]}, {"w": "ing", "b": [0.1429, 0.6574, 0.1696, 0.6788]}, {"w": "to", "b": [0.1746, 0.6574, 0.1916, 0.6788]}, {"w": "amazing", "b": [0.1966, 0.6574, 0.2674, 0.6788]}, {"w": "advances", "b": [0.2724, 0.6574, 0.3481, 0.6788]}, {"w": "in", "b": [0.3531, 0.6574, 0.3701, 0.6788]}, {"w": "the", "b": [0.3751, 0.6574, 0.4014, 0.6788]}, {"w": "field.", "b": [0.4064, 0.6574, 0.448, 0.6788]}, {"w": "A", "b": [0.453, 0.6574, 0.4674, 0.6788]}, {"w": "good", "b": [0.4724, 0.6574, 0.5144, 0.6788]}, {"w": "measure", "b": [0.5194, 0.6574, 0.5898, 0.6788]}, {"w": "of", "b": [0.5948, 0.6574, 0.6116, 0.6788]}, {"w": "this", "b": [0.6166, 0.6574, 0.6473, 0.6788]}, {"w": "progress", "b": [0.6523, 0.6574, 0.7232, 0.6788]}, {"w": "is", "b": [0.7282, 0.6574, 0.7414, 0.6788]}, {"w": "the", "b": [0.7465, 0.6574, 0.7728, 0.6788]}, {"w": "error", "b": [0.7778, 0.6574, 0.8205, 0.6788]}, {"w": "rate", "b": [0.8255, 0.6574, 0.8572, 0.6788]}, {"w": "in", "b": [0.1429, 0.6765, 0.1598, 0.6979]}, {"w": "competitions", "b": [0.1684, 0.6765, 0.2778, 0.6979]}, {"w": "such", "b": [0.2863, 0.6765, 0.325, 0.6979]}, {"w": "as", "b": [0.3335, 0.6765, 0.3503, 0.6979]}, {"w": "the", "b": [0.3588, 0.6765, 0.3852, 0.6979]}, {"w": "ILSVRC", "b": [0.3937, 0.6765, 0.4633, 0.6979]}, {"w": "ImageNet", "b": [0.4719, 0.6765, 0.5539, 0.6979]}, {"w": "challenge.", "b": [0.5625, 0.6765, 0.6457, 0.6979]}, {"w": "In", "b": [0.6542, 0.6765, 0.6727, 0.6979]}, {"w": "this", "b": [0.6813, 0.6765, 0.712, 0.6979]}, {"w": "competition", "b": [0.7205, 0.6765, 0.8223, 0.6979]}, {"w": "the", "b": [0.8308, 0.6765, 0.8571, 0.6979]}, {"w": "top-5", "b": [0.1429, 0.6955, 0.1882, 0.7169]}, {"w": "error", "b": [0.1929, 0.6955, 0.2356, 0.7169]}, {"w": "rate", "b": [0.2403, 0.6955, 0.272, 0.7169]}, {"w": "for", "b": [0.2767, 0.6955, 0.3012, 0.7169]}, {"w": "image", "b": [0.3064, 0.6955, 0.3567, 0.7169]}, {"w": "classification", "b": [0.3616, 0.6955, 0.469, 0.7169]}, {"w": "fell", "b": [0.4738, 0.6955, 0.4993, 0.7169]}, {"w": "from", "b": [0.5042, 0.6955, 0.5457, 0.7169]}, {"w": "over", "b": [0.5506, 0.6955, 0.5874, 0.7169]}, {"w": "26%", "b": [0.5923, 0.6955, 0.628, 0.7169]}, {"w": "to", "b": [0.6328, 0.6955, 0.6498, 0.7169]}, {"w": "less", "b": [0.6546, 0.6955, 0.6841, 0.7169]}, {"w": "than", "b": [0.6889, 0.6955, 0.7269, 0.7169]}, {"w": "2.3%", "b": [0.7317, 0.6955, 0.7722, 0.7169]}, {"w": "in", "b": [0.7771, 0.6955, 0.794, 0.7169]}, {"w": "just", "b": [0.7989, 0.6955, 0.8293, 0.7169]}, {"w": "six", "b": [0.8341, 0.6955, 0.8571, 0.7169]}, {"w": "years.", "b": [0.1429, 0.7145, 0.1905, 0.736]}, {"w": "The", "b": [0.1955, 0.7145, 0.2283, 0.736]}, {"w": "top-five", "b": [0.2332, 0.7145, 0.2988, 0.736]}, {"w": "error", "b": [0.3037, 0.7145, 0.3463, 0.736]}, {"w": "rate", "b": [0.3512, 0.7145, 0.3829, 0.736]}, {"w": "is", "b": [0.3878, 0.7145, 0.4011, 0.736]}, {"w": "the", "b": [0.406, 0.7145, 0.4323, 0.736]}, {"w": "number", "b": [0.4372, 0.7145, 0.5035, 0.736]}, {"w": "of", "b": [0.5084, 0.7145, 0.5252, 0.736]}, {"w": "test", "b": [0.5301, 0.7145, 0.5593, 0.736]}, {"w": "images", "b": [0.5642, 0.7145, 0.6223, 0.736]}, {"w": "for", "b": [0.6272, 0.7145, 0.6517, 0.736]}, {"w": "which", "b": [0.6566, 0.7145, 0.7075, 0.736]}, {"w": "the", "b": [0.7125, 0.7145, 0.7388, 0.736]}, {"w": "system’s", "b": [0.7437, 0.7145, 0.8094, 0.736]}, {"w": "top", "b": [0.8143, 0.7145, 0.8422, 0.736]}, {"w": "5", "b": [0.8471, 0.7145, 0.8571, 0.736]}, {"w": "predictions", "b": [0.1428, 0.7336, 0.2373, 0.755]}, {"w": "did", "b": [0.2425, 0.7336, 0.2701, 0.755]}, {"w": "not", "b": [0.2752, 0.7336, 0.3036, 0.755]}, {"w": "include", "b": [0.3087, 0.7336, 0.3707, 0.755]}, {"w": "the", "b": [0.3758, 0.7336, 0.4021, 0.755]}, {"w": "correct", "b": [0.4073, 0.7336, 0.4662, 0.755]}, {"w": "answer.", "b": [0.4713, 0.7336, 0.5338, 0.755]}, {"w": "The", "b": [0.5389, 0.7336, 0.5717, 0.755]}, {"w": "images", "b": [0.5769, 0.7336, 0.6349, 0.755]}, {"w": "are", "b": [0.64, 0.7336, 0.6658, 0.755]}, {"w": "large", "b": [0.6709, 0.7336, 0.7116, 0.755]}, {"w": "(256", "b": [0.7168, 0.7336, 0.754, 0.755]}, {"w": "pixels", "b": [0.7591, 0.7336, 0.8072, 0.755]}, {"w": "high)", "b": [0.8123, 0.7336, 0.8571, 0.755]}, {"w": "and", "b": [0.1429, 0.7526, 0.1744, 0.7741]}, {"w": "there", "b": [0.1817, 0.7526, 0.2247, 0.7741]}, {"w": "are", "b": [0.232, 0.7526, 0.2577, 0.7741]}, {"w": "1,000", "b": [0.2651, 0.7526, 0.3098, 0.7741]}, {"w": "classes,", "b": [0.3172, 0.7526, 0.3769, 0.7741]}, {"w": "some", "b": [0.3843, 0.7526, 0.4285, 0.7741]}, {"w": "of", "b": [0.4358, 0.7526, 0.4526, 0.7741]}, {"w": "which", "b": [0.4599, 0.7526, 0.5109, 0.7741]}, {"w": "are", "b": [0.5182, 0.7526, 0.5439, 0.7741]}, {"w": "really", "b": [0.5513, 0.7526, 0.5971, 0.7741]}, {"w": "subtle", "b": [0.6044, 0.7526, 0.6542, 0.7741]}, {"w": "(try", "b": [0.6616, 0.7526, 0.693, 0.7741]}, {"w": "distinguishing", "b": [0.7003, 0.7526, 0.8198, 0.7741]}, {"w": "120", "b": [0.8271, 0.7526, 0.8571, 0.7741]}, {"w": "dog", "b": [0.1429, 0.7717, 0.1742, 0.7931]}, {"w": "breeds).", "b": [0.18, 0.7717, 0.2466, 0.7931]}, {"w": "Looking", "b": [0.2523, 0.7717, 0.3218, 0.7931]}, {"w": "at", "b": [0.3276, 0.7717, 0.3427, 0.7931]}, {"w": "the", "b": [0.3484, 0.7717, 0.3747, 0.7931]}, {"w": "evolution", "b": [0.3805, 0.7717, 0.4599, 0.7931]}, {"w": "of", "b": [0.4656, 0.7717, 0.4824, 0.7931]}, {"w": "the", "b": [0.4881, 0.7717, 0.5145, 0.7931]}, {"w": "winning", "b": [0.5202, 0.7717, 0.5896, 0.7931]}, {"w": "entries", "b": [0.5953, 0.7717, 0.6513, 0.7931]}, {"w": "is", "b": [0.6571, 0.7717, 0.6703, 0.7931]}, {"w": "a", "b": [0.676, 0.7717, 0.6852, 0.7931]}, {"w": "good", "b": [0.6909, 0.7717, 0.7329, 0.7931]}, {"w": "way", "b": [0.7386, 0.7717, 0.7712, 0.7931]}, {"w": "to", "b": [0.777, 0.7717, 0.794, 0.7931]}, {"w": "under‐", "b": [0.7997, 0.7717, 0.8571, 0.7931]}, {"w": "stand", "b": [0.1429, 0.7907, 0.1884, 0.8121]}, {"w": "how", "b": [0.1931, 0.7907, 0.2291, 0.8121]}, {"w": "CNNs", "b": [0.2339, 0.7907, 0.2858, 0.8121]}, {"w": "work.", "b": [0.2905, 0.7907, 0.3382, 0.8121]}]}, {"id": "b_8", "type": "paragraph", "text": "We will first look at the classical LeNet-5 architecture (1998), then three of the win‐ ners of the ILSVRC challenge: AlexNet (2012), GoogLeNet (2014), and ResNet (2015).", "words": [{"w": "We", "b": [0.1429, 0.8189, 0.1699, 0.8403]}, {"w": "will", "b": [0.1762, 0.8189, 0.2066, 0.8403]}, {"w": "first", "b": [0.2129, 0.8189, 0.2464, 0.8403]}, {"w": "look", "b": [0.2527, 0.8189, 0.2895, 0.8403]}, {"w": "at", "b": [0.2958, 0.8189, 0.3109, 0.8403]}, {"w": "the", "b": [0.3172, 0.8189, 0.3435, 0.8403]}, {"w": "classical", "b": [0.3498, 0.8189, 0.4172, 0.8403]}, {"w": "LeNet-5", "b": [0.4234, 0.8189, 0.4911, 0.8403]}, {"w": "architecture", "b": [0.4974, 0.8189, 0.5978, 0.8403]}, {"w": "(1998),", "b": [0.6041, 0.8189, 0.6633, 0.8403]}, {"w": "then", "b": [0.6695, 0.8189, 0.7073, 0.8403]}, {"w": "three", "b": [0.7136, 0.8189, 0.7565, 0.8403]}, {"w": "of", "b": [0.7628, 0.8189, 0.7796, 0.8403]}, {"w": "the", "b": [0.7858, 0.8189, 0.8122, 0.8403]}, {"w": "win‐", "b": [0.8185, 0.8189, 0.8571, 0.8403]}, {"w": "ners", "b": [0.1429, 0.8379, 0.1785, 0.8593]}, {"w": "of", "b": [0.1893, 0.8379, 0.2061, 0.8593]}, {"w": "the", "b": [0.217, 0.8379, 0.2433, 0.8593]}, {"w": "ILSVRC", "b": [0.2542, 0.8379, 0.3238, 0.8593]}, {"w": "challenge:", "b": [0.3347, 0.8379, 0.4179, 0.8593]}, {"w": "AlexNet", "b": [0.4287, 0.8379, 0.4973, 0.8593]}, {"w": "(2012),", "b": [0.5081, 0.8379, 0.5673, 0.8593]}, {"w": "GoogLeNet", "b": [0.5781, 0.8379, 0.6743, 0.8593]}, {"w": "(2014),", "b": [0.6851, 0.8379, 0.7443, 0.8593]}, {"w": "and", "b": [0.7552, 0.8379, 0.7867, 0.8593]}, {"w": "ResNet", "b": [0.7975, 0.8379, 0.8572, 0.8593]}, {"w": "(2015).", "b": [0.1429, 0.857, 0.202, 0.8784]}]}, {"id": "b_9", "type": "paragraph", "text": "448 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "448", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3683, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 475, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "10 “Gradient-Based Learning Applied to Document Recognition”, Y. LeCun, L. Bottou, Y. Bengio and P. Haffner (1998).", "words": [{"w": "10", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "“Gradient-Based", "b": [0.1587, 0.8598, 0.2642, 0.8761]}, {"w": "Learning", "b": [0.2678, 0.8598, 0.325, 0.8761]}, {"w": "Applied", "b": [0.3286, 0.8598, 0.3789, 0.8761]}, {"w": "to", "b": [0.3825, 0.8598, 0.3955, 0.8761]}, {"w": "Document", "b": [0.3991, 0.8598, 0.467, 0.8761]}, {"w": "Recognition”,", "b": [0.4706, 0.8598, 0.5543, 0.8761]}, {"w": "Y.", "b": [0.558, 0.8598, 0.5698, 0.8761]}, {"w": "LeCun,", "b": [0.5734, 0.8598, 0.62, 0.8761]}, {"w": "L.", "b": [0.6236, 0.8598, 0.6357, 0.8761]}, {"w": "Bottou,", "b": [0.6393, 0.8598, 0.6869, 0.8761]}, {"w": "Y.", "b": [0.6905, 0.8598, 0.7023, 0.8761]}, {"w": "Bengio", "b": [0.706, 0.8598, 0.7508, 0.8761]}, {"w": "and", "b": [0.7544, 0.8598, 0.7784, 0.8761]}, {"w": "P.", "b": [0.782, 0.8598, 0.7924, 0.8761]}, {"w": "Haffner", "b": [0.796, 0.8598, 0.8455, 0.8761]}, {"w": "(1998).", "b": [0.1587, 0.8749, 0.2038, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "LeNet-5", "words": [{"w": "LeNet-5", "b": [0.1429, 0.0763, 0.2244, 0.1049]}]}, {"id": "b_2", "type": "paragraph", "text": "The LeNet-5 architecture10 is perhaps the most widely known CNN architecture. As mentioned earlier, it was created by Yann LeCun in 1998 and widely used for hand‐ written digit recognition (MNIST). It is composed of the layers shown in Table 14-1.", "words": [{"w": "The", "b": [0.1429, 0.1108, 0.1757, 0.1322]}, {"w": "LeNet-5", "b": [0.1821, 0.1108, 0.2497, 0.1322]}, {"w": "architecture10", "b": [0.2561, 0.1108, 0.3679, 0.1322]}, {"w": "is", "b": [0.3743, 0.1108, 0.3876, 0.1322]}, {"w": "perhaps", "b": [0.3939, 0.1108, 0.4599, 0.1322]}, {"w": "the", "b": [0.4663, 0.1108, 0.4926, 0.1322]}, {"w": "most", "b": [0.499, 0.1108, 0.5407, 0.1322]}, {"w": "widely", "b": [0.547, 0.1108, 0.6016, 0.1322]}, {"w": "known", "b": [0.608, 0.1108, 0.666, 0.1322]}, {"w": "CNN", "b": [0.6724, 0.1108, 0.7172, 0.1322]}, {"w": "architecture.", "b": [0.7236, 0.1108, 0.8287, 0.1322]}, {"w": "As", "b": [0.8351, 0.1108, 0.8571, 0.1322]}, {"w": "mentioned", "b": [0.1429, 0.1298, 0.2336, 0.1512]}, {"w": "earlier,", "b": [0.2399, 0.1298, 0.2965, 0.1512]}, {"w": "it", "b": [0.3028, 0.1298, 0.3147, 0.1512]}, {"w": "was", "b": [0.321, 0.1298, 0.3521, 0.1512]}, {"w": "created", "b": [0.3584, 0.1298, 0.4187, 0.1512]}, {"w": "by", "b": [0.425, 0.1298, 0.4451, 0.1512]}, {"w": "Yann", "b": [0.4514, 0.1298, 0.4942, 0.1512]}, {"w": "LeCun", "b": [0.5005, 0.1298, 0.5569, 0.1512]}, {"w": "in", "b": [0.5632, 0.1298, 0.5801, 0.1512]}, {"w": "1998", "b": [0.5864, 0.1298, 0.6264, 0.1512]}, {"w": "and", "b": [0.6327, 0.1298, 0.6643, 0.1512]}, {"w": "widely", "b": [0.6705, 0.1298, 0.7251, 0.1512]}, {"w": "used", "b": [0.7314, 0.1298, 0.7699, 0.1512]}, {"w": "for", "b": [0.7762, 0.1298, 0.8008, 0.1512]}, {"w": "hand‐", "b": [0.8071, 0.1298, 0.8571, 0.1512]}, {"w": "written", "b": [0.1429, 0.1489, 0.2034, 0.1703]}, {"w": "digit", "b": [0.2081, 0.1489, 0.2464, 0.1703]}, {"w": "recognition", "b": [0.2511, 0.1489, 0.3478, 0.1703]}, {"w": "(MNIST).", "b": [0.3526, 0.1489, 0.4356, 0.1703]}, {"w": "It", "b": [0.4403, 0.1489, 0.453, 0.1703]}, {"w": "is", "b": [0.4577, 0.1489, 0.4709, 0.1703]}, {"w": "composed", "b": [0.4757, 0.1489, 0.5608, 0.1703]}, {"w": "of", "b": [0.5656, 0.1489, 0.5823, 0.1703]}, {"w": "the", "b": [0.5871, 0.1489, 0.6134, 0.1703]}, {"w": "layers", "b": [0.6181, 0.1489, 0.666, 0.1703]}, {"w": "shown", "b": [0.6707, 0.1489, 0.7258, 0.1703]}, {"w": "in", "b": [0.7305, 0.1489, 0.7475, 0.1703]}, {"w": "Table", "b": [0.7522, 0.1489, 0.797, 0.1703]}, {"w": "14-1.", "b": [0.8017, 0.1489, 0.8439, 0.1703]}]}, {"id": "b_3", "type": "equation", "text": "Table 14-1. LeNet-5 architecture", "words": [{"w": "Table", "b": [0.1429, 0.1867, 0.1844, 0.2073]}, {"w": "14-1.", "b": [0.189, 0.1867, 0.2286, 0.2073]}, {"w": "LeNet-5", "b": [0.2332, 0.1867, 0.2951, 0.2073]}, {"w": "architecture", "b": [0.2997, 0.1867, 0.3907, 0.2073]}]}, {"id": "b_4", "type": "paragraph", "text": "Layer Type Maps Size Kernel size Stride Activation Out Fully Connected – 10 – – RBF", "words": [{"w": "Layer", "b": [0.15, 0.2153, 0.1821, 0.2316]}, {"w": "Type", "b": [0.1964, 0.2153, 0.2243, 0.2316]}, {"w": "Maps", "b": [0.2983, 0.2153, 0.3296, 0.2316]}, {"w": "Size", "b": [0.3438, 0.2153, 0.3673, 0.2316]}, {"w": "Kernel", "b": [0.4031, 0.2153, 0.4413, 0.2316]}, {"w": "size", "b": [0.4447, 0.2153, 0.4668, 0.2316]}, {"w": "Stride", "b": [0.4811, 0.2153, 0.5162, 0.2316]}, {"w": "Activation", "b": [0.5304, 0.2153, 0.5904, 0.2316]}, {"w": "Out", "b": [0.15, 0.2356, 0.1696, 0.2517]}, {"w": "Fully", "b": [0.1964, 0.2356, 0.2226, 0.2517]}, {"w": "Connected", "b": [0.226, 0.2356, 0.284, 0.2517]}, {"w": "–", "b": [0.2983, 0.2356, 0.3073, 0.2517]}, {"w": "10", "b": [0.3438, 0.2356, 0.3576, 0.2517]}, {"w": "–", "b": [0.4031, 0.2356, 0.412, 0.2517]}, {"w": "–", "b": [0.4811, 0.2356, 0.4901, 0.2517]}, {"w": "RBF", "b": [0.5305, 0.2356, 0.5513, 0.2517]}]}, {"id": "b_5", "type": "paragraph", "text": "F6 Fully Connected – 84 – – tanh", "words": [{"w": "F6", "b": [0.15, 0.2566, 0.163, 0.2728]}, {"w": "Fully", "b": [0.1964, 0.2566, 0.2226, 0.2728]}, {"w": "Connected", "b": [0.226, 0.2566, 0.284, 0.2728]}, {"w": "–", "b": [0.2983, 0.2566, 0.3073, 0.2728]}, {"w": "84", "b": [0.3438, 0.2566, 0.3576, 0.2728]}, {"w": "–", "b": [0.4031, 0.2566, 0.412, 0.2728]}, {"w": "–", "b": [0.4811, 0.2566, 0.4901, 0.2728]}, {"w": "tanh", "b": [0.5305, 0.2566, 0.556, 0.2728]}]}, {"id": "b_6", "type": "paragraph", "text": "C5 Convolution 120 1 × 1 5 × 5 1 tanh", "words": [{"w": "C5", "b": [0.15, 0.2777, 0.1635, 0.2938]}, {"w": "Convolution", "b": [0.1964, 0.2777, 0.2626, 0.2938]}, {"w": "120", "b": [0.2983, 0.2777, 0.319, 0.2938]}, {"w": "1", "b": [0.3438, 0.2777, 0.3507, 0.2938]}, {"w": "×", "b": [0.3541, 0.2777, 0.3648, 0.2938]}, {"w": "1", "b": [0.3682, 0.2777, 0.375, 0.2938]}, {"w": "5", "b": [0.4031, 0.2777, 0.4099, 0.2938]}, {"w": "×", "b": [0.4133, 0.2777, 0.424, 0.2938]}, {"w": "5", "b": [0.4274, 0.2777, 0.4343, 0.2938]}, {"w": "1", "b": [0.4811, 0.2777, 0.488, 0.2938]}, {"w": "tanh", "b": [0.5305, 0.2777, 0.556, 0.2938]}]}, {"id": "b_7", "type": "paragraph", "text": "S4 Avg Pooling 16 5 × 5 2 × 2 2 tanh", "words": [{"w": "S4", "b": [0.15, 0.2987, 0.1633, 0.3148]}, {"w": "Avg", "b": [0.1964, 0.2987, 0.2175, 0.3148]}, {"w": "Pooling", "b": [0.2209, 0.2987, 0.2627, 0.3148]}, {"w": "16", "b": [0.2983, 0.2987, 0.3121, 0.3148]}, {"w": "5", "b": [0.3438, 0.2987, 0.3507, 0.3148]}, {"w": "×", "b": [0.3541, 0.2987, 0.3648, 0.3148]}, {"w": "5", "b": [0.3682, 0.2987, 0.375, 0.3148]}, {"w": "2", "b": [0.4031, 0.2987, 0.4099, 0.3148]}, {"w": "×", "b": [0.4133, 0.2987, 0.424, 0.3148]}, {"w": "2", "b": [0.4274, 0.2987, 0.4343, 0.3148]}, {"w": "2", "b": [0.4811, 0.2987, 0.488, 0.3148]}, {"w": "tanh", "b": [0.5305, 0.2987, 0.556, 0.3148]}]}, {"id": "b_8", "type": "paragraph", "text": "C3 Convolution 16 10 × 10 5 × 5 1 tanh", "words": [{"w": "C3", "b": [0.15, 0.3197, 0.1635, 0.3358]}, {"w": "Convolution", "b": [0.1964, 0.3197, 0.2626, 0.3358]}, {"w": "16", "b": [0.2983, 0.3197, 0.3121, 0.3358]}, {"w": "10", "b": [0.3438, 0.3197, 0.3576, 0.3358]}, {"w": "×", "b": [0.361, 0.3197, 0.3716, 0.3358]}, {"w": "10", "b": [0.375, 0.3197, 0.3888, 0.3358]}, {"w": "5", "b": [0.4031, 0.3197, 0.4099, 0.3358]}, {"w": "×", "b": [0.4133, 0.3197, 0.424, 0.3358]}, {"w": "5", "b": [0.4274, 0.3197, 0.4343, 0.3358]}, {"w": "1", "b": [0.4811, 0.3197, 0.488, 0.3358]}, {"w": "tanh", "b": [0.5305, 0.3197, 0.556, 0.3358]}]}, {"id": "b_9", "type": "paragraph", "text": "S2 Avg Pooling 6 14 × 14 2 × 2 2 tanh", "words": [{"w": "S2", "b": [0.15, 0.3407, 0.1633, 0.3568]}, {"w": "Avg", "b": [0.1964, 0.3407, 0.2175, 0.3568]}, {"w": "Pooling", "b": [0.2209, 0.3407, 0.2627, 0.3568]}, {"w": "6", "b": [0.2983, 0.3407, 0.3052, 0.3568]}, {"w": "14", "b": [0.3438, 0.3407, 0.3576, 0.3568]}, {"w": "×", "b": [0.361, 0.3407, 0.3716, 0.3568]}, {"w": "14", "b": [0.375, 0.3407, 0.3888, 0.3568]}, {"w": "2", "b": [0.4031, 0.3407, 0.4099, 0.3568]}, {"w": "×", "b": [0.4133, 0.3407, 0.424, 0.3568]}, {"w": "2", "b": [0.4274, 0.3407, 0.4343, 0.3568]}, {"w": "2", "b": [0.4811, 0.3407, 0.488, 0.3568]}, {"w": "tanh", "b": [0.5305, 0.3407, 0.556, 0.3568]}]}, {"id": "b_10", "type": "paragraph", "text": "C1 Convolution 6 28 × 28 5 × 5 1 tanh", "words": [{"w": "C1", "b": [0.15, 0.3617, 0.1635, 0.3778]}, {"w": "Convolution", "b": [0.1964, 0.3617, 0.2626, 0.3778]}, {"w": "6", "b": [0.2983, 0.3617, 0.3052, 0.3778]}, {"w": "28", "b": [0.3438, 0.3617, 0.3576, 0.3778]}, {"w": "×", "b": [0.361, 0.3617, 0.3716, 0.3778]}, {"w": "28", "b": [0.375, 0.3617, 0.3888, 0.3778]}, {"w": "5", "b": [0.4031, 0.3617, 0.4099, 0.3778]}, {"w": "×", "b": [0.4133, 0.3617, 0.424, 0.3778]}, {"w": "5", "b": [0.4274, 0.3617, 0.4343, 0.3778]}, {"w": "1", "b": [0.4811, 0.3617, 0.488, 0.3778]}, {"w": "tanh", "b": [0.5305, 0.3617, 0.556, 0.3778]}]}, {"id": "b_11", "type": "paragraph", "text": "In Input 1 32 × 32 – – –", "words": [{"w": "In", "b": [0.15, 0.3827, 0.1608, 0.3988]}, {"w": "Input", "b": [0.1964, 0.3827, 0.2259, 0.3988]}, {"w": "1", "b": [0.2983, 0.3827, 0.3052, 0.3988]}, {"w": "32", "b": [0.3438, 0.3827, 0.3576, 0.3988]}, {"w": "×", "b": [0.361, 0.3827, 0.3716, 0.3988]}, {"w": "32", "b": [0.375, 0.3827, 0.3888, 0.3988]}, {"w": "–", "b": [0.4031, 0.3827, 0.412, 0.3988]}, {"w": "–", "b": [0.4811, 0.3827, 0.4901, 0.3988]}, {"w": "–", "b": [0.5305, 0.3827, 0.5394, 0.3988]}]}, {"id": "b_12", "type": "paragraph", "text": "There are a few extra details to be noted:", "words": [{"w": "There", "b": [0.1429, 0.4192, 0.1923, 0.4407]}, {"w": "are", "b": [0.197, 0.4192, 0.2227, 0.4407]}, {"w": "a", "b": [0.2275, 0.4192, 0.2366, 0.4407]}, {"w": "few", "b": [0.2413, 0.4192, 0.2706, 0.4407]}, {"w": "extra", "b": [0.2754, 0.4192, 0.3173, 0.4407]}, {"w": "details", "b": [0.322, 0.4192, 0.3759, 0.4407]}, {"w": "to", "b": [0.3806, 0.4192, 0.3976, 0.4407]}, {"w": "be", "b": [0.4023, 0.4192, 0.4217, 0.4407]}, {"w": "noted:", "b": [0.4265, 0.4192, 0.4794, 0.4407]}]}, {"id": "b_13", "type": "paragraph", "text": "• MNIST images are 28 × 28 pixels, but they are zero-padded to 32 × 32 pixels and normalized before being fed to the network. The rest of the network does not use any padding, which is why the size keeps shrinking as the image progresses through the network.", "words": [{"w": "•", "b": [0.16, 0.4534, 0.1682, 0.4748]}, {"w": "MNIST", "b": [0.1786, 0.4534, 0.2424, 0.4748]}, {"w": "images", "b": [0.2476, 0.4534, 0.3056, 0.4748]}, {"w": "are", "b": [0.3108, 0.4534, 0.3365, 0.4748]}, {"w": "28", "b": [0.3417, 0.4534, 0.3617, 0.4748]}, {"w": "×", "b": [0.3668, 0.4534, 0.3789, 0.4748]}, {"w": "28", "b": [0.384, 0.4534, 0.404, 0.4748]}, {"w": "pixels,", "b": [0.4092, 0.4534, 0.462, 0.4748]}, {"w": "but", "b": [0.4672, 0.4534, 0.4952, 0.4748]}, {"w": "they", "b": [0.5003, 0.4534, 0.5362, 0.4748]}, {"w": "are", "b": [0.5414, 0.4534, 0.5671, 0.4748]}, {"w": "zero-padded", "b": [0.5723, 0.4534, 0.6775, 0.4748]}, {"w": "to", "b": [0.6827, 0.4534, 0.6997, 0.4748]}, {"w": "32", "b": [0.7048, 0.4534, 0.7248, 0.4748]}, {"w": "×", "b": [0.73, 0.4534, 0.742, 0.4748]}, {"w": "32", "b": [0.7472, 0.4534, 0.7672, 0.4748]}, {"w": "pixels", "b": [0.7723, 0.4534, 0.8204, 0.4748]}, {"w": "and", "b": [0.8256, 0.4534, 0.8571, 0.4748]}, {"w": "normalized", "b": [0.1786, 0.4725, 0.274, 0.4939]}, {"w": "before", "b": [0.279, 0.4725, 0.3318, 0.4939]}, {"w": "being", "b": [0.3369, 0.4725, 0.383, 0.4939]}, {"w": "fed", "b": [0.388, 0.4725, 0.4141, 0.4939]}, {"w": "to", "b": [0.4191, 0.4725, 0.4361, 0.4939]}, {"w": "the", "b": [0.4411, 0.4725, 0.4674, 0.4939]}, {"w": "network.", "b": [0.4725, 0.4725, 0.5468, 0.4939]}, {"w": "The", "b": [0.5518, 0.4725, 0.5846, 0.4939]}, {"w": "rest", "b": [0.5897, 0.4725, 0.6202, 0.4939]}, {"w": "of", "b": [0.6253, 0.4725, 0.6421, 0.4939]}, {"w": "the", "b": [0.6471, 0.4725, 0.6734, 0.4939]}, {"w": "network", "b": [0.6784, 0.4725, 0.748, 0.4939]}, {"w": "does", "b": [0.753, 0.4725, 0.7912, 0.4939]}, {"w": "not", "b": [0.7962, 0.4725, 0.8246, 0.4939]}, {"w": "use", "b": [0.8296, 0.4725, 0.8571, 0.4939]}, {"w": "any", "b": [0.1786, 0.4915, 0.2082, 0.5129]}, {"w": "padding,", "b": [0.2175, 0.4915, 0.291, 0.5129]}, {"w": "which", "b": [0.3003, 0.4915, 0.3512, 0.5129]}, {"w": "is", "b": [0.3605, 0.4915, 0.3738, 0.5129]}, {"w": "why", "b": [0.3831, 0.4915, 0.4175, 0.5129]}, {"w": "the", "b": [0.4268, 0.4915, 0.4532, 0.5129]}, {"w": "size", "b": [0.4625, 0.4915, 0.4933, 0.5129]}, {"w": "keeps", "b": [0.5026, 0.4915, 0.5492, 0.5129]}, {"w": "shrinking", "b": [0.5585, 0.4915, 0.639, 0.5129]}, {"w": "as", "b": [0.6483, 0.4915, 0.6651, 0.5129]}, {"w": "the", "b": [0.6744, 0.4915, 0.7008, 0.5129]}, {"w": "image", "b": [0.71, 0.4915, 0.7604, 0.5129]}, {"w": "progresses", "b": [0.7697, 0.4915, 0.8571, 0.5129]}, {"w": "through", "b": [0.1786, 0.5106, 0.2463, 0.532]}, {"w": "the", "b": [0.2511, 0.5106, 0.2774, 0.532]}, {"w": "network.", "b": [0.2821, 0.5106, 0.3564, 0.532]}]}, {"id": "b_14", "type": "paragraph", "text": "• The average pooling layers are slightly more complex than usual: each neuron computes the mean of its inputs, then multiplies the result by a learnable coeffi‐ cient (one per map) and adds a learnable bias term (again, one per map), then finally applies the activation function.", "words": [{"w": "•", "b": [0.16, 0.5356, 0.1682, 0.5571]}, {"w": "The", "b": [0.1786, 0.5356, 0.2114, 0.5571]}, {"w": "average", "b": [0.219, 0.5356, 0.2818, 0.5571]}, {"w": "pooling", "b": [0.2894, 0.5356, 0.3536, 0.5571]}, {"w": "layers", "b": [0.3612, 0.5356, 0.409, 0.5571]}, {"w": "are", "b": [0.4167, 0.5356, 0.4424, 0.5571]}, {"w": "slightly", "b": [0.45, 0.5356, 0.5102, 0.5571]}, {"w": "more", "b": [0.5178, 0.5356, 0.5621, 0.5571]}, {"w": "complex", "b": [0.5697, 0.5356, 0.6407, 0.5571]}, {"w": "than", "b": [0.6483, 0.5356, 0.6863, 0.5571]}, {"w": "usual:", "b": [0.6939, 0.5356, 0.7429, 0.5571]}, {"w": "each", "b": [0.7505, 0.5356, 0.7884, 0.5571]}, {"w": "neuron", "b": [0.7961, 0.5356, 0.8571, 0.5571]}, {"w": "computes", "b": [0.1786, 0.5547, 0.2595, 0.5761]}, {"w": "the", "b": [0.2655, 0.5547, 0.2918, 0.5761]}, {"w": "mean", "b": [0.2978, 0.5547, 0.3443, 0.5761]}, {"w": "of", "b": [0.3503, 0.5547, 0.367, 0.5761]}, {"w": "its", "b": [0.373, 0.5547, 0.3926, 0.5761]}, {"w": "inputs,", "b": [0.3986, 0.5547, 0.4559, 0.5761]}, {"w": "then", "b": [0.4619, 0.5547, 0.4996, 0.5761]}, {"w": "multiplies", "b": [0.5056, 0.5547, 0.5888, 0.5761]}, {"w": "the", "b": [0.5948, 0.5547, 0.6211, 0.5761]}, {"w": "result", "b": [0.6271, 0.5547, 0.674, 0.5761]}, {"w": "by", "b": [0.68, 0.5547, 0.7002, 0.5761]}, {"w": "a", "b": [0.7062, 0.5547, 0.7153, 0.5761]}, {"w": "learnable", "b": [0.7213, 0.5547, 0.7975, 0.5761]}, {"w": "coeffi‐", "b": [0.8035, 0.5547, 0.8571, 0.5761]}, {"w": "cient", "b": [0.1786, 0.5737, 0.2192, 0.5952]}, {"w": "(one", "b": [0.2262, 0.5737, 0.2642, 0.5952]}, {"w": "per", "b": [0.2712, 0.5737, 0.2987, 0.5952]}, {"w": "map)", "b": [0.3057, 0.5737, 0.3497, 0.5952]}, {"w": "and", "b": [0.3567, 0.5737, 0.3882, 0.5952]}, {"w": "adds", "b": [0.3952, 0.5737, 0.434, 0.5952]}, {"w": "a", "b": [0.441, 0.5737, 0.4502, 0.5952]}, {"w": "learnable", "b": [0.4572, 0.5737, 0.5334, 0.5952]}, {"w": "bias", "b": [0.5404, 0.5737, 0.5734, 0.5952]}, {"w": "term", "b": [0.5804, 0.5737, 0.6204, 0.5952]}, {"w": "(again,", "b": [0.6274, 0.5737, 0.6843, 0.5952]}, {"w": "one", "b": [0.6913, 0.5737, 0.7222, 0.5952]}, {"w": "per", "b": [0.7292, 0.5737, 0.7567, 0.5952]}, {"w": "map),", "b": [0.7637, 0.5737, 0.8124, 0.5952]}, {"w": "then", "b": [0.8194, 0.5737, 0.8571, 0.5952]}, {"w": "finally", "b": [0.1786, 0.5928, 0.231, 0.6142]}, {"w": "applies", "b": [0.2357, 0.5928, 0.2936, 0.6142]}, {"w": "the", "b": [0.2984, 0.5928, 0.3247, 0.6142]}, {"w": "activation", "b": [0.3294, 0.5928, 0.4117, 0.6142]}, {"w": "function.", "b": [0.4164, 0.5928, 0.4926, 0.6142]}]}, {"id": "b_15", "type": "paragraph", "text": "• Most neurons in C3 maps are connected to neurons in only three or four S2 maps (instead of all six S2 maps). See table 1 (page 8) in the original paper10 for details.", "words": [{"w": "•", "b": [0.16, 0.6179, 0.1682, 0.6393]}, {"w": "Most", "b": [0.1786, 0.6179, 0.2212, 0.6393]}, {"w": "neurons", "b": [0.2293, 0.6179, 0.2981, 0.6393]}, {"w": "in", "b": [0.3062, 0.6179, 0.3232, 0.6393]}, {"w": "C3", "b": [0.3313, 0.6179, 0.3552, 0.6393]}, {"w": "maps", "b": [0.3633, 0.6179, 0.4077, 0.6393]}, {"w": "are", "b": [0.4158, 0.6179, 0.4415, 0.6393]}, {"w": "connected", "b": [0.4497, 0.6179, 0.5358, 0.6393]}, {"w": "to", "b": [0.5439, 0.6179, 0.5609, 0.6393]}, {"w": "neurons", "b": [0.569, 0.6179, 0.6377, 0.6393]}, {"w": "in", "b": [0.6459, 0.6179, 0.6629, 0.6393]}, {"w": "only", "b": [0.671, 0.6179, 0.7079, 0.6393]}, {"w": "three", "b": [0.716, 0.6179, 0.7589, 0.6393]}, {"w": "or", "b": [0.767, 0.6179, 0.7854, 0.6393]}, {"w": "four", "b": [0.7935, 0.6179, 0.8291, 0.6393]}, {"w": "S2", "b": [0.8373, 0.6179, 0.8571, 0.6393]}, {"w": "maps", "b": [0.1786, 0.6369, 0.2229, 0.6583]}, {"w": "(instead", "b": [0.2291, 0.6369, 0.2963, 0.6583]}, {"w": "of", "b": [0.3024, 0.6369, 0.3192, 0.6583]}, {"w": "all", "b": [0.3254, 0.6369, 0.345, 0.6583]}, {"w": "six", "b": [0.3512, 0.6369, 0.3743, 0.6583]}, {"w": "S2", "b": [0.3804, 0.6369, 0.4003, 0.6583]}, {"w": "maps).", "b": [0.4064, 0.6369, 0.4627, 0.6583]}, {"w": "See", "b": [0.4689, 0.6369, 0.4965, 0.6583]}, {"w": "table", "b": [0.5026, 0.6369, 0.5428, 0.6583]}, {"w": "1", "b": [0.549, 0.6369, 0.559, 0.6583]}, {"w": "(page", "b": [0.5651, 0.6369, 0.611, 0.6583]}, {"w": "8)", "b": [0.6171, 0.6369, 0.6343, 0.6583]}, {"w": "in", "b": [0.6405, 0.6369, 0.6575, 0.6583]}, {"w": "the", "b": [0.6636, 0.6369, 0.6899, 0.6583]}, {"w": "original", "b": [0.6961, 0.6369, 0.7612, 0.6583]}, {"w": "paper10", "b": [0.7673, 0.6369, 0.8265, 0.6583]}, {"w": "for", "b": [0.8326, 0.6369, 0.8571, 0.6583]}, {"w": "details.", "b": [0.1786, 0.656, 0.2372, 0.6774]}]}, {"id": "b_16", "type": "paragraph", "text": "• The output layer is a bit special: instead of computing the matrix multiplication of the inputs and the weight vector, each neuron outputs the square of the Eucli‐ dian distance between its input vector and its weight vector. Each output meas‐ ures how much the image belongs to a particular digit class. The cross entropy cost function is now preferred, as it penalizes bad predictions much more, pro‐ ducing larger gradients and converging faster.", "words": [{"w": "•", "b": [0.16, 0.6811, 0.1682, 0.7025]}, {"w": "The", "b": [0.1786, 0.6811, 0.2114, 0.7025]}, {"w": "output", "b": [0.2177, 0.6811, 0.2741, 0.7025]}, {"w": "layer", "b": [0.2804, 0.6811, 0.3205, 0.7025]}, {"w": "is", "b": [0.3268, 0.6811, 0.3401, 0.7025]}, {"w": "a", "b": [0.3464, 0.6811, 0.3555, 0.7025]}, {"w": "bit", "b": [0.3618, 0.6811, 0.3843, 0.7025]}, {"w": "special:", "b": [0.3906, 0.6811, 0.4516, 0.7025]}, {"w": "instead", "b": [0.4579, 0.6811, 0.5179, 0.7025]}, {"w": "of", "b": [0.5241, 0.6811, 0.5409, 0.7025]}, {"w": "computing", "b": [0.5472, 0.6811, 0.6384, 0.7025]}, {"w": "the", "b": [0.6447, 0.6811, 0.671, 0.7025]}, {"w": "matrix", "b": [0.6773, 0.6811, 0.7326, 0.7025]}, {"w": "multiplication", "b": [0.7389, 0.6811, 0.8571, 0.7025]}, {"w": "of", "b": [0.1786, 0.7001, 0.1954, 0.7215]}, {"w": "the", "b": [0.2009, 0.7001, 0.2272, 0.7215]}, {"w": "inputs", "b": [0.2327, 0.7001, 0.2853, 0.7215]}, {"w": "and", "b": [0.2907, 0.7001, 0.3223, 0.7215]}, {"w": "the", "b": [0.3278, 0.7001, 0.3541, 0.7215]}, {"w": "weight", "b": [0.3596, 0.7001, 0.4152, 0.7215]}, {"w": "vector,", "b": [0.4206, 0.7001, 0.4761, 0.7215]}, {"w": "each", "b": [0.4816, 0.7001, 0.5195, 0.7215]}, {"w": "neuron", "b": [0.525, 0.7001, 0.5861, 0.7215]}, {"w": "outputs", "b": [0.5916, 0.7001, 0.6556, 0.7215]}, {"w": "the", "b": [0.6611, 0.7001, 0.6874, 0.7215]}, {"w": "square", "b": [0.6929, 0.7001, 0.748, 0.7215]}, {"w": "of", "b": [0.7535, 0.7001, 0.7703, 0.7215]}, {"w": "the", "b": [0.7758, 0.7001, 0.8021, 0.7215]}, {"w": "Eucli‐", "b": [0.8076, 0.7001, 0.8571, 0.7215]}, {"w": "dian", "b": [0.1786, 0.7192, 0.2157, 0.7406]}, {"w": "distance", "b": [0.2221, 0.7192, 0.2909, 0.7406]}, {"w": "between", "b": [0.2974, 0.7192, 0.3666, 0.7406]}, {"w": "its", "b": [0.373, 0.7192, 0.3926, 0.7406]}, {"w": "input", "b": [0.399, 0.7192, 0.444, 0.7406]}, {"w": "vector", "b": [0.4504, 0.7192, 0.5024, 0.7406]}, {"w": "and", "b": [0.5089, 0.7192, 0.5404, 0.7406]}, {"w": "its", "b": [0.5469, 0.7192, 0.5665, 0.7406]}, {"w": "weight", "b": [0.5729, 0.7192, 0.6285, 0.7406]}, {"w": "vector.", "b": [0.6349, 0.7192, 0.6904, 0.7406]}, {"w": "Each", "b": [0.6968, 0.7192, 0.7377, 0.7406]}, {"w": "output", "b": [0.7442, 0.7192, 0.8006, 0.7406]}, {"w": "meas‐", "b": [0.807, 0.7192, 0.8571, 0.7406]}, {"w": "ures", "b": [0.1786, 0.7382, 0.2139, 0.7596]}, {"w": "how", "b": [0.2202, 0.7382, 0.2562, 0.7596]}, {"w": "much", "b": [0.2626, 0.7382, 0.3103, 0.7596]}, {"w": "the", "b": [0.3166, 0.7382, 0.343, 0.7596]}, {"w": "image", "b": [0.3493, 0.7382, 0.3997, 0.7596]}, {"w": "belongs", "b": [0.4061, 0.7382, 0.4702, 0.7596]}, {"w": "to", "b": [0.4765, 0.7382, 0.4935, 0.7596]}, {"w": "a", "b": [0.4999, 0.7382, 0.509, 0.7596]}, {"w": "particular", "b": [0.5154, 0.7382, 0.5971, 0.7596]}, {"w": "digit", "b": [0.6035, 0.7382, 0.6418, 0.7596]}, {"w": "class.", "b": [0.6481, 0.7382, 0.6914, 0.7596]}, {"w": "The", "b": [0.6977, 0.7382, 0.7306, 0.7596]}, {"w": "cross", "b": [0.7369, 0.7382, 0.7794, 0.7596]}, {"w": "entropy", "b": [0.7857, 0.7382, 0.8508, 0.7596]}, {"w": "cost", "b": [0.1786, 0.7573, 0.212, 0.7787]}, {"w": "function", "b": [0.2185, 0.7573, 0.2899, 0.7787]}, {"w": "is", "b": [0.2964, 0.7573, 0.3096, 0.7787]}, {"w": "now", "b": [0.3161, 0.7573, 0.3524, 0.7787]}, {"w": "preferred,", "b": [0.3589, 0.7573, 0.4415, 0.7787]}, {"w": "as", "b": [0.448, 0.7573, 0.4648, 0.7787]}, {"w": "it", "b": [0.4713, 0.7573, 0.4832, 0.7787]}, {"w": "penalizes", "b": [0.4897, 0.7573, 0.5661, 0.7787]}, {"w": "bad", "b": [0.5726, 0.7573, 0.6033, 0.7787]}, {"w": "predictions", "b": [0.6098, 0.7573, 0.7043, 0.7787]}, {"w": "much", "b": [0.7108, 0.7573, 0.7585, 0.7787]}, {"w": "more,", "b": [0.765, 0.7573, 0.814, 0.7787]}, {"w": "pro‐", "b": [0.8205, 0.7573, 0.8572, 0.7787]}, {"w": "ducing", "b": [0.1786, 0.7763, 0.2362, 0.7977]}, {"w": "larger", "b": [0.2409, 0.7763, 0.2894, 0.7977]}, {"w": "gradients", "b": [0.2941, 0.7763, 0.3712, 0.7977]}, {"w": "and", "b": [0.3759, 0.7763, 0.4074, 0.7977]}, {"w": "converging", "b": [0.4122, 0.7763, 0.5052, 0.7977]}, {"w": "faster.", "b": [0.51, 0.7763, 0.5593, 0.7977]}]}, {"id": "b_17", "type": "paragraph", "text": "CNN Architectures | 449", "words": [{"w": "CNN", "b": [0.6907, 0.9225, 0.7152, 0.9388]}, {"w": "Architectures", "b": [0.718, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "449", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 476, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "11 “ImageNet Classification with Deep Convolutional Neural Networks,” A. Krizhevsky et al. (2012).", "words": [{"w": "11", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“ImageNet", "b": [0.1587, 0.8749, 0.2276, 0.8912]}, {"w": "Classification", "b": [0.2312, 0.8749, 0.3168, 0.8912]}, {"w": "with", "b": [0.3204, 0.8749, 0.3489, 0.8912]}, {"w": "Deep", "b": [0.3525, 0.8749, 0.386, 0.8912]}, {"w": "Convolutional", "b": [0.3896, 0.8749, 0.4813, 0.8912]}, {"w": "Neural", "b": [0.4849, 0.8749, 0.5283, 0.8912]}, {"w": "Networks,”", "b": [0.5319, 0.8749, 0.6013, 0.8912]}, {"w": "A.", "b": [0.6049, 0.8749, 0.6195, 0.8912]}, {"w": "Krizhevsky", "b": [0.6231, 0.8749, 0.6941, 0.8912]}, {"w": "et", "b": [0.6977, 0.8749, 0.7093, 0.8912]}, {"w": "al.", "b": [0.7129, 0.8749, 0.7275, 0.8912]}, {"w": "(2012).", "b": [0.7311, 0.8749, 0.7762, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "Yann LeCun’s website (“LENET” section) features great demos of LeNet-5 classifying digits.", "words": [{"w": "Yann", "b": [0.1429, 0.0791, 0.1856, 0.1005]}, {"w": "LeCun’s", "b": [0.1908, 0.0791, 0.2558, 0.1005]}, {"w": "website", "b": [0.261, 0.0791, 0.3231, 0.1005]}, {"w": "(“LENET”", "b": [0.3283, 0.0791, 0.4158, 0.1005]}, {"w": "section)", "b": [0.421, 0.0791, 0.4875, 0.1005]}, {"w": "features", "b": [0.4927, 0.0791, 0.5581, 0.1005]}, {"w": "great", "b": [0.5633, 0.0791, 0.6047, 0.1005]}, {"w": "demos", "b": [0.6099, 0.0791, 0.6651, 0.1005]}, {"w": "of", "b": [0.6702, 0.0791, 0.687, 0.1005]}, {"w": "LeNet-5", "b": [0.6922, 0.0791, 0.7599, 0.1005]}, {"w": "classifying", "b": [0.765, 0.0791, 0.852, 0.1005]}, {"w": "digits.", "b": [0.1429, 0.0981, 0.1935, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "AlexNet", "words": [{"w": "AlexNet", "b": [0.1429, 0.1323, 0.2241, 0.1609]}]}, {"id": "b_3", "type": "paragraph", "text": "The AlexNet CNN architecture11 won the 2012 ImageNet ILSVRC challenge by a large margin: it achieved 17% top-5 error rate while the second best achieved only 26%! It was developed by Alex Krizhevsky (hence the name), Ilya Sutskever, and Geoffrey Hinton. It is quite similar to LeNet-5, only much larger and deeper, and it was the first to stack convolutional layers directly on top of each other, instead of stacking a pooling layer on top of each convolutional layer. Table 14-2 presents this architecture.", "words": [{"w": "The", "b": [0.1429, 0.1668, 0.1757, 0.1882]}, {"w": "AlexNet", "b": [0.1845, 0.1665, 0.2503, 0.1882]}, {"w": "CNN", "b": [0.2591, 0.1668, 0.3039, 0.1882]}, {"w": "architecture11", "b": [0.3127, 0.1668, 0.4246, 0.1882]}, {"w": "won", "b": [0.4334, 0.1668, 0.4697, 0.1882]}, {"w": "the", "b": [0.4785, 0.1668, 0.5048, 0.1882]}, {"w": "2012", "b": [0.5136, 0.1668, 0.5536, 0.1882]}, {"w": "ImageNet", "b": [0.5624, 0.1668, 0.6445, 0.1882]}, {"w": "ILSVRC", "b": [0.6533, 0.1668, 0.7229, 0.1882]}, {"w": "challenge", "b": [0.7317, 0.1668, 0.8102, 0.1882]}, {"w": "by", "b": [0.819, 0.1668, 0.8392, 0.1882]}, {"w": "a", "b": [0.848, 0.1668, 0.8571, 0.1882]}, {"w": "large", "b": [0.1428, 0.1858, 0.1836, 0.2072]}, {"w": "margin:", "b": [0.1909, 0.1858, 0.2563, 0.2072]}, {"w": "it", "b": [0.2636, 0.1858, 0.2755, 0.2072]}, {"w": "achieved", "b": [0.2828, 0.1858, 0.3558, 0.2072]}, {"w": "17%", "b": [0.3631, 0.1858, 0.3988, 0.2072]}, {"w": "top-5", "b": [0.4061, 0.1858, 0.4514, 0.2072]}, {"w": "error", "b": [0.4587, 0.1858, 0.5014, 0.2072]}, {"w": "rate", "b": [0.5087, 0.1858, 0.5404, 0.2072]}, {"w": "while", "b": [0.5477, 0.1858, 0.5928, 0.2072]}, {"w": "the", "b": [0.6, 0.1858, 0.6264, 0.2072]}, {"w": "second", "b": [0.6337, 0.1858, 0.692, 0.2072]}, {"w": "best", "b": [0.6993, 0.1858, 0.7327, 0.2072]}, {"w": "achieved", "b": [0.74, 0.1858, 0.813, 0.2072]}, {"w": "only", "b": [0.8203, 0.1858, 0.8572, 0.2072]}, {"w": "26%!", "b": [0.1429, 0.2048, 0.1844, 0.2263]}, {"w": "It", "b": [0.1931, 0.2048, 0.2057, 0.2263]}, {"w": "was", "b": [0.2145, 0.2048, 0.2456, 0.2263]}, {"w": "developed", "b": [0.2543, 0.2048, 0.3393, 0.2263]}, {"w": "by", "b": [0.3481, 0.2048, 0.3682, 0.2263]}, {"w": "Alex", "b": [0.3769, 0.2048, 0.4153, 0.2263]}, {"w": "Krizhevsky", "b": [0.424, 0.2048, 0.5173, 0.2263]}, {"w": "(hence", "b": [0.526, 0.2048, 0.5823, 0.2263]}, {"w": "the", "b": [0.591, 0.2048, 0.6174, 0.2263]}, {"w": "name),", "b": [0.6261, 0.2048, 0.6845, 0.2263]}, {"w": "Ilya", "b": [0.6932, 0.2048, 0.7243, 0.2263]}, {"w": "Sutskever,", "b": [0.7331, 0.2048, 0.8169, 0.2263]}, {"w": "and", "b": [0.8256, 0.2048, 0.8571, 0.2263]}, {"w": "Geoffrey", "b": [0.1429, 0.2239, 0.2157, 0.2453]}, {"w": "Hinton.", "b": [0.2223, 0.2239, 0.288, 0.2453]}, {"w": "It", "b": [0.2946, 0.2239, 0.3072, 0.2453]}, {"w": "is", "b": [0.3138, 0.2239, 0.327, 0.2453]}, {"w": "quite", "b": [0.3336, 0.2239, 0.3761, 0.2453]}, {"w": "similar", "b": [0.3827, 0.2239, 0.4407, 0.2453]}, {"w": "to", "b": [0.4473, 0.2239, 0.4643, 0.2453]}, {"w": "LeNet-5,", "b": [0.4709, 0.2239, 0.5433, 0.2453]}, {"w": "only", "b": [0.5499, 0.2239, 0.5868, 0.2453]}, {"w": "much", "b": [0.5934, 0.2239, 0.641, 0.2453]}, {"w": "larger", "b": [0.6476, 0.2239, 0.6961, 0.2453]}, {"w": "and", "b": [0.7027, 0.2239, 0.7342, 0.2453]}, {"w": "deeper,", "b": [0.7408, 0.2239, 0.8005, 0.2453]}, {"w": "and", "b": [0.8071, 0.2239, 0.8386, 0.2453]}, {"w": "it", "b": [0.8452, 0.2239, 0.8571, 0.2453]}, {"w": "was", "b": [0.1428, 0.2429, 0.1739, 0.2644]}, {"w": "the", "b": [0.1816, 0.2429, 0.208, 0.2644]}, {"w": "first", "b": [0.2157, 0.2429, 0.2492, 0.2644]}, {"w": "to", "b": [0.2569, 0.2429, 0.2739, 0.2644]}, {"w": "stack", "b": [0.2816, 0.2429, 0.3239, 0.2644]}, {"w": "convolutional", "b": [0.3317, 0.2429, 0.447, 0.2644]}, {"w": "layers", "b": [0.4547, 0.2429, 0.5026, 0.2644]}, {"w": "directly", "b": [0.5103, 0.2429, 0.5735, 0.2644]}, {"w": "on", "b": [0.5812, 0.2429, 0.6032, 0.2644]}, {"w": "top", "b": [0.6109, 0.2429, 0.6388, 0.2644]}, {"w": "of", "b": [0.6466, 0.2429, 0.6634, 0.2644]}, {"w": "each", "b": [0.6711, 0.2429, 0.709, 0.2644]}, {"w": "other,", "b": [0.7168, 0.2429, 0.7649, 0.2644]}, {"w": "instead", "b": [0.7726, 0.2429, 0.8326, 0.2644]}, {"w": "of", "b": [0.8403, 0.2429, 0.8571, 0.2644]}, {"w": "stacking", "b": [0.1429, 0.262, 0.2119, 0.2834]}, {"w": "a", "b": [0.2185, 0.262, 0.2277, 0.2834]}, {"w": "pooling", "b": [0.2343, 0.262, 0.2985, 0.2834]}, {"w": "layer", "b": [0.3051, 0.262, 0.3453, 0.2834]}, {"w": "on", "b": [0.3519, 0.262, 0.3739, 0.2834]}, {"w": "top", "b": [0.3806, 0.262, 0.4085, 0.2834]}, {"w": "of", "b": [0.4151, 0.262, 0.4319, 0.2834]}, {"w": "each", "b": [0.4385, 0.262, 0.4765, 0.2834]}, {"w": "convolutional", "b": [0.4831, 0.262, 0.5984, 0.2834]}, {"w": "layer.", "b": [0.6051, 0.262, 0.6487, 0.2834]}, {"w": "Table", "b": [0.6553, 0.262, 0.7001, 0.2834]}, {"w": "14-2", "b": [0.7068, 0.262, 0.7442, 0.2834]}, {"w": "presents", "b": [0.7508, 0.262, 0.8198, 0.2834]}, {"w": "this", "b": [0.8264, 0.262, 0.8571, 0.2834]}, {"w": "architecture.", "b": [0.1429, 0.281, 0.248, 0.3025]}]}, {"id": "b_4", "type": "equation", "text": "Table 14-2. AlexNet architecture", "words": [{"w": "Table", "b": [0.1429, 0.3189, 0.1844, 0.3395]}, {"w": "14-2.", "b": [0.189, 0.3189, 0.2287, 0.3395]}, {"w": "AlexNet", "b": [0.2332, 0.3189, 0.2959, 0.3395]}, {"w": "architecture", "b": [0.3004, 0.3189, 0.3914, 0.3395]}]}, {"id": "b_5", "type": "paragraph", "text": "Layer Type Maps Size Kernel size Stride Padding Activation Out Fully Connected – 1,000 – – – Softmax", "words": [{"w": "Layer", "b": [0.15, 0.3474, 0.1821, 0.3637]}, {"w": "Type", "b": [0.1964, 0.3474, 0.2243, 0.3637]}, {"w": "Maps", "b": [0.2983, 0.3474, 0.3296, 0.3637]}, {"w": "Size", "b": [0.3544, 0.3474, 0.3779, 0.3637]}, {"w": "Kernel", "b": [0.4274, 0.3474, 0.4656, 0.3637]}, {"w": "size", "b": [0.469, 0.3474, 0.4912, 0.3637]}, {"w": "Stride", "b": [0.5055, 0.3474, 0.5405, 0.3637]}, {"w": "Padding", "b": [0.5548, 0.3474, 0.6037, 0.3637]}, {"w": "Activation", "b": [0.618, 0.3474, 0.678, 0.3637]}, {"w": "Out", "b": [0.15, 0.3678, 0.1696, 0.3839]}, {"w": "Fully", "b": [0.1964, 0.3678, 0.2226, 0.3839]}, {"w": "Connected", "b": [0.226, 0.3678, 0.284, 0.3839]}, {"w": "–", "b": [0.2983, 0.3678, 0.3073, 0.3839]}, {"w": "1,000", "b": [0.3544, 0.3678, 0.3854, 0.3839]}, {"w": "–", "b": [0.4274, 0.3678, 0.4363, 0.3839]}, {"w": "–", "b": [0.5055, 0.3678, 0.5144, 0.3839]}, {"w": "–", "b": [0.5548, 0.3678, 0.5637, 0.3839]}, {"w": "Softmax", "b": [0.618, 0.3678, 0.6636, 0.3839]}]}, {"id": "b_6", "type": "paragraph", "text": "F9 Fully Connected – 4,096 – – – ReLU", "words": [{"w": "F9", "b": [0.15, 0.3888, 0.163, 0.4049]}, {"w": "Fully", "b": [0.1964, 0.3888, 0.2226, 0.4049]}, {"w": "Connected", "b": [0.226, 0.3888, 0.284, 0.4049]}, {"w": "–", "b": [0.2983, 0.3888, 0.3073, 0.4049]}, {"w": "4,096", "b": [0.3544, 0.3888, 0.3854, 0.4049]}, {"w": "–", "b": [0.4274, 0.3888, 0.4363, 0.4049]}, {"w": "–", "b": [0.5055, 0.3888, 0.5144, 0.4049]}, {"w": "–", "b": [0.5548, 0.3888, 0.5637, 0.4049]}, {"w": "ReLU", "b": [0.618, 0.3888, 0.6461, 0.4049]}]}, {"id": "b_7", "type": "paragraph", "text": "F8 Fully Connected – 4,096 – – – ReLU", "words": [{"w": "F8", "b": [0.15, 0.4098, 0.163, 0.4259]}, {"w": "Fully", "b": [0.1964, 0.4098, 0.2226, 0.4259]}, {"w": "Connected", "b": [0.226, 0.4098, 0.284, 0.4259]}, {"w": "–", "b": [0.2983, 0.4098, 0.3073, 0.4259]}, {"w": "4,096", "b": [0.3544, 0.4098, 0.3854, 0.4259]}, {"w": "–", "b": [0.4274, 0.4098, 0.4363, 0.4259]}, {"w": "–", "b": [0.5055, 0.4098, 0.5144, 0.4259]}, {"w": "–", "b": [0.5548, 0.4098, 0.5637, 0.4259]}, {"w": "ReLU", "b": [0.618, 0.4098, 0.6461, 0.4259]}]}, {"id": "b_8", "type": "paragraph", "text": "C7 Convolution 256 13 × 13 3 × 3 1 SAME ReLU", "words": [{"w": "C7", "b": [0.15, 0.4308, 0.1635, 0.447]}, {"w": "Convolution", "b": [0.1964, 0.4308, 0.2626, 0.447]}, {"w": "256", "b": [0.2983, 0.4308, 0.319, 0.447]}, {"w": "13", "b": [0.3544, 0.4308, 0.3682, 0.447]}, {"w": "×", "b": [0.3716, 0.4308, 0.3822, 0.447]}, {"w": "13", "b": [0.3856, 0.4308, 0.3994, 0.447]}, {"w": "3", "b": [0.4274, 0.4308, 0.4343, 0.447]}, {"w": "×", "b": [0.4377, 0.4308, 0.4483, 0.447]}, {"w": "3", "b": [0.4517, 0.4308, 0.4586, 0.447]}, {"w": "1", "b": [0.5055, 0.4308, 0.5124, 0.447]}, {"w": "SAME", "b": [0.5548, 0.4308, 0.586, 0.447]}, {"w": "ReLU", "b": [0.618, 0.4308, 0.6461, 0.447]}]}, {"id": "b_9", "type": "paragraph", "text": "C6 Convolution 384 13 × 13 3 × 3 1 SAME ReLU", "words": [{"w": "C6", "b": [0.15, 0.4518, 0.1635, 0.468]}, {"w": "Convolution", "b": [0.1964, 0.4518, 0.2626, 0.468]}, {"w": "384", "b": [0.2983, 0.4518, 0.319, 0.468]}, {"w": "13", "b": [0.3544, 0.4518, 0.3682, 0.468]}, {"w": "×", "b": [0.3716, 0.4518, 0.3822, 0.468]}, {"w": "13", "b": [0.3856, 0.4518, 0.3994, 0.468]}, {"w": "3", "b": [0.4274, 0.4518, 0.4343, 0.468]}, {"w": "×", "b": [0.4377, 0.4518, 0.4483, 0.468]}, {"w": "3", "b": [0.4517, 0.4518, 0.4586, 0.468]}, {"w": "1", "b": [0.5055, 0.4518, 0.5124, 0.468]}, {"w": "SAME", "b": [0.5548, 0.4518, 0.586, 0.468]}, {"w": "ReLU", "b": [0.618, 0.4518, 0.6461, 0.468]}]}, {"id": "b_10", "type": "paragraph", "text": "C5 Convolution 384 13 × 13 3 × 3 1 SAME ReLU", "words": [{"w": "C5", "b": [0.15, 0.4729, 0.1635, 0.489]}, {"w": "Convolution", "b": [0.1964, 0.4729, 0.2626, 0.489]}, {"w": "384", "b": [0.2983, 0.4729, 0.319, 0.489]}, {"w": "13", "b": [0.3544, 0.4729, 0.3682, 0.489]}, {"w": "×", "b": [0.3716, 0.4729, 0.3822, 0.489]}, {"w": "13", "b": [0.3856, 0.4729, 0.3994, 0.489]}, {"w": "3", "b": [0.4274, 0.4729, 0.4343, 0.489]}, {"w": "×", "b": [0.4377, 0.4729, 0.4483, 0.489]}, {"w": "3", "b": [0.4517, 0.4729, 0.4586, 0.489]}, {"w": "1", "b": [0.5055, 0.4729, 0.5124, 0.489]}, {"w": "SAME", "b": [0.5548, 0.4729, 0.586, 0.489]}, {"w": "ReLU", "b": [0.618, 0.4729, 0.6461, 0.489]}]}, {"id": "b_11", "type": "paragraph", "text": "S4 Max Pooling 256 13 × 13 3 × 3 2 VALID –", "words": [{"w": "S4", "b": [0.15, 0.4939, 0.1633, 0.51]}, {"w": "Max", "b": [0.1964, 0.4939, 0.2196, 0.51]}, {"w": "Pooling", "b": [0.223, 0.4939, 0.2649, 0.51]}, {"w": "256", "b": [0.2983, 0.4939, 0.319, 0.51]}, {"w": "13", "b": [0.3544, 0.4939, 0.3682, 0.51]}, {"w": "×", "b": [0.3716, 0.4939, 0.3822, 0.51]}, {"w": "13", "b": [0.3856, 0.4939, 0.3994, 0.51]}, {"w": "3", "b": [0.4274, 0.4939, 0.4343, 0.51]}, {"w": "×", "b": [0.4377, 0.4939, 0.4483, 0.51]}, {"w": "3", "b": [0.4517, 0.4939, 0.4586, 0.51]}, {"w": "2", "b": [0.5055, 0.4939, 0.5124, 0.51]}, {"w": "VALID", "b": [0.5548, 0.4939, 0.5877, 0.51]}, {"w": "–", "b": [0.618, 0.4939, 0.627, 0.51]}]}, {"id": "b_12", "type": "paragraph", "text": "C3 Convolution 256 27 × 27 5 × 5 1 SAME ReLU", "words": [{"w": "C3", "b": [0.15, 0.5149, 0.1635, 0.531]}, {"w": "Convolution", "b": [0.1964, 0.5149, 0.2626, 0.531]}, {"w": "256", "b": [0.2983, 0.5149, 0.319, 0.531]}, {"w": "27", "b": [0.3544, 0.5149, 0.3682, 0.531]}, {"w": "×", "b": [0.3716, 0.5149, 0.3822, 0.531]}, {"w": "27", "b": [0.3856, 0.5149, 0.3994, 0.531]}, {"w": "5", "b": [0.4274, 0.5149, 0.4343, 0.531]}, {"w": "×", "b": [0.4377, 0.5149, 0.4483, 0.531]}, {"w": "5", "b": [0.4517, 0.5149, 0.4586, 0.531]}, {"w": "1", "b": [0.5055, 0.5149, 0.5124, 0.531]}, {"w": "SAME", "b": [0.5548, 0.5149, 0.586, 0.531]}, {"w": "ReLU", "b": [0.618, 0.5149, 0.6461, 0.531]}]}, {"id": "b_13", "type": "paragraph", "text": "S2 Max Pooling 96 27 × 27 3 × 3 2 VALID –", "words": [{"w": "S2", "b": [0.15, 0.5359, 0.1633, 0.552]}, {"w": "Max", "b": [0.1964, 0.5359, 0.2196, 0.552]}, {"w": "Pooling", "b": [0.223, 0.5359, 0.2649, 0.552]}, {"w": "96", "b": [0.2983, 0.5359, 0.3121, 0.552]}, {"w": "27", "b": [0.3544, 0.5359, 0.3682, 0.552]}, {"w": "×", "b": [0.3716, 0.5359, 0.3822, 0.552]}, {"w": "27", "b": [0.3856, 0.5359, 0.3994, 0.552]}, {"w": "3", "b": [0.4274, 0.5359, 0.4343, 0.552]}, {"w": "×", "b": [0.4377, 0.5359, 0.4483, 0.552]}, {"w": "3", "b": [0.4517, 0.5359, 0.4586, 0.552]}, {"w": "2", "b": [0.5055, 0.5359, 0.5124, 0.552]}, {"w": "VALID", "b": [0.5548, 0.5359, 0.5877, 0.552]}, {"w": "–", "b": [0.618, 0.5359, 0.627, 0.552]}]}, {"id": "b_14", "type": "paragraph", "text": "C1 Convolution 96 55 × 55 11 × 11 4 VALID ReLU", "words": [{"w": "C1", "b": [0.15, 0.5569, 0.1635, 0.573]}, {"w": "Convolution", "b": [0.1964, 0.5569, 0.2626, 0.573]}, {"w": "96", "b": [0.2983, 0.5569, 0.3121, 0.573]}, {"w": "55", "b": [0.3544, 0.5569, 0.3682, 0.573]}, {"w": "×", "b": [0.3716, 0.5569, 0.3822, 0.573]}, {"w": "55", "b": [0.3856, 0.5569, 0.3994, 0.573]}, {"w": "11", "b": [0.4274, 0.5569, 0.4412, 0.573]}, {"w": "×", "b": [0.4446, 0.5569, 0.4552, 0.573]}, {"w": "11", "b": [0.4586, 0.5569, 0.4724, 0.573]}, {"w": "4", "b": [0.5055, 0.5569, 0.5124, 0.573]}, {"w": "VALID", "b": [0.5548, 0.5569, 0.5877, 0.573]}, {"w": "ReLU", "b": [0.618, 0.5569, 0.6461, 0.573]}]}, {"id": "b_15", "type": "paragraph", "text": "In Input 3 (RGB) 227 × 227 – – – –", "words": [{"w": "In", "b": [0.15, 0.5779, 0.1608, 0.594]}, {"w": "Input", "b": [0.1964, 0.5779, 0.2259, 0.594]}, {"w": "3", "b": [0.2983, 0.5779, 0.3052, 0.594]}, {"w": "(RGB)", "b": [0.3086, 0.5779, 0.3401, 0.594]}, {"w": "227", "b": [0.3544, 0.5779, 0.3751, 0.594]}, {"w": "×", "b": [0.3785, 0.5779, 0.3891, 0.594]}, {"w": "227", "b": [0.3925, 0.5779, 0.4131, 0.594]}, {"w": "–", "b": [0.4274, 0.5779, 0.4363, 0.594]}, {"w": "–", "b": [0.5055, 0.5779, 0.5144, 0.594]}, {"w": "–", "b": [0.5548, 0.5779, 0.5637, 0.594]}, {"w": "–", "b": [0.618, 0.5779, 0.627, 0.594]}]}, {"id": "b_16", "type": "paragraph", "text": "To reduce overfitting, the authors used two regularization techniques: first they applied dropout (introduced in Chapter 11) with a 50% dropout rate during training to the outputs of layers F8 and F9. Second, they performed data augmentation by ran‐ domly shifting the training images by various offsets, flipping them horizontally, and changing the lighting conditions.", "words": [{"w": "To", "b": [0.1429, 0.6144, 0.1643, 0.6359]}, {"w": "reduce", "b": [0.1746, 0.6144, 0.2309, 0.6359]}, {"w": "overfitting,", "b": [0.2413, 0.6144, 0.3341, 0.6359]}, {"w": "the", "b": [0.3444, 0.6144, 0.3707, 0.6359]}, {"w": "authors", "b": [0.381, 0.6144, 0.4443, 0.6359]}, {"w": "used", "b": [0.4547, 0.6144, 0.4932, 0.6359]}, {"w": "two", "b": [0.5035, 0.6144, 0.5348, 0.6359]}, {"w": "regularization", "b": [0.5451, 0.6144, 0.6617, 0.6359]}, {"w": "techniques:", "b": [0.672, 0.6144, 0.7671, 0.6359]}, {"w": "first", "b": [0.7774, 0.6144, 0.8109, 0.6359]}, {"w": "they", "b": [0.8212, 0.6144, 0.8571, 0.6359]}, {"w": "applied", "b": [0.1429, 0.6335, 0.2041, 0.6549]}, {"w": "dropout", "b": [0.2098, 0.6335, 0.2781, 0.6549]}, {"w": "(introduced", "b": [0.2838, 0.6335, 0.383, 0.6549]}, {"w": "in", "b": [0.3887, 0.6335, 0.4057, 0.6549]}, {"w": "Chapter", "b": [0.4113, 0.6335, 0.4789, 0.6549]}, {"w": "11)", "b": [0.4846, 0.6335, 0.5118, 0.6549]}, {"w": "with", "b": [0.5175, 0.6335, 0.5548, 0.6549]}, {"w": "a", "b": [0.5605, 0.6335, 0.5696, 0.6549]}, {"w": "50%", "b": [0.5753, 0.6335, 0.611, 0.6549]}, {"w": "dropout", "b": [0.6167, 0.6335, 0.685, 0.6549]}, {"w": "rate", "b": [0.6907, 0.6335, 0.7223, 0.6549]}, {"w": "during", "b": [0.728, 0.6335, 0.7845, 0.6549]}, {"w": "training", "b": [0.7902, 0.6335, 0.8571, 0.6549]}, {"w": "to", "b": [0.1429, 0.6525, 0.1598, 0.674]}, {"w": "the", "b": [0.1647, 0.6525, 0.191, 0.674]}, {"w": "outputs", "b": [0.1959, 0.6525, 0.2599, 0.674]}, {"w": "of", "b": [0.2648, 0.6525, 0.2816, 0.674]}, {"w": "layers", "b": [0.2864, 0.6525, 0.3343, 0.674]}, {"w": "F8", "b": [0.3391, 0.6525, 0.3601, 0.674]}, {"w": "and", "b": [0.365, 0.6525, 0.3966, 0.674]}, {"w": "F9.", "b": [0.4014, 0.6525, 0.4272, 0.674]}, {"w": "Second,", "b": [0.432, 0.6525, 0.4974, 0.674]}, {"w": "they", "b": [0.5022, 0.6525, 0.5381, 0.674]}, {"w": "performed", "b": [0.543, 0.6525, 0.6319, 0.674]}, {"w": "data", "b": [0.6368, 0.6523, 0.6734, 0.674]}, {"w": "augmentation", "b": [0.6782, 0.6523, 0.7915, 0.674]}, {"w": "by", "b": [0.7964, 0.6525, 0.8166, 0.674]}, {"w": "ran‐", "b": [0.8213, 0.6525, 0.857, 0.674]}, {"w": "domly", "b": [0.1429, 0.6716, 0.1964, 0.693]}, {"w": "shifting", "b": [0.2019, 0.6716, 0.2656, 0.693]}, {"w": "the", "b": [0.2711, 0.6716, 0.2975, 0.693]}, {"w": "training", "b": [0.303, 0.6716, 0.37, 0.693]}, {"w": "images", "b": [0.3755, 0.6716, 0.4336, 0.693]}, {"w": "by", "b": [0.4391, 0.6716, 0.4593, 0.693]}, {"w": "various", "b": [0.4649, 0.6716, 0.5263, 0.693]}, {"w": "offsets,", "b": [0.5319, 0.6716, 0.5901, 0.693]}, {"w": "flipping", "b": [0.5956, 0.6716, 0.6612, 0.693]}, {"w": "them", "b": [0.6668, 0.6716, 0.7102, 0.693]}, {"w": "horizontally,", "b": [0.7158, 0.6716, 0.82, 0.693]}, {"w": "and", "b": [0.8256, 0.6716, 0.8571, 0.693]}, {"w": "changing", "b": [0.1429, 0.6906, 0.2198, 0.7121]}, {"w": "the", "b": [0.2245, 0.6906, 0.2509, 0.7121]}, {"w": "lighting", "b": [0.2556, 0.6906, 0.32, 0.7121]}, {"w": "conditions.", "b": [0.3247, 0.6906, 0.4185, 0.7121]}]}, {"id": "b_17", "type": "paragraph", "text": "Data Augmentation", "words": [{"w": "Data", "b": [0.4032, 0.7378, 0.4493, 0.765]}, {"w": "Augmentation", "b": [0.454, 0.7378, 0.5968, 0.765]}]}, {"id": "b_18", "type": "paragraph", "text": "Data augmentation artificially increases the size of the training set by generating many realistic variants of each training instance. This reduces overfitting, making this a regularization technique. The generated instances should be as realistic as possible:", "words": [{"w": "Data", "b": [0.1592, 0.7695, 0.1969, 0.7899]}, {"w": "augmentation", "b": [0.2057, 0.7695, 0.3158, 0.7899]}, {"w": "artificially", "b": [0.3246, 0.7695, 0.4048, 0.7899]}, {"w": "increases", "b": [0.4136, 0.7695, 0.4857, 0.7899]}, {"w": "the", "b": [0.4945, 0.7695, 0.5196, 0.7899]}, {"w": "size", "b": [0.5284, 0.7695, 0.5578, 0.7899]}, {"w": "of", "b": [0.5666, 0.7695, 0.5826, 0.7899]}, {"w": "the", "b": [0.5915, 0.7695, 0.6165, 0.7899]}, {"w": "training", "b": [0.6254, 0.7695, 0.6891, 0.7899]}, {"w": "set", "b": [0.698, 0.7695, 0.7197, 0.7899]}, {"w": "by", "b": [0.7286, 0.7695, 0.7477, 0.7899]}, {"w": "generating", "b": [0.7566, 0.7695, 0.8408, 0.7899]}, {"w": "many", "b": [0.1592, 0.7877, 0.2037, 0.8081]}, {"w": "realistic", "b": [0.2084, 0.7877, 0.2703, 0.8081]}, {"w": "variants", "b": [0.275, 0.7877, 0.3381, 0.8081]}, {"w": "of", "b": [0.3427, 0.7877, 0.3587, 0.8081]}, {"w": "each", "b": [0.3634, 0.7877, 0.3996, 0.8081]}, {"w": "training", "b": [0.4043, 0.7877, 0.468, 0.8081]}, {"w": "instance.", "b": [0.4727, 0.7877, 0.5431, 0.8081]}, {"w": "This", "b": [0.5478, 0.7877, 0.5832, 0.8081]}, {"w": "reduces", "b": [0.5879, 0.7877, 0.6488, 0.8081]}, {"w": "overfitting,", "b": [0.6535, 0.7877, 0.7419, 0.8081]}, {"w": "making", "b": [0.7466, 0.7877, 0.8068, 0.8081]}, {"w": "this", "b": [0.8115, 0.7877, 0.8408, 0.8081]}, {"w": "a", "b": [0.1592, 0.8058, 0.1679, 0.8262]}, {"w": "regularization", "b": [0.1735, 0.8058, 0.2846, 0.8262]}, {"w": "technique.", "b": [0.2902, 0.8058, 0.3734, 0.8262]}, {"w": "The", "b": [0.379, 0.8058, 0.4103, 0.8262]}, {"w": "generated", "b": [0.4159, 0.8058, 0.4936, 0.8262]}, {"w": "instances", "b": [0.4992, 0.8058, 0.5723, 0.8262]}, {"w": "should", "b": [0.5779, 0.8058, 0.632, 0.8262]}, {"w": "be", "b": [0.6376, 0.8058, 0.6561, 0.8262]}, {"w": "as", "b": [0.6617, 0.8058, 0.6777, 0.8262]}, {"w": "realistic", "b": [0.6833, 0.8058, 0.7451, 0.8262]}, {"w": "as", "b": [0.7507, 0.8058, 0.7667, 0.8262]}, {"w": "possible:", "b": [0.7723, 0.8058, 0.8408, 0.8262]}]}, {"id": "b_19", "type": "paragraph", "text": "450 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "450", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 477, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "ideally, given an image from the augmented training set, a human should not be able to tell whether it was augmented or not. Moreover, simply adding white noise will not help; the modifications should be learnable (white noise is not).", "words": [{"w": "ideally,", "b": [0.1592, 0.0792, 0.2144, 0.0996]}, {"w": "given", "b": [0.2198, 0.0792, 0.2629, 0.0996]}, {"w": "an", "b": [0.2683, 0.0792, 0.2878, 0.0996]}, {"w": "image", "b": [0.2932, 0.0792, 0.3412, 0.0996]}, {"w": "from", "b": [0.3466, 0.0792, 0.3862, 0.0996]}, {"w": "the", "b": [0.3916, 0.0792, 0.4167, 0.0996]}, {"w": "augmented", "b": [0.4221, 0.0792, 0.5104, 0.0996]}, {"w": "training", "b": [0.5158, 0.0792, 0.5796, 0.0996]}, {"w": "set,", "b": [0.585, 0.0792, 0.6113, 0.0996]}, {"w": "a", "b": [0.6167, 0.0792, 0.6254, 0.0996]}, {"w": "human", "b": [0.6308, 0.0792, 0.6873, 0.0996]}, {"w": "should", "b": [0.6928, 0.0792, 0.7468, 0.0996]}, {"w": "not", "b": [0.7522, 0.0792, 0.7792, 0.0996]}, {"w": "be", "b": [0.7846, 0.0792, 0.8031, 0.0996]}, {"w": "able", "b": [0.8085, 0.0792, 0.8408, 0.0996]}, {"w": "to", "b": [0.1592, 0.0973, 0.1754, 0.1177]}, {"w": "tell", "b": [0.1801, 0.0973, 0.2046, 0.1177]}, {"w": "whether", "b": [0.2094, 0.0973, 0.2744, 0.1177]}, {"w": "it", "b": [0.2791, 0.0973, 0.2905, 0.1177]}, {"w": "was", "b": [0.2952, 0.0973, 0.3248, 0.1177]}, {"w": "augmented", "b": [0.3295, 0.0973, 0.4178, 0.1177]}, {"w": "or", "b": [0.4225, 0.0973, 0.44, 0.1177]}, {"w": "not.", "b": [0.4447, 0.0973, 0.4762, 0.1177]}, {"w": "Moreover,", "b": [0.481, 0.0973, 0.5624, 0.1177]}, {"w": "simply", "b": [0.5671, 0.0973, 0.6201, 0.1177]}, {"w": "adding", "b": [0.6248, 0.0973, 0.6799, 0.1177]}, {"w": "white", "b": [0.6847, 0.0973, 0.7287, 0.1177]}, {"w": "noise", "b": [0.7334, 0.0973, 0.7754, 0.1177]}, {"w": "will", "b": [0.7801, 0.0973, 0.809, 0.1177]}, {"w": "not", "b": [0.8137, 0.0973, 0.8408, 0.1177]}, {"w": "help;", "b": [0.1592, 0.1155, 0.1982, 0.1359]}, {"w": "the", "b": [0.2027, 0.1155, 0.2278, 0.1359]}, {"w": "modifications", "b": [0.2323, 0.1155, 0.342, 0.1359]}, {"w": "should", "b": [0.3465, 0.1155, 0.4005, 0.1359]}, {"w": "be", "b": [0.405, 0.1155, 0.4235, 0.1359]}, {"w": "learnable", "b": [0.428, 0.1155, 0.5007, 0.1359]}, {"w": "(white", "b": [0.5052, 0.1155, 0.556, 0.1359]}, {"w": "noise", "b": [0.5605, 0.1155, 0.6025, 0.1359]}, {"w": "is", "b": [0.607, 0.1155, 0.6196, 0.1359]}, {"w": "not).", "b": [0.6241, 0.1155, 0.6625, 0.1359]}]}, {"id": "b_1", "type": "paragraph", "text": "For example, you can slightly shift, rotate, and resize every picture in the training set by various amounts and add the resulting pictures to the training set (see Figure 14-12). This forces the model to be more tolerant to variations in the position, orientation, and size of the objects in the pictures. If you want the model to be more tolerant to different lighting conditions, you can similarly generate many images with various contrasts. In general, you can also flip the pictures horizontally (except for text, and other non-symmetrical objects). By combining these transformations you can greatly increase the size of your training set.", "words": [{"w": "For", "b": [0.1592, 0.1427, 0.1868, 0.1631]}, {"w": "example,", "b": [0.1923, 0.1427, 0.263, 0.1631]}, {"w": "you", "b": [0.2685, 0.1427, 0.2982, 0.1631]}, {"w": "can", "b": [0.3037, 0.1427, 0.3316, 0.1631]}, {"w": "slightly", "b": [0.337, 0.1427, 0.3943, 0.1631]}, {"w": "shift,", "b": [0.3998, 0.1427, 0.4394, 0.1631]}, {"w": "rotate,", "b": [0.4449, 0.1427, 0.4957, 0.1631]}, {"w": "and", "b": [0.5012, 0.1427, 0.5312, 0.1631]}, {"w": "resize", "b": [0.5366, 0.1427, 0.5818, 0.1631]}, {"w": "every", "b": [0.5872, 0.1427, 0.6303, 0.1631]}, {"w": "picture", "b": [0.6358, 0.1427, 0.6923, 0.1631]}, {"w": "in", "b": [0.6977, 0.1427, 0.7139, 0.1631]}, {"w": "the", "b": [0.7193, 0.1427, 0.7444, 0.1631]}, {"w": "training", "b": [0.7498, 0.1427, 0.8136, 0.1631]}, {"w": "set", "b": [0.819, 0.1427, 0.8408, 0.1631]}, {"w": "by", "b": [0.1592, 0.1608, 0.1784, 0.1812]}, {"w": "various", "b": [0.1916, 0.1608, 0.2501, 0.1812]}, {"w": "amounts", "b": [0.2633, 0.1608, 0.3327, 0.1812]}, {"w": "and", "b": [0.3458, 0.1608, 0.3759, 0.1812]}, {"w": "add", "b": [0.389, 0.1608, 0.4187, 0.1812]}, {"w": "the", "b": [0.4319, 0.1608, 0.4569, 0.1812]}, {"w": "resulting", "b": [0.4701, 0.1608, 0.5402, 0.1812]}, {"w": "pictures", "b": [0.5534, 0.1608, 0.6172, 0.1812]}, {"w": "to", "b": [0.6303, 0.1608, 0.6465, 0.1812]}, {"w": "the", "b": [0.6597, 0.1608, 0.6848, 0.1812]}, {"w": "training", "b": [0.6979, 0.1608, 0.7617, 0.1812]}, {"w": "set", "b": [0.7748, 0.1608, 0.7966, 0.1812]}, {"w": "(see", "b": [0.8098, 0.1608, 0.8408, 0.1812]}, {"w": "Figure", "b": [0.1592, 0.179, 0.2107, 0.1993]}, {"w": "14-12).", "b": [0.2152, 0.179, 0.2722, 0.1993]}, {"w": "This", "b": [0.2772, 0.179, 0.3127, 0.1993]}, {"w": "forces", "b": [0.3177, 0.179, 0.3652, 0.1993]}, {"w": "the", "b": [0.3702, 0.179, 0.3953, 0.1993]}, {"w": "model", "b": [0.4003, 0.179, 0.4506, 0.1993]}, {"w": "to", "b": [0.4556, 0.179, 0.4718, 0.1993]}, {"w": "be", "b": [0.4768, 0.179, 0.4953, 0.1993]}, {"w": "more", "b": [0.5003, 0.179, 0.5425, 0.1993]}, {"w": "tolerant", "b": [0.5475, 0.179, 0.6097, 0.1993]}, {"w": "to", "b": [0.6148, 0.179, 0.6309, 0.1993]}, {"w": "variations", "b": [0.6359, 0.179, 0.7145, 0.1993]}, {"w": "in", "b": [0.7195, 0.179, 0.7357, 0.1993]}, {"w": "the", "b": [0.7407, 0.179, 0.7658, 0.1993]}, {"w": "position,", "b": [0.7708, 0.179, 0.8408, 0.1993]}, {"w": "orientation,", "b": [0.1592, 0.1971, 0.2522, 0.2175]}, {"w": "and", "b": [0.2578, 0.1971, 0.2878, 0.2175]}, {"w": "size", "b": [0.2934, 0.1971, 0.3228, 0.2175]}, {"w": "of", "b": [0.3284, 0.1971, 0.3444, 0.2175]}, {"w": "the", "b": [0.35, 0.1971, 0.3751, 0.2175]}, {"w": "objects", "b": [0.3807, 0.1971, 0.4361, 0.2175]}, {"w": "in", "b": [0.4417, 0.1971, 0.4579, 0.2175]}, {"w": "the", "b": [0.4635, 0.1971, 0.4886, 0.2175]}, {"w": "pictures.", "b": [0.4942, 0.1971, 0.5625, 0.2175]}, {"w": "If", "b": [0.5681, 0.1971, 0.5807, 0.2175]}, {"w": "you", "b": [0.5863, 0.1971, 0.6161, 0.2175]}, {"w": "want", "b": [0.6217, 0.1971, 0.6605, 0.2175]}, {"w": "the", "b": [0.6661, 0.1971, 0.6912, 0.2175]}, {"w": "model", "b": [0.6968, 0.1971, 0.7471, 0.2175]}, {"w": "to", "b": [0.7527, 0.1971, 0.7689, 0.2175]}, {"w": "be", "b": [0.7745, 0.1971, 0.793, 0.2175]}, {"w": "more", "b": [0.7986, 0.1971, 0.8408, 0.2175]}, {"w": "tolerant", "b": [0.1592, 0.2152, 0.2214, 0.2356]}, {"w": "to", "b": [0.2264, 0.2152, 0.2426, 0.2356]}, {"w": "different", "b": [0.2475, 0.2152, 0.3158, 0.2356]}, {"w": "lighting", "b": [0.3208, 0.2152, 0.3822, 0.2356]}, {"w": "conditions,", "b": [0.3871, 0.2152, 0.4764, 0.2356]}, {"w": "you", "b": [0.4814, 0.2152, 0.5112, 0.2356]}, {"w": "can", "b": [0.5161, 0.2152, 0.5441, 0.2356]}, {"w": "similarly", "b": [0.549, 0.2152, 0.6184, 0.2356]}, {"w": "generate", "b": [0.6234, 0.2152, 0.6906, 0.2356]}, {"w": "many", "b": [0.6955, 0.2152, 0.74, 0.2356]}, {"w": "images", "b": [0.745, 0.2152, 0.8003, 0.2356]}, {"w": "with", "b": [0.8052, 0.2152, 0.8408, 0.2356]}, {"w": "various", "b": [0.1592, 0.2334, 0.2177, 0.2538]}, {"w": "contrasts.", "b": [0.2248, 0.2334, 0.301, 0.2538]}, {"w": "In", "b": [0.3081, 0.2334, 0.3257, 0.2538]}, {"w": "general,", "b": [0.3328, 0.2334, 0.3954, 0.2538]}, {"w": "you", "b": [0.4025, 0.2334, 0.4322, 0.2538]}, {"w": "can", "b": [0.4393, 0.2334, 0.4672, 0.2538]}, {"w": "also", "b": [0.4743, 0.2334, 0.5054, 0.2538]}, {"w": "flip", "b": [0.5125, 0.2334, 0.5391, 0.2538]}, {"w": "the", "b": [0.5462, 0.2334, 0.5712, 0.2538]}, {"w": "pictures", "b": [0.5783, 0.2334, 0.6421, 0.2538]}, {"w": "horizontally", "b": [0.6491, 0.2334, 0.7454, 0.2538]}, {"w": "(except", "b": [0.7524, 0.2334, 0.8104, 0.2538]}, {"w": "for", "b": [0.8174, 0.2334, 0.8408, 0.2538]}, {"w": "text,", "b": [0.1592, 0.2515, 0.1936, 0.2719]}, {"w": "and", "b": [0.2009, 0.2515, 0.2309, 0.2719]}, {"w": "other", "b": [0.2381, 0.2515, 0.2807, 0.2719]}, {"w": "non-symmetrical", "b": [0.2879, 0.2515, 0.425, 0.2719]}, {"w": "objects).", "b": [0.4322, 0.2515, 0.499, 0.2719]}, {"w": "By", "b": [0.5063, 0.2515, 0.527, 0.2719]}, {"w": "combining", "b": [0.5343, 0.2515, 0.6207, 0.2719]}, {"w": "these", "b": [0.628, 0.2515, 0.6687, 0.2719]}, {"w": "transformations", "b": [0.676, 0.2515, 0.8038, 0.2719]}, {"w": "you", "b": [0.811, 0.2515, 0.8408, 0.2719]}, {"w": "can", "b": [0.1592, 0.2697, 0.1872, 0.2901]}, {"w": "greatly", "b": [0.1917, 0.2697, 0.2453, 0.2901]}, {"w": "increase", "b": [0.2498, 0.2697, 0.3146, 0.2901]}, {"w": "the", "b": [0.3191, 0.2697, 0.3441, 0.2901]}, {"w": "size", "b": [0.3486, 0.2697, 0.378, 0.2901]}, {"w": "of", "b": [0.3825, 0.2697, 0.3985, 0.2901]}, {"w": "your", "b": [0.403, 0.2697, 0.4401, 0.2901]}, {"w": "training", "b": [0.4446, 0.2697, 0.5084, 0.2901]}, {"w": "set.", "b": [0.5129, 0.2697, 0.5392, 0.2901]}]}, {"id": "b_2", "type": "equation", "text": "Figure 14-12. Generating new training instances from existing ones", "words": [{"w": "Figure", "b": [0.1592, 0.637, 0.2082, 0.6576]}, {"w": "14-12.", "b": [0.2128, 0.637, 0.2619, 0.6576]}, {"w": "Generating", "b": [0.2664, 0.637, 0.3522, 0.6576]}, {"w": "new", "b": [0.3567, 0.637, 0.3885, 0.6576]}, {"w": "training", "b": [0.393, 0.637, 0.4544, 0.6576]}, {"w": "instances", "b": [0.4589, 0.637, 0.5287, 0.6576]}, {"w": "from", "b": [0.5333, 0.637, 0.5705, 0.6576]}, {"w": "existing", "b": [0.575, 0.637, 0.634, 0.6576]}, {"w": "ones", "b": [0.6385, 0.637, 0.6726, 0.6576]}]}, {"id": "b_3", "type": "paragraph", "text": "AlexNet also uses a competitive normalization step immediately after the ReLU step of layers C1 and C3, called local response normalization. The most strongly activated neurons inhibit other neurons located at the same position in neighboring feature maps (such competitive activation has been observed in biological neurons). This encourages different feature maps to specialize, pushing them apart and forcing them", "words": [{"w": "AlexNet", "b": [0.1428, 0.6964, 0.2114, 0.7178]}, {"w": "also", "b": [0.2176, 0.6964, 0.2503, 0.7178]}, {"w": "uses", "b": [0.2565, 0.6964, 0.2917, 0.7178]}, {"w": "a", "b": [0.298, 0.6964, 0.3071, 0.7178]}, {"w": "competitive", "b": [0.3134, 0.6964, 0.4116, 0.7178]}, {"w": "normalization", "b": [0.4179, 0.6964, 0.5361, 0.7178]}, {"w": "step", "b": [0.5424, 0.6964, 0.5761, 0.7178]}, {"w": "immediately", "b": [0.5824, 0.6964, 0.6863, 0.7178]}, {"w": "after", "b": [0.6926, 0.6964, 0.7308, 0.7178]}, {"w": "the", "b": [0.7371, 0.6964, 0.7634, 0.7178]}, {"w": "ReLU", "b": [0.7696, 0.6964, 0.8171, 0.7178]}, {"w": "step", "b": [0.8234, 0.6964, 0.8571, 0.7178]}, {"w": "of", "b": [0.1429, 0.7155, 0.1597, 0.7369]}, {"w": "layers", "b": [0.1657, 0.7155, 0.2136, 0.7369]}, {"w": "C1", "b": [0.2196, 0.7155, 0.2435, 0.7369]}, {"w": "and", "b": [0.2495, 0.7155, 0.2811, 0.7369]}, {"w": "C3,", "b": [0.2872, 0.7155, 0.3158, 0.7369]}, {"w": "called", "b": [0.3218, 0.7155, 0.3702, 0.7369]}, {"w": "local", "b": [0.3762, 0.7153, 0.414, 0.7369]}, {"w": "response", "b": [0.4201, 0.7153, 0.4885, 0.7369]}, {"w": "normalization.", "b": [0.4946, 0.7153, 0.6155, 0.7369]}, {"w": "The", "b": [0.6216, 0.7155, 0.6544, 0.7369]}, {"w": "most", "b": [0.6605, 0.7155, 0.7022, 0.7369]}, {"w": "strongly", "b": [0.7082, 0.7155, 0.7766, 0.7369]}, {"w": "activated", "b": [0.7827, 0.7155, 0.8572, 0.7369]}, {"w": "neurons", "b": [0.1429, 0.7345, 0.2116, 0.7559]}, {"w": "inhibit", "b": [0.2194, 0.7345, 0.2756, 0.7559]}, {"w": "other", "b": [0.2835, 0.7345, 0.3282, 0.7559]}, {"w": "neurons", "b": [0.336, 0.7345, 0.4047, 0.7559]}, {"w": "located", "b": [0.4126, 0.7345, 0.4722, 0.7559]}, {"w": "at", "b": [0.4801, 0.7345, 0.4952, 0.7559]}, {"w": "the", "b": [0.503, 0.7345, 0.5294, 0.7559]}, {"w": "same", "b": [0.5372, 0.7345, 0.5799, 0.7559]}, {"w": "position", "b": [0.5878, 0.7345, 0.6565, 0.7559]}, {"w": "in", "b": [0.6643, 0.7345, 0.6813, 0.7559]}, {"w": "neighboring", "b": [0.6892, 0.7345, 0.7915, 0.7559]}, {"w": "feature", "b": [0.7994, 0.7345, 0.8571, 0.7559]}, {"w": "maps", "b": [0.1429, 0.7536, 0.1872, 0.775]}, {"w": "(such", "b": [0.1957, 0.7536, 0.2415, 0.775]}, {"w": "competitive", "b": [0.2499, 0.7536, 0.3482, 0.775]}, {"w": "activation", "b": [0.3566, 0.7536, 0.4389, 0.775]}, {"w": "has", "b": [0.4473, 0.7536, 0.4752, 0.775]}, {"w": "been", "b": [0.4837, 0.7536, 0.5233, 0.775]}, {"w": "observed", "b": [0.5318, 0.7536, 0.6073, 0.775]}, {"w": "in", "b": [0.6157, 0.7536, 0.6327, 0.775]}, {"w": "biological", "b": [0.6412, 0.7536, 0.7224, 0.775]}, {"w": "neurons).", "b": [0.7308, 0.7536, 0.8115, 0.775]}, {"w": "This", "b": [0.8199, 0.7536, 0.8571, 0.775]}, {"w": "encourages", "b": [0.1428, 0.7726, 0.2367, 0.794]}, {"w": "different", "b": [0.2419, 0.7726, 0.3136, 0.794]}, {"w": "feature", "b": [0.3187, 0.7726, 0.3765, 0.794]}, {"w": "maps", "b": [0.3816, 0.7726, 0.426, 0.794]}, {"w": "to", "b": [0.4312, 0.7726, 0.4482, 0.794]}, {"w": "specialize,", "b": [0.4533, 0.7726, 0.5375, 0.794]}, {"w": "pushing", "b": [0.5426, 0.7726, 0.6101, 0.794]}, {"w": "them", "b": [0.6152, 0.7726, 0.6586, 0.794]}, {"w": "apart", "b": [0.6638, 0.7726, 0.7067, 0.794]}, {"w": "and", "b": [0.7118, 0.7726, 0.7434, 0.794]}, {"w": "forcing", "b": [0.7485, 0.7726, 0.8086, 0.794]}, {"w": "them", "b": [0.8137, 0.7726, 0.8571, 0.794]}]}, {"id": "b_4", "type": "paragraph", "text": "CNN Architectures | 451", "words": [{"w": "CNN", "b": [0.6908, 0.9225, 0.7152, 0.9388]}, {"w": "Architectures", "b": [0.7181, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "451", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 478, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "12 “Going Deeper with Convolutions,” C. Szegedy et al. (2015).", "words": [{"w": "12", "b": [0.1385, 0.8416, 0.1518, 0.8559]}, {"w": "“Going", "b": [0.1587, 0.8401, 0.2043, 0.8565]}, {"w": "Deeper", "b": [0.2079, 0.8401, 0.254, 0.8565]}, {"w": "with", "b": [0.2576, 0.8401, 0.286, 0.8565]}, {"w": "Convolutions,”", "b": [0.2897, 0.8401, 0.384, 0.8565]}, {"w": "C.", "b": [0.3876, 0.8401, 0.4018, 0.8565]}, {"w": "Szegedy", "b": [0.4054, 0.8401, 0.4562, 0.8565]}, {"w": "et", "b": [0.4598, 0.8401, 0.4713, 0.8565]}, {"w": "al.", "b": [0.475, 0.8401, 0.4896, 0.8565]}, {"w": "(2015).", "b": [0.4932, 0.8401, 0.5382, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "13 In the 2010 movie Inception, the characters keep going deeper and deeper into multiple layers of dreams, hence the name of these modules.", "words": [{"w": "13", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "In", "b": [0.1587, 0.8598, 0.1728, 0.8761]}, {"w": "the", "b": [0.1764, 0.8598, 0.1965, 0.8761]}, {"w": "2010", "b": [0.2001, 0.8598, 0.2306, 0.8761]}, {"w": "movie", "b": [0.2342, 0.8598, 0.2736, 0.8761]}, {"w": "Inception,", "b": [0.2772, 0.8596, 0.3384, 0.8761]}, {"w": "the", "b": [0.342, 0.8598, 0.362, 0.8761]}, {"w": "characters", "b": [0.3657, 0.8598, 0.4307, 0.8761]}, {"w": "keep", "b": [0.4343, 0.8598, 0.464, 0.8761]}, {"w": "going", "b": [0.4676, 0.8598, 0.5035, 0.8761]}, {"w": "deeper", "b": [0.5071, 0.8598, 0.5499, 0.8761]}, {"w": "and", "b": [0.5535, 0.8598, 0.5775, 0.8761]}, {"w": "deeper", "b": [0.5811, 0.8598, 0.624, 0.8761]}, {"w": "into", "b": [0.6276, 0.8598, 0.6531, 0.8761]}, {"w": "multiple", "b": [0.6567, 0.8598, 0.71, 0.8761]}, {"w": "layers", "b": [0.7137, 0.8598, 0.7501, 0.8761]}, {"w": "of", "b": [0.7537, 0.8598, 0.7665, 0.8761]}, {"w": "dreams,", "b": [0.7701, 0.8598, 0.8205, 0.8761]}, {"w": "hence", "b": [0.1587, 0.8749, 0.1961, 0.8912]}, {"w": "the", "b": [0.1997, 0.8749, 0.2198, 0.8912]}, {"w": "name", "b": [0.2234, 0.8749, 0.2588, 0.8912]}, {"w": "of", "b": [0.2624, 0.8749, 0.2752, 0.8912]}, {"w": "these", "b": [0.2788, 0.8749, 0.3114, 0.8912]}, {"w": "modules.", "b": [0.315, 0.8749, 0.3731, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "to explore a wider range of features, ultimately improving generalization. Equation 14-2 shows how to apply LRN.", "words": [{"w": "to", "b": [0.1429, 0.0791, 0.1598, 0.1005]}, {"w": "explore", "b": [0.1672, 0.0791, 0.2293, 0.1005]}, {"w": "a", "b": [0.2367, 0.0791, 0.2458, 0.1005]}, {"w": "wider", "b": [0.2532, 0.0791, 0.3006, 0.1005]}, {"w": "range", "b": [0.308, 0.0791, 0.3549, 0.1005]}, {"w": "of", "b": [0.3623, 0.0791, 0.379, 0.1005]}, {"w": "features,", "b": [0.3864, 0.0791, 0.4566, 0.1005]}, {"w": "ultimately", "b": [0.464, 0.0791, 0.5481, 0.1005]}, {"w": "improving", "b": [0.5555, 0.0791, 0.6434, 0.1005]}, {"w": "generalization.", "b": [0.6507, 0.0791, 0.7735, 0.1005]}, {"w": "Equation", "b": [0.7809, 0.0791, 0.8571, 0.1005]}, {"w": "14-2", "b": [0.1429, 0.0981, 0.1803, 0.1195]}, {"w": "shows", "b": [0.185, 0.0981, 0.2363, 0.1195]}, {"w": "how", "b": [0.241, 0.0981, 0.2771, 0.1195]}, {"w": "to", "b": [0.2818, 0.0981, 0.2988, 0.1195]}, {"w": "apply", "b": [0.3035, 0.0981, 0.3489, 0.1195]}, {"w": "LRN.", "b": [0.3536, 0.0981, 0.398, 0.1195]}]}, {"id": "b_3", "type": "equation", "text": "Equation 14-2. Local response normalization", "words": [{"w": "Equation", "b": [0.1726, 0.1376, 0.2473, 0.1593]}, {"w": "14-2.", "b": [0.2521, 0.1376, 0.2937, 0.1593]}, {"w": "Local", "b": [0.2985, 0.1376, 0.3423, 0.1593]}, {"w": "response", "b": [0.3471, 0.1376, 0.4155, 0.1593]}, {"w": "normalization", "b": [0.4202, 0.1376, 0.5364, 0.1593]}]}, {"id": "b_4", "type": "equation", "text": "bi = ai k + α ∑", "words": [{"w": "bi", "b": [0.1726, 0.1939, 0.1866, 0.2188]}, {"w": "=", "b": [0.1921, 0.1941, 0.2036, 0.2145]}, {"w": "ai", "b": [0.2091, 0.1939, 0.2232, 0.2188]}, {"w": "k", "b": [0.23, 0.1939, 0.2394, 0.2145]}, {"w": "+", "b": [0.2438, 0.1941, 0.2553, 0.2145]}, {"w": "α", "b": [0.2597, 0.1939, 0.2703, 0.2145]}, {"w": "∑", "b": [0.2903, 0.1894, 0.3053, 0.2182]}]}, {"id": "b_5", "type": "equation", "text": "j = jlow", "words": [{"w": "j", "b": [0.273, 0.2088, 0.2773, 0.2253]}, {"w": "=", "b": [0.2817, 0.209, 0.2909, 0.2253]}, {"w": "jlow", "b": [0.2969, 0.2088, 0.3241, 0.2313]}]}, {"id": "b_6", "type": "paragraph", "text": "jhigh", "words": [{"w": "jhigh", "b": [0.2821, 0.1751, 0.315, 0.1976]}]}, {"id": "b_10", "type": "paragraph", "text": "with", "words": [{"w": "with", "b": [0.3947, 0.1941, 0.4303, 0.2145]}]}, {"id": "b_11", "type": "equation", "text": "jhigh = min i + r", "words": [{"w": "jhigh", "b": [0.4471, 0.1742, 0.481, 0.1991]}, {"w": "=", "b": [0.4865, 0.1744, 0.498, 0.1948]}, {"w": "min", "b": [0.5091, 0.1744, 0.5415, 0.1948]}, {"w": "i", "b": [0.5539, 0.1742, 0.5593, 0.1948]}, {"w": "+", "b": [0.5637, 0.1744, 0.5752, 0.1948]}, {"w": "r", "b": [0.5827, 0.1654, 0.59, 0.186]}]}, {"id": "b_12", "type": "paragraph", "text": "2, f n −1", "words": [{"w": "2,", "b": [0.5818, 0.1744, 0.5981, 0.2036]}, {"w": "f", "b": [0.6041, 0.1742, 0.6095, 0.1948]}, {"w": "n", "b": [0.6126, 0.1826, 0.621, 0.1991]}, {"w": "−1", "b": [0.6254, 0.1744, 0.6509, 0.1948]}]}, {"id": "b_13", "type": "equation", "text": "jlow = max 0, i −r", "words": [{"w": "jlow", "b": [0.4471, 0.2136, 0.4754, 0.2385]}, {"w": "=", "b": [0.4809, 0.2138, 0.4924, 0.2342]}, {"w": "max", "b": [0.5034, 0.2138, 0.5377, 0.2342]}, {"w": "0,", "b": [0.5501, 0.2138, 0.5642, 0.2342]}, {"w": "i", "b": [0.5675, 0.2136, 0.5729, 0.2342]}, {"w": "−r", "b": [0.5773, 0.2048, 0.6036, 0.2342]}]}, {"id": "b_15", "type": "paragraph", "text": "• bi is the normalized output of the neuron located in feature map i, at some row u and column v (note that in this equation we consider only neurons located at this row and column, so u and v are not shown).", "words": [{"w": "•", "b": [0.16, 0.2679, 0.1682, 0.2893]}, {"w": "bi", "b": [0.1786, 0.2677, 0.1921, 0.2902]}, {"w": "is", "b": [0.1974, 0.2679, 0.2106, 0.2893]}, {"w": "the", "b": [0.216, 0.2679, 0.2423, 0.2893]}, {"w": "normalized", "b": [0.2476, 0.2679, 0.343, 0.2893]}, {"w": "output", "b": [0.3483, 0.2679, 0.4047, 0.2893]}, {"w": "of", "b": [0.41, 0.2679, 0.4268, 0.2893]}, {"w": "the", "b": [0.4321, 0.2679, 0.4584, 0.2893]}, {"w": "neuron", "b": [0.4637, 0.2679, 0.5248, 0.2893]}, {"w": "located", "b": [0.5301, 0.2679, 0.5898, 0.2893]}, {"w": "in", "b": [0.5951, 0.2679, 0.612, 0.2893]}, {"w": "feature", "b": [0.6174, 0.2679, 0.6751, 0.2893]}, {"w": "map", "b": [0.6804, 0.2679, 0.7172, 0.2893]}, {"w": "i,", "b": [0.7225, 0.2677, 0.7329, 0.2893]}, {"w": "at", "b": [0.7382, 0.2679, 0.7533, 0.2893]}, {"w": "some", "b": [0.7586, 0.2679, 0.8028, 0.2893]}, {"w": "row", "b": [0.8081, 0.2679, 0.8407, 0.2893]}, {"w": "u", "b": [0.846, 0.2677, 0.8571, 0.2893]}, {"w": "and", "b": [0.1786, 0.2869, 0.2101, 0.3083]}, {"w": "column", "b": [0.2149, 0.2869, 0.2791, 0.3083]}, {"w": "v", "b": [0.2843, 0.2867, 0.2936, 0.3083]}, {"w": "(note", "b": [0.2986, 0.2869, 0.343, 0.3083]}, {"w": "that", "b": [0.348, 0.2869, 0.3806, 0.3083]}, {"w": "in", "b": [0.3856, 0.2869, 0.4025, 0.3083]}, {"w": "this", "b": [0.4075, 0.2869, 0.4382, 0.3083]}, {"w": "equation", "b": [0.4432, 0.2869, 0.5165, 0.3083]}, {"w": "we", "b": [0.5215, 0.2869, 0.5446, 0.3083]}, {"w": "consider", "b": [0.5496, 0.2869, 0.6212, 0.3083]}, {"w": "only", "b": [0.6262, 0.2869, 0.663, 0.3083]}, {"w": "neurons", "b": [0.668, 0.2869, 0.7367, 0.3083]}, {"w": "located", "b": [0.7417, 0.2869, 0.8014, 0.3083]}, {"w": "at", "b": [0.8063, 0.2869, 0.8214, 0.3083]}, {"w": "this", "b": [0.8264, 0.2869, 0.8571, 0.3083]}, {"w": "row", "b": [0.1786, 0.306, 0.2112, 0.3274]}, {"w": "and", "b": [0.2159, 0.306, 0.2475, 0.3274]}, {"w": "column,", "b": [0.2522, 0.306, 0.3212, 0.3274]}, {"w": "so", "b": [0.3259, 0.306, 0.3442, 0.3274]}, {"w": "u", "b": [0.3489, 0.3057, 0.36, 0.3274]}, {"w": "and", "b": [0.3647, 0.306, 0.3963, 0.3274]}, {"w": "v", "b": [0.401, 0.3057, 0.4103, 0.3274]}, {"w": "are", "b": [0.4151, 0.306, 0.4408, 0.3274]}, {"w": "not", "b": [0.4455, 0.306, 0.4739, 0.3274]}, {"w": "shown).", "b": [0.4786, 0.306, 0.5456, 0.3274]}]}, {"id": "b_16", "type": "paragraph", "text": "• ai is the activation of that neuron after the ReLU step, but before normalization.", "words": [{"w": "•", "b": [0.16, 0.331, 0.1682, 0.3525]}, {"w": "ai", "b": [0.1786, 0.3308, 0.1922, 0.3533]}, {"w": "is", "b": [0.1969, 0.331, 0.2101, 0.3525]}, {"w": "the", "b": [0.2149, 0.331, 0.2412, 0.3525]}, {"w": "activation", "b": [0.2459, 0.331, 0.3282, 0.3525]}, {"w": "of", "b": [0.3329, 0.331, 0.3497, 0.3525]}, {"w": "that", "b": [0.3544, 0.331, 0.387, 0.3525]}, {"w": "neuron", "b": [0.3917, 0.331, 0.4528, 0.3525]}, {"w": "after", "b": [0.4575, 0.331, 0.4958, 0.3525]}, {"w": "the", "b": [0.5005, 0.331, 0.5269, 0.3525]}, {"w": "ReLU", "b": [0.5316, 0.331, 0.5791, 0.3525]}, {"w": "step,", "b": [0.5838, 0.331, 0.6217, 0.3525]}, {"w": "but", "b": [0.6265, 0.331, 0.6545, 0.3525]}, {"w": "before", "b": [0.6592, 0.331, 0.712, 0.3525]}, {"w": "normalization.", "b": [0.7167, 0.331, 0.8397, 0.3525]}]}, {"id": "b_17", "type": "paragraph", "text": "• k, α, β, and r are hyperparameters. k is called the bias, and r is called the depth radius.", "words": [{"w": "•", "b": [0.16, 0.3561, 0.1682, 0.3776]}, {"w": "k,", "b": [0.1786, 0.3559, 0.1931, 0.3776]}, {"w": "α,", "b": [0.1998, 0.3559, 0.2157, 0.3776]}, {"w": "β,", "b": [0.2224, 0.3559, 0.2378, 0.3776]}, {"w": "and", "b": [0.2445, 0.3561, 0.2761, 0.3776]}, {"w": "r", "b": [0.2828, 0.3559, 0.2904, 0.3776]}, {"w": "are", "b": [0.2971, 0.3561, 0.3229, 0.3776]}, {"w": "hyperparameters.", "b": [0.3296, 0.3561, 0.4755, 0.3776]}, {"w": "k", "b": [0.4822, 0.3559, 0.492, 0.3776]}, {"w": "is", "b": [0.4987, 0.3561, 0.5119, 0.3776]}, {"w": "called", "b": [0.5187, 0.3561, 0.567, 0.3776]}, {"w": "the", "b": [0.5737, 0.3561, 0.6001, 0.3776]}, {"w": "bias,", "b": [0.6068, 0.3559, 0.6443, 0.3776]}, {"w": "and", "b": [0.651, 0.3561, 0.6825, 0.3776]}, {"w": "r", "b": [0.6893, 0.3559, 0.6969, 0.3776]}, {"w": "is", "b": [0.7036, 0.3561, 0.7168, 0.3776]}, {"w": "called", "b": [0.7235, 0.3561, 0.7719, 0.3776]}, {"w": "the", "b": [0.7786, 0.3561, 0.8049, 0.3776]}, {"w": "depth", "b": [0.8117, 0.3559, 0.8571, 0.3776]}, {"w": "radius.", "b": [0.1786, 0.375, 0.2346, 0.3966]}]}, {"id": "b_18", "type": "paragraph", "text": "• fn is the number of feature maps.", "words": [{"w": "•", "b": [0.16, 0.4003, 0.1682, 0.4217]}, {"w": "fn", "b": [0.1786, 0.4001, 0.1909, 0.4226]}, {"w": "is", "b": [0.1956, 0.4003, 0.2088, 0.4217]}, {"w": "the", "b": [0.2135, 0.4003, 0.2399, 0.4217]}, {"w": "number", "b": [0.2446, 0.4003, 0.3109, 0.4217]}, {"w": "of", "b": [0.3156, 0.4003, 0.3324, 0.4217]}, {"w": "feature", "b": [0.3372, 0.4003, 0.3949, 0.4217]}, {"w": "maps.", "b": [0.3997, 0.4003, 0.4488, 0.4217]}]}, {"id": "b_19", "type": "paragraph", "text": "For example, if r = 2 and a neuron has a strong activation, it will inhibit the activation of the neurons located in the feature maps immediately above and below its own.", "words": [{"w": "For", "b": [0.1429, 0.4344, 0.1718, 0.4559]}, {"w": "example,", "b": [0.1766, 0.4344, 0.2509, 0.4559]}, {"w": "if", "b": [0.2556, 0.4344, 0.2673, 0.4559]}, {"w": "r", "b": [0.2725, 0.4342, 0.2802, 0.4559]}, {"w": "=", "b": [0.2851, 0.4344, 0.2972, 0.4559]}, {"w": "2", "b": [0.302, 0.4344, 0.312, 0.4559]}, {"w": "and", "b": [0.3169, 0.4344, 0.3485, 0.4559]}, {"w": "a", "b": [0.3534, 0.4344, 0.3625, 0.4559]}, {"w": "neuron", "b": [0.3674, 0.4344, 0.4285, 0.4559]}, {"w": "has", "b": [0.4333, 0.4344, 0.4613, 0.4559]}, {"w": "a", "b": [0.4662, 0.4344, 0.4753, 0.4559]}, {"w": "strong", "b": [0.4802, 0.4344, 0.5337, 0.4559]}, {"w": "activation,", "b": [0.5386, 0.4344, 0.6256, 0.4559]}, {"w": "it", "b": [0.6305, 0.4344, 0.6424, 0.4559]}, {"w": "will", "b": [0.6473, 0.4344, 0.6777, 0.4559]}, {"w": "inhibit", "b": [0.6826, 0.4344, 0.7388, 0.4559]}, {"w": "the", "b": [0.7437, 0.4344, 0.77, 0.4559]}, {"w": "activation", "b": [0.7749, 0.4344, 0.8572, 0.4559]}, {"w": "of", "b": [0.1429, 0.4535, 0.1597, 0.4749]}, {"w": "the", "b": [0.1644, 0.4535, 0.1907, 0.4749]}, {"w": "neurons", "b": [0.1954, 0.4535, 0.2642, 0.4749]}, {"w": "located", "b": [0.2689, 0.4535, 0.3285, 0.4749]}, {"w": "in", "b": [0.3333, 0.4535, 0.3503, 0.4749]}, {"w": "the", "b": [0.355, 0.4535, 0.3813, 0.4749]}, {"w": "feature", "b": [0.386, 0.4535, 0.4438, 0.4749]}, {"w": "maps", "b": [0.4485, 0.4535, 0.4929, 0.4749]}, {"w": "immediately", "b": [0.4977, 0.4535, 0.6016, 0.4749]}, {"w": "above", "b": [0.6063, 0.4535, 0.6552, 0.4749]}, {"w": "and", "b": [0.6599, 0.4535, 0.6914, 0.4749]}, {"w": "below", "b": [0.6962, 0.4535, 0.7458, 0.4749]}, {"w": "its", "b": [0.7505, 0.4535, 0.7701, 0.4749]}, {"w": "own.", "b": [0.7748, 0.4535, 0.8159, 0.4749]}]}, {"id": "b_20", "type": "paragraph", "text": "In AlexNet, the hyperparameters are set as follows: r = 2, α = 0.00002, β = 0.75, and k = 1. This step can be implemented using the tf.nn.local_response_normaliza tion() function (which you can wrap in a Lambda layer if you want to use it in a Keras model).", "words": [{"w": "In", "b": [0.1429, 0.4816, 0.1614, 0.503]}, {"w": "AlexNet,", "b": [0.1666, 0.4816, 0.2399, 0.503]}, {"w": "the", "b": [0.2451, 0.4816, 0.2714, 0.503]}, {"w": "hyperparameters", "b": [0.2767, 0.4816, 0.4178, 0.503]}, {"w": "are", "b": [0.4231, 0.4816, 0.4488, 0.503]}, {"w": "set", "b": [0.454, 0.4816, 0.4769, 0.503]}, {"w": "as", "b": [0.4821, 0.4816, 0.4989, 0.503]}, {"w": "follows:", "b": [0.5042, 0.4816, 0.5688, 0.503]}, {"w": "r", "b": [0.574, 0.4814, 0.5816, 0.503]}, {"w": "=", "b": [0.5869, 0.4816, 0.599, 0.503]}, {"w": "2,", "b": [0.6042, 0.4816, 0.6189, 0.503]}, {"w": "α", "b": [0.6242, 0.4814, 0.6353, 0.503]}, {"w": "=", "b": [0.6406, 0.4816, 0.6527, 0.503]}, {"w": "0.00002,", "b": [0.6579, 0.4816, 0.7274, 0.503]}, {"w": "β", "b": [0.7326, 0.4814, 0.7433, 0.503]}, {"w": "=", "b": [0.7485, 0.4816, 0.7606, 0.503]}, {"w": "0.75,", "b": [0.7658, 0.4816, 0.8053, 0.503]}, {"w": "and", "b": [0.8106, 0.4816, 0.8421, 0.503]}, {"w": "k", "b": [0.8473, 0.4814, 0.8571, 0.503]}, {"w": "=", "b": [0.1428, 0.5016, 0.1549, 0.523]}, {"w": "1.", "b": [0.1643, 0.5016, 0.179, 0.523]}, {"w": "This", "b": [0.1884, 0.5016, 0.2256, 0.523]}, {"w": "step", "b": [0.235, 0.5016, 0.2687, 0.523]}, {"w": "can", "b": [0.2781, 0.5016, 0.3074, 0.523]}, {"w": "be", "b": [0.3168, 0.5016, 0.3362, 0.523]}, {"w": "implemented", "b": [0.3456, 0.5016, 0.456, 0.523]}, {"w": "using", "b": [0.4654, 0.5016, 0.5108, 0.523]}, {"w": "the", "b": [0.5202, 0.5016, 0.5465, 0.523]}, {"w": "tf.nn.local_response_normaliza", "b": [0.5559, 0.5047, 0.8527, 0.5198]}, {"w": "tion()", "b": [0.1429, 0.5247, 0.2022, 0.5398]}, {"w": "function", "b": [0.2099, 0.5215, 0.2813, 0.5429]}, {"w": "(which", "b": [0.289, 0.5215, 0.3472, 0.5429]}, {"w": "you", "b": [0.3549, 0.5215, 0.3861, 0.5429]}, {"w": "can", "b": [0.3938, 0.5215, 0.4232, 0.5429]}, {"w": "wrap", "b": [0.4309, 0.5215, 0.4726, 0.5429]}, {"w": "in", "b": [0.4803, 0.5215, 0.4973, 0.5429]}, {"w": "a", "b": [0.505, 0.5215, 0.5141, 0.5429]}, {"w": "Lambda", "b": [0.5218, 0.5247, 0.5812, 0.5398]}, {"w": "layer", "b": [0.5889, 0.5215, 0.6291, 0.5429]}, {"w": "if", "b": [0.6368, 0.5215, 0.6485, 0.5429]}, {"w": "you", "b": [0.6563, 0.5215, 0.6875, 0.5429]}, {"w": "want", "b": [0.6952, 0.5215, 0.736, 0.5429]}, {"w": "to", "b": [0.7437, 0.5215, 0.7607, 0.5429]}, {"w": "use", "b": [0.7684, 0.5215, 0.7959, 0.5429]}, {"w": "it", "b": [0.8037, 0.5215, 0.8156, 0.5429]}, {"w": "in", "b": [0.8233, 0.5215, 0.8403, 0.5429]}, {"w": "a", "b": [0.848, 0.5215, 0.8571, 0.5429]}, {"w": "Keras", "b": [0.1429, 0.5406, 0.1898, 0.562]}, {"w": "model).", "b": [0.1945, 0.5406, 0.2593, 0.562]}]}, {"id": "b_21", "type": "paragraph", "text": "A variant of AlexNet called ZF Net was developed by Matthew Zeiler and Rob Fergus and won the 2013 ILSVRC challenge. It is essentially AlexNet with a few tweaked hyperparameters (number of feature maps, kernel size, stride, etc.).", "words": [{"w": "A", "b": [0.1429, 0.5687, 0.1573, 0.5901]}, {"w": "variant", "b": [0.1626, 0.5687, 0.2212, 0.5901]}, {"w": "of", "b": [0.2266, 0.5687, 0.2434, 0.5901]}, {"w": "AlexNet", "b": [0.2488, 0.5687, 0.3173, 0.5901]}, {"w": "called", "b": [0.3227, 0.5687, 0.3711, 0.5901]}, {"w": "ZF", "b": [0.3764, 0.5685, 0.3997, 0.5901]}, {"w": "Net", "b": [0.4044, 0.5685, 0.4331, 0.5901]}, {"w": "was", "b": [0.4391, 0.5687, 0.4702, 0.5901]}, {"w": "developed", "b": [0.4756, 0.5687, 0.5606, 0.5901]}, {"w": "by", "b": [0.566, 0.5687, 0.5861, 0.5901]}, {"w": "Matthew", "b": [0.5915, 0.5687, 0.6654, 0.5901]}, {"w": "Zeiler", "b": [0.6708, 0.5687, 0.7196, 0.5901]}, {"w": "and", "b": [0.725, 0.5687, 0.7566, 0.5901]}, {"w": "Rob", "b": [0.7619, 0.5687, 0.7961, 0.5901]}, {"w": "Fergus", "b": [0.8015, 0.5687, 0.8571, 0.5901]}, {"w": "and", "b": [0.1428, 0.5877, 0.1744, 0.6091]}, {"w": "won", "b": [0.1818, 0.5877, 0.218, 0.6091]}, {"w": "the", "b": [0.2254, 0.5877, 0.2517, 0.6091]}, {"w": "2013", "b": [0.2591, 0.5877, 0.2991, 0.6091]}, {"w": "ILSVRC", "b": [0.3065, 0.5877, 0.3761, 0.6091]}, {"w": "challenge.", "b": [0.3835, 0.5877, 0.4667, 0.6091]}, {"w": "It", "b": [0.4741, 0.5877, 0.4867, 0.6091]}, {"w": "is", "b": [0.4941, 0.5877, 0.5073, 0.6091]}, {"w": "essentially", "b": [0.5147, 0.5877, 0.5998, 0.6091]}, {"w": "AlexNet", "b": [0.6072, 0.5877, 0.6757, 0.6091]}, {"w": "with", "b": [0.6831, 0.5877, 0.7204, 0.6091]}, {"w": "a", "b": [0.7278, 0.5877, 0.7369, 0.6091]}, {"w": "few", "b": [0.7443, 0.5877, 0.7736, 0.6091]}, {"w": "tweaked", "b": [0.781, 0.5877, 0.8498, 0.6091]}, {"w": "hyperparameters", "b": [0.1429, 0.6068, 0.284, 0.6282]}, {"w": "(number", "b": [0.2887, 0.6068, 0.3622, 0.6282]}, {"w": "of", "b": [0.367, 0.6068, 0.3838, 0.6282]}, {"w": "feature", "b": [0.3885, 0.6068, 0.4463, 0.6282]}, {"w": "maps,", "b": [0.451, 0.6068, 0.5001, 0.6282]}, {"w": "kernel", "b": [0.5048, 0.6068, 0.5573, 0.6282]}, {"w": "size,", "b": [0.562, 0.6068, 0.5976, 0.6282]}, {"w": "stride,", "b": [0.6023, 0.6068, 0.6542, 0.6282]}, {"w": "etc.).", "b": [0.659, 0.6068, 0.6997, 0.6282]}]}, {"id": "b_22", "type": "paragraph", "text": "GoogLeNet", "words": [{"w": "GoogLeNet", "b": [0.1429, 0.6409, 0.2565, 0.6695]}]}, {"id": "b_23", "type": "paragraph", "text": "The GoogLeNet architecture was developed by Christian Szegedy et al. from Google Research,12 and it won the ILSVRC 2014 challenge by pushing the top-5 error rate below 7%. This great performance came in large part from the fact that the network was much deeper than previous CNNs (see Figure 14-14). This was made possible by sub-networks called inception modules,13 which allow GoogLeNet to use parameters", "words": [{"w": "The", "b": [0.1429, 0.6754, 0.1757, 0.6968]}, {"w": "GoogLeNet", "b": [0.1818, 0.6754, 0.278, 0.6968]}, {"w": "architecture", "b": [0.2841, 0.6754, 0.3845, 0.6968]}, {"w": "was", "b": [0.3907, 0.6754, 0.4217, 0.6968]}, {"w": "developed", "b": [0.4279, 0.6754, 0.5129, 0.6968]}, {"w": "by", "b": [0.5191, 0.6754, 0.5392, 0.6968]}, {"w": "Christian", "b": [0.5454, 0.6754, 0.6238, 0.6968]}, {"w": "Szegedy", "b": [0.6299, 0.6754, 0.6966, 0.6968]}, {"w": "et", "b": [0.7027, 0.6754, 0.7179, 0.6968]}, {"w": "al.", "b": [0.7241, 0.6754, 0.7432, 0.6968]}, {"w": "from", "b": [0.7494, 0.6754, 0.791, 0.6968]}, {"w": "Google", "b": [0.7971, 0.6754, 0.8572, 0.6968]}, {"w": "Research,12", "b": [0.1429, 0.6945, 0.2341, 0.7159]}, {"w": "and", "b": [0.2415, 0.6945, 0.273, 0.7159]}, {"w": "it", "b": [0.2803, 0.6945, 0.2923, 0.7159]}, {"w": "won", "b": [0.2996, 0.6945, 0.3359, 0.7159]}, {"w": "the", "b": [0.3432, 0.6945, 0.3695, 0.7159]}, {"w": "ILSVRC", "b": [0.3768, 0.6945, 0.4465, 0.7159]}, {"w": "2014", "b": [0.4538, 0.6945, 0.4938, 0.7159]}, {"w": "challenge", "b": [0.5011, 0.6945, 0.5796, 0.7159]}, {"w": "by", "b": [0.5869, 0.6945, 0.6071, 0.7159]}, {"w": "pushing", "b": [0.6144, 0.6945, 0.6819, 0.7159]}, {"w": "the", "b": [0.6892, 0.6945, 0.7155, 0.7159]}, {"w": "top-5", "b": [0.7228, 0.6945, 0.7681, 0.7159]}, {"w": "error", "b": [0.7755, 0.6945, 0.8181, 0.7159]}, {"w": "rate", "b": [0.8255, 0.6945, 0.8571, 0.7159]}, {"w": "below", "b": [0.1429, 0.7135, 0.1925, 0.7349]}, {"w": "7%.", "b": [0.1986, 0.7135, 0.2291, 0.7349]}, {"w": "This", "b": [0.2352, 0.7135, 0.2724, 0.7349]}, {"w": "great", "b": [0.2785, 0.7135, 0.32, 0.7349]}, {"w": "performance", "b": [0.3261, 0.7135, 0.4334, 0.7349]}, {"w": "came", "b": [0.4395, 0.7135, 0.4833, 0.7349]}, {"w": "in", "b": [0.4895, 0.7135, 0.5064, 0.7349]}, {"w": "large", "b": [0.5126, 0.7135, 0.5533, 0.7349]}, {"w": "part", "b": [0.5594, 0.7135, 0.5936, 0.7349]}, {"w": "from", "b": [0.5997, 0.7135, 0.6413, 0.7349]}, {"w": "the", "b": [0.6474, 0.7135, 0.6737, 0.7349]}, {"w": "fact", "b": [0.6798, 0.7135, 0.7103, 0.7349]}, {"w": "that", "b": [0.7164, 0.7135, 0.749, 0.7349]}, {"w": "the", "b": [0.7551, 0.7135, 0.7815, 0.7349]}, {"w": "network", "b": [0.7876, 0.7135, 0.8571, 0.7349]}, {"w": "was", "b": [0.1429, 0.7326, 0.1739, 0.754]}, {"w": "much", "b": [0.1793, 0.7326, 0.227, 0.754]}, {"w": "deeper", "b": [0.2323, 0.7326, 0.2885, 0.754]}, {"w": "than", "b": [0.2939, 0.7326, 0.3319, 0.754]}, {"w": "previous", "b": [0.3373, 0.7326, 0.4094, 0.754]}, {"w": "CNNs", "b": [0.4147, 0.7326, 0.4666, 0.754]}, {"w": "(see", "b": [0.472, 0.7326, 0.5046, 0.754]}, {"w": "Figure", "b": [0.5099, 0.7326, 0.5639, 0.754]}, {"w": "14-14).", "b": [0.5687, 0.7326, 0.6287, 0.754]}, {"w": "This", "b": [0.634, 0.7326, 0.6713, 0.754]}, {"w": "was", "b": [0.6766, 0.7326, 0.7077, 0.754]}, {"w": "made", "b": [0.7131, 0.7326, 0.7591, 0.754]}, {"w": "possible", "b": [0.7645, 0.7326, 0.8316, 0.754]}, {"w": "by", "b": [0.837, 0.7326, 0.8571, 0.754]}, {"w": "sub-networks", "b": [0.1429, 0.7516, 0.2568, 0.773]}, {"w": "called", "b": [0.2639, 0.7516, 0.3122, 0.773]}, {"w": "inception", "b": [0.3193, 0.7514, 0.3941, 0.773]}, {"w": "modules,13", "b": [0.4012, 0.7514, 0.485, 0.773]}, {"w": "which", "b": [0.4921, 0.7516, 0.543, 0.773]}, {"w": "allow", "b": [0.5501, 0.7516, 0.5947, 0.773]}, {"w": "GoogLeNet", "b": [0.6018, 0.7516, 0.6979, 0.773]}, {"w": "to", "b": [0.705, 0.7516, 0.722, 0.773]}, {"w": "use", "b": [0.729, 0.7516, 0.7566, 0.773]}, {"w": "parameters", "b": [0.7637, 0.7516, 0.8571, 0.773]}]}, {"id": "b_24", "type": "paragraph", "text": "452 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "452", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 479, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "much more efficiently than previous architectures: GoogLeNet actually has 10 times fewer parameters than AlexNet (roughly 6 million instead of 60 million).", "words": [{"w": "much", "b": [0.1429, 0.0791, 0.1905, 0.1005]}, {"w": "more", "b": [0.1968, 0.0791, 0.2411, 0.1005]}, {"w": "efficiently", "b": [0.2474, 0.0791, 0.3296, 0.1005]}, {"w": "than", "b": [0.3359, 0.0791, 0.3739, 0.1005]}, {"w": "previous", "b": [0.3803, 0.0791, 0.4523, 0.1005]}, {"w": "architectures:", "b": [0.4586, 0.0791, 0.5714, 0.1005]}, {"w": "GoogLeNet", "b": [0.5777, 0.0791, 0.6739, 0.1005]}, {"w": "actually", "b": [0.6802, 0.0791, 0.7448, 0.1005]}, {"w": "has", "b": [0.7511, 0.0791, 0.779, 0.1005]}, {"w": "10", "b": [0.7853, 0.0791, 0.8053, 0.1005]}, {"w": "times", "b": [0.8116, 0.0791, 0.8571, 0.1005]}, {"w": "fewer", "b": [0.1429, 0.0981, 0.1887, 0.1195]}, {"w": "parameters", "b": [0.1935, 0.0981, 0.2869, 0.1195]}, {"w": "than", "b": [0.2916, 0.0981, 0.3296, 0.1195]}, {"w": "AlexNet", "b": [0.3344, 0.0981, 0.4029, 0.1195]}, {"w": "(roughly", "b": [0.4076, 0.0981, 0.48, 0.1195]}, {"w": "6", "b": [0.4847, 0.0981, 0.4947, 0.1195]}, {"w": "million", "b": [0.4994, 0.0981, 0.5602, 0.1195]}, {"w": "instead", "b": [0.5649, 0.0981, 0.6249, 0.1195]}, {"w": "of", "b": [0.6296, 0.0981, 0.6464, 0.1195]}, {"w": "60", "b": [0.6512, 0.0981, 0.6712, 0.1195]}, {"w": "million).", "b": [0.6759, 0.0981, 0.7486, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "Figure 14-13 shows the architecture of an inception module. The notation “3 × 3 + 1(S)” means that the layer uses a 3 × 3 kernel, stride 1, and SAME padding. The input signal is first copied and fed to four different layers. All convolutional layers use the ReLU activation function. Note that the second set of convolutional layers uses differ‐ ent kernel sizes (1 × 1, 3 × 3, and 5 × 5), allowing them to capture patterns at different scales. Also note that every single layer uses a stride of 1 and SAME padding (even the max pooling layer), so their outputs all have the same height and width as their inputs. This makes it possible to concatenate all the outputs along the depth dimen‐ sion in the final depth concat layer (i.e., stack the feature maps from all four top con‐ volutional layers). This concatenation layer can be implemented in TensorFlow using the tf.concat() operation, with axis=3 (axis 3 is the depth).", "words": [{"w": "Figure", "b": [0.1429, 0.1262, 0.1969, 0.1476]}, {"w": "14-13", "b": [0.2035, 0.1262, 0.2509, 0.1476]}, {"w": "shows", "b": [0.2575, 0.1262, 0.3089, 0.1476]}, {"w": "the", "b": [0.3155, 0.1262, 0.3418, 0.1476]}, {"w": "architecture", "b": [0.3485, 0.1262, 0.4489, 0.1476]}, {"w": "of", "b": [0.4555, 0.1262, 0.4723, 0.1476]}, {"w": "an", "b": [0.479, 0.1262, 0.4995, 0.1476]}, {"w": "inception", "b": [0.5061, 0.1262, 0.5857, 0.1476]}, {"w": "module.", "b": [0.5923, 0.1262, 0.6609, 0.1476]}, {"w": "The", "b": [0.6676, 0.1262, 0.7004, 0.1476]}, {"w": "notation", "b": [0.707, 0.1262, 0.7781, 0.1476]}, {"w": "“3", "b": [0.7848, 0.1262, 0.8031, 0.1476]}, {"w": "×", "b": [0.8097, 0.1262, 0.8218, 0.1476]}, {"w": "3", "b": [0.8284, 0.1262, 0.8384, 0.1476]}, {"w": "+", "b": [0.8451, 0.1262, 0.8571, 0.1476]}, {"w": "1(S)”", "b": [0.1429, 0.1453, 0.1855, 0.1667]}, {"w": "means", "b": [0.1905, 0.1453, 0.2446, 0.1667]}, {"w": "that", "b": [0.2497, 0.1453, 0.2822, 0.1667]}, {"w": "the", "b": [0.2873, 0.1453, 0.3136, 0.1667]}, {"w": "layer", "b": [0.3186, 0.1453, 0.3588, 0.1667]}, {"w": "uses", "b": [0.3638, 0.1453, 0.399, 0.1667]}, {"w": "a", "b": [0.4041, 0.1453, 0.4132, 0.1667]}, {"w": "3", "b": [0.4182, 0.1453, 0.4282, 0.1667]}, {"w": "×", "b": [0.4333, 0.1453, 0.4453, 0.1667]}, {"w": "3", "b": [0.4504, 0.1453, 0.4604, 0.1667]}, {"w": "kernel,", "b": [0.4654, 0.1453, 0.5226, 0.1667]}, {"w": "stride", "b": [0.5276, 0.1453, 0.5748, 0.1667]}, {"w": "1,", "b": [0.5798, 0.1453, 0.5945, 0.1667]}, {"w": "and", "b": [0.5996, 0.1453, 0.6311, 0.1667]}, {"w": "SAME", "b": [0.6361, 0.1453, 0.6908, 0.1667]}, {"w": "padding.", "b": [0.6958, 0.1453, 0.7694, 0.1667]}, {"w": "The", "b": [0.7744, 0.1453, 0.8072, 0.1667]}, {"w": "input", "b": [0.8122, 0.1453, 0.8572, 0.1667]}, {"w": "signal", "b": [0.1429, 0.1643, 0.1917, 0.1857]}, {"w": "is", "b": [0.1978, 0.1643, 0.2111, 0.1857]}, {"w": "first", "b": [0.2172, 0.1643, 0.2507, 0.1857]}, {"w": "copied", "b": [0.2569, 0.1643, 0.3127, 0.1857]}, {"w": "and", "b": [0.3189, 0.1643, 0.3504, 0.1857]}, {"w": "fed", "b": [0.3566, 0.1643, 0.3826, 0.1857]}, {"w": "to", "b": [0.3888, 0.1643, 0.4058, 0.1857]}, {"w": "four", "b": [0.412, 0.1643, 0.4476, 0.1857]}, {"w": "different", "b": [0.4537, 0.1643, 0.5255, 0.1857]}, {"w": "layers.", "b": [0.5316, 0.1643, 0.5842, 0.1857]}, {"w": "All", "b": [0.5904, 0.1643, 0.6153, 0.1857]}, {"w": "convolutional", "b": [0.6215, 0.1643, 0.7369, 0.1857]}, {"w": "layers", "b": [0.743, 0.1643, 0.7909, 0.1857]}, {"w": "use", "b": [0.7971, 0.1643, 0.8246, 0.1857]}, {"w": "the", "b": [0.8308, 0.1643, 0.8571, 0.1857]}, {"w": "ReLU", "b": [0.1429, 0.1834, 0.1904, 0.2048]}, {"w": "activation", "b": [0.1953, 0.1834, 0.2776, 0.2048]}, {"w": "function.", "b": [0.2825, 0.1834, 0.3587, 0.2048]}, {"w": "Note", "b": [0.3636, 0.1834, 0.4044, 0.2048]}, {"w": "that", "b": [0.4093, 0.1834, 0.4419, 0.2048]}, {"w": "the", "b": [0.4469, 0.1834, 0.4732, 0.2048]}, {"w": "second", "b": [0.4782, 0.1834, 0.5365, 0.2048]}, {"w": "set", "b": [0.5414, 0.1834, 0.5643, 0.2048]}, {"w": "of", "b": [0.5693, 0.1834, 0.586, 0.2048]}, {"w": "convolutional", "b": [0.591, 0.1834, 0.7063, 0.2048]}, {"w": "layers", "b": [0.7113, 0.1834, 0.7591, 0.2048]}, {"w": "uses", "b": [0.7641, 0.1834, 0.7993, 0.2048]}, {"w": "differ‐", "b": [0.8042, 0.1834, 0.8571, 0.2048]}, {"w": "ent", "b": [0.1428, 0.2024, 0.1691, 0.2238]}, {"w": "kernel", "b": [0.1739, 0.2024, 0.2263, 0.2238]}, {"w": "sizes", "b": [0.2311, 0.2024, 0.2696, 0.2238]}, {"w": "(1", "b": [0.2745, 0.2024, 0.2917, 0.2238]}, {"w": "×", "b": [0.2965, 0.2024, 0.3086, 0.2238]}, {"w": "1,", "b": [0.3134, 0.2024, 0.3282, 0.2238]}, {"w": "3", "b": [0.333, 0.2024, 0.343, 0.2238]}, {"w": "×", "b": [0.3478, 0.2024, 0.3599, 0.2238]}, {"w": "3,", "b": [0.3647, 0.2024, 0.3795, 0.2238]}, {"w": "and", "b": [0.3843, 0.2024, 0.4158, 0.2238]}, {"w": "5", "b": [0.4207, 0.2024, 0.4307, 0.2238]}, {"w": "×", "b": [0.4355, 0.2024, 0.4476, 0.2238]}, {"w": "5),", "b": [0.4524, 0.2024, 0.4744, 0.2238]}, {"w": "allowing", "b": [0.4792, 0.2024, 0.5505, 0.2238]}, {"w": "them", "b": [0.5553, 0.2024, 0.5987, 0.2238]}, {"w": "to", "b": [0.6036, 0.2024, 0.6205, 0.2238]}, {"w": "capture", "b": [0.6254, 0.2024, 0.6878, 0.2238]}, {"w": "patterns", "b": [0.6927, 0.2024, 0.7607, 0.2238]}, {"w": "at", "b": [0.7655, 0.2024, 0.7806, 0.2238]}, {"w": "different", "b": [0.7854, 0.2024, 0.8571, 0.2238]}, {"w": "scales.", "b": [0.1429, 0.2215, 0.195, 0.2429]}, {"w": "Also", "b": [0.2017, 0.2215, 0.2397, 0.2429]}, {"w": "note", "b": [0.2464, 0.2215, 0.2836, 0.2429]}, {"w": "that", "b": [0.2904, 0.2215, 0.323, 0.2429]}, {"w": "every", "b": [0.3297, 0.2215, 0.375, 0.2429]}, {"w": "single", "b": [0.3817, 0.2215, 0.4302, 0.2429]}, {"w": "layer", "b": [0.437, 0.2215, 0.4772, 0.2429]}, {"w": "uses", "b": [0.4839, 0.2215, 0.5191, 0.2429]}, {"w": "a", "b": [0.5259, 0.2215, 0.535, 0.2429]}, {"w": "stride", "b": [0.5418, 0.2215, 0.5889, 0.2429]}, {"w": "of", "b": [0.5957, 0.2215, 0.6125, 0.2429]}, {"w": "1", "b": [0.6192, 0.2215, 0.6292, 0.2429]}, {"w": "and", "b": [0.636, 0.2215, 0.6675, 0.2429]}, {"w": "SAME", "b": [0.6742, 0.2215, 0.7289, 0.2429]}, {"w": "padding", "b": [0.7357, 0.2215, 0.8044, 0.2429]}, {"w": "(even", "b": [0.8112, 0.2215, 0.8571, 0.2429]}, {"w": "the", "b": [0.1429, 0.2405, 0.1692, 0.2619]}, {"w": "max", "b": [0.1757, 0.2405, 0.2118, 0.2619]}, {"w": "pooling", "b": [0.2183, 0.2405, 0.2824, 0.2619]}, {"w": "layer),", "b": [0.289, 0.2405, 0.3411, 0.2619]}, {"w": "so", "b": [0.3476, 0.2405, 0.3659, 0.2619]}, {"w": "their", "b": [0.3724, 0.2405, 0.4121, 0.2619]}, {"w": "outputs", "b": [0.4186, 0.2405, 0.4826, 0.2619]}, {"w": "all", "b": [0.4891, 0.2405, 0.5088, 0.2619]}, {"w": "have", "b": [0.5153, 0.2405, 0.5537, 0.2619]}, {"w": "the", "b": [0.5603, 0.2405, 0.5866, 0.2619]}, {"w": "same", "b": [0.5931, 0.2405, 0.6358, 0.2619]}, {"w": "height", "b": [0.6423, 0.2405, 0.6947, 0.2619]}, {"w": "and", "b": [0.7013, 0.2405, 0.7328, 0.2619]}, {"w": "width", "b": [0.7393, 0.2405, 0.7877, 0.2619]}, {"w": "as", "b": [0.7942, 0.2405, 0.811, 0.2619]}, {"w": "their", "b": [0.8175, 0.2405, 0.8571, 0.2619]}, {"w": "inputs.", "b": [0.1429, 0.2596, 0.2002, 0.281]}, {"w": "This", "b": [0.2063, 0.2596, 0.2435, 0.281]}, {"w": "makes", "b": [0.2496, 0.2596, 0.3027, 0.281]}, {"w": "it", "b": [0.3088, 0.2596, 0.3207, 0.281]}, {"w": "possible", "b": [0.3268, 0.2596, 0.394, 0.281]}, {"w": "to", "b": [0.4001, 0.2596, 0.4171, 0.281]}, {"w": "concatenate", "b": [0.4232, 0.2596, 0.5222, 0.281]}, {"w": "all", "b": [0.5283, 0.2596, 0.548, 0.281]}, {"w": "the", "b": [0.5541, 0.2596, 0.5804, 0.281]}, {"w": "outputs", "b": [0.5865, 0.2596, 0.6506, 0.281]}, {"w": "along", "b": [0.6567, 0.2596, 0.7029, 0.281]}, {"w": "the", "b": [0.709, 0.2596, 0.7353, 0.281]}, {"w": "depth", "b": [0.7415, 0.2596, 0.7897, 0.281]}, {"w": "dimen‐", "b": [0.7958, 0.2596, 0.8571, 0.281]}, {"w": "sion", "b": [0.1429, 0.2786, 0.1781, 0.3]}, {"w": "in", "b": [0.1838, 0.2786, 0.2008, 0.3]}, {"w": "the", "b": [0.2064, 0.2786, 0.2328, 0.3]}, {"w": "final", "b": [0.2384, 0.2786, 0.276, 0.3]}, {"w": "depth", "b": [0.2817, 0.2784, 0.3272, 0.3]}, {"w": "concat", "b": [0.3329, 0.2784, 0.3852, 0.3]}, {"w": "layer", "b": [0.3909, 0.2784, 0.4308, 0.3]}, {"w": "(i.e.,", "b": [0.4365, 0.2786, 0.4723, 0.3]}, {"w": "stack", "b": [0.478, 0.2786, 0.5203, 0.3]}, {"w": "the", "b": [0.526, 0.2786, 0.5523, 0.3]}, {"w": "feature", "b": [0.558, 0.2786, 0.6158, 0.3]}, {"w": "maps", "b": [0.6214, 0.2786, 0.6658, 0.3]}, {"w": "from", "b": [0.6715, 0.2786, 0.7131, 0.3]}, {"w": "all", "b": [0.7187, 0.2786, 0.7384, 0.3]}, {"w": "four", "b": [0.7441, 0.2786, 0.7797, 0.3]}, {"w": "top", "b": [0.7853, 0.2786, 0.8132, 0.3]}, {"w": "con‐", "b": [0.8189, 0.2786, 0.8572, 0.3]}, {"w": "volutional", "b": [0.1429, 0.2977, 0.2278, 0.3191]}, {"w": "layers).", "b": [0.2333, 0.2977, 0.2931, 0.3191]}, {"w": "This", "b": [0.2985, 0.2977, 0.3357, 0.3191]}, {"w": "concatenation", "b": [0.3412, 0.2977, 0.4589, 0.3191]}, {"w": "layer", "b": [0.4644, 0.2977, 0.5045, 0.3191]}, {"w": "can", "b": [0.51, 0.2977, 0.5394, 0.3191]}, {"w": "be", "b": [0.5448, 0.2977, 0.5642, 0.3191]}, {"w": "implemented", "b": [0.5697, 0.2977, 0.6801, 0.3191]}, {"w": "in", "b": [0.6856, 0.2977, 0.7026, 0.3191]}, {"w": "TensorFlow", "b": [0.708, 0.2977, 0.8063, 0.3191]}, {"w": "using", "b": [0.8117, 0.2977, 0.8571, 0.3191]}, {"w": "the", "b": [0.1429, 0.3176, 0.1692, 0.339]}, {"w": "tf.concat()", "b": [0.1739, 0.3208, 0.2828, 0.3359]}, {"w": "operation,", "b": [0.2875, 0.3176, 0.3731, 0.339]}, {"w": "with", "b": [0.3778, 0.3176, 0.4151, 0.339]}, {"w": "axis=3", "b": [0.4199, 0.3208, 0.4793, 0.3359]}, {"w": "(axis", "b": [0.484, 0.3176, 0.5234, 0.339]}, {"w": "3", "b": [0.5281, 0.3176, 0.5381, 0.339]}, {"w": "is", "b": [0.5429, 0.3176, 0.5561, 0.339]}, {"w": "the", "b": [0.5608, 0.3176, 0.5871, 0.339]}, {"w": "depth).", "b": [0.5919, 0.3176, 0.6521, 0.339]}]}, {"id": "b_2", "type": "equation", "text": "Figure 14-13. Inception module", "words": [{"w": "Figure", "b": [0.1429, 0.5954, 0.1943, 0.6171]}, {"w": "14-13.", "b": [0.1991, 0.5954, 0.2507, 0.6171]}, {"w": "Inception", "b": [0.2554, 0.5954, 0.331, 0.6171]}, {"w": "module", "b": [0.3357, 0.5954, 0.3964, 0.6171]}]}, {"id": "b_3", "type": "paragraph", "text": "You may wonder why inception modules have convolutional layers with 1 × 1 ker‐ nels. Surely these layers cannot capture any features since they look at only one pixel at a time? In fact, these layers serve three purposes:", "words": [{"w": "You", "b": [0.1429, 0.6328, 0.1752, 0.6543]}, {"w": "may", "b": [0.1823, 0.6328, 0.2177, 0.6543]}, {"w": "wonder", "b": [0.2247, 0.6328, 0.2886, 0.6543]}, {"w": "why", "b": [0.2957, 0.6328, 0.3301, 0.6543]}, {"w": "inception", "b": [0.3372, 0.6328, 0.4167, 0.6543]}, {"w": "modules", "b": [0.4238, 0.6328, 0.4953, 0.6543]}, {"w": "have", "b": [0.5024, 0.6328, 0.5408, 0.6543]}, {"w": "convolutional", "b": [0.5478, 0.6328, 0.6632, 0.6543]}, {"w": "layers", "b": [0.6702, 0.6328, 0.7181, 0.6543]}, {"w": "with", "b": [0.7251, 0.6328, 0.7625, 0.6543]}, {"w": "1", "b": [0.7695, 0.6328, 0.7795, 0.6543]}, {"w": "×", "b": [0.7866, 0.6328, 0.7987, 0.6543]}, {"w": "1", "b": [0.8057, 0.6328, 0.8157, 0.6543]}, {"w": "ker‐", "b": [0.8228, 0.6328, 0.8571, 0.6543]}, {"w": "nels.", "b": [0.1428, 0.6519, 0.1808, 0.6733]}, {"w": "Surely", "b": [0.1865, 0.6519, 0.2388, 0.6733]}, {"w": "these", "b": [0.2445, 0.6519, 0.2873, 0.6733]}, {"w": "layers", "b": [0.293, 0.6519, 0.3409, 0.6733]}, {"w": "cannot", "b": [0.3466, 0.6519, 0.4043, 0.6733]}, {"w": "capture", "b": [0.41, 0.6519, 0.4725, 0.6733]}, {"w": "any", "b": [0.4782, 0.6519, 0.5078, 0.6733]}, {"w": "features", "b": [0.5135, 0.6519, 0.5789, 0.6733]}, {"w": "since", "b": [0.5846, 0.6519, 0.6269, 0.6733]}, {"w": "they", "b": [0.6326, 0.6519, 0.6685, 0.6733]}, {"w": "look", "b": [0.6742, 0.6519, 0.7111, 0.6733]}, {"w": "at", "b": [0.7168, 0.6519, 0.7319, 0.6733]}, {"w": "only", "b": [0.7376, 0.6519, 0.7744, 0.6733]}, {"w": "one", "b": [0.7801, 0.6519, 0.811, 0.6733]}, {"w": "pixel", "b": [0.8167, 0.6519, 0.8571, 0.6733]}, {"w": "at", "b": [0.1429, 0.6709, 0.158, 0.6923]}, {"w": "a", "b": [0.1627, 0.6709, 0.1718, 0.6923]}, {"w": "time?", "b": [0.1766, 0.6709, 0.2223, 0.6923]}, {"w": "In", "b": [0.2271, 0.6709, 0.2456, 0.6923]}, {"w": "fact,", "b": [0.2503, 0.6709, 0.2855, 0.6923]}, {"w": "these", "b": [0.2902, 0.6709, 0.3331, 0.6923]}, {"w": "layers", "b": [0.3378, 0.6709, 0.3856, 0.6923]}, {"w": "serve", "b": [0.3904, 0.6709, 0.4337, 0.6923]}, {"w": "three", "b": [0.4384, 0.6709, 0.4813, 0.6923]}, {"w": "purposes:", "b": [0.4861, 0.6709, 0.5662, 0.6923]}]}, {"id": "b_4", "type": "paragraph", "text": "• First, although they cannot capture spatial patterns, they can capture patterns along the depth dimension.", "words": [{"w": "•", "b": [0.16, 0.7051, 0.1682, 0.7265]}, {"w": "First,", "b": [0.1786, 0.7051, 0.2216, 0.7265]}, {"w": "although", "b": [0.2299, 0.7051, 0.3044, 0.7265]}, {"w": "they", "b": [0.3127, 0.7051, 0.3486, 0.7265]}, {"w": "cannot", "b": [0.3568, 0.7051, 0.4146, 0.7265]}, {"w": "capture", "b": [0.4228, 0.7051, 0.4853, 0.7265]}, {"w": "spatial", "b": [0.4936, 0.7051, 0.5473, 0.7265]}, {"w": "patterns,", "b": [0.5555, 0.7051, 0.6283, 0.7265]}, {"w": "they", "b": [0.6366, 0.7051, 0.6725, 0.7265]}, {"w": "can", "b": [0.6807, 0.7051, 0.7101, 0.7265]}, {"w": "capture", "b": [0.7184, 0.7051, 0.7809, 0.7265]}, {"w": "patterns", "b": [0.7891, 0.7051, 0.8571, 0.7265]}, {"w": "along", "b": [0.1786, 0.7241, 0.2248, 0.7456]}, {"w": "the", "b": [0.2295, 0.7241, 0.2558, 0.7456]}, {"w": "depth", "b": [0.2606, 0.7241, 0.3088, 0.7456]}, {"w": "dimension.", "b": [0.3135, 0.7241, 0.4074, 0.7456]}]}, {"id": "b_5", "type": "paragraph", "text": "• Second, they are configured to output fewer feature maps than their inputs, so they serve as bottleneck layers, meaning they reduce dimensionality. This cuts the computational cost and the number of parameters, speeding up training and improving generalization.", "words": [{"w": "•", "b": [0.16, 0.7492, 0.1682, 0.7707]}, {"w": "Second,", "b": [0.1786, 0.7492, 0.2439, 0.7707]}, {"w": "they", "b": [0.251, 0.7492, 0.2869, 0.7707]}, {"w": "are", "b": [0.2941, 0.7492, 0.3198, 0.7707]}, {"w": "configured", "b": [0.327, 0.7492, 0.418, 0.7707]}, {"w": "to", "b": [0.4252, 0.7492, 0.4421, 0.7707]}, {"w": "output", "b": [0.4493, 0.7492, 0.5057, 0.7707]}, {"w": "fewer", "b": [0.5129, 0.7492, 0.5587, 0.7707]}, {"w": "feature", "b": [0.5659, 0.7492, 0.6237, 0.7707]}, {"w": "maps", "b": [0.6308, 0.7492, 0.6752, 0.7707]}, {"w": "than", "b": [0.6824, 0.7492, 0.7204, 0.7707]}, {"w": "their", "b": [0.7276, 0.7492, 0.7672, 0.7707]}, {"w": "inputs,", "b": [0.7744, 0.7492, 0.8317, 0.7707]}, {"w": "so", "b": [0.8389, 0.7492, 0.8571, 0.7707]}, {"w": "they", "b": [0.1786, 0.7683, 0.2145, 0.7897]}, {"w": "serve", "b": [0.2197, 0.7683, 0.263, 0.7897]}, {"w": "as", "b": [0.2683, 0.7683, 0.2851, 0.7897]}, {"w": "bottleneck", "b": [0.2903, 0.7681, 0.3726, 0.7897]}, {"w": "layers,", "b": [0.3773, 0.7681, 0.4294, 0.7897]}, {"w": "meaning", "b": [0.4347, 0.7683, 0.5078, 0.7897]}, {"w": "they", "b": [0.5131, 0.7683, 0.549, 0.7897]}, {"w": "reduce", "b": [0.5542, 0.7683, 0.6105, 0.7897]}, {"w": "dimensionality.", "b": [0.6157, 0.7683, 0.744, 0.7897]}, {"w": "This", "b": [0.7493, 0.7683, 0.7865, 0.7897]}, {"w": "cuts", "b": [0.7917, 0.7683, 0.8256, 0.7897]}, {"w": "the", "b": [0.8308, 0.7683, 0.8571, 0.7897]}, {"w": "computational", "b": [0.1786, 0.7873, 0.3001, 0.8088]}, {"w": "cost", "b": [0.3091, 0.7873, 0.3426, 0.8088]}, {"w": "and", "b": [0.3516, 0.7873, 0.3831, 0.8088]}, {"w": "the", "b": [0.3921, 0.7873, 0.4184, 0.8088]}, {"w": "number", "b": [0.4274, 0.7873, 0.4937, 0.8088]}, {"w": "of", "b": [0.5027, 0.7873, 0.5195, 0.8088]}, {"w": "parameters,", "b": [0.5285, 0.7873, 0.6267, 0.8088]}, {"w": "speeding", "b": [0.6357, 0.7873, 0.7097, 0.8088]}, {"w": "up", "b": [0.7187, 0.7873, 0.7407, 0.8088]}, {"w": "training", "b": [0.7497, 0.7873, 0.8166, 0.8088]}, {"w": "and", "b": [0.8256, 0.7873, 0.8572, 0.8088]}, {"w": "improving", "b": [0.1786, 0.8064, 0.2665, 0.8278]}, {"w": "generalization.", "b": [0.2712, 0.8064, 0.394, 0.8278]}]}, {"id": "b_6", "type": "paragraph", "text": "• Lastly, each pair of convolutional layers ([1 × 1, 3 × 3] and [1 × 1, 5 × 5]) acts like a single, powerful convolutional layer, capable of capturing more complex pat‐ terns. Indeed, instead of sweeping a simple linear classifier across the image (as a", "words": [{"w": "•", "b": [0.16, 0.8315, 0.1682, 0.8529]}, {"w": "Lastly,", "b": [0.1786, 0.8315, 0.231, 0.8529]}, {"w": "each", "b": [0.236, 0.8315, 0.2739, 0.8529]}, {"w": "pair", "b": [0.279, 0.8315, 0.3123, 0.8529]}, {"w": "of", "b": [0.3173, 0.8315, 0.3341, 0.8529]}, {"w": "convolutional", "b": [0.3392, 0.8315, 0.4545, 0.8529]}, {"w": "layers", "b": [0.4595, 0.8315, 0.5073, 0.8529]}, {"w": "([1", "b": [0.5124, 0.8315, 0.5368, 0.8529]}, {"w": "×", "b": [0.5418, 0.8315, 0.5539, 0.8529]}, {"w": "1,", "b": [0.5589, 0.8315, 0.5736, 0.8529]}, {"w": "3", "b": [0.5786, 0.8315, 0.5886, 0.8529]}, {"w": "×", "b": [0.5937, 0.8315, 0.6057, 0.8529]}, {"w": "3]", "b": [0.6108, 0.8315, 0.6279, 0.8529]}, {"w": "and", "b": [0.633, 0.8315, 0.6645, 0.8529]}, {"w": "[1", "b": [0.6695, 0.8315, 0.6867, 0.8529]}, {"w": "×", "b": [0.6917, 0.8315, 0.7038, 0.8529]}, {"w": "1,", "b": [0.7088, 0.8315, 0.7236, 0.8529]}, {"w": "5", "b": [0.7286, 0.8315, 0.7386, 0.8529]}, {"w": "×", "b": [0.7436, 0.8315, 0.7557, 0.8529]}, {"w": "5])", "b": [0.7607, 0.8315, 0.7851, 0.8529]}, {"w": "acts", "b": [0.7901, 0.8315, 0.8221, 0.8529]}, {"w": "like", "b": [0.8271, 0.8315, 0.8571, 0.8529]}, {"w": "a", "b": [0.1786, 0.8505, 0.1877, 0.8719]}, {"w": "single,", "b": [0.1951, 0.8505, 0.2484, 0.8719]}, {"w": "powerful", "b": [0.2558, 0.8505, 0.3307, 0.8719]}, {"w": "convolutional", "b": [0.3381, 0.8505, 0.4534, 0.8719]}, {"w": "layer,", "b": [0.4609, 0.8505, 0.5045, 0.8719]}, {"w": "capable", "b": [0.5119, 0.8505, 0.5742, 0.8719]}, {"w": "of", "b": [0.5817, 0.8505, 0.5984, 0.8719]}, {"w": "capturing", "b": [0.6059, 0.8505, 0.6862, 0.8719]}, {"w": "more", "b": [0.6936, 0.8505, 0.7379, 0.8719]}, {"w": "complex", "b": [0.7453, 0.8505, 0.8163, 0.8719]}, {"w": "pat‐", "b": [0.8237, 0.8505, 0.8571, 0.8719]}, {"w": "terns.", "b": [0.1786, 0.8696, 0.2253, 0.891]}, {"w": "Indeed,", "b": [0.2306, 0.8696, 0.2935, 0.891]}, {"w": "instead", "b": [0.2988, 0.8696, 0.3588, 0.891]}, {"w": "of", "b": [0.3641, 0.8696, 0.3809, 0.891]}, {"w": "sweeping", "b": [0.3862, 0.8696, 0.4635, 0.891]}, {"w": "a", "b": [0.4688, 0.8696, 0.4779, 0.891]}, {"w": "simple", "b": [0.4832, 0.8696, 0.5382, 0.891]}, {"w": "linear", "b": [0.5435, 0.8696, 0.5914, 0.891]}, {"w": "classifier", "b": [0.5967, 0.8696, 0.6692, 0.891]}, {"w": "across", "b": [0.6745, 0.8696, 0.7261, 0.891]}, {"w": "the", "b": [0.7314, 0.8696, 0.7577, 0.891]}, {"w": "image", "b": [0.763, 0.8696, 0.8134, 0.891]}, {"w": "(as", "b": [0.8187, 0.8696, 0.8427, 0.891]}, {"w": "a", "b": [0.848, 0.8696, 0.8571, 0.891]}]}, {"id": "b_7", "type": "paragraph", "text": "CNN Architectures | 453", "words": [{"w": "CNN", "b": [0.6907, 0.9225, 0.7152, 0.9388]}, {"w": "Architectures", "b": [0.718, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "453", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 480, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "single convolutional layer does), this pair of convolutional layers sweeps a two- layer neural network across the image.", "words": [{"w": "single", "b": [0.1786, 0.0791, 0.2271, 0.1005]}, {"w": "convolutional", "b": [0.2338, 0.0791, 0.3492, 0.1005]}, {"w": "layer", "b": [0.3559, 0.0791, 0.3961, 0.1005]}, {"w": "does),", "b": [0.4029, 0.0791, 0.453, 0.1005]}, {"w": "this", "b": [0.4597, 0.0791, 0.4904, 0.1005]}, {"w": "pair", "b": [0.4972, 0.0791, 0.5306, 0.1005]}, {"w": "of", "b": [0.5373, 0.0791, 0.5541, 0.1005]}, {"w": "convolutional", "b": [0.5609, 0.0791, 0.6762, 0.1005]}, {"w": "layers", "b": [0.683, 0.0791, 0.7308, 0.1005]}, {"w": "sweeps", "b": [0.7376, 0.0791, 0.7958, 0.1005]}, {"w": "a", "b": [0.8026, 0.0791, 0.8117, 0.1005]}, {"w": "two-", "b": [0.8185, 0.0791, 0.8571, 0.1005]}, {"w": "layer", "b": [0.1786, 0.0981, 0.2188, 0.1195]}, {"w": "neural", "b": [0.2235, 0.0981, 0.2769, 0.1195]}, {"w": "network", "b": [0.2817, 0.0981, 0.3512, 0.1195]}, {"w": "across", "b": [0.356, 0.0981, 0.4076, 0.1195]}, {"w": "the", "b": [0.4123, 0.0981, 0.4386, 0.1195]}, {"w": "image.", "b": [0.4434, 0.0981, 0.4985, 0.1195]}]}, {"id": "b_1", "type": "paragraph", "text": "In short, you can think of the whole inception module as a convolutional layer on steroids, able to output feature maps that capture complex patterns at various scales.", "words": [{"w": "In", "b": [0.1429, 0.1323, 0.1614, 0.1537]}, {"w": "short,", "b": [0.1687, 0.1323, 0.2169, 0.1537]}, {"w": "you", "b": [0.2242, 0.1323, 0.2554, 0.1537]}, {"w": "can", "b": [0.2627, 0.1323, 0.2921, 0.1537]}, {"w": "think", "b": [0.2993, 0.1323, 0.3441, 0.1537]}, {"w": "of", "b": [0.3514, 0.1323, 0.3682, 0.1537]}, {"w": "the", "b": [0.3755, 0.1323, 0.4018, 0.1537]}, {"w": "whole", "b": [0.4091, 0.1323, 0.4593, 0.1537]}, {"w": "inception", "b": [0.4666, 0.1323, 0.5461, 0.1537]}, {"w": "module", "b": [0.5534, 0.1323, 0.6172, 0.1537]}, {"w": "as", "b": [0.6245, 0.1323, 0.6413, 0.1537]}, {"w": "a", "b": [0.6486, 0.1323, 0.6577, 0.1537]}, {"w": "convolutional", "b": [0.665, 0.1323, 0.7804, 0.1537]}, {"w": "layer", "b": [0.7877, 0.1323, 0.8278, 0.1537]}, {"w": "on", "b": [0.8351, 0.1323, 0.8572, 0.1537]}, {"w": "steroids,", "b": [0.1429, 0.1513, 0.213, 0.1727]}, {"w": "able", "b": [0.2178, 0.1513, 0.2516, 0.1727]}, {"w": "to", "b": [0.2564, 0.1513, 0.2733, 0.1727]}, {"w": "output", "b": [0.2781, 0.1513, 0.3344, 0.1727]}, {"w": "feature", "b": [0.3392, 0.1513, 0.3969, 0.1727]}, {"w": "maps", "b": [0.4017, 0.1513, 0.446, 0.1727]}, {"w": "that", "b": [0.4508, 0.1513, 0.4834, 0.1727]}, {"w": "capture", "b": [0.4881, 0.1513, 0.5506, 0.1727]}, {"w": "complex", "b": [0.5553, 0.1513, 0.6263, 0.1727]}, {"w": "patterns", "b": [0.631, 0.1513, 0.699, 0.1727]}, {"w": "at", "b": [0.7037, 0.1513, 0.7188, 0.1727]}, {"w": "various", "b": [0.7236, 0.1513, 0.785, 0.1727]}, {"w": "scales.", "b": [0.7897, 0.1513, 0.8419, 0.1727]}]}, {"id": "b_2", "type": "paragraph", "text": "The number of convolutional kernels for each convolutional layer is a hyperparameter. Unfortunately, this means that you have six more hyperparameters to tweak for every inception layer you add.", "words": [{"w": "The", "b": [0.2714, 0.1933, 0.3014, 0.2128]}, {"w": "number", "b": [0.3075, 0.1933, 0.3681, 0.2128]}, {"w": "of", "b": [0.3742, 0.1933, 0.3895, 0.2128]}, {"w": "convolutional", "b": [0.3956, 0.1933, 0.5011, 0.2128]}, {"w": "kernels", "b": [0.5072, 0.1933, 0.5621, 0.2128]}, {"w": "for", "b": [0.5682, 0.1933, 0.5906, 0.2128]}, {"w": "each", "b": [0.5967, 0.1933, 0.6314, 0.2128]}, {"w": "convolutional", "b": [0.6374, 0.1933, 0.7429, 0.2128]}, {"w": "layer", "b": [0.749, 0.1933, 0.7857, 0.2128]}, {"w": "is", "b": [0.2714, 0.2107, 0.2835, 0.2303]}, {"w": "a", "b": [0.2908, 0.2107, 0.2992, 0.2303]}, {"w": "hyperparameter.", "b": [0.3065, 0.2107, 0.4317, 0.2303]}, {"w": "Unfortunately,", "b": [0.439, 0.2107, 0.5498, 0.2303]}, {"w": "this", "b": [0.5571, 0.2107, 0.5852, 0.2303]}, {"w": "means", "b": [0.5925, 0.2107, 0.6419, 0.2303]}, {"w": "that", "b": [0.6492, 0.2107, 0.679, 0.2303]}, {"w": "you", "b": [0.6863, 0.2107, 0.7149, 0.2303]}, {"w": "have", "b": [0.7222, 0.2107, 0.7573, 0.2303]}, {"w": "six", "b": [0.7646, 0.2107, 0.7857, 0.2303]}, {"w": "more", "b": [0.2714, 0.2281, 0.3119, 0.2477]}, {"w": "hyperparameters", "b": [0.3162, 0.2281, 0.4453, 0.2477]}, {"w": "to", "b": [0.4496, 0.2281, 0.4651, 0.2477]}, {"w": "tweak", "b": [0.4694, 0.2281, 0.5142, 0.2477]}, {"w": "for", "b": [0.5185, 0.2281, 0.5409, 0.2477]}, {"w": "every", "b": [0.5453, 0.2281, 0.5866, 0.2477]}, {"w": "inception", "b": [0.5909, 0.2281, 0.6637, 0.2477]}, {"w": "layer", "b": [0.668, 0.2281, 0.7047, 0.2477]}, {"w": "you", "b": [0.709, 0.2281, 0.7376, 0.2477]}, {"w": "add.", "b": [0.7419, 0.2281, 0.7748, 0.2477]}]}, {"id": "b_3", "type": "paragraph", "text": "Now let’s look at the architecture of the GoogLeNet CNN (see Figure 14-14). The number of feature maps output by each convolutional layer and each pooling layer is shown before the kernel size. The architecture is so deep that it has to be represented in three columns, but GoogLeNet is actually one tall stack, including nine inception modules (the boxes with the spinning tops). The six numbers in the inception mod‐ ules represent the number of feature maps output by each convolutional layer in the module (in the same order as in Figure 14-13). Note that all the convolutional layers use the ReLU activation function.", "words": [{"w": "Now", "b": [0.1429, 0.2919, 0.1827, 0.3133]}, {"w": "let’s", "b": [0.1906, 0.2919, 0.2208, 0.3133]}, {"w": "look", "b": [0.2287, 0.2919, 0.2656, 0.3133]}, {"w": "at", "b": [0.2735, 0.2919, 0.2886, 0.3133]}, {"w": "the", "b": [0.2965, 0.2919, 0.3228, 0.3133]}, {"w": "architecture", "b": [0.3307, 0.2919, 0.4311, 0.3133]}, {"w": "of", "b": [0.439, 0.2919, 0.4558, 0.3133]}, {"w": "the", "b": [0.4637, 0.2919, 0.4901, 0.3133]}, {"w": "GoogLeNet", "b": [0.498, 0.2919, 0.5941, 0.3133]}, {"w": "CNN", "b": [0.602, 0.2919, 0.6468, 0.3133]}, {"w": "(see", "b": [0.6547, 0.2919, 0.6872, 0.3133]}, {"w": "Figure", "b": [0.6951, 0.2919, 0.7491, 0.3133]}, {"w": "14-14).", "b": [0.757, 0.2919, 0.8164, 0.3133]}, {"w": "The", "b": [0.8243, 0.2919, 0.8571, 0.3133]}, {"w": "number", "b": [0.1429, 0.311, 0.2091, 0.3324]}, {"w": "of", "b": [0.2147, 0.311, 0.2315, 0.3324]}, {"w": "feature", "b": [0.237, 0.311, 0.2948, 0.3324]}, {"w": "maps", "b": [0.3003, 0.311, 0.3447, 0.3324]}, {"w": "output", "b": [0.3502, 0.311, 0.4066, 0.3324]}, {"w": "by", "b": [0.4122, 0.311, 0.4323, 0.3324]}, {"w": "each", "b": [0.4378, 0.311, 0.4758, 0.3324]}, {"w": "convolutional", "b": [0.4813, 0.311, 0.5967, 0.3324]}, {"w": "layer", "b": [0.6022, 0.311, 0.6424, 0.3324]}, {"w": "and", "b": [0.6479, 0.311, 0.6795, 0.3324]}, {"w": "each", "b": [0.685, 0.311, 0.7229, 0.3324]}, {"w": "pooling", "b": [0.7285, 0.311, 0.7926, 0.3324]}, {"w": "layer", "b": [0.7982, 0.311, 0.8384, 0.3324]}, {"w": "is", "b": [0.8439, 0.311, 0.8571, 0.3324]}, {"w": "shown", "b": [0.1428, 0.33, 0.1979, 0.3514]}, {"w": "before", "b": [0.2033, 0.33, 0.2561, 0.3514]}, {"w": "the", "b": [0.2615, 0.33, 0.2879, 0.3514]}, {"w": "kernel", "b": [0.2933, 0.33, 0.3457, 0.3514]}, {"w": "size.", "b": [0.3511, 0.33, 0.3867, 0.3514]}, {"w": "The", "b": [0.3921, 0.33, 0.4249, 0.3514]}, {"w": "architecture", "b": [0.4303, 0.33, 0.5307, 0.3514]}, {"w": "is", "b": [0.5361, 0.33, 0.5494, 0.3514]}, {"w": "so", "b": [0.5548, 0.33, 0.573, 0.3514]}, {"w": "deep", "b": [0.5785, 0.33, 0.6181, 0.3514]}, {"w": "that", "b": [0.6235, 0.33, 0.6561, 0.3514]}, {"w": "it", "b": [0.6615, 0.33, 0.6734, 0.3514]}, {"w": "has", "b": [0.6788, 0.33, 0.7067, 0.3514]}, {"w": "to", "b": [0.7121, 0.33, 0.7291, 0.3514]}, {"w": "be", "b": [0.7345, 0.33, 0.7539, 0.3514]}, {"w": "represented", "b": [0.7593, 0.33, 0.8571, 0.3514]}, {"w": "in", "b": [0.1429, 0.3491, 0.1598, 0.3705]}, {"w": "three", "b": [0.1661, 0.3491, 0.209, 0.3705]}, {"w": "columns,", "b": [0.2153, 0.3491, 0.2919, 0.3705]}, {"w": "but", "b": [0.2982, 0.3491, 0.3262, 0.3705]}, {"w": "GoogLeNet", "b": [0.3325, 0.3491, 0.4286, 0.3705]}, {"w": "is", "b": [0.4349, 0.3491, 0.4481, 0.3705]}, {"w": "actually", "b": [0.4544, 0.3491, 0.519, 0.3705]}, {"w": "one", "b": [0.5252, 0.3491, 0.5561, 0.3705]}, {"w": "tall", "b": [0.5624, 0.3491, 0.5884, 0.3705]}, {"w": "stack,", "b": [0.5947, 0.3491, 0.6417, 0.3705]}, {"w": "including", "b": [0.648, 0.3491, 0.7279, 0.3705]}, {"w": "nine", "b": [0.7341, 0.3491, 0.7714, 0.3705]}, {"w": "inception", "b": [0.7776, 0.3491, 0.8572, 0.3705]}, {"w": "modules", "b": [0.1429, 0.3681, 0.2144, 0.3895]}, {"w": "(the", "b": [0.2204, 0.3681, 0.2539, 0.3895]}, {"w": "boxes", "b": [0.2599, 0.3681, 0.3075, 0.3895]}, {"w": "with", "b": [0.3135, 0.3681, 0.3508, 0.3895]}, {"w": "the", "b": [0.3568, 0.3681, 0.3832, 0.3895]}, {"w": "spinning", "b": [0.3892, 0.3681, 0.4628, 0.3895]}, {"w": "tops).", "b": [0.4688, 0.3681, 0.5163, 0.3895]}, {"w": "The", "b": [0.5223, 0.3681, 0.5552, 0.3895]}, {"w": "six", "b": [0.5612, 0.3681, 0.5842, 0.3895]}, {"w": "numbers", "b": [0.5902, 0.3681, 0.6642, 0.3895]}, {"w": "in", "b": [0.6702, 0.3681, 0.6872, 0.3895]}, {"w": "the", "b": [0.6932, 0.3681, 0.7195, 0.3895]}, {"w": "inception", "b": [0.7255, 0.3681, 0.805, 0.3895]}, {"w": "mod‐", "b": [0.811, 0.3681, 0.8571, 0.3895]}, {"w": "ules", "b": [0.1429, 0.3871, 0.1757, 0.4086]}, {"w": "represent", "b": [0.1817, 0.3871, 0.2597, 0.4086]}, {"w": "the", "b": [0.2657, 0.3871, 0.2921, 0.4086]}, {"w": "number", "b": [0.2981, 0.3871, 0.3644, 0.4086]}, {"w": "of", "b": [0.3705, 0.3871, 0.3872, 0.4086]}, {"w": "feature", "b": [0.3933, 0.3871, 0.4511, 0.4086]}, {"w": "maps", "b": [0.4571, 0.3871, 0.5015, 0.4086]}, {"w": "output", "b": [0.5075, 0.3871, 0.5639, 0.4086]}, {"w": "by", "b": [0.57, 0.3871, 0.5901, 0.4086]}, {"w": "each", "b": [0.5962, 0.3871, 0.6341, 0.4086]}, {"w": "convolutional", "b": [0.6402, 0.3871, 0.7555, 0.4086]}, {"w": "layer", "b": [0.7615, 0.3871, 0.8017, 0.4086]}, {"w": "in", "b": [0.8078, 0.3871, 0.8248, 0.4086]}, {"w": "the", "b": [0.8308, 0.3871, 0.8571, 0.4086]}, {"w": "module", "b": [0.1429, 0.4062, 0.2067, 0.4276]}, {"w": "(in", "b": [0.2126, 0.4062, 0.2368, 0.4276]}, {"w": "the", "b": [0.2426, 0.4062, 0.2689, 0.4276]}, {"w": "same", "b": [0.2747, 0.4062, 0.3174, 0.4276]}, {"w": "order", "b": [0.3233, 0.4062, 0.3692, 0.4276]}, {"w": "as", "b": [0.375, 0.4062, 0.3918, 0.4276]}, {"w": "in", "b": [0.3976, 0.4062, 0.4146, 0.4276]}, {"w": "Figure", "b": [0.4204, 0.4062, 0.4744, 0.4276]}, {"w": "14-13).", "b": [0.4803, 0.4062, 0.5396, 0.4276]}, {"w": "Note", "b": [0.5455, 0.4062, 0.5863, 0.4276]}, {"w": "that", "b": [0.5921, 0.4062, 0.6247, 0.4276]}, {"w": "all", "b": [0.6305, 0.4062, 0.6502, 0.4276]}, {"w": "the", "b": [0.656, 0.4062, 0.6823, 0.4276]}, {"w": "convolutional", "b": [0.6882, 0.4062, 0.8035, 0.4276]}, {"w": "layers", "b": [0.8093, 0.4062, 0.8572, 0.4276]}, {"w": "use", "b": [0.1429, 0.4252, 0.1704, 0.4467]}, {"w": "the", "b": [0.1752, 0.4252, 0.2015, 0.4467]}, {"w": "ReLU", "b": [0.2062, 0.4252, 0.2537, 0.4467]}, {"w": "activation", "b": [0.2584, 0.4252, 0.3407, 0.4467]}, {"w": "function.", "b": [0.3454, 0.4252, 0.4216, 0.4467]}]}, {"id": "b_4", "type": "paragraph", "text": "454 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "454", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 481, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 14-14. GoogLeNet architecture", "words": [{"w": "Figure", "b": [0.1429, 0.5723, 0.1943, 0.5939]}, {"w": "14-14.", "b": [0.1991, 0.5723, 0.2507, 0.5939]}, {"w": "GoogLeNet", "b": [0.2554, 0.5723, 0.3461, 0.5939]}, {"w": "architecture", "b": [0.3509, 0.5723, 0.4464, 0.5939]}]}, {"id": "b_1", "type": "paragraph", "text": "Let’s go through this network:", "words": [{"w": "Let’s", "b": [0.1429, 0.6097, 0.179, 0.6311]}, {"w": "go", "b": [0.1838, 0.6097, 0.2041, 0.6311]}, {"w": "through", "b": [0.2089, 0.6097, 0.2766, 0.6311]}, {"w": "this", "b": [0.2814, 0.6097, 0.3121, 0.6311]}, {"w": "network:", "b": [0.3168, 0.6097, 0.3911, 0.6311]}]}, {"id": "b_2", "type": "paragraph", "text": "• The first two layers divide the image’s height and width by 4 (so its area is divided by 16), to reduce the computational load. The first layer uses a large kernel size, so that much of the information is still preserved.", "words": [{"w": "•", "b": [0.16, 0.6438, 0.1682, 0.6652]}, {"w": "The", "b": [0.1786, 0.6438, 0.2114, 0.6652]}, {"w": "first", "b": [0.2162, 0.6438, 0.2497, 0.6652]}, {"w": "two", "b": [0.2546, 0.6438, 0.2858, 0.6652]}, {"w": "layers", "b": [0.2906, 0.6438, 0.3385, 0.6652]}, {"w": "divide", "b": [0.3433, 0.6438, 0.395, 0.6652]}, {"w": "the", "b": [0.3998, 0.6438, 0.4262, 0.6652]}, {"w": "image’s", "b": [0.431, 0.6438, 0.4905, 0.6652]}, {"w": "height", "b": [0.4953, 0.6438, 0.5477, 0.6652]}, {"w": "and", "b": [0.5526, 0.6438, 0.5841, 0.6652]}, {"w": "width", "b": [0.589, 0.6438, 0.6373, 0.6652]}, {"w": "by", "b": [0.6421, 0.6438, 0.6623, 0.6652]}, {"w": "4", "b": [0.6671, 0.6438, 0.6771, 0.6652]}, {"w": "(so", "b": [0.6819, 0.6438, 0.7074, 0.6652]}, {"w": "its", "b": [0.7123, 0.6438, 0.7318, 0.6652]}, {"w": "area", "b": [0.7367, 0.6438, 0.7716, 0.6652]}, {"w": "is", "b": [0.7764, 0.6438, 0.7896, 0.6652]}, {"w": "divided", "b": [0.7945, 0.6438, 0.8571, 0.6652]}, {"w": "by", "b": [0.1786, 0.6629, 0.1987, 0.6843]}, {"w": "16),", "b": [0.2048, 0.6629, 0.2367, 0.6843]}, {"w": "to", "b": [0.2428, 0.6629, 0.2598, 0.6843]}, {"w": "reduce", "b": [0.2658, 0.6629, 0.3222, 0.6843]}, {"w": "the", "b": [0.3282, 0.6629, 0.3546, 0.6843]}, {"w": "computational", "b": [0.3606, 0.6629, 0.4822, 0.6843]}, {"w": "load.", "b": [0.4882, 0.6629, 0.529, 0.6843]}, {"w": "The", "b": [0.5351, 0.6629, 0.5679, 0.6843]}, {"w": "first", "b": [0.574, 0.6629, 0.6075, 0.6843]}, {"w": "layer", "b": [0.6135, 0.6629, 0.6537, 0.6843]}, {"w": "uses", "b": [0.6598, 0.6629, 0.695, 0.6843]}, {"w": "a", "b": [0.701, 0.6629, 0.7102, 0.6843]}, {"w": "large", "b": [0.7163, 0.6629, 0.757, 0.6843]}, {"w": "kernel", "b": [0.7631, 0.6629, 0.8155, 0.6843]}, {"w": "size,", "b": [0.8216, 0.6629, 0.8571, 0.6843]}, {"w": "so", "b": [0.1786, 0.6819, 0.1968, 0.7033]}, {"w": "that", "b": [0.2016, 0.6819, 0.2341, 0.7033]}, {"w": "much", "b": [0.2389, 0.6819, 0.2865, 0.7033]}, {"w": "of", "b": [0.2913, 0.6819, 0.3081, 0.7033]}, {"w": "the", "b": [0.3128, 0.6819, 0.3391, 0.7033]}, {"w": "information", "b": [0.3439, 0.6819, 0.4451, 0.7033]}, {"w": "is", "b": [0.4499, 0.6819, 0.4631, 0.7033]}, {"w": "still", "b": [0.4678, 0.6819, 0.4979, 0.7033]}, {"w": "preserved.", "b": [0.5027, 0.6819, 0.5892, 0.7033]}]}, {"id": "b_3", "type": "paragraph", "text": "• Then the local response normalization layer ensures that the previous layers learn a wide variety of features (as discussed earlier).", "words": [{"w": "•", "b": [0.16, 0.707, 0.1682, 0.7284]}, {"w": "Then", "b": [0.1786, 0.707, 0.2228, 0.7284]}, {"w": "the", "b": [0.2275, 0.707, 0.2539, 0.7284]}, {"w": "local", "b": [0.2586, 0.707, 0.2977, 0.7284]}, {"w": "response", "b": [0.3024, 0.707, 0.3761, 0.7284]}, {"w": "normalization", "b": [0.3808, 0.707, 0.4991, 0.7284]}, {"w": "layer", "b": [0.5038, 0.707, 0.544, 0.7284]}, {"w": "ensures", "b": [0.5488, 0.707, 0.6119, 0.7284]}, {"w": "that", "b": [0.6167, 0.707, 0.6493, 0.7284]}, {"w": "the", "b": [0.654, 0.707, 0.6803, 0.7284]}, {"w": "previous", "b": [0.685, 0.707, 0.7571, 0.7284]}, {"w": "layers", "b": [0.7618, 0.707, 0.8097, 0.7284]}, {"w": "learn", "b": [0.8144, 0.707, 0.8568, 0.7284]}, {"w": "a", "b": [0.1786, 0.7261, 0.1877, 0.7475]}, {"w": "wide", "b": [0.1924, 0.7261, 0.2321, 0.7475]}, {"w": "variety", "b": [0.2369, 0.7261, 0.2938, 0.7475]}, {"w": "of", "b": [0.2985, 0.7261, 0.3153, 0.7475]}, {"w": "features", "b": [0.32, 0.7261, 0.3854, 0.7475]}, {"w": "(as", "b": [0.3901, 0.7261, 0.4141, 0.7475]}, {"w": "discussed", "b": [0.4189, 0.7261, 0.4981, 0.7475]}, {"w": "earlier).", "b": [0.5029, 0.7261, 0.568, 0.7475]}]}, {"id": "b_4", "type": "paragraph", "text": "• Two convolutional layers follow, where the first acts like a bottleneck layer. As explained earlier, you can think of this pair as a single smarter convolutional layer.", "words": [{"w": "•", "b": [0.16, 0.7511, 0.1682, 0.7726]}, {"w": "Two", "b": [0.1786, 0.7511, 0.2148, 0.7726]}, {"w": "convolutional", "b": [0.2225, 0.7511, 0.3379, 0.7726]}, {"w": "layers", "b": [0.3456, 0.7511, 0.3934, 0.7726]}, {"w": "follow,", "b": [0.4012, 0.7511, 0.4566, 0.7726]}, {"w": "where", "b": [0.4644, 0.7511, 0.5152, 0.7726]}, {"w": "the", "b": [0.523, 0.7511, 0.5493, 0.7726]}, {"w": "first", "b": [0.557, 0.7511, 0.5905, 0.7726]}, {"w": "acts", "b": [0.5983, 0.7511, 0.6302, 0.7726]}, {"w": "like", "b": [0.638, 0.7511, 0.668, 0.7726]}, {"w": "a", "b": [0.6757, 0.7511, 0.6849, 0.7726]}, {"w": "bottleneck", "b": [0.6926, 0.7509, 0.7749, 0.7726]}, {"w": "layer.", "b": [0.7827, 0.7509, 0.8274, 0.7726]}, {"w": "As", "b": [0.8351, 0.7511, 0.8571, 0.7726]}, {"w": "explained", "b": [0.1786, 0.7702, 0.2594, 0.7916]}, {"w": "earlier,", "b": [0.2678, 0.7702, 0.3244, 0.7916]}, {"w": "you", "b": [0.3328, 0.7702, 0.364, 0.7916]}, {"w": "can", "b": [0.3724, 0.7702, 0.4018, 0.7916]}, {"w": "think", "b": [0.4102, 0.7702, 0.4549, 0.7916]}, {"w": "of", "b": [0.4633, 0.7702, 0.4801, 0.7916]}, {"w": "this", "b": [0.4885, 0.7702, 0.5192, 0.7916]}, {"w": "pair", "b": [0.5276, 0.7702, 0.561, 0.7916]}, {"w": "as", "b": [0.5693, 0.7702, 0.5861, 0.7916]}, {"w": "a", "b": [0.5945, 0.7702, 0.6037, 0.7916]}, {"w": "single", "b": [0.612, 0.7702, 0.6605, 0.7916]}, {"w": "smarter", "b": [0.6689, 0.7702, 0.7334, 0.7916]}, {"w": "convolutional", "b": [0.7418, 0.7702, 0.8571, 0.7916]}, {"w": "layer.", "b": [0.1786, 0.7892, 0.2222, 0.8107]}]}, {"id": "b_5", "type": "paragraph", "text": "• Again, a local response normalization layer ensures that the previous layers cap‐ ture a wide variety of patterns.", "words": [{"w": "•", "b": [0.16, 0.8143, 0.1682, 0.8357]}, {"w": "Again,", "b": [0.1786, 0.8143, 0.2336, 0.8357]}, {"w": "a", "b": [0.2395, 0.8143, 0.2487, 0.8357]}, {"w": "local", "b": [0.2546, 0.8143, 0.2937, 0.8357]}, {"w": "response", "b": [0.2997, 0.8143, 0.3733, 0.8357]}, {"w": "normalization", "b": [0.3793, 0.8143, 0.4975, 0.8357]}, {"w": "layer", "b": [0.5035, 0.8143, 0.5436, 0.8357]}, {"w": "ensures", "b": [0.5496, 0.8143, 0.6128, 0.8357]}, {"w": "that", "b": [0.6187, 0.8143, 0.6513, 0.8357]}, {"w": "the", "b": [0.6572, 0.8143, 0.6835, 0.8357]}, {"w": "previous", "b": [0.6895, 0.8143, 0.7615, 0.8357]}, {"w": "layers", "b": [0.7675, 0.8143, 0.8153, 0.8357]}, {"w": "cap‐", "b": [0.8212, 0.8143, 0.8571, 0.8357]}, {"w": "ture", "b": [0.1786, 0.8334, 0.2126, 0.8548]}, {"w": "a", "b": [0.2173, 0.8334, 0.2264, 0.8548]}, {"w": "wide", "b": [0.2312, 0.8334, 0.2709, 0.8548]}, {"w": "variety", "b": [0.2756, 0.8334, 0.3325, 0.8548]}, {"w": "of", "b": [0.3372, 0.8334, 0.354, 0.8548]}, {"w": "patterns.", "b": [0.3587, 0.8334, 0.4315, 0.8548]}]}, {"id": "b_6", "type": "paragraph", "text": "CNN Architectures | 455", "words": [{"w": "CNN", "b": [0.6907, 0.9225, 0.7152, 0.9388]}, {"w": "Architectures", "b": [0.718, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "455", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 482, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "14 “Very Deep Convolutional Networks for Large-Scale Image Recognition,” K. Simonyan and A. Zisserman (2015).", "words": [{"w": "14", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "“Very", "b": [0.1587, 0.8598, 0.195, 0.8761]}, {"w": "Deep", "b": [0.1987, 0.8598, 0.2321, 0.8761]}, {"w": "Convolutional", "b": [0.2357, 0.8598, 0.3274, 0.8761]}, {"w": "Networks", "b": [0.331, 0.8598, 0.3926, 0.8761]}, {"w": "for", "b": [0.3962, 0.8598, 0.4149, 0.8761]}, {"w": "Large-Scale", "b": [0.4185, 0.8598, 0.4917, 0.8761]}, {"w": "Image", "b": [0.4953, 0.8598, 0.5348, 0.8761]}, {"w": "Recognition,”", "b": [0.5384, 0.8598, 0.6239, 0.8761]}, {"w": "K.", "b": [0.6275, 0.8598, 0.6418, 0.8761]}, {"w": "Simonyan", "b": [0.6454, 0.8598, 0.7095, 0.8761]}, {"w": "and", "b": [0.7131, 0.8598, 0.7371, 0.8761]}, {"w": "A.", "b": [0.7407, 0.8598, 0.7553, 0.8761]}, {"w": "Zisserman", "b": [0.7589, 0.8598, 0.8257, 0.8761]}, {"w": "(2015).", "b": [0.1587, 0.8749, 0.2038, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "• Next a max pooling layer reduces the image height and width by 2, again to speed up computations.", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1681, 0.1005]}, {"w": "Next", "b": [0.1786, 0.0791, 0.2186, 0.1005]}, {"w": "a", "b": [0.2234, 0.0791, 0.2325, 0.1005]}, {"w": "max", "b": [0.2373, 0.0791, 0.2733, 0.1005]}, {"w": "pooling", "b": [0.2781, 0.0791, 0.3423, 0.1005]}, {"w": "layer", "b": [0.3471, 0.0791, 0.3873, 0.1005]}, {"w": "reduces", "b": [0.3921, 0.0791, 0.456, 0.1005]}, {"w": "the", "b": [0.4608, 0.0791, 0.4872, 0.1005]}, {"w": "image", "b": [0.492, 0.0791, 0.5424, 0.1005]}, {"w": "height", "b": [0.5471, 0.0791, 0.5995, 0.1005]}, {"w": "and", "b": [0.6043, 0.0791, 0.6359, 0.1005]}, {"w": "width", "b": [0.6407, 0.0791, 0.689, 0.1005]}, {"w": "by", "b": [0.6938, 0.0791, 0.7139, 0.1005]}, {"w": "2,", "b": [0.7187, 0.0791, 0.7335, 0.1005]}, {"w": "again", "b": [0.7383, 0.0791, 0.7833, 0.1005]}, {"w": "to", "b": [0.7881, 0.0791, 0.8051, 0.1005]}, {"w": "speed", "b": [0.8099, 0.0791, 0.8571, 0.1005]}, {"w": "up", "b": [0.1786, 0.0981, 0.2006, 0.1195]}, {"w": "computations.", "b": [0.2053, 0.0981, 0.3248, 0.1195]}]}, {"id": "b_2", "type": "paragraph", "text": "• Then comes the tall stack of nine inception modules, interleaved with a couple max pooling layers to reduce dimensionality and speed up the net.", "words": [{"w": "•", "b": [0.16, 0.1232, 0.1682, 0.1446]}, {"w": "Then", "b": [0.1786, 0.1232, 0.2228, 0.1446]}, {"w": "comes", "b": [0.2297, 0.1232, 0.2827, 0.1446]}, {"w": "the", "b": [0.2896, 0.1232, 0.3159, 0.1446]}, {"w": "tall", "b": [0.3229, 0.1232, 0.3489, 0.1446]}, {"w": "stack", "b": [0.3558, 0.1232, 0.3981, 0.1446]}, {"w": "of", "b": [0.405, 0.1232, 0.4218, 0.1446]}, {"w": "nine", "b": [0.4287, 0.1232, 0.4659, 0.1446]}, {"w": "inception", "b": [0.4729, 0.1232, 0.5524, 0.1446]}, {"w": "modules,", "b": [0.5593, 0.1232, 0.6356, 0.1446]}, {"w": "interleaved", "b": [0.6425, 0.1232, 0.7344, 0.1446]}, {"w": "with", "b": [0.7413, 0.1232, 0.7786, 0.1446]}, {"w": "a", "b": [0.7855, 0.1232, 0.7947, 0.1446]}, {"w": "couple", "b": [0.8016, 0.1232, 0.8571, 0.1446]}, {"w": "max", "b": [0.1786, 0.1423, 0.2146, 0.1637]}, {"w": "pooling", "b": [0.2193, 0.1423, 0.2835, 0.1637]}, {"w": "layers", "b": [0.2882, 0.1423, 0.3361, 0.1637]}, {"w": "to", "b": [0.3408, 0.1423, 0.3578, 0.1637]}, {"w": "reduce", "b": [0.3625, 0.1423, 0.4188, 0.1637]}, {"w": "dimensionality", "b": [0.4236, 0.1423, 0.5486, 0.1637]}, {"w": "and", "b": [0.5533, 0.1423, 0.5849, 0.1637]}, {"w": "speed", "b": [0.5896, 0.1423, 0.6369, 0.1637]}, {"w": "up", "b": [0.6416, 0.1423, 0.6636, 0.1637]}, {"w": "the", "b": [0.6683, 0.1423, 0.6947, 0.1637]}, {"w": "net.", "b": [0.6994, 0.1423, 0.7307, 0.1637]}]}, {"id": "b_3", "type": "paragraph", "text": "• Next, the global average pooling layer simply outputs the mean of each feature map: this drops any remaining spatial information, which is fine since there was not much spatial information left at that point. Indeed, GoogLeNet input images are typically expected to be 224 × 224 pixels, so after 5 max pooling layers, each dividing the height and width by 2, the feature maps are down to 7 × 7. More‐ over, it is a classification task, not localization, so it does not matter where the object is. Thanks to the dimensionality reduction brought by this layer, there is no need to have several fully connected layers at the top of the CNN (like in AlexNet), and this considerably reduces the number of parameters in the net‐ work and limits the risk of overfitting.", "words": [{"w": "•", "b": [0.16, 0.1673, 0.1682, 0.1888]}, {"w": "Next,", "b": [0.1786, 0.1673, 0.2233, 0.1888]}, {"w": "the", "b": [0.2304, 0.1673, 0.2567, 0.1888]}, {"w": "global", "b": [0.2638, 0.1673, 0.3144, 0.1888]}, {"w": "average", "b": [0.3215, 0.1673, 0.3842, 0.1888]}, {"w": "pooling", "b": [0.3913, 0.1673, 0.4555, 0.1888]}, {"w": "layer", "b": [0.4625, 0.1673, 0.5027, 0.1888]}, {"w": "simply", "b": [0.5098, 0.1673, 0.5654, 0.1888]}, {"w": "outputs", "b": [0.5725, 0.1673, 0.6365, 0.1888]}, {"w": "the", "b": [0.6436, 0.1673, 0.6699, 0.1888]}, {"w": "mean", "b": [0.677, 0.1673, 0.7234, 0.1888]}, {"w": "of", "b": [0.7305, 0.1673, 0.7473, 0.1888]}, {"w": "each", "b": [0.7544, 0.1673, 0.7923, 0.1888]}, {"w": "feature", "b": [0.7994, 0.1673, 0.8571, 0.1888]}, {"w": "map:", "b": [0.1786, 0.1864, 0.2201, 0.2078]}, {"w": "this", "b": [0.2259, 0.1864, 0.2566, 0.2078]}, {"w": "drops", "b": [0.2625, 0.1864, 0.3104, 0.2078]}, {"w": "any", "b": [0.3162, 0.1864, 0.3459, 0.2078]}, {"w": "remaining", "b": [0.3517, 0.1864, 0.4382, 0.2078]}, {"w": "spatial", "b": [0.4441, 0.1864, 0.4977, 0.2078]}, {"w": "information,", "b": [0.5036, 0.1864, 0.6096, 0.2078]}, {"w": "which", "b": [0.6155, 0.1864, 0.6664, 0.2078]}, {"w": "is", "b": [0.6722, 0.1864, 0.6855, 0.2078]}, {"w": "fine", "b": [0.6913, 0.1864, 0.7233, 0.2078]}, {"w": "since", "b": [0.7292, 0.1864, 0.7715, 0.2078]}, {"w": "there", "b": [0.7773, 0.1864, 0.8202, 0.2078]}, {"w": "was", "b": [0.8261, 0.1864, 0.8571, 0.2078]}, {"w": "not", "b": [0.1786, 0.2054, 0.2069, 0.2269]}, {"w": "much", "b": [0.2126, 0.2054, 0.2602, 0.2269]}, {"w": "spatial", "b": [0.2659, 0.2054, 0.3195, 0.2269]}, {"w": "information", "b": [0.3252, 0.2054, 0.4264, 0.2269]}, {"w": "left", "b": [0.4321, 0.2054, 0.4587, 0.2269]}, {"w": "at", "b": [0.4644, 0.2054, 0.4795, 0.2269]}, {"w": "that", "b": [0.4851, 0.2054, 0.5177, 0.2269]}, {"w": "point.", "b": [0.5233, 0.2054, 0.5726, 0.2269]}, {"w": "Indeed,", "b": [0.5782, 0.2054, 0.6411, 0.2269]}, {"w": "GoogLeNet", "b": [0.6468, 0.2054, 0.7429, 0.2269]}, {"w": "input", "b": [0.7485, 0.2054, 0.7935, 0.2269]}, {"w": "images", "b": [0.7991, 0.2054, 0.8571, 0.2269]}, {"w": "are", "b": [0.1786, 0.2245, 0.2043, 0.2459]}, {"w": "typically", "b": [0.2103, 0.2245, 0.2808, 0.2459]}, {"w": "expected", "b": [0.2868, 0.2245, 0.3603, 0.2459]}, {"w": "to", "b": [0.3663, 0.2245, 0.3833, 0.2459]}, {"w": "be", "b": [0.3893, 0.2245, 0.4088, 0.2459]}, {"w": "224", "b": [0.4148, 0.2245, 0.4448, 0.2459]}, {"w": "×", "b": [0.4508, 0.2245, 0.4629, 0.2459]}, {"w": "224", "b": [0.4689, 0.2245, 0.4989, 0.2459]}, {"w": "pixels,", "b": [0.5049, 0.2245, 0.5578, 0.2459]}, {"w": "so", "b": [0.5638, 0.2245, 0.5821, 0.2459]}, {"w": "after", "b": [0.5881, 0.2245, 0.6263, 0.2459]}, {"w": "5", "b": [0.6323, 0.2245, 0.6423, 0.2459]}, {"w": "max", "b": [0.6484, 0.2245, 0.6844, 0.2459]}, {"w": "pooling", "b": [0.6904, 0.2245, 0.7546, 0.2459]}, {"w": "layers,", "b": [0.7606, 0.2245, 0.8132, 0.2459]}, {"w": "each", "b": [0.8192, 0.2245, 0.8571, 0.2459]}, {"w": "dividing", "b": [0.1786, 0.2435, 0.2481, 0.2649]}, {"w": "the", "b": [0.2548, 0.2435, 0.2812, 0.2649]}, {"w": "height", "b": [0.2879, 0.2435, 0.3403, 0.2649]}, {"w": "and", "b": [0.347, 0.2435, 0.3786, 0.2649]}, {"w": "width", "b": [0.3853, 0.2435, 0.4336, 0.2649]}, {"w": "by", "b": [0.4403, 0.2435, 0.4605, 0.2649]}, {"w": "2,", "b": [0.4672, 0.2435, 0.482, 0.2649]}, {"w": "the", "b": [0.4887, 0.2435, 0.515, 0.2649]}, {"w": "feature", "b": [0.5217, 0.2435, 0.5795, 0.2649]}, {"w": "maps", "b": [0.5862, 0.2435, 0.6306, 0.2649]}, {"w": "are", "b": [0.6373, 0.2435, 0.6631, 0.2649]}, {"w": "down", "b": [0.6698, 0.2435, 0.7171, 0.2649]}, {"w": "to", "b": [0.7238, 0.2435, 0.7408, 0.2649]}, {"w": "7", "b": [0.7475, 0.2435, 0.7575, 0.2649]}, {"w": "×", "b": [0.7642, 0.2435, 0.7763, 0.2649]}, {"w": "7.", "b": [0.783, 0.2435, 0.7978, 0.2649]}, {"w": "More‐", "b": [0.8045, 0.2435, 0.8572, 0.2649]}, {"w": "over,", "b": [0.1786, 0.2626, 0.2189, 0.284]}, {"w": "it", "b": [0.226, 0.2626, 0.2379, 0.284]}, {"w": "is", "b": [0.2451, 0.2626, 0.2583, 0.284]}, {"w": "a", "b": [0.2655, 0.2626, 0.2746, 0.284]}, {"w": "classification", "b": [0.2818, 0.2626, 0.3891, 0.284]}, {"w": "task,", "b": [0.3963, 0.2626, 0.4345, 0.284]}, {"w": "not", "b": [0.4417, 0.2626, 0.47, 0.284]}, {"w": "localization,", "b": [0.4772, 0.2626, 0.5781, 0.284]}, {"w": "so", "b": [0.5853, 0.2626, 0.6035, 0.284]}, {"w": "it", "b": [0.6107, 0.2626, 0.6226, 0.284]}, {"w": "does", "b": [0.6298, 0.2626, 0.6679, 0.284]}, {"w": "not", "b": [0.675, 0.2626, 0.7034, 0.284]}, {"w": "matter", "b": [0.7106, 0.2626, 0.7657, 0.284]}, {"w": "where", "b": [0.7728, 0.2626, 0.8237, 0.284]}, {"w": "the", "b": [0.8308, 0.2626, 0.8571, 0.284]}, {"w": "object", "b": [0.1786, 0.2816, 0.2291, 0.303]}, {"w": "is.", "b": [0.2358, 0.2816, 0.2538, 0.303]}, {"w": "Thanks", "b": [0.2605, 0.2816, 0.323, 0.303]}, {"w": "to", "b": [0.3297, 0.2816, 0.3467, 0.303]}, {"w": "the", "b": [0.3534, 0.2816, 0.3797, 0.303]}, {"w": "dimensionality", "b": [0.3864, 0.2816, 0.5114, 0.303]}, {"w": "reduction", "b": [0.5181, 0.2816, 0.5996, 0.303]}, {"w": "brought", "b": [0.6062, 0.2816, 0.6731, 0.303]}, {"w": "by", "b": [0.6798, 0.2816, 0.6999, 0.303]}, {"w": "this", "b": [0.7066, 0.2816, 0.7373, 0.303]}, {"w": "layer,", "b": [0.744, 0.2816, 0.7876, 0.303]}, {"w": "there", "b": [0.7943, 0.2816, 0.8372, 0.303]}, {"w": "is", "b": [0.8439, 0.2816, 0.8571, 0.303]}, {"w": "no", "b": [0.1786, 0.3007, 0.2006, 0.3221]}, {"w": "need", "b": [0.2087, 0.3007, 0.2488, 0.3221]}, {"w": "to", "b": [0.2568, 0.3007, 0.2738, 0.3221]}, {"w": "have", "b": [0.2819, 0.3007, 0.3203, 0.3221]}, {"w": "several", "b": [0.3284, 0.3007, 0.3855, 0.3221]}, {"w": "fully", "b": [0.3936, 0.3007, 0.4309, 0.3221]}, {"w": "connected", "b": [0.439, 0.3007, 0.5251, 0.3221]}, {"w": "layers", "b": [0.5332, 0.3007, 0.581, 0.3221]}, {"w": "at", "b": [0.5891, 0.3007, 0.6042, 0.3221]}, {"w": "the", "b": [0.6123, 0.3007, 0.6386, 0.3221]}, {"w": "top", "b": [0.6467, 0.3007, 0.6746, 0.3221]}, {"w": "of", "b": [0.6827, 0.3007, 0.6995, 0.3221]}, {"w": "the", "b": [0.7075, 0.3007, 0.7339, 0.3221]}, {"w": "CNN", "b": [0.7419, 0.3007, 0.7868, 0.3221]}, {"w": "(like", "b": [0.7948, 0.3007, 0.8321, 0.3221]}, {"w": "in", "b": [0.8402, 0.3007, 0.8571, 0.3221]}, {"w": "AlexNet),", "b": [0.1786, 0.3197, 0.2591, 0.3411]}, {"w": "and", "b": [0.2668, 0.3197, 0.2984, 0.3411]}, {"w": "this", "b": [0.3061, 0.3197, 0.3368, 0.3411]}, {"w": "considerably", "b": [0.3446, 0.3197, 0.4508, 0.3411]}, {"w": "reduces", "b": [0.4586, 0.3197, 0.5226, 0.3411]}, {"w": "the", "b": [0.5303, 0.3197, 0.5567, 0.3411]}, {"w": "number", "b": [0.5644, 0.3197, 0.6307, 0.3411]}, {"w": "of", "b": [0.6385, 0.3197, 0.6553, 0.3411]}, {"w": "parameters", "b": [0.6631, 0.3197, 0.7565, 0.3411]}, {"w": "in", "b": [0.7643, 0.3197, 0.7812, 0.3411]}, {"w": "the", "b": [0.789, 0.3197, 0.8154, 0.3411]}, {"w": "net‐", "b": [0.8231, 0.3197, 0.8571, 0.3411]}, {"w": "work", "b": [0.1786, 0.3388, 0.2215, 0.3602]}, {"w": "and", "b": [0.2263, 0.3388, 0.2578, 0.3602]}, {"w": "limits", "b": [0.2625, 0.3388, 0.31, 0.3602]}, {"w": "the", "b": [0.3148, 0.3388, 0.3411, 0.3602]}, {"w": "risk", "b": [0.3458, 0.3388, 0.3771, 0.3602]}, {"w": "of", "b": [0.3818, 0.3388, 0.3986, 0.3602]}, {"w": "overfitting.", "b": [0.4034, 0.3388, 0.4961, 0.3602]}]}, {"id": "b_4", "type": "paragraph", "text": "• The last layers are self-explanatory: dropout for regularization, then a fully con‐ nected layer with 1,000 units, since there are a 1,000 classes, and a softmax acti‐ vation function to output estimated class probabilities.", "words": [{"w": "•", "b": [0.16, 0.3639, 0.1682, 0.3853]}, {"w": "The", "b": [0.1786, 0.3639, 0.2114, 0.3853]}, {"w": "last", "b": [0.2175, 0.3639, 0.2459, 0.3853]}, {"w": "layers", "b": [0.2521, 0.3639, 0.2999, 0.3853]}, {"w": "are", "b": [0.306, 0.3639, 0.3317, 0.3853]}, {"w": "self-explanatory:", "b": [0.3379, 0.3639, 0.4777, 0.3853]}, {"w": "dropout", "b": [0.4838, 0.3639, 0.5521, 0.3853]}, {"w": "for", "b": [0.5582, 0.3639, 0.5827, 0.3853]}, {"w": "regularization,", "b": [0.5889, 0.3639, 0.7102, 0.3853]}, {"w": "then", "b": [0.7163, 0.3639, 0.754, 0.3853]}, {"w": "a", "b": [0.7602, 0.3639, 0.7693, 0.3853]}, {"w": "fully", "b": [0.7754, 0.3639, 0.8128, 0.3853]}, {"w": "con‐", "b": [0.8189, 0.3639, 0.8571, 0.3853]}, {"w": "nected", "b": [0.1786, 0.3829, 0.2338, 0.4043]}, {"w": "layer", "b": [0.2399, 0.3829, 0.2801, 0.4043]}, {"w": "with", "b": [0.2861, 0.3829, 0.3235, 0.4043]}, {"w": "1,000", "b": [0.3295, 0.3829, 0.3743, 0.4043]}, {"w": "units,", "b": [0.3803, 0.3829, 0.4271, 0.4043]}, {"w": "since", "b": [0.4332, 0.3829, 0.4755, 0.4043]}, {"w": "there", "b": [0.4815, 0.3829, 0.5245, 0.4043]}, {"w": "are", "b": [0.5305, 0.3829, 0.5562, 0.4043]}, {"w": "a", "b": [0.5623, 0.3829, 0.5714, 0.4043]}, {"w": "1,000", "b": [0.5775, 0.3829, 0.6223, 0.4043]}, {"w": "classes,", "b": [0.6283, 0.3829, 0.6881, 0.4043]}, {"w": "and", "b": [0.6941, 0.3829, 0.7257, 0.4043]}, {"w": "a", "b": [0.7317, 0.3829, 0.7409, 0.4043]}, {"w": "softmax", "b": [0.7469, 0.3829, 0.8138, 0.4043]}, {"w": "acti‐", "b": [0.8198, 0.3829, 0.8571, 0.4043]}, {"w": "vation", "b": [0.1786, 0.402, 0.2309, 0.4234]}, {"w": "function", "b": [0.2356, 0.402, 0.307, 0.4234]}, {"w": "to", "b": [0.3118, 0.402, 0.3288, 0.4234]}, {"w": "output", "b": [0.3335, 0.402, 0.3899, 0.4234]}, {"w": "estimated", "b": [0.3946, 0.402, 0.475, 0.4234]}, {"w": "class", "b": [0.4798, 0.402, 0.5183, 0.4234]}, {"w": "probabilities.", "b": [0.523, 0.402, 0.6322, 0.4234]}]}, {"id": "b_5", "type": "paragraph", "text": "This diagram is slightly simplified: the original GoogLeNet architecture also included two auxiliary classifiers plugged on top of the third and sixth inception modules. They were both composed of one average pooling layer, one convolutional layer, two fully connected layers, and a softmax activation layer. During training, their loss (scaled down by 70%) was added to the overall loss. The goal was to fight the vanish‐ ing gradients problem and regularize the network. However, it was later shown that their effect was relatively minor.", "words": [{"w": "This", "b": [0.1429, 0.4361, 0.1801, 0.4575]}, {"w": "diagram", "b": [0.1853, 0.4361, 0.2547, 0.4575]}, {"w": "is", "b": [0.26, 0.4361, 0.2732, 0.4575]}, {"w": "slightly", "b": [0.2785, 0.4361, 0.3387, 0.4575]}, {"w": "simplified:", "b": [0.3439, 0.4361, 0.4319, 0.4575]}, {"w": "the", "b": [0.4372, 0.4361, 0.4635, 0.4575]}, {"w": "original", "b": [0.4688, 0.4361, 0.5339, 0.4575]}, {"w": "GoogLeNet", "b": [0.5391, 0.4361, 0.6353, 0.4575]}, {"w": "architecture", "b": [0.6405, 0.4361, 0.7409, 0.4575]}, {"w": "also", "b": [0.7462, 0.4361, 0.7789, 0.4575]}, {"w": "included", "b": [0.7842, 0.4361, 0.8571, 0.4575]}, {"w": "two", "b": [0.1428, 0.4552, 0.1741, 0.4766]}, {"w": "auxiliary", "b": [0.1825, 0.4552, 0.2556, 0.4766]}, {"w": "classifiers", "b": [0.264, 0.4552, 0.3441, 0.4766]}, {"w": "plugged", "b": [0.3524, 0.4552, 0.419, 0.4766]}, {"w": "on", "b": [0.4274, 0.4552, 0.4494, 0.4766]}, {"w": "top", "b": [0.4578, 0.4552, 0.4857, 0.4766]}, {"w": "of", "b": [0.4941, 0.4552, 0.5109, 0.4766]}, {"w": "the", "b": [0.5193, 0.4552, 0.5456, 0.4766]}, {"w": "third", "b": [0.554, 0.4552, 0.5958, 0.4766]}, {"w": "and", "b": [0.6041, 0.4552, 0.6357, 0.4766]}, {"w": "sixth", "b": [0.644, 0.4552, 0.6846, 0.4766]}, {"w": "inception", "b": [0.693, 0.4552, 0.7725, 0.4766]}, {"w": "modules.", "b": [0.7809, 0.4552, 0.8571, 0.4766]}, {"w": "They", "b": [0.1429, 0.4742, 0.1853, 0.4956]}, {"w": "were", "b": [0.191, 0.4742, 0.2307, 0.4956]}, {"w": "both", "b": [0.2365, 0.4742, 0.2752, 0.4956]}, {"w": "composed", "b": [0.2809, 0.4742, 0.3661, 0.4956]}, {"w": "of", "b": [0.3718, 0.4742, 0.3886, 0.4956]}, {"w": "one", "b": [0.3944, 0.4742, 0.4252, 0.4956]}, {"w": "average", "b": [0.431, 0.4742, 0.4937, 0.4956]}, {"w": "pooling", "b": [0.4995, 0.4742, 0.5637, 0.4956]}, {"w": "layer,", "b": [0.5694, 0.4742, 0.613, 0.4956]}, {"w": "one", "b": [0.6188, 0.4742, 0.6497, 0.4956]}, {"w": "convolutional", "b": [0.6554, 0.4742, 0.7708, 0.4956]}, {"w": "layer,", "b": [0.7765, 0.4742, 0.8201, 0.4956]}, {"w": "two", "b": [0.8259, 0.4742, 0.8571, 0.4956]}, {"w": "fully", "b": [0.1429, 0.4933, 0.1802, 0.5147]}, {"w": "connected", "b": [0.1894, 0.4933, 0.2755, 0.5147]}, {"w": "layers,", "b": [0.2848, 0.4933, 0.3373, 0.5147]}, {"w": "and", "b": [0.3466, 0.4933, 0.3781, 0.5147]}, {"w": "a", "b": [0.3873, 0.4933, 0.3965, 0.5147]}, {"w": "softmax", "b": [0.4057, 0.4933, 0.4725, 0.5147]}, {"w": "activation", "b": [0.4818, 0.4933, 0.564, 0.5147]}, {"w": "layer.", "b": [0.5732, 0.4933, 0.6169, 0.5147]}, {"w": "During", "b": [0.6261, 0.4933, 0.6869, 0.5147]}, {"w": "training,", "b": [0.6962, 0.4933, 0.7679, 0.5147]}, {"w": "their", "b": [0.7771, 0.4933, 0.8167, 0.5147]}, {"w": "loss", "b": [0.826, 0.4933, 0.8571, 0.5147]}, {"w": "(scaled", "b": [0.1429, 0.5123, 0.2008, 0.5337]}, {"w": "down", "b": [0.2061, 0.5123, 0.2534, 0.5337]}, {"w": "by", "b": [0.2588, 0.5123, 0.2789, 0.5337]}, {"w": "70%)", "b": [0.2843, 0.5123, 0.3272, 0.5337]}, {"w": "was", "b": [0.3326, 0.5123, 0.3636, 0.5337]}, {"w": "added", "b": [0.369, 0.5123, 0.42, 0.5337]}, {"w": "to", "b": [0.4253, 0.5123, 0.4423, 0.5337]}, {"w": "the", "b": [0.4477, 0.5123, 0.474, 0.5337]}, {"w": "overall", "b": [0.4793, 0.5123, 0.5359, 0.5337]}, {"w": "loss.", "b": [0.5412, 0.5123, 0.5772, 0.5337]}, {"w": "The", "b": [0.5825, 0.5123, 0.6153, 0.5337]}, {"w": "goal", "b": [0.6207, 0.5123, 0.6555, 0.5337]}, {"w": "was", "b": [0.6608, 0.5123, 0.6919, 0.5337]}, {"w": "to", "b": [0.6972, 0.5123, 0.7142, 0.5337]}, {"w": "fight", "b": [0.7196, 0.5123, 0.7582, 0.5337]}, {"w": "the", "b": [0.7635, 0.5123, 0.7898, 0.5337]}, {"w": "vanish‐", "b": [0.7952, 0.5123, 0.8571, 0.5337]}, {"w": "ing", "b": [0.1429, 0.5314, 0.1696, 0.5528]}, {"w": "gradients", "b": [0.1761, 0.5314, 0.2532, 0.5528]}, {"w": "problem", "b": [0.2597, 0.5314, 0.3307, 0.5528]}, {"w": "and", "b": [0.3372, 0.5314, 0.3688, 0.5528]}, {"w": "regularize", "b": [0.3753, 0.5314, 0.458, 0.5528]}, {"w": "the", "b": [0.4645, 0.5314, 0.4908, 0.5528]}, {"w": "network.", "b": [0.4973, 0.5314, 0.5717, 0.5528]}, {"w": "However,", "b": [0.5782, 0.5314, 0.657, 0.5528]}, {"w": "it", "b": [0.6635, 0.5314, 0.6755, 0.5528]}, {"w": "was", "b": [0.682, 0.5314, 0.713, 0.5528]}, {"w": "later", "b": [0.7195, 0.5314, 0.7565, 0.5528]}, {"w": "shown", "b": [0.763, 0.5314, 0.8181, 0.5528]}, {"w": "that", "b": [0.8246, 0.5314, 0.8572, 0.5528]}, {"w": "their", "b": [0.1429, 0.5504, 0.1825, 0.5718]}, {"w": "effect", "b": [0.1872, 0.5504, 0.2324, 0.5718]}, {"w": "was", "b": [0.2372, 0.5504, 0.2682, 0.5718]}, {"w": "relatively", "b": [0.273, 0.5504, 0.3488, 0.5718]}, {"w": "minor.", "b": [0.3536, 0.5504, 0.4094, 0.5718]}]}, {"id": "b_6", "type": "paragraph", "text": "Several variants of the GoogLeNet architecture were later proposed by Google researchers, including Inception-v3 and Inception-v4, using slightly different incep‐ tion modules, and reaching even better performance.", "words": [{"w": "Several", "b": [0.1429, 0.5785, 0.2022, 0.5999]}, {"w": "variants", "b": [0.2136, 0.5785, 0.2799, 0.5999]}, {"w": "of", "b": [0.2913, 0.5785, 0.308, 0.5999]}, {"w": "the", "b": [0.3194, 0.5785, 0.3458, 0.5999]}, {"w": "GoogLeNet", "b": [0.3571, 0.5785, 0.4533, 0.5999]}, {"w": "architecture", "b": [0.4647, 0.5785, 0.5651, 0.5999]}, {"w": "were", "b": [0.5765, 0.5785, 0.6162, 0.5999]}, {"w": "later", "b": [0.6276, 0.5785, 0.6645, 0.5999]}, {"w": "proposed", "b": [0.6759, 0.5785, 0.7542, 0.5999]}, {"w": "by", "b": [0.7656, 0.5785, 0.7857, 0.5999]}, {"w": "Google", "b": [0.7971, 0.5785, 0.8571, 0.5999]}, {"w": "researchers,", "b": [0.1429, 0.5976, 0.2417, 0.619]}, {"w": "including", "b": [0.2483, 0.5976, 0.3282, 0.619]}, {"w": "Inception-v3", "b": [0.3348, 0.5976, 0.4429, 0.619]}, {"w": "and", "b": [0.4495, 0.5976, 0.481, 0.619]}, {"w": "Inception-v4,", "b": [0.4876, 0.5976, 0.6005, 0.619]}, {"w": "using", "b": [0.6071, 0.5976, 0.6525, 0.619]}, {"w": "slightly", "b": [0.6591, 0.5976, 0.7193, 0.619]}, {"w": "different", "b": [0.7259, 0.5976, 0.7976, 0.619]}, {"w": "incep‐", "b": [0.8042, 0.5976, 0.8571, 0.619]}, {"w": "tion", "b": [0.1428, 0.6166, 0.1768, 0.638]}, {"w": "modules,", "b": [0.1815, 0.6166, 0.2578, 0.638]}, {"w": "and", "b": [0.2625, 0.6166, 0.2941, 0.638]}, {"w": "reaching", "b": [0.2988, 0.6166, 0.3712, 0.638]}, {"w": "even", "b": [0.3759, 0.6166, 0.4147, 0.638]}, {"w": "better", "b": [0.4194, 0.6166, 0.4681, 0.638]}, {"w": "performance.", "b": [0.4729, 0.6166, 0.5849, 0.638]}]}, {"id": "b_7", "type": "paragraph", "text": "VGGNet", "words": [{"w": "VGGNet", "b": [0.1429, 0.6508, 0.2218, 0.6794]}]}, {"id": "b_8", "type": "paragraph", "text": "The runner up in the ILSVRC 2014 challenge was VGGNet14, developed by K. Simon‐ yan and A. Zisserman. It had a very simple and classical architecture, with 2 or 3 con‐ volutional layers, a pooling layer, then again 2 or 3 convolutional layers, a pooling layer, and so on (with a total of just 16 convolutional layers), plus a final dense net‐ work with 2 hidden layers and the output layer. It used only 3 × 3 filters, but many filters.", "words": [{"w": "The", "b": [0.1429, 0.6853, 0.1757, 0.7067]}, {"w": "runner", "b": [0.1805, 0.6853, 0.2387, 0.7067]}, {"w": "up", "b": [0.2435, 0.6853, 0.2655, 0.7067]}, {"w": "in", "b": [0.2704, 0.6853, 0.2873, 0.7067]}, {"w": "the", "b": [0.2922, 0.6853, 0.3185, 0.7067]}, {"w": "ILSVRC", "b": [0.3233, 0.6853, 0.393, 0.7067]}, {"w": "2014", "b": [0.3978, 0.6853, 0.4378, 0.7067]}, {"w": "challenge", "b": [0.4427, 0.6853, 0.5211, 0.7067]}, {"w": "was", "b": [0.526, 0.6853, 0.557, 0.7067]}, {"w": "VGGNet14,", "b": [0.5619, 0.6853, 0.6519, 0.7067]}, {"w": "developed", "b": [0.6566, 0.6853, 0.7416, 0.7067]}, {"w": "by", "b": [0.7464, 0.6853, 0.7665, 0.7067]}, {"w": "K.", "b": [0.7712, 0.6853, 0.79, 0.7067]}, {"w": "Simon‐", "b": [0.7947, 0.6853, 0.8567, 0.7067]}, {"w": "yan", "b": [0.1429, 0.7043, 0.173, 0.7257]}, {"w": "and", "b": [0.1779, 0.7043, 0.2094, 0.7257]}, {"w": "A.", "b": [0.2143, 0.7043, 0.2335, 0.7257]}, {"w": "Zisserman.", "b": [0.2384, 0.7043, 0.3308, 0.7257]}, {"w": "It", "b": [0.3357, 0.7043, 0.3483, 0.7257]}, {"w": "had", "b": [0.3533, 0.7043, 0.3845, 0.7257]}, {"w": "a", "b": [0.3895, 0.7043, 0.3986, 0.7257]}, {"w": "very", "b": [0.4035, 0.7043, 0.4399, 0.7257]}, {"w": "simple", "b": [0.4448, 0.7043, 0.4998, 0.7257]}, {"w": "and", "b": [0.5047, 0.7043, 0.5362, 0.7257]}, {"w": "classical", "b": [0.5412, 0.7043, 0.6085, 0.7257]}, {"w": "architecture,", "b": [0.6134, 0.7043, 0.7186, 0.7257]}, {"w": "with", "b": [0.7235, 0.7043, 0.7608, 0.7257]}, {"w": "2", "b": [0.7658, 0.7043, 0.7758, 0.7257]}, {"w": "or", "b": [0.7807, 0.7043, 0.799, 0.7257]}, {"w": "3", "b": [0.804, 0.7043, 0.814, 0.7257]}, {"w": "con‐", "b": [0.8189, 0.7043, 0.8571, 0.7257]}, {"w": "volutional", "b": [0.1429, 0.7234, 0.2278, 0.7448]}, {"w": "layers,", "b": [0.2353, 0.7234, 0.2879, 0.7448]}, {"w": "a", "b": [0.2954, 0.7234, 0.3046, 0.7448]}, {"w": "pooling", "b": [0.3121, 0.7234, 0.3762, 0.7448]}, {"w": "layer,", "b": [0.3837, 0.7234, 0.4274, 0.7448]}, {"w": "then", "b": [0.4348, 0.7234, 0.4726, 0.7448]}, {"w": "again", "b": [0.4801, 0.7234, 0.5251, 0.7448]}, {"w": "2", "b": [0.5326, 0.7234, 0.5426, 0.7448]}, {"w": "or", "b": [0.5501, 0.7234, 0.5684, 0.7448]}, {"w": "3", "b": [0.5759, 0.7234, 0.5859, 0.7448]}, {"w": "convolutional", "b": [0.5934, 0.7234, 0.7088, 0.7448]}, {"w": "layers,", "b": [0.7163, 0.7234, 0.7688, 0.7448]}, {"w": "a", "b": [0.7763, 0.7234, 0.7855, 0.7448]}, {"w": "pooling", "b": [0.793, 0.7234, 0.8572, 0.7448]}, {"w": "layer,", "b": [0.1429, 0.7424, 0.1865, 0.7638]}, {"w": "and", "b": [0.1928, 0.7424, 0.2244, 0.7638]}, {"w": "so", "b": [0.2307, 0.7424, 0.249, 0.7638]}, {"w": "on", "b": [0.2554, 0.7424, 0.2774, 0.7638]}, {"w": "(with", "b": [0.2837, 0.7424, 0.3283, 0.7638]}, {"w": "a", "b": [0.3346, 0.7424, 0.3438, 0.7638]}, {"w": "total", "b": [0.3501, 0.7424, 0.3879, 0.7638]}, {"w": "of", "b": [0.3943, 0.7424, 0.411, 0.7638]}, {"w": "just", "b": [0.4174, 0.7424, 0.4478, 0.7638]}, {"w": "16", "b": [0.4542, 0.7424, 0.4742, 0.7638]}, {"w": "convolutional", "b": [0.4805, 0.7424, 0.5958, 0.7638]}, {"w": "layers),", "b": [0.6022, 0.7424, 0.662, 0.7638]}, {"w": "plus", "b": [0.6683, 0.7424, 0.7032, 0.7638]}, {"w": "a", "b": [0.7096, 0.7424, 0.7187, 0.7638]}, {"w": "final", "b": [0.7251, 0.7424, 0.7627, 0.7638]}, {"w": "dense", "b": [0.769, 0.7424, 0.8168, 0.7638]}, {"w": "net‐", "b": [0.8231, 0.7424, 0.8571, 0.7638]}, {"w": "work", "b": [0.1429, 0.7615, 0.1858, 0.7829]}, {"w": "with", "b": [0.1924, 0.7615, 0.2297, 0.7829]}, {"w": "2", "b": [0.2363, 0.7615, 0.2463, 0.7829]}, {"w": "hidden", "b": [0.2529, 0.7615, 0.3119, 0.7829]}, {"w": "layers", "b": [0.3185, 0.7615, 0.3663, 0.7829]}, {"w": "and", "b": [0.3729, 0.7615, 0.4045, 0.7829]}, {"w": "the", "b": [0.4111, 0.7615, 0.4374, 0.7829]}, {"w": "output", "b": [0.444, 0.7615, 0.5004, 0.7829]}, {"w": "layer.", "b": [0.507, 0.7615, 0.5506, 0.7829]}, {"w": "It", "b": [0.5572, 0.7615, 0.5698, 0.7829]}, {"w": "used", "b": [0.5764, 0.7615, 0.615, 0.7829]}, {"w": "only", "b": [0.6216, 0.7615, 0.6584, 0.7829]}, {"w": "3", "b": [0.665, 0.7615, 0.675, 0.7829]}, {"w": "×", "b": [0.6816, 0.7615, 0.6937, 0.7829]}, {"w": "3", "b": [0.7003, 0.7615, 0.7103, 0.7829]}, {"w": "filters,", "b": [0.7169, 0.7615, 0.7693, 0.7829]}, {"w": "but", "b": [0.7759, 0.7615, 0.8039, 0.7829]}, {"w": "many", "b": [0.8105, 0.7615, 0.8571, 0.7829]}, {"w": "filters.", "b": [0.1428, 0.7805, 0.1952, 0.8019]}]}, {"id": "b_9", "type": "paragraph", "text": "456 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "456", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 483, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "15 “Deep Residual Learning for Image Recognition,” K. He (2015).", "words": [{"w": "15", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Deep", "b": [0.1587, 0.8749, 0.1985, 0.8912]}, {"w": "Residual", "b": [0.2021, 0.8749, 0.2566, 0.8912]}, {"w": "Learning", "b": [0.2602, 0.8749, 0.3174, 0.8912]}, {"w": "for", "b": [0.321, 0.8749, 0.3397, 0.8912]}, {"w": "Image", "b": [0.3433, 0.8749, 0.3828, 0.8912]}, {"w": "Recognition,”", "b": [0.3864, 0.8749, 0.4719, 0.8912]}, {"w": "K.", "b": [0.4755, 0.8749, 0.4898, 0.8912]}, {"w": "He", "b": [0.4934, 0.8749, 0.5119, 0.8912]}, {"w": "(2015).", "b": [0.5155, 0.8749, 0.5606, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "ResNet", "words": [{"w": "ResNet", "b": [0.1429, 0.0763, 0.2154, 0.1049]}]}, {"id": "b_2", "type": "paragraph", "text": "The ILSVRC 2015 challenge was won using a Residual Network (or ResNet), devel‐ oped by Kaiming He et al.,15 which delivered an astounding top-5 error rate under 3.6%, using an extremely deep CNN composed of 152 layers. It confirmed the general trend: models are getting deeper and deeper, with fewer and fewer parameters. The key to being able to train such a deep network is to use skip connections (also called shortcut connections): the signal feeding into a layer is also added to the output of a layer located a bit higher up the stack. Let’s see why this is useful.", "words": [{"w": "The", "b": [0.1429, 0.1108, 0.1757, 0.1322]}, {"w": "ILSVRC", "b": [0.183, 0.1108, 0.2526, 0.1322]}, {"w": "2015", "b": [0.2599, 0.1108, 0.2999, 0.1322]}, {"w": "challenge", "b": [0.3072, 0.1108, 0.3857, 0.1322]}, {"w": "was", "b": [0.393, 0.1108, 0.4241, 0.1322]}, {"w": "won", "b": [0.4314, 0.1108, 0.4677, 0.1322]}, {"w": "using", "b": [0.475, 0.1108, 0.5204, 0.1322]}, {"w": "a", "b": [0.5277, 0.1108, 0.5369, 0.1322]}, {"w": "Residual", "b": [0.5442, 0.1106, 0.6137, 0.1322]}, {"w": "Network", "b": [0.621, 0.1106, 0.6904, 0.1322]}, {"w": "(or", "b": [0.6977, 0.1108, 0.7233, 0.1322]}, {"w": "ResNet),", "b": [0.7306, 0.1106, 0.7988, 0.1322]}, {"w": "devel‐", "b": [0.8061, 0.1108, 0.8571, 0.1322]}, {"w": "oped", "b": [0.1429, 0.1298, 0.1842, 0.1512]}, {"w": "by", "b": [0.1914, 0.1298, 0.2116, 0.1512]}, {"w": "Kaiming", "b": [0.2188, 0.1298, 0.2913, 0.1512]}, {"w": "He", "b": [0.2985, 0.1298, 0.3228, 0.1512]}, {"w": "et", "b": [0.33, 0.1298, 0.3452, 0.1512]}, {"w": "al.,15", "b": [0.3524, 0.1298, 0.3877, 0.1512]}, {"w": "which", "b": [0.3949, 0.1298, 0.4458, 0.1512]}, {"w": "delivered", "b": [0.453, 0.1298, 0.5298, 0.1512]}, {"w": "an", "b": [0.537, 0.1298, 0.5575, 0.1512]}, {"w": "astounding", "b": [0.5647, 0.1298, 0.6587, 0.1512]}, {"w": "top-5", "b": [0.6659, 0.1298, 0.7112, 0.1512]}, {"w": "error", "b": [0.7184, 0.1298, 0.761, 0.1512]}, {"w": "rate", "b": [0.7682, 0.1298, 0.7999, 0.1512]}, {"w": "under", "b": [0.8071, 0.1298, 0.8571, 0.1512]}, {"w": "3.6%,", "b": [0.1429, 0.1489, 0.1881, 0.1703]}, {"w": "using", "b": [0.1931, 0.1489, 0.2385, 0.1703]}, {"w": "an", "b": [0.2435, 0.1489, 0.264, 0.1703]}, {"w": "extremely", "b": [0.269, 0.1489, 0.3514, 0.1703]}, {"w": "deep", "b": [0.3563, 0.1489, 0.3959, 0.1703]}, {"w": "CNN", "b": [0.4009, 0.1489, 0.4457, 0.1703]}, {"w": "composed", "b": [0.4507, 0.1489, 0.5358, 0.1703]}, {"w": "of", "b": [0.5408, 0.1489, 0.5576, 0.1703]}, {"w": "152", "b": [0.5625, 0.1489, 0.5925, 0.1703]}, {"w": "layers.", "b": [0.5975, 0.1489, 0.6501, 0.1703]}, {"w": "It", "b": [0.6551, 0.1489, 0.6677, 0.1703]}, {"w": "confirmed", "b": [0.6727, 0.1489, 0.7599, 0.1703]}, {"w": "the", "b": [0.7649, 0.1489, 0.7912, 0.1703]}, {"w": "general", "b": [0.7962, 0.1489, 0.8572, 0.1703]}, {"w": "trend:", "b": [0.1429, 0.1679, 0.1929, 0.1893]}, {"w": "models", "b": [0.1997, 0.1679, 0.2601, 0.1893]}, {"w": "are", "b": [0.2669, 0.1679, 0.2926, 0.1893]}, {"w": "getting", "b": [0.2994, 0.1679, 0.3574, 0.1893]}, {"w": "deeper", "b": [0.3641, 0.1679, 0.4204, 0.1893]}, {"w": "and", "b": [0.4271, 0.1679, 0.4586, 0.1893]}, {"w": "deeper,", "b": [0.4654, 0.1679, 0.525, 0.1893]}, {"w": "with", "b": [0.5318, 0.1679, 0.5691, 0.1893]}, {"w": "fewer", "b": [0.5759, 0.1679, 0.6217, 0.1893]}, {"w": "and", "b": [0.6285, 0.1679, 0.66, 0.1893]}, {"w": "fewer", "b": [0.6668, 0.1679, 0.7126, 0.1893]}, {"w": "parameters.", "b": [0.7194, 0.1679, 0.8176, 0.1893]}, {"w": "The", "b": [0.8243, 0.1679, 0.8571, 0.1893]}, {"w": "key", "b": [0.1429, 0.187, 0.1716, 0.2084]}, {"w": "to", "b": [0.178, 0.187, 0.1949, 0.2084]}, {"w": "being", "b": [0.2013, 0.187, 0.2475, 0.2084]}, {"w": "able", "b": [0.2538, 0.187, 0.2877, 0.2084]}, {"w": "to", "b": [0.294, 0.187, 0.311, 0.2084]}, {"w": "train", "b": [0.3174, 0.187, 0.3576, 0.2084]}, {"w": "such", "b": [0.3639, 0.187, 0.4026, 0.2084]}, {"w": "a", "b": [0.4089, 0.187, 0.4181, 0.2084]}, {"w": "deep", "b": [0.4244, 0.187, 0.4641, 0.2084]}, {"w": "network", "b": [0.4704, 0.187, 0.54, 0.2084]}, {"w": "is", "b": [0.5463, 0.187, 0.5596, 0.2084]}, {"w": "to", "b": [0.5659, 0.187, 0.5829, 0.2084]}, {"w": "use", "b": [0.5893, 0.187, 0.6168, 0.2084]}, {"w": "skip", "b": [0.6232, 0.1868, 0.655, 0.2084]}, {"w": "connections", "b": [0.6614, 0.1868, 0.7562, 0.2084]}, {"w": "(also", "b": [0.7625, 0.187, 0.8024, 0.2084]}, {"w": "called", "b": [0.8088, 0.187, 0.8571, 0.2084]}, {"w": "shortcut", "b": [0.1428, 0.2058, 0.2091, 0.2274]}, {"w": "connections):", "b": [0.2157, 0.2058, 0.3225, 0.2274]}, {"w": "the", "b": [0.3291, 0.206, 0.3554, 0.2274]}, {"w": "signal", "b": [0.362, 0.206, 0.4108, 0.2274]}, {"w": "feeding", "b": [0.4174, 0.206, 0.479, 0.2274]}, {"w": "into", "b": [0.4856, 0.206, 0.5192, 0.2274]}, {"w": "a", "b": [0.5258, 0.206, 0.5349, 0.2274]}, {"w": "layer", "b": [0.5416, 0.206, 0.5817, 0.2274]}, {"w": "is", "b": [0.5883, 0.206, 0.6016, 0.2274]}, {"w": "also", "b": [0.6082, 0.206, 0.6409, 0.2274]}, {"w": "added", "b": [0.6475, 0.206, 0.6985, 0.2274]}, {"w": "to", "b": [0.7051, 0.206, 0.7221, 0.2274]}, {"w": "the", "b": [0.7287, 0.206, 0.755, 0.2274]}, {"w": "output", "b": [0.7616, 0.206, 0.818, 0.2274]}, {"w": "of", "b": [0.8246, 0.206, 0.8414, 0.2274]}, {"w": "a", "b": [0.848, 0.206, 0.8571, 0.2274]}, {"w": "layer", "b": [0.1429, 0.2251, 0.1831, 0.2465]}, {"w": "located", "b": [0.1878, 0.2251, 0.2474, 0.2465]}, {"w": "a", "b": [0.2522, 0.2251, 0.2613, 0.2465]}, {"w": "bit", "b": [0.2661, 0.2251, 0.2886, 0.2465]}, {"w": "higher", "b": [0.2933, 0.2251, 0.3475, 0.2465]}, {"w": "up", "b": [0.3522, 0.2251, 0.3742, 0.2465]}, {"w": "the", "b": [0.3789, 0.2251, 0.4052, 0.2465]}, {"w": "stack.", "b": [0.41, 0.2251, 0.457, 0.2465]}, {"w": "Let’s", "b": [0.4617, 0.2251, 0.4979, 0.2465]}, {"w": "see", "b": [0.5026, 0.2251, 0.528, 0.2465]}, {"w": "why", "b": [0.5327, 0.2251, 0.5672, 0.2465]}, {"w": "this", "b": [0.5719, 0.2251, 0.6026, 0.2465]}, {"w": "is", "b": [0.6074, 0.2251, 0.6206, 0.2465]}, {"w": "useful.", "b": [0.6253, 0.2251, 0.6801, 0.2465]}]}, {"id": "b_3", "type": "paragraph", "text": "When training a neural network, the goal is to make it model a target function h(x). If you add the input x to the output of the network (i.e., you add a skip connection), then the network will be forced to model f(x) = h(x) – x rather than h(x). This is called residual learning (see Figure 14-15).", "words": [{"w": "When", "b": [0.1429, 0.2532, 0.1945, 0.2746]}, {"w": "training", "b": [0.2004, 0.2532, 0.2673, 0.2746]}, {"w": "a", "b": [0.2732, 0.2532, 0.2824, 0.2746]}, {"w": "neural", "b": [0.2883, 0.2532, 0.3418, 0.2746]}, {"w": "network,", "b": [0.3477, 0.2532, 0.422, 0.2746]}, {"w": "the", "b": [0.4279, 0.2532, 0.4542, 0.2746]}, {"w": "goal", "b": [0.4602, 0.2532, 0.495, 0.2746]}, {"w": "is", "b": [0.5009, 0.2532, 0.5141, 0.2746]}, {"w": "to", "b": [0.52, 0.2532, 0.537, 0.2746]}, {"w": "make", "b": [0.5429, 0.2532, 0.5883, 0.2746]}, {"w": "it", "b": [0.5942, 0.2532, 0.6062, 0.2746]}, {"w": "model", "b": [0.6121, 0.2532, 0.6649, 0.2746]}, {"w": "a", "b": [0.6708, 0.2532, 0.68, 0.2746]}, {"w": "target", "b": [0.6859, 0.2532, 0.7341, 0.2746]}, {"w": "function", "b": [0.74, 0.2532, 0.8114, 0.2746]}, {"w": "h(x).", "b": [0.8173, 0.2526, 0.8571, 0.2746]}, {"w": "If", "b": [0.1429, 0.2722, 0.1561, 0.2936]}, {"w": "you", "b": [0.1618, 0.2722, 0.1931, 0.2936]}, {"w": "add", "b": [0.1988, 0.2722, 0.23, 0.2936]}, {"w": "the", "b": [0.2357, 0.2722, 0.262, 0.2936]}, {"w": "input", "b": [0.2677, 0.2722, 0.3127, 0.2936]}, {"w": "x", "b": [0.3184, 0.2717, 0.3284, 0.2936]}, {"w": "to", "b": [0.3341, 0.2722, 0.3511, 0.2936]}, {"w": "the", "b": [0.3568, 0.2722, 0.3832, 0.2936]}, {"w": "output", "b": [0.3889, 0.2722, 0.4453, 0.2936]}, {"w": "of", "b": [0.451, 0.2722, 0.4678, 0.2936]}, {"w": "the", "b": [0.4735, 0.2722, 0.4998, 0.2936]}, {"w": "network", "b": [0.5055, 0.2722, 0.5751, 0.2936]}, {"w": "(i.e.,", "b": [0.5808, 0.2722, 0.6167, 0.2936]}, {"w": "you", "b": [0.6224, 0.2722, 0.6537, 0.2936]}, {"w": "add", "b": [0.6594, 0.2722, 0.6905, 0.2936]}, {"w": "a", "b": [0.6963, 0.2722, 0.7054, 0.2936]}, {"w": "skip", "b": [0.7111, 0.2722, 0.7456, 0.2936]}, {"w": "connection),", "b": [0.7513, 0.2722, 0.8571, 0.2936]}, {"w": "then", "b": [0.1429, 0.2913, 0.1806, 0.3127]}, {"w": "the", "b": [0.1883, 0.2913, 0.2146, 0.3127]}, {"w": "network", "b": [0.2223, 0.2913, 0.2919, 0.3127]}, {"w": "will", "b": [0.2996, 0.2913, 0.33, 0.3127]}, {"w": "be", "b": [0.3377, 0.2913, 0.3571, 0.3127]}, {"w": "forced", "b": [0.3648, 0.2913, 0.418, 0.3127]}, {"w": "to", "b": [0.4257, 0.2913, 0.4427, 0.3127]}, {"w": "model", "b": [0.4503, 0.2913, 0.5032, 0.3127]}, {"w": "f(x)", "b": [0.5109, 0.2907, 0.541, 0.3127]}, {"w": "=", "b": [0.5487, 0.2913, 0.5607, 0.3127]}, {"w": "h(x)", "b": [0.5684, 0.2907, 0.6035, 0.3127]}, {"w": "–", "b": [0.6112, 0.2913, 0.6221, 0.3127]}, {"w": "x", "b": [0.6298, 0.2907, 0.6398, 0.3127]}, {"w": "rather", "b": [0.6475, 0.2913, 0.698, 0.3127]}, {"w": "than", "b": [0.7057, 0.2913, 0.7438, 0.3127]}, {"w": "h(x).", "b": [0.7515, 0.2907, 0.7913, 0.3127]}, {"w": "This", "b": [0.799, 0.2913, 0.8362, 0.3127]}, {"w": "is", "b": [0.8439, 0.2913, 0.8571, 0.3127]}, {"w": "called", "b": [0.1429, 0.3103, 0.1912, 0.3317]}, {"w": "residual", "b": [0.1959, 0.3101, 0.2603, 0.3317]}, {"w": "learning", "b": [0.265, 0.3101, 0.3317, 0.3317]}, {"w": "(see", "b": [0.3365, 0.3103, 0.369, 0.3317]}, {"w": "Figure", "b": [0.3738, 0.3103, 0.4278, 0.3317]}, {"w": "14-15).", "b": [0.4325, 0.3103, 0.4919, 0.3317]}]}, {"id": "b_4", "type": "equation", "text": "Figure 14-15. Residual learning", "words": [{"w": "Figure", "b": [0.1429, 0.5685, 0.1943, 0.5901]}, {"w": "14-15.", "b": [0.1991, 0.5685, 0.2507, 0.5901]}, {"w": "Residual", "b": [0.2555, 0.5685, 0.325, 0.5901]}, {"w": "learning", "b": [0.3297, 0.5685, 0.3964, 0.5901]}]}, {"id": "b_5", "type": "paragraph", "text": "When you initialize a regular neural network, its weights are close to zero, so the net‐ work just outputs values close to zero. If you add a skip connection, the resulting net‐ work just outputs a copy of its inputs; in other words, it initially models the identity function. If the target function is fairly close to the identity function (which is often the case), this will speed up training considerably.", "words": [{"w": "When", "b": [0.1429, 0.6059, 0.1945, 0.6273]}, {"w": "you", "b": [0.1996, 0.6059, 0.2309, 0.6273]}, {"w": "initialize", "b": [0.236, 0.6059, 0.3082, 0.6273]}, {"w": "a", "b": [0.3133, 0.6059, 0.3225, 0.6273]}, {"w": "regular", "b": [0.3276, 0.6059, 0.3872, 0.6273]}, {"w": "neural", "b": [0.3923, 0.6059, 0.4458, 0.6273]}, {"w": "network,", "b": [0.451, 0.6059, 0.5253, 0.6273]}, {"w": "its", "b": [0.5304, 0.6059, 0.55, 0.6273]}, {"w": "weights", "b": [0.5552, 0.6059, 0.6184, 0.6273]}, {"w": "are", "b": [0.6235, 0.6059, 0.6493, 0.6273]}, {"w": "close", "b": [0.6544, 0.6059, 0.6956, 0.6273]}, {"w": "to", "b": [0.7008, 0.6059, 0.7178, 0.6273]}, {"w": "zero,", "b": [0.7229, 0.6059, 0.763, 0.6273]}, {"w": "so", "b": [0.7682, 0.6059, 0.7865, 0.6273]}, {"w": "the", "b": [0.7916, 0.6059, 0.818, 0.6273]}, {"w": "net‐", "b": [0.8231, 0.6059, 0.8572, 0.6273]}, {"w": "work", "b": [0.1429, 0.6249, 0.1858, 0.6463]}, {"w": "just", "b": [0.1908, 0.6249, 0.2212, 0.6463]}, {"w": "outputs", "b": [0.2262, 0.6249, 0.2902, 0.6463]}, {"w": "values", "b": [0.2953, 0.6249, 0.3469, 0.6463]}, {"w": "close", "b": [0.3519, 0.6249, 0.3931, 0.6463]}, {"w": "to", "b": [0.3981, 0.6249, 0.4151, 0.6463]}, {"w": "zero.", "b": [0.4201, 0.6249, 0.4602, 0.6463]}, {"w": "If", "b": [0.4652, 0.6249, 0.4785, 0.6463]}, {"w": "you", "b": [0.4835, 0.6249, 0.5147, 0.6463]}, {"w": "add", "b": [0.5197, 0.6249, 0.5509, 0.6463]}, {"w": "a", "b": [0.5559, 0.6249, 0.565, 0.6463]}, {"w": "skip", "b": [0.57, 0.6249, 0.6045, 0.6463]}, {"w": "connection,", "b": [0.6095, 0.6249, 0.7081, 0.6463]}, {"w": "the", "b": [0.7131, 0.6249, 0.7395, 0.6463]}, {"w": "resulting", "b": [0.7445, 0.6249, 0.8181, 0.6463]}, {"w": "net‐", "b": [0.8231, 0.6249, 0.8571, 0.6463]}, {"w": "work", "b": [0.1429, 0.644, 0.1858, 0.6654]}, {"w": "just", "b": [0.1918, 0.644, 0.2222, 0.6654]}, {"w": "outputs", "b": [0.2282, 0.644, 0.2922, 0.6654]}, {"w": "a", "b": [0.2982, 0.644, 0.3073, 0.6654]}, {"w": "copy", "b": [0.3133, 0.644, 0.3532, 0.6654]}, {"w": "of", "b": [0.3592, 0.644, 0.376, 0.6654]}, {"w": "its", "b": [0.382, 0.644, 0.4015, 0.6654]}, {"w": "inputs;", "b": [0.4075, 0.644, 0.4648, 0.6654]}, {"w": "in", "b": [0.4708, 0.644, 0.4878, 0.6654]}, {"w": "other", "b": [0.4938, 0.644, 0.5385, 0.6654]}, {"w": "words,", "b": [0.5444, 0.644, 0.6005, 0.6654]}, {"w": "it", "b": [0.6064, 0.644, 0.6184, 0.6654]}, {"w": "initially", "b": [0.6244, 0.644, 0.6881, 0.6654]}, {"w": "models", "b": [0.6941, 0.644, 0.7546, 0.6654]}, {"w": "the", "b": [0.7605, 0.644, 0.7869, 0.6654]}, {"w": "identity", "b": [0.7928, 0.644, 0.8571, 0.6654]}, {"w": "function.", "b": [0.1428, 0.663, 0.219, 0.6844]}, {"w": "If", "b": [0.2252, 0.663, 0.2385, 0.6844]}, {"w": "the", "b": [0.2447, 0.663, 0.2711, 0.6844]}, {"w": "target", "b": [0.2773, 0.663, 0.3255, 0.6844]}, {"w": "function", "b": [0.3317, 0.663, 0.4031, 0.6844]}, {"w": "is", "b": [0.4094, 0.663, 0.4226, 0.6844]}, {"w": "fairly", "b": [0.4288, 0.663, 0.4723, 0.6844]}, {"w": "close", "b": [0.4785, 0.663, 0.5197, 0.6844]}, {"w": "to", "b": [0.526, 0.663, 0.5429, 0.6844]}, {"w": "the", "b": [0.5492, 0.663, 0.5755, 0.6844]}, {"w": "identity", "b": [0.5818, 0.663, 0.646, 0.6844]}, {"w": "function", "b": [0.6523, 0.663, 0.7237, 0.6844]}, {"w": "(which", "b": [0.7299, 0.663, 0.788, 0.6844]}, {"w": "is", "b": [0.7943, 0.663, 0.8075, 0.6844]}, {"w": "often", "b": [0.8137, 0.663, 0.8571, 0.6844]}, {"w": "the", "b": [0.1429, 0.6821, 0.1692, 0.7035]}, {"w": "case),", "b": [0.1739, 0.6821, 0.2203, 0.7035]}, {"w": "this", "b": [0.2251, 0.6821, 0.2558, 0.7035]}, {"w": "will", "b": [0.2605, 0.6821, 0.2909, 0.7035]}, {"w": "speed", "b": [0.2956, 0.6821, 0.3429, 0.7035]}, {"w": "up", "b": [0.3476, 0.6821, 0.3696, 0.7035]}, {"w": "training", "b": [0.3743, 0.6821, 0.4413, 0.7035]}, {"w": "considerably.", "b": [0.446, 0.6821, 0.5554, 0.7035]}]}, {"id": "b_6", "type": "paragraph", "text": "Moreover, if you add many skip connections, the network can start making progress even if several layers have not started learning yet (see Figure 14-16). Thanks to skip connections, the signal can easily make its way across the whole network. The deep residual network can be seen as a stack of residual units, where each residual unit is a small neural network with a skip connection.", "words": [{"w": "Moreover,", "b": [0.1429, 0.7102, 0.2284, 0.7316]}, {"w": "if", "b": [0.2343, 0.7102, 0.246, 0.7316]}, {"w": "you", "b": [0.2519, 0.7102, 0.2831, 0.7316]}, {"w": "add", "b": [0.289, 0.7102, 0.3202, 0.7316]}, {"w": "many", "b": [0.326, 0.7102, 0.3727, 0.7316]}, {"w": "skip", "b": [0.3786, 0.7102, 0.4131, 0.7316]}, {"w": "connections,", "b": [0.419, 0.7102, 0.5252, 0.7316]}, {"w": "the", "b": [0.5311, 0.7102, 0.5574, 0.7316]}, {"w": "network", "b": [0.5633, 0.7102, 0.6329, 0.7316]}, {"w": "can", "b": [0.6388, 0.7102, 0.6681, 0.7316]}, {"w": "start", "b": [0.674, 0.7102, 0.7112, 0.7316]}, {"w": "making", "b": [0.7171, 0.7102, 0.7804, 0.7316]}, {"w": "progress", "b": [0.7863, 0.7102, 0.8571, 0.7316]}, {"w": "even", "b": [0.1429, 0.7292, 0.1816, 0.7507]}, {"w": "if", "b": [0.1874, 0.7292, 0.1992, 0.7507]}, {"w": "several", "b": [0.205, 0.7292, 0.2621, 0.7507]}, {"w": "layers", "b": [0.2679, 0.7292, 0.3157, 0.7507]}, {"w": "have", "b": [0.3215, 0.7292, 0.3599, 0.7507]}, {"w": "not", "b": [0.3657, 0.7292, 0.3941, 0.7507]}, {"w": "started", "b": [0.3999, 0.7292, 0.457, 0.7507]}, {"w": "learning", "b": [0.4628, 0.7292, 0.5319, 0.7507]}, {"w": "yet", "b": [0.5377, 0.7292, 0.5625, 0.7507]}, {"w": "(see", "b": [0.5683, 0.7292, 0.6008, 0.7507]}, {"w": "Figure", "b": [0.6066, 0.7292, 0.6606, 0.7507]}, {"w": "14-16).", "b": [0.6664, 0.7292, 0.7258, 0.7507]}, {"w": "Thanks", "b": [0.7316, 0.7292, 0.7941, 0.7507]}, {"w": "to", "b": [0.7999, 0.7292, 0.8169, 0.7507]}, {"w": "skip", "b": [0.8227, 0.7292, 0.8571, 0.7507]}, {"w": "connections,", "b": [0.1429, 0.7483, 0.2491, 0.7697]}, {"w": "the", "b": [0.2556, 0.7483, 0.282, 0.7697]}, {"w": "signal", "b": [0.2885, 0.7483, 0.3373, 0.7697]}, {"w": "can", "b": [0.3439, 0.7483, 0.3732, 0.7697]}, {"w": "easily", "b": [0.3798, 0.7483, 0.4258, 0.7697]}, {"w": "make", "b": [0.4324, 0.7483, 0.4778, 0.7697]}, {"w": "its", "b": [0.4843, 0.7483, 0.5039, 0.7697]}, {"w": "way", "b": [0.5104, 0.7483, 0.543, 0.7697]}, {"w": "across", "b": [0.5496, 0.7483, 0.6012, 0.7697]}, {"w": "the", "b": [0.6077, 0.7483, 0.634, 0.7697]}, {"w": "whole", "b": [0.6406, 0.7483, 0.6907, 0.7697]}, {"w": "network.", "b": [0.6973, 0.7483, 0.7716, 0.7697]}, {"w": "The", "b": [0.7781, 0.7483, 0.811, 0.7697]}, {"w": "deep", "b": [0.8175, 0.7483, 0.8571, 0.7697]}, {"w": "residual", "b": [0.1429, 0.7673, 0.2092, 0.7888]}, {"w": "network", "b": [0.2146, 0.7673, 0.2841, 0.7888]}, {"w": "can", "b": [0.2895, 0.7673, 0.3189, 0.7888]}, {"w": "be", "b": [0.3243, 0.7673, 0.3437, 0.7888]}, {"w": "seen", "b": [0.3492, 0.7673, 0.3859, 0.7888]}, {"w": "as", "b": [0.3913, 0.7673, 0.4081, 0.7888]}, {"w": "a", "b": [0.4135, 0.7673, 0.4227, 0.7888]}, {"w": "stack", "b": [0.4281, 0.7673, 0.4704, 0.7888]}, {"w": "of", "b": [0.4758, 0.7673, 0.4926, 0.7888]}, {"w": "residual", "b": [0.498, 0.7671, 0.5623, 0.7888]}, {"w": "units,", "b": [0.5671, 0.7671, 0.6128, 0.7888]}, {"w": "where", "b": [0.6183, 0.7673, 0.6691, 0.7888]}, {"w": "each", "b": [0.6745, 0.7673, 0.7124, 0.7888]}, {"w": "residual", "b": [0.7179, 0.7673, 0.7841, 0.7888]}, {"w": "unit", "b": [0.7896, 0.7673, 0.824, 0.7888]}, {"w": "is", "b": [0.8294, 0.7673, 0.8426, 0.7888]}, {"w": "a", "b": [0.848, 0.7673, 0.8571, 0.7888]}, {"w": "small", "b": [0.1429, 0.7864, 0.1873, 0.8078]}, {"w": "neural", "b": [0.192, 0.7864, 0.2454, 0.8078]}, {"w": "network", "b": [0.2502, 0.7864, 0.3197, 0.8078]}, {"w": "with", "b": [0.3245, 0.7864, 0.3618, 0.8078]}, {"w": "a", "b": [0.3665, 0.7864, 0.3757, 0.8078]}, {"w": "skip", "b": [0.3804, 0.7864, 0.4149, 0.8078]}, {"w": "connection.", "b": [0.4196, 0.7864, 0.5182, 0.8078]}]}, {"id": "b_7", "type": "paragraph", "text": "CNN Architectures | 457", "words": [{"w": "CNN", "b": [0.6907, 0.9225, 0.7152, 0.9388]}, {"w": "Architectures", "b": [0.718, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "457", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 484, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Figure 14-16. Regular deep neural network (left) and deep residual network (right)", "words": [{"w": "Figure", "b": [0.1429, 0.3496, 0.1943, 0.3712]}, {"w": "14-16.", "b": [0.1991, 0.3496, 0.2507, 0.3712]}, {"w": "Regular", "b": [0.2554, 0.3496, 0.3185, 0.3712]}, {"w": "deep", "b": [0.3233, 0.3496, 0.3603, 0.3712]}, {"w": "neural", "b": [0.3651, 0.3496, 0.4176, 0.3712]}, {"w": "network", "b": [0.4224, 0.3496, 0.4886, 0.3712]}, {"w": "(left)", "b": [0.4934, 0.3496, 0.5327, 0.3712]}, {"w": "and", "b": [0.5375, 0.3496, 0.5689, 0.3712]}, {"w": "deep", "b": [0.5736, 0.3496, 0.6107, 0.3712]}, {"w": "residual", "b": [0.6155, 0.3496, 0.6798, 0.3712]}, {"w": "network", "b": [0.6846, 0.3496, 0.7508, 0.3712]}, {"w": "(right)", "b": [0.7556, 0.3496, 0.8082, 0.3712]}]}, {"id": "b_1", "type": "paragraph", "text": "Now let’s look at ResNet’s architecture (see Figure 14-17). It is actually surprisingly simple. It starts and ends exactly like GoogLeNet (except without a dropout layer), and in between is just a very deep stack of simple residual units. Each residual unit is composed of two convolutional layers (and no pooling layer!), with Batch Normaliza‐ tion (BN) and ReLU activation, using 3 × 3 kernels and preserving spatial dimensions (stride 1, SAME padding).", "words": [{"w": "Now", "b": [0.1429, 0.387, 0.1827, 0.4084]}, {"w": "let’s", "b": [0.1899, 0.387, 0.2201, 0.4084]}, {"w": "look", "b": [0.2273, 0.387, 0.2642, 0.4084]}, {"w": "at", "b": [0.2713, 0.387, 0.2864, 0.4084]}, {"w": "ResNet’s", "b": [0.2936, 0.387, 0.363, 0.4084]}, {"w": "architecture", "b": [0.3702, 0.387, 0.4706, 0.4084]}, {"w": "(see", "b": [0.4777, 0.387, 0.5103, 0.4084]}, {"w": "Figure", "b": [0.5175, 0.387, 0.5715, 0.4084]}, {"w": "14-17).", "b": [0.5787, 0.387, 0.638, 0.4084]}, {"w": "It", "b": [0.6452, 0.387, 0.6579, 0.4084]}, {"w": "is", "b": [0.6651, 0.387, 0.6783, 0.4084]}, {"w": "actually", "b": [0.6855, 0.387, 0.7501, 0.4084]}, {"w": "surprisingly", "b": [0.7573, 0.387, 0.8571, 0.4084]}, {"w": "simple.", "b": [0.1429, 0.4061, 0.2025, 0.4275]}, {"w": "It", "b": [0.2098, 0.4061, 0.2224, 0.4275]}, {"w": "starts", "b": [0.2297, 0.4061, 0.2745, 0.4275]}, {"w": "and", "b": [0.2818, 0.4061, 0.3133, 0.4275]}, {"w": "ends", "b": [0.3205, 0.4061, 0.3594, 0.4275]}, {"w": "exactly", "b": [0.3667, 0.4061, 0.4245, 0.4275]}, {"w": "like", "b": [0.4317, 0.4061, 0.4618, 0.4275]}, {"w": "GoogLeNet", "b": [0.469, 0.4061, 0.5651, 0.4275]}, {"w": "(except", "b": [0.5724, 0.4061, 0.6332, 0.4275]}, {"w": "without", "b": [0.6405, 0.4061, 0.7058, 0.4275]}, {"w": "a", "b": [0.7131, 0.4061, 0.7222, 0.4275]}, {"w": "dropout", "b": [0.7294, 0.4061, 0.7978, 0.4275]}, {"w": "layer),", "b": [0.805, 0.4061, 0.8571, 0.4275]}, {"w": "and", "b": [0.1429, 0.4251, 0.1744, 0.4465]}, {"w": "in", "b": [0.1798, 0.4251, 0.1968, 0.4465]}, {"w": "between", "b": [0.2021, 0.4251, 0.2713, 0.4465]}, {"w": "is", "b": [0.2767, 0.4251, 0.2899, 0.4465]}, {"w": "just", "b": [0.2952, 0.4251, 0.3256, 0.4465]}, {"w": "a", "b": [0.331, 0.4251, 0.3402, 0.4465]}, {"w": "very", "b": [0.3455, 0.4251, 0.3819, 0.4465]}, {"w": "deep", "b": [0.3873, 0.4251, 0.4269, 0.4465]}, {"w": "stack", "b": [0.4323, 0.4251, 0.4746, 0.4465]}, {"w": "of", "b": [0.4799, 0.4251, 0.4967, 0.4465]}, {"w": "simple", "b": [0.5021, 0.4251, 0.557, 0.4465]}, {"w": "residual", "b": [0.5624, 0.4251, 0.6287, 0.4465]}, {"w": "units.", "b": [0.6341, 0.4251, 0.6809, 0.4465]}, {"w": "Each", "b": [0.6862, 0.4251, 0.7271, 0.4465]}, {"w": "residual", "b": [0.7325, 0.4251, 0.7988, 0.4465]}, {"w": "unit", "b": [0.8042, 0.4251, 0.8386, 0.4465]}, {"w": "is", "b": [0.8439, 0.4251, 0.8572, 0.4465]}, {"w": "composed", "b": [0.1429, 0.4442, 0.228, 0.4656]}, {"w": "of", "b": [0.233, 0.4442, 0.2498, 0.4656]}, {"w": "two", "b": [0.2548, 0.4442, 0.286, 0.4656]}, {"w": "convolutional", "b": [0.291, 0.4442, 0.4063, 0.4656]}, {"w": "layers", "b": [0.4113, 0.4442, 0.4591, 0.4656]}, {"w": "(and", "b": [0.4641, 0.4442, 0.5029, 0.4656]}, {"w": "no", "b": [0.5078, 0.4442, 0.5299, 0.4656]}, {"w": "pooling", "b": [0.5348, 0.4442, 0.599, 0.4656]}, {"w": "layer!),", "b": [0.604, 0.4442, 0.6619, 0.4656]}, {"w": "with", "b": [0.6669, 0.4442, 0.7042, 0.4656]}, {"w": "Batch", "b": [0.7092, 0.4442, 0.7565, 0.4656]}, {"w": "Normaliza‐", "b": [0.7612, 0.4442, 0.8569, 0.4656]}, {"w": "tion", "b": [0.1429, 0.4632, 0.1768, 0.4846]}, {"w": "(BN)", "b": [0.1817, 0.4632, 0.2239, 0.4846]}, {"w": "and", "b": [0.2288, 0.4632, 0.2603, 0.4846]}, {"w": "ReLU", "b": [0.2652, 0.4632, 0.3127, 0.4846]}, {"w": "activation,", "b": [0.3176, 0.4632, 0.4046, 0.4846]}, {"w": "using", "b": [0.4095, 0.4632, 0.455, 0.4846]}, {"w": "3", "b": [0.4599, 0.4632, 0.4699, 0.4846]}, {"w": "×", "b": [0.4748, 0.4632, 0.4869, 0.4846]}, {"w": "3", "b": [0.4918, 0.4632, 0.5018, 0.4846]}, {"w": "kernels", "b": [0.5067, 0.4632, 0.5668, 0.4846]}, {"w": "and", "b": [0.5717, 0.4632, 0.6032, 0.4846]}, {"w": "preserving", "b": [0.6082, 0.4632, 0.6969, 0.4846]}, {"w": "spatial", "b": [0.7018, 0.4632, 0.7554, 0.4846]}, {"w": "dimensions", "b": [0.7603, 0.4632, 0.8571, 0.4846]}, {"w": "(stride", "b": [0.1428, 0.4823, 0.1972, 0.5037]}, {"w": "1,", "b": [0.2019, 0.4823, 0.2167, 0.5037]}, {"w": "SAME", "b": [0.2214, 0.4823, 0.2761, 0.5037]}, {"w": "padding).", "b": [0.2808, 0.4823, 0.3616, 0.5037]}]}, {"id": "b_2", "type": "equation", "text": "Figure 14-17. ResNet architecture", "words": [{"w": "Figure", "b": [0.1428, 0.7788, 0.1943, 0.8004]}, {"w": "14-17.", "b": [0.1991, 0.7788, 0.2507, 0.8004]}, {"w": "ResNet", "b": [0.2554, 0.7788, 0.3117, 0.8004]}, {"w": "architecture", "b": [0.3165, 0.7788, 0.412, 0.8004]}]}, {"id": "b_3", "type": "paragraph", "text": "Note that the number of feature maps is doubled every few residual units, at the same time as their height and width are halved (using a convolutional layer with stride 2). When this happens the inputs cannot be added directly to the outputs of the residual unit since they don’t have the same shape (for example, this problem affects the skip", "words": [{"w": "Note", "b": [0.1428, 0.8162, 0.1836, 0.8376]}, {"w": "that", "b": [0.1887, 0.8162, 0.2213, 0.8376]}, {"w": "the", "b": [0.2263, 0.8162, 0.2527, 0.8376]}, {"w": "number", "b": [0.2577, 0.8162, 0.324, 0.8376]}, {"w": "of", "b": [0.3291, 0.8162, 0.3459, 0.8376]}, {"w": "feature", "b": [0.351, 0.8162, 0.4087, 0.8376]}, {"w": "maps", "b": [0.4138, 0.8162, 0.4582, 0.8376]}, {"w": "is", "b": [0.4632, 0.8162, 0.4765, 0.8376]}, {"w": "doubled", "b": [0.4815, 0.8162, 0.5499, 0.8376]}, {"w": "every", "b": [0.555, 0.8162, 0.6002, 0.8376]}, {"w": "few", "b": [0.6053, 0.8162, 0.6346, 0.8376]}, {"w": "residual", "b": [0.6396, 0.8162, 0.7059, 0.8376]}, {"w": "units,", "b": [0.711, 0.8162, 0.7578, 0.8376]}, {"w": "at", "b": [0.7629, 0.8162, 0.778, 0.8376]}, {"w": "the", "b": [0.783, 0.8162, 0.8094, 0.8376]}, {"w": "same", "b": [0.8144, 0.8162, 0.8571, 0.8376]}, {"w": "time", "b": [0.1429, 0.8353, 0.1807, 0.8567]}, {"w": "as", "b": [0.1867, 0.8353, 0.2034, 0.8567]}, {"w": "their", "b": [0.2094, 0.8353, 0.249, 0.8567]}, {"w": "height", "b": [0.255, 0.8353, 0.3074, 0.8567]}, {"w": "and", "b": [0.3133, 0.8353, 0.3449, 0.8567]}, {"w": "width", "b": [0.3508, 0.8353, 0.3991, 0.8567]}, {"w": "are", "b": [0.4051, 0.8353, 0.4308, 0.8567]}, {"w": "halved", "b": [0.4367, 0.8353, 0.4918, 0.8567]}, {"w": "(using", "b": [0.4977, 0.8353, 0.5504, 0.8567]}, {"w": "a", "b": [0.5563, 0.8353, 0.5655, 0.8567]}, {"w": "convolutional", "b": [0.5714, 0.8353, 0.6867, 0.8567]}, {"w": "layer", "b": [0.6927, 0.8353, 0.7329, 0.8567]}, {"w": "with", "b": [0.7388, 0.8353, 0.7761, 0.8567]}, {"w": "stride", "b": [0.7821, 0.8353, 0.8292, 0.8567]}, {"w": "2).", "b": [0.8352, 0.8353, 0.8571, 0.8567]}, {"w": "When", "b": [0.1429, 0.8543, 0.1945, 0.8757]}, {"w": "this", "b": [0.1998, 0.8543, 0.2306, 0.8757]}, {"w": "happens", "b": [0.2359, 0.8543, 0.3055, 0.8757]}, {"w": "the", "b": [0.3109, 0.8543, 0.3373, 0.8757]}, {"w": "inputs", "b": [0.3426, 0.8543, 0.3952, 0.8757]}, {"w": "cannot", "b": [0.4006, 0.8543, 0.4583, 0.8757]}, {"w": "be", "b": [0.4637, 0.8543, 0.4831, 0.8757]}, {"w": "added", "b": [0.4885, 0.8543, 0.5395, 0.8757]}, {"w": "directly", "b": [0.5449, 0.8543, 0.6081, 0.8757]}, {"w": "to", "b": [0.6135, 0.8543, 0.6304, 0.8757]}, {"w": "the", "b": [0.6358, 0.8543, 0.6622, 0.8757]}, {"w": "outputs", "b": [0.6675, 0.8543, 0.7316, 0.8757]}, {"w": "of", "b": [0.737, 0.8543, 0.7537, 0.8757]}, {"w": "the", "b": [0.7591, 0.8543, 0.7855, 0.8757]}, {"w": "residual", "b": [0.7909, 0.8543, 0.8571, 0.8757]}, {"w": "unit", "b": [0.1429, 0.8733, 0.1772, 0.8948]}, {"w": "since", "b": [0.1832, 0.8733, 0.2255, 0.8948]}, {"w": "they", "b": [0.2315, 0.8733, 0.2674, 0.8948]}, {"w": "don’t", "b": [0.2734, 0.8733, 0.315, 0.8948]}, {"w": "have", "b": [0.3209, 0.8733, 0.3593, 0.8948]}, {"w": "the", "b": [0.3653, 0.8733, 0.3916, 0.8948]}, {"w": "same", "b": [0.3976, 0.8733, 0.4403, 0.8948]}, {"w": "shape", "b": [0.4463, 0.8733, 0.4936, 0.8948]}, {"w": "(for", "b": [0.4996, 0.8733, 0.5313, 0.8948]}, {"w": "example,", "b": [0.5373, 0.8733, 0.6116, 0.8948]}, {"w": "this", "b": [0.6175, 0.8733, 0.6482, 0.8948]}, {"w": "problem", "b": [0.6542, 0.8733, 0.7253, 0.8948]}, {"w": "affects", "b": [0.7312, 0.8733, 0.7844, 0.8948]}, {"w": "the", "b": [0.7903, 0.8733, 0.8167, 0.8948]}, {"w": "skip", "b": [0.8227, 0.8733, 0.8571, 0.8948]}]}, {"id": "b_4", "type": "paragraph", "text": "458 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "458", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 485, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "16 “Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning,” C. Szegedy et al. (2016).", "words": [{"w": "16", "b": [0.1385, 0.8416, 0.1518, 0.8559]}, {"w": "“Inception-v4,", "b": [0.1587, 0.8401, 0.251, 0.8565]}, {"w": "Inception-ResNet", "b": [0.2546, 0.8401, 0.3674, 0.8565]}, {"w": "and", "b": [0.371, 0.8401, 0.3951, 0.8565]}, {"w": "the", "b": [0.3987, 0.8401, 0.4187, 0.8565]}, {"w": "Impact", "b": [0.4223, 0.8401, 0.4673, 0.8565]}, {"w": "of", "b": [0.4709, 0.8401, 0.4837, 0.8565]}, {"w": "Residual", "b": [0.4873, 0.8401, 0.5418, 0.8565]}, {"w": "Connections", "b": [0.5454, 0.8401, 0.6266, 0.8565]}, {"w": "on", "b": [0.6302, 0.8401, 0.6469, 0.8565]}, {"w": "Learning,”", "b": [0.6505, 0.8401, 0.7155, 0.8565]}, {"w": "C.", "b": [0.7191, 0.8401, 0.7333, 0.8565]}, {"w": "Szegedy", "b": [0.7369, 0.8401, 0.7877, 0.8565]}, {"w": "et", "b": [0.7913, 0.8401, 0.8029, 0.8565]}, {"w": "al.", "b": [0.8065, 0.8401, 0.8211, 0.8565]}, {"w": "(2016).", "b": [0.1587, 0.8553, 0.2038, 0.8716]}]}, {"id": "b_1", "type": "paragraph", "text": "17 “Xception: Deep Learning with Depthwise Separable Convolutions,” François Chollet (2016)", "words": [{"w": "17", "b": [0.1384, 0.8764, 0.1518, 0.8907]}, {"w": "“Xception:", "b": [0.1587, 0.8749, 0.2264, 0.8912]}, {"w": "Deep", "b": [0.23, 0.8749, 0.2635, 0.8912]}, {"w": "Learning", "b": [0.2671, 0.8749, 0.3243, 0.8912]}, {"w": "with", "b": [0.3279, 0.8749, 0.3563, 0.8912]}, {"w": "Depthwise", "b": [0.3599, 0.8749, 0.4273, 0.8912]}, {"w": "Separable", "b": [0.4309, 0.8749, 0.4921, 0.8912]}, {"w": "Convolutions,”", "b": [0.4957, 0.8749, 0.5901, 0.8912]}, {"w": "François", "b": [0.5937, 0.8749, 0.6485, 0.8912]}, {"w": "Chollet", "b": [0.6521, 0.8749, 0.6988, 0.8912]}, {"w": "(2016)", "b": [0.7024, 0.8749, 0.7439, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "connection represented by the dashed arrow in Figure 14-17). To solve this problem, the inputs are passed through a 1 × 1 convolutional layer with stride 2 and the right number of output feature maps (see Figure 14-18).", "words": [{"w": "connection", "b": [0.1428, 0.0791, 0.2367, 0.1005]}, {"w": "represented", "b": [0.2423, 0.0791, 0.3401, 0.1005]}, {"w": "by", "b": [0.3458, 0.0791, 0.3659, 0.1005]}, {"w": "the", "b": [0.3715, 0.0791, 0.3979, 0.1005]}, {"w": "dashed", "b": [0.4035, 0.0791, 0.4623, 0.1005]}, {"w": "arrow", "b": [0.4679, 0.0791, 0.5174, 0.1005]}, {"w": "in", "b": [0.523, 0.0791, 0.54, 0.1005]}, {"w": "Figure", "b": [0.5456, 0.0791, 0.5996, 0.1005]}, {"w": "14-17).", "b": [0.6053, 0.0791, 0.6646, 0.1005]}, {"w": "To", "b": [0.6703, 0.0791, 0.6917, 0.1005]}, {"w": "solve", "b": [0.6973, 0.0791, 0.7394, 0.1005]}, {"w": "this", "b": [0.745, 0.0791, 0.7757, 0.1005]}, {"w": "problem,", "b": [0.7813, 0.0791, 0.8571, 0.1005]}, {"w": "the", "b": [0.1429, 0.0981, 0.1692, 0.1195]}, {"w": "inputs", "b": [0.1753, 0.0981, 0.2278, 0.1195]}, {"w": "are", "b": [0.2339, 0.0981, 0.2597, 0.1195]}, {"w": "passed", "b": [0.2658, 0.0981, 0.321, 0.1195]}, {"w": "through", "b": [0.327, 0.0981, 0.3948, 0.1195]}, {"w": "a", "b": [0.4009, 0.0981, 0.4101, 0.1195]}, {"w": "1", "b": [0.4161, 0.0981, 0.4261, 0.1195]}, {"w": "×", "b": [0.4322, 0.0981, 0.4443, 0.1195]}, {"w": "1", "b": [0.4504, 0.0981, 0.4604, 0.1195]}, {"w": "convolutional", "b": [0.4665, 0.0981, 0.5818, 0.1195]}, {"w": "layer", "b": [0.5879, 0.0981, 0.6281, 0.1195]}, {"w": "with", "b": [0.6342, 0.0981, 0.6715, 0.1195]}, {"w": "stride", "b": [0.6776, 0.0981, 0.7248, 0.1195]}, {"w": "2", "b": [0.7309, 0.0981, 0.7409, 0.1195]}, {"w": "and", "b": [0.747, 0.0981, 0.7785, 0.1195]}, {"w": "the", "b": [0.7846, 0.0981, 0.8109, 0.1195]}, {"w": "right", "b": [0.817, 0.0981, 0.8571, 0.1195]}, {"w": "number", "b": [0.1429, 0.1172, 0.2091, 0.1386]}, {"w": "of", "b": [0.2139, 0.1172, 0.2307, 0.1386]}, {"w": "output", "b": [0.2354, 0.1172, 0.2918, 0.1386]}, {"w": "feature", "b": [0.2965, 0.1172, 0.3543, 0.1386]}, {"w": "maps", "b": [0.359, 0.1172, 0.4034, 0.1386]}, {"w": "(see", "b": [0.4081, 0.1172, 0.4407, 0.1386]}, {"w": "Figure", "b": [0.4454, 0.1172, 0.4994, 0.1386]}, {"w": "14-18).", "b": [0.5041, 0.1172, 0.5635, 0.1386]}]}, {"id": "b_3", "type": "equation", "text": "Figure 14-18. Skip connection when changing feature map size and depth", "words": [{"w": "Figure", "b": [0.1429, 0.3184, 0.1943, 0.34]}, {"w": "14-18.", "b": [0.1991, 0.3184, 0.2507, 0.34]}, {"w": "Skip", "b": [0.2554, 0.3184, 0.2901, 0.34]}, {"w": "connection", "b": [0.2949, 0.3184, 0.3827, 0.34]}, {"w": "when", "b": [0.3874, 0.3184, 0.4313, 0.34]}, {"w": "changing", "b": [0.436, 0.3184, 0.5088, 0.34]}, {"w": "feature", "b": [0.5135, 0.3184, 0.5695, 0.34]}, {"w": "map", "b": [0.5743, 0.3184, 0.6107, 0.34]}, {"w": "size", "b": [0.6154, 0.3184, 0.645, 0.34]}, {"w": "and", "b": [0.6498, 0.3184, 0.6812, 0.34]}, {"w": "depth", "b": [0.686, 0.3184, 0.7315, 0.34]}]}, {"id": "b_4", "type": "paragraph", "text": "ResNet-34 is the ResNet with 34 layers (only counting the convolutional layers and the fully connected layer) containing three residual units that output 64 feature maps, 4 RUs with 128 maps, 6 RUs with 256 maps, and 3 RUs with 512 maps. We will imple‐ ment this architecture later in this chapter.", "words": [{"w": "ResNet-34", "b": [0.1429, 0.3558, 0.2299, 0.3772]}, {"w": "is", "b": [0.2368, 0.3558, 0.25, 0.3772]}, {"w": "the", "b": [0.257, 0.3558, 0.2833, 0.3772]}, {"w": "ResNet", "b": [0.2903, 0.3558, 0.3499, 0.3772]}, {"w": "with", "b": [0.3568, 0.3558, 0.3941, 0.3772]}, {"w": "34", "b": [0.4011, 0.3558, 0.4211, 0.3772]}, {"w": "layers", "b": [0.428, 0.3558, 0.4758, 0.3772]}, {"w": "(only", "b": [0.4828, 0.3558, 0.5268, 0.3772]}, {"w": "counting", "b": [0.5338, 0.3558, 0.6084, 0.3772]}, {"w": "the", "b": [0.6153, 0.3558, 0.6416, 0.3772]}, {"w": "convolutional", "b": [0.6486, 0.3558, 0.7639, 0.3772]}, {"w": "layers", "b": [0.7708, 0.3558, 0.8187, 0.3772]}, {"w": "and", "b": [0.8256, 0.3558, 0.8571, 0.3772]}, {"w": "the", "b": [0.1429, 0.3748, 0.1692, 0.3962]}, {"w": "fully", "b": [0.1742, 0.3748, 0.2115, 0.3962]}, {"w": "connected", "b": [0.2166, 0.3748, 0.3027, 0.3962]}, {"w": "layer)", "b": [0.3077, 0.3748, 0.3551, 0.3962]}, {"w": "containing", "b": [0.3601, 0.3748, 0.4498, 0.3962]}, {"w": "three", "b": [0.4548, 0.3748, 0.4977, 0.3962]}, {"w": "residual", "b": [0.5028, 0.3748, 0.5691, 0.3962]}, {"w": "units", "b": [0.5741, 0.3748, 0.6161, 0.3962]}, {"w": "that", "b": [0.6212, 0.3748, 0.6537, 0.3962]}, {"w": "output", "b": [0.6588, 0.3748, 0.7151, 0.3962]}, {"w": "64", "b": [0.7202, 0.3748, 0.7402, 0.3962]}, {"w": "feature", "b": [0.7452, 0.3748, 0.803, 0.3962]}, {"w": "maps,", "b": [0.808, 0.3748, 0.8571, 0.3962]}, {"w": "4", "b": [0.1429, 0.3938, 0.1529, 0.4153]}, {"w": "RUs", "b": [0.1578, 0.3938, 0.1919, 0.4153]}, {"w": "with", "b": [0.1968, 0.3938, 0.2341, 0.4153]}, {"w": "128", "b": [0.2391, 0.3938, 0.2691, 0.4153]}, {"w": "maps,", "b": [0.274, 0.3938, 0.3232, 0.4153]}, {"w": "6", "b": [0.3281, 0.3938, 0.3381, 0.4153]}, {"w": "RUs", "b": [0.3431, 0.3938, 0.3771, 0.4153]}, {"w": "with", "b": [0.382, 0.3938, 0.4194, 0.4153]}, {"w": "256", "b": [0.4243, 0.3938, 0.4543, 0.4153]}, {"w": "maps,", "b": [0.4593, 0.3938, 0.5084, 0.4153]}, {"w": "and", "b": [0.5134, 0.3938, 0.5449, 0.4153]}, {"w": "3", "b": [0.5498, 0.3938, 0.5598, 0.4153]}, {"w": "RUs", "b": [0.5648, 0.3938, 0.5988, 0.4153]}, {"w": "with", "b": [0.6038, 0.3938, 0.6411, 0.4153]}, {"w": "512", "b": [0.6461, 0.3938, 0.6761, 0.4153]}, {"w": "maps.", "b": [0.681, 0.3938, 0.7301, 0.4153]}, {"w": "We", "b": [0.7351, 0.3938, 0.7621, 0.4153]}, {"w": "will", "b": [0.7671, 0.3938, 0.7975, 0.4153]}, {"w": "imple‐", "b": [0.8024, 0.3938, 0.8572, 0.4153]}, {"w": "ment", "b": [0.1429, 0.4129, 0.1861, 0.4343]}, {"w": "this", "b": [0.1909, 0.4129, 0.2216, 0.4343]}, {"w": "architecture", "b": [0.2263, 0.4129, 0.3267, 0.4343]}, {"w": "later", "b": [0.3314, 0.4129, 0.3684, 0.4343]}, {"w": "in", "b": [0.3731, 0.4129, 0.3901, 0.4343]}, {"w": "this", "b": [0.3948, 0.4129, 0.4255, 0.4343]}, {"w": "chapter.", "b": [0.4303, 0.4129, 0.4963, 0.4343]}]}, {"id": "b_5", "type": "paragraph", "text": "ResNets deeper than that, such as ResNet-152, use slightly different residual units. Instead of two 3 × 3 convolutional layers with (say) 256 feature maps, they use three convolutional layers: first a 1 × 1 convolutional layer with just 64 feature maps (4 times less), which acts as a bottleneck layer (as discussed already), then a 3 × 3 layer with 64 feature maps, and finally another 1 × 1 convolutional layer with 256 feature maps (4 times 64) that restores the original depth. ResNet-152 contains three such RUs that output 256 maps, then 8 RUs with 512 maps, a whopping 36 RUs with 1,024 maps, and finally 3 RUs with 2,048 maps.", "words": [{"w": "ResNets", "b": [0.1429, 0.441, 0.2101, 0.4624]}, {"w": "deeper", "b": [0.2179, 0.441, 0.2741, 0.4624]}, {"w": "than", "b": [0.2819, 0.441, 0.3199, 0.4624]}, {"w": "that,", "b": [0.3277, 0.441, 0.3651, 0.4624]}, {"w": "such", "b": [0.3729, 0.441, 0.4115, 0.4624]}, {"w": "as", "b": [0.4193, 0.441, 0.4361, 0.4624]}, {"w": "ResNet-152,", "b": [0.4439, 0.441, 0.5456, 0.4624]}, {"w": "use", "b": [0.5534, 0.441, 0.581, 0.4624]}, {"w": "slightly", "b": [0.5888, 0.441, 0.649, 0.4624]}, {"w": "different", "b": [0.6568, 0.441, 0.7285, 0.4624]}, {"w": "residual", "b": [0.7363, 0.441, 0.8026, 0.4624]}, {"w": "units.", "b": [0.8104, 0.441, 0.8571, 0.4624]}, {"w": "Instead", "b": [0.1429, 0.4601, 0.2044, 0.4815]}, {"w": "of", "b": [0.2103, 0.4601, 0.227, 0.4815]}, {"w": "two", "b": [0.2329, 0.4601, 0.2642, 0.4815]}, {"w": "3", "b": [0.2701, 0.4601, 0.2801, 0.4815]}, {"w": "×", "b": [0.286, 0.4601, 0.2981, 0.4815]}, {"w": "3", "b": [0.304, 0.4601, 0.314, 0.4815]}, {"w": "convolutional", "b": [0.3199, 0.4601, 0.4352, 0.4815]}, {"w": "layers", "b": [0.4411, 0.4601, 0.4889, 0.4815]}, {"w": "with", "b": [0.4948, 0.4601, 0.5322, 0.4815]}, {"w": "(say)", "b": [0.5381, 0.4601, 0.5785, 0.4815]}, {"w": "256", "b": [0.5844, 0.4601, 0.6144, 0.4815]}, {"w": "feature", "b": [0.6203, 0.4601, 0.678, 0.4815]}, {"w": "maps,", "b": [0.6839, 0.4601, 0.7331, 0.4815]}, {"w": "they", "b": [0.739, 0.4601, 0.7749, 0.4815]}, {"w": "use", "b": [0.7808, 0.4601, 0.8083, 0.4815]}, {"w": "three", "b": [0.8142, 0.4601, 0.8571, 0.4815]}, {"w": "convolutional", "b": [0.1428, 0.4791, 0.2582, 0.5005]}, {"w": "layers:", "b": [0.266, 0.4791, 0.3186, 0.5005]}, {"w": "first", "b": [0.3263, 0.4791, 0.3598, 0.5005]}, {"w": "a", "b": [0.3676, 0.4791, 0.3768, 0.5005]}, {"w": "1", "b": [0.3845, 0.4791, 0.3945, 0.5005]}, {"w": "×", "b": [0.4023, 0.4791, 0.4144, 0.5005]}, {"w": "1", "b": [0.4222, 0.4791, 0.4322, 0.5005]}, {"w": "convolutional", "b": [0.44, 0.4791, 0.5553, 0.5005]}, {"w": "layer", "b": [0.5631, 0.4791, 0.6033, 0.5005]}, {"w": "with", "b": [0.6111, 0.4791, 0.6484, 0.5005]}, {"w": "just", "b": [0.6562, 0.4791, 0.6866, 0.5005]}, {"w": "64", "b": [0.6944, 0.4791, 0.7144, 0.5005]}, {"w": "feature", "b": [0.7222, 0.4791, 0.78, 0.5005]}, {"w": "maps", "b": [0.7878, 0.4791, 0.8321, 0.5005]}, {"w": "(4", "b": [0.8399, 0.4791, 0.8571, 0.5005]}, {"w": "times", "b": [0.1429, 0.4982, 0.1884, 0.5196]}, {"w": "less),", "b": [0.1944, 0.4982, 0.2357, 0.5196]}, {"w": "which", "b": [0.2417, 0.4982, 0.2926, 0.5196]}, {"w": "acts", "b": [0.2986, 0.4982, 0.3306, 0.5196]}, {"w": "as", "b": [0.3366, 0.4982, 0.3534, 0.5196]}, {"w": "a", "b": [0.3594, 0.4982, 0.3685, 0.5196]}, {"w": "bottleneck", "b": [0.3745, 0.4982, 0.462, 0.5196]}, {"w": "layer", "b": [0.4679, 0.4982, 0.5081, 0.5196]}, {"w": "(as", "b": [0.5141, 0.4982, 0.5381, 0.5196]}, {"w": "discussed", "b": [0.5441, 0.4982, 0.6234, 0.5196]}, {"w": "already),", "b": [0.6294, 0.4982, 0.702, 0.5196]}, {"w": "then", "b": [0.708, 0.4982, 0.7458, 0.5196]}, {"w": "a", "b": [0.7518, 0.4982, 0.7609, 0.5196]}, {"w": "3", "b": [0.7669, 0.4982, 0.7769, 0.5196]}, {"w": "×", "b": [0.7829, 0.4982, 0.795, 0.5196]}, {"w": "3", "b": [0.801, 0.4982, 0.811, 0.5196]}, {"w": "layer", "b": [0.817, 0.4982, 0.8571, 0.5196]}, {"w": "with", "b": [0.1429, 0.5172, 0.1802, 0.5386]}, {"w": "64", "b": [0.1865, 0.5172, 0.2065, 0.5386]}, {"w": "feature", "b": [0.2128, 0.5172, 0.2706, 0.5386]}, {"w": "maps,", "b": [0.2769, 0.5172, 0.326, 0.5386]}, {"w": "and", "b": [0.3323, 0.5172, 0.3638, 0.5386]}, {"w": "finally", "b": [0.3701, 0.5172, 0.4225, 0.5386]}, {"w": "another", "b": [0.4288, 0.5172, 0.494, 0.5386]}, {"w": "1", "b": [0.5003, 0.5172, 0.5103, 0.5386]}, {"w": "×", "b": [0.5166, 0.5172, 0.5287, 0.5386]}, {"w": "1", "b": [0.535, 0.5172, 0.545, 0.5386]}, {"w": "convolutional", "b": [0.5513, 0.5172, 0.6667, 0.5386]}, {"w": "layer", "b": [0.673, 0.5172, 0.7131, 0.5386]}, {"w": "with", "b": [0.7194, 0.5172, 0.7568, 0.5386]}, {"w": "256", "b": [0.7631, 0.5172, 0.7931, 0.5386]}, {"w": "feature", "b": [0.7994, 0.5172, 0.8571, 0.5386]}, {"w": "maps", "b": [0.1429, 0.5363, 0.1872, 0.5577]}, {"w": "(4", "b": [0.1946, 0.5363, 0.2118, 0.5577]}, {"w": "times", "b": [0.2192, 0.5363, 0.2647, 0.5577]}, {"w": "64)", "b": [0.272, 0.5363, 0.2992, 0.5577]}, {"w": "that", "b": [0.3066, 0.5363, 0.3392, 0.5577]}, {"w": "restores", "b": [0.3466, 0.5363, 0.412, 0.5577]}, {"w": "the", "b": [0.4194, 0.5363, 0.4457, 0.5577]}, {"w": "original", "b": [0.4531, 0.5363, 0.5182, 0.5577]}, {"w": "depth.", "b": [0.5255, 0.5363, 0.5785, 0.5577]}, {"w": "ResNet-152", "b": [0.5859, 0.5363, 0.6829, 0.5577]}, {"w": "contains", "b": [0.6903, 0.5363, 0.7608, 0.5577]}, {"w": "three", "b": [0.7682, 0.5363, 0.8111, 0.5577]}, {"w": "such", "b": [0.8185, 0.5363, 0.8571, 0.5577]}, {"w": "RUs", "b": [0.1429, 0.5553, 0.1769, 0.5767]}, {"w": "that", "b": [0.1822, 0.5553, 0.2147, 0.5767]}, {"w": "output", "b": [0.22, 0.5553, 0.2764, 0.5767]}, {"w": "256", "b": [0.2816, 0.5553, 0.3116, 0.5767]}, {"w": "maps,", "b": [0.3169, 0.5553, 0.366, 0.5767]}, {"w": "then", "b": [0.3713, 0.5553, 0.409, 0.5767]}, {"w": "8", "b": [0.4142, 0.5553, 0.4242, 0.5767]}, {"w": "RUs", "b": [0.4295, 0.5553, 0.4635, 0.5767]}, {"w": "with", "b": [0.4688, 0.5553, 0.5061, 0.5767]}, {"w": "512", "b": [0.5114, 0.5553, 0.5414, 0.5767]}, {"w": "maps,", "b": [0.5466, 0.5553, 0.5958, 0.5767]}, {"w": "a", "b": [0.601, 0.5553, 0.6102, 0.5767]}, {"w": "whopping", "b": [0.6154, 0.5553, 0.7, 0.5767]}, {"w": "36", "b": [0.7053, 0.5553, 0.7253, 0.5767]}, {"w": "RUs", "b": [0.7305, 0.5553, 0.7646, 0.5767]}, {"w": "with", "b": [0.7698, 0.5553, 0.8071, 0.5767]}, {"w": "1,024", "b": [0.8124, 0.5553, 0.8572, 0.5767]}, {"w": "maps,", "b": [0.1429, 0.5743, 0.192, 0.5958]}, {"w": "and", "b": [0.1967, 0.5743, 0.2283, 0.5958]}, {"w": "finally", "b": [0.233, 0.5743, 0.2854, 0.5958]}, {"w": "3", "b": [0.2901, 0.5743, 0.3001, 0.5958]}, {"w": "RUs", "b": [0.3048, 0.5743, 0.3389, 0.5958]}, {"w": "with", "b": [0.3436, 0.5743, 0.3809, 0.5958]}, {"w": "2,048", "b": [0.3857, 0.5743, 0.4304, 0.5958]}, {"w": "maps.", "b": [0.4352, 0.5743, 0.4843, 0.5958]}]}, {"id": "b_6", "type": "paragraph", "text": "Google’s Inception-v416 architecture merged the ideas of GoogLe‐ Net and ResNet and achieved close to 3% top-5 error rate on ImageNet classification.", "words": [{"w": "Google’s", "b": [0.2714, 0.6163, 0.3346, 0.6359]}, {"w": "Inception-v416", "b": [0.3412, 0.6163, 0.4515, 0.6359]}, {"w": "architecture", "b": [0.458, 0.6163, 0.5499, 0.6359]}, {"w": "merged", "b": [0.5564, 0.6163, 0.6143, 0.6359]}, {"w": "the", "b": [0.6208, 0.6163, 0.6449, 0.6359]}, {"w": "ideas", "b": [0.6515, 0.6163, 0.6901, 0.6359]}, {"w": "of", "b": [0.6967, 0.6163, 0.712, 0.6359]}, {"w": "GoogLe‐", "b": [0.7186, 0.6163, 0.7857, 0.6359]}, {"w": "Net", "b": [0.2714, 0.6337, 0.299, 0.6533]}, {"w": "and", "b": [0.3082, 0.6337, 0.3371, 0.6533]}, {"w": "ResNet", "b": [0.3463, 0.6337, 0.4008, 0.6533]}, {"w": "and", "b": [0.41, 0.6337, 0.4388, 0.6533]}, {"w": "achieved", "b": [0.4481, 0.6337, 0.5148, 0.6533]}, {"w": "close", "b": [0.5241, 0.6337, 0.5617, 0.6533]}, {"w": "to", "b": [0.571, 0.6337, 0.5865, 0.6533]}, {"w": "3%", "b": [0.5957, 0.6337, 0.6193, 0.6533]}, {"w": "top-5", "b": [0.6285, 0.6337, 0.6699, 0.6533]}, {"w": "error", "b": [0.6791, 0.6337, 0.7182, 0.6533]}, {"w": "rate", "b": [0.7274, 0.6337, 0.7564, 0.6533]}, {"w": "on", "b": [0.7656, 0.6337, 0.7857, 0.6533]}, {"w": "ImageNet", "b": [0.2714, 0.6511, 0.3465, 0.6707]}, {"w": "classification.", "b": [0.3508, 0.6511, 0.4533, 0.6707]}]}, {"id": "b_7", "type": "paragraph", "text": "Xception", "words": [{"w": "Xception", "b": [0.1428, 0.7122, 0.2326, 0.7408]}]}, {"id": "b_8", "type": "paragraph", "text": "Another variant of the GoogLeNet architecture is also worth noting: Xception17", "words": [{"w": "Another", "b": [0.1429, 0.7467, 0.2133, 0.7681]}, {"w": "variant", "b": [0.2235, 0.7467, 0.2822, 0.7681]}, {"w": "of", "b": [0.2924, 0.7467, 0.3092, 0.7681]}, {"w": "the", "b": [0.3194, 0.7467, 0.3457, 0.7681]}, {"w": "GoogLeNet", "b": [0.3559, 0.7467, 0.452, 0.7681]}, {"w": "architecture", "b": [0.4622, 0.7467, 0.5626, 0.7681]}, {"w": "is", "b": [0.5729, 0.7467, 0.5861, 0.7681]}, {"w": "also", "b": [0.5963, 0.7467, 0.629, 0.7681]}, {"w": "worth", "b": [0.6392, 0.7467, 0.6893, 0.7681]}, {"w": "noting:", "b": [0.6995, 0.7467, 0.7593, 0.7681]}, {"w": "Xception17", "b": [0.7696, 0.7467, 0.8571, 0.7681]}]}, {"id": "b_9", "type": "paragraph", "text": "(which stands for Extreme Inception) was proposed in 2016 by François Chollet (the", "words": [{"w": "(which", "b": [0.1429, 0.7657, 0.201, 0.7871]}, {"w": "stands", "b": [0.2072, 0.7657, 0.2604, 0.7871]}, {"w": "for", "b": [0.2665, 0.7657, 0.2911, 0.7871]}, {"w": "Extreme", "b": [0.2972, 0.7655, 0.3654, 0.7871]}, {"w": "Inception)", "b": [0.3716, 0.7655, 0.4544, 0.7871]}, {"w": "was", "b": [0.4606, 0.7657, 0.4916, 0.7871]}, {"w": "proposed", "b": [0.4978, 0.7657, 0.5761, 0.7871]}, {"w": "in", "b": [0.5823, 0.7657, 0.5993, 0.7871]}, {"w": "2016", "b": [0.6055, 0.7657, 0.6455, 0.7871]}, {"w": "by", "b": [0.6516, 0.7657, 0.6718, 0.7871]}, {"w": "François", "b": [0.678, 0.7657, 0.7499, 0.7871]}, {"w": "Chollet", "b": [0.7561, 0.7657, 0.8174, 0.7871]}, {"w": "(the", "b": [0.8236, 0.7657, 0.8571, 0.7871]}]}, {"id": "b_10", "type": "paragraph", "text": "CNN Architectures | 459", "words": [{"w": "CNN", "b": [0.6908, 0.9225, 0.7152, 0.9388]}, {"w": "Architectures", "b": [0.7181, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "459", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 486, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "18 This name can sometimes be ambiguous, since spatially separable convolutions are often called “separable convolutions” as well.", "words": [{"w": "18", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "This", "b": [0.1587, 0.8598, 0.1871, 0.8761]}, {"w": "name", "b": [0.1907, 0.8598, 0.2261, 0.8761]}, {"w": "can", "b": [0.2297, 0.8598, 0.252, 0.8761]}, {"w": "sometimes", "b": [0.2557, 0.8598, 0.324, 0.8761]}, {"w": "be", "b": [0.3276, 0.8598, 0.3424, 0.8761]}, {"w": "ambiguous,", "b": [0.346, 0.8598, 0.4201, 0.8761]}, {"w": "since", "b": [0.4237, 0.8598, 0.4559, 0.8761]}, {"w": "spatially", "b": [0.4595, 0.8598, 0.5117, 0.8761]}, {"w": "separable", "b": [0.5153, 0.8598, 0.5749, 0.8761]}, {"w": "convolutions", "b": [0.5785, 0.8598, 0.6612, 0.8761]}, {"w": "are", "b": [0.6648, 0.8598, 0.6844, 0.8761]}, {"w": "often", "b": [0.688, 0.8598, 0.7211, 0.8761]}, {"w": "called", "b": [0.7247, 0.8598, 0.7615, 0.8761]}, {"w": "“separable", "b": [0.7651, 0.8598, 0.83, 0.8761]}, {"w": "convolutions”", "b": [0.1587, 0.8749, 0.2472, 0.8912]}, {"w": "as", "b": [0.2508, 0.8749, 0.2636, 0.8912]}, {"w": "well.", "b": [0.2672, 0.8749, 0.2964, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "author of Keras), and it significantly outperformed Inception-v3 on a huge vision task (350 million images and 17,000 classes). Just like Inception-v4, it also merges the ideas of GoogLeNet and ResNet, but it replaces the inception modules with a special type of layer called a depthwise separable convolution (or separable convolution for short18). These layers had been used before in some CNN architectures, but they were not as central as in the Xception architecture. While a regular convolutional layer uses filters that try to simultaneously capture spatial patterns (e.g., an oval) and cross- channel patterns (e.g., mouth + nose + eyes = face), a separable convolutional layer makes the strong assumption that spatial patterns and cross-channel patterns can be modeled separately (see Figure 14-19). Thus, it is composed of two parts: the first part applies a single spatial filter for each input feature map, then the second part looks exclusively for cross-channel patterns—it is just a regular convolutional layer with 1 × 1 filters.", "words": [{"w": "author", "b": [0.1429, 0.0791, 0.1985, 0.1005]}, {"w": "of", "b": [0.2032, 0.0791, 0.22, 0.1005]}, {"w": "Keras),", "b": [0.2248, 0.0791, 0.2836, 0.1005]}, {"w": "and", "b": [0.2883, 0.0791, 0.3199, 0.1005]}, {"w": "it", "b": [0.3246, 0.0791, 0.3366, 0.1005]}, {"w": "significantly", "b": [0.3413, 0.0791, 0.4431, 0.1005]}, {"w": "outperformed", "b": [0.4479, 0.0791, 0.5648, 0.1005]}, {"w": "Inception-v3", "b": [0.5696, 0.0791, 0.6777, 0.1005]}, {"w": "on", "b": [0.6824, 0.0791, 0.7044, 0.1005]}, {"w": "a", "b": [0.7092, 0.0791, 0.7183, 0.1005]}, {"w": "huge", "b": [0.723, 0.0791, 0.7634, 0.1005]}, {"w": "vision", "b": [0.7682, 0.0791, 0.8186, 0.1005]}, {"w": "task", "b": [0.8234, 0.0791, 0.8568, 0.1005]}, {"w": "(350", "b": [0.1429, 0.0981, 0.1801, 0.1195]}, {"w": "million", "b": [0.1884, 0.0981, 0.2492, 0.1195]}, {"w": "images", "b": [0.2575, 0.0981, 0.3156, 0.1195]}, {"w": "and", "b": [0.3239, 0.0981, 0.3554, 0.1195]}, {"w": "17,000", "b": [0.3638, 0.0981, 0.4185, 0.1195]}, {"w": "classes).", "b": [0.4269, 0.0981, 0.4938, 0.1195]}, {"w": "Just", "b": [0.5022, 0.0981, 0.5334, 0.1195]}, {"w": "like", "b": [0.5417, 0.0981, 0.5718, 0.1195]}, {"w": "Inception-v4,", "b": [0.5801, 0.0981, 0.693, 0.1195]}, {"w": "it", "b": [0.7013, 0.0981, 0.7132, 0.1195]}, {"w": "also", "b": [0.7216, 0.0981, 0.7543, 0.1195]}, {"w": "merges", "b": [0.7626, 0.0981, 0.8225, 0.1195]}, {"w": "the", "b": [0.8308, 0.0981, 0.8572, 0.1195]}, {"w": "ideas", "b": [0.1429, 0.1172, 0.1851, 0.1386]}, {"w": "of", "b": [0.1909, 0.1172, 0.2077, 0.1386]}, {"w": "GoogLeNet", "b": [0.2136, 0.1172, 0.3097, 0.1386]}, {"w": "and", "b": [0.3155, 0.1172, 0.3471, 0.1386]}, {"w": "ResNet,", "b": [0.3529, 0.1172, 0.4173, 0.1386]}, {"w": "but", "b": [0.4231, 0.1172, 0.4511, 0.1386]}, {"w": "it", "b": [0.457, 0.1172, 0.4689, 0.1386]}, {"w": "replaces", "b": [0.4748, 0.1172, 0.542, 0.1386]}, {"w": "the", "b": [0.5478, 0.1172, 0.5742, 0.1386]}, {"w": "inception", "b": [0.58, 0.1172, 0.6595, 0.1386]}, {"w": "modules", "b": [0.6654, 0.1172, 0.7369, 0.1386]}, {"w": "with", "b": [0.7427, 0.1172, 0.7801, 0.1386]}, {"w": "a", "b": [0.7859, 0.1172, 0.7951, 0.1386]}, {"w": "special", "b": [0.8009, 0.1172, 0.8571, 0.1386]}, {"w": "type", "b": [0.1429, 0.1362, 0.1785, 0.1576]}, {"w": "of", "b": [0.1869, 0.1362, 0.2037, 0.1576]}, {"w": "layer", "b": [0.2121, 0.1362, 0.2523, 0.1576]}, {"w": "called", "b": [0.2607, 0.1362, 0.3091, 0.1576]}, {"w": "a", "b": [0.3175, 0.1362, 0.3266, 0.1576]}, {"w": "depthwise", "b": [0.335, 0.136, 0.4154, 0.1576]}, {"w": "separable", "b": [0.4238, 0.136, 0.4994, 0.1576]}, {"w": "convolution", "b": [0.5079, 0.136, 0.6028, 0.1576]}, {"w": "(or", "b": [0.6113, 0.1362, 0.6368, 0.1576]}, {"w": "separable", "b": [0.6452, 0.136, 0.7208, 0.1576]}, {"w": "convolution", "b": [0.7292, 0.136, 0.8242, 0.1576]}, {"w": "for", "b": [0.8326, 0.1362, 0.8571, 0.1576]}, {"w": "short18).", "b": [0.1428, 0.1553, 0.2097, 0.1767]}, {"w": "These", "b": [0.2148, 0.1553, 0.2641, 0.1767]}, {"w": "layers", "b": [0.2691, 0.1553, 0.317, 0.1767]}, {"w": "had", "b": [0.322, 0.1553, 0.3533, 0.1767]}, {"w": "been", "b": [0.3583, 0.1553, 0.398, 0.1767]}, {"w": "used", "b": [0.4031, 0.1553, 0.4416, 0.1767]}, {"w": "before", "b": [0.4467, 0.1553, 0.4995, 0.1767]}, {"w": "in", "b": [0.5045, 0.1553, 0.5215, 0.1767]}, {"w": "some", "b": [0.5265, 0.1553, 0.5707, 0.1767]}, {"w": "CNN", "b": [0.5758, 0.1553, 0.6206, 0.1767]}, {"w": "architectures,", "b": [0.6256, 0.1553, 0.7384, 0.1767]}, {"w": "but", "b": [0.7435, 0.1553, 0.7715, 0.1767]}, {"w": "they", "b": [0.7765, 0.1553, 0.8124, 0.1767]}, {"w": "were", "b": [0.8174, 0.1553, 0.8571, 0.1767]}, {"w": "not", "b": [0.1429, 0.1743, 0.1712, 0.1957]}, {"w": "as", "b": [0.1792, 0.1743, 0.196, 0.1957]}, {"w": "central", "b": [0.2039, 0.1743, 0.2611, 0.1957]}, {"w": "as", "b": [0.269, 0.1743, 0.2858, 0.1957]}, {"w": "in", "b": [0.2937, 0.1743, 0.3107, 0.1957]}, {"w": "the", "b": [0.3186, 0.1743, 0.345, 0.1957]}, {"w": "Xception", "b": [0.3529, 0.1743, 0.4291, 0.1957]}, {"w": "architecture.", "b": [0.437, 0.1743, 0.5422, 0.1957]}, {"w": "While", "b": [0.5501, 0.1743, 0.6012, 0.1957]}, {"w": "a", "b": [0.6091, 0.1743, 0.6183, 0.1957]}, {"w": "regular", "b": [0.6262, 0.1743, 0.6857, 0.1957]}, {"w": "convolutional", "b": [0.6937, 0.1743, 0.809, 0.1957]}, {"w": "layer", "b": [0.817, 0.1743, 0.8571, 0.1957]}, {"w": "uses", "b": [0.1428, 0.1933, 0.1781, 0.2148]}, {"w": "filters", "b": [0.1829, 0.1933, 0.2305, 0.2148]}, {"w": "that", "b": [0.2354, 0.1933, 0.268, 0.2148]}, {"w": "try", "b": [0.2729, 0.1933, 0.2971, 0.2148]}, {"w": "to", "b": [0.302, 0.1933, 0.319, 0.2148]}, {"w": "simultaneously", "b": [0.3239, 0.1933, 0.45, 0.2148]}, {"w": "capture", "b": [0.4549, 0.1933, 0.5174, 0.2148]}, {"w": "spatial", "b": [0.5223, 0.1933, 0.5759, 0.2148]}, {"w": "patterns", "b": [0.5808, 0.1933, 0.6488, 0.2148]}, {"w": "(e.g.,", "b": [0.6537, 0.1933, 0.6938, 0.2148]}, {"w": "an", "b": [0.6986, 0.1933, 0.7192, 0.2148]}, {"w": "oval)", "b": [0.7241, 0.1933, 0.766, 0.2148]}, {"w": "and", "b": [0.7708, 0.1933, 0.8024, 0.2148]}, {"w": "cross-", "b": [0.8073, 0.1933, 0.8571, 0.2148]}, {"w": "channel", "b": [0.1429, 0.2124, 0.2089, 0.2338]}, {"w": "patterns", "b": [0.2155, 0.2124, 0.2835, 0.2338]}, {"w": "(e.g.,", "b": [0.2902, 0.2124, 0.3302, 0.2338]}, {"w": "mouth", "b": [0.3369, 0.2124, 0.3931, 0.2338]}, {"w": "+", "b": [0.3998, 0.2124, 0.4119, 0.2338]}, {"w": "nose", "b": [0.4185, 0.2124, 0.457, 0.2338]}, {"w": "+", "b": [0.4637, 0.2124, 0.4758, 0.2338]}, {"w": "eyes", "b": [0.4824, 0.2124, 0.5174, 0.2338]}, {"w": "=", "b": [0.524, 0.2124, 0.5361, 0.2338]}, {"w": "face),", "b": [0.5428, 0.2124, 0.5877, 0.2338]}, {"w": "a", "b": [0.5944, 0.2124, 0.6035, 0.2338]}, {"w": "separable", "b": [0.6102, 0.2124, 0.6883, 0.2338]}, {"w": "convolutional", "b": [0.695, 0.2124, 0.8103, 0.2338]}, {"w": "layer", "b": [0.817, 0.2124, 0.8571, 0.2338]}, {"w": "makes", "b": [0.1429, 0.2314, 0.1959, 0.2529]}, {"w": "the", "b": [0.2019, 0.2314, 0.2282, 0.2529]}, {"w": "strong", "b": [0.2342, 0.2314, 0.2877, 0.2529]}, {"w": "assumption", "b": [0.2937, 0.2314, 0.3907, 0.2529]}, {"w": "that", "b": [0.3967, 0.2314, 0.4293, 0.2529]}, {"w": "spatial", "b": [0.4353, 0.2314, 0.489, 0.2529]}, {"w": "patterns", "b": [0.495, 0.2314, 0.563, 0.2529]}, {"w": "and", "b": [0.569, 0.2314, 0.6005, 0.2529]}, {"w": "cross-channel", "b": [0.6065, 0.2314, 0.7224, 0.2529]}, {"w": "patterns", "b": [0.7284, 0.2314, 0.7964, 0.2529]}, {"w": "can", "b": [0.8024, 0.2314, 0.8317, 0.2529]}, {"w": "be", "b": [0.8377, 0.2314, 0.8571, 0.2529]}, {"w": "modeled", "b": [0.1429, 0.2505, 0.2155, 0.2719]}, {"w": "separately", "b": [0.2202, 0.2505, 0.3033, 0.2719]}, {"w": "(see", "b": [0.3081, 0.2505, 0.3406, 0.2719]}, {"w": "Figure", "b": [0.3455, 0.2505, 0.3995, 0.2719]}, {"w": "14-19).", "b": [0.4042, 0.2505, 0.4636, 0.2719]}, {"w": "Thus,", "b": [0.4683, 0.2505, 0.5154, 0.2719]}, {"w": "it", "b": [0.5201, 0.2505, 0.532, 0.2719]}, {"w": "is", "b": [0.5368, 0.2505, 0.55, 0.2719]}, {"w": "composed", "b": [0.5547, 0.2505, 0.6399, 0.2719]}, {"w": "of", "b": [0.6446, 0.2505, 0.6614, 0.2719]}, {"w": "two", "b": [0.6661, 0.2505, 0.6974, 0.2719]}, {"w": "parts:", "b": [0.7021, 0.2505, 0.7486, 0.2719]}, {"w": "the", "b": [0.7534, 0.2505, 0.7797, 0.2719]}, {"w": "first", "b": [0.7844, 0.2505, 0.8179, 0.2719]}, {"w": "part", "b": [0.8226, 0.2505, 0.8568, 0.2719]}, {"w": "applies", "b": [0.1429, 0.2695, 0.2008, 0.291]}, {"w": "a", "b": [0.2078, 0.2695, 0.2169, 0.291]}, {"w": "single", "b": [0.2239, 0.2695, 0.2724, 0.291]}, {"w": "spatial", "b": [0.2794, 0.2695, 0.3331, 0.291]}, {"w": "filter", "b": [0.3401, 0.2695, 0.3801, 0.291]}, {"w": "for", "b": [0.3871, 0.2695, 0.4116, 0.291]}, {"w": "each", "b": [0.4186, 0.2695, 0.4565, 0.291]}, {"w": "input", "b": [0.4635, 0.2695, 0.5084, 0.291]}, {"w": "feature", "b": [0.5154, 0.2695, 0.5732, 0.291]}, {"w": "map,", "b": [0.5802, 0.2695, 0.6211, 0.291]}, {"w": "then", "b": [0.6281, 0.2695, 0.6658, 0.291]}, {"w": "the", "b": [0.6728, 0.2695, 0.6992, 0.291]}, {"w": "second", "b": [0.7062, 0.2695, 0.7645, 0.291]}, {"w": "part", "b": [0.7715, 0.2695, 0.8056, 0.291]}, {"w": "looks", "b": [0.8126, 0.2695, 0.8571, 0.291]}, {"w": "exclusively", "b": [0.1429, 0.2886, 0.2333, 0.31]}, {"w": "for", "b": [0.238, 0.2886, 0.2625, 0.31]}, {"w": "cross-channel", "b": [0.2672, 0.2886, 0.3831, 0.31]}, {"w": "patterns—it", "b": [0.3878, 0.2886, 0.487, 0.31]}, {"w": "is", "b": [0.4917, 0.2886, 0.505, 0.31]}, {"w": "just", "b": [0.5097, 0.2886, 0.5401, 0.31]}, {"w": "a", "b": [0.5448, 0.2886, 0.554, 0.31]}, {"w": "regular", "b": [0.5587, 0.2886, 0.6182, 0.31]}, {"w": "convolutional", "b": [0.623, 0.2886, 0.7383, 0.31]}, {"w": "layer", "b": [0.743, 0.2886, 0.7832, 0.31]}, {"w": "with", "b": [0.7879, 0.2886, 0.8253, 0.31]}, {"w": "1", "b": [0.83, 0.2886, 0.84, 0.31]}, {"w": "×", "b": [0.8447, 0.2886, 0.8568, 0.31]}, {"w": "1", "b": [0.1429, 0.3076, 0.1529, 0.329]}, {"w": "filters.", "b": [0.1576, 0.3076, 0.21, 0.329]}]}, {"id": "b_2", "type": "equation", "text": "Figure 14-19. Depthwise Separable Convolutional Layer", "words": [{"w": "Figure", "b": [0.1429, 0.6846, 0.1943, 0.7062]}, {"w": "14-19.", "b": [0.1991, 0.6846, 0.2507, 0.7062]}, {"w": "Depthwise", "b": [0.2554, 0.6846, 0.3402, 0.7062]}, {"w": "Separable", "b": [0.345, 0.6846, 0.4234, 0.7062]}, {"w": "Convolutional", "b": [0.4281, 0.6846, 0.5436, 0.7062]}, {"w": "Layer", "b": [0.5484, 0.6846, 0.5943, 0.7062]}]}, {"id": "b_3", "type": "paragraph", "text": "Since separable convolutional layers only have one spatial filter per input channel, you should avoid using them after layers that have too few channels, such as the input layer (granted, that’s what Figure 14-19 represents, but it is just for illustration pur‐ poses). For this reason, the Xception architecture starts with 2 regular convolutional layers, but then the rest of the architecture uses only separable convolutions (34 in", "words": [{"w": "Since", "b": [0.1429, 0.722, 0.1874, 0.7434]}, {"w": "separable", "b": [0.1952, 0.722, 0.2733, 0.7434]}, {"w": "convolutional", "b": [0.2811, 0.722, 0.3964, 0.7434]}, {"w": "layers", "b": [0.4042, 0.722, 0.452, 0.7434]}, {"w": "only", "b": [0.4598, 0.722, 0.4967, 0.7434]}, {"w": "have", "b": [0.5044, 0.722, 0.5428, 0.7434]}, {"w": "one", "b": [0.5506, 0.722, 0.5815, 0.7434]}, {"w": "spatial", "b": [0.5893, 0.722, 0.6429, 0.7434]}, {"w": "filter", "b": [0.6507, 0.722, 0.6907, 0.7434]}, {"w": "per", "b": [0.6984, 0.722, 0.7259, 0.7434]}, {"w": "input", "b": [0.7337, 0.722, 0.7786, 0.7434]}, {"w": "channel,", "b": [0.7864, 0.722, 0.8572, 0.7434]}, {"w": "you", "b": [0.1429, 0.741, 0.1741, 0.7624]}, {"w": "should", "b": [0.179, 0.741, 0.2357, 0.7624]}, {"w": "avoid", "b": [0.2405, 0.741, 0.2862, 0.7624]}, {"w": "using", "b": [0.291, 0.741, 0.3365, 0.7624]}, {"w": "them", "b": [0.3413, 0.741, 0.3847, 0.7624]}, {"w": "after", "b": [0.3896, 0.741, 0.4278, 0.7624]}, {"w": "layers", "b": [0.4327, 0.741, 0.4805, 0.7624]}, {"w": "that", "b": [0.4854, 0.741, 0.5179, 0.7624]}, {"w": "have", "b": [0.5228, 0.741, 0.5612, 0.7624]}, {"w": "too", "b": [0.566, 0.741, 0.5936, 0.7624]}, {"w": "few", "b": [0.5985, 0.741, 0.6278, 0.7624]}, {"w": "channels,", "b": [0.6326, 0.741, 0.711, 0.7624]}, {"w": "such", "b": [0.7159, 0.741, 0.7545, 0.7624]}, {"w": "as", "b": [0.7594, 0.741, 0.7762, 0.7624]}, {"w": "the", "b": [0.781, 0.741, 0.8074, 0.7624]}, {"w": "input", "b": [0.8122, 0.741, 0.8571, 0.7624]}, {"w": "layer", "b": [0.1429, 0.7601, 0.183, 0.7815]}, {"w": "(granted,", "b": [0.1897, 0.7601, 0.2655, 0.7815]}, {"w": "that’s", "b": [0.2722, 0.7601, 0.3145, 0.7815]}, {"w": "what", "b": [0.3212, 0.7601, 0.3617, 0.7815]}, {"w": "Figure", "b": [0.3684, 0.7601, 0.4224, 0.7815]}, {"w": "14-19", "b": [0.4291, 0.7601, 0.4765, 0.7815]}, {"w": "represents,", "b": [0.4832, 0.7601, 0.5735, 0.7815]}, {"w": "but", "b": [0.5802, 0.7601, 0.6082, 0.7815]}, {"w": "it", "b": [0.6149, 0.7601, 0.6268, 0.7815]}, {"w": "is", "b": [0.6335, 0.7601, 0.6467, 0.7815]}, {"w": "just", "b": [0.6534, 0.7601, 0.6838, 0.7815]}, {"w": "for", "b": [0.6905, 0.7601, 0.715, 0.7815]}, {"w": "illustration", "b": [0.7217, 0.7601, 0.8133, 0.7815]}, {"w": "pur‐", "b": [0.82, 0.7601, 0.8571, 0.7815]}, {"w": "poses).", "b": [0.1428, 0.7791, 0.2005, 0.8005]}, {"w": "For", "b": [0.2066, 0.7791, 0.2355, 0.8005]}, {"w": "this", "b": [0.2416, 0.7791, 0.2723, 0.8005]}, {"w": "reason,", "b": [0.2784, 0.7791, 0.3385, 0.8005]}, {"w": "the", "b": [0.3446, 0.7791, 0.371, 0.8005]}, {"w": "Xception", "b": [0.377, 0.7791, 0.4532, 0.8005]}, {"w": "architecture", "b": [0.4593, 0.7791, 0.5597, 0.8005]}, {"w": "starts", "b": [0.5658, 0.7791, 0.6106, 0.8005]}, {"w": "with", "b": [0.6167, 0.7791, 0.654, 0.8005]}, {"w": "2", "b": [0.6601, 0.7791, 0.6701, 0.8005]}, {"w": "regular", "b": [0.6762, 0.7791, 0.7357, 0.8005]}, {"w": "convolutional", "b": [0.7418, 0.7791, 0.8571, 0.8005]}, {"w": "layers,", "b": [0.1429, 0.7982, 0.1954, 0.8196]}, {"w": "but", "b": [0.2026, 0.7982, 0.2306, 0.8196]}, {"w": "then", "b": [0.2377, 0.7982, 0.2754, 0.8196]}, {"w": "the", "b": [0.2825, 0.7982, 0.3089, 0.8196]}, {"w": "rest", "b": [0.316, 0.7982, 0.3466, 0.8196]}, {"w": "of", "b": [0.3537, 0.7982, 0.3705, 0.8196]}, {"w": "the", "b": [0.3776, 0.7982, 0.4039, 0.8196]}, {"w": "architecture", "b": [0.4111, 0.7982, 0.5115, 0.8196]}, {"w": "uses", "b": [0.5186, 0.7982, 0.5538, 0.8196]}, {"w": "only", "b": [0.5609, 0.7982, 0.5978, 0.8196]}, {"w": "separable", "b": [0.6049, 0.7982, 0.683, 0.8196]}, {"w": "convolutions", "b": [0.6902, 0.7982, 0.7987, 0.8196]}, {"w": "(34", "b": [0.8058, 0.7982, 0.8331, 0.8196]}, {"w": "in", "b": [0.8402, 0.7982, 0.8571, 0.8196]}]}, {"id": "b_4", "type": "paragraph", "text": "460 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "460", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 487, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "19 “Crafting GBD-Net for Object Detection,” X. Zeng et al. (2016).", "words": [{"w": "19", "b": [0.1385, 0.8568, 0.1518, 0.871]}, {"w": "“Crafting", "b": [0.1587, 0.8553, 0.2178, 0.8716]}, {"w": "GBD-Net", "b": [0.2214, 0.8553, 0.2824, 0.8716]}, {"w": "for", "b": [0.286, 0.8553, 0.3047, 0.8716]}, {"w": "Object", "b": [0.3083, 0.8553, 0.3506, 0.8716]}, {"w": "Detection,”", "b": [0.3542, 0.8553, 0.4245, 0.8716]}, {"w": "X.", "b": [0.4281, 0.8553, 0.4421, 0.8716]}, {"w": "Zeng", "b": [0.4457, 0.8553, 0.4782, 0.8716]}, {"w": "et", "b": [0.4818, 0.8553, 0.4934, 0.8716]}, {"w": "al.", "b": [0.497, 0.8553, 0.5116, 0.8716]}, {"w": "(2016).", "b": [0.5152, 0.8553, 0.5603, 0.8716]}]}, {"id": "b_1", "type": "equation", "text": "20 “Squeeze-and-Excitation Networks,” Jie Hu et al. (2017)", "words": [{"w": "20", "b": [0.1384, 0.8764, 0.1518, 0.8907]}, {"w": "“Squeeze-and-Excitation", "b": [0.1587, 0.8749, 0.3158, 0.8912]}, {"w": "Networks,”", "b": [0.3194, 0.8749, 0.3887, 0.8912]}, {"w": "Jie", "b": [0.3923, 0.8749, 0.408, 0.8912]}, {"w": "Hu", "b": [0.4116, 0.8749, 0.4316, 0.8912]}, {"w": "et", "b": [0.4352, 0.8749, 0.4468, 0.8912]}, {"w": "al.", "b": [0.4504, 0.8749, 0.465, 0.8912]}, {"w": "(2017)", "b": [0.4686, 0.8749, 0.5101, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "all), plus a few max pooling layers and the usual final layers (a global average pooling layer, and a dense output layer).", "words": [{"w": "all),", "b": [0.1429, 0.0791, 0.1745, 0.1005]}, {"w": "plus", "b": [0.1798, 0.0791, 0.2147, 0.1005]}, {"w": "a", "b": [0.22, 0.0791, 0.2292, 0.1005]}, {"w": "few", "b": [0.2345, 0.0791, 0.2638, 0.1005]}, {"w": "max", "b": [0.2691, 0.0791, 0.3052, 0.1005]}, {"w": "pooling", "b": [0.3105, 0.0791, 0.3747, 0.1005]}, {"w": "layers", "b": [0.38, 0.0791, 0.4278, 0.1005]}, {"w": "and", "b": [0.4332, 0.0791, 0.4647, 0.1005]}, {"w": "the", "b": [0.47, 0.0791, 0.4964, 0.1005]}, {"w": "usual", "b": [0.5017, 0.0791, 0.5459, 0.1005]}, {"w": "final", "b": [0.5512, 0.0791, 0.5888, 0.1005]}, {"w": "layers", "b": [0.5941, 0.0791, 0.6419, 0.1005]}, {"w": "(a", "b": [0.6472, 0.0791, 0.6636, 0.1005]}, {"w": "global", "b": [0.6689, 0.0791, 0.7196, 0.1005]}, {"w": "average", "b": [0.7249, 0.0791, 0.7876, 0.1005]}, {"w": "pooling", "b": [0.793, 0.0791, 0.8571, 0.1005]}, {"w": "layer,", "b": [0.1428, 0.0981, 0.1865, 0.1195]}, {"w": "and", "b": [0.1912, 0.0981, 0.2227, 0.1195]}, {"w": "a", "b": [0.2275, 0.0981, 0.2366, 0.1195]}, {"w": "dense", "b": [0.2413, 0.0981, 0.2891, 0.1195]}, {"w": "output", "b": [0.2938, 0.0981, 0.3502, 0.1195]}, {"w": "layer).", "b": [0.3549, 0.0981, 0.4071, 0.1195]}]}, {"id": "b_3", "type": "paragraph", "text": "You might wonder why Xception is considered a variant of GoogLeNet, since it con‐ tains no inception module at all? Well, as we discussed earlier, an Inception module contains convolutional layers with 1 × 1 filters: these look exclusively for cross- channel patterns. However, the convolution layers that sit on top of them are regular convolutional layers that look both for spatial and cross-channel patterns. So you can think of an Inception module as an intermediate between a regular convolutional layer (which considers spatial patterns and cross-channel patterns jointly) and a sepa‐ rable convolutional layer (which considers them separately). In practice, it seems that separable convolutions generally perform better.", "words": [{"w": "You", "b": [0.1428, 0.1262, 0.1752, 0.1476]}, {"w": "might", "b": [0.181, 0.1262, 0.2305, 0.1476]}, {"w": "wonder", "b": [0.2363, 0.1262, 0.3001, 0.1476]}, {"w": "why", "b": [0.3059, 0.1262, 0.3404, 0.1476]}, {"w": "Xception", "b": [0.3462, 0.1262, 0.4224, 0.1476]}, {"w": "is", "b": [0.4282, 0.1262, 0.4414, 0.1476]}, {"w": "considered", "b": [0.4472, 0.1262, 0.5387, 0.1476]}, {"w": "a", "b": [0.5445, 0.1262, 0.5536, 0.1476]}, {"w": "variant", "b": [0.5594, 0.1262, 0.618, 0.1476]}, {"w": "of", "b": [0.6238, 0.1262, 0.6406, 0.1476]}, {"w": "GoogLeNet,", "b": [0.6464, 0.1262, 0.7473, 0.1476]}, {"w": "since", "b": [0.7531, 0.1262, 0.7954, 0.1476]}, {"w": "it", "b": [0.8012, 0.1262, 0.8131, 0.1476]}, {"w": "con‐", "b": [0.8189, 0.1262, 0.8571, 0.1476]}, {"w": "tains", "b": [0.1429, 0.1453, 0.183, 0.1667]}, {"w": "no", "b": [0.1893, 0.1453, 0.2114, 0.1667]}, {"w": "inception", "b": [0.2177, 0.1453, 0.2972, 0.1667]}, {"w": "module", "b": [0.3036, 0.1453, 0.3674, 0.1667]}, {"w": "at", "b": [0.3738, 0.1453, 0.3889, 0.1667]}, {"w": "all?", "b": [0.3952, 0.1453, 0.4228, 0.1667]}, {"w": "Well,", "b": [0.4292, 0.1453, 0.4715, 0.1667]}, {"w": "as", "b": [0.4779, 0.1453, 0.4946, 0.1667]}, {"w": "we", "b": [0.501, 0.1453, 0.5241, 0.1667]}, {"w": "discussed", "b": [0.5305, 0.1453, 0.6097, 0.1667]}, {"w": "earlier,", "b": [0.6161, 0.1453, 0.6727, 0.1667]}, {"w": "an", "b": [0.679, 0.1453, 0.6995, 0.1667]}, {"w": "Inception", "b": [0.7059, 0.1453, 0.7869, 0.1667]}, {"w": "module", "b": [0.7933, 0.1453, 0.8571, 0.1667]}, {"w": "contains", "b": [0.1429, 0.1643, 0.2134, 0.1857]}, {"w": "convolutional", "b": [0.2229, 0.1643, 0.3383, 0.1857]}, {"w": "layers", "b": [0.3478, 0.1643, 0.3956, 0.1857]}, {"w": "with", "b": [0.4052, 0.1643, 0.4425, 0.1857]}, {"w": "1", "b": [0.452, 0.1643, 0.462, 0.1857]}, {"w": "×", "b": [0.4715, 0.1643, 0.4836, 0.1857]}, {"w": "1", "b": [0.4932, 0.1643, 0.5032, 0.1857]}, {"w": "filters:", "b": [0.5127, 0.1643, 0.565, 0.1857]}, {"w": "these", "b": [0.5746, 0.1643, 0.6174, 0.1857]}, {"w": "look", "b": [0.6269, 0.1643, 0.6638, 0.1857]}, {"w": "exclusively", "b": [0.6733, 0.1643, 0.7637, 0.1857]}, {"w": "for", "b": [0.7732, 0.1643, 0.7977, 0.1857]}, {"w": "cross-", "b": [0.8073, 0.1643, 0.8571, 0.1857]}, {"w": "channel", "b": [0.1429, 0.1834, 0.2089, 0.2048]}, {"w": "patterns.", "b": [0.2145, 0.1834, 0.2873, 0.2048]}, {"w": "However,", "b": [0.293, 0.1834, 0.3718, 0.2048]}, {"w": "the", "b": [0.3775, 0.1834, 0.4039, 0.2048]}, {"w": "convolution", "b": [0.4096, 0.1834, 0.5105, 0.2048]}, {"w": "layers", "b": [0.5162, 0.1834, 0.564, 0.2048]}, {"w": "that", "b": [0.5697, 0.1834, 0.6023, 0.2048]}, {"w": "sit", "b": [0.608, 0.1834, 0.6276, 0.2048]}, {"w": "on", "b": [0.6333, 0.1834, 0.6553, 0.2048]}, {"w": "top", "b": [0.661, 0.1834, 0.6889, 0.2048]}, {"w": "of", "b": [0.6946, 0.1834, 0.7114, 0.2048]}, {"w": "them", "b": [0.7171, 0.1834, 0.7605, 0.2048]}, {"w": "are", "b": [0.7662, 0.1834, 0.7919, 0.2048]}, {"w": "regular", "b": [0.7976, 0.1834, 0.8571, 0.2048]}, {"w": "convolutional", "b": [0.1429, 0.2024, 0.2582, 0.2238]}, {"w": "layers", "b": [0.2635, 0.2024, 0.3113, 0.2238]}, {"w": "that", "b": [0.3166, 0.2024, 0.3492, 0.2238]}, {"w": "look", "b": [0.3545, 0.2024, 0.3914, 0.2238]}, {"w": "both", "b": [0.3967, 0.2024, 0.4353, 0.2238]}, {"w": "for", "b": [0.4406, 0.2024, 0.4652, 0.2238]}, {"w": "spatial", "b": [0.4704, 0.2024, 0.5241, 0.2238]}, {"w": "and", "b": [0.5294, 0.2024, 0.561, 0.2238]}, {"w": "cross-channel", "b": [0.5662, 0.2024, 0.6821, 0.2238]}, {"w": "patterns.", "b": [0.6874, 0.2024, 0.7602, 0.2238]}, {"w": "So", "b": [0.7655, 0.2024, 0.786, 0.2238]}, {"w": "you", "b": [0.7913, 0.2024, 0.8225, 0.2238]}, {"w": "can", "b": [0.8278, 0.2024, 0.8572, 0.2238]}, {"w": "think", "b": [0.1429, 0.2215, 0.1877, 0.2429]}, {"w": "of", "b": [0.1959, 0.2215, 0.2127, 0.2429]}, {"w": "an", "b": [0.2209, 0.2215, 0.2415, 0.2429]}, {"w": "Inception", "b": [0.2497, 0.2215, 0.3308, 0.2429]}, {"w": "module", "b": [0.339, 0.2215, 0.4029, 0.2429]}, {"w": "as", "b": [0.4112, 0.2215, 0.4279, 0.2429]}, {"w": "an", "b": [0.4362, 0.2215, 0.4567, 0.2429]}, {"w": "intermediate", "b": [0.465, 0.2215, 0.571, 0.2429]}, {"w": "between", "b": [0.5792, 0.2215, 0.6484, 0.2429]}, {"w": "a", "b": [0.6566, 0.2215, 0.6658, 0.2429]}, {"w": "regular", "b": [0.674, 0.2215, 0.7336, 0.2429]}, {"w": "convolutional", "b": [0.7418, 0.2215, 0.8571, 0.2429]}, {"w": "layer", "b": [0.1429, 0.2405, 0.183, 0.2619]}, {"w": "(which", "b": [0.188, 0.2405, 0.2461, 0.2619]}, {"w": "considers", "b": [0.251, 0.2405, 0.3303, 0.2619]}, {"w": "spatial", "b": [0.3352, 0.2405, 0.3889, 0.2619]}, {"w": "patterns", "b": [0.3938, 0.2405, 0.4618, 0.2619]}, {"w": "and", "b": [0.4667, 0.2405, 0.4982, 0.2619]}, {"w": "cross-channel", "b": [0.5031, 0.2405, 0.619, 0.2619]}, {"w": "patterns", "b": [0.6239, 0.2405, 0.6919, 0.2619]}, {"w": "jointly)", "b": [0.6968, 0.2405, 0.7577, 0.2619]}, {"w": "and", "b": [0.7627, 0.2405, 0.7942, 0.2619]}, {"w": "a", "b": [0.7991, 0.2405, 0.8083, 0.2619]}, {"w": "sepa‐", "b": [0.8132, 0.2405, 0.8571, 0.2619]}, {"w": "rable", "b": [0.1428, 0.2596, 0.1844, 0.281]}, {"w": "convolutional", "b": [0.1896, 0.2596, 0.305, 0.281]}, {"w": "layer", "b": [0.3102, 0.2596, 0.3504, 0.281]}, {"w": "(which", "b": [0.3556, 0.2596, 0.4137, 0.281]}, {"w": "considers", "b": [0.4189, 0.2596, 0.4982, 0.281]}, {"w": "them", "b": [0.5034, 0.2596, 0.5468, 0.281]}, {"w": "separately).", "b": [0.552, 0.2596, 0.6471, 0.281]}, {"w": "In", "b": [0.6523, 0.2596, 0.6708, 0.281]}, {"w": "practice,", "b": [0.676, 0.2596, 0.7469, 0.281]}, {"w": "it", "b": [0.7521, 0.2596, 0.7641, 0.281]}, {"w": "seems", "b": [0.7693, 0.2596, 0.8193, 0.281]}, {"w": "that", "b": [0.8246, 0.2596, 0.8571, 0.281]}, {"w": "separable", "b": [0.1429, 0.2786, 0.221, 0.3]}, {"w": "convolutions", "b": [0.2257, 0.2786, 0.3343, 0.3]}, {"w": "generally", "b": [0.339, 0.2786, 0.4149, 0.3]}, {"w": "perform", "b": [0.4196, 0.2786, 0.4887, 0.3]}, {"w": "better.", "b": [0.4934, 0.2786, 0.5456, 0.3]}]}, {"id": "b_4", "type": "paragraph", "text": "Separable convolutions use less parameters, less memory and less computations than regular convolutional layers, and in general they even perform better, so you should consider using them by default (except after layers with few channels).", "words": [{"w": "Separable", "b": [0.2714, 0.3206, 0.3449, 0.3401]}, {"w": "convolutions", "b": [0.3513, 0.3206, 0.4506, 0.3401]}, {"w": "use", "b": [0.4571, 0.3206, 0.4823, 0.3401]}, {"w": "less", "b": [0.4887, 0.3206, 0.5156, 0.3401]}, {"w": "parameters,", "b": [0.5221, 0.3206, 0.6119, 0.3401]}, {"w": "less", "b": [0.6183, 0.3206, 0.6452, 0.3401]}, {"w": "memory", "b": [0.6517, 0.3206, 0.717, 0.3401]}, {"w": "and", "b": [0.7235, 0.3206, 0.7523, 0.3401]}, {"w": "less", "b": [0.7588, 0.3206, 0.7857, 0.3401]}, {"w": "computations", "b": [0.2714, 0.338, 0.3764, 0.3575]}, {"w": "than", "b": [0.3859, 0.338, 0.4206, 0.3575]}, {"w": "regular", "b": [0.4301, 0.338, 0.4846, 0.3575]}, {"w": "convolutional", "b": [0.4941, 0.338, 0.5995, 0.3575]}, {"w": "layers,", "b": [0.609, 0.338, 0.6571, 0.3575]}, {"w": "and", "b": [0.6666, 0.338, 0.6954, 0.3575]}, {"w": "in", "b": [0.7049, 0.338, 0.7204, 0.3575]}, {"w": "general", "b": [0.7299, 0.338, 0.7857, 0.3575]}, {"w": "they", "b": [0.2714, 0.3554, 0.3042, 0.375]}, {"w": "even", "b": [0.3115, 0.3554, 0.3469, 0.375]}, {"w": "perform", "b": [0.3542, 0.3554, 0.4174, 0.375]}, {"w": "better,", "b": [0.4247, 0.3554, 0.4724, 0.375]}, {"w": "so", "b": [0.4797, 0.3554, 0.4964, 0.375]}, {"w": "you", "b": [0.5037, 0.3554, 0.5322, 0.375]}, {"w": "should", "b": [0.5395, 0.3554, 0.5914, 0.375]}, {"w": "consider", "b": [0.5987, 0.3554, 0.6642, 0.375]}, {"w": "using", "b": [0.6715, 0.3554, 0.713, 0.375]}, {"w": "them", "b": [0.7203, 0.3554, 0.76, 0.375]}, {"w": "by", "b": [0.7673, 0.3554, 0.7857, 0.375]}, {"w": "default", "b": [0.2714, 0.3728, 0.3239, 0.3924]}, {"w": "(except", "b": [0.3283, 0.3728, 0.3839, 0.3924]}, {"w": "after", "b": [0.3882, 0.3728, 0.4232, 0.3924]}, {"w": "layers", "b": [0.4275, 0.3728, 0.4712, 0.3924]}, {"w": "with", "b": [0.4756, 0.3728, 0.5097, 0.3924]}, {"w": "few", "b": [0.514, 0.3728, 0.5408, 0.3924]}, {"w": "channels).", "b": [0.5451, 0.3728, 0.6234, 0.3924]}]}, {"id": "b_5", "type": "paragraph", "text": "The ILSVRC 2016 challenge was won by the CUImage team from the Chinese Uni‐ versity of Hong Kong. They used an ensemble of many different techniques, includ‐ ing a sophisticated object-detection system called GBD-Net19, to achieve a top-5 error rate below 3%. Although this result is unquestionably impressive, the complexity of the solution contrasted with the simplicity of ResNets. Moreover, one year later another fairly simple architecture performed even better, as we will see now.", "words": [{"w": "The", "b": [0.1429, 0.4192, 0.1757, 0.4406]}, {"w": "ILSVRC", "b": [0.1821, 0.4192, 0.2517, 0.4406]}, {"w": "2016", "b": [0.2581, 0.4192, 0.2981, 0.4406]}, {"w": "challenge", "b": [0.3045, 0.4192, 0.3829, 0.4406]}, {"w": "was", "b": [0.3893, 0.4192, 0.4204, 0.4406]}, {"w": "won", "b": [0.4268, 0.4192, 0.4631, 0.4406]}, {"w": "by", "b": [0.4694, 0.4192, 0.4896, 0.4406]}, {"w": "the", "b": [0.496, 0.4192, 0.5223, 0.4406]}, {"w": "CUImage", "b": [0.5287, 0.4192, 0.6098, 0.4406]}, {"w": "team", "b": [0.6162, 0.4192, 0.6576, 0.4406]}, {"w": "from", "b": [0.6639, 0.4192, 0.7055, 0.4406]}, {"w": "the", "b": [0.7119, 0.4192, 0.7382, 0.4406]}, {"w": "Chinese", "b": [0.7446, 0.4192, 0.8119, 0.4406]}, {"w": "Uni‐", "b": [0.8183, 0.4192, 0.8571, 0.4406]}, {"w": "versity", "b": [0.1429, 0.4382, 0.1982, 0.4597]}, {"w": "of", "b": [0.2044, 0.4382, 0.2212, 0.4597]}, {"w": "Hong", "b": [0.2274, 0.4382, 0.2746, 0.4597]}, {"w": "Kong.", "b": [0.2807, 0.4382, 0.3308, 0.4597]}, {"w": "They", "b": [0.337, 0.4382, 0.3793, 0.4597]}, {"w": "used", "b": [0.3855, 0.4382, 0.4241, 0.4597]}, {"w": "an", "b": [0.4303, 0.4382, 0.4508, 0.4597]}, {"w": "ensemble", "b": [0.457, 0.4382, 0.5355, 0.4597]}, {"w": "of", "b": [0.5417, 0.4382, 0.5584, 0.4597]}, {"w": "many", "b": [0.5646, 0.4382, 0.6113, 0.4597]}, {"w": "different", "b": [0.6175, 0.4382, 0.6892, 0.4597]}, {"w": "techniques,", "b": [0.6953, 0.4382, 0.7904, 0.4597]}, {"w": "includ‐", "b": [0.7966, 0.4382, 0.8571, 0.4597]}, {"w": "ing", "b": [0.1429, 0.4573, 0.1696, 0.4787]}, {"w": "a", "b": [0.1746, 0.4573, 0.1838, 0.4787]}, {"w": "sophisticated", "b": [0.1888, 0.4573, 0.2981, 0.4787]}, {"w": "object-detection", "b": [0.3031, 0.4573, 0.4389, 0.4787]}, {"w": "system", "b": [0.444, 0.4573, 0.5011, 0.4787]}, {"w": "called", "b": [0.5062, 0.4573, 0.5545, 0.4787]}, {"w": "GBD-Net19,", "b": [0.5596, 0.4573, 0.6558, 0.4787]}, {"w": "to", "b": [0.6608, 0.4573, 0.6778, 0.4787]}, {"w": "achieve", "b": [0.6828, 0.4573, 0.7449, 0.4787]}, {"w": "a", "b": [0.7499, 0.4573, 0.7591, 0.4787]}, {"w": "top-5", "b": [0.7641, 0.4573, 0.8094, 0.4787]}, {"w": "error", "b": [0.8145, 0.4573, 0.8571, 0.4787]}, {"w": "rate", "b": [0.1429, 0.4763, 0.1746, 0.4978]}, {"w": "below", "b": [0.1812, 0.4763, 0.2308, 0.4978]}, {"w": "3%.", "b": [0.2375, 0.4763, 0.268, 0.4978]}, {"w": "Although", "b": [0.2746, 0.4763, 0.3543, 0.4978]}, {"w": "this", "b": [0.361, 0.4763, 0.3917, 0.4978]}, {"w": "result", "b": [0.3984, 0.4763, 0.4453, 0.4978]}, {"w": "is", "b": [0.452, 0.4763, 0.4652, 0.4978]}, {"w": "unquestionably", "b": [0.4718, 0.4763, 0.601, 0.4978]}, {"w": "impressive,", "b": [0.6077, 0.4763, 0.7016, 0.4978]}, {"w": "the", "b": [0.7082, 0.4763, 0.7346, 0.4978]}, {"w": "complexity", "b": [0.7412, 0.4763, 0.8337, 0.4978]}, {"w": "of", "b": [0.8404, 0.4763, 0.8572, 0.4978]}, {"w": "the", "b": [0.1429, 0.4954, 0.1692, 0.5168]}, {"w": "solution", "b": [0.1791, 0.4954, 0.2476, 0.5168]}, {"w": "contrasted", "b": [0.2575, 0.4954, 0.3451, 0.5168]}, {"w": "with", "b": [0.3549, 0.4954, 0.3923, 0.5168]}, {"w": "the", "b": [0.4022, 0.4954, 0.4285, 0.5168]}, {"w": "simplicity", "b": [0.4384, 0.4954, 0.5204, 0.5168]}, {"w": "of", "b": [0.5303, 0.4954, 0.5471, 0.5168]}, {"w": "ResNets.", "b": [0.5569, 0.4954, 0.6289, 0.5168]}, {"w": "Moreover,", "b": [0.6388, 0.4954, 0.7244, 0.5168]}, {"w": "one", "b": [0.7342, 0.4954, 0.7651, 0.5168]}, {"w": "year", "b": [0.775, 0.4954, 0.8103, 0.5168]}, {"w": "later", "b": [0.8202, 0.4954, 0.8571, 0.5168]}, {"w": "another", "b": [0.1429, 0.5144, 0.2081, 0.5358]}, {"w": "fairly", "b": [0.2128, 0.5144, 0.2563, 0.5358]}, {"w": "simple", "b": [0.261, 0.5144, 0.3159, 0.5358]}, {"w": "architecture", "b": [0.3207, 0.5144, 0.4211, 0.5358]}, {"w": "performed", "b": [0.4258, 0.5144, 0.5147, 0.5358]}, {"w": "even", "b": [0.5195, 0.5144, 0.5582, 0.5358]}, {"w": "better,", "b": [0.563, 0.5144, 0.6151, 0.5358]}, {"w": "as", "b": [0.6199, 0.5144, 0.6366, 0.5358]}, {"w": "we", "b": [0.6414, 0.5144, 0.6645, 0.5358]}, {"w": "will", "b": [0.6692, 0.5144, 0.6996, 0.5358]}, {"w": "see", "b": [0.7044, 0.5144, 0.7297, 0.5358]}, {"w": "now.", "b": [0.7344, 0.5144, 0.774, 0.5358]}]}, {"id": "b_6", "type": "paragraph", "text": "SENet", "words": [{"w": "SENet", "b": [0.1428, 0.5486, 0.2032, 0.5772]}]}, {"id": "b_7", "type": "paragraph", "text": "The winning architecture in the ILSVRC 2017 challenge was the Squeeze-and- Excitation Network (SENet)20. This architecture extends existing architectures such as inception networks or ResNets, and boosts their performance. This allowed SENet to win the competition with an astonishing 2.25% top-5 error rate! The extended ver‐ sions of inception networks and ResNet are called SE-Inception and SE-ResNet respec‐ tively. The boost comes from the fact that a SENet adds a small neural network, called a SE Block, to every unit in the original architecture (i.e., every inception module or every residual unit), as shown in Figure 14-20.", "words": [{"w": "The", "b": [0.1429, 0.5831, 0.1757, 0.6045]}, {"w": "winning", "b": [0.1867, 0.5831, 0.256, 0.6045]}, {"w": "architecture", "b": [0.267, 0.5831, 0.3674, 0.6045]}, {"w": "in", "b": [0.3784, 0.5831, 0.3953, 0.6045]}, {"w": "the", "b": [0.4063, 0.5831, 0.4326, 0.6045]}, {"w": "ILSVRC", "b": [0.4436, 0.5831, 0.5132, 0.6045]}, {"w": "2017", "b": [0.5242, 0.5831, 0.5642, 0.6045]}, {"w": "challenge", "b": [0.5751, 0.5831, 0.6536, 0.6045]}, {"w": "was", "b": [0.6646, 0.5831, 0.6956, 0.6045]}, {"w": "the", "b": [0.7066, 0.5831, 0.7329, 0.6045]}, {"w": "Squeeze-and-", "b": [0.7439, 0.5831, 0.8571, 0.6045]}, {"w": "Excitation", "b": [0.1429, 0.6021, 0.228, 0.6235]}, {"w": "Network", "b": [0.2327, 0.6021, 0.3058, 0.6235]}, {"w": "(SENet)20.", "b": [0.3108, 0.6021, 0.3932, 0.6235]}, {"w": "This", "b": [0.3981, 0.6021, 0.4353, 0.6235]}, {"w": "architecture", "b": [0.4401, 0.6021, 0.5405, 0.6235]}, {"w": "extends", "b": [0.5454, 0.6021, 0.6093, 0.6235]}, {"w": "existing", "b": [0.6141, 0.6021, 0.6791, 0.6235]}, {"w": "architectures", "b": [0.684, 0.6021, 0.792, 0.6235]}, {"w": "such", "b": [0.7969, 0.6021, 0.8355, 0.6235]}, {"w": "as", "b": [0.8403, 0.6021, 0.8571, 0.6235]}, {"w": "inception", "b": [0.1428, 0.6212, 0.2224, 0.6426]}, {"w": "networks", "b": [0.2278, 0.6212, 0.305, 0.6426]}, {"w": "or", "b": [0.3105, 0.6212, 0.3288, 0.6426]}, {"w": "ResNets,", "b": [0.3343, 0.6212, 0.4063, 0.6426]}, {"w": "and", "b": [0.4117, 0.6212, 0.4433, 0.6426]}, {"w": "boosts", "b": [0.4487, 0.6212, 0.5022, 0.6426]}, {"w": "their", "b": [0.5077, 0.6212, 0.5473, 0.6426]}, {"w": "performance.", "b": [0.5528, 0.6212, 0.6648, 0.6426]}, {"w": "This", "b": [0.6703, 0.6212, 0.7075, 0.6426]}, {"w": "allowed", "b": [0.7129, 0.6212, 0.7774, 0.6426]}, {"w": "SENet", "b": [0.7828, 0.6212, 0.8347, 0.6426]}, {"w": "to", "b": [0.8402, 0.6212, 0.8571, 0.6426]}, {"w": "win", "b": [0.1429, 0.6402, 0.1741, 0.6616]}, {"w": "the", "b": [0.181, 0.6402, 0.2073, 0.6616]}, {"w": "competition", "b": [0.2142, 0.6402, 0.3159, 0.6616]}, {"w": "with", "b": [0.3228, 0.6402, 0.3601, 0.6616]}, {"w": "an", "b": [0.367, 0.6402, 0.3875, 0.6616]}, {"w": "astonishing", "b": [0.3944, 0.6402, 0.4906, 0.6616]}, {"w": "2.25%", "b": [0.4975, 0.6402, 0.548, 0.6616]}, {"w": "top-5", "b": [0.5548, 0.6402, 0.6001, 0.6616]}, {"w": "error", "b": [0.607, 0.6402, 0.6497, 0.6616]}, {"w": "rate!", "b": [0.6565, 0.6402, 0.694, 0.6616]}, {"w": "The", "b": [0.7008, 0.6402, 0.7336, 0.6616]}, {"w": "extended", "b": [0.7405, 0.6402, 0.8166, 0.6616]}, {"w": "ver‐", "b": [0.8235, 0.6402, 0.8571, 0.6616]}, {"w": "sions", "b": [0.1429, 0.6593, 0.1858, 0.6807]}, {"w": "of", "b": [0.1905, 0.6593, 0.2073, 0.6807]}, {"w": "inception", "b": [0.212, 0.6593, 0.2915, 0.6807]}, {"w": "networks", "b": [0.2963, 0.6593, 0.3735, 0.6807]}, {"w": "and", "b": [0.3782, 0.6593, 0.4097, 0.6807]}, {"w": "ResNet", "b": [0.4145, 0.6593, 0.4741, 0.6807]}, {"w": "are", "b": [0.4788, 0.6593, 0.5045, 0.6807]}, {"w": "called", "b": [0.5093, 0.6593, 0.5576, 0.6807]}, {"w": "SE-Inception", "b": [0.5628, 0.6591, 0.6665, 0.6807]}, {"w": "and", "b": [0.6713, 0.6593, 0.7029, 0.6807]}, {"w": "SE-ResNet", "b": [0.7077, 0.6591, 0.7921, 0.6807]}, {"w": "respec‐", "b": [0.7969, 0.6593, 0.8571, 0.6807]}, {"w": "tively.", "b": [0.1429, 0.6783, 0.1914, 0.6997]}, {"w": "The", "b": [0.1963, 0.6783, 0.2291, 0.6997]}, {"w": "boost", "b": [0.234, 0.6783, 0.2798, 0.6997]}, {"w": "comes", "b": [0.2848, 0.6783, 0.3378, 0.6997]}, {"w": "from", "b": [0.3427, 0.6783, 0.3843, 0.6997]}, {"w": "the", "b": [0.3892, 0.6783, 0.4155, 0.6997]}, {"w": "fact", "b": [0.4204, 0.6783, 0.4509, 0.6997]}, {"w": "that", "b": [0.4558, 0.6783, 0.4884, 0.6997]}, {"w": "a", "b": [0.4933, 0.6783, 0.5024, 0.6997]}, {"w": "SENet", "b": [0.5073, 0.6783, 0.5592, 0.6997]}, {"w": "adds", "b": [0.5641, 0.6783, 0.6029, 0.6997]}, {"w": "a", "b": [0.6078, 0.6783, 0.617, 0.6997]}, {"w": "small", "b": [0.6219, 0.6783, 0.6663, 0.6997]}, {"w": "neural", "b": [0.6712, 0.6783, 0.7247, 0.6997]}, {"w": "network,", "b": [0.7296, 0.6783, 0.8039, 0.6997]}, {"w": "called", "b": [0.8088, 0.6783, 0.8571, 0.6997]}, {"w": "a", "b": [0.1429, 0.6974, 0.152, 0.7188]}, {"w": "SE", "b": [0.1582, 0.6972, 0.1794, 0.7188]}, {"w": "Block,", "b": [0.1856, 0.6972, 0.2346, 0.7188]}, {"w": "to", "b": [0.2408, 0.6974, 0.2577, 0.7188]}, {"w": "every", "b": [0.2639, 0.6974, 0.3092, 0.7188]}, {"w": "unit", "b": [0.3154, 0.6974, 0.3498, 0.7188]}, {"w": "in", "b": [0.3559, 0.6974, 0.3729, 0.7188]}, {"w": "the", "b": [0.3791, 0.6974, 0.4054, 0.7188]}, {"w": "original", "b": [0.4116, 0.6974, 0.4767, 0.7188]}, {"w": "architecture", "b": [0.4829, 0.6974, 0.5833, 0.7188]}, {"w": "(i.e.,", "b": [0.5895, 0.6974, 0.6254, 0.7188]}, {"w": "every", "b": [0.6316, 0.6974, 0.6768, 0.7188]}, {"w": "inception", "b": [0.683, 0.6974, 0.7625, 0.7188]}, {"w": "module", "b": [0.7687, 0.6974, 0.8326, 0.7188]}, {"w": "or", "b": [0.8388, 0.6974, 0.8571, 0.7188]}, {"w": "every", "b": [0.1429, 0.7164, 0.1881, 0.7378]}, {"w": "residual", "b": [0.1928, 0.7164, 0.2591, 0.7378]}, {"w": "unit),", "b": [0.2639, 0.7164, 0.3102, 0.7378]}, {"w": "as", "b": [0.315, 0.7164, 0.3317, 0.7378]}, {"w": "shown", "b": [0.3365, 0.7164, 0.3915, 0.7378]}, {"w": "in", "b": [0.3963, 0.7164, 0.4132, 0.7378]}, {"w": "Figure", "b": [0.418, 0.7164, 0.472, 0.7378]}, {"w": "14-20.", "b": [0.4767, 0.7164, 0.5289, 0.7378]}]}, {"id": "b_8", "type": "paragraph", "text": "CNN Architectures | 461", "words": [{"w": "CNN", "b": [0.6908, 0.9225, 0.7152, 0.9388]}, {"w": "Architectures", "b": [0.7181, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "461", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 488, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 14-20. SE-Inception Module (left) and SE-ResNet Unit (right)", "words": [{"w": "Figure", "b": [0.1429, 0.433, 0.1943, 0.4546]}, {"w": "14-20.", "b": [0.1991, 0.433, 0.2507, 0.4546]}, {"w": "SE-Inception", "b": [0.2554, 0.433, 0.3591, 0.4546]}, {"w": "Module", "b": [0.3639, 0.433, 0.426, 0.4546]}, {"w": "(left)", "b": [0.4308, 0.433, 0.4701, 0.4546]}, {"w": "and", "b": [0.4749, 0.433, 0.5063, 0.4546]}, {"w": "SE-ResNet", "b": [0.511, 0.433, 0.5955, 0.4546]}, {"w": "Unit", "b": [0.6003, 0.433, 0.6367, 0.4546]}, {"w": "(right)", "b": [0.6415, 0.433, 0.6941, 0.4546]}]}, {"id": "b_1", "type": "paragraph", "text": "A SE Block analyzes the output of the unit it is attached to, focusing exclusively on the depth dimension (it does not look for any spatial pattern), and it learns which fea‐ tures are usually most active together. It then uses this information to recalibrate the feature maps, as shown in Figure 14-21. For example, a SE Block may learn that mouths, noses and eyes usually appear together in pictures: if you see a mouth and a nose, you should expect to see eyes as well. So if a SE Block sees a strong activation in the mouth and nose feature maps, but only mild activation in the eye feature map, it will boost the eye feature map (more accurately, it will reduce irrelevant feature maps). If the eyes were somewhat confused with something else, this feature map recalibration will help resolve the ambiguity.", "words": [{"w": "A", "b": [0.1429, 0.4704, 0.1573, 0.4918]}, {"w": "SE", "b": [0.164, 0.4704, 0.1857, 0.4918]}, {"w": "Block", "b": [0.1924, 0.4704, 0.2397, 0.4918]}, {"w": "analyzes", "b": [0.2464, 0.4704, 0.3162, 0.4918]}, {"w": "the", "b": [0.3229, 0.4704, 0.3492, 0.4918]}, {"w": "output", "b": [0.3559, 0.4704, 0.4123, 0.4918]}, {"w": "of", "b": [0.419, 0.4704, 0.4358, 0.4918]}, {"w": "the", "b": [0.4425, 0.4704, 0.4689, 0.4918]}, {"w": "unit", "b": [0.4756, 0.4704, 0.51, 0.4918]}, {"w": "it", "b": [0.5167, 0.4704, 0.5286, 0.4918]}, {"w": "is", "b": [0.5354, 0.4704, 0.5486, 0.4918]}, {"w": "attached", "b": [0.5553, 0.4704, 0.6257, 0.4918]}, {"w": "to,", "b": [0.6324, 0.4704, 0.6535, 0.4918]}, {"w": "focusing", "b": [0.6602, 0.4704, 0.7313, 0.4918]}, {"w": "exclusively", "b": [0.738, 0.4704, 0.8284, 0.4918]}, {"w": "on", "b": [0.8351, 0.4704, 0.8571, 0.4918]}, {"w": "the", "b": [0.1428, 0.4894, 0.1692, 0.5108]}, {"w": "depth", "b": [0.174, 0.4894, 0.2222, 0.5108]}, {"w": "dimension", "b": [0.227, 0.4894, 0.3162, 0.5108]}, {"w": "(it", "b": [0.321, 0.4894, 0.3401, 0.5108]}, {"w": "does", "b": [0.3449, 0.4894, 0.383, 0.5108]}, {"w": "not", "b": [0.3878, 0.4894, 0.4162, 0.5108]}, {"w": "look", "b": [0.421, 0.4894, 0.4578, 0.5108]}, {"w": "for", "b": [0.4626, 0.4894, 0.4872, 0.5108]}, {"w": "any", "b": [0.492, 0.4894, 0.5216, 0.5108]}, {"w": "spatial", "b": [0.5264, 0.4894, 0.58, 0.5108]}, {"w": "pattern),", "b": [0.5848, 0.4894, 0.6571, 0.5108]}, {"w": "and", "b": [0.6619, 0.4894, 0.6935, 0.5108]}, {"w": "it", "b": [0.6983, 0.4894, 0.7102, 0.5108]}, {"w": "learns", "b": [0.715, 0.4894, 0.765, 0.5108]}, {"w": "which", "b": [0.7698, 0.4894, 0.8208, 0.5108]}, {"w": "fea‐", "b": [0.8256, 0.4894, 0.8571, 0.5108]}, {"w": "tures", "b": [0.1429, 0.5084, 0.1845, 0.5299]}, {"w": "are", "b": [0.1904, 0.5084, 0.2161, 0.5299]}, {"w": "usually", "b": [0.222, 0.5084, 0.281, 0.5299]}, {"w": "most", "b": [0.2868, 0.5084, 0.3285, 0.5299]}, {"w": "active", "b": [0.3344, 0.5084, 0.3828, 0.5299]}, {"w": "together.", "b": [0.3886, 0.5084, 0.4617, 0.5299]}, {"w": "It", "b": [0.4676, 0.5084, 0.4802, 0.5299]}, {"w": "then", "b": [0.4861, 0.5084, 0.5238, 0.5299]}, {"w": "uses", "b": [0.5297, 0.5084, 0.5649, 0.5299]}, {"w": "this", "b": [0.5708, 0.5084, 0.6015, 0.5299]}, {"w": "information", "b": [0.6073, 0.5084, 0.7086, 0.5299]}, {"w": "to", "b": [0.7145, 0.5084, 0.7314, 0.5299]}, {"w": "recalibrate", "b": [0.7373, 0.5084, 0.825, 0.5299]}, {"w": "the", "b": [0.8308, 0.5084, 0.8572, 0.5299]}, {"w": "feature", "b": [0.1429, 0.5275, 0.2006, 0.5489]}, {"w": "maps,", "b": [0.2092, 0.5275, 0.2584, 0.5489]}, {"w": "as", "b": [0.267, 0.5275, 0.2838, 0.5489]}, {"w": "shown", "b": [0.2924, 0.5275, 0.3475, 0.5489]}, {"w": "in", "b": [0.3561, 0.5275, 0.373, 0.5489]}, {"w": "Figure", "b": [0.3817, 0.5275, 0.4357, 0.5489]}, {"w": "14-21.", "b": [0.4443, 0.5275, 0.4964, 0.5489]}, {"w": "For", "b": [0.5051, 0.5275, 0.534, 0.5489]}, {"w": "example,", "b": [0.5426, 0.5275, 0.6169, 0.5489]}, {"w": "a", "b": [0.6256, 0.5275, 0.6347, 0.5489]}, {"w": "SE", "b": [0.6433, 0.5275, 0.665, 0.5489]}, {"w": "Block", "b": [0.6736, 0.5275, 0.7209, 0.5489]}, {"w": "may", "b": [0.7295, 0.5275, 0.7649, 0.5489]}, {"w": "learn", "b": [0.7736, 0.5275, 0.8159, 0.5489]}, {"w": "that", "b": [0.8246, 0.5275, 0.8571, 0.5489]}, {"w": "mouths,", "b": [0.1429, 0.5465, 0.2115, 0.568]}, {"w": "noses", "b": [0.2171, 0.5465, 0.2633, 0.568]}, {"w": "and", "b": [0.269, 0.5465, 0.3005, 0.568]}, {"w": "eyes", "b": [0.3062, 0.5465, 0.3411, 0.568]}, {"w": "usually", "b": [0.3468, 0.5465, 0.4058, 0.568]}, {"w": "appear", "b": [0.4114, 0.5465, 0.4678, 0.568]}, {"w": "together", "b": [0.4734, 0.5465, 0.5431, 0.568]}, {"w": "in", "b": [0.5487, 0.5465, 0.5657, 0.568]}, {"w": "pictures:", "b": [0.5714, 0.5465, 0.6431, 0.568]}, {"w": "if", "b": [0.6487, 0.5465, 0.6605, 0.568]}, {"w": "you", "b": [0.6662, 0.5465, 0.6974, 0.568]}, {"w": "see", "b": [0.7031, 0.5465, 0.7284, 0.568]}, {"w": "a", "b": [0.7341, 0.5465, 0.7432, 0.568]}, {"w": "mouth", "b": [0.7489, 0.5465, 0.8051, 0.568]}, {"w": "and", "b": [0.8108, 0.5465, 0.8423, 0.568]}, {"w": "a", "b": [0.848, 0.5465, 0.8571, 0.568]}, {"w": "nose,", "b": [0.1428, 0.5656, 0.1861, 0.587]}, {"w": "you", "b": [0.1912, 0.5656, 0.2225, 0.587]}, {"w": "should", "b": [0.2276, 0.5656, 0.2843, 0.587]}, {"w": "expect", "b": [0.2894, 0.5656, 0.343, 0.587]}, {"w": "to", "b": [0.3481, 0.5656, 0.3651, 0.587]}, {"w": "see", "b": [0.3702, 0.5656, 0.3955, 0.587]}, {"w": "eyes", "b": [0.4006, 0.5656, 0.4355, 0.587]}, {"w": "as", "b": [0.4406, 0.5656, 0.4574, 0.587]}, {"w": "well.", "b": [0.4625, 0.5656, 0.5009, 0.587]}, {"w": "So", "b": [0.506, 0.5656, 0.5265, 0.587]}, {"w": "if", "b": [0.5316, 0.5656, 0.5434, 0.587]}, {"w": "a", "b": [0.5485, 0.5656, 0.5576, 0.587]}, {"w": "SE", "b": [0.5627, 0.5656, 0.5844, 0.587]}, {"w": "Block", "b": [0.5895, 0.5656, 0.6368, 0.587]}, {"w": "sees", "b": [0.6419, 0.5656, 0.6749, 0.587]}, {"w": "a", "b": [0.68, 0.5656, 0.6891, 0.587]}, {"w": "strong", "b": [0.6942, 0.5656, 0.7477, 0.587]}, {"w": "activation", "b": [0.7528, 0.5656, 0.8351, 0.587]}, {"w": "in", "b": [0.8402, 0.5656, 0.8571, 0.587]}, {"w": "the", "b": [0.1429, 0.5846, 0.1692, 0.6061]}, {"w": "mouth", "b": [0.175, 0.5846, 0.2313, 0.6061]}, {"w": "and", "b": [0.2371, 0.5846, 0.2686, 0.6061]}, {"w": "nose", "b": [0.2745, 0.5846, 0.313, 0.6061]}, {"w": "feature", "b": [0.3188, 0.5846, 0.3766, 0.6061]}, {"w": "maps,", "b": [0.3824, 0.5846, 0.4316, 0.6061]}, {"w": "but", "b": [0.4374, 0.5846, 0.4654, 0.6061]}, {"w": "only", "b": [0.4713, 0.5846, 0.5081, 0.6061]}, {"w": "mild", "b": [0.5139, 0.5846, 0.5529, 0.6061]}, {"w": "activation", "b": [0.5587, 0.5846, 0.6409, 0.6061]}, {"w": "in", "b": [0.6468, 0.5846, 0.6638, 0.6061]}, {"w": "the", "b": [0.6696, 0.5846, 0.6959, 0.6061]}, {"w": "eye", "b": [0.7018, 0.5846, 0.729, 0.6061]}, {"w": "feature", "b": [0.7349, 0.5846, 0.7927, 0.6061]}, {"w": "map,", "b": [0.7985, 0.5846, 0.8394, 0.6061]}, {"w": "it", "b": [0.8452, 0.5846, 0.8571, 0.6061]}, {"w": "will", "b": [0.1429, 0.6037, 0.1733, 0.6251]}, {"w": "boost", "b": [0.1828, 0.6037, 0.2286, 0.6251]}, {"w": "the", "b": [0.2381, 0.6037, 0.2645, 0.6251]}, {"w": "eye", "b": [0.274, 0.6037, 0.3013, 0.6251]}, {"w": "feature", "b": [0.3108, 0.6037, 0.3686, 0.6251]}, {"w": "map", "b": [0.3781, 0.6037, 0.4148, 0.6251]}, {"w": "(more", "b": [0.4243, 0.6037, 0.4758, 0.6251]}, {"w": "accurately,", "b": [0.4853, 0.6037, 0.5729, 0.6251]}, {"w": "it", "b": [0.5825, 0.6037, 0.5944, 0.6251]}, {"w": "will", "b": [0.6039, 0.6037, 0.6343, 0.6251]}, {"w": "reduce", "b": [0.6438, 0.6037, 0.7002, 0.6251]}, {"w": "irrelevant", "b": [0.7097, 0.6037, 0.7898, 0.6251]}, {"w": "feature", "b": [0.7994, 0.6037, 0.8571, 0.6251]}, {"w": "maps).", "b": [0.1428, 0.6227, 0.1992, 0.6441]}, {"w": "If", "b": [0.2073, 0.6227, 0.2205, 0.6441]}, {"w": "the", "b": [0.2286, 0.6227, 0.255, 0.6441]}, {"w": "eyes", "b": [0.2631, 0.6227, 0.298, 0.6441]}, {"w": "were", "b": [0.3061, 0.6227, 0.3458, 0.6441]}, {"w": "somewhat", "b": [0.3539, 0.6227, 0.4386, 0.6441]}, {"w": "confused", "b": [0.4467, 0.6227, 0.5222, 0.6441]}, {"w": "with", "b": [0.5303, 0.6227, 0.5677, 0.6441]}, {"w": "something", "b": [0.5758, 0.6227, 0.6642, 0.6441]}, {"w": "else,", "b": [0.6723, 0.6227, 0.7076, 0.6441]}, {"w": "this", "b": [0.7157, 0.6227, 0.7464, 0.6441]}, {"w": "feature", "b": [0.7545, 0.6227, 0.8123, 0.6441]}, {"w": "map", "b": [0.8204, 0.6227, 0.8571, 0.6441]}, {"w": "recalibration", "b": [0.1429, 0.6418, 0.2493, 0.6632]}, {"w": "will", "b": [0.254, 0.6418, 0.2844, 0.6632]}, {"w": "help", "b": [0.2891, 0.6418, 0.3253, 0.6632]}, {"w": "resolve", "b": [0.33, 0.6418, 0.3887, 0.6632]}, {"w": "the", "b": [0.3934, 0.6418, 0.4197, 0.6632]}, {"w": "ambiguity.", "b": [0.4244, 0.6418, 0.5124, 0.6632]}]}, {"id": "b_2", "type": "paragraph", "text": "462 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "462", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3683, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 489, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 14-21. An SE Block Performs Feature Map Recalibration", "words": [{"w": "Figure", "b": [0.1429, 0.2874, 0.1943, 0.309]}, {"w": "14-21.", "b": [0.1991, 0.2874, 0.2507, 0.309]}, {"w": "An", "b": [0.2554, 0.2874, 0.2804, 0.309]}, {"w": "SE", "b": [0.2851, 0.2874, 0.3064, 0.309]}, {"w": "Block", "b": [0.3111, 0.2874, 0.3553, 0.309]}, {"w": "Performs", "b": [0.3601, 0.2874, 0.4339, 0.309]}, {"w": "Feature", "b": [0.4386, 0.2874, 0.4995, 0.309]}, {"w": "Map", "b": [0.5043, 0.2874, 0.542, 0.309]}, {"w": "Recalibration", "b": [0.5468, 0.2874, 0.6549, 0.309]}]}, {"id": "b_1", "type": "paragraph", "text": "A SE Block is composed of just 3 layers: a global average pooling layer, a hidden dense layer using the ReLU activation function, and a dense output layer using the sigmoid activation function (see Figure 14-22):", "words": [{"w": "A", "b": [0.1429, 0.3248, 0.1573, 0.3462]}, {"w": "SE", "b": [0.162, 0.3248, 0.1837, 0.3462]}, {"w": "Block", "b": [0.1885, 0.3248, 0.2358, 0.3462]}, {"w": "is", "b": [0.2406, 0.3248, 0.2538, 0.3462]}, {"w": "composed", "b": [0.2586, 0.3248, 0.3438, 0.3462]}, {"w": "of", "b": [0.3486, 0.3248, 0.3653, 0.3462]}, {"w": "just", "b": [0.3701, 0.3248, 0.4005, 0.3462]}, {"w": "3", "b": [0.4053, 0.3248, 0.4153, 0.3462]}, {"w": "layers:", "b": [0.4201, 0.3248, 0.4727, 0.3462]}, {"w": "a", "b": [0.4775, 0.3248, 0.4866, 0.3462]}, {"w": "global", "b": [0.4914, 0.3248, 0.542, 0.3462]}, {"w": "average", "b": [0.5468, 0.3248, 0.6096, 0.3462]}, {"w": "pooling", "b": [0.6144, 0.3248, 0.6785, 0.3462]}, {"w": "layer,", "b": [0.6833, 0.3248, 0.7269, 0.3462]}, {"w": "a", "b": [0.7317, 0.3248, 0.7409, 0.3462]}, {"w": "hidden", "b": [0.7456, 0.3248, 0.8046, 0.3462]}, {"w": "dense", "b": [0.8094, 0.3248, 0.8571, 0.3462]}, {"w": "layer", "b": [0.1429, 0.3438, 0.183, 0.3652]}, {"w": "using", "b": [0.1886, 0.3438, 0.234, 0.3652]}, {"w": "the", "b": [0.2396, 0.3438, 0.2659, 0.3652]}, {"w": "ReLU", "b": [0.2715, 0.3438, 0.319, 0.3652]}, {"w": "activation", "b": [0.3246, 0.3438, 0.4068, 0.3652]}, {"w": "function,", "b": [0.4124, 0.3438, 0.4886, 0.3652]}, {"w": "and", "b": [0.4941, 0.3438, 0.5257, 0.3652]}, {"w": "a", "b": [0.5312, 0.3438, 0.5404, 0.3652]}, {"w": "dense", "b": [0.546, 0.3438, 0.5937, 0.3652]}, {"w": "output", "b": [0.5993, 0.3438, 0.6556, 0.3652]}, {"w": "layer", "b": [0.6612, 0.3438, 0.7014, 0.3652]}, {"w": "using", "b": [0.707, 0.3438, 0.7524, 0.3652]}, {"w": "the", "b": [0.758, 0.3438, 0.7843, 0.3652]}, {"w": "sigmoid", "b": [0.7899, 0.3438, 0.8571, 0.3652]}, {"w": "activation", "b": [0.1429, 0.3629, 0.2251, 0.3843]}, {"w": "function", "b": [0.2298, 0.3629, 0.3012, 0.3843]}, {"w": "(see", "b": [0.306, 0.3629, 0.3385, 0.3843]}, {"w": "Figure", "b": [0.3433, 0.3629, 0.3973, 0.3843]}, {"w": "14-22):", "b": [0.402, 0.3629, 0.4614, 0.3843]}]}, {"id": "b_2", "type": "equation", "text": "Figure 14-22. SE Block Architecture", "words": [{"w": "Figure", "b": [0.1429, 0.8233, 0.1943, 0.845]}, {"w": "14-22.", "b": [0.1991, 0.8233, 0.2507, 0.845]}, {"w": "SE", "b": [0.2554, 0.8233, 0.2767, 0.845]}, {"w": "Block", "b": [0.2814, 0.8233, 0.3256, 0.845]}, {"w": "Architecture", "b": [0.3304, 0.8233, 0.4299, 0.845]}]}, {"id": "b_3", "type": "paragraph", "text": "CNN Architectures | 463", "words": [{"w": "CNN", "b": [0.6907, 0.9225, 0.7152, 0.9388]}, {"w": "Architectures", "b": [0.7181, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "463", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 490, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "As earlier, the global average pooling layer computes the mean activation for each fea‐ ture map: for example, if its input contains 256 feature maps, it will output 256 num‐ bers representing the overall level of response for each filter. The next layer is where the “squeeze” happens: this layer has much less than 256 neurons, typically 16 times less than the number of feature maps (e.g., 16 neurons), so the 256 numbers get com‐ pressed into a small vector (e.g., 16 dimensional). This is a low-dimensional vector representation (i.e., an embedding) of the distribution of feature responses. This bot‐ tleneck step forces the SE Block to learn a general representation of the feature com‐ binations (we will see this principle in action again when we discuss autoencoders in ???). Finally, the output layer takes the embedding and outputs a recalibration vec‐ tor containing one number per feature map (e.g., 256), each between 0 and 1. The feature maps are then multiplied by this recalibration vector, so irrelevant features (with a low recalibration score) get scaled down while relevant features (with a recali‐ bration score close to 1) are left alone.", "words": [{"w": "As", "b": [0.1429, 0.0791, 0.1649, 0.1005]}, {"w": "earlier,", "b": [0.1696, 0.0791, 0.2262, 0.1005]}, {"w": "the", "b": [0.231, 0.0791, 0.2573, 0.1005]}, {"w": "global", "b": [0.262, 0.0791, 0.3127, 0.1005]}, {"w": "average", "b": [0.3174, 0.0791, 0.3801, 0.1005]}, {"w": "pooling", "b": [0.3849, 0.0791, 0.449, 0.1005]}, {"w": "layer", "b": [0.4538, 0.0791, 0.494, 0.1005]}, {"w": "computes", "b": [0.4987, 0.0791, 0.5796, 0.1005]}, {"w": "the", "b": [0.5844, 0.0791, 0.6107, 0.1005]}, {"w": "mean", "b": [0.6154, 0.0791, 0.6619, 0.1005]}, {"w": "activation", "b": [0.6666, 0.0791, 0.7489, 0.1005]}, {"w": "for", "b": [0.7536, 0.0791, 0.7781, 0.1005]}, {"w": "each", "b": [0.7828, 0.0791, 0.8208, 0.1005]}, {"w": "fea‐", "b": [0.8255, 0.0791, 0.8571, 0.1005]}, {"w": "ture", "b": [0.1429, 0.0981, 0.1769, 0.1195]}, {"w": "map:", "b": [0.1823, 0.0981, 0.2237, 0.1195]}, {"w": "for", "b": [0.2291, 0.0981, 0.2537, 0.1195]}, {"w": "example,", "b": [0.2591, 0.0981, 0.3334, 0.1195]}, {"w": "if", "b": [0.3388, 0.0981, 0.3505, 0.1195]}, {"w": "its", "b": [0.3559, 0.0981, 0.3755, 0.1195]}, {"w": "input", "b": [0.3809, 0.0981, 0.4258, 0.1195]}, {"w": "contains", "b": [0.4312, 0.0981, 0.5018, 0.1195]}, {"w": "256", "b": [0.5072, 0.0981, 0.5372, 0.1195]}, {"w": "feature", "b": [0.5426, 0.0981, 0.6004, 0.1195]}, {"w": "maps,", "b": [0.6058, 0.0981, 0.6549, 0.1195]}, {"w": "it", "b": [0.6603, 0.0981, 0.6722, 0.1195]}, {"w": "will", "b": [0.6776, 0.0981, 0.708, 0.1195]}, {"w": "output", "b": [0.7134, 0.0981, 0.7698, 0.1195]}, {"w": "256", "b": [0.7752, 0.0981, 0.8052, 0.1195]}, {"w": "num‐", "b": [0.8106, 0.0981, 0.8571, 0.1195]}, {"w": "bers", "b": [0.1429, 0.1172, 0.1777, 0.1386]}, {"w": "representing", "b": [0.1837, 0.1172, 0.2883, 0.1386]}, {"w": "the", "b": [0.2944, 0.1172, 0.3207, 0.1386]}, {"w": "overall", "b": [0.3267, 0.1172, 0.3832, 0.1386]}, {"w": "level", "b": [0.3893, 0.1172, 0.4272, 0.1386]}, {"w": "of", "b": [0.4332, 0.1172, 0.45, 0.1386]}, {"w": "response", "b": [0.456, 0.1172, 0.5296, 0.1386]}, {"w": "for", "b": [0.5357, 0.1172, 0.5602, 0.1386]}, {"w": "each", "b": [0.5662, 0.1172, 0.6041, 0.1386]}, {"w": "filter.", "b": [0.6101, 0.1172, 0.6535, 0.1386]}, {"w": "The", "b": [0.6596, 0.1172, 0.6924, 0.1386]}, {"w": "next", "b": [0.6984, 0.1172, 0.7348, 0.1386]}, {"w": "layer", "b": [0.7409, 0.1172, 0.781, 0.1386]}, {"w": "is", "b": [0.7871, 0.1172, 0.8003, 0.1386]}, {"w": "where", "b": [0.8063, 0.1172, 0.8571, 0.1386]}, {"w": "the", "b": [0.1429, 0.1362, 0.1692, 0.1576]}, {"w": "“squeeze”", "b": [0.1755, 0.1362, 0.2544, 0.1576]}, {"w": "happens:", "b": [0.2606, 0.1362, 0.335, 0.1576]}, {"w": "this", "b": [0.3412, 0.1362, 0.3719, 0.1576]}, {"w": "layer", "b": [0.3782, 0.1362, 0.4184, 0.1576]}, {"w": "has", "b": [0.4246, 0.1362, 0.4525, 0.1576]}, {"w": "much", "b": [0.4588, 0.1362, 0.5065, 0.1576]}, {"w": "less", "b": [0.5127, 0.1362, 0.5421, 0.1576]}, {"w": "than", "b": [0.5484, 0.1362, 0.5864, 0.1576]}, {"w": "256", "b": [0.5927, 0.1362, 0.6227, 0.1576]}, {"w": "neurons,", "b": [0.6289, 0.1362, 0.7024, 0.1576]}, {"w": "typically", "b": [0.7087, 0.1362, 0.7791, 0.1576]}, {"w": "16", "b": [0.7854, 0.1362, 0.8054, 0.1576]}, {"w": "times", "b": [0.8117, 0.1362, 0.8572, 0.1576]}, {"w": "less", "b": [0.1429, 0.1553, 0.1723, 0.1767]}, {"w": "than", "b": [0.1774, 0.1553, 0.2154, 0.1767]}, {"w": "the", "b": [0.2206, 0.1553, 0.2469, 0.1767]}, {"w": "number", "b": [0.2521, 0.1553, 0.3184, 0.1767]}, {"w": "of", "b": [0.3235, 0.1553, 0.3403, 0.1767]}, {"w": "feature", "b": [0.3454, 0.1553, 0.4032, 0.1767]}, {"w": "maps", "b": [0.4083, 0.1553, 0.4527, 0.1767]}, {"w": "(e.g.,", "b": [0.4579, 0.1553, 0.4979, 0.1767]}, {"w": "16", "b": [0.5031, 0.1553, 0.5231, 0.1767]}, {"w": "neurons),", "b": [0.5282, 0.1553, 0.6089, 0.1767]}, {"w": "so", "b": [0.614, 0.1553, 0.6323, 0.1767]}, {"w": "the", "b": [0.6374, 0.1553, 0.6638, 0.1767]}, {"w": "256", "b": [0.6689, 0.1553, 0.6989, 0.1767]}, {"w": "numbers", "b": [0.704, 0.1553, 0.778, 0.1767]}, {"w": "get", "b": [0.7831, 0.1553, 0.8081, 0.1767]}, {"w": "com‐", "b": [0.8132, 0.1553, 0.8571, 0.1767]}, {"w": "pressed", "b": [0.1429, 0.1743, 0.2055, 0.1957]}, {"w": "into", "b": [0.2125, 0.1743, 0.2461, 0.1957]}, {"w": "a", "b": [0.2531, 0.1743, 0.2622, 0.1957]}, {"w": "small", "b": [0.2693, 0.1743, 0.3136, 0.1957]}, {"w": "vector", "b": [0.3207, 0.1743, 0.3727, 0.1957]}, {"w": "(e.g.,", "b": [0.3797, 0.1743, 0.4198, 0.1957]}, {"w": "16", "b": [0.4268, 0.1743, 0.4468, 0.1957]}, {"w": "dimensional).", "b": [0.4538, 0.1743, 0.5693, 0.1957]}, {"w": "This", "b": [0.5763, 0.1743, 0.6135, 0.1957]}, {"w": "is", "b": [0.6206, 0.1743, 0.6338, 0.1957]}, {"w": "a", "b": [0.6408, 0.1743, 0.6499, 0.1957]}, {"w": "low-dimensional", "b": [0.657, 0.1743, 0.7981, 0.1957]}, {"w": "vector", "b": [0.8051, 0.1743, 0.8571, 0.1957]}, {"w": "representation", "b": [0.1428, 0.1933, 0.2635, 0.2148]}, {"w": "(i.e.,", "b": [0.269, 0.1933, 0.3049, 0.2148]}, {"w": "an", "b": [0.3104, 0.1933, 0.3309, 0.2148]}, {"w": "embedding)", "b": [0.3364, 0.1933, 0.4377, 0.2148]}, {"w": "of", "b": [0.4432, 0.1933, 0.46, 0.2148]}, {"w": "the", "b": [0.4655, 0.1933, 0.4918, 0.2148]}, {"w": "distribution", "b": [0.4973, 0.1933, 0.5968, 0.2148]}, {"w": "of", "b": [0.6023, 0.1933, 0.6191, 0.2148]}, {"w": "feature", "b": [0.6246, 0.1933, 0.6824, 0.2148]}, {"w": "responses.", "b": [0.6879, 0.1933, 0.774, 0.2148]}, {"w": "This", "b": [0.7794, 0.1933, 0.8167, 0.2148]}, {"w": "bot‐", "b": [0.8222, 0.1933, 0.8571, 0.2148]}, {"w": "tleneck", "b": [0.1429, 0.2124, 0.2027, 0.2338]}, {"w": "step", "b": [0.2085, 0.2124, 0.2423, 0.2338]}, {"w": "forces", "b": [0.248, 0.2124, 0.2978, 0.2338]}, {"w": "the", "b": [0.3036, 0.2124, 0.3299, 0.2338]}, {"w": "SE", "b": [0.3357, 0.2124, 0.3574, 0.2338]}, {"w": "Block", "b": [0.3631, 0.2124, 0.4104, 0.2338]}, {"w": "to", "b": [0.4162, 0.2124, 0.4332, 0.2338]}, {"w": "learn", "b": [0.4389, 0.2124, 0.4813, 0.2338]}, {"w": "a", "b": [0.487, 0.2124, 0.4962, 0.2338]}, {"w": "general", "b": [0.5019, 0.2124, 0.5629, 0.2338]}, {"w": "representation", "b": [0.5687, 0.2124, 0.6893, 0.2338]}, {"w": "of", "b": [0.6951, 0.2124, 0.7119, 0.2338]}, {"w": "the", "b": [0.7176, 0.2124, 0.744, 0.2338]}, {"w": "feature", "b": [0.7497, 0.2124, 0.8075, 0.2338]}, {"w": "com‐", "b": [0.8132, 0.2124, 0.8571, 0.2338]}, {"w": "binations", "b": [0.1429, 0.2314, 0.2208, 0.2529]}, {"w": "(we", "b": [0.2283, 0.2314, 0.2587, 0.2529]}, {"w": "will", "b": [0.2662, 0.2314, 0.2966, 0.2529]}, {"w": "see", "b": [0.3042, 0.2314, 0.3295, 0.2529]}, {"w": "this", "b": [0.3371, 0.2314, 0.3678, 0.2529]}, {"w": "principle", "b": [0.3754, 0.2314, 0.4504, 0.2529]}, {"w": "in", "b": [0.458, 0.2314, 0.475, 0.2529]}, {"w": "action", "b": [0.4825, 0.2314, 0.5344, 0.2529]}, {"w": "again", "b": [0.542, 0.2314, 0.587, 0.2529]}, {"w": "when", "b": [0.5946, 0.2314, 0.6402, 0.2529]}, {"w": "we", "b": [0.6478, 0.2314, 0.6709, 0.2529]}, {"w": "discuss", "b": [0.6785, 0.2314, 0.7379, 0.2529]}, {"w": "autoencoders", "b": [0.7454, 0.2314, 0.8571, 0.2529]}, {"w": "in", "b": [0.1429, 0.2505, 0.1598, 0.2719]}, {"w": "???).", "b": [0.1652, 0.2505, 0.2009, 0.2719]}, {"w": "Finally,", "b": [0.2062, 0.2505, 0.2667, 0.2719]}, {"w": "the", "b": [0.2721, 0.2505, 0.2984, 0.2719]}, {"w": "output", "b": [0.3037, 0.2505, 0.3601, 0.2719]}, {"w": "layer", "b": [0.3655, 0.2505, 0.4057, 0.2719]}, {"w": "takes", "b": [0.411, 0.2505, 0.4534, 0.2719]}, {"w": "the", "b": [0.4587, 0.2505, 0.4851, 0.2719]}, {"w": "embedding", "b": [0.4904, 0.2505, 0.5845, 0.2719]}, {"w": "and", "b": [0.5899, 0.2505, 0.6214, 0.2719]}, {"w": "outputs", "b": [0.6268, 0.2505, 0.6908, 0.2719]}, {"w": "a", "b": [0.6961, 0.2505, 0.7053, 0.2719]}, {"w": "recalibration", "b": [0.7106, 0.2505, 0.8171, 0.2719]}, {"w": "vec‐", "b": [0.8224, 0.2505, 0.8572, 0.2719]}, {"w": "tor", "b": [0.1429, 0.2695, 0.1676, 0.291]}, {"w": "containing", "b": [0.1749, 0.2695, 0.2645, 0.291]}, {"w": "one", "b": [0.2719, 0.2695, 0.3027, 0.291]}, {"w": "number", "b": [0.3101, 0.2695, 0.3763, 0.291]}, {"w": "per", "b": [0.3837, 0.2695, 0.4112, 0.291]}, {"w": "feature", "b": [0.4185, 0.2695, 0.4763, 0.291]}, {"w": "map", "b": [0.4836, 0.2695, 0.5203, 0.291]}, {"w": "(e.g.,", "b": [0.5276, 0.2695, 0.5677, 0.291]}, {"w": "256),", "b": [0.575, 0.2695, 0.617, 0.291]}, {"w": "each", "b": [0.6243, 0.2695, 0.6622, 0.291]}, {"w": "between", "b": [0.6696, 0.2695, 0.7387, 0.291]}, {"w": "0", "b": [0.7461, 0.2695, 0.7561, 0.291]}, {"w": "and", "b": [0.7634, 0.2695, 0.7949, 0.291]}, {"w": "1.", "b": [0.8022, 0.2695, 0.817, 0.291]}, {"w": "The", "b": [0.8243, 0.2695, 0.8571, 0.291]}, {"w": "feature", "b": [0.1429, 0.2886, 0.2006, 0.31]}, {"w": "maps", "b": [0.2084, 0.2886, 0.2528, 0.31]}, {"w": "are", "b": [0.2606, 0.2886, 0.2863, 0.31]}, {"w": "then", "b": [0.2941, 0.2886, 0.3318, 0.31]}, {"w": "multiplied", "b": [0.3396, 0.2886, 0.4261, 0.31]}, {"w": "by", "b": [0.4339, 0.2886, 0.454, 0.31]}, {"w": "this", "b": [0.4618, 0.2886, 0.4925, 0.31]}, {"w": "recalibration", "b": [0.5003, 0.2886, 0.6067, 0.31]}, {"w": "vector,", "b": [0.6145, 0.2886, 0.67, 0.31]}, {"w": "so", "b": [0.6777, 0.2886, 0.696, 0.31]}, {"w": "irrelevant", "b": [0.7038, 0.2886, 0.7839, 0.31]}, {"w": "features", "b": [0.7917, 0.2886, 0.8571, 0.31]}, {"w": "(with", "b": [0.1428, 0.3076, 0.1874, 0.329]}, {"w": "a", "b": [0.1925, 0.3076, 0.2016, 0.329]}, {"w": "low", "b": [0.2067, 0.3076, 0.2369, 0.329]}, {"w": "recalibration", "b": [0.242, 0.3076, 0.3484, 0.329]}, {"w": "score)", "b": [0.3535, 0.3076, 0.4044, 0.329]}, {"w": "get", "b": [0.4095, 0.3076, 0.4344, 0.329]}, {"w": "scaled", "b": [0.4395, 0.3076, 0.4903, 0.329]}, {"w": "down", "b": [0.4954, 0.3076, 0.5427, 0.329]}, {"w": "while", "b": [0.5478, 0.3076, 0.5929, 0.329]}, {"w": "relevant", "b": [0.598, 0.3076, 0.6648, 0.329]}, {"w": "features", "b": [0.6699, 0.3076, 0.7353, 0.329]}, {"w": "(with", "b": [0.7404, 0.3076, 0.785, 0.329]}, {"w": "a", "b": [0.7901, 0.3076, 0.7992, 0.329]}, {"w": "recali‐", "b": [0.8043, 0.3076, 0.8571, 0.329]}, {"w": "bration", "b": [0.1429, 0.3267, 0.2039, 0.3481]}, {"w": "score", "b": [0.2086, 0.3267, 0.2523, 0.3481]}, {"w": "close", "b": [0.257, 0.3267, 0.2982, 0.3481]}, {"w": "to", "b": [0.3029, 0.3267, 0.3199, 0.3481]}, {"w": "1)", "b": [0.3247, 0.3267, 0.3419, 0.3481]}, {"w": "are", "b": [0.3466, 0.3267, 0.3723, 0.3481]}, {"w": "left", "b": [0.3771, 0.3267, 0.4037, 0.3481]}, {"w": "alone.", "b": [0.4084, 0.3267, 0.4585, 0.3481]}]}, {"id": "b_1", "type": "equation", "text": "Implementing a ResNet-34 CNN Using Keras", "words": [{"w": "Implementing", "b": [0.1429, 0.3611, 0.3208, 0.3953]}, {"w": "a", "b": [0.3267, 0.3611, 0.3416, 0.3953]}, {"w": "ResNet-34", "b": [0.3475, 0.3611, 0.4752, 0.3953]}, {"w": "CNN", "b": [0.4811, 0.3611, 0.5326, 0.3953]}, {"w": "Using", "b": [0.5385, 0.3611, 0.6081, 0.3953]}, {"w": "Keras", "b": [0.614, 0.3611, 0.6818, 0.3953]}]}, {"id": "b_2", "type": "paragraph", "text": "Most CNN architectures described so far are fairly straightforward to implement (although generally you would load a pretrained network instead, as we will see). To illustrate the process, let’s implement a ResNet-34 from scratch using Keras. First, let’s create a ResidualUnit layer:", "words": [{"w": "Most", "b": [0.1429, 0.4023, 0.1855, 0.4237]}, {"w": "CNN", "b": [0.1945, 0.4023, 0.2393, 0.4237]}, {"w": "architectures", "b": [0.2483, 0.4023, 0.3564, 0.4237]}, {"w": "described", "b": [0.3654, 0.4023, 0.4455, 0.4237]}, {"w": "so", "b": [0.4545, 0.4023, 0.4727, 0.4237]}, {"w": "far", "b": [0.4818, 0.4023, 0.5048, 0.4237]}, {"w": "are", "b": [0.5138, 0.4023, 0.5395, 0.4237]}, {"w": "fairly", "b": [0.5485, 0.4023, 0.592, 0.4237]}, {"w": "straightforward", "b": [0.601, 0.4023, 0.7316, 0.4237]}, {"w": "to", "b": [0.7406, 0.4023, 0.7576, 0.4237]}, {"w": "implement", "b": [0.7666, 0.4023, 0.8571, 0.4237]}, {"w": "(although", "b": [0.1428, 0.4213, 0.2245, 0.4427]}, {"w": "generally", "b": [0.2305, 0.4213, 0.3063, 0.4427]}, {"w": "you", "b": [0.3122, 0.4213, 0.3435, 0.4427]}, {"w": "would", "b": [0.3494, 0.4213, 0.4016, 0.4427]}, {"w": "load", "b": [0.4076, 0.4213, 0.4436, 0.4427]}, {"w": "a", "b": [0.4496, 0.4213, 0.4587, 0.4427]}, {"w": "pretrained", "b": [0.4646, 0.4213, 0.5522, 0.4427]}, {"w": "network", "b": [0.5581, 0.4213, 0.6277, 0.4427]}, {"w": "instead,", "b": [0.6336, 0.4213, 0.6984, 0.4427]}, {"w": "as", "b": [0.7043, 0.4213, 0.7211, 0.4427]}, {"w": "we", "b": [0.727, 0.4213, 0.7502, 0.4427]}, {"w": "will", "b": [0.7561, 0.4213, 0.7865, 0.4427]}, {"w": "see).", "b": [0.7924, 0.4213, 0.8298, 0.4427]}, {"w": "To", "b": [0.8357, 0.4213, 0.8571, 0.4427]}, {"w": "illustrate", "b": [0.1429, 0.4404, 0.2157, 0.4618]}, {"w": "the", "b": [0.2207, 0.4404, 0.2471, 0.4618]}, {"w": "process,", "b": [0.2521, 0.4404, 0.319, 0.4618]}, {"w": "let’s", "b": [0.324, 0.4404, 0.3543, 0.4618]}, {"w": "implement", "b": [0.3593, 0.4404, 0.4498, 0.4618]}, {"w": "a", "b": [0.4548, 0.4404, 0.464, 0.4618]}, {"w": "ResNet-34", "b": [0.469, 0.4404, 0.556, 0.4618]}, {"w": "from", "b": [0.561, 0.4404, 0.6026, 0.4618]}, {"w": "scratch", "b": [0.6075, 0.4404, 0.6668, 0.4618]}, {"w": "using", "b": [0.6718, 0.4404, 0.7172, 0.4618]}, {"w": "Keras.", "b": [0.7222, 0.4404, 0.7738, 0.4618]}, {"w": "First,", "b": [0.7788, 0.4404, 0.8219, 0.4618]}, {"w": "let’s", "b": [0.8269, 0.4404, 0.8571, 0.4618]}, {"w": "create", "b": [0.1429, 0.4603, 0.1922, 0.4817]}, {"w": "a", "b": [0.1969, 0.4603, 0.2061, 0.4817]}, {"w": "ResidualUnit", "b": [0.2108, 0.4635, 0.3296, 0.4786]}, {"w": "layer:", "b": [0.3343, 0.4603, 0.3797, 0.4817]}]}, {"id": "b_3", "type": "paragraph", "text": "DefaultConv2D = partial(keras.layers.Conv2D, kernel_size=3, strides=1, padding=\"SAME\", use_bias=False)", "words": [{"w": "DefaultConv2D", "b": [0.1766, 0.4923, 0.2862, 0.5051]}, {"w": "=", "b": [0.2946, 0.4923, 0.3031, 0.5051]}, {"w": "partial(keras.layers.Conv2D,", "b": [0.3115, 0.4923, 0.5476, 0.5051]}, {"w": "kernel_size=3,", "b": [0.5561, 0.4923, 0.6741, 0.5051]}, {"w": "strides=1,", "b": [0.6825, 0.4923, 0.7669, 0.5051]}, {"w": "padding=\"SAME\",", "b": [0.379, 0.5077, 0.5055, 0.5205]}, {"w": "use_bias=False)", "b": [0.5139, 0.5077, 0.6404, 0.5205]}]}, {"id": "b_4", "type": "paragraph", "text": "class ResidualUnit(keras.layers.Layer): def __init__(self, filters, strides=1, activation=\"relu\", **kwargs): super().__init__(**kwargs) self.activation = keras.activations.get(activation) self.main_layers = [ DefaultConv2D(filters, strides=strides), keras.layers.BatchNormalization(), self.activation, DefaultConv2D(filters), keras.layers.BatchNormalization()] self.skip_layers = [] if strides > 1: self.skip_layers = [ DefaultConv2D(filters, kernel_size=1, strides=strides), keras.layers.BatchNormalization()]", "words": [{"w": "class", "b": [0.1766, 0.5385, 0.2188, 0.5514]}, {"w": "ResidualUnit(keras.layers.Layer):", "b": [0.2272, 0.5385, 0.5055, 0.5514]}, {"w": "def", "b": [0.2103, 0.554, 0.2356, 0.5668]}, {"w": "__init__(self,", "b": [0.2441, 0.554, 0.3621, 0.5668]}, {"w": "filters,", "b": [0.3705, 0.554, 0.438, 0.5668]}, {"w": "strides=1,", "b": [0.4464, 0.554, 0.5308, 0.5668]}, {"w": "activation=\"relu\",", "b": [0.5392, 0.554, 0.691, 0.5668]}, {"w": "**kwargs):", "b": [0.6994, 0.554, 0.7837, 0.5668]}, {"w": "super().__init__(**kwargs)", "b": [0.2441, 0.5694, 0.4633, 0.5822]}, {"w": "self.activation", "b": [0.2441, 0.5848, 0.3705, 0.5976]}, {"w": "=", "b": [0.379, 0.5848, 0.3874, 0.5976]}, {"w": "keras.activations.get(activation)", "b": [0.3958, 0.5848, 0.6741, 0.5976]}, {"w": "self.main_layers", "b": [0.2441, 0.6002, 0.379, 0.6131]}, {"w": "=", "b": [0.3874, 0.6002, 0.3958, 0.6131]}, {"w": "[", "b": [0.4043, 0.6002, 0.4127, 0.6131]}, {"w": "DefaultConv2D(filters,", "b": [0.2778, 0.6156, 0.4633, 0.6285]}, {"w": "strides=strides),", "b": [0.4717, 0.6156, 0.6151, 0.6285]}, {"w": "keras.layers.BatchNormalization(),", "b": [0.2778, 0.6311, 0.5645, 0.6439]}, {"w": "self.activation,", "b": [0.2778, 0.6465, 0.4127, 0.6593]}, {"w": "DefaultConv2D(filters),", "b": [0.2778, 0.6619, 0.4717, 0.6747]}, {"w": "keras.layers.BatchNormalization()]", "b": [0.2778, 0.6773, 0.5645, 0.6902]}, {"w": "self.skip_layers", "b": [0.2441, 0.6927, 0.379, 0.7056]}, {"w": "=", "b": [0.3874, 0.6927, 0.3958, 0.7056]}, {"w": "[]", "b": [0.4043, 0.6927, 0.4211, 0.7056]}, {"w": "if", "b": [0.2441, 0.7082, 0.2609, 0.721]}, {"w": "strides", "b": [0.2693, 0.7082, 0.3284, 0.721]}, {"w": ">", "b": [0.3368, 0.7082, 0.3452, 0.721]}, {"w": "1:", "b": [0.3537, 0.7082, 0.3705, 0.721]}, {"w": "self.skip_layers", "b": [0.2778, 0.7236, 0.4127, 0.7364]}, {"w": "=", "b": [0.4211, 0.7236, 0.4296, 0.7364]}, {"w": "[", "b": [0.438, 0.7236, 0.4464, 0.7364]}, {"w": "DefaultConv2D(filters,", "b": [0.3115, 0.739, 0.497, 0.7518]}, {"w": "kernel_size=1,", "b": [0.5055, 0.739, 0.6235, 0.7518]}, {"w": "strides=strides),", "b": [0.6319, 0.739, 0.7753, 0.7518]}, {"w": "keras.layers.BatchNormalization()]", "b": [0.3115, 0.7544, 0.5982, 0.7673]}]}, {"id": "b_5", "type": "paragraph", "text": "def call(self, inputs): Z = inputs for layer in self.main_layers: Z = layer(Z) skip_Z = inputs for layer in self.skip_layers:", "words": [{"w": "def", "b": [0.2103, 0.7853, 0.2356, 0.7981]}, {"w": "call(self,", "b": [0.2441, 0.7853, 0.3284, 0.7981]}, {"w": "inputs):", "b": [0.3368, 0.7853, 0.4043, 0.7981]}, {"w": "Z", "b": [0.2441, 0.8007, 0.2525, 0.8135]}, {"w": "=", "b": [0.2609, 0.8007, 0.2693, 0.8135]}, {"w": "inputs", "b": [0.2778, 0.8007, 0.3284, 0.8135]}, {"w": "for", "b": [0.2441, 0.8161, 0.2693, 0.8289]}, {"w": "layer", "b": [0.2778, 0.8161, 0.3199, 0.8289]}, {"w": "in", "b": [0.3284, 0.8161, 0.3452, 0.8289]}, {"w": "self.main_layers:", "b": [0.3537, 0.8161, 0.497, 0.8289]}, {"w": "Z", "b": [0.2778, 0.8315, 0.2862, 0.8444]}, {"w": "=", "b": [0.2946, 0.8315, 0.3031, 0.8444]}, {"w": "layer(Z)", "b": [0.3115, 0.8315, 0.379, 0.8444]}, {"w": "skip_Z", "b": [0.2441, 0.8469, 0.2946, 0.8598]}, {"w": "=", "b": [0.3031, 0.8469, 0.3115, 0.8598]}, {"w": "inputs", "b": [0.3199, 0.8469, 0.3705, 0.8598]}, {"w": "for", "b": [0.2441, 0.8623, 0.2693, 0.8752]}, {"w": "layer", "b": [0.2778, 0.8623, 0.3199, 0.8752]}, {"w": "in", "b": [0.3284, 0.8623, 0.3452, 0.8752]}, {"w": "self.skip_layers:", "b": [0.3537, 0.8623, 0.497, 0.8752]}]}, {"id": "b_6", "type": "paragraph", "text": "464 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "464", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3683, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 491, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "skip_Z = layer(skip_Z) return self.activation(Z + skip_Z)", "words": [{"w": "skip_Z", "b": [0.2778, 0.0829, 0.3284, 0.0958]}, {"w": "=", "b": [0.3368, 0.0829, 0.3452, 0.0958]}, {"w": "layer(skip_Z)", "b": [0.3537, 0.0829, 0.4633, 0.0958]}, {"w": "return", "b": [0.244, 0.0983, 0.2946, 0.1112]}, {"w": "self.activation(Z", "b": [0.3031, 0.0983, 0.4464, 0.1112]}, {"w": "+", "b": [0.4549, 0.0983, 0.4633, 0.1112]}, {"w": "skip_Z)", "b": [0.4717, 0.0983, 0.5308, 0.1112]}]}, {"id": "b_1", "type": "paragraph", "text": "As you can see, this code matches Figure 14-18 pretty closely. In the constructor, we create all the layers we will need: the main layers are the ones on the right side of the diagram, and the skip layers are the ones on the left (only needed if the stride is greater than 1). Then in the call() method, we simply make the inputs go through the main layers, and the skip layers (if any), then we add both outputs and we apply the activation function.", "words": [{"w": "As", "b": [0.1429, 0.119, 0.1649, 0.1404]}, {"w": "you", "b": [0.1709, 0.119, 0.2021, 0.1404]}, {"w": "can", "b": [0.2081, 0.119, 0.2375, 0.1404]}, {"w": "see,", "b": [0.2435, 0.119, 0.2736, 0.1404]}, {"w": "this", "b": [0.2796, 0.119, 0.3103, 0.1404]}, {"w": "code", "b": [0.3163, 0.119, 0.3556, 0.1404]}, {"w": "matches", "b": [0.3616, 0.119, 0.4302, 0.1404]}, {"w": "Figure", "b": [0.4362, 0.119, 0.4902, 0.1404]}, {"w": "14-18", "b": [0.4962, 0.119, 0.5436, 0.1404]}, {"w": "pretty", "b": [0.5496, 0.119, 0.5994, 0.1404]}, {"w": "closely.", "b": [0.6054, 0.119, 0.6646, 0.1404]}, {"w": "In", "b": [0.6706, 0.119, 0.6891, 0.1404]}, {"w": "the", "b": [0.6951, 0.119, 0.7214, 0.1404]}, {"w": "constructor,", "b": [0.7274, 0.119, 0.828, 0.1404]}, {"w": "we", "b": [0.834, 0.119, 0.8571, 0.1404]}, {"w": "create", "b": [0.1429, 0.138, 0.1922, 0.1594]}, {"w": "all", "b": [0.1978, 0.138, 0.2175, 0.1594]}, {"w": "the", "b": [0.223, 0.138, 0.2493, 0.1594]}, {"w": "layers", "b": [0.2549, 0.138, 0.3027, 0.1594]}, {"w": "we", "b": [0.3083, 0.138, 0.3314, 0.1594]}, {"w": "will", "b": [0.337, 0.138, 0.3674, 0.1594]}, {"w": "need:", "b": [0.3729, 0.138, 0.4178, 0.1594]}, {"w": "the", "b": [0.4233, 0.138, 0.4497, 0.1594]}, {"w": "main", "b": [0.4552, 0.138, 0.4984, 0.1594]}, {"w": "layers", "b": [0.504, 0.138, 0.5518, 0.1594]}, {"w": "are", "b": [0.5574, 0.138, 0.5831, 0.1594]}, {"w": "the", "b": [0.5887, 0.138, 0.615, 0.1594]}, {"w": "ones", "b": [0.6206, 0.138, 0.6591, 0.1594]}, {"w": "on", "b": [0.6646, 0.138, 0.6867, 0.1594]}, {"w": "the", "b": [0.6922, 0.138, 0.7185, 0.1594]}, {"w": "right", "b": [0.7241, 0.138, 0.7643, 0.1594]}, {"w": "side", "b": [0.7698, 0.138, 0.8029, 0.1594]}, {"w": "of", "b": [0.8085, 0.138, 0.8252, 0.1594]}, {"w": "the", "b": [0.8308, 0.138, 0.8571, 0.1594]}, {"w": "diagram,", "b": [0.1429, 0.1571, 0.217, 0.1785]}, {"w": "and", "b": [0.2253, 0.1571, 0.2568, 0.1785]}, {"w": "the", "b": [0.2651, 0.1571, 0.2914, 0.1785]}, {"w": "skip", "b": [0.2996, 0.1571, 0.3341, 0.1785]}, {"w": "layers", "b": [0.3423, 0.1571, 0.3902, 0.1785]}, {"w": "are", "b": [0.3984, 0.1571, 0.4242, 0.1785]}, {"w": "the", "b": [0.4324, 0.1571, 0.4587, 0.1785]}, {"w": "ones", "b": [0.467, 0.1571, 0.5055, 0.1785]}, {"w": "on", "b": [0.5137, 0.1571, 0.5357, 0.1785]}, {"w": "the", "b": [0.544, 0.1571, 0.5703, 0.1785]}, {"w": "left", "b": [0.5786, 0.1571, 0.6052, 0.1785]}, {"w": "(only", "b": [0.6135, 0.1571, 0.6575, 0.1785]}, {"w": "needed", "b": [0.6658, 0.1571, 0.7257, 0.1785]}, {"w": "if", "b": [0.734, 0.1571, 0.7457, 0.1785]}, {"w": "the", "b": [0.7539, 0.1571, 0.7803, 0.1785]}, {"w": "stride", "b": [0.7885, 0.1571, 0.8357, 0.1785]}, {"w": "is", "b": [0.8439, 0.1571, 0.8572, 0.1785]}, {"w": "greater", "b": [0.1429, 0.177, 0.2009, 0.1984]}, {"w": "than", "b": [0.2072, 0.177, 0.2452, 0.1984]}, {"w": "1).", "b": [0.2515, 0.177, 0.2735, 0.1984]}, {"w": "Then", "b": [0.2798, 0.177, 0.324, 0.1984]}, {"w": "in", "b": [0.3303, 0.177, 0.3473, 0.1984]}, {"w": "the", "b": [0.3536, 0.177, 0.38, 0.1984]}, {"w": "call()", "b": [0.3863, 0.1802, 0.4457, 0.1953]}, {"w": "method,", "b": [0.452, 0.177, 0.5217, 0.1984]}, {"w": "we", "b": [0.5281, 0.177, 0.5512, 0.1984]}, {"w": "simply", "b": [0.5575, 0.177, 0.6131, 0.1984]}, {"w": "make", "b": [0.6195, 0.177, 0.6649, 0.1984]}, {"w": "the", "b": [0.6712, 0.177, 0.6975, 0.1984]}, {"w": "inputs", "b": [0.7038, 0.177, 0.7564, 0.1984]}, {"w": "go", "b": [0.7627, 0.177, 0.7831, 0.1984]}, {"w": "through", "b": [0.7894, 0.177, 0.8571, 0.1984]}, {"w": "the", "b": [0.1429, 0.1961, 0.1692, 0.2175]}, {"w": "main", "b": [0.1752, 0.1961, 0.2184, 0.2175]}, {"w": "layers,", "b": [0.2245, 0.1961, 0.277, 0.2175]}, {"w": "and", "b": [0.2831, 0.1961, 0.3146, 0.2175]}, {"w": "the", "b": [0.3207, 0.1961, 0.347, 0.2175]}, {"w": "skip", "b": [0.353, 0.1961, 0.3875, 0.2175]}, {"w": "layers", "b": [0.3936, 0.1961, 0.4414, 0.2175]}, {"w": "(if", "b": [0.4474, 0.1961, 0.4664, 0.2175]}, {"w": "any),", "b": [0.4724, 0.1961, 0.514, 0.2175]}, {"w": "then", "b": [0.5201, 0.1961, 0.5578, 0.2175]}, {"w": "we", "b": [0.5638, 0.1961, 0.587, 0.2175]}, {"w": "add", "b": [0.593, 0.1961, 0.6241, 0.2175]}, {"w": "both", "b": [0.6302, 0.1961, 0.6689, 0.2175]}, {"w": "outputs", "b": [0.6749, 0.1961, 0.7389, 0.2175]}, {"w": "and", "b": [0.745, 0.1961, 0.7765, 0.2175]}, {"w": "we", "b": [0.7826, 0.1961, 0.8057, 0.2175]}, {"w": "apply", "b": [0.8117, 0.1961, 0.8571, 0.2175]}, {"w": "the", "b": [0.1428, 0.2151, 0.1692, 0.2365]}, {"w": "activation", "b": [0.1739, 0.2151, 0.2562, 0.2365]}, {"w": "function.", "b": [0.2609, 0.2151, 0.337, 0.2365]}]}, {"id": "b_2", "type": "paragraph", "text": "Next, we can build the ResNet-34 simply using a Sequential model, since it is really just a long sequence of layers (we can treat each residual unit as a single layer now that we have the ResidualUnit class):", "words": [{"w": "Next,", "b": [0.1428, 0.2441, 0.1876, 0.2655]}, {"w": "we", "b": [0.1933, 0.2441, 0.2164, 0.2655]}, {"w": "can", "b": [0.2222, 0.2441, 0.2515, 0.2655]}, {"w": "build", "b": [0.2573, 0.2441, 0.3008, 0.2655]}, {"w": "the", "b": [0.3065, 0.2441, 0.3328, 0.2655]}, {"w": "ResNet-34", "b": [0.3385, 0.2441, 0.4256, 0.2655]}, {"w": "simply", "b": [0.4313, 0.2441, 0.4869, 0.2655]}, {"w": "using", "b": [0.4927, 0.2441, 0.5381, 0.2655]}, {"w": "a", "b": [0.5438, 0.2441, 0.553, 0.2655]}, {"w": "Sequential", "b": [0.5587, 0.2473, 0.6577, 0.2624]}, {"w": "model,", "b": [0.6634, 0.2441, 0.7209, 0.2655]}, {"w": "since", "b": [0.7267, 0.2441, 0.769, 0.2655]}, {"w": "it", "b": [0.7747, 0.2441, 0.7866, 0.2655]}, {"w": "is", "b": [0.7923, 0.2441, 0.8056, 0.2655]}, {"w": "really", "b": [0.8113, 0.2441, 0.8571, 0.2655]}, {"w": "just", "b": [0.1429, 0.2632, 0.1733, 0.2846]}, {"w": "a", "b": [0.1801, 0.2632, 0.1893, 0.2846]}, {"w": "long", "b": [0.1961, 0.2632, 0.2332, 0.2846]}, {"w": "sequence", "b": [0.24, 0.2632, 0.3161, 0.2846]}, {"w": "of", "b": [0.323, 0.2632, 0.3398, 0.2846]}, {"w": "layers", "b": [0.3466, 0.2632, 0.3945, 0.2846]}, {"w": "(we", "b": [0.4013, 0.2632, 0.4317, 0.2846]}, {"w": "can", "b": [0.4385, 0.2632, 0.4679, 0.2846]}, {"w": "treat", "b": [0.4747, 0.2632, 0.5128, 0.2846]}, {"w": "each", "b": [0.5196, 0.2632, 0.5576, 0.2846]}, {"w": "residual", "b": [0.5644, 0.2632, 0.6307, 0.2846]}, {"w": "unit", "b": [0.6376, 0.2632, 0.672, 0.2846]}, {"w": "as", "b": [0.6788, 0.2632, 0.6956, 0.2846]}, {"w": "a", "b": [0.7025, 0.2632, 0.7116, 0.2846]}, {"w": "single", "b": [0.7185, 0.2632, 0.767, 0.2846]}, {"w": "layer", "b": [0.7738, 0.2632, 0.814, 0.2846]}, {"w": "now", "b": [0.8209, 0.2632, 0.8572, 0.2846]}, {"w": "that", "b": [0.1429, 0.2831, 0.1754, 0.3045]}, {"w": "we", "b": [0.1802, 0.2831, 0.2033, 0.3045]}, {"w": "have", "b": [0.208, 0.2831, 0.2464, 0.3045]}, {"w": "the", "b": [0.2512, 0.2831, 0.2775, 0.3045]}, {"w": "ResidualUnit", "b": [0.2822, 0.2863, 0.401, 0.3014]}, {"w": "class):", "b": [0.4057, 0.2831, 0.4562, 0.3045]}]}, {"id": "b_3", "type": "paragraph", "text": "model = keras.models.Sequential() model.add(DefaultConv2D(64, kernel_size=7, strides=2, input_shape=[224, 224, 3])) model.add(keras.layers.BatchNormalization()) model.add(keras.layers.Activation(\"relu\")) model.add(keras.layers.MaxPool2D(pool_size=3, strides=2, padding=\"SAME\")) prev_filters = 64 for filters in [64] * 3 + [128] * 4 + [256] * 6 + [512] * 3: strides = 1 if filters == prev_filters else 2 model.add(ResidualUnit(filters, strides=strides)) prev_filters = filters model.add(keras.layers.GlobalAvgPool2D()) model.add(keras.layers.Flatten()) model.add(keras.layers.Dense(10, activation=\"softmax\"))", "words": [{"w": "model", "b": [0.1766, 0.3151, 0.2187, 0.3279]}, {"w": "=", "b": [0.2272, 0.3151, 0.2356, 0.3279]}, {"w": "keras.models.Sequential()", "b": [0.244, 0.3151, 0.4549, 0.3279]}, {"w": "model.add(DefaultConv2D(64,", "b": [0.1766, 0.3305, 0.4043, 0.3434]}, {"w": "kernel_size=7,", "b": [0.4127, 0.3305, 0.5307, 0.3434]}, {"w": "strides=2,", "b": [0.5392, 0.3305, 0.6235, 0.3434]}, {"w": "input_shape=[224,", "b": [0.379, 0.3459, 0.5223, 0.3588]}, {"w": "224,", "b": [0.5307, 0.3459, 0.5645, 0.3588]}, {"w": "3]))", "b": [0.5729, 0.3459, 0.6066, 0.3588]}, {"w": "model.add(keras.layers.BatchNormalization())", "b": [0.1766, 0.3613, 0.5476, 0.3742]}, {"w": "model.add(keras.layers.Activation(\"relu\"))", "b": [0.1766, 0.3768, 0.5307, 0.3896]}, {"w": "model.add(keras.layers.MaxPool2D(pool_size=3,", "b": [0.1766, 0.3922, 0.556, 0.405]}, {"w": "strides=2,", "b": [0.5645, 0.3922, 0.6488, 0.405]}, {"w": "padding=\"SAME\"))", "b": [0.6572, 0.3922, 0.7922, 0.405]}, {"w": "prev_filters", "b": [0.1766, 0.4076, 0.2778, 0.4205]}, {"w": "=", "b": [0.2862, 0.4076, 0.2946, 0.4205]}, {"w": "64", "b": [0.3031, 0.4076, 0.3199, 0.4205]}, {"w": "for", "b": [0.1766, 0.423, 0.2019, 0.4359]}, {"w": "filters", "b": [0.2103, 0.423, 0.2693, 0.4359]}, {"w": "in", "b": [0.2778, 0.423, 0.2946, 0.4359]}, {"w": "[64]", "b": [0.3031, 0.423, 0.3368, 0.4359]}, {"w": "*", "b": [0.3452, 0.423, 0.3537, 0.4359]}, {"w": "3", "b": [0.3621, 0.423, 0.3705, 0.4359]}, {"w": "+", "b": [0.379, 0.423, 0.3874, 0.4359]}, {"w": "[128]", "b": [0.3958, 0.423, 0.438, 0.4359]}, {"w": "*", "b": [0.4464, 0.423, 0.4549, 0.4359]}, {"w": "4", "b": [0.4633, 0.423, 0.4717, 0.4359]}, {"w": "+", "b": [0.4802, 0.423, 0.4886, 0.4359]}, {"w": "[256]", "b": [0.497, 0.423, 0.5392, 0.4359]}, {"w": "*", "b": [0.5476, 0.423, 0.556, 0.4359]}, {"w": "6", "b": [0.5645, 0.423, 0.5729, 0.4359]}, {"w": "+", "b": [0.5813, 0.423, 0.5898, 0.4359]}, {"w": "[512]", "b": [0.5982, 0.423, 0.6404, 0.4359]}, {"w": "*", "b": [0.6488, 0.423, 0.6572, 0.4359]}, {"w": "3:", "b": [0.6657, 0.423, 0.6825, 0.4359]}, {"w": "strides", "b": [0.2103, 0.4384, 0.2693, 0.4513]}, {"w": "=", "b": [0.2778, 0.4384, 0.2862, 0.4513]}, {"w": "1", "b": [0.2946, 0.4384, 0.3031, 0.4513]}, {"w": "if", "b": [0.3115, 0.4384, 0.3284, 0.4513]}, {"w": "filters", "b": [0.3368, 0.4384, 0.3958, 0.4513]}, {"w": "==", "b": [0.4043, 0.4384, 0.4211, 0.4513]}, {"w": "prev_filters", "b": [0.4296, 0.4384, 0.5307, 0.4513]}, {"w": "else", "b": [0.5392, 0.4384, 0.5729, 0.4513]}, {"w": "2", "b": [0.5813, 0.4384, 0.5898, 0.4513]}, {"w": "model.add(ResidualUnit(filters,", "b": [0.2103, 0.4539, 0.4717, 0.4667]}, {"w": "strides=strides))", "b": [0.4802, 0.4539, 0.6235, 0.4667]}, {"w": "prev_filters", "b": [0.2103, 0.4693, 0.3115, 0.4821]}, {"w": "=", "b": [0.3199, 0.4693, 0.3284, 0.4821]}, {"w": "filters", "b": [0.3368, 0.4693, 0.3958, 0.4821]}, {"w": "model.add(keras.layers.GlobalAvgPool2D())", "b": [0.1766, 0.4847, 0.5223, 0.4976]}, {"w": "model.add(keras.layers.Flatten())", "b": [0.1766, 0.5001, 0.4549, 0.513]}, {"w": "model.add(keras.layers.Dense(10,", "b": [0.1766, 0.5155, 0.4464, 0.5284]}, {"w": "activation=\"softmax\"))", "b": [0.4549, 0.5155, 0.6404, 0.5284]}]}, {"id": "b_4", "type": "paragraph", "text": "The only slightly tricky part in this code is the loop that adds the ResidualUnit layers to the model: as explained earlier, the first 3 RUs have 64 filters, then the next 4 RUs have 128 filters, and so on. We then set the strides to 1 when the number of filters is the same as in the previous RU, or else we set it to 2. Then we add the ResidualUnit, and finally we update prev_filters.", "words": [{"w": "The", "b": [0.1429, 0.5371, 0.1757, 0.5585]}, {"w": "only", "b": [0.1806, 0.5371, 0.2174, 0.5585]}, {"w": "slightly", "b": [0.2224, 0.5371, 0.2825, 0.5585]}, {"w": "tricky", "b": [0.2874, 0.5371, 0.3358, 0.5585]}, {"w": "part", "b": [0.3407, 0.5371, 0.3749, 0.5585]}, {"w": "in", "b": [0.3798, 0.5371, 0.3968, 0.5585]}, {"w": "this", "b": [0.4017, 0.5371, 0.4324, 0.5585]}, {"w": "code", "b": [0.4373, 0.5371, 0.4766, 0.5585]}, {"w": "is", "b": [0.4815, 0.5371, 0.4947, 0.5585]}, {"w": "the", "b": [0.4996, 0.5371, 0.526, 0.5585]}, {"w": "loop", "b": [0.5309, 0.5371, 0.5683, 0.5585]}, {"w": "that", "b": [0.5732, 0.5371, 0.6058, 0.5585]}, {"w": "adds", "b": [0.6107, 0.5371, 0.6495, 0.5585]}, {"w": "the", "b": [0.6544, 0.5371, 0.6807, 0.5585]}, {"w": "ResidualUnit", "b": [0.6856, 0.5403, 0.8044, 0.5553]}, {"w": "layers", "b": [0.8093, 0.5371, 0.8571, 0.5585]}, {"w": "to", "b": [0.1429, 0.5561, 0.1598, 0.5775]}, {"w": "the", "b": [0.1657, 0.5561, 0.192, 0.5775]}, {"w": "model:", "b": [0.1979, 0.5561, 0.2555, 0.5775]}, {"w": "as", "b": [0.2614, 0.5561, 0.2782, 0.5775]}, {"w": "explained", "b": [0.2841, 0.5561, 0.3649, 0.5775]}, {"w": "earlier,", "b": [0.3708, 0.5561, 0.4274, 0.5775]}, {"w": "the", "b": [0.4333, 0.5561, 0.4596, 0.5775]}, {"w": "first", "b": [0.4655, 0.5561, 0.499, 0.5775]}, {"w": "3", "b": [0.5049, 0.5561, 0.5149, 0.5775]}, {"w": "RUs", "b": [0.5207, 0.5561, 0.5548, 0.5775]}, {"w": "have", "b": [0.5607, 0.5561, 0.5991, 0.5775]}, {"w": "64", "b": [0.6049, 0.5561, 0.6249, 0.5775]}, {"w": "filters,", "b": [0.6308, 0.5561, 0.6832, 0.5775]}, {"w": "then", "b": [0.6891, 0.5561, 0.7268, 0.5775]}, {"w": "the", "b": [0.7327, 0.5561, 0.759, 0.5775]}, {"w": "next", "b": [0.7649, 0.5561, 0.8013, 0.5775]}, {"w": "4", "b": [0.8072, 0.5561, 0.8172, 0.5775]}, {"w": "RUs", "b": [0.8231, 0.5561, 0.8571, 0.5775]}, {"w": "have", "b": [0.1429, 0.5752, 0.1813, 0.5966]}, {"w": "128", "b": [0.1871, 0.5752, 0.2171, 0.5966]}, {"w": "filters,", "b": [0.223, 0.5752, 0.2753, 0.5966]}, {"w": "and", "b": [0.2812, 0.5752, 0.3127, 0.5966]}, {"w": "so", "b": [0.3186, 0.5752, 0.3368, 0.5966]}, {"w": "on.", "b": [0.3427, 0.5752, 0.3694, 0.5966]}, {"w": "We", "b": [0.3753, 0.5752, 0.4024, 0.5966]}, {"w": "then", "b": [0.4082, 0.5752, 0.4459, 0.5966]}, {"w": "set", "b": [0.4518, 0.5752, 0.4746, 0.5966]}, {"w": "the", "b": [0.4805, 0.5752, 0.5068, 0.5966]}, {"w": "strides", "b": [0.5127, 0.5752, 0.5675, 0.5966]}, {"w": "to", "b": [0.5733, 0.5752, 0.5903, 0.5966]}, {"w": "1", "b": [0.5962, 0.5752, 0.6062, 0.5966]}, {"w": "when", "b": [0.612, 0.5752, 0.6577, 0.5966]}, {"w": "the", "b": [0.6635, 0.5752, 0.6898, 0.5966]}, {"w": "number", "b": [0.6957, 0.5752, 0.762, 0.5966]}, {"w": "of", "b": [0.7678, 0.5752, 0.7846, 0.5966]}, {"w": "filters", "b": [0.7905, 0.5752, 0.8381, 0.5966]}, {"w": "is", "b": [0.8439, 0.5752, 0.8572, 0.5966]}, {"w": "the", "b": [0.1429, 0.5951, 0.1692, 0.6165]}, {"w": "same", "b": [0.1745, 0.5951, 0.2172, 0.6165]}, {"w": "as", "b": [0.2225, 0.5951, 0.2393, 0.6165]}, {"w": "in", "b": [0.2446, 0.5951, 0.2616, 0.6165]}, {"w": "the", "b": [0.2669, 0.5951, 0.2932, 0.6165]}, {"w": "previous", "b": [0.2985, 0.5951, 0.3706, 0.6165]}, {"w": "RU,", "b": [0.3759, 0.5951, 0.4066, 0.6165]}, {"w": "or", "b": [0.4119, 0.5951, 0.4302, 0.6165]}, {"w": "else", "b": [0.4355, 0.5951, 0.4662, 0.6165]}, {"w": "we", "b": [0.4715, 0.5951, 0.4946, 0.6165]}, {"w": "set", "b": [0.4999, 0.5951, 0.5227, 0.6165]}, {"w": "it", "b": [0.528, 0.5951, 0.54, 0.6165]}, {"w": "to", "b": [0.5453, 0.5951, 0.5623, 0.6165]}, {"w": "2.", "b": [0.5676, 0.5951, 0.5823, 0.6165]}, {"w": "Then", "b": [0.5876, 0.5951, 0.6318, 0.6165]}, {"w": "we", "b": [0.6371, 0.5951, 0.6603, 0.6165]}, {"w": "add", "b": [0.6656, 0.5951, 0.6967, 0.6165]}, {"w": "the", "b": [0.702, 0.5951, 0.7283, 0.6165]}, {"w": "ResidualUnit,", "b": [0.7336, 0.5951, 0.8571, 0.6165]}, {"w": "and", "b": [0.1429, 0.6151, 0.1744, 0.6365]}, {"w": "finally", "b": [0.1791, 0.6151, 0.2315, 0.6365]}, {"w": "we", "b": [0.2363, 0.6151, 0.2594, 0.6365]}, {"w": "update", "b": [0.2641, 0.6151, 0.321, 0.6365]}, {"w": "prev_filters.", "b": [0.3258, 0.6151, 0.4493, 0.6365]}]}, {"id": "b_5", "type": "paragraph", "text": "It is quite amazing that in less than 40 lines of code, we can build the model that won the ILSVRC 2015 challenge! It demonstrates both the elegance of the ResNet model, and the expressiveness of the Keras API. Implementing the other CNN architectures is not much harder. However, Keras comes with several of these architectures built in, so why not use them instead?", "words": [{"w": "It", "b": [0.1429, 0.6432, 0.1555, 0.6646]}, {"w": "is", "b": [0.1608, 0.6432, 0.174, 0.6646]}, {"w": "quite", "b": [0.1792, 0.6432, 0.2217, 0.6646]}, {"w": "amazing", "b": [0.227, 0.6432, 0.2978, 0.6646]}, {"w": "that", "b": [0.3031, 0.6432, 0.3356, 0.6646]}, {"w": "in", "b": [0.3409, 0.6432, 0.3579, 0.6646]}, {"w": "less", "b": [0.3631, 0.6432, 0.3925, 0.6646]}, {"w": "than", "b": [0.3978, 0.6432, 0.4358, 0.6646]}, {"w": "40", "b": [0.4411, 0.6432, 0.4611, 0.6646]}, {"w": "lines", "b": [0.4663, 0.6432, 0.5051, 0.6646]}, {"w": "of", "b": [0.5103, 0.6432, 0.5271, 0.6646]}, {"w": "code,", "b": [0.5324, 0.6432, 0.5764, 0.6646]}, {"w": "we", "b": [0.5816, 0.6432, 0.6048, 0.6646]}, {"w": "can", "b": [0.61, 0.6432, 0.6394, 0.6646]}, {"w": "build", "b": [0.6446, 0.6432, 0.6881, 0.6646]}, {"w": "the", "b": [0.6934, 0.6432, 0.7197, 0.6646]}, {"w": "model", "b": [0.725, 0.6432, 0.7778, 0.6646]}, {"w": "that", "b": [0.783, 0.6432, 0.8156, 0.6646]}, {"w": "won", "b": [0.8209, 0.6432, 0.8571, 0.6646]}, {"w": "the", "b": [0.1429, 0.6622, 0.1692, 0.6836]}, {"w": "ILSVRC", "b": [0.1753, 0.6622, 0.2449, 0.6836]}, {"w": "2015", "b": [0.251, 0.6622, 0.291, 0.6836]}, {"w": "challenge!", "b": [0.297, 0.6622, 0.3813, 0.6836]}, {"w": "It", "b": [0.3873, 0.6622, 0.4, 0.6836]}, {"w": "demonstrates", "b": [0.4061, 0.6622, 0.5183, 0.6836]}, {"w": "both", "b": [0.5244, 0.6622, 0.5631, 0.6836]}, {"w": "the", "b": [0.5692, 0.6622, 0.5955, 0.6836]}, {"w": "elegance", "b": [0.6016, 0.6622, 0.6725, 0.6836]}, {"w": "of", "b": [0.6786, 0.6622, 0.6954, 0.6836]}, {"w": "the", "b": [0.7015, 0.6622, 0.7278, 0.6836]}, {"w": "ResNet", "b": [0.7339, 0.6622, 0.7935, 0.6836]}, {"w": "model,", "b": [0.7996, 0.6622, 0.8571, 0.6836]}, {"w": "and", "b": [0.1429, 0.6813, 0.1744, 0.7027]}, {"w": "the", "b": [0.1803, 0.6813, 0.2066, 0.7027]}, {"w": "expressiveness", "b": [0.2125, 0.6813, 0.3336, 0.7027]}, {"w": "of", "b": [0.3395, 0.6813, 0.3563, 0.7027]}, {"w": "the", "b": [0.3621, 0.6813, 0.3885, 0.7027]}, {"w": "Keras", "b": [0.3943, 0.6813, 0.4412, 0.7027]}, {"w": "API.", "b": [0.4471, 0.6813, 0.4851, 0.7027]}, {"w": "Implementing", "b": [0.491, 0.6813, 0.6098, 0.7027]}, {"w": "the", "b": [0.6156, 0.6813, 0.642, 0.7027]}, {"w": "other", "b": [0.6478, 0.6813, 0.6925, 0.7027]}, {"w": "CNN", "b": [0.6984, 0.6813, 0.7432, 0.7027]}, {"w": "architectures", "b": [0.7491, 0.6813, 0.8572, 0.7027]}, {"w": "is", "b": [0.1429, 0.7003, 0.1561, 0.7217]}, {"w": "not", "b": [0.1611, 0.7003, 0.1894, 0.7217]}, {"w": "much", "b": [0.1944, 0.7003, 0.2421, 0.7217]}, {"w": "harder.", "b": [0.247, 0.7003, 0.306, 0.7217]}, {"w": "However,", "b": [0.311, 0.7003, 0.3899, 0.7217]}, {"w": "Keras", "b": [0.3948, 0.7003, 0.4417, 0.7217]}, {"w": "comes", "b": [0.4467, 0.7003, 0.4997, 0.7217]}, {"w": "with", "b": [0.5046, 0.7003, 0.542, 0.7217]}, {"w": "several", "b": [0.5469, 0.7003, 0.6041, 0.7217]}, {"w": "of", "b": [0.609, 0.7003, 0.6258, 0.7217]}, {"w": "these", "b": [0.6308, 0.7003, 0.6736, 0.7217]}, {"w": "architectures", "b": [0.6786, 0.7003, 0.7866, 0.7217]}, {"w": "built", "b": [0.7916, 0.7003, 0.8305, 0.7217]}, {"w": "in,", "b": [0.8354, 0.7003, 0.8571, 0.7217]}, {"w": "so", "b": [0.1429, 0.7194, 0.1611, 0.7408]}, {"w": "why", "b": [0.1659, 0.7194, 0.2003, 0.7408]}, {"w": "not", "b": [0.2051, 0.7194, 0.2334, 0.7408]}, {"w": "use", "b": [0.2382, 0.7194, 0.2657, 0.7408]}, {"w": "them", "b": [0.2705, 0.7194, 0.3139, 0.7408]}, {"w": "instead?", "b": [0.3186, 0.7194, 0.3865, 0.7408]}]}, {"id": "b_6", "type": "paragraph", "text": "Using Pretrained Models From Keras", "words": [{"w": "Using", "b": [0.1429, 0.7538, 0.2124, 0.788]}, {"w": "Pretrained", "b": [0.2184, 0.7538, 0.3502, 0.788]}, {"w": "Models", "b": [0.3561, 0.7538, 0.4449, 0.788]}, {"w": "From", "b": [0.4509, 0.7538, 0.515, 0.788]}, {"w": "Keras", "b": [0.5209, 0.7538, 0.5886, 0.788]}]}, {"id": "b_7", "type": "paragraph", "text": "In general, you won’t have to implement standard models like GoogLeNet or ResNet manually, since pretrained networks are readily available with a single line of code, in the keras.applications package. For example:", "words": [{"w": "In", "b": [0.1429, 0.7949, 0.1614, 0.8164]}, {"w": "general,", "b": [0.1672, 0.7949, 0.2329, 0.8164]}, {"w": "you", "b": [0.2388, 0.7949, 0.27, 0.8164]}, {"w": "won’t", "b": [0.2758, 0.7949, 0.3207, 0.8164]}, {"w": "have", "b": [0.3266, 0.7949, 0.365, 0.8164]}, {"w": "to", "b": [0.3708, 0.7949, 0.3878, 0.8164]}, {"w": "implement", "b": [0.3936, 0.7949, 0.4842, 0.8164]}, {"w": "standard", "b": [0.49, 0.7949, 0.5634, 0.8164]}, {"w": "models", "b": [0.5692, 0.7949, 0.6297, 0.8164]}, {"w": "like", "b": [0.6355, 0.7949, 0.6656, 0.8164]}, {"w": "GoogLeNet", "b": [0.6714, 0.7949, 0.7675, 0.8164]}, {"w": "or", "b": [0.7734, 0.7949, 0.7917, 0.8164]}, {"w": "ResNet", "b": [0.7975, 0.7949, 0.8571, 0.8164]}, {"w": "manually,", "b": [0.1428, 0.814, 0.2236, 0.8354]}, {"w": "since", "b": [0.2288, 0.814, 0.2711, 0.8354]}, {"w": "pretrained", "b": [0.2763, 0.814, 0.3638, 0.8354]}, {"w": "networks", "b": [0.369, 0.814, 0.4462, 0.8354]}, {"w": "are", "b": [0.4514, 0.814, 0.4771, 0.8354]}, {"w": "readily", "b": [0.4823, 0.814, 0.5395, 0.8354]}, {"w": "available", "b": [0.5447, 0.814, 0.6169, 0.8354]}, {"w": "with", "b": [0.6221, 0.814, 0.6595, 0.8354]}, {"w": "a", "b": [0.6646, 0.814, 0.6738, 0.8354]}, {"w": "single", "b": [0.679, 0.814, 0.7275, 0.8354]}, {"w": "line", "b": [0.7327, 0.814, 0.7638, 0.8354]}, {"w": "of", "b": [0.7689, 0.814, 0.7857, 0.8354]}, {"w": "code,", "b": [0.7909, 0.814, 0.835, 0.8354]}, {"w": "in", "b": [0.8402, 0.814, 0.8571, 0.8354]}, {"w": "the", "b": [0.1429, 0.8339, 0.1692, 0.8554]}, {"w": "keras.applications", "b": [0.1739, 0.8371, 0.3521, 0.8522]}, {"w": "package.", "b": [0.3568, 0.8339, 0.4285, 0.8554]}, {"w": "For", "b": [0.4332, 0.8339, 0.4622, 0.8554]}, {"w": "example:", "b": [0.4669, 0.8339, 0.5412, 0.8554]}]}, {"id": "b_8", "type": "equation", "text": "model = keras.applications.resnet50.ResNet50(weights=\"imagenet\")", "words": [{"w": "model", "b": [0.1766, 0.8659, 0.2188, 0.8788]}, {"w": "=", "b": [0.2272, 0.8659, 0.2356, 0.8788]}, {"w": "keras.applications.resnet50.ResNet50(weights=\"imagenet\")", "b": [0.2441, 0.8659, 0.7163, 0.8788]}]}, {"id": "b_9", "type": "paragraph", "text": "Using Pretrained Models From Keras | 465", "words": [{"w": "Using", "b": [0.5838, 0.9225, 0.6169, 0.9388]}, {"w": "Pretrained", "b": [0.6197, 0.9225, 0.6824, 0.9388]}, {"w": "Models", "b": [0.6852, 0.9225, 0.7275, 0.9388]}, {"w": "From", "b": [0.7303, 0.9225, 0.7608, 0.9388]}, {"w": "Keras", "b": [0.7636, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "465", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 492, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "21 In the ImageNet dataset, each image is associated to a word in the WordNet dataset: the class ID is just a WordNet ID.", "words": [{"w": "21", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "In", "b": [0.1587, 0.8598, 0.1728, 0.8761]}, {"w": "the", "b": [0.1764, 0.8598, 0.1965, 0.8761]}, {"w": "ImageNet", "b": [0.2001, 0.8598, 0.2626, 0.8761]}, {"w": "dataset,", "b": [0.2662, 0.8598, 0.3141, 0.8761]}, {"w": "each", "b": [0.3177, 0.8598, 0.3466, 0.8761]}, {"w": "image", "b": [0.3502, 0.8598, 0.3886, 0.8761]}, {"w": "is", "b": [0.3922, 0.8598, 0.4023, 0.8761]}, {"w": "associated", "b": [0.4059, 0.8598, 0.4702, 0.8761]}, {"w": "to", "b": [0.4738, 0.8598, 0.4868, 0.8761]}, {"w": "a", "b": [0.4904, 0.8598, 0.4973, 0.8761]}, {"w": "word", "b": [0.501, 0.8598, 0.5342, 0.8761]}, {"w": "in", "b": [0.5378, 0.8598, 0.5507, 0.8761]}, {"w": "the", "b": [0.5543, 0.8598, 0.5744, 0.8761]}, {"w": "WordNet", "b": [0.578, 0.8598, 0.6372, 0.8761]}, {"w": "dataset:", "b": [0.6408, 0.8598, 0.6887, 0.8761]}, {"w": "the", "b": [0.6923, 0.8598, 0.7124, 0.8761]}, {"w": "class", "b": [0.716, 0.8598, 0.7453, 0.8761]}, {"w": "ID", "b": [0.7489, 0.8598, 0.766, 0.8761]}, {"w": "is", "b": [0.7696, 0.8598, 0.7797, 0.8761]}, {"w": "just", "b": [0.7833, 0.8598, 0.8065, 0.8761]}, {"w": "a", "b": [0.8101, 0.8598, 0.817, 0.8761]}, {"w": "WordNet", "b": [0.1587, 0.8749, 0.218, 0.8912]}, {"w": "ID.", "b": [0.2216, 0.8749, 0.2416, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "That’s all! This will create a ResNet-50 model and download weights pretrained on the ImageNet dataset. To use it, you first need to ensure that the images have the right size. A ResNet-50 model expects 224 × 224 images (other models may expect other sizes, such as 299 × 299), so let’s use TensorFlow’s tf.image.resize() function to resize the images we loaded earlier:", "words": [{"w": "That’s", "b": [0.1428, 0.0791, 0.1917, 0.1005]}, {"w": "all!", "b": [0.1989, 0.0791, 0.2243, 0.1005]}, {"w": "This", "b": [0.2315, 0.0791, 0.2687, 0.1005]}, {"w": "will", "b": [0.2759, 0.0791, 0.3063, 0.1005]}, {"w": "create", "b": [0.3135, 0.0791, 0.3629, 0.1005]}, {"w": "a", "b": [0.3701, 0.0791, 0.3792, 0.1005]}, {"w": "ResNet-50", "b": [0.3864, 0.0791, 0.4735, 0.1005]}, {"w": "model", "b": [0.4807, 0.0791, 0.5335, 0.1005]}, {"w": "and", "b": [0.5407, 0.0791, 0.5722, 0.1005]}, {"w": "download", "b": [0.5794, 0.0791, 0.6628, 0.1005]}, {"w": "weights", "b": [0.67, 0.0791, 0.7331, 0.1005]}, {"w": "pretrained", "b": [0.7403, 0.0791, 0.8279, 0.1005]}, {"w": "on", "b": [0.8351, 0.0791, 0.8571, 0.1005]}, {"w": "the", "b": [0.1429, 0.0981, 0.1692, 0.1195]}, {"w": "ImageNet", "b": [0.1741, 0.0981, 0.2562, 0.1195]}, {"w": "dataset.", "b": [0.261, 0.0981, 0.3239, 0.1195]}, {"w": "To", "b": [0.3288, 0.0981, 0.3502, 0.1195]}, {"w": "use", "b": [0.3551, 0.0981, 0.3827, 0.1195]}, {"w": "it,", "b": [0.3876, 0.0981, 0.4042, 0.1195]}, {"w": "you", "b": [0.4091, 0.0981, 0.4404, 0.1195]}, {"w": "first", "b": [0.4453, 0.0981, 0.4787, 0.1195]}, {"w": "need", "b": [0.4836, 0.0981, 0.5237, 0.1195]}, {"w": "to", "b": [0.5286, 0.0981, 0.5456, 0.1195]}, {"w": "ensure", "b": [0.5505, 0.0981, 0.606, 0.1195]}, {"w": "that", "b": [0.6109, 0.0981, 0.6435, 0.1195]}, {"w": "the", "b": [0.6484, 0.0981, 0.6747, 0.1195]}, {"w": "images", "b": [0.6796, 0.0981, 0.7376, 0.1195]}, {"w": "have", "b": [0.7425, 0.0981, 0.7809, 0.1195]}, {"w": "the", "b": [0.7858, 0.0981, 0.8121, 0.1195]}, {"w": "right", "b": [0.817, 0.0981, 0.8571, 0.1195]}, {"w": "size.", "b": [0.1429, 0.1172, 0.1784, 0.1386]}, {"w": "A", "b": [0.1851, 0.1172, 0.1995, 0.1386]}, {"w": "ResNet-50", "b": [0.2062, 0.1172, 0.2932, 0.1386]}, {"w": "model", "b": [0.2999, 0.1172, 0.3528, 0.1386]}, {"w": "expects", "b": [0.3594, 0.1172, 0.4207, 0.1386]}, {"w": "224", "b": [0.4274, 0.1172, 0.4574, 0.1386]}, {"w": "×", "b": [0.4641, 0.1172, 0.4762, 0.1386]}, {"w": "224", "b": [0.4829, 0.1172, 0.5129, 0.1386]}, {"w": "images", "b": [0.5196, 0.1172, 0.5776, 0.1386]}, {"w": "(other", "b": [0.5843, 0.1172, 0.6362, 0.1386]}, {"w": "models", "b": [0.6429, 0.1172, 0.7034, 0.1386]}, {"w": "may", "b": [0.71, 0.1172, 0.7454, 0.1386]}, {"w": "expect", "b": [0.7521, 0.1172, 0.8058, 0.1386]}, {"w": "other", "b": [0.8125, 0.1172, 0.8571, 0.1386]}, {"w": "sizes,", "b": [0.1429, 0.1371, 0.1861, 0.1585]}, {"w": "such", "b": [0.1936, 0.1371, 0.2323, 0.1585]}, {"w": "as", "b": [0.2398, 0.1371, 0.2566, 0.1585]}, {"w": "299", "b": [0.2641, 0.1371, 0.2941, 0.1585]}, {"w": "×", "b": [0.3016, 0.1371, 0.3137, 0.1585]}, {"w": "299),", "b": [0.3212, 0.1371, 0.3632, 0.1585]}, {"w": "so", "b": [0.3707, 0.1371, 0.389, 0.1585]}, {"w": "let’s", "b": [0.3965, 0.1371, 0.4268, 0.1585]}, {"w": "use", "b": [0.4343, 0.1371, 0.4619, 0.1585]}, {"w": "TensorFlow’s", "b": [0.4694, 0.1371, 0.5779, 0.1585]}, {"w": "tf.image.resize()", "b": [0.5855, 0.1403, 0.7537, 0.1554]}, {"w": "function", "b": [0.7612, 0.1371, 0.8326, 0.1585]}, {"w": "to", "b": [0.8402, 0.1371, 0.8571, 0.1585]}, {"w": "resize", "b": [0.1429, 0.1561, 0.1903, 0.1776]}, {"w": "the", "b": [0.195, 0.1561, 0.2213, 0.1776]}, {"w": "images", "b": [0.2261, 0.1561, 0.2841, 0.1776]}, {"w": "we", "b": [0.2888, 0.1561, 0.312, 0.1776]}, {"w": "loaded", "b": [0.3167, 0.1561, 0.3726, 0.1776]}, {"w": "earlier:", "b": [0.3773, 0.1561, 0.4357, 0.1776]}]}, {"id": "b_2", "type": "equation", "text": "images_resized = tf.image.resize(images, [224, 224])", "words": [{"w": "images_resized", "b": [0.1766, 0.1881, 0.2946, 0.201]}, {"w": "=", "b": [0.3031, 0.1881, 0.3115, 0.201]}, {"w": "tf.image.resize(images,", "b": [0.3199, 0.1881, 0.5139, 0.201]}, {"w": "[224,", "b": [0.5223, 0.1881, 0.5645, 0.201]}, {"w": "224])", "b": [0.5729, 0.1881, 0.6151, 0.201]}]}, {"id": "b_3", "type": "paragraph", "text": "The tf.image.resize() will not preserve the aspect ratio. If this is a problem, you can try cropping the images to the appropriate aspect ratio before resizing. Both operations can be done in one shot with tf.image.crop_and_resize().", "words": [{"w": "The", "b": [0.2714, 0.2234, 0.3014, 0.243]}, {"w": "tf.image.resize()", "b": [0.3063, 0.2263, 0.4601, 0.2401]}, {"w": "will", "b": [0.465, 0.2234, 0.4928, 0.243]}, {"w": "not", "b": [0.4977, 0.2234, 0.5236, 0.243]}, {"w": "preserve", "b": [0.5285, 0.2234, 0.5933, 0.243]}, {"w": "the", "b": [0.5981, 0.2234, 0.6222, 0.243]}, {"w": "aspect", "b": [0.6271, 0.2234, 0.6744, 0.243]}, {"w": "ratio.", "b": [0.6793, 0.2234, 0.7188, 0.243]}, {"w": "If", "b": [0.7236, 0.2234, 0.7358, 0.243]}, {"w": "this", "b": [0.7407, 0.2234, 0.7687, 0.243]}, {"w": "is", "b": [0.7736, 0.2234, 0.7857, 0.243]}, {"w": "a", "b": [0.2714, 0.2408, 0.2798, 0.2604]}, {"w": "problem,", "b": [0.2882, 0.2408, 0.3575, 0.2604]}, {"w": "you", "b": [0.3659, 0.2408, 0.3945, 0.2604]}, {"w": "can", "b": [0.4029, 0.2408, 0.4298, 0.2604]}, {"w": "try", "b": [0.4382, 0.2408, 0.4604, 0.2604]}, {"w": "cropping", "b": [0.4688, 0.2408, 0.538, 0.2604]}, {"w": "the", "b": [0.5465, 0.2408, 0.5705, 0.2604]}, {"w": "images", "b": [0.579, 0.2408, 0.632, 0.2604]}, {"w": "to", "b": [0.6405, 0.2408, 0.656, 0.2604]}, {"w": "the", "b": [0.6644, 0.2408, 0.6885, 0.2604]}, {"w": "appropriate", "b": [0.6969, 0.2408, 0.7857, 0.2604]}, {"w": "aspect", "b": [0.2714, 0.2582, 0.3187, 0.2778]}, {"w": "ratio", "b": [0.3261, 0.2582, 0.3618, 0.2778]}, {"w": "before", "b": [0.3692, 0.2582, 0.4175, 0.2778]}, {"w": "resizing.", "b": [0.4249, 0.2582, 0.489, 0.2778]}, {"w": "Both", "b": [0.4964, 0.2582, 0.5337, 0.2778]}, {"w": "operations", "b": [0.5411, 0.2582, 0.622, 0.2778]}, {"w": "can", "b": [0.6294, 0.2582, 0.6562, 0.2778]}, {"w": "be", "b": [0.6636, 0.2582, 0.6814, 0.2778]}, {"w": "done", "b": [0.6888, 0.2582, 0.7271, 0.2778]}, {"w": "in", "b": [0.7345, 0.2582, 0.7501, 0.2778]}, {"w": "one", "b": [0.7575, 0.2582, 0.7857, 0.2778]}, {"w": "shot", "b": [0.2714, 0.2765, 0.3041, 0.296]}, {"w": "with", "b": [0.3084, 0.2765, 0.3425, 0.296]}, {"w": "tf.image.crop_and_resize().", "b": [0.3469, 0.2765, 0.5865, 0.296]}]}, {"id": "b_4", "type": "paragraph", "text": "The pretrained models assume that the images are preprocessed in a specific way. In some cases they may expect the inputs to be scaled from 0 to 1, or -1 to 1, and so on. Each model provides a preprocess_input() function that you can use to preprocess your images. These functions assume that the pixel values range from 0 to 255, so we must multiply them by 255 (since earlier we scaled them to the 0–1 range):", "words": [{"w": "The", "b": [0.1428, 0.3212, 0.1757, 0.3426]}, {"w": "pretrained", "b": [0.1816, 0.3212, 0.2692, 0.3426]}, {"w": "models", "b": [0.2751, 0.3212, 0.3355, 0.3426]}, {"w": "assume", "b": [0.3415, 0.3212, 0.4029, 0.3426]}, {"w": "that", "b": [0.4088, 0.3212, 0.4414, 0.3426]}, {"w": "the", "b": [0.4473, 0.3212, 0.4736, 0.3426]}, {"w": "images", "b": [0.4795, 0.3212, 0.5376, 0.3426]}, {"w": "are", "b": [0.5435, 0.3212, 0.5692, 0.3426]}, {"w": "preprocessed", "b": [0.5751, 0.3212, 0.6847, 0.3426]}, {"w": "in", "b": [0.6906, 0.3212, 0.7076, 0.3426]}, {"w": "a", "b": [0.7135, 0.3212, 0.7227, 0.3426]}, {"w": "specific", "b": [0.7286, 0.3212, 0.791, 0.3426]}, {"w": "way.", "b": [0.7969, 0.3212, 0.8327, 0.3426]}, {"w": "In", "b": [0.8386, 0.3212, 0.8571, 0.3426]}, {"w": "some", "b": [0.1429, 0.3403, 0.1871, 0.3617]}, {"w": "cases", "b": [0.1925, 0.3403, 0.2346, 0.3617]}, {"w": "they", "b": [0.2401, 0.3403, 0.276, 0.3617]}, {"w": "may", "b": [0.2815, 0.3403, 0.3169, 0.3617]}, {"w": "expect", "b": [0.3224, 0.3403, 0.376, 0.3617]}, {"w": "the", "b": [0.3815, 0.3403, 0.4078, 0.3617]}, {"w": "inputs", "b": [0.4133, 0.3403, 0.4659, 0.3617]}, {"w": "to", "b": [0.4713, 0.3403, 0.4883, 0.3617]}, {"w": "be", "b": [0.4938, 0.3403, 0.5132, 0.3617]}, {"w": "scaled", "b": [0.5187, 0.3403, 0.5695, 0.3617]}, {"w": "from", "b": [0.5749, 0.3403, 0.6165, 0.3617]}, {"w": "0", "b": [0.622, 0.3403, 0.632, 0.3617]}, {"w": "to", "b": [0.6375, 0.3403, 0.6545, 0.3617]}, {"w": "1,", "b": [0.6599, 0.3403, 0.6747, 0.3617]}, {"w": "or", "b": [0.6802, 0.3403, 0.6985, 0.3617]}, {"w": "-1", "b": [0.704, 0.3403, 0.7214, 0.3617]}, {"w": "to", "b": [0.7269, 0.3403, 0.7439, 0.3617]}, {"w": "1,", "b": [0.7494, 0.3403, 0.7641, 0.3617]}, {"w": "and", "b": [0.7696, 0.3403, 0.8011, 0.3617]}, {"w": "so", "b": [0.8066, 0.3403, 0.8249, 0.3617]}, {"w": "on.", "b": [0.8304, 0.3403, 0.8572, 0.3617]}, {"w": "Each", "b": [0.1429, 0.3602, 0.1838, 0.3816]}, {"w": "model", "b": [0.1895, 0.3602, 0.2423, 0.3816]}, {"w": "provides", "b": [0.2479, 0.3602, 0.3199, 0.3816]}, {"w": "a", "b": [0.3256, 0.3602, 0.3348, 0.3816]}, {"w": "preprocess_input()", "b": [0.3404, 0.3634, 0.5186, 0.3785]}, {"w": "function", "b": [0.5242, 0.3602, 0.5956, 0.3816]}, {"w": "that", "b": [0.6013, 0.3602, 0.6339, 0.3816]}, {"w": "you", "b": [0.6396, 0.3602, 0.6708, 0.3816]}, {"w": "can", "b": [0.6765, 0.3602, 0.7058, 0.3816]}, {"w": "use", "b": [0.7115, 0.3602, 0.7391, 0.3816]}, {"w": "to", "b": [0.7448, 0.3602, 0.7617, 0.3816]}, {"w": "preprocess", "b": [0.7674, 0.3602, 0.8571, 0.3816]}, {"w": "your", "b": [0.1429, 0.3793, 0.1818, 0.4007]}, {"w": "images.", "b": [0.1872, 0.3793, 0.25, 0.4007]}, {"w": "These", "b": [0.2553, 0.3793, 0.3046, 0.4007]}, {"w": "functions", "b": [0.31, 0.3793, 0.389, 0.4007]}, {"w": "assume", "b": [0.3944, 0.3793, 0.4558, 0.4007]}, {"w": "that", "b": [0.4611, 0.3793, 0.4937, 0.4007]}, {"w": "the", "b": [0.4991, 0.3793, 0.5254, 0.4007]}, {"w": "pixel", "b": [0.5307, 0.3793, 0.5712, 0.4007]}, {"w": "values", "b": [0.5765, 0.3793, 0.6282, 0.4007]}, {"w": "range", "b": [0.6335, 0.3793, 0.6804, 0.4007]}, {"w": "from", "b": [0.6857, 0.3793, 0.7273, 0.4007]}, {"w": "0", "b": [0.7326, 0.3793, 0.7426, 0.4007]}, {"w": "to", "b": [0.748, 0.3793, 0.765, 0.4007]}, {"w": "255,", "b": [0.7703, 0.3793, 0.8051, 0.4007]}, {"w": "so", "b": [0.8104, 0.3793, 0.8287, 0.4007]}, {"w": "we", "b": [0.834, 0.3793, 0.8571, 0.4007]}, {"w": "must", "b": [0.1428, 0.3983, 0.1846, 0.4197]}, {"w": "multiply", "b": [0.1893, 0.3983, 0.26, 0.4197]}, {"w": "them", "b": [0.2647, 0.3983, 0.3081, 0.4197]}, {"w": "by", "b": [0.3128, 0.3983, 0.333, 0.4197]}, {"w": "255", "b": [0.3377, 0.3983, 0.3677, 0.4197]}, {"w": "(since", "b": [0.3725, 0.3983, 0.422, 0.4197]}, {"w": "earlier", "b": [0.4267, 0.3983, 0.4798, 0.4197]}, {"w": "we", "b": [0.4846, 0.3983, 0.5077, 0.4197]}, {"w": "scaled", "b": [0.5124, 0.3983, 0.5632, 0.4197]}, {"w": "them", "b": [0.5679, 0.3983, 0.6113, 0.4197]}, {"w": "to", "b": [0.616, 0.3983, 0.633, 0.4197]}, {"w": "the", "b": [0.6377, 0.3983, 0.6641, 0.4197]}, {"w": "0–1", "b": [0.6688, 0.3983, 0.6996, 0.4197]}, {"w": "range):", "b": [0.7043, 0.3983, 0.7632, 0.4197]}]}, {"id": "b_5", "type": "equation", "text": "inputs = keras.applications.resnet50.preprocess_input(images_resized * 255)", "words": [{"w": "inputs", "b": [0.1766, 0.4303, 0.2272, 0.4431]}, {"w": "=", "b": [0.2356, 0.4303, 0.244, 0.4431]}, {"w": "keras.applications.resnet50.preprocess_input(images_resized", "b": [0.2525, 0.4303, 0.75, 0.4431]}, {"w": "*", "b": [0.7584, 0.4303, 0.7669, 0.4431]}, {"w": "255)", "b": [0.7753, 0.4303, 0.809, 0.4431]}]}, {"id": "b_6", "type": "paragraph", "text": "Now we can use the pretrained model to make predictions:", "words": [{"w": "Now", "b": [0.1429, 0.4509, 0.1827, 0.4723]}, {"w": "we", "b": [0.1874, 0.4509, 0.2106, 0.4723]}, {"w": "can", "b": [0.2153, 0.4509, 0.2446, 0.4723]}, {"w": "use", "b": [0.2494, 0.4509, 0.2769, 0.4723]}, {"w": "the", "b": [0.2817, 0.4509, 0.308, 0.4723]}, {"w": "pretrained", "b": [0.3127, 0.4509, 0.4003, 0.4723]}, {"w": "model", "b": [0.405, 0.4509, 0.4578, 0.4723]}, {"w": "to", "b": [0.4626, 0.4509, 0.4795, 0.4723]}, {"w": "make", "b": [0.4843, 0.4509, 0.5297, 0.4723]}, {"w": "predictions:", "b": [0.5344, 0.4509, 0.6336, 0.4723]}]}, {"id": "b_7", "type": "equation", "text": "Y_proba = model.predict(inputs)", "words": [{"w": "Y_proba", "b": [0.1766, 0.4829, 0.2356, 0.4957]}, {"w": "=", "b": [0.244, 0.4829, 0.2525, 0.4957]}, {"w": "model.predict(inputs)", "b": [0.2609, 0.4829, 0.438, 0.4957]}]}, {"id": "b_8", "type": "paragraph", "text": "As usual, the output Y_proba is a matrix with one row per image and one column per class (in this case, there are 1,000 classes). If you want to display the top K predic‐ tions, including the class name and the estimated probability of each predicted class, you can use the decode_predictions() function. For each image, it returns an array containing the top K predictions, where each prediction is represented as an array containing the class identifier21, its name and the corresponding confidence score:", "words": [{"w": "As", "b": [0.1428, 0.5044, 0.1649, 0.5258]}, {"w": "usual,", "b": [0.1699, 0.5044, 0.2189, 0.5258]}, {"w": "the", "b": [0.2239, 0.5044, 0.2503, 0.5258]}, {"w": "output", "b": [0.2553, 0.5044, 0.3117, 0.5258]}, {"w": "Y_proba", "b": [0.3167, 0.5076, 0.386, 0.5227]}, {"w": "is", "b": [0.3911, 0.5044, 0.4043, 0.5258]}, {"w": "a", "b": [0.4093, 0.5044, 0.4185, 0.5258]}, {"w": "matrix", "b": [0.4235, 0.5044, 0.4788, 0.5258]}, {"w": "with", "b": [0.4839, 0.5044, 0.5212, 0.5258]}, {"w": "one", "b": [0.5263, 0.5044, 0.5571, 0.5258]}, {"w": "row", "b": [0.5622, 0.5044, 0.5948, 0.5258]}, {"w": "per", "b": [0.5999, 0.5044, 0.6274, 0.5258]}, {"w": "image", "b": [0.6324, 0.5044, 0.6828, 0.5258]}, {"w": "and", "b": [0.6879, 0.5044, 0.7194, 0.5258]}, {"w": "one", "b": [0.7244, 0.5044, 0.7553, 0.5258]}, {"w": "column", "b": [0.7604, 0.5044, 0.8246, 0.5258]}, {"w": "per", "b": [0.8296, 0.5044, 0.8571, 0.5258]}, {"w": "class", "b": [0.1429, 0.5235, 0.1814, 0.5449]}, {"w": "(in", "b": [0.1884, 0.5235, 0.2125, 0.5449]}, {"w": "this", "b": [0.2195, 0.5235, 0.2502, 0.5449]}, {"w": "case,", "b": [0.2572, 0.5235, 0.2964, 0.5449]}, {"w": "there", "b": [0.3034, 0.5235, 0.3463, 0.5449]}, {"w": "are", "b": [0.3533, 0.5235, 0.379, 0.5449]}, {"w": "1,000", "b": [0.386, 0.5235, 0.4308, 0.5449]}, {"w": "classes).", "b": [0.4377, 0.5235, 0.5047, 0.5449]}, {"w": "If", "b": [0.5117, 0.5235, 0.525, 0.5449]}, {"w": "you", "b": [0.532, 0.5235, 0.5632, 0.5449]}, {"w": "want", "b": [0.5702, 0.5235, 0.611, 0.5449]}, {"w": "to", "b": [0.6179, 0.5235, 0.6349, 0.5449]}, {"w": "display", "b": [0.6419, 0.5235, 0.7007, 0.5449]}, {"w": "the", "b": [0.7076, 0.5235, 0.734, 0.5449]}, {"w": "top", "b": [0.741, 0.5235, 0.7688, 0.5449]}, {"w": "K", "b": [0.7758, 0.5235, 0.7898, 0.5449]}, {"w": "predic‐", "b": [0.7968, 0.5235, 0.8571, 0.5449]}, {"w": "tions,", "b": [0.1429, 0.5425, 0.1892, 0.5639]}, {"w": "including", "b": [0.195, 0.5425, 0.2748, 0.5639]}, {"w": "the", "b": [0.2806, 0.5425, 0.307, 0.5639]}, {"w": "class", "b": [0.3127, 0.5425, 0.3513, 0.5639]}, {"w": "name", "b": [0.357, 0.5425, 0.4035, 0.5639]}, {"w": "and", "b": [0.4093, 0.5425, 0.4408, 0.5639]}, {"w": "the", "b": [0.4466, 0.5425, 0.4729, 0.5639]}, {"w": "estimated", "b": [0.4787, 0.5425, 0.5592, 0.5639]}, {"w": "probability", "b": [0.565, 0.5425, 0.6569, 0.5639]}, {"w": "of", "b": [0.6627, 0.5425, 0.6795, 0.5639]}, {"w": "each", "b": [0.6853, 0.5425, 0.7232, 0.5639]}, {"w": "predicted", "b": [0.729, 0.5425, 0.8081, 0.5639]}, {"w": "class,", "b": [0.8139, 0.5425, 0.8571, 0.5639]}, {"w": "you", "b": [0.1429, 0.5625, 0.1741, 0.5839]}, {"w": "can", "b": [0.1797, 0.5625, 0.2091, 0.5839]}, {"w": "use", "b": [0.2147, 0.5625, 0.2423, 0.5839]}, {"w": "the", "b": [0.2479, 0.5625, 0.2742, 0.5839]}, {"w": "decode_predictions()", "b": [0.2799, 0.5656, 0.4778, 0.5807]}, {"w": "function.", "b": [0.4834, 0.5625, 0.5595, 0.5839]}, {"w": "For", "b": [0.5652, 0.5625, 0.5941, 0.5839]}, {"w": "each", "b": [0.5998, 0.5625, 0.6377, 0.5839]}, {"w": "image,", "b": [0.6433, 0.5625, 0.6985, 0.5839]}, {"w": "it", "b": [0.7041, 0.5625, 0.716, 0.5839]}, {"w": "returns", "b": [0.7217, 0.5625, 0.7824, 0.5839]}, {"w": "an", "b": [0.788, 0.5625, 0.8086, 0.5839]}, {"w": "array", "b": [0.8142, 0.5625, 0.8572, 0.5839]}, {"w": "containing", "b": [0.1429, 0.5815, 0.2325, 0.6029]}, {"w": "the", "b": [0.24, 0.5815, 0.2664, 0.6029]}, {"w": "top", "b": [0.2739, 0.5815, 0.3018, 0.6029]}, {"w": "K", "b": [0.3093, 0.5815, 0.3233, 0.6029]}, {"w": "predictions,", "b": [0.3308, 0.5815, 0.4301, 0.6029]}, {"w": "where", "b": [0.4376, 0.5815, 0.4884, 0.6029]}, {"w": "each", "b": [0.496, 0.5815, 0.5339, 0.6029]}, {"w": "prediction", "b": [0.5414, 0.5815, 0.6283, 0.6029]}, {"w": "is", "b": [0.6358, 0.5815, 0.649, 0.6029]}, {"w": "represented", "b": [0.6565, 0.5815, 0.7543, 0.6029]}, {"w": "as", "b": [0.7618, 0.5815, 0.7786, 0.6029]}, {"w": "an", "b": [0.7861, 0.5815, 0.8067, 0.6029]}, {"w": "array", "b": [0.8142, 0.5815, 0.8571, 0.6029]}, {"w": "containing", "b": [0.1429, 0.6006, 0.2325, 0.622]}, {"w": "the", "b": [0.2372, 0.6006, 0.2636, 0.622]}, {"w": "class", "b": [0.2683, 0.6006, 0.3068, 0.622]}, {"w": "identifier21,", "b": [0.3115, 0.6006, 0.4044, 0.622]}, {"w": "its", "b": [0.4092, 0.6006, 0.4287, 0.622]}, {"w": "name", "b": [0.4335, 0.6006, 0.4799, 0.622]}, {"w": "and", "b": [0.4847, 0.6006, 0.5162, 0.622]}, {"w": "the", "b": [0.5209, 0.6006, 0.5473, 0.622]}, {"w": "corresponding", "b": [0.552, 0.6006, 0.6741, 0.622]}, {"w": "confidence", "b": [0.6788, 0.6006, 0.7703, 0.622]}, {"w": "score:", "b": [0.775, 0.6006, 0.8234, 0.622]}]}, {"id": "b_9", "type": "paragraph", "text": "top_K = keras.applications.resnet50.decode_predictions(Y_proba, top=3) for image_index in range(len(images)): print(\"Image #{}\".format(image_index)) for class_id, name, y_proba in top_K[image_index]: print(\" {} - {:12s} {:.2f}%\".format(class_id, name, y_proba * 100)) print()", "words": [{"w": "top_K", "b": [0.1766, 0.6325, 0.2187, 0.6454]}, {"w": "=", "b": [0.2272, 0.6325, 0.2356, 0.6454]}, {"w": "keras.applications.resnet50.decode_predictions(Y_proba,", "b": [0.244, 0.6325, 0.7078, 0.6454]}, {"w": "top=3)", "b": [0.7163, 0.6325, 0.7669, 0.6454]}, {"w": "for", "b": [0.1766, 0.648, 0.2019, 0.6608]}, {"w": "image_index", "b": [0.2103, 0.648, 0.3031, 0.6608]}, {"w": "in", "b": [0.3115, 0.648, 0.3284, 0.6608]}, {"w": "range(len(images)):", "b": [0.3368, 0.648, 0.497, 0.6608]}, {"w": "print(\"Image", "b": [0.2103, 0.6634, 0.3115, 0.6762]}, {"w": "#{}\".format(image_index))", "b": [0.3199, 0.6634, 0.5308, 0.6762]}, {"w": "for", "b": [0.2103, 0.6788, 0.2356, 0.6916]}, {"w": "class_id,", "b": [0.244, 0.6788, 0.3199, 0.6916]}, {"w": "name,", "b": [0.3284, 0.6788, 0.3705, 0.6916]}, {"w": "y_proba", "b": [0.379, 0.6788, 0.438, 0.6916]}, {"w": "in", "b": [0.4464, 0.6788, 0.4633, 0.6916]}, {"w": "top_K[image_index]:", "b": [0.4717, 0.6788, 0.6319, 0.6916]}, {"w": "print(\"", "b": [0.244, 0.6942, 0.3031, 0.7071]}, {"w": "{}", "b": [0.3199, 0.6942, 0.3368, 0.7071]}, {"w": "-", "b": [0.3452, 0.6942, 0.3537, 0.7071]}, {"w": "{:12s}", "b": [0.3621, 0.6942, 0.4127, 0.7071]}, {"w": "{:.2f}%\".format(class_id,", "b": [0.4211, 0.6942, 0.6319, 0.7071]}, {"w": "name,", "b": [0.6404, 0.6942, 0.6825, 0.7071]}, {"w": "y_proba", "b": [0.691, 0.6942, 0.75, 0.7071]}, {"w": "*", "b": [0.7584, 0.6942, 0.7669, 0.7071]}, {"w": "100))", "b": [0.7753, 0.6942, 0.8175, 0.7071]}, {"w": "print()", "b": [0.2103, 0.7096, 0.2693, 0.7225]}]}, {"id": "b_10", "type": "paragraph", "text": "The output looks like this:", "words": [{"w": "The", "b": [0.1429, 0.7303, 0.1757, 0.7517]}, {"w": "output", "b": [0.1804, 0.7303, 0.2368, 0.7517]}, {"w": "looks", "b": [0.2415, 0.7303, 0.286, 0.7517]}, {"w": "like", "b": [0.2908, 0.7303, 0.3208, 0.7517]}, {"w": "this:", "b": [0.3255, 0.7303, 0.361, 0.7517]}]}, {"id": "b_11", "type": "paragraph", "text": "Image #0 n03877845 - palace 42.87% n02825657 - bell_cote 40.57% n03781244 - monastery 14.56%", "words": [{"w": "Image", "b": [0.1766, 0.7622, 0.2187, 0.7751]}, {"w": "#0", "b": [0.2272, 0.7622, 0.244, 0.7751]}, {"w": "n03877845", "b": [0.1935, 0.7777, 0.2693, 0.7905]}, {"w": "-", "b": [0.2778, 0.7777, 0.2862, 0.7905]}, {"w": "palace", "b": [0.2946, 0.7777, 0.3452, 0.7905]}, {"w": "42.87%", "b": [0.4043, 0.7777, 0.4549, 0.7905]}, {"w": "n02825657", "b": [0.1935, 0.7931, 0.2693, 0.8059]}, {"w": "-", "b": [0.2778, 0.7931, 0.2862, 0.8059]}, {"w": "bell_cote", "b": [0.2946, 0.7931, 0.3705, 0.8059]}, {"w": "40.57%", "b": [0.4043, 0.7931, 0.4549, 0.8059]}, {"w": "n03781244", "b": [0.1935, 0.8085, 0.2693, 0.8214]}, {"w": "-", "b": [0.2778, 0.8085, 0.2862, 0.8214]}, {"w": "monastery", "b": [0.2946, 0.8085, 0.3705, 0.8214]}, {"w": "14.56%", "b": [0.4043, 0.8085, 0.4549, 0.8214]}]}, {"id": "b_12", "type": "paragraph", "text": "466 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "466", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 493, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Image #1 n04522168 - vase 46.83% n07930864 - cup 7.78% n11939491 - daisy 4.87%", "words": [{"w": "Image", "b": [0.1766, 0.0983, 0.2188, 0.1112]}, {"w": "#1", "b": [0.2272, 0.0983, 0.244, 0.1112]}, {"w": "n04522168", "b": [0.1935, 0.1138, 0.2693, 0.1266]}, {"w": "-", "b": [0.2778, 0.1138, 0.2862, 0.1266]}, {"w": "vase", "b": [0.2946, 0.1138, 0.3284, 0.1266]}, {"w": "46.83%", "b": [0.4043, 0.1138, 0.4549, 0.1266]}, {"w": "n07930864", "b": [0.1935, 0.1292, 0.2693, 0.142]}, {"w": "-", "b": [0.2778, 0.1292, 0.2862, 0.142]}, {"w": "cup", "b": [0.2946, 0.1292, 0.3199, 0.142]}, {"w": "7.78%", "b": [0.4043, 0.1292, 0.4464, 0.142]}, {"w": "n11939491", "b": [0.1935, 0.1446, 0.2693, 0.1574]}, {"w": "-", "b": [0.2778, 0.1446, 0.2862, 0.1574]}, {"w": "daisy", "b": [0.2946, 0.1446, 0.3368, 0.1574]}, {"w": "4.87%", "b": [0.4043, 0.1446, 0.4464, 0.1574]}]}, {"id": "b_1", "type": "paragraph", "text": "The correct classes (monastery and daisy) appear in the top 3 results for both images. That’s pretty good considering that the model had to choose among 1,000 classes.", "words": [{"w": "The", "b": [0.1429, 0.1652, 0.1757, 0.1866]}, {"w": "correct", "b": [0.1808, 0.1652, 0.2397, 0.1866]}, {"w": "classes", "b": [0.2448, 0.1652, 0.2999, 0.1866]}, {"w": "(monastery", "b": [0.305, 0.1652, 0.4012, 0.1866]}, {"w": "and", "b": [0.4063, 0.1652, 0.4378, 0.1866]}, {"w": "daisy)", "b": [0.4429, 0.1652, 0.4931, 0.1866]}, {"w": "appear", "b": [0.4982, 0.1652, 0.5545, 0.1866]}, {"w": "in", "b": [0.5596, 0.1652, 0.5766, 0.1866]}, {"w": "the", "b": [0.5817, 0.1652, 0.608, 0.1866]}, {"w": "top", "b": [0.6131, 0.1652, 0.641, 0.1866]}, {"w": "3", "b": [0.6461, 0.1652, 0.6561, 0.1866]}, {"w": "results", "b": [0.6613, 0.1652, 0.7158, 0.1866]}, {"w": "for", "b": [0.7209, 0.1652, 0.7455, 0.1866]}, {"w": "both", "b": [0.7506, 0.1652, 0.7892, 0.1866]}, {"w": "images.", "b": [0.7944, 0.1652, 0.8572, 0.1866]}, {"w": "That’s", "b": [0.1429, 0.1843, 0.1917, 0.2057]}, {"w": "pretty", "b": [0.1964, 0.1843, 0.2462, 0.2057]}, {"w": "good", "b": [0.2509, 0.1843, 0.2929, 0.2057]}, {"w": "considering", "b": [0.2977, 0.1843, 0.396, 0.2057]}, {"w": "that", "b": [0.4008, 0.1843, 0.4333, 0.2057]}, {"w": "the", "b": [0.4381, 0.1843, 0.4644, 0.2057]}, {"w": "model", "b": [0.4691, 0.1843, 0.5219, 0.2057]}, {"w": "had", "b": [0.5267, 0.1843, 0.5579, 0.2057]}, {"w": "to", "b": [0.5627, 0.1843, 0.5797, 0.2057]}, {"w": "choose", "b": [0.5844, 0.1843, 0.6421, 0.2057]}, {"w": "among", "b": [0.6468, 0.1843, 0.7048, 0.2057]}, {"w": "1,000", "b": [0.7095, 0.1843, 0.7543, 0.2057]}, {"w": "classes.", "b": [0.759, 0.1843, 0.8188, 0.2057]}]}, {"id": "b_2", "type": "paragraph", "text": "As you can see, it is very easy to create a pretty good image classifier using a pre‐ trained model. Other vision models are available in keras.applications, including several ResNet variants, GoogLeNet variants like InceptionV3 and Xception, VGGNet variants, MobileNet and MobileNetV2 (lightweight models for use in mobile applications), and more.", "words": [{"w": "As", "b": [0.1429, 0.2124, 0.1649, 0.2338]}, {"w": "you", "b": [0.1723, 0.2124, 0.2035, 0.2338]}, {"w": "can", "b": [0.2109, 0.2124, 0.2402, 0.2338]}, {"w": "see,", "b": [0.2476, 0.2124, 0.2777, 0.2338]}, {"w": "it", "b": [0.2851, 0.2124, 0.297, 0.2338]}, {"w": "is", "b": [0.3044, 0.2124, 0.3176, 0.2338]}, {"w": "very", "b": [0.325, 0.2124, 0.3614, 0.2338]}, {"w": "easy", "b": [0.3687, 0.2124, 0.4039, 0.2338]}, {"w": "to", "b": [0.4113, 0.2124, 0.4283, 0.2338]}, {"w": "create", "b": [0.4356, 0.2124, 0.485, 0.2338]}, {"w": "a", "b": [0.4924, 0.2124, 0.5015, 0.2338]}, {"w": "pretty", "b": [0.5089, 0.2124, 0.5586, 0.2338]}, {"w": "good", "b": [0.566, 0.2124, 0.608, 0.2338]}, {"w": "image", "b": [0.6154, 0.2124, 0.6658, 0.2338]}, {"w": "classifier", "b": [0.6731, 0.2124, 0.7456, 0.2338]}, {"w": "using", "b": [0.7529, 0.2124, 0.7984, 0.2338]}, {"w": "a", "b": [0.8057, 0.2124, 0.8149, 0.2338]}, {"w": "pre‐", "b": [0.8222, 0.2124, 0.8571, 0.2338]}, {"w": "trained", "b": [0.1429, 0.2323, 0.2029, 0.2538]}, {"w": "model.", "b": [0.2094, 0.2323, 0.267, 0.2538]}, {"w": "Other", "b": [0.2735, 0.2323, 0.3231, 0.2538]}, {"w": "vision", "b": [0.3296, 0.2323, 0.38, 0.2538]}, {"w": "models", "b": [0.3865, 0.2323, 0.447, 0.2538]}, {"w": "are", "b": [0.4535, 0.2323, 0.4792, 0.2538]}, {"w": "available", "b": [0.4857, 0.2323, 0.558, 0.2538]}, {"w": "in", "b": [0.5645, 0.2323, 0.5814, 0.2538]}, {"w": "keras.applications,", "b": [0.5879, 0.2323, 0.7708, 0.2538]}, {"w": "including", "b": [0.7773, 0.2323, 0.8571, 0.2538]}, {"w": "several", "b": [0.1428, 0.2514, 0.2, 0.2728]}, {"w": "ResNet", "b": [0.2145, 0.2514, 0.2741, 0.2728]}, {"w": "variants,", "b": [0.2886, 0.2514, 0.3596, 0.2728]}, {"w": "GoogLeNet", "b": [0.3741, 0.2514, 0.4702, 0.2728]}, {"w": "variants", "b": [0.4847, 0.2514, 0.551, 0.2728]}, {"w": "like", "b": [0.5655, 0.2514, 0.5955, 0.2728]}, {"w": "InceptionV3", "b": [0.61, 0.2514, 0.7157, 0.2728]}, {"w": "and", "b": [0.7302, 0.2514, 0.7617, 0.2728]}, {"w": "Xception,", "b": [0.7762, 0.2514, 0.8571, 0.2728]}, {"w": "VGGNet", "b": [0.1429, 0.2704, 0.2167, 0.2918]}, {"w": "variants,", "b": [0.2284, 0.2704, 0.2994, 0.2918]}, {"w": "MobileNet", "b": [0.3111, 0.2704, 0.4002, 0.2918]}, {"w": "and", "b": [0.4118, 0.2704, 0.4434, 0.2918]}, {"w": "MobileNetV2", "b": [0.4551, 0.2704, 0.5688, 0.2918]}, {"w": "(lightweight", "b": [0.5805, 0.2704, 0.6809, 0.2918]}, {"w": "models", "b": [0.6926, 0.2704, 0.7531, 0.2918]}, {"w": "for", "b": [0.7647, 0.2704, 0.7893, 0.2918]}, {"w": "use", "b": [0.8009, 0.2704, 0.8285, 0.2918]}, {"w": "in", "b": [0.8402, 0.2704, 0.8571, 0.2918]}, {"w": "mobile", "b": [0.1429, 0.2895, 0.2008, 0.3109]}, {"w": "applications),", "b": [0.2056, 0.2895, 0.3181, 0.3109]}, {"w": "and", "b": [0.3229, 0.2895, 0.3544, 0.3109]}, {"w": "more.", "b": [0.3591, 0.2895, 0.4081, 0.3109]}]}, {"id": "b_3", "type": "paragraph", "text": "But what if you want to use an image classifier for classes of images that are not part of ImageNet? In that case, you may still benefit from the pretrained models to per‐ form transfer learning.", "words": [{"w": "But", "b": [0.1429, 0.3176, 0.1725, 0.339]}, {"w": "what", "b": [0.1782, 0.3176, 0.2187, 0.339]}, {"w": "if", "b": [0.2245, 0.3176, 0.2362, 0.339]}, {"w": "you", "b": [0.2419, 0.3176, 0.2732, 0.339]}, {"w": "want", "b": [0.2789, 0.3176, 0.3197, 0.339]}, {"w": "to", "b": [0.3254, 0.3176, 0.3424, 0.339]}, {"w": "use", "b": [0.3481, 0.3176, 0.3757, 0.339]}, {"w": "an", "b": [0.3814, 0.3176, 0.4019, 0.339]}, {"w": "image", "b": [0.4076, 0.3176, 0.458, 0.339]}, {"w": "classifier", "b": [0.4637, 0.3176, 0.5362, 0.339]}, {"w": "for", "b": [0.5419, 0.3176, 0.5664, 0.339]}, {"w": "classes", "b": [0.5721, 0.3176, 0.6272, 0.339]}, {"w": "of", "b": [0.6329, 0.3176, 0.6497, 0.339]}, {"w": "images", "b": [0.6554, 0.3176, 0.7134, 0.339]}, {"w": "that", "b": [0.7192, 0.3176, 0.7517, 0.339]}, {"w": "are", "b": [0.7575, 0.3176, 0.7832, 0.339]}, {"w": "not", "b": [0.7889, 0.3176, 0.8173, 0.339]}, {"w": "part", "b": [0.823, 0.3176, 0.8571, 0.339]}, {"w": "of", "b": [0.1429, 0.3366, 0.1596, 0.3581]}, {"w": "ImageNet?", "b": [0.1664, 0.3366, 0.2564, 0.3581]}, {"w": "In", "b": [0.2632, 0.3366, 0.2817, 0.3581]}, {"w": "that", "b": [0.2884, 0.3366, 0.321, 0.3581]}, {"w": "case,", "b": [0.3278, 0.3366, 0.367, 0.3581]}, {"w": "you", "b": [0.3738, 0.3366, 0.405, 0.3581]}, {"w": "may", "b": [0.4118, 0.3366, 0.4472, 0.3581]}, {"w": "still", "b": [0.454, 0.3366, 0.4841, 0.3581]}, {"w": "benefit", "b": [0.4909, 0.3366, 0.5487, 0.3581]}, {"w": "from", "b": [0.5554, 0.3366, 0.597, 0.3581]}, {"w": "the", "b": [0.6038, 0.3366, 0.6301, 0.3581]}, {"w": "pretrained", "b": [0.6369, 0.3366, 0.7245, 0.3581]}, {"w": "models", "b": [0.7312, 0.3366, 0.7917, 0.3581]}, {"w": "to", "b": [0.7985, 0.3366, 0.8154, 0.3581]}, {"w": "per‐", "b": [0.8222, 0.3366, 0.8571, 0.3581]}, {"w": "form", "b": [0.1429, 0.3557, 0.1844, 0.3771]}, {"w": "transfer", "b": [0.1892, 0.3557, 0.2542, 0.3771]}, {"w": "learning.", "b": [0.2589, 0.3557, 0.3328, 0.3771]}]}, {"id": "b_4", "type": "paragraph", "text": "Pretrained Models for Transfer Learning", "words": [{"w": "Pretrained", "b": [0.1429, 0.3901, 0.2747, 0.4244]}, {"w": "Models", "b": [0.2806, 0.3901, 0.3694, 0.4244]}, {"w": "for", "b": [0.3754, 0.3901, 0.4108, 0.4244]}, {"w": "Transfer", "b": [0.4167, 0.3901, 0.5186, 0.4244]}, {"w": "Learning", "b": [0.5245, 0.3901, 0.6343, 0.4244]}]}, {"id": "b_5", "type": "paragraph", "text": "If you want to build an image classifier, but you do not have enough training data, then it is often a good idea to reuse the lower layers of a pretrained model, as we dis‐ cussed in Chapter 11. For example, let’s train a model to classify pictures of flowers, reusing a pretrained Xception model. First, let’s load the dataset using TensorFlow Datasets (see Chapter 13):", "words": [{"w": "If", "b": [0.1429, 0.4313, 0.1561, 0.4527]}, {"w": "you", "b": [0.1631, 0.4313, 0.1943, 0.4527]}, {"w": "want", "b": [0.2013, 0.4313, 0.2421, 0.4527]}, {"w": "to", "b": [0.249, 0.4313, 0.266, 0.4527]}, {"w": "build", "b": [0.273, 0.4313, 0.3165, 0.4527]}, {"w": "an", "b": [0.3234, 0.4313, 0.3439, 0.4527]}, {"w": "image", "b": [0.3509, 0.4313, 0.4013, 0.4527]}, {"w": "classifier,", "b": [0.4082, 0.4313, 0.4841, 0.4527]}, {"w": "but", "b": [0.4911, 0.4313, 0.5191, 0.4527]}, {"w": "you", "b": [0.526, 0.4313, 0.5573, 0.4527]}, {"w": "do", "b": [0.5642, 0.4313, 0.5859, 0.4527]}, {"w": "not", "b": [0.5928, 0.4313, 0.6212, 0.4527]}, {"w": "have", "b": [0.6281, 0.4313, 0.6665, 0.4527]}, {"w": "enough", "b": [0.6735, 0.4313, 0.7363, 0.4527]}, {"w": "training", "b": [0.7433, 0.4313, 0.8102, 0.4527]}, {"w": "data,", "b": [0.8171, 0.4313, 0.8571, 0.4527]}, {"w": "then", "b": [0.1429, 0.4503, 0.1806, 0.4717]}, {"w": "it", "b": [0.186, 0.4503, 0.1979, 0.4717]}, {"w": "is", "b": [0.2034, 0.4503, 0.2166, 0.4717]}, {"w": "often", "b": [0.222, 0.4503, 0.2654, 0.4717]}, {"w": "a", "b": [0.2708, 0.4503, 0.28, 0.4717]}, {"w": "good", "b": [0.2854, 0.4503, 0.3274, 0.4717]}, {"w": "idea", "b": [0.3328, 0.4503, 0.3674, 0.4717]}, {"w": "to", "b": [0.3728, 0.4503, 0.3898, 0.4717]}, {"w": "reuse", "b": [0.3952, 0.4503, 0.4394, 0.4717]}, {"w": "the", "b": [0.4448, 0.4503, 0.4711, 0.4717]}, {"w": "lower", "b": [0.4766, 0.4503, 0.5233, 0.4717]}, {"w": "layers", "b": [0.5287, 0.4503, 0.5766, 0.4717]}, {"w": "of", "b": [0.582, 0.4503, 0.5988, 0.4717]}, {"w": "a", "b": [0.6042, 0.4503, 0.6133, 0.4717]}, {"w": "pretrained", "b": [0.6188, 0.4503, 0.7063, 0.4717]}, {"w": "model,", "b": [0.7118, 0.4503, 0.7693, 0.4717]}, {"w": "as", "b": [0.7747, 0.4503, 0.7915, 0.4717]}, {"w": "we", "b": [0.797, 0.4503, 0.8201, 0.4717]}, {"w": "dis‐", "b": [0.8255, 0.4503, 0.8571, 0.4717]}, {"w": "cussed", "b": [0.1429, 0.4694, 0.1979, 0.4908]}, {"w": "in", "b": [0.2042, 0.4694, 0.2211, 0.4908]}, {"w": "Chapter", "b": [0.2274, 0.4694, 0.295, 0.4908]}, {"w": "11.", "b": [0.3013, 0.4694, 0.3261, 0.4908]}, {"w": "For", "b": [0.3323, 0.4694, 0.3613, 0.4908]}, {"w": "example,", "b": [0.3676, 0.4694, 0.4419, 0.4908]}, {"w": "let’s", "b": [0.4482, 0.4694, 0.4784, 0.4908]}, {"w": "train", "b": [0.4847, 0.4694, 0.5249, 0.4908]}, {"w": "a", "b": [0.5312, 0.4694, 0.5404, 0.4908]}, {"w": "model", "b": [0.5466, 0.4694, 0.5995, 0.4908]}, {"w": "to", "b": [0.6057, 0.4694, 0.6227, 0.4908]}, {"w": "classify", "b": [0.629, 0.4694, 0.6892, 0.4908]}, {"w": "pictures", "b": [0.6955, 0.4694, 0.7625, 0.4908]}, {"w": "of", "b": [0.7687, 0.4694, 0.7855, 0.4908]}, {"w": "flowers,", "b": [0.7918, 0.4694, 0.8571, 0.4908]}, {"w": "reusing", "b": [0.1429, 0.4884, 0.2049, 0.5098]}, {"w": "a", "b": [0.2126, 0.4884, 0.2217, 0.5098]}, {"w": "pretrained", "b": [0.2294, 0.4884, 0.3169, 0.5098]}, {"w": "Xception", "b": [0.3246, 0.4884, 0.4008, 0.5098]}, {"w": "model.", "b": [0.4084, 0.4884, 0.466, 0.5098]}, {"w": "First,", "b": [0.4737, 0.4884, 0.5167, 0.5098]}, {"w": "let’s", "b": [0.5244, 0.4884, 0.5546, 0.5098]}, {"w": "load", "b": [0.5623, 0.4884, 0.5984, 0.5098]}, {"w": "the", "b": [0.606, 0.4884, 0.6324, 0.5098]}, {"w": "dataset", "b": [0.64, 0.4884, 0.6981, 0.5098]}, {"w": "using", "b": [0.7058, 0.4884, 0.7512, 0.5098]}, {"w": "TensorFlow", "b": [0.7589, 0.4884, 0.8572, 0.5098]}, {"w": "Datasets", "b": [0.1429, 0.5075, 0.2129, 0.5289]}, {"w": "(see", "b": [0.2177, 0.5075, 0.2502, 0.5289]}, {"w": "Chapter", "b": [0.2549, 0.5075, 0.3225, 0.5289]}, {"w": "13):", "b": [0.3273, 0.5075, 0.3592, 0.5289]}]}, {"id": "b_6", "type": "equation", "text": "import tensorflow_datasets as tfds", "words": [{"w": "import", "b": [0.1766, 0.5394, 0.2272, 0.5523]}, {"w": "tensorflow_datasets", "b": [0.2356, 0.5394, 0.3958, 0.5523]}, {"w": "as", "b": [0.4043, 0.5394, 0.4211, 0.5523]}, {"w": "tfds", "b": [0.4296, 0.5394, 0.4633, 0.5523]}]}, {"id": "b_7", "type": "paragraph", "text": "dataset, info = tfds.load(\"tf_flowers\", as_supervised=True, with_info=True) dataset_size = info.splits[\"train\"].num_examples # 3670 class_names = info.features[\"label\"].names # [\"dandelion\", \"daisy\", ...] n_classes = info.features[\"label\"].num_classes # 5", "words": [{"w": "dataset,", "b": [0.1766, 0.5703, 0.244, 0.5831]}, {"w": "info", "b": [0.2525, 0.5703, 0.2862, 0.5831]}, {"w": "=", "b": [0.2946, 0.5703, 0.3031, 0.5831]}, {"w": "tfds.load(\"tf_flowers\",", "b": [0.3115, 0.5703, 0.5055, 0.5831]}, {"w": "as_supervised=True,", "b": [0.5139, 0.5703, 0.6741, 0.5831]}, {"w": "with_info=True)", "b": [0.6825, 0.5703, 0.809, 0.5831]}, {"w": "dataset_size", "b": [0.1766, 0.5857, 0.2778, 0.5986]}, {"w": "=", "b": [0.2862, 0.5857, 0.2946, 0.5986]}, {"w": "info.splits[\"train\"].num_examples", "b": [0.3031, 0.5857, 0.5813, 0.5986]}, {"w": "#", "b": [0.5898, 0.5857, 0.5982, 0.5986]}, {"w": "3670", "b": [0.6066, 0.5857, 0.6404, 0.5986]}, {"w": "class_names", "b": [0.1766, 0.6011, 0.2693, 0.614]}, {"w": "=", "b": [0.2778, 0.6011, 0.2862, 0.614]}, {"w": "info.features[\"label\"].names", "b": [0.2946, 0.6011, 0.5308, 0.614]}, {"w": "#", "b": [0.5392, 0.6011, 0.5476, 0.614]}, {"w": "[\"dandelion\",", "b": [0.556, 0.6011, 0.6657, 0.614]}, {"w": "\"daisy\",", "b": [0.6741, 0.6011, 0.7416, 0.614]}, {"w": "...]", "b": [0.75, 0.6011, 0.7837, 0.614]}, {"w": "n_classes", "b": [0.1766, 0.6165, 0.2525, 0.6294]}, {"w": "=", "b": [0.2609, 0.6165, 0.2693, 0.6294]}, {"w": "info.features[\"label\"].num_classes", "b": [0.2778, 0.6165, 0.5645, 0.6294]}, {"w": "#", "b": [0.5729, 0.6165, 0.5813, 0.6294]}, {"w": "5", "b": [0.5898, 0.6165, 0.5982, 0.6294]}]}, {"id": "b_8", "type": "paragraph", "text": "Note that you can get information about the dataset by setting with_info=True. Here, we get the dataset size and the names of the classes. Unfortunately, there is only a \"train\" dataset, no test set or validation set, so we need to split the training set. The TF Datasets project provides an API for this. For example, let’s take the first 10% of the dataset for testing, the next 15% for validation, and the remaining 75% for train‐ ing:", "words": [{"w": "Note", "b": [0.1429, 0.6381, 0.1836, 0.6595]}, {"w": "that", "b": [0.1884, 0.6381, 0.221, 0.6595]}, {"w": "you", "b": [0.2257, 0.6381, 0.2569, 0.6595]}, {"w": "can", "b": [0.2617, 0.6381, 0.291, 0.6595]}, {"w": "get", "b": [0.2958, 0.6381, 0.3207, 0.6595]}, {"w": "information", "b": [0.3254, 0.6381, 0.4267, 0.6595]}, {"w": "about", "b": [0.4314, 0.6381, 0.4792, 0.6595]}, {"w": "the", "b": [0.4839, 0.6381, 0.5103, 0.6595]}, {"w": "dataset", "b": [0.515, 0.6381, 0.5731, 0.6595]}, {"w": "by", "b": [0.5778, 0.6381, 0.598, 0.6595]}, {"w": "setting", "b": [0.6027, 0.6381, 0.6586, 0.6595]}, {"w": "with_info=True.", "b": [0.6635, 0.6381, 0.8068, 0.6595]}, {"w": "Here,", "b": [0.8115, 0.6381, 0.8571, 0.6595]}, {"w": "we", "b": [0.1428, 0.6571, 0.166, 0.6785]}, {"w": "get", "b": [0.1735, 0.6571, 0.1984, 0.6785]}, {"w": "the", "b": [0.206, 0.6571, 0.2323, 0.6785]}, {"w": "dataset", "b": [0.2398, 0.6571, 0.2979, 0.6785]}, {"w": "size", "b": [0.3054, 0.6571, 0.3363, 0.6785]}, {"w": "and", "b": [0.3438, 0.6571, 0.3753, 0.6785]}, {"w": "the", "b": [0.3828, 0.6571, 0.4092, 0.6785]}, {"w": "names", "b": [0.4167, 0.6571, 0.4708, 0.6785]}, {"w": "of", "b": [0.4783, 0.6571, 0.4951, 0.6785]}, {"w": "the", "b": [0.5026, 0.6571, 0.5289, 0.6785]}, {"w": "classes.", "b": [0.5365, 0.6571, 0.5962, 0.6785]}, {"w": "Unfortunately,", "b": [0.6037, 0.6571, 0.7249, 0.6785]}, {"w": "there", "b": [0.7324, 0.6571, 0.7754, 0.6785]}, {"w": "is", "b": [0.7829, 0.6571, 0.7961, 0.6785]}, {"w": "only", "b": [0.8036, 0.6571, 0.8405, 0.6785]}, {"w": "a", "b": [0.848, 0.6571, 0.8571, 0.6785]}, {"w": "\"train\"", "b": [0.1429, 0.6802, 0.2121, 0.6953]}, {"w": "dataset,", "b": [0.2178, 0.6771, 0.2807, 0.6985]}, {"w": "no", "b": [0.2863, 0.6771, 0.3084, 0.6985]}, {"w": "test", "b": [0.314, 0.6771, 0.3432, 0.6985]}, {"w": "set", "b": [0.3489, 0.6771, 0.3718, 0.6985]}, {"w": "or", "b": [0.3774, 0.6771, 0.3958, 0.6985]}, {"w": "validation", "b": [0.4015, 0.6771, 0.4848, 0.6985]}, {"w": "set,", "b": [0.4905, 0.6771, 0.5181, 0.6985]}, {"w": "so", "b": [0.5238, 0.6771, 0.542, 0.6985]}, {"w": "we", "b": [0.5477, 0.6771, 0.5708, 0.6985]}, {"w": "need", "b": [0.5765, 0.6771, 0.6166, 0.6985]}, {"w": "to", "b": [0.6223, 0.6771, 0.6393, 0.6985]}, {"w": "split", "b": [0.645, 0.6771, 0.6807, 0.6985]}, {"w": "the", "b": [0.6864, 0.6771, 0.7127, 0.6985]}, {"w": "training", "b": [0.7184, 0.6771, 0.7854, 0.6985]}, {"w": "set.", "b": [0.791, 0.6771, 0.8186, 0.6985]}, {"w": "The", "b": [0.8243, 0.6771, 0.8571, 0.6985]}, {"w": "TF", "b": [0.1428, 0.6961, 0.1667, 0.7175]}, {"w": "Datasets", "b": [0.1731, 0.6961, 0.2431, 0.7175]}, {"w": "project", "b": [0.2495, 0.6961, 0.3081, 0.7175]}, {"w": "provides", "b": [0.3145, 0.6961, 0.3865, 0.7175]}, {"w": "an", "b": [0.3929, 0.6961, 0.4134, 0.7175]}, {"w": "API", "b": [0.4198, 0.6961, 0.453, 0.7175]}, {"w": "for", "b": [0.4594, 0.6961, 0.4839, 0.7175]}, {"w": "this.", "b": [0.4902, 0.6961, 0.5257, 0.7175]}, {"w": "For", "b": [0.5321, 0.6961, 0.561, 0.7175]}, {"w": "example,", "b": [0.5674, 0.6961, 0.6417, 0.7175]}, {"w": "let’s", "b": [0.6481, 0.6961, 0.6783, 0.7175]}, {"w": "take", "b": [0.6846, 0.6961, 0.7193, 0.7175]}, {"w": "the", "b": [0.7257, 0.6961, 0.752, 0.7175]}, {"w": "first", "b": [0.7584, 0.6961, 0.7919, 0.7175]}, {"w": "10%", "b": [0.7982, 0.6961, 0.834, 0.7175]}, {"w": "of", "b": [0.8403, 0.6961, 0.8571, 0.7175]}, {"w": "the", "b": [0.1429, 0.7152, 0.1692, 0.7366]}, {"w": "dataset", "b": [0.175, 0.7152, 0.2331, 0.7366]}, {"w": "for", "b": [0.2389, 0.7152, 0.2634, 0.7366]}, {"w": "testing,", "b": [0.2692, 0.7152, 0.3299, 0.7366]}, {"w": "the", "b": [0.3357, 0.7152, 0.362, 0.7366]}, {"w": "next", "b": [0.3679, 0.7152, 0.4043, 0.7366]}, {"w": "15%", "b": [0.4101, 0.7152, 0.4458, 0.7366]}, {"w": "for", "b": [0.4516, 0.7152, 0.4762, 0.7366]}, {"w": "validation,", "b": [0.482, 0.7152, 0.5701, 0.7366]}, {"w": "and", "b": [0.5759, 0.7152, 0.6074, 0.7366]}, {"w": "the", "b": [0.6132, 0.7152, 0.6395, 0.7366]}, {"w": "remaining", "b": [0.6453, 0.7152, 0.7318, 0.7366]}, {"w": "75%", "b": [0.7376, 0.7152, 0.7734, 0.7366]}, {"w": "for", "b": [0.7792, 0.7152, 0.8037, 0.7366]}, {"w": "train‐", "b": [0.8095, 0.7152, 0.8571, 0.7366]}, {"w": "ing:", "b": [0.1429, 0.7342, 0.1743, 0.7556]}]}, {"id": "b_9", "type": "equation", "text": "test_split, valid_split, train_split = tfds.Split.TRAIN.subsplit([10, 15, 75])", "words": [{"w": "test_split,", "b": [0.1766, 0.7662, 0.2693, 0.779]}, {"w": "valid_split,", "b": [0.2778, 0.7662, 0.379, 0.779]}, {"w": "train_split", "b": [0.3874, 0.7662, 0.4802, 0.779]}, {"w": "=", "b": [0.4886, 0.7662, 0.497, 0.779]}, {"w": "tfds.Split.TRAIN.subsplit([10,", "b": [0.5054, 0.7662, 0.7584, 0.779]}, {"w": "15,", "b": [0.7669, 0.7662, 0.7922, 0.779]}, {"w": "75])", "b": [0.8006, 0.7662, 0.8343, 0.779]}]}, {"id": "b_10", "type": "paragraph", "text": "test_set = tfds.load(\"tf_flowers\", split=test_split, as_supervised=True) valid_set = tfds.load(\"tf_flowers\", split=valid_split, as_supervised=True) train_set = tfds.load(\"tf_flowers\", split=train_split, as_supervised=True)", "words": [{"w": "test_set", "b": [0.1766, 0.797, 0.244, 0.8099]}, {"w": "=", "b": [0.2525, 0.797, 0.2609, 0.8099]}, {"w": "tfds.load(\"tf_flowers\",", "b": [0.2693, 0.797, 0.4633, 0.8099]}, {"w": "split=test_split,", "b": [0.4717, 0.797, 0.6151, 0.8099]}, {"w": "as_supervised=True)", "b": [0.6235, 0.797, 0.7837, 0.8099]}, {"w": "valid_set", "b": [0.1766, 0.8124, 0.2525, 0.8253]}, {"w": "=", "b": [0.2609, 0.8124, 0.2693, 0.8253]}, {"w": "tfds.load(\"tf_flowers\",", "b": [0.2778, 0.8124, 0.4717, 0.8253]}, {"w": "split=valid_split,", "b": [0.4802, 0.8124, 0.6319, 0.8253]}, {"w": "as_supervised=True)", "b": [0.6404, 0.8124, 0.8006, 0.8253]}, {"w": "train_set", "b": [0.1766, 0.8279, 0.2525, 0.8407]}, {"w": "=", "b": [0.2609, 0.8279, 0.2693, 0.8407]}, {"w": "tfds.load(\"tf_flowers\",", "b": [0.2778, 0.8279, 0.4717, 0.8407]}, {"w": "split=train_split,", "b": [0.4802, 0.8279, 0.6319, 0.8407]}, {"w": "as_supervised=True)", "b": [0.6404, 0.8279, 0.8006, 0.8407]}]}, {"id": "b_11", "type": "paragraph", "text": "Pretrained Models for Transfer Learning | 467", "words": [{"w": "Pretrained", "b": [0.562, 0.9225, 0.6247, 0.9388]}, {"w": "Models", "b": [0.6276, 0.9225, 0.6698, 0.9388]}, {"w": "for", "b": [0.6726, 0.9225, 0.6895, 0.9388]}, {"w": "Transfer", "b": [0.6923, 0.9225, 0.7408, 0.9388]}, {"w": "Learning", "b": [0.7436, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "467", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 494, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "Next we must preprocess the images. The CNN expects 224 × 224 images, so we need to resize them. We also need to run the image through Xception’s prepro cess_input() function:", "words": [{"w": "Next", "b": [0.1429, 0.0791, 0.1829, 0.1005]}, {"w": "we", "b": [0.1879, 0.0791, 0.211, 0.1005]}, {"w": "must", "b": [0.216, 0.0791, 0.2577, 0.1005]}, {"w": "preprocess", "b": [0.2628, 0.0791, 0.3525, 0.1005]}, {"w": "the", "b": [0.3575, 0.0791, 0.3839, 0.1005]}, {"w": "images.", "b": [0.3889, 0.0791, 0.4517, 0.1005]}, {"w": "The", "b": [0.4567, 0.0791, 0.4895, 0.1005]}, {"w": "CNN", "b": [0.4945, 0.0791, 0.5393, 0.1005]}, {"w": "expects", "b": [0.5444, 0.0791, 0.6056, 0.1005]}, {"w": "224", "b": [0.6107, 0.0791, 0.6407, 0.1005]}, {"w": "×", "b": [0.6457, 0.0791, 0.6578, 0.1005]}, {"w": "224", "b": [0.6628, 0.0791, 0.6928, 0.1005]}, {"w": "images,", "b": [0.6978, 0.0791, 0.7606, 0.1005]}, {"w": "so", "b": [0.7656, 0.0791, 0.7839, 0.1005]}, {"w": "we", "b": [0.7889, 0.0791, 0.812, 0.1005]}, {"w": "need", "b": [0.817, 0.0791, 0.8571, 0.1005]}, {"w": "to", "b": [0.1429, 0.099, 0.1598, 0.1204]}, {"w": "resize", "b": [0.173, 0.099, 0.2204, 0.1204]}, {"w": "them.", "b": [0.2336, 0.099, 0.2817, 0.1204]}, {"w": "We", "b": [0.2949, 0.099, 0.322, 0.1204]}, {"w": "also", "b": [0.3351, 0.099, 0.3678, 0.1204]}, {"w": "need", "b": [0.381, 0.099, 0.4211, 0.1204]}, {"w": "to", "b": [0.4343, 0.099, 0.4513, 0.1204]}, {"w": "run", "b": [0.4644, 0.099, 0.4946, 0.1204]}, {"w": "the", "b": [0.5078, 0.099, 0.5341, 0.1204]}, {"w": "image", "b": [0.5473, 0.099, 0.5977, 0.1204]}, {"w": "through", "b": [0.6109, 0.099, 0.6786, 0.1204]}, {"w": "Xception’s", "b": [0.6918, 0.099, 0.7766, 0.1204]}, {"w": "prepro", "b": [0.7897, 0.1022, 0.8491, 0.1173]}, {"w": "cess_input()", "b": [0.1429, 0.1221, 0.2616, 0.1372]}, {"w": "function:", "b": [0.2663, 0.119, 0.3425, 0.1404]}]}, {"id": "b_1", "type": "paragraph", "text": "def preprocess(image, label): resized_image = tf.image.resize(image, [224, 224]) final_image = keras.applications.xception.preprocess_input(resized_image) return final_image, label", "words": [{"w": "def", "b": [0.1766, 0.1509, 0.2019, 0.1638]}, {"w": "preprocess(image,", "b": [0.2103, 0.1509, 0.3537, 0.1638]}, {"w": "label):", "b": [0.3621, 0.1509, 0.4211, 0.1638]}, {"w": "resized_image", "b": [0.2103, 0.1663, 0.3199, 0.1792]}, {"w": "=", "b": [0.3284, 0.1663, 0.3368, 0.1792]}, {"w": "tf.image.resize(image,", "b": [0.3452, 0.1663, 0.5308, 0.1792]}, {"w": "[224,", "b": [0.5392, 0.1663, 0.5814, 0.1792]}, {"w": "224])", "b": [0.5898, 0.1663, 0.6319, 0.1792]}, {"w": "final_image", "b": [0.2103, 0.1818, 0.3031, 0.1946]}, {"w": "=", "b": [0.3115, 0.1818, 0.3199, 0.1946]}, {"w": "keras.applications.xception.preprocess_input(resized_image)", "b": [0.3284, 0.1818, 0.8259, 0.1946]}, {"w": "return", "b": [0.2103, 0.1972, 0.2609, 0.21]}, {"w": "final_image,", "b": [0.2693, 0.1972, 0.3705, 0.21]}, {"w": "label", "b": [0.379, 0.1972, 0.4211, 0.21]}]}, {"id": "b_2", "type": "paragraph", "text": "Let’s apply this preprocessing function to all 3 datasets, and let’s also shuffle & repeat the training set, and add batching & prefetching to all datasets:", "words": [{"w": "Let’s", "b": [0.1429, 0.2178, 0.179, 0.2392]}, {"w": "apply", "b": [0.1848, 0.2178, 0.2302, 0.2392]}, {"w": "this", "b": [0.2359, 0.2178, 0.2666, 0.2392]}, {"w": "preprocessing", "b": [0.2724, 0.2178, 0.3888, 0.2392]}, {"w": "function", "b": [0.3946, 0.2178, 0.466, 0.2392]}, {"w": "to", "b": [0.4717, 0.2178, 0.4887, 0.2392]}, {"w": "all", "b": [0.4944, 0.2178, 0.5141, 0.2392]}, {"w": "3", "b": [0.5198, 0.2178, 0.5298, 0.2392]}, {"w": "datasets,", "b": [0.5356, 0.2178, 0.6061, 0.2392]}, {"w": "and", "b": [0.6118, 0.2178, 0.6434, 0.2392]}, {"w": "let’s", "b": [0.6491, 0.2178, 0.6793, 0.2392]}, {"w": "also", "b": [0.6851, 0.2178, 0.7178, 0.2392]}, {"w": "shuffle", "b": [0.7235, 0.2178, 0.7794, 0.2392]}, {"w": "&", "b": [0.7851, 0.2178, 0.8, 0.2392]}, {"w": "repeat", "b": [0.8057, 0.2178, 0.8571, 0.2392]}, {"w": "the", "b": [0.1429, 0.2369, 0.1692, 0.2583]}, {"w": "training", "b": [0.1739, 0.2369, 0.2409, 0.2583]}, {"w": "set,", "b": [0.2456, 0.2369, 0.2732, 0.2583]}, {"w": "and", "b": [0.2779, 0.2369, 0.3095, 0.2583]}, {"w": "add", "b": [0.3142, 0.2369, 0.3453, 0.2583]}, {"w": "batching", "b": [0.3501, 0.2369, 0.4224, 0.2583]}, {"w": "&", "b": [0.4271, 0.2369, 0.442, 0.2583]}, {"w": "prefetching", "b": [0.4467, 0.2369, 0.5422, 0.2583]}, {"w": "to", "b": [0.547, 0.2369, 0.5639, 0.2583]}, {"w": "all", "b": [0.5687, 0.2369, 0.5884, 0.2583]}, {"w": "datasets:", "b": [0.5931, 0.2369, 0.6636, 0.2583]}]}, {"id": "b_3", "type": "paragraph", "text": "batch_size = 32 train_set = train_set.shuffle(1000).repeat() train_set = train_set.map(preprocess).batch(batch_size).prefetch(1) valid_set = valid_set.map(preprocess).batch(batch_size).prefetch(1) test_set = test_set.map(preprocess).batch(batch_size).prefetch(1)", "words": [{"w": "batch_size", "b": [0.1766, 0.2688, 0.2609, 0.2817]}, {"w": "=", "b": [0.2693, 0.2688, 0.2778, 0.2817]}, {"w": "32", "b": [0.2862, 0.2688, 0.3031, 0.2817]}, {"w": "train_set", "b": [0.1766, 0.2843, 0.2525, 0.2971]}, {"w": "=", "b": [0.2609, 0.2843, 0.2693, 0.2971]}, {"w": "train_set.shuffle(1000).repeat()", "b": [0.2778, 0.2843, 0.5476, 0.2971]}, {"w": "train_set", "b": [0.1766, 0.2997, 0.2525, 0.3125]}, {"w": "=", "b": [0.2609, 0.2997, 0.2693, 0.3125]}, {"w": "train_set.map(preprocess).batch(batch_size).prefetch(1)", "b": [0.2778, 0.2997, 0.7416, 0.3125]}, {"w": "valid_set", "b": [0.1766, 0.3151, 0.2525, 0.3279]}, {"w": "=", "b": [0.2609, 0.3151, 0.2693, 0.3279]}, {"w": "valid_set.map(preprocess).batch(batch_size).prefetch(1)", "b": [0.2778, 0.3151, 0.7416, 0.3279]}, {"w": "test_set", "b": [0.1766, 0.3305, 0.2441, 0.3434]}, {"w": "=", "b": [0.2525, 0.3305, 0.2609, 0.3434]}, {"w": "test_set.map(preprocess).batch(batch_size).prefetch(1)", "b": [0.2693, 0.3305, 0.7247, 0.3434]}]}, {"id": "b_4", "type": "paragraph", "text": "If you want to perform some data augmentation, you can just change the preprocess‐ ing function for the training set, adding some random transformations to the training images. For example, use tf.image.random_crop() to randomly crop the images, use tf.image.random_flip_left_right() to randomly flip the images horizontally, and so on (see the notebook for an example).", "words": [{"w": "If", "b": [0.1429, 0.3511, 0.1561, 0.3726]}, {"w": "you", "b": [0.1615, 0.3511, 0.1927, 0.3726]}, {"w": "want", "b": [0.1981, 0.3511, 0.2389, 0.3726]}, {"w": "to", "b": [0.2442, 0.3511, 0.2612, 0.3726]}, {"w": "perform", "b": [0.2666, 0.3511, 0.3356, 0.3726]}, {"w": "some", "b": [0.341, 0.3511, 0.3852, 0.3726]}, {"w": "data", "b": [0.3905, 0.3511, 0.4258, 0.3726]}, {"w": "augmentation,", "b": [0.4311, 0.3511, 0.5514, 0.3726]}, {"w": "you", "b": [0.5568, 0.3511, 0.588, 0.3726]}, {"w": "can", "b": [0.5934, 0.3511, 0.6228, 0.3726]}, {"w": "just", "b": [0.6281, 0.3511, 0.6585, 0.3726]}, {"w": "change", "b": [0.6639, 0.3511, 0.7229, 0.3726]}, {"w": "the", "b": [0.7283, 0.3511, 0.7546, 0.3726]}, {"w": "preprocess‐", "b": [0.76, 0.3511, 0.8571, 0.3726]}, {"w": "ing", "b": [0.1429, 0.3702, 0.1696, 0.3916]}, {"w": "function", "b": [0.1743, 0.3702, 0.2457, 0.3916]}, {"w": "for", "b": [0.2505, 0.3702, 0.275, 0.3916]}, {"w": "the", "b": [0.2797, 0.3702, 0.306, 0.3916]}, {"w": "training", "b": [0.3108, 0.3702, 0.3777, 0.3916]}, {"w": "set,", "b": [0.3824, 0.3702, 0.41, 0.3916]}, {"w": "adding", "b": [0.4148, 0.3702, 0.4726, 0.3916]}, {"w": "some", "b": [0.4774, 0.3702, 0.5216, 0.3916]}, {"w": "random", "b": [0.5263, 0.3702, 0.5932, 0.3916]}, {"w": "transformations", "b": [0.598, 0.3702, 0.7322, 0.3916]}, {"w": "to", "b": [0.7369, 0.3702, 0.7539, 0.3916]}, {"w": "the", "b": [0.7586, 0.3702, 0.785, 0.3916]}, {"w": "training", "b": [0.7897, 0.3702, 0.8566, 0.3916]}, {"w": "images.", "b": [0.1429, 0.3901, 0.2057, 0.4116]}, {"w": "For", "b": [0.2106, 0.3901, 0.2396, 0.4116]}, {"w": "example,", "b": [0.2445, 0.3901, 0.3188, 0.4116]}, {"w": "use", "b": [0.3238, 0.3901, 0.3513, 0.4116]}, {"w": "tf.image.random_crop()", "b": [0.3562, 0.3933, 0.5739, 0.4084]}, {"w": "to", "b": [0.5789, 0.3901, 0.5959, 0.4116]}, {"w": "randomly", "b": [0.6008, 0.3901, 0.6826, 0.4116]}, {"w": "crop", "b": [0.6876, 0.3901, 0.7256, 0.4116]}, {"w": "the", "b": [0.7306, 0.3901, 0.7569, 0.4116]}, {"w": "images,", "b": [0.7619, 0.3901, 0.8246, 0.4116]}, {"w": "use", "b": [0.8296, 0.3901, 0.8572, 0.4116]}, {"w": "tf.image.random_flip_left_right()", "b": [0.1428, 0.4133, 0.4694, 0.4283]}, {"w": "to", "b": [0.4752, 0.4101, 0.4922, 0.4315]}, {"w": "randomly", "b": [0.4981, 0.4101, 0.5798, 0.4315]}, {"w": "flip", "b": [0.5857, 0.4101, 0.6136, 0.4315]}, {"w": "the", "b": [0.6194, 0.4101, 0.6458, 0.4315]}, {"w": "images", "b": [0.6516, 0.4101, 0.7097, 0.4315]}, {"w": "horizontally,", "b": [0.7155, 0.4101, 0.8198, 0.4315]}, {"w": "and", "b": [0.8256, 0.4101, 0.8571, 0.4315]}, {"w": "so", "b": [0.1429, 0.4291, 0.1611, 0.4505]}, {"w": "on", "b": [0.1659, 0.4291, 0.1879, 0.4505]}, {"w": "(see", "b": [0.1926, 0.4291, 0.2252, 0.4505]}, {"w": "the", "b": [0.2299, 0.4291, 0.2562, 0.4505]}, {"w": "notebook", "b": [0.261, 0.4291, 0.3404, 0.4505]}, {"w": "for", "b": [0.3451, 0.4291, 0.3696, 0.4505]}, {"w": "an", "b": [0.3743, 0.4291, 0.3949, 0.4505]}, {"w": "example).", "b": [0.3996, 0.4291, 0.4811, 0.4505]}]}, {"id": "b_5", "type": "paragraph", "text": "Next let’s load an Xception model, pretrained on ImageNet. We exclude the top of the network (by setting include_top=False): this excludes the global average pooling layer and the dense output layer. We then add our own global average pooling layer, based on the output of the base model, followed by a dense output layer with 1 unit per class, using the softmax activation function. Finally, we create the Keras Model:", "words": [{"w": "Next", "b": [0.1429, 0.4573, 0.1829, 0.4787]}, {"w": "let’s", "b": [0.1878, 0.4573, 0.218, 0.4787]}, {"w": "load", "b": [0.223, 0.4573, 0.259, 0.4787]}, {"w": "an", "b": [0.264, 0.4573, 0.2845, 0.4787]}, {"w": "Xception", "b": [0.2895, 0.4573, 0.3656, 0.4787]}, {"w": "model,", "b": [0.3706, 0.4573, 0.4281, 0.4787]}, {"w": "pretrained", "b": [0.4331, 0.4573, 0.5206, 0.4787]}, {"w": "on", "b": [0.5256, 0.4573, 0.5476, 0.4787]}, {"w": "ImageNet.", "b": [0.5525, 0.4573, 0.6394, 0.4787]}, {"w": "We", "b": [0.6443, 0.4573, 0.6714, 0.4787]}, {"w": "exclude", "b": [0.6763, 0.4573, 0.74, 0.4787]}, {"w": "the", "b": [0.745, 0.4573, 0.7713, 0.4787]}, {"w": "top", "b": [0.7762, 0.4573, 0.8041, 0.4787]}, {"w": "of", "b": [0.8091, 0.4573, 0.8259, 0.4787]}, {"w": "the", "b": [0.8308, 0.4573, 0.8571, 0.4787]}, {"w": "network", "b": [0.1429, 0.4772, 0.2124, 0.4986]}, {"w": "(by", "b": [0.2208, 0.4772, 0.2481, 0.4986]}, {"w": "setting", "b": [0.2565, 0.4772, 0.3124, 0.4986]}, {"w": "include_top=False):", "b": [0.3208, 0.4772, 0.501, 0.4986]}, {"w": "this", "b": [0.5094, 0.4772, 0.5401, 0.4986]}, {"w": "excludes", "b": [0.5484, 0.4772, 0.6198, 0.4986]}, {"w": "the", "b": [0.6281, 0.4772, 0.6545, 0.4986]}, {"w": "global", "b": [0.6628, 0.4772, 0.7135, 0.4986]}, {"w": "average", "b": [0.7219, 0.4772, 0.7846, 0.4986]}, {"w": "pooling", "b": [0.793, 0.4772, 0.8571, 0.4986]}, {"w": "layer", "b": [0.1429, 0.4962, 0.183, 0.5177]}, {"w": "and", "b": [0.1892, 0.4962, 0.2207, 0.5177]}, {"w": "the", "b": [0.2268, 0.4962, 0.2531, 0.5177]}, {"w": "dense", "b": [0.2593, 0.4962, 0.307, 0.5177]}, {"w": "output", "b": [0.3131, 0.4962, 0.3695, 0.5177]}, {"w": "layer.", "b": [0.3756, 0.4962, 0.4193, 0.5177]}, {"w": "We", "b": [0.4254, 0.4962, 0.4524, 0.5177]}, {"w": "then", "b": [0.4585, 0.4962, 0.4963, 0.5177]}, {"w": "add", "b": [0.5024, 0.4962, 0.5335, 0.5177]}, {"w": "our", "b": [0.5397, 0.4962, 0.5691, 0.5177]}, {"w": "own", "b": [0.5752, 0.4962, 0.6115, 0.5177]}, {"w": "global", "b": [0.6176, 0.4962, 0.6682, 0.5177]}, {"w": "average", "b": [0.6744, 0.4962, 0.7371, 0.5177]}, {"w": "pooling", "b": [0.7432, 0.4962, 0.8074, 0.5177]}, {"w": "layer,", "b": [0.8135, 0.4962, 0.8571, 0.5177]}, {"w": "based", "b": [0.1428, 0.5153, 0.1901, 0.5367]}, {"w": "on", "b": [0.1962, 0.5153, 0.2182, 0.5367]}, {"w": "the", "b": [0.2243, 0.5153, 0.2507, 0.5367]}, {"w": "output", "b": [0.2568, 0.5153, 0.3132, 0.5367]}, {"w": "of", "b": [0.3193, 0.5153, 0.3361, 0.5367]}, {"w": "the", "b": [0.3422, 0.5153, 0.3686, 0.5367]}, {"w": "base", "b": [0.3747, 0.5153, 0.4109, 0.5367]}, {"w": "model,", "b": [0.417, 0.5153, 0.4746, 0.5367]}, {"w": "followed", "b": [0.4807, 0.5153, 0.5528, 0.5367]}, {"w": "by", "b": [0.5589, 0.5153, 0.5791, 0.5367]}, {"w": "a", "b": [0.5852, 0.5153, 0.5943, 0.5367]}, {"w": "dense", "b": [0.6005, 0.5153, 0.6482, 0.5367]}, {"w": "output", "b": [0.6543, 0.5153, 0.7107, 0.5367]}, {"w": "layer", "b": [0.7168, 0.5153, 0.757, 0.5367]}, {"w": "with", "b": [0.7632, 0.5153, 0.8005, 0.5367]}, {"w": "1", "b": [0.8066, 0.5153, 0.8166, 0.5367]}, {"w": "unit", "b": [0.8227, 0.5153, 0.8571, 0.5367]}, {"w": "per", "b": [0.1429, 0.5352, 0.1704, 0.5566]}, {"w": "class,", "b": [0.1751, 0.5352, 0.2184, 0.5566]}, {"w": "using", "b": [0.2231, 0.5352, 0.2685, 0.5566]}, {"w": "the", "b": [0.2733, 0.5352, 0.2996, 0.5566]}, {"w": "softmax", "b": [0.3043, 0.5352, 0.3712, 0.5566]}, {"w": "activation", "b": [0.3759, 0.5352, 0.4581, 0.5566]}, {"w": "function.", "b": [0.4629, 0.5352, 0.539, 0.5566]}, {"w": "Finally,", "b": [0.5437, 0.5352, 0.6042, 0.5566]}, {"w": "we", "b": [0.6089, 0.5352, 0.6321, 0.5566]}, {"w": "create", "b": [0.6368, 0.5352, 0.6862, 0.5566]}, {"w": "the", "b": [0.6909, 0.5352, 0.7172, 0.5566]}, {"w": "Keras", "b": [0.7219, 0.5352, 0.7688, 0.5566]}, {"w": "Model:", "b": [0.7736, 0.5352, 0.8278, 0.5566]}]}, {"id": "b_6", "type": "paragraph", "text": "base_model = keras.applications.xception.Xception(weights=\"imagenet\", include_top=False) avg = keras.layers.GlobalAveragePooling2D()(base_model.output) output = keras.layers.Dense(n_classes, activation=\"softmax\")(avg) model = keras.models.Model(inputs=base_model.input, outputs=output)", "words": [{"w": "base_model", "b": [0.1766, 0.5672, 0.2609, 0.5801]}, {"w": "=", "b": [0.2693, 0.5672, 0.2778, 0.5801]}, {"w": "keras.applications.xception.Xception(weights=\"imagenet\",", "b": [0.2862, 0.5672, 0.7584, 0.5801]}, {"w": "include_top=False)", "b": [0.5982, 0.5826, 0.75, 0.5955]}, {"w": "avg", "b": [0.1766, 0.598, 0.2019, 0.6109]}, {"w": "=", "b": [0.2103, 0.598, 0.2188, 0.6109]}, {"w": "keras.layers.GlobalAveragePooling2D()(base_model.output)", "b": [0.2272, 0.598, 0.6994, 0.6109]}, {"w": "output", "b": [0.1766, 0.6135, 0.2272, 0.6263]}, {"w": "=", "b": [0.2356, 0.6135, 0.244, 0.6263]}, {"w": "keras.layers.Dense(n_classes,", "b": [0.2525, 0.6135, 0.497, 0.6263]}, {"w": "activation=\"softmax\")(avg)", "b": [0.5055, 0.6135, 0.7247, 0.6263]}, {"w": "model", "b": [0.1766, 0.6289, 0.2188, 0.6417]}, {"w": "=", "b": [0.2272, 0.6289, 0.2356, 0.6417]}, {"w": "keras.models.Model(inputs=base_model.input,", "b": [0.244, 0.6289, 0.6066, 0.6417]}, {"w": "outputs=output)", "b": [0.6151, 0.6289, 0.7416, 0.6417]}]}, {"id": "b_7", "type": "paragraph", "text": "As explained in Chapter 11, it’s usually a good idea to freeze the weights of the pre‐ trained layers, at least at the beginning of training:", "words": [{"w": "As", "b": [0.1429, 0.6495, 0.1649, 0.6709]}, {"w": "explained", "b": [0.1713, 0.6495, 0.2521, 0.6709]}, {"w": "in", "b": [0.2585, 0.6495, 0.2755, 0.6709]}, {"w": "Chapter", "b": [0.2818, 0.6495, 0.3494, 0.6709]}, {"w": "11,", "b": [0.3558, 0.6495, 0.3805, 0.6709]}, {"w": "it’s", "b": [0.3869, 0.6495, 0.4086, 0.6709]}, {"w": "usually", "b": [0.415, 0.6495, 0.474, 0.6709]}, {"w": "a", "b": [0.4804, 0.6495, 0.4895, 0.6709]}, {"w": "good", "b": [0.4959, 0.6495, 0.5379, 0.6709]}, {"w": "idea", "b": [0.5442, 0.6495, 0.5788, 0.6709]}, {"w": "to", "b": [0.5852, 0.6495, 0.6022, 0.6709]}, {"w": "freeze", "b": [0.6085, 0.6495, 0.6577, 0.6709]}, {"w": "the", "b": [0.6641, 0.6495, 0.6904, 0.6709]}, {"w": "weights", "b": [0.6968, 0.6495, 0.76, 0.6709]}, {"w": "of", "b": [0.7664, 0.6495, 0.7832, 0.6709]}, {"w": "the", "b": [0.7895, 0.6495, 0.8159, 0.6709]}, {"w": "pre‐", "b": [0.8222, 0.6495, 0.8571, 0.6709]}, {"w": "trained", "b": [0.1429, 0.6686, 0.2029, 0.69]}, {"w": "layers,", "b": [0.2076, 0.6686, 0.2602, 0.69]}, {"w": "at", "b": [0.265, 0.6686, 0.2801, 0.69]}, {"w": "least", "b": [0.2848, 0.6686, 0.3221, 0.69]}, {"w": "at", "b": [0.3268, 0.6686, 0.3419, 0.69]}, {"w": "the", "b": [0.3466, 0.6686, 0.373, 0.69]}, {"w": "beginning", "b": [0.3777, 0.6686, 0.462, 0.69]}, {"w": "of", "b": [0.4667, 0.6686, 0.4835, 0.69]}, {"w": "training:", "b": [0.4882, 0.6686, 0.5599, 0.69]}]}, {"id": "b_8", "type": "equation", "text": "for layer in base_model.layers: layer.trainable = False", "words": [{"w": "for", "b": [0.1766, 0.7005, 0.2019, 0.7134]}, {"w": "layer", "b": [0.2103, 0.7005, 0.2525, 0.7134]}, {"w": "in", "b": [0.2609, 0.7005, 0.2778, 0.7134]}, {"w": "base_model.layers:", "b": [0.2862, 0.7005, 0.438, 0.7134]}, {"w": "layer.trainable", "b": [0.2103, 0.716, 0.3368, 0.7288]}, {"w": "=", "b": [0.3452, 0.716, 0.3537, 0.7288]}, {"w": "False", "b": [0.3621, 0.716, 0.4043, 0.7288]}]}, {"id": "b_9", "type": "paragraph", "text": "Since our model uses the base model’s layers directly, rather than the base_model object itself, setting base_model.trainable=False would have no effect.", "words": [{"w": "Since", "b": [0.2714, 0.7504, 0.3121, 0.77]}, {"w": "our", "b": [0.3188, 0.7504, 0.3457, 0.77]}, {"w": "model", "b": [0.3523, 0.7504, 0.4006, 0.77]}, {"w": "uses", "b": [0.4072, 0.7504, 0.4394, 0.77]}, {"w": "the", "b": [0.446, 0.7504, 0.4701, 0.77]}, {"w": "base", "b": [0.4768, 0.7504, 0.5099, 0.77]}, {"w": "model’s", "b": [0.5165, 0.7504, 0.5737, 0.77]}, {"w": "layers", "b": [0.5804, 0.7504, 0.6241, 0.77]}, {"w": "directly,", "b": [0.6308, 0.7504, 0.6915, 0.77]}, {"w": "rather", "b": [0.6981, 0.7504, 0.7443, 0.77]}, {"w": "than", "b": [0.751, 0.7504, 0.7857, 0.77]}, {"w": "the", "b": [0.2714, 0.7687, 0.2955, 0.7882]}, {"w": "base_model", "b": [0.3008, 0.7716, 0.3912, 0.7854]}, {"w": "object", "b": [0.3965, 0.7687, 0.4427, 0.7882]}, {"w": "itself,", "b": [0.448, 0.7687, 0.4888, 0.7882]}, {"w": "setting", "b": [0.4941, 0.7687, 0.5452, 0.7882]}, {"w": "base_model.trainable=False", "b": [0.5505, 0.7716, 0.7857, 0.7854]}, {"w": "would", "b": [0.2714, 0.7861, 0.3192, 0.8056]}, {"w": "have", "b": [0.3235, 0.7861, 0.3586, 0.8056]}, {"w": "no", "b": [0.3629, 0.7861, 0.3831, 0.8056]}, {"w": "effect.", "b": [0.3874, 0.7861, 0.4331, 0.8056]}]}, {"id": "b_10", "type": "paragraph", "text": "Finally, we can compile the model and start training:", "words": [{"w": "Finally,", "b": [0.1429, 0.8491, 0.2033, 0.8705]}, {"w": "we", "b": [0.2081, 0.8491, 0.2312, 0.8705]}, {"w": "can", "b": [0.2359, 0.8491, 0.2653, 0.8705]}, {"w": "compile", "b": [0.27, 0.8491, 0.3367, 0.8705]}, {"w": "the", "b": [0.3415, 0.8491, 0.3678, 0.8705]}, {"w": "model", "b": [0.3725, 0.8491, 0.4253, 0.8705]}, {"w": "and", "b": [0.4301, 0.8491, 0.4616, 0.8705]}, {"w": "start", "b": [0.4663, 0.8491, 0.5036, 0.8705]}, {"w": "training:", "b": [0.5083, 0.8491, 0.58, 0.8705]}]}, {"id": "b_11", "type": "paragraph", "text": "468 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "468", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 495, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "optimizer = keras.optimizers.SGD(lr=0.2, momentum=0.9, decay=0.01) model.compile(loss=\"sparse_categorical_crossentropy\", optimizer=optimizer, metrics=[\"accuracy\"]) history = model.fit(train_set, steps_per_epoch=int(0.75 * dataset_size / batch_size), validation_data=valid_set, validation_steps=int(0.15 * dataset_size / batch_size), epochs=5)", "words": [{"w": "optimizer", "b": [0.1766, 0.0829, 0.2525, 0.0958]}, {"w": "=", "b": [0.2609, 0.0829, 0.2693, 0.0958]}, {"w": "keras.optimizers.SGD(lr=0.2,", "b": [0.2778, 0.0829, 0.5139, 0.0958]}, {"w": "momentum=0.9,", "b": [0.5223, 0.0829, 0.6319, 0.0958]}, {"w": "decay=0.01)", "b": [0.6404, 0.0829, 0.7331, 0.0958]}, {"w": "model.compile(loss=\"sparse_categorical_crossentropy\",", "b": [0.1766, 0.0983, 0.6235, 0.1112]}, {"w": "optimizer=optimizer,", "b": [0.6319, 0.0983, 0.8006, 0.1112]}, {"w": "metrics=[\"accuracy\"])", "b": [0.2946, 0.1138, 0.4717, 0.1266]}, {"w": "history", "b": [0.1766, 0.1292, 0.2356, 0.142]}, {"w": "=", "b": [0.244, 0.1292, 0.2525, 0.142]}, {"w": "model.fit(train_set,", "b": [0.2609, 0.1292, 0.4296, 0.142]}, {"w": "steps_per_epoch=int(0.75", "b": [0.3452, 0.1446, 0.5476, 0.1574]}, {"w": "*", "b": [0.5561, 0.1446, 0.5645, 0.1574]}, {"w": "dataset_size", "b": [0.5729, 0.1446, 0.6741, 0.1574]}, {"w": "/", "b": [0.6825, 0.1446, 0.691, 0.1574]}, {"w": "batch_size),", "b": [0.6994, 0.1446, 0.8006, 0.1574]}, {"w": "validation_data=valid_set,", "b": [0.3452, 0.16, 0.5645, 0.1729]}, {"w": "validation_steps=int(0.15", "b": [0.3452, 0.1754, 0.5561, 0.1883]}, {"w": "*", "b": [0.5645, 0.1754, 0.5729, 0.1883]}, {"w": "dataset_size", "b": [0.5813, 0.1754, 0.6825, 0.1883]}, {"w": "/", "b": [0.691, 0.1754, 0.6994, 0.1883]}, {"w": "batch_size),", "b": [0.7078, 0.1754, 0.809, 0.1883]}, {"w": "epochs=5)", "b": [0.3452, 0.1909, 0.4211, 0.2037]}]}, {"id": "b_1", "type": "paragraph", "text": "This will be very slow, unless you have a GPU. If you do not, then you should run this chapter’s notebook in Colab, using a GPU run‐ time (it’s free!). See the instructions at https://github.com/ageron/ handson-ml2.", "words": [{"w": "This", "b": [0.2714, 0.2253, 0.3054, 0.2449]}, {"w": "will", "b": [0.311, 0.2253, 0.3388, 0.2449]}, {"w": "be", "b": [0.3444, 0.2253, 0.3621, 0.2449]}, {"w": "very", "b": [0.3677, 0.2253, 0.401, 0.2449]}, {"w": "slow,", "b": [0.4065, 0.2253, 0.4441, 0.2449]}, {"w": "unless", "b": [0.4496, 0.2253, 0.4971, 0.2449]}, {"w": "you", "b": [0.5026, 0.2253, 0.5312, 0.2449]}, {"w": "have", "b": [0.5368, 0.2253, 0.5719, 0.2449]}, {"w": "a", "b": [0.5774, 0.2253, 0.5858, 0.2449]}, {"w": "GPU.", "b": [0.5914, 0.2253, 0.6326, 0.2449]}, {"w": "If", "b": [0.6382, 0.2253, 0.6503, 0.2449]}, {"w": "you", "b": [0.6559, 0.2253, 0.6845, 0.2449]}, {"w": "do", "b": [0.69, 0.2253, 0.7098, 0.2449]}, {"w": "not,", "b": [0.7154, 0.2253, 0.7457, 0.2449]}, {"w": "then", "b": [0.7512, 0.2253, 0.7857, 0.2449]}, {"w": "you", "b": [0.2714, 0.2427, 0.3, 0.2623]}, {"w": "should", "b": [0.3047, 0.2427, 0.3566, 0.2623]}, {"w": "run", "b": [0.3613, 0.2427, 0.3889, 0.2623]}, {"w": "this", "b": [0.3936, 0.2427, 0.4217, 0.2623]}, {"w": "chapter’s", "b": [0.4264, 0.2427, 0.493, 0.2623]}, {"w": "notebook", "b": [0.4977, 0.2427, 0.5703, 0.2623]}, {"w": "in", "b": [0.575, 0.2427, 0.5905, 0.2623]}, {"w": "Colab,", "b": [0.5952, 0.2427, 0.6442, 0.2623]}, {"w": "using", "b": [0.649, 0.2427, 0.6905, 0.2623]}, {"w": "a", "b": [0.6952, 0.2427, 0.7036, 0.2623]}, {"w": "GPU", "b": [0.7083, 0.2427, 0.7466, 0.2623]}, {"w": "run‐", "b": [0.7513, 0.2427, 0.7857, 0.2623]}, {"w": "time", "b": [0.2714, 0.2601, 0.306, 0.2797]}, {"w": "(it’s", "b": [0.314, 0.2601, 0.3404, 0.2797]}, {"w": "free!).", "b": [0.3484, 0.2601, 0.3935, 0.2797]}, {"w": "See", "b": [0.4015, 0.2601, 0.4267, 0.2797]}, {"w": "the", "b": [0.4347, 0.2601, 0.4587, 0.2797]}, {"w": "instructions", "b": [0.4667, 0.2601, 0.5583, 0.2797]}, {"w": "at", "b": [0.5663, 0.2601, 0.5801, 0.2797]}, {"w": "https://github.com/ageron/", "b": [0.5881, 0.26, 0.7857, 0.2797]}, {"w": "handson-ml2.", "b": [0.2714, 0.2774, 0.3745, 0.2971]}]}, {"id": "b_2", "type": "paragraph", "text": "After training the model for a few epochs, its validation accuracy should reach about 75-80%, and stop making much progress. This means that the top layers are now pretty well trained, so we are ready to unfreeze all layers (or you could try unfreezing just the top ones), and continue training (don’t forget to compile the model when you freeze or unfreeze layers). This time we use a much lower learning rate to avoid dam‐ aging the pretrained weights:", "words": [{"w": "After", "b": [0.1429, 0.324, 0.1864, 0.3454]}, {"w": "training", "b": [0.192, 0.324, 0.2589, 0.3454]}, {"w": "the", "b": [0.2645, 0.324, 0.2908, 0.3454]}, {"w": "model", "b": [0.2964, 0.324, 0.3492, 0.3454]}, {"w": "for", "b": [0.3548, 0.324, 0.3794, 0.3454]}, {"w": "a", "b": [0.385, 0.324, 0.3941, 0.3454]}, {"w": "few", "b": [0.3997, 0.324, 0.429, 0.3454]}, {"w": "epochs,", "b": [0.4346, 0.324, 0.4973, 0.3454]}, {"w": "its", "b": [0.5029, 0.324, 0.5225, 0.3454]}, {"w": "validation", "b": [0.5281, 0.324, 0.6115, 0.3454]}, {"w": "accuracy", "b": [0.6171, 0.324, 0.6902, 0.3454]}, {"w": "should", "b": [0.6958, 0.324, 0.7525, 0.3454]}, {"w": "reach", "b": [0.7581, 0.324, 0.8038, 0.3454]}, {"w": "about", "b": [0.8094, 0.324, 0.8571, 0.3454]}, {"w": "75-80%,", "b": [0.1429, 0.343, 0.2108, 0.3644]}, {"w": "and", "b": [0.2188, 0.343, 0.2504, 0.3644]}, {"w": "stop", "b": [0.2584, 0.343, 0.294, 0.3644]}, {"w": "making", "b": [0.302, 0.343, 0.3653, 0.3644]}, {"w": "much", "b": [0.3733, 0.343, 0.421, 0.3644]}, {"w": "progress.", "b": [0.4291, 0.343, 0.5047, 0.3644]}, {"w": "This", "b": [0.5128, 0.343, 0.55, 0.3644]}, {"w": "means", "b": [0.558, 0.343, 0.6121, 0.3644]}, {"w": "that", "b": [0.6202, 0.343, 0.6528, 0.3644]}, {"w": "the", "b": [0.6608, 0.343, 0.6872, 0.3644]}, {"w": "top", "b": [0.6952, 0.343, 0.7231, 0.3644]}, {"w": "layers", "b": [0.7312, 0.343, 0.779, 0.3644]}, {"w": "are", "b": [0.7871, 0.343, 0.8128, 0.3644]}, {"w": "now", "b": [0.8208, 0.343, 0.8571, 0.3644]}, {"w": "pretty", "b": [0.1429, 0.3621, 0.1926, 0.3835]}, {"w": "well", "b": [0.1979, 0.3621, 0.2316, 0.3835]}, {"w": "trained,", "b": [0.2368, 0.3621, 0.3017, 0.3835]}, {"w": "so", "b": [0.3069, 0.3621, 0.3252, 0.3835]}, {"w": "we", "b": [0.3305, 0.3621, 0.3536, 0.3835]}, {"w": "are", "b": [0.3589, 0.3621, 0.3846, 0.3835]}, {"w": "ready", "b": [0.3899, 0.3621, 0.4362, 0.3835]}, {"w": "to", "b": [0.4414, 0.3621, 0.4584, 0.3835]}, {"w": "unfreeze", "b": [0.4637, 0.3621, 0.5354, 0.3835]}, {"w": "all", "b": [0.5406, 0.3621, 0.5603, 0.3835]}, {"w": "layers", "b": [0.5656, 0.3621, 0.6134, 0.3835]}, {"w": "(or", "b": [0.6187, 0.3621, 0.6443, 0.3835]}, {"w": "you", "b": [0.6495, 0.3621, 0.6808, 0.3835]}, {"w": "could", "b": [0.686, 0.3621, 0.7328, 0.3835]}, {"w": "try", "b": [0.7381, 0.3621, 0.7623, 0.3835]}, {"w": "unfreezing", "b": [0.7676, 0.3621, 0.8572, 0.3835]}, {"w": "just", "b": [0.1429, 0.3811, 0.1733, 0.4025]}, {"w": "the", "b": [0.1782, 0.3811, 0.2045, 0.4025]}, {"w": "top", "b": [0.2095, 0.3811, 0.2374, 0.4025]}, {"w": "ones),", "b": [0.2423, 0.3811, 0.2928, 0.4025]}, {"w": "and", "b": [0.2978, 0.3811, 0.3293, 0.4025]}, {"w": "continue", "b": [0.3343, 0.3811, 0.4076, 0.4025]}, {"w": "training", "b": [0.4125, 0.3811, 0.4795, 0.4025]}, {"w": "(don’t", "b": [0.4844, 0.3811, 0.5332, 0.4025]}, {"w": "forget", "b": [0.5382, 0.3811, 0.5877, 0.4025]}, {"w": "to", "b": [0.5926, 0.3811, 0.6096, 0.4025]}, {"w": "compile", "b": [0.6146, 0.3811, 0.6813, 0.4025]}, {"w": "the", "b": [0.6862, 0.3811, 0.7126, 0.4025]}, {"w": "model", "b": [0.7175, 0.3811, 0.7703, 0.4025]}, {"w": "when", "b": [0.7753, 0.3811, 0.8209, 0.4025]}, {"w": "you", "b": [0.8259, 0.3811, 0.8571, 0.4025]}, {"w": "freeze", "b": [0.1429, 0.4001, 0.1921, 0.4216]}, {"w": "or", "b": [0.1973, 0.4001, 0.2156, 0.4216]}, {"w": "unfreeze", "b": [0.2208, 0.4001, 0.2925, 0.4216]}, {"w": "layers).", "b": [0.2977, 0.4001, 0.3575, 0.4216]}, {"w": "This", "b": [0.3627, 0.4001, 0.3999, 0.4216]}, {"w": "time", "b": [0.4051, 0.4001, 0.4429, 0.4216]}, {"w": "we", "b": [0.4481, 0.4001, 0.4712, 0.4216]}, {"w": "use", "b": [0.4764, 0.4001, 0.504, 0.4216]}, {"w": "a", "b": [0.5092, 0.4001, 0.5183, 0.4216]}, {"w": "much", "b": [0.5235, 0.4001, 0.5712, 0.4216]}, {"w": "lower", "b": [0.5764, 0.4001, 0.6231, 0.4216]}, {"w": "learning", "b": [0.6283, 0.4001, 0.6974, 0.4216]}, {"w": "rate", "b": [0.7026, 0.4001, 0.7343, 0.4216]}, {"w": "to", "b": [0.7395, 0.4001, 0.7565, 0.4216]}, {"w": "avoid", "b": [0.7617, 0.4001, 0.8073, 0.4216]}, {"w": "dam‐", "b": [0.8125, 0.4001, 0.8571, 0.4216]}, {"w": "aging", "b": [0.1428, 0.4192, 0.1885, 0.4406]}, {"w": "the", "b": [0.1932, 0.4192, 0.2195, 0.4406]}, {"w": "pretrained", "b": [0.2243, 0.4192, 0.3118, 0.4406]}, {"w": "weights:", "b": [0.3166, 0.4192, 0.3845, 0.4406]}]}, {"id": "b_3", "type": "equation", "text": "for layer in base_model.layers: layer.trainable = True", "words": [{"w": "for", "b": [0.1766, 0.4512, 0.2019, 0.464]}, {"w": "layer", "b": [0.2103, 0.4512, 0.2525, 0.464]}, {"w": "in", "b": [0.2609, 0.4512, 0.2778, 0.464]}, {"w": "base_model.layers:", "b": [0.2862, 0.4512, 0.438, 0.464]}, {"w": "layer.trainable", "b": [0.2103, 0.4666, 0.3368, 0.4794]}, {"w": "=", "b": [0.3452, 0.4666, 0.3537, 0.4794]}, {"w": "True", "b": [0.3621, 0.4666, 0.3958, 0.4794]}]}, {"id": "b_4", "type": "paragraph", "text": "optimizer = keras.optimizers.SGD(lr=0.01, momentum=0.9, decay=0.001) model.compile(...) history = model.fit(...)", "words": [{"w": "optimizer", "b": [0.1766, 0.4974, 0.2525, 0.5103]}, {"w": "=", "b": [0.2609, 0.4974, 0.2693, 0.5103]}, {"w": "keras.optimizers.SGD(lr=0.01,", "b": [0.2778, 0.4974, 0.5223, 0.5103]}, {"w": "momentum=0.9,", "b": [0.5307, 0.4974, 0.6404, 0.5103]}, {"w": "decay=0.001)", "b": [0.6488, 0.4974, 0.75, 0.5103]}, {"w": "model.compile(...)", "b": [0.1766, 0.5128, 0.3284, 0.5257]}, {"w": "history", "b": [0.1766, 0.5283, 0.2356, 0.5411]}, {"w": "=", "b": [0.244, 0.5283, 0.2525, 0.5411]}, {"w": "model.fit(...)", "b": [0.2609, 0.5283, 0.379, 0.5411]}]}, {"id": "b_5", "type": "paragraph", "text": "It will take a while, but this model should reach around 95% accuracy on the test set. With that, you can start training amazing image classifiers! But there’s more to com‐ puter vision than just classification. For example, what if you also want to know where the flower is in the picture? Let’s look at this now.", "words": [{"w": "It", "b": [0.1429, 0.5489, 0.1555, 0.5703]}, {"w": "will", "b": [0.161, 0.5489, 0.1914, 0.5703]}, {"w": "take", "b": [0.197, 0.5489, 0.2317, 0.5703]}, {"w": "a", "b": [0.2372, 0.5489, 0.2464, 0.5703]}, {"w": "while,", "b": [0.2519, 0.5489, 0.3018, 0.5703]}, {"w": "but", "b": [0.3073, 0.5489, 0.3353, 0.5703]}, {"w": "this", "b": [0.3408, 0.5489, 0.3715, 0.5703]}, {"w": "model", "b": [0.3771, 0.5489, 0.4299, 0.5703]}, {"w": "should", "b": [0.4354, 0.5489, 0.4922, 0.5703]}, {"w": "reach", "b": [0.4977, 0.5489, 0.5434, 0.5703]}, {"w": "around", "b": [0.5489, 0.5489, 0.6099, 0.5703]}, {"w": "95%", "b": [0.6154, 0.5489, 0.6512, 0.5703]}, {"w": "accuracy", "b": [0.6567, 0.5489, 0.7298, 0.5703]}, {"w": "on", "b": [0.7353, 0.5489, 0.7574, 0.5703]}, {"w": "the", "b": [0.7629, 0.5489, 0.7892, 0.5703]}, {"w": "test", "b": [0.7948, 0.5489, 0.824, 0.5703]}, {"w": "set.", "b": [0.8295, 0.5489, 0.8571, 0.5703]}, {"w": "With", "b": [0.1429, 0.568, 0.1853, 0.5894]}, {"w": "that,", "b": [0.1911, 0.568, 0.2285, 0.5894]}, {"w": "you", "b": [0.2343, 0.568, 0.2655, 0.5894]}, {"w": "can", "b": [0.2714, 0.568, 0.3007, 0.5894]}, {"w": "start", "b": [0.3066, 0.568, 0.3438, 0.5894]}, {"w": "training", "b": [0.3496, 0.568, 0.4166, 0.5894]}, {"w": "amazing", "b": [0.4224, 0.568, 0.4932, 0.5894]}, {"w": "image", "b": [0.4991, 0.568, 0.5495, 0.5894]}, {"w": "classifiers!", "b": [0.5553, 0.568, 0.6411, 0.5894]}, {"w": "But", "b": [0.647, 0.568, 0.6766, 0.5894]}, {"w": "there’s", "b": [0.6825, 0.568, 0.7345, 0.5894]}, {"w": "more", "b": [0.7403, 0.568, 0.7846, 0.5894]}, {"w": "to", "b": [0.7904, 0.568, 0.8074, 0.5894]}, {"w": "com‐", "b": [0.8132, 0.568, 0.8571, 0.5894]}, {"w": "puter", "b": [0.1428, 0.587, 0.1878, 0.6084]}, {"w": "vision", "b": [0.1925, 0.587, 0.243, 0.6084]}, {"w": "than", "b": [0.2477, 0.587, 0.2857, 0.6084]}, {"w": "just", "b": [0.2904, 0.587, 0.3208, 0.6084]}, {"w": "classification.", "b": [0.3256, 0.587, 0.4377, 0.6084]}, {"w": "For", "b": [0.4424, 0.587, 0.4714, 0.6084]}, {"w": "example,", "b": [0.4761, 0.587, 0.5504, 0.6084]}, {"w": "what", "b": [0.5552, 0.587, 0.5957, 0.6084]}, {"w": "if", "b": [0.6004, 0.587, 0.6121, 0.6084]}, {"w": "you", "b": [0.6169, 0.587, 0.6481, 0.6084]}, {"w": "also", "b": [0.6528, 0.587, 0.6855, 0.6084]}, {"w": "want", "b": [0.6903, 0.587, 0.731, 0.6084]}, {"w": "to", "b": [0.7358, 0.587, 0.7527, 0.6084]}, {"w": "know", "b": [0.7575, 0.587, 0.8041, 0.6084]}, {"w": "where", "b": [0.8088, 0.5868, 0.8571, 0.6084]}, {"w": "the", "b": [0.1428, 0.606, 0.1692, 0.6275]}, {"w": "flower", "b": [0.1739, 0.606, 0.2268, 0.6275]}, {"w": "is", "b": [0.2316, 0.606, 0.2448, 0.6275]}, {"w": "in", "b": [0.2495, 0.606, 0.2665, 0.6275]}, {"w": "the", "b": [0.2712, 0.606, 0.2976, 0.6275]}, {"w": "picture?", "b": [0.3023, 0.606, 0.3695, 0.6275]}, {"w": "Let’s", "b": [0.3742, 0.606, 0.4104, 0.6275]}, {"w": "look", "b": [0.4151, 0.606, 0.452, 0.6275]}, {"w": "at", "b": [0.4567, 0.606, 0.4718, 0.6275]}, {"w": "this", "b": [0.4765, 0.606, 0.5072, 0.6275]}, {"w": "now.", "b": [0.512, 0.606, 0.5515, 0.6275]}]}, {"id": "b_6", "type": "paragraph", "text": "Classification and Localization", "words": [{"w": "Classification", "b": [0.1429, 0.6405, 0.3048, 0.6747]}, {"w": "and", "b": [0.3107, 0.6405, 0.3578, 0.6747]}, {"w": "Localization", "b": [0.3638, 0.6405, 0.5125, 0.6747]}]}, {"id": "b_7", "type": "paragraph", "text": "Localizing an object in a picture can be expressed as a regression task, as discussed in Chapter 10: to predict a bounding box around the object, a common approach is to predict the horizontal and vertical coordinates of the object’s center, as well as its height and width. This means we have 4 numbers to predict. It does not require much change to the model, we just need to add a second dense output layer with 4 units (typically on top of the global average pooling layer), and it can be trained using the MSE loss:", "words": [{"w": "Localizing", "b": [0.1429, 0.6816, 0.229, 0.703]}, {"w": "an", "b": [0.2342, 0.6816, 0.2548, 0.703]}, {"w": "object", "b": [0.26, 0.6816, 0.3106, 0.703]}, {"w": "in", "b": [0.3158, 0.6816, 0.3328, 0.703]}, {"w": "a", "b": [0.338, 0.6816, 0.3471, 0.703]}, {"w": "picture", "b": [0.3524, 0.6816, 0.4117, 0.703]}, {"w": "can", "b": [0.4169, 0.6816, 0.4463, 0.703]}, {"w": "be", "b": [0.4515, 0.6816, 0.4709, 0.703]}, {"w": "expressed", "b": [0.4762, 0.6816, 0.5575, 0.703]}, {"w": "as", "b": [0.5627, 0.6816, 0.5795, 0.703]}, {"w": "a", "b": [0.5848, 0.6816, 0.5939, 0.703]}, {"w": "regression", "b": [0.5992, 0.6816, 0.685, 0.703]}, {"w": "task,", "b": [0.6902, 0.6816, 0.7284, 0.703]}, {"w": "as", "b": [0.7337, 0.6816, 0.7505, 0.703]}, {"w": "discussed", "b": [0.7557, 0.6816, 0.8349, 0.703]}, {"w": "in", "b": [0.8402, 0.6816, 0.8571, 0.703]}, {"w": "Chapter", "b": [0.1429, 0.7007, 0.2104, 0.7221]}, {"w": "10:", "b": [0.2168, 0.7007, 0.2415, 0.7221]}, {"w": "to", "b": [0.2478, 0.7007, 0.2648, 0.7221]}, {"w": "predict", "b": [0.2711, 0.7007, 0.3304, 0.7221]}, {"w": "a", "b": [0.3367, 0.7007, 0.3459, 0.7221]}, {"w": "bounding", "b": [0.3522, 0.7007, 0.4336, 0.7221]}, {"w": "box", "b": [0.4399, 0.7007, 0.471, 0.7221]}, {"w": "around", "b": [0.4773, 0.7007, 0.5382, 0.7221]}, {"w": "the", "b": [0.5446, 0.7007, 0.5709, 0.7221]}, {"w": "object,", "b": [0.5772, 0.7007, 0.6325, 0.7221]}, {"w": "a", "b": [0.6389, 0.7007, 0.648, 0.7221]}, {"w": "common", "b": [0.6543, 0.7007, 0.7299, 0.7221]}, {"w": "approach", "b": [0.7363, 0.7007, 0.8143, 0.7221]}, {"w": "is", "b": [0.8206, 0.7007, 0.8338, 0.7221]}, {"w": "to", "b": [0.8402, 0.7007, 0.8571, 0.7221]}, {"w": "predict", "b": [0.1428, 0.7197, 0.2021, 0.7411]}, {"w": "the", "b": [0.2103, 0.7197, 0.2367, 0.7411]}, {"w": "horizontal", "b": [0.2449, 0.7197, 0.3311, 0.7411]}, {"w": "and", "b": [0.3393, 0.7197, 0.3708, 0.7411]}, {"w": "vertical", "b": [0.3791, 0.7197, 0.4405, 0.7411]}, {"w": "coordinates", "b": [0.4487, 0.7197, 0.5461, 0.7411]}, {"w": "of", "b": [0.5543, 0.7197, 0.5711, 0.7411]}, {"w": "the", "b": [0.5793, 0.7197, 0.6056, 0.7411]}, {"w": "object’s", "b": [0.6138, 0.7197, 0.6742, 0.7411]}, {"w": "center,", "b": [0.6824, 0.7197, 0.7374, 0.7411]}, {"w": "as", "b": [0.7456, 0.7197, 0.7624, 0.7411]}, {"w": "well", "b": [0.7707, 0.7197, 0.8043, 0.7411]}, {"w": "as", "b": [0.8125, 0.7197, 0.8293, 0.7411]}, {"w": "its", "b": [0.8376, 0.7197, 0.8571, 0.7411]}, {"w": "height", "b": [0.1429, 0.7388, 0.1953, 0.7602]}, {"w": "and", "b": [0.2001, 0.7388, 0.2316, 0.7602]}, {"w": "width.", "b": [0.2364, 0.7388, 0.2895, 0.7602]}, {"w": "This", "b": [0.2943, 0.7388, 0.3315, 0.7602]}, {"w": "means", "b": [0.3364, 0.7388, 0.3905, 0.7602]}, {"w": "we", "b": [0.3953, 0.7388, 0.4184, 0.7602]}, {"w": "have", "b": [0.4232, 0.7388, 0.4616, 0.7602]}, {"w": "4", "b": [0.4664, 0.7388, 0.4764, 0.7602]}, {"w": "numbers", "b": [0.4812, 0.7388, 0.5552, 0.7602]}, {"w": "to", "b": [0.56, 0.7388, 0.577, 0.7602]}, {"w": "predict.", "b": [0.5818, 0.7388, 0.6458, 0.7602]}, {"w": "It", "b": [0.6506, 0.7388, 0.6633, 0.7602]}, {"w": "does", "b": [0.6681, 0.7388, 0.7062, 0.7602]}, {"w": "not", "b": [0.711, 0.7388, 0.7394, 0.7602]}, {"w": "require", "b": [0.7442, 0.7388, 0.8047, 0.7602]}, {"w": "much", "b": [0.8095, 0.7388, 0.8572, 0.7602]}, {"w": "change", "b": [0.1429, 0.7578, 0.2019, 0.7792]}, {"w": "to", "b": [0.2089, 0.7578, 0.2259, 0.7792]}, {"w": "the", "b": [0.2328, 0.7578, 0.2592, 0.7792]}, {"w": "model,", "b": [0.2661, 0.7578, 0.3237, 0.7792]}, {"w": "we", "b": [0.3307, 0.7578, 0.3538, 0.7792]}, {"w": "just", "b": [0.3608, 0.7578, 0.3912, 0.7792]}, {"w": "need", "b": [0.3981, 0.7578, 0.4382, 0.7792]}, {"w": "to", "b": [0.4452, 0.7578, 0.4622, 0.7792]}, {"w": "add", "b": [0.4691, 0.7578, 0.5003, 0.7792]}, {"w": "a", "b": [0.5072, 0.7578, 0.5164, 0.7792]}, {"w": "second", "b": [0.5233, 0.7578, 0.5817, 0.7792]}, {"w": "dense", "b": [0.5886, 0.7578, 0.6364, 0.7792]}, {"w": "output", "b": [0.6434, 0.7578, 0.6997, 0.7792]}, {"w": "layer", "b": [0.7067, 0.7578, 0.7469, 0.7792]}, {"w": "with", "b": [0.7538, 0.7578, 0.7912, 0.7792]}, {"w": "4", "b": [0.7981, 0.7578, 0.8081, 0.7792]}, {"w": "units", "b": [0.8151, 0.7578, 0.8571, 0.7792]}, {"w": "(typically", "b": [0.1429, 0.7769, 0.2205, 0.7983]}, {"w": "on", "b": [0.2265, 0.7769, 0.2485, 0.7983]}, {"w": "top", "b": [0.2545, 0.7769, 0.2824, 0.7983]}, {"w": "of", "b": [0.2884, 0.7769, 0.3052, 0.7983]}, {"w": "the", "b": [0.3112, 0.7769, 0.3375, 0.7983]}, {"w": "global", "b": [0.3435, 0.7769, 0.3941, 0.7983]}, {"w": "average", "b": [0.4001, 0.7769, 0.4629, 0.7983]}, {"w": "pooling", "b": [0.4689, 0.7769, 0.533, 0.7983]}, {"w": "layer),", "b": [0.539, 0.7769, 0.5912, 0.7983]}, {"w": "and", "b": [0.5971, 0.7769, 0.6287, 0.7983]}, {"w": "it", "b": [0.6347, 0.7769, 0.6466, 0.7983]}, {"w": "can", "b": [0.6526, 0.7769, 0.6819, 0.7983]}, {"w": "be", "b": [0.6879, 0.7769, 0.7074, 0.7983]}, {"w": "trained", "b": [0.7133, 0.7769, 0.7734, 0.7983]}, {"w": "using", "b": [0.7794, 0.7769, 0.8248, 0.7983]}, {"w": "the", "b": [0.8308, 0.7769, 0.8571, 0.7983]}, {"w": "MSE", "b": [0.1429, 0.7959, 0.1831, 0.8173]}, {"w": "loss:", "b": [0.1879, 0.7959, 0.2238, 0.8173]}]}, {"id": "b_8", "type": "paragraph", "text": "base_model = keras.applications.xception.Xception(weights=\"imagenet\", include_top=False) avg = keras.layers.GlobalAveragePooling2D()(base_model.output) class_output = keras.layers.Dense(n_classes, activation=\"softmax\")(avg)", "words": [{"w": "base_model", "b": [0.1766, 0.8279, 0.2609, 0.8407]}, {"w": "=", "b": [0.2693, 0.8279, 0.2778, 0.8407]}, {"w": "keras.applications.xception.Xception(weights=\"imagenet\",", "b": [0.2862, 0.8279, 0.7584, 0.8407]}, {"w": "include_top=False)", "b": [0.5982, 0.8433, 0.75, 0.8562]}, {"w": "avg", "b": [0.1766, 0.8587, 0.2019, 0.8716]}, {"w": "=", "b": [0.2103, 0.8587, 0.2187, 0.8716]}, {"w": "keras.layers.GlobalAveragePooling2D()(base_model.output)", "b": [0.2272, 0.8587, 0.6994, 0.8716]}, {"w": "class_output", "b": [0.1766, 0.8742, 0.2778, 0.887]}, {"w": "=", "b": [0.2862, 0.8742, 0.2946, 0.887]}, {"w": "keras.layers.Dense(n_classes,", "b": [0.3031, 0.8742, 0.5476, 0.887]}, {"w": "activation=\"softmax\")(avg)", "b": [0.556, 0.8742, 0.7753, 0.887]}]}, {"id": "b_9", "type": "paragraph", "text": "Classification and Localization | 469", "words": [{"w": "Classification", "b": [0.62, 0.9225, 0.697, 0.9388]}, {"w": "and", "b": [0.6998, 0.9225, 0.7222, 0.9388]}, {"w": "Localization", "b": [0.7251, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "469", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 496, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "22 “Crowdsourcing in Computer Vision,” A. Kovashka et al. (2016).", "words": [{"w": "22", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Crowdsourcing", "b": [0.1587, 0.8749, 0.2636, 0.8912]}, {"w": "in", "b": [0.2672, 0.8749, 0.2801, 0.8912]}, {"w": "Computer", "b": [0.2837, 0.8749, 0.3493, 0.8912]}, {"w": "Vision,”", "b": [0.3529, 0.8749, 0.4023, 0.8912]}, {"w": "A.", "b": [0.4059, 0.8749, 0.4205, 0.8912]}, {"w": "Kovashka", "b": [0.4241, 0.8749, 0.486, 0.8912]}, {"w": "et", "b": [0.4896, 0.8749, 0.5012, 0.8912]}, {"w": "al.", "b": [0.5048, 0.8749, 0.5194, 0.8912]}, {"w": "(2016).", "b": [0.523, 0.8749, 0.568, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "loc_output = keras.layers.Dense(4)(avg) model = keras.models.Model(inputs=base_model.input, outputs=[class_output, loc_output]) model.compile(loss=[\"sparse_categorical_crossentropy\", \"mse\"], loss_weights=[0.8, 0.2], # depends on what you care most about optimizer=optimizer, metrics=[\"accuracy\"])", "words": [{"w": "loc_output", "b": [0.1766, 0.0829, 0.2609, 0.0958]}, {"w": "=", "b": [0.2694, 0.0829, 0.2778, 0.0958]}, {"w": "keras.layers.Dense(4)(avg)", "b": [0.2862, 0.0829, 0.5055, 0.0958]}, {"w": "model", "b": [0.1766, 0.0983, 0.2188, 0.1112]}, {"w": "=", "b": [0.2272, 0.0983, 0.2356, 0.1112]}, {"w": "keras.models.Model(inputs=base_model.input,", "b": [0.2441, 0.0983, 0.6067, 0.1112]}, {"w": "outputs=[class_output,", "b": [0.4043, 0.1138, 0.5898, 0.1266]}, {"w": "loc_output])", "b": [0.5982, 0.1138, 0.6994, 0.1266]}, {"w": "model.compile(loss=[\"sparse_categorical_crossentropy\",", "b": [0.1766, 0.1292, 0.6319, 0.142]}, {"w": "\"mse\"],", "b": [0.6404, 0.1292, 0.6994, 0.142]}, {"w": "loss_weights=[0.8,", "b": [0.2946, 0.1446, 0.4464, 0.1574]}, {"w": "0.2],", "b": [0.4549, 0.1446, 0.497, 0.1574]}, {"w": "#", "b": [0.5055, 0.1446, 0.5139, 0.1574]}, {"w": "depends", "b": [0.5223, 0.1446, 0.5814, 0.1574]}, {"w": "on", "b": [0.5898, 0.1446, 0.6067, 0.1574]}, {"w": "what", "b": [0.6151, 0.1446, 0.6488, 0.1574]}, {"w": "you", "b": [0.6572, 0.1446, 0.6825, 0.1574]}, {"w": "care", "b": [0.691, 0.1446, 0.7247, 0.1574]}, {"w": "most", "b": [0.7331, 0.1446, 0.7669, 0.1574]}, {"w": "about", "b": [0.7753, 0.1446, 0.8175, 0.1574]}, {"w": "optimizer=optimizer,", "b": [0.2946, 0.16, 0.4633, 0.1729]}, {"w": "metrics=[\"accuracy\"])", "b": [0.4717, 0.16, 0.6488, 0.1729]}]}, {"id": "b_2", "type": "paragraph", "text": "But now we have a problem: the flowers dataset does not have bounding boxes around the flowers. So we need to add them ourselves. This is often one of the hard‐ est and most costly part of a Machine Learning project: getting the labels. It’s a good idea to spend time looking for the right tools. To annotate images with bounding boxes, you may want to use an open source image labeling tool like VGG Image Annotator, LabelImg, OpenLabeler or ImgLab, or perhaps a commercial tool like LabelBox or Supervisely. You may also want to consider crowdsourcing platforms such as Amazon Mechanical Turk or CrowdFlower if you have a very large number of images to annotate. However, it is quite a lot of work to setup a crowdsourcing plat‐ form, prepare the form to be sent to the workers, to supervise them and ensure the quality of the bounding boxes they produce is good, so make sure it is worth the effort: if there are just a few thousand images to label, and you don’t plan to do this frequently, it may be preferable to do it yourself. Adriana Kovashka et al. wrote a very practical paper22 about crowdsourcing in Computer Vision, I recommend you check it out, even if you do not plan to use crowdsourcing.", "words": [{"w": "But", "b": [0.1429, 0.1806, 0.1725, 0.2021]}, {"w": "now", "b": [0.182, 0.1806, 0.2183, 0.2021]}, {"w": "we", "b": [0.2277, 0.1806, 0.2509, 0.2021]}, {"w": "have", "b": [0.2603, 0.1806, 0.2987, 0.2021]}, {"w": "a", "b": [0.3082, 0.1806, 0.3173, 0.2021]}, {"w": "problem:", "b": [0.3268, 0.1806, 0.4026, 0.2021]}, {"w": "the", "b": [0.4121, 0.1806, 0.4384, 0.2021]}, {"w": "flowers", "b": [0.4479, 0.1806, 0.5084, 0.2021]}, {"w": "dataset", "b": [0.5179, 0.1806, 0.576, 0.2021]}, {"w": "does", "b": [0.5855, 0.1806, 0.6236, 0.2021]}, {"w": "not", "b": [0.633, 0.1806, 0.6614, 0.2021]}, {"w": "have", "b": [0.6709, 0.1806, 0.7093, 0.2021]}, {"w": "bounding", "b": [0.7187, 0.1806, 0.8001, 0.2021]}, {"w": "boxes", "b": [0.8096, 0.1806, 0.8571, 0.2021]}, {"w": "around", "b": [0.1429, 0.1997, 0.2038, 0.2211]}, {"w": "the", "b": [0.2094, 0.1997, 0.2358, 0.2211]}, {"w": "flowers.", "b": [0.2414, 0.1997, 0.3067, 0.2211]}, {"w": "So", "b": [0.3123, 0.1997, 0.3328, 0.2211]}, {"w": "we", "b": [0.3385, 0.1997, 0.3616, 0.2211]}, {"w": "need", "b": [0.3672, 0.1997, 0.4073, 0.2211]}, {"w": "to", "b": [0.413, 0.1997, 0.4299, 0.2211]}, {"w": "add", "b": [0.4356, 0.1997, 0.4667, 0.2211]}, {"w": "them", "b": [0.4724, 0.1997, 0.5158, 0.2211]}, {"w": "ourselves.", "b": [0.5214, 0.1997, 0.6035, 0.2211]}, {"w": "This", "b": [0.6091, 0.1997, 0.6463, 0.2211]}, {"w": "is", "b": [0.6519, 0.1997, 0.6652, 0.2211]}, {"w": "often", "b": [0.6708, 0.1997, 0.7142, 0.2211]}, {"w": "one", "b": [0.7198, 0.1997, 0.7507, 0.2211]}, {"w": "of", "b": [0.7563, 0.1997, 0.7731, 0.2211]}, {"w": "the", "b": [0.7788, 0.1997, 0.8051, 0.2211]}, {"w": "hard‐", "b": [0.8107, 0.1997, 0.8571, 0.2211]}, {"w": "est", "b": [0.1429, 0.2187, 0.1657, 0.2402]}, {"w": "and", "b": [0.1716, 0.2187, 0.2032, 0.2402]}, {"w": "most", "b": [0.2091, 0.2187, 0.2508, 0.2402]}, {"w": "costly", "b": [0.2567, 0.2187, 0.305, 0.2402]}, {"w": "part", "b": [0.3109, 0.2187, 0.3451, 0.2402]}, {"w": "of", "b": [0.351, 0.2187, 0.3678, 0.2402]}, {"w": "a", "b": [0.3737, 0.2187, 0.3828, 0.2402]}, {"w": "Machine", "b": [0.3888, 0.2187, 0.4619, 0.2402]}, {"w": "Learning", "b": [0.4678, 0.2187, 0.5429, 0.2402]}, {"w": "project:", "b": [0.5488, 0.2187, 0.6122, 0.2402]}, {"w": "getting", "b": [0.6181, 0.2187, 0.6761, 0.2402]}, {"w": "the", "b": [0.6821, 0.2187, 0.7084, 0.2402]}, {"w": "labels.", "b": [0.7143, 0.2187, 0.7658, 0.2402]}, {"w": "It’s", "b": [0.7718, 0.2187, 0.7942, 0.2402]}, {"w": "a", "b": [0.8001, 0.2187, 0.8092, 0.2402]}, {"w": "good", "b": [0.8152, 0.2187, 0.8572, 0.2402]}, {"w": "idea", "b": [0.1429, 0.2378, 0.1774, 0.2592]}, {"w": "to", "b": [0.1855, 0.2378, 0.2024, 0.2592]}, {"w": "spend", "b": [0.2104, 0.2378, 0.2603, 0.2592]}, {"w": "time", "b": [0.2683, 0.2378, 0.3061, 0.2592]}, {"w": "looking", "b": [0.3141, 0.2378, 0.3777, 0.2592]}, {"w": "for", "b": [0.3857, 0.2378, 0.4102, 0.2592]}, {"w": "the", "b": [0.4182, 0.2378, 0.4446, 0.2592]}, {"w": "right", "b": [0.4526, 0.2378, 0.4927, 0.2592]}, {"w": "tools.", "b": [0.5007, 0.2378, 0.546, 0.2592]}, {"w": "To", "b": [0.554, 0.2378, 0.5755, 0.2592]}, {"w": "annotate", "b": [0.5835, 0.2378, 0.6563, 0.2592]}, {"w": "images", "b": [0.6644, 0.2378, 0.7224, 0.2592]}, {"w": "with", "b": [0.7304, 0.2378, 0.7677, 0.2592]}, {"w": "bounding", "b": [0.7757, 0.2378, 0.8571, 0.2592]}, {"w": "boxes,", "b": [0.1429, 0.2568, 0.1951, 0.2783]}, {"w": "you", "b": [0.2036, 0.2568, 0.2348, 0.2783]}, {"w": "may", "b": [0.2433, 0.2568, 0.2787, 0.2783]}, {"w": "want", "b": [0.2871, 0.2568, 0.3279, 0.2783]}, {"w": "to", "b": [0.3363, 0.2568, 0.3533, 0.2783]}, {"w": "use", "b": [0.3618, 0.2568, 0.3893, 0.2783]}, {"w": "an", "b": [0.3978, 0.2568, 0.4183, 0.2783]}, {"w": "open", "b": [0.4268, 0.2568, 0.4685, 0.2783]}, {"w": "source", "b": [0.477, 0.2568, 0.5317, 0.2783]}, {"w": "image", "b": [0.5402, 0.2568, 0.5906, 0.2783]}, {"w": "labeling", "b": [0.599, 0.2568, 0.6649, 0.2783]}, {"w": "tool", "b": [0.6733, 0.2568, 0.7062, 0.2783]}, {"w": "like", "b": [0.7146, 0.2568, 0.7447, 0.2783]}, {"w": "VGG", "b": [0.7531, 0.2568, 0.7968, 0.2783]}, {"w": "Image", "b": [0.8052, 0.2568, 0.8571, 0.2783]}, {"w": "Annotator,", "b": [0.1428, 0.2759, 0.2339, 0.2973]}, {"w": "LabelImg,", "b": [0.2428, 0.2759, 0.3265, 0.2973]}, {"w": "OpenLabeler", "b": [0.3353, 0.2759, 0.4437, 0.2973]}, {"w": "or", "b": [0.4525, 0.2759, 0.4709, 0.2973]}, {"w": "ImgLab,", "b": [0.4797, 0.2759, 0.5487, 0.2973]}, {"w": "or", "b": [0.5576, 0.2759, 0.5759, 0.2973]}, {"w": "perhaps", "b": [0.5848, 0.2759, 0.6507, 0.2973]}, {"w": "a", "b": [0.6596, 0.2759, 0.6687, 0.2973]}, {"w": "commercial", "b": [0.6776, 0.2759, 0.7765, 0.2973]}, {"w": "tool", "b": [0.7854, 0.2759, 0.8182, 0.2973]}, {"w": "like", "b": [0.8271, 0.2759, 0.8571, 0.2973]}, {"w": "LabelBox", "b": [0.1429, 0.2949, 0.221, 0.3163]}, {"w": "or", "b": [0.2294, 0.2949, 0.2478, 0.3163]}, {"w": "Supervisely.", "b": [0.2561, 0.2949, 0.3549, 0.3163]}, {"w": "You", "b": [0.3633, 0.2949, 0.3956, 0.3163]}, {"w": "may", "b": [0.404, 0.2949, 0.4394, 0.3163]}, {"w": "also", "b": [0.4477, 0.2949, 0.4804, 0.3163]}, {"w": "want", "b": [0.4888, 0.2949, 0.5296, 0.3163]}, {"w": "to", "b": [0.5379, 0.2949, 0.5549, 0.3163]}, {"w": "consider", "b": [0.5632, 0.2949, 0.6349, 0.3163]}, {"w": "crowdsourcing", "b": [0.6432, 0.2949, 0.7683, 0.3163]}, {"w": "platforms", "b": [0.7766, 0.2949, 0.8571, 0.3163]}, {"w": "such", "b": [0.1429, 0.314, 0.1815, 0.3354]}, {"w": "as", "b": [0.1863, 0.314, 0.2031, 0.3354]}, {"w": "Amazon", "b": [0.2079, 0.314, 0.2792, 0.3354]}, {"w": "Mechanical", "b": [0.284, 0.314, 0.3802, 0.3354]}, {"w": "Turk", "b": [0.385, 0.314, 0.4249, 0.3354]}, {"w": "or", "b": [0.4297, 0.314, 0.4481, 0.3354]}, {"w": "CrowdFlower", "b": [0.4529, 0.314, 0.5681, 0.3354]}, {"w": "if", "b": [0.5729, 0.314, 0.5846, 0.3354]}, {"w": "you", "b": [0.5894, 0.314, 0.6207, 0.3354]}, {"w": "have", "b": [0.6255, 0.314, 0.6638, 0.3354]}, {"w": "a", "b": [0.6686, 0.314, 0.6778, 0.3354]}, {"w": "very", "b": [0.6826, 0.314, 0.719, 0.3354]}, {"w": "large", "b": [0.7237, 0.314, 0.7645, 0.3354]}, {"w": "number", "b": [0.7693, 0.314, 0.8356, 0.3354]}, {"w": "of", "b": [0.8404, 0.314, 0.8571, 0.3354]}, {"w": "images", "b": [0.1429, 0.333, 0.2009, 0.3544]}, {"w": "to", "b": [0.2068, 0.333, 0.2238, 0.3544]}, {"w": "annotate.", "b": [0.2298, 0.333, 0.3074, 0.3544]}, {"w": "However,", "b": [0.3133, 0.333, 0.3922, 0.3544]}, {"w": "it", "b": [0.3982, 0.333, 0.4101, 0.3544]}, {"w": "is", "b": [0.416, 0.333, 0.4293, 0.3544]}, {"w": "quite", "b": [0.4352, 0.333, 0.4777, 0.3544]}, {"w": "a", "b": [0.4837, 0.333, 0.4928, 0.3544]}, {"w": "lot", "b": [0.4988, 0.333, 0.521, 0.3544]}, {"w": "of", "b": [0.527, 0.333, 0.5438, 0.3544]}, {"w": "work", "b": [0.5497, 0.333, 0.5927, 0.3544]}, {"w": "to", "b": [0.5986, 0.333, 0.6156, 0.3544]}, {"w": "setup", "b": [0.6216, 0.333, 0.6664, 0.3544]}, {"w": "a", "b": [0.6723, 0.333, 0.6815, 0.3544]}, {"w": "crowdsourcing", "b": [0.6874, 0.333, 0.8125, 0.3544]}, {"w": "plat‐", "b": [0.8184, 0.333, 0.8571, 0.3544]}, {"w": "form,", "b": [0.1429, 0.3521, 0.1892, 0.3735]}, {"w": "prepare", "b": [0.1957, 0.3521, 0.2599, 0.3735]}, {"w": "the", "b": [0.2664, 0.3521, 0.2927, 0.3735]}, {"w": "form", "b": [0.2993, 0.3521, 0.3409, 0.3735]}, {"w": "to", "b": [0.3474, 0.3521, 0.3644, 0.3735]}, {"w": "be", "b": [0.3709, 0.3521, 0.3904, 0.3735]}, {"w": "sent", "b": [0.3969, 0.3521, 0.4307, 0.3735]}, {"w": "to", "b": [0.4373, 0.3521, 0.4543, 0.3735]}, {"w": "the", "b": [0.4608, 0.3521, 0.4871, 0.3735]}, {"w": "workers,", "b": [0.4937, 0.3521, 0.5656, 0.3735]}, {"w": "to", "b": [0.5721, 0.3521, 0.5891, 0.3735]}, {"w": "supervise", "b": [0.5957, 0.3521, 0.6742, 0.3735]}, {"w": "them", "b": [0.6807, 0.3521, 0.7241, 0.3735]}, {"w": "and", "b": [0.7307, 0.3521, 0.7622, 0.3735]}, {"w": "ensure", "b": [0.7687, 0.3521, 0.8243, 0.3735]}, {"w": "the", "b": [0.8308, 0.3521, 0.8572, 0.3735]}, {"w": "quality", "b": [0.1429, 0.3711, 0.2005, 0.3925]}, {"w": "of", "b": [0.2084, 0.3711, 0.2252, 0.3925]}, {"w": "the", "b": [0.2332, 0.3711, 0.2595, 0.3925]}, {"w": "bounding", "b": [0.2674, 0.3711, 0.3488, 0.3925]}, {"w": "boxes", "b": [0.3568, 0.3711, 0.4043, 0.3925]}, {"w": "they", "b": [0.4123, 0.3711, 0.4482, 0.3925]}, {"w": "produce", "b": [0.4561, 0.3711, 0.5251, 0.3925]}, {"w": "is", "b": [0.5331, 0.3711, 0.5463, 0.3925]}, {"w": "good,", "b": [0.5542, 0.3711, 0.601, 0.3925]}, {"w": "so", "b": [0.6089, 0.3711, 0.6272, 0.3925]}, {"w": "make", "b": [0.6351, 0.3711, 0.6805, 0.3925]}, {"w": "sure", "b": [0.6885, 0.3711, 0.7238, 0.3925]}, {"w": "it", "b": [0.7317, 0.3711, 0.7436, 0.3925]}, {"w": "is", "b": [0.7516, 0.3711, 0.7648, 0.3925]}, {"w": "worth", "b": [0.7728, 0.3711, 0.8229, 0.3925]}, {"w": "the", "b": [0.8308, 0.3711, 0.8571, 0.3925]}, {"w": "effort:", "b": [0.1429, 0.3902, 0.1935, 0.4116]}, {"w": "if", "b": [0.1998, 0.3902, 0.2115, 0.4116]}, {"w": "there", "b": [0.2178, 0.3902, 0.2607, 0.4116]}, {"w": "are", "b": [0.267, 0.3902, 0.2927, 0.4116]}, {"w": "just", "b": [0.299, 0.3902, 0.3294, 0.4116]}, {"w": "a", "b": [0.3357, 0.3902, 0.3448, 0.4116]}, {"w": "few", "b": [0.3511, 0.3902, 0.3804, 0.4116]}, {"w": "thousand", "b": [0.3867, 0.3902, 0.465, 0.4116]}, {"w": "images", "b": [0.4713, 0.3902, 0.5293, 0.4116]}, {"w": "to", "b": [0.5356, 0.3902, 0.5526, 0.4116]}, {"w": "label,", "b": [0.5589, 0.3902, 0.6028, 0.4116]}, {"w": "and", "b": [0.609, 0.3902, 0.6406, 0.4116]}, {"w": "you", "b": [0.6469, 0.3902, 0.6781, 0.4116]}, {"w": "don’t", "b": [0.6844, 0.3902, 0.726, 0.4116]}, {"w": "plan", "b": [0.7323, 0.3902, 0.769, 0.4116]}, {"w": "to", "b": [0.7753, 0.3902, 0.7923, 0.4116]}, {"w": "do", "b": [0.7985, 0.3902, 0.8202, 0.4116]}, {"w": "this", "b": [0.8264, 0.3902, 0.8571, 0.4116]}, {"w": "frequently,", "b": [0.1428, 0.4092, 0.2316, 0.4306]}, {"w": "it", "b": [0.2366, 0.4092, 0.2486, 0.4306]}, {"w": "may", "b": [0.2536, 0.4092, 0.289, 0.4306]}, {"w": "be", "b": [0.294, 0.4092, 0.3135, 0.4306]}, {"w": "preferable", "b": [0.3185, 0.4092, 0.4026, 0.4306]}, {"w": "to", "b": [0.4077, 0.4092, 0.4247, 0.4306]}, {"w": "do", "b": [0.4297, 0.4092, 0.4513, 0.4306]}, {"w": "it", "b": [0.4564, 0.4092, 0.4683, 0.4306]}, {"w": "yourself.", "b": [0.4734, 0.4092, 0.545, 0.4306]}, {"w": "Adriana", "b": [0.5501, 0.4092, 0.6179, 0.4306]}, {"w": "Kovashka", "b": [0.623, 0.4092, 0.7042, 0.4306]}, {"w": "et", "b": [0.7092, 0.4092, 0.7244, 0.4306]}, {"w": "al.", "b": [0.7295, 0.4092, 0.7486, 0.4306]}, {"w": "wrote", "b": [0.7537, 0.4092, 0.8015, 0.4306]}, {"w": "a", "b": [0.8065, 0.4092, 0.8157, 0.4306]}, {"w": "very", "b": [0.8207, 0.4092, 0.8571, 0.4306]}, {"w": "practical", "b": [0.1429, 0.4283, 0.2146, 0.4497]}, {"w": "paper22", "b": [0.2207, 0.4283, 0.2793, 0.4497]}, {"w": "about", "b": [0.2854, 0.4283, 0.3332, 0.4497]}, {"w": "crowdsourcing", "b": [0.3393, 0.4283, 0.4643, 0.4497]}, {"w": "in", "b": [0.4704, 0.4283, 0.4874, 0.4497]}, {"w": "Computer", "b": [0.4935, 0.4283, 0.5796, 0.4497]}, {"w": "Vision,", "b": [0.5857, 0.4283, 0.6451, 0.4497]}, {"w": "I", "b": [0.6512, 0.4283, 0.6583, 0.4497]}, {"w": "recommend", "b": [0.6644, 0.4283, 0.7658, 0.4497]}, {"w": "you", "b": [0.7719, 0.4283, 0.8031, 0.4497]}, {"w": "check", "b": [0.8092, 0.4283, 0.8571, 0.4497]}, {"w": "it", "b": [0.1429, 0.4473, 0.1548, 0.4687]}, {"w": "out,", "b": [0.1595, 0.4473, 0.1923, 0.4687]}, {"w": "even", "b": [0.197, 0.4473, 0.2358, 0.4687]}, {"w": "if", "b": [0.2405, 0.4473, 0.2523, 0.4687]}, {"w": "you", "b": [0.257, 0.4473, 0.2883, 0.4687]}, {"w": "do", "b": [0.293, 0.4473, 0.3146, 0.4687]}, {"w": "not", "b": [0.3193, 0.4473, 0.3477, 0.4687]}, {"w": "plan", "b": [0.3524, 0.4473, 0.3892, 0.4687]}, {"w": "to", "b": [0.3939, 0.4473, 0.4109, 0.4687]}, {"w": "use", "b": [0.4156, 0.4473, 0.4432, 0.4687]}, {"w": "crowdsourcing.", "b": [0.4479, 0.4473, 0.5777, 0.4687]}]}, {"id": "b_3", "type": "paragraph", "text": "So let’s suppose you obtained the bounding boxes for every image in the flowers data‐ set (for now we will assume there is a single bounding box per image), you then need to create a dataset whose items will be batches of preprocessed images along with their class labels and their bounding boxes. Each item should be a tuple of the form: (images, (class_labels, bounding_boxes)). Then you are ready to train your model!", "words": [{"w": "So", "b": [0.1429, 0.4754, 0.1634, 0.4968]}, {"w": "let’s", "b": [0.1683, 0.4754, 0.1985, 0.4968]}, {"w": "suppose", "b": [0.2035, 0.4754, 0.2711, 0.4968]}, {"w": "you", "b": [0.2761, 0.4754, 0.3073, 0.4968]}, {"w": "obtained", "b": [0.3123, 0.4754, 0.3858, 0.4968]}, {"w": "the", "b": [0.3907, 0.4754, 0.4171, 0.4968]}, {"w": "bounding", "b": [0.422, 0.4754, 0.5034, 0.4968]}, {"w": "boxes", "b": [0.5083, 0.4754, 0.5559, 0.4968]}, {"w": "for", "b": [0.5608, 0.4754, 0.5853, 0.4968]}, {"w": "every", "b": [0.5903, 0.4754, 0.6355, 0.4968]}, {"w": "image", "b": [0.6405, 0.4754, 0.6909, 0.4968]}, {"w": "in", "b": [0.6958, 0.4754, 0.7128, 0.4968]}, {"w": "the", "b": [0.7177, 0.4754, 0.744, 0.4968]}, {"w": "flowers", "b": [0.749, 0.4754, 0.8095, 0.4968]}, {"w": "data‐", "b": [0.8145, 0.4754, 0.8571, 0.4968]}, {"w": "set", "b": [0.1429, 0.4945, 0.1657, 0.5159]}, {"w": "(for", "b": [0.1709, 0.4945, 0.2026, 0.5159]}, {"w": "now", "b": [0.2078, 0.4945, 0.2441, 0.5159]}, {"w": "we", "b": [0.2493, 0.4945, 0.2725, 0.5159]}, {"w": "will", "b": [0.2777, 0.4945, 0.3081, 0.5159]}, {"w": "assume", "b": [0.3133, 0.4945, 0.3747, 0.5159]}, {"w": "there", "b": [0.3799, 0.4945, 0.4228, 0.5159]}, {"w": "is", "b": [0.428, 0.4945, 0.4413, 0.5159]}, {"w": "a", "b": [0.4465, 0.4945, 0.4556, 0.5159]}, {"w": "single", "b": [0.4608, 0.4945, 0.5093, 0.5159]}, {"w": "bounding", "b": [0.5145, 0.4945, 0.5959, 0.5159]}, {"w": "box", "b": [0.6011, 0.4945, 0.6322, 0.5159]}, {"w": "per", "b": [0.6374, 0.4945, 0.6649, 0.5159]}, {"w": "image),", "b": [0.6701, 0.4945, 0.7324, 0.5159]}, {"w": "you", "b": [0.7376, 0.4945, 0.7689, 0.5159]}, {"w": "then", "b": [0.7741, 0.4945, 0.8118, 0.5159]}, {"w": "need", "b": [0.817, 0.4945, 0.8571, 0.5159]}, {"w": "to", "b": [0.1429, 0.5135, 0.1598, 0.5349]}, {"w": "create", "b": [0.1678, 0.5135, 0.2171, 0.5349]}, {"w": "a", "b": [0.225, 0.5135, 0.2342, 0.5349]}, {"w": "dataset", "b": [0.2421, 0.5135, 0.3002, 0.5349]}, {"w": "whose", "b": [0.3081, 0.5135, 0.3606, 0.5349]}, {"w": "items", "b": [0.3685, 0.5135, 0.414, 0.5349]}, {"w": "will", "b": [0.4219, 0.5135, 0.4523, 0.5349]}, {"w": "be", "b": [0.4602, 0.5135, 0.4796, 0.5349]}, {"w": "batches", "b": [0.4876, 0.5135, 0.5497, 0.5349]}, {"w": "of", "b": [0.5576, 0.5135, 0.5744, 0.5349]}, {"w": "preprocessed", "b": [0.5823, 0.5135, 0.6919, 0.5349]}, {"w": "images", "b": [0.6998, 0.5135, 0.7578, 0.5349]}, {"w": "along", "b": [0.7657, 0.5135, 0.8119, 0.5349]}, {"w": "with", "b": [0.8198, 0.5135, 0.8572, 0.5349]}, {"w": "their", "b": [0.1429, 0.5326, 0.1825, 0.554]}, {"w": "class", "b": [0.1884, 0.5326, 0.2269, 0.554]}, {"w": "labels", "b": [0.2328, 0.5326, 0.2796, 0.554]}, {"w": "and", "b": [0.2855, 0.5326, 0.317, 0.554]}, {"w": "their", "b": [0.3229, 0.5326, 0.3626, 0.554]}, {"w": "bounding", "b": [0.3685, 0.5326, 0.4499, 0.554]}, {"w": "boxes.", "b": [0.4558, 0.5326, 0.5081, 0.554]}, {"w": "Each", "b": [0.514, 0.5326, 0.5549, 0.554]}, {"w": "item", "b": [0.5608, 0.5326, 0.5986, 0.554]}, {"w": "should", "b": [0.6045, 0.5326, 0.6613, 0.554]}, {"w": "be", "b": [0.6672, 0.5326, 0.6866, 0.554]}, {"w": "a", "b": [0.6925, 0.5326, 0.7016, 0.554]}, {"w": "tuple", "b": [0.7075, 0.5326, 0.75, 0.554]}, {"w": "of", "b": [0.7559, 0.5326, 0.7727, 0.554]}, {"w": "the", "b": [0.7786, 0.5326, 0.8049, 0.554]}, {"w": "form:", "b": [0.8108, 0.5326, 0.8571, 0.554]}, {"w": "(images,", "b": [0.1429, 0.5557, 0.222, 0.5708]}, {"w": "(class_labels,", "b": [0.2359, 0.5557, 0.3744, 0.5708]}, {"w": "bounding_boxes)).", "b": [0.3882, 0.5525, 0.5513, 0.5739]}, {"w": "Then", "b": [0.5602, 0.5525, 0.6044, 0.5739]}, {"w": "you", "b": [0.6133, 0.5525, 0.6446, 0.5739]}, {"w": "are", "b": [0.6534, 0.5525, 0.6792, 0.5739]}, {"w": "ready", "b": [0.6881, 0.5525, 0.7343, 0.5739]}, {"w": "to", "b": [0.7432, 0.5525, 0.7602, 0.5739]}, {"w": "train", "b": [0.7691, 0.5525, 0.8093, 0.5739]}, {"w": "your", "b": [0.8182, 0.5525, 0.8572, 0.5739]}, {"w": "model!", "b": [0.1429, 0.5716, 0.2014, 0.593]}]}, {"id": "b_4", "type": "paragraph", "text": "The bounding boxes should be normalized so that the horizontal and vertical coordinates, as well as the height and width all range from 0 to 1. Also, it is common to predict the square root of the height and width rather than the height and width directly: this way, a 10 pixel error for a large bounding box will not be penalized as much as a 10 pixel error for a small bounding box.", "words": [{"w": "The", "b": [0.2714, 0.6135, 0.3014, 0.6331]}, {"w": "bounding", "b": [0.3081, 0.6135, 0.3825, 0.6331]}, {"w": "boxes", "b": [0.3892, 0.6135, 0.4327, 0.6331]}, {"w": "should", "b": [0.4394, 0.6135, 0.4912, 0.6331]}, {"w": "be", "b": [0.4979, 0.6135, 0.5157, 0.6331]}, {"w": "normalized", "b": [0.5224, 0.6135, 0.6096, 0.6331]}, {"w": "so", "b": [0.6163, 0.6135, 0.633, 0.6331]}, {"w": "that", "b": [0.6397, 0.6135, 0.6694, 0.6331]}, {"w": "the", "b": [0.6761, 0.6135, 0.7002, 0.6331]}, {"w": "horizontal", "b": [0.7069, 0.6135, 0.7857, 0.6331]}, {"w": "and", "b": [0.2714, 0.6309, 0.3002, 0.6505]}, {"w": "vertical", "b": [0.3065, 0.6309, 0.3626, 0.6505]}, {"w": "coordinates,", "b": [0.3688, 0.6309, 0.4622, 0.6505]}, {"w": "as", "b": [0.4685, 0.6309, 0.4838, 0.6505]}, {"w": "well", "b": [0.49, 0.6309, 0.5208, 0.6505]}, {"w": "as", "b": [0.5271, 0.6309, 0.5424, 0.6505]}, {"w": "the", "b": [0.5487, 0.6309, 0.5727, 0.6505]}, {"w": "height", "b": [0.579, 0.6309, 0.6269, 0.6505]}, {"w": "and", "b": [0.6331, 0.6309, 0.6619, 0.6505]}, {"w": "width", "b": [0.6682, 0.6309, 0.7124, 0.6505]}, {"w": "all", "b": [0.7186, 0.6309, 0.7366, 0.6505]}, {"w": "range", "b": [0.7429, 0.6309, 0.7857, 0.6505]}, {"w": "from", "b": [0.2714, 0.6483, 0.3094, 0.6679]}, {"w": "0", "b": [0.316, 0.6483, 0.3251, 0.6679]}, {"w": "to", "b": [0.3317, 0.6483, 0.3472, 0.6679]}, {"w": "1.", "b": [0.3537, 0.6483, 0.3672, 0.6679]}, {"w": "Also,", "b": [0.3738, 0.6483, 0.4122, 0.6679]}, {"w": "it", "b": [0.4188, 0.6483, 0.4297, 0.6679]}, {"w": "is", "b": [0.4363, 0.6483, 0.4484, 0.6679]}, {"w": "common", "b": [0.4549, 0.6483, 0.524, 0.6679]}, {"w": "to", "b": [0.5306, 0.6483, 0.5461, 0.6679]}, {"w": "predict", "b": [0.5526, 0.6483, 0.6068, 0.6679]}, {"w": "the", "b": [0.6133, 0.6483, 0.6374, 0.6679]}, {"w": "square", "b": [0.644, 0.6483, 0.6943, 0.6679]}, {"w": "root", "b": [0.7009, 0.6483, 0.7332, 0.6679]}, {"w": "of", "b": [0.7397, 0.6483, 0.7551, 0.6679]}, {"w": "the", "b": [0.7616, 0.6483, 0.7857, 0.6679]}, {"w": "height", "b": [0.2714, 0.6658, 0.3193, 0.6853]}, {"w": "and", "b": [0.327, 0.6658, 0.3558, 0.6853]}, {"w": "width", "b": [0.3635, 0.6658, 0.4077, 0.6853]}, {"w": "rather", "b": [0.4153, 0.6658, 0.4615, 0.6853]}, {"w": "than", "b": [0.4692, 0.6658, 0.504, 0.6853]}, {"w": "the", "b": [0.5116, 0.6658, 0.5357, 0.6853]}, {"w": "height", "b": [0.5434, 0.6658, 0.5913, 0.6853]}, {"w": "and", "b": [0.5989, 0.6658, 0.6278, 0.6853]}, {"w": "width", "b": [0.6354, 0.6658, 0.6796, 0.6853]}, {"w": "directly:", "b": [0.6873, 0.6658, 0.75, 0.6853]}, {"w": "this", "b": [0.7576, 0.6658, 0.7857, 0.6853]}, {"w": "way,", "b": [0.2714, 0.6832, 0.3042, 0.7027]}, {"w": "a", "b": [0.3091, 0.6832, 0.3174, 0.7027]}, {"w": "10", "b": [0.3223, 0.6832, 0.3406, 0.7027]}, {"w": "pixel", "b": [0.3455, 0.6832, 0.3825, 0.7027]}, {"w": "error", "b": [0.3874, 0.6832, 0.4264, 0.7027]}, {"w": "for", "b": [0.4313, 0.6832, 0.4537, 0.7027]}, {"w": "a", "b": [0.4586, 0.6832, 0.467, 0.7027]}, {"w": "large", "b": [0.4719, 0.6832, 0.5091, 0.7027]}, {"w": "bounding", "b": [0.514, 0.6832, 0.5884, 0.7027]}, {"w": "box", "b": [0.5933, 0.6832, 0.6217, 0.7027]}, {"w": "will", "b": [0.6266, 0.6832, 0.6544, 0.7027]}, {"w": "not", "b": [0.6593, 0.6832, 0.6852, 0.7027]}, {"w": "be", "b": [0.6901, 0.6832, 0.7079, 0.7027]}, {"w": "penalized", "b": [0.7128, 0.6832, 0.7857, 0.7027]}, {"w": "as", "b": [0.2714, 0.7006, 0.2868, 0.7202]}, {"w": "much", "b": [0.2911, 0.7006, 0.3347, 0.7202]}, {"w": "as", "b": [0.339, 0.7006, 0.3543, 0.7202]}, {"w": "a", "b": [0.3587, 0.7006, 0.367, 0.7202]}, {"w": "10", "b": [0.3713, 0.7006, 0.3896, 0.7202]}, {"w": "pixel", "b": [0.394, 0.7006, 0.4309, 0.7202]}, {"w": "error", "b": [0.4353, 0.7006, 0.4743, 0.7202]}, {"w": "for", "b": [0.4786, 0.7006, 0.501, 0.7202]}, {"w": "a", "b": [0.5053, 0.7006, 0.5137, 0.7202]}, {"w": "small", "b": [0.518, 0.7006, 0.5586, 0.7202]}, {"w": "bounding", "b": [0.5629, 0.7006, 0.6374, 0.7202]}, {"w": "box.", "b": [0.6417, 0.7006, 0.6744, 0.7202]}]}, {"id": "b_5", "type": "paragraph", "text": "The MSE often works fairly well as a cost function to train the model, but it is not a great metric to evaluate how well the model can predict bounding boxes. The most common metric for this is the Intersection over Union (IoU): it is the area of overlap between the predicted bounding box and the target bounding box, divided by the", "words": [{"w": "The", "b": [0.1429, 0.7405, 0.1757, 0.7619]}, {"w": "MSE", "b": [0.1817, 0.7405, 0.2219, 0.7619]}, {"w": "often", "b": [0.2279, 0.7405, 0.2713, 0.7619]}, {"w": "works", "b": [0.2773, 0.7405, 0.3279, 0.7619]}, {"w": "fairly", "b": [0.3338, 0.7405, 0.3773, 0.7619]}, {"w": "well", "b": [0.3833, 0.7405, 0.4169, 0.7619]}, {"w": "as", "b": [0.4229, 0.7405, 0.4397, 0.7619]}, {"w": "a", "b": [0.4457, 0.7405, 0.4548, 0.7619]}, {"w": "cost", "b": [0.4608, 0.7405, 0.4942, 0.7619]}, {"w": "function", "b": [0.5002, 0.7405, 0.5716, 0.7619]}, {"w": "to", "b": [0.5776, 0.7405, 0.5946, 0.7619]}, {"w": "train", "b": [0.6005, 0.7405, 0.6407, 0.7619]}, {"w": "the", "b": [0.6467, 0.7405, 0.673, 0.7619]}, {"w": "model,", "b": [0.679, 0.7405, 0.7366, 0.7619]}, {"w": "but", "b": [0.7426, 0.7405, 0.7706, 0.7619]}, {"w": "it", "b": [0.7765, 0.7405, 0.7885, 0.7619]}, {"w": "is", "b": [0.7944, 0.7405, 0.8077, 0.7619]}, {"w": "not", "b": [0.8136, 0.7405, 0.842, 0.7619]}, {"w": "a", "b": [0.848, 0.7405, 0.8571, 0.7619]}, {"w": "great", "b": [0.1429, 0.7595, 0.1843, 0.7809]}, {"w": "metric", "b": [0.1911, 0.7595, 0.2455, 0.7809]}, {"w": "to", "b": [0.2522, 0.7595, 0.2692, 0.7809]}, {"w": "evaluate", "b": [0.276, 0.7595, 0.3439, 0.7809]}, {"w": "how", "b": [0.3507, 0.7595, 0.3867, 0.7809]}, {"w": "well", "b": [0.3934, 0.7595, 0.4271, 0.7809]}, {"w": "the", "b": [0.4339, 0.7595, 0.4602, 0.7809]}, {"w": "model", "b": [0.467, 0.7595, 0.5198, 0.7809]}, {"w": "can", "b": [0.5265, 0.7595, 0.5559, 0.7809]}, {"w": "predict", "b": [0.5627, 0.7595, 0.6219, 0.7809]}, {"w": "bounding", "b": [0.6287, 0.7595, 0.7101, 0.7809]}, {"w": "boxes.", "b": [0.7168, 0.7595, 0.7691, 0.7809]}, {"w": "The", "b": [0.7759, 0.7595, 0.8087, 0.7809]}, {"w": "most", "b": [0.8155, 0.7595, 0.8572, 0.7809]}, {"w": "common", "b": [0.1429, 0.7786, 0.2184, 0.8]}, {"w": "metric", "b": [0.2239, 0.7786, 0.2783, 0.8]}, {"w": "for", "b": [0.2838, 0.7786, 0.3083, 0.8]}, {"w": "this", "b": [0.3138, 0.7786, 0.3445, 0.8]}, {"w": "is", "b": [0.35, 0.7786, 0.3632, 0.8]}, {"w": "the", "b": [0.3687, 0.7786, 0.395, 0.8]}, {"w": "Intersection", "b": [0.4005, 0.7786, 0.5008, 0.8]}, {"w": "over", "b": [0.5063, 0.7786, 0.5432, 0.8]}, {"w": "Union", "b": [0.5487, 0.7786, 0.6021, 0.8]}, {"w": "(IoU):", "b": [0.6076, 0.7786, 0.6593, 0.8]}, {"w": "it", "b": [0.6648, 0.7786, 0.6767, 0.8]}, {"w": "is", "b": [0.6822, 0.7786, 0.6954, 0.8]}, {"w": "the", "b": [0.7009, 0.7786, 0.7272, 0.8]}, {"w": "area", "b": [0.7327, 0.7786, 0.7676, 0.8]}, {"w": "of", "b": [0.7731, 0.7786, 0.7899, 0.8]}, {"w": "overlap", "b": [0.7954, 0.7786, 0.8571, 0.8]}, {"w": "between", "b": [0.1429, 0.7976, 0.212, 0.819]}, {"w": "the", "b": [0.2199, 0.7976, 0.2463, 0.819]}, {"w": "predicted", "b": [0.2542, 0.7976, 0.3333, 0.819]}, {"w": "bounding", "b": [0.3412, 0.7976, 0.4226, 0.819]}, {"w": "box", "b": [0.4305, 0.7976, 0.4615, 0.819]}, {"w": "and", "b": [0.4694, 0.7976, 0.501, 0.819]}, {"w": "the", "b": [0.5089, 0.7976, 0.5352, 0.819]}, {"w": "target", "b": [0.5431, 0.7976, 0.5913, 0.819]}, {"w": "bounding", "b": [0.5992, 0.7976, 0.6806, 0.819]}, {"w": "box,", "b": [0.6885, 0.7976, 0.7243, 0.819]}, {"w": "divided", "b": [0.7322, 0.7976, 0.7949, 0.819]}, {"w": "by", "b": [0.8028, 0.7976, 0.8229, 0.819]}, {"w": "the", "b": [0.8308, 0.7976, 0.8571, 0.819]}]}, {"id": "b_6", "type": "paragraph", "text": "470 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "470", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 497, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "area of their union (see Figure 14-23). In tf.keras, it is implemented by the tf.keras.metrics.MeanIoU class.", "words": [{"w": "area", "b": [0.1429, 0.0791, 0.1777, 0.1005]}, {"w": "of", "b": [0.1901, 0.0791, 0.2069, 0.1005]}, {"w": "their", "b": [0.2192, 0.0791, 0.2589, 0.1005]}, {"w": "union", "b": [0.2712, 0.0791, 0.3213, 0.1005]}, {"w": "(see", "b": [0.3337, 0.0791, 0.3662, 0.1005]}, {"w": "Figure", "b": [0.3786, 0.0791, 0.4326, 0.1005]}, {"w": "14-23).", "b": [0.4449, 0.0791, 0.5043, 0.1005]}, {"w": "In", "b": [0.5167, 0.0791, 0.5352, 0.1005]}, {"w": "tf.keras,", "b": [0.5475, 0.0791, 0.6133, 0.1005]}, {"w": "it", "b": [0.6256, 0.0791, 0.6376, 0.1005]}, {"w": "is", "b": [0.6499, 0.0791, 0.6632, 0.1005]}, {"w": "implemented", "b": [0.6755, 0.0791, 0.7859, 0.1005]}, {"w": "by", "b": [0.7983, 0.0791, 0.8184, 0.1005]}, {"w": "the", "b": [0.8308, 0.0791, 0.8571, 0.1005]}, {"w": "tf.keras.metrics.MeanIoU", "b": [0.1429, 0.1022, 0.3804, 0.1173]}, {"w": "class.", "b": [0.3851, 0.099, 0.4284, 0.1204]}]}, {"id": "b_1", "type": "equation", "text": "Figure 14-23. Intersection over Union (IoU) Metric for Bounding Boxes", "words": [{"w": "Figure", "b": [0.1429, 0.4246, 0.1943, 0.4462]}, {"w": "14-23.", "b": [0.1991, 0.4246, 0.2507, 0.4462]}, {"w": "Intersection", "b": [0.2554, 0.4246, 0.3501, 0.4462]}, {"w": "over", "b": [0.3549, 0.4246, 0.3896, 0.4462]}, {"w": "Union", "b": [0.3944, 0.4246, 0.4453, 0.4462]}, {"w": "(IoU)", "b": [0.4501, 0.4246, 0.4949, 0.4462]}, {"w": "Metric", "b": [0.4997, 0.4246, 0.5531, 0.4462]}, {"w": "for", "b": [0.5578, 0.4246, 0.5805, 0.4462]}, {"w": "Bounding", "b": [0.5852, 0.4246, 0.664, 0.4462]}, {"w": "Boxes", "b": [0.6688, 0.4246, 0.7155, 0.4462]}]}, {"id": "b_2", "type": "paragraph", "text": "Classifying and localizing a single object is nice, but what if the images contain multi‐ ple objects (as is often the case in the flowers dataset)?", "words": [{"w": "Classifying", "b": [0.1429, 0.462, 0.2348, 0.4834]}, {"w": "and", "b": [0.2398, 0.462, 0.2713, 0.4834]}, {"w": "localizing", "b": [0.2763, 0.462, 0.3565, 0.4834]}, {"w": "a", "b": [0.3615, 0.462, 0.3707, 0.4834]}, {"w": "single", "b": [0.3756, 0.462, 0.4241, 0.4834]}, {"w": "object", "b": [0.4291, 0.462, 0.4797, 0.4834]}, {"w": "is", "b": [0.4847, 0.462, 0.4979, 0.4834]}, {"w": "nice,", "b": [0.5029, 0.462, 0.5423, 0.4834]}, {"w": "but", "b": [0.5473, 0.462, 0.5753, 0.4834]}, {"w": "what", "b": [0.5803, 0.462, 0.6208, 0.4834]}, {"w": "if", "b": [0.6258, 0.462, 0.6375, 0.4834]}, {"w": "the", "b": [0.6425, 0.462, 0.6689, 0.4834]}, {"w": "images", "b": [0.6738, 0.462, 0.7319, 0.4834]}, {"w": "contain", "b": [0.7369, 0.462, 0.7998, 0.4834]}, {"w": "multi‐", "b": [0.8048, 0.462, 0.8571, 0.4834]}, {"w": "ple", "b": [0.1428, 0.481, 0.1679, 0.5025]}, {"w": "objects", "b": [0.1726, 0.481, 0.2308, 0.5025]}, {"w": "(as", "b": [0.2356, 0.481, 0.2596, 0.5025]}, {"w": "is", "b": [0.2643, 0.481, 0.2775, 0.5025]}, {"w": "often", "b": [0.2822, 0.481, 0.3256, 0.5025]}, {"w": "the", "b": [0.3304, 0.481, 0.3567, 0.5025]}, {"w": "case", "b": [0.3614, 0.481, 0.3959, 0.5025]}, {"w": "in", "b": [0.4006, 0.481, 0.4176, 0.5025]}, {"w": "the", "b": [0.4223, 0.481, 0.4487, 0.5025]}, {"w": "flowers", "b": [0.4534, 0.481, 0.514, 0.5025]}, {"w": "dataset)?", "b": [0.5187, 0.481, 0.5919, 0.5025]}]}, {"id": "b_3", "type": "paragraph", "text": "Object Detection", "words": [{"w": "Object", "b": [0.1429, 0.5154, 0.2214, 0.5497]}, {"w": "Detection", "b": [0.2273, 0.5154, 0.3471, 0.5497]}]}, {"id": "b_4", "type": "paragraph", "text": "The task of classifying and localizing multiple objects in an image is called object detection. Until a few years ago, a common approach was to take a CNN that was trained to classify and locate a single object, then slide it across the image, as shown in Figure 14-24. In this example, the image was chopped into a 6 × 8 grid, and we show a CNN (the thick black rectangle) sliding across all 3 × 3 regions. When the CNN was looking at the top left of the image, it detected part of the left-most rose, and then it detected that same rose again when it was first shifted one step to the right. At the next step, it started detecting part of the top-most rose, and then it detec‐ ted it again once it was shifted one more step to the right. You would then continue to slide the CNN through the whole image, looking at all 3 × 3 regions. Moreover, since objects can have varying sizes, you would also slide the CNN across regions of differ‐ ent sizes. For example, once you are done with the 3 × 3 regions, you might want to slide the CNN across all 4 × 4 regions as well.", "words": [{"w": "The", "b": [0.1429, 0.5566, 0.1757, 0.578]}, {"w": "task", "b": [0.1839, 0.5566, 0.2174, 0.578]}, {"w": "of", "b": [0.2257, 0.5566, 0.2425, 0.578]}, {"w": "classifying", "b": [0.2507, 0.5566, 0.3376, 0.578]}, {"w": "and", "b": [0.3459, 0.5566, 0.3774, 0.578]}, {"w": "localizing", "b": [0.3857, 0.5566, 0.4659, 0.578]}, {"w": "multiple", "b": [0.4741, 0.5566, 0.5441, 0.578]}, {"w": "objects", "b": [0.5523, 0.5566, 0.6105, 0.578]}, {"w": "in", "b": [0.6188, 0.5566, 0.6358, 0.578]}, {"w": "an", "b": [0.644, 0.5566, 0.6646, 0.578]}, {"w": "image", "b": [0.6728, 0.5566, 0.7232, 0.578]}, {"w": "is", "b": [0.7314, 0.5566, 0.7447, 0.578]}, {"w": "called", "b": [0.7529, 0.5566, 0.8013, 0.578]}, {"w": "object", "b": [0.8095, 0.5564, 0.8571, 0.578]}, {"w": "detection.", "b": [0.1429, 0.5755, 0.2212, 0.5971]}, {"w": "Until", "b": [0.2289, 0.5757, 0.2715, 0.5971]}, {"w": "a", "b": [0.2792, 0.5757, 0.2884, 0.5971]}, {"w": "few", "b": [0.296, 0.5757, 0.3253, 0.5971]}, {"w": "years", "b": [0.333, 0.5757, 0.3759, 0.5971]}, {"w": "ago,", "b": [0.3836, 0.5757, 0.4173, 0.5971]}, {"w": "a", "b": [0.425, 0.5757, 0.4341, 0.5971]}, {"w": "common", "b": [0.4418, 0.5757, 0.5174, 0.5971]}, {"w": "approach", "b": [0.525, 0.5757, 0.6031, 0.5971]}, {"w": "was", "b": [0.6107, 0.5757, 0.6418, 0.5971]}, {"w": "to", "b": [0.6495, 0.5757, 0.6665, 0.5971]}, {"w": "take", "b": [0.6741, 0.5757, 0.7088, 0.5971]}, {"w": "a", "b": [0.7165, 0.5757, 0.7257, 0.5971]}, {"w": "CNN", "b": [0.7333, 0.5757, 0.7781, 0.5971]}, {"w": "that", "b": [0.7858, 0.5757, 0.8184, 0.5971]}, {"w": "was", "b": [0.8261, 0.5757, 0.8571, 0.5971]}, {"w": "trained", "b": [0.1429, 0.5947, 0.2029, 0.6161]}, {"w": "to", "b": [0.209, 0.5947, 0.226, 0.6161]}, {"w": "classify", "b": [0.232, 0.5947, 0.2922, 0.6161]}, {"w": "and", "b": [0.2983, 0.5947, 0.3298, 0.6161]}, {"w": "locate", "b": [0.3359, 0.5947, 0.3845, 0.6161]}, {"w": "a", "b": [0.3906, 0.5947, 0.3997, 0.6161]}, {"w": "single", "b": [0.4058, 0.5947, 0.4543, 0.6161]}, {"w": "object,", "b": [0.4604, 0.5947, 0.5157, 0.6161]}, {"w": "then", "b": [0.5217, 0.5947, 0.5595, 0.6161]}, {"w": "slide", "b": [0.5655, 0.5947, 0.6039, 0.6161]}, {"w": "it", "b": [0.61, 0.5947, 0.6219, 0.6161]}, {"w": "across", "b": [0.628, 0.5947, 0.6796, 0.6161]}, {"w": "the", "b": [0.6856, 0.5947, 0.712, 0.6161]}, {"w": "image,", "b": [0.718, 0.5947, 0.7732, 0.6161]}, {"w": "as", "b": [0.7792, 0.5947, 0.796, 0.6161]}, {"w": "shown", "b": [0.8021, 0.5947, 0.8571, 0.6161]}, {"w": "in", "b": [0.1429, 0.6138, 0.1598, 0.6352]}, {"w": "Figure", "b": [0.1669, 0.6138, 0.2209, 0.6352]}, {"w": "14-24.", "b": [0.2279, 0.6138, 0.2801, 0.6352]}, {"w": "In", "b": [0.2871, 0.6138, 0.3056, 0.6352]}, {"w": "this", "b": [0.3126, 0.6138, 0.3433, 0.6352]}, {"w": "example,", "b": [0.3503, 0.6138, 0.4246, 0.6352]}, {"w": "the", "b": [0.4316, 0.6138, 0.458, 0.6352]}, {"w": "image", "b": [0.465, 0.6138, 0.5154, 0.6352]}, {"w": "was", "b": [0.5224, 0.6138, 0.5535, 0.6352]}, {"w": "chopped", "b": [0.5605, 0.6138, 0.6327, 0.6352]}, {"w": "into", "b": [0.6397, 0.6138, 0.6733, 0.6352]}, {"w": "a", "b": [0.6803, 0.6138, 0.6895, 0.6352]}, {"w": "6", "b": [0.6965, 0.6138, 0.7065, 0.6352]}, {"w": "×", "b": [0.7135, 0.6138, 0.7256, 0.6352]}, {"w": "8", "b": [0.7326, 0.6138, 0.7426, 0.6352]}, {"w": "grid,", "b": [0.7496, 0.6138, 0.7884, 0.6352]}, {"w": "and", "b": [0.7955, 0.6138, 0.827, 0.6352]}, {"w": "we", "b": [0.834, 0.6138, 0.8572, 0.6352]}, {"w": "show", "b": [0.1429, 0.6328, 0.1865, 0.6542]}, {"w": "a", "b": [0.1938, 0.6328, 0.203, 0.6542]}, {"w": "CNN", "b": [0.2103, 0.6328, 0.2551, 0.6542]}, {"w": "(the", "b": [0.2624, 0.6328, 0.2959, 0.6542]}, {"w": "thick", "b": [0.3032, 0.6328, 0.3454, 0.6542]}, {"w": "black", "b": [0.3527, 0.6328, 0.3969, 0.6542]}, {"w": "rectangle)", "b": [0.4042, 0.6328, 0.4876, 0.6542]}, {"w": "sliding", "b": [0.4949, 0.6328, 0.5511, 0.6542]}, {"w": "across", "b": [0.5584, 0.6328, 0.61, 0.6542]}, {"w": "all", "b": [0.6173, 0.6328, 0.637, 0.6542]}, {"w": "3", "b": [0.6443, 0.6328, 0.6543, 0.6542]}, {"w": "×", "b": [0.6616, 0.6328, 0.6737, 0.6542]}, {"w": "3", "b": [0.681, 0.6328, 0.691, 0.6542]}, {"w": "regions.", "b": [0.6983, 0.6328, 0.7646, 0.6542]}, {"w": "When", "b": [0.7719, 0.6328, 0.8235, 0.6542]}, {"w": "the", "b": [0.8308, 0.6328, 0.8571, 0.6542]}, {"w": "CNN", "b": [0.1429, 0.6519, 0.1877, 0.6733]}, {"w": "was", "b": [0.1943, 0.6519, 0.2253, 0.6733]}, {"w": "looking", "b": [0.232, 0.6519, 0.2956, 0.6733]}, {"w": "at", "b": [0.3022, 0.6519, 0.3173, 0.6733]}, {"w": "the", "b": [0.3239, 0.6519, 0.3502, 0.6733]}, {"w": "top", "b": [0.3569, 0.6519, 0.3847, 0.6733]}, {"w": "left", "b": [0.3914, 0.6519, 0.418, 0.6733]}, {"w": "of", "b": [0.4246, 0.6519, 0.4414, 0.6733]}, {"w": "the", "b": [0.448, 0.6519, 0.4744, 0.6733]}, {"w": "image,", "b": [0.481, 0.6519, 0.5361, 0.6733]}, {"w": "it", "b": [0.5428, 0.6519, 0.5547, 0.6733]}, {"w": "detected", "b": [0.5613, 0.6519, 0.6314, 0.6733]}, {"w": "part", "b": [0.638, 0.6519, 0.6722, 0.6733]}, {"w": "of", "b": [0.6788, 0.6519, 0.6956, 0.6733]}, {"w": "the", "b": [0.7022, 0.6519, 0.7285, 0.6733]}, {"w": "left-most", "b": [0.7352, 0.6519, 0.8109, 0.6733]}, {"w": "rose,", "b": [0.8175, 0.6519, 0.8571, 0.6733]}, {"w": "and", "b": [0.1428, 0.6709, 0.1744, 0.6923]}, {"w": "then", "b": [0.182, 0.6709, 0.2197, 0.6923]}, {"w": "it", "b": [0.2272, 0.6709, 0.2392, 0.6923]}, {"w": "detected", "b": [0.2467, 0.6709, 0.3168, 0.6923]}, {"w": "that", "b": [0.3244, 0.6709, 0.357, 0.6923]}, {"w": "same", "b": [0.3645, 0.6709, 0.4072, 0.6923]}, {"w": "rose", "b": [0.4148, 0.6709, 0.4497, 0.6923]}, {"w": "again", "b": [0.4572, 0.6709, 0.5023, 0.6923]}, {"w": "when", "b": [0.5098, 0.6709, 0.5555, 0.6923]}, {"w": "it", "b": [0.563, 0.6709, 0.575, 0.6923]}, {"w": "was", "b": [0.5825, 0.6709, 0.6136, 0.6923]}, {"w": "first", "b": [0.6211, 0.6709, 0.6546, 0.6923]}, {"w": "shifted", "b": [0.6622, 0.6709, 0.7189, 0.6923]}, {"w": "one", "b": [0.7265, 0.6709, 0.7574, 0.6923]}, {"w": "step", "b": [0.7649, 0.6709, 0.7987, 0.6923]}, {"w": "to", "b": [0.8063, 0.6709, 0.8232, 0.6923]}, {"w": "the", "b": [0.8308, 0.6709, 0.8571, 0.6923]}, {"w": "right.", "b": [0.1429, 0.69, 0.1878, 0.7114]}, {"w": "At", "b": [0.1925, 0.69, 0.2124, 0.7114]}, {"w": "the", "b": [0.2172, 0.69, 0.2435, 0.7114]}, {"w": "next", "b": [0.2483, 0.69, 0.2848, 0.7114]}, {"w": "step,", "b": [0.2895, 0.69, 0.3275, 0.7114]}, {"w": "it", "b": [0.3322, 0.69, 0.3442, 0.7114]}, {"w": "started", "b": [0.3489, 0.69, 0.406, 0.7114]}, {"w": "detecting", "b": [0.4108, 0.69, 0.4878, 0.7114]}, {"w": "part", "b": [0.4925, 0.69, 0.5267, 0.7114]}, {"w": "of", "b": [0.5315, 0.69, 0.5483, 0.7114]}, {"w": "the", "b": [0.553, 0.69, 0.5794, 0.7114]}, {"w": "top-most", "b": [0.5842, 0.69, 0.6612, 0.7114]}, {"w": "rose,", "b": [0.6659, 0.69, 0.7055, 0.7114]}, {"w": "and", "b": [0.7103, 0.69, 0.7419, 0.7114]}, {"w": "then", "b": [0.7466, 0.69, 0.7844, 0.7114]}, {"w": "it", "b": [0.7891, 0.69, 0.8011, 0.7114]}, {"w": "detec‐", "b": [0.8059, 0.69, 0.8571, 0.7114]}, {"w": "ted", "b": [0.1429, 0.709, 0.1691, 0.7304]}, {"w": "it", "b": [0.1739, 0.709, 0.1858, 0.7304]}, {"w": "again", "b": [0.1906, 0.709, 0.2357, 0.7304]}, {"w": "once", "b": [0.2405, 0.709, 0.2802, 0.7304]}, {"w": "it", "b": [0.285, 0.709, 0.2969, 0.7304]}, {"w": "was", "b": [0.3018, 0.709, 0.3328, 0.7304]}, {"w": "shifted", "b": [0.3377, 0.709, 0.3944, 0.7304]}, {"w": "one", "b": [0.3992, 0.709, 0.4301, 0.7304]}, {"w": "more", "b": [0.4349, 0.709, 0.4792, 0.7304]}, {"w": "step", "b": [0.484, 0.709, 0.5178, 0.7304]}, {"w": "to", "b": [0.5226, 0.709, 0.5396, 0.7304]}, {"w": "the", "b": [0.5444, 0.709, 0.5707, 0.7304]}, {"w": "right.", "b": [0.5755, 0.709, 0.6204, 0.7304]}, {"w": "You", "b": [0.6253, 0.709, 0.6576, 0.7304]}, {"w": "would", "b": [0.6624, 0.709, 0.7147, 0.7304]}, {"w": "then", "b": [0.7195, 0.709, 0.7572, 0.7304]}, {"w": "continue", "b": [0.762, 0.709, 0.8353, 0.7304]}, {"w": "to", "b": [0.8402, 0.709, 0.8571, 0.7304]}, {"w": "slide", "b": [0.1429, 0.7281, 0.1812, 0.7495]}, {"w": "the", "b": [0.1866, 0.7281, 0.2129, 0.7495]}, {"w": "CNN", "b": [0.2183, 0.7281, 0.2631, 0.7495]}, {"w": "through", "b": [0.2685, 0.7281, 0.3363, 0.7495]}, {"w": "the", "b": [0.3417, 0.7281, 0.368, 0.7495]}, {"w": "whole", "b": [0.3734, 0.7281, 0.4235, 0.7495]}, {"w": "image,", "b": [0.4289, 0.7281, 0.4841, 0.7495]}, {"w": "looking", "b": [0.4894, 0.7281, 0.553, 0.7495]}, {"w": "at", "b": [0.5584, 0.7281, 0.5735, 0.7495]}, {"w": "all", "b": [0.5789, 0.7281, 0.5986, 0.7495]}, {"w": "3", "b": [0.604, 0.7281, 0.614, 0.7495]}, {"w": "×", "b": [0.6194, 0.7281, 0.6314, 0.7495]}, {"w": "3", "b": [0.6368, 0.7281, 0.6468, 0.7495]}, {"w": "regions.", "b": [0.6522, 0.7281, 0.7186, 0.7495]}, {"w": "Moreover,", "b": [0.7239, 0.7281, 0.8095, 0.7495]}, {"w": "since", "b": [0.8148, 0.7281, 0.8571, 0.7495]}, {"w": "objects", "b": [0.1429, 0.7471, 0.2011, 0.7685]}, {"w": "can", "b": [0.2063, 0.7471, 0.2357, 0.7685]}, {"w": "have", "b": [0.2409, 0.7471, 0.2793, 0.7685]}, {"w": "varying", "b": [0.2845, 0.7471, 0.3479, 0.7685]}, {"w": "sizes,", "b": [0.3531, 0.7471, 0.3964, 0.7685]}, {"w": "you", "b": [0.4016, 0.7471, 0.4328, 0.7685]}, {"w": "would", "b": [0.4381, 0.7471, 0.4903, 0.7685]}, {"w": "also", "b": [0.4955, 0.7471, 0.5282, 0.7685]}, {"w": "slide", "b": [0.5334, 0.7471, 0.5718, 0.7685]}, {"w": "the", "b": [0.577, 0.7471, 0.6033, 0.7685]}, {"w": "CNN", "b": [0.6086, 0.7471, 0.6534, 0.7685]}, {"w": "across", "b": [0.6586, 0.7471, 0.7102, 0.7685]}, {"w": "regions", "b": [0.7154, 0.7471, 0.777, 0.7685]}, {"w": "of", "b": [0.7822, 0.7471, 0.799, 0.7685]}, {"w": "differ‐", "b": [0.8042, 0.7471, 0.8572, 0.7685]}, {"w": "ent", "b": [0.1429, 0.7662, 0.1691, 0.7876]}, {"w": "sizes.", "b": [0.1751, 0.7662, 0.2183, 0.7876]}, {"w": "For", "b": [0.2244, 0.7662, 0.2533, 0.7876]}, {"w": "example,", "b": [0.2594, 0.7662, 0.3337, 0.7876]}, {"w": "once", "b": [0.3397, 0.7662, 0.3794, 0.7876]}, {"w": "you", "b": [0.3854, 0.7662, 0.4166, 0.7876]}, {"w": "are", "b": [0.4227, 0.7662, 0.4484, 0.7876]}, {"w": "done", "b": [0.4544, 0.7662, 0.4963, 0.7876]}, {"w": "with", "b": [0.5023, 0.7662, 0.5397, 0.7876]}, {"w": "the", "b": [0.5457, 0.7662, 0.572, 0.7876]}, {"w": "3", "b": [0.5781, 0.7662, 0.5881, 0.7876]}, {"w": "×", "b": [0.5941, 0.7662, 0.6062, 0.7876]}, {"w": "3", "b": [0.6122, 0.7662, 0.6222, 0.7876]}, {"w": "regions,", "b": [0.6282, 0.7662, 0.6946, 0.7876]}, {"w": "you", "b": [0.7006, 0.7662, 0.7318, 0.7876]}, {"w": "might", "b": [0.7379, 0.7662, 0.7873, 0.7876]}, {"w": "want", "b": [0.7934, 0.7662, 0.8341, 0.7876]}, {"w": "to", "b": [0.8402, 0.7662, 0.8571, 0.7876]}, {"w": "slide", "b": [0.1429, 0.7852, 0.1812, 0.8066]}, {"w": "the", "b": [0.1859, 0.7852, 0.2123, 0.8066]}, {"w": "CNN", "b": [0.217, 0.7852, 0.2618, 0.8066]}, {"w": "across", "b": [0.2665, 0.7852, 0.3181, 0.8066]}, {"w": "all", "b": [0.3229, 0.7852, 0.3426, 0.8066]}, {"w": "4", "b": [0.3473, 0.7852, 0.3573, 0.8066]}, {"w": "×", "b": [0.362, 0.7852, 0.3741, 0.8066]}, {"w": "4", "b": [0.3788, 0.7852, 0.3888, 0.8066]}, {"w": "regions", "b": [0.3936, 0.7852, 0.4551, 0.8066]}, {"w": "as", "b": [0.4599, 0.7852, 0.4767, 0.8066]}, {"w": "well.", "b": [0.4814, 0.7852, 0.5198, 0.8066]}]}, {"id": "b_5", "type": "paragraph", "text": "Object Detection | 471", "words": [{"w": "Object", "b": [0.6987, 0.9225, 0.736, 0.9388]}, {"w": "Detection", "b": [0.7388, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "471", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 498, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 14-24. Detecting Multiple Objects by Sliding a CNN Across the Image", "words": [{"w": "Figure", "b": [0.1429, 0.4764, 0.1943, 0.498]}, {"w": "14-24.", "b": [0.1991, 0.4764, 0.2507, 0.498]}, {"w": "Detecting", "b": [0.2554, 0.4764, 0.3321, 0.498]}, {"w": "Multiple", "b": [0.3369, 0.4764, 0.4055, 0.498]}, {"w": "Objects", "b": [0.4103, 0.4764, 0.4703, 0.498]}, {"w": "by", "b": [0.475, 0.4764, 0.4941, 0.498]}, {"w": "Sliding", "b": [0.4989, 0.4764, 0.5543, 0.498]}, {"w": "a", "b": [0.5591, 0.4764, 0.5693, 0.498]}, {"w": "CNN", "b": [0.574, 0.4764, 0.6166, 0.498]}, {"w": "Across", "b": [0.6214, 0.4764, 0.6739, 0.498]}, {"w": "the", "b": [0.6787, 0.4764, 0.7038, 0.498]}, {"w": "Image", "b": [0.7085, 0.4764, 0.7579, 0.498]}]}, {"id": "b_1", "type": "paragraph", "text": "This technique is fairly straightforward, but as you can see it will detect the same object multiple times, at slightly different positions. Some post-processing will then be needed to get rid of all the unnecessary bounding boxes. A common approach for this is called non-max suppression:", "words": [{"w": "This", "b": [0.1429, 0.5138, 0.1801, 0.5352]}, {"w": "technique", "b": [0.1879, 0.5138, 0.2706, 0.5352]}, {"w": "is", "b": [0.2785, 0.5138, 0.2917, 0.5352]}, {"w": "fairly", "b": [0.2996, 0.5138, 0.343, 0.5352]}, {"w": "straightforward,", "b": [0.3509, 0.5138, 0.4862, 0.5352]}, {"w": "but", "b": [0.4941, 0.5138, 0.5221, 0.5352]}, {"w": "as", "b": [0.5299, 0.5138, 0.5467, 0.5352]}, {"w": "you", "b": [0.5546, 0.5138, 0.5858, 0.5352]}, {"w": "can", "b": [0.5937, 0.5138, 0.623, 0.5352]}, {"w": "see", "b": [0.6309, 0.5138, 0.6562, 0.5352]}, {"w": "it", "b": [0.6641, 0.5138, 0.676, 0.5352]}, {"w": "will", "b": [0.6839, 0.5138, 0.7143, 0.5352]}, {"w": "detect", "b": [0.7222, 0.5138, 0.7724, 0.5352]}, {"w": "the", "b": [0.7802, 0.5138, 0.8066, 0.5352]}, {"w": "same", "b": [0.8144, 0.5138, 0.8571, 0.5352]}, {"w": "object", "b": [0.1429, 0.5328, 0.1934, 0.5542]}, {"w": "multiple", "b": [0.2003, 0.5328, 0.2703, 0.5542]}, {"w": "times,", "b": [0.2772, 0.5328, 0.3274, 0.5542]}, {"w": "at", "b": [0.3343, 0.5328, 0.3494, 0.5542]}, {"w": "slightly", "b": [0.3563, 0.5328, 0.4165, 0.5542]}, {"w": "different", "b": [0.4234, 0.5328, 0.4951, 0.5542]}, {"w": "positions.", "b": [0.502, 0.5328, 0.5831, 0.5542]}, {"w": "Some", "b": [0.59, 0.5328, 0.6364, 0.5542]}, {"w": "post-processing", "b": [0.6433, 0.5328, 0.7752, 0.5542]}, {"w": "will", "b": [0.7821, 0.5328, 0.8125, 0.5542]}, {"w": "then", "b": [0.8194, 0.5328, 0.8571, 0.5542]}, {"w": "be", "b": [0.1429, 0.5519, 0.1623, 0.5733]}, {"w": "needed", "b": [0.1678, 0.5519, 0.2278, 0.5733]}, {"w": "to", "b": [0.2332, 0.5519, 0.2502, 0.5733]}, {"w": "get", "b": [0.2557, 0.5519, 0.2807, 0.5733]}, {"w": "rid", "b": [0.2862, 0.5519, 0.3105, 0.5733]}, {"w": "of", "b": [0.316, 0.5519, 0.3328, 0.5733]}, {"w": "all", "b": [0.3383, 0.5519, 0.358, 0.5733]}, {"w": "the", "b": [0.3634, 0.5519, 0.3898, 0.5733]}, {"w": "unnecessary", "b": [0.3953, 0.5519, 0.498, 0.5733]}, {"w": "bounding", "b": [0.5035, 0.5519, 0.5849, 0.5733]}, {"w": "boxes.", "b": [0.5904, 0.5519, 0.6427, 0.5733]}, {"w": "A", "b": [0.6481, 0.5519, 0.6625, 0.5733]}, {"w": "common", "b": [0.668, 0.5519, 0.7436, 0.5733]}, {"w": "approach", "b": [0.7491, 0.5519, 0.8271, 0.5733]}, {"w": "for", "b": [0.8326, 0.5519, 0.8572, 0.5733]}, {"w": "this", "b": [0.1429, 0.5709, 0.1736, 0.5923]}, {"w": "is", "b": [0.1783, 0.5709, 0.1915, 0.5923]}, {"w": "called", "b": [0.1963, 0.5709, 0.2446, 0.5923]}, {"w": "non-max", "b": [0.2493, 0.5707, 0.3242, 0.5923]}, {"w": "suppression:", "b": [0.329, 0.5707, 0.4266, 0.5923]}]}, {"id": "b_2", "type": "paragraph", "text": "• First, you need to add an extra objectness output to your CNN, to estimate the probability that a flower is indeed present in the image (alternatively, you could add a “no-flower” class, but this usually does not work as well). It must use the sigmoid activation function and you can train it using the \"binary_crossen tropy\" loss. Then just get rid of all the bounding boxes for which the objectness score is below some threshold: this will drop all the bounding boxes that don’t actually contain a flower.", "words": [{"w": "•", "b": [0.16, 0.6051, 0.1682, 0.6265]}, {"w": "First,", "b": [0.1786, 0.6051, 0.2216, 0.6265]}, {"w": "you", "b": [0.2287, 0.6051, 0.2599, 0.6265]}, {"w": "need", "b": [0.267, 0.6051, 0.3071, 0.6265]}, {"w": "to", "b": [0.3141, 0.6051, 0.3311, 0.6265]}, {"w": "add", "b": [0.3381, 0.6051, 0.3693, 0.6265]}, {"w": "an", "b": [0.3763, 0.6051, 0.3969, 0.6265]}, {"w": "extra", "b": [0.4039, 0.6051, 0.4458, 0.6265]}, {"w": "objectness", "b": [0.4528, 0.6049, 0.5332, 0.6265]}, {"w": "output", "b": [0.5403, 0.6051, 0.5966, 0.6265]}, {"w": "to", "b": [0.6037, 0.6051, 0.6206, 0.6265]}, {"w": "your", "b": [0.6277, 0.6051, 0.6667, 0.6265]}, {"w": "CNN,", "b": [0.6737, 0.6051, 0.7233, 0.6265]}, {"w": "to", "b": [0.7303, 0.6051, 0.7473, 0.6265]}, {"w": "estimate", "b": [0.7543, 0.6051, 0.8238, 0.6265]}, {"w": "the", "b": [0.8308, 0.6051, 0.8571, 0.6265]}, {"w": "probability", "b": [0.1786, 0.6241, 0.2705, 0.6455]}, {"w": "that", "b": [0.2768, 0.6241, 0.3094, 0.6455]}, {"w": "a", "b": [0.3157, 0.6241, 0.3249, 0.6455]}, {"w": "flower", "b": [0.3312, 0.6241, 0.3841, 0.6455]}, {"w": "is", "b": [0.3904, 0.6241, 0.4036, 0.6455]}, {"w": "indeed", "b": [0.41, 0.6241, 0.4667, 0.6455]}, {"w": "present", "b": [0.473, 0.6241, 0.5343, 0.6455]}, {"w": "in", "b": [0.5406, 0.6241, 0.5576, 0.6455]}, {"w": "the", "b": [0.5639, 0.6241, 0.5903, 0.6455]}, {"w": "image", "b": [0.5966, 0.6241, 0.647, 0.6455]}, {"w": "(alternatively,", "b": [0.6533, 0.6241, 0.7665, 0.6455]}, {"w": "you", "b": [0.7728, 0.6241, 0.8041, 0.6455]}, {"w": "could", "b": [0.8104, 0.6241, 0.8571, 0.6455]}, {"w": "add", "b": [0.1786, 0.6432, 0.2097, 0.6646]}, {"w": "a", "b": [0.2163, 0.6432, 0.2254, 0.6646]}, {"w": "“no-flower”", "b": [0.232, 0.6432, 0.3304, 0.6646]}, {"w": "class,", "b": [0.337, 0.6432, 0.3802, 0.6646]}, {"w": "but", "b": [0.3868, 0.6432, 0.4148, 0.6646]}, {"w": "this", "b": [0.4214, 0.6432, 0.4521, 0.6646]}, {"w": "usually", "b": [0.4587, 0.6432, 0.5177, 0.6646]}, {"w": "does", "b": [0.5243, 0.6432, 0.5624, 0.6646]}, {"w": "not", "b": [0.569, 0.6432, 0.5974, 0.6646]}, {"w": "work", "b": [0.604, 0.6432, 0.6469, 0.6646]}, {"w": "as", "b": [0.6535, 0.6432, 0.6703, 0.6646]}, {"w": "well).", "b": [0.6769, 0.6432, 0.7225, 0.6646]}, {"w": "It", "b": [0.7291, 0.6432, 0.7418, 0.6646]}, {"w": "must", "b": [0.7483, 0.6432, 0.7901, 0.6646]}, {"w": "use", "b": [0.7967, 0.6432, 0.8242, 0.6646]}, {"w": "the", "b": [0.8308, 0.6432, 0.8571, 0.6646]}, {"w": "sigmoid", "b": [0.1786, 0.6631, 0.2458, 0.6845]}, {"w": "activation", "b": [0.2547, 0.6631, 0.337, 0.6845]}, {"w": "function", "b": [0.3459, 0.6631, 0.4173, 0.6845]}, {"w": "and", "b": [0.4262, 0.6631, 0.4578, 0.6845]}, {"w": "you", "b": [0.4667, 0.6631, 0.4979, 0.6845]}, {"w": "can", "b": [0.5069, 0.6631, 0.5362, 0.6845]}, {"w": "train", "b": [0.5451, 0.6631, 0.5853, 0.6845]}, {"w": "it", "b": [0.5943, 0.6631, 0.6062, 0.6845]}, {"w": "using", "b": [0.6151, 0.6631, 0.6606, 0.6845]}, {"w": "the", "b": [0.6695, 0.6631, 0.6958, 0.6845]}, {"w": "\"binary_crossen", "b": [0.7047, 0.6663, 0.8532, 0.6814]}, {"w": "tropy\"", "b": [0.1786, 0.6862, 0.2379, 0.7013]}, {"w": "loss.", "b": [0.2436, 0.6831, 0.2796, 0.7045]}, {"w": "Then", "b": [0.2853, 0.6831, 0.3295, 0.7045]}, {"w": "just", "b": [0.3352, 0.6831, 0.3656, 0.7045]}, {"w": "get", "b": [0.3713, 0.6831, 0.3962, 0.7045]}, {"w": "rid", "b": [0.4019, 0.6831, 0.4263, 0.7045]}, {"w": "of", "b": [0.4319, 0.6831, 0.4487, 0.7045]}, {"w": "all", "b": [0.4544, 0.6831, 0.4741, 0.7045]}, {"w": "the", "b": [0.4798, 0.6831, 0.5062, 0.7045]}, {"w": "bounding", "b": [0.5118, 0.6831, 0.5932, 0.7045]}, {"w": "boxes", "b": [0.5989, 0.6831, 0.6465, 0.7045]}, {"w": "for", "b": [0.6522, 0.6831, 0.6767, 0.7045]}, {"w": "which", "b": [0.6824, 0.6831, 0.7333, 0.7045]}, {"w": "the", "b": [0.739, 0.6831, 0.7653, 0.7045]}, {"w": "objectness", "b": [0.771, 0.6831, 0.8571, 0.7045]}, {"w": "score", "b": [0.1786, 0.7021, 0.2222, 0.7235]}, {"w": "is", "b": [0.2294, 0.7021, 0.2426, 0.7235]}, {"w": "below", "b": [0.2498, 0.7021, 0.2994, 0.7235]}, {"w": "some", "b": [0.3065, 0.7021, 0.3507, 0.7235]}, {"w": "threshold:", "b": [0.3578, 0.7021, 0.4423, 0.7235]}, {"w": "this", "b": [0.4495, 0.7021, 0.4802, 0.7235]}, {"w": "will", "b": [0.4873, 0.7021, 0.5177, 0.7235]}, {"w": "drop", "b": [0.5249, 0.7021, 0.5651, 0.7235]}, {"w": "all", "b": [0.5723, 0.7021, 0.592, 0.7235]}, {"w": "the", "b": [0.5991, 0.7021, 0.6254, 0.7235]}, {"w": "bounding", "b": [0.6326, 0.7021, 0.714, 0.7235]}, {"w": "boxes", "b": [0.7211, 0.7021, 0.7687, 0.7235]}, {"w": "that", "b": [0.7758, 0.7021, 0.8084, 0.7235]}, {"w": "don’t", "b": [0.8155, 0.7021, 0.8571, 0.7235]}, {"w": "actually", "b": [0.1786, 0.7211, 0.2432, 0.7426]}, {"w": "contain", "b": [0.2479, 0.7211, 0.3109, 0.7426]}, {"w": "a", "b": [0.3156, 0.7211, 0.3247, 0.7426]}, {"w": "flower.", "b": [0.3295, 0.7211, 0.3858, 0.7426]}]}, {"id": "b_3", "type": "paragraph", "text": "• Second, find the bounding box with the highest objectness score, and get rid of all the other bounding boxes that overlap a lot with it (e.g., with an IoU greater than 60%). For example, in Figure 14-24, the bounding box with the max object‐ ness score is the thick bounding box over the top-most rose (the objectness score is represented by the thickness of the bounding boxes). The other bounding box over that same rose overlaps a lot with the max bounding box, so we will get rid of it.", "words": [{"w": "•", "b": [0.16, 0.7462, 0.1681, 0.7677]}, {"w": "Second,", "b": [0.1786, 0.7462, 0.2439, 0.7677]}, {"w": "find", "b": [0.2503, 0.7462, 0.2845, 0.7677]}, {"w": "the", "b": [0.291, 0.7462, 0.3173, 0.7677]}, {"w": "bounding", "b": [0.3238, 0.7462, 0.4052, 0.7677]}, {"w": "box", "b": [0.4116, 0.7462, 0.4427, 0.7677]}, {"w": "with", "b": [0.4491, 0.7462, 0.4865, 0.7677]}, {"w": "the", "b": [0.4929, 0.7462, 0.5193, 0.7677]}, {"w": "highest", "b": [0.5258, 0.7462, 0.5862, 0.7677]}, {"w": "objectness", "b": [0.5927, 0.7462, 0.6788, 0.7677]}, {"w": "score,", "b": [0.6852, 0.7462, 0.7337, 0.7677]}, {"w": "and", "b": [0.7401, 0.7462, 0.7717, 0.7677]}, {"w": "get", "b": [0.7781, 0.7462, 0.8031, 0.7677]}, {"w": "rid", "b": [0.8096, 0.7462, 0.8339, 0.7677]}, {"w": "of", "b": [0.8403, 0.7462, 0.8571, 0.7677]}, {"w": "all", "b": [0.1786, 0.7653, 0.1983, 0.7867]}, {"w": "the", "b": [0.2046, 0.7653, 0.231, 0.7867]}, {"w": "other", "b": [0.2373, 0.7653, 0.282, 0.7867]}, {"w": "bounding", "b": [0.2884, 0.7653, 0.3698, 0.7867]}, {"w": "boxes", "b": [0.3761, 0.7653, 0.4237, 0.7867]}, {"w": "that", "b": [0.43, 0.7653, 0.4626, 0.7867]}, {"w": "overlap", "b": [0.469, 0.7653, 0.5307, 0.7867]}, {"w": "a", "b": [0.5371, 0.7653, 0.5463, 0.7867]}, {"w": "lot", "b": [0.5526, 0.7653, 0.5749, 0.7867]}, {"w": "with", "b": [0.5812, 0.7653, 0.6186, 0.7867]}, {"w": "it", "b": [0.6249, 0.7653, 0.6369, 0.7867]}, {"w": "(e.g.,", "b": [0.6432, 0.7653, 0.6833, 0.7867]}, {"w": "with", "b": [0.6896, 0.7653, 0.727, 0.7867]}, {"w": "an", "b": [0.7333, 0.7653, 0.7539, 0.7867]}, {"w": "IoU", "b": [0.7602, 0.7653, 0.7928, 0.7867]}, {"w": "greater", "b": [0.7991, 0.7653, 0.8571, 0.7867]}, {"w": "than", "b": [0.1786, 0.7843, 0.2166, 0.8057]}, {"w": "60%).", "b": [0.222, 0.7843, 0.2697, 0.8057]}, {"w": "For", "b": [0.2751, 0.7843, 0.304, 0.8057]}, {"w": "example,", "b": [0.3094, 0.7843, 0.3837, 0.8057]}, {"w": "in", "b": [0.3891, 0.7843, 0.4061, 0.8057]}, {"w": "Figure", "b": [0.4115, 0.7843, 0.4655, 0.8057]}, {"w": "14-24,", "b": [0.4702, 0.7843, 0.523, 0.8057]}, {"w": "the", "b": [0.5284, 0.7843, 0.5547, 0.8057]}, {"w": "bounding", "b": [0.5601, 0.7843, 0.6415, 0.8057]}, {"w": "box", "b": [0.6469, 0.7843, 0.6779, 0.8057]}, {"w": "with", "b": [0.6833, 0.7843, 0.7206, 0.8057]}, {"w": "the", "b": [0.726, 0.7843, 0.7524, 0.8057]}, {"w": "max", "b": [0.7577, 0.7843, 0.7938, 0.8057]}, {"w": "object‐", "b": [0.7992, 0.7843, 0.8571, 0.8057]}, {"w": "ness", "b": [0.1786, 0.8034, 0.2141, 0.8248]}, {"w": "score", "b": [0.2192, 0.8034, 0.2629, 0.8248]}, {"w": "is", "b": [0.268, 0.8034, 0.2813, 0.8248]}, {"w": "the", "b": [0.2864, 0.8034, 0.3127, 0.8248]}, {"w": "thick", "b": [0.3179, 0.8034, 0.3601, 0.8248]}, {"w": "bounding", "b": [0.3652, 0.8034, 0.4466, 0.8248]}, {"w": "box", "b": [0.4518, 0.8034, 0.4828, 0.8248]}, {"w": "over", "b": [0.4879, 0.8034, 0.5248, 0.8248]}, {"w": "the", "b": [0.5299, 0.8034, 0.5563, 0.8248]}, {"w": "top-most", "b": [0.5614, 0.8034, 0.6384, 0.8248]}, {"w": "rose", "b": [0.6436, 0.8034, 0.6784, 0.8248]}, {"w": "(the", "b": [0.6835, 0.8034, 0.7171, 0.8248]}, {"w": "objectness", "b": [0.7222, 0.8034, 0.8083, 0.8248]}, {"w": "score", "b": [0.8135, 0.8034, 0.8571, 0.8248]}, {"w": "is", "b": [0.1786, 0.8224, 0.1918, 0.8438]}, {"w": "represented", "b": [0.1976, 0.8224, 0.2954, 0.8438]}, {"w": "by", "b": [0.3012, 0.8224, 0.3213, 0.8438]}, {"w": "the", "b": [0.3271, 0.8224, 0.3534, 0.8438]}, {"w": "thickness", "b": [0.3592, 0.8224, 0.4369, 0.8438]}, {"w": "of", "b": [0.4427, 0.8224, 0.4595, 0.8438]}, {"w": "the", "b": [0.4653, 0.8224, 0.4916, 0.8438]}, {"w": "bounding", "b": [0.4974, 0.8224, 0.5788, 0.8438]}, {"w": "boxes).", "b": [0.5846, 0.8224, 0.6441, 0.8438]}, {"w": "The", "b": [0.6498, 0.8224, 0.6827, 0.8438]}, {"w": "other", "b": [0.6885, 0.8224, 0.7331, 0.8438]}, {"w": "bounding", "b": [0.7389, 0.8224, 0.8203, 0.8438]}, {"w": "box", "b": [0.8261, 0.8224, 0.8571, 0.8438]}, {"w": "over", "b": [0.1786, 0.8415, 0.2154, 0.8629]}, {"w": "that", "b": [0.2212, 0.8415, 0.2538, 0.8629]}, {"w": "same", "b": [0.2596, 0.8415, 0.3023, 0.8629]}, {"w": "rose", "b": [0.3081, 0.8415, 0.343, 0.8629]}, {"w": "overlaps", "b": [0.3488, 0.8415, 0.4182, 0.8629]}, {"w": "a", "b": [0.424, 0.8415, 0.4331, 0.8629]}, {"w": "lot", "b": [0.4389, 0.8415, 0.4612, 0.8629]}, {"w": "with", "b": [0.467, 0.8415, 0.5043, 0.8629]}, {"w": "the", "b": [0.5101, 0.8415, 0.5365, 0.8629]}, {"w": "max", "b": [0.5422, 0.8415, 0.5783, 0.8629]}, {"w": "bounding", "b": [0.5841, 0.8415, 0.6655, 0.8629]}, {"w": "box,", "b": [0.6713, 0.8415, 0.7071, 0.8629]}, {"w": "so", "b": [0.7129, 0.8415, 0.7311, 0.8629]}, {"w": "we", "b": [0.7369, 0.8415, 0.7601, 0.8629]}, {"w": "will", "b": [0.7659, 0.8415, 0.7963, 0.8629]}, {"w": "get", "b": [0.8021, 0.8415, 0.827, 0.8629]}, {"w": "rid", "b": [0.8328, 0.8415, 0.8571, 0.8629]}, {"w": "of", "b": [0.1786, 0.8605, 0.1954, 0.8819]}, {"w": "it.", "b": [0.2001, 0.8605, 0.2168, 0.8819]}]}, {"id": "b_4", "type": "paragraph", "text": "472 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "472", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3683, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 499, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "23 “Fully Convolutional Networks for Semantic Segmentation,” J. Long, E. Shelhamer, T. Darrell (2015).", "words": [{"w": "23", "b": [0.1385, 0.8416, 0.1518, 0.8559]}, {"w": "“Fully", "b": [0.1587, 0.8401, 0.1969, 0.8565]}, {"w": "Convolutional", "b": [0.2005, 0.8401, 0.2922, 0.8565]}, {"w": "Networks", "b": [0.2958, 0.8401, 0.3573, 0.8565]}, {"w": "for", "b": [0.3609, 0.8401, 0.3796, 0.8565]}, {"w": "Semantic", "b": [0.3832, 0.8401, 0.4417, 0.8565]}, {"w": "Segmentation,”", "b": [0.4453, 0.8401, 0.5403, 0.8565]}, {"w": "J.", "b": [0.5439, 0.8401, 0.552, 0.8565]}, {"w": "Long,", "b": [0.5556, 0.8401, 0.592, 0.8565]}, {"w": "E.", "b": [0.5956, 0.8401, 0.6082, 0.8565]}, {"w": "Shelhamer,", "b": [0.6118, 0.8401, 0.6823, 0.8565]}, {"w": "T.", "b": [0.6859, 0.8401, 0.6977, 0.8565]}, {"w": "Darrell", "b": [0.7013, 0.8401, 0.7465, 0.8565]}, {"w": "(2015).", "b": [0.7501, 0.8401, 0.7952, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "24 There is one small exception: a convolutional layer using VALID padding will complain if the input size is smaller than the kernel size.", "words": [{"w": "24", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "There", "b": [0.1587, 0.8598, 0.1964, 0.8761]}, {"w": "is", "b": [0.2, 0.8598, 0.2101, 0.8761]}, {"w": "one", "b": [0.2137, 0.8598, 0.2372, 0.8761]}, {"w": "small", "b": [0.2408, 0.8598, 0.2746, 0.8761]}, {"w": "exception:", "b": [0.2782, 0.8598, 0.3437, 0.8761]}, {"w": "a", "b": [0.3473, 0.8598, 0.3543, 0.8761]}, {"w": "convolutional", "b": [0.3579, 0.8598, 0.4458, 0.8761]}, {"w": "layer", "b": [0.4494, 0.8598, 0.48, 0.8761]}, {"w": "using", "b": [0.4836, 0.8598, 0.5182, 0.8761]}, {"w": "VALID", "b": [0.5218, 0.8598, 0.5676, 0.8761]}, {"w": "padding", "b": [0.5712, 0.8598, 0.6236, 0.8761]}, {"w": "will", "b": [0.6272, 0.8598, 0.6504, 0.8761]}, {"w": "complain", "b": [0.654, 0.8598, 0.7137, 0.8761]}, {"w": "if", "b": [0.7173, 0.8598, 0.7263, 0.8761]}, {"w": "the", "b": [0.7299, 0.8598, 0.75, 0.8761]}, {"w": "input", "b": [0.7536, 0.8598, 0.7878, 0.8761]}, {"w": "size", "b": [0.7914, 0.8598, 0.8149, 0.8761]}, {"w": "is", "b": [0.8185, 0.8598, 0.8286, 0.8761]}, {"w": "smaller", "b": [0.1587, 0.8749, 0.2052, 0.8912]}, {"w": "than", "b": [0.2088, 0.8749, 0.2378, 0.8912]}, {"w": "the", "b": [0.2414, 0.8749, 0.2614, 0.8912]}, {"w": "kernel", "b": [0.265, 0.8749, 0.305, 0.8912]}, {"w": "size.", "b": [0.3086, 0.8749, 0.3357, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "• Third, repeat step two until there are no more bounding boxes to get rid of.", "words": [{"w": "•", "b": [0.16, 0.0791, 0.1682, 0.1005]}, {"w": "Third,", "b": [0.1786, 0.0791, 0.2316, 0.1005]}, {"w": "repeat", "b": [0.2363, 0.0791, 0.2878, 0.1005]}, {"w": "step", "b": [0.2925, 0.0791, 0.3263, 0.1005]}, {"w": "two", "b": [0.331, 0.0791, 0.3623, 0.1005]}, {"w": "until", "b": [0.367, 0.0791, 0.4063, 0.1005]}, {"w": "there", "b": [0.411, 0.0791, 0.4539, 0.1005]}, {"w": "are", "b": [0.4586, 0.0791, 0.4844, 0.1005]}, {"w": "no", "b": [0.4891, 0.0791, 0.5111, 0.1005]}, {"w": "more", "b": [0.5159, 0.0791, 0.5601, 0.1005]}, {"w": "bounding", "b": [0.5649, 0.0791, 0.6463, 0.1005]}, {"w": "boxes", "b": [0.651, 0.0791, 0.6985, 0.1005]}, {"w": "to", "b": [0.7033, 0.0791, 0.7202, 0.1005]}, {"w": "get", "b": [0.725, 0.0791, 0.7499, 0.1005]}, {"w": "rid", "b": [0.7546, 0.0791, 0.779, 0.1005]}, {"w": "of.", "b": [0.7837, 0.0791, 0.8052, 0.1005]}]}, {"id": "b_3", "type": "paragraph", "text": "This simple approach to object detection works pretty well, but it requires running the CNN many times, so it is quite slow. Fortunately, there is a much faster way to slide a CNN across an image: using a Fully Convolutional Network.", "words": [{"w": "This", "b": [0.1429, 0.1132, 0.1801, 0.1346]}, {"w": "simple", "b": [0.187, 0.1132, 0.242, 0.1346]}, {"w": "approach", "b": [0.2489, 0.1132, 0.327, 0.1346]}, {"w": "to", "b": [0.3339, 0.1132, 0.3509, 0.1346]}, {"w": "object", "b": [0.3579, 0.1132, 0.4084, 0.1346]}, {"w": "detection", "b": [0.4154, 0.1132, 0.4932, 0.1346]}, {"w": "works", "b": [0.5002, 0.1132, 0.5508, 0.1346]}, {"w": "pretty", "b": [0.5578, 0.1132, 0.6075, 0.1346]}, {"w": "well,", "b": [0.6145, 0.1132, 0.6529, 0.1346]}, {"w": "but", "b": [0.6599, 0.1132, 0.6879, 0.1346]}, {"w": "it", "b": [0.6949, 0.1132, 0.7068, 0.1346]}, {"w": "requires", "b": [0.7138, 0.1132, 0.7819, 0.1346]}, {"w": "running", "b": [0.7888, 0.1132, 0.8571, 0.1346]}, {"w": "the", "b": [0.1429, 0.1323, 0.1692, 0.1537]}, {"w": "CNN", "b": [0.1761, 0.1323, 0.2209, 0.1537]}, {"w": "many", "b": [0.2279, 0.1323, 0.2746, 0.1537]}, {"w": "times,", "b": [0.2815, 0.1323, 0.3317, 0.1537]}, {"w": "so", "b": [0.3387, 0.1323, 0.3569, 0.1537]}, {"w": "it", "b": [0.3639, 0.1323, 0.3758, 0.1537]}, {"w": "is", "b": [0.3828, 0.1323, 0.396, 0.1537]}, {"w": "quite", "b": [0.4029, 0.1323, 0.4454, 0.1537]}, {"w": "slow.", "b": [0.4524, 0.1323, 0.4934, 0.1537]}, {"w": "Fortunately,", "b": [0.5003, 0.1323, 0.6001, 0.1537]}, {"w": "there", "b": [0.6071, 0.1323, 0.65, 0.1537]}, {"w": "is", "b": [0.6569, 0.1323, 0.6702, 0.1537]}, {"w": "a", "b": [0.6771, 0.1323, 0.6862, 0.1537]}, {"w": "much", "b": [0.6932, 0.1323, 0.7409, 0.1537]}, {"w": "faster", "b": [0.7478, 0.1323, 0.7937, 0.1537]}, {"w": "way", "b": [0.8006, 0.1323, 0.8332, 0.1537]}, {"w": "to", "b": [0.8402, 0.1323, 0.8571, 0.1537]}, {"w": "slide", "b": [0.1429, 0.1513, 0.1812, 0.1727]}, {"w": "a", "b": [0.1859, 0.1513, 0.1951, 0.1727]}, {"w": "CNN", "b": [0.1998, 0.1513, 0.2446, 0.1727]}, {"w": "across", "b": [0.2494, 0.1513, 0.301, 0.1727]}, {"w": "an", "b": [0.3057, 0.1513, 0.3262, 0.1727]}, {"w": "image:", "b": [0.331, 0.1513, 0.3861, 0.1727]}, {"w": "using", "b": [0.3908, 0.1513, 0.4363, 0.1727]}, {"w": "a", "b": [0.441, 0.1513, 0.4502, 0.1727]}, {"w": "Fully", "b": [0.4549, 0.1511, 0.4955, 0.1727]}, {"w": "Convolutional", "b": [0.5003, 0.1511, 0.6158, 0.1727]}, {"w": "Network.", "b": [0.6206, 0.1511, 0.6947, 0.1727]}]}, {"id": "b_4", "type": "paragraph", "text": "Fully Convolutional Networks (FCNs)", "words": [{"w": "Fully", "b": [0.1429, 0.1855, 0.1926, 0.2141]}, {"w": "Convolutional", "b": [0.1975, 0.1855, 0.3412, 0.2141]}, {"w": "Networks", "b": [0.3461, 0.1855, 0.4445, 0.2141]}, {"w": "(FCNs)", "b": [0.4495, 0.1855, 0.5142, 0.2141]}]}, {"id": "b_5", "type": "paragraph", "text": "The idea of FCNs was first introduced in a 2015 paper23 by Jonathan Long et al., for semantic segmentation (the task of classifying every pixel in an image according to the class of the object it belongs to). They pointed out that you could replace the dense layers at the top of a CNN by convolutional layers. To understand this, let’s look at an example: suppose a dense layer with 200 neurons sits on top of a convolutional layer that outputs 100 feature maps, each of size 7 × 7 (this is the feature map size, not the kernel size). Each neuron will compute a weighted sum of all 100 × 7 × 7 activa‐ tions from the convolutional layer (plus a bias term). Now let’s see what happens if we replace the dense layer with a convolution layer using 200 filters, each 7 × 7, and with VALID padding. This layer will output 200 feature maps, each 1 × 1 (since the kernel is exactly the size of the input feature maps and we are using VALID padding). In other words, it will output 200 numbers, just like the dense layer did, and if you look closely at the computations performed by a convolutional layer, you will notice that these numbers will be precisely the same as the dense layer produced. The only differ‐ ence is that the dense layer’s output was a tensor of shape [batch size, 200] while the convolutional layer will output a tensor of shape [batch size, 1, 1, 200].", "words": [{"w": "The", "b": [0.1429, 0.22, 0.1757, 0.2414]}, {"w": "idea", "b": [0.1819, 0.22, 0.2165, 0.2414]}, {"w": "of", "b": [0.2227, 0.22, 0.2395, 0.2414]}, {"w": "FCNs", "b": [0.2457, 0.22, 0.2931, 0.2414]}, {"w": "was", "b": [0.2994, 0.22, 0.3304, 0.2414]}, {"w": "first", "b": [0.3366, 0.22, 0.3701, 0.2414]}, {"w": "introduced", "b": [0.3763, 0.22, 0.4683, 0.2414]}, {"w": "in", "b": [0.4746, 0.22, 0.4915, 0.2414]}, {"w": "a", "b": [0.4977, 0.22, 0.5069, 0.2414]}, {"w": "2015", "b": [0.5131, 0.22, 0.5531, 0.2414]}, {"w": "paper23", "b": [0.5593, 0.22, 0.6179, 0.2414]}, {"w": "by", "b": [0.6241, 0.22, 0.6443, 0.2414]}, {"w": "Jonathan", "b": [0.6505, 0.22, 0.7257, 0.2414]}, {"w": "Long", "b": [0.7319, 0.22, 0.7749, 0.2414]}, {"w": "et", "b": [0.7811, 0.22, 0.7963, 0.2414]}, {"w": "al.,", "b": [0.8025, 0.22, 0.8264, 0.2414]}, {"w": "for", "b": [0.8326, 0.22, 0.8571, 0.2414]}, {"w": "semantic", "b": [0.1428, 0.239, 0.2173, 0.2604]}, {"w": "segmentation", "b": [0.2243, 0.239, 0.3365, 0.2604]}, {"w": "(the", "b": [0.3434, 0.239, 0.377, 0.2604]}, {"w": "task", "b": [0.3839, 0.239, 0.4174, 0.2604]}, {"w": "of", "b": [0.4244, 0.239, 0.4412, 0.2604]}, {"w": "classifying", "b": [0.4481, 0.239, 0.535, 0.2604]}, {"w": "every", "b": [0.542, 0.239, 0.5872, 0.2604]}, {"w": "pixel", "b": [0.5942, 0.239, 0.6346, 0.2604]}, {"w": "in", "b": [0.6416, 0.239, 0.6586, 0.2604]}, {"w": "an", "b": [0.6655, 0.239, 0.6861, 0.2604]}, {"w": "image", "b": [0.693, 0.239, 0.7434, 0.2604]}, {"w": "according", "b": [0.7503, 0.239, 0.8332, 0.2604]}, {"w": "to", "b": [0.8402, 0.239, 0.8571, 0.2604]}, {"w": "the", "b": [0.1429, 0.2581, 0.1692, 0.2795]}, {"w": "class", "b": [0.1772, 0.2581, 0.2157, 0.2795]}, {"w": "of", "b": [0.2236, 0.2581, 0.2404, 0.2795]}, {"w": "the", "b": [0.2484, 0.2581, 0.2747, 0.2795]}, {"w": "object", "b": [0.2827, 0.2581, 0.3333, 0.2795]}, {"w": "it", "b": [0.3412, 0.2581, 0.3532, 0.2795]}, {"w": "belongs", "b": [0.3611, 0.2581, 0.4252, 0.2795]}, {"w": "to).", "b": [0.4332, 0.2581, 0.4621, 0.2795]}, {"w": "They", "b": [0.4701, 0.2581, 0.5125, 0.2795]}, {"w": "pointed", "b": [0.5205, 0.2581, 0.5848, 0.2795]}, {"w": "out", "b": [0.5928, 0.2581, 0.6208, 0.2795]}, {"w": "that", "b": [0.6288, 0.2581, 0.6614, 0.2795]}, {"w": "you", "b": [0.6693, 0.2581, 0.7006, 0.2795]}, {"w": "could", "b": [0.7085, 0.2581, 0.7553, 0.2795]}, {"w": "replace", "b": [0.7633, 0.2581, 0.8229, 0.2795]}, {"w": "the", "b": [0.8308, 0.2581, 0.8571, 0.2795]}, {"w": "dense", "b": [0.1429, 0.2771, 0.1906, 0.2985]}, {"w": "layers", "b": [0.1953, 0.2771, 0.2432, 0.2985]}, {"w": "at", "b": [0.2479, 0.2771, 0.263, 0.2985]}, {"w": "the", "b": [0.2677, 0.2771, 0.2941, 0.2985]}, {"w": "top", "b": [0.2988, 0.2771, 0.3267, 0.2985]}, {"w": "of", "b": [0.3314, 0.2771, 0.3482, 0.2985]}, {"w": "a", "b": [0.3529, 0.2771, 0.3621, 0.2985]}, {"w": "CNN", "b": [0.3668, 0.2771, 0.4116, 0.2985]}, {"w": "by", "b": [0.4164, 0.2771, 0.4365, 0.2985]}, {"w": "convolutional", "b": [0.4412, 0.2771, 0.5566, 0.2985]}, {"w": "layers.", "b": [0.5613, 0.2771, 0.6139, 0.2985]}, {"w": "To", "b": [0.6186, 0.2771, 0.64, 0.2985]}, {"w": "understand", "b": [0.6448, 0.2771, 0.7404, 0.2985]}, {"w": "this,", "b": [0.7451, 0.2771, 0.7805, 0.2985]}, {"w": "let’s", "b": [0.7853, 0.2771, 0.8155, 0.2985]}, {"w": "look", "b": [0.8202, 0.2771, 0.8571, 0.2985]}, {"w": "at", "b": [0.1429, 0.2962, 0.158, 0.3176]}, {"w": "an", "b": [0.1636, 0.2962, 0.1842, 0.3176]}, {"w": "example:", "b": [0.1899, 0.2962, 0.2641, 0.3176]}, {"w": "suppose", "b": [0.2698, 0.2962, 0.3375, 0.3176]}, {"w": "a", "b": [0.3432, 0.2962, 0.3523, 0.3176]}, {"w": "dense", "b": [0.358, 0.2962, 0.4057, 0.3176]}, {"w": "layer", "b": [0.4114, 0.2962, 0.4516, 0.3176]}, {"w": "with", "b": [0.4573, 0.2962, 0.4946, 0.3176]}, {"w": "200", "b": [0.5003, 0.2962, 0.5303, 0.3176]}, {"w": "neurons", "b": [0.536, 0.2962, 0.6047, 0.3176]}, {"w": "sits", "b": [0.6103, 0.2962, 0.6376, 0.3176]}, {"w": "on", "b": [0.6433, 0.2962, 0.6653, 0.3176]}, {"w": "top", "b": [0.6709, 0.2962, 0.6988, 0.3176]}, {"w": "of", "b": [0.7045, 0.2962, 0.7213, 0.3176]}, {"w": "a", "b": [0.727, 0.2962, 0.7361, 0.3176]}, {"w": "convolutional", "b": [0.7418, 0.2962, 0.8571, 0.3176]}, {"w": "layer", "b": [0.1429, 0.3152, 0.183, 0.3366]}, {"w": "that", "b": [0.1879, 0.3152, 0.2205, 0.3366]}, {"w": "outputs", "b": [0.2253, 0.3152, 0.2893, 0.3366]}, {"w": "100", "b": [0.2941, 0.3152, 0.3241, 0.3366]}, {"w": "feature", "b": [0.329, 0.3152, 0.3868, 0.3366]}, {"w": "maps,", "b": [0.3916, 0.3152, 0.4407, 0.3366]}, {"w": "each", "b": [0.4455, 0.3152, 0.4835, 0.3366]}, {"w": "of", "b": [0.4883, 0.3152, 0.5051, 0.3366]}, {"w": "size", "b": [0.5099, 0.3152, 0.5408, 0.3366]}, {"w": "7", "b": [0.5456, 0.3152, 0.5556, 0.3366]}, {"w": "×", "b": [0.5604, 0.3152, 0.5725, 0.3366]}, {"w": "7", "b": [0.5774, 0.3152, 0.5874, 0.3366]}, {"w": "(this", "b": [0.5922, 0.3152, 0.6301, 0.3366]}, {"w": "is", "b": [0.6349, 0.3152, 0.6482, 0.3366]}, {"w": "the", "b": [0.653, 0.3152, 0.6793, 0.3366]}, {"w": "feature", "b": [0.6842, 0.3152, 0.7419, 0.3366]}, {"w": "map", "b": [0.7468, 0.3152, 0.7835, 0.3366]}, {"w": "size,", "b": [0.7883, 0.3152, 0.8239, 0.3366]}, {"w": "not", "b": [0.8288, 0.3152, 0.8571, 0.3366]}, {"w": "the", "b": [0.1429, 0.3343, 0.1692, 0.3557]}, {"w": "kernel", "b": [0.1751, 0.3343, 0.2275, 0.3557]}, {"w": "size).", "b": [0.2334, 0.3343, 0.2762, 0.3557]}, {"w": "Each", "b": [0.2821, 0.3343, 0.323, 0.3557]}, {"w": "neuron", "b": [0.3289, 0.3343, 0.3899, 0.3557]}, {"w": "will", "b": [0.3958, 0.3343, 0.4262, 0.3557]}, {"w": "compute", "b": [0.4321, 0.3343, 0.5054, 0.3557]}, {"w": "a", "b": [0.5113, 0.3343, 0.5204, 0.3557]}, {"w": "weighted", "b": [0.5263, 0.3343, 0.6017, 0.3557]}, {"w": "sum", "b": [0.6076, 0.3343, 0.6433, 0.3557]}, {"w": "of", "b": [0.6492, 0.3343, 0.666, 0.3557]}, {"w": "all", "b": [0.6719, 0.3343, 0.6916, 0.3557]}, {"w": "100", "b": [0.6975, 0.3343, 0.7275, 0.3557]}, {"w": "×", "b": [0.7334, 0.3343, 0.7454, 0.3557]}, {"w": "7", "b": [0.7513, 0.3343, 0.7613, 0.3557]}, {"w": "×", "b": [0.7672, 0.3343, 0.7793, 0.3557]}, {"w": "7", "b": [0.7852, 0.3343, 0.7952, 0.3557]}, {"w": "activa‐", "b": [0.801, 0.3343, 0.8572, 0.3557]}, {"w": "tions", "b": [0.1429, 0.3533, 0.1845, 0.3747]}, {"w": "from", "b": [0.1893, 0.3533, 0.2309, 0.3747]}, {"w": "the", "b": [0.2357, 0.3533, 0.2621, 0.3747]}, {"w": "convolutional", "b": [0.2669, 0.3533, 0.3822, 0.3747]}, {"w": "layer", "b": [0.3871, 0.3533, 0.4273, 0.3747]}, {"w": "(plus", "b": [0.4321, 0.3533, 0.4742, 0.3747]}, {"w": "a", "b": [0.4791, 0.3533, 0.4882, 0.3747]}, {"w": "bias", "b": [0.4931, 0.3533, 0.526, 0.3747]}, {"w": "term).", "b": [0.5309, 0.3533, 0.5828, 0.3747]}, {"w": "Now", "b": [0.5877, 0.3533, 0.6275, 0.3747]}, {"w": "let’s", "b": [0.6324, 0.3533, 0.6626, 0.3747]}, {"w": "see", "b": [0.6674, 0.3533, 0.6928, 0.3747]}, {"w": "what", "b": [0.6976, 0.3533, 0.7381, 0.3747]}, {"w": "happens", "b": [0.743, 0.3533, 0.8126, 0.3747]}, {"w": "if", "b": [0.8174, 0.3533, 0.8292, 0.3747]}, {"w": "we", "b": [0.834, 0.3533, 0.8571, 0.3747]}, {"w": "replace", "b": [0.1429, 0.3723, 0.2024, 0.3938]}, {"w": "the", "b": [0.2075, 0.3723, 0.2339, 0.3938]}, {"w": "dense", "b": [0.2389, 0.3723, 0.2867, 0.3938]}, {"w": "layer", "b": [0.2918, 0.3723, 0.332, 0.3938]}, {"w": "with", "b": [0.3371, 0.3723, 0.3744, 0.3938]}, {"w": "a", "b": [0.3795, 0.3723, 0.3886, 0.3938]}, {"w": "convolution", "b": [0.3937, 0.3723, 0.4946, 0.3938]}, {"w": "layer", "b": [0.4997, 0.3723, 0.5399, 0.3938]}, {"w": "using", "b": [0.545, 0.3723, 0.5904, 0.3938]}, {"w": "200", "b": [0.5955, 0.3723, 0.6255, 0.3938]}, {"w": "filters,", "b": [0.6306, 0.3723, 0.683, 0.3938]}, {"w": "each", "b": [0.6881, 0.3723, 0.726, 0.3938]}, {"w": "7", "b": [0.7311, 0.3723, 0.7411, 0.3938]}, {"w": "×", "b": [0.7462, 0.3723, 0.7583, 0.3938]}, {"w": "7,", "b": [0.7633, 0.3723, 0.7781, 0.3938]}, {"w": "and", "b": [0.7832, 0.3723, 0.8147, 0.3938]}, {"w": "with", "b": [0.8198, 0.3723, 0.8571, 0.3938]}, {"w": "VALID", "b": [0.1428, 0.3914, 0.203, 0.4128]}, {"w": "padding.", "b": [0.2084, 0.3914, 0.2819, 0.4128]}, {"w": "This", "b": [0.2873, 0.3914, 0.3245, 0.4128]}, {"w": "layer", "b": [0.33, 0.3914, 0.3701, 0.4128]}, {"w": "will", "b": [0.3756, 0.3914, 0.406, 0.4128]}, {"w": "output", "b": [0.4114, 0.3914, 0.4678, 0.4128]}, {"w": "200", "b": [0.4732, 0.3914, 0.5032, 0.4128]}, {"w": "feature", "b": [0.5086, 0.3914, 0.5664, 0.4128]}, {"w": "maps,", "b": [0.5718, 0.3914, 0.6209, 0.4128]}, {"w": "each", "b": [0.6263, 0.3914, 0.6643, 0.4128]}, {"w": "1", "b": [0.6697, 0.3914, 0.6797, 0.4128]}, {"w": "×", "b": [0.6851, 0.3914, 0.6972, 0.4128]}, {"w": "1", "b": [0.7026, 0.3914, 0.7126, 0.4128]}, {"w": "(since", "b": [0.718, 0.3914, 0.7675, 0.4128]}, {"w": "the", "b": [0.7729, 0.3914, 0.7993, 0.4128]}, {"w": "kernel", "b": [0.8047, 0.3914, 0.8571, 0.4128]}, {"w": "is", "b": [0.1429, 0.4104, 0.1561, 0.4319]}, {"w": "exactly", "b": [0.1635, 0.4104, 0.2213, 0.4319]}, {"w": "the", "b": [0.2287, 0.4104, 0.255, 0.4319]}, {"w": "size", "b": [0.2624, 0.4104, 0.2932, 0.4319]}, {"w": "of", "b": [0.3006, 0.4104, 0.3174, 0.4319]}, {"w": "the", "b": [0.3248, 0.4104, 0.3511, 0.4319]}, {"w": "input", "b": [0.3585, 0.4104, 0.4034, 0.4319]}, {"w": "feature", "b": [0.4108, 0.4104, 0.4686, 0.4319]}, {"w": "maps", "b": [0.4759, 0.4104, 0.5203, 0.4319]}, {"w": "and", "b": [0.5277, 0.4104, 0.5592, 0.4319]}, {"w": "we", "b": [0.5666, 0.4104, 0.5897, 0.4319]}, {"w": "are", "b": [0.5971, 0.4104, 0.6228, 0.4319]}, {"w": "using", "b": [0.6302, 0.4104, 0.6757, 0.4319]}, {"w": "VALID", "b": [0.683, 0.4104, 0.7431, 0.4319]}, {"w": "padding).", "b": [0.7505, 0.4104, 0.8313, 0.4319]}, {"w": "In", "b": [0.8386, 0.4104, 0.8571, 0.4319]}, {"w": "other", "b": [0.1429, 0.4295, 0.1875, 0.4509]}, {"w": "words,", "b": [0.193, 0.4295, 0.249, 0.4509]}, {"w": "it", "b": [0.2545, 0.4295, 0.2665, 0.4509]}, {"w": "will", "b": [0.272, 0.4295, 0.3024, 0.4509]}, {"w": "output", "b": [0.3078, 0.4295, 0.3642, 0.4509]}, {"w": "200", "b": [0.3697, 0.4295, 0.3997, 0.4509]}, {"w": "numbers,", "b": [0.4052, 0.4295, 0.4839, 0.4509]}, {"w": "just", "b": [0.4893, 0.4295, 0.5197, 0.4509]}, {"w": "like", "b": [0.5252, 0.4295, 0.5553, 0.4509]}, {"w": "the", "b": [0.5608, 0.4295, 0.5871, 0.4509]}, {"w": "dense", "b": [0.5926, 0.4295, 0.6403, 0.4509]}, {"w": "layer", "b": [0.6458, 0.4295, 0.686, 0.4509]}, {"w": "did,", "b": [0.6915, 0.4295, 0.7238, 0.4509]}, {"w": "and", "b": [0.7293, 0.4295, 0.7608, 0.4509]}, {"w": "if", "b": [0.7663, 0.4295, 0.7781, 0.4509]}, {"w": "you", "b": [0.7836, 0.4295, 0.8148, 0.4509]}, {"w": "look", "b": [0.8203, 0.4295, 0.8571, 0.4509]}, {"w": "closely", "b": [0.1429, 0.4485, 0.1989, 0.47]}, {"w": "at", "b": [0.2055, 0.4485, 0.2206, 0.47]}, {"w": "the", "b": [0.2272, 0.4485, 0.2535, 0.47]}, {"w": "computations", "b": [0.2601, 0.4485, 0.3749, 0.47]}, {"w": "performed", "b": [0.3814, 0.4485, 0.4704, 0.47]}, {"w": "by", "b": [0.477, 0.4485, 0.4971, 0.47]}, {"w": "a", "b": [0.5037, 0.4485, 0.5128, 0.47]}, {"w": "convolutional", "b": [0.5194, 0.4485, 0.6348, 0.47]}, {"w": "layer,", "b": [0.6413, 0.4485, 0.685, 0.47]}, {"w": "you", "b": [0.6915, 0.4485, 0.7228, 0.47]}, {"w": "will", "b": [0.7294, 0.4485, 0.7598, 0.47]}, {"w": "notice", "b": [0.7663, 0.4485, 0.818, 0.47]}, {"w": "that", "b": [0.8246, 0.4485, 0.8571, 0.47]}, {"w": "these", "b": [0.1429, 0.4676, 0.1857, 0.489]}, {"w": "numbers", "b": [0.1905, 0.4676, 0.2644, 0.489]}, {"w": "will", "b": [0.2692, 0.4676, 0.2996, 0.489]}, {"w": "be", "b": [0.3044, 0.4676, 0.3238, 0.489]}, {"w": "precisely", "b": [0.3286, 0.4676, 0.4018, 0.489]}, {"w": "the", "b": [0.4066, 0.4676, 0.433, 0.489]}, {"w": "same", "b": [0.4377, 0.4676, 0.4805, 0.489]}, {"w": "as", "b": [0.4852, 0.4676, 0.502, 0.489]}, {"w": "the", "b": [0.5068, 0.4676, 0.5331, 0.489]}, {"w": "dense", "b": [0.5379, 0.4676, 0.5857, 0.489]}, {"w": "layer", "b": [0.5905, 0.4676, 0.6307, 0.489]}, {"w": "produced.", "b": [0.6354, 0.4676, 0.7202, 0.489]}, {"w": "The", "b": [0.725, 0.4676, 0.7578, 0.489]}, {"w": "only", "b": [0.7626, 0.4676, 0.7994, 0.489]}, {"w": "differ‐", "b": [0.8042, 0.4676, 0.8572, 0.489]}, {"w": "ence", "b": [0.1429, 0.4866, 0.1808, 0.508]}, {"w": "is", "b": [0.1868, 0.4866, 0.2, 0.508]}, {"w": "that", "b": [0.206, 0.4866, 0.2385, 0.508]}, {"w": "the", "b": [0.2445, 0.4866, 0.2709, 0.508]}, {"w": "dense", "b": [0.2768, 0.4866, 0.3246, 0.508]}, {"w": "layer’s", "b": [0.3306, 0.4866, 0.3811, 0.508]}, {"w": "output", "b": [0.3871, 0.4866, 0.4434, 0.508]}, {"w": "was", "b": [0.4494, 0.4866, 0.4805, 0.508]}, {"w": "a", "b": [0.4865, 0.4866, 0.4956, 0.508]}, {"w": "tensor", "b": [0.5016, 0.4866, 0.5542, 0.508]}, {"w": "of", "b": [0.5602, 0.4866, 0.577, 0.508]}, {"w": "shape", "b": [0.5829, 0.4866, 0.6302, 0.508]}, {"w": "[batch", "b": [0.6362, 0.4866, 0.689, 0.508]}, {"w": "size,", "b": [0.695, 0.4866, 0.7306, 0.508]}, {"w": "200]", "b": [0.7366, 0.4866, 0.7737, 0.508]}, {"w": "while", "b": [0.7797, 0.4866, 0.8248, 0.508]}, {"w": "the", "b": [0.8308, 0.4866, 0.8571, 0.508]}, {"w": "convolutional", "b": [0.1429, 0.5057, 0.2582, 0.5271]}, {"w": "layer", "b": [0.2629, 0.5057, 0.3031, 0.5271]}, {"w": "will", "b": [0.3078, 0.5057, 0.3382, 0.5271]}, {"w": "output", "b": [0.343, 0.5057, 0.3993, 0.5271]}, {"w": "a", "b": [0.4041, 0.5057, 0.4132, 0.5271]}, {"w": "tensor", "b": [0.4179, 0.5057, 0.4705, 0.5271]}, {"w": "of", "b": [0.4753, 0.5057, 0.4921, 0.5271]}, {"w": "shape", "b": [0.4968, 0.5057, 0.5441, 0.5271]}, {"w": "[batch", "b": [0.5488, 0.5057, 0.6016, 0.5271]}, {"w": "size,", "b": [0.6064, 0.5057, 0.6419, 0.5271]}, {"w": "1,", "b": [0.6467, 0.5057, 0.6614, 0.5271]}, {"w": "1,", "b": [0.6661, 0.5057, 0.6809, 0.5271]}, {"w": "200].", "b": [0.6856, 0.5057, 0.7276, 0.5271]}]}, {"id": "b_6", "type": "paragraph", "text": "To convert a dense layer to a convolutional layer, the number of fil‐ ters in the convolutional layer must be equal to the number of units in the dense layer, the filter size must be equal to the size of the input feature maps, and you must use VALID padding. The stride may be set to 1 or more, as we will see shortly.", "words": [{"w": "To", "b": [0.2714, 0.5476, 0.291, 0.5672]}, {"w": "convert", "b": [0.2957, 0.5476, 0.3533, 0.5672]}, {"w": "a", "b": [0.358, 0.5476, 0.3664, 0.5672]}, {"w": "dense", "b": [0.3711, 0.5476, 0.4148, 0.5672]}, {"w": "layer", "b": [0.4195, 0.5476, 0.4562, 0.5672]}, {"w": "to", "b": [0.461, 0.5476, 0.4765, 0.5672]}, {"w": "a", "b": [0.4812, 0.5476, 0.4896, 0.5672]}, {"w": "convolutional", "b": [0.4943, 0.5476, 0.5998, 0.5672]}, {"w": "layer,", "b": [0.6045, 0.5476, 0.6444, 0.5672]}, {"w": "the", "b": [0.6491, 0.5476, 0.6732, 0.5672]}, {"w": "number", "b": [0.6779, 0.5476, 0.7386, 0.5672]}, {"w": "of", "b": [0.7433, 0.5476, 0.7586, 0.5672]}, {"w": "fil‐", "b": [0.7634, 0.5476, 0.7857, 0.5672]}, {"w": "ters", "b": [0.2714, 0.565, 0.2994, 0.5846]}, {"w": "in", "b": [0.3038, 0.565, 0.3194, 0.5846]}, {"w": "the", "b": [0.3238, 0.565, 0.3479, 0.5846]}, {"w": "convolutional", "b": [0.3523, 0.565, 0.4578, 0.5846]}, {"w": "layer", "b": [0.4623, 0.565, 0.499, 0.5846]}, {"w": "must", "b": [0.5035, 0.565, 0.5416, 0.5846]}, {"w": "be", "b": [0.5461, 0.565, 0.5638, 0.5846]}, {"w": "equal", "b": [0.5683, 0.565, 0.6094, 0.5846]}, {"w": "to", "b": [0.6139, 0.565, 0.6294, 0.5846]}, {"w": "the", "b": [0.6339, 0.565, 0.6579, 0.5846]}, {"w": "number", "b": [0.6624, 0.565, 0.723, 0.5846]}, {"w": "of", "b": [0.7275, 0.565, 0.7428, 0.5846]}, {"w": "units", "b": [0.7473, 0.565, 0.7857, 0.5846]}, {"w": "in", "b": [0.2714, 0.5825, 0.2869, 0.602]}, {"w": "the", "b": [0.2939, 0.5825, 0.318, 0.602]}, {"w": "dense", "b": [0.325, 0.5825, 0.3687, 0.602]}, {"w": "layer,", "b": [0.3757, 0.5825, 0.4156, 0.602]}, {"w": "the", "b": [0.4226, 0.5825, 0.4467, 0.602]}, {"w": "filter", "b": [0.4537, 0.5825, 0.4902, 0.602]}, {"w": "size", "b": [0.4972, 0.5825, 0.5254, 0.602]}, {"w": "must", "b": [0.5324, 0.5825, 0.5706, 0.602]}, {"w": "be", "b": [0.5776, 0.5825, 0.5953, 0.602]}, {"w": "equal", "b": [0.6023, 0.5825, 0.6435, 0.602]}, {"w": "to", "b": [0.6505, 0.5825, 0.666, 0.602]}, {"w": "the", "b": [0.673, 0.5825, 0.6971, 0.602]}, {"w": "size", "b": [0.7041, 0.5825, 0.7323, 0.602]}, {"w": "of", "b": [0.7393, 0.5825, 0.7546, 0.602]}, {"w": "the", "b": [0.7616, 0.5825, 0.7857, 0.602]}, {"w": "input", "b": [0.2714, 0.5999, 0.3125, 0.6194]}, {"w": "feature", "b": [0.3184, 0.5999, 0.3712, 0.6194]}, {"w": "maps,", "b": [0.3772, 0.5999, 0.4221, 0.6194]}, {"w": "and", "b": [0.428, 0.5999, 0.4569, 0.6194]}, {"w": "you", "b": [0.4628, 0.5999, 0.4914, 0.6194]}, {"w": "must", "b": [0.4973, 0.5999, 0.5355, 0.6194]}, {"w": "use", "b": [0.5414, 0.5999, 0.5666, 0.6194]}, {"w": "VALID", "b": [0.5726, 0.5999, 0.6275, 0.6194]}, {"w": "padding.", "b": [0.6335, 0.5999, 0.7007, 0.6194]}, {"w": "The", "b": [0.7066, 0.5999, 0.7367, 0.6194]}, {"w": "stride", "b": [0.7426, 0.5999, 0.7857, 0.6194]}, {"w": "may", "b": [0.2714, 0.6173, 0.3038, 0.6369]}, {"w": "be", "b": [0.3081, 0.6173, 0.3259, 0.6369]}, {"w": "set", "b": [0.3302, 0.6173, 0.3511, 0.6369]}, {"w": "to", "b": [0.3554, 0.6173, 0.3709, 0.6369]}, {"w": "1", "b": [0.3753, 0.6173, 0.3844, 0.6369]}, {"w": "or", "b": [0.3887, 0.6173, 0.4055, 0.6369]}, {"w": "more,", "b": [0.4098, 0.6173, 0.4547, 0.6369]}, {"w": "as", "b": [0.459, 0.6173, 0.4743, 0.6369]}, {"w": "we", "b": [0.4787, 0.6173, 0.4998, 0.6369]}, {"w": "will", "b": [0.5041, 0.6173, 0.5319, 0.6369]}, {"w": "see", "b": [0.5362, 0.6173, 0.5594, 0.6369]}, {"w": "shortly.", "b": [0.5637, 0.6173, 0.62, 0.6369]}]}, {"id": "b_7", "type": "paragraph", "text": "Why is this important? Well, while a dense layer expects a specific input size (since it has one weight per input feature), a convolutional layer will happily process images of any size24 (however, it does expect its inputs to have a specific number of channels, since each kernel contains a different set of weights for each input channel). Since an FCN contains only convolutional layers (and pooling layers, which have the same property), it can be trained and executed on images of any size!", "words": [{"w": "Why", "b": [0.1429, 0.6572, 0.1833, 0.6786]}, {"w": "is", "b": [0.1888, 0.6572, 0.2021, 0.6786]}, {"w": "this", "b": [0.2076, 0.6572, 0.2383, 0.6786]}, {"w": "important?", "b": [0.2439, 0.6572, 0.3361, 0.6786]}, {"w": "Well,", "b": [0.3417, 0.6572, 0.384, 0.6786]}, {"w": "while", "b": [0.3896, 0.6572, 0.4347, 0.6786]}, {"w": "a", "b": [0.4402, 0.6572, 0.4494, 0.6786]}, {"w": "dense", "b": [0.4549, 0.6572, 0.5026, 0.6786]}, {"w": "layer", "b": [0.5082, 0.6572, 0.5484, 0.6786]}, {"w": "expects", "b": [0.5539, 0.6572, 0.6152, 0.6786]}, {"w": "a", "b": [0.6207, 0.6572, 0.6299, 0.6786]}, {"w": "specific", "b": [0.6354, 0.6572, 0.6978, 0.6786]}, {"w": "input", "b": [0.7033, 0.6572, 0.7482, 0.6786]}, {"w": "size", "b": [0.7538, 0.6572, 0.7846, 0.6786]}, {"w": "(since", "b": [0.7902, 0.6572, 0.8397, 0.6786]}, {"w": "it", "b": [0.8452, 0.6572, 0.8571, 0.6786]}, {"w": "has", "b": [0.1429, 0.6762, 0.1708, 0.6976]}, {"w": "one", "b": [0.1757, 0.6762, 0.2065, 0.6976]}, {"w": "weight", "b": [0.2114, 0.6762, 0.267, 0.6976]}, {"w": "per", "b": [0.2719, 0.6762, 0.2994, 0.6976]}, {"w": "input", "b": [0.3042, 0.6762, 0.3492, 0.6976]}, {"w": "feature),", "b": [0.354, 0.6762, 0.4238, 0.6976]}, {"w": "a", "b": [0.4287, 0.6762, 0.4378, 0.6976]}, {"w": "convolutional", "b": [0.4427, 0.6762, 0.558, 0.6976]}, {"w": "layer", "b": [0.5629, 0.6762, 0.6031, 0.6976]}, {"w": "will", "b": [0.608, 0.6762, 0.6384, 0.6976]}, {"w": "happily", "b": [0.6433, 0.6762, 0.7054, 0.6976]}, {"w": "process", "b": [0.7103, 0.6762, 0.7725, 0.6976]}, {"w": "images", "b": [0.7774, 0.6762, 0.8355, 0.6976]}, {"w": "of", "b": [0.8403, 0.6762, 0.8571, 0.6976]}, {"w": "any", "b": [0.1429, 0.6953, 0.1725, 0.7167]}, {"w": "size24", "b": [0.1794, 0.6953, 0.2216, 0.7167]}, {"w": "(however,", "b": [0.2285, 0.6953, 0.3103, 0.7167]}, {"w": "it", "b": [0.3172, 0.6953, 0.3291, 0.7167]}, {"w": "does", "b": [0.336, 0.6953, 0.3741, 0.7167]}, {"w": "expect", "b": [0.381, 0.6953, 0.4346, 0.7167]}, {"w": "its", "b": [0.4415, 0.6953, 0.4611, 0.7167]}, {"w": "inputs", "b": [0.468, 0.6953, 0.5205, 0.7167]}, {"w": "to", "b": [0.5274, 0.6953, 0.5444, 0.7167]}, {"w": "have", "b": [0.5513, 0.6953, 0.5897, 0.7167]}, {"w": "a", "b": [0.5966, 0.6953, 0.6057, 0.7167]}, {"w": "specific", "b": [0.6126, 0.6953, 0.675, 0.7167]}, {"w": "number", "b": [0.6819, 0.6953, 0.7482, 0.7167]}, {"w": "of", "b": [0.7551, 0.6953, 0.7719, 0.7167]}, {"w": "channels,", "b": [0.7787, 0.6953, 0.8571, 0.7167]}, {"w": "since", "b": [0.1428, 0.7143, 0.1851, 0.7357]}, {"w": "each", "b": [0.1906, 0.7143, 0.2286, 0.7357]}, {"w": "kernel", "b": [0.2341, 0.7143, 0.2865, 0.7357]}, {"w": "contains", "b": [0.292, 0.7143, 0.3626, 0.7357]}, {"w": "a", "b": [0.3681, 0.7143, 0.3772, 0.7357]}, {"w": "different", "b": [0.3827, 0.7143, 0.4544, 0.7357]}, {"w": "set", "b": [0.4599, 0.7143, 0.4828, 0.7357]}, {"w": "of", "b": [0.4883, 0.7143, 0.5051, 0.7357]}, {"w": "weights", "b": [0.5106, 0.7143, 0.5738, 0.7357]}, {"w": "for", "b": [0.5792, 0.7143, 0.6038, 0.7357]}, {"w": "each", "b": [0.6093, 0.7143, 0.6472, 0.7357]}, {"w": "input", "b": [0.6527, 0.7143, 0.6976, 0.7357]}, {"w": "channel).", "b": [0.7031, 0.7143, 0.7811, 0.7357]}, {"w": "Since", "b": [0.7866, 0.7143, 0.8311, 0.7357]}, {"w": "an", "b": [0.8366, 0.7143, 0.8571, 0.7357]}, {"w": "FCN", "b": [0.1429, 0.7333, 0.1832, 0.7548]}, {"w": "contains", "b": [0.1914, 0.7333, 0.2619, 0.7548]}, {"w": "only", "b": [0.2701, 0.7333, 0.3069, 0.7548]}, {"w": "convolutional", "b": [0.315, 0.7333, 0.4304, 0.7548]}, {"w": "layers", "b": [0.4385, 0.7333, 0.4863, 0.7548]}, {"w": "(and", "b": [0.4945, 0.7333, 0.5332, 0.7548]}, {"w": "pooling", "b": [0.5414, 0.7333, 0.6055, 0.7548]}, {"w": "layers,", "b": [0.6137, 0.7333, 0.6663, 0.7548]}, {"w": "which", "b": [0.6744, 0.7333, 0.7253, 0.7548]}, {"w": "have", "b": [0.7334, 0.7333, 0.7718, 0.7548]}, {"w": "the", "b": [0.78, 0.7333, 0.8063, 0.7548]}, {"w": "same", "b": [0.8144, 0.7333, 0.8571, 0.7548]}, {"w": "property),", "b": [0.1429, 0.7524, 0.2275, 0.7738]}, {"w": "it", "b": [0.2322, 0.7524, 0.2442, 0.7738]}, {"w": "can", "b": [0.2489, 0.7524, 0.2783, 0.7738]}, {"w": "be", "b": [0.283, 0.7524, 0.3024, 0.7738]}, {"w": "trained", "b": [0.3071, 0.7524, 0.3672, 0.7738]}, {"w": "and", "b": [0.3719, 0.7524, 0.4035, 0.7738]}, {"w": "executed", "b": [0.4082, 0.7524, 0.4818, 0.7738]}, {"w": "on", "b": [0.4866, 0.7524, 0.5086, 0.7738]}, {"w": "images", "b": [0.5133, 0.7524, 0.5714, 0.7738]}, {"w": "of", "b": [0.5761, 0.7524, 0.5929, 0.7738]}, {"w": "any", "b": [0.5976, 0.7524, 0.6272, 0.7738]}, {"w": "size!", "b": [0.632, 0.7524, 0.6685, 0.7738]}]}, {"id": "b_8", "type": "paragraph", "text": "Object Detection | 473", "words": [{"w": "Object", "b": [0.6987, 0.9225, 0.736, 0.9388]}, {"w": "Detection", "b": [0.7388, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "473", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 500, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "25 This assumes we used only SAME padding in the network: indeed, VALID padding would reduce the size of the feature maps. Moreover, 448 can be neatly divided by 2 several times until we reach 7, without any round‐ ing error. If any layer uses a different stride than 1 or 2, then there may be some rounding error, so again the feature maps may end up being smaller.", "words": [{"w": "25", "b": [0.1385, 0.8311, 0.1518, 0.8453]}, {"w": "This", "b": [0.1587, 0.8296, 0.1871, 0.8459]}, {"w": "assumes", "b": [0.1907, 0.8296, 0.2433, 0.8459]}, {"w": "we", "b": [0.2469, 0.8296, 0.2645, 0.8459]}, {"w": "used", "b": [0.2681, 0.8296, 0.2975, 0.8459]}, {"w": "only", "b": [0.3011, 0.8296, 0.3292, 0.8459]}, {"w": "SAME", "b": [0.3328, 0.8296, 0.3744, 0.8459]}, {"w": "padding", "b": [0.378, 0.8296, 0.4305, 0.8459]}, {"w": "in", "b": [0.4341, 0.8296, 0.447, 0.8459]}, {"w": "the", "b": [0.4506, 0.8296, 0.4707, 0.8459]}, {"w": "network:", "b": [0.4743, 0.8296, 0.5309, 0.8459]}, {"w": "indeed,", "b": [0.5345, 0.8296, 0.5813, 0.8459]}, {"w": "VALID", "b": [0.5849, 0.8296, 0.6307, 0.8459]}, {"w": "padding", "b": [0.6343, 0.8296, 0.6867, 0.8459]}, {"w": "would", "b": [0.6903, 0.8296, 0.7301, 0.8459]}, {"w": "reduce", "b": [0.7337, 0.8296, 0.7766, 0.8459]}, {"w": "the", "b": [0.7802, 0.8296, 0.8003, 0.8459]}, {"w": "size", "b": [0.8039, 0.8296, 0.8274, 0.8459]}, {"w": "of", "b": [0.831, 0.8296, 0.8438, 0.8459]}, {"w": "the", "b": [0.1587, 0.8447, 0.1788, 0.861]}, {"w": "feature", "b": [0.1824, 0.8447, 0.2264, 0.861]}, {"w": "maps.", "b": [0.23, 0.8447, 0.2674, 0.861]}, {"w": "Moreover,", "b": [0.271, 0.8447, 0.3362, 0.861]}, {"w": "448", "b": [0.3398, 0.8447, 0.3627, 0.861]}, {"w": "can", "b": [0.3663, 0.8447, 0.3886, 0.861]}, {"w": "be", "b": [0.3922, 0.8447, 0.407, 0.861]}, {"w": "neatly", "b": [0.4107, 0.8447, 0.4489, 0.861]}, {"w": "divided", "b": [0.4525, 0.8447, 0.5002, 0.861]}, {"w": "by", "b": [0.5038, 0.8447, 0.5192, 0.861]}, {"w": "2", "b": [0.5228, 0.8447, 0.5304, 0.861]}, {"w": "several", "b": [0.534, 0.8447, 0.5776, 0.861]}, {"w": "times", "b": [0.5812, 0.8447, 0.6158, 0.861]}, {"w": "until", "b": [0.6194, 0.8447, 0.6493, 0.861]}, {"w": "we", "b": [0.653, 0.8447, 0.6706, 0.861]}, {"w": "reach", "b": [0.6742, 0.8447, 0.709, 0.861]}, {"w": "7,", "b": [0.7126, 0.8447, 0.7238, 0.861]}, {"w": "without", "b": [0.7274, 0.8447, 0.7772, 0.861]}, {"w": "any", "b": [0.7808, 0.8447, 0.8034, 0.861]}, {"w": "round‐", "b": [0.807, 0.8447, 0.8521, 0.861]}, {"w": "ing", "b": [0.1587, 0.8598, 0.1791, 0.8761]}, {"w": "error.", "b": [0.1827, 0.8598, 0.2178, 0.8761]}, {"w": "If", "b": [0.2214, 0.8598, 0.2315, 0.8761]}, {"w": "any", "b": [0.2351, 0.8598, 0.2577, 0.8761]}, {"w": "layer", "b": [0.2613, 0.8598, 0.2919, 0.8761]}, {"w": "uses", "b": [0.2955, 0.8598, 0.3224, 0.8761]}, {"w": "a", "b": [0.326, 0.8598, 0.3329, 0.8761]}, {"w": "different", "b": [0.3365, 0.8598, 0.3912, 0.8761]}, {"w": "stride", "b": [0.3948, 0.8598, 0.4307, 0.8761]}, {"w": "than", "b": [0.4343, 0.8598, 0.4633, 0.8761]}, {"w": "1", "b": [0.4669, 0.8598, 0.4745, 0.8761]}, {"w": "or", "b": [0.4781, 0.8598, 0.4921, 0.8761]}, {"w": "2,", "b": [0.4957, 0.8598, 0.5069, 0.8761]}, {"w": "then", "b": [0.5105, 0.8598, 0.5393, 0.8761]}, {"w": "there", "b": [0.5429, 0.8598, 0.5756, 0.8761]}, {"w": "may", "b": [0.5792, 0.8598, 0.6062, 0.8761]}, {"w": "be", "b": [0.6098, 0.8598, 0.6246, 0.8761]}, {"w": "some", "b": [0.6282, 0.8598, 0.6618, 0.8761]}, {"w": "rounding", "b": [0.6654, 0.8598, 0.7253, 0.8761]}, {"w": "error,", "b": [0.7289, 0.8598, 0.764, 0.8761]}, {"w": "so", "b": [0.7676, 0.8598, 0.7815, 0.8761]}, {"w": "again", "b": [0.7851, 0.8598, 0.8194, 0.8761]}, {"w": "the", "b": [0.823, 0.8598, 0.8431, 0.8761]}, {"w": "feature", "b": [0.1587, 0.8749, 0.2027, 0.8912]}, {"w": "maps", "b": [0.2063, 0.8749, 0.2402, 0.8912]}, {"w": "may", "b": [0.2438, 0.8749, 0.2707, 0.8912]}, {"w": "end", "b": [0.2743, 0.8749, 0.2981, 0.8912]}, {"w": "up", "b": [0.3017, 0.8749, 0.3185, 0.8912]}, {"w": "being", "b": [0.3221, 0.8749, 0.3573, 0.8912]}, {"w": "smaller.", "b": [0.3609, 0.8749, 0.41, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "For example, suppose we already trained a CNN for flower classification and localiza‐ tion. It was trained on 224 × 224 images and it outputs 10 numbers: outputs 0 to 4 are sent through the softmax activation function, and this gives the class probabilities (one per class); output 5 is sent through the logistic activation function, and this gives the objectness score; outputs 6 to 9 do not use any activation function, and they rep‐ resent the bounding box’s center coordinates, and its height and width. We can now convert its dense layers to convolutional layers. In fact, we don’t even need to retrain it, we can just copy the weights from the dense layers to the convolutional layers! Alternatively, we could have converted the CNN into an FCN before training.", "words": [{"w": "For", "b": [0.1428, 0.0791, 0.1718, 0.1005]}, {"w": "example,", "b": [0.1768, 0.0791, 0.251, 0.1005]}, {"w": "suppose", "b": [0.256, 0.0791, 0.3236, 0.1005]}, {"w": "we", "b": [0.3286, 0.0791, 0.3517, 0.1005]}, {"w": "already", "b": [0.3566, 0.0791, 0.4173, 0.1005]}, {"w": "trained", "b": [0.4223, 0.0791, 0.4823, 0.1005]}, {"w": "a", "b": [0.4872, 0.0791, 0.4964, 0.1005]}, {"w": "CNN", "b": [0.5013, 0.0791, 0.5461, 0.1005]}, {"w": "for", "b": [0.5511, 0.0791, 0.5756, 0.1005]}, {"w": "flower", "b": [0.5805, 0.0791, 0.6334, 0.1005]}, {"w": "classification", "b": [0.6383, 0.0791, 0.7457, 0.1005]}, {"w": "and", "b": [0.7506, 0.0791, 0.7822, 0.1005]}, {"w": "localiza‐", "b": [0.7871, 0.0791, 0.8571, 0.1005]}, {"w": "tion.", "b": [0.1429, 0.0981, 0.1816, 0.1195]}, {"w": "It", "b": [0.1864, 0.0981, 0.199, 0.1195]}, {"w": "was", "b": [0.2039, 0.0981, 0.2349, 0.1195]}, {"w": "trained", "b": [0.2397, 0.0981, 0.2998, 0.1195]}, {"w": "on", "b": [0.3046, 0.0981, 0.3266, 0.1195]}, {"w": "224", "b": [0.3315, 0.0981, 0.3615, 0.1195]}, {"w": "×", "b": [0.3663, 0.0981, 0.3784, 0.1195]}, {"w": "224", "b": [0.3832, 0.0981, 0.4132, 0.1195]}, {"w": "images", "b": [0.418, 0.0981, 0.476, 0.1195]}, {"w": "and", "b": [0.4809, 0.0981, 0.5124, 0.1195]}, {"w": "it", "b": [0.5172, 0.0981, 0.5292, 0.1195]}, {"w": "outputs", "b": [0.534, 0.0981, 0.598, 0.1195]}, {"w": "10", "b": [0.6028, 0.0981, 0.6228, 0.1195]}, {"w": "numbers:", "b": [0.6276, 0.0981, 0.7063, 0.1195]}, {"w": "outputs", "b": [0.7111, 0.0981, 0.7752, 0.1195]}, {"w": "0", "b": [0.78, 0.0981, 0.79, 0.1195]}, {"w": "to", "b": [0.7948, 0.0981, 0.8118, 0.1195]}, {"w": "4", "b": [0.8166, 0.0981, 0.8266, 0.1195]}, {"w": "are", "b": [0.8314, 0.0981, 0.8571, 0.1195]}, {"w": "sent", "b": [0.1429, 0.1172, 0.1767, 0.1386]}, {"w": "through", "b": [0.1847, 0.1172, 0.2525, 0.1386]}, {"w": "the", "b": [0.2605, 0.1172, 0.2868, 0.1386]}, {"w": "softmax", "b": [0.2948, 0.1172, 0.3617, 0.1386]}, {"w": "activation", "b": [0.3697, 0.1172, 0.4519, 0.1386]}, {"w": "function,", "b": [0.4599, 0.1172, 0.5361, 0.1386]}, {"w": "and", "b": [0.5441, 0.1172, 0.5756, 0.1386]}, {"w": "this", "b": [0.5836, 0.1172, 0.6143, 0.1386]}, {"w": "gives", "b": [0.6223, 0.1172, 0.6638, 0.1386]}, {"w": "the", "b": [0.6718, 0.1172, 0.6982, 0.1386]}, {"w": "class", "b": [0.7062, 0.1172, 0.7447, 0.1386]}, {"w": "probabilities", "b": [0.7527, 0.1172, 0.8571, 0.1386]}, {"w": "(one", "b": [0.1429, 0.1362, 0.1809, 0.1576]}, {"w": "per", "b": [0.1859, 0.1362, 0.2134, 0.1576]}, {"w": "class);", "b": [0.2183, 0.1362, 0.2688, 0.1576]}, {"w": "output", "b": [0.2737, 0.1362, 0.3301, 0.1576]}, {"w": "5", "b": [0.335, 0.1362, 0.345, 0.1576]}, {"w": "is", "b": [0.3499, 0.1362, 0.3631, 0.1576]}, {"w": "sent", "b": [0.3681, 0.1362, 0.4019, 0.1576]}, {"w": "through", "b": [0.4068, 0.1362, 0.4746, 0.1576]}, {"w": "the", "b": [0.4795, 0.1362, 0.5059, 0.1576]}, {"w": "logistic", "b": [0.5108, 0.1362, 0.5704, 0.1576]}, {"w": "activation", "b": [0.5753, 0.1362, 0.6576, 0.1576]}, {"w": "function,", "b": [0.6625, 0.1362, 0.7386, 0.1576]}, {"w": "and", "b": [0.7436, 0.1362, 0.7751, 0.1576]}, {"w": "this", "b": [0.78, 0.1362, 0.8107, 0.1576]}, {"w": "gives", "b": [0.8157, 0.1362, 0.8571, 0.1576]}, {"w": "the", "b": [0.1429, 0.1553, 0.1692, 0.1767]}, {"w": "objectness", "b": [0.1748, 0.1553, 0.2609, 0.1767]}, {"w": "score;", "b": [0.2666, 0.1553, 0.315, 0.1767]}, {"w": "outputs", "b": [0.3206, 0.1553, 0.3846, 0.1767]}, {"w": "6", "b": [0.3903, 0.1553, 0.4003, 0.1767]}, {"w": "to", "b": [0.4059, 0.1553, 0.4229, 0.1767]}, {"w": "9", "b": [0.4285, 0.1553, 0.4385, 0.1767]}, {"w": "do", "b": [0.4442, 0.1553, 0.4658, 0.1767]}, {"w": "not", "b": [0.4714, 0.1553, 0.4998, 0.1767]}, {"w": "use", "b": [0.5054, 0.1553, 0.533, 0.1767]}, {"w": "any", "b": [0.5386, 0.1553, 0.5682, 0.1767]}, {"w": "activation", "b": [0.5739, 0.1553, 0.6561, 0.1767]}, {"w": "function,", "b": [0.6618, 0.1553, 0.7379, 0.1767]}, {"w": "and", "b": [0.7435, 0.1553, 0.7751, 0.1767]}, {"w": "they", "b": [0.7807, 0.1553, 0.8166, 0.1767]}, {"w": "rep‐", "b": [0.8222, 0.1553, 0.8572, 0.1767]}, {"w": "resent", "b": [0.1429, 0.1743, 0.1933, 0.1957]}, {"w": "the", "b": [0.1995, 0.1743, 0.2258, 0.1957]}, {"w": "bounding", "b": [0.232, 0.1743, 0.3134, 0.1957]}, {"w": "box’s", "b": [0.3195, 0.1743, 0.3609, 0.1957]}, {"w": "center", "b": [0.3671, 0.1743, 0.4187, 0.1957]}, {"w": "coordinates,", "b": [0.4248, 0.1743, 0.5269, 0.1957]}, {"w": "and", "b": [0.5331, 0.1743, 0.5647, 0.1957]}, {"w": "its", "b": [0.5708, 0.1743, 0.5904, 0.1957]}, {"w": "height", "b": [0.5966, 0.1743, 0.649, 0.1957]}, {"w": "and", "b": [0.6551, 0.1743, 0.6867, 0.1957]}, {"w": "width.", "b": [0.6929, 0.1743, 0.7459, 0.1957]}, {"w": "We", "b": [0.7521, 0.1743, 0.7792, 0.1957]}, {"w": "can", "b": [0.7853, 0.1743, 0.8147, 0.1957]}, {"w": "now", "b": [0.8209, 0.1743, 0.8571, 0.1957]}, {"w": "convert", "b": [0.1429, 0.1933, 0.2058, 0.2148]}, {"w": "its", "b": [0.2115, 0.1933, 0.2311, 0.2148]}, {"w": "dense", "b": [0.2368, 0.1933, 0.2846, 0.2148]}, {"w": "layers", "b": [0.2903, 0.1933, 0.3381, 0.2148]}, {"w": "to", "b": [0.3439, 0.1933, 0.3609, 0.2148]}, {"w": "convolutional", "b": [0.3666, 0.1933, 0.4819, 0.2148]}, {"w": "layers.", "b": [0.4876, 0.1933, 0.5402, 0.2148]}, {"w": "In", "b": [0.546, 0.1933, 0.5645, 0.2148]}, {"w": "fact,", "b": [0.5702, 0.1933, 0.6054, 0.2148]}, {"w": "we", "b": [0.6111, 0.1933, 0.6343, 0.2148]}, {"w": "don’t", "b": [0.64, 0.1933, 0.6816, 0.2148]}, {"w": "even", "b": [0.6873, 0.1933, 0.7261, 0.2148]}, {"w": "need", "b": [0.7318, 0.1933, 0.7719, 0.2148]}, {"w": "to", "b": [0.7776, 0.1933, 0.7946, 0.2148]}, {"w": "retrain", "b": [0.8003, 0.1933, 0.8571, 0.2148]}, {"w": "it,", "b": [0.1428, 0.2124, 0.1595, 0.2338]}, {"w": "we", "b": [0.1674, 0.2124, 0.1905, 0.2338]}, {"w": "can", "b": [0.1983, 0.2124, 0.2277, 0.2338]}, {"w": "just", "b": [0.2355, 0.2124, 0.2659, 0.2338]}, {"w": "copy", "b": [0.2737, 0.2124, 0.3136, 0.2338]}, {"w": "the", "b": [0.3215, 0.2124, 0.3478, 0.2338]}, {"w": "weights", "b": [0.3556, 0.2124, 0.4188, 0.2338]}, {"w": "from", "b": [0.4266, 0.2124, 0.4682, 0.2338]}, {"w": "the", "b": [0.476, 0.2124, 0.5024, 0.2338]}, {"w": "dense", "b": [0.5102, 0.2124, 0.5579, 0.2338]}, {"w": "layers", "b": [0.5658, 0.2124, 0.6136, 0.2338]}, {"w": "to", "b": [0.6214, 0.2124, 0.6384, 0.2338]}, {"w": "the", "b": [0.6462, 0.2124, 0.6726, 0.2338]}, {"w": "convolutional", "b": [0.6804, 0.2124, 0.7957, 0.2338]}, {"w": "layers!", "b": [0.8036, 0.2124, 0.8571, 0.2338]}, {"w": "Alternatively,", "b": [0.1429, 0.2314, 0.2541, 0.2529]}, {"w": "we", "b": [0.2588, 0.2314, 0.282, 0.2529]}, {"w": "could", "b": [0.2867, 0.2314, 0.3335, 0.2529]}, {"w": "have", "b": [0.3382, 0.2314, 0.3766, 0.2529]}, {"w": "converted", "b": [0.3813, 0.2314, 0.4641, 0.2529]}, {"w": "the", "b": [0.4688, 0.2314, 0.4952, 0.2529]}, {"w": "CNN", "b": [0.4999, 0.2314, 0.5447, 0.2529]}, {"w": "into", "b": [0.5494, 0.2314, 0.583, 0.2529]}, {"w": "an", "b": [0.5877, 0.2314, 0.6083, 0.2529]}, {"w": "FCN", "b": [0.613, 0.2314, 0.6534, 0.2529]}, {"w": "before", "b": [0.6581, 0.2314, 0.7109, 0.2529]}, {"w": "training.", "b": [0.7156, 0.2314, 0.7873, 0.2529]}]}, {"id": "b_2", "type": "paragraph", "text": "Now suppose the last convolutional layer before the output layer (also called the bot‐ tleneck layer) outputs 7 × 7 feature maps when the network is fed a 224 × 224 image (see the left side of Figure 14-25). If we feed the FCN a 448 × 448 image (see the right side of Figure 14-25), the bottleneck layer will now output 14 × 14 feature maps.25", "words": [{"w": "Now", "b": [0.1429, 0.2596, 0.1827, 0.281]}, {"w": "suppose", "b": [0.1882, 0.2596, 0.2559, 0.281]}, {"w": "the", "b": [0.2613, 0.2596, 0.2877, 0.281]}, {"w": "last", "b": [0.2932, 0.2596, 0.3216, 0.281]}, {"w": "convolutional", "b": [0.327, 0.2596, 0.4424, 0.281]}, {"w": "layer", "b": [0.4479, 0.2596, 0.488, 0.281]}, {"w": "before", "b": [0.4935, 0.2596, 0.5463, 0.281]}, {"w": "the", "b": [0.5518, 0.2596, 0.5782, 0.281]}, {"w": "output", "b": [0.5836, 0.2596, 0.64, 0.281]}, {"w": "layer", "b": [0.6455, 0.2596, 0.6857, 0.281]}, {"w": "(also", "b": [0.6912, 0.2596, 0.731, 0.281]}, {"w": "called", "b": [0.7365, 0.2596, 0.7849, 0.281]}, {"w": "the", "b": [0.7904, 0.2596, 0.8167, 0.281]}, {"w": "bot‐", "b": [0.8222, 0.2596, 0.8571, 0.281]}, {"w": "tleneck", "b": [0.1429, 0.2786, 0.2027, 0.3]}, {"w": "layer)", "b": [0.2084, 0.2786, 0.2558, 0.3]}, {"w": "outputs", "b": [0.2615, 0.2786, 0.3255, 0.3]}, {"w": "7", "b": [0.3312, 0.2786, 0.3412, 0.3]}, {"w": "×", "b": [0.3468, 0.2786, 0.3589, 0.3]}, {"w": "7", "b": [0.3646, 0.2786, 0.3746, 0.3]}, {"w": "feature", "b": [0.3802, 0.2786, 0.438, 0.3]}, {"w": "maps", "b": [0.4437, 0.2786, 0.4881, 0.3]}, {"w": "when", "b": [0.4937, 0.2786, 0.5394, 0.3]}, {"w": "the", "b": [0.545, 0.2786, 0.5714, 0.3]}, {"w": "network", "b": [0.577, 0.2786, 0.6466, 0.3]}, {"w": "is", "b": [0.6523, 0.2786, 0.6655, 0.3]}, {"w": "fed", "b": [0.6712, 0.2786, 0.6972, 0.3]}, {"w": "a", "b": [0.7028, 0.2786, 0.712, 0.3]}, {"w": "224", "b": [0.7177, 0.2786, 0.7477, 0.3]}, {"w": "×", "b": [0.7533, 0.2786, 0.7654, 0.3]}, {"w": "224", "b": [0.7711, 0.2786, 0.8011, 0.3]}, {"w": "image", "b": [0.8067, 0.2786, 0.8571, 0.3]}, {"w": "(see", "b": [0.1429, 0.2977, 0.1754, 0.3191]}, {"w": "the", "b": [0.1805, 0.2977, 0.2068, 0.3191]}, {"w": "left", "b": [0.2119, 0.2977, 0.2386, 0.3191]}, {"w": "side", "b": [0.2437, 0.2977, 0.2768, 0.3191]}, {"w": "of", "b": [0.2819, 0.2977, 0.2987, 0.3191]}, {"w": "Figure", "b": [0.3038, 0.2977, 0.3578, 0.3191]}, {"w": "14-25).", "b": [0.3625, 0.2977, 0.4222, 0.3191]}, {"w": "If", "b": [0.4273, 0.2977, 0.4406, 0.3191]}, {"w": "we", "b": [0.4457, 0.2977, 0.4688, 0.3191]}, {"w": "feed", "b": [0.4739, 0.2977, 0.5088, 0.3191]}, {"w": "the", "b": [0.5139, 0.2977, 0.5402, 0.3191]}, {"w": "FCN", "b": [0.5453, 0.2977, 0.5857, 0.3191]}, {"w": "a", "b": [0.5908, 0.2977, 0.5999, 0.3191]}, {"w": "448", "b": [0.605, 0.2977, 0.635, 0.3191]}, {"w": "×", "b": [0.6401, 0.2977, 0.6522, 0.3191]}, {"w": "448", "b": [0.6573, 0.2977, 0.6873, 0.3191]}, {"w": "image", "b": [0.6924, 0.2977, 0.7428, 0.3191]}, {"w": "(see", "b": [0.7479, 0.2977, 0.7805, 0.3191]}, {"w": "the", "b": [0.7856, 0.2977, 0.8119, 0.3191]}, {"w": "right", "b": [0.817, 0.2977, 0.8571, 0.3191]}, {"w": "side", "b": [0.1429, 0.3167, 0.1759, 0.3381]}, {"w": "of", "b": [0.1833, 0.3167, 0.2001, 0.3381]}, {"w": "Figure", "b": [0.2075, 0.3167, 0.2615, 0.3381]}, {"w": "14-25),", "b": [0.2689, 0.3167, 0.3283, 0.3381]}, {"w": "the", "b": [0.3357, 0.3167, 0.362, 0.3381]}, {"w": "bottleneck", "b": [0.3694, 0.3167, 0.4569, 0.3381]}, {"w": "layer", "b": [0.4643, 0.3167, 0.5045, 0.3381]}, {"w": "will", "b": [0.5119, 0.3167, 0.5423, 0.3381]}, {"w": "now", "b": [0.5497, 0.3167, 0.586, 0.3381]}, {"w": "output", "b": [0.5934, 0.3167, 0.6497, 0.3381]}, {"w": "14", "b": [0.6571, 0.3167, 0.6771, 0.3381]}, {"w": "×", "b": [0.6845, 0.3167, 0.6966, 0.3381]}, {"w": "14", "b": [0.704, 0.3167, 0.724, 0.3381]}, {"w": "feature", "b": [0.7314, 0.3167, 0.7892, 0.3381]}, {"w": "maps.25", "b": [0.7966, 0.3167, 0.8571, 0.3381]}]}, {"id": "b_3", "type": "paragraph", "text": "Since the dense output layer was replaced by a convolutional layer using 10 filters of size 7 × 7, VALID padding and stride 1, the output will be composed of 10 features maps, each of size 8 × 8 (since 14 - 7 + 1 = 8). In other words, the FCN will process the whole image only once and it will output an 8 × 8 grid where each cell contains 10 numbers (5 class probabilities, 1 objectness score and 4 bounding box coordinates). It’s exactly like taking the original CNN and sliding it across the image using 8 steps per row and 8 steps per column: to visualize this, imagine chopping the original image into a 14 × 14 grid, then sliding a 7 × 7 window across this grid: there will be 8 × 8 = 64 possible locations for the window, hence 8 × 8 predictions. However, the FCN approach is much more efficient, since the network only looks at the image once. In fact, You Only Look Once (YOLO) is the name of a very popular object detec‐ tion architecture!", "words": [{"w": "Since", "b": [0.1429, 0.3358, 0.1874, 0.3572]}, {"w": "the", "b": [0.1933, 0.3358, 0.2196, 0.3572]}, {"w": "dense", "b": [0.2256, 0.3358, 0.2733, 0.3572]}, {"w": "output", "b": [0.2792, 0.3358, 0.3356, 0.3572]}, {"w": "layer", "b": [0.3415, 0.3358, 0.3817, 0.3572]}, {"w": "was", "b": [0.3876, 0.3358, 0.4187, 0.3572]}, {"w": "replaced", "b": [0.4246, 0.3358, 0.4952, 0.3572]}, {"w": "by", "b": [0.5011, 0.3358, 0.5212, 0.3572]}, {"w": "a", "b": [0.5272, 0.3358, 0.5363, 0.3572]}, {"w": "convolutional", "b": [0.5422, 0.3358, 0.6576, 0.3572]}, {"w": "layer", "b": [0.6635, 0.3358, 0.7037, 0.3572]}, {"w": "using", "b": [0.7096, 0.3358, 0.755, 0.3572]}, {"w": "10", "b": [0.7609, 0.3358, 0.7809, 0.3572]}, {"w": "filters", "b": [0.7868, 0.3358, 0.8344, 0.3572]}, {"w": "of", "b": [0.8404, 0.3358, 0.8572, 0.3572]}, {"w": "size", "b": [0.1429, 0.3548, 0.1737, 0.3762]}, {"w": "7", "b": [0.1802, 0.3548, 0.1902, 0.3762]}, {"w": "×", "b": [0.1967, 0.3548, 0.2088, 0.3762]}, {"w": "7,", "b": [0.2153, 0.3548, 0.2301, 0.3762]}, {"w": "VALID", "b": [0.2366, 0.3548, 0.2967, 0.3762]}, {"w": "padding", "b": [0.3032, 0.3548, 0.372, 0.3762]}, {"w": "and", "b": [0.3786, 0.3548, 0.4101, 0.3762]}, {"w": "stride", "b": [0.4166, 0.3548, 0.4638, 0.3762]}, {"w": "1,", "b": [0.4703, 0.3548, 0.4851, 0.3762]}, {"w": "the", "b": [0.4916, 0.3548, 0.5179, 0.3762]}, {"w": "output", "b": [0.5244, 0.3548, 0.5808, 0.3762]}, {"w": "will", "b": [0.5873, 0.3548, 0.6177, 0.3762]}, {"w": "be", "b": [0.6243, 0.3548, 0.6437, 0.3762]}, {"w": "composed", "b": [0.6502, 0.3548, 0.7354, 0.3762]}, {"w": "of", "b": [0.7419, 0.3548, 0.7587, 0.3762]}, {"w": "10", "b": [0.7652, 0.3548, 0.7852, 0.3762]}, {"w": "features", "b": [0.7917, 0.3548, 0.8571, 0.3762]}, {"w": "maps,", "b": [0.1429, 0.3738, 0.192, 0.3953]}, {"w": "each", "b": [0.198, 0.3738, 0.2359, 0.3953]}, {"w": "of", "b": [0.2419, 0.3738, 0.2587, 0.3953]}, {"w": "size", "b": [0.2647, 0.3738, 0.2955, 0.3953]}, {"w": "8", "b": [0.3015, 0.3738, 0.3115, 0.3953]}, {"w": "×", "b": [0.3175, 0.3738, 0.3296, 0.3953]}, {"w": "8", "b": [0.3356, 0.3738, 0.3456, 0.3953]}, {"w": "(since", "b": [0.3516, 0.3738, 0.4011, 0.3953]}, {"w": "14", "b": [0.4071, 0.3738, 0.4271, 0.3953]}, {"w": "-", "b": [0.4331, 0.3738, 0.4405, 0.3953]}, {"w": "7", "b": [0.4465, 0.3738, 0.4565, 0.3953]}, {"w": "+", "b": [0.4625, 0.3738, 0.4746, 0.3953]}, {"w": "1", "b": [0.4806, 0.3738, 0.4906, 0.3953]}, {"w": "=", "b": [0.4966, 0.3738, 0.5087, 0.3953]}, {"w": "8).", "b": [0.5147, 0.3738, 0.5366, 0.3953]}, {"w": "In", "b": [0.5426, 0.3738, 0.5611, 0.3953]}, {"w": "other", "b": [0.5671, 0.3738, 0.6118, 0.3953]}, {"w": "words,", "b": [0.6178, 0.3738, 0.6738, 0.3953]}, {"w": "the", "b": [0.6798, 0.3738, 0.7062, 0.3953]}, {"w": "FCN", "b": [0.7122, 0.3738, 0.7525, 0.3953]}, {"w": "will", "b": [0.7585, 0.3738, 0.7889, 0.3953]}, {"w": "process", "b": [0.7949, 0.3738, 0.8571, 0.3953]}, {"w": "the", "b": [0.1428, 0.3929, 0.1692, 0.4143]}, {"w": "whole", "b": [0.174, 0.3929, 0.2241, 0.4143]}, {"w": "image", "b": [0.2289, 0.3929, 0.2793, 0.4143]}, {"w": "only", "b": [0.2841, 0.3929, 0.321, 0.4143]}, {"w": "once", "b": [0.3258, 0.3929, 0.3655, 0.4143]}, {"w": "and", "b": [0.3703, 0.3929, 0.4018, 0.4143]}, {"w": "it", "b": [0.4066, 0.3929, 0.4185, 0.4143]}, {"w": "will", "b": [0.4233, 0.3929, 0.4537, 0.4143]}, {"w": "output", "b": [0.4585, 0.3929, 0.5149, 0.4143]}, {"w": "an", "b": [0.5197, 0.3929, 0.5403, 0.4143]}, {"w": "8", "b": [0.5451, 0.3929, 0.5551, 0.4143]}, {"w": "×", "b": [0.5599, 0.3929, 0.5719, 0.4143]}, {"w": "8", "b": [0.5767, 0.3929, 0.5867, 0.4143]}, {"w": "grid", "b": [0.5915, 0.3929, 0.6256, 0.4143]}, {"w": "where", "b": [0.6304, 0.3929, 0.6812, 0.4143]}, {"w": "each", "b": [0.686, 0.3929, 0.724, 0.4143]}, {"w": "cell", "b": [0.7288, 0.3929, 0.757, 0.4143]}, {"w": "contains", "b": [0.7618, 0.3929, 0.8323, 0.4143]}, {"w": "10", "b": [0.8371, 0.3929, 0.8571, 0.4143]}, {"w": "numbers", "b": [0.1429, 0.4119, 0.2168, 0.4334]}, {"w": "(5", "b": [0.2234, 0.4119, 0.2406, 0.4334]}, {"w": "class", "b": [0.2472, 0.4119, 0.2857, 0.4334]}, {"w": "probabilities,", "b": [0.2923, 0.4119, 0.4015, 0.4334]}, {"w": "1", "b": [0.408, 0.4119, 0.418, 0.4334]}, {"w": "objectness", "b": [0.4246, 0.4119, 0.5107, 0.4334]}, {"w": "score", "b": [0.5173, 0.4119, 0.561, 0.4334]}, {"w": "and", "b": [0.5675, 0.4119, 0.5991, 0.4334]}, {"w": "4", "b": [0.6057, 0.4119, 0.6157, 0.4334]}, {"w": "bounding", "b": [0.6222, 0.4119, 0.7036, 0.4334]}, {"w": "box", "b": [0.7102, 0.4119, 0.7412, 0.4334]}, {"w": "coordinates).", "b": [0.7478, 0.4119, 0.8572, 0.4334]}, {"w": "It’s", "b": [0.1429, 0.431, 0.1653, 0.4524]}, {"w": "exactly", "b": [0.1713, 0.431, 0.2291, 0.4524]}, {"w": "like", "b": [0.2351, 0.431, 0.2652, 0.4524]}, {"w": "taking", "b": [0.2712, 0.431, 0.3238, 0.4524]}, {"w": "the", "b": [0.3298, 0.431, 0.3561, 0.4524]}, {"w": "original", "b": [0.3621, 0.431, 0.4272, 0.4524]}, {"w": "CNN", "b": [0.4332, 0.431, 0.4781, 0.4524]}, {"w": "and", "b": [0.4841, 0.431, 0.5156, 0.4524]}, {"w": "sliding", "b": [0.5216, 0.431, 0.5779, 0.4524]}, {"w": "it", "b": [0.5839, 0.431, 0.5958, 0.4524]}, {"w": "across", "b": [0.6018, 0.431, 0.6535, 0.4524]}, {"w": "the", "b": [0.6595, 0.431, 0.6858, 0.4524]}, {"w": "image", "b": [0.6918, 0.431, 0.7422, 0.4524]}, {"w": "using", "b": [0.7482, 0.431, 0.7937, 0.4524]}, {"w": "8", "b": [0.7997, 0.431, 0.8097, 0.4524]}, {"w": "steps", "b": [0.8157, 0.431, 0.8571, 0.4524]}, {"w": "per", "b": [0.1429, 0.45, 0.1704, 0.4714]}, {"w": "row", "b": [0.179, 0.45, 0.2117, 0.4714]}, {"w": "and", "b": [0.2203, 0.45, 0.2519, 0.4714]}, {"w": "8", "b": [0.2606, 0.45, 0.2706, 0.4714]}, {"w": "steps", "b": [0.2792, 0.45, 0.3207, 0.4714]}, {"w": "per", "b": [0.3293, 0.45, 0.3568, 0.4714]}, {"w": "column:", "b": [0.3655, 0.45, 0.4345, 0.4714]}, {"w": "to", "b": [0.4432, 0.45, 0.4601, 0.4714]}, {"w": "visualize", "b": [0.4688, 0.45, 0.5404, 0.4714]}, {"w": "this,", "b": [0.549, 0.45, 0.5845, 0.4714]}, {"w": "imagine", "b": [0.5932, 0.45, 0.6606, 0.4714]}, {"w": "chopping", "b": [0.6692, 0.45, 0.7484, 0.4714]}, {"w": "the", "b": [0.757, 0.45, 0.7834, 0.4714]}, {"w": "original", "b": [0.7921, 0.45, 0.8571, 0.4714]}, {"w": "image", "b": [0.1429, 0.4691, 0.1933, 0.4905]}, {"w": "into", "b": [0.1985, 0.4691, 0.232, 0.4905]}, {"w": "a", "b": [0.2372, 0.4691, 0.2464, 0.4905]}, {"w": "14", "b": [0.2516, 0.4691, 0.2716, 0.4905]}, {"w": "×", "b": [0.2768, 0.4691, 0.2889, 0.4905]}, {"w": "14", "b": [0.2941, 0.4691, 0.3141, 0.4905]}, {"w": "grid,", "b": [0.3193, 0.4691, 0.3581, 0.4905]}, {"w": "then", "b": [0.3633, 0.4691, 0.401, 0.4905]}, {"w": "sliding", "b": [0.4062, 0.4691, 0.4625, 0.4905]}, {"w": "a", "b": [0.4677, 0.4691, 0.4768, 0.4905]}, {"w": "7", "b": [0.482, 0.4691, 0.492, 0.4905]}, {"w": "×", "b": [0.4972, 0.4691, 0.5093, 0.4905]}, {"w": "7", "b": [0.5145, 0.4691, 0.5245, 0.4905]}, {"w": "window", "b": [0.5297, 0.4691, 0.5969, 0.4905]}, {"w": "across", "b": [0.6021, 0.4691, 0.6537, 0.4905]}, {"w": "this", "b": [0.6589, 0.4691, 0.6896, 0.4905]}, {"w": "grid:", "b": [0.6948, 0.4691, 0.7336, 0.4905]}, {"w": "there", "b": [0.7388, 0.4691, 0.7817, 0.4905]}, {"w": "will", "b": [0.7869, 0.4691, 0.8173, 0.4905]}, {"w": "be", "b": [0.8225, 0.4691, 0.8419, 0.4905]}, {"w": "8", "b": [0.8472, 0.4691, 0.8572, 0.4905]}, {"w": "×", "b": [0.1429, 0.4881, 0.1549, 0.5095]}, {"w": "8", "b": [0.1624, 0.4881, 0.1724, 0.5095]}, {"w": "=", "b": [0.1798, 0.4881, 0.1918, 0.5095]}, {"w": "64", "b": [0.1993, 0.4881, 0.2193, 0.5095]}, {"w": "possible", "b": [0.2267, 0.4881, 0.2938, 0.5095]}, {"w": "locations", "b": [0.3012, 0.4881, 0.3763, 0.5095]}, {"w": "for", "b": [0.3837, 0.4881, 0.4082, 0.5095]}, {"w": "the", "b": [0.4156, 0.4881, 0.4419, 0.5095]}, {"w": "window,", "b": [0.4493, 0.4881, 0.5197, 0.5095]}, {"w": "hence", "b": [0.5271, 0.4881, 0.5762, 0.5095]}, {"w": "8", "b": [0.5836, 0.4881, 0.5936, 0.5095]}, {"w": "×", "b": [0.601, 0.4881, 0.6131, 0.5095]}, {"w": "8", "b": [0.6205, 0.4881, 0.6305, 0.5095]}, {"w": "predictions.", "b": [0.6379, 0.4881, 0.7371, 0.5095]}, {"w": "However,", "b": [0.7446, 0.4881, 0.8234, 0.5095]}, {"w": "the", "b": [0.8308, 0.4881, 0.8571, 0.5095]}, {"w": "FCN", "b": [0.1429, 0.5072, 0.1832, 0.5286]}, {"w": "approach", "b": [0.1916, 0.5072, 0.2697, 0.5286]}, {"w": "is", "b": [0.2781, 0.5072, 0.2913, 0.5286]}, {"w": "much", "b": [0.2997, 0.507, 0.3451, 0.5286]}, {"w": "more", "b": [0.3536, 0.5072, 0.3978, 0.5286]}, {"w": "efficient,", "b": [0.4063, 0.5072, 0.4784, 0.5286]}, {"w": "since", "b": [0.4868, 0.5072, 0.5291, 0.5286]}, {"w": "the", "b": [0.5375, 0.5072, 0.5639, 0.5286]}, {"w": "network", "b": [0.5723, 0.5072, 0.6418, 0.5286]}, {"w": "only", "b": [0.6503, 0.5072, 0.6871, 0.5286]}, {"w": "looks", "b": [0.6955, 0.5072, 0.74, 0.5286]}, {"w": "at", "b": [0.7485, 0.5072, 0.7636, 0.5286]}, {"w": "the", "b": [0.772, 0.5072, 0.7983, 0.5286]}, {"w": "image", "b": [0.8067, 0.5072, 0.8571, 0.5286]}, {"w": "once.", "b": [0.1429, 0.5262, 0.1873, 0.5476]}, {"w": "In", "b": [0.192, 0.5262, 0.2105, 0.5476]}, {"w": "fact,", "b": [0.2152, 0.5262, 0.2505, 0.5476]}, {"w": "You", "b": [0.2556, 0.526, 0.2869, 0.5476]}, {"w": "Only", "b": [0.2916, 0.526, 0.3314, 0.5476]}, {"w": "Look", "b": [0.3362, 0.526, 0.3764, 0.5476]}, {"w": "Once", "b": [0.3812, 0.526, 0.4231, 0.5476]}, {"w": "(YOLO)", "b": [0.4284, 0.5262, 0.4975, 0.5476]}, {"w": "is", "b": [0.5023, 0.5262, 0.5156, 0.5476]}, {"w": "the", "b": [0.5204, 0.5262, 0.5468, 0.5476]}, {"w": "name", "b": [0.5516, 0.5262, 0.5981, 0.5476]}, {"w": "of", "b": [0.6029, 0.5262, 0.6197, 0.5476]}, {"w": "a", "b": [0.6246, 0.5262, 0.6338, 0.5476]}, {"w": "very", "b": [0.6386, 0.5262, 0.675, 0.5476]}, {"w": "popular", "b": [0.6799, 0.5262, 0.7456, 0.5476]}, {"w": "object", "b": [0.7504, 0.5262, 0.801, 0.5476]}, {"w": "detec‐", "b": [0.8059, 0.5262, 0.8571, 0.5476]}, {"w": "tion", "b": [0.1429, 0.5453, 0.1768, 0.5667]}, {"w": "architecture!", "b": [0.1815, 0.5453, 0.2877, 0.5667]}]}, {"id": "b_4", "type": "paragraph", "text": "474 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "474", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 501, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "26 “You Only Look Once: Unified, Real-Time Object Detection,” J. Redmon, S. Divvala, R. Girshick, A. Farhadi (2015).", "words": [{"w": "26", "b": [0.1385, 0.822, 0.1518, 0.8363]}, {"w": "“You", "b": [0.1587, 0.8205, 0.1897, 0.8368]}, {"w": "Only", "b": [0.1933, 0.8205, 0.2251, 0.8368]}, {"w": "Look", "b": [0.2287, 0.8205, 0.2613, 0.8368]}, {"w": "Once:", "b": [0.265, 0.8205, 0.3026, 0.8368]}, {"w": "Unified,", "b": [0.3062, 0.8205, 0.3578, 0.8368]}, {"w": "Real-Time", "b": [0.3614, 0.8205, 0.4278, 0.8368]}, {"w": "Object", "b": [0.4314, 0.8205, 0.4737, 0.8368]}, {"w": "Detection,”", "b": [0.4773, 0.8205, 0.5477, 0.8368]}, {"w": "J.", "b": [0.5513, 0.8205, 0.5594, 0.8368]}, {"w": "Redmon,", "b": [0.563, 0.8205, 0.6214, 0.8368]}, {"w": "S.", "b": [0.625, 0.8205, 0.6362, 0.8368]}, {"w": "Divvala,", "b": [0.6398, 0.8205, 0.692, 0.8368]}, {"w": "R.", "b": [0.6956, 0.8205, 0.709, 0.8368]}, {"w": "Girshick,", "b": [0.7126, 0.8205, 0.7709, 0.8368]}, {"w": "A.", "b": [0.7745, 0.8205, 0.7891, 0.8368]}, {"w": "Farhadi", "b": [0.7927, 0.8205, 0.8417, 0.8368]}, {"w": "(2015).", "b": [0.1587, 0.8356, 0.2038, 0.8519]}]}, {"id": "b_1", "type": "paragraph", "text": "27 “YOLO9000: Better, Faster, Stronger,” J. Redmon, A. Farhadi (2016).", "words": [{"w": "27", "b": [0.1384, 0.8568, 0.1518, 0.871]}, {"w": "“YOLO9000:", "b": [0.1587, 0.8553, 0.2408, 0.8716]}, {"w": "Better,", "b": [0.2444, 0.8553, 0.2857, 0.8716]}, {"w": "Faster,", "b": [0.2893, 0.8553, 0.3303, 0.8716]}, {"w": "Stronger,”", "b": [0.3339, 0.8553, 0.3958, 0.8716]}, {"w": "J.", "b": [0.3994, 0.8553, 0.4075, 0.8716]}, {"w": "Redmon,", "b": [0.4111, 0.8553, 0.4695, 0.8716]}, {"w": "A.", "b": [0.4731, 0.8553, 0.4877, 0.8716]}, {"w": "Farhadi", "b": [0.4913, 0.8553, 0.5403, 0.8716]}, {"w": "(2016).", "b": [0.5439, 0.8553, 0.589, 0.8716]}]}, {"id": "b_2", "type": "paragraph", "text": "28 “YOLOv3: An Incremental Improvement,” J. Redmon, A. Farhadi (2018).", "words": [{"w": "28", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“YOLOv3:", "b": [0.1587, 0.8749, 0.2255, 0.8912]}, {"w": "An", "b": [0.2291, 0.8749, 0.2488, 0.8912]}, {"w": "Incremental", "b": [0.2524, 0.8749, 0.3298, 0.8912]}, {"w": "Improvement,”", "b": [0.3334, 0.8749, 0.4287, 0.8912]}, {"w": "J.", "b": [0.4323, 0.8749, 0.4404, 0.8912]}, {"w": "Redmon,", "b": [0.444, 0.8749, 0.5024, 0.8912]}, {"w": "A.", "b": [0.506, 0.8749, 0.5206, 0.8912]}, {"w": "Farhadi", "b": [0.5242, 0.8749, 0.5732, 0.8912]}, {"w": "(2018).", "b": [0.5768, 0.8749, 0.6219, 0.8912]}]}, {"id": "b_3", "type": "paragraph", "text": "Figure 14-25. A Fully Convolutional Network Processing a Small Image (left) and a Large One (right)", "words": [{"w": "Figure", "b": [0.1429, 0.5272, 0.1943, 0.5488]}, {"w": "14-25.", "b": [0.1991, 0.5272, 0.2507, 0.5488]}, {"w": "A", "b": [0.2554, 0.5272, 0.2693, 0.5488]}, {"w": "Fully", "b": [0.2741, 0.5272, 0.3147, 0.5488]}, {"w": "Convolutional", "b": [0.3195, 0.5272, 0.4349, 0.5488]}, {"w": "Network", "b": [0.4397, 0.5272, 0.5091, 0.5488]}, {"w": "Processing", "b": [0.5139, 0.5272, 0.5969, 0.5488]}, {"w": "a", "b": [0.6016, 0.5272, 0.6118, 0.5488]}, {"w": "Small", "b": [0.6166, 0.5272, 0.6626, 0.5488]}, {"w": "Image", "b": [0.6674, 0.5272, 0.7167, 0.5488]}, {"w": "(left)", "b": [0.7215, 0.5272, 0.7608, 0.5488]}, {"w": "and", "b": [0.7656, 0.5272, 0.797, 0.5488]}, {"w": "a", "b": [0.8018, 0.5272, 0.812, 0.5488]}, {"w": "Large", "b": [0.1429, 0.5462, 0.1884, 0.5678]}, {"w": "One", "b": [0.1932, 0.5462, 0.2273, 0.5678]}, {"w": "(right)", "b": [0.2321, 0.5462, 0.2847, 0.5678]}]}, {"id": "b_4", "type": "paragraph", "text": "You Only Look Once (YOLO)", "words": [{"w": "You", "b": [0.1429, 0.5809, 0.1815, 0.6094]}, {"w": "Only", "b": [0.1865, 0.5809, 0.2328, 0.6094]}, {"w": "Look", "b": [0.2377, 0.5809, 0.2868, 0.6094]}, {"w": "Once", "b": [0.2918, 0.5809, 0.342, 0.6094]}, {"w": "(YOLO)", "b": [0.347, 0.5809, 0.4159, 0.6094]}]}, {"id": "b_5", "type": "paragraph", "text": "YOLO is an extremely fast and accurate object detection architecture proposed by Joseph Redmon et al. in a 2015 paper26, and subsequently improved in 201627", "words": [{"w": "YOLO", "b": [0.1429, 0.6153, 0.1975, 0.6368]}, {"w": "is", "b": [0.2053, 0.6153, 0.2185, 0.6368]}, {"w": "an", "b": [0.2263, 0.6153, 0.2469, 0.6368]}, {"w": "extremely", "b": [0.2547, 0.6153, 0.3371, 0.6368]}, {"w": "fast", "b": [0.3449, 0.6153, 0.3742, 0.6368]}, {"w": "and", "b": [0.382, 0.6153, 0.4135, 0.6368]}, {"w": "accurate", "b": [0.4213, 0.6153, 0.4908, 0.6368]}, {"w": "object", "b": [0.4987, 0.6153, 0.5492, 0.6368]}, {"w": "detection", "b": [0.557, 0.6153, 0.6349, 0.6368]}, {"w": "architecture", "b": [0.6427, 0.6153, 0.7431, 0.6368]}, {"w": "proposed", "b": [0.7509, 0.6153, 0.8292, 0.6368]}, {"w": "by", "b": [0.837, 0.6153, 0.8571, 0.6368]}, {"w": "Joseph", "b": [0.1429, 0.6344, 0.1984, 0.6558]}, {"w": "Redmon", "b": [0.2096, 0.6344, 0.2814, 0.6558]}, {"w": "et", "b": [0.2926, 0.6344, 0.3078, 0.6558]}, {"w": "al.", "b": [0.3189, 0.6344, 0.3381, 0.6558]}, {"w": "in", "b": [0.3492, 0.6344, 0.3662, 0.6558]}, {"w": "a", "b": [0.3773, 0.6344, 0.3864, 0.6558]}, {"w": "2015", "b": [0.3975, 0.6344, 0.4375, 0.6558]}, {"w": "paper26,", "b": [0.4487, 0.6344, 0.512, 0.6558]}, {"w": "and", "b": [0.5231, 0.6344, 0.5547, 0.6558]}, {"w": "subsequently", "b": [0.5658, 0.6344, 0.6743, 0.6558]}, {"w": "improved", "b": [0.6855, 0.6344, 0.7665, 0.6558]}, {"w": "in", "b": [0.7776, 0.6344, 0.7946, 0.6558]}, {"w": "201627", "b": [0.8057, 0.6344, 0.8571, 0.6558]}]}, {"id": "b_6", "type": "paragraph", "text": "(YOLOv2) and in 201828 (YOLOv3). It is so fast that it can run in realtime on a video (check out this nice demo).", "words": [{"w": "(YOLOv2)", "b": [0.1428, 0.6534, 0.2319, 0.6748]}, {"w": "and", "b": [0.2373, 0.6534, 0.2688, 0.6748]}, {"w": "in", "b": [0.2742, 0.6534, 0.2911, 0.6748]}, {"w": "201828", "b": [0.2959, 0.6534, 0.348, 0.6748]}, {"w": "(YOLOv3).", "b": [0.3533, 0.6534, 0.4471, 0.6748]}, {"w": "It", "b": [0.4525, 0.6534, 0.4651, 0.6748]}, {"w": "is", "b": [0.4705, 0.6534, 0.4837, 0.6748]}, {"w": "so", "b": [0.4891, 0.6534, 0.5074, 0.6748]}, {"w": "fast", "b": [0.5127, 0.6534, 0.5421, 0.6748]}, {"w": "that", "b": [0.5474, 0.6534, 0.58, 0.6748]}, {"w": "it", "b": [0.5854, 0.6534, 0.5973, 0.6748]}, {"w": "can", "b": [0.6027, 0.6534, 0.632, 0.6748]}, {"w": "run", "b": [0.6374, 0.6534, 0.6676, 0.6748]}, {"w": "in", "b": [0.673, 0.6534, 0.6899, 0.6748]}, {"w": "realtime", "b": [0.6953, 0.6534, 0.7642, 0.6748]}, {"w": "on", "b": [0.7695, 0.6534, 0.7916, 0.6748]}, {"w": "a", "b": [0.7969, 0.6534, 0.8061, 0.6748]}, {"w": "video", "b": [0.8114, 0.6534, 0.8571, 0.6748]}, {"w": "(check", "b": [0.1429, 0.6725, 0.198, 0.6939]}, {"w": "out", "b": [0.2027, 0.6725, 0.2308, 0.6939]}, {"w": "this", "b": [0.2355, 0.6725, 0.2662, 0.6939]}, {"w": "nice", "b": [0.2709, 0.6725, 0.3056, 0.6939]}, {"w": "demo).", "b": [0.3103, 0.6725, 0.3698, 0.6939]}]}, {"id": "b_7", "type": "paragraph", "text": "YOLOv3’s architecture is quite similar to the one we just discussed, but with a few important differences:", "words": [{"w": "YOLOv3’s", "b": [0.1429, 0.7006, 0.2278, 0.722]}, {"w": "architecture", "b": [0.2349, 0.7006, 0.3353, 0.722]}, {"w": "is", "b": [0.3424, 0.7006, 0.3557, 0.722]}, {"w": "quite", "b": [0.3628, 0.7006, 0.4053, 0.722]}, {"w": "similar", "b": [0.4124, 0.7006, 0.4704, 0.722]}, {"w": "to", "b": [0.4776, 0.7006, 0.4945, 0.722]}, {"w": "the", "b": [0.5017, 0.7006, 0.528, 0.722]}, {"w": "one", "b": [0.5351, 0.7006, 0.566, 0.722]}, {"w": "we", "b": [0.5731, 0.7006, 0.5962, 0.722]}, {"w": "just", "b": [0.6034, 0.7006, 0.6338, 0.722]}, {"w": "discussed,", "b": [0.6409, 0.7006, 0.7249, 0.722]}, {"w": "but", "b": [0.732, 0.7006, 0.76, 0.722]}, {"w": "with", "b": [0.7671, 0.7006, 0.8045, 0.722]}, {"w": "a", "b": [0.8116, 0.7006, 0.8207, 0.722]}, {"w": "few", "b": [0.8278, 0.7006, 0.8571, 0.722]}, {"w": "important", "b": [0.1428, 0.7196, 0.2272, 0.7411]}, {"w": "differences:", "b": [0.2319, 0.7196, 0.3278, 0.7411]}]}, {"id": "b_8", "type": "paragraph", "text": "Object Detection | 475", "words": [{"w": "Object", "b": [0.6987, 0.9225, 0.736, 0.9388]}, {"w": "Detection", "b": [0.7388, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "475", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 502, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "• First, it outputs 5 bounding boxes for each grid cell (instead of just 1), and each bounding box comes with an objectness score. It also outputs 20 class probabili‐ ties per grid cell, as it was trained on the PASCAL VOC dataset, which contains 20 classes. That’s a total of 45 numbers per grid cell (5 * 4 bounding box coordi‐ nates, plus 5 objectness scores, plus 20 class probabilities).", "words": [{"w": "•", "b": [0.16, 0.0851, 0.1682, 0.1065]}, {"w": "First,", "b": [0.1786, 0.0851, 0.2216, 0.1065]}, {"w": "it", "b": [0.2277, 0.0851, 0.2396, 0.1065]}, {"w": "outputs", "b": [0.2456, 0.0851, 0.3096, 0.1065]}, {"w": "5", "b": [0.3156, 0.0851, 0.3256, 0.1065]}, {"w": "bounding", "b": [0.3316, 0.0851, 0.413, 0.1065]}, {"w": "boxes", "b": [0.419, 0.0851, 0.4666, 0.1065]}, {"w": "for", "b": [0.4726, 0.0851, 0.4971, 0.1065]}, {"w": "each", "b": [0.5031, 0.0851, 0.541, 0.1065]}, {"w": "grid", "b": [0.547, 0.0851, 0.5811, 0.1065]}, {"w": "cell", "b": [0.5871, 0.0851, 0.6153, 0.1065]}, {"w": "(instead", "b": [0.6213, 0.0851, 0.6885, 0.1065]}, {"w": "of", "b": [0.6945, 0.0851, 0.7113, 0.1065]}, {"w": "just", "b": [0.7173, 0.0851, 0.7477, 0.1065]}, {"w": "1),", "b": [0.7537, 0.0851, 0.7757, 0.1065]}, {"w": "and", "b": [0.7817, 0.0851, 0.8132, 0.1065]}, {"w": "each", "b": [0.8192, 0.0851, 0.8571, 0.1065]}, {"w": "bounding", "b": [0.1786, 0.1042, 0.26, 0.1256]}, {"w": "box", "b": [0.2658, 0.1042, 0.2968, 0.1256]}, {"w": "comes", "b": [0.3026, 0.1042, 0.3556, 0.1256]}, {"w": "with", "b": [0.3614, 0.1042, 0.3987, 0.1256]}, {"w": "an", "b": [0.4045, 0.1042, 0.425, 0.1256]}, {"w": "objectness", "b": [0.4308, 0.1042, 0.5169, 0.1256]}, {"w": "score.", "b": [0.5227, 0.1042, 0.5711, 0.1256]}, {"w": "It", "b": [0.5769, 0.1042, 0.5896, 0.1256]}, {"w": "also", "b": [0.5953, 0.1042, 0.628, 0.1256]}, {"w": "outputs", "b": [0.6338, 0.1042, 0.6978, 0.1256]}, {"w": "20", "b": [0.7036, 0.1042, 0.7236, 0.1256]}, {"w": "class", "b": [0.7294, 0.1042, 0.7679, 0.1256]}, {"w": "probabili‐", "b": [0.7737, 0.1042, 0.8571, 0.1256]}, {"w": "ties", "b": [0.1786, 0.1232, 0.207, 0.1446]}, {"w": "per", "b": [0.2131, 0.1232, 0.2406, 0.1446]}, {"w": "grid", "b": [0.2467, 0.1232, 0.2808, 0.1446]}, {"w": "cell,", "b": [0.2869, 0.1232, 0.3199, 0.1446]}, {"w": "as", "b": [0.326, 0.1232, 0.3428, 0.1446]}, {"w": "it", "b": [0.3489, 0.1232, 0.3609, 0.1446]}, {"w": "was", "b": [0.367, 0.1232, 0.398, 0.1446]}, {"w": "trained", "b": [0.4042, 0.1232, 0.4642, 0.1446]}, {"w": "on", "b": [0.4704, 0.1232, 0.4924, 0.1446]}, {"w": "the", "b": [0.4985, 0.1232, 0.5248, 0.1446]}, {"w": "PASCAL", "b": [0.531, 0.1232, 0.6046, 0.1446]}, {"w": "VOC", "b": [0.6108, 0.1232, 0.6544, 0.1446]}, {"w": "dataset,", "b": [0.6606, 0.1232, 0.7234, 0.1446]}, {"w": "which", "b": [0.7295, 0.1232, 0.7804, 0.1446]}, {"w": "contains", "b": [0.7866, 0.1232, 0.8571, 0.1446]}, {"w": "20", "b": [0.1786, 0.1423, 0.1986, 0.1637]}, {"w": "classes.", "b": [0.2044, 0.1423, 0.2641, 0.1637]}, {"w": "That’s", "b": [0.2699, 0.1423, 0.3188, 0.1637]}, {"w": "a", "b": [0.3246, 0.1423, 0.3337, 0.1637]}, {"w": "total", "b": [0.3395, 0.1423, 0.3773, 0.1637]}, {"w": "of", "b": [0.383, 0.1423, 0.3998, 0.1637]}, {"w": "45", "b": [0.4056, 0.1423, 0.4256, 0.1637]}, {"w": "numbers", "b": [0.4314, 0.1423, 0.5054, 0.1637]}, {"w": "per", "b": [0.5112, 0.1423, 0.5387, 0.1637]}, {"w": "grid", "b": [0.5445, 0.1423, 0.5785, 0.1637]}, {"w": "cell", "b": [0.5843, 0.1423, 0.6125, 0.1637]}, {"w": "(5", "b": [0.6183, 0.1423, 0.6355, 0.1637]}, {"w": "*", "b": [0.6413, 0.1423, 0.6497, 0.1637]}, {"w": "4", "b": [0.6555, 0.1423, 0.6655, 0.1637]}, {"w": "bounding", "b": [0.6713, 0.1423, 0.7527, 0.1637]}, {"w": "box", "b": [0.7585, 0.1423, 0.7896, 0.1637]}, {"w": "coordi‐", "b": [0.7954, 0.1423, 0.8571, 0.1637]}, {"w": "nates,", "b": [0.1786, 0.1613, 0.2263, 0.1827]}, {"w": "plus", "b": [0.2311, 0.1613, 0.266, 0.1827]}, {"w": "5", "b": [0.2707, 0.1613, 0.2807, 0.1827]}, {"w": "objectness", "b": [0.2854, 0.1613, 0.3715, 0.1827]}, {"w": "scores,", "b": [0.3762, 0.1613, 0.4323, 0.1827]}, {"w": "plus", "b": [0.437, 0.1613, 0.4719, 0.1827]}, {"w": "20", "b": [0.4767, 0.1613, 0.4967, 0.1827]}, {"w": "class", "b": [0.5014, 0.1613, 0.5399, 0.1827]}, {"w": "probabilities).", "b": [0.5446, 0.1613, 0.6611, 0.1827]}]}, {"id": "b_1", "type": "paragraph", "text": "• Second, instead of predicting the absolute coordinates of the bounding box cen‐ ters, YOLOv3 predicts an offset relative to the coordinates of the grid cell, where (0, 0) means the top left of that cell, and (1, 1) means the bottom right. For each grid cell, YOLOv3 is trained to predict only bounding boxes whose center lies in that cell (but the bounding box itself generally extends well beyond the grid cell). YOLOv3 applies the logistic activation function to the bounding box coordinates to ensure they remain in the 0 to 1 range.", "words": [{"w": "•", "b": [0.16, 0.1864, 0.1681, 0.2078]}, {"w": "Second,", "b": [0.1786, 0.1864, 0.2439, 0.2078]}, {"w": "instead", "b": [0.2498, 0.1864, 0.3098, 0.2078]}, {"w": "of", "b": [0.3157, 0.1864, 0.3325, 0.2078]}, {"w": "predicting", "b": [0.3384, 0.1864, 0.4244, 0.2078]}, {"w": "the", "b": [0.4303, 0.1864, 0.4567, 0.2078]}, {"w": "absolute", "b": [0.4626, 0.1864, 0.5321, 0.2078]}, {"w": "coordinates", "b": [0.5381, 0.1864, 0.6355, 0.2078]}, {"w": "of", "b": [0.6414, 0.1864, 0.6582, 0.2078]}, {"w": "the", "b": [0.6641, 0.1864, 0.6904, 0.2078]}, {"w": "bounding", "b": [0.6964, 0.1864, 0.7778, 0.2078]}, {"w": "box", "b": [0.7837, 0.1864, 0.8147, 0.2078]}, {"w": "cen‐", "b": [0.8207, 0.1864, 0.8571, 0.2078]}, {"w": "ters,", "b": [0.1786, 0.2054, 0.2139, 0.2269]}, {"w": "YOLOv3", "b": [0.2195, 0.2054, 0.2941, 0.2269]}, {"w": "predicts", "b": [0.2997, 0.2054, 0.3666, 0.2269]}, {"w": "an", "b": [0.3722, 0.2054, 0.3927, 0.2269]}, {"w": "offset", "b": [0.3983, 0.2054, 0.4441, 0.2269]}, {"w": "relative", "b": [0.4497, 0.2054, 0.5108, 0.2269]}, {"w": "to", "b": [0.5164, 0.2054, 0.5333, 0.2269]}, {"w": "the", "b": [0.5389, 0.2054, 0.5653, 0.2269]}, {"w": "coordinates", "b": [0.5708, 0.2054, 0.6682, 0.2269]}, {"w": "of", "b": [0.6738, 0.2054, 0.6906, 0.2269]}, {"w": "the", "b": [0.6962, 0.2054, 0.7225, 0.2269]}, {"w": "grid", "b": [0.7281, 0.2054, 0.7622, 0.2269]}, {"w": "cell,", "b": [0.7678, 0.2054, 0.8007, 0.2269]}, {"w": "where", "b": [0.8063, 0.2054, 0.8571, 0.2269]}, {"w": "(0,", "b": [0.1786, 0.2245, 0.2005, 0.2459]}, {"w": "0)", "b": [0.2063, 0.2245, 0.2235, 0.2459]}, {"w": "means", "b": [0.2292, 0.2245, 0.2833, 0.2459]}, {"w": "the", "b": [0.289, 0.2245, 0.3154, 0.2459]}, {"w": "top", "b": [0.3211, 0.2245, 0.349, 0.2459]}, {"w": "left", "b": [0.3547, 0.2245, 0.3814, 0.2459]}, {"w": "of", "b": [0.3871, 0.2245, 0.4039, 0.2459]}, {"w": "that", "b": [0.4097, 0.2245, 0.4422, 0.2459]}, {"w": "cell,", "b": [0.448, 0.2245, 0.4809, 0.2459]}, {"w": "and", "b": [0.4867, 0.2245, 0.5182, 0.2459]}, {"w": "(1,", "b": [0.524, 0.2245, 0.5459, 0.2459]}, {"w": "1)", "b": [0.5516, 0.2245, 0.5689, 0.2459]}, {"w": "means", "b": [0.5746, 0.2245, 0.6287, 0.2459]}, {"w": "the", "b": [0.6344, 0.2245, 0.6608, 0.2459]}, {"w": "bottom", "b": [0.6665, 0.2245, 0.7281, 0.2459]}, {"w": "right.", "b": [0.7338, 0.2245, 0.7787, 0.2459]}, {"w": "For", "b": [0.7845, 0.2245, 0.8135, 0.2459]}, {"w": "each", "b": [0.8192, 0.2245, 0.8571, 0.2459]}, {"w": "grid", "b": [0.1786, 0.2435, 0.2126, 0.2649]}, {"w": "cell,", "b": [0.2183, 0.2435, 0.2512, 0.2649]}, {"w": "YOLOv3", "b": [0.2568, 0.2435, 0.3315, 0.2649]}, {"w": "is", "b": [0.3371, 0.2435, 0.3503, 0.2649]}, {"w": "trained", "b": [0.356, 0.2435, 0.416, 0.2649]}, {"w": "to", "b": [0.4216, 0.2435, 0.4386, 0.2649]}, {"w": "predict", "b": [0.4443, 0.2435, 0.5035, 0.2649]}, {"w": "only", "b": [0.5091, 0.2435, 0.546, 0.2649]}, {"w": "bounding", "b": [0.5516, 0.2435, 0.633, 0.2649]}, {"w": "boxes", "b": [0.6386, 0.2435, 0.6862, 0.2649]}, {"w": "whose", "b": [0.6918, 0.2435, 0.7443, 0.2649]}, {"w": "center", "b": [0.75, 0.2435, 0.8016, 0.2649]}, {"w": "lies", "b": [0.8072, 0.2435, 0.8345, 0.2649]}, {"w": "in", "b": [0.8402, 0.2435, 0.8571, 0.2649]}, {"w": "that", "b": [0.1786, 0.2626, 0.2112, 0.284]}, {"w": "cell", "b": [0.2164, 0.2626, 0.2446, 0.284]}, {"w": "(but", "b": [0.2498, 0.2626, 0.285, 0.284]}, {"w": "the", "b": [0.2903, 0.2626, 0.3166, 0.284]}, {"w": "bounding", "b": [0.3218, 0.2626, 0.4032, 0.284]}, {"w": "box", "b": [0.4084, 0.2626, 0.4395, 0.284]}, {"w": "itself", "b": [0.4447, 0.2626, 0.4846, 0.284]}, {"w": "generally", "b": [0.4898, 0.2626, 0.5656, 0.284]}, {"w": "extends", "b": [0.5708, 0.2626, 0.6348, 0.284]}, {"w": "well", "b": [0.64, 0.2626, 0.6737, 0.284]}, {"w": "beyond", "b": [0.6789, 0.2626, 0.7409, 0.284]}, {"w": "the", "b": [0.7461, 0.2626, 0.7725, 0.284]}, {"w": "grid", "b": [0.7777, 0.2626, 0.8118, 0.284]}, {"w": "cell).", "b": [0.817, 0.2626, 0.8572, 0.284]}, {"w": "YOLOv3", "b": [0.1786, 0.2816, 0.2532, 0.303]}, {"w": "applies", "b": [0.2585, 0.2816, 0.3165, 0.303]}, {"w": "the", "b": [0.3218, 0.2816, 0.3481, 0.303]}, {"w": "logistic", "b": [0.3534, 0.2816, 0.4131, 0.303]}, {"w": "activation", "b": [0.4184, 0.2816, 0.5007, 0.303]}, {"w": "function", "b": [0.506, 0.2816, 0.5774, 0.303]}, {"w": "to", "b": [0.5827, 0.2816, 0.5997, 0.303]}, {"w": "the", "b": [0.605, 0.2816, 0.6313, 0.303]}, {"w": "bounding", "b": [0.6367, 0.2816, 0.7181, 0.303]}, {"w": "box", "b": [0.7234, 0.2816, 0.7544, 0.303]}, {"w": "coordinates", "b": [0.7598, 0.2816, 0.8571, 0.303]}, {"w": "to", "b": [0.1786, 0.3007, 0.1956, 0.3221]}, {"w": "ensure", "b": [0.2003, 0.3007, 0.2558, 0.3221]}, {"w": "they", "b": [0.2606, 0.3007, 0.2965, 0.3221]}, {"w": "remain", "b": [0.3012, 0.3007, 0.361, 0.3221]}, {"w": "in", "b": [0.3657, 0.3007, 0.3827, 0.3221]}, {"w": "the", "b": [0.3874, 0.3007, 0.4137, 0.3221]}, {"w": "0", "b": [0.4185, 0.3007, 0.4285, 0.3221]}, {"w": "to", "b": [0.4332, 0.3007, 0.4502, 0.3221]}, {"w": "1", "b": [0.4549, 0.3007, 0.4649, 0.3221]}, {"w": "range.", "b": [0.4696, 0.3007, 0.5212, 0.3221]}]}, {"id": "b_2", "type": "paragraph", "text": "• Third, before training the neural net, YOLOv3 finds 5 representative bounding box dimensions, called anchor boxes (or bounding box priors): it does this by applying the K-Means algorithm (see ???) to the height and width of the training set bounding boxes. For example, if the training images contain many pedes‐ trians, then one of the anchor boxes will likely have the dimensions of a typical pedestrian. Then when the neural net predicts 5 bounding boxes per grid cell, it actually predicts how much to rescale each of the anchor boxes. For example, suppose one anchor box is 100 pixels tall and 50 pixels wide, and the network predicts, say, a vertical rescaling factor of 1.5 and a horizontal rescaling of 0.9 (for one of the grid cells), this will result in a predicted bounding box of size 150 × 45 pixels. To be more precise, for each grid cell and each anchor box, the network predicts the log of the vertical and horizontal rescaling factors. Having these pri‐ ors makes the network more likely to predict bounding boxes of the appropriate dimensions, and it also speeds up training since it will more quickly learn what reasonable bounding boxes look like.", "words": [{"w": "•", "b": [0.16, 0.3258, 0.1681, 0.3472]}, {"w": "Third,", "b": [0.1786, 0.3258, 0.2316, 0.3472]}, {"w": "before", "b": [0.2386, 0.3258, 0.2914, 0.3472]}, {"w": "training", "b": [0.2984, 0.3258, 0.3653, 0.3472]}, {"w": "the", "b": [0.3723, 0.3258, 0.3986, 0.3472]}, {"w": "neural", "b": [0.4056, 0.3258, 0.459, 0.3472]}, {"w": "net,", "b": [0.466, 0.3258, 0.4974, 0.3472]}, {"w": "YOLOv3", "b": [0.5043, 0.3258, 0.5789, 0.3472]}, {"w": "finds", "b": [0.5859, 0.3258, 0.6277, 0.3472]}, {"w": "5", "b": [0.6347, 0.3258, 0.6447, 0.3472]}, {"w": "representative", "b": [0.6516, 0.3258, 0.7688, 0.3472]}, {"w": "bounding", "b": [0.7757, 0.3258, 0.8571, 0.3472]}, {"w": "box", "b": [0.1786, 0.3448, 0.2096, 0.3662]}, {"w": "dimensions,", "b": [0.2183, 0.3448, 0.3199, 0.3662]}, {"w": "called", "b": [0.3286, 0.3448, 0.377, 0.3662]}, {"w": "anchor", "b": [0.3857, 0.3446, 0.4419, 0.3662]}, {"w": "boxes", "b": [0.4507, 0.3446, 0.4953, 0.3662]}, {"w": "(or", "b": [0.504, 0.3448, 0.5296, 0.3662]}, {"w": "bounding", "b": [0.5383, 0.3446, 0.615, 0.3662]}, {"w": "box", "b": [0.6238, 0.3446, 0.6531, 0.3662]}, {"w": "priors):", "b": [0.6619, 0.3446, 0.7213, 0.3662]}, {"w": "it", "b": [0.73, 0.3448, 0.742, 0.3662]}, {"w": "does", "b": [0.7507, 0.3448, 0.7888, 0.3662]}, {"w": "this", "b": [0.7976, 0.3448, 0.8283, 0.3662]}, {"w": "by", "b": [0.837, 0.3448, 0.8571, 0.3662]}, {"w": "applying", "b": [0.1786, 0.3639, 0.2507, 0.3853]}, {"w": "the", "b": [0.2562, 0.3639, 0.2826, 0.3853]}, {"w": "K-Means", "b": [0.2881, 0.3639, 0.3646, 0.3853]}, {"w": "algorithm", "b": [0.3701, 0.3639, 0.4528, 0.3853]}, {"w": "(see", "b": [0.4583, 0.3639, 0.4909, 0.3853]}, {"w": "???)", "b": [0.4964, 0.3639, 0.5273, 0.3853]}, {"w": "to", "b": [0.5328, 0.3639, 0.5498, 0.3853]}, {"w": "the", "b": [0.5553, 0.3639, 0.5816, 0.3853]}, {"w": "height", "b": [0.5872, 0.3639, 0.6396, 0.3853]}, {"w": "and", "b": [0.6451, 0.3639, 0.6766, 0.3853]}, {"w": "width", "b": [0.6822, 0.3639, 0.7305, 0.3853]}, {"w": "of", "b": [0.736, 0.3639, 0.7528, 0.3853]}, {"w": "the", "b": [0.7583, 0.3639, 0.7847, 0.3853]}, {"w": "training", "b": [0.7902, 0.3639, 0.8571, 0.3853]}, {"w": "set", "b": [0.1786, 0.3829, 0.2014, 0.4043]}, {"w": "bounding", "b": [0.2097, 0.3829, 0.2911, 0.4043]}, {"w": "boxes.", "b": [0.2994, 0.3829, 0.3517, 0.4043]}, {"w": "For", "b": [0.36, 0.3829, 0.389, 0.4043]}, {"w": "example,", "b": [0.3973, 0.3829, 0.4716, 0.4043]}, {"w": "if", "b": [0.4799, 0.3829, 0.4917, 0.4043]}, {"w": "the", "b": [0.5, 0.3829, 0.5263, 0.4043]}, {"w": "training", "b": [0.5346, 0.3829, 0.6016, 0.4043]}, {"w": "images", "b": [0.6099, 0.3829, 0.6679, 0.4043]}, {"w": "contain", "b": [0.6762, 0.3829, 0.7391, 0.4043]}, {"w": "many", "b": [0.7475, 0.3829, 0.7941, 0.4043]}, {"w": "pedes‐", "b": [0.8025, 0.3829, 0.8571, 0.4043]}, {"w": "trians,", "b": [0.1786, 0.402, 0.2312, 0.4234]}, {"w": "then", "b": [0.2376, 0.402, 0.2753, 0.4234]}, {"w": "one", "b": [0.2817, 0.402, 0.3126, 0.4234]}, {"w": "of", "b": [0.319, 0.402, 0.3358, 0.4234]}, {"w": "the", "b": [0.3421, 0.402, 0.3685, 0.4234]}, {"w": "anchor", "b": [0.3749, 0.402, 0.4337, 0.4234]}, {"w": "boxes", "b": [0.4401, 0.402, 0.4876, 0.4234]}, {"w": "will", "b": [0.494, 0.402, 0.5244, 0.4234]}, {"w": "likely", "b": [0.5308, 0.402, 0.5757, 0.4234]}, {"w": "have", "b": [0.5821, 0.402, 0.6205, 0.4234]}, {"w": "the", "b": [0.6269, 0.402, 0.6532, 0.4234]}, {"w": "dimensions", "b": [0.6596, 0.402, 0.7564, 0.4234]}, {"w": "of", "b": [0.7628, 0.402, 0.7796, 0.4234]}, {"w": "a", "b": [0.786, 0.402, 0.7951, 0.4234]}, {"w": "typical", "b": [0.8015, 0.402, 0.8572, 0.4234]}, {"w": "pedestrian.", "b": [0.1786, 0.421, 0.2708, 0.4424]}, {"w": "Then", "b": [0.2768, 0.421, 0.321, 0.4424]}, {"w": "when", "b": [0.327, 0.421, 0.3726, 0.4424]}, {"w": "the", "b": [0.3786, 0.421, 0.405, 0.4424]}, {"w": "neural", "b": [0.4109, 0.421, 0.4644, 0.4424]}, {"w": "net", "b": [0.4704, 0.421, 0.497, 0.4424]}, {"w": "predicts", "b": [0.503, 0.421, 0.5699, 0.4424]}, {"w": "5", "b": [0.5758, 0.421, 0.5858, 0.4424]}, {"w": "bounding", "b": [0.5918, 0.421, 0.6732, 0.4424]}, {"w": "boxes", "b": [0.6792, 0.421, 0.7267, 0.4424]}, {"w": "per", "b": [0.7327, 0.421, 0.7602, 0.4424]}, {"w": "grid", "b": [0.7662, 0.421, 0.8003, 0.4424]}, {"w": "cell,", "b": [0.8063, 0.421, 0.8392, 0.4424]}, {"w": "it", "b": [0.8452, 0.421, 0.8571, 0.4424]}, {"w": "actually", "b": [0.1786, 0.4401, 0.2432, 0.4615]}, {"w": "predicts", "b": [0.2511, 0.4401, 0.318, 0.4615]}, {"w": "how", "b": [0.3259, 0.4401, 0.3619, 0.4615]}, {"w": "much", "b": [0.3698, 0.4401, 0.4174, 0.4615]}, {"w": "to", "b": [0.4253, 0.4401, 0.4423, 0.4615]}, {"w": "rescale", "b": [0.4502, 0.4401, 0.5065, 0.4615]}, {"w": "each", "b": [0.5144, 0.4401, 0.5523, 0.4615]}, {"w": "of", "b": [0.5602, 0.4401, 0.577, 0.4615]}, {"w": "the", "b": [0.5849, 0.4401, 0.6112, 0.4615]}, {"w": "anchor", "b": [0.6191, 0.4401, 0.6779, 0.4615]}, {"w": "boxes.", "b": [0.6858, 0.4401, 0.7381, 0.4615]}, {"w": "For", "b": [0.746, 0.4401, 0.775, 0.4615]}, {"w": "example,", "b": [0.7829, 0.4401, 0.8571, 0.4615]}, {"w": "suppose", "b": [0.1786, 0.4591, 0.2462, 0.4805]}, {"w": "one", "b": [0.2535, 0.4591, 0.2843, 0.4805]}, {"w": "anchor", "b": [0.2916, 0.4591, 0.3504, 0.4805]}, {"w": "box", "b": [0.3576, 0.4591, 0.3887, 0.4805]}, {"w": "is", "b": [0.3959, 0.4591, 0.4091, 0.4805]}, {"w": "100", "b": [0.4164, 0.4591, 0.4464, 0.4805]}, {"w": "pixels", "b": [0.4536, 0.4591, 0.5017, 0.4805]}, {"w": "tall", "b": [0.5089, 0.4591, 0.535, 0.4805]}, {"w": "and", "b": [0.5422, 0.4591, 0.5737, 0.4805]}, {"w": "50", "b": [0.581, 0.4591, 0.601, 0.4805]}, {"w": "pixels", "b": [0.6082, 0.4591, 0.6563, 0.4805]}, {"w": "wide,", "b": [0.6635, 0.4591, 0.708, 0.4805]}, {"w": "and", "b": [0.7152, 0.4591, 0.7468, 0.4805]}, {"w": "the", "b": [0.754, 0.4591, 0.7803, 0.4805]}, {"w": "network", "b": [0.7876, 0.4591, 0.8571, 0.4805]}, {"w": "predicts,", "b": [0.1786, 0.4782, 0.2502, 0.4996]}, {"w": "say,", "b": [0.2551, 0.4782, 0.2843, 0.4996]}, {"w": "a", "b": [0.2892, 0.4782, 0.2983, 0.4996]}, {"w": "vertical", "b": [0.3032, 0.4782, 0.3646, 0.4996]}, {"w": "rescaling", "b": [0.3695, 0.4782, 0.4437, 0.4996]}, {"w": "factor", "b": [0.4485, 0.4782, 0.4974, 0.4996]}, {"w": "of", "b": [0.5022, 0.4782, 0.519, 0.4996]}, {"w": "1.5", "b": [0.5239, 0.4782, 0.5487, 0.4996]}, {"w": "and", "b": [0.5535, 0.4782, 0.5851, 0.4996]}, {"w": "a", "b": [0.59, 0.4782, 0.5991, 0.4996]}, {"w": "horizontal", "b": [0.604, 0.4782, 0.6902, 0.4996]}, {"w": "rescaling", "b": [0.6951, 0.4782, 0.7692, 0.4996]}, {"w": "of", "b": [0.7741, 0.4782, 0.7909, 0.4996]}, {"w": "0.9", "b": [0.7958, 0.4782, 0.8205, 0.4996]}, {"w": "(for", "b": [0.8254, 0.4782, 0.8571, 0.4996]}, {"w": "one", "b": [0.1786, 0.4972, 0.2094, 0.5186]}, {"w": "of", "b": [0.2146, 0.4972, 0.2314, 0.5186]}, {"w": "the", "b": [0.2365, 0.4972, 0.2628, 0.5186]}, {"w": "grid", "b": [0.268, 0.4972, 0.302, 0.5186]}, {"w": "cells),", "b": [0.3072, 0.4972, 0.355, 0.5186]}, {"w": "this", "b": [0.3601, 0.4972, 0.3908, 0.5186]}, {"w": "will", "b": [0.396, 0.4972, 0.4264, 0.5186]}, {"w": "result", "b": [0.4315, 0.4972, 0.4784, 0.5186]}, {"w": "in", "b": [0.4835, 0.4972, 0.5005, 0.5186]}, {"w": "a", "b": [0.5057, 0.4972, 0.5148, 0.5186]}, {"w": "predicted", "b": [0.5199, 0.4972, 0.599, 0.5186]}, {"w": "bounding", "b": [0.6042, 0.4972, 0.6856, 0.5186]}, {"w": "box", "b": [0.6907, 0.4972, 0.7217, 0.5186]}, {"w": "of", "b": [0.7269, 0.4972, 0.7437, 0.5186]}, {"w": "size", "b": [0.7488, 0.4972, 0.7796, 0.5186]}, {"w": "150", "b": [0.7848, 0.4972, 0.8148, 0.5186]}, {"w": "×", "b": [0.8199, 0.4972, 0.832, 0.5186]}, {"w": "45", "b": [0.8371, 0.4972, 0.8571, 0.5186]}, {"w": "pixels.", "b": [0.1786, 0.5163, 0.2314, 0.5377]}, {"w": "To", "b": [0.238, 0.5163, 0.2595, 0.5377]}, {"w": "be", "b": [0.2661, 0.5163, 0.2855, 0.5377]}, {"w": "more", "b": [0.2922, 0.5163, 0.3364, 0.5377]}, {"w": "precise,", "b": [0.3431, 0.5163, 0.4062, 0.5377]}, {"w": "for", "b": [0.4128, 0.5163, 0.4373, 0.5377]}, {"w": "each", "b": [0.444, 0.5163, 0.4819, 0.5377]}, {"w": "grid", "b": [0.4885, 0.5163, 0.5226, 0.5377]}, {"w": "cell", "b": [0.5292, 0.5163, 0.5574, 0.5377]}, {"w": "and", "b": [0.564, 0.5163, 0.5956, 0.5377]}, {"w": "each", "b": [0.6022, 0.5163, 0.6401, 0.5377]}, {"w": "anchor", "b": [0.6468, 0.5163, 0.7056, 0.5377]}, {"w": "box,", "b": [0.7122, 0.5163, 0.748, 0.5377]}, {"w": "the", "b": [0.7546, 0.5163, 0.781, 0.5377]}, {"w": "network", "b": [0.7876, 0.5163, 0.8571, 0.5377]}, {"w": "predicts", "b": [0.1786, 0.5353, 0.2455, 0.5567]}, {"w": "the", "b": [0.2511, 0.5353, 0.2774, 0.5567]}, {"w": "log", "b": [0.283, 0.5353, 0.3086, 0.5567]}, {"w": "of", "b": [0.3142, 0.5353, 0.331, 0.5567]}, {"w": "the", "b": [0.3366, 0.5353, 0.3629, 0.5567]}, {"w": "vertical", "b": [0.3685, 0.5353, 0.4299, 0.5567]}, {"w": "and", "b": [0.4354, 0.5353, 0.467, 0.5567]}, {"w": "horizontal", "b": [0.4726, 0.5353, 0.5588, 0.5567]}, {"w": "rescaling", "b": [0.5643, 0.5353, 0.6385, 0.5567]}, {"w": "factors.", "b": [0.6441, 0.5353, 0.7053, 0.5567]}, {"w": "Having", "b": [0.7109, 0.5353, 0.7715, 0.5567]}, {"w": "these", "b": [0.7771, 0.5353, 0.8199, 0.5567]}, {"w": "pri‐", "b": [0.8255, 0.5353, 0.8572, 0.5567]}, {"w": "ors", "b": [0.1786, 0.5543, 0.2046, 0.5758]}, {"w": "makes", "b": [0.2103, 0.5543, 0.2634, 0.5758]}, {"w": "the", "b": [0.2691, 0.5543, 0.2955, 0.5758]}, {"w": "network", "b": [0.3012, 0.5543, 0.3708, 0.5758]}, {"w": "more", "b": [0.3765, 0.5543, 0.4208, 0.5758]}, {"w": "likely", "b": [0.4266, 0.5543, 0.4714, 0.5758]}, {"w": "to", "b": [0.4772, 0.5543, 0.4942, 0.5758]}, {"w": "predict", "b": [0.4999, 0.5543, 0.5592, 0.5758]}, {"w": "bounding", "b": [0.5649, 0.5543, 0.6463, 0.5758]}, {"w": "boxes", "b": [0.6521, 0.5543, 0.6996, 0.5758]}, {"w": "of", "b": [0.7054, 0.5543, 0.7222, 0.5758]}, {"w": "the", "b": [0.7279, 0.5543, 0.7543, 0.5758]}, {"w": "appropriate", "b": [0.76, 0.5543, 0.8571, 0.5758]}, {"w": "dimensions,", "b": [0.1786, 0.5734, 0.2801, 0.5948]}, {"w": "and", "b": [0.2866, 0.5734, 0.3181, 0.5948]}, {"w": "it", "b": [0.3246, 0.5734, 0.3365, 0.5948]}, {"w": "also", "b": [0.343, 0.5734, 0.3757, 0.5948]}, {"w": "speeds", "b": [0.3821, 0.5734, 0.437, 0.5948]}, {"w": "up", "b": [0.4435, 0.5734, 0.4655, 0.5948]}, {"w": "training", "b": [0.4719, 0.5734, 0.5389, 0.5948]}, {"w": "since", "b": [0.5453, 0.5734, 0.5876, 0.5948]}, {"w": "it", "b": [0.5941, 0.5734, 0.606, 0.5948]}, {"w": "will", "b": [0.6125, 0.5734, 0.6429, 0.5948]}, {"w": "more", "b": [0.6493, 0.5734, 0.6936, 0.5948]}, {"w": "quickly", "b": [0.7001, 0.5734, 0.7613, 0.5948]}, {"w": "learn", "b": [0.7678, 0.5734, 0.8102, 0.5948]}, {"w": "what", "b": [0.8166, 0.5734, 0.8571, 0.5948]}, {"w": "reasonable", "b": [0.1786, 0.5924, 0.2678, 0.6139]}, {"w": "bounding", "b": [0.2725, 0.5924, 0.3539, 0.6139]}, {"w": "boxes", "b": [0.3587, 0.5924, 0.4062, 0.6139]}, {"w": "look", "b": [0.4109, 0.5924, 0.4478, 0.6139]}, {"w": "like.", "b": [0.4525, 0.5924, 0.4873, 0.6139]}]}, {"id": "b_3", "type": "paragraph", "text": "• Fourth, the network is trained using images of different scales: every few batches during training, the network randomly chooses a new image dimension (from 330 × 330 to 608 × 608 pixels). This allows the network to learn to detect objects at different scales. Moreover, it makes it possible to use YOLOv3 at different scales: the smaller scale will be less accurate but faster than the larger scale, so you can choose the right tradeoff for your use case.", "words": [{"w": "•", "b": [0.16, 0.6175, 0.1682, 0.6389]}, {"w": "Fourth,", "b": [0.1786, 0.6175, 0.2408, 0.6389]}, {"w": "the", "b": [0.2464, 0.6175, 0.2727, 0.6389]}, {"w": "network", "b": [0.2782, 0.6175, 0.3478, 0.6389]}, {"w": "is", "b": [0.3533, 0.6175, 0.3665, 0.6389]}, {"w": "trained", "b": [0.3721, 0.6175, 0.4321, 0.6389]}, {"w": "using", "b": [0.4377, 0.6175, 0.4831, 0.6389]}, {"w": "images", "b": [0.4886, 0.6175, 0.5467, 0.6389]}, {"w": "of", "b": [0.5522, 0.6175, 0.569, 0.6389]}, {"w": "different", "b": [0.5745, 0.6175, 0.6462, 0.6389]}, {"w": "scales:", "b": [0.6518, 0.6175, 0.7039, 0.6389]}, {"w": "every", "b": [0.7094, 0.6175, 0.7547, 0.6389]}, {"w": "few", "b": [0.7602, 0.6175, 0.7895, 0.6389]}, {"w": "batches", "b": [0.795, 0.6175, 0.8571, 0.6389]}, {"w": "during", "b": [0.1786, 0.6366, 0.2351, 0.658]}, {"w": "training,", "b": [0.2426, 0.6366, 0.3143, 0.658]}, {"w": "the", "b": [0.3219, 0.6366, 0.3482, 0.658]}, {"w": "network", "b": [0.3557, 0.6366, 0.4253, 0.658]}, {"w": "randomly", "b": [0.4328, 0.6366, 0.5146, 0.658]}, {"w": "chooses", "b": [0.5221, 0.6366, 0.5875, 0.658]}, {"w": "a", "b": [0.595, 0.6366, 0.6042, 0.658]}, {"w": "new", "b": [0.6117, 0.6366, 0.6462, 0.658]}, {"w": "image", "b": [0.6537, 0.6366, 0.7041, 0.658]}, {"w": "dimension", "b": [0.7117, 0.6366, 0.8008, 0.658]}, {"w": "(from", "b": [0.8084, 0.6366, 0.8571, 0.658]}, {"w": "330", "b": [0.1786, 0.6556, 0.2086, 0.677]}, {"w": "×", "b": [0.214, 0.6556, 0.2261, 0.677]}, {"w": "330", "b": [0.2316, 0.6556, 0.2616, 0.677]}, {"w": "to", "b": [0.267, 0.6556, 0.284, 0.677]}, {"w": "608", "b": [0.2894, 0.6556, 0.3194, 0.677]}, {"w": "×", "b": [0.3249, 0.6556, 0.337, 0.677]}, {"w": "608", "b": [0.3424, 0.6556, 0.3724, 0.677]}, {"w": "pixels).", "b": [0.3779, 0.6556, 0.4379, 0.677]}, {"w": "This", "b": [0.4434, 0.6556, 0.4806, 0.677]}, {"w": "allows", "b": [0.4861, 0.6556, 0.5383, 0.677]}, {"w": "the", "b": [0.5437, 0.6556, 0.5701, 0.677]}, {"w": "network", "b": [0.5755, 0.6556, 0.6451, 0.677]}, {"w": "to", "b": [0.6505, 0.6556, 0.6675, 0.677]}, {"w": "learn", "b": [0.673, 0.6556, 0.7154, 0.677]}, {"w": "to", "b": [0.7208, 0.6556, 0.7378, 0.677]}, {"w": "detect", "b": [0.7432, 0.6556, 0.7935, 0.677]}, {"w": "objects", "b": [0.7989, 0.6556, 0.8571, 0.677]}, {"w": "at", "b": [0.1786, 0.6747, 0.1937, 0.6961]}, {"w": "different", "b": [0.2023, 0.6747, 0.2741, 0.6961]}, {"w": "scales.", "b": [0.2827, 0.6747, 0.3349, 0.6961]}, {"w": "Moreover,", "b": [0.3435, 0.6747, 0.4291, 0.6961]}, {"w": "it", "b": [0.4377, 0.6747, 0.4497, 0.6961]}, {"w": "makes", "b": [0.4583, 0.6747, 0.5114, 0.6961]}, {"w": "it", "b": [0.5201, 0.6747, 0.532, 0.6961]}, {"w": "possible", "b": [0.5407, 0.6747, 0.6078, 0.6961]}, {"w": "to", "b": [0.6165, 0.6747, 0.6334, 0.6961]}, {"w": "use", "b": [0.6421, 0.6747, 0.6697, 0.6961]}, {"w": "YOLOv3", "b": [0.6784, 0.6747, 0.753, 0.6961]}, {"w": "at", "b": [0.7617, 0.6747, 0.7768, 0.6961]}, {"w": "different", "b": [0.7854, 0.6747, 0.8571, 0.6961]}, {"w": "scales:", "b": [0.1786, 0.6937, 0.2307, 0.7151]}, {"w": "the", "b": [0.2379, 0.6937, 0.2643, 0.7151]}, {"w": "smaller", "b": [0.2715, 0.6937, 0.3325, 0.7151]}, {"w": "scale", "b": [0.3397, 0.6937, 0.3794, 0.7151]}, {"w": "will", "b": [0.3866, 0.6937, 0.417, 0.7151]}, {"w": "be", "b": [0.4243, 0.6937, 0.4437, 0.7151]}, {"w": "less", "b": [0.4509, 0.6937, 0.4803, 0.7151]}, {"w": "accurate", "b": [0.4876, 0.6937, 0.5571, 0.7151]}, {"w": "but", "b": [0.5643, 0.6937, 0.5923, 0.7151]}, {"w": "faster", "b": [0.5995, 0.6937, 0.6454, 0.7151]}, {"w": "than", "b": [0.6527, 0.6937, 0.6907, 0.7151]}, {"w": "the", "b": [0.6979, 0.6937, 0.7242, 0.7151]}, {"w": "larger", "b": [0.7315, 0.6937, 0.78, 0.7151]}, {"w": "scale,", "b": [0.7872, 0.6937, 0.8317, 0.7151]}, {"w": "so", "b": [0.8389, 0.6937, 0.8572, 0.7151]}, {"w": "you", "b": [0.1786, 0.7128, 0.2098, 0.7342]}, {"w": "can", "b": [0.2145, 0.7128, 0.2439, 0.7342]}, {"w": "choose", "b": [0.2486, 0.7128, 0.3063, 0.7342]}, {"w": "the", "b": [0.311, 0.7128, 0.3374, 0.7342]}, {"w": "right", "b": [0.3421, 0.7128, 0.3823, 0.7342]}, {"w": "tradeoff", "b": [0.387, 0.7128, 0.453, 0.7342]}, {"w": "for", "b": [0.4578, 0.7128, 0.4823, 0.7342]}, {"w": "your", "b": [0.487, 0.7128, 0.526, 0.7342]}, {"w": "use", "b": [0.5307, 0.7128, 0.5583, 0.7342]}, {"w": "case.", "b": [0.563, 0.7128, 0.6022, 0.7342]}]}, {"id": "b_4", "type": "paragraph", "text": "There are a few more innovations you might be interested in, such as the use of skip connections to recover some of the spatial resolution that is lost in the CNN (we will discuss this shortly when we look at semantic segmentation). Moreover, in the 2016 paper, the authors introduce the YOLO9000 model that uses hierarchical classifica‐ tion: the model predicts a probability for each node in a visual hierarchy called Word‐ Tree. This makes it possible for the network to predict with high confidence that an image represents, say, a dog, even though it is unsure what specific type of dog it is.", "words": [{"w": "There", "b": [0.1429, 0.7469, 0.1923, 0.7684]}, {"w": "are", "b": [0.1981, 0.7469, 0.2238, 0.7684]}, {"w": "a", "b": [0.2296, 0.7469, 0.2387, 0.7684]}, {"w": "few", "b": [0.2445, 0.7469, 0.2738, 0.7684]}, {"w": "more", "b": [0.2796, 0.7469, 0.3239, 0.7684]}, {"w": "innovations", "b": [0.3297, 0.7469, 0.4287, 0.7684]}, {"w": "you", "b": [0.4345, 0.7469, 0.4657, 0.7684]}, {"w": "might", "b": [0.4715, 0.7469, 0.521, 0.7684]}, {"w": "be", "b": [0.5268, 0.7469, 0.5462, 0.7684]}, {"w": "interested", "b": [0.552, 0.7469, 0.6343, 0.7684]}, {"w": "in,", "b": [0.64, 0.7469, 0.6618, 0.7684]}, {"w": "such", "b": [0.6676, 0.7469, 0.7062, 0.7684]}, {"w": "as", "b": [0.712, 0.7469, 0.7288, 0.7684]}, {"w": "the", "b": [0.7346, 0.7469, 0.7609, 0.7684]}, {"w": "use", "b": [0.7667, 0.7469, 0.7943, 0.7684]}, {"w": "of", "b": [0.8001, 0.7469, 0.8169, 0.7684]}, {"w": "skip", "b": [0.8227, 0.7469, 0.8571, 0.7684]}, {"w": "connections", "b": [0.1429, 0.766, 0.2444, 0.7874]}, {"w": "to", "b": [0.2499, 0.766, 0.2669, 0.7874]}, {"w": "recover", "b": [0.2724, 0.766, 0.3346, 0.7874]}, {"w": "some", "b": [0.3402, 0.766, 0.3843, 0.7874]}, {"w": "of", "b": [0.3899, 0.766, 0.4067, 0.7874]}, {"w": "the", "b": [0.4122, 0.766, 0.4385, 0.7874]}, {"w": "spatial", "b": [0.444, 0.766, 0.4977, 0.7874]}, {"w": "resolution", "b": [0.5032, 0.766, 0.5884, 0.7874]}, {"w": "that", "b": [0.5939, 0.766, 0.6265, 0.7874]}, {"w": "is", "b": [0.632, 0.766, 0.6452, 0.7874]}, {"w": "lost", "b": [0.6508, 0.766, 0.6807, 0.7874]}, {"w": "in", "b": [0.6862, 0.766, 0.7032, 0.7874]}, {"w": "the", "b": [0.7087, 0.766, 0.735, 0.7874]}, {"w": "CNN", "b": [0.7405, 0.766, 0.7854, 0.7874]}, {"w": "(we", "b": [0.7909, 0.766, 0.8212, 0.7874]}, {"w": "will", "b": [0.8267, 0.766, 0.8571, 0.7874]}, {"w": "discuss", "b": [0.1428, 0.785, 0.2022, 0.8064]}, {"w": "this", "b": [0.2087, 0.785, 0.2394, 0.8064]}, {"w": "shortly", "b": [0.2459, 0.785, 0.3042, 0.8064]}, {"w": "when", "b": [0.3107, 0.785, 0.3563, 0.8064]}, {"w": "we", "b": [0.3628, 0.785, 0.3859, 0.8064]}, {"w": "look", "b": [0.3924, 0.785, 0.4292, 0.8064]}, {"w": "at", "b": [0.4357, 0.785, 0.4508, 0.8064]}, {"w": "semantic", "b": [0.4573, 0.785, 0.5318, 0.8064]}, {"w": "segmentation).", "b": [0.5382, 0.785, 0.6624, 0.8064]}, {"w": "Moreover,", "b": [0.6689, 0.785, 0.7544, 0.8064]}, {"w": "in", "b": [0.7609, 0.785, 0.7779, 0.8064]}, {"w": "the", "b": [0.7843, 0.785, 0.8107, 0.8064]}, {"w": "2016", "b": [0.8171, 0.785, 0.8571, 0.8064]}, {"w": "paper,", "b": [0.1429, 0.8041, 0.1935, 0.8255]}, {"w": "the", "b": [0.2006, 0.8041, 0.2269, 0.8255]}, {"w": "authors", "b": [0.2341, 0.8041, 0.2974, 0.8255]}, {"w": "introduce", "b": [0.3045, 0.8041, 0.3855, 0.8255]}, {"w": "the", "b": [0.3926, 0.8041, 0.419, 0.8255]}, {"w": "YOLO9000", "b": [0.4261, 0.8041, 0.5207, 0.8255]}, {"w": "model", "b": [0.5279, 0.8041, 0.5807, 0.8255]}, {"w": "that", "b": [0.5878, 0.8041, 0.6204, 0.8255]}, {"w": "uses", "b": [0.6275, 0.8041, 0.6627, 0.8255]}, {"w": "hierarchical", "b": [0.6699, 0.8041, 0.7688, 0.8255]}, {"w": "classifica‐", "b": [0.7759, 0.8041, 0.8571, 0.8255]}, {"w": "tion:", "b": [0.1429, 0.8231, 0.1816, 0.8445]}, {"w": "the", "b": [0.1866, 0.8231, 0.2129, 0.8445]}, {"w": "model", "b": [0.2179, 0.8231, 0.2707, 0.8445]}, {"w": "predicts", "b": [0.2757, 0.8231, 0.3426, 0.8445]}, {"w": "a", "b": [0.3476, 0.8231, 0.3567, 0.8445]}, {"w": "probability", "b": [0.3617, 0.8231, 0.4537, 0.8445]}, {"w": "for", "b": [0.4587, 0.8231, 0.4832, 0.8445]}, {"w": "each", "b": [0.4882, 0.8231, 0.5261, 0.8445]}, {"w": "node", "b": [0.5311, 0.8231, 0.573, 0.8445]}, {"w": "in", "b": [0.578, 0.8231, 0.5949, 0.8445]}, {"w": "a", "b": [0.5999, 0.8231, 0.6091, 0.8445]}, {"w": "visual", "b": [0.6141, 0.8231, 0.6624, 0.8445]}, {"w": "hierarchy", "b": [0.6674, 0.8231, 0.7466, 0.8445]}, {"w": "called", "b": [0.7516, 0.8231, 0.8, 0.8445]}, {"w": "Word‐", "b": [0.805, 0.8229, 0.8571, 0.8445]}, {"w": "Tree.", "b": [0.1429, 0.842, 0.1824, 0.8636]}, {"w": "This", "b": [0.1888, 0.8422, 0.226, 0.8636]}, {"w": "makes", "b": [0.2323, 0.8422, 0.2854, 0.8636]}, {"w": "it", "b": [0.2918, 0.8422, 0.3037, 0.8636]}, {"w": "possible", "b": [0.3101, 0.8422, 0.3772, 0.8636]}, {"w": "for", "b": [0.3836, 0.8422, 0.4081, 0.8636]}, {"w": "the", "b": [0.4145, 0.8422, 0.4408, 0.8636]}, {"w": "network", "b": [0.4472, 0.8422, 0.5167, 0.8636]}, {"w": "to", "b": [0.5231, 0.8422, 0.5401, 0.8636]}, {"w": "predict", "b": [0.5465, 0.8422, 0.6057, 0.8636]}, {"w": "with", "b": [0.6121, 0.8422, 0.6494, 0.8636]}, {"w": "high", "b": [0.6558, 0.8422, 0.6934, 0.8636]}, {"w": "confidence", "b": [0.6998, 0.8422, 0.7913, 0.8636]}, {"w": "that", "b": [0.7976, 0.8422, 0.8302, 0.8636]}, {"w": "an", "b": [0.8366, 0.8422, 0.8571, 0.8636]}, {"w": "image", "b": [0.1429, 0.8612, 0.1933, 0.8826]}, {"w": "represents,", "b": [0.1996, 0.8612, 0.2899, 0.8826]}, {"w": "say,", "b": [0.2962, 0.8612, 0.3254, 0.8826]}, {"w": "a", "b": [0.3317, 0.8612, 0.3408, 0.8826]}, {"w": "dog,", "b": [0.3471, 0.8612, 0.3833, 0.8826]}, {"w": "even", "b": [0.3896, 0.8612, 0.4283, 0.8826]}, {"w": "though", "b": [0.4346, 0.8612, 0.4946, 0.8826]}, {"w": "it", "b": [0.5009, 0.8612, 0.5129, 0.8826]}, {"w": "is", "b": [0.5192, 0.8612, 0.5324, 0.8826]}, {"w": "unsure", "b": [0.5387, 0.8612, 0.5964, 0.8826]}, {"w": "what", "b": [0.6027, 0.8612, 0.6432, 0.8826]}, {"w": "specific", "b": [0.6495, 0.8612, 0.7119, 0.8826]}, {"w": "type", "b": [0.7182, 0.8612, 0.7539, 0.8826]}, {"w": "of", "b": [0.7602, 0.8612, 0.777, 0.8826]}, {"w": "dog", "b": [0.7833, 0.8612, 0.8146, 0.8826]}, {"w": "it", "b": [0.8209, 0.8612, 0.8329, 0.8826]}, {"w": "is.", "b": [0.8392, 0.8612, 0.8572, 0.8826]}]}, {"id": "b_5", "type": "paragraph", "text": "476 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "476", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3683, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 503, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "So I encourage you to go ahead and read all three papers: they are quite pleasant to read, and it is an excellent example of how Deep Learning systems can be incremen‐ tally improved.", "words": [{"w": "So", "b": [0.1429, 0.0791, 0.1634, 0.1005]}, {"w": "I", "b": [0.1698, 0.0791, 0.1769, 0.1005]}, {"w": "encourage", "b": [0.1833, 0.0791, 0.2695, 0.1005]}, {"w": "you", "b": [0.2759, 0.0791, 0.3072, 0.1005]}, {"w": "to", "b": [0.3136, 0.0791, 0.3306, 0.1005]}, {"w": "go", "b": [0.337, 0.0791, 0.3574, 0.1005]}, {"w": "ahead", "b": [0.3638, 0.0791, 0.4131, 0.1005]}, {"w": "and", "b": [0.4195, 0.0791, 0.451, 0.1005]}, {"w": "read", "b": [0.4575, 0.0791, 0.4942, 0.1005]}, {"w": "all", "b": [0.5006, 0.0791, 0.5203, 0.1005]}, {"w": "three", "b": [0.5267, 0.0791, 0.5696, 0.1005]}, {"w": "papers:", "b": [0.576, 0.0791, 0.6356, 0.1005]}, {"w": "they", "b": [0.642, 0.0791, 0.6779, 0.1005]}, {"w": "are", "b": [0.6843, 0.0791, 0.7101, 0.1005]}, {"w": "quite", "b": [0.7165, 0.0791, 0.759, 0.1005]}, {"w": "pleasant", "b": [0.7654, 0.0791, 0.8337, 0.1005]}, {"w": "to", "b": [0.8402, 0.0791, 0.8571, 0.1005]}, {"w": "read,", "b": [0.1429, 0.0981, 0.1843, 0.1195]}, {"w": "and", "b": [0.1901, 0.0981, 0.2216, 0.1195]}, {"w": "it", "b": [0.2274, 0.0981, 0.2393, 0.1195]}, {"w": "is", "b": [0.245, 0.0981, 0.2583, 0.1195]}, {"w": "an", "b": [0.264, 0.0981, 0.2846, 0.1195]}, {"w": "excellent", "b": [0.2903, 0.0981, 0.3634, 0.1195]}, {"w": "example", "b": [0.3692, 0.0981, 0.4387, 0.1195]}, {"w": "of", "b": [0.4444, 0.0981, 0.4612, 0.1195]}, {"w": "how", "b": [0.467, 0.0981, 0.503, 0.1195]}, {"w": "Deep", "b": [0.5087, 0.0981, 0.5527, 0.1195]}, {"w": "Learning", "b": [0.5584, 0.0981, 0.6335, 0.1195]}, {"w": "systems", "b": [0.6392, 0.0981, 0.704, 0.1195]}, {"w": "can", "b": [0.7098, 0.0981, 0.7391, 0.1195]}, {"w": "be", "b": [0.7448, 0.0981, 0.7643, 0.1195]}, {"w": "incremen‐", "b": [0.77, 0.0981, 0.8571, 0.1195]}, {"w": "tally", "b": [0.1429, 0.1172, 0.1785, 0.1386]}, {"w": "improved.", "b": [0.1832, 0.1172, 0.269, 0.1386]}]}, {"id": "b_1", "type": "paragraph", "text": "Mean Average Precision (mAP)", "words": [{"w": "Mean", "b": [0.3506, 0.1643, 0.4055, 0.1915]}, {"w": "Average", "b": [0.4102, 0.1643, 0.4907, 0.1915]}, {"w": "Precision", "b": [0.4954, 0.1643, 0.5839, 0.1915]}, {"w": "(mAP)", "b": [0.5886, 0.1643, 0.6494, 0.1915]}]}, {"id": "b_2", "type": "paragraph", "text": "A very common metric used in object detection tasks is the mean Average Precision (mAP). “Mean Average” sounds a bit redundant, doesn’t it? To understand this met‐ ric, let’s go back to two classification metrics we discussed in Chapter 3: precision and recall. Remember the tradeoff: the higher the recall, the lower the precision. You can visualize this in a Precision/Recall curve (see Figure 3-5). To summarize this curve into a single number, we could compute its Area Under the Curve (AUC). But note that the Precision/Recall curve may contain a few sections where precision actually goes up when recall increases, especially at low recall values (you can see this at the top left of Figure 3-5). This is one of the motivations for the mAP metric.", "words": [{"w": "A", "b": [0.1592, 0.196, 0.1729, 0.2164]}, {"w": "very", "b": [0.1792, 0.196, 0.2139, 0.2164]}, {"w": "common", "b": [0.2201, 0.196, 0.2921, 0.2164]}, {"w": "metric", "b": [0.2984, 0.196, 0.3502, 0.2164]}, {"w": "used", "b": [0.3564, 0.196, 0.3931, 0.2164]}, {"w": "in", "b": [0.3994, 0.196, 0.4156, 0.2164]}, {"w": "object", "b": [0.4218, 0.196, 0.47, 0.2164]}, {"w": "detection", "b": [0.4762, 0.196, 0.5504, 0.2164]}, {"w": "tasks", "b": [0.5566, 0.196, 0.5958, 0.2164]}, {"w": "is", "b": [0.6021, 0.196, 0.6147, 0.2164]}, {"w": "the", "b": [0.6209, 0.196, 0.646, 0.2164]}, {"w": "mean", "b": [0.6522, 0.1958, 0.6955, 0.2164]}, {"w": "Average", "b": [0.7018, 0.1958, 0.7643, 0.2164]}, {"w": "Precision", "b": [0.7706, 0.1958, 0.8408, 0.2164]}, {"w": "(mAP).", "b": [0.1592, 0.2142, 0.2186, 0.2346]}, {"w": "“Mean", "b": [0.2246, 0.2142, 0.2771, 0.2346]}, {"w": "Average”", "b": [0.2831, 0.2142, 0.3537, 0.2346]}, {"w": "sounds", "b": [0.3597, 0.2142, 0.4163, 0.2346]}, {"w": "a", "b": [0.4222, 0.2142, 0.4309, 0.2346]}, {"w": "bit", "b": [0.4369, 0.2142, 0.4584, 0.2346]}, {"w": "redundant,", "b": [0.4643, 0.2142, 0.5522, 0.2346]}, {"w": "doesn’t", "b": [0.5582, 0.2142, 0.6135, 0.2346]}, {"w": "it?", "b": [0.6195, 0.2142, 0.6384, 0.2346]}, {"w": "To", "b": [0.6444, 0.2142, 0.6648, 0.2346]}, {"w": "understand", "b": [0.6708, 0.2142, 0.7618, 0.2346]}, {"w": "this", "b": [0.7678, 0.2142, 0.797, 0.2346]}, {"w": "met‐", "b": [0.803, 0.2142, 0.8408, 0.2346]}, {"w": "ric,", "b": [0.1592, 0.2323, 0.1848, 0.2527]}, {"w": "let’s", "b": [0.1897, 0.2323, 0.2185, 0.2527]}, {"w": "go", "b": [0.2233, 0.2323, 0.2427, 0.2527]}, {"w": "back", "b": [0.2476, 0.2323, 0.2846, 0.2527]}, {"w": "to", "b": [0.2894, 0.2323, 0.3056, 0.2527]}, {"w": "two", "b": [0.3104, 0.2323, 0.3402, 0.2527]}, {"w": "classification", "b": [0.3451, 0.2323, 0.4473, 0.2527]}, {"w": "metrics", "b": [0.4522, 0.2323, 0.5113, 0.2527]}, {"w": "we", "b": [0.5161, 0.2323, 0.5381, 0.2527]}, {"w": "discussed", "b": [0.543, 0.2323, 0.6184, 0.2527]}, {"w": "in", "b": [0.6233, 0.2323, 0.6395, 0.2527]}, {"w": "Chapter", "b": [0.6443, 0.2323, 0.7087, 0.2527]}, {"w": "3:", "b": [0.7132, 0.2323, 0.7276, 0.2527]}, {"w": "precision", "b": [0.7324, 0.2323, 0.8059, 0.2527]}, {"w": "and", "b": [0.8107, 0.2323, 0.8408, 0.2527]}, {"w": "recall.", "b": [0.1592, 0.2505, 0.2067, 0.2709]}, {"w": "Remember", "b": [0.2123, 0.2505, 0.2999, 0.2709]}, {"w": "the", "b": [0.3055, 0.2505, 0.3306, 0.2709]}, {"w": "tradeoff:", "b": [0.3363, 0.2505, 0.4037, 0.2709]}, {"w": "the", "b": [0.4093, 0.2505, 0.4344, 0.2709]}, {"w": "higher", "b": [0.44, 0.2505, 0.4916, 0.2709]}, {"w": "the", "b": [0.4973, 0.2505, 0.5224, 0.2709]}, {"w": "recall,", "b": [0.528, 0.2505, 0.5755, 0.2709]}, {"w": "the", "b": [0.5811, 0.2505, 0.6062, 0.2709]}, {"w": "lower", "b": [0.6118, 0.2505, 0.6563, 0.2709]}, {"w": "the", "b": [0.662, 0.2505, 0.6871, 0.2709]}, {"w": "precision.", "b": [0.6927, 0.2505, 0.7707, 0.2709]}, {"w": "You", "b": [0.7764, 0.2505, 0.8072, 0.2709]}, {"w": "can", "b": [0.8128, 0.2505, 0.8408, 0.2709]}, {"w": "visualize", "b": [0.1592, 0.2686, 0.2274, 0.289]}, {"w": "this", "b": [0.2343, 0.2686, 0.2636, 0.289]}, {"w": "in", "b": [0.2705, 0.2686, 0.2867, 0.289]}, {"w": "a", "b": [0.2937, 0.2686, 0.3024, 0.289]}, {"w": "Precision/Recall", "b": [0.3093, 0.2686, 0.438, 0.289]}, {"w": "curve", "b": [0.445, 0.2686, 0.4895, 0.289]}, {"w": "(see", "b": [0.4964, 0.2686, 0.5275, 0.289]}, {"w": "Figure", "b": [0.5344, 0.2686, 0.5858, 0.289]}, {"w": "3-5).", "b": [0.5928, 0.2686, 0.6303, 0.289]}, {"w": "To", "b": [0.6373, 0.2686, 0.6577, 0.289]}, {"w": "summarize", "b": [0.6646, 0.2686, 0.7531, 0.289]}, {"w": "this", "b": [0.7601, 0.2686, 0.7893, 0.289]}, {"w": "curve", "b": [0.7963, 0.2686, 0.8408, 0.289]}, {"w": "into", "b": [0.1592, 0.2867, 0.1912, 0.3071]}, {"w": "a", "b": [0.1974, 0.2867, 0.2061, 0.3071]}, {"w": "single", "b": [0.2124, 0.2867, 0.2586, 0.3071]}, {"w": "number,", "b": [0.2648, 0.2867, 0.3312, 0.3071]}, {"w": "we", "b": [0.3375, 0.2867, 0.3595, 0.3071]}, {"w": "could", "b": [0.3658, 0.2867, 0.4103, 0.3071]}, {"w": "compute", "b": [0.4166, 0.2867, 0.4864, 0.3071]}, {"w": "its", "b": [0.4926, 0.2867, 0.5113, 0.3071]}, {"w": "Area", "b": [0.5175, 0.2867, 0.5557, 0.3071]}, {"w": "Under", "b": [0.562, 0.2867, 0.6128, 0.3071]}, {"w": "the", "b": [0.6191, 0.2867, 0.6442, 0.3071]}, {"w": "Curve", "b": [0.6504, 0.2867, 0.6997, 0.3071]}, {"w": "(AUC).", "b": [0.706, 0.2867, 0.7646, 0.3071]}, {"w": "But", "b": [0.7708, 0.2867, 0.7991, 0.3071]}, {"w": "note", "b": [0.8053, 0.2867, 0.8408, 0.3071]}, {"w": "that", "b": [0.1592, 0.3049, 0.1903, 0.3253]}, {"w": "the", "b": [0.1971, 0.3049, 0.2221, 0.3253]}, {"w": "Precision/Recall", "b": [0.2289, 0.3049, 0.3577, 0.3253]}, {"w": "curve", "b": [0.3645, 0.3049, 0.4089, 0.3253]}, {"w": "may", "b": [0.4157, 0.3049, 0.4495, 0.3253]}, {"w": "contain", "b": [0.4563, 0.3049, 0.5162, 0.3253]}, {"w": "a", "b": [0.523, 0.3049, 0.5317, 0.3253]}, {"w": "few", "b": [0.5385, 0.3049, 0.5664, 0.3253]}, {"w": "sections", "b": [0.5732, 0.3049, 0.6369, 0.3253]}, {"w": "where", "b": [0.6437, 0.3049, 0.6921, 0.3253]}, {"w": "precision", "b": [0.6989, 0.3049, 0.7724, 0.3253]}, {"w": "actually", "b": [0.7792, 0.3049, 0.8408, 0.3253]}, {"w": "goes", "b": [0.1592, 0.323, 0.1943, 0.3434]}, {"w": "up", "b": [0.2006, 0.323, 0.2215, 0.3434]}, {"w": "when", "b": [0.2278, 0.323, 0.2712, 0.3434]}, {"w": "recall", "b": [0.2775, 0.323, 0.3204, 0.3434]}, {"w": "increases,", "b": [0.3267, 0.323, 0.4033, 0.3434]}, {"w": "especially", "b": [0.4095, 0.323, 0.4856, 0.3434]}, {"w": "at", "b": [0.4919, 0.323, 0.5063, 0.3434]}, {"w": "low", "b": [0.5125, 0.323, 0.5412, 0.3434]}, {"w": "recall", "b": [0.5475, 0.323, 0.5904, 0.3434]}, {"w": "values", "b": [0.5967, 0.323, 0.6458, 0.3434]}, {"w": "(you", "b": [0.6521, 0.323, 0.6887, 0.3434]}, {"w": "can", "b": [0.695, 0.323, 0.7229, 0.3434]}, {"w": "see", "b": [0.7292, 0.323, 0.7533, 0.3434]}, {"w": "this", "b": [0.7596, 0.323, 0.7888, 0.3434]}, {"w": "at", "b": [0.7951, 0.323, 0.8094, 0.3434]}, {"w": "the", "b": [0.8157, 0.323, 0.8408, 0.3434]}, {"w": "top", "b": [0.1592, 0.3412, 0.1858, 0.3616]}, {"w": "left", "b": [0.1903, 0.3412, 0.2157, 0.3616]}, {"w": "of", "b": [0.2202, 0.3412, 0.2362, 0.3616]}, {"w": "Figure", "b": [0.2407, 0.3412, 0.2921, 0.3616]}, {"w": "3-5).", "b": [0.2966, 0.3412, 0.3341, 0.3616]}, {"w": "This", "b": [0.3386, 0.3412, 0.374, 0.3616]}, {"w": "is", "b": [0.3785, 0.3412, 0.3911, 0.3616]}, {"w": "one", "b": [0.3957, 0.3412, 0.4251, 0.3616]}, {"w": "of", "b": [0.4296, 0.3412, 0.4456, 0.3616]}, {"w": "the", "b": [0.4501, 0.3412, 0.4751, 0.3616]}, {"w": "motivations", "b": [0.4796, 0.3412, 0.5745, 0.3616]}, {"w": "for", "b": [0.579, 0.3412, 0.6024, 0.3616]}, {"w": "the", "b": [0.6069, 0.3412, 0.632, 0.3616]}, {"w": "mAP", "b": [0.6365, 0.3412, 0.6776, 0.3616]}, {"w": "metric.", "b": [0.6821, 0.3412, 0.7384, 0.3616]}]}, {"id": "b_3", "type": "paragraph", "text": "Suppose the classifier has a 90% precision at 10% recall, but a 96% precision at 20% recall: there’s really no tradeoff here: it simply makes more sense to use the classifier at 20% recall rather than at 10% recall, as you will get both higher recall and higher precision. So instead of looking at the precision at 10% recall, we should really be looking at the maximum precision that the classifier can offer with at least 10% recall. It would be 96%, not 90%. So one way to get a fair idea of the model’s performance is to compute the maximum precision you can get with at least 0% recall, then 10% recall, 20%, and so on up to 100%, and then calculate the mean of these maximum precisions. This is called the Average Precision (AP) metric. Now when there are more than 2 classes, we can compute the AP for each class, and then compute the mean AP (mAP). That’s it!", "words": [{"w": "Suppose", "b": [0.1592, 0.3684, 0.2258, 0.3888]}, {"w": "the", "b": [0.2318, 0.3684, 0.2569, 0.3888]}, {"w": "classifier", "b": [0.263, 0.3684, 0.332, 0.3888]}, {"w": "has", "b": [0.338, 0.3684, 0.3646, 0.3888]}, {"w": "a", "b": [0.3707, 0.3684, 0.3794, 0.3888]}, {"w": "90%", "b": [0.3854, 0.3684, 0.4195, 0.3888]}, {"w": "precision", "b": [0.4256, 0.3684, 0.499, 0.3888]}, {"w": "at", "b": [0.5051, 0.3684, 0.5195, 0.3888]}, {"w": "10%", "b": [0.5255, 0.3684, 0.5596, 0.3888]}, {"w": "recall,", "b": [0.5656, 0.3684, 0.6131, 0.3888]}, {"w": "but", "b": [0.6191, 0.3684, 0.6458, 0.3888]}, {"w": "a", "b": [0.6519, 0.3684, 0.6606, 0.3888]}, {"w": "96%", "b": [0.6666, 0.3684, 0.7007, 0.3888]}, {"w": "precision", "b": [0.7067, 0.3684, 0.7802, 0.3888]}, {"w": "at", "b": [0.7863, 0.3684, 0.8007, 0.3888]}, {"w": "20%", "b": [0.8067, 0.3684, 0.8408, 0.3888]}, {"w": "recall:", "b": [0.1592, 0.3865, 0.2067, 0.4069]}, {"w": "there’s", "b": [0.2125, 0.3865, 0.2621, 0.4069]}, {"w": "really", "b": [0.2679, 0.3865, 0.3116, 0.4069]}, {"w": "no", "b": [0.3174, 0.3865, 0.3384, 0.4069]}, {"w": "tradeoff", "b": [0.3442, 0.3865, 0.4071, 0.4069]}, {"w": "here:", "b": [0.413, 0.3865, 0.4523, 0.4069]}, {"w": "it", "b": [0.4582, 0.3865, 0.4695, 0.4069]}, {"w": "simply", "b": [0.4754, 0.3865, 0.5284, 0.4069]}, {"w": "makes", "b": [0.5342, 0.3865, 0.5848, 0.4069]}, {"w": "more", "b": [0.5906, 0.3865, 0.6328, 0.4069]}, {"w": "sense", "b": [0.6386, 0.3865, 0.6809, 0.4069]}, {"w": "to", "b": [0.6867, 0.3865, 0.7029, 0.4069]}, {"w": "use", "b": [0.7088, 0.3865, 0.735, 0.4069]}, {"w": "the", "b": [0.7409, 0.3865, 0.7659, 0.4069]}, {"w": "classifier", "b": [0.7718, 0.3865, 0.8408, 0.4069]}, {"w": "at", "b": [0.1592, 0.4047, 0.1736, 0.425]}, {"w": "20%", "b": [0.1798, 0.4047, 0.2138, 0.425]}, {"w": "recall", "b": [0.22, 0.4047, 0.2629, 0.425]}, {"w": "rather", "b": [0.2691, 0.4047, 0.3172, 0.425]}, {"w": "than", "b": [0.3233, 0.4047, 0.3596, 0.425]}, {"w": "at", "b": [0.3657, 0.4047, 0.3801, 0.425]}, {"w": "10%", "b": [0.3862, 0.4047, 0.4203, 0.425]}, {"w": "recall,", "b": [0.4265, 0.4047, 0.4739, 0.425]}, {"w": "as", "b": [0.4801, 0.4047, 0.4961, 0.425]}, {"w": "you", "b": [0.5022, 0.4047, 0.532, 0.425]}, {"w": "will", "b": [0.5381, 0.4047, 0.5671, 0.425]}, {"w": "get", "b": [0.5732, 0.4047, 0.597, 0.425]}, {"w": "both", "b": [0.6032, 0.4047, 0.64, 0.425]}, {"w": "higher", "b": [0.6462, 0.4047, 0.6977, 0.425]}, {"w": "recall", "b": [0.7039, 0.4047, 0.7468, 0.425]}, {"w": "and", "b": [0.753, 0.4047, 0.783, 0.425]}, {"w": "higher", "b": [0.7892, 0.4047, 0.8408, 0.425]}, {"w": "precision.", "b": [0.1592, 0.4228, 0.2372, 0.4432]}, {"w": "So", "b": [0.2445, 0.4228, 0.2641, 0.4432]}, {"w": "instead", "b": [0.2714, 0.4228, 0.3285, 0.4432]}, {"w": "of", "b": [0.3358, 0.4228, 0.3518, 0.4432]}, {"w": "looking", "b": [0.3591, 0.4228, 0.4196, 0.4432]}, {"w": "at", "b": [0.427, 0.4228, 0.4413, 0.4432]}, {"w": "the", "b": [0.4486, 0.4228, 0.4737, 0.4432]}, {"w": "precision", "b": [0.481, 0.4228, 0.5545, 0.4432]}, {"w": "at", "b": [0.5618, 0.4226, 0.5772, 0.4432]}, {"w": "10%", "b": [0.5845, 0.4228, 0.6186, 0.4432]}, {"w": "recall,", "b": [0.6259, 0.4228, 0.6733, 0.4432]}, {"w": "we", "b": [0.6806, 0.4228, 0.7027, 0.4432]}, {"w": "should", "b": [0.71, 0.4228, 0.764, 0.4432]}, {"w": "really", "b": [0.7713, 0.4228, 0.8149, 0.4432]}, {"w": "be", "b": [0.8223, 0.4228, 0.8408, 0.4432]}, {"w": "looking", "b": [0.1592, 0.4409, 0.2198, 0.4613]}, {"w": "at", "b": [0.2247, 0.4409, 0.2391, 0.4613]}, {"w": "the", "b": [0.244, 0.4409, 0.2691, 0.4613]}, {"w": "maximum", "b": [0.274, 0.4407, 0.355, 0.4613]}, {"w": "precision", "b": [0.3599, 0.4409, 0.4334, 0.4613]}, {"w": "that", "b": [0.4383, 0.4409, 0.4693, 0.4613]}, {"w": "the", "b": [0.4742, 0.4409, 0.4993, 0.4613]}, {"w": "classifier", "b": [0.5042, 0.4409, 0.5732, 0.4613]}, {"w": "can", "b": [0.5782, 0.4409, 0.6061, 0.4613]}, {"w": "offer", "b": [0.611, 0.4409, 0.6487, 0.4613]}, {"w": "with", "b": [0.6536, 0.4409, 0.6892, 0.4613]}, {"w": "at", "b": [0.6941, 0.4407, 0.7095, 0.4613]}, {"w": "least", "b": [0.714, 0.4407, 0.749, 0.4613]}, {"w": "10%", "b": [0.7544, 0.4409, 0.7884, 0.4613]}, {"w": "recall.", "b": [0.7929, 0.4409, 0.8404, 0.4613]}, {"w": "It", "b": [0.1592, 0.4591, 0.1713, 0.4795]}, {"w": "would", "b": [0.1764, 0.4591, 0.2262, 0.4795]}, {"w": "be", "b": [0.2313, 0.4591, 0.2498, 0.4795]}, {"w": "96%,", "b": [0.255, 0.4591, 0.2936, 0.4795]}, {"w": "not", "b": [0.2987, 0.4591, 0.3257, 0.4795]}, {"w": "90%.", "b": [0.3309, 0.4591, 0.3695, 0.4795]}, {"w": "So", "b": [0.3746, 0.4591, 0.3942, 0.4795]}, {"w": "one", "b": [0.3993, 0.4591, 0.4287, 0.4795]}, {"w": "way", "b": [0.4339, 0.4591, 0.4649, 0.4795]}, {"w": "to", "b": [0.4701, 0.4591, 0.4862, 0.4795]}, {"w": "get", "b": [0.4914, 0.4591, 0.5152, 0.4795]}, {"w": "a", "b": [0.5203, 0.4591, 0.529, 0.4795]}, {"w": "fair", "b": [0.5342, 0.4591, 0.5615, 0.4795]}, {"w": "idea", "b": [0.5666, 0.4591, 0.5995, 0.4795]}, {"w": "of", "b": [0.6047, 0.4591, 0.6207, 0.4795]}, {"w": "the", "b": [0.6258, 0.4591, 0.6509, 0.4795]}, {"w": "model’s", "b": [0.6561, 0.4591, 0.7157, 0.4795]}, {"w": "performance", "b": [0.7208, 0.4591, 0.823, 0.4795]}, {"w": "is", "b": [0.8282, 0.4591, 0.8408, 0.4795]}, {"w": "to", "b": [0.1592, 0.4772, 0.1754, 0.4976]}, {"w": "compute", "b": [0.183, 0.4772, 0.2528, 0.4976]}, {"w": "the", "b": [0.2603, 0.4772, 0.2854, 0.4976]}, {"w": "maximum", "b": [0.293, 0.4772, 0.3753, 0.4976]}, {"w": "precision", "b": [0.3828, 0.4772, 0.4563, 0.4976]}, {"w": "you", "b": [0.4639, 0.4772, 0.4936, 0.4976]}, {"w": "can", "b": [0.5012, 0.4772, 0.5291, 0.4976]}, {"w": "get", "b": [0.5367, 0.4772, 0.5605, 0.4976]}, {"w": "with", "b": [0.568, 0.4772, 0.6036, 0.4976]}, {"w": "at", "b": [0.6111, 0.4772, 0.6255, 0.4976]}, {"w": "least", "b": [0.6331, 0.4772, 0.6686, 0.4976]}, {"w": "0%", "b": [0.6761, 0.4772, 0.7007, 0.4976]}, {"w": "recall,", "b": [0.7082, 0.4772, 0.7557, 0.4976]}, {"w": "then", "b": [0.7632, 0.4772, 0.7992, 0.4976]}, {"w": "10%", "b": [0.8067, 0.4772, 0.8408, 0.4976]}, {"w": "recall,", "b": [0.1592, 0.4954, 0.2067, 0.5158]}, {"w": "20%,", "b": [0.2133, 0.4954, 0.2518, 0.5158]}, {"w": "and", "b": [0.2584, 0.4954, 0.2885, 0.5158]}, {"w": "so", "b": [0.295, 0.4954, 0.3124, 0.5158]}, {"w": "on", "b": [0.319, 0.4954, 0.34, 0.5158]}, {"w": "up", "b": [0.3466, 0.4954, 0.3675, 0.5158]}, {"w": "to", "b": [0.3741, 0.4954, 0.3902, 0.5158]}, {"w": "100%,", "b": [0.3968, 0.4954, 0.4449, 0.5158]}, {"w": "and", "b": [0.4515, 0.4954, 0.4815, 0.5158]}, {"w": "then", "b": [0.4881, 0.4954, 0.524, 0.5158]}, {"w": "calculate", "b": [0.5306, 0.4954, 0.5995, 0.5158]}, {"w": "the", "b": [0.6061, 0.4954, 0.6311, 0.5158]}, {"w": "mean", "b": [0.6377, 0.4954, 0.682, 0.5158]}, {"w": "of", "b": [0.6885, 0.4954, 0.7045, 0.5158]}, {"w": "these", "b": [0.7111, 0.4954, 0.7519, 0.5158]}, {"w": "maximum", "b": [0.7585, 0.4954, 0.8408, 0.5158]}, {"w": "precisions.", "b": [0.1592, 0.5135, 0.2445, 0.5339]}, {"w": "This", "b": [0.2492, 0.5135, 0.2846, 0.5339]}, {"w": "is", "b": [0.2892, 0.5135, 0.3018, 0.5339]}, {"w": "called", "b": [0.3065, 0.5135, 0.3526, 0.5339]}, {"w": "the", "b": [0.3572, 0.5135, 0.3823, 0.5339]}, {"w": "Average", "b": [0.3869, 0.5133, 0.4494, 0.5339]}, {"w": "Precision", "b": [0.4539, 0.5133, 0.5242, 0.5339]}, {"w": "(AP)", "b": [0.529, 0.5135, 0.5676, 0.5339]}, {"w": "metric.", "b": [0.5722, 0.5135, 0.6286, 0.5339]}, {"w": "Now", "b": [0.6332, 0.5135, 0.6712, 0.5339]}, {"w": "when", "b": [0.6758, 0.5135, 0.7193, 0.5339]}, {"w": "there", "b": [0.7239, 0.5135, 0.7648, 0.5339]}, {"w": "are", "b": [0.7695, 0.5135, 0.794, 0.5339]}, {"w": "more", "b": [0.7986, 0.5135, 0.8408, 0.5339]}, {"w": "than", "b": [0.1592, 0.5316, 0.1954, 0.552]}, {"w": "2", "b": [0.2003, 0.5316, 0.2099, 0.552]}, {"w": "classes,", "b": [0.2148, 0.5316, 0.2717, 0.552]}, {"w": "we", "b": [0.2766, 0.5316, 0.2986, 0.552]}, {"w": "can", "b": [0.3035, 0.5316, 0.3315, 0.552]}, {"w": "compute", "b": [0.3364, 0.5316, 0.4062, 0.552]}, {"w": "the", "b": [0.4111, 0.5316, 0.4362, 0.552]}, {"w": "AP", "b": [0.4411, 0.5316, 0.466, 0.552]}, {"w": "for", "b": [0.4709, 0.5316, 0.4942, 0.552]}, {"w": "each", "b": [0.4991, 0.5316, 0.5353, 0.552]}, {"w": "class,", "b": [0.5402, 0.5316, 0.5814, 0.552]}, {"w": "and", "b": [0.5863, 0.5316, 0.6163, 0.552]}, {"w": "then", "b": [0.6212, 0.5316, 0.6572, 0.552]}, {"w": "compute", "b": [0.6621, 0.5316, 0.7319, 0.552]}, {"w": "the", "b": [0.7368, 0.5316, 0.7618, 0.552]}, {"w": "mean", "b": [0.7667, 0.5316, 0.811, 0.552]}, {"w": "AP", "b": [0.8159, 0.5316, 0.8408, 0.552]}, {"w": "(mAP).", "b": [0.1592, 0.5498, 0.2186, 0.5702]}, {"w": "That’s", "b": [0.2231, 0.5498, 0.2696, 0.5702]}, {"w": "it!", "b": [0.2741, 0.5498, 0.291, 0.5702]}]}, {"id": "b_4", "type": "paragraph", "text": "However, in an object detection systems, there is an additional level of complexity: what if the system detected the correct class, but at the wrong location (i.e., the bounding box is completely off)? Surely we should not count this as a positive predic‐ tion. So one approach is to define an IOU threshold: for example, we may consider that a prediction is correct only if the IOU is greater than, say, 0.5, and the predicted class is correct. The corresponding mAP is generally noted mAP@0.5 (or mAP@50%, or sometimes just AP50). In some competitions (such as the Pascal VOC challenge), this is what is done. In others (such as the COCO competition), the mAP is computed for different IOU thresholds (0.50, 0.55, 0.60, …, 0.95), and the final metric is the mean of all these mAPs (noted AP@[.50:.95] or AP@[.50:0.05:.95]). Yes, that’s a mean mean average.", "words": [{"w": "However,", "b": [0.1592, 0.577, 0.2343, 0.5974]}, {"w": "in", "b": [0.2412, 0.577, 0.2574, 0.5974]}, {"w": "an", "b": [0.2643, 0.577, 0.2839, 0.5974]}, {"w": "object", "b": [0.2908, 0.577, 0.3389, 0.5974]}, {"w": "detection", "b": [0.3458, 0.577, 0.42, 0.5974]}, {"w": "systems,", "b": [0.4269, 0.577, 0.4931, 0.5974]}, {"w": "there", "b": [0.5, 0.577, 0.5409, 0.5974]}, {"w": "is", "b": [0.5478, 0.577, 0.5604, 0.5974]}, {"w": "an", "b": [0.5673, 0.577, 0.5868, 0.5974]}, {"w": "additional", "b": [0.5937, 0.577, 0.6748, 0.5974]}, {"w": "level", "b": [0.6817, 0.577, 0.7178, 0.5974]}, {"w": "of", "b": [0.7247, 0.577, 0.7407, 0.5974]}, {"w": "complexity:", "b": [0.7476, 0.577, 0.8408, 0.5974]}, {"w": "what", "b": [0.1592, 0.5951, 0.1978, 0.6155]}, {"w": "if", "b": [0.2065, 0.5951, 0.2177, 0.6155]}, {"w": "the", "b": [0.2265, 0.5951, 0.2516, 0.6155]}, {"w": "system", "b": [0.2603, 0.5951, 0.3147, 0.6155]}, {"w": "detected", "b": [0.3234, 0.5951, 0.3902, 0.6155]}, {"w": "the", "b": [0.3989, 0.5951, 0.424, 0.6155]}, {"w": "correct", "b": [0.4327, 0.5951, 0.4888, 0.6155]}, {"w": "class,", "b": [0.4976, 0.5951, 0.5388, 0.6155]}, {"w": "but", "b": [0.5475, 0.5951, 0.5742, 0.6155]}, {"w": "at", "b": [0.5829, 0.5951, 0.5973, 0.6155]}, {"w": "the", "b": [0.6061, 0.5951, 0.6311, 0.6155]}, {"w": "wrong", "b": [0.6399, 0.5951, 0.6911, 0.6155]}, {"w": "location", "b": [0.6998, 0.5951, 0.764, 0.6155]}, {"w": "(i.e.,", "b": [0.7728, 0.5951, 0.807, 0.6155]}, {"w": "the", "b": [0.8157, 0.5951, 0.8408, 0.6155]}, {"w": "bounding", "b": [0.1592, 0.6133, 0.2368, 0.6337]}, {"w": "box", "b": [0.2414, 0.6133, 0.271, 0.6337]}, {"w": "is", "b": [0.2756, 0.6133, 0.2882, 0.6337]}, {"w": "completely", "b": [0.2929, 0.6133, 0.3797, 0.6337]}, {"w": "off)?", "b": [0.3844, 0.6133, 0.4222, 0.6337]}, {"w": "Surely", "b": [0.4269, 0.6133, 0.4767, 0.6337]}, {"w": "we", "b": [0.4814, 0.6133, 0.5034, 0.6337]}, {"w": "should", "b": [0.5081, 0.6133, 0.5621, 0.6337]}, {"w": "not", "b": [0.5667, 0.6133, 0.5938, 0.6337]}, {"w": "count", "b": [0.5984, 0.6133, 0.644, 0.6337]}, {"w": "this", "b": [0.6487, 0.6133, 0.6779, 0.6337]}, {"w": "as", "b": [0.6826, 0.6133, 0.6986, 0.6337]}, {"w": "a", "b": [0.7032, 0.6133, 0.7119, 0.6337]}, {"w": "positive", "b": [0.7166, 0.6133, 0.7787, 0.6337]}, {"w": "predic‐", "b": [0.7833, 0.6133, 0.8408, 0.6337]}, {"w": "tion.", "b": [0.1592, 0.6314, 0.1961, 0.6518]}, {"w": "So", "b": [0.2025, 0.6314, 0.222, 0.6518]}, {"w": "one", "b": [0.2283, 0.6314, 0.2577, 0.6518]}, {"w": "approach", "b": [0.2641, 0.6314, 0.3384, 0.6518]}, {"w": "is", "b": [0.3448, 0.6314, 0.3574, 0.6518]}, {"w": "to", "b": [0.3637, 0.6314, 0.3799, 0.6518]}, {"w": "define", "b": [0.3862, 0.6314, 0.4356, 0.6518]}, {"w": "an", "b": [0.442, 0.6314, 0.4616, 0.6518]}, {"w": "IOU", "b": [0.4679, 0.6314, 0.5041, 0.6518]}, {"w": "threshold:", "b": [0.5105, 0.6314, 0.5909, 0.6518]}, {"w": "for", "b": [0.5973, 0.6314, 0.6206, 0.6518]}, {"w": "example,", "b": [0.627, 0.6314, 0.6977, 0.6518]}, {"w": "we", "b": [0.7041, 0.6314, 0.7261, 0.6518]}, {"w": "may", "b": [0.7325, 0.6314, 0.7662, 0.6518]}, {"w": "consider", "b": [0.7725, 0.6314, 0.8408, 0.6518]}, {"w": "that", "b": [0.1592, 0.6496, 0.1903, 0.6699]}, {"w": "a", "b": [0.1958, 0.6496, 0.2045, 0.6699]}, {"w": "prediction", "b": [0.21, 0.6496, 0.2927, 0.6699]}, {"w": "is", "b": [0.2982, 0.6496, 0.3108, 0.6699]}, {"w": "correct", "b": [0.3163, 0.6496, 0.3724, 0.6699]}, {"w": "only", "b": [0.3779, 0.6496, 0.413, 0.6699]}, {"w": "if", "b": [0.4184, 0.6496, 0.4296, 0.6699]}, {"w": "the", "b": [0.4351, 0.6496, 0.4602, 0.6699]}, {"w": "IOU", "b": [0.4657, 0.6496, 0.5019, 0.6699]}, {"w": "is", "b": [0.5074, 0.6496, 0.52, 0.6699]}, {"w": "greater", "b": [0.5255, 0.6496, 0.5807, 0.6699]}, {"w": "than,", "b": [0.5862, 0.6496, 0.627, 0.6699]}, {"w": "say,", "b": [0.6324, 0.6496, 0.6603, 0.6699]}, {"w": "0.5,", "b": [0.6658, 0.6496, 0.6939, 0.6699]}, {"w": "and", "b": [0.6993, 0.6496, 0.7294, 0.6699]}, {"w": "the", "b": [0.7349, 0.6496, 0.76, 0.6699]}, {"w": "predicted", "b": [0.7654, 0.6496, 0.8408, 0.6699]}, {"w": "class", "b": [0.1592, 0.6677, 0.1959, 0.6881]}, {"w": "is", "b": [0.2008, 0.6677, 0.2134, 0.6881]}, {"w": "correct.", "b": [0.2183, 0.6677, 0.2789, 0.6881]}, {"w": "The", "b": [0.2838, 0.6677, 0.315, 0.6881]}, {"w": "corresponding", "b": [0.3199, 0.6677, 0.4362, 0.6881]}, {"w": "mAP", "b": [0.441, 0.6677, 0.4822, 0.6881]}, {"w": "is", "b": [0.487, 0.6677, 0.4996, 0.6881]}, {"w": "generally", "b": [0.5045, 0.6677, 0.5767, 0.6881]}, {"w": "noted", "b": [0.5816, 0.6677, 0.6275, 0.6881]}, {"w": "mAP@0.5", "b": [0.6324, 0.6677, 0.712, 0.6881]}, {"w": "(or", "b": [0.7169, 0.6677, 0.7413, 0.6881]}, {"w": "mAP@50%,", "b": [0.7461, 0.6677, 0.8408, 0.6881]}, {"w": "or", "b": [0.1592, 0.6858, 0.1767, 0.7062]}, {"w": "sometimes", "b": [0.1831, 0.6858, 0.2685, 0.7062]}, {"w": "just", "b": [0.2748, 0.6858, 0.3038, 0.7062]}, {"w": "AP50).", "b": [0.3101, 0.6858, 0.3584, 0.7072]}, {"w": "In", "b": [0.3647, 0.6858, 0.3824, 0.7062]}, {"w": "some", "b": [0.3887, 0.6858, 0.4308, 0.7062]}, {"w": "competitions", "b": [0.4371, 0.6858, 0.5414, 0.7062]}, {"w": "(such", "b": [0.5477, 0.6858, 0.5914, 0.7062]}, {"w": "as", "b": [0.5977, 0.6858, 0.6137, 0.7062]}, {"w": "the", "b": [0.6201, 0.6858, 0.6451, 0.7062]}, {"w": "Pascal", "b": [0.6515, 0.6858, 0.7003, 0.7062]}, {"w": "VOC", "b": [0.7067, 0.6858, 0.7483, 0.7062]}, {"w": "challenge),", "b": [0.7546, 0.6858, 0.8408, 0.7062]}, {"w": "this", "b": [0.1592, 0.704, 0.1885, 0.7244]}, {"w": "is", "b": [0.193, 0.704, 0.2056, 0.7244]}, {"w": "what", "b": [0.2101, 0.704, 0.2486, 0.7244]}, {"w": "is", "b": [0.2531, 0.704, 0.2657, 0.7244]}, {"w": "done.", "b": [0.2703, 0.704, 0.3147, 0.7244]}, {"w": "In", "b": [0.3192, 0.704, 0.3368, 0.7244]}, {"w": "others", "b": [0.3413, 0.704, 0.3911, 0.7244]}, {"w": "(such", "b": [0.3956, 0.704, 0.4393, 0.7244]}, {"w": "as", "b": [0.4438, 0.704, 0.4598, 0.7244]}, {"w": "the", "b": [0.4643, 0.704, 0.4894, 0.7244]}, {"w": "COCO", "b": [0.4939, 0.704, 0.5503, 0.7244]}, {"w": "competition),", "b": [0.5548, 0.704, 0.6631, 0.7244]}, {"w": "the", "b": [0.6676, 0.704, 0.6927, 0.7244]}, {"w": "mAP", "b": [0.6972, 0.704, 0.7383, 0.7244]}, {"w": "is", "b": [0.7428, 0.704, 0.7554, 0.7244]}, {"w": "computed", "b": [0.7599, 0.704, 0.8402, 0.7244]}, {"w": "for", "b": [0.1592, 0.7221, 0.1826, 0.7425]}, {"w": "different", "b": [0.1899, 0.7221, 0.2582, 0.7425]}, {"w": "IOU", "b": [0.2655, 0.7221, 0.3017, 0.7425]}, {"w": "thresholds", "b": [0.3089, 0.7221, 0.3922, 0.7425]}, {"w": "(0.50,", "b": [0.3995, 0.7221, 0.4439, 0.7425]}, {"w": "0.55,", "b": [0.4512, 0.7221, 0.4889, 0.7425]}, {"w": "0.60,", "b": [0.4962, 0.7221, 0.5338, 0.7425]}, {"w": "…,", "b": [0.5411, 0.7221, 0.5648, 0.7425]}, {"w": "0.95),", "b": [0.5721, 0.7221, 0.6166, 0.7425]}, {"w": "and", "b": [0.6239, 0.7221, 0.654, 0.7425]}, {"w": "the", "b": [0.6612, 0.7221, 0.6863, 0.7425]}, {"w": "final", "b": [0.6936, 0.7221, 0.7294, 0.7425]}, {"w": "metric", "b": [0.7367, 0.7221, 0.7885, 0.7425]}, {"w": "is", "b": [0.7958, 0.7221, 0.8084, 0.7425]}, {"w": "the", "b": [0.8157, 0.7221, 0.8408, 0.7425]}, {"w": "mean", "b": [0.1592, 0.7403, 0.2035, 0.7607]}, {"w": "of", "b": [0.2085, 0.7403, 0.2245, 0.7607]}, {"w": "all", "b": [0.2296, 0.7403, 0.2483, 0.7607]}, {"w": "these", "b": [0.2534, 0.7403, 0.2942, 0.7607]}, {"w": "mAPs", "b": [0.2992, 0.7403, 0.3471, 0.7607]}, {"w": "(noted", "b": [0.3521, 0.7403, 0.4049, 0.7607]}, {"w": "AP@[.50:.95]", "b": [0.41, 0.7403, 0.5151, 0.7607]}, {"w": "or", "b": [0.5202, 0.7403, 0.5377, 0.7607]}, {"w": "AP@[.50:0.05:.95]).", "b": [0.5427, 0.7403, 0.6969, 0.7607]}, {"w": "Yes,", "b": [0.7019, 0.7403, 0.7323, 0.7607]}, {"w": "that’s", "b": [0.7374, 0.7403, 0.7777, 0.7607]}, {"w": "a", "b": [0.7828, 0.7403, 0.7915, 0.7607]}, {"w": "mean", "b": [0.7965, 0.7403, 0.8408, 0.7607]}, {"w": "mean", "b": [0.1592, 0.7584, 0.2035, 0.7788]}, {"w": "average.", "b": [0.208, 0.7584, 0.2723, 0.7788]}]}, {"id": "b_5", "type": "paragraph", "text": "Several YOLO implementations built using TensorFlow are available on github, some with pretrained weights. At the time of writing, they are based on TensorFlow 1, but by the time you read this, TF 2 implementations will certainly be available. Moreover, other object detection models are available in the TensorFlow Models project, many", "words": [{"w": "Several", "b": [0.1429, 0.8085, 0.2022, 0.83]}, {"w": "YOLO", "b": [0.2077, 0.8085, 0.2623, 0.83]}, {"w": "implementations", "b": [0.2677, 0.8085, 0.4087, 0.83]}, {"w": "built", "b": [0.4141, 0.8085, 0.453, 0.83]}, {"w": "using", "b": [0.4584, 0.8085, 0.5038, 0.83]}, {"w": "TensorFlow", "b": [0.5093, 0.8085, 0.6075, 0.83]}, {"w": "are", "b": [0.613, 0.8085, 0.6387, 0.83]}, {"w": "available", "b": [0.6441, 0.8085, 0.7164, 0.83]}, {"w": "on", "b": [0.7218, 0.8085, 0.7439, 0.83]}, {"w": "github,", "b": [0.7493, 0.8085, 0.8075, 0.83]}, {"w": "some", "b": [0.813, 0.8085, 0.8571, 0.83]}, {"w": "with", "b": [0.1429, 0.8276, 0.1802, 0.849]}, {"w": "pretrained", "b": [0.1861, 0.8276, 0.2737, 0.849]}, {"w": "weights.", "b": [0.2796, 0.8276, 0.3476, 0.849]}, {"w": "At", "b": [0.3535, 0.8276, 0.3734, 0.849]}, {"w": "the", "b": [0.3794, 0.8276, 0.4057, 0.849]}, {"w": "time", "b": [0.4117, 0.8276, 0.4495, 0.849]}, {"w": "of", "b": [0.4555, 0.8276, 0.4723, 0.849]}, {"w": "writing,", "b": [0.4782, 0.8276, 0.5436, 0.849]}, {"w": "they", "b": [0.5496, 0.8276, 0.5855, 0.849]}, {"w": "are", "b": [0.5914, 0.8276, 0.6171, 0.849]}, {"w": "based", "b": [0.6231, 0.8276, 0.6703, 0.849]}, {"w": "on", "b": [0.6763, 0.8276, 0.6983, 0.849]}, {"w": "TensorFlow", "b": [0.7042, 0.8276, 0.8025, 0.849]}, {"w": "1,", "b": [0.8084, 0.8276, 0.8232, 0.849]}, {"w": "but", "b": [0.8291, 0.8276, 0.8571, 0.849]}, {"w": "by", "b": [0.1428, 0.8466, 0.163, 0.868]}, {"w": "the", "b": [0.1681, 0.8466, 0.1945, 0.868]}, {"w": "time", "b": [0.1996, 0.8466, 0.2374, 0.868]}, {"w": "you", "b": [0.2426, 0.8466, 0.2738, 0.868]}, {"w": "read", "b": [0.2789, 0.8466, 0.3157, 0.868]}, {"w": "this,", "b": [0.3208, 0.8466, 0.3563, 0.868]}, {"w": "TF", "b": [0.3614, 0.8466, 0.3853, 0.868]}, {"w": "2", "b": [0.3904, 0.8466, 0.4004, 0.868]}, {"w": "implementations", "b": [0.4055, 0.8466, 0.5464, 0.868]}, {"w": "will", "b": [0.5515, 0.8466, 0.5819, 0.868]}, {"w": "certainly", "b": [0.5871, 0.8466, 0.6598, 0.868]}, {"w": "be", "b": [0.6649, 0.8466, 0.6843, 0.868]}, {"w": "available.", "b": [0.6895, 0.8466, 0.7665, 0.868]}, {"w": "Moreover,", "b": [0.7716, 0.8466, 0.8571, 0.868]}, {"w": "other", "b": [0.1429, 0.8657, 0.1876, 0.8871]}, {"w": "object", "b": [0.1939, 0.8657, 0.2445, 0.8871]}, {"w": "detection", "b": [0.2508, 0.8657, 0.3286, 0.8871]}, {"w": "models", "b": [0.335, 0.8657, 0.3954, 0.8871]}, {"w": "are", "b": [0.4018, 0.8657, 0.4275, 0.8871]}, {"w": "available", "b": [0.4338, 0.8657, 0.5061, 0.8871]}, {"w": "in", "b": [0.5124, 0.8657, 0.5294, 0.8871]}, {"w": "the", "b": [0.5357, 0.8657, 0.5621, 0.8871]}, {"w": "TensorFlow", "b": [0.5684, 0.8657, 0.6667, 0.8871]}, {"w": "Models", "b": [0.673, 0.8657, 0.7344, 0.8871]}, {"w": "project,", "b": [0.7408, 0.8657, 0.8041, 0.8871]}, {"w": "many", "b": [0.8105, 0.8657, 0.8571, 0.8871]}]}, {"id": "b_6", "type": "paragraph", "text": "Object Detection | 477", "words": [{"w": "Object", "b": [0.6987, 0.9225, 0.736, 0.9388]}, {"w": "Detection", "b": [0.7388, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "477", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 504, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "29 “SSD: Single Shot MultiBox Detector,” Wei Liu et al. (2015).", "words": [{"w": "29", "b": [0.1385, 0.8416, 0.1518, 0.8559]}, {"w": "“SSD:", "b": [0.1587, 0.8401, 0.195, 0.8565]}, {"w": "Single", "b": [0.1986, 0.8401, 0.2372, 0.8565]}, {"w": "Shot", "b": [0.2408, 0.8401, 0.2697, 0.8565]}, {"w": "MultiBox", "b": [0.2733, 0.8401, 0.3337, 0.8565]}, {"w": "Detector,”", "b": [0.3373, 0.8401, 0.3997, 0.8565]}, {"w": "Wei", "b": [0.4033, 0.8401, 0.4282, 0.8565]}, {"w": "Liu", "b": [0.4318, 0.8401, 0.453, 0.8565]}, {"w": "et", "b": [0.4566, 0.8401, 0.4682, 0.8565]}, {"w": "al.", "b": [0.4718, 0.8401, 0.4864, 0.8565]}, {"w": "(2015).", "b": [0.49, 0.8401, 0.5351, 0.8565]}]}, {"id": "b_1", "type": "paragraph", "text": "30 “Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks,” Shaoqing Ren et al. (2015).", "words": [{"w": "30", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "“Faster", "b": [0.1587, 0.8598, 0.2034, 0.8761]}, {"w": "R-CNN:", "b": [0.207, 0.8598, 0.2596, 0.8761]}, {"w": "Towards", "b": [0.2632, 0.8598, 0.3175, 0.8761]}, {"w": "Real-Time", "b": [0.3211, 0.8598, 0.3874, 0.8761]}, {"w": "Object", "b": [0.391, 0.8598, 0.4333, 0.8761]}, {"w": "Detection", "b": [0.4369, 0.8598, 0.4995, 0.8761]}, {"w": "with", "b": [0.5031, 0.8598, 0.5316, 0.8761]}, {"w": "Region", "b": [0.5352, 0.8598, 0.5802, 0.8761]}, {"w": "Proposal", "b": [0.5838, 0.8598, 0.64, 0.8761]}, {"w": "Networks,”", "b": [0.6436, 0.8598, 0.7129, 0.8761]}, {"w": "Shaoqing", "b": [0.7165, 0.8598, 0.776, 0.8761]}, {"w": "Ren", "b": [0.7797, 0.8598, 0.8049, 0.8761]}, {"w": "et", "b": [0.8085, 0.8598, 0.8201, 0.8761]}, {"w": "al.", "b": [0.8237, 0.8598, 0.8383, 0.8761]}, {"w": "(2015).", "b": [0.1587, 0.8749, 0.2038, 0.8912]}]}, {"id": "b_2", "type": "paragraph", "text": "with pretrained weights, and some have even been ported to TF Hub, making them extremely easy to use, such as SSD29 and Faster-RCNN.30, which are both quite popu‐ lar. SSD is also a “single shot” detection model, quite similar to YOLO, while Faster R- CNN is more complex: the image first goes through a CNN, and the output is passed to a Region Proposal Network (RPN) which proposes bounding boxes that are most likely to contain an object, and a classifier is run for each bounding box, based on the cropped output of the CNN.", "words": [{"w": "with", "b": [0.1429, 0.0791, 0.1802, 0.1005]}, {"w": "pretrained", "b": [0.1867, 0.0791, 0.2743, 0.1005]}, {"w": "weights,", "b": [0.2808, 0.0791, 0.3488, 0.1005]}, {"w": "and", "b": [0.3553, 0.0791, 0.3868, 0.1005]}, {"w": "some", "b": [0.3934, 0.0791, 0.4376, 0.1005]}, {"w": "have", "b": [0.4441, 0.0791, 0.4825, 0.1005]}, {"w": "even", "b": [0.489, 0.0791, 0.5278, 0.1005]}, {"w": "been", "b": [0.5343, 0.0791, 0.574, 0.1005]}, {"w": "ported", "b": [0.5805, 0.0791, 0.636, 0.1005]}, {"w": "to", "b": [0.6425, 0.0791, 0.6595, 0.1005]}, {"w": "TF", "b": [0.6661, 0.0791, 0.6899, 0.1005]}, {"w": "Hub,", "b": [0.6965, 0.0791, 0.7374, 0.1005]}, {"w": "making", "b": [0.7439, 0.0791, 0.8072, 0.1005]}, {"w": "them", "b": [0.8137, 0.0791, 0.8571, 0.1005]}, {"w": "extremely", "b": [0.1429, 0.0981, 0.2252, 0.1195]}, {"w": "easy", "b": [0.2306, 0.0981, 0.2658, 0.1195]}, {"w": "to", "b": [0.2711, 0.0981, 0.2881, 0.1195]}, {"w": "use,", "b": [0.2934, 0.0981, 0.3257, 0.1195]}, {"w": "such", "b": [0.331, 0.0981, 0.3697, 0.1195]}, {"w": "as", "b": [0.375, 0.0981, 0.3918, 0.1195]}, {"w": "SSD29", "b": [0.3971, 0.0981, 0.4436, 0.1195]}, {"w": "and", "b": [0.4489, 0.0981, 0.4805, 0.1195]}, {"w": "Faster-RCNN.30,", "b": [0.4858, 0.0981, 0.6217, 0.1195]}, {"w": "which", "b": [0.6271, 0.0981, 0.678, 0.1195]}, {"w": "are", "b": [0.6833, 0.0981, 0.709, 0.1195]}, {"w": "both", "b": [0.7144, 0.0981, 0.7531, 0.1195]}, {"w": "quite", "b": [0.7584, 0.0981, 0.8009, 0.1195]}, {"w": "popu‐", "b": [0.8062, 0.0981, 0.8571, 0.1195]}, {"w": "lar.", "b": [0.1429, 0.1172, 0.1684, 0.1386]}, {"w": "SSD", "b": [0.1733, 0.1172, 0.2084, 0.1386]}, {"w": "is", "b": [0.2132, 0.1172, 0.2265, 0.1386]}, {"w": "also", "b": [0.2314, 0.1172, 0.264, 0.1386]}, {"w": "a", "b": [0.2689, 0.1172, 0.2781, 0.1386]}, {"w": "“single", "b": [0.2829, 0.1172, 0.3385, 0.1386]}, {"w": "shot”", "b": [0.3434, 0.1172, 0.3869, 0.1386]}, {"w": "detection", "b": [0.3918, 0.1172, 0.4696, 0.1386]}, {"w": "model,", "b": [0.4745, 0.1172, 0.5321, 0.1386]}, {"w": "quite", "b": [0.537, 0.1172, 0.5795, 0.1386]}, {"w": "similar", "b": [0.5843, 0.1172, 0.6424, 0.1386]}, {"w": "to", "b": [0.6472, 0.1172, 0.6642, 0.1386]}, {"w": "YOLO,", "b": [0.6691, 0.1172, 0.7276, 0.1386]}, {"w": "while", "b": [0.7325, 0.1172, 0.7776, 0.1386]}, {"w": "Faster", "b": [0.7825, 0.1172, 0.8328, 0.1386]}, {"w": "R-", "b": [0.8377, 0.1172, 0.8571, 0.1386]}, {"w": "CNN", "b": [0.1428, 0.1362, 0.1877, 0.1576]}, {"w": "is", "b": [0.193, 0.1362, 0.2062, 0.1576]}, {"w": "more", "b": [0.2116, 0.1362, 0.2558, 0.1576]}, {"w": "complex:", "b": [0.2612, 0.1362, 0.3369, 0.1576]}, {"w": "the", "b": [0.3422, 0.1362, 0.3686, 0.1576]}, {"w": "image", "b": [0.3739, 0.1362, 0.4243, 0.1576]}, {"w": "first", "b": [0.4296, 0.1362, 0.4631, 0.1576]}, {"w": "goes", "b": [0.4684, 0.1362, 0.5053, 0.1576]}, {"w": "through", "b": [0.5106, 0.1362, 0.5784, 0.1576]}, {"w": "a", "b": [0.5837, 0.1362, 0.5929, 0.1576]}, {"w": "CNN,", "b": [0.5982, 0.1362, 0.6478, 0.1576]}, {"w": "and", "b": [0.6531, 0.1362, 0.6847, 0.1576]}, {"w": "the", "b": [0.69, 0.1362, 0.7163, 0.1576]}, {"w": "output", "b": [0.7217, 0.1362, 0.778, 0.1576]}, {"w": "is", "b": [0.7834, 0.1362, 0.7966, 0.1576]}, {"w": "passed", "b": [0.8019, 0.1362, 0.8571, 0.1576]}, {"w": "to", "b": [0.1429, 0.1553, 0.1598, 0.1767]}, {"w": "a", "b": [0.1659, 0.1553, 0.1751, 0.1767]}, {"w": "Region", "b": [0.1811, 0.1553, 0.2403, 0.1767]}, {"w": "Proposal", "b": [0.2463, 0.1553, 0.32, 0.1767]}, {"w": "Network", "b": [0.3261, 0.1553, 0.3992, 0.1767]}, {"w": "(RPN)", "b": [0.4053, 0.1553, 0.4599, 0.1767]}, {"w": "which", "b": [0.4659, 0.1553, 0.5168, 0.1767]}, {"w": "proposes", "b": [0.5229, 0.1553, 0.5979, 0.1767]}, {"w": "bounding", "b": [0.6039, 0.1553, 0.6853, 0.1767]}, {"w": "boxes", "b": [0.6914, 0.1553, 0.7389, 0.1767]}, {"w": "that", "b": [0.745, 0.1553, 0.7776, 0.1767]}, {"w": "are", "b": [0.7837, 0.1553, 0.8094, 0.1767]}, {"w": "most", "b": [0.8155, 0.1553, 0.8571, 0.1767]}, {"w": "likely", "b": [0.1429, 0.1743, 0.1877, 0.1957]}, {"w": "to", "b": [0.1929, 0.1743, 0.2098, 0.1957]}, {"w": "contain", "b": [0.2149, 0.1743, 0.2779, 0.1957]}, {"w": "an", "b": [0.283, 0.1743, 0.3035, 0.1957]}, {"w": "object,", "b": [0.3086, 0.1743, 0.364, 0.1957]}, {"w": "and", "b": [0.3691, 0.1743, 0.4006, 0.1957]}, {"w": "a", "b": [0.4057, 0.1743, 0.4149, 0.1957]}, {"w": "classifier", "b": [0.42, 0.1743, 0.4924, 0.1957]}, {"w": "is", "b": [0.4976, 0.1743, 0.5108, 0.1957]}, {"w": "run", "b": [0.5159, 0.1743, 0.5461, 0.1957]}, {"w": "for", "b": [0.5512, 0.1743, 0.5757, 0.1957]}, {"w": "each", "b": [0.5808, 0.1743, 0.6188, 0.1957]}, {"w": "bounding", "b": [0.6239, 0.1743, 0.7053, 0.1957]}, {"w": "box,", "b": [0.7104, 0.1743, 0.7462, 0.1957]}, {"w": "based", "b": [0.7513, 0.1743, 0.7986, 0.1957]}, {"w": "on", "b": [0.8037, 0.1743, 0.8257, 0.1957]}, {"w": "the", "b": [0.8308, 0.1743, 0.8571, 0.1957]}, {"w": "cropped", "b": [0.1429, 0.1933, 0.2117, 0.2148]}, {"w": "output", "b": [0.2164, 0.1933, 0.2728, 0.2148]}, {"w": "of", "b": [0.2775, 0.1933, 0.2943, 0.2148]}, {"w": "the", "b": [0.2991, 0.1933, 0.3254, 0.2148]}, {"w": "CNN.", "b": [0.3301, 0.1933, 0.3797, 0.2148]}]}, {"id": "b_3", "type": "paragraph", "text": "The choice of detection system depends on many factors: speed, accuracy, available pretrained models, training time, complexity, etc. The papers contain tables of met‐ rics, but there is quite a lot of variability in the testing environments, and the technol‐ ogies evolve so fast that it is difficulty to make a fair comparison that will be useful for most people and remain valid for more than a few months.", "words": [{"w": "The", "b": [0.1429, 0.2215, 0.1757, 0.2429]}, {"w": "choice", "b": [0.1826, 0.2215, 0.2364, 0.2429]}, {"w": "of", "b": [0.2433, 0.2215, 0.26, 0.2429]}, {"w": "detection", "b": [0.2669, 0.2215, 0.3448, 0.2429]}, {"w": "system", "b": [0.3516, 0.2215, 0.4088, 0.2429]}, {"w": "depends", "b": [0.4156, 0.2215, 0.4853, 0.2429]}, {"w": "on", "b": [0.4922, 0.2215, 0.5142, 0.2429]}, {"w": "many", "b": [0.5211, 0.2215, 0.5678, 0.2429]}, {"w": "factors:", "b": [0.5747, 0.2215, 0.6359, 0.2429]}, {"w": "speed,", "b": [0.6428, 0.2215, 0.6948, 0.2429]}, {"w": "accuracy,", "b": [0.7017, 0.2215, 0.778, 0.2429]}, {"w": "available", "b": [0.7849, 0.2215, 0.8571, 0.2429]}, {"w": "pretrained", "b": [0.1429, 0.2405, 0.2304, 0.2619]}, {"w": "models,", "b": [0.237, 0.2405, 0.3022, 0.2619]}, {"w": "training", "b": [0.3088, 0.2405, 0.3758, 0.2619]}, {"w": "time,", "b": [0.3824, 0.2405, 0.425, 0.2619]}, {"w": "complexity,", "b": [0.4316, 0.2405, 0.5273, 0.2619]}, {"w": "etc.", "b": [0.5339, 0.2405, 0.5627, 0.2619]}, {"w": "The", "b": [0.5693, 0.2405, 0.6021, 0.2619]}, {"w": "papers", "b": [0.6087, 0.2405, 0.6635, 0.2619]}, {"w": "contain", "b": [0.6701, 0.2405, 0.733, 0.2619]}, {"w": "tables", "b": [0.7396, 0.2405, 0.7875, 0.2619]}, {"w": "of", "b": [0.7941, 0.2405, 0.8109, 0.2619]}, {"w": "met‐", "b": [0.8175, 0.2405, 0.8572, 0.2619]}, {"w": "rics,", "b": [0.1429, 0.2596, 0.1774, 0.281]}, {"w": "but", "b": [0.1823, 0.2596, 0.2103, 0.281]}, {"w": "there", "b": [0.2152, 0.2596, 0.2581, 0.281]}, {"w": "is", "b": [0.263, 0.2596, 0.2762, 0.281]}, {"w": "quite", "b": [0.2811, 0.2596, 0.3236, 0.281]}, {"w": "a", "b": [0.3285, 0.2596, 0.3376, 0.281]}, {"w": "lot", "b": [0.3425, 0.2596, 0.3648, 0.281]}, {"w": "of", "b": [0.3697, 0.2596, 0.3864, 0.281]}, {"w": "variability", "b": [0.3913, 0.2596, 0.4755, 0.281]}, {"w": "in", "b": [0.4804, 0.2596, 0.4974, 0.281]}, {"w": "the", "b": [0.5023, 0.2596, 0.5286, 0.281]}, {"w": "testing", "b": [0.5335, 0.2596, 0.5894, 0.281]}, {"w": "environments,", "b": [0.5943, 0.2596, 0.7147, 0.281]}, {"w": "and", "b": [0.7196, 0.2596, 0.7512, 0.281]}, {"w": "the", "b": [0.7561, 0.2596, 0.7824, 0.281]}, {"w": "technol‐", "b": [0.7873, 0.2596, 0.8571, 0.281]}, {"w": "ogies", "b": [0.1429, 0.2786, 0.1853, 0.3]}, {"w": "evolve", "b": [0.1901, 0.2786, 0.243, 0.3]}, {"w": "so", "b": [0.2478, 0.2786, 0.2661, 0.3]}, {"w": "fast", "b": [0.2709, 0.2786, 0.3002, 0.3]}, {"w": "that", "b": [0.305, 0.2786, 0.3376, 0.3]}, {"w": "it", "b": [0.3424, 0.2786, 0.3544, 0.3]}, {"w": "is", "b": [0.3592, 0.2786, 0.3724, 0.3]}, {"w": "difficulty", "b": [0.3772, 0.2786, 0.4528, 0.3]}, {"w": "to", "b": [0.4576, 0.2786, 0.4746, 0.3]}, {"w": "make", "b": [0.4794, 0.2786, 0.5248, 0.3]}, {"w": "a", "b": [0.5296, 0.2786, 0.5387, 0.3]}, {"w": "fair", "b": [0.5435, 0.2786, 0.5721, 0.3]}, {"w": "comparison", "b": [0.577, 0.2786, 0.6761, 0.3]}, {"w": "that", "b": [0.6809, 0.2786, 0.7135, 0.3]}, {"w": "will", "b": [0.7183, 0.2786, 0.7487, 0.3]}, {"w": "be", "b": [0.7535, 0.2786, 0.7729, 0.3]}, {"w": "useful", "b": [0.7777, 0.2786, 0.8278, 0.3]}, {"w": "for", "b": [0.8326, 0.2786, 0.8571, 0.3]}, {"w": "most", "b": [0.1428, 0.2977, 0.1845, 0.3191]}, {"w": "people", "b": [0.1893, 0.2977, 0.2447, 0.3191]}, {"w": "and", "b": [0.2494, 0.2977, 0.281, 0.3191]}, {"w": "remain", "b": [0.2857, 0.2977, 0.3455, 0.3191]}, {"w": "valid", "b": [0.3502, 0.2977, 0.3908, 0.3191]}, {"w": "for", "b": [0.3956, 0.2977, 0.4201, 0.3191]}, {"w": "more", "b": [0.4248, 0.2977, 0.4691, 0.3191]}, {"w": "than", "b": [0.4738, 0.2977, 0.5118, 0.3191]}, {"w": "a", "b": [0.5166, 0.2977, 0.5257, 0.3191]}, {"w": "few", "b": [0.5305, 0.2977, 0.5597, 0.3191]}, {"w": "months.", "b": [0.5645, 0.2977, 0.633, 0.3191]}]}, {"id": "b_4", "type": "paragraph", "text": "Great! So we can locate objects by drawing bounding boxes around them. But per‐ haps you might want to be a bit more precise. Let’s see how to go down to the pixel level.", "words": [{"w": "Great!", "b": [0.1428, 0.3258, 0.1952, 0.3472]}, {"w": "So", "b": [0.2022, 0.3258, 0.2227, 0.3472]}, {"w": "we", "b": [0.2297, 0.3258, 0.2528, 0.3472]}, {"w": "can", "b": [0.2598, 0.3258, 0.2891, 0.3472]}, {"w": "locate", "b": [0.2961, 0.3258, 0.3448, 0.3472]}, {"w": "objects", "b": [0.3518, 0.3258, 0.41, 0.3472]}, {"w": "by", "b": [0.417, 0.3258, 0.4371, 0.3472]}, {"w": "drawing", "b": [0.4441, 0.3258, 0.5126, 0.3472]}, {"w": "bounding", "b": [0.5196, 0.3258, 0.601, 0.3472]}, {"w": "boxes", "b": [0.608, 0.3258, 0.6555, 0.3472]}, {"w": "around", "b": [0.6625, 0.3258, 0.7234, 0.3472]}, {"w": "them.", "b": [0.7304, 0.3258, 0.7786, 0.3472]}, {"w": "But", "b": [0.7856, 0.3258, 0.8152, 0.3472]}, {"w": "per‐", "b": [0.8222, 0.3258, 0.8571, 0.3472]}, {"w": "haps", "b": [0.1429, 0.3448, 0.1813, 0.3662]}, {"w": "you", "b": [0.1876, 0.3448, 0.2188, 0.3662]}, {"w": "might", "b": [0.2251, 0.3448, 0.2746, 0.3662]}, {"w": "want", "b": [0.2808, 0.3448, 0.3216, 0.3662]}, {"w": "to", "b": [0.3279, 0.3448, 0.3449, 0.3662]}, {"w": "be", "b": [0.3511, 0.3448, 0.3706, 0.3662]}, {"w": "a", "b": [0.3768, 0.3448, 0.386, 0.3662]}, {"w": "bit", "b": [0.3923, 0.3448, 0.4148, 0.3662]}, {"w": "more", "b": [0.4211, 0.3448, 0.4653, 0.3662]}, {"w": "precise.", "b": [0.4716, 0.3448, 0.5347, 0.3662]}, {"w": "Let’s", "b": [0.541, 0.3448, 0.5772, 0.3662]}, {"w": "see", "b": [0.5835, 0.3448, 0.6088, 0.3662]}, {"w": "how", "b": [0.6151, 0.3448, 0.6511, 0.3662]}, {"w": "to", "b": [0.6574, 0.3448, 0.6744, 0.3662]}, {"w": "go", "b": [0.6806, 0.3448, 0.701, 0.3662]}, {"w": "down", "b": [0.7073, 0.3448, 0.7546, 0.3662]}, {"w": "to", "b": [0.7608, 0.3448, 0.7778, 0.3662]}, {"w": "the", "b": [0.7841, 0.3448, 0.8104, 0.3662]}, {"w": "pixel", "b": [0.8167, 0.3448, 0.8571, 0.3662]}, {"w": "level.", "b": [0.1429, 0.3639, 0.1855, 0.3853]}]}, {"id": "b_5", "type": "paragraph", "text": "Semantic Segmentation", "words": [{"w": "Semantic", "b": [0.1429, 0.3983, 0.2577, 0.4325]}, {"w": "Segmentation", "b": [0.2637, 0.3983, 0.4399, 0.4325]}]}, {"id": "b_6", "type": "paragraph", "text": "In semantic segmentation, each pixel is classified according to the class of the object it belongs to (e.g., road, car, pedestrian, building, etc.), as shown in Figure 14-26. Note that different objects of the same class are not distinguished. For example, all the bicy‐ cles on the right side of the segmented image end up as one big lump of pixels. The main difficulty in this task is that when images go through a regular CNN, they grad‐ ually lose their spatial resolution (due to the layers with strides greater than 1): so a regular CNN may end up knowing that there’s a person in the image, somewhere in the bottom left of the image, but it will not be much more precise than that.", "words": [{"w": "In", "b": [0.1429, 0.4395, 0.1614, 0.4609]}, {"w": "semantic", "b": [0.1666, 0.4392, 0.2386, 0.4609]}, {"w": "segmentation,", "b": [0.2433, 0.4392, 0.3563, 0.4609]}, {"w": "each", "b": [0.3616, 0.4395, 0.3995, 0.4609]}, {"w": "pixel", "b": [0.4048, 0.4395, 0.4453, 0.4609]}, {"w": "is", "b": [0.4505, 0.4395, 0.4638, 0.4609]}, {"w": "classified", "b": [0.469, 0.4395, 0.5447, 0.4609]}, {"w": "according", "b": [0.55, 0.4395, 0.6328, 0.4609]}, {"w": "to", "b": [0.6381, 0.4395, 0.6551, 0.4609]}, {"w": "the", "b": [0.6604, 0.4395, 0.6867, 0.4609]}, {"w": "class", "b": [0.6919, 0.4395, 0.7305, 0.4609]}, {"w": "of", "b": [0.7357, 0.4395, 0.7525, 0.4609]}, {"w": "the", "b": [0.7578, 0.4395, 0.7841, 0.4609]}, {"w": "object", "b": [0.7894, 0.4395, 0.8399, 0.4609]}, {"w": "it", "b": [0.8452, 0.4395, 0.8571, 0.4609]}, {"w": "belongs", "b": [0.1429, 0.4585, 0.207, 0.4799]}, {"w": "to", "b": [0.2129, 0.4585, 0.2299, 0.4799]}, {"w": "(e.g.,", "b": [0.2358, 0.4585, 0.2759, 0.4799]}, {"w": "road,", "b": [0.2818, 0.4585, 0.325, 0.4799]}, {"w": "car,", "b": [0.331, 0.4585, 0.3601, 0.4799]}, {"w": "pedestrian,", "b": [0.366, 0.4585, 0.4582, 0.4799]}, {"w": "building,", "b": [0.4642, 0.4585, 0.5391, 0.4799]}, {"w": "etc.),", "b": [0.5451, 0.4585, 0.5858, 0.4799]}, {"w": "as", "b": [0.5917, 0.4585, 0.6085, 0.4799]}, {"w": "shown", "b": [0.6144, 0.4585, 0.6695, 0.4799]}, {"w": "in", "b": [0.6754, 0.4585, 0.6924, 0.4799]}, {"w": "Figure", "b": [0.6983, 0.4585, 0.7523, 0.4799]}, {"w": "14-26.", "b": [0.7583, 0.4585, 0.8104, 0.4799]}, {"w": "Note", "b": [0.8163, 0.4585, 0.8571, 0.4799]}, {"w": "that", "b": [0.1429, 0.4776, 0.1754, 0.499]}, {"w": "different", "b": [0.1802, 0.4776, 0.2519, 0.499]}, {"w": "objects", "b": [0.2566, 0.4776, 0.3148, 0.499]}, {"w": "of", "b": [0.3196, 0.4776, 0.3363, 0.499]}, {"w": "the", "b": [0.3411, 0.4776, 0.3674, 0.499]}, {"w": "same", "b": [0.3721, 0.4776, 0.4148, 0.499]}, {"w": "class", "b": [0.4196, 0.4776, 0.4581, 0.499]}, {"w": "are", "b": [0.4628, 0.4776, 0.4886, 0.499]}, {"w": "not", "b": [0.4933, 0.4773, 0.5202, 0.499]}, {"w": "distinguished.", "b": [0.5249, 0.4776, 0.6422, 0.499]}, {"w": "For", "b": [0.647, 0.4776, 0.676, 0.499]}, {"w": "example,", "b": [0.6807, 0.4776, 0.755, 0.499]}, {"w": "all", "b": [0.7597, 0.4776, 0.7794, 0.499]}, {"w": "the", "b": [0.7841, 0.4776, 0.8105, 0.499]}, {"w": "bicy‐", "b": [0.8152, 0.4776, 0.8571, 0.499]}, {"w": "cles", "b": [0.1429, 0.4966, 0.1734, 0.518]}, {"w": "on", "b": [0.1797, 0.4966, 0.2017, 0.518]}, {"w": "the", "b": [0.2079, 0.4966, 0.2343, 0.518]}, {"w": "right", "b": [0.2405, 0.4966, 0.2807, 0.518]}, {"w": "side", "b": [0.2869, 0.4966, 0.32, 0.518]}, {"w": "of", "b": [0.3262, 0.4966, 0.343, 0.518]}, {"w": "the", "b": [0.3492, 0.4966, 0.3756, 0.518]}, {"w": "segmented", "b": [0.3818, 0.4966, 0.4712, 0.518]}, {"w": "image", "b": [0.4774, 0.4966, 0.5278, 0.518]}, {"w": "end", "b": [0.5341, 0.4966, 0.5653, 0.518]}, {"w": "up", "b": [0.5715, 0.4966, 0.5935, 0.518]}, {"w": "as", "b": [0.5998, 0.4966, 0.6165, 0.518]}, {"w": "one", "b": [0.6228, 0.4966, 0.6537, 0.518]}, {"w": "big", "b": [0.6599, 0.4966, 0.6858, 0.518]}, {"w": "lump", "b": [0.692, 0.4966, 0.736, 0.518]}, {"w": "of", "b": [0.7422, 0.4966, 0.759, 0.518]}, {"w": "pixels.", "b": [0.7652, 0.4966, 0.8181, 0.518]}, {"w": "The", "b": [0.8243, 0.4966, 0.8572, 0.518]}, {"w": "main", "b": [0.1429, 0.5156, 0.186, 0.5371]}, {"w": "difficulty", "b": [0.1912, 0.5156, 0.2668, 0.5371]}, {"w": "in", "b": [0.2719, 0.5156, 0.2889, 0.5371]}, {"w": "this", "b": [0.2941, 0.5156, 0.3248, 0.5371]}, {"w": "task", "b": [0.33, 0.5156, 0.3635, 0.5371]}, {"w": "is", "b": [0.3686, 0.5156, 0.3819, 0.5371]}, {"w": "that", "b": [0.387, 0.5156, 0.4196, 0.5371]}, {"w": "when", "b": [0.4248, 0.5156, 0.4704, 0.5371]}, {"w": "images", "b": [0.4756, 0.5156, 0.5336, 0.5371]}, {"w": "go", "b": [0.5388, 0.5156, 0.5592, 0.5371]}, {"w": "through", "b": [0.5643, 0.5156, 0.6321, 0.5371]}, {"w": "a", "b": [0.6373, 0.5156, 0.6464, 0.5371]}, {"w": "regular", "b": [0.6516, 0.5156, 0.7111, 0.5371]}, {"w": "CNN,", "b": [0.7163, 0.5156, 0.7659, 0.5371]}, {"w": "they", "b": [0.771, 0.5156, 0.8069, 0.5371]}, {"w": "grad‐", "b": [0.8121, 0.5156, 0.8571, 0.5371]}, {"w": "ually", "b": [0.1429, 0.5347, 0.1832, 0.5561]}, {"w": "lose", "b": [0.1896, 0.5347, 0.222, 0.5561]}, {"w": "their", "b": [0.2284, 0.5347, 0.268, 0.5561]}, {"w": "spatial", "b": [0.2745, 0.5347, 0.3281, 0.5561]}, {"w": "resolution", "b": [0.3346, 0.5347, 0.4197, 0.5561]}, {"w": "(due", "b": [0.4261, 0.5347, 0.4642, 0.5561]}, {"w": "to", "b": [0.4707, 0.5347, 0.4876, 0.5561]}, {"w": "the", "b": [0.4941, 0.5347, 0.5204, 0.5561]}, {"w": "layers", "b": [0.5268, 0.5347, 0.5746, 0.5561]}, {"w": "with", "b": [0.5811, 0.5347, 0.6184, 0.5561]}, {"w": "strides", "b": [0.6248, 0.5347, 0.6796, 0.5561]}, {"w": "greater", "b": [0.686, 0.5347, 0.7441, 0.5561]}, {"w": "than", "b": [0.7505, 0.5347, 0.7885, 0.5561]}, {"w": "1):", "b": [0.7949, 0.5347, 0.8169, 0.5561]}, {"w": "so", "b": [0.8233, 0.5347, 0.8416, 0.5561]}, {"w": "a", "b": [0.848, 0.5347, 0.8571, 0.5561]}, {"w": "regular", "b": [0.1428, 0.5537, 0.2024, 0.5752]}, {"w": "CNN", "b": [0.2086, 0.5537, 0.2534, 0.5752]}, {"w": "may", "b": [0.2596, 0.5537, 0.295, 0.5752]}, {"w": "end", "b": [0.3012, 0.5537, 0.3324, 0.5752]}, {"w": "up", "b": [0.3386, 0.5537, 0.3606, 0.5752]}, {"w": "knowing", "b": [0.3667, 0.5537, 0.4401, 0.5752]}, {"w": "that", "b": [0.4463, 0.5537, 0.4789, 0.5752]}, {"w": "there’s", "b": [0.4851, 0.5537, 0.5371, 0.5752]}, {"w": "a", "b": [0.5433, 0.5537, 0.5524, 0.5752]}, {"w": "person", "b": [0.5586, 0.5537, 0.6158, 0.5752]}, {"w": "in", "b": [0.6219, 0.5537, 0.6389, 0.5752]}, {"w": "the", "b": [0.6451, 0.5537, 0.6714, 0.5752]}, {"w": "image,", "b": [0.6776, 0.5537, 0.7328, 0.5752]}, {"w": "somewhere", "b": [0.739, 0.5537, 0.834, 0.5752]}, {"w": "in", "b": [0.8402, 0.5537, 0.8571, 0.5752]}, {"w": "the", "b": [0.1429, 0.5728, 0.1692, 0.5942]}, {"w": "bottom", "b": [0.1739, 0.5728, 0.2355, 0.5942]}, {"w": "left", "b": [0.2403, 0.5728, 0.2669, 0.5942]}, {"w": "of", "b": [0.2716, 0.5728, 0.2884, 0.5942]}, {"w": "the", "b": [0.2932, 0.5728, 0.3195, 0.5942]}, {"w": "image,", "b": [0.3242, 0.5728, 0.3794, 0.5942]}, {"w": "but", "b": [0.3841, 0.5728, 0.4121, 0.5942]}, {"w": "it", "b": [0.4168, 0.5728, 0.4288, 0.5942]}, {"w": "will", "b": [0.4335, 0.5728, 0.4639, 0.5942]}, {"w": "not", "b": [0.4686, 0.5728, 0.497, 0.5942]}, {"w": "be", "b": [0.5017, 0.5728, 0.5212, 0.5942]}, {"w": "much", "b": [0.5259, 0.5728, 0.5736, 0.5942]}, {"w": "more", "b": [0.5783, 0.5728, 0.6226, 0.5942]}, {"w": "precise", "b": [0.6273, 0.5728, 0.6857, 0.5942]}, {"w": "than", "b": [0.6904, 0.5728, 0.7284, 0.5942]}, {"w": "that.", "b": [0.7332, 0.5728, 0.7705, 0.5942]}]}, {"id": "b_7", "type": "paragraph", "text": "478 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "478", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 505, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "31 This type of layer is sometimes referred to as a deconvolution layer, but it does not perform what mathemati‐ cians call a deconvolution, so this name should be avoided.", "words": [{"w": "31", "b": [0.1385, 0.8613, 0.1518, 0.8756]}, {"w": "This", "b": [0.1587, 0.8598, 0.1871, 0.8761]}, {"w": "type", "b": [0.1907, 0.8598, 0.2179, 0.8761]}, {"w": "of", "b": [0.2215, 0.8598, 0.2343, 0.8761]}, {"w": "layer", "b": [0.2379, 0.8598, 0.2685, 0.8761]}, {"w": "is", "b": [0.2721, 0.8598, 0.2822, 0.8761]}, {"w": "sometimes", "b": [0.2858, 0.8598, 0.3541, 0.8761]}, {"w": "referred", "b": [0.3577, 0.8598, 0.4087, 0.8761]}, {"w": "to", "b": [0.4123, 0.8598, 0.4252, 0.8761]}, {"w": "as", "b": [0.4288, 0.8598, 0.4416, 0.8761]}, {"w": "a", "b": [0.4452, 0.8598, 0.4522, 0.8761]}, {"w": "deconvolution", "b": [0.4558, 0.8596, 0.5424, 0.8761]}, {"w": "layer,", "b": [0.5461, 0.8596, 0.5801, 0.8761]}, {"w": "but", "b": [0.5837, 0.8598, 0.605, 0.8761]}, {"w": "it", "b": [0.6086, 0.8598, 0.6177, 0.8761]}, {"w": "does", "b": [0.6213, 0.8598, 0.6504, 0.8761]}, {"w": "not", "b": [0.654, 0.8596, 0.6745, 0.8761]}, {"w": "perform", "b": [0.6781, 0.8598, 0.7307, 0.8761]}, {"w": "what", "b": [0.7343, 0.8598, 0.7652, 0.8761]}, {"w": "mathemati‐", "b": [0.7688, 0.8598, 0.8429, 0.8761]}, {"w": "cians", "b": [0.1587, 0.8749, 0.1912, 0.8912]}, {"w": "call", "b": [0.1948, 0.8749, 0.2165, 0.8912]}, {"w": "a", "b": [0.2201, 0.8749, 0.2271, 0.8912]}, {"w": "deconvolution,", "b": [0.2307, 0.8749, 0.3263, 0.8912]}, {"w": "so", "b": [0.3299, 0.8749, 0.3438, 0.8912]}, {"w": "this", "b": [0.3474, 0.8749, 0.3708, 0.8912]}, {"w": "name", "b": [0.3744, 0.8749, 0.4098, 0.8912]}, {"w": "should", "b": [0.4134, 0.8749, 0.4567, 0.8912]}, {"w": "be", "b": [0.4603, 0.8749, 0.4751, 0.8912]}, {"w": "avoided.", "b": [0.4787, 0.8749, 0.5322, 0.8912]}]}, {"id": "b_1", "type": "equation", "text": "Figure 14-26. Semantic segmentation", "words": [{"w": "Figure", "b": [0.1429, 0.3084, 0.1943, 0.33]}, {"w": "14-26.", "b": [0.1991, 0.3084, 0.2507, 0.33]}, {"w": "Semantic", "b": [0.2554, 0.3084, 0.3302, 0.33]}, {"w": "segmentation", "b": [0.3349, 0.3084, 0.4427, 0.33]}]}, {"id": "b_2", "type": "paragraph", "text": "Just like for object detection, there are many different approaches to tackle this prob‐ lem, some quite complex. However, a fairly simple solution was proposed in the 2015 paper by Jonathan Long et al. we discussed earlier. They start by taking a pretrained CNN and turning into an FCN, as discussed earlier. The CNN applies a stride of 32 to the input image overall (i.e., if you add up all the strides greater than 1), meaning the last layer outputs feature maps that are 32 times smaller than the input image. This is clearly too coarse, so they add a single upsampling layer that multiplies the resolution by 32. There are several solutions available for upsampling (increasing the size of an image), such as bilinear interpolation, but it only works reasonably well up to ×4 or ×8. Instead, they used a transposed convolutional layer:31 it is equivalent to first stretching the image by inserting empty rows and columns (full of zeros), then per‐ forming a regular convolution (see Figure 14-27). Alternatively, some people prefer to think of it as a regular convolutional layer that uses fractional strides (e.g., 1/2 in Figure 14-27). The transposed convolutional layer can be initialized to perform some‐ thing close to linear interpolation, but since it is a trainable layer, it will learn to do better during training.", "words": [{"w": "Just", "b": [0.1429, 0.3458, 0.1741, 0.3672]}, {"w": "like", "b": [0.1795, 0.3458, 0.2095, 0.3672]}, {"w": "for", "b": [0.2149, 0.3458, 0.2394, 0.3672]}, {"w": "object", "b": [0.2448, 0.3458, 0.2954, 0.3672]}, {"w": "detection,", "b": [0.3008, 0.3458, 0.3834, 0.3672]}, {"w": "there", "b": [0.3888, 0.3458, 0.4317, 0.3672]}, {"w": "are", "b": [0.4371, 0.3458, 0.4628, 0.3672]}, {"w": "many", "b": [0.4682, 0.3458, 0.5149, 0.3672]}, {"w": "different", "b": [0.5203, 0.3458, 0.592, 0.3672]}, {"w": "approaches", "b": [0.5973, 0.3458, 0.6919, 0.3672]}, {"w": "to", "b": [0.6973, 0.3458, 0.7142, 0.3672]}, {"w": "tackle", "b": [0.7196, 0.3458, 0.7684, 0.3672]}, {"w": "this", "b": [0.7738, 0.3458, 0.8045, 0.3672]}, {"w": "prob‐", "b": [0.8099, 0.3458, 0.8571, 0.3672]}, {"w": "lem,", "b": [0.1429, 0.3649, 0.1788, 0.3863]}, {"w": "some", "b": [0.184, 0.3649, 0.2282, 0.3863]}, {"w": "quite", "b": [0.2335, 0.3649, 0.276, 0.3863]}, {"w": "complex.", "b": [0.2812, 0.3649, 0.357, 0.3863]}, {"w": "However,", "b": [0.3622, 0.3649, 0.4411, 0.3863]}, {"w": "a", "b": [0.4463, 0.3649, 0.4555, 0.3863]}, {"w": "fairly", "b": [0.4607, 0.3649, 0.5042, 0.3863]}, {"w": "simple", "b": [0.5094, 0.3649, 0.5644, 0.3863]}, {"w": "solution", "b": [0.5696, 0.3649, 0.6382, 0.3863]}, {"w": "was", "b": [0.6434, 0.3649, 0.6745, 0.3863]}, {"w": "proposed", "b": [0.6798, 0.3649, 0.7581, 0.3863]}, {"w": "in", "b": [0.7633, 0.3649, 0.7803, 0.3863]}, {"w": "the", "b": [0.7856, 0.3649, 0.8119, 0.3863]}, {"w": "2015", "b": [0.8171, 0.3649, 0.8571, 0.3863]}, {"w": "paper", "b": [0.1429, 0.3839, 0.19, 0.4053]}, {"w": "by", "b": [0.1962, 0.3839, 0.2163, 0.4053]}, {"w": "Jonathan", "b": [0.2225, 0.3839, 0.2977, 0.4053]}, {"w": "Long", "b": [0.3039, 0.3839, 0.3469, 0.4053]}, {"w": "et", "b": [0.353, 0.3839, 0.3682, 0.4053]}, {"w": "al.", "b": [0.3744, 0.3839, 0.3936, 0.4053]}, {"w": "we", "b": [0.3997, 0.3839, 0.4229, 0.4053]}, {"w": "discussed", "b": [0.429, 0.3839, 0.5083, 0.4053]}, {"w": "earlier.", "b": [0.5145, 0.3839, 0.5711, 0.4053]}, {"w": "They", "b": [0.5772, 0.3839, 0.6196, 0.4053]}, {"w": "start", "b": [0.6258, 0.3839, 0.663, 0.4053]}, {"w": "by", "b": [0.6692, 0.3839, 0.6894, 0.4053]}, {"w": "taking", "b": [0.6955, 0.3839, 0.7481, 0.4053]}, {"w": "a", "b": [0.7543, 0.3839, 0.7634, 0.4053]}, {"w": "pretrained", "b": [0.7696, 0.3839, 0.8571, 0.4053]}, {"w": "CNN", "b": [0.1429, 0.403, 0.1877, 0.4244]}, {"w": "and", "b": [0.1925, 0.403, 0.224, 0.4244]}, {"w": "turning", "b": [0.2289, 0.403, 0.2921, 0.4244]}, {"w": "into", "b": [0.297, 0.403, 0.3305, 0.4244]}, {"w": "an", "b": [0.3353, 0.403, 0.3559, 0.4244]}, {"w": "FCN,", "b": [0.3607, 0.403, 0.4058, 0.4244]}, {"w": "as", "b": [0.4106, 0.403, 0.4274, 0.4244]}, {"w": "discussed", "b": [0.4322, 0.403, 0.5115, 0.4244]}, {"w": "earlier.", "b": [0.5163, 0.403, 0.5729, 0.4244]}, {"w": "The", "b": [0.5777, 0.403, 0.6106, 0.4244]}, {"w": "CNN", "b": [0.6154, 0.403, 0.6602, 0.4244]}, {"w": "applies", "b": [0.665, 0.403, 0.723, 0.4244]}, {"w": "a", "b": [0.7278, 0.403, 0.7369, 0.4244]}, {"w": "stride", "b": [0.7417, 0.403, 0.7889, 0.4244]}, {"w": "of", "b": [0.7937, 0.403, 0.8105, 0.4244]}, {"w": "32", "b": [0.8154, 0.403, 0.8354, 0.4244]}, {"w": "to", "b": [0.8402, 0.403, 0.8572, 0.4244]}, {"w": "the", "b": [0.1429, 0.422, 0.1692, 0.4434]}, {"w": "input", "b": [0.1746, 0.422, 0.2195, 0.4434]}, {"w": "image", "b": [0.2248, 0.422, 0.2752, 0.4434]}, {"w": "overall", "b": [0.2806, 0.422, 0.3371, 0.4434]}, {"w": "(i.e.,", "b": [0.3425, 0.422, 0.3784, 0.4434]}, {"w": "if", "b": [0.3837, 0.422, 0.3955, 0.4434]}, {"w": "you", "b": [0.4008, 0.422, 0.4321, 0.4434]}, {"w": "add", "b": [0.4374, 0.422, 0.4686, 0.4434]}, {"w": "up", "b": [0.474, 0.422, 0.4959, 0.4434]}, {"w": "all", "b": [0.5013, 0.422, 0.521, 0.4434]}, {"w": "the", "b": [0.5263, 0.422, 0.5527, 0.4434]}, {"w": "strides", "b": [0.558, 0.422, 0.6128, 0.4434]}, {"w": "greater", "b": [0.6182, 0.422, 0.6762, 0.4434]}, {"w": "than", "b": [0.6816, 0.422, 0.7196, 0.4434]}, {"w": "1),", "b": [0.725, 0.422, 0.7469, 0.4434]}, {"w": "meaning", "b": [0.7523, 0.422, 0.8255, 0.4434]}, {"w": "the", "b": [0.8308, 0.422, 0.8571, 0.4434]}, {"w": "last", "b": [0.1429, 0.441, 0.1713, 0.4625]}, {"w": "layer", "b": [0.1766, 0.441, 0.2168, 0.4625]}, {"w": "outputs", "b": [0.2221, 0.441, 0.2861, 0.4625]}, {"w": "feature", "b": [0.2915, 0.441, 0.3492, 0.4625]}, {"w": "maps", "b": [0.3545, 0.441, 0.3989, 0.4625]}, {"w": "that", "b": [0.4042, 0.441, 0.4368, 0.4625]}, {"w": "are", "b": [0.4422, 0.441, 0.4679, 0.4625]}, {"w": "32", "b": [0.4732, 0.441, 0.4932, 0.4625]}, {"w": "times", "b": [0.4985, 0.441, 0.544, 0.4625]}, {"w": "smaller", "b": [0.5494, 0.441, 0.6103, 0.4625]}, {"w": "than", "b": [0.6157, 0.441, 0.6537, 0.4625]}, {"w": "the", "b": [0.659, 0.441, 0.6853, 0.4625]}, {"w": "input", "b": [0.6907, 0.441, 0.7356, 0.4625]}, {"w": "image.", "b": [0.7409, 0.441, 0.7961, 0.4625]}, {"w": "This", "b": [0.8014, 0.441, 0.8386, 0.4625]}, {"w": "is", "b": [0.8439, 0.441, 0.8571, 0.4625]}, {"w": "clearly", "b": [0.1428, 0.4601, 0.1975, 0.4815]}, {"w": "too", "b": [0.2029, 0.4601, 0.2305, 0.4815]}, {"w": "coarse,", "b": [0.236, 0.4601, 0.2935, 0.4815]}, {"w": "so", "b": [0.2989, 0.4601, 0.3172, 0.4815]}, {"w": "they", "b": [0.3226, 0.4601, 0.3585, 0.4815]}, {"w": "add", "b": [0.364, 0.4601, 0.3951, 0.4815]}, {"w": "a", "b": [0.4005, 0.4601, 0.4097, 0.4815]}, {"w": "single", "b": [0.4151, 0.4601, 0.4636, 0.4815]}, {"w": "upsampling", "b": [0.469, 0.4599, 0.5628, 0.4815]}, {"w": "layer", "b": [0.5682, 0.4599, 0.6082, 0.4815]}, {"w": "that", "b": [0.6136, 0.4601, 0.6462, 0.4815]}, {"w": "multiplies", "b": [0.6516, 0.4601, 0.7348, 0.4815]}, {"w": "the", "b": [0.7402, 0.4601, 0.7666, 0.4815]}, {"w": "resolution", "b": [0.772, 0.4601, 0.8571, 0.4815]}, {"w": "by", "b": [0.1429, 0.4791, 0.163, 0.5006]}, {"w": "32.", "b": [0.169, 0.4791, 0.1938, 0.5006]}, {"w": "There", "b": [0.1998, 0.4791, 0.2492, 0.5006]}, {"w": "are", "b": [0.2552, 0.4791, 0.2809, 0.5006]}, {"w": "several", "b": [0.2869, 0.4791, 0.3441, 0.5006]}, {"w": "solutions", "b": [0.3501, 0.4791, 0.4263, 0.5006]}, {"w": "available", "b": [0.4323, 0.4791, 0.5046, 0.5006]}, {"w": "for", "b": [0.5106, 0.4791, 0.5351, 0.5006]}, {"w": "upsampling", "b": [0.5411, 0.4791, 0.6395, 0.5006]}, {"w": "(increasing", "b": [0.6455, 0.4791, 0.7386, 0.5006]}, {"w": "the", "b": [0.7446, 0.4791, 0.7709, 0.5006]}, {"w": "size", "b": [0.777, 0.4791, 0.8078, 0.5006]}, {"w": "of", "b": [0.8138, 0.4791, 0.8306, 0.5006]}, {"w": "an", "b": [0.8366, 0.4791, 0.8571, 0.5006]}, {"w": "image),", "b": [0.1429, 0.4982, 0.2052, 0.5196]}, {"w": "such", "b": [0.2115, 0.4982, 0.2502, 0.5196]}, {"w": "as", "b": [0.2564, 0.4982, 0.2732, 0.5196]}, {"w": "bilinear", "b": [0.2795, 0.4982, 0.3437, 0.5196]}, {"w": "interpolation,", "b": [0.35, 0.4982, 0.4638, 0.5196]}, {"w": "but", "b": [0.4701, 0.4982, 0.4981, 0.5196]}, {"w": "it", "b": [0.5044, 0.4982, 0.5163, 0.5196]}, {"w": "only", "b": [0.5226, 0.4982, 0.5594, 0.5196]}, {"w": "works", "b": [0.5657, 0.4982, 0.6163, 0.5196]}, {"w": "reasonably", "b": [0.6226, 0.4982, 0.7126, 0.5196]}, {"w": "well", "b": [0.7189, 0.4982, 0.7526, 0.5196]}, {"w": "up", "b": [0.7589, 0.4982, 0.7808, 0.5196]}, {"w": "to", "b": [0.7871, 0.4982, 0.8041, 0.5196]}, {"w": "×4", "b": [0.8104, 0.4982, 0.8325, 0.5196]}, {"w": "or", "b": [0.8388, 0.4982, 0.8571, 0.5196]}, {"w": "×8.", "b": [0.1429, 0.5172, 0.1697, 0.5387]}, {"w": "Instead,", "b": [0.1799, 0.5172, 0.2461, 0.5387]}, {"w": "they", "b": [0.2564, 0.5172, 0.2923, 0.5387]}, {"w": "used", "b": [0.3025, 0.5172, 0.341, 0.5387]}, {"w": "a", "b": [0.3512, 0.5172, 0.3604, 0.5387]}, {"w": "transposed", "b": [0.3706, 0.517, 0.4574, 0.5387]}, {"w": "convolutional", "b": [0.4677, 0.517, 0.5777, 0.5387]}, {"w": "layer:31", "b": [0.5879, 0.517, 0.644, 0.5387]}, {"w": "it", "b": [0.6543, 0.5172, 0.6662, 0.5387]}, {"w": "is", "b": [0.6764, 0.5172, 0.6896, 0.5387]}, {"w": "equivalent", "b": [0.6998, 0.5172, 0.7863, 0.5387]}, {"w": "to", "b": [0.7965, 0.5172, 0.8135, 0.5387]}, {"w": "first", "b": [0.8237, 0.5172, 0.8571, 0.5387]}, {"w": "stretching", "b": [0.1429, 0.5363, 0.2265, 0.5577]}, {"w": "the", "b": [0.2329, 0.5363, 0.2592, 0.5577]}, {"w": "image", "b": [0.2656, 0.5363, 0.316, 0.5577]}, {"w": "by", "b": [0.3225, 0.5363, 0.3426, 0.5577]}, {"w": "inserting", "b": [0.349, 0.5363, 0.4233, 0.5577]}, {"w": "empty", "b": [0.4297, 0.5363, 0.4821, 0.5577]}, {"w": "rows", "b": [0.4885, 0.5363, 0.5288, 0.5577]}, {"w": "and", "b": [0.5352, 0.5363, 0.5668, 0.5577]}, {"w": "columns", "b": [0.5732, 0.5363, 0.6451, 0.5577]}, {"w": "(full", "b": [0.6515, 0.5363, 0.6865, 0.5577]}, {"w": "of", "b": [0.6929, 0.5363, 0.7097, 0.5577]}, {"w": "zeros),", "b": [0.7161, 0.5363, 0.7717, 0.5577]}, {"w": "then", "b": [0.7781, 0.5363, 0.8158, 0.5577]}, {"w": "per‐", "b": [0.8222, 0.5363, 0.8571, 0.5577]}, {"w": "forming", "b": [0.1429, 0.5553, 0.2112, 0.5767]}, {"w": "a", "b": [0.2159, 0.5553, 0.225, 0.5767]}, {"w": "regular", "b": [0.2298, 0.5553, 0.2893, 0.5767]}, {"w": "convolution", "b": [0.294, 0.5553, 0.395, 0.5767]}, {"w": "(see", "b": [0.3997, 0.5553, 0.4322, 0.5767]}, {"w": "Figure", "b": [0.4371, 0.5553, 0.4911, 0.5767]}, {"w": "14-27).", "b": [0.4959, 0.5553, 0.5552, 0.5767]}, {"w": "Alternatively,", "b": [0.56, 0.5553, 0.6712, 0.5767]}, {"w": "some", "b": [0.676, 0.5553, 0.7201, 0.5767]}, {"w": "people", "b": [0.7249, 0.5553, 0.7803, 0.5767]}, {"w": "prefer", "b": [0.785, 0.5553, 0.8353, 0.5767]}, {"w": "to", "b": [0.84, 0.5553, 0.857, 0.5767]}, {"w": "think", "b": [0.1429, 0.5744, 0.1876, 0.5958]}, {"w": "of", "b": [0.1957, 0.5744, 0.2125, 0.5958]}, {"w": "it", "b": [0.2206, 0.5744, 0.2325, 0.5958]}, {"w": "as", "b": [0.2406, 0.5744, 0.2574, 0.5958]}, {"w": "a", "b": [0.2654, 0.5744, 0.2746, 0.5958]}, {"w": "regular", "b": [0.2827, 0.5744, 0.3422, 0.5958]}, {"w": "convolutional", "b": [0.3503, 0.5744, 0.4656, 0.5958]}, {"w": "layer", "b": [0.4737, 0.5744, 0.5139, 0.5958]}, {"w": "that", "b": [0.5219, 0.5744, 0.5545, 0.5958]}, {"w": "uses", "b": [0.5626, 0.5744, 0.5978, 0.5958]}, {"w": "fractional", "b": [0.6059, 0.5744, 0.6861, 0.5958]}, {"w": "strides", "b": [0.6942, 0.5744, 0.749, 0.5958]}, {"w": "(e.g.,", "b": [0.7571, 0.5744, 0.7971, 0.5958]}, {"w": "1/2", "b": [0.8052, 0.5744, 0.8321, 0.5958]}, {"w": "in", "b": [0.8402, 0.5744, 0.8571, 0.5958]}, {"w": "Figure", "b": [0.1429, 0.5934, 0.1969, 0.6148]}, {"w": "14-27).", "b": [0.2025, 0.5934, 0.2619, 0.6148]}, {"w": "The", "b": [0.2675, 0.5934, 0.3003, 0.6148]}, {"w": "transposed", "b": [0.3059, 0.5932, 0.3927, 0.6148]}, {"w": "convolutional", "b": [0.3984, 0.5932, 0.5084, 0.6148]}, {"w": "layer", "b": [0.514, 0.5932, 0.5539, 0.6148]}, {"w": "can", "b": [0.5595, 0.5934, 0.5889, 0.6148]}, {"w": "be", "b": [0.5945, 0.5934, 0.6139, 0.6148]}, {"w": "initialized", "b": [0.6196, 0.5934, 0.7027, 0.6148]}, {"w": "to", "b": [0.7083, 0.5934, 0.7252, 0.6148]}, {"w": "perform", "b": [0.7309, 0.5934, 0.7999, 0.6148]}, {"w": "some‐", "b": [0.8056, 0.5934, 0.8572, 0.6148]}, {"w": "thing", "b": [0.1429, 0.6125, 0.1871, 0.6339]}, {"w": "close", "b": [0.1936, 0.6125, 0.2348, 0.6339]}, {"w": "to", "b": [0.2413, 0.6125, 0.2583, 0.6339]}, {"w": "linear", "b": [0.2649, 0.6125, 0.3128, 0.6339]}, {"w": "interpolation,", "b": [0.3194, 0.6125, 0.4332, 0.6339]}, {"w": "but", "b": [0.4397, 0.6125, 0.4677, 0.6339]}, {"w": "since", "b": [0.4742, 0.6125, 0.5165, 0.6339]}, {"w": "it", "b": [0.523, 0.6125, 0.535, 0.6339]}, {"w": "is", "b": [0.5415, 0.6125, 0.5547, 0.6339]}, {"w": "a", "b": [0.5613, 0.6125, 0.5704, 0.6339]}, {"w": "trainable", "b": [0.5769, 0.6125, 0.651, 0.6339]}, {"w": "layer,", "b": [0.6575, 0.6125, 0.7012, 0.6339]}, {"w": "it", "b": [0.7077, 0.6125, 0.7196, 0.6339]}, {"w": "will", "b": [0.7262, 0.6125, 0.7566, 0.6339]}, {"w": "learn", "b": [0.7631, 0.6125, 0.8055, 0.6339]}, {"w": "to", "b": [0.812, 0.6125, 0.829, 0.6339]}, {"w": "do", "b": [0.8355, 0.6125, 0.8571, 0.6339]}, {"w": "better", "b": [0.1429, 0.6315, 0.1916, 0.6529]}, {"w": "during", "b": [0.1963, 0.6315, 0.2528, 0.6529]}, {"w": "training.", "b": [0.2576, 0.6315, 0.3293, 0.6529]}]}, {"id": "b_3", "type": "paragraph", "text": "Semantic Segmentation | 479", "words": [{"w": "Semantic", "b": [0.6545, 0.9225, 0.7091, 0.9388]}, {"w": "Segmentation", "b": [0.712, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "479", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 506, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "equation", "text": "Figure 14-27. Upsampling Using a Transpose Convolutional Layer", "words": [{"w": "Figure", "b": [0.1429, 0.443, 0.1943, 0.4646]}, {"w": "14-27.", "b": [0.1991, 0.443, 0.2507, 0.4646]}, {"w": "Upsampling", "b": [0.2554, 0.443, 0.3523, 0.4646]}, {"w": "Using", "b": [0.357, 0.443, 0.4027, 0.4646]}, {"w": "a", "b": [0.4075, 0.443, 0.4177, 0.4646]}, {"w": "Transpose", "b": [0.4225, 0.443, 0.5036, 0.4646]}, {"w": "Convolutional", "b": [0.5084, 0.443, 0.6239, 0.4646]}, {"w": "Layer", "b": [0.6286, 0.443, 0.6746, 0.4646]}]}, {"id": "b_1", "type": "paragraph", "text": "In a transposed convolution layer, the stride defines how much the input will be stretched, not the size of the filter steps, so the larger the stride, the larger the output (unlike for convolutional layers or pooling layers).", "words": [{"w": "In", "b": [0.2714, 0.4851, 0.2883, 0.5047]}, {"w": "a", "b": [0.2934, 0.4851, 0.3018, 0.5047]}, {"w": "transposed", "b": [0.3069, 0.4851, 0.3904, 0.5047]}, {"w": "convolution", "b": [0.3955, 0.4851, 0.4878, 0.5047]}, {"w": "layer,", "b": [0.4929, 0.4851, 0.5328, 0.5047]}, {"w": "the", "b": [0.5379, 0.4851, 0.562, 0.5047]}, {"w": "stride", "b": [0.5671, 0.4851, 0.6102, 0.5047]}, {"w": "defines", "b": [0.6154, 0.4851, 0.6698, 0.5047]}, {"w": "how", "b": [0.6749, 0.4851, 0.7078, 0.5047]}, {"w": "much", "b": [0.7129, 0.4851, 0.7565, 0.5047]}, {"w": "the", "b": [0.7616, 0.4851, 0.7857, 0.5047]}, {"w": "input", "b": [0.2714, 0.5026, 0.3125, 0.5221]}, {"w": "will", "b": [0.318, 0.5026, 0.3458, 0.5221]}, {"w": "be", "b": [0.3513, 0.5026, 0.3691, 0.5221]}, {"w": "stretched,", "b": [0.3746, 0.5026, 0.4491, 0.5221]}, {"w": "not", "b": [0.4546, 0.5026, 0.4805, 0.5221]}, {"w": "the", "b": [0.486, 0.5026, 0.5101, 0.5221]}, {"w": "size", "b": [0.5156, 0.5026, 0.5438, 0.5221]}, {"w": "of", "b": [0.5493, 0.5026, 0.5647, 0.5221]}, {"w": "the", "b": [0.5702, 0.5026, 0.5943, 0.5221]}, {"w": "filter", "b": [0.5998, 0.5026, 0.6363, 0.5221]}, {"w": "steps,", "b": [0.6419, 0.5026, 0.6841, 0.5221]}, {"w": "so", "b": [0.6896, 0.5026, 0.7063, 0.5221]}, {"w": "the", "b": [0.7118, 0.5026, 0.7359, 0.5221]}, {"w": "larger", "b": [0.7414, 0.5026, 0.7857, 0.5221]}, {"w": "the", "b": [0.2714, 0.52, 0.2955, 0.5395]}, {"w": "stride,", "b": [0.3011, 0.52, 0.3485, 0.5395]}, {"w": "the", "b": [0.3541, 0.52, 0.3782, 0.5395]}, {"w": "larger", "b": [0.3838, 0.52, 0.4281, 0.5395]}, {"w": "the", "b": [0.4337, 0.52, 0.4577, 0.5395]}, {"w": "output", "b": [0.4633, 0.52, 0.5149, 0.5395]}, {"w": "(unlike", "b": [0.5204, 0.52, 0.575, 0.5395]}, {"w": "for", "b": [0.5806, 0.52, 0.603, 0.5395]}, {"w": "convolutional", "b": [0.6086, 0.52, 0.714, 0.5395]}, {"w": "layers", "b": [0.7196, 0.52, 0.7634, 0.5395]}, {"w": "or", "b": [0.7689, 0.52, 0.7857, 0.5395]}, {"w": "pooling", "b": [0.2714, 0.5374, 0.3301, 0.557]}, {"w": "layers).", "b": [0.3344, 0.5374, 0.3891, 0.557]}]}, {"id": "b_2", "type": "paragraph", "text": "TensorFlow Convolution Operations", "words": [{"w": "TensorFlow", "b": [0.3262, 0.5968, 0.4387, 0.624]}, {"w": "Convolution", "b": [0.4434, 0.5968, 0.562, 0.624]}, {"w": "Operations", "b": [0.5667, 0.5968, 0.6738, 0.624]}]}, {"id": "b_3", "type": "paragraph", "text": "TensorFlow also offers a few other kinds of convolutional layers:", "words": [{"w": "TensorFlow", "b": [0.1592, 0.6285, 0.2528, 0.6489]}, {"w": "also", "b": [0.2573, 0.6285, 0.2884, 0.6489]}, {"w": "offers", "b": [0.2929, 0.6285, 0.3379, 0.6489]}, {"w": "a", "b": [0.3424, 0.6285, 0.3511, 0.6489]}, {"w": "few", "b": [0.3556, 0.6285, 0.3835, 0.6489]}, {"w": "other", "b": [0.388, 0.6285, 0.4306, 0.6489]}, {"w": "kinds", "b": [0.4351, 0.6285, 0.4788, 0.6489]}, {"w": "of", "b": [0.4833, 0.6285, 0.4993, 0.6489]}, {"w": "convolutional", "b": [0.5038, 0.6285, 0.6137, 0.6489]}, {"w": "layers:", "b": [0.6182, 0.6285, 0.6683, 0.6489]}]}, {"id": "b_4", "type": "paragraph", "text": "• keras.layers.Conv1D creates a convolutional layer for 1D inputs, such as time series or text (sequences of letters or words), as we will see in ???.", "words": [{"w": "•", "b": [0.1773, 0.6626, 0.185, 0.683]}, {"w": "keras.layers.Conv1D", "b": [0.1949, 0.6656, 0.374, 0.68]}, {"w": "creates", "b": [0.3805, 0.6626, 0.4348, 0.683]}, {"w": "a", "b": [0.4412, 0.6626, 0.45, 0.683]}, {"w": "convolutional", "b": [0.4564, 0.6626, 0.5663, 0.683]}, {"w": "layer", "b": [0.5727, 0.6626, 0.611, 0.683]}, {"w": "for", "b": [0.6175, 0.6626, 0.6409, 0.683]}, {"w": "1D", "b": [0.6473, 0.6626, 0.6714, 0.683]}, {"w": "inputs,", "b": [0.6779, 0.6626, 0.7325, 0.683]}, {"w": "such", "b": [0.739, 0.6626, 0.7758, 0.683]}, {"w": "as", "b": [0.7823, 0.6626, 0.7982, 0.683]}, {"w": "time", "b": [0.8047, 0.6626, 0.8408, 0.683]}, {"w": "series", "b": [0.1949, 0.6808, 0.239, 0.7011]}, {"w": "or", "b": [0.2435, 0.6808, 0.261, 0.7011]}, {"w": "text", "b": [0.2655, 0.6808, 0.2954, 0.7011]}, {"w": "(sequences", "b": [0.2999, 0.6808, 0.3866, 0.7011]}, {"w": "of", "b": [0.3911, 0.6808, 0.4071, 0.7011]}, {"w": "letters", "b": [0.4116, 0.6808, 0.4602, 0.7011]}, {"w": "or", "b": [0.4647, 0.6808, 0.4822, 0.7011]}, {"w": "words),", "b": [0.4867, 0.6808, 0.5469, 0.7011]}, {"w": "as", "b": [0.5514, 0.6808, 0.5674, 0.7011]}, {"w": "we", "b": [0.5719, 0.6808, 0.5939, 0.7011]}, {"w": "will", "b": [0.5984, 0.6808, 0.6274, 0.7011]}, {"w": "see", "b": [0.6319, 0.6808, 0.656, 0.7011]}, {"w": "in", "b": [0.6606, 0.6808, 0.6767, 0.7011]}, {"w": "???.", "b": [0.6812, 0.6808, 0.7083, 0.7011]}]}, {"id": "b_5", "type": "paragraph", "text": "• keras.layers.Conv3D creates a convolutional layer for 3D inputs, such as 3D PET scan.", "words": [{"w": "•", "b": [0.1773, 0.7058, 0.185, 0.7262]}, {"w": "keras.layers.Conv3D", "b": [0.1949, 0.7088, 0.374, 0.7232]}, {"w": "creates", "b": [0.3817, 0.7058, 0.436, 0.7262]}, {"w": "a", "b": [0.4436, 0.7058, 0.4523, 0.7262]}, {"w": "convolutional", "b": [0.46, 0.7058, 0.5699, 0.7262]}, {"w": "layer", "b": [0.5775, 0.7058, 0.6158, 0.7262]}, {"w": "for", "b": [0.6235, 0.7058, 0.6468, 0.7262]}, {"w": "3D", "b": [0.6545, 0.7058, 0.6786, 0.7262]}, {"w": "inputs,", "b": [0.6863, 0.7058, 0.7409, 0.7262]}, {"w": "such", "b": [0.7485, 0.7058, 0.7853, 0.7262]}, {"w": "as", "b": [0.793, 0.7058, 0.809, 0.7262]}, {"w": "3D", "b": [0.8167, 0.7058, 0.8408, 0.7262]}, {"w": "PET", "b": [0.1949, 0.7239, 0.2296, 0.7443]}, {"w": "scan.", "b": [0.2341, 0.7239, 0.2739, 0.7443]}]}, {"id": "b_6", "type": "paragraph", "text": "• Setting the dilation_rate hyperparameter of any convolutional layer to a value of 2 or more creates an à-trous convolutional layer (“à trous” is French for “with holes”). This is equivalent to using a regular convolutional layer with a filter dila‐ ted by inserting rows and columns of zeros (i.e., holes). For example, a 1 × 3 filter equal to [[1,2,3]] may be dilated with a dilation rate of 4, resulting in a dilated filter [[1, 0, 0, 0, 2, 0, 0, 0, 3]]. This allows the convolutional layer to", "words": [{"w": "•", "b": [0.1773, 0.749, 0.185, 0.7694]}, {"w": "Setting", "b": [0.1949, 0.749, 0.2503, 0.7694]}, {"w": "the", "b": [0.256, 0.749, 0.2811, 0.7694]}, {"w": "dilation_rate", "b": [0.2867, 0.752, 0.4093, 0.7664]}, {"w": "hyperparameter", "b": [0.4149, 0.749, 0.5421, 0.7694]}, {"w": "of", "b": [0.5477, 0.749, 0.5637, 0.7694]}, {"w": "any", "b": [0.5694, 0.749, 0.5976, 0.7694]}, {"w": "convolutional", "b": [0.6033, 0.749, 0.7131, 0.7694]}, {"w": "layer", "b": [0.7188, 0.749, 0.757, 0.7694]}, {"w": "to", "b": [0.7627, 0.749, 0.7789, 0.7694]}, {"w": "a", "b": [0.7845, 0.749, 0.7932, 0.7694]}, {"w": "value", "b": [0.7989, 0.749, 0.8408, 0.7694]}, {"w": "of", "b": [0.1949, 0.7671, 0.2109, 0.7875]}, {"w": "2", "b": [0.2168, 0.7671, 0.2263, 0.7875]}, {"w": "or", "b": [0.2322, 0.7671, 0.2497, 0.7875]}, {"w": "more", "b": [0.2555, 0.7671, 0.2977, 0.7875]}, {"w": "creates", "b": [0.3036, 0.7671, 0.3579, 0.7875]}, {"w": "an", "b": [0.3637, 0.7671, 0.3833, 0.7875]}, {"w": "à-trous", "b": [0.3892, 0.7669, 0.4448, 0.7875]}, {"w": "convolutional", "b": [0.4507, 0.7669, 0.5554, 0.7875]}, {"w": "layer", "b": [0.5613, 0.7669, 0.5994, 0.7875]}, {"w": "(“à", "b": [0.6052, 0.7671, 0.6274, 0.7875]}, {"w": "trous”", "b": [0.6333, 0.7671, 0.6818, 0.7875]}, {"w": "is", "b": [0.6876, 0.7671, 0.7002, 0.7875]}, {"w": "French", "b": [0.7061, 0.7671, 0.7622, 0.7875]}, {"w": "for", "b": [0.7681, 0.7671, 0.7915, 0.7875]}, {"w": "“with", "b": [0.7973, 0.7671, 0.8408, 0.7875]}, {"w": "holes”).", "b": [0.1949, 0.7853, 0.2549, 0.8057]}, {"w": "This", "b": [0.2598, 0.7853, 0.2953, 0.8057]}, {"w": "is", "b": [0.3001, 0.7853, 0.3127, 0.8057]}, {"w": "equivalent", "b": [0.3176, 0.7853, 0.3999, 0.8057]}, {"w": "to", "b": [0.4048, 0.7853, 0.421, 0.8057]}, {"w": "using", "b": [0.4259, 0.7853, 0.4692, 0.8057]}, {"w": "a", "b": [0.4741, 0.7853, 0.4828, 0.8057]}, {"w": "regular", "b": [0.4877, 0.7853, 0.5444, 0.8057]}, {"w": "convolutional", "b": [0.5493, 0.7853, 0.6591, 0.8057]}, {"w": "layer", "b": [0.664, 0.7853, 0.7023, 0.8057]}, {"w": "with", "b": [0.7072, 0.7853, 0.7427, 0.8057]}, {"w": "a", "b": [0.7476, 0.7853, 0.7563, 0.8057]}, {"w": "filter", "b": [0.7612, 0.7853, 0.7993, 0.8057]}, {"w": "dila‐", "b": [0.8042, 0.7853, 0.8408, 0.8057]}, {"w": "ted", "b": [0.1949, 0.8034, 0.2199, 0.8238]}, {"w": "by", "b": [0.2245, 0.8034, 0.2437, 0.8238]}, {"w": "inserting", "b": [0.2483, 0.8034, 0.3191, 0.8238]}, {"w": "rows", "b": [0.3237, 0.8034, 0.362, 0.8238]}, {"w": "and", "b": [0.3667, 0.8034, 0.3967, 0.8238]}, {"w": "columns", "b": [0.4013, 0.8034, 0.4698, 0.8238]}, {"w": "of", "b": [0.4744, 0.8034, 0.4904, 0.8238]}, {"w": "zeros", "b": [0.495, 0.8034, 0.5365, 0.8238]}, {"w": "(i.e.,", "b": [0.5411, 0.8034, 0.5753, 0.8238]}, {"w": "holes).", "b": [0.5799, 0.8034, 0.6328, 0.8238]}, {"w": "For", "b": [0.6374, 0.8034, 0.665, 0.8238]}, {"w": "example,", "b": [0.6696, 0.8034, 0.7404, 0.8238]}, {"w": "a", "b": [0.745, 0.8034, 0.7537, 0.8238]}, {"w": "1", "b": [0.7583, 0.8034, 0.7678, 0.8238]}, {"w": "×", "b": [0.7725, 0.8034, 0.784, 0.8238]}, {"w": "3", "b": [0.7886, 0.8034, 0.7981, 0.8238]}, {"w": "filter", "b": [0.8027, 0.8034, 0.8408, 0.8238]}, {"w": "equal", "b": [0.1949, 0.8224, 0.2378, 0.8428]}, {"w": "to", "b": [0.2433, 0.8224, 0.2595, 0.8428]}, {"w": "[[1,2,3]]", "b": [0.265, 0.8254, 0.3498, 0.8398]}, {"w": "may", "b": [0.3554, 0.8224, 0.3891, 0.8428]}, {"w": "be", "b": [0.3946, 0.8224, 0.4131, 0.8428]}, {"w": "dilated", "b": [0.4187, 0.8224, 0.4728, 0.8428]}, {"w": "with", "b": [0.4783, 0.8224, 0.5139, 0.8428]}, {"w": "a", "b": [0.5194, 0.8224, 0.5281, 0.8428]}, {"w": "dilation", "b": [0.5336, 0.8222, 0.5939, 0.8428]}, {"w": "rate", "b": [0.5994, 0.8222, 0.6294, 0.8428]}, {"w": "of", "b": [0.635, 0.8224, 0.651, 0.8428]}, {"w": "4,", "b": [0.6565, 0.8224, 0.6705, 0.8428]}, {"w": "resulting", "b": [0.6761, 0.8224, 0.7462, 0.8428]}, {"w": "in", "b": [0.7517, 0.8224, 0.7679, 0.8428]}, {"w": "a", "b": [0.7735, 0.8224, 0.7822, 0.8428]}, {"w": "dilated", "b": [0.7877, 0.8222, 0.8408, 0.8428]}, {"w": "filter", "b": [0.1949, 0.8412, 0.2317, 0.8618]}, {"w": "[[1,", "b": [0.2379, 0.8444, 0.2756, 0.8588]}, {"w": "0,", "b": [0.2867, 0.8444, 0.3055, 0.8588]}, {"w": "0,", "b": [0.3166, 0.8444, 0.3355, 0.8588]}, {"w": "0,", "b": [0.3465, 0.8444, 0.3654, 0.8588]}, {"w": "2,", "b": [0.3764, 0.8444, 0.3953, 0.8588]}, {"w": "0,", "b": [0.4063, 0.8444, 0.4252, 0.8588]}, {"w": "0,", "b": [0.4362, 0.8444, 0.4551, 0.8588]}, {"w": "0,", "b": [0.4662, 0.8444, 0.485, 0.8588]}, {"w": "3]].", "b": [0.4961, 0.8414, 0.5289, 0.8618]}, {"w": "This", "b": [0.5351, 0.8414, 0.5705, 0.8618]}, {"w": "allows", "b": [0.5768, 0.8414, 0.6265, 0.8618]}, {"w": "the", "b": [0.6327, 0.8414, 0.6578, 0.8618]}, {"w": "convolutional", "b": [0.664, 0.8414, 0.7739, 0.8618]}, {"w": "layer", "b": [0.7801, 0.8414, 0.8184, 0.8618]}, {"w": "to", "b": [0.8246, 0.8414, 0.8408, 0.8618]}]}, {"id": "b_7", "type": "paragraph", "text": "480 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "480", "b": [0.1429, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2746, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3684, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 507, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "have a larger receptive field at no computational price and using no extra param‐ eters.", "words": [{"w": "have", "b": [0.1949, 0.0792, 0.2315, 0.0996]}, {"w": "a", "b": [0.2364, 0.0792, 0.2451, 0.0996]}, {"w": "larger", "b": [0.25, 0.0792, 0.2962, 0.0996]}, {"w": "receptive", "b": [0.3011, 0.0792, 0.3731, 0.0996]}, {"w": "field", "b": [0.3779, 0.0792, 0.4131, 0.0996]}, {"w": "at", "b": [0.4179, 0.0792, 0.4323, 0.0996]}, {"w": "no", "b": [0.4372, 0.0792, 0.4582, 0.0996]}, {"w": "computational", "b": [0.4631, 0.0792, 0.5789, 0.0996]}, {"w": "price", "b": [0.5837, 0.0792, 0.6236, 0.0996]}, {"w": "and", "b": [0.6285, 0.0792, 0.6586, 0.0996]}, {"w": "using", "b": [0.6635, 0.0792, 0.7067, 0.0996]}, {"w": "no", "b": [0.7116, 0.0792, 0.7326, 0.0996]}, {"w": "extra", "b": [0.7375, 0.0792, 0.7774, 0.0996]}, {"w": "param‐", "b": [0.7823, 0.0792, 0.8408, 0.0996]}, {"w": "eters.", "b": [0.1949, 0.0973, 0.237, 0.1177]}]}, {"id": "b_1", "type": "paragraph", "text": "• tf.nn.depthwise_conv2d() can be used to create a depthwise convolutional layer (but you need to create the variables yourself). It applies every filter to every individual input channel independently. Thus, if there are fn filters and fn′ input channels, then this will output fn × fn′ feature maps.", "words": [{"w": "•", "b": [0.1773, 0.1224, 0.185, 0.1428]}, {"w": "tf.nn.depthwise_conv2d()", "b": [0.1949, 0.1254, 0.4211, 0.1398]}, {"w": "can", "b": [0.4261, 0.1224, 0.4541, 0.1428]}, {"w": "be", "b": [0.4591, 0.1224, 0.4776, 0.1428]}, {"w": "used", "b": [0.4827, 0.1224, 0.5194, 0.1428]}, {"w": "to", "b": [0.5244, 0.1224, 0.5406, 0.1428]}, {"w": "create", "b": [0.5456, 0.1224, 0.5926, 0.1428]}, {"w": "a", "b": [0.5976, 0.1224, 0.6063, 0.1428]}, {"w": "depthwise", "b": [0.6113, 0.1222, 0.6879, 0.1428]}, {"w": "convolutional", "b": [0.6929, 0.1222, 0.7977, 0.1428]}, {"w": "layer", "b": [0.8028, 0.1222, 0.8408, 0.1428]}, {"w": "(but", "b": [0.1949, 0.1405, 0.2285, 0.1609]}, {"w": "you", "b": [0.2363, 0.1405, 0.2661, 0.1609]}, {"w": "need", "b": [0.2739, 0.1405, 0.3121, 0.1609]}, {"w": "to", "b": [0.3199, 0.1405, 0.3361, 0.1609]}, {"w": "create", "b": [0.3439, 0.1405, 0.3909, 0.1609]}, {"w": "the", "b": [0.3987, 0.1405, 0.4238, 0.1609]}, {"w": "variables", "b": [0.4316, 0.1405, 0.5017, 0.1609]}, {"w": "yourself).", "b": [0.5095, 0.1405, 0.5862, 0.1609]}, {"w": "It", "b": [0.594, 0.1405, 0.6061, 0.1609]}, {"w": "applies", "b": [0.6139, 0.1405, 0.6691, 0.1609]}, {"w": "every", "b": [0.6769, 0.1405, 0.72, 0.1609]}, {"w": "filter", "b": [0.7278, 0.1405, 0.7659, 0.1609]}, {"w": "to", "b": [0.7737, 0.1405, 0.7899, 0.1609]}, {"w": "every", "b": [0.7977, 0.1405, 0.8408, 0.1609]}, {"w": "individual", "b": [0.1949, 0.1586, 0.2762, 0.179]}, {"w": "input", "b": [0.2817, 0.1586, 0.3245, 0.179]}, {"w": "channel", "b": [0.3301, 0.1586, 0.393, 0.179]}, {"w": "independently.", "b": [0.3986, 0.1586, 0.516, 0.179]}, {"w": "Thus,", "b": [0.5216, 0.1586, 0.5664, 0.179]}, {"w": "if", "b": [0.572, 0.1586, 0.5831, 0.179]}, {"w": "there", "b": [0.5887, 0.1586, 0.6296, 0.179]}, {"w": "are", "b": [0.6352, 0.1586, 0.6597, 0.179]}, {"w": "fn", "b": [0.6653, 0.1585, 0.6812, 0.1821]}, {"w": "filters", "b": [0.6868, 0.1586, 0.7322, 0.179]}, {"w": "and", "b": [0.7377, 0.1586, 0.7678, 0.179]}, {"w": "fn′", "b": [0.7734, 0.1585, 0.7924, 0.1821]}, {"w": "input", "b": [0.798, 0.1586, 0.8408, 0.179]}, {"w": "channels,", "b": [0.1949, 0.1768, 0.2696, 0.1972]}, {"w": "then", "b": [0.2741, 0.1768, 0.31, 0.1972]}, {"w": "this", "b": [0.3145, 0.1768, 0.3438, 0.1972]}, {"w": "will", "b": [0.3483, 0.1768, 0.3772, 0.1972]}, {"w": "output", "b": [0.3817, 0.1768, 0.4354, 0.1972]}, {"w": "fn", "b": [0.4399, 0.1766, 0.4559, 0.2002]}, {"w": "×", "b": [0.4604, 0.1768, 0.4719, 0.1972]}, {"w": "fn′", "b": [0.4764, 0.1766, 0.4954, 0.2002]}, {"w": "feature", "b": [0.4999, 0.1768, 0.5549, 0.1972]}, {"w": "maps.", "b": [0.5594, 0.1768, 0.6062, 0.1972]}]}, {"id": "b_2", "type": "paragraph", "text": "This solution is okay, but still too imprecise. To do better, the authors added skip con‐ nections from lower layers: for example, they upsampled the output image by a factor of 2 (instead of 32), and they added the output of a lower layer that had this double resolution. Then they upsampled the result by a factor of 16, leading to a total upsam‐ pling factor of 32 (see Figure 14-28). This recovered some of the spatial resolution that was lost in earlier pooling layers. In their best architecture, they used a second similar skip connection to recover even finer details from an even lower layer: in short, the output of the original CNN goes through the following extra steps: upscale ×2, add the output of a lower layer (of the appropriate scale), upscale ×2, add the out‐ put of an even lower layer, and finally upscale ×8. It is even possible to scale up beyond the size of the original image: this can be used to increase the resolution of an image, which is a technique called super-resolution.", "words": [{"w": "This", "b": [0.1429, 0.233, 0.1801, 0.2544]}, {"w": "solution", "b": [0.1849, 0.233, 0.2535, 0.2544]}, {"w": "is", "b": [0.2584, 0.233, 0.2716, 0.2544]}, {"w": "okay,", "b": [0.2765, 0.233, 0.319, 0.2544]}, {"w": "but", "b": [0.3239, 0.233, 0.3519, 0.2544]}, {"w": "still", "b": [0.3567, 0.233, 0.3869, 0.2544]}, {"w": "too", "b": [0.3917, 0.233, 0.4193, 0.2544]}, {"w": "imprecise.", "b": [0.4242, 0.233, 0.5096, 0.2544]}, {"w": "To", "b": [0.5145, 0.233, 0.5359, 0.2544]}, {"w": "do", "b": [0.5408, 0.233, 0.5624, 0.2544]}, {"w": "better,", "b": [0.5673, 0.233, 0.6194, 0.2544]}, {"w": "the", "b": [0.6243, 0.233, 0.6507, 0.2544]}, {"w": "authors", "b": [0.6555, 0.233, 0.7188, 0.2544]}, {"w": "added", "b": [0.7237, 0.233, 0.7747, 0.2544]}, {"w": "skip", "b": [0.7796, 0.233, 0.814, 0.2544]}, {"w": "con‐", "b": [0.8189, 0.233, 0.8572, 0.2544]}, {"w": "nections", "b": [0.1429, 0.252, 0.2135, 0.2734]}, {"w": "from", "b": [0.2186, 0.252, 0.2601, 0.2734]}, {"w": "lower", "b": [0.2652, 0.252, 0.3119, 0.2734]}, {"w": "layers:", "b": [0.3169, 0.252, 0.3695, 0.2734]}, {"w": "for", "b": [0.3745, 0.252, 0.3991, 0.2734]}, {"w": "example,", "b": [0.4041, 0.252, 0.4784, 0.2734]}, {"w": "they", "b": [0.4834, 0.252, 0.5193, 0.2734]}, {"w": "upsampled", "b": [0.5243, 0.252, 0.6158, 0.2734]}, {"w": "the", "b": [0.6208, 0.252, 0.6471, 0.2734]}, {"w": "output", "b": [0.6522, 0.252, 0.7085, 0.2734]}, {"w": "image", "b": [0.7136, 0.252, 0.764, 0.2734]}, {"w": "by", "b": [0.769, 0.252, 0.7891, 0.2734]}, {"w": "a", "b": [0.7941, 0.252, 0.8033, 0.2734]}, {"w": "factor", "b": [0.8083, 0.252, 0.8571, 0.2734]}, {"w": "of", "b": [0.1429, 0.2711, 0.1596, 0.2925]}, {"w": "2", "b": [0.1659, 0.2711, 0.1759, 0.2925]}, {"w": "(instead", "b": [0.1821, 0.2711, 0.2493, 0.2925]}, {"w": "of", "b": [0.2555, 0.2711, 0.2723, 0.2925]}, {"w": "32),", "b": [0.2785, 0.2711, 0.3104, 0.2925]}, {"w": "and", "b": [0.3166, 0.2711, 0.3482, 0.2925]}, {"w": "they", "b": [0.3544, 0.2711, 0.3903, 0.2925]}, {"w": "added", "b": [0.3965, 0.2711, 0.4475, 0.2925]}, {"w": "the", "b": [0.4537, 0.2711, 0.48, 0.2925]}, {"w": "output", "b": [0.4863, 0.2711, 0.5426, 0.2925]}, {"w": "of", "b": [0.5488, 0.2711, 0.5656, 0.2925]}, {"w": "a", "b": [0.5718, 0.2711, 0.581, 0.2925]}, {"w": "lower", "b": [0.5872, 0.2711, 0.6339, 0.2925]}, {"w": "layer", "b": [0.6402, 0.2711, 0.6803, 0.2925]}, {"w": "that", "b": [0.6866, 0.2711, 0.7191, 0.2925]}, {"w": "had", "b": [0.7253, 0.2711, 0.7566, 0.2925]}, {"w": "this", "b": [0.7628, 0.2711, 0.7935, 0.2925]}, {"w": "double", "b": [0.7997, 0.2711, 0.8571, 0.2925]}, {"w": "resolution.", "b": [0.1429, 0.2901, 0.2327, 0.3115]}, {"w": "Then", "b": [0.2375, 0.2901, 0.2818, 0.3115]}, {"w": "they", "b": [0.2865, 0.2901, 0.3224, 0.3115]}, {"w": "upsampled", "b": [0.3272, 0.2901, 0.4187, 0.3115]}, {"w": "the", "b": [0.4235, 0.2901, 0.4498, 0.3115]}, {"w": "result", "b": [0.4546, 0.2901, 0.5015, 0.3115]}, {"w": "by", "b": [0.5063, 0.2901, 0.5264, 0.3115]}, {"w": "a", "b": [0.5312, 0.2901, 0.5404, 0.3115]}, {"w": "factor", "b": [0.5452, 0.2901, 0.594, 0.3115]}, {"w": "of", "b": [0.5988, 0.2901, 0.6156, 0.3115]}, {"w": "16,", "b": [0.6203, 0.2901, 0.6451, 0.3115]}, {"w": "leading", "b": [0.6499, 0.2901, 0.7109, 0.3115]}, {"w": "to", "b": [0.7157, 0.2901, 0.7326, 0.3115]}, {"w": "a", "b": [0.7374, 0.2901, 0.7466, 0.3115]}, {"w": "total", "b": [0.7514, 0.2901, 0.7891, 0.3115]}, {"w": "upsam‐", "b": [0.7939, 0.2901, 0.8571, 0.3115]}, {"w": "pling", "b": [0.1429, 0.3092, 0.1858, 0.3306]}, {"w": "factor", "b": [0.193, 0.3092, 0.2419, 0.3306]}, {"w": "of", "b": [0.2491, 0.3092, 0.2659, 0.3306]}, {"w": "32", "b": [0.2732, 0.3092, 0.2932, 0.3306]}, {"w": "(see", "b": [0.3004, 0.3092, 0.333, 0.3306]}, {"w": "Figure", "b": [0.3403, 0.3092, 0.3943, 0.3306]}, {"w": "14-28).", "b": [0.4015, 0.3092, 0.4609, 0.3306]}, {"w": "This", "b": [0.4682, 0.3092, 0.5054, 0.3306]}, {"w": "recovered", "b": [0.5126, 0.3092, 0.5947, 0.3306]}, {"w": "some", "b": [0.602, 0.3092, 0.6462, 0.3306]}, {"w": "of", "b": [0.6534, 0.3092, 0.6702, 0.3306]}, {"w": "the", "b": [0.6775, 0.3092, 0.7038, 0.3306]}, {"w": "spatial", "b": [0.7111, 0.3092, 0.7647, 0.3306]}, {"w": "resolution", "b": [0.772, 0.3092, 0.8572, 0.3306]}, {"w": "that", "b": [0.1429, 0.3282, 0.1754, 0.3496]}, {"w": "was", "b": [0.1822, 0.3282, 0.2133, 0.3496]}, {"w": "lost", "b": [0.2201, 0.3282, 0.25, 0.3496]}, {"w": "in", "b": [0.2568, 0.3282, 0.2738, 0.3496]}, {"w": "earlier", "b": [0.2806, 0.3282, 0.3337, 0.3496]}, {"w": "pooling", "b": [0.3405, 0.3282, 0.4047, 0.3496]}, {"w": "layers.", "b": [0.4115, 0.3282, 0.4641, 0.3496]}, {"w": "In", "b": [0.4709, 0.3282, 0.4894, 0.3496]}, {"w": "their", "b": [0.4962, 0.3282, 0.5358, 0.3496]}, {"w": "best", "b": [0.5426, 0.3282, 0.5761, 0.3496]}, {"w": "architecture,", "b": [0.5829, 0.3282, 0.688, 0.3496]}, {"w": "they", "b": [0.6948, 0.3282, 0.7307, 0.3496]}, {"w": "used", "b": [0.7375, 0.3282, 0.7761, 0.3496]}, {"w": "a", "b": [0.7829, 0.3282, 0.792, 0.3496]}, {"w": "second", "b": [0.7988, 0.3282, 0.8571, 0.3496]}, {"w": "similar", "b": [0.1429, 0.3473, 0.2009, 0.3687]}, {"w": "skip", "b": [0.2091, 0.3473, 0.2435, 0.3687]}, {"w": "connection", "b": [0.2517, 0.3473, 0.3456, 0.3687]}, {"w": "to", "b": [0.3537, 0.3473, 0.3707, 0.3687]}, {"w": "recover", "b": [0.3789, 0.3473, 0.4412, 0.3687]}, {"w": "even", "b": [0.4493, 0.3473, 0.4881, 0.3687]}, {"w": "finer", "b": [0.4963, 0.3473, 0.536, 0.3687]}, {"w": "details", "b": [0.5442, 0.3473, 0.598, 0.3687]}, {"w": "from", "b": [0.6062, 0.3473, 0.6478, 0.3687]}, {"w": "an", "b": [0.656, 0.3473, 0.6765, 0.3687]}, {"w": "even", "b": [0.6847, 0.3473, 0.7234, 0.3687]}, {"w": "lower", "b": [0.7316, 0.3473, 0.7784, 0.3687]}, {"w": "layer:", "b": [0.7865, 0.3473, 0.832, 0.3687]}, {"w": "in", "b": [0.8402, 0.3473, 0.8571, 0.3687]}, {"w": "short,", "b": [0.1429, 0.3663, 0.1911, 0.3877]}, {"w": "the", "b": [0.1965, 0.3663, 0.2229, 0.3877]}, {"w": "output", "b": [0.2283, 0.3663, 0.2847, 0.3877]}, {"w": "of", "b": [0.2901, 0.3663, 0.3069, 0.3877]}, {"w": "the", "b": [0.3123, 0.3663, 0.3387, 0.3877]}, {"w": "original", "b": [0.3441, 0.3663, 0.4092, 0.3877]}, {"w": "CNN", "b": [0.4146, 0.3663, 0.4594, 0.3877]}, {"w": "goes", "b": [0.4648, 0.3663, 0.5017, 0.3877]}, {"w": "through", "b": [0.5071, 0.3663, 0.5749, 0.3877]}, {"w": "the", "b": [0.5803, 0.3663, 0.6067, 0.3877]}, {"w": "following", "b": [0.6121, 0.3663, 0.6911, 0.3877]}, {"w": "extra", "b": [0.6965, 0.3663, 0.7384, 0.3877]}, {"w": "steps:", "b": [0.7438, 0.3663, 0.79, 0.3877]}, {"w": "upscale", "b": [0.7954, 0.3663, 0.8572, 0.3877]}, {"w": "×2,", "b": [0.1429, 0.3854, 0.1697, 0.4068]}, {"w": "add", "b": [0.1747, 0.3854, 0.2058, 0.4068]}, {"w": "the", "b": [0.2109, 0.3854, 0.2372, 0.4068]}, {"w": "output", "b": [0.2422, 0.3854, 0.2986, 0.4068]}, {"w": "of", "b": [0.3036, 0.3854, 0.3204, 0.4068]}, {"w": "a", "b": [0.3254, 0.3854, 0.3345, 0.4068]}, {"w": "lower", "b": [0.3395, 0.3854, 0.3863, 0.4068]}, {"w": "layer", "b": [0.3913, 0.3854, 0.4315, 0.4068]}, {"w": "(of", "b": [0.4365, 0.3854, 0.4605, 0.4068]}, {"w": "the", "b": [0.4655, 0.3854, 0.4918, 0.4068]}, {"w": "appropriate", "b": [0.4968, 0.3854, 0.5939, 0.4068]}, {"w": "scale),", "b": [0.599, 0.3854, 0.6506, 0.4068]}, {"w": "upscale", "b": [0.6556, 0.3854, 0.7174, 0.4068]}, {"w": "×2,", "b": [0.7224, 0.3854, 0.7492, 0.4068]}, {"w": "add", "b": [0.7542, 0.3854, 0.7853, 0.4068]}, {"w": "the", "b": [0.7904, 0.3854, 0.8167, 0.4068]}, {"w": "out‐", "b": [0.8217, 0.3854, 0.8571, 0.4068]}, {"w": "put", "b": [0.1429, 0.4044, 0.1712, 0.4258]}, {"w": "of", "b": [0.1797, 0.4044, 0.1965, 0.4258]}, {"w": "an", "b": [0.2051, 0.4044, 0.2256, 0.4258]}, {"w": "even", "b": [0.2341, 0.4044, 0.2729, 0.4258]}, {"w": "lower", "b": [0.2814, 0.4044, 0.3282, 0.4258]}, {"w": "layer,", "b": [0.3367, 0.4044, 0.3803, 0.4258]}, {"w": "and", "b": [0.3889, 0.4044, 0.4204, 0.4258]}, {"w": "finally", "b": [0.4289, 0.4044, 0.4813, 0.4258]}, {"w": "upscale", "b": [0.4899, 0.4044, 0.5516, 0.4258]}, {"w": "×8.", "b": [0.5601, 0.4044, 0.587, 0.4258]}, {"w": "It", "b": [0.5955, 0.4044, 0.6081, 0.4258]}, {"w": "is", "b": [0.6167, 0.4044, 0.6299, 0.4258]}, {"w": "even", "b": [0.6384, 0.4044, 0.6772, 0.4258]}, {"w": "possible", "b": [0.6857, 0.4044, 0.7528, 0.4258]}, {"w": "to", "b": [0.7614, 0.4044, 0.7784, 0.4258]}, {"w": "scale", "b": [0.7869, 0.4044, 0.8266, 0.4258]}, {"w": "up", "b": [0.8352, 0.4044, 0.8571, 0.4258]}, {"w": "beyond", "b": [0.1429, 0.4235, 0.2049, 0.4449]}, {"w": "the", "b": [0.2099, 0.4235, 0.2362, 0.4449]}, {"w": "size", "b": [0.2412, 0.4235, 0.272, 0.4449]}, {"w": "of", "b": [0.277, 0.4235, 0.2938, 0.4449]}, {"w": "the", "b": [0.2988, 0.4235, 0.3251, 0.4449]}, {"w": "original", "b": [0.3301, 0.4235, 0.3952, 0.4449]}, {"w": "image:", "b": [0.4002, 0.4235, 0.4553, 0.4449]}, {"w": "this", "b": [0.4603, 0.4235, 0.491, 0.4449]}, {"w": "can", "b": [0.496, 0.4235, 0.5254, 0.4449]}, {"w": "be", "b": [0.5304, 0.4235, 0.5498, 0.4449]}, {"w": "used", "b": [0.5548, 0.4235, 0.5934, 0.4449]}, {"w": "to", "b": [0.5984, 0.4235, 0.6153, 0.4449]}, {"w": "increase", "b": [0.6203, 0.4235, 0.6884, 0.4449]}, {"w": "the", "b": [0.6933, 0.4235, 0.7197, 0.4449]}, {"w": "resolution", "b": [0.7247, 0.4235, 0.8098, 0.4449]}, {"w": "of", "b": [0.8148, 0.4235, 0.8316, 0.4449]}, {"w": "an", "b": [0.8366, 0.4235, 0.8571, 0.4449]}, {"w": "image,", "b": [0.1429, 0.4425, 0.198, 0.4639]}, {"w": "which", "b": [0.2027, 0.4425, 0.2537, 0.4639]}, {"w": "is", "b": [0.2584, 0.4425, 0.2716, 0.4639]}, {"w": "a", "b": [0.2763, 0.4425, 0.2855, 0.4639]}, {"w": "technique", "b": [0.2902, 0.4425, 0.3729, 0.4639]}, {"w": "called", "b": [0.3776, 0.4425, 0.426, 0.4639]}, {"w": "super-resolution.", "b": [0.4307, 0.4423, 0.566, 0.4639]}]}, {"id": "b_3", "type": "equation", "text": "Figure 14-28. Skip layers recover some spatial resolution from lower layers", "words": [{"w": "Figure", "b": [0.1429, 0.6465, 0.1943, 0.6681]}, {"w": "14-28.", "b": [0.1991, 0.6465, 0.2507, 0.6681]}, {"w": "Skip", "b": [0.2554, 0.6465, 0.2901, 0.6681]}, {"w": "layers", "b": [0.2949, 0.6465, 0.3417, 0.6681]}, {"w": "recover", "b": [0.3465, 0.6465, 0.4045, 0.6681]}, {"w": "some", "b": [0.4092, 0.6465, 0.4505, 0.6681]}, {"w": "spatial", "b": [0.4553, 0.6465, 0.5089, 0.6681]}, {"w": "resolution", "b": [0.5136, 0.6465, 0.5939, 0.6681]}, {"w": "from", "b": [0.5987, 0.6465, 0.6377, 0.6681]}, {"w": "lower", "b": [0.6425, 0.6465, 0.6869, 0.6681]}, {"w": "layers", "b": [0.6917, 0.6465, 0.7386, 0.6681]}]}, {"id": "b_4", "type": "paragraph", "text": "Once again, many github repositories provide TensorFlow implementations of semantic segmentation (TensorFlow 1 for now), and you will even find a pretrained instance segmentation model in the TensorFlow Models project. Instance segmenta‐ tion is similar to semantic segmentation, but instead of merging all objects of the same class into one big lump, each object is distinguished from the others (e.g., it identifies each individual bicycle). At the present, they provide multiple implementa‐ tions of the Mask R-CNN architecture, which was proposed in a 2017 paper: it extends the Faster R-CNN model by additionally producing a pixel-mask for each bounding box. So not only do you get a bounding box around each object, with a set of estimated class probabilities, you also get a pixel mask that locates pixels in the bounding box that belong to the object.", "words": [{"w": "Once", "b": [0.1429, 0.6839, 0.1875, 0.7053]}, {"w": "again,", "b": [0.2001, 0.6839, 0.2498, 0.7053]}, {"w": "many", "b": [0.2624, 0.6839, 0.3091, 0.7053]}, {"w": "github", "b": [0.3217, 0.6839, 0.3758, 0.7053]}, {"w": "repositories", "b": [0.3884, 0.6839, 0.4865, 0.7053]}, {"w": "provide", "b": [0.4991, 0.6839, 0.5634, 0.7053]}, {"w": "TensorFlow", "b": [0.576, 0.6839, 0.6743, 0.7053]}, {"w": "implementations", "b": [0.6869, 0.6839, 0.8278, 0.7053]}, {"w": "of", "b": [0.8404, 0.6839, 0.8572, 0.7053]}, {"w": "semantic", "b": [0.1429, 0.7029, 0.2173, 0.7243]}, {"w": "segmentation", "b": [0.2237, 0.7029, 0.3359, 0.7243]}, {"w": "(TensorFlow", "b": [0.3423, 0.7029, 0.4478, 0.7243]}, {"w": "1", "b": [0.4541, 0.7029, 0.4641, 0.7243]}, {"w": "for", "b": [0.4705, 0.7029, 0.4951, 0.7243]}, {"w": "now),", "b": [0.5014, 0.7029, 0.5497, 0.7243]}, {"w": "and", "b": [0.5561, 0.7029, 0.5876, 0.7243]}, {"w": "you", "b": [0.594, 0.7029, 0.6252, 0.7243]}, {"w": "will", "b": [0.6316, 0.7029, 0.662, 0.7243]}, {"w": "even", "b": [0.6684, 0.7029, 0.7071, 0.7243]}, {"w": "find", "b": [0.7135, 0.7029, 0.7477, 0.7243]}, {"w": "a", "b": [0.7541, 0.7029, 0.7632, 0.7243]}, {"w": "pretrained", "b": [0.7696, 0.7029, 0.8571, 0.7243]}, {"w": "instance", "b": [0.1429, 0.7218, 0.2093, 0.7434]}, {"w": "segmentation", "b": [0.2165, 0.7218, 0.3242, 0.7434]}, {"w": "model", "b": [0.3313, 0.722, 0.3841, 0.7434]}, {"w": "in", "b": [0.3913, 0.722, 0.4082, 0.7434]}, {"w": "the", "b": [0.4154, 0.722, 0.4417, 0.7434]}, {"w": "TensorFlow", "b": [0.4488, 0.722, 0.5471, 0.7434]}, {"w": "Models", "b": [0.5542, 0.722, 0.6156, 0.7434]}, {"w": "project.", "b": [0.6227, 0.722, 0.6861, 0.7434]}, {"w": "Instance", "b": [0.6932, 0.722, 0.7639, 0.7434]}, {"w": "segmenta‐", "b": [0.7711, 0.722, 0.8571, 0.7434]}, {"w": "tion", "b": [0.1428, 0.741, 0.1768, 0.7624]}, {"w": "is", "b": [0.1849, 0.741, 0.1981, 0.7624]}, {"w": "similar", "b": [0.2061, 0.741, 0.2642, 0.7624]}, {"w": "to", "b": [0.2722, 0.741, 0.2892, 0.7624]}, {"w": "semantic", "b": [0.2973, 0.741, 0.3717, 0.7624]}, {"w": "segmentation,", "b": [0.3798, 0.741, 0.4968, 0.7624]}, {"w": "but", "b": [0.5048, 0.741, 0.5328, 0.7624]}, {"w": "instead", "b": [0.5409, 0.741, 0.6009, 0.7624]}, {"w": "of", "b": [0.6089, 0.741, 0.6257, 0.7624]}, {"w": "merging", "b": [0.6338, 0.741, 0.7039, 0.7624]}, {"w": "all", "b": [0.7119, 0.741, 0.7316, 0.7624]}, {"w": "objects", "b": [0.7397, 0.741, 0.7979, 0.7624]}, {"w": "of", "b": [0.806, 0.741, 0.8227, 0.7624]}, {"w": "the", "b": [0.8308, 0.741, 0.8571, 0.7624]}, {"w": "same", "b": [0.1429, 0.7601, 0.1856, 0.7815]}, {"w": "class", "b": [0.1933, 0.7601, 0.2318, 0.7815]}, {"w": "into", "b": [0.2395, 0.7601, 0.2731, 0.7815]}, {"w": "one", "b": [0.2808, 0.7601, 0.3117, 0.7815]}, {"w": "big", "b": [0.3194, 0.7601, 0.3453, 0.7815]}, {"w": "lump,", "b": [0.353, 0.7601, 0.4011, 0.7815]}, {"w": "each", "b": [0.4088, 0.7601, 0.4468, 0.7815]}, {"w": "object", "b": [0.4545, 0.7601, 0.505, 0.7815]}, {"w": "is", "b": [0.5128, 0.7601, 0.526, 0.7815]}, {"w": "distinguished", "b": [0.5337, 0.7601, 0.6463, 0.7815]}, {"w": "from", "b": [0.654, 0.7601, 0.6956, 0.7815]}, {"w": "the", "b": [0.7033, 0.7601, 0.7297, 0.7815]}, {"w": "others", "b": [0.7374, 0.7601, 0.7897, 0.7815]}, {"w": "(e.g.,", "b": [0.7974, 0.7601, 0.8375, 0.7815]}, {"w": "it", "b": [0.8452, 0.7601, 0.8571, 0.7815]}, {"w": "identifies", "b": [0.1429, 0.7791, 0.2195, 0.8005]}, {"w": "each", "b": [0.225, 0.7791, 0.263, 0.8005]}, {"w": "individual", "b": [0.2685, 0.7791, 0.3538, 0.8005]}, {"w": "bicycle).", "b": [0.3593, 0.7791, 0.4287, 0.8005]}, {"w": "At", "b": [0.4343, 0.7791, 0.4542, 0.8005]}, {"w": "the", "b": [0.4597, 0.7791, 0.486, 0.8005]}, {"w": "present,", "b": [0.4916, 0.7791, 0.5577, 0.8005]}, {"w": "they", "b": [0.5632, 0.7791, 0.5991, 0.8005]}, {"w": "provide", "b": [0.6046, 0.7791, 0.669, 0.8005]}, {"w": "multiple", "b": [0.6745, 0.7791, 0.7445, 0.8005]}, {"w": "implementa‐", "b": [0.75, 0.7791, 0.8571, 0.8005]}, {"w": "tions", "b": [0.1428, 0.7982, 0.1845, 0.8196]}, {"w": "of", "b": [0.1943, 0.7982, 0.2111, 0.8196]}, {"w": "the", "b": [0.221, 0.7982, 0.2473, 0.8196]}, {"w": "Mask", "b": [0.2572, 0.7979, 0.3015, 0.8196]}, {"w": "R-CNN", "b": [0.3114, 0.7979, 0.3729, 0.8196]}, {"w": "architecture,", "b": [0.3828, 0.7982, 0.488, 0.8196]}, {"w": "which", "b": [0.4978, 0.7982, 0.5487, 0.8196]}, {"w": "was", "b": [0.5586, 0.7982, 0.5897, 0.8196]}, {"w": "proposed", "b": [0.5995, 0.7982, 0.6778, 0.8196]}, {"w": "in", "b": [0.6877, 0.7982, 0.7047, 0.8196]}, {"w": "a", "b": [0.7146, 0.7982, 0.7237, 0.8196]}, {"w": "2017", "b": [0.7336, 0.7982, 0.7736, 0.8196]}, {"w": "paper:", "b": [0.7834, 0.7982, 0.8353, 0.8196]}, {"w": "it", "b": [0.8452, 0.7982, 0.8571, 0.8196]}, {"w": "extends", "b": [0.1429, 0.8172, 0.2068, 0.8386]}, {"w": "the", "b": [0.2146, 0.8172, 0.241, 0.8386]}, {"w": "Faster", "b": [0.2488, 0.8172, 0.2991, 0.8386]}, {"w": "R-CNN", "b": [0.3069, 0.8172, 0.3712, 0.8386]}, {"w": "model", "b": [0.379, 0.8172, 0.4318, 0.8386]}, {"w": "by", "b": [0.4396, 0.8172, 0.4598, 0.8386]}, {"w": "additionally", "b": [0.4676, 0.8172, 0.5675, 0.8386]}, {"w": "producing", "b": [0.5753, 0.8172, 0.6622, 0.8386]}, {"w": "a", "b": [0.67, 0.8172, 0.6792, 0.8386]}, {"w": "pixel-mask", "b": [0.687, 0.8172, 0.7791, 0.8386]}, {"w": "for", "b": [0.7869, 0.8172, 0.8114, 0.8386]}, {"w": "each", "b": [0.8192, 0.8172, 0.8571, 0.8386]}, {"w": "bounding", "b": [0.1429, 0.8363, 0.2243, 0.8577]}, {"w": "box.", "b": [0.2298, 0.8363, 0.2656, 0.8577]}, {"w": "So", "b": [0.2711, 0.8363, 0.2916, 0.8577]}, {"w": "not", "b": [0.2971, 0.8363, 0.3255, 0.8577]}, {"w": "only", "b": [0.331, 0.8363, 0.3679, 0.8577]}, {"w": "do", "b": [0.3734, 0.8363, 0.395, 0.8577]}, {"w": "you", "b": [0.4006, 0.8363, 0.4318, 0.8577]}, {"w": "get", "b": [0.4373, 0.8363, 0.4623, 0.8577]}, {"w": "a", "b": [0.4678, 0.8363, 0.477, 0.8577]}, {"w": "bounding", "b": [0.4825, 0.8363, 0.5639, 0.8577]}, {"w": "box", "b": [0.5694, 0.8363, 0.6004, 0.8577]}, {"w": "around", "b": [0.606, 0.8363, 0.6669, 0.8577]}, {"w": "each", "b": [0.6725, 0.8363, 0.7104, 0.8577]}, {"w": "object,", "b": [0.7159, 0.8363, 0.7712, 0.8577]}, {"w": "with", "b": [0.7768, 0.8363, 0.8141, 0.8577]}, {"w": "a", "b": [0.8196, 0.8363, 0.8288, 0.8577]}, {"w": "set", "b": [0.8343, 0.8363, 0.8571, 0.8577]}, {"w": "of", "b": [0.1429, 0.8553, 0.1596, 0.8767]}, {"w": "estimated", "b": [0.1672, 0.8553, 0.2477, 0.8767]}, {"w": "class", "b": [0.2553, 0.8553, 0.2938, 0.8767]}, {"w": "probabilities,", "b": [0.3014, 0.8553, 0.4106, 0.8767]}, {"w": "you", "b": [0.4182, 0.8553, 0.4495, 0.8767]}, {"w": "also", "b": [0.457, 0.8553, 0.4897, 0.8767]}, {"w": "get", "b": [0.4973, 0.8553, 0.5223, 0.8767]}, {"w": "a", "b": [0.5299, 0.8553, 0.539, 0.8767]}, {"w": "pixel", "b": [0.5466, 0.8553, 0.5871, 0.8767]}, {"w": "mask", "b": [0.5947, 0.8553, 0.6389, 0.8767]}, {"w": "that", "b": [0.6465, 0.8553, 0.679, 0.8767]}, {"w": "locates", "b": [0.6866, 0.8553, 0.7429, 0.8767]}, {"w": "pixels", "b": [0.7505, 0.8553, 0.7986, 0.8767]}, {"w": "in", "b": [0.8062, 0.8553, 0.8232, 0.8767]}, {"w": "the", "b": [0.8308, 0.8553, 0.8571, 0.8767]}, {"w": "bounding", "b": [0.1428, 0.8743, 0.2242, 0.8958]}, {"w": "box", "b": [0.229, 0.8743, 0.26, 0.8958]}, {"w": "that", "b": [0.2647, 0.8743, 0.2973, 0.8958]}, {"w": "belong", "b": [0.3021, 0.8743, 0.3585, 0.8958]}, {"w": "to", "b": [0.3633, 0.8743, 0.3802, 0.8958]}, {"w": "the", "b": [0.385, 0.8743, 0.4113, 0.8958]}, {"w": "object.", "b": [0.416, 0.8743, 0.4713, 0.8958]}]}, {"id": "b_5", "type": "paragraph", "text": "Semantic Segmentation | 481", "words": [{"w": "Semantic", "b": [0.6545, 0.9225, 0.7092, 0.9388]}, {"w": "Segmentation", "b": [0.712, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "481", "b": [0.8353, 0.9225, 0.8572, 0.9388]}]}]}, {"page": 508, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "32 “Matrix Capsules with EM Routing,” G. Hinton, S. Sabour, N. Frosst (2018).", "words": [{"w": "32", "b": [0.1385, 0.8764, 0.1518, 0.8907]}, {"w": "“Matrix", "b": [0.1587, 0.8749, 0.2077, 0.8912]}, {"w": "Capsules", "b": [0.2113, 0.8749, 0.2677, 0.8912]}, {"w": "with", "b": [0.2713, 0.8749, 0.2997, 0.8912]}, {"w": "EM", "b": [0.3033, 0.8749, 0.3265, 0.8912]}, {"w": "Routing,”", "b": [0.3301, 0.8749, 0.3894, 0.8912]}, {"w": "G.", "b": [0.393, 0.8749, 0.408, 0.8912]}, {"w": "Hinton,", "b": [0.4116, 0.8749, 0.4617, 0.8912]}, {"w": "S.", "b": [0.4653, 0.8749, 0.4764, 0.8912]}, {"w": "Sabour,", "b": [0.48, 0.8749, 0.5276, 0.8912]}, {"w": "N.", "b": [0.5312, 0.8749, 0.5466, 0.8912]}, {"w": "Frosst", "b": [0.5502, 0.8749, 0.5891, 0.8912]}, {"w": "(2018).", "b": [0.5927, 0.8749, 0.6378, 0.8912]}]}, {"id": "b_1", "type": "paragraph", "text": "As you can see, the field of Deep Computer Vision is vast and moving fast, with all sorts of architectures popping out every year, all based on Convolutional Neural Net‐ works. The progress made in just a few years has been astounding, and researchers are now focusing on harder and harder problems, such as adversarial learning (which attempts to make the network more resistant to images designed to fool it), explaina‐ bility (understanding why the network makes a specific classification), realistic image generation (which we will come back to in ???), single-shot learning (a system that can recognize an object after it has seen it just once), and much more. Some even explore completely novel architectures, such as Geoffrey Hinton’s capsule networks32 (I pre‐ sented them in a couple videos, with the corresponding code in a notebook). Now on to the next chapter, where we will look at how to process sequential data such as time series using Recurrent Neural Networks and Convolutional Neural Networks.", "words": [{"w": "As", "b": [0.1429, 0.0791, 0.1649, 0.1005]}, {"w": "you", "b": [0.1714, 0.0791, 0.2027, 0.1005]}, {"w": "can", "b": [0.2092, 0.0791, 0.2385, 0.1005]}, {"w": "see,", "b": [0.245, 0.0791, 0.2752, 0.1005]}, {"w": "the", "b": [0.2817, 0.0791, 0.308, 0.1005]}, {"w": "field", "b": [0.3145, 0.0791, 0.3514, 0.1005]}, {"w": "of", "b": [0.3579, 0.0791, 0.3747, 0.1005]}, {"w": "Deep", "b": [0.3812, 0.0791, 0.4251, 0.1005]}, {"w": "Computer", "b": [0.4317, 0.0791, 0.5177, 0.1005]}, {"w": "Vision", "b": [0.5242, 0.0791, 0.5789, 0.1005]}, {"w": "is", "b": [0.5854, 0.0791, 0.5986, 0.1005]}, {"w": "vast", "b": [0.6051, 0.0791, 0.6379, 0.1005]}, {"w": "and", "b": [0.6444, 0.0791, 0.676, 0.1005]}, {"w": "moving", "b": [0.6825, 0.0791, 0.7465, 0.1005]}, {"w": "fast,", "b": [0.753, 0.0791, 0.7871, 0.1005]}, {"w": "with", "b": [0.7936, 0.0791, 0.831, 0.1005]}, {"w": "all", "b": [0.8375, 0.0791, 0.8572, 0.1005]}, {"w": "sorts", "b": [0.1429, 0.0981, 0.1829, 0.1195]}, {"w": "of", "b": [0.1881, 0.0981, 0.2049, 0.1195]}, {"w": "architectures", "b": [0.2102, 0.0981, 0.3183, 0.1195]}, {"w": "popping", "b": [0.3236, 0.0981, 0.3937, 0.1195]}, {"w": "out", "b": [0.3989, 0.0981, 0.427, 0.1195]}, {"w": "every", "b": [0.4323, 0.0981, 0.4775, 0.1195]}, {"w": "year,", "b": [0.4828, 0.0981, 0.5215, 0.1195]}, {"w": "all", "b": [0.5268, 0.0981, 0.5465, 0.1195]}, {"w": "based", "b": [0.5518, 0.0981, 0.599, 0.1195]}, {"w": "on", "b": [0.6043, 0.0981, 0.6263, 0.1195]}, {"w": "Convolutional", "b": [0.6316, 0.0981, 0.752, 0.1195]}, {"w": "Neural", "b": [0.7573, 0.0981, 0.8143, 0.1195]}, {"w": "Net‐", "b": [0.8196, 0.0981, 0.8571, 0.1195]}, {"w": "works.", "b": [0.1429, 0.1172, 0.1982, 0.1386]}, {"w": "The", "b": [0.205, 0.1172, 0.2378, 0.1386]}, {"w": "progress", "b": [0.2446, 0.1172, 0.3155, 0.1386]}, {"w": "made", "b": [0.3223, 0.1172, 0.3684, 0.1386]}, {"w": "in", "b": [0.3752, 0.1172, 0.3922, 0.1386]}, {"w": "just", "b": [0.399, 0.1172, 0.4294, 0.1386]}, {"w": "a", "b": [0.4362, 0.1172, 0.4453, 0.1386]}, {"w": "few", "b": [0.4521, 0.1172, 0.4814, 0.1386]}, {"w": "years", "b": [0.4882, 0.1172, 0.5312, 0.1386]}, {"w": "has", "b": [0.538, 0.1172, 0.5659, 0.1386]}, {"w": "been", "b": [0.5727, 0.1172, 0.6124, 0.1386]}, {"w": "astounding,", "b": [0.6192, 0.1172, 0.7179, 0.1386]}, {"w": "and", "b": [0.7247, 0.1172, 0.7562, 0.1386]}, {"w": "researchers", "b": [0.763, 0.1172, 0.8571, 0.1386]}, {"w": "are", "b": [0.1428, 0.1362, 0.1686, 0.1576]}, {"w": "now", "b": [0.1737, 0.1362, 0.21, 0.1576]}, {"w": "focusing", "b": [0.2152, 0.1362, 0.2862, 0.1576]}, {"w": "on", "b": [0.2914, 0.1362, 0.3134, 0.1576]}, {"w": "harder", "b": [0.3185, 0.1362, 0.3741, 0.1576]}, {"w": "and", "b": [0.3793, 0.1362, 0.4108, 0.1576]}, {"w": "harder", "b": [0.4159, 0.1362, 0.4715, 0.1576]}, {"w": "problems,", "b": [0.4767, 0.1362, 0.5601, 0.1576]}, {"w": "such", "b": [0.5653, 0.1362, 0.6039, 0.1576]}, {"w": "as", "b": [0.609, 0.1362, 0.6258, 0.1576]}, {"w": "adversarial", "b": [0.631, 0.136, 0.722, 0.1576]}, {"w": "learning", "b": [0.7267, 0.136, 0.7934, 0.1576]}, {"w": "(which", "b": [0.799, 0.1362, 0.8572, 0.1576]}, {"w": "attempts", "b": [0.1429, 0.1553, 0.2148, 0.1767]}, {"w": "to", "b": [0.2201, 0.1553, 0.2371, 0.1767]}, {"w": "make", "b": [0.2424, 0.1553, 0.2878, 0.1767]}, {"w": "the", "b": [0.2931, 0.1553, 0.3195, 0.1767]}, {"w": "network", "b": [0.3248, 0.1553, 0.3944, 0.1767]}, {"w": "more", "b": [0.3997, 0.1553, 0.444, 0.1767]}, {"w": "resistant", "b": [0.4493, 0.1553, 0.5196, 0.1767]}, {"w": "to", "b": [0.5249, 0.1553, 0.5419, 0.1767]}, {"w": "images", "b": [0.5472, 0.1553, 0.6053, 0.1767]}, {"w": "designed", "b": [0.6106, 0.1553, 0.6847, 0.1767]}, {"w": "to", "b": [0.69, 0.1553, 0.707, 0.1767]}, {"w": "fool", "b": [0.7123, 0.1553, 0.745, 0.1767]}, {"w": "it),", "b": [0.7504, 0.1553, 0.7743, 0.1767]}, {"w": "explaina‐", "b": [0.7796, 0.1553, 0.8571, 0.1767]}, {"w": "bility", "b": [0.1429, 0.1743, 0.1858, 0.1957]}, {"w": "(understanding", "b": [0.1912, 0.1743, 0.3207, 0.1957]}, {"w": "why", "b": [0.3261, 0.1743, 0.3606, 0.1957]}, {"w": "the", "b": [0.366, 0.1743, 0.3923, 0.1957]}, {"w": "network", "b": [0.3977, 0.1743, 0.4673, 0.1957]}, {"w": "makes", "b": [0.4727, 0.1743, 0.5257, 0.1957]}, {"w": "a", "b": [0.5311, 0.1743, 0.5402, 0.1957]}, {"w": "specific", "b": [0.5456, 0.1743, 0.608, 0.1957]}, {"w": "classification),", "b": [0.6134, 0.1743, 0.7327, 0.1957]}, {"w": "realistic", "b": [0.7381, 0.1743, 0.8031, 0.1957]}, {"w": "image", "b": [0.8085, 0.1741, 0.8571, 0.1957]}, {"w": "generation", "b": [0.1428, 0.1931, 0.2287, 0.2148]}, {"w": "(which", "b": [0.2341, 0.1933, 0.2922, 0.2148]}, {"w": "we", "b": [0.2976, 0.1933, 0.3207, 0.2148]}, {"w": "will", "b": [0.3261, 0.1933, 0.3565, 0.2148]}, {"w": "come", "b": [0.3619, 0.1933, 0.4072, 0.2148]}, {"w": "back", "b": [0.4126, 0.1933, 0.4515, 0.2148]}, {"w": "to", "b": [0.4569, 0.1933, 0.4739, 0.2148]}, {"w": "in", "b": [0.4792, 0.1933, 0.4962, 0.2148]}, {"w": "???),", "b": [0.5016, 0.1933, 0.5373, 0.2148]}, {"w": "single-shot", "b": [0.5427, 0.1931, 0.628, 0.2148]}, {"w": "learning", "b": [0.6328, 0.1931, 0.6995, 0.2148]}, {"w": "(a", "b": [0.7056, 0.1933, 0.7219, 0.2148]}, {"w": "system", "b": [0.7273, 0.1933, 0.7844, 0.2148]}, {"w": "that", "b": [0.7898, 0.1933, 0.8224, 0.2148]}, {"w": "can", "b": [0.8278, 0.1933, 0.8571, 0.2148]}, {"w": "recognize", "b": [0.1428, 0.2124, 0.2232, 0.2338]}, {"w": "an", "b": [0.2284, 0.2124, 0.249, 0.2338]}, {"w": "object", "b": [0.2542, 0.2124, 0.3048, 0.2338]}, {"w": "after", "b": [0.31, 0.2124, 0.3483, 0.2338]}, {"w": "it", "b": [0.3535, 0.2124, 0.3654, 0.2338]}, {"w": "has", "b": [0.3707, 0.2124, 0.3986, 0.2338]}, {"w": "seen", "b": [0.4038, 0.2124, 0.4406, 0.2338]}, {"w": "it", "b": [0.4458, 0.2124, 0.4577, 0.2338]}, {"w": "just", "b": [0.463, 0.2124, 0.4934, 0.2338]}, {"w": "once),", "b": [0.4986, 0.2124, 0.5502, 0.2338]}, {"w": "and", "b": [0.5555, 0.2124, 0.587, 0.2338]}, {"w": "much", "b": [0.5923, 0.2124, 0.6399, 0.2338]}, {"w": "more.", "b": [0.6452, 0.2124, 0.6942, 0.2338]}, {"w": "Some", "b": [0.6994, 0.2124, 0.7458, 0.2338]}, {"w": "even", "b": [0.7511, 0.2124, 0.7898, 0.2338]}, {"w": "explore", "b": [0.795, 0.2124, 0.8571, 0.2338]}, {"w": "completely", "b": [0.1429, 0.2314, 0.234, 0.2529]}, {"w": "novel", "b": [0.2414, 0.2314, 0.2872, 0.2529]}, {"w": "architectures,", "b": [0.2946, 0.2314, 0.4074, 0.2529]}, {"w": "such", "b": [0.4148, 0.2314, 0.4534, 0.2529]}, {"w": "as", "b": [0.4608, 0.2314, 0.4776, 0.2529]}, {"w": "Geoffrey", "b": [0.4849, 0.2314, 0.5578, 0.2529]}, {"w": "Hinton’s", "b": [0.5652, 0.2314, 0.6347, 0.2529]}, {"w": "capsule", "b": [0.642, 0.2312, 0.7011, 0.2529]}, {"w": "networks32", "b": [0.7085, 0.2312, 0.7932, 0.2529]}, {"w": "(I", "b": [0.8005, 0.2314, 0.8149, 0.2529]}, {"w": "pre‐", "b": [0.8222, 0.2314, 0.8571, 0.2529]}, {"w": "sented", "b": [0.1429, 0.2505, 0.1966, 0.2719]}, {"w": "them", "b": [0.2018, 0.2505, 0.2452, 0.2719]}, {"w": "in", "b": [0.2504, 0.2505, 0.2674, 0.2719]}, {"w": "a", "b": [0.2726, 0.2505, 0.2817, 0.2719]}, {"w": "couple", "b": [0.287, 0.2505, 0.3425, 0.2719]}, {"w": "videos,", "b": [0.3477, 0.2505, 0.4058, 0.2719]}, {"w": "with", "b": [0.411, 0.2505, 0.4484, 0.2719]}, {"w": "the", "b": [0.4536, 0.2505, 0.4799, 0.2719]}, {"w": "corresponding", "b": [0.4851, 0.2505, 0.6072, 0.2719]}, {"w": "code", "b": [0.6124, 0.2505, 0.6517, 0.2719]}, {"w": "in", "b": [0.6569, 0.2505, 0.6739, 0.2719]}, {"w": "a", "b": [0.6791, 0.2505, 0.6883, 0.2719]}, {"w": "notebook).", "b": [0.6935, 0.2505, 0.7848, 0.2719]}, {"w": "Now", "b": [0.79, 0.2505, 0.8299, 0.2719]}, {"w": "on", "b": [0.8351, 0.2505, 0.8571, 0.2719]}, {"w": "to", "b": [0.1428, 0.2695, 0.1598, 0.291]}, {"w": "the", "b": [0.1651, 0.2695, 0.1914, 0.291]}, {"w": "next", "b": [0.1967, 0.2695, 0.2331, 0.291]}, {"w": "chapter,", "b": [0.2384, 0.2695, 0.3043, 0.291]}, {"w": "where", "b": [0.3096, 0.2695, 0.3604, 0.291]}, {"w": "we", "b": [0.3657, 0.2695, 0.3888, 0.291]}, {"w": "will", "b": [0.3941, 0.2695, 0.4245, 0.291]}, {"w": "look", "b": [0.4297, 0.2695, 0.4666, 0.291]}, {"w": "at", "b": [0.4718, 0.2695, 0.4869, 0.291]}, {"w": "how", "b": [0.4922, 0.2695, 0.5282, 0.291]}, {"w": "to", "b": [0.5334, 0.2695, 0.5504, 0.291]}, {"w": "process", "b": [0.5557, 0.2695, 0.6179, 0.291]}, {"w": "sequential", "b": [0.6232, 0.2695, 0.7076, 0.291]}, {"w": "data", "b": [0.7128, 0.2695, 0.7481, 0.291]}, {"w": "such", "b": [0.7533, 0.2695, 0.792, 0.291]}, {"w": "as", "b": [0.7972, 0.2695, 0.814, 0.291]}, {"w": "time", "b": [0.8193, 0.2695, 0.8571, 0.291]}, {"w": "series", "b": [0.1429, 0.2886, 0.1892, 0.31]}, {"w": "using", "b": [0.1939, 0.2886, 0.2393, 0.31]}, {"w": "Recurrent", "b": [0.2441, 0.2886, 0.3274, 0.31]}, {"w": "Neural", "b": [0.3321, 0.2886, 0.3892, 0.31]}, {"w": "Networks", "b": [0.3939, 0.2886, 0.4747, 0.31]}, {"w": "and", "b": [0.4794, 0.2886, 0.5109, 0.31]}, {"w": "Convolutional", "b": [0.5157, 0.2886, 0.636, 0.31]}, {"w": "Neural", "b": [0.6408, 0.2886, 0.6978, 0.31]}, {"w": "Networks.", "b": [0.7025, 0.2886, 0.788, 0.31]}]}, {"id": "b_2", "type": "paragraph", "text": "Exercises", "words": [{"w": "Exercises", "b": [0.1429, 0.323, 0.2533, 0.3573]}]}, {"id": "b_3", "type": "paragraph", "text": "1. What are the advantages of a CNN over a fully connected DNN for image classi‐ fication?", "words": [{"w": "1.", "b": [0.1534, 0.3702, 0.1682, 0.3916]}, {"w": "What", "b": [0.1786, 0.3702, 0.225, 0.3916]}, {"w": "are", "b": [0.2304, 0.3702, 0.2561, 0.3916]}, {"w": "the", "b": [0.2615, 0.3702, 0.2879, 0.3916]}, {"w": "advantages", "b": [0.2933, 0.3702, 0.3849, 0.3916]}, {"w": "of", "b": [0.3903, 0.3702, 0.4071, 0.3916]}, {"w": "a", "b": [0.4125, 0.3702, 0.4217, 0.3916]}, {"w": "CNN", "b": [0.4271, 0.3702, 0.4719, 0.3916]}, {"w": "over", "b": [0.4773, 0.3702, 0.5141, 0.3916]}, {"w": "a", "b": [0.5195, 0.3702, 0.5286, 0.3916]}, {"w": "fully", "b": [0.534, 0.3702, 0.5714, 0.3916]}, {"w": "connected", "b": [0.5768, 0.3702, 0.6629, 0.3916]}, {"w": "DNN", "b": [0.6683, 0.3702, 0.7145, 0.3916]}, {"w": "for", "b": [0.7199, 0.3702, 0.7444, 0.3916]}, {"w": "image", "b": [0.7498, 0.3702, 0.8002, 0.3916]}, {"w": "classi‐", "b": [0.8056, 0.3702, 0.8571, 0.3916]}, {"w": "fication?", "b": [0.1786, 0.3893, 0.2497, 0.4107]}]}, {"id": "b_4", "type": "paragraph", "text": "2. Consider a CNN composed of three convolutional layers, each with 3 × 3 kernels, a stride of 2, and SAME padding. The lowest layer outputs 100 feature maps, the middle one outputs 200, and the top one outputs 400. The input images are RGB images of 200 × 300 pixels. What is the total number of parameters in the CNN? If we are using 32-bit floats, at least how much RAM will this network require when making a prediction for a single instance? What about when training on a mini-batch of 50 images?", "words": [{"w": "2.", "b": [0.1534, 0.4144, 0.1682, 0.4358]}, {"w": "Consider", "b": [0.1786, 0.4144, 0.2553, 0.4358]}, {"w": "a", "b": [0.2601, 0.4144, 0.2692, 0.4358]}, {"w": "CNN", "b": [0.2741, 0.4144, 0.3189, 0.4358]}, {"w": "composed", "b": [0.3237, 0.4144, 0.4089, 0.4358]}, {"w": "of", "b": [0.4137, 0.4144, 0.4305, 0.4358]}, {"w": "three", "b": [0.4354, 0.4144, 0.4783, 0.4358]}, {"w": "convolutional", "b": [0.4831, 0.4144, 0.5985, 0.4358]}, {"w": "layers,", "b": [0.6033, 0.4144, 0.6559, 0.4358]}, {"w": "each", "b": [0.6607, 0.4144, 0.6987, 0.4358]}, {"w": "with", "b": [0.7035, 0.4144, 0.7408, 0.4358]}, {"w": "3", "b": [0.7457, 0.4144, 0.7557, 0.4358]}, {"w": "×", "b": [0.7605, 0.4144, 0.7726, 0.4358]}, {"w": "3", "b": [0.7775, 0.4144, 0.7875, 0.4358]}, {"w": "kernels,", "b": [0.7923, 0.4144, 0.8571, 0.4358]}, {"w": "a", "b": [0.1786, 0.4334, 0.1877, 0.4548]}, {"w": "stride", "b": [0.1933, 0.4334, 0.2404, 0.4548]}, {"w": "of", "b": [0.246, 0.4334, 0.2628, 0.4548]}, {"w": "2,", "b": [0.2683, 0.4334, 0.2831, 0.4548]}, {"w": "and", "b": [0.2886, 0.4334, 0.3202, 0.4548]}, {"w": "SAME", "b": [0.3257, 0.4334, 0.3804, 0.4548]}, {"w": "padding.", "b": [0.3859, 0.4334, 0.4595, 0.4548]}, {"w": "The", "b": [0.465, 0.4334, 0.4978, 0.4548]}, {"w": "lowest", "b": [0.5034, 0.4334, 0.5564, 0.4548]}, {"w": "layer", "b": [0.562, 0.4334, 0.6022, 0.4548]}, {"w": "outputs", "b": [0.6077, 0.4334, 0.6717, 0.4548]}, {"w": "100", "b": [0.6773, 0.4334, 0.7073, 0.4548]}, {"w": "feature", "b": [0.7128, 0.4334, 0.7706, 0.4548]}, {"w": "maps,", "b": [0.7761, 0.4334, 0.8253, 0.4548]}, {"w": "the", "b": [0.8308, 0.4334, 0.8571, 0.4548]}, {"w": "middle", "b": [0.1786, 0.4525, 0.2373, 0.4739]}, {"w": "one", "b": [0.2426, 0.4525, 0.2734, 0.4739]}, {"w": "outputs", "b": [0.2787, 0.4525, 0.3427, 0.4739]}, {"w": "200,", "b": [0.3479, 0.4525, 0.3827, 0.4739]}, {"w": "and", "b": [0.3879, 0.4525, 0.4194, 0.4739]}, {"w": "the", "b": [0.4246, 0.4525, 0.451, 0.4739]}, {"w": "top", "b": [0.4562, 0.4525, 0.4841, 0.4739]}, {"w": "one", "b": [0.4893, 0.4525, 0.5202, 0.4739]}, {"w": "outputs", "b": [0.5254, 0.4525, 0.5894, 0.4739]}, {"w": "400.", "b": [0.5947, 0.4525, 0.6294, 0.4739]}, {"w": "The", "b": [0.6346, 0.4525, 0.6675, 0.4739]}, {"w": "input", "b": [0.6727, 0.4525, 0.7176, 0.4739]}, {"w": "images", "b": [0.7228, 0.4525, 0.7809, 0.4739]}, {"w": "are", "b": [0.7861, 0.4525, 0.8118, 0.4739]}, {"w": "RGB", "b": [0.8171, 0.4525, 0.8571, 0.4739]}, {"w": "images", "b": [0.1786, 0.4715, 0.2366, 0.4929]}, {"w": "of", "b": [0.2421, 0.4715, 0.2589, 0.4929]}, {"w": "200", "b": [0.2644, 0.4715, 0.2944, 0.4929]}, {"w": "×", "b": [0.2999, 0.4715, 0.312, 0.4929]}, {"w": "300", "b": [0.3175, 0.4715, 0.3475, 0.4929]}, {"w": "pixels.", "b": [0.353, 0.4715, 0.4058, 0.4929]}, {"w": "What", "b": [0.4113, 0.4715, 0.4578, 0.4929]}, {"w": "is", "b": [0.4633, 0.4715, 0.4765, 0.4929]}, {"w": "the", "b": [0.482, 0.4715, 0.5084, 0.4929]}, {"w": "total", "b": [0.5139, 0.4715, 0.5516, 0.4929]}, {"w": "number", "b": [0.5571, 0.4715, 0.6234, 0.4929]}, {"w": "of", "b": [0.6289, 0.4715, 0.6457, 0.4929]}, {"w": "parameters", "b": [0.6512, 0.4715, 0.7446, 0.4929]}, {"w": "in", "b": [0.7501, 0.4715, 0.7671, 0.4929]}, {"w": "the", "b": [0.7726, 0.4715, 0.7989, 0.4929]}, {"w": "CNN?", "b": [0.8044, 0.4715, 0.8571, 0.4929]}, {"w": "If", "b": [0.1786, 0.4906, 0.1919, 0.512]}, {"w": "we", "b": [0.1989, 0.4906, 0.222, 0.512]}, {"w": "are", "b": [0.229, 0.4906, 0.2548, 0.512]}, {"w": "using", "b": [0.2618, 0.4906, 0.3072, 0.512]}, {"w": "32-bit", "b": [0.3143, 0.4906, 0.3642, 0.512]}, {"w": "floats,", "b": [0.3712, 0.4906, 0.4208, 0.512]}, {"w": "at", "b": [0.4278, 0.4906, 0.4429, 0.512]}, {"w": "least", "b": [0.45, 0.4906, 0.4872, 0.512]}, {"w": "how", "b": [0.4943, 0.4906, 0.5303, 0.512]}, {"w": "much", "b": [0.5373, 0.4906, 0.585, 0.512]}, {"w": "RAM", "b": [0.592, 0.4906, 0.6379, 0.512]}, {"w": "will", "b": [0.6449, 0.4906, 0.6753, 0.512]}, {"w": "this", "b": [0.6824, 0.4906, 0.7131, 0.512]}, {"w": "network", "b": [0.7201, 0.4906, 0.7897, 0.512]}, {"w": "require", "b": [0.7967, 0.4906, 0.8572, 0.512]}, {"w": "when", "b": [0.1786, 0.5096, 0.2242, 0.531]}, {"w": "making", "b": [0.2301, 0.5096, 0.2934, 0.531]}, {"w": "a", "b": [0.2992, 0.5096, 0.3084, 0.531]}, {"w": "prediction", "b": [0.3143, 0.5096, 0.4011, 0.531]}, {"w": "for", "b": [0.407, 0.5096, 0.4315, 0.531]}, {"w": "a", "b": [0.4374, 0.5096, 0.4465, 0.531]}, {"w": "single", "b": [0.4524, 0.5096, 0.5009, 0.531]}, {"w": "instance?", "b": [0.5068, 0.5096, 0.5839, 0.531]}, {"w": "What", "b": [0.5898, 0.5096, 0.6362, 0.531]}, {"w": "about", "b": [0.6421, 0.5096, 0.6899, 0.531]}, {"w": "when", "b": [0.6958, 0.5096, 0.7414, 0.531]}, {"w": "training", "b": [0.7473, 0.5096, 0.8142, 0.531]}, {"w": "on", "b": [0.8201, 0.5096, 0.8421, 0.531]}, {"w": "a", "b": [0.848, 0.5096, 0.8571, 0.531]}, {"w": "mini-batch", "b": [0.1786, 0.5286, 0.2712, 0.5501]}, {"w": "of", "b": [0.276, 0.5286, 0.2928, 0.5501]}, {"w": "50", "b": [0.2975, 0.5286, 0.3175, 0.5501]}, {"w": "images?", "b": [0.3222, 0.5286, 0.3882, 0.5501]}]}, {"id": "b_5", "type": "paragraph", "text": "3. If your GPU runs out of memory while training a CNN, what are five things you could try to solve the problem?", "words": [{"w": "3.", "b": [0.1534, 0.5537, 0.1681, 0.5752]}, {"w": "If", "b": [0.1786, 0.5537, 0.1918, 0.5752]}, {"w": "your", "b": [0.1972, 0.5537, 0.2361, 0.5752]}, {"w": "GPU", "b": [0.2415, 0.5537, 0.2834, 0.5752]}, {"w": "runs", "b": [0.2887, 0.5537, 0.3266, 0.5752]}, {"w": "out", "b": [0.3319, 0.5537, 0.3599, 0.5752]}, {"w": "of", "b": [0.3653, 0.5537, 0.3821, 0.5752]}, {"w": "memory", "b": [0.3874, 0.5537, 0.4589, 0.5752]}, {"w": "while", "b": [0.4642, 0.5537, 0.5093, 0.5752]}, {"w": "training", "b": [0.5146, 0.5537, 0.5816, 0.5752]}, {"w": "a", "b": [0.5869, 0.5537, 0.596, 0.5752]}, {"w": "CNN,", "b": [0.6014, 0.5537, 0.6509, 0.5752]}, {"w": "what", "b": [0.6563, 0.5537, 0.6968, 0.5752]}, {"w": "are", "b": [0.7021, 0.5537, 0.7278, 0.5752]}, {"w": "five", "b": [0.7331, 0.5537, 0.7634, 0.5752]}, {"w": "things", "b": [0.7687, 0.5537, 0.8206, 0.5752]}, {"w": "you", "b": [0.8259, 0.5537, 0.8571, 0.5752]}, {"w": "could", "b": [0.1786, 0.5728, 0.2253, 0.5942]}, {"w": "try", "b": [0.2301, 0.5728, 0.2543, 0.5942]}, {"w": "to", "b": [0.2591, 0.5728, 0.276, 0.5942]}, {"w": "solve", "b": [0.2808, 0.5728, 0.3228, 0.5942]}, {"w": "the", "b": [0.3275, 0.5728, 0.3539, 0.5942]}, {"w": "problem?", "b": [0.3586, 0.5728, 0.4375, 0.5942]}]}, {"id": "b_6", "type": "paragraph", "text": "4. Why would you want to add a max pooling layer rather than a convolutional layer with the same stride?", "words": [{"w": "4.", "b": [0.1534, 0.5979, 0.1682, 0.6193]}, {"w": "Why", "b": [0.1786, 0.5979, 0.219, 0.6193]}, {"w": "would", "b": [0.2269, 0.5979, 0.2792, 0.6193]}, {"w": "you", "b": [0.2871, 0.5979, 0.3184, 0.6193]}, {"w": "want", "b": [0.3263, 0.5979, 0.3671, 0.6193]}, {"w": "to", "b": [0.375, 0.5979, 0.392, 0.6193]}, {"w": "add", "b": [0.3999, 0.5979, 0.4311, 0.6193]}, {"w": "a", "b": [0.439, 0.5979, 0.4481, 0.6193]}, {"w": "max", "b": [0.4561, 0.5979, 0.4921, 0.6193]}, {"w": "pooling", "b": [0.5001, 0.5979, 0.5642, 0.6193]}, {"w": "layer", "b": [0.5722, 0.5979, 0.6123, 0.6193]}, {"w": "rather", "b": [0.6203, 0.5979, 0.6708, 0.6193]}, {"w": "than", "b": [0.6788, 0.5979, 0.7168, 0.6193]}, {"w": "a", "b": [0.7247, 0.5979, 0.7339, 0.6193]}, {"w": "convolutional", "b": [0.7418, 0.5979, 0.8571, 0.6193]}, {"w": "layer", "b": [0.1786, 0.6169, 0.2188, 0.6383]}, {"w": "with", "b": [0.2235, 0.6169, 0.2608, 0.6383]}, {"w": "the", "b": [0.2656, 0.6169, 0.2919, 0.6383]}, {"w": "same", "b": [0.2966, 0.6169, 0.3393, 0.6383]}, {"w": "stride?", "b": [0.3441, 0.6169, 0.3991, 0.6383]}]}, {"id": "b_7", "type": "paragraph", "text": "5. When would you want to add a local response normalization layer?", "words": [{"w": "5.", "b": [0.1534, 0.642, 0.1682, 0.6634]}, {"w": "When", "b": [0.1786, 0.642, 0.2302, 0.6634]}, {"w": "would", "b": [0.2349, 0.642, 0.2871, 0.6634]}, {"w": "you", "b": [0.2919, 0.642, 0.3231, 0.6634]}, {"w": "want", "b": [0.3278, 0.642, 0.3686, 0.6634]}, {"w": "to", "b": [0.3733, 0.642, 0.3903, 0.6634]}, {"w": "add", "b": [0.395, 0.642, 0.4262, 0.6634]}, {"w": "a", "b": [0.4309, 0.642, 0.4401, 0.6634]}, {"w": "local", "b": [0.4448, 0.6418, 0.4826, 0.6634]}, {"w": "response", "b": [0.4874, 0.6418, 0.5557, 0.6634]}, {"w": "normalization", "b": [0.5605, 0.6418, 0.6766, 0.6634]}, {"w": "layer?", "b": [0.6814, 0.642, 0.7295, 0.6634]}]}, {"id": "b_8", "type": "paragraph", "text": "6. Can you name the main innovations in AlexNet, compared to LeNet-5? What about the main innovations in GoogLeNet, ResNet, SENet and Xception?", "words": [{"w": "6.", "b": [0.1534, 0.6671, 0.1682, 0.6885]}, {"w": "Can", "b": [0.1786, 0.6671, 0.213, 0.6885]}, {"w": "you", "b": [0.2207, 0.6671, 0.2519, 0.6885]}, {"w": "name", "b": [0.2597, 0.6671, 0.3061, 0.6885]}, {"w": "the", "b": [0.3138, 0.6671, 0.3402, 0.6885]}, {"w": "main", "b": [0.3479, 0.6671, 0.3911, 0.6885]}, {"w": "innovations", "b": [0.3988, 0.6671, 0.4978, 0.6885]}, {"w": "in", "b": [0.5055, 0.6671, 0.5225, 0.6885]}, {"w": "AlexNet,", "b": [0.5302, 0.6671, 0.6035, 0.6885]}, {"w": "compared", "b": [0.6112, 0.6671, 0.695, 0.6885]}, {"w": "to", "b": [0.7027, 0.6671, 0.7197, 0.6885]}, {"w": "LeNet-5?", "b": [0.7274, 0.6671, 0.803, 0.6885]}, {"w": "What", "b": [0.8107, 0.6671, 0.8571, 0.6885]}, {"w": "about", "b": [0.1786, 0.6862, 0.2263, 0.7076]}, {"w": "the", "b": [0.2311, 0.6862, 0.2574, 0.7076]}, {"w": "main", "b": [0.2621, 0.6862, 0.3053, 0.7076]}, {"w": "innovations", "b": [0.3101, 0.6862, 0.4091, 0.7076]}, {"w": "in", "b": [0.4138, 0.6862, 0.4308, 0.7076]}, {"w": "GoogLeNet,", "b": [0.4355, 0.6862, 0.5364, 0.7076]}, {"w": "ResNet,", "b": [0.5411, 0.6862, 0.6054, 0.7076]}, {"w": "SENet", "b": [0.6102, 0.6862, 0.6621, 0.7076]}, {"w": "and", "b": [0.6668, 0.6862, 0.6983, 0.7076]}, {"w": "Xception?", "b": [0.7031, 0.6862, 0.7871, 0.7076]}]}, {"id": "b_9", "type": "paragraph", "text": "7. What is a Fully Convolutional Network? How can you convert a dense layer into a convolutional layer?", "words": [{"w": "7.", "b": [0.1534, 0.7113, 0.1682, 0.7327]}, {"w": "What", "b": [0.1786, 0.7113, 0.225, 0.7327]}, {"w": "is", "b": [0.2306, 0.7113, 0.2438, 0.7327]}, {"w": "a", "b": [0.2493, 0.7113, 0.2585, 0.7327]}, {"w": "Fully", "b": [0.264, 0.7113, 0.3058, 0.7327]}, {"w": "Convolutional", "b": [0.3113, 0.7113, 0.4317, 0.7327]}, {"w": "Network?", "b": [0.4373, 0.7113, 0.5183, 0.7327]}, {"w": "How", "b": [0.5238, 0.7113, 0.5642, 0.7327]}, {"w": "can", "b": [0.5697, 0.7113, 0.599, 0.7327]}, {"w": "you", "b": [0.6046, 0.7113, 0.6358, 0.7327]}, {"w": "convert", "b": [0.6414, 0.7113, 0.7043, 0.7327]}, {"w": "a", "b": [0.7099, 0.7113, 0.719, 0.7327]}, {"w": "dense", "b": [0.7246, 0.7113, 0.7723, 0.7327]}, {"w": "layer", "b": [0.7778, 0.7113, 0.818, 0.7327]}, {"w": "into", "b": [0.8236, 0.7113, 0.8571, 0.7327]}, {"w": "a", "b": [0.1786, 0.7303, 0.1877, 0.7517]}, {"w": "convolutional", "b": [0.1924, 0.7303, 0.3078, 0.7517]}, {"w": "layer?", "b": [0.3125, 0.7303, 0.3606, 0.7517]}]}, {"id": "b_10", "type": "paragraph", "text": "8. What is the main technical difficulty of semantic segmentation?", "words": [{"w": "8.", "b": [0.1534, 0.7554, 0.1682, 0.7768]}, {"w": "What", "b": [0.1786, 0.7554, 0.225, 0.7768]}, {"w": "is", "b": [0.2298, 0.7554, 0.243, 0.7768]}, {"w": "the", "b": [0.2477, 0.7554, 0.274, 0.7768]}, {"w": "main", "b": [0.2788, 0.7554, 0.322, 0.7768]}, {"w": "technical", "b": [0.3267, 0.7554, 0.402, 0.7768]}, {"w": "difficulty", "b": [0.4068, 0.7554, 0.4823, 0.7768]}, {"w": "of", "b": [0.4871, 0.7554, 0.5039, 0.7768]}, {"w": "semantic", "b": [0.5086, 0.7554, 0.583, 0.7768]}, {"w": "segmentation?", "b": [0.5878, 0.7554, 0.7079, 0.7768]}]}, {"id": "b_11", "type": "paragraph", "text": "9. Build your own CNN from scratch and try to achieve the highest possible accu‐ racy on MNIST.", "words": [{"w": "9.", "b": [0.1534, 0.7805, 0.1682, 0.8019]}, {"w": "Build", "b": [0.1786, 0.7805, 0.2237, 0.8019]}, {"w": "your", "b": [0.2298, 0.7805, 0.2688, 0.8019]}, {"w": "own", "b": [0.2748, 0.7805, 0.3111, 0.8019]}, {"w": "CNN", "b": [0.3171, 0.7805, 0.3619, 0.8019]}, {"w": "from", "b": [0.368, 0.7805, 0.4096, 0.8019]}, {"w": "scratch", "b": [0.4156, 0.7805, 0.4748, 0.8019]}, {"w": "and", "b": [0.4809, 0.7805, 0.5124, 0.8019]}, {"w": "try", "b": [0.5185, 0.7805, 0.5427, 0.8019]}, {"w": "to", "b": [0.5488, 0.7805, 0.5658, 0.8019]}, {"w": "achieve", "b": [0.5718, 0.7805, 0.6338, 0.8019]}, {"w": "the", "b": [0.6399, 0.7805, 0.6662, 0.8019]}, {"w": "highest", "b": [0.6722, 0.7805, 0.7327, 0.8019]}, {"w": "possible", "b": [0.7387, 0.7805, 0.8058, 0.8019]}, {"w": "accu‐", "b": [0.8119, 0.7805, 0.8571, 0.8019]}, {"w": "racy", "b": [0.1786, 0.7995, 0.2138, 0.821]}, {"w": "on", "b": [0.2186, 0.7995, 0.2406, 0.821]}, {"w": "MNIST.", "b": [0.2453, 0.7995, 0.3119, 0.821]}]}, {"id": "b_12", "type": "paragraph", "text": "482 | Chapter 14: Deep Computer Vision Using Convolutional Neural Networks", "words": [{"w": "482", "b": [0.1428, 0.9225, 0.1647, 0.9388]}, {"w": "|", "b": [0.1826, 0.9225, 0.1863, 0.9388]}, {"w": "Chapter", "b": [0.2042, 0.9225, 0.2505, 0.9388]}, {"w": "14:", "b": [0.2533, 0.9225, 0.2717, 0.9388]}, {"w": "Deep", "b": [0.2745, 0.9225, 0.3046, 0.9388]}, {"w": "Computer", "b": [0.3074, 0.9225, 0.3655, 0.9388]}, {"w": "Vision", "b": [0.3683, 0.9225, 0.4041, 0.9388]}, {"w": "Using", "b": [0.4069, 0.9225, 0.44, 0.9388]}, {"w": "Convolutional", "b": [0.4428, 0.9225, 0.5248, 0.9388]}, {"w": "Neural", "b": [0.5276, 0.9225, 0.5668, 0.9388]}, {"w": "Networks", "b": [0.5696, 0.9225, 0.6258, 0.9388]}]}]}, {"page": 509, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "10. Use transfer learning for large image classification.", "words": [{"w": "10.", "b": [0.1434, 0.0791, 0.1682, 0.1005]}, {"w": "Use", "b": [0.1786, 0.0791, 0.2093, 0.1005]}, {"w": "transfer", "b": [0.214, 0.0791, 0.279, 0.1005]}, {"w": "learning", "b": [0.2838, 0.0791, 0.3529, 0.1005]}, {"w": "for", "b": [0.3576, 0.0791, 0.3821, 0.1005]}, {"w": "large", "b": [0.3869, 0.0791, 0.4276, 0.1005]}, {"w": "image", "b": [0.4324, 0.0791, 0.4828, 0.1005]}, {"w": "classification.", "b": [0.4875, 0.0791, 0.5996, 0.1005]}]}, {"id": "b_1", "type": "paragraph", "text": "a. Create a training set containing at least 100 images per class. For example, you", "words": [{"w": "a.", "b": [0.1801, 0.1042, 0.1939, 0.1256]}, {"w": "Create", "b": [0.2044, 0.1042, 0.2588, 0.1256]}, {"w": "a", "b": [0.2637, 0.1042, 0.2728, 0.1256]}, {"w": "training", "b": [0.2778, 0.1042, 0.3447, 0.1256]}, {"w": "set", "b": [0.3496, 0.1042, 0.3725, 0.1256]}, {"w": "containing", "b": [0.3774, 0.1042, 0.4671, 0.1256]}, {"w": "at", "b": [0.472, 0.1042, 0.4871, 0.1256]}, {"w": "least", "b": [0.492, 0.1042, 0.5293, 0.1256]}, {"w": "100", "b": [0.5342, 0.1042, 0.5642, 0.1256]}, {"w": "images", "b": [0.5692, 0.1042, 0.6272, 0.1256]}, {"w": "per", "b": [0.6321, 0.1042, 0.6596, 0.1256]}, {"w": "class.", "b": [0.6646, 0.1042, 0.7078, 0.1256]}, {"w": "For", "b": [0.7128, 0.1042, 0.7417, 0.1256]}, {"w": "example,", "b": [0.7467, 0.1042, 0.821, 0.1256]}, {"w": "you", "b": [0.8259, 0.1042, 0.8571, 0.1256]}]}, {"id": "b_2", "type": "paragraph", "text": "could classify your own pictures based on the location (beach, mountain, city, etc.), or alternatively you can just use an existing dataset (e.g., from Tensor‐ Flow Datasets).", "words": [{"w": "could", "b": [0.2044, 0.1232, 0.2511, 0.1446]}, {"w": "classify", "b": [0.2566, 0.1232, 0.3167, 0.1446]}, {"w": "your", "b": [0.3222, 0.1232, 0.3611, 0.1446]}, {"w": "own", "b": [0.3666, 0.1232, 0.4028, 0.1446]}, {"w": "pictures", "b": [0.4083, 0.1232, 0.4752, 0.1446]}, {"w": "based", "b": [0.4806, 0.1232, 0.5279, 0.1446]}, {"w": "on", "b": [0.5333, 0.1232, 0.5553, 0.1446]}, {"w": "the", "b": [0.5607, 0.1232, 0.5871, 0.1446]}, {"w": "location", "b": [0.5925, 0.1232, 0.6599, 0.1446]}, {"w": "(beach,", "b": [0.6653, 0.1232, 0.7258, 0.1446]}, {"w": "mountain,", "b": [0.7312, 0.1232, 0.8182, 0.1446]}, {"w": "city,", "b": [0.8236, 0.1232, 0.8571, 0.1446]}, {"w": "etc.),", "b": [0.2044, 0.1423, 0.2451, 0.1637]}, {"w": "or", "b": [0.252, 0.1423, 0.2703, 0.1637]}, {"w": "alternatively", "b": [0.2772, 0.1423, 0.38, 0.1637]}, {"w": "you", "b": [0.3869, 0.1423, 0.4181, 0.1637]}, {"w": "can", "b": [0.425, 0.1423, 0.4544, 0.1637]}, {"w": "just", "b": [0.4612, 0.1423, 0.4916, 0.1637]}, {"w": "use", "b": [0.4985, 0.1423, 0.5261, 0.1637]}, {"w": "an", "b": [0.533, 0.1423, 0.5535, 0.1637]}, {"w": "existing", "b": [0.5604, 0.1423, 0.6254, 0.1637]}, {"w": "dataset", "b": [0.6323, 0.1423, 0.6904, 0.1637]}, {"w": "(e.g.,", "b": [0.6973, 0.1423, 0.7373, 0.1637]}, {"w": "from", "b": [0.7442, 0.1423, 0.7858, 0.1637]}, {"w": "Tensor‐", "b": [0.7927, 0.1423, 0.8571, 0.1637]}, {"w": "Flow", "b": [0.2044, 0.1613, 0.2455, 0.1827]}, {"w": "Datasets).", "b": [0.2503, 0.1613, 0.3323, 0.1827]}]}, {"id": "b_3", "type": "paragraph", "text": "b. Split it into a training set, a validation set and a test set.", "words": [{"w": "b.", "b": [0.1792, 0.1864, 0.1939, 0.2078]}, {"w": "Split", "b": [0.2044, 0.1864, 0.2424, 0.2078]}, {"w": "it", "b": [0.2471, 0.1864, 0.259, 0.2078]}, {"w": "into", "b": [0.2638, 0.1864, 0.2973, 0.2078]}, {"w": "a", "b": [0.302, 0.1864, 0.3112, 0.2078]}, {"w": "training", "b": [0.3159, 0.1864, 0.3829, 0.2078]}, {"w": "set,", "b": [0.3876, 0.1864, 0.4152, 0.2078]}, {"w": "a", "b": [0.4199, 0.1864, 0.4291, 0.2078]}, {"w": "validation", "b": [0.4338, 0.1864, 0.5171, 0.2078]}, {"w": "set", "b": [0.5219, 0.1864, 0.5447, 0.2078]}, {"w": "and", "b": [0.5495, 0.1864, 0.581, 0.2078]}, {"w": "a", "b": [0.5857, 0.1864, 0.5949, 0.2078]}, {"w": "test", "b": [0.5996, 0.1864, 0.6288, 0.2078]}, {"w": "set.", "b": [0.6335, 0.1864, 0.6611, 0.2078]}]}, {"id": "b_4", "type": "paragraph", "text": "c. Build the input pipeline, including the appropriate preprocessing operations,", "words": [{"w": "c.", "b": [0.1804, 0.2115, 0.1939, 0.2329]}, {"w": "Build", "b": [0.2044, 0.2115, 0.2495, 0.2329]}, {"w": "the", "b": [0.2559, 0.2115, 0.2823, 0.2329]}, {"w": "input", "b": [0.2887, 0.2115, 0.3336, 0.2329]}, {"w": "pipeline,", "b": [0.34, 0.2115, 0.4121, 0.2329]}, {"w": "including", "b": [0.4185, 0.2115, 0.4984, 0.2329]}, {"w": "the", "b": [0.5048, 0.2115, 0.5311, 0.2329]}, {"w": "appropriate", "b": [0.5375, 0.2115, 0.6346, 0.2329]}, {"w": "preprocessing", "b": [0.641, 0.2115, 0.7575, 0.2329]}, {"w": "operations,", "b": [0.7639, 0.2115, 0.8571, 0.2329]}]}, {"id": "b_5", "type": "paragraph", "text": "and optionally add data augmentation.", "words": [{"w": "and", "b": [0.2044, 0.2305, 0.2359, 0.2519]}, {"w": "optionally", "b": [0.2406, 0.2305, 0.3254, 0.2519]}, {"w": "add", "b": [0.3301, 0.2305, 0.3613, 0.2519]}, {"w": "data", "b": [0.366, 0.2305, 0.4012, 0.2519]}, {"w": "augmentation.", "b": [0.406, 0.2305, 0.5263, 0.2519]}]}, {"id": "b_6", "type": "equation", "text": "d. Fine-tune a pretrained model on this dataset.", "words": [{"w": "d.", "b": [0.1782, 0.2556, 0.194, 0.277]}, {"w": "Fine-tune", "b": [0.2044, 0.2556, 0.2863, 0.277]}, {"w": "a", "b": [0.291, 0.2556, 0.3002, 0.277]}, {"w": "pretrained", "b": [0.3049, 0.2556, 0.3925, 0.277]}, {"w": "model", "b": [0.3972, 0.2556, 0.45, 0.277]}, {"w": "on", "b": [0.4547, 0.2556, 0.4768, 0.277]}, {"w": "this", "b": [0.4815, 0.2556, 0.5122, 0.277]}, {"w": "dataset.", "b": [0.5169, 0.2556, 0.5798, 0.277]}]}, {"id": "b_7", "type": "paragraph", "text": "11. Go through TensorFlow’s DeepDream tutorial. It is a fun way to familiarize your‐ self with various ways of visualizing the patterns learned by a CNN, and to gener‐ ate art using Deep Learning.", "words": [{"w": "11.", "b": [0.1434, 0.2807, 0.1682, 0.3021]}, {"w": "Go", "b": [0.1786, 0.2807, 0.2041, 0.3021]}, {"w": "through", "b": [0.2088, 0.2807, 0.2766, 0.3021]}, {"w": "TensorFlow’s", "b": [0.2813, 0.2807, 0.3899, 0.3021]}, {"w": "DeepDream", "b": [0.3953, 0.2807, 0.4973, 0.3021]}, {"w": "tutorial.", "b": [0.502, 0.2807, 0.5691, 0.3021]}, {"w": "It", "b": [0.574, 0.2807, 0.5867, 0.3021]}, {"w": "is", "b": [0.5916, 0.2807, 0.6049, 0.3021]}, {"w": "a", "b": [0.6098, 0.2807, 0.619, 0.3021]}, {"w": "fun", "b": [0.6239, 0.2807, 0.6525, 0.3021]}, {"w": "way", "b": [0.6575, 0.2807, 0.6901, 0.3021]}, {"w": "to", "b": [0.695, 0.2807, 0.712, 0.3021]}, {"w": "familiarize", "b": [0.7169, 0.2807, 0.8058, 0.3021]}, {"w": "your‐", "b": [0.8107, 0.2807, 0.8571, 0.3021]}, {"w": "self", "b": [0.1786, 0.2998, 0.2065, 0.3212]}, {"w": "with", "b": [0.2113, 0.2998, 0.2487, 0.3212]}, {"w": "various", "b": [0.2535, 0.2998, 0.3149, 0.3212]}, {"w": "ways", "b": [0.3197, 0.2998, 0.36, 0.3212]}, {"w": "of", "b": [0.3648, 0.2998, 0.3816, 0.3212]}, {"w": "visualizing", "b": [0.3864, 0.2998, 0.4758, 0.3212]}, {"w": "the", "b": [0.4807, 0.2998, 0.507, 0.3212]}, {"w": "patterns", "b": [0.5118, 0.2998, 0.5798, 0.3212]}, {"w": "learned", "b": [0.5846, 0.2998, 0.6469, 0.3212]}, {"w": "by", "b": [0.6517, 0.2998, 0.6718, 0.3212]}, {"w": "a", "b": [0.6767, 0.2998, 0.6858, 0.3212]}, {"w": "CNN,", "b": [0.6906, 0.2998, 0.7402, 0.3212]}, {"w": "and", "b": [0.745, 0.2998, 0.7765, 0.3212]}, {"w": "to", "b": [0.7814, 0.2998, 0.7983, 0.3212]}, {"w": "gener‐", "b": [0.8032, 0.2998, 0.8572, 0.3212]}, {"w": "ate", "b": [0.1786, 0.3188, 0.2025, 0.3402]}, {"w": "art", "b": [0.2073, 0.3188, 0.2305, 0.3402]}, {"w": "using", "b": [0.2352, 0.3188, 0.2807, 0.3402]}, {"w": "Deep", "b": [0.2854, 0.3188, 0.3293, 0.3402]}, {"w": "Learning.", "b": [0.334, 0.3188, 0.4139, 0.3402]}]}, {"id": "b_8", "type": "paragraph", "text": "Solutions to these exercises are available in ???.", "words": [{"w": "Solutions", "b": [0.1429, 0.353, 0.2213, 0.3744]}, {"w": "to", "b": [0.226, 0.353, 0.243, 0.3744]}, {"w": "these", "b": [0.2477, 0.353, 0.2906, 0.3744]}, {"w": "exercises", "b": [0.2953, 0.353, 0.3691, 0.3744]}, {"w": "are", "b": [0.3738, 0.353, 0.3996, 0.3744]}, {"w": "available", "b": [0.4043, 0.353, 0.4766, 0.3744]}, {"w": "in", "b": [0.4813, 0.353, 0.4983, 0.3744]}, {"w": "???.", "b": [0.503, 0.353, 0.5314, 0.3744]}]}, {"id": "b_9", "type": "paragraph", "text": "Exercises | 483", "words": [{"w": "Exercises", "b": [0.7433, 0.9225, 0.7958, 0.9388]}, {"w": "|", "b": [0.8137, 0.9225, 0.8174, 0.9388]}, {"w": "483", "b": [0.8353, 0.9225, 0.8571, 0.9388]}]}]}, {"page": 510, "dimensions": {"width": 504.0, "height": 661.5}, "blocks": [{"id": "b_0", "type": "paragraph", "text": "About the Author", "words": [{"w": "About", "b": [0.1429, 0.0914, 0.2053, 0.12]}, {"w": "the", "b": [0.2102, 0.0914, 0.245, 0.12]}, {"w": "Author", "b": [0.25, 0.0914, 0.3212, 0.12]}]}, {"id": "b_1", "type": "paragraph", "text": "Aurélien Géron is a Machine Learning consultant. A former Googler, he led the You‐ Tube video classification team from 2013 to 2016. He was also a founder and CTO of Wifirst from 2002 to 2012, a leading Wireless ISP in France; and a founder and CTO of Polyconseil in 2001, the firm that now manages the electric car sharing service Autolib’.", "words": [{"w": "Aurélien", "b": [0.1429, 0.1287, 0.2186, 0.1507]}, {"w": "Géron", "b": [0.2231, 0.1287, 0.2783, 0.1507]}, {"w": "is", "b": [0.2837, 0.1293, 0.2969, 0.1507]}, {"w": "a", "b": [0.302, 0.1293, 0.3111, 0.1507]}, {"w": "Machine", "b": [0.3162, 0.1293, 0.3893, 0.1507]}, {"w": "Learning", "b": [0.3943, 0.1293, 0.4694, 0.1507]}, {"w": "consultant.", "b": [0.4744, 0.1293, 0.5669, 0.1507]}, {"w": "A", "b": [0.5719, 0.1293, 0.5863, 0.1507]}, {"w": "former", "b": [0.5913, 0.1293, 0.6495, 0.1507]}, {"w": "Googler,", "b": [0.6546, 0.1293, 0.7257, 0.1507]}, {"w": "he", "b": [0.7308, 0.1293, 0.7508, 0.1507]}, {"w": "led", "b": [0.7558, 0.1293, 0.7809, 0.1507]}, {"w": "the", "b": [0.786, 0.1293, 0.8123, 0.1507]}, {"w": "You‐", "b": [0.8174, 0.1293, 0.8571, 0.1507]}, {"w": "Tube", "b": [0.1429, 0.1483, 0.1842, 0.1697]}, {"w": "video", "b": [0.1896, 0.1483, 0.2353, 0.1697]}, {"w": "classification", "b": [0.2406, 0.1483, 0.348, 0.1697]}, {"w": "team", "b": [0.3534, 0.1483, 0.3948, 0.1697]}, {"w": "from", "b": [0.4002, 0.1483, 0.4418, 0.1697]}, {"w": "2013", "b": [0.4471, 0.1483, 0.4871, 0.1697]}, {"w": "to", "b": [0.4925, 0.1483, 0.5095, 0.1697]}, {"w": "2016.", "b": [0.5148, 0.1483, 0.5596, 0.1697]}, {"w": "He", "b": [0.565, 0.1483, 0.5892, 0.1697]}, {"w": "was", "b": [0.5946, 0.1483, 0.6257, 0.1697]}, {"w": "also", "b": [0.631, 0.1483, 0.6637, 0.1697]}, {"w": "a", "b": [0.6691, 0.1483, 0.6782, 0.1697]}, {"w": "founder", "b": [0.6836, 0.1483, 0.7504, 0.1697]}, {"w": "and", "b": [0.7558, 0.1483, 0.7874, 0.1697]}, {"w": "CTO", "b": [0.7927, 0.1483, 0.835, 0.1697]}, {"w": "of", "b": [0.8404, 0.1483, 0.8571, 0.1697]}, {"w": "Wifirst", "b": [0.1429, 0.1674, 0.2013, 0.1888]}, {"w": "from", "b": [0.2068, 0.1674, 0.2484, 0.1888]}, {"w": "2002", "b": [0.2539, 0.1674, 0.2939, 0.1888]}, {"w": "to", "b": [0.2994, 0.1674, 0.3164, 0.1888]}, {"w": "2012,", "b": [0.3219, 0.1674, 0.3667, 0.1888]}, {"w": "a", "b": [0.3722, 0.1674, 0.3813, 0.1888]}, {"w": "leading", "b": [0.3868, 0.1674, 0.4478, 0.1888]}, {"w": "Wireless", "b": [0.4533, 0.1674, 0.5243, 0.1888]}, {"w": "ISP", "b": [0.5298, 0.1674, 0.5585, 0.1888]}, {"w": "in", "b": [0.564, 0.1674, 0.581, 0.1888]}, {"w": "France;", "b": [0.5865, 0.1674, 0.6482, 0.1888]}, {"w": "and", "b": [0.6538, 0.1674, 0.6853, 0.1888]}, {"w": "a", "b": [0.6908, 0.1674, 0.7, 0.1888]}, {"w": "founder", "b": [0.7055, 0.1674, 0.7723, 0.1888]}, {"w": "and", "b": [0.7778, 0.1674, 0.8094, 0.1888]}, {"w": "CTO", "b": [0.8149, 0.1674, 0.8571, 0.1888]}, {"w": "of", "b": [0.1429, 0.1864, 0.1596, 0.2078]}, {"w": "Polyconseil", "b": [0.1676, 0.1864, 0.2623, 0.2078]}, {"w": "in", "b": [0.2703, 0.1864, 0.2873, 0.2078]}, {"w": "2001,", "b": [0.2953, 0.1864, 0.3401, 0.2078]}, {"w": "the", "b": [0.3481, 0.1864, 0.3744, 0.2078]}, {"w": "firm", "b": [0.3824, 0.1864, 0.4189, 0.2078]}, {"w": "that", "b": [0.4269, 0.1864, 0.4595, 0.2078]}, {"w": "now", "b": [0.4675, 0.1864, 0.5038, 0.2078]}, {"w": "manages", "b": [0.5118, 0.1864, 0.5848, 0.2078]}, {"w": "the", "b": [0.5928, 0.1864, 0.6191, 0.2078]}, {"w": "electric", "b": [0.6271, 0.1864, 0.6874, 0.2078]}, {"w": "car", "b": [0.6954, 0.1864, 0.721, 0.2078]}, {"w": "sharing", "b": [0.729, 0.1864, 0.7914, 0.2078]}, {"w": "service", "b": [0.7994, 0.1864, 0.8571, 0.2078]}, {"w": "Autolib’.", "b": [0.1429, 0.2055, 0.2104, 0.2269]}]}, {"id": "b_2", "type": "paragraph", "text": "Before this he worked as an engineer in a variety of domains: finance (JP Morgan and Société Générale), defense (Canada’s DOD), and healthcare (blood transfusion). He published a few technical books (on C++, WiFi, and internet architectures), and was a Computer Science lecturer in a French engineering school.", "words": [{"w": "Before", "b": [0.1429, 0.2336, 0.1978, 0.255]}, {"w": "this", "b": [0.2027, 0.2336, 0.2334, 0.255]}, {"w": "he", "b": [0.2383, 0.2336, 0.2582, 0.255]}, {"w": "worked", "b": [0.2631, 0.2336, 0.3259, 0.255]}, {"w": "as", "b": [0.3308, 0.2336, 0.3476, 0.255]}, {"w": "an", "b": [0.3525, 0.2336, 0.3731, 0.255]}, {"w": "engineer", "b": [0.378, 0.2336, 0.4504, 0.255]}, {"w": "in", "b": [0.4553, 0.2336, 0.4723, 0.255]}, {"w": "a", "b": [0.4772, 0.2336, 0.4863, 0.255]}, {"w": "variety", "b": [0.4912, 0.2336, 0.5481, 0.255]}, {"w": "of", "b": [0.553, 0.2336, 0.5698, 0.255]}, {"w": "domains:", "b": [0.5747, 0.2336, 0.6519, 0.255]}, {"w": "finance", "b": [0.6568, 0.2336, 0.7181, 0.255]}, {"w": "(JP", "b": [0.723, 0.2336, 0.7492, 0.255]}, {"w": "Morgan", "b": [0.754, 0.2336, 0.8207, 0.255]}, {"w": "and", "b": [0.8256, 0.2336, 0.8572, 0.255]}, {"w": "Société", "b": [0.1429, 0.2526, 0.2018, 0.274]}, {"w": "Générale),", "b": [0.2088, 0.2526, 0.2958, 0.274]}, {"w": "defense", "b": [0.3028, 0.2526, 0.3656, 0.274]}, {"w": "(Canada’s", "b": [0.3726, 0.2526, 0.4522, 0.274]}, {"w": "DOD),", "b": [0.4592, 0.2526, 0.5177, 0.274]}, {"w": "and", "b": [0.5248, 0.2526, 0.5563, 0.274]}, {"w": "healthcare", "b": [0.5633, 0.2526, 0.6498, 0.274]}, {"w": "(blood", "b": [0.6568, 0.2526, 0.7121, 0.274]}, {"w": "transfusion).", "b": [0.7191, 0.2526, 0.8258, 0.274]}, {"w": "He", "b": [0.8329, 0.2526, 0.8571, 0.274]}, {"w": "published", "b": [0.1429, 0.2717, 0.2249, 0.2931]}, {"w": "a", "b": [0.2307, 0.2717, 0.2399, 0.2931]}, {"w": "few", "b": [0.2457, 0.2717, 0.275, 0.2931]}, {"w": "technical", "b": [0.2808, 0.2717, 0.3562, 0.2931]}, {"w": "books", "b": [0.362, 0.2717, 0.4118, 0.2931]}, {"w": "(on", "b": [0.4177, 0.2717, 0.4469, 0.2931]}, {"w": "C++,", "b": [0.4527, 0.2717, 0.4955, 0.2931]}, {"w": "WiFi,", "b": [0.5014, 0.2717, 0.5477, 0.2931]}, {"w": "and", "b": [0.5535, 0.2717, 0.585, 0.2931]}, {"w": "internet", "b": [0.5909, 0.2717, 0.657, 0.2931]}, {"w": "architectures),", "b": [0.6628, 0.2717, 0.7829, 0.2931]}, {"w": "and", "b": [0.7887, 0.2717, 0.8202, 0.2931]}, {"w": "was", "b": [0.8261, 0.2717, 0.8571, 0.2931]}, {"w": "a", "b": [0.1428, 0.2907, 0.152, 0.3121]}, {"w": "Computer", "b": [0.1567, 0.2907, 0.2428, 0.3121]}, {"w": "Science", "b": [0.2475, 0.2907, 0.3097, 0.3121]}, {"w": "lecturer", "b": [0.3144, 0.2907, 0.3791, 0.3121]}, {"w": "in", "b": [0.3838, 0.2907, 0.4008, 0.3121]}, {"w": "a", "b": [0.4055, 0.2907, 0.4147, 0.3121]}, {"w": "French", "b": [0.4194, 0.2907, 0.4783, 0.3121]}, {"w": "engineering", "b": [0.4831, 0.2907, 0.5822, 0.3121]}, {"w": "school.", "b": [0.587, 0.2907, 0.6458, 0.3121]}]}, {"id": "b_3", "type": "paragraph", "text": "A few fun facts: he taught his three children to count in binary with their fingers (up to 1023), he studied microbiology and evolutionary genetics before going into soft‐ ware engineering, and his parachute didn’t open on the second jump.", "words": [{"w": "A", "b": [0.1428, 0.3188, 0.1572, 0.3403]}, {"w": "few", "b": [0.1628, 0.3188, 0.1921, 0.3403]}, {"w": "fun", "b": [0.1977, 0.3188, 0.2263, 0.3403]}, {"w": "facts:", "b": [0.2319, 0.3188, 0.2748, 0.3403]}, {"w": "he", "b": [0.2804, 0.3188, 0.3004, 0.3403]}, {"w": "taught", "b": [0.3059, 0.3188, 0.3589, 0.3403]}, {"w": "his", "b": [0.3645, 0.3188, 0.3889, 0.3403]}, {"w": "three", "b": [0.3945, 0.3188, 0.4374, 0.3403]}, {"w": "children", "b": [0.443, 0.3188, 0.5127, 0.3403]}, {"w": "to", "b": [0.5183, 0.3188, 0.5353, 0.3403]}, {"w": "count", "b": [0.5409, 0.3188, 0.5887, 0.3403]}, {"w": "in", "b": [0.5943, 0.3188, 0.6113, 0.3403]}, {"w": "binary", "b": [0.6169, 0.3188, 0.6715, 0.3403]}, {"w": "with", "b": [0.6771, 0.3188, 0.7144, 0.3403]}, {"w": "their", "b": [0.72, 0.3188, 0.7597, 0.3403]}, {"w": "fingers", "b": [0.7652, 0.3188, 0.8224, 0.3403]}, {"w": "(up", "b": [0.8279, 0.3188, 0.8571, 0.3403]}, {"w": "to", "b": [0.1429, 0.3379, 0.1598, 0.3593]}, {"w": "1023),", "b": [0.1666, 0.3379, 0.2186, 0.3593]}, {"w": "he", "b": [0.2254, 0.3379, 0.2453, 0.3593]}, {"w": "studied", "b": [0.2521, 0.3379, 0.3136, 0.3593]}, {"w": "microbiology", "b": [0.3204, 0.3379, 0.4327, 0.3593]}, {"w": "and", "b": [0.4395, 0.3379, 0.4711, 0.3593]}, {"w": "evolutionary", "b": [0.4778, 0.3379, 0.5843, 0.3593]}, {"w": "genetics", "b": [0.5911, 0.3379, 0.6583, 0.3593]}, {"w": "before", "b": [0.6651, 0.3379, 0.7179, 0.3593]}, {"w": "going", "b": [0.7247, 0.3379, 0.7718, 0.3593]}, {"w": "into", "b": [0.7786, 0.3379, 0.8122, 0.3593]}, {"w": "soft‐", "b": [0.8189, 0.3379, 0.8571, 0.3593]}, {"w": "ware", "b": [0.1429, 0.3569, 0.1829, 0.3783]}, {"w": "engineering,", "b": [0.1876, 0.3569, 0.2915, 0.3783]}, {"w": "and", "b": [0.2962, 0.3569, 0.3278, 0.3783]}, {"w": "his", "b": [0.3325, 0.3569, 0.3568, 0.3783]}, {"w": "parachute", "b": [0.3616, 0.3569, 0.4443, 0.3783]}, {"w": "didn’t", "b": [0.449, 0.3569, 0.4966, 0.3783]}, {"w": "open", "b": [0.5013, 0.3569, 0.5431, 0.3783]}, {"w": "on", "b": [0.5479, 0.3569, 0.5699, 0.3783]}, {"w": "the", "b": [0.5746, 0.3569, 0.6009, 0.3783]}, {"w": "second", "b": [0.6057, 0.3569, 0.664, 0.3783]}, {"w": "jump.", "b": [0.6687, 0.3569, 0.7169, 0.3783]}]}, {"id": "b_4", "type": "paragraph", "text": "Colophon", "words": [{"w": "Colophon", "b": [0.1429, 0.3884, 0.2403, 0.4169]}]}, {"id": "b_5", "type": "paragraph", "text": "The animal on the cover of Hands-On Machine Learning with Scikit-Learn and Ten‐ sorFlow is the fire salamander (Salamandra salamandra), an amphibian found across most of Europe. Its black, glossy skin features large yellow spots on the head and back, signaling the presence of alkaloid toxins. This is a possible source of this amphibian’s common name: contact with these toxins (which they can also spray short distances) causes convulsions and hyperventilation. Either the painful poisons or the moistness of the salamander’s skin (or both) led to a misguided belief that these creatures not only could survive being placed in fire but could extinguish it as well.", "words": [{"w": "The", "b": [0.1429, 0.4262, 0.1757, 0.4476]}, {"w": "animal", "b": [0.1823, 0.4262, 0.2399, 0.4476]}, {"w": "on", "b": [0.2465, 0.4262, 0.2685, 0.4476]}, {"w": "the", "b": [0.2751, 0.4262, 0.3014, 0.4476]}, {"w": "cover", "b": [0.308, 0.4262, 0.3536, 0.4476]}, {"w": "of", "b": [0.3602, 0.4262, 0.377, 0.4476]}, {"w": "Hands-On", "b": [0.3836, 0.426, 0.4698, 0.4476]}, {"w": "Machine", "b": [0.4764, 0.426, 0.5468, 0.4476]}, {"w": "Learning", "b": [0.5534, 0.426, 0.6261, 0.4476]}, {"w": "with", "b": [0.6328, 0.426, 0.6692, 0.4476]}, {"w": "Scikit-Learn", "b": [0.6759, 0.426, 0.7756, 0.4476]}, {"w": "and", "b": [0.7822, 0.426, 0.8136, 0.4476]}, {"w": "Ten‐", "b": [0.8202, 0.426, 0.8571, 0.4476]}, {"w": "sorFlow", "b": [0.1429, 0.445, 0.2066, 0.4666]}, {"w": "is", "b": [0.2124, 0.4452, 0.2257, 0.4666]}, {"w": "the", "b": [0.2315, 0.4452, 0.2578, 0.4666]}, {"w": "fire", "b": [0.2636, 0.4452, 0.2919, 0.4666]}, {"w": "salamander", "b": [0.2977, 0.4452, 0.3941, 0.4666]}, {"w": "(Salamandra", "b": [0.3999, 0.445, 0.5068, 0.4666]}, {"w": "salamandra),", "b": [0.5126, 0.445, 0.6214, 0.4666]}, {"w": "an", "b": [0.6272, 0.4452, 0.6478, 0.4666]}, {"w": "amphibian", "b": [0.6535, 0.4452, 0.7437, 0.4666]}, {"w": "found", "b": [0.7495, 0.4452, 0.7997, 0.4666]}, {"w": "across", "b": [0.8055, 0.4452, 0.8571, 0.4666]}, {"w": "most", "b": [0.1429, 0.4643, 0.1846, 0.4857]}, {"w": "of", "b": [0.1926, 0.4643, 0.2094, 0.4857]}, {"w": "Europe.", "b": [0.2174, 0.4643, 0.2827, 0.4857]}, {"w": "Its", "b": [0.2908, 0.4643, 0.3111, 0.4857]}, {"w": "black,", "b": [0.3191, 0.4643, 0.368, 0.4857]}, {"w": "glossy", "b": [0.3761, 0.4643, 0.4266, 0.4857]}, {"w": "skin", "b": [0.4346, 0.4643, 0.4696, 0.4857]}, {"w": "features", "b": [0.4776, 0.4643, 0.543, 0.4857]}, {"w": "large", "b": [0.5511, 0.4643, 0.5918, 0.4857]}, {"w": "yellow", "b": [0.5999, 0.4643, 0.6537, 0.4857]}, {"w": "spots", "b": [0.6618, 0.4643, 0.705, 0.4857]}, {"w": "on", "b": [0.713, 0.4643, 0.735, 0.4857]}, {"w": "the", "b": [0.7431, 0.4643, 0.7694, 0.4857]}, {"w": "head", "b": [0.7774, 0.4643, 0.8176, 0.4857]}, {"w": "and", "b": [0.8256, 0.4643, 0.8572, 0.4857]}, {"w": "back,", "b": [0.1429, 0.4833, 0.1865, 0.5047]}, {"w": "signaling", "b": [0.1963, 0.4833, 0.2718, 0.5047]}, {"w": "the", "b": [0.2816, 0.4833, 0.3079, 0.5047]}, {"w": "presence", "b": [0.3178, 0.4833, 0.3908, 0.5047]}, {"w": "of", "b": [0.4006, 0.4833, 0.4174, 0.5047]}, {"w": "alkaloid", "b": [0.4272, 0.4833, 0.4936, 0.5047]}, {"w": "toxins.", "b": [0.5034, 0.4833, 0.5596, 0.5047]}, {"w": "This", "b": [0.5694, 0.4833, 0.6066, 0.5047]}, {"w": "is", "b": [0.6164, 0.4833, 0.6296, 0.5047]}, {"w": "a", "b": [0.6394, 0.4833, 0.6486, 0.5047]}, {"w": "possible", "b": [0.6584, 0.4833, 0.7255, 0.5047]}, {"w": "source", "b": [0.7353, 0.4833, 0.79, 0.5047]}, {"w": "of", "b": [0.7998, 0.4833, 0.8166, 0.5047]}, {"w": "this", "b": [0.8264, 0.4833, 0.8571, 0.5047]}, {"w": "amphibian’s", "b": [0.1429, 0.5024, 0.2416, 0.5238]}, {"w": "common", "b": [0.2503, 0.5024, 0.3259, 0.5238]}, {"w": "name:", "b": [0.3345, 0.5024, 0.3857, 0.5238]}, {"w": "contact", "b": [0.3944, 0.5024, 0.4555, 0.5238]}, {"w": "with", "b": [0.4642, 0.5024, 0.5015, 0.5238]}, {"w": "these", "b": [0.5102, 0.5024, 0.553, 0.5238]}, {"w": "toxins", "b": [0.5617, 0.5024, 0.6131, 0.5238]}, {"w": "(which", "b": [0.6218, 0.5024, 0.6799, 0.5238]}, {"w": "they", "b": [0.6886, 0.5024, 0.7245, 0.5238]}, {"w": "can", "b": [0.7331, 0.5024, 0.7625, 0.5238]}, {"w": "also", "b": [0.7712, 0.5024, 0.8038, 0.5238]}, {"w": "spray", "b": [0.8125, 0.5024, 0.8571, 0.5238]}, {"w": "short", "b": [0.1428, 0.5214, 0.1863, 0.5428]}, {"w": "distances)", "b": [0.1929, 0.5214, 0.2766, 0.5428]}, {"w": "causes", "b": [0.2832, 0.5214, 0.3359, 0.5428]}, {"w": "convulsions", "b": [0.3425, 0.5214, 0.4418, 0.5428]}, {"w": "and", "b": [0.4484, 0.5214, 0.4799, 0.5428]}, {"w": "hyperventilation.", "b": [0.4865, 0.5214, 0.629, 0.5428]}, {"w": "Either", "b": [0.6356, 0.5214, 0.687, 0.5428]}, {"w": "the", "b": [0.6936, 0.5214, 0.72, 0.5428]}, {"w": "painful", "b": [0.7266, 0.5214, 0.7861, 0.5428]}, {"w": "poisons", "b": [0.7927, 0.5214, 0.8571, 0.5428]}, {"w": "or", "b": [0.1429, 0.5405, 0.1612, 0.5619]}, {"w": "the", "b": [0.1659, 0.5405, 0.1923, 0.5619]}, {"w": "moistness", "b": [0.197, 0.5405, 0.2798, 0.5619]}, {"w": "of", "b": [0.2846, 0.5405, 0.3013, 0.5619]}, {"w": "the", "b": [0.3061, 0.5405, 0.3324, 0.5619]}, {"w": "salamander’s", "b": [0.3371, 0.5405, 0.4438, 0.5619]}, {"w": "skin", "b": [0.4486, 0.5405, 0.4835, 0.5619]}, {"w": "(or", "b": [0.4883, 0.5405, 0.5138, 0.5619]}, {"w": "both)", "b": [0.5186, 0.5405, 0.5644, 0.5619]}, {"w": "led", "b": [0.5692, 0.5405, 0.5943, 0.5619]}, {"w": "to", "b": [0.599, 0.5405, 0.616, 0.5619]}, {"w": "a", "b": [0.6207, 0.5405, 0.6299, 0.5619]}, {"w": "misguided", "b": [0.6346, 0.5405, 0.7222, 0.5619]}, {"w": "belief", "b": [0.7269, 0.5405, 0.7722, 0.5619]}, {"w": "that", "b": [0.7769, 0.5405, 0.8095, 0.5619]}, {"w": "these", "b": [0.8142, 0.5405, 0.8571, 0.5619]}, {"w": "creatures", "b": [0.1429, 0.5595, 0.2187, 0.5809]}, {"w": "not", "b": [0.2234, 0.5595, 0.2518, 0.5809]}, {"w": "only", "b": [0.2565, 0.5595, 0.2933, 0.5809]}, {"w": "could", "b": [0.2981, 0.5595, 0.3448, 0.5809]}, {"w": "survive", "b": [0.3496, 0.5595, 0.4103, 0.5809]}, {"w": "being", "b": [0.4151, 0.5595, 0.4612, 0.5809]}, {"w": "placed", "b": [0.466, 0.5595, 0.52, 0.5809]}, {"w": "in", "b": [0.5247, 0.5595, 0.5417, 0.5809]}, {"w": "fire", "b": [0.5464, 0.5595, 0.5747, 0.5809]}, {"w": "but", "b": [0.5795, 0.5595, 0.6075, 0.5809]}, {"w": "could", "b": [0.6122, 0.5595, 0.659, 0.5809]}, {"w": "extinguish", "b": [0.6637, 0.5595, 0.7509, 0.5809]}, {"w": "it", "b": [0.7556, 0.5595, 0.7676, 0.5809]}, {"w": "as", "b": [0.7723, 0.5595, 0.7891, 0.5809]}, {"w": "well.", "b": [0.7938, 0.5595, 0.8322, 0.5809]}]}, {"id": "b_6", "type": "paragraph", "text": "Fire salamanders live in shaded forests, hiding in moist crevices and under logs near the pools or other freshwater bodies that facilitate their breeding. Though they spend most of their life on land, they give birth to their young in water. They subsist mostly on a diet of insects, spiders, slugs, and worms. Fire salamanders can grow up to a foot in length, and in captivity, may live as long as 50 years.", "words": [{"w": "Fire", "b": [0.1429, 0.5876, 0.1761, 0.6091]}, {"w": "salamanders", "b": [0.1819, 0.5876, 0.2859, 0.6091]}, {"w": "live", "b": [0.2917, 0.5876, 0.3211, 0.6091]}, {"w": "in", "b": [0.3269, 0.5876, 0.3439, 0.6091]}, {"w": "shaded", "b": [0.3497, 0.5876, 0.4084, 0.6091]}, {"w": "forests,", "b": [0.4143, 0.5876, 0.474, 0.6091]}, {"w": "hiding", "b": [0.4798, 0.5876, 0.5343, 0.6091]}, {"w": "in", "b": [0.5401, 0.5876, 0.5571, 0.6091]}, {"w": "moist", "b": [0.5629, 0.5876, 0.6102, 0.6091]}, {"w": "crevices", "b": [0.616, 0.5876, 0.6819, 0.6091]}, {"w": "and", "b": [0.6877, 0.5876, 0.7193, 0.6091]}, {"w": "under", "b": [0.7251, 0.5876, 0.7751, 0.6091]}, {"w": "logs", "b": [0.7809, 0.5876, 0.8142, 0.6091]}, {"w": "near", "b": [0.82, 0.5876, 0.8572, 0.6091]}, {"w": "the", "b": [0.1429, 0.6067, 0.1692, 0.6281]}, {"w": "pools", "b": [0.1746, 0.6067, 0.2197, 0.6281]}, {"w": "or", "b": [0.2251, 0.6067, 0.2434, 0.6281]}, {"w": "other", "b": [0.2488, 0.6067, 0.2935, 0.6281]}, {"w": "freshwater", "b": [0.2989, 0.6067, 0.3859, 0.6281]}, {"w": "bodies", "b": [0.3913, 0.6067, 0.4456, 0.6281]}, {"w": "that", "b": [0.4509, 0.6067, 0.4835, 0.6281]}, {"w": "facilitate", "b": [0.4889, 0.6067, 0.5598, 0.6281]}, {"w": "their", "b": [0.5652, 0.6067, 0.6048, 0.6281]}, {"w": "breeding.", "b": [0.6102, 0.6067, 0.6887, 0.6281]}, {"w": "Though", "b": [0.6941, 0.6067, 0.7607, 0.6281]}, {"w": "they", "b": [0.766, 0.6067, 0.8019, 0.6281]}, {"w": "spend", "b": [0.8073, 0.6067, 0.8571, 0.6281]}, {"w": "most", "b": [0.1429, 0.6257, 0.1845, 0.6471]}, {"w": "of", "b": [0.1898, 0.6257, 0.2066, 0.6471]}, {"w": "their", "b": [0.2119, 0.6257, 0.2516, 0.6471]}, {"w": "life", "b": [0.2569, 0.6257, 0.2827, 0.6471]}, {"w": "on", "b": [0.288, 0.6257, 0.3101, 0.6471]}, {"w": "land,", "b": [0.3154, 0.6257, 0.3569, 0.6471]}, {"w": "they", "b": [0.3622, 0.6257, 0.3981, 0.6471]}, {"w": "give", "b": [0.4034, 0.6257, 0.4372, 0.6471]}, {"w": "birth", "b": [0.4425, 0.6257, 0.4839, 0.6471]}, {"w": "to", "b": [0.4892, 0.6257, 0.5062, 0.6471]}, {"w": "their", "b": [0.5115, 0.6257, 0.5511, 0.6471]}, {"w": "young", "b": [0.5564, 0.6257, 0.6088, 0.6471]}, {"w": "in", "b": [0.6141, 0.6257, 0.6311, 0.6471]}, {"w": "water.", "b": [0.6364, 0.6257, 0.6858, 0.6471]}, {"w": "They", "b": [0.6911, 0.6257, 0.7335, 0.6471]}, {"w": "subsist", "b": [0.7388, 0.6257, 0.7953, 0.6471]}, {"w": "mostly", "b": [0.8006, 0.6257, 0.8571, 0.6471]}, {"w": "on", "b": [0.1429, 0.6448, 0.1649, 0.6662]}, {"w": "a", "b": [0.1698, 0.6448, 0.179, 0.6662]}, {"w": "diet", "b": [0.1839, 0.6448, 0.2157, 0.6662]}, {"w": "of", "b": [0.2206, 0.6448, 0.2374, 0.6662]}, {"w": "insects,", "b": [0.2423, 0.6448, 0.3034, 0.6662]}, {"w": "spiders,", "b": [0.3083, 0.6448, 0.3724, 0.6662]}, {"w": "slugs,", "b": [0.3773, 0.6448, 0.4235, 0.6662]}, {"w": "and", "b": [0.4284, 0.6448, 0.4599, 0.6662]}, {"w": "worms.", "b": [0.4648, 0.6448, 0.5269, 0.6662]}, {"w": "Fire", "b": [0.5319, 0.6448, 0.565, 0.6662]}, {"w": "salamanders", "b": [0.57, 0.6448, 0.674, 0.6662]}, {"w": "can", "b": [0.6789, 0.6448, 0.7083, 0.6662]}, {"w": "grow", "b": [0.7132, 0.6448, 0.7556, 0.6662]}, {"w": "up", "b": [0.7605, 0.6448, 0.7825, 0.6662]}, {"w": "to", "b": [0.7874, 0.6448, 0.8044, 0.6662]}, {"w": "a", "b": [0.8093, 0.6448, 0.8185, 0.6662]}, {"w": "foot", "b": [0.8234, 0.6448, 0.8572, 0.6662]}, {"w": "in", "b": [0.1429, 0.6638, 0.1598, 0.6852]}, {"w": "length,", "b": [0.1646, 0.6638, 0.2221, 0.6852]}, {"w": "and", "b": [0.2268, 0.6638, 0.2583, 0.6852]}, {"w": "in", "b": [0.2631, 0.6638, 0.28, 0.6852]}, {"w": "captivity,", "b": [0.2848, 0.6638, 0.3596, 0.6852]}, {"w": "may", "b": [0.3643, 0.6638, 0.3997, 0.6852]}, {"w": "live", "b": [0.4044, 0.6638, 0.4338, 0.6852]}, {"w": "as", "b": [0.4385, 0.6638, 0.4553, 0.6852]}, {"w": "long", "b": [0.46, 0.6638, 0.4971, 0.6852]}, {"w": "as", "b": [0.5018, 0.6638, 0.5186, 0.6852]}, {"w": "50", "b": [0.5233, 0.6638, 0.5433, 0.6852]}, {"w": "years.", "b": [0.548, 0.6638, 0.5957, 0.6852]}]}, {"id": "b_7", "type": "paragraph", "text": "The fire salamander’s numbers have been reduced by destruction of their forest habi‐ tat and capture for the pet trade, but the greatest threat is the susceptibility of their moisture-permeable skin to pollutants and microbes. Since 2014, they have become extinct in parts of the Netherlands and Belgium due to an introduced fungus.", "words": [{"w": "The", "b": [0.1429, 0.6919, 0.1757, 0.7134]}, {"w": "fire", "b": [0.181, 0.6919, 0.2093, 0.7134]}, {"w": "salamander’s", "b": [0.2147, 0.6919, 0.3214, 0.7134]}, {"w": "numbers", "b": [0.3267, 0.6919, 0.4006, 0.7134]}, {"w": "have", "b": [0.406, 0.6919, 0.4444, 0.7134]}, {"w": "been", "b": [0.4497, 0.6919, 0.4894, 0.7134]}, {"w": "reduced", "b": [0.4947, 0.6919, 0.562, 0.7134]}, {"w": "by", "b": [0.5673, 0.6919, 0.5875, 0.7134]}, {"w": "destruction", "b": [0.5928, 0.6919, 0.6882, 0.7134]}, {"w": "of", "b": [0.6935, 0.6919, 0.7103, 0.7134]}, {"w": "their", "b": [0.7156, 0.6919, 0.7553, 0.7134]}, {"w": "forest", "b": [0.7606, 0.6919, 0.808, 0.7134]}, {"w": "habi‐", "b": [0.8133, 0.6919, 0.8571, 0.7134]}, {"w": "tat", "b": [0.1429, 0.711, 0.1643, 0.7324]}, {"w": "and", "b": [0.171, 0.711, 0.2025, 0.7324]}, {"w": "capture", "b": [0.2092, 0.711, 0.2717, 0.7324]}, {"w": "for", "b": [0.2784, 0.711, 0.3029, 0.7324]}, {"w": "the", "b": [0.3096, 0.711, 0.336, 0.7324]}, {"w": "pet", "b": [0.3427, 0.711, 0.3688, 0.7324]}, {"w": "trade,", "b": [0.3755, 0.711, 0.4233, 0.7324]}, {"w": "but", "b": [0.43, 0.711, 0.458, 0.7324]}, {"w": "the", "b": [0.4647, 0.711, 0.491, 0.7324]}, {"w": "greatest", "b": [0.4977, 0.711, 0.562, 0.7324]}, {"w": "threat", "b": [0.5687, 0.711, 0.6179, 0.7324]}, {"w": "is", "b": [0.6246, 0.711, 0.6378, 0.7324]}, {"w": "the", "b": [0.6445, 0.711, 0.6708, 0.7324]}, {"w": "susceptibility", "b": [0.6775, 0.711, 0.7873, 0.7324]}, {"w": "of", "b": [0.794, 0.711, 0.8108, 0.7324]}, {"w": "their", "b": [0.8175, 0.711, 0.8571, 0.7324]}, {"w": "moisture-permeable", "b": [0.1428, 0.73, 0.3125, 0.7515]}, {"w": "skin", "b": [0.3192, 0.73, 0.3542, 0.7515]}, {"w": "to", "b": [0.3609, 0.73, 0.3779, 0.7515]}, {"w": "pollutants", "b": [0.3847, 0.73, 0.4683, 0.7515]}, {"w": "and", "b": [0.4751, 0.73, 0.5066, 0.7515]}, {"w": "microbes.", "b": [0.5134, 0.73, 0.595, 0.7515]}, {"w": "Since", "b": [0.6018, 0.73, 0.6463, 0.7515]}, {"w": "2014,", "b": [0.653, 0.73, 0.6978, 0.7515]}, {"w": "they", "b": [0.7045, 0.73, 0.7404, 0.7515]}, {"w": "have", "b": [0.7472, 0.73, 0.7856, 0.7515]}, {"w": "become", "b": [0.7923, 0.73, 0.8571, 0.7515]}, {"w": "extinct", "b": [0.1429, 0.7491, 0.2001, 0.7705]}, {"w": "in", "b": [0.2048, 0.7491, 0.2218, 0.7705]}, {"w": "parts", "b": [0.2265, 0.7491, 0.2683, 0.7705]}, {"w": "of", "b": [0.273, 0.7491, 0.2898, 0.7705]}, {"w": "the", "b": [0.2945, 0.7491, 0.3209, 0.7705]}, {"w": "Netherlands", "b": [0.3256, 0.7491, 0.4279, 0.7705]}, {"w": "and", "b": [0.4327, 0.7491, 0.4642, 0.7705]}, {"w": "Belgium", "b": [0.4689, 0.7491, 0.5392, 0.7705]}, {"w": "due", "b": [0.5439, 0.7491, 0.5748, 0.7705]}, {"w": "to", "b": [0.5796, 0.7491, 0.5965, 0.7705]}, {"w": "an", "b": [0.6013, 0.7491, 0.6218, 0.7705]}, {"w": "introduced", "b": [0.6265, 0.7491, 0.7186, 0.7705]}, {"w": "fungus.", "b": [0.7233, 0.7491, 0.7851, 0.7705]}]}, {"id": "b_8", "type": "paragraph", "text": "Many of the animals on O’Reilly covers are endangered; all of them are important to the world. To learn more about how you can help, go to animals.oreilly.com.", "words": [{"w": "Many", "b": [0.1429, 0.7772, 0.1907, 0.7986]}, {"w": "of", "b": [0.1964, 0.7772, 0.2132, 0.7986]}, {"w": "the", "b": [0.219, 0.7772, 0.2453, 0.7986]}, {"w": "animals", "b": [0.251, 0.7772, 0.3163, 0.7986]}, {"w": "on", "b": [0.322, 0.7772, 0.3441, 0.7986]}, {"w": "O’Reilly", "b": [0.3498, 0.7772, 0.4167, 0.7986]}, {"w": "covers", "b": [0.4225, 0.7772, 0.4758, 0.7986]}, {"w": "are", "b": [0.4815, 0.7772, 0.5073, 0.7986]}, {"w": "endangered;", "b": [0.513, 0.7772, 0.6157, 0.7986]}, {"w": "all", "b": [0.6215, 0.7772, 0.6412, 0.7986]}, {"w": "of", "b": [0.6469, 0.7772, 0.6637, 0.7986]}, {"w": "them", "b": [0.6694, 0.7772, 0.7128, 0.7986]}, {"w": "are", "b": [0.7186, 0.7772, 0.7443, 0.7986]}, {"w": "important", "b": [0.7501, 0.7772, 0.8344, 0.7986]}, {"w": "to", "b": [0.8402, 0.7772, 0.8572, 0.7986]}, {"w": "the", "b": [0.1429, 0.7963, 0.1692, 0.8177]}, {"w": "world.", "b": [0.1739, 0.7963, 0.2276, 0.8177]}, {"w": "To", "b": [0.2323, 0.7963, 0.2537, 0.8177]}, {"w": "learn", "b": [0.2585, 0.7963, 0.3009, 0.8177]}, {"w": "more", "b": [0.3056, 0.7963, 0.3499, 0.8177]}, {"w": "about", "b": [0.3546, 0.7963, 0.4024, 0.8177]}, {"w": "how", "b": [0.4071, 0.7963, 0.4431, 0.8177]}, {"w": "you", "b": [0.4478, 0.7963, 0.4791, 0.8177]}, {"w": "can", "b": [0.4838, 0.7963, 0.5132, 0.8177]}, {"w": "help,", "b": [0.5179, 0.7963, 0.5582, 0.8177]}, {"w": "go", "b": [0.5629, 0.7963, 0.5833, 0.8177]}, {"w": "to", "b": [0.588, 0.7963, 0.605, 0.8177]}, {"w": "animals.oreilly.com.", "b": [0.6098, 0.7961, 0.7712, 0.8177]}]}, {"id": "b_9", "type": "paragraph", "text": "The cover image is from Wood’s Illustrated Natural History. The cover fonts are URW Typewriter and Guardian Sans. The text font is Adobe Minion Pro; the heading font is Adobe Myriad Condensed; and the code font is Dalton Maag’s Ubuntu Mono.", "words": [{"w": "The", "b": [0.1429, 0.8244, 0.1757, 0.8458]}, {"w": "cover", "b": [0.181, 0.8244, 0.2267, 0.8458]}, {"w": "image", "b": [0.2319, 0.8244, 0.2823, 0.8458]}, {"w": "is", "b": [0.2876, 0.8244, 0.3009, 0.8458]}, {"w": "from", "b": [0.3061, 0.8244, 0.3477, 0.8458]}, {"w": "Wood’s", "b": [0.353, 0.8242, 0.4099, 0.8458]}, {"w": "Illustrated", "b": [0.4152, 0.8242, 0.4983, 0.8458]}, {"w": "Natural", "b": [0.5036, 0.8242, 0.5669, 0.8458]}, {"w": "History.", "b": [0.5722, 0.8242, 0.6372, 0.8458]}, {"w": "The", "b": [0.6425, 0.8244, 0.6753, 0.8458]}, {"w": "cover", "b": [0.6806, 0.8244, 0.7263, 0.8458]}, {"w": "fonts", "b": [0.7316, 0.8244, 0.7734, 0.8458]}, {"w": "are", "b": [0.7786, 0.8244, 0.8044, 0.8458]}, {"w": "URW", "b": [0.8097, 0.8244, 0.8571, 0.8458]}, {"w": "Typewriter", "b": [0.1429, 0.8434, 0.234, 0.8648]}, {"w": "and", "b": [0.24, 0.8434, 0.2715, 0.8648]}, {"w": "Guardian", "b": [0.2774, 0.8434, 0.3574, 0.8648]}, {"w": "Sans.", "b": [0.3633, 0.8434, 0.4061, 0.8648]}, {"w": "The", "b": [0.412, 0.8434, 0.4449, 0.8648]}, {"w": "text", "b": [0.4508, 0.8434, 0.4822, 0.8648]}, {"w": "font", "b": [0.4881, 0.8434, 0.5222, 0.8648]}, {"w": "is", "b": [0.5282, 0.8434, 0.5414, 0.8648]}, {"w": "Adobe", "b": [0.5473, 0.8434, 0.6022, 0.8648]}, {"w": "Minion", "b": [0.6081, 0.8434, 0.6713, 0.8648]}, {"w": "Pro;", "b": [0.6772, 0.8434, 0.712, 0.8648]}, {"w": "the", "b": [0.718, 0.8434, 0.7443, 0.8648]}, {"w": "heading", "b": [0.7502, 0.8434, 0.8171, 0.8648]}, {"w": "font", "b": [0.823, 0.8434, 0.8571, 0.8648]}, {"w": "is", "b": [0.1429, 0.8625, 0.1561, 0.8839]}, {"w": "Adobe", "b": [0.1608, 0.8625, 0.2157, 0.8839]}, {"w": "Myriad", "b": [0.2205, 0.8625, 0.2814, 0.8839]}, {"w": "Condensed;", "b": [0.2861, 0.8625, 0.3855, 0.8839]}, {"w": "and", "b": [0.3902, 0.8625, 0.4218, 0.8839]}, {"w": "the", "b": [0.4265, 0.8625, 0.4528, 0.8839]}, {"w": "code", "b": [0.4576, 0.8625, 0.4968, 0.8839]}, {"w": "font", "b": [0.5016, 0.8625, 0.5357, 0.8839]}, {"w": "is", "b": [0.5405, 0.8625, 0.5537, 0.8839]}, {"w": "Dalton", "b": [0.5584, 0.8625, 0.6165, 0.8839]}, {"w": "Maag’s", "b": [0.6212, 0.8625, 0.6774, 0.8839]}, {"w": "Ubuntu", "b": [0.6821, 0.8625, 0.7475, 0.8839]}, {"w": "Mono.", "b": [0.7523, 0.8625, 0.8071, 0.8839]}]}]}]}